diff --git a/README.md b/README.md
index 9a9b81e..61b8326 100644
--- a/README.md
+++ b/README.md
@@ -1640,7 +1640,8 @@ index.cleanup();
The basic idea of this concept is to limit relevance by its context instead of calculating relevance through the whole distance of its corresponding document. The context acts like a bidirectional moving window of 2 pointers (terms) which can initially have a maximum distance of the value passed via option setting `depth` and dynamically growth on search when the query did not match any results.
-
+
+
### Enable Context-Search
diff --git a/dist/flexsearch.bundle.debug.js b/dist/flexsearch.bundle.debug.js
index c76a541..e8bb065 100644
--- a/dist/flexsearch.bundle.debug.js
+++ b/dist/flexsearch.bundle.debug.js
@@ -1,5 +1,5 @@
/**!
- * FlexSearch.js v0.8.213 (Bundle/Debug)
+ * FlexSearch.js v0.8.214 (Bundle/Debug)
* Author and Copyright: Thomas Wilkerling
* Licence: Apache-2.0
* Hosted by Nextapps GmbH
@@ -857,31 +857,32 @@ function Oa(a, c, b, e, d, f, g, k) {
if (r && (u || a.await)) {
u = 1;
let v;
- const A = a.C.length, D = new Promise(function(F) {
+ const A = a.C.length, E = new Promise(function(F) {
v = F;
});
- (function(F, E) {
- D.h = function() {
- E.index = null;
- E.resolve = !1;
- let B = t ? F.searchAsync(E) : F.search(E);
- if (B.then) {
- return B.then(function(z) {
+ (function(F, B) {
+ E.h = function() {
+ B.index = null;
+ B.resolve = !1;
+ B.enrich = !1;
+ let C = t ? F.searchAsync(B) : F.search(B);
+ if (C.then) {
+ return C.then(function(z) {
a.C[A] = z = z.result || z;
v(z);
return z;
});
}
- B = B.result || B;
- v(B);
- return B;
+ C = C.result || C;
+ v(C);
+ return C;
};
})(n, Object.assign({}, d));
- a.C.push(D);
- f[c] = D;
+ a.C.push(E);
+ f[c] = E;
continue;
} else {
- d.resolve = !1, d.index = null, r = t ? n.searchAsync(d) : n.search(d), d.resolve = l, d.index = n;
+ d.resolve = !1, d.enrich = !1, d.index = null, r = t ? n.searchAsync(d) : n.search(d), d.resolve = l, d.enrich = h, d.index = n;
}
} else if (d.and) {
r = Va(d, "and", n);
@@ -1138,70 +1139,70 @@ function bb(a, c, b, e, d, f, g) {
q = "";
var v = [];
let za = [];
- var A = -1, D = -1, F = 0;
- for (var E = 0; E < x.length; E++) {
- var B = x[E], z = ea.encode(B);
+ var A = -1, E = -1, F = 0;
+ for (var B = 0; B < x.length; B++) {
+ var C = x[B], z = ea.encode(C);
z = z.length > 1 ? z.join(" ") : z[0];
let y;
- if (z && B) {
- var C = B.length, J = (ea.split ? B.replace(ea.split, "") : B).length - z.length, G = "", L = 0;
+ if (z && C) {
+ var D = C.length, J = (ea.split ? C.replace(ea.split, "") : C).length - z.length, G = "", L = 0;
for (var O = 0; O < n.length; O++) {
var P = n[O];
if (P) {
var M = P.length;
M += J < 0 ? 0 : J;
- L && M <= L || (P = z.indexOf(P), P > -1 && (G = (P ? B.substring(0, P) : "") + g + B.substring(P, P + M) + k + (P + M < C ? B.substring(P + M) : ""), L = M, y = !0));
+ L && M <= L || (P = z.indexOf(P), P > -1 && (G = (P ? C.substring(0, P) : "") + g + C.substring(P, P + M) + k + (P + M < D ? C.substring(P + M) : ""), L = M, y = !0));
}
}
- G && (h && (A < 0 && (A = q.length + (q ? 1 : 0)), D = q.length + (q ? 1 : 0) + G.length, F += C, za.push(v.length), v.push({match:G})), q += (q ? " " : "") + G);
+ G && (h && (A < 0 && (A = q.length + (q ? 1 : 0)), E = q.length + (q ? 1 : 0) + G.length, F += D, za.push(v.length), v.push({match:G})), q += (q ? " " : "") + G);
}
if (!y) {
- B = x[E], q += (q ? " " : "") + B, h && v.push({text:B});
+ C = x[B], q += (q ? " " : "") + C, h && v.push({text:C});
} else if (h && F >= h) {
break;
}
}
F = za.length * (f.length - 2);
if (r || t || h && q.length - F > h) {
- if (F = h + F - u * 2, E = D - A, r > 0 && (E += r), t > 0 && (E += t), E <= F) {
- x = r ? A - (r > 0 ? r : 0) : A - ((F - E) / 2 | 0), v = t ? D + (t > 0 ? t : 0) : x + F, l || (x > 0 && q.charAt(x) !== " " && q.charAt(x - 1) !== " " && (x = q.indexOf(" ", x), x < 0 && (x = 0)), v < q.length && q.charAt(v - 1) !== " " && q.charAt(v) !== " " && (v = q.lastIndexOf(" ", v), v < D ? v = D : ++v)), q = (x ? d : "") + q.substring(x, v) + (v < q.length ? d : "");
+ if (F = h + F - u * 2, B = E - A, r > 0 && (B += r), t > 0 && (B += t), B <= F) {
+ x = r ? A - (r > 0 ? r : 0) : A - ((F - B) / 2 | 0), v = t ? E + (t > 0 ? t : 0) : x + F, l || (x > 0 && q.charAt(x) !== " " && q.charAt(x - 1) !== " " && (x = q.indexOf(" ", x), x < 0 && (x = 0)), v < q.length && q.charAt(v - 1) !== " " && q.charAt(v) !== " " && (v = q.lastIndexOf(" ", v), v < E ? v = E : ++v)), q = (x ? d : "") + q.substring(x, v) + (v < q.length ? d : "");
} else {
- D = [];
+ E = [];
A = {};
F = {};
- E = {};
B = {};
+ C = {};
z = {};
- G = J = C = 0;
+ G = J = D = 0;
for (O = L = 1;;) {
var U = void 0;
for (let y = 0, K; y < za.length; y++) {
K = za[y];
if (G) {
if (J !== G) {
- if (E[y + 1]) {
+ if (B[y + 1]) {
continue;
}
K += G;
if (A[K]) {
- C -= u;
+ D -= u;
F[y + 1] = 1;
- E[y + 1] = 1;
+ B[y + 1] = 1;
continue;
}
if (K >= v.length - 1) {
if (K >= v.length) {
- E[y + 1] = 1;
+ B[y + 1] = 1;
K >= x.length && (F[y + 1] = 1);
continue;
}
- C -= u;
+ D -= u;
}
q = v[K].text;
if (M = t && z[y]) {
if (M > 0) {
if (q.length > M) {
- if (E[y + 1] = 1, l) {
+ if (B[y + 1] = 1, l) {
q = q.substring(0, M);
} else {
continue;
@@ -1210,81 +1211,81 @@ function bb(a, c, b, e, d, f, g) {
(M -= q.length) || (M = -1);
z[y] = M;
} else {
- E[y + 1] = 1;
+ B[y + 1] = 1;
continue;
}
}
- if (C + q.length + 1 <= h) {
- q = " " + q, D[y] += q;
+ if (D + q.length + 1 <= h) {
+ q = " " + q, E[y] += q;
} else if (l) {
- U = h - C - 1, U > 0 && (q = " " + q.substring(0, U), D[y] += q), E[y + 1] = 1;
+ U = h - D - 1, U > 0 && (q = " " + q.substring(0, U), E[y] += q), B[y + 1] = 1;
} else {
- E[y + 1] = 1;
+ B[y + 1] = 1;
continue;
}
} else {
- if (E[y]) {
+ if (B[y]) {
continue;
}
K -= J;
if (A[K]) {
- C -= u;
- E[y] = 1;
+ D -= u;
+ B[y] = 1;
F[y] = 1;
continue;
}
if (K <= 0) {
if (K < 0) {
- E[y] = 1;
+ B[y] = 1;
F[y] = 1;
continue;
}
- C -= u;
+ D -= u;
}
q = v[K].text;
- if (M = r && B[y]) {
+ if (M = r && C[y]) {
if (M > 0) {
if (q.length > M) {
- if (E[y] = 1, l) {
+ if (B[y] = 1, l) {
q = q.substring(q.length - M);
} else {
continue;
}
}
(M -= q.length) || (M = -1);
- B[y] = M;
+ C[y] = M;
} else {
- E[y] = 1;
+ B[y] = 1;
continue;
}
}
- if (C + q.length + 1 <= h) {
- q += " ", D[y] = q + D[y];
+ if (D + q.length + 1 <= h) {
+ q += " ", E[y] = q + E[y];
} else if (l) {
- U = q.length + 1 - (h - C), U >= 0 && U < q.length && (q = q.substring(U) + " ", D[y] = q + D[y]), E[y] = 1;
+ U = q.length + 1 - (h - D), U >= 0 && U < q.length && (q = q.substring(U) + " ", E[y] = q + E[y]), B[y] = 1;
} else {
- E[y] = 1;
+ B[y] = 1;
continue;
}
}
} else {
q = v[K].match;
- r && (B[y] = r);
+ r && (C[y] = r);
t && (z[y] = t);
- y && C++;
+ y && D++;
let Qa;
- K ? !y && u && (C += u) : (F[y] = 1, E[y] = 1);
- K >= x.length - 1 ? Qa = 1 : K < v.length - 1 && v[K + 1].match ? Qa = 1 : u && (C += u);
- C -= f.length - 2;
- if (!y || C + q.length <= h) {
- D[y] = q;
+ K ? !y && u && (D += u) : (F[y] = 1, B[y] = 1);
+ K >= x.length - 1 ? Qa = 1 : K < v.length - 1 && v[K + 1].match ? Qa = 1 : u && (D += u);
+ D -= f.length - 2;
+ if (!y || D + q.length <= h) {
+ E[y] = q;
} else {
U = L = O = F[y] = 0;
break;
}
- Qa && (F[y + 1] = 1, E[y + 1] = 1);
+ Qa && (F[y + 1] = 1, B[y + 1] = 1);
}
- C += q.length;
+ D += q.length;
U = A[K] = 1;
}
if (U) {
@@ -1298,10 +1299,10 @@ function bb(a, c, b, e, d, f, g) {
}
}
q = "";
- for (let y = 0, K; y < D.length; y++) {
- K = (F[y] ? y ? " " : "" : (y && !d ? " " : "") + d) + D[y], q += K;
+ for (let y = 0, K; y < E.length; y++) {
+ K = (F[y] ? y ? " " : "" : (y && !d ? " " : "") + d) + E[y], q += K;
}
- d && !F[D.length] && (q += d);
+ d && !F[E.length] && (q += d);
}
}
m && (q = q.replace(m, " "));
@@ -1328,9 +1329,11 @@ function bb(a, c, b, e, d, f, g) {
const m = l.resolve;
a = l.async || l.queue;
l.resolve = !1;
+ l.highlight = "";
l.index = null;
a = a ? c.searchAsync(l) : c.search(l);
l.resolve = m;
+ l.highlight = g;
l.index = c;
a = a.result || a;
} else {
@@ -1626,26 +1629,26 @@ Na.prototype.search = function(a, c, b, e) {
if (n && (!this.db || !e)) {
n.constructor !== Array && (n = [n]);
var v = [];
- for (let B = 0, z; B < n.length; B++) {
- z = n[B];
+ for (let C = 0, z; C < n.length; C++) {
+ z = n[C];
if (N(z)) {
throw Error("A tag option can't be a string, instead it needs a { field: tag } format.");
}
if (z.field && z.tag) {
var A = z.tag;
if (A.constructor === Array) {
- for (var D = 0; D < A.length; D++) {
- v.push(z.field, A[D]);
+ for (var E = 0; E < A.length; E++) {
+ v.push(z.field, A[E]);
}
} else {
v.push(z.field, A);
}
} else {
A = Object.keys(z);
- for (let C = 0, J, G; C < A.length; C++) {
- if (J = A[C], G = z[J], G.constructor === Array) {
- for (D = 0; D < G.length; D++) {
- v.push(J, G[D]);
+ for (let D = 0, J, G; D < A.length; D++) {
+ if (J = A[D], G = z[J], G.constructor === Array) {
+ for (E = 0; E < G.length; E++) {
+ v.push(J, G[E]);
}
} else {
v.push(J, G);
@@ -1675,12 +1678,12 @@ Na.prototype.search = function(a, c, b, e) {
}
}
if (f.length) {
- const B = this;
+ const C = this;
return Promise.all(f).then(function(z) {
- for (let C = 0; C < z.length; C++) {
- r ? d[C].result = z[C] : d[C] = z[C];
+ for (let D = 0; D < z.length; D++) {
+ r ? d[D].result = z[D] : d[D] = z[D];
}
- return r ? d : new X(d.length > 1 ? $a(d, 1, 0, 0, h, l) : d[0], B);
+ return r ? d : new X(d.length > 1 ? $a(d, 1, 0, 0, h, l) : d[0], C);
});
}
return r ? d : new X(d.length > 1 ? $a(d, 1, 0, 0, h, l) : d[0], this);
@@ -1699,38 +1702,38 @@ Na.prototype.search = function(a, c, b, e) {
p || (p = this.field);
let F;
v = (this.worker || this.db) && !e && [];
- for (let B = 0, z, C, J; B < p.length; B++) {
- C = p[B];
- if (this.db && this.tag && !this.B[B]) {
+ for (let C = 0, z, D, J; C < p.length; C++) {
+ D = p[C];
+ if (this.db && this.tag && !this.B[C]) {
continue;
}
let G;
- N(C) || (G = C, C = G.field, a = G.query || a, c = aa(G.limit, c), x = aa(G.offset, x), h = aa(G.suggest, h), t = r && this.store && aa(G.highlight, t), q = !!t || r && this.store && aa(G.enrich, q), m = aa(G.cache, m));
+ N(D) || (G = D, D = G.field, a = G.query || a, c = aa(G.limit, c), x = aa(G.offset, x), h = aa(G.suggest, h), t = r && this.store && aa(G.highlight, t), q = !!t || r && this.store && aa(G.enrich, q), m = aa(G.cache, m));
if (e) {
- z = e[B];
+ z = e[C];
} else {
A = G || b || {};
- D = A.enrich;
- var E = this.index.get(C);
- n && (this.db && (A.tag = n, A.field = p, F = E.db.support_tag_search), !F && D && (A.enrich = !1), F || (A.limit = 0, A.offset = 0));
- z = m ? E.searchCache(a, n && !F ? 0 : c, A) : E.search(a, n && !F ? 0 : c, A);
+ E = A.enrich;
+ var B = this.index.get(D);
+ n && (this.db && (A.tag = n, A.field = p, F = B.db.support_tag_search), !F && E && (A.enrich = !1), F || (A.limit = 0, A.offset = 0));
+ z = m ? B.searchCache(a, n && !F ? 0 : c, A) : B.search(a, n && !F ? 0 : c, A);
n && !F && (A.limit = c, A.offset = x);
- D && (A.enrich = D);
+ E && (A.enrich = E);
if (v) {
- v[B] = z;
+ v[C] = z;
continue;
}
}
J = (z = z.result || z) && z.length;
if (n && J) {
A = [];
- D = 0;
+ E = 0;
if (this.db && e) {
if (!F) {
- for (E = p.length; E < e.length; E++) {
- let L = e[E];
+ for (B = p.length; B < e.length; B++) {
+ let L = e[B];
if (L && L.length) {
- D++, A.push(L);
+ E++, A.push(L);
} else if (!h) {
return r ? d : new X(d, this);
}
@@ -1747,23 +1750,23 @@ Na.prototype.search = function(a, c, b, e) {
}
}
if (P = (O = O && O.get(n[L + 1])) && O.length) {
- D++, A.push(O);
+ E++, A.push(O);
} else if (!h) {
return r ? d : new X(d, this);
}
}
}
- if (D) {
+ if (E) {
z = db(z, A, c, x, r);
J = z.length;
if (!J && !h) {
return r ? z : new X(z, this);
}
- D--;
+ E--;
}
}
if (J) {
- f[u] = C, d.push(z), u++;
+ f[u] = D, d.push(z), u++;
} else if (p.length === 1) {
return r ? d : new X(d, this);
}
@@ -1782,10 +1785,10 @@ Na.prototype.search = function(a, c, b, e) {
v.push(f.db.tag(n[q + 1], c, x, !1));
}
}
- const B = this;
+ const C = this;
return Promise.all(v).then(function(z) {
b && (b.resolve = r);
- z.length && (z = B.search(a, c, b, z));
+ z.length && (z = C.search(a, c, b, z));
return z;
});
}
@@ -1805,12 +1808,12 @@ Na.prototype.search = function(a, c, b, e) {
d[x] = {field:f[x], result:n};
}
if (q && this.db && v.length) {
- const B = this;
+ const C = this;
return Promise.all(v).then(function(z) {
- for (let C = 0; C < z.length; C++) {
- d[C].result = z[C];
+ for (let D = 0; D < z.length; D++) {
+ d[D].result = z[D];
}
- t && (d = cb(a, d, B.index, g, t));
+ t && (d = cb(a, d, C.index, g, t));
return k ? fb(d) : d;
});
}
@@ -2277,7 +2280,7 @@ function tb(a, c) {
}
return b;
}
-;const vb = {memory:{resolution:1}, performance:{resolution:3, fastupdate:!0, context:{depth:1, resolution:1}}, match:{tokenize:"forward"}, score:{resolution:9, context:{depth:2, resolution:3}}};
+;const vb = {memory:{resolution:1}, performance:{resolution:3, fastupdate:!0, context:{depth:1, resolution:1}}, match:{tokenize:"full"}, score:{resolution:9, context:{depth:2, resolution:3}}};
T.prototype.add = function(a, c, b, e) {
if (c && (a || a === 0)) {
if (!e && !b && this.reg.has(a)) {
diff --git a/dist/flexsearch.bundle.min.js b/dist/flexsearch.bundle.min.js
index f8c5e0d..2a54c10 100644
--- a/dist/flexsearch.bundle.min.js
+++ b/dist/flexsearch.bundle.min.js
@@ -1,5 +1,5 @@
/**!
- * FlexSearch.js v0.8.213 (Bundle)
+ * FlexSearch.js v0.8.214 (Bundle)
* Author and Copyright: Thomas Wilkerling
* Licence: Apache-2.0
* Hosted by Nextapps GmbH
@@ -35,32 +35,32 @@ function Ma(a,c,b){return c?typeof module!=="undefined"?new(require("worker_thre
f.G;if(g&&!g(c))continue;f.constructor===String&&(f=""+f);f=ca(c,f)}if(d&&f){M(f)&&(f=[f]);for(let h=0,l,m;hc?a.slice(b,b+c):a,e?Ta.call(this,a):a;let d=[];for(let f=0,g,k;f=k){b-=k;continue}g=g.slice(b,b+c);k=g.length;b=0}k>c&&(g=g.slice(0,c),k=c);if(!d.length&&k>=c)return e?Ta.call(this,g):g;d.push(g);c-=k;if(!c)break}d=d.length>1?[].concat.apply([],d):d[0];return e?Ta.call(this,d):d};function Ua(a,c,b,e){var d=e[0];if(d[0]&&d[0].query)return a[c].apply(a,d);if(!(c!=="and"&&c!=="not"||a.result.length||a.await||d.suggest))return e.length>1&&(d=e[e.length-1]),(e=d.resolve)?a.await||a.result:a;let f=[],g=0,k=0,h,l,m,p,u;for(c=0;c1&&(b=b[c].apply(b,a.slice(1)));return b};X.prototype.or=function(){return Ua(this,"or",Xa,arguments)};function Xa(a,c,b,e,d,f,g){a.length&&(this.result.length&&a.push(this.result),a.length<2?this.result=a[0]:(this.result=Ya(a,c,b,!1,this.h),b=0));d&&(this.await=null);return d?this.resolve(c,b,e,g):this};X.prototype.and=function(){return Ua(this,"and",Za,arguments)};function Za(a,c,b,e,d,f,g){if(!f&&!this.result.length)return d?this.result:this;let k;if(a.length)if(this.result.length&&a.unshift(this.result),a.length<2)this.result=a[0];else{let h=0;for(let l=0,m,p;l1&&(b=b[c].apply(b,a.slice(1)));return b};X.prototype.or=function(){return Ua(this,"or",Xa,arguments)};function Xa(a,c,b,e,d,f,g){a.length&&(this.result.length&&a.push(this.result),a.length<2?this.result=a[0]:(this.result=Ya(a,c,b,!1,this.h),b=0));d&&(this.await=null);return d?this.resolve(c,b,e,g):this};X.prototype.and=function(){return Ua(this,"and",Za,arguments)};function Za(a,c,b,e,d,f,g){if(!f&&!this.result.length)return d?this.result:this;let k;if(a.length)if(this.result.length&&a.unshift(this.result),a.length<2)this.result=a[0];else{let h=0;for(let l=0,m,p;l1?z.join(" "):z[0];let y;if(z&&B){var C=B.length,J=(da.split?
-B.replace(da.split,""):B).length-z.length,G="",N=0;for(var O=0;O-1&&(G=(P?B.substring(0,P):"")+g+B.substring(P,P+L)+k+(P+L=h)break}F=za.length*(f.length-2);if(r||t||h&&q.length-F>h)if(F=h+F-u*2,E=D-
-A,r>0&&(E+=r),t>0&&(E+=t),E<=F)x=r?A-(r>0?r:0):A-((F-E)/2|0),v=t?D+(t>0?t:0):x+F,l||(x>0&&q.charAt(x)!==" "&&q.charAt(x-1)!==" "&&(x=q.indexOf(" ",x),x<0&&(x=0)),v=v.length-
-1){if(K>=v.length){E[y+1]=1;K>=x.length&&(F[y+1]=1);continue}C-=u}q=v[K].text;if(L=t&&z[y])if(L>0){if(q.length>L)if(E[y+1]=1,l)q=q.substring(0,L);else continue;(L-=q.length)||(L=-1);z[y]=L}else{E[y+1]=1;continue}if(C+q.length+1<=h)q=" "+q,D[y]+=q;else if(l)U=h-C-1,U>0&&(q=" "+q.substring(0,U),D[y]+=q),E[y+1]=1;else{E[y+1]=1;continue}}else{if(E[y])continue;K-=J;if(A[K]){C-=u;E[y]=1;F[y]=1;continue}if(K<=0){if(K<0){E[y]=1;F[y]=1;continue}C-=u}q=v[K].text;if(L=r&&B[y])if(L>0){if(q.length>L)if(E[y]=1,
-l)q=q.substring(q.length-L);else continue;(L-=q.length)||(L=-1);B[y]=L}else{E[y]=1;continue}if(C+q.length+1<=h)q+=" ",D[y]=q+D[y];else if(l)U=q.length+1-(h-C),U>=0&&U=x.length-1?Qa=1:K1?z.join(" "):z[0];let y;if(z&&C){var D=C.length,J=(da.split?
+C.replace(da.split,""):C).length-z.length,G="",N=0;for(var O=0;O-1&&(G=(P?C.substring(0,P):"")+g+C.substring(P,P+L)+k+(P+L=h)break}F=za.length*(f.length-2);if(r||t||h&&q.length-F>h)if(F=h+F-u*2,B=E-
+A,r>0&&(B+=r),t>0&&(B+=t),B<=F)x=r?A-(r>0?r:0):A-((F-B)/2|0),v=t?E+(t>0?t:0):x+F,l||(x>0&&q.charAt(x)!==" "&&q.charAt(x-1)!==" "&&(x=q.indexOf(" ",x),x<0&&(x=0)),v=v.length-
+1){if(K>=v.length){B[y+1]=1;K>=x.length&&(F[y+1]=1);continue}D-=u}q=v[K].text;if(L=t&&z[y])if(L>0){if(q.length>L)if(B[y+1]=1,l)q=q.substring(0,L);else continue;(L-=q.length)||(L=-1);z[y]=L}else{B[y+1]=1;continue}if(D+q.length+1<=h)q=" "+q,E[y]+=q;else if(l)U=h-D-1,U>0&&(q=" "+q.substring(0,U),E[y]+=q),B[y+1]=1;else{B[y+1]=1;continue}}else{if(B[y])continue;K-=J;if(A[K]){D-=u;B[y]=1;F[y]=1;continue}if(K<=0){if(K<0){B[y]=1;F[y]=1;continue}D-=u}q=v[K].text;if(L=r&&C[y])if(L>0){if(q.length>L)if(B[y]=1,
+l)q=q.substring(q.length-L);else continue;(L-=q.length)||(L=-1);C[y]=L}else{B[y]=1;continue}if(D+q.length+1<=h)q+=" ",E[y]=q+E[y];else if(l)U=q.length+1-(h-D),U>=0&&U=x.length-1?Qa=1:K1?Ya(h,b,e,g,f):(h=h[0])&&b&&h.length>b||e?h.slice(e,b+e):h;else{if(ab||e)h=h.slice(e,b+
e)}else{d=[];for(let p=0,u;pe)e-=u.length;else{if(b&&u.length>b||e)u=u.slice(e,b+e),b-=u.length,e&&(e-=u.length);d.push(u);if(!b)break}h=d}}return h}
function Ya(a,c,b,e,d){const f=[],g=I();let k;var h=a.length;let l;if(e)for(d=h-1;d>=0;d--){if(l=(e=a[d])&&e.length)for(h=0;h=0;m--){p=a[m];for(let r=0;r1?$a(d,1,0,0,h,l):d[0],B)})}return r?d:new X(d.length>1?$a(d,1,0,0,h,l):d[0],this)}}r||g||!(p=p||this.field)||(M(p)?g=p:(p.constructor===Array&&p.length===1&&(p=p[0]),g=p.field||p.index));p&&p.constructor!==Array&&(p=[p])}p||(p=this.field);let F;v=(this.worker||this.db)&&!e&&[];for(let B=0,z,C,J;B1?$a(d,1,0,0,h,l):d[0],C)})}return r?d:new X(d.length>1?$a(d,1,0,0,h,l):d[0],this)}}r||g||!(p=p||this.field)||(M(p)?g=p:(p.constructor===Array&&p.length===1&&(p=p[0]),g=p.field||p.index));p&&p.constructor!==Array&&(p=[p])}p||(p=this.field);let F;v=(this.worker||this.db)&&!e&&[];for(let C=0,z,D,J;C0){if(b&&c>b||e)a=a.slice(e,e+b);d&&(a=Ta.call(this,a))}return a}
function Ta(a){if(!this||!this.store)return a;if(this.db)return this.index.get(this.field[0]).db.enrich(a);const c=Array(a.length);for(let b=0,e;b2?b[0]:"";b=b.length>2?b[2]:b[1];if(this.worker&&e)return this.index.get(e).import(a);if(c){typeof c==="string"&&(c=JSON.parse(c));if(e)return this.index.get(e).import(b,c);switch(b){case "reg":this.fastupdate=!1;this.reg=qb(c,this.reg);for(let d=0,f;d=0&&d.splice(g,1)}}else tb(this.map,a),this.depth&&tb(this.ctx,a);c||this.reg.delete(a)}this.db&&(this.commit_task.push({del:a}),this.M&&ub(this));this.cache&&this.cache.remove(a);return this};
-function tb(a,c){let b=0;var e=typeof c==="undefined";if(a.constructor===Array)for(let d=0,f,g,k;d=0){if(f.length>1)return f.splice(g,1),1;delete a[d];if(b)return 1;k=1}else{if(k)return 1;b++}}}else for(let d of a.entries())e=d[0],tb(d[1],c)?b++:a.delete(e);return b};const vb={memory:{resolution:1},performance:{resolution:3,fastupdate:!0,context:{depth:1,resolution:1}},match:{tokenize:"forward"},score:{resolution:9,context:{depth:2,resolution:3}}};T.prototype.add=function(a,c,b,e){if(c&&(a||a===0)){if(!e&&!b&&this.reg.has(a))return this.update(a,c);e=this.depth;c=this.encoder.encode(c,!e);const l=c.length;if(l){const m=I(),p=I(),u=this.resolution;for(let r=0;r2){for(let n=1,q,x,v,A;n=0){if(f.length>1)return f.splice(g,1),1;delete a[d];if(b)return 1;k=1}else{if(k)return 1;b++}}}else for(let d of a.entries())e=d[0],tb(d[1],c)?b++:a.delete(e);return b};const vb={memory:{resolution:1},performance:{resolution:3,fastupdate:!0,context:{depth:1,resolution:1}},match:{tokenize:"full"},score:{resolution:9,context:{depth:2,resolution:3}}};T.prototype.add=function(a,c,b,e){if(c&&(a||a===0)){if(!e&&!b&&this.reg.has(a))return this.update(a,c);e=this.depth;c=this.encoder.encode(c,!e);const l=c.length;if(l){const m=I(),p=I(),u=this.resolution;for(let r=0;r2){for(let n=1,q,x,v,A;n2){for(let n=0,q;nn;f--){g=t.substring(n,f);q=this.rtl?d-1-n:n;var k=this.score?this.score(c,t,r,g,q):wb(u,l,r,d,q);Y(this,p,g,k,a,b)}break}case "bidirectional":case "reverse":if(d>1){for(k=d-1;k>0;k--){g=t[this.rtl?d-1-k:k]+g;var h=this.score?this.score(c,t,r,g,k):wb(u,l,r,d,k);Y(this,p,g,h,a,b)}g=""}case "forward":if(d>1){for(k=0;k1&&rg;const n=this.score?this.score(c,g,r,t,k-1):wb(d+(l/2>d?0:1),l,r,f-1,k-1);Y(this,m,h?g:t,n,a,b,h?t:g)}}}}this.fastupdate||this.reg.add(a)}}this.db&&(this.commit_task.push(b?{ins:a}:{del:a}),this.M&&ub(this));return this};
function Y(a,c,b,e,d,f,g){let k,h;if(!(k=c[b])||g&&!k[g]){g?(c=k||(c[b]=I()),c[g]=1,h=a.ctx,(k=h.get(g))?h=k:h.set(g,h=a.keystore?new R(a.keystore):new Map)):(h=a.map,c[b]=1);(k=h.get(b))?h=k:h.set(b,h=k=[]);if(f)for(let l=0,m;l 1 ? z.join(" ") : z[0];
let y;
- if (z && B) {
- var C = B.length, J = (ea.split ? B.replace(ea.split, "") : B).length - z.length, G = "", L = 0;
+ if (z && C) {
+ var D = C.length, J = (ea.split ? C.replace(ea.split, "") : C).length - z.length, G = "", L = 0;
for (var O = 0; O < n.length; O++) {
var P = n[O];
if (P) {
var M = P.length;
M += J < 0 ? 0 : J;
- L && M <= L || (P = z.indexOf(P), P > -1 && (G = (P ? B.substring(0, P) : "") + g + B.substring(P, P + M) + k + (P + M < C ? B.substring(P + M) : ""), L = M, y = !0));
+ L && M <= L || (P = z.indexOf(P), P > -1 && (G = (P ? C.substring(0, P) : "") + g + C.substring(P, P + M) + k + (P + M < D ? C.substring(P + M) : ""), L = M, y = !0));
}
}
- G && (h && (A < 0 && (A = q.length + (q ? 1 : 0)), D = q.length + (q ? 1 : 0) + G.length, F += C, za.push(v.length), v.push({match:G})), q += (q ? " " : "") + G);
+ G && (h && (A < 0 && (A = q.length + (q ? 1 : 0)), E = q.length + (q ? 1 : 0) + G.length, F += D, za.push(v.length), v.push({match:G})), q += (q ? " " : "") + G);
}
if (!y) {
- B = x[E], q += (q ? " " : "") + B, h && v.push({text:B});
+ C = x[B], q += (q ? " " : "") + C, h && v.push({text:C});
} else if (h && F >= h) {
break;
}
}
F = za.length * (f.length - 2);
if (r || t || h && q.length - F > h) {
- if (F = h + F - u * 2, E = D - A, r > 0 && (E += r), t > 0 && (E += t), E <= F) {
- x = r ? A - (r > 0 ? r : 0) : A - ((F - E) / 2 | 0), v = t ? D + (t > 0 ? t : 0) : x + F, l || (x > 0 && q.charAt(x) !== " " && q.charAt(x - 1) !== " " && (x = q.indexOf(" ", x), x < 0 && (x = 0)), v < q.length && q.charAt(v - 1) !== " " && q.charAt(v) !== " " && (v = q.lastIndexOf(" ", v), v < D ? v = D : ++v)), q = (x ? d : "") + q.substring(x, v) + (v < q.length ? d : "");
+ if (F = h + F - u * 2, B = E - A, r > 0 && (B += r), t > 0 && (B += t), B <= F) {
+ x = r ? A - (r > 0 ? r : 0) : A - ((F - B) / 2 | 0), v = t ? E + (t > 0 ? t : 0) : x + F, l || (x > 0 && q.charAt(x) !== " " && q.charAt(x - 1) !== " " && (x = q.indexOf(" ", x), x < 0 && (x = 0)), v < q.length && q.charAt(v - 1) !== " " && q.charAt(v) !== " " && (v = q.lastIndexOf(" ", v), v < E ? v = E : ++v)), q = (x ? d : "") + q.substring(x, v) + (v < q.length ? d : "");
} else {
- D = [];
+ E = [];
A = {};
F = {};
- E = {};
B = {};
+ C = {};
z = {};
- G = J = C = 0;
+ G = J = D = 0;
for (O = L = 1;;) {
var U = void 0;
for (let y = 0, K; y < za.length; y++) {
K = za[y];
if (G) {
if (J !== G) {
- if (E[y + 1]) {
+ if (B[y + 1]) {
continue;
}
K += G;
if (A[K]) {
- C -= u;
+ D -= u;
F[y + 1] = 1;
- E[y + 1] = 1;
+ B[y + 1] = 1;
continue;
}
if (K >= v.length - 1) {
if (K >= v.length) {
- E[y + 1] = 1;
+ B[y + 1] = 1;
K >= x.length && (F[y + 1] = 1);
continue;
}
- C -= u;
+ D -= u;
}
q = v[K].text;
if (M = t && z[y]) {
if (M > 0) {
if (q.length > M) {
- if (E[y + 1] = 1, l) {
+ if (B[y + 1] = 1, l) {
q = q.substring(0, M);
} else {
continue;
@@ -1209,81 +1210,81 @@ function bb(a, c, b, e, d, f, g) {
(M -= q.length) || (M = -1);
z[y] = M;
} else {
- E[y + 1] = 1;
+ B[y + 1] = 1;
continue;
}
}
- if (C + q.length + 1 <= h) {
- q = " " + q, D[y] += q;
+ if (D + q.length + 1 <= h) {
+ q = " " + q, E[y] += q;
} else if (l) {
- U = h - C - 1, U > 0 && (q = " " + q.substring(0, U), D[y] += q), E[y + 1] = 1;
+ U = h - D - 1, U > 0 && (q = " " + q.substring(0, U), E[y] += q), B[y + 1] = 1;
} else {
- E[y + 1] = 1;
+ B[y + 1] = 1;
continue;
}
} else {
- if (E[y]) {
+ if (B[y]) {
continue;
}
K -= J;
if (A[K]) {
- C -= u;
- E[y] = 1;
+ D -= u;
+ B[y] = 1;
F[y] = 1;
continue;
}
if (K <= 0) {
if (K < 0) {
- E[y] = 1;
+ B[y] = 1;
F[y] = 1;
continue;
}
- C -= u;
+ D -= u;
}
q = v[K].text;
- if (M = r && B[y]) {
+ if (M = r && C[y]) {
if (M > 0) {
if (q.length > M) {
- if (E[y] = 1, l) {
+ if (B[y] = 1, l) {
q = q.substring(q.length - M);
} else {
continue;
}
}
(M -= q.length) || (M = -1);
- B[y] = M;
+ C[y] = M;
} else {
- E[y] = 1;
+ B[y] = 1;
continue;
}
}
- if (C + q.length + 1 <= h) {
- q += " ", D[y] = q + D[y];
+ if (D + q.length + 1 <= h) {
+ q += " ", E[y] = q + E[y];
} else if (l) {
- U = q.length + 1 - (h - C), U >= 0 && U < q.length && (q = q.substring(U) + " ", D[y] = q + D[y]), E[y] = 1;
+ U = q.length + 1 - (h - D), U >= 0 && U < q.length && (q = q.substring(U) + " ", E[y] = q + E[y]), B[y] = 1;
} else {
- E[y] = 1;
+ B[y] = 1;
continue;
}
}
} else {
q = v[K].match;
- r && (B[y] = r);
+ r && (C[y] = r);
t && (z[y] = t);
- y && C++;
+ y && D++;
let Pa;
- K ? !y && u && (C += u) : (F[y] = 1, E[y] = 1);
- K >= x.length - 1 ? Pa = 1 : K < v.length - 1 && v[K + 1].match ? Pa = 1 : u && (C += u);
- C -= f.length - 2;
- if (!y || C + q.length <= h) {
- D[y] = q;
+ K ? !y && u && (D += u) : (F[y] = 1, B[y] = 1);
+ K >= x.length - 1 ? Pa = 1 : K < v.length - 1 && v[K + 1].match ? Pa = 1 : u && (D += u);
+ D -= f.length - 2;
+ if (!y || D + q.length <= h) {
+ E[y] = q;
} else {
U = L = O = F[y] = 0;
break;
}
- Pa && (F[y + 1] = 1, E[y + 1] = 1);
+ Pa && (F[y + 1] = 1, B[y + 1] = 1);
}
- C += q.length;
+ D += q.length;
U = A[K] = 1;
}
if (U) {
@@ -1297,10 +1298,10 @@ function bb(a, c, b, e, d, f, g) {
}
}
q = "";
- for (let y = 0, K; y < D.length; y++) {
- K = (F[y] ? y ? " " : "" : (y && !d ? " " : "") + d) + D[y], q += K;
+ for (let y = 0, K; y < E.length; y++) {
+ K = (F[y] ? y ? " " : "" : (y && !d ? " " : "") + d) + E[y], q += K;
}
- d && !F[D.length] && (q += d);
+ d && !F[E.length] && (q += d);
}
}
m && (q = q.replace(m, " "));
@@ -1327,9 +1328,11 @@ function bb(a, c, b, e, d, f, g) {
const m = l.resolve;
a = l.async || l.queue;
l.resolve = !1;
+ l.highlight = "";
l.index = null;
a = a ? c.searchAsync(l) : c.search(l);
l.resolve = m;
+ l.highlight = g;
l.index = c;
a = a.result || a;
} else {
@@ -1625,26 +1628,26 @@ Na.prototype.search = function(a, c, b, e) {
if (n && (!this.db || !e)) {
n.constructor !== Array && (n = [n]);
var v = [];
- for (let B = 0, z; B < n.length; B++) {
- z = n[B];
+ for (let C = 0, z; C < n.length; C++) {
+ z = n[C];
if (N(z)) {
throw Error("A tag option can't be a string, instead it needs a { field: tag } format.");
}
if (z.field && z.tag) {
var A = z.tag;
if (A.constructor === Array) {
- for (var D = 0; D < A.length; D++) {
- v.push(z.field, A[D]);
+ for (var E = 0; E < A.length; E++) {
+ v.push(z.field, A[E]);
}
} else {
v.push(z.field, A);
}
} else {
A = Object.keys(z);
- for (let C = 0, J, G; C < A.length; C++) {
- if (J = A[C], G = z[J], G.constructor === Array) {
- for (D = 0; D < G.length; D++) {
- v.push(J, G[D]);
+ for (let D = 0, J, G; D < A.length; D++) {
+ if (J = A[D], G = z[J], G.constructor === Array) {
+ for (E = 0; E < G.length; E++) {
+ v.push(J, G[E]);
}
} else {
v.push(J, G);
@@ -1674,12 +1677,12 @@ Na.prototype.search = function(a, c, b, e) {
}
}
if (f.length) {
- const B = this;
+ const C = this;
return Promise.all(f).then(function(z) {
- for (let C = 0; C < z.length; C++) {
- r ? d[C].result = z[C] : d[C] = z[C];
+ for (let D = 0; D < z.length; D++) {
+ r ? d[D].result = z[D] : d[D] = z[D];
}
- return r ? d : new X(d.length > 1 ? $a(d, 1, 0, 0, h, l) : d[0], B);
+ return r ? d : new X(d.length > 1 ? $a(d, 1, 0, 0, h, l) : d[0], C);
});
}
return r ? d : new X(d.length > 1 ? $a(d, 1, 0, 0, h, l) : d[0], this);
@@ -1698,38 +1701,38 @@ Na.prototype.search = function(a, c, b, e) {
p || (p = this.field);
let F;
v = (this.worker || this.db) && !e && [];
- for (let B = 0, z, C, J; B < p.length; B++) {
- C = p[B];
- if (this.db && this.tag && !this.B[B]) {
+ for (let C = 0, z, D, J; C < p.length; C++) {
+ D = p[C];
+ if (this.db && this.tag && !this.B[C]) {
continue;
}
let G;
- N(C) || (G = C, C = G.field, a = G.query || a, c = aa(G.limit, c), x = aa(G.offset, x), h = aa(G.suggest, h), t = r && this.store && aa(G.highlight, t), q = !!t || r && this.store && aa(G.enrich, q), m = aa(G.cache, m));
+ N(D) || (G = D, D = G.field, a = G.query || a, c = aa(G.limit, c), x = aa(G.offset, x), h = aa(G.suggest, h), t = r && this.store && aa(G.highlight, t), q = !!t || r && this.store && aa(G.enrich, q), m = aa(G.cache, m));
if (e) {
- z = e[B];
+ z = e[C];
} else {
A = G || b || {};
- D = A.enrich;
- var E = this.index.get(C);
- n && (this.db && (A.tag = n, A.field = p, F = E.db.support_tag_search), !F && D && (A.enrich = !1), F || (A.limit = 0, A.offset = 0));
- z = m ? E.searchCache(a, n && !F ? 0 : c, A) : E.search(a, n && !F ? 0 : c, A);
+ E = A.enrich;
+ var B = this.index.get(D);
+ n && (this.db && (A.tag = n, A.field = p, F = B.db.support_tag_search), !F && E && (A.enrich = !1), F || (A.limit = 0, A.offset = 0));
+ z = m ? B.searchCache(a, n && !F ? 0 : c, A) : B.search(a, n && !F ? 0 : c, A);
n && !F && (A.limit = c, A.offset = x);
- D && (A.enrich = D);
+ E && (A.enrich = E);
if (v) {
- v[B] = z;
+ v[C] = z;
continue;
}
}
J = (z = z.result || z) && z.length;
if (n && J) {
A = [];
- D = 0;
+ E = 0;
if (this.db && e) {
if (!F) {
- for (E = p.length; E < e.length; E++) {
- let L = e[E];
+ for (B = p.length; B < e.length; B++) {
+ let L = e[B];
if (L && L.length) {
- D++, A.push(L);
+ E++, A.push(L);
} else if (!h) {
return r ? d : new X(d, this);
}
@@ -1746,23 +1749,23 @@ Na.prototype.search = function(a, c, b, e) {
}
}
if (P = (O = O && O.get(n[L + 1])) && O.length) {
- D++, A.push(O);
+ E++, A.push(O);
} else if (!h) {
return r ? d : new X(d, this);
}
}
}
- if (D) {
+ if (E) {
z = eb(z, A, c, x, r);
J = z.length;
if (!J && !h) {
return r ? z : new X(z, this);
}
- D--;
+ E--;
}
}
if (J) {
- f[u] = C, d.push(z), u++;
+ f[u] = D, d.push(z), u++;
} else if (p.length === 1) {
return r ? d : new X(d, this);
}
@@ -1781,10 +1784,10 @@ Na.prototype.search = function(a, c, b, e) {
v.push(f.db.tag(n[q + 1], c, x, !1));
}
}
- const B = this;
+ const C = this;
return Promise.all(v).then(function(z) {
b && (b.resolve = r);
- z.length && (z = B.search(a, c, b, z));
+ z.length && (z = C.search(a, c, b, z));
return z;
});
}
@@ -1804,12 +1807,12 @@ Na.prototype.search = function(a, c, b, e) {
d[x] = {field:f[x], result:n};
}
if (q && this.db && v.length) {
- const B = this;
+ const C = this;
return Promise.all(v).then(function(z) {
- for (let C = 0; C < z.length; C++) {
- d[C].result = z[C];
+ for (let D = 0; D < z.length; D++) {
+ d[D].result = z[D];
}
- t && (d = cb(a, d, B.index, g, t));
+ t && (d = cb(a, d, C.index, g, t));
return k ? gb(d) : d;
});
}
@@ -2276,7 +2279,7 @@ function tb(a, c) {
}
return b;
}
-;const vb = {memory:{resolution:1}, performance:{resolution:3, fastupdate:!0, context:{depth:1, resolution:1}}, match:{tokenize:"forward"}, score:{resolution:9, context:{depth:2, resolution:3}}};
+;const vb = {memory:{resolution:1}, performance:{resolution:3, fastupdate:!0, context:{depth:1, resolution:1}}, match:{tokenize:"full"}, score:{resolution:9, context:{depth:2, resolution:3}}};
T.prototype.add = function(a, c, b, e) {
if (c && (a || a === 0)) {
if (!e && !b && this.reg.has(a)) {
diff --git a/dist/flexsearch.bundle.module.debug.mjs b/dist/flexsearch.bundle.module.debug.mjs
index 6c45c11..3ea9c3b 100644
--- a/dist/flexsearch.bundle.module.debug.mjs
+++ b/dist/flexsearch.bundle.module.debug.mjs
@@ -1,5 +1,5 @@
/**!
- * FlexSearch.js v0.8.213 (Bundle/Module/Debug)
+ * FlexSearch.js v0.8.214 (Bundle/Module/Debug)
* Author and Copyright: Thomas Wilkerling
* Licence: Apache-2.0
* Hosted by Nextapps GmbH
@@ -856,31 +856,32 @@ function Qa(a, c, b, e, d, f, g, k) {
if (r && (u || a.await)) {
u = 1;
let v;
- const A = a.C.length, D = new Promise(function(F) {
+ const A = a.C.length, E = new Promise(function(F) {
v = F;
});
- (function(F, E) {
- D.h = function() {
- E.index = null;
- E.resolve = !1;
- let B = t ? F.searchAsync(E) : F.search(E);
- if (B.then) {
- return B.then(function(z) {
+ (function(F, B) {
+ E.h = function() {
+ B.index = null;
+ B.resolve = !1;
+ B.enrich = !1;
+ let C = t ? F.searchAsync(B) : F.search(B);
+ if (C.then) {
+ return C.then(function(z) {
a.C[A] = z = z.result || z;
v(z);
return z;
});
}
- B = B.result || B;
- v(B);
- return B;
+ C = C.result || C;
+ v(C);
+ return C;
};
})(n, Object.assign({}, d));
- a.C.push(D);
- f[c] = D;
+ a.C.push(E);
+ f[c] = E;
continue;
} else {
- d.resolve = !1, d.index = null, r = t ? n.searchAsync(d) : n.search(d), d.resolve = l, d.index = n;
+ d.resolve = !1, d.enrich = !1, d.index = null, r = t ? n.searchAsync(d) : n.search(d), d.resolve = l, d.enrich = h, d.index = n;
}
} else if (d.and) {
r = Va(d, "and", n);
@@ -1137,70 +1138,70 @@ function bb(a, c, b, e, d, f, g) {
q = "";
var v = [];
let za = [];
- var A = -1, D = -1, F = 0;
- for (var E = 0; E < x.length; E++) {
- var B = x[E], z = ea.encode(B);
+ var A = -1, E = -1, F = 0;
+ for (var B = 0; B < x.length; B++) {
+ var C = x[B], z = ea.encode(C);
z = z.length > 1 ? z.join(" ") : z[0];
let y;
- if (z && B) {
- var C = B.length, J = (ea.split ? B.replace(ea.split, "") : B).length - z.length, G = "", L = 0;
+ if (z && C) {
+ var D = C.length, J = (ea.split ? C.replace(ea.split, "") : C).length - z.length, G = "", L = 0;
for (var O = 0; O < n.length; O++) {
var P = n[O];
if (P) {
var M = P.length;
M += J < 0 ? 0 : J;
- L && M <= L || (P = z.indexOf(P), P > -1 && (G = (P ? B.substring(0, P) : "") + g + B.substring(P, P + M) + k + (P + M < C ? B.substring(P + M) : ""), L = M, y = !0));
+ L && M <= L || (P = z.indexOf(P), P > -1 && (G = (P ? C.substring(0, P) : "") + g + C.substring(P, P + M) + k + (P + M < D ? C.substring(P + M) : ""), L = M, y = !0));
}
}
- G && (h && (A < 0 && (A = q.length + (q ? 1 : 0)), D = q.length + (q ? 1 : 0) + G.length, F += C, za.push(v.length), v.push({match:G})), q += (q ? " " : "") + G);
+ G && (h && (A < 0 && (A = q.length + (q ? 1 : 0)), E = q.length + (q ? 1 : 0) + G.length, F += D, za.push(v.length), v.push({match:G})), q += (q ? " " : "") + G);
}
if (!y) {
- B = x[E], q += (q ? " " : "") + B, h && v.push({text:B});
+ C = x[B], q += (q ? " " : "") + C, h && v.push({text:C});
} else if (h && F >= h) {
break;
}
}
F = za.length * (f.length - 2);
if (r || t || h && q.length - F > h) {
- if (F = h + F - u * 2, E = D - A, r > 0 && (E += r), t > 0 && (E += t), E <= F) {
- x = r ? A - (r > 0 ? r : 0) : A - ((F - E) / 2 | 0), v = t ? D + (t > 0 ? t : 0) : x + F, l || (x > 0 && q.charAt(x) !== " " && q.charAt(x - 1) !== " " && (x = q.indexOf(" ", x), x < 0 && (x = 0)), v < q.length && q.charAt(v - 1) !== " " && q.charAt(v) !== " " && (v = q.lastIndexOf(" ", v), v < D ? v = D : ++v)), q = (x ? d : "") + q.substring(x, v) + (v < q.length ? d : "");
+ if (F = h + F - u * 2, B = E - A, r > 0 && (B += r), t > 0 && (B += t), B <= F) {
+ x = r ? A - (r > 0 ? r : 0) : A - ((F - B) / 2 | 0), v = t ? E + (t > 0 ? t : 0) : x + F, l || (x > 0 && q.charAt(x) !== " " && q.charAt(x - 1) !== " " && (x = q.indexOf(" ", x), x < 0 && (x = 0)), v < q.length && q.charAt(v - 1) !== " " && q.charAt(v) !== " " && (v = q.lastIndexOf(" ", v), v < E ? v = E : ++v)), q = (x ? d : "") + q.substring(x, v) + (v < q.length ? d : "");
} else {
- D = [];
+ E = [];
A = {};
F = {};
- E = {};
B = {};
+ C = {};
z = {};
- G = J = C = 0;
+ G = J = D = 0;
for (O = L = 1;;) {
var U = void 0;
for (let y = 0, K; y < za.length; y++) {
K = za[y];
if (G) {
if (J !== G) {
- if (E[y + 1]) {
+ if (B[y + 1]) {
continue;
}
K += G;
if (A[K]) {
- C -= u;
+ D -= u;
F[y + 1] = 1;
- E[y + 1] = 1;
+ B[y + 1] = 1;
continue;
}
if (K >= v.length - 1) {
if (K >= v.length) {
- E[y + 1] = 1;
+ B[y + 1] = 1;
K >= x.length && (F[y + 1] = 1);
continue;
}
- C -= u;
+ D -= u;
}
q = v[K].text;
if (M = t && z[y]) {
if (M > 0) {
if (q.length > M) {
- if (E[y + 1] = 1, l) {
+ if (B[y + 1] = 1, l) {
q = q.substring(0, M);
} else {
continue;
@@ -1209,81 +1210,81 @@ function bb(a, c, b, e, d, f, g) {
(M -= q.length) || (M = -1);
z[y] = M;
} else {
- E[y + 1] = 1;
+ B[y + 1] = 1;
continue;
}
}
- if (C + q.length + 1 <= h) {
- q = " " + q, D[y] += q;
+ if (D + q.length + 1 <= h) {
+ q = " " + q, E[y] += q;
} else if (l) {
- U = h - C - 1, U > 0 && (q = " " + q.substring(0, U), D[y] += q), E[y + 1] = 1;
+ U = h - D - 1, U > 0 && (q = " " + q.substring(0, U), E[y] += q), B[y + 1] = 1;
} else {
- E[y + 1] = 1;
+ B[y + 1] = 1;
continue;
}
} else {
- if (E[y]) {
+ if (B[y]) {
continue;
}
K -= J;
if (A[K]) {
- C -= u;
- E[y] = 1;
+ D -= u;
+ B[y] = 1;
F[y] = 1;
continue;
}
if (K <= 0) {
if (K < 0) {
- E[y] = 1;
+ B[y] = 1;
F[y] = 1;
continue;
}
- C -= u;
+ D -= u;
}
q = v[K].text;
- if (M = r && B[y]) {
+ if (M = r && C[y]) {
if (M > 0) {
if (q.length > M) {
- if (E[y] = 1, l) {
+ if (B[y] = 1, l) {
q = q.substring(q.length - M);
} else {
continue;
}
}
(M -= q.length) || (M = -1);
- B[y] = M;
+ C[y] = M;
} else {
- E[y] = 1;
+ B[y] = 1;
continue;
}
}
- if (C + q.length + 1 <= h) {
- q += " ", D[y] = q + D[y];
+ if (D + q.length + 1 <= h) {
+ q += " ", E[y] = q + E[y];
} else if (l) {
- U = q.length + 1 - (h - C), U >= 0 && U < q.length && (q = q.substring(U) + " ", D[y] = q + D[y]), E[y] = 1;
+ U = q.length + 1 - (h - D), U >= 0 && U < q.length && (q = q.substring(U) + " ", E[y] = q + E[y]), B[y] = 1;
} else {
- E[y] = 1;
+ B[y] = 1;
continue;
}
}
} else {
q = v[K].match;
- r && (B[y] = r);
+ r && (C[y] = r);
t && (z[y] = t);
- y && C++;
+ y && D++;
let Pa;
- K ? !y && u && (C += u) : (F[y] = 1, E[y] = 1);
- K >= x.length - 1 ? Pa = 1 : K < v.length - 1 && v[K + 1].match ? Pa = 1 : u && (C += u);
- C -= f.length - 2;
- if (!y || C + q.length <= h) {
- D[y] = q;
+ K ? !y && u && (D += u) : (F[y] = 1, B[y] = 1);
+ K >= x.length - 1 ? Pa = 1 : K < v.length - 1 && v[K + 1].match ? Pa = 1 : u && (D += u);
+ D -= f.length - 2;
+ if (!y || D + q.length <= h) {
+ E[y] = q;
} else {
U = L = O = F[y] = 0;
break;
}
- Pa && (F[y + 1] = 1, E[y + 1] = 1);
+ Pa && (F[y + 1] = 1, B[y + 1] = 1);
}
- C += q.length;
+ D += q.length;
U = A[K] = 1;
}
if (U) {
@@ -1297,10 +1298,10 @@ function bb(a, c, b, e, d, f, g) {
}
}
q = "";
- for (let y = 0, K; y < D.length; y++) {
- K = (F[y] ? y ? " " : "" : (y && !d ? " " : "") + d) + D[y], q += K;
+ for (let y = 0, K; y < E.length; y++) {
+ K = (F[y] ? y ? " " : "" : (y && !d ? " " : "") + d) + E[y], q += K;
}
- d && !F[D.length] && (q += d);
+ d && !F[E.length] && (q += d);
}
}
m && (q = q.replace(m, " "));
@@ -1327,9 +1328,11 @@ function bb(a, c, b, e, d, f, g) {
const m = l.resolve;
a = l.async || l.queue;
l.resolve = !1;
+ l.highlight = "";
l.index = null;
a = a ? c.searchAsync(l) : c.search(l);
l.resolve = m;
+ l.highlight = g;
l.index = c;
a = a.result || a;
} else {
@@ -1625,26 +1628,26 @@ Na.prototype.search = function(a, c, b, e) {
if (n && (!this.db || !e)) {
n.constructor !== Array && (n = [n]);
var v = [];
- for (let B = 0, z; B < n.length; B++) {
- z = n[B];
+ for (let C = 0, z; C < n.length; C++) {
+ z = n[C];
if (N(z)) {
throw Error("A tag option can't be a string, instead it needs a { field: tag } format.");
}
if (z.field && z.tag) {
var A = z.tag;
if (A.constructor === Array) {
- for (var D = 0; D < A.length; D++) {
- v.push(z.field, A[D]);
+ for (var E = 0; E < A.length; E++) {
+ v.push(z.field, A[E]);
}
} else {
v.push(z.field, A);
}
} else {
A = Object.keys(z);
- for (let C = 0, J, G; C < A.length; C++) {
- if (J = A[C], G = z[J], G.constructor === Array) {
- for (D = 0; D < G.length; D++) {
- v.push(J, G[D]);
+ for (let D = 0, J, G; D < A.length; D++) {
+ if (J = A[D], G = z[J], G.constructor === Array) {
+ for (E = 0; E < G.length; E++) {
+ v.push(J, G[E]);
}
} else {
v.push(J, G);
@@ -1674,12 +1677,12 @@ Na.prototype.search = function(a, c, b, e) {
}
}
if (f.length) {
- const B = this;
+ const C = this;
return Promise.all(f).then(function(z) {
- for (let C = 0; C < z.length; C++) {
- r ? d[C].result = z[C] : d[C] = z[C];
+ for (let D = 0; D < z.length; D++) {
+ r ? d[D].result = z[D] : d[D] = z[D];
}
- return r ? d : new X(d.length > 1 ? $a(d, 1, 0, 0, h, l) : d[0], B);
+ return r ? d : new X(d.length > 1 ? $a(d, 1, 0, 0, h, l) : d[0], C);
});
}
return r ? d : new X(d.length > 1 ? $a(d, 1, 0, 0, h, l) : d[0], this);
@@ -1698,38 +1701,38 @@ Na.prototype.search = function(a, c, b, e) {
p || (p = this.field);
let F;
v = (this.worker || this.db) && !e && [];
- for (let B = 0, z, C, J; B < p.length; B++) {
- C = p[B];
- if (this.db && this.tag && !this.B[B]) {
+ for (let C = 0, z, D, J; C < p.length; C++) {
+ D = p[C];
+ if (this.db && this.tag && !this.B[C]) {
continue;
}
let G;
- N(C) || (G = C, C = G.field, a = G.query || a, c = aa(G.limit, c), x = aa(G.offset, x), h = aa(G.suggest, h), t = r && this.store && aa(G.highlight, t), q = !!t || r && this.store && aa(G.enrich, q), m = aa(G.cache, m));
+ N(D) || (G = D, D = G.field, a = G.query || a, c = aa(G.limit, c), x = aa(G.offset, x), h = aa(G.suggest, h), t = r && this.store && aa(G.highlight, t), q = !!t || r && this.store && aa(G.enrich, q), m = aa(G.cache, m));
if (e) {
- z = e[B];
+ z = e[C];
} else {
A = G || b || {};
- D = A.enrich;
- var E = this.index.get(C);
- n && (this.db && (A.tag = n, A.field = p, F = E.db.support_tag_search), !F && D && (A.enrich = !1), F || (A.limit = 0, A.offset = 0));
- z = m ? E.searchCache(a, n && !F ? 0 : c, A) : E.search(a, n && !F ? 0 : c, A);
+ E = A.enrich;
+ var B = this.index.get(D);
+ n && (this.db && (A.tag = n, A.field = p, F = B.db.support_tag_search), !F && E && (A.enrich = !1), F || (A.limit = 0, A.offset = 0));
+ z = m ? B.searchCache(a, n && !F ? 0 : c, A) : B.search(a, n && !F ? 0 : c, A);
n && !F && (A.limit = c, A.offset = x);
- D && (A.enrich = D);
+ E && (A.enrich = E);
if (v) {
- v[B] = z;
+ v[C] = z;
continue;
}
}
J = (z = z.result || z) && z.length;
if (n && J) {
A = [];
- D = 0;
+ E = 0;
if (this.db && e) {
if (!F) {
- for (E = p.length; E < e.length; E++) {
- let L = e[E];
+ for (B = p.length; B < e.length; B++) {
+ let L = e[B];
if (L && L.length) {
- D++, A.push(L);
+ E++, A.push(L);
} else if (!h) {
return r ? d : new X(d, this);
}
@@ -1746,23 +1749,23 @@ Na.prototype.search = function(a, c, b, e) {
}
}
if (P = (O = O && O.get(n[L + 1])) && O.length) {
- D++, A.push(O);
+ E++, A.push(O);
} else if (!h) {
return r ? d : new X(d, this);
}
}
}
- if (D) {
+ if (E) {
z = eb(z, A, c, x, r);
J = z.length;
if (!J && !h) {
return r ? z : new X(z, this);
}
- D--;
+ E--;
}
}
if (J) {
- f[u] = C, d.push(z), u++;
+ f[u] = D, d.push(z), u++;
} else if (p.length === 1) {
return r ? d : new X(d, this);
}
@@ -1781,10 +1784,10 @@ Na.prototype.search = function(a, c, b, e) {
v.push(f.db.tag(n[q + 1], c, x, !1));
}
}
- const B = this;
+ const C = this;
return Promise.all(v).then(function(z) {
b && (b.resolve = r);
- z.length && (z = B.search(a, c, b, z));
+ z.length && (z = C.search(a, c, b, z));
return z;
});
}
@@ -1804,12 +1807,12 @@ Na.prototype.search = function(a, c, b, e) {
d[x] = {field:f[x], result:n};
}
if (q && this.db && v.length) {
- const B = this;
+ const C = this;
return Promise.all(v).then(function(z) {
- for (let C = 0; C < z.length; C++) {
- d[C].result = z[C];
+ for (let D = 0; D < z.length; D++) {
+ d[D].result = z[D];
}
- t && (d = cb(a, d, B.index, g, t));
+ t && (d = cb(a, d, C.index, g, t));
return k ? gb(d) : d;
});
}
@@ -2276,7 +2279,7 @@ function tb(a, c) {
}
return b;
}
-;const vb = {memory:{resolution:1}, performance:{resolution:3, fastupdate:!0, context:{depth:1, resolution:1}}, match:{tokenize:"forward"}, score:{resolution:9, context:{depth:2, resolution:3}}};
+;const vb = {memory:{resolution:1}, performance:{resolution:3, fastupdate:!0, context:{depth:1, resolution:1}}, match:{tokenize:"full"}, score:{resolution:9, context:{depth:2, resolution:3}}};
T.prototype.add = function(a, c, b, e) {
if (c && (a || a === 0)) {
if (!e && !b && this.reg.has(a)) {
diff --git a/dist/flexsearch.bundle.module.min.js b/dist/flexsearch.bundle.module.min.js
index a5cb7c4..1ee5bca 100644
--- a/dist/flexsearch.bundle.module.min.js
+++ b/dist/flexsearch.bundle.module.min.js
@@ -1,5 +1,5 @@
/**!
- * FlexSearch.js v0.8.213 (Bundle/Module)
+ * FlexSearch.js v0.8.214 (Bundle/Module)
* Author and Copyright: Thomas Wilkerling
* Licence: Apache-2.0
* Hosted by Nextapps GmbH
@@ -35,32 +35,32 @@ function Ma(a,c,b){return c?typeof module!=="undefined"?new(require("worker_thre
f.G;if(g&&!g(c))continue;f.constructor===String&&(f=""+f);f=ca(c,f)}if(d&&f){M(f)&&(f=[f]);for(let h=0,l,m;hc?a.slice(b,b+c):a,e?Ta.call(this,a):a;let d=[];for(let f=0,g,k;f=k){b-=k;continue}g=g.slice(b,b+c);k=g.length;b=0}k>c&&(g=g.slice(0,c),k=c);if(!d.length&&k>=c)return e?Ta.call(this,g):g;d.push(g);c-=k;if(!c)break}d=d.length>1?[].concat.apply([],d):d[0];return e?Ta.call(this,d):d};function Ua(a,c,b,e){var d=e[0];if(d[0]&&d[0].query)return a[c].apply(a,d);if(!(c!=="and"&&c!=="not"||a.result.length||a.await||d.suggest))return e.length>1&&(d=e[e.length-1]),(e=d.resolve)?a.await||a.result:a;let f=[],g=0,k=0,h,l,m,p,u;for(c=0;c1&&(b=b[c].apply(b,a.slice(1)));return b};X.prototype.or=function(){return Ua(this,"or",Xa,arguments)};function Xa(a,c,b,e,d,f,g){a.length&&(this.result.length&&a.push(this.result),a.length<2?this.result=a[0]:(this.result=Ya(a,c,b,!1,this.h),b=0));d&&(this.await=null);return d?this.resolve(c,b,e,g):this};X.prototype.and=function(){return Ua(this,"and",Za,arguments)};function Za(a,c,b,e,d,f,g){if(!f&&!this.result.length)return d?this.result:this;let k;if(a.length)if(this.result.length&&a.unshift(this.result),a.length<2)this.result=a[0];else{let h=0;for(let l=0,m,p;l1&&(b=b[c].apply(b,a.slice(1)));return b};X.prototype.or=function(){return Ua(this,"or",Xa,arguments)};function Xa(a,c,b,e,d,f,g){a.length&&(this.result.length&&a.push(this.result),a.length<2?this.result=a[0]:(this.result=Ya(a,c,b,!1,this.h),b=0));d&&(this.await=null);return d?this.resolve(c,b,e,g):this};X.prototype.and=function(){return Ua(this,"and",Za,arguments)};function Za(a,c,b,e,d,f,g){if(!f&&!this.result.length)return d?this.result:this;let k;if(a.length)if(this.result.length&&a.unshift(this.result),a.length<2)this.result=a[0];else{let h=0;for(let l=0,m,p;l1?z.join(" "):z[0];let y;if(z&&B){var C=B.length,J=(da.split?
-B.replace(da.split,""):B).length-z.length,G="",N=0;for(var O=0;O-1&&(G=(P?B.substring(0,P):"")+g+B.substring(P,P+L)+k+(P+L=h)break}F=za.length*(f.length-2);if(r||t||h&&q.length-F>h)if(F=h+F-u*2,E=D-
-A,r>0&&(E+=r),t>0&&(E+=t),E<=F)x=r?A-(r>0?r:0):A-((F-E)/2|0),v=t?D+(t>0?t:0):x+F,l||(x>0&&q.charAt(x)!==" "&&q.charAt(x-1)!==" "&&(x=q.indexOf(" ",x),x<0&&(x=0)),v=v.length-
-1){if(K>=v.length){E[y+1]=1;K>=x.length&&(F[y+1]=1);continue}C-=u}q=v[K].text;if(L=t&&z[y])if(L>0){if(q.length>L)if(E[y+1]=1,l)q=q.substring(0,L);else continue;(L-=q.length)||(L=-1);z[y]=L}else{E[y+1]=1;continue}if(C+q.length+1<=h)q=" "+q,D[y]+=q;else if(l)U=h-C-1,U>0&&(q=" "+q.substring(0,U),D[y]+=q),E[y+1]=1;else{E[y+1]=1;continue}}else{if(E[y])continue;K-=J;if(A[K]){C-=u;E[y]=1;F[y]=1;continue}if(K<=0){if(K<0){E[y]=1;F[y]=1;continue}C-=u}q=v[K].text;if(L=r&&B[y])if(L>0){if(q.length>L)if(E[y]=1,
-l)q=q.substring(q.length-L);else continue;(L-=q.length)||(L=-1);B[y]=L}else{E[y]=1;continue}if(C+q.length+1<=h)q+=" ",D[y]=q+D[y];else if(l)U=q.length+1-(h-C),U>=0&&U=x.length-1?Pa=1:K1?z.join(" "):z[0];let y;if(z&&C){var D=C.length,J=(da.split?
+C.replace(da.split,""):C).length-z.length,G="",N=0;for(var O=0;O-1&&(G=(P?C.substring(0,P):"")+g+C.substring(P,P+L)+k+(P+L=h)break}F=za.length*(f.length-2);if(r||t||h&&q.length-F>h)if(F=h+F-u*2,B=E-
+A,r>0&&(B+=r),t>0&&(B+=t),B<=F)x=r?A-(r>0?r:0):A-((F-B)/2|0),v=t?E+(t>0?t:0):x+F,l||(x>0&&q.charAt(x)!==" "&&q.charAt(x-1)!==" "&&(x=q.indexOf(" ",x),x<0&&(x=0)),v=v.length-
+1){if(K>=v.length){B[y+1]=1;K>=x.length&&(F[y+1]=1);continue}D-=u}q=v[K].text;if(L=t&&z[y])if(L>0){if(q.length>L)if(B[y+1]=1,l)q=q.substring(0,L);else continue;(L-=q.length)||(L=-1);z[y]=L}else{B[y+1]=1;continue}if(D+q.length+1<=h)q=" "+q,E[y]+=q;else if(l)U=h-D-1,U>0&&(q=" "+q.substring(0,U),E[y]+=q),B[y+1]=1;else{B[y+1]=1;continue}}else{if(B[y])continue;K-=J;if(A[K]){D-=u;B[y]=1;F[y]=1;continue}if(K<=0){if(K<0){B[y]=1;F[y]=1;continue}D-=u}q=v[K].text;if(L=r&&C[y])if(L>0){if(q.length>L)if(B[y]=1,
+l)q=q.substring(q.length-L);else continue;(L-=q.length)||(L=-1);C[y]=L}else{B[y]=1;continue}if(D+q.length+1<=h)q+=" ",E[y]=q+E[y];else if(l)U=q.length+1-(h-D),U>=0&&U=x.length-1?Pa=1:K1?Ya(h,b,e,g,f):(h=h[0])&&b&&h.length>b||e?h.slice(e,b+e):h;else{if(ab||e)h=h.slice(e,b+
e)}else{d=[];for(let p=0,u;pe)e-=u.length;else{if(b&&u.length>b||e)u=u.slice(e,b+e),b-=u.length,e&&(e-=u.length);d.push(u);if(!b)break}h=d}}return h}
function Ya(a,c,b,e,d){const f=[],g=I();let k;var h=a.length;let l;if(e)for(d=h-1;d>=0;d--){if(l=(e=a[d])&&e.length)for(h=0;h=0;m--){p=a[m];for(let r=0;r1?$a(d,1,0,0,h,l):d[0],B)})}return r?d:new X(d.length>1?$a(d,1,0,0,h,l):d[0],this)}}r||g||!(p=p||this.field)||(M(p)?g=p:(p.constructor===Array&&p.length===1&&(p=p[0]),g=p.field||p.index));p&&p.constructor!==Array&&(p=[p])}p||(p=this.field);let F;v=(this.worker||this.db)&&!e&&[];for(let B=0,z,C,J;B1?$a(d,1,0,0,h,l):d[0],C)})}return r?d:new X(d.length>1?$a(d,1,0,0,h,l):d[0],this)}}r||g||!(p=p||this.field)||(M(p)?g=p:(p.constructor===Array&&p.length===1&&(p=p[0]),g=p.field||p.index));p&&p.constructor!==Array&&(p=[p])}p||(p=this.field);let F;v=(this.worker||this.db)&&!e&&[];for(let C=0,z,D,J;C0){if(b&&c>b||e)a=a.slice(e,e+b);d&&(a=Ta.call(this,a))}return a}
function Ta(a){if(!this||!this.store)return a;if(this.db)return this.index.get(this.field[0]).db.enrich(a);const c=Array(a.length);for(let b=0,e;b2?b[0]:"";b=b.length>2?b[2]:b[1];if(this.worker&&e)return this.index.get(e).import(a);if(c){typeof c==="string"&&(c=JSON.parse(c));if(e)return this.index.get(e).import(b,c);switch(b){case "reg":this.fastupdate=!1;this.reg=qb(c,this.reg);for(let d=0,f;d=0&&d.splice(g,1)}}else tb(this.map,a),this.depth&&tb(this.ctx,a);c||this.reg.delete(a)}this.db&&(this.commit_task.push({del:a}),this.M&&ub(this));this.cache&&this.cache.remove(a);return this};
-function tb(a,c){let b=0;var e=typeof c==="undefined";if(a.constructor===Array)for(let d=0,f,g,k;d=0){if(f.length>1)return f.splice(g,1),1;delete a[d];if(b)return 1;k=1}else{if(k)return 1;b++}}}else for(let d of a.entries())e=d[0],tb(d[1],c)?b++:a.delete(e);return b};const vb={memory:{resolution:1},performance:{resolution:3,fastupdate:!0,context:{depth:1,resolution:1}},match:{tokenize:"forward"},score:{resolution:9,context:{depth:2,resolution:3}}};T.prototype.add=function(a,c,b,e){if(c&&(a||a===0)){if(!e&&!b&&this.reg.has(a))return this.update(a,c);e=this.depth;c=this.encoder.encode(c,!e);const l=c.length;if(l){const m=I(),p=I(),u=this.resolution;for(let r=0;r2){for(let n=1,q,x,v,A;n=0){if(f.length>1)return f.splice(g,1),1;delete a[d];if(b)return 1;k=1}else{if(k)return 1;b++}}}else for(let d of a.entries())e=d[0],tb(d[1],c)?b++:a.delete(e);return b};const vb={memory:{resolution:1},performance:{resolution:3,fastupdate:!0,context:{depth:1,resolution:1}},match:{tokenize:"full"},score:{resolution:9,context:{depth:2,resolution:3}}};T.prototype.add=function(a,c,b,e){if(c&&(a||a===0)){if(!e&&!b&&this.reg.has(a))return this.update(a,c);e=this.depth;c=this.encoder.encode(c,!e);const l=c.length;if(l){const m=I(),p=I(),u=this.resolution;for(let r=0;r2){for(let n=1,q,x,v,A;n2){for(let n=0,q;nn;f--){g=t.substring(n,f);q=this.rtl?d-1-n:n;var k=this.score?this.score(c,t,r,g,q):wb(u,l,r,d,q);Y(this,p,g,k,a,b)}break}case "bidirectional":case "reverse":if(d>1){for(k=d-1;k>0;k--){g=t[this.rtl?d-1-k:k]+g;var h=this.score?this.score(c,t,r,g,k):wb(u,l,r,d,k);Y(this,p,g,h,a,b)}g=""}case "forward":if(d>1){for(k=0;k1&&rg;const n=this.score?this.score(c,g,r,t,k-1):wb(d+(l/2>d?0:1),l,r,f-1,k-1);Y(this,m,h?g:t,n,a,b,h?t:g)}}}}this.fastupdate||this.reg.add(a)}}this.db&&(this.commit_task.push(b?{ins:a}:{del:a}),this.M&&ub(this));return this};
function Y(a,c,b,e,d,f,g){let k,h;if(!(k=c[b])||g&&!k[g]){g?(c=k||(c[b]=I()),c[g]=1,h=a.ctx,(k=h.get(g))?h=k:h.set(g,h=a.keystore?new R(a.keystore):new Map)):(h=a.map,c[b]=1);(k=h.get(b))?h=k:h.set(b,h=k=[]);if(f)for(let l=0,m;lc?a.slice(b,b+c):a,e?Ta.call(this,a):a;let d=[];for(let f=0,g,k;f=k){b-=k;continue}g=g.slice(b,b+c);k=g.length;b=0}k>c&&(g=g.slice(0,c),k=c);if(!d.length&&k>=c)return e?Ta.call(this,g):g;d.push(g);c-=k;if(!c)break}d=d.length>1?[].concat.apply([],d):d[0];return e?Ta.call(this,d):d};function Ua(a,c,b,e){var d=e[0];if(d[0]&&d[0].query)return a[c].apply(a,d);if(!(c!=="and"&&c!=="not"||a.result.length||a.await||d.suggest))return e.length>1&&(d=e[e.length-1]),(e=d.resolve)?a.await||a.result:a;let f=[],g=0,k=0,h,l,m,p,u;for(c=0;c1&&(b=b[c].apply(b,a.slice(1)));return b};X.prototype.or=function(){return Ua(this,"or",Xa,arguments)};function Xa(a,c,b,e,d,f,g){a.length&&(this.result.length&&a.push(this.result),a.length<2?this.result=a[0]:(this.result=Ya(a,c,b,!1,this.h),b=0));d&&(this.await=null);return d?this.resolve(c,b,e,g):this};X.prototype.and=function(){return Ua(this,"and",Za,arguments)};function Za(a,c,b,e,d,f,g){if(!f&&!this.result.length)return d?this.result:this;let k;if(a.length)if(this.result.length&&a.unshift(this.result),a.length<2)this.result=a[0];else{let h=0;for(let l=0,m,p;l1&&(b=b[c].apply(b,a.slice(1)));return b};X.prototype.or=function(){return Ua(this,"or",Xa,arguments)};function Xa(a,c,b,e,d,f,g){a.length&&(this.result.length&&a.push(this.result),a.length<2?this.result=a[0]:(this.result=Ya(a,c,b,!1,this.h),b=0));d&&(this.await=null);return d?this.resolve(c,b,e,g):this};X.prototype.and=function(){return Ua(this,"and",Za,arguments)};function Za(a,c,b,e,d,f,g){if(!f&&!this.result.length)return d?this.result:this;let k;if(a.length)if(this.result.length&&a.unshift(this.result),a.length<2)this.result=a[0];else{let h=0;for(let l=0,m,p;l1?z.join(" "):z[0];let y;if(z&&B){var C=B.length,J=(da.split?
-B.replace(da.split,""):B).length-z.length,G="",N=0;for(var O=0;O-1&&(G=(P?B.substring(0,P):"")+g+B.substring(P,P+L)+k+(P+L=h)break}F=za.length*(f.length-2);if(r||t||h&&q.length-F>h)if(F=h+F-u*2,E=D-
-A,r>0&&(E+=r),t>0&&(E+=t),E<=F)x=r?A-(r>0?r:0):A-((F-E)/2|0),v=t?D+(t>0?t:0):x+F,l||(x>0&&q.charAt(x)!==" "&&q.charAt(x-1)!==" "&&(x=q.indexOf(" ",x),x<0&&(x=0)),v=v.length-
-1){if(K>=v.length){E[y+1]=1;K>=x.length&&(F[y+1]=1);continue}C-=u}q=v[K].text;if(L=t&&z[y])if(L>0){if(q.length>L)if(E[y+1]=1,l)q=q.substring(0,L);else continue;(L-=q.length)||(L=-1);z[y]=L}else{E[y+1]=1;continue}if(C+q.length+1<=h)q=" "+q,D[y]+=q;else if(l)U=h-C-1,U>0&&(q=" "+q.substring(0,U),D[y]+=q),E[y+1]=1;else{E[y+1]=1;continue}}else{if(E[y])continue;K-=J;if(A[K]){C-=u;E[y]=1;F[y]=1;continue}if(K<=0){if(K<0){E[y]=1;F[y]=1;continue}C-=u}q=v[K].text;if(L=r&&B[y])if(L>0){if(q.length>L)if(E[y]=1,
-l)q=q.substring(q.length-L);else continue;(L-=q.length)||(L=-1);B[y]=L}else{E[y]=1;continue}if(C+q.length+1<=h)q+=" ",D[y]=q+D[y];else if(l)U=q.length+1-(h-C),U>=0&&U=x.length-1?Pa=1:K1?z.join(" "):z[0];let y;if(z&&C){var D=C.length,J=(da.split?
+C.replace(da.split,""):C).length-z.length,G="",N=0;for(var O=0;O-1&&(G=(P?C.substring(0,P):"")+g+C.substring(P,P+L)+k+(P+L=h)break}F=za.length*(f.length-2);if(r||t||h&&q.length-F>h)if(F=h+F-u*2,B=E-
+A,r>0&&(B+=r),t>0&&(B+=t),B<=F)x=r?A-(r>0?r:0):A-((F-B)/2|0),v=t?E+(t>0?t:0):x+F,l||(x>0&&q.charAt(x)!==" "&&q.charAt(x-1)!==" "&&(x=q.indexOf(" ",x),x<0&&(x=0)),v=v.length-
+1){if(K>=v.length){B[y+1]=1;K>=x.length&&(F[y+1]=1);continue}D-=u}q=v[K].text;if(L=t&&z[y])if(L>0){if(q.length>L)if(B[y+1]=1,l)q=q.substring(0,L);else continue;(L-=q.length)||(L=-1);z[y]=L}else{B[y+1]=1;continue}if(D+q.length+1<=h)q=" "+q,E[y]+=q;else if(l)U=h-D-1,U>0&&(q=" "+q.substring(0,U),E[y]+=q),B[y+1]=1;else{B[y+1]=1;continue}}else{if(B[y])continue;K-=J;if(A[K]){D-=u;B[y]=1;F[y]=1;continue}if(K<=0){if(K<0){B[y]=1;F[y]=1;continue}D-=u}q=v[K].text;if(L=r&&C[y])if(L>0){if(q.length>L)if(B[y]=1,
+l)q=q.substring(q.length-L);else continue;(L-=q.length)||(L=-1);C[y]=L}else{B[y]=1;continue}if(D+q.length+1<=h)q+=" ",E[y]=q+E[y];else if(l)U=q.length+1-(h-D),U>=0&&U=x.length-1?Pa=1:K1?Ya(h,b,e,g,f):(h=h[0])&&b&&h.length>b||e?h.slice(e,b+e):h;else{if(ab||e)h=h.slice(e,b+
e)}else{d=[];for(let p=0,u;pe)e-=u.length;else{if(b&&u.length>b||e)u=u.slice(e,b+e),b-=u.length,e&&(e-=u.length);d.push(u);if(!b)break}h=d}}return h}
function Ya(a,c,b,e,d){const f=[],g=I();let k;var h=a.length;let l;if(e)for(d=h-1;d>=0;d--){if(l=(e=a[d])&&e.length)for(h=0;h=0;m--){p=a[m];for(let r=0;r1?$a(d,1,0,0,h,l):d[0],B)})}return r?d:new X(d.length>1?$a(d,1,0,0,h,l):d[0],this)}}r||g||!(p=p||this.field)||(M(p)?g=p:(p.constructor===Array&&p.length===1&&(p=p[0]),g=p.field||p.index));p&&p.constructor!==Array&&(p=[p])}p||(p=this.field);let F;v=(this.worker||this.db)&&!e&&[];for(let B=0,z,C,J;B1?$a(d,1,0,0,h,l):d[0],C)})}return r?d:new X(d.length>1?$a(d,1,0,0,h,l):d[0],this)}}r||g||!(p=p||this.field)||(M(p)?g=p:(p.constructor===Array&&p.length===1&&(p=p[0]),g=p.field||p.index));p&&p.constructor!==Array&&(p=[p])}p||(p=this.field);let F;v=(this.worker||this.db)&&!e&&[];for(let C=0,z,D,J;C0){if(b&&c>b||e)a=a.slice(e,e+b);d&&(a=Ta.call(this,a))}return a}
function Ta(a){if(!this||!this.store)return a;if(this.db)return this.index.get(this.field[0]).db.enrich(a);const c=Array(a.length);for(let b=0,e;b2?b[0]:"";b=b.length>2?b[2]:b[1];if(this.worker&&e)return this.index.get(e).import(a);if(c){typeof c==="string"&&(c=JSON.parse(c));if(e)return this.index.get(e).import(b,c);switch(b){case "reg":this.fastupdate=!1;this.reg=qb(c,this.reg);for(let d=0,f;d=0&&d.splice(g,1)}}else tb(this.map,a),this.depth&&tb(this.ctx,a);c||this.reg.delete(a)}this.db&&(this.commit_task.push({del:a}),this.M&&ub(this));this.cache&&this.cache.remove(a);return this};
-function tb(a,c){let b=0;var e=typeof c==="undefined";if(a.constructor===Array)for(let d=0,f,g,k;d=0){if(f.length>1)return f.splice(g,1),1;delete a[d];if(b)return 1;k=1}else{if(k)return 1;b++}}}else for(let d of a.entries())e=d[0],tb(d[1],c)?b++:a.delete(e);return b};const vb={memory:{resolution:1},performance:{resolution:3,fastupdate:!0,context:{depth:1,resolution:1}},match:{tokenize:"forward"},score:{resolution:9,context:{depth:2,resolution:3}}};T.prototype.add=function(a,c,b,e){if(c&&(a||a===0)){if(!e&&!b&&this.reg.has(a))return this.update(a,c);e=this.depth;c=this.encoder.encode(c,!e);const l=c.length;if(l){const m=I(),p=I(),u=this.resolution;for(let r=0;r2){for(let n=1,q,x,v,A;n=0){if(f.length>1)return f.splice(g,1),1;delete a[d];if(b)return 1;k=1}else{if(k)return 1;b++}}}else for(let d of a.entries())e=d[0],tb(d[1],c)?b++:a.delete(e);return b};const vb={memory:{resolution:1},performance:{resolution:3,fastupdate:!0,context:{depth:1,resolution:1}},match:{tokenize:"full"},score:{resolution:9,context:{depth:2,resolution:3}}};T.prototype.add=function(a,c,b,e){if(c&&(a||a===0)){if(!e&&!b&&this.reg.has(a))return this.update(a,c);e=this.depth;c=this.encoder.encode(c,!e);const l=c.length;if(l){const m=I(),p=I(),u=this.resolution;for(let r=0;r2){for(let n=1,q,x,v,A;n2){for(let n=0,q;nn;f--){g=t.substring(n,f);q=this.rtl?d-1-n:n;var k=this.score?this.score(c,t,r,g,q):wb(u,l,r,d,q);Y(this,p,g,k,a,b)}break}case "bidirectional":case "reverse":if(d>1){for(k=d-1;k>0;k--){g=t[this.rtl?d-1-k:k]+g;var h=this.score?this.score(c,t,r,g,k):wb(u,l,r,d,k);Y(this,p,g,h,a,b)}g=""}case "forward":if(d>1){for(k=0;k1&&rg;const n=this.score?this.score(c,g,r,t,k-1):wb(d+(l/2>d?0:1),l,r,f-1,k-1);Y(this,m,h?g:t,n,a,b,h?t:g)}}}}this.fastupdate||this.reg.add(a)}}this.db&&(this.commit_task.push(b?{ins:a}:{del:a}),this.M&&ub(this));return this};
function Y(a,c,b,e,d,f,g){let k,h;if(!(k=c[b])||g&&!k[g]){g?(c=k||(c[b]=I()),c[g]=1,h=a.ctx,(k=h.get(g))?h=k:h.set(g,h=a.keystore?new R(a.keystore):new Map)):(h=a.map,c[b]=1);(k=h.get(b))?h=k:h.set(b,h=k=[]);if(f)for(let l=0,m;l2?b[0]:"";b=b.length>2?b[2]:b[1];if(c){typeof c==="string"&&(c=JSON.parse(c));if(a)return this.index.get(a).import(b,c);switch(b){case "reg":this.fastupdate=!1;this.reg=Sa(c,this.reg);for(let e=0,d;e=0&&d.splice(g,1)}}else Va(this.map,a),this.depth&&Va(this.ctx,a);c||this.reg.delete(a)}this.cache&&this.cache.remove(a);return this};
-function Va(a,c){let b=0;var e=typeof c==="undefined";if(a.constructor===Array)for(let d=0,f,g,h;d=0){if(f.length>1)return f.splice(g,1),1;delete a[d];if(b)return 1;h=1}else{if(h)return 1;b++}}}else for(let d of a.entries())e=d[0],Va(d[1],c)?b++:a.delete(e);return b};const Wa={memory:{resolution:1},performance:{resolution:3,fastupdate:!0,context:{depth:1,resolution:1}},match:{tokenize:"forward"},score:{resolution:9,context:{depth:2,resolution:3}}};Y.prototype.add=function(a,c,b,e){if(c&&(a||a===0)){if(!e&&!b&&this.reg.has(a))return this.update(a,c);e=this.depth;c=this.encoder.encode(c,!e);const m=c.length;if(m){const l=N(),A=N(),x=this.resolution;for(let u=0;u2){for(let w=1,n,v,q,C;w=0){if(f.length>1)return f.splice(g,1),1;delete a[d];if(b)return 1;h=1}else{if(h)return 1;b++}}}else for(let d of a.entries())e=d[0],Va(d[1],c)?b++:a.delete(e);return b};const Wa={memory:{resolution:1},performance:{resolution:3,fastupdate:!0,context:{depth:1,resolution:1}},match:{tokenize:"full"},score:{resolution:9,context:{depth:2,resolution:3}}};Y.prototype.add=function(a,c,b,e){if(c&&(a||a===0)){if(!e&&!b&&this.reg.has(a))return this.update(a,c);e=this.depth;c=this.encoder.encode(c,!e);const m=c.length;if(m){const l=N(),A=N(),x=this.resolution;for(let u=0;u2){for(let w=1,n,v,q,C;w2){for(let w=0,n;ww;f--){g=p.substring(w,f);n=this.rtl?d-1-w:w;var h=this.score?this.score(c,p,u,g,n):Xa(x,m,u,d,n);Z(this,A,g,h,a,b)}break}case "bidirectional":case "reverse":if(d>1){for(h=d-1;h>0;h--){g=p[this.rtl?d-1-h:h]+g;var k=this.score?this.score(c,p,u,g,h):Xa(x,m,u,d,h);Z(this,A,g,k,a,b)}g=""}case "forward":if(d>1){for(h=0;h1&&ug;const w=this.score?this.score(c,g,u,p,h-1):Xa(d+(m/2>d?0:1),m,u,f-1,h-1);Z(this,l,k?g:p,w,a,b,k?p:g)}}}}this.fastupdate||this.reg.add(a)}}return this};
function Z(a,c,b,e,d,f,g){let h,k;if(!(h=c[b])||g&&!h[g]){g?(c=h||(c[b]=N()),c[g]=1,k=a.ctx,(h=k.get(g))?k=h:k.set(g,k=new Map)):(k=a.map,c[b]=1);(h=k.get(b))?k=h:k.set(b,k=h=[]);if(f)for(let m=0,l;m2?b[0]:"";b=b.length>2?b[2]:b[1];if(c){typeof c==="string"&&(c=JSON.parse(c));if(a)return this.index.get(a).import(b,c);switch(b){case "reg":this.fastupdate=!1;this.reg=Sa(c,this.reg);for(let e=0,d;e=0&&d.splice(g,1)}}else Va(this.map,a),this.depth&&Va(this.ctx,a);c||this.reg.delete(a)}this.cache&&this.cache.remove(a);return this};
-function Va(a,c){let b=0;var e=typeof c==="undefined";if(a.constructor===Array)for(let d=0,f,g,h;d=0){if(f.length>1)return f.splice(g,1),1;delete a[d];if(b)return 1;h=1}else{if(h)return 1;b++}}}else for(let d of a.entries())e=d[0],Va(d[1],c)?b++:a.delete(e);return b};const Wa={memory:{resolution:1},performance:{resolution:3,fastupdate:!0,context:{depth:1,resolution:1}},match:{tokenize:"forward"},score:{resolution:9,context:{depth:2,resolution:3}}};Y.prototype.add=function(a,c,b,e){if(c&&(a||a===0)){if(!e&&!b&&this.reg.has(a))return this.update(a,c);e=this.depth;c=this.encoder.encode(c,!e);const m=c.length;if(m){const l=N(),A=N(),x=this.resolution;for(let u=0;u2){for(let w=1,n,v,q,C;w=0){if(f.length>1)return f.splice(g,1),1;delete a[d];if(b)return 1;h=1}else{if(h)return 1;b++}}}else for(let d of a.entries())e=d[0],Va(d[1],c)?b++:a.delete(e);return b};const Wa={memory:{resolution:1},performance:{resolution:3,fastupdate:!0,context:{depth:1,resolution:1}},match:{tokenize:"full"},score:{resolution:9,context:{depth:2,resolution:3}}};Y.prototype.add=function(a,c,b,e){if(c&&(a||a===0)){if(!e&&!b&&this.reg.has(a))return this.update(a,c);e=this.depth;c=this.encoder.encode(c,!e);const m=c.length;if(m){const l=N(),A=N(),x=this.resolution;for(let u=0;u2){for(let w=1,n,v,q,C;w2){for(let w=0,n;ww;f--){g=p.substring(w,f);n=this.rtl?d-1-w:w;var h=this.score?this.score(c,p,u,g,n):Xa(x,m,u,d,n);Z(this,A,g,h,a,b)}break}case "bidirectional":case "reverse":if(d>1){for(h=d-1;h>0;h--){g=p[this.rtl?d-1-h:h]+g;var k=this.score?this.score(c,p,u,g,h):Xa(x,m,u,d,h);Z(this,A,g,k,a,b)}g=""}case "forward":if(d>1){for(h=0;h1&&ug;const w=this.score?this.score(c,g,u,p,h-1):Xa(d+(m/2>d?0:1),m,u,f-1,h-1);Z(this,l,k?g:p,w,a,b,k?p:g)}}}}this.fastupdate||this.reg.add(a)}}return this};
function Z(a,c,b,e,d,f,g){let h,k;if(!(h=c[b])||g&&!h[g]){g?(c=h||(c[b]=N()),c[g]=1,k=a.ctx,(h=k.get(g))?k=h:k.set(g,k=new Map)):(k=a.map,c[b]=1);(h=k.get(b))?k=h:k.set(b,k=h=[]);if(f)for(let m=0,l;mb?a.slice(c,c+b):a,d?sb.call(this,a):a;for(var e=[],f=0,g=void 0,h=void 0;f=h){c-=h;continue}g=g.slice(c,c+b);h=g.length;c=0}h>b&&(g=g.slice(0,b),h=b);if(!e.length&&h>=b)return d?sb.call(this,g):g;e.push(g);b-=h;if(!b)break}e=e.length>1?[].concat.apply([],e):e[0];return d?sb.call(this,e):e};function tb(a,b,c,d){var e=d[0];if(e[0]&&e[0].query)return a[b].apply(a,e);if(!(b!=="and"&&b!=="not"||a.result.length||a.await||e.suggest))return d.length>1&&(e=d[d.length-1]),(d=e.resolve)?a.await||a.result:a;var f=[],g=0,h=0,k;b={};for(e=0;e1&&(c=c[b].apply(c,a.slice(1)));return c};Z.prototype.or=function(){return tb(this,"or",wb,arguments)};function wb(a,b,c,d,e,f,g){a.length&&(this.result.length&&a.push(this.result),a.length<2?this.result=a[0]:(this.result=xb(a,b,c,!1,this.h),c=0));e&&(this.await=null);return e?this.resolve(b,c,d,g):this};Z.prototype.and=function(){return tb(this,"and",yb,arguments)};function yb(a,b,c,d,e,f,g){if(!f&&!this.result.length)return e?this.result:this;if(a.length)if(this.result.length&&a.unshift(this.result),a.length<2)this.result=a[0];else{for(var h=0,k=0,l=void 0,m=void 0;k1&&(c=c[b].apply(c,a.slice(1)));return c};Z.prototype.or=function(){return tb(this,"or",wb,arguments)};function wb(a,b,c,d,e,f,g){a.length&&(this.result.length&&a.push(this.result),a.length<2?this.result=a[0]:(this.result=xb(a,b,c,!1,this.h),c=0));e&&(this.await=null);return e?this.resolve(b,c,d,g):this};Z.prototype.and=function(){return tb(this,"and",yb,arguments)};function yb(a,b,c,d,e,f,g){if(!f&&!this.result.length)return e?this.result:this;if(a.length)if(this.result.length&&a.unshift(this.result),a.length<2)this.result=a[0];else{for(var h=0,k=0,l=void 0,m=void 0;k-1&&(ba=(I?R.s
N,l||(x>0&&r.charAt(x)!==" "&&r.charAt(x-1)!==" "&&(x=r.indexOf(" ",x),x<0&&(x=0)),E=E.length-1){if(J>=E.length){F[y+1]=1;J>=x.length&&(G[y+1]=1);continue}P-=n}r=E[J].text;var V=t&&W[y];
if(V)if(V>0){if(r.length>V)if(F[y+1]=1,l)r=r.substring(0,V);else continue;(V-=r.length)||(V=-1);W[y]=V}else{F[y+1]=1;continue}if(P+r.length+1<=k)r=" "+r,O[y]+=r;else if(l)I=k-P-1,I>0&&(r=" "+r.substring(0,I),O[y]+=r),F[y+1]=1;else{F[y+1]=1;continue}}else{if(F[y])continue;J-=M;if(N[J]){P-=n;F[y]=1;G[y]=1;continue}if(J<=0){if(J<0){F[y]=1;G[y]=1;continue}P-=n}r=E[J].text;if(V=q&&R[y])if(V>0){if(r.length>V)if(F[y]=1,l)r=r.substring(r.length-V);else continue;(V-=r.length)||(V=-1);R[y]=V}else{F[y]=1;continue}if(P+
r.length+1<=k)r+=" ",O[y]=r+O[y];else if(l)I=r.length+1-(k-P),I>=0&&I=x.length-1?I=1:J2?c[0]:"";c=c.length>2?c[2]:c[1];if(this.worker&&d)return this.index.get(d).import(a);if(b){typeof b==="string"&&(b=JSON.parse(b));if(d)return this.index.get(d).import(c,b);switch(c){case "reg":this.fastupdate=!1;this.reg=Pb(b,this.reg);for(b=0;b=0&&e.splice(g,1)}}else Sb(this.map,a),this.depth&&Sb(this.ctx,a);b||this.reg.delete(a)}this.db&&(this.commit_task.push({del:a}),this.$&&Tb(this));this.cache&&this.cache.remove(a);return this};
-function Sb(a,b){var c=0,d=typeof b==="undefined";if(a.constructor===Array)for(var e=0,f=void 0,g,h=void 0;e=0){if(f.length>1)return f.splice(g,1),1;delete a[e];if(c)return 1;h=1}else{if(h)return 1;c++}}}else for(d=D(a.entries()),e=d.next();!e.done;e=d.next())e=e.value,f=e[0],Sb(e[1],b)?c++:a.delete(f);return c};var Ub={memory:{resolution:1},performance:{resolution:3,fastupdate:!0,context:{depth:1,resolution:1}},match:{tokenize:"forward"},score:{resolution:9,context:{depth:2,resolution:3}}};db.prototype.add=function(a,b,c,d){if(b&&(a||a===0)){if(!d&&!c&&this.reg.has(a))return this.update(a,b);d=this.depth;b=this.encoder.encode(b,!d);var e=b.length;if(e){for(var f=S(),g=S(),h=this.resolution,k=0;k2){for(var q=1,t,u;q=0){if(f.length>1)return f.splice(g,1),1;delete a[e];if(c)return 1;h=1}else{if(h)return 1;c++}}}else for(d=D(a.entries()),e=d.next();!e.done;e=d.next())e=e.value,f=e[0],Sb(e[1],b)?c++:a.delete(f);return c};var Ub={memory:{resolution:1},performance:{resolution:3,fastupdate:!0,context:{depth:1,resolution:1}},match:{tokenize:"full"},score:{resolution:9,context:{depth:2,resolution:3}}};db.prototype.add=function(a,b,c,d){if(b&&(a||a===0)){if(!d&&!c&&this.reg.has(a))return this.update(a,b);d=this.depth;b=this.encoder.encode(b,!d);var e=b.length;if(e){for(var f=S(),g=S(),h=this.resolution,k=0;k2){for(var q=1,t,u;q2){for(p=0;pp;q--)n=l.substring(p,q),t=this.rtl?m-1-p:p,t=this.score?this.score(b,l,k,n,t):Vb(h,e,k,m,t),Wb(this,g,n,t,a,c);break}case "bidirectional":case "reverse":if(m>1){for(q=m-1;q>0;q--)n=l[this.rtl?m-1-q:q]+n,t=this.score?this.score(b,l,k,n,q):Vb(h,e,k,m,q),Wb(this,g,n,t,a,c);n=""}case "forward":if(m>1){for(q=0;q1&&kn,u=this.score?this.score(b,n,k,l,q-1):Vb(m+(e/2>m?0:1),e,k,p-1,q-1),Wb(this,f,t?n:l,u,a,c,t?l:n)}}}this.fastupdate||this.reg.add(a)}}this.db&&(this.commit_task.push(c?{ins:a}:{del:a}),this.$&&Tb(this));return this};
function Wb(a,b,c,d,e,f,g){var h;if(!(h=b[c])||g&&!h[g]){if(g){b=h||(b[c]=S());b[g]=1;var k=a.ctx;(h=k.get(g))?k=h:k.set(g,k=a.keystore?new X(a.keystore):new Map)}else k=a.map,b[c]=1;(h=k.get(c))?k=h:k.set(c,k=h=[]);if(f)for(c=0;cthis.maxlength)){if(c){if(d[g])continue;d[g]=1}else{if(h===g)continue;h=g}if(b)f.push(g);else if(!this.filter||(typeof this.filter==="function"?this.filter(g):!this.filter.has(g))){if(this.cache&&g.length<=this.o)if(this.l){var l=this.j.get(g);if(l||l===""){l&&f.push(l);continue}}else this.l=setTimeout(G,50,this);if(this.stemmer){this.u||(this.u=new RegExp("(?!^)("+
this.h+")$"));let w;for(;w!==g&&g.length>2;)w=g,g=g.replace(this.u,q=>this.stemmer.get(q))}if(g&&(this.mapper||this.dedupe&&g.length>1)){l="";for(let w=0,q="",m,p;w1&&(this.s||(this.s=new RegExp("("+this.g+")","g")),g=g.replace(this.s,w=>this.matcher.get(w)));if(g&&this.replacer)for(l=0;g&<his.A&&(this.j.clear(),this.o=this.o/1.1|0));if(g){if(g!==t)if(c){if(d[g])continue;d[g]=1}else{if(e===g)continue;e=g}f.push(g)}}}this.finalize&&(f=this.finalize(f)||f);this.cache&&a.length<=this.m&&(this.i.set(a,f),this.i.size>this.A&&(this.i.clear(),this.m=this.m/1.1|0));return f};function G(a){a.l=null;a.i.clear();a.j.clear()};function H(a,c,b){if(!a.length)return a;if(a.length===1)return a=a[0],a=b||a.length>c?a.slice(b,b+c):a;let f=[];for(let d=0,h,e;d=e){b-=e;continue}h=h.slice(b,b+c);e=h.length;b=0}e>c&&(h=h.slice(0,c),e=c);if(!f.length&&e>=c)return h;f.push(h);c-=e;if(!c)break}return f=f.length>1?[].concat.apply([],f):f[0]};z();J.prototype.remove=function(a,c){const b=this.reg.size&&(this.fastupdate?this.reg.get(a):this.reg.has(a));if(b){if(this.fastupdate)for(let f=0,d,h;f=0&&d.splice(e,1)}}else K(this.map,a),this.depth&&K(this.ctx,a);c||this.reg.delete(a)}return this};
-function K(a,c){let b=0;var f=typeof c==="undefined";if(a.constructor===Array)for(let d=0,h,e,k;d=0){if(h.length>1)return h.splice(e,1),1;delete a[d];if(b)return 1;k=1}else{if(k)return 1;b++}}}else for(let d of a.entries())f=d[0],K(d[1],c)?b++:a.delete(f);return b};const L={memory:{resolution:1},performance:{resolution:3,fastupdate:!0,context:{depth:1,resolution:1}},match:{tokenize:"forward"},score:{resolution:9,context:{depth:2,resolution:3}}};J.prototype.add=function(a,c,b,f){if(c&&(a||a===0)){if(!f&&!b&&this.reg.has(a))return this.update(a,c);f=this.depth;c=this.encoder.encode(c,!f);const n=c.length;if(n){const g=z(),t=z(),w=this.resolution;for(let q=0;q2){for(let p=1,u,y,x,I;p=0){if(h.length>1)return h.splice(e,1),1;delete a[d];if(b)return 1;k=1}else{if(k)return 1;b++}}}else for(let d of a.entries())f=d[0],K(d[1],c)?b++:a.delete(f);return b};const L={memory:{resolution:1},performance:{resolution:3,fastupdate:!0,context:{depth:1,resolution:1}},match:{tokenize:"full"},score:{resolution:9,context:{depth:2,resolution:3}}};J.prototype.add=function(a,c,b,f){if(c&&(a||a===0)){if(!f&&!b&&this.reg.has(a))return this.update(a,c);f=this.depth;c=this.encoder.encode(c,!f);const n=c.length;if(n){const g=z(),t=z(),w=this.resolution;for(let q=0;q2){for(let p=1,u,y,x,I;p2){for(let p=0,u;pp;h--){e=m.substring(p,h);u=this.rtl?d-1-p:p;var k=this.score?this.score(c,m,q,e,u):M(w,n,q,d,u);N(this,t,e,k,a,b)}break}case "bidirectional":case "reverse":if(d>1){for(k=d-1;k>0;k--){e=m[this.rtl?d-1-k:k]+e;var l=this.score?this.score(c,m,q,e,k):M(w,n,q,d,k);N(this,t,e,l,a,b)}e=""}case "forward":if(d>1){for(k=0;k1&&qe;const p=this.score?this.score(c,e,q,m,k-1):M(d+(n/2>d?0:1),n,q,h-1,k-1);N(this,g,l?e:m,p,a,b,l?m:e)}}}}this.fastupdate||this.reg.add(a)}}return this};
function N(a,c,b,f,d,h,e){let k,l;if(!(k=c[b])||e&&!k[e]){e?(c=k||(c[b]=z()),c[e]=1,l=a.ctx,(k=l.get(e))?l=k:l.set(e,l=new Map)):(l=a.map,c[b]=1);(k=l.get(b))?l=k:l.set(b,l=k=[]);if(h)for(let n=0,g;nthis.maxlength)){if(c){if(d[g])continue;d[g]=1}else{if(h===g)continue;h=g}if(b)f.push(g);else if(!this.filter||(typeof this.filter==="function"?this.filter(g):!this.filter.has(g))){if(this.cache&&g.length<=this.o)if(this.l){var l=this.j.get(g);if(l||l===""){l&&f.push(l);continue}}else this.l=setTimeout(G,50,this);if(this.stemmer){this.u||(this.u=new RegExp("(?!^)("+
this.h+")$"));let w;for(;w!==g&&g.length>2;)w=g,g=g.replace(this.u,q=>this.stemmer.get(q))}if(g&&(this.mapper||this.dedupe&&g.length>1)){l="";for(let w=0,q="",m,p;w1&&(this.s||(this.s=new RegExp("("+this.g+")","g")),g=g.replace(this.s,w=>this.matcher.get(w)));if(g&&this.replacer)for(l=0;g&<his.A&&(this.j.clear(),this.o=this.o/1.1|0));if(g){if(g!==t)if(c){if(d[g])continue;d[g]=1}else{if(e===g)continue;e=g}f.push(g)}}}this.finalize&&(f=this.finalize(f)||f);this.cache&&a.length<=this.m&&(this.i.set(a,f),this.i.size>this.A&&(this.i.clear(),this.m=this.m/1.1|0));return f};function G(a){a.l=null;a.i.clear();a.j.clear()};function I(a,c,b){if(!a.length)return a;if(a.length===1)return a=a[0],a=b||a.length>c?a.slice(b,b+c):a;let f=[];for(let d=0,h,e;d=e){b-=e;continue}h=h.slice(b,b+c);e=h.length;b=0}e>c&&(h=h.slice(0,c),e=c);if(!f.length&&e>=c)return h;f.push(h);c-=e;if(!c)break}return f=f.length>1?[].concat.apply([],f):f[0]};z();J.prototype.remove=function(a,c){const b=this.reg.size&&(this.fastupdate?this.reg.get(a):this.reg.has(a));if(b){if(this.fastupdate)for(let f=0,d,h;f=0&&d.splice(e,1)}}else K(this.map,a),this.depth&&K(this.ctx,a);c||this.reg.delete(a)}return this};
-function K(a,c){let b=0;var f=typeof c==="undefined";if(a.constructor===Array)for(let d=0,h,e,k;d=0){if(h.length>1)return h.splice(e,1),1;delete a[d];if(b)return 1;k=1}else{if(k)return 1;b++}}}else for(let d of a.entries())f=d[0],K(d[1],c)?b++:a.delete(f);return b};const L={memory:{resolution:1},performance:{resolution:3,fastupdate:!0,context:{depth:1,resolution:1}},match:{tokenize:"forward"},score:{resolution:9,context:{depth:2,resolution:3}}};J.prototype.add=function(a,c,b,f){if(c&&(a||a===0)){if(!f&&!b&&this.reg.has(a))return this.update(a,c);f=this.depth;c=this.encoder.encode(c,!f);const n=c.length;if(n){const g=z(),t=z(),w=this.resolution;for(let q=0;q2){for(let p=1,u,y,x,H;p=0){if(h.length>1)return h.splice(e,1),1;delete a[d];if(b)return 1;k=1}else{if(k)return 1;b++}}}else for(let d of a.entries())f=d[0],K(d[1],c)?b++:a.delete(f);return b};const L={memory:{resolution:1},performance:{resolution:3,fastupdate:!0,context:{depth:1,resolution:1}},match:{tokenize:"full"},score:{resolution:9,context:{depth:2,resolution:3}}};J.prototype.add=function(a,c,b,f){if(c&&(a||a===0)){if(!f&&!b&&this.reg.has(a))return this.update(a,c);f=this.depth;c=this.encoder.encode(c,!f);const n=c.length;if(n){const g=z(),t=z(),w=this.resolution;for(let q=0;q2){for(let p=1,u,y,x,H;p2){for(let p=0,u;pp;h--){e=m.substring(p,h);u=this.rtl?d-1-p:p;var k=this.score?this.score(c,m,q,e,u):M(w,n,q,d,u);N(this,t,e,k,a,b)}break}case "bidirectional":case "reverse":if(d>1){for(k=d-1;k>0;k--){e=m[this.rtl?d-1-k:k]+e;var l=this.score?this.score(c,m,q,e,k):M(w,n,q,d,k);N(this,t,e,l,a,b)}e=""}case "forward":if(d>1){for(k=0;k1&&qe;const p=this.score?this.score(c,e,q,m,k-1):M(d+(n/2>d?0:1),n,q,h-1,k-1);N(this,g,l?e:m,p,a,b,l?m:e)}}}}this.fastupdate||this.reg.add(a)}}return this};
function N(a,c,b,f,d,h,e){let k,l;if(!(k=c[b])||e&&!k[e]){e?(c=k||(c[b]=z()),c[e]=1,l=a.ctx,(k=l.get(e))?l=k:l.set(e,l=new Map)):(l=a.map,c[b]=1);(k=l.get(b))?l=k:l.set(b,l=k=[]);if(h)for(let n=0,g;n