1
0
mirror of https://github.com/nextapps-de/flexsearch.git synced 2025-09-01 09:53:56 +02:00

stretch score to full resolution + improve intersection

This commit is contained in:
Thomas Wilkerling
2021-06-04 22:35:26 +02:00
parent 94235f3e74
commit bce8923cee
7 changed files with 615 additions and 585 deletions

View File

@@ -5,30 +5,30 @@
* Licence: Apache-2.0
* https://github.com/nextapps-de/flexsearch
*/
(function _f(self){'use strict';try{if(module)self=module}catch(e){}self._factory=_f;var r;function v(a){return"undefined"!==typeof a?a:!0}function w(a){const b=Array(a);for(let c=0;c<a;c++)b[c]=y();return b}function y(){return Object.create(null)}function aa(a,b){return b.length-a.length}function C(a){return"string"===typeof a}function D(a){return"object"===typeof a}function E(a){return"function"===typeof a};const ba=/[\u0300-\u036f]/g;function ca(a){a.normalize&&(a=a.normalize("NFD").replace(ba,""));return a}function da(a,b){const c=Object.keys(a),d=c.length,e=[];let f="",g=0;for(let h=0,l,m;h<d;h++)l=c[h],(m=a[l])?(e[g++]=F(b?"(?!\\b)"+l+"(\\b|_)":l),e[g++]=m):f+=(f?"|":"")+l;f&&(e[g++]=F(b?"(?!\\b)("+f+")(\\b|_)":"("+f+")"),e[g]="");return e}function H(a,b){for(let c=0,d=b.length;c<d&&(a=a.replace(b[c],b[c+1]),a);c+=2);return a}function F(a){return new RegExp(a,"g")}
function ea(a){let b="",c="";for(let d=0,e=a.length,f;d<e;d++)(f=a[d])!==c&&(b+=c=f);return b};var ha={encode:fa,B:!1,C:""};const ia=/[\W_]+/;function fa(a){return ja(this,ca(a).toLowerCase(),!1,ia)};const ka={},I={};function la(a){J(a,"add");J(a,"append");J(a,"search");J(a,"update");J(a,"remove")}function J(a,b){a[b+"Async"]=function(){const c=this,d=arguments;var e=d[d.length-1];let f;E(e)&&(f=e,delete d[d.length-1]);e=new Promise(function(g){setTimeout(function(){c.async=!0;const h=c[b].apply(c,d);c.async=!1;g(h)})});return f?(e.then(f),this):e}};function ma(a,b,c,d){const e=a.length;let f=[],g;let h,l;for(var m=0;m<e;m++){var n=a[m],u=n.length,t=0;for(let k=0,p;k<u;k++)(p=n[k])&&(t+=p.length);if(!q||t<q){var q=t;h=n;l=m}}h=1===h.length?h[0]:[].concat.apply([],h);d&&(d=[h],g=y());m=q=0;for(n=e-1;0<=n;n--)if(n!==l){m++;u=a[n];t=u.length;const k=[];let p=0;for(let x=0,z;x<h.length;x++){z=h[x];let A;for(let B=0;B<t;B++){const G=u[B];if(G.length&&(A=-1!==G.indexOf(z))){if(m===e-1){if(c)c--;else if(f[q++]=z,q===b)return f;d&&(g[z]=1)}break}}A&&
(k[p++]=z)}if(d)d[m]=k;else if(!p)return[];h=k}if(d)for(let k=d.length-1,p,x;0<=k;k--)if(x=(p=d[k])&&p.length)for(let z=0,A;z<x;z++)if(A=p[z],!g[A])if(g[A]=1,c)c--;else if(f[q++]=A,q===b)return f;return f}function na(a,b){const c=y(),d=y(),e=[];for(let f=0;f<a.length;f++)c[a[f]]=1;for(let f=0,g;f<b.length;f++){g=b[f];for(let h=0,l;h<g.length;h++)l=g[h],c[l]&&!d[l]&&(d[l]=1,e[e.length]=l)}return e};function K(a){this.l=!0!==a&&a;this.cache=y();this.h=[]}function oa(a,b,c){D(a)&&(a=a.query);let d=this.cache.get(a);d||(d=this.search(a,b,c),this.cache.set(a,d));return d}K.prototype.set=function(a,b){if(!this.cache[a]){var c=this.h.length;c===this.l?delete this.cache[this.h[c-1]]:c++;for(--c;0<c;c--)this.h[c]=this.h[c-1];this.h[0]=a}this.cache[a]=b};K.prototype.get=function(a){const b=this.cache[a];if(this.l&&b&&(a=this.h.indexOf(a))){const c=this.h[a-1];this.h[a-1]=this.h[a];this.h[a]=c}return b};const qa={memory:{charset:"latin:extra",D:3,A:3,o:!1,s:"memory"},performance:{threshold:8,A:3,context:{depth:1,F:!0}},match:{charset:"latin:extra",C:"full",D:3},score:{charset:"latin:advanced",threshold:1,context:{depth:3,F:!0}},"default":{D:3,threshold:0,depth:3}};function ra(a,b,c,d,e,f){setTimeout(function(){const g=a(c,JSON.stringify(f));g&&g.then?g.then(function(){b.export(a,b,c,d,e+1)}):b.export(a,b,c,d,e+1)})};function L(a,b){if(!(this instanceof L))return new L(a);var c;if(a){C(a)?a=qa[a]:(c=a.preset)&&(a=Object.assign({},c[c],a));c=a.charset;var d=a.lang;C(c)&&(-1===c.indexOf(":")&&(c+=":default"),c=I[c]);C(d)&&(d=ka[d])}else a={};let e,f,g=a.context||{};this.encode=a.encode||c&&c.encode||fa;this.register=b||y();this.D=e=a.resolution||9;this.C=b=c&&c.C||a.tokenize||"strict";this.depth="strict"===b&&g.depth;this.F=v(g.bidirectional);this.s=f=v(a.optimize);this.o=v(a.fastupdate);this.A=a.minlength||1;this.map=
f?w(e):y();this.l=e=g.resolution||1;this.h=f?w(e):y();this.B=c&&c.B||a.rtl;this.I=(b=a.matcher||d&&d.I)&&da(b,!1);this.K=(b=a.stemmer||d&&d.K)&&da(b,!0);if(c=b=a.filter||d&&d.filter){c=b;d=y();for(let h=0,l=c.length;h<l;h++)d[c[h]]=1;c=d}this.filter=c;this.cache=(b=a.cache)&&new K(b)}
function ja(a,b,c,d){if(b&&(c&&(b=H(b,c)),a.I&&(b=H(b,a.I)),a.K&&1<b.length&&(b=H(b,a.K)),d||""===d)){b=b.split(d);if(a.filter){a=a.filter;c=b.length;d=[];for(let e=0,f=0;e<c;e++){const g=b[e];g&&!a[g]&&(d[f++]=g)}a=d}else a=b;return a}return b}r=L.prototype;r.append=function(a,b){return this.add(a,b,!0)};
r.add=function(a,b,c,d){if(!d&&!c&&this.register[a])return this.update(a,b);if(b&&(a||0===a)&&(b=this.encode(b),d=b.length)){const m=this.depth,n=this.D,u=y(),t=y();for(let q=0;q<d;q++){let k=b[this.B?d-1-q:q];var e=k.length;if(k&&e>=this.A&&(m||!u[k])){var f=d<n?q:n/d*q|0,g="";switch(this.C){case "full":if(3<e){for(f=0;f<e;f++)for(var h=e;h>f;h--)if(h-f>=this.A){var l=d+e<n?q+f:n/(d+e)*(q+f)|0;g=k.substring(f,h);M(this,u,g,l,a,c)}break}case "reverse":if(2<e){for(h=e-1;0<h;h--)g=k[h]+g,g.length>=
this.A&&M(this,u,g,d+e<n?q+h:n/(d+e)*(q+h)|0,a,c);g=""}case "forward":if(1<e)for(h=0;h<e;h++)g+=k[h],g.length>=this.A&&M(this,u,g,f,a,c);break;default:if(M(this,u,k,f,a,c),m&&1<d&&q<d-1)for(e=this.l,g=y(),f=k,h=Math.min(m+1,d-q),g[f]=1,l=1;l<h;l++)if((k=b[this.B?d-1-q-l:q+l])&&k.length>=this.A&&!g[k]){g[k]=1;const p=this.F&&k>f;M(this,t,p?f:k,h+d<e?q+(l-1):e/(h+d)*(q+l)|0,a,c,p?k:f)}}}}this.o||(this.register[a]=1)}return this};
function M(a,b,c,d,e,f,g){let h=g?a.h:a.map;if(!b[c]||g&&!b[c][g])a.s&&(h=h[d]),g?(b=b[c]||(b[c]=y()),b[g]=1,h=h[g]||(h[g]=y())):b[c]=1,h=h[c]||(h[c]=[]),a.s||(h=h[d]||(h[d]=[])),f&&-1!==h.indexOf(e)||(h[h.length]=e,a.o&&(a=a.register[e]||(a.register[e]=[]),a[a.length]=h))}
r.search=function(a,b,c){D(a)?(c=a,a=c.query):D(b)&&(c=b);let d=[],e;let f,g=0;if(c){b=c.limit;g=c.offset||0;var h=c.context;f=c.suggest}if(a&&(a=this.encode(a),e=a.length,1<e)){c=y();var l=[];for(let n=0,u=0,t;n<e;n++)if((t=a[n])&&t.length>=this.A&&!c[t])if(this.s||f||this.map[t])l[u++]=t,c[t]=1;else return d;a=l;e=a.length}if(!e)return d;b||(b=100);h=this.depth&&1<e&&!1!==h;c=0;let m;h?(m=a[0],c=1):1<e&&a.sort(aa);for(let n,u;c<e;c++){u=a[c];h?(n=sa(this,d,f,b,g,2===e,u,m),f&&!1===n&&d.length||
(m=u)):n=sa(this,d,f,b,g,1===e,u);if(n)return n;if(f&&c===e-1){l=d.length;if(!l){if(h){h=0;c=-1;continue}return d}if(1===l)return ta(d[0],b,g)}}return ma(d,b,g,f)};
function sa(a,b,c,d,e,f,g,h){let l=[],m=h?a.h:a.map;a.s||(m=ua(m,g,h,a.F));if(m){let n=0;const u=Math.min(m.length,h?a.l:a.D);for(let t=0,q=0,k,p;t<u;t++)if(k=m[t])if(a.s&&(k=ua(k,g,h,a.F)),e&&k&&f&&(p=k.length,p<=e?(e-=p,k=null):(k=k.slice(e),e=0)),k&&(l[n++]=k,f&&(q+=k.length,q>=d)))break;if(n){if(f)return ta(l,d,0);b[b.length]=l;return}}return!c&&l}function ta(a,b,c){a=1===a.length?a[0]:[].concat.apply([],a);return c||a.length>b?a.slice(c,c+b):a}
function ua(a,b,c,d){c?(d=d&&b>c,a=(a=a[d?b:c])&&a[d?c:b]):a=a[b];return a}r.contain=function(a){return!!this.register[a]};r.update=function(a,b){return this.remove(a).add(a,b)};
r.remove=function(a,b){const c=this.register[a];if(c){if(this.o)for(let d=0,e;d<c.length;d++)e=c[d],e.splice(e.indexOf(a),1);else N(this.map,a,this.D,this.s),this.depth&&N(this.h,a,this.l,this.s);b||delete this.register[a];if(this.cache){b=this.cache;for(let d=0,e,f;d<b.h.length;d++)f=b.h[d],e=b.cache[f],-1!==e.indexOf(a)&&(b.h.splice(d--,1),delete b.cache[f])}}return this};
function N(a,b,c,d,e){let f=0;if(a.constructor===Array)if(e)b=a.indexOf(b),-1!==b?1<a.length&&(a.splice(b,1),f++):f++;else{e=Math.min(a.length,c);for(let g=0,h;g<e;g++)if(h=a[g])f=N(h,b,c,d,e),d||f||delete a[g]}else for(let g in a)(f=N(a[g],b,c,d,e))||delete a[g];return f}r.searchCache=oa;
r.export=function(a,b,c,d,e){let f,g;switch(e||(e=0)){case 0:f="reg";if(this.o){g=y();for(let h in this.register)g[h]=1}else g=this.register;break;case 1:f="cfg";g={doc:0,opt:this.s?1:0};break;case 2:f="map";g=this.map;break;case 3:f="ctx";g=this.h;break;default:return}ra(a,b||this,c?c+"."+f:f,d,e,g);return!0};r.import=function(a,b){if(b)switch(C(b)&&(b=JSON.parse(b)),a){case "cfg":this.s=!!b.opt;break;case "reg":this.o=!1;this.register=b;break;case "map":this.map=b;break;case "ctx":this.h=b}};la(L.prototype);function va(a){a=a.data;var b=self._index;const c=a.args;var d=a.task;switch(d){case "init":d=a.options||{};a=a.factory;b=d.encode;d.cache=!1;b&&0===b.indexOf("function")&&(d.encode=Function("return "+b)());a?(Function("return "+a)()(self),self._index=new self.FlexSearch.Index(d),delete self.FlexSearch):self._index=new L(d);break;default:a=a.id,b=b[d].apply(b,c),postMessage("search"===d?{id:a,msg:b}:{id:a})}};let wa=0;function O(a){var b;a?E(b=a.encode)&&(a.encode=b.toString()):a={};(b=(self||window)._factory)&&(b=b.toString());const c=self.exports,d=this;this.m=xa(b,c,a.worker);this.h=y();if(this.m){if(c)this.m.on("message",function(e){d.h[e.id](e.msg);delete d.h[e.id]});else this.m.onmessage=function(e){e=e.data;d.h[e.id](e.msg);delete d.h[e.id]};this.m.postMessage({task:"init",factory:b,options:a})}}P("add");P("append");P("search");P("update");P("remove");
function P(a){O.prototype[a]=O.prototype[a+"Async"]=function(){const b=this,c=[].slice.call(arguments);var d=c[c.length-1];let e;E(d)&&(e=d,c.splice(c.length-1,1));d=new Promise(function(f){setTimeout(function(){b.h[++wa]=f;b.m.postMessage({task:a,id:wa,args:c})})});return e?(d.then(e),this):d}}
function xa(a,b,c){let d;try{d=b?eval('new (require("worker_threads")["Worker"])("../dist/node/node.js")'):a?new Worker(URL.createObjectURL(new Blob(["onmessage="+va.toString()],{type:"text/javascript"}))):new Worker(C(c)?c:"worker/worker.js",{type:"module"})}catch(e){}return d};function R(a){if(!(this instanceof R))return new R(a);var b=a.document||a.doc||a,c;this.L=[];this.h=[];this.G=[];this.register=y();this.key=(c=b.key||b.id)&&S(c,this.G)||"id";this.o=v(a.fastupdate);this.H=(c=b.store)&&!0!==c&&[];this.store=c&&y();this.J=(c=b.tag)&&S(c,this.G);this.l=c&&y();this.cache=(c=a.cache)&&new K(c);a.cache=!1;this.m=a.worker;this.async=!1;c=y();let d=b.index||b.field||b;C(d)&&(d=[d]);for(let e=0,f,g;e<d.length;e++)f=d[e],C(f)||(g=f,f=f.field),g=D(g)?Object.assign({},a,g):a,
this.m&&(c[f]=new O(g),c[f].m||(this.m=!1)),this.m||(c[f]=new L(g,this.register)),this.L[e]=S(f,this.G),this.h[e]=f;if(this.H)for(a=b.store,C(a)&&(a=[a]),b=0;b<a.length;b++)this.H[b]=S(a[b],this.G);this.index=c}function S(a,b){const c=a.split(":");let d=0;for(let e=0;e<c.length;e++)a=c[e],0<=a.indexOf("[]")&&(a=a.substring(0,a.length-2))&&(b[d]=!0),a&&(c[d++]=a);d<c.length&&(c.length=d);return 1<d?c:c[0]}function T(a,b){if(C(b))a=a[b];else for(let c=0;a&&c<b.length;c++)a=a[b[c]];return a}
function U(a,b,c,d,e){a=a[e];if(d===c.length-1)b[e]=a;else if(a)if(a.constructor===Array)for(b=b[e]=Array(a.length),e=0;e<a.length;e++)U(a,b,c,d,e);else b=b[e]||(b[e]=y()),e=c[++d],U(a,b,c,d,e)}function V(a,b,c,d,e,f,g,h){a=a[g];if(d===b.length-1){if(a.constructor===Array){if(c[d]){for(b=0;b<a.length;b++)e.add(f,a[b],!0,!0);return}a=a.join(" ")}e.add(f,a,h,!0)}else if(a)if(a.constructor===Array)for(g=0;g<a.length;g++)V(a,b,c,d,e,f,g,h);else g=b[++d],V(a,b,c,d,e,f,g,h)}r=R.prototype;
r.add=function(a,b,c){D(a)&&(b=a,a=T(b,this.key));if(b&&(a||0===a)){if(this.register[a])return this.update(a,b);for(let d=0,e,f;d<this.h.length;d++)f=this.h[d],e=this.L[d],C(e)&&(e=[e]),V(b,e,this.G,0,this.index[f],a,e[0],c);if(this.J){let d=T(b,this.J),e=y();C(d)&&(d=[d]);for(let f=0,g,h;f<d.length;f++)if(g=d[f],!e[g]&&(e[g]=1,h=this.l[g]||(this.l[g]=[]),!c||-1===h.indexOf(a)))if(h[h.length]=a,this.o){const l=this.register[a]||(this.register[a]=[]);l[l.length]=h}}if(this.store){let d;if(this.H){d=
y();for(let e=0,f;e<this.H.length;e++)f=this.H[e],C(f)?d[f]=b[f]:U(b,d,f,0,f[0])}this.store[a]=d||b}}return this};r.append=function(a,b){return this.add(a,b,!0)};r.update=function(a,b){return this.remove(a).add(a,b)};
r.remove=function(a){D(a)&&(a=T(a,this.key));if(this.register[a]){var b=this.o&&!this.m;for(var c=0;c<this.h.length&&(this.index[this.h[c]].remove(a,b),!b);c++);if(this.J&&!b)for(let d in this.l)b=this.l[d],c=b.indexOf(a),-1!==c&&(1<b.length?b.splice(c,1):delete this.l[d]);this.store&&delete this.store[a];delete this.register[a]}return this};
r.search=function(a,b,c,d){D(a)?(c=a,a=c.query):D(b)&&(c=b,b=0);let e=[],f=[],g,h,l,m,n,u,t=0;if(c)if(c.constructor===Array)l=c,c=null;else{l=(g=c.pluck)||c.index||c.field||c;m=c.tag;h=this.store&&c.enrich;n="and"===c.bool;b=c.limit||100;u=c.offset||0;if(m&&(C(m)&&(m=[m]),!a)){for(let k=0,p;k<m.length;k++)if(p=ya.call(this,m[k],b,u,h))e[e.length]=p,t++;return t?e:[]}C(l)?l=[l]:l.constructor===Array||(l=null)}l||(l=this.h);n=n&&(1<l.length||m&&1<m.length);const q=!d&&(this.m||this.async)&&[];for(let k=
0,p,x,z;k<l.length;k++){let A;x=l[k];C(x)||(A=x,x=x.field);if(q)q[k]=this.index[x].searchAsync(a,b,A||c);else{d?p=d[k]:p=this.index[x].search(a,b,A||c);z=p&&p.length;if(m&&z){const B=[];let G=0;n&&(B[0]=[p]);for(let W=0,pa,Q;W<m.length;W++)if(pa=m[W],z=(Q=this.l[pa])&&Q.length)G++,B[B.length]=n?[Q]:Q;G&&(p=n?ma(B,b||100,u||0):na(p,B),z=p.length)}if(z)f[t]=x,e[t++]=p;else if(n)return[]}}if(q){const k=this;return new Promise(function(p){Promise.all(q).then(function(x){p(k.search(a,b,c,x))})})}if(!t)return[];
if(g&&(!h||!this.store))return e[0];for(let k=0,p;k<f.length;k++){p=e[k];p.length&&h&&(p=za.call(this,p));if(g)return p;e[k]={field:f[k],result:p}}return e};function ya(a,b,c,d){let e=this.l[a],f=e&&e.length-c;if(f&&0<f){if(f>b||c)e=e.slice(c,c+b);d&&(e=za.call(this,e));return{tag:a,result:e}}}function za(a){const b=Array(a.length);for(let c=0,d;c<a.length;c++)d=a[c],b[c]={key:d,doc:this.store[d]};return b}r.contain=function(a){return!!this.register[a]};r.get=function(a){return this.store[a]};
r.set=function(a,b){this.store[a]=b;return this};r.searchCache=oa;r.export=function(a,b,c,d,e){e||(e=0);d||(d=0);if(d<this.h.length){const f=this.h[d],g=this.index[f];b=this;setTimeout(function(){g.export(a,b,e?f.replace(":","-"):"",d,e++)||(d++,e=1,b.export(a,b,f,d,e))})}else{let f;switch(e){case 1:c="tag";f=this.l;break;case 2:c="store";f=this.store;break;default:return}ra(a,this,c,d,e,f)}};
r.import=function(a,b){if(b)switch(C(b)&&(b=JSON.parse(b)),a){case "tag":this.l=b;break;case "reg":this.o=!1;this.register=b;for(let d=0,e;d<this.h.length;d++)e=this.index[this.h[d]],e.register=b,e.o=!1;break;case "store":this.store=b;break;default:a=a.split(".");const c=a[0];a=a[1];c&&a&&this.index[c].import(a,b)}};la(R.prototype);var Ba={encode:Aa,B:!1,C:""};const Ca=/[\W_]+/,Da=[F("[\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5]"),"a",F("[\u00e8\u00e9\u00ea\u00eb]"),"e",F("[\u00ec\u00ed\u00ee\u00ef]"),"i",F("[\u00f2\u00f3\u00f4\u00f5\u00f6\u0151]"),"o",F("[\u00f9\u00fa\u00fb\u00fc\u0171]"),"u",F("[\u00fd\u0177\u00ff]"),"y",F("\u00f1"),"n",F("[\u00e7c]"),"k",F("\u00df"),"s",F(" & ")," and "];function Aa(a){return ja(this,ca(a).toLowerCase(),!a.normalize&&Da,Ca)};var Fa={encode:Ea,B:!1,C:"strict"};const Ga=/[^a-z0-9]+/,Ha={b:"p",v:"f",w:"f",z:"s",x:"s","\u00df":"s",d:"t",n:"m",c:"k",g:"k",j:"k",q:"k",i:"e",y:"e",u:"o"};function Ea(a){a=Aa.call(this,a).join(" ");const b=[];if(a){const c=a.split(Ga),d=c.length;for(let e=0,f,g=0;e<d;e++)if((a=c[e])&&(!this.filter||!this.filter[a])){f=a[0];let h=Ha[f]||f,l=h;for(let m=1;m<a.length;m++){f=a[m];const n=Ha[f]||f;n&&n!==l&&(h+=n,l=n)}b[g++]=h}}return b};var Ja={encode:Ia,B:!1,C:""};const Ka=[F("ae"),"a",F("oe"),"o",F("sh"),"s",F("th"),"t",F("ph"),"f",F("pf"),"f"];function Ia(a,b){a&&(a=Ea.call(this,a).join(" "),2<a.length&&(a=H(a,Ka)),b||(1<a.length&&(a=ea(a)),a&&(a=a.split(" "))));return a};var Ma={encode:La,B:!1,C:""};const Na=F("(?!\\b)[aeiouy]");function La(a){a&&(a=Ia.call(this,a,!0),1<a.length&&(a=a.replace(Na,"")),1<a.length&&(a=ea(a)),a&&(a=a.split(" ")));return a};I["latin:default"]=ha;I["latin:simple"]=Ba;I["latin:balance"]=Fa;I["latin:advanced"]=Ja;I["latin:extra"]=Ma;const X=self;let Y;const Z={Index:L,Document:R,Worker:O,registerCharset:function(a,b){I[a]=b},registerLanguage:function(a,b){ka[a]=b}};(Y=X.define)&&Y.amd?Y([],function(){return Z}):X.exports?X.exports=Z:X.FlexSearch=Z;}(this));
(function _f(self){'use strict';try{if(module)self=module}catch(e){}self._factory=_f;var u;function v(a){return"undefined"!==typeof a?a:!0}function w(a){const b=Array(a);for(let c=0;c<a;c++)b[c]=x();return b}function x(){return Object.create(null)}function aa(a,b){return b.length-a.length}function B(a){return"string"===typeof a}function D(a){return"object"===typeof a}function E(a){return"function"===typeof a};const ba=/[\u0300-\u036f]/g;function ca(a){a.normalize&&(a=a.normalize("NFD").replace(ba,""));return a}function da(a,b){const c=Object.keys(a),d=c.length,e=[];let f="",g=0;for(let h=0,k,m;h<d;h++)k=c[h],(m=a[k])?(e[g++]=F(b?"(?!\\b)"+k+"(\\b|_)":k),e[g++]=m):f+=(f?"|":"")+k;f&&(e[g++]=F(b?"(?!\\b)("+f+")(\\b|_)":"("+f+")"),e[g]="");return e}function G(a,b){for(let c=0,d=b.length;c<d&&(a=a.replace(b[c],b[c+1]),a);c+=2);return a}function F(a){return new RegExp(a,"g")}
function ea(a){let b="",c="";for(let d=0,e=a.length,f;d<e;d++)(f=a[d])!==c&&(b+=c=f);return b};var ha={encode:fa,B:!1,C:""};const ia=/[\W_]+/;function fa(a){return ja(this,ca(a).toLowerCase(),!1,ia)};const ka={},H={};function la(a){I(a,"add");I(a,"append");I(a,"search");I(a,"update");I(a,"remove")}function I(a,b){a[b+"Async"]=function(){const c=this,d=arguments;var e=d[d.length-1];let f;E(e)&&(f=e,delete d[d.length-1]);e=new Promise(function(g){setTimeout(function(){c.async=!0;const h=c[b].apply(c,d);c.async=!1;g(h)})});return f?(e.then(f),this):e}};function ma(a,b,c,d){var e=a.length;let f=[],g,h,k=0;d&&(d=[]);for(--e;0<=e;e--){const m=a[e],n=m.length,r=x();let t=!g;for(let q=0;q<n;q++){const l=m[q],p=l.length;if(p)for(let y=0,z,A;y<p;y++)if(A=l[y],g){if(g[A]){if(!e)if(c)c--;else if(f[k++]=A,k===b)return f;if(e||d)r[A]=1;t=!0}if(d&&(h[A]=(z=h[A])?z++:z=1,z<n)){const C=d[z-1]||(d[z-1]=[]);C[C.length]=A}}else r[A]=1}if(d)g||(h=r);else if(!t)return[];g=r}if(d)for(let m=d.length-1,n,r;0<=m;m--){n=d[m];r=n.length;for(let t=0,q;t<r;t++)if(q=n[t],
!g[q]){if(c)c--;else if(f[k++]=q,k===b)return f;g[q]=1}}return f}function na(a,b){const c=x(),d=x(),e=[];for(let f=0;f<a.length;f++)c[a[f]]=1;for(let f=0,g;f<b.length;f++){g=b[f];for(let h=0,k;h<g.length;h++)k=g[h],c[k]&&!d[k]&&(d[k]=1,e[e.length]=k)}return e};function J(a){this.l=!0!==a&&a;this.cache=x();this.h=[]}function oa(a,b,c){D(a)&&(a=a.query);let d=this.cache.get(a);d||(d=this.search(a,b,c),this.cache.set(a,d));return d}J.prototype.set=function(a,b){if(!this.cache[a]){var c=this.h.length;c===this.l?delete this.cache[this.h[c-1]]:c++;for(--c;0<c;c--)this.h[c]=this.h[c-1];this.h[0]=a}this.cache[a]=b};J.prototype.get=function(a){const b=this.cache[a];if(this.l&&b&&(a=this.h.indexOf(a))){const c=this.h[a-1];this.h[a-1]=this.h[a];this.h[a]=c}return b};const ra={memory:{charset:"latin:extra",D:3,A:3,o:!1,s:"memory"},performance:{threshold:8,A:3,context:{depth:1,F:!0}},match:{charset:"latin:extra",C:"full",D:3},score:{charset:"latin:advanced",threshold:1,context:{depth:3,F:!0}},"default":{D:3,threshold:0,depth:3}};function sa(a,b,c,d,e,f){setTimeout(function(){const g=a(c,JSON.stringify(f));g&&g.then?g.then(function(){b.export(a,b,c,d,e+1)}):b.export(a,b,c,d,e+1)})};function K(a,b){if(!(this instanceof K))return new K(a);var c;if(a){B(a)?a=ra[a]:(c=a.preset)&&(a=Object.assign({},c[c],a));c=a.charset;var d=a.lang;B(c)&&(-1===c.indexOf(":")&&(c+=":default"),c=H[c]);B(d)&&(d=ka[d])}else a={};let e,f,g=a.context||{};this.encode=a.encode||c&&c.encode||fa;this.register=b||x();this.D=e=a.resolution||9;this.C=b=c&&c.C||a.tokenize||"strict";this.depth="strict"===b&&g.depth;this.F=v(g.bidirectional);this.s=f=v(a.optimize);this.o=v(a.fastupdate);this.A=a.minlength||1;this.map=
f?w(e):x();this.l=e=g.resolution||1;this.h=f?w(e):x();this.B=c&&c.B||a.rtl;this.I=(b=a.matcher||d&&d.I)&&da(b,!1);this.K=(b=a.stemmer||d&&d.K)&&da(b,!0);if(c=b=a.filter||d&&d.filter){c=b;d=x();for(let h=0,k=c.length;h<k;h++)d[c[h]]=1;c=d}this.filter=c;this.cache=(b=a.cache)&&new J(b)}
function ja(a,b,c,d){if(b&&(c&&(b=G(b,c)),a.I&&(b=G(b,a.I)),a.K&&1<b.length&&(b=G(b,a.K)),d||""===d)){b=b.split(d);if(a.filter){a=a.filter;c=b.length;d=[];for(let e=0,f=0;e<c;e++){const g=b[e];g&&!a[g]&&(d[f++]=g)}a=d}else a=b;return a}return b}u=K.prototype;u.append=function(a,b){return this.add(a,b,!0)};
u.add=function(a,b,c,d){if(!d&&!c&&this.register[a])return this.update(a,b);if(b&&(a||0===a)&&(b=this.encode(b),d=b.length)){const m=this.depth,n=this.D,r=x(),t=x();for(let q=0;q<d;q++){let l=b[this.B?d-1-q:q];var e=l.length;if(l&&e>=this.A&&(m||!r[l])){var f=L(n,d,q),g="";switch(this.C){case "full":if(3<e){for(f=0;f<e;f++)for(var h=e;h>f;h--)if(h-f>=this.A){var k=L(n,d,q,e,f);g=l.substring(f,h);M(this,r,g,k,a,c)}break}case "reverse":if(2<e){for(h=e-1;0<h;h--)g=l[h]+g,g.length>=this.A&&M(this,r,g,
L(n,d,q,e,h),a,c);g=""}case "forward":if(1<e)for(h=0;h<e;h++)g+=l[h],g.length>=this.A&&M(this,r,g,f,a,c);break;default:if(M(this,r,l,f,a,c),m&&1<d&&q<d-1)for(e=this.l,g=x(),f=l,h=Math.min(m+1,d-q),g[f]=1,k=1;k<h;k++)if((l=b[this.B?d-1-q-k:q+k])&&l.length>=this.A&&!g[l]){g[l]=1;const p=this.F&&l>f;M(this,t,p?f:l,L(e+(d/2>e?0:1),d,q,h-1,k-1),a,c,p?l:f)}}}}this.o||(this.register[a]=1)}return this};function L(a,b,c,d,e){return c&&1<a?b+(d||0)<=a?c+(e||0):(a-1)/(b+(d||0))*(c+(e||0))+1|0:0}
function M(a,b,c,d,e,f,g){let h=g?a.h:a.map;if(!b[c]||g&&!b[c][g])a.s&&(h=h[d]),g?(b=b[c]||(b[c]=x()),b[g]=1,h=h[g]||(h[g]=x())):b[c]=1,h=h[c]||(h[c]=[]),a.s||(h=h[d]||(h[d]=[])),f&&-1!==h.indexOf(e)||(h[h.length]=e,a.o&&(a=a.register[e]||(a.register[e]=[]),a[a.length]=h))}
u.search=function(a,b,c){D(a)?(c=a,a=c.query):D(b)&&(c=b);let d=[],e;let f,g=0;if(c){b=c.limit;g=c.offset||0;var h=c.context;f=c.suggest}if(a&&(a=this.encode(a),e=a.length,1<e)){c=x();var k=[];for(let n=0,r=0,t;n<e;n++)if((t=a[n])&&t.length>=this.A&&!c[t])if(this.s||f||this.map[t])k[r++]=t,c[t]=1;else return d;a=k;e=a.length}if(!e)return d;b||(b=100);h=this.depth&&1<e&&!1!==h;c=0;let m;h?(m=a[0],c=1):1<e&&a.sort(aa);for(let n,r;c<e;c++){r=a[c];h?(n=ta(this,d,f,b,g,2===e,r,m),f&&!1===n&&d.length||
(m=r)):n=ta(this,d,f,b,g,1===e,r);if(n)return n;if(f&&c===e-1){k=d.length;if(!k){if(h){h=0;c=-1;continue}return d}if(1===k)return ua(d[0],b,g)}}return ma(d,b,g,f)};
function ta(a,b,c,d,e,f,g,h){let k=[],m=h?a.h:a.map;a.s||(m=va(m,g,h,a.F));if(m){let n=0;const r=Math.min(m.length,h?a.l:a.D);for(let t=0,q=0,l,p;t<r;t++)if(l=m[t])if(a.s&&(l=va(l,g,h,a.F)),e&&l&&f&&(p=l.length,p<=e?(e-=p,l=null):(l=l.slice(e),e=0)),l&&(k[n++]=l,f&&(q+=l.length,q>=d)))break;if(n){if(f)return ua(k,d,0);b[b.length]=k;return}}return!c&&k}function ua(a,b,c){a=1===a.length?a[0]:[].concat.apply([],a);return c||a.length>b?a.slice(c,c+b):a}
function va(a,b,c,d){c?(d=d&&b>c,a=(a=a[d?b:c])&&a[d?c:b]):a=a[b];return a}u.contain=function(a){return!!this.register[a]};u.update=function(a,b){return this.remove(a).add(a,b)};
u.remove=function(a,b){const c=this.register[a];if(c){if(this.o)for(let d=0,e;d<c.length;d++)e=c[d],e.splice(e.indexOf(a),1);else N(this.map,a,this.D,this.s),this.depth&&N(this.h,a,this.l,this.s);b||delete this.register[a];if(this.cache){b=this.cache;for(let d=0,e,f;d<b.h.length;d++)f=b.h[d],e=b.cache[f],-1!==e.indexOf(a)&&(b.h.splice(d--,1),delete b.cache[f])}}return this};
function N(a,b,c,d,e){let f=0;if(a.constructor===Array)if(e)b=a.indexOf(b),-1!==b?1<a.length&&(a.splice(b,1),f++):f++;else{e=Math.min(a.length,c);for(let g=0,h;g<e;g++)if(h=a[g])f=N(h,b,c,d,e),d||f||delete a[g]}else for(let g in a)(f=N(a[g],b,c,d,e))||delete a[g];return f}u.searchCache=oa;
u.export=function(a,b,c,d,e){let f,g;switch(e||(e=0)){case 0:f="reg";if(this.o){g=x();for(let h in this.register)g[h]=1}else g=this.register;break;case 1:f="cfg";g={doc:0,opt:this.s?1:0};break;case 2:f="map";g=this.map;break;case 3:f="ctx";g=this.h;break;default:return}sa(a,b||this,c?c+"."+f:f,d,e,g);return!0};u.import=function(a,b){if(b)switch(B(b)&&(b=JSON.parse(b)),a){case "cfg":this.s=!!b.opt;break;case "reg":this.o=!1;this.register=b;break;case "map":this.map=b;break;case "ctx":this.h=b}};la(K.prototype);function wa(a){a=a.data;var b=self._index;const c=a.args;var d=a.task;switch(d){case "init":d=a.options||{};a=a.factory;b=d.encode;d.cache=!1;b&&0===b.indexOf("function")&&(d.encode=Function("return "+b)());a?(Function("return "+a)()(self),self._index=new self.FlexSearch.Index(d),delete self.FlexSearch):self._index=new K(d);break;default:a=a.id,b=b[d].apply(b,c),postMessage("search"===d?{id:a,msg:b}:{id:a})}};let xa=0;function O(a){var b;a?E(b=a.encode)&&(a.encode=b.toString()):a={};(b=(self||window)._factory)&&(b=b.toString());const c=self.exports,d=this;this.m=ya(b,c,a.worker);this.h=x();if(this.m){if(c)this.m.on("message",function(e){d.h[e.id](e.msg);delete d.h[e.id]});else this.m.onmessage=function(e){e=e.data;d.h[e.id](e.msg);delete d.h[e.id]};this.m.postMessage({task:"init",factory:b,options:a})}}P("add");P("append");P("search");P("update");P("remove");
function P(a){O.prototype[a]=O.prototype[a+"Async"]=function(){const b=this,c=[].slice.call(arguments);var d=c[c.length-1];let e;E(d)&&(e=d,c.splice(c.length-1,1));d=new Promise(function(f){setTimeout(function(){b.h[++xa]=f;b.m.postMessage({task:a,id:xa,args:c})})});return e?(d.then(e),this):d}}
function ya(a,b,c){let d;try{d=b?eval('new (require("worker_threads")["Worker"])("../dist/node/node.js")'):a?new Worker(URL.createObjectURL(new Blob(["onmessage="+wa.toString()],{type:"text/javascript"}))):new Worker(B(c)?c:"worker/worker.js",{type:"module"})}catch(e){}return d};function R(a){if(!(this instanceof R))return new R(a);var b=a.document||a.doc||a,c;this.L=[];this.h=[];this.G=[];this.register=x();this.key=(c=b.key||b.id)&&S(c,this.G)||"id";this.o=v(a.fastupdate);this.H=(c=b.store)&&!0!==c&&[];this.store=c&&x();this.J=(c=b.tag)&&S(c,this.G);this.l=c&&x();this.cache=(c=a.cache)&&new J(c);a.cache=!1;this.m=a.worker;this.async=!1;c=x();let d=b.index||b.field||b;B(d)&&(d=[d]);for(let e=0,f,g;e<d.length;e++)f=d[e],B(f)||(g=f,f=f.field),g=D(g)?Object.assign({},a,g):a,
this.m&&(c[f]=new O(g),c[f].m||(this.m=!1)),this.m||(c[f]=new K(g,this.register)),this.L[e]=S(f,this.G),this.h[e]=f;if(this.H)for(a=b.store,B(a)&&(a=[a]),b=0;b<a.length;b++)this.H[b]=S(a[b],this.G);this.index=c}function S(a,b){const c=a.split(":");let d=0;for(let e=0;e<c.length;e++)a=c[e],0<=a.indexOf("[]")&&(a=a.substring(0,a.length-2))&&(b[d]=!0),a&&(c[d++]=a);d<c.length&&(c.length=d);return 1<d?c:c[0]}function T(a,b){if(B(b))a=a[b];else for(let c=0;a&&c<b.length;c++)a=a[b[c]];return a}
function U(a,b,c,d,e){a=a[e];if(d===c.length-1)b[e]=a;else if(a)if(a.constructor===Array)for(b=b[e]=Array(a.length),e=0;e<a.length;e++)U(a,b,c,d,e);else b=b[e]||(b[e]=x()),e=c[++d],U(a,b,c,d,e)}function V(a,b,c,d,e,f,g,h){a=a[g];if(d===b.length-1){if(a.constructor===Array){if(c[d]){for(b=0;b<a.length;b++)e.add(f,a[b],!0,!0);return}a=a.join(" ")}e.add(f,a,h,!0)}else if(a)if(a.constructor===Array)for(g=0;g<a.length;g++)V(a,b,c,d,e,f,g,h);else g=b[++d],V(a,b,c,d,e,f,g,h)}u=R.prototype;
u.add=function(a,b,c){D(a)&&(b=a,a=T(b,this.key));if(b&&(a||0===a)){if(this.register[a])return this.update(a,b);for(let d=0,e,f;d<this.h.length;d++)f=this.h[d],e=this.L[d],B(e)&&(e=[e]),V(b,e,this.G,0,this.index[f],a,e[0],c);if(this.J){let d=T(b,this.J),e=x();B(d)&&(d=[d]);for(let f=0,g,h;f<d.length;f++)if(g=d[f],!e[g]&&(e[g]=1,h=this.l[g]||(this.l[g]=[]),!c||-1===h.indexOf(a)))if(h[h.length]=a,this.o){const k=this.register[a]||(this.register[a]=[]);k[k.length]=h}}if(this.store){let d;if(this.H){d=
x();for(let e=0,f;e<this.H.length;e++)f=this.H[e],B(f)?d[f]=b[f]:U(b,d,f,0,f[0])}this.store[a]=d||b}}return this};u.append=function(a,b){return this.add(a,b,!0)};u.update=function(a,b){return this.remove(a).add(a,b)};
u.remove=function(a){D(a)&&(a=T(a,this.key));if(this.register[a]){var b=this.o&&!this.m;for(var c=0;c<this.h.length&&(this.index[this.h[c]].remove(a,b),!b);c++);if(this.J&&!b)for(let d in this.l)b=this.l[d],c=b.indexOf(a),-1!==c&&(1<b.length?b.splice(c,1):delete this.l[d]);this.store&&delete this.store[a];delete this.register[a]}return this};
u.search=function(a,b,c,d){D(a)?(c=a,a=c.query):D(b)&&(c=b,b=0);let e=[],f=[],g,h,k,m,n,r,t=0;if(c)if(c.constructor===Array)k=c,c=null;else{k=(g=c.pluck)||c.index||c.field||c;m=c.tag;h=this.store&&c.enrich;n="and"===c.bool;b=c.limit||100;r=c.offset||0;if(m&&(B(m)&&(m=[m]),!a)){for(let l=0,p;l<m.length;l++)if(p=za.call(this,m[l],b,r,h))e[e.length]=p,t++;return t?e:[]}B(k)?k=[k]:k.constructor===Array||(k=null)}k||(k=this.h);n=n&&(1<k.length||m&&1<m.length);const q=!d&&(this.m||this.async)&&[];for(let l=
0,p,y,z;l<k.length;l++){let A;y=k[l];B(y)||(A=y,y=y.field);if(q)q[l]=this.index[y].searchAsync(a,b,A||c);else{d?p=d[l]:p=this.index[y].search(a,b,A||c);z=p&&p.length;if(m&&z){const C=[];let pa=0;n&&(C[0]=[p]);for(let W=0,qa,Q;W<m.length;W++)if(qa=m[W],z=(Q=this.l[qa])&&Q.length)pa++,C[C.length]=n?[Q]:Q;pa&&(p=n?ma(C,b||100,r||0):na(p,C),z=p.length)}if(z)f[t]=y,e[t++]=p;else if(n)return[]}}if(q){const l=this;return new Promise(function(p){Promise.all(q).then(function(y){p(l.search(a,b,c,y))})})}if(!t)return[];
if(g&&(!h||!this.store))return e[0];for(let l=0,p;l<f.length;l++){p=e[l];p.length&&h&&(p=Aa.call(this,p));if(g)return p;e[l]={field:f[l],result:p}}return e};function za(a,b,c,d){let e=this.l[a],f=e&&e.length-c;if(f&&0<f){if(f>b||c)e=e.slice(c,c+b);d&&(e=Aa.call(this,e));return{tag:a,result:e}}}function Aa(a){const b=Array(a.length);for(let c=0,d;c<a.length;c++)d=a[c],b[c]={key:d,doc:this.store[d]};return b}u.contain=function(a){return!!this.register[a]};u.get=function(a){return this.store[a]};
u.set=function(a,b){this.store[a]=b;return this};u.searchCache=oa;u.export=function(a,b,c,d,e){e||(e=0);d||(d=0);if(d<this.h.length){const f=this.h[d],g=this.index[f];b=this;setTimeout(function(){g.export(a,b,e?f.replace(":","-"):"",d,e++)||(d++,e=1,b.export(a,b,f,d,e))})}else{let f;switch(e){case 1:c="tag";f=this.l;break;case 2:c="store";f=this.store;break;default:return}sa(a,this,c,d,e,f)}};
u.import=function(a,b){if(b)switch(B(b)&&(b=JSON.parse(b)),a){case "tag":this.l=b;break;case "reg":this.o=!1;this.register=b;for(let d=0,e;d<this.h.length;d++)e=this.index[this.h[d]],e.register=b,e.o=!1;break;case "store":this.store=b;break;default:a=a.split(".");const c=a[0];a=a[1];c&&a&&this.index[c].import(a,b)}};la(R.prototype);var Ca={encode:Ba,B:!1,C:""};const Da=/[\W_]+/,Ea=[F("[\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5]"),"a",F("[\u00e8\u00e9\u00ea\u00eb]"),"e",F("[\u00ec\u00ed\u00ee\u00ef]"),"i",F("[\u00f2\u00f3\u00f4\u00f5\u00f6\u0151]"),"o",F("[\u00f9\u00fa\u00fb\u00fc\u0171]"),"u",F("[\u00fd\u0177\u00ff]"),"y",F("\u00f1"),"n",F("[\u00e7c]"),"k",F("\u00df"),"s",F(" & ")," and "];function Ba(a){return ja(this,ca(a).toLowerCase(),!a.normalize&&Ea,Da)};var Ga={encode:Fa,B:!1,C:"strict"};const Ha=/[^a-z0-9]+/,Ia={b:"p",v:"f",w:"f",z:"s",x:"s","\u00df":"s",d:"t",n:"m",c:"k",g:"k",j:"k",q:"k",i:"e",y:"e",u:"o"};function Fa(a){a=Ba.call(this,a).join(" ");const b=[];if(a){const c=a.split(Ha),d=c.length;for(let e=0,f,g=0;e<d;e++)if((a=c[e])&&(!this.filter||!this.filter[a])){f=a[0];let h=Ia[f]||f,k=h;for(let m=1;m<a.length;m++){f=a[m];const n=Ia[f]||f;n&&n!==k&&(h+=n,k=n)}b[g++]=h}}return b};var Ka={encode:Ja,B:!1,C:""};const La=[F("ae"),"a",F("oe"),"o",F("sh"),"s",F("th"),"t",F("ph"),"f",F("pf"),"f"];function Ja(a,b){a&&(a=Fa.call(this,a).join(" "),2<a.length&&(a=G(a,La)),b||(1<a.length&&(a=ea(a)),a&&(a=a.split(" "))));return a};var Na={encode:Ma,B:!1,C:""};const Oa=F("(?!\\b)[aeiouy]");function Ma(a){a&&(a=Ja.call(this,a,!0),1<a.length&&(a=a.replace(Oa,"")),1<a.length&&(a=ea(a)),a&&(a=a.split(" ")));return a};H["latin:default"]=ha;H["latin:simple"]=Ca;H["latin:balance"]=Ga;H["latin:advanced"]=Ka;H["latin:extra"]=Na;const X=self;let Y;const Z={Index:K,Document:R,Worker:O,registerCharset:function(a,b){H[a]=b},registerLanguage:function(a,b){ka[a]=b}};(Y=X.define)&&Y.amd?Y([],function(){return Z}):X.exports?X.exports=Z:X.FlexSearch=Z;}(this));

View File

@@ -5,24 +5,24 @@
* Licence: Apache-2.0
* https://github.com/nextapps-de/flexsearch
*/
(function(self){'use strict';var u;function v(a){return"undefined"!==typeof a?a:!0}function x(a){const b=Array(a);for(let c=0;c<a;c++)b[c]=z();return b}function z(){return Object.create(null)}function aa(a,b){return b.length-a.length}function C(a){return"string"===typeof a}function D(a){return"object"===typeof a};const ba=/[\u0300-\u036f]/g;function E(a){a.normalize&&(a=a.normalize("NFD").replace(ba,""));return a}function F(a,b){const c=Object.keys(a),e=c.length,d=[];let f="",h=0;for(let g=0,l,m;g<e;g++)l=c[g],(m=a[l])?(d[h++]=H(b?"(?!\\b)"+l+"(\\b|_)":l),d[h++]=m):f+=(f?"|":"")+l;f&&(d[h++]=H(b?"(?!\\b)("+f+")(\\b|_)":"("+f+")"),d[h]="");return d}function I(a,b){for(let c=0,e=b.length;c<e&&(a=a.replace(b[c],b[c+1]),a);c+=2);return a}function H(a){return new RegExp(a,"g")}
function J(a){let b="",c="";for(let e=0,d=a.length,f;e<d;e++)(f=a[e])!==c&&(b+=c=f);return b};var ca={encode:K,A:!1,B:""};const da=/[\W_]+/;function K(a){return L(this,E(a).toLowerCase(),!1,da)};const ea={},N={};function fa(a){O(a,"add");O(a,"append");O(a,"search");O(a,"update");O(a,"remove")}function O(a,b){a[b+"Async"]=function(){const c=this,e=arguments;var d=e[e.length-1];let f;"function"===typeof d&&(f=d,delete e[e.length-1]);d=new Promise(function(h){setTimeout(function(){c.async=!0;const g=c[b].apply(c,e);c.async=!1;h(g)})});return f?(d.then(f),this):d}};function ha(a,b,c,e){const d=a.length;let f=[],h;let g,l;for(var m=0;m<d;m++){var n=a[m],t=n.length,r=0;for(let k=0,p;k<t;k++)(p=n[k])&&(r+=p.length);if(!q||r<q){var q=r;g=n;l=m}}g=1===g.length?g[0]:[].concat.apply([],g);e&&(e=[g],h=z());m=q=0;for(n=d-1;0<=n;n--)if(n!==l){m++;t=a[n];r=t.length;const k=[];let p=0;for(let w=0,y;w<g.length;w++){y=g[w];let A;for(let B=0;B<r;B++){const G=t[B];if(G.length&&(A=-1!==G.indexOf(y))){if(m===d-1){if(c)c--;else if(f[q++]=y,q===b)return f;e&&(h[y]=1)}break}}A&&
(k[p++]=y)}if(e)e[m]=k;else if(!p)return[];g=k}if(e)for(let k=e.length-1,p,w;0<=k;k--)if(w=(p=e[k])&&p.length)for(let y=0,A;y<w;y++)if(A=p[y],!h[A])if(h[A]=1,c)c--;else if(f[q++]=A,q===b)return f;return f}function ja(a,b){const c=z(),e=z(),d=[];for(let f=0;f<a.length;f++)c[a[f]]=1;for(let f=0,h;f<b.length;f++){h=b[f];for(let g=0,l;g<h.length;g++)l=h[g],c[l]&&!e[l]&&(e[l]=1,d[d.length]=l)}return d};const ka={memory:{charset:"latin:extra",D:3,o:3,C:!1,s:"memory"},performance:{threshold:8,o:3,context:{depth:1,F:!0}},match:{charset:"latin:extra",B:"full",D:3},score:{charset:"latin:advanced",threshold:1,context:{depth:3,F:!0}},"default":{D:3,threshold:0,depth:3}};function P(a,b){if(!(this instanceof P))return new P(a);var c;let e;a?(C(a)?a=ka[a]:(c=a.preset)&&(a=Object.assign({},c[c],a)),c=a.charset,e=a.lang,C(c)&&(-1===c.indexOf(":")&&(c+=":default"),c=N[c]),C(e)&&(e=ea[e])):a={};let d,f,h=a.context||{};this.encode=a.encode||c&&c.encode||K;this.register=b||z();this.D=d=a.resolution||9;this.B=b=c&&c.B||a.tokenize||"strict";this.depth="strict"===b&&h.depth;this.F=v(h.bidirectional);this.s=f=v(a.optimize);this.C=v(a.fastupdate);this.o=a.minlength||1;this.h=
f?x(d):z();this.m=d=h.resolution||1;this.l=f?x(d):z();this.A=c&&c.A||a.rtl;this.G=(b=a.matcher||e&&e.G)&&F(b,!1);this.H=(b=a.stemmer||e&&e.H)&&F(b,!0);if(a=b=a.filter||e&&e.filter){a=b;c=z();for(let g=0,l=a.length;g<l;g++)c[a[g]]=1;a=c}this.filter=a}function L(a,b,c,e){if(b&&(c&&(b=I(b,c)),a.G&&(b=I(b,a.G)),a.H&&1<b.length&&(b=I(b,a.H)),e||""===e)){b=b.split(e);if(a.filter){a=a.filter;c=b.length;e=[];for(let d=0,f=0;d<c;d++){const h=b[d];h&&!a[h]&&(e[f++]=h)}a=e}else a=b;return a}return b}u=P.prototype;
(function(self){'use strict';var u;function v(a){return"undefined"!==typeof a?a:!0}function w(a){const b=Array(a);for(let c=0;c<a;c++)b[c]=y();return b}function y(){return Object.create(null)}function aa(a,b){return b.length-a.length}function C(a){return"string"===typeof a}function D(a){return"object"===typeof a};const ba=/[\u0300-\u036f]/g;function E(a){a.normalize&&(a=a.normalize("NFD").replace(ba,""));return a}function F(a,b){const c=Object.keys(a),e=c.length,d=[];let f="",g=0;for(let h=0,k,m;h<e;h++)k=c[h],(m=a[k])?(d[g++]=G(b?"(?!\\b)"+k+"(\\b|_)":k),d[g++]=m):f+=(f?"|":"")+k;f&&(d[g++]=G(b?"(?!\\b)("+f+")(\\b|_)":"("+f+")"),d[g]="");return d}function H(a,b){for(let c=0,e=b.length;c<e&&(a=a.replace(b[c],b[c+1]),a);c+=2);return a}function G(a){return new RegExp(a,"g")}
function I(a){let b="",c="";for(let e=0,d=a.length,f;e<d;e++)(f=a[e])!==c&&(b+=c=f);return b};var ca={encode:J,A:!1,B:""};const da=/[\W_]+/;function J(a){return K(this,E(a).toLowerCase(),!1,da)};const ea={},L={};function fa(a){N(a,"add");N(a,"append");N(a,"search");N(a,"update");N(a,"remove")}function N(a,b){a[b+"Async"]=function(){const c=this,e=arguments;var d=e[e.length-1];let f;"function"===typeof d&&(f=d,delete e[e.length-1]);d=new Promise(function(g){setTimeout(function(){c.async=!0;const h=c[b].apply(c,e);c.async=!1;g(h)})});return f?(d.then(f),this):d}};function ha(a,b,c,e){var d=a.length;let f=[],g,h,k=0;e&&(e=[]);for(--d;0<=d;d--){const m=a[d],n=m.length,r=y();let t=!g;for(let q=0;q<n;q++){const l=m[q],p=l.length;if(p)for(let x=0,z,A;x<p;x++)if(A=l[x],g){if(g[A]){if(!d)if(c)c--;else if(f[k++]=A,k===b)return f;if(d||e)r[A]=1;t=!0}if(e&&(h[A]=(z=h[A])?z++:z=1,z<n)){const B=e[z-1]||(e[z-1]=[]);B[B.length]=A}}else r[A]=1}if(e)g||(h=r);else if(!t)return[];g=r}if(e)for(let m=e.length-1,n,r;0<=m;m--){n=e[m];r=n.length;for(let t=0,q;t<r;t++)if(q=n[t],
!g[q]){if(c)c--;else if(f[k++]=q,k===b)return f;g[q]=1}}return f}function ka(a,b){const c=y(),e=y(),d=[];for(let f=0;f<a.length;f++)c[a[f]]=1;for(let f=0,g;f<b.length;f++){g=b[f];for(let h=0,k;h<g.length;h++)k=g[h],c[k]&&!e[k]&&(e[k]=1,d[d.length]=k)}return d};const la={memory:{charset:"latin:extra",D:3,o:3,C:!1,s:"memory"},performance:{threshold:8,o:3,context:{depth:1,F:!0}},match:{charset:"latin:extra",B:"full",D:3},score:{charset:"latin:advanced",threshold:1,context:{depth:3,F:!0}},"default":{D:3,threshold:0,depth:3}};function O(a,b){if(!(this instanceof O))return new O(a);var c;let e;a?(C(a)?a=la[a]:(c=a.preset)&&(a=Object.assign({},c[c],a)),c=a.charset,e=a.lang,C(c)&&(-1===c.indexOf(":")&&(c+=":default"),c=L[c]),C(e)&&(e=ea[e])):a={};let d,f,g=a.context||{};this.encode=a.encode||c&&c.encode||J;this.register=b||y();this.D=d=a.resolution||9;this.B=b=c&&c.B||a.tokenize||"strict";this.depth="strict"===b&&g.depth;this.F=v(g.bidirectional);this.s=f=v(a.optimize);this.C=v(a.fastupdate);this.o=a.minlength||1;this.h=
f?w(d):y();this.m=d=g.resolution||1;this.l=f?w(d):y();this.A=c&&c.A||a.rtl;this.G=(b=a.matcher||e&&e.G)&&F(b,!1);this.H=(b=a.stemmer||e&&e.H)&&F(b,!0);if(a=b=a.filter||e&&e.filter){a=b;c=y();for(let h=0,k=a.length;h<k;h++)c[a[h]]=1;a=c}this.filter=a}function K(a,b,c,e){if(b&&(c&&(b=H(b,c)),a.G&&(b=H(b,a.G)),a.H&&1<b.length&&(b=H(b,a.H)),e||""===e)){b=b.split(e);if(a.filter){a=a.filter;c=b.length;e=[];for(let d=0,f=0;d<c;d++){const g=b[d];g&&!a[g]&&(e[f++]=g)}a=e}else a=b;return a}return b}u=O.prototype;
u.append=function(a,b){return this.add(a,b,!0)};
u.add=function(a,b,c,e){if(!e&&!c&&this.register[a])return this.update(a,b);if(b&&(a||0===a)&&(b=this.encode(b),e=b.length)){const m=this.depth,n=this.D,t=z(),r=z();for(let q=0;q<e;q++){let k=b[this.A?e-1-q:q];var d=k.length;if(k&&d>=this.o&&(m||!t[k])){var f=e<n?q:n/e*q|0,h="";switch(this.B){case "full":if(3<d){for(f=0;f<d;f++)for(var g=d;g>f;g--)if(g-f>=this.o){var l=e+d<n?q+f:n/(e+d)*(q+f)|0;h=k.substring(f,g);Q(this,t,h,l,a,c)}break}case "reverse":if(2<d){for(g=d-1;0<g;g--)h=k[g]+h,h.length>=
this.o&&Q(this,t,h,e+d<n?q+g:n/(e+d)*(q+g)|0,a,c);h=""}case "forward":if(1<d)for(g=0;g<d;g++)h+=k[g],h.length>=this.o&&Q(this,t,h,f,a,c);break;default:if(Q(this,t,k,f,a,c),m&&1<e&&q<e-1)for(d=this.m,h=z(),f=k,g=Math.min(m+1,e-q),h[f]=1,l=1;l<g;l++)if((k=b[this.A?e-1-q-l:q+l])&&k.length>=this.o&&!h[k]){h[k]=1;const p=this.F&&k>f;Q(this,r,p?f:k,g+e<d?q+(l-1):d/(g+e)*(q+l)|0,a,c,p?k:f)}}}}this.C||(this.register[a]=1)}return this};
function Q(a,b,c,e,d,f,h){let g=h?a.l:a.h;if(!b[c]||h&&!b[c][h])a.s&&(g=g[e]),h?(b=b[c]||(b[c]=z()),b[h]=1,g=g[h]||(g[h]=z())):b[c]=1,g=g[c]||(g[c]=[]),a.s||(g=g[e]||(g[e]=[])),f&&-1!==g.indexOf(d)||(g[g.length]=d,a.C&&(a=a.register[d]||(a.register[d]=[]),a[a.length]=g))}
u.search=function(a,b,c){D(a)?(c=a,a=c.query):D(b)&&(c=b);let e=[],d;let f,h=0;if(c){b=c.limit;h=c.offset||0;var g=c.context;f=c.suggest}if(a&&(a=this.encode(a),d=a.length,1<d)){c=z();var l=[];for(let n=0,t=0,r;n<d;n++)if((r=a[n])&&r.length>=this.o&&!c[r])if(this.s||f||this.h[r])l[t++]=r,c[r]=1;else return e;a=l;d=a.length}if(!d)return e;b||(b=100);g=this.depth&&1<d&&!1!==g;c=0;let m;g?(m=a[0],c=1):1<d&&a.sort(aa);for(let n,t;c<d;c++){t=a[c];g?(n=la(this,e,f,b,h,2===d,t,m),f&&!1===n&&e.length||(m=
t)):n=la(this,e,f,b,h,1===d,t);if(n)return n;if(f&&c===d-1){l=e.length;if(!l){if(g){g=0;c=-1;continue}return e}if(1===l)return ma(e[0],b,h)}}return ha(e,b,h,f)};
function la(a,b,c,e,d,f,h,g){let l=[],m=g?a.l:a.h;a.s||(m=na(m,h,g,a.F));if(m){let n=0;const t=Math.min(m.length,g?a.m:a.D);for(let r=0,q=0,k,p;r<t;r++)if(k=m[r])if(a.s&&(k=na(k,h,g,a.F)),d&&k&&f&&(p=k.length,p<=d?(d-=p,k=null):(k=k.slice(d),d=0)),k&&(l[n++]=k,f&&(q+=k.length,q>=e)))break;if(n){if(f)return ma(l,e,0);b[b.length]=l;return}}return!c&&l}function ma(a,b,c){a=1===a.length?a[0]:[].concat.apply([],a);return c||a.length>b?a.slice(c,c+b):a}
function na(a,b,c,e){c?(e=e&&b>c,a=(a=a[e?b:c])&&a[e?c:b]):a=a[b];return a}u.contain=function(a){return!!this.register[a]};u.update=function(a,b){return this.remove(a).add(a,b)};u.remove=function(a,b){const c=this.register[a];if(c){if(this.C)for(let e=0,d;e<c.length;e++)d=c[e],d.splice(d.indexOf(a),1);else S(this.h,a,this.D,this.s),this.depth&&S(this.l,a,this.m,this.s);b||delete this.register[a]}return this};
function S(a,b,c,e,d){let f=0;if(a.constructor===Array)if(d)b=a.indexOf(b),-1!==b?1<a.length&&(a.splice(b,1),f++):f++;else{d=Math.min(a.length,c);for(let h=0,g;h<d;h++)if(g=a[h])f=S(g,b,c,e,d),e||f||delete a[h]}else for(let h in a)(f=S(a[h],b,c,e,d))||delete a[h];return f}fa(P.prototype);function T(a){if(!(this instanceof T))return new T(a);var b=a.document||a.doc||a,c;this.I=[];this.h=[];this.m=[];this.register=z();this.key=(c=b.key||b.id)&&U(c,this.m)||"id";this.C=v(a.fastupdate);this.l=(c=b.store)&&!0!==c&&[];this.store=c&&z();this.async=!1;c=z();let e=b.index||b.field||b;C(e)&&(e=[e]);for(let d=0,f,h;d<e.length;d++)f=e[d],C(f)||(h=f,f=f.field),h=D(h)?Object.assign({},a,h):a,this.J||(c[f]=new P(h,this.register)),this.I[d]=U(f,this.m),this.h[d]=f;if(this.l)for(a=b.store,C(a)&&(a=
[a]),b=0;b<a.length;b++)this.l[b]=U(a[b],this.m);this.index=c}function U(a,b){const c=a.split(":");let e=0;for(let d=0;d<c.length;d++)a=c[d],0<=a.indexOf("[]")&&(a=a.substring(0,a.length-2))&&(b[e]=!0),a&&(c[e++]=a);e<c.length&&(c.length=e);return 1<e?c:c[0]}function oa(a,b){if(C(b))a=a[b];else for(let c=0;a&&c<b.length;c++)a=a[b[c]];return a}
function V(a,b,c,e,d){a=a[d];if(e===c.length-1)b[d]=a;else if(a)if(a.constructor===Array)for(b=b[d]=Array(a.length),d=0;d<a.length;d++)V(a,b,c,e,d);else b=b[d]||(b[d]=z()),d=c[++e],V(a,b,c,e,d)}function W(a,b,c,e,d,f,h,g){a=a[h];if(e===b.length-1){if(a.constructor===Array){if(c[e]){for(b=0;b<a.length;b++)d.add(f,a[b],!0,!0);return}a=a.join(" ")}d.add(f,a,g,!0)}else if(a)if(a.constructor===Array)for(h=0;h<a.length;h++)W(a,b,c,e,d,f,h,g);else h=b[++e],W(a,b,c,e,d,f,h,g)}u=T.prototype;
u.add=function(a,b,c){D(a)&&(b=a,a=oa(b,this.key));if(b&&(a||0===a)){if(this.register[a])return this.update(a,b);for(let e=0,d,f;e<this.h.length;e++)f=this.h[e],d=this.I[e],C(d)&&(d=[d]),W(b,d,this.m,0,this.index[f],a,d[0],c);if(this.store){let e;if(this.l){e=z();for(let d=0,f;d<this.l.length;d++)f=this.l[d],C(f)?e[f]=b[f]:V(b,e,f,0,f[0])}this.store[a]=e||b}}return this};u.append=function(a,b){return this.add(a,b,!0)};u.update=function(a,b){return this.remove(a).add(a,b)};
u.remove=function(a){D(a)&&(a=oa(a,this.key));if(this.register[a]){const b=this.C&&!this.J;for(let c=0;c<this.h.length&&(this.index[this.h[c]].remove(a,b),!b);c++);this.store&&delete this.store[a];delete this.register[a]}return this};
u.search=function(a,b,c,e){D(a)?(c=a,a=c.query):D(b)&&(c=b,b=0);let d=[],f=[],h,g,l,m,n,t,r=0;if(c)if(c.constructor===Array)l=c,c=null;else{l=(h=c.pluck)||c.index||c.field||c;m=!1;g=this.store&&c.enrich;n="and"===c.bool;b=c.limit||100;t=c.offset||0;if(m&&(C(m)&&(m=[m]),!a)){for(let k=0,p;k<m.length;k++)if(p=pa.call(this,m[k],b,t,g))d[d.length]=p,r++;return r?d:[]}C(l)?l=[l]:l.constructor===Array||(l=null)}l||(l=this.h);n=n&&(1<l.length||m&&1<m.length);const q=!e&&(this.J||this.async)&&[];for(let k=
0,p,w,y;k<l.length;k++){let A;w=l[k];C(w)||(A=w,w=w.field);if(q)q[k]=this.index[w].searchAsync(a,b,A||c);else{e?p=e[k]:p=this.index[w].search(a,b,A||c);y=p&&p.length;if(m&&y){const B=[];let G=0;n&&(B[0]=[p]);for(let R=0,ia,M;R<m.length;R++)if(ia=m[R],y=(M=this.K[ia])&&M.length)G++,B[B.length]=n?[M]:M;G&&(p=n?ha(B,b||100,t||0):ja(p,B),y=p.length)}if(y)f[r]=w,d[r++]=p;else if(n)return[]}}if(q){const k=this;return new Promise(function(p){Promise.all(q).then(function(w){p(k.search(a,b,c,w))})})}if(!r)return[];
if(h&&(!g||!this.store))return d[0];for(let k=0,p;k<f.length;k++){p=d[k];p.length&&g&&(p=qa.call(this,p));if(h)return p;d[k]={field:f[k],result:p}}return d};function pa(a,b,c,e){let d=this.K[a],f=d&&d.length-c;if(f&&0<f){if(f>b||c)d=d.slice(c,c+b);e&&(d=qa.call(this,d));return{tag:a,result:d}}}function qa(a){const b=Array(a.length);for(let c=0,e;c<a.length;c++)e=a[c],b[c]={key:e,doc:this.store[e]};return b}u.contain=function(a){return!!this.register[a]};u.get=function(a){return this.store[a]};
u.set=function(a,b){this.store[a]=b;return this};fa(T.prototype);var sa={encode:ra,A:!1,B:""};const ta=/[\W_]+/,ua=[H("[\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5]"),"a",H("[\u00e8\u00e9\u00ea\u00eb]"),"e",H("[\u00ec\u00ed\u00ee\u00ef]"),"i",H("[\u00f2\u00f3\u00f4\u00f5\u00f6\u0151]"),"o",H("[\u00f9\u00fa\u00fb\u00fc\u0171]"),"u",H("[\u00fd\u0177\u00ff]"),"y",H("\u00f1"),"n",H("[\u00e7c]"),"k",H("\u00df"),"s",H(" & ")," and "];function ra(a){return L(this,E(a).toLowerCase(),!a.normalize&&ua,ta)};var wa={encode:va,A:!1,B:"strict"};const xa=/[^a-z0-9]+/,ya={b:"p",v:"f",w:"f",z:"s",x:"s","\u00df":"s",d:"t",n:"m",c:"k",g:"k",j:"k",q:"k",i:"e",y:"e",u:"o"};function va(a){a=ra.call(this,a).join(" ");const b=[];if(a){const c=a.split(xa),e=c.length;for(let d=0,f,h=0;d<e;d++)if((a=c[d])&&(!this.filter||!this.filter[a])){f=a[0];let g=ya[f]||f,l=g;for(let m=1;m<a.length;m++){f=a[m];const n=ya[f]||f;n&&n!==l&&(g+=n,l=n)}b[h++]=g}}return b};var Aa={encode:za,A:!1,B:""};const Ba=[H("ae"),"a",H("oe"),"o",H("sh"),"s",H("th"),"t",H("ph"),"f",H("pf"),"f"];function za(a,b){a&&(a=va.call(this,a).join(" "),2<a.length&&(a=I(a,Ba)),b||(1<a.length&&(a=J(a)),a&&(a=a.split(" "))));return a};var Da={encode:Ca,A:!1,B:""};const Ea=H("(?!\\b)[aeiouy]");function Ca(a){a&&(a=za.call(this,a,!0),1<a.length&&(a=a.replace(Ea,"")),1<a.length&&(a=J(a)),a&&(a=a.split(" ")));return a};N["latin:default"]=ca;N["latin:simple"]=sa;N["latin:balance"]=wa;N["latin:advanced"]=Aa;N["latin:extra"]=Da;const X=self;let Y;const Z={Index:P,Document:T,Worker:null,registerCharset:function(a,b){N[a]=b},registerLanguage:function(a,b){ea[a]=b}};(Y=X.define)&&Y.amd?Y([],function(){return Z}):X.exports?X.exports=Z:X.FlexSearch=Z;}(this));
u.add=function(a,b,c,e){if(!e&&!c&&this.register[a])return this.update(a,b);if(b&&(a||0===a)&&(b=this.encode(b),e=b.length)){const m=this.depth,n=this.D,r=y(),t=y();for(let q=0;q<e;q++){let l=b[this.A?e-1-q:q];var d=l.length;if(l&&d>=this.o&&(m||!r[l])){var f=P(n,e,q),g="";switch(this.B){case "full":if(3<d){for(f=0;f<d;f++)for(var h=d;h>f;h--)if(h-f>=this.o){var k=P(n,e,q,d,f);g=l.substring(f,h);Q(this,r,g,k,a,c)}break}case "reverse":if(2<d){for(h=d-1;0<h;h--)g=l[h]+g,g.length>=this.o&&Q(this,r,g,
P(n,e,q,d,h),a,c);g=""}case "forward":if(1<d)for(h=0;h<d;h++)g+=l[h],g.length>=this.o&&Q(this,r,g,f,a,c);break;default:if(Q(this,r,l,f,a,c),m&&1<e&&q<e-1)for(d=this.m,g=y(),f=l,h=Math.min(m+1,e-q),g[f]=1,k=1;k<h;k++)if((l=b[this.A?e-1-q-k:q+k])&&l.length>=this.o&&!g[l]){g[l]=1;const p=this.F&&l>f;Q(this,t,p?f:l,P(d+(e/2>d?0:1),e,q,h-1,k-1),a,c,p?l:f)}}}}this.C||(this.register[a]=1)}return this};function P(a,b,c,e,d){return c&&1<a?b+(e||0)<=a?c+(d||0):(a-1)/(b+(e||0))*(c+(d||0))+1|0:0}
function Q(a,b,c,e,d,f,g){let h=g?a.l:a.h;if(!b[c]||g&&!b[c][g])a.s&&(h=h[e]),g?(b=b[c]||(b[c]=y()),b[g]=1,h=h[g]||(h[g]=y())):b[c]=1,h=h[c]||(h[c]=[]),a.s||(h=h[e]||(h[e]=[])),f&&-1!==h.indexOf(d)||(h[h.length]=d,a.C&&(a=a.register[d]||(a.register[d]=[]),a[a.length]=h))}
u.search=function(a,b,c){D(a)?(c=a,a=c.query):D(b)&&(c=b);let e=[],d;let f,g=0;if(c){b=c.limit;g=c.offset||0;var h=c.context;f=c.suggest}if(a&&(a=this.encode(a),d=a.length,1<d)){c=y();var k=[];for(let n=0,r=0,t;n<d;n++)if((t=a[n])&&t.length>=this.o&&!c[t])if(this.s||f||this.h[t])k[r++]=t,c[t]=1;else return e;a=k;d=a.length}if(!d)return e;b||(b=100);h=this.depth&&1<d&&!1!==h;c=0;let m;h?(m=a[0],c=1):1<d&&a.sort(aa);for(let n,r;c<d;c++){r=a[c];h?(n=ma(this,e,f,b,g,2===d,r,m),f&&!1===n&&e.length||(m=
r)):n=ma(this,e,f,b,g,1===d,r);if(n)return n;if(f&&c===d-1){k=e.length;if(!k){if(h){h=0;c=-1;continue}return e}if(1===k)return na(e[0],b,g)}}return ha(e,b,g,f)};
function ma(a,b,c,e,d,f,g,h){let k=[],m=h?a.l:a.h;a.s||(m=oa(m,g,h,a.F));if(m){let n=0;const r=Math.min(m.length,h?a.m:a.D);for(let t=0,q=0,l,p;t<r;t++)if(l=m[t])if(a.s&&(l=oa(l,g,h,a.F)),d&&l&&f&&(p=l.length,p<=d?(d-=p,l=null):(l=l.slice(d),d=0)),l&&(k[n++]=l,f&&(q+=l.length,q>=e)))break;if(n){if(f)return na(k,e,0);b[b.length]=k;return}}return!c&&k}function na(a,b,c){a=1===a.length?a[0]:[].concat.apply([],a);return c||a.length>b?a.slice(c,c+b):a}
function oa(a,b,c,e){c?(e=e&&b>c,a=(a=a[e?b:c])&&a[e?c:b]):a=a[b];return a}u.contain=function(a){return!!this.register[a]};u.update=function(a,b){return this.remove(a).add(a,b)};u.remove=function(a,b){const c=this.register[a];if(c){if(this.C)for(let e=0,d;e<c.length;e++)d=c[e],d.splice(d.indexOf(a),1);else S(this.h,a,this.D,this.s),this.depth&&S(this.l,a,this.m,this.s);b||delete this.register[a]}return this};
function S(a,b,c,e,d){let f=0;if(a.constructor===Array)if(d)b=a.indexOf(b),-1!==b?1<a.length&&(a.splice(b,1),f++):f++;else{d=Math.min(a.length,c);for(let g=0,h;g<d;g++)if(h=a[g])f=S(h,b,c,e,d),e||f||delete a[g]}else for(let g in a)(f=S(a[g],b,c,e,d))||delete a[g];return f}fa(O.prototype);function T(a){if(!(this instanceof T))return new T(a);var b=a.document||a.doc||a,c;this.I=[];this.h=[];this.m=[];this.register=y();this.key=(c=b.key||b.id)&&U(c,this.m)||"id";this.C=v(a.fastupdate);this.l=(c=b.store)&&!0!==c&&[];this.store=c&&y();this.async=!1;c=y();let e=b.index||b.field||b;C(e)&&(e=[e]);for(let d=0,f,g;d<e.length;d++)f=e[d],C(f)||(g=f,f=f.field),g=D(g)?Object.assign({},a,g):a,this.J||(c[f]=new O(g,this.register)),this.I[d]=U(f,this.m),this.h[d]=f;if(this.l)for(a=b.store,C(a)&&(a=
[a]),b=0;b<a.length;b++)this.l[b]=U(a[b],this.m);this.index=c}function U(a,b){const c=a.split(":");let e=0;for(let d=0;d<c.length;d++)a=c[d],0<=a.indexOf("[]")&&(a=a.substring(0,a.length-2))&&(b[e]=!0),a&&(c[e++]=a);e<c.length&&(c.length=e);return 1<e?c:c[0]}function pa(a,b){if(C(b))a=a[b];else for(let c=0;a&&c<b.length;c++)a=a[b[c]];return a}
function V(a,b,c,e,d){a=a[d];if(e===c.length-1)b[d]=a;else if(a)if(a.constructor===Array)for(b=b[d]=Array(a.length),d=0;d<a.length;d++)V(a,b,c,e,d);else b=b[d]||(b[d]=y()),d=c[++e],V(a,b,c,e,d)}function W(a,b,c,e,d,f,g,h){a=a[g];if(e===b.length-1){if(a.constructor===Array){if(c[e]){for(b=0;b<a.length;b++)d.add(f,a[b],!0,!0);return}a=a.join(" ")}d.add(f,a,h,!0)}else if(a)if(a.constructor===Array)for(g=0;g<a.length;g++)W(a,b,c,e,d,f,g,h);else g=b[++e],W(a,b,c,e,d,f,g,h)}u=T.prototype;
u.add=function(a,b,c){D(a)&&(b=a,a=pa(b,this.key));if(b&&(a||0===a)){if(this.register[a])return this.update(a,b);for(let e=0,d,f;e<this.h.length;e++)f=this.h[e],d=this.I[e],C(d)&&(d=[d]),W(b,d,this.m,0,this.index[f],a,d[0],c);if(this.store){let e;if(this.l){e=y();for(let d=0,f;d<this.l.length;d++)f=this.l[d],C(f)?e[f]=b[f]:V(b,e,f,0,f[0])}this.store[a]=e||b}}return this};u.append=function(a,b){return this.add(a,b,!0)};u.update=function(a,b){return this.remove(a).add(a,b)};
u.remove=function(a){D(a)&&(a=pa(a,this.key));if(this.register[a]){const b=this.C&&!this.J;for(let c=0;c<this.h.length&&(this.index[this.h[c]].remove(a,b),!b);c++);this.store&&delete this.store[a];delete this.register[a]}return this};
u.search=function(a,b,c,e){D(a)?(c=a,a=c.query):D(b)&&(c=b,b=0);let d=[],f=[],g,h,k,m,n,r,t=0;if(c)if(c.constructor===Array)k=c,c=null;else{k=(g=c.pluck)||c.index||c.field||c;m=!1;h=this.store&&c.enrich;n="and"===c.bool;b=c.limit||100;r=c.offset||0;if(m&&(C(m)&&(m=[m]),!a)){for(let l=0,p;l<m.length;l++)if(p=qa.call(this,m[l],b,r,h))d[d.length]=p,t++;return t?d:[]}C(k)?k=[k]:k.constructor===Array||(k=null)}k||(k=this.h);n=n&&(1<k.length||m&&1<m.length);const q=!e&&(this.J||this.async)&&[];for(let l=
0,p,x,z;l<k.length;l++){let A;x=k[l];C(x)||(A=x,x=x.field);if(q)q[l]=this.index[x].searchAsync(a,b,A||c);else{e?p=e[l]:p=this.index[x].search(a,b,A||c);z=p&&p.length;if(m&&z){const B=[];let ia=0;n&&(B[0]=[p]);for(let R=0,ja,M;R<m.length;R++)if(ja=m[R],z=(M=this.K[ja])&&M.length)ia++,B[B.length]=n?[M]:M;ia&&(p=n?ha(B,b||100,r||0):ka(p,B),z=p.length)}if(z)f[t]=x,d[t++]=p;else if(n)return[]}}if(q){const l=this;return new Promise(function(p){Promise.all(q).then(function(x){p(l.search(a,b,c,x))})})}if(!t)return[];
if(g&&(!h||!this.store))return d[0];for(let l=0,p;l<f.length;l++){p=d[l];p.length&&h&&(p=ra.call(this,p));if(g)return p;d[l]={field:f[l],result:p}}return d};function qa(a,b,c,e){let d=this.K[a],f=d&&d.length-c;if(f&&0<f){if(f>b||c)d=d.slice(c,c+b);e&&(d=ra.call(this,d));return{tag:a,result:d}}}function ra(a){const b=Array(a.length);for(let c=0,e;c<a.length;c++)e=a[c],b[c]={key:e,doc:this.store[e]};return b}u.contain=function(a){return!!this.register[a]};u.get=function(a){return this.store[a]};
u.set=function(a,b){this.store[a]=b;return this};fa(T.prototype);var ta={encode:sa,A:!1,B:""};const ua=/[\W_]+/,va=[G("[\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5]"),"a",G("[\u00e8\u00e9\u00ea\u00eb]"),"e",G("[\u00ec\u00ed\u00ee\u00ef]"),"i",G("[\u00f2\u00f3\u00f4\u00f5\u00f6\u0151]"),"o",G("[\u00f9\u00fa\u00fb\u00fc\u0171]"),"u",G("[\u00fd\u0177\u00ff]"),"y",G("\u00f1"),"n",G("[\u00e7c]"),"k",G("\u00df"),"s",G(" & ")," and "];function sa(a){return K(this,E(a).toLowerCase(),!a.normalize&&va,ua)};var xa={encode:wa,A:!1,B:"strict"};const ya=/[^a-z0-9]+/,za={b:"p",v:"f",w:"f",z:"s",x:"s","\u00df":"s",d:"t",n:"m",c:"k",g:"k",j:"k",q:"k",i:"e",y:"e",u:"o"};function wa(a){a=sa.call(this,a).join(" ");const b=[];if(a){const c=a.split(ya),e=c.length;for(let d=0,f,g=0;d<e;d++)if((a=c[d])&&(!this.filter||!this.filter[a])){f=a[0];let h=za[f]||f,k=h;for(let m=1;m<a.length;m++){f=a[m];const n=za[f]||f;n&&n!==k&&(h+=n,k=n)}b[g++]=h}}return b};var Ba={encode:Aa,A:!1,B:""};const Ca=[G("ae"),"a",G("oe"),"o",G("sh"),"s",G("th"),"t",G("ph"),"f",G("pf"),"f"];function Aa(a,b){a&&(a=wa.call(this,a).join(" "),2<a.length&&(a=H(a,Ca)),b||(1<a.length&&(a=I(a)),a&&(a=a.split(" "))));return a};var Ea={encode:Da,A:!1,B:""};const Fa=G("(?!\\b)[aeiouy]");function Da(a){a&&(a=Aa.call(this,a,!0),1<a.length&&(a=a.replace(Fa,"")),1<a.length&&(a=I(a)),a&&(a=a.split(" ")));return a};L["latin:default"]=ca;L["latin:simple"]=ta;L["latin:balance"]=xa;L["latin:advanced"]=Ba;L["latin:extra"]=Ea;const X=self;let Y;const Z={Index:O,Document:T,Worker:null,registerCharset:function(a,b){L[a]=b},registerLanguage:function(a,b){ea[a]=b}};(Y=X.define)&&Y.amd?Y([],function(){return Z}):X.exports?X.exports=Z:X.FlexSearch=Z;}(this));

View File

@@ -6,7 +6,7 @@
* https://github.com/nextapps-de/flexsearch
*/
(function(self){'use strict';
function t(a, b) {
function r(a, b) {
return "undefined" !== typeof a ? a : b;
}
function v(a) {
@@ -25,10 +25,10 @@ function aa(a, b) {
function y(a) {
return "string" === typeof a;
}
function A(a) {
function z(a) {
return "object" === typeof a;
}
function D(a) {
function C(a) {
return "function" === typeof a;
}
;const ba = /[\u0300-\u036f]/g;
@@ -39,13 +39,13 @@ function E(a) {
function ca(a, b) {
const c = Object.keys(a), d = c.length, e = [];
let f = "", g = 0;
for (let h = 0, k, p; h < d; h++) {
k = c[h], (p = a[k]) ? (e[g++] = F(b ? "(?!\\b)" + k + "(\\b|_)" : k), e[g++] = p) : f += (f ? "|" : "") + k;
for (let h = 0, k, n; h < d; h++) {
k = c[h], (n = a[k]) ? (e[g++] = F(b ? "(?!\\b)" + k + "(\\b|_)" : k), e[g++] = n) : f += (f ? "|" : "") + k;
}
f && (e[g++] = F(b ? "(?!\\b)(" + f + ")(\\b|_)" : "(" + f + ")"), e[g] = "");
return e;
}
function H(a, b) {
function G(a, b) {
for (let c = 0, d = b.length; c < d && (a = a.replace(b[c], b[c + 1]), a); c += 2) {
}
return a;
@@ -53,7 +53,7 @@ function H(a, b) {
function F(a) {
return new RegExp(a, "g");
}
function I(a) {
function H(a) {
let b = "", c = "";
for (let d = 0, e = a.length, f; d < e; d++) {
(f = a[d]) !== c && (b += c = f);
@@ -65,20 +65,20 @@ const fa = /[\W_]+/;
function da(a) {
return this.pipeline(E(a).toLowerCase(), !1, fa, !1);
}
;const ha = {}, J = {};
;const ha = {}, I = {};
function ia(a) {
K(a, "add");
K(a, "append");
K(a, "search");
K(a, "update");
K(a, "remove");
J(a, "add");
J(a, "append");
J(a, "search");
J(a, "update");
J(a, "remove");
}
function K(a, b) {
function J(a, b) {
a[b + "Async"] = function() {
const c = this, d = arguments;
var e = d[d.length - 1];
let f;
D(e) && (f = e, delete d[d.length - 1]);
C(e) && (f = e, delete d[d.length - 1]);
e = new Promise(function(g) {
setTimeout(function() {
c.async = !0;
@@ -91,74 +91,65 @@ function K(a, b) {
};
}
;function ja(a, b, c, d) {
const e = a.length;
let f = [], g;
let h, k;
for (var p = 0; p < e; p++) {
var n = a[p], r = n.length, u = 0;
for (let l = 0, q; l < r; l++) {
(q = n[l]) && (u += q.length);
}
if (!m || u < m) {
var m = u;
h = n;
k = p;
}
}
h = 1 === h.length ? h[0] : [].concat.apply([], h);
d && (d = [h], g = w());
p = m = 0;
for (n = e - 1; 0 <= n; n--) {
if (n !== k) {
p++;
r = a[n];
u = r.length;
const l = [];
let q = 0;
for (let x = 0, z; x < h.length; x++) {
z = h[x];
let B;
for (let C = 0; C < u; C++) {
const G = r[C];
if (G.length && (B = -1 !== G.indexOf(z))) {
if (p === e - 1) {
if (c) {
c--;
} else {
if (f[m++] = z, m === b) {
return f;
var e = a.length;
let f = [], g, h, k = 0;
d && (d = []);
for (--e; 0 <= e; e--) {
const n = a[e], p = n.length, q = w();
let t = !g;
for (let m = 0; m < p; m++) {
const l = n[m], u = l.length;
if (u) {
for (let x = 0, A, B; x < u; x++) {
if (B = l[x], g) {
if (g[B]) {
if (!e) {
if (c) {
c--;
} else {
if (f[k++] = B, k === b) {
return f;
}
}
}
d && (g[z] = 1);
if (e || d) {
q[B] = 1;
}
t = !0;
}
break;
if (d && (h[B] = (A = h[B]) ? A++ : A = 1, A < p)) {
const D = d[A - 1] || (d[A - 1] = []);
D[D.length] = B;
}
} else {
q[B] = 1;
}
}
B && (l[q++] = z);
}
if (d) {
d[p] = l;
} else {
if (!q) {
return [];
}
}
h = l;
}
if (d) {
g || (h = q);
} else {
if (!t) {
return [];
}
}
g = q;
}
if (d) {
for (let l = d.length - 1, q, x; 0 <= l; l--) {
if (x = (q = d[l]) && q.length) {
for (let z = 0, B; z < x; z++) {
if (B = q[z], !g[B]) {
if (g[B] = 1, c) {
c--;
} else {
if (f[m++] = B, m === b) {
return f;
}
for (let n = d.length - 1, p, q; 0 <= n; n--) {
p = d[n];
q = p.length;
for (let t = 0, m; t < q; t++) {
if (m = p[t], !g[m]) {
if (c) {
c--;
} else {
if (f[k++] = m, k === b) {
return f;
}
}
g[m] = 1;
}
}
}
@@ -178,18 +169,18 @@ function ka(a, b) {
}
return e;
}
;function L(a) {
;function K(a) {
this.limit = !0 !== a && a;
this.cache = w();
this.queue = [];
}
function la(a, b, c) {
A(a) && (a = a.query);
z(a) && (a = a.query);
let d = this.cache.get(a);
d || (d = this.search(a, b, c), this.cache.set(a, d));
return d;
}
L.prototype.set = function(a, b) {
K.prototype.set = function(a, b) {
if (!this.cache[a]) {
var c = this.queue.length;
c === this.limit ? delete this.cache[this.queue[c - 1]] : c++;
@@ -200,7 +191,7 @@ L.prototype.set = function(a, b) {
}
this.cache[a] = b;
};
L.prototype.get = function(a) {
K.prototype.get = function(a) {
const b = this.cache[a];
if (this.limit && b && (a = this.queue.indexOf(a))) {
const c = this.queue[a - 1];
@@ -209,13 +200,13 @@ L.prototype.get = function(a) {
}
return b;
};
L.prototype.del = function(a) {
K.prototype.del = function(a) {
for (let b = 0, c, d; b < this.queue.length; b++) {
d = this.queue[b], c = this.cache[d], -1 !== c.indexOf(a) && (this.queue.splice(b--, 1), delete this.cache[d]);
}
};
const na = {memory:{charset:"latin:extra", resolution:3, minlength:3, fastupdate:!1, optimize:"memory"}, performance:{threshold:8, minlength:3, context:{depth:1, bidirectional:!0}}, match:{charset:"latin:extra", tokenize:"full", resolution:3, }, score:{charset:"latin:advanced", threshold:1, context:{depth:3, bidirectional:!0}}, "default":{resolution:3, threshold:0, depth:3}, };
function oa(a, b, c, d, e, f) {
const oa = {memory:{charset:"latin:extra", resolution:3, minlength:3, fastupdate:!1, optimize:"memory"}, performance:{threshold:8, minlength:3, context:{depth:1, bidirectional:!0}}, match:{charset:"latin:extra", tokenize:"full", resolution:3, }, score:{charset:"latin:advanced", threshold:1, context:{depth:3, bidirectional:!0}}, "default":{resolution:3, threshold:0, depth:3}, };
function pa(a, b, c, d, e, f) {
setTimeout(function() {
const g = a(c, JSON.stringify(f));
g && g.then ? g.then(function() {
@@ -223,14 +214,14 @@ function oa(a, b, c, d, e, f) {
}) : b.export(a, b, c, d, e + 1);
});
}
;function M(a, b) {
if (!(this instanceof M)) {
return new M(a);
;function L(a, b) {
if (!(this instanceof L)) {
return new L(a);
}
var c;
if (a) {
if (y(a)) {
na[a] || console.warn("Preset not found: " + a), a = na[a];
oa[a] || console.warn("Preset not found: " + a), a = oa[a];
} else {
if (c = a.preset) {
c[c] || console.warn("Preset not found: " + c), a = Object.assign({}, c[c], a);
@@ -238,7 +229,7 @@ function oa(a, b, c, d, e, f) {
}
c = a.charset;
var d = a.lang;
y(c) && (-1 === c.indexOf(":") && (c += ":default"), c = J[c]);
y(c) && (-1 === c.indexOf(":") && (c += ":default"), c = I[c]);
y(d) && (d = ha[d]);
} else {
a = {};
@@ -249,9 +240,9 @@ function oa(a, b, c, d, e, f) {
this.resolution = e = a.resolution || 9;
this.tokenize = b = c && c.tokenize || a.tokenize || "strict";
this.depth = "strict" === b && g.depth;
this.bidirectional = t(g.bidirectional, !0);
this.optimize = f = t(a.optimize, !0);
this.fastupdate = t(a.fastupdate, !0);
this.bidirectional = r(g.bidirectional, !0);
this.optimize = f = r(a.optimize, !0);
this.fastupdate = r(a.fastupdate, !0);
this.minlength = a.minlength || 1;
this.map = f ? v(e) : w();
this.resolution_ctx = e = g.resolution || 1;
@@ -268,10 +259,10 @@ function oa(a, b, c, d, e, f) {
c = d;
}
this.filter = c;
this.cache = (b = a.cache) && new L(b);
this.cache = (b = a.cache) && new K(b);
}
M.prototype.pipeline = function(a, b, c, d) {
if (a && (b && (a = H(a, b)), this.matcher && (a = H(a, this.matcher)), this.stemmer && 1 < a.length && (a = H(a, this.stemmer)), d && 1 < a.length && (a = I(a)), c || "" === c)) {
L.prototype.pipeline = function(a, b, c, d) {
if (a && (b && (a = G(a, b)), this.matcher && (a = G(a, this.matcher)), this.stemmer && 1 < a.length && (a = G(a, this.stemmer)), d && 1 < a.length && (a = H(a)), c || "" === c)) {
a = a.split(c);
if (this.filter) {
b = this.filter;
@@ -287,29 +278,29 @@ M.prototype.pipeline = function(a, b, c, d) {
}
return a;
};
M.prototype.append = function(a, b) {
L.prototype.append = function(a, b) {
return this.add(a, b, !0);
};
M.prototype.add = function(a, b, c, d) {
L.prototype.add = function(a, b, c, d) {
if (!d && !c && this.register[a]) {
return this.update(a, b);
}
if (b && (a || 0 === a) && (b = this.encode(b), d = b.length)) {
const p = this.depth, n = this.resolution, r = w(), u = w();
const n = this.depth, p = this.resolution, q = w(), t = w();
for (let m = 0; m < d; m++) {
let l = b[this.rtl ? d - 1 - m : m];
var e = l.length;
if (l && e >= this.minlength && (p || !r[l])) {
var f = d < n ? m : n / d * m | 0, g = "";
if (l && e >= this.minlength && (n || !q[l])) {
var f = M(p, d, m), g = "";
switch(this.tokenize) {
case "full":
if (3 < e) {
for (f = 0; f < e; f++) {
for (var h = e; h > f; h--) {
if (h - f >= this.minlength) {
var k = d + e < n ? m + f : n / (d + e) * (m + f) | 0;
var k = M(p, d, m, e, f);
g = l.substring(f, h);
this.push_index(r, g, k, a, c);
this.push_index(q, g, k, a, c);
}
}
}
@@ -318,24 +309,24 @@ M.prototype.add = function(a, b, c, d) {
case "reverse":
if (2 < e) {
for (h = e - 1; 0 < h; h--) {
g = l[h] + g, g.length >= this.minlength && this.push_index(r, g, d + e < n ? m + h : n / (d + e) * (m + h) | 0, a, c);
g = l[h] + g, g.length >= this.minlength && (k = M(p, d, m, e, h), this.push_index(q, g, k, a, c));
}
g = "";
}
case "forward":
if (1 < e) {
for (h = 0; h < e; h++) {
g += l[h], g.length >= this.minlength && this.push_index(r, g, f, a, c);
g += l[h], g.length >= this.minlength && this.push_index(q, g, f, a, c);
}
}
break;
default:
if (this.push_index(r, l, f, a, c), p && 1 < d && m < d - 1) {
for (e = this.resolution_ctx, g = w(), f = l, h = Math.min(p + 1, d - m), g[f] = 1, k = 1; k < h; k++) {
if (this.push_index(q, l, f, a, c), n && 1 < d && m < d - 1) {
for (e = this.resolution_ctx, g = w(), f = l, h = Math.min(n + 1, d - m), g[f] = 1, k = 1; k < h; k++) {
if ((l = b[this.rtl ? d - 1 - m - k : m + k]) && l.length >= this.minlength && !g[l]) {
g[l] = 1;
const q = this.bidirectional && l > f;
this.push_index(u, q ? f : l, h + d < e ? m + (k - 1) : e / (h + d) * (m + k) | 0, a, c, q ? l : f);
const u = M(e + (d / 2 > e ? 0 : 1), d, m, h - 1, k - 1), x = this.bidirectional && l > f;
this.push_index(t, x ? f : l, u, a, c, x ? l : f);
}
}
}
@@ -346,14 +337,17 @@ M.prototype.add = function(a, b, c, d) {
}
return this;
};
M.prototype.push_index = function(a, b, c, d, e, f) {
function M(a, b, c, d, e) {
return c && 1 < a ? b + (d || 0) <= a ? c + (e || 0) : (a - 1) / (b + (d || 0)) * (c + (e || 0)) + 1 | 0 : 0;
}
L.prototype.push_index = function(a, b, c, d, e, f) {
let g = f ? this.ctx : this.map;
if (!a[b] || f && !a[b][f]) {
this.optimize && (g = g[c]), f ? (a = a[b] || (a[b] = w()), a[f] = 1, g = g[f] || (g[f] = w())) : a[b] = 1, g = g[b] || (g[b] = []), this.optimize || (g = g[c] || (g[c] = [])), e && -1 !== g.indexOf(d) || (g[g.length] = d, this.fastupdate && (a = this.register[d] || (this.register[d] = []), a[a.length] = g));
}
};
M.prototype.search = function(a, b, c) {
A(a) ? (c = a, a = c.query) : A(b) && (c = b);
L.prototype.search = function(a, b, c) {
z(a) ? (c = a, a = c.query) : z(b) && (c = b);
let d = [], e;
let f, g = 0;
if (c) {
@@ -365,10 +359,10 @@ M.prototype.search = function(a, b, c) {
if (a && (a = this.encode(a), e = a.length, 1 < e)) {
c = w();
var k = [];
for (let n = 0, r = 0, u; n < e; n++) {
if ((u = a[n]) && u.length >= this.minlength && !c[u]) {
if (this.optimize || f || this.map[u]) {
k[r++] = u, c[u] = 1;
for (let p = 0, q = 0, t; p < e; p++) {
if ((t = a[p]) && t.length >= this.minlength && !c[t]) {
if (this.optimize || f || this.map[t]) {
k[q++] = t, c[t] = 1;
} else {
return d;
}
@@ -383,13 +377,13 @@ M.prototype.search = function(a, b, c) {
b || (b = 100);
h = this.depth && 1 < e && !1 !== h;
c = 0;
let p;
h ? (p = a[0], c = 1) : 1 < e && a.sort(aa);
for (let n, r; c < e; c++) {
r = a[c];
h ? (n = this.add_result(d, f, b, g, 2 === e, r, p), f && !1 === n && d.length || (p = r)) : n = this.add_result(d, f, b, g, 1 === e, r);
if (n) {
return n;
let n;
h ? (n = a[0], c = 1) : 1 < e && a.sort(aa);
for (let p, q; c < e; c++) {
q = a[c];
h ? (p = this.add_result(d, f, b, g, 2 === e, q, n), f && !1 === p && d.length || (n = q)) : p = this.add_result(d, f, b, g, 1 === e, q);
if (p) {
return p;
}
if (f && c === e - 1) {
k = d.length;
@@ -402,28 +396,28 @@ M.prototype.search = function(a, b, c) {
return d;
}
if (1 === k) {
return pa(d[0], b, g);
return qa(d[0], b, g);
}
}
}
return ja(d, b, g, f);
};
M.prototype.add_result = function(a, b, c, d, e, f, g) {
L.prototype.add_result = function(a, b, c, d, e, f, g) {
let h = [], k = g ? this.ctx : this.map;
this.optimize || (k = qa(k, f, g, this.bidirectional));
this.optimize || (k = ra(k, f, g, this.bidirectional));
if (k) {
let p = 0;
const n = Math.min(k.length, g ? this.resolution_ctx : this.resolution);
for (let r = 0, u = 0, m, l; r < n; r++) {
if (m = k[r]) {
if (this.optimize && (m = qa(m, f, g, this.bidirectional)), d && m && e && (l = m.length, l <= d ? (d -= l, m = null) : (m = m.slice(d), d = 0)), m && (h[p++] = m, e && (u += m.length, u >= c))) {
let n = 0;
const p = Math.min(k.length, g ? this.resolution_ctx : this.resolution);
for (let q = 0, t = 0, m, l; q < p; q++) {
if (m = k[q]) {
if (this.optimize && (m = ra(m, f, g, this.bidirectional)), d && m && e && (l = m.length, l <= d ? (d -= l, m = null) : (m = m.slice(d), d = 0)), m && (h[n++] = m, e && (t += m.length, t >= c))) {
break;
}
}
}
if (p) {
if (n) {
if (e) {
return pa(h, c, 0);
return qa(h, c, 0);
}
a[a.length] = h;
return;
@@ -431,21 +425,21 @@ M.prototype.add_result = function(a, b, c, d, e, f, g) {
}
return !b && h;
};
function pa(a, b, c) {
function qa(a, b, c) {
a = 1 === a.length ? a[0] : [].concat.apply([], a);
return c || a.length > b ? a.slice(c, c + b) : a;
}
function qa(a, b, c, d) {
function ra(a, b, c, d) {
c ? (d = d && b > c, a = (a = a[d ? b : c]) && a[d ? c : b]) : a = a[b];
return a;
}
M.prototype.contain = function(a) {
L.prototype.contain = function(a) {
return !!this.register[a];
};
M.prototype.update = function(a, b) {
L.prototype.update = function(a, b) {
return this.remove(a).add(a, b);
};
M.prototype.remove = function(a, b) {
L.prototype.remove = function(a, b) {
const c = this.register[a];
if (c) {
if (this.fastupdate) {
@@ -480,8 +474,8 @@ function N(a, b, c, d, e) {
}
return f;
}
M.prototype.searchCache = la;
M.prototype.export = function(a, b, c, d, e) {
L.prototype.searchCache = la;
L.prototype.export = function(a, b, c, d, e) {
let f, g;
switch(e || (e = 0)) {
case 0:
@@ -510,10 +504,10 @@ M.prototype.export = function(a, b, c, d, e) {
default:
return;
}
oa(a, b || this, c ? c + "." + f : f, d, e, g);
pa(a, b || this, c ? c + "." + f : f, d, e, g);
return !0;
};
M.prototype.import = function(a, b) {
L.prototype.import = function(a, b) {
if (b) {
switch(y(b) && (b = JSON.parse(b)), a) {
case "cfg":
@@ -531,8 +525,8 @@ M.prototype.import = function(a, b) {
}
}
};
ia(M.prototype);
function ra(a) {
ia(L.prototype);
function sa(a) {
a = a.data;
var b = self._index;
const c = a.args;
@@ -544,19 +538,19 @@ function ra(a) {
b = d.encode;
d.cache = !1;
b && 0 === b.indexOf("function") && (d.encode = Function("return " + b)());
a ? (Function("return " + a)()(self), self._index = new self.FlexSearch.Index(d), delete self.FlexSearch) : self._index = new M(d);
a ? (Function("return " + a)()(self), self._index = new self.FlexSearch.Index(d), delete self.FlexSearch) : self._index = new L(d);
break;
default:
a = a.id, b = b[d].apply(b, c), postMessage("search" === d ? {id:a, msg:b} : {id:a});
}
}
;let sa = 0;
;let ta = 0;
function P(a) {
var b;
a ? D(b = a.encode) && (a.encode = b.toString()) : a = {};
a ? C(b = a.encode) && (a.encode = b.toString()) : a = {};
(b = (self || window)._factory) && (b = b.toString());
const c = self.exports, d = this;
this.worker = ta(b, c, a.worker);
this.worker = ua(b, c, a.worker);
this.resolver = w();
if (this.worker) {
if (c) {
@@ -584,20 +578,20 @@ function Q(a) {
const b = this, c = [].slice.call(arguments);
var d = c[c.length - 1];
let e;
D(d) && (e = d, c.splice(c.length - 1, 1));
C(d) && (e = d, c.splice(c.length - 1, 1));
d = new Promise(function(f) {
setTimeout(function() {
b.resolver[++sa] = f;
b.worker.postMessage({task:a, id:sa, args:c});
b.resolver[++ta] = f;
b.worker.postMessage({task:a, id:ta, args:c});
});
});
return e ? (d.then(e), this) : d;
};
}
function ta(a, b, c) {
function ua(a, b, c) {
let d;
try {
d = b ? eval('new (require("worker_threads")["Worker"])("../dist/node/node.js")') : a ? new Worker(URL.createObjectURL(new Blob(["onmessage=" + ra.toString()], {type:"text/javascript"}))) : new Worker(y(c) ? c : "worker/worker.js", {type:"module"});
d = b ? eval('new (require("worker_threads")["Worker"])("../dist/node/node.js")') : a ? new Worker(URL.createObjectURL(new Blob(["onmessage=" + sa.toString()], {type:"text/javascript"}))) : new Worker(y(c) ? c : "worker/worker.js", {type:"module"});
} catch (e) {
}
return d;
@@ -612,12 +606,12 @@ function ta(a, b, c) {
this.marker = [];
this.register = w();
this.key = (c = b.key || b.id) && S(c, this.marker) || "id";
this.fastupdate = t(a.fastupdate, !0);
this.fastupdate = r(a.fastupdate, !0);
this.storetree = (c = b.store) && !0 !== c && [];
this.store = c && w();
this.tag = (c = b.tag) && S(c, this.marker);
this.tagindex = c && w();
this.cache = (c = a.cache) && new L(c);
this.cache = (c = a.cache) && new K(c);
a.cache = !1;
this.worker = a.worker;
this.async = !1;
@@ -625,7 +619,7 @@ function ta(a, b, c) {
let d = b.index || b.field || b;
y(d) && (d = [d]);
for (let e = 0, f, g; e < d.length; e++) {
f = d[e], y(f) || (g = f, f = f.field), g = A(g) ? Object.assign({}, a, g) : a, this.worker && (c[f] = new P(g), c[f].worker || (this.worker = !1)), this.worker || (c[f] = new M(g, this.register)), this.tree[e] = S(f, this.marker), this.field[e] = f;
f = d[e], y(f) || (g = f, f = f.field), g = z(g) ? Object.assign({}, a, g) : a, this.worker && (c[f] = new P(g), c[f].worker || (this.worker = !1)), this.worker || (c[f] = new L(g, this.register)), this.tree[e] = S(f, this.marker), this.field[e] = f;
}
if (this.storetree) {
for (a = b.store, y(a) && (a = [a]), b = 0; b < a.length; b++) {
@@ -695,7 +689,7 @@ function W(a, b, c, d, e, f, g, h) {
}
}
R.prototype.add = function(a, b, c) {
A(a) && (b = a, a = T(b, this.key));
z(a) && (b = a, a = T(b, this.key));
if (b && (a || 0 === a)) {
if (this.register[a]) {
return this.update(a, b);
@@ -735,7 +729,7 @@ R.prototype.update = function(a, b) {
return this.remove(a).add(a, b);
};
R.prototype.remove = function(a) {
A(a) && (a = T(a, this.key));
z(a) && (a = T(a, this.key));
if (this.register[a]) {
var b = this.fastupdate && !this.worker;
for (var c = 0; c < this.field.length && (this.index[this.field[c]].remove(a, b), !b); c++) {
@@ -751,55 +745,55 @@ R.prototype.remove = function(a) {
return this;
};
R.prototype.search = function(a, b, c, d) {
A(a) ? (c = a, a = c.query) : A(b) && (c = b, b = 0);
let e = [], f = [], g, h, k, p, n, r, u = 0;
z(a) ? (c = a, a = c.query) : z(b) && (c = b, b = 0);
let e = [], f = [], g, h, k, n, p, q, t = 0;
if (c) {
if (c.constructor === Array) {
k = c, c = null;
} else {
k = (g = c.pluck) || c.index || c.field || c;
p = c.tag;
n = c.tag;
h = this.store && c.enrich;
n = "and" === c.bool;
p = "and" === c.bool;
b = c.limit || 100;
r = c.offset || 0;
if (p && (y(p) && (p = [p]), !a)) {
for (let l = 0, q; l < p.length; l++) {
if (q = ua.call(this, p[l], b, r, h)) {
e[e.length] = q, u++;
q = c.offset || 0;
if (n && (y(n) && (n = [n]), !a)) {
for (let l = 0, u; l < n.length; l++) {
if (u = va.call(this, n[l], b, q, h)) {
e[e.length] = u, t++;
}
}
return u ? e : [];
return t ? e : [];
}
y(k) ? k = [k] : k.constructor === Array || (k = null);
}
}
k || (k = this.field);
n = n && (1 < k.length || p && 1 < p.length);
p = p && (1 < k.length || n && 1 < n.length);
const m = !d && (this.worker || this.async) && [];
for (let l = 0, q, x, z; l < k.length; l++) {
for (let l = 0, u, x, A; l < k.length; l++) {
let B;
x = k[l];
y(x) || (B = x, x = x.field);
if (m) {
m[l] = this.index[x].searchAsync(a, b, B || c);
} else {
z = (q = d ? d[l] : this.index[x].search(a, b, B || c)) && q.length;
if (p && z) {
const C = [];
let G = 0;
n && (C[0] = [q]);
for (let V = 0, ma, O; V < p.length; V++) {
if (ma = p[V], z = (O = this.tagindex[ma]) && O.length) {
G++, C[C.length] = n ? [O] : O;
A = (u = d ? d[l] : this.index[x].search(a, b, B || c)) && u.length;
if (n && A) {
const D = [];
let ma = 0;
p && (D[0] = [u]);
for (let V = 0, na, O; V < n.length; V++) {
if (na = n[V], A = (O = this.tagindex[na]) && O.length) {
ma++, D[D.length] = p ? [O] : O;
}
}
G && (q = n ? ja(C, b || 100, r || 0) : ka(q, C), z = q.length);
ma && (u = p ? ja(D, b || 100, q || 0) : ka(u, D), A = u.length);
}
if (z) {
f[u] = x, e[u++] = q;
if (A) {
f[t] = x, e[t++] = u;
} else {
if (n) {
if (p) {
return [];
}
}
@@ -807,39 +801,39 @@ R.prototype.search = function(a, b, c, d) {
}
if (m) {
const l = this;
return new Promise(function(q) {
return new Promise(function(u) {
Promise.all(m).then(function(x) {
q(l.search(a, b, c, x));
u(l.search(a, b, c, x));
});
});
}
if (!u) {
if (!t) {
return [];
}
if (g && (!h || !this.store)) {
return e[0];
}
for (let l = 0, q; l < f.length; l++) {
q = e[l];
q.length && h && (q = va.call(this, q));
for (let l = 0, u; l < f.length; l++) {
u = e[l];
u.length && h && (u = wa.call(this, u));
if (g) {
return q;
return u;
}
e[l] = {field:f[l], result:q};
e[l] = {field:f[l], result:u};
}
return e;
};
function ua(a, b, c, d) {
function va(a, b, c, d) {
let e = this.tagindex[a], f = e && e.length - c;
if (f && 0 < f) {
if (f > b || c) {
e = e.slice(c, c + b);
}
d && (e = va.call(this, e));
d && (e = wa.call(this, e));
return {tag:a, result:e};
}
}
function va(a) {
function wa(a) {
const b = Array(a.length);
for (let c = 0, d; c < a.length; c++) {
d = a[c], b[c] = {key:d, doc:this.store[d]};
@@ -880,7 +874,7 @@ R.prototype.export = function(a, b, c, d, e) {
default:
return;
}
oa(a, this, c, d, e, f);
pa(a, this, c, d, e, f);
}
};
R.prototype.import = function(a, b) {
@@ -908,26 +902,26 @@ R.prototype.import = function(a, b) {
}
};
ia(R.prototype);
var xa = {encode:wa, rtl:!1, tokenize:""};
const ya = /[\W_]+/, za = F("[\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5]"), Aa = F("[\u00e8\u00e9\u00ea\u00eb]"), Ba = F("[\u00ec\u00ed\u00ee\u00ef]"), Ca = F("[\u00f2\u00f3\u00f4\u00f5\u00f6\u0151]"), Da = F("[\u00f9\u00fa\u00fb\u00fc\u0171]"), Ea = F("[\u00fd\u0177\u00ff]"), Fa = F("\u00f1"), Ga = F("[\u00e7c]"), Ha = F("\u00df"), Ia = F(" & "), Ja = [za, "a", Aa, "e", Ba, "i", Ca, "o", Da, "u", Ea, "y", Fa, "n", Ga, "k", Ha, "s", Ia, " and "];
function wa(a) {
return this.pipeline(E(a).toLowerCase(), !a.normalize && Ja, ya, !1);
var ya = {encode:xa, rtl:!1, tokenize:""};
const za = /[\W_]+/, Aa = F("[\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5]"), Ba = F("[\u00e8\u00e9\u00ea\u00eb]"), Ca = F("[\u00ec\u00ed\u00ee\u00ef]"), Da = F("[\u00f2\u00f3\u00f4\u00f5\u00f6\u0151]"), Ea = F("[\u00f9\u00fa\u00fb\u00fc\u0171]"), Fa = F("[\u00fd\u0177\u00ff]"), Ga = F("\u00f1"), Ha = F("[\u00e7c]"), Ia = F("\u00df"), Ja = F(" & "), Ka = [Aa, "a", Ba, "e", Ca, "i", Da, "o", Ea, "u", Fa, "y", Ga, "n", Ha, "k", Ia, "s", Ja, " and "];
function xa(a) {
return this.pipeline(E(a).toLowerCase(), !a.normalize && Ka, za, !1);
}
;var La = {encode:Ka, rtl:!1, tokenize:"strict"};
const Ma = /[^a-z0-9]+/, Na = {b:"p", v:"f", w:"f", z:"s", x:"s", "\u00df":"s", d:"t", n:"m", c:"k", g:"k", j:"k", q:"k", i:"e", y:"e", u:"o"};
function Ka(a) {
a = wa.call(this, a).join(" ");
;var Ma = {encode:La, rtl:!1, tokenize:"strict"};
const Na = /[^a-z0-9]+/, Oa = {b:"p", v:"f", w:"f", z:"s", x:"s", "\u00df":"s", d:"t", n:"m", c:"k", g:"k", j:"k", q:"k", i:"e", y:"e", u:"o"};
function La(a) {
a = xa.call(this, a).join(" ");
const b = [];
if (a) {
const c = a.split(Ma), d = c.length;
const c = a.split(Na), d = c.length;
for (let e = 0, f, g = 0; e < d; e++) {
if ((a = c[e]) && (!this.filter || !this.filter[a])) {
f = a[0];
let h = Na[f] || f, k = h;
for (let p = 1; p < a.length; p++) {
f = a[p];
const n = Na[f] || f;
n && n !== k && (h += n, k = n);
let h = Oa[f] || f, k = h;
for (let n = 1; n < a.length; n++) {
f = a[n];
const p = Oa[f] || f;
p && p !== k && (h += p, k = p);
}
b[g++] = h;
}
@@ -935,27 +929,27 @@ function Ka(a) {
}
return b;
}
;var Pa = {encode:Oa, rtl:!1, tokenize:""};
const Qa = F("ae"), Ra = F("oe"), Sa = F("sh"), Ta = F("th"), Ua = F("ph"), Va = F("pf"), Wa = [Qa, "a", Ra, "o", Sa, "s", Ta, "t", Ua, "f", Va, "f", ];
function Oa(a, b) {
a && (a = Ka.call(this, a).join(" "), 2 < a.length && (a = H(a, Wa)), b || (1 < a.length && (a = I(a)), a && (a = a.split(" "))));
;var Qa = {encode:Pa, rtl:!1, tokenize:""};
const Ra = F("ae"), Sa = F("oe"), Ta = F("sh"), Ua = F("th"), Va = F("ph"), Wa = F("pf"), Xa = [Ra, "a", Sa, "o", Ta, "s", Ua, "t", Va, "f", Wa, "f", ];
function Pa(a, b) {
a && (a = La.call(this, a).join(" "), 2 < a.length && (a = G(a, Xa)), b || (1 < a.length && (a = H(a)), a && (a = a.split(" "))));
return a;
}
;var Ya = {encode:Xa, rtl:!1, tokenize:""};
const Za = F("(?!\\b)[aeiouy]");
function Xa(a) {
a && (a = Oa.call(this, a, !0), 1 < a.length && (a = a.replace(Za, "")), 1 < a.length && (a = I(a)), a && (a = a.split(" ")));
;var Za = {encode:Ya, rtl:!1, tokenize:""};
const $a = F("(?!\\b)[aeiouy]");
function Ya(a) {
a && (a = Pa.call(this, a, !0), 1 < a.length && (a = a.replace($a, "")), 1 < a.length && (a = H(a)), a && (a = a.split(" ")));
return a;
}
;J["latin:default"] = ea;
J["latin:simple"] = xa;
J["latin:balance"] = La;
J["latin:advanced"] = Pa;
J["latin:extra"] = Ya;
;I["latin:default"] = ea;
I["latin:simple"] = ya;
I["latin:balance"] = Ma;
I["latin:advanced"] = Qa;
I["latin:extra"] = Za;
const X = self;
let Y;
const Z = {Index:M, Document:R, Worker:P, registerCharset:function(a, b) {
J[a] = b;
const Z = {Index:L, Document:R, Worker:P, registerCharset:function(a, b) {
I[a] = b;
}, registerLanguage:function(a, b) {
ha[a] = b;
}};

View File

@@ -6,40 +6,40 @@
* https://github.com/nextapps-de/flexsearch
*/
(function(self){'use strict';var u;function aa(a){var b=0;return function(){return b<a.length?{done:!1,value:a[b++]}:{done:!0}}}var v="function"==typeof Object.defineProperties?Object.defineProperty:function(a,b,c){if(a==Array.prototype||a==Object.prototype)return a;a[b]=c.value;return a};
function ba(a){a=["object"==typeof globalThis&&globalThis,a,"object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof global&&global];for(var b=0;b<a.length;++b){var c=a[b];if(c&&c.Math==Math)return c}throw Error("Cannot find global object");}var w=ba(this);function x(a,b){if(b)a:{var c=w;a=a.split(".");for(var d=0;d<a.length-1;d++){var f=a[d];if(!(f in c))break a;c=c[f]}a=a[a.length-1];d=c[a];b=b(d);b!=d&&null!=b&&v(c,a,{configurable:!0,writable:!0,value:b})}}
x("Symbol",function(a){function b(g){if(this instanceof b)throw new TypeError("Symbol is not a constructor");return new c(d+(g||"")+"_"+f++,g)}function c(g,e){this.h=g;v(this,"description",{configurable:!0,writable:!0,value:e})}if(a)return a;c.prototype.toString=function(){return this.h};var d="jscomp_symbol_"+(1E9*Math.random()>>>0)+"_",f=0;return b});
x("Symbol.iterator",function(a){if(a)return a;a=Symbol("Symbol.iterator");for(var b="Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array".split(" "),c=0;c<b.length;c++){var d=w[b[c]];"function"===typeof d&&"function"!=typeof d.prototype[a]&&v(d.prototype,a,{configurable:!0,writable:!0,value:function(){return ca(aa(this))}})}return a});function ca(a){a={next:a};a[Symbol.iterator]=function(){return this};return a}
function da(a,b){a instanceof String&&(a+="");var c=0,d=!1,f={next:function(){if(!d&&c<a.length){var g=c++;return{value:b(g,a[g]),done:!1}}d=!0;return{done:!0,value:void 0}}};f[Symbol.iterator]=function(){return f};return f}x("Array.prototype.keys",function(a){return a?a:function(){return da(this,function(b){return b})}});function ea(a){var b="undefined"!=typeof Symbol&&Symbol.iterator&&a[Symbol.iterator];return b?b.call(a):{next:aa(a)}}
x("Promise",function(a){function b(e){this.l=0;this.m=void 0;this.h=[];this.N=!1;var h=this.A();try{e(h.resolve,h.reject)}catch(k){h.reject(k)}}function c(){this.h=null}function d(e){return e instanceof b?e:new b(function(h){h(e)})}if(a)return a;c.prototype.l=function(e){if(null==this.h){this.h=[];var h=this;this.m(function(){h.C()})}this.h.push(e)};var f=w.setTimeout;c.prototype.m=function(e){f(e,0)};c.prototype.C=function(){for(;this.h&&this.h.length;){var e=this.h;this.h=[];for(var h=0;h<e.length;++h){var k=
e[h];e[h]=null;try{k()}catch(l){this.A(l)}}}this.h=null};c.prototype.A=function(e){this.m(function(){throw e;})};b.prototype.A=function(){function e(l){return function(m){k||(k=!0,l.call(h,m))}}var h=this,k=!1;return{resolve:e(this.T),reject:e(this.C)}};b.prototype.T=function(e){if(e===this)this.C(new TypeError("A Promise cannot resolve to itself"));else if(e instanceof b)this.V(e);else{a:switch(typeof e){case "object":var h=null!=e;break a;case "function":h=!0;break a;default:h=!1}h?this.S(e):this.I(e)}};
function ba(a){a=["object"==typeof globalThis&&globalThis,a,"object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof global&&global];for(var b=0;b<a.length;++b){var c=a[b];if(c&&c.Math==Math)return c}throw Error("Cannot find global object");}var w=ba(this);function y(a,b){if(b)a:{var c=w;a=a.split(".");for(var d=0;d<a.length-1;d++){var f=a[d];if(!(f in c))break a;c=c[f]}a=a[a.length-1];d=c[a];b=b(d);b!=d&&null!=b&&v(c,a,{configurable:!0,writable:!0,value:b})}}
y("Symbol",function(a){function b(g){if(this instanceof b)throw new TypeError("Symbol is not a constructor");return new c(d+(g||"")+"_"+f++,g)}function c(g,e){this.h=g;v(this,"description",{configurable:!0,writable:!0,value:e})}if(a)return a;c.prototype.toString=function(){return this.h};var d="jscomp_symbol_"+(1E9*Math.random()>>>0)+"_",f=0;return b});
y("Symbol.iterator",function(a){if(a)return a;a=Symbol("Symbol.iterator");for(var b="Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array".split(" "),c=0;c<b.length;c++){var d=w[b[c]];"function"===typeof d&&"function"!=typeof d.prototype[a]&&v(d.prototype,a,{configurable:!0,writable:!0,value:function(){return ca(aa(this))}})}return a});function ca(a){a={next:a};a[Symbol.iterator]=function(){return this};return a}
function da(a,b){a instanceof String&&(a+="");var c=0,d=!1,f={next:function(){if(!d&&c<a.length){var g=c++;return{value:b(g,a[g]),done:!1}}d=!0;return{done:!0,value:void 0}}};f[Symbol.iterator]=function(){return f};return f}y("Array.prototype.keys",function(a){return a?a:function(){return da(this,function(b){return b})}});function ea(a){var b="undefined"!=typeof Symbol&&Symbol.iterator&&a[Symbol.iterator];return b?b.call(a):{next:aa(a)}}
y("Promise",function(a){function b(e){this.l=0;this.m=void 0;this.h=[];this.N=!1;var h=this.A();try{e(h.resolve,h.reject)}catch(k){h.reject(k)}}function c(){this.h=null}function d(e){return e instanceof b?e:new b(function(h){h(e)})}if(a)return a;c.prototype.l=function(e){if(null==this.h){this.h=[];var h=this;this.m(function(){h.C()})}this.h.push(e)};var f=w.setTimeout;c.prototype.m=function(e){f(e,0)};c.prototype.C=function(){for(;this.h&&this.h.length;){var e=this.h;this.h=[];for(var h=0;h<e.length;++h){var k=
e[h];e[h]=null;try{k()}catch(l){this.A(l)}}}this.h=null};c.prototype.A=function(e){this.m(function(){throw e;})};b.prototype.A=function(){function e(l){return function(n){k||(k=!0,l.call(h,n))}}var h=this,k=!1;return{resolve:e(this.T),reject:e(this.C)}};b.prototype.T=function(e){if(e===this)this.C(new TypeError("A Promise cannot resolve to itself"));else if(e instanceof b)this.V(e);else{a:switch(typeof e){case "object":var h=null!=e;break a;case "function":h=!0;break a;default:h=!1}h?this.S(e):this.I(e)}};
b.prototype.S=function(e){var h=void 0;try{h=e.then}catch(k){this.C(k);return}"function"==typeof h?this.W(h,e):this.I(e)};b.prototype.C=function(e){this.O(2,e)};b.prototype.I=function(e){this.O(1,e)};b.prototype.O=function(e,h){if(0!=this.l)throw Error("Cannot settle("+e+", "+h+"): Promise already settled in state"+this.l);this.l=e;this.m=h;2===this.l&&this.U();this.P()};b.prototype.U=function(){var e=this;f(function(){if(e.R()){var h=w.console;"undefined"!==typeof h&&h.error(e.m)}},1)};b.prototype.R=
function(){if(this.N)return!1;var e=w.CustomEvent,h=w.Event,k=w.dispatchEvent;if("undefined"===typeof k)return!0;"function"===typeof e?e=new e("unhandledrejection",{cancelable:!0}):"function"===typeof h?e=new h("unhandledrejection",{cancelable:!0}):(e=w.document.createEvent("CustomEvent"),e.initCustomEvent("unhandledrejection",!1,!0,e));e.promise=this;e.reason=this.m;return k(e)};b.prototype.P=function(){if(null!=this.h){for(var e=0;e<this.h.length;++e)g.l(this.h[e]);this.h=null}};var g=new c;b.prototype.V=
function(e){var h=this.A();e.K(h.resolve,h.reject)};b.prototype.W=function(e,h){var k=this.A();try{e.call(h,k.resolve,k.reject)}catch(l){k.reject(l)}};b.prototype.then=function(e,h){function k(n,q){return"function"==typeof n?function(r){try{l(n(r))}catch(t){m(t)}}:q}var l,m,p=new b(function(n,q){l=n;m=q});this.K(k(e,l),k(h,m));return p};b.prototype.catch=function(e){return this.then(void 0,e)};b.prototype.K=function(e,h){function k(){switch(l.l){case 1:e(l.m);break;case 2:h(l.m);break;default:throw Error("Unexpected state: "+
l.l);}}var l=this;null==this.h?g.l(k):this.h.push(k);this.N=!0};b.resolve=d;b.reject=function(e){return new b(function(h,k){k(e)})};b.race=function(e){return new b(function(h,k){for(var l=ea(e),m=l.next();!m.done;m=l.next())d(m.value).K(h,k)})};b.all=function(e){var h=ea(e),k=h.next();return k.done?d([]):new b(function(l,m){function p(r){return function(t){n[r]=t;q--;0==q&&l(n)}}var n=[],q=0;do n.push(void 0),q++,d(k.value).K(p(n.length-1),m),k=h.next();while(!k.done)})};return b});
var fa="function"==typeof Object.assign?Object.assign:function(a,b){for(var c=1;c<arguments.length;c++){var d=arguments[c];if(d)for(var f in d)Object.prototype.hasOwnProperty.call(d,f)&&(a[f]=d[f])}return a};x("Object.assign",function(a){return a||fa});function A(a){return"undefined"!==typeof a?a:!0}function ha(a){for(var b=Array(a),c=0;c<a;c++)b[c]=B();return b}function B(){return Object.create(null)}function ia(a,b){return b.length-a.length}function D(a){return"string"===typeof a}function E(a){return"object"===typeof a}function I(a){return"function"===typeof a};var ja=/[\u0300-\u036f]/g;function ka(a){a.normalize&&(a=a.normalize("NFD").replace(ja,""));return a}function la(a,b){for(var c=Object.keys(a),d=c.length,f=[],g="",e=0,h=0,k,l;h<d;h++)k=c[h],(l=a[k])?(f[e++]=J(b?"(?!\\b)"+k+"(\\b|_)":k),f[e++]=l):g+=(g?"|":"")+k;g&&(f[e++]=J(b?"(?!\\b)("+g+")(\\b|_)":"("+g+")"),f[e]="");return f}function K(a,b){for(var c=0,d=b.length;c<d&&(a=a.replace(b[c],b[c+1]),a);c+=2);return a}function J(a){return new RegExp(a,"g")}
function ma(a){for(var b="",c="",d=0,f=a.length,g=void 0;d<f;d++)(g=a[d])!==c&&(b+=c=g);return b};var oa={encode:na,F:!1,G:""},pa=/[\W_]+/;function na(a){return qa(this,ka(a).toLowerCase(),!1,pa)};var ra={},L={};function sa(a){M(a,"add");M(a,"append");M(a,"search");M(a,"update");M(a,"remove")}function M(a,b){a[b+"Async"]=function(){var c=this,d=arguments,f=d[d.length-1];if(I(f)){var g=f;delete d[d.length-1]}f=new Promise(function(e){setTimeout(function(){c.async=!0;var h=c[b].apply(c,d);c.async=!1;e(h)})});return g?(f.then(g),this):f}};function ta(a,b,c,d){for(var f=a.length,g=[],e,h,k,l,m=0;m<f;m++){for(var p=a[m],n=p.length,q=0,r=0,t;r<n;r++)(t=p[r])&&(q+=t.length);if(!h||q<h)h=q,k=p,l=m}k=1===k.length?k[0]:[].concat.apply([],k);d&&(d=[k],e=B());m=h=0;for(p=f-1;0<=p;p--)if(p!==l){m++;n=a[p];q=n.length;r=[];for(var z=t=0,y;z<k.length;z++){y=k[z];for(var C=void 0,G=0;G<q;G++){var H=n[G];if(H.length&&(C=-1!==H.indexOf(y))){if(m===f-1){if(c)c--;else if(g[h++]=y,h===b)return g;d&&(e[y]=1)}break}}C&&(r[t++]=y)}if(d)d[m]=r;else if(!t)return[];
k=r}if(d)for(a=d.length-1;0<=a;a--)if(k=(f=d[a])&&f.length)for(l=0;l<k;l++)if(m=f[l],!e[m])if(e[m]=1,c)c--;else if(g[h++]=m,h===b)return g;return g}function ua(a,b){for(var c=B(),d=B(),f=[],g=0;g<a.length;g++)c[a[g]]=1;for(a=0;a<b.length;a++){g=b[a];for(var e=0,h;e<g.length;e++)h=g[e],c[h]&&!d[h]&&(d[h]=1,f[f.length]=h)}return f};function N(a){this.l=!0!==a&&a;this.cache=B();this.h=[]}function va(a,b,c){E(a)&&(a=a.query);var d=this.cache.get(a);d||(d=this.search(a,b,c),this.cache.set(a,d));return d}N.prototype.set=function(a,b){if(!this.cache[a]){var c=this.h.length;c===this.l?delete this.cache[this.h[c-1]]:c++;for(--c;0<c;c--)this.h[c]=this.h[c-1];this.h[0]=a}this.cache[a]=b};N.prototype.get=function(a){var b=this.cache[a];if(this.l&&b&&(a=this.h.indexOf(a))){var c=this.h[a-1];this.h[a-1]=this.h[a];this.h[a]=c}return b};var wa={memory:{charset:"latin:extra",H:3,D:3,s:!1,B:"memory"},performance:{threshold:8,D:3,context:{depth:1,J:!0}},match:{charset:"latin:extra",G:"full",H:3},score:{charset:"latin:advanced",threshold:1,context:{depth:3,J:!0}},"default":{H:3,threshold:0,depth:3}};function xa(a,b,c,d,f,g){setTimeout(function(){var e=a(c,JSON.stringify(g));e&&e.then?e.then(function(){b.export(a,b,c,d,f+1)}):b.export(a,b,c,d,f+1)})};function O(a,b){if(!(this instanceof O))return new O(a);var c;if(a){D(a)?a=wa[a]:(c=a.preset)&&(a=Object.assign({},c[c],a));c=a.charset;var d=a.lang;D(c)&&(-1===c.indexOf(":")&&(c+=":default"),c=L[c]);D(d)&&(d=ra[d])}else a={};var f,g,e=a.context||{};this.encode=a.encode||c&&c.encode||na;this.register=b||B();this.H=f=a.resolution||9;this.G=b=c&&c.G||a.tokenize||"strict";this.depth="strict"===b&&e.depth;this.J=A(e.bidirectional);this.B=g=A(a.optimize);this.s=A(a.fastupdate);this.D=a.minlength||1;this.map=
g?ha(f):B();this.l=f=e.resolution||1;this.h=g?ha(f):B();this.F=c&&c.F||a.rtl;this.L=(b=a.matcher||d&&d.L)&&la(b,!1);this.M=(b=a.stemmer||d&&d.M)&&la(b,!0);if(c=b=a.filter||d&&d.filter){c=b;d=B();e=0;for(f=c.length;e<f;e++)d[c[e]]=1;c=d}this.filter=c;this.cache=(b=a.cache)&&new N(b)}
function qa(a,b,c,d){if(b&&(c&&(b=K(b,c)),a.L&&(b=K(b,a.L)),a.M&&1<b.length&&(b=K(b,a.M)),d||""===d)){b=b.split(d);if(a.filter){a=a.filter;c=b.length;d=[];for(var f=0,g=0;f<c;f++){var e=b[f];e&&!a[e]&&(d[g++]=e)}b=d}return b}return b}u=O.prototype;u.append=function(a,b){return this.add(a,b,!0)};
u.add=function(a,b,c,d){if(!d&&!c&&this.register[a])return this.update(a,b);if(b&&(a||0===a)&&(b=this.encode(b),d=b.length)){for(var f=this.depth,g=this.H,e=B(),h=B(),k=0;k<d;k++){var l=b[this.F?d-1-k:k],m=l.length;if(l&&m>=this.D&&(f||!e[l])){var p=d<g?k:g/d*k|0,n="";switch(this.G){case "full":if(3<m){for(p=0;p<m;p++)for(var q=m;q>p;q--)if(q-p>=this.D){var r=d+m<g?k+p:g/(d+m)*(k+p)|0;n=l.substring(p,q);P(this,e,n,r,a,c)}break}case "reverse":if(2<m){for(q=m-1;0<q;q--)n=l[q]+n,n.length>=this.D&&P(this,
e,n,d+m<g?k+q:g/(d+m)*(k+q)|0,a,c);n=""}case "forward":if(1<m)for(q=0;q<m;q++)n+=l[q],n.length>=this.D&&P(this,e,n,p,a,c);break;default:if(P(this,e,l,p,a,c),f&&1<d&&k<d-1)for(m=this.l,n=B(),p=l,q=Math.min(f+1,d-k),r=n[p]=1;r<q;r++)if((l=b[this.F?d-1-k-r:k+r])&&l.length>=this.D&&!n[l]){n[l]=1;var t=this.J&&l>p;P(this,h,t?p:l,q+d<m?k+(r-1):m/(q+d)*(k+r)|0,a,c,t?l:p)}}}}this.s||(this.register[a]=1)}return this};
function P(a,b,c,d,f,g,e){var h=e?a.h:a.map;if(!b[c]||e&&!b[c][e])a.B&&(h=h[d]),e?(b=b[c]||(b[c]=B()),b[e]=1,h=h[e]||(h[e]=B())):b[c]=1,h=h[c]||(h[c]=[]),a.B||(h=h[d]||(h[d]=[])),g&&-1!==h.indexOf(f)||(h[h.length]=f,a.s&&(a=a.register[f]||(a.register[f]=[]),a[a.length]=h))}
u.search=function(a,b,c){E(a)?(c=a,a=c.query):E(b)&&(c=b);var d=[],f=0;if(c){b=c.limit;f=c.offset||0;var g=c.context;var e=c.suggest}if(a){a=this.encode(a);var h=a.length;if(1<h){c=B();for(var k=[],l=0,m=0,p;l<h;l++)if((p=a[l])&&p.length>=this.D&&!c[p])if(this.B||e||this.map[p])k[m++]=p,c[p]=1;else return d;a=k;h=a.length}}if(!h)return d;b||(b=100);g=this.depth&&1<h&&!1!==g;c=0;if(g){var n=a[0];c=1}else 1<h&&a.sort(ia);for(;c<h;c++){l=a[c];g?(k=ya(this,d,e,b,f,2===h,l,n),e&&!1===k&&d.length||(n=l)):
function(e){var h=this.A();e.K(h.resolve,h.reject)};b.prototype.W=function(e,h){var k=this.A();try{e.call(h,k.resolve,k.reject)}catch(l){k.reject(l)}};b.prototype.then=function(e,h){function k(m,q){return"function"==typeof m?function(r){try{l(m(r))}catch(t){n(t)}}:q}var l,n,p=new b(function(m,q){l=m;n=q});this.K(k(e,l),k(h,n));return p};b.prototype.catch=function(e){return this.then(void 0,e)};b.prototype.K=function(e,h){function k(){switch(l.l){case 1:e(l.m);break;case 2:h(l.m);break;default:throw Error("Unexpected state: "+
l.l);}}var l=this;null==this.h?g.l(k):this.h.push(k);this.N=!0};b.resolve=d;b.reject=function(e){return new b(function(h,k){k(e)})};b.race=function(e){return new b(function(h,k){for(var l=ea(e),n=l.next();!n.done;n=l.next())d(n.value).K(h,k)})};b.all=function(e){var h=ea(e),k=h.next();return k.done?d([]):new b(function(l,n){function p(r){return function(t){m[r]=t;q--;0==q&&l(m)}}var m=[],q=0;do m.push(void 0),q++,d(k.value).K(p(m.length-1),n),k=h.next();while(!k.done)})};return b});
var fa="function"==typeof Object.assign?Object.assign:function(a,b){for(var c=1;c<arguments.length;c++){var d=arguments[c];if(d)for(var f in d)Object.prototype.hasOwnProperty.call(d,f)&&(a[f]=d[f])}return a};y("Object.assign",function(a){return a||fa});function B(a){return"undefined"!==typeof a?a:!0}function ha(a){for(var b=Array(a),c=0;c<a;c++)b[c]=C();return b}function C(){return Object.create(null)}function ia(a,b){return b.length-a.length}function E(a){return"string"===typeof a}function F(a){return"object"===typeof a}function H(a){return"function"===typeof a};var ja=/[\u0300-\u036f]/g;function ka(a){a.normalize&&(a=a.normalize("NFD").replace(ja,""));return a}function la(a,b){for(var c=Object.keys(a),d=c.length,f=[],g="",e=0,h=0,k,l;h<d;h++)k=c[h],(l=a[k])?(f[e++]=I(b?"(?!\\b)"+k+"(\\b|_)":k),f[e++]=l):g+=(g?"|":"")+k;g&&(f[e++]=I(b?"(?!\\b)("+g+")(\\b|_)":"("+g+")"),f[e]="");return f}function J(a,b){for(var c=0,d=b.length;c<d&&(a=a.replace(b[c],b[c+1]),a);c+=2);return a}function I(a){return new RegExp(a,"g")}
function ma(a){for(var b="",c="",d=0,f=a.length,g=void 0;d<f;d++)(g=a[d])!==c&&(b+=c=g);return b};var oa={encode:na,F:!1,G:""},pa=/[\W_]+/;function na(a){return qa(this,ka(a).toLowerCase(),!1,pa)};var ra={},K={};function sa(a){L(a,"add");L(a,"append");L(a,"search");L(a,"update");L(a,"remove")}function L(a,b){a[b+"Async"]=function(){var c=this,d=arguments,f=d[d.length-1];if(H(f)){var g=f;delete d[d.length-1]}f=new Promise(function(e){setTimeout(function(){c.async=!0;var h=c[b].apply(c,d);c.async=!1;e(h)})});return g?(f.then(g),this):f}};function ta(a,b,c,d){var f=a.length,g=[],e,h=0;d&&(d=[]);for(--f;0<=f;f--){for(var k=a[f],l=k.length,n=C(),p=!A,m=0;m<l;m++){var q=k[m],r=q.length;if(r)for(var t=0,z=void 0,x;t<r;t++)if(x=q[t],A){if(A[x]){if(!f)if(c)c--;else if(g[h++]=x,h===b)return g;if(f||d)n[x]=1;p=!0}if(d&&(e[x]=(z=e[x])?z++:z=1,z<l)){var D=d[z-1]||(d[z-1]=[]);D[D.length]=x}}else n[x]=1}if(d)A||(e=n);else if(!p)return[];var A=n}if(d)for(a=d.length-1;0<=a;a--)for(e=d[a],f=e.length,k=0;k<f;k++)if(l=e[k],!A[l]){if(c)c--;else if(g[h++]=
l,h===b)return g;A[l]=1}return g}function ua(a,b){for(var c=C(),d=C(),f=[],g=0;g<a.length;g++)c[a[g]]=1;for(a=0;a<b.length;a++){g=b[a];for(var e=0,h;e<g.length;e++)h=g[e],c[h]&&!d[h]&&(d[h]=1,f[f.length]=h)}return f};function M(a){this.l=!0!==a&&a;this.cache=C();this.h=[]}function va(a,b,c){F(a)&&(a=a.query);var d=this.cache.get(a);d||(d=this.search(a,b,c),this.cache.set(a,d));return d}M.prototype.set=function(a,b){if(!this.cache[a]){var c=this.h.length;c===this.l?delete this.cache[this.h[c-1]]:c++;for(--c;0<c;c--)this.h[c]=this.h[c-1];this.h[0]=a}this.cache[a]=b};M.prototype.get=function(a){var b=this.cache[a];if(this.l&&b&&(a=this.h.indexOf(a))){var c=this.h[a-1];this.h[a-1]=this.h[a];this.h[a]=c}return b};var wa={memory:{charset:"latin:extra",H:3,D:3,s:!1,B:"memory"},performance:{threshold:8,D:3,context:{depth:1,J:!0}},match:{charset:"latin:extra",G:"full",H:3},score:{charset:"latin:advanced",threshold:1,context:{depth:3,J:!0}},"default":{H:3,threshold:0,depth:3}};function xa(a,b,c,d,f,g){setTimeout(function(){var e=a(c,JSON.stringify(g));e&&e.then?e.then(function(){b.export(a,b,c,d,f+1)}):b.export(a,b,c,d,f+1)})};function N(a,b){if(!(this instanceof N))return new N(a);var c;if(a){E(a)?a=wa[a]:(c=a.preset)&&(a=Object.assign({},c[c],a));c=a.charset;var d=a.lang;E(c)&&(-1===c.indexOf(":")&&(c+=":default"),c=K[c]);E(d)&&(d=ra[d])}else a={};var f,g,e=a.context||{};this.encode=a.encode||c&&c.encode||na;this.register=b||C();this.H=f=a.resolution||9;this.G=b=c&&c.G||a.tokenize||"strict";this.depth="strict"===b&&e.depth;this.J=B(e.bidirectional);this.B=g=B(a.optimize);this.s=B(a.fastupdate);this.D=a.minlength||1;this.map=
g?ha(f):C();this.l=f=e.resolution||1;this.h=g?ha(f):C();this.F=c&&c.F||a.rtl;this.L=(b=a.matcher||d&&d.L)&&la(b,!1);this.M=(b=a.stemmer||d&&d.M)&&la(b,!0);if(c=b=a.filter||d&&d.filter){c=b;d=C();e=0;for(f=c.length;e<f;e++)d[c[e]]=1;c=d}this.filter=c;this.cache=(b=a.cache)&&new M(b)}
function qa(a,b,c,d){if(b&&(c&&(b=J(b,c)),a.L&&(b=J(b,a.L)),a.M&&1<b.length&&(b=J(b,a.M)),d||""===d)){b=b.split(d);if(a.filter){a=a.filter;c=b.length;d=[];for(var f=0,g=0;f<c;f++){var e=b[f];e&&!a[e]&&(d[g++]=e)}b=d}return b}return b}u=N.prototype;u.append=function(a,b){return this.add(a,b,!0)};
u.add=function(a,b,c,d){if(!d&&!c&&this.register[a])return this.update(a,b);if(b&&(a||0===a)&&(b=this.encode(b),d=b.length)){for(var f=this.depth,g=this.H,e=C(),h=C(),k=0;k<d;k++){var l=b[this.F?d-1-k:k],n=l.length;if(l&&n>=this.D&&(f||!e[l])){var p=O(g,d,k),m="";switch(this.G){case "full":if(3<n){for(p=0;p<n;p++)for(var q=n;q>p;q--)if(q-p>=this.D){var r=O(g,d,k,n,p);m=l.substring(p,q);P(this,e,m,r,a,c)}break}case "reverse":if(2<n){for(q=n-1;0<q;q--)m=l[q]+m,m.length>=this.D&&P(this,e,m,O(g,d,k,n,
q),a,c);m=""}case "forward":if(1<n)for(q=0;q<n;q++)m+=l[q],m.length>=this.D&&P(this,e,m,p,a,c);break;default:if(P(this,e,l,p,a,c),f&&1<d&&k<d-1)for(n=this.l,m=C(),p=l,q=Math.min(f+1,d-k),r=m[p]=1;r<q;r++)if((l=b[this.F?d-1-k-r:k+r])&&l.length>=this.D&&!m[l]){m[l]=1;var t=this.J&&l>p;P(this,h,t?p:l,O(n+(d/2>n?0:1),d,k,q-1,r-1),a,c,t?l:p)}}}}this.s||(this.register[a]=1)}return this};function O(a,b,c,d,f){return c&&1<a?b+(d||0)<=a?c+(f||0):(a-1)/(b+(d||0))*(c+(f||0))+1|0:0}
function P(a,b,c,d,f,g,e){var h=e?a.h:a.map;if(!b[c]||e&&!b[c][e])a.B&&(h=h[d]),e?(b=b[c]||(b[c]=C()),b[e]=1,h=h[e]||(h[e]=C())):b[c]=1,h=h[c]||(h[c]=[]),a.B||(h=h[d]||(h[d]=[])),g&&-1!==h.indexOf(f)||(h[h.length]=f,a.s&&(a=a.register[f]||(a.register[f]=[]),a[a.length]=h))}
u.search=function(a,b,c){F(a)?(c=a,a=c.query):F(b)&&(c=b);var d=[],f=0;if(c){b=c.limit;f=c.offset||0;var g=c.context;var e=c.suggest}if(a){a=this.encode(a);var h=a.length;if(1<h){c=C();for(var k=[],l=0,n=0,p;l<h;l++)if((p=a[l])&&p.length>=this.D&&!c[p])if(this.B||e||this.map[p])k[n++]=p,c[p]=1;else return d;a=k;h=a.length}}if(!h)return d;b||(b=100);g=this.depth&&1<h&&!1!==g;c=0;if(g){var m=a[0];c=1}else 1<h&&a.sort(ia);for(;c<h;c++){l=a[c];g?(k=ya(this,d,e,b,f,2===h,l,m),e&&!1===k&&d.length||(m=l)):
k=ya(this,d,e,b,f,1===h,l);if(k)return k;if(e&&c===h-1){k=d.length;if(!k){if(g){g=0;c=-1;continue}return d}if(1===k)return za(d[0],b,f)}}return ta(d,b,f,e)};
function ya(a,b,c,d,f,g,e,h){var k=[],l=h?a.h:a.map;a.B||(l=Aa(l,e,h,a.J));if(l){for(var m=0,p=Math.min(l.length,h?a.l:a.H),n=0,q=0,r,t;n<p;n++)if(r=l[n])if(a.B&&(r=Aa(r,e,h,a.J)),f&&r&&g&&(t=r.length,t<=f?(f-=t,r=null):(r=r.slice(f),f=0)),r&&(k[m++]=r,g&&(q+=r.length,q>=d)))break;if(m){if(g)return za(k,d,0);b[b.length]=k;return}}return!c&&k}function za(a,b,c){a=1===a.length?a[0]:[].concat.apply([],a);return c||a.length>b?a.slice(c,c+b):a}
function ya(a,b,c,d,f,g,e,h){var k=[],l=h?a.h:a.map;a.B||(l=Aa(l,e,h,a.J));if(l){for(var n=0,p=Math.min(l.length,h?a.l:a.H),m=0,q=0,r,t;m<p;m++)if(r=l[m])if(a.B&&(r=Aa(r,e,h,a.J)),f&&r&&g&&(t=r.length,t<=f?(f-=t,r=null):(r=r.slice(f),f=0)),r&&(k[n++]=r,g&&(q+=r.length,q>=d)))break;if(n){if(g)return za(k,d,0);b[b.length]=k;return}}return!c&&k}function za(a,b,c){a=1===a.length?a[0]:[].concat.apply([],a);return c||a.length>b?a.slice(c,c+b):a}
function Aa(a,b,c,d){c?(d=d&&b>c,a=(a=a[d?b:c])&&a[d?c:b]):a=a[b];return a}u.contain=function(a){return!!this.register[a]};u.update=function(a,b){return this.remove(a).add(a,b)};
u.remove=function(a,b){var c=this.register[a];if(c){if(this.s)for(var d=0,f;d<c.length;d++)f=c[d],f.splice(f.indexOf(a),1);else Q(this.map,a,this.H,this.B),this.depth&&Q(this.h,a,this.l,this.B);b||delete this.register[a];if(this.cache)for(b=this.cache,c=0;c<b.h.length;c++)f=b.h[c],d=b.cache[f],-1!==d.indexOf(a)&&(b.h.splice(c--,1),delete b.cache[f])}return this};
function Q(a,b,c,d,f){var g=0;if(a.constructor===Array)if(f)b=a.indexOf(b),-1!==b?1<a.length&&(a.splice(b,1),g++):g++;else{f=Math.min(a.length,c);for(var e=0,h;e<f;e++)if(h=a[e])g=Q(h,b,c,d,f),d||g||delete a[e]}else for(e in a)(g=Q(a[e],b,c,d,f))||delete a[e];return g}u.searchCache=va;
u.export=function(a,b,c,d,f){switch(f||(f=0)){case 0:var g="reg";if(this.s){var e=B();for(var h in this.register)e[h]=1}else e=this.register;break;case 1:g="cfg";e={doc:0,opt:this.B?1:0};break;case 2:g="map";e=this.map;break;case 3:g="ctx";e=this.h;break;default:return}xa(a,b||this,c?c+"."+g:g,d,f,e);return!0};u.import=function(a,b){if(b)switch(D(b)&&(b=JSON.parse(b)),a){case "cfg":this.B=!!b.opt;break;case "reg":this.s=!1;this.register=b;break;case "map":this.map=b;break;case "ctx":this.h=b}};sa(O.prototype);function Ba(a){a=a.data;var b=self._index,c=a.args,d=a.task;switch(d){case "init":d=a.options||{};a=a.factory;b=d.encode;d.cache=!1;b&&0===b.indexOf("function")&&(d.encode=Function("return "+b)());a?(Function("return "+a)()(self),self._index=new self.FlexSearch.Index(d),delete self.FlexSearch):self._index=new O(d);break;default:a=a.id,b=b[d].apply(b,c),postMessage("search"===d?{id:a,msg:b}:{id:a})}};var Ca=0;function R(a){var b;a?I(b=a.encode)&&(a.encode=b.toString()):a={};(b=(self||window)._factory)&&(b=b.toString());var c=self.exports,d=this;this.o=Da(b,c,a.worker);this.h=B();if(this.o){if(c)this.o.on("message",function(f){d.h[f.id](f.msg);delete d.h[f.id]});else this.o.onmessage=function(f){f=f.data;d.h[f.id](f.msg);delete d.h[f.id]};this.o.postMessage({task:"init",factory:b,options:a})}}S("add");S("append");S("search");S("update");S("remove");
function S(a){R.prototype[a]=R.prototype[a+"Async"]=function(){var b=this,c=[].slice.call(arguments),d=c[c.length-1];if(I(d)){var f=d;c.splice(c.length-1,1)}d=new Promise(function(g){setTimeout(function(){b.h[++Ca]=g;b.o.postMessage({task:a,id:Ca,args:c})})});return f?(d.then(f),this):d}}
function Da(a,b,c){try{var d=b?eval('new (require("worker_threads")["Worker"])("../dist/node/node.js")'):a?new Worker(URL.createObjectURL(new Blob(["onmessage="+Ba.toString()],{type:"text/javascript"}))):new Worker(D(c)?c:"worker/worker.js",{type:"module"})}catch(f){}return d};function T(a){if(!(this instanceof T))return new T(a);var b=a.document||a.doc||a,c;this.I=[];this.h=[];this.m=[];this.register=B();this.key=(c=b.key||b.id)&&U(c,this.m)||"id";this.s=A(a.fastupdate);this.A=(c=b.store)&&!0!==c&&[];this.store=c&&B();this.C=(c=b.tag)&&U(c,this.m);this.l=c&&B();this.cache=(c=a.cache)&&new N(c);a.cache=!1;this.o=a.worker;this.async=!1;c=B();var d=b.index||b.field||b;D(d)&&(d=[d]);for(var f=0,g,e=void 0;f<d.length;f++)g=d[f],D(g)||(e=g,g=g.field),e=E(e)?Object.assign({},
a,e):a,this.o&&(c[g]=new R(e),c[g].o||(this.o=!1)),this.o||(c[g]=new O(e,this.register)),this.I[f]=U(g,this.m),this.h[f]=g;if(this.A)for(a=b.store,D(a)&&(a=[a]),b=0;b<a.length;b++)this.A[b]=U(a[b],this.m);this.index=c}function U(a,b){for(var c=a.split(":"),d=0,f=0;f<c.length;f++)a=c[f],0<=a.indexOf("[]")&&(a=a.substring(0,a.length-2))&&(b[d]=!0),a&&(c[d++]=a);d<c.length&&(c.length=d);return 1<d?c:c[0]}function V(a,b){if(D(b))a=a[b];else for(var c=0;a&&c<b.length;c++)a=a[b[c]];return a}
function W(a,b,c,d,f){a=a[f];if(d===c.length-1)b[f]=a;else if(a)if(a.constructor===Array)for(b=b[f]=Array(a.length),f=0;f<a.length;f++)W(a,b,c,d,f);else b=b[f]||(b[f]=B()),f=c[++d],W(a,b,c,d,f)}function X(a,b,c,d,f,g,e,h){a=a[e];if(d===b.length-1){if(a.constructor===Array){if(c[d]){for(b=0;b<a.length;b++)f.add(g,a[b],!0,!0);return}a=a.join(" ")}f.add(g,a,h,!0)}else if(a)if(a.constructor===Array)for(e=0;e<a.length;e++)X(a,b,c,d,f,g,e,h);else e=b[++d],X(a,b,c,d,f,g,e,h)}u=T.prototype;
u.add=function(a,b,c){E(a)&&(b=a,a=V(b,this.key));if(b&&(a||0===a)){if(this.register[a])return this.update(a,b);for(var d=0,f,g;d<this.h.length;d++)g=this.h[d],f=this.I[d],D(f)&&(f=[f]),X(b,f,this.m,0,this.index[g],a,f[0],c);if(this.C){d=V(b,this.C);f=B();D(d)&&(d=[d]);g=0;for(var e;g<d.length;g++)if(e=d[g],!f[e]&&(f[e]=1,e=this.l[e]||(this.l[e]=[]),!c||-1===e.indexOf(a)))if(e[e.length]=a,this.s){var h=this.register[a]||(this.register[a]=[]);h[h.length]=e}}if(this.store){if(this.A){var k=B();for(c=
0;c<this.A.length;c++)d=this.A[c],D(d)?k[d]=b[d]:W(b,k,d,0,d[0])}this.store[a]=k||b}}return this};u.append=function(a,b){return this.add(a,b,!0)};u.update=function(a,b){return this.remove(a).add(a,b)};
u.remove=function(a){E(a)&&(a=V(a,this.key));if(this.register[a]){for(var b=this.s&&!this.o,c=0;c<this.h.length&&(this.index[this.h[c]].remove(a,b),!b);c++);if(this.C&&!b)for(var d in this.l)b=this.l[d],c=b.indexOf(a),-1!==c&&(1<b.length?b.splice(c,1):delete this.l[d]);this.store&&delete this.store[a];delete this.register[a]}return this};
u.search=function(a,b,c,d){E(a)?(c=a,a=c.query):E(b)&&(c=b,b=0);var f=[],g=[],e,h=0;if(c)if(c.constructor===Array){var k=c;c=null}else{k=(e=c.pluck)||c.index||c.field||c;var l=c.tag;var m=this.store&&c.enrich;var p="and"===c.bool;b=c.limit||100;var n=c.offset||0;if(l&&(D(l)&&(l=[l]),!a)){g=0;for(e=void 0;g<l.length;g++)if(e=Ea.call(this,l[g],b,n,m))f[f.length]=e,h++;return h?f:[]}D(k)?k=[k]:k.constructor===Array||(k=null)}k||(k=this.h);p=p&&(1<k.length||l&&1<l.length);for(var q=!d&&(this.o||this.async)&&
[],r=0,t=void 0,z=void 0,y=void 0;r<k.length;r++)if(y=void 0,z=k[r],D(z)||(y=z,z=z.field),q)q[r]=this.index[z].searchAsync(a,b,y||c);else{d?t=d[r]:t=this.index[z].search(a,b,y||c);y=t&&t.length;if(l&&y){var C=[],G=0;p&&(C[0]=[t]);var H=0,F=void 0;for(F=void 0;H<l.length;H++)if(F=l[H],y=(F=this.l[F])&&F.length)G++,C[C.length]=p?[F]:F;G&&(t=p?ta(C,b||100,n||0):ua(t,C),y=t.length)}if(y)g[h]=z,f[h++]=t;else if(p)return[]}if(q){var La=this;return new Promise(function(Ma){Promise.all(q).then(function(Na){Ma(La.search(a,
b,c,Na))})})}if(!h)return[];if(e&&(!m||!this.store))return f[0];l=0;for(n=void 0;l<g.length;l++){n=f[l];n.length&&m&&(n=Fa.call(this,n));if(e)return n;f[l]={field:g[l],result:n}}return f};function Ea(a,b,c,d){var f=this.l[a],g=f&&f.length-c;if(g&&0<g){if(g>b||c)f=f.slice(c,c+b);d&&(f=Fa.call(this,f));return{tag:a,result:f}}}function Fa(a){for(var b=Array(a.length),c=0,d;c<a.length;c++)d=a[c],b[c]={key:d,doc:this.store[d]};return b}u.contain=function(a){return!!this.register[a]};u.get=function(a){return this.store[a]};
u.export=function(a,b,c,d,f){switch(f||(f=0)){case 0:var g="reg";if(this.s){var e=C();for(var h in this.register)e[h]=1}else e=this.register;break;case 1:g="cfg";e={doc:0,opt:this.B?1:0};break;case 2:g="map";e=this.map;break;case 3:g="ctx";e=this.h;break;default:return}xa(a,b||this,c?c+"."+g:g,d,f,e);return!0};u.import=function(a,b){if(b)switch(E(b)&&(b=JSON.parse(b)),a){case "cfg":this.B=!!b.opt;break;case "reg":this.s=!1;this.register=b;break;case "map":this.map=b;break;case "ctx":this.h=b}};sa(N.prototype);function Ba(a){a=a.data;var b=self._index,c=a.args,d=a.task;switch(d){case "init":d=a.options||{};a=a.factory;b=d.encode;d.cache=!1;b&&0===b.indexOf("function")&&(d.encode=Function("return "+b)());a?(Function("return "+a)()(self),self._index=new self.FlexSearch.Index(d),delete self.FlexSearch):self._index=new N(d);break;default:a=a.id,b=b[d].apply(b,c),postMessage("search"===d?{id:a,msg:b}:{id:a})}};var Ca=0;function R(a){var b;a?H(b=a.encode)&&(a.encode=b.toString()):a={};(b=(self||window)._factory)&&(b=b.toString());var c=self.exports,d=this;this.o=Da(b,c,a.worker);this.h=C();if(this.o){if(c)this.o.on("message",function(f){d.h[f.id](f.msg);delete d.h[f.id]});else this.o.onmessage=function(f){f=f.data;d.h[f.id](f.msg);delete d.h[f.id]};this.o.postMessage({task:"init",factory:b,options:a})}}S("add");S("append");S("search");S("update");S("remove");
function S(a){R.prototype[a]=R.prototype[a+"Async"]=function(){var b=this,c=[].slice.call(arguments),d=c[c.length-1];if(H(d)){var f=d;c.splice(c.length-1,1)}d=new Promise(function(g){setTimeout(function(){b.h[++Ca]=g;b.o.postMessage({task:a,id:Ca,args:c})})});return f?(d.then(f),this):d}}
function Da(a,b,c){try{var d=b?eval('new (require("worker_threads")["Worker"])("../dist/node/node.js")'):a?new Worker(URL.createObjectURL(new Blob(["onmessage="+Ba.toString()],{type:"text/javascript"}))):new Worker(E(c)?c:"worker/worker.js",{type:"module"})}catch(f){}return d};function T(a){if(!(this instanceof T))return new T(a);var b=a.document||a.doc||a,c;this.I=[];this.h=[];this.m=[];this.register=C();this.key=(c=b.key||b.id)&&U(c,this.m)||"id";this.s=B(a.fastupdate);this.A=(c=b.store)&&!0!==c&&[];this.store=c&&C();this.C=(c=b.tag)&&U(c,this.m);this.l=c&&C();this.cache=(c=a.cache)&&new M(c);a.cache=!1;this.o=a.worker;this.async=!1;c=C();var d=b.index||b.field||b;E(d)&&(d=[d]);for(var f=0,g,e=void 0;f<d.length;f++)g=d[f],E(g)||(e=g,g=g.field),e=F(e)?Object.assign({},
a,e):a,this.o&&(c[g]=new R(e),c[g].o||(this.o=!1)),this.o||(c[g]=new N(e,this.register)),this.I[f]=U(g,this.m),this.h[f]=g;if(this.A)for(a=b.store,E(a)&&(a=[a]),b=0;b<a.length;b++)this.A[b]=U(a[b],this.m);this.index=c}function U(a,b){for(var c=a.split(":"),d=0,f=0;f<c.length;f++)a=c[f],0<=a.indexOf("[]")&&(a=a.substring(0,a.length-2))&&(b[d]=!0),a&&(c[d++]=a);d<c.length&&(c.length=d);return 1<d?c:c[0]}function V(a,b){if(E(b))a=a[b];else for(var c=0;a&&c<b.length;c++)a=a[b[c]];return a}
function W(a,b,c,d,f){a=a[f];if(d===c.length-1)b[f]=a;else if(a)if(a.constructor===Array)for(b=b[f]=Array(a.length),f=0;f<a.length;f++)W(a,b,c,d,f);else b=b[f]||(b[f]=C()),f=c[++d],W(a,b,c,d,f)}function X(a,b,c,d,f,g,e,h){a=a[e];if(d===b.length-1){if(a.constructor===Array){if(c[d]){for(b=0;b<a.length;b++)f.add(g,a[b],!0,!0);return}a=a.join(" ")}f.add(g,a,h,!0)}else if(a)if(a.constructor===Array)for(e=0;e<a.length;e++)X(a,b,c,d,f,g,e,h);else e=b[++d],X(a,b,c,d,f,g,e,h)}u=T.prototype;
u.add=function(a,b,c){F(a)&&(b=a,a=V(b,this.key));if(b&&(a||0===a)){if(this.register[a])return this.update(a,b);for(var d=0,f,g;d<this.h.length;d++)g=this.h[d],f=this.I[d],E(f)&&(f=[f]),X(b,f,this.m,0,this.index[g],a,f[0],c);if(this.C){d=V(b,this.C);f=C();E(d)&&(d=[d]);g=0;for(var e;g<d.length;g++)if(e=d[g],!f[e]&&(f[e]=1,e=this.l[e]||(this.l[e]=[]),!c||-1===e.indexOf(a)))if(e[e.length]=a,this.s){var h=this.register[a]||(this.register[a]=[]);h[h.length]=e}}if(this.store){if(this.A){var k=C();for(c=
0;c<this.A.length;c++)d=this.A[c],E(d)?k[d]=b[d]:W(b,k,d,0,d[0])}this.store[a]=k||b}}return this};u.append=function(a,b){return this.add(a,b,!0)};u.update=function(a,b){return this.remove(a).add(a,b)};
u.remove=function(a){F(a)&&(a=V(a,this.key));if(this.register[a]){for(var b=this.s&&!this.o,c=0;c<this.h.length&&(this.index[this.h[c]].remove(a,b),!b);c++);if(this.C&&!b)for(var d in this.l)b=this.l[d],c=b.indexOf(a),-1!==c&&(1<b.length?b.splice(c,1):delete this.l[d]);this.store&&delete this.store[a];delete this.register[a]}return this};
u.search=function(a,b,c,d){F(a)?(c=a,a=c.query):F(b)&&(c=b,b=0);var f=[],g=[],e,h=0;if(c)if(c.constructor===Array){var k=c;c=null}else{k=(e=c.pluck)||c.index||c.field||c;var l=c.tag;var n=this.store&&c.enrich;var p="and"===c.bool;b=c.limit||100;var m=c.offset||0;if(l&&(E(l)&&(l=[l]),!a)){g=0;for(e=void 0;g<l.length;g++)if(e=Ea.call(this,l[g],b,m,n))f[f.length]=e,h++;return h?f:[]}E(k)?k=[k]:k.constructor===Array||(k=null)}k||(k=this.h);p=p&&(1<k.length||l&&1<l.length);for(var q=!d&&(this.o||this.async)&&
[],r=0,t=void 0,z=void 0,x=void 0;r<k.length;r++)if(x=void 0,z=k[r],E(z)||(x=z,z=z.field),q)q[r]=this.index[z].searchAsync(a,b,x||c);else{d?t=d[r]:t=this.index[z].search(a,b,x||c);x=t&&t.length;if(l&&x){var D=[],A=0;p&&(D[0]=[t]);var Z=0,G=void 0;for(G=void 0;Z<l.length;Z++)if(G=l[Z],x=(G=this.l[G])&&G.length)A++,D[D.length]=p?[G]:G;A&&(t=p?ta(D,b||100,m||0):ua(t,D),x=t.length)}if(x)g[h]=z,f[h++]=t;else if(p)return[]}if(q){var Ma=this;return new Promise(function(Na){Promise.all(q).then(function(Oa){Na(Ma.search(a,
b,c,Oa))})})}if(!h)return[];if(e&&(!n||!this.store))return f[0];l=0;for(m=void 0;l<g.length;l++){m=f[l];m.length&&n&&(m=Fa.call(this,m));if(e)return m;f[l]={field:g[l],result:m}}return f};function Ea(a,b,c,d){var f=this.l[a],g=f&&f.length-c;if(g&&0<g){if(g>b||c)f=f.slice(c,c+b);d&&(f=Fa.call(this,f));return{tag:a,result:f}}}function Fa(a){for(var b=Array(a.length),c=0,d;c<a.length;c++)d=a[c],b[c]={key:d,doc:this.store[d]};return b}u.contain=function(a){return!!this.register[a]};u.get=function(a){return this.store[a]};
u.set=function(a,b){this.store[a]=b;return this};u.searchCache=va;u.export=function(a,b,c,d,f){f||(f=0);d||(d=0);if(d<this.h.length){var g=this.h[d],e=this.index[g];b=this;setTimeout(function(){e.export(a,b,f?g.replace(":","-"):"",d,f++)||(d++,f=1,b.export(a,b,g,d,f))})}else{switch(f){case 1:c="tag";var h=this.l;break;case 2:c="store";h=this.store;break;default:return}xa(a,this,c,d,f,h)}};
u.import=function(a,b){if(b)switch(D(b)&&(b=JSON.parse(b)),a){case "tag":this.l=b;break;case "reg":this.s=!1;this.register=b;a=0;for(var c;a<this.h.length;a++)c=this.index[this.h[a]],c.register=b,c.s=!1;break;case "store":this.store=b;break;default:a=a.split("."),c=a[0],a=a[1],c&&a&&this.index[c].import(a,b)}};sa(T.prototype);var Ha={encode:Ga,F:!1,G:""},Ia=/[\W_]+/,Ja=[J("[\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5]"),"a",J("[\u00e8\u00e9\u00ea\u00eb]"),"e",J("[\u00ec\u00ed\u00ee\u00ef]"),"i",J("[\u00f2\u00f3\u00f4\u00f5\u00f6\u0151]"),"o",J("[\u00f9\u00fa\u00fb\u00fc\u0171]"),"u",J("[\u00fd\u0177\u00ff]"),"y",J("\u00f1"),"n",J("[\u00e7c]"),"k",J("\u00df"),"s",J(" & ")," and "];function Ga(a){return qa(this,ka(a).toLowerCase(),!a.normalize&&Ja,Ia)};var Oa={encode:Ka,F:!1,G:"strict"},Pa=/[^a-z0-9]+/,Qa={b:"p",v:"f",w:"f",z:"s",x:"s","\u00df":"s",d:"t",n:"m",c:"k",g:"k",j:"k",q:"k",i:"e",y:"e",u:"o"};function Ka(a){a=Ga.call(this,a).join(" ");var b=[];if(a)for(var c=a.split(Pa),d=c.length,f=0,g,e=0;f<d;f++)if((a=c[f])&&(!this.filter||!this.filter[a])){g=a[0];for(var h=Qa[g]||g,k=h,l=1;l<a.length;l++)g=a[l],(g=Qa[g]||g)&&g!==k&&(h+=g,k=g);b[e++]=h}return b};var Sa={encode:Ra,F:!1,G:""},Ta=[J("ae"),"a",J("oe"),"o",J("sh"),"s",J("th"),"t",J("ph"),"f",J("pf"),"f"];function Ra(a,b){a&&(a=Ka.call(this,a).join(" "),2<a.length&&(a=K(a,Ta)),b||(1<a.length&&(a=ma(a)),a&&(a=a.split(" "))));return a};var Va={encode:Ua,F:!1,G:""},Wa=J("(?!\\b)[aeiouy]");function Ua(a){a&&(a=Ra.call(this,a,!0),1<a.length&&(a=a.replace(Wa,"")),1<a.length&&(a=ma(a)),a&&(a=a.split(" ")));return a};L["latin:default"]=oa;L["latin:simple"]=Ha;L["latin:balance"]=Oa;L["latin:advanced"]=Sa;L["latin:extra"]=Va;var Y=self,Z,Xa={Index:O,Document:T,Worker:R,registerCharset:function(a,b){L[a]=b},registerLanguage:function(a,b){ra[a]=b}};(Z=Y.define)&&Z.amd?Z([],function(){return Xa}):Y.exports?Y.exports=Xa:Y.FlexSearch=Xa;}(this));
u.import=function(a,b){if(b)switch(E(b)&&(b=JSON.parse(b)),a){case "tag":this.l=b;break;case "reg":this.s=!1;this.register=b;a=0;for(var c;a<this.h.length;a++)c=this.index[this.h[a]],c.register=b,c.s=!1;break;case "store":this.store=b;break;default:a=a.split("."),c=a[0],a=a[1],c&&a&&this.index[c].import(a,b)}};sa(T.prototype);var Ha={encode:Ga,F:!1,G:""},Ia=/[\W_]+/,Ja=[I("[\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5]"),"a",I("[\u00e8\u00e9\u00ea\u00eb]"),"e",I("[\u00ec\u00ed\u00ee\u00ef]"),"i",I("[\u00f2\u00f3\u00f4\u00f5\u00f6\u0151]"),"o",I("[\u00f9\u00fa\u00fb\u00fc\u0171]"),"u",I("[\u00fd\u0177\u00ff]"),"y",I("\u00f1"),"n",I("[\u00e7c]"),"k",I("\u00df"),"s",I(" & ")," and "];function Ga(a){return qa(this,ka(a).toLowerCase(),!a.normalize&&Ja,Ia)};var La={encode:Ka,F:!1,G:"strict"},Pa=/[^a-z0-9]+/,Qa={b:"p",v:"f",w:"f",z:"s",x:"s","\u00df":"s",d:"t",n:"m",c:"k",g:"k",j:"k",q:"k",i:"e",y:"e",u:"o"};function Ka(a){a=Ga.call(this,a).join(" ");var b=[];if(a)for(var c=a.split(Pa),d=c.length,f=0,g,e=0;f<d;f++)if((a=c[f])&&(!this.filter||!this.filter[a])){g=a[0];for(var h=Qa[g]||g,k=h,l=1;l<a.length;l++)g=a[l],(g=Qa[g]||g)&&g!==k&&(h+=g,k=g);b[e++]=h}return b};var Sa={encode:Ra,F:!1,G:""},Ta=[I("ae"),"a",I("oe"),"o",I("sh"),"s",I("th"),"t",I("ph"),"f",I("pf"),"f"];function Ra(a,b){a&&(a=Ka.call(this,a).join(" "),2<a.length&&(a=J(a,Ta)),b||(1<a.length&&(a=ma(a)),a&&(a=a.split(" "))));return a};var Va={encode:Ua,F:!1,G:""},Wa=I("(?!\\b)[aeiouy]");function Ua(a){a&&(a=Ra.call(this,a,!0),1<a.length&&(a=a.replace(Wa,"")),1<a.length&&(a=ma(a)),a&&(a=a.split(" ")));return a};K["latin:default"]=oa;K["latin:simple"]=Ha;K["latin:balance"]=La;K["latin:advanced"]=Sa;K["latin:extra"]=Va;var Y=self,Xa,Ya={Index:N,Document:T,Worker:R,registerCharset:function(a,b){K[a]=b},registerLanguage:function(a,b){ra[a]=b}};(Xa=Y.define)&&Xa.amd?Xa([],function(){return Ya}):Y.exports?Y.exports=Ya:Y.FlexSearch=Ya;}(this));

View File

@@ -5,14 +5,14 @@
* Licence: Apache-2.0
* https://github.com/nextapps-de/flexsearch
*/
(function(self){'use strict';function u(a){return"undefined"!==typeof a?a:!0}function w(a){const c=Array(a);for(let b=0;b<a;b++)c[b]=z();return c}function z(){return Object.create(null)}function A(a,c){return c.length-a.length};const B=/[\u0300-\u036f]/g;function C(a,c){const b=Object.keys(a),d=b.length,e=[];let h="",g=0;for(let f=0,l,p;f<d;f++)l=b[f],(p=a[l])?(e[g++]=new RegExp(c?"(?!\\b)"+l+"(\\b|_)":l,"g"),e[g++]=p):h+=(h?"|":"")+l;h&&(e[g++]=new RegExp(c?"(?!\\b)("+h+")(\\b|_)":"("+h+")","g"),e[g]="");return e}function D(a,c){for(let b=0,d=c.length;b<d&&(a=a.replace(c[b],c[b+1]),a);b+=2);return a};const F=/[\W_]+/;function G(a){a.normalize&&(a=a.normalize("NFD").replace(B,""));if(a=a.toLowerCase())if(this.o&&(a=D(a,this.o)),this.A&&1<a.length&&(a=D(a,this.A)),F||""===F)if(a=a.split(F),this.filter){var c=this.filter;const b=a.length,d=[];for(let e=0,h=0;e<b;e++){const g=a[e];g&&!c[g]&&(d[h++]=g)}a=d}return a};const H={},I={};function J(a,c,b,d){const e=a.length;let h=[],g;let f,l;for(var p=0;p<e;p++){var m=a[p],q=m.length,r=0;for(let k=0,t;k<q;k++)(t=m[k])&&(r+=t.length);if(!n||r<n){var n=r;f=m;l=p}}f=1===f.length?f[0]:[].concat.apply([],f);d&&(d=[f],g=z());p=n=0;for(m=e-1;0<=m;m--)if(m!==l){p++;q=a[m];r=q.length;const k=[];let t=0;for(let y=0,v;y<f.length;y++){v=f[y];let x;for(let E=0;E<r;E++){const M=q[E];if(M.length&&(x=-1!==M.indexOf(v))){if(p===e-1){if(b)b--;else if(h[n++]=v,n===c)return h;d&&(g[v]=1)}break}}x&&
(k[t++]=v)}if(d)d[p]=k;else if(!t)return[];f=k}if(d)for(let k=d.length-1,t,y;0<=k;k--)if(y=(t=d[k])&&t.length)for(let v=0,x;v<y;v++)if(x=t[v],!g[x])if(g[x]=1,b)b--;else if(h[n++]=x,n===c)return h;return h};function K(a,c){if(!(this instanceof K))return new K(a);let b;if(a){var d=a.charset;b=a.lang;"string"===typeof d&&(-1===d.indexOf(":")&&(d+=":default"),d=I[d]);"string"===typeof b&&(b=H[b])}else a={};let e,h,g=a.context||{};this.encode=a.encode||d&&d.encode||G;this.register=c||z();this.v=e=a.resolution||9;this.C=c=d&&d.C||a.tokenize||"strict";this.j="strict"===c&&g.depth;this.l=u(g.bidirectional);this.g=h=u(a.optimize);this.s=u(a.fastupdate);this.h=a.minlength||1;this.i=h?w(e):z();this.B=e=g.resolution||
1;this.m=h?w(e):z();this.u=d&&d.u||a.rtl;this.o=(c=a.matcher||b&&b.o)&&C(c,!1);this.A=(c=a.stemmer||b&&b.A)&&C(c,!0);if(a=c=a.filter||b&&b.filter){a=c;d=z();for(let f=0,l=a.length;f<l;f++)d[a[f]]=1;a=d}this.filter=a}K.prototype.append=function(a,c){return this.add(a,c,!0)};
K.prototype.add=function(a,c,b,d){if(!d&&!b&&this.register[a])return this.update(a,c);if(c&&(a||0===a)&&(c=this.encode(c),d=c.length)){const p=this.j,m=this.v,q=z(),r=z();for(let n=0;n<d;n++){let k=c[this.u?d-1-n:n];var e=k.length;if(k&&e>=this.h&&(p||!q[k])){var h=d<m?n:m/d*n|0,g="";switch(this.C){case "full":if(3<e){for(h=0;h<e;h++)for(var f=e;f>h;f--)if(f-h>=this.h){var l=d+e<m?n+h:m/(d+e)*(n+h)|0;g=k.substring(h,f);L(this,q,g,l,a,b)}break}case "reverse":if(2<e){for(f=e-1;0<f;f--)g=k[f]+g,g.length>=
this.h&&L(this,q,g,d+e<m?n+f:m/(d+e)*(n+f)|0,a,b);g=""}case "forward":if(1<e)for(f=0;f<e;f++)g+=k[f],g.length>=this.h&&L(this,q,g,h,a,b);break;default:if(L(this,q,k,h,a,b),p&&1<d&&n<d-1)for(e=this.B,g=z(),h=k,f=Math.min(p+1,d-n),g[h]=1,l=1;l<f;l++)if((k=c[this.u?d-1-n-l:n+l])&&k.length>=this.h&&!g[k]){g[k]=1;const t=this.l&&k>h;L(this,r,t?h:k,f+d<e?n+(l-1):e/(f+d)*(n+l)|0,a,b,t?k:h)}}}}this.s||(this.register[a]=1)}return this};
function L(a,c,b,d,e,h,g){let f=g?a.m:a.i;if(!c[b]||g&&!c[b][g])a.g&&(f=f[d]),g?(c=c[b]||(c[b]=z()),c[g]=1,f=f[g]||(f[g]=z())):c[b]=1,f=f[b]||(f[b]=[]),a.g||(f=f[d]||(f[d]=[])),h&&-1!==f.indexOf(e)||(f[f.length]=e,a.s&&(a=a.register[e]||(a.register[e]=[]),a[a.length]=f))}
K.prototype.search=function(a,c,b){"object"===typeof a?(b=a,a=b.query):"object"===typeof c&&(b=c);let d=[],e;let h,g=0;if(b){c=b.limit;g=b.offset||0;var f=b.context;h=!1}if(a&&(a=this.encode(a),e=a.length,1<e)){b=z();var l=[];for(let m=0,q=0,r;m<e;m++)if((r=a[m])&&r.length>=this.h&&!b[r])if(this.g||h||this.i[r])l[q++]=r,b[r]=1;else return d;a=l;e=a.length}if(!e)return d;c||(c=100);f=this.j&&1<e&&!1!==f;b=0;let p;f?(p=a[0],b=1):1<e&&a.sort(A);for(let m,q;b<e;b++){q=a[b];f?(m=N(this,d,h,c,g,2===e,q,
p),h&&!1===m&&d.length||(p=q)):m=N(this,d,h,c,g,1===e,q);if(m)return m;if(h&&b===e-1){l=d.length;if(!l){if(f){f=0;b=-1;continue}return d}if(1===l)return O(d[0],c,g)}}return J(d,c,g,h)};
function N(a,c,b,d,e,h,g,f){let l=[],p=f?a.m:a.i;a.g||(p=P(p,g,f,a.l));if(p){let m=0;const q=Math.min(p.length,f?a.B:a.v);for(let r=0,n=0,k,t;r<q;r++)if(k=p[r])if(a.g&&(k=P(k,g,f,a.l)),e&&k&&h&&(t=k.length,t<=e?(e-=t,k=null):(k=k.slice(e),e=0)),k&&(l[m++]=k,h&&(n+=k.length,n>=d)))break;if(m){if(h)return O(l,d,0);c[c.length]=l;return}}return!b&&l}function O(a,c,b){a=1===a.length?a[0]:[].concat.apply([],a);return b||a.length>c?a.slice(b,b+c):a}
function P(a,c,b,d){b?(d=d&&c>b,a=(a=a[d?c:b])&&a[d?b:c]):a=a[c];return a}K.prototype.contain=function(a){return!!this.register[a]};K.prototype.update=function(a,c){return this.remove(a).add(a,c)};K.prototype.remove=function(a,c){const b=this.register[a];if(b){if(this.s)for(let d=0,e;d<b.length;d++)e=b[d],e.splice(e.indexOf(a),1);else Q(this.i,a,this.v,this.g),this.j&&Q(this.m,a,this.B,this.g);c||delete this.register[a]}return this};
function Q(a,c,b,d,e){let h=0;if(a.constructor===Array)if(e)c=a.indexOf(c),-1!==c?1<a.length&&(a.splice(c,1),h++):h++;else{e=Math.min(a.length,b);for(let g=0,f;g<e;g++)if(f=a[g])h=Q(f,c,b,d,e),d||h||delete a[g]}else for(let g in a)(h=Q(a[g],c,b,d,e))||delete a[g];return h};const R=self;let S;const T={Index:K,Document:null,Worker:null,registerCharset:function(a,c){I[a]=c},registerLanguage:function(a,c){H[a]=c}};(S=R.define)&&S.amd?S([],function(){return T}):R.exports?R.exports=T:R.FlexSearch=T;}(this));
(function(self){'use strict';function t(a){return"undefined"!==typeof a?a:!0}function v(a){const c=Array(a);for(let b=0;b<a;b++)c[b]=y();return c}function y(){return Object.create(null)}function z(a,c){return c.length-a.length};const A=/[\u0300-\u036f]/g;function B(a,c){const b=Object.keys(a),d=b.length,e=[];let h="",f=0;for(let g=0,k,n;g<d;g++)k=b[g],(n=a[k])?(e[f++]=new RegExp(c?"(?!\\b)"+k+"(\\b|_)":k,"g"),e[f++]=n):h+=(h?"|":"")+k;h&&(e[f++]=new RegExp(c?"(?!\\b)("+h+")(\\b|_)":"("+h+")","g"),e[f]="");return e}function C(a,c){for(let b=0,d=c.length;b<d&&(a=a.replace(c[b],c[b+1]),a);b+=2);return a};const D=/[\W_]+/;function F(a){a.normalize&&(a=a.normalize("NFD").replace(A,""));if(a=a.toLowerCase())if(this.o&&(a=C(a,this.o)),this.A&&1<a.length&&(a=C(a,this.A)),D||""===D)if(a=a.split(D),this.filter){var c=this.filter;const b=a.length,d=[];for(let e=0,h=0;e<b;e++){const f=a[e];f&&!c[f]&&(d[h++]=f)}a=d}return a};const G={},H={};function I(a,c,b,d){var e=a.length;let h=[],f,g,k=0;d&&(d=[]);for(--e;0<=e;e--){const n=a[e],p=n.length,q=y();let r=!f;for(let m=0;m<p;m++){const l=n[m],u=l.length;if(u)for(let E=0,x,w;E<u;E++)if(w=l[E],f){if(f[w]){if(!e)if(b)b--;else if(h[k++]=w,k===c)return h;if(e||d)q[w]=1;r=!0}if(d&&(g[w]=(x=g[w])?x++:x=1,x<p)){const M=d[x-1]||(d[x-1]=[]);M[M.length]=w}}else q[w]=1}if(d)f||(g=q);else if(!r)return[];f=q}if(d)for(let n=d.length-1,p,q;0<=n;n--){p=d[n];q=p.length;for(let r=0,m;r<q;r++)if(m=p[r],!f[m]){if(b)b--;
else if(h[k++]=m,k===c)return h;f[m]=1}}return h};function J(a,c){if(!(this instanceof J))return new J(a);let b;if(a){var d=a.charset;b=a.lang;"string"===typeof d&&(-1===d.indexOf(":")&&(d+=":default"),d=H[d]);"string"===typeof b&&(b=G[b])}else a={};let e,h,f=a.context||{};this.encode=a.encode||d&&d.encode||F;this.register=c||y();this.v=e=a.resolution||9;this.C=c=d&&d.C||a.tokenize||"strict";this.j="strict"===c&&f.depth;this.l=t(f.bidirectional);this.g=h=t(a.optimize);this.s=t(a.fastupdate);this.h=a.minlength||1;this.i=h?v(e):y();this.B=e=f.resolution||
1;this.m=h?v(e):y();this.u=d&&d.u||a.rtl;this.o=(c=a.matcher||b&&b.o)&&B(c,!1);this.A=(c=a.stemmer||b&&b.A)&&B(c,!0);if(a=c=a.filter||b&&b.filter){a=c;d=y();for(let g=0,k=a.length;g<k;g++)d[a[g]]=1;a=d}this.filter=a}J.prototype.append=function(a,c){return this.add(a,c,!0)};
J.prototype.add=function(a,c,b,d){if(!d&&!b&&this.register[a])return this.update(a,c);if(c&&(a||0===a)&&(c=this.encode(c),d=c.length)){const n=this.j,p=this.v,q=y(),r=y();for(let m=0;m<d;m++){let l=c[this.u?d-1-m:m];var e=l.length;if(l&&e>=this.h&&(n||!q[l])){var h=K(p,d,m),f="";switch(this.C){case "full":if(3<e){for(h=0;h<e;h++)for(var g=e;g>h;g--)if(g-h>=this.h){var k=K(p,d,m,e,h);f=l.substring(h,g);L(this,q,f,k,a,b)}break}case "reverse":if(2<e){for(g=e-1;0<g;g--)f=l[g]+f,f.length>=this.h&&L(this,
q,f,K(p,d,m,e,g),a,b);f=""}case "forward":if(1<e)for(g=0;g<e;g++)f+=l[g],f.length>=this.h&&L(this,q,f,h,a,b);break;default:if(L(this,q,l,h,a,b),n&&1<d&&m<d-1)for(e=this.B,f=y(),h=l,g=Math.min(n+1,d-m),f[h]=1,k=1;k<g;k++)if((l=c[this.u?d-1-m-k:m+k])&&l.length>=this.h&&!f[l]){f[l]=1;const u=this.l&&l>h;L(this,r,u?h:l,K(e+(d/2>e?0:1),d,m,g-1,k-1),a,b,u?l:h)}}}}this.s||(this.register[a]=1)}return this};function K(a,c,b,d,e){return b&&1<a?c+(d||0)<=a?b+(e||0):(a-1)/(c+(d||0))*(b+(e||0))+1|0:0}
function L(a,c,b,d,e,h,f){let g=f?a.m:a.i;if(!c[b]||f&&!c[b][f])a.g&&(g=g[d]),f?(c=c[b]||(c[b]=y()),c[f]=1,g=g[f]||(g[f]=y())):c[b]=1,g=g[b]||(g[b]=[]),a.g||(g=g[d]||(g[d]=[])),h&&-1!==g.indexOf(e)||(g[g.length]=e,a.s&&(a=a.register[e]||(a.register[e]=[]),a[a.length]=g))}
J.prototype.search=function(a,c,b){"object"===typeof a?(b=a,a=b.query):"object"===typeof c&&(b=c);let d=[],e;let h,f=0;if(b){c=b.limit;f=b.offset||0;var g=b.context;h=!1}if(a&&(a=this.encode(a),e=a.length,1<e)){b=y();var k=[];for(let p=0,q=0,r;p<e;p++)if((r=a[p])&&r.length>=this.h&&!b[r])if(this.g||h||this.i[r])k[q++]=r,b[r]=1;else return d;a=k;e=a.length}if(!e)return d;c||(c=100);g=this.j&&1<e&&!1!==g;b=0;let n;g?(n=a[0],b=1):1<e&&a.sort(z);for(let p,q;b<e;b++){q=a[b];g?(p=N(this,d,h,c,f,2===e,q,
n),h&&!1===p&&d.length||(n=q)):p=N(this,d,h,c,f,1===e,q);if(p)return p;if(h&&b===e-1){k=d.length;if(!k){if(g){g=0;b=-1;continue}return d}if(1===k)return O(d[0],c,f)}}return I(d,c,f,h)};
function N(a,c,b,d,e,h,f,g){let k=[],n=g?a.m:a.i;a.g||(n=P(n,f,g,a.l));if(n){let p=0;const q=Math.min(n.length,g?a.B:a.v);for(let r=0,m=0,l,u;r<q;r++)if(l=n[r])if(a.g&&(l=P(l,f,g,a.l)),e&&l&&h&&(u=l.length,u<=e?(e-=u,l=null):(l=l.slice(e),e=0)),l&&(k[p++]=l,h&&(m+=l.length,m>=d)))break;if(p){if(h)return O(k,d,0);c[c.length]=k;return}}return!b&&k}function O(a,c,b){a=1===a.length?a[0]:[].concat.apply([],a);return b||a.length>c?a.slice(b,b+c):a}
function P(a,c,b,d){b?(d=d&&c>b,a=(a=a[d?c:b])&&a[d?b:c]):a=a[c];return a}J.prototype.contain=function(a){return!!this.register[a]};J.prototype.update=function(a,c){return this.remove(a).add(a,c)};J.prototype.remove=function(a,c){const b=this.register[a];if(b){if(this.s)for(let d=0,e;d<b.length;d++)e=b[d],e.splice(e.indexOf(a),1);else Q(this.i,a,this.v,this.g),this.j&&Q(this.m,a,this.B,this.g);c||delete this.register[a]}return this};
function Q(a,c,b,d,e){let h=0;if(a.constructor===Array)if(e)c=a.indexOf(c),-1!==c?1<a.length&&(a.splice(c,1),h++):h++;else{e=Math.min(a.length,b);for(let f=0,g;f<e;f++)if(g=a[f])h=Q(g,c,b,d,e),d||h||delete a[f]}else for(let f in a)(h=Q(a[f],c,b,d,e))||delete a[f];return h};const R=self;let S;const T={Index:J,Document:null,Worker:null,registerCharset:function(a,c){H[a]=c},registerLanguage:function(a,c){G[a]=c}};(S=R.define)&&S.amd?S([],function(){return T}):R.exports?R.exports=T:R.FlexSearch=T;}(this));

View File

@@ -141,20 +141,19 @@ Index.prototype.add = function(id, content, _append, _skip_update){
const depth = this.depth;
const resolution = this.resolution;
const dupes = create_object();
// check context dupes to skip all contextual redundancy in the whole document
// check context dupes to skip all contextual redundancy along a document
const dupes_ctx = create_object();
// TODO: stretch the partial score to its full resolution
for(let i = 0; i < length; i++){
let term = content[this.rtl ? length - 1 - i : i];
let term_length = term.length;
// skip dupes will break the context chain
if(term && (term_length >= this.minlength) && (depth || !dupes[term])){
const score = length < resolution ? i : (resolution / length * i) | 0;
const score = get_score(resolution, length, i);
let token = "";
switch(this.tokenize){
@@ -169,14 +168,7 @@ Index.prototype.add = function(id, content, _append, _skip_update){
if((y - x) >= this.minlength){
const partial_score = (length + term_length) < resolution ? i + x : (resolution / (length + term_length) * (i + x)) | 0;
// console.log("resolution", resolution);
// console.log("length", length);
// console.log("term_length", term_length);
// console.log("i", i);
// console.log((length + term_length) < resolution ? i + x : resolution / (length + term_length) * (i + x));
const partial_score = get_score(resolution, length, i, term_length, x);
token = term.substring(x, y);
this.push_index(dupes, token, partial_score, id, _append);
}
@@ -186,7 +178,7 @@ Index.prototype.add = function(id, content, _append, _skip_update){
break;
}
// fallthrough to next case when term length < 4
// fallthrough to next case when term length < 4
case "reverse":
@@ -200,15 +192,7 @@ Index.prototype.add = function(id, content, _append, _skip_update){
if(token.length >= this.minlength){
const partial_score = (length + term_length) < resolution ? i + x : (resolution / (length + term_length) * (i + x)) | 0;
// console.log("token", token);
// console.log("resolution", resolution);
// console.log("length", length);
// console.log("term_length", term_length);
// console.log("i", i);
// console.log((length + term_length) < resolution ? i + x : (resolution / (length + term_length) * (i + x)));
const partial_score = get_score(resolution, length, i, term_length, x);
this.push_index(dupes, token, partial_score, id, _append);
}
}
@@ -216,7 +200,7 @@ Index.prototype.add = function(id, content, _append, _skip_update){
token = "";
}
// fallthrough to next case to apply forward also
// fallthrough to next case to apply forward also
case "forward":
@@ -228,13 +212,6 @@ Index.prototype.add = function(id, content, _append, _skip_update){
if(token.length >= this.minlength){
// console.log("token", token);
// console.log("resolution", resolution);
// console.log("length", length);
// console.log("term_length", term_length);
// console.log("i", i);
// console.log(score);
this.push_index(dupes, token, score, id, _append);
}
}
@@ -245,12 +222,6 @@ Index.prototype.add = function(id, content, _append, _skip_update){
//case "strict":
default:
// console.log("term", term);
// console.log("resolution", resolution);
// console.log("length", length);
// console.log("i", i);
// console.log(score);
this.push_index(dupes, term, score, id, _append);
if(depth){
@@ -273,16 +244,7 @@ Index.prototype.add = function(id, content, _append, _skip_update){
dupes_inner[term] = 1;
const context_score = (size + length) < resolution ? i + (x - 1) : ((resolution / (size + length) * (i + x)) | 0);
// console.log("term", term);
// console.log("resolution", resolution);
// console.log("size", size);
// console.log("length", length);
// console.log("i", i);
// console.log("x", x);
// console.log(resolution / (size + length) * (i + x));
const context_score = get_score(resolution + ((length / 2) > resolution ? 0 : 1), length, i, size - 1, x - 1);
const swap = this.bidirectional && (term > keyword);
this.push_index(dupes_ctx, swap ? keyword : term, context_score, id, _append, swap ? term : keyword);
}
@@ -300,6 +262,46 @@ Index.prototype.add = function(id, content, _append, _skip_update){
return this;
};
/**
* @param {number} resolution
* @param {number} length
* @param {number} i
* @param {number=} term_length
* @param {number=} x
* @returns {number}
*/
function get_score(resolution, length, i, term_length, x){
// console.log("resolution", resolution);
// console.log("length", length);
// console.log("term_length", term_length);
// console.log("i", i);
// console.log("x", x);
// console.log((resolution - 1) / (length + (term_length || 0)) * (i + (x || 0)) + 1);
// the first resolution slot is reserved for the best match,
// when a query matches the first word(s).
// also to stretch score to the whole range of resolution, the
// calculation is shift by one and cut the floating point.
// this needs the resolution "1" to be handled additionally.
// do not stretch the resolution more than the term length will
// improve performance and memory, also it improves scoring in
// most cases between a short document and a long document
return i && (resolution > 1) ? (
(length + (term_length || 0)) <= resolution ?
i + (x || 0)
:
((resolution - 1) / (length + (term_length || 0)) * (i + (x || 0)) + 1) | 0
):
0;
}
/**
* @private
* @param dupes
@@ -404,7 +406,7 @@ Index.prototype.search = function(query, limit, options){
if(term && (term.length >= this.minlength) && !dupes[term]){
// the fast path just could applied when not in memory-optimized mode
// this fast path just could applied when not in memory-optimized mode
if(!this.optimize && !suggest && !this.map[term]){
@@ -452,10 +454,17 @@ Index.prototype.search = function(query, limit, options){
term = query[index];
// console.log(keyword);
// console.log(term);
// console.log("");
if(depth){
arr = this.add_result(result, suggest, limit, offset, length === 2, term, keyword);
// console.log(arr);
// console.log(result);
// when suggestion enabled just forward keyword if term was found
// as long as the result is empty forward the pointer also

View File

@@ -1,7 +1,203 @@
import { create_object, concat } from "./common.js";
/**
* Implementation based on Array.indexOf()
* Implementation based on Array.indexOf() provides better performance,
* but it needs at least one word in the query which is less frequent.
* Also on large indexes it does not scale well performance-wise.
* This strategy also lacks of suggestion capabilities (matching & sorting).
*
* @param arrays
* @param limit
* @param offset
* @param {boolean|Array=} suggest
* @returns {Array}
*/
// export function intersect(arrays, limit, offset, suggest) {
//
// const length = arrays.length;
// let result = [];
// let check;
//
// // determine shortest array and collect results
// // from the sparse relevance arrays
//
// let smallest_size;
// let smallest_arr;
// let smallest_index;
//
// for(let x = 0; x < length; x++){
//
// const arr = arrays[x];
// const len = arr.length;
//
// let size = 0;
//
// for(let y = 0, tmp; y < len; y++){
//
// tmp = arr[y];
//
// if(tmp){
//
// size += tmp.length;
// }
// }
//
// if(!smallest_size || (size < smallest_size)){
//
// smallest_size = size;
// smallest_arr = arr;
// smallest_index = x;
// }
// }
//
// smallest_arr = smallest_arr.length === 1 ?
//
// smallest_arr[0]
// :
// concat(smallest_arr);
//
// if(suggest){
//
// suggest = [smallest_arr];
// check = create_object();
// }
//
// let size = 0;
// let steps = 0;
//
// // process terms in reversed order often results in better performance.
// // the outer loop must be the words array, using the
// // smallest array here disables the "fast fail" optimization.
//
// for(let x = length - 1; x >= 0; x--){
//
// if(x !== smallest_index){
//
// steps++;
//
// const word_arr = arrays[x];
// const word_arr_len = word_arr.length;
// const new_arr = [];
//
// let count = 0;
//
// for(let z = 0, id; z < smallest_arr.length; z++){
//
// id = smallest_arr[z];
//
// let found;
//
// // process relevance in forward order (direction is
// // important for adding IDs during the last round)
//
// for(let y = 0; y < word_arr_len; y++){
//
// const arr = word_arr[y];
//
// if(arr.length){
//
// found = arr.indexOf(id) !== -1;
//
// if(found){
//
// // check if in last round
//
// if(steps === length - 1){
//
// if(offset){
//
// offset--;
// }
// else{
//
// result[size++] = id;
//
// if(size === limit){
//
// // fast path "end reached"
//
// return result;
// }
// }
//
// if(suggest){
//
// check[id] = 1;
// }
// }
//
// break;
// }
// }
// }
//
// if(found){
//
// new_arr[count++] = id;
// }
// }
//
// if(suggest){
//
// suggest[steps] = new_arr;
// }
// else if(!count){
//
// return [];
// }
//
// smallest_arr = new_arr;
// }
// }
//
// if(suggest){
//
// // needs to iterate in reverse direction
//
// for(let x = suggest.length - 1, arr, len; x >= 0; x--){
//
// arr = suggest[x];
// len = arr && arr.length;
//
// if(len){
//
// for(let y = 0, id; y < len; y++){
//
// id = arr[y];
//
// if(!check[id]){
//
// check[id] = 1;
//
// if(offset){
//
// offset--;
// }
// else{
//
// result[size++] = id;
//
// if(size === limit){
//
// // fast path "end reached"
//
// return result;
// }
// }
// }
// }
// }
// }
// }
//
// return result;
// }
/**
* Implementation based on Object[key] provides better suggestions
* capabilities and has less performance scaling issues on large indexes.
*
* @param arrays
* @param limit
* @param offset
@@ -14,94 +210,48 @@ export function intersect(arrays, limit, offset, suggest) {
const length = arrays.length;
let result = [];
let check;
// determine shortest array and collect results
// from the sparse relevance arrays
let smallest_size;
let smallest_arr;
let smallest_index;
for(let x = 0; x < length; x++){
const arr = arrays[x];
const len = arr.length;
let size = 0;
for(let y = 0, tmp; y < len; y++){
tmp = arr[y];
if(tmp){
size += tmp.length;
}
}
if(!smallest_size || (size < smallest_size)){
smallest_size = size;
smallest_arr = arr;
smallest_index = x;
}
}
smallest_arr = smallest_arr.length === 1 ?
smallest_arr[0]
:
concat(smallest_arr);
let check_suggest;
let size = 0;
if(suggest){
suggest = [smallest_arr];
check = create_object();
suggest = [];
}
let size = 0;
let steps = 0;
// TODO: the first word should be processed in the last round?
// process terms in reversed order often results in better performance
// the outer loop must be the words array,
// using the smallest array here disables the "fast fail" optimization
// process terms in reversed order often has advantage for the fast path "end reached".
// also a reversed order prioritize the order of words from a query.
for(let x = length - 1; x >= 0; x--){
if(x !== smallest_index){
const word_arr = arrays[x];
const word_arr_len = word_arr.length;
const check_new = create_object();
steps++;
let found = !check;
const word_arr = arrays[x];
const word_arr_len = word_arr.length;
const new_arr = [];
// process relevance in forward order (direction is
// important for adding IDs during the last round)
let count = 0;
for(let y = 0; y < word_arr_len; y++){
for(let z = 0, id; z < smallest_arr.length; z++){
const arr = word_arr[y];
const arr_len = arr.length;
id = smallest_arr[z];
if(arr_len){
let found;
// loop through IDs
// process relevance in forward order (direction is
// important for the "fill" during the last round)
for(let z = 0, check_idx, id; z < arr_len; z++){
for(let y = 0; y < word_arr_len; y++){
id = arr[z];
const arr = word_arr[y];
if(check){
if(arr.length){
found = arr.indexOf(id) !== -1;
if(found){
if(check[id]){
// check if in last round
if(steps === length - 1){
if(!x){
if(offset){
@@ -118,47 +268,63 @@ export function intersect(arrays, limit, offset, suggest) {
return result;
}
}
if(suggest){
check[id] = 1;
}
}
break;
if(x || suggest){
check_new[id] = 1;
}
found = true;
}
if(suggest){
check_suggest[id] = (check_idx = check_suggest[id]) ? check_idx++ : check_idx = 1;
// do not adding IDs which are already included in the result (saves one loop)
if(check_idx < word_arr_len){
const tmp = suggest[check_idx - 1] || (suggest[check_idx - 1] = []);
tmp[tmp.length] = id;
}
}
}
}
else{
if(found){
// pre-fill in first round
new_arr[count++] = id;
check_new[id] = 1;
}
}
}
if(suggest){
suggest[steps] = new_arr;
}
else if(!count){
return [];
}
smallest_arr = new_arr;
}
if(suggest){
// re-use the first pre-filled check for suggestions
check || (check_suggest = check_new);
}
else if(!found){
return [];
}
check = check_new;
}
if(suggest){
// has to iterate in reverse direction
// needs to iterate in reverse direction
for(let x = suggest.length - 1, arr, len; x >= 0; x--){
arr = suggest[x];
len = arr && arr.length;
len = /*arr &&*/ arr.length;
if(len){
//if(len){
for(let y = 0, id; y < len; y++){
@@ -166,8 +332,6 @@ export function intersect(arrays, limit, offset, suggest) {
if(!check[id]){
check[id] = 1;
if(offset){
offset--;
@@ -183,154 +347,17 @@ export function intersect(arrays, limit, offset, suggest) {
return result;
}
}
check[id] = 1;
}
}
}
//}
}
}
return result;
}
/**
* Implementation based on Object[key]
* @param arrays
* @param limit
* @param offset
* @param {boolean|Array=} suggest
* @returns {Array}
*/
// export function intersect(arrays, limit, offset, suggest) {
//
// const length = arrays.length;
// let result = [];
//
// // arrays.sort(function(a, b){
// //
// // return a.length - b.length;
// // });
//
// let check;
// let count = 0;
//
// if(suggest){
//
// suggest = [];
// }
//
// // terms in reversed order!
// for(let x = length - 1; x >= 0; x--){
//
// const word_arr = arrays[x];
// const word_arr_len = word_arr.length;
// const new_check = create_object();
//
// let found = !check;
//
// // relevance in forward order
// for(let y = 0, count_suggest = 0; y < word_arr_len; y++){
//
// //const arr = [].concat.apply([], word_arr);
// const arr = word_arr[y];
// const arr_len = arr.length;
//
// if(arr_len){
//
// // ids
// for(let z = 0, id; z < arr_len; z++){
//
// id = arr[z];
//
// if(!check){
//
// new_check[id] = 1;
// }
// else if(check[id]){
//
// if(!x){
//
// if(offset){
//
// offset--;
// }
// else{
//
// result[count++] = id;
//
// if(count === limit){
//
// // fast path "end reached"
//
// return result;
// }
// }
// }
// else{
//
// if(suggest && (count_suggest < limit)){
//
// const tmp = suggest[y] || (suggest[y] = []);
// tmp[tmp.length] = id;
// count_suggest++;
// }
//
// new_check[id] = 1;
// }
//
// found = true;
// }
// }
// }
// }
//
// if(!found && !suggest){
//
// return [];
// }
//
// check = new_check;
// }
//
// if(suggest){
//
// for(let i = suggest.length - 1, res, len; i >= 0; i--){
//
// res = suggest[i];
// len = res && res.length;
//
// if(len && offset){
//
// if(len <= offset){
//
// offset -= len;
// len = 0;
// }
// else{
//
// len -= offset;
// }
// }
//
// if(len){
//
// if(count + len >= limit){
//
// return result.concat(res.slice(offset, limit - count + offset));
// }
// else{
//
// result = result.concat(offset ? res.slice(offset) : res);
// count += len;
// offset = 0;
// }
// }
// }
// }
//
// return result;
// }
/**
* @param mandatory
* @param arrays