/**
 * Minified by jsDelivr using Terser v5.39.0.
 * Original file: /npm/gm-webext-pref@0.4.2/dist/GM_webextPref.node.mjs
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
import{createPref}from"webext-pref";import{createUI,createBinding}from"webext-pref-ui";import EventLite from"event-lite";function createGMStorage(){const e="function"==typeof GM_setValue?o(GM_setValue):GM.setValue.bind(GM),t="function"==typeof GM_getValue?o(GM_getValue):GM.getValue.bind(GM),n="function"==typeof GM_deleteValue?o(GM_deleteValue):GM.deleteValue.bind(GM),r=new EventLite;return"function"==typeof GM_addValueChangeListener&&GM_addValueChangeListener("webext-pref-message",((e,t,n)=>{const o=JSON.parse(n);for(const e of Object.keys(o))"object"==typeof o[e]&&o[e].$undefined&&(o[e]=void 0);r.emit("change",o)})),Object.assign(r,{getMany:function(e){return Promise.all(e.map((e=>t(`webext-pref/${e}`).then((t=>[e,"string"==typeof t?JSON.parse(t):t]))))).then((e=>{const t={};for(const[n,r]of e)t[n]=r;return t}))},setMany:function(t){return Promise.all(Object.entries(t).map((([t,n])=>e(`webext-pref/${t}`,JSON.stringify(n))))).then((()=>{if("function"==typeof GM_addValueChangeListener)return e("webext-pref-message",JSON.stringify(t));r.emit("change",t)}))},deleteMany:function(t){return Promise.all(t.map((e=>n(`webext-pref/${e}`)))).then((()=>{if("function"==typeof GM_addValueChangeListener){const n={};for(const e of t)n[e]={$undefined:!0};return e("webext-pref-message",JSON.stringify(n))}const n={};for(const e of t)n[e]=void 0;r.emit("change",n)}))}});function o(e){return(...t)=>{try{return Promise.resolve(e(...t))}catch(e){return Promise.reject(e)}}}}function GM_webextPref({default:e,separator:t,css:n="",...r}){const o=createPref(e,t),i=o.connect(createGMStorage());let a=!1;const d="function"==typeof GM_registerMenuCommand?GM_registerMenuCommand:"undefined"!=typeof GM&&GM&&GM.registerMenuCommand?GM.registerMenuCommand.bind(GM):void 0;return d&&d(`${c()} - Configure`,l),Object.assign(o,{ready:()=>i,openDialog:l});function l(){if(a)return;let e;a=!0;const t=document.createElement("div");t.className="webext-pref-modal",t.onclick=()=>{t.classList.remove("webext-pref-modal-open"),t.addEventListener("transitionend",(()=>{e&&e(),t.remove(),a=!1}))};const i=document.createElement("style");i.textContent=`body{overflow:hidden}.webext-pref-modal{position:fixed;top:0;right:0;bottom:0;left:0;background:rgba(0,0,0,.5);overflow:auto;z-index:999999;opacity:0;transition:opacity .2s linear;display:flex}.webext-pref-modal-open{opacity:1}.webext-pref-modal::after,.webext-pref-modal::before{content:"";display:block;height:30px;visibility:hidden}.webext-pref-iframe-wrap{margin:auto}.webext-pref-iframe{margin:30px 0;display:inline-block;width:100%;max-width:100%;background:#fff;border-width:0;box-shadow:0 0 30px #000;transform:translateY(-20px);transition:transform .2s linear}.webext-pref-modal-open .webext-pref-iframe{transform:none}\n      body {\n        padding-right: ${window.innerWidth-document.documentElement.offsetWidth}px;\n      }\n    `;const d=document.createElement("iframe");d.className="webext-pref-iframe",d.srcdoc='\n      <html>\n        <head>\n          <style class="dialog-style"></style>\n        </head>\n        <body>\n          <div class="dialog-body"></div>\n        </body>\n      </html>\n    ';const l=document.createElement("div");l.className="webext-pref-iframe-wrap",l.append(d),t.append(i,l),document.body.appendChild(t),d.onload=()=>{d.onload=null,d.contentDocument.querySelector(".dialog-style").textContent="body{display:inline-block;font-size:16px;font-family:sans-serif;white-space:nowrap;overflow:hidden;margin:0;color:#3d3d3d;line-height:1}input[type=number],input[type=text],select,textarea{display:block;width:100%;box-sizing:border-box;height:2em;font:inherit;padding:0 .3em;border:1px solid #9e9e9e;cursor:pointer}select[multiple],textarea{height:6em}input[type=number]:hover,input[type=text]:hover,select:hover,textarea:hover{border-color:#d5d5d5}input[type=number]:focus,input[type=text]:focus,select:focus,textarea:focus{cursor:auto;border-color:#3a93ee}textarea{line-height:1.5}input[type=checkbox],input[type=radio]{display:inline-block;width:1em;height:1em;font:inherit;margin:0}button{box-sizing:border-box;height:2em;font:inherit;border:1px solid #9e9e9e;cursor:pointer;background:0 0}button:hover{border-color:#d5d5d5}button:focus{border-color:#3a93ee}.dialog-body{margin:2em}.webext-pref-toolbar{display:flex;align-items:center;margin-bottom:1em}.dialog-title{font-size:1.34em;margin:0 2em 0 0;flex-grow:1}.webext-pref-toolbar button{font-size:.7em;margin-left:.5em}.webext-pref-nav{display:flex;margin-bottom:1em}.webext-pref-nav select{text-align:center;text-align-last:center}.webext-pref-nav button{width:2em}.webext-pref-number,.webext-pref-radiogroup,.webext-pref-select,.webext-pref-text,.webext-pref-textarea{margin:1em 0}.webext-pref-body>:first-child{margin-top:0}.webext-pref-body>:last-child{margin-bottom:0}.webext-pref-number>input,.webext-pref-select>select,.webext-pref-text>input,.webext-pref-textarea>textarea{margin:.3em 0}.webext-pref-checkbox,.webext-pref-radio{margin:.5em 0;padding-left:1.5em}.webext-pref-checkbox>input,.webext-pref-radio>input{margin-left:-1.5em;margin-right:.5em;vertical-align:middle}.webext-pref-checkbox>label,.webext-pref-radio>label{cursor:pointer;vertical-align:middle}.webext-pref-checkbox>label:hover,.webext-pref-radio>label:hover{color:#707070}.webext-pref-checkbox-children,.webext-pref-radio-children{margin:.7em 0 0;padding:0;border-width:0}.webext-pref-checkbox-children[disabled],.webext-pref-radio-children[disabled]{opacity:.5}.webext-pref-checkbox-children>:first-child,.webext-pref-radio-children>:first-child{margin-top:0}.webext-pref-checkbox-children>:last-child,.webext-pref-radio-children>:last-child{margin-bottom:0}.webext-pref-checkbox-children>:last-child>:last-child,.webext-pref-radio-children>:last-child>:last-child{margin-bottom:0}.webext-pref-help{color:#969696}.responsive{white-space:normal}.responsive .dialog-body{margin:1em}.responsive .webext-pref-toolbar{display:block}.responsive .dialog-title{margin:0 0 1em 0}.responsive .webext-pref-toolbar button{font-size:1em}.responsive .webext-pref-nav{display:block}"+n;const i=d.contentDocument.querySelector(".dialog-body");i.append(createUI(r)),e=createBinding({pref:o,root:i,...r});const a=document.createElement("h2");a.className="dialog-title",a.textContent=c(),d.contentDocument.querySelector(".webext-pref-toolbar").prepend(a),d.contentDocument.body.offsetWidth>t.offsetWidth&&d.contentDocument.body.classList.add("responsive"),d.style=`\n        width: ${d.contentDocument.body.offsetWidth}px;\n        height: ${d.contentDocument.body.scrollHeight}px;\n      `,t.classList.add("webext-pref-modal-open")}}function c(){return"object"==typeof GM_info?GM_info.script.name:GM.info.script.name}}export{GM_webextPref as default};
//# sourceMappingURL=/sm/9e95d0659694f555160ca4962916bea60cf576c42f313fb3c5e567c3ab9595b3.map