let e=1;export const OnChrome=!0;export const OnFirefox=!1;export const OnEdge=!1;export const OnSafari=!1;let t,o,n=navigator.userAgentData,r=n.brands;export const IsEdg_=!!r.find(e=>e.brand.includes("Edge")||e.brand.includes("Microsoft"));export const CurCVer_=(t=r.find(e=>e.brand.includes("Chromium")))&&parseInt(t.version)>82?parseInt(t.version):0|(navigator.userAgent.match(/\bChrom(?:e|ium)\/(\d+)/)||[0,998])[1];export let CurFFVer_=999;export let BrowserName_;export let PageOs_=9;export const setupPageOs_=e=>{PageOs_=e};export const browser_=chrome;export const isVApiReady_=new Promise(e=>{let t;o=new Promise(e=>{t=e}),addEventListener("VimiumC",()=>{h(t),nextTick_(e)},{once:!0,capture:!0})});let l=4,s={},i=new Map,c=null,a=null,p=null,u=Object.create(null),d=1,_=null;export let selfTabId_=-1;let x=e=>{if(_&&(a=0),e===!1)return void alert("Can not send info to the background: not trusted");let t=u[e.i];delete u[e.i];for(let o=e.a,n=0;n<t.length;n++)t[n](o[n]);VApi&&_&&Object.keys(u).length===0&&k()},m=e=>{e=structuredClone(e),x(e)},g=()=>{_=0,console.log("[WARNING] the temp port is disconnected unexpectedly; need to replay messages using VApi"),a&&o.then(()=>{let e=a,t=e?Object.keys(u):[];a=0;for(let o of t){let t=u[o],n=e[o];n&&t&&(c=n,p=t,b(n.length))}})},b=e=>{if(!c)return;let t=VApi,o=c.length;if(o>(e||1))return void h(b.bind(null,o));if(t&&_&&Object.keys(u).length===0&&k(),e===0)return void(c=p=null);let n=d++;u[n]=p,p=null;t?t.r[0](40,{i:n,q:c},x):(_==null&&(_=browser_.runtime.connect({name:"128"}),_.onMessage.addListener(x),_.onDisconnect.addListener(g)),_&&_.postMessage({H:40,i:n,q:c}),a!==0&&((a||(a=Object.create(null)))[n]=c)),c=null};export const post_=(e,t)=>new Promise(o=>{c||f(),c.push({n:e,q:t!==void 0?t:null}),p.push(o)});let f=()=>{c||(c=[],p=[],h(b))};export{f as disconnect_};let k=()=>{let e=_;_=null,e&&(e.onDisconnect.removeListener(g),e.onMessage.removeListener(x),e.disconnect())},h=queueMicrotask;export const $=e=>document.querySelector(e);export const $$=(e,t)=>{let o=(t||document).querySelectorAll(e);return[].slice.call(o)};export const toggleDark_=e=>{let t=document.head.querySelector("meta[name=color-scheme]"),o=e===2?"light dark":e===1?"dark":"light";if(t.content!==o){t.content=o;let n=document.documentElement.classList;n.toggle("no-dark",!e),n.toggle("dark",e===1)}};export const toggleReduceMotion_=e=>{document.documentElement.classList.toggle("less-motion",e)};export let enableNextTick_;let w=null;export const nextTick_=(()=>{let e=()=>{let n=t.length;for(let e=0;e<n;e++)(0,t[e])();t.length>n?(t.splice(0,n),h(e)):(t.length=0,o=0)},t=[],o=0;return enableNextTick_=(t,o)=>{l=(l|t)&~(o||0),l===7&&h(e)},(o,n)=>{if(t.length<=0&&l===7&&h(e),n===9)t.unshift(o);else{let e=n?o.bind(null,n):o;t.push(e)}}})();export const import2_=e=>import(e);export const pageTrans_=(e,t)=>{let o=i.get(e);return t!=null&&o&&(o=o.replace(/\$\d/g,e=>t[+e[1]-1])),o};let y=(e,t)=>e&&e.split(" ").reduce((e,o)=>e||(o.includes("=")?o.startsWith(t)?o.slice(t.length+1):e:o),"");export const bTrans_=browser_.i18n.getMessage;let O=location.pathname.replace("/pages/","").split(".")[0],T=bTrans_("lang1");export const pageLangs_=y(bTrans_("i18n"),O)||T||"en";let V=!0,v=e=>{let t=i;for(let o of e.reverse()){if(!o)continue;let e=V?o.default:JSON.parse(o.slice(14));for(let o in e)t.set(o,e[o])}enableNextTick_(2)};export const onDicts_=V?v:0;export const curPagePath_=V?O:0;if(O!=="options"&&O!=="action"&&onDicts_(await Promise.all(pageLangs_.split(",").map(e=>import(`/i18n/${e}/${O==="show"?"action":O}.js`)))),browser_.storage.local.get("autoDarkMode",e=>{let t=e&&e.autoDarkMode;return(t===!1||t===1||t===0)&&toggleDark_(t?1:0),browser_.runtime.lastError}),T&&O!=="action"){let e=bTrans_("v"+O);e&&(document.title="Vimium C "+e)}O==="options"&&isVApiReady_.then(()=>{VApi.r[0](40,{i:1,q:[{n:26,q:null}]},e=>{e!==!1&&(selfTabId_=e.a[0])})});export const simulateClick_=(e,t)=>{let o;return t=t||{ctrlKey:!1,altKey:!1,shiftKey:!1,metaKey:!1},o=new MouseEvent("click",{bubbles:!0,cancelable:!0,composed:!0,view:window,detail:1,screenX:0,screenY:0,clientX:0,clientY:0,ctrlKey:t.ctrlKey,altKey:t.altKey,shiftKey:t.shiftKey,metaKey:t.metaKey,button:0,buttons:1,relatedTarget:null}),e.dispatchEvent(o)};export const hasShift_=e=>e.shiftKey;export const isRepeated_=e=>e.repeat;export const prevent_=e=>{e.preventDefault();let t=e.type==="keydown"?e.keyCode:0;!t||!PageOs_&&e.metaKey||VApi&&(VApi.a()[t]=1)};export const escapeAllForRe_=e=>e.replace(/[$()*+.?\[\\\]\^{|}]/g,"\\$&");typeof VApi=="undefined"&&(globalThis.VApi=void 0);