!function(){"use strict";const e=3;const t=new class{constructor(e){this.level=e}setLevel(e){this.level=e}info(...e){this.level}trace(...e){this.level}warning(...e){this.level}error(...e){this.level}}(e);const n=chrome,o=(Object.prototype.toString,e=>null==e),r="__SP_COPY__",s="__SP_KEYBOARD_TYPE__",E="__SP_CONTEXT_MENU_TYPE__",a=["https://*/*","http://*/*","file://*/*"],c=["COPY_TYPE","KEYBOARD_TYPE","CONTEXT_MENU_TYPE","QUERY_STATE","DEBUG_MOUSE_EVENT","DEBUG_FOCUS_EVENT","DEBUG_EDITABLE","DEBUG_PASTE_EVENT"].reduce(((e,t)=>({...e,[t]:`__${t}__PC__`})),{});class i{static async postToContent(e){return new Promise((r=>{n.tabs.query({active:!0,currentWindow:!0}).then((t=>{const s=t[0],E=s&&s.id,c=s&&s.url;!c||a.some((e=>new RegExp(e).test(c)))?o(E)?r(null):n.tabs.sendMessage(E,e).then(r):r(null)})).catch((e=>{t.warning("Send Message Error",e)}))}))}static onPopupMessage(e){const t=(t,n,o)=>{const r=e(t);r&&r.type===t.type&&o(r)};return n.runtime.onMessage.addListener(t),()=>{n.runtime.onMessage.removeListener(t)}}static isPCRequestType(e){return e&&e.type&&e.type.endsWith("__PC__")}}i.REQUEST=c;const l=self!==top,_=e=>{try{return JSON.parse(e)}catch(e){}return null},u=e=>{try{return JSON.stringify(e)}catch(e){}return null},T=e=>String(e)+"__STORAGE__",p={get:function(e,t){const n=T(t),o=e.getItem(n);if(!o)return null;const r=(e=>{try{const t=_(e);return t?Number.isNaN(t.expire)||t.expire&&Date.now()>t.expire?null:t.origin:null}catch(e){return null}})(o);return null===r&&this.remove(e,n),r},set:function(e,t,n,o=null){const r=T(t),s=((e,t)=>{try{const n={origin:e,expire:null};if(t){const e=Date.now();n.expire=t+e}return u(n)}catch(e){return null}})(n,o);if(s)return e.setItem(r,s)},getOrigin:function(e,t){const n=T(t);return e.getItem(n)},remove:function(e,t){const n=T(t);return e.removeItem(n)}},d={get:function(e){return p.get(localStorage,e)},set:function(e,t,n=null){return p.set(localStorage,e,t,n)},getOrigin:function(e){return p.getOrigin(localStorage,e)},remove:function(e){return p.remove(localStorage,e)}},y={get:function(e){return p.get(sessionStorage,e)},set:function(e,t,n=null){return p.set(sessionStorage,e,t,n)},getOrigin:function(e){return p.getOrigin(sessionStorage,e)},remove:function(e){return p.remove(sessionStorage,e)}},g="lah2AqVqxG",S=["COPY_TYPE","KEYBOARD_TYPE","CONTEXT_MENU_TYPE","DEBUG_MOUSE_EVENT","DEBUG_FOCUS_EVENT","DEBUG_EDITABLE","DEBUG_PASTE"].reduce(((e,t)=>({...e,[t]:`__${t}__CI__`})),{}),U="START",O="CLOSE";class P{static postToInject(e){window.dispatchEvent(new CustomEvent(g,{detail:u(e)}))}static onContentMessage(e){const t=t=>{const n=_(t.detail);n&&n.type&&void 0!==n.payload&&e(n)};return window.addEventListener(g,t),()=>{window.removeEventListener(g,t)}}static isCIRequestType(e){return e&&e.type&&e.type.endsWith("__CI__")}}P.REQUEST=S;const h="COPY",C="MENU",N="KEYBOARD",Y="COPY_ONCE",D="MENU_ONCE",B="KEYBOARD_ONCE",R=e=>{switch(t.info("Content Receive Popup Message",location.host,e),e.type){case c.COPY_TYPE:P.postToInject({type:S.COPY_TYPE,payload:e.payload.checked?U:O}),e.payload.once?y.set(r,e.payload.checked):d.set(r,e.payload.checked);break;case c.KEYBOARD_TYPE:P.postToInject({type:S.KEYBOARD_TYPE,payload:e.payload.checked?U:O}),e.payload.once?y.set(s,e.payload.checked):d.set(s,e.payload.checked);break;case c.CONTEXT_MENU_TYPE:P.postToInject({type:S.CONTEXT_MENU_TYPE,payload:e.payload.checked?U:O}),e.payload.once?y.set(E,e.payload.checked):d.set(E,e.payload.checked);break;case c.QUERY_STATE:if(l)break;return{type:e.type,payload:{[h]:!!d.get(r),[C]:!!d.get(E),[N]:!!d.get(s),[Y]:!!y.get(r),[D]:!!y.get(E),[B]:!!y.get(s)}};case i.REQUEST.DEBUG_MOUSE_EVENT:P.postToInject({type:P.REQUEST.DEBUG_MOUSE_EVENT,payload:null});break;case i.REQUEST.DEBUG_FOCUS_EVENT:P.postToInject({type:P.REQUEST.DEBUG_FOCUS_EVENT,payload:null});break;case i.REQUEST.DEBUG_EDITABLE:P.postToInject({type:P.REQUEST.DEBUG_EDITABLE,payload:null});break;case i.REQUEST.DEBUG_PASTE_EVENT:P.postToInject({type:P.REQUEST.DEBUG_PASTE,payload:null})}};t.info("Content Script Loaded",location.href),i.onPopupMessage(R)}();