function I(e){return Array.isArray?Array.isArray(e):ft(e)==="[object Array]"}var Et=1/0;function mt(e){if(typeof e=="string")return e;let t=e+"";return t=="0"&&1/e==-Et?"-0":t}function Dt(e){return e==null?"":mt(e)}function F(e){return typeof e=="string"}function lt(e){return typeof e=="number"}function Ft(e){return e===!0||e===!1||Bt(e)&&ft(e)=="[object Boolean]"}function dt(e){return typeof e=="object"}function Bt(e){return dt(e)&&e!==null}function C(e){return e!=null}function V(e){return!e.trim().length}function ft(e){return e==null?e===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}var Mt="Incorrect 'index' type",It=e=>`Invalid value for key ${e}`,yt=e=>`Pattern length exceeds max of ${e}.`,_t=e=>`Missing ${e} property in key`,St=e=>`Property 'weight' in key '${e}' must be a positive integer`,ut=Object.prototype.hasOwnProperty,H=class{constructor(t){this._keys=[],this._keyMap={};let s=0;t.forEach(n=>{let i=gt(n);this._keys.push(i),this._keyMap[i.id]=i,s+=i.weight}),this._keys.forEach(n=>{n.weight/=s})}get(t){return this._keyMap[t]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}};function gt(e){let t=null,s=null,n=null,i=1,r=null;if(F(e)||I(e))n=e,t=ct(e),s=U(e);else{if(!ut.call(e,"name"))throw new Error(_t("name"));let c=e.name;if(n=c,ut.call(e,"weight")&&(i=e.weight,i<=0))throw new Error(St(c));t=ct(c),s=U(c),r=e.getFn}return{path:t,id:s,weight:i,src:n,getFn:r}}function ct(e){return I(e)?e:e.split(".")}function U(e){return I(e)?e.join("."):e}function wt(e,t){let s=[],n=!1,i=(r,c,o)=>{if(C(r))if(!c[o])s.push(r);else{let h=c[o],u=r[h];if(!C(u))return;if(o===c.length-1&&(F(u)||lt(u)||Ft(u)))s.push(Dt(u));else if(I(u)){n=!0;for(let a=0,d=u.length;a<d;a+=1)i(u[a],c,o+1)}else c.length&&i(u,c,o+1)}};return i(e,F(t)?t.split("."):t,0),n?s:s[0]}var xt={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},Lt={isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(e,t)=>e.score===t.score?e.idx<t.idx?-1:1:e.score<t.score?-1:1},bt={location:0,threshold:.6,distance:100},Rt={useExtendedSearch:!1,getFn:wt,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1},l={...Lt,...xt,...bt,...Rt},Ot=/[^ ]+/g;function kt(e=1,t=3){let s=new Map,n=Math.pow(10,t);return{get(i){let r=i.match(Ot).length;if(s.has(r))return s.get(r);let c=1/Math.pow(r,.5*e),o=parseFloat(Math.round(c*n)/n);return s.set(r,o),o},clear(){s.clear()}}}var O=class{constructor({getFn:t=l.getFn,fieldNormWeight:s=l.fieldNormWeight}={}){this.norm=kt(s,3),this.getFn=t,this.isCreated=!1,this.setIndexRecords()}setSources(t=[]){this.docs=t}setIndexRecords(t=[]){this.records=t}setKeys(t=[]){this.keys=t,this._keysMap={},t.forEach((s,n)=>{this._keysMap[s.id]=n})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,F(this.docs[0])?this.docs.forEach((t,s)=>{this._addString(t,s)}):this.docs.forEach((t,s)=>{this._addObject(t,s)}),this.norm.clear())}add(t){let s=this.size();F(t)?this._addString(t,s):this._addObject(t,s)}removeAt(t){this.records.splice(t,1);for(let s=t,n=this.size();s<n;s+=1)this.records[s].i-=1}getValueForItemAtKeyId(t,s){return t[this._keysMap[s]]}size(){return this.records.length}_addString(t,s){if(!C(t)||V(t))return;let n={v:t,i:s,n:this.norm.get(t)};this.records.push(n)}_addObject(t,s){let n={i:s,$:{}};this.keys.forEach((i,r)=>{let c=i.getFn?i.getFn(t):this.getFn(t,i.path);if(C(c)){if(I(c)){let o=[],h=[{nestedArrIndex:-1,value:c}];for(;h.length;){let{nestedArrIndex:u,value:a}=h.pop();if(C(a))if(F(a)&&!V(a)){let d={v:a,i:u,n:this.norm.get(a)};o.push(d)}else I(a)&&a.forEach((d,f)=>{h.push({nestedArrIndex:f,value:d})})}n.$[r]=o}else if(F(c)&&!V(c)){let o={v:c,n:this.norm.get(c)};n.$[r]=o}}}),this.records.push(n)}toJSON(){return{keys:this.keys,records:this.records}}};function At(e,t,{getFn:s=l.getFn,fieldNormWeight:n=l.fieldNormWeight}={}){let i=new O({getFn:s,fieldNormWeight:n});return i.setKeys(e.map(gt)),i.setSources(t),i.create(),i}function Nt(e,{getFn:t=l.getFn,fieldNormWeight:s=l.fieldNormWeight}={}){let{keys:n,records:i}=e,r=new O({getFn:t,fieldNormWeight:s});return r.setKeys(n),r.setIndexRecords(i),r}function N(e,{errors:t=0,currentLocation:s=0,expectedLocation:n=0,distance:i=l.distance,ignoreLocation:r=l.ignoreLocation}={}){let c=t/e.length;if(r)return c;let o=Math.abs(n-s);return i?c+o/i:o?1:c}function $t(e=[],t=l.minMatchCharLength){let s=[],n=-1,i=-1,r=0;for(let c=e.length;r<c;r+=1){let o=e[r];o&&n===-1?n=r:!o&&n!==-1&&(i=r-1,i-n+1>=t&&s.push([n,i]),n=-1)}return e[r-1]&&r-n>=t&&s.push([n,r-1]),s}var L=32;function Tt(e,t,s,{location:n=l.location,distance:i=l.distance,threshold:r=l.threshold,findAllMatches:c=l.findAllMatches,minMatchCharLength:o=l.minMatchCharLength,includeMatches:h=l.includeMatches,ignoreLocation:u=l.ignoreLocation}={}){if(t.length>L)throw new Error(yt(L));let a=t.length,d=e.length,f=Math.max(0,Math.min(n,d)),g=r,A=f,p=o>1||h,m=p?Array(d):[],_;for(;(_=e.indexOf(t,A))>-1;){let E=N(t,{currentLocation:_,expectedLocation:f,distance:i,ignoreLocation:u});if(g=Math.min(E,g),A=_+a,p){let S=0;for(;S<a;)m[_+S]=1,S+=1}}A=-1;let M=[],b=1,x=a+d,Ct=1<<a-1;for(let E=0;E<a;E+=1){let S=0,w=x;for(;S<w;)N(t,{errors:E,currentLocation:f+w,expectedLocation:f,distance:i,ignoreLocation:u})<=g?S=w:x=w,w=Math.floor((x-S)/2+S);x=w;let it=Math.max(1,f-w+1),W=c?d:Math.min(f+w,d)+a,R=Array(W+2);R[W+1]=(1<<E)-1;for(let D=W;D>=it;D-=1){let k=D-1,rt=s[e.charAt(k)];if(p&&(m[k]=+!!rt),R[D]=(R[D+1]<<1|1)&rt,E&&(R[D]|=(M[D+1]|M[D])<<1|1|M[D+1]),R[D]&Ct&&(b=N(t,{errors:E,currentLocation:k,expectedLocation:f,distance:i,ignoreLocation:u}),b<=g)){if(g=b,A=k,A<=f)break;it=Math.max(1,2*f-A)}}if(N(t,{errors:E+1,currentLocation:f,expectedLocation:f,distance:i,ignoreLocation:u})>g)break;M=R}let K={isMatch:A>=0,score:Math.max(.001,b)};if(p){let E=$t(m,o);E.length?h&&(K.indices=E):K.isMatch=!1}return K}function vt(e){let t={};for(let s=0,n=e.length;s<n;s+=1){let i=e.charAt(s);t[i]=(t[i]||0)|1<<n-s-1}return t}var $=String.prototype.normalize?e=>e.normalize("NFD").replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g,""):e=>e,T=class{constructor(t,{location:s=l.location,threshold:n=l.threshold,distance:i=l.distance,includeMatches:r=l.includeMatches,findAllMatches:c=l.findAllMatches,minMatchCharLength:o=l.minMatchCharLength,isCaseSensitive:h=l.isCaseSensitive,ignoreDiacritics:u=l.ignoreDiacritics,ignoreLocation:a=l.ignoreLocation}={}){if(this.options={location:s,threshold:n,distance:i,includeMatches:r,findAllMatches:c,minMatchCharLength:o,isCaseSensitive:h,ignoreDiacritics:u,ignoreLocation:a},t=h?t:t.toLowerCase(),t=u?$(t):t,this.pattern=t,this.chunks=[],!this.pattern.length)return;let d=(g,A)=>{this.chunks.push({pattern:g,alphabet:vt(g),startIndex:A})},f=this.pattern.length;if(f>L){let g=0,A=f%L,p=f-A;for(;g<p;)d(this.pattern.substr(g,L),g),g+=L;if(A){let m=f-L;d(this.pattern.substr(m),m)}}else d(this.pattern,0)}searchIn(t){let{isCaseSensitive:s,ignoreDiacritics:n,includeMatches:i}=this.options;if(t=s?t:t.toLowerCase(),t=n?$(t):t,this.pattern===t){let p={isMatch:!0,score:0};return i&&(p.indices=[[0,t.length-1]]),p}let{location:r,distance:c,threshold:o,findAllMatches:h,minMatchCharLength:u,ignoreLocation:a}=this.options,d=[],f=0,g=!1;this.chunks.forEach(({pattern:p,alphabet:m,startIndex:_})=>{let{isMatch:M,score:b,indices:x}=Tt(t,p,m,{location:r+_,distance:c,threshold:o,findAllMatches:h,minMatchCharLength:u,includeMatches:i,ignoreLocation:a});M&&(g=!0),f+=b,M&&x&&(d=[...d,...x])});let A={isMatch:g,score:g?f/this.chunks.length:1};return g&&i&&(A.indices=d),A}},B=class{constructor(t){this.pattern=t}static isMultiMatch(t){return ot(t,this.multiRegex)}static isSingleMatch(t){return ot(t,this.singleRegex)}search(){}};function ot(e,t){let s=e.match(t);return s?s[1]:null}var z=class extends B{constructor(t){super(t)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(t){let s=t===this.pattern;return{isMatch:s,score:s?0:1,indices:[0,this.pattern.length-1]}}},Y=class extends B{constructor(t){super(t)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(t){let n=t.indexOf(this.pattern)===-1;return{isMatch:n,score:n?0:1,indices:[0,t.length-1]}}},G=class extends B{constructor(t){super(t)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(t){let s=t.startsWith(this.pattern);return{isMatch:s,score:s?0:1,indices:[0,this.pattern.length-1]}}},Q=class extends B{constructor(t){super(t)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(t){let s=!t.startsWith(this.pattern);return{isMatch:s,score:s?0:1,indices:[0,t.length-1]}}},X=class extends B{constructor(t){super(t)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(t){let s=t.endsWith(this.pattern);return{isMatch:s,score:s?0:1,indices:[t.length-this.pattern.length,t.length-1]}}},J=class extends B{constructor(t){super(t)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(t){let s=!t.endsWith(this.pattern);return{isMatch:s,score:s?0:1,indices:[0,t.length-1]}}},v=class extends B{constructor(t,{location:s=l.location,threshold:n=l.threshold,distance:i=l.distance,includeMatches:r=l.includeMatches,findAllMatches:c=l.findAllMatches,minMatchCharLength:o=l.minMatchCharLength,isCaseSensitive:h=l.isCaseSensitive,ignoreDiacritics:u=l.ignoreDiacritics,ignoreLocation:a=l.ignoreLocation}={}){super(t),this._bitapSearch=new T(t,{location:s,threshold:n,distance:i,includeMatches:r,findAllMatches:c,minMatchCharLength:o,isCaseSensitive:h,ignoreDiacritics:u,ignoreLocation:a})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(t){return this._bitapSearch.searchIn(t)}},P=class extends B{constructor(t){super(t)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(t){let s=0,n,i=[],r=this.pattern.length;for(;(n=t.indexOf(this.pattern,s))>-1;)s=n+r,i.push([n,s-1]);let c=!!i.length;return{isMatch:c,score:c?0:1,indices:i}}},Z=[z,P,G,Q,J,X,Y,v],ht=Z.length,Pt=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,jt="|";function Kt(e,t={}){return e.split(jt).map(s=>{let n=s.trim().split(Pt).filter(r=>r&&!!r.trim()),i=[];for(let r=0,c=n.length;r<c;r+=1){let o=n[r],h=!1,u=-1;for(;!h&&++u<ht;){let a=Z[u],d=a.isMultiMatch(o);d&&(i.push(new a(d,t)),h=!0)}if(!h)for(u=-1;++u<ht;){let a=Z[u],d=a.isSingleMatch(o);if(d){i.push(new a(d,t));break}}}return i})}var Wt=new Set([v.type,P.type]),q=class{constructor(t,{isCaseSensitive:s=l.isCaseSensitive,ignoreDiacritics:n=l.ignoreDiacritics,includeMatches:i=l.includeMatches,minMatchCharLength:r=l.minMatchCharLength,ignoreLocation:c=l.ignoreLocation,findAllMatches:o=l.findAllMatches,location:h=l.location,threshold:u=l.threshold,distance:a=l.distance}={}){this.query=null,this.options={isCaseSensitive:s,ignoreDiacritics:n,includeMatches:i,minMatchCharLength:r,findAllMatches:o,ignoreLocation:c,location:h,threshold:u,distance:a},t=s?t:t.toLowerCase(),t=n?$(t):t,this.pattern=t,this.query=Kt(this.pattern,this.options)}static condition(t,s){return s.useExtendedSearch}searchIn(t){let s=this.query;if(!s)return{isMatch:!1,score:1};let{includeMatches:n,isCaseSensitive:i,ignoreDiacritics:r}=this.options;t=i?t:t.toLowerCase(),t=r?$(t):t;let c=0,o=[],h=0;for(let u=0,a=s.length;u<a;u+=1){let d=s[u];o.length=0,c=0;for(let f=0,g=d.length;f<g;f+=1){let A=d[f],{isMatch:p,indices:m,score:_}=A.search(t);if(p){if(c+=1,h+=_,n){let M=A.constructor.type;Wt.has(M)?o=[...o,...m]:o.push(m)}}else{h=0,c=0,o.length=0;break}}if(c){let f={isMatch:!0,score:h/c};return n&&(f.indices=o),f}}return{isMatch:!1,score:1}}},tt=[];function Vt(...e){tt.push(...e)}function et(e,t){for(let s=0,n=tt.length;s<n;s+=1){let i=tt[s];if(i.condition(e,t))return new i(e,t)}return new T(e,t)}var j={AND:"$and",OR:"$or"},st={PATH:"$path",PATTERN:"$val"},nt=e=>!!(e[j.AND]||e[j.OR]),Ht=e=>!!e[st.PATH],Ut=e=>!I(e)&&dt(e)&&!nt(e),at=e=>({[j.AND]:Object.keys(e).map(t=>({[t]:e[t]}))});function pt(e,t,{auto:s=!0}={}){let n=i=>{let r=Object.keys(i),c=Ht(i);if(!c&&r.length>1&&!nt(i))return n(at(i));if(Ut(i)){let h=c?i[st.PATH]:r[0],u=c?i[st.PATTERN]:i[h];if(!F(u))throw new Error(It(h));let a={keyId:U(h),pattern:u};return s&&(a.searcher=et(u,t)),a}let o={children:[],operator:r[0]};return r.forEach(h=>{let u=i[h];I(u)&&u.forEach(a=>{o.children.push(n(a))})}),o};return nt(e)||(e=at(e)),n(e)}function zt(e,{ignoreFieldNorm:t=l.ignoreFieldNorm}){e.forEach(s=>{let n=1;s.matches.forEach(({key:i,norm:r,score:c})=>{let o=i?i.weight:null;n*=Math.pow(c===0&&o?Number.EPSILON:c,(o||1)*(t?1:r))}),s.score=n})}function Yt(e,t){let s=e.matches;t.matches=[],C(s)&&s.forEach(n=>{if(!C(n.indices)||!n.indices.length)return;let{indices:i,value:r}=n,c={indices:i,value:r};n.key&&(c.key=n.key.src),n.idx>-1&&(c.refIndex=n.idx),t.matches.push(c)})}function Gt(e,t){t.score=e.score}function Qt(e,t,{includeMatches:s=l.includeMatches,includeScore:n=l.includeScore}={}){let i=[];return s&&i.push(Yt),n&&i.push(Gt),e.map(r=>{let{idx:c}=r,o={item:t[c],refIndex:c};return i.length&&i.forEach(h=>{h(r,o)}),o})}var y=class{constructor(t,s={},n){this.options={...l,...s},this.options.useExtendedSearch,this._keyStore=new H(this.options.keys),this.setCollection(t,n)}setCollection(t,s){if(this._docs=t,s&&!(s instanceof O))throw new Error(Mt);this._myIndex=s||At(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(t){C(t)&&(this._docs.push(t),this._myIndex.add(t))}remove(t=()=>!1){let s=[];for(let n=0,i=this._docs.length;n<i;n+=1){let r=this._docs[n];t(r,n)&&(this.removeAt(n),n-=1,i-=1,s.push(r))}return s}removeAt(t){this._docs.splice(t,1),this._myIndex.removeAt(t)}getIndex(){return this._myIndex}search(t,{limit:s=-1}={}){let{includeMatches:n,includeScore:i,shouldSort:r,sortFn:c,ignoreFieldNorm:o}=this.options,h=F(t)?F(this._docs[0])?this._searchStringList(t):this._searchObjectList(t):this._searchLogical(t);return zt(h,{ignoreFieldNorm:o}),r&&h.sort(c),lt(s)&&s>-1&&(h=h.slice(0,s)),Qt(h,this._docs,{includeMatches:n,includeScore:i})}_searchStringList(t){let s=et(t,this.options),{records:n}=this._myIndex,i=[];return n.forEach(({v:r,i:c,n:o})=>{if(!C(r))return;let{isMatch:h,score:u,indices:a}=s.searchIn(r);h&&i.push({item:r,idx:c,matches:[{score:u,value:r,norm:o,indices:a}]})}),i}_searchLogical(t){let s=pt(t,this.options),n=(o,h,u)=>{if(!o.children){let{keyId:d,searcher:f}=o,g=this._findMatches({key:this._keyStore.get(d),value:this._myIndex.getValueForItemAtKeyId(h,d),searcher:f});return g&&g.length?[{idx:u,item:h,matches:g}]:[]}let a=[];for(let d=0,f=o.children.length;d<f;d+=1){let g=o.children[d],A=n(g,h,u);if(A.length)a.push(...A);else if(o.operator===j.AND)return[]}return a},i=this._myIndex.records,r={},c=[];return i.forEach(({$:o,i:h})=>{if(C(o)){let u=n(s,o,h);u.length&&(r[h]||(r[h]={idx:h,item:o,matches:[]},c.push(r[h])),u.forEach(({matches:a})=>{r[h].matches.push(...a)}))}}),c}_searchObjectList(t){let s=et(t,this.options),{keys:n,records:i}=this._myIndex,r=[];return i.forEach(({$:c,i:o})=>{if(!C(c))return;let h=[];n.forEach((u,a)=>{h.push(...this._findMatches({key:u,value:c[a],searcher:s}))}),h.length&&r.push({idx:o,item:c,matches:h})}),r}_findMatches({key:t,value:s,searcher:n}){if(!C(s))return[];let i=[];if(I(s))s.forEach(({v:r,i:c,n:o})=>{if(!C(r))return;let{isMatch:h,score:u,indices:a}=n.searchIn(r);h&&i.push({score:u,key:t,value:r,idx:c,norm:o,indices:a})});else{let{v:r,n:c}=s,{isMatch:o,score:h,indices:u}=n.searchIn(r);o&&i.push({score:h,key:t,value:r,norm:c,indices:u})}return i}};y.version="7.1.0";y.createIndex=At;y.parseIndex=Nt;y.config=l;y.parseQuery=pt;Vt(q);function Xt({key:e,state:t,displayName:s,isDropdown:n,shouldCloseOnSelect:i,getSetUsing:r,getIconsUsing:c,getIconSvgUsing:o,verifyStateUsing:h}){return{state:t,displayName:s,isDropdown:n,shouldCloseOnSelect:i,dropdownOpen:!1,set:null,icons:[],search:"",fuse:null,results:[],resultsVisible:[],minimumItems:300,resultsPerPage:50,resultsIndex:0,isLoading:!1,async init(){await h(this.state).then(u=>this.state=u),await this.loadIcons(),this.$wire.on(`custom-icon-uploaded::${e}`,u=>{this.displayName=u.label,this.set=u.set,this.afterSetUpdated()})},deferLoadingState(){return setTimeout(()=>this.isLoading=!0,150)},async loadIcons(){return this.isLoading=!0,await c(this.set).then(u=>{this.icons=u,this.createFuseObject(),this.resetSearchResults(),this.isLoading=!1})},async loadSet(){return this.isLoading=!0,await r(this.state).then(u=>{this.set=u,this.isLoading=!1})},afterStateUpdated(){},afterSetUpdated(){this.loadIcons()},async updateSelectedIcon(u=!0){this.icons.find(d=>d.id===this.state)||u&&(await this.loadSet(),await this.loadIcons(),await this.updateSelectedIcon(!1))},setElementIcon(u,a,d=null){o(a).then(f=>u.innerHTML=f).finally(d)},createFuseObject(){let u={includeScore:!0,keys:["id"]};this.fuse=new y(this.icons,u)},resetSearchResults(){this.resultsPerPage=20,this.resultsIndex=0,this.results=this.icons,this.resultsVisible=[],this.addSearchResultsChunk()},setSelect:{async"x-on:change"(u){let a=u.target.value;this.set=a||null,this.afterSetUpdated()}},searchInput:{"x-on:input.debounce"(u){let a=u.target.value,d=this.deferLoadingState();a.length?(this.resultsVisible=[],this.resultsIndex=0,this.results=this.fuse.search(a).map(f=>f.item),this.addSearchResultsChunk()):this.resetSearchResults(),clearTimeout(d),this.isLoading=!1}},dropdownTrigger:{"x-on:click.prevent"(){this.dropdownOpen=!0}},dropdownMenu:{"x-show"(){return!this.isDropdown||this.dropdownOpen},"x-on:click.outside"(){this.dropdownOpen=!1}},addSearchResultsChunk(){let u=this.resultsIndex+this.resultsPerPage;u<this.minimumItems&&(u=this.minimumItems),this.resultsVisible.push(...this.results.slice(this.resultsIndex,u)),this.resultsIndex=u},updateState(u){u?(this.state=u.id,this.displayName=u.label,this.shouldCloseOnSelect&&this.$nextTick(()=>this.dropdownOpen=!1)):(this.state=null,this.displayName=null)}}}export{Xt as default};
