const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["chunks/search-D2LwWSFS.js","chunks/store-aiW_fD0x.js"])))=>i.map(i=>d[i]);
import{search as f,getSearchEngineFallback as b,saveRecentSearch as L}from"./chunks/search-D2LwWSFS.js";import{g as _,D as k}from"./chunks/store-aiW_fD0x.js";const T="modulepreload",S=function(e){return"/"+e},v={},$=function(t,n,u){let m=Promise.resolve();if(n&&n.length>0){let c=function(r){return Promise.all(r.map(i=>Promise.resolve(i).then(d=>({status:"fulfilled",value:d}),d=>({status:"rejected",reason:d}))))};document.getElementsByTagName("link");const s=document.querySelector("meta[property=csp-nonce]"),h=s?.nonce||s?.getAttribute("nonce");m=c(n.map(r=>{if(r=S(r),r in v)return;v[r]=!0;const i=r.endsWith(".css"),d=i?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${r}"]${d}`))return;const a=document.createElement("link");if(a.rel=i?"stylesheet":T,i||(a.as="script"),a.crossOrigin="",a.href=r,h&&a.setAttribute("nonce",h),document.head.appendChild(a),i)return new Promise((y,w)=>{a.addEventListener("load",y),a.addEventListener("error",()=>w(new Error(`Unable to preload CSS for ${r}`)))})}))}function p(c){const s=new Event("vite:preloadError",{cancelable:!0});if(s.payload=c,window.dispatchEvent(s),!s.defaultPrevented)throw c}return m.then(c=>{for(const s of c||[])s.status==="rejected"&&p(s.reason);return t().catch(p)})},o=document.getElementById("ext-search-input"),P=document.getElementById("ext-search-form"),l=document.getElementById("ext-search-results");async function x(){const e=await _(k),{searchEngines:t}=await $(async()=>{const{searchEngines:n}=await import("./chunks/search-D2LwWSFS.js");return{searchEngines:n}},__vite__mapDeps([0,1]));return t.find(n=>n.id===e)??t[0]}function g(e){if(!e.length){l.hidden=!0,l.innerHTML="";return}l.hidden=!1,l.innerHTML=e.map(t=>`
      <div class="search-result-item" data-url="${t.url??""}" data-copy="${t.copyValue??""}">
        <span class="search-result-badge">${t.badge}</span>
        <div class="search-result-body">
          <strong>${t.title}</strong>
          ${t.subtitle?`<span>${t.subtitle}</span>`:""}
        </div>
      </div>
    `).join("")}let E;o.addEventListener("input",()=>{clearTimeout(E);const e=o.value.trim();if(!e){l.hidden=!0;return}E=setTimeout(()=>{const t=f(e);g(t)},150)});P.addEventListener("submit",async e=>{e.preventDefault();const t=o.value.trim();if(!t)return;const n=f(t);if(n.length>0)D(n[0]);else{const u=await x();window.open(b(t,u),"_self")}await L(t)});function D(e){e.copyValue&&navigator.clipboard?.writeText(e.copyValue).catch(()=>{}),e.url&&window.open(e.url,"_self")}l.addEventListener("click",e=>{const t=e.target.closest(".search-result-item");if(!t)return;const n=t.dataset.url,u=t.dataset.copy;u&&navigator.clipboard?.writeText(u).catch(()=>{}),n&&window.open(n,"_self")});document.querySelectorAll("[data-example]").forEach(e=>{e.addEventListener("click",()=>{o.value=e.dataset.example||"",o.focus();const t=f(o.value);g(t)})});document.addEventListener("keydown",e=>{(e.metaKey||e.ctrlKey)&&e.key==="k"&&(e.preventDefault(),o.focus(),o.select())});window.addEventListener("load",()=>{setTimeout(()=>o.focus(),100)});
