(function(){"use strict";let l=[],u=0;const c=[],q=10,a=100;function M(n){return"^"+n.normalize("NFKD").replace(/[\u0300-\u036f]/g,"").toLowerCase()+"$"}function S(n){return n.normalize("NFKD").replace(/[\u0300-\u036f]/g,"").toLowerCase()}function g(n,e,t){return n.includes(e)||t.every(o=>n.includes(o))}const y=new Intl.Collator("en",{sensitivity:"base",numeric:!0}),z=()=>new Promise(n=>setTimeout(n,0));function k(n){let e=null;for(const t of c)t.complete&&n.startsWith(t.query)&&(!e||t.query.length>e.query.length)&&(e=t);return e}function C(n,e,t){const o=c.findIndex(r=>r.query===n);o!==-1&&c.splice(o,1),c.unshift({query:n,results:e,complete:t}),c.length>q&&c.pop()}function E(){c.length=0}async function L(n,e,t){const o=S(n),r=o.split(/\s+/),s=[];let h=0;const m=c.find(i=>i.query===o);if(m){u===t&&f(m.results,n,e,t,!0);return}const N=k(o);if(N){for(const i of N.results)g(i.haystack,o,r)&&s.push(i);C(o,s,!0),u===t&&f(s,n,e,t,!0);return}const p=500;for(let i=0;i<l.length&&s.length<a;i+=p){if(u!==t)return;const T=Math.min(i+p,l.length);for(let d=i;d<T&&s.length<a;d++){const b=l[d];g(b.haystack,o,r)&&s.push(b)}s.length>h&&u===t&&(h=s.length,f(s,n,e,t,!1)),i+p<l.length&&s.length<a&&await z()}C(o,s,s.length<a),u===t&&f(s,n,e,t,!0)}function f(n,e,t,o,r){const s=R(n,e,t);postMessage({type:"results",docs:s.map(({haystack:h,...m})=>m),id:o,done:r})}function R(n,e,t){const o=t+"/";return[...n].sort((r,s)=>+(s.loc===t)-+(r.loc===t)||Number(s.loc.startsWith(o))-Number(r.loc.startsWith(o))||y.compare(r.loc,s.loc)||Number(s.dir)-Number(r.dir)||Number(s.name.includes(e))-Number(r.name.includes(e))||y.compare(r.name,s.name))}self.onmessage=async n=>{const e=n.data;e.type==="update"?(l=e.documents.map(t=>({...t,haystack:M(t.name)})).sort((t,o)=>o.mtime-t.mtime),E()):e.type==="search"&&(u=e.id,e.query?await L(e.query,e.loc,e.id):postMessage({type:"results",docs:[],id:e.id,done:!0}))}})();
