@eox/itemfilter 0.0.2 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,25 +1,260 @@
1
- (function(M,m){typeof exports=="object"&&typeof module<"u"?m(exports):typeof define=="function"&&define.amd?define(["exports"],m):(M=typeof globalThis<"u"?globalThis:M||self,m(M["eox-itemfilter"]={}))})(this,function(M){"use strict";var Ze=Object.defineProperty;var et=(M,m,b)=>m in M?Ze(M,m,{enumerable:!0,configurable:!0,writable:!0,value:b}):M[m]=b;var A=(M,m,b)=>(et(M,typeof m!="symbol"?m+"":m,b),b);function m(t){return Array.isArray?Array.isArray(t):J(t)==="[object Array]"}const b=1/0;function de(t){if(typeof t=="string")return t;let e=t+"";return e=="0"&&1/t==-b?"-0":e}function ge(t){return t==null?"":de(t)}function I(t){return typeof t=="string"}function Q(t){return typeof t=="number"}function pe(t){return t===!0||t===!1||me(t)&&J(t)=="[object Boolean]"}function X(t){return typeof t=="object"}function me(t){return X(t)&&t!==null}function y(t){return t!=null}function H(t){return!t.trim().length}function J(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const tt="Extended search is not available",ye="Incorrect 'index' type",Me=t=>`Invalid value for key ${t}`,Ee=t=>`Pattern length exceeds max of ${t}.`,xe=t=>`Missing ${t} property in key`,Se=t=>`Property 'weight' in key '${t}' must be a positive integer`,q=Object.prototype.hasOwnProperty;class Ie{constructor(e){this._keys=[],this._keyMap={};let s=0;e.forEach(r=>{let n=Z(r);s+=n.weight,this._keys.push(n),this._keyMap[n.id]=n,s+=n.weight}),this._keys.forEach(r=>{r.weight/=s})}get(e){return this._keyMap[e]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function Z(t){let e=null,s=null,r=null,n=1,i=null;if(I(t)||m(t))r=t,e=ee(t),s=B(t);else{if(!q.call(t,"name"))throw new Error(xe("name"));const c=t.name;if(r=c,q.call(t,"weight")&&(n=t.weight,n<=0))throw new Error(Se(c));e=ee(c),s=B(c),i=t.getFn}return{path:e,id:s,weight:n,src:r,getFn:i}}function ee(t){return m(t)?t:t.split(".")}function B(t){return m(t)?t.join("."):t}function Ae(t,e){let s=[],r=!1;const n=(i,c,o)=>{if(y(i))if(!c[o])s.push(i);else{let a=c[o];const h=i[a];if(!y(h))return;if(o===c.length-1&&(I(h)||Q(h)||pe(h)))s.push(ge(h));else if(m(h)){r=!0;for(let l=0,u=h.length;l<u;l+=1)n(h[l],c,o+1)}else c.length&&n(h,c,o+1)}};return n(t,I(e)?e.split("."):e,0),r?s:s[0]}var f={...{isCaseSensitive:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(t,e)=>t.score===e.score?t.idx<e.idx?-1:1:t.score<e.score?-1:1},...{includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},...{location:0,threshold:.6,distance:100},...{useExtendedSearch:!1,getFn:Ae,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1}};const _e=/[^ ]+/g;function we(t=1,e=3){const s=new Map,r=Math.pow(10,e);return{get(n){const i=n.match(_e).length;if(s.has(i))return s.get(i);const c=1/Math.pow(i,.5*t),o=parseFloat(Math.round(c*r)/r);return s.set(i,o),o},clear(){s.clear()}}}class K{constructor({getFn:e=f.getFn,fieldNormWeight:s=f.fieldNormWeight}={}){this.norm=we(s,3),this.getFn=e,this.isCreated=!1,this.setIndexRecords()}setSources(e=[]){this.docs=e}setIndexRecords(e=[]){this.records=e}setKeys(e=[]){this.keys=e,this._keysMap={},e.forEach((s,r)=>{this._keysMap[s.id]=r})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,I(this.docs[0])?this.docs.forEach((e,s)=>{this._addString(e,s)}):this.docs.forEach((e,s)=>{this._addObject(e,s)}),this.norm.clear())}add(e){const s=this.size();I(e)?this._addString(e,s):this._addObject(e,s)}removeAt(e){this.records.splice(e,1);for(let s=e,r=this.size();s<r;s+=1)this.records[s].i-=1}getValueForItemAtKeyId(e,s){return e[this._keysMap[s]]}size(){return this.records.length}_addString(e,s){if(!y(e)||H(e))return;let r={v:e,i:s,n:this.norm.get(e)};this.records.push(r)}_addObject(e,s){let r={i:s,$:{}};this.keys.forEach((n,i)=>{let c=n.getFn?n.getFn(e):this.getFn(e,n.path);if(y(c)){if(m(c)){let o=[];const a=[{nestedArrIndex:-1,value:c}];for(;a.length;){const{nestedArrIndex:h,value:l}=a.pop();if(y(l))if(I(l)&&!H(l)){let u={v:l,i:h,n:this.norm.get(l)};o.push(u)}else m(l)&&l.forEach((u,d)=>{a.push({nestedArrIndex:d,value:u})})}r.$[i]=o}else if(I(c)&&!H(c)){let o={v:c,n:this.norm.get(c)};r.$[i]=o}}}),this.records.push(r)}toJSON(){return{keys:this.keys,records:this.records}}}function te(t,e,{getFn:s=f.getFn,fieldNormWeight:r=f.fieldNormWeight}={}){const n=new K({getFn:s,fieldNormWeight:r});return n.setKeys(t.map(Z)),n.setSources(e),n.create(),n}function Le(t,{getFn:e=f.getFn,fieldNormWeight:s=f.fieldNormWeight}={}){const{keys:r,records:n}=t,i=new K({getFn:e,fieldNormWeight:s});return i.setKeys(r),i.setIndexRecords(n),i}function v(t,{errors:e=0,currentLocation:s=0,expectedLocation:r=0,distance:n=f.distance,ignoreLocation:i=f.ignoreLocation}={}){const c=e/t.length;if(i)return c;const o=Math.abs(r-s);return n?c+o/n:o?1:c}function Re(t=[],e=f.minMatchCharLength){let s=[],r=-1,n=-1,i=0;for(let c=t.length;i<c;i+=1){let o=t[i];o&&r===-1?r=i:!o&&r!==-1&&(n=i-1,n-r+1>=e&&s.push([r,n]),r=-1)}return t[i-1]&&i-r>=e&&s.push([r,i-1]),s}const k=32;function be(t,e,s,{location:r=f.location,distance:n=f.distance,threshold:i=f.threshold,findAllMatches:c=f.findAllMatches,minMatchCharLength:o=f.minMatchCharLength,includeMatches:a=f.includeMatches,ignoreLocation:h=f.ignoreLocation}={}){if(e.length>k)throw new Error(Ee(k));const l=e.length,u=t.length,d=Math.max(0,Math.min(r,u));let g=i,p=d;const E=o>1||a,T=E?Array(u):[];let _;for(;(_=t.indexOf(e,p))>-1;){let x=v(e,{currentLocation:_,expectedLocation:d,distance:n,ignoreLocation:h});if(g=Math.min(x,g),p=_+l,E){let L=0;for(;L<l;)T[_+L]=1,L+=1}}p=-1;let N=[],O=1,P=l+u;const qe=1<<l-1;for(let x=0;x<l;x+=1){let L=0,R=P;for(;L<R;)v(e,{errors:x,currentLocation:d+R,expectedLocation:d,distance:n,ignoreLocation:h})<=g?L=R:P=R,R=Math.floor((P-L)/2+L);P=R;let ue=Math.max(1,d-R+1),U=c?u:Math.min(d+R,u)+l,C=Array(U+2);C[U+1]=(1<<x)-1;for(let S=U;S>=ue;S-=1){let j=S-1,fe=s[t.charAt(j)];if(E&&(T[j]=+!!fe),C[S]=(C[S+1]<<1|1)&fe,x&&(C[S]|=(N[S+1]|N[S])<<1|1|N[S+1]),C[S]&qe&&(O=v(e,{errors:x,currentLocation:j,expectedLocation:d,distance:n,ignoreLocation:h}),O<=g)){if(g=O,p=j,p<=d)break;ue=Math.max(1,2*d-p)}}if(v(e,{errors:x+1,currentLocation:d,expectedLocation:d,distance:n,ignoreLocation:h})>g)break;N=C}const G={isMatch:p>=0,score:Math.max(.001,O)};if(E){const x=Re(T,o);x.length?a&&(G.indices=x):G.isMatch=!1}return G}function ke(t){let e={};for(let s=0,r=t.length;s<r;s+=1){const n=t.charAt(s);e[n]=(e[n]||0)|1<<r-s-1}return e}class se{constructor(e,{location:s=f.location,threshold:r=f.threshold,distance:n=f.distance,includeMatches:i=f.includeMatches,findAllMatches:c=f.findAllMatches,minMatchCharLength:o=f.minMatchCharLength,isCaseSensitive:a=f.isCaseSensitive,ignoreLocation:h=f.ignoreLocation}={}){if(this.options={location:s,threshold:r,distance:n,includeMatches:i,findAllMatches:c,minMatchCharLength:o,isCaseSensitive:a,ignoreLocation:h},this.pattern=a?e:e.toLowerCase(),this.chunks=[],!this.pattern.length)return;const l=(d,g)=>{this.chunks.push({pattern:d,alphabet:ke(d),startIndex:g})},u=this.pattern.length;if(u>k){let d=0;const g=u%k,p=u-g;for(;d<p;)l(this.pattern.substr(d,k),d),d+=k;if(g){const E=u-k;l(this.pattern.substr(E),E)}}else l(this.pattern,0)}searchIn(e){const{isCaseSensitive:s,includeMatches:r}=this.options;if(s||(e=e.toLowerCase()),this.pattern===e){let p={isMatch:!0,score:0};return r&&(p.indices=[[0,e.length-1]]),p}const{location:n,distance:i,threshold:c,findAllMatches:o,minMatchCharLength:a,ignoreLocation:h}=this.options;let l=[],u=0,d=!1;this.chunks.forEach(({pattern:p,alphabet:E,startIndex:T})=>{const{isMatch:_,score:N,indices:O}=be(e,p,E,{location:n+T,distance:i,threshold:c,findAllMatches:o,minMatchCharLength:a,includeMatches:r,ignoreLocation:h});_&&(d=!0),u+=N,_&&O&&(l=[...l,...O])});let g={isMatch:d,score:d?u/this.chunks.length:1};return d&&r&&(g.indices=l),g}}class w{constructor(e){this.pattern=e}static isMultiMatch(e){return ne(e,this.multiRegex)}static isSingleMatch(e){return ne(e,this.singleRegex)}search(){}}function ne(t,e){const s=t.match(e);return s?s[1]:null}class Te extends w{constructor(e){super(e)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(e){const s=e===this.pattern;return{isMatch:s,score:s?0:1,indices:[0,this.pattern.length-1]}}}class Oe extends w{constructor(e){super(e)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(e){const r=e.indexOf(this.pattern)===-1;return{isMatch:r,score:r?0:1,indices:[0,e.length-1]}}}class $e extends w{constructor(e){super(e)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(e){const s=e.startsWith(this.pattern);return{isMatch:s,score:s?0:1,indices:[0,this.pattern.length-1]}}}class Ne extends w{constructor(e){super(e)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(e){const s=!e.startsWith(this.pattern);return{isMatch:s,score:s?0:1,indices:[0,e.length-1]}}}class Ce extends w{constructor(e){super(e)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(e){const s=e.endsWith(this.pattern);return{isMatch:s,score:s?0:1,indices:[e.length-this.pattern.length,e.length-1]}}}class ve extends w{constructor(e){super(e)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(e){const s=!e.endsWith(this.pattern);return{isMatch:s,score:s?0:1,indices:[0,e.length-1]}}}class re extends w{constructor(e,{location:s=f.location,threshold:r=f.threshold,distance:n=f.distance,includeMatches:i=f.includeMatches,findAllMatches:c=f.findAllMatches,minMatchCharLength:o=f.minMatchCharLength,isCaseSensitive:a=f.isCaseSensitive,ignoreLocation:h=f.ignoreLocation}={}){super(e),this._bitapSearch=new se(e,{location:s,threshold:r,distance:n,includeMatches:i,findAllMatches:c,minMatchCharLength:o,isCaseSensitive:a,ignoreLocation:h})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(e){return this._bitapSearch.searchIn(e)}}class ie extends w{constructor(e){super(e)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(e){let s=0,r;const n=[],i=this.pattern.length;for(;(r=e.indexOf(this.pattern,s))>-1;)s=r+i,n.push([r,s-1]);const c=!!n.length;return{isMatch:c,score:c?0:1,indices:n}}}const D=[Te,ie,$e,Ne,ve,Ce,Oe,re],ce=D.length,Fe=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,Pe="|";function je(t,e={}){return t.split(Pe).map(s=>{let r=s.trim().split(Fe).filter(i=>i&&!!i.trim()),n=[];for(let i=0,c=r.length;i<c;i+=1){const o=r[i];let a=!1,h=-1;for(;!a&&++h<ce;){const l=D[h];let u=l.isMultiMatch(o);u&&(n.push(new l(u,e)),a=!0)}if(!a)for(h=-1;++h<ce;){const l=D[h];let u=l.isSingleMatch(o);if(u){n.push(new l(u,e));break}}}return n})}const He=new Set([re.type,ie.type]);class Be{constructor(e,{isCaseSensitive:s=f.isCaseSensitive,includeMatches:r=f.includeMatches,minMatchCharLength:n=f.minMatchCharLength,ignoreLocation:i=f.ignoreLocation,findAllMatches:c=f.findAllMatches,location:o=f.location,threshold:a=f.threshold,distance:h=f.distance}={}){this.query=null,this.options={isCaseSensitive:s,includeMatches:r,minMatchCharLength:n,findAllMatches:c,ignoreLocation:i,location:o,threshold:a,distance:h},this.pattern=s?e:e.toLowerCase(),this.query=je(this.pattern,this.options)}static condition(e,s){return s.useExtendedSearch}searchIn(e){const s=this.query;if(!s)return{isMatch:!1,score:1};const{includeMatches:r,isCaseSensitive:n}=this.options;e=n?e:e.toLowerCase();let i=0,c=[],o=0;for(let a=0,h=s.length;a<h;a+=1){const l=s[a];c.length=0,i=0;for(let u=0,d=l.length;u<d;u+=1){const g=l[u],{isMatch:p,indices:E,score:T}=g.search(e);if(p){if(i+=1,o+=T,r){const _=g.constructor.type;He.has(_)?c=[...c,...E]:c.push(E)}}else{o=0,i=0,c.length=0;break}}if(i){let u={isMatch:!0,score:o/i};return r&&(u.indices=c),u}}return{isMatch:!1,score:1}}}const W=[];function Ke(...t){W.push(...t)}function z(t,e){for(let s=0,r=W.length;s<r;s+=1){let n=W[s];if(n.condition(t,e))return new n(t,e)}return new se(t,e)}const F={AND:"$and",OR:"$or"},V={PATH:"$path",PATTERN:"$val"},Y=t=>!!(t[F.AND]||t[F.OR]),De=t=>!!t[V.PATH],We=t=>!m(t)&&X(t)&&!Y(t),oe=t=>({[F.AND]:Object.keys(t).map(e=>({[e]:t[e]}))});function ae(t,e,{auto:s=!0}={}){const r=n=>{let i=Object.keys(n);const c=De(n);if(!c&&i.length>1&&!Y(n))return r(oe(n));if(We(n)){const a=c?n[V.PATH]:i[0],h=c?n[V.PATTERN]:n[a];if(!I(h))throw new Error(Me(a));const l={keyId:B(a),pattern:h};return s&&(l.searcher=z(h,e)),l}let o={children:[],operator:i[0]};return i.forEach(a=>{const h=n[a];m(h)&&h.forEach(l=>{o.children.push(r(l))})}),o};return Y(t)||(t=oe(t)),r(t)}function ze(t,{ignoreFieldNorm:e=f.ignoreFieldNorm}){t.forEach(s=>{let r=1;s.matches.forEach(({key:n,norm:i,score:c})=>{const o=n?n.weight:null;r*=Math.pow(c===0&&o?Number.EPSILON:c,(o||1)*(e?1:i))}),s.score=r})}function Ve(t,e){const s=t.matches;e.matches=[],y(s)&&s.forEach(r=>{if(!y(r.indices)||!r.indices.length)return;const{indices:n,value:i}=r;let c={indices:n,value:i};r.key&&(c.key=r.key.src),r.idx>-1&&(c.refIndex=r.idx),e.matches.push(c)})}function Ye(t,e){e.score=t.score}function Ge(t,e,{includeMatches:s=f.includeMatches,includeScore:r=f.includeScore}={}){const n=[];return s&&n.push(Ve),r&&n.push(Ye),t.map(i=>{const{idx:c}=i,o={item:e[c],refIndex:c};return n.length&&n.forEach(a=>{a(i,o)}),o})}class ${constructor(e,s={},r){this.options={...f,...s},this.options.useExtendedSearch,this._keyStore=new Ie(this.options.keys),this.setCollection(e,r)}setCollection(e,s){if(this._docs=e,s&&!(s instanceof K))throw new Error(ye);this._myIndex=s||te(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(e){y(e)&&(this._docs.push(e),this._myIndex.add(e))}remove(e=()=>!1){const s=[];for(let r=0,n=this._docs.length;r<n;r+=1){const i=this._docs[r];e(i,r)&&(this.removeAt(r),r-=1,n-=1,s.push(i))}return s}removeAt(e){this._docs.splice(e,1),this._myIndex.removeAt(e)}getIndex(){return this._myIndex}search(e,{limit:s=-1}={}){const{includeMatches:r,includeScore:n,shouldSort:i,sortFn:c,ignoreFieldNorm:o}=this.options;let a=I(e)?I(this._docs[0])?this._searchStringList(e):this._searchObjectList(e):this._searchLogical(e);return ze(a,{ignoreFieldNorm:o}),i&&a.sort(c),Q(s)&&s>-1&&(a=a.slice(0,s)),Ge(a,this._docs,{includeMatches:r,includeScore:n})}_searchStringList(e){const s=z(e,this.options),{records:r}=this._myIndex,n=[];return r.forEach(({v:i,i:c,n:o})=>{if(!y(i))return;const{isMatch:a,score:h,indices:l}=s.searchIn(i);a&&n.push({item:i,idx:c,matches:[{score:h,value:i,norm:o,indices:l}]})}),n}_searchLogical(e){const s=ae(e,this.options),r=(o,a,h)=>{if(!o.children){const{keyId:u,searcher:d}=o,g=this._findMatches({key:this._keyStore.get(u),value:this._myIndex.getValueForItemAtKeyId(a,u),searcher:d});return g&&g.length?[{idx:h,item:a,matches:g}]:[]}const l=[];for(let u=0,d=o.children.length;u<d;u+=1){const g=o.children[u],p=r(g,a,h);if(p.length)l.push(...p);else if(o.operator===F.AND)return[]}return l},n=this._myIndex.records,i={},c=[];return n.forEach(({$:o,i:a})=>{if(y(o)){let h=r(s,o,a);h.length&&(i[a]||(i[a]={idx:a,item:o,matches:[]},c.push(i[a])),h.forEach(({matches:l})=>{i[a].matches.push(...l)}))}}),c}_searchObjectList(e){const s=z(e,this.options),{keys:r,records:n}=this._myIndex,i=[];return n.forEach(({$:c,i:o})=>{if(!y(c))return;let a=[];r.forEach((h,l)=>{a.push(...this._findMatches({key:h,value:c[l],searcher:s}))}),a.length&&i.push({idx:o,item:c,matches:a})}),i}_findMatches({key:e,value:s,searcher:r}){if(!y(s))return[];let n=[];if(m(s))s.forEach(({v:i,i:c,n:o})=>{if(!y(i))return;const{isMatch:a,score:h,indices:l}=r.searchIn(i);a&&n.push({score:h,key:e,value:i,idx:c,norm:o,indices:l})});else{const{v:i,n:c}=s,{isMatch:o,score:a,indices:h}=r.searchIn(i);o&&n.push({score:a,key:e,value:i,norm:c,indices:h})}return n}}$.version="6.6.2",$.createIndex=te,$.parseIndex=Le,$.config=f,$.parseQuery=ae,Ke(Be);const Ue=`
2
- <style>
1
+ (function(_,v){typeof exports=="object"&&typeof module<"u"?v(exports):typeof define=="function"&&define.amd?define(["exports"],v):(_=typeof globalThis<"u"?globalThis:_||self,v(_["eox-itemfilter"]={}))})(this,function(_){"use strict";var ms=Object.defineProperty;var _s=(_,v,S)=>v in _?ms(_,v,{enumerable:!0,configurable:!0,writable:!0,value:S}):_[v]=S;var R=(_,v,S)=>(_s(_,typeof v!="symbol"?v+"":v,S),S);/**
2
+ * @license
3
+ * Copyright 2019 Google LLC
4
+ * SPDX-License-Identifier: BSD-3-Clause
5
+ */const v=window,S=v.ShadowRoot&&(v.ShadyCSS===void 0||v.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,It=Symbol(),Ot=new WeakMap;let he=class{constructor(t,e,s){if(this._$cssResult$=!0,s!==It)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const e=this.t;if(S&&t===void 0){const s=e!==void 0&&e.length===1;s&&(t=Ot.get(e)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),s&&Ot.set(e,t))}return t}toString(){return this.cssText}};const ae=n=>new he(typeof n=="string"?n:n+"",void 0,It),ue=(n,t)=>{S?n.adoptedStyleSheets=t.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet):t.forEach(e=>{const s=document.createElement("style"),i=v.litNonce;i!==void 0&&s.setAttribute("nonce",i),s.textContent=e.cssText,n.appendChild(s)})},Rt=S?n=>n:n=>n instanceof CSSStyleSheet?(t=>{let e="";for(const s of t.cssRules)e+=s.cssText;return ae(e)})(n):n;/**
6
+ * @license
7
+ * Copyright 2017 Google LLC
8
+ * SPDX-License-Identifier: BSD-3-Clause
9
+ */var lt;const tt=window,Lt=tt.trustedTypes,de=Lt?Lt.emptyScript:"",Nt=tt.reactiveElementPolyfillSupport,ct={toAttribute(n,t){switch(t){case Boolean:n=n?de:null;break;case Object:case Array:n=n==null?n:JSON.stringify(n)}return n},fromAttribute(n,t){let e=n;switch(t){case Boolean:e=n!==null;break;case Number:e=n===null?null:Number(n);break;case Object:case Array:try{e=JSON.parse(n)}catch{e=null}}return e}},Tt=(n,t)=>t!==n&&(t==t||n==n),ht={attribute:!0,type:String,converter:ct,reflect:!1,hasChanged:Tt};let j=class extends HTMLElement{constructor(){super(),this._$Ei=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$El=null,this.u()}static addInitializer(t){var e;this.finalize(),((e=this.h)!==null&&e!==void 0?e:this.h=[]).push(t)}static get observedAttributes(){this.finalize();const t=[];return this.elementProperties.forEach((e,s)=>{const i=this._$Ep(s,e);i!==void 0&&(this._$Ev.set(i,s),t.push(i))}),t}static createProperty(t,e=ht){if(e.state&&(e.attribute=!1),this.finalize(),this.elementProperties.set(t,e),!e.noAccessor&&!this.prototype.hasOwnProperty(t)){const s=typeof t=="symbol"?Symbol():"__"+t,i=this.getPropertyDescriptor(t,s,e);i!==void 0&&Object.defineProperty(this.prototype,t,i)}}static getPropertyDescriptor(t,e,s){return{get(){return this[e]},set(i){const r=this[t];this[e]=i,this.requestUpdate(t,r,s)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)||ht}static finalize(){if(this.hasOwnProperty("finalized"))return!1;this.finalized=!0;const t=Object.getPrototypeOf(this);if(t.finalize(),t.h!==void 0&&(this.h=[...t.h]),this.elementProperties=new Map(t.elementProperties),this._$Ev=new Map,this.hasOwnProperty("properties")){const e=this.properties,s=[...Object.getOwnPropertyNames(e),...Object.getOwnPropertySymbols(e)];for(const i of s)this.createProperty(i,e[i])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const s=new Set(t.flat(1/0).reverse());for(const i of s)e.unshift(Rt(i))}else t!==void 0&&e.push(Rt(t));return e}static _$Ep(t,e){const s=e.attribute;return s===!1?void 0:typeof s=="string"?s:typeof t=="string"?t.toLowerCase():void 0}u(){var t;this._$E_=new Promise(e=>this.enableUpdating=e),this._$AL=new Map,this._$Eg(),this.requestUpdate(),(t=this.constructor.h)===null||t===void 0||t.forEach(e=>e(this))}addController(t){var e,s;((e=this._$ES)!==null&&e!==void 0?e:this._$ES=[]).push(t),this.renderRoot!==void 0&&this.isConnected&&((s=t.hostConnected)===null||s===void 0||s.call(t))}removeController(t){var e;(e=this._$ES)===null||e===void 0||e.splice(this._$ES.indexOf(t)>>>0,1)}_$Eg(){this.constructor.elementProperties.forEach((t,e)=>{this.hasOwnProperty(e)&&(this._$Ei.set(e,this[e]),delete this[e])})}createRenderRoot(){var t;const e=(t=this.shadowRoot)!==null&&t!==void 0?t:this.attachShadow(this.constructor.shadowRootOptions);return ue(e,this.constructor.elementStyles),e}connectedCallback(){var t;this.renderRoot===void 0&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(t=this._$ES)===null||t===void 0||t.forEach(e=>{var s;return(s=e.hostConnected)===null||s===void 0?void 0:s.call(e)})}enableUpdating(t){}disconnectedCallback(){var t;(t=this._$ES)===null||t===void 0||t.forEach(e=>{var s;return(s=e.hostDisconnected)===null||s===void 0?void 0:s.call(e)})}attributeChangedCallback(t,e,s){this._$AK(t,s)}_$EO(t,e,s=ht){var i;const r=this.constructor._$Ep(t,s);if(r!==void 0&&s.reflect===!0){const o=(((i=s.converter)===null||i===void 0?void 0:i.toAttribute)!==void 0?s.converter:ct).toAttribute(e,s.type);this._$El=t,o==null?this.removeAttribute(r):this.setAttribute(r,o),this._$El=null}}_$AK(t,e){var s;const i=this.constructor,r=i._$Ev.get(t);if(r!==void 0&&this._$El!==r){const o=i.getPropertyOptions(r),c=typeof o.converter=="function"?{fromAttribute:o.converter}:((s=o.converter)===null||s===void 0?void 0:s.fromAttribute)!==void 0?o.converter:ct;this._$El=r,this[r]=c.fromAttribute(e,o.type),this._$El=null}}requestUpdate(t,e,s){let i=!0;t!==void 0&&(((s=s||this.constructor.getPropertyOptions(t)).hasChanged||Tt)(this[t],e)?(this._$AL.has(t)||this._$AL.set(t,e),s.reflect===!0&&this._$El!==t&&(this._$EC===void 0&&(this._$EC=new Map),this._$EC.set(t,s))):i=!1),!this.isUpdatePending&&i&&(this._$E_=this._$Ej())}async _$Ej(){this.isUpdatePending=!0;try{await this._$E_}catch(e){Promise.reject(e)}const t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var t;if(!this.isUpdatePending)return;this.hasUpdated,this._$Ei&&(this._$Ei.forEach((i,r)=>this[r]=i),this._$Ei=void 0);let e=!1;const s=this._$AL;try{e=this.shouldUpdate(s),e?(this.willUpdate(s),(t=this._$ES)===null||t===void 0||t.forEach(i=>{var r;return(r=i.hostUpdate)===null||r===void 0?void 0:r.call(i)}),this.update(s)):this._$Ek()}catch(i){throw e=!1,this._$Ek(),i}e&&this._$AE(s)}willUpdate(t){}_$AE(t){var e;(e=this._$ES)===null||e===void 0||e.forEach(s=>{var i;return(i=s.hostUpdated)===null||i===void 0?void 0:i.call(s)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$Ek(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$E_}shouldUpdate(t){return!0}update(t){this._$EC!==void 0&&(this._$EC.forEach((e,s)=>this._$EO(s,this[s],e)),this._$EC=void 0),this._$Ek()}updated(t){}firstUpdated(t){}};j.finalized=!0,j.elementProperties=new Map,j.elementStyles=[],j.shadowRootOptions={mode:"open"},Nt==null||Nt({ReactiveElement:j}),((lt=tt.reactiveElementVersions)!==null&&lt!==void 0?lt:tt.reactiveElementVersions=[]).push("1.6.1");/**
10
+ * @license
11
+ * Copyright 2017 Google LLC
12
+ * SPDX-License-Identifier: BSD-3-Clause
13
+ */var at;const et=window,F=et.trustedTypes,kt=F?F.createPolicy("lit-html",{createHTML:n=>n}):void 0,ut="$lit$",M=`lit$${(Math.random()+"").slice(9)}$`,Pt="?"+M,fe=`<${Pt}>`,L=document,Y=()=>L.createComment(""),G=n=>n===null||typeof n!="object"&&typeof n!="function",Ht=Array.isArray,pe=n=>Ht(n)||typeof(n==null?void 0:n[Symbol.iterator])=="function",dt=`[
14
+ \f\r]`,J=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Ut=/-->/g,jt=/>/g,N=RegExp(`>|${dt}(?:([^\\s"'>=/]+)(${dt}*=${dt}*(?:[^
15
+ \f\r"'\`<>=]|("|')|))|$)`,"g"),Ft=/'/g,zt=/"/g,Bt=/^(?:script|style|textarea|title)$/i,ge=n=>(t,...e)=>({_$litType$:n,strings:t,values:e}),z=ge(1),T=Symbol.for("lit-noChange"),m=Symbol.for("lit-nothing"),Dt=new WeakMap,k=L.createTreeWalker(L,129,null,!1),me=(n,t)=>{const e=n.length-1,s=[];let i,r=t===2?"<svg>":"",o=J;for(let l=0;l<e;l++){const h=n[l];let u,a,d=-1,p=0;for(;p<h.length&&(o.lastIndex=p,a=o.exec(h),a!==null);)p=o.lastIndex,o===J?a[1]==="!--"?o=Ut:a[1]!==void 0?o=jt:a[2]!==void 0?(Bt.test(a[2])&&(i=RegExp("</"+a[2],"g")),o=N):a[3]!==void 0&&(o=N):o===N?a[0]===">"?(o=i??J,d=-1):a[1]===void 0?d=-2:(d=o.lastIndex-a[2].length,u=a[1],o=a[3]===void 0?N:a[3]==='"'?zt:Ft):o===zt||o===Ft?o=N:o===Ut||o===jt?o=J:(o=N,i=void 0);const g=o===N&&n[l+1].startsWith("/>")?" ":"";r+=o===J?h+fe:d>=0?(s.push(u),h.slice(0,d)+ut+h.slice(d)+M+g):h+M+(d===-2?(s.push(void 0),l):g)}const c=r+(n[e]||"<?>")+(t===2?"</svg>":"");if(!Array.isArray(n)||!n.hasOwnProperty("raw"))throw Error("invalid template strings array");return[kt!==void 0?kt.createHTML(c):c,s]};class Q{constructor({strings:t,_$litType$:e},s){let i;this.parts=[];let r=0,o=0;const c=t.length-1,l=this.parts,[h,u]=me(t,e);if(this.el=Q.createElement(h,s),k.currentNode=this.el.content,e===2){const a=this.el.content,d=a.firstChild;d.remove(),a.append(...d.childNodes)}for(;(i=k.nextNode())!==null&&l.length<c;){if(i.nodeType===1){if(i.hasAttributes()){const a=[];for(const d of i.getAttributeNames())if(d.endsWith(ut)||d.startsWith(M)){const p=u[o++];if(a.push(d),p!==void 0){const g=i.getAttribute(p.toLowerCase()+ut).split(M),$=/([.?@])?(.*)/.exec(p);l.push({type:1,index:r,name:$[2],strings:g,ctor:$[1]==="."?$e:$[1]==="?"?ye:$[1]==="@"?Ae:st})}else l.push({type:6,index:r})}for(const d of a)i.removeAttribute(d)}if(Bt.test(i.tagName)){const a=i.textContent.split(M),d=a.length-1;if(d>0){i.textContent=F?F.emptyScript:"";for(let p=0;p<d;p++)i.append(a[p],Y()),k.nextNode(),l.push({type:2,index:++r});i.append(a[d],Y())}}}else if(i.nodeType===8)if(i.data===Pt)l.push({type:2,index:r});else{let a=-1;for(;(a=i.data.indexOf(M,a+1))!==-1;)l.push({type:7,index:r}),a+=M.length-1}r++}}static createElement(t,e){const s=L.createElement("template");return s.innerHTML=t,s}}function B(n,t,e=n,s){var i,r,o,c;if(t===T)return t;let l=s!==void 0?(i=e._$Co)===null||i===void 0?void 0:i[s]:e._$Cl;const h=G(t)?void 0:t._$litDirective$;return(l==null?void 0:l.constructor)!==h&&((r=l==null?void 0:l._$AO)===null||r===void 0||r.call(l,!1),h===void 0?l=void 0:(l=new h(n),l._$AT(n,e,s)),s!==void 0?((o=(c=e)._$Co)!==null&&o!==void 0?o:c._$Co=[])[s]=l:e._$Cl=l),l!==void 0&&(t=B(n,l._$AS(n,t.values),l,s)),t}class _e{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){var e;const{el:{content:s},parts:i}=this._$AD,r=((e=t==null?void 0:t.creationScope)!==null&&e!==void 0?e:L).importNode(s,!0);k.currentNode=r;let o=k.nextNode(),c=0,l=0,h=i[0];for(;h!==void 0;){if(c===h.index){let u;h.type===2?u=new X(o,o.nextSibling,this,t):h.type===1?u=new h.ctor(o,h.name,h.strings,this,t):h.type===6&&(u=new Ee(o,this,t)),this._$AV.push(u),h=i[++l]}c!==(h==null?void 0:h.index)&&(o=k.nextNode(),c++)}return k.currentNode=L,r}v(t){let e=0;for(const s of this._$AV)s!==void 0&&(s.strings!==void 0?(s._$AI(t,s,e),e+=s.strings.length-2):s._$AI(t[e])),e++}}class X{constructor(t,e,s,i){var r;this.type=2,this._$AH=m,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=s,this.options=i,this._$Cp=(r=i==null?void 0:i.isConnected)===null||r===void 0||r}get _$AU(){var t,e;return(e=(t=this._$AM)===null||t===void 0?void 0:t._$AU)!==null&&e!==void 0?e:this._$Cp}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return e!==void 0&&(t==null?void 0:t.nodeType)===11&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=B(this,t,e),G(t)?t===m||t==null||t===""?(this._$AH!==m&&this._$AR(),this._$AH=m):t!==this._$AH&&t!==T&&this._(t):t._$litType$!==void 0?this.g(t):t.nodeType!==void 0?this.$(t):pe(t)?this.T(t):this._(t)}k(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}$(t){this._$AH!==t&&(this._$AR(),this._$AH=this.k(t))}_(t){this._$AH!==m&&G(this._$AH)?this._$AA.nextSibling.data=t:this.$(L.createTextNode(t)),this._$AH=t}g(t){var e;const{values:s,_$litType$:i}=t,r=typeof i=="number"?this._$AC(t):(i.el===void 0&&(i.el=Q.createElement(i.h,this.options)),i);if(((e=this._$AH)===null||e===void 0?void 0:e._$AD)===r)this._$AH.v(s);else{const o=new _e(r,this),c=o.u(this.options);o.v(s),this.$(c),this._$AH=o}}_$AC(t){let e=Dt.get(t.strings);return e===void 0&&Dt.set(t.strings,e=new Q(t)),e}T(t){Ht(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let s,i=0;for(const r of t)i===e.length?e.push(s=new X(this.k(Y()),this.k(Y()),this,this.options)):s=e[i],s._$AI(r),i++;i<e.length&&(this._$AR(s&&s._$AB.nextSibling,i),e.length=i)}_$AR(t=this._$AA.nextSibling,e){var s;for((s=this._$AP)===null||s===void 0||s.call(this,!1,!0,e);t&&t!==this._$AB;){const i=t.nextSibling;t.remove(),t=i}}setConnected(t){var e;this._$AM===void 0&&(this._$Cp=t,(e=this._$AP)===null||e===void 0||e.call(this,t))}}class st{constructor(t,e,s,i,r){this.type=1,this._$AH=m,this._$AN=void 0,this.element=t,this.name=e,this._$AM=i,this.options=r,s.length>2||s[0]!==""||s[1]!==""?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=m}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(t,e=this,s,i){const r=this.strings;let o=!1;if(r===void 0)t=B(this,t,e,0),o=!G(t)||t!==this._$AH&&t!==T,o&&(this._$AH=t);else{const c=t;let l,h;for(t=r[0],l=0;l<r.length-1;l++)h=B(this,c[s+l],e,l),h===T&&(h=this._$AH[l]),o||(o=!G(h)||h!==this._$AH[l]),h===m?t=m:t!==m&&(t+=(h??"")+r[l+1]),this._$AH[l]=h}o&&!i&&this.j(t)}j(t){t===m?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}class $e extends st{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===m?void 0:t}}const ve=F?F.emptyScript:"";class ye extends st{constructor(){super(...arguments),this.type=4}j(t){t&&t!==m?this.element.setAttribute(this.name,ve):this.element.removeAttribute(this.name)}}class Ae extends st{constructor(t,e,s,i,r){super(t,e,s,i,r),this.type=5}_$AI(t,e=this){var s;if((t=(s=B(this,t,e,0))!==null&&s!==void 0?s:m)===T)return;const i=this._$AH,r=t===m&&i!==m||t.capture!==i.capture||t.once!==i.once||t.passive!==i.passive,o=t!==m&&(i===m||r);r&&this.element.removeEventListener(this.name,this,i),o&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var e,s;typeof this._$AH=="function"?this._$AH.call((s=(e=this.options)===null||e===void 0?void 0:e.host)!==null&&s!==void 0?s:this.element,t):this._$AH.handleEvent(t)}}class Ee{constructor(t,e,s){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=s}get _$AU(){return this._$AM._$AU}_$AI(t){B(this,t)}}const Wt=et.litHtmlPolyfillSupport;Wt==null||Wt(Q,X),((at=et.litHtmlVersions)!==null&&at!==void 0?at:et.litHtmlVersions=[]).push("2.7.4");const xe=(n,t,e)=>{var s,i;const r=(s=e==null?void 0:e.renderBefore)!==null&&s!==void 0?s:t;let o=r._$litPart$;if(o===void 0){const c=(i=e==null?void 0:e.renderBefore)!==null&&i!==void 0?i:null;r._$litPart$=o=new X(t.insertBefore(Y(),c),c,void 0,e??{})}return o._$AI(n),o};/**
16
+ * @license
17
+ * Copyright 2017 Google LLC
18
+ * SPDX-License-Identifier: BSD-3-Clause
19
+ */var ft,pt;class Z extends j{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var t,e;const s=super.createRenderRoot();return(t=(e=this.renderOptions).renderBefore)!==null&&t!==void 0||(e.renderBefore=s.firstChild),s}update(t){const e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=xe(e,this.renderRoot,this.renderOptions)}connectedCallback(){var t;super.connectedCallback(),(t=this._$Do)===null||t===void 0||t.setConnected(!0)}disconnectedCallback(){var t;super.disconnectedCallback(),(t=this._$Do)===null||t===void 0||t.setConnected(!1)}render(){return T}}Z.finalized=!0,Z._$litElement$=!0,(ft=globalThis.litElementHydrateSupport)===null||ft===void 0||ft.call(globalThis,{LitElement:Z});const Kt=globalThis.litElementPolyfillSupport;Kt==null||Kt({LitElement:Z}),((pt=globalThis.litElementVersions)!==null&&pt!==void 0?pt:globalThis.litElementVersions=[]).push("3.3.2");/**
20
+ * @license
21
+ * Copyright 2017 Google LLC
22
+ * SPDX-License-Identifier: BSD-3-Clause
23
+ */const Se=n=>t=>typeof t=="function"?((e,s)=>(customElements.define(e,s),s))(n,t):((e,s)=>{const{kind:i,elements:r}=s;return{kind:i,elements:r,finisher(o){customElements.define(e,o)}}})(n,t);/**
24
+ * @license
25
+ * Copyright 2017 Google LLC
26
+ * SPDX-License-Identifier: BSD-3-Clause
27
+ */const be=(n,t)=>t.kind==="method"&&t.descriptor&&!("value"in t.descriptor)?{...t,finisher(e){e.createProperty(t.key,n)}}:{kind:"field",key:Symbol(),placement:"own",descriptor:{},originalKey:t.key,initializer(){typeof t.initializer=="function"&&(this[t.key]=t.initializer.call(this))},finisher(e){e.createProperty(t.key,n)}};function gt(n){return(t,e)=>e!==void 0?((s,i,r)=>{i.constructor.createProperty(r,s)})(n,t,e):be(n,t)}/**
28
+ * @license
29
+ * Copyright 2017 Google LLC
30
+ * SPDX-License-Identifier: BSD-3-Clause
31
+ */function mt(n){return gt({...n,state:!0})}/**
32
+ * @license
33
+ * Copyright 2021 Google LLC
34
+ * SPDX-License-Identifier: BSD-3-Clause
35
+ */var _t;((_t=window.HTMLSlotElement)===null||_t===void 0?void 0:_t.prototype.assignedElements)!=null;/**
36
+ * @license
37
+ * Copyright 2021 Google LLC
38
+ * SPDX-License-Identifier: BSD-3-Clause
39
+ */function*q(n,t){if(n!==void 0){let e=0;for(const s of n)yield t(s,e++)}}/**
40
+ * @license
41
+ * Copyright 2017 Google LLC
42
+ * SPDX-License-Identifier: BSD-3-Clause
43
+ */const we={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},Me=n=>(...t)=>({_$litDirective$:n,values:t});class Ce{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,e,s){this._$Ct=t,this._$AM=e,this._$Ci=s}_$AS(t,e){return this.update(t,e)}update(t,e){return this.render(...e)}}/**
44
+ * @license
45
+ * Copyright 2017 Google LLC
46
+ * SPDX-License-Identifier: BSD-3-Clause
47
+ */class $t extends Ce{constructor(t){if(super(t),this.et=m,t.type!==we.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(t){if(t===m||t==null)return this.ft=void 0,this.et=t;if(t===T)return t;if(typeof t!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(t===this.et)return this.ft;this.et=t;const e=[t];return e.raw=e,this.ft={_$litType$:this.constructor.resultType,strings:e,values:[]}}}$t.directiveName="unsafeHTML",$t.resultType=1;const Vt=Me($t);function b(n){return Array.isArray?Array.isArray(n):Jt(n)==="[object Array]"}const Ie=1/0;function Oe(n){if(typeof n=="string")return n;let t=n+"";return t=="0"&&1/n==-Ie?"-0":t}function Re(n){return n==null?"":Oe(n)}function x(n){return typeof n=="string"}function Yt(n){return typeof n=="number"}function Le(n){return n===!0||n===!1||Ne(n)&&Jt(n)=="[object Boolean]"}function Gt(n){return typeof n=="object"}function Ne(n){return Gt(n)&&n!==null}function y(n){return n!=null}function vt(n){return!n.trim().length}function Jt(n){return n==null?n===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(n)}const $s="Extended search is not available",Te="Incorrect 'index' type",ke=n=>`Invalid value for key ${n}`,Pe=n=>`Pattern length exceeds max of ${n}.`,He=n=>`Missing ${n} property in key`,Ue=n=>`Property 'weight' in key '${n}' must be a positive integer`,Qt=Object.prototype.hasOwnProperty;class je{constructor(t){this._keys=[],this._keyMap={};let e=0;t.forEach(s=>{let i=Xt(s);e+=i.weight,this._keys.push(i),this._keyMap[i.id]=i,e+=i.weight}),this._keys.forEach(s=>{s.weight/=e})}get(t){return this._keyMap[t]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function Xt(n){let t=null,e=null,s=null,i=1,r=null;if(x(n)||b(n))s=n,t=Zt(n),e=yt(n);else{if(!Qt.call(n,"name"))throw new Error(He("name"));const o=n.name;if(s=o,Qt.call(n,"weight")&&(i=n.weight,i<=0))throw new Error(Ue(o));t=Zt(o),e=yt(o),r=n.getFn}return{path:t,id:e,weight:i,src:s,getFn:r}}function Zt(n){return b(n)?n:n.split(".")}function yt(n){return b(n)?n.join("."):n}function Fe(n,t){let e=[],s=!1;const i=(r,o,c)=>{if(y(r))if(!o[c])e.push(r);else{let l=o[c];const h=r[l];if(!y(h))return;if(c===o.length-1&&(x(h)||Yt(h)||Le(h)))e.push(Re(h));else if(b(h)){s=!0;for(let u=0,a=h.length;u<a;u+=1)i(h[u],o,c+1)}else o.length&&i(h,o,c+1)}};return i(n,x(t)?t.split("."):t,0),s?e:e[0]}var f={...{isCaseSensitive:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(n,t)=>n.score===t.score?n.idx<t.idx?-1:1:n.score<t.score?-1:1},...{includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},...{location:0,threshold:.6,distance:100},...{useExtendedSearch:!1,getFn:Fe,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1}};const ze=/[^ ]+/g;function Be(n=1,t=3){const e=new Map,s=Math.pow(10,t);return{get(i){const r=i.match(ze).length;if(e.has(r))return e.get(r);const o=1/Math.pow(r,.5*n),c=parseFloat(Math.round(o*s)/s);return e.set(r,c),c},clear(){e.clear()}}}class At{constructor({getFn:t=f.getFn,fieldNormWeight:e=f.fieldNormWeight}={}){this.norm=Be(e,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((e,s)=>{this._keysMap[e.id]=s})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,x(this.docs[0])?this.docs.forEach((t,e)=>{this._addString(t,e)}):this.docs.forEach((t,e)=>{this._addObject(t,e)}),this.norm.clear())}add(t){const e=this.size();x(t)?this._addString(t,e):this._addObject(t,e)}removeAt(t){this.records.splice(t,1);for(let e=t,s=this.size();e<s;e+=1)this.records[e].i-=1}getValueForItemAtKeyId(t,e){return t[this._keysMap[e]]}size(){return this.records.length}_addString(t,e){if(!y(t)||vt(t))return;let s={v:t,i:e,n:this.norm.get(t)};this.records.push(s)}_addObject(t,e){let s={i:e,$:{}};this.keys.forEach((i,r)=>{let o=i.getFn?i.getFn(t):this.getFn(t,i.path);if(y(o)){if(b(o)){let c=[];const l=[{nestedArrIndex:-1,value:o}];for(;l.length;){const{nestedArrIndex:h,value:u}=l.pop();if(y(u))if(x(u)&&!vt(u)){let a={v:u,i:h,n:this.norm.get(u)};c.push(a)}else b(u)&&u.forEach((a,d)=>{l.push({nestedArrIndex:d,value:a})})}s.$[r]=c}else if(x(o)&&!vt(o)){let c={v:o,n:this.norm.get(o)};s.$[r]=c}}}),this.records.push(s)}toJSON(){return{keys:this.keys,records:this.records}}}function qt(n,t,{getFn:e=f.getFn,fieldNormWeight:s=f.fieldNormWeight}={}){const i=new At({getFn:e,fieldNormWeight:s});return i.setKeys(n.map(Xt)),i.setSources(t),i.create(),i}function De(n,{getFn:t=f.getFn,fieldNormWeight:e=f.fieldNormWeight}={}){const{keys:s,records:i}=n,r=new At({getFn:t,fieldNormWeight:e});return r.setKeys(s),r.setIndexRecords(i),r}function it(n,{errors:t=0,currentLocation:e=0,expectedLocation:s=0,distance:i=f.distance,ignoreLocation:r=f.ignoreLocation}={}){const o=t/n.length;if(r)return o;const c=Math.abs(s-e);return i?o+c/i:c?1:o}function We(n=[],t=f.minMatchCharLength){let e=[],s=-1,i=-1,r=0;for(let o=n.length;r<o;r+=1){let c=n[r];c&&s===-1?s=r:!c&&s!==-1&&(i=r-1,i-s+1>=t&&e.push([s,i]),s=-1)}return n[r-1]&&r-s>=t&&e.push([s,r-1]),e}const P=32;function Ke(n,t,e,{location:s=f.location,distance:i=f.distance,threshold:r=f.threshold,findAllMatches:o=f.findAllMatches,minMatchCharLength:c=f.minMatchCharLength,includeMatches:l=f.includeMatches,ignoreLocation:h=f.ignoreLocation}={}){if(t.length>P)throw new Error(Pe(P));const u=t.length,a=n.length,d=Math.max(0,Math.min(s,a));let p=r,g=d;const $=c>1||l,H=$?Array(a):[];let w;for(;(w=n.indexOf(t,g))>-1;){let A=it(t,{currentLocation:w,expectedLocation:d,distance:i,ignoreLocation:h});if(p=Math.min(A,p),g=w+u,$){let I=0;for(;I<u;)H[w+I]=1,I+=1}}g=-1;let K=[],U=1,rt=u+a;const gs=1<<u-1;for(let A=0;A<u;A+=1){let I=0,O=rt;for(;I<O;)it(t,{errors:A,currentLocation:d+O,expectedLocation:d,distance:i,ignoreLocation:h})<=p?I=O:rt=O,O=Math.floor((rt-I)/2+I);rt=O;let le=Math.max(1,d-O+1),Ct=o?a:Math.min(d+O,a)+u,V=Array(Ct+2);V[Ct+1]=(1<<A)-1;for(let E=Ct;E>=le;E-=1){let ot=E-1,ce=e[n.charAt(ot)];if($&&(H[ot]=+!!ce),V[E]=(V[E+1]<<1|1)&ce,A&&(V[E]|=(K[E+1]|K[E])<<1|1|K[E+1]),V[E]&gs&&(U=it(t,{errors:A,currentLocation:ot,expectedLocation:d,distance:i,ignoreLocation:h}),U<=p)){if(p=U,g=ot,g<=d)break;le=Math.max(1,2*d-g)}}if(it(t,{errors:A+1,currentLocation:d,expectedLocation:d,distance:i,ignoreLocation:h})>p)break;K=V}const Mt={isMatch:g>=0,score:Math.max(.001,U)};if($){const A=We(H,c);A.length?l&&(Mt.indices=A):Mt.isMatch=!1}return Mt}function Ve(n){let t={};for(let e=0,s=n.length;e<s;e+=1){const i=n.charAt(e);t[i]=(t[i]||0)|1<<s-e-1}return t}class te{constructor(t,{location:e=f.location,threshold:s=f.threshold,distance:i=f.distance,includeMatches:r=f.includeMatches,findAllMatches:o=f.findAllMatches,minMatchCharLength:c=f.minMatchCharLength,isCaseSensitive:l=f.isCaseSensitive,ignoreLocation:h=f.ignoreLocation}={}){if(this.options={location:e,threshold:s,distance:i,includeMatches:r,findAllMatches:o,minMatchCharLength:c,isCaseSensitive:l,ignoreLocation:h},this.pattern=l?t:t.toLowerCase(),this.chunks=[],!this.pattern.length)return;const u=(d,p)=>{this.chunks.push({pattern:d,alphabet:Ve(d),startIndex:p})},a=this.pattern.length;if(a>P){let d=0;const p=a%P,g=a-p;for(;d<g;)u(this.pattern.substr(d,P),d),d+=P;if(p){const $=a-P;u(this.pattern.substr($),$)}}else u(this.pattern,0)}searchIn(t){const{isCaseSensitive:e,includeMatches:s}=this.options;if(e||(t=t.toLowerCase()),this.pattern===t){let g={isMatch:!0,score:0};return s&&(g.indices=[[0,t.length-1]]),g}const{location:i,distance:r,threshold:o,findAllMatches:c,minMatchCharLength:l,ignoreLocation:h}=this.options;let u=[],a=0,d=!1;this.chunks.forEach(({pattern:g,alphabet:$,startIndex:H})=>{const{isMatch:w,score:K,indices:U}=Ke(t,g,$,{location:i+H,distance:r,threshold:o,findAllMatches:c,minMatchCharLength:l,includeMatches:s,ignoreLocation:h});w&&(d=!0),a+=K,w&&U&&(u=[...u,...U])});let p={isMatch:d,score:d?a/this.chunks.length:1};return d&&s&&(p.indices=u),p}}class C{constructor(t){this.pattern=t}static isMultiMatch(t){return ee(t,this.multiRegex)}static isSingleMatch(t){return ee(t,this.singleRegex)}search(){}}function ee(n,t){const e=n.match(t);return e?e[1]:null}class Ye extends C{constructor(t){super(t)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(t){const e=t===this.pattern;return{isMatch:e,score:e?0:1,indices:[0,this.pattern.length-1]}}}class Ge extends C{constructor(t){super(t)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(t){const s=t.indexOf(this.pattern)===-1;return{isMatch:s,score:s?0:1,indices:[0,t.length-1]}}}class Je extends C{constructor(t){super(t)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(t){const e=t.startsWith(this.pattern);return{isMatch:e,score:e?0:1,indices:[0,this.pattern.length-1]}}}class Qe extends C{constructor(t){super(t)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(t){const e=!t.startsWith(this.pattern);return{isMatch:e,score:e?0:1,indices:[0,t.length-1]}}}class Xe extends C{constructor(t){super(t)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(t){const e=t.endsWith(this.pattern);return{isMatch:e,score:e?0:1,indices:[t.length-this.pattern.length,t.length-1]}}}class Ze extends C{constructor(t){super(t)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(t){const e=!t.endsWith(this.pattern);return{isMatch:e,score:e?0:1,indices:[0,t.length-1]}}}class se extends C{constructor(t,{location:e=f.location,threshold:s=f.threshold,distance:i=f.distance,includeMatches:r=f.includeMatches,findAllMatches:o=f.findAllMatches,minMatchCharLength:c=f.minMatchCharLength,isCaseSensitive:l=f.isCaseSensitive,ignoreLocation:h=f.ignoreLocation}={}){super(t),this._bitapSearch=new te(t,{location:e,threshold:s,distance:i,includeMatches:r,findAllMatches:o,minMatchCharLength:c,isCaseSensitive:l,ignoreLocation:h})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(t){return this._bitapSearch.searchIn(t)}}class ie extends C{constructor(t){super(t)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(t){let e=0,s;const i=[],r=this.pattern.length;for(;(s=t.indexOf(this.pattern,e))>-1;)e=s+r,i.push([s,e-1]);const o=!!i.length;return{isMatch:o,score:o?0:1,indices:i}}}const Et=[Ye,ie,Je,Qe,Ze,Xe,Ge,se],ne=Et.length,qe=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,ts="|";function es(n,t={}){return n.split(ts).map(e=>{let s=e.trim().split(qe).filter(r=>r&&!!r.trim()),i=[];for(let r=0,o=s.length;r<o;r+=1){const c=s[r];let l=!1,h=-1;for(;!l&&++h<ne;){const u=Et[h];let a=u.isMultiMatch(c);a&&(i.push(new u(a,t)),l=!0)}if(!l)for(h=-1;++h<ne;){const u=Et[h];let a=u.isSingleMatch(c);if(a){i.push(new u(a,t));break}}}return i})}const ss=new Set([se.type,ie.type]);class is{constructor(t,{isCaseSensitive:e=f.isCaseSensitive,includeMatches:s=f.includeMatches,minMatchCharLength:i=f.minMatchCharLength,ignoreLocation:r=f.ignoreLocation,findAllMatches:o=f.findAllMatches,location:c=f.location,threshold:l=f.threshold,distance:h=f.distance}={}){this.query=null,this.options={isCaseSensitive:e,includeMatches:s,minMatchCharLength:i,findAllMatches:o,ignoreLocation:r,location:c,threshold:l,distance:h},this.pattern=e?t:t.toLowerCase(),this.query=es(this.pattern,this.options)}static condition(t,e){return e.useExtendedSearch}searchIn(t){const e=this.query;if(!e)return{isMatch:!1,score:1};const{includeMatches:s,isCaseSensitive:i}=this.options;t=i?t:t.toLowerCase();let r=0,o=[],c=0;for(let l=0,h=e.length;l<h;l+=1){const u=e[l];o.length=0,r=0;for(let a=0,d=u.length;a<d;a+=1){const p=u[a],{isMatch:g,indices:$,score:H}=p.search(t);if(g){if(r+=1,c+=H,s){const w=p.constructor.type;ss.has(w)?o=[...o,...$]:o.push($)}}else{c=0,r=0,o.length=0;break}}if(r){let a={isMatch:!0,score:c/r};return s&&(a.indices=o),a}}return{isMatch:!1,score:1}}}const xt=[];function ns(...n){xt.push(...n)}function St(n,t){for(let e=0,s=xt.length;e<s;e+=1){let i=xt[e];if(i.condition(n,t))return new i(n,t)}return new te(n,t)}const nt={AND:"$and",OR:"$or"},bt={PATH:"$path",PATTERN:"$val"},wt=n=>!!(n[nt.AND]||n[nt.OR]),rs=n=>!!n[bt.PATH],os=n=>!b(n)&&Gt(n)&&!wt(n),re=n=>({[nt.AND]:Object.keys(n).map(t=>({[t]:n[t]}))});function oe(n,t,{auto:e=!0}={}){const s=i=>{let r=Object.keys(i);const o=rs(i);if(!o&&r.length>1&&!wt(i))return s(re(i));if(os(i)){const l=o?i[bt.PATH]:r[0],h=o?i[bt.PATTERN]:i[l];if(!x(h))throw new Error(ke(l));const u={keyId:yt(l),pattern:h};return e&&(u.searcher=St(h,t)),u}let c={children:[],operator:r[0]};return r.forEach(l=>{const h=i[l];b(h)&&h.forEach(u=>{c.children.push(s(u))})}),c};return wt(n)||(n=re(n)),s(n)}function ls(n,{ignoreFieldNorm:t=f.ignoreFieldNorm}){n.forEach(e=>{let s=1;e.matches.forEach(({key:i,norm:r,score:o})=>{const c=i?i.weight:null;s*=Math.pow(o===0&&c?Number.EPSILON:o,(c||1)*(t?1:r))}),e.score=s})}function cs(n,t){const e=n.matches;t.matches=[],y(e)&&e.forEach(s=>{if(!y(s.indices)||!s.indices.length)return;const{indices:i,value:r}=s;let o={indices:i,value:r};s.key&&(o.key=s.key.src),s.idx>-1&&(o.refIndex=s.idx),t.matches.push(o)})}function hs(n,t){t.score=n.score}function as(n,t,{includeMatches:e=f.includeMatches,includeScore:s=f.includeScore}={}){const i=[];return e&&i.push(cs),s&&i.push(hs),n.map(r=>{const{idx:o}=r,c={item:t[o],refIndex:o};return i.length&&i.forEach(l=>{l(r,c)}),c})}class D{constructor(t,e={},s){this.options={...f,...e},this.options.useExtendedSearch,this._keyStore=new je(this.options.keys),this.setCollection(t,s)}setCollection(t,e){if(this._docs=t,e&&!(e instanceof At))throw new Error(Te);this._myIndex=e||qt(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(t){y(t)&&(this._docs.push(t),this._myIndex.add(t))}remove(t=()=>!1){const e=[];for(let s=0,i=this._docs.length;s<i;s+=1){const r=this._docs[s];t(r,s)&&(this.removeAt(s),s-=1,i-=1,e.push(r))}return e}removeAt(t){this._docs.splice(t,1),this._myIndex.removeAt(t)}getIndex(){return this._myIndex}search(t,{limit:e=-1}={}){const{includeMatches:s,includeScore:i,shouldSort:r,sortFn:o,ignoreFieldNorm:c}=this.options;let l=x(t)?x(this._docs[0])?this._searchStringList(t):this._searchObjectList(t):this._searchLogical(t);return ls(l,{ignoreFieldNorm:c}),r&&l.sort(o),Yt(e)&&e>-1&&(l=l.slice(0,e)),as(l,this._docs,{includeMatches:s,includeScore:i})}_searchStringList(t){const e=St(t,this.options),{records:s}=this._myIndex,i=[];return s.forEach(({v:r,i:o,n:c})=>{if(!y(r))return;const{isMatch:l,score:h,indices:u}=e.searchIn(r);l&&i.push({item:r,idx:o,matches:[{score:h,value:r,norm:c,indices:u}]})}),i}_searchLogical(t){const e=oe(t,this.options),s=(c,l,h)=>{if(!c.children){const{keyId:a,searcher:d}=c,p=this._findMatches({key:this._keyStore.get(a),value:this._myIndex.getValueForItemAtKeyId(l,a),searcher:d});return p&&p.length?[{idx:h,item:l,matches:p}]:[]}const u=[];for(let a=0,d=c.children.length;a<d;a+=1){const p=c.children[a],g=s(p,l,h);if(g.length)u.push(...g);else if(c.operator===nt.AND)return[]}return u},i=this._myIndex.records,r={},o=[];return i.forEach(({$:c,i:l})=>{if(y(c)){let h=s(e,c,l);h.length&&(r[l]||(r[l]={idx:l,item:c,matches:[]},o.push(r[l])),h.forEach(({matches:u})=>{r[l].matches.push(...u)}))}}),o}_searchObjectList(t){const e=St(t,this.options),{keys:s,records:i}=this._myIndex,r=[];return i.forEach(({$:o,i:c})=>{if(!y(o))return;let l=[];s.forEach((h,u)=>{l.push(...this._findMatches({key:h,value:o[u],searcher:e}))}),l.length&&r.push({idx:c,item:o,matches:l})}),r}_findMatches({key:t,value:e,searcher:s}){if(!y(e))return[];let i=[];if(b(e))e.forEach(({v:r,i:o,n:c})=>{if(!y(r))return;const{isMatch:l,score:h,indices:u}=s.searchIn(r);l&&i.push({score:h,key:t,value:r,idx:o,norm:c,indices:u})});else{const{v:r,n:o}=e,{isMatch:c,score:l,indices:h}=s.searchIn(r);c&&i.push({score:l,key:t,value:r,norm:o,indices:h})}return i}}D.version="6.6.2",D.createIndex=qt,D.parseIndex=De,D.config=f,D.parseQuery=oe,ns(is);const us=(n,t="highlight")=>{const e=(i,r,o)=>{const c=r.split(".");let l;for(l=0;l<c.length-1;l++)i=i[c[l]];i[c[l]]=o},s=(i,r=[])=>{let o="",c=0;return r.forEach(l=>{const h=l[1]+1;o+=[i.substring(c,l[0]),`<mark class="${t}">`,i.substring(l[0],h),"</mark>"].join(""),c=h}),o+=i.substring(c),o};return n.filter(({matches:i})=>i&&i.length).map(({item:i,matches:r})=>{const o={...i};return r.forEach(c=>{c.key==="name"&&e(o,c.key,s(c.value,c.indices))}),o})},ds=`
3
48
  :host {
4
- display: block;
5
- }
6
- </style>
7
- <div>
8
- <slot></slot>
9
- <ul id="filters"></ul>
10
- <input type="text" />
11
- <ul id="results"></ul>
12
- </div>
13
- `,Qe=`
14
- <li>
15
- <label>
16
- <input type="checkbox" />
17
- <span class="title">FILTERITEMTITLE</span>
18
- </label>
19
- </li>
20
- `,Xe=`
21
- <details open>
22
- <summary>TITLE</summar>
23
- <ul></ul>
24
- </details>
25
- `,Je=(t,e="highlight")=>{const s=(n,i,c)=>{const o=i.split(".");let a;for(a=0;a<o.length-1;a++)n=n[o[a]];n[o[a]]=c},r=(n,i=[])=>{let c="",o=0;return i.forEach(a=>{const h=a[1]+1;c+=[n.substring(o,a[0]),`<mark class="${e}">`,n.substring(a[0],h),"</mark>"].join(""),o=h}),c+=n.substring(o),c};return t.filter(({matches:n})=>n&&n.length).map(({item:n,matches:i})=>{const c={...n};return i.forEach(o=>{o.key==="name"&&s(c,o.key,r(o.value,o.indices))}),c})},he=document.createElement("template");he.innerHTML=Ue;class le extends HTMLElement{constructor(){super();A(this,"shadowRoot");A(this,"apply");A(this,"filterProperties");A(this,"items");A(this,"fuse");A(this,"filters");A(this,"aggregateBy");A(this,"aggregateResults");A(this,"fuseConfig");this.filters={},this.shadowRoot=this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(he.content.cloneNode(!0)),this.apply=n=>{this.items=n,this.fuse=new $(this.items,{minMatchCharLength:1,includeMatches:!0,keys:["name",...this.filterProperties],useExtendedSearch:!0,...this.fuseConfig}),this.filterProperties.forEach(i=>{const c=[...new Set(this.items.reduce((a,h)=>a.concat(h[i]),[]))].sort(),o=this.shadowRoot.querySelector("ul#filters");c.forEach(a=>{const h=document.createElement("template");h.innerHTML=Qe;const l=h.content.cloneNode(!0);l.querySelector("input[type='checkbox']").setAttribute("data-filter-key",i),l.querySelector("input[type='checkbox']").setAttribute("data-filter-value",a),l.querySelector("span.title").innerHTML=a,o.appendChild(l)}),this.aggregateResults===i&&(this.aggregateBy=c)}),s()};const s=()=>{this.shadowRoot.querySelectorAll("input[type='checkbox']").forEach(n=>{n.addEventListener("click",i=>{const c=i.target,o=c.getAttribute("data-filter-key"),a=c.getAttribute("data-filter-value");c.checked?(this.filters[o]||(this.filters[o]=[]),this.filters[o].push(a)):(this.filters[o].splice(this.filters[o].indexOf(a),1),this.filters[o].length===0&&delete this.filters[o]),r(this.shadowRoot.querySelector("input[type='text']").value)})})},r=(n,i=this.filters)=>{const c=Object.entries(i).reduce((h,[l,u])=>{const d=g=>{const p={};p[l]=`=${g}`,h.push(p)};return Array.isArray(u)?u.forEach(g=>d(g)):d(u),h},[]),o=Je(this.fuse.search({...n.length&&Object.keys(c).length?{$and:[{name:n},{$or:c}]}:{$or:[{name:n},{$or:c}]}})),a=this.shadowRoot.querySelector("ul#results");if(a.innerHTML="",this.aggregateResults){const h=document.createElement("template");h.innerHTML=Xe,this.aggregateBy.forEach(l=>{if(!o.find(d=>Array.isArray(d[this.aggregateResults])?d[this.aggregateResults].includes(l):d[this.aggregateResults]===l))return;const u=h.content.cloneNode(!0);u.querySelector("summary").innerHTML=l,u.querySelector("details").setAttribute("data-aggregate",l),a.appendChild(u)})}o.forEach(h=>{if(this.aggregateBy){const l=h[this.aggregateResults];if(Array.isArray(l))l.forEach(u=>{const d=document.createElement("li");d.innerHTML=h.name,this.shadowRoot.querySelector(`details[data-aggregate=${u}]`).appendChild(d)});else{const u=document.createElement("li");u.innerHTML=h.name,this.shadowRoot.querySelector(`details[data-aggregate=${l}]`).appendChild(u)}}else{const l=document.createElement("li");l.innerHTML=h.name,a.appendChild(l)}})};this.shadowRoot.querySelector("input[type='text']").addEventListener("input",n=>{r(n.target.value)})}}customElements.define("eox-itemfilter",le),M.EOxItemFilter=le,Object.defineProperty(M,Symbol.toStringTag,{value:"Module"})});
49
+ display: flex;
50
+ box-sizing: border-box;
51
+ height: 100%;
52
+ overflow: hidden;
53
+ }
54
+ *,
55
+ *:before,
56
+ *:after {
57
+ box-sizing: inherit;
58
+ }
59
+ form {
60
+ height: 100%;
61
+ width: 100%;
62
+ max-width: 100%;
63
+ display: flex;
64
+ flex-direction: column;
65
+ }
66
+ ul {
67
+ padding-left: 0;
68
+ margin-top: 0;
69
+ }
70
+ li {
71
+ list-style: none;
72
+ }
73
+ li span {
74
+ font-size: small;
75
+ overflow: hidden;
76
+ text-overflow: ellipsis;
77
+ white-space: nowrap;
78
+ }
79
+ label {
80
+ display: flex;
81
+ align-items: center;
82
+ }
83
+ details {
84
+ margin-bottom: 0.5rem;
85
+ }
86
+ details summary > * {
87
+ display: inline;
88
+ }
89
+ details summary {
90
+ display: flex;
91
+ align-items: center;
92
+ }
93
+ #details-filter summary {
94
+ justify-content: space-between;
95
+ }
96
+ #details-results summary {
97
+ list-style: none;
98
+ }
99
+ #details-filter summary svg,
100
+ #details-results summary svg {
101
+ width: 24px;
102
+ height: 24px;
103
+ transition: all ease-in-out 0.3s;
104
+ }
105
+ #details-results summary svg {
106
+ transform: rotate(-90deg);
107
+ }
108
+ #details-filter[open] summary svg {
109
+ transform: rotate(180deg);
110
+ }
111
+ #details-results[open] summary svg {
112
+ transform: rotate(0deg);
113
+ }
114
+ li span,
115
+ details summary {
116
+ text-transform: capitalize;
117
+ }
118
+ li,
119
+ label,
120
+ details,
121
+ input[type="checkbox"],
122
+ input[type="radio"] {
123
+ cursor: pointer;
124
+ }
125
+ input[type="checkbox"],
126
+ input[type="radio"] {
127
+ margin: 0;
128
+ margin-right: 0.5rem;
129
+ }
130
+ input[type="text"] {
131
+ width: 100%;
132
+ margin-bottom: 0.5rem;
133
+ }
134
+ section {
135
+ padding-left: 1rem;
136
+ padding-right: 1rem;
137
+ }
138
+ section:first-of-type {
139
+ padding-top: 1rem;
140
+ }
141
+ #section-results {
142
+ overflow: hidden;
143
+ flex: 1;
144
+ display: flex;
145
+ flex-direction: column;
146
+ }
147
+ #container-results {
148
+ margin-right: -1rem;
149
+ }
150
+ ul#results {
151
+ padding-right: 1rem;
152
+ }
153
+ ul#results li {
154
+ padding-left: 0.5rem;
155
+ }
156
+ .scroll {
157
+ height: 100%;
158
+ overflow-x: hidden;
159
+ overflow-y: auto;
160
+ }
161
+ `;var fs=Object.defineProperty,ps=Object.getOwnPropertyDescriptor,W=(n,t,e,s)=>{for(var i=s>1?void 0:s?ps(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(i=(s?o(t,e,i):o(i))||i);return s&&i&&fs(t,e,i),i};_.EOxItemFilter=class extends Z{constructor(){super(...arguments);R(this,"_fuse");R(this,"_resultAggregation",[]);R(this,"_items",[]);R(this,"_results",[]);R(this,"_filters",{});R(this,"config",{filterProperties:["themes"],aggregateResults:"themes",fuseConfig:{},enableSearch:!0,enableHighlighting:!1,onSelect:()=>{},matchAllWhenEmpty:!0,exclusiveFilters:!1});R(this,"apply",e=>{this._items=e,this._fuse=new D(this._items,{minMatchCharLength:1,includeMatches:!0,keys:["name",...this.config.filterProperties],useExtendedSearch:!0,...this.config.fuseConfig}),this.config.filterProperties.forEach(s=>{const i={};this._items.forEach(r=>{Array.isArray(r[s])?r[s].forEach(o=>{i[o]=void 0}):i[r[s]]=void 0}),this._filters[s]=i}),this.config.matchAllWhenEmpty!==!1&&(this._results=this._items,this.requestUpdate()),this.config.aggregateResults&&(this._resultAggregation=[...new Set(this._items.reduce((s,i)=>s.concat(i[this.config.aggregateResults]),[]))].sort())})}search(e="",s=this._filters){const i=Object.entries(s).reduce((o,[c,l])=>{const h=u=>{const a={};a[c]=`=${u}`,o.push(a)};return Object.entries(l).filter(([u,a])=>a).forEach(([u,a])=>h(u)),o},[]);let r;if(!e.length&&!i.length&&this.config.matchAllWhenEmpty!==!1)r=this._items;else{const o={...e.length&&i.length?{$and:[{name:e},{$or:i}]}:{$or:[{name:e},{$or:i}]}},c=this._fuse.search(o);r=this.config.enableHighlighting?us(c):c.map(l=>l.item)}this._results=r,this.requestUpdate()}aggregateResults(e,s){return e.filter(i=>{const r=i[this.config.aggregateResults];return Array.isArray(r)?r.includes(s):r===s})}toggleFilter(e,s){this.config.exclusiveFilters===!0&&Object.keys(this._filters).forEach(i=>{Object.keys(this._filters[i]).forEach(r=>{this._filters[i][r]=!1})}),this._filters[e][s]=!this._filters[e][s],console.log(this._filters),this.search()}render(){return z`
162
+ <style>
163
+ ${ds}
164
+ </style>
165
+ <form>
166
+ <section>
167
+ <input
168
+ type="text"
169
+ placeholder="Search"
170
+ style="display:${this.config.enableSearch?"block":"none"}"
171
+ @input="${e=>this.search(e.target.value)}"
172
+ />
173
+ </section>
174
+ <section>
175
+ <slot name="filterstitle"></slot>
176
+ <ul id="filters">
177
+ ${q(this.config.filterProperties,e=>z`
178
+ <details id="details-filter">
179
+ <summary>
180
+ <small>
181
+ <strong class="title"> ${e} </strong>
182
+ </small>
183
+ <div>
184
+ <svg
185
+ xmlns="http://www.w3.org/2000/svg"
186
+ viewBox="0 0 24 24"
187
+ >
188
+ <title>chevron-down</title>
189
+ <path
190
+ d="M7.41,8.58L12,13.17L16.59,8.58L18,10L12,16L6,10L7.41,8.58Z"
191
+ />
192
+ </svg>
193
+ </div>
194
+ </summary>
195
+ <ul>
196
+ ${this._filters[e]?q(Object.keys(this._filters[e]).sort(),s=>z`
197
+ <li>
198
+ <label>
199
+ <input
200
+ name="selection"
201
+ type="${this.config.exclusiveFilters===!0?"radio":"checkbox"}"
202
+ checked="${this._filters[e][s]||m}"
203
+ @click=${()=>this.toggleFilter(e,s)}
204
+ />
205
+ <span class="title">${s}</span>
206
+ </label>
207
+ </li>
208
+ `):null}
209
+ </ul>
210
+ </details>
211
+ `)}
212
+ </ul>
213
+ </section>
214
+ <section id="section-results">
215
+ <div>
216
+ <slot name="resultstitle"></slot>
217
+ </div>
218
+ <div id="container-results" class="scroll">
219
+ <ul id="results">
220
+ ${this.config.aggregateResults?q(this._resultAggregation.filter(e=>this.aggregateResults(this._results,e).length),e=>z`<details
221
+ id="details-results"
222
+ open
223
+ >
224
+ <summary>
225
+ <svg
226
+ xmlns="http://www.w3.org/2000/svg"
227
+ viewBox="0 0 24 24"
228
+ >
229
+ <title>chevron-down</title>
230
+ <path
231
+ d="M7.41,8.58L12,13.17L16.59,8.58L18,10L12,16L6,10L7.41,8.58Z"
232
+ />
233
+ </svg>
234
+ <strong class="title"> ${e} </strong>
235
+ <span style="margin-left: 0.25rem"
236
+ >(${this.aggregateResults(this._results,e).length})</span
237
+ >
238
+ </summary>
239
+ <ul>
240
+ ${q(this.aggregateResults(this._results,e),s=>z`
241
+ <li>
242
+ <label>
243
+ <input
244
+ type="radio"
245
+ name="result"
246
+ @click=${()=>this.config.onSelect(s)}
247
+ />
248
+ <span class="title"
249
+ >${Vt(s.name)}</span
250
+ >
251
+ </label>
252
+ </li>
253
+ `)}
254
+ </ul>
255
+ </details>`):q(this._results,e=>z`<li>${Vt(e.name)}</li>`)}
256
+ </ul>
257
+ </div>
258
+ </section>
259
+ </form>
260
+ `}},W([mt()],_.EOxItemFilter.prototype,"_items",2),W([mt()],_.EOxItemFilter.prototype,"_results",2),W([mt()],_.EOxItemFilter.prototype,"_filters",2),W([gt({attribute:!1})],_.EOxItemFilter.prototype,"config",2),W([gt()],_.EOxItemFilter.prototype,"apply",2),_.EOxItemFilter=W([Se("eox-itemfilter")],_.EOxItemFilter),Object.defineProperty(_,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eox/itemfilter",
3
- "version": "0.0.2",
3
+ "version": "0.2.0",
4
4
  "type": "module",
5
5
  "devDependencies": {
6
6
  "@eox/eslint-config": "^1.0.0",
@@ -25,6 +25,7 @@
25
25
  "watch": "tsc && vite build --watch"
26
26
  },
27
27
  "dependencies": {
28
- "fuse.js": "^6.6.2"
28
+ "fuse.js": "^6.6.2",
29
+ "lit": "^2.7.4"
29
30
  }
30
31
  }
@@ -9,8 +9,17 @@ describe("Item Filter", () => {
9
9
  it("loads the itemfilter", () => {
10
10
  cy.get("eox-itemfilter").should(($el) => {
11
11
  const EOxItemFilter = <EOxItemFilter>$el[0];
12
- EOxItemFilter.filterProperties = ["themes", "code"];
13
- EOxItemFilter.aggregateResults = "themes";
12
+ EOxItemFilter.config = {
13
+ filterProperties: ["themes"],
14
+ aggregateResults: "themes",
15
+ enableSearch: true,
16
+ // enableHighlighting: false,
17
+ // onSelect: (item: any) => {
18
+ // console.log(item);
19
+ // },
20
+ // matchAllWhenEmpty: true,
21
+ // exclusiveFilters: true,
22
+ };
14
23
  EOxItemFilter.apply(testItems);
15
24
  });
16
25
  });
package/test/general.html CHANGED
@@ -3,14 +3,20 @@
3
3
  <head>
4
4
  <style>
5
5
  html,
6
- body {
6
+ body,
7
+ eox-itemfilter {
7
8
  padding: 0;
8
9
  margin: 0;
10
+ width: 100%;
11
+ height: 100%;
9
12
  }
10
13
  </style>
11
14
  <script type="module" defer src="../dist/eox-itemfilter.js"></script>
12
15
  </head>
13
16
  <body>
14
- <eox-itemfilter> Filter! </eox-itemfilter>
17
+ <eox-itemfilter>
18
+ <h4 slot="filterstitle">Filter</h4>
19
+ <h4 slot="resultstitle">Results</h4>
20
+ </eox-itemfilter>
15
21
  </body>
16
22
  </html>
@@ -0,0 +1,32 @@
1
+ import { EOxItemFilter } from "../src/main";
2
+ import testItems from "./testItems.json";
3
+
4
+ describe("Item Filter", () => {
5
+ beforeEach(() => {
6
+ cy.visit("/elements/itemfilter/test/general.html");
7
+ });
8
+
9
+ it("loads the itemfilter", () => {
10
+ cy.get("eox-itemfilter").should(($el) => {
11
+ const EOxItemFilter = <EOxItemFilter>$el[0];
12
+ EOxItemFilter.config = {
13
+ filterProperties: ["themes"],
14
+ aggregateResults: "themes",
15
+ enableSearch: true,
16
+ };
17
+ EOxItemFilter.apply(testItems);
18
+ });
19
+ cy.viewport(800, 700);
20
+ cy.wait(2000);
21
+ cy.viewport(600, 700);
22
+ cy.wait(2000);
23
+ cy.viewport(400, 700);
24
+ cy.wait(2000);
25
+ cy.viewport(800, 400);
26
+ cy.wait(2000);
27
+ cy.viewport(600, 400);
28
+ cy.wait(2000);
29
+ cy.viewport(400, 400);
30
+ cy.wait(2000);
31
+ });
32
+ });