mirror of
https://github.com/nextapps-de/flexsearch.git
synced 2025-08-31 17:42:13 +02:00
v0.6.2 Improve Suggestion, Improve Coverage, Add Tests
This commit is contained in:
14
README.md
14
README.md
@@ -13,8 +13,8 @@
|
||||
<h1></h1>
|
||||
<h3>Web's fastest and most memory-flexible full-text search library with zero dependencies.</h3>
|
||||
|
||||
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.
|
||||
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 <a href="#dictionary">pre-scored lexical dictionary</a> architecture which actually performs queries up to 100,000 times faster than other libraries.
|
||||
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>.
|
||||
@@ -45,19 +45,19 @@ Get Latest (Stable Release):
|
||||
<tr>
|
||||
<td>flexsearch.min.js</td>
|
||||
<td><a href="https://github.com/nextapps-de/flexsearch/raw/master/dist/flexsearch.min.js" target="_blank">Download</a></td>
|
||||
<td><a href="https://rawcdn.githack.com/nextapps-de/flexsearch/8a4c8f849d8f78deed08e2d78c7400c27297deb6/dist/flexsearch.min.js" target="_blank">https://rawcdn.githack.com/nextapps-de/flexsearch/8a4c8f849d8f78deed08e2d78c7400c27297deb6/dist/flexsearch.min.js</a></td>
|
||||
<td><a href="https://rawcdn.githack.com/nextapps-de/flexsearch/master/dist/flexsearch.min.js" target="_blank">https://rawcdn.githack.com/nextapps-de/flexsearch/master/dist/flexsearch.min.js</a></td>
|
||||
</tr>
|
||||
<tr></tr>
|
||||
<tr>
|
||||
<td>flexsearch.light.js</td>
|
||||
<td><a href="https://github.com/nextapps-de/flexsearch/raw/master/dist/flexsearch.light.js" target="_blank">Download</a></td>
|
||||
<td><a href="https://rawcdn.githack.com/nextapps-de/flexsearch/8a4c8f849d8f78deed08e2d78c7400c27297deb6/dist/flexsearch.light.js" target="_blank">https://rawcdn.githack.com/nextapps-de/flexsearch/8a4c8f849d8f78deed08e2d78c7400c27297deb6/dist/flexsearch.light.js</a></td>
|
||||
<td><a href="https://rawcdn.githack.com/nextapps-de/flexsearch/master/dist/flexsearch.light.js" target="_blank">https://rawcdn.githack.com/nextapps-de/flexsearch/master/dist/flexsearch.light.js</a></td>
|
||||
</tr>
|
||||
<tr></tr>
|
||||
<tr>
|
||||
<td>flexsearch.compact.js</td>
|
||||
<td><a href="https://github.com/nextapps-de/flexsearch/raw/master/dist/flexsearch.compact.js" target="_blank">Download</a></td>
|
||||
<td><a href="https://rawcdn.githack.com/nextapps-de/flexsearch/8a4c8f849d8f78deed08e2d78c7400c27297deb6/dist/flexsearch.compact.js" target="_blank">https://rawcdn.githack.com/nextapps-de/flexsearch/8a4c8f849d8f78deed08e2d78c7400c27297deb6/dist/flexsearch.compact.js</a></td>
|
||||
<td><a href="https://rawcdn.githack.com/nextapps-de/flexsearch/master/dist/flexsearch.compact.js" target="_blank">https://rawcdn.githack.com/nextapps-de/flexsearch/master/dist/flexsearch.compact.js</a></td>
|
||||
</tr>
|
||||
<tr></tr>
|
||||
<tr>
|
||||
@@ -203,8 +203,8 @@ All Features:
|
||||
</tr>
|
||||
<tr>
|
||||
<td>File Size (gzip)</td>
|
||||
<td>5.0 kb</td>
|
||||
<td>3.9 kb</td>
|
||||
<td>6.6 kb</td>
|
||||
<td>4.7 kb</td>
|
||||
<td>2.7 kb</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
19
compile.js
19
compile.js
@@ -13,6 +13,8 @@ fs.existsSync("log") || fs.mkdirSync("log");
|
||||
|
||||
var flag_str = "";
|
||||
var language_out;
|
||||
var formatting;
|
||||
var compilation_level;
|
||||
|
||||
var options = (function(argv){
|
||||
|
||||
@@ -31,6 +33,14 @@ var options = (function(argv){
|
||||
|
||||
language_out = val;
|
||||
}
|
||||
else if(index === "FORMATTING"){
|
||||
|
||||
formatting = val;
|
||||
}
|
||||
else if(index === "COMPILATION_LEVEL"){
|
||||
|
||||
compilation_level = val;
|
||||
}
|
||||
else{
|
||||
|
||||
flag_str += " --define='" + index + "=" + val + "'";
|
||||
@@ -50,6 +60,11 @@ var options = (function(argv){
|
||||
|
||||
var parameter = (function(opt){
|
||||
|
||||
if(formatting && !opt["formatting"]){
|
||||
|
||||
opt["formatting"] = formatting;
|
||||
}
|
||||
|
||||
var parameter = '';
|
||||
|
||||
for(var index in opt){
|
||||
@@ -63,7 +78,7 @@ var parameter = (function(opt){
|
||||
return parameter;
|
||||
})({
|
||||
|
||||
compilation_level: "ADVANCED_OPTIMIZATIONS", //"WHITESPACE"
|
||||
compilation_level: compilation_level || "ADVANCED_OPTIMIZATIONS", //"WHITESPACE"
|
||||
use_types_for_optimization: true,
|
||||
new_type_inf: true,
|
||||
jscomp_warning: "newCheckTypes",
|
||||
@@ -80,7 +95,7 @@ var parameter = (function(opt){
|
||||
output_manifest: "log/manifest.log",
|
||||
output_module_dependencies: "log/module_dependencies.log",
|
||||
property_renaming_report: "log/renaming_report.log"
|
||||
//formatting: "PRETTY_PRINT"
|
||||
//formatting: formatting || "DEFAULT" //"PRETTY_PRINT"
|
||||
});
|
||||
|
||||
var release = options["RELEASE"];
|
||||
|
50
dist/flexsearch.compact.js
vendored
50
dist/flexsearch.compact.js
vendored
@@ -1,31 +1,31 @@
|
||||
/*
|
||||
FlexSearch v0.6.1
|
||||
FlexSearch v0.6.2
|
||||
Copyright 2019 Nextapps GmbH
|
||||
Author: Thomas Wilkerling
|
||||
Released under the Apache 2.0 Licence
|
||||
https://github.com/nextapps-de/flexsearch
|
||||
*/
|
||||
'use strict';(function(l,F,G){let x;(x=G.define)&&x.amd?x([],function(){return F}):(x=G.modules)?x[l.toLowerCase()]=F:"object"===typeof exports?module.exports=F:G[l]=F})("FlexSearch",function(){function l(b,a){const c=a?a.id:b&&b.id;this.id=c||0===c?c:aa++;this.init(b,a);x(this,"index",function(){return this.a?Object.keys(this.a.index[this.a.keys[0]].f):Object.keys(this.f)});x(this,"length",function(){return this.index.length})}function F(b,a){const c=b.length,d=H(a),f=[];for(let m=0,g=0;m<c;m++){const c=
|
||||
b[m];if(d&&a(c)||!d&&!a[c])f[g++]=c}return f}function G(b,a,c,d,f,m,g,h,p,e){c=V(c,g?0:f,!1,!1,a,p,e);let n;h&&(h=c.page,n=c.next,c=c.result);if(g)b=this.where(g,null,f,c);else{b=c;a=this.g;c=b.length;f=Array(c);for(m=0;m<c;m++)f[m]=a[b[m]];b=f}c=b;d&&(H(d)||(y=d.split(":"),1<y.length?d=ba:(y=y[0],d=ca)),c.sort(d));return c=I(h,n,c)}function x(b,a,c){Object.defineProperty(b,a,{get:c})}function e(b){return new RegExp(b,"g")}function J(b,a){for(let c=0;c<a.length;c+=2)b=b.replace(a[c],a[c+1]);return b}
|
||||
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)*f:m;a[c]=f;f>=g&&(b=b[h-(f+.5>>0)],b=b[c]||(b[c]=[]),b[b.length]=d);return f}function S(b,a){if(b){const c=Object.keys(b);for(let d=0,f=c.length;d<f;d++){const f=c[d],g=b[f];if(g)for(let c=0,d=g.length;c<d;c++)if(g[c]===a){1===d?delete b[f]:g.splice(c,1);break}else K(g[c])&&S(g[c],a)}}}function T(b){let a="",c="";var d="";for(let f=0;f<b.length;f++){const m=b[f];if(m!==c)if(f&&"h"===m){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+=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);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)&&
|
||||
(b||0===b)){var e="@"+b;if(this.f[e]&&!d)return this.update(b,a);if(!f){if(this.async&&"function"!==typeof importScripts){let f=this;e=new Promise(function(c){setTimeout(function(){f.add(b,a,null,d,!0);f=null;c()})});if(c)e.then(c);else return e;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;f=H(c)?c(a):a.split(this.split);this.filter&&(f=F(f,this.filter));const m=A();m._ctx=A();const k=f.length,l=this.threshold,r=this.depth,t=this.b,z=
|
||||
this.l,L=this.m;for(let a=0;a<k;a++){var g=f[a];if(g){var h=g.length,p=(L?a+1:k-a)/k,u="";switch(c){case "reverse":case "both":for(var n=h;--n;)u=g[n]+u,P(z,m,u,b,L?1:(h-n)/h,p,l,t-1);u="";case "forward":for(n=0;n<h;n++)u+=g[n],P(z,m,u,b,L?(n+1)/h:1,p,l,t-1);break;case "full":for(n=0;n<h;n++){const a=(L?n+1:h-n)/h;for(let c=h;c>n;c--)u=g.substring(n,c),P(z,m,u,b,a,p,l,t-1)}break;default:if(h=P(z,m,g,b,1,p,l,t-1),r&&1<k&&h>=l)for(h=m._ctx[g]||(m._ctx[g]=A()),g=this.h[g]||(this.h[g]=W(t-(l||0))),p=
|
||||
a-r,u=a+r+1,0>p&&(p=0),u>k&&(u=k);p<u;p++)p!==a&&P(g,h,f[p],b,0,t-(p<a?a-p:p-a),l,t-1)}}}this.f[e]=1}return this};l.prototype.j=function(b,a,c){if(w(a))for(let d=0,f=a.length;d<f;d++){if(d===f-1)return this.j(b,a[d],c);this.j(b,a[d])}else{const m=this.a.index,l=this.a.keys;var d=this.a.tag,f=this.a.id;let n;let q;for(var e=0;e<f.length;e++)n=(n||a)[f[e]];if(d){for(f=0;f<d.length;f++){var g=d[f];var h=g.split(":");for(e=0;e<h.length;e++)q=(q||a)[h[e]];q="@"+q}h=this.s[g];h=h[q]||(h[q]=[])}if("remove"===
|
||||
b){delete this.g[n];for(let a=0,b=l.length;a<b;a++){if(a===b-1)return m[l[a]].remove(n,c);m[l[a]].remove(n)}}f=this.a.field;h&&(h[h.length]=a);this.g[n]=a;for(let e=0,h=f.length;e<h;e++){d=f[e];let k;for(g=0;g<d.length;g++)k=(k||a)[d[g]];d=m[l[e]];g="add"===b?d.add:d.update;if(e===h-1)return g.call(d,n,k,c);g.call(d,n,k)}}};l.prototype.update=function(b,a,c){if(this.a&&K(b))return this.j("update",b,a);this.f["@"+b]&&E(a)&&(this.remove(b),this.add(b,a,c,!0));return this};l.prototype.remove=function(b,
|
||||
a,c){if(this.a&&K(b))return this.j("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++)S(this.l[a],b);this.depth&&S(this.h,b);delete this.f[d]}return this};let y;l.prototype.search=function(b,a,c,d){if(K(a)){if(w(a))for(var f=0;f<a.length;f++)a[f].query=
|
||||
b;else a.query=b;b=a;a=0}let e=[],g=b;let h,l,u;if(K(b)&&!w(b)){(c=b.callback||H(a)&&a)&&(g.callback=null);l=b.sort;h=!1;a=b.limit;var n=b.threshold;u=!1;b=b.query}if(this.a){n=this.a.index;var q=g.bool||"or",k=g.field;let m=q;let p,t;if(k)w(k)||(k=[k]);else if(w(g)){var v=g;k=[];m=[];for(var r=0;r<g.length;r++)d=g[r],f=d.bool||q,k[r]=d.field,m[r]=f,"not"===f?p=!0:"and"===f&&(t=!0)}else k=this.a.keys;q=k.length;for(r=0;r<q;r++)v&&(g=v[r]),h&&!E(g)&&(g.page=null,g.limit=0),e[r]=n[k[r]].search(g,0);
|
||||
if(c)return c(G.call(this,b,m,e,l,a,u,!1,h,t,p));if(this.async){const c=this;return new Promise(function(d){Promise.all(e).then(function(e){d(G.call(c,b,m,e,l,a,u,!1,h,t,p))})})}return G.call(this,b,m,e,l,a,u,!1,h,t,p)}n||(n=this.threshold||0);H(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(g,a,null,!0));b=null})});if(c)n.then(c);else return n;return this}if(c)return c(this.search(g,a,
|
||||
null,!0)),this}if(!b||!E(b))return e;g=b;g=this.encode(g);if(!g.length)return e;c=this.c;c=H(c)?c(g):g.split(this.split);this.filter&&(c=F(c,this.filter));v=c.length;d=!0;f=[];const t=A();1<v&&(this.depth?(k=!0,r=c[0],t[r]=1):c.sort(da));if(!k||(q=this.h)[r]){const a=this.b;for(let b=k?1:0;b<v;b++){const e=c[b];if(e){if(!t[e]){const b=[];let c=!1,g=0;if(r=k?q[r]:this.l){let d;for(let f=0;f<a-n;f++)if(d=r[f][e])b[g++]=d,c=!0}if(c)f[f.length]=1<g?b.concat.apply([],b):b[0];else{d=!1;break}t[e]=1}r=e}}}else d=
|
||||
!1;d&&(e=V(f,a,h,!1));return e};l.prototype.clear=function(){return this.destroy().init()};l.prototype.destroy=function(){this.l=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};const O={icase:function(b){return b.toLowerCase()},simple:function(){const b=[e("[\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5]"),"a",e("[\u00e8\u00e9\u00ea\u00eb]"),"e",e("[\u00ec\u00ed\u00ee\u00ef]"),"i",e("[\u00f2\u00f3\u00f4\u00f5\u00f6\u0151]"),
|
||||
"o",e("[\u00f9\u00fa\u00fb\u00fc\u0171]"),"u",e("[\u00fd\u0177\u00ff]"),"y",e("\u00f1"),"n",e("\u00e7"),"c",e("\u00df"),"s",e(" & ")," and ",e("[-/]")," ",e("[^a-z0-9 ]"),"",e("\\s+")," "];return function(a){a=J(a.toLowerCase(),b);return" "===a?"":a}}(),advanced:function(){const b=[e("ae"),"a",e("ai"),"ei",e("ay"),"ei",e("ey"),"ei",e("oe"),"o",e("ue"),"u",e("ie"),"i",e("sz"),"s",e("zs"),"s",e("sh"),"s",e("ck"),"k",e("cc"),"k",e("dt"),"t",e("ph"),"f",e("pf"),"f",e("ou"),"o",e("uo"),"u"];return function(a,
|
||||
c){if(!a)return a;a=this.simple(a);2<a.length&&(a=J(a,b));c||1<a.length&&(a=T(a));return a}}(),extra:function(){const b=[e("p"),"b",e("z"),"s",e("[cgq]"),"k",e("n"),"m",e("d"),"t",e("[vw]"),"f",e("[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]+J(d.substring(1),b))}a=a.join(" ");a=T(a)}return a}}(),balance:function(){const b=[e("[-/]")," ",e("[^a-z0-9 ]"),"",e("\\s+")," "];return function(a){return T(J(a.toLowerCase(),
|
||||
b))}}()};return l}(!1),this);
|
||||
'use strict';(function(n,y,G){let z;(z=G.define)&&z.amd?z([],function(){return y}):(z=G.modules)?z[n.toLowerCase()]=y:"object"===typeof exports?module.exports=y:G[n]=y})("FlexSearch",function(){function n(a,b){const c=b?b.id:a&&a.id;this.id=c||0===c?c:aa++;this.init(a,b);z(this,"index",function(){return this.a?Object.keys(this.a.index[this.a.keys[0]].f):Object.keys(this.f)});z(this,"length",function(){return this.index.length})}function y(a,b){const c=a.length,d=J(b),f=[];for(let k=0,g=0;k<c;k++){const c=
|
||||
a[k];if(d&&b(c)||!d&&!b[c])f[g++]=c}return f}function G(a,b,c,d,f,k,g,p,q,l){c=V(c,g?0:f,!1,!1,b,q,l);let e;p&&(p=c.page,e=c.next,c=c.result);if(g)a=this.where(g,null,f,c);else{a=c;b=this.g;c=a.length;f=Array(c);for(k=0;k<c;k++)f[k]=b[a[k]];a=f}c=a;d&&(J(d)||(x=d.split(":"),1<x.length?d=ba:(x=x[0],d=ca)),c.sort(d));return c=K(p,e,c)}function z(a,b,c){Object.defineProperty(a,b,{get:c})}function e(a){return new RegExp(a,"g")}function H(a,b){for(let c=0;c<b.length;c+=2)a=a.replace(b[c],b[c+1]);return a}
|
||||
function Q(a,b,c,d,f,k,g,p){if(b[c])return b[c];f=f?(p-(g||p/1.5))*k+(g||p/1.5)*f:k;b[c]=f;f>=g&&(a=a[p-(f+.5>>0)],a=a[c]||(a[c]=[]),a[a.length]=d);return f}function S(a,b){if(a){const c=Object.keys(a);for(let d=0,f=c.length;d<f;d++){const f=c[d],g=a[f];if(g)for(let c=0,d=g.length;c<d;c++)if(g[c]===b){1===d?delete a[f]:g.splice(c,1);break}else I(g[c])&&S(g[c],b)}}}function T(a){let b="",c="";var d="";for(let f=0;f<a.length;f++){const k=a[f];if(k!==c)if(f&&"h"===k){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+=k}else b+=k;d=f===a.length-1?"":a[f+1];c=k}return b}function da(a,b){a=a.length-b.length;return 0>a?1:a?-1:0}function ca(a,b){a=a[x];b=b[x];return a<b?-1:a>b?1:0}function ba(a,b){const c=x.length;for(let d=0;d<c;d++)a=a[x[d]],b=b[x[d]];return a<b?-1:a>b?1:0}function K(a,b,c){return a?{page:a,next:b?""+b:null,result:c}:c}function V(a,b,c,d,f,k,g){let p,q=[];if(!0===c){c="0";var l=""}else l=c&&c.split(":");
|
||||
const e=a.length;if(1<e){const r=A();let B=[],M,E;var m=0,h;let O;var R=!0;let C,D=0,u,x,w,z;l&&(2===l.length?(w=l,l=!1):l=z=parseInt(l[0],10));if(g){for(M=A();m<e;m++)if("not"===f[m])for(E=a[m],O=E.length,h=0;h<O;h++)M["@"+E[h]]=1;else x=m+1;if(N(x))return K(c,p,q);m=0}else u=F(f)&&f;let y;for(;m<e;m++){const L=m===(x||e)-1;if(!u||!m)if((h=u||f&&f[m])&&"and"!==h)if("or"===h)y=!1;else continue;else y=k=!0;E=a[m];if(O=E.length){if(R)if(C){var t=C.length;for(h=0;h<t;h++){R=C[h];var n="@"+R;g&&M[n]||
|
||||
(r[n]=1,k||(q[D++]=R))}C=null;R=!1}else{C=E;continue}n=!1;for(h=0;h<O;h++){t=E[h];var v="@"+t;const a=k?r[v]||0:m;if(!(!a&&!d||g&&M[v]||!k&&r[v]))if(a===m){if(L){if(!z||--z<D)if(q[D++]=t,b&&D===b)return K(c,D+(l||0),q)}else r[v]=m+1;n=!0}else d&&(v=B[a]||(B[a]=[]),v[v.length]=t)}if(y&&!n&&!d)break}else if(y&&!d)return K(c,p,E)}if(C)if(m=C.length,g)for(h=l?parseInt(l,10):0;h<m;h++)a=C[h],M["@"+a]||(q[D++]=a);else q=C;if(d)for(D=q.length,w?(m=parseInt(w[0],10)+1,h=parseInt(w[1],10)+1):(m=B.length,h=
|
||||
0);m--;)if(t=B[m]){for(O=t.length;h<O;h++)if(d=t[h],!g||!M["@"+d])if(q[D++]=d,b&&D===b)return K(c,m+":"+h,q);h=0}}else!e||f&&"not"===f[0]||(q=a[0],l&&(l=parseInt(l[0],10)));b&&(g=q.length,l&&l>g&&(l=0),l=l||0,p=l+b,p<g?q=q.slice(l,p):(p=0,l&&(q=q.slice(l))));return K(c,p,q)}function F(a){return"string"===typeof a}function w(a){return a.constructor===Array}function J(a){return"function"===typeof a}function I(a){return"object"===typeof a}function N(a){return"undefined"===typeof a}function W(a){const b=
|
||||
Array(a);for(let c=0;c<a;c++)b[c]=A();return b}function A(){return Object.create(null)}const u={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={};n.create=function(a,b){return new n(a,b)};n.registerMatcher=function(a){for(const b in a)a.hasOwnProperty(b)&&U.push(e(b),a[b]);return this};n.registerEncoder=function(a,b){P[a]=b.bind(P);return this};n.registerLanguage=function(a,b){Y[a]=b.filter;Z[a]=b.stemmer;return this};n.encode=function(a,b){return P[a](b)};n.prototype.init=function(a,b){this.o=[];if(b){var c=b.preset;a=b}else a||(a=u),c=a.preset;b={};F(a)?(b=X[a],a={}):c&&(b=X[c]);this.c=
|
||||
a.tokenize||b.c||this.c||u.c;this.split=a.split||this.split||u.split;this.m=a.rtl||this.m||u.m;this.async="undefined"===typeof Promise||N(c=a.async)?this.async||u.async:c;this.threshold=N(c=a.threshold)?b.threshold||this.threshold||u.threshold:c;this.b=N(c=a.resolution)?c=b.b||this.b||u.b:c;c<=this.threshold&&(this.b=this.threshold+1);this.depth="strict"!==this.c||N(c=a.depth)?b.depth||this.depth||u.depth:c;this.i=(c=N(c=a.encode)?b.encode||u.encode:c)&&P[c]&&P[c].bind(P)||(J(c)?c:this.i||!1);(c=
|
||||
a.matcher)&&this.addMatcher(c);if(c=(b=a.lang)||a.filter){F(c)&&(c=Y[c]);if(w(c)){var d=this.i,f=A();for(var k=0;k<c.length;k++){const a=d?d(c[k]):c[k];f[a]=1}c=f}this.filter=c}if(c=b||a.stemmer){var g;b=F(c)?Z[c]:c;d=this.i;f=[];for(g in b)b.hasOwnProperty(g)&&(k=d?d(g):g,f.push(e(k+"($|\\W)"),d?d(b[g]):b[g]));this.stemmer=g=f}this.a=d=(c=a.doc)?c:this.a||u.a;this.l=W(this.b-(this.threshold||0));this.h=A();this.f=A();if(d&&(this.g=A(),a.doc=null,g=d.index={},c=d.keys=[],b=d.field,w(d.id)||(d.id=
|
||||
d.id.split(":")),b)){let k;w(b)||(I(b)?(k=b,d.field=b=Object.keys(b)):d.field=b=[b]);for(d=0;d<b.length;d++)f=b[d],w(f)||(k&&(a=k[f]),c[d]=f,b[d]=f.split(":")),g[f]=new n(a),g[f].g=this.g}return this};n.prototype.encode=function(a){a&&U.length&&(a=H(a,U));a&&this.o.length&&(a=H(a,this.o));a&&this.i&&(a=this.i(a));a&&this.stemmer&&(a=H(a,this.stemmer));return a};n.prototype.addMatcher=function(a){const b=this.o;for(const c in a)a.hasOwnProperty(c)&&b.push(e(c),a[c]);return this};n.prototype.add=function(a,
|
||||
b,c,d,f){if(this.a&&I(a))return this.j("add",a,b);if(b&&F(b)&&(a||0===a)){var k="@"+a;if(this.f[k]&&!d)return this.update(a,b);if(!f){if(this.async){let f=this;k=new Promise(function(c){setTimeout(function(){f.add(a,b,null,d,!0);f=null;c()})});if(c)k.then(c);else return k;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.c;f=J(c)?c(b):b.split(this.split);this.filter&&(f=y(f,this.filter));const m=A();m._ctx=A();const h=f.length,p=this.threshold,
|
||||
t=this.depth,n=this.b,v=this.l,L=this.m;for(let b=0;b<h;b++){var g=f[b];if(g){var e=g.length,q=(L?b+1:h-b)/h,l="";switch(c){case "reverse":case "both":for(var r=e;--r;)l=g[r]+l,Q(v,m,l,a,L?1:(e-r)/e,q,p,n-1);l="";case "forward":for(r=0;r<e;r++)l+=g[r],Q(v,m,l,a,L?(r+1)/e:1,q,p,n-1);break;case "full":for(r=0;r<e;r++){const b=(L?r+1:e-r)/e;for(let c=e;c>r;c--)l=g.substring(r,c),Q(v,m,l,a,b,q,p,n-1)}break;default:if(e=Q(v,m,g,a,1,q,p,n-1),t&&1<h&&e>=p)for(e=m._ctx[g]||(m._ctx[g]=A()),g=this.h[g]||(this.h[g]=
|
||||
W(n-(p||0))),q=b-t,l=b+t+1,0>q&&(q=0),l>h&&(l=h);q<l;q++)q!==b&&Q(g,e,f[q],a,0,n-(q<b?b-q:q-b),p,n-1)}}}this.f[k]=1}return this};n.prototype.j=function(a,b,c){if(w(b))for(let d=0,f=b.length;d<f;d++){if(d===f-1)return this.j(a,b[d],c);this.j(a,b[d])}else{const k=this.a.index,l=this.a.keys;var d=this.a.tag,f=this.a.id;let r;let m;for(var e=0;e<f.length;e++)r=(r||b)[f[e]];if(d){for(f=0;f<d.length;f++){var g=d[f];var p=g.split(":");for(e=0;e<p.length;e++)m=(m||b)[p[e]];m="@"+m}p=this.s[g];p=p[m]||(p[m]=
|
||||
[])}if("remove"===a){delete this.g[r];for(let b=0,a=l.length;b<a;b++){if(b===a-1)return k[l[b]].remove(r,c),this;k[l[b]].remove(r)}}f=this.a.field;p&&(p[p.length]=b);this.g[r]=b;for(let e=0,m=f.length;e<m;e++){d=f[e];let h;for(g=0;g<d.length;g++)h=(h||b)[d[g]];d=k[l[e]];g="add"===a?d.add:d.update;e===m-1?g.call(d,r,h,c):g.call(d,r,h)}}return this};n.prototype.update=function(a,b,c){if(this.a&&I(a))return this.j("update",a,b);this.f["@"+a]&&F(b)&&(this.remove(a),this.add(a,b,c,!0));return this};n.prototype.remove=
|
||||
function(a,b,c){if(this.a&&I(a))return this.j("remove",a,b);var d="@"+a;if(this.f[d]){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++)S(this.l[b],a);this.depth&&S(this.h,a);delete this.f[d]}return this};let x;n.prototype.search=function(a,b,c,d){if(I(b)){if(w(b))for(var f=
|
||||
0;f<b.length;f++)b[f].query=a;else b.query=a;a=b;b=1E3}else b&&J(b)?(c=b,b=1E3):b||0===b||(b=1E3);let e=[],g=a;let p,q,l;if(I(a)&&!w(a)){c||(c=a.callback)&&(g.callback=null);q=a.sort;p=!1;b=a.limit;var r=a.threshold;l=!1;a=a.query}if(this.a){r=this.a.index;var m=g.bool||"or",h=g.field;let k=m;let B,u;if(h)w(h)||(h=[h]);else if(w(g)){var n=g;h=[];k=[];for(var t=0;t<g.length;t++)d=g[t],f=d.bool||m,h[t]=d.field,k[t]=f,"not"===f?B=!0:"and"===f&&(u=!0)}else h=this.a.keys;m=h.length;for(t=0;t<m;t++)n&&
|
||||
(g=n[t]),p&&!F(g)&&(g.page=null,g.limit=0),e[t]=r[h[t]].search(g,0);if(c)return c(G.call(this,a,k,e,q,b,l,!1,p,u,B));if(this.async){const c=this;return new Promise(function(d){Promise.all(e).then(function(e){d(G.call(c,a,k,e,q,b,l,!1,p,u,B))})})}return G.call(this,a,k,e,q,b,l,!1,p,u,B)}r||(r=this.threshold||0);if(!d){if(this.async&&"function"!==typeof importScripts){let a=this;r=new Promise(function(c){setTimeout(function(){c(a.search(g,b,null,!0));a=null})});if(c)r.then(c);else return r;return this}if(c)return c(this.search(g,
|
||||
b,null,!0)),this}if(!a||!F(a))return e;g=a;g=this.encode(g);if(!g.length)return e;c=this.c;c=J(c)?c(g):g.split(this.split);this.filter&&(c=y(c,this.filter));n=c.length;d=!0;f=[];const u=A();let v=0;1<n&&(this.depth&&"strict"===this.c?h=!0:c.sort(da));if(!h||(m=this.h)){const b=this.b;for(;v<n;v++){let a=c[v];if(a){if(h){if(!t)if(m[a])t=a,u[a]=1;else if(!l)return e;if(l&&v===n-1&&!f.length)h=!1,a=t||a,u[a]=0;else if(!t)continue}if(!u[a]){const c=[];let e=!1,g=0;if(t=h?m[t]:this.l){let d;for(let f=
|
||||
0;f<b-r;f++)if(d=t[f][a])c[g++]=d,e=!0}if(e)t=a,f[f.length]=1<g?c.concat.apply([],c):c[0];else{d=!1;break}u[a]=1}}}}else d=!1;d&&(e=V(f,b,p,!1));return e};n.prototype.clear=function(){return this.destroy().init()};n.prototype.destroy=function(){this.l=this.h=this.f=null;if(this.a){const a=this.a.keys;for(let b=0;b<a.length;b++)this.a.index[a[b]].destroy();this.a=this.g=null}return this};const P={icase:function(a){return a.toLowerCase()},simple:function(){const a=[e("[\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5]"),
|
||||
"a",e("[\u00e8\u00e9\u00ea\u00eb]"),"e",e("[\u00ec\u00ed\u00ee\u00ef]"),"i",e("[\u00f2\u00f3\u00f4\u00f5\u00f6\u0151]"),"o",e("[\u00f9\u00fa\u00fb\u00fc\u0171]"),"u",e("[\u00fd\u0177\u00ff]"),"y",e("\u00f1"),"n",e("\u00e7"),"c",e("\u00df"),"s",e(" & ")," and ",e("[-/]")," ",e("[^a-z0-9 ]"),"",e("\\s+")," "];return function(b){b=H(b.toLowerCase(),a);return" "===b?"":b}}(),advanced:function(){const a=[e("ae"),"a",e("ai"),"ei",e("ay"),"ei",e("ey"),"ei",e("oe"),"o",e("ue"),"u",e("ie"),"i",e("sz"),"s",
|
||||
e("zs"),"s",e("sh"),"s",e("ck"),"k",e("cc"),"k",e("dt"),"t",e("ph"),"f",e("pf"),"f",e("ou"),"o",e("uo"),"u"];return function(b,c){if(!b)return b;b=this.simple(b);2<b.length&&(b=H(b,a));c||1<b.length&&(b=T(b));return b}}(),extra:function(){const a=[e("p"),"b",e("z"),"s",e("[cgq]"),"k",e("n"),"m",e("d"),"t",e("[vw]"),"f",e("[aeiouy]"),""];return function(b){if(!b)return b;b=this.advanced(b,!0);if(1<b.length){b=b.split(" ");for(let c=0;c<b.length;c++){const d=b[c];1<d.length&&(b[c]=d[0]+H(d.substring(1),
|
||||
a))}b=b.join(" ");b=T(b)}return b}}(),balance:function(){const a=[e("[-/]")," ",e("[^a-z0-9 ]"),"",e("\\s+")," "];return function(b){return T(H(b.toLowerCase(),a))}}()};return n}(!1),this);
|
||||
|
86
dist/flexsearch.es5.js
vendored
86
dist/flexsearch.es5.js
vendored
@@ -1,49 +1,49 @@
|
||||
/*
|
||||
FlexSearch v0.6.1
|
||||
FlexSearch v0.6.2
|
||||
Copyright 2019 Nextapps GmbH
|
||||
Author: Thomas Wilkerling
|
||||
Released under the Apache 2.0 Licence
|
||||
https://github.com/nextapps-de/flexsearch
|
||||
*/
|
||||
'use strict';function ba(d){var m=0;return function(){return m<d.length?{done:!1,value:d[m++]}:{done:!0}}}var ca="function"==typeof Object.defineProperties?Object.defineProperty:function(d,m,g){d!=Array.prototype&&d!=Object.prototype&&(d[m]=g.value)},P="undefined"!=typeof window&&window===this?this:"undefined"!=typeof global&&null!=global?global:this;function da(){da=function(){};P.Symbol||(P.Symbol=ea)}var ea=function(){var d=0;return function(m){return"jscomp_symbol_"+(m||"")+d++}}();
|
||||
function W(){da();var d=P.Symbol.iterator;d||(d=P.Symbol.iterator=P.Symbol("iterator"));"function"!=typeof Array.prototype[d]&&ca(Array.prototype,d,{configurable:!0,writable:!0,value:function(){return fa(ba(this))}});W=function(){}}function fa(d){W();d={next:d};d[P.Symbol.iterator]=function(){return this};return d}
|
||||
function ma(d,m){W();d instanceof String&&(d+="");var g=0,k={next:function(){if(g<d.length){var p=g++;return{value:m(p,d[p]),done:!1}}k.next=function(){return{done:!0,value:void 0}};return k.next()}};k[Symbol.iterator]=function(){return k};return k}function na(d,m){if(m){var g=P;d=d.split(".");for(var k=0;k<d.length-1;k++){var p=d[k];p in g||(g[p]={});g=g[p]}d=d[d.length-1];k=g[d];m=m(k);m!=k&&null!=m&&ca(g,d,{configurable:!0,writable:!0,value:m})}}
|
||||
na("Array.prototype.keys",function(d){return d?d:function(){return ma(this,function(d){return d})}});function oa(d){var m="undefined"!=typeof Symbol&&Symbol.iterator&&d[Symbol.iterator];return m?m.call(d):{next:ba(d)}}
|
||||
na("Promise",function(d){function m(f){this.g=0;this.o=void 0;this.b=[];var e=this.j();try{f(e.resolve,e.reject)}catch(x){e.reject(x)}}function g(){this.b=null}function k(f){return f instanceof m?f:new m(function(e){e(f)})}if(d)return d;g.prototype.g=function(f){if(null==this.b){this.b=[];var e=this;this.j(function(){e.o()})}this.b.push(f)};var p=P.setTimeout;g.prototype.j=function(f){p(f,0)};g.prototype.o=function(){for(;this.b&&this.b.length;){var f=this.b;this.b=[];for(var e=0;e<f.length;++e){var d=
|
||||
f[e];f[e]=null;try{d()}catch(C){this.l(C)}}}this.b=null};g.prototype.l=function(f){this.j(function(){throw f;})};m.prototype.j=function(){function f(f){return function(g){d||(d=!0,f.call(e,g))}}var e=this,d=!1;return{resolve:f(this.L),reject:f(this.l)}};m.prototype.L=function(f){if(f===this)this.l(new TypeError("A Promise cannot resolve to itself"));else if(f instanceof m)this.M(f);else{a:switch(typeof f){case "object":var e=null!=f;break a;case "function":e=!0;break a;default:e=!1}e?this.K(f):this.w(f)}};
|
||||
m.prototype.K=function(f){var e=void 0;try{e=f.then}catch(x){this.l(x);return}"function"==typeof e?this.N(e,f):this.w(f)};m.prototype.l=function(f){this.B(2,f)};m.prototype.w=function(f){this.B(1,f)};m.prototype.B=function(f,e){if(0!=this.g)throw Error("Cannot settle("+f+", "+e+"): Promise already settled in state"+this.g);this.g=f;this.o=e;this.I()};m.prototype.I=function(){if(null!=this.b){for(var f=0;f<this.b.length;++f)Q.g(this.b[f]);this.b=null}};var Q=new g;m.prototype.M=function(f){var e=this.j();
|
||||
f.F(e.resolve,e.reject)};m.prototype.N=function(f,e){var d=this.j();try{f.call(e,d.resolve,d.reject)}catch(C){d.reject(C)}};m.prototype.then=function(f,e){function d(e,d){return"function"==typeof e?function(d){try{g(e(d))}catch(G){k(G)}}:d}var g,k,p=new m(function(e,d){g=e;k=d});this.F(d(f,g),d(e,k));return p};m.prototype.catch=function(d){return this.then(void 0,d)};m.prototype.F=function(d,e){function f(){switch(g.g){case 1:d(g.o);break;case 2:e(g.o);break;default:throw Error("Unexpected state: "+
|
||||
g.g);}}var g=this;null==this.b?Q.g(f):this.b.push(f)};m.resolve=k;m.reject=function(d){return new m(function(e,g){g(d)})};m.race=function(d){return new m(function(e,g){for(var f=oa(d),m=f.next();!m.done;m=f.next())k(m.value).F(e,g)})};m.all=function(d){var e=oa(d),g=e.next();return g.done?k([]):new m(function(d,f){function m(e){return function(g){p[e]=g;x--;0==x&&d(p)}}var p=[],x=0;do p.push(void 0),x++,k(g.value).F(m(p.length-1),f),g=e.next();while(!g.done)})};return m});
|
||||
(function(d,m,g){var k;(k=g.define)&&k.amd?k([],function(){return m}):(k=g.modules)?k[d.toLowerCase()]=m:"object"===typeof exports?module.exports=m:g[d]=m})("FlexSearch",function sa(d){function g(a,b){var c=b?b.id:a&&a.id;this.id=c||0===c?c:ta++;this.init(a,b);f(this,"index",function(){return this.a?Object.keys(this.a.index[this.a.keys[0]].f):Object.keys(this.f)});f(this,"length",function(){return this.index.length})}function k(a,b,c,h){this.D!==this.i&&(this.A=this.A.concat(c),this.D++,h&&this.A.length>=
|
||||
h&&(this.D=this.i),this.D===this.i&&(this.cache&&this.v.set(b,this.A),this.H&&this.H(this.A)));return this}function p(a,b){for(var c=a.length,h=R(b),l=[],w=0,e=0;w<c;w++){var d=a[w];if(h&&b(d)||!h&&!b[d])l[e++]=d}return l}function Q(a,b,c,h,l,w,e,d,g,f){c=ha(c,e?0:l,d,w,b,g,f);if(d){d=c.page;var T=c.next;c=c.result}if(e)b=this.where(e,null,l,c);else{b=c;c=this.m;l=b.length;w=Array(l);for(e=0;e<l;e++)w[e]=c[b[e]];b=w}c=b;h&&(R(h)||(D=h.split(":"),1<D.length?h=ra:(D=D[0],h=qa)),c.sort(h));c=G(d,T,c);
|
||||
this.cache&&this.v.set(a,c);return c}function f(a,b,c){Object.defineProperty(a,b,{get:c})}function e(a){return new RegExp(a,"g")}function x(a,b){for(var c=0;c<b.length;c+=2)a=a.replace(b[c],b[c+1]);return a}function C(a,b,c,h,l,w,e,d){if(b[c])return b[c];l=l?(d-(e||d/1.5))*w+(e||d/1.5)*l:w;b[c]=l;l>=e&&(a=a[d-(l+.5>>0)],a=a[c]||(a[c]=[]),a[a.length]=h);return l}function X(a,b){if(a)for(var c=Object.keys(a),h=0,l=c.length;h<l;h++){var w=c[h],e=a[w];if(e)for(var d=0,g=e.length;d<g;d++)if(e[d]===b){1===
|
||||
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);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]):
|
||||
b[f]));this.stemmer=l}this.a=l=(c=a.doc)?c:this.a||u.a;this.u=ia(this.c-(this.threshold||0));this.s=E();this.f=E();if(l){this.m=E();a.doc=null;f=l.index={};b=l.keys=[];h=l.field;d=l.tag;I(l.id)||(l.id=l.id.split(":"));if(d){this.B=E();var U=E();if(h)if(N(h))U[h]=a;else if(I(h))for(var Z=0;Z<h.length;Z++)U[h[Z]]=a;else M(h)&&(U=h);I(d)||(l.tag=d=[d]);for(h=0;h<d.length;h++)this.B[d[h]]=E();this.I=d;h=U}if(h){if(!I(h))if(M(h)){var B=h;l.field=h=Object.keys(h)}else l.field=h=[h];for(l=0;l<h.length;l++)d=
|
||||
h[l],I(d)||(B&&(a=B[d]),b[l]=d,h[l]=d.split(":")),f[d]=new g(a),f[d].m=this.m}}this.o=!0;this.v=(this.cache=c=H(c=a.cache)?this.cache||u.cache:c)?new wa(c):!1;return this};g.prototype.encode=function(a){a&&S.length&&(a=x(a,S));a&&this.g.length&&(a=x(a,this.g));a&&this.j&&(a=this.j(a));a&&this.stemmer&&(a=x(a,this.stemmer));return a};g.prototype.addMatcher=function(a){var b=this.g,c;for(c in a)a.hasOwnProperty(c)&&b.push(e(c),a[c]);return this};g.prototype.add=function(a,b,c,h,d){if(this.a&&M(a))return this.l("add",
|
||||
a,b);if(b&&N(b)&&(a||0===a)){var e="@"+a;if(this.f[e]&&!h)return this.update(a,b);if(this.i)return++this.w>=this.b.length&&(this.w=0),this.b[this.w].postMessage({add:!0,id:a,content:b}),this.f[e]=""+this.w,c&&c(),this;if(!d){if(this.async&&"function"!==typeof importScripts){var l=this;e=new Promise(function(c){setTimeout(function(){l.add(a,b,null,h,!0);l=null;c()})});if(c)e.then(c);else return e;return this}if(c)return this.add(a,b,null,h,!0),c(),this}b=this.encode(b);if(!b.length)return this;c=this.h;
|
||||
d=R(c)?c(b):b.split(this.split);this.filter&&(d=p(d,this.filter));var f=E();f._ctx=E();for(var g=d.length,k=this.threshold,aa=this.depth,t=this.c,V=this.u,n=this.G,r=0;r<g;r++){var y=d[r];if(y){var v=y.length,z=(n?r+1:g-r)/g,q="";switch(c){case "reverse":case "both":for(var A=v;--A;)q=y[A]+q,C(V,f,q,a,n?1:(v-A)/v,z,k,t-1);q="";case "forward":for(A=0;A<v;A++)q+=y[A],C(V,f,q,a,n?(A+1)/v:1,z,k,t-1);break;case "full":for(A=0;A<v;A++)for(var x=(n?A+1:v-A)/v,u=v;u>A;u--)q=y.substring(A,u),C(V,f,q,a,x,z,
|
||||
k,t-1);break;default:if(v=C(V,f,y,a,1,z,k,t-1),aa&&1<g&&v>=k)for(v=f._ctx[y]||(f._ctx[y]=E()),y=this.s[y]||(this.s[y]=ia(t-(k||0))),z=r-aa,q=r+aa+1,0>z&&(z=0),q>g&&(q=g);z<q;z++)z!==r&&C(y,v,d[z],a,0,t-(z<r?r-z:z-r),k,t-1)}}}this.f[e]=1;this.o=!1}return this};g.prototype.l=function(a,b,c){if(I(b))for(var h=0,d=b.length;h<d;h++){if(h===d-1)return this.l(a,b[h],c);this.l(a,b[h])}else{h=this.a.index;d=this.a.keys;for(var e=this.a.tag,f=this.a.id,g,k,B,p,t=0;t<f.length;t++)g=(g||b)[f[t]];if(e){for(f=
|
||||
0;f<e.length;f++){B=e[f];k=B.split(":");for(t=0;t<k.length;t++)p=(p||b)[k[t]];p="@"+p}k=this.B[B];k=k[p]||(k[p]=[])}if("remove"===a)for(delete this.m[g],f=0,e=d.length;f<e;f++){if(f===e-1)return h[d[f]].remove(g,c);h[d[f]].remove(g)}f=this.a.field;k&&(k[k.length]=b);this.m[g]=b;e=0;for(B=f.length;e<B;e++){k=f[e];p=void 0;for(t=0;t<k.length;t++)p=(p||b)[k[t]];k=h[d[e]];t="add"===a?k.add:k.update;if(e===B-1)return t.call(k,g,p,c);t.call(k,g,p)}}};g.prototype.update=function(a,b,c){if(this.a&&M(a))return this.l("update",
|
||||
a,b);this.f["@"+a]&&N(b)&&(this.remove(a),this.add(a,b,c,!0));return this};g.prototype.remove=function(a,b,c){if(this.a&&M(a))return this.l("remove",a,b);var d="@"+a;if(this.f[d]){if(this.i)return this.b[this.f[d]].postMessage({remove:!0,id:a}),delete this.f[d],b&&b(),this;if(!c){if(this.async&&"function"!==typeof importScripts){var e=this;d=new Promise(function(b){setTimeout(function(){e.remove(a,null,!0);e=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.c-(this.threshold||0);b++)X(this.u[b],a);this.depth&&X(this.s,a);delete this.f[d];this.o=!1}return this};var D;g.prototype.search=function(a,b,c,d){if(M(b)){if(I(b))for(var e=0;e<b.length;e++)b[e].query=a;else b.query=a;a=b;b=0}var h=[],f=a;if(M(a)&&!I(a)){(c=a.callback||R(b)&&b)&&(f.callback=null);var g=a.sort;var k=a.page;b=a.limit;var B=a.threshold;var u=a.suggest;a=a.query}if(this.a){B=this.a.index;var t=f.where,x=f.bool||"or",n=f.field,r=x,y,v;if(n)I(n)||(n=[n]);else if(I(f)){var z=
|
||||
f;n=[];r=[];for(var q=0;q<f.length;q++)d=f[q],e=d.bool||x,n[q]=d.field,r[q]=e,"not"===e?y=!0:"and"===e&&(v=!0)}else n=this.a.keys;x=n.length;for(q=0;q<x;q++)z&&(f=z[q]),k&&!N(f)&&(f.page=null,f.limit=0),h[q]=B[n[q]].search(f,0);if(c)return c(Q.call(this,a,r,h,g,b,u,t,k,v,y));if(this.async){var A=this;return new Promise(function(c){Promise.all(h).then(function(d){c(Q.call(A,a,r,d,g,b,u,t,k,v,y))})})}return Q.call(this,a,r,h,g,b,u,t,k,v,y)}B||(B=this.threshold||0);R(b)?(c=b,b=1E3):b||0===b||(b=1E3);
|
||||
if(this.i)for(this.H=c,this.D=0,this.A=[],n=0;n<this.i;n++)this.b[n].postMessage({search:!0,limit:b,cursor:k,threshold:B,content:a});else{if(!d){if(this.async&&"function"!==typeof importScripts){var D=this;B=new Promise(function(a){setTimeout(function(){a(D.search(f,b,null,!0));D=null})});if(c)B.then(c);else return B;return this}if(c)return c(this.search(f,b,null,!0)),this}if(!a||!N(a))return h;f=a;if(this.cache)if(this.o){if(c=this.v.get(a))return c}else this.v.clear(),this.o=!0;f=this.encode(f);
|
||||
if(!f.length)return h;c=this.h;c=R(c)?c(f):f.split(this.split);this.filter&&(c=p(c,this.filter));z=c.length;d=!0;e=[];var C=E();1<z&&(this.depth?(n=!0,q=c[0],C[q]=1):c.sort(pa));if(!n||(x=this.s)[q])for(var H=this.c,G=n?1:0;G<z;G++){var F=c[G];if(F){if(!C[F]){var K=[],J=!1,L=0;if(q=n?x[q]:this.u)for(var O=void 0,S=0;S<H-B;S++)if(O=q[S][F])K[L++]=O,J=!0;if(J)e[e.length]=1<L?K.concat.apply([],K):K[0];else if(!u){d=!1;break}C[F]=1}q=F}}else d=!1;d&&(h=ha(e,b,k,u));this.cache&&this.v.set(a,h);return h}};
|
||||
g.prototype.find=function(a,b){return this.where(a,b,1)[0]||null};g.prototype.where=function(a,b,c,d){var e=this.m,f=[],h=0,g;if(M(a)){c||(c=b);var k=Object.keys(a);var p=k.length;var x=!1;if(1===p&&"id"===k[0])return[e[a.id]];if((g=this.I)&&!d)for(var t=0;t<g.length;t++){var u=g[t],n=a[u];if(!H(n)){d=this.B[u]["@"+n];if(0===--p)return d;k.splice(k.indexOf(u),1);delete a[u];break}}g=Array(p);for(t=0;t<p;t++)g[t]=k[t].split(":")}else{if(R(a)){b=d||Object.keys(e);c=b.length;for(k=0;k<c;k++)p=e[b[k]],
|
||||
a(p)&&(f[h++]=p);return f}if(H(b))return[e[a]];if("id"===a)return[e[b]];k=[a];p=1;g=[a.split(":")];x=!0}d=d||Object.keys(e);t=d.length;for(u=0;u<t;u++){n=e[d[u]];for(var r=!0,y=0;y<p;y++){x||(b=a[k[y]]);var v=g[y],z=v.length,q=n;if(1<z)for(var A=0;A<z;A++)q=q[v[A]];else q=q[v[0]];if(q!==b){r=!1;break}}if(r&&(f[h++]=n,c&&h===c))break}return f};g.prototype.info=function(){if(this.i)for(var a=0;a<this.i;a++)this.b[a].postMessage({info:!0,id:this.id});else return{id:this.id,items:this.length,cache:this.cache&&
|
||||
this.cache.C?this.cache.C.length:!1,matcher:S.length+(this.g?this.g.length:0),worker:this.i,threshold:this.threshold,depth:this.depth,resolution:this.c,contextual:this.depth&&"strict"===this.h}};g.prototype.clear=function(){return this.destroy().init()};g.prototype.destroy=function(){this.cache&&(this.v.clear(),this.v=null);this.u=this.s=this.f=null;if(this.a){for(var a=this.a.keys,b=0;b<a.length;b++)this.a.index[a[b]].destroy();this.a=this.m=null}return this};g.prototype.export=function(){if(this.a){for(var a=
|
||||
this.a.keys,b=Array(a.length+1),c=0;c<a.length;c++){var d=this.a.index[a[c]];b[c]=[d.u,d.s,Object.keys(d.f)]}b[c]=this.m;return JSON.stringify(b)}return JSON.stringify([this.u,this.s,Object.keys(this.f)])};g.prototype.import=function(a){a=JSON.parse(a);var b=E();if(this.a){for(var c=this.a.keys,d=c.length,e=a[0][2],f=0;f<e.length;f++)b[e[f]]=1;for(e=0;e<d;e++)f=this.a.index[c[e]],f.u=a[e][0],f.s=a[e][1],f.f=b,f.m=a[d];this.m=a[d]}else{c=a[2];for(d=0;d<c.length;d++)b[c[d]]=1;this.u=a[0];this.s=a[1];
|
||||
this.f=b}};var O={icase:function(a){return a.toLowerCase()},simple:function(){var a=[e("[\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5]"),"a",e("[\u00e8\u00e9\u00ea\u00eb]"),"e",e("[\u00ec\u00ed\u00ee\u00ef]"),"i",e("[\u00f2\u00f3\u00f4\u00f5\u00f6\u0151]"),"o",e("[\u00f9\u00fa\u00fb\u00fc\u0171]"),"u",e("[\u00fd\u0177\u00ff]"),"y",e("\u00f1"),"n",e("\u00e7"),"c",e("\u00df"),"s",e(" & ")," and ",e("[-/]")," ",e("[^a-z0-9 ]"),"",e("\\s+")," "];return function(b){b=x(b.toLowerCase(),a);return" "===b?"":b}}(),
|
||||
advanced:function(){var a=[e("ae"),"a",e("ai"),"ei",e("ay"),"ei",e("ey"),"ei",e("oe"),"o",e("ue"),"u",e("ie"),"i",e("sz"),"s",e("zs"),"s",e("sh"),"s",e("ck"),"k",e("cc"),"k",e("dt"),"t",e("ph"),"f",e("pf"),"f",e("ou"),"o",e("uo"),"u"];return function(b,c){if(!b)return b;b=this.simple(b);2<b.length&&(b=x(b,a));c||1<b.length&&(b=Y(b));return b}}(),extra:function(){var a=[e("p"),"b",e("z"),"s",e("[cgq]"),"k",e("n"),"m",e("d"),"t",e("[vw]"),"f",e("[aeiouy]"),""];return function(b){if(!b)return b;b=this.advanced(b,
|
||||
!0);if(1<b.length){b=b.split(" ");for(var c=0;c<b.length;c++){var d=b[c];1<d.length&&(b[c]=d[0]+x(d.substring(1),a))}b=b.join(" ");b=Y(b)}return b}}(),balance:function(){var a=[e("[-/]")," ",e("[^a-z0-9 ]"),"",e("\\s+")," "];return function(b){return Y(x(b.toLowerCase(),a))}}()},wa=function(){function a(a){this.clear();this.J=!0!==a&&a}a.prototype.clear=function(){this.cache=E();this.count=E();this.index=E();this.C=[]};a.prototype.set=function(a,c){if(this.J&&H(this.cache[a])){var b=this.C.length;
|
||||
if(b===this.J){b--;var d=this.C[b];delete this.cache[d];delete this.count[d];delete this.index[d]}this.index[a]=b;this.C[b]=a;this.count[a]=-1;this.cache[a]=c;this.get(a)}else this.cache[a]=c};a.prototype.get=function(a){var b=this.cache[a];if(this.J&&b){var d=++this.count[a],e=this.index,f=e[a];if(0<f){for(var g=this.C,k=f;this.count[g[--f]]<=d&&-1!==f;);f++;if(f!==k){for(d=k;d>f;d--)k=g[d-1],g[d]=k,e[k]=d;g[f]=a;e[a]=f}}}return b};return a}();return g}(function(){var d={},m="undefined"!==typeof Blob&&
|
||||
"undefined"!==typeof URL&&URL.createObjectURL;return function(g,k,p,Q,f){p=m?URL.createObjectURL(new Blob(["("+p.toString()+")()"],{type:"text/javascript"})):g+".es5.js";g+="-"+k;d[g]||(d[g]=[]);d[g][f]=new Worker(p);d[g][f].onmessage=Q;console.log("Register Worker: "+g+"@"+f);return d[g][f]}}()),this);
|
||||
'use strict';function ca(d){var l=0;return function(){return l<d.length?{done:!1,value:d[l++]}:{done:!0}}}var da="function"==typeof Object.defineProperties?Object.defineProperty:function(d,l,f){d!=Array.prototype&&d!=Object.prototype&&(d[l]=f.value)},S="undefined"!=typeof window&&window===this?this:"undefined"!=typeof global&&null!=global?global:this;function ea(){ea=function(){};S.Symbol||(S.Symbol=fa)}var fa=function(){var d=0;return function(l){return"jscomp_symbol_"+(l||"")+d++}}();
|
||||
function Y(){ea();var d=S.Symbol.iterator;d||(d=S.Symbol.iterator=S.Symbol("iterator"));"function"!=typeof Array.prototype[d]&&da(Array.prototype,d,{configurable:!0,writable:!0,value:function(){return ha(ca(this))}});Y=function(){}}function ha(d){Y();d={next:d};d[S.Symbol.iterator]=function(){return this};return d}
|
||||
function na(d,l){Y();d instanceof String&&(d+="");var f=0,k={next:function(){if(f<d.length){var n=f++;return{value:l(n,d[n]),done:!1}}k.next=function(){return{done:!0,value:void 0}};return k.next()}};k[Symbol.iterator]=function(){return k};return k}function oa(d,l){if(l){var f=S;d=d.split(".");for(var k=0;k<d.length-1;k++){var n=d[k];n in f||(f[n]={});f=f[n]}d=d[d.length-1];k=f[d];l=l(k);l!=k&&null!=l&&da(f,d,{configurable:!0,writable:!0,value:l})}}
|
||||
oa("Array.prototype.keys",function(d){return d?d:function(){return na(this,function(d){return d})}});function pa(d){var l="undefined"!=typeof Symbol&&Symbol.iterator&&d[Symbol.iterator];return l?l.call(d):{next:ca(d)}}
|
||||
oa("Promise",function(d){function l(g){this.h=0;this.o=void 0;this.b=[];var e=this.j();try{g(e.resolve,e.reject)}catch(w){e.reject(w)}}function f(){this.b=null}function k(g){return g instanceof l?g:new l(function(e){e(g)})}if(d)return d;f.prototype.h=function(g){if(null==this.b){this.b=[];var e=this;this.j(function(){e.o()})}this.b.push(g)};var n=S.setTimeout;f.prototype.j=function(g){n(g,0)};f.prototype.o=function(){for(;this.b&&this.b.length;){var g=this.b;this.b=[];for(var e=0;e<g.length;++e){var d=
|
||||
g[e];g[e]=null;try{d()}catch(G){this.l(G)}}}this.b=null};f.prototype.l=function(g){this.j(function(){throw g;})};l.prototype.j=function(){function g(g){return function(f){d||(d=!0,g.call(e,f))}}var e=this,d=!1;return{resolve:g(this.L),reject:g(this.l)}};l.prototype.L=function(g){if(g===this)this.l(new TypeError("A Promise cannot resolve to itself"));else if(g instanceof l)this.M(g);else{a:switch(typeof g){case "object":var e=null!=g;break a;case "function":e=!0;break a;default:e=!1}e?this.K(g):this.w(g)}};
|
||||
l.prototype.K=function(g){var e=void 0;try{e=g.then}catch(w){this.l(w);return}"function"==typeof e?this.N(e,g):this.w(g)};l.prototype.l=function(g){this.B(2,g)};l.prototype.w=function(g){this.B(1,g)};l.prototype.B=function(g,e){if(0!=this.h)throw Error("Cannot settle("+g+", "+e+"): Promise already settled in state"+this.h);this.h=g;this.o=e;this.I()};l.prototype.I=function(){if(null!=this.b){for(var g=0;g<this.b.length;++g)T.h(this.b[g]);this.b=null}};var T=new f;l.prototype.M=function(g){var e=this.j();
|
||||
g.F(e.resolve,e.reject)};l.prototype.N=function(g,e){var d=this.j();try{g.call(e,d.resolve,d.reject)}catch(G){d.reject(G)}};l.prototype.then=function(g,e){function d(e,d){return"function"==typeof e?function(d){try{f(e(d))}catch(L){k(L)}}:d}var f,k,n=new l(function(e,d){f=e;k=d});this.F(d(g,f),d(e,k));return n};l.prototype.catch=function(d){return this.then(void 0,d)};l.prototype.F=function(d,e){function g(){switch(f.h){case 1:d(f.o);break;case 2:e(f.o);break;default:throw Error("Unexpected state: "+
|
||||
f.h);}}var f=this;null==this.b?T.h(g):this.b.push(g)};l.resolve=k;l.reject=function(d){return new l(function(e,f){f(d)})};l.race=function(d){return new l(function(e,f){for(var g=pa(d),l=g.next();!l.done;l=g.next())k(l.value).F(e,f)})};l.all=function(d){var e=pa(d),f=e.next();return f.done?k([]):new l(function(d,g){function l(e){return function(f){n[e]=f;w--;0==w&&d(n)}}var n=[],w=0;do n.push(void 0),w++,k(f.value).F(l(n.length-1),g),f=e.next();while(!f.done)})};return l});
|
||||
(function(d,l,f){var k;(k=f.define)&&k.amd?k([],function(){return l}):(k=f.modules)?k[d.toLowerCase()]=l:"object"===typeof exports?module.exports=l:f[d]=l})("FlexSearch",function ta(d){function f(a,b){var c=b?b.id:a&&a.id;this.id=c||0===c?c:ua++;this.init(a,b);g(this,"index",function(){return this.a?Object.keys(this.a.index[this.a.keys[0]].f):Object.keys(this.f)});g(this,"length",function(){return this.index.length})}function k(a,b,c,h){this.D!==this.i&&(this.A=this.A.concat(c),this.D++,h&&this.A.length>=
|
||||
h&&(this.D=this.i),this.D===this.i&&(this.cache&&this.v.set(b,this.A),this.H&&this.H(this.A)));return this}function n(a,b){for(var c=a.length,h=V(b),t=[],q=0,e=0;q<c;q++){var d=a[q];if(h&&b(d)||!h&&!b[d])t[e++]=d}return t}function T(a,b,c,h,t,q,e,d,f,g){c=ia(c,e?0:t,d,q,b,f,g);if(d){d=c.page;var W=c.next;c=c.result}if(e)b=this.where(e,null,t,c);else{b=c;c=this.m;t=b.length;q=Array(t);for(e=0;e<t;e++)q[e]=c[b[e]];b=q}c=b;h&&(V(h)||(F=h.split(":"),1<F.length?h=sa:(F=F[0],h=ra)),c.sort(h));c=L(d,W,c);
|
||||
this.cache&&this.v.set(a,c);return c}function g(a,b,c){Object.defineProperty(a,b,{get:c})}function e(a){return new RegExp(a,"g")}function w(a,b){for(var c=0;c<b.length;c+=2)a=a.replace(b[c],b[c+1]);return a}function G(a,b,c,h,t,q,e,d){if(b[c])return b[c];t=t?(d-(e||d/1.5))*q+(e||d/1.5)*t:q;b[c]=t;t>=e&&(a=a[d-(t+.5>>0)],a=a[c]||(a[c]=[]),a[a.length]=h);return t}function Z(a,b){if(a)for(var c=Object.keys(a),h=0,t=c.length;h<t;h++){var q=c[h],e=a[q];if(e)for(var d=0,f=e.length;d<f;d++)if(e[d]===b){1===
|
||||
f?delete a[q]:e.splice(d,1);break}else P(e[d])&&Z(e[d],b)}}function aa(a){for(var b="",c="",h="",t=0;t<a.length;t++){var q=a[t];if(q!==c)if(t&&"h"===q){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+=q}else b+=q;h=t===a.length-1?"":a[t+1];c=q}return b}function qa(a,b){a=a.length-b.length;return 0>a?1:a?-1:0}function ra(a,b){a=a[F];b=b[F];return a<b?-1:a>b?1:0}function sa(a,b){for(var c=F.length,h=0;h<c;h++)a=a[F[h]],b=
|
||||
b[F[h]];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 ia(a,b,c,h,t,q,e){var d=[];if(!0===c){c="0";var f=""}else f=c&&c.split(":");var g=a.length;if(1<g){var W=H(),r=[],k,m=0,p,z=!0,v=0,y;if(f)if(2===f.length){var u=f;f=!1}else f=y=parseInt(f[0],10);if(e){for(k=H();m<g;m++)if("not"===t[m]){var x=a[m];var n=x.length;for(p=0;p<n;p++)k["@"+x[p]]=1}else var w=m+1;if(I(w))return L(c,N,d);m=0}else var D=Q(t)&&t;for(var B;m<g;m++){var J=m===(w||g)-1;if(!D||
|
||||
!m)if((p=D||t&&t[m])&&"and"!==p)if("or"===p)B=!1;else continue;else B=q=!0;x=a[m];if(n=x.length){if(z)if(M){var K=M.length;for(p=0;p<K;p++){z=M[p];var G="@"+z;e&&k[G]||(W[G]=1,q||(d[v++]=z))}var M=null;z=!1}else{M=x;continue}G=!1;for(p=0;p<n;p++){K=x[p];var O="@"+K,F=q?W[O]||0:m;if(!(!F&&!h||e&&k[O]||!q&&W[O]))if(F===m){if(J){if(!y||--y<v)if(d[v++]=K,b&&v===b)return L(c,v+(f||0),d)}else W[O]=m+1;G=!0}else h&&(O=r[F]||(r[F]=[]),O[O.length]=K)}if(B&&!G&&!h)break}else if(B&&!h)return L(c,N,x)}if(M)if(m=
|
||||
M.length,e)for(p=f?parseInt(f,10):0;p<m;p++)a=M[p],k["@"+a]||(d[v++]=a);else d=M;if(h)for(v=d.length,u?(m=parseInt(u[0],10)+1,p=parseInt(u[1],10)+1):(m=r.length,p=0);m--;)if(K=r[m]){for(n=K.length;p<n;p++)if(h=K[p],!e||!k["@"+h])if(d[v++]=h,b&&v===b)return L(c,m+":"+p,d);p=0}}else!g||t&&"not"===t[0]||(d=a[0],f&&(f=parseInt(f[0],10)));if(b){e=d.length;f&&f>e&&(f=0);f=f||0;var N=f+b;N<e?d=d.slice(f,N):(N=0,f&&(d=d.slice(f)))}return L(c,N,d)}function Q(a){return"string"===typeof a}function B(a){return a.constructor===
|
||||
Array}function V(a){return"function"===typeof a}function P(a){return"object"===typeof a}function I(a){return"undefined"===typeof a}function ja(a){for(var b=Array(a),c=0;c<a;c++)b[c]=H();return b}function H(){return Object.create(null)}function va(){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 wa(a,b,c,h){a=d("flexsearch","id"+a,va,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=ta.toString();c.id=b;a.postMessage({register:e,
|
||||
options:c,id:b});return a}var D={encode:"icase",g:"forward",split:/\W+/,cache:!1,async:!1,i:!1,G:!1,a:!1,c:9,threshold:0,depth:0},ka={memory:{encode:"extra",g:"strict",threshold:0,c:1},speed:{encode:"icase",g:"strict",threshold:1,c:3,depth:2},match:{encode:"extra",g:"full",threshold:1,c:3},score:{encode:"extra",g:"strict",threshold:1,c:9,depth:4},balance:{encode:"balance",g:"strict",threshold:0,c:3,depth:3},fast:{encode:"icase",g:"strict",threshold:8,c:9,depth:1}},X=[],ua=0,la={},ma={};f.create=function(a,
|
||||
b){return new f(a,b)};f.registerMatcher=function(a){for(var b in a)a.hasOwnProperty(b)&&X.push(e(b),a[b]);return this};f.registerEncoder=function(a,b){R[a]=b.bind(R);return this};f.registerLanguage=function(a,b){la[a]=b.filter;ma[a]=b.stemmer;return this};f.encode=function(a,b){return R[a](b)};f.prototype.init=function(a,b){this.h=[];if(b){var c=b.preset;a=b}else a||(a=D),c=a.preset;b={};Q(a)?((b=ka[a])||console.warn("Preset not found: "+a),a={}):c&&((b=ka[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 d=0;d<h;d++)this.b[d]=wa(this.id,d,a,k.bind(this))}this.g=a.tokenize||b.g||this.g||D.g;this.split=a.split||this.split||D.split;this.G=a.rtl||this.G||D.G;this.async="undefined"===typeof Promise||I(c=a.async)?this.async||D.async:c;this.i=I(c=a.worker)?this.i||D.i:c;this.threshold=I(c=a.threshold)?b.threshold||this.threshold||D.threshold:c;
|
||||
this.c=I(c=a.resolution)?c=b.c||this.c||D.c:c;c<=this.threshold&&(this.c=this.threshold+1);this.depth="strict"!==this.g||I(c=a.depth)?b.depth||this.depth||D.depth:c;this.j=(c=I(c=a.encode)?b.encode||D.encode:c)&&R[c]&&R[c].bind(R)||(V(c)?c:this.j||!1);(c=a.matcher)&&this.addMatcher(c);if(c=(b=a.lang)||a.filter){Q(c)&&(c=la[c]);if(B(c)){h=this.j;d=H();for(var q=0;q<c.length;q++){var g=h?h(c[q]):c[q];d[g]=1}c=d}this.filter=c}if(c=b||a.stemmer){b=Q(c)?ma[c]:c;h=this.j;d=[];for(var U in b)b.hasOwnProperty(U)&&
|
||||
(q=h?h(U):U,d.push(e(q+"($|\\W)"),h?h(b[U]):b[U]));this.stemmer=d}this.a=d=(c=a.doc)?c:this.a||D.a;this.u=ja(this.c-(this.threshold||0));this.s=H();this.f=H();if(d){this.m=H();a.doc=null;U=d.index={};b=d.keys=[];h=d.field;q=d.tag;B(d.id)||(d.id=d.id.split(":"));if(q){this.B=H();g=H();if(h)if(Q(h))g[h]=a;else if(B(h))for(var C=0;C<h.length;C++)g[h[C]]=a;else P(h)&&(g=h);B(q)||(d.tag=q=[q]);for(h=0;h<q.length;h++)this.B[q[h]]=H();this.I=q;h=g}if(h){if(!B(h))if(P(h)){var E=h;d.field=h=Object.keys(h)}else d.field=
|
||||
h=[h];for(d=0;d<h.length;d++)q=h[d],B(q)||(E&&(a=E[q]),b[d]=q,h[d]=q.split(":")),U[q]=new f(a),U[q].m=this.m}}this.o=!0;this.v=(this.cache=c=I(c=a.cache)?this.cache||D.cache:c)?new xa(c):!1;return this};f.prototype.encode=function(a){a&&X.length&&(a=w(a,X));a&&this.h.length&&(a=w(a,this.h));a&&this.j&&(a=this.j(a));a&&this.stemmer&&(a=w(a,this.stemmer));return a};f.prototype.addMatcher=function(a){var b=this.h,c;for(c in a)a.hasOwnProperty(c)&&b.push(e(c),a[c]);return this};f.prototype.add=function(a,
|
||||
b,c,d,e){if(this.a&&P(a))return this.l("add",a,b);if(b&&Q(b)&&(a||0===a)){var h="@"+a;if(this.f[h]&&!d)return this.update(a,b);if(this.i)return++this.w>=this.b.length&&(this.w=0),this.b[this.w].postMessage({add:!0,id:a,content:b}),this.f[h]=""+this.w,c&&c(),this;if(!e){if(this.async&&"function"!==typeof importScripts){var f=this;h=new Promise(function(c){setTimeout(function(){f.add(a,b,null,d,!0);f=null;c()})});if(c)h.then(c);else return h;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.g;e=V(c)?c(b):b.split(this.split);this.filter&&(e=n(e,this.filter));var t=H();t._ctx=H();for(var g=e.length,k=this.threshold,ba=this.depth,r=this.c,A=this.u,m=this.G,p=0;p<g;p++){var z=e[p];if(z){var v=z.length,y=(m?p+1:g-p)/g,u="";switch(c){case "reverse":case "both":for(var x=v;--x;)u=z[x]+u,G(A,t,u,a,m?1:(v-x)/v,y,k,r-1);u="";case "forward":for(x=0;x<v;x++)u+=z[x],G(A,t,u,a,m?(x+1)/v:1,y,k,r-1);break;case "full":for(x=0;x<v;x++)for(var w=(m?x+1:v-
|
||||
x)/v,B=v;B>x;B--)u=z.substring(x,B),G(A,t,u,a,w,y,k,r-1);break;default:if(v=G(A,t,z,a,1,y,k,r-1),ba&&1<g&&v>=k)for(v=t._ctx[z]||(t._ctx[z]=H()),z=this.s[z]||(this.s[z]=ja(r-(k||0))),y=p-ba,u=p+ba+1,0>y&&(y=0),u>g&&(u=g);y<u;y++)y!==p&&G(z,v,e[y],a,0,r-(y<p?p-y:y-p),k,r-1)}}}this.f[h]=1;this.o=!1}return this};f.prototype.l=function(a,b,c){if(B(b))for(var d=0,e=b.length;d<e;d++){if(d===e-1)return this.l(a,b[d],c);this.l(a,b[d])}else{d=this.a.index;e=this.a.keys;for(var f=this.a.tag,g=this.a.id,k,C,
|
||||
E,n,r=0;r<g.length;r++)k=(k||b)[g[r]];if(f){for(g=0;g<f.length;g++){E=f[g];C=E.split(":");for(r=0;r<C.length;r++)n=(n||b)[C[r]];n="@"+n}C=this.B[E];C=C[n]||(C[n]=[])}if("remove"===a)for(delete this.m[k],g=0,f=e.length;g<f;g++){if(g===f-1)return d[e[g]].remove(k,c),this;d[e[g]].remove(k)}g=this.a.field;C&&(C[C.length]=b);this.m[k]=b;f=0;for(E=g.length;f<E;f++){C=g[f];n=void 0;for(r=0;r<C.length;r++)n=(n||b)[C[r]];C=d[e[f]];r="add"===a?C.add:C.update;f===E-1?r.call(C,k,n,c):r.call(C,k,n)}}return this};
|
||||
f.prototype.update=function(a,b,c){if(this.a&&P(a))return this.l("update",a,b);this.f["@"+a]&&Q(b)&&(this.remove(a),this.add(a,b,c,!0));return this};f.prototype.remove=function(a,b,c){if(this.a&&P(a))return this.l("remove",a,b);var d="@"+a;if(this.f[d]){if(this.i)return this.b[this.f[d]].postMessage({remove:!0,id:a}),delete this.f[d],b&&b(),this;if(!c){if(this.async&&"function"!==typeof importScripts){var e=this;d=new Promise(function(b){setTimeout(function(){e.remove(a,null,!0);e=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.c-(this.threshold||0);b++)Z(this.u[b],a);this.depth&&Z(this.s,a);delete this.f[d];this.o=!1}return this};var F;f.prototype.search=function(a,b,c,d){if(P(b)){if(B(b))for(var e=0;e<b.length;e++)b[e].query=a;else b.query=a;a=b;b=1E3}else b&&V(b)?(c=b,b=1E3):b||0===b||(b=1E3);var h=[],f=a;if(P(a)&&!B(a)){c||(c=a.callback)&&(f.callback=null);var g=a.sort;var k=a.page;b=a.limit;var E=a.threshold;var w=a.suggest;a=a.query}if(this.a){E=
|
||||
this.a.index;var r=f.where,A=f.bool||"or",m=f.field,p=A,z,v;if(m)B(m)||(m=[m]);else if(B(f)){var y=f;m=[];p=[];for(var u=0;u<f.length;u++)d=f[u],e=d.bool||A,m[u]=d.field,p[u]=e,"not"===e?z=!0:"and"===e&&(v=!0)}else m=this.a.keys;A=m.length;for(u=0;u<A;u++)y&&(f=y[u]),k&&!Q(f)&&(f.page=null,f.limit=0),h[u]=E[m[u]].search(f,0);if(c)return c(T.call(this,a,p,h,g,b,w,r,k,v,z));if(this.async){var x=this;return new Promise(function(c){Promise.all(h).then(function(d){c(T.call(x,a,p,d,g,b,w,r,k,v,z))})})}return T.call(this,
|
||||
a,p,h,g,b,w,r,k,v,z)}E||(E=this.threshold||0);if(this.i)for(this.H=c,this.D=0,this.A=[],m=0;m<this.i;m++)this.b[m].postMessage({search:!0,limit:b,cursor:k,threshold:E,content:a});else{if(!d){if(this.async&&"function"!==typeof importScripts){var G=this;E=new Promise(function(a){setTimeout(function(){a(G.search(f,b,null,!0));G=null})});if(c)E.then(c);else return E;return this}if(c)return c(this.search(f,b,null,!0)),this}if(!a||!Q(a))return h;f=a;if(this.cache)if(this.o){if(c=this.v.get(a))return c}else this.v.clear(),
|
||||
this.o=!0;f=this.encode(f);if(!f.length)return h;c=this.g;c=V(c)?c(f):f.split(this.split);this.filter&&(c=n(c,this.filter));y=c.length;d=!0;e=[];var D=H(),F=0;1<y&&(this.depth&&"strict"===this.g?A=!0:c.sort(qa));if(!A||(u=this.s))for(var I=this.c;F<y;F++){var J=c[F];if(J){if(A){if(!m)if(u[J])m=J,D[J]=1;else if(!w)return h;if(w&&F===y-1&&!e.length)A=!1,J=m||J,D[J]=0;else if(!m)continue}if(!D[J]){var K=[],L=!1,M=0,O=A?u[m]:this.u;if(O)for(var R=void 0,N=0;N<I-E;N++)if(R=O[N][J])K[M++]=R,L=!0;if(L)m=
|
||||
J,e[e.length]=1<M?K.concat.apply([],K):K[0];else if(!w){d=!1;break}D[J]=1}}}else d=!1;d&&(h=ia(e,b,k,w));this.cache&&this.v.set(a,h);return h}};f.prototype.find=function(a,b){return this.where(a,b,1)[0]||null};f.prototype.where=function(a,b,c,d){var e=this.m,f=[],h=0,g;if(P(a)){c||(c=b);var k=Object.keys(a);var n=k.length;var w=!1;if(1===n&&"id"===k[0])return[e[a.id]];if((g=this.I)&&!d)for(var r=0;r<g.length;r++){var A=g[r],m=a[A];if(!I(m)){var p=this.B[A]["@"+m];if(0===--n)return p;k.splice(k.indexOf(A),
|
||||
1);delete a[A];break}}g=Array(n);for(r=0;r<n;r++)g[r]=k[r].split(":")}else{if(V(a)){b=d||Object.keys(e);c=b.length;for(k=0;k<c;k++)n=e[b[k]],a(n)&&(f[h++]=n);return f}if(I(b))return[e[a]];if("id"===a)return[e[b]];k=[a];n=1;g=[a.split(":")];w=!0}d=p||d||Object.keys(e);r=d.length;for(A=0;A<r;A++){m=p?d[A]:e[d[A]];for(var z=!0,v=0;v<n;v++){w||(b=a[k[v]]);var y=g[v],u=y.length,x=m;if(1<u)for(var B=0;B<u;B++)x=x[y[B]];else x=x[y[0]];if(x!==b){z=!1;break}}if(z&&(f[h++]=m,c&&h===c))break}return f};f.prototype.info=
|
||||
function(){if(this.i)for(var a=0;a<this.i;a++)this.b[a].postMessage({info:!0,id:this.id});else return{id:this.id,items:this.length,cache:this.cache&&this.cache.C?this.cache.C.length:!1,matcher:X.length+(this.h?this.h.length:0),worker:this.i,threshold:this.threshold,depth:this.depth,resolution:this.c,contextual:this.depth&&"strict"===this.g}};f.prototype.clear=function(){return this.destroy().init()};f.prototype.destroy=function(){this.cache&&(this.v.clear(),this.v=null);this.u=this.s=this.f=null;
|
||||
if(this.a){for(var a=this.a.keys,b=0;b<a.length;b++)this.a.index[a[b]].destroy();this.a=this.m=null}return this};f.prototype.export=function(){if(this.a){var a=this.a.keys;var b=Array(a.length+1);for(var c=0;c<a.length;c++){var d=this.a.index[a[c]];b[c]=[d.u,d.s,Object.keys(d.f)]}b[c]=this.m}else b=[this.u,this.s,Object.keys(this.f)];return JSON.stringify(b)};f.prototype.import=function(a){a=JSON.parse(a);var b=H();if(this.a){for(var c=this.a.keys,d=c.length,e=a[0][2],f=0;f<e.length;f++)b[e[f]]=1;
|
||||
for(e=0;e<d;e++)f=this.a.index[c[e]],f.u=a[e][0],f.s=a[e][1],f.f=b,f.m=a[d];this.m=a[d]}else{c=a[2];for(d=0;d<c.length;d++)b[c[d]]=1;this.u=a[0];this.s=a[1];this.f=b}};var R={icase:function(a){return a.toLowerCase()},simple:function(){var a=[e("[\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5]"),"a",e("[\u00e8\u00e9\u00ea\u00eb]"),"e",e("[\u00ec\u00ed\u00ee\u00ef]"),"i",e("[\u00f2\u00f3\u00f4\u00f5\u00f6\u0151]"),"o",e("[\u00f9\u00fa\u00fb\u00fc\u0171]"),"u",e("[\u00fd\u0177\u00ff]"),"y",e("\u00f1"),"n",e("\u00e7"),
|
||||
"c",e("\u00df"),"s",e(" & ")," and ",e("[-/]")," ",e("[^a-z0-9 ]"),"",e("\\s+")," "];return function(b){b=w(b.toLowerCase(),a);return" "===b?"":b}}(),advanced:function(){var a=[e("ae"),"a",e("ai"),"ei",e("ay"),"ei",e("ey"),"ei",e("oe"),"o",e("ue"),"u",e("ie"),"i",e("sz"),"s",e("zs"),"s",e("sh"),"s",e("ck"),"k",e("cc"),"k",e("dt"),"t",e("ph"),"f",e("pf"),"f",e("ou"),"o",e("uo"),"u"];return function(b,c){if(!b)return b;b=this.simple(b);2<b.length&&(b=w(b,a));c||1<b.length&&(b=aa(b));return b}}(),extra:function(){var a=
|
||||
[e("p"),"b",e("z"),"s",e("[cgq]"),"k",e("n"),"m",e("d"),"t",e("[vw]"),"f",e("[aeiouy]"),""];return function(b){if(!b)return b;b=this.advanced(b,!0);if(1<b.length){b=b.split(" ");for(var c=0;c<b.length;c++){var d=b[c];1<d.length&&(b[c]=d[0]+w(d.substring(1),a))}b=b.join(" ");b=aa(b)}return b}}(),balance:function(){var a=[e("[-/]")," ",e("[^a-z0-9 ]"),"",e("\\s+")," "];return function(b){return aa(w(b.toLowerCase(),a))}}()},xa=function(){function a(a){this.clear();this.J=!0!==a&&a}a.prototype.clear=
|
||||
function(){this.cache=H();this.count=H();this.index=H();this.C=[]};a.prototype.set=function(a,c){if(this.J&&I(this.cache[a])){var b=this.C.length;if(b===this.J){b--;var d=this.C[b];delete this.cache[d];delete this.count[d];delete this.index[d]}this.index[a]=b;this.C[b]=a;this.count[a]=-1;this.cache[a]=c;this.get(a)}else this.cache[a]=c};a.prototype.get=function(a){var b=this.cache[a];if(this.J&&b){var d=++this.count[a],e=this.index,f=e[a];if(0<f){for(var g=this.C,k=f;this.count[g[--f]]<=d&&-1!==f;);
|
||||
f++;if(f!==k){for(d=k;d>f;d--)k=g[d-1],g[d]=k,e[k]=d;g[f]=a;e[a]=f}}}return b};return a}();return f}(function(){var d={},l="undefined"!==typeof Blob&&"undefined"!==typeof URL&&URL.createObjectURL;return function(f,k,n,T,g){n=l?URL.createObjectURL(new Blob(["("+n.toString()+")()"],{type:"text/javascript"})):f+".es5.js";f+="-"+k;d[f]||(d[f]=[]);d[f][g]=new Worker(n);d[f][g].onmessage=T;console.log("Register Worker: "+f+"@"+g);return d[f][g]}}()),this);
|
||||
|
26
dist/flexsearch.light.js
vendored
26
dist/flexsearch.light.js
vendored
@@ -1,19 +1,19 @@
|
||||
/*
|
||||
FlexSearch v0.6.1
|
||||
FlexSearch v0.6.2
|
||||
Copyright 2019 Nextapps GmbH
|
||||
Author: Thomas Wilkerling
|
||||
Released under the Apache 2.0 Licence
|
||||
https://github.com/nextapps-de/flexsearch
|
||||
*/
|
||||
'use strict';(function(e,z,t){let k;(k=t.define)&&k.amd?k([],function(){return z}):(k=t.modules)?k[e.toLowerCase()]=z:"object"===typeof exports?module.exports=z:t[e]=z})("FlexSearch",function(){function e(a,c){const b=c?c.id:a&&a.id;this.id=b||0===b?b:K++;this.init(a,c);t(this,"index",function(){return Object.keys(this.b)});t(this,"length",function(){return this.index.length})}function z(a,c){const b=a.length,f=A(c),d=[];for(let l=0,g=0;l<b;l++){const b=a[l];if(f&&c(b)||!f&&!c[b])d[g++]=b}return d}
|
||||
function t(a,c,b){Object.defineProperty(a,c,{get:b})}function k(a,c){for(let b=0;b<c.length;b+=2)a=a.replace(c[b],c[b+1]);return a}function B(a,c,b,f,d,l,g,h){if(c[b])return c[b];d=d?(h-(g||h/1.5))*l+(g||h/1.5)*d:l;c[b]=d;d>=g&&(a=a[h-(d+.5>>0)],a=a[b]||(a[b]=[]),a[a.length]=f);return d}function E(a,c){if(a){const b=Object.keys(a);for(let f=0,d=b.length;f<d;f++){const d=b[f],g=a[d];if(g)for(let b=0,f=g.length;b<f;b++)if(g[b]===c){1===f?delete a[d]:g.splice(b,1);break}else"object"===typeof g[b]&&E(g[b],
|
||||
c)}}}function L(a,c){a=a.length-c.length;return 0>a?1:a?-1:0}function F(a,c,b){return a?{page:a,next:c?""+c:null,result:b}:b}function C(a){return"string"===typeof a}function A(a){return"function"===typeof a}function D(a){return"undefined"===typeof a}function H(a){const c=Array(a);for(let b=0;b<a;b++)c[b]=y();return c}function y(){return Object.create(null)}const u={encode:"icase",c:"forward",split:/\W+/,cache:!1,async:!1,m:!1,i:!1,l:!1,a:9,threshold:0,depth:0},G=[];let K=0;const I={},J={};e.create=
|
||||
function(a){return new e(a)};e.registerMatcher=function(a){for(const c in a)a.hasOwnProperty(c)&&G.push(new RegExp(c,"g"),a[c]);return this};e.registerEncoder=function(a,c){w[a]=c.bind(w);return this};e.registerLanguage=function(a,c){I[a]=c.filter;J[a]=c.stemmer;return this};e.encode=function(a,c){return w[a](c)};e.prototype.init=function(a,c){this.j=[];if(c){var b=c.preset;a=c}else a||(a=u),b=a.preset;c={};this.c=a.tokenize||c.c||this.c||u.c;this.split=a.split||this.split||u.split;this.i=a.rtl||
|
||||
this.i||u.i;this.threshold=D(b=a.threshold)?c.threshold||this.threshold||u.threshold:b;this.a=D(b=a.resolution)?b=c.a||this.a||u.a:b;b<=this.threshold&&(this.a=this.threshold+1);this.depth="strict"!==this.c||D(b=a.depth)?c.depth||this.depth||u.depth:b;this.g=(b=D(b=a.encode)?c.encode||u.encode:b)&&w[b]&&w[b].bind(w)||(A(b)?b:this.g||!1);(b=a.matcher)&&this.addMatcher(b);if(b=a.filter){C(b)&&(b=I[b]);if(b.constructor===Array){c=this.g;var f=y();for(let a=0;a<b.length;a++){const d=c?c(b[a]):b[a];f[d]=
|
||||
1}b=f}this.filter=b}if(b=a.stemmer){var d;a=C(b)?J[b]:b;b=this.g;c=[];for(d in a)a.hasOwnProperty(d)&&(f=b?b(d):d,c.push(new RegExp(f+"($|\\W)","g"),b?b(a[d]):a[d]));this.stemmer=d=c}this.h=H(this.a-(this.threshold||0));this.f=y();this.b=y();return this};e.prototype.encode=function(a){a&&G.length&&(a=k(a,G));a&&this.j.length&&(a=k(a,this.j));a&&this.g&&(a=this.g(a));a&&this.stemmer&&(a=k(a,this.stemmer));return a};e.prototype.addMatcher=function(a){const c=this.j;for(const b in a)a.hasOwnProperty(b)&&
|
||||
c.push(new RegExp(b,"g"),a[b]);return this};e.prototype.add=function(a,c,b,f,d){if(c&&C(c)&&(a||0===a)){const e="@"+a;if(this.b[e]&&!f)return this.update(a,c);if(!d&&b)return this.add(a,c,null,f,!0),b(),this;c=this.encode(c);if(!c.length)return this;b=this.c;c=A(b)?b(c):c.split(this.split);this.filter&&(c=z(c,this.filter));f=y();f._ctx=y();d=c.length;const r=this.threshold,k=this.depth,p=this.a,q=this.h,v=this.i;for(let e=0;e<d;e++){var l=c[e];if(l){var g=l.length,h=(v?e+1:d-e)/d,n="";switch(b){case "reverse":case "both":for(var m=
|
||||
g;--m;)n=l[m]+n,B(q,f,n,a,v?1:(g-m)/g,h,r,p-1);n="";case "forward":for(m=0;m<g;m++)n+=l[m],B(q,f,n,a,v?(m+1)/g:1,h,r,p-1);break;case "full":for(m=0;m<g;m++){const b=(v?m+1:g-m)/g;for(let c=g;c>m;c--)n=l.substring(m,c),B(q,f,n,a,b,h,r,p-1)}break;default:if(g=B(q,f,l,a,1,h,r,p-1),k&&1<d&&g>=r)for(g=f._ctx[l]||(f._ctx[l]=y()),l=this.f[l]||(this.f[l]=H(p-(r||0))),h=e-k,n=e+k+1,0>h&&(h=0),n>d&&(n=d);h<n;h++)h!==e&&B(l,g,c[h],a,0,p-(h<e?e-h:h-e),r,p-1)}}}this.b[e]=1}return this};e.prototype.update=function(a,
|
||||
c,b){this.b["@"+a]&&C(c)&&(this.remove(a),this.add(a,c,b,!0));return this};e.prototype.remove=function(a,c,b){const f="@"+a;if(this.b[f]){if(!b&&c)return this.remove(a,null,!0),c(),this;for(c=0;c<this.a-(this.threshold||0);c++)E(this.h[c],a);this.depth&&E(this.f,a);delete this.b[f]}return this};e.prototype.search=function(a,c,b,f){var d=[],e=a;if("object"===typeof a){var g=!1;c=a.limit;var h=a.threshold;a=a.query}h||(h=this.threshold||0);A(c)?(b=c,c=1E3):c||0===c||(c=1E3);if(!f&&b)return b(this.search(e,
|
||||
c,null,!0)),this;if(!a||!C(a))return d;e=this.encode(a);if(!e.length)return d;a=this.c;a=A(a)?a(e):e.split(this.split);this.filter&&(a=z(a,this.filter));b=a.length;f=!0;e=[];var n=y();if(1<b)if(this.depth){var m=!0;var k=a[0];n[k]=1}else a.sort(L);var r;if(!m||(r=this.f)[k]){var u=this.a;for(var p=m?1:0;p<b;p++){var q=a[p];if(q){if(!n[q]){var v=[],t=!1,w=0;if(k=m?r[k]:this.h){let a;for(let b=0;b<u-h;b++)if(a=k[b][q])v[w++]=a,t=!0}if(t)e[e.length]=1<w?v.concat.apply([],v):v[0];else{f=!1;break}n[q]=
|
||||
1}k=q}}}else f=!1;if(f)a:{let l;d=[];m=e.length;!0===g?(g="0",h=""):h=g&&g.split(":");if(1<m){r=y();a=-1;q=!0;n=0;for(h&&(2===h.length?h=!1:h=parseInt(h[0],10));++a<m;){u=a===m-1;k=e[a];f=k.length;if(!f){d=F(g,l,k);break a}if(q)if(x){p=x.length;for(b=0;b<p;)q=x[b++],r["@"+q]=1;var x=null;q=!1}else{x=k;continue}v=!1;for(b=0;b<f;)if(p=k[b++],t="@"+p,(w=r[t])&&w===a){if(u){if(!h||--h<n)if(d[n++]=p,c&&n===c){d=F(g,n,d);break a}}else r[t]=a+1;v=!0}if(!v)break}x&&(d=x)}else m&&(d=e[0]);c&&(x=g?parseInt(g,
|
||||
10):0,l=x+c,l<d.length?d=d.slice(x,l):x&&(d=d.slice(x)));d=F(g,l,d)}return d};e.prototype.clear=function(){return this.destroy().init()};e.prototype.destroy=function(){this.h=this.f=this.b=null;return this};const w={icase:function(a){return a.toLowerCase()}};return e}(!1),this);
|
||||
'use strict';(function(e,A,w){let n;(n=w.define)&&n.amd?n([],function(){return A}):(n=w.modules)?n[e.toLowerCase()]=A:"object"===typeof exports?module.exports=A:w[e]=A})("FlexSearch",function(){function e(a,b){const c=b?b.id:a&&a.id;this.id=c||0===c?c:M++;this.init(a,b);w(this,"index",function(){return Object.keys(this.c)});w(this,"length",function(){return this.index.length})}function A(a,b){const c=a.length,f=C(b),d=[];for(let k=0,h=0;k<c;k++){const c=a[k];if(f&&b(c)||!f&&!b[c])d[h++]=c}return d}
|
||||
function w(a,b,c){Object.defineProperty(a,b,{get:c})}function n(a,b){for(let c=0;c<b.length;c+=2)a=a.replace(b[c],b[c+1]);return a}function D(a,b,c,f,d,k,h,g){if(b[c])return b[c];d=d?(g-(h||g/1.5))*k+(h||g/1.5)*d:k;b[c]=d;d>=h&&(a=a[g-(d+.5>>0)],a=a[c]||(a[c]=[]),a[a.length]=f);return d}function G(a,b){if(a){const c=Object.keys(a);for(let f=0,d=c.length;f<d;f++){const d=c[f],h=a[d];if(h)for(let c=0,f=h.length;c<f;c++)if(h[c]===b){1===f?delete a[d]:h.splice(c,1);break}else"object"===typeof h[c]&&G(h[c],
|
||||
b)}}}function N(a,b){a=a.length-b.length;return 0>a?1:a?-1:0}function H(a,b,c){return a?{page:a,next:b?""+b:null,result:c}:c}function E(a){return"string"===typeof a}function C(a){return"function"===typeof a}function F(a){return"undefined"===typeof a}function J(a){const b=Array(a);for(let c=0;c<a;c++)b[c]=x();return b}function x(){return Object.create(null)}const t={encode:"icase",b:"forward",split:/\W+/,cache:!1,async:!1,m:!1,i:!1,l:!1,a:9,threshold:0,depth:0},I=[];let M=0;const K={},L={};e.create=
|
||||
function(a,b){return new e(a,b)};e.registerMatcher=function(a){for(const b in a)a.hasOwnProperty(b)&&I.push(new RegExp(b,"g"),a[b]);return this};e.registerEncoder=function(a,b){B[a]=b.bind(B);return this};e.registerLanguage=function(a,b){K[a]=b.filter;L[a]=b.stemmer;return this};e.encode=function(a,b){return B[a](b)};e.prototype.init=function(a,b){this.j=[];if(b){var c=b.preset;a=b}else a||(a=t),c=a.preset;b={};this.b=a.tokenize||b.b||this.b||t.b;this.split=a.split||this.split||t.split;this.i=a.rtl||
|
||||
this.i||t.i;this.threshold=F(c=a.threshold)?b.threshold||this.threshold||t.threshold:c;this.a=F(c=a.resolution)?c=b.a||this.a||t.a:c;c<=this.threshold&&(this.a=this.threshold+1);this.depth="strict"!==this.b||F(c=a.depth)?b.depth||this.depth||t.depth:c;this.g=(c=F(c=a.encode)?b.encode||t.encode:c)&&B[c]&&B[c].bind(B)||(C(c)?c:this.g||!1);(c=a.matcher)&&this.addMatcher(c);if(c=(b=a.lang)||a.filter){E(c)&&(c=K[c]);if(c.constructor===Array){{var f=this.g;const a=x();for(let b=0;b<c.length;b++){const d=
|
||||
f?f(c[b]):c[b];a[d]=1}c=a}}this.filter=c}if(c=b||a.stemmer){var d;a=E(c)?L[c]:c;b=this.g;c=[];for(d in a)a.hasOwnProperty(d)&&(f=b?b(d):d,c.push(new RegExp(f+"($|\\W)","g"),b?b(a[d]):a[d]));this.stemmer=d=c}this.h=J(this.a-(this.threshold||0));this.f=x();this.c=x();return this};e.prototype.encode=function(a){a&&I.length&&(a=n(a,I));a&&this.j.length&&(a=n(a,this.j));a&&this.g&&(a=this.g(a));a&&this.stemmer&&(a=n(a,this.stemmer));return a};e.prototype.addMatcher=function(a){const b=this.j;for(const c in a)a.hasOwnProperty(c)&&
|
||||
b.push(new RegExp(c,"g"),a[c]);return this};e.prototype.add=function(a,b,c,f,d){if(b&&E(b)&&(a||0===a)){const e="@"+a;if(this.c[e]&&!f)return this.update(a,b);if(!d&&c)return this.add(a,b,null,f,!0),c(),this;b=this.encode(b);if(!b.length)return this;c=this.b;b=C(c)?c(b):b.split(this.split);this.filter&&(b=A(b,this.filter));f=x();f._ctx=x();d=b.length;const r=this.threshold,u=this.depth,v=this.a,p=this.h,q=this.i;for(let e=0;e<d;e++){var k=b[e];if(k){var h=k.length,g=(q?e+1:d-e)/d,m="";switch(c){case "reverse":case "both":for(var l=
|
||||
h;--l;)m=k[l]+m,D(p,f,m,a,q?1:(h-l)/h,g,r,v-1);m="";case "forward":for(l=0;l<h;l++)m+=k[l],D(p,f,m,a,q?(l+1)/h:1,g,r,v-1);break;case "full":for(l=0;l<h;l++){const b=(q?l+1:h-l)/h;for(let c=h;c>l;c--)m=k.substring(l,c),D(p,f,m,a,b,g,r,v-1)}break;default:if(h=D(p,f,k,a,1,g,r,v-1),u&&1<d&&h>=r)for(h=f._ctx[k]||(f._ctx[k]=x()),k=this.f[k]||(this.f[k]=J(v-(r||0))),g=e-u,m=e+u+1,0>g&&(g=0),m>d&&(m=d);g<m;g++)g!==e&&D(k,h,b[g],a,0,v-(g<e?e-g:g-e),r,v-1)}}}this.c[e]=1}return this};e.prototype.update=function(a,
|
||||
b,c){this.c["@"+a]&&E(b)&&(this.remove(a),this.add(a,b,c,!0));return this};e.prototype.remove=function(a,b,c){const f="@"+a;if(this.c[f]){if(!c&&b)return this.remove(a,null,!0),b(),this;for(b=0;b<this.a-(this.threshold||0);b++)G(this.h[b],a);this.depth&&G(this.f,a);delete this.c[f]}return this};e.prototype.search=function(a,b,c,f){b&&C(b)?(c=b,b=1E3):b||0===b||(b=1E3);var d=[],e=a;if("object"===typeof a){var h=!1;b=a.limit;var g=a.threshold;var m=!1;a=a.query}g||(g=this.threshold||0);if(!f&&c)return c(this.search(e,
|
||||
b,null,!0)),this;if(!a||!E(a))return d;e=this.encode(a);if(!e.length)return d;a=this.b;a=C(a)?a(e):e.split(this.split);this.filter&&(a=A(a,this.filter));c=a.length;f=!0;e=[];var l=x(),n,r=0;1<c&&(this.depth&&"strict"===this.b?n=!0:a.sort(N));var u;if(!n||(u=this.f))for(var v=this.a;r<c;r++){var p=a[r];if(p){if(n){if(!q)if(u[p]){var q=p;l[p]=1}else if(!m)return d;if(m&&r===c-1&&!e.length)n=!1,p=q||p,l[p]=0;else if(!q)continue}if(!l[p]){var t=[],w=!1;let a=0;if(q=n?u[q]:this.h){let b;for(let c=0;c<
|
||||
v-g;c++)if(b=q[c][p])t[a++]=b,w=!0}if(w)q=p,e[e.length]=1<a?t.concat.apply([],t):t[0];else{f=!1;break}l[p]=1}}}else f=!1;if(f)a:{let k;d=[];!0===h?(h="0",g=""):g=h&&h.split(":");m=e.length;if(1<m){n=x();q=0;v=!0;f=0;var z;for(g&&(2===g.length?g=!1:g=z=parseInt(g[0],10));q<m;q++){l=q===m-1;u=e[q];c=u.length;if(!c){d=H(h,k,u);break a}if(v)if(y){r=y.length;for(a=0;a<r;a++)n["@"+y[a]]=1;var y=null;v=!1}else{y=u;continue}p=!1;for(a=0;a<c;a++)if(r=u[a],t="@"+r,(w=n[t]||0)&&w===q){if(l){if(!z||--z<f)if(d[f++]=
|
||||
r,b&&f===b){d=H(h,f+(g||0),d);break a}}else n[t]=q+1;p=!0}if(!p)break}y&&(d=y)}else m&&(d=e[0],g&&(g=parseInt(g[0],10)));b&&(y=d.length,g&&g>y&&(g=0),z=g||0,k=z+b,k<y?d=d.slice(z,k):(k=0,z&&(d=d.slice(z))));d=H(h,k,d)}return d};e.prototype.clear=function(){return this.destroy().init()};e.prototype.destroy=function(){this.h=this.f=this.c=null;return this};const B={icase:function(a){return a.toLowerCase()}};return e}(!1),this);
|
||||
|
69
dist/flexsearch.min.js
vendored
69
dist/flexsearch.min.js
vendored
@@ -1,40 +1,41 @@
|
||||
/*
|
||||
FlexSearch v0.6.1
|
||||
FlexSearch v0.6.2
|
||||
Copyright 2019 Nextapps GmbH
|
||||
Author: Thomas Wilkerling
|
||||
Released under the Apache 2.0 Licence
|
||||
https://github.com/nextapps-de/flexsearch
|
||||
*/
|
||||
'use strict';(function(x,N,l){let z;(z=l.define)&&z.amd?z([],function(){return N}):(z=l.modules)?z[x.toLowerCase()]=N:"object"===typeof exports?module.exports=N:l[x]=N})("FlexSearch",function da(x){function l(a,b){const c=b?b.id:a&&a.id;this.id=c||0===c?c:ea++;this.init(a,b);O(this,"index",function(){return this.a?Object.keys(this.a.index[this.a.keys[0]].c):Object.keys(this.c)});O(this,"length",function(){return this.index.length})}function z(a,b,c,d){this.u!==this.g&&(this.o=this.o.concat(c),this.u++,
|
||||
d&&this.o.length>=d&&(this.u=this.g),this.u===this.g&&(this.cache&&this.l.set(b,this.o),this.F&&this.F(this.o)));return this}function P(a,b){const c=a.length,d=J(b),e=[];for(let g=0,f=0;g<c;g++){const c=a[g];if(d&&b(c)||!d&&!b[c])e[f++]=c}return e}function S(a,b,c,d,e,g,f,r,q,n){c=Y(c,f?0:e,r,g,b,q,n);let p;r&&(r=c.page,p=c.next,c=c.result);if(f)b=this.where(f,null,e,c);else{b=c;c=this.h;e=b.length;g=Array(e);for(f=0;f<e;f++)g[f]=c[b[f]];b=g}c=b;d&&(J(d)||(E=d.split(":"),1<E.length?d=fa:(E=E[0],d=
|
||||
ha)),c.sort(d));c=L(r,p,c);this.cache&&this.l.set(a,c);return c}function O(a,b,c){Object.defineProperty(a,b,{get:c})}function h(a){return new RegExp(a,"g")}function M(a,b){for(let c=0;c<b.length;c+=2)a=a.replace(b[c],b[c+1]);return a}function T(a,b,c,d,e,g,f,r){if(b[c])return b[c];e=e?(r-(f||r/1.5))*g+(f||r/1.5)*e:g;b[c]=e;e>=f&&(a=a[r-(e+.5>>0)],a=a[c]||(a[c]=[]),a[a.length]=d);return e}function W(a,b){if(a){const c=Object.keys(a);for(let d=0,e=c.length;d<e;d++){const e=c[d],f=a[e];if(f)for(let 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),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,
|
||||
n,r,h,B,G))})})}return S.call(this,a,v,g,q,b,n,r,h,B,G)}p||(p=this.threshold||0);J(b)?(c=b,b=1E3):b||0===b||(b=1E3);if(this.g)for(this.F=c,this.u=0,this.o=[],k=0;k<this.g;k++)this.m[k].postMessage({search:!0,limit:b,cursor:h,threshold:p,content:a});else{if(!d){if(this.async&&"function"!==typeof importScripts){let a=this;p=new Promise(function(c){setTimeout(function(){c(a.search(f,b,null,!0));a=null})});if(c)p.then(c);else return p;return this}if(c)return c(this.search(f,b,null,!0)),this}if(!a||!I(a))return g;
|
||||
f=a;if(this.cache)if(this.B){if(c=this.l.get(a))return c}else this.l.clear(),this.B=!0;f=this.encode(f);if(!f.length)return g;c=this.f;c=J(c)?c(f):f.split(this.split);this.filter&&(c=P(c,this.filter));l=c.length;d=!0;e=[];var v=u();1<l&&(this.depth?(k=!0,t=c[0],v[t]=1):c.sort(ia));if(!k||(m=this.i)[t]){const a=this.b;for(let b=k?1:0;b<l;b++){const f=c[b];if(f){if(!v[f]){const b=[];let c=!1,g=0;if(t=k?m[t]:this.j){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(!n){d=!1;break}v[f]=1}t=f}}}else d=!1;d&&(g=Y(e,b,h,n));this.cache&&this.l.set(a,g);return g}};l.prototype.find=function(a,b){return this.where(a,b,1)[0]||null};l.prototype.where=function(a,b,c,d){const e=this.h,g=[];let f=0;let h;var l;if(F(a)){c||(c=b);var n=Object.keys(a);var p=n.length;h=!1;if(1===p&&"id"===n[0])return[e[a.id]];if((l=this.I)&&!d)for(var m=0;m<l.length;m++){var k=l[m],u=a[k];if(!D(u)){d=this.G[k]["@"+u];if(0===--p)return d;n.splice(n.indexOf(k),1);delete a[k];break}}l=
|
||||
Array(p);for(m=0;m<p;m++)l[m]=n[m].split(":")}else{if(J(a)){b=d||Object.keys(e);c=b.length;for(n=0;n<c;n++)p=e[b[n]],a(p)&&(g[f++]=p);return g}if(D(b))return[e[a]];if("id"===a)return[e[b]];n=[a];p=1;l=[a.split(":")];h=!0}d=d||Object.keys(e);m=d.length;for(k=0;k<m;k++){u=e[d[k]];let m=!0;for(let c=0;c<p;c++){h||(b=a[n[c]]);const d=l[c],e=d.length;let f=u;if(1<e)for(let a=0;a<e;a++)f=f[d[a]];else f=f[d[0]];if(f!==b){m=!1;break}}if(m&&(g[f++]=u,c&&f===c))break}return g};l.prototype.info=function(){if(this.g)for(let a=
|
||||
0;a<this.g;a++)this.m[a].postMessage({info:!0,id:this.id});else return{id:this.id,items:this.length,cache:this.cache&&this.cache.s?this.cache.s.length:!1,matcher:V.length+(this.v?this.v.length:0),worker:this.g,threshold:this.threshold,depth:this.depth,resolution:this.b,contextual:this.depth&&"strict"===this.f}};l.prototype.clear=function(){return this.destroy().init()};l.prototype.destroy=function(){this.cache&&(this.l.clear(),this.l=null);this.j=this.i=this.c=null;if(this.a){const a=this.a.keys;
|
||||
for(let b=0;b<a.length;b++)this.a.index[a[b]].destroy();this.a=this.h=null}return this};l.prototype.export=function(){if(this.a){const a=this.a.keys,b=Array(a.length+1);let c=0;for(;c<a.length;c++){const d=this.a.index[a[c]];b[c]=[d.j,d.i,Object.keys(d.c)]}b[c]=this.h;return JSON.stringify(b)}return JSON.stringify([this.j,this.i,Object.keys(this.c)])};l.prototype.import=function(a){a=JSON.parse(a);const b=u();if(this.a){var c=this.a.keys,d=c.length,e=a[0][2];for(var g=0;g<e.length;g++)b[e[g]]=1;for(e=
|
||||
0;e<d;e++)g=this.a.index[c[e]],g.j=a[e][0],g.i=a[e][1],g.c=b,g.h=a[d];this.h=a[d]}else{c=a[2];for(d=0;d<c.length;d++)b[c[d]]=1;this.j=a[0];this.i=a[1];this.c=b}};const R={icase:function(a){return a.toLowerCase()},simple:function(){const a=[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(b){b=M(b.toLowerCase(),a);return" "===b?"":b}}(),advanced:function(){const a=[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(b,c){if(!b)return b;b=this.simple(b);2<b.length&&(b=M(b,a));c||1<b.length&&(b=X(b));return b}}(),extra:function(){const a=
|
||||
[h("p"),"b",h("z"),"s",h("[cgq]"),"k",h("n"),"m",h("d"),"t",h("[vw]"),"f",h("[aeiouy]"),""];return function(b){if(!b)return b;b=this.advanced(b,!0);if(1<b.length){b=b.split(" ");for(let c=0;c<b.length;c++){const d=b[c];1<d.length&&(b[c]=d[0]+M(d.substring(1),a))}b=b.join(" ");b=X(b)}return b}}(),balance:function(){const a=[h("[-/]")," ",h("[^a-z0-9 ]"),"",h("\\s+")," "];return function(b){return X(M(b.toLowerCase(),a))}}()},la=function(){function a(a){this.clear();this.H=!0!==a&&a}a.prototype.clear=
|
||||
function(){this.cache=u();this.count=u();this.index=u();this.s=[]};a.prototype.set=function(a,c){if(this.H&&D(this.cache[a])){let b=this.s.length;if(b===this.H){b--;const a=this.s[b];delete this.cache[a];delete this.count[a];delete this.index[a]}this.index[a]=b;this.s[b]=a;this.count[a]=-1;this.cache[a]=c;this.get(a)}else this.cache[a]=c};a.prototype.get=function(a){const c=this.cache[a];if(this.H&&c){var b=++this.count[a];const c=this.index;let d=c[a];if(0<d){const f=this.s;for(var e=d;this.count[f[--d]]<=
|
||||
b&&-1!==d;);d++;if(d!==e){for(b=e;b>d;b--)e=f[b-1],f[b]=e,c[e]=b;f[d]=a;c[a]=d}}}return c};return a}();return l}(function(){const x={},N="undefined"!==typeof Blob&&"undefined"!==typeof URL&&URL.createObjectURL;return function(l,z,P,S,O){P=N?URL.createObjectURL(new Blob(["("+P.toString()+")()"],{type:"text/javascript"})):l+".min.js";l+="-"+z;x[l]||(x[l]=[]);x[l][O]=new Worker(P);x[l][O].onmessage=S;return x[l][O]}}()),this);
|
||||
'use strict';(function(y,L,m){let B;(B=m.define)&&B.amd?B([],function(){return L}):(B=m.modules)?B[y.toLowerCase()]=L:"object"===typeof exports?module.exports=L:m[y]=L})("FlexSearch",function da(y){function m(a,b){const c=b?b.id:a&&a.id;this.id=c||0===c?c:ea++;this.init(a,b);M(this,"index",function(){return this.a?Object.keys(this.a.index[this.a.keys[0]].c):Object.keys(this.c)});M(this,"length",function(){return this.index.length})}function B(a,b,c,d){this.u!==this.g&&(this.o=this.o.concat(c),this.u++,
|
||||
d&&this.o.length>=d&&(this.u=this.g),this.u===this.g&&(this.cache&&this.l.set(b,this.o),this.F&&this.F(this.o)));return this}function N(a,b){const c=a.length,d=J(b),e=[];for(let g=0,f=0;g<c;g++){const c=a[g];if(d&&b(c)||!d&&!b[c])e[f++]=c}return e}function R(a,b,c,d,e,g,f,l,r,p){c=Y(c,f?0:e,l,g,b,r,p);let q;l&&(l=c.page,q=c.next,c=c.result);if(f)b=this.where(f,null,e,c);else{b=c;c=this.h;e=b.length;g=Array(e);for(f=0;f<e;f++)g[f]=c[b[f]];b=g}c=b;d&&(J(d)||(A=d.split(":"),1<A.length?d=fa:(A=A[0],d=
|
||||
ha)),c.sort(d));c=O(l,q,c);this.cache&&this.l.set(a,c);return c}function M(a,b,c){Object.defineProperty(a,b,{get:c})}function h(a){return new RegExp(a,"g")}function K(a,b){for(let c=0;c<b.length;c+=2)a=a.replace(b[c],b[c+1]);return a}function S(a,b,c,d,e,g,f,l){if(b[c])return b[c];e=e?(l-(f||l/1.5))*g+(f||l/1.5)*e:g;b[c]=e;e>=f&&(a=a[l-(e+.5>>0)],a=a[c]||(a[c]=[]),a[a.length]=d);return e}function W(a,b){if(a){const c=Object.keys(a);for(let d=0,e=c.length;d<e;d++){const e=c[d],f=a[e];if(f)for(let c=
|
||||
0,d=f.length;c<d;c++)if(f[c]===b){1===d?delete a[e]:f.splice(c,1);break}else E(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[A];b=b[A];return a<b?-1:a>b?1:0}function fa(a,
|
||||
b){const c=A.length;for(let d=0;d<c;d++)a=a[A[d]],b=b[A[d]];return a<b?-1:a>b?1:0}function O(a,b,c){return a?{page:a,next:b?""+b:null,result:c}:c}function Y(a,b,c,d,e,g,f){let l,r=[];if(!0===c){c="0";var p=""}else p=c&&c.split(":");const q=a.length;if(1<q){const U=w();let D=[],P,I;var n=0,k;let u;var h=!0;let F,G=0,x,z,y,B;p&&(2===p.length?(y=p,p=!1):p=B=parseInt(p[0],10));if(f){for(P=w();n<q;n++)if("not"===e[n])for(I=a[n],u=I.length,k=0;k<u;k++)P["@"+I[k]]=1;else z=n+1;if(C(z))return O(c,l,r);n=
|
||||
0}else x=H(e)&&e;let A;for(;n<q;n++){const w=n===(z||q)-1;if(!x||!n)if((k=x||e&&e[n])&&"and"!==k)if("or"===k)A=!1;else continue;else A=g=!0;I=a[n];if(u=I.length){if(h)if(F){var t=F.length;for(k=0;k<t;k++){h=F[k];var m="@"+h;f&&P[m]||(U[m]=1,g||(r[G++]=h))}F=null;h=!1}else{F=I;continue}m=!1;for(k=0;k<u;k++){t=I[k];var v="@"+t;const a=g?U[v]||0:n;if(!(!a&&!d||f&&P[v]||!g&&U[v]))if(a===n){if(w){if(!B||--B<G)if(r[G++]=t,b&&G===b)return O(c,G+(p||0),r)}else U[v]=n+1;m=!0}else d&&(v=D[a]||(D[a]=[]),v[v.length]=
|
||||
t)}if(A&&!m&&!d)break}else if(A&&!d)return O(c,l,I)}if(F)if(n=F.length,f)for(k=p?parseInt(p,10):0;k<n;k++)a=F[k],P["@"+a]||(r[G++]=a);else r=F;if(d)for(G=r.length,y?(n=parseInt(y[0],10)+1,k=parseInt(y[1],10)+1):(n=D.length,k=0);n--;)if(t=D[n]){for(u=t.length;k<u;k++)if(d=t[k],!f||!P["@"+d])if(r[G++]=d,b&&G===b)return O(c,n+":"+k,r);k=0}}else!q||e&&"not"===e[0]||(r=a[0],p&&(p=parseInt(p[0],10)));b&&(f=r.length,p&&p>f&&(p=0),p=p||0,l=p+b,l<f?r=r.slice(p,l):(l=0,p&&(r=r.slice(p))));return O(c,l,r)}function H(a){return"string"===
|
||||
typeof a}function z(a){return a.constructor===Array}function J(a){return"function"===typeof a}function E(a){return"object"===typeof a}function C(a){return"undefined"===typeof a}function Z(a){const b=Array(a);for(let c=0;c<a;c++)b[c]=w();return b}function w(){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=y("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 x={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={};m.create=function(a,b){return new m(a,b)};m.registerMatcher=function(a){for(const b in a)a.hasOwnProperty(b)&&V.push(h(b),a[b]);return this};m.registerEncoder=function(a,b){Q[a]=b.bind(Q);return this};m.registerLanguage=function(a,b){ba[a]=b.filter;ca[a]=b.stemmer;return this};m.encode=function(a,b){return Q[a](b)};m.prototype.init=function(a,b){this.v=[];if(b){var c=b.preset;a=b}else a||(a=x),c=a.preset;b={};H(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,B.bind(this))}this.f=a.tokenize||b.f||this.f||x.f;this.split=a.split||this.split||x.split;this.D=a.rtl||this.D||x.D;this.async="undefined"===typeof Promise||C(c=a.async)?this.async||x.async:c;this.g=C(c=a.worker)?this.g||x.g:c;this.threshold=C(c=a.threshold)?b.threshold||this.threshold||
|
||||
x.threshold:c;this.b=C(c=a.resolution)?c=b.b||this.b||x.b:c;c<=this.threshold&&(this.b=this.threshold+1);this.depth="strict"!==this.f||C(c=a.depth)?b.depth||this.depth||x.depth:c;this.w=(c=C(c=a.encode)?b.encode||x.encode:c)&&Q[c]&&Q[c].bind(Q)||(J(c)?c:this.w||!1);(c=a.matcher)&&this.addMatcher(c);if(c=(b=a.lang)||a.filter){H(c)&&(c=ba[c]);if(z(c)){d=this.w;e=w();for(var g=0;g<c.length;g++){var f=d?d(c[g]):c[g];e[f]=1}c=e}this.filter=c}if(c=b||a.stemmer){var l;b=H(c)?ca[c]:c;d=this.w;e=[];for(l in b)b.hasOwnProperty(l)&&
|
||||
(g=d?d(l):l,e.push(h(g+"($|\\W)"),d?d(b[l]):b[l]));this.stemmer=l=e}this.a=e=(c=a.doc)?c:this.a||x.a;this.j=Z(this.b-(this.threshold||0));this.i=w();this.c=w();if(e){this.h=w();a.doc=null;l=e.index={};b=e.keys=[];d=e.field;g=e.tag;z(e.id)||(e.id=e.id.split(":"));if(g){this.G=w();f=w();if(d)if(H(d))f[d]=a;else if(z(d))for(let b=0;b<d.length;b++)f[d[b]]=a;else E(d)&&(f=d);z(g)||(e.tag=g=[g]);for(d=0;d<g.length;d++)this.G[g[d]]=w();this.I=g;d=f}if(d){let c;z(d)||(E(d)?(c=d,e.field=d=Object.keys(d)):
|
||||
e.field=d=[d]);for(e=0;e<d.length;e++)g=d[e],z(g)||(c&&(a=c[g]),b[e]=g,d[e]=g.split(":")),l[g]=new m(a),l[g].h=this.h}}this.B=!0;this.l=(this.cache=c=C(c=a.cache)?this.cache||x.cache:c)?new la(c):!1;return this};m.prototype.encode=function(a){a&&V.length&&(a=K(a,V));a&&this.v.length&&(a=K(a,this.v));a&&this.w&&(a=this.w(a));a&&this.stemmer&&(a=K(a,this.stemmer));return a};m.prototype.addMatcher=function(a){const b=this.v;for(const c in a)a.hasOwnProperty(c)&&b.push(h(c),a[c]);return this};m.prototype.add=
|
||||
function(a,b,c,d,e){if(this.a&&E(a))return this.A("add",a,b);if(b&&H(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=N(e,this.filter));const n=w();n._ctx=w();const k=e.length,h=this.threshold,m=this.depth,u=this.b,v=this.j,T=this.D;for(let b=0;b<k;b++){var f=e[b];if(f){var l=f.length,r=(T?b+1:k-b)/k,p="";switch(c){case "reverse":case "both":for(var q=l;--q;)p=f[q]+p,S(v,n,p,a,T?1:(l-q)/l,r,h,u-1);p="";case "forward":for(q=0;q<l;q++)p+=f[q],S(v,n,p,a,T?(q+1)/l:1,r,h,u-1);break;case "full":for(q=0;q<l;q++){const b=
|
||||
(T?q+1:l-q)/l;for(let c=l;c>q;c--)p=f.substring(q,c),S(v,n,p,a,b,r,h,u-1)}break;default:if(l=S(v,n,f,a,1,r,h,u-1),m&&1<k&&l>=h)for(l=n._ctx[f]||(n._ctx[f]=w()),f=this.i[f]||(this.i[f]=Z(u-(h||0))),r=b-m,p=b+m+1,0>r&&(r=0),p>k&&(p=k);r<p;r++)r!==b&&S(f,l,e[r],a,0,u-(r<b?b-r:r-b),h,u-1)}}}this.c[g]=1;this.B=!1}return this};m.prototype.A=function(a,b,c){if(z(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 h=this.a.index,p=this.a.keys;var d=this.a.tag,e=
|
||||
this.a.id;let q;let n;for(var g=0;g<e.length;g++)q=(q||b)[e[g]];if(d){for(e=0;e<d.length;e++){var f=d[e];var l=f.split(":");for(g=0;g<l.length;g++)n=(n||b)[l[g]];n="@"+n}l=this.G[f];l=l[n]||(l[n]=[])}if("remove"===a){delete this.h[q];for(let a=0,b=p.length;a<b;a++){if(a===b-1)return h[p[a]].remove(q,c),this;h[p[a]].remove(q)}}e=this.a.field;l&&(l[l.length]=b);this.h[q]=b;for(let g=0,l=e.length;g<l;g++){d=e[g];let k;for(f=0;f<d.length;f++)k=(k||b)[d[f]];d=h[p[g]];f="add"===a?d.add:d.update;g===l-1?
|
||||
f.call(d,q,k,c):f.call(d,q,k)}}return this};m.prototype.update=function(a,b,c){if(this.a&&E(a))return this.A("update",a,b);this.c["@"+a]&&H(b)&&(this.remove(a),this.add(a,b,c,!0));return this};m.prototype.remove=function(a,b,c){if(this.a&&E(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 A;m.prototype.search=function(a,b,c,d){if(E(b)){if(z(b))for(var e=0;e<b.length;e++)b[e].query=a;else b.query=a;a=b;b=1E3}else b&&J(b)?(c=b,b=1E3):b||0===b||(b=1E3);let g=[],f=a;let l,h,p;if(E(a)&&!z(a)){c||(c=a.callback)&&(f.callback=null);h=a.sort;l=a.page;b=a.limit;
|
||||
var q=a.threshold;p=a.suggest;a=a.query}if(this.a){q=this.a.index;const r=f.where;var n=f.bool||"or",k=f.field;let D=n;let u,v;if(k)z(k)||(k=[k]);else if(z(f)){var m=f;k=[];D=[];for(var t=0;t<f.length;t++)d=f[t],e=d.bool||n,k[t]=d.field,D[t]=e,"not"===e?u=!0:"and"===e&&(v=!0)}else k=this.a.keys;n=k.length;for(t=0;t<n;t++)m&&(f=m[t]),l&&!H(f)&&(f.page=null,f.limit=0),g[t]=q[k[t]].search(f,0);if(c)return c(R.call(this,a,D,g,h,b,p,r,l,v,u));if(this.async){const c=this;return new Promise(function(d){Promise.all(g).then(function(e){d(R.call(c,
|
||||
a,D,e,h,b,p,r,l,v,u))})})}return R.call(this,a,D,g,h,b,p,r,l,v,u)}q||(q=this.threshold||0);if(this.g)for(this.F=c,this.u=0,this.o=[],k=0;k<this.g;k++)this.m[k].postMessage({search:!0,limit:b,cursor:l,threshold:q,content:a});else{if(!d){if(this.async&&"function"!==typeof importScripts){let a=this;q=new Promise(function(c){setTimeout(function(){c(a.search(f,b,null,!0));a=null})});if(c)q.then(c);else return q;return this}if(c)return c(this.search(f,b,null,!0)),this}if(!a||!H(a))return g;f=a;if(this.cache)if(this.B){if(c=
|
||||
this.l.get(a))return c}else this.l.clear(),this.B=!0;f=this.encode(f);if(!f.length)return g;c=this.f;c=J(c)?c(f):f.split(this.split);this.filter&&(c=N(c,this.filter));m=c.length;d=!0;e=[];var u=w(),v=0;1<m&&(this.depth&&"strict"===this.f?n=!0:c.sort(ia));if(!n||(t=this.i)){const a=this.b;for(;v<m;v++){let b=c[v];if(b){if(n){if(!k)if(t[b])k=b,u[b]=1;else if(!p)return g;if(p&&v===m-1&&!e.length)n=!1,b=k||b,u[b]=0;else if(!k)continue}if(!u[b]){const c=[];let f=!1,g=0;const l=n?t[k]:this.j;if(l){let d;
|
||||
for(let e=0;e<a-q;e++)if(d=l[e][b])c[g++]=d,f=!0}if(f)k=b,e[e.length]=1<g?c.concat.apply([],c):c[0];else if(!p){d=!1;break}u[b]=1}}}}else d=!1;d&&(g=Y(e,b,l,p));this.cache&&this.l.set(a,g);return g}};m.prototype.find=function(a,b){return this.where(a,b,1)[0]||null};m.prototype.where=function(a,b,c,d){const e=this.h,g=[];let f=0;let l;var h;let p;if(E(a)){c||(c=b);var q=Object.keys(a);var n=q.length;l=!1;if(1===n&&"id"===q[0])return[e[a.id]];if((h=this.I)&&!d)for(var k=0;k<h.length;k++){var m=h[k],
|
||||
t=a[m];if(!C(t)){p=this.G[m]["@"+t];if(0===--n)return p;q.splice(q.indexOf(m),1);delete a[m];break}}h=Array(n);for(k=0;k<n;k++)h[k]=q[k].split(":")}else{if(J(a)){b=d||Object.keys(e);c=b.length;for(q=0;q<c;q++)n=e[b[q]],a(n)&&(g[f++]=n);return g}if(C(b))return[e[a]];if("id"===a)return[e[b]];q=[a];n=1;h=[a.split(":")];l=!0}d=p||d||Object.keys(e);k=d.length;for(m=0;m<k;m++){t=p?d[m]:e[d[m]];let k=!0;for(let c=0;c<n;c++){l||(b=a[q[c]]);const d=h[c],e=d.length;let f=t;if(1<e)for(let a=0;a<e;a++)f=f[d[a]];
|
||||
else f=f[d[0]];if(f!==b){k=!1;break}}if(k&&(g[f++]=t,c&&f===c))break}return g};m.prototype.info=function(){if(this.g)for(let a=0;a<this.g;a++)this.m[a].postMessage({info:!0,id:this.id});else return{id:this.id,items:this.length,cache:this.cache&&this.cache.s?this.cache.s.length:!1,matcher:V.length+(this.v?this.v.length:0),worker:this.g,threshold:this.threshold,depth:this.depth,resolution:this.b,contextual:this.depth&&"strict"===this.f}};m.prototype.clear=function(){return this.destroy().init()};m.prototype.destroy=
|
||||
function(){this.cache&&(this.l.clear(),this.l=null);this.j=this.i=this.c=null;if(this.a){const a=this.a.keys;for(let b=0;b<a.length;b++)this.a.index[a[b]].destroy();this.a=this.h=null}return this};m.prototype.export=function(){let a;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.j,d.i,Object.keys(d.c)]}a[c]=this.h}else a=[this.j,this.i,Object.keys(this.c)];return JSON.stringify(a)};m.prototype.import=function(a){a=JSON.parse(a);const b=
|
||||
w();if(this.a){var c=this.a.keys,d=c.length,e=a[0][2];for(var g=0;g<e.length;g++)b[e[g]]=1;for(e=0;e<d;e++)g=this.a.index[c[e]],g.j=a[e][0],g.i=a[e][1],g.c=b,g.h=a[d];this.h=a[d]}else{c=a[2];for(d=0;d<c.length;d++)b[c[d]]=1;this.j=a[0];this.i=a[1];this.c=b}};const Q={icase:function(a){return a.toLowerCase()},simple:function(){const a=[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(b){b=K(b.toLowerCase(),a);return" "===b?"":b}}(),advanced:function(){const a=[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(b,
|
||||
c){if(!b)return b;b=this.simple(b);2<b.length&&(b=K(b,a));c||1<b.length&&(b=X(b));return b}}(),extra:function(){const a=[h("p"),"b",h("z"),"s",h("[cgq]"),"k",h("n"),"m",h("d"),"t",h("[vw]"),"f",h("[aeiouy]"),""];return function(b){if(!b)return b;b=this.advanced(b,!0);if(1<b.length){b=b.split(" ");for(let c=0;c<b.length;c++){const d=b[c];1<d.length&&(b[c]=d[0]+K(d.substring(1),a))}b=b.join(" ");b=X(b)}return b}}(),balance:function(){const a=[h("[-/]")," ",h("[^a-z0-9 ]"),"",h("\\s+")," "];return function(b){return X(K(b.toLowerCase(),
|
||||
a))}}()},la=function(){function a(a){this.clear();this.H=!0!==a&&a}a.prototype.clear=function(){this.cache=w();this.count=w();this.index=w();this.s=[]};a.prototype.set=function(a,c){if(this.H&&C(this.cache[a])){let b=this.s.length;if(b===this.H){b--;const a=this.s[b];delete this.cache[a];delete this.count[a];delete this.index[a]}this.index[a]=b;this.s[b]=a;this.count[a]=-1;this.cache[a]=c;this.get(a)}else this.cache[a]=c};a.prototype.get=function(a){const b=this.cache[a];if(this.H&&b){var d=++this.count[a];
|
||||
const b=this.index;let c=b[a];if(0<c){const f=this.s;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 a}();return m}(function(){const y={},L="undefined"!==typeof Blob&&"undefined"!==typeof URL&&URL.createObjectURL;return function(m,B,N,R,M){N=L?URL.createObjectURL(new Blob(["("+N.toString()+")()"],{type:"text/javascript"})):m+".min.js";m+="-"+B;y[m]||(y[m]=[]);y[m][M]=new Worker(N);y[m][M].onmessage=R;return y[m][M]}}()),
|
||||
this);
|
||||
|
60
dist/flexsearch.node.js
vendored
60
dist/flexsearch.node.js
vendored
@@ -1,36 +1,36 @@
|
||||
/*
|
||||
FlexSearch v0.6.1
|
||||
FlexSearch v0.6.2
|
||||
Copyright 2019 Nextapps GmbH
|
||||
Author: Thomas Wilkerling
|
||||
Released under the Apache 2.0 Licence
|
||||
https://github.com/nextapps-de/flexsearch
|
||||
*/
|
||||
'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 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={};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 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 n}(!1),this);
|
||||
'use strict';(function(m,H,I){let z;(z=I.define)&&z.amd?z([],function(){return H}):(z=I.modules)?z[m.toLowerCase()]=H:"object"===typeof exports?module.exports=H:I[m]=H})("FlexSearch",function(){function m(a,b){const c=b?b.id:a&&a.id;this.id=c||0===c?c:aa++;this.init(a,b);z(this,"index",function(){return this.a?Object.keys(this.a.index[this.a.keys[0]].f):Object.keys(this.f)});z(this,"length",function(){return this.index.length})}function H(a,b){const c=a.length,d=J(b),e=[];for(let g=0,f=0;g<c;g++){const c=
|
||||
a[g];if(d&&b(c)||!d&&!b[c])e[f++]=c}return e}function I(a,b,c,d,e,g,f,k,r,p){c=V(c,f?0:e,k,g,b,r,p);let q;k&&(k=c.page,q=c.next,c=c.result);if(f)b=this.where(f,null,e,c);else{b=c;c=this.g;e=b.length;g=Array(e);for(f=0;f<e;f++)g[f]=c[b[f]];b=g}c=b;d&&(J(d)||(y=d.split(":"),1<y.length?d=ba:(y=y[0],d=ca)),c.sort(d));c=L(k,q,c);this.cache&&this.j.set(a,c);return c}function z(a,b,c){Object.defineProperty(a,b,{get:c})}function h(a){return new RegExp(a,"g")}function K(a,b){for(let c=0;c<b.length;c+=2)a=
|
||||
a.replace(b[c],b[c+1]);return a}function P(a,b,c,d,e,g,f,k){if(b[c])return b[c];e=e?(k-(f||k/1.5))*g+(f||k/1.5)*e:g;b[c]=e;e>=f&&(a=a[k-(e+.5>>0)],a=a[c]||(a[c]=[]),a[a.length]=d);return e}function T(a,b){if(a){const c=Object.keys(a);for(let d=0,e=c.length;d<e;d++){const e=c[d],f=a[e];if(f)for(let c=0,d=f.length;c<d;c++)if(f[c]===b){1===d?delete a[e]:f.splice(c,1);break}else A(f[c])&&T(f[c],b)}}}function U(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 da(a,b){a=a.length-b.length;return 0>a?1:a?-1:0}function ca(a,b){a=a[y];b=b[y];return a<b?-1:a>b?1:0}function ba(a,b){const c=y.length;for(let d=0;d<c;d++)a=a[y[d]],b=b[y[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 V(a,b,c,d,e,g,f){let k,r=[];if(!0===c){c="0";var p=
|
||||
""}else p=c&&c.split(":");const q=a.length;if(1<q){const R=u();let B=[],M,G;var n=0,l;let N;var h=!0;let D,E=0,x,w,y,A;p&&(2===p.length?(y=p,p=!1):p=A=parseInt(p[0],10));if(f){for(M=u();n<q;n++)if("not"===e[n])for(G=a[n],N=G.length,l=0;l<N;l++)M["@"+G[l]]=1;else w=n+1;if(C(w))return L(c,k,r);n=0}else x=F(e)&&e;let z;for(;n<q;n++){const u=n===(w||q)-1;if(!x||!n)if((l=x||e&&e[n])&&"and"!==l)if("or"===l)z=!1;else continue;else z=g=!0;G=a[n];if(N=G.length){if(h)if(D){var t=D.length;for(l=0;l<t;l++){h=
|
||||
D[l];var m="@"+h;f&&M[m]||(R[m]=1,g||(r[E++]=h))}D=null;h=!1}else{D=G;continue}m=!1;for(l=0;l<N;l++){t=G[l];var v="@"+t;const a=g?R[v]||0:n;if(!(!a&&!d||f&&M[v]||!g&&R[v]))if(a===n){if(u){if(!A||--A<E)if(r[E++]=t,b&&E===b)return L(c,E+(p||0),r)}else R[v]=n+1;m=!0}else d&&(v=B[a]||(B[a]=[]),v[v.length]=t)}if(z&&!m&&!d)break}else if(z&&!d)return L(c,k,G)}if(D)if(n=D.length,f)for(l=p?parseInt(p,10):0;l<n;l++)a=D[l],M["@"+a]||(r[E++]=a);else r=D;if(d)for(E=r.length,y?(n=parseInt(y[0],10)+1,l=parseInt(y[1],
|
||||
10)+1):(n=B.length,l=0);n--;)if(t=B[n]){for(N=t.length;l<N;l++)if(d=t[l],!f||!M["@"+d])if(r[E++]=d,b&&E===b)return L(c,n+":"+l,r);l=0}}else!q||e&&"not"===e[0]||(r=a[0],p&&(p=parseInt(p[0],10)));b&&(f=r.length,p&&p>f&&(p=0),p=p||0,k=p+b,k<f?r=r.slice(p,k):(k=0,p&&(r=r.slice(p))));return L(c,k,r)}function F(a){return"string"===typeof a}function x(a){return a.constructor===Array}function J(a){return"function"===typeof a}function A(a){return"object"===typeof a}function C(a){return"undefined"===typeof a}
|
||||
function W(a){const b=Array(a);for(let c=0;c<a;c++)b[c]=u();return b}function u(){return Object.create(null)}const w={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(a,b){return new m(a,b)};m.registerMatcher=function(a){for(const b in a)a.hasOwnProperty(b)&&S.push(h(b),a[b]);return this};m.registerEncoder=function(a,b){O[a]=b.bind(O);return this};m.registerLanguage=function(a,b){Y[a]=b.filter;Z[a]=b.stemmer;return this};m.encode=function(a,b){return O[a](b)};m.prototype.init=function(a,b){this.m=[];if(b){var c=b.preset;a=b}else a||(a=w),c=a.preset;b={};F(a)?(b=X[a],a={}):c&&(b=
|
||||
X[c]);this.c=a.tokenize||b.c||this.c||w.c;this.split=a.split||this.split||w.split;this.v=a.rtl||this.v||w.v;this.async="undefined"===typeof Promise||C(c=a.async)?this.async||w.async:c;this.threshold=C(c=a.threshold)?b.threshold||this.threshold||w.threshold:c;this.b=C(c=a.resolution)?c=b.b||this.b||w.b:c;c<=this.threshold&&(this.b=this.threshold+1);this.depth="strict"!==this.c||C(c=a.depth)?b.depth||this.depth||w.depth:c;this.o=(c=C(c=a.encode)?b.encode||w.encode:c)&&O[c]&&O[c].bind(O)||(J(c)?c:this.o||
|
||||
!1);(c=a.matcher)&&this.addMatcher(c);if(c=(b=a.lang)||a.filter){F(c)&&(c=Y[c]);if(x(c)){var d=this.o,e=u();for(var g=0;g<c.length;g++){var f=d?d(c[g]):c[g];e[f]=1}c=e}this.filter=c}if(c=b||a.stemmer){var k;b=F(c)?Z[c]:c;d=this.o;e=[];for(k in b)b.hasOwnProperty(k)&&(g=d?d(k):k,e.push(h(g+"($|\\W)"),d?d(b[k]):b[k]));this.stemmer=k=e}this.a=e=(c=a.doc)?c:this.a||w.a;this.i=W(this.b-(this.threshold||0));this.h=u();this.f=u();if(e){this.g=u();a.doc=null;k=e.index={};b=e.keys=[];d=e.field;g=e.tag;x(e.id)||
|
||||
(e.id=e.id.split(":"));if(g){this.w=u();f=u();if(d)if(F(d))f[d]=a;else if(x(d))for(let b=0;b<d.length;b++)f[d[b]]=a;else A(d)&&(f=d);x(g)||(e.tag=g=[g]);for(d=0;d<g.length;d++)this.w[g[d]]=u();this.B=g;d=f}if(d){let c;x(d)||(A(d)?(c=d,e.field=d=Object.keys(d)):e.field=d=[d]);for(e=0;e<d.length;e++)g=d[e],x(g)||(c&&(a=c[g]),b[e]=g,d[e]=g.split(":")),k[g]=new m(a),k[g].g=this.g}}this.u=!0;this.j=(this.cache=c=C(c=a.cache)?this.cache||w.cache:c)?new ea(c):!1;return this};m.prototype.encode=function(a){a&&
|
||||
S.length&&(a=K(a,S));a&&this.m.length&&(a=K(a,this.m));a&&this.o&&(a=this.o(a));a&&this.stemmer&&(a=K(a,this.stemmer));return a};m.prototype.addMatcher=function(a){const b=this.m;for(const c in a)a.hasOwnProperty(c)&&b.push(h(c),a[c]);return this};m.prototype.add=function(a,b,c,d,e){if(this.a&&A(a))return this.s("add",a,b);if(b&&F(b)&&(a||0===a)){var g="@"+a;if(this.f[g]&&!d)return this.update(a,b);if(!e){if(this.async){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.c;e=J(c)?c(b):b.split(this.split);this.filter&&(e=H(e,this.filter));const n=u();n._ctx=u();const l=e.length,h=this.threshold,t=this.depth,m=this.b,v=this.i,Q=this.v;for(let b=0;b<l;b++){var f=e[b];if(f){var k=f.length,r=(Q?b+1:l-b)/l,p="";switch(c){case "reverse":case "both":for(var q=k;--q;)p=f[q]+p,P(v,n,p,a,Q?1:(k-q)/k,r,h,m-1);p="";case "forward":for(q=
|
||||
0;q<k;q++)p+=f[q],P(v,n,p,a,Q?(q+1)/k:1,r,h,m-1);break;case "full":for(q=0;q<k;q++){const b=(Q?q+1:k-q)/k;for(let c=k;c>q;c--)p=f.substring(q,c),P(v,n,p,a,b,r,h,m-1)}break;default:if(k=P(v,n,f,a,1,r,h,m-1),t&&1<l&&k>=h)for(k=n._ctx[f]||(n._ctx[f]=u()),f=this.h[f]||(this.h[f]=W(m-(h||0))),r=b-t,p=b+t+1,0>r&&(r=0),p>l&&(p=l);r<p;r++)r!==b&&P(f,k,e[r],a,0,m-(r<b?b-r:r-b),h,m-1)}}}this.f[g]=1;this.u=!1}return this};m.prototype.s=function(a,b,c){if(x(b))for(let d=0,e=b.length;d<e;d++){if(d===e-1)return this.s(a,
|
||||
b[d],c);this.s(a,b[d])}else{const h=this.a.index,p=this.a.keys;var d=this.a.tag,e=this.a.id;let q;let n;for(var g=0;g<e.length;g++)q=(q||b)[e[g]];if(d){for(e=0;e<d.length;e++){var f=d[e];var k=f.split(":");for(g=0;g<k.length;g++)n=(n||b)[k[g]];n="@"+n}k=this.w[f];k=k[n]||(k[n]=[])}if("remove"===a){delete this.g[q];for(let b=0,a=p.length;b<a;b++){if(b===a-1)return h[p[b]].remove(q,c),this;h[p[b]].remove(q)}}e=this.a.field;k&&(k[k.length]=b);this.g[q]=b;for(let g=0,k=e.length;g<k;g++){d=e[g];let l;
|
||||
for(f=0;f<d.length;f++)l=(l||b)[d[f]];d=h[p[g]];f="add"===a?d.add:d.update;g===k-1?f.call(d,q,l,c):f.call(d,q,l)}}return this};m.prototype.update=function(a,b,c){if(this.a&&A(a))return this.s("update",a,b);this.f["@"+a]&&F(b)&&(this.remove(a),this.add(a,b,c,!0));return this};m.prototype.remove=function(a,b,c){if(this.a&&A(a))return this.s("remove",a,b);var d="@"+a;if(this.f[d]){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++)T(this.i[b],a);this.depth&&T(this.h,a);delete this.f[d];this.u=!1}return this};let y;m.prototype.search=function(a,b,c,d){if(A(b)){if(x(b))for(var e=0;e<b.length;e++)b[e].query=a;else b.query=a;a=b;b=1E3}else b&&J(b)?(c=b,b=1E3):b||0===b||(b=1E3);let g=[],f=a;let k,h,p;if(A(a)&&!x(a)){c||(c=a.callback)&&(f.callback=null);h=a.sort;k=a.page;b=a.limit;
|
||||
var q=a.threshold;p=a.suggest;a=a.query}if(this.a){q=this.a.index;const r=f.where;var n=f.bool||"or",l=f.field;let B=n;let v,u;if(l)x(l)||(l=[l]);else if(x(f)){var m=f;l=[];B=[];for(var t=0;t<f.length;t++)d=f[t],e=d.bool||n,l[t]=d.field,B[t]=e,"not"===e?v=!0:"and"===e&&(u=!0)}else l=this.a.keys;n=l.length;for(t=0;t<n;t++)m&&(f=m[t]),k&&!F(f)&&(f.page=null,f.limit=0),g[t]=q[l[t]].search(f,0);if(c)return c(I.call(this,a,B,g,h,b,p,r,k,u,v));if(this.async){const c=this;return new Promise(function(d){Promise.all(g).then(function(e){d(I.call(c,
|
||||
a,B,e,h,b,p,r,k,u,v))})})}return I.call(this,a,B,g,h,b,p,r,k,u,v)}q||(q=this.threshold||0);if(!d){if(this.async&&"function"!==typeof importScripts){let a=this;q=new Promise(function(c){setTimeout(function(){c(a.search(f,b,null,!0));a=null})});if(c)q.then(c);else return q;return this}if(c)return c(this.search(f,b,null,!0)),this}if(!a||!F(a))return g;f=a;if(this.cache)if(this.u){if(c=this.j.get(a))return c}else this.j.clear(),this.u=!0;f=this.encode(f);if(!f.length)return g;c=this.c;c=J(c)?c(f):f.split(this.split);
|
||||
this.filter&&(c=H(c,this.filter));m=c.length;d=!0;e=[];const w=u();let v=0;1<m&&(this.depth&&"strict"===this.c?n=!0:c.sort(da));if(!n||(t=this.h)){const b=this.b;for(;v<m;v++){let a=c[v];if(a){if(n){if(!l)if(t[a])l=a,w[a]=1;else if(!p)return g;if(p&&v===m-1&&!e.length)n=!1,a=l||a,w[a]=0;else if(!l)continue}if(!w[a]){const c=[];let f=!1,g=0;const k=n?t[l]:this.i;if(k){let d;for(let e=0;e<b-q;e++)if(d=k[e][a])c[g++]=d,f=!0}if(f)l=a,e[e.length]=1<g?c.concat.apply([],c):c[0];else if(!p){d=!1;break}w[a]=
|
||||
1}}}}else d=!1;d&&(g=V(e,b,k,p));this.cache&&this.j.set(a,g);return g};m.prototype.find=function(a,b){return this.where(a,b,1)[0]||null};m.prototype.where=function(a,b,c,d){const e=this.g,g=[];let f=0;let k;var h;let p;if(A(a)){c||(c=b);var q=Object.keys(a);var n=q.length;k=!1;if(1===n&&"id"===q[0])return[e[a.id]];if((h=this.B)&&!d)for(var l=0;l<h.length;l++){var m=h[l],t=a[m];if(!C(t)){p=this.w[m]["@"+t];if(0===--n)return p;q.splice(q.indexOf(m),1);delete a[m];break}}h=Array(n);for(l=0;l<n;l++)h[l]=
|
||||
q[l].split(":")}else{if(J(a)){b=d||Object.keys(e);c=b.length;for(q=0;q<c;q++)n=e[b[q]],a(n)&&(g[f++]=n);return g}if(C(b))return[e[a]];if("id"===a)return[e[b]];q=[a];n=1;h=[a.split(":")];k=!0}d=p||d||Object.keys(e);l=d.length;for(m=0;m<l;m++){t=p?d[m]:e[d[m]];let l=!0;for(let c=0;c<n;c++){k||(b=a[q[c]]);const d=h[c],e=d.length;let f=t;if(1<e)for(let a=0;a<e;a++)f=f[d[a]];else f=f[d[0]];if(f!==b){l=!1;break}}if(l&&(g[f++]=t,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 a=this.a.keys;for(let b=0;b<a.length;b++)this.a.index[a[b]].destroy();this.a=this.g=null}return this};m.prototype.export=
|
||||
function(){let a;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}else a=[this.i,this.h,Object.keys(this.f)];return JSON.stringify(a)};m.prototype.import=function(a){a=JSON.parse(a);const b=u();if(this.a){var c=this.a.keys,d=c.length,e=a[0][2];for(var g=0;g<e.length;g++)b[e[g]]=1;for(e=0;e<d;e++)g=this.a.index[c[e]],g.i=a[e][0],g.h=a[e][1],g.f=b,g.g=a[d];this.g=a[d]}else{c=a[2];for(d=0;d<c.length;d++)b[c[d]]=
|
||||
1;this.i=a[0];this.h=a[1];this.f=b}};const O={icase:function(a){return a.toLowerCase()},simple:function(){const a=[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(b){b=K(b.toLowerCase(),
|
||||
a);return" "===b?"":b}}(),advanced:function(){const a=[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(b,c){if(!b)return b;b=this.simple(b);2<b.length&&(b=K(b,a));c||1<b.length&&(b=U(b));return b}}(),extra:function(){const a=[h("p"),"b",h("z"),"s",h("[cgq]"),"k",h("n"),"m",h("d"),"t",h("[vw]"),"f",h("[aeiouy]"),""];return function(b){if(!b)return b;
|
||||
b=this.advanced(b,!0);if(1<b.length){b=b.split(" ");for(let c=0;c<b.length;c++){const d=b[c];1<d.length&&(b[c]=d[0]+K(d.substring(1),a))}b=b.join(" ");b=U(b)}return b}}(),balance:function(){const a=[h("[-/]")," ",h("[^a-z0-9 ]"),"",h("\\s+")," "];return function(b){return U(K(b.toLowerCase(),a))}}()},ea=function(){function a(a){this.clear();this.A=!0!==a&&a}a.prototype.clear=function(){this.cache=u();this.count=u();this.index=u();this.l=[]};a.prototype.set=function(a,c){if(this.A&&C(this.cache[a])){let b=
|
||||
this.l.length;if(b===this.A){b--;const a=this.l[b];delete this.cache[a];delete this.count[a];delete this.index[a]}this.index[a]=b;this.l[b]=a;this.count[a]=-1;this.cache[a]=c;this.get(a)}else this.cache[a]=c};a.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 a}();return m}(!1),this);
|
||||
|
986
dist/flexsearch.pre.js
vendored
Normal file
986
dist/flexsearch.pre.js
vendored
Normal file
@@ -0,0 +1,986 @@
|
||||
/*
|
||||
FlexSearch v0.6.2
|
||||
Copyright 2019 Nextapps GmbH
|
||||
Author: Thomas Wilkerling
|
||||
Released under the Apache 2.0 Licence
|
||||
https://github.com/nextapps-de/flexsearch
|
||||
*/
|
||||
'use strict';
|
||||
(function(m, H, I) {
|
||||
let z;
|
||||
(z = I.define) && z.amd ? z([], function() {
|
||||
return H;
|
||||
}) : (z = I.modules) ? z[m.toLowerCase()] = H : "object" === typeof exports ? module.exports = H : I[m] = H;
|
||||
})("FlexSearch", function() {
|
||||
function m(a, b) {
|
||||
const c = b ? b.id : a && a.id;
|
||||
this.id = c || 0 === c ? c : aa++;
|
||||
this.init(a, b);
|
||||
z(this, "index", function() {
|
||||
return this.a ? Object.keys(this.a.index[this.a.keys[0]].f) : Object.keys(this.f);
|
||||
});
|
||||
z(this, "length", function() {
|
||||
return this.index.length;
|
||||
});
|
||||
}
|
||||
function H(a, b) {
|
||||
const c = a.length, d = J(b), e = [];
|
||||
for (let g = 0, f = 0; g < c; g++) {
|
||||
const c = a[g];
|
||||
if (d && b(c) || !d && !b[c]) {
|
||||
e[f++] = c;
|
||||
}
|
||||
}
|
||||
return e;
|
||||
}
|
||||
function I(a, b, c, d, e, g, f, k, r, p) {
|
||||
c = V(c, f ? 0 : e, k, g, b, r, p);
|
||||
let q;
|
||||
k && (k = c.page, q = c.next, c = c.result);
|
||||
if (f) {
|
||||
b = this.where(f, null, e, c);
|
||||
} else {
|
||||
b = c;
|
||||
c = this.g;
|
||||
e = b.length;
|
||||
g = Array(e);
|
||||
for (f = 0; f < e; f++) {
|
||||
g[f] = c[b[f]];
|
||||
}
|
||||
b = g;
|
||||
}
|
||||
c = b;
|
||||
d && (J(d) || (y = d.split(":"), 1 < y.length ? d = ba : (y = y[0], d = ca)), c.sort(d));
|
||||
c = L(k, q, c);
|
||||
this.cache && this.j.set(a, c);
|
||||
return c;
|
||||
}
|
||||
function z(a, b, c) {
|
||||
Object.defineProperty(a, b, {get:c});
|
||||
}
|
||||
function h(a) {
|
||||
return new RegExp(a, "g");
|
||||
}
|
||||
function K(a, b) {
|
||||
for (let c = 0; c < b.length; c += 2) {
|
||||
a = a.replace(b[c], b[c + 1]);
|
||||
}
|
||||
return a;
|
||||
}
|
||||
function P(a, b, c, d, e, g, f, k) {
|
||||
if (b[c]) {
|
||||
return b[c];
|
||||
}
|
||||
e = e ? (k - (f || k / 1.5)) * g + (f || k / 1.5) * e : g;
|
||||
b[c] = e;
|
||||
e >= f && (a = a[k - (e + 0.5 >> 0)], a = a[c] || (a[c] = []), a[a.length] = d);
|
||||
return e;
|
||||
}
|
||||
function T(a, b) {
|
||||
if (a) {
|
||||
const c = Object.keys(a);
|
||||
for (let d = 0, e = c.length; d < e; d++) {
|
||||
const e = c[d], f = a[e];
|
||||
if (f) {
|
||||
for (let c = 0, d = f.length; c < d; c++) {
|
||||
if (f[c] === b) {
|
||||
1 === d ? delete a[e] : f.splice(c, 1);
|
||||
break;
|
||||
} else {
|
||||
A(f[c]) && T(f[c], b);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
function U(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 da(a, b) {
|
||||
a = a.length - b.length;
|
||||
return 0 > a ? 1 : a ? -1 : 0;
|
||||
}
|
||||
function ca(a, b) {
|
||||
a = a[y];
|
||||
b = b[y];
|
||||
return a < b ? -1 : a > b ? 1 : 0;
|
||||
}
|
||||
function ba(a, b) {
|
||||
const c = y.length;
|
||||
for (let d = 0; d < c; d++) {
|
||||
a = a[y[d]], b = b[y[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 V(a, b, c, d, e, g, f) {
|
||||
let k, r = [];
|
||||
if (!0 === c) {
|
||||
c = "0";
|
||||
var p = "";
|
||||
} else {
|
||||
p = c && c.split(":");
|
||||
}
|
||||
const q = a.length;
|
||||
if (1 < q) {
|
||||
const R = u();
|
||||
let B = [], M, G;
|
||||
var n = 0, l;
|
||||
let N;
|
||||
var h = !0;
|
||||
let D, E = 0, x, w, y, A;
|
||||
p && (2 === p.length ? (y = p, p = !1) : p = A = parseInt(p[0], 10));
|
||||
if (f) {
|
||||
for (M = u(); n < q; n++) {
|
||||
if ("not" === e[n]) {
|
||||
for (G = a[n], N = G.length, l = 0; l < N; l++) {
|
||||
M["@" + G[l]] = 1;
|
||||
}
|
||||
} else {
|
||||
w = n + 1;
|
||||
}
|
||||
}
|
||||
if (C(w)) {
|
||||
return L(c, k, r);
|
||||
}
|
||||
n = 0;
|
||||
} else {
|
||||
x = F(e) && e;
|
||||
}
|
||||
let z;
|
||||
for (; n < q; n++) {
|
||||
const u = n === (w || q) - 1;
|
||||
if (!x || !n) {
|
||||
if ((l = x || e && e[n]) && "and" !== l) {
|
||||
if ("or" === l) {
|
||||
z = !1;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
z = g = !0;
|
||||
}
|
||||
}
|
||||
G = a[n];
|
||||
if (N = G.length) {
|
||||
if (h) {
|
||||
if (D) {
|
||||
var t = D.length;
|
||||
for (l = 0; l < t; l++) {
|
||||
h = D[l];
|
||||
var m = "@" + h;
|
||||
f && M[m] || (R[m] = 1, g || (r[E++] = h));
|
||||
}
|
||||
D = null;
|
||||
h = !1;
|
||||
} else {
|
||||
D = G;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
m = !1;
|
||||
for (l = 0; l < N; l++) {
|
||||
t = G[l];
|
||||
var v = "@" + t;
|
||||
const a = g ? R[v] || 0 : n;
|
||||
if (!(!a && !d || f && M[v] || !g && R[v])) {
|
||||
if (a === n) {
|
||||
if (u) {
|
||||
if (!A || --A < E) {
|
||||
if (r[E++] = t, b && E === b) {
|
||||
return L(c, E + (p || 0), r);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
R[v] = n + 1;
|
||||
}
|
||||
m = !0;
|
||||
} else {
|
||||
d && (v = B[a] || (B[a] = []), v[v.length] = t);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (z && !m && !d) {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if (z && !d) {
|
||||
return L(c, k, G);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (D) {
|
||||
if (n = D.length, f) {
|
||||
for (l = p ? parseInt(p, 10) : 0; l < n; l++) {
|
||||
a = D[l], M["@" + a] || (r[E++] = a);
|
||||
}
|
||||
} else {
|
||||
r = D;
|
||||
}
|
||||
}
|
||||
if (d) {
|
||||
for (E = r.length, y ? (n = parseInt(y[0], 10) + 1, l = parseInt(y[1], 10) + 1) : (n = B.length, l = 0); n--;) {
|
||||
if (t = B[n]) {
|
||||
for (N = t.length; l < N; l++) {
|
||||
if (d = t[l], !f || !M["@" + d]) {
|
||||
if (r[E++] = d, b && E === b) {
|
||||
return L(c, n + ":" + l, r);
|
||||
}
|
||||
}
|
||||
}
|
||||
l = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
!q || e && "not" === e[0] || (r = a[0], p && (p = parseInt(p[0], 10)));
|
||||
}
|
||||
b && (f = r.length, p && p > f && (p = 0), p = p || 0, k = p + b, k < f ? r = r.slice(p, k) : (k = 0, p && (r = r.slice(p))));
|
||||
return L(c, k, r);
|
||||
}
|
||||
function F(a) {
|
||||
return "string" === typeof a;
|
||||
}
|
||||
function x(a) {
|
||||
return a.constructor === Array;
|
||||
}
|
||||
function J(a) {
|
||||
return "function" === typeof a;
|
||||
}
|
||||
function A(a) {
|
||||
return "object" === typeof a;
|
||||
}
|
||||
function C(a) {
|
||||
return "undefined" === typeof a;
|
||||
}
|
||||
function W(a) {
|
||||
const b = Array(a);
|
||||
for (let c = 0; c < a; c++) {
|
||||
b[c] = u();
|
||||
}
|
||||
return b;
|
||||
}
|
||||
function u() {
|
||||
return Object.create(null);
|
||||
}
|
||||
const w = {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(a, b) {
|
||||
return new m(a, b);
|
||||
};
|
||||
m.registerMatcher = function(a) {
|
||||
for (const b in a) {
|
||||
a.hasOwnProperty(b) && S.push(h(b), a[b]);
|
||||
}
|
||||
return this;
|
||||
};
|
||||
m.registerEncoder = function(a, b) {
|
||||
O[a] = b.bind(O);
|
||||
return this;
|
||||
};
|
||||
m.registerLanguage = function(a, b) {
|
||||
Y[a] = b.filter;
|
||||
Z[a] = b.stemmer;
|
||||
return this;
|
||||
};
|
||||
m.encode = function(a, b) {
|
||||
return O[a](b);
|
||||
};
|
||||
m.prototype.init = function(a, b) {
|
||||
this.m = [];
|
||||
if (b) {
|
||||
var c = b.preset;
|
||||
a = b;
|
||||
} else {
|
||||
a || (a = w), c = a.preset;
|
||||
}
|
||||
b = {};
|
||||
F(a) ? (b = X[a], a = {}) : c && (b = X[c]);
|
||||
this.c = a.tokenize || b.c || this.c || w.c;
|
||||
this.split = a.split || this.split || w.split;
|
||||
this.v = a.rtl || this.v || w.v;
|
||||
this.async = "undefined" === typeof Promise || C(c = a.async) ? this.async || w.async : c;
|
||||
this.threshold = C(c = a.threshold) ? b.threshold || this.threshold || w.threshold : c;
|
||||
this.b = C(c = a.resolution) ? c = b.b || this.b || w.b : c;
|
||||
c <= this.threshold && (this.b = this.threshold + 1);
|
||||
this.depth = "strict" !== this.c || C(c = a.depth) ? b.depth || this.depth || w.depth : c;
|
||||
this.o = (c = C(c = a.encode) ? b.encode || w.encode : c) && O[c] && O[c].bind(O) || (J(c) ? c : this.o || !1);
|
||||
(c = a.matcher) && this.addMatcher(c);
|
||||
if (c = (b = a.lang) || a.filter) {
|
||||
F(c) && (c = Y[c]);
|
||||
if (x(c)) {
|
||||
var d = this.o, e = u();
|
||||
for (var g = 0; g < c.length; g++) {
|
||||
var f = d ? d(c[g]) : c[g];
|
||||
e[f] = 1;
|
||||
}
|
||||
c = e;
|
||||
}
|
||||
this.filter = c;
|
||||
}
|
||||
if (c = b || a.stemmer) {
|
||||
var k;
|
||||
b = F(c) ? Z[c] : c;
|
||||
d = this.o;
|
||||
e = [];
|
||||
for (k in b) {
|
||||
b.hasOwnProperty(k) && (g = d ? d(k) : k, e.push(h(g + "($|\\W)"), d ? d(b[k]) : b[k]));
|
||||
}
|
||||
this.stemmer = k = e;
|
||||
}
|
||||
this.a = e = (c = a.doc) ? c : this.a || w.a;
|
||||
this.i = W(this.b - (this.threshold || 0));
|
||||
this.h = u();
|
||||
this.f = u();
|
||||
if (e) {
|
||||
this.g = u();
|
||||
a.doc = null;
|
||||
k = e.index = {};
|
||||
b = e.keys = [];
|
||||
d = e.field;
|
||||
g = e.tag;
|
||||
x(e.id) || (e.id = e.id.split(":"));
|
||||
if (g) {
|
||||
this.w = u();
|
||||
f = u();
|
||||
if (d) {
|
||||
if (F(d)) {
|
||||
f[d] = a;
|
||||
} else {
|
||||
if (x(d)) {
|
||||
for (let b = 0; b < d.length; b++) {
|
||||
f[d[b]] = a;
|
||||
}
|
||||
} else {
|
||||
A(d) && (f = d);
|
||||
}
|
||||
}
|
||||
}
|
||||
x(g) || (e.tag = g = [g]);
|
||||
for (d = 0; d < g.length; d++) {
|
||||
this.w[g[d]] = u();
|
||||
}
|
||||
this.B = g;
|
||||
d = f;
|
||||
}
|
||||
if (d) {
|
||||
let c;
|
||||
x(d) || (A(d) ? (c = d, e.field = d = Object.keys(d)) : e.field = d = [d]);
|
||||
for (e = 0; e < d.length; e++) {
|
||||
g = d[e], x(g) || (c && (a = c[g]), b[e] = g, d[e] = g.split(":")), k[g] = new m(a), k[g].g = this.g;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.u = !0;
|
||||
this.j = (this.cache = c = C(c = a.cache) ? this.cache || w.cache : c) ? new ea(c) : !1;
|
||||
return this;
|
||||
};
|
||||
m.prototype.encode = function(a) {
|
||||
a && S.length && (a = K(a, S));
|
||||
a && this.m.length && (a = K(a, this.m));
|
||||
a && this.o && (a = this.o(a));
|
||||
a && this.stemmer && (a = K(a, this.stemmer));
|
||||
return a;
|
||||
};
|
||||
m.prototype.addMatcher = function(a) {
|
||||
const b = this.m;
|
||||
for (const c in a) {
|
||||
a.hasOwnProperty(c) && b.push(h(c), a[c]);
|
||||
}
|
||||
return this;
|
||||
};
|
||||
m.prototype.add = function(a, b, c, d, e) {
|
||||
if (this.a && A(a)) {
|
||||
return this.s("add", a, b);
|
||||
}
|
||||
if (b && F(b) && (a || 0 === a)) {
|
||||
var g = "@" + a;
|
||||
if (this.f[g] && !d) {
|
||||
return this.update(a, b);
|
||||
}
|
||||
if (!e) {
|
||||
if (this.async) {
|
||||
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.c;
|
||||
e = J(c) ? c(b) : b.split(this.split);
|
||||
this.filter && (e = H(e, this.filter));
|
||||
const n = u();
|
||||
n._ctx = u();
|
||||
const l = e.length, h = this.threshold, t = this.depth, m = this.b, v = this.i, Q = this.v;
|
||||
for (let b = 0; b < l; b++) {
|
||||
var f = e[b];
|
||||
if (f) {
|
||||
var k = f.length, r = (Q ? b + 1 : l - b) / l, p = "";
|
||||
switch(c) {
|
||||
case "reverse":
|
||||
case "both":
|
||||
for (var q = k; --q;) {
|
||||
p = f[q] + p, P(v, n, p, a, Q ? 1 : (k - q) / k, r, h, m - 1);
|
||||
}
|
||||
p = "";
|
||||
case "forward":
|
||||
for (q = 0; q < k; q++) {
|
||||
p += f[q], P(v, n, p, a, Q ? (q + 1) / k : 1, r, h, m - 1);
|
||||
}
|
||||
break;
|
||||
case "full":
|
||||
for (q = 0; q < k; q++) {
|
||||
const b = (Q ? q + 1 : k - q) / k;
|
||||
for (let c = k; c > q; c--) {
|
||||
p = f.substring(q, c), P(v, n, p, a, b, r, h, m - 1);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (k = P(v, n, f, a, 1, r, h, m - 1), t && 1 < l && k >= h) {
|
||||
for (k = n._ctx[f] || (n._ctx[f] = u()), f = this.h[f] || (this.h[f] = W(m - (h || 0))), r = b - t, p = b + t + 1, 0 > r && (r = 0), p > l && (p = l); r < p; r++) {
|
||||
r !== b && P(f, k, e[r], a, 0, m - (r < b ? b - r : r - b), h, m - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
this.f[g] = 1;
|
||||
this.u = !1;
|
||||
}
|
||||
return this;
|
||||
};
|
||||
m.prototype.s = function(a, b, c) {
|
||||
if (x(b)) {
|
||||
for (let d = 0, e = b.length; d < e; d++) {
|
||||
if (d === e - 1) {
|
||||
return this.s(a, b[d], c);
|
||||
}
|
||||
this.s(a, b[d]);
|
||||
}
|
||||
} else {
|
||||
const h = this.a.index, p = this.a.keys;
|
||||
var d = this.a.tag, e = this.a.id;
|
||||
let q;
|
||||
let n;
|
||||
for (var g = 0; g < e.length; g++) {
|
||||
q = (q || b)[e[g]];
|
||||
}
|
||||
if (d) {
|
||||
for (e = 0; e < d.length; e++) {
|
||||
var f = d[e];
|
||||
var k = f.split(":");
|
||||
for (g = 0; g < k.length; g++) {
|
||||
n = (n || b)[k[g]];
|
||||
}
|
||||
n = "@" + n;
|
||||
}
|
||||
k = this.w[f];
|
||||
k = k[n] || (k[n] = []);
|
||||
}
|
||||
if ("remove" === a) {
|
||||
delete this.g[q];
|
||||
for (let b = 0, a = p.length; b < a; b++) {
|
||||
if (b === a - 1) {
|
||||
return h[p[b]].remove(q, c), this;
|
||||
}
|
||||
h[p[b]].remove(q);
|
||||
}
|
||||
}
|
||||
e = this.a.field;
|
||||
k && (k[k.length] = b);
|
||||
this.g[q] = b;
|
||||
for (let g = 0, k = e.length; g < k; g++) {
|
||||
d = e[g];
|
||||
let l;
|
||||
for (f = 0; f < d.length; f++) {
|
||||
l = (l || b)[d[f]];
|
||||
}
|
||||
d = h[p[g]];
|
||||
f = "add" === a ? d.add : d.update;
|
||||
g === k - 1 ? f.call(d, q, l, c) : f.call(d, q, l);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
};
|
||||
m.prototype.update = function(a, b, c) {
|
||||
if (this.a && A(a)) {
|
||||
return this.s("update", a, b);
|
||||
}
|
||||
this.f["@" + a] && F(b) && (this.remove(a), this.add(a, b, c, !0));
|
||||
return this;
|
||||
};
|
||||
m.prototype.remove = function(a, b, c) {
|
||||
if (this.a && A(a)) {
|
||||
return this.s("remove", a, b);
|
||||
}
|
||||
var d = "@" + a;
|
||||
if (this.f[d]) {
|
||||
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++) {
|
||||
T(this.i[b], a);
|
||||
}
|
||||
this.depth && T(this.h, a);
|
||||
delete this.f[d];
|
||||
this.u = !1;
|
||||
}
|
||||
return this;
|
||||
};
|
||||
let y;
|
||||
m.prototype.search = function(a, b, c, d) {
|
||||
if (A(b)) {
|
||||
if (x(b)) {
|
||||
for (var e = 0; e < b.length; e++) {
|
||||
b[e].query = a;
|
||||
}
|
||||
} else {
|
||||
b.query = a;
|
||||
}
|
||||
a = b;
|
||||
b = 1000;
|
||||
} else {
|
||||
b && J(b) ? (c = b, b = 1000) : b || 0 === b || (b = 1000);
|
||||
}
|
||||
let g = [], f = a;
|
||||
let k, h, p;
|
||||
if (A(a) && !x(a)) {
|
||||
c || (c = a.callback) && (f.callback = null);
|
||||
h = a.sort;
|
||||
k = a.page;
|
||||
b = a.limit;
|
||||
var q = a.threshold;
|
||||
p = a.suggest;
|
||||
a = a.query;
|
||||
}
|
||||
if (this.a) {
|
||||
q = this.a.index;
|
||||
const r = f.where;
|
||||
var n = f.bool || "or", l = f.field;
|
||||
let B = n;
|
||||
let v, u;
|
||||
if (l) {
|
||||
x(l) || (l = [l]);
|
||||
} else {
|
||||
if (x(f)) {
|
||||
var m = f;
|
||||
l = [];
|
||||
B = [];
|
||||
for (var t = 0; t < f.length; t++) {
|
||||
d = f[t], e = d.bool || n, l[t] = d.field, B[t] = e, "not" === e ? v = !0 : "and" === e && (u = !0);
|
||||
}
|
||||
} else {
|
||||
l = this.a.keys;
|
||||
}
|
||||
}
|
||||
n = l.length;
|
||||
for (t = 0; t < n; t++) {
|
||||
m && (f = m[t]), k && !F(f) && (f.page = null, f.limit = 0), g[t] = q[l[t]].search(f, 0);
|
||||
}
|
||||
if (c) {
|
||||
return c(I.call(this, a, B, g, h, b, p, r, k, u, v));
|
||||
}
|
||||
if (this.async) {
|
||||
const c = this;
|
||||
return new Promise(function(d) {
|
||||
Promise.all(g).then(function(e) {
|
||||
d(I.call(c, a, B, e, h, b, p, r, k, u, v));
|
||||
});
|
||||
});
|
||||
}
|
||||
return I.call(this, a, B, g, h, b, p, r, k, u, v);
|
||||
}
|
||||
q || (q = this.threshold || 0);
|
||||
if (!d) {
|
||||
if (this.async && "function" !== typeof importScripts) {
|
||||
let a = this;
|
||||
q = new Promise(function(c) {
|
||||
setTimeout(function() {
|
||||
c(a.search(f, b, null, !0));
|
||||
a = null;
|
||||
});
|
||||
});
|
||||
if (c) {
|
||||
q.then(c);
|
||||
} else {
|
||||
return q;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
if (c) {
|
||||
return c(this.search(f, b, null, !0)), this;
|
||||
}
|
||||
}
|
||||
if (!a || !F(a)) {
|
||||
return g;
|
||||
}
|
||||
f = a;
|
||||
if (this.cache) {
|
||||
if (this.u) {
|
||||
if (c = this.j.get(a)) {
|
||||
return c;
|
||||
}
|
||||
} else {
|
||||
this.j.clear(), this.u = !0;
|
||||
}
|
||||
}
|
||||
f = this.encode(f);
|
||||
if (!f.length) {
|
||||
return g;
|
||||
}
|
||||
c = this.c;
|
||||
c = J(c) ? c(f) : f.split(this.split);
|
||||
this.filter && (c = H(c, this.filter));
|
||||
m = c.length;
|
||||
d = !0;
|
||||
e = [];
|
||||
const w = u();
|
||||
let v = 0;
|
||||
1 < m && (this.depth && "strict" === this.c ? n = !0 : c.sort(da));
|
||||
if (!n || (t = this.h)) {
|
||||
const b = this.b;
|
||||
for (; v < m; v++) {
|
||||
let a = c[v];
|
||||
if (a) {
|
||||
if (n) {
|
||||
if (!l) {
|
||||
if (t[a]) {
|
||||
l = a, w[a] = 1;
|
||||
} else {
|
||||
if (!p) {
|
||||
return g;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (p && v === m - 1 && !e.length) {
|
||||
n = !1, a = l || a, w[a] = 0;
|
||||
} else {
|
||||
if (!l) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!w[a]) {
|
||||
const c = [];
|
||||
let f = !1, g = 0;
|
||||
const k = n ? t[l] : this.i;
|
||||
if (k) {
|
||||
let d;
|
||||
for (let e = 0; e < b - q; e++) {
|
||||
if (d = k[e][a]) {
|
||||
c[g++] = d, f = !0;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (f) {
|
||||
l = a, e[e.length] = 1 < g ? c.concat.apply([], c) : c[0];
|
||||
} else {
|
||||
if (!p) {
|
||||
d = !1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
w[a] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
d = !1;
|
||||
}
|
||||
d && (g = V(e, b, k, p));
|
||||
this.cache && this.j.set(a, g);
|
||||
return g;
|
||||
};
|
||||
m.prototype.find = function(a, b) {
|
||||
return this.where(a, b, 1)[0] || null;
|
||||
};
|
||||
m.prototype.where = function(a, b, c, d) {
|
||||
const e = this.g, g = [];
|
||||
let f = 0;
|
||||
let k;
|
||||
var h;
|
||||
let p;
|
||||
if (A(a)) {
|
||||
c || (c = b);
|
||||
var q = Object.keys(a);
|
||||
var n = q.length;
|
||||
k = !1;
|
||||
if (1 === n && "id" === q[0]) {
|
||||
return [e[a.id]];
|
||||
}
|
||||
if ((h = this.B) && !d) {
|
||||
for (var l = 0; l < h.length; l++) {
|
||||
var m = h[l], t = a[m];
|
||||
if (!C(t)) {
|
||||
p = this.w[m]["@" + t];
|
||||
if (0 === --n) {
|
||||
return p;
|
||||
}
|
||||
q.splice(q.indexOf(m), 1);
|
||||
delete a[m];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
h = Array(n);
|
||||
for (l = 0; l < n; l++) {
|
||||
h[l] = q[l].split(":");
|
||||
}
|
||||
} else {
|
||||
if (J(a)) {
|
||||
b = d || Object.keys(e);
|
||||
c = b.length;
|
||||
for (q = 0; q < c; q++) {
|
||||
n = e[b[q]], a(n) && (g[f++] = n);
|
||||
}
|
||||
return g;
|
||||
}
|
||||
if (C(b)) {
|
||||
return [e[a]];
|
||||
}
|
||||
if ("id" === a) {
|
||||
return [e[b]];
|
||||
}
|
||||
q = [a];
|
||||
n = 1;
|
||||
h = [a.split(":")];
|
||||
k = !0;
|
||||
}
|
||||
d = p || d || Object.keys(e);
|
||||
l = d.length;
|
||||
for (m = 0; m < l; m++) {
|
||||
t = p ? d[m] : e[d[m]];
|
||||
let l = !0;
|
||||
for (let c = 0; c < n; c++) {
|
||||
k || (b = a[q[c]]);
|
||||
const d = h[c], e = d.length;
|
||||
let f = t;
|
||||
if (1 < e) {
|
||||
for (let a = 0; a < e; a++) {
|
||||
f = f[d[a]];
|
||||
}
|
||||
} else {
|
||||
f = f[d[0]];
|
||||
}
|
||||
if (f !== b) {
|
||||
l = !1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (l && (g[f++] = t, 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 a = this.a.keys;
|
||||
for (let b = 0; b < a.length; b++) {
|
||||
this.a.index[a[b]].destroy();
|
||||
}
|
||||
this.a = this.g = null;
|
||||
}
|
||||
return this;
|
||||
};
|
||||
m.prototype.export = function() {
|
||||
let a;
|
||||
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;
|
||||
} else {
|
||||
a = [this.i, this.h, Object.keys(this.f)];
|
||||
}
|
||||
return JSON.stringify(a);
|
||||
};
|
||||
m.prototype.import = function(a) {
|
||||
a = JSON.parse(a);
|
||||
const b = u();
|
||||
if (this.a) {
|
||||
var c = this.a.keys, d = c.length, e = a[0][2];
|
||||
for (var g = 0; g < e.length; g++) {
|
||||
b[e[g]] = 1;
|
||||
}
|
||||
for (e = 0; e < d; e++) {
|
||||
g = this.a.index[c[e]], g.i = a[e][0], g.h = a[e][1], g.f = b, g.g = a[d];
|
||||
}
|
||||
this.g = a[d];
|
||||
} else {
|
||||
c = a[2];
|
||||
for (d = 0; d < c.length; d++) {
|
||||
b[c[d]] = 1;
|
||||
}
|
||||
this.i = a[0];
|
||||
this.h = a[1];
|
||||
this.f = b;
|
||||
}
|
||||
};
|
||||
const O = {icase:function(a) {
|
||||
return a.toLowerCase();
|
||||
}, simple:function() {
|
||||
const a = [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(b) {
|
||||
b = K(b.toLowerCase(), a);
|
||||
return " " === b ? "" : b;
|
||||
};
|
||||
}(), advanced:function() {
|
||||
const a = [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(b, c) {
|
||||
if (!b) {
|
||||
return b;
|
||||
}
|
||||
b = this.simple(b);
|
||||
2 < b.length && (b = K(b, a));
|
||||
c || 1 < b.length && (b = U(b));
|
||||
return b;
|
||||
};
|
||||
}(), extra:function() {
|
||||
const a = [h("p"), "b", h("z"), "s", h("[cgq]"), "k", h("n"), "m", h("d"), "t", h("[vw]"), "f", h("[aeiouy]"), ""];
|
||||
return function(b) {
|
||||
if (!b) {
|
||||
return b;
|
||||
}
|
||||
b = this.advanced(b, !0);
|
||||
if (1 < b.length) {
|
||||
b = b.split(" ");
|
||||
for (let c = 0; c < b.length; c++) {
|
||||
const d = b[c];
|
||||
1 < d.length && (b[c] = d[0] + K(d.substring(1), a));
|
||||
}
|
||||
b = b.join(" ");
|
||||
b = U(b);
|
||||
}
|
||||
return b;
|
||||
};
|
||||
}(), balance:function() {
|
||||
const a = [h("[-/]"), " ", h("[^a-z0-9 ]"), "", h("\\s+"), " "];
|
||||
return function(b) {
|
||||
return U(K(b.toLowerCase(), a));
|
||||
};
|
||||
}()}, ea = function() {
|
||||
function a(a) {
|
||||
this.clear();
|
||||
this.A = !0 !== a && a;
|
||||
}
|
||||
a.prototype.clear = function() {
|
||||
this.cache = u();
|
||||
this.count = u();
|
||||
this.index = u();
|
||||
this.l = [];
|
||||
};
|
||||
a.prototype.set = function(a, c) {
|
||||
if (this.A && C(this.cache[a])) {
|
||||
let b = this.l.length;
|
||||
if (b === this.A) {
|
||||
b--;
|
||||
const a = this.l[b];
|
||||
delete this.cache[a];
|
||||
delete this.count[a];
|
||||
delete this.index[a];
|
||||
}
|
||||
this.index[a] = b;
|
||||
this.l[b] = a;
|
||||
this.count[a] = -1;
|
||||
this.cache[a] = c;
|
||||
this.get(a);
|
||||
} else {
|
||||
this.cache[a] = c;
|
||||
}
|
||||
};
|
||||
a.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 a;
|
||||
}();
|
||||
return m;
|
||||
}(!1), this);
|
||||
|
257
flexsearch.js
257
flexsearch.js
@@ -1,5 +1,5 @@
|
||||
/**!
|
||||
* @preserve FlexSearch v0.6.1
|
||||
* @preserve FlexSearch v0.6.2
|
||||
* Copyright 2019 Nextapps GmbH
|
||||
* Author: Thomas Wilkerling
|
||||
* Released under the Apache 2.0 Licence
|
||||
@@ -191,12 +191,13 @@
|
||||
|
||||
/**
|
||||
* @param {Object<string, number|string|boolean|Object|function(string):string>=} options
|
||||
* @param {Object<string, number|string|boolean>=} settings
|
||||
* @export
|
||||
*/
|
||||
|
||||
FlexSearch.create = function(options){
|
||||
FlexSearch.create = function(options, settings){
|
||||
|
||||
return new FlexSearch(options);
|
||||
return new FlexSearch(options, settings);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -495,20 +496,6 @@
|
||||
);
|
||||
*/
|
||||
|
||||
// if(SUPPORT_SUGGESTION){
|
||||
//
|
||||
// /** @private */
|
||||
// this.suggest = (
|
||||
//
|
||||
// is_undefined(custom = options["suggest"]) ?
|
||||
//
|
||||
// this.suggest ||
|
||||
// defaults.suggest
|
||||
// :
|
||||
// custom
|
||||
// );
|
||||
// }
|
||||
|
||||
custom = is_undefined(custom = options["encode"]) ?
|
||||
|
||||
preset.encode ||
|
||||
@@ -532,7 +519,9 @@
|
||||
);
|
||||
}
|
||||
|
||||
if((custom = options["filter"])) {
|
||||
const lang = options["lang"];
|
||||
|
||||
if((custom = lang || options["filter"])) {
|
||||
|
||||
if(is_string(custom)){
|
||||
|
||||
@@ -548,7 +537,7 @@
|
||||
this.filter = custom;
|
||||
}
|
||||
|
||||
if((custom = options["stemmer"])) {
|
||||
if((custom = lang || options["stemmer"])) {
|
||||
|
||||
/** @private */
|
||||
this.stemmer = init_stemmer(
|
||||
@@ -860,7 +849,7 @@
|
||||
|
||||
if(!_recall){
|
||||
|
||||
if(SUPPORT_ASYNC && this.async && (typeof importScripts !== "function")){
|
||||
if(SUPPORT_ASYNC && this.async && (!SUPPORT_WORKER || (typeof importScripts !== "function"))){
|
||||
|
||||
let self = this;
|
||||
|
||||
@@ -1171,7 +1160,8 @@
|
||||
|
||||
if(z === length - 1){
|
||||
|
||||
return index[keys[z]].remove(id, callback);
|
||||
index[keys[z]].remove(id, callback);
|
||||
return this;
|
||||
}
|
||||
else{
|
||||
|
||||
@@ -1214,7 +1204,7 @@
|
||||
|
||||
if(i === len - 1){
|
||||
|
||||
return fn.call(self, id, content, callback);
|
||||
fn.call(self, id, content, callback);
|
||||
}
|
||||
else{
|
||||
|
||||
@@ -1222,6 +1212,8 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1474,7 +1466,16 @@
|
||||
}
|
||||
|
||||
query = /** @type {Object} */ (limit);
|
||||
limit = 0;
|
||||
limit = 1000;
|
||||
}
|
||||
else if(limit && is_function(limit)){
|
||||
|
||||
callback = /** @type {?Function} */ (limit);
|
||||
limit = 1000;
|
||||
}
|
||||
else{
|
||||
|
||||
limit || (limit === 0 ) || (limit = 1000);
|
||||
}
|
||||
|
||||
let result = [];
|
||||
@@ -1490,11 +1491,14 @@
|
||||
|
||||
if(SUPPORT_ASYNC){
|
||||
|
||||
callback = query["callback"] || (is_function(limit) && /** @type {?Function} */ (limit));
|
||||
if(!callback){
|
||||
|
||||
if(callback) {
|
||||
callback = query["callback"];
|
||||
|
||||
_query["callback"] = null;
|
||||
if(callback){
|
||||
|
||||
_query["callback"] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1636,16 +1640,6 @@
|
||||
|
||||
threshold || (threshold = this.threshold || 0);
|
||||
|
||||
if(is_function(limit)){
|
||||
|
||||
callback = limit;
|
||||
limit = 1000;
|
||||
}
|
||||
else {
|
||||
|
||||
limit || (limit === 0 ) || (limit = 1000);
|
||||
}
|
||||
|
||||
if(SUPPORT_WORKER && this.worker){
|
||||
|
||||
this._current_callback = callback;
|
||||
@@ -1781,14 +1775,13 @@
|
||||
|
||||
let ctx_root;
|
||||
let use_contextual;
|
||||
let a = 0;
|
||||
|
||||
if(length > 1){
|
||||
|
||||
if(this.depth){
|
||||
if(this.depth && (this.tokenize === "strict")){
|
||||
|
||||
use_contextual = true;
|
||||
ctx_root = words[0]; // TODO: iterate roots
|
||||
check_words[ctx_root] = 1;
|
||||
}
|
||||
else{
|
||||
|
||||
@@ -1827,7 +1820,7 @@
|
||||
|
||||
let ctx_map;
|
||||
|
||||
if(!use_contextual || (ctx_map = this._ctx)[ctx_root]){
|
||||
if(!use_contextual || (ctx_map = this._ctx)){
|
||||
|
||||
const resolution = this.resolution;
|
||||
|
||||
@@ -1837,12 +1830,41 @@
|
||||
// threshold = (threshold || 1) / boost;
|
||||
// }
|
||||
|
||||
for(let a = (use_contextual ? 1 : 0); a < length; a++){
|
||||
for(; a < length; a++){
|
||||
|
||||
const value = words[a];
|
||||
let value = words[a];
|
||||
|
||||
if(value){
|
||||
|
||||
if(use_contextual){
|
||||
|
||||
if(!ctx_root){
|
||||
|
||||
if(ctx_map[value]){
|
||||
|
||||
ctx_root = value;
|
||||
check_words[value] = 1;
|
||||
}
|
||||
else if(!suggest){
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
if(suggest && (a === length - 1) && !check.length){
|
||||
|
||||
// fall back to single-term-strategy
|
||||
|
||||
use_contextual = false;
|
||||
value = ctx_root || value;
|
||||
check_words[value] = 0;
|
||||
}
|
||||
else if(!ctx_root){
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if(!check_words[value]){
|
||||
|
||||
const map_check = [];
|
||||
@@ -1871,7 +1893,10 @@
|
||||
|
||||
if(map_found){
|
||||
|
||||
ctx_root = value;
|
||||
|
||||
// not handled by intersection:
|
||||
|
||||
check[check.length] = (
|
||||
|
||||
count > 1 ?
|
||||
@@ -1882,7 +1907,7 @@
|
||||
);
|
||||
|
||||
// handled by intersection:
|
||||
//check[check.length] = map_check;
|
||||
// check[check.length] = map_check;
|
||||
}
|
||||
else if(!SUPPORT_SUGGESTION || !suggest){
|
||||
|
||||
@@ -1892,8 +1917,6 @@
|
||||
|
||||
check_words[value] = 1;
|
||||
}
|
||||
|
||||
ctx_root = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1902,24 +1925,21 @@
|
||||
found = false;
|
||||
}
|
||||
|
||||
//if(!SUPPORT_DOCUMENT || !this.doc){
|
||||
if(found){
|
||||
|
||||
if(found){
|
||||
// Not handled by intersection:
|
||||
result = /** @type {Array} */ (intersect(check, limit, cursor, SUPPORT_SUGGESTION && suggest));
|
||||
|
||||
// Not handled by intersection:
|
||||
result = /** @type {Array} */ (intersect(check, limit, cursor, SUPPORT_SUGGESTION && suggest));
|
||||
// Handled by intersection:
|
||||
//result = intersect_3d(check, limit, suggest);
|
||||
}
|
||||
|
||||
// Handled by intersection:
|
||||
//result = intersect_3d(check, limit, suggest);
|
||||
}
|
||||
// store result to cache
|
||||
|
||||
// store result to cache
|
||||
if(SUPPORT_CACHE && this.cache){
|
||||
|
||||
if(SUPPORT_CACHE && this.cache){
|
||||
|
||||
this._cache.set(query, result);
|
||||
}
|
||||
//}
|
||||
this._cache.set(query, result);
|
||||
}
|
||||
|
||||
if(PROFILER){
|
||||
|
||||
@@ -1959,6 +1979,7 @@
|
||||
let keys_len;
|
||||
let has_value;
|
||||
let tree;
|
||||
let tag_results;
|
||||
|
||||
if(is_object(key)){
|
||||
|
||||
@@ -1983,12 +2004,12 @@
|
||||
|
||||
if(!is_undefined(current_where)){
|
||||
|
||||
result = this._tag[current_tag]["@" + current_where];
|
||||
tag_results = this._tag[current_tag]["@" + current_where];
|
||||
//result = result.slice(0, limit && (limit < result.length) ? limit : result.length);
|
||||
|
||||
if(--keys_len === 0){
|
||||
|
||||
return result;
|
||||
return tag_results;
|
||||
}
|
||||
|
||||
keys.splice(keys.indexOf(current_tag), 1);
|
||||
@@ -2042,12 +2063,12 @@
|
||||
has_value = true;
|
||||
}
|
||||
|
||||
const ids = result || get_keys(doc); // this._ids;
|
||||
const ids = tag_results || result || get_keys(doc); // this._ids;
|
||||
const length = ids.length;
|
||||
|
||||
for(let x = 0; x < length; x++){
|
||||
|
||||
const obj = doc[ids[x]];
|
||||
const obj = tag_results ? ids[x] : doc[ids[x]];
|
||||
let found = true;
|
||||
|
||||
for(let i = 0; i < keys_len; i++){
|
||||
@@ -2214,11 +2235,14 @@
|
||||
|
||||
FlexSearch.prototype.export = function(){
|
||||
|
||||
let payload;
|
||||
|
||||
if(SUPPORT_DOCUMENT && this.doc){
|
||||
|
||||
const keys = this.doc.keys;
|
||||
const length = keys.length;
|
||||
const payload = new Array(length + 1);
|
||||
|
||||
payload = new Array(length + 1);
|
||||
|
||||
let i = 0;
|
||||
|
||||
@@ -2233,16 +2257,18 @@
|
||||
}
|
||||
|
||||
payload[i] = this._doc;
|
||||
}
|
||||
else{
|
||||
|
||||
return JSON.stringify(payload);
|
||||
payload = [
|
||||
|
||||
this._map,
|
||||
this._ctx,
|
||||
get_keys(this._ids)
|
||||
];
|
||||
}
|
||||
|
||||
return JSON.stringify([
|
||||
|
||||
this._map,
|
||||
this._ctx,
|
||||
get_keys(this._ids)
|
||||
]);
|
||||
return JSON.stringify(payload);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -3161,7 +3187,6 @@
|
||||
let page;
|
||||
let result = [];
|
||||
let pointer;
|
||||
const length_z = arrays.length;
|
||||
|
||||
if(cursor === true){
|
||||
|
||||
@@ -3173,6 +3198,8 @@
|
||||
pointer = cursor && cursor.split(":");
|
||||
}
|
||||
|
||||
const length_z = arrays.length;
|
||||
|
||||
// use complex handler when length > 1
|
||||
|
||||
if(length_z > 1){
|
||||
@@ -3182,11 +3209,11 @@
|
||||
//arrays.sort(sort_by_length_down);
|
||||
|
||||
const check = create_object();
|
||||
const suggestions = [];
|
||||
|
||||
let suggestions = [];
|
||||
let check_not;
|
||||
let arr;
|
||||
let z = -1; // start from 0
|
||||
let z = 0;
|
||||
let i = 0;
|
||||
let length;
|
||||
let tmp;
|
||||
@@ -3197,6 +3224,7 @@
|
||||
let last_index;
|
||||
|
||||
let pointer_suggest;
|
||||
let pointer_count;
|
||||
|
||||
if(pointer){
|
||||
|
||||
@@ -3207,7 +3235,7 @@
|
||||
}
|
||||
else{
|
||||
|
||||
pointer = parseInt(pointer[0], 10);
|
||||
pointer = pointer_count = parseInt(pointer[0], 10);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3220,17 +3248,16 @@
|
||||
|
||||
check_not = create_object();
|
||||
|
||||
while(++z < length_z){
|
||||
for(; z < length_z; z++){
|
||||
|
||||
if(bool[z] === "not"){
|
||||
|
||||
arr = arrays[z];
|
||||
length = arr.length;
|
||||
i = 0;
|
||||
|
||||
while(i < length){
|
||||
for(i = 0; i < length; i++){
|
||||
|
||||
check_not["@" + arr[i++]] = 1;
|
||||
check_not["@" + arr[i]] = 1;
|
||||
}
|
||||
}
|
||||
else{
|
||||
@@ -3250,7 +3277,7 @@
|
||||
return create_page(cursor, page, result);
|
||||
}
|
||||
|
||||
z = -1;
|
||||
z = 0;
|
||||
}
|
||||
else{
|
||||
|
||||
@@ -3263,7 +3290,7 @@
|
||||
|
||||
// loop through arrays
|
||||
|
||||
while(++z < length_z){
|
||||
for(; z < length_z; z++){
|
||||
|
||||
const is_final_loop = (
|
||||
|
||||
@@ -3322,13 +3349,11 @@
|
||||
|
||||
const result_length = first_result.length;
|
||||
|
||||
i = 0;
|
||||
|
||||
// fill initial map
|
||||
|
||||
while(i < result_length){
|
||||
for(i = 0; i < result_length; i++){
|
||||
|
||||
const id = first_result[i++];
|
||||
const id = first_result[i];
|
||||
const index = "@" + id;
|
||||
|
||||
// there is no and, add items
|
||||
@@ -3359,17 +3384,14 @@
|
||||
|
||||
let found = false;
|
||||
|
||||
i = 0;
|
||||
//suggestions = [];
|
||||
for(i = 0; i < length; i++){
|
||||
|
||||
while(i < length){
|
||||
|
||||
tmp = arr[i++];
|
||||
tmp = arr[i];
|
||||
|
||||
const index = "@" + tmp;
|
||||
const check_val = has_and ? check[index] : z;
|
||||
const check_val = has_and ? check[index] || 0 : z;
|
||||
|
||||
if(check_val){
|
||||
if(check_val || suggest){
|
||||
|
||||
if(has_not && check_not[index]){
|
||||
|
||||
@@ -3392,13 +3414,13 @@
|
||||
// should only happened when at least one bool "and" was set
|
||||
// TODO: check bool and provide complexity reduction
|
||||
|
||||
if(!pointer || (--pointer < count)){
|
||||
if(!pointer_count || (--pointer_count < count)){
|
||||
|
||||
result[count++] = tmp;
|
||||
|
||||
if(limit && (count === limit)){
|
||||
|
||||
return create_page(cursor, count, result);
|
||||
return create_page(cursor, count + (pointer || 0), result);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3449,21 +3471,19 @@
|
||||
i = 0;
|
||||
}
|
||||
|
||||
while(i < result_length){
|
||||
for(; i < result_length; i++){
|
||||
|
||||
const id = first_result[i++];
|
||||
const id = first_result[i];
|
||||
|
||||
if(!check_not["@" + id]){
|
||||
|
||||
if(!pointer || (--pointer < count)){
|
||||
result[count++] = id;
|
||||
|
||||
result[count++] = id;
|
||||
|
||||
if(limit && (count === limit)){
|
||||
|
||||
return create_page(cursor, i, result);
|
||||
}
|
||||
}
|
||||
// TODO: is actually not covered
|
||||
// if(limit && (count === limit)){
|
||||
//
|
||||
// return create_page(cursor, (i + 1), result);
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3480,7 +3500,7 @@
|
||||
if(pointer_suggest){
|
||||
|
||||
z = parseInt(pointer_suggest[0], 10) + 1;
|
||||
i = parseInt(pointer_suggest[1], 10);
|
||||
i = parseInt(pointer_suggest[1], 10) + 1;
|
||||
}
|
||||
else{
|
||||
|
||||
@@ -3488,7 +3508,7 @@
|
||||
i = 0;
|
||||
}
|
||||
|
||||
while(z--){
|
||||
for(; z--;){
|
||||
|
||||
tmp = suggestions[z];
|
||||
|
||||
@@ -3520,6 +3540,11 @@
|
||||
|
||||
result = arrays[0];
|
||||
|
||||
if(pointer){
|
||||
|
||||
pointer = parseInt(pointer[0], 10);
|
||||
}
|
||||
|
||||
// TODO: handle references to the original index array
|
||||
// return result.slice(0);
|
||||
}
|
||||
@@ -3527,16 +3552,28 @@
|
||||
|
||||
if(limit){
|
||||
|
||||
const start = cursor ? parseInt(cursor, 10) : 0;
|
||||
const length = result.length;
|
||||
|
||||
if(pointer && (pointer > length)){
|
||||
|
||||
pointer = 0;
|
||||
}
|
||||
|
||||
const start = pointer || 0;
|
||||
page = start + limit;
|
||||
|
||||
if(page < result.length){
|
||||
if(page < length){
|
||||
|
||||
result = result.slice(start, page);
|
||||
}
|
||||
else if(start){
|
||||
else {
|
||||
|
||||
result = result.slice(start);
|
||||
page = 0;
|
||||
|
||||
if(start){
|
||||
|
||||
result = result.slice(start);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4014,8 +4051,6 @@
|
||||
|
||||
function provide(name, factory, root){
|
||||
|
||||
/* istanbul ignore next */
|
||||
|
||||
let prop;
|
||||
|
||||
// AMD (RequireJS)
|
||||
|
33
package.json
33
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "flexsearch",
|
||||
"version": "0.6.1",
|
||||
"version": "0.6.2",
|
||||
"description": "Next-Generation full text search library with zero dependencies.",
|
||||
"homepage": "https://github.com/nextapps-de/flexsearch/",
|
||||
"author": "Thomas Wilkerling",
|
||||
@@ -32,15 +32,24 @@
|
||||
"build-custom": "node compile RELEASE=custom DEBUG=false PROFILER=false SUPPORT_WORKER=false SUPPORT_ENCODER=false SUPPORT_CACHE=false SUPPORT_ASYNC=false SUPPORT_PRESET=false SUPPORT_SUGGESTION=false SUPPORT_SERIALIZE=false SUPPORT_INFO=false SUPPORT_DOCUMENT=false SUPPORT_OPERATOR=false SUPPORT_WHERE=false SUPPORT_PAGINATION=false SUPPORT_LANG_DE=false SUPPORT_LANG_EN=false",
|
||||
"build-es5": "node compile RELEASE=es5 DEBUG=true PROFILER=false SUPPORT_WORKER=true SUPPORT_ENCODER=true SUPPORT_CACHE=true SUPPORT_ASYNC=true SUPPORT_PRESET=true SUPPORT_SUGGESTION=true SUPPORT_SERIALIZE=true SUPPORT_INFO=true SUPPORT_DOCUMENT=true SUPPORT_OPERATOR=true SUPPORT_WHERE=true SUPPORT_PAGINATION=true SUPPORT_LANG_DE=false SUPPORT_LANG_EN=false LANGUAGE_OUT=ECMASCRIPT5_STRICT",
|
||||
"build-node": "node compile RELEASE=node DEBUG=false PROFILER=false SUPPORT_WORKER=false SUPPORT_ENCODER=true SUPPORT_CACHE=true SUPPORT_ASYNC=true SUPPORT_PRESET=true SUPPORT_SUGGESTION=true SUPPORT_SERIALIZE=true SUPPORT_INFO=true SUPPORT_DOCUMENT=true SUPPORT_OPERATOR=true SUPPORT_WHERE=true SUPPORT_PAGINATION=true SUPPORT_LANG_DE=false SUPPORT_LANG_EN=false",
|
||||
"build-pre": "node compile RELEASE=pre DEBUG=false PROFILER=false SUPPORT_WORKER=false SUPPORT_ENCODER=true SUPPORT_CACHE=true SUPPORT_ASYNC=true SUPPORT_PRESET=true SUPPORT_SUGGESTION=true SUPPORT_SERIALIZE=true SUPPORT_INFO=true SUPPORT_DOCUMENT=true SUPPORT_OPERATOR=true SUPPORT_WHERE=true SUPPORT_PAGINATION=true SUPPORT_LANG_DE=false SUPPORT_LANG_EN=false FORMATTING=PRETTY_PRINT",
|
||||
"build-lang": "node compile RELEASE=lang",
|
||||
"build-all": "npm run build && npm run build-light && npm run build-compact && npm run build-es5 && npm run build-node",
|
||||
"test-production": "nyc --reporter=html --reporter=text mocha --timeout=3000 test --exit",
|
||||
"test-light": "nyc --reporter=html --reporter=text mocha --timeout=3000 test/ --exit",
|
||||
"test-develop": "nyc --reporter=html --reporter=text mocha --timeout=3000 --exit",
|
||||
"build-all": "npm run build && npm run build-light && npm run build-compact && npm run build-es5 && npm run build-node && npm run build-pre",
|
||||
"test-production": "mocha --timeout=3000 test --exit",
|
||||
"test-light": "mocha --timeout=3000 test/ --exit",
|
||||
"test-develop": "mocha --timeout=3000 --exit",
|
||||
"test-browser": "mocha-phantomjs test/index.html",
|
||||
"test": "npm run test-develop && npm run test-production && npm run test-light && npm run test-browser",
|
||||
"update": "node_modules/.bin/updtr --to non-breaking",
|
||||
"coverage": "nyc report --reporter=lcov --reporter=text-lcov | coveralls"
|
||||
"test-coverage": "nyc --reporter=html --reporter=text mocha --timeout=3000 mocha test/test.js",
|
||||
"test": "npm run test-develop && npm run test-production && npm run test-light && npm run test-browser && npm run test-coverage",
|
||||
"coverage": "nyc report --reporter=text-lcov | coveralls",
|
||||
"update": "node_modules/.bin/updtr --to non-breaking"
|
||||
},
|
||||
"nyc": {
|
||||
"per-file": true,
|
||||
"all": true,
|
||||
"include": [
|
||||
"dist/flexsearch.pre.js"
|
||||
]
|
||||
},
|
||||
"files": [
|
||||
"flexsearch.js",
|
||||
@@ -57,12 +66,12 @@
|
||||
"devDependencies": {
|
||||
"chai": "^4.2.0",
|
||||
"codacy-coverage": "^3.4.0",
|
||||
"coveralls": "^3.0.2",
|
||||
"google-closure-compiler": "^20190215.0.0-nightly",
|
||||
"mocha": "^6.0.0",
|
||||
"coveralls": "^3.0.3",
|
||||
"google-closure-compiler": "^20190219.0.0-nightly",
|
||||
"mocha": "^6.0.1",
|
||||
"mocha-lcov-reporter": "^1.3.0",
|
||||
"mocha-phantomjs": "^4.1.0",
|
||||
"nyc": "^13.1.0",
|
||||
"nyc": "^13.3.0",
|
||||
"phantomjs-prebuilt": "^2.1.16",
|
||||
"updtr": "^3.0.0"
|
||||
}
|
||||
|
@@ -276,8 +276,7 @@
|
||||
bulksearch = new BulkSearch({
|
||||
type: 'short', // this type specifies the maximum bitlength of assigned IDs!
|
||||
encode: 'extra',
|
||||
multi: true,
|
||||
suggest:true
|
||||
multi: true
|
||||
});
|
||||
|
||||
console.time('bulksearch');
|
||||
@@ -295,8 +294,7 @@
|
||||
tokenize: 'strict',
|
||||
threshold: 0,
|
||||
resolution: 9,
|
||||
depth: 3,
|
||||
suggest: true
|
||||
depth: 3
|
||||
});
|
||||
|
||||
console.time('flexsearch');
|
||||
@@ -452,11 +450,11 @@
|
||||
switch(i){
|
||||
|
||||
case 1:
|
||||
results = flexsearch.search(query);
|
||||
results = flexsearch.search(query, {suggest: true});
|
||||
break;
|
||||
|
||||
case 2:
|
||||
results = bulksearch.search(query);
|
||||
results = bulksearch.search(query, {suggest: true});
|
||||
break;
|
||||
|
||||
case 3:
|
||||
|
@@ -1,7 +1,6 @@
|
||||
var env = "";
|
||||
|
||||
if(typeof module !== "undefined"){
|
||||
|
||||
var env = "pre";
|
||||
var expect = require("chai").expect;
|
||||
var FlexSearch = require("../" + (env ? "dist/": "") + "flexsearch" + (env ? "." + env : "") + ".js");
|
||||
}
|
||||
@@ -60,7 +59,6 @@ describe("Index Multi-Field Documents (ES6)", function(){
|
||||
|
||||
async: true,
|
||||
doc: {
|
||||
|
||||
id: "id",
|
||||
field: [
|
||||
"data:title",
|
||||
@@ -71,8 +69,11 @@ describe("Index Multi-Field Documents (ES6)", function(){
|
||||
|
||||
await index.add(data);
|
||||
|
||||
expect(index.doc.index["data:title"].length).to.equal(3);
|
||||
expect(index.doc.index["data:body"].length).to.equal(3);
|
||||
if(env === ""){
|
||||
|
||||
expect(index.doc.index["data:title"].length).to.equal(3);
|
||||
expect(index.doc.index["data:body"].length).to.equal(3);
|
||||
}
|
||||
|
||||
expect(await index.search({field: "data:body", query: "body"})).to.have.members(data);
|
||||
expect(await index.search({field: "data:title", query: "title"})).to.have.members(data);
|
||||
@@ -106,8 +107,11 @@ describe("Index Multi-Field Documents (ES6)", function(){
|
||||
|
||||
await index.remove(update);
|
||||
|
||||
expect(await index.doc.index["data:title"].length).to.equal(0);
|
||||
expect(await index.doc.index["data:body"].length).to.equal(0);
|
||||
if(env === ""){
|
||||
|
||||
expect(await index.doc.index["data:title"].length).to.equal(0);
|
||||
expect(await index.doc.index["data:body"].length).to.equal(0);
|
||||
}
|
||||
});
|
||||
|
||||
it("Should have been indexed properly (Worker)", async function(){
|
||||
@@ -128,8 +132,11 @@ describe("Index Multi-Field Documents (ES6)", function(){
|
||||
|
||||
await index.add(data);
|
||||
|
||||
expect(index.doc.index["data:title"].length).to.equal(3);
|
||||
expect(index.doc.index["data:body"].length).to.equal(3);
|
||||
if(env === ""){
|
||||
|
||||
expect(index.doc.index["data:title"].length).to.equal(3);
|
||||
expect(index.doc.index["data:body"].length).to.equal(3);
|
||||
}
|
||||
|
||||
expect(await index.search({field: "data:body", query: "body"})).to.have.members(data);
|
||||
expect(await index.search({field: "data:title", query: "title"})).to.have.members(data);
|
||||
@@ -163,7 +170,10 @@ describe("Index Multi-Field Documents (ES6)", function(){
|
||||
|
||||
await index.remove(update);
|
||||
|
||||
expect(await index.doc.index["data:title"].length).to.equal(0);
|
||||
expect(await index.doc.index["data:body"].length).to.equal(0);
|
||||
if(env === ""){
|
||||
|
||||
expect(await index.doc.index["data:title"].length).to.equal(0);
|
||||
expect(await index.doc.index["data:body"].length).to.equal(0);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
522
test/test.js
522
test/test.js
@@ -1,6 +1,6 @@
|
||||
if(typeof module !== "undefined"){
|
||||
|
||||
var env = process.argv[3] === "test" ? "min" : process.argv[3] === "test/" ? "light" : "";
|
||||
var env = (process.argv[3] === "test" ? "min" : process.argv[3] === "test/" ? "light" : process.argv[3] === "test/test.js" ? "pre" : "");
|
||||
var expect = require("chai").expect;
|
||||
var FlexSearch = require("../" + (env ? "dist/": "") + "flexsearch" + (env ? "." + env : "") + ".js");
|
||||
//require("../lang/en.min.js");
|
||||
@@ -130,7 +130,7 @@ describe("Initialize", function(){
|
||||
|
||||
encode: "icase",
|
||||
tokenize: "reverse",
|
||||
cache: true
|
||||
cache: 2
|
||||
});
|
||||
|
||||
it("Should have correct constructors", function(){
|
||||
@@ -186,7 +186,7 @@ describe("Initialize", function(){
|
||||
expect(flexsearch_async.async).to.equal(true);
|
||||
}
|
||||
|
||||
if((env !== "light") && (env !== "min")){
|
||||
if((env !== "light") && (env !== "min") && (env !== "pre")){
|
||||
|
||||
expect(flexsearch_default.tokenize).to.equal("forward");
|
||||
expect(flexsearch_strict.tokenize).to.equal("strict");
|
||||
@@ -403,15 +403,42 @@ if(env !== "light"){
|
||||
|
||||
describe("Add (Async)", function(){
|
||||
|
||||
it("Should have been added to the index", function(done){
|
||||
|
||||
var index = new FlexSearch();
|
||||
|
||||
expect(index.length).to.equal(0);
|
||||
|
||||
index.add(0, "foo", function(){
|
||||
|
||||
expect(index.length).to.equal(1);
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
expect(index.length).to.equal(0);
|
||||
});
|
||||
|
||||
it("Should have been added to the index", function(done){
|
||||
|
||||
expect(flexsearch_async.length).to.equal(0);
|
||||
|
||||
flexsearch_async.add(0, "foo");
|
||||
flexsearch_async.add(0, "foo", function(){
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
expect(flexsearch_async.length).to.equal(0);
|
||||
});
|
||||
|
||||
it("Should have been added to the index", function(done){
|
||||
|
||||
expect(flexsearch_async.length).to.equal(1);
|
||||
|
||||
flexsearch_async.add(2, "bar");
|
||||
flexsearch_async.add(1, "foobar");
|
||||
|
||||
expect(flexsearch_async.length).to.equal(0);
|
||||
expect(flexsearch_async.length).to.equal(1);
|
||||
|
||||
setTimeout(function(){
|
||||
|
||||
@@ -448,6 +475,20 @@ if(env !== "light"){
|
||||
|
||||
describe("Search (Async)", function(){
|
||||
|
||||
it("Should have been matched from index", function(done){
|
||||
|
||||
var index = new FlexSearch({doc: {id: "id", field: "title"}});
|
||||
var data = {id: 0, title: "foo"};
|
||||
|
||||
index.add(data);
|
||||
|
||||
index.search("foo", function(result){
|
||||
|
||||
expect(result).to.have.members([data]);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it("Should have been matched from index", function(done){
|
||||
|
||||
flexsearch_async.search("foo", function(result){
|
||||
@@ -580,13 +621,44 @@ if(env !== "light"){
|
||||
|
||||
it("Should have been removed from the index", function(done){
|
||||
|
||||
flexsearch_async.remove(0);
|
||||
var index = new FlexSearch();
|
||||
|
||||
index.add(0, "foo");
|
||||
|
||||
expect(index.length).to.equal(1);
|
||||
|
||||
index.remove(0, function(){
|
||||
|
||||
expect(index.length).to.equal(0);
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
expect(index.length).to.equal(1);
|
||||
});
|
||||
|
||||
it("Should have been removed from the index", function(done){
|
||||
|
||||
expect(flexsearch_async.length).to.equal(3);
|
||||
|
||||
flexsearch_async.remove(0, function(){
|
||||
|
||||
expect(flexsearch_async.length).to.equal(2);
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
expect(flexsearch_async.length).to.equal(3);
|
||||
});
|
||||
|
||||
it("Should have been removed from the index", function(done){
|
||||
|
||||
flexsearch_async.remove(2);
|
||||
flexsearch_async.remove(1).then(function(){
|
||||
expect(flexsearch_async.length).to.equal(0);
|
||||
});
|
||||
|
||||
expect(flexsearch_async.length).to.equal(3);
|
||||
expect(flexsearch_async.length).to.equal(2);
|
||||
|
||||
flexsearch_async.search("foo", function(result){
|
||||
expect(result).to.have.lengthOf(0);
|
||||
@@ -794,7 +866,7 @@ if(env !== "light"){
|
||||
});
|
||||
});
|
||||
|
||||
if(env !== "light" && env !== "min"){
|
||||
if((env !== "light") && (env !== "min")){
|
||||
|
||||
it("Should have been debug mode activated", function(){
|
||||
|
||||
@@ -820,7 +892,7 @@ if(env !== "light"){
|
||||
worker: 4
|
||||
});
|
||||
|
||||
if(env !== "min"){
|
||||
if((env !== "min") && (env !== "pre")){
|
||||
|
||||
expect(flexsearch_worker.info().worker).to.equal(false);
|
||||
}
|
||||
@@ -1130,6 +1202,50 @@ describe("Stemmer", function(){
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe("Custom Language", function(){
|
||||
|
||||
it("Should have been applied properly", function(){
|
||||
|
||||
FlexSearch.registerLanguage("custom", {
|
||||
filter: ["a", "an"],
|
||||
stemmer: {
|
||||
"ization": "ize",
|
||||
"tional": "tion"
|
||||
}
|
||||
});
|
||||
|
||||
var index = new FlexSearch({
|
||||
encode: "icase",
|
||||
tokenize: "reverse",
|
||||
filter: "custom",
|
||||
stemmer: "custom"
|
||||
});
|
||||
|
||||
index.add(0, "Just a multinational colonization.");
|
||||
|
||||
expect(index.length).to.equal(1);
|
||||
expect(index.search("Just a multinational colonization.")).to.include(0);
|
||||
expect(index.search("Just an multinational colonization.")).to.include(0);
|
||||
expect(index.search("multinational colonization")).to.include(0);
|
||||
expect(index.search("tional tion")).to.have.length(0);
|
||||
|
||||
index = new FlexSearch({
|
||||
encode: "icase",
|
||||
tokenize: "reverse",
|
||||
lang: "custom"
|
||||
});
|
||||
|
||||
index.add(0, "Just a multinational colonization.");
|
||||
|
||||
expect(index.length).to.equal(1);
|
||||
expect(index.search("Just a multinational colonization.")).to.include(0);
|
||||
expect(index.search("Just an multinational colonization.")).to.include(0);
|
||||
expect(index.search("multinational colonization")).to.include(0);
|
||||
expect(index.search("tional tion")).to.have.length(0);
|
||||
});
|
||||
});
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Relevance Tests
|
||||
// ------------------------------------------------------------------------
|
||||
@@ -1209,11 +1325,31 @@ if(env !== "light") describe("Suggestions", function(){
|
||||
expect(index.search("1 3 4 7", { suggest: false })).to.have.lengthOf(0);
|
||||
expect(index.search("1 3 4 7", { suggest: true })).to.have.members([0]);
|
||||
expect(index.search("1 3 9 7", { suggest: true })).to.have.members([0]);
|
||||
expect(index.search("one foobar two", { suggest: true })).to.have.members([1, 2]);
|
||||
expect(index.search("zero one foobar two foobar", { suggest: true })).to.have.members([1, 2]);
|
||||
|
||||
//TODO
|
||||
//expect(index.search("zero one foobar two foobar")[0]).to.equal(1);
|
||||
expect(index.search("foobar one two", { suggest: true })).to.have.members([1, 2]);
|
||||
expect(index.search("one foobar two", { suggest: true })).to.have.members([1, 2]);
|
||||
expect(index.search("one two foobar", { suggest: true })).to.have.members([1, 2]);
|
||||
expect(index.search("zero one foobar two foobar", { suggest: true })).to.have.members([1, 2]);
|
||||
});
|
||||
|
||||
it("Should have been suggested properly by context", function(){
|
||||
|
||||
var index = new FlexSearch({
|
||||
encode: "advanced",
|
||||
tokenize: "strict",
|
||||
depth: 3
|
||||
});
|
||||
|
||||
index.add(1, "zero one two three four five six seven eight nine ten");
|
||||
index.add(2, "four two zero one three ten five seven eight six nine");
|
||||
|
||||
expect(index.search("foobar one", { suggest: true })).to.have.members([1, 2]);
|
||||
expect(index.search("foobar foobar foobar one foobar foobar foobar", { suggest: true })).to.have.members([1, 2]);
|
||||
expect(index.search("foobar one two", { suggest: true })).to.have.members([1, 2]);
|
||||
expect(index.search("one foobar two", { suggest: true })).to.have.members([1, 2]);
|
||||
expect(index.search("one two foobar", { suggest: true })).to.have.members([1, 2]);
|
||||
expect(index.search("foobar one foobar two foobar", { suggest: true })).to.have.members([1, 2]);
|
||||
expect(index.search("zero one foobar two foobar", { suggest: true })).to.have.members([1, 2]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1221,7 +1357,7 @@ if(env !== "light") describe("Suggestions", function(){
|
||||
// Where Clause
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
if(env === "" || env === "min") describe("Where/Find", function(){
|
||||
if((env === "") || (env === "min") || (env === "pre")) describe("Where/Find", function(){
|
||||
|
||||
var data = [{
|
||||
id: 0,
|
||||
@@ -1286,6 +1422,145 @@ if(env === "" || env === "min") describe("Where/Find", function(){
|
||||
}
|
||||
})).to.have.members([data[2]]);
|
||||
});
|
||||
|
||||
it("Should have been tagged properly", function(){
|
||||
|
||||
var index = new FlexSearch({
|
||||
doc: {
|
||||
id: "id",
|
||||
field: "title",
|
||||
tag : "cat"
|
||||
}
|
||||
});
|
||||
|
||||
index.add(data);
|
||||
|
||||
expect(index.length).to.equal(3);
|
||||
expect(index.index).to.have.members(["@0", "@1", "@2"]);
|
||||
|
||||
expect(index.where({cat: "1"})).to.have.members([data[0], data[2]]);
|
||||
expect(index.where("cat", "1")).to.have.members([data[0], data[2]]);
|
||||
expect(index.where("cat", "1", 1)).to.have.members([data[0]]);
|
||||
|
||||
expect(index.where({
|
||||
cat: "1",
|
||||
flag: true
|
||||
})).to.have.members([data[2]]);
|
||||
|
||||
expect(index.where({
|
||||
flag: true,
|
||||
cat: "1"
|
||||
})).to.have.members([data[2]]);
|
||||
|
||||
expect(index.search("title", {
|
||||
where: {
|
||||
cat: "1"
|
||||
}
|
||||
})).to.have.members([data[0], data[2]]);
|
||||
|
||||
expect(index.search("title", {
|
||||
where: {
|
||||
cat: "1"
|
||||
},
|
||||
limit: 1
|
||||
})).to.have.members([data[0]]);
|
||||
|
||||
expect(index.search("title", {
|
||||
where: {
|
||||
cat: "3"
|
||||
}
|
||||
})).to.have.lengthOf(0);
|
||||
|
||||
expect(index.search("foobar", {
|
||||
where: {
|
||||
cat: "1"
|
||||
}
|
||||
})).to.have.lengthOf(0);
|
||||
|
||||
// -----------------------------------------
|
||||
|
||||
index = new FlexSearch({
|
||||
doc: {
|
||||
id: "id",
|
||||
field: ["title"],
|
||||
tag : ["cat"]
|
||||
}
|
||||
});
|
||||
|
||||
index.add(data);
|
||||
|
||||
expect(index.length).to.equal(3);
|
||||
expect(index.index).to.have.members(["@0", "@1", "@2"]);
|
||||
|
||||
expect(index.where({cat: "1"})).to.have.members([data[0], data[2]]);
|
||||
|
||||
expect(index.search("title", {
|
||||
where: {
|
||||
cat: "1"
|
||||
}
|
||||
})).to.have.members([data[0], data[2]]);
|
||||
|
||||
expect(index.search("title", {
|
||||
where: {
|
||||
cat: "3"
|
||||
}
|
||||
})).to.have.lengthOf(0);
|
||||
|
||||
expect(index.search("foobar", {
|
||||
where: {
|
||||
cat: "1"
|
||||
}
|
||||
})).to.have.lengthOf(0);
|
||||
|
||||
// ------------------------------------
|
||||
|
||||
index = new FlexSearch({
|
||||
doc: {
|
||||
id: "id",
|
||||
field: "data:title",
|
||||
tag : "data:cat"
|
||||
}
|
||||
});
|
||||
|
||||
data = [{
|
||||
id: 0,
|
||||
data: {
|
||||
title: "Title 1",
|
||||
cat: "1",
|
||||
flag: false
|
||||
}
|
||||
},{
|
||||
id: 1,
|
||||
data: {
|
||||
title: "Title 2",
|
||||
cat: "2",
|
||||
flag: false
|
||||
}
|
||||
},{
|
||||
id: 2,
|
||||
data: {
|
||||
title: "Title 3",
|
||||
cat: "1",
|
||||
flag: true
|
||||
}
|
||||
}];
|
||||
|
||||
index.add(data);
|
||||
|
||||
expect(index.where({"data:cat": "1"})).to.have.members([data[0], data[2]]);
|
||||
expect(index.where("data:cat", "1")).to.have.members([data[0], data[2]]);
|
||||
expect(index.where("data:cat", "1", 1)).to.have.members([data[0]]);
|
||||
|
||||
expect(index.where({
|
||||
"data:cat": "1",
|
||||
"data:flag": true
|
||||
})).to.have.members([data[2]]);
|
||||
|
||||
expect(index.where({
|
||||
"data:flag": true,
|
||||
"data:cat": "1"
|
||||
})).to.have.members([data[2]]);
|
||||
});
|
||||
});
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
@@ -1777,7 +2052,79 @@ if(env !== "light") describe("Index Multi-Field Documents", function(){
|
||||
expect(results[2]).to.equal(data[0]);
|
||||
});
|
||||
|
||||
if(env === "" && (typeof require !== "undefined") && !this._phantom){
|
||||
it("Should have been sorted suggested and paged", function(){
|
||||
|
||||
var index = new FlexSearch({
|
||||
|
||||
doc: {
|
||||
id: "id",
|
||||
field: ["data:title", "data:body"]
|
||||
}
|
||||
});
|
||||
|
||||
index.add(data);
|
||||
|
||||
var results = index.search({
|
||||
|
||||
field: "data:title",
|
||||
query: "title",
|
||||
suggest: true,
|
||||
page: true,
|
||||
limit: 2
|
||||
});
|
||||
|
||||
expect(results.result).to.have.members([data[0], data[1]]);
|
||||
|
||||
results = index.search({
|
||||
|
||||
field: "data:title",
|
||||
query: "title",
|
||||
suggest: true,
|
||||
page: results.next,
|
||||
limit: 2
|
||||
});
|
||||
|
||||
expect(results.result).to.have.members([data[2]]);
|
||||
|
||||
results = index.search({
|
||||
|
||||
field: "data:title",
|
||||
query: "foobar title foobar title foobar",
|
||||
suggest: true,
|
||||
page: true,
|
||||
limit: 2
|
||||
});
|
||||
|
||||
expect(results.result).to.have.members([data[0], data[1]]);
|
||||
|
||||
results = index.search({
|
||||
|
||||
field: "data:title",
|
||||
query: "foobar title foobar title foobar",
|
||||
suggest: true,
|
||||
page: results.next,
|
||||
limit: 2
|
||||
});
|
||||
|
||||
expect(results.result).to.have.members([data[2]]);
|
||||
|
||||
results = index.search([{
|
||||
|
||||
field: "data:title",
|
||||
query: "title undefined",
|
||||
bool: "and",
|
||||
suggest: true,
|
||||
limit: 2
|
||||
},{
|
||||
field: "data:body",
|
||||
query: "undefined",
|
||||
bool: "not"
|
||||
}]);
|
||||
|
||||
expect(results).to.have.members([data[0], data[1]]);
|
||||
});
|
||||
|
||||
if((!env || (env === "pre")) && (typeof require !== "undefined") && !this._phantom){
|
||||
|
||||
require("./test.es6.js");
|
||||
}
|
||||
@@ -1829,6 +2176,66 @@ if(env !== "light") describe("Pagination", function(){
|
||||
expect(result.result).to.have.members([4]);
|
||||
});
|
||||
|
||||
it("Should have been properly paged (suggestion)", function(){
|
||||
|
||||
var index = new FlexSearch();
|
||||
|
||||
index.add(0, "foo bar").add(1, "foo bar").add(2, "foo bar test").add(3, "foo bar").add(4, "foo bar");
|
||||
|
||||
expect(index.index).to.have.members(["@0", "@1", "@2", "@3", "@4"]);
|
||||
expect(index.search("foo")).to.have.lengthOf(5);
|
||||
expect(index.search("foo", 2)).to.have.lengthOf(2);
|
||||
|
||||
var result = index.search("foo undefined bar", {
|
||||
suggest: true,
|
||||
page: true,
|
||||
limit: 2
|
||||
});
|
||||
|
||||
expect(result).to.have.keys(["page", "next", "result"]);
|
||||
expect(result.result).to.have.members([0, 1]);
|
||||
|
||||
result = index.search("foo bar test", {
|
||||
suggest: true,
|
||||
page: true,
|
||||
limit: 2
|
||||
});
|
||||
|
||||
expect(result.result).to.have.members([2, 0]);
|
||||
|
||||
result = index.search("foo undefined bar", {
|
||||
suggest: true,
|
||||
page: true,
|
||||
limit: 2
|
||||
});
|
||||
|
||||
expect(result.result).to.have.members([0, 1]);
|
||||
|
||||
result = index.search("foo undefined bar", {
|
||||
suggest: true,
|
||||
page: result.next,
|
||||
limit: 2
|
||||
});
|
||||
|
||||
expect(result.result).to.have.members([2, 3]);
|
||||
|
||||
result = index.search("foo undefined bar", {
|
||||
suggest: true,
|
||||
page: result.page,
|
||||
limit: 2
|
||||
});
|
||||
|
||||
expect(result.result).to.have.members([2, 3]);
|
||||
|
||||
result = index.search("foo undefined bar", {
|
||||
suggest: true,
|
||||
page: result.next,
|
||||
limit: 2
|
||||
});
|
||||
|
||||
expect(result.result).to.have.members([4]);
|
||||
});
|
||||
|
||||
it("Should have been properly paged (documents)", function(){
|
||||
|
||||
var data = [{
|
||||
@@ -2164,6 +2571,20 @@ if(env !== "light") describe("Operators", function(){
|
||||
query: "x",
|
||||
bool: "not"
|
||||
}])).to.have.length(0);
|
||||
|
||||
expect(index.search([{
|
||||
field: "title",
|
||||
query: "title",
|
||||
bool: "not"
|
||||
},{
|
||||
field: "body",
|
||||
query: "body",
|
||||
bool: "not"
|
||||
},{
|
||||
field: "blacklist",
|
||||
query: "x",
|
||||
bool: "not"
|
||||
}])).to.have.length(0);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -2220,6 +2641,42 @@ if(env !== "light") describe("Export / Import", function(){
|
||||
|
||||
it("Should have been exported properly", function(){
|
||||
|
||||
var index = new FlexSearch("match");
|
||||
|
||||
index.add(0, "foo");
|
||||
index.add(1, "bar");
|
||||
index.add(2, "foobar");
|
||||
|
||||
data = index.export();
|
||||
|
||||
if(env === ""){
|
||||
|
||||
expect(data).to.equal(JSON.stringify(
|
||||
[
|
||||
index._map,
|
||||
index._ctx,
|
||||
Object.keys(index._ids)
|
||||
]
|
||||
));
|
||||
}
|
||||
});
|
||||
|
||||
it("Should have been imported properly", function(){
|
||||
|
||||
var index = new FlexSearch("match");
|
||||
|
||||
index.import(data);
|
||||
|
||||
expect(index.length).to.equal(3);
|
||||
|
||||
expect(index.search("foo")).to.have.lengthOf(2);
|
||||
expect(index.search("bar")).to.have.lengthOf(2);
|
||||
expect(index.search("foobar")).to.have.lengthOf(1);
|
||||
expect(index.search("foobar")[0]).to.equal(2);
|
||||
});
|
||||
|
||||
it("Should have been exported properly (documents)", function(){
|
||||
|
||||
var index = new FlexSearch({
|
||||
tokenize: "reverse",
|
||||
doc: {
|
||||
@@ -2248,9 +2705,10 @@ if(env !== "light") describe("Export / Import", function(){
|
||||
}
|
||||
});
|
||||
|
||||
it("Should have been imported properly", function(){
|
||||
it("Should have been imported properly (documents)", function(){
|
||||
|
||||
var index = new FlexSearch("score", {
|
||||
var index = new FlexSearch({
|
||||
tokenize: "reverse",
|
||||
doc: {
|
||||
id: "id",
|
||||
field: "title"
|
||||
@@ -2286,6 +2744,19 @@ describe("Presets", function(){
|
||||
expect(FlexSearch.create("balance").length).to.equal(0);
|
||||
expect(FlexSearch.create("fast").length).to.equal(0);
|
||||
});
|
||||
|
||||
it("Should have been properly extended", function(){
|
||||
|
||||
var index = FlexSearch.create("fast");
|
||||
index.add(0, "foobar");
|
||||
expect(index.search("bar")).to.have.lengthOf(0);
|
||||
|
||||
index = FlexSearch.create("fast", {id: "test", tokenize: "reverse"});
|
||||
expect(index.id).to.equal("test");
|
||||
index.add(0, "foobar");
|
||||
expect(index.search("bar")).to.have.lengthOf(1);
|
||||
expect(index.search("bar")).to.have.members([0])
|
||||
});
|
||||
});
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
@@ -2418,6 +2889,23 @@ describe("Destroy", function(){
|
||||
expect(index.search("foo")).to.have.lengthOf(0);
|
||||
expect(index.search("bar")).to.have.lengthOf(0);
|
||||
});
|
||||
|
||||
if(env !== "light") it("Should have been destroyed properly (documents)", function(){
|
||||
|
||||
var data = [{id: 0, title: "foo"}, {id: 1, title: "bar"}];
|
||||
|
||||
var index = FlexSearch.create({doc: {id: "id", field: "title"}})
|
||||
.add(data)
|
||||
.add(data);
|
||||
|
||||
expect(index.search("foo")).to.have.members([data[0]]);
|
||||
expect(index.search("bar")).to.have.members([data[1]]);
|
||||
|
||||
index.destroy();
|
||||
|
||||
expect(index.search("foo")).to.have.lengthOf(0);
|
||||
expect(index.search("bar")).to.have.lengthOf(0);
|
||||
});
|
||||
});
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
Reference in New Issue
Block a user