mirror of
https://github.com/nextapps-de/flexsearch.git
synced 2025-09-01 09:53:56 +02:00
Update Readme
This commit is contained in:
@@ -13,8 +13,8 @@
|
||||
<h1></h1>
|
||||
<h3>Web's fastest and most memory-flexible full-text search library with zero dependencies.</h3>
|
||||
|
||||
When it comes to raw search speed <a href="https://raw.githack.com/nextapps-de/flexsearch/master/test/benchmark.html" target="_blank">FlexSearch outperforms every single searching library out there</a> and also provides flexible search capabilities like multi-field search, phonetic transformations or partial matching.
|
||||
Depending on the used <a href="#options">options</a> it also provides the <a href="#memory">most memory-efficient index</a>. Keep in mind that updating __existing__ items or removing items from the index has a significant cost. When existing items of your index needs to be updated/removed continuously then <a href="https://github.com/nextapps-de/bulksearch" target="_blank">BulkSearch</a> may be a better choice.
|
||||
It is time for a quantum leap in full-text searching algorithms. When it comes to raw search speed <a href="https://raw.githack.com/nextapps-de/flexsearch/master/test/benchmark.html" target="_blank">FlexSearch outperforms every single searching library out there</a> and also provides flexible search capabilities like multi-field search, phonetic transformations or partial matching.
|
||||
Depending on the used <a href="#options">options</a> it also provides the <a href="#memory">most memory-efficient index</a>. FlexSearch introduce a new scoring algorithm called <a href="#contextual">"contextual index"</a> based on a high-performance <a href="#dictionary">pre-scored lexical dictionary</a> architecture which actually performs queries up to 100,000 times faster than Apache Lucene.
|
||||
FlexSearch also provides you a non-blocking asynchronous processing model as well as web workers to perform any updates or queries on the index in parallel through dedicated balanced threads.
|
||||
|
||||
FlexSearch Server is available here: <a target="_blank" href="https://github.com/nextapps-de/flexsearch-server">https://github.com/nextapps-de/flexsearch-server</a>.
|
||||
@@ -416,9 +416,10 @@ FlexSearch introduce a new scoring mechanism called __Contextual Search__ which
|
||||
The basic idea of this concept is to limit relevance by its context instead of calculating relevance through the whole (unlimited) distance.<!--Imagine you add a text block of some sentences to an index ID. Assuming the query includes a combination of first and last word from this text block, are they really relevant to each other?-->
|
||||
In this way contextual search also <a href="https://raw.githack.com/nextapps-de/flexsearch/master/test/matching.html" target="_blank">improves the results of relevance-based queries</a> on a large amount of text data.
|
||||
|
||||
<!--
|
||||
> "TF-IDF and all kinds of variations (like BM25) is a big mistake in searching algorithms today. They don't provide neither: a meaningful relevance of a term nor the importance of it! Like many pseudo-intelligent algorithms this is also just an example of mathematical stupidity." — Thomas Wilkerling, _Contextual-based Scoring_, 2018
|
||||
|
||||
#### Model of context-based scoring
|
||||
-->
|
||||
|
||||
<p align="center">
|
||||
<img src="https://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@master/doc/contextual-index.svg">
|
||||
@@ -536,6 +537,8 @@ The complexity for one single term is always 1.
|
||||
-->
|
||||
</table>
|
||||
|
||||
Keep in mind that updating __existing__ items or removing items from the index has a significant cost. When existing items of your index needs to be updated/removed continuously then <a href="https://github.com/nextapps-de/bulksearch" target="_blank">BulkSearch</a> may be a better choice.
|
||||
|
||||
<a name="installation"></a>
|
||||
## Installation
|
||||
|
||||
|
6
dist/flexsearch.compact.js
vendored
6
dist/flexsearch.compact.js
vendored
@@ -11,9 +11,9 @@ function P(b,a,c,d,f,m,g,h){if(a[c])return a[c];f=f?(h-(g||h/1.5))*m+(g||h/1.5)*
|
||||
"o"===d||"u"===d||"y"===d,("a"===c||"e"===c||"i"===c||"o"===c||"u"===c||"y"===c)&&d||" "===c)a+=m}else a+=m;d=f===b.length-1?"":b[f+1];c=m}return a}function da(b,a){b=b.length-a.length;return 0>b?1:b?-1:0}function ca(b,a){b=b[y];a=a[y];return b<a?-1:b>a?1:0}function ba(b,a){const c=y.length;for(let d=0;d<c;d++)b=b[y[d]],a=a[y[d]];return b<a?-1:b>a?1:0}function I(b,a,c){return b?{page:b,next:a?""+a:null,result:c}:c}function V(b,a,c,d,f,m,g){let h,p=[],e;const n=b.length;!0===c?(c="0",e=""):e=c&&c.split(":");
|
||||
if(1<n){const u=A();let R=[],M,D;var q=-1,k;let t;var Q=!0;let C,B=0,v,y,w;e&&(2===e.length?(w=e,e=!1):e=parseInt(e[0],10));if(g){for(M=A();++q<n;)if("not"===f[q])for(D=b[q],t=D.length,k=0;k<t;)M["@"+D[k++]]=1;else y=q+1;if(N(y))return I(c,h,p);q=-1}else v=E(f)&&f;let x;for(;++q<n;){const L=q===(y||n)-1;if(!v||!q)if((k=v||f&&f[q])&&"and"!==k)if("or"===k)x=!1;else continue;else x=m=!0;D=b[q];if(t=D.length){if(Q)if(C){var r=C.length;for(k=0;k<r;){Q=C[k++];var l="@"+Q;g&&M[l]||(u[l]=1,m||(p[B++]=Q))}C=
|
||||
null;Q=!1}else{C=D;continue}l=!1;for(k=0;k<t;){r=D[k++];var z="@"+r;const b=m?u[z]:q;if(!(!b||g&&M[z]||!m&&u[z]))if(b===q){if(L){if(!e||--e<B)if(p[B++]=r,a&&B===a)return I(c,B,p)}else u[z]=q+1;l=!0}else d&&(z=R[b]||(R[b]=[]),z[z.length]=r)}if(x&&!l&&!d)break}else if(x&&!d)return I(c,h,D)}if(C)if(q=C.length,g)for(k=e?parseInt(e,10):0;k<q;){if(b=C[k++],!M["@"+b]&&(!e||--e<B)&&(p[B++]=b,a&&B===a))return I(c,k,p)}else p=C;if(d)for(B=p.length,w?(q=parseInt(w[0],10)+1,k=parseInt(w[1],10)):(q=R.length,k=
|
||||
0);q--;)if(r=R[q])for(t=r.length;k<t;k++)if(d=r[k],!g||!M["@"+d])if(p[B++]=d,a&&B===a)return I(c,q+":"+k,p)}else n&&(f&&"not"===f[0]||(p=b[0]));a&&(g=c?parseInt(c,10):0,h=g+a,h<p.length?p=p.slice(g,h):g&&(p=p.slice(g)));return I(c,h,p)}function E(b){return"string"===typeof b}function w(b){return b.constructor===Array}function H(b){return"function"===typeof b}function K(b){return"object"===typeof b}function N(b){return"undefined"===typeof b}function W(b){const a=Array(b);for(let c=0;c<b;c++)a[c]=A();
|
||||
return a}function A(){return Object.create(null)}const v={encode:"icase",c:"forward",split:/\W+/,cache:!1,async:!1,u:!1,m:!1,a:!1,b:9,threshold:0,depth:0},X={memory:{encode:"extra",c:"strict",threshold:0,b:1},speed:{encode:"icase",c:"strict",threshold:1,b:3,depth:2},match:{encode:"extra",c:"full",threshold:1,b:3},score:{encode:"extra",c:"strict",threshold:1,b:9,depth:4},balance:{encode:"balance",c:"strict",threshold:0,b:3,depth:3},fast:{encode:"icase",c:"strict",threshold:8,b:9,depth:1}},U=[];let aa=
|
||||
0;const Y={},Z={};l.create=function(b){return new l(b)};l.registerMatcher=function(b){for(const a in b)b.hasOwnProperty(a)&&U.push(e(a),b[a]);return this};l.registerEncoder=function(b,a){O[b]=a.bind(O);return this};l.registerLanguage=function(b,a){Y[b]=a.filter;Z[b]=a.stemmer;return this};l.encode=function(b,a){return O[b](a)};l.prototype.init=function(b,a){this.o=[];if(a){var c=a.preset;b=a}else b||(b=v),c=b.preset;a={};E(b)?(a=X[b],b={}):c&&(a=X[c]);this.c=b.tokenize||a.c||this.c||v.c;this.split=
|
||||
0);q--;)if(r=R[q]){for(t=r.length;k<t;k++)if(d=r[k],!g||!M["@"+d])if(p[B++]=d,a&&B===a)return I(c,q+":"+k,p);k=0}}else n&&(f&&"not"===f[0]||(p=b[0]));a&&(g=c?parseInt(c,10):0,h=g+a,h<p.length?p=p.slice(g,h):g&&(p=p.slice(g)));return I(c,h,p)}function E(b){return"string"===typeof b}function w(b){return b.constructor===Array}function H(b){return"function"===typeof b}function K(b){return"object"===typeof b}function N(b){return"undefined"===typeof b}function W(b){const a=Array(b);for(let c=0;c<b;c++)a[c]=
|
||||
A();return a}function A(){return Object.create(null)}const v={encode:"icase",c:"forward",split:/\W+/,cache:!1,async:!1,u:!1,m:!1,a:!1,b:9,threshold:0,depth:0},X={memory:{encode:"extra",c:"strict",threshold:0,b:1},speed:{encode:"icase",c:"strict",threshold:1,b:3,depth:2},match:{encode:"extra",c:"full",threshold:1,b:3},score:{encode:"extra",c:"strict",threshold:1,b:9,depth:4},balance:{encode:"balance",c:"strict",threshold:0,b:3,depth:3},fast:{encode:"icase",c:"strict",threshold:8,b:9,depth:1}},U=[];
|
||||
let aa=0;const Y={},Z={};l.create=function(b){return new l(b)};l.registerMatcher=function(b){for(const a in b)b.hasOwnProperty(a)&&U.push(e(a),b[a]);return this};l.registerEncoder=function(b,a){O[b]=a.bind(O);return this};l.registerLanguage=function(b,a){Y[b]=a.filter;Z[b]=a.stemmer;return this};l.encode=function(b,a){return O[b](a)};l.prototype.init=function(b,a){this.o=[];if(a){var c=a.preset;b=a}else b||(b=v),c=b.preset;a={};E(b)?(a=X[b],b={}):c&&(a=X[c]);this.c=b.tokenize||a.c||this.c||v.c;this.split=
|
||||
b.split||this.split||v.split;this.m=b.rtl||this.m||v.m;this.async="undefined"===typeof Promise||N(c=b.async)?this.async||v.async:c;this.threshold=N(c=b.threshold)?a.threshold||this.threshold||v.threshold:c;this.b=N(c=b.resolution)?c=a.b||this.b||v.b:c;c<=this.threshold&&(this.b=this.threshold+1);this.depth="strict"!==this.c||N(c=b.depth)?a.depth||this.depth||v.depth:c;this.i=(c=N(c=b.encode)?a.encode||v.encode:c)&&O[c]&&O[c].bind(O)||(H(c)?c:this.i||!1);(c=b.matcher)&&this.addMatcher(c);if(c=b.filter){E(c)&&
|
||||
(c=Y[c]);if(w(c)){a=this.i;var d=A();for(var f=0;f<c.length;f++){var m=a?a(c[f]):c[f];d[m]=1}c=d}this.filter=c}if(c=b.stemmer){var g;a=E(c)?Z[c]:c;d=this.i;f=[];for(g in a)a.hasOwnProperty(g)&&(m=d?d(g):g,f.push(e(m+"($|\\W)"),d?d(a[g]):a[g]));this.stemmer=g=f}this.a=d=(c=b.doc)?c:this.a||v.a;this.l=W(this.b-(this.threshold||0));this.h=A();this.f=A();if(d&&(this.g=A(),b.doc=null,g=d.index={},c=d.keys=[],a=d.field,w(d.id)||(d.id=d.id.split(":")),a)){let e;w(a)||(K(a)?(e=a,d.field=a=Object.keys(a)):
|
||||
d.field=a=[a]);for(d=0;d<a.length;d++)f=a[d],w(f)||(e&&(b=e[f]),c[d]=f,a[d]=f.split(":")),g[f]=new l(b),g[f].g=this.g}return this};l.prototype.encode=function(b){b&&U.length&&(b=J(b,U));b&&this.o.length&&(b=J(b,this.o));b&&this.i&&(b=this.i(b));b&&this.stemmer&&(b=J(b,this.stemmer));return b};l.prototype.addMatcher=function(b){const a=this.o;for(const c in b)b.hasOwnProperty(c)&&a.push(e(c),b[c]);return this};l.prototype.add=function(b,a,c,d,f){if(this.a&&K(b))return this.j("add",b,a);if(a&&E(a)&&
|
||||
|
8
dist/flexsearch.es5.js
vendored
8
dist/flexsearch.es5.js
vendored
@@ -20,10 +20,10 @@ this.cache&&this.v.set(a,c);return c}function f(a,b,c){Object.defineProperty(a,b
|
||||
g?delete a[w]:e.splice(d,1);break}else M(e[d])&&X(e[d],b)}}function Y(a){for(var b="",c="",h="",l=0;l<a.length;l++){var e=a[l];if(e!==c)if(l&&"h"===e){if(h="a"===h||"e"===h||"i"===h||"o"===h||"u"===h||"y"===h,("a"===c||"e"===c||"i"===c||"o"===c||"u"===c||"y"===c)&&h||" "===c)b+=e}else b+=e;h=l===a.length-1?"":a[l+1];c=e}return b}function pa(a,b){a=a.length-b.length;return 0>a?1:a?-1:0}function qa(a,b){a=a[D];b=b[D];return a<b?-1:a>b?1:0}function ra(a,b){for(var c=D.length,h=0;h<c;h++)a=a[D[h]],b=
|
||||
b[D[h]];return a<b?-1:a>b?1:0}function G(a,b,c){return a?{page:a,next:b?""+b:null,result:c}:c}function ha(a,b,c,h,l,e,d){var w=[],g=a.length;if(!0===c){c="0";var f=""}else f=c&&c.split(":");if(1<g){var T=E(),t=[],k,n=-1,r,y=!0,v=0;if(f)if(2===f.length){var z=f;f=!1}else f=parseInt(f[0],10);if(d){for(k=E();++n<g;)if("not"===l[n]){var q=a[n];var A=q.length;for(r=0;r<A;)k["@"+q[r++]]=1}else var p=n+1;if(H(p))return G(c,D,w);n=-1}else var x=N(l)&&l;for(var u;++n<g;){var I=n===(p||g)-1;if(!x||!n)if((r=
|
||||
x||l&&l[n])&&"and"!==r)if("or"===r)u=!1;else continue;else u=e=!0;q=a[n];if(A=q.length){if(y)if(J){var F=J.length;for(r=0;r<F;){y=J[r++];var K="@"+y;d&&k[K]||(T[K]=1,e||(w[v++]=y))}var J=null;y=!1}else{J=q;continue}K=!1;for(r=0;r<A;){F=q[r++];var L="@"+F,C=e?T[L]:n;if(!(!C||d&&k[L]||!e&&T[L]))if(C===n){if(I){if(!f||--f<v)if(w[v++]=F,b&&v===b)return G(c,v,w)}else T[L]=n+1;K=!0}else h&&(L=t[C]||(t[C]=[]),L[L.length]=F)}if(u&&!K&&!h)break}else if(u&&!h)return G(c,D,q)}if(J)if(n=J.length,d)for(r=f?parseInt(f,
|
||||
10):0;r<n;){if(a=J[r++],!k["@"+a]&&(!f||--f<v)&&(w[v++]=a,b&&v===b))return G(c,r,w)}else w=J;if(h)for(v=w.length,z?(n=parseInt(z[0],10)+1,r=parseInt(z[1],10)):(n=t.length,r=0);n--;)if(F=t[n])for(A=F.length;r<A;r++)if(h=F[r],!d||!k["@"+h])if(w[v++]=h,b&&v===b)return G(c,n+":"+r,w)}else g&&(l&&"not"===l[0]||(w=a[0]));if(b){d=c?parseInt(c,10):0;var D=d+b;D<w.length?w=w.slice(d,D):d&&(w=w.slice(d))}return G(c,D,w)}function N(a){return"string"===typeof a}function I(a){return a.constructor===Array}function R(a){return"function"===
|
||||
typeof a}function M(a){return"object"===typeof a}function H(a){return"undefined"===typeof a}function ia(a){for(var b=Array(a),c=0;c<a;c++)b[c]=E();return b}function E(){return Object.create(null)}function ua(){var a,b;self.onmessage=function(c){if(c=c.data)if(c.search){var h=b.search(c.content,c.threshold?{limit:c.limit,threshold:c.threshold,where:c.where}:c.limit);self.postMessage({id:a,content:c.content,limit:c.limit,result:h})}else c.add?b.add(c.id,c.content):c.update?b.update(c.id,c.content):
|
||||
c.remove?b.remove(c.id):c.clear?b.clear():c.info?(c=b.info(),c.worker=a,console.log(c)):c.register&&(a=c.id,c.options.cache=!1,c.options.async=!1,c.options.worker=!1,b=(new Function(c.register.substring(c.register.indexOf("{")+1,c.register.lastIndexOf("}"))))(),b=new b(c.options))}}function va(a,b,c,h){a=d("flexsearch","id"+a,ua,function(a){(a=a.data)&&a.result&&h(a.id,a.content,a.result,a.limit,a.where,a.cursor,a.suggest)},b);var e=sa.toString();c.id=b;a.postMessage({register:e,options:c,id:b});
|
||||
return a}var u={encode:"icase",h:"forward",split:/\W+/,cache:!1,async:!1,i:!1,G:!1,a:!1,c:9,threshold:0,depth:0},ja={memory:{encode:"extra",h:"strict",threshold:0,c:1},speed:{encode:"icase",h:"strict",threshold:1,c:3,depth:2},match:{encode:"extra",h:"full",threshold:1,c:3},score:{encode:"extra",h:"strict",threshold:1,c:9,depth:4},balance:{encode:"balance",h:"strict",threshold:0,c:3,depth:3},fast:{encode:"icase",h:"strict",threshold:8,c:9,depth:1}},S=[],ta=0,ka={},la={};g.create=function(a){return new g(a)};
|
||||
10):0;r<n;){if(a=J[r++],!k["@"+a]&&(!f||--f<v)&&(w[v++]=a,b&&v===b))return G(c,r,w)}else w=J;if(h)for(v=w.length,z?(n=parseInt(z[0],10)+1,r=parseInt(z[1],10)):(n=t.length,r=0);n--;)if(F=t[n]){for(A=F.length;r<A;r++)if(h=F[r],!d||!k["@"+h])if(w[v++]=h,b&&v===b)return G(c,n+":"+r,w);r=0}}else g&&(l&&"not"===l[0]||(w=a[0]));if(b){d=c?parseInt(c,10):0;var D=d+b;D<w.length?w=w.slice(d,D):d&&(w=w.slice(d))}return G(c,D,w)}function N(a){return"string"===typeof a}function I(a){return a.constructor===Array}
|
||||
function R(a){return"function"===typeof a}function M(a){return"object"===typeof a}function H(a){return"undefined"===typeof a}function ia(a){for(var b=Array(a),c=0;c<a;c++)b[c]=E();return b}function E(){return Object.create(null)}function ua(){var a,b;self.onmessage=function(c){if(c=c.data)if(c.search){var h=b.search(c.content,c.threshold?{limit:c.limit,threshold:c.threshold,where:c.where}:c.limit);self.postMessage({id:a,content:c.content,limit:c.limit,result:h})}else c.add?b.add(c.id,c.content):c.update?
|
||||
b.update(c.id,c.content):c.remove?b.remove(c.id):c.clear?b.clear():c.info?(c=b.info(),c.worker=a,console.log(c)):c.register&&(a=c.id,c.options.cache=!1,c.options.async=!1,c.options.worker=!1,b=(new Function(c.register.substring(c.register.indexOf("{")+1,c.register.lastIndexOf("}"))))(),b=new b(c.options))}}function va(a,b,c,h){a=d("flexsearch","id"+a,ua,function(a){(a=a.data)&&a.result&&h(a.id,a.content,a.result,a.limit,a.where,a.cursor,a.suggest)},b);var e=sa.toString();c.id=b;a.postMessage({register:e,
|
||||
options:c,id:b});return a}var u={encode:"icase",h:"forward",split:/\W+/,cache:!1,async:!1,i:!1,G:!1,a:!1,c:9,threshold:0,depth:0},ja={memory:{encode:"extra",h:"strict",threshold:0,c:1},speed:{encode:"icase",h:"strict",threshold:1,c:3,depth:2},match:{encode:"extra",h:"full",threshold:1,c:3},score:{encode:"extra",h:"strict",threshold:1,c:9,depth:4},balance:{encode:"balance",h:"strict",threshold:0,c:3,depth:3},fast:{encode:"icase",h:"strict",threshold:8,c:9,depth:1}},S=[],ta=0,ka={},la={};g.create=function(a){return new g(a)};
|
||||
g.registerMatcher=function(a){for(var b in a)a.hasOwnProperty(b)&&S.push(e(b),a[b]);return this};g.registerEncoder=function(a,b){O[a]=b.bind(O);return this};g.registerLanguage=function(a,b){ka[a]=b.filter;la[a]=b.stemmer;return this};g.encode=function(a,b){return O[a](b)};g.prototype.init=function(a,b){this.g=[];if(b){var c=b.preset;a=b}else a||(a=u),c=a.preset;b={};N(a)?((b=ja[a])||console.warn("Preset not found: "+a),a={}):c&&((b=ja[c])||console.warn("Preset not found: "+c));if(c=a.worker)if("undefined"===
|
||||
typeof Worker)a.worker=!1,this.b=null;else{var h=parseInt(c,10)||4;this.w=-1;this.D=0;this.A=[];this.H=null;this.b=Array(h);for(var l=0;l<h;l++)this.b[l]=va(this.id,l,a,k.bind(this))}this.h=a.tokenize||b.h||this.h||u.h;this.split=a.split||this.split||u.split;this.G=a.rtl||this.G||u.G;this.async="undefined"===typeof Promise||H(c=a.async)?this.async||u.async:c;this.i=H(c=a.worker)?this.i||u.i:c;this.threshold=H(c=a.threshold)?b.threshold||this.threshold||u.threshold:c;this.c=H(c=a.resolution)?c=b.c||
|
||||
this.c||u.c:c;c<=this.threshold&&(this.c=this.threshold+1);this.depth="strict"!==this.h||H(c=a.depth)?b.depth||this.depth||u.depth:c;this.j=(c=H(c=a.encode)?b.encode||u.encode:c)&&O[c]&&O[c].bind(O)||(R(c)?c:this.j||!1);(c=a.matcher)&&this.addMatcher(c);if(c=a.filter){N(c)&&(c=ka[c]);if(I(c)){b=this.j;h=E();for(l=0;l<c.length;l++){var d=b?b(c[l]):c[l];h[d]=1}c=h}this.filter=c}if(c=a.stemmer){b=N(c)?la[c]:c;h=this.j;l=[];for(var f in b)b.hasOwnProperty(f)&&(d=h?h(f):f,l.push(e(d+"($|\\W)"),h?h(b[f]):
|
||||
|
26
dist/flexsearch.min.js
vendored
26
dist/flexsearch.min.js
vendored
@@ -11,19 +11,19 @@ ha)),c.sort(d));c=L(r,p,c);this.cache&&this.l.set(a,c);return c}function O(a,b,c
|
||||
0,d=f.length;c<d;c++)if(f[c]===b){1===d?delete a[e]:f.splice(c,1);break}else F(f[c])&&W(f[c],b)}}}function X(a){let b="",c="";var d="";for(let e=0;e<a.length;e++){const g=a[e];if(g!==c)if(e&&"h"===g){if(d="a"===d||"e"===d||"i"===d||"o"===d||"u"===d||"y"===d,("a"===c||"e"===c||"i"===c||"o"===c||"u"===c||"y"===c)&&d||" "===c)b+=g}else b+=g;d=e===a.length-1?"":a[e+1];c=g}return b}function ia(a,b){a=a.length-b.length;return 0>a?1:a?-1:0}function ha(a,b){a=a[E];b=b[E];return a<b?-1:a>b?1:0}function fa(a,
|
||||
b){const c=E.length;for(let d=0;d<c;d++)a=a[E[d]],b=b[E[d]];return a<b?-1:a>b?1:0}function L(a,b,c){return a?{page:a,next:b?""+b:null,result:c}:c}function Y(a,b,c,d,e,g,f){let r,q=[],n;const p=a.length;!0===c?(c="0",n=""):n=c&&c.split(":");if(1<p){const U=u();let G=[],B,K;var m=-1,k;let v;var h=!0;let H,C=0,w,y,x;n&&(2===n.length?(x=n,n=!1):n=parseInt(n[0],10));if(f){for(B=u();++m<p;)if("not"===e[m])for(K=a[m],v=K.length,k=0;k<v;)B["@"+K[k++]]=1;else y=m+1;if(D(y))return L(c,r,q);m=-1}else w=I(e)&&
|
||||
e;let z;for(;++m<p;){const Q=m===(y||p)-1;if(!w||!m)if((k=w||e&&e[m])&&"and"!==k)if("or"===k)z=!1;else continue;else z=g=!0;K=a[m];if(v=K.length){if(h)if(H){var t=H.length;for(k=0;k<t;){h=H[k++];var l="@"+h;f&&B[l]||(U[l]=1,g||(q[C++]=h))}H=null;h=!1}else{H=K;continue}l=!1;for(k=0;k<v;){t=K[k++];var A="@"+t;const a=g?U[A]:m;if(!(!a||f&&B[A]||!g&&U[A]))if(a===m){if(Q){if(!n||--n<C)if(q[C++]=t,b&&C===b)return L(c,C,q)}else U[A]=m+1;l=!0}else d&&(A=G[a]||(G[a]=[]),A[A.length]=t)}if(z&&!l&&!d)break}else if(z&&
|
||||
!d)return L(c,r,K)}if(H)if(m=H.length,f)for(k=n?parseInt(n,10):0;k<m;){if(a=H[k++],!B["@"+a]&&(!n||--n<C)&&(q[C++]=a,b&&C===b))return L(c,k,q)}else q=H;if(d)for(C=q.length,x?(m=parseInt(x[0],10)+1,k=parseInt(x[1],10)):(m=G.length,k=0);m--;)if(t=G[m])for(v=t.length;k<v;k++)if(d=t[k],!f||!B["@"+d])if(q[C++]=d,b&&C===b)return L(c,m+":"+k,q)}else p&&(e&&"not"===e[0]||(q=a[0]));b&&(f=c?parseInt(c,10):0,r=f+b,r<q.length?q=q.slice(f,r):f&&(q=q.slice(f)));return L(c,r,q)}function I(a){return"string"===typeof a}
|
||||
function y(a){return a.constructor===Array}function J(a){return"function"===typeof a}function F(a){return"object"===typeof a}function D(a){return"undefined"===typeof a}function Z(a){const b=Array(a);for(let c=0;c<a;c++)b[c]=u();return b}function u(){return Object.create(null)}function ja(){let a,b;self.onmessage=function(c){if(c=c.data)if(c.search){const d=b.search(c.content,c.threshold?{limit:c.limit,threshold:c.threshold,where:c.where}:c.limit);self.postMessage({id:a,content:c.content,limit:c.limit,
|
||||
result:d})}else c.add?b.add(c.id,c.content):c.update?b.update(c.id,c.content):c.remove?b.remove(c.id):c.clear?b.clear():c.info?(c=b.info(),c.worker=a,console.log(c)):c.register&&(a=c.id,c.options.cache=!1,c.options.async=!1,c.options.worker=!1,b=(new Function(c.register.substring(c.register.indexOf("{")+1,c.register.lastIndexOf("}"))))(),b=new b(c.options))}}function ka(a,b,c,d){a=x("flexsearch","id"+a,ja,function(a){(a=a.data)&&a.result&&d(a.id,a.content,a.result,a.limit,a.where,a.cursor,a.suggest)},
|
||||
b);const e=da.toString();c.id=b;a.postMessage({register:e,options:c,id:b});return a}const w={encode:"icase",f:"forward",split:/\W+/,cache:!1,async:!1,g:!1,D:!1,a:!1,b:9,threshold:0,depth:0},aa={memory:{encode:"extra",f:"strict",threshold:0,b:1},speed:{encode:"icase",f:"strict",threshold:1,b:3,depth:2},match:{encode:"extra",f:"full",threshold:1,b:3},score:{encode:"extra",f:"strict",threshold:1,b:9,depth:4},balance:{encode:"balance",f:"strict",threshold:0,b:3,depth:3},fast:{encode:"icase",f:"strict",
|
||||
threshold:8,b:9,depth:1}},V=[];let ea=0;const ba={},ca={};l.create=function(a){return new l(a)};l.registerMatcher=function(a){for(const b in a)a.hasOwnProperty(b)&&V.push(h(b),a[b]);return this};l.registerEncoder=function(a,b){R[a]=b.bind(R);return this};l.registerLanguage=function(a,b){ba[a]=b.filter;ca[a]=b.stemmer;return this};l.encode=function(a,b){return R[a](b)};l.prototype.init=function(a,b){this.v=[];if(b){var c=b.preset;a=b}else a||(a=w),c=a.preset;b={};I(a)?(b=aa[a],a={}):c&&(b=aa[c]);if(c=
|
||||
a.worker)if("undefined"===typeof Worker)a.worker=!1,this.m=null;else{var d=parseInt(c,10)||4;this.C=-1;this.u=0;this.o=[];this.F=null;this.m=Array(d);for(var e=0;e<d;e++)this.m[e]=ka(this.id,e,a,z.bind(this))}this.f=a.tokenize||b.f||this.f||w.f;this.split=a.split||this.split||w.split;this.D=a.rtl||this.D||w.D;this.async="undefined"===typeof Promise||D(c=a.async)?this.async||w.async:c;this.g=D(c=a.worker)?this.g||w.g:c;this.threshold=D(c=a.threshold)?b.threshold||this.threshold||w.threshold:c;this.b=
|
||||
D(c=a.resolution)?c=b.b||this.b||w.b:c;c<=this.threshold&&(this.b=this.threshold+1);this.depth="strict"!==this.f||D(c=a.depth)?b.depth||this.depth||w.depth:c;this.w=(c=D(c=a.encode)?b.encode||w.encode:c)&&R[c]&&R[c].bind(R)||(J(c)?c:this.w||!1);(c=a.matcher)&&this.addMatcher(c);if(c=a.filter){I(c)&&(c=ba[c]);if(y(c)){b=this.w;d=u();for(e=0;e<c.length;e++){var g=b?b(c[e]):c[e];d[g]=1}c=d}this.filter=c}if(c=a.stemmer){var f;b=I(c)?ca[c]:c;d=this.w;e=[];for(f in b)b.hasOwnProperty(f)&&(g=d?d(f):f,e.push(h(g+
|
||||
"($|\\W)"),d?d(b[f]):b[f]));this.stemmer=f=e}this.a=e=(c=a.doc)?c:this.a||w.a;this.j=Z(this.b-(this.threshold||0));this.i=u();this.c=u();if(e){this.h=u();a.doc=null;f=e.index={};b=e.keys=[];d=e.field;g=e.tag;y(e.id)||(e.id=e.id.split(":"));if(g){this.G=u();let b=u();if(d)if(I(d))b[d]=a;else if(y(d))for(let c=0;c<d.length;c++)b[d[c]]=a;else F(d)&&(b=d);y(g)||(e.tag=g=[g]);for(d=0;d<g.length;d++)this.G[g[d]]=u();this.I=g;d=b}if(d){let c;y(d)||(F(d)?(c=d,e.field=d=Object.keys(d)):e.field=d=[d]);for(e=
|
||||
0;e<d.length;e++)g=d[e],y(g)||(c&&(a=c[g]),b[e]=g,d[e]=g.split(":")),f[g]=new l(a),f[g].h=this.h}}this.B=!0;this.l=(this.cache=c=D(c=a.cache)?this.cache||w.cache:c)?new la(c):!1;return this};l.prototype.encode=function(a){a&&V.length&&(a=M(a,V));a&&this.v.length&&(a=M(a,this.v));a&&this.w&&(a=this.w(a));a&&this.stemmer&&(a=M(a,this.stemmer));return a};l.prototype.addMatcher=function(a){const b=this.v;for(const c in a)a.hasOwnProperty(c)&&b.push(h(c),a[c]);return this};l.prototype.add=function(a,b,
|
||||
c,d,e){if(this.a&&F(a))return this.A("add",a,b);if(b&&I(b)&&(a||0===a)){var g="@"+a;if(this.c[g]&&!d)return this.update(a,b);if(this.g)return++this.C>=this.m.length&&(this.C=0),this.m[this.C].postMessage({add:!0,id:a,content:b}),this.c[g]=""+this.C,c&&c(),this;if(!e){if(this.async&&"function"!==typeof importScripts){let e=this;g=new Promise(function(c){setTimeout(function(){e.add(a,b,null,d,!0);e=null;c()})});if(c)g.then(c);else return g;return this}if(c)return this.add(a,b,null,d,!0),c(),this}b=
|
||||
this.encode(b);if(!b.length)return this;c=this.f;e=J(c)?c(b):b.split(this.split);this.filter&&(e=P(e,this.filter));const m=u();m._ctx=u();const k=e.length,h=this.threshold,l=this.depth,v=this.b,A=this.j,Q=this.D;for(let b=0;b<k;b++){var f=e[b];if(f){var r=f.length,q=(Q?b+1:k-b)/k,n="";switch(c){case "reverse":case "both":for(var p=r;--p;)n=f[p]+n,T(A,m,n,a,Q?1:(r-p)/r,q,h,v-1);n="";case "forward":for(p=0;p<r;p++)n+=f[p],T(A,m,n,a,Q?(p+1)/r:1,q,h,v-1);break;case "full":for(p=0;p<r;p++){const b=(Q?
|
||||
p+1:r-p)/r;for(let c=r;c>p;c--)n=f.substring(p,c),T(A,m,n,a,b,q,h,v-1)}break;default:if(r=T(A,m,f,a,1,q,h,v-1),l&&1<k&&r>=h)for(r=m._ctx[f]||(m._ctx[f]=u()),f=this.i[f]||(this.i[f]=Z(v-(h||0))),q=b-l,n=b+l+1,0>q&&(q=0),n>k&&(n=k);q<n;q++)q!==b&&T(f,r,e[q],a,0,v-(q<b?b-q:q-b),h,v-1)}}}this.c[g]=1;this.B=!1}return this};l.prototype.A=function(a,b,c){if(y(b))for(let d=0,e=b.length;d<e;d++){if(d===e-1)return this.A(a,b[d],c);this.A(a,b[d])}else{const q=this.a.index,n=this.a.keys;var d=this.a.tag,e=this.a.id;
|
||||
let p;let m;for(var g=0;g<e.length;g++)p=(p||b)[e[g]];if(d){for(e=0;e<d.length;e++){var f=d[e];var h=f.split(":");for(g=0;g<h.length;g++)m=(m||b)[h[g]];m="@"+m}h=this.G[f];h=h[m]||(h[m]=[])}if("remove"===a){delete this.h[p];for(let a=0,b=n.length;a<b;a++){if(a===b-1)return q[n[a]].remove(p,c);q[n[a]].remove(p)}}e=this.a.field;h&&(h[h.length]=b);this.h[p]=b;for(let g=0,h=e.length;g<h;g++){d=e[g];let k;for(f=0;f<d.length;f++)k=(k||b)[d[f]];d=q[n[g]];f="add"===a?d.add:d.update;if(g===h-1)return f.call(d,
|
||||
!d)return L(c,r,K)}if(H)if(m=H.length,f)for(k=n?parseInt(n,10):0;k<m;){if(a=H[k++],!B["@"+a]&&(!n||--n<C)&&(q[C++]=a,b&&C===b))return L(c,k,q)}else q=H;if(d)for(C=q.length,x?(m=parseInt(x[0],10),k=parseInt(x[1],10)):(m=G.length,k=0);m--;)if(t=G[m]){for(v=t.length;k<v;k++)if(d=t[k],!f||!B["@"+d])if(q[C++]=d,b&&C===b)return L(c,m+1+":"+k,q);k=0}}else p&&(e&&"not"===e[0]||(q=a[0]));b&&(f=c?parseInt(c,10):0,r=f+b,r<q.length?q=q.slice(f,r):f&&(q=q.slice(f)));return L(c,r,q)}function I(a){return"string"===
|
||||
typeof a}function y(a){return a.constructor===Array}function J(a){return"function"===typeof a}function F(a){return"object"===typeof a}function D(a){return"undefined"===typeof a}function Z(a){const b=Array(a);for(let c=0;c<a;c++)b[c]=u();return b}function u(){return Object.create(null)}function ja(){let a,b;self.onmessage=function(c){if(c=c.data)if(c.search){const d=b.search(c.content,c.threshold?{limit:c.limit,threshold:c.threshold,where:c.where}:c.limit);self.postMessage({id:a,content:c.content,
|
||||
limit:c.limit,result:d})}else c.add?b.add(c.id,c.content):c.update?b.update(c.id,c.content):c.remove?b.remove(c.id):c.clear?b.clear():c.info?(c=b.info(),c.worker=a,console.log(c)):c.register&&(a=c.id,c.options.cache=!1,c.options.async=!1,c.options.worker=!1,b=(new Function(c.register.substring(c.register.indexOf("{")+1,c.register.lastIndexOf("}"))))(),b=new b(c.options))}}function ka(a,b,c,d){a=x("flexsearch","id"+a,ja,function(a){(a=a.data)&&a.result&&d(a.id,a.content,a.result,a.limit,a.where,a.cursor,
|
||||
a.suggest)},b);const e=da.toString();c.id=b;a.postMessage({register:e,options:c,id:b});return a}const w={encode:"icase",f:"forward",split:/\W+/,cache:!1,async:!1,g:!1,D:!1,a:!1,b:9,threshold:0,depth:0},aa={memory:{encode:"extra",f:"strict",threshold:0,b:1},speed:{encode:"icase",f:"strict",threshold:1,b:3,depth:2},match:{encode:"extra",f:"full",threshold:1,b:3},score:{encode:"extra",f:"strict",threshold:1,b:9,depth:4},balance:{encode:"balance",f:"strict",threshold:0,b:3,depth:3},fast:{encode:"icase",
|
||||
f:"strict",threshold:8,b:9,depth:1}},V=[];let ea=0;const ba={},ca={};l.create=function(a){return new l(a)};l.registerMatcher=function(a){for(const b in a)a.hasOwnProperty(b)&&V.push(h(b),a[b]);return this};l.registerEncoder=function(a,b){R[a]=b.bind(R);return this};l.registerLanguage=function(a,b){ba[a]=b.filter;ca[a]=b.stemmer;return this};l.encode=function(a,b){return R[a](b)};l.prototype.init=function(a,b){this.v=[];if(b){var c=b.preset;a=b}else a||(a=w),c=a.preset;b={};I(a)?(b=aa[a],a={}):c&&
|
||||
(b=aa[c]);if(c=a.worker)if("undefined"===typeof Worker)a.worker=!1,this.m=null;else{var d=parseInt(c,10)||4;this.C=-1;this.u=0;this.o=[];this.F=null;this.m=Array(d);for(var e=0;e<d;e++)this.m[e]=ka(this.id,e,a,z.bind(this))}this.f=a.tokenize||b.f||this.f||w.f;this.split=a.split||this.split||w.split;this.D=a.rtl||this.D||w.D;this.async="undefined"===typeof Promise||D(c=a.async)?this.async||w.async:c;this.g=D(c=a.worker)?this.g||w.g:c;this.threshold=D(c=a.threshold)?b.threshold||this.threshold||w.threshold:
|
||||
c;this.b=D(c=a.resolution)?c=b.b||this.b||w.b:c;c<=this.threshold&&(this.b=this.threshold+1);this.depth="strict"!==this.f||D(c=a.depth)?b.depth||this.depth||w.depth:c;this.w=(c=D(c=a.encode)?b.encode||w.encode:c)&&R[c]&&R[c].bind(R)||(J(c)?c:this.w||!1);(c=a.matcher)&&this.addMatcher(c);if(c=a.filter){I(c)&&(c=ba[c]);if(y(c)){b=this.w;d=u();for(e=0;e<c.length;e++){var g=b?b(c[e]):c[e];d[g]=1}c=d}this.filter=c}if(c=a.stemmer){var f;b=I(c)?ca[c]:c;d=this.w;e=[];for(f in b)b.hasOwnProperty(f)&&(g=d?
|
||||
d(f):f,e.push(h(g+"($|\\W)"),d?d(b[f]):b[f]));this.stemmer=f=e}this.a=e=(c=a.doc)?c:this.a||w.a;this.j=Z(this.b-(this.threshold||0));this.i=u();this.c=u();if(e){this.h=u();a.doc=null;f=e.index={};b=e.keys=[];d=e.field;g=e.tag;y(e.id)||(e.id=e.id.split(":"));if(g){this.G=u();let b=u();if(d)if(I(d))b[d]=a;else if(y(d))for(let c=0;c<d.length;c++)b[d[c]]=a;else F(d)&&(b=d);y(g)||(e.tag=g=[g]);for(d=0;d<g.length;d++)this.G[g[d]]=u();this.I=g;d=b}if(d){let c;y(d)||(F(d)?(c=d,e.field=d=Object.keys(d)):e.field=
|
||||
d=[d]);for(e=0;e<d.length;e++)g=d[e],y(g)||(c&&(a=c[g]),b[e]=g,d[e]=g.split(":")),f[g]=new l(a),f[g].h=this.h}}this.B=!0;this.l=(this.cache=c=D(c=a.cache)?this.cache||w.cache:c)?new la(c):!1;return this};l.prototype.encode=function(a){a&&V.length&&(a=M(a,V));a&&this.v.length&&(a=M(a,this.v));a&&this.w&&(a=this.w(a));a&&this.stemmer&&(a=M(a,this.stemmer));return a};l.prototype.addMatcher=function(a){const b=this.v;for(const c in a)a.hasOwnProperty(c)&&b.push(h(c),a[c]);return this};l.prototype.add=
|
||||
function(a,b,c,d,e){if(this.a&&F(a))return this.A("add",a,b);if(b&&I(b)&&(a||0===a)){var g="@"+a;if(this.c[g]&&!d)return this.update(a,b);if(this.g)return++this.C>=this.m.length&&(this.C=0),this.m[this.C].postMessage({add:!0,id:a,content:b}),this.c[g]=""+this.C,c&&c(),this;if(!e){if(this.async&&"function"!==typeof importScripts){let e=this;g=new Promise(function(c){setTimeout(function(){e.add(a,b,null,d,!0);e=null;c()})});if(c)g.then(c);else return g;return this}if(c)return this.add(a,b,null,d,!0),
|
||||
c(),this}b=this.encode(b);if(!b.length)return this;c=this.f;e=J(c)?c(b):b.split(this.split);this.filter&&(e=P(e,this.filter));const m=u();m._ctx=u();const k=e.length,h=this.threshold,l=this.depth,v=this.b,A=this.j,Q=this.D;for(let b=0;b<k;b++){var f=e[b];if(f){var r=f.length,q=(Q?b+1:k-b)/k,n="";switch(c){case "reverse":case "both":for(var p=r;--p;)n=f[p]+n,T(A,m,n,a,Q?1:(r-p)/r,q,h,v-1);n="";case "forward":for(p=0;p<r;p++)n+=f[p],T(A,m,n,a,Q?(p+1)/r:1,q,h,v-1);break;case "full":for(p=0;p<r;p++){const b=
|
||||
(Q?p+1:r-p)/r;for(let c=r;c>p;c--)n=f.substring(p,c),T(A,m,n,a,b,q,h,v-1)}break;default:if(r=T(A,m,f,a,1,q,h,v-1),l&&1<k&&r>=h)for(r=m._ctx[f]||(m._ctx[f]=u()),f=this.i[f]||(this.i[f]=Z(v-(h||0))),q=b-l,n=b+l+1,0>q&&(q=0),n>k&&(n=k);q<n;q++)q!==b&&T(f,r,e[q],a,0,v-(q<b?b-q:q-b),h,v-1)}}}this.c[g]=1;this.B=!1}return this};l.prototype.A=function(a,b,c){if(y(b))for(let d=0,e=b.length;d<e;d++){if(d===e-1)return this.A(a,b[d],c);this.A(a,b[d])}else{const q=this.a.index,n=this.a.keys;var d=this.a.tag,e=
|
||||
this.a.id;let p;let m;for(var g=0;g<e.length;g++)p=(p||b)[e[g]];if(d){for(e=0;e<d.length;e++){var f=d[e];var h=f.split(":");for(g=0;g<h.length;g++)m=(m||b)[h[g]];m="@"+m}h=this.G[f];h=h[m]||(h[m]=[])}if("remove"===a){delete this.h[p];for(let a=0,b=n.length;a<b;a++){if(a===b-1)return q[n[a]].remove(p,c);q[n[a]].remove(p)}}e=this.a.field;h&&(h[h.length]=b);this.h[p]=b;for(let g=0,h=e.length;g<h;g++){d=e[g];let k;for(f=0;f<d.length;f++)k=(k||b)[d[f]];d=q[n[g]];f="add"===a?d.add:d.update;if(g===h-1)return f.call(d,
|
||||
p,k,c);f.call(d,p,k)}}};l.prototype.update=function(a,b,c){if(this.a&&F(a))return this.A("update",a,b);this.c["@"+a]&&I(b)&&(this.remove(a),this.add(a,b,c,!0));return this};l.prototype.remove=function(a,b,c){if(this.a&&F(a))return this.A("remove",a,b);var d="@"+a;if(this.c[d]){if(this.g)return this.m[this.c[d]].postMessage({remove:!0,id:a}),delete this.c[d],b&&b(),this;if(!c){if(this.async&&"function"!==typeof importScripts){let c=this;d=new Promise(function(b){setTimeout(function(){c.remove(a,null,
|
||||
!0);c=null;b()})});if(b)d.then(b);else return d;return this}if(b)return this.remove(a,null,!0),b(),this}for(b=0;b<this.b-(this.threshold||0);b++)W(this.j[b],a);this.depth&&W(this.i,a);delete this.c[d];this.B=!1}return this};let E;l.prototype.search=function(a,b,c,d){if(F(b)){if(y(b))for(var e=0;e<b.length;e++)b[e].query=a;else b.query=a;a=b;b=0}let g=[],f=a;let h,q,n;if(F(a)&&!y(a)){(c=a.callback||J(b)&&b)&&(f.callback=null);q=a.sort;h=a.page;b=a.limit;var p=a.threshold;n=a.suggest;a=a.query}if(this.a){p=
|
||||
this.a.index;const r=f.where;var m=f.bool||"or",k=f.field;let v=m;let G,B;if(k)y(k)||(k=[k]);else if(y(f)){var l=f;k=[];v=[];for(var t=0;t<f.length;t++)d=f[t],e=d.bool||m,k[t]=d.field,v[t]=e,"not"===e?G=!0:"and"===e&&(B=!0)}else k=this.a.keys;m=k.length;for(t=0;t<m;t++)l&&(f=l[t]),h&&!I(f)&&(f.page=null,f.limit=0),g[t]=p[k[t]].search(f,0);if(c)return c(S.call(this,a,v,g,q,b,n,r,h,B,G));if(this.async){const c=this;return new Promise(function(d){Promise.all(g).then(function(e){d(S.call(c,a,v,e,q,b,
|
||||
|
44
dist/flexsearch.node.js
vendored
44
dist/flexsearch.node.js
vendored
@@ -5,32 +5,32 @@
|
||||
Released under the Apache 2.0 Licence
|
||||
https://github.com/nextapps-de/flexsearch
|
||||
*/
|
||||
'use strict';(function(m,K,L){let H;(H=L.define)&&H.amd?H([],function(){return K}):(H=L.modules)?H[m.toLowerCase()]=K:"object"===typeof exports?module.exports=K:L[m]=K})("FlexSearch",function(){function m(b,a){const c=a?a.id:b&&b.id;this.id=c||0===c?c:aa++;this.init(b,a);H(this,"index",function(){return this.a?Object.keys(this.a.index[this.a.keys[0]].f):Object.keys(this.f)});H(this,"length",function(){return this.index.length})}function K(b,a){const c=b.length,d=I(a),e=[];for(let g=0,f=0;g<c;g++){const c=
|
||||
b[g];if(d&&a(c)||!d&&!a[c])e[f++]=c}return e}function L(b,a,c,d,e,g,f,r,q,l){c=V(c,f?0:e,r,g,a,q,l);let n;r&&(r=c.page,n=c.next,c=c.result);if(f)a=this.where(f,null,e,c);else{a=c;c=this.g;e=a.length;g=Array(e);for(f=0;f<e;f++)g[f]=c[a[f]];a=g}c=a;d&&(I(d)||(x=d.split(":"),1<x.length?d=ba:(x=x[0],d=ca)),c.sort(d));c=M(r,n,c);this.cache&&this.j.set(b,c);return c}function H(b,a,c){Object.defineProperty(b,a,{get:c})}function h(b){return new RegExp(b,"g")}function N(b,a){for(let c=0;c<a.length;c+=2)b=
|
||||
'use strict';(function(n,K,L){let H;(H=L.define)&&H.amd?H([],function(){return K}):(H=L.modules)?H[n.toLowerCase()]=K:"object"===typeof exports?module.exports=K:L[n]=K})("FlexSearch",function(){function n(b,a){const c=a?a.id:b&&b.id;this.id=c||0===c?c:aa++;this.init(b,a);H(this,"index",function(){return this.a?Object.keys(this.a.index[this.a.keys[0]].f):Object.keys(this.f)});H(this,"length",function(){return this.index.length})}function K(b,a){const c=b.length,d=I(a),e=[];for(let g=0,f=0;g<c;g++){const c=
|
||||
b[g];if(d&&a(c)||!d&&!a[c])e[f++]=c}return e}function L(b,a,c,d,e,g,f,r,q,l){c=V(c,f?0:e,r,g,a,q,l);let p;r&&(r=c.page,p=c.next,c=c.result);if(f)a=this.where(f,null,e,c);else{a=c;c=this.g;e=a.length;g=Array(e);for(f=0;f<e;f++)g[f]=c[a[f]];a=g}c=a;d&&(I(d)||(x=d.split(":"),1<x.length?d=ba:(x=x[0],d=ca)),c.sort(d));c=M(r,p,c);this.cache&&this.j.set(b,c);return c}function H(b,a,c){Object.defineProperty(b,a,{get:c})}function h(b){return new RegExp(b,"g")}function N(b,a){for(let c=0;c<a.length;c+=2)b=
|
||||
b.replace(a[c],a[c+1]);return b}function Q(b,a,c,d,e,g,f,r){if(a[c])return a[c];e=e?(r-(f||r/1.5))*g+(f||r/1.5)*e:g;a[c]=e;e>=f&&(b=b[r-(e+.5>>0)],b=b[c]||(b[c]=[]),b[b.length]=d);return e}function T(b,a){if(b){const c=Object.keys(b);for(let d=0,e=c.length;d<e;d++){const e=c[d],f=b[e];if(f)for(let c=0,d=f.length;c<d;c++)if(f[c]===a){1===d?delete b[e]:f.splice(c,1);break}else y(f[c])&&T(f[c],a)}}}function U(b){let a="",c="";var d="";for(let e=0;e<b.length;e++){const g=b[e];if(g!==c)if(e&&"h"===g){if(d=
|
||||
"a"===d||"e"===d||"i"===d||"o"===d||"u"===d||"y"===d,("a"===c||"e"===c||"i"===c||"o"===c||"u"===c||"y"===c)&&d||" "===c)a+=g}else a+=g;d=e===b.length-1?"":b[e+1];c=g}return a}function da(b,a){b=b.length-a.length;return 0>b?1:b?-1:0}function ca(b,a){b=b[x];a=a[x];return b<a?-1:b>a?1:0}function ba(b,a){const c=x.length;for(let d=0;d<c;d++)b=b[x[d]],a=a[x[d]];return b<a?-1:b>a?1:0}function M(b,a,c){return b?{page:b,next:a?""+a:null,result:c}:c}function V(b,a,c,d,e,g,f){let r,q=[],l;const n=b.length;
|
||||
!0===c?(c="0",l=""):l=c&&c.split(":");if(1<n){const R=v();let E=[],B,J;var k=-1,p;let O;var h=!0;let F,C=0,w,u,x;l&&(2===l.length?(x=l,l=!1):l=parseInt(l[0],10));if(f){for(B=v();++k<n;)if("not"===e[k])for(J=b[k],O=J.length,p=0;p<O;)B["@"+J[p++]]=1;else u=k+1;if(D(u))return M(c,r,q);k=-1}else w=G(e)&&e;let y;for(;++k<n;){const z=k===(u||n)-1;if(!w||!k)if((p=w||e&&e[k])&&"and"!==p)if("or"===p)y=!1;else continue;else y=g=!0;J=b[k];if(O=J.length){if(h)if(F){var t=F.length;for(p=0;p<t;){h=F[p++];var m=
|
||||
"@"+h;f&&B[m]||(R[m]=1,g||(q[C++]=h))}F=null;h=!1}else{F=J;continue}m=!1;for(p=0;p<O;){t=J[p++];var A="@"+t;const b=g?R[A]:k;if(!(!b||f&&B[A]||!g&&R[A]))if(b===k){if(z){if(!l||--l<C)if(q[C++]=t,a&&C===a)return M(c,C,q)}else R[A]=k+1;m=!0}else d&&(A=E[b]||(E[b]=[]),A[A.length]=t)}if(y&&!m&&!d)break}else if(y&&!d)return M(c,r,J)}if(F)if(k=F.length,f)for(p=l?parseInt(l,10):0;p<k;){if(b=F[p++],!B["@"+b]&&(!l||--l<C)&&(q[C++]=b,a&&C===a))return M(c,p,q)}else q=F;if(d)for(C=q.length,x?(k=parseInt(x[0],
|
||||
10)+1,p=parseInt(x[1],10)):(k=E.length,p=0);k--;)if(t=E[k])for(O=t.length;p<O;p++)if(d=t[p],!f||!B["@"+d])if(q[C++]=d,a&&C===a)return M(c,k+":"+p,q)}else n&&(e&&"not"===e[0]||(q=b[0]));a&&(f=c?parseInt(c,10):0,r=f+a,r<q.length?q=q.slice(f,r):f&&(q=q.slice(f)));return M(c,r,q)}function G(b){return"string"===typeof b}function w(b){return b.constructor===Array}function I(b){return"function"===typeof b}function y(b){return"object"===typeof b}function D(b){return"undefined"===typeof b}function W(b){const a=
|
||||
"a"===d||"e"===d||"i"===d||"o"===d||"u"===d||"y"===d,("a"===c||"e"===c||"i"===c||"o"===c||"u"===c||"y"===c)&&d||" "===c)a+=g}else a+=g;d=e===b.length-1?"":b[e+1];c=g}return a}function da(b,a){b=b.length-a.length;return 0>b?1:b?-1:0}function ca(b,a){b=b[x];a=a[x];return b<a?-1:b>a?1:0}function ba(b,a){const c=x.length;for(let d=0;d<c;d++)b=b[x[d]],a=a[x[d]];return b<a?-1:b>a?1:0}function M(b,a,c){return b?{page:b,next:a?""+a:null,result:c}:c}function V(b,a,c,d,e,g,f){let r,q=[],l;const p=b.length;
|
||||
!0===c?(c="0",l=""):l=c&&c.split(":");if(1<p){const R=v();let E=[],B,J;var k=-1,m;let O;var h=!0;let F,C=0,w,u,x;l&&(2===l.length?(x=l,l=!1):l=parseInt(l[0],10));if(f){for(B=v();++k<p;)if("not"===e[k])for(J=b[k],O=J.length,m=0;m<O;)B["@"+J[m++]]=1;else u=k+1;if(D(u))return M(c,r,q);k=-1}else w=G(e)&&e;let y;for(;++k<p;){const z=k===(u||p)-1;if(!w||!k)if((m=w||e&&e[k])&&"and"!==m)if("or"===m)y=!1;else continue;else y=g=!0;J=b[k];if(O=J.length){if(h)if(F){var t=F.length;for(m=0;m<t;){h=F[m++];var n=
|
||||
"@"+h;f&&B[n]||(R[n]=1,g||(q[C++]=h))}F=null;h=!1}else{F=J;continue}n=!1;for(m=0;m<O;){t=J[m++];var A="@"+t;const b=g?R[A]:k;if(!(!b||f&&B[A]||!g&&R[A]))if(b===k){if(z){if(!l||--l<C)if(q[C++]=t,a&&C===a)return M(c,C,q)}else R[A]=k+1;n=!0}else d&&(A=E[b]||(E[b]=[]),A[A.length]=t)}if(y&&!n&&!d)break}else if(y&&!d)return M(c,r,J)}if(F)if(k=F.length,f)for(m=l?parseInt(l,10):0;m<k;){if(b=F[m++],!B["@"+b]&&(!l||--l<C)&&(q[C++]=b,a&&C===a))return M(c,m,q)}else q=F;if(d)for(C=q.length,x?(k=parseInt(x[0],
|
||||
10)+1,m=parseInt(x[1],10)):(k=E.length,m=0);k--;)if(t=E[k]){for(O=t.length;m<O;m++)if(d=t[m],!f||!B["@"+d])if(q[C++]=d,a&&C===a)return M(c,k+":"+m,q);m=0}}else p&&(e&&"not"===e[0]||(q=b[0]));a&&(f=c?parseInt(c,10):0,r=f+a,r<q.length?q=q.slice(f,r):f&&(q=q.slice(f)));return M(c,r,q)}function G(b){return"string"===typeof b}function w(b){return b.constructor===Array}function I(b){return"function"===typeof b}function y(b){return"object"===typeof b}function D(b){return"undefined"===typeof b}function W(b){const a=
|
||||
Array(b);for(let c=0;c<b;c++)a[c]=v();return a}function v(){return Object.create(null)}const u={encode:"icase",c:"forward",split:/\W+/,cache:!1,async:!1,C:!1,v:!1,a:!1,b:9,threshold:0,depth:0},X={memory:{encode:"extra",c:"strict",threshold:0,b:1},speed:{encode:"icase",c:"strict",threshold:1,b:3,depth:2},match:{encode:"extra",c:"full",threshold:1,b:3},score:{encode:"extra",c:"strict",threshold:1,b:9,depth:4},balance:{encode:"balance",c:"strict",threshold:0,b:3,depth:3},fast:{encode:"icase",c:"strict",
|
||||
threshold:8,b:9,depth:1}},S=[];let aa=0;const Y={},Z={};m.create=function(b){return new m(b)};m.registerMatcher=function(b){for(const a in b)b.hasOwnProperty(a)&&S.push(h(a),b[a]);return this};m.registerEncoder=function(b,a){P[b]=a.bind(P);return this};m.registerLanguage=function(b,a){Y[b]=a.filter;Z[b]=a.stemmer;return this};m.encode=function(b,a){return P[b](a)};m.prototype.init=function(b,a){this.m=[];if(a){var c=a.preset;b=a}else b||(b=u),c=b.preset;a={};G(b)?(a=X[b],b={}):c&&(a=X[c]);this.c=
|
||||
threshold:8,b:9,depth:1}},S=[];let aa=0;const Y={},Z={};n.create=function(b){return new n(b)};n.registerMatcher=function(b){for(const a in b)b.hasOwnProperty(a)&&S.push(h(a),b[a]);return this};n.registerEncoder=function(b,a){P[b]=a.bind(P);return this};n.registerLanguage=function(b,a){Y[b]=a.filter;Z[b]=a.stemmer;return this};n.encode=function(b,a){return P[b](a)};n.prototype.init=function(b,a){this.m=[];if(a){var c=a.preset;b=a}else b||(b=u),c=b.preset;a={};G(b)?(a=X[b],b={}):c&&(a=X[c]);this.c=
|
||||
b.tokenize||a.c||this.c||u.c;this.split=b.split||this.split||u.split;this.v=b.rtl||this.v||u.v;this.async="undefined"===typeof Promise||D(c=b.async)?this.async||u.async:c;this.threshold=D(c=b.threshold)?a.threshold||this.threshold||u.threshold:c;this.b=D(c=b.resolution)?c=a.b||this.b||u.b:c;c<=this.threshold&&(this.b=this.threshold+1);this.depth="strict"!==this.c||D(c=b.depth)?a.depth||this.depth||u.depth:c;this.o=(c=D(c=b.encode)?a.encode||u.encode:c)&&P[c]&&P[c].bind(P)||(I(c)?c:this.o||!1);(c=
|
||||
b.matcher)&&this.addMatcher(c);if(c=b.filter){G(c)&&(c=Y[c]);if(w(c)){a=this.o;var d=v();for(var e=0;e<c.length;e++){var g=a?a(c[e]):c[e];d[g]=1}c=d}this.filter=c}if(c=b.stemmer){var f;a=G(c)?Z[c]:c;d=this.o;e=[];for(f in a)a.hasOwnProperty(f)&&(g=d?d(f):f,e.push(h(g+"($|\\W)"),d?d(a[f]):a[f]));this.stemmer=f=e}this.a=e=(c=b.doc)?c:this.a||u.a;this.i=W(this.b-(this.threshold||0));this.h=v();this.f=v();if(e){this.g=v();b.doc=null;f=e.index={};a=e.keys=[];d=e.field;g=e.tag;w(e.id)||(e.id=e.id.split(":"));
|
||||
if(g){this.w=v();let a=v();if(d)if(G(d))a[d]=b;else if(w(d))for(let c=0;c<d.length;c++)a[d[c]]=b;else y(d)&&(a=d);w(g)||(e.tag=g=[g]);for(d=0;d<g.length;d++)this.w[g[d]]=v();this.B=g;d=a}if(d){let c;w(d)||(y(d)?(c=d,e.field=d=Object.keys(d)):e.field=d=[d]);for(e=0;e<d.length;e++)g=d[e],w(g)||(c&&(b=c[g]),a[e]=g,d[e]=g.split(":")),f[g]=new m(b),f[g].g=this.g}}this.u=!0;this.j=(this.cache=c=D(c=b.cache)?this.cache||u.cache:c)?new ea(c):!1;return this};m.prototype.encode=function(b){b&&S.length&&(b=
|
||||
N(b,S));b&&this.m.length&&(b=N(b,this.m));b&&this.o&&(b=this.o(b));b&&this.stemmer&&(b=N(b,this.stemmer));return b};m.prototype.addMatcher=function(b){const a=this.m;for(const c in b)b.hasOwnProperty(c)&&a.push(h(c),b[c]);return this};m.prototype.add=function(b,a,c,d,e){if(this.a&&y(b))return this.s("add",b,a);if(a&&G(a)&&(b||0===b)){var g="@"+b;if(this.f[g]&&!d)return this.update(b,a);if(!e){if(this.async&&"function"!==typeof importScripts){let e=this;g=new Promise(function(c){setTimeout(function(){e.add(b,
|
||||
a,null,d,!0);e=null;c()})});if(c)g.then(c);else return g;return this}if(c)return this.add(b,a,null,d,!0),c(),this}a=this.encode(a);if(!a.length)return this;c=this.c;e=I(c)?c(a):a.split(this.split);this.filter&&(e=K(e,this.filter));const k=v();k._ctx=v();const p=e.length,h=this.threshold,t=this.depth,m=this.b,A=this.i,z=this.v;for(let a=0;a<p;a++){var f=e[a];if(f){var r=f.length,q=(z?a+1:p-a)/p,l="";switch(c){case "reverse":case "both":for(var n=r;--n;)l=f[n]+l,Q(A,k,l,b,z?1:(r-n)/r,q,h,m-1);l="";
|
||||
case "forward":for(n=0;n<r;n++)l+=f[n],Q(A,k,l,b,z?(n+1)/r:1,q,h,m-1);break;case "full":for(n=0;n<r;n++){const a=(z?n+1:r-n)/r;for(let c=r;c>n;c--)l=f.substring(n,c),Q(A,k,l,b,a,q,h,m-1)}break;default:if(r=Q(A,k,f,b,1,q,h,m-1),t&&1<p&&r>=h)for(r=k._ctx[f]||(k._ctx[f]=v()),f=this.h[f]||(this.h[f]=W(m-(h||0))),q=a-t,l=a+t+1,0>q&&(q=0),l>p&&(l=p);q<l;q++)q!==a&&Q(f,r,e[q],b,0,m-(q<a?a-q:q-a),h,m-1)}}}this.f[g]=1;this.u=!1}return this};m.prototype.s=function(b,a,c){if(w(a))for(let d=0,e=a.length;d<e;d++){if(d===
|
||||
e-1)return this.s(b,a[d],c);this.s(b,a[d])}else{const q=this.a.index,l=this.a.keys;var d=this.a.tag,e=this.a.id;let n;let k;for(var g=0;g<e.length;g++)n=(n||a)[e[g]];if(d){for(e=0;e<d.length;e++){var f=d[e];var h=f.split(":");for(g=0;g<h.length;g++)k=(k||a)[h[g]];k="@"+k}h=this.w[f];h=h[k]||(h[k]=[])}if("remove"===b){delete this.g[n];for(let a=0,b=l.length;a<b;a++){if(a===b-1)return q[l[a]].remove(n,c);q[l[a]].remove(n)}}e=this.a.field;h&&(h[h.length]=a);this.g[n]=a;for(let g=0,h=e.length;g<h;g++){d=
|
||||
e[g];let k;for(f=0;f<d.length;f++)k=(k||a)[d[f]];d=q[l[g]];f="add"===b?d.add:d.update;if(g===h-1)return f.call(d,n,k,c);f.call(d,n,k)}}};m.prototype.update=function(b,a,c){if(this.a&&y(b))return this.s("update",b,a);this.f["@"+b]&&G(a)&&(this.remove(b),this.add(b,a,c,!0));return this};m.prototype.remove=function(b,a,c){if(this.a&&y(b))return this.s("remove",b,a);var d="@"+b;if(this.f[d]){if(!c){if(this.async&&"function"!==typeof importScripts){let c=this;d=new Promise(function(a){setTimeout(function(){c.remove(b,
|
||||
null,!0);c=null;a()})});if(a)d.then(a);else return d;return this}if(a)return this.remove(b,null,!0),a(),this}for(a=0;a<this.b-(this.threshold||0);a++)T(this.i[a],b);this.depth&&T(this.h,b);delete this.f[d];this.u=!1}return this};let x;m.prototype.search=function(b,a,c,d){if(y(a)){if(w(a))for(var e=0;e<a.length;e++)a[e].query=b;else a.query=b;b=a;a=0}let g=[],f=b;let h,q,l;if(y(b)&&!w(b)){(c=b.callback||I(a)&&a)&&(f.callback=null);q=b.sort;h=b.page;a=b.limit;var n=b.threshold;l=b.suggest;b=b.query}if(this.a){n=
|
||||
this.a.index;const r=f.where;var k=f.bool||"or",p=f.field;let z=k;let E,B;if(p)w(p)||(p=[p]);else if(w(f)){var m=f;p=[];z=[];for(var t=0;t<f.length;t++)d=f[t],e=d.bool||k,p[t]=d.field,z[t]=e,"not"===e?E=!0:"and"===e&&(B=!0)}else p=this.a.keys;k=p.length;for(t=0;t<k;t++)m&&(f=m[t]),h&&!G(f)&&(f.page=null,f.limit=0),g[t]=n[p[t]].search(f,0);if(c)return c(L.call(this,b,z,g,q,a,l,r,h,B,E));if(this.async){const c=this;return new Promise(function(d){Promise.all(g).then(function(e){d(L.call(c,b,z,e,q,a,
|
||||
l,r,h,B,E))})})}return L.call(this,b,z,g,q,a,l,r,h,B,E)}n||(n=this.threshold||0);I(a)?(c=a,a=1E3):a||0===a||(a=1E3);if(!d){if(this.async&&"function"!==typeof importScripts){let b=this;n=new Promise(function(c){setTimeout(function(){c(b.search(f,a,null,!0));b=null})});if(c)n.then(c);else return n;return this}if(c)return c(this.search(f,a,null,!0)),this}if(!b||!G(b))return g;f=b;if(this.cache)if(this.u){if(c=this.j.get(b))return c}else this.j.clear(),this.u=!0;f=this.encode(f);if(!f.length)return g;
|
||||
c=this.c;c=I(c)?c(f):f.split(this.split);this.filter&&(c=K(c,this.filter));m=c.length;d=!0;e=[];const u=v();1<m&&(this.depth?(p=!0,t=c[0],u[t]=1):c.sort(da));if(!p||(k=this.h)[t]){const a=this.b;for(let b=p?1:0;b<m;b++){const f=c[b];if(f){if(!u[f]){const b=[];let c=!1,g=0;if(t=p?k[t]:this.i){let d;for(let e=0;e<a-n;e++)if(d=t[e][f])b[g++]=d,c=!0}if(c)e[e.length]=1<g?b.concat.apply([],b):b[0];else if(!l){d=!1;break}u[f]=1}t=f}}}else d=!1;d&&(g=V(e,a,h,l));this.cache&&this.j.set(b,g);return g};m.prototype.find=
|
||||
function(b,a){return this.where(b,a,1)[0]||null};m.prototype.where=function(b,a,c,d){const e=this.g,g=[];let f=0;let h;var q;if(y(b)){c||(c=a);var l=Object.keys(b);var n=l.length;h=!1;if(1===n&&"id"===l[0])return[e[b.id]];if((q=this.B)&&!d)for(var k=0;k<q.length;k++){var p=q[k],m=b[p];if(!D(m)){d=this.w[p]["@"+m];if(0===--n)return d;l.splice(l.indexOf(p),1);delete b[p];break}}q=Array(n);for(k=0;k<n;k++)q[k]=l[k].split(":")}else{if(I(b)){a=d||Object.keys(e);c=a.length;for(l=0;l<c;l++)n=e[a[l]],b(n)&&
|
||||
(g[f++]=n);return g}if(D(a))return[e[b]];if("id"===b)return[e[a]];l=[b];n=1;q=[b.split(":")];h=!0}d=d||Object.keys(e);k=d.length;for(p=0;p<k;p++){m=e[d[p]];let k=!0;for(let c=0;c<n;c++){h||(a=b[l[c]]);const d=q[c],e=d.length;let f=m;if(1<e)for(let a=0;a<e;a++)f=f[d[a]];else f=f[d[0]];if(f!==a){k=!1;break}}if(k&&(g[f++]=m,c&&f===c))break}return g};m.prototype.info=function(){return{id:this.id,items:this.length,cache:this.cache&&this.cache.l?this.cache.l.length:!1,matcher:S.length+(this.m?this.m.length:
|
||||
0),worker:this.C,threshold:this.threshold,depth:this.depth,resolution:this.b,contextual:this.depth&&"strict"===this.c}};m.prototype.clear=function(){return this.destroy().init()};m.prototype.destroy=function(){this.cache&&(this.j.clear(),this.j=null);this.i=this.h=this.f=null;if(this.a){const b=this.a.keys;for(let a=0;a<b.length;a++)this.a.index[b[a]].destroy();this.a=this.g=null}return this};m.prototype.export=function(){if(this.a){const b=this.a.keys,a=Array(b.length+1);let c=0;for(;c<b.length;c++){const d=
|
||||
this.a.index[b[c]];a[c]=[d.i,d.h,Object.keys(d.f)]}a[c]=this.g;return JSON.stringify(a)}return JSON.stringify([this.i,this.h,Object.keys(this.f)])};m.prototype.import=function(b){b=JSON.parse(b);const a=v();if(this.a){var c=this.a.keys,d=c.length,e=b[0][2];for(var g=0;g<e.length;g++)a[e[g]]=1;for(e=0;e<d;e++)g=this.a.index[c[e]],g.i=b[e][0],g.h=b[e][1],g.f=a,g.g=b[d];this.g=b[d]}else{c=b[2];for(d=0;d<c.length;d++)a[c[d]]=1;this.i=b[0];this.h=b[1];this.f=a}};const P={icase:function(b){return b.toLowerCase()},
|
||||
if(g){this.w=v();let a=v();if(d)if(G(d))a[d]=b;else if(w(d))for(let c=0;c<d.length;c++)a[d[c]]=b;else y(d)&&(a=d);w(g)||(e.tag=g=[g]);for(d=0;d<g.length;d++)this.w[g[d]]=v();this.B=g;d=a}if(d){let c;w(d)||(y(d)?(c=d,e.field=d=Object.keys(d)):e.field=d=[d]);for(e=0;e<d.length;e++)g=d[e],w(g)||(c&&(b=c[g]),a[e]=g,d[e]=g.split(":")),f[g]=new n(b),f[g].g=this.g}}this.u=!0;this.j=(this.cache=c=D(c=b.cache)?this.cache||u.cache:c)?new ea(c):!1;return this};n.prototype.encode=function(b){b&&S.length&&(b=
|
||||
N(b,S));b&&this.m.length&&(b=N(b,this.m));b&&this.o&&(b=this.o(b));b&&this.stemmer&&(b=N(b,this.stemmer));return b};n.prototype.addMatcher=function(b){const a=this.m;for(const c in b)b.hasOwnProperty(c)&&a.push(h(c),b[c]);return this};n.prototype.add=function(b,a,c,d,e){if(this.a&&y(b))return this.s("add",b,a);if(a&&G(a)&&(b||0===b)){var g="@"+b;if(this.f[g]&&!d)return this.update(b,a);if(!e){if(this.async&&"function"!==typeof importScripts){let e=this;g=new Promise(function(c){setTimeout(function(){e.add(b,
|
||||
a,null,d,!0);e=null;c()})});if(c)g.then(c);else return g;return this}if(c)return this.add(b,a,null,d,!0),c(),this}a=this.encode(a);if(!a.length)return this;c=this.c;e=I(c)?c(a):a.split(this.split);this.filter&&(e=K(e,this.filter));const k=v();k._ctx=v();const m=e.length,h=this.threshold,t=this.depth,n=this.b,A=this.i,z=this.v;for(let a=0;a<m;a++){var f=e[a];if(f){var r=f.length,q=(z?a+1:m-a)/m,l="";switch(c){case "reverse":case "both":for(var p=r;--p;)l=f[p]+l,Q(A,k,l,b,z?1:(r-p)/r,q,h,n-1);l="";
|
||||
case "forward":for(p=0;p<r;p++)l+=f[p],Q(A,k,l,b,z?(p+1)/r:1,q,h,n-1);break;case "full":for(p=0;p<r;p++){const a=(z?p+1:r-p)/r;for(let c=r;c>p;c--)l=f.substring(p,c),Q(A,k,l,b,a,q,h,n-1)}break;default:if(r=Q(A,k,f,b,1,q,h,n-1),t&&1<m&&r>=h)for(r=k._ctx[f]||(k._ctx[f]=v()),f=this.h[f]||(this.h[f]=W(n-(h||0))),q=a-t,l=a+t+1,0>q&&(q=0),l>m&&(l=m);q<l;q++)q!==a&&Q(f,r,e[q],b,0,n-(q<a?a-q:q-a),h,n-1)}}}this.f[g]=1;this.u=!1}return this};n.prototype.s=function(b,a,c){if(w(a))for(let d=0,e=a.length;d<e;d++){if(d===
|
||||
e-1)return this.s(b,a[d],c);this.s(b,a[d])}else{const q=this.a.index,l=this.a.keys;var d=this.a.tag,e=this.a.id;let p;let k;for(var g=0;g<e.length;g++)p=(p||a)[e[g]];if(d){for(e=0;e<d.length;e++){var f=d[e];var h=f.split(":");for(g=0;g<h.length;g++)k=(k||a)[h[g]];k="@"+k}h=this.w[f];h=h[k]||(h[k]=[])}if("remove"===b){delete this.g[p];for(let a=0,b=l.length;a<b;a++){if(a===b-1)return q[l[a]].remove(p,c);q[l[a]].remove(p)}}e=this.a.field;h&&(h[h.length]=a);this.g[p]=a;for(let g=0,h=e.length;g<h;g++){d=
|
||||
e[g];let k;for(f=0;f<d.length;f++)k=(k||a)[d[f]];d=q[l[g]];f="add"===b?d.add:d.update;if(g===h-1)return f.call(d,p,k,c);f.call(d,p,k)}}};n.prototype.update=function(b,a,c){if(this.a&&y(b))return this.s("update",b,a);this.f["@"+b]&&G(a)&&(this.remove(b),this.add(b,a,c,!0));return this};n.prototype.remove=function(b,a,c){if(this.a&&y(b))return this.s("remove",b,a);var d="@"+b;if(this.f[d]){if(!c){if(this.async&&"function"!==typeof importScripts){let c=this;d=new Promise(function(a){setTimeout(function(){c.remove(b,
|
||||
null,!0);c=null;a()})});if(a)d.then(a);else return d;return this}if(a)return this.remove(b,null,!0),a(),this}for(a=0;a<this.b-(this.threshold||0);a++)T(this.i[a],b);this.depth&&T(this.h,b);delete this.f[d];this.u=!1}return this};let x;n.prototype.search=function(b,a,c,d){if(y(a)){if(w(a))for(var e=0;e<a.length;e++)a[e].query=b;else a.query=b;b=a;a=0}let g=[],f=b;let h,q,l;if(y(b)&&!w(b)){(c=b.callback||I(a)&&a)&&(f.callback=null);q=b.sort;h=b.page;a=b.limit;var p=b.threshold;l=b.suggest;b=b.query}if(this.a){p=
|
||||
this.a.index;const r=f.where;var k=f.bool||"or",m=f.field;let z=k;let E,B;if(m)w(m)||(m=[m]);else if(w(f)){var n=f;m=[];z=[];for(var t=0;t<f.length;t++)d=f[t],e=d.bool||k,m[t]=d.field,z[t]=e,"not"===e?E=!0:"and"===e&&(B=!0)}else m=this.a.keys;k=m.length;for(t=0;t<k;t++)n&&(f=n[t]),h&&!G(f)&&(f.page=null,f.limit=0),g[t]=p[m[t]].search(f,0);if(c)return c(L.call(this,b,z,g,q,a,l,r,h,B,E));if(this.async){const c=this;return new Promise(function(d){Promise.all(g).then(function(e){d(L.call(c,b,z,e,q,a,
|
||||
l,r,h,B,E))})})}return L.call(this,b,z,g,q,a,l,r,h,B,E)}p||(p=this.threshold||0);I(a)?(c=a,a=1E3):a||0===a||(a=1E3);if(!d){if(this.async&&"function"!==typeof importScripts){let b=this;p=new Promise(function(c){setTimeout(function(){c(b.search(f,a,null,!0));b=null})});if(c)p.then(c);else return p;return this}if(c)return c(this.search(f,a,null,!0)),this}if(!b||!G(b))return g;f=b;if(this.cache)if(this.u){if(c=this.j.get(b))return c}else this.j.clear(),this.u=!0;f=this.encode(f);if(!f.length)return g;
|
||||
c=this.c;c=I(c)?c(f):f.split(this.split);this.filter&&(c=K(c,this.filter));n=c.length;d=!0;e=[];const u=v();1<n&&(this.depth?(m=!0,t=c[0],u[t]=1):c.sort(da));if(!m||(k=this.h)[t]){const a=this.b;for(let b=m?1:0;b<n;b++){const f=c[b];if(f){if(!u[f]){const b=[];let c=!1,g=0;if(t=m?k[t]:this.i){let d;for(let e=0;e<a-p;e++)if(d=t[e][f])b[g++]=d,c=!0}if(c)e[e.length]=1<g?b.concat.apply([],b):b[0];else if(!l){d=!1;break}u[f]=1}t=f}}}else d=!1;d&&(g=V(e,a,h,l));this.cache&&this.j.set(b,g);return g};n.prototype.find=
|
||||
function(b,a){return this.where(b,a,1)[0]||null};n.prototype.where=function(b,a,c,d){const e=this.g,g=[];let f=0;let h;var q;if(y(b)){c||(c=a);var l=Object.keys(b);var p=l.length;h=!1;if(1===p&&"id"===l[0])return[e[b.id]];if((q=this.B)&&!d)for(var k=0;k<q.length;k++){var m=q[k],n=b[m];if(!D(n)){d=this.w[m]["@"+n];if(0===--p)return d;l.splice(l.indexOf(m),1);delete b[m];break}}q=Array(p);for(k=0;k<p;k++)q[k]=l[k].split(":")}else{if(I(b)){a=d||Object.keys(e);c=a.length;for(l=0;l<c;l++)p=e[a[l]],b(p)&&
|
||||
(g[f++]=p);return g}if(D(a))return[e[b]];if("id"===b)return[e[a]];l=[b];p=1;q=[b.split(":")];h=!0}d=d||Object.keys(e);k=d.length;for(m=0;m<k;m++){n=e[d[m]];let k=!0;for(let c=0;c<p;c++){h||(a=b[l[c]]);const d=q[c],e=d.length;let f=n;if(1<e)for(let a=0;a<e;a++)f=f[d[a]];else f=f[d[0]];if(f!==a){k=!1;break}}if(k&&(g[f++]=n,c&&f===c))break}return g};n.prototype.info=function(){return{id:this.id,items:this.length,cache:this.cache&&this.cache.l?this.cache.l.length:!1,matcher:S.length+(this.m?this.m.length:
|
||||
0),worker:this.C,threshold:this.threshold,depth:this.depth,resolution:this.b,contextual:this.depth&&"strict"===this.c}};n.prototype.clear=function(){return this.destroy().init()};n.prototype.destroy=function(){this.cache&&(this.j.clear(),this.j=null);this.i=this.h=this.f=null;if(this.a){const b=this.a.keys;for(let a=0;a<b.length;a++)this.a.index[b[a]].destroy();this.a=this.g=null}return this};n.prototype.export=function(){if(this.a){const b=this.a.keys,a=Array(b.length+1);let c=0;for(;c<b.length;c++){const d=
|
||||
this.a.index[b[c]];a[c]=[d.i,d.h,Object.keys(d.f)]}a[c]=this.g;return JSON.stringify(a)}return JSON.stringify([this.i,this.h,Object.keys(this.f)])};n.prototype.import=function(b){b=JSON.parse(b);const a=v();if(this.a){var c=this.a.keys,d=c.length,e=b[0][2];for(var g=0;g<e.length;g++)a[e[g]]=1;for(e=0;e<d;e++)g=this.a.index[c[e]],g.i=b[e][0],g.h=b[e][1],g.f=a,g.g=b[d];this.g=b[d]}else{c=b[2];for(d=0;d<c.length;d++)a[c[d]]=1;this.i=b[0];this.h=b[1];this.f=a}};const P={icase:function(b){return b.toLowerCase()},
|
||||
simple:function(){const b=[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("\u00e7"),"c",h("\u00df"),"s",h(" & ")," and ",h("[-/]")," ",h("[^a-z0-9 ]"),"",h("\\s+")," "];return function(a){a=N(a.toLowerCase(),b);return" "===a?"":a}}(),advanced:function(){const b=[h("ae"),"a",h("ai"),"ei",h("ay"),
|
||||
"ei",h("ey"),"ei",h("oe"),"o",h("ue"),"u",h("ie"),"i",h("sz"),"s",h("zs"),"s",h("sh"),"s",h("ck"),"k",h("cc"),"k",h("dt"),"t",h("ph"),"f",h("pf"),"f",h("ou"),"o",h("uo"),"u"];return function(a,c){if(!a)return a;a=this.simple(a);2<a.length&&(a=N(a,b));c||1<a.length&&(a=U(a));return a}}(),extra:function(){const b=[h("p"),"b",h("z"),"s",h("[cgq]"),"k",h("n"),"m",h("d"),"t",h("[vw]"),"f",h("[aeiouy]"),""];return function(a){if(!a)return a;a=this.advanced(a,!0);if(1<a.length){a=a.split(" ");for(let c=
|
||||
0;c<a.length;c++){const d=a[c];1<d.length&&(a[c]=d[0]+N(d.substring(1),b))}a=a.join(" ");a=U(a)}return a}}(),balance:function(){const b=[h("[-/]")," ",h("[^a-z0-9 ]"),"",h("\\s+")," "];return function(a){return U(N(a.toLowerCase(),b))}}()},ea=function(){function b(a){this.clear();this.A=!0!==a&&a}b.prototype.clear=function(){this.cache=v();this.count=v();this.index=v();this.l=[]};b.prototype.set=function(a,b){if(this.A&&D(this.cache[a])){let c=this.l.length;if(c===this.A){c--;const a=this.l[c];delete this.cache[a];
|
||||
delete this.count[a];delete this.index[a]}this.index[a]=c;this.l[c]=a;this.count[a]=-1;this.cache[a]=b;this.get(a)}else this.cache[a]=b};b.prototype.get=function(a){const b=this.cache[a];if(this.A&&b){var d=++this.count[a];const b=this.index;let c=b[a];if(0<c){const f=this.l;for(var e=c;this.count[f[--c]]<=d&&-1!==c;);c++;if(c!==e){for(d=e;d>c;d--)e=f[d-1],f[d]=e,b[e]=d;f[c]=a;b[a]=c}}}return b};return b}();return m}(!1),this);
|
||||
delete this.count[a];delete this.index[a]}this.index[a]=c;this.l[c]=a;this.count[a]=-1;this.cache[a]=b;this.get(a)}else this.cache[a]=b};b.prototype.get=function(a){const b=this.cache[a];if(this.A&&b){var d=++this.count[a];const b=this.index;let c=b[a];if(0<c){const f=this.l;for(var e=c;this.count[f[--c]]<=d&&-1!==c;);c++;if(c!==e){for(d=e;d>c;d--)e=f[d-1],f[d]=e,b[e]=d;f[c]=a;b[a]=c}}}return b};return b}();return n}(!1),this);
|
||||
|
@@ -3508,6 +3508,8 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
i = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user