1
0
mirror of https://github.com/nextapps-de/flexsearch.git synced 2025-09-30 07:18:57 +02:00

fast-boot serialization for server-side-rendering

This commit is contained in:
Thomas Wilkerling
2025-03-10 16:54:01 +01:00
parent da475effee
commit 3a00dba465
27 changed files with 2055 additions and 1223 deletions

View File

@@ -29,6 +29,7 @@ npm install git+https://github.com/nextapps-de/flexsearch/tree/v0.8-preview
- Enhanced Worker Support
- Improved Build System + Bundler (Supported: CommonJS, ESM, Global Namespace), also the import of language packs are now supported for Node.js
- Full covering index.d.ts type definitions
- Fast-Boot Serialization optimized for Server-Side-Rendering (PHP, Python, Ruby, Rust, Java, Go, Node.js, ...)
Compare Benchmark: [0.7.0](https://nextapps-de.github.io/flexsearch/test/flexsearch-0.7.0/) vs. [0.8.0](https://nextapps-de.github.io/flexsearch/test/flexsearch-0.8.0/)
@@ -1633,6 +1634,72 @@ const index = new Index({
If you get some good results please feel free to share your encoder.
## Fast-Boot Serialization for Server-Side-Rendering (PHP, Python, Ruby, Rust, Java, Go, Node.js, ...)
When using Server-Side-Rendering you can create a different export which instantly boot up. Especially when using Server-side rendered content, this could help to restore an index on page load.
> When your index is too large you should use the default export/import mechanism.
As the first step populate the FlexSearch index with your contents.
You have two options:
### 1. Create a function as string
```js
const fn_string = index.serialize();
```
The contents of `fn_string` is a valid Javascript-Function declared as `inject(index)`. Store it or place this somewhere in your code.
This function basically looks like:
```js
function inject(index){
index.reg = new Set([/* ... */]);
index.map = new Map([/* ... */]);
index.ctx = new Map([/* ... */]);
}
```
After creating the index on client side just call the inject method like:
```js
const index = new Index();
inject(index);
```
That's it.
### 2. Create just a function body as string
Alternatively you can use lazy function declaration by passing `false` to the serialize function:
```js
const fn_body = index.serialize(false);
```
You will get just the function body which looks like:
```js
index.reg = new Set([/* ... */]);
index.map = new Map([/* ... */]);
index.ctx = new Map([/* ... */]);
```
Now you can place this in your code directly (name your index as `index`), or you can also create an inject function from it, e.g.:
```js
const inject = new Function("index", fn_body);
```
This function is callable like the above example:
```js
const index = new Index();
inject(index);
```
## Load Library (Node.js, ESM, Legacy Browser)
> Please do not use the `/src/` folder of this repo. It isn't meant to be used directly, instead it needs [conditional compilation](https://en.wikipedia.org/wiki/Conditional_compilation). You can easily perform a <a href="#builds">custom build</a>, but you shouldn't use the source folder for production. You will need at least any kind of compiler which resolve the compiler flags within the code like [Closure Compiler](https://github.com/google/closure-compiler) (Advanced Compilation) or with [Babel conditional-compile](https://github.com/brianZeng/babel-plugin-conditional-compile) plugin. The `/dist/` folder is containing every version which you probably need including unminified ESM modules.

View File

@@ -129,32 +129,32 @@ G.prototype.assign = function(a) {
this.minlength = y(a.minlength, 1, this.minlength);
this.maxlength = y(a.maxlength, 0, this.maxlength);
if (this.cache = c = y(a.cache, !0, this.cache)) {
this.O = null, this.V = "number" === typeof c ? c : 2e5, this.J = new Map(), this.M = new Map(), this.B = this.h = 128;
this.M = null, this.T = "number" === typeof c ? c : 2e5, this.H = new Map(), this.K = new Map(), this.A = this.h = 128;
}
this.C = "";
this.S = null;
this.P = "";
this.T = null;
this.B = "";
this.P = null;
this.N = "";
this.R = null;
if (this.matcher) {
for (const d of this.matcher.keys()) {
this.C += (this.C ? "|" : "") + d;
this.B += (this.B ? "|" : "") + d;
}
}
if (this.stemmer) {
for (const d of this.stemmer.keys()) {
this.P += (this.P ? "|" : "") + d;
this.N += (this.N ? "|" : "") + d;
}
}
return this;
};
G.prototype.encode = function(a) {
if (this.cache && a.length <= this.h) {
if (this.O) {
if (this.J.has(a)) {
return this.J.get(a);
if (this.M) {
if (this.H.has(a)) {
return this.H.get(a);
}
} else {
this.O = setTimeout(la, 0, this);
this.M = setTimeout(la, 0, this);
}
}
this.normalize && (a = "function" === typeof this.normalize ? this.normalize(a) : ka ? a.normalize("NFKD").replace(ka, "").toLowerCase() : a.toLowerCase());
@@ -176,20 +176,20 @@ G.prototype.encode = function(a) {
if (this.filter && this.filter.has(g)) {
continue;
}
if (this.cache && g.length <= this.B) {
if (this.O) {
var e = this.M.get(g);
if (this.cache && g.length <= this.A) {
if (this.M) {
var e = this.K.get(g);
if (e || "" === e) {
e && c.push(e);
continue;
}
} else {
this.O = setTimeout(la, 0, this);
this.M = setTimeout(la, 0, this);
}
}
let k;
this.stemmer && 2 < g.length && (this.T || (this.T = new RegExp("(?!^)(" + this.P + ")$")), g = g.replace(this.T, l => this.stemmer.get(l)), k = 1);
this.matcher && 1 < g.length && (this.S || (this.S = new RegExp("(" + this.C + ")", "g")), g = g.replace(this.S, l => this.matcher.get(l)), k = 1);
this.stemmer && 2 < g.length && (this.R || (this.R = new RegExp("(?!^)(" + this.N + ")$")), g = g.replace(this.R, l => this.stemmer.get(l)), k = 1);
this.matcher && 1 < g.length && (this.P || (this.P = new RegExp("(" + this.B + ")", "g")), g = g.replace(this.P, l => this.matcher.get(l)), k = 1);
g && k && (g.length < this.minlength || this.filter && this.filter.has(g)) && (g = "");
if (g && (this.mapper || this.dedupe && 1 < g.length)) {
e = "";
@@ -203,17 +203,17 @@ G.prototype.encode = function(a) {
g = g.replace(this.replacer[e], this.replacer[e + 1]);
}
}
this.cache && h.length <= this.B && (this.M.set(h, g), this.M.size > this.V && (this.M.clear(), this.B = this.B / 1.1 | 0));
this.cache && h.length <= this.A && (this.K.set(h, g), this.K.size > this.T && (this.K.clear(), this.A = this.A / 1.1 | 0));
g && c.push(g);
}
this.finalize && (c = this.finalize(c) || c);
this.cache && a.length <= this.h && (this.J.set(a, c), this.J.size > this.V && (this.J.clear(), this.h = this.h / 1.1 | 0));
this.cache && a.length <= this.h && (this.H.set(a, c), this.H.size > this.T && (this.H.clear(), this.h = this.h / 1.1 | 0));
return c;
};
function la(a) {
a.O = null;
a.J.clear();
a.M.clear();
a.M = null;
a.H.clear();
a.K.clear();
}
;function ma(a, b, c) {
a = ("object" === typeof a ? "" + a.query : a).toLowerCase();
@@ -376,9 +376,9 @@ function L(a = 8) {
return new L(a);
}
this.index = z();
this.C = [];
this.B = [];
this.size = 0;
32 < a ? (this.h = xa, this.B = BigInt(a)) : (this.h = ya, this.B = a);
32 < a ? (this.h = xa, this.A = BigInt(a)) : (this.h = ya, this.A = a);
}
L.prototype.get = function(a) {
const b = this.index[this.h(a)];
@@ -387,7 +387,7 @@ L.prototype.get = function(a) {
L.prototype.set = function(a, b) {
var c = this.h(a);
let d = this.index[c];
d ? (c = d.size, d.set(a, b), (c -= d.size) && this.size++) : (this.index[c] = d = new Map([[a, b]]), this.C.push(d));
d ? (c = d.size, d.set(a, b), (c -= d.size) && this.size++) : (this.index[c] = d = new Map([[a, b]]), this.B.push(d));
};
function M(a = 8) {
if (!this) {
@@ -395,20 +395,20 @@ function M(a = 8) {
}
this.index = z();
this.h = [];
32 < a ? (this.C = xa, this.B = BigInt(a)) : (this.C = ya, this.B = a);
32 < a ? (this.B = xa, this.A = BigInt(a)) : (this.B = ya, this.A = a);
}
M.prototype.add = function(a) {
var b = this.C(a);
var b = this.B(a);
let c = this.index[b];
c ? (b = c.size, c.add(a), (b -= c.size) && this.size++) : (this.index[b] = c = new Set([a]), this.h.push(c));
};
u = L.prototype;
u.has = M.prototype.has = function(a) {
const b = this.index[this.C(a)];
const b = this.index[this.B(a)];
return b && b.has(a);
};
u.delete = M.prototype.delete = function(a) {
const b = this.index[this.C(a)];
const b = this.index[this.B(a)];
b && b.delete(a) && this.size--;
};
u.clear = M.prototype.clear = function() {
@@ -438,18 +438,18 @@ u.entries = M.prototype.entries = function*() {
}
};
function ya(a) {
let b = 2 ** this.B - 1;
let b = 2 ** this.A - 1;
if ("number" == typeof a) {
return a & b;
}
let c = 0, d = this.B + 1;
let c = 0, d = this.A + 1;
for (let e = 0; e < a.length; e++) {
c = (c * d ^ a.charCodeAt(e)) & b;
}
return 32 === this.B ? c + 2 ** 31 : c;
return 32 === this.A ? c + 2 ** 31 : c;
}
function xa(a) {
let b = BigInt(2) ** this.B - BigInt(1);
let b = BigInt(2) ** this.A - BigInt(1);
var c = typeof a;
if ("bigint" === c) {
return a & b;
@@ -458,7 +458,7 @@ function xa(a) {
return BigInt(a) & b;
}
c = BigInt(0);
let d = this.B + BigInt(1);
let d = this.A + BigInt(1);
for (let e = 0; e < a.length; e++) {
c = (c * d ^ BigInt(a.charCodeAt(e))) & b;
}
@@ -493,7 +493,7 @@ function N(a) {
;z();
O.prototype.add = function(a, b, c, d) {
if (b && (a || 0 === a)) {
if (!d && !c && this.A.has(a)) {
if (!d && !c && this.reg.has(a)) {
return this.update(a, b);
}
b = this.encoder.encode(b);
@@ -532,7 +532,7 @@ O.prototype.add = function(a, b, c, d) {
}
default:
if (Q(this, m, p, f, a, c), n && 1 < d && r < d - 1) {
for (e = z(), g = this.U, f = p, h = Math.min(n + 1, d - r), e[f] = 1, k = 1; k < h; k++) {
for (e = z(), g = this.S, f = p, h = Math.min(n + 1, d - r), e[f] = 1, k = 1; k < h; k++) {
if ((p = b[this.rtl ? d - 1 - r - k : r + k]) && !e[p]) {
e[p] = 1;
const t = this.score ? this.score(b, f, r, p, k) : P(g + (d / 2 > g ? 0 : 1), d, r, h - 1, k - 1), x = this.bidirectional && p > f;
@@ -543,29 +543,29 @@ O.prototype.add = function(a, b, c, d) {
}
}
}
this.fastupdate || this.A.add(a);
this.fastupdate || this.reg.add(a);
} else {
b = "";
}
}
this.db && (b || this.K.push({del:a}), this.W && Ca(this));
this.db && (b || this.I.push({del:a}), this.U && Ca(this));
return this;
};
function Q(a, b, c, d, e, f, g) {
let h = g ? a.F : a.map, k;
let h = g ? a.ctx : a.map, k;
if (!b[c] || !g || !(k = b[c])[g]) {
if (g ? (b = k || (b[c] = z()), b[g] = 1, (k = h.get(g)) ? h = k : h.set(g, h = new Map())) : b[c] = 1, (k = h.get(c)) ? h = k : h.set(c, h = k = []), h = h[d] || (h[d] = []), !f || !h.includes(e)) {
if (h.length === 2 ** 31 - 1) {
b = new K(h);
if (a.fastupdate) {
for (let l of a.A.values()) {
for (let l of a.reg.values()) {
l.includes(h) && (l[l.indexOf(h)] = b);
}
}
k[d] = h = b;
}
h.push(e);
a.fastupdate && ((d = a.A.get(e)) ? d.push(h) : a.A.set(e, [h]));
a.fastupdate && ((d = a.reg.get(e)) ? d.push(h) : a.reg.set(e, [h]));
}
}
}
@@ -656,12 +656,12 @@ function Da(a) {
if (c.length) {
return Promise.all(c).then(function() {
a.result.length && (d = [a.result].concat(d));
a.result = Ea(d, e, f, g, h, a.G);
a.result = Ea(d, e, f, g, h, a.D);
return h ? a.result : a;
});
}
this.result.length && (d = [this.result].concat(d));
this.result = Ea(d, e, f, g, h, a.G);
this.result = Ea(d, e, f, g, h, a.D);
return h ? this.result : this;
};
function Ea(a, b, c, d, e, f) {
@@ -746,12 +746,12 @@ function Ea(a, b, c, d, e, f) {
if (a.length) {
return Promise.all(a).then(function() {
d = [b.result].concat(d);
b.result = Fa(d, e, f, g, b.G);
b.result = Fa(d, e, f, g, b.D);
return g ? b.result : b;
});
}
d = [this.result].concat(d);
this.result = Fa(d, e, f, g, b.G);
this.result = Fa(d, e, f, g, b.D);
return g ? this.result : this;
}
return this;
@@ -842,12 +842,12 @@ function Fa(a, b, c, d, e) {
if (c.length) {
return Promise.all(c).then(function() {
a.result.length && (d = [a.result].concat(d));
a.result = Ga(d, e, f, g, !h, a.G);
a.result = Ga(d, e, f, g, !h, a.D);
return h ? a.result : a;
});
}
this.result.length && (d = [this.result].concat(d));
this.result = Ga(d, e, f, g, !h, a.G);
this.result = Ga(d, e, f, g, !h, a.D);
return h ? this.result : this;
};
function Ga(a, b, c, d, e, f) {
@@ -957,7 +957,7 @@ function Ha(a, b) {
}
this.index = null;
this.result = a || [];
this.G = 0;
this.D = 0;
}
S.prototype.limit = function(a) {
if (this.result.length) {
@@ -987,7 +987,7 @@ S.prototype.offset = function(a) {
return this;
};
S.prototype.boost = function(a) {
this.G += a;
this.D += a;
return this;
};
S.prototype.resolve = function(a, b, c) {
@@ -1122,7 +1122,7 @@ O.prototype.search = function(a, b, c) {
return async function() {
for (let t, x; q < e; q++) {
x = a[q];
r ? (t = await V(p, x, r), t = Ka(t, d, f, p.U, b, g, 2 === e), f && !1 === t && d.length || (r = x)) : (t = await V(p, x), t = Ka(t, d, f, p.resolution, b, g, 1 === e));
r ? (t = await V(p, x, r), t = Ka(t, d, f, p.S, b, g, 2 === e), f && !1 === t && d.length || (r = x)) : (t = await V(p, x), t = Ka(t, d, f, p.resolution, b, g, 1 === e));
if (t) {
return t;
}
@@ -1146,7 +1146,7 @@ O.prototype.search = function(a, b, c) {
}
for (let p, t; q < e; q++) {
t = a[q];
r ? (p = V(this, t, r), p = Ka(p, d, f, this.U, b, g, 2 === e), f && !1 === p && d.length || (r = t)) : (p = V(this, t), p = Ka(p, d, f, this.resolution, b, g, 1 === e));
r ? (p = V(this, t, r), p = Ka(p, d, f, this.S, b, g, 2 === e), f && !1 === p && d.length || (r = t)) : (p = V(this, t), p = Ka(p, d, f, this.resolution, b, g, 1 === e));
if (p) {
return p;
}
@@ -1201,11 +1201,11 @@ function V(a, b, c, d, e, f, g, h) {
if (a.db) {
return c ? a.db.get(k ? c : b, k ? b : c, d, e, f, g, h) : a.db.get(b, "", d, e, f, g, h);
}
a = c ? (a = a.F.get(k ? b : c)) && a.get(k ? c : b) : a.map.get(b);
a = c ? (a = a.ctx.get(k ? b : c)) && a.get(k ? c : b) : a.map.get(b);
return a;
}
;O.prototype.remove = function(a, b) {
const c = this.A.size && (this.fastupdate ? this.A.get(a) : this.A.has(a));
const c = this.reg.size && (this.fastupdate ? this.reg.get(a) : this.reg.has(a));
if (c) {
if (this.fastupdate) {
for (let d = 0, e; d < c.length; d++) {
@@ -1219,11 +1219,11 @@ function V(a, b, c, d, e, f, g, h) {
}
}
} else {
La(this.map, a), this.depth && La(this.F, a);
La(this.map, a), this.depth && La(this.ctx, a);
}
b || this.A.delete(a);
b || this.reg.delete(a);
}
this.db && (this.K.push({del:a}), this.W && Ca(this));
this.db && (this.I.push({del:a}), this.U && Ca(this));
this.cache && this.cache.remove(a);
return this;
};
@@ -1270,17 +1270,17 @@ function La(a, b) {
this.score = a.score || null;
(e = a.keystore || 0) && (this.keystore = e);
this.map = e ? new L(e) : new Map();
this.F = e ? new L(e) : new Map();
this.A = b || (this.fastupdate ? e ? new L(e) : new Map() : e ? new M(e) : new Set());
this.U = c.resolution || 1;
this.ctx = e ? new L(e) : new Map();
this.reg = b || (this.fastupdate ? e ? new L(e) : new Map() : e ? new M(e) : new Set());
this.S = c.resolution || 1;
this.rtl = d.rtl || a.rtl || !1;
this.cache = (e = a.cache || null) && new H(e);
this.resolve = !1 !== a.resolve;
if (e = a.db) {
this.db = e.mount(this);
}
this.W = !1 !== a.commit;
this.K = [];
this.U = !1 !== a.commit;
this.I = [];
this.h = null;
}
u = O.prototype;
@@ -1300,17 +1300,17 @@ function Ca(a) {
}
u.clear = function() {
this.map.clear();
this.F.clear();
this.A.clear();
this.ctx.clear();
this.reg.clear();
this.cache && this.cache.clear();
this.db && (this.h && clearTimeout(this.h), this.h = null, this.K = [{clear:!0}]);
this.db && (this.h && clearTimeout(this.h), this.h = null, this.I = [{clear:!0}]);
return this;
};
u.append = function(a, b) {
return this.add(a, b, !0);
};
u.contain = function(a) {
return this.db ? this.db.has(a) : this.A.has(a);
return this.db ? this.db.has(a) : this.reg.has(a);
};
u.update = function(a, b) {
if (this.async) {
@@ -1338,7 +1338,7 @@ u.cleanup = function() {
return console.info('Cleanup the index isn\'t required when not using "fastupdate".'), this;
}
Ma(this.map);
this.depth && Ma(this.F);
this.depth && Ma(this.ctx);
return this;
};
u.searchCache = ma;
@@ -1353,16 +1353,16 @@ u.export = function(a, b, c, d, e, f) {
h = "reg";
if (this.fastupdate) {
k = z();
for (let l of this.A.keys()) {
for (let l of this.reg.keys()) {
k[l] = 1;
}
} else {
k = this.A;
k = this.reg;
}
break;
case 1:
h = "cfg";
k = {doc:0, opt:this.B ? 1 : 0};
k = {doc:0, opt:this.A ? 1 : 0};
break;
case 2:
h = "map";
@@ -1370,7 +1370,7 @@ u.export = function(a, b, c, d, e, f) {
break;
case 3:
h = "ctx";
k = this.F;
k = this.ctx;
break;
default:
"undefined" === typeof c && f && f();
@@ -1383,20 +1383,70 @@ u.import = function(a, b) {
if (b) {
switch(B(b) && (b = JSON.parse(b)), a) {
case "cfg":
this.B = !!b.opt;
this.A = !!b.opt;
break;
case "reg":
this.fastupdate = !1;
this.A = b;
this.reg = b;
break;
case "map":
this.map = b;
break;
case "ctx":
this.F = b;
this.ctx = b;
}
}
};
u.serialize = function(a = !0) {
if (!this.reg.size) {
return "";
}
let b = "", c = "";
for (var d of this.reg.keys()) {
c || (c = typeof d), b += (b ? "," : "") + ("string" === c ? '"' + d + '"' : d);
}
b = "index.reg=new Set([" + b + "]);";
d = "";
for (var e of this.map.entries()) {
var f = e[0], g = e[1], h = "";
for (let m = 0, n; m < g.length; m++) {
n = g[m] || [""];
var k = "";
for (var l = 0; l < n.length; l++) {
k += (k ? "," : "") + ("string" === c ? '"' + n[l] + '"' : n[l]);
}
k = "[" + k + "]";
h += (h ? "," : "") + k;
}
h = '["' + f + '",[' + h + "]]";
d += (d ? "," : "") + h;
}
d = "index.map=new Map([" + d + "]);";
e = "";
for (const m of this.ctx.entries()) {
f = m[0];
g = m[1];
for (const n of g.entries()) {
g = n[0];
h = n[1];
k = "";
for (let q = 0, r; q < h.length; q++) {
r = h[q] || [""];
l = "";
for (let p = 0; p < r.length; p++) {
l += (l ? "," : "") + ("string" === c ? '"' + r[p] + '"' : r[p]);
}
l = "[" + l + "]";
k += (k ? "," : "") + l;
}
k = 'new Map([["' + g + '",[' + k + "]]])";
k = '["' + f + '",' + k + "]";
e += (e ? "," : "") + k;
}
}
e = "index.ctx=new Map([" + e + "]);";
return a ? "function inject(index){" + b + d + e + "}" : b + d + e;
};
Ba(O.prototype);
async function Na(a) {
a = a.data;
@@ -1467,24 +1517,24 @@ function Pa(a, b, c) {
;Y.prototype.add = function(a, b, c) {
C(a) && (b = a, a = ca(b, this.key));
if (b && (a || 0 === a)) {
if (!c && this.A.has(a)) {
if (!c && this.reg.has(a)) {
return this.update(a, b);
}
for (let h = 0, k; h < this.field.length; h++) {
k = this.I[h];
k = this.G[h];
var d = this.index.get(this.field[h]);
if ("function" === typeof k) {
var e = k(b);
e && d.add(a, e, !1, !0);
} else {
if (e = k.L, !e || e(b)) {
k.constructor === String ? k = ["" + k] : B(k) && (k = [k]), Qa(b, k, this.N, 0, d, a, k[0], c);
if (e = k.J, !e || e(b)) {
k.constructor === String ? k = ["" + k] : B(k) && (k = [k]), Qa(b, k, this.L, 0, d, a, k[0], c);
}
}
}
if (this.tag) {
for (d = 0; d < this.H.length; d++) {
var f = this.H[d], g = this.R[d];
for (d = 0; d < this.F.length; d++) {
var f = this.F[d], g = this.O[d];
e = this.tag.get(g);
let h = z();
if ("function" === typeof f) {
@@ -1492,7 +1542,7 @@ function Pa(a, b, c) {
continue;
}
} else {
const k = f.L;
const k = f.J;
if (k && !k(b)) {
continue;
}
@@ -1506,14 +1556,14 @@ function Pa(a, b, c) {
if (m.length === 2 ** 31 - 1) {
g = new K(m);
if (this.fastupdate) {
for (let n of this.A.values()) {
for (let n of this.reg.values()) {
n.includes(m) && (n[n.indexOf(m)] = g);
}
}
e.set(l, m = g);
}
m.push(a);
this.fastupdate && ((g = this.A.get(a)) ? g.push(m) : this.A.set(a, [m]));
this.fastupdate && ((g = this.reg.get(a)) ? g.push(m) : this.reg.set(a, [m]));
}
}
} else {
@@ -1523,11 +1573,11 @@ function Pa(a, b, c) {
}
if (this.store && (!c || !this.store.has(a))) {
let h;
if (this.D) {
if (this.C) {
h = z();
for (let k = 0, l; k < this.D.length; k++) {
l = this.D[k];
if ((c = l.L) && !c(b)) {
for (let k = 0, l; k < this.C.length; k++) {
l = this.C[k];
if ((c = l.J) && !c(b)) {
continue;
}
let m;
@@ -1536,7 +1586,7 @@ function Pa(a, b, c) {
if (!m) {
continue;
}
l = [l.X];
l = [l.V];
} else if (B(l) || l.constructor === String) {
h[l] = b[l];
continue;
@@ -1673,7 +1723,7 @@ function Qa(a, b, c, d, e, f, g, h) {
let A;
for (let w = 0, v, I, J; w < k.length; w++) {
I = k[w];
if (this.db && this.tag && !this.I[w]) {
if (this.db && this.tag && !this.G[w]) {
continue;
}
let D;
@@ -1681,7 +1731,7 @@ function Qa(a, b, c, d, e, f, g, h) {
if (d) {
v = d[w];
} else {
if (t = D || c, x = this.index.get(I), n && (this.db && (t.tag = n, A = x.db.Z, t.field = k), A || (t.enrich = !1)), p) {
if (t = D || c, x = this.index.get(I), n && (this.db && (t.tag = n, A = x.db.X, t.field = k), A || (t.enrich = !1)), p) {
p[w] = x.searchAsync(a, b, t);
t && q && (t.enrich = q);
continue;
@@ -1822,13 +1872,13 @@ function Ta(a) {
}
const b = a.document || a.doc || a;
var c, d;
this.I = [];
this.G = [];
this.field = [];
this.N = [];
this.key = (c = b.key || b.id) && Va(c, this.N) || "id";
this.L = [];
this.key = (c = b.key || b.id) && Va(c, this.L) || "id";
(d = a.keystore || 0) && (this.keystore = d);
this.A = (this.fastupdate = !!a.fastupdate) ? d ? new L(d) : new Map() : d ? new M(d) : new Set();
this.D = (c = b.store || null) && !0 !== c && [];
this.reg = (this.fastupdate = !!a.fastupdate) ? d ? new L(d) : new Map() : d ? new M(d) : new Set();
this.C = (c = b.store || null) && !0 !== c && [];
this.store = c && (d ? new L(d) : new Map());
this.cache = (c = a.cache || null) && new H(c);
a.cache = !1;
@@ -1846,15 +1896,15 @@ function Ta(a) {
c.set(f, h);
h.worker || (this.worker = !1);
}
this.worker || c.set(f, new O(g, this.A));
g.custom ? this.I[e] = g.custom : (this.I[e] = Va(f, this.N), g.filter && ("string" === typeof this.I[e] && (this.I[e] = new String(this.I[e])), this.I[e].L = g.filter));
this.worker || c.set(f, new O(g, this.reg));
g.custom ? this.G[e] = g.custom : (this.G[e] = Va(f, this.L), g.filter && ("string" === typeof this.G[e] && (this.G[e] = new String(this.G[e])), this.G[e].J = g.filter));
this.field[e] = f;
}
if (this.D) {
if (this.C) {
d = b.store;
B(d) && (d = [d]);
for (let e = 0, f, g; e < d.length; e++) {
f = d[e], g = f.field || f, f.custom ? (this.D[e] = f.custom, f.custom.X = g) : (this.D[e] = Va(g, this.N), f.filter && ("string" === typeof this.D[e] && (this.D[e] = new String(this.D[e])), this.D[e].L = f.filter));
f = d[e], g = f.field || f, f.custom ? (this.C[e] = f.custom, f.custom.V = g) : (this.C[e] = Va(g, this.L), f.filter && ("string" === typeof this.C[e] && (this.C[e] = new String(this.C[e])), this.C[e].J = f.filter));
}
}
this.index = c;
@@ -1862,16 +1912,16 @@ function Ta(a) {
if (c = b.tag) {
if ("string" === typeof c && (c = [c]), c.length) {
this.tag = new Map();
this.H = [];
this.R = [];
this.F = [];
this.O = [];
for (let e = 0, f, g; e < c.length; e++) {
f = c[e];
g = f.field || f;
if (!g) {
throw Error("The tag field from the document descriptor is undefined.");
}
f.custom ? this.H[e] = f.custom : (this.H[e] = Va(g, this.N), f.filter && ("string" === typeof this.H[e] && (this.H[e] = new String(this.H[e])), this.H[e].L = f.filter));
this.R[e] = g;
f.custom ? this.F[e] = f.custom : (this.F[e] = Va(g, this.L), f.filter && ("string" === typeof this.F[e] && (this.F[e] = new String(this.F[e])), this.F[e].J = f.filter));
this.O[e] = g;
this.tag.set(g, new Map());
}
}
@@ -1882,10 +1932,10 @@ u = Y.prototype;
u.mount = function(a) {
let b = this.field;
if (this.tag) {
for (let e = 0, f; e < this.R.length; e++) {
f = this.R[e];
for (let e = 0, f; e < this.O.length; e++) {
f = this.O[e];
var c = this.index.get(f);
c || (this.index.set(f, c = new O({}, this.A)), b === this.field && (b = b.slice(0)), b.push(f));
c || (this.index.set(f, c = new O({}, this.reg)), b === this.field && (b = b.slice(0)), b.push(f));
c.tag = this.tag.get(f);
}
}
@@ -1898,7 +1948,7 @@ u.mount = function(a) {
h.id = a.id;
c[e] = h.mount(f);
f.document = !0;
e ? f.Y = !0 : f.store = this.store;
e ? f.W = !0 : f.store = this.store;
}
this.db = this.async = !0;
return Promise.all(c);
@@ -1909,7 +1959,7 @@ u.commit = async function(a, b) {
c.push(d.db.commit(d, a, b));
}
await Promise.all(c);
this.A.clear();
this.reg.clear();
};
function Va(a, b) {
const c = a.split(":");
@@ -1931,7 +1981,7 @@ u.remove = function(a) {
for (var b of this.index.values()) {
b.remove(a, !0);
}
if (this.A.has(a)) {
if (this.reg.has(a)) {
if (this.tag && !this.fastupdate) {
for (let c of this.tag.values()) {
for (let d of c) {
@@ -1942,7 +1992,7 @@ u.remove = function(a) {
}
}
this.store && this.store.delete(a);
this.A.delete(a);
this.reg.delete(a);
}
this.cache && this.cache.remove(a);
return this;
@@ -1960,7 +2010,7 @@ u.clear = function() {
return this;
};
u.contain = function(a) {
return this.db ? this.index.get(this.field[0]).db.has(a) : this.A.has(a);
return this.db ? this.index.get(this.field[0]).db.has(a) : this.reg.has(a);
};
u.cleanup = function() {
for (const a of this.index.values()) {
@@ -2018,9 +2068,9 @@ u.import = function(a, b) {
break;
case "reg":
this.fastupdate = !1;
this.A = b;
this.reg = b;
for (let d = 0, e; d < this.field.length; d++) {
e = this.index[this.field[d]], e.A = b, e.fastupdate = !1;
e = this.index[this.field[d]], e.reg = b, e.fastupdate = !1;
}
break;
case "store":
@@ -2044,7 +2094,7 @@ function Ya(a, b = {}) {
a || console.info("Default storage space was used, because a name was not passed.");
this.id = "flexsearch" + (a ? ":" + a.toLowerCase().replace(/[^a-z0-9_\-]/g, "") : "");
this.field = b.field ? b.field.toLowerCase().replace(/[^a-z0-9_\-]/g, "") : "";
this.Z = !1;
this.X = !1;
this.db = null;
this.h = {};
}
@@ -2184,22 +2234,22 @@ u.transaction = function(a, b, c) {
};
u.commit = async function(a, b, c) {
if (b) {
await this.clear(), a.K = [];
await this.clear(), a.I = [];
} else {
let d = a.K;
a.K = [];
let d = a.I;
a.I = [];
for (let e = 0, f; e < d.length; e++) {
if (f = d[e], f.clear) {
await this.clear();
b = !0;
break;
} else {
d[e] = f.$;
d[e] = f.Y;
}
}
b || (c || (d = d.concat(ba(a.A))), d.length && await this.remove(d));
b || (c || (d = d.concat(ba(a.reg))), d.length && await this.remove(d));
}
a.A.size && (await this.transaction("map", "readwrite", function(d) {
a.reg.size && (await this.transaction("map", "readwrite", function(d) {
for (const e of a.map) {
const f = e[0], g = e[1];
g.length && (b ? d.put(g, f) : d.get(f).onsuccess = function() {
@@ -2226,7 +2276,7 @@ u.commit = async function(a, b, c) {
});
}
}), await this.transaction("ctx", "readwrite", function(d) {
for (const e of a.F) {
for (const e of a.ctx) {
const f = e[0], g = e[1];
for (const h of g) {
const k = h[0], l = h[1];
@@ -2259,8 +2309,8 @@ u.commit = async function(a, b, c) {
const f = e[0], g = e[1];
d.put("object" === typeof g ? JSON.stringify(g) : 1, f);
}
}) : a.Y || await this.transaction("reg", "readwrite", function(d) {
for (const e of a.A.keys()) {
}) : a.W || await this.transaction("reg", "readwrite", function(d) {
for (const e of a.reg.keys()) {
d.put(1, e);
}
}), a.tag && await this.transaction("tag", "readwrite", function(d) {
@@ -2272,7 +2322,7 @@ u.commit = async function(a, b, c) {
d.put(h, f);
});
}
}), a.map.clear(), a.F.clear(), a.tag && a.tag.clear(), a.store && a.store.clear(), a.document || a.A.clear());
}), a.map.clear(), a.ctx.clear(), a.tag && a.tag.clear(), a.store && a.store.clear(), a.document || a.reg.clear());
};
function $a(a, b, c) {
const d = a.value;

View File

@@ -15,74 +15,76 @@ function B(a){return"string"===typeof a}function C(a){return"object"===typeof a}
["\u0477","\u0475"],["\u04c2","\u0436"],["\u04d1","\u0430"],["\u04d3","\u0430"],["\u04d7","\u0435"],["\u04db","\u04d9"],["\u04dd","\u0436"],["\u04df","\u0437"],["\u04e3","\u0438"],["\u04e5","\u0438"],["\u04e7","\u043e"],["\u04eb","\u04e9"],["\u04ed","\u044d"],["\u04ef","\u0443"],["\u04f1","\u0443"],["\u04f3","\u0443"],["\u04f5","\u0447"]];const fa=/[^\p{L}\p{N}]+/u,ha=/(\d{3})/g,ia=/(\D)(\d{3})/g,ja=/(\d{3})(\D)/g,ka="".normalize&&/[\u0300-\u036f]/g;function F(a){if(!this)return new F(...arguments);for(let b=0;b<arguments.length;b++)this.assign(arguments[b])}
F.prototype.assign=function(a){this.normalize=y(a.normalize,!0,this.normalize);let b=a.include,c=b||a.exclude||a.split;if("object"===typeof c){let d=!b,e="";a.include||(e+="\\p{Z}");c.letter&&(e+="\\p{L}");c.number&&(e+="\\p{N}",d=!!b);c.symbol&&(e+="\\p{S}");c.punctuation&&(e+="\\p{P}");c.control&&(e+="\\p{C}");if(c=c.char)e+="object"===typeof c?c.join(""):c;this.split=new RegExp("["+(b?"^":"")+e+"]+","u");this.numeric=d}else this.split=y(c,fa,this.split),this.numeric=y(this.numeric,!0);this.prepare=
y(a.prepare,null,this.prepare);this.finalize=y(a.finalize,null,this.finalize);ka||(this.mapper=new Map(ea));this.rtl=a.rtl||!1;this.dedupe=y(a.dedupe,!0,this.dedupe);this.filter=y((c=a.filter)&&new Set(c),null,this.filter);this.matcher=y((c=a.matcher)&&new Map(c),null,this.matcher);this.mapper=y((c=a.mapper)&&new Map(c),null,this.mapper);this.stemmer=y((c=a.stemmer)&&new Map(c),null,this.stemmer);this.replacer=y(a.replacer,null,this.replacer);this.minlength=y(a.minlength,1,this.minlength);this.maxlength=
y(a.maxlength,0,this.maxlength);if(this.cache=c=y(a.cache,!0,this.cache))this.O=null,this.V="number"===typeof c?c:2E5,this.J=new Map,this.M=new Map,this.B=this.h=128;this.C="";this.S=null;this.P="";this.T=null;if(this.matcher)for(const d of this.matcher.keys())this.C+=(this.C?"|":"")+d;if(this.stemmer)for(const d of this.stemmer.keys())this.P+=(this.P?"|":"")+d;return this};
F.prototype.encode=function(a){if(this.cache&&a.length<=this.h)if(this.O){if(this.J.has(a))return this.J.get(a)}else this.O=setTimeout(la,0,this);this.normalize&&(a="function"===typeof this.normalize?this.normalize(a):ka?a.normalize("NFKD").replace(ka,"").toLowerCase():a.toLowerCase());this.prepare&&(a=this.prepare(a));this.numeric&&3<a.length&&(a=a.replace(ia,"$1 $2").replace(ja,"$1 $2").replace(ha,"$1 "));const b=!(this.dedupe||this.mapper||this.filter||this.matcher||this.stemmer||this.replacer);
let c=[],d=this.split||""===this.split?a.split(this.split):a;for(let f=0,g,h;f<d.length;f++){if(!(g=h=d[f]))continue;if(g.length<this.minlength)continue;if(b){c.push(g);continue}if(this.filter&&this.filter.has(g))continue;if(this.cache&&g.length<=this.B)if(this.O){var e=this.M.get(g);if(e||""===e){e&&c.push(e);continue}}else this.O=setTimeout(la,0,this);let k;this.stemmer&&2<g.length&&(this.T||(this.T=new RegExp("(?!^)("+this.P+")$")),g=g.replace(this.T,l=>this.stemmer.get(l)),k=1);this.matcher&&
1<g.length&&(this.S||(this.S=new RegExp("("+this.C+")","g")),g=g.replace(this.S,l=>this.matcher.get(l)),k=1);g&&k&&(g.length<this.minlength||this.filter&&this.filter.has(g))&&(g="");if(g&&(this.mapper||this.dedupe&&1<g.length)){e="";for(let l=0,m="",n,q;l<g.length;l++)n=g.charAt(l),n===m&&this.dedupe||((q=this.mapper&&this.mapper.get(n))||""===q?q===m&&this.dedupe||!(m=q)||(e+=q):e+=m=n);g=e}if(g&&this.replacer)for(e=0;g&&e<this.replacer.length;e+=2)g=g.replace(this.replacer[e],this.replacer[e+1]);
this.cache&&h.length<=this.B&&(this.M.set(h,g),this.M.size>this.V&&(this.M.clear(),this.B=this.B/1.1|0));g&&c.push(g)}this.finalize&&(c=this.finalize(c)||c);this.cache&&a.length<=this.h&&(this.J.set(a,c),this.J.size>this.V&&(this.J.clear(),this.h=this.h/1.1|0));return c};function la(a){a.O=null;a.J.clear();a.M.clear()};function ma(a,b,c){a=("object"===typeof a?""+a.query:a).toLowerCase();let d=this.cache.get(a);if(!d){d=this.search(a,b,c);if(d.then){const e=this;d.then(function(f){e.cache.set(a,f);return f})}this.cache.set(a,d)}return d}function G(a){this.limit=a&&!0!==a?a:1E3;this.cache=new Map;this.h=""}G.prototype.set=function(a,b){this.cache.set(this.h=a,b);this.cache.size>this.limit&&this.cache.delete(this.cache.keys().next().value)};
y(a.maxlength,0,this.maxlength);if(this.cache=c=y(a.cache,!0,this.cache))this.M=null,this.T="number"===typeof c?c:2E5,this.H=new Map,this.K=new Map,this.A=this.h=128;this.B="";this.P=null;this.N="";this.R=null;if(this.matcher)for(const d of this.matcher.keys())this.B+=(this.B?"|":"")+d;if(this.stemmer)for(const d of this.stemmer.keys())this.N+=(this.N?"|":"")+d;return this};
F.prototype.encode=function(a){if(this.cache&&a.length<=this.h)if(this.M){if(this.H.has(a))return this.H.get(a)}else this.M=setTimeout(la,0,this);this.normalize&&(a="function"===typeof this.normalize?this.normalize(a):ka?a.normalize("NFKD").replace(ka,"").toLowerCase():a.toLowerCase());this.prepare&&(a=this.prepare(a));this.numeric&&3<a.length&&(a=a.replace(ia,"$1 $2").replace(ja,"$1 $2").replace(ha,"$1 "));const b=!(this.dedupe||this.mapper||this.filter||this.matcher||this.stemmer||this.replacer);
let c=[],d=this.split||""===this.split?a.split(this.split):a;for(let f=0,g,h;f<d.length;f++){if(!(g=h=d[f]))continue;if(g.length<this.minlength)continue;if(b){c.push(g);continue}if(this.filter&&this.filter.has(g))continue;if(this.cache&&g.length<=this.A)if(this.M){var e=this.K.get(g);if(e||""===e){e&&c.push(e);continue}}else this.M=setTimeout(la,0,this);let k;this.stemmer&&2<g.length&&(this.R||(this.R=new RegExp("(?!^)("+this.N+")$")),g=g.replace(this.R,l=>this.stemmer.get(l)),k=1);this.matcher&&
1<g.length&&(this.P||(this.P=new RegExp("("+this.B+")","g")),g=g.replace(this.P,l=>this.matcher.get(l)),k=1);g&&k&&(g.length<this.minlength||this.filter&&this.filter.has(g))&&(g="");if(g&&(this.mapper||this.dedupe&&1<g.length)){e="";for(let l=0,m="",n,q;l<g.length;l++)n=g.charAt(l),n===m&&this.dedupe||((q=this.mapper&&this.mapper.get(n))||""===q?q===m&&this.dedupe||!(m=q)||(e+=q):e+=m=n);g=e}if(g&&this.replacer)for(e=0;g&&e<this.replacer.length;e+=2)g=g.replace(this.replacer[e],this.replacer[e+1]);
this.cache&&h.length<=this.A&&(this.K.set(h,g),this.K.size>this.T&&(this.K.clear(),this.A=this.A/1.1|0));g&&c.push(g)}this.finalize&&(c=this.finalize(c)||c);this.cache&&a.length<=this.h&&(this.H.set(a,c),this.H.size>this.T&&(this.H.clear(),this.h=this.h/1.1|0));return c};function la(a){a.M=null;a.H.clear();a.K.clear()};function ma(a,b,c){a=("object"===typeof a?""+a.query:a).toLowerCase();let d=this.cache.get(a);if(!d){d=this.search(a,b,c);if(d.then){const e=this;d.then(function(f){e.cache.set(a,f);return f})}this.cache.set(a,d)}return d}function G(a){this.limit=a&&!0!==a?a:1E3;this.cache=new Map;this.h=""}G.prototype.set=function(a,b){this.cache.set(this.h=a,b);this.cache.size>this.limit&&this.cache.delete(this.cache.keys().next().value)};
G.prototype.get=function(a){const b=this.cache.get(a);b&&this.h!==a&&(this.cache.delete(a),this.cache.set(this.h=a,b));return b};G.prototype.remove=function(a){for(const b of this.cache){const c=b[0];b[1].includes(a)&&this.cache.delete(c)}};G.prototype.clear=function(){this.cache.clear();this.h=""};const na={normalize:function(a){return a.toLowerCase()},dedupe:!1};const oa=new Map([["b","p"],["v","f"],["w","f"],["z","s"],["x","s"],["d","t"],["n","m"],["c","k"],["g","k"],["j","k"],["q","k"],["i","e"],["y","e"],["u","o"]]);const pa=new Map([["ai","ei"],["ae","a"],["oe","o"],["ue","u"],["sh","s"],["ch","c"],["th","t"],["ph","f"],["pf","f"]]),qa=[/([^aeo])h([aeo$])/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2"];const ra={a:"",e:"",i:"",o:"",u:"",y:"",b:1,f:1,p:1,v:1,c:2,g:2,j:2,k:2,q:2,s:2,x:2,z:2,"\u00df":2,d:3,t:3,l:4,m:5,n:5,r:6};const sa=/[\x00-\x7F]+/g;const ta=/[\x00-\x7F]+/g;const ua=/[\x00-\x7F]+/g;var va={LatinExact:{normalize:!1,dedupe:!1},LatinDefault:na,LatinSimple:{normalize:!0,dedupe:!0},LatinBalance:{normalize:!0,dedupe:!0,mapper:oa},LatinAdvanced:{normalize:!0,dedupe:!0,mapper:oa,replacer:qa,matcher:pa},LatinExtra:{normalize:!0,dedupe:!0,mapper:oa,replacer:qa.concat([/(?!^)[aeoy]/g,""]),matcher:pa},LatinSoundex:{normalize:!0,dedupe:!1,include:{letter:!0},finalize:function(a){for(let c=0;c<a.length;c++){var b=a[c];let d=b.charAt(0),e=ra[d];for(let f=1,g;f<b.length&&(g=b.charAt(f),"h"===
g||"w"===g||!(g=ra[g])||g===e||(d+=g,e=g,4!==d.length));f++);a[c]=d}}},ArabicDefault:{rtl:!0,normalize:!1,dedupe:!0,prepare:function(a){return(""+a).replace(sa," ")}},CjkDefault:{normalize:!1,dedupe:!0,split:"",prepare:function(a){return(""+a).replace(ta,"")}},CyrillicDefault:{normalize:!1,dedupe:!0,prepare:function(a){return(""+a).replace(ua," ")}}};function wa(a,b,c,d){let e=[];for(let f=0,g;f<a.index.length;f++)if(g=a.index[f],b>=g.length)b-=g.length;else{b=g[d?"splice":"slice"](b,c);const h=b.length;if(h&&(e=e.length?e.concat(b):b,c-=h,d&&(a.length-=h),!c))break;b=0}return e}
function J(a){if(!this)return new J(a);this.index=a?[a]:[];this.length=a?a.length:0;const b=this;return new Proxy([],{get(c,d){if("length"===d)return b.length;if("push"===d)return function(e){b.index[b.index.length-1].push(e);b.length++};if("pop"===d)return function(){if(b.length)return b.length--,b.index[b.index.length-1].pop()};if("indexOf"===d)return function(e){let f=0;for(let g=0,h,k;g<b.index.length;g++){h=b.index[g];k=h.indexOf(e);if(0<=k)return f+k;f+=h.length}return-1};if("includes"===d)return function(e){for(let f=
0;f<b.index.length;f++)if(b.index[f].includes(e))return!0;return!1};if("slice"===d)return function(e,f){return wa(b,e||0,f||b.length,!1)};if("splice"===d)return function(e,f){return wa(b,e||0,f||b.length,!0)};if("constructor"===d)return Array;if("symbol"!==typeof d)return(c=b.index[d/2**31|0])&&c[d]},set(c,d,e){c=d/2**31|0;(b.index[c]||(b.index[c]=[]))[d]=e;b.length++;return!0}})}J.prototype.clear=function(){this.index.length=0};J.prototype.push=function(){};
function K(a=8){if(!this)return new K(a);this.index=z();this.C=[];this.size=0;32<a?(this.h=xa,this.B=BigInt(a)):(this.h=ya,this.B=a)}K.prototype.get=function(a){const b=this.index[this.h(a)];return b&&b.get(a)};K.prototype.set=function(a,b){var c=this.h(a);let d=this.index[c];d?(c=d.size,d.set(a,b),(c-=d.size)&&this.size++):(this.index[c]=d=new Map([[a,b]]),this.C.push(d))};function M(a=8){if(!this)return new M(a);this.index=z();this.h=[];32<a?(this.C=xa,this.B=BigInt(a)):(this.C=ya,this.B=a)}
M.prototype.add=function(a){var b=this.C(a);let c=this.index[b];c?(b=c.size,c.add(a),(b-=c.size)&&this.size++):(this.index[b]=c=new Set([a]),this.h.push(c))};u=K.prototype;u.has=M.prototype.has=function(a){const b=this.index[this.C(a)];return b&&b.has(a)};u.delete=M.prototype.delete=function(a){const b=this.index[this.C(a)];b&&b.delete(a)&&this.size--};u.clear=M.prototype.clear=function(){this.index=z();this.h=[];this.size=0};u.values=M.prototype.values=function*(){for(let a=0;a<this.h.length;a++)for(let b of this.h[a].values())yield b};
u.keys=M.prototype.keys=function*(){for(let a=0;a<this.h.length;a++)for(let b of this.h[a].keys())yield b};u.entries=M.prototype.entries=function*(){for(let a=0;a<this.h.length;a++)for(let b of this.h[a].entries())yield b};function ya(a){let b=2**this.B-1;if("number"==typeof a)return a&b;let c=0,d=this.B+1;for(let e=0;e<a.length;e++)c=(c*d^a.charCodeAt(e))&b;return 32===this.B?c+2**31:c}
function xa(a){let b=BigInt(2)**this.B-BigInt(1);var c=typeof a;if("bigint"===c)return a&b;if("number"===c)return BigInt(a)&b;c=BigInt(0);let d=this.B+BigInt(1);for(let e=0;e<a.length;e++)c=(c*d^BigInt(a.charCodeAt(e)))&b;return c};function za(a,b,c,d,e,f,g,h){(d=a(c?c+"."+d:d,JSON.stringify(g)))&&d.then?d.then(function(){b.export(a,b,c,e,f+1,h)}):b.export(a,b,c,e,f+1,h)};const Aa={memory:{resolution:1},performance:{resolution:6,fastupdate:!0,context:{depth:1,resolution:3}},match:{tokenize:"forward"},score:{resolution:9,context:{depth:2,resolution:9}}};function Ba(a){N.call(a,"add");N.call(a,"append");N.call(a,"search");N.call(a,"update");N.call(a,"remove")}function N(a){this[a+"Async"]=function(){var b=arguments;const c=b[b.length-1];let d;"function"===typeof c&&(d=c,delete b[b.length-1]);this.async=!0;b=this[a].apply(this,b);this.async=!1;d&&(b.then?b.then(d):d(b));return b}};z();O.prototype.add=function(a,b,c,d){if(b&&(a||0===a)){if(!d&&!c&&this.A.has(a))return this.update(a,b);b=this.encoder.encode(b);if(d=b.length){const l=z(),m=z(),n=this.depth,q=this.resolution;for(let r=0;r<d;r++){let p=b[this.rtl?d-1-r:r];var e=p.length;if(e&&(n||!m[p])){var f=this.score?this.score(b,p,r,null,0):P(q,d,r),g="";switch(this.tokenize){case "full":if(2<e){for(f=0;f<e;f++)for(var h=e;h>f;h--){g=p.substring(f,h);var k=this.score?this.score(b,p,r,g,f):P(q,d,r,e,f);Q(this,m,g,k,a,c)}break}case "reverse":if(1<
e){for(h=e-1;0<h;h--)g=p[h]+g,k=this.score?this.score(b,p,r,g,h):P(q,d,r,e,h),Q(this,m,g,k,a,c);g=""}case "forward":if(1<e){for(h=0;h<e;h++)g+=p[h],Q(this,m,g,f,a,c);break}default:if(Q(this,m,p,f,a,c),n&&1<d&&r<d-1)for(e=z(),g=this.U,f=p,h=Math.min(n+1,d-r),e[f]=1,k=1;k<h;k++)if((p=b[this.rtl?d-1-r-k:r+k])&&!e[p]){e[p]=1;const t=this.score?this.score(b,f,r,p,k):P(g+(d/2>g?0:1),d,r,h-1,k-1),x=this.bidirectional&&p>f;Q(this,l,x?f:p,t,a,c,x?p:f)}}}}this.fastupdate||this.A.add(a)}else b=""}this.db&&(b||
this.K.push({del:a}),this.W&&Ca(this));return this};function Q(a,b,c,d,e,f,g){let h=g?a.F:a.map,k;if(!b[c]||!g||!(k=b[c])[g])if(g?(b=k||(b[c]=z()),b[g]=1,(k=h.get(g))?h=k:h.set(g,h=new Map)):b[c]=1,(k=h.get(c))?h=k:h.set(c,h=k=[]),h=h[d]||(h[d]=[]),!f||!h.includes(e)){if(h.length===2**31-1){b=new J(h);if(a.fastupdate)for(let l of a.A.values())l.includes(h)&&(l[l.indexOf(h)]=b);k[d]=h=b}h.push(e);a.fastupdate&&((d=a.A.get(e))?d.push(h):a.A.set(e,[h]))}}
function K(a=8){if(!this)return new K(a);this.index=z();this.B=[];this.size=0;32<a?(this.h=xa,this.A=BigInt(a)):(this.h=ya,this.A=a)}K.prototype.get=function(a){const b=this.index[this.h(a)];return b&&b.get(a)};K.prototype.set=function(a,b){var c=this.h(a);let d=this.index[c];d?(c=d.size,d.set(a,b),(c-=d.size)&&this.size++):(this.index[c]=d=new Map([[a,b]]),this.B.push(d))};function M(a=8){if(!this)return new M(a);this.index=z();this.h=[];32<a?(this.B=xa,this.A=BigInt(a)):(this.B=ya,this.A=a)}
M.prototype.add=function(a){var b=this.B(a);let c=this.index[b];c?(b=c.size,c.add(a),(b-=c.size)&&this.size++):(this.index[b]=c=new Set([a]),this.h.push(c))};u=K.prototype;u.has=M.prototype.has=function(a){const b=this.index[this.B(a)];return b&&b.has(a)};u.delete=M.prototype.delete=function(a){const b=this.index[this.B(a)];b&&b.delete(a)&&this.size--};u.clear=M.prototype.clear=function(){this.index=z();this.h=[];this.size=0};u.values=M.prototype.values=function*(){for(let a=0;a<this.h.length;a++)for(let b of this.h[a].values())yield b};
u.keys=M.prototype.keys=function*(){for(let a=0;a<this.h.length;a++)for(let b of this.h[a].keys())yield b};u.entries=M.prototype.entries=function*(){for(let a=0;a<this.h.length;a++)for(let b of this.h[a].entries())yield b};function ya(a){let b=2**this.A-1;if("number"==typeof a)return a&b;let c=0,d=this.A+1;for(let e=0;e<a.length;e++)c=(c*d^a.charCodeAt(e))&b;return 32===this.A?c+2**31:c}
function xa(a){let b=BigInt(2)**this.A-BigInt(1);var c=typeof a;if("bigint"===c)return a&b;if("number"===c)return BigInt(a)&b;c=BigInt(0);let d=this.A+BigInt(1);for(let e=0;e<a.length;e++)c=(c*d^BigInt(a.charCodeAt(e)))&b;return c};function za(a,b,c,d,e,f,g,h){(d=a(c?c+"."+d:d,JSON.stringify(g)))&&d.then?d.then(function(){b.export(a,b,c,e,f+1,h)}):b.export(a,b,c,e,f+1,h)};const Aa={memory:{resolution:1},performance:{resolution:6,fastupdate:!0,context:{depth:1,resolution:3}},match:{tokenize:"forward"},score:{resolution:9,context:{depth:2,resolution:9}}};function Ba(a){N.call(a,"add");N.call(a,"append");N.call(a,"search");N.call(a,"update");N.call(a,"remove")}function N(a){this[a+"Async"]=function(){var b=arguments;const c=b[b.length-1];let d;"function"===typeof c&&(d=c,delete b[b.length-1]);this.async=!0;b=this[a].apply(this,b);this.async=!1;d&&(b.then?b.then(d):d(b));return b}};z();O.prototype.add=function(a,b,c,d){if(b&&(a||0===a)){if(!d&&!c&&this.reg.has(a))return this.update(a,b);b=this.encoder.encode(b);if(d=b.length){const l=z(),m=z(),n=this.depth,q=this.resolution;for(let r=0;r<d;r++){let p=b[this.rtl?d-1-r:r];var e=p.length;if(e&&(n||!m[p])){var f=this.score?this.score(b,p,r,null,0):P(q,d,r),g="";switch(this.tokenize){case "full":if(2<e){for(f=0;f<e;f++)for(var h=e;h>f;h--){g=p.substring(f,h);var k=this.score?this.score(b,p,r,g,f):P(q,d,r,e,f);Q(this,m,g,k,a,c)}break}case "reverse":if(1<
e){for(h=e-1;0<h;h--)g=p[h]+g,k=this.score?this.score(b,p,r,g,h):P(q,d,r,e,h),Q(this,m,g,k,a,c);g=""}case "forward":if(1<e){for(h=0;h<e;h++)g+=p[h],Q(this,m,g,f,a,c);break}default:if(Q(this,m,p,f,a,c),n&&1<d&&r<d-1)for(e=z(),g=this.S,f=p,h=Math.min(n+1,d-r),e[f]=1,k=1;k<h;k++)if((p=b[this.rtl?d-1-r-k:r+k])&&!e[p]){e[p]=1;const t=this.score?this.score(b,f,r,p,k):P(g+(d/2>g?0:1),d,r,h-1,k-1),x=this.bidirectional&&p>f;Q(this,l,x?f:p,t,a,c,x?p:f)}}}}this.fastupdate||this.reg.add(a)}else b=""}this.db&&
(b||this.I.push({del:a}),this.U&&Ca(this));return this};function Q(a,b,c,d,e,f,g){let h=g?a.ctx:a.map,k;if(!b[c]||!g||!(k=b[c])[g])if(g?(b=k||(b[c]=z()),b[g]=1,(k=h.get(g))?h=k:h.set(g,h=new Map)):b[c]=1,(k=h.get(c))?h=k:h.set(c,h=k=[]),h=h[d]||(h[d]=[]),!f||!h.includes(e)){if(h.length===2**31-1){b=new J(h);if(a.fastupdate)for(let l of a.reg.values())l.includes(h)&&(l[l.indexOf(h)]=b);k[d]=h=b}h.push(e);a.fastupdate&&((d=a.reg.get(e))?d.push(h):a.reg.set(e,[h]))}}
function P(a,b,c,d,e){return c&&1<a?b+(d||0)<=a?c+(e||0):(a-1)/(b+(d||0))*(c+(e||0))+1|0:0};function R(a,b,c,d){if(1===a.length)return a=a[0],a=c||a.length>b?b?a.slice(c,c+b):a.slice(c):a,d?Da(a):a;let e=[];for(let f=0,g,h;f<a.length;f++)if((g=a[f])&&(h=g.length)){if(c){if(c>=h){c-=h;continue}c<h&&(g=b?g.slice(c,c+b):g.slice(c),h=g.length,c=0)}if(e.length)h>b&&(g=g.slice(0,b),h=g.length),e.push(g);else{if(h>=b)return h>b&&(g=g.slice(0,b)),d?Da(g):g;e=[g]}b-=h;if(!b)break}if(!e.length)return e;e=1<e.length?[].concat.apply([],e):e[0];return d?Da(e):e}
function Da(a){for(let b=0;b<a.length;b++)a[b]={score:b,id:a[b]};return a};S.prototype.or=function(){const a=this;let b=arguments;var c=b[0];if(c.then)return c.then(function(){return a.or.apply(a,b)});if(c[0]&&c[0].index)return this.or.apply(this,c);let d=[];c=[];let e=0,f=0,g,h;for(let k=0,l;k<b.length;k++)if(l=b[k]){let m;if(l.constructor===S)m=l.result;else if(l.constructor===Array)m=l;else if(l.index)l.resolve=!1,m=l.index.search(l).result;else if(l.and)m=this.and(l.and);else if(l.xor)m=this.xor(l.xor);else if(l.not)m=this.not(l.not);else{e=l.limit||0;f=l.offset||0;
g=l.enrich;h=l.resolve;continue}d[k]=m;m.then&&c.push(m)}if(c.length)return Promise.all(c).then(function(){a.result.length&&(d=[a.result].concat(d));a.result=Ea(d,e,f,g,h,a.G);return h?a.result:a});this.result.length&&(d=[this.result].concat(d));this.result=Ea(d,e,f,g,h,a.G);return h?this.result:this};
g=l.enrich;h=l.resolve;continue}d[k]=m;m.then&&c.push(m)}if(c.length)return Promise.all(c).then(function(){a.result.length&&(d=[a.result].concat(d));a.result=Ea(d,e,f,g,h,a.D);return h?a.result:a});this.result.length&&(d=[this.result].concat(d));this.result=Ea(d,e,f,g,h,a.D);return h?this.result:this};
function Ea(a,b,c,d,e,f){if(!a.length)return a;"object"===typeof b&&(c=b.offset||0,d=b.enrich||!1,b=b.limit||0);if(2>a.length)return e?R(a[0],b,c,d):a[0];d=[];let g=0,h=z(),k=da(a);for(let l=0,m;l<k;l++)for(let n=0,q;n<a.length;n++)if(q=a[n])if(m=q[l])for(let r=0,p;r<m.length;r++)if(p=m[r],!h[p])if(h[p]=1,c)c--;else{if(e)d.push(p);else{const t=l+(n?f:0);d[t]||(d[t]=[]);d[t].push(p)}if(b&&++g===b)return d}return d};S.prototype.and=function(){if(this.result.length){const b=this;let c=arguments;var a=c[0];if(a.then)return a.then(function(){return b.and.apply(b,c)});if(a[0]&&a[0].index)return this.and.apply(this,a);let d=[];a=[];let e=0,f=0,g;for(let h=0,k;h<c.length;h++)if(k=c[h]){let l;if(k.constructor===S)l=k.result;else if(k.constructor===Array)l=k;else if(k.index)k.resolve=!1,l=k.index.search(k).result;else if(k.or)l=this.or(k.or);else if(k.xor)l=this.xor(k.xor);else if(k.not)l=this.not(k.not);else{e=k.limit||
0;f=k.offset||0;g=k.resolve;continue}d[h]=l;l.then&&a.push(l)}if(a.length)return Promise.all(a).then(function(){d=[b.result].concat(d);b.result=Fa(d,e,f,g,b.G);return g?b.result:b});d=[this.result].concat(d);this.result=Fa(d,e,f,g,b.G);return g?this.result:this}return this};
0;f=k.offset||0;g=k.resolve;continue}d[h]=l;l.then&&a.push(l)}if(a.length)return Promise.all(a).then(function(){d=[b.result].concat(d);b.result=Fa(d,e,f,g,b.D);return g?b.result:b});d=[this.result].concat(d);this.result=Fa(d,e,f,g,b.D);return g?this.result:this}return this};
function Fa(a,b,c,d,e){if(2>a.length)return[];let f=[],g=0,h=z(),k=da(a);if(!k)return f;for(let l=0,m;l<a.length;l++){m=a[l];if(!m||!m.length)return[];let n=z(),q=0,r=l===a.length-1;for(let p=0,t;p<k;p++)if(t=m[p])for(let x=0,A,w;x<t.length;x++)if(A=t[x],!l)n[A]=p+1+(l?e:0),q=1;else if(r){if(w=h[A])if(q=1,c)c--;else if(d?f.push(A):(w--,p<w&&(w=p),f[w]||(f[w]=[]),f[w].push(A)),b&&++g===b)return f}else if(w=h[A])p+1<w&&(w=p+1),n[A]=w,q=1;if(!q)return[];h=n}return f};S.prototype.xor=function(){const a=this;let b=arguments;var c=b[0];if(c.then)return c.then(function(){return a.xor.apply(a,b)});if(c[0]&&c[0].index)return this.xor.apply(this,c);let d=[];c=[];let e=0,f=0,g,h;for(let k=0,l;k<b.length;k++)if(l=b[k]){let m;if(l.constructor===S)m=l.result;else if(l.constructor===Array)m=l;else if(l.index)l.resolve=!1,m=l.index.search(l).result;else if(l.or)m=this.or(l.or);else if(l.and)m=this.and(l.and);else if(l.not)m=this.not(l.not);else{e=l.limit||0;f=l.offset||0;
g=l.enrich;h=l.resolve;continue}d[k]=m;m.then&&c.push(m)}if(c.length)return Promise.all(c).then(function(){a.result.length&&(d=[a.result].concat(d));a.result=Ga(d,e,f,g,!h,a.G);return h?a.result:a});this.result.length&&(d=[this.result].concat(d));this.result=Ga(d,e,f,g,!h,a.G);return h?this.result:this};
g=l.enrich;h=l.resolve;continue}d[k]=m;m.then&&c.push(m)}if(c.length)return Promise.all(c).then(function(){a.result.length&&(d=[a.result].concat(d));a.result=Ga(d,e,f,g,!h,a.D);return h?a.result:a});this.result.length&&(d=[this.result].concat(d));this.result=Ga(d,e,f,g,!h,a.D);return h?this.result:this};
function Ga(a,b,c,d,e,f){if(!a.length)return a;if(2>a.length)return e?R(a[0],b,c,d):a[0];b=[];c=z();for(let g=0,h;g<a.length;g++)if(h=a[g])for(let k=0,l;k<h.length;k++)if(l=h[k])for(let m=0,n;m<l.length;m++)n=l[m],c[n]?c[n]++:c[n]=1;for(let g=0,h;g<a.length;g++)if(h=a[g])for(let k=0,l;k<h.length;k++)if(l=h[k])for(let m=0,n;m<l.length;m++)n=l[m],1===c[n]&&(e?b.push(n):(d=k+(g?f:0),b[d]||(b[d]=[]),b[d].push(n)));return b};S.prototype.not=function(){const a=this;let b=arguments;var c=b[0];if(c.then)return c.then(function(){return a.not.apply(a,b)});if(c[0]&&c[0].index)return this.not.apply(this,c);let d=[];c=[];let e;for(let f=0,g;f<b.length;f++)if(g=b[f]){let h;if(g.constructor===S)h=g.result;else if(g.constructor===Array)h=g;else if(g.index)g.resolve=!1,h=g.index.search(g).result;else if(g.or)h=this.or(g.or);else if(g.and)h=this.and(g.and);else if(g.xor)h=this.xor(g.xor);else{e=g.resolve;continue}d[f]=h;h.then&&c.push(h)}if(c.length)return Promise.all(c).then(function(){a.result=
Ha.call(a,d,e);return e?a.result:a});this.result=Ha.call(this,d,e);return e?this.result:this};function Ha(a,b){if(!a.length)return this.result;const c=[];a=new Set(a.flat().flat());for(let d=0,e;d<this.result.length;d++)if(e=this.result[d])for(let f=0,g;f<e.length;f++)g=e[f],a.has(g)||(b?c.push(g):(c[d]||(c[d]=[]),c[d].push(g)));return c};function S(a){if(!this)return new S(a);if(a&&a.index)return a.resolve=!1,this.index=a.index,a.index.search(a);if(a.constructor===S)return a;this.index=null;this.result=a||[];this.G=0}S.prototype.limit=function(a){if(this.result.length){const b=[];let c=0;for(let d=0,e;d<this.result.length;d++)if(e=this.result[d],e.length+c<a)b[d]=e,c+=e.length;else{b[d]=e.slice(0,a-c);this.result=b;break}}return this};
S.prototype.offset=function(a){if(this.result.length){const b=[];let c=0;for(let d=0,e;d<this.result.length;d++)e=this.result[d],e.length+c<a?c+=e.length:(b[d]=e.slice(a-c),c=a);this.result=b}return this};S.prototype.boost=function(a){this.G+=a;return this};S.prototype.resolve=function(a,b,c){T=1;const d=this.result;this.result=this.index=null;return d.length?("object"===typeof a&&(c=a.enrich,b=a.offset,a=a.limit),R(d,a||100,b,c)):d};function Ia(a,b,c,d,e){var f=a.length,g=[],h;var k=z();for(let n=0,q,r,p,t;n<b;n++)for(var l=0;l<f;l++)if(p=a[l],n<p.length&&(q=p[n]))for(var m=0;m<q.length;m++)r=q[m],(h=k[r])?k[r]++:(h=0,k[r]=1),t=g[h]||(g[h]=[]),t.push(r);if(a=g.length)if(e){if(1<g.length){e=g;f=[];g=z();k=e.length;for(l=0;l<k;l++)for(a=e[l],h=a.length,m=0;m<h;m++)if(b=a[m],!g[b])if(g[b]=1,d)d--;else if(f.push(b),f.length===c)break;c=f}else c=g[0];g=c}else{if(a<f)return[];g=g[a-1];if(g.length>c||d)g=g.slice(d,c+d)}return g}
Ha.call(a,d,e);return e?a.result:a});this.result=Ha.call(this,d,e);return e?this.result:this};function Ha(a,b){if(!a.length)return this.result;const c=[];a=new Set(a.flat().flat());for(let d=0,e;d<this.result.length;d++)if(e=this.result[d])for(let f=0,g;f<e.length;f++)g=e[f],a.has(g)||(b?c.push(g):(c[d]||(c[d]=[]),c[d].push(g)));return c};function S(a){if(!this)return new S(a);if(a&&a.index)return a.resolve=!1,this.index=a.index,a.index.search(a);if(a.constructor===S)return a;this.index=null;this.result=a||[];this.D=0}S.prototype.limit=function(a){if(this.result.length){const b=[];let c=0;for(let d=0,e;d<this.result.length;d++)if(e=this.result[d],e.length+c<a)b[d]=e,c+=e.length;else{b[d]=e.slice(0,a-c);this.result=b;break}}return this};
S.prototype.offset=function(a){if(this.result.length){const b=[];let c=0;for(let d=0,e;d<this.result.length;d++)e=this.result[d],e.length+c<a?c+=e.length:(b[d]=e.slice(a-c),c=a);this.result=b}return this};S.prototype.boost=function(a){this.D+=a;return this};S.prototype.resolve=function(a,b,c){T=1;const d=this.result;this.result=this.index=null;return d.length?("object"===typeof a&&(c=a.enrich,b=a.offset,a=a.limit),R(d,a||100,b,c)):d};function Ia(a,b,c,d,e){var f=a.length,g=[],h;var k=z();for(let n=0,q,r,p,t;n<b;n++)for(var l=0;l<f;l++)if(p=a[l],n<p.length&&(q=p[n]))for(var m=0;m<q.length;m++)r=q[m],(h=k[r])?k[r]++:(h=0,k[r]=1),t=g[h]||(g[h]=[]),t.push(r);if(a=g.length)if(e){if(1<g.length){e=g;f=[];g=z();k=e.length;for(l=0;l<k;l++)for(a=e[l],h=a.length,m=0;m<h;m++)if(b=a[m],!g[b])if(g[b]=1,d)d--;else if(f.push(b),f.length===c)break;c=f}else c=g[0];g=c}else{if(a<f)return[];g=g[a-1];if(g.length>c||d)g=g.slice(d,c+d)}return g}
function Ja(a,b){const c=z(),d=z(),e=[];for(let f=0;f<a.length;f++)c[a[f]]=1;for(let f=0,g;f<b.length;f++){g=b[f];for(let h=0,k;h<g.length;h++)k=g[h],c[k]&&!d[k]&&(d[k]=1,e.push(k))}return e};let T=1;
O.prototype.search=function(a,b,c){c||(!b&&C(a)?(c=a,a=""):C(b)&&(c=b,b=0));let d=[],e;let f,g=0,h,k,l;if(c){a=c.query||a;b=c.limit||b;g=c.offset||0;var m=c.context;f=c.suggest;(h=T&&!1!==c.resolve)||(T=0);k=h&&c.enrich;l=this.db&&c.tag}else h=this.resolve||T;a=this.encoder.encode(a);e=a.length;b||!h||(b=100);if(1===e)return U.call(this,a[0],"",b,g,h,k,l);m=this.depth&&!1!==m;if(2===e&&m&&!f)return U.call(this,a[0],a[1],b,g,h,k,l);let n=c=0;if(1<e){const p=z(),t=[];for(let x=0,A;x<e;x++)if((A=a[x])&&
!p[A]){if(f||this.db||V(this,A))t.push(A),p[A]=1;else return h?d:new S(d);const w=A.length;c=Math.max(c,w);n=n?Math.min(n,w):w}a=t;e=a.length}if(!e)return h?d:new S(d);let q=0,r;if(1===e)return U.call(this,a[0],"",b,g,h,k,l);if(2===e&&m&&!f)return U.call(this,a[0],a[1],b,g,h,k,l);1<e&&(m?(r=a[0],q=1):9<c&&3<c/n&&a.sort(aa));if(this.db){if(this.db.search&&(m=this.db.search(this,a,b,g,f,h,k,l),!1!==m))return m;const p=this;return async function(){for(let t,x;q<e;q++){x=a[q];r?(t=await V(p,x,r),t=Ka(t,
d,f,p.U,b,g,2===e),f&&!1===t&&d.length||(r=x)):(t=await V(p,x),t=Ka(t,d,f,p.resolution,b,g,1===e));if(t)return t;if(f&&q===e-1){let A=d.length;if(!A){if(r){r="";q=-1;continue}return d}if(1===A)return h?R(d[0],b,g):new S(d[0])}}return h?Ia(d,p.resolution,b,g,f):new S(d[0])}()}for(let p,t;q<e;q++){t=a[q];r?(p=V(this,t,r),p=Ka(p,d,f,this.U,b,g,2===e),f&&!1===p&&d.length||(r=t)):(p=V(this,t),p=Ka(p,d,f,this.resolution,b,g,1===e));if(p)return p;if(f&&q===e-1){m=d.length;if(!m){if(r){r="";q=-1;continue}return d}if(1===
d,f,p.S,b,g,2===e),f&&!1===t&&d.length||(r=x)):(t=await V(p,x),t=Ka(t,d,f,p.resolution,b,g,1===e));if(t)return t;if(f&&q===e-1){let A=d.length;if(!A){if(r){r="";q=-1;continue}return d}if(1===A)return h?R(d[0],b,g):new S(d[0])}}return h?Ia(d,p.resolution,b,g,f):new S(d[0])}()}for(let p,t;q<e;q++){t=a[q];r?(p=V(this,t,r),p=Ka(p,d,f,this.S,b,g,2===e),f&&!1===p&&d.length||(r=t)):(p=V(this,t),p=Ka(p,d,f,this.resolution,b,g,1===e));if(p)return p;if(f&&q===e-1){m=d.length;if(!m){if(r){r="";q=-1;continue}return d}if(1===
m)return h?R(d[0],b,g):new S(d[0])}}d=Ia(d,this.resolution,b,g,f);return h?d:new S(d)};function U(a,b,c,d,e,f,g){a=V(this,a,b,c,d,e,f,g);return this.db?a.then(function(h){return e?h:h&&h.length?e?R(h,c,d):new S(h):e?[]:new S([])}):a&&a.length?e?R(a,c,d):new S(a):e?[]:new S([])}
function Ka(a,b,c,d,e,f,g){let h=[];if(a){d=Math.min(a.length,d);for(let k=0,l=0,m;k<d;k++)if(m=a[k])if(f&&m&&g&&(m.length<=f?(f-=m.length,m=null):(m=m.slice(f),f=0)),m&&(h[k]=m,g&&(l+=m.length,l>=e)))break;if(h.length){if(g)return R(h,e,0);b.push(h);return}}return!c&&h}function V(a,b,c,d,e,f,g,h){let k;c&&(k=a.bidirectional&&b>c);if(a.db)return c?a.db.get(k?c:b,k?b:c,d,e,f,g,h):a.db.get(b,"",d,e,f,g,h);a=c?(a=a.F.get(k?b:c))&&a.get(k?c:b):a.map.get(b);return a};O.prototype.remove=function(a,b){const c=this.A.size&&(this.fastupdate?this.A.get(a):this.A.has(a));if(c){if(this.fastupdate)for(let d=0,e;d<c.length;d++){if(e=c[d])if(2>e.length)e.pop();else{const f=e.indexOf(a);f===c.length-1?e.pop():e.splice(f,1)}}else La(this.map,a),this.depth&&La(this.F,a);b||this.A.delete(a)}this.db&&(this.K.push({del:a}),this.W&&Ca(this));this.cache&&this.cache.remove(a);return this};
function La(a,b){let c=0;if(a.constructor===Array)for(let d=0,e,f;d<a.length;d++){if((e=a[d])&&e.length)if(f=e.indexOf(b),0<=f){1<e.length?(e.splice(f,1),c++):delete a[d];break}else c++}else for(let d of a){const e=d[0],f=La(d[1],b);f?c+=f:a.delete(e)}return c};function O(a,b){if(!this)return new O(a);if(a){var c=B(a)?a:a.preset;c&&(a=Object.assign({},Aa[c],a))}else a={};c=a.context||{};const d=a.encode||a.encoder||na;this.encoder=d.encode?d:"object"===typeof d?new F(d):{encode:d};let e;this.resolution=a.resolution||9;this.tokenize=e=a.tokenize||"strict";this.depth="strict"===e&&c.depth||0;this.bidirectional=!1!==c.bidirectional;this.fastupdate=!!a.fastupdate;this.score=a.score||null;(e=a.keystore||0)&&(this.keystore=e);this.map=e?new K(e):new Map;this.F=
e?new K(e):new Map;this.A=b||(this.fastupdate?e?new K(e):new Map:e?new M(e):new Set);this.U=c.resolution||1;this.rtl=d.rtl||a.rtl||!1;this.cache=(e=a.cache||null)&&new G(e);this.resolve=!1!==a.resolve;if(e=a.db)this.db=e.mount(this);this.W=!1!==a.commit;this.K=[];this.h=null}u=O.prototype;u.mount=function(a){this.h&&(clearTimeout(this.h),this.h=null);return a.mount(this)};u.commit=function(a,b){this.h&&(clearTimeout(this.h),this.h=null);return this.db.commit(this,a,b)};
function Ca(a){a.h||(a.h=setTimeout(function(){a.h=null;a.db.commit(a,void 0,void 0)},0))}u.clear=function(){this.map.clear();this.F.clear();this.A.clear();this.cache&&this.cache.clear();this.db&&(this.h&&clearTimeout(this.h),this.h=null,this.K=[{clear:!0}]);return this};u.append=function(a,b){return this.add(a,b,!0)};u.contain=function(a){return this.db?this.db.has(a):this.A.has(a)};
u.update=function(a,b){if(this.async){const c=this,d=this.remove(a);return d.then?d.then(()=>c.add(a,b)):this.add(a,b)}return this.remove(a).add(a,b)};function Ma(a){let b=0;if(a.constructor===Array)for(let c=0,d;c<a.length;c++)(d=a[c])&&(b+=d.length);else for(const c of a){const d=c[0],e=Ma(c[1]);e?b+=e:a.delete(d)}return b}u.cleanup=function(){if(!this.fastupdate)return this;Ma(this.map);this.depth&&Ma(this.F);return this};u.searchCache=ma;
u.export=function(a,b,c,d,e,f){let g=!0;"undefined"===typeof f&&(g=new Promise(l=>{f=l}));let h,k;switch(e||(e=0)){case 0:h="reg";if(this.fastupdate){k=z();for(let l of this.A.keys())k[l]=1}else k=this.A;break;case 1:h="cfg";k={doc:0,opt:this.B?1:0};break;case 2:h="map";k=this.map;break;case 3:h="ctx";k=this.F;break;default:"undefined"===typeof c&&f&&f();return}za(a,b||this,c,h,d,e,k,f);return g};
u.import=function(a,b){if(b)switch(B(b)&&(b=JSON.parse(b)),a){case "cfg":this.B=!!b.opt;break;case "reg":this.fastupdate=!1;this.A=b;break;case "map":this.map=b;break;case "ctx":this.F=b}};Ba(O.prototype);async function Na(a){a=a.data;var b=self._index;const c=a.args;var d=a.task;switch(d){case "init":d=a.options||{};(b=d.config)&&(d=await import(b));(b=a.factory)?(Function("return "+b)()(self),self._index=new self.FlexSearch.Index(d),delete self.FlexSearch):self._index=new O(d);postMessage({id:a.id});break;default:a=a.id,b=b[d].apply(b,c),postMessage("search"===d?{id:a,msg:b}:{id:a})}};let Oa=0;
function Ka(a,b,c,d,e,f,g){let h=[];if(a){d=Math.min(a.length,d);for(let k=0,l=0,m;k<d;k++)if(m=a[k])if(f&&m&&g&&(m.length<=f?(f-=m.length,m=null):(m=m.slice(f),f=0)),m&&(h[k]=m,g&&(l+=m.length,l>=e)))break;if(h.length){if(g)return R(h,e,0);b.push(h);return}}return!c&&h}function V(a,b,c,d,e,f,g,h){let k;c&&(k=a.bidirectional&&b>c);if(a.db)return c?a.db.get(k?c:b,k?b:c,d,e,f,g,h):a.db.get(b,"",d,e,f,g,h);a=c?(a=a.ctx.get(k?b:c))&&a.get(k?c:b):a.map.get(b);return a};O.prototype.remove=function(a,b){const c=this.reg.size&&(this.fastupdate?this.reg.get(a):this.reg.has(a));if(c){if(this.fastupdate)for(let d=0,e;d<c.length;d++){if(e=c[d])if(2>e.length)e.pop();else{const f=e.indexOf(a);f===c.length-1?e.pop():e.splice(f,1)}}else La(this.map,a),this.depth&&La(this.ctx,a);b||this.reg.delete(a)}this.db&&(this.I.push({del:a}),this.U&&Ca(this));this.cache&&this.cache.remove(a);return this};
function La(a,b){let c=0;if(a.constructor===Array)for(let d=0,e,f;d<a.length;d++){if((e=a[d])&&e.length)if(f=e.indexOf(b),0<=f){1<e.length?(e.splice(f,1),c++):delete a[d];break}else c++}else for(let d of a){const e=d[0],f=La(d[1],b);f?c+=f:a.delete(e)}return c};function O(a,b){if(!this)return new O(a);if(a){var c=B(a)?a:a.preset;c&&(a=Object.assign({},Aa[c],a))}else a={};c=a.context||{};const d=a.encode||a.encoder||na;this.encoder=d.encode?d:"object"===typeof d?new F(d):{encode:d};let e;this.resolution=a.resolution||9;this.tokenize=e=a.tokenize||"strict";this.depth="strict"===e&&c.depth||0;this.bidirectional=!1!==c.bidirectional;this.fastupdate=!!a.fastupdate;this.score=a.score||null;(e=a.keystore||0)&&(this.keystore=e);this.map=e?new K(e):new Map;this.ctx=
e?new K(e):new Map;this.reg=b||(this.fastupdate?e?new K(e):new Map:e?new M(e):new Set);this.S=c.resolution||1;this.rtl=d.rtl||a.rtl||!1;this.cache=(e=a.cache||null)&&new G(e);this.resolve=!1!==a.resolve;if(e=a.db)this.db=e.mount(this);this.U=!1!==a.commit;this.I=[];this.h=null}u=O.prototype;u.mount=function(a){this.h&&(clearTimeout(this.h),this.h=null);return a.mount(this)};u.commit=function(a,b){this.h&&(clearTimeout(this.h),this.h=null);return this.db.commit(this,a,b)};
function Ca(a){a.h||(a.h=setTimeout(function(){a.h=null;a.db.commit(a,void 0,void 0)},0))}u.clear=function(){this.map.clear();this.ctx.clear();this.reg.clear();this.cache&&this.cache.clear();this.db&&(this.h&&clearTimeout(this.h),this.h=null,this.I=[{clear:!0}]);return this};u.append=function(a,b){return this.add(a,b,!0)};u.contain=function(a){return this.db?this.db.has(a):this.reg.has(a)};
u.update=function(a,b){if(this.async){const c=this,d=this.remove(a);return d.then?d.then(()=>c.add(a,b)):this.add(a,b)}return this.remove(a).add(a,b)};function Ma(a){let b=0;if(a.constructor===Array)for(let c=0,d;c<a.length;c++)(d=a[c])&&(b+=d.length);else for(const c of a){const d=c[0],e=Ma(c[1]);e?b+=e:a.delete(d)}return b}u.cleanup=function(){if(!this.fastupdate)return this;Ma(this.map);this.depth&&Ma(this.ctx);return this};u.searchCache=ma;
u.export=function(a,b,c,d,e,f){let g=!0;"undefined"===typeof f&&(g=new Promise(l=>{f=l}));let h,k;switch(e||(e=0)){case 0:h="reg";if(this.fastupdate){k=z();for(let l of this.reg.keys())k[l]=1}else k=this.reg;break;case 1:h="cfg";k={doc:0,opt:this.A?1:0};break;case 2:h="map";k=this.map;break;case 3:h="ctx";k=this.ctx;break;default:"undefined"===typeof c&&f&&f();return}za(a,b||this,c,h,d,e,k,f);return g};
u.import=function(a,b){if(b)switch(B(b)&&(b=JSON.parse(b)),a){case "cfg":this.A=!!b.opt;break;case "reg":this.fastupdate=!1;this.reg=b;break;case "map":this.map=b;break;case "ctx":this.ctx=b}};
u.serialize=function(a=!0){if(!this.reg.size)return"";let b="",c="";for(var d of this.reg.keys())c||(c=typeof d),b+=(b?",":"")+("string"===c?'"'+d+'"':d);b="index.reg=new Set(["+b+"]);";d="";for(var e of this.map.entries()){var f=e[0],g=e[1],h="";for(let m=0,n;m<g.length;m++){n=g[m]||[""];var k="";for(var l=0;l<n.length;l++)k+=(k?",":"")+("string"===c?'"'+n[l]+'"':n[l]);k="["+k+"]";h+=(h?",":"")+k}h='["'+f+'",['+h+"]]";d+=(d?",":"")+h}d="index.map=new Map(["+d+"]);";e="";for(const m of this.ctx.entries()){f=
m[0];g=m[1];for(const n of g.entries()){g=n[0];h=n[1];k="";for(let q=0,r;q<h.length;q++){r=h[q]||[""];l="";for(let p=0;p<r.length;p++)l+=(l?",":"")+("string"===c?'"'+r[p]+'"':r[p]);l="["+l+"]";k+=(k?",":"")+l}k='new Map([["'+g+'",['+k+"]]])";k='["'+f+'",'+k+"]";e+=(e?",":"")+k}}e="index.ctx=new Map(["+e+"]);";return a?"function inject(index){"+b+d+e+"}":b+d+e};Ba(O.prototype);async function Na(a){a=a.data;var b=self._index;const c=a.args;var d=a.task;switch(d){case "init":d=a.options||{};(b=d.config)&&(d=await import(b));(b=a.factory)?(Function("return "+b)()(self),self._index=new self.FlexSearch.Index(d),delete self.FlexSearch):self._index=new O(d);postMessage({id:a.id});break;default:a=a.id,b=b[d].apply(b,c),postMessage("search"===d?{id:a,msg:b}:{id:a})}};let Oa=0;
function W(a){function b(f){f=f.data||f;const g=f.id,h=g&&e.h[g];h&&(h(f.msg),delete e.h[g])}if(!this)return new W(a);a||(a={});let c=(self||window)._factory;c&&(c=c.toString());const d="undefined"===typeof window&&self.exports,e=this;this.worker=Pa(c,d,a.worker);this.h=z();if(this.worker){d?this.worker.on("message",b):this.worker.onmessage=b;if(a.config)return new Promise(function(f){e.h[++Oa]=function(){f(e)};e.worker.postMessage({id:Oa,task:"init",factory:c,options:a})});this.worker.postMessage({task:"init",factory:c,
options:a})}}X("add");X("append");X("search");X("update");X("remove");function X(a){W.prototype[a]=W.prototype[a+"Async"]=function(){const b=this,c=[].slice.call(arguments);var d=c[c.length-1];let e;"function"===typeof d&&(e=d,c.splice(c.length-1,1));d=new Promise(function(f){b.h[++Oa]=f;b.worker.postMessage({task:a,id:Oa,args:c})});return e?(d.then(e),this):d}}
function Pa(a,b,c){return b?new (require("worker_threads")["Worker"])(__dirname + "/node/node.js"):a?new window.Worker(URL.createObjectURL(new Blob(["onmessage="+Na.toString()],{type:"text/javascript"}))):new window.Worker(B(c)?c:"worker/worker.js",{type:"module"})};Y.prototype.add=function(a,b,c){C(a)&&(b=a,a=ca(b,this.key));if(b&&(a||0===a)){if(!c&&this.A.has(a))return this.update(a,b);for(let h=0,k;h<this.field.length;h++){k=this.I[h];var d=this.index.get(this.field[h]);if("function"===typeof k){var e=k(b);e&&d.add(a,e,!1,!0)}else if(e=k.L,!e||e(b))k.constructor===String?k=[""+k]:B(k)&&(k=[k]),Qa(b,k,this.N,0,d,a,k[0],c)}if(this.tag)for(d=0;d<this.H.length;d++){var f=this.H[d];e=this.tag.get(this.R[d]);let h=z();if("function"===typeof f){if(f=f(b),!f)continue}else{var g=
f.L;if(g&&!g(b))continue;f.constructor===String&&(f=""+f);f=ca(b,f)}if(e&&f){B(f)&&(f=[f]);for(let k=0,l,m;k<f.length;k++)if(l=f[k],!h[l]&&(h[l]=1,(g=e.get(l))?m=g:e.set(l,m=[]),!c||!m.includes(a))){if(m.length===2**31-1){g=new J(m);if(this.fastupdate)for(let n of this.A.values())n.includes(m)&&(n[n.indexOf(m)]=g);e.set(l,m=g)}m.push(a);this.fastupdate&&((g=this.A.get(a))?g.push(m):this.A.set(a,[m]))}}}if(this.store&&(!c||!this.store.has(a))){let h;if(this.D){h=z();for(let k=0,l;k<this.D.length;k++){l=
this.D[k];if((c=l.L)&&!c(b))continue;let m;if("function"===typeof l){m=l(b);if(!m)continue;l=[l.X]}else if(B(l)||l.constructor===String){h[l]=b[l];continue}Ra(b,h,l,0,l[0],m)}}this.store.set(a,h||b)}}return this};function Ra(a,b,c,d,e,f){a=a[e];if(d===c.length-1)b[e]=f||a;else if(a)if(a.constructor===Array)for(b=b[e]=Array(a.length),e=0;e<a.length;e++)Ra(a,b,c,d,e);else b=b[e]||(b[e]=z()),e=c[++d],Ra(a,b,c,d,e)}
function Pa(a,b,c){return b?new (require("worker_threads")["Worker"])(__dirname + "/node/node.js"):a?new window.Worker(URL.createObjectURL(new Blob(["onmessage="+Na.toString()],{type:"text/javascript"}))):new window.Worker(B(c)?c:"worker/worker.js",{type:"module"})};Y.prototype.add=function(a,b,c){C(a)&&(b=a,a=ca(b,this.key));if(b&&(a||0===a)){if(!c&&this.reg.has(a))return this.update(a,b);for(let h=0,k;h<this.field.length;h++){k=this.G[h];var d=this.index.get(this.field[h]);if("function"===typeof k){var e=k(b);e&&d.add(a,e,!1,!0)}else if(e=k.J,!e||e(b))k.constructor===String?k=[""+k]:B(k)&&(k=[k]),Qa(b,k,this.L,0,d,a,k[0],c)}if(this.tag)for(d=0;d<this.F.length;d++){var f=this.F[d];e=this.tag.get(this.O[d]);let h=z();if("function"===typeof f){if(f=f(b),!f)continue}else{var g=
f.J;if(g&&!g(b))continue;f.constructor===String&&(f=""+f);f=ca(b,f)}if(e&&f){B(f)&&(f=[f]);for(let k=0,l,m;k<f.length;k++)if(l=f[k],!h[l]&&(h[l]=1,(g=e.get(l))?m=g:e.set(l,m=[]),!c||!m.includes(a))){if(m.length===2**31-1){g=new J(m);if(this.fastupdate)for(let n of this.reg.values())n.includes(m)&&(n[n.indexOf(m)]=g);e.set(l,m=g)}m.push(a);this.fastupdate&&((g=this.reg.get(a))?g.push(m):this.reg.set(a,[m]))}}}if(this.store&&(!c||!this.store.has(a))){let h;if(this.C){h=z();for(let k=0,l;k<this.C.length;k++){l=
this.C[k];if((c=l.J)&&!c(b))continue;let m;if("function"===typeof l){m=l(b);if(!m)continue;l=[l.V]}else if(B(l)||l.constructor===String){h[l]=b[l];continue}Ra(b,h,l,0,l[0],m)}}this.store.set(a,h||b)}}return this};function Ra(a,b,c,d,e,f){a=a[e];if(d===c.length-1)b[e]=f||a;else if(a)if(a.constructor===Array)for(b=b[e]=Array(a.length),e=0;e<a.length;e++)Ra(a,b,c,d,e);else b=b[e]||(b[e]=z()),e=c[++d],Ra(a,b,c,d,e)}
function Qa(a,b,c,d,e,f,g,h){if(a=a[g])if(d===b.length-1){if(a.constructor===Array){if(c[d]){for(b=0;b<a.length;b++)e.add(f,a[b],!0,!0);return}a=a.join(" ")}e.add(f,a,h,!0)}else if(a.constructor===Array)for(g=0;g<a.length;g++)Qa(a,b,c,d,e,f,g,h);else g=b[++d],Qa(a,b,c,d,e,f,g,h);else e.db&&e.remove(f)};Y.prototype.search=function(a,b,c,d){c||(!b&&C(a)?(c=a,a=""):C(b)&&(c=b,b=0));let e=[],f=[],g;let h;let k;let l,m=0;if(c){c.constructor===Array&&(c={index:c});a=c.query||a;g=c.pluck;h=c.merge;k=g||c.field||c.index;var n=this.tag&&c.tag;var q=this.store&&c.enrich;var r=c.suggest;b=c.limit||b;l=c.offset||0;b||(b=100);if(n&&(!this.db||!d)){n.constructor!==Array&&(n=[n]);var p=[];for(let w=0,v;w<n.length;w++)if(v=n[w],v.field&&v.tag){var t=v.tag;if(t.constructor===Array)for(var x=0;x<t.length;x++)p.push(v.field,
t[x]);else p.push(v.field,t)}else{t=Object.keys(v);for(let H=0,I,D;H<t.length;H++)if(I=t[H],D=v[I],D.constructor===Array)for(x=0;x<D.length;x++)p.push(I,D[x]);else p.push(I,D)}n=p;if(!a){r=[];if(p.length)for(n=0;n<p.length;n+=2){if(this.db){d=this.index.get(p[n]);if(!d)continue;r.push(d=d.db.tag(p[n+1],b,l,q))}else d=Sa.call(this,p[n],p[n+1],b,l,q);e.push({field:p[n],tag:p[n+1],result:d})}return r.length?Promise.all(r).then(function(w){for(let v=0;v<w.length;v++)e[v].result=w[v];return e}):e}}B(k)&&
(k=[k])}k||(k=this.field);p=!d&&(this.worker||this.async)&&[];let A;for(let w=0,v,H,I;w<k.length;w++){H=k[w];if(this.db&&this.tag&&!this.I[w])continue;let D;B(H)||(D=H,H=D.field,a=D.query||a,b=D.limit||b,r=D.suggest||r);if(d)v=d[w];else if(t=D||c,x=this.index.get(H),n&&(this.db&&(t.tag=n,A=x.db.Z,t.field=k),A||(t.enrich=!1)),p){p[w]=x.searchAsync(a,b,t);t&&q&&(t.enrich=q);continue}else v=x.search(a,b,t),t&&q&&(t.enrich=q);I=v&&v.length;if(n&&I){t=[];x=0;if(this.db&&d){if(!A)for(let L=k.length;L<d.length;L++){let E=
(k=[k])}k||(k=this.field);p=!d&&(this.worker||this.async)&&[];let A;for(let w=0,v,H,I;w<k.length;w++){H=k[w];if(this.db&&this.tag&&!this.G[w])continue;let D;B(H)||(D=H,H=D.field,a=D.query||a,b=D.limit||b,r=D.suggest||r);if(d)v=d[w];else if(t=D||c,x=this.index.get(H),n&&(this.db&&(t.tag=n,A=x.db.X,t.field=k),A||(t.enrich=!1)),p){p[w]=x.searchAsync(a,b,t);t&&q&&(t.enrich=q);continue}else v=x.search(a,b,t),t&&q&&(t.enrich=q);I=v&&v.length;if(n&&I){t=[];x=0;if(this.db&&d){if(!A)for(let L=k.length;L<d.length;L++){let E=
d[L];if(E&&E.length)x++,t.push(E);else if(!r)return e}}else for(let L=0,E,bb;L<n.length;L+=2){E=this.tag.get(n[L]);if(!E)if(r)continue;else return e;if(bb=(E=E&&E.get(n[L+1]))&&E.length)x++,t.push(E);else if(!r)return e}if(x){v=Ja(v,t);I=v.length;if(!I&&!r)return e;x--}}if(I)f[m]=H,e.push(v),m++;else if(1===k.length)return e}if(p){if(this.db&&n&&n.length&&!A)for(q=0;q<n.length;q+=2){d=this.index.get(n[q]);if(!d)if(r)continue;else return e;p.push(d.db.tag(n[q+1],b,l,!1))}const w=this;return Promise.all(p).then(function(v){return v.length?
w.search(a,b,c,v):v})}if(!m)return e;if(g&&(!q||!this.store))return e[0];p=[];for(let w=0,v;w<f.length;w++){v=e[w];q&&v.length&&!v[0].doc&&(this.db?p.push(v=this.index.get(this.field[0]).db.enrich(v)):v.length&&(v=Ta.call(this,v)));if(g)return v;e[w]={field:f[w],result:v}}return q&&this.db&&p.length?Promise.all(p).then(function(w){for(let v=0;v<w.length;v++)e[v].result=w[v];return h?Ua(e,b):e}):h?Ua(e,b):e};
function Ua(a,b){const c=[],d=z();for(let e=0,f,g;e<a.length;e++){f=a[e];g=f.result;for(let h=0,k,l,m;h<g.length;h++)if(l=g[h],k=l.id,m=d[k])m.push(f.field);else{if(c.length===b)return c;l.field=d[k]=[f.field];c.push(l)}}return c}function Sa(a,b,c,d,e){a=this.tag.get(a);if(!a)return[];if((b=(a=a&&a.get(b))&&a.length-d)&&0<b){if(b>c||d)a=a.slice(d,d+c);e&&(a=Ta.call(this,a));return a}}
function Ta(a){const b=Array(a.length);for(let c=0,d;c<a.length;c++)d=a[c],b[c]={id:d,doc:this.store.get(d)};return b};function Y(a){if(!this)return new Y(a);const b=a.document||a.doc||a;var c,d;this.I=[];this.field=[];this.N=[];this.key=(c=b.key||b.id)&&Va(c,this.N)||"id";(d=a.keystore||0)&&(this.keystore=d);this.A=(this.fastupdate=!!a.fastupdate)?d?new K(d):new Map:d?new M(d):new Set;this.D=(c=b.store||null)&&!0!==c&&[];this.store=c&&(d?new K(d):new Map);this.cache=(c=a.cache||null)&&new G(c);a.cache=!1;this.worker=a.worker;this.async=!1;c=new Map;d=b.index||b.field||b;B(d)&&(d=[d]);for(let e=0,f,g;e<d.length;e++){f=
d[e];B(f)||(g=f,f=f.field);g=C(g)?Object.assign({},a,g):a;if(this.worker){const h=new W(g);c.set(f,h);h.worker||(this.worker=!1)}this.worker||c.set(f,new O(g,this.A));g.custom?this.I[e]=g.custom:(this.I[e]=Va(f,this.N),g.filter&&("string"===typeof this.I[e]&&(this.I[e]=new String(this.I[e])),this.I[e].L=g.filter));this.field[e]=f}if(this.D){d=b.store;B(d)&&(d=[d]);for(let e=0,f,g;e<d.length;e++)f=d[e],g=f.field||f,f.custom?(this.D[e]=f.custom,f.custom.X=g):(this.D[e]=Va(g,this.N),f.filter&&("string"===
typeof this.D[e]&&(this.D[e]=new String(this.D[e])),this.D[e].L=f.filter))}this.index=c;this.tag=null;if(c=b.tag)if("string"===typeof c&&(c=[c]),c.length){this.tag=new Map;this.H=[];this.R=[];for(let e=0,f,g;e<c.length;e++){f=c[e];g=f.field||f;if(!g)throw Error("The tag field from the document descriptor is undefined.");f.custom?this.H[e]=f.custom:(this.H[e]=Va(g,this.N),f.filter&&("string"===typeof this.H[e]&&(this.H[e]=new String(this.H[e])),this.H[e].L=f.filter));this.R[e]=g;this.tag.set(g,new Map)}}a.db&&
function Ta(a){const b=Array(a.length);for(let c=0,d;c<a.length;c++)d=a[c],b[c]={id:d,doc:this.store.get(d)};return b};function Y(a){if(!this)return new Y(a);const b=a.document||a.doc||a;var c,d;this.G=[];this.field=[];this.L=[];this.key=(c=b.key||b.id)&&Va(c,this.L)||"id";(d=a.keystore||0)&&(this.keystore=d);this.reg=(this.fastupdate=!!a.fastupdate)?d?new K(d):new Map:d?new M(d):new Set;this.C=(c=b.store||null)&&!0!==c&&[];this.store=c&&(d?new K(d):new Map);this.cache=(c=a.cache||null)&&new G(c);a.cache=!1;this.worker=a.worker;this.async=!1;c=new Map;d=b.index||b.field||b;B(d)&&(d=[d]);for(let e=0,f,g;e<d.length;e++){f=
d[e];B(f)||(g=f,f=f.field);g=C(g)?Object.assign({},a,g):a;if(this.worker){const h=new W(g);c.set(f,h);h.worker||(this.worker=!1)}this.worker||c.set(f,new O(g,this.reg));g.custom?this.G[e]=g.custom:(this.G[e]=Va(f,this.L),g.filter&&("string"===typeof this.G[e]&&(this.G[e]=new String(this.G[e])),this.G[e].J=g.filter));this.field[e]=f}if(this.C){d=b.store;B(d)&&(d=[d]);for(let e=0,f,g;e<d.length;e++)f=d[e],g=f.field||f,f.custom?(this.C[e]=f.custom,f.custom.V=g):(this.C[e]=Va(g,this.L),f.filter&&("string"===
typeof this.C[e]&&(this.C[e]=new String(this.C[e])),this.C[e].J=f.filter))}this.index=c;this.tag=null;if(c=b.tag)if("string"===typeof c&&(c=[c]),c.length){this.tag=new Map;this.F=[];this.O=[];for(let e=0,f,g;e<c.length;e++){f=c[e];g=f.field||f;if(!g)throw Error("The tag field from the document descriptor is undefined.");f.custom?this.F[e]=f.custom:(this.F[e]=Va(g,this.L),f.filter&&("string"===typeof this.F[e]&&(this.F[e]=new String(this.F[e])),this.F[e].J=f.filter));this.O[e]=g;this.tag.set(g,new Map)}}a.db&&
this.mount(a.db)}u=Y.prototype;
u.mount=function(a){let b=this.field;if(this.tag)for(let e=0,f;e<this.R.length;e++){f=this.R[e];var c=this.index.get(f);c||(this.index.set(f,c=new O({},this.A)),b===this.field&&(b=b.slice(0)),b.push(f));c.tag=this.tag.get(f)}c=[];const d={db:a.db,type:a.type,fastupdate:a.fastupdate};for(let e=0,f,g;e<b.length;e++){d.field=g=b[e];f=this.index.get(g);const h=new a.constructor(a.id,d);h.id=a.id;c[e]=h.mount(f);f.document=!0;e?f.Y=!0:f.store=this.store}this.db=this.async=!0;return Promise.all(c)};
u.commit=async function(a,b){const c=[];for(const d of this.index.values())c.push(d.db.commit(d,a,b));await Promise.all(c);this.A.clear()};function Va(a,b){const c=a.split(":");let d=0;for(let e=0;e<c.length;e++)a=c[e],"]"===a[a.length-1]&&(a=a.substring(0,a.length-2))&&(b[d]=!0),a&&(c[d++]=a);d<c.length&&(c.length=d);return 1<d?c:c[0]}u.append=function(a,b){return this.add(a,b,!0)};u.update=function(a,b){return this.remove(a).add(a,b)};
u.remove=function(a){C(a)&&(a=ca(a,this.key));for(var b of this.index.values())b.remove(a,!0);if(this.A.has(a)){if(this.tag&&!this.fastupdate)for(let c of this.tag.values())for(let d of c){b=d[0];const e=d[1],f=e.indexOf(a);-1<f&&(1<e.length?e.splice(f,1):c.delete(b))}this.store&&this.store.delete(a);this.A.delete(a)}this.cache&&this.cache.remove(a);return this};
u.clear=function(){for(const a of this.index.values())a.clear();if(this.tag)for(const a of this.tag.values())a.clear();this.store&&this.store.clear();return this};u.contain=function(a){return this.db?this.index.get(this.field[0]).db.has(a):this.A.has(a)};u.cleanup=function(){for(const a of this.index.values())a.cleanup();return this};u.get=function(a){return this.db?this.index.get(this.field[0]).db.enrich(a).then(function(b){return b[0]&&b[0].doc}):this.store.get(a)};
u.mount=function(a){let b=this.field;if(this.tag)for(let e=0,f;e<this.O.length;e++){f=this.O[e];var c=this.index.get(f);c||(this.index.set(f,c=new O({},this.reg)),b===this.field&&(b=b.slice(0)),b.push(f));c.tag=this.tag.get(f)}c=[];const d={db:a.db,type:a.type,fastupdate:a.fastupdate};for(let e=0,f,g;e<b.length;e++){d.field=g=b[e];f=this.index.get(g);const h=new a.constructor(a.id,d);h.id=a.id;c[e]=h.mount(f);f.document=!0;e?f.W=!0:f.store=this.store}this.db=this.async=!0;return Promise.all(c)};
u.commit=async function(a,b){const c=[];for(const d of this.index.values())c.push(d.db.commit(d,a,b));await Promise.all(c);this.reg.clear()};function Va(a,b){const c=a.split(":");let d=0;for(let e=0;e<c.length;e++)a=c[e],"]"===a[a.length-1]&&(a=a.substring(0,a.length-2))&&(b[d]=!0),a&&(c[d++]=a);d<c.length&&(c.length=d);return 1<d?c:c[0]}u.append=function(a,b){return this.add(a,b,!0)};u.update=function(a,b){return this.remove(a).add(a,b)};
u.remove=function(a){C(a)&&(a=ca(a,this.key));for(var b of this.index.values())b.remove(a,!0);if(this.reg.has(a)){if(this.tag&&!this.fastupdate)for(let c of this.tag.values())for(let d of c){b=d[0];const e=d[1],f=e.indexOf(a);-1<f&&(1<e.length?e.splice(f,1):c.delete(b))}this.store&&this.store.delete(a);this.reg.delete(a)}this.cache&&this.cache.remove(a);return this};
u.clear=function(){for(const a of this.index.values())a.clear();if(this.tag)for(const a of this.tag.values())a.clear();this.store&&this.store.clear();return this};u.contain=function(a){return this.db?this.index.get(this.field[0]).db.has(a):this.reg.has(a)};u.cleanup=function(){for(const a of this.index.values())a.cleanup();return this};u.get=function(a){return this.db?this.index.get(this.field[0]).db.enrich(a).then(function(b){return b[0]&&b[0].doc}):this.store.get(a)};
u.set=function(a,b){this.store.set(a,b);return this};u.searchCache=ma;u.export=function(a,b,c,d,e,f){let g;"undefined"===typeof f&&(g=new Promise(k=>{f=k}));e||(e=0);d||(d=0);if(d<this.field.length){c=this.field[d];var h=this.index[c];b=this;h.export(a,b,e?c:"",d,e++,f)||(d++,b.export(a,b,c,d,1,f))}else{switch(e){case 1:b="tag";h=this.h;c=null;break;case 2:b="store";h=this.store;c=null;break;default:f();return}za(a,this,c,b,d,e,h,f)}return g};
u.import=function(a,b){if(b)switch(B(b)&&(b=JSON.parse(b)),a){case "tag":this.h=b;break;case "reg":this.fastupdate=!1;this.A=b;for(let d=0,e;d<this.field.length;d++)e=this.index[this.field[d]],e.A=b,e.fastupdate=!1;break;case "store":this.store=b;break;default:a=a.split(".");const c=a[0];a=a[1];c&&a&&this.index[c].import(a,b)}};Ba(Y.prototype);const Wa="undefined"!==typeof window&&(window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB),Xa=["map","ctx","tag","reg","cfg"];
function Ya(a,b={}){if(!this)return new Ya(a,b);"object"===typeof a&&(b=a=a.name);a||console.info("Default storage space was used, because a name was not passed.");this.id="flexsearch"+(a?":"+a.toLowerCase().replace(/[^a-z0-9_\-]/g,""):"");this.field=b.field?b.field.toLowerCase().replace(/[^a-z0-9_\-]/g,""):"";this.Z=!1;this.db=null;this.h={}}u=Ya.prototype;u.mount=function(a){if(a.constructor===Y)return a.mount(this);a.db=this;return Za(this)};
u.import=function(a,b){if(b)switch(B(b)&&(b=JSON.parse(b)),a){case "tag":this.h=b;break;case "reg":this.fastupdate=!1;this.reg=b;for(let d=0,e;d<this.field.length;d++)e=this.index[this.field[d]],e.reg=b,e.fastupdate=!1;break;case "store":this.store=b;break;default:a=a.split(".");const c=a[0];a=a[1];c&&a&&this.index[c].import(a,b)}};Ba(Y.prototype);const Wa="undefined"!==typeof window&&(window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB),Xa=["map","ctx","tag","reg","cfg"];
function Ya(a,b={}){if(!this)return new Ya(a,b);"object"===typeof a&&(b=a=a.name);a||console.info("Default storage space was used, because a name was not passed.");this.id="flexsearch"+(a?":"+a.toLowerCase().replace(/[^a-z0-9_\-]/g,""):"");this.field=b.field?b.field.toLowerCase().replace(/[^a-z0-9_\-]/g,""):"";this.X=!1;this.db=null;this.h={}}u=Ya.prototype;u.mount=function(a){if(a.constructor===Y)return a.mount(this);a.db=this;return Za(this)};
function Za(a){navigator.storage&&navigator.storage.persist();return a.db||new Promise(function(b,c){const d=Wa.open(a.id+(a.field?":"+a.field:""),1);d.onupgradeneeded=function(){const e=a.db=this.result;Xa.forEach(f=>{e.objectStoreNames.contains(f)||e.createObjectStore(f)})};d.onblocked=function(e){console.error("blocked",e);c()};d.onerror=function(e){console.error(this.error,e);c()};d.onsuccess=function(){a.db=this.result;a.db.onversionchange=function(){a.close()};b(a)}})}
u.close=function(){this.db.close();this.db=null};u.clear=function(){const a=this.db.transaction(Xa,"readwrite");for(let b=0;b<Xa.length;b++)a.objectStore(Xa[b]).clear();return Z(a)};
u.get=function(a,b,c=0,d=0,e=!0,f=!1){a=this.db.transaction(b?"ctx":"map","readonly").objectStore(b?"ctx":"map").get(b?b+":"+a:a);const g=this;return Z(a).then(function(h){let k=[];if(!h||!h.length)return k;if(e){if(!c&&!d&&1===h.length)return h[0];for(let l=0,m;l<h.length;l++)if((m=h[l])&&m.length){if(d>=m.length){d-=m.length;continue}const n=c?d+Math.min(m.length-d,c):m.length;for(let q=d;q<n;q++)k.push(m[q]);d=0;if(k.length===c)break}return f?g.enrich(k):k}return h})};
u.tag=function(a,b=0,c=0,d=!1){a=this.db.transaction("tag","readonly").objectStore("tag").get(a);const e=this;return Z(a).then(function(f){if(!f||!f.length||c>=f.length)return[];if(!b&&!c)return f;f=f.slice(c,c+b);return d?e.enrich(f):f})};
u.enrich=function(a){"object"!==typeof a&&(a=[a]);const b=this.db.transaction("reg","readonly").objectStore("reg"),c=[];for(let d=0;d<a.length;d++)c[d]=Z(b.get(a[d]));return Promise.all(c).then(function(d){for(let e=0;e<d.length;e++)d[e]={id:a[e],doc:d[e]?JSON.parse(d[e]):null};return d})};u.has=function(a){a=this.db.transaction("reg","readonly").objectStore("reg").getKey(a);return Z(a)};u.search=null;u.info=function(){};
u.transaction=function(a,b,c){let d=this.h[a+":"+b];if(d)return c.call(this,d);let e=this.db.transaction(a,b);this.h[a+":"+b]=d=e.objectStore(a);return new Promise((f,g)=>{e.onerror=h=>{this.h[a+":"+b]=null;e.abort();e=d=null;g(h)};e.oncomplete=h=>{e=d=this.h[a+":"+b]=null;f(h||!0)};return c.call(this,d)})};
u.commit=async function(a,b,c){if(b)await this.clear(),a.K=[];else{let d=a.K;a.K=[];for(let e=0,f;e<d.length;e++)if(f=d[e],f.clear){await this.clear();b=!0;break}else d[e]=f.$;b||(c||(d=d.concat(ba(a.A))),d.length&&await this.remove(d))}a.A.size&&(await this.transaction("map","readwrite",function(d){for(const e of a.map){const f=e[0],g=e[1];g.length&&(b?d.put(g,f):d.get(f).onsuccess=function(){let h=this.result;var k;if(h&&h.length){const l=Math.max(h.length,g.length);for(let m=0,n,q;m<l;m++)if((q=
g[m])&&q.length){if((n=h[m])&&n.length)for(k=0;k<q.length;k++)n.push(q[k]);else h[m]=q;k=1}}else h=g,k=1;k&&d.put(h,f)})}}),await this.transaction("ctx","readwrite",function(d){for(const e of a.F){const f=e[0],g=e[1];for(const h of g){const k=h[0],l=h[1];l.length&&(b?d.put(l,f+":"+k):d.get(f+":"+k).onsuccess=function(){let m=this.result;var n;if(m&&m.length){const q=Math.max(m.length,l.length);for(let r=0,p,t;r<q;r++)if((t=l[r])&&t.length){if((p=m[r])&&p.length)for(n=0;n<t.length;n++)p.push(t[n]);
else m[r]=t;n=1}}else m=l,n=1;n&&d.put(m,f+":"+k)})}}}),a.store?await this.transaction("reg","readwrite",function(d){for(const e of a.store){const f=e[0],g=e[1];d.put("object"===typeof g?JSON.stringify(g):1,f)}}):a.Y||await this.transaction("reg","readwrite",function(d){for(const e of a.A.keys())d.put(1,e)}),a.tag&&await this.transaction("tag","readwrite",function(d){for(const e of a.tag){const f=e[0],g=e[1];g.length&&(d.get(f).onsuccess=function(){let h=this.result;h=h&&h.length?h.concat(g):g;d.put(h,
f)})}}),a.map.clear(),a.F.clear(),a.tag&&a.tag.clear(),a.store&&a.store.clear(),a.document||a.A.clear())};function $a(a,b,c){const d=a.value;let e,f,g=0;for(let h=0,k;h<d.length;h++){if(k=c?d:d[h]){for(let l=0,m,n;l<b.length;l++)if(n=b[l],m=k.indexOf(f?parseInt(n,10):n),0>m&&!f&&"string"===typeof n&&!isNaN(n)&&(m=k.indexOf(parseInt(n,10)))&&(f=1),0<=m)if(e=1,1<k.length)k.splice(m,1);else{d[h]=[];break}g+=k.length}if(c)break}g?e&&a.update(d):a.delete();a.continue()}
u.commit=async function(a,b,c){if(b)await this.clear(),a.I=[];else{let d=a.I;a.I=[];for(let e=0,f;e<d.length;e++)if(f=d[e],f.clear){await this.clear();b=!0;break}else d[e]=f.Y;b||(c||(d=d.concat(ba(a.reg))),d.length&&await this.remove(d))}a.reg.size&&(await this.transaction("map","readwrite",function(d){for(const e of a.map){const f=e[0],g=e[1];g.length&&(b?d.put(g,f):d.get(f).onsuccess=function(){let h=this.result;var k;if(h&&h.length){const l=Math.max(h.length,g.length);for(let m=0,n,q;m<l;m++)if((q=
g[m])&&q.length){if((n=h[m])&&n.length)for(k=0;k<q.length;k++)n.push(q[k]);else h[m]=q;k=1}}else h=g,k=1;k&&d.put(h,f)})}}),await this.transaction("ctx","readwrite",function(d){for(const e of a.ctx){const f=e[0],g=e[1];for(const h of g){const k=h[0],l=h[1];l.length&&(b?d.put(l,f+":"+k):d.get(f+":"+k).onsuccess=function(){let m=this.result;var n;if(m&&m.length){const q=Math.max(m.length,l.length);for(let r=0,p,t;r<q;r++)if((t=l[r])&&t.length){if((p=m[r])&&p.length)for(n=0;n<t.length;n++)p.push(t[n]);
else m[r]=t;n=1}}else m=l,n=1;n&&d.put(m,f+":"+k)})}}}),a.store?await this.transaction("reg","readwrite",function(d){for(const e of a.store){const f=e[0],g=e[1];d.put("object"===typeof g?JSON.stringify(g):1,f)}}):a.W||await this.transaction("reg","readwrite",function(d){for(const e of a.reg.keys())d.put(1,e)}),a.tag&&await this.transaction("tag","readwrite",function(d){for(const e of a.tag){const f=e[0],g=e[1];g.length&&(d.get(f).onsuccess=function(){let h=this.result;h=h&&h.length?h.concat(g):g;
d.put(h,f)})}}),a.map.clear(),a.ctx.clear(),a.tag&&a.tag.clear(),a.store&&a.store.clear(),a.document||a.reg.clear())};function $a(a,b,c){const d=a.value;let e,f,g=0;for(let h=0,k;h<d.length;h++){if(k=c?d:d[h]){for(let l=0,m,n;l<b.length;l++)if(n=b[l],m=k.indexOf(f?parseInt(n,10):n),0>m&&!f&&"string"===typeof n&&!isNaN(n)&&(m=k.indexOf(parseInt(n,10)))&&(f=1),0<=m)if(e=1,1<k.length)k.splice(m,1);else{d[h]=[];break}g+=k.length}if(c)break}g?e&&a.update(d):a.delete();a.continue()}
u.remove=function(a){"object"!==typeof a&&(a=[a]);return Promise.all([this.transaction("map","readwrite",function(b){b.openCursor().onsuccess=function(){const c=this.result;c&&$a(c,a)}}),this.transaction("ctx","readwrite",function(b){b.openCursor().onsuccess=function(){const c=this.result;c&&$a(c,a)}}),this.transaction("tag","readwrite",function(b){b.openCursor().onsuccess=function(){const c=this.result;c&&$a(c,a,!0)}}),this.transaction("reg","readwrite",function(b){for(let c=0;c<a.length;c++)b.delete(a[c])})])};
function Z(a){return new Promise((b,c)=>{a.onsuccess=function(){b(this.result)};a.oncomplete=function(){b(this.result)};a.onerror=c;a=null})};const ab={Index:O,Charset:va,Encoder:F,Document:Y,Worker:W,Resolver:S,IndexedDB:Ya,Language:{}},cb=self;let db;(db=cb.define)&&db.amd?db([],function(){return ab}):"object"===typeof cb.exports?cb.exports=ab:cb.FlexSearch=ab;}(this));

View File

@@ -128,32 +128,32 @@ G.prototype.assign = function(a) {
this.minlength = y(a.minlength, 1, this.minlength);
this.maxlength = y(a.maxlength, 0, this.maxlength);
if (this.cache = c = y(a.cache, !0, this.cache)) {
this.O = null, this.V = "number" === typeof c ? c : 2e5, this.J = new Map(), this.M = new Map(), this.B = this.h = 128;
this.M = null, this.T = "number" === typeof c ? c : 2e5, this.H = new Map(), this.K = new Map(), this.A = this.h = 128;
}
this.C = "";
this.S = null;
this.P = "";
this.T = null;
this.B = "";
this.P = null;
this.N = "";
this.R = null;
if (this.matcher) {
for (const d of this.matcher.keys()) {
this.C += (this.C ? "|" : "") + d;
this.B += (this.B ? "|" : "") + d;
}
}
if (this.stemmer) {
for (const d of this.stemmer.keys()) {
this.P += (this.P ? "|" : "") + d;
this.N += (this.N ? "|" : "") + d;
}
}
return this;
};
G.prototype.encode = function(a) {
if (this.cache && a.length <= this.h) {
if (this.O) {
if (this.J.has(a)) {
return this.J.get(a);
if (this.M) {
if (this.H.has(a)) {
return this.H.get(a);
}
} else {
this.O = setTimeout(la, 0, this);
this.M = setTimeout(la, 0, this);
}
}
this.normalize && (a = "function" === typeof this.normalize ? this.normalize(a) : ka ? a.normalize("NFKD").replace(ka, "").toLowerCase() : a.toLowerCase());
@@ -175,20 +175,20 @@ G.prototype.encode = function(a) {
if (this.filter && this.filter.has(g)) {
continue;
}
if (this.cache && g.length <= this.B) {
if (this.O) {
var e = this.M.get(g);
if (this.cache && g.length <= this.A) {
if (this.M) {
var e = this.K.get(g);
if (e || "" === e) {
e && c.push(e);
continue;
}
} else {
this.O = setTimeout(la, 0, this);
this.M = setTimeout(la, 0, this);
}
}
let k;
this.stemmer && 2 < g.length && (this.T || (this.T = new RegExp("(?!^)(" + this.P + ")$")), g = g.replace(this.T, l => this.stemmer.get(l)), k = 1);
this.matcher && 1 < g.length && (this.S || (this.S = new RegExp("(" + this.C + ")", "g")), g = g.replace(this.S, l => this.matcher.get(l)), k = 1);
this.stemmer && 2 < g.length && (this.R || (this.R = new RegExp("(?!^)(" + this.N + ")$")), g = g.replace(this.R, l => this.stemmer.get(l)), k = 1);
this.matcher && 1 < g.length && (this.P || (this.P = new RegExp("(" + this.B + ")", "g")), g = g.replace(this.P, l => this.matcher.get(l)), k = 1);
g && k && (g.length < this.minlength || this.filter && this.filter.has(g)) && (g = "");
if (g && (this.mapper || this.dedupe && 1 < g.length)) {
e = "";
@@ -202,17 +202,17 @@ G.prototype.encode = function(a) {
g = g.replace(this.replacer[e], this.replacer[e + 1]);
}
}
this.cache && h.length <= this.B && (this.M.set(h, g), this.M.size > this.V && (this.M.clear(), this.B = this.B / 1.1 | 0));
this.cache && h.length <= this.A && (this.K.set(h, g), this.K.size > this.T && (this.K.clear(), this.A = this.A / 1.1 | 0));
g && c.push(g);
}
this.finalize && (c = this.finalize(c) || c);
this.cache && a.length <= this.h && (this.J.set(a, c), this.J.size > this.V && (this.J.clear(), this.h = this.h / 1.1 | 0));
this.cache && a.length <= this.h && (this.H.set(a, c), this.H.size > this.T && (this.H.clear(), this.h = this.h / 1.1 | 0));
return c;
};
function la(a) {
a.O = null;
a.J.clear();
a.M.clear();
a.M = null;
a.H.clear();
a.K.clear();
}
;function ma(a, b, c) {
a = ("object" === typeof a ? "" + a.query : a).toLowerCase();
@@ -375,9 +375,9 @@ function L(a = 8) {
return new L(a);
}
this.index = z();
this.C = [];
this.B = [];
this.size = 0;
32 < a ? (this.h = xa, this.B = BigInt(a)) : (this.h = ya, this.B = a);
32 < a ? (this.h = xa, this.A = BigInt(a)) : (this.h = ya, this.A = a);
}
L.prototype.get = function(a) {
const b = this.index[this.h(a)];
@@ -386,7 +386,7 @@ L.prototype.get = function(a) {
L.prototype.set = function(a, b) {
var c = this.h(a);
let d = this.index[c];
d ? (c = d.size, d.set(a, b), (c -= d.size) && this.size++) : (this.index[c] = d = new Map([[a, b]]), this.C.push(d));
d ? (c = d.size, d.set(a, b), (c -= d.size) && this.size++) : (this.index[c] = d = new Map([[a, b]]), this.B.push(d));
};
function M(a = 8) {
if (!this) {
@@ -394,20 +394,20 @@ function M(a = 8) {
}
this.index = z();
this.h = [];
32 < a ? (this.C = xa, this.B = BigInt(a)) : (this.C = ya, this.B = a);
32 < a ? (this.B = xa, this.A = BigInt(a)) : (this.B = ya, this.A = a);
}
M.prototype.add = function(a) {
var b = this.C(a);
var b = this.B(a);
let c = this.index[b];
c ? (b = c.size, c.add(a), (b -= c.size) && this.size++) : (this.index[b] = c = new Set([a]), this.h.push(c));
};
u = L.prototype;
u.has = M.prototype.has = function(a) {
const b = this.index[this.C(a)];
const b = this.index[this.B(a)];
return b && b.has(a);
};
u.delete = M.prototype.delete = function(a) {
const b = this.index[this.C(a)];
const b = this.index[this.B(a)];
b && b.delete(a) && this.size--;
};
u.clear = M.prototype.clear = function() {
@@ -437,18 +437,18 @@ u.entries = M.prototype.entries = function*() {
}
};
function ya(a) {
let b = 2 ** this.B - 1;
let b = 2 ** this.A - 1;
if ("number" == typeof a) {
return a & b;
}
let c = 0, d = this.B + 1;
let c = 0, d = this.A + 1;
for (let e = 0; e < a.length; e++) {
c = (c * d ^ a.charCodeAt(e)) & b;
}
return 32 === this.B ? c + 2 ** 31 : c;
return 32 === this.A ? c + 2 ** 31 : c;
}
function xa(a) {
let b = BigInt(2) ** this.B - BigInt(1);
let b = BigInt(2) ** this.A - BigInt(1);
var c = typeof a;
if ("bigint" === c) {
return a & b;
@@ -457,7 +457,7 @@ function xa(a) {
return BigInt(a) & b;
}
c = BigInt(0);
let d = this.B + BigInt(1);
let d = this.A + BigInt(1);
for (let e = 0; e < a.length; e++) {
c = (c * d ^ BigInt(a.charCodeAt(e))) & b;
}
@@ -492,7 +492,7 @@ function N(a) {
;z();
O.prototype.add = function(a, b, c, d) {
if (b && (a || 0 === a)) {
if (!d && !c && this.A.has(a)) {
if (!d && !c && this.reg.has(a)) {
return this.update(a, b);
}
b = this.encoder.encode(b);
@@ -531,7 +531,7 @@ O.prototype.add = function(a, b, c, d) {
}
default:
if (Q(this, m, p, f, a, c), n && 1 < d && r < d - 1) {
for (e = z(), g = this.U, f = p, h = Math.min(n + 1, d - r), e[f] = 1, k = 1; k < h; k++) {
for (e = z(), g = this.S, f = p, h = Math.min(n + 1, d - r), e[f] = 1, k = 1; k < h; k++) {
if ((p = b[this.rtl ? d - 1 - r - k : r + k]) && !e[p]) {
e[p] = 1;
const t = this.score ? this.score(b, f, r, p, k) : P(g + (d / 2 > g ? 0 : 1), d, r, h - 1, k - 1), x = this.bidirectional && p > f;
@@ -542,29 +542,29 @@ O.prototype.add = function(a, b, c, d) {
}
}
}
this.fastupdate || this.A.add(a);
this.fastupdate || this.reg.add(a);
} else {
b = "";
}
}
this.db && (b || this.K.push({del:a}), this.W && Ca(this));
this.db && (b || this.I.push({del:a}), this.U && Ca(this));
return this;
};
function Q(a, b, c, d, e, f, g) {
let h = g ? a.F : a.map, k;
let h = g ? a.ctx : a.map, k;
if (!b[c] || !g || !(k = b[c])[g]) {
if (g ? (b = k || (b[c] = z()), b[g] = 1, (k = h.get(g)) ? h = k : h.set(g, h = new Map())) : b[c] = 1, (k = h.get(c)) ? h = k : h.set(c, h = k = []), h = h[d] || (h[d] = []), !f || !h.includes(e)) {
if (h.length === 2 ** 31 - 1) {
b = new K(h);
if (a.fastupdate) {
for (let l of a.A.values()) {
for (let l of a.reg.values()) {
l.includes(h) && (l[l.indexOf(h)] = b);
}
}
k[d] = h = b;
}
h.push(e);
a.fastupdate && ((d = a.A.get(e)) ? d.push(h) : a.A.set(e, [h]));
a.fastupdate && ((d = a.reg.get(e)) ? d.push(h) : a.reg.set(e, [h]));
}
}
}
@@ -655,12 +655,12 @@ function Da(a) {
if (c.length) {
return Promise.all(c).then(function() {
a.result.length && (d = [a.result].concat(d));
a.result = Ea(d, e, f, g, h, a.G);
a.result = Ea(d, e, f, g, h, a.D);
return h ? a.result : a;
});
}
this.result.length && (d = [this.result].concat(d));
this.result = Ea(d, e, f, g, h, a.G);
this.result = Ea(d, e, f, g, h, a.D);
return h ? this.result : this;
};
function Ea(a, b, c, d, e, f) {
@@ -745,12 +745,12 @@ function Ea(a, b, c, d, e, f) {
if (a.length) {
return Promise.all(a).then(function() {
d = [b.result].concat(d);
b.result = Fa(d, e, f, g, b.G);
b.result = Fa(d, e, f, g, b.D);
return g ? b.result : b;
});
}
d = [this.result].concat(d);
this.result = Fa(d, e, f, g, b.G);
this.result = Fa(d, e, f, g, b.D);
return g ? this.result : this;
}
return this;
@@ -841,12 +841,12 @@ function Fa(a, b, c, d, e) {
if (c.length) {
return Promise.all(c).then(function() {
a.result.length && (d = [a.result].concat(d));
a.result = Ga(d, e, f, g, !h, a.G);
a.result = Ga(d, e, f, g, !h, a.D);
return h ? a.result : a;
});
}
this.result.length && (d = [this.result].concat(d));
this.result = Ga(d, e, f, g, !h, a.G);
this.result = Ga(d, e, f, g, !h, a.D);
return h ? this.result : this;
};
function Ga(a, b, c, d, e, f) {
@@ -956,7 +956,7 @@ function Ha(a, b) {
}
this.index = null;
this.result = a || [];
this.G = 0;
this.D = 0;
}
S.prototype.limit = function(a) {
if (this.result.length) {
@@ -986,7 +986,7 @@ S.prototype.offset = function(a) {
return this;
};
S.prototype.boost = function(a) {
this.G += a;
this.D += a;
return this;
};
S.prototype.resolve = function(a, b, c) {
@@ -1121,7 +1121,7 @@ O.prototype.search = function(a, b, c) {
return async function() {
for (let t, x; q < e; q++) {
x = a[q];
r ? (t = await V(p, x, r), t = Ka(t, d, f, p.U, b, g, 2 === e), f && !1 === t && d.length || (r = x)) : (t = await V(p, x), t = Ka(t, d, f, p.resolution, b, g, 1 === e));
r ? (t = await V(p, x, r), t = Ka(t, d, f, p.S, b, g, 2 === e), f && !1 === t && d.length || (r = x)) : (t = await V(p, x), t = Ka(t, d, f, p.resolution, b, g, 1 === e));
if (t) {
return t;
}
@@ -1145,7 +1145,7 @@ O.prototype.search = function(a, b, c) {
}
for (let p, t; q < e; q++) {
t = a[q];
r ? (p = V(this, t, r), p = Ka(p, d, f, this.U, b, g, 2 === e), f && !1 === p && d.length || (r = t)) : (p = V(this, t), p = Ka(p, d, f, this.resolution, b, g, 1 === e));
r ? (p = V(this, t, r), p = Ka(p, d, f, this.S, b, g, 2 === e), f && !1 === p && d.length || (r = t)) : (p = V(this, t), p = Ka(p, d, f, this.resolution, b, g, 1 === e));
if (p) {
return p;
}
@@ -1200,11 +1200,11 @@ function V(a, b, c, d, e, f, g, h) {
if (a.db) {
return c ? a.db.get(k ? c : b, k ? b : c, d, e, f, g, h) : a.db.get(b, "", d, e, f, g, h);
}
a = c ? (a = a.F.get(k ? b : c)) && a.get(k ? c : b) : a.map.get(b);
a = c ? (a = a.ctx.get(k ? b : c)) && a.get(k ? c : b) : a.map.get(b);
return a;
}
;O.prototype.remove = function(a, b) {
const c = this.A.size && (this.fastupdate ? this.A.get(a) : this.A.has(a));
const c = this.reg.size && (this.fastupdate ? this.reg.get(a) : this.reg.has(a));
if (c) {
if (this.fastupdate) {
for (let d = 0, e; d < c.length; d++) {
@@ -1218,11 +1218,11 @@ function V(a, b, c, d, e, f, g, h) {
}
}
} else {
La(this.map, a), this.depth && La(this.F, a);
La(this.map, a), this.depth && La(this.ctx, a);
}
b || this.A.delete(a);
b || this.reg.delete(a);
}
this.db && (this.K.push({del:a}), this.W && Ca(this));
this.db && (this.I.push({del:a}), this.U && Ca(this));
this.cache && this.cache.remove(a);
return this;
};
@@ -1269,17 +1269,17 @@ function La(a, b) {
this.score = a.score || null;
(e = a.keystore || 0) && (this.keystore = e);
this.map = e ? new L(e) : new Map();
this.F = e ? new L(e) : new Map();
this.A = b || (this.fastupdate ? e ? new L(e) : new Map() : e ? new M(e) : new Set());
this.U = c.resolution || 1;
this.ctx = e ? new L(e) : new Map();
this.reg = b || (this.fastupdate ? e ? new L(e) : new Map() : e ? new M(e) : new Set());
this.S = c.resolution || 1;
this.rtl = d.rtl || a.rtl || !1;
this.cache = (e = a.cache || null) && new H(e);
this.resolve = !1 !== a.resolve;
if (e = a.db) {
this.db = e.mount(this);
}
this.W = !1 !== a.commit;
this.K = [];
this.U = !1 !== a.commit;
this.I = [];
this.h = null;
}
u = O.prototype;
@@ -1299,17 +1299,17 @@ function Ca(a) {
}
u.clear = function() {
this.map.clear();
this.F.clear();
this.A.clear();
this.ctx.clear();
this.reg.clear();
this.cache && this.cache.clear();
this.db && (this.h && clearTimeout(this.h), this.h = null, this.K = [{clear:!0}]);
this.db && (this.h && clearTimeout(this.h), this.h = null, this.I = [{clear:!0}]);
return this;
};
u.append = function(a, b) {
return this.add(a, b, !0);
};
u.contain = function(a) {
return this.db ? this.db.has(a) : this.A.has(a);
return this.db ? this.db.has(a) : this.reg.has(a);
};
u.update = function(a, b) {
if (this.async) {
@@ -1337,7 +1337,7 @@ u.cleanup = function() {
return console.info('Cleanup the index isn\'t required when not using "fastupdate".'), this;
}
Ma(this.map);
this.depth && Ma(this.F);
this.depth && Ma(this.ctx);
return this;
};
u.searchCache = ma;
@@ -1352,16 +1352,16 @@ u.export = function(a, b, c, d, e, f) {
h = "reg";
if (this.fastupdate) {
k = z();
for (let l of this.A.keys()) {
for (let l of this.reg.keys()) {
k[l] = 1;
}
} else {
k = this.A;
k = this.reg;
}
break;
case 1:
h = "cfg";
k = {doc:0, opt:this.B ? 1 : 0};
k = {doc:0, opt:this.A ? 1 : 0};
break;
case 2:
h = "map";
@@ -1369,7 +1369,7 @@ u.export = function(a, b, c, d, e, f) {
break;
case 3:
h = "ctx";
k = this.F;
k = this.ctx;
break;
default:
"undefined" === typeof c && f && f();
@@ -1382,20 +1382,70 @@ u.import = function(a, b) {
if (b) {
switch(B(b) && (b = JSON.parse(b)), a) {
case "cfg":
this.B = !!b.opt;
this.A = !!b.opt;
break;
case "reg":
this.fastupdate = !1;
this.A = b;
this.reg = b;
break;
case "map":
this.map = b;
break;
case "ctx":
this.F = b;
this.ctx = b;
}
}
};
u.serialize = function(a = !0) {
if (!this.reg.size) {
return "";
}
let b = "", c = "";
for (var d of this.reg.keys()) {
c || (c = typeof d), b += (b ? "," : "") + ("string" === c ? '"' + d + '"' : d);
}
b = "index.reg=new Set([" + b + "]);";
d = "";
for (var e of this.map.entries()) {
var f = e[0], g = e[1], h = "";
for (let m = 0, n; m < g.length; m++) {
n = g[m] || [""];
var k = "";
for (var l = 0; l < n.length; l++) {
k += (k ? "," : "") + ("string" === c ? '"' + n[l] + '"' : n[l]);
}
k = "[" + k + "]";
h += (h ? "," : "") + k;
}
h = '["' + f + '",[' + h + "]]";
d += (d ? "," : "") + h;
}
d = "index.map=new Map([" + d + "]);";
e = "";
for (const m of this.ctx.entries()) {
f = m[0];
g = m[1];
for (const n of g.entries()) {
g = n[0];
h = n[1];
k = "";
for (let q = 0, r; q < h.length; q++) {
r = h[q] || [""];
l = "";
for (let p = 0; p < r.length; p++) {
l += (l ? "," : "") + ("string" === c ? '"' + r[p] + '"' : r[p]);
}
l = "[" + l + "]";
k += (k ? "," : "") + l;
}
k = 'new Map([["' + g + '",[' + k + "]]])";
k = '["' + f + '",' + k + "]";
e += (e ? "," : "") + k;
}
}
e = "index.ctx=new Map([" + e + "]);";
return a ? "function inject(index){" + b + d + e + "}" : b + d + e;
};
Ba(O.prototype);
async function Na(a) {
a = a.data;
@@ -1466,24 +1516,24 @@ function Pa(a, b, c) {
;Y.prototype.add = function(a, b, c) {
C(a) && (b = a, a = ca(b, this.key));
if (b && (a || 0 === a)) {
if (!c && this.A.has(a)) {
if (!c && this.reg.has(a)) {
return this.update(a, b);
}
for (let h = 0, k; h < this.field.length; h++) {
k = this.I[h];
k = this.G[h];
var d = this.index.get(this.field[h]);
if ("function" === typeof k) {
var e = k(b);
e && d.add(a, e, !1, !0);
} else {
if (e = k.L, !e || e(b)) {
k.constructor === String ? k = ["" + k] : B(k) && (k = [k]), Qa(b, k, this.N, 0, d, a, k[0], c);
if (e = k.J, !e || e(b)) {
k.constructor === String ? k = ["" + k] : B(k) && (k = [k]), Qa(b, k, this.L, 0, d, a, k[0], c);
}
}
}
if (this.tag) {
for (d = 0; d < this.H.length; d++) {
var f = this.H[d], g = this.R[d];
for (d = 0; d < this.F.length; d++) {
var f = this.F[d], g = this.O[d];
e = this.tag.get(g);
let h = z();
if ("function" === typeof f) {
@@ -1491,7 +1541,7 @@ function Pa(a, b, c) {
continue;
}
} else {
const k = f.L;
const k = f.J;
if (k && !k(b)) {
continue;
}
@@ -1505,14 +1555,14 @@ function Pa(a, b, c) {
if (m.length === 2 ** 31 - 1) {
g = new K(m);
if (this.fastupdate) {
for (let n of this.A.values()) {
for (let n of this.reg.values()) {
n.includes(m) && (n[n.indexOf(m)] = g);
}
}
e.set(l, m = g);
}
m.push(a);
this.fastupdate && ((g = this.A.get(a)) ? g.push(m) : this.A.set(a, [m]));
this.fastupdate && ((g = this.reg.get(a)) ? g.push(m) : this.reg.set(a, [m]));
}
}
} else {
@@ -1522,11 +1572,11 @@ function Pa(a, b, c) {
}
if (this.store && (!c || !this.store.has(a))) {
let h;
if (this.D) {
if (this.C) {
h = z();
for (let k = 0, l; k < this.D.length; k++) {
l = this.D[k];
if ((c = l.L) && !c(b)) {
for (let k = 0, l; k < this.C.length; k++) {
l = this.C[k];
if ((c = l.J) && !c(b)) {
continue;
}
let m;
@@ -1535,7 +1585,7 @@ function Pa(a, b, c) {
if (!m) {
continue;
}
l = [l.X];
l = [l.V];
} else if (B(l) || l.constructor === String) {
h[l] = b[l];
continue;
@@ -1672,7 +1722,7 @@ function Qa(a, b, c, d, e, f, g, h) {
let A;
for (let w = 0, v, I, J; w < k.length; w++) {
I = k[w];
if (this.db && this.tag && !this.I[w]) {
if (this.db && this.tag && !this.G[w]) {
continue;
}
let D;
@@ -1680,7 +1730,7 @@ function Qa(a, b, c, d, e, f, g, h) {
if (d) {
v = d[w];
} else {
if (t = D || c, x = this.index.get(I), n && (this.db && (t.tag = n, A = x.db.Z, t.field = k), A || (t.enrich = !1)), p) {
if (t = D || c, x = this.index.get(I), n && (this.db && (t.tag = n, A = x.db.X, t.field = k), A || (t.enrich = !1)), p) {
p[w] = x.searchAsync(a, b, t);
t && q && (t.enrich = q);
continue;
@@ -1821,13 +1871,13 @@ function Ta(a) {
}
const b = a.document || a.doc || a;
var c, d;
this.I = [];
this.G = [];
this.field = [];
this.N = [];
this.key = (c = b.key || b.id) && Va(c, this.N) || "id";
this.L = [];
this.key = (c = b.key || b.id) && Va(c, this.L) || "id";
(d = a.keystore || 0) && (this.keystore = d);
this.A = (this.fastupdate = !!a.fastupdate) ? d ? new L(d) : new Map() : d ? new M(d) : new Set();
this.D = (c = b.store || null) && !0 !== c && [];
this.reg = (this.fastupdate = !!a.fastupdate) ? d ? new L(d) : new Map() : d ? new M(d) : new Set();
this.C = (c = b.store || null) && !0 !== c && [];
this.store = c && (d ? new L(d) : new Map());
this.cache = (c = a.cache || null) && new H(c);
a.cache = !1;
@@ -1845,15 +1895,15 @@ function Ta(a) {
c.set(f, h);
h.worker || (this.worker = !1);
}
this.worker || c.set(f, new O(g, this.A));
g.custom ? this.I[e] = g.custom : (this.I[e] = Va(f, this.N), g.filter && ("string" === typeof this.I[e] && (this.I[e] = new String(this.I[e])), this.I[e].L = g.filter));
this.worker || c.set(f, new O(g, this.reg));
g.custom ? this.G[e] = g.custom : (this.G[e] = Va(f, this.L), g.filter && ("string" === typeof this.G[e] && (this.G[e] = new String(this.G[e])), this.G[e].J = g.filter));
this.field[e] = f;
}
if (this.D) {
if (this.C) {
d = b.store;
B(d) && (d = [d]);
for (let e = 0, f, g; e < d.length; e++) {
f = d[e], g = f.field || f, f.custom ? (this.D[e] = f.custom, f.custom.X = g) : (this.D[e] = Va(g, this.N), f.filter && ("string" === typeof this.D[e] && (this.D[e] = new String(this.D[e])), this.D[e].L = f.filter));
f = d[e], g = f.field || f, f.custom ? (this.C[e] = f.custom, f.custom.V = g) : (this.C[e] = Va(g, this.L), f.filter && ("string" === typeof this.C[e] && (this.C[e] = new String(this.C[e])), this.C[e].J = f.filter));
}
}
this.index = c;
@@ -1861,16 +1911,16 @@ function Ta(a) {
if (c = b.tag) {
if ("string" === typeof c && (c = [c]), c.length) {
this.tag = new Map();
this.H = [];
this.R = [];
this.F = [];
this.O = [];
for (let e = 0, f, g; e < c.length; e++) {
f = c[e];
g = f.field || f;
if (!g) {
throw Error("The tag field from the document descriptor is undefined.");
}
f.custom ? this.H[e] = f.custom : (this.H[e] = Va(g, this.N), f.filter && ("string" === typeof this.H[e] && (this.H[e] = new String(this.H[e])), this.H[e].L = f.filter));
this.R[e] = g;
f.custom ? this.F[e] = f.custom : (this.F[e] = Va(g, this.L), f.filter && ("string" === typeof this.F[e] && (this.F[e] = new String(this.F[e])), this.F[e].J = f.filter));
this.O[e] = g;
this.tag.set(g, new Map());
}
}
@@ -1881,10 +1931,10 @@ u = Y.prototype;
u.mount = function(a) {
let b = this.field;
if (this.tag) {
for (let e = 0, f; e < this.R.length; e++) {
f = this.R[e];
for (let e = 0, f; e < this.O.length; e++) {
f = this.O[e];
var c = this.index.get(f);
c || (this.index.set(f, c = new O({}, this.A)), b === this.field && (b = b.slice(0)), b.push(f));
c || (this.index.set(f, c = new O({}, this.reg)), b === this.field && (b = b.slice(0)), b.push(f));
c.tag = this.tag.get(f);
}
}
@@ -1897,7 +1947,7 @@ u.mount = function(a) {
h.id = a.id;
c[e] = h.mount(f);
f.document = !0;
e ? f.Y = !0 : f.store = this.store;
e ? f.W = !0 : f.store = this.store;
}
this.db = this.async = !0;
return Promise.all(c);
@@ -1908,7 +1958,7 @@ u.commit = async function(a, b) {
c.push(d.db.commit(d, a, b));
}
await Promise.all(c);
this.A.clear();
this.reg.clear();
};
function Va(a, b) {
const c = a.split(":");
@@ -1930,7 +1980,7 @@ u.remove = function(a) {
for (var b of this.index.values()) {
b.remove(a, !0);
}
if (this.A.has(a)) {
if (this.reg.has(a)) {
if (this.tag && !this.fastupdate) {
for (let c of this.tag.values()) {
for (let d of c) {
@@ -1941,7 +1991,7 @@ u.remove = function(a) {
}
}
this.store && this.store.delete(a);
this.A.delete(a);
this.reg.delete(a);
}
this.cache && this.cache.remove(a);
return this;
@@ -1959,7 +2009,7 @@ u.clear = function() {
return this;
};
u.contain = function(a) {
return this.db ? this.index.get(this.field[0]).db.has(a) : this.A.has(a);
return this.db ? this.index.get(this.field[0]).db.has(a) : this.reg.has(a);
};
u.cleanup = function() {
for (const a of this.index.values()) {
@@ -2017,9 +2067,9 @@ u.import = function(a, b) {
break;
case "reg":
this.fastupdate = !1;
this.A = b;
this.reg = b;
for (let d = 0, e; d < this.field.length; d++) {
e = this.index[this.field[d]], e.A = b, e.fastupdate = !1;
e = this.index[this.field[d]], e.reg = b, e.fastupdate = !1;
}
break;
case "store":
@@ -2043,7 +2093,7 @@ function Ya(a, b = {}) {
a || console.info("Default storage space was used, because a name was not passed.");
this.id = "flexsearch" + (a ? ":" + a.toLowerCase().replace(/[^a-z0-9_\-]/g, "") : "");
this.field = b.field ? b.field.toLowerCase().replace(/[^a-z0-9_\-]/g, "") : "";
this.Z = !1;
this.X = !1;
this.db = null;
this.h = {};
}
@@ -2183,22 +2233,22 @@ u.transaction = function(a, b, c) {
};
u.commit = async function(a, b, c) {
if (b) {
await this.clear(), a.K = [];
await this.clear(), a.I = [];
} else {
let d = a.K;
a.K = [];
let d = a.I;
a.I = [];
for (let e = 0, f; e < d.length; e++) {
if (f = d[e], f.clear) {
await this.clear();
b = !0;
break;
} else {
d[e] = f.$;
d[e] = f.Y;
}
}
b || (c || (d = d.concat(ba(a.A))), d.length && await this.remove(d));
b || (c || (d = d.concat(ba(a.reg))), d.length && await this.remove(d));
}
a.A.size && (await this.transaction("map", "readwrite", function(d) {
a.reg.size && (await this.transaction("map", "readwrite", function(d) {
for (const e of a.map) {
const f = e[0], g = e[1];
g.length && (b ? d.put(g, f) : d.get(f).onsuccess = function() {
@@ -2225,7 +2275,7 @@ u.commit = async function(a, b, c) {
});
}
}), await this.transaction("ctx", "readwrite", function(d) {
for (const e of a.F) {
for (const e of a.ctx) {
const f = e[0], g = e[1];
for (const h of g) {
const k = h[0], l = h[1];
@@ -2258,8 +2308,8 @@ u.commit = async function(a, b, c) {
const f = e[0], g = e[1];
d.put("object" === typeof g ? JSON.stringify(g) : 1, f);
}
}) : a.Y || await this.transaction("reg", "readwrite", function(d) {
for (const e of a.A.keys()) {
}) : a.W || await this.transaction("reg", "readwrite", function(d) {
for (const e of a.reg.keys()) {
d.put(1, e);
}
}), a.tag && await this.transaction("tag", "readwrite", function(d) {
@@ -2271,7 +2321,7 @@ u.commit = async function(a, b, c) {
d.put(h, f);
});
}
}), a.map.clear(), a.F.clear(), a.tag && a.tag.clear(), a.store && a.store.clear(), a.document || a.A.clear());
}), a.map.clear(), a.ctx.clear(), a.tag && a.tag.clear(), a.store && a.store.clear(), a.document || a.reg.clear());
};
function ab(a, b, c) {
const d = a.value;

View File

@@ -15,75 +15,77 @@ function B(a){return"string"===typeof a}function C(a){return"object"===typeof a}
["\u0477","\u0475"],["\u04c2","\u0436"],["\u04d1","\u0430"],["\u04d3","\u0430"],["\u04d7","\u0435"],["\u04db","\u04d9"],["\u04dd","\u0436"],["\u04df","\u0437"],["\u04e3","\u0438"],["\u04e5","\u0438"],["\u04e7","\u043e"],["\u04eb","\u04e9"],["\u04ed","\u044d"],["\u04ef","\u0443"],["\u04f1","\u0443"],["\u04f3","\u0443"],["\u04f5","\u0447"]];const fa=/[^\p{L}\p{N}]+/u,ha=/(\d{3})/g,ia=/(\D)(\d{3})/g,ja=/(\d{3})(\D)/g,ka="".normalize&&/[\u0300-\u036f]/g;function F(a){if(!this)return new F(...arguments);for(let b=0;b<arguments.length;b++)this.assign(arguments[b])}
F.prototype.assign=function(a){this.normalize=y(a.normalize,!0,this.normalize);let b=a.include,c=b||a.exclude||a.split;if("object"===typeof c){let d=!b,e="";a.include||(e+="\\p{Z}");c.letter&&(e+="\\p{L}");c.number&&(e+="\\p{N}",d=!!b);c.symbol&&(e+="\\p{S}");c.punctuation&&(e+="\\p{P}");c.control&&(e+="\\p{C}");if(c=c.char)e+="object"===typeof c?c.join(""):c;this.split=new RegExp("["+(b?"^":"")+e+"]+","u");this.numeric=d}else this.split=y(c,fa,this.split),this.numeric=y(this.numeric,!0);this.prepare=
y(a.prepare,null,this.prepare);this.finalize=y(a.finalize,null,this.finalize);ka||(this.mapper=new Map(ea));this.rtl=a.rtl||!1;this.dedupe=y(a.dedupe,!0,this.dedupe);this.filter=y((c=a.filter)&&new Set(c),null,this.filter);this.matcher=y((c=a.matcher)&&new Map(c),null,this.matcher);this.mapper=y((c=a.mapper)&&new Map(c),null,this.mapper);this.stemmer=y((c=a.stemmer)&&new Map(c),null,this.stemmer);this.replacer=y(a.replacer,null,this.replacer);this.minlength=y(a.minlength,1,this.minlength);this.maxlength=
y(a.maxlength,0,this.maxlength);if(this.cache=c=y(a.cache,!0,this.cache))this.O=null,this.V="number"===typeof c?c:2E5,this.J=new Map,this.M=new Map,this.B=this.h=128;this.C="";this.S=null;this.P="";this.T=null;if(this.matcher)for(const d of this.matcher.keys())this.C+=(this.C?"|":"")+d;if(this.stemmer)for(const d of this.stemmer.keys())this.P+=(this.P?"|":"")+d;return this};
F.prototype.encode=function(a){if(this.cache&&a.length<=this.h)if(this.O){if(this.J.has(a))return this.J.get(a)}else this.O=setTimeout(la,0,this);this.normalize&&(a="function"===typeof this.normalize?this.normalize(a):ka?a.normalize("NFKD").replace(ka,"").toLowerCase():a.toLowerCase());this.prepare&&(a=this.prepare(a));this.numeric&&3<a.length&&(a=a.replace(ia,"$1 $2").replace(ja,"$1 $2").replace(ha,"$1 "));const b=!(this.dedupe||this.mapper||this.filter||this.matcher||this.stemmer||this.replacer);
let c=[],d=this.split||""===this.split?a.split(this.split):a;for(let f=0,g,h;f<d.length;f++){if(!(g=h=d[f]))continue;if(g.length<this.minlength)continue;if(b){c.push(g);continue}if(this.filter&&this.filter.has(g))continue;if(this.cache&&g.length<=this.B)if(this.O){var e=this.M.get(g);if(e||""===e){e&&c.push(e);continue}}else this.O=setTimeout(la,0,this);let k;this.stemmer&&2<g.length&&(this.T||(this.T=new RegExp("(?!^)("+this.P+")$")),g=g.replace(this.T,l=>this.stemmer.get(l)),k=1);this.matcher&&
1<g.length&&(this.S||(this.S=new RegExp("("+this.C+")","g")),g=g.replace(this.S,l=>this.matcher.get(l)),k=1);g&&k&&(g.length<this.minlength||this.filter&&this.filter.has(g))&&(g="");if(g&&(this.mapper||this.dedupe&&1<g.length)){e="";for(let l=0,m="",n,q;l<g.length;l++)n=g.charAt(l),n===m&&this.dedupe||((q=this.mapper&&this.mapper.get(n))||""===q?q===m&&this.dedupe||!(m=q)||(e+=q):e+=m=n);g=e}if(g&&this.replacer)for(e=0;g&&e<this.replacer.length;e+=2)g=g.replace(this.replacer[e],this.replacer[e+1]);
this.cache&&h.length<=this.B&&(this.M.set(h,g),this.M.size>this.V&&(this.M.clear(),this.B=this.B/1.1|0));g&&c.push(g)}this.finalize&&(c=this.finalize(c)||c);this.cache&&a.length<=this.h&&(this.J.set(a,c),this.J.size>this.V&&(this.J.clear(),this.h=this.h/1.1|0));return c};function la(a){a.O=null;a.J.clear();a.M.clear()};function ma(a,b,c){a=("object"===typeof a?""+a.query:a).toLowerCase();let d=this.cache.get(a);if(!d){d=this.search(a,b,c);if(d.then){const e=this;d.then(function(f){e.cache.set(a,f);return f})}this.cache.set(a,d)}return d}function G(a){this.limit=a&&!0!==a?a:1E3;this.cache=new Map;this.h=""}G.prototype.set=function(a,b){this.cache.set(this.h=a,b);this.cache.size>this.limit&&this.cache.delete(this.cache.keys().next().value)};
y(a.maxlength,0,this.maxlength);if(this.cache=c=y(a.cache,!0,this.cache))this.M=null,this.T="number"===typeof c?c:2E5,this.H=new Map,this.K=new Map,this.A=this.h=128;this.B="";this.P=null;this.N="";this.R=null;if(this.matcher)for(const d of this.matcher.keys())this.B+=(this.B?"|":"")+d;if(this.stemmer)for(const d of this.stemmer.keys())this.N+=(this.N?"|":"")+d;return this};
F.prototype.encode=function(a){if(this.cache&&a.length<=this.h)if(this.M){if(this.H.has(a))return this.H.get(a)}else this.M=setTimeout(la,0,this);this.normalize&&(a="function"===typeof this.normalize?this.normalize(a):ka?a.normalize("NFKD").replace(ka,"").toLowerCase():a.toLowerCase());this.prepare&&(a=this.prepare(a));this.numeric&&3<a.length&&(a=a.replace(ia,"$1 $2").replace(ja,"$1 $2").replace(ha,"$1 "));const b=!(this.dedupe||this.mapper||this.filter||this.matcher||this.stemmer||this.replacer);
let c=[],d=this.split||""===this.split?a.split(this.split):a;for(let f=0,g,h;f<d.length;f++){if(!(g=h=d[f]))continue;if(g.length<this.minlength)continue;if(b){c.push(g);continue}if(this.filter&&this.filter.has(g))continue;if(this.cache&&g.length<=this.A)if(this.M){var e=this.K.get(g);if(e||""===e){e&&c.push(e);continue}}else this.M=setTimeout(la,0,this);let k;this.stemmer&&2<g.length&&(this.R||(this.R=new RegExp("(?!^)("+this.N+")$")),g=g.replace(this.R,l=>this.stemmer.get(l)),k=1);this.matcher&&
1<g.length&&(this.P||(this.P=new RegExp("("+this.B+")","g")),g=g.replace(this.P,l=>this.matcher.get(l)),k=1);g&&k&&(g.length<this.minlength||this.filter&&this.filter.has(g))&&(g="");if(g&&(this.mapper||this.dedupe&&1<g.length)){e="";for(let l=0,m="",n,q;l<g.length;l++)n=g.charAt(l),n===m&&this.dedupe||((q=this.mapper&&this.mapper.get(n))||""===q?q===m&&this.dedupe||!(m=q)||(e+=q):e+=m=n);g=e}if(g&&this.replacer)for(e=0;g&&e<this.replacer.length;e+=2)g=g.replace(this.replacer[e],this.replacer[e+1]);
this.cache&&h.length<=this.A&&(this.K.set(h,g),this.K.size>this.T&&(this.K.clear(),this.A=this.A/1.1|0));g&&c.push(g)}this.finalize&&(c=this.finalize(c)||c);this.cache&&a.length<=this.h&&(this.H.set(a,c),this.H.size>this.T&&(this.H.clear(),this.h=this.h/1.1|0));return c};function la(a){a.M=null;a.H.clear();a.K.clear()};function ma(a,b,c){a=("object"===typeof a?""+a.query:a).toLowerCase();let d=this.cache.get(a);if(!d){d=this.search(a,b,c);if(d.then){const e=this;d.then(function(f){e.cache.set(a,f);return f})}this.cache.set(a,d)}return d}function G(a){this.limit=a&&!0!==a?a:1E3;this.cache=new Map;this.h=""}G.prototype.set=function(a,b){this.cache.set(this.h=a,b);this.cache.size>this.limit&&this.cache.delete(this.cache.keys().next().value)};
G.prototype.get=function(a){const b=this.cache.get(a);b&&this.h!==a&&(this.cache.delete(a),this.cache.set(this.h=a,b));return b};G.prototype.remove=function(a){for(const b of this.cache){const c=b[0];b[1].includes(a)&&this.cache.delete(c)}};G.prototype.clear=function(){this.cache.clear();this.h=""};const na={normalize:function(a){return a.toLowerCase()},dedupe:!1};const oa=new Map([["b","p"],["v","f"],["w","f"],["z","s"],["x","s"],["d","t"],["n","m"],["c","k"],["g","k"],["j","k"],["q","k"],["i","e"],["y","e"],["u","o"]]);const pa=new Map([["ai","ei"],["ae","a"],["oe","o"],["ue","u"],["sh","s"],["ch","c"],["th","t"],["ph","f"],["pf","f"]]),qa=[/([^aeo])h([aeo$])/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2"];const ra={a:"",e:"",i:"",o:"",u:"",y:"",b:1,f:1,p:1,v:1,c:2,g:2,j:2,k:2,q:2,s:2,x:2,z:2,"\u00df":2,d:3,t:3,l:4,m:5,n:5,r:6};const sa=/[\x00-\x7F]+/g;const ta=/[\x00-\x7F]+/g;const ua=/[\x00-\x7F]+/g;var va={LatinExact:{normalize:!1,dedupe:!1},LatinDefault:na,LatinSimple:{normalize:!0,dedupe:!0},LatinBalance:{normalize:!0,dedupe:!0,mapper:oa},LatinAdvanced:{normalize:!0,dedupe:!0,mapper:oa,replacer:qa,matcher:pa},LatinExtra:{normalize:!0,dedupe:!0,mapper:oa,replacer:qa.concat([/(?!^)[aeoy]/g,""]),matcher:pa},LatinSoundex:{normalize:!0,dedupe:!1,include:{letter:!0},finalize:function(a){for(let c=0;c<a.length;c++){var b=a[c];let d=b.charAt(0),e=ra[d];for(let f=1,g;f<b.length&&(g=b.charAt(f),"h"===
g||"w"===g||!(g=ra[g])||g===e||(d+=g,e=g,4!==d.length));f++);a[c]=d}}},ArabicDefault:{rtl:!0,normalize:!1,dedupe:!0,prepare:function(a){return(""+a).replace(sa," ")}},CjkDefault:{normalize:!1,dedupe:!0,split:"",prepare:function(a){return(""+a).replace(ta,"")}},CyrillicDefault:{normalize:!1,dedupe:!0,prepare:function(a){return(""+a).replace(ua," ")}}};function wa(a,b,c,d){let e=[];for(let f=0,g;f<a.index.length;f++)if(g=a.index[f],b>=g.length)b-=g.length;else{b=g[d?"splice":"slice"](b,c);const h=b.length;if(h&&(e=e.length?e.concat(b):b,c-=h,d&&(a.length-=h),!c))break;b=0}return e}
function J(a){if(!this)return new J(a);this.index=a?[a]:[];this.length=a?a.length:0;const b=this;return new Proxy([],{get(c,d){if("length"===d)return b.length;if("push"===d)return function(e){b.index[b.index.length-1].push(e);b.length++};if("pop"===d)return function(){if(b.length)return b.length--,b.index[b.index.length-1].pop()};if("indexOf"===d)return function(e){let f=0;for(let g=0,h,k;g<b.index.length;g++){h=b.index[g];k=h.indexOf(e);if(0<=k)return f+k;f+=h.length}return-1};if("includes"===d)return function(e){for(let f=
0;f<b.index.length;f++)if(b.index[f].includes(e))return!0;return!1};if("slice"===d)return function(e,f){return wa(b,e||0,f||b.length,!1)};if("splice"===d)return function(e,f){return wa(b,e||0,f||b.length,!0)};if("constructor"===d)return Array;if("symbol"!==typeof d)return(c=b.index[d/2**31|0])&&c[d]},set(c,d,e){c=d/2**31|0;(b.index[c]||(b.index[c]=[]))[d]=e;b.length++;return!0}})}J.prototype.clear=function(){this.index.length=0};J.prototype.push=function(){};
function K(a=8){if(!this)return new K(a);this.index=z();this.C=[];this.size=0;32<a?(this.h=xa,this.B=BigInt(a)):(this.h=ya,this.B=a)}K.prototype.get=function(a){const b=this.index[this.h(a)];return b&&b.get(a)};K.prototype.set=function(a,b){var c=this.h(a);let d=this.index[c];d?(c=d.size,d.set(a,b),(c-=d.size)&&this.size++):(this.index[c]=d=new Map([[a,b]]),this.C.push(d))};function M(a=8){if(!this)return new M(a);this.index=z();this.h=[];32<a?(this.C=xa,this.B=BigInt(a)):(this.C=ya,this.B=a)}
M.prototype.add=function(a){var b=this.C(a);let c=this.index[b];c?(b=c.size,c.add(a),(b-=c.size)&&this.size++):(this.index[b]=c=new Set([a]),this.h.push(c))};u=K.prototype;u.has=M.prototype.has=function(a){const b=this.index[this.C(a)];return b&&b.has(a)};u.delete=M.prototype.delete=function(a){const b=this.index[this.C(a)];b&&b.delete(a)&&this.size--};u.clear=M.prototype.clear=function(){this.index=z();this.h=[];this.size=0};u.values=M.prototype.values=function*(){for(let a=0;a<this.h.length;a++)for(let b of this.h[a].values())yield b};
u.keys=M.prototype.keys=function*(){for(let a=0;a<this.h.length;a++)for(let b of this.h[a].keys())yield b};u.entries=M.prototype.entries=function*(){for(let a=0;a<this.h.length;a++)for(let b of this.h[a].entries())yield b};function ya(a){let b=2**this.B-1;if("number"==typeof a)return a&b;let c=0,d=this.B+1;for(let e=0;e<a.length;e++)c=(c*d^a.charCodeAt(e))&b;return 32===this.B?c+2**31:c}
function xa(a){let b=BigInt(2)**this.B-BigInt(1);var c=typeof a;if("bigint"===c)return a&b;if("number"===c)return BigInt(a)&b;c=BigInt(0);let d=this.B+BigInt(1);for(let e=0;e<a.length;e++)c=(c*d^BigInt(a.charCodeAt(e)))&b;return c};function za(a,b,c,d,e,f,g,h){(d=a(c?c+"."+d:d,JSON.stringify(g)))&&d.then?d.then(function(){b.export(a,b,c,e,f+1,h)}):b.export(a,b,c,e,f+1,h)};const Aa={memory:{resolution:1},performance:{resolution:6,fastupdate:!0,context:{depth:1,resolution:3}},match:{tokenize:"forward"},score:{resolution:9,context:{depth:2,resolution:9}}};function Ba(a){N.call(a,"add");N.call(a,"append");N.call(a,"search");N.call(a,"update");N.call(a,"remove")}function N(a){this[a+"Async"]=function(){var b=arguments;const c=b[b.length-1];let d;"function"===typeof c&&(d=c,delete b[b.length-1]);this.async=!0;b=this[a].apply(this,b);this.async=!1;d&&(b.then?b.then(d):d(b));return b}};z();O.prototype.add=function(a,b,c,d){if(b&&(a||0===a)){if(!d&&!c&&this.A.has(a))return this.update(a,b);b=this.encoder.encode(b);if(d=b.length){const l=z(),m=z(),n=this.depth,q=this.resolution;for(let r=0;r<d;r++){let p=b[this.rtl?d-1-r:r];var e=p.length;if(e&&(n||!m[p])){var f=this.score?this.score(b,p,r,null,0):P(q,d,r),g="";switch(this.tokenize){case "full":if(2<e){for(f=0;f<e;f++)for(var h=e;h>f;h--){g=p.substring(f,h);var k=this.score?this.score(b,p,r,g,f):P(q,d,r,e,f);Q(this,m,g,k,a,c)}break}case "reverse":if(1<
e){for(h=e-1;0<h;h--)g=p[h]+g,k=this.score?this.score(b,p,r,g,h):P(q,d,r,e,h),Q(this,m,g,k,a,c);g=""}case "forward":if(1<e){for(h=0;h<e;h++)g+=p[h],Q(this,m,g,f,a,c);break}default:if(Q(this,m,p,f,a,c),n&&1<d&&r<d-1)for(e=z(),g=this.U,f=p,h=Math.min(n+1,d-r),e[f]=1,k=1;k<h;k++)if((p=b[this.rtl?d-1-r-k:r+k])&&!e[p]){e[p]=1;const t=this.score?this.score(b,f,r,p,k):P(g+(d/2>g?0:1),d,r,h-1,k-1),x=this.bidirectional&&p>f;Q(this,l,x?f:p,t,a,c,x?p:f)}}}}this.fastupdate||this.A.add(a)}else b=""}this.db&&(b||
this.K.push({del:a}),this.W&&Ca(this));return this};function Q(a,b,c,d,e,f,g){let h=g?a.F:a.map,k;if(!b[c]||!g||!(k=b[c])[g])if(g?(b=k||(b[c]=z()),b[g]=1,(k=h.get(g))?h=k:h.set(g,h=new Map)):b[c]=1,(k=h.get(c))?h=k:h.set(c,h=k=[]),h=h[d]||(h[d]=[]),!f||!h.includes(e)){if(h.length===2**31-1){b=new J(h);if(a.fastupdate)for(let l of a.A.values())l.includes(h)&&(l[l.indexOf(h)]=b);k[d]=h=b}h.push(e);a.fastupdate&&((d=a.A.get(e))?d.push(h):a.A.set(e,[h]))}}
function K(a=8){if(!this)return new K(a);this.index=z();this.B=[];this.size=0;32<a?(this.h=xa,this.A=BigInt(a)):(this.h=ya,this.A=a)}K.prototype.get=function(a){const b=this.index[this.h(a)];return b&&b.get(a)};K.prototype.set=function(a,b){var c=this.h(a);let d=this.index[c];d?(c=d.size,d.set(a,b),(c-=d.size)&&this.size++):(this.index[c]=d=new Map([[a,b]]),this.B.push(d))};function M(a=8){if(!this)return new M(a);this.index=z();this.h=[];32<a?(this.B=xa,this.A=BigInt(a)):(this.B=ya,this.A=a)}
M.prototype.add=function(a){var b=this.B(a);let c=this.index[b];c?(b=c.size,c.add(a),(b-=c.size)&&this.size++):(this.index[b]=c=new Set([a]),this.h.push(c))};u=K.prototype;u.has=M.prototype.has=function(a){const b=this.index[this.B(a)];return b&&b.has(a)};u.delete=M.prototype.delete=function(a){const b=this.index[this.B(a)];b&&b.delete(a)&&this.size--};u.clear=M.prototype.clear=function(){this.index=z();this.h=[];this.size=0};u.values=M.prototype.values=function*(){for(let a=0;a<this.h.length;a++)for(let b of this.h[a].values())yield b};
u.keys=M.prototype.keys=function*(){for(let a=0;a<this.h.length;a++)for(let b of this.h[a].keys())yield b};u.entries=M.prototype.entries=function*(){for(let a=0;a<this.h.length;a++)for(let b of this.h[a].entries())yield b};function ya(a){let b=2**this.A-1;if("number"==typeof a)return a&b;let c=0,d=this.A+1;for(let e=0;e<a.length;e++)c=(c*d^a.charCodeAt(e))&b;return 32===this.A?c+2**31:c}
function xa(a){let b=BigInt(2)**this.A-BigInt(1);var c=typeof a;if("bigint"===c)return a&b;if("number"===c)return BigInt(a)&b;c=BigInt(0);let d=this.A+BigInt(1);for(let e=0;e<a.length;e++)c=(c*d^BigInt(a.charCodeAt(e)))&b;return c};function za(a,b,c,d,e,f,g,h){(d=a(c?c+"."+d:d,JSON.stringify(g)))&&d.then?d.then(function(){b.export(a,b,c,e,f+1,h)}):b.export(a,b,c,e,f+1,h)};const Aa={memory:{resolution:1},performance:{resolution:6,fastupdate:!0,context:{depth:1,resolution:3}},match:{tokenize:"forward"},score:{resolution:9,context:{depth:2,resolution:9}}};function Ba(a){N.call(a,"add");N.call(a,"append");N.call(a,"search");N.call(a,"update");N.call(a,"remove")}function N(a){this[a+"Async"]=function(){var b=arguments;const c=b[b.length-1];let d;"function"===typeof c&&(d=c,delete b[b.length-1]);this.async=!0;b=this[a].apply(this,b);this.async=!1;d&&(b.then?b.then(d):d(b));return b}};z();O.prototype.add=function(a,b,c,d){if(b&&(a||0===a)){if(!d&&!c&&this.reg.has(a))return this.update(a,b);b=this.encoder.encode(b);if(d=b.length){const l=z(),m=z(),n=this.depth,q=this.resolution;for(let r=0;r<d;r++){let p=b[this.rtl?d-1-r:r];var e=p.length;if(e&&(n||!m[p])){var f=this.score?this.score(b,p,r,null,0):P(q,d,r),g="";switch(this.tokenize){case "full":if(2<e){for(f=0;f<e;f++)for(var h=e;h>f;h--){g=p.substring(f,h);var k=this.score?this.score(b,p,r,g,f):P(q,d,r,e,f);Q(this,m,g,k,a,c)}break}case "reverse":if(1<
e){for(h=e-1;0<h;h--)g=p[h]+g,k=this.score?this.score(b,p,r,g,h):P(q,d,r,e,h),Q(this,m,g,k,a,c);g=""}case "forward":if(1<e){for(h=0;h<e;h++)g+=p[h],Q(this,m,g,f,a,c);break}default:if(Q(this,m,p,f,a,c),n&&1<d&&r<d-1)for(e=z(),g=this.S,f=p,h=Math.min(n+1,d-r),e[f]=1,k=1;k<h;k++)if((p=b[this.rtl?d-1-r-k:r+k])&&!e[p]){e[p]=1;const t=this.score?this.score(b,f,r,p,k):P(g+(d/2>g?0:1),d,r,h-1,k-1),x=this.bidirectional&&p>f;Q(this,l,x?f:p,t,a,c,x?p:f)}}}}this.fastupdate||this.reg.add(a)}else b=""}this.db&&
(b||this.I.push({del:a}),this.U&&Ca(this));return this};function Q(a,b,c,d,e,f,g){let h=g?a.ctx:a.map,k;if(!b[c]||!g||!(k=b[c])[g])if(g?(b=k||(b[c]=z()),b[g]=1,(k=h.get(g))?h=k:h.set(g,h=new Map)):b[c]=1,(k=h.get(c))?h=k:h.set(c,h=k=[]),h=h[d]||(h[d]=[]),!f||!h.includes(e)){if(h.length===2**31-1){b=new J(h);if(a.fastupdate)for(let l of a.reg.values())l.includes(h)&&(l[l.indexOf(h)]=b);k[d]=h=b}h.push(e);a.fastupdate&&((d=a.reg.get(e))?d.push(h):a.reg.set(e,[h]))}}
function P(a,b,c,d,e){return c&&1<a?b+(d||0)<=a?c+(e||0):(a-1)/(b+(d||0))*(c+(e||0))+1|0:0};function R(a,b,c,d){if(1===a.length)return a=a[0],a=c||a.length>b?b?a.slice(c,c+b):a.slice(c):a,d?Da(a):a;let e=[];for(let f=0,g,h;f<a.length;f++)if((g=a[f])&&(h=g.length)){if(c){if(c>=h){c-=h;continue}c<h&&(g=b?g.slice(c,c+b):g.slice(c),h=g.length,c=0)}if(e.length)h>b&&(g=g.slice(0,b),h=g.length),e.push(g);else{if(h>=b)return h>b&&(g=g.slice(0,b)),d?Da(g):g;e=[g]}b-=h;if(!b)break}if(!e.length)return e;e=1<e.length?[].concat.apply([],e):e[0];return d?Da(e):e}
function Da(a){for(let b=0;b<a.length;b++)a[b]={score:b,id:a[b]};return a};S.prototype.or=function(){const a=this;let b=arguments;var c=b[0];if(c.then)return c.then(function(){return a.or.apply(a,b)});if(c[0]&&c[0].index)return this.or.apply(this,c);let d=[];c=[];let e=0,f=0,g,h;for(let k=0,l;k<b.length;k++)if(l=b[k]){let m;if(l.constructor===S)m=l.result;else if(l.constructor===Array)m=l;else if(l.index)l.resolve=!1,m=l.index.search(l).result;else if(l.and)m=this.and(l.and);else if(l.xor)m=this.xor(l.xor);else if(l.not)m=this.not(l.not);else{e=l.limit||0;f=l.offset||0;
g=l.enrich;h=l.resolve;continue}d[k]=m;m.then&&c.push(m)}if(c.length)return Promise.all(c).then(function(){a.result.length&&(d=[a.result].concat(d));a.result=Ea(d,e,f,g,h,a.G);return h?a.result:a});this.result.length&&(d=[this.result].concat(d));this.result=Ea(d,e,f,g,h,a.G);return h?this.result:this};
g=l.enrich;h=l.resolve;continue}d[k]=m;m.then&&c.push(m)}if(c.length)return Promise.all(c).then(function(){a.result.length&&(d=[a.result].concat(d));a.result=Ea(d,e,f,g,h,a.D);return h?a.result:a});this.result.length&&(d=[this.result].concat(d));this.result=Ea(d,e,f,g,h,a.D);return h?this.result:this};
function Ea(a,b,c,d,e,f){if(!a.length)return a;"object"===typeof b&&(c=b.offset||0,d=b.enrich||!1,b=b.limit||0);if(2>a.length)return e?R(a[0],b,c,d):a[0];d=[];let g=0,h=z(),k=da(a);for(let l=0,m;l<k;l++)for(let n=0,q;n<a.length;n++)if(q=a[n])if(m=q[l])for(let r=0,p;r<m.length;r++)if(p=m[r],!h[p])if(h[p]=1,c)c--;else{if(e)d.push(p);else{const t=l+(n?f:0);d[t]||(d[t]=[]);d[t].push(p)}if(b&&++g===b)return d}return d};S.prototype.and=function(){if(this.result.length){const b=this;let c=arguments;var a=c[0];if(a.then)return a.then(function(){return b.and.apply(b,c)});if(a[0]&&a[0].index)return this.and.apply(this,a);let d=[];a=[];let e=0,f=0,g;for(let h=0,k;h<c.length;h++)if(k=c[h]){let l;if(k.constructor===S)l=k.result;else if(k.constructor===Array)l=k;else if(k.index)k.resolve=!1,l=k.index.search(k).result;else if(k.or)l=this.or(k.or);else if(k.xor)l=this.xor(k.xor);else if(k.not)l=this.not(k.not);else{e=k.limit||
0;f=k.offset||0;g=k.resolve;continue}d[h]=l;l.then&&a.push(l)}if(a.length)return Promise.all(a).then(function(){d=[b.result].concat(d);b.result=Fa(d,e,f,g,b.G);return g?b.result:b});d=[this.result].concat(d);this.result=Fa(d,e,f,g,b.G);return g?this.result:this}return this};
0;f=k.offset||0;g=k.resolve;continue}d[h]=l;l.then&&a.push(l)}if(a.length)return Promise.all(a).then(function(){d=[b.result].concat(d);b.result=Fa(d,e,f,g,b.D);return g?b.result:b});d=[this.result].concat(d);this.result=Fa(d,e,f,g,b.D);return g?this.result:this}return this};
function Fa(a,b,c,d,e){if(2>a.length)return[];let f=[],g=0,h=z(),k=da(a);if(!k)return f;for(let l=0,m;l<a.length;l++){m=a[l];if(!m||!m.length)return[];let n=z(),q=0,r=l===a.length-1;for(let p=0,t;p<k;p++)if(t=m[p])for(let x=0,A,w;x<t.length;x++)if(A=t[x],!l)n[A]=p+1+(l?e:0),q=1;else if(r){if(w=h[A])if(q=1,c)c--;else if(d?f.push(A):(w--,p<w&&(w=p),f[w]||(f[w]=[]),f[w].push(A)),b&&++g===b)return f}else if(w=h[A])p+1<w&&(w=p+1),n[A]=w,q=1;if(!q)return[];h=n}return f};S.prototype.xor=function(){const a=this;let b=arguments;var c=b[0];if(c.then)return c.then(function(){return a.xor.apply(a,b)});if(c[0]&&c[0].index)return this.xor.apply(this,c);let d=[];c=[];let e=0,f=0,g,h;for(let k=0,l;k<b.length;k++)if(l=b[k]){let m;if(l.constructor===S)m=l.result;else if(l.constructor===Array)m=l;else if(l.index)l.resolve=!1,m=l.index.search(l).result;else if(l.or)m=this.or(l.or);else if(l.and)m=this.and(l.and);else if(l.not)m=this.not(l.not);else{e=l.limit||0;f=l.offset||0;
g=l.enrich;h=l.resolve;continue}d[k]=m;m.then&&c.push(m)}if(c.length)return Promise.all(c).then(function(){a.result.length&&(d=[a.result].concat(d));a.result=Ga(d,e,f,g,!h,a.G);return h?a.result:a});this.result.length&&(d=[this.result].concat(d));this.result=Ga(d,e,f,g,!h,a.G);return h?this.result:this};
g=l.enrich;h=l.resolve;continue}d[k]=m;m.then&&c.push(m)}if(c.length)return Promise.all(c).then(function(){a.result.length&&(d=[a.result].concat(d));a.result=Ga(d,e,f,g,!h,a.D);return h?a.result:a});this.result.length&&(d=[this.result].concat(d));this.result=Ga(d,e,f,g,!h,a.D);return h?this.result:this};
function Ga(a,b,c,d,e,f){if(!a.length)return a;if(2>a.length)return e?R(a[0],b,c,d):a[0];b=[];c=z();for(let g=0,h;g<a.length;g++)if(h=a[g])for(let k=0,l;k<h.length;k++)if(l=h[k])for(let m=0,n;m<l.length;m++)n=l[m],c[n]?c[n]++:c[n]=1;for(let g=0,h;g<a.length;g++)if(h=a[g])for(let k=0,l;k<h.length;k++)if(l=h[k])for(let m=0,n;m<l.length;m++)n=l[m],1===c[n]&&(e?b.push(n):(d=k+(g?f:0),b[d]||(b[d]=[]),b[d].push(n)));return b};S.prototype.not=function(){const a=this;let b=arguments;var c=b[0];if(c.then)return c.then(function(){return a.not.apply(a,b)});if(c[0]&&c[0].index)return this.not.apply(this,c);let d=[];c=[];let e;for(let f=0,g;f<b.length;f++)if(g=b[f]){let h;if(g.constructor===S)h=g.result;else if(g.constructor===Array)h=g;else if(g.index)g.resolve=!1,h=g.index.search(g).result;else if(g.or)h=this.or(g.or);else if(g.and)h=this.and(g.and);else if(g.xor)h=this.xor(g.xor);else{e=g.resolve;continue}d[f]=h;h.then&&c.push(h)}if(c.length)return Promise.all(c).then(function(){a.result=
Ha.call(a,d,e);return e?a.result:a});this.result=Ha.call(this,d,e);return e?this.result:this};function Ha(a,b){if(!a.length)return this.result;const c=[];a=new Set(a.flat().flat());for(let d=0,e;d<this.result.length;d++)if(e=this.result[d])for(let f=0,g;f<e.length;f++)g=e[f],a.has(g)||(b?c.push(g):(c[d]||(c[d]=[]),c[d].push(g)));return c};function S(a){if(!this)return new S(a);if(a&&a.index)return a.resolve=!1,this.index=a.index,a.index.search(a);if(a.constructor===S)return a;this.index=null;this.result=a||[];this.G=0}S.prototype.limit=function(a){if(this.result.length){const b=[];let c=0;for(let d=0,e;d<this.result.length;d++)if(e=this.result[d],e.length+c<a)b[d]=e,c+=e.length;else{b[d]=e.slice(0,a-c);this.result=b;break}}return this};
S.prototype.offset=function(a){if(this.result.length){const b=[];let c=0;for(let d=0,e;d<this.result.length;d++)e=this.result[d],e.length+c<a?c+=e.length:(b[d]=e.slice(a-c),c=a);this.result=b}return this};S.prototype.boost=function(a){this.G+=a;return this};S.prototype.resolve=function(a,b,c){T=1;const d=this.result;this.result=this.index=null;return d.length?("object"===typeof a&&(c=a.enrich,b=a.offset,a=a.limit),R(d,a||100,b,c)):d};function Ia(a,b,c,d,e){var f=a.length,g=[],h;var k=z();for(let n=0,q,r,p,t;n<b;n++)for(var l=0;l<f;l++)if(p=a[l],n<p.length&&(q=p[n]))for(var m=0;m<q.length;m++)r=q[m],(h=k[r])?k[r]++:(h=0,k[r]=1),t=g[h]||(g[h]=[]),t.push(r);if(a=g.length)if(e){if(1<g.length){e=g;f=[];g=z();k=e.length;for(l=0;l<k;l++)for(a=e[l],h=a.length,m=0;m<h;m++)if(b=a[m],!g[b])if(g[b]=1,d)d--;else if(f.push(b),f.length===c)break;c=f}else c=g[0];g=c}else{if(a<f)return[];g=g[a-1];if(g.length>c||d)g=g.slice(d,c+d)}return g}
Ha.call(a,d,e);return e?a.result:a});this.result=Ha.call(this,d,e);return e?this.result:this};function Ha(a,b){if(!a.length)return this.result;const c=[];a=new Set(a.flat().flat());for(let d=0,e;d<this.result.length;d++)if(e=this.result[d])for(let f=0,g;f<e.length;f++)g=e[f],a.has(g)||(b?c.push(g):(c[d]||(c[d]=[]),c[d].push(g)));return c};function S(a){if(!this)return new S(a);if(a&&a.index)return a.resolve=!1,this.index=a.index,a.index.search(a);if(a.constructor===S)return a;this.index=null;this.result=a||[];this.D=0}S.prototype.limit=function(a){if(this.result.length){const b=[];let c=0;for(let d=0,e;d<this.result.length;d++)if(e=this.result[d],e.length+c<a)b[d]=e,c+=e.length;else{b[d]=e.slice(0,a-c);this.result=b;break}}return this};
S.prototype.offset=function(a){if(this.result.length){const b=[];let c=0;for(let d=0,e;d<this.result.length;d++)e=this.result[d],e.length+c<a?c+=e.length:(b[d]=e.slice(a-c),c=a);this.result=b}return this};S.prototype.boost=function(a){this.D+=a;return this};S.prototype.resolve=function(a,b,c){T=1;const d=this.result;this.result=this.index=null;return d.length?("object"===typeof a&&(c=a.enrich,b=a.offset,a=a.limit),R(d,a||100,b,c)):d};function Ia(a,b,c,d,e){var f=a.length,g=[],h;var k=z();for(let n=0,q,r,p,t;n<b;n++)for(var l=0;l<f;l++)if(p=a[l],n<p.length&&(q=p[n]))for(var m=0;m<q.length;m++)r=q[m],(h=k[r])?k[r]++:(h=0,k[r]=1),t=g[h]||(g[h]=[]),t.push(r);if(a=g.length)if(e){if(1<g.length){e=g;f=[];g=z();k=e.length;for(l=0;l<k;l++)for(a=e[l],h=a.length,m=0;m<h;m++)if(b=a[m],!g[b])if(g[b]=1,d)d--;else if(f.push(b),f.length===c)break;c=f}else c=g[0];g=c}else{if(a<f)return[];g=g[a-1];if(g.length>c||d)g=g.slice(d,c+d)}return g}
function Ja(a,b){const c=z(),d=z(),e=[];for(let f=0;f<a.length;f++)c[a[f]]=1;for(let f=0,g;f<b.length;f++){g=b[f];for(let h=0,k;h<g.length;h++)k=g[h],c[k]&&!d[k]&&(d[k]=1,e.push(k))}return e};let T=1;
O.prototype.search=function(a,b,c){c||(!b&&C(a)?(c=a,a=""):C(b)&&(c=b,b=0));let d=[],e;let f,g=0,h,k,l;if(c){a=c.query||a;b=c.limit||b;g=c.offset||0;var m=c.context;f=c.suggest;(h=T&&!1!==c.resolve)||(T=0);k=h&&c.enrich;l=this.db&&c.tag}else h=this.resolve||T;a=this.encoder.encode(a);e=a.length;b||!h||(b=100);if(1===e)return U.call(this,a[0],"",b,g,h,k,l);m=this.depth&&!1!==m;if(2===e&&m&&!f)return U.call(this,a[0],a[1],b,g,h,k,l);let n=c=0;if(1<e){const p=z(),t=[];for(let x=0,A;x<e;x++)if((A=a[x])&&
!p[A]){if(f||this.db||V(this,A))t.push(A),p[A]=1;else return h?d:new S(d);const w=A.length;c=Math.max(c,w);n=n?Math.min(n,w):w}a=t;e=a.length}if(!e)return h?d:new S(d);let q=0,r;if(1===e)return U.call(this,a[0],"",b,g,h,k,l);if(2===e&&m&&!f)return U.call(this,a[0],a[1],b,g,h,k,l);1<e&&(m?(r=a[0],q=1):9<c&&3<c/n&&a.sort(aa));if(this.db){if(this.db.search&&(m=this.db.search(this,a,b,g,f,h,k,l),!1!==m))return m;const p=this;return async function(){for(let t,x;q<e;q++){x=a[q];r?(t=await V(p,x,r),t=Ka(t,
d,f,p.U,b,g,2===e),f&&!1===t&&d.length||(r=x)):(t=await V(p,x),t=Ka(t,d,f,p.resolution,b,g,1===e));if(t)return t;if(f&&q===e-1){let A=d.length;if(!A){if(r){r="";q=-1;continue}return d}if(1===A)return h?R(d[0],b,g):new S(d[0])}}return h?Ia(d,p.resolution,b,g,f):new S(d[0])}()}for(let p,t;q<e;q++){t=a[q];r?(p=V(this,t,r),p=Ka(p,d,f,this.U,b,g,2===e),f&&!1===p&&d.length||(r=t)):(p=V(this,t),p=Ka(p,d,f,this.resolution,b,g,1===e));if(p)return p;if(f&&q===e-1){m=d.length;if(!m){if(r){r="";q=-1;continue}return d}if(1===
d,f,p.S,b,g,2===e),f&&!1===t&&d.length||(r=x)):(t=await V(p,x),t=Ka(t,d,f,p.resolution,b,g,1===e));if(t)return t;if(f&&q===e-1){let A=d.length;if(!A){if(r){r="";q=-1;continue}return d}if(1===A)return h?R(d[0],b,g):new S(d[0])}}return h?Ia(d,p.resolution,b,g,f):new S(d[0])}()}for(let p,t;q<e;q++){t=a[q];r?(p=V(this,t,r),p=Ka(p,d,f,this.S,b,g,2===e),f&&!1===p&&d.length||(r=t)):(p=V(this,t),p=Ka(p,d,f,this.resolution,b,g,1===e));if(p)return p;if(f&&q===e-1){m=d.length;if(!m){if(r){r="";q=-1;continue}return d}if(1===
m)return h?R(d[0],b,g):new S(d[0])}}d=Ia(d,this.resolution,b,g,f);return h?d:new S(d)};function U(a,b,c,d,e,f,g){a=V(this,a,b,c,d,e,f,g);return this.db?a.then(function(h){return e?h:h&&h.length?e?R(h,c,d):new S(h):e?[]:new S([])}):a&&a.length?e?R(a,c,d):new S(a):e?[]:new S([])}
function Ka(a,b,c,d,e,f,g){let h=[];if(a){d=Math.min(a.length,d);for(let k=0,l=0,m;k<d;k++)if(m=a[k])if(f&&m&&g&&(m.length<=f?(f-=m.length,m=null):(m=m.slice(f),f=0)),m&&(h[k]=m,g&&(l+=m.length,l>=e)))break;if(h.length){if(g)return R(h,e,0);b.push(h);return}}return!c&&h}function V(a,b,c,d,e,f,g,h){let k;c&&(k=a.bidirectional&&b>c);if(a.db)return c?a.db.get(k?c:b,k?b:c,d,e,f,g,h):a.db.get(b,"",d,e,f,g,h);a=c?(a=a.F.get(k?b:c))&&a.get(k?c:b):a.map.get(b);return a};O.prototype.remove=function(a,b){const c=this.A.size&&(this.fastupdate?this.A.get(a):this.A.has(a));if(c){if(this.fastupdate)for(let d=0,e;d<c.length;d++){if(e=c[d])if(2>e.length)e.pop();else{const f=e.indexOf(a);f===c.length-1?e.pop():e.splice(f,1)}}else La(this.map,a),this.depth&&La(this.F,a);b||this.A.delete(a)}this.db&&(this.K.push({del:a}),this.W&&Ca(this));this.cache&&this.cache.remove(a);return this};
function La(a,b){let c=0;if(a.constructor===Array)for(let d=0,e,f;d<a.length;d++){if((e=a[d])&&e.length)if(f=e.indexOf(b),0<=f){1<e.length?(e.splice(f,1),c++):delete a[d];break}else c++}else for(let d of a){const e=d[0],f=La(d[1],b);f?c+=f:a.delete(e)}return c};function O(a,b){if(!this)return new O(a);if(a){var c=B(a)?a:a.preset;c&&(a=Object.assign({},Aa[c],a))}else a={};c=a.context||{};const d=a.encode||a.encoder||na;this.encoder=d.encode?d:"object"===typeof d?new F(d):{encode:d};let e;this.resolution=a.resolution||9;this.tokenize=e=a.tokenize||"strict";this.depth="strict"===e&&c.depth||0;this.bidirectional=!1!==c.bidirectional;this.fastupdate=!!a.fastupdate;this.score=a.score||null;(e=a.keystore||0)&&(this.keystore=e);this.map=e?new K(e):new Map;this.F=
e?new K(e):new Map;this.A=b||(this.fastupdate?e?new K(e):new Map:e?new M(e):new Set);this.U=c.resolution||1;this.rtl=d.rtl||a.rtl||!1;this.cache=(e=a.cache||null)&&new G(e);this.resolve=!1!==a.resolve;if(e=a.db)this.db=e.mount(this);this.W=!1!==a.commit;this.K=[];this.h=null}u=O.prototype;u.mount=function(a){this.h&&(clearTimeout(this.h),this.h=null);return a.mount(this)};u.commit=function(a,b){this.h&&(clearTimeout(this.h),this.h=null);return this.db.commit(this,a,b)};
function Ca(a){a.h||(a.h=setTimeout(function(){a.h=null;a.db.commit(a,void 0,void 0)},0))}u.clear=function(){this.map.clear();this.F.clear();this.A.clear();this.cache&&this.cache.clear();this.db&&(this.h&&clearTimeout(this.h),this.h=null,this.K=[{clear:!0}]);return this};u.append=function(a,b){return this.add(a,b,!0)};u.contain=function(a){return this.db?this.db.has(a):this.A.has(a)};
u.update=function(a,b){if(this.async){const c=this,d=this.remove(a);return d.then?d.then(()=>c.add(a,b)):this.add(a,b)}return this.remove(a).add(a,b)};function Ma(a){let b=0;if(a.constructor===Array)for(let c=0,d;c<a.length;c++)(d=a[c])&&(b+=d.length);else for(const c of a){const d=c[0],e=Ma(c[1]);e?b+=e:a.delete(d)}return b}u.cleanup=function(){if(!this.fastupdate)return this;Ma(this.map);this.depth&&Ma(this.F);return this};u.searchCache=ma;
u.export=function(a,b,c,d,e,f){let g=!0;"undefined"===typeof f&&(g=new Promise(l=>{f=l}));let h,k;switch(e||(e=0)){case 0:h="reg";if(this.fastupdate){k=z();for(let l of this.A.keys())k[l]=1}else k=this.A;break;case 1:h="cfg";k={doc:0,opt:this.B?1:0};break;case 2:h="map";k=this.map;break;case 3:h="ctx";k=this.F;break;default:"undefined"===typeof c&&f&&f();return}za(a,b||this,c,h,d,e,k,f);return g};
u.import=function(a,b){if(b)switch(B(b)&&(b=JSON.parse(b)),a){case "cfg":this.B=!!b.opt;break;case "reg":this.fastupdate=!1;this.A=b;break;case "map":this.map=b;break;case "ctx":this.F=b}};Ba(O.prototype);async function Na(a){a=a.data;var b=self._index;const c=a.args;var d=a.task;switch(d){case "init":d=a.options||{};(b=d.config)&&(d=await import(b));(b=a.factory)?(Function("return "+b)()(self),self._index=new self.FlexSearch.Index(d),delete self.FlexSearch):self._index=new O(d);postMessage({id:a.id});break;default:a=a.id,b=b[d].apply(b,c),postMessage("search"===d?{id:a,msg:b}:{id:a})}};let Oa=0;
function Ka(a,b,c,d,e,f,g){let h=[];if(a){d=Math.min(a.length,d);for(let k=0,l=0,m;k<d;k++)if(m=a[k])if(f&&m&&g&&(m.length<=f?(f-=m.length,m=null):(m=m.slice(f),f=0)),m&&(h[k]=m,g&&(l+=m.length,l>=e)))break;if(h.length){if(g)return R(h,e,0);b.push(h);return}}return!c&&h}function V(a,b,c,d,e,f,g,h){let k;c&&(k=a.bidirectional&&b>c);if(a.db)return c?a.db.get(k?c:b,k?b:c,d,e,f,g,h):a.db.get(b,"",d,e,f,g,h);a=c?(a=a.ctx.get(k?b:c))&&a.get(k?c:b):a.map.get(b);return a};O.prototype.remove=function(a,b){const c=this.reg.size&&(this.fastupdate?this.reg.get(a):this.reg.has(a));if(c){if(this.fastupdate)for(let d=0,e;d<c.length;d++){if(e=c[d])if(2>e.length)e.pop();else{const f=e.indexOf(a);f===c.length-1?e.pop():e.splice(f,1)}}else La(this.map,a),this.depth&&La(this.ctx,a);b||this.reg.delete(a)}this.db&&(this.I.push({del:a}),this.U&&Ca(this));this.cache&&this.cache.remove(a);return this};
function La(a,b){let c=0;if(a.constructor===Array)for(let d=0,e,f;d<a.length;d++){if((e=a[d])&&e.length)if(f=e.indexOf(b),0<=f){1<e.length?(e.splice(f,1),c++):delete a[d];break}else c++}else for(let d of a){const e=d[0],f=La(d[1],b);f?c+=f:a.delete(e)}return c};function O(a,b){if(!this)return new O(a);if(a){var c=B(a)?a:a.preset;c&&(a=Object.assign({},Aa[c],a))}else a={};c=a.context||{};const d=a.encode||a.encoder||na;this.encoder=d.encode?d:"object"===typeof d?new F(d):{encode:d};let e;this.resolution=a.resolution||9;this.tokenize=e=a.tokenize||"strict";this.depth="strict"===e&&c.depth||0;this.bidirectional=!1!==c.bidirectional;this.fastupdate=!!a.fastupdate;this.score=a.score||null;(e=a.keystore||0)&&(this.keystore=e);this.map=e?new K(e):new Map;this.ctx=
e?new K(e):new Map;this.reg=b||(this.fastupdate?e?new K(e):new Map:e?new M(e):new Set);this.S=c.resolution||1;this.rtl=d.rtl||a.rtl||!1;this.cache=(e=a.cache||null)&&new G(e);this.resolve=!1!==a.resolve;if(e=a.db)this.db=e.mount(this);this.U=!1!==a.commit;this.I=[];this.h=null}u=O.prototype;u.mount=function(a){this.h&&(clearTimeout(this.h),this.h=null);return a.mount(this)};u.commit=function(a,b){this.h&&(clearTimeout(this.h),this.h=null);return this.db.commit(this,a,b)};
function Ca(a){a.h||(a.h=setTimeout(function(){a.h=null;a.db.commit(a,void 0,void 0)},0))}u.clear=function(){this.map.clear();this.ctx.clear();this.reg.clear();this.cache&&this.cache.clear();this.db&&(this.h&&clearTimeout(this.h),this.h=null,this.I=[{clear:!0}]);return this};u.append=function(a,b){return this.add(a,b,!0)};u.contain=function(a){return this.db?this.db.has(a):this.reg.has(a)};
u.update=function(a,b){if(this.async){const c=this,d=this.remove(a);return d.then?d.then(()=>c.add(a,b)):this.add(a,b)}return this.remove(a).add(a,b)};function Ma(a){let b=0;if(a.constructor===Array)for(let c=0,d;c<a.length;c++)(d=a[c])&&(b+=d.length);else for(const c of a){const d=c[0],e=Ma(c[1]);e?b+=e:a.delete(d)}return b}u.cleanup=function(){if(!this.fastupdate)return this;Ma(this.map);this.depth&&Ma(this.ctx);return this};u.searchCache=ma;
u.export=function(a,b,c,d,e,f){let g=!0;"undefined"===typeof f&&(g=new Promise(l=>{f=l}));let h,k;switch(e||(e=0)){case 0:h="reg";if(this.fastupdate){k=z();for(let l of this.reg.keys())k[l]=1}else k=this.reg;break;case 1:h="cfg";k={doc:0,opt:this.A?1:0};break;case 2:h="map";k=this.map;break;case 3:h="ctx";k=this.ctx;break;default:"undefined"===typeof c&&f&&f();return}za(a,b||this,c,h,d,e,k,f);return g};
u.import=function(a,b){if(b)switch(B(b)&&(b=JSON.parse(b)),a){case "cfg":this.A=!!b.opt;break;case "reg":this.fastupdate=!1;this.reg=b;break;case "map":this.map=b;break;case "ctx":this.ctx=b}};
u.serialize=function(a=!0){if(!this.reg.size)return"";let b="",c="";for(var d of this.reg.keys())c||(c=typeof d),b+=(b?",":"")+("string"===c?'"'+d+'"':d);b="index.reg=new Set(["+b+"]);";d="";for(var e of this.map.entries()){var f=e[0],g=e[1],h="";for(let m=0,n;m<g.length;m++){n=g[m]||[""];var k="";for(var l=0;l<n.length;l++)k+=(k?",":"")+("string"===c?'"'+n[l]+'"':n[l]);k="["+k+"]";h+=(h?",":"")+k}h='["'+f+'",['+h+"]]";d+=(d?",":"")+h}d="index.map=new Map(["+d+"]);";e="";for(const m of this.ctx.entries()){f=
m[0];g=m[1];for(const n of g.entries()){g=n[0];h=n[1];k="";for(let q=0,r;q<h.length;q++){r=h[q]||[""];l="";for(let p=0;p<r.length;p++)l+=(l?",":"")+("string"===c?'"'+r[p]+'"':r[p]);l="["+l+"]";k+=(k?",":"")+l}k='new Map([["'+g+'",['+k+"]]])";k='["'+f+'",'+k+"]";e+=(e?",":"")+k}}e="index.ctx=new Map(["+e+"]);";return a?"function inject(index){"+b+d+e+"}":b+d+e};Ba(O.prototype);async function Na(a){a=a.data;var b=self._index;const c=a.args;var d=a.task;switch(d){case "init":d=a.options||{};(b=d.config)&&(d=await import(b));(b=a.factory)?(Function("return "+b)()(self),self._index=new self.FlexSearch.Index(d),delete self.FlexSearch):self._index=new O(d);postMessage({id:a.id});break;default:a=a.id,b=b[d].apply(b,c),postMessage("search"===d?{id:a,msg:b}:{id:a})}};let Oa=0;
function W(a){function b(f){f=f.data||f;const g=f.id,h=g&&e.h[g];h&&(h(f.msg),delete e.h[g])}if(!this)return new W(a);a||(a={});let c=(self||window)._factory;c&&(c=c.toString());const d="undefined"===typeof window&&self.exports,e=this;this.worker=Pa(c,d,a.worker);this.h=z();if(this.worker){d?this.worker.on("message",b):this.worker.onmessage=b;if(a.config)return new Promise(function(f){e.h[++Oa]=function(){f(e)};e.worker.postMessage({id:Oa,task:"init",factory:c,options:a})});this.worker.postMessage({task:"init",factory:c,
options:a})}}X("add");X("append");X("search");X("update");X("remove");function X(a){W.prototype[a]=W.prototype[a+"Async"]=function(){const b=this,c=[].slice.call(arguments);var d=c[c.length-1];let e;"function"===typeof d&&(e=d,c.splice(c.length-1,1));d=new Promise(function(f){b.h[++Oa]=f;b.worker.postMessage({task:a,id:Oa,args:c})});return e?(d.then(e),this):d}}
function Pa(a,b,c){return b?new (require("worker_threads")["Worker"])(__dirname + "/node/node.js"):a?new window.Worker(URL.createObjectURL(new Blob(["onmessage="+Na.toString()],{type:"text/javascript"}))):new window.Worker(B(c)?c:"worker/worker.js",{type:"module"})};Y.prototype.add=function(a,b,c){C(a)&&(b=a,a=ca(b,this.key));if(b&&(a||0===a)){if(!c&&this.A.has(a))return this.update(a,b);for(let h=0,k;h<this.field.length;h++){k=this.I[h];var d=this.index.get(this.field[h]);if("function"===typeof k){var e=k(b);e&&d.add(a,e,!1,!0)}else if(e=k.L,!e||e(b))k.constructor===String?k=[""+k]:B(k)&&(k=[k]),Qa(b,k,this.N,0,d,a,k[0],c)}if(this.tag)for(d=0;d<this.H.length;d++){var f=this.H[d];e=this.tag.get(this.R[d]);let h=z();if("function"===typeof f){if(f=f(b),!f)continue}else{var g=
f.L;if(g&&!g(b))continue;f.constructor===String&&(f=""+f);f=ca(b,f)}if(e&&f){B(f)&&(f=[f]);for(let k=0,l,m;k<f.length;k++)if(l=f[k],!h[l]&&(h[l]=1,(g=e.get(l))?m=g:e.set(l,m=[]),!c||!m.includes(a))){if(m.length===2**31-1){g=new J(m);if(this.fastupdate)for(let n of this.A.values())n.includes(m)&&(n[n.indexOf(m)]=g);e.set(l,m=g)}m.push(a);this.fastupdate&&((g=this.A.get(a))?g.push(m):this.A.set(a,[m]))}}}if(this.store&&(!c||!this.store.has(a))){let h;if(this.D){h=z();for(let k=0,l;k<this.D.length;k++){l=
this.D[k];if((c=l.L)&&!c(b))continue;let m;if("function"===typeof l){m=l(b);if(!m)continue;l=[l.X]}else if(B(l)||l.constructor===String){h[l]=b[l];continue}Ra(b,h,l,0,l[0],m)}}this.store.set(a,h||b)}}return this};function Ra(a,b,c,d,e,f){a=a[e];if(d===c.length-1)b[e]=f||a;else if(a)if(a.constructor===Array)for(b=b[e]=Array(a.length),e=0;e<a.length;e++)Ra(a,b,c,d,e);else b=b[e]||(b[e]=z()),e=c[++d],Ra(a,b,c,d,e)}
function Pa(a,b,c){return b?new (require("worker_threads")["Worker"])(__dirname + "/node/node.js"):a?new window.Worker(URL.createObjectURL(new Blob(["onmessage="+Na.toString()],{type:"text/javascript"}))):new window.Worker(B(c)?c:"worker/worker.js",{type:"module"})};Y.prototype.add=function(a,b,c){C(a)&&(b=a,a=ca(b,this.key));if(b&&(a||0===a)){if(!c&&this.reg.has(a))return this.update(a,b);for(let h=0,k;h<this.field.length;h++){k=this.G[h];var d=this.index.get(this.field[h]);if("function"===typeof k){var e=k(b);e&&d.add(a,e,!1,!0)}else if(e=k.J,!e||e(b))k.constructor===String?k=[""+k]:B(k)&&(k=[k]),Qa(b,k,this.L,0,d,a,k[0],c)}if(this.tag)for(d=0;d<this.F.length;d++){var f=this.F[d];e=this.tag.get(this.O[d]);let h=z();if("function"===typeof f){if(f=f(b),!f)continue}else{var g=
f.J;if(g&&!g(b))continue;f.constructor===String&&(f=""+f);f=ca(b,f)}if(e&&f){B(f)&&(f=[f]);for(let k=0,l,m;k<f.length;k++)if(l=f[k],!h[l]&&(h[l]=1,(g=e.get(l))?m=g:e.set(l,m=[]),!c||!m.includes(a))){if(m.length===2**31-1){g=new J(m);if(this.fastupdate)for(let n of this.reg.values())n.includes(m)&&(n[n.indexOf(m)]=g);e.set(l,m=g)}m.push(a);this.fastupdate&&((g=this.reg.get(a))?g.push(m):this.reg.set(a,[m]))}}}if(this.store&&(!c||!this.store.has(a))){let h;if(this.C){h=z();for(let k=0,l;k<this.C.length;k++){l=
this.C[k];if((c=l.J)&&!c(b))continue;let m;if("function"===typeof l){m=l(b);if(!m)continue;l=[l.V]}else if(B(l)||l.constructor===String){h[l]=b[l];continue}Ra(b,h,l,0,l[0],m)}}this.store.set(a,h||b)}}return this};function Ra(a,b,c,d,e,f){a=a[e];if(d===c.length-1)b[e]=f||a;else if(a)if(a.constructor===Array)for(b=b[e]=Array(a.length),e=0;e<a.length;e++)Ra(a,b,c,d,e);else b=b[e]||(b[e]=z()),e=c[++d],Ra(a,b,c,d,e)}
function Qa(a,b,c,d,e,f,g,h){if(a=a[g])if(d===b.length-1){if(a.constructor===Array){if(c[d]){for(b=0;b<a.length;b++)e.add(f,a[b],!0,!0);return}a=a.join(" ")}e.add(f,a,h,!0)}else if(a.constructor===Array)for(g=0;g<a.length;g++)Qa(a,b,c,d,e,f,g,h);else g=b[++d],Qa(a,b,c,d,e,f,g,h);else e.db&&e.remove(f)};Y.prototype.search=function(a,b,c,d){c||(!b&&C(a)?(c=a,a=""):C(b)&&(c=b,b=0));let e=[],f=[],g;let h;let k;let l,m=0;if(c){c.constructor===Array&&(c={index:c});a=c.query||a;g=c.pluck;h=c.merge;k=g||c.field||c.index;var n=this.tag&&c.tag;var q=this.store&&c.enrich;var r=c.suggest;b=c.limit||b;l=c.offset||0;b||(b=100);if(n&&(!this.db||!d)){n.constructor!==Array&&(n=[n]);var p=[];for(let w=0,v;w<n.length;w++)if(v=n[w],v.field&&v.tag){var t=v.tag;if(t.constructor===Array)for(var x=0;x<t.length;x++)p.push(v.field,
t[x]);else p.push(v.field,t)}else{t=Object.keys(v);for(let H=0,I,D;H<t.length;H++)if(I=t[H],D=v[I],D.constructor===Array)for(x=0;x<D.length;x++)p.push(I,D[x]);else p.push(I,D)}n=p;if(!a){r=[];if(p.length)for(n=0;n<p.length;n+=2){if(this.db){d=this.index.get(p[n]);if(!d)continue;r.push(d=d.db.tag(p[n+1],b,l,q))}else d=Sa.call(this,p[n],p[n+1],b,l,q);e.push({field:p[n],tag:p[n+1],result:d})}return r.length?Promise.all(r).then(function(w){for(let v=0;v<w.length;v++)e[v].result=w[v];return e}):e}}B(k)&&
(k=[k])}k||(k=this.field);p=!d&&(this.worker||this.async)&&[];let A;for(let w=0,v,H,I;w<k.length;w++){H=k[w];if(this.db&&this.tag&&!this.I[w])continue;let D;B(H)||(D=H,H=D.field,a=D.query||a,b=D.limit||b,r=D.suggest||r);if(d)v=d[w];else if(t=D||c,x=this.index.get(H),n&&(this.db&&(t.tag=n,A=x.db.Z,t.field=k),A||(t.enrich=!1)),p){p[w]=x.searchAsync(a,b,t);t&&q&&(t.enrich=q);continue}else v=x.search(a,b,t),t&&q&&(t.enrich=q);I=v&&v.length;if(n&&I){t=[];x=0;if(this.db&&d){if(!A)for(let L=k.length;L<d.length;L++){let E=
(k=[k])}k||(k=this.field);p=!d&&(this.worker||this.async)&&[];let A;for(let w=0,v,H,I;w<k.length;w++){H=k[w];if(this.db&&this.tag&&!this.G[w])continue;let D;B(H)||(D=H,H=D.field,a=D.query||a,b=D.limit||b,r=D.suggest||r);if(d)v=d[w];else if(t=D||c,x=this.index.get(H),n&&(this.db&&(t.tag=n,A=x.db.X,t.field=k),A||(t.enrich=!1)),p){p[w]=x.searchAsync(a,b,t);t&&q&&(t.enrich=q);continue}else v=x.search(a,b,t),t&&q&&(t.enrich=q);I=v&&v.length;if(n&&I){t=[];x=0;if(this.db&&d){if(!A)for(let L=k.length;L<d.length;L++){let E=
d[L];if(E&&E.length)x++,t.push(E);else if(!r)return e}}else for(let L=0,E,Za;L<n.length;L+=2){E=this.tag.get(n[L]);if(!E)if(r)continue;else return e;if(Za=(E=E&&E.get(n[L+1]))&&E.length)x++,t.push(E);else if(!r)return e}if(x){v=Ja(v,t);I=v.length;if(!I&&!r)return e;x--}}if(I)f[m]=H,e.push(v),m++;else if(1===k.length)return e}if(p){if(this.db&&n&&n.length&&!A)for(q=0;q<n.length;q+=2){d=this.index.get(n[q]);if(!d)if(r)continue;else return e;p.push(d.db.tag(n[q+1],b,l,!1))}const w=this;return Promise.all(p).then(function(v){return v.length?
w.search(a,b,c,v):v})}if(!m)return e;if(g&&(!q||!this.store))return e[0];p=[];for(let w=0,v;w<f.length;w++){v=e[w];q&&v.length&&!v[0].doc&&(this.db?p.push(v=this.index.get(this.field[0]).db.enrich(v)):v.length&&(v=Ta.call(this,v)));if(g)return v;e[w]={field:f[w],result:v}}return q&&this.db&&p.length?Promise.all(p).then(function(w){for(let v=0;v<w.length;v++)e[v].result=w[v];return h?Ua(e,b):e}):h?Ua(e,b):e};
function Ua(a,b){const c=[],d=z();for(let e=0,f,g;e<a.length;e++){f=a[e];g=f.result;for(let h=0,k,l,m;h<g.length;h++)if(l=g[h],k=l.id,m=d[k])m.push(f.field);else{if(c.length===b)return c;l.field=d[k]=[f.field];c.push(l)}}return c}function Sa(a,b,c,d,e){a=this.tag.get(a);if(!a)return[];if((b=(a=a&&a.get(b))&&a.length-d)&&0<b){if(b>c||d)a=a.slice(d,d+c);e&&(a=Ta.call(this,a));return a}}
function Ta(a){const b=Array(a.length);for(let c=0,d;c<a.length;c++)d=a[c],b[c]={id:d,doc:this.store.get(d)};return b};function Y(a){if(!this)return new Y(a);const b=a.document||a.doc||a;var c,d;this.I=[];this.field=[];this.N=[];this.key=(c=b.key||b.id)&&Va(c,this.N)||"id";(d=a.keystore||0)&&(this.keystore=d);this.A=(this.fastupdate=!!a.fastupdate)?d?new K(d):new Map:d?new M(d):new Set;this.D=(c=b.store||null)&&!0!==c&&[];this.store=c&&(d?new K(d):new Map);this.cache=(c=a.cache||null)&&new G(c);a.cache=!1;this.worker=a.worker;this.async=!1;c=new Map;d=b.index||b.field||b;B(d)&&(d=[d]);for(let e=0,f,g;e<d.length;e++){f=
d[e];B(f)||(g=f,f=f.field);g=C(g)?Object.assign({},a,g):a;if(this.worker){const h=new W(g);c.set(f,h);h.worker||(this.worker=!1)}this.worker||c.set(f,new O(g,this.A));g.custom?this.I[e]=g.custom:(this.I[e]=Va(f,this.N),g.filter&&("string"===typeof this.I[e]&&(this.I[e]=new String(this.I[e])),this.I[e].L=g.filter));this.field[e]=f}if(this.D){d=b.store;B(d)&&(d=[d]);for(let e=0,f,g;e<d.length;e++)f=d[e],g=f.field||f,f.custom?(this.D[e]=f.custom,f.custom.X=g):(this.D[e]=Va(g,this.N),f.filter&&("string"===
typeof this.D[e]&&(this.D[e]=new String(this.D[e])),this.D[e].L=f.filter))}this.index=c;this.tag=null;if(c=b.tag)if("string"===typeof c&&(c=[c]),c.length){this.tag=new Map;this.H=[];this.R=[];for(let e=0,f,g;e<c.length;e++){f=c[e];g=f.field||f;if(!g)throw Error("The tag field from the document descriptor is undefined.");f.custom?this.H[e]=f.custom:(this.H[e]=Va(g,this.N),f.filter&&("string"===typeof this.H[e]&&(this.H[e]=new String(this.H[e])),this.H[e].L=f.filter));this.R[e]=g;this.tag.set(g,new Map)}}a.db&&
function Ta(a){const b=Array(a.length);for(let c=0,d;c<a.length;c++)d=a[c],b[c]={id:d,doc:this.store.get(d)};return b};function Y(a){if(!this)return new Y(a);const b=a.document||a.doc||a;var c,d;this.G=[];this.field=[];this.L=[];this.key=(c=b.key||b.id)&&Va(c,this.L)||"id";(d=a.keystore||0)&&(this.keystore=d);this.reg=(this.fastupdate=!!a.fastupdate)?d?new K(d):new Map:d?new M(d):new Set;this.C=(c=b.store||null)&&!0!==c&&[];this.store=c&&(d?new K(d):new Map);this.cache=(c=a.cache||null)&&new G(c);a.cache=!1;this.worker=a.worker;this.async=!1;c=new Map;d=b.index||b.field||b;B(d)&&(d=[d]);for(let e=0,f,g;e<d.length;e++){f=
d[e];B(f)||(g=f,f=f.field);g=C(g)?Object.assign({},a,g):a;if(this.worker){const h=new W(g);c.set(f,h);h.worker||(this.worker=!1)}this.worker||c.set(f,new O(g,this.reg));g.custom?this.G[e]=g.custom:(this.G[e]=Va(f,this.L),g.filter&&("string"===typeof this.G[e]&&(this.G[e]=new String(this.G[e])),this.G[e].J=g.filter));this.field[e]=f}if(this.C){d=b.store;B(d)&&(d=[d]);for(let e=0,f,g;e<d.length;e++)f=d[e],g=f.field||f,f.custom?(this.C[e]=f.custom,f.custom.V=g):(this.C[e]=Va(g,this.L),f.filter&&("string"===
typeof this.C[e]&&(this.C[e]=new String(this.C[e])),this.C[e].J=f.filter))}this.index=c;this.tag=null;if(c=b.tag)if("string"===typeof c&&(c=[c]),c.length){this.tag=new Map;this.F=[];this.O=[];for(let e=0,f,g;e<c.length;e++){f=c[e];g=f.field||f;if(!g)throw Error("The tag field from the document descriptor is undefined.");f.custom?this.F[e]=f.custom:(this.F[e]=Va(g,this.L),f.filter&&("string"===typeof this.F[e]&&(this.F[e]=new String(this.F[e])),this.F[e].J=f.filter));this.O[e]=g;this.tag.set(g,new Map)}}a.db&&
this.mount(a.db)}u=Y.prototype;
u.mount=function(a){let b=this.field;if(this.tag)for(let e=0,f;e<this.R.length;e++){f=this.R[e];var c=this.index.get(f);c||(this.index.set(f,c=new O({},this.A)),b===this.field&&(b=b.slice(0)),b.push(f));c.tag=this.tag.get(f)}c=[];const d={db:a.db,type:a.type,fastupdate:a.fastupdate};for(let e=0,f,g;e<b.length;e++){d.field=g=b[e];f=this.index.get(g);const h=new a.constructor(a.id,d);h.id=a.id;c[e]=h.mount(f);f.document=!0;e?f.Y=!0:f.store=this.store}this.db=this.async=!0;return Promise.all(c)};
u.commit=async function(a,b){const c=[];for(const d of this.index.values())c.push(d.db.commit(d,a,b));await Promise.all(c);this.A.clear()};function Va(a,b){const c=a.split(":");let d=0;for(let e=0;e<c.length;e++)a=c[e],"]"===a[a.length-1]&&(a=a.substring(0,a.length-2))&&(b[d]=!0),a&&(c[d++]=a);d<c.length&&(c.length=d);return 1<d?c:c[0]}u.append=function(a,b){return this.add(a,b,!0)};u.update=function(a,b){return this.remove(a).add(a,b)};
u.remove=function(a){C(a)&&(a=ca(a,this.key));for(var b of this.index.values())b.remove(a,!0);if(this.A.has(a)){if(this.tag&&!this.fastupdate)for(let c of this.tag.values())for(let d of c){b=d[0];const e=d[1],f=e.indexOf(a);-1<f&&(1<e.length?e.splice(f,1):c.delete(b))}this.store&&this.store.delete(a);this.A.delete(a)}this.cache&&this.cache.remove(a);return this};
u.clear=function(){for(const a of this.index.values())a.clear();if(this.tag)for(const a of this.tag.values())a.clear();this.store&&this.store.clear();return this};u.contain=function(a){return this.db?this.index.get(this.field[0]).db.has(a):this.A.has(a)};u.cleanup=function(){for(const a of this.index.values())a.cleanup();return this};u.get=function(a){return this.db?this.index.get(this.field[0]).db.enrich(a).then(function(b){return b[0]&&b[0].doc}):this.store.get(a)};
u.mount=function(a){let b=this.field;if(this.tag)for(let e=0,f;e<this.O.length;e++){f=this.O[e];var c=this.index.get(f);c||(this.index.set(f,c=new O({},this.reg)),b===this.field&&(b=b.slice(0)),b.push(f));c.tag=this.tag.get(f)}c=[];const d={db:a.db,type:a.type,fastupdate:a.fastupdate};for(let e=0,f,g;e<b.length;e++){d.field=g=b[e];f=this.index.get(g);const h=new a.constructor(a.id,d);h.id=a.id;c[e]=h.mount(f);f.document=!0;e?f.W=!0:f.store=this.store}this.db=this.async=!0;return Promise.all(c)};
u.commit=async function(a,b){const c=[];for(const d of this.index.values())c.push(d.db.commit(d,a,b));await Promise.all(c);this.reg.clear()};function Va(a,b){const c=a.split(":");let d=0;for(let e=0;e<c.length;e++)a=c[e],"]"===a[a.length-1]&&(a=a.substring(0,a.length-2))&&(b[d]=!0),a&&(c[d++]=a);d<c.length&&(c.length=d);return 1<d?c:c[0]}u.append=function(a,b){return this.add(a,b,!0)};u.update=function(a,b){return this.remove(a).add(a,b)};
u.remove=function(a){C(a)&&(a=ca(a,this.key));for(var b of this.index.values())b.remove(a,!0);if(this.reg.has(a)){if(this.tag&&!this.fastupdate)for(let c of this.tag.values())for(let d of c){b=d[0];const e=d[1],f=e.indexOf(a);-1<f&&(1<e.length?e.splice(f,1):c.delete(b))}this.store&&this.store.delete(a);this.reg.delete(a)}this.cache&&this.cache.remove(a);return this};
u.clear=function(){for(const a of this.index.values())a.clear();if(this.tag)for(const a of this.tag.values())a.clear();this.store&&this.store.clear();return this};u.contain=function(a){return this.db?this.index.get(this.field[0]).db.has(a):this.reg.has(a)};u.cleanup=function(){for(const a of this.index.values())a.cleanup();return this};u.get=function(a){return this.db?this.index.get(this.field[0]).db.enrich(a).then(function(b){return b[0]&&b[0].doc}):this.store.get(a)};
u.set=function(a,b){this.store.set(a,b);return this};u.searchCache=ma;u.export=function(a,b,c,d,e,f){let g;"undefined"===typeof f&&(g=new Promise(k=>{f=k}));e||(e=0);d||(d=0);if(d<this.field.length){c=this.field[d];var h=this.index[c];b=this;h.export(a,b,e?c:"",d,e++,f)||(d++,b.export(a,b,c,d,1,f))}else{switch(e){case 1:b="tag";h=this.h;c=null;break;case 2:b="store";h=this.store;c=null;break;default:f();return}za(a,this,c,b,d,e,h,f)}return g};
u.import=function(a,b){if(b)switch(B(b)&&(b=JSON.parse(b)),a){case "tag":this.h=b;break;case "reg":this.fastupdate=!1;this.A=b;for(let d=0,e;d<this.field.length;d++)e=this.index[this.field[d]],e.A=b,e.fastupdate=!1;break;case "store":this.store=b;break;default:a=a.split(".");const c=a[0];a=a[1];c&&a&&this.index[c].import(a,b)}};Ba(Y.prototype);const Wa="undefined"!==typeof window&&(window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB),Xa=["map","ctx","tag","reg","cfg"];
function Ya(a,b={}){if(!this)return new Ya(a,b);"object"===typeof a&&(b=a=a.name);a||console.info("Default storage space was used, because a name was not passed.");this.id="flexsearch"+(a?":"+a.toLowerCase().replace(/[^a-z0-9_\-]/g,""):"");this.field=b.field?b.field.toLowerCase().replace(/[^a-z0-9_\-]/g,""):"";this.Z=!1;this.db=null;this.h={}}u=Ya.prototype;u.mount=function(a){if(a.constructor===Y)return a.mount(this);a.db=this;return $a(this)};
u.import=function(a,b){if(b)switch(B(b)&&(b=JSON.parse(b)),a){case "tag":this.h=b;break;case "reg":this.fastupdate=!1;this.reg=b;for(let d=0,e;d<this.field.length;d++)e=this.index[this.field[d]],e.reg=b,e.fastupdate=!1;break;case "store":this.store=b;break;default:a=a.split(".");const c=a[0];a=a[1];c&&a&&this.index[c].import(a,b)}};Ba(Y.prototype);const Wa="undefined"!==typeof window&&(window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB),Xa=["map","ctx","tag","reg","cfg"];
function Ya(a,b={}){if(!this)return new Ya(a,b);"object"===typeof a&&(b=a=a.name);a||console.info("Default storage space was used, because a name was not passed.");this.id="flexsearch"+(a?":"+a.toLowerCase().replace(/[^a-z0-9_\-]/g,""):"");this.field=b.field?b.field.toLowerCase().replace(/[^a-z0-9_\-]/g,""):"";this.X=!1;this.db=null;this.h={}}u=Ya.prototype;u.mount=function(a){if(a.constructor===Y)return a.mount(this);a.db=this;return $a(this)};
function $a(a){navigator.storage&&navigator.storage.persist();return a.db||new Promise(function(b,c){const d=Wa.open(a.id+(a.field?":"+a.field:""),1);d.onupgradeneeded=function(){const e=a.db=this.result;Xa.forEach(f=>{e.objectStoreNames.contains(f)||e.createObjectStore(f)})};d.onblocked=function(e){console.error("blocked",e);c()};d.onerror=function(e){console.error(this.error,e);c()};d.onsuccess=function(){a.db=this.result;a.db.onversionchange=function(){a.close()};b(a)}})}
u.close=function(){this.db.close();this.db=null};u.clear=function(){const a=this.db.transaction(Xa,"readwrite");for(let b=0;b<Xa.length;b++)a.objectStore(Xa[b]).clear();return Z(a)};
u.get=function(a,b,c=0,d=0,e=!0,f=!1){a=this.db.transaction(b?"ctx":"map","readonly").objectStore(b?"ctx":"map").get(b?b+":"+a:a);const g=this;return Z(a).then(function(h){let k=[];if(!h||!h.length)return k;if(e){if(!c&&!d&&1===h.length)return h[0];for(let l=0,m;l<h.length;l++)if((m=h[l])&&m.length){if(d>=m.length){d-=m.length;continue}const n=c?d+Math.min(m.length-d,c):m.length;for(let q=d;q<n;q++)k.push(m[q]);d=0;if(k.length===c)break}return f?g.enrich(k):k}return h})};
u.tag=function(a,b=0,c=0,d=!1){a=this.db.transaction("tag","readonly").objectStore("tag").get(a);const e=this;return Z(a).then(function(f){if(!f||!f.length||c>=f.length)return[];if(!b&&!c)return f;f=f.slice(c,c+b);return d?e.enrich(f):f})};
u.enrich=function(a){"object"!==typeof a&&(a=[a]);const b=this.db.transaction("reg","readonly").objectStore("reg"),c=[];for(let d=0;d<a.length;d++)c[d]=Z(b.get(a[d]));return Promise.all(c).then(function(d){for(let e=0;e<d.length;e++)d[e]={id:a[e],doc:d[e]?JSON.parse(d[e]):null};return d})};u.has=function(a){a=this.db.transaction("reg","readonly").objectStore("reg").getKey(a);return Z(a)};u.search=null;u.info=function(){};
u.transaction=function(a,b,c){let d=this.h[a+":"+b];if(d)return c.call(this,d);let e=this.db.transaction(a,b);this.h[a+":"+b]=d=e.objectStore(a);return new Promise((f,g)=>{e.onerror=h=>{this.h[a+":"+b]=null;e.abort();e=d=null;g(h)};e.oncomplete=h=>{e=d=this.h[a+":"+b]=null;f(h||!0)};return c.call(this,d)})};
u.commit=async function(a,b,c){if(b)await this.clear(),a.K=[];else{let d=a.K;a.K=[];for(let e=0,f;e<d.length;e++)if(f=d[e],f.clear){await this.clear();b=!0;break}else d[e]=f.$;b||(c||(d=d.concat(ba(a.A))),d.length&&await this.remove(d))}a.A.size&&(await this.transaction("map","readwrite",function(d){for(const e of a.map){const f=e[0],g=e[1];g.length&&(b?d.put(g,f):d.get(f).onsuccess=function(){let h=this.result;var k;if(h&&h.length){const l=Math.max(h.length,g.length);for(let m=0,n,q;m<l;m++)if((q=
g[m])&&q.length){if((n=h[m])&&n.length)for(k=0;k<q.length;k++)n.push(q[k]);else h[m]=q;k=1}}else h=g,k=1;k&&d.put(h,f)})}}),await this.transaction("ctx","readwrite",function(d){for(const e of a.F){const f=e[0],g=e[1];for(const h of g){const k=h[0],l=h[1];l.length&&(b?d.put(l,f+":"+k):d.get(f+":"+k).onsuccess=function(){let m=this.result;var n;if(m&&m.length){const q=Math.max(m.length,l.length);for(let r=0,p,t;r<q;r++)if((t=l[r])&&t.length){if((p=m[r])&&p.length)for(n=0;n<t.length;n++)p.push(t[n]);
else m[r]=t;n=1}}else m=l,n=1;n&&d.put(m,f+":"+k)})}}}),a.store?await this.transaction("reg","readwrite",function(d){for(const e of a.store){const f=e[0],g=e[1];d.put("object"===typeof g?JSON.stringify(g):1,f)}}):a.Y||await this.transaction("reg","readwrite",function(d){for(const e of a.A.keys())d.put(1,e)}),a.tag&&await this.transaction("tag","readwrite",function(d){for(const e of a.tag){const f=e[0],g=e[1];g.length&&(d.get(f).onsuccess=function(){let h=this.result;h=h&&h.length?h.concat(g):g;d.put(h,
f)})}}),a.map.clear(),a.F.clear(),a.tag&&a.tag.clear(),a.store&&a.store.clear(),a.document||a.A.clear())};function ab(a,b,c){const d=a.value;let e,f,g=0;for(let h=0,k;h<d.length;h++){if(k=c?d:d[h]){for(let l=0,m,n;l<b.length;l++)if(n=b[l],m=k.indexOf(f?parseInt(n,10):n),0>m&&!f&&"string"===typeof n&&!isNaN(n)&&(m=k.indexOf(parseInt(n,10)))&&(f=1),0<=m)if(e=1,1<k.length)k.splice(m,1);else{d[h]=[];break}g+=k.length}if(c)break}g?e&&a.update(d):a.delete();a.continue()}
u.commit=async function(a,b,c){if(b)await this.clear(),a.I=[];else{let d=a.I;a.I=[];for(let e=0,f;e<d.length;e++)if(f=d[e],f.clear){await this.clear();b=!0;break}else d[e]=f.Y;b||(c||(d=d.concat(ba(a.reg))),d.length&&await this.remove(d))}a.reg.size&&(await this.transaction("map","readwrite",function(d){for(const e of a.map){const f=e[0],g=e[1];g.length&&(b?d.put(g,f):d.get(f).onsuccess=function(){let h=this.result;var k;if(h&&h.length){const l=Math.max(h.length,g.length);for(let m=0,n,q;m<l;m++)if((q=
g[m])&&q.length){if((n=h[m])&&n.length)for(k=0;k<q.length;k++)n.push(q[k]);else h[m]=q;k=1}}else h=g,k=1;k&&d.put(h,f)})}}),await this.transaction("ctx","readwrite",function(d){for(const e of a.ctx){const f=e[0],g=e[1];for(const h of g){const k=h[0],l=h[1];l.length&&(b?d.put(l,f+":"+k):d.get(f+":"+k).onsuccess=function(){let m=this.result;var n;if(m&&m.length){const q=Math.max(m.length,l.length);for(let r=0,p,t;r<q;r++)if((t=l[r])&&t.length){if((p=m[r])&&p.length)for(n=0;n<t.length;n++)p.push(t[n]);
else m[r]=t;n=1}}else m=l,n=1;n&&d.put(m,f+":"+k)})}}}),a.store?await this.transaction("reg","readwrite",function(d){for(const e of a.store){const f=e[0],g=e[1];d.put("object"===typeof g?JSON.stringify(g):1,f)}}):a.W||await this.transaction("reg","readwrite",function(d){for(const e of a.reg.keys())d.put(1,e)}),a.tag&&await this.transaction("tag","readwrite",function(d){for(const e of a.tag){const f=e[0],g=e[1];g.length&&(d.get(f).onsuccess=function(){let h=this.result;h=h&&h.length?h.concat(g):g;
d.put(h,f)})}}),a.map.clear(),a.ctx.clear(),a.tag&&a.tag.clear(),a.store&&a.store.clear(),a.document||a.reg.clear())};function ab(a,b,c){const d=a.value;let e,f,g=0;for(let h=0,k;h<d.length;h++){if(k=c?d:d[h]){for(let l=0,m,n;l<b.length;l++)if(n=b[l],m=k.indexOf(f?parseInt(n,10):n),0>m&&!f&&"string"===typeof n&&!isNaN(n)&&(m=k.indexOf(parseInt(n,10)))&&(f=1),0<=m)if(e=1,1<k.length)k.splice(m,1);else{d[h]=[];break}g+=k.length}if(c)break}g?e&&a.update(d):a.delete();a.continue()}
u.remove=function(a){"object"!==typeof a&&(a=[a]);return Promise.all([this.transaction("map","readwrite",function(b){b.openCursor().onsuccess=function(){const c=this.result;c&&ab(c,a)}}),this.transaction("ctx","readwrite",function(b){b.openCursor().onsuccess=function(){const c=this.result;c&&ab(c,a)}}),this.transaction("tag","readwrite",function(b){b.openCursor().onsuccess=function(){const c=this.result;c&&ab(c,a,!0)}}),this.transaction("reg","readwrite",function(b){for(let c=0;c<a.length;c++)b.delete(a[c])})])};
function Z(a){return new Promise((b,c)=>{a.onsuccess=function(){b(this.result)};a.oncomplete=function(){b(this.result)};a.onerror=c;a=null})};export default {Index:O,Charset:va,Encoder:F,Document:Y,Worker:W,Resolver:S,IndexedDB:Ya,Language:{}};
export const Index=O;export const Charset=va;export const Encoder=F;export const Document=Y;export const Worker=W;export const Resolver=S;export const IndexedDB=Ya;export const Language={};

View File

@@ -115,32 +115,32 @@ J.prototype.assign = function(a) {
this.minlength = x(a.minlength, 1, this.minlength);
this.maxlength = x(a.maxlength, 0, this.maxlength);
if (this.cache = b = x(a.cache, !0, this.cache)) {
this.L = null, this.R = "number" === typeof b ? b : 2e5, this.H = new Map(), this.J = new Map(), this.G = this.A = 128;
this.J = null, this.O = "number" === typeof b ? b : 2e5, this.F = new Map(), this.H = new Map(), this.D = this.h = 128;
}
this.M = "";
this.O = null;
this.N = "";
this.P = null;
this.K = "";
this.M = null;
this.L = "";
this.N = null;
if (this.matcher) {
for (const e of this.matcher.keys()) {
this.M += (this.M ? "|" : "") + e;
this.K += (this.K ? "|" : "") + e;
}
}
if (this.stemmer) {
for (const e of this.stemmer.keys()) {
this.N += (this.N ? "|" : "") + e;
this.L += (this.L ? "|" : "") + e;
}
}
return this;
};
J.prototype.encode = function(a) {
if (this.cache && a.length <= this.A) {
if (this.L) {
if (this.H.has(a)) {
return this.H.get(a);
if (this.cache && a.length <= this.h) {
if (this.J) {
if (this.F.has(a)) {
return this.F.get(a);
}
} else {
this.L = setTimeout(ha, 0, this);
this.J = setTimeout(ha, 0, this);
}
}
this.normalize && (a = "function" === typeof this.normalize ? this.normalize(a) : I ? a.normalize("NFKD").replace(I, "").toLowerCase() : a.toLowerCase());
@@ -162,25 +162,25 @@ J.prototype.encode = function(a) {
if (this.filter && this.filter.has(g)) {
continue;
}
if (this.cache && g.length <= this.G) {
if (this.L) {
var d = this.J.get(g);
if (this.cache && g.length <= this.D) {
if (this.J) {
var d = this.H.get(g);
if (d || "" === d) {
d && b.push(d);
continue;
}
} else {
this.L = setTimeout(ha, 0, this);
this.J = setTimeout(ha, 0, this);
}
}
let k;
this.stemmer && 2 < g.length && (this.P || (this.P = new RegExp("(?!^)(" + this.N + ")$")), g = g.replace(this.P, l => this.stemmer.get(l)), k = 1);
this.matcher && 1 < g.length && (this.O || (this.O = new RegExp("(" + this.M + ")", "g")), g = g.replace(this.O, l => this.matcher.get(l)), k = 1);
this.stemmer && 2 < g.length && (this.N || (this.N = new RegExp("(?!^)(" + this.L + ")$")), g = g.replace(this.N, l => this.stemmer.get(l)), k = 1);
this.matcher && 1 < g.length && (this.M || (this.M = new RegExp("(" + this.K + ")", "g")), g = g.replace(this.M, l => this.matcher.get(l)), k = 1);
g && k && (g.length < this.minlength || this.filter && this.filter.has(g)) && (g = "");
if (g && (this.mapper || this.dedupe && 1 < g.length)) {
d = "";
for (let l = 0, m = "", r, t; l < g.length; l++) {
r = g.charAt(l), r === m && this.dedupe || ((t = this.mapper && this.mapper.get(r)) || "" === t ? t === m && this.dedupe || !(m = t) || (d += t) : d += m = r);
for (let l = 0, m = "", q, t; l < g.length; l++) {
q = g.charAt(l), q === m && this.dedupe || ((t = this.mapper && this.mapper.get(q)) || "" === t ? t === m && this.dedupe || !(m = t) || (d += t) : d += m = q);
}
g = d;
}
@@ -189,17 +189,17 @@ J.prototype.encode = function(a) {
g = g.replace(this.replacer[d], this.replacer[d + 1]);
}
}
this.cache && h.length <= this.G && (this.J.set(h, g), this.J.size > this.R && (this.J.clear(), this.G = this.G / 1.1 | 0));
this.cache && h.length <= this.D && (this.H.set(h, g), this.H.size > this.O && (this.H.clear(), this.D = this.D / 1.1 | 0));
g && b.push(g);
}
this.finalize && (b = this.finalize(b) || b);
this.cache && a.length <= this.A && (this.H.set(a, b), this.H.size > this.R && (this.H.clear(), this.A = this.A / 1.1 | 0));
this.cache && a.length <= this.h && (this.F.set(a, b), this.F.size > this.O && (this.F.clear(), this.h = this.h / 1.1 | 0));
return b;
};
function ha(a) {
a.L = null;
a.J = null;
a.F.clear();
a.H.clear();
a.J.clear();
}
;function ia(a, c, b) {
a = ("object" === typeof a ? "" + a.query : a).toLowerCase();
@@ -220,15 +220,15 @@ function ha(a) {
function K(a) {
this.limit = a && !0 !== a ? a : 1000;
this.cache = new Map();
this.A = "";
this.h = "";
}
K.prototype.set = function(a, c) {
this.cache.set(this.A = a, c);
this.cache.set(this.h = a, c);
this.cache.size > this.limit && this.cache.delete(this.cache.keys().next().value);
};
K.prototype.get = function(a) {
const c = this.cache.get(a);
c && this.A !== a && (this.cache.delete(a), this.cache.set(this.A = a, c));
c && this.h !== a && (this.cache.delete(a), this.cache.set(this.h = a, c));
return c;
};
K.prototype.remove = function(a) {
@@ -239,7 +239,7 @@ K.prototype.remove = function(a) {
};
K.prototype.clear = function() {
this.cache.clear();
this.A = "";
this.h = "";
};
const ja = {normalize:function(a) {
return a.toLowerCase();
@@ -294,16 +294,16 @@ function M(a) {
;y();
N.prototype.add = function(a, c, b, e) {
if (c && (a || 0 === a)) {
if (!e && !b && this.h.has(a)) {
if (!e && !b && this.reg.has(a)) {
return this.update(a, c);
}
c = this.encoder.encode(c);
if (e = c.length) {
const l = y(), m = y(), r = this.depth, t = this.resolution;
const l = y(), m = y(), q = this.depth, t = this.resolution;
for (let p = 0; p < e; p++) {
let n = c[this.rtl ? e - 1 - p : p];
var d = n.length;
if (d && (r || !m[n])) {
if (d && (q || !m[n])) {
var f = this.score ? this.score(c, n, p, null, 0) : O(t, e, p), g = "";
switch(this.tokenize) {
case "full":
@@ -332,8 +332,8 @@ N.prototype.add = function(a, c, b, e) {
break;
}
default:
if (P(this, m, n, f, a, b), r && 1 < e && p < e - 1) {
for (d = y(), g = this.S, f = n, h = Math.min(r + 1, e - p), d[f] = 1, k = 1; k < h; k++) {
if (P(this, m, n, f, a, b), q && 1 < e && p < e - 1) {
for (d = y(), g = this.P, f = n, h = Math.min(q + 1, e - p), d[f] = 1, k = 1; k < h; k++) {
if ((n = c[this.rtl ? e - 1 - p - k : p + k]) && !d[n]) {
d[n] = 1;
const w = this.score ? this.score(c, f, p, n, k) : O(g + (e / 2 > g ? 0 : 1), e, p, h - 1, k - 1), B = this.bidirectional && n > f;
@@ -344,14 +344,14 @@ N.prototype.add = function(a, c, b, e) {
}
}
}
this.fastupdate || this.h.add(a);
this.fastupdate || this.reg.add(a);
}
}
return this;
};
function P(a, c, b, e, d, f, g) {
let h = g ? a.D : a.map, k;
c[b] && g && (k = c[b])[g] || (g ? (c = k || (c[b] = y()), c[g] = 1, (k = h.get(g)) ? h = k : h.set(g, h = new Map())) : c[b] = 1, (k = h.get(b)) ? h = k : h.set(b, h = []), h = h[e] || (h[e] = []), f && h.includes(d) || (h.push(d), a.fastupdate && ((c = a.h.get(d)) ? c.push(h) : a.h.set(d, [h]))));
let h = g ? a.ctx : a.map, k;
c[b] && g && (k = c[b])[g] || (g ? (c = k || (c[b] = y()), c[g] = 1, (k = h.get(g)) ? h = k : h.set(g, h = new Map())) : c[b] = 1, (k = h.get(b)) ? h = k : h.set(b, h = []), h = h[e] || (h[e] = []), f && h.includes(d) || (h.push(d), a.fastupdate && ((c = a.reg.get(d)) ? c.push(h) : a.reg.set(d, [h]))));
}
function O(a, c, b, e, d) {
return b && 1 < a ? c + (e || 0) <= a ? b + (d || 0) : (a - 1) / (c + (e || 0)) * (b + (d || 0)) + 1 | 0 : 0;
@@ -422,11 +422,11 @@ function O(a, c, b, e, d) {
var h = 0, k = 0;
if (1 < b) {
var l = y();
const r = [];
const q = [];
for (let t = 0, p; t < b; t++) {
if ((p = a[t]) && !l[p]) {
if (g || S(this, p)) {
r.push(p), l[p] = 1;
q.push(p), l[p] = 1;
} else {
return e;
}
@@ -435,7 +435,7 @@ function O(a, c, b, e, d) {
k = k ? Math.min(k, n) : n;
}
}
a = r;
a = q;
b = a.length;
}
if (!b) {
@@ -456,11 +456,11 @@ function O(a, c, b, e, d) {
9 < h && 3 < h / k && a.sort(aa);
}
}
for (let r, t; l < b; l++) {
for (let q, t; l < b; l++) {
t = a[l];
m ? (r = S(this, t, m), r = va(r, e, g, this.S, c, d, 2 === b), g && !1 === r && e.length || (m = t)) : (r = S(this, t), r = va(r, e, g, this.resolution, c, d, 1 === b));
if (r) {
return r;
m ? (q = S(this, t, m), q = va(q, e, g, this.P, c, d, 2 === b), g && !1 === q && e.length || (m = t)) : (q = S(this, t), q = va(q, e, g, this.resolution, c, d, 1 === b));
if (q) {
return q;
}
if (g && l === b - 1) {
f = e.length;
@@ -483,9 +483,9 @@ function O(a, c, b, e, d) {
m = a.length;
b = [];
f = y();
for (let r = 0, t, p, n, w; r < e; r++) {
for (let q = 0, t, p, n, w; q < e; q++) {
for (k = 0; k < m; k++) {
if (n = a[k], r < n.length && (t = n[r])) {
if (n = a[k], q < n.length && (t = n[q])) {
for (l = 0; l < t.length; l++) {
p = t[l], (h = f[p]) ? f[p]++ : (h = 0, f[p] = 1), w = b[h] || (b[h] = []), w.push(p);
}
@@ -559,11 +559,11 @@ function va(a, c, b, e, d, f, g) {
function S(a, c, b) {
let e;
b && (e = a.bidirectional && c > b);
a = b ? (a = a.D.get(e ? c : b)) && a.get(e ? b : c) : a.map.get(c);
a = b ? (a = a.ctx.get(e ? c : b)) && a.get(e ? b : c) : a.map.get(c);
return a;
}
;N.prototype.remove = function(a, c) {
const b = this.h.size && (this.fastupdate ? this.h.get(a) : this.h.has(a));
const b = this.reg.size && (this.fastupdate ? this.reg.get(a) : this.reg.has(a));
if (b) {
if (this.fastupdate) {
for (let e = 0, d; e < b.length; e++) {
@@ -577,9 +577,9 @@ function S(a, c, b) {
}
}
} else {
T(this.map, a), this.depth && T(this.D, a);
T(this.map, a), this.depth && T(this.ctx, a);
}
c || this.h.delete(a);
c || this.reg.delete(a);
}
this.cache && this.cache.remove(a);
return this;
@@ -627,17 +627,17 @@ function T(a, c) {
this.score = a.score || null;
d = !1;
this.map = new Map();
this.D = new Map();
this.h = c || (this.fastupdate ? new Map() : new Set());
this.S = b.resolution || 1;
this.ctx = new Map();
this.reg = c || (this.fastupdate ? new Map() : new Set());
this.P = b.resolution || 1;
this.rtl = e.rtl || a.rtl || !1;
this.cache = (d = a.cache || null) && new K(d);
}
u = N.prototype;
u.clear = function() {
this.map.clear();
this.D.clear();
this.h.clear();
this.ctx.clear();
this.reg.clear();
this.cache && this.cache.clear();
return this;
};
@@ -645,7 +645,7 @@ u.append = function(a, c) {
return this.add(a, c, !0);
};
u.contain = function(a) {
return this.h.has(a);
return this.reg.has(a);
};
u.update = function(a, c) {
if (this.async) {
@@ -673,7 +673,7 @@ u.cleanup = function() {
return console.info('Cleanup the index isn\'t required when not using "fastupdate".'), this;
}
U(this.map);
this.depth && U(this.D);
this.depth && U(this.ctx);
return this;
};
u.searchCache = ia;
@@ -688,16 +688,16 @@ u.export = function(a, c, b, e, d, f) {
h = "reg";
if (this.fastupdate) {
k = y();
for (let l of this.h.keys()) {
for (let l of this.reg.keys()) {
k[l] = 1;
}
} else {
k = this.h;
k = this.reg;
}
break;
case 1:
h = "cfg";
k = {doc:0, opt:this.A ? 1 : 0};
k = {doc:0, opt:this.h ? 1 : 0};
break;
case 2:
h = "map";
@@ -705,7 +705,7 @@ u.export = function(a, c, b, e, d, f) {
break;
case 3:
h = "ctx";
k = this.D;
k = this.ctx;
break;
default:
"undefined" === typeof b && f && f();
@@ -718,42 +718,92 @@ u.import = function(a, c) {
if (c) {
switch(z(c) && (c = JSON.parse(c)), a) {
case "cfg":
this.A = !!c.opt;
this.h = !!c.opt;
break;
case "reg":
this.fastupdate = !1;
this.h = c;
this.reg = c;
break;
case "map":
this.map = c;
break;
case "ctx":
this.D = c;
this.ctx = c;
}
}
};
u.serialize = function(a = !0) {
if (!this.reg.size) {
return "";
}
let c = "", b = "";
for (var e of this.reg.keys()) {
b || (b = typeof e), c += (c ? "," : "") + ("string" === b ? '"' + e + '"' : e);
}
c = "index.reg=new Set([" + c + "]);";
e = "";
for (var d of this.map.entries()) {
var f = d[0], g = d[1], h = "";
for (let m = 0, q; m < g.length; m++) {
q = g[m] || [""];
var k = "";
for (var l = 0; l < q.length; l++) {
k += (k ? "," : "") + ("string" === b ? '"' + q[l] + '"' : q[l]);
}
k = "[" + k + "]";
h += (h ? "," : "") + k;
}
h = '["' + f + '",[' + h + "]]";
e += (e ? "," : "") + h;
}
e = "index.map=new Map([" + e + "]);";
d = "";
for (const m of this.ctx.entries()) {
f = m[0];
g = m[1];
for (const q of g.entries()) {
g = q[0];
h = q[1];
k = "";
for (let t = 0, p; t < h.length; t++) {
p = h[t] || [""];
l = "";
for (let n = 0; n < p.length; n++) {
l += (l ? "," : "") + ("string" === b ? '"' + p[n] + '"' : p[n]);
}
l = "[" + l + "]";
k += (k ? "," : "") + l;
}
k = 'new Map([["' + g + '",[' + k + "]]])";
k = '["' + f + '",' + k + "]";
d += (d ? "," : "") + k;
}
}
d = "index.ctx=new Map([" + d + "]);";
return a ? "function inject(index){" + c + e + d + "}" : c + e + d;
};
ta(N.prototype);
V.prototype.add = function(a, c, b) {
E(a) && (c = a, a = F(c, this.key));
if (c && (a || 0 === a)) {
if (!b && this.h.has(a)) {
if (!b && this.reg.has(a)) {
return this.update(a, c);
}
for (let h = 0, k; h < this.field.length; h++) {
k = this.F[h];
k = this.C[h];
var e = this.index.get(this.field[h]);
if ("function" === typeof k) {
var d = k(c);
d && e.add(a, d, !1, !0);
} else {
if (d = k.I, !d || d(c)) {
k.constructor === String ? k = ["" + k] : z(k) && (k = [k]), W(c, k, this.K, 0, e, a, k[0], b);
if (d = k.G, !d || d(c)) {
k.constructor === String ? k = ["" + k] : z(k) && (k = [k]), W(c, k, this.I, 0, e, a, k[0], b);
}
}
}
if (this.tag) {
for (e = 0; e < this.C.length; e++) {
var f = this.C[e], g = this.T[e];
for (e = 0; e < this.B.length; e++) {
var f = this.B[e], g = this.R[e];
d = this.tag.get(g);
let h = y();
if ("function" === typeof f) {
@@ -761,7 +811,7 @@ V.prototype.add = function(a, c, b) {
continue;
}
} else {
const k = f.I;
const k = f.G;
if (k && !k(c)) {
continue;
}
@@ -771,7 +821,7 @@ V.prototype.add = function(a, c, b) {
if (d && f) {
z(f) && (f = [f]);
for (let k = 0, l, m; k < f.length; k++) {
l = f[k], h[l] || (h[l] = 1, (g = d.get(l)) ? m = g : d.set(l, m = []), b && m.includes(a) || (m.push(a), this.fastupdate && ((g = this.h.get(a)) ? g.push(m) : this.h.set(a, [m]))));
l = f[k], h[l] || (h[l] = 1, (g = d.get(l)) ? m = g : d.set(l, m = []), b && m.includes(a) || (m.push(a), this.fastupdate && ((g = this.reg.get(a)) ? g.push(m) : this.reg.set(a, [m]))));
}
} else {
d || console.warn("Tag '" + g + "' was not found");
@@ -780,11 +830,11 @@ V.prototype.add = function(a, c, b) {
}
if (this.store && (!b || !this.store.has(a))) {
let h;
if (this.B) {
if (this.A) {
h = y();
for (let k = 0, l; k < this.B.length; k++) {
l = this.B[k];
if ((b = l.I) && !b(c)) {
for (let k = 0, l; k < this.A.length; k++) {
l = this.A[k];
if ((b = l.G) && !b(c)) {
continue;
}
let m;
@@ -793,7 +843,7 @@ V.prototype.add = function(a, c, b) {
if (!m) {
continue;
}
l = [l.U];
l = [l.S];
} else if (z(l) || l.constructor === String) {
h[l] = c[l];
continue;
@@ -849,7 +899,7 @@ function W(a, c, b, e, d, f, g, h) {
let d = [];
var f = [];
let g, h, k, l, m;
let r = 0;
let q = 0;
if (b) {
b.constructor === Array && (b = {index:b});
a = b.query || a;
@@ -865,24 +915,24 @@ function W(a, c, b, e, d, f, g, h) {
if (m) {
m.constructor !== Array && (m = [m]);
var n = [];
for (let v = 0, q; v < m.length; v++) {
q = m[v];
if (z(q)) {
for (let v = 0, r; v < m.length; v++) {
r = m[v];
if (z(r)) {
throw Error("A tag option can't be a string, instead it needs a { field: tag } format.");
}
if (q.field && q.tag) {
var w = q.tag;
if (r.field && r.tag) {
var w = r.tag;
if (w.constructor === Array) {
for (var B = 0; B < w.length; B++) {
n.push(q.field, w[B]);
n.push(r.field, w[B]);
}
} else {
n.push(q.field, w);
n.push(r.field, w);
}
} else {
w = Object.keys(q);
w = Object.keys(r);
for (let C = 0, D, A; C < w.length; C++) {
if (D = w[C], A = q[D], A.constructor === Array) {
if (D = w[C], A = r[D], A.constructor === Array) {
for (B = 0; B < A.length; B++) {
n.push(D, A[B]);
}
@@ -904,8 +954,8 @@ function W(a, c, b, e, d, f, g, h) {
}
}
return e.length ? Promise.all(e).then(function(v) {
for (let q = 0; q < v.length; q++) {
d[q].result = v[q];
for (let r = 0; r < v.length; r++) {
d[r].result = v[r];
}
return d;
}) : d;
@@ -915,22 +965,22 @@ function W(a, c, b, e, d, f, g, h) {
}
l || (l = this.field);
p = !e && (this.worker || this.async) && [];
for (let v = 0, q, C, D; v < l.length; v++) {
for (let v = 0, r, C, D; v < l.length; v++) {
C = l[v];
let A;
z(C) || (A = C, C = A.field, a = A.query || a, c = A.limit || c, k = A.suggest || k);
if (e) {
q = e[v];
r = e[v];
} else {
if (n = A || b, w = this.index.get(C), m && (n.enrich = !1), p) {
p[v] = w.searchAsync(a, c, n);
n && g && (n.enrich = g);
continue;
} else {
q = w.search(a, c, n), n && g && (n.enrich = g);
r = w.search(a, c, n), n && g && (n.enrich = g);
}
}
D = q && q.length;
D = r && r.length;
if (m && D) {
n = [];
w = 0;
@@ -950,8 +1000,8 @@ function W(a, c, b, e, d, f, g, h) {
}
}
if (w) {
q = ua(q, n);
D = q.length;
r = ua(r, n);
D = r.length;
if (!D && !k) {
return d;
}
@@ -959,31 +1009,31 @@ function W(a, c, b, e, d, f, g, h) {
}
}
if (D) {
f[r] = C, d.push(q), r++;
f[q] = C, d.push(r), q++;
} else if (1 === l.length) {
return d;
}
}
if (p) {
const v = this;
return Promise.all(p).then(function(q) {
return q.length ? v.search(a, c, b, q) : q;
return Promise.all(p).then(function(r) {
return r.length ? v.search(a, c, b, r) : r;
});
}
if (!r) {
if (!q) {
return d;
}
if (t && (!g || !this.store)) {
return d[0];
}
p = [];
for (let v = 0, q; v < f.length; v++) {
q = d[v];
g && q.length && !q[0].doc && q.length && (q = xa.call(this, q));
for (let v = 0, r; v < f.length; v++) {
r = d[v];
g && r.length && !r[0].doc && r.length && (r = xa.call(this, r));
if (t) {
return q;
return r;
}
d[v] = {field:f[v], result:q};
d[v] = {field:f[v], result:r};
}
return h ? ya(d, c) : d;
};
@@ -1032,12 +1082,12 @@ function xa(a) {
}
const c = a.document || a.doc || a;
var b;
this.F = [];
this.C = [];
this.field = [];
this.K = [];
this.key = (b = c.key || c.id) && Y(b, this.K) || "id";
this.h = (this.fastupdate = !!a.fastupdate) ? new Map() : new Set();
this.B = (b = c.store || null) && !0 !== b && [];
this.I = [];
this.key = (b = c.key || c.id) && Y(b, this.I) || "id";
this.reg = (this.fastupdate = !!a.fastupdate) ? new Map() : new Set();
this.A = (b = c.store || null) && !0 !== b && [];
this.store = b && new Map();
this.cache = (b = a.cache || null) && new K(b);
this.async = a.cache = !1;
@@ -1045,13 +1095,13 @@ function xa(a) {
let e = c.index || c.field || c;
z(e) && (e = [e]);
for (let d = 0, f, g; d < e.length; d++) {
f = e[d], z(f) || (g = f, f = f.field), g = E(g) ? Object.assign({}, a, g) : a, b.set(f, new N(g, this.h)), g.custom ? this.F[d] = g.custom : (this.F[d] = Y(f, this.K), g.filter && ("string" === typeof this.F[d] && (this.F[d] = new String(this.F[d])), this.F[d].I = g.filter)), this.field[d] = f;
f = e[d], z(f) || (g = f, f = f.field), g = E(g) ? Object.assign({}, a, g) : a, b.set(f, new N(g, this.reg)), g.custom ? this.C[d] = g.custom : (this.C[d] = Y(f, this.I), g.filter && ("string" === typeof this.C[d] && (this.C[d] = new String(this.C[d])), this.C[d].G = g.filter)), this.field[d] = f;
}
if (this.B) {
if (this.A) {
a = c.store;
z(a) && (a = [a]);
for (let d = 0, f, g; d < a.length; d++) {
f = a[d], g = f.field || f, f.custom ? (this.B[d] = f.custom, f.custom.U = g) : (this.B[d] = Y(g, this.K), f.filter && ("string" === typeof this.B[d] && (this.B[d] = new String(this.B[d])), this.B[d].I = f.filter));
f = a[d], g = f.field || f, f.custom ? (this.A[d] = f.custom, f.custom.S = g) : (this.A[d] = Y(g, this.I), f.filter && ("string" === typeof this.A[d] && (this.A[d] = new String(this.A[d])), this.A[d].G = f.filter));
}
}
this.index = b;
@@ -1059,16 +1109,16 @@ function xa(a) {
if (b = c.tag) {
if ("string" === typeof b && (b = [b]), b.length) {
this.tag = new Map();
this.C = [];
this.T = [];
this.B = [];
this.R = [];
for (let d = 0, f, g; d < b.length; d++) {
f = b[d];
g = f.field || f;
if (!g) {
throw Error("The tag field from the document descriptor is undefined.");
}
f.custom ? this.C[d] = f.custom : (this.C[d] = Y(g, this.K), f.filter && ("string" === typeof this.C[d] && (this.C[d] = new String(this.C[d])), this.C[d].I = f.filter));
this.T[d] = g;
f.custom ? this.B[d] = f.custom : (this.B[d] = Y(g, this.I), f.filter && ("string" === typeof this.B[d] && (this.B[d] = new String(this.B[d])), this.B[d].G = f.filter));
this.R[d] = g;
this.tag.set(g, new Map());
}
}
@@ -1095,7 +1145,7 @@ u.remove = function(a) {
for (var c of this.index.values()) {
c.remove(a, !0);
}
if (this.h.has(a)) {
if (this.reg.has(a)) {
if (this.tag && !this.fastupdate) {
for (let b of this.tag.values()) {
for (let e of b) {
@@ -1106,7 +1156,7 @@ u.remove = function(a) {
}
}
this.store && this.store.delete(a);
this.h.delete(a);
this.reg.delete(a);
}
this.cache && this.cache.remove(a);
return this;
@@ -1124,7 +1174,7 @@ u.clear = function() {
return this;
};
u.contain = function(a) {
return this.h.has(a);
return this.reg.has(a);
};
u.cleanup = function() {
for (const a of this.index.values()) {
@@ -1156,7 +1206,7 @@ u.export = function(a, c, b, e, d, f) {
switch(d) {
case 1:
c = "tag";
h = this.G;
h = this.D;
b = null;
break;
case 2:
@@ -1176,13 +1226,13 @@ u.import = function(a, c) {
if (c) {
switch(z(c) && (c = JSON.parse(c)), a) {
case "tag":
this.G = c;
this.D = c;
break;
case "reg":
this.fastupdate = !1;
this.h = c;
this.reg = c;
for (let e = 0, d; e < this.field.length; e++) {
d = this.index[this.field[e]], d.h = c, d.fastupdate = !1;
d = this.index[this.field[e]], d.reg = c, d.fastupdate = !1;
}
break;
case "store":

View File

@@ -15,35 +15,37 @@ function z(a){return"string"===typeof a}function E(a){return"object"===typeof a}
["\u0477","\u0475"],["\u04c2","\u0436"],["\u04d1","\u0430"],["\u04d3","\u0430"],["\u04d7","\u0435"],["\u04db","\u04d9"],["\u04dd","\u0436"],["\u04df","\u0437"],["\u04e3","\u0438"],["\u04e5","\u0438"],["\u04e7","\u043e"],["\u04eb","\u04e9"],["\u04ed","\u044d"],["\u04ef","\u0443"],["\u04f1","\u0443"],["\u04f3","\u0443"],["\u04f5","\u0447"]];const ca=/[^\p{L}\p{N}]+/u,da=/(\d{3})/g,ea=/(\D)(\d{3})/g,fa=/(\d{3})(\D)/g,H="".normalize&&/[\u0300-\u036f]/g;function I(a){if(!this)return new I(...arguments);for(let c=0;c<arguments.length;c++)this.assign(arguments[c])}
I.prototype.assign=function(a){this.normalize=x(a.normalize,!0,this.normalize);let c=a.include,b=c||a.exclude||a.split;if("object"===typeof b){let e=!c,d="";a.include||(d+="\\p{Z}");b.letter&&(d+="\\p{L}");b.number&&(d+="\\p{N}",e=!!c);b.symbol&&(d+="\\p{S}");b.punctuation&&(d+="\\p{P}");b.control&&(d+="\\p{C}");if(b=b.char)d+="object"===typeof b?b.join(""):b;this.split=new RegExp("["+(c?"^":"")+d+"]+","u");this.numeric=e}else this.split=x(b,ca,this.split),this.numeric=x(this.numeric,!0);this.prepare=
x(a.prepare,null,this.prepare);this.finalize=x(a.finalize,null,this.finalize);H||(this.mapper=new Map(ba));this.rtl=a.rtl||!1;this.dedupe=x(a.dedupe,!0,this.dedupe);this.filter=x((b=a.filter)&&new Set(b),null,this.filter);this.matcher=x((b=a.matcher)&&new Map(b),null,this.matcher);this.mapper=x((b=a.mapper)&&new Map(b),null,this.mapper);this.stemmer=x((b=a.stemmer)&&new Map(b),null,this.stemmer);this.replacer=x(a.replacer,null,this.replacer);this.minlength=x(a.minlength,1,this.minlength);this.maxlength=
x(a.maxlength,0,this.maxlength);if(this.cache=b=x(a.cache,!0,this.cache))this.L=null,this.R="number"===typeof b?b:2E5,this.H=new Map,this.J=new Map,this.G=this.A=128;this.M="";this.O=null;this.N="";this.P=null;if(this.matcher)for(const e of this.matcher.keys())this.M+=(this.M?"|":"")+e;if(this.stemmer)for(const e of this.stemmer.keys())this.N+=(this.N?"|":"")+e;return this};
I.prototype.encode=function(a){if(this.cache&&a.length<=this.A)if(this.L){if(this.H.has(a))return this.H.get(a)}else this.L=setTimeout(ha,0,this);this.normalize&&(a="function"===typeof this.normalize?this.normalize(a):H?a.normalize("NFKD").replace(H,"").toLowerCase():a.toLowerCase());this.prepare&&(a=this.prepare(a));this.numeric&&3<a.length&&(a=a.replace(ea,"$1 $2").replace(fa,"$1 $2").replace(da,"$1 "));const c=!(this.dedupe||this.mapper||this.filter||this.matcher||this.stemmer||this.replacer);
let b=[],e=this.split||""===this.split?a.split(this.split):a;for(let f=0,g,h;f<e.length;f++){if(!(g=h=e[f]))continue;if(g.length<this.minlength)continue;if(c){b.push(g);continue}if(this.filter&&this.filter.has(g))continue;if(this.cache&&g.length<=this.G)if(this.L){var d=this.J.get(g);if(d||""===d){d&&b.push(d);continue}}else this.L=setTimeout(ha,0,this);let k;this.stemmer&&2<g.length&&(this.P||(this.P=new RegExp("(?!^)("+this.N+")$")),g=g.replace(this.P,l=>this.stemmer.get(l)),k=1);this.matcher&&
1<g.length&&(this.O||(this.O=new RegExp("("+this.M+")","g")),g=g.replace(this.O,l=>this.matcher.get(l)),k=1);g&&k&&(g.length<this.minlength||this.filter&&this.filter.has(g))&&(g="");if(g&&(this.mapper||this.dedupe&&1<g.length)){d="";for(let l=0,m="",r,t;l<g.length;l++)r=g.charAt(l),r===m&&this.dedupe||((t=this.mapper&&this.mapper.get(r))||""===t?t===m&&this.dedupe||!(m=t)||(d+=t):d+=m=r);g=d}if(g&&this.replacer)for(d=0;g&&d<this.replacer.length;d+=2)g=g.replace(this.replacer[d],this.replacer[d+1]);
this.cache&&h.length<=this.G&&(this.J.set(h,g),this.J.size>this.R&&(this.J.clear(),this.G=this.G/1.1|0));g&&b.push(g)}this.finalize&&(b=this.finalize(b)||b);this.cache&&a.length<=this.A&&(this.H.set(a,b),this.H.size>this.R&&(this.H.clear(),this.A=this.A/1.1|0));return b};function ha(a){a.L=null;a.H.clear();a.J.clear()};function ia(a,c,b){a=("object"===typeof a?""+a.query:a).toLowerCase();let e=this.cache.get(a);if(!e){e=this.search(a,c,b);if(e.then){const d=this;e.then(function(f){d.cache.set(a,f);return f})}this.cache.set(a,e)}return e}function J(a){this.limit=a&&!0!==a?a:1E3;this.cache=new Map;this.A=""}J.prototype.set=function(a,c){this.cache.set(this.A=a,c);this.cache.size>this.limit&&this.cache.delete(this.cache.keys().next().value)};
J.prototype.get=function(a){const c=this.cache.get(a);c&&this.A!==a&&(this.cache.delete(a),this.cache.set(this.A=a,c));return c};J.prototype.remove=function(a){for(const c of this.cache){const b=c[0];c[1].includes(a)&&this.cache.delete(b)}};J.prototype.clear=function(){this.cache.clear();this.A=""};const ja={normalize:function(a){return a.toLowerCase()},dedupe:!1};const K=new Map([["b","p"],["v","f"],["w","f"],["z","s"],["x","s"],["d","t"],["n","m"],["c","k"],["g","k"],["j","k"],["q","k"],["i","e"],["y","e"],["u","o"]]);const ka=new Map([["ai","ei"],["ae","a"],["oe","o"],["ue","u"],["sh","s"],["ch","c"],["th","t"],["ph","f"],["pf","f"]]),la=[/([^aeo])h([aeo$])/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2"];const ma={a:"",e:"",i:"",o:"",u:"",y:"",b:1,f:1,p:1,v:1,c:2,g:2,j:2,k:2,q:2,s:2,x:2,z:2,"\u00df":2,d:3,t:3,l:4,m:5,n:5,r:6};const na=/[\x00-\x7F]+/g;const oa=/[\x00-\x7F]+/g;const pa=/[\x00-\x7F]+/g;var qa={LatinExact:{normalize:!1,dedupe:!1},LatinDefault:ja,LatinSimple:{normalize:!0,dedupe:!0},LatinBalance:{normalize:!0,dedupe:!0,mapper:K},LatinAdvanced:{normalize:!0,dedupe:!0,mapper:K,replacer:la,matcher:ka},LatinExtra:{normalize:!0,dedupe:!0,mapper:K,replacer:la.concat([/(?!^)[aeoy]/g,""]),matcher:ka},LatinSoundex:{normalize:!0,dedupe:!1,include:{letter:!0},finalize:function(a){for(let b=0;b<a.length;b++){var c=a[b];let e=c.charAt(0),d=ma[e];for(let f=1,g;f<c.length&&(g=c.charAt(f),"h"===
g||"w"===g||!(g=ma[g])||g===d||(e+=g,d=g,4!==e.length));f++);a[b]=e}}},ArabicDefault:{rtl:!0,normalize:!1,dedupe:!0,prepare:function(a){return(""+a).replace(na," ")}},CjkDefault:{normalize:!1,dedupe:!0,split:"",prepare:function(a){return(""+a).replace(oa,"")}},CyrillicDefault:{normalize:!1,dedupe:!0,prepare:function(a){return(""+a).replace(pa," ")}}};function ra(a,c,b,e,d,f,g,h){(e=a(b?b+"."+e:e,JSON.stringify(g)))&&e.then?e.then(function(){c.export(a,c,b,d,f+1,h)}):c.export(a,c,b,d,f+1,h)};const sa={memory:{resolution:1},performance:{resolution:6,fastupdate:!0,context:{depth:1,resolution:3}},match:{tokenize:"forward"},score:{resolution:9,context:{depth:2,resolution:9}}};function ta(a){L.call(a,"add");L.call(a,"append");L.call(a,"search");L.call(a,"update");L.call(a,"remove")}function L(a){this[a+"Async"]=function(){var c=arguments;const b=c[c.length-1];let e;"function"===typeof b&&(e=b,delete c[c.length-1]);this.async=!0;c=this[a].apply(this,c);this.async=!1;e&&(c.then?c.then(e):e(c));return c}};y();M.prototype.add=function(a,c,b,e){if(c&&(a||0===a)){if(!e&&!b&&this.h.has(a))return this.update(a,c);c=this.encoder.encode(c);if(e=c.length){const l=y(),m=y(),r=this.depth,t=this.resolution;for(let p=0;p<e;p++){let n=c[this.rtl?e-1-p:p];var d=n.length;if(d&&(r||!m[n])){var f=this.score?this.score(c,n,p,null,0):N(t,e,p),g="";switch(this.tokenize){case "full":if(2<d){for(f=0;f<d;f++)for(var h=d;h>f;h--){g=n.substring(f,h);var k=this.score?this.score(c,n,p,g,f):N(t,e,p,d,f);O(this,m,g,k,a,b)}break}case "reverse":if(1<
d){for(h=d-1;0<h;h--)g=n[h]+g,k=this.score?this.score(c,n,p,g,h):N(t,e,p,d,h),O(this,m,g,k,a,b);g=""}case "forward":if(1<d){for(h=0;h<d;h++)g+=n[h],O(this,m,g,f,a,b);break}default:if(O(this,m,n,f,a,b),r&&1<e&&p<e-1)for(d=y(),g=this.S,f=n,h=Math.min(r+1,e-p),d[f]=1,k=1;k<h;k++)if((n=c[this.rtl?e-1-p-k:p+k])&&!d[n]){d[n]=1;const w=this.score?this.score(c,f,p,n,k):N(g+(e/2>g?0:1),e,p,h-1,k-1),B=this.bidirectional&&n>f;O(this,l,B?f:n,w,a,b,B?n:f)}}}}this.fastupdate||this.h.add(a)}}return this};
function O(a,c,b,e,d,f,g){let h=g?a.D:a.map,k;c[b]&&g&&(k=c[b])[g]||(g?(c=k||(c[b]=y()),c[g]=1,(k=h.get(g))?h=k:h.set(g,h=new Map)):c[b]=1,(k=h.get(b))?h=k:h.set(b,h=[]),h=h[e]||(h[e]=[]),f&&h.includes(d)||(h.push(d),a.fastupdate&&((c=a.h.get(d))?c.push(h):a.h.set(d,[h]))))}function N(a,c,b,e,d){return b&&1<a?c+(e||0)<=a?b+(d||0):(a-1)/(c+(e||0))*(b+(d||0))+1|0:0};function Q(a,c,b){if(1===a.length)return a=a[0],a=b||a.length>c?c?a.slice(b,b+c):a.slice(b):a;let e=[];for(let d=0,f,g;d<a.length;d++)if((f=a[d])&&(g=f.length)){if(b){if(b>=g){b-=g;continue}b<g&&(f=c?f.slice(b,b+c):f.slice(b),g=f.length,b=0)}if(e.length)g>c&&(f=f.slice(0,c),g=f.length),e.push(f);else{if(g>=c)return g>c&&(f=f.slice(0,c)),f;e=[f]}c-=g;if(!c)break}return e.length?e=1<e.length?[].concat.apply([],e):e[0]:e};function ua(a,c){const b=y(),e=y(),d=[];for(let f=0;f<a.length;f++)b[a[f]]=1;for(let f=0,g;f<c.length;f++){g=c[f];for(let h=0,k;h<g.length;h++)k=g[h],b[k]&&!e[k]&&(e[k]=1,d.push(k))}return d};M.prototype.search=function(a,c,b){b||(!c&&E(a)?(b=a,a=""):E(c)&&(b=c,c=0));var e=[],d=0;if(b){a=b.query||a;c=b.limit||c;d=b.offset||0;var f=b.context;var g=b.suggest}a=this.encoder.encode(a);b=a.length;c||(c=100);if(1===b)return R.call(this,a[0],"",c,d);f=this.depth&&!1!==f;if(2===b&&f&&!g)return R.call(this,a[0],a[1],c,d);var h=0,k=0;if(1<b){var l=y();const r=[];for(let t=0,p;t<b;t++)if((p=a[t])&&!l[p]){if(g||S(this,p))r.push(p),l[p]=1;else return e;const n=p.length;h=Math.max(h,n);k=k?Math.min(k,
n):n}a=r;b=a.length}if(!b)return e;l=0;if(1===b)return R.call(this,a[0],"",c,d);if(2===b&&f&&!g)return R.call(this,a[0],a[1],c,d);if(1<b)if(f){var m=a[0];l=1}else 9<h&&3<h/k&&a.sort(aa);for(let r,t;l<b;l++){t=a[l];m?(r=S(this,t,m),r=va(r,e,g,this.S,c,d,2===b),g&&!1===r&&e.length||(m=t)):(r=S(this,t),r=va(r,e,g,this.resolution,c,d,1===b));if(r)return r;if(g&&l===b-1){f=e.length;if(!f){if(m){m="";l=-1;continue}return e}if(1===f)return Q(e[0],c,d)}}a:{a=e;e=this.resolution;m=a.length;b=[];f=y();for(let r=
0,t,p,n,w;r<e;r++)for(k=0;k<m;k++)if(n=a[k],r<n.length&&(t=n[r]))for(l=0;l<t.length;l++)p=t[l],(h=f[p])?f[p]++:(h=0,f[p]=1),w=b[h]||(b[h]=[]),w.push(p);if(a=b.length)if(g){if(1<b.length){g=b;a=[];e=y();f=g.length;for(k=0;k<f;k++)for(m=g[k],h=m.length,l=0;l<h;l++)if(b=m[l],!e[b])if(e[b]=1,d)d--;else if(a.push(b),a.length===c)break;c=a}else c=b[0];b=c}else{if(a<m){e=[];break a}b=b[a-1];if(b.length>c||d)b=b.slice(d,c+d)}e=b}return e};function R(a,c,b,e){return(a=S(this,a,c))&&a.length?Q(a,b,e):[]}
function va(a,c,b,e,d,f,g){let h=[];if(a){e=Math.min(a.length,e);for(let k=0,l=0,m;k<e;k++)if(m=a[k])if(f&&m&&g&&(m.length<=f?(f-=m.length,m=null):(m=m.slice(f),f=0)),m&&(h[k]=m,g&&(l+=m.length,l>=d)))break;if(h.length){if(g)return Q(h,d,0);c.push(h);return}}return!b&&h}function S(a,c,b){let e;b&&(e=a.bidirectional&&c>b);a=b?(a=a.D.get(e?c:b))&&a.get(e?b:c):a.map.get(c);return a};M.prototype.remove=function(a,c){const b=this.h.size&&(this.fastupdate?this.h.get(a):this.h.has(a));if(b){if(this.fastupdate)for(let e=0,d;e<b.length;e++){if(d=b[e])if(2>d.length)d.pop();else{const f=d.indexOf(a);f===b.length-1?d.pop():d.splice(f,1)}}else T(this.map,a),this.depth&&T(this.D,a);c||this.h.delete(a)}this.cache&&this.cache.remove(a);return this};
function T(a,c){let b=0;if(a.constructor===Array)for(let e=0,d,f;e<a.length;e++){if((d=a[e])&&d.length)if(f=d.indexOf(c),0<=f){1<d.length?(d.splice(f,1),b++):delete a[e];break}else b++}else for(let e of a){const d=e[0],f=T(e[1],c);f?b+=f:a.delete(d)}return b};function M(a,c){if(!this)return new M(a);if(a){var b=z(a)?a:a.preset;b&&(a=Object.assign({},sa[b],a))}else a={};b=a.context||{};const e=a.encode||a.encoder||ja;this.encoder=e.encode?e:"object"===typeof e?new I(e):{encode:e};let d;this.resolution=a.resolution||9;this.tokenize=d=a.tokenize||"strict";this.depth="strict"===d&&b.depth||0;this.bidirectional=!1!==b.bidirectional;this.fastupdate=!!a.fastupdate;this.score=a.score||null;d=!1;this.map=new Map;this.D=new Map;this.h=c||(this.fastupdate?new Map:
new Set);this.S=b.resolution||1;this.rtl=e.rtl||a.rtl||!1;this.cache=(d=a.cache||null)&&new J(d)}u=M.prototype;u.clear=function(){this.map.clear();this.D.clear();this.h.clear();this.cache&&this.cache.clear();return this};u.append=function(a,c){return this.add(a,c,!0)};u.contain=function(a){return this.h.has(a)};u.update=function(a,c){if(this.async){const b=this,e=this.remove(a);return e.then?e.then(()=>b.add(a,c)):this.add(a,c)}return this.remove(a).add(a,c)};
function U(a){let c=0;if(a.constructor===Array)for(let b=0,e;b<a.length;b++)(e=a[b])&&(c+=e.length);else for(const b of a){const e=b[0],d=U(b[1]);d?c+=d:a.delete(e)}return c}u.cleanup=function(){if(!this.fastupdate)return this;U(this.map);this.depth&&U(this.D);return this};u.searchCache=ia;
u.export=function(a,c,b,e,d,f){let g=!0;"undefined"===typeof f&&(g=new Promise(l=>{f=l}));let h,k;switch(d||(d=0)){case 0:h="reg";if(this.fastupdate){k=y();for(let l of this.h.keys())k[l]=1}else k=this.h;break;case 1:h="cfg";k={doc:0,opt:this.A?1:0};break;case 2:h="map";k=this.map;break;case 3:h="ctx";k=this.D;break;default:"undefined"===typeof b&&f&&f();return}ra(a,c||this,b,h,e,d,k,f);return g};
u.import=function(a,c){if(c)switch(z(c)&&(c=JSON.parse(c)),a){case "cfg":this.A=!!c.opt;break;case "reg":this.fastupdate=!1;this.h=c;break;case "map":this.map=c;break;case "ctx":this.D=c}};ta(M.prototype);V.prototype.add=function(a,c,b){E(a)&&(c=a,a=F(c,this.key));if(c&&(a||0===a)){if(!b&&this.h.has(a))return this.update(a,c);for(let h=0,k;h<this.field.length;h++){k=this.F[h];var e=this.index.get(this.field[h]);if("function"===typeof k){var d=k(c);d&&e.add(a,d,!1,!0)}else if(d=k.I,!d||d(c))k.constructor===String?k=[""+k]:z(k)&&(k=[k]),W(c,k,this.K,0,e,a,k[0],b)}if(this.tag)for(e=0;e<this.C.length;e++){var f=this.C[e];d=this.tag.get(this.T[e]);let h=y();if("function"===typeof f){if(f=f(c),!f)continue}else{var g=
f.I;if(g&&!g(c))continue;f.constructor===String&&(f=""+f);f=F(c,f)}if(d&&f){z(f)&&(f=[f]);for(let k=0,l,m;k<f.length;k++)l=f[k],h[l]||(h[l]=1,(g=d.get(l))?m=g:d.set(l,m=[]),b&&m.includes(a)||(m.push(a),this.fastupdate&&((g=this.h.get(a))?g.push(m):this.h.set(a,[m]))))}}if(this.store&&(!b||!this.store.has(a))){let h;if(this.B){h=y();for(let k=0,l;k<this.B.length;k++){l=this.B[k];if((b=l.I)&&!b(c))continue;let m;if("function"===typeof l){m=l(c);if(!m)continue;l=[l.U]}else if(z(l)||l.constructor===String){h[l]=
c[l];continue}X(c,h,l,0,l[0],m)}}this.store.set(a,h||c)}}return this};function X(a,c,b,e,d,f){a=a[d];if(e===b.length-1)c[d]=f||a;else if(a)if(a.constructor===Array)for(c=c[d]=Array(a.length),d=0;d<a.length;d++)X(a,c,b,e,d);else c=c[d]||(c[d]=y()),d=b[++e],X(a,c,b,e,d)}
function W(a,c,b,e,d,f,g,h){if(a=a[g])if(e===c.length-1){if(a.constructor===Array){if(b[e]){for(c=0;c<a.length;c++)d.add(f,a[c],!0,!0);return}a=a.join(" ")}d.add(f,a,h,!0)}else if(a.constructor===Array)for(g=0;g<a.length;g++)W(a,c,b,e,d,f,g,h);else g=c[++e],W(a,c,b,e,d,f,g,h)};V.prototype.search=function(a,c,b,e){b||(!c&&E(a)?(b=a,a=""):E(c)&&(b=c,c=0));let d=[];var f=[];let g,h,k,l,m;let r=0;if(b){b.constructor===Array&&(b={index:b});a=b.query||a;var t=b.pluck;h=b.merge;l=t||b.field||b.index;m=this.tag&&b.tag;g=this.store&&b.enrich;k=b.suggest;c=b.limit||c;var p=b.offset||0;c||(c=100);if(m){m.constructor!==Array&&(m=[m]);var n=[];for(let v=0,q;v<m.length;v++)if(q=m[v],q.field&&q.tag){var w=q.tag;if(w.constructor===Array)for(var B=0;B<w.length;B++)n.push(q.field,w[B]);
else n.push(q.field,w)}else{w=Object.keys(q);for(let C=0,D,A;C<w.length;C++)if(D=w[C],A=q[D],A.constructor===Array)for(B=0;B<A.length;B++)n.push(D,A[B]);else n.push(D,A)}m=n;if(!a){e=[];if(n.length)for(f=0;f<n.length;f+=2)t=wa.call(this,n[f],n[f+1],c,p,g),d.push({field:n[f],tag:n[f+1],result:t});return e.length?Promise.all(e).then(function(v){for(let q=0;q<v.length;q++)d[q].result=v[q];return d}):d}}z(l)&&(l=[l])}l||(l=this.field);p=!e&&(this.worker||this.async)&&[];for(let v=0,q,C,D;v<l.length;v++){C=
l[v];let A;z(C)||(A=C,C=A.field,a=A.query||a,c=A.limit||c,k=A.suggest||k);if(e)q=e[v];else if(n=A||b,w=this.index.get(C),m&&(n.enrich=!1),p){p[v]=w.searchAsync(a,c,n);n&&g&&(n.enrich=g);continue}else q=w.search(a,c,n),n&&g&&(n.enrich=g);D=q&&q.length;if(m&&D){n=[];w=0;for(let P=0,G,Aa;P<m.length;P+=2){G=this.tag.get(m[P]);if(!G)if(k)continue;else return d;if(Aa=(G=G&&G.get(m[P+1]))&&G.length)w++,n.push(G);else if(!k)return d}if(w){q=ua(q,n);D=q.length;if(!D&&!k)return d;w--}}if(D)f[r]=C,d.push(q),
r++;else if(1===l.length)return d}if(p){const v=this;return Promise.all(p).then(function(q){return q.length?v.search(a,c,b,q):q})}if(!r)return d;if(t&&(!g||!this.store))return d[0];p=[];for(let v=0,q;v<f.length;v++){q=d[v];g&&q.length&&!q[0].doc&&q.length&&(q=xa.call(this,q));if(t)return q;d[v]={field:f[v],result:q}}return h?ya(d,c):d};
x(a.maxlength,0,this.maxlength);if(this.cache=b=x(a.cache,!0,this.cache))this.J=null,this.O="number"===typeof b?b:2E5,this.F=new Map,this.H=new Map,this.D=this.h=128;this.K="";this.M=null;this.L="";this.N=null;if(this.matcher)for(const e of this.matcher.keys())this.K+=(this.K?"|":"")+e;if(this.stemmer)for(const e of this.stemmer.keys())this.L+=(this.L?"|":"")+e;return this};
I.prototype.encode=function(a){if(this.cache&&a.length<=this.h)if(this.J){if(this.F.has(a))return this.F.get(a)}else this.J=setTimeout(ha,0,this);this.normalize&&(a="function"===typeof this.normalize?this.normalize(a):H?a.normalize("NFKD").replace(H,"").toLowerCase():a.toLowerCase());this.prepare&&(a=this.prepare(a));this.numeric&&3<a.length&&(a=a.replace(ea,"$1 $2").replace(fa,"$1 $2").replace(da,"$1 "));const c=!(this.dedupe||this.mapper||this.filter||this.matcher||this.stemmer||this.replacer);
let b=[],e=this.split||""===this.split?a.split(this.split):a;for(let f=0,g,h;f<e.length;f++){if(!(g=h=e[f]))continue;if(g.length<this.minlength)continue;if(c){b.push(g);continue}if(this.filter&&this.filter.has(g))continue;if(this.cache&&g.length<=this.D)if(this.J){var d=this.H.get(g);if(d||""===d){d&&b.push(d);continue}}else this.J=setTimeout(ha,0,this);let k;this.stemmer&&2<g.length&&(this.N||(this.N=new RegExp("(?!^)("+this.L+")$")),g=g.replace(this.N,l=>this.stemmer.get(l)),k=1);this.matcher&&
1<g.length&&(this.M||(this.M=new RegExp("("+this.K+")","g")),g=g.replace(this.M,l=>this.matcher.get(l)),k=1);g&&k&&(g.length<this.minlength||this.filter&&this.filter.has(g))&&(g="");if(g&&(this.mapper||this.dedupe&&1<g.length)){d="";for(let l=0,m="",q,t;l<g.length;l++)q=g.charAt(l),q===m&&this.dedupe||((t=this.mapper&&this.mapper.get(q))||""===t?t===m&&this.dedupe||!(m=t)||(d+=t):d+=m=q);g=d}if(g&&this.replacer)for(d=0;g&&d<this.replacer.length;d+=2)g=g.replace(this.replacer[d],this.replacer[d+1]);
this.cache&&h.length<=this.D&&(this.H.set(h,g),this.H.size>this.O&&(this.H.clear(),this.D=this.D/1.1|0));g&&b.push(g)}this.finalize&&(b=this.finalize(b)||b);this.cache&&a.length<=this.h&&(this.F.set(a,b),this.F.size>this.O&&(this.F.clear(),this.h=this.h/1.1|0));return b};function ha(a){a.J=null;a.F.clear();a.H.clear()};function ia(a,c,b){a=("object"===typeof a?""+a.query:a).toLowerCase();let e=this.cache.get(a);if(!e){e=this.search(a,c,b);if(e.then){const d=this;e.then(function(f){d.cache.set(a,f);return f})}this.cache.set(a,e)}return e}function J(a){this.limit=a&&!0!==a?a:1E3;this.cache=new Map;this.h=""}J.prototype.set=function(a,c){this.cache.set(this.h=a,c);this.cache.size>this.limit&&this.cache.delete(this.cache.keys().next().value)};
J.prototype.get=function(a){const c=this.cache.get(a);c&&this.h!==a&&(this.cache.delete(a),this.cache.set(this.h=a,c));return c};J.prototype.remove=function(a){for(const c of this.cache){const b=c[0];c[1].includes(a)&&this.cache.delete(b)}};J.prototype.clear=function(){this.cache.clear();this.h=""};const ja={normalize:function(a){return a.toLowerCase()},dedupe:!1};const K=new Map([["b","p"],["v","f"],["w","f"],["z","s"],["x","s"],["d","t"],["n","m"],["c","k"],["g","k"],["j","k"],["q","k"],["i","e"],["y","e"],["u","o"]]);const ka=new Map([["ai","ei"],["ae","a"],["oe","o"],["ue","u"],["sh","s"],["ch","c"],["th","t"],["ph","f"],["pf","f"]]),la=[/([^aeo])h([aeo$])/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2"];const ma={a:"",e:"",i:"",o:"",u:"",y:"",b:1,f:1,p:1,v:1,c:2,g:2,j:2,k:2,q:2,s:2,x:2,z:2,"\u00df":2,d:3,t:3,l:4,m:5,n:5,r:6};const na=/[\x00-\x7F]+/g;const oa=/[\x00-\x7F]+/g;const pa=/[\x00-\x7F]+/g;var qa={LatinExact:{normalize:!1,dedupe:!1},LatinDefault:ja,LatinSimple:{normalize:!0,dedupe:!0},LatinBalance:{normalize:!0,dedupe:!0,mapper:K},LatinAdvanced:{normalize:!0,dedupe:!0,mapper:K,replacer:la,matcher:ka},LatinExtra:{normalize:!0,dedupe:!0,mapper:K,replacer:la.concat([/(?!^)[aeoy]/g,""]),matcher:ka},LatinSoundex:{normalize:!0,dedupe:!1,include:{letter:!0},finalize:function(a){for(let b=0;b<a.length;b++){var c=a[b];let e=c.charAt(0),d=ma[e];for(let f=1,g;f<c.length&&(g=c.charAt(f),"h"===
g||"w"===g||!(g=ma[g])||g===d||(e+=g,d=g,4!==e.length));f++);a[b]=e}}},ArabicDefault:{rtl:!0,normalize:!1,dedupe:!0,prepare:function(a){return(""+a).replace(na," ")}},CjkDefault:{normalize:!1,dedupe:!0,split:"",prepare:function(a){return(""+a).replace(oa,"")}},CyrillicDefault:{normalize:!1,dedupe:!0,prepare:function(a){return(""+a).replace(pa," ")}}};function ra(a,c,b,e,d,f,g,h){(e=a(b?b+"."+e:e,JSON.stringify(g)))&&e.then?e.then(function(){c.export(a,c,b,d,f+1,h)}):c.export(a,c,b,d,f+1,h)};const sa={memory:{resolution:1},performance:{resolution:6,fastupdate:!0,context:{depth:1,resolution:3}},match:{tokenize:"forward"},score:{resolution:9,context:{depth:2,resolution:9}}};function ta(a){L.call(a,"add");L.call(a,"append");L.call(a,"search");L.call(a,"update");L.call(a,"remove")}function L(a){this[a+"Async"]=function(){var c=arguments;const b=c[c.length-1];let e;"function"===typeof b&&(e=b,delete c[c.length-1]);this.async=!0;c=this[a].apply(this,c);this.async=!1;e&&(c.then?c.then(e):e(c));return c}};y();M.prototype.add=function(a,c,b,e){if(c&&(a||0===a)){if(!e&&!b&&this.reg.has(a))return this.update(a,c);c=this.encoder.encode(c);if(e=c.length){const l=y(),m=y(),q=this.depth,t=this.resolution;for(let p=0;p<e;p++){let n=c[this.rtl?e-1-p:p];var d=n.length;if(d&&(q||!m[n])){var f=this.score?this.score(c,n,p,null,0):N(t,e,p),g="";switch(this.tokenize){case "full":if(2<d){for(f=0;f<d;f++)for(var h=d;h>f;h--){g=n.substring(f,h);var k=this.score?this.score(c,n,p,g,f):N(t,e,p,d,f);O(this,m,g,k,a,b)}break}case "reverse":if(1<
d){for(h=d-1;0<h;h--)g=n[h]+g,k=this.score?this.score(c,n,p,g,h):N(t,e,p,d,h),O(this,m,g,k,a,b);g=""}case "forward":if(1<d){for(h=0;h<d;h++)g+=n[h],O(this,m,g,f,a,b);break}default:if(O(this,m,n,f,a,b),q&&1<e&&p<e-1)for(d=y(),g=this.P,f=n,h=Math.min(q+1,e-p),d[f]=1,k=1;k<h;k++)if((n=c[this.rtl?e-1-p-k:p+k])&&!d[n]){d[n]=1;const w=this.score?this.score(c,f,p,n,k):N(g+(e/2>g?0:1),e,p,h-1,k-1),B=this.bidirectional&&n>f;O(this,l,B?f:n,w,a,b,B?n:f)}}}}this.fastupdate||this.reg.add(a)}}return this};
function O(a,c,b,e,d,f,g){let h=g?a.ctx:a.map,k;c[b]&&g&&(k=c[b])[g]||(g?(c=k||(c[b]=y()),c[g]=1,(k=h.get(g))?h=k:h.set(g,h=new Map)):c[b]=1,(k=h.get(b))?h=k:h.set(b,h=[]),h=h[e]||(h[e]=[]),f&&h.includes(d)||(h.push(d),a.fastupdate&&((c=a.reg.get(d))?c.push(h):a.reg.set(d,[h]))))}function N(a,c,b,e,d){return b&&1<a?c+(e||0)<=a?b+(d||0):(a-1)/(c+(e||0))*(b+(d||0))+1|0:0};function Q(a,c,b){if(1===a.length)return a=a[0],a=b||a.length>c?c?a.slice(b,b+c):a.slice(b):a;let e=[];for(let d=0,f,g;d<a.length;d++)if((f=a[d])&&(g=f.length)){if(b){if(b>=g){b-=g;continue}b<g&&(f=c?f.slice(b,b+c):f.slice(b),g=f.length,b=0)}if(e.length)g>c&&(f=f.slice(0,c),g=f.length),e.push(f);else{if(g>=c)return g>c&&(f=f.slice(0,c)),f;e=[f]}c-=g;if(!c)break}return e.length?e=1<e.length?[].concat.apply([],e):e[0]:e};function ua(a,c){const b=y(),e=y(),d=[];for(let f=0;f<a.length;f++)b[a[f]]=1;for(let f=0,g;f<c.length;f++){g=c[f];for(let h=0,k;h<g.length;h++)k=g[h],b[k]&&!e[k]&&(e[k]=1,d.push(k))}return d};M.prototype.search=function(a,c,b){b||(!c&&E(a)?(b=a,a=""):E(c)&&(b=c,c=0));var e=[],d=0;if(b){a=b.query||a;c=b.limit||c;d=b.offset||0;var f=b.context;var g=b.suggest}a=this.encoder.encode(a);b=a.length;c||(c=100);if(1===b)return R.call(this,a[0],"",c,d);f=this.depth&&!1!==f;if(2===b&&f&&!g)return R.call(this,a[0],a[1],c,d);var h=0,k=0;if(1<b){var l=y();const q=[];for(let t=0,p;t<b;t++)if((p=a[t])&&!l[p]){if(g||S(this,p))q.push(p),l[p]=1;else return e;const n=p.length;h=Math.max(h,n);k=k?Math.min(k,
n):n}a=q;b=a.length}if(!b)return e;l=0;if(1===b)return R.call(this,a[0],"",c,d);if(2===b&&f&&!g)return R.call(this,a[0],a[1],c,d);if(1<b)if(f){var m=a[0];l=1}else 9<h&&3<h/k&&a.sort(aa);for(let q,t;l<b;l++){t=a[l];m?(q=S(this,t,m),q=va(q,e,g,this.P,c,d,2===b),g&&!1===q&&e.length||(m=t)):(q=S(this,t),q=va(q,e,g,this.resolution,c,d,1===b));if(q)return q;if(g&&l===b-1){f=e.length;if(!f){if(m){m="";l=-1;continue}return e}if(1===f)return Q(e[0],c,d)}}a:{a=e;e=this.resolution;m=a.length;b=[];f=y();for(let q=
0,t,p,n,w;q<e;q++)for(k=0;k<m;k++)if(n=a[k],q<n.length&&(t=n[q]))for(l=0;l<t.length;l++)p=t[l],(h=f[p])?f[p]++:(h=0,f[p]=1),w=b[h]||(b[h]=[]),w.push(p);if(a=b.length)if(g){if(1<b.length){g=b;a=[];e=y();f=g.length;for(k=0;k<f;k++)for(m=g[k],h=m.length,l=0;l<h;l++)if(b=m[l],!e[b])if(e[b]=1,d)d--;else if(a.push(b),a.length===c)break;c=a}else c=b[0];b=c}else{if(a<m){e=[];break a}b=b[a-1];if(b.length>c||d)b=b.slice(d,c+d)}e=b}return e};function R(a,c,b,e){return(a=S(this,a,c))&&a.length?Q(a,b,e):[]}
function va(a,c,b,e,d,f,g){let h=[];if(a){e=Math.min(a.length,e);for(let k=0,l=0,m;k<e;k++)if(m=a[k])if(f&&m&&g&&(m.length<=f?(f-=m.length,m=null):(m=m.slice(f),f=0)),m&&(h[k]=m,g&&(l+=m.length,l>=d)))break;if(h.length){if(g)return Q(h,d,0);c.push(h);return}}return!b&&h}function S(a,c,b){let e;b&&(e=a.bidirectional&&c>b);a=b?(a=a.ctx.get(e?c:b))&&a.get(e?b:c):a.map.get(c);return a};M.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 e=0,d;e<b.length;e++){if(d=b[e])if(2>d.length)d.pop();else{const f=d.indexOf(a);f===b.length-1?d.pop():d.splice(f,1)}}else T(this.map,a),this.depth&&T(this.ctx,a);c||this.reg.delete(a)}this.cache&&this.cache.remove(a);return this};
function T(a,c){let b=0;if(a.constructor===Array)for(let e=0,d,f;e<a.length;e++){if((d=a[e])&&d.length)if(f=d.indexOf(c),0<=f){1<d.length?(d.splice(f,1),b++):delete a[e];break}else b++}else for(let e of a){const d=e[0],f=T(e[1],c);f?b+=f:a.delete(d)}return b};function M(a,c){if(!this)return new M(a);if(a){var b=z(a)?a:a.preset;b&&(a=Object.assign({},sa[b],a))}else a={};b=a.context||{};const e=a.encode||a.encoder||ja;this.encoder=e.encode?e:"object"===typeof e?new I(e):{encode:e};let d;this.resolution=a.resolution||9;this.tokenize=d=a.tokenize||"strict";this.depth="strict"===d&&b.depth||0;this.bidirectional=!1!==b.bidirectional;this.fastupdate=!!a.fastupdate;this.score=a.score||null;d=!1;this.map=new Map;this.ctx=new Map;this.reg=c||(this.fastupdate?new Map:
new Set);this.P=b.resolution||1;this.rtl=e.rtl||a.rtl||!1;this.cache=(d=a.cache||null)&&new J(d)}u=M.prototype;u.clear=function(){this.map.clear();this.ctx.clear();this.reg.clear();this.cache&&this.cache.clear();return this};u.append=function(a,c){return this.add(a,c,!0)};u.contain=function(a){return this.reg.has(a)};u.update=function(a,c){if(this.async){const b=this,e=this.remove(a);return e.then?e.then(()=>b.add(a,c)):this.add(a,c)}return this.remove(a).add(a,c)};
function U(a){let c=0;if(a.constructor===Array)for(let b=0,e;b<a.length;b++)(e=a[b])&&(c+=e.length);else for(const b of a){const e=b[0],d=U(b[1]);d?c+=d:a.delete(e)}return c}u.cleanup=function(){if(!this.fastupdate)return this;U(this.map);this.depth&&U(this.ctx);return this};u.searchCache=ia;
u.export=function(a,c,b,e,d,f){let g=!0;"undefined"===typeof f&&(g=new Promise(l=>{f=l}));let h,k;switch(d||(d=0)){case 0:h="reg";if(this.fastupdate){k=y();for(let l of this.reg.keys())k[l]=1}else k=this.reg;break;case 1:h="cfg";k={doc:0,opt:this.h?1:0};break;case 2:h="map";k=this.map;break;case 3:h="ctx";k=this.ctx;break;default:"undefined"===typeof b&&f&&f();return}ra(a,c||this,b,h,e,d,k,f);return g};
u.import=function(a,c){if(c)switch(z(c)&&(c=JSON.parse(c)),a){case "cfg":this.h=!!c.opt;break;case "reg":this.fastupdate=!1;this.reg=c;break;case "map":this.map=c;break;case "ctx":this.ctx=c}};
u.serialize=function(a=!0){if(!this.reg.size)return"";let c="",b="";for(var e of this.reg.keys())b||(b=typeof e),c+=(c?",":"")+("string"===b?'"'+e+'"':e);c="index.reg=new Set(["+c+"]);";e="";for(var d of this.map.entries()){var f=d[0],g=d[1],h="";for(let m=0,q;m<g.length;m++){q=g[m]||[""];var k="";for(var l=0;l<q.length;l++)k+=(k?",":"")+("string"===b?'"'+q[l]+'"':q[l]);k="["+k+"]";h+=(h?",":"")+k}h='["'+f+'",['+h+"]]";e+=(e?",":"")+h}e="index.map=new Map(["+e+"]);";d="";for(const m of this.ctx.entries()){f=
m[0];g=m[1];for(const q of g.entries()){g=q[0];h=q[1];k="";for(let t=0,p;t<h.length;t++){p=h[t]||[""];l="";for(let n=0;n<p.length;n++)l+=(l?",":"")+("string"===b?'"'+p[n]+'"':p[n]);l="["+l+"]";k+=(k?",":"")+l}k='new Map([["'+g+'",['+k+"]]])";k='["'+f+'",'+k+"]";d+=(d?",":"")+k}}d="index.ctx=new Map(["+d+"]);";return a?"function inject(index){"+c+e+d+"}":c+e+d};ta(M.prototype);V.prototype.add=function(a,c,b){E(a)&&(c=a,a=F(c,this.key));if(c&&(a||0===a)){if(!b&&this.reg.has(a))return this.update(a,c);for(let h=0,k;h<this.field.length;h++){k=this.C[h];var e=this.index.get(this.field[h]);if("function"===typeof k){var d=k(c);d&&e.add(a,d,!1,!0)}else if(d=k.G,!d||d(c))k.constructor===String?k=[""+k]:z(k)&&(k=[k]),W(c,k,this.I,0,e,a,k[0],b)}if(this.tag)for(e=0;e<this.B.length;e++){var f=this.B[e];d=this.tag.get(this.R[e]);let h=y();if("function"===typeof f){if(f=f(c),!f)continue}else{var g=
f.G;if(g&&!g(c))continue;f.constructor===String&&(f=""+f);f=F(c,f)}if(d&&f){z(f)&&(f=[f]);for(let k=0,l,m;k<f.length;k++)l=f[k],h[l]||(h[l]=1,(g=d.get(l))?m=g:d.set(l,m=[]),b&&m.includes(a)||(m.push(a),this.fastupdate&&((g=this.reg.get(a))?g.push(m):this.reg.set(a,[m]))))}}if(this.store&&(!b||!this.store.has(a))){let h;if(this.A){h=y();for(let k=0,l;k<this.A.length;k++){l=this.A[k];if((b=l.G)&&!b(c))continue;let m;if("function"===typeof l){m=l(c);if(!m)continue;l=[l.S]}else if(z(l)||l.constructor===
String){h[l]=c[l];continue}X(c,h,l,0,l[0],m)}}this.store.set(a,h||c)}}return this};function X(a,c,b,e,d,f){a=a[d];if(e===b.length-1)c[d]=f||a;else if(a)if(a.constructor===Array)for(c=c[d]=Array(a.length),d=0;d<a.length;d++)X(a,c,b,e,d);else c=c[d]||(c[d]=y()),d=b[++e],X(a,c,b,e,d)}
function W(a,c,b,e,d,f,g,h){if(a=a[g])if(e===c.length-1){if(a.constructor===Array){if(b[e]){for(c=0;c<a.length;c++)d.add(f,a[c],!0,!0);return}a=a.join(" ")}d.add(f,a,h,!0)}else if(a.constructor===Array)for(g=0;g<a.length;g++)W(a,c,b,e,d,f,g,h);else g=c[++e],W(a,c,b,e,d,f,g,h)};V.prototype.search=function(a,c,b,e){b||(!c&&E(a)?(b=a,a=""):E(c)&&(b=c,c=0));let d=[];var f=[];let g,h,k,l,m;let q=0;if(b){b.constructor===Array&&(b={index:b});a=b.query||a;var t=b.pluck;h=b.merge;l=t||b.field||b.index;m=this.tag&&b.tag;g=this.store&&b.enrich;k=b.suggest;c=b.limit||c;var p=b.offset||0;c||(c=100);if(m){m.constructor!==Array&&(m=[m]);var n=[];for(let v=0,r;v<m.length;v++)if(r=m[v],r.field&&r.tag){var w=r.tag;if(w.constructor===Array)for(var B=0;B<w.length;B++)n.push(r.field,w[B]);
else n.push(r.field,w)}else{w=Object.keys(r);for(let C=0,D,A;C<w.length;C++)if(D=w[C],A=r[D],A.constructor===Array)for(B=0;B<A.length;B++)n.push(D,A[B]);else n.push(D,A)}m=n;if(!a){e=[];if(n.length)for(f=0;f<n.length;f+=2)t=wa.call(this,n[f],n[f+1],c,p,g),d.push({field:n[f],tag:n[f+1],result:t});return e.length?Promise.all(e).then(function(v){for(let r=0;r<v.length;r++)d[r].result=v[r];return d}):d}}z(l)&&(l=[l])}l||(l=this.field);p=!e&&(this.worker||this.async)&&[];for(let v=0,r,C,D;v<l.length;v++){C=
l[v];let A;z(C)||(A=C,C=A.field,a=A.query||a,c=A.limit||c,k=A.suggest||k);if(e)r=e[v];else if(n=A||b,w=this.index.get(C),m&&(n.enrich=!1),p){p[v]=w.searchAsync(a,c,n);n&&g&&(n.enrich=g);continue}else r=w.search(a,c,n),n&&g&&(n.enrich=g);D=r&&r.length;if(m&&D){n=[];w=0;for(let P=0,G,Aa;P<m.length;P+=2){G=this.tag.get(m[P]);if(!G)if(k)continue;else return d;if(Aa=(G=G&&G.get(m[P+1]))&&G.length)w++,n.push(G);else if(!k)return d}if(w){r=ua(r,n);D=r.length;if(!D&&!k)return d;w--}}if(D)f[q]=C,d.push(r),
q++;else if(1===l.length)return d}if(p){const v=this;return Promise.all(p).then(function(r){return r.length?v.search(a,c,b,r):r})}if(!q)return d;if(t&&(!g||!this.store))return d[0];p=[];for(let v=0,r;v<f.length;v++){r=d[v];g&&r.length&&!r[0].doc&&r.length&&(r=xa.call(this,r));if(t)return r;d[v]={field:f[v],result:r}}return h?ya(d,c):d};
function ya(a,c){const b=[],e=y();for(let d=0,f,g;d<a.length;d++){f=a[d];g=f.result;for(let h=0,k,l,m;h<g.length;h++)if(l=g[h],k=l.id,m=e[k])m.push(f.field);else{if(b.length===c)return b;l.field=e[k]=[f.field];b.push(l)}}return b}function wa(a,c,b,e,d){a=this.tag.get(a);if(!a)return[];if((c=(a=a&&a.get(c))&&a.length-e)&&0<c){if(c>b||e)a=a.slice(e,e+b);d&&(a=xa.call(this,a));return a}}
function xa(a){const c=Array(a.length);for(let b=0,e;b<a.length;b++)e=a[b],c[b]={id:e,doc:this.store.get(e)};return c};function V(a){if(!this)return new V(a);const c=a.document||a.doc||a;var b;this.F=[];this.field=[];this.K=[];this.key=(b=c.key||c.id)&&Y(b,this.K)||"id";this.h=(this.fastupdate=!!a.fastupdate)?new Map:new Set;this.B=(b=c.store||null)&&!0!==b&&[];this.store=b&&new Map;this.cache=(b=a.cache||null)&&new J(b);this.async=a.cache=!1;b=new Map;let e=c.index||c.field||c;z(e)&&(e=[e]);for(let d=0,f,g;d<e.length;d++)f=e[d],z(f)||(g=f,f=f.field),g=E(g)?Object.assign({},a,g):a,b.set(f,new M(g,this.h)),g.custom?
this.F[d]=g.custom:(this.F[d]=Y(f,this.K),g.filter&&("string"===typeof this.F[d]&&(this.F[d]=new String(this.F[d])),this.F[d].I=g.filter)),this.field[d]=f;if(this.B){a=c.store;z(a)&&(a=[a]);for(let d=0,f,g;d<a.length;d++)f=a[d],g=f.field||f,f.custom?(this.B[d]=f.custom,f.custom.U=g):(this.B[d]=Y(g,this.K),f.filter&&("string"===typeof this.B[d]&&(this.B[d]=new String(this.B[d])),this.B[d].I=f.filter))}this.index=b;this.tag=null;if(b=c.tag)if("string"===typeof b&&(b=[b]),b.length){this.tag=new Map;
this.C=[];this.T=[];for(let d=0,f,g;d<b.length;d++){f=b[d];g=f.field||f;if(!g)throw Error("The tag field from the document descriptor is undefined.");f.custom?this.C[d]=f.custom:(this.C[d]=Y(g,this.K),f.filter&&("string"===typeof this.C[d]&&(this.C[d]=new String(this.C[d])),this.C[d].I=f.filter));this.T[d]=g;this.tag.set(g,new Map)}}}
function xa(a){const c=Array(a.length);for(let b=0,e;b<a.length;b++)e=a[b],c[b]={id:e,doc:this.store.get(e)};return c};function V(a){if(!this)return new V(a);const c=a.document||a.doc||a;var b;this.C=[];this.field=[];this.I=[];this.key=(b=c.key||c.id)&&Y(b,this.I)||"id";this.reg=(this.fastupdate=!!a.fastupdate)?new Map:new Set;this.A=(b=c.store||null)&&!0!==b&&[];this.store=b&&new Map;this.cache=(b=a.cache||null)&&new J(b);this.async=a.cache=!1;b=new Map;let e=c.index||c.field||c;z(e)&&(e=[e]);for(let d=0,f,g;d<e.length;d++)f=e[d],z(f)||(g=f,f=f.field),g=E(g)?Object.assign({},a,g):a,b.set(f,new M(g,this.reg)),g.custom?
this.C[d]=g.custom:(this.C[d]=Y(f,this.I),g.filter&&("string"===typeof this.C[d]&&(this.C[d]=new String(this.C[d])),this.C[d].G=g.filter)),this.field[d]=f;if(this.A){a=c.store;z(a)&&(a=[a]);for(let d=0,f,g;d<a.length;d++)f=a[d],g=f.field||f,f.custom?(this.A[d]=f.custom,f.custom.S=g):(this.A[d]=Y(g,this.I),f.filter&&("string"===typeof this.A[d]&&(this.A[d]=new String(this.A[d])),this.A[d].G=f.filter))}this.index=b;this.tag=null;if(b=c.tag)if("string"===typeof b&&(b=[b]),b.length){this.tag=new Map;
this.B=[];this.R=[];for(let d=0,f,g;d<b.length;d++){f=b[d];g=f.field||f;if(!g)throw Error("The tag field from the document descriptor is undefined.");f.custom?this.B[d]=f.custom:(this.B[d]=Y(g,this.I),f.filter&&("string"===typeof this.B[d]&&(this.B[d]=new String(this.B[d])),this.B[d].G=f.filter));this.R[d]=g;this.tag.set(g,new Map)}}}
function Y(a,c){const b=a.split(":");let e=0;for(let d=0;d<b.length;d++)a=b[d],"]"===a[a.length-1]&&(a=a.substring(0,a.length-2))&&(c[e]=!0),a&&(b[e++]=a);e<b.length&&(b.length=e);return 1<e?b:b[0]}u=V.prototype;u.append=function(a,c){return this.add(a,c,!0)};u.update=function(a,c){return this.remove(a).add(a,c)};
u.remove=function(a){E(a)&&(a=F(a,this.key));for(var c of this.index.values())c.remove(a,!0);if(this.h.has(a)){if(this.tag&&!this.fastupdate)for(let b of this.tag.values())for(let e of b){c=e[0];const d=e[1],f=d.indexOf(a);-1<f&&(1<d.length?d.splice(f,1):b.delete(c))}this.store&&this.store.delete(a);this.h.delete(a)}this.cache&&this.cache.remove(a);return this};
u.clear=function(){for(const a of this.index.values())a.clear();if(this.tag)for(const a of this.tag.values())a.clear();this.store&&this.store.clear();return this};u.contain=function(a){return this.h.has(a)};u.cleanup=function(){for(const a of this.index.values())a.cleanup();return this};u.get=function(a){return this.store.get(a)};u.set=function(a,c){this.store.set(a,c);return this};u.searchCache=ia;
u.export=function(a,c,b,e,d,f){let g;"undefined"===typeof f&&(g=new Promise(k=>{f=k}));d||(d=0);e||(e=0);if(e<this.field.length){b=this.field[e];var h=this.index[b];c=this;h.export(a,c,d?b:"",e,d++,f)||(e++,c.export(a,c,b,e,1,f))}else{switch(d){case 1:c="tag";h=this.G;b=null;break;case 2:c="store";h=this.store;b=null;break;default:f();return}ra(a,this,b,c,e,d,h,f)}return g};
u.import=function(a,c){if(c)switch(z(c)&&(c=JSON.parse(c)),a){case "tag":this.G=c;break;case "reg":this.fastupdate=!1;this.h=c;for(let e=0,d;e<this.field.length;e++)d=this.index[this.field[e]],d.h=c,d.fastupdate=!1;break;case "store":this.store=c;break;default:a=a.split(".");const b=a[0];a=a[1];b&&a&&this.index[b].import(a,c)}};ta(V.prototype);const za={Index:M,Charset:qa,Encoder:I,Document:V,Worker:null,Resolver:null,IndexedDB:null,Language:{}},Z=self;let Ba;(Ba=Z.define)&&Ba.amd?Ba([],function(){return za}):"object"===typeof Z.exports?Z.exports=za:Z.FlexSearch=za;}(this));
u.remove=function(a){E(a)&&(a=F(a,this.key));for(var c of this.index.values())c.remove(a,!0);if(this.reg.has(a)){if(this.tag&&!this.fastupdate)for(let b of this.tag.values())for(let e of b){c=e[0];const d=e[1],f=d.indexOf(a);-1<f&&(1<d.length?d.splice(f,1):b.delete(c))}this.store&&this.store.delete(a);this.reg.delete(a)}this.cache&&this.cache.remove(a);return this};
u.clear=function(){for(const a of this.index.values())a.clear();if(this.tag)for(const a of this.tag.values())a.clear();this.store&&this.store.clear();return this};u.contain=function(a){return this.reg.has(a)};u.cleanup=function(){for(const a of this.index.values())a.cleanup();return this};u.get=function(a){return this.store.get(a)};u.set=function(a,c){this.store.set(a,c);return this};u.searchCache=ia;
u.export=function(a,c,b,e,d,f){let g;"undefined"===typeof f&&(g=new Promise(k=>{f=k}));d||(d=0);e||(e=0);if(e<this.field.length){b=this.field[e];var h=this.index[b];c=this;h.export(a,c,d?b:"",e,d++,f)||(e++,c.export(a,c,b,e,1,f))}else{switch(d){case 1:c="tag";h=this.D;b=null;break;case 2:c="store";h=this.store;b=null;break;default:f();return}ra(a,this,b,c,e,d,h,f)}return g};
u.import=function(a,c){if(c)switch(z(c)&&(c=JSON.parse(c)),a){case "tag":this.D=c;break;case "reg":this.fastupdate=!1;this.reg=c;for(let e=0,d;e<this.field.length;e++)d=this.index[this.field[e]],d.reg=c,d.fastupdate=!1;break;case "store":this.store=c;break;default:a=a.split(".");const b=a[0];a=a[1];b&&a&&this.index[b].import(a,c)}};ta(V.prototype);const za={Index:M,Charset:qa,Encoder:I,Document:V,Worker:null,Resolver:null,IndexedDB:null,Language:{}},Z=self;let Ba;(Ba=Z.define)&&Ba.amd?Ba([],function(){return za}):"object"===typeof Z.exports?Z.exports=za:Z.FlexSearch=za;}(this));

File diff suppressed because it is too large Load Diff

View File

@@ -5,7 +5,7 @@
* Hosted by Nextapps GmbH
* https://github.com/nextapps-de/flexsearch
*/
var v;function x(a,c,b){const d=typeof b,e=typeof a;if("undefined"!==d){if("undefined"!==e){if(b){if("function"===e&&d===e)return function(h){return a(b(h))};c=a.constructor;if(c===b.constructor){if(c===Array)return b.concat(a);if(c===Map){var f=new Map(b);for(var g of a)f.set(g[0],g[1]);return f}if(c===Set){g=new Set(b);for(f of a.values())g.add(f);return g}}}return a}return b}return"undefined"===e?c:a}function y(){return Object.create(null)}function aa(a,c){return c.length-a.length}
var u;function x(a,c,b){const d=typeof b,e=typeof a;if("undefined"!==d){if("undefined"!==e){if(b){if("function"===e&&d===e)return function(h){return a(b(h))};c=a.constructor;if(c===b.constructor){if(c===Array)return b.concat(a);if(c===Map){var f=new Map(b);for(var g of a)f.set(g[0],g[1]);return f}if(c===Set){g=new Set(b);for(f of a.values())g.add(f);return g}}}return a}return b}return"undefined"===e?c:a}function y(){return Object.create(null)}function aa(a,c){return c.length-a.length}
function A(a){return"string"===typeof a}function E(a){return"object"===typeof a}function F(a,c){if(A(c))a=a[c];else for(let b=0;a&&b<c.length;b++)a=a[c[b]];return a};var ba=[["\u00aa","a"],["\u00b2","2"],["\u00b3","3"],["\u00b9","1"],["\u00ba","o"],["\u00bc","1\u20444"],["\u00bd","1\u20442"],["\u00be","3\u20444"],["\u00e0","a"],["\u00e1","a"],["\u00e2","a"],["\u00e3","a"],["\u00e4","a"],["\u00e5","a"],["\u00e7","c"],["\u00e8","e"],["\u00e9","e"],["\u00ea","e"],["\u00eb","e"],["\u00ec","i"],["\u00ed","i"],["\u00ee","i"],["\u00ef","i"],["\u00f1","n"],["\u00f2","o"],["\u00f3","o"],["\u00f4","o"],["\u00f5","o"],["\u00f6","o"],["\u00f9","u"],["\u00fa","u"],["\u00fb",
"u"],["\u00fc","u"],["\u00fd","y"],["\u00ff","y"],["\u0101","a"],["\u0103","a"],["\u0105","a"],["\u0107","c"],["\u0109","c"],["\u010b","c"],["\u010d","c"],["\u010f","d"],["\u0113","e"],["\u0115","e"],["\u0117","e"],["\u0119","e"],["\u011b","e"],["\u011d","g"],["\u011f","g"],["\u0121","g"],["\u0123","g"],["\u0125","h"],["\u0129","i"],["\u012b","i"],["\u012d","i"],["\u012f","i"],["\u0133","ij"],["\u0135","j"],["\u0137","k"],["\u013a","l"],["\u013c","l"],["\u013e","l"],["\u0140","l"],["\u0144","n"],
["\u0146","n"],["\u0148","n"],["\u0149","n"],["\u014d","o"],["\u014f","o"],["\u0151","o"],["\u0155","r"],["\u0157","r"],["\u0159","r"],["\u015b","s"],["\u015d","s"],["\u015f","s"],["\u0161","s"],["\u0163","t"],["\u0165","t"],["\u0169","u"],["\u016b","u"],["\u016d","u"],["\u016f","u"],["\u0171","u"],["\u0173","u"],["\u0175","w"],["\u0177","y"],["\u017a","z"],["\u017c","z"],["\u017e","z"],["\u017f","s"],["\u01a1","o"],["\u01b0","u"],["\u01c6","dz"],["\u01c9","lj"],["\u01cc","nj"],["\u01ce","a"],["\u01d0",
@@ -15,31 +15,33 @@ function A(a){return"string"===typeof a}function E(a){return"object"===typeof a}
["\u0477","\u0475"],["\u04c2","\u0436"],["\u04d1","\u0430"],["\u04d3","\u0430"],["\u04d7","\u0435"],["\u04db","\u04d9"],["\u04dd","\u0436"],["\u04df","\u0437"],["\u04e3","\u0438"],["\u04e5","\u0438"],["\u04e7","\u043e"],["\u04eb","\u04e9"],["\u04ed","\u044d"],["\u04ef","\u0443"],["\u04f1","\u0443"],["\u04f3","\u0443"],["\u04f5","\u0447"]];const ca=/[^\p{L}\p{N}]+/u,da=/(\d{3})/g,ea=/(\D)(\d{3})/g,fa=/(\d{3})(\D)/g,H="".normalize&&/[\u0300-\u036f]/g;function I(a){if(!this)return new I(...arguments);for(let c=0;c<arguments.length;c++)this.assign(arguments[c])}
I.prototype.assign=function(a){this.normalize=x(a.normalize,!0,this.normalize);let c=a.include,b=c||a.exclude||a.split;if("object"===typeof b){let d=!c,e="";a.include||(e+="\\p{Z}");b.letter&&(e+="\\p{L}");b.number&&(e+="\\p{N}",d=!!c);b.symbol&&(e+="\\p{S}");b.punctuation&&(e+="\\p{P}");b.control&&(e+="\\p{C}");if(b=b.char)e+="object"===typeof b?b.join(""):b;this.split=new RegExp("["+(c?"^":"")+e+"]+","u");this.numeric=d}else this.split=x(b,ca,this.split),this.numeric=x(this.numeric,!0);this.prepare=
x(a.prepare,null,this.prepare);this.finalize=x(a.finalize,null,this.finalize);H||(this.mapper=new Map(ba));this.rtl=a.rtl||!1;this.dedupe=x(a.dedupe,!0,this.dedupe);this.filter=x((b=a.filter)&&new Set(b),null,this.filter);this.matcher=x((b=a.matcher)&&new Map(b),null,this.matcher);this.mapper=x((b=a.mapper)&&new Map(b),null,this.mapper);this.stemmer=x((b=a.stemmer)&&new Map(b),null,this.stemmer);this.replacer=x(a.replacer,null,this.replacer);this.minlength=x(a.minlength,1,this.minlength);this.maxlength=
x(a.maxlength,0,this.maxlength);this.F="";this.H=null;this.D="";this.I=null;if(this.matcher)for(const d of this.matcher.keys())this.F+=(this.F?"|":"")+d;if(this.stemmer)for(const d of this.stemmer.keys())this.D+=(this.D?"|":"")+d;return this};
x(a.maxlength,0,this.maxlength);this.C="";this.F=null;this.B="";this.G=null;if(this.matcher)for(const d of this.matcher.keys())this.C+=(this.C?"|":"")+d;if(this.stemmer)for(const d of this.stemmer.keys())this.B+=(this.B?"|":"")+d;return this};
I.prototype.encode=function(a){this.normalize&&(a="function"===typeof this.normalize?this.normalize(a):H?a.normalize("NFKD").replace(H,"").toLowerCase():a.toLowerCase());this.prepare&&(a=this.prepare(a));this.numeric&&3<a.length&&(a=a.replace(ea,"$1 $2").replace(fa,"$1 $2").replace(da,"$1 "));const c=!(this.dedupe||this.mapper||this.filter||this.matcher||this.stemmer||this.replacer);let b=[];a=this.split||""===this.split?a.split(this.split):a;for(let e=0,f;e<a.length;e++){if(!(f=a[e]))continue;if(f.length<
this.minlength)continue;if(c){b.push(f);continue}if(this.filter&&this.filter.has(f))continue;let g;this.stemmer&&2<f.length&&(this.I||(this.I=new RegExp("(?!^)("+this.D+")$")),f=f.replace(this.I,h=>this.stemmer.get(h)),g=1);this.matcher&&1<f.length&&(this.H||(this.H=new RegExp("("+this.F+")","g")),f=f.replace(this.H,h=>this.matcher.get(h)),g=1);f&&g&&(f.length<this.minlength||this.filter&&this.filter.has(f))&&(f="");if(f&&(this.mapper||this.dedupe&&1<f.length)){var d="";for(let h=0,k="",n,l;h<f.length;h++)n=
f.charAt(h),n===k&&this.dedupe||((l=this.mapper&&this.mapper.get(n))||""===l?l===k&&this.dedupe||!(k=l)||(d+=l):d+=k=n);f=d}if(f&&this.replacer)for(d=0;f&&d<this.replacer.length;d+=2)f=f.replace(this.replacer[d],this.replacer[d+1]);f&&b.push(f)}this.finalize&&(b=this.finalize(b)||b);return b};const J={normalize:function(a){return a.toLowerCase()},dedupe:!1};const K=new Map([["b","p"],["v","f"],["w","f"],["z","s"],["x","s"],["d","t"],["n","m"],["c","k"],["g","k"],["j","k"],["q","k"],["i","e"],["y","e"],["u","o"]]);const L=new Map([["ai","ei"],["ae","a"],["oe","o"],["ue","u"],["sh","s"],["ch","c"],["th","t"],["ph","f"],["pf","f"]]),ha=[/([^aeo])h([aeo$])/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2"];const ia={a:"",e:"",i:"",o:"",u:"",y:"",b:1,f:1,p:1,v:1,c:2,g:2,j:2,k:2,q:2,s:2,x:2,z:2,"\u00df":2,d:3,t:3,l:4,m:5,n:5,r:6};const ja=/[\x00-\x7F]+/g;const ka=/[\x00-\x7F]+/g;const la=/[\x00-\x7F]+/g;var ma={LatinExact:{normalize:!1,dedupe:!1},LatinDefault:J,LatinSimple:{normalize:!0,dedupe:!0},LatinBalance:{normalize:!0,dedupe:!0,mapper:K},LatinAdvanced:{normalize:!0,dedupe:!0,mapper:K,replacer:ha,matcher:L},LatinExtra:{normalize:!0,dedupe:!0,mapper:K,replacer:ha.concat([/(?!^)[aeoy]/g,""]),matcher:L},LatinSoundex:{normalize:!0,dedupe:!1,include:{letter:!0},finalize:function(a){for(let b=0;b<a.length;b++){var c=a[b];let d=c.charAt(0),e=ia[d];for(let f=1,g;f<c.length&&(g=c.charAt(f),"h"===g||
"w"===g||!(g=ia[g])||g===e||(d+=g,e=g,4!==d.length));f++);a[b]=d}}},ArabicDefault:{rtl:!0,normalize:!1,dedupe:!0,prepare:function(a){return(""+a).replace(ja," ")}},CjkDefault:{normalize:!1,dedupe:!0,split:"",prepare:function(a){return(""+a).replace(ka,"")}},CyrillicDefault:{normalize:!1,dedupe:!0,prepare:function(a){return(""+a).replace(la," ")}}};function na(a,c,b,d,e,f,g,h){(d=a(b?b+"."+d:d,JSON.stringify(g)))&&d.then?d.then(function(){c.export(a,c,b,e,f+1,h)}):c.export(a,c,b,e,f+1,h)};const oa={memory:{resolution:1},performance:{resolution:6,fastupdate:!0,context:{depth:1,resolution:3}},match:{tokenize:"forward"},score:{resolution:9,context:{depth:2,resolution:9}}};function pa(a){M.call(a,"add");M.call(a,"append");M.call(a,"search");M.call(a,"update");M.call(a,"remove")}function M(a){this[a+"Async"]=function(){var c=arguments;const b=c[c.length-1];let d;"function"===typeof b&&(d=b,delete c[c.length-1]);this.async=!0;c=this[a].apply(this,c);this.async=!1;d&&(c.then?c.then(d):d(c));return c}};y();N.prototype.add=function(a,c,b,d){if(c&&(a||0===a)){if(!d&&!b&&this.h.has(a))return this.update(a,c);c=this.encoder.encode(c);if(d=c.length){const n=y(),l=y(),r=this.depth,t=this.resolution;for(let p=0;p<d;p++){let m=c[this.rtl?d-1-p:p];var e=m.length;if(e&&(r||!l[m])){var f=this.score?this.score(c,m,p,null,0):P(t,d,p),g="";switch(this.tokenize){case "full":if(2<e){for(f=0;f<e;f++)for(var h=e;h>f;h--){g=m.substring(f,h);var k=this.score?this.score(c,m,p,g,f):P(t,d,p,e,f);Q(this,l,g,k,a,b)}break}case "reverse":if(1<
e){for(h=e-1;0<h;h--)g=m[h]+g,k=this.score?this.score(c,m,p,g,h):P(t,d,p,e,h),Q(this,l,g,k,a,b);g=""}case "forward":if(1<e){for(h=0;h<e;h++)g+=m[h],Q(this,l,g,f,a,b);break}default:if(Q(this,l,m,f,a,b),r&&1<d&&p<d-1)for(e=y(),g=this.K,f=m,h=Math.min(r+1,d-p),e[f]=1,k=1;k<h;k++)if((m=c[this.rtl?d-1-p-k:p+k])&&!e[m]){e[m]=1;const w=this.score?this.score(c,f,p,m,k):P(g+(d/2>g?0:1),d,p,h-1,k-1),B=this.bidirectional&&m>f;Q(this,n,B?f:m,w,a,b,B?m:f)}}}}this.fastupdate||this.h.add(a)}}return this};
function Q(a,c,b,d,e,f,g){let h=g?a.B:a.map,k;c[b]&&g&&(k=c[b])[g]||(g?(c=k||(c[b]=y()),c[g]=1,(k=h.get(g))?h=k:h.set(g,h=new Map)):c[b]=1,(k=h.get(b))?h=k:h.set(b,h=[]),h=h[d]||(h[d]=[]),f&&h.includes(e)||(h.push(e),a.fastupdate&&((c=a.h.get(e))?c.push(h):a.h.set(e,[h]))))}function P(a,c,b,d,e){return b&&1<a?c+(d||0)<=a?b+(e||0):(a-1)/(c+(d||0))*(b+(e||0))+1|0:0};function R(a,c,b){if(1===a.length)return a=a[0],a=b||a.length>c?c?a.slice(b,b+c):a.slice(b):a;let d=[];for(let e=0,f,g;e<a.length;e++)if((f=a[e])&&(g=f.length)){if(b){if(b>=g){b-=g;continue}b<g&&(f=c?f.slice(b,b+c):f.slice(b),g=f.length,b=0)}if(d.length)g>c&&(f=f.slice(0,c),g=f.length),d.push(f);else{if(g>=c)return g>c&&(f=f.slice(0,c)),f;d=[f]}c-=g;if(!c)break}return d.length?d=1<d.length?[].concat.apply([],d):d[0]:d};function qa(a,c){const b=y(),d=y(),e=[];for(let f=0;f<a.length;f++)b[a[f]]=1;for(let f=0,g;f<c.length;f++){g=c[f];for(let h=0,k;h<g.length;h++)k=g[h],b[k]&&!d[k]&&(d[k]=1,e.push(k))}return e};N.prototype.search=function(a,c,b){b||(!c&&E(a)?(b=a,a=""):E(c)&&(b=c,c=0));var d=[],e=0;if(b){a=b.query||a;c=b.limit||c;e=b.offset||0;var f=b.context;var g=b.suggest}a=this.encoder.encode(a);b=a.length;c||(c=100);if(1===b)return S.call(this,a[0],"",c,e);f=this.depth&&!1!==f;if(2===b&&f&&!g)return S.call(this,a[0],a[1],c,e);var h=0,k=0;if(1<b){var n=y();const r=[];for(let t=0,p;t<b;t++)if((p=a[t])&&!n[p]){if(g||T(this,p))r.push(p),n[p]=1;else return d;const m=p.length;h=Math.max(h,m);k=k?Math.min(k,
m):m}a=r;b=a.length}if(!b)return d;n=0;if(1===b)return S.call(this,a[0],"",c,e);if(2===b&&f&&!g)return S.call(this,a[0],a[1],c,e);if(1<b)if(f){var l=a[0];n=1}else 9<h&&3<h/k&&a.sort(aa);for(let r,t;n<b;n++){t=a[n];l?(r=T(this,t,l),r=ra(r,d,g,this.K,c,e,2===b),g&&!1===r&&d.length||(l=t)):(r=T(this,t),r=ra(r,d,g,this.resolution,c,e,1===b));if(r)return r;if(g&&n===b-1){f=d.length;if(!f){if(l){l="";n=-1;continue}return d}if(1===f)return R(d[0],c,e)}}a:{a=d;d=this.resolution;l=a.length;b=[];f=y();for(let r=
0,t,p,m,w;r<d;r++)for(k=0;k<l;k++)if(m=a[k],r<m.length&&(t=m[r]))for(n=0;n<t.length;n++)p=t[n],(h=f[p])?f[p]++:(h=0,f[p]=1),w=b[h]||(b[h]=[]),w.push(p);if(a=b.length)if(g){if(1<b.length){g=b;a=[];d=y();f=g.length;for(k=0;k<f;k++)for(l=g[k],h=l.length,n=0;n<h;n++)if(b=l[n],!d[b])if(d[b]=1,e)e--;else if(a.push(b),a.length===c)break;c=a}else c=b[0];b=c}else{if(a<l){d=[];break a}b=b[a-1];if(b.length>c||e)b=b.slice(e,c+e)}d=b}return d};function S(a,c,b,d){return(a=T(this,a,c))&&a.length?R(a,b,d):[]}
function ra(a,c,b,d,e,f,g){let h=[];if(a){d=Math.min(a.length,d);for(let k=0,n=0,l;k<d;k++)if(l=a[k])if(f&&l&&g&&(l.length<=f?(f-=l.length,l=null):(l=l.slice(f),f=0)),l&&(h[k]=l,g&&(n+=l.length,n>=e)))break;if(h.length){if(g)return R(h,e,0);c.push(h);return}}return!b&&h}function T(a,c,b){let d;b&&(d=a.bidirectional&&c>b);a=b?(a=a.B.get(d?c:b))&&a.get(d?b:c):a.map.get(c);return a};N.prototype.remove=function(a,c){const b=this.h.size&&(this.fastupdate?this.h.get(a):this.h.has(a));if(b){if(this.fastupdate)for(let d=0,e;d<b.length;d++){if(e=b[d])if(2>e.length)e.pop();else{const f=e.indexOf(a);f===b.length-1?e.pop():e.splice(f,1)}}else U(this.map,a),this.depth&&U(this.B,a);c||this.h.delete(a)}return this};
function U(a,c){let b=0;if(a.constructor===Array)for(let d=0,e,f;d<a.length;d++){if((e=a[d])&&e.length)if(f=e.indexOf(c),0<=f){1<e.length?(e.splice(f,1),b++):delete a[d];break}else b++}else for(let d of a){const e=d[0],f=U(d[1],c);f?b+=f:a.delete(e)}return b};function N(a,c){if(!this)return new N(a);if(a){var b=A(a)?a:a.preset;b&&(a=Object.assign({},oa[b],a))}else a={};b=a.context||{};const d=a.encode||a.encoder||J;this.encoder=d.encode?d:"object"===typeof d?new I(d):{encode:d};let e;this.resolution=a.resolution||9;this.tokenize=e=a.tokenize||"strict";this.depth="strict"===e&&b.depth||0;this.bidirectional=!1!==b.bidirectional;this.fastupdate=!!a.fastupdate;this.score=a.score||null;this.map=new Map;this.B=new Map;this.h=c||(this.fastupdate?new Map:new Set);
this.K=b.resolution||1;this.rtl=d.rtl||a.rtl||!1}v=N.prototype;v.clear=function(){this.map.clear();this.B.clear();this.h.clear();return this};v.append=function(a,c){return this.add(a,c,!0)};v.contain=function(a){return this.h.has(a)};v.update=function(a,c){if(this.async){const b=this,d=this.remove(a);return d.then?d.then(()=>b.add(a,c)):this.add(a,c)}return this.remove(a).add(a,c)};
function V(a){let c=0;if(a.constructor===Array)for(let b=0,d;b<a.length;b++)(d=a[b])&&(c+=d.length);else for(const b of a){const d=b[0],e=V(b[1]);e?c+=e:a.delete(d)}return c}v.cleanup=function(){if(!this.fastupdate)return this;V(this.map);this.depth&&V(this.B);return this};
v.export=function(a,c,b,d,e,f){let g=!0;"undefined"===typeof f&&(g=new Promise(n=>{f=n}));let h,k;switch(e||(e=0)){case 0:h="reg";if(this.fastupdate){k=y();for(let n of this.h.keys())k[n]=1}else k=this.h;break;case 1:h="cfg";k={doc:0,opt:this.F?1:0};break;case 2:h="map";k=this.map;break;case 3:h="ctx";k=this.B;break;default:"undefined"===typeof b&&f&&f();return}na(a,c||this,b,h,d,e,k,f);return g};
v.import=function(a,c){if(c)switch(A(c)&&(c=JSON.parse(c)),a){case "cfg":this.F=!!c.opt;break;case "reg":this.fastupdate=!1;this.h=c;break;case "map":this.map=c;break;case "ctx":this.B=c}};pa(N.prototype);W.prototype.add=function(a,c,b){E(a)&&(c=a,a=F(c,this.key));if(c&&(a||0===a)){if(!b&&this.h.has(a))return this.update(a,c);for(let e=0,f;e<this.field.length;e++){f=this.C[e];const g=this.index.get(this.field[e]);if("function"===typeof f){var d=f(c);d&&g.add(a,d,!1,!0)}else if(d=f.J,!d||d(c))f.constructor===String?f=[""+f]:A(f)&&(f=[f]),X(c,f,this.G,0,g,a,f[0],b)}if(this.store&&(!b||!this.store.has(a))){let e;if(this.A){e=y();for(let f=0,g;f<this.A.length;f++){g=this.A[f];if((b=g.J)&&!b(c))continue;
let h;if("function"===typeof g){h=g(c);if(!h)continue;g=[g.L]}else if(A(g)||g.constructor===String){e[g]=c[g];continue}Y(c,e,g,0,g[0],h)}}this.store.set(a,e||c)}}return this};function Y(a,c,b,d,e,f){a=a[e];if(d===b.length-1)c[e]=f||a;else if(a)if(a.constructor===Array)for(c=c[e]=Array(a.length),e=0;e<a.length;e++)Y(a,c,b,d,e);else c=c[e]||(c[e]=y()),e=b[++d],Y(a,c,b,d,e)}
function X(a,c,b,d,e,f,g,h){if(a=a[g])if(d===c.length-1){if(a.constructor===Array){if(b[d]){for(c=0;c<a.length;c++)e.add(f,a[c],!0,!0);return}a=a.join(" ")}e.add(f,a,h,!0)}else if(a.constructor===Array)for(g=0;g<a.length;g++)X(a,c,b,d,e,f,g,h);else g=c[++d],X(a,c,b,d,e,f,g,h)};W.prototype.search=function(a,c,b,d){b||(!c&&E(a)?(b=a,a=""):E(c)&&(b=c,c=0));let e=[];var f=[];let g,h,k,n,l;let r=0;if(b){b.constructor===Array&&(b={index:b});a=b.query||a;var t=b.pluck;h=b.merge;n=t||b.field||b.index;l=!1;g=this.store&&b.enrich;k=b.suggest;c=b.limit||c;var p=b.offset||0;c||(c=100);if(l){l.constructor!==Array&&(l=[l]);var m=[];for(let u=0,q;u<l.length;u++)if(q=l[u],q.field&&q.tag){var w=q.tag;if(w.constructor===Array)for(var B=0;B<w.length;B++)m.push(q.field,w[B]);else m.push(q.field,
w)}else{w=Object.keys(q);for(let C=0,D,z;C<w.length;C++)if(D=w[C],z=q[D],z.constructor===Array)for(B=0;B<z.length;B++)m.push(D,z[B]);else m.push(D,z)}l=m;if(!a){d=[];if(m.length)for(f=0;f<m.length;f+=2)t=sa.call(this,m[f],m[f+1],c,p,g),e.push({field:m[f],tag:m[f+1],result:t});return d.length?Promise.all(d).then(function(u){for(let q=0;q<u.length;q++)e[q].result=u[q];return e}):e}}A(n)&&(n=[n])}n||(n=this.field);p=!d&&(this.worker||this.async)&&[];for(let u=0,q,C,D;u<n.length;u++){C=n[u];let z;A(C)||
(z=C,C=z.field,a=z.query||a,c=z.limit||c,k=z.suggest||k);if(d)q=d[u];else if(m=z||b,w=this.index.get(C),l&&(m.enrich=!1),p){p[u]=w.searchAsync(a,c,m);m&&g&&(m.enrich=g);continue}else q=w.search(a,c,m),m&&g&&(m.enrich=g);D=q&&q.length;if(l&&D){m=[];w=0;for(let O=0,G,ua;O<l.length;O+=2){G=this.tag.get(l[O]);if(!G)if(k)continue;else return e;if(ua=(G=G&&G.get(l[O+1]))&&G.length)w++,m.push(G);else if(!k)return e}if(w){q=qa(q,m);D=q.length;if(!D&&!k)return e;w--}}if(D)f[r]=C,e.push(q),r++;else if(1===
n.length)return e}if(p){const u=this;return Promise.all(p).then(function(q){return q.length?u.search(a,c,b,q):q})}if(!r)return e;if(t&&(!g||!this.store))return e[0];p=[];for(let u=0,q;u<f.length;u++){q=e[u];g&&q.length&&!q[0].doc&&q.length&&(q=ta.call(this,q));if(t)return q;e[u]={field:f[u],result:q}}return h?va(e,c):e};
function va(a,c){const b=[],d=y();for(let e=0,f,g;e<a.length;e++){f=a[e];g=f.result;for(let h=0,k,n,l;h<g.length;h++)if(n=g[h],k=n.id,l=d[k])l.push(f.field);else{if(b.length===c)return b;n.field=d[k]=[f.field];b.push(n)}}return b}function sa(a,c,b,d,e){a=this.tag.get(a);if(!a)return[];if((c=(a=a&&a.get(c))&&a.length-d)&&0<c){if(c>b||d)a=a.slice(d,d+b);e&&(a=ta.call(this,a));return a}}
function ta(a){const c=Array(a.length);for(let b=0,d;b<a.length;b++)d=a[b],c[b]={id:d,doc:this.store.get(d)};return c};function W(a){if(!this)return new W(a);const c=a.document||a.doc||a;var b;this.C=[];this.field=[];this.G=[];this.key=(b=c.key||c.id)&&Z(b,this.G)||"id";this.h=(this.fastupdate=!!a.fastupdate)?new Map:new Set;this.A=(b=c.store||null)&&!0!==b&&[];this.store=b&&new Map;this.async=!1;b=new Map;let d=c.index||c.field||c;A(d)&&(d=[d]);for(let e=0,f,g;e<d.length;e++)f=d[e],A(f)||(g=f,f=f.field),g=E(g)?Object.assign({},a,g):a,b.set(f,new N(g,this.h)),g.custom?this.C[e]=g.custom:(this.C[e]=Z(f,this.G),g.filter&&
("string"===typeof this.C[e]&&(this.C[e]=new String(this.C[e])),this.C[e].J=g.filter)),this.field[e]=f;if(this.A){a=c.store;A(a)&&(a=[a]);for(let e=0,f,g;e<a.length;e++)f=a[e],g=f.field||f,f.custom?(this.A[e]=f.custom,f.custom.L=g):(this.A[e]=Z(g,this.G),f.filter&&("string"===typeof this.A[e]&&(this.A[e]=new String(this.A[e])),this.A[e].J=f.filter))}this.index=b}
function Z(a,c){const b=a.split(":");let d=0;for(let e=0;e<b.length;e++)a=b[e],"]"===a[a.length-1]&&(a=a.substring(0,a.length-2))&&(c[d]=!0),a&&(b[d++]=a);d<b.length&&(b.length=d);return 1<d?b:b[0]}v=W.prototype;v.append=function(a,c){return this.add(a,c,!0)};v.update=function(a,c){return this.remove(a).add(a,c)};v.remove=function(a){E(a)&&(a=F(a,this.key));for(const c of this.index.values())c.remove(a,!0);this.h.has(a)&&(this.store&&this.store.delete(a),this.h.delete(a));return this};
v.clear=function(){for(const a of this.index.values())a.clear();this.store&&this.store.clear();return this};v.contain=function(a){return this.h.has(a)};v.cleanup=function(){for(const a of this.index.values())a.cleanup();return this};v.get=function(a){return this.store.get(a)};v.set=function(a,c){this.store.set(a,c);return this};
v.export=function(a,c,b,d,e,f){let g;"undefined"===typeof f&&(g=new Promise(k=>{f=k}));e||(e=0);d||(d=0);if(d<this.field.length){b=this.field[d];var h=this.index[b];c=this;h.export(a,c,e?b:"",d,e++,f)||(d++,c.export(a,c,b,d,1,f))}else{switch(e){case 1:c="tag";h=this.D;b=null;break;case 2:c="store";h=this.store;b=null;break;default:f();return}na(a,this,b,c,d,e,h,f)}return g};
v.import=function(a,c){if(c)switch(A(c)&&(c=JSON.parse(c)),a){case "tag":this.D=c;break;case "reg":this.fastupdate=!1;this.h=c;for(let d=0,e;d<this.field.length;d++)e=this.index[this.field[d]],e.h=c,e.fastupdate=!1;break;case "store":this.store=c;break;default:a=a.split(".");const b=a[0];a=a[1];b&&a&&this.index[b].import(a,c)}};pa(W.prototype);export default {Index:N,Charset:ma,Encoder:I,Document:W,Worker:null,Resolver:null,IndexedDB:null,Language:{}};
this.minlength)continue;if(c){b.push(f);continue}if(this.filter&&this.filter.has(f))continue;let g;this.stemmer&&2<f.length&&(this.G||(this.G=new RegExp("(?!^)("+this.B+")$")),f=f.replace(this.G,h=>this.stemmer.get(h)),g=1);this.matcher&&1<f.length&&(this.F||(this.F=new RegExp("("+this.C+")","g")),f=f.replace(this.F,h=>this.matcher.get(h)),g=1);f&&g&&(f.length<this.minlength||this.filter&&this.filter.has(f))&&(f="");if(f&&(this.mapper||this.dedupe&&1<f.length)){var d="";for(let h=0,k="",m,l;h<f.length;h++)m=
f.charAt(h),m===k&&this.dedupe||((l=this.mapper&&this.mapper.get(m))||""===l?l===k&&this.dedupe||!(k=l)||(d+=l):d+=k=m);f=d}if(f&&this.replacer)for(d=0;f&&d<this.replacer.length;d+=2)f=f.replace(this.replacer[d],this.replacer[d+1]);f&&b.push(f)}this.finalize&&(b=this.finalize(b)||b);return b};const J={normalize:function(a){return a.toLowerCase()},dedupe:!1};const K=new Map([["b","p"],["v","f"],["w","f"],["z","s"],["x","s"],["d","t"],["n","m"],["c","k"],["g","k"],["j","k"],["q","k"],["i","e"],["y","e"],["u","o"]]);const L=new Map([["ai","ei"],["ae","a"],["oe","o"],["ue","u"],["sh","s"],["ch","c"],["th","t"],["ph","f"],["pf","f"]]),ha=[/([^aeo])h([aeo$])/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2"];const ia={a:"",e:"",i:"",o:"",u:"",y:"",b:1,f:1,p:1,v:1,c:2,g:2,j:2,k:2,q:2,s:2,x:2,z:2,"\u00df":2,d:3,t:3,l:4,m:5,n:5,r:6};const ja=/[\x00-\x7F]+/g;const ka=/[\x00-\x7F]+/g;const la=/[\x00-\x7F]+/g;var ma={LatinExact:{normalize:!1,dedupe:!1},LatinDefault:J,LatinSimple:{normalize:!0,dedupe:!0},LatinBalance:{normalize:!0,dedupe:!0,mapper:K},LatinAdvanced:{normalize:!0,dedupe:!0,mapper:K,replacer:ha,matcher:L},LatinExtra:{normalize:!0,dedupe:!0,mapper:K,replacer:ha.concat([/(?!^)[aeoy]/g,""]),matcher:L},LatinSoundex:{normalize:!0,dedupe:!1,include:{letter:!0},finalize:function(a){for(let b=0;b<a.length;b++){var c=a[b];let d=c.charAt(0),e=ia[d];for(let f=1,g;f<c.length&&(g=c.charAt(f),"h"===g||
"w"===g||!(g=ia[g])||g===e||(d+=g,e=g,4!==d.length));f++);a[b]=d}}},ArabicDefault:{rtl:!0,normalize:!1,dedupe:!0,prepare:function(a){return(""+a).replace(ja," ")}},CjkDefault:{normalize:!1,dedupe:!0,split:"",prepare:function(a){return(""+a).replace(ka,"")}},CyrillicDefault:{normalize:!1,dedupe:!0,prepare:function(a){return(""+a).replace(la," ")}}};function na(a,c,b,d,e,f,g,h){(d=a(b?b+"."+d:d,JSON.stringify(g)))&&d.then?d.then(function(){c.export(a,c,b,e,f+1,h)}):c.export(a,c,b,e,f+1,h)};const oa={memory:{resolution:1},performance:{resolution:6,fastupdate:!0,context:{depth:1,resolution:3}},match:{tokenize:"forward"},score:{resolution:9,context:{depth:2,resolution:9}}};function pa(a){M.call(a,"add");M.call(a,"append");M.call(a,"search");M.call(a,"update");M.call(a,"remove")}function M(a){this[a+"Async"]=function(){var c=arguments;const b=c[c.length-1];let d;"function"===typeof b&&(d=b,delete c[c.length-1]);this.async=!0;c=this[a].apply(this,c);this.async=!1;d&&(c.then?c.then(d):d(c));return c}};y();N.prototype.add=function(a,c,b,d){if(c&&(a||0===a)){if(!d&&!b&&this.reg.has(a))return this.update(a,c);c=this.encoder.encode(c);if(d=c.length){const m=y(),l=y(),r=this.depth,t=this.resolution;for(let p=0;p<d;p++){let n=c[this.rtl?d-1-p:p];var e=n.length;if(e&&(r||!l[n])){var f=this.score?this.score(c,n,p,null,0):P(t,d,p),g="";switch(this.tokenize){case "full":if(2<e){for(f=0;f<e;f++)for(var h=e;h>f;h--){g=n.substring(f,h);var k=this.score?this.score(c,n,p,g,f):P(t,d,p,e,f);Q(this,l,g,k,a,b)}break}case "reverse":if(1<
e){for(h=e-1;0<h;h--)g=n[h]+g,k=this.score?this.score(c,n,p,g,h):P(t,d,p,e,h),Q(this,l,g,k,a,b);g=""}case "forward":if(1<e){for(h=0;h<e;h++)g+=n[h],Q(this,l,g,f,a,b);break}default:if(Q(this,l,n,f,a,b),r&&1<d&&p<d-1)for(e=y(),g=this.I,f=n,h=Math.min(r+1,d-p),e[f]=1,k=1;k<h;k++)if((n=c[this.rtl?d-1-p-k:p+k])&&!e[n]){e[n]=1;const w=this.score?this.score(c,f,p,n,k):P(g+(d/2>g?0:1),d,p,h-1,k-1),B=this.bidirectional&&n>f;Q(this,m,B?f:n,w,a,b,B?n:f)}}}}this.fastupdate||this.reg.add(a)}}return this};
function Q(a,c,b,d,e,f,g){let h=g?a.ctx:a.map,k;c[b]&&g&&(k=c[b])[g]||(g?(c=k||(c[b]=y()),c[g]=1,(k=h.get(g))?h=k:h.set(g,h=new Map)):c[b]=1,(k=h.get(b))?h=k:h.set(b,h=[]),h=h[d]||(h[d]=[]),f&&h.includes(e)||(h.push(e),a.fastupdate&&((c=a.reg.get(e))?c.push(h):a.reg.set(e,[h]))))}function P(a,c,b,d,e){return b&&1<a?c+(d||0)<=a?b+(e||0):(a-1)/(c+(d||0))*(b+(e||0))+1|0:0};function R(a,c,b){if(1===a.length)return a=a[0],a=b||a.length>c?c?a.slice(b,b+c):a.slice(b):a;let d=[];for(let e=0,f,g;e<a.length;e++)if((f=a[e])&&(g=f.length)){if(b){if(b>=g){b-=g;continue}b<g&&(f=c?f.slice(b,b+c):f.slice(b),g=f.length,b=0)}if(d.length)g>c&&(f=f.slice(0,c),g=f.length),d.push(f);else{if(g>=c)return g>c&&(f=f.slice(0,c)),f;d=[f]}c-=g;if(!c)break}return d.length?d=1<d.length?[].concat.apply([],d):d[0]:d};function qa(a,c){const b=y(),d=y(),e=[];for(let f=0;f<a.length;f++)b[a[f]]=1;for(let f=0,g;f<c.length;f++){g=c[f];for(let h=0,k;h<g.length;h++)k=g[h],b[k]&&!d[k]&&(d[k]=1,e.push(k))}return e};N.prototype.search=function(a,c,b){b||(!c&&E(a)?(b=a,a=""):E(c)&&(b=c,c=0));var d=[],e=0;if(b){a=b.query||a;c=b.limit||c;e=b.offset||0;var f=b.context;var g=b.suggest}a=this.encoder.encode(a);b=a.length;c||(c=100);if(1===b)return S.call(this,a[0],"",c,e);f=this.depth&&!1!==f;if(2===b&&f&&!g)return S.call(this,a[0],a[1],c,e);var h=0,k=0;if(1<b){var m=y();const r=[];for(let t=0,p;t<b;t++)if((p=a[t])&&!m[p]){if(g||T(this,p))r.push(p),m[p]=1;else return d;const n=p.length;h=Math.max(h,n);k=k?Math.min(k,
n):n}a=r;b=a.length}if(!b)return d;m=0;if(1===b)return S.call(this,a[0],"",c,e);if(2===b&&f&&!g)return S.call(this,a[0],a[1],c,e);if(1<b)if(f){var l=a[0];m=1}else 9<h&&3<h/k&&a.sort(aa);for(let r,t;m<b;m++){t=a[m];l?(r=T(this,t,l),r=ra(r,d,g,this.I,c,e,2===b),g&&!1===r&&d.length||(l=t)):(r=T(this,t),r=ra(r,d,g,this.resolution,c,e,1===b));if(r)return r;if(g&&m===b-1){f=d.length;if(!f){if(l){l="";m=-1;continue}return d}if(1===f)return R(d[0],c,e)}}a:{a=d;d=this.resolution;l=a.length;b=[];f=y();for(let r=
0,t,p,n,w;r<d;r++)for(k=0;k<l;k++)if(n=a[k],r<n.length&&(t=n[r]))for(m=0;m<t.length;m++)p=t[m],(h=f[p])?f[p]++:(h=0,f[p]=1),w=b[h]||(b[h]=[]),w.push(p);if(a=b.length)if(g){if(1<b.length){g=b;a=[];d=y();f=g.length;for(k=0;k<f;k++)for(l=g[k],h=l.length,m=0;m<h;m++)if(b=l[m],!d[b])if(d[b]=1,e)e--;else if(a.push(b),a.length===c)break;c=a}else c=b[0];b=c}else{if(a<l){d=[];break a}b=b[a-1];if(b.length>c||e)b=b.slice(e,c+e)}d=b}return d};function S(a,c,b,d){return(a=T(this,a,c))&&a.length?R(a,b,d):[]}
function ra(a,c,b,d,e,f,g){let h=[];if(a){d=Math.min(a.length,d);for(let k=0,m=0,l;k<d;k++)if(l=a[k])if(f&&l&&g&&(l.length<=f?(f-=l.length,l=null):(l=l.slice(f),f=0)),l&&(h[k]=l,g&&(m+=l.length,m>=e)))break;if(h.length){if(g)return R(h,e,0);c.push(h);return}}return!b&&h}function T(a,c,b){let d;b&&(d=a.bidirectional&&c>b);a=b?(a=a.ctx.get(d?c:b))&&a.get(d?b:c):a.map.get(c);return a};N.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 d=0,e;d<b.length;d++){if(e=b[d])if(2>e.length)e.pop();else{const f=e.indexOf(a);f===b.length-1?e.pop():e.splice(f,1)}}else U(this.map,a),this.depth&&U(this.ctx,a);c||this.reg.delete(a)}return this};
function U(a,c){let b=0;if(a.constructor===Array)for(let d=0,e,f;d<a.length;d++){if((e=a[d])&&e.length)if(f=e.indexOf(c),0<=f){1<e.length?(e.splice(f,1),b++):delete a[d];break}else b++}else for(let d of a){const e=d[0],f=U(d[1],c);f?b+=f:a.delete(e)}return b};function N(a,c){if(!this)return new N(a);if(a){var b=A(a)?a:a.preset;b&&(a=Object.assign({},oa[b],a))}else a={};b=a.context||{};const d=a.encode||a.encoder||J;this.encoder=d.encode?d:"object"===typeof d?new I(d):{encode:d};let e;this.resolution=a.resolution||9;this.tokenize=e=a.tokenize||"strict";this.depth="strict"===e&&b.depth||0;this.bidirectional=!1!==b.bidirectional;this.fastupdate=!!a.fastupdate;this.score=a.score||null;this.map=new Map;this.ctx=new Map;this.reg=c||(this.fastupdate?new Map:
new Set);this.I=b.resolution||1;this.rtl=d.rtl||a.rtl||!1}u=N.prototype;u.clear=function(){this.map.clear();this.ctx.clear();this.reg.clear();return this};u.append=function(a,c){return this.add(a,c,!0)};u.contain=function(a){return this.reg.has(a)};u.update=function(a,c){if(this.async){const b=this,d=this.remove(a);return d.then?d.then(()=>b.add(a,c)):this.add(a,c)}return this.remove(a).add(a,c)};
function V(a){let c=0;if(a.constructor===Array)for(let b=0,d;b<a.length;b++)(d=a[b])&&(c+=d.length);else for(const b of a){const d=b[0],e=V(b[1]);e?c+=e:a.delete(d)}return c}u.cleanup=function(){if(!this.fastupdate)return this;V(this.map);this.depth&&V(this.ctx);return this};
u.export=function(a,c,b,d,e,f){let g=!0;"undefined"===typeof f&&(g=new Promise(m=>{f=m}));let h,k;switch(e||(e=0)){case 0:h="reg";if(this.fastupdate){k=y();for(let m of this.reg.keys())k[m]=1}else k=this.reg;break;case 1:h="cfg";k={doc:0,opt:this.C?1:0};break;case 2:h="map";k=this.map;break;case 3:h="ctx";k=this.ctx;break;default:"undefined"===typeof b&&f&&f();return}na(a,c||this,b,h,d,e,k,f);return g};
u.import=function(a,c){if(c)switch(A(c)&&(c=JSON.parse(c)),a){case "cfg":this.C=!!c.opt;break;case "reg":this.fastupdate=!1;this.reg=c;break;case "map":this.map=c;break;case "ctx":this.ctx=c}};
u.serialize=function(a=!0){if(!this.reg.size)return"";let c="",b="";for(var d of this.reg.keys())b||(b=typeof d),c+=(c?",":"")+("string"===b?'"'+d+'"':d);c="index.reg=new Set(["+c+"]);";d="";for(var e of this.map.entries()){var f=e[0],g=e[1],h="";for(let l=0,r;l<g.length;l++){r=g[l]||[""];var k="";for(var m=0;m<r.length;m++)k+=(k?",":"")+("string"===b?'"'+r[m]+'"':r[m]);k="["+k+"]";h+=(h?",":"")+k}h='["'+f+'",['+h+"]]";d+=(d?",":"")+h}d="index.map=new Map(["+d+"]);";e="";for(const l of this.ctx.entries()){f=
l[0];g=l[1];for(const r of g.entries()){g=r[0];h=r[1];k="";for(let t=0,p;t<h.length;t++){p=h[t]||[""];m="";for(let n=0;n<p.length;n++)m+=(m?",":"")+("string"===b?'"'+p[n]+'"':p[n]);m="["+m+"]";k+=(k?",":"")+m}k='new Map([["'+g+'",['+k+"]]])";k='["'+f+'",'+k+"]";e+=(e?",":"")+k}}e="index.ctx=new Map(["+e+"]);";return a?"function inject(index){"+c+d+e+"}":c+d+e};pa(N.prototype);W.prototype.add=function(a,c,b){E(a)&&(c=a,a=F(c,this.key));if(c&&(a||0===a)){if(!b&&this.reg.has(a))return this.update(a,c);for(let e=0,f;e<this.field.length;e++){f=this.A[e];const g=this.index.get(this.field[e]);if("function"===typeof f){var d=f(c);d&&g.add(a,d,!1,!0)}else if(d=f.H,!d||d(c))f.constructor===String?f=[""+f]:A(f)&&(f=[f]),X(c,f,this.D,0,g,a,f[0],b)}if(this.store&&(!b||!this.store.has(a))){let e;if(this.h){e=y();for(let f=0,g;f<this.h.length;f++){g=this.h[f];if((b=g.H)&&!b(c))continue;
let h;if("function"===typeof g){h=g(c);if(!h)continue;g=[g.J]}else if(A(g)||g.constructor===String){e[g]=c[g];continue}Y(c,e,g,0,g[0],h)}}this.store.set(a,e||c)}}return this};function Y(a,c,b,d,e,f){a=a[e];if(d===b.length-1)c[e]=f||a;else if(a)if(a.constructor===Array)for(c=c[e]=Array(a.length),e=0;e<a.length;e++)Y(a,c,b,d,e);else c=c[e]||(c[e]=y()),e=b[++d],Y(a,c,b,d,e)}
function X(a,c,b,d,e,f,g,h){if(a=a[g])if(d===c.length-1){if(a.constructor===Array){if(b[d]){for(c=0;c<a.length;c++)e.add(f,a[c],!0,!0);return}a=a.join(" ")}e.add(f,a,h,!0)}else if(a.constructor===Array)for(g=0;g<a.length;g++)X(a,c,b,d,e,f,g,h);else g=c[++d],X(a,c,b,d,e,f,g,h)};W.prototype.search=function(a,c,b,d){b||(!c&&E(a)?(b=a,a=""):E(c)&&(b=c,c=0));let e=[];var f=[];let g,h,k,m,l;let r=0;if(b){b.constructor===Array&&(b={index:b});a=b.query||a;var t=b.pluck;h=b.merge;m=t||b.field||b.index;l=!1;g=this.store&&b.enrich;k=b.suggest;c=b.limit||c;var p=b.offset||0;c||(c=100);if(l){l.constructor!==Array&&(l=[l]);var n=[];for(let v=0,q;v<l.length;v++)if(q=l[v],q.field&&q.tag){var w=q.tag;if(w.constructor===Array)for(var B=0;B<w.length;B++)n.push(q.field,w[B]);else n.push(q.field,
w)}else{w=Object.keys(q);for(let C=0,D,z;C<w.length;C++)if(D=w[C],z=q[D],z.constructor===Array)for(B=0;B<z.length;B++)n.push(D,z[B]);else n.push(D,z)}l=n;if(!a){d=[];if(n.length)for(f=0;f<n.length;f+=2)t=sa.call(this,n[f],n[f+1],c,p,g),e.push({field:n[f],tag:n[f+1],result:t});return d.length?Promise.all(d).then(function(v){for(let q=0;q<v.length;q++)e[q].result=v[q];return e}):e}}A(m)&&(m=[m])}m||(m=this.field);p=!d&&(this.worker||this.async)&&[];for(let v=0,q,C,D;v<m.length;v++){C=m[v];let z;A(C)||
(z=C,C=z.field,a=z.query||a,c=z.limit||c,k=z.suggest||k);if(d)q=d[v];else if(n=z||b,w=this.index.get(C),l&&(n.enrich=!1),p){p[v]=w.searchAsync(a,c,n);n&&g&&(n.enrich=g);continue}else q=w.search(a,c,n),n&&g&&(n.enrich=g);D=q&&q.length;if(l&&D){n=[];w=0;for(let O=0,G,ua;O<l.length;O+=2){G=this.tag.get(l[O]);if(!G)if(k)continue;else return e;if(ua=(G=G&&G.get(l[O+1]))&&G.length)w++,n.push(G);else if(!k)return e}if(w){q=qa(q,n);D=q.length;if(!D&&!k)return e;w--}}if(D)f[r]=C,e.push(q),r++;else if(1===
m.length)return e}if(p){const v=this;return Promise.all(p).then(function(q){return q.length?v.search(a,c,b,q):q})}if(!r)return e;if(t&&(!g||!this.store))return e[0];p=[];for(let v=0,q;v<f.length;v++){q=e[v];g&&q.length&&!q[0].doc&&q.length&&(q=ta.call(this,q));if(t)return q;e[v]={field:f[v],result:q}}return h?va(e,c):e};
function va(a,c){const b=[],d=y();for(let e=0,f,g;e<a.length;e++){f=a[e];g=f.result;for(let h=0,k,m,l;h<g.length;h++)if(m=g[h],k=m.id,l=d[k])l.push(f.field);else{if(b.length===c)return b;m.field=d[k]=[f.field];b.push(m)}}return b}function sa(a,c,b,d,e){a=this.tag.get(a);if(!a)return[];if((c=(a=a&&a.get(c))&&a.length-d)&&0<c){if(c>b||d)a=a.slice(d,d+b);e&&(a=ta.call(this,a));return a}}
function ta(a){const c=Array(a.length);for(let b=0,d;b<a.length;b++)d=a[b],c[b]={id:d,doc:this.store.get(d)};return c};function W(a){if(!this)return new W(a);const c=a.document||a.doc||a;var b;this.A=[];this.field=[];this.D=[];this.key=(b=c.key||c.id)&&Z(b,this.D)||"id";this.reg=(this.fastupdate=!!a.fastupdate)?new Map:new Set;this.h=(b=c.store||null)&&!0!==b&&[];this.store=b&&new Map;this.async=!1;b=new Map;let d=c.index||c.field||c;A(d)&&(d=[d]);for(let e=0,f,g;e<d.length;e++)f=d[e],A(f)||(g=f,f=f.field),g=E(g)?Object.assign({},a,g):a,b.set(f,new N(g,this.reg)),g.custom?this.A[e]=g.custom:(this.A[e]=Z(f,this.D),
g.filter&&("string"===typeof this.A[e]&&(this.A[e]=new String(this.A[e])),this.A[e].H=g.filter)),this.field[e]=f;if(this.h){a=c.store;A(a)&&(a=[a]);for(let e=0,f,g;e<a.length;e++)f=a[e],g=f.field||f,f.custom?(this.h[e]=f.custom,f.custom.J=g):(this.h[e]=Z(g,this.D),f.filter&&("string"===typeof this.h[e]&&(this.h[e]=new String(this.h[e])),this.h[e].H=f.filter))}this.index=b}
function Z(a,c){const b=a.split(":");let d=0;for(let e=0;e<b.length;e++)a=b[e],"]"===a[a.length-1]&&(a=a.substring(0,a.length-2))&&(c[d]=!0),a&&(b[d++]=a);d<b.length&&(b.length=d);return 1<d?b:b[0]}u=W.prototype;u.append=function(a,c){return this.add(a,c,!0)};u.update=function(a,c){return this.remove(a).add(a,c)};u.remove=function(a){E(a)&&(a=F(a,this.key));for(const c of this.index.values())c.remove(a,!0);this.reg.has(a)&&(this.store&&this.store.delete(a),this.reg.delete(a));return this};
u.clear=function(){for(const a of this.index.values())a.clear();this.store&&this.store.clear();return this};u.contain=function(a){return this.reg.has(a)};u.cleanup=function(){for(const a of this.index.values())a.cleanup();return this};u.get=function(a){return this.store.get(a)};u.set=function(a,c){this.store.set(a,c);return this};
u.export=function(a,c,b,d,e,f){let g;"undefined"===typeof f&&(g=new Promise(k=>{f=k}));e||(e=0);d||(d=0);if(d<this.field.length){b=this.field[d];var h=this.index[b];c=this;h.export(a,c,e?b:"",d,e++,f)||(d++,c.export(a,c,b,d,1,f))}else{switch(e){case 1:c="tag";h=this.B;b=null;break;case 2:c="store";h=this.store;b=null;break;default:f();return}na(a,this,b,c,d,e,h,f)}return g};
u.import=function(a,c){if(c)switch(A(c)&&(c=JSON.parse(c)),a){case "tag":this.B=c;break;case "reg":this.fastupdate=!1;this.reg=c;for(let d=0,e;d<this.field.length;d++)e=this.index[this.field[d]],e.reg=c,e.fastupdate=!1;break;case "store":this.store=c;break;default:a=a.split(".");const b=a[0];a=a[1];b&&a&&this.index[b].import(a,c)}};pa(W.prototype);export default {Index:N,Charset:ma,Encoder:I,Document:W,Worker:null,Resolver:null,IndexedDB:null,Language:{}};
export const Index=N;export const Charset=ma;export const Encoder=I;export const Document=W;export const Worker=null;export const Resolver=null;export const IndexedDB=null;export const Language={};

File diff suppressed because it is too large Load Diff

View File

@@ -7,115 +7,118 @@
*/
(function(self){'use strict';var w;function aa(a){var b=0;return function(){return b<a.length?{done:!1,value:a[b++]}:{done:!0}}}function x(a){var b="undefined"!=typeof Symbol&&Symbol.iterator&&a[Symbol.iterator];if(b)return b.call(a);if("number"==typeof a.length)return{next:aa(a)};throw Error(String(a)+" is not an iterable or ArrayLike");}var ba="function"==typeof Object.defineProperties?Object.defineProperty:function(a,b,c){if(a==Array.prototype||a==Object.prototype)return a;a[b]=c.value;return a};
function ca(a){a=["object"==typeof globalThis&&globalThis,a,"object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof global&&global];for(var b=0;b<a.length;++b){var c=a[b];if(c&&c.Math==Math)return c}throw Error("Cannot find global object");}var z=ca(this);function B(a,b){if(b)a:{var c=z;a=a.split(".");for(var d=0;d<a.length-1;d++){var e=a[d];if(!(e in c))break a;c=c[e]}a=a[a.length-1];d=c[a];b=b(d);b!=d&&null!=b&&ba(c,a,{configurable:!0,writable:!0,value:b})}}var da;
if("function"==typeof Object.setPrototypeOf)da=Object.setPrototypeOf;else{var ea;a:{var fa={a:!0},ha={};try{ha.__proto__=fa;ea=ha.a;break a}catch(a){}ea=!1}da=ea?function(a,b){a.__proto__=b;if(a.__proto__!==b)throw new TypeError(a+" is not extensible");return a}:null}var ia=da;function ja(){this.D=!1;this.A=null;this.G=void 0;this.h=1;this.L=0;this.C=null}function ka(a){if(a.D)throw new TypeError("Generator is already running");a.D=!0}ja.prototype.H=function(a){this.G=a};
function la(a,b){a.C={qa:b,ra:!0};a.h=a.L}ja.prototype.return=function(a){this.C={return:a};this.h=this.L};function F(a,b,c){a.h=c;return{value:b}}function ma(a){this.h=new ja;this.A=a}function na(a,b){ka(a.h);var c=a.h.A;if(c)return oa(a,"return"in c?c["return"]:function(d){return{value:d,done:!0}},b,a.h.return);a.h.return(b);return G(a)}
function oa(a,b,c,d){try{var e=b.call(a.h.A,c);if(!(e instanceof Object))throw new TypeError("Iterator result "+e+" is not an object");if(!e.done)return a.h.D=!1,e;var g=e.value}catch(f){return a.h.A=null,la(a.h,f),G(a)}a.h.A=null;d.call(a.h,g);return G(a)}function G(a){for(;a.h.h;)try{var b=a.A(a.h);if(b)return a.h.D=!1,{value:b.value,done:!1}}catch(c){a.h.G=void 0,la(a.h,c)}a.h.D=!1;if(a.h.C){b=a.h.C;a.h.C=null;if(b.ra)throw b.qa;return{value:b.return,done:!0}}return{value:void 0,done:!0}}
function pa(a){this.next=function(b){ka(a.h);a.h.A?b=oa(a,a.h.A.next,b,a.h.H):(a.h.H(b),b=G(a));return b};this.throw=function(b){ka(a.h);a.h.A?b=oa(a,a.h.A["throw"],b,a.h.H):(la(a.h,b),b=G(a));return b};this.return=function(b){return na(a,b)};this[Symbol.iterator]=function(){return this}}function qa(a,b){b=new pa(new ma(b));ia&&a.prototype&&ia(b,a.prototype);return b}
function ra(a){function b(d){return a.next(d)}function c(d){return a.throw(d)}return new Promise(function(d,e){function g(f){f.done?d(f.value):Promise.resolve(f.value).then(b,c).then(g,e)}g(a.next())})}function sa(a){return ra(new pa(new ma(a)))}
B("Symbol",function(a){function b(g){if(this instanceof b)throw new TypeError("Symbol is not a constructor");return new c(d+(g||"")+"_"+e++,g)}function c(g,f){this.h=g;ba(this,"description",{configurable:!0,writable:!0,value:f})}if(a)return a;c.prototype.toString=function(){return this.h};var d="jscomp_symbol_"+(1E9*Math.random()>>>0)+"_",e=0;return b});
if("function"==typeof Object.setPrototypeOf)da=Object.setPrototypeOf;else{var ea;a:{var fa={a:!0},ha={};try{ha.__proto__=fa;ea=ha.a;break a}catch(a){}ea=!1}da=ea?function(a,b){a.__proto__=b;if(a.__proto__!==b)throw new TypeError(a+" is not extensible");return a}:null}var ia=da;function ja(){this.C=!1;this.A=null;this.F=void 0;this.h=1;this.J=0;this.B=null}function ka(a){if(a.C)throw new TypeError("Generator is already running");a.C=!0}ja.prototype.G=function(a){this.F=a};
function la(a,b){a.B={oa:b,pa:!0};a.h=a.J}ja.prototype.return=function(a){this.B={return:a};this.h=this.J};function F(a,b,c){a.h=c;return{value:b}}function ma(a){this.h=new ja;this.A=a}function na(a,b){ka(a.h);var c=a.h.A;if(c)return oa(a,"return"in c?c["return"]:function(d){return{value:d,done:!0}},b,a.h.return);a.h.return(b);return G(a)}
function oa(a,b,c,d){try{var e=b.call(a.h.A,c);if(!(e instanceof Object))throw new TypeError("Iterator result "+e+" is not an object");if(!e.done)return a.h.C=!1,e;var h=e.value}catch(f){return a.h.A=null,la(a.h,f),G(a)}a.h.A=null;d.call(a.h,h);return G(a)}function G(a){for(;a.h.h;)try{var b=a.A(a.h);if(b)return a.h.C=!1,{value:b.value,done:!1}}catch(c){a.h.F=void 0,la(a.h,c)}a.h.C=!1;if(a.h.B){b=a.h.B;a.h.B=null;if(b.pa)throw b.oa;return{value:b.return,done:!0}}return{value:void 0,done:!0}}
function pa(a){this.next=function(b){ka(a.h);a.h.A?b=oa(a,a.h.A.next,b,a.h.G):(a.h.G(b),b=G(a));return b};this.throw=function(b){ka(a.h);a.h.A?b=oa(a,a.h.A["throw"],b,a.h.G):(la(a.h,b),b=G(a));return b};this.return=function(b){return na(a,b)};this[Symbol.iterator]=function(){return this}}function qa(a,b){b=new pa(new ma(b));ia&&a.prototype&&ia(b,a.prototype);return b}
function ra(a){function b(d){return a.next(d)}function c(d){return a.throw(d)}return new Promise(function(d,e){function h(f){f.done?d(f.value):Promise.resolve(f.value).then(b,c).then(h,e)}h(a.next())})}function sa(a){return ra(new pa(new ma(a)))}
B("Symbol",function(a){function b(h){if(this instanceof b)throw new TypeError("Symbol is not a constructor");return new c(d+(h||"")+"_"+e++,h)}function c(h,f){this.h=h;ba(this,"description",{configurable:!0,writable:!0,value:f})}if(a)return a;c.prototype.toString=function(){return this.h};var d="jscomp_symbol_"+(1E9*Math.random()>>>0)+"_",e=0;return b});
B("Symbol.iterator",function(a){if(a)return a;a=Symbol("Symbol.iterator");for(var b="Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array".split(" "),c=0;c<b.length;c++){var d=z[b[c]];"function"===typeof d&&"function"!=typeof d.prototype[a]&&ba(d.prototype,a,{configurable:!0,writable:!0,value:function(){return ta(aa(this))}})}return a});function ta(a){a={next:a};a[Symbol.iterator]=function(){return this};return a}
B("Promise",function(a){function b(f){this.A=0;this.C=void 0;this.h=[];this.L=!1;var h=this.D();try{f(h.resolve,h.reject)}catch(k){h.reject(k)}}function c(){this.h=null}function d(f){return f instanceof b?f:new b(function(h){h(f)})}if(a)return a;c.prototype.A=function(f){if(null==this.h){this.h=[];var h=this;this.C(function(){h.G()})}this.h.push(f)};var e=z.setTimeout;c.prototype.C=function(f){e(f,0)};c.prototype.G=function(){for(;this.h&&this.h.length;){var f=this.h;this.h=[];for(var h=0;h<f.length;++h){var k=
f[h];f[h]=null;try{k()}catch(l){this.D(l)}}}this.h=null};c.prototype.D=function(f){this.C(function(){throw f;})};b.prototype.D=function(){function f(l){return function(m){k||(k=!0,l.call(h,m))}}var h=this,k=!1;return{resolve:f(this.ka),reject:f(this.G)}};b.prototype.ka=function(f){if(f===this)this.G(new TypeError("A Promise cannot resolve to itself"));else if(f instanceof b)this.ma(f);else{a:switch(typeof f){case "object":var h=null!=f;break a;case "function":h=!0;break a;default:h=!1}h?this.ja(f):
this.H(f)}};b.prototype.ja=function(f){var h=void 0;try{h=f.then}catch(k){this.G(k);return}"function"==typeof h?this.na(h,f):this.H(f)};b.prototype.G=function(f){this.fa(2,f)};b.prototype.H=function(f){this.fa(1,f)};b.prototype.fa=function(f,h){if(0!=this.A)throw Error("Cannot settle("+f+", "+h+"): Promise already settled in state"+this.A);this.A=f;this.C=h;2===this.A&&this.la();this.ha()};b.prototype.la=function(){var f=this;e(function(){if(f.ia()){var h=z.console;"undefined"!==typeof h&&h.error(f.C)}},
1)};b.prototype.ia=function(){if(this.L)return!1;var f=z.CustomEvent,h=z.Event,k=z.dispatchEvent;if("undefined"===typeof k)return!0;"function"===typeof f?f=new f("unhandledrejection",{cancelable:!0}):"function"===typeof h?f=new h("unhandledrejection",{cancelable:!0}):(f=z.document.createEvent("CustomEvent"),f.initCustomEvent("unhandledrejection",!1,!0,f));f.promise=this;f.reason=this.C;return k(f)};b.prototype.ha=function(){if(null!=this.h){for(var f=0;f<this.h.length;++f)g.A(this.h[f]);this.h=null}};
var g=new c;b.prototype.ma=function(f){var h=this.D();f.Y(h.resolve,h.reject)};b.prototype.na=function(f,h){var k=this.D();try{f.call(h,k.resolve,k.reject)}catch(l){k.reject(l)}};b.prototype.then=function(f,h){function k(p,q){return"function"==typeof p?function(r){try{l(p(r))}catch(y){m(y)}}:q}var l,m,n=new b(function(p,q){l=p;m=q});this.Y(k(f,l),k(h,m));return n};b.prototype.catch=function(f){return this.then(void 0,f)};b.prototype.Y=function(f,h){function k(){switch(l.A){case 1:f(l.C);break;case 2:h(l.C);
break;default:throw Error("Unexpected state: "+l.A);}}var l=this;null==this.h?g.A(k):this.h.push(k);this.L=!0};b.resolve=d;b.reject=function(f){return new b(function(h,k){k(f)})};b.race=function(f){return new b(function(h,k){for(var l=x(f),m=l.next();!m.done;m=l.next())d(m.value).Y(h,k)})};b.all=function(f){var h=x(f),k=h.next();return k.done?d([]):new b(function(l,m){function n(r){return function(y){p[r]=y;q--;0==q&&l(p)}}var p=[],q=0;do p.push(void 0),q++,d(k.value).Y(n(p.length-1),m),k=h.next();
while(!k.done)})};return b});function ua(a,b){a instanceof String&&(a+="");var c=0,d=!1,e={next:function(){if(!d&&c<a.length){var g=c++;return{value:b(g,a[g]),done:!1}}d=!0;return{done:!0,value:void 0}}};e[Symbol.iterator]=function(){return e};return e}B("Array.prototype.values",function(a){return a?a:function(){return ua(this,function(b,c){return c})}});function H(a,b){return Object.prototype.hasOwnProperty.call(a,b)}
B("WeakMap",function(a){function b(k){this.h=(h+=Math.random()+1).toString();if(k){k=x(k);for(var l;!(l=k.next()).done;)l=l.value,this.set(l[0],l[1])}}function c(){}function d(k){var l=typeof k;return"object"===l&&null!==k||"function"===l}function e(k){if(!H(k,f)){var l=new c;ba(k,f,{value:l})}}function g(k){var l=Object[k];l&&(Object[k]=function(m){if(m instanceof c)return m;Object.isExtensible(m)&&e(m);return l(m)})}if(function(){if(!a||!Object.seal)return!1;try{var k=Object.seal({}),l=Object.seal({}),
m=new a([[k,2],[l,3]]);if(2!=m.get(k)||3!=m.get(l))return!1;m.delete(k);m.set(l,4);return!m.has(k)&&4==m.get(l)}catch(n){return!1}}())return a;var f="$jscomp_hidden_"+Math.random();g("freeze");g("preventExtensions");g("seal");var h=0;b.prototype.set=function(k,l){if(!d(k))throw Error("Invalid WeakMap key");e(k);if(!H(k,f))throw Error("WeakMap key fail: "+k);k[f][this.h]=l;return this};b.prototype.get=function(k){return d(k)&&H(k,f)?k[f][this.h]:void 0};b.prototype.has=function(k){return d(k)&&H(k,
B("Promise",function(a){function b(f){this.A=0;this.B=void 0;this.h=[];this.J=!1;var g=this.C();try{f(g.resolve,g.reject)}catch(k){g.reject(k)}}function c(){this.h=null}function d(f){return f instanceof b?f:new b(function(g){g(f)})}if(a)return a;c.prototype.A=function(f){if(null==this.h){this.h=[];var g=this;this.B(function(){g.F()})}this.h.push(f)};var e=z.setTimeout;c.prototype.B=function(f){e(f,0)};c.prototype.F=function(){for(;this.h&&this.h.length;){var f=this.h;this.h=[];for(var g=0;g<f.length;++g){var k=
f[g];f[g]=null;try{k()}catch(l){this.C(l)}}}this.h=null};c.prototype.C=function(f){this.B(function(){throw f;})};b.prototype.C=function(){function f(l){return function(m){k||(k=!0,l.call(g,m))}}var g=this,k=!1;return{resolve:f(this.ia),reject:f(this.F)}};b.prototype.ia=function(f){if(f===this)this.F(new TypeError("A Promise cannot resolve to itself"));else if(f instanceof b)this.ka(f);else{a:switch(typeof f){case "object":var g=null!=f;break a;case "function":g=!0;break a;default:g=!1}g?this.ha(f):
this.G(f)}};b.prototype.ha=function(f){var g=void 0;try{g=f.then}catch(k){this.F(k);return}"function"==typeof g?this.la(g,f):this.G(f)};b.prototype.F=function(f){this.da(2,f)};b.prototype.G=function(f){this.da(1,f)};b.prototype.da=function(f,g){if(0!=this.A)throw Error("Cannot settle("+f+", "+g+"): Promise already settled in state"+this.A);this.A=f;this.B=g;2===this.A&&this.ja();this.fa()};b.prototype.ja=function(){var f=this;e(function(){if(f.ga()){var g=z.console;"undefined"!==typeof g&&g.error(f.B)}},
1)};b.prototype.ga=function(){if(this.J)return!1;var f=z.CustomEvent,g=z.Event,k=z.dispatchEvent;if("undefined"===typeof k)return!0;"function"===typeof f?f=new f("unhandledrejection",{cancelable:!0}):"function"===typeof g?f=new g("unhandledrejection",{cancelable:!0}):(f=z.document.createEvent("CustomEvent"),f.initCustomEvent("unhandledrejection",!1,!0,f));f.promise=this;f.reason=this.B;return k(f)};b.prototype.fa=function(){if(null!=this.h){for(var f=0;f<this.h.length;++f)h.A(this.h[f]);this.h=null}};
var h=new c;b.prototype.ka=function(f){var g=this.C();f.W(g.resolve,g.reject)};b.prototype.la=function(f,g){var k=this.C();try{f.call(g,k.resolve,k.reject)}catch(l){k.reject(l)}};b.prototype.then=function(f,g){function k(p,q){return"function"==typeof p?function(r){try{l(p(r))}catch(y){m(y)}}:q}var l,m,n=new b(function(p,q){l=p;m=q});this.W(k(f,l),k(g,m));return n};b.prototype.catch=function(f){return this.then(void 0,f)};b.prototype.W=function(f,g){function k(){switch(l.A){case 1:f(l.B);break;case 2:g(l.B);
break;default:throw Error("Unexpected state: "+l.A);}}var l=this;null==this.h?h.A(k):this.h.push(k);this.J=!0};b.resolve=d;b.reject=function(f){return new b(function(g,k){k(f)})};b.race=function(f){return new b(function(g,k){for(var l=x(f),m=l.next();!m.done;m=l.next())d(m.value).W(g,k)})};b.all=function(f){var g=x(f),k=g.next();return k.done?d([]):new b(function(l,m){function n(r){return function(y){p[r]=y;q--;0==q&&l(p)}}var p=[],q=0;do p.push(void 0),q++,d(k.value).W(n(p.length-1),m),k=g.next();
while(!k.done)})};return b});function ua(a,b){a instanceof String&&(a+="");var c=0,d=!1,e={next:function(){if(!d&&c<a.length){var h=c++;return{value:b(h,a[h]),done:!1}}d=!0;return{done:!0,value:void 0}}};e[Symbol.iterator]=function(){return e};return e}B("Array.prototype.values",function(a){return a?a:function(){return ua(this,function(b,c){return c})}});function H(a,b){return Object.prototype.hasOwnProperty.call(a,b)}
B("WeakMap",function(a){function b(k){this.h=(g+=Math.random()+1).toString();if(k){k=x(k);for(var l;!(l=k.next()).done;)l=l.value,this.set(l[0],l[1])}}function c(){}function d(k){var l=typeof k;return"object"===l&&null!==k||"function"===l}function e(k){if(!H(k,f)){var l=new c;ba(k,f,{value:l})}}function h(k){var l=Object[k];l&&(Object[k]=function(m){if(m instanceof c)return m;Object.isExtensible(m)&&e(m);return l(m)})}if(function(){if(!a||!Object.seal)return!1;try{var k=Object.seal({}),l=Object.seal({}),
m=new a([[k,2],[l,3]]);if(2!=m.get(k)||3!=m.get(l))return!1;m.delete(k);m.set(l,4);return!m.has(k)&&4==m.get(l)}catch(n){return!1}}())return a;var f="$jscomp_hidden_"+Math.random();h("freeze");h("preventExtensions");h("seal");var g=0;b.prototype.set=function(k,l){if(!d(k))throw Error("Invalid WeakMap key");e(k);if(!H(k,f))throw Error("WeakMap key fail: "+k);k[f][this.h]=l;return this};b.prototype.get=function(k){return d(k)&&H(k,f)?k[f][this.h]:void 0};b.prototype.has=function(k){return d(k)&&H(k,
f)&&H(k[f],this.h)};b.prototype.delete=function(k){return d(k)&&H(k,f)&&H(k[f],this.h)?delete k[f][this.h]:!1};return b});
B("Map",function(a){function b(){var h={};return h.K=h.next=h.head=h}function c(h,k){var l=h[1];return ta(function(){if(l){for(;l.head!=h[1];)l=l.K;for(;l.next!=l.head;)return l=l.next,{done:!1,value:k(l)};l=null}return{done:!0,value:void 0}})}function d(h,k){var l=k&&typeof k;"object"==l||"function"==l?g.has(k)?l=g.get(k):(l=""+ ++f,g.set(k,l)):l="p_"+k;var m=h[0][l];if(m&&H(h[0],l))for(h=0;h<m.length;h++){var n=m[h];if(k!==k&&n.key!==n.key||k===n.key)return{id:l,list:m,index:h,F:n}}return{id:l,
list:m,index:-1,F:void 0}}function e(h){this[0]={};this[1]=b();this.size=0;if(h){h=x(h);for(var k;!(k=h.next()).done;)k=k.value,this.set(k[0],k[1])}}if(function(){if(!a||"function"!=typeof a||!a.prototype.entries||"function"!=typeof Object.seal)return!1;try{var h=Object.seal({x:4}),k=new a(x([[h,"s"]]));if("s"!=k.get(h)||1!=k.size||k.get({x:4})||k.set({x:4},"t")!=k||2!=k.size)return!1;var l=k.entries(),m=l.next();if(m.done||m.value[0]!=h||"s"!=m.value[1])return!1;m=l.next();return m.done||4!=m.value[0].x||
"t"!=m.value[1]||!l.next().done?!1:!0}catch(n){return!1}}())return a;var g=new WeakMap;e.prototype.set=function(h,k){h=0===h?0:h;var l=d(this,h);l.list||(l.list=this[0][l.id]=[]);l.F?l.F.value=k:(l.F={next:this[1],K:this[1].K,head:this[1],key:h,value:k},l.list.push(l.F),this[1].K.next=l.F,this[1].K=l.F,this.size++);return this};e.prototype.delete=function(h){h=d(this,h);return h.F&&h.list?(h.list.splice(h.index,1),h.list.length||delete this[0][h.id],h.F.K.next=h.F.next,h.F.next.K=h.F.K,h.F.head=null,
this.size--,!0):!1};e.prototype.clear=function(){this[0]={};this[1]=this[1].K=b();this.size=0};e.prototype.has=function(h){return!!d(this,h).F};e.prototype.get=function(h){return(h=d(this,h).F)&&h.value};e.prototype.entries=function(){return c(this,function(h){return[h.key,h.value]})};e.prototype.keys=function(){return c(this,function(h){return h.key})};e.prototype.values=function(){return c(this,function(h){return h.value})};e.prototype.forEach=function(h,k){for(var l=this.entries(),m;!(m=l.next()).done;)m=
m.value,h.call(k,m[1],m[0],this)};e.prototype[Symbol.iterator]=e.prototype.entries;var f=0;return e});B("Array.prototype.keys",function(a){return a?a:function(){return ua(this,function(b){return b})}});
B("Set",function(a){function b(c){this.h=new Map;if(c){c=x(c);for(var d;!(d=c.next()).done;)this.add(d.value)}this.size=this.h.size}if(function(){if(!a||"function"!=typeof a||!a.prototype.entries||"function"!=typeof Object.seal)return!1;try{var c=Object.seal({x:4}),d=new a(x([c]));if(!d.has(c)||1!=d.size||d.add(c)!=d||1!=d.size||d.add({x:4})!=d||2!=d.size)return!1;var e=d.entries(),g=e.next();if(g.done||g.value[0]!=c||g.value[1]!=c)return!1;g=e.next();return g.done||g.value[0]==c||4!=g.value[0].x||
g.value[1]!=g.value[0]?!1:e.next().done}catch(f){return!1}}())return a;b.prototype.add=function(c){c=0===c?0:c;this.h.set(c,c);this.size=this.h.size;return this};b.prototype.delete=function(c){c=this.h.delete(c);this.size=this.h.size;return c};b.prototype.clear=function(){this.h.clear();this.size=0};b.prototype.has=function(c){return this.h.has(c)};b.prototype.entries=function(){return this.h.entries()};b.prototype.values=function(){return this.h.values()};b.prototype.keys=b.prototype.values;b.prototype[Symbol.iterator]=
b.prototype.values;b.prototype.forEach=function(c,d){var e=this;this.h.forEach(function(g){return c.call(d,g,g,e)})};return b});B("Object.is",function(a){return a?a:function(b,c){return b===c?0!==b||1/b===1/c:b!==b&&c!==c}});B("Array.prototype.includes",function(a){return a?a:function(b,c){var d=this;d instanceof String&&(d=String(d));var e=d.length;c=c||0;for(0>c&&(c=Math.max(c+e,0));c<e;c++){var g=d[c];if(g===b||Object.is(g,b))return!0}return!1}});
B("Map",function(a){function b(){var g={};return g.I=g.next=g.head=g}function c(g,k){var l=g[1];return ta(function(){if(l){for(;l.head!=g[1];)l=l.I;for(;l.next!=l.head;)return l=l.next,{done:!1,value:k(l)};l=null}return{done:!0,value:void 0}})}function d(g,k){var l=k&&typeof k;"object"==l||"function"==l?h.has(k)?l=h.get(k):(l=""+ ++f,h.set(k,l)):l="p_"+k;var m=g[0][l];if(m&&H(g[0],l))for(g=0;g<m.length;g++){var n=m[g];if(k!==k&&n.key!==n.key||k===n.key)return{id:l,list:m,index:g,D:n}}return{id:l,
list:m,index:-1,D:void 0}}function e(g){this[0]={};this[1]=b();this.size=0;if(g){g=x(g);for(var k;!(k=g.next()).done;)k=k.value,this.set(k[0],k[1])}}if(function(){if(!a||"function"!=typeof a||!a.prototype.entries||"function"!=typeof Object.seal)return!1;try{var g=Object.seal({x:4}),k=new a(x([[g,"s"]]));if("s"!=k.get(g)||1!=k.size||k.get({x:4})||k.set({x:4},"t")!=k||2!=k.size)return!1;var l=k.entries(),m=l.next();if(m.done||m.value[0]!=g||"s"!=m.value[1])return!1;m=l.next();return m.done||4!=m.value[0].x||
"t"!=m.value[1]||!l.next().done?!1:!0}catch(n){return!1}}())return a;var h=new WeakMap;e.prototype.set=function(g,k){g=0===g?0:g;var l=d(this,g);l.list||(l.list=this[0][l.id]=[]);l.D?l.D.value=k:(l.D={next:this[1],I:this[1].I,head:this[1],key:g,value:k},l.list.push(l.D),this[1].I.next=l.D,this[1].I=l.D,this.size++);return this};e.prototype.delete=function(g){g=d(this,g);return g.D&&g.list?(g.list.splice(g.index,1),g.list.length||delete this[0][g.id],g.D.I.next=g.D.next,g.D.next.I=g.D.I,g.D.head=null,
this.size--,!0):!1};e.prototype.clear=function(){this[0]={};this[1]=this[1].I=b();this.size=0};e.prototype.has=function(g){return!!d(this,g).D};e.prototype.get=function(g){return(g=d(this,g).D)&&g.value};e.prototype.entries=function(){return c(this,function(g){return[g.key,g.value]})};e.prototype.keys=function(){return c(this,function(g){return g.key})};e.prototype.values=function(){return c(this,function(g){return g.value})};e.prototype.forEach=function(g,k){for(var l=this.entries(),m;!(m=l.next()).done;)m=
m.value,g.call(k,m[1],m[0],this)};e.prototype[Symbol.iterator]=e.prototype.entries;var f=0;return e});B("Array.prototype.keys",function(a){return a?a:function(){return ua(this,function(b){return b})}});
B("Set",function(a){function b(c){this.h=new Map;if(c){c=x(c);for(var d;!(d=c.next()).done;)this.add(d.value)}this.size=this.h.size}if(function(){if(!a||"function"!=typeof a||!a.prototype.entries||"function"!=typeof Object.seal)return!1;try{var c=Object.seal({x:4}),d=new a(x([c]));if(!d.has(c)||1!=d.size||d.add(c)!=d||1!=d.size||d.add({x:4})!=d||2!=d.size)return!1;var e=d.entries(),h=e.next();if(h.done||h.value[0]!=c||h.value[1]!=c)return!1;h=e.next();return h.done||h.value[0]==c||4!=h.value[0].x||
h.value[1]!=h.value[0]?!1:e.next().done}catch(f){return!1}}())return a;b.prototype.add=function(c){c=0===c?0:c;this.h.set(c,c);this.size=this.h.size;return this};b.prototype.delete=function(c){c=this.h.delete(c);this.size=this.h.size;return c};b.prototype.clear=function(){this.h.clear();this.size=0};b.prototype.has=function(c){return this.h.has(c)};b.prototype.entries=function(){return this.h.entries()};b.prototype.values=function(){return this.h.values()};b.prototype.keys=b.prototype.values;b.prototype[Symbol.iterator]=
b.prototype.values;b.prototype.forEach=function(c,d){var e=this;this.h.forEach(function(h){return c.call(d,h,h,e)})};return b});B("Object.is",function(a){return a?a:function(b,c){return b===c?0!==b||1/b===1/c:b!==b&&c!==c}});B("Array.prototype.includes",function(a){return a?a:function(b,c){var d=this;d instanceof String&&(d=String(d));var e=d.length;c=c||0;for(0>c&&(c=Math.max(c+e,0));c<e;c++){var h=d[c];if(h===b||Object.is(h,b))return!0}return!1}});
B("String.prototype.includes",function(a){return a?a:function(b,c){if(null==this)throw new TypeError("The 'this' value for String.prototype.includes must not be null or undefined");if(b instanceof RegExp)throw new TypeError("First argument to String.prototype.includes must not be a regular expression");return-1!==this.indexOf(b,c||0)}});B("Array.prototype.entries",function(a){return a?a:function(){return ua(this,function(b,c){return[b,c]})}});
var va="function"==typeof Object.assign?Object.assign:function(a,b){for(var c=1;c<arguments.length;c++){var d=arguments[c];if(d)for(var e in d)H(d,e)&&(a[e]=d[e])}return a};B("Object.assign",function(a){return a||va});B("Array.prototype.flat",function(a){return a?a:function(b){b=void 0===b?1:b;var c=[];Array.prototype.forEach.call(this,function(d){Array.isArray(d)&&0<b?(d=Array.prototype.flat.call(d,b-1),c.push.apply(c,d)):c.push(d)});return c}});function I(a,b,c){var d=typeof c,e=typeof a;if("undefined"!==d){if("undefined"!==e){if(c){if("function"===e&&d===e)return function(g){return a(c(g))};b=a.constructor;if(b===c.constructor){if(b===Array)return c.concat(a);if(b===Map){b=new Map(c);d=x(a);for(e=d.next();!e.done;e=d.next())e=e.value,b.set(e[0],e[1]);return b}if(b===Set){b=new Set(c);d=x(a.values());for(e=d.next();!e.done;e=d.next())b.add(e.value);return b}}}return a}return c}return"undefined"===e?b:a}
var va="function"==typeof Object.assign?Object.assign:function(a,b){for(var c=1;c<arguments.length;c++){var d=arguments[c];if(d)for(var e in d)H(d,e)&&(a[e]=d[e])}return a};B("Object.assign",function(a){return a||va});B("Array.prototype.flat",function(a){return a?a:function(b){b=void 0===b?1:b;var c=[];Array.prototype.forEach.call(this,function(d){Array.isArray(d)&&0<b?(d=Array.prototype.flat.call(d,b-1),c.push.apply(c,d)):c.push(d)});return c}});function I(a,b,c){var d=typeof c,e=typeof a;if("undefined"!==d){if("undefined"!==e){if(c){if("function"===e&&d===e)return function(h){return a(c(h))};b=a.constructor;if(b===c.constructor){if(b===Array)return c.concat(a);if(b===Map){b=new Map(c);d=x(a);for(e=d.next();!e.done;e=d.next())e=e.value,b.set(e[0],e[1]);return b}if(b===Set){b=new Set(c);d=x(a.values());for(e=d.next();!e.done;e=d.next())b.add(e.value);return b}}}return a}return c}return"undefined"===e?b:a}
function K(){return Object.create(null)}function wa(a,b){return b.length-a.length}function L(a){return"string"===typeof a}function M(a){return"object"===typeof a}function xa(a){var b=[];a=x(a.keys());for(var c=a.next();!c.done;c=a.next())b.push(c.value);return b}function ya(a,b){if(L(b))a=a[b];else for(var c=0;a&&c<b.length;c++)a=a[b[c]];return a}function za(a){for(var b=0,c=0,d=void 0;c<a.length;c++)(d=a[c])&&b<d.length&&(b=d.length);return b};var Aa=[["\u00aa","a"],["\u00b2","2"],["\u00b3","3"],["\u00b9","1"],["\u00ba","o"],["\u00bc","1\u20444"],["\u00bd","1\u20442"],["\u00be","3\u20444"],["\u00e0","a"],["\u00e1","a"],["\u00e2","a"],["\u00e3","a"],["\u00e4","a"],["\u00e5","a"],["\u00e7","c"],["\u00e8","e"],["\u00e9","e"],["\u00ea","e"],["\u00eb","e"],["\u00ec","i"],["\u00ed","i"],["\u00ee","i"],["\u00ef","i"],["\u00f1","n"],["\u00f2","o"],["\u00f3","o"],["\u00f4","o"],["\u00f5","o"],["\u00f6","o"],["\u00f9","u"],["\u00fa","u"],["\u00fb",
"u"],["\u00fc","u"],["\u00fd","y"],["\u00ff","y"],["\u0101","a"],["\u0103","a"],["\u0105","a"],["\u0107","c"],["\u0109","c"],["\u010b","c"],["\u010d","c"],["\u010f","d"],["\u0113","e"],["\u0115","e"],["\u0117","e"],["\u0119","e"],["\u011b","e"],["\u011d","g"],["\u011f","g"],["\u0121","g"],["\u0123","g"],["\u0125","h"],["\u0129","i"],["\u012b","i"],["\u012d","i"],["\u012f","i"],["\u0133","ij"],["\u0135","j"],["\u0137","k"],["\u013a","l"],["\u013c","l"],["\u013e","l"],["\u0140","l"],["\u0144","n"],
["\u0146","n"],["\u0148","n"],["\u0149","n"],["\u014d","o"],["\u014f","o"],["\u0151","o"],["\u0155","r"],["\u0157","r"],["\u0159","r"],["\u015b","s"],["\u015d","s"],["\u015f","s"],["\u0161","s"],["\u0163","t"],["\u0165","t"],["\u0169","u"],["\u016b","u"],["\u016d","u"],["\u016f","u"],["\u0171","u"],["\u0173","u"],["\u0175","w"],["\u0177","y"],["\u017a","z"],["\u017c","z"],["\u017e","z"],["\u017f","s"],["\u01a1","o"],["\u01b0","u"],["\u01c6","dz"],["\u01c9","lj"],["\u01cc","nj"],["\u01ce","a"],["\u01d0",
"i"],["\u01d2","o"],["\u01d4","u"],["\u01d6","u"],["\u01d8","u"],["\u01da","u"],["\u01dc","u"],["\u01df","a"],["\u01e1","a"],["\u01e3","ae"],["\u00e6","ae"],["\u01fd","ae"],["\u01e7","g"],["\u01e9","k"],["\u01eb","o"],["\u01ed","o"],["\u01ef","\u0292"],["\u01f0","j"],["\u01f3","dz"],["\u01f5","g"],["\u01f9","n"],["\u01fb","a"],["\u01ff","\u00f8"],["\u0201","a"],["\u0203","a"],["\u0205","e"],["\u0207","e"],["\u0209","i"],["\u020b","i"],["\u020d","o"],["\u020f","o"],["\u0211","r"],["\u0213","r"],["\u0215",
"u"],["\u0217","u"],["\u0219","s"],["\u021b","t"],["\u021f","h"],["\u0227","a"],["\u0229","e"],["\u022b","o"],["\u022d","o"],["\u022f","o"],["\u0231","o"],["\u0233","y"],["\u02b0","h"],["\u02b1","h"],["\u0266","h"],["\u02b2","j"],["\u02b3","r"],["\u02b4","\u0279"],["\u02b5","\u027b"],["\u02b6","\u0281"],["\u02b7","w"],["\u02b8","y"],["\u02e0","\u0263"],["\u02e1","l"],["\u02e2","s"],["\u02e3","x"],["\u02e4","\u0295"],["\u0390","\u03b9"],["\u03ac","\u03b1"],["\u03ad","\u03b5"],["\u03ae","\u03b7"],["\u03af",
"\u03b9"],["\u03b0","\u03c5"],["\u03ca","\u03b9"],["\u03cb","\u03c5"],["\u03cc","\u03bf"],["\u03cd","\u03c5"],["\u03ce","\u03c9"],["\u03d0","\u03b2"],["\u03d1","\u03b8"],["\u03d2","\u03a5"],["\u03d3","\u03a5"],["\u03d4","\u03a5"],["\u03d5","\u03c6"],["\u03d6","\u03c0"],["\u03f0","\u03ba"],["\u03f1","\u03c1"],["\u03f2","\u03c2"],["\u03f5","\u03b5"],["\u0439","\u0438"],["\u0450","\u0435"],["\u0451","\u0435"],["\u0453","\u0433"],["\u0457","\u0456"],["\u045c","\u043a"],["\u045d","\u0438"],["\u045e","\u0443"],
["\u0477","\u0475"],["\u04c2","\u0436"],["\u04d1","\u0430"],["\u04d3","\u0430"],["\u04d7","\u0435"],["\u04db","\u04d9"],["\u04dd","\u0436"],["\u04df","\u0437"],["\u04e3","\u0438"],["\u04e5","\u0438"],["\u04e7","\u043e"],["\u04eb","\u04e9"],["\u04ed","\u044d"],["\u04ef","\u0443"],["\u04f1","\u0443"],["\u04f3","\u0443"],["\u04f5","\u0447"]];var Ba=/[^\p{L}\p{N}]+/u,Ca=/(\d{3})/g,Da=/(\D)(\d{3})/g,Ea=/(\d{3})(\D)/g,Fa="".normalize&&/[\u0300-\u036f]/g;function N(a){if(!this){var b=Function.prototype.bind,c=b.apply,d=[null],e=d.concat;if(arguments instanceof Array)var g=arguments;else{g=x(arguments);for(var f,h=[];!(f=g.next()).done;)h.push(f.value);g=h}return new (c.call(b,N,e.call(d,g)))}for(b=0;b<arguments.length;b++)this.assign(arguments[b])}
["\u0477","\u0475"],["\u04c2","\u0436"],["\u04d1","\u0430"],["\u04d3","\u0430"],["\u04d7","\u0435"],["\u04db","\u04d9"],["\u04dd","\u0436"],["\u04df","\u0437"],["\u04e3","\u0438"],["\u04e5","\u0438"],["\u04e7","\u043e"],["\u04eb","\u04e9"],["\u04ed","\u044d"],["\u04ef","\u0443"],["\u04f1","\u0443"],["\u04f3","\u0443"],["\u04f5","\u0447"]];var Ba=/[^\p{L}\p{N}]+/u,Ca=/(\d{3})/g,Da=/(\D)(\d{3})/g,Ea=/(\d{3})(\D)/g,Fa="".normalize&&/[\u0300-\u036f]/g;function N(a){if(!this){var b=Function.prototype.bind,c=b.apply,d=[null],e=d.concat;if(arguments instanceof Array)var h=arguments;else{h=x(arguments);for(var f,g=[];!(f=h.next()).done;)g.push(f.value);h=g}return new (c.call(b,N,e.call(d,h)))}for(b=0;b<arguments.length;b++)this.assign(arguments[b])}
N.prototype.assign=function(a){this.normalize=I(a.normalize,!0,this.normalize);var b=a.include,c=b||a.exclude||a.split;if("object"===typeof c){var d=!b,e="";a.include||(e+="\\p{Z}");c.letter&&(e+="\\p{L}");c.number&&(e+="\\p{N}",d=!!b);c.symbol&&(e+="\\p{S}");c.punctuation&&(e+="\\p{P}");c.control&&(e+="\\p{C}");if(c=c.char)e+="object"===typeof c?c.join(""):c;this.split=new RegExp("["+(b?"^":"")+e+"]+","u");this.numeric=d}else this.split=I(c,Ba,this.split),this.numeric=I(this.numeric,!0);this.prepare=
I(a.prepare,null,this.prepare);this.finalize=I(a.finalize,null,this.finalize);Fa||(this.mapper=new Map(Aa));this.rtl=a.rtl||!1;this.dedupe=I(a.dedupe,!0,this.dedupe);this.filter=I((c=a.filter)&&new Set(c),null,this.filter);this.matcher=I((c=a.matcher)&&new Map(c),null,this.matcher);this.mapper=I((c=a.mapper)&&new Map(c),null,this.mapper);this.stemmer=I((c=a.stemmer)&&new Map(c),null,this.stemmer);this.replacer=I(a.replacer,null,this.replacer);this.minlength=I(a.minlength,1,this.minlength);this.maxlength=
I(a.maxlength,0,this.maxlength);if(this.cache=c=I(a.cache,!0,this.cache))this.X=null,this.L="number"===typeof c?c:2E5,this.P=new Map,this.V=new Map,this.A=this.h=128;this.C="";this.G=null;this.D="";this.H=null;if(this.matcher)for(a=x(this.matcher.keys()),b=a.next();!b.done;b=a.next())this.C+=(this.C?"|":"")+b.value;if(this.stemmer)for(a=x(this.stemmer.keys()),b=a.next();!b.done;b=a.next())this.D+=(this.D?"|":"")+b.value;return this};
N.prototype.encode=function(a){var b=this;if(this.cache&&a.length<=this.h)if(this.X){if(this.P.has(a))return this.P.get(a)}else this.X=setTimeout(Ga,0,this);this.normalize&&(a="function"===typeof this.normalize?this.normalize(a):Fa?a.normalize("NFKD").replace(Fa,"").toLowerCase():a.toLowerCase());this.prepare&&(a=this.prepare(a));this.numeric&&3<a.length&&(a=a.replace(Da,"$1 $2").replace(Ea,"$1 $2").replace(Ca,"$1 "));for(var c=!(this.dedupe||this.mapper||this.filter||this.matcher||this.stemmer||
this.replacer),d=[],e=this.split||""===this.split?a.split(this.split):a,g=0,f=void 0,h=void 0;g<e.length;g++)if((f=h=e[g])&&!(f.length<this.minlength))if(c)d.push(f);else if(!this.filter||!this.filter.has(f)){if(this.cache&&f.length<=this.A)if(this.X){var k=this.V.get(f);if(k||""===k){k&&d.push(k);continue}}else this.X=setTimeout(Ga,0,this);k=void 0;this.stemmer&&2<f.length&&(this.H||(this.H=new RegExp("(?!^)("+this.D+")$")),f=f.replace(this.H,function(q){return b.stemmer.get(q)}),k=1);this.matcher&&
1<f.length&&(this.G||(this.G=new RegExp("("+this.C+")","g")),f=f.replace(this.G,function(q){return b.matcher.get(q)}),k=1);f&&k&&(f.length<this.minlength||this.filter&&this.filter.has(f))&&(f="");if(f&&(this.mapper||this.dedupe&&1<f.length)){k="";for(var l=0,m="",n=void 0,p=void 0;l<f.length;l++)n=f.charAt(l),n===m&&this.dedupe||((p=this.mapper&&this.mapper.get(n))||""===p?p===m&&this.dedupe||!(m=p)||(k+=p):k+=m=n);f=k}if(f&&this.replacer)for(k=0;f&&k<this.replacer.length;k+=2)f=f.replace(this.replacer[k],
this.replacer[k+1]);this.cache&&h.length<=this.A&&(this.V.set(h,f),this.V.size>this.L&&(this.V.clear(),this.A=this.A/1.1|0));f&&d.push(f)}this.finalize&&(d=this.finalize(d)||d);this.cache&&a.length<=this.h&&(this.P.set(a,d),this.P.size>this.L&&(this.P.clear(),this.h=this.h/1.1|0));return d};function Ga(a){a.X=null;a.P.clear();a.V.clear()};function Ha(a,b,c){a=("object"===typeof a?""+a.query:a).toLowerCase();var d=this.cache.get(a);if(!d){d=this.search(a,b,c);if(d.then){var e=this;d.then(function(g){e.cache.set(a,g);return g})}this.cache.set(a,d)}return d}function Q(a){this.limit=a&&!0!==a?a:1E3;this.cache=new Map;this.h=""}Q.prototype.set=function(a,b){this.cache.set(this.h=a,b);this.cache.size>this.limit&&this.cache.delete(this.cache.keys().next().value)};
Q.prototype.get=function(a){var b=this.cache.get(a);b&&this.h!==a&&(this.cache.delete(a),this.cache.set(this.h=a,b));return b};Q.prototype.remove=function(a){for(var b=x(this.cache),c=b.next();!c.done;c=b.next()){c=c.value;var d=c[0];c[1].includes(a)&&this.cache.delete(d)}};Q.prototype.clear=function(){this.cache.clear();this.h=""};var Ia={normalize:function(a){return a.toLowerCase()},dedupe:!1};var Ja=new Map([["b","p"],["v","f"],["w","f"],["z","s"],["x","s"],["d","t"],["n","m"],["c","k"],["g","k"],["j","k"],["q","k"],["i","e"],["y","e"],["u","o"]]);var Ka=new Map([["ai","ei"],["ae","a"],["oe","o"],["ue","u"],["sh","s"],["ch","c"],["th","t"],["ph","f"],["pf","f"]]),La=[/([^aeo])h([aeo$])/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2"];var Ma={a:"",e:"",i:"",o:"",u:"",y:"",b:1,f:1,p:1,v:1,c:2,g:2,j:2,k:2,q:2,s:2,x:2,z:2,"\u00df":2,d:3,t:3,l:4,m:5,n:5,r:6};var Na=/[\x00-\x7F]+/g;var Oa=/[\x00-\x7F]+/g;var Pa=/[\x00-\x7F]+/g;var Qa={LatinExact:{normalize:!1,dedupe:!1},LatinDefault:Ia,LatinSimple:{normalize:!0,dedupe:!0},LatinBalance:{normalize:!0,dedupe:!0,mapper:Ja},LatinAdvanced:{normalize:!0,dedupe:!0,mapper:Ja,replacer:La,matcher:Ka},LatinExtra:{normalize:!0,dedupe:!0,mapper:Ja,replacer:La.concat([/(?!^)[aeoy]/g,""]),matcher:Ka},LatinSoundex:{normalize:!0,dedupe:!1,include:{letter:!0},finalize:function(a){for(var b=0;b<a.length;b++){for(var c=a[b],d=c.charAt(0),e=Ma[d],g=1,f;g<c.length&&(f=c.charAt(g),"h"===f||"w"===
f||!(f=Ma[f])||f===e||(d+=f,e=f,4!==d.length));g++);a[b]=d}}},ArabicDefault:{rtl:!0,normalize:!1,dedupe:!0,prepare:function(a){return(""+a).replace(Na," ")}},CjkDefault:{normalize:!1,dedupe:!0,split:"",prepare:function(a){return(""+a).replace(Oa,"")}},CyrillicDefault:{normalize:!1,dedupe:!0,prepare:function(a){return(""+a).replace(Pa," ")}}};function Ra(a,b,c,d){for(var e=[],g=0,f;g<a.index.length;g++)if(f=a.index[g],b>=f.length)b-=f.length;else{b=f[d?"splice":"slice"](b,c);if(f=b.length)if(e=e.length?e.concat(b):b,c-=f,d&&(a.length-=f),!c)break;b=0}return e}
function R(a){if(!this)return new R(a);this.index=a?[a]:[];this.length=a?a.length:0;var b=this;return new Proxy([],{get:function(c,d){if("length"===d)return b.length;if("push"===d)return function(e){b.index[b.index.length-1].push(e);b.length++};if("pop"===d)return function(){if(b.length)return b.length--,b.index[b.index.length-1].pop()};if("indexOf"===d)return function(e){for(var g=0,f=0,h,k;f<b.index.length;f++){h=b.index[f];k=h.indexOf(e);if(0<=k)return g+k;g+=h.length}return-1};if("includes"===
d)return function(e){for(var g=0;g<b.index.length;g++)if(b.index[g].includes(e))return!0;return!1};if("slice"===d)return function(e,g){return Ra(b,e||0,g||b.length,!1)};if("splice"===d)return function(e,g){return Ra(b,e||0,g||b.length,!0)};if("constructor"===d)return Array;if("symbol"!==typeof d)return(c=b.index[d/Math.pow(2,31)|0])&&c[d]},set:function(c,d,e){c=d/Math.pow(2,31)|0;(b.index[c]||(b.index[c]=[]))[d]=e;b.length++;return!0}})}R.prototype.clear=function(){this.index.length=0};
R.prototype.push=function(){};function S(a){a=void 0===a?8:a;if(!this)return new S(a);this.index=K();this.C=[];this.size=0;32<a?(this.h=Sa,this.A=BigInt(a)):(this.h=Ta,this.A=a)}S.prototype.get=function(a){var b=this.h(a);return(b=this.index[b])&&b.get(a)};S.prototype.set=function(a,b){var c=this.h(a),d=this.index[c];d?(c=d.size,d.set(a,b),(c-=d.size)&&this.size++):(this.index[c]=d=new Map([[a,b]]),this.C.push(d))};
function T(a){a=void 0===a?8:a;if(!this)return new T(a);this.index=K();this.h=[];32<a?(this.C=Sa,this.A=BigInt(a)):(this.C=Ta,this.A=a)}T.prototype.add=function(a){var b=this.C(a),c=this.index[b];c?(b=c.size,c.add(a),(b-=c.size)&&this.size++):(this.index[b]=c=new Set([a]),this.h.push(c))};w=S.prototype;w.has=T.prototype.has=function(a){var b=this.C(a);return(b=this.index[b])&&b.has(a)};w.delete=T.prototype.delete=function(a){var b=this.C(a);(b=this.index[b])&&b.delete(a)&&this.size--};
w.clear=T.prototype.clear=function(){this.index=K();this.h=[];this.size=0};w.values=T.prototype.values=function Ua(){var b,c=this,d,e,g;return qa(Ua,function(f){switch(f.h){case 1:b=0;case 2:if(!(b<c.h.length)){f.h=0;break}d=x(c.h[b].values());e=d.next();case 5:if(e.done){b++;f.h=2;break}g=e.value;return F(f,g,6);case 6:e=d.next(),f.h=5}})};
w.keys=T.prototype.keys=function Va(){var b,c=this,d,e,g;return qa(Va,function(f){switch(f.h){case 1:b=0;case 2:if(!(b<c.h.length)){f.h=0;break}d=x(c.h[b].keys());e=d.next();case 5:if(e.done){b++;f.h=2;break}g=e.value;return F(f,g,6);case 6:e=d.next(),f.h=5}})};
w.entries=T.prototype.entries=function Wa(){var b,c=this,d,e,g;return qa(Wa,function(f){switch(f.h){case 1:b=0;case 2:if(!(b<c.h.length)){f.h=0;break}d=x(c.h[b].entries());e=d.next();case 5:if(e.done){b++;f.h=2;break}g=e.value;return F(f,g,6);case 6:e=d.next(),f.h=5}})};function Ta(a){var b=Math.pow(2,this.A)-1;if("number"==typeof a)return a&b;for(var c=0,d=this.A+1,e=0;e<a.length;e++)c=(c*d^a.charCodeAt(e))&b;return 32===this.A?c+Math.pow(2,31):c}
function Sa(){throw Error("The keystore is limited to 32 for EcmaScript5");};function Xa(a,b,c,d,e,g,f,h){(d=a(c?c+"."+d:d,JSON.stringify(f)))&&d.then?d.then(function(){b.export(a,b,c,e,g+1,h)}):b.export(a,b,c,e,g+1,h)};var Ya={memory:{resolution:1},performance:{resolution:6,fastupdate:!0,context:{depth:1,resolution:3}},match:{tokenize:"forward"},score:{resolution:9,context:{depth:2,resolution:9}}};function Za(a){U.call(a,"add");U.call(a,"append");U.call(a,"search");U.call(a,"update");U.call(a,"remove")}function U(a){this[a+"Async"]=function(){var b=arguments,c=b[b.length-1];if("function"===typeof c){var d=c;delete b[b.length-1]}this.async=!0;b=this[a].apply(this,b);this.async=!1;d&&(b.then?b.then(d):d(b));return b}};K();V.prototype.add=function(a,b,c,d){if(b&&(a||0===a)){if(!d&&!c&&this.B.has(a))return this.update(a,b);b=this.encoder.encode(b);if(d=b.length){for(var e=K(),g=K(),f=this.depth,h=this.resolution,k=0;k<d;k++){var l=b[this.rtl?d-1-k:k],m=l.length;if(m&&(f||!g[l])){var n=this.score?this.score(b,l,k,null,0):$a(h,d,k),p="";switch(this.tokenize){case "full":if(2<m){for(n=0;n<m;n++)for(var q=m;q>n;q--){p=l.substring(n,q);var r=this.score?this.score(b,l,k,p,n):$a(h,d,k,m,n);ab(this,g,p,r,a,c)}break}case "reverse":if(1<
m){for(q=m-1;0<q;q--)p=l[q]+p,r=this.score?this.score(b,l,k,p,q):$a(h,d,k,m,q),ab(this,g,p,r,a,c);p=""}case "forward":if(1<m){for(q=0;q<m;q++)p+=l[q],ab(this,g,p,n,a,c);break}default:if(ab(this,g,l,n,a,c),f&&1<d&&k<d-1)for(m=K(),p=this.da,n=l,q=Math.min(f+1,d-k),r=m[n]=1;r<q;r++)if((l=b[this.rtl?d-1-k-r:k+r])&&!m[l]){m[l]=1;var y=this.score?this.score(b,n,k,l,r):$a(p+(d/2>p?0:1),d,k,q-1,r-1),u=this.bidirectional&&l>n;ab(this,e,u?n:l,y,a,c,u?l:n)}}}}this.fastupdate||this.B.add(a)}else b=""}this.db&&
(b||this.R.push({del:a}),this.ga&&bb(this));return this};
function ab(a,b,c,d,e,g,f){var h=f?a.J:a.map,k;if(!b[c]||!f||!(k=b[c])[f])if(f?(b=k||(b[c]=K()),b[f]=1,(k=h.get(f))?h=k:h.set(f,h=new Map)):b[c]=1,(k=h.get(c))?h=k:h.set(c,h=k=[]),h=h[d]||(h[d]=[]),!g||!h.includes(e)){if(h.length===Math.pow(2,31)-1){b=new R(h);if(a.fastupdate)for(c=x(a.B.values()),g=c.next();!g.done;g=c.next())g=g.value,g.includes(h)&&(g[g.indexOf(h)]=b);k[d]=h=b}h.push(e);a.fastupdate&&((d=a.B.get(e))?d.push(h):a.B.set(e,[h]))}}
function $a(a,b,c,d,e){return c&&1<a?b+(d||0)<=a?c+(e||0):(a-1)/(b+(d||0))*(c+(e||0))+1|0:0};function W(a,b,c,d){if(1===a.length)return a=a[0],a=c||a.length>b?b?a.slice(c,c+b):a.slice(c):a,d?cb(a):a;for(var e=[],g=0,f=void 0,h=void 0;g<a.length;g++)if((f=a[g])&&(h=f.length)){if(c){if(c>=h){c-=h;continue}c<h&&(f=b?f.slice(c,c+b):f.slice(c),h=f.length,c=0)}if(e.length)h>b&&(f=f.slice(0,b),h=f.length),e.push(f);else{if(h>=b)return h>b&&(f=f.slice(0,b)),d?cb(f):f;e=[f]}b-=h;if(!b)break}if(!e.length)return e;e=1<e.length?[].concat.apply([],e):e[0];return d?cb(e):e}
function cb(a){for(var b=0;b<a.length;b++)a[b]={score:b,id:a[b]};return a};X.prototype.or=function(){var a=this,b=arguments,c=b[0];if(c.then)return c.then(function(){return a.or.apply(a,b)});if(c[0]&&c[0].index)return this.or.apply(this,c);var d=[];c=[];for(var e=0,g=0,f,h,k=0,l=void 0;k<b.length;k++)if(l=b[k]){var m=void 0;if(l.constructor===X)m=l.result;else if(l.constructor===Array)m=l;else if(l.index)l.resolve=!1,m=l.index.search(l).result;else if(l.and)m=this.and(l.and);else if(l.xor)m=this.xor(l.xor);else if(l.not)m=this.not(l.not);else{e=l.limit||0;g=l.offset||0;
f=l.enrich;h=l.resolve;continue}d[k]=m;m.then&&c.push(m)}if(c.length)return Promise.all(c).then(function(){a.result.length&&(d=[a.result].concat(d));a.result=db(d,e,g,f,h,a.M);return h?a.result:a});this.result.length&&(d=[this.result].concat(d));this.result=db(d,e,g,f,h,a.M);return h?this.result:this};
function db(a,b,c,d,e,g){if(!a.length)return a;"object"===typeof b&&(c=b.offset||0,d=b.enrich||!1,b=b.limit||0);if(2>a.length)return e?W(a[0],b,c,d):a[0];d=[];for(var f=0,h=K(),k=za(a),l=0,m;l<k;l++)for(var n=0;n<a.length;n++)if(m=a[n])if(m=m[l])for(var p=0,q;p<m.length;p++)if(q=m[p],!h[q])if(h[q]=1,c)c--;else{if(e)d.push(q);else{var r=l+(n?g:0);d[r]||(d[r]=[]);d[r].push(q)}if(b&&++f===b)return d}return d};X.prototype.and=function(){if(this.result.length){var a=this,b=arguments,c=b[0];if(c.then)return c.then(function(){return a.and.apply(a,b)});if(c[0]&&c[0].index)return this.and.apply(this,c);var d=[];c=[];for(var e=0,g=0,f,h=0,k=void 0;h<b.length;h++)if(k=b[h]){var l=void 0;if(k.constructor===X)l=k.result;else if(k.constructor===Array)l=k;else if(k.index)k.resolve=!1,l=k.index.search(k).result;else if(k.or)l=this.or(k.or);else if(k.xor)l=this.xor(k.xor);else if(k.not)l=this.not(k.not);else{e=k.limit||
0;g=k.offset||0;f=k.resolve;continue}d[h]=l;l.then&&c.push(l)}if(c.length)return Promise.all(c).then(function(){d=[a.result].concat(d);a.result=eb(d,e,g,f,a.M);return f?a.result:a});d=[this.result].concat(d);this.result=eb(d,e,g,f,a.M);return f?this.result:this}return this};
function eb(a,b,c,d,e){if(2>a.length)return[];var g=[],f=0,h=K(),k=za(a);if(!k)return g;for(var l=0,m;l<a.length;l++){m=a[l];if(!m||!m.length)return[];for(var n=K(),p=0,q=l===a.length-1,r=0,y;r<k;r++)if(y=m[r])for(var u=0,t,v;u<y.length;u++)if(t=y[u],!l)n[t]=r+1+(l?e:0),p=1;else if(q){if(v=h[t])if(p=1,c)c--;else if(d?g.push(t):(v--,r<v&&(v=r),g[v]||(g[v]=[]),g[v].push(t)),b&&++f===b)return g}else if(v=h[t])r+1<v&&(v=r+1),n[t]=v,p=1;if(!p)return[];h=n}return g};X.prototype.xor=function(){var a=this,b=arguments,c=b[0];if(c.then)return c.then(function(){return a.xor.apply(a,b)});if(c[0]&&c[0].index)return this.xor.apply(this,c);var d=[];c=[];for(var e=0,g=0,f,h,k=0,l=void 0;k<b.length;k++)if(l=b[k]){var m=void 0;if(l.constructor===X)m=l.result;else if(l.constructor===Array)m=l;else if(l.index)l.resolve=!1,m=l.index.search(l).result;else if(l.or)m=this.or(l.or);else if(l.and)m=this.and(l.and);else if(l.not)m=this.not(l.not);else{e=l.limit||0;g=l.offset||0;
f=l.enrich;h=l.resolve;continue}d[k]=m;m.then&&c.push(m)}if(c.length)return Promise.all(c).then(function(){a.result.length&&(d=[a.result].concat(d));a.result=fb(d,e,g,f,!h,a.M);return h?a.result:a});this.result.length&&(d=[this.result].concat(d));this.result=fb(d,e,g,f,!h,a.M);return h?this.result:this};
function fb(a,b,c,d,e,g){if(!a.length)return a;if(2>a.length)return e?W(a[0],b,c,d):a[0];b=[];c=K();d=0;for(var f;d<a.length;d++)if(f=a[d])for(var h=0,k;h<f.length;h++)if(k=f[h])for(var l=0,m;l<k.length;l++)m=k[l],c[m]?c[m]++:c[m]=1;for(d=0;d<a.length;d++)if(f=a[d])for(h=0;h<f.length;h++)if(k=f[h])for(l=0;l<k.length;l++)if(m=k[l],1===c[m])if(e)b.push(m);else{var n=h+(d?g:0);b[n]||(b[n]=[]);b[n].push(m)}return b};X.prototype.not=function(){var a=this,b=arguments,c=b[0];if(c.then)return c.then(function(){return a.not.apply(a,b)});if(c[0]&&c[0].index)return this.not.apply(this,c);var d=[];c=[];for(var e,g=0,f=void 0;g<b.length;g++)if(f=b[g]){var h=void 0;if(f.constructor===X)h=f.result;else if(f.constructor===Array)h=f;else if(f.index)f.resolve=!1,h=f.index.search(f).result;else if(f.or)h=this.or(f.or);else if(f.and)h=this.and(f.and);else if(f.xor)h=this.xor(f.xor);else{e=f.resolve;continue}d[g]=h;h.then&&c.push(h)}if(c.length)return Promise.all(c).then(function(){a.result=
gb.call(a,d,e);return e?a.result:a});this.result=gb.call(this,d,e);return e?this.result:this};function gb(a,b){if(!a.length)return this.result;var c=[];a=new Set(a.flat().flat());for(var d=0,e;d<this.result.length;d++)if(e=this.result[d])for(var g=0,f;g<e.length;g++)f=e[g],a.has(f)||(b?c.push(f):(c[d]||(c[d]=[]),c[d].push(f)));return c};function X(a){if(!this)return new X(a);if(a&&a.index)return a.resolve=!1,this.index=a.index,a.index.search(a);if(a.constructor===X)return a;this.index=null;this.result=a||[];this.M=0}X.prototype.limit=function(a){if(this.result.length)for(var b=[],c=0,d=0,e;d<this.result.length;d++)if(e=this.result[d],e.length+c<a)b[d]=e,c+=e.length;else{b[d]=e.slice(0,a-c);this.result=b;break}return this};
X.prototype.offset=function(a){if(this.result.length){for(var b=[],c=0,d=0,e;d<this.result.length;d++)e=this.result[d],e.length+c<a?c+=e.length:(b[d]=e.slice(a-c),c=a);this.result=b}return this};X.prototype.boost=function(a){this.M+=a;return this};X.prototype.resolve=function(a,b,c){hb=1;var d=this.result;this.result=this.index=null;return d.length?("object"===typeof a&&(c=a.enrich,b=a.offset,a=a.limit),W(d,a||100,b,c)):d};function ib(a,b,c,d,e){var g=a.length,f=[],h;var k=K();for(var l=0,m=void 0,n;l<b;l++)for(var p=0;p<g;p++)if(n=a[p],l<n.length&&(m=n[l]))for(var q=0;q<m.length;q++)n=m[q],(h=k[n])?k[n]++:(h=0,k[n]=1),h=f[h]||(f[h]=[]),h.push(n);if(a=f.length)if(e){if(1<f.length){e=f;g=[];f=K();k=e.length;for(m=0;m<k;m++)for(a=e[m],l=a.length,p=0;p<l;p++)if(b=a[p],!f[b])if(f[b]=1,d)d--;else if(g.push(b),g.length===c)break;c=g}else c=f[0];f=c}else{if(a<g)return[];f=f[a-1];if(f.length>c||d)f=f.slice(d,c+d)}return f}
function jb(a,b){for(var c=K(),d=K(),e=[],g=0;g<a.length;g++)c[a[g]]=1;for(a=0;a<b.length;a++){g=b[a];for(var f=0,h;f<g.length;f++)h=g[f],c[h]&&!d[h]&&(d[h]=1,e.push(h))}return e};var hb=1;
V.prototype.search=function(a,b,c){c||(!b&&M(a)?(c=a,a=""):M(b)&&(c=b,b=0));var d=[],e=0,g;if(c){a=c.query||a;b=c.limit||b;e=c.offset||0;var f=c.context;var h=c.suggest;(g=hb&&!1!==c.resolve)||(hb=0);var k=g&&c.enrich;var l=this.db&&c.tag}else g=this.resolve||hb;a=this.encoder.encode(a);var m=a.length;b||!g||(b=100);if(1===m)return kb.call(this,a[0],"",b,e,g,k,l);f=this.depth&&!1!==f;if(2===m&&f&&!h)return kb.call(this,a[0],a[1],b,e,g,k,l);var n=c=0;if(1<m){for(var p=K(),q=[],r=0,y=void 0;r<m;r++)if((y=
a[r])&&!p[y]){if(h||this.db||Y(this,y))q.push(y),p[y]=1;else return g?d:new X(d);y=y.length;c=Math.max(c,y);n=n?Math.min(n,y):y}a=q;m=a.length}if(!m)return g?d:new X(d);var u=0;if(1===m)return kb.call(this,a[0],"",b,e,g,k,l);if(2===m&&f&&!h)return kb.call(this,a[0],a[1],b,e,g,k,l);if(1<m)if(f){var t=a[0];u=1}else 9<c&&3<c/n&&a.sort(wa);if(this.db){if(this.db.search&&(f=this.db.search(this,a,b,e,h,g,k,l),!1!==f))return f;var v=this;return function(){var A,C,D;return sa(function(E){switch(E.h){case 1:C=
A=void 0;case 2:if(!(u<m)){E.h=4;break}C=a[u];return t?F(E,Y(v,C,t),8):F(E,Y(v,C),7);case 7:A=E.G;A=lb(A,d,h,v.resolution,b,e,1===m);E.h=6;break;case 8:A=E.G,A=lb(A,d,h,v.da,b,e,2===m),h&&!1===A&&d.length||(t=C);case 6:if(A)return E.return(A);if(h&&u===m-1){D=d.length;if(!D){if(t){t="";u=-1;E.h=3;break}return E.return(d)}if(1===D)return E.return(g?W(d[0],b,e):new X(d[0]))}case 3:u++;E.h=2;break;case 4:return E.return(g?ib(d,v.resolution,b,e,h):new X(d[0]))}})}()}for(k=f=void 0;u<m;u++){k=a[u];t?(f=
Y(this,k,t),f=lb(f,d,h,this.da,b,e,2===m),h&&!1===f&&d.length||(t=k)):(f=Y(this,k),f=lb(f,d,h,this.resolution,b,e,1===m));if(f)return f;if(h&&u===m-1){f=d.length;if(!f){if(t){t="";u=-1;continue}return d}if(1===f)return g?W(d[0],b,e):new X(d[0])}}d=ib(d,this.resolution,b,e,h);return g?d:new X(d)};function kb(a,b,c,d,e,g,f){a=Y(this,a,b,c,d,e,g,f);return this.db?a.then(function(h){return e?h:h&&h.length?e?W(h,c,d):new X(h):e?[]:new X([])}):a&&a.length?e?W(a,c,d):new X(a):e?[]:new X([])}
function lb(a,b,c,d,e,g,f){var h=[];if(a){d=Math.min(a.length,d);for(var k=0,l=0,m;k<d;k++)if(m=a[k])if(g&&m&&f&&(m.length<=g?(g-=m.length,m=null):(m=m.slice(g),g=0)),m&&(h[k]=m,f&&(l+=m.length,l>=e)))break;if(h.length){if(f)return W(h,e,0);b.push(h);return}}return!c&&h}function Y(a,b,c,d,e,g,f,h){var k;c&&(k=a.bidirectional&&b>c);if(a.db)return c?a.db.get(k?c:b,k?b:c,d,e,g,f,h):a.db.get(b,"",d,e,g,f,h);a=c?(a=a.J.get(k?b:c))&&a.get(k?c:b):a.map.get(b);return a};V.prototype.remove=function(a,b){var c=this.B.size&&(this.fastupdate?this.B.get(a):this.B.has(a));if(c){if(this.fastupdate)for(var d=0,e;d<c.length;d++){if(e=c[d])if(2>e.length)e.pop();else{var g=e.indexOf(a);g===c.length-1?e.pop():e.splice(g,1)}}else mb(this.map,a),this.depth&&mb(this.J,a);b||this.B.delete(a)}this.db&&(this.R.push({del:a}),this.ga&&bb(this));this.cache&&this.cache.remove(a);return this};
function mb(a,b){var c=0;if(a.constructor===Array)for(var d=0,e=void 0,g;d<a.length;d++){if((e=a[d])&&e.length)if(g=e.indexOf(b),0<=g){1<e.length?(e.splice(g,1),c++):delete a[d];break}else c++}else for(d=x(a),e=d.next();!e.done;e=d.next())g=e.value,e=g[0],(g=mb(g[1],b))?c+=g:a.delete(e);return c};function V(a,b){if(!this)return new V(a);if(a){var c=L(a)?a:a.preset;c&&(a=Object.assign({},Ya[c],a))}else a={};c=a.context||{};var d=a.encode||a.encoder||Ia;this.encoder=d.encode?d:"object"===typeof d?new N(d):{encode:d};var e;this.resolution=a.resolution||9;this.tokenize=e=a.tokenize||"strict";this.depth="strict"===e&&c.depth||0;this.bidirectional=!1!==c.bidirectional;this.fastupdate=!!a.fastupdate;this.score=a.score||null;(e=a.keystore||0)&&(this.keystore=e);this.map=e?new S(e):new Map;this.J=
e?new S(e):new Map;this.B=b||(this.fastupdate?e?new S(e):new Map:e?new T(e):new Set);this.da=c.resolution||1;this.rtl=d.rtl||a.rtl||!1;this.cache=(e=a.cache||null)&&new Q(e);this.resolve=!1!==a.resolve;if(e=a.db)this.db=e.mount(this);this.ga=!1!==a.commit;this.R=[];this.h=null}w=V.prototype;w.mount=function(a){this.h&&(clearTimeout(this.h),this.h=null);return a.mount(this)};w.commit=function(a,b){this.h&&(clearTimeout(this.h),this.h=null);return this.db.commit(this,a,b)};
function bb(a){a.h||(a.h=setTimeout(function(){a.h=null;a.db.commit(a,void 0,void 0)},0))}w.clear=function(){this.map.clear();this.J.clear();this.B.clear();this.cache&&this.cache.clear();this.db&&(this.h&&clearTimeout(this.h),this.h=null,this.R=[{clear:!0}]);return this};w.append=function(a,b){return this.add(a,b,!0)};w.contain=function(a){return this.db?this.db.has(a):this.B.has(a)};
w.update=function(a,b){if(this.async){var c=this,d=this.remove(a);return d.then?d.then(function(){return c.add(a,b)}):this.add(a,b)}return this.remove(a).add(a,b)};function nb(a){var b=0;if(a.constructor===Array)for(var c=0,d=void 0;c<a.length;c++)(d=a[c])&&(b+=d.length);else for(c=x(a),d=c.next();!d.done;d=c.next()){var e=d.value;d=e[0];(e=nb(e[1]))?b+=e:a.delete(d)}return b}w.cleanup=function(){if(!this.fastupdate)return this;nb(this.map);this.depth&&nb(this.J);return this};w.searchCache=Ha;
w.export=function(a,b,c,d,e,g){var f=!0;"undefined"===typeof g&&(f=new Promise(function(n){g=n}));switch(e||(e=0)){case 0:var h="reg";if(this.fastupdate){var k=K();for(var l=x(this.B.keys()),m=l.next();!m.done;m=l.next())k[m.value]=1}else k=this.B;break;case 1:h="cfg";k={doc:0,opt:this.A?1:0};break;case 2:h="map";k=this.map;break;case 3:h="ctx";k=this.J;break;default:"undefined"===typeof c&&g&&g();return}Xa(a,b||this,c,h,d,e,k,g);return f};
w.import=function(a,b){if(b)switch(L(b)&&(b=JSON.parse(b)),a){case "cfg":this.A=!!b.opt;break;case "reg":this.fastupdate=!1;this.B=b;break;case "map":this.map=b;break;case "ctx":this.J=b}};Za(V.prototype);function ob(a){var b,c,d,e,g,f,h,k;return sa(function(l){a=a.data;b=self._index;c=a.args;d=a.task;switch(d){case "init":e=a.options||{};(g=e.config)&&(e=await import(g));(f=a.factory)?(Function("return "+f)()(self),self._index=new self.FlexSearch.Index(e),delete self.FlexSearch):self._index=new V(e);postMessage({id:a.id});break;default:h=a.id,k=b[d].apply(b,c),postMessage("search"===d?{id:h,msg:k}:{id:h})}l.h=0})};var pb=0;
function qb(a){function b(g){g=g.data||g;var f=g.id,h=f&&e.h[f];h&&(h(g.msg),delete e.h[f])}if(!this)return new qb(a);a||(a={});var c=(self||window)._factory;c&&(c=c.toString());var d="undefined"===typeof window&&self.exports,e=this;this.worker=rb(c,d,a.worker);this.h=K();if(this.worker){d?this.worker.on("message",b):this.worker.onmessage=b;if(a.config)return new Promise(function(g){e.h[++pb]=function(){g(e)};e.worker.postMessage({id:pb,task:"init",factory:c,options:a})});this.worker.postMessage({task:"init",factory:c,
options:a})}}sb("add");sb("append");sb("search");sb("update");sb("remove");function sb(a){qb.prototype[a]=qb.prototype[a+"Async"]=function(){var b=this,c=[].slice.call(arguments),d=c[c.length-1];if("function"===typeof d){var e=d;c.splice(c.length-1,1)}d=new Promise(function(g){b.h[++pb]=g;b.worker.postMessage({task:a,id:pb,args:c})});return e?(d.then(e),this):d}}
function rb(a,b,c){return b?new (require("worker_threads")["Worker"])(__dirname + "/node/node.js"):a?new window.Worker(URL.createObjectURL(new Blob(["onmessage="+ob.toString()],{type:"text/javascript"}))):new window.Worker(L(c)?c:"worker/worker.js",{type:"module"})};Z.prototype.add=function(a,b,c){M(a)&&(b=a,a=ya(b,this.key));if(b&&(a||0===a)){if(!c&&this.B.has(a))return this.update(a,b);for(var d=0,e;d<this.field.length;d++){e=this.O[d];var g=this.index.get(this.field[d]);if("function"===typeof e)(e=e(b))&&g.add(a,e,!1,!0);else{var f=e.U;if(!f||f(b))e.constructor===String?e=[""+e]:L(e)&&(e=[e]),tb(b,e,this.W,0,g,a,e[0],c)}}if(this.tag)for(d=0;d<this.N.length;d++){f=this.N[d];g=this.tag.get(this.ca[d]);e=K();if("function"===typeof f){if(f=f(b),!f)continue}else{var h=
f.U;if(h&&!h(b))continue;f.constructor===String&&(f=""+f);f=ya(b,f)}if(g&&f){L(f)&&(f=[f]);h=0;for(var k,l=void 0;h<f.length;h++)if(k=f[h],!e[k]){e[k]=1;var m;(m=g.get(k))?l=m:g.set(k,l=[]);if(!c||!l.includes(a)){if(l.length===Math.pow(2,31)-1){m=new R(l);if(this.fastupdate)for(var n=x(this.B.values()),p=n.next();!p.done;p=n.next())p=p.value,p.includes(l)&&(p[p.indexOf(l)]=m);g.set(k,l=m)}l.push(a);this.fastupdate&&((k=this.B.get(a))?k.push(l):this.B.set(a,[l]))}}}}if(this.store&&(!c||!this.store.has(a))){if(this.I){var q=
K();for(c=0;c<this.I.length;c++)if(d=this.I[c],g=d.U,!g||g(b)){g=void 0;if("function"===typeof d){g=d(b);if(!g)continue;d=[d.oa]}else if(L(d)||d.constructor===String){q[d]=b[d];continue}ub(b,q,d,0,d[0],g)}}this.store.set(a,q||b)}}return this};function ub(a,b,c,d,e,g){a=a[e];if(d===c.length-1)b[e]=g||a;else if(a)if(a.constructor===Array)for(b=b[e]=Array(a.length),e=0;e<a.length;e++)ub(a,b,c,d,e);else b=b[e]||(b[e]=K()),e=c[++d],ub(a,b,c,d,e)}
function tb(a,b,c,d,e,g,f,h){if(a=a[f])if(d===b.length-1){if(a.constructor===Array){if(c[d]){for(b=0;b<a.length;b++)e.add(g,a[b],!0,!0);return}a=a.join(" ")}e.add(g,a,h,!0)}else if(a.constructor===Array)for(f=0;f<a.length;f++)tb(a,b,c,d,e,g,f,h);else f=b[++d],tb(a,b,c,d,e,g,f,h);else e.db&&e.remove(g)};Z.prototype.search=function(a,b,c,d){c||(!b&&M(a)?(c=a,a=""):M(b)&&(c=b,b=0));var e=[],g=[],f=0;if(c){c.constructor===Array&&(c={index:c});a=c.query||a;var h=c.pluck;var k=c.merge;var l=h||c.field||c.index;var m=this.tag&&c.tag;var n=this.store&&c.enrich;var p=c.suggest;b=c.limit||b;var q=c.offset||0;b||(b=100);if(m&&(!this.db||!d)){m.constructor!==Array&&(m=[m]);for(var r=[],y=0,u=void 0;y<m.length;y++)if(u=m[y],u.field&&u.tag){var t=u.tag;if(t.constructor===Array)for(var v=0;v<t.length;v++)r.push(u.field,
t[v]);else r.push(u.field,t)}else{t=Object.keys(u);v=0;for(var A=void 0,C=void 0;v<t.length;v++)if(A=t[v],C=u[A],C.constructor===Array)for(var D=0;D<C.length;D++)r.push(A,C[D]);else r.push(A,C)}m=r;if(!a){g=[];if(r.length)for(h=0;h<r.length;h+=2){p=void 0;if(this.db){p=this.index.get(r[h]);if(!p)continue;g.push(p=p.db.tag(r[h+1],b,q,n))}else p=vb.call(this,r[h],r[h+1],b,q,n);e.push({field:r[h],tag:r[h+1],result:p})}return g.length?Promise.all(g).then(function(O){for(var P=0;P<O.length;P++)e[P].result=
O[P];return e}):e}}L(l)&&(l=[l])}l||(l=this.field);r=!d&&(this.worker||this.async)&&[];y=0;for(v=u=t=void 0;y<l.length;y++)if(u=l[y],!this.db||!this.tag||this.O[y]){t=void 0;L(u)||(t=u,u=t.field,a=t.query||a,b=t.limit||b,p=t.suggest||p);if(d)t=d[y];else{v=t||c;t=this.index.get(u);if(m){if(this.db){v.tag=m;var E=t.db.sa;v.field=l}E||(v.enrich=!1)}if(r){r[y]=t.searchAsync(a,b,v);v&&n&&(v.enrich=n);continue}else t=t.search(a,b,v),v&&n&&(v.enrich=n)}v=t&&t.length;if(m&&v){A=[];C=0;if(this.db&&d){if(!E)for(D=
l.length;D<d.length;D++){var J=d[D];if(J&&J.length)C++,A.push(J);else if(!p)return e}}else{D=0;for(var Gb=J=void 0;D<m.length;D+=2){J=this.tag.get(m[D]);if(!J)if(p)continue;else return e;if(Gb=(J=J&&J.get(m[D+1]))&&J.length)C++,A.push(J);else if(!p)return e}}if(C){t=jb(t,A);v=t.length;if(!v&&!p)return e;C--}}if(v)g[f]=u,e.push(t),f++;else if(1===l.length)return e}if(r){if(this.db&&m&&m.length&&!E)for(n=0;n<m.length;n+=2){g=this.index.get(m[n]);if(!g)if(p)continue;else return e;r.push(g.db.tag(m[n+
1],b,q,!1))}var Hb=this;return Promise.all(r).then(function(O){return O.length?Hb.search(a,b,c,O):O})}if(!f)return e;if(h&&(!n||!this.store))return e[0];r=[];q=0;for(p=void 0;q<g.length;q++){p=e[q];n&&p.length&&!p[0].doc&&(this.db?r.push(p=this.index.get(this.field[0]).db.enrich(p)):p.length&&(p=wb.call(this,p)));if(h)return p;e[q]={field:g[q],result:p}}return n&&this.db&&r.length?Promise.all(r).then(function(O){for(var P=0;P<O.length;P++)e[P].result=O[P];return k?xb(e,b):e}):k?xb(e,b):e};
function xb(a,b){for(var c=[],d=K(),e=0,g,f;e<a.length;e++){g=a[e];f=g.result;for(var h=0,k,l,m;h<f.length;h++)if(l=f[h],k=l.id,m=d[k])m.push(g.field);else{if(c.length===b)return c;l.field=d[k]=[g.field];c.push(l)}}return c}function vb(a,b,c,d,e){a=this.tag.get(a);if(!a)return[];if((b=(a=a&&a.get(b))&&a.length-d)&&0<b){if(b>c||d)a=a.slice(d,d+c);e&&(a=wb.call(this,a));return a}}function wb(a){for(var b=Array(a.length),c=0,d;c<a.length;c++)d=a[c],b[c]={id:d,doc:this.store.get(d)};return b};function Z(a){if(!this)return new Z(a);var b=a.document||a.doc||a,c,d;this.O=[];this.field=[];this.W=[];this.key=(c=b.key||b.id)&&yb(c,this.W)||"id";(d=a.keystore||0)&&(this.keystore=d);this.B=(this.fastupdate=!!a.fastupdate)?d?new S(d):new Map:d?new T(d):new Set;this.I=(c=b.store||null)&&!0!==c&&[];this.store=c&&(d?new S(d):new Map);this.cache=(c=a.cache||null)&&new Q(c);a.cache=!1;this.worker=a.worker;this.async=!1;c=new Map;d=b.index||b.field||b;L(d)&&(d=[d]);for(var e=0,g,f=void 0;e<d.length;e++){g=
d[e];L(g)||(f=g,g=g.field);f=M(f)?Object.assign({},a,f):a;if(this.worker){var h=new qb(f);c.set(g,h);h.worker||(this.worker=!1)}this.worker||c.set(g,new V(f,this.B));f.custom?this.O[e]=f.custom:(this.O[e]=yb(g,this.W),f.filter&&("string"===typeof this.O[e]&&(this.O[e]=new String(this.O[e])),this.O[e].U=f.filter));this.field[e]=g}if(this.I)for(d=b.store,L(d)&&(d=[d]),e=0;e<d.length;e++)g=d[e],f=g.field||g,g.custom?(this.I[e]=g.custom,g.custom.oa=f):(this.I[e]=yb(f,this.W),g.filter&&("string"===typeof this.I[e]&&
(this.I[e]=new String(this.I[e])),this.I[e].U=g.filter));this.index=c;this.tag=null;if(c=b.tag)if("string"===typeof c&&(c=[c]),c.length)for(this.tag=new Map,this.N=[],this.ca=[],b=0;b<c.length;b++){d=c[b];e=d.field||d;if(!e)throw Error("The tag field from the document descriptor is undefined.");d.custom?this.N[b]=d.custom:(this.N[b]=yb(e,this.W),d.filter&&("string"===typeof this.N[b]&&(this.N[b]=new String(this.N[b])),this.N[b].U=d.filter));this.ca[b]=e;this.tag.set(e,new Map)}a.db&&this.mount(a.db)}
w=Z.prototype;w.mount=function(a){var b=this.field;if(this.tag)for(var c=0,d;c<this.ca.length;c++){d=this.ca[c];var e=this.index.get(d);e||(this.index.set(d,e=new V({},this.B)),b===this.field&&(b=b.slice(0)),b.push(d));e.tag=this.tag.get(d)}c=[];d={db:a.db,type:a.type,fastupdate:a.fastupdate};e=0;for(var g;e<b.length;e++){d.field=g=b[e];g=this.index.get(g);var f=new a.constructor(a.id,d);f.id=a.id;c[e]=f.mount(g);g.document=!0;e?g.pa=!0:g.store=this.store}this.db=this.async=!0;return Promise.all(c)};
w.commit=function(a,b){var c=this,d,e,g,f;return sa(function(h){if(1==h.h){d=[];e=x(c.index.values());for(g=e.next();!g.done;g=e.next())f=g.value,d.push(f.db.commit(f,a,b));return F(h,Promise.all(d),2)}c.B.clear();h.h=0})};function yb(a,b){for(var c=a.split(":"),d=0,e=0;e<c.length;e++)a=c[e],"]"===a[a.length-1]&&(a=a.substring(0,a.length-2))&&(b[d]=!0),a&&(c[d++]=a);d<c.length&&(c.length=d);return 1<d?c:c[0]}w.append=function(a,b){return this.add(a,b,!0)};
I(a.maxlength,0,this.maxlength);if(this.cache=c=I(a.cache,!0,this.cache))this.V=null,this.J="number"===typeof c?c:2E5,this.N=new Map,this.T=new Map,this.A=this.h=128;this.B="";this.F=null;this.C="";this.G=null;if(this.matcher)for(a=x(this.matcher.keys()),b=a.next();!b.done;b=a.next())this.B+=(this.B?"|":"")+b.value;if(this.stemmer)for(a=x(this.stemmer.keys()),b=a.next();!b.done;b=a.next())this.C+=(this.C?"|":"")+b.value;return this};
N.prototype.encode=function(a){var b=this;if(this.cache&&a.length<=this.h)if(this.V){if(this.N.has(a))return this.N.get(a)}else this.V=setTimeout(Ga,0,this);this.normalize&&(a="function"===typeof this.normalize?this.normalize(a):Fa?a.normalize("NFKD").replace(Fa,"").toLowerCase():a.toLowerCase());this.prepare&&(a=this.prepare(a));this.numeric&&3<a.length&&(a=a.replace(Da,"$1 $2").replace(Ea,"$1 $2").replace(Ca,"$1 "));for(var c=!(this.dedupe||this.mapper||this.filter||this.matcher||this.stemmer||
this.replacer),d=[],e=this.split||""===this.split?a.split(this.split):a,h=0,f=void 0,g=void 0;h<e.length;h++)if((f=g=e[h])&&!(f.length<this.minlength))if(c)d.push(f);else if(!this.filter||!this.filter.has(f)){if(this.cache&&f.length<=this.A)if(this.V){var k=this.T.get(f);if(k||""===k){k&&d.push(k);continue}}else this.V=setTimeout(Ga,0,this);k=void 0;this.stemmer&&2<f.length&&(this.G||(this.G=new RegExp("(?!^)("+this.C+")$")),f=f.replace(this.G,function(q){return b.stemmer.get(q)}),k=1);this.matcher&&
1<f.length&&(this.F||(this.F=new RegExp("("+this.B+")","g")),f=f.replace(this.F,function(q){return b.matcher.get(q)}),k=1);f&&k&&(f.length<this.minlength||this.filter&&this.filter.has(f))&&(f="");if(f&&(this.mapper||this.dedupe&&1<f.length)){k="";for(var l=0,m="",n=void 0,p=void 0;l<f.length;l++)n=f.charAt(l),n===m&&this.dedupe||((p=this.mapper&&this.mapper.get(n))||""===p?p===m&&this.dedupe||!(m=p)||(k+=p):k+=m=n);f=k}if(f&&this.replacer)for(k=0;f&&k<this.replacer.length;k+=2)f=f.replace(this.replacer[k],
this.replacer[k+1]);this.cache&&g.length<=this.A&&(this.T.set(g,f),this.T.size>this.J&&(this.T.clear(),this.A=this.A/1.1|0));f&&d.push(f)}this.finalize&&(d=this.finalize(d)||d);this.cache&&a.length<=this.h&&(this.N.set(a,d),this.N.size>this.J&&(this.N.clear(),this.h=this.h/1.1|0));return d};function Ga(a){a.V=null;a.N.clear();a.T.clear()};function Ha(a,b,c){a=("object"===typeof a?""+a.query:a).toLowerCase();var d=this.cache.get(a);if(!d){d=this.search(a,b,c);if(d.then){var e=this;d.then(function(h){e.cache.set(a,h);return h})}this.cache.set(a,d)}return d}function Q(a){this.limit=a&&!0!==a?a:1E3;this.cache=new Map;this.h=""}Q.prototype.set=function(a,b){this.cache.set(this.h=a,b);this.cache.size>this.limit&&this.cache.delete(this.cache.keys().next().value)};
Q.prototype.get=function(a){var b=this.cache.get(a);b&&this.h!==a&&(this.cache.delete(a),this.cache.set(this.h=a,b));return b};Q.prototype.remove=function(a){for(var b=x(this.cache),c=b.next();!c.done;c=b.next()){c=c.value;var d=c[0];c[1].includes(a)&&this.cache.delete(d)}};Q.prototype.clear=function(){this.cache.clear();this.h=""};var Ia={normalize:function(a){return a.toLowerCase()},dedupe:!1};var Ja=new Map([["b","p"],["v","f"],["w","f"],["z","s"],["x","s"],["d","t"],["n","m"],["c","k"],["g","k"],["j","k"],["q","k"],["i","e"],["y","e"],["u","o"]]);var Ka=new Map([["ai","ei"],["ae","a"],["oe","o"],["ue","u"],["sh","s"],["ch","c"],["th","t"],["ph","f"],["pf","f"]]),La=[/([^aeo])h([aeo$])/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2"];var Ma={a:"",e:"",i:"",o:"",u:"",y:"",b:1,f:1,p:1,v:1,c:2,g:2,j:2,k:2,q:2,s:2,x:2,z:2,"\u00df":2,d:3,t:3,l:4,m:5,n:5,r:6};var Na=/[\x00-\x7F]+/g;var Oa=/[\x00-\x7F]+/g;var Pa=/[\x00-\x7F]+/g;var Qa={LatinExact:{normalize:!1,dedupe:!1},LatinDefault:Ia,LatinSimple:{normalize:!0,dedupe:!0},LatinBalance:{normalize:!0,dedupe:!0,mapper:Ja},LatinAdvanced:{normalize:!0,dedupe:!0,mapper:Ja,replacer:La,matcher:Ka},LatinExtra:{normalize:!0,dedupe:!0,mapper:Ja,replacer:La.concat([/(?!^)[aeoy]/g,""]),matcher:Ka},LatinSoundex:{normalize:!0,dedupe:!1,include:{letter:!0},finalize:function(a){for(var b=0;b<a.length;b++){for(var c=a[b],d=c.charAt(0),e=Ma[d],h=1,f;h<c.length&&(f=c.charAt(h),"h"===f||"w"===
f||!(f=Ma[f])||f===e||(d+=f,e=f,4!==d.length));h++);a[b]=d}}},ArabicDefault:{rtl:!0,normalize:!1,dedupe:!0,prepare:function(a){return(""+a).replace(Na," ")}},CjkDefault:{normalize:!1,dedupe:!0,split:"",prepare:function(a){return(""+a).replace(Oa,"")}},CyrillicDefault:{normalize:!1,dedupe:!0,prepare:function(a){return(""+a).replace(Pa," ")}}};function Ra(a,b,c,d){for(var e=[],h=0,f;h<a.index.length;h++)if(f=a.index[h],b>=f.length)b-=f.length;else{b=f[d?"splice":"slice"](b,c);if(f=b.length)if(e=e.length?e.concat(b):b,c-=f,d&&(a.length-=f),!c)break;b=0}return e}
function R(a){if(!this)return new R(a);this.index=a?[a]:[];this.length=a?a.length:0;var b=this;return new Proxy([],{get:function(c,d){if("length"===d)return b.length;if("push"===d)return function(e){b.index[b.index.length-1].push(e);b.length++};if("pop"===d)return function(){if(b.length)return b.length--,b.index[b.index.length-1].pop()};if("indexOf"===d)return function(e){for(var h=0,f=0,g,k;f<b.index.length;f++){g=b.index[f];k=g.indexOf(e);if(0<=k)return h+k;h+=g.length}return-1};if("includes"===
d)return function(e){for(var h=0;h<b.index.length;h++)if(b.index[h].includes(e))return!0;return!1};if("slice"===d)return function(e,h){return Ra(b,e||0,h||b.length,!1)};if("splice"===d)return function(e,h){return Ra(b,e||0,h||b.length,!0)};if("constructor"===d)return Array;if("symbol"!==typeof d)return(c=b.index[d/Math.pow(2,31)|0])&&c[d]},set:function(c,d,e){c=d/Math.pow(2,31)|0;(b.index[c]||(b.index[c]=[]))[d]=e;b.length++;return!0}})}R.prototype.clear=function(){this.index.length=0};
R.prototype.push=function(){};function S(a){a=void 0===a?8:a;if(!this)return new S(a);this.index=K();this.B=[];this.size=0;32<a?(this.h=Sa,this.A=BigInt(a)):(this.h=Ta,this.A=a)}S.prototype.get=function(a){var b=this.h(a);return(b=this.index[b])&&b.get(a)};S.prototype.set=function(a,b){var c=this.h(a),d=this.index[c];d?(c=d.size,d.set(a,b),(c-=d.size)&&this.size++):(this.index[c]=d=new Map([[a,b]]),this.B.push(d))};
function T(a){a=void 0===a?8:a;if(!this)return new T(a);this.index=K();this.h=[];32<a?(this.B=Sa,this.A=BigInt(a)):(this.B=Ta,this.A=a)}T.prototype.add=function(a){var b=this.B(a),c=this.index[b];c?(b=c.size,c.add(a),(b-=c.size)&&this.size++):(this.index[b]=c=new Set([a]),this.h.push(c))};w=S.prototype;w.has=T.prototype.has=function(a){var b=this.B(a);return(b=this.index[b])&&b.has(a)};w.delete=T.prototype.delete=function(a){var b=this.B(a);(b=this.index[b])&&b.delete(a)&&this.size--};
w.clear=T.prototype.clear=function(){this.index=K();this.h=[];this.size=0};w.values=T.prototype.values=function Ua(){var b,c=this,d,e,h;return qa(Ua,function(f){switch(f.h){case 1:b=0;case 2:if(!(b<c.h.length)){f.h=0;break}d=x(c.h[b].values());e=d.next();case 5:if(e.done){b++;f.h=2;break}h=e.value;return F(f,h,6);case 6:e=d.next(),f.h=5}})};
w.keys=T.prototype.keys=function Va(){var b,c=this,d,e,h;return qa(Va,function(f){switch(f.h){case 1:b=0;case 2:if(!(b<c.h.length)){f.h=0;break}d=x(c.h[b].keys());e=d.next();case 5:if(e.done){b++;f.h=2;break}h=e.value;return F(f,h,6);case 6:e=d.next(),f.h=5}})};
w.entries=T.prototype.entries=function Wa(){var b,c=this,d,e,h;return qa(Wa,function(f){switch(f.h){case 1:b=0;case 2:if(!(b<c.h.length)){f.h=0;break}d=x(c.h[b].entries());e=d.next();case 5:if(e.done){b++;f.h=2;break}h=e.value;return F(f,h,6);case 6:e=d.next(),f.h=5}})};function Ta(a){var b=Math.pow(2,this.A)-1;if("number"==typeof a)return a&b;for(var c=0,d=this.A+1,e=0;e<a.length;e++)c=(c*d^a.charCodeAt(e))&b;return 32===this.A?c+Math.pow(2,31):c}
function Sa(){throw Error("The keystore is limited to 32 for EcmaScript5");};function Xa(a,b,c,d,e,h,f,g){(d=a(c?c+"."+d:d,JSON.stringify(f)))&&d.then?d.then(function(){b.export(a,b,c,e,h+1,g)}):b.export(a,b,c,e,h+1,g)};var Ya={memory:{resolution:1},performance:{resolution:6,fastupdate:!0,context:{depth:1,resolution:3}},match:{tokenize:"forward"},score:{resolution:9,context:{depth:2,resolution:9}}};function Za(a){U.call(a,"add");U.call(a,"append");U.call(a,"search");U.call(a,"update");U.call(a,"remove")}function U(a){this[a+"Async"]=function(){var b=arguments,c=b[b.length-1];if("function"===typeof c){var d=c;delete b[b.length-1]}this.async=!0;b=this[a].apply(this,b);this.async=!1;d&&(b.then?b.then(d):d(b));return b}};K();V.prototype.add=function(a,b,c,d){if(b&&(a||0===a)){if(!d&&!c&&this.reg.has(a))return this.update(a,b);b=this.encoder.encode(b);if(d=b.length){for(var e=K(),h=K(),f=this.depth,g=this.resolution,k=0;k<d;k++){var l=b[this.rtl?d-1-k:k],m=l.length;if(m&&(f||!h[l])){var n=this.score?this.score(b,l,k,null,0):$a(g,d,k),p="";switch(this.tokenize){case "full":if(2<m){for(n=0;n<m;n++)for(var q=m;q>n;q--){p=l.substring(n,q);var r=this.score?this.score(b,l,k,p,n):$a(g,d,k,m,n);ab(this,h,p,r,a,c)}break}case "reverse":if(1<
m){for(q=m-1;0<q;q--)p=l[q]+p,r=this.score?this.score(b,l,k,p,q):$a(g,d,k,m,q),ab(this,h,p,r,a,c);p=""}case "forward":if(1<m){for(q=0;q<m;q++)p+=l[q],ab(this,h,p,n,a,c);break}default:if(ab(this,h,l,n,a,c),f&&1<d&&k<d-1)for(m=K(),p=this.ba,n=l,q=Math.min(f+1,d-k),r=m[n]=1;r<q;r++)if((l=b[this.rtl?d-1-k-r:k+r])&&!m[l]){m[l]=1;var y=this.score?this.score(b,n,k,l,r):$a(p+(d/2>p?0:1),d,k,q-1,r-1),u=this.bidirectional&&l>n;ab(this,e,u?n:l,y,a,c,u?l:n)}}}}this.fastupdate||this.reg.add(a)}else b=""}this.db&&
(b||this.O.push({del:a}),this.ea&&bb(this));return this};
function ab(a,b,c,d,e,h,f){var g=f?a.ctx:a.map,k;if(!b[c]||!f||!(k=b[c])[f])if(f?(b=k||(b[c]=K()),b[f]=1,(k=g.get(f))?g=k:g.set(f,g=new Map)):b[c]=1,(k=g.get(c))?g=k:g.set(c,g=k=[]),g=g[d]||(g[d]=[]),!h||!g.includes(e)){if(g.length===Math.pow(2,31)-1){b=new R(g);if(a.fastupdate)for(c=x(a.reg.values()),h=c.next();!h.done;h=c.next())h=h.value,h.includes(g)&&(h[h.indexOf(g)]=b);k[d]=g=b}g.push(e);a.fastupdate&&((d=a.reg.get(e))?d.push(g):a.reg.set(e,[g]))}}
function $a(a,b,c,d,e){return c&&1<a?b+(d||0)<=a?c+(e||0):(a-1)/(b+(d||0))*(c+(e||0))+1|0:0};function W(a,b,c,d){if(1===a.length)return a=a[0],a=c||a.length>b?b?a.slice(c,c+b):a.slice(c):a,d?cb(a):a;for(var e=[],h=0,f=void 0,g=void 0;h<a.length;h++)if((f=a[h])&&(g=f.length)){if(c){if(c>=g){c-=g;continue}c<g&&(f=b?f.slice(c,c+b):f.slice(c),g=f.length,c=0)}if(e.length)g>b&&(f=f.slice(0,b),g=f.length),e.push(f);else{if(g>=b)return g>b&&(f=f.slice(0,b)),d?cb(f):f;e=[f]}b-=g;if(!b)break}if(!e.length)return e;e=1<e.length?[].concat.apply([],e):e[0];return d?cb(e):e}
function cb(a){for(var b=0;b<a.length;b++)a[b]={score:b,id:a[b]};return a};X.prototype.or=function(){var a=this,b=arguments,c=b[0];if(c.then)return c.then(function(){return a.or.apply(a,b)});if(c[0]&&c[0].index)return this.or.apply(this,c);var d=[];c=[];for(var e=0,h=0,f,g,k=0,l=void 0;k<b.length;k++)if(l=b[k]){var m=void 0;if(l.constructor===X)m=l.result;else if(l.constructor===Array)m=l;else if(l.index)l.resolve=!1,m=l.index.search(l).result;else if(l.and)m=this.and(l.and);else if(l.xor)m=this.xor(l.xor);else if(l.not)m=this.not(l.not);else{e=l.limit||0;h=l.offset||0;
f=l.enrich;g=l.resolve;continue}d[k]=m;m.then&&c.push(m)}if(c.length)return Promise.all(c).then(function(){a.result.length&&(d=[a.result].concat(d));a.result=db(d,e,h,f,g,a.K);return g?a.result:a});this.result.length&&(d=[this.result].concat(d));this.result=db(d,e,h,f,g,a.K);return g?this.result:this};
function db(a,b,c,d,e,h){if(!a.length)return a;"object"===typeof b&&(c=b.offset||0,d=b.enrich||!1,b=b.limit||0);if(2>a.length)return e?W(a[0],b,c,d):a[0];d=[];for(var f=0,g=K(),k=za(a),l=0,m;l<k;l++)for(var n=0;n<a.length;n++)if(m=a[n])if(m=m[l])for(var p=0,q;p<m.length;p++)if(q=m[p],!g[q])if(g[q]=1,c)c--;else{if(e)d.push(q);else{var r=l+(n?h:0);d[r]||(d[r]=[]);d[r].push(q)}if(b&&++f===b)return d}return d};X.prototype.and=function(){if(this.result.length){var a=this,b=arguments,c=b[0];if(c.then)return c.then(function(){return a.and.apply(a,b)});if(c[0]&&c[0].index)return this.and.apply(this,c);var d=[];c=[];for(var e=0,h=0,f,g=0,k=void 0;g<b.length;g++)if(k=b[g]){var l=void 0;if(k.constructor===X)l=k.result;else if(k.constructor===Array)l=k;else if(k.index)k.resolve=!1,l=k.index.search(k).result;else if(k.or)l=this.or(k.or);else if(k.xor)l=this.xor(k.xor);else if(k.not)l=this.not(k.not);else{e=k.limit||
0;h=k.offset||0;f=k.resolve;continue}d[g]=l;l.then&&c.push(l)}if(c.length)return Promise.all(c).then(function(){d=[a.result].concat(d);a.result=eb(d,e,h,f,a.K);return f?a.result:a});d=[this.result].concat(d);this.result=eb(d,e,h,f,a.K);return f?this.result:this}return this};
function eb(a,b,c,d,e){if(2>a.length)return[];var h=[],f=0,g=K(),k=za(a);if(!k)return h;for(var l=0,m;l<a.length;l++){m=a[l];if(!m||!m.length)return[];for(var n=K(),p=0,q=l===a.length-1,r=0,y;r<k;r++)if(y=m[r])for(var u=0,t,v;u<y.length;u++)if(t=y[u],!l)n[t]=r+1+(l?e:0),p=1;else if(q){if(v=g[t])if(p=1,c)c--;else if(d?h.push(t):(v--,r<v&&(v=r),h[v]||(h[v]=[]),h[v].push(t)),b&&++f===b)return h}else if(v=g[t])r+1<v&&(v=r+1),n[t]=v,p=1;if(!p)return[];g=n}return h};X.prototype.xor=function(){var a=this,b=arguments,c=b[0];if(c.then)return c.then(function(){return a.xor.apply(a,b)});if(c[0]&&c[0].index)return this.xor.apply(this,c);var d=[];c=[];for(var e=0,h=0,f,g,k=0,l=void 0;k<b.length;k++)if(l=b[k]){var m=void 0;if(l.constructor===X)m=l.result;else if(l.constructor===Array)m=l;else if(l.index)l.resolve=!1,m=l.index.search(l).result;else if(l.or)m=this.or(l.or);else if(l.and)m=this.and(l.and);else if(l.not)m=this.not(l.not);else{e=l.limit||0;h=l.offset||0;
f=l.enrich;g=l.resolve;continue}d[k]=m;m.then&&c.push(m)}if(c.length)return Promise.all(c).then(function(){a.result.length&&(d=[a.result].concat(d));a.result=fb(d,e,h,f,!g,a.K);return g?a.result:a});this.result.length&&(d=[this.result].concat(d));this.result=fb(d,e,h,f,!g,a.K);return g?this.result:this};
function fb(a,b,c,d,e,h){if(!a.length)return a;if(2>a.length)return e?W(a[0],b,c,d):a[0];b=[];c=K();d=0;for(var f;d<a.length;d++)if(f=a[d])for(var g=0,k;g<f.length;g++)if(k=f[g])for(var l=0,m;l<k.length;l++)m=k[l],c[m]?c[m]++:c[m]=1;for(d=0;d<a.length;d++)if(f=a[d])for(g=0;g<f.length;g++)if(k=f[g])for(l=0;l<k.length;l++)if(m=k[l],1===c[m])if(e)b.push(m);else{var n=g+(d?h:0);b[n]||(b[n]=[]);b[n].push(m)}return b};X.prototype.not=function(){var a=this,b=arguments,c=b[0];if(c.then)return c.then(function(){return a.not.apply(a,b)});if(c[0]&&c[0].index)return this.not.apply(this,c);var d=[];c=[];for(var e,h=0,f=void 0;h<b.length;h++)if(f=b[h]){var g=void 0;if(f.constructor===X)g=f.result;else if(f.constructor===Array)g=f;else if(f.index)f.resolve=!1,g=f.index.search(f).result;else if(f.or)g=this.or(f.or);else if(f.and)g=this.and(f.and);else if(f.xor)g=this.xor(f.xor);else{e=f.resolve;continue}d[h]=g;g.then&&c.push(g)}if(c.length)return Promise.all(c).then(function(){a.result=
gb.call(a,d,e);return e?a.result:a});this.result=gb.call(this,d,e);return e?this.result:this};function gb(a,b){if(!a.length)return this.result;var c=[];a=new Set(a.flat().flat());for(var d=0,e;d<this.result.length;d++)if(e=this.result[d])for(var h=0,f;h<e.length;h++)f=e[h],a.has(f)||(b?c.push(f):(c[d]||(c[d]=[]),c[d].push(f)));return c};function X(a){if(!this)return new X(a);if(a&&a.index)return a.resolve=!1,this.index=a.index,a.index.search(a);if(a.constructor===X)return a;this.index=null;this.result=a||[];this.K=0}X.prototype.limit=function(a){if(this.result.length)for(var b=[],c=0,d=0,e;d<this.result.length;d++)if(e=this.result[d],e.length+c<a)b[d]=e,c+=e.length;else{b[d]=e.slice(0,a-c);this.result=b;break}return this};
X.prototype.offset=function(a){if(this.result.length){for(var b=[],c=0,d=0,e;d<this.result.length;d++)e=this.result[d],e.length+c<a?c+=e.length:(b[d]=e.slice(a-c),c=a);this.result=b}return this};X.prototype.boost=function(a){this.K+=a;return this};X.prototype.resolve=function(a,b,c){hb=1;var d=this.result;this.result=this.index=null;return d.length?("object"===typeof a&&(c=a.enrich,b=a.offset,a=a.limit),W(d,a||100,b,c)):d};function ib(a,b,c,d,e){var h=a.length,f=[],g;var k=K();for(var l=0,m=void 0,n;l<b;l++)for(var p=0;p<h;p++)if(n=a[p],l<n.length&&(m=n[l]))for(var q=0;q<m.length;q++)n=m[q],(g=k[n])?k[n]++:(g=0,k[n]=1),g=f[g]||(f[g]=[]),g.push(n);if(a=f.length)if(e){if(1<f.length){e=f;h=[];f=K();k=e.length;for(m=0;m<k;m++)for(a=e[m],l=a.length,p=0;p<l;p++)if(b=a[p],!f[b])if(f[b]=1,d)d--;else if(h.push(b),h.length===c)break;c=h}else c=f[0];f=c}else{if(a<h)return[];f=f[a-1];if(f.length>c||d)f=f.slice(d,c+d)}return f}
function jb(a,b){for(var c=K(),d=K(),e=[],h=0;h<a.length;h++)c[a[h]]=1;for(a=0;a<b.length;a++){h=b[a];for(var f=0,g;f<h.length;f++)g=h[f],c[g]&&!d[g]&&(d[g]=1,e.push(g))}return e};var hb=1;
V.prototype.search=function(a,b,c){c||(!b&&M(a)?(c=a,a=""):M(b)&&(c=b,b=0));var d=[],e=0,h;if(c){a=c.query||a;b=c.limit||b;e=c.offset||0;var f=c.context;var g=c.suggest;(h=hb&&!1!==c.resolve)||(hb=0);var k=h&&c.enrich;var l=this.db&&c.tag}else h=this.resolve||hb;a=this.encoder.encode(a);var m=a.length;b||!h||(b=100);if(1===m)return kb.call(this,a[0],"",b,e,h,k,l);f=this.depth&&!1!==f;if(2===m&&f&&!g)return kb.call(this,a[0],a[1],b,e,h,k,l);var n=c=0;if(1<m){for(var p=K(),q=[],r=0,y=void 0;r<m;r++)if((y=
a[r])&&!p[y]){if(g||this.db||Y(this,y))q.push(y),p[y]=1;else return h?d:new X(d);y=y.length;c=Math.max(c,y);n=n?Math.min(n,y):y}a=q;m=a.length}if(!m)return h?d:new X(d);var u=0;if(1===m)return kb.call(this,a[0],"",b,e,h,k,l);if(2===m&&f&&!g)return kb.call(this,a[0],a[1],b,e,h,k,l);if(1<m)if(f){var t=a[0];u=1}else 9<c&&3<c/n&&a.sort(wa);if(this.db){if(this.db.search&&(f=this.db.search(this,a,b,e,g,h,k,l),!1!==f))return f;var v=this;return function(){var A,C,D;return sa(function(E){switch(E.h){case 1:C=
A=void 0;case 2:if(!(u<m)){E.h=4;break}C=a[u];return t?F(E,Y(v,C,t),8):F(E,Y(v,C),7);case 7:A=E.F;A=lb(A,d,g,v.resolution,b,e,1===m);E.h=6;break;case 8:A=E.F,A=lb(A,d,g,v.ba,b,e,2===m),g&&!1===A&&d.length||(t=C);case 6:if(A)return E.return(A);if(g&&u===m-1){D=d.length;if(!D){if(t){t="";u=-1;E.h=3;break}return E.return(d)}if(1===D)return E.return(h?W(d[0],b,e):new X(d[0]))}case 3:u++;E.h=2;break;case 4:return E.return(h?ib(d,v.resolution,b,e,g):new X(d[0]))}})}()}for(k=f=void 0;u<m;u++){k=a[u];t?(f=
Y(this,k,t),f=lb(f,d,g,this.ba,b,e,2===m),g&&!1===f&&d.length||(t=k)):(f=Y(this,k),f=lb(f,d,g,this.resolution,b,e,1===m));if(f)return f;if(g&&u===m-1){f=d.length;if(!f){if(t){t="";u=-1;continue}return d}if(1===f)return h?W(d[0],b,e):new X(d[0])}}d=ib(d,this.resolution,b,e,g);return h?d:new X(d)};function kb(a,b,c,d,e,h,f){a=Y(this,a,b,c,d,e,h,f);return this.db?a.then(function(g){return e?g:g&&g.length?e?W(g,c,d):new X(g):e?[]:new X([])}):a&&a.length?e?W(a,c,d):new X(a):e?[]:new X([])}
function lb(a,b,c,d,e,h,f){var g=[];if(a){d=Math.min(a.length,d);for(var k=0,l=0,m;k<d;k++)if(m=a[k])if(h&&m&&f&&(m.length<=h?(h-=m.length,m=null):(m=m.slice(h),h=0)),m&&(g[k]=m,f&&(l+=m.length,l>=e)))break;if(g.length){if(f)return W(g,e,0);b.push(g);return}}return!c&&g}function Y(a,b,c,d,e,h,f,g){var k;c&&(k=a.bidirectional&&b>c);if(a.db)return c?a.db.get(k?c:b,k?b:c,d,e,h,f,g):a.db.get(b,"",d,e,h,f,g);a=c?(a=a.ctx.get(k?b:c))&&a.get(k?c:b):a.map.get(b);return a};V.prototype.remove=function(a,b){var c=this.reg.size&&(this.fastupdate?this.reg.get(a):this.reg.has(a));if(c){if(this.fastupdate)for(var d=0,e;d<c.length;d++){if(e=c[d])if(2>e.length)e.pop();else{var h=e.indexOf(a);h===c.length-1?e.pop():e.splice(h,1)}}else mb(this.map,a),this.depth&&mb(this.ctx,a);b||this.reg.delete(a)}this.db&&(this.O.push({del:a}),this.ea&&bb(this));this.cache&&this.cache.remove(a);return this};
function mb(a,b){var c=0;if(a.constructor===Array)for(var d=0,e=void 0,h;d<a.length;d++){if((e=a[d])&&e.length)if(h=e.indexOf(b),0<=h){1<e.length?(e.splice(h,1),c++):delete a[d];break}else c++}else for(d=x(a),e=d.next();!e.done;e=d.next())h=e.value,e=h[0],(h=mb(h[1],b))?c+=h:a.delete(e);return c};function V(a,b){if(!this)return new V(a);if(a){var c=L(a)?a:a.preset;c&&(a=Object.assign({},Ya[c],a))}else a={};c=a.context||{};var d=a.encode||a.encoder||Ia;this.encoder=d.encode?d:"object"===typeof d?new N(d):{encode:d};var e;this.resolution=a.resolution||9;this.tokenize=e=a.tokenize||"strict";this.depth="strict"===e&&c.depth||0;this.bidirectional=!1!==c.bidirectional;this.fastupdate=!!a.fastupdate;this.score=a.score||null;(e=a.keystore||0)&&(this.keystore=e);this.map=e?new S(e):new Map;this.ctx=
e?new S(e):new Map;this.reg=b||(this.fastupdate?e?new S(e):new Map:e?new T(e):new Set);this.ba=c.resolution||1;this.rtl=d.rtl||a.rtl||!1;this.cache=(e=a.cache||null)&&new Q(e);this.resolve=!1!==a.resolve;if(e=a.db)this.db=e.mount(this);this.ea=!1!==a.commit;this.O=[];this.h=null}w=V.prototype;w.mount=function(a){this.h&&(clearTimeout(this.h),this.h=null);return a.mount(this)};w.commit=function(a,b){this.h&&(clearTimeout(this.h),this.h=null);return this.db.commit(this,a,b)};
function bb(a){a.h||(a.h=setTimeout(function(){a.h=null;a.db.commit(a,void 0,void 0)},0))}w.clear=function(){this.map.clear();this.ctx.clear();this.reg.clear();this.cache&&this.cache.clear();this.db&&(this.h&&clearTimeout(this.h),this.h=null,this.O=[{clear:!0}]);return this};w.append=function(a,b){return this.add(a,b,!0)};w.contain=function(a){return this.db?this.db.has(a):this.reg.has(a)};
w.update=function(a,b){if(this.async){var c=this,d=this.remove(a);return d.then?d.then(function(){return c.add(a,b)}):this.add(a,b)}return this.remove(a).add(a,b)};function nb(a){var b=0;if(a.constructor===Array)for(var c=0,d=void 0;c<a.length;c++)(d=a[c])&&(b+=d.length);else for(c=x(a),d=c.next();!d.done;d=c.next()){var e=d.value;d=e[0];(e=nb(e[1]))?b+=e:a.delete(d)}return b}w.cleanup=function(){if(!this.fastupdate)return this;nb(this.map);this.depth&&nb(this.ctx);return this};w.searchCache=Ha;
w.export=function(a,b,c,d,e,h){var f=!0;"undefined"===typeof h&&(f=new Promise(function(n){h=n}));switch(e||(e=0)){case 0:var g="reg";if(this.fastupdate){var k=K();for(var l=x(this.reg.keys()),m=l.next();!m.done;m=l.next())k[m.value]=1}else k=this.reg;break;case 1:g="cfg";k={doc:0,opt:this.A?1:0};break;case 2:g="map";k=this.map;break;case 3:g="ctx";k=this.ctx;break;default:"undefined"===typeof c&&h&&h();return}Xa(a,b||this,c,g,d,e,k,h);return f};
w.import=function(a,b){if(b)switch(L(b)&&(b=JSON.parse(b)),a){case "cfg":this.A=!!b.opt;break;case "reg":this.fastupdate=!1;this.reg=b;break;case "map":this.map=b;break;case "ctx":this.ctx=b}};
w.serialize=function(a){a=void 0===a?!0:a;if(!this.reg.size)return"";for(var b="",c="",d=x(this.reg.keys()),e=d.next();!e.done;e=d.next())e=e.value,c||(c=typeof e),b+=(b?",":"")+("string"===c?'"'+e+'"':e);b="index.reg=new Set(["+b+"]);";d="";e=x(this.map.entries());for(var h=e.next();!h.done;h=e.next()){var f=h.value;h=f[0];f=f[1];for(var g="",k=0,l;k<f.length;k++){l=f[k]||[""];for(var m="",n=0;n<l.length;n++)m+=(m?",":"")+("string"===c?'"'+l[n]+'"':l[n]);m="["+m+"]";g+=(g?",":"")+m}g='["'+h+'",['+
g+"]]";d+=(d?",":"")+g}d="index.map=new Map(["+d+"]);";e="";h=x(this.ctx.entries());for(f=h.next();!f.done;f=h.next())for(g=f.value,f=g[0],g=x(g[1].entries()),k=g.next();!k.done;k=g.next()){l=k.value;k=l[0];l=l[1];m="";n=0;for(var p;n<l.length;n++){p=l[n]||[""];for(var q="",r=0;r<p.length;r++)q+=(q?",":"")+("string"===c?'"'+p[r]+'"':p[r]);q="["+q+"]";m+=(m?",":"")+q}m='new Map([["'+k+'",['+m+"]]])";m='["'+f+'",'+m+"]";e+=(e?",":"")+m}e="index.ctx=new Map(["+e+"]);";return a?"function inject(index){"+
b+d+e+"}":b+d+e};Za(V.prototype);function ob(a){var b,c,d,e,h,f,g,k;return sa(function(l){a=a.data;b=self._index;c=a.args;d=a.task;switch(d){case "init":e=a.options||{};(h=e.config)&&(e=await import(h));(f=a.factory)?(Function("return "+f)()(self),self._index=new self.FlexSearch.Index(e),delete self.FlexSearch):self._index=new V(e);postMessage({id:a.id});break;default:g=a.id,k=b[d].apply(b,c),postMessage("search"===d?{id:g,msg:k}:{id:g})}l.h=0})};var pb=0;
function qb(a){function b(h){h=h.data||h;var f=h.id,g=f&&e.h[f];g&&(g(h.msg),delete e.h[f])}if(!this)return new qb(a);a||(a={});var c=(self||window)._factory;c&&(c=c.toString());var d="undefined"===typeof window&&self.exports,e=this;this.worker=rb(c,d,a.worker);this.h=K();if(this.worker){d?this.worker.on("message",b):this.worker.onmessage=b;if(a.config)return new Promise(function(h){e.h[++pb]=function(){h(e)};e.worker.postMessage({id:pb,task:"init",factory:c,options:a})});this.worker.postMessage({task:"init",factory:c,
options:a})}}sb("add");sb("append");sb("search");sb("update");sb("remove");function sb(a){qb.prototype[a]=qb.prototype[a+"Async"]=function(){var b=this,c=[].slice.call(arguments),d=c[c.length-1];if("function"===typeof d){var e=d;c.splice(c.length-1,1)}d=new Promise(function(h){b.h[++pb]=h;b.worker.postMessage({task:a,id:pb,args:c})});return e?(d.then(e),this):d}}
function rb(a,b,c){return b?new (require("worker_threads")["Worker"])(__dirname + "/node/node.js"):a?new window.Worker(URL.createObjectURL(new Blob(["onmessage="+ob.toString()],{type:"text/javascript"}))):new window.Worker(L(c)?c:"worker/worker.js",{type:"module"})};Z.prototype.add=function(a,b,c){M(a)&&(b=a,a=ya(b,this.key));if(b&&(a||0===a)){if(!c&&this.reg.has(a))return this.update(a,b);for(var d=0,e;d<this.field.length;d++){e=this.M[d];var h=this.index.get(this.field[d]);if("function"===typeof e)(e=e(b))&&h.add(a,e,!1,!0);else{var f=e.S;if(!f||f(b))e.constructor===String?e=[""+e]:L(e)&&(e=[e]),tb(b,e,this.U,0,h,a,e[0],c)}}if(this.tag)for(d=0;d<this.L.length;d++){f=this.L[d];h=this.tag.get(this.aa[d]);e=K();if("function"===typeof f){if(f=f(b),!f)continue}else{var g=
f.S;if(g&&!g(b))continue;f.constructor===String&&(f=""+f);f=ya(b,f)}if(h&&f){L(f)&&(f=[f]);g=0;for(var k,l=void 0;g<f.length;g++)if(k=f[g],!e[k]){e[k]=1;var m;(m=h.get(k))?l=m:h.set(k,l=[]);if(!c||!l.includes(a)){if(l.length===Math.pow(2,31)-1){m=new R(l);if(this.fastupdate)for(var n=x(this.reg.values()),p=n.next();!p.done;p=n.next())p=p.value,p.includes(l)&&(p[p.indexOf(l)]=m);h.set(k,l=m)}l.push(a);this.fastupdate&&((k=this.reg.get(a))?k.push(l):this.reg.set(a,[l]))}}}}if(this.store&&(!c||!this.store.has(a))){if(this.H){var q=
K();for(c=0;c<this.H.length;c++)if(d=this.H[c],h=d.S,!h||h(b)){h=void 0;if("function"===typeof d){h=d(b);if(!h)continue;d=[d.ma]}else if(L(d)||d.constructor===String){q[d]=b[d];continue}ub(b,q,d,0,d[0],h)}}this.store.set(a,q||b)}}return this};function ub(a,b,c,d,e,h){a=a[e];if(d===c.length-1)b[e]=h||a;else if(a)if(a.constructor===Array)for(b=b[e]=Array(a.length),e=0;e<a.length;e++)ub(a,b,c,d,e);else b=b[e]||(b[e]=K()),e=c[++d],ub(a,b,c,d,e)}
function tb(a,b,c,d,e,h,f,g){if(a=a[f])if(d===b.length-1){if(a.constructor===Array){if(c[d]){for(b=0;b<a.length;b++)e.add(h,a[b],!0,!0);return}a=a.join(" ")}e.add(h,a,g,!0)}else if(a.constructor===Array)for(f=0;f<a.length;f++)tb(a,b,c,d,e,h,f,g);else f=b[++d],tb(a,b,c,d,e,h,f,g);else e.db&&e.remove(h)};Z.prototype.search=function(a,b,c,d){c||(!b&&M(a)?(c=a,a=""):M(b)&&(c=b,b=0));var e=[],h=[],f=0;if(c){c.constructor===Array&&(c={index:c});a=c.query||a;var g=c.pluck;var k=c.merge;var l=g||c.field||c.index;var m=this.tag&&c.tag;var n=this.store&&c.enrich;var p=c.suggest;b=c.limit||b;var q=c.offset||0;b||(b=100);if(m&&(!this.db||!d)){m.constructor!==Array&&(m=[m]);for(var r=[],y=0,u=void 0;y<m.length;y++)if(u=m[y],u.field&&u.tag){var t=u.tag;if(t.constructor===Array)for(var v=0;v<t.length;v++)r.push(u.field,
t[v]);else r.push(u.field,t)}else{t=Object.keys(u);v=0;for(var A=void 0,C=void 0;v<t.length;v++)if(A=t[v],C=u[A],C.constructor===Array)for(var D=0;D<C.length;D++)r.push(A,C[D]);else r.push(A,C)}m=r;if(!a){h=[];if(r.length)for(g=0;g<r.length;g+=2){p=void 0;if(this.db){p=this.index.get(r[g]);if(!p)continue;h.push(p=p.db.tag(r[g+1],b,q,n))}else p=vb.call(this,r[g],r[g+1],b,q,n);e.push({field:r[g],tag:r[g+1],result:p})}return h.length?Promise.all(h).then(function(O){for(var P=0;P<O.length;P++)e[P].result=
O[P];return e}):e}}L(l)&&(l=[l])}l||(l=this.field);r=!d&&(this.worker||this.async)&&[];y=0;for(v=u=t=void 0;y<l.length;y++)if(u=l[y],!this.db||!this.tag||this.M[y]){t=void 0;L(u)||(t=u,u=t.field,a=t.query||a,b=t.limit||b,p=t.suggest||p);if(d)t=d[y];else{v=t||c;t=this.index.get(u);if(m){if(this.db){v.tag=m;var E=t.db.qa;v.field=l}E||(v.enrich=!1)}if(r){r[y]=t.searchAsync(a,b,v);v&&n&&(v.enrich=n);continue}else t=t.search(a,b,v),v&&n&&(v.enrich=n)}v=t&&t.length;if(m&&v){A=[];C=0;if(this.db&&d){if(!E)for(D=
l.length;D<d.length;D++){var J=d[D];if(J&&J.length)C++,A.push(J);else if(!p)return e}}else{D=0;for(var Gb=J=void 0;D<m.length;D+=2){J=this.tag.get(m[D]);if(!J)if(p)continue;else return e;if(Gb=(J=J&&J.get(m[D+1]))&&J.length)C++,A.push(J);else if(!p)return e}}if(C){t=jb(t,A);v=t.length;if(!v&&!p)return e;C--}}if(v)h[f]=u,e.push(t),f++;else if(1===l.length)return e}if(r){if(this.db&&m&&m.length&&!E)for(n=0;n<m.length;n+=2){h=this.index.get(m[n]);if(!h)if(p)continue;else return e;r.push(h.db.tag(m[n+
1],b,q,!1))}var Hb=this;return Promise.all(r).then(function(O){return O.length?Hb.search(a,b,c,O):O})}if(!f)return e;if(g&&(!n||!this.store))return e[0];r=[];q=0;for(p=void 0;q<h.length;q++){p=e[q];n&&p.length&&!p[0].doc&&(this.db?r.push(p=this.index.get(this.field[0]).db.enrich(p)):p.length&&(p=wb.call(this,p)));if(g)return p;e[q]={field:h[q],result:p}}return n&&this.db&&r.length?Promise.all(r).then(function(O){for(var P=0;P<O.length;P++)e[P].result=O[P];return k?xb(e,b):e}):k?xb(e,b):e};
function xb(a,b){for(var c=[],d=K(),e=0,h,f;e<a.length;e++){h=a[e];f=h.result;for(var g=0,k,l,m;g<f.length;g++)if(l=f[g],k=l.id,m=d[k])m.push(h.field);else{if(c.length===b)return c;l.field=d[k]=[h.field];c.push(l)}}return c}function vb(a,b,c,d,e){a=this.tag.get(a);if(!a)return[];if((b=(a=a&&a.get(b))&&a.length-d)&&0<b){if(b>c||d)a=a.slice(d,d+c);e&&(a=wb.call(this,a));return a}}function wb(a){for(var b=Array(a.length),c=0,d;c<a.length;c++)d=a[c],b[c]={id:d,doc:this.store.get(d)};return b};function Z(a){if(!this)return new Z(a);var b=a.document||a.doc||a,c,d;this.M=[];this.field=[];this.U=[];this.key=(c=b.key||b.id)&&yb(c,this.U)||"id";(d=a.keystore||0)&&(this.keystore=d);this.reg=(this.fastupdate=!!a.fastupdate)?d?new S(d):new Map:d?new T(d):new Set;this.H=(c=b.store||null)&&!0!==c&&[];this.store=c&&(d?new S(d):new Map);this.cache=(c=a.cache||null)&&new Q(c);a.cache=!1;this.worker=a.worker;this.async=!1;c=new Map;d=b.index||b.field||b;L(d)&&(d=[d]);for(var e=0,h,f=void 0;e<d.length;e++){h=
d[e];L(h)||(f=h,h=h.field);f=M(f)?Object.assign({},a,f):a;if(this.worker){var g=new qb(f);c.set(h,g);g.worker||(this.worker=!1)}this.worker||c.set(h,new V(f,this.reg));f.custom?this.M[e]=f.custom:(this.M[e]=yb(h,this.U),f.filter&&("string"===typeof this.M[e]&&(this.M[e]=new String(this.M[e])),this.M[e].S=f.filter));this.field[e]=h}if(this.H)for(d=b.store,L(d)&&(d=[d]),e=0;e<d.length;e++)h=d[e],f=h.field||h,h.custom?(this.H[e]=h.custom,h.custom.ma=f):(this.H[e]=yb(f,this.U),h.filter&&("string"===typeof this.H[e]&&
(this.H[e]=new String(this.H[e])),this.H[e].S=h.filter));this.index=c;this.tag=null;if(c=b.tag)if("string"===typeof c&&(c=[c]),c.length)for(this.tag=new Map,this.L=[],this.aa=[],b=0;b<c.length;b++){d=c[b];e=d.field||d;if(!e)throw Error("The tag field from the document descriptor is undefined.");d.custom?this.L[b]=d.custom:(this.L[b]=yb(e,this.U),d.filter&&("string"===typeof this.L[b]&&(this.L[b]=new String(this.L[b])),this.L[b].S=d.filter));this.aa[b]=e;this.tag.set(e,new Map)}a.db&&this.mount(a.db)}
w=Z.prototype;w.mount=function(a){var b=this.field;if(this.tag)for(var c=0,d;c<this.aa.length;c++){d=this.aa[c];var e=this.index.get(d);e||(this.index.set(d,e=new V({},this.reg)),b===this.field&&(b=b.slice(0)),b.push(d));e.tag=this.tag.get(d)}c=[];d={db:a.db,type:a.type,fastupdate:a.fastupdate};e=0;for(var h;e<b.length;e++){d.field=h=b[e];h=this.index.get(h);var f=new a.constructor(a.id,d);f.id=a.id;c[e]=f.mount(h);h.document=!0;e?h.na=!0:h.store=this.store}this.db=this.async=!0;return Promise.all(c)};
w.commit=function(a,b){var c=this,d,e,h,f;return sa(function(g){if(1==g.h){d=[];e=x(c.index.values());for(h=e.next();!h.done;h=e.next())f=h.value,d.push(f.db.commit(f,a,b));return F(g,Promise.all(d),2)}c.reg.clear();g.h=0})};function yb(a,b){for(var c=a.split(":"),d=0,e=0;e<c.length;e++)a=c[e],"]"===a[a.length-1]&&(a=a.substring(0,a.length-2))&&(b[d]=!0),a&&(c[d++]=a);d<c.length&&(c.length=d);return 1<d?c:c[0]}w.append=function(a,b){return this.add(a,b,!0)};
w.update=function(a,b){return this.remove(a).add(a,b)};
w.remove=function(a){M(a)&&(a=ya(a,this.key));for(var b=x(this.index.values()),c=b.next();!c.done;c=b.next())c.value.remove(a,!0);if(this.B.has(a)){if(this.tag&&!this.fastupdate)for(b=x(this.tag.values()),c=b.next();!c.done;c=b.next()){c=c.value;for(var d=x(c),e=d.next();!e.done;e=d.next()){var g=e.value;e=g[0];g=g[1];var f=g.indexOf(a);-1<f&&(1<g.length?g.splice(f,1):c.delete(e))}}this.store&&this.store.delete(a);this.B.delete(a)}this.cache&&this.cache.remove(a);return this};
w.clear=function(){for(var a=x(this.index.values()),b=a.next();!b.done;b=a.next())b.value.clear();if(this.tag)for(a=x(this.tag.values()),b=a.next();!b.done;b=a.next())b.value.clear();this.store&&this.store.clear();return this};w.contain=function(a){return this.db?this.index.get(this.field[0]).db.has(a):this.B.has(a)};w.cleanup=function(){for(var a=x(this.index.values()),b=a.next();!b.done;b=a.next())b.value.cleanup();return this};
w.remove=function(a){M(a)&&(a=ya(a,this.key));for(var b=x(this.index.values()),c=b.next();!c.done;c=b.next())c.value.remove(a,!0);if(this.reg.has(a)){if(this.tag&&!this.fastupdate)for(b=x(this.tag.values()),c=b.next();!c.done;c=b.next()){c=c.value;for(var d=x(c),e=d.next();!e.done;e=d.next()){var h=e.value;e=h[0];h=h[1];var f=h.indexOf(a);-1<f&&(1<h.length?h.splice(f,1):c.delete(e))}}this.store&&this.store.delete(a);this.reg.delete(a)}this.cache&&this.cache.remove(a);return this};
w.clear=function(){for(var a=x(this.index.values()),b=a.next();!b.done;b=a.next())b.value.clear();if(this.tag)for(a=x(this.tag.values()),b=a.next();!b.done;b=a.next())b.value.clear();this.store&&this.store.clear();return this};w.contain=function(a){return this.db?this.index.get(this.field[0]).db.has(a):this.reg.has(a)};w.cleanup=function(){for(var a=x(this.index.values()),b=a.next();!b.done;b=a.next())b.value.cleanup();return this};
w.get=function(a){return this.db?this.index.get(this.field[0]).db.enrich(a).then(function(b){return b[0]&&b[0].doc}):this.store.get(a)};w.set=function(a,b){this.store.set(a,b);return this};w.searchCache=Ha;
w.export=function(a,b,c,d,e,g){var f;"undefined"===typeof g&&(f=new Promise(function(k){g=k}));e||(e=0);d||(d=0);if(d<this.field.length){c=this.field[d];var h=this.index[c];b=this;h.export(a,b,e?c:"",d,e++,g)||(d++,b.export(a,b,c,d,1,g))}else{switch(e){case 1:b="tag";h=this.h;c=null;break;case 2:b="store";h=this.store;c=null;break;default:g();return}Xa(a,this,c,b,d,e,h,g)}return f};
w.import=function(a,b){if(b)switch(L(b)&&(b=JSON.parse(b)),a){case "tag":this.h=b;break;case "reg":this.fastupdate=!1;this.B=b;a=0;for(var c;a<this.field.length;a++)c=this.index[this.field[a]],c.B=b,c.fastupdate=!1;break;case "store":this.store=b;break;default:a=a.split("."),c=a[0],a=a[1],c&&a&&this.index[c].import(a,b)}};Za(Z.prototype);var zb="undefined"!==typeof window&&(window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB),Ab=["map","ctx","tag","reg","cfg"];
function Bb(a,b){b=void 0===b?{}:b;if(!this)return new Bb(a,b);"object"===typeof a&&(b=a=a.name);a||console.info("Default storage space was used, because a name was not passed.");this.id="flexsearch"+(a?":"+a.toLowerCase().replace(/[^a-z0-9_\-]/g,""):"");this.field=b.field?b.field.toLowerCase().replace(/[^a-z0-9_\-]/g,""):"";this.sa=!1;this.db=null;this.h={}}w=Bb.prototype;w.mount=function(a){if(a.constructor===Z)return a.mount(this);a.db=this;return Cb(this)};
function Cb(a){navigator.storage&&navigator.storage.persist();return a.db||new Promise(function(b,c){var d=zb.open(a.id+(a.field?":"+a.field:""),1);d.onupgradeneeded=function(){var e=a.db=this.result;Ab.forEach(function(g){e.objectStoreNames.contains(g)||e.createObjectStore(g)})};d.onblocked=function(e){console.error("blocked",e);c()};d.onerror=function(e){console.error(this.error,e);c()};d.onsuccess=function(){a.db=this.result;a.db.onversionchange=function(){a.close()};b(a)}})}
w.export=function(a,b,c,d,e,h){var f;"undefined"===typeof h&&(f=new Promise(function(k){h=k}));e||(e=0);d||(d=0);if(d<this.field.length){c=this.field[d];var g=this.index[c];b=this;g.export(a,b,e?c:"",d,e++,h)||(d++,b.export(a,b,c,d,1,h))}else{switch(e){case 1:b="tag";g=this.h;c=null;break;case 2:b="store";g=this.store;c=null;break;default:h();return}Xa(a,this,c,b,d,e,g,h)}return f};
w.import=function(a,b){if(b)switch(L(b)&&(b=JSON.parse(b)),a){case "tag":this.h=b;break;case "reg":this.fastupdate=!1;this.reg=b;a=0;for(var c;a<this.field.length;a++)c=this.index[this.field[a]],c.reg=b,c.fastupdate=!1;break;case "store":this.store=b;break;default:a=a.split("."),c=a[0],a=a[1],c&&a&&this.index[c].import(a,b)}};Za(Z.prototype);var zb="undefined"!==typeof window&&(window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB),Ab=["map","ctx","tag","reg","cfg"];
function Bb(a,b){b=void 0===b?{}:b;if(!this)return new Bb(a,b);"object"===typeof a&&(b=a=a.name);a||console.info("Default storage space was used, because a name was not passed.");this.id="flexsearch"+(a?":"+a.toLowerCase().replace(/[^a-z0-9_\-]/g,""):"");this.field=b.field?b.field.toLowerCase().replace(/[^a-z0-9_\-]/g,""):"";this.qa=!1;this.db=null;this.h={}}w=Bb.prototype;w.mount=function(a){if(a.constructor===Z)return a.mount(this);a.db=this;return Cb(this)};
function Cb(a){navigator.storage&&navigator.storage.persist();return a.db||new Promise(function(b,c){var d=zb.open(a.id+(a.field?":"+a.field:""),1);d.onupgradeneeded=function(){var e=a.db=this.result;Ab.forEach(function(h){e.objectStoreNames.contains(h)||e.createObjectStore(h)})};d.onblocked=function(e){console.error("blocked",e);c()};d.onerror=function(e){console.error(this.error,e);c()};d.onsuccess=function(){a.db=this.result;a.db.onversionchange=function(){a.close()};b(a)}})}
w.close=function(){this.db.close();this.db=null};w.clear=function(){for(var a=this.db.transaction(Ab,"readwrite"),b=0;b<Ab.length;b++)a.objectStore(Ab[b]).clear();return Db(a)};
w.get=function(a,b,c,d,e,g){c=void 0===c?0:c;d=void 0===d?0:d;e=void 0===e?!0:e;g=void 0===g?!1:g;a=this.db.transaction(b?"ctx":"map","readonly").objectStore(b?"ctx":"map").get(b?b+":"+a:a);var f=this;return Db(a).then(function(h){var k=[];if(!h||!h.length)return k;if(e){if(!c&&!d&&1===h.length)return h[0];for(var l=0,m=void 0;l<h.length;l++)if((m=h[l])&&m.length)if(d>=m.length)d-=m.length;else{for(var n=c?d+Math.min(m.length-d,c):m.length,p=d;p<n;p++)k.push(m[p]);d=0;if(k.length===c)break}return g?
f.enrich(k):k}return h})};w.tag=function(a,b,c,d){b=void 0===b?0:b;c=void 0===c?0:c;d=void 0===d?!1:d;a=this.db.transaction("tag","readonly").objectStore("tag").get(a);var e=this;return Db(a).then(function(g){if(!g||!g.length||c>=g.length)return[];if(!b&&!c)return g;g=g.slice(c,c+b);return d?e.enrich(g):g})};
w.enrich=function(a){"object"!==typeof a&&(a=[a]);for(var b=this.db.transaction("reg","readonly").objectStore("reg"),c=[],d=0;d<a.length;d++)c[d]=Db(b.get(a[d]));return Promise.all(c).then(function(e){for(var g=0;g<e.length;g++)e[g]={id:a[g],doc:e[g]?JSON.parse(e[g]):null};return e})};w.has=function(a){a=this.db.transaction("reg","readonly").objectStore("reg").getKey(a);return Db(a)};w.search=null;w.info=function(){};
w.transaction=function(a,b,c){var d=this,e=this.h[a+":"+b];if(e)return c.call(this,e);var g=this.db.transaction(a,b);this.h[a+":"+b]=e=g.objectStore(a);return new Promise(function(f,h){g.onerror=function(k){d.h[a+":"+b]=null;g.abort();g=e=null;h(k)};g.oncomplete=function(k){g=e=d.h[a+":"+b]=null;f(k||!0)};return c.call(d,e)})};
w.commit=function(a,b,c){var d=this,e,g,f;return sa(function(h){switch(h.h){case 1:if(b)return F(h,d.clear(),12);e=a.R;a.R=[];g=0;f=void 0;case 4:if(!(g<e.length)){h.h=6;break}f=e[g];if(!f.clear){e[g]=f.ta;h.h=5;break}return F(h,d.clear(),8);case 8:b=!0;h.h=6;break;case 5:g++;h.h=4;break;case 6:if(b){h.h=3;break}c||(e=e.concat(xa(a.B)));if(!e.length){h.h=10;break}return F(h,d.remove(e),11);case 11:case 10:h.h=3;break;case 12:a.R=[];case 3:return a.B.size?F(h,d.transaction("map","readwrite",function(k){for(var l=
x(a.map),m=l.next(),n={};!m.done;n={S:void 0,aa:void 0},m=l.next())m=m.value,n.aa=m[0],n.S=m[1],n.S.length&&(b?k.put(n.S,n.aa):k.get(n.aa).onsuccess=function(p){return function(){var q=this.result,r;if(q&&q.length)for(var y=Math.max(q.length,p.S.length),u=0,t;u<y;u++){if((t=p.S[u])&&t.length){if((r=q[u])&&r.length)for(var v=0;v<t.length;v++)r.push(t[v]);else q[u]=t;r=1}}else q=p.S,r=1;r&&k.put(q,p.aa)}}(n))}),13):h.return();case 13:return F(h,d.transaction("ctx","readwrite",function(k){for(var l=
x(a.J),m=l.next(),n={};!m.done;n={Z:void 0},m=l.next()){m=m.value;n.Z=m[0];m=x(m[1]);for(var p=m.next(),q={};!p.done;q={T:void 0,ba:void 0},p=m.next())p=p.value,q.ba=p[0],q.T=p[1],q.T.length&&(b?k.put(q.T,n.Z+":"+q.ba):k.get(n.Z+":"+q.ba).onsuccess=function(r,y){return function(){var u=this.result,t;if(u&&u.length)for(var v=Math.max(u.length,r.T.length),A=0,C;A<v;A++){if((C=r.T[A])&&C.length){if((t=u[A])&&t.length)for(var D=0;D<C.length;D++)t.push(C[D]);else u[A]=C;t=1}}else u=r.T,t=1;t&&k.put(u,
y.Z+":"+r.ba)}}(q,n))}}),14);case 14:if(a.store)return F(h,d.transaction("reg","readwrite",function(k){for(var l=x(a.store),m=l.next();!m.done;m=l.next()){var n=m.value;m=n[0];n=n[1];k.put("object"===typeof n?JSON.stringify(n):1,m)}}),16);if(a.pa){h.h=16;break}return F(h,d.transaction("reg","readwrite",function(k){for(var l=x(a.B.keys()),m=l.next();!m.done;m=l.next())k.put(1,m.value)}),16);case 16:if(!a.tag){h.h=20;break}return F(h,d.transaction("tag","readwrite",function(k){for(var l=x(a.tag),m=
l.next(),n={};!m.done;n={$:void 0,ea:void 0},m=l.next())m=m.value,n.ea=m[0],n.$=m[1],n.$.length&&(k.get(n.ea).onsuccess=function(p){return function(){var q=this.result;q=q&&q.length?q.concat(p.$):p.$;k.put(q,p.ea)}}(n))}),20);case 20:a.map.clear(),a.J.clear(),a.tag&&a.tag.clear(),a.store&&a.store.clear(),a.document||a.B.clear(),h.h=0}})};
function Eb(a,b,c){for(var d=a.value,e,g,f=0,h=0,k;h<d.length;h++){if(k=c?d:d[h]){for(var l=0,m,n;l<b.length;l++)if(n=b[l],m=k.indexOf(g?parseInt(n,10):n),0>m&&!g&&"string"===typeof n&&!isNaN(n)&&(m=k.indexOf(parseInt(n,10)))&&(g=1),0<=m)if(e=1,1<k.length)k.splice(m,1);else{d[h]=[];break}f+=k.length}if(c)break}f?e&&a.update(d):a.delete();a.continue()}
w.get=function(a,b,c,d,e,h){c=void 0===c?0:c;d=void 0===d?0:d;e=void 0===e?!0:e;h=void 0===h?!1:h;a=this.db.transaction(b?"ctx":"map","readonly").objectStore(b?"ctx":"map").get(b?b+":"+a:a);var f=this;return Db(a).then(function(g){var k=[];if(!g||!g.length)return k;if(e){if(!c&&!d&&1===g.length)return g[0];for(var l=0,m=void 0;l<g.length;l++)if((m=g[l])&&m.length)if(d>=m.length)d-=m.length;else{for(var n=c?d+Math.min(m.length-d,c):m.length,p=d;p<n;p++)k.push(m[p]);d=0;if(k.length===c)break}return h?
f.enrich(k):k}return g})};w.tag=function(a,b,c,d){b=void 0===b?0:b;c=void 0===c?0:c;d=void 0===d?!1:d;a=this.db.transaction("tag","readonly").objectStore("tag").get(a);var e=this;return Db(a).then(function(h){if(!h||!h.length||c>=h.length)return[];if(!b&&!c)return h;h=h.slice(c,c+b);return d?e.enrich(h):h})};
w.enrich=function(a){"object"!==typeof a&&(a=[a]);for(var b=this.db.transaction("reg","readonly").objectStore("reg"),c=[],d=0;d<a.length;d++)c[d]=Db(b.get(a[d]));return Promise.all(c).then(function(e){for(var h=0;h<e.length;h++)e[h]={id:a[h],doc:e[h]?JSON.parse(e[h]):null};return e})};w.has=function(a){a=this.db.transaction("reg","readonly").objectStore("reg").getKey(a);return Db(a)};w.search=null;w.info=function(){};
w.transaction=function(a,b,c){var d=this,e=this.h[a+":"+b];if(e)return c.call(this,e);var h=this.db.transaction(a,b);this.h[a+":"+b]=e=h.objectStore(a);return new Promise(function(f,g){h.onerror=function(k){d.h[a+":"+b]=null;h.abort();h=e=null;g(k)};h.oncomplete=function(k){h=e=d.h[a+":"+b]=null;f(k||!0)};return c.call(d,e)})};
w.commit=function(a,b,c){var d=this,e,h,f;return sa(function(g){switch(g.h){case 1:if(b)return F(g,d.clear(),12);e=a.O;a.O=[];h=0;f=void 0;case 4:if(!(h<e.length)){g.h=6;break}f=e[h];if(!f.clear){e[h]=f.ra;g.h=5;break}return F(g,d.clear(),8);case 8:b=!0;g.h=6;break;case 5:h++;g.h=4;break;case 6:if(b){g.h=3;break}c||(e=e.concat(xa(a.reg)));if(!e.length){g.h=10;break}return F(g,d.remove(e),11);case 11:case 10:g.h=3;break;case 12:a.O=[];case 3:return a.reg.size?F(g,d.transaction("map","readwrite",function(k){for(var l=
x(a.map),m=l.next(),n={};!m.done;n={P:void 0,Z:void 0},m=l.next())m=m.value,n.Z=m[0],n.P=m[1],n.P.length&&(b?k.put(n.P,n.Z):k.get(n.Z).onsuccess=function(p){return function(){var q=this.result,r;if(q&&q.length)for(var y=Math.max(q.length,p.P.length),u=0,t;u<y;u++){if((t=p.P[u])&&t.length){if((r=q[u])&&r.length)for(var v=0;v<t.length;v++)r.push(t[v]);else q[u]=t;r=1}}else q=p.P,r=1;r&&k.put(q,p.Z)}}(n))}),13):g.return();case 13:return F(g,d.transaction("ctx","readwrite",function(k){for(var l=x(a.ctx),
m=l.next(),n={};!m.done;n={X:void 0},m=l.next()){m=m.value;n.X=m[0];m=x(m[1]);for(var p=m.next(),q={};!p.done;q={R:void 0,$:void 0},p=m.next())p=p.value,q.$=p[0],q.R=p[1],q.R.length&&(b?k.put(q.R,n.X+":"+q.$):k.get(n.X+":"+q.$).onsuccess=function(r,y){return function(){var u=this.result,t;if(u&&u.length)for(var v=Math.max(u.length,r.R.length),A=0,C;A<v;A++){if((C=r.R[A])&&C.length){if((t=u[A])&&t.length)for(var D=0;D<C.length;D++)t.push(C[D]);else u[A]=C;t=1}}else u=r.R,t=1;t&&k.put(u,y.X+":"+r.$)}}(q,
n))}}),14);case 14:if(a.store)return F(g,d.transaction("reg","readwrite",function(k){for(var l=x(a.store),m=l.next();!m.done;m=l.next()){var n=m.value;m=n[0];n=n[1];k.put("object"===typeof n?JSON.stringify(n):1,m)}}),16);if(a.na){g.h=16;break}return F(g,d.transaction("reg","readwrite",function(k){for(var l=x(a.reg.keys()),m=l.next();!m.done;m=l.next())k.put(1,m.value)}),16);case 16:if(!a.tag){g.h=20;break}return F(g,d.transaction("tag","readwrite",function(k){for(var l=x(a.tag),m=l.next(),n={};!m.done;n=
{Y:void 0,ca:void 0},m=l.next())m=m.value,n.ca=m[0],n.Y=m[1],n.Y.length&&(k.get(n.ca).onsuccess=function(p){return function(){var q=this.result;q=q&&q.length?q.concat(p.Y):p.Y;k.put(q,p.ca)}}(n))}),20);case 20:a.map.clear(),a.ctx.clear(),a.tag&&a.tag.clear(),a.store&&a.store.clear(),a.document||a.reg.clear(),g.h=0}})};
function Eb(a,b,c){for(var d=a.value,e,h,f=0,g=0,k;g<d.length;g++){if(k=c?d:d[g]){for(var l=0,m,n;l<b.length;l++)if(n=b[l],m=k.indexOf(h?parseInt(n,10):n),0>m&&!h&&"string"===typeof n&&!isNaN(n)&&(m=k.indexOf(parseInt(n,10)))&&(h=1),0<=m)if(e=1,1<k.length)k.splice(m,1);else{d[g]=[];break}f+=k.length}if(c)break}f?e&&a.update(d):a.delete();a.continue()}
w.remove=function(a){"object"!==typeof a&&(a=[a]);return Promise.all([this.transaction("map","readwrite",function(b){b.openCursor().onsuccess=function(){var c=this.result;c&&Eb(c,a)}}),this.transaction("ctx","readwrite",function(b){b.openCursor().onsuccess=function(){var c=this.result;c&&Eb(c,a)}}),this.transaction("tag","readwrite",function(b){b.openCursor().onsuccess=function(){var c=this.result;c&&Eb(c,a,!0)}}),this.transaction("reg","readwrite",function(b){for(var c=0;c<a.length;c++)b.delete(a[c])})])};
function Db(a){return new Promise(function(b,c){a.onsuccess=function(){b(this.result)};a.oncomplete=function(){b(this.result)};a.onerror=c;a=null})};var Fb={Index:V,Charset:Qa,Encoder:N,Document:Z,Worker:qb,Resolver:X,IndexedDB:Bb,Language:{}},Ib=self,Jb;(Jb=Ib.define)&&Jb.amd?Jb([],function(){return Fb}):"object"===typeof Ib.exports?Ib.exports=Fb:Ib.FlexSearch=Fb;}(this));

View File

@@ -89,32 +89,32 @@ C.prototype.assign = function(a) {
this.minlength = t(a.minlength, 1, this.minlength);
this.maxlength = t(a.maxlength, 0, this.maxlength);
if (this.cache = b = t(a.cache, !0, this.cache)) {
this.m = null, this.B = "number" === typeof b ? b : 2e5, this.i = new Map(), this.j = new Map(), this.o = this.h = 128;
this.j = null, this.v = "number" === typeof b ? b : 2e5, this.h = new Map(), this.i = new Map(), this.l = this.g = 128;
}
this.s = "";
this.v = null;
this.u = "";
this.A = null;
this.m = "";
this.s = null;
this.o = "";
this.u = null;
if (this.matcher) {
for (const d of this.matcher.keys()) {
this.s += (this.s ? "|" : "") + d;
this.m += (this.m ? "|" : "") + d;
}
}
if (this.stemmer) {
for (const d of this.stemmer.keys()) {
this.u += (this.u ? "|" : "") + d;
this.o += (this.o ? "|" : "") + d;
}
}
return this;
};
C.prototype.encode = function(a) {
if (this.cache && a.length <= this.h) {
if (this.m) {
if (this.i.has(a)) {
return this.i.get(a);
if (this.cache && a.length <= this.g) {
if (this.j) {
if (this.h.has(a)) {
return this.h.get(a);
}
} else {
this.m = setTimeout(D, 0, this);
this.j = setTimeout(D, 0, this);
}
}
this.normalize && (a = "function" === typeof this.normalize ? this.normalize(a) : B ? a.normalize("NFKD").replace(B, "").toLowerCase() : a.toLowerCase());
@@ -136,20 +136,20 @@ C.prototype.encode = function(a) {
if (this.filter && this.filter.has(f)) {
continue;
}
if (this.cache && f.length <= this.o) {
if (this.m) {
var e = this.j.get(f);
if (this.cache && f.length <= this.l) {
if (this.j) {
var e = this.i.get(f);
if (e || "" === e) {
e && b.push(e);
continue;
}
} else {
this.m = setTimeout(D, 0, this);
this.j = setTimeout(D, 0, this);
}
}
let k;
this.stemmer && 2 < f.length && (this.A || (this.A = new RegExp("(?!^)(" + this.u + ")$")), f = f.replace(this.A, m => this.stemmer.get(m)), k = 1);
this.matcher && 1 < f.length && (this.v || (this.v = new RegExp("(" + this.s + ")", "g")), f = f.replace(this.v, m => this.matcher.get(m)), k = 1);
this.stemmer && 2 < f.length && (this.u || (this.u = new RegExp("(?!^)(" + this.o + ")$")), f = f.replace(this.u, m => this.stemmer.get(m)), k = 1);
this.matcher && 1 < f.length && (this.s || (this.s = new RegExp("(" + this.m + ")", "g")), f = f.replace(this.s, m => this.matcher.get(m)), k = 1);
f && k && (f.length < this.minlength || this.filter && this.filter.has(f)) && (f = "");
if (f && (this.mapper || this.dedupe && 1 < f.length)) {
e = "";
@@ -163,30 +163,30 @@ C.prototype.encode = function(a) {
f = f.replace(this.replacer[e], this.replacer[e + 1]);
}
}
this.cache && h.length <= this.o && (this.j.set(h, f), this.j.size > this.B && (this.j.clear(), this.o = this.o / 1.1 | 0));
this.cache && h.length <= this.l && (this.i.set(h, f), this.i.size > this.v && (this.i.clear(), this.l = this.l / 1.1 | 0));
f && b.push(f);
}
this.finalize && (b = this.finalize(b) || b);
this.cache && a.length <= this.h && (this.i.set(a, b), this.i.size > this.B && (this.i.clear(), this.h = this.h / 1.1 | 0));
this.cache && a.length <= this.g && (this.h.set(a, b), this.h.size > this.v && (this.h.clear(), this.g = this.g / 1.1 | 0));
return b;
};
function D(a) {
a.m = null;
a.j = null;
a.h.clear();
a.i.clear();
a.j.clear();
}
;function E(a) {
this.limit = a && !0 !== a ? a : 1000;
this.cache = new Map();
this.h = "";
this.g = "";
}
E.prototype.set = function(a, c) {
this.cache.set(this.h = a, c);
this.cache.set(this.g = a, c);
this.cache.size > this.limit && this.cache.delete(this.cache.keys().next().value);
};
E.prototype.get = function(a) {
const c = this.cache.get(a);
c && this.h !== a && (this.cache.delete(a), this.cache.set(this.h = a, c));
c && this.g !== a && (this.cache.delete(a), this.cache.set(this.g = a, c));
return c;
};
E.prototype.remove = function(a) {
@@ -197,7 +197,7 @@ E.prototype.remove = function(a) {
};
E.prototype.clear = function() {
this.cache.clear();
this.h = "";
this.g = "";
};
const F = {normalize:function(a) {
return a.toLowerCase();
@@ -206,7 +206,7 @@ const G = {memory:{resolution:1}, performance:{resolution:6, fastupdate:!0, cont
u();
H.prototype.add = function(a, c, b, d) {
if (c && (a || 0 === a)) {
if (!d && !b && this.g.has(a)) {
if (!d && !b && this.reg.has(a)) {
return this.update(a, c);
}
c = this.encoder.encode(c);
@@ -245,7 +245,7 @@ H.prototype.add = function(a, c, b, d) {
}
default:
if (J(this, l, q, g, a, b), p && 1 < d && n < d - 1) {
for (e = u(), f = this.C, g = q, h = Math.min(p + 1, d - n), e[g] = 1, k = 1; k < h; k++) {
for (e = u(), f = this.A, g = q, h = Math.min(p + 1, d - n), e[g] = 1, k = 1; k < h; k++) {
if ((q = c[this.rtl ? d - 1 - n - k : n + k]) && !e[q]) {
e[q] = 1;
const A = this.score ? this.score(c, g, n, q, k) : I(f + (d / 2 > f ? 0 : 1), d, n, h - 1, k - 1), M = this.bidirectional && q > g;
@@ -256,14 +256,14 @@ H.prototype.add = function(a, c, b, d) {
}
}
}
this.fastupdate || this.g.add(a);
this.fastupdate || this.reg.add(a);
}
}
return this;
};
function J(a, c, b, d, e, g, f) {
let h = f ? a.l : a.map, k;
c[b] && f && (k = c[b])[f] || (f ? (c = k || (c[b] = u()), c[f] = 1, (k = h.get(f)) ? h = k : h.set(f, h = new Map())) : c[b] = 1, (k = h.get(b)) ? h = k : h.set(b, h = []), h = h[d] || (h[d] = []), g && h.includes(e) || (h.push(e), a.fastupdate && ((c = a.g.get(e)) ? c.push(h) : a.g.set(e, [h]))));
let h = f ? a.ctx : a.map, k;
c[b] && f && (k = c[b])[f] || (f ? (c = k || (c[b] = u()), c[f] = 1, (k = h.get(f)) ? h = k : h.set(f, h = new Map())) : c[b] = 1, (k = h.get(b)) ? h = k : h.set(b, h = []), h = h[d] || (h[d] = []), g && h.includes(e) || (h.push(e), a.fastupdate && ((c = a.reg.get(e)) ? c.push(h) : a.reg.set(e, [h]))));
}
function I(a, c, b, d, e) {
return b && 1 < a ? c + (d || 0) <= a ? b + (e || 0) : (a - 1) / (c + (d || 0)) * (b + (e || 0)) + 1 | 0 : 0;
@@ -357,7 +357,7 @@ function I(a, c, b, d, e) {
}
for (let p, r; m < b; m++) {
r = a[m];
l ? (p = N(this, r, l), p = O(p, d, f, this.C, c, e, 2 === b), f && !1 === p && d.length || (l = r)) : (p = N(this, r), p = O(p, d, f, this.resolution, c, e, 1 === b));
l ? (p = N(this, r, l), p = O(p, d, f, this.A, c, e, 2 === b), f && !1 === p && d.length || (l = r)) : (p = N(this, r), p = O(p, d, f, this.resolution, c, e, 1 === b));
if (p) {
return p;
}
@@ -458,11 +458,11 @@ function O(a, c, b, d, e, g, f) {
function N(a, c, b) {
let d;
b && (d = a.bidirectional && c > b);
a = b ? (a = a.l.get(d ? c : b)) && a.get(d ? b : c) : a.map.get(c);
a = b ? (a = a.ctx.get(d ? c : b)) && a.get(d ? b : c) : a.map.get(c);
return a;
}
;H.prototype.remove = function(a, c) {
const b = this.g.size && (this.fastupdate ? this.g.get(a) : this.g.has(a));
const b = this.reg.size && (this.fastupdate ? this.reg.get(a) : this.reg.has(a));
if (b) {
if (this.fastupdate) {
for (let d = 0, e; d < b.length; d++) {
@@ -476,9 +476,9 @@ function N(a, c, b) {
}
}
} else {
P(this.map, a), this.depth && P(this.l, a);
P(this.map, a), this.depth && P(this.ctx, a);
}
c || this.g.delete(a);
c || this.reg.delete(a);
}
this.cache && this.cache.remove(a);
return this;
@@ -526,16 +526,16 @@ function P(a, c) {
this.score = a.score || null;
e = !1;
this.map = new Map();
this.l = new Map();
this.g = c || (this.fastupdate ? new Map() : new Set());
this.C = b.resolution || 1;
this.ctx = new Map();
this.reg = c || (this.fastupdate ? new Map() : new Set());
this.A = b.resolution || 1;
this.rtl = d.rtl || a.rtl || !1;
this.cache = (e = a.cache || null) && new E(e);
}
H.prototype.clear = function() {
this.map.clear();
this.l.clear();
this.g.clear();
this.ctx.clear();
this.reg.clear();
this.cache && this.cache.clear();
return this;
};
@@ -543,7 +543,7 @@ H.prototype.append = function(a, c) {
return this.add(a, c, !0);
};
H.prototype.contain = function(a) {
return this.g.has(a);
return this.reg.has(a);
};
H.prototype.update = function(a, c) {
if (this.async) {
@@ -571,7 +571,7 @@ H.prototype.cleanup = function() {
return console.info('Cleanup the index isn\'t required when not using "fastupdate".'), this;
}
Q(this.map);
this.depth && Q(this.l);
this.depth && Q(this.ctx);
return this;
};
H.prototype.searchCache = function(a, c, b) {

View File

@@ -8,18 +8,18 @@
(function(self){'use strict';function t(a,c,b){const d=typeof b,e=typeof a;if("undefined"!==d){if("undefined"!==e){if(b){if("function"===e&&d===e)return function(h){return a(b(h))};c=a.constructor;if(c===b.constructor){if(c===Array)return b.concat(a);if(c===Map){var g=new Map(b);for(var f of a)g.set(f[0],f[1]);return g}if(c===Set){f=new Set(b);for(g of a.values())f.add(g);return f}}}return a}return b}return"undefined"===e?c:a}function u(){return Object.create(null)}function v(a,c){return c.length-a.length};const w=/[^\p{L}\p{N}]+/u,x=/(\d{3})/g,y=/(\D)(\d{3})/g,z=/(\d{3})(\D)/g,B="".normalize&&/[\u0300-\u036f]/g;function C(a){if(!this)return new C(...arguments);for(let c=0;c<arguments.length;c++)this.assign(arguments[c])}
C.prototype.assign=function(a){this.normalize=t(a.normalize,!0,this.normalize);let c=a.include,b=c||a.exclude||a.split;if("object"===typeof b){let d=!c,e="";a.include||(e+="\\p{Z}");b.letter&&(e+="\\p{L}");b.number&&(e+="\\p{N}",d=!!c);b.symbol&&(e+="\\p{S}");b.punctuation&&(e+="\\p{P}");b.control&&(e+="\\p{C}");if(b=b.char)e+="object"===typeof b?b.join(""):b;this.split=new RegExp("["+(c?"^":"")+e+"]+","u");this.numeric=d}else this.split=t(b,w,this.split),this.numeric=t(this.numeric,!0);this.prepare=
t(a.prepare,null,this.prepare);this.finalize=t(a.finalize,null,this.finalize);this.rtl=a.rtl||!1;this.dedupe=t(a.dedupe,!0,this.dedupe);this.filter=t((b=a.filter)&&new Set(b),null,this.filter);this.matcher=t((b=a.matcher)&&new Map(b),null,this.matcher);this.mapper=t((b=a.mapper)&&new Map(b),null,this.mapper);this.stemmer=t((b=a.stemmer)&&new Map(b),null,this.stemmer);this.replacer=t(a.replacer,null,this.replacer);this.minlength=t(a.minlength,1,this.minlength);this.maxlength=t(a.maxlength,0,this.maxlength);
if(this.cache=b=t(a.cache,!0,this.cache))this.m=null,this.B="number"===typeof b?b:2E5,this.i=new Map,this.j=new Map,this.o=this.h=128;this.s="";this.v=null;this.u="";this.A=null;if(this.matcher)for(const d of this.matcher.keys())this.s+=(this.s?"|":"")+d;if(this.stemmer)for(const d of this.stemmer.keys())this.u+=(this.u?"|":"")+d;return this};
C.prototype.encode=function(a){if(this.cache&&a.length<=this.h)if(this.m){if(this.i.has(a))return this.i.get(a)}else this.m=setTimeout(D,0,this);this.normalize&&(a="function"===typeof this.normalize?this.normalize(a):B?a.normalize("NFKD").replace(B,"").toLowerCase():a.toLowerCase());this.prepare&&(a=this.prepare(a));this.numeric&&3<a.length&&(a=a.replace(y,"$1 $2").replace(z,"$1 $2").replace(x,"$1 "));const c=!(this.dedupe||this.mapper||this.filter||this.matcher||this.stemmer||this.replacer);let b=
[],d=this.split||""===this.split?a.split(this.split):a;for(let g=0,f,h;g<d.length;g++){if(!(f=h=d[g]))continue;if(f.length<this.minlength)continue;if(c){b.push(f);continue}if(this.filter&&this.filter.has(f))continue;if(this.cache&&f.length<=this.o)if(this.m){var e=this.j.get(f);if(e||""===e){e&&b.push(e);continue}}else this.m=setTimeout(D,0,this);let k;this.stemmer&&2<f.length&&(this.A||(this.A=new RegExp("(?!^)("+this.u+")$")),f=f.replace(this.A,m=>this.stemmer.get(m)),k=1);this.matcher&&1<f.length&&
(this.v||(this.v=new RegExp("("+this.s+")","g")),f=f.replace(this.v,m=>this.matcher.get(m)),k=1);f&&k&&(f.length<this.minlength||this.filter&&this.filter.has(f))&&(f="");if(f&&(this.mapper||this.dedupe&&1<f.length)){e="";for(let m=0,l="",p,r;m<f.length;m++)p=f.charAt(m),p===l&&this.dedupe||((r=this.mapper&&this.mapper.get(p))||""===r?r===l&&this.dedupe||!(l=r)||(e+=r):e+=l=p);f=e}if(f&&this.replacer)for(e=0;f&&e<this.replacer.length;e+=2)f=f.replace(this.replacer[e],this.replacer[e+1]);this.cache&&
h.length<=this.o&&(this.j.set(h,f),this.j.size>this.B&&(this.j.clear(),this.o=this.o/1.1|0));f&&b.push(f)}this.finalize&&(b=this.finalize(b)||b);this.cache&&a.length<=this.h&&(this.i.set(a,b),this.i.size>this.B&&(this.i.clear(),this.h=this.h/1.1|0));return b};function D(a){a.m=null;a.i.clear();a.j.clear()};function E(a){this.limit=a&&!0!==a?a:1E3;this.cache=new Map;this.h=""}E.prototype.set=function(a,c){this.cache.set(this.h=a,c);this.cache.size>this.limit&&this.cache.delete(this.cache.keys().next().value)};E.prototype.get=function(a){const c=this.cache.get(a);c&&this.h!==a&&(this.cache.delete(a),this.cache.set(this.h=a,c));return c};E.prototype.remove=function(a){for(const c of this.cache){const b=c[0];c[1].includes(a)&&this.cache.delete(b)}};
E.prototype.clear=function(){this.cache.clear();this.h=""};const F={normalize:function(a){return a.toLowerCase()},dedupe:!1};const G={memory:{resolution:1},performance:{resolution:6,fastupdate:!0,context:{depth:1,resolution:3}},match:{tokenize:"forward"},score:{resolution:9,context:{depth:2,resolution:9}}};u();H.prototype.add=function(a,c,b,d){if(c&&(a||0===a)){if(!d&&!b&&this.g.has(a))return this.update(a,c);c=this.encoder.encode(c);if(d=c.length){const m=u(),l=u(),p=this.depth,r=this.resolution;for(let n=0;n<d;n++){let q=c[this.rtl?d-1-n:n];var e=q.length;if(e&&(p||!l[q])){var g=this.score?this.score(c,q,n,null,0):I(r,d,n),f="";switch(this.tokenize){case "full":if(2<e){for(g=0;g<e;g++)for(var h=e;h>g;h--){f=q.substring(g,h);var k=this.score?this.score(c,q,n,f,g):I(r,d,n,e,g);J(this,l,f,k,a,b)}break}case "reverse":if(1<
e){for(h=e-1;0<h;h--)f=q[h]+f,k=this.score?this.score(c,q,n,f,h):I(r,d,n,e,h),J(this,l,f,k,a,b);f=""}case "forward":if(1<e){for(h=0;h<e;h++)f+=q[h],J(this,l,f,g,a,b);break}default:if(J(this,l,q,g,a,b),p&&1<d&&n<d-1)for(e=u(),f=this.C,g=q,h=Math.min(p+1,d-n),e[g]=1,k=1;k<h;k++)if((q=c[this.rtl?d-1-n-k:n+k])&&!e[q]){e[q]=1;const A=this.score?this.score(c,g,n,q,k):I(f+(d/2>f?0:1),d,n,h-1,k-1),L=this.bidirectional&&q>g;J(this,m,L?g:q,A,a,b,L?q:g)}}}}this.fastupdate||this.g.add(a)}}return this};
function J(a,c,b,d,e,g,f){let h=f?a.l:a.map,k;c[b]&&f&&(k=c[b])[f]||(f?(c=k||(c[b]=u()),c[f]=1,(k=h.get(f))?h=k:h.set(f,h=new Map)):c[b]=1,(k=h.get(b))?h=k:h.set(b,h=[]),h=h[d]||(h[d]=[]),g&&h.includes(e)||(h.push(e),a.fastupdate&&((c=a.g.get(e))?c.push(h):a.g.set(e,[h]))))}function I(a,c,b,d,e){return b&&1<a?c+(d||0)<=a?b+(e||0):(a-1)/(c+(d||0))*(b+(e||0))+1|0:0};function K(a,c,b){if(1===a.length)return a=a[0],a=b||a.length>c?c?a.slice(b,b+c):a.slice(b):a;let d=[];for(let e=0,g,f;e<a.length;e++)if((g=a[e])&&(f=g.length)){if(b){if(b>=f){b-=f;continue}b<f&&(g=c?g.slice(b,b+c):g.slice(b),f=g.length,b=0)}if(d.length)f>c&&(g=g.slice(0,c),f=g.length),d.push(g);else{if(f>=c)return f>c&&(g=g.slice(0,c)),g;d=[g]}c-=f;if(!c)break}return d.length?d=1<d.length?[].concat.apply([],d):d[0]:d};H.prototype.search=function(a,c,b){b||(c||"object"!==typeof a?"object"===typeof c&&(b=c,c=0):(b=a,a=""));var d=[],e=0;if(b){a=b.query||a;c=b.limit||c;e=b.offset||0;var g=b.context;var f=b.suggest}a=this.encoder.encode(a);b=a.length;c||(c=100);if(1===b)return M.call(this,a[0],"",c,e);g=this.depth&&!1!==g;if(2===b&&g&&!f)return M.call(this,a[0],a[1],c,e);var h=0,k=0;if(1<b){var m=u();const p=[];for(let r=0,n;r<b;r++)if((n=a[r])&&!m[n]){if(f||N(this,n))p.push(n),m[n]=1;else return d;const q=n.length;
h=Math.max(h,q);k=k?Math.min(k,q):q}a=p;b=a.length}if(!b)return d;m=0;if(1===b)return M.call(this,a[0],"",c,e);if(2===b&&g&&!f)return M.call(this,a[0],a[1],c,e);if(1<b)if(g){var l=a[0];m=1}else 9<h&&3<h/k&&a.sort(v);for(let p,r;m<b;m++){r=a[m];l?(p=N(this,r,l),p=O(p,d,f,this.C,c,e,2===b),f&&!1===p&&d.length||(l=r)):(p=N(this,r),p=O(p,d,f,this.resolution,c,e,1===b));if(p)return p;if(f&&m===b-1){g=d.length;if(!g){if(l){l="";m=-1;continue}return d}if(1===g)return K(d[0],c,e)}}a:{a=d;d=this.resolution;
if(this.cache=b=t(a.cache,!0,this.cache))this.j=null,this.v="number"===typeof b?b:2E5,this.h=new Map,this.i=new Map,this.l=this.g=128;this.m="";this.s=null;this.o="";this.u=null;if(this.matcher)for(const d of this.matcher.keys())this.m+=(this.m?"|":"")+d;if(this.stemmer)for(const d of this.stemmer.keys())this.o+=(this.o?"|":"")+d;return this};
C.prototype.encode=function(a){if(this.cache&&a.length<=this.g)if(this.j){if(this.h.has(a))return this.h.get(a)}else this.j=setTimeout(D,0,this);this.normalize&&(a="function"===typeof this.normalize?this.normalize(a):B?a.normalize("NFKD").replace(B,"").toLowerCase():a.toLowerCase());this.prepare&&(a=this.prepare(a));this.numeric&&3<a.length&&(a=a.replace(y,"$1 $2").replace(z,"$1 $2").replace(x,"$1 "));const c=!(this.dedupe||this.mapper||this.filter||this.matcher||this.stemmer||this.replacer);let b=
[],d=this.split||""===this.split?a.split(this.split):a;for(let g=0,f,h;g<d.length;g++){if(!(f=h=d[g]))continue;if(f.length<this.minlength)continue;if(c){b.push(f);continue}if(this.filter&&this.filter.has(f))continue;if(this.cache&&f.length<=this.l)if(this.j){var e=this.i.get(f);if(e||""===e){e&&b.push(e);continue}}else this.j=setTimeout(D,0,this);let k;this.stemmer&&2<f.length&&(this.u||(this.u=new RegExp("(?!^)("+this.o+")$")),f=f.replace(this.u,m=>this.stemmer.get(m)),k=1);this.matcher&&1<f.length&&
(this.s||(this.s=new RegExp("("+this.m+")","g")),f=f.replace(this.s,m=>this.matcher.get(m)),k=1);f&&k&&(f.length<this.minlength||this.filter&&this.filter.has(f))&&(f="");if(f&&(this.mapper||this.dedupe&&1<f.length)){e="";for(let m=0,l="",p,r;m<f.length;m++)p=f.charAt(m),p===l&&this.dedupe||((r=this.mapper&&this.mapper.get(p))||""===r?r===l&&this.dedupe||!(l=r)||(e+=r):e+=l=p);f=e}if(f&&this.replacer)for(e=0;f&&e<this.replacer.length;e+=2)f=f.replace(this.replacer[e],this.replacer[e+1]);this.cache&&
h.length<=this.l&&(this.i.set(h,f),this.i.size>this.v&&(this.i.clear(),this.l=this.l/1.1|0));f&&b.push(f)}this.finalize&&(b=this.finalize(b)||b);this.cache&&a.length<=this.g&&(this.h.set(a,b),this.h.size>this.v&&(this.h.clear(),this.g=this.g/1.1|0));return b};function D(a){a.j=null;a.h.clear();a.i.clear()};function E(a){this.limit=a&&!0!==a?a:1E3;this.cache=new Map;this.g=""}E.prototype.set=function(a,c){this.cache.set(this.g=a,c);this.cache.size>this.limit&&this.cache.delete(this.cache.keys().next().value)};E.prototype.get=function(a){const c=this.cache.get(a);c&&this.g!==a&&(this.cache.delete(a),this.cache.set(this.g=a,c));return c};E.prototype.remove=function(a){for(const c of this.cache){const b=c[0];c[1].includes(a)&&this.cache.delete(b)}};
E.prototype.clear=function(){this.cache.clear();this.g=""};const F={normalize:function(a){return a.toLowerCase()},dedupe:!1};const G={memory:{resolution:1},performance:{resolution:6,fastupdate:!0,context:{depth:1,resolution:3}},match:{tokenize:"forward"},score:{resolution:9,context:{depth:2,resolution:9}}};u();H.prototype.add=function(a,c,b,d){if(c&&(a||0===a)){if(!d&&!b&&this.reg.has(a))return this.update(a,c);c=this.encoder.encode(c);if(d=c.length){const m=u(),l=u(),p=this.depth,r=this.resolution;for(let n=0;n<d;n++){let q=c[this.rtl?d-1-n:n];var e=q.length;if(e&&(p||!l[q])){var g=this.score?this.score(c,q,n,null,0):I(r,d,n),f="";switch(this.tokenize){case "full":if(2<e){for(g=0;g<e;g++)for(var h=e;h>g;h--){f=q.substring(g,h);var k=this.score?this.score(c,q,n,f,g):I(r,d,n,e,g);J(this,l,f,k,a,b)}break}case "reverse":if(1<
e){for(h=e-1;0<h;h--)f=q[h]+f,k=this.score?this.score(c,q,n,f,h):I(r,d,n,e,h),J(this,l,f,k,a,b);f=""}case "forward":if(1<e){for(h=0;h<e;h++)f+=q[h],J(this,l,f,g,a,b);break}default:if(J(this,l,q,g,a,b),p&&1<d&&n<d-1)for(e=u(),f=this.A,g=q,h=Math.min(p+1,d-n),e[g]=1,k=1;k<h;k++)if((q=c[this.rtl?d-1-n-k:n+k])&&!e[q]){e[q]=1;const A=this.score?this.score(c,g,n,q,k):I(f+(d/2>f?0:1),d,n,h-1,k-1),L=this.bidirectional&&q>g;J(this,m,L?g:q,A,a,b,L?q:g)}}}}this.fastupdate||this.reg.add(a)}}return this};
function J(a,c,b,d,e,g,f){let h=f?a.ctx:a.map,k;c[b]&&f&&(k=c[b])[f]||(f?(c=k||(c[b]=u()),c[f]=1,(k=h.get(f))?h=k:h.set(f,h=new Map)):c[b]=1,(k=h.get(b))?h=k:h.set(b,h=[]),h=h[d]||(h[d]=[]),g&&h.includes(e)||(h.push(e),a.fastupdate&&((c=a.reg.get(e))?c.push(h):a.reg.set(e,[h]))))}function I(a,c,b,d,e){return b&&1<a?c+(d||0)<=a?b+(e||0):(a-1)/(c+(d||0))*(b+(e||0))+1|0:0};function K(a,c,b){if(1===a.length)return a=a[0],a=b||a.length>c?c?a.slice(b,b+c):a.slice(b):a;let d=[];for(let e=0,g,f;e<a.length;e++)if((g=a[e])&&(f=g.length)){if(b){if(b>=f){b-=f;continue}b<f&&(g=c?g.slice(b,b+c):g.slice(b),f=g.length,b=0)}if(d.length)f>c&&(g=g.slice(0,c),f=g.length),d.push(g);else{if(f>=c)return f>c&&(g=g.slice(0,c)),g;d=[g]}c-=f;if(!c)break}return d.length?d=1<d.length?[].concat.apply([],d):d[0]:d};H.prototype.search=function(a,c,b){b||(c||"object"!==typeof a?"object"===typeof c&&(b=c,c=0):(b=a,a=""));var d=[],e=0;if(b){a=b.query||a;c=b.limit||c;e=b.offset||0;var g=b.context;var f=b.suggest}a=this.encoder.encode(a);b=a.length;c||(c=100);if(1===b)return M.call(this,a[0],"",c,e);g=this.depth&&!1!==g;if(2===b&&g&&!f)return M.call(this,a[0],a[1],c,e);var h=0,k=0;if(1<b){var m=u();const p=[];for(let r=0,n;r<b;r++)if((n=a[r])&&!m[n]){if(f||N(this,n))p.push(n),m[n]=1;else return d;const q=n.length;
h=Math.max(h,q);k=k?Math.min(k,q):q}a=p;b=a.length}if(!b)return d;m=0;if(1===b)return M.call(this,a[0],"",c,e);if(2===b&&g&&!f)return M.call(this,a[0],a[1],c,e);if(1<b)if(g){var l=a[0];m=1}else 9<h&&3<h/k&&a.sort(v);for(let p,r;m<b;m++){r=a[m];l?(p=N(this,r,l),p=O(p,d,f,this.A,c,e,2===b),f&&!1===p&&d.length||(l=r)):(p=N(this,r),p=O(p,d,f,this.resolution,c,e,1===b));if(p)return p;if(f&&m===b-1){g=d.length;if(!g){if(l){l="";m=-1;continue}return d}if(1===g)return K(d[0],c,e)}}a:{a=d;d=this.resolution;
l=a.length;b=[];g=u();for(let p=0,r,n,q,A;p<d;p++)for(k=0;k<l;k++)if(q=a[k],p<q.length&&(r=q[p]))for(m=0;m<r.length;m++)n=r[m],(h=g[n])?g[n]++:(h=0,g[n]=1),A=b[h]||(b[h]=[]),A.push(n);if(a=b.length)if(f){if(1<b.length){f=b;a=[];d=u();g=f.length;for(k=0;k<g;k++)for(l=f[k],h=l.length,m=0;m<h;m++)if(b=l[m],!d[b])if(d[b]=1,e)e--;else if(a.push(b),a.length===c)break;c=a}else c=b[0];b=c}else{if(a<l){d=[];break a}b=b[a-1];if(b.length>c||e)b=b.slice(e,c+e)}d=b}return d};
function M(a,c,b,d){return(a=N(this,a,c))&&a.length?K(a,b,d):[]}function O(a,c,b,d,e,g,f){let h=[];if(a){d=Math.min(a.length,d);for(let k=0,m=0,l;k<d;k++)if(l=a[k])if(g&&l&&f&&(l.length<=g?(g-=l.length,l=null):(l=l.slice(g),g=0)),l&&(h[k]=l,f&&(m+=l.length,m>=e)))break;if(h.length){if(f)return K(h,e,0);c.push(h);return}}return!b&&h}function N(a,c,b){let d;b&&(d=a.bidirectional&&c>b);a=b?(a=a.l.get(d?c:b))&&a.get(d?b:c):a.map.get(c);return a};H.prototype.remove=function(a,c){const b=this.g.size&&(this.fastupdate?this.g.get(a):this.g.has(a));if(b){if(this.fastupdate)for(let d=0,e;d<b.length;d++){if(e=b[d])if(2>e.length)e.pop();else{const g=e.indexOf(a);g===b.length-1?e.pop():e.splice(g,1)}}else P(this.map,a),this.depth&&P(this.l,a);c||this.g.delete(a)}this.cache&&this.cache.remove(a);return this};
function P(a,c){let b=0;if(a.constructor===Array)for(let d=0,e,g;d<a.length;d++){if((e=a[d])&&e.length)if(g=e.indexOf(c),0<=g){1<e.length?(e.splice(g,1),b++):delete a[d];break}else b++}else for(let d of a){const e=d[0],g=P(d[1],c);g?b+=g:a.delete(e)}return b};function H(a,c){if(!this)return new H(a);if(a){var b="string"===typeof a?a:a.preset;b&&(a=Object.assign({},G[b],a))}else a={};b=a.context||{};const d=a.encode||a.encoder||F;this.encoder=d.encode?d:"object"===typeof d?new C(d):{encode:d};let e;this.resolution=a.resolution||9;this.tokenize=e=a.tokenize||"strict";this.depth="strict"===e&&b.depth||0;this.bidirectional=!1!==b.bidirectional;this.fastupdate=!!a.fastupdate;this.score=a.score||null;e=!1;this.map=new Map;this.l=new Map;this.g=c||(this.fastupdate?
new Map:new Set);this.C=b.resolution||1;this.rtl=d.rtl||a.rtl||!1;this.cache=(e=a.cache||null)&&new E(e)}H.prototype.clear=function(){this.map.clear();this.l.clear();this.g.clear();this.cache&&this.cache.clear();return this};H.prototype.append=function(a,c){return this.add(a,c,!0)};H.prototype.contain=function(a){return this.g.has(a)};H.prototype.update=function(a,c){if(this.async){const b=this,d=this.remove(a);return d.then?d.then(()=>b.add(a,c)):this.add(a,c)}return this.remove(a).add(a,c)};
function Q(a){let c=0;if(a.constructor===Array)for(let b=0,d;b<a.length;b++)(d=a[b])&&(c+=d.length);else for(const b of a){const d=b[0],e=Q(b[1]);e?c+=e:a.delete(d)}return c}H.prototype.cleanup=function(){if(!this.fastupdate)return this;Q(this.map);this.depth&&Q(this.l);return this};
function M(a,c,b,d){return(a=N(this,a,c))&&a.length?K(a,b,d):[]}function O(a,c,b,d,e,g,f){let h=[];if(a){d=Math.min(a.length,d);for(let k=0,m=0,l;k<d;k++)if(l=a[k])if(g&&l&&f&&(l.length<=g?(g-=l.length,l=null):(l=l.slice(g),g=0)),l&&(h[k]=l,f&&(m+=l.length,m>=e)))break;if(h.length){if(f)return K(h,e,0);c.push(h);return}}return!b&&h}function N(a,c,b){let d;b&&(d=a.bidirectional&&c>b);a=b?(a=a.ctx.get(d?c:b))&&a.get(d?b:c):a.map.get(c);return a};H.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 d=0,e;d<b.length;d++){if(e=b[d])if(2>e.length)e.pop();else{const g=e.indexOf(a);g===b.length-1?e.pop():e.splice(g,1)}}else P(this.map,a),this.depth&&P(this.ctx,a);c||this.reg.delete(a)}this.cache&&this.cache.remove(a);return this};
function P(a,c){let b=0;if(a.constructor===Array)for(let d=0,e,g;d<a.length;d++){if((e=a[d])&&e.length)if(g=e.indexOf(c),0<=g){1<e.length?(e.splice(g,1),b++):delete a[d];break}else b++}else for(let d of a){const e=d[0],g=P(d[1],c);g?b+=g:a.delete(e)}return b};function H(a,c){if(!this)return new H(a);if(a){var b="string"===typeof a?a:a.preset;b&&(a=Object.assign({},G[b],a))}else a={};b=a.context||{};const d=a.encode||a.encoder||F;this.encoder=d.encode?d:"object"===typeof d?new C(d):{encode:d};let e;this.resolution=a.resolution||9;this.tokenize=e=a.tokenize||"strict";this.depth="strict"===e&&b.depth||0;this.bidirectional=!1!==b.bidirectional;this.fastupdate=!!a.fastupdate;this.score=a.score||null;e=!1;this.map=new Map;this.ctx=new Map;this.reg=c||(this.fastupdate?
new Map:new Set);this.A=b.resolution||1;this.rtl=d.rtl||a.rtl||!1;this.cache=(e=a.cache||null)&&new E(e)}H.prototype.clear=function(){this.map.clear();this.ctx.clear();this.reg.clear();this.cache&&this.cache.clear();return this};H.prototype.append=function(a,c){return this.add(a,c,!0)};H.prototype.contain=function(a){return this.reg.has(a)};H.prototype.update=function(a,c){if(this.async){const b=this,d=this.remove(a);return d.then?d.then(()=>b.add(a,c)):this.add(a,c)}return this.remove(a).add(a,c)};
function Q(a){let c=0;if(a.constructor===Array)for(let b=0,d;b<a.length;b++)(d=a[b])&&(c+=d.length);else for(const b of a){const d=b[0],e=Q(b[1]);e?c+=e:a.delete(d)}return c}H.prototype.cleanup=function(){if(!this.fastupdate)return this;Q(this.map);this.depth&&Q(this.ctx);return this};
H.prototype.searchCache=function(a,c,b){a=("object"===typeof a?""+a.query:a).toLowerCase();let d=this.cache.get(a);if(!d){d=this.search(a,c,b);if(d.then){const e=this;d.then(function(g){e.cache.set(a,g);return g})}this.cache.set(a,d)}return d};const R={Index:H,Charset:null,Encoder:C,Document:null,Worker:null,Resolver:null,IndexedDB:null,Language:{}},S=self;let T;(T=S.define)&&T.amd?T([],function(){return R}):"object"===typeof S.exports?S.exports=R:S.FlexSearch=R;}(this));

View File

@@ -14,15 +14,15 @@ function u(a, c) {
;function v(a) {
this.limit = a && !0 !== a ? a : 1000;
this.cache = new Map();
this.B = "";
this.h = "";
}
v.prototype.set = function(a, c) {
this.cache.set(this.B = a, c);
this.cache.set(this.h = a, c);
this.cache.size > this.limit && this.cache.delete(this.cache.keys().next().value);
};
v.prototype.get = function(a) {
const c = this.cache.get(a);
c && this.B !== a && (this.cache.delete(a), this.cache.set(this.B = a, c));
c && this.h !== a && (this.cache.delete(a), this.cache.set(this.h = a, c));
return c;
};
v.prototype.remove = function(a) {
@@ -33,7 +33,7 @@ v.prototype.remove = function(a) {
};
v.prototype.clear = function() {
this.cache.clear();
this.B = "";
this.h = "";
};
const w = new Map([["b", "p"], ["v", "f"], ["w", "f"], ["z", "s"], ["x", "s"], ["d", "t"], ["n", "m"], ["c", "k"], ["g", "k"], ["j", "k"], ["q", "k"], ["i", "e"], ["y", "e"], ["u", "o"]]);
const x = new Map([["ai", "ei"], ["ae", "a"], ["oe", "o"], ["ue", "u"], ["sh", "s"], ["ch", "c"], ["th", "t"], ["ph", "f"], ["pf", "f"]]), z = [/([^aeo])h([aeo$])/g, "$1$2", /([aeo])h([^aeo]|$)/g, "$1$2"];
@@ -67,7 +67,7 @@ function G(a) {
;t();
H.prototype.add = function(a, c, b, d) {
if (c && (a || 0 === a)) {
if (!d && !b && this.h.has(a)) {
if (!d && !b && this.reg.has(a)) {
return this.update(a, c);
}
c = this.encoder.encode(c);
@@ -106,7 +106,7 @@ H.prototype.add = function(a, c, b, d) {
}
default:
if (K(this, m, n, f, a, b), q && 1 < d && l < d - 1) {
for (e = t(), g = this.C, f = n, h = Math.min(q + 1, d - l), e[f] = 1, k = 1; k < h; k++) {
for (e = t(), g = this.A, f = n, h = Math.min(q + 1, d - l), e[f] = 1, k = 1; k < h; k++) {
if ((n = c[this.rtl ? d - 1 - l - k : l + k]) && !e[n]) {
e[n] = 1;
const y = this.score ? this.score(c, f, l, n, k) : I(g + (d / 2 > g ? 0 : 1), d, l, h - 1, k - 1), J = this.bidirectional && n > f;
@@ -117,14 +117,14 @@ H.prototype.add = function(a, c, b, d) {
}
}
}
this.fastupdate || this.h.add(a);
this.fastupdate || this.reg.add(a);
}
}
return this;
};
function K(a, c, b, d, e, f, g) {
let h = g ? a.A : a.map, k;
c[b] && g && (k = c[b])[g] || (g ? (c = k || (c[b] = t()), c[g] = 1, (k = h.get(g)) ? h = k : h.set(g, h = new Map())) : c[b] = 1, (k = h.get(b)) ? h = k : h.set(b, h = []), h = h[d] || (h[d] = []), f && h.includes(e) || (h.push(e), a.fastupdate && ((c = a.h.get(e)) ? c.push(h) : a.h.set(e, [h]))));
let h = g ? a.ctx : a.map, k;
c[b] && g && (k = c[b])[g] || (g ? (c = k || (c[b] = t()), c[g] = 1, (k = h.get(g)) ? h = k : h.set(g, h = new Map())) : c[b] = 1, (k = h.get(b)) ? h = k : h.set(b, h = []), h = h[d] || (h[d] = []), f && h.includes(e) || (h.push(e), a.fastupdate && ((c = a.reg.get(e)) ? c.push(h) : a.reg.set(e, [h]))));
}
function I(a, c, b, d, e) {
return b && 1 < a ? c + (d || 0) <= a ? b + (e || 0) : (a - 1) / (c + (d || 0)) * (b + (e || 0)) + 1 | 0 : 0;
@@ -218,7 +218,7 @@ function I(a, c, b, d, e) {
}
for (let q, r; p < b; p++) {
r = a[p];
m ? (q = N(this, r, m), q = O(q, d, g, this.C, c, e, 2 === b), g && !1 === q && d.length || (m = r)) : (q = N(this, r), q = O(q, d, g, this.resolution, c, e, 1 === b));
m ? (q = N(this, r, m), q = O(q, d, g, this.A, c, e, 2 === b), g && !1 === q && d.length || (m = r)) : (q = N(this, r), q = O(q, d, g, this.resolution, c, e, 1 === b));
if (q) {
return q;
}
@@ -319,11 +319,11 @@ function O(a, c, b, d, e, f, g) {
function N(a, c, b) {
let d;
b && (d = a.bidirectional && c > b);
a = b ? (a = a.A.get(d ? c : b)) && a.get(d ? b : c) : a.map.get(c);
a = b ? (a = a.ctx.get(d ? c : b)) && a.get(d ? b : c) : a.map.get(c);
return a;
}
;H.prototype.remove = function(a, c) {
const b = this.h.size && (this.fastupdate ? this.h.get(a) : this.h.has(a));
const b = this.reg.size && (this.fastupdate ? this.reg.get(a) : this.reg.has(a));
if (b) {
if (this.fastupdate) {
for (let d = 0, e; d < b.length; d++) {
@@ -337,9 +337,9 @@ function N(a, c, b) {
}
}
} else {
P(this.map, a), this.depth && P(this.A, a);
P(this.map, a), this.depth && P(this.ctx, a);
}
c || this.h.delete(a);
c || this.reg.delete(a);
}
this.cache && this.cache.remove(a);
return this;
@@ -383,16 +383,16 @@ function P(a, c) {
this.score = a.score || null;
e = !1;
this.map = new Map();
this.A = new Map();
this.h = c || (this.fastupdate ? new Map() : new Set());
this.C = b.resolution || 1;
this.ctx = new Map();
this.reg = c || (this.fastupdate ? new Map() : new Set());
this.A = b.resolution || 1;
this.rtl = d.rtl || a.rtl || !1;
this.cache = (e = a.cache || null) && new v(e);
}
H.prototype.clear = function() {
this.map.clear();
this.A.clear();
this.h.clear();
this.ctx.clear();
this.reg.clear();
this.cache && this.cache.clear();
return this;
};
@@ -400,7 +400,7 @@ H.prototype.append = function(a, c) {
return this.add(a, c, !0);
};
H.prototype.contain = function(a) {
return this.h.has(a);
return this.reg.has(a);
};
H.prototype.update = function(a, c) {
if (this.async) {
@@ -428,7 +428,7 @@ H.prototype.cleanup = function() {
return console.info('Cleanup the index isn\'t required when not using "fastupdate".'), this;
}
Q(this.map);
this.depth && Q(this.A);
this.depth && Q(this.ctx);
return this;
};
H.prototype.searchCache = function(a, c, b) {

View File

@@ -5,16 +5,16 @@
* Hosted by Nextapps GmbH
* https://github.com/nextapps-de/flexsearch
*/
function t(){return Object.create(null)}function u(a,c){return c.length-a.length};function v(a){this.limit=a&&!0!==a?a:1E3;this.cache=new Map;this.B=""}v.prototype.set=function(a,c){this.cache.set(this.B=a,c);this.cache.size>this.limit&&this.cache.delete(this.cache.keys().next().value)};v.prototype.get=function(a){const c=this.cache.get(a);c&&this.B!==a&&(this.cache.delete(a),this.cache.set(this.B=a,c));return c};v.prototype.remove=function(a){for(const c of this.cache){const b=c[0];c[1].includes(a)&&this.cache.delete(b)}};
v.prototype.clear=function(){this.cache.clear();this.B=""};const w=new Map([["b","p"],["v","f"],["w","f"],["z","s"],["x","s"],["d","t"],["n","m"],["c","k"],["g","k"],["j","k"],["q","k"],["i","e"],["y","e"],["u","o"]]);const x=new Map([["ai","ei"],["ae","a"],["oe","o"],["ue","u"],["sh","s"],["ch","c"],["th","t"],["ph","f"],["pf","f"]]),z=[/([^aeo])h([aeo$])/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2"];const A={a:"",e:"",i:"",o:"",u:"",y:"",b:1,f:1,p:1,v:1,c:2,g:2,j:2,k:2,q:2,s:2,x:2,z:2,"\u00df":2,d:3,t:3,l:4,m:5,n:5,r:6};const B=/[\x00-\x7F]+/g;const C=/[\x00-\x7F]+/g;const D=/[\x00-\x7F]+/g;var E={LatinExact:{normalize:!1,dedupe:!1},LatinDefault:{normalize:function(a){return a.toLowerCase()},dedupe:!1},LatinSimple:{normalize:!0,dedupe:!0},LatinBalance:{normalize:!0,dedupe:!0,mapper:w},LatinAdvanced:{normalize:!0,dedupe:!0,mapper:w,replacer:z,matcher:x},LatinExtra:{normalize:!0,dedupe:!0,mapper:w,replacer:z.concat([/(?!^)[aeoy]/g,""]),matcher:x},LatinSoundex:{normalize:!0,dedupe:!1,include:{letter:!0},finalize:function(a){for(let b=0;b<a.length;b++){var c=a[b];let d=c.charAt(0),e=A[d];
for(let f=1,g;f<c.length&&(g=c.charAt(f),"h"===g||"w"===g||!(g=A[g])||g===e||(d+=g,e=g,4!==d.length));f++);a[b]=d}}},ArabicDefault:{rtl:!0,normalize:!1,dedupe:!0,prepare:function(a){return(""+a).replace(B," ")}},CjkDefault:{normalize:!1,dedupe:!0,split:"",prepare:function(a){return(""+a).replace(C,"")}},CyrillicDefault:{normalize:!1,dedupe:!0,prepare:function(a){return(""+a).replace(D," ")}}};const F={memory:{resolution:1},performance:{resolution:6,fastupdate:!0,context:{depth:1,resolution:3}},match:{tokenize:"forward"},score:{resolution:9,context:{depth:2,resolution:9}}};function G(a){const c="string"===typeof a?a:a.preset;c&&(a=Object.assign({},F[c],a));return a};t();H.prototype.add=function(a,c,b,d){if(c&&(a||0===a)){if(!d&&!b&&this.h.has(a))return this.update(a,c);c=this.encoder.encode(c);if(d=c.length){const p=t(),m=t(),q=this.depth,r=this.resolution;for(let l=0;l<d;l++){let n=c[this.rtl?d-1-l:l];var e=n.length;if(e&&(q||!m[n])){var f=this.score?this.score(c,n,l,null,0):J(r,d,l),g="";switch(this.tokenize){case "full":if(2<e){for(f=0;f<e;f++)for(var h=e;h>f;h--){g=n.substring(f,h);var k=this.score?this.score(c,n,l,g,f):J(r,d,l,e,f);K(this,m,g,k,a,b)}break}case "reverse":if(1<
e){for(h=e-1;0<h;h--)g=n[h]+g,k=this.score?this.score(c,n,l,g,h):J(r,d,l,e,h),K(this,m,g,k,a,b);g=""}case "forward":if(1<e){for(h=0;h<e;h++)g+=n[h],K(this,m,g,f,a,b);break}default:if(K(this,m,n,f,a,b),q&&1<d&&l<d-1)for(e=t(),g=this.C,f=n,h=Math.min(q+1,d-l),e[f]=1,k=1;k<h;k++)if((n=c[this.rtl?d-1-l-k:l+k])&&!e[n]){e[n]=1;const y=this.score?this.score(c,f,l,n,k):J(g+(d/2>g?0:1),d,l,h-1,k-1),I=this.bidirectional&&n>f;K(this,p,I?f:n,y,a,b,I?n:f)}}}}this.fastupdate||this.h.add(a)}}return this};
function K(a,c,b,d,e,f,g){let h=g?a.A:a.map,k;c[b]&&g&&(k=c[b])[g]||(g?(c=k||(c[b]=t()),c[g]=1,(k=h.get(g))?h=k:h.set(g,h=new Map)):c[b]=1,(k=h.get(b))?h=k:h.set(b,h=[]),h=h[d]||(h[d]=[]),f&&h.includes(e)||(h.push(e),a.fastupdate&&((c=a.h.get(e))?c.push(h):a.h.set(e,[h]))))}function J(a,c,b,d,e){return b&&1<a?c+(d||0)<=a?b+(e||0):(a-1)/(c+(d||0))*(b+(e||0))+1|0:0};function L(a,c,b){if(1===a.length)return a=a[0],a=b||a.length>c?c?a.slice(b,b+c):a.slice(b):a;let d=[];for(let e=0,f,g;e<a.length;e++)if((f=a[e])&&(g=f.length)){if(b){if(b>=g){b-=g;continue}b<g&&(f=c?f.slice(b,b+c):f.slice(b),g=f.length,b=0)}if(d.length)g>c&&(f=f.slice(0,c),g=f.length),d.push(f);else{if(g>=c)return g>c&&(f=f.slice(0,c)),f;d=[f]}c-=g;if(!c)break}return d.length?d=1<d.length?[].concat.apply([],d):d[0]:d};H.prototype.search=function(a,c,b){b||(c||"object"!==typeof a?"object"===typeof c&&(b=c,c=0):(b=a,a=""));var d=[],e=0;if(b){a=b.query||a;c=b.limit||c;e=b.offset||0;var f=b.context;var g=!1}a=this.encoder.encode(a);b=a.length;c||(c=100);if(1===b)return M.call(this,a[0],"",c,e);f=this.depth&&!1!==f;if(2===b&&f&&!g)return M.call(this,a[0],a[1],c,e);var h=0,k=0;if(1<b){var p=t();const q=[];for(let r=0,l;r<b;r++)if((l=a[r])&&!p[l]){if(g||N(this,l))q.push(l),p[l]=1;else return d;const n=l.length;h=Math.max(h,
n);k=k?Math.min(k,n):n}a=q;b=a.length}if(!b)return d;p=0;if(1===b)return M.call(this,a[0],"",c,e);if(2===b&&f&&!g)return M.call(this,a[0],a[1],c,e);if(1<b)if(f){var m=a[0];p=1}else 9<h&&3<h/k&&a.sort(u);for(let q,r;p<b;p++){r=a[p];m?(q=N(this,r,m),q=O(q,d,g,this.C,c,e,2===b),g&&!1===q&&d.length||(m=r)):(q=N(this,r),q=O(q,d,g,this.resolution,c,e,1===b));if(q)return q;if(g&&p===b-1){f=d.length;if(!f){if(m){m="";p=-1;continue}return d}if(1===f)return L(d[0],c,e)}}a:{a=d;d=this.resolution;m=a.length;
function t(){return Object.create(null)}function u(a,c){return c.length-a.length};function v(a){this.limit=a&&!0!==a?a:1E3;this.cache=new Map;this.h=""}v.prototype.set=function(a,c){this.cache.set(this.h=a,c);this.cache.size>this.limit&&this.cache.delete(this.cache.keys().next().value)};v.prototype.get=function(a){const c=this.cache.get(a);c&&this.h!==a&&(this.cache.delete(a),this.cache.set(this.h=a,c));return c};v.prototype.remove=function(a){for(const c of this.cache){const b=c[0];c[1].includes(a)&&this.cache.delete(b)}};
v.prototype.clear=function(){this.cache.clear();this.h=""};const w=new Map([["b","p"],["v","f"],["w","f"],["z","s"],["x","s"],["d","t"],["n","m"],["c","k"],["g","k"],["j","k"],["q","k"],["i","e"],["y","e"],["u","o"]]);const x=new Map([["ai","ei"],["ae","a"],["oe","o"],["ue","u"],["sh","s"],["ch","c"],["th","t"],["ph","f"],["pf","f"]]),z=[/([^aeo])h([aeo$])/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2"];const A={a:"",e:"",i:"",o:"",u:"",y:"",b:1,f:1,p:1,v:1,c:2,g:2,j:2,k:2,q:2,s:2,x:2,z:2,"\u00df":2,d:3,t:3,l:4,m:5,n:5,r:6};const B=/[\x00-\x7F]+/g;const C=/[\x00-\x7F]+/g;const D=/[\x00-\x7F]+/g;var E={LatinExact:{normalize:!1,dedupe:!1},LatinDefault:{normalize:function(a){return a.toLowerCase()},dedupe:!1},LatinSimple:{normalize:!0,dedupe:!0},LatinBalance:{normalize:!0,dedupe:!0,mapper:w},LatinAdvanced:{normalize:!0,dedupe:!0,mapper:w,replacer:z,matcher:x},LatinExtra:{normalize:!0,dedupe:!0,mapper:w,replacer:z.concat([/(?!^)[aeoy]/g,""]),matcher:x},LatinSoundex:{normalize:!0,dedupe:!1,include:{letter:!0},finalize:function(a){for(let b=0;b<a.length;b++){var c=a[b];let d=c.charAt(0),e=A[d];
for(let f=1,g;f<c.length&&(g=c.charAt(f),"h"===g||"w"===g||!(g=A[g])||g===e||(d+=g,e=g,4!==d.length));f++);a[b]=d}}},ArabicDefault:{rtl:!0,normalize:!1,dedupe:!0,prepare:function(a){return(""+a).replace(B," ")}},CjkDefault:{normalize:!1,dedupe:!0,split:"",prepare:function(a){return(""+a).replace(C,"")}},CyrillicDefault:{normalize:!1,dedupe:!0,prepare:function(a){return(""+a).replace(D," ")}}};const F={memory:{resolution:1},performance:{resolution:6,fastupdate:!0,context:{depth:1,resolution:3}},match:{tokenize:"forward"},score:{resolution:9,context:{depth:2,resolution:9}}};function G(a){const c="string"===typeof a?a:a.preset;c&&(a=Object.assign({},F[c],a));return a};t();H.prototype.add=function(a,c,b,d){if(c&&(a||0===a)){if(!d&&!b&&this.reg.has(a))return this.update(a,c);c=this.encoder.encode(c);if(d=c.length){const p=t(),m=t(),q=this.depth,r=this.resolution;for(let l=0;l<d;l++){let n=c[this.rtl?d-1-l:l];var e=n.length;if(e&&(q||!m[n])){var f=this.score?this.score(c,n,l,null,0):J(r,d,l),g="";switch(this.tokenize){case "full":if(2<e){for(f=0;f<e;f++)for(var h=e;h>f;h--){g=n.substring(f,h);var k=this.score?this.score(c,n,l,g,f):J(r,d,l,e,f);K(this,m,g,k,a,b)}break}case "reverse":if(1<
e){for(h=e-1;0<h;h--)g=n[h]+g,k=this.score?this.score(c,n,l,g,h):J(r,d,l,e,h),K(this,m,g,k,a,b);g=""}case "forward":if(1<e){for(h=0;h<e;h++)g+=n[h],K(this,m,g,f,a,b);break}default:if(K(this,m,n,f,a,b),q&&1<d&&l<d-1)for(e=t(),g=this.A,f=n,h=Math.min(q+1,d-l),e[f]=1,k=1;k<h;k++)if((n=c[this.rtl?d-1-l-k:l+k])&&!e[n]){e[n]=1;const y=this.score?this.score(c,f,l,n,k):J(g+(d/2>g?0:1),d,l,h-1,k-1),I=this.bidirectional&&n>f;K(this,p,I?f:n,y,a,b,I?n:f)}}}}this.fastupdate||this.reg.add(a)}}return this};
function K(a,c,b,d,e,f,g){let h=g?a.ctx:a.map,k;c[b]&&g&&(k=c[b])[g]||(g?(c=k||(c[b]=t()),c[g]=1,(k=h.get(g))?h=k:h.set(g,h=new Map)):c[b]=1,(k=h.get(b))?h=k:h.set(b,h=[]),h=h[d]||(h[d]=[]),f&&h.includes(e)||(h.push(e),a.fastupdate&&((c=a.reg.get(e))?c.push(h):a.reg.set(e,[h]))))}function J(a,c,b,d,e){return b&&1<a?c+(d||0)<=a?b+(e||0):(a-1)/(c+(d||0))*(b+(e||0))+1|0:0};function L(a,c,b){if(1===a.length)return a=a[0],a=b||a.length>c?c?a.slice(b,b+c):a.slice(b):a;let d=[];for(let e=0,f,g;e<a.length;e++)if((f=a[e])&&(g=f.length)){if(b){if(b>=g){b-=g;continue}b<g&&(f=c?f.slice(b,b+c):f.slice(b),g=f.length,b=0)}if(d.length)g>c&&(f=f.slice(0,c),g=f.length),d.push(f);else{if(g>=c)return g>c&&(f=f.slice(0,c)),f;d=[f]}c-=g;if(!c)break}return d.length?d=1<d.length?[].concat.apply([],d):d[0]:d};H.prototype.search=function(a,c,b){b||(c||"object"!==typeof a?"object"===typeof c&&(b=c,c=0):(b=a,a=""));var d=[],e=0;if(b){a=b.query||a;c=b.limit||c;e=b.offset||0;var f=b.context;var g=!1}a=this.encoder.encode(a);b=a.length;c||(c=100);if(1===b)return M.call(this,a[0],"",c,e);f=this.depth&&!1!==f;if(2===b&&f&&!g)return M.call(this,a[0],a[1],c,e);var h=0,k=0;if(1<b){var p=t();const q=[];for(let r=0,l;r<b;r++)if((l=a[r])&&!p[l]){if(g||N(this,l))q.push(l),p[l]=1;else return d;const n=l.length;h=Math.max(h,
n);k=k?Math.min(k,n):n}a=q;b=a.length}if(!b)return d;p=0;if(1===b)return M.call(this,a[0],"",c,e);if(2===b&&f&&!g)return M.call(this,a[0],a[1],c,e);if(1<b)if(f){var m=a[0];p=1}else 9<h&&3<h/k&&a.sort(u);for(let q,r;p<b;p++){r=a[p];m?(q=N(this,r,m),q=O(q,d,g,this.A,c,e,2===b),g&&!1===q&&d.length||(m=r)):(q=N(this,r),q=O(q,d,g,this.resolution,c,e,1===b));if(q)return q;if(g&&p===b-1){f=d.length;if(!f){if(m){m="";p=-1;continue}return d}if(1===f)return L(d[0],c,e)}}a:{a=d;d=this.resolution;m=a.length;
b=[];f=t();for(let q=0,r,l,n,y;q<d;q++)for(k=0;k<m;k++)if(n=a[k],q<n.length&&(r=n[q]))for(p=0;p<r.length;p++)l=r[p],(h=f[l])?f[l]++:(h=0,f[l]=1),y=b[h]||(b[h]=[]),y.push(l);if(a=b.length)if(g){if(1<b.length){g=b;a=[];d=t();f=g.length;for(k=0;k<f;k++)for(m=g[k],h=m.length,p=0;p<h;p++)if(b=m[p],!d[b])if(d[b]=1,e)e--;else if(a.push(b),a.length===c)break;c=a}else c=b[0];b=c}else{if(a<m){d=[];break a}b=b[a-1];if(b.length>c||e)b=b.slice(e,c+e)}d=b}return d};
function M(a,c,b,d){return(a=N(this,a,c))&&a.length?L(a,b,d):[]}function O(a,c,b,d,e,f,g){let h=[];if(a){d=Math.min(a.length,d);for(let k=0,p=0,m;k<d;k++)if(m=a[k])if(f&&m&&g&&(m.length<=f?(f-=m.length,m=null):(m=m.slice(f),f=0)),m&&(h[k]=m,g&&(p+=m.length,p>=e)))break;if(h.length){if(g)return L(h,e,0);c.push(h);return}}return!b&&h}function N(a,c,b){let d;b&&(d=a.bidirectional&&c>b);a=b?(a=a.A.get(d?c:b))&&a.get(d?b:c):a.map.get(c);return a};H.prototype.remove=function(a,c){const b=this.h.size&&(this.fastupdate?this.h.get(a):this.h.has(a));if(b){if(this.fastupdate)for(let d=0,e;d<b.length;d++){if(e=b[d])if(2>e.length)e.pop();else{const f=e.indexOf(a);f===b.length-1?e.pop():e.splice(f,1)}}else P(this.map,a),this.depth&&P(this.A,a);c||this.h.delete(a)}this.cache&&this.cache.remove(a);return this};
function P(a,c){let b=0;if(a.constructor===Array)for(let d=0,e,f;d<a.length;d++){if((e=a[d])&&e.length)if(f=e.indexOf(c),0<=f){1<e.length?(e.splice(f,1),b++):delete a[d];break}else b++}else for(let d of a){const e=d[0],f=P(d[1],c);f?b+=f:a.delete(e)}return b};function H(a,c){if(!this)return new H(a);a=a?G(a):{};const b=a.context||{},d=a.encode||a.encoder||function(f){return f.toLowerCase().trim().split(/\s+/)};this.encoder=d.encode?d:"object"===typeof d?d:{encode:d};let e;this.resolution=a.resolution||9;this.tokenize=e=a.tokenize||"strict";this.depth="strict"===e&&b.depth||0;this.bidirectional=!1!==b.bidirectional;this.fastupdate=!!a.fastupdate;this.score=a.score||null;e=!1;this.map=new Map;this.A=new Map;this.h=c||(this.fastupdate?new Map:new Set);this.C=
b.resolution||1;this.rtl=d.rtl||a.rtl||!1;this.cache=(e=a.cache||null)&&new v(e)}H.prototype.clear=function(){this.map.clear();this.A.clear();this.h.clear();this.cache&&this.cache.clear();return this};H.prototype.append=function(a,c){return this.add(a,c,!0)};H.prototype.contain=function(a){return this.h.has(a)};H.prototype.update=function(a,c){if(this.async){const b=this,d=this.remove(a);return d.then?d.then(()=>b.add(a,c)):this.add(a,c)}return this.remove(a).add(a,c)};
function Q(a){let c=0;if(a.constructor===Array)for(let b=0,d;b<a.length;b++)(d=a[b])&&(c+=d.length);else for(const b of a){const d=b[0],e=Q(b[1]);e?c+=e:a.delete(d)}return c}H.prototype.cleanup=function(){if(!this.fastupdate)return this;Q(this.map);this.depth&&Q(this.A);return this};
function M(a,c,b,d){return(a=N(this,a,c))&&a.length?L(a,b,d):[]}function O(a,c,b,d,e,f,g){let h=[];if(a){d=Math.min(a.length,d);for(let k=0,p=0,m;k<d;k++)if(m=a[k])if(f&&m&&g&&(m.length<=f?(f-=m.length,m=null):(m=m.slice(f),f=0)),m&&(h[k]=m,g&&(p+=m.length,p>=e)))break;if(h.length){if(g)return L(h,e,0);c.push(h);return}}return!b&&h}function N(a,c,b){let d;b&&(d=a.bidirectional&&c>b);a=b?(a=a.ctx.get(d?c:b))&&a.get(d?b:c):a.map.get(c);return a};H.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 d=0,e;d<b.length;d++){if(e=b[d])if(2>e.length)e.pop();else{const f=e.indexOf(a);f===b.length-1?e.pop():e.splice(f,1)}}else P(this.map,a),this.depth&&P(this.ctx,a);c||this.reg.delete(a)}this.cache&&this.cache.remove(a);return this};
function P(a,c){let b=0;if(a.constructor===Array)for(let d=0,e,f;d<a.length;d++){if((e=a[d])&&e.length)if(f=e.indexOf(c),0<=f){1<e.length?(e.splice(f,1),b++):delete a[d];break}else b++}else for(let d of a){const e=d[0],f=P(d[1],c);f?b+=f:a.delete(e)}return b};function H(a,c){if(!this)return new H(a);a=a?G(a):{};const b=a.context||{},d=a.encode||a.encoder||function(f){return f.toLowerCase().trim().split(/\s+/)};this.encoder=d.encode?d:"object"===typeof d?d:{encode:d};let e;this.resolution=a.resolution||9;this.tokenize=e=a.tokenize||"strict";this.depth="strict"===e&&b.depth||0;this.bidirectional=!1!==b.bidirectional;this.fastupdate=!!a.fastupdate;this.score=a.score||null;e=!1;this.map=new Map;this.ctx=new Map;this.reg=c||(this.fastupdate?new Map:new Set);
this.A=b.resolution||1;this.rtl=d.rtl||a.rtl||!1;this.cache=(e=a.cache||null)&&new v(e)}H.prototype.clear=function(){this.map.clear();this.ctx.clear();this.reg.clear();this.cache&&this.cache.clear();return this};H.prototype.append=function(a,c){return this.add(a,c,!0)};H.prototype.contain=function(a){return this.reg.has(a)};H.prototype.update=function(a,c){if(this.async){const b=this,d=this.remove(a);return d.then?d.then(()=>b.add(a,c)):this.add(a,c)}return this.remove(a).add(a,c)};
function Q(a){let c=0;if(a.constructor===Array)for(let b=0,d;b<a.length;b++)(d=a[b])&&(c+=d.length);else for(const b of a){const d=b[0],e=Q(b[1]);e?c+=e:a.delete(d)}return c}H.prototype.cleanup=function(){if(!this.fastupdate)return this;Q(this.map);this.depth&&Q(this.ctx);return this};
H.prototype.searchCache=function(a,c,b){a=("object"===typeof a?""+a.query:a).toLowerCase();let d=this.cache.get(a);if(!d){d=this.search(a,c,b);if(d.then){const e=this;d.then(function(f){e.cache.set(a,f);return f})}this.cache.set(a,d)}return d};export default {Index:H,Charset:E,Encoder:null,Document:null,Worker:null,Resolver:null,IndexedDB:null,Language:{}};
export const Index=H;export const Charset=E;export const Encoder=null;export const Document=null;export const Worker=null;export const Resolver=null;export const IndexedDB=null;export const Language={};

View File

@@ -12,7 +12,7 @@ import Cache, { searchCache } from "./cache.js";
import Charset from "./charset.js";
import { KeystoreMap, KeystoreSet } from "./keystore.js";
import { is_array, is_string } from "./common.js";
import { exportIndex, importIndex } from "./serialize.js";
import { exportIndex, importIndex, serialize } from "./serialize.js";
import default_encoder from "./charset/latin/default.js";
import apply_preset from "./preset.js";
import apply_async from "./async.js";
@@ -207,6 +207,7 @@ Index.prototype.searchCache = searchCache;
Index.prototype.export = exportIndex;
Index.prototype.import = importIndex;
Index.prototype.serialize = serialize;
apply_async(Index.prototype);

View File

@@ -276,4 +276,165 @@ export function importDocument(key, data) {
this.index[field].import(key, data);
}
}
}
}
/*
reg: "1,2,3,4,5,6,7,8,9"
map: "gulliver:1,2,3|4,5,6|7,8,9;"
ctx: "gulliver+travel:1,2,3|4,5,6|7,8,9;"
*/
/**
* @this Index
* @param {boolean} withFunctionWrapper
* @return {string}
*/
export function serialize(withFunctionWrapper = !0) {
if (!this.reg.size) return "";
let reg = '',
type = "";
for (const key of this.reg.keys()) {
type || (type = typeof key);
reg += (reg ? ',' : '') + ("string" == type ? '"' + key + '"' : key);
}
reg = 'index.reg=new Set([' + reg + ']);';
let map = '';
for (const item of this.map.entries()) {
const key = item[0],
value = item[1];
let res = '';
for (let i = 0, ids; i < value.length; i++) {
ids = value[i] || [''];
let str = '';
for (let j = 0; j < ids.length; j++) {
str += (str ? ',' : '') + ("string" == type ? '"' + ids[j] + '"' : ids[j]);
}
str = '[' + str + ']';
res += (res ? ',' : '') + str;
}
res = '["' + key + '",[' + res + ']]';
map += (map ? ',' : '') + res;
}
map = "index.map=new Map([" + map + "]);";
let ctx = '';
for (const context of this.ctx.entries()) {
const key_ctx = context[0],
value_ctx = context[1];
for (const item of value_ctx.entries()) {
const key = item[0],
value = item[1];
let res = '';
for (let i = 0, ids; i < value.length; i++) {
ids = value[i] || [''];
let str = '';
for (let j = 0; j < ids.length; j++) {
str += (str ? ',' : '') + ("string" == type ? '"' + ids[j] + '"' : ids[j]);
}
str = '[' + str + ']';
res += (res ? ',' : '') + str;
}
res = 'new Map([["' + key + '",[' + res + ']]])';
res = '["' + key_ctx + '",' + res + ']';
ctx += (ctx ? ',' : '') + res;
}
}
ctx = "index.ctx=new Map([" + ctx + "]);";
return withFunctionWrapper ? "function inject(index){" + reg + map + ctx + "}" : reg + map + ctx;
}
// export function exportSnapshot(flexsearch){
//
// if(!flexsearch.reg.size) return;
//
// let reg = '';
// let type = "";
// for(const key of flexsearch.reg.keys()){
// type || (type = typeof key);
// reg += (reg ? ',' : '') + (type === "string" ? '"' + key + '"' : key);
// }
// reg = "f.reg=[" + reg + "];";
//
// let map = '';
// for(const item of flexsearch.map.entries()){
// const key = item[0];
// const value = item[1];
// let res = '';
// for(let i = 0, ids; i < value.length; i++){
// ids = value[i] || [''];
// let str = '';
// for(let j = 0; j < ids.length; j++){
// str += (str ? ',' : '') + (type === "string" ? '"' + ids[j] + '"' : ids[j]);
// }
// str = "[
// res += (res ? '|' : '') + str;
// }
// map += (map ? ';' : '') + key + ':' + res;
// }
//
//
// let ctx = '';
// for(const context of flexsearch.ctx.entries()){
// const key_ctx = context[0];
// const value_ctx = context[1];
//
// for(const item of value_ctx.entries()){
// const key = item[0];
// const value = item[1];
//
// let res = '';
// for(let i = 0, ids; i < value.length; i++){
// ids = value[i] || [''];
// let str = '';
// for(let j = 0; j < ids.length; j++){
// str += (str ? ',' : '') + (type === "string" ? '"' + ids[j] + '"' : ids[j]);
// }
// res += (res ? '|' : '') + str;
// }
// ctx += (ctx ? ';' : '') + key_ctx + '+' + key + ':' + res;
// }
// }
//
// return reg + '#' + map + '#' + ctx;
// }
//
// export function importSnapshot(flexsearch, input){
//
// if(!input) return;
//
// let pos_reg = input.indexOf("#");
// const reg = input.substring(0, pos_reg).split(",");
// flexsearch.reg = new Set(reg);
//
// let pos_map = input.indexOf("#", pos_reg + 1);
// const map = input.substring(pos_reg + 1, pos_map).split(";").map(res => {
// const split = res.split(":");
// split[1] = split[1].split("|").map(ids => ids ? ids.split(",") : null);
// return split;
// });
// flexsearch.map = new Map(map);
//
// input = input.substring(pos_map + 1);
// if(input){
// const ctx = input.split(";").map(res => {
// const split = res.split(":");
// const context = split[0].split("+");
// const map = new Map([
// [context[1], split[1].split("|").map(ids => ids ? ids.split(",") : null)]
// ]);
// return [context[0], map]
// });
// flexsearch.ctx = new Map(ctx);
// }
// }

View File

@@ -24,10 +24,15 @@ import Charset from "./charset.js";
/** @export */Index.prototype.removeAsync;
/** @export */Index.prototype.export;
/** @export */Index.prototype.import;
/** @export */Index.prototype.serialize;
/** @export */Index.prototype.mount;
/** @export */Index.prototype.commit;
/** @export */Index.db;
/** @export */Index.prototype.reg;
/** @export */Index.prototype.map;
/** @export */Index.prototype.ctx;
/** @export */Document.prototype.add;
/** @export */Document.prototype.append;
/** @export */Document.prototype.search;

View File

@@ -1 +1 @@
import{IndexOptions,ContextOptions}from"./type.js";import Encoder from"./encoder.js";import Cache,{searchCache}from"./cache.js";import Charset from"./charset.js";import{KeystoreMap,KeystoreSet}from"./keystore.js";import{is_array,is_string}from"./common.js";import{exportIndex,importIndex}from"./serialize.js";import default_encoder from"./charset/latin/default.js";import apply_preset from"./preset.js";import apply_async from"./async.js";import tick from"./profiler.js";import"./index/add.js";import"./index/search.js";import"./index/remove.js";export default function Index(a,b){if(!this)return new Index(a);!1,a=a?apply_preset(a):{};const c=a.context||{},d=a.encode||a.encoder||default_encoder;this.encoder=d.encode?d:"object"==typeof d?new Encoder(d):{encode:d},this.compress=a.compress||a.compression||!1;let e;this.resolution=a.resolution||9,this.tokenize=e=a.tokenize||"strict",this.depth="strict"===e&&c.depth||0,this.bidirectional=!1!==c.bidirectional,this.fastupdate=!!a.fastupdate,this.score=a.score||null,e=a.keystore||0,e&&(this.keystore=e),this.map=e&&!0?new KeystoreMap(e):new Map,this.ctx=e&&!0?new KeystoreMap(e):new Map,this.reg=b||(this.fastupdate?e&&!0?new KeystoreMap(e):new Map:e&&!0?new KeystoreSet(e):new Set),this.resolution_ctx=c.resolution||1,this.rtl=d.rtl||a.rtl||!1,this.cache=(e=a.cache||null)&&new Cache(e),this.resolve=!1!==a.resolve,(e=a.db)&&(this.db=e.mount(this)),this.commit_auto=!1!==a.commit,this.commit_task=[],this.commit_timer=null}Index.prototype.mount=function(a){return this.commit_timer&&(clearTimeout(this.commit_timer),this.commit_timer=null),a.mount(this)},Index.prototype.commit=function(a,b){return this.commit_timer&&(clearTimeout(this.commit_timer),this.commit_timer=null),this.db.commit(this,a,b)};export function autoCommit(a,b,c){a.commit_timer||(a.commit_timer=setTimeout(function(){a.commit_timer=null,a.db.commit(a,b,c)},0))}Index.prototype.clear=function(){return this.map.clear(),this.ctx.clear(),this.reg.clear(),this.cache&&this.cache.clear(),this.db&&(this.commit_timer&&clearTimeout(this.commit_timer),this.commit_timer=null,this.commit_task=[{clear:!0}]),this},Index.prototype.append=function(a,b){return this.add(a,b,!0)},Index.prototype.contain=function(a){return this.db?this.db.has(a):this.reg.has(a)},Index.prototype.update=function(a,b){if(this.async){const c=this,d=this.remove(a);return d.then?d.then(()=>c.add(a,b)):this.add(a,b)}return this.remove(a).add(a,b)};function cleanup_index(a){let b=0;if(is_array(a))for(let c,d=0;d<a.length;d++)(c=a[d])&&(b+=c.length);else for(const c of a){const d=c[0],e=c[1],f=cleanup_index(e);f?b+=f:a.delete(d)}return b}Index.prototype.cleanup=function(){return this.fastupdate?(cleanup_index(this.map),this.depth&&cleanup_index(this.ctx),this):(!1,this)},Index.prototype.searchCache=searchCache,Index.prototype.export=exportIndex,Index.prototype.import=importIndex,apply_async(Index.prototype);
import{IndexOptions,ContextOptions}from"./type.js";import Encoder from"./encoder.js";import Cache,{searchCache}from"./cache.js";import Charset from"./charset.js";import{KeystoreMap,KeystoreSet}from"./keystore.js";import{is_array,is_string}from"./common.js";import{exportIndex,importIndex,serialize}from"./serialize.js";import default_encoder from"./charset/latin/default.js";import apply_preset from"./preset.js";import apply_async from"./async.js";import tick from"./profiler.js";import"./index/add.js";import"./index/search.js";import"./index/remove.js";export default function Index(a,b){if(!this)return new Index(a);!1,a=a?apply_preset(a):{};const c=a.context||{},d=a.encode||a.encoder||default_encoder;this.encoder=d.encode?d:"object"==typeof d?new Encoder(d):{encode:d},this.compress=a.compress||a.compression||!1;let e;this.resolution=a.resolution||9,this.tokenize=e=a.tokenize||"strict",this.depth="strict"===e&&c.depth||0,this.bidirectional=!1!==c.bidirectional,this.fastupdate=!!a.fastupdate,this.score=a.score||null,e=a.keystore||0,e&&(this.keystore=e),this.map=e&&!0?new KeystoreMap(e):new Map,this.ctx=e&&!0?new KeystoreMap(e):new Map,this.reg=b||(this.fastupdate?e&&!0?new KeystoreMap(e):new Map:e&&!0?new KeystoreSet(e):new Set),this.resolution_ctx=c.resolution||1,this.rtl=d.rtl||a.rtl||!1,this.cache=(e=a.cache||null)&&new Cache(e),this.resolve=!1!==a.resolve,(e=a.db)&&(this.db=e.mount(this)),this.commit_auto=!1!==a.commit,this.commit_task=[],this.commit_timer=null}Index.prototype.mount=function(a){return this.commit_timer&&(clearTimeout(this.commit_timer),this.commit_timer=null),a.mount(this)},Index.prototype.commit=function(a,b){return this.commit_timer&&(clearTimeout(this.commit_timer),this.commit_timer=null),this.db.commit(this,a,b)};export function autoCommit(a,b,c){a.commit_timer||(a.commit_timer=setTimeout(function(){a.commit_timer=null,a.db.commit(a,b,c)},0))}Index.prototype.clear=function(){return this.map.clear(),this.ctx.clear(),this.reg.clear(),this.cache&&this.cache.clear(),this.db&&(this.commit_timer&&clearTimeout(this.commit_timer),this.commit_timer=null,this.commit_task=[{clear:!0}]),this},Index.prototype.append=function(a,b){return this.add(a,b,!0)},Index.prototype.contain=function(a){return this.db?this.db.has(a):this.reg.has(a)},Index.prototype.update=function(a,b){if(this.async){const c=this,d=this.remove(a);return d.then?d.then(()=>c.add(a,b)):this.add(a,b)}return this.remove(a).add(a,b)};function cleanup_index(a){let b=0;if(is_array(a))for(let c,d=0;d<a.length;d++)(c=a[d])&&(b+=c.length);else for(const c of a){const d=c[0],e=c[1],f=cleanup_index(e);f?b+=f:a.delete(d)}return b}Index.prototype.cleanup=function(){return this.fastupdate?(cleanup_index(this.map),this.depth&&cleanup_index(this.ctx),this):(!1,this)},Index.prototype.searchCache=searchCache,Index.prototype.export=exportIndex,Index.prototype.import=importIndex,Index.prototype.serialize=serialize,apply_async(Index.prototype);

View File

@@ -1 +1 @@
import Index from"./index.js";import Document from"./document.js";import{create_object,is_string}from"./common.js";function async(a,b,c,d,e,f,g,h){const i=a(c?c+"."+d:d,JSON.stringify(g));i&&i.then?i.then(function(){b.export(a,b,c,e,f+1,h)}):b.export(a,b,c,e,f+1,h)}export function exportIndex(a,b,c,d,e,f){let g=!0;"undefined"==typeof f&&(g=new Promise(a=>{f=a}));let h,i;switch(e||(e=0)){case 0:if(h="reg",this.fastupdate){i=create_object();for(let a of this.reg.keys())i[a]=1}else i=this.reg;break;case 1:h="cfg",i={doc:0,opt:this.optimize?1:0};break;case 2:h="map",i=this.map;break;case 3:h="ctx",i=this.ctx;break;default:return void("undefined"==typeof c&&f&&f());}return async(a,b||this,c,h,d,e,i,f),g}export function importIndex(a,b){b&&(is_string(b)&&(b=JSON.parse(b)),"cfg"===a?this.optimize=!!b.opt:"reg"===a?(this.fastupdate=!1,this.reg=b):"map"===a?this.map=b:"ctx"===a?this.ctx=b:void 0)}export function exportDocument(a,b,c,d,e,f){let g;if("undefined"==typeof f&&(g=new Promise(a=>{f=a})),e||(e=0),d||(d=0),d<this.field.length){const c=this.field[d],g=this.index[c];b=this,g.export(a,b,e?c:"",d,e++,f)||(d++,e=1,b.export(a,b,c,d,e,f))}else{let b,g;switch(e){case 1:b="tag",g=this.tagindex,c=null;break;case 2:b="store",g=this.store,c=null;break;default:return void f();}async(a,this,c,b,d,e,g,f)}return g}export function importDocument(a,b){if(b)switch(is_string(b)&&(b=JSON.parse(b)),a){case"tag":this.tagindex=b;break;case"reg":this.fastupdate=!1,this.reg=b;for(let a,c=0;c<this.field.length;c++)a=this.index[this.field[c]],a.reg=b,a.fastupdate=!1;break;case"store":this.store=b;break;default:a=a.split(".");const c=a[0];a=a[1],c&&a&&this.index[c].import(a,b);}}
import Index from"./index.js";import Document from"./document.js";import{create_object,is_string}from"./common.js";function async(a,b,c,d,e,f,g,h){const i=a(c?c+"."+d:d,JSON.stringify(g));i&&i.then?i.then(function(){b.export(a,b,c,e,f+1,h)}):b.export(a,b,c,e,f+1,h)}export function exportIndex(a,b,c,d,e,f){let g=!0;"undefined"==typeof f&&(g=new Promise(a=>{f=a}));let h,i;switch(e||(e=0)){case 0:if(h="reg",this.fastupdate){i=create_object();for(let a of this.reg.keys())i[a]=1}else i=this.reg;break;case 1:h="cfg",i={doc:0,opt:this.optimize?1:0};break;case 2:h="map",i=this.map;break;case 3:h="ctx",i=this.ctx;break;default:return void("undefined"==typeof c&&f&&f());}return async(a,b||this,c,h,d,e,i,f),g}export function importIndex(a,b){b&&(is_string(b)&&(b=JSON.parse(b)),"cfg"===a?this.optimize=!!b.opt:"reg"===a?(this.fastupdate=!1,this.reg=b):"map"===a?this.map=b:"ctx"===a?this.ctx=b:void 0)}export function exportDocument(a,b,c,d,e,f){let g;if("undefined"==typeof f&&(g=new Promise(a=>{f=a})),e||(e=0),d||(d=0),d<this.field.length){const c=this.field[d],g=this.index[c];b=this,g.export(a,b,e?c:"",d,e++,f)||(d++,e=1,b.export(a,b,c,d,e,f))}else{let b,g;switch(e){case 1:b="tag",g=this.tagindex,c=null;break;case 2:b="store",g=this.store,c=null;break;default:return void f();}async(a,this,c,b,d,e,g,f)}return g}export function importDocument(a,b){if(b)switch(is_string(b)&&(b=JSON.parse(b)),a){case"tag":this.tagindex=b;break;case"reg":this.fastupdate=!1,this.reg=b;for(let a,c=0;c<this.field.length;c++)a=this.index[this.field[c]],a.reg=b,a.fastupdate=!1;break;case"store":this.store=b;break;default:a=a.split(".");const c=a[0];a=a[1],c&&a&&this.index[c].import(a,b);}}export function serialize(a=!0){if(!this.reg.size)return"";let b="",c="";for(const d of this.reg.keys())c||(c=typeof d),b+=(b?",":"")+("string"==c?"\""+d+"\"":d);b="index.reg=new Set(["+b+"]);";let d="";for(const b of this.map.entries()){const a=b[0],e=b[1];let f="";for(let a,b=0;b<e.length;b++){a=e[b]||[""];let d="";for(let b=0;b<a.length;b++)d+=(d?",":"")+("string"==c?"\""+a[b]+"\"":a[b]);d="["+d+"]",f+=(f?",":"")+d}f="[\""+a+"\",["+f+"]]",d+=(d?",":"")+f}d="index.map=new Map(["+d+"]);";let e="";for(const b of this.ctx.entries()){const a=b[0],d=b[1];for(const b of d.entries()){const d=b[0],f=b[1];let g="";for(let a,b=0;b<f.length;b++){a=f[b]||[""];let d="";for(let b=0;b<a.length;b++)d+=(d?",":"")+("string"==c?"\""+a[b]+"\"":a[b]);d="["+d+"]",g+=(g?",":"")+d}g="new Map([[\""+d+"\",["+g+"]]])",g="[\""+a+"\","+g+"]",e+=(e?",":"")+g}}return e="index.ctx=new Map(["+e+"]);",a?"function inject(index){"+b+d+e+"}":b+d+e}

View File

@@ -1 +1 @@
import{SearchOptions,ContextOptions,DocumentDescriptor,DocumentSearchOptions,DocumentIndexOptions,IndexOptions,DocumentOptions,TagOptions,StoreOptions,EncoderOptions,EncoderSplitOptions}from"./type.js";import Document from"./document.js";import Index from"./index.js";import WorkerIndex from"./worker.js";import Resolver from"./resolver.js";import Encoder from"./encoder.js";import IdxDB from"./db/indexeddb/index.js";import Charset from"./charset.js";Index.prototype.add,Index.prototype.append,Index.prototype.search,Index.prototype.update,Index.prototype.remove,Index.prototype.contain,Index.prototype.clear,Index.prototype.cleanup,Index.prototype.searchCache,Index.prototype.addAsync,Index.prototype.appendAsync,Index.prototype.searchAsync,Index.prototype.updateAsync,Index.prototype.removeAsync,Index.prototype.export,Index.prototype.import,Index.prototype.mount,Index.prototype.commit,Index.db,Document.prototype.add,Document.prototype.append,Document.prototype.search,Document.prototype.update,Document.prototype.remove,Document.prototype.contain,Document.prototype.clear,Document.prototype.cleanup,Document.prototype.addAsync,Document.prototype.appendAsync,Document.prototype.searchAsync,Document.prototype.updateAsync,Document.prototype.removeAsync,Document.prototype.mount,Document.prototype.commit,Document.db,Document.prototype.export,Document.prototype.import,Document.prototype.searchCache,Document.prototype.get,Document.prototype.set,Resolver.prototype.limit,Resolver.prototype.offset,Resolver.prototype.boost,Resolver.prototype.resolve,Resolver.prototype.or,Resolver.prototype.and,Resolver.prototype.xor,Resolver.prototype.not,Charset.LatinExact,Charset.LatinDefault,Charset.LatinSimple,Charset.LatinBalance,Charset.LatinAdvanced,Charset.LatinExtra,Charset.LatinSoundex,Charset.ArabicDefault,Charset.CjkDefault,Charset.CyrillicDefault,IndexOptions.preset,IndexOptions.context,IndexOptions.encoder,IndexOptions.encode,IndexOptions.resolution,IndexOptions.tokenize,IndexOptions.fastupdate,IndexOptions.score,IndexOptions.keystore,IndexOptions.rtl,IndexOptions.cache,IndexOptions.resolve,IndexOptions.db,IndexOptions.config,DocumentIndexOptions.preset,DocumentIndexOptions.context,DocumentIndexOptions.encoder,DocumentIndexOptions.encode,DocumentIndexOptions.resolution,DocumentIndexOptions.tokenize,DocumentIndexOptions.fastupdate,DocumentIndexOptions.score,DocumentIndexOptions.keystore,DocumentIndexOptions.rtl,DocumentIndexOptions.cache,DocumentIndexOptions.db,DocumentIndexOptions.config,DocumentIndexOptions.field,DocumentIndexOptions.filter,DocumentIndexOptions.custom,DocumentOptions.context,DocumentOptions.encoder,DocumentOptions.encode,DocumentOptions.resolution,DocumentOptions.tokenize,DocumentOptions.fastupdate,DocumentOptions.score,DocumentOptions.keystore,DocumentOptions.rtl,DocumentOptions.cache,DocumentOptions.db,DocumentOptions.doc,DocumentOptions.document,DocumentOptions.worker,ContextOptions.depth,ContextOptions.bidirectional,ContextOptions.resolution,DocumentDescriptor.field,DocumentDescriptor.index,DocumentDescriptor.tag,DocumentDescriptor.store,TagOptions.field,TagOptions.tag,TagOptions.filter,TagOptions.custom,TagOptions.keystore,TagOptions.db,TagOptions.config,StoreOptions.field,StoreOptions.filter,StoreOptions.custom,StoreOptions.config,SearchOptions.query,SearchOptions.limit,SearchOptions.offset,SearchOptions.context,SearchOptions.suggest,SearchOptions.resolve,SearchOptions.enrich,DocumentSearchOptions.query,DocumentSearchOptions.limit,DocumentSearchOptions.offset,DocumentSearchOptions.context,DocumentSearchOptions.suggest,DocumentSearchOptions.enrich,DocumentSearchOptions.tag,DocumentSearchOptions.field,DocumentSearchOptions.index,DocumentSearchOptions.pluck,DocumentSearchOptions.merge,EncoderOptions.rtl,EncoderOptions.dedupe,EncoderOptions.split,EncoderOptions.include,EncoderOptions.exclude,EncoderOptions.prepare,EncoderOptions.finalize,EncoderOptions.filter,EncoderOptions.matcher,EncoderOptions.mapper,EncoderOptions.stemmer,EncoderOptions.replacer,EncoderOptions.minlength,EncoderOptions.maxlength,EncoderOptions.cache,EncoderSplitOptions.letter,EncoderSplitOptions.number,EncoderSplitOptions.symbol,EncoderSplitOptions.punctuation,EncoderSplitOptions.control,EncoderSplitOptions.char;const FlexSearch={Index:Index,Charset:Charset,Encoder:Encoder,Document:Document,Worker:WorkerIndex,Resolver:Resolver,IndexedDB:IdxDB,Language:{}};{FlexSearch.Language={};const a=self;let b;(b=a.define)&&b.amd?b([],function(){return FlexSearch}):"object"==typeof a.exports?a.exports=FlexSearch:a.FlexSearch=FlexSearch}
import{SearchOptions,ContextOptions,DocumentDescriptor,DocumentSearchOptions,DocumentIndexOptions,IndexOptions,DocumentOptions,TagOptions,StoreOptions,EncoderOptions,EncoderSplitOptions}from"./type.js";import Document from"./document.js";import Index from"./index.js";import WorkerIndex from"./worker.js";import Resolver from"./resolver.js";import Encoder from"./encoder.js";import IdxDB from"./db/indexeddb/index.js";import Charset from"./charset.js";Index.prototype.add,Index.prototype.append,Index.prototype.search,Index.prototype.update,Index.prototype.remove,Index.prototype.contain,Index.prototype.clear,Index.prototype.cleanup,Index.prototype.searchCache,Index.prototype.addAsync,Index.prototype.appendAsync,Index.prototype.searchAsync,Index.prototype.updateAsync,Index.prototype.removeAsync,Index.prototype.export,Index.prototype.import,Index.prototype.serialize,Index.prototype.mount,Index.prototype.commit,Index.db,Index.prototype.reg,Index.prototype.map,Index.prototype.ctx,Document.prototype.add,Document.prototype.append,Document.prototype.search,Document.prototype.update,Document.prototype.remove,Document.prototype.contain,Document.prototype.clear,Document.prototype.cleanup,Document.prototype.addAsync,Document.prototype.appendAsync,Document.prototype.searchAsync,Document.prototype.updateAsync,Document.prototype.removeAsync,Document.prototype.mount,Document.prototype.commit,Document.db,Document.prototype.export,Document.prototype.import,Document.prototype.searchCache,Document.prototype.get,Document.prototype.set,Resolver.prototype.limit,Resolver.prototype.offset,Resolver.prototype.boost,Resolver.prototype.resolve,Resolver.prototype.or,Resolver.prototype.and,Resolver.prototype.xor,Resolver.prototype.not,Charset.LatinExact,Charset.LatinDefault,Charset.LatinSimple,Charset.LatinBalance,Charset.LatinAdvanced,Charset.LatinExtra,Charset.LatinSoundex,Charset.ArabicDefault,Charset.CjkDefault,Charset.CyrillicDefault,IndexOptions.preset,IndexOptions.context,IndexOptions.encoder,IndexOptions.encode,IndexOptions.resolution,IndexOptions.tokenize,IndexOptions.fastupdate,IndexOptions.score,IndexOptions.keystore,IndexOptions.rtl,IndexOptions.cache,IndexOptions.resolve,IndexOptions.db,IndexOptions.config,DocumentIndexOptions.preset,DocumentIndexOptions.context,DocumentIndexOptions.encoder,DocumentIndexOptions.encode,DocumentIndexOptions.resolution,DocumentIndexOptions.tokenize,DocumentIndexOptions.fastupdate,DocumentIndexOptions.score,DocumentIndexOptions.keystore,DocumentIndexOptions.rtl,DocumentIndexOptions.cache,DocumentIndexOptions.db,DocumentIndexOptions.config,DocumentIndexOptions.field,DocumentIndexOptions.filter,DocumentIndexOptions.custom,DocumentOptions.context,DocumentOptions.encoder,DocumentOptions.encode,DocumentOptions.resolution,DocumentOptions.tokenize,DocumentOptions.fastupdate,DocumentOptions.score,DocumentOptions.keystore,DocumentOptions.rtl,DocumentOptions.cache,DocumentOptions.db,DocumentOptions.doc,DocumentOptions.document,DocumentOptions.worker,ContextOptions.depth,ContextOptions.bidirectional,ContextOptions.resolution,DocumentDescriptor.field,DocumentDescriptor.index,DocumentDescriptor.tag,DocumentDescriptor.store,TagOptions.field,TagOptions.tag,TagOptions.filter,TagOptions.custom,TagOptions.keystore,TagOptions.db,TagOptions.config,StoreOptions.field,StoreOptions.filter,StoreOptions.custom,StoreOptions.config,SearchOptions.query,SearchOptions.limit,SearchOptions.offset,SearchOptions.context,SearchOptions.suggest,SearchOptions.resolve,SearchOptions.enrich,DocumentSearchOptions.query,DocumentSearchOptions.limit,DocumentSearchOptions.offset,DocumentSearchOptions.context,DocumentSearchOptions.suggest,DocumentSearchOptions.enrich,DocumentSearchOptions.tag,DocumentSearchOptions.field,DocumentSearchOptions.index,DocumentSearchOptions.pluck,DocumentSearchOptions.merge,EncoderOptions.rtl,EncoderOptions.dedupe,EncoderOptions.split,EncoderOptions.include,EncoderOptions.exclude,EncoderOptions.prepare,EncoderOptions.finalize,EncoderOptions.filter,EncoderOptions.matcher,EncoderOptions.mapper,EncoderOptions.stemmer,EncoderOptions.replacer,EncoderOptions.minlength,EncoderOptions.maxlength,EncoderOptions.cache,EncoderSplitOptions.letter,EncoderSplitOptions.number,EncoderSplitOptions.symbol,EncoderSplitOptions.punctuation,EncoderSplitOptions.control,EncoderSplitOptions.char;const FlexSearch={Index:Index,Charset:Charset,Encoder:Encoder,Document:Document,Worker:WorkerIndex,Resolver:Resolver,IndexedDB:IdxDB,Language:{}};{FlexSearch.Language={};const a=self;let b;(b=a.define)&&b.amd?b([],function(){return FlexSearch}):"object"==typeof a.exports?a.exports=FlexSearch:a.FlexSearch=FlexSearch}

View File

@@ -12,7 +12,7 @@ import Cache, { searchCache } from "./cache.js";
import Charset from "./charset.js";
import { KeystoreMap, KeystoreSet } from "./keystore.js";
import { is_array, is_string } from "./common.js";
import { exportIndex, importIndex } from "./serialize.js";
import { exportIndex, importIndex, serialize } from "./serialize.js";
import default_encoder from "./charset/latin/default.js";
import apply_preset from "./preset.js";
import apply_async from "./async.js";
@@ -206,6 +206,7 @@ Index.prototype.searchCache = searchCache;
Index.prototype.export = exportIndex;
Index.prototype.import = importIndex;
Index.prototype.serialize = serialize;
apply_async(Index.prototype);

View File

@@ -276,4 +276,165 @@ export function importDocument(key, data) {
this.index[field].import(key, data);
}
}
}
}
/*
reg: "1,2,3,4,5,6,7,8,9"
map: "gulliver:1,2,3|4,5,6|7,8,9;"
ctx: "gulliver+travel:1,2,3|4,5,6|7,8,9;"
*/
/**
* @this Index
* @param {boolean} withFunctionWrapper
* @return {string}
*/
export function serialize(withFunctionWrapper = !0) {
if (!this.reg.size) return "";
let reg = '',
type = "";
for (const key of this.reg.keys()) {
type || (type = typeof key);
reg += (reg ? ',' : '') + ("string" == type ? '"' + key + '"' : key);
}
reg = 'index.reg=new Set([' + reg + ']);';
let map = '';
for (const item of this.map.entries()) {
const key = item[0],
value = item[1];
let res = '';
for (let i = 0, ids; i < value.length; i++) {
ids = value[i] || [''];
let str = '';
for (let j = 0; j < ids.length; j++) {
str += (str ? ',' : '') + ("string" == type ? '"' + ids[j] + '"' : ids[j]);
}
str = '[' + str + ']';
res += (res ? ',' : '') + str;
}
res = '["' + key + '",[' + res + ']]';
map += (map ? ',' : '') + res;
}
map = "index.map=new Map([" + map + "]);";
let ctx = '';
for (const context of this.ctx.entries()) {
const key_ctx = context[0],
value_ctx = context[1];
for (const item of value_ctx.entries()) {
const key = item[0],
value = item[1];
let res = '';
for (let i = 0, ids; i < value.length; i++) {
ids = value[i] || [''];
let str = '';
for (let j = 0; j < ids.length; j++) {
str += (str ? ',' : '') + ("string" == type ? '"' + ids[j] + '"' : ids[j]);
}
str = '[' + str + ']';
res += (res ? ',' : '') + str;
}
res = 'new Map([["' + key + '",[' + res + ']]])';
res = '["' + key_ctx + '",' + res + ']';
ctx += (ctx ? ',' : '') + res;
}
}
ctx = "index.ctx=new Map([" + ctx + "]);";
return withFunctionWrapper ? "function inject(index){" + reg + map + ctx + "}" : reg + map + ctx;
}
// export function exportSnapshot(flexsearch){
//
// if(!flexsearch.reg.size) return;
//
// let reg = '';
// let type = "";
// for(const key of flexsearch.reg.keys()){
// type || (type = typeof key);
// reg += (reg ? ',' : '') + (type === "string" ? '"' + key + '"' : key);
// }
// reg = "f.reg=[" + reg + "];";
//
// let map = '';
// for(const item of flexsearch.map.entries()){
// const key = item[0];
// const value = item[1];
// let res = '';
// for(let i = 0, ids; i < value.length; i++){
// ids = value[i] || [''];
// let str = '';
// for(let j = 0; j < ids.length; j++){
// str += (str ? ',' : '') + (type === "string" ? '"' + ids[j] + '"' : ids[j]);
// }
// str = "[
// res += (res ? '|' : '') + str;
// }
// map += (map ? ';' : '') + key + ':' + res;
// }
//
//
// let ctx = '';
// for(const context of flexsearch.ctx.entries()){
// const key_ctx = context[0];
// const value_ctx = context[1];
//
// for(const item of value_ctx.entries()){
// const key = item[0];
// const value = item[1];
//
// let res = '';
// for(let i = 0, ids; i < value.length; i++){
// ids = value[i] || [''];
// let str = '';
// for(let j = 0; j < ids.length; j++){
// str += (str ? ',' : '') + (type === "string" ? '"' + ids[j] + '"' : ids[j]);
// }
// res += (res ? '|' : '') + str;
// }
// ctx += (ctx ? ';' : '') + key_ctx + '+' + key + ':' + res;
// }
// }
//
// return reg + '#' + map + '#' + ctx;
// }
//
// export function importSnapshot(flexsearch, input){
//
// if(!input) return;
//
// let pos_reg = input.indexOf("#");
// const reg = input.substring(0, pos_reg).split(",");
// flexsearch.reg = new Set(reg);
//
// let pos_map = input.indexOf("#", pos_reg + 1);
// const map = input.substring(pos_reg + 1, pos_map).split(";").map(res => {
// const split = res.split(":");
// split[1] = split[1].split("|").map(ids => ids ? ids.split(",") : null);
// return split;
// });
// flexsearch.map = new Map(map);
//
// input = input.substring(pos_map + 1);
// if(input){
// const ctx = input.split(";").map(res => {
// const split = res.split(":");
// const context = split[0].split("+");
// const map = new Map([
// [context[1], split[1].split("|").map(ids => ids ? ids.split(",") : null)]
// ]);
// return [context[0], map]
// });
// flexsearch.ctx = new Map(ctx);
// }
// }

View File

@@ -24,10 +24,15 @@ import Charset from "./charset.js";
/** @export */Index.prototype.removeAsync;
/** @export */Index.prototype.export;
/** @export */Index.prototype.import;
/** @export */Index.prototype.serialize;
/** @export */Index.prototype.mount;
/** @export */Index.prototype.commit;
/** @export */Index.db;
/** @export */Index.prototype.reg;
/** @export */Index.prototype.map;
/** @export */Index.prototype.ctx;
/** @export */Document.prototype.add;
/** @export */Document.prototype.append;
/** @export */Document.prototype.search;

View File

@@ -30,7 +30,7 @@ import Cache, { searchCache } from "./cache.js";
import Charset from "./charset.js";
import { KeystoreMap, KeystoreSet } from "./keystore.js";
import { is_array, is_string } from "./common.js";
import { exportIndex, importIndex } from "./serialize.js";
import { exportIndex, importIndex, serialize } from "./serialize.js";
import default_encoder from "./charset/latin/default.js";
import apply_preset from "./preset.js";
import apply_async from "./async.js";
@@ -262,6 +262,7 @@ if(SUPPORT_SERIALIZE){
Index.prototype.export = exportIndex;
Index.prototype.import = importIndex;
Index.prototype.serialize = serialize;
}
if(SUPPORT_ASYNC){

View File

@@ -279,3 +279,162 @@ export function importDocument(key, data){
}
}
}
/*
reg: "1,2,3,4,5,6,7,8,9"
map: "gulliver:1,2,3|4,5,6|7,8,9;"
ctx: "gulliver+travel:1,2,3|4,5,6|7,8,9;"
*/
/**
* @this Index
* @param {boolean} withFunctionWrapper
* @return {string}
*/
export function serialize(withFunctionWrapper = true){
if(!this.reg.size) return "";
let reg = '';
let type = "";
for(const key of this.reg.keys()){
type || (type = typeof key);
reg += (reg ? ',' : '') + (type === "string" ? '"' + key + '"' : key);
}
reg = 'index.reg=new Set([' + reg + ']);';
let map = '';
for(const item of this.map.entries()){
const key = item[0];
const value = item[1];
let res = '';
for(let i = 0, ids; i < value.length; i++){
ids = value[i] || [''];
let str = '';
for(let j = 0; j < ids.length; j++){
str += (str ? ',' : '') + (type === "string" ? '"' + ids[j] + '"' : ids[j]);
}
str = '[' + str + ']';
res += (res ? ',' : '') + str;
}
res = '["' + key + '",[' + res + ']]';
map += (map ? ',' : '') + res;
}
map = "index.map=new Map([" + map + "]);";
let ctx = '';
for(const context of this.ctx.entries()){
const key_ctx = context[0];
const value_ctx = context[1];
for(const item of value_ctx.entries()){
const key = item[0];
const value = item[1];
let res = '';
for(let i = 0, ids; i < value.length; i++){
ids = value[i] || [''];
let str = '';
for(let j = 0; j < ids.length; j++){
str += (str ? ',' : '') + (type === "string" ? '"' + ids[j] + '"' : ids[j]);
}
str = '[' + str + ']';
res += (res ? ',' : '') + str;
}
res = 'new Map([["' + key + '",[' + res + ']]])';
res = '["' + key_ctx + '",' + res + ']';
ctx += (ctx ? ',' : '') + res;
}
}
ctx = "index.ctx=new Map([" + ctx + "]);";
return withFunctionWrapper
? "function inject(index){" + reg + map + ctx + "}"
: reg + map + ctx
}
// export function exportSnapshot(flexsearch){
//
// if(!flexsearch.reg.size) return;
//
// let reg = '';
// let type = "";
// for(const key of flexsearch.reg.keys()){
// type || (type = typeof key);
// reg += (reg ? ',' : '') + (type === "string" ? '"' + key + '"' : key);
// }
// reg = "f.reg=[" + reg + "];";
//
// let map = '';
// for(const item of flexsearch.map.entries()){
// const key = item[0];
// const value = item[1];
// let res = '';
// for(let i = 0, ids; i < value.length; i++){
// ids = value[i] || [''];
// let str = '';
// for(let j = 0; j < ids.length; j++){
// str += (str ? ',' : '') + (type === "string" ? '"' + ids[j] + '"' : ids[j]);
// }
// str = "[
// res += (res ? '|' : '') + str;
// }
// map += (map ? ';' : '') + key + ':' + res;
// }
//
//
// let ctx = '';
// for(const context of flexsearch.ctx.entries()){
// const key_ctx = context[0];
// const value_ctx = context[1];
//
// for(const item of value_ctx.entries()){
// const key = item[0];
// const value = item[1];
//
// let res = '';
// for(let i = 0, ids; i < value.length; i++){
// ids = value[i] || [''];
// let str = '';
// for(let j = 0; j < ids.length; j++){
// str += (str ? ',' : '') + (type === "string" ? '"' + ids[j] + '"' : ids[j]);
// }
// res += (res ? '|' : '') + str;
// }
// ctx += (ctx ? ';' : '') + key_ctx + '+' + key + ':' + res;
// }
// }
//
// return reg + '#' + map + '#' + ctx;
// }
//
// export function importSnapshot(flexsearch, input){
//
// if(!input) return;
//
// let pos_reg = input.indexOf("#");
// const reg = input.substring(0, pos_reg).split(",");
// flexsearch.reg = new Set(reg);
//
// let pos_map = input.indexOf("#", pos_reg + 1);
// const map = input.substring(pos_reg + 1, pos_map).split(";").map(res => {
// const split = res.split(":");
// split[1] = split[1].split("|").map(ids => ids ? ids.split(",") : null);
// return split;
// });
// flexsearch.map = new Map(map);
//
// input = input.substring(pos_map + 1);
// if(input){
// const ctx = input.split(";").map(res => {
// const split = res.split(":");
// const context = split[0].split("+");
// const map = new Map([
// [context[1], split[1].split("|").map(ids => ids ? ids.split(",") : null)]
// ]);
// return [context[0], map]
// });
// flexsearch.ctx = new Map(ctx);
// }
// }

View File

@@ -6,7 +6,8 @@ import {
SUPPORT_ENCODER,
SUPPORT_CHARSET,
SUPPORT_PERSISTENT,
SUPPORT_RESOLVER
SUPPORT_RESOLVER,
SUPPORT_SERIALIZE
} from "./config.js";
// <-- COMPILER BLOCK
import {
@@ -46,10 +47,17 @@ import Charset from "./charset.js";
/** @export */ Index.prototype.removeAsync;
/** @export */ Index.prototype.export;
/** @export */ Index.prototype.import;
/** @export */ Index.prototype.serialize;
/** @export */ Index.prototype.mount;
/** @export */ Index.prototype.commit;
/** @export */ Index.db;
if(SUPPORT_SERIALIZE){
/** @export */ Index.prototype.reg;
/** @export */ Index.prototype.map;
/** @export */ Index.prototype.ctx;
}
/** @export */ Document.prototype.add;
/** @export */ Document.prototype.append;
/** @export */ Document.prototype.search;