mirror of
https://github.com/nextapps-de/flexsearch.git
synced 2025-09-18 18:04:26 +02:00
add union for suggestions
This commit is contained in:
193
dist/flexsearch.bundle.debug.js
vendored
193
dist/flexsearch.bundle.debug.js
vendored
@@ -499,18 +499,18 @@ O.prototype.add = function(a, b, c, d) {
|
||||
b = this.encoder.encode(b);
|
||||
if (d = b.length) {
|
||||
const l = z(), m = z(), n = this.depth, q = this.resolution;
|
||||
for (let t = 0; t < d; t++) {
|
||||
let p = b[this.rtl ? d - 1 - t : t];
|
||||
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, t, null, 0) : P(q, d, t), g = "";
|
||||
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, t, g, f) : P(q, d, t, e, f);
|
||||
var k = this.score ? this.score(b, p, r, g, f) : P(q, d, r, e, f);
|
||||
Q(this, m, g, k, a, c);
|
||||
}
|
||||
}
|
||||
@@ -519,7 +519,7 @@ O.prototype.add = function(a, b, c, d) {
|
||||
case "reverse":
|
||||
if (1 < e) {
|
||||
for (h = e - 1; 0 < h; h--) {
|
||||
g = p[h] + g, k = this.score ? this.score(b, p, t, g, h) : P(q, d, t, e, h), Q(this, m, g, k, a, c);
|
||||
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 = "";
|
||||
}
|
||||
@@ -531,12 +531,12 @@ O.prototype.add = function(a, b, c, d) {
|
||||
break;
|
||||
}
|
||||
default:
|
||||
if (Q(this, m, p, f, a, c), n && 1 < d && t < d - 1) {
|
||||
for (e = z(), g = this.U, f = p, h = Math.min(n + 1, d - t), e[f] = 1, k = 1; k < h; k++) {
|
||||
if ((p = b[this.rtl ? d - 1 - t - k : t + k]) && !e[p]) {
|
||||
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 r = this.score ? this.score(b, f, t, p, k) : P(g + (d / 2 > g ? 0 : 1), d, t, h - 1, k - 1), x = this.bidirectional && p > f;
|
||||
Q(this, l, x ? f : p, r, a, c, x ? p : f);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -678,17 +678,17 @@ function Ea(a, b, c, d, e, f) {
|
||||
for (let n = 0, q; n < a.length; n++) {
|
||||
if (q = a[n]) {
|
||||
if (m = q[l]) {
|
||||
for (let t = 0, p; t < m.length; t++) {
|
||||
if (p = m[t], !h[p]) {
|
||||
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 r = l + (n ? f : 0);
|
||||
d[r] || (d[r] = []);
|
||||
d[r].push(p);
|
||||
const t = l + (n ? f : 0);
|
||||
d[t] || (d[t] = []);
|
||||
d[t].push(p);
|
||||
}
|
||||
if (b && ++g === b) {
|
||||
return d;
|
||||
@@ -769,13 +769,13 @@ function Fa(a, b, c, d, e) {
|
||||
if (!m || !m.length) {
|
||||
return [];
|
||||
}
|
||||
let n = z(), q = 0, t = l === a.length - 1;
|
||||
for (let p = 0, r; p < k; p++) {
|
||||
if (r = m[p]) {
|
||||
for (let x = 0, A, w; x < r.length; x++) {
|
||||
if (A = r[x], !l) {
|
||||
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 (t) {
|
||||
} else if (r) {
|
||||
if (w = h[A]) {
|
||||
if (q = 1, c) {
|
||||
c--;
|
||||
@@ -997,14 +997,13 @@ S.prototype.resolve = function(a, b, c) {
|
||||
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) {
|
||||
const f = a.length;
|
||||
let g = [], h, k;
|
||||
h = z();
|
||||
for (let l = 0, m, n, q, t; l < b; l++) {
|
||||
for (let p = 0; p < f; p++) {
|
||||
if (q = a[p], l < q.length && (m = q[l])) {
|
||||
for (let r = 0; r < m.length; r++) {
|
||||
n = m[r], (k = h[n]) ? h[n]++ : (k = 0, h[n] = 1), t = g[k] || (g[k] = []), t.push(n);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1012,21 +1011,43 @@ function Ia(a, b, c, d, e) {
|
||||
if (a = g.length) {
|
||||
if (e) {
|
||||
e = [];
|
||||
for (let l = a - 1, m = 0, n, q; 0 <= l; l--) {
|
||||
if (n = g[l], q = n.length, d >= q) {
|
||||
d -= q;
|
||||
for (let n = a - 1, q = 0, r, p; 0 <= n; n--) {
|
||||
if (r = g[n], p = r.length, d >= p) {
|
||||
d -= p;
|
||||
} else {
|
||||
if (q + m > c || d) {
|
||||
n = n.slice(d, c - m + d), q = n.length;
|
||||
if (p + q > c || d) {
|
||||
r = r.slice(d, c - q + d), p = r.length;
|
||||
}
|
||||
e.push(n);
|
||||
m += q;
|
||||
if (c === m) {
|
||||
e.push(r);
|
||||
q += p;
|
||||
if (c === q) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
g = 1 < e.length ? [].concat.apply([], e) : e[0];
|
||||
if (1 < e.length) {
|
||||
g = e;
|
||||
e = [];
|
||||
f = z();
|
||||
k = g.length;
|
||||
for (l = 0; l < k; l++) {
|
||||
for (a = g[l], h = a.length, m = 0; m < h; m++) {
|
||||
if (b = a[m], !f[b]) {
|
||||
if (f[b] = 1, d) {
|
||||
d--;
|
||||
} else {
|
||||
if (e.push(b), e.length === c) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
c = e;
|
||||
} else {
|
||||
c = e[0];
|
||||
}
|
||||
g = c;
|
||||
} else {
|
||||
if (a < f) {
|
||||
return [];
|
||||
@@ -1081,11 +1102,11 @@ O.prototype.search = function(a, b, c) {
|
||||
}
|
||||
let n = c = 0;
|
||||
if (1 < e) {
|
||||
const p = z(), r = [];
|
||||
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)) {
|
||||
r.push(A), p[A] = 1;
|
||||
t.push(A), p[A] = 1;
|
||||
} else {
|
||||
return h ? d : new S(d);
|
||||
}
|
||||
@@ -1094,37 +1115,37 @@ O.prototype.search = function(a, b, c) {
|
||||
n = n ? Math.min(n, w) : w;
|
||||
}
|
||||
}
|
||||
a = r;
|
||||
a = t;
|
||||
e = a.length;
|
||||
}
|
||||
if (!e) {
|
||||
return h ? d : new S(d);
|
||||
}
|
||||
let q = 0, t;
|
||||
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 ? (t = a[0], q = 1) : 9 < c && 3 < c / n && a.sort(aa));
|
||||
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 r, x; q < e; q++) {
|
||||
for (let t, x; q < e; q++) {
|
||||
x = a[q];
|
||||
t ? (r = await V(p, x, t), r = Ka(r, d, f, p.U, b, g, 2 === e), f && !1 === r && d.length || (t = x)) : (r = await V(p, x), r = Ka(r, d, f, p.resolution, b, g, 1 === e));
|
||||
if (r) {
|
||||
return r;
|
||||
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 (t) {
|
||||
t = "";
|
||||
if (r) {
|
||||
r = "";
|
||||
q = -1;
|
||||
continue;
|
||||
}
|
||||
@@ -1138,17 +1159,17 @@ O.prototype.search = function(a, b, c) {
|
||||
return h ? Ia(d, p.resolution, b, g, f) : new S(d[0]);
|
||||
}();
|
||||
}
|
||||
for (let p, r; q < e; q++) {
|
||||
r = a[q];
|
||||
t ? (p = V(this, r, t), p = Ka(p, d, f, this.U, b, g, 2 === e), f && !1 === p && d.length || (t = r)) : (p = V(this, r), p = Ka(p, d, f, this.resolution, b, g, 1 === e));
|
||||
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 (t) {
|
||||
t = "";
|
||||
if (r) {
|
||||
r = "";
|
||||
q = -1;
|
||||
continue;
|
||||
}
|
||||
@@ -1597,7 +1618,7 @@ function Qa(a, b, c, d, e, f, g, h) {
|
||||
k = g || c.field || c.index;
|
||||
var n = this.tag && c.tag;
|
||||
var q = this.store && c.enrich;
|
||||
var t = c.suggest;
|
||||
var r = c.suggest;
|
||||
b = c.limit || b;
|
||||
l = c.offset || 0;
|
||||
b || (b = 100);
|
||||
@@ -1610,18 +1631,18 @@ function Qa(a, b, c, d, e, f, g, h) {
|
||||
throw Error("A tag option can't be a string, instead it needs a { field: tag } format.");
|
||||
}
|
||||
if (v.field && v.tag) {
|
||||
var r = v.tag;
|
||||
if (r.constructor === Array) {
|
||||
for (var x = 0; x < r.length; x++) {
|
||||
p.push(v.field, r[x]);
|
||||
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, r);
|
||||
p.push(v.field, t);
|
||||
}
|
||||
} else {
|
||||
r = Object.keys(v);
|
||||
for (let I = 0, J, D; I < r.length; I++) {
|
||||
if (J = r[I], D = v[J], D.constructor === Array) {
|
||||
t = Object.keys(v);
|
||||
for (let I = 0, J, D; I < t.length; I++) {
|
||||
if (J = t[I], D = v[J], D.constructor === Array) {
|
||||
for (x = 0; x < D.length; x++) {
|
||||
p.push(J, D[x]);
|
||||
}
|
||||
@@ -1636,7 +1657,7 @@ function Qa(a, b, c, d, e, f, g, h) {
|
||||
}
|
||||
n = p;
|
||||
if (!a) {
|
||||
t = [];
|
||||
r = [];
|
||||
if (p.length) {
|
||||
for (n = 0; n < p.length; n += 2) {
|
||||
if (this.db) {
|
||||
@@ -1645,14 +1666,14 @@ function Qa(a, b, c, d, e, f, g, h) {
|
||||
console.warn("Tag '" + p[n] + ":" + p[n + 1] + "' will be skipped because there is no field '" + p[n] + "'.");
|
||||
continue;
|
||||
}
|
||||
t.push(d = d.db.tag(p[n + 1], b, l, q));
|
||||
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 t.length ? Promise.all(t).then(function(w) {
|
||||
return r.length ? Promise.all(r).then(function(w) {
|
||||
for (let v = 0; v < w.length; v++) {
|
||||
e[v].result = w[v];
|
||||
}
|
||||
@@ -1671,29 +1692,29 @@ function Qa(a, b, c, d, e, f, g, h) {
|
||||
continue;
|
||||
}
|
||||
let D;
|
||||
B(I) || (D = I, I = D.field, a = D.query || a, b = D.limit || b, t = D.suggest || t);
|
||||
B(I) || (D = I, I = D.field, a = D.query || a, b = D.limit || b, r = D.suggest || r);
|
||||
if (d) {
|
||||
v = d[w];
|
||||
} else {
|
||||
if (r = D || c, x = this.index.get(I), n && (this.db && (r.tag = n, A = x.db.Z, r.field = k), A || (r.enrich = !1)), p) {
|
||||
p[w] = x.searchAsync(a, b, r);
|
||||
r && q && (r.enrich = q);
|
||||
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) {
|
||||
p[w] = x.searchAsync(a, b, t);
|
||||
t && q && (t.enrich = q);
|
||||
continue;
|
||||
} else {
|
||||
v = x.search(a, b, r), r && q && (r.enrich = q);
|
||||
v = x.search(a, b, t), t && q && (t.enrich = q);
|
||||
}
|
||||
}
|
||||
J = v && v.length;
|
||||
if (n && J) {
|
||||
r = [];
|
||||
t = [];
|
||||
x = 0;
|
||||
if (this.db && d) {
|
||||
if (!A) {
|
||||
for (let E = k.length; E < d.length; E++) {
|
||||
let F = d[E];
|
||||
if (F && F.length) {
|
||||
x++, r.push(F);
|
||||
} else if (!t) {
|
||||
x++, t.push(F);
|
||||
} else if (!r) {
|
||||
return e;
|
||||
}
|
||||
}
|
||||
@@ -1702,23 +1723,23 @@ function Qa(a, b, c, d, e, f, g, h) {
|
||||
for (let E = 0, F, bb; E < n.length; E += 2) {
|
||||
F = this.tag.get(n[E]);
|
||||
if (!F) {
|
||||
if (console.warn("Tag '" + n[E] + ":" + n[E + 1] + "' will be skipped because there is no field '" + n[E] + "'."), t) {
|
||||
if (console.warn("Tag '" + n[E] + ":" + n[E + 1] + "' will be skipped because there is no field '" + n[E] + "'."), r) {
|
||||
continue;
|
||||
} else {
|
||||
return e;
|
||||
}
|
||||
}
|
||||
if (bb = (F = F && F.get(n[E + 1])) && F.length) {
|
||||
x++, r.push(F);
|
||||
} else if (!t) {
|
||||
x++, t.push(F);
|
||||
} else if (!r) {
|
||||
return e;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (x) {
|
||||
v = Ja(v, r);
|
||||
v = Ja(v, t);
|
||||
J = v.length;
|
||||
if (!J && !t) {
|
||||
if (!J && !r) {
|
||||
return e;
|
||||
}
|
||||
x--;
|
||||
@@ -1735,7 +1756,7 @@ function Qa(a, b, c, d, e, f, g, h) {
|
||||
for (q = 0; q < n.length; q += 2) {
|
||||
d = this.index.get(n[q]);
|
||||
if (!d) {
|
||||
if (console.warn("Tag '" + n[q] + ":" + n[q + 1] + "' was not found because there is no field '" + n[q] + "'."), t) {
|
||||
if (console.warn("Tag '" + n[q] + ":" + n[q + 1] + "' was not found because there is no field '" + n[q] + "'."), r) {
|
||||
continue;
|
||||
} else {
|
||||
return e;
|
||||
@@ -2229,14 +2250,14 @@ u.commit = async function(a, b, c) {
|
||||
var n;
|
||||
if (m && m.length) {
|
||||
const q = Math.max(m.length, l.length);
|
||||
for (let t = 0, p, r; t < q; t++) {
|
||||
if ((r = l[t]) && r.length) {
|
||||
if ((p = m[t]) && p.length) {
|
||||
for (n = 0; n < r.length; n++) {
|
||||
p.push(r[n]);
|
||||
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[t] = r;
|
||||
m[r] = t;
|
||||
}
|
||||
n = 1;
|
||||
}
|
||||
|
30
dist/flexsearch.bundle.min.js
vendored
30
dist/flexsearch.bundle.min.js
vendored
@@ -27,23 +27,23 @@ function J(a){if(!this)return new J(a);this.index=a?[a]:[];this.length=a?a.lengt
|
||||
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 t=0;t<d;t++){let p=b[this.rtl?d-1-t:t];var e=p.length;if(e&&(n||!m[p])){var f=this.score?this.score(b,p,t,null,0):P(q,d,t),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,t,g,f):P(q,d,t,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,t,g,h):P(q,d,t,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&&t<d-1)for(e=z(),g=this.U,f=p,h=Math.min(n+1,d-t),e[f]=1,k=1;k<h;k++)if((p=b[this.rtl?d-1-t-k:t+k])&&!e[p]){e[p]=1;const r=this.score?this.score(b,f,t,p,k):P(g+(d/2>g?0:1),d,t,h-1,k-1),x=this.bidirectional&&p>f;Q(this,l,x?f:p,r,a,c,x?p:f)}}}}this.fastupdate||this.A.add(a)}else b=""}this.db&&(b||
|
||||
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 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};
|
||||
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 t=0,p;t<m.length;t++)if(p=m[t],!h[p])if(h[p]=1,c)c--;else{if(e)d.push(p);else{const r=l+(n?f:0);d[r]||(d[r]=[]);d[r].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||
|
||||
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};
|
||||
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,t=l===a.length-1;for(let p=0,r;p<k;p++)if(r=m[p])for(let x=0,A,w;x<r.length;x++)if(A=r[x],!l)n[A]=p+1+(l?e:0),q=1;else if(t){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;
|
||||
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};
|
||||
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){const f=a.length;let g=[],h,k;h=z();for(let l=0,m,n,q,t;l<b;l++)for(let p=0;p<f;p++)if(q=a[p],l<q.length&&(m=q[l]))for(let r=0;r<m.length;r++)n=m[r],(k=h[n])?h[n]++:(k=0,h[n]=1),t=g[k]||(g[k]=[]),t.push(n);if(a=g.length)if(e){e=[];for(let l=a-1,m=0,n,q;0<=l;l--)if(n=g[l],q=n.length,d>=q)d-=q;else{if(q+m>c||d)n=n.slice(d,c-m+d),q=n.length;e.push(n);m+=q;if(c===m)break}g=1<e.length?[].concat.apply([],e):e[0]}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(),r=[];for(let x=0,A;x<e;x++)if((A=a[x])&&
|
||||
!p[A]){if(f||this.db||V(this,A))r.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=r;e=a.length}if(!e)return h?d:new S(d);let q=0,t;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?(t=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 r,x;q<e;q++){x=a[q];t?(r=await V(p,x,t),r=Ka(r,
|
||||
d,f,p.U,b,g,2===e),f&&!1===r&&d.length||(t=x)):(r=await V(p,x),r=Ka(r,d,f,p.resolution,b,g,1===e));if(r)return r;if(f&&q===e-1){let A=d.length;if(!A){if(t){t="";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,r;q<e;q++){r=a[q];t?(p=V(this,r,t),p=Ka(p,d,f,this.U,b,g,2===e),f&&!1===p&&d.length||(t=r)):(p=V(this,r),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(t){t="";q=-1;continue}return d}if(1===
|
||||
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){e=[];for(let n=a-1,q=0,r,p;0<=n;n--)if(r=g[n],p=r.length,d>=p)d-=p;else{if(p+q>c||d)r=r.slice(d,c-q+d),p=r.length;e.push(r);q+=p;if(c===q)break}if(1<e.length){g=e;e=[];f=z();k=g.length;for(l=0;l<k;l++)for(a=g[l],h=a.length,m=0;m<h;m++)if(b=a[m],!f[b])if(f[b]=
|
||||
1,d)d--;else if(e.push(b),e.length===c)break;c=e}else c=e[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===
|
||||
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=
|
||||
@@ -57,10 +57,10 @@ options:a})}}X("add");X("append");X("search");X("update");X("remove");function X
|
||||
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 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 t=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 r=v.tag;if(r.constructor===Array)for(var x=0;x<r.length;x++)p.push(v.field,
|
||||
r[x]);else p.push(v.field,r)}else{r=Object.keys(v);for(let H=0,I,D;H<r.length;H++)if(I=r[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){t=[];if(p.length)for(n=0;n<p.length;n+=2){if(this.db){d=this.index.get(p[n]);if(!d)continue;t.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 t.length?Promise.all(t).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,t=D.suggest||t);if(d)v=d[w];else if(r=D||c,x=this.index.get(H),n&&(this.db&&(r.tag=n,A=x.db.Z,r.field=k),A||(r.enrich=!1)),p){p[w]=x.searchAsync(a,b,r);r&&q&&(r.enrich=q);continue}else v=x.search(a,b,r),r&&q&&(r.enrich=q);I=v&&v.length;if(n&&I){r=[];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++,r.push(E);else if(!t)return e}}else for(let L=0,E,bb;L<n.length;L+=2){E=this.tag.get(n[L]);if(!E)if(t)continue;else return e;if(bb=(E=E&&E.get(n[L+1]))&&E.length)x++,r.push(E);else if(!t)return e}if(x){v=Ja(v,r);I=v.length;if(!I&&!t)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(t)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?
|
||||
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=
|
||||
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=
|
||||
@@ -81,8 +81,8 @@ u.tag=function(a,b=0,c=0,d=!1){a=this.db.transaction("tag","readonly").objectSto
|
||||
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 t=0,p,r;t<q;t++)if((r=l[t])&&r.length){if((p=m[t])&&p.length)for(n=0;n<r.length;n++)p.push(r[n]);
|
||||
else m[t]=r;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,
|
||||
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.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));
|
||||
|
193
dist/flexsearch.bundle.module.debug.js
vendored
193
dist/flexsearch.bundle.module.debug.js
vendored
@@ -498,18 +498,18 @@ O.prototype.add = function(a, b, c, d) {
|
||||
b = this.encoder.encode(b);
|
||||
if (d = b.length) {
|
||||
const l = z(), m = z(), n = this.depth, q = this.resolution;
|
||||
for (let t = 0; t < d; t++) {
|
||||
let p = b[this.rtl ? d - 1 - t : t];
|
||||
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, t, null, 0) : P(q, d, t), g = "";
|
||||
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, t, g, f) : P(q, d, t, e, f);
|
||||
var k = this.score ? this.score(b, p, r, g, f) : P(q, d, r, e, f);
|
||||
Q(this, m, g, k, a, c);
|
||||
}
|
||||
}
|
||||
@@ -518,7 +518,7 @@ O.prototype.add = function(a, b, c, d) {
|
||||
case "reverse":
|
||||
if (1 < e) {
|
||||
for (h = e - 1; 0 < h; h--) {
|
||||
g = p[h] + g, k = this.score ? this.score(b, p, t, g, h) : P(q, d, t, e, h), Q(this, m, g, k, a, c);
|
||||
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 = "";
|
||||
}
|
||||
@@ -530,12 +530,12 @@ O.prototype.add = function(a, b, c, d) {
|
||||
break;
|
||||
}
|
||||
default:
|
||||
if (Q(this, m, p, f, a, c), n && 1 < d && t < d - 1) {
|
||||
for (e = z(), g = this.U, f = p, h = Math.min(n + 1, d - t), e[f] = 1, k = 1; k < h; k++) {
|
||||
if ((p = b[this.rtl ? d - 1 - t - k : t + k]) && !e[p]) {
|
||||
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 r = this.score ? this.score(b, f, t, p, k) : P(g + (d / 2 > g ? 0 : 1), d, t, h - 1, k - 1), x = this.bidirectional && p > f;
|
||||
Q(this, l, x ? f : p, r, a, c, x ? p : f);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -677,17 +677,17 @@ function Ea(a, b, c, d, e, f) {
|
||||
for (let n = 0, q; n < a.length; n++) {
|
||||
if (q = a[n]) {
|
||||
if (m = q[l]) {
|
||||
for (let t = 0, p; t < m.length; t++) {
|
||||
if (p = m[t], !h[p]) {
|
||||
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 r = l + (n ? f : 0);
|
||||
d[r] || (d[r] = []);
|
||||
d[r].push(p);
|
||||
const t = l + (n ? f : 0);
|
||||
d[t] || (d[t] = []);
|
||||
d[t].push(p);
|
||||
}
|
||||
if (b && ++g === b) {
|
||||
return d;
|
||||
@@ -768,13 +768,13 @@ function Fa(a, b, c, d, e) {
|
||||
if (!m || !m.length) {
|
||||
return [];
|
||||
}
|
||||
let n = z(), q = 0, t = l === a.length - 1;
|
||||
for (let p = 0, r; p < k; p++) {
|
||||
if (r = m[p]) {
|
||||
for (let x = 0, A, w; x < r.length; x++) {
|
||||
if (A = r[x], !l) {
|
||||
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 (t) {
|
||||
} else if (r) {
|
||||
if (w = h[A]) {
|
||||
if (q = 1, c) {
|
||||
c--;
|
||||
@@ -996,14 +996,13 @@ S.prototype.resolve = function(a, b, c) {
|
||||
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) {
|
||||
const f = a.length;
|
||||
let g = [], h, k;
|
||||
h = z();
|
||||
for (let l = 0, m, n, q, t; l < b; l++) {
|
||||
for (let p = 0; p < f; p++) {
|
||||
if (q = a[p], l < q.length && (m = q[l])) {
|
||||
for (let r = 0; r < m.length; r++) {
|
||||
n = m[r], (k = h[n]) ? h[n]++ : (k = 0, h[n] = 1), t = g[k] || (g[k] = []), t.push(n);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1011,21 +1010,43 @@ function Ia(a, b, c, d, e) {
|
||||
if (a = g.length) {
|
||||
if (e) {
|
||||
e = [];
|
||||
for (let l = a - 1, m = 0, n, q; 0 <= l; l--) {
|
||||
if (n = g[l], q = n.length, d >= q) {
|
||||
d -= q;
|
||||
for (let n = a - 1, q = 0, r, p; 0 <= n; n--) {
|
||||
if (r = g[n], p = r.length, d >= p) {
|
||||
d -= p;
|
||||
} else {
|
||||
if (q + m > c || d) {
|
||||
n = n.slice(d, c - m + d), q = n.length;
|
||||
if (p + q > c || d) {
|
||||
r = r.slice(d, c - q + d), p = r.length;
|
||||
}
|
||||
e.push(n);
|
||||
m += q;
|
||||
if (c === m) {
|
||||
e.push(r);
|
||||
q += p;
|
||||
if (c === q) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
g = 1 < e.length ? [].concat.apply([], e) : e[0];
|
||||
if (1 < e.length) {
|
||||
g = e;
|
||||
e = [];
|
||||
f = z();
|
||||
k = g.length;
|
||||
for (l = 0; l < k; l++) {
|
||||
for (a = g[l], h = a.length, m = 0; m < h; m++) {
|
||||
if (b = a[m], !f[b]) {
|
||||
if (f[b] = 1, d) {
|
||||
d--;
|
||||
} else {
|
||||
if (e.push(b), e.length === c) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
c = e;
|
||||
} else {
|
||||
c = e[0];
|
||||
}
|
||||
g = c;
|
||||
} else {
|
||||
if (a < f) {
|
||||
return [];
|
||||
@@ -1080,11 +1101,11 @@ O.prototype.search = function(a, b, c) {
|
||||
}
|
||||
let n = c = 0;
|
||||
if (1 < e) {
|
||||
const p = z(), r = [];
|
||||
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)) {
|
||||
r.push(A), p[A] = 1;
|
||||
t.push(A), p[A] = 1;
|
||||
} else {
|
||||
return h ? d : new S(d);
|
||||
}
|
||||
@@ -1093,37 +1114,37 @@ O.prototype.search = function(a, b, c) {
|
||||
n = n ? Math.min(n, w) : w;
|
||||
}
|
||||
}
|
||||
a = r;
|
||||
a = t;
|
||||
e = a.length;
|
||||
}
|
||||
if (!e) {
|
||||
return h ? d : new S(d);
|
||||
}
|
||||
let q = 0, t;
|
||||
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 ? (t = a[0], q = 1) : 9 < c && 3 < c / n && a.sort(aa));
|
||||
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 r, x; q < e; q++) {
|
||||
for (let t, x; q < e; q++) {
|
||||
x = a[q];
|
||||
t ? (r = await V(p, x, t), r = Ka(r, d, f, p.U, b, g, 2 === e), f && !1 === r && d.length || (t = x)) : (r = await V(p, x), r = Ka(r, d, f, p.resolution, b, g, 1 === e));
|
||||
if (r) {
|
||||
return r;
|
||||
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 (t) {
|
||||
t = "";
|
||||
if (r) {
|
||||
r = "";
|
||||
q = -1;
|
||||
continue;
|
||||
}
|
||||
@@ -1137,17 +1158,17 @@ O.prototype.search = function(a, b, c) {
|
||||
return h ? Ia(d, p.resolution, b, g, f) : new S(d[0]);
|
||||
}();
|
||||
}
|
||||
for (let p, r; q < e; q++) {
|
||||
r = a[q];
|
||||
t ? (p = V(this, r, t), p = Ka(p, d, f, this.U, b, g, 2 === e), f && !1 === p && d.length || (t = r)) : (p = V(this, r), p = Ka(p, d, f, this.resolution, b, g, 1 === e));
|
||||
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 (t) {
|
||||
t = "";
|
||||
if (r) {
|
||||
r = "";
|
||||
q = -1;
|
||||
continue;
|
||||
}
|
||||
@@ -1596,7 +1617,7 @@ function Qa(a, b, c, d, e, f, g, h) {
|
||||
k = g || c.field || c.index;
|
||||
var n = this.tag && c.tag;
|
||||
var q = this.store && c.enrich;
|
||||
var t = c.suggest;
|
||||
var r = c.suggest;
|
||||
b = c.limit || b;
|
||||
l = c.offset || 0;
|
||||
b || (b = 100);
|
||||
@@ -1609,18 +1630,18 @@ function Qa(a, b, c, d, e, f, g, h) {
|
||||
throw Error("A tag option can't be a string, instead it needs a { field: tag } format.");
|
||||
}
|
||||
if (v.field && v.tag) {
|
||||
var r = v.tag;
|
||||
if (r.constructor === Array) {
|
||||
for (var x = 0; x < r.length; x++) {
|
||||
p.push(v.field, r[x]);
|
||||
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, r);
|
||||
p.push(v.field, t);
|
||||
}
|
||||
} else {
|
||||
r = Object.keys(v);
|
||||
for (let I = 0, J, D; I < r.length; I++) {
|
||||
if (J = r[I], D = v[J], D.constructor === Array) {
|
||||
t = Object.keys(v);
|
||||
for (let I = 0, J, D; I < t.length; I++) {
|
||||
if (J = t[I], D = v[J], D.constructor === Array) {
|
||||
for (x = 0; x < D.length; x++) {
|
||||
p.push(J, D[x]);
|
||||
}
|
||||
@@ -1635,7 +1656,7 @@ function Qa(a, b, c, d, e, f, g, h) {
|
||||
}
|
||||
n = p;
|
||||
if (!a) {
|
||||
t = [];
|
||||
r = [];
|
||||
if (p.length) {
|
||||
for (n = 0; n < p.length; n += 2) {
|
||||
if (this.db) {
|
||||
@@ -1644,14 +1665,14 @@ function Qa(a, b, c, d, e, f, g, h) {
|
||||
console.warn("Tag '" + p[n] + ":" + p[n + 1] + "' will be skipped because there is no field '" + p[n] + "'.");
|
||||
continue;
|
||||
}
|
||||
t.push(d = d.db.tag(p[n + 1], b, l, q));
|
||||
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 t.length ? Promise.all(t).then(function(w) {
|
||||
return r.length ? Promise.all(r).then(function(w) {
|
||||
for (let v = 0; v < w.length; v++) {
|
||||
e[v].result = w[v];
|
||||
}
|
||||
@@ -1670,29 +1691,29 @@ function Qa(a, b, c, d, e, f, g, h) {
|
||||
continue;
|
||||
}
|
||||
let D;
|
||||
B(I) || (D = I, I = D.field, a = D.query || a, b = D.limit || b, t = D.suggest || t);
|
||||
B(I) || (D = I, I = D.field, a = D.query || a, b = D.limit || b, r = D.suggest || r);
|
||||
if (d) {
|
||||
v = d[w];
|
||||
} else {
|
||||
if (r = D || c, x = this.index.get(I), n && (this.db && (r.tag = n, A = x.db.Z, r.field = k), A || (r.enrich = !1)), p) {
|
||||
p[w] = x.searchAsync(a, b, r);
|
||||
r && q && (r.enrich = q);
|
||||
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) {
|
||||
p[w] = x.searchAsync(a, b, t);
|
||||
t && q && (t.enrich = q);
|
||||
continue;
|
||||
} else {
|
||||
v = x.search(a, b, r), r && q && (r.enrich = q);
|
||||
v = x.search(a, b, t), t && q && (t.enrich = q);
|
||||
}
|
||||
}
|
||||
J = v && v.length;
|
||||
if (n && J) {
|
||||
r = [];
|
||||
t = [];
|
||||
x = 0;
|
||||
if (this.db && d) {
|
||||
if (!A) {
|
||||
for (let E = k.length; E < d.length; E++) {
|
||||
let F = d[E];
|
||||
if (F && F.length) {
|
||||
x++, r.push(F);
|
||||
} else if (!t) {
|
||||
x++, t.push(F);
|
||||
} else if (!r) {
|
||||
return e;
|
||||
}
|
||||
}
|
||||
@@ -1701,23 +1722,23 @@ function Qa(a, b, c, d, e, f, g, h) {
|
||||
for (let E = 0, F, Za; E < n.length; E += 2) {
|
||||
F = this.tag.get(n[E]);
|
||||
if (!F) {
|
||||
if (console.warn("Tag '" + n[E] + ":" + n[E + 1] + "' will be skipped because there is no field '" + n[E] + "'."), t) {
|
||||
if (console.warn("Tag '" + n[E] + ":" + n[E + 1] + "' will be skipped because there is no field '" + n[E] + "'."), r) {
|
||||
continue;
|
||||
} else {
|
||||
return e;
|
||||
}
|
||||
}
|
||||
if (Za = (F = F && F.get(n[E + 1])) && F.length) {
|
||||
x++, r.push(F);
|
||||
} else if (!t) {
|
||||
x++, t.push(F);
|
||||
} else if (!r) {
|
||||
return e;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (x) {
|
||||
v = Ja(v, r);
|
||||
v = Ja(v, t);
|
||||
J = v.length;
|
||||
if (!J && !t) {
|
||||
if (!J && !r) {
|
||||
return e;
|
||||
}
|
||||
x--;
|
||||
@@ -1734,7 +1755,7 @@ function Qa(a, b, c, d, e, f, g, h) {
|
||||
for (q = 0; q < n.length; q += 2) {
|
||||
d = this.index.get(n[q]);
|
||||
if (!d) {
|
||||
if (console.warn("Tag '" + n[q] + ":" + n[q + 1] + "' was not found because there is no field '" + n[q] + "'."), t) {
|
||||
if (console.warn("Tag '" + n[q] + ":" + n[q + 1] + "' was not found because there is no field '" + n[q] + "'."), r) {
|
||||
continue;
|
||||
} else {
|
||||
return e;
|
||||
@@ -2228,14 +2249,14 @@ u.commit = async function(a, b, c) {
|
||||
var n;
|
||||
if (m && m.length) {
|
||||
const q = Math.max(m.length, l.length);
|
||||
for (let t = 0, p, r; t < q; t++) {
|
||||
if ((r = l[t]) && r.length) {
|
||||
if ((p = m[t]) && p.length) {
|
||||
for (n = 0; n < r.length; n++) {
|
||||
p.push(r[n]);
|
||||
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[t] = r;
|
||||
m[r] = t;
|
||||
}
|
||||
n = 1;
|
||||
}
|
||||
|
30
dist/flexsearch.bundle.module.min.js
vendored
30
dist/flexsearch.bundle.module.min.js
vendored
@@ -27,23 +27,23 @@ function J(a){if(!this)return new J(a);this.index=a?[a]:[];this.length=a?a.lengt
|
||||
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 t=0;t<d;t++){let p=b[this.rtl?d-1-t:t];var e=p.length;if(e&&(n||!m[p])){var f=this.score?this.score(b,p,t,null,0):P(q,d,t),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,t,g,f):P(q,d,t,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,t,g,h):P(q,d,t,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&&t<d-1)for(e=z(),g=this.U,f=p,h=Math.min(n+1,d-t),e[f]=1,k=1;k<h;k++)if((p=b[this.rtl?d-1-t-k:t+k])&&!e[p]){e[p]=1;const r=this.score?this.score(b,f,t,p,k):P(g+(d/2>g?0:1),d,t,h-1,k-1),x=this.bidirectional&&p>f;Q(this,l,x?f:p,r,a,c,x?p:f)}}}}this.fastupdate||this.A.add(a)}else b=""}this.db&&(b||
|
||||
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 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};
|
||||
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 t=0,p;t<m.length;t++)if(p=m[t],!h[p])if(h[p]=1,c)c--;else{if(e)d.push(p);else{const r=l+(n?f:0);d[r]||(d[r]=[]);d[r].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||
|
||||
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};
|
||||
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,t=l===a.length-1;for(let p=0,r;p<k;p++)if(r=m[p])for(let x=0,A,w;x<r.length;x++)if(A=r[x],!l)n[A]=p+1+(l?e:0),q=1;else if(t){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;
|
||||
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};
|
||||
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){const f=a.length;let g=[],h,k;h=z();for(let l=0,m,n,q,t;l<b;l++)for(let p=0;p<f;p++)if(q=a[p],l<q.length&&(m=q[l]))for(let r=0;r<m.length;r++)n=m[r],(k=h[n])?h[n]++:(k=0,h[n]=1),t=g[k]||(g[k]=[]),t.push(n);if(a=g.length)if(e){e=[];for(let l=a-1,m=0,n,q;0<=l;l--)if(n=g[l],q=n.length,d>=q)d-=q;else{if(q+m>c||d)n=n.slice(d,c-m+d),q=n.length;e.push(n);m+=q;if(c===m)break}g=1<e.length?[].concat.apply([],e):e[0]}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(),r=[];for(let x=0,A;x<e;x++)if((A=a[x])&&
|
||||
!p[A]){if(f||this.db||V(this,A))r.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=r;e=a.length}if(!e)return h?d:new S(d);let q=0,t;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?(t=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 r,x;q<e;q++){x=a[q];t?(r=await V(p,x,t),r=Ka(r,
|
||||
d,f,p.U,b,g,2===e),f&&!1===r&&d.length||(t=x)):(r=await V(p,x),r=Ka(r,d,f,p.resolution,b,g,1===e));if(r)return r;if(f&&q===e-1){let A=d.length;if(!A){if(t){t="";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,r;q<e;q++){r=a[q];t?(p=V(this,r,t),p=Ka(p,d,f,this.U,b,g,2===e),f&&!1===p&&d.length||(t=r)):(p=V(this,r),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(t){t="";q=-1;continue}return d}if(1===
|
||||
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){e=[];for(let n=a-1,q=0,r,p;0<=n;n--)if(r=g[n],p=r.length,d>=p)d-=p;else{if(p+q>c||d)r=r.slice(d,c-q+d),p=r.length;e.push(r);q+=p;if(c===q)break}if(1<e.length){g=e;e=[];f=z();k=g.length;for(l=0;l<k;l++)for(a=g[l],h=a.length,m=0;m<h;m++)if(b=a[m],!f[b])if(f[b]=
|
||||
1,d)d--;else if(e.push(b),e.length===c)break;c=e}else c=e[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===
|
||||
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=
|
||||
@@ -57,10 +57,10 @@ options:a})}}X("add");X("append");X("search");X("update");X("remove");function X
|
||||
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 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 t=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 r=v.tag;if(r.constructor===Array)for(var x=0;x<r.length;x++)p.push(v.field,
|
||||
r[x]);else p.push(v.field,r)}else{r=Object.keys(v);for(let H=0,I,D;H<r.length;H++)if(I=r[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){t=[];if(p.length)for(n=0;n<p.length;n+=2){if(this.db){d=this.index.get(p[n]);if(!d)continue;t.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 t.length?Promise.all(t).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,t=D.suggest||t);if(d)v=d[w];else if(r=D||c,x=this.index.get(H),n&&(this.db&&(r.tag=n,A=x.db.Z,r.field=k),A||(r.enrich=!1)),p){p[w]=x.searchAsync(a,b,r);r&&q&&(r.enrich=q);continue}else v=x.search(a,b,r),r&&q&&(r.enrich=q);I=v&&v.length;if(n&&I){r=[];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++,r.push(E);else if(!t)return e}}else for(let L=0,E,Za;L<n.length;L+=2){E=this.tag.get(n[L]);if(!E)if(t)continue;else return e;if(Za=(E=E&&E.get(n[L+1]))&&E.length)x++,r.push(E);else if(!t)return e}if(x){v=Ja(v,r);I=v.length;if(!I&&!t)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(t)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?
|
||||
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=
|
||||
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=
|
||||
@@ -81,8 +81,8 @@ u.tag=function(a,b=0,c=0,d=!1){a=this.db.transaction("tag","readonly").objectSto
|
||||
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 t=0,p,r;t<q;t++)if((r=l[t])&&r.length){if((p=m[t])&&p.length)for(n=0;n<r.length;n++)p.push(r[n]);
|
||||
else m[t]=r;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,
|
||||
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.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:{}};
|
||||
|
24
dist/flexsearch.compact.debug.js
vendored
24
dist/flexsearch.compact.debug.js
vendored
@@ -510,7 +510,29 @@ function O(a, c, b, e, d) {
|
||||
}
|
||||
}
|
||||
}
|
||||
g = 1 < e.length ? [].concat.apply([], e) : e[0];
|
||||
if (1 < e.length) {
|
||||
g = e;
|
||||
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 = e[0];
|
||||
}
|
||||
g = c;
|
||||
} else {
|
||||
if (a < b) {
|
||||
e = [];
|
||||
|
5
dist/flexsearch.compact.min.js
vendored
5
dist/flexsearch.compact.min.js
vendored
@@ -25,8 +25,9 @@ g||"w"===g||!(g=ma[g])||g===d||(e+=g,d=g,4!==e.length));f++);a[c]=e}}},ArabicDef
|
||||
d){for(h=d-1;0<h;h--)g=n[h]+g,k=this.score?this.score(b,n,p,g,h):N(t,e,p,d,h),O(this,m,g,k,a,c);g=""}case "forward":if(1<d){for(h=0;h<d;h++)g+=n[h],O(this,m,g,f,a,c);break}default:if(O(this,m,n,f,a,c),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=b[this.rtl?e-1-p-k:p+k])&&!d[n]){d[n]=1;const w=this.score?this.score(b,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,c,B?n:f)}}}}this.fastupdate||this.h.add(a)}}return this};
|
||||
function O(a,b,c,e,d,f,g){let h=g?a.D:a.map,k;b[c]&&g&&(k=b[c])[g]||(g?(b=k||(b[c]=y()),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=[]),h=h[e]||(h[e]=[]),f&&h.includes(d)||(h.push(d),a.fastupdate&&((b=a.h.get(d))?b.push(h):a.h.set(d,[h]))))}function N(a,b,c,e,d){return c&&1<a?b+(e||0)<=a?c+(d||0):(a-1)/(b+(e||0))*(c+(d||0))+1|0:0};function Q(a,b,c){if(1===a.length)return a=a[0],a=c||a.length>b?b?a.slice(c,c+b):a.slice(c):a;let e=[];for(let d=0,f,g;d<a.length;d++)if((f=a[d])&&(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)),f;e=[f]}b-=g;if(!b)break}return e.length?e=1<e.length?[].concat.apply([],e):e[0]:e};function ua(a,b){const c=y(),e=y(),d=[];for(let f=0;f<a.length;f++)c[a[f]]=1;for(let f=0,g;f<b.length;f++){g=b[f];for(let h=0,k;h<g.length;h++)k=g[h],c[k]&&!e[k]&&(e[k]=1,d.push(k))}return d};M.prototype.search=function(a,b,c){c||(!b&&E(a)?(c=a,a=""):E(b)&&(c=b,b=0));var e=[],d=0;if(c){a=c.query||a;b=c.limit||b;d=c.offset||0;var f=c.context;var g=c.suggest}a=this.encoder.encode(a);c=a.length;b||(b=100);if(1===c)return R.call(this,a[0],"",b,d);f=this.depth&&!1!==f;if(2===c&&f&&!g)return R.call(this,a[0],a[1],b,d);var h=0,k=0;if(1<c){var l=y();const r=[];for(let t=0,p;t<c;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;c=a.length}if(!c)return e;l=0;if(1===c)return R.call(this,a[0],"",b,d);if(2===c&&f&&!g)return R.call(this,a[0],a[1],b,d);if(1<c)if(f){var m=a[0];l=1}else 9<h&&3<h/k&&a.sort(aa);for(let r,t;l<c;l++){t=a[l];m?(r=S(this,t,m),r=va(r,e,g,this.S,b,d,2===c),g&&!1===r&&e.length||(m=t)):(r=S(this,t),r=va(r,e,g,this.resolution,b,d,1===c));if(r)return r;if(g&&l===c-1){f=e.length;if(!f){if(m){m="";l=-1;continue}return e}if(1===f)return Q(e[0],b,d)}}a:{a=e;e=this.resolution;m=g;c=a.length;g=[];f=y();
|
||||
for(let r=0,t,p,n,w;r<e;r++)for(k=0;k<c;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=g[h]||(g[h]=[]),w.push(p);if(a=g.length)if(m){e=[];for(let r=a-1,t=0,p,n;0<=r;r--)if(p=g[r],n=p.length,d>=n)d-=n;else{if(n+t>b||d)p=p.slice(d,b-t+d),n=p.length;e.push(p);t+=n;if(b===t)break}g=1<e.length?[].concat.apply([],e):e[0]}else{if(a<c){e=[];break a}g=g[a-1];if(g.length>b||d)g=g.slice(d,b+d)}e=g}return e};
|
||||
function R(a,b,c,e){return(a=S(this,a,b))&&a.length?Q(a,c,e):[]}function va(a,b,c,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);b.push(h);return}}return!c&&h}function S(a,b,c){let e;c&&(e=a.bidirectional&&b>c);a=c?(a=a.D.get(e?b:c))&&a.get(e?c:b):a.map.get(b);return a};M.prototype.remove=function(a,b){const c=this.h.size&&(this.fastupdate?this.h.get(a):this.h.has(a));if(c){if(this.fastupdate)for(let e=0,d;e<c.length;e++){if(d=c[e])if(2>d.length)d.pop();else{const f=d.indexOf(a);f===c.length-1?d.pop():d.splice(f,1)}}else T(this.map,a),this.depth&&T(this.D,a);b||this.h.delete(a)}this.cache&&this.cache.remove(a);return this};
|
||||
for(let r=0,t,p,n,w;r<e;r++)for(k=0;k<c;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=g[h]||(g[h]=[]),w.push(p);if(a=g.length)if(m){e=[];for(let r=a-1,t=0,p,n;0<=r;r--)if(p=g[r],n=p.length,d>=n)d-=n;else{if(n+t>b||d)p=p.slice(d,b-t+d),n=p.length;e.push(p);t+=n;if(b===t)break}if(1<e.length){g=e;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(c=m[l],!e[c])if(e[c]=1,d)d--;else if(a.push(c),a.length===b)break;b=a}else b=e[0];
|
||||
g=b}else{if(a<c){e=[];break a}g=g[a-1];if(g.length>b||d)g=g.slice(d,b+d)}e=g}return e};function R(a,b,c,e){return(a=S(this,a,b))&&a.length?Q(a,c,e):[]}function va(a,b,c,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);b.push(h);return}}return!c&&h}
|
||||
function S(a,b,c){let e;c&&(e=a.bidirectional&&b>c);a=c?(a=a.D.get(e?b:c))&&a.get(e?c:b):a.map.get(b);return a};M.prototype.remove=function(a,b){const c=this.h.size&&(this.fastupdate?this.h.get(a):this.h.has(a));if(c){if(this.fastupdate)for(let e=0,d;e<c.length;e++){if(d=c[e])if(2>d.length)d.pop();else{const f=d.indexOf(a);f===c.length-1?d.pop():d.splice(f,1)}}else T(this.map,a),this.depth&&T(this.D,a);b||this.h.delete(a)}this.cache&&this.cache.remove(a);return this};
|
||||
function T(a,b){let c=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(b),0<=f){1<d.length?(d.splice(f,1),c++):delete a[e];break}else c++}else for(let e of a){const d=e[0],f=T(e[1],b);f?c+=f:a.delete(d)}return c};function M(a,b){if(!this)return new M(a);if(a){var c=z(a)?a:a.preset;c&&(a=Object.assign({},sa[c],a))}else a={};c=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&&c.depth||0;this.bidirectional=!1!==c.bidirectional;this.fastupdate=!!a.fastupdate;this.score=a.score||null;d=!1;this.map=new Map;this.D=new Map;this.h=b||(this.fastupdate?new Map:
|
||||
new Set);this.S=c.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,b){return this.add(a,b,!0)};u.contain=function(a){return this.h.has(a)};u.update=function(a,b){if(this.async){const c=this,e=this.remove(a);return e.then?e.then(()=>c.add(a,b)):this.add(a,b)}return this.remove(a).add(a,b)};
|
||||
function U(a){let b=0;if(a.constructor===Array)for(let c=0,e;c<a.length;c++)(e=a[c])&&(b+=e.length);else for(const c of a){const e=c[0],d=U(c[1]);d?b+=d:a.delete(e)}return b}u.cleanup=function(){if(!this.fastupdate)return this;U(this.map);this.depth&&U(this.D);return this};u.searchCache=ia;
|
||||
|
138
dist/flexsearch.compact.module.debug.js
vendored
138
dist/flexsearch.compact.module.debug.js
vendored
@@ -156,8 +156,8 @@ J.prototype.encode = function(a) {
|
||||
d && g && (d.length < this.minlength || this.filter && this.filter.has(d)) && (d = "");
|
||||
if (d && (this.mapper || this.dedupe && 1 < d.length)) {
|
||||
var e = "";
|
||||
for (let h = 0, k = "", p, m; h < d.length; h++) {
|
||||
p = d.charAt(h), p === k && this.dedupe || ((m = this.mapper && this.mapper.get(p)) || "" === m ? m === k && this.dedupe || !(k = m) || (e += m) : e += k = p);
|
||||
for (let h = 0, k = "", n, m; h < d.length; h++) {
|
||||
n = d.charAt(h), n === k && this.dedupe || ((m = this.mapper && this.mapper.get(n)) || "" === m ? m === k && this.dedupe || !(k = m) || (e += m) : e += k = n);
|
||||
}
|
||||
d = e;
|
||||
}
|
||||
@@ -229,19 +229,19 @@ O.prototype.add = function(a, b, c, e) {
|
||||
}
|
||||
b = this.encoder.encode(b);
|
||||
if (e = b.length) {
|
||||
const p = y(), m = y(), r = this.depth, t = this.resolution;
|
||||
for (let n = 0; n < e; n++) {
|
||||
let l = b[this.rtl ? e - 1 - n : n];
|
||||
const n = y(), m = y(), r = this.depth, t = this.resolution;
|
||||
for (let p = 0; p < e; p++) {
|
||||
let l = b[this.rtl ? e - 1 - p : p];
|
||||
var f = l.length;
|
||||
if (f && (r || !m[l])) {
|
||||
var d = this.score ? this.score(b, l, n, null, 0) : P(t, e, n), g = "";
|
||||
var d = this.score ? this.score(b, l, p, null, 0) : P(t, e, p), g = "";
|
||||
switch(this.tokenize) {
|
||||
case "full":
|
||||
if (2 < f) {
|
||||
for (d = 0; d < f; d++) {
|
||||
for (var h = f; h > d; h--) {
|
||||
g = l.substring(d, h);
|
||||
var k = this.score ? this.score(b, l, n, g, d) : P(t, e, n, f, d);
|
||||
var k = this.score ? this.score(b, l, p, g, d) : P(t, e, p, f, d);
|
||||
Q(this, m, g, k, a, c);
|
||||
}
|
||||
}
|
||||
@@ -250,7 +250,7 @@ O.prototype.add = function(a, b, c, e) {
|
||||
case "reverse":
|
||||
if (1 < f) {
|
||||
for (h = f - 1; 0 < h; h--) {
|
||||
g = l[h] + g, k = this.score ? this.score(b, l, n, g, h) : P(t, e, n, f, h), Q(this, m, g, k, a, c);
|
||||
g = l[h] + g, k = this.score ? this.score(b, l, p, g, h) : P(t, e, p, f, h), Q(this, m, g, k, a, c);
|
||||
}
|
||||
g = "";
|
||||
}
|
||||
@@ -262,12 +262,12 @@ O.prototype.add = function(a, b, c, e) {
|
||||
break;
|
||||
}
|
||||
default:
|
||||
if (Q(this, m, l, d, a, c), r && 1 < e && n < e - 1) {
|
||||
for (f = y(), g = this.K, d = l, h = Math.min(r + 1, e - n), f[d] = 1, k = 1; k < h; k++) {
|
||||
if ((l = b[this.rtl ? e - 1 - n - k : n + k]) && !f[l]) {
|
||||
if (Q(this, m, l, d, a, c), r && 1 < e && p < e - 1) {
|
||||
for (f = y(), g = this.K, d = l, h = Math.min(r + 1, e - p), f[d] = 1, k = 1; k < h; k++) {
|
||||
if ((l = b[this.rtl ? e - 1 - p - k : p + k]) && !f[l]) {
|
||||
f[l] = 1;
|
||||
const w = this.score ? this.score(b, d, n, l, k) : P(g + (e / 2 > g ? 0 : 1), e, n, h - 1, k - 1), B = this.bidirectional && l > d;
|
||||
Q(this, p, B ? d : l, w, a, c, B ? l : d);
|
||||
const w = this.score ? this.score(b, d, p, l, k) : P(g + (e / 2 > g ? 0 : 1), e, p, h - 1, k - 1), B = this.bidirectional && l > d;
|
||||
Q(this, n, B ? d : l, w, a, c, B ? l : d);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -351,16 +351,16 @@ function P(a, b, c, e, f) {
|
||||
}
|
||||
var h = 0, k = 0;
|
||||
if (1 < c) {
|
||||
var p = y();
|
||||
var n = y();
|
||||
const r = [];
|
||||
for (let t = 0, n; t < c; t++) {
|
||||
if ((n = a[t]) && !p[n]) {
|
||||
if (g || T(this, n)) {
|
||||
r.push(n), p[n] = 1;
|
||||
for (let t = 0, p; t < c; t++) {
|
||||
if ((p = a[t]) && !n[p]) {
|
||||
if (g || T(this, p)) {
|
||||
r.push(p), n[p] = 1;
|
||||
} else {
|
||||
return e;
|
||||
}
|
||||
const l = n.length;
|
||||
const l = p.length;
|
||||
h = Math.max(h, l);
|
||||
k = k ? Math.min(k, l) : l;
|
||||
}
|
||||
@@ -371,7 +371,7 @@ function P(a, b, c, e, f) {
|
||||
if (!c) {
|
||||
return e;
|
||||
}
|
||||
p = 0;
|
||||
n = 0;
|
||||
if (1 === c) {
|
||||
return S.call(this, a[0], "", b, f);
|
||||
}
|
||||
@@ -381,23 +381,23 @@ function P(a, b, c, e, f) {
|
||||
if (1 < c) {
|
||||
if (d) {
|
||||
var m = a[0];
|
||||
p = 1;
|
||||
n = 1;
|
||||
} else {
|
||||
9 < h && 3 < h / k && a.sort(aa);
|
||||
}
|
||||
}
|
||||
for (let r, t; p < c; p++) {
|
||||
t = a[p];
|
||||
for (let r, t; n < c; n++) {
|
||||
t = a[n];
|
||||
m ? (r = T(this, t, m), r = ra(r, e, g, this.K, b, f, 2 === c), g && !1 === r && e.length || (m = t)) : (r = T(this, t), r = ra(r, e, g, this.resolution, b, f, 1 === c));
|
||||
if (r) {
|
||||
return r;
|
||||
}
|
||||
if (g && p === c - 1) {
|
||||
if (g && n === c - 1) {
|
||||
d = e.length;
|
||||
if (!d) {
|
||||
if (m) {
|
||||
m = "";
|
||||
p = -1;
|
||||
n = -1;
|
||||
continue;
|
||||
}
|
||||
return e;
|
||||
@@ -414,11 +414,11 @@ function P(a, b, c, e, f) {
|
||||
c = a.length;
|
||||
g = [];
|
||||
d = y();
|
||||
for (let r = 0, t, n, l, w; r < e; r++) {
|
||||
for (let r = 0, t, p, l, w; r < e; r++) {
|
||||
for (k = 0; k < c; k++) {
|
||||
if (l = a[k], r < l.length && (t = l[r])) {
|
||||
for (p = 0; p < t.length; p++) {
|
||||
n = t[p], (h = d[n]) ? d[n]++ : (h = 0, d[n] = 1), w = g[h] || (g[h] = []), w.push(n);
|
||||
for (n = 0; n < t.length; n++) {
|
||||
p = t[n], (h = d[p]) ? d[p]++ : (h = 0, d[p] = 1), w = g[h] || (g[h] = []), w.push(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -426,21 +426,43 @@ function P(a, b, c, e, f) {
|
||||
if (a = g.length) {
|
||||
if (m) {
|
||||
e = [];
|
||||
for (let r = a - 1, t = 0, n, l; 0 <= r; r--) {
|
||||
if (n = g[r], l = n.length, f >= l) {
|
||||
for (let r = a - 1, t = 0, p, l; 0 <= r; r--) {
|
||||
if (p = g[r], l = p.length, f >= l) {
|
||||
f -= l;
|
||||
} else {
|
||||
if (l + t > b || f) {
|
||||
n = n.slice(f, b - t + f), l = n.length;
|
||||
p = p.slice(f, b - t + f), l = p.length;
|
||||
}
|
||||
e.push(n);
|
||||
e.push(p);
|
||||
t += l;
|
||||
if (b === t) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
g = 1 < e.length ? [].concat.apply([], e) : e[0];
|
||||
if (1 < e.length) {
|
||||
g = e;
|
||||
a = [];
|
||||
e = y();
|
||||
d = g.length;
|
||||
for (k = 0; k < d; k++) {
|
||||
for (m = g[k], h = m.length, n = 0; n < h; n++) {
|
||||
if (c = m[n], !e[c]) {
|
||||
if (e[c] = 1, f) {
|
||||
f--;
|
||||
} else {
|
||||
if (a.push(c), a.length === b) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
b = a;
|
||||
} else {
|
||||
b = e[0];
|
||||
}
|
||||
g = b;
|
||||
} else {
|
||||
if (a < c) {
|
||||
e = [];
|
||||
@@ -463,9 +485,9 @@ function ra(a, b, c, e, f, d, g) {
|
||||
let h = [];
|
||||
if (a) {
|
||||
e = Math.min(a.length, e);
|
||||
for (let k = 0, p = 0, m; k < e; k++) {
|
||||
for (let k = 0, n = 0, m; k < e; k++) {
|
||||
if (m = a[k]) {
|
||||
if (d && m && g && (m.length <= d ? (d -= m.length, m = null) : (m = m.slice(d), d = 0)), m && (h[k] = m, g && (p += m.length, p >= f))) {
|
||||
if (d && m && g && (m.length <= d ? (d -= m.length, m = null) : (m = m.slice(d), d = 0)), m && (h[k] = m, g && (n += m.length, n >= f))) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -598,8 +620,8 @@ v.cleanup = function() {
|
||||
};
|
||||
v.export = function(a, b, c, e, f, d) {
|
||||
let g = !0;
|
||||
"undefined" === typeof d && (g = new Promise(p => {
|
||||
d = p;
|
||||
"undefined" === typeof d && (g = new Promise(n => {
|
||||
d = n;
|
||||
}));
|
||||
let h, k;
|
||||
switch(f || (f = 0)) {
|
||||
@@ -607,8 +629,8 @@ v.export = function(a, b, c, e, f, d) {
|
||||
h = "reg";
|
||||
if (this.fastupdate) {
|
||||
k = y();
|
||||
for (let p of this.h.keys()) {
|
||||
k[p] = 1;
|
||||
for (let n of this.h.keys()) {
|
||||
k[n] = 1;
|
||||
}
|
||||
} else {
|
||||
k = this.h;
|
||||
@@ -740,19 +762,19 @@ function X(a, b, c, e, f, d, g, h) {
|
||||
c || (!b && E(a) ? (c = a, a = "") : E(b) && (c = b, b = 0));
|
||||
let f = [];
|
||||
var d = [];
|
||||
let g, h, k, p, m;
|
||||
let g, h, k, n, m;
|
||||
let r = 0;
|
||||
if (c) {
|
||||
c.constructor === Array && (c = {index:c});
|
||||
a = c.query || a;
|
||||
var t = c.pluck;
|
||||
h = c.merge;
|
||||
p = t || c.field || c.index;
|
||||
n = t || c.field || c.index;
|
||||
m = !1;
|
||||
g = this.store && c.enrich;
|
||||
k = c.suggest;
|
||||
b = c.limit || b;
|
||||
var n = c.offset || 0;
|
||||
var p = c.offset || 0;
|
||||
b || (b = 100);
|
||||
if (m) {
|
||||
m.constructor !== Array && (m = [m]);
|
||||
@@ -792,7 +814,7 @@ function X(a, b, c, e, f, d, g, h) {
|
||||
e = [];
|
||||
if (l.length) {
|
||||
for (d = 0; d < l.length; d += 2) {
|
||||
t = sa.call(this, l[d], l[d + 1], b, n, g), f.push({field:l[d], tag:l[d + 1], result:t});
|
||||
t = sa.call(this, l[d], l[d + 1], b, p, g), f.push({field:l[d], tag:l[d + 1], result:t});
|
||||
}
|
||||
}
|
||||
return e.length ? Promise.all(e).then(function(u) {
|
||||
@@ -803,19 +825,19 @@ function X(a, b, c, e, f, d, g, h) {
|
||||
}) : f;
|
||||
}
|
||||
}
|
||||
z(p) && (p = [p]);
|
||||
z(n) && (n = [n]);
|
||||
}
|
||||
p || (p = this.field);
|
||||
n = !e && (this.worker || this.async) && [];
|
||||
for (let u = 0, q, C, D; u < p.length; u++) {
|
||||
C = p[u];
|
||||
n || (n = this.field);
|
||||
p = !e && (this.worker || this.async) && [];
|
||||
for (let u = 0, q, C, D; u < n.length; u++) {
|
||||
C = n[u];
|
||||
let A;
|
||||
z(C) || (A = C, C = A.field, a = A.query || a, b = A.limit || b, k = A.suggest || k);
|
||||
if (e) {
|
||||
q = e[u];
|
||||
} else {
|
||||
if (l = A || c, w = this.index.get(C), m && (l.enrich = !1), n) {
|
||||
n[u] = w.searchAsync(a, b, l);
|
||||
if (l = A || c, w = this.index.get(C), m && (l.enrich = !1), p) {
|
||||
p[u] = w.searchAsync(a, b, l);
|
||||
l && g && (l.enrich = g);
|
||||
continue;
|
||||
} else {
|
||||
@@ -852,13 +874,13 @@ function X(a, b, c, e, f, d, g, h) {
|
||||
}
|
||||
if (D) {
|
||||
d[r] = C, f.push(q), r++;
|
||||
} else if (1 === p.length) {
|
||||
} else if (1 === n.length) {
|
||||
return f;
|
||||
}
|
||||
}
|
||||
if (n) {
|
||||
if (p) {
|
||||
const u = this;
|
||||
return Promise.all(n).then(function(q) {
|
||||
return Promise.all(p).then(function(q) {
|
||||
return q.length ? u.search(a, b, c, q) : q;
|
||||
});
|
||||
}
|
||||
@@ -868,7 +890,7 @@ function X(a, b, c, e, f, d, g, h) {
|
||||
if (t && (!g || !this.store)) {
|
||||
return f[0];
|
||||
}
|
||||
n = [];
|
||||
p = [];
|
||||
for (let u = 0, q; u < d.length; u++) {
|
||||
q = f[u];
|
||||
g && q.length && !q[0].doc && q.length && (q = ta.call(this, q));
|
||||
@@ -884,15 +906,15 @@ function va(a, b) {
|
||||
for (let f = 0, d, g; f < a.length; f++) {
|
||||
d = a[f];
|
||||
g = d.result;
|
||||
for (let h = 0, k, p, m; h < g.length; h++) {
|
||||
if (p = g[h], k = p.id, m = e[k]) {
|
||||
for (let h = 0, k, n, m; h < g.length; h++) {
|
||||
if (n = g[h], k = n.id, m = e[k]) {
|
||||
m.push(d.field);
|
||||
} else {
|
||||
if (c.length === b) {
|
||||
return c;
|
||||
}
|
||||
p.field = e[k] = [d.field];
|
||||
c.push(p);
|
||||
n.field = e[k] = [d.field];
|
||||
c.push(n);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
29
dist/flexsearch.compact.module.min.js
vendored
29
dist/flexsearch.compact.module.min.js
vendored
@@ -17,25 +17,26 @@ I.prototype.assign=function(a){this.normalize=x(a.normalize,!0,this.normalize);l
|
||||
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((c=a.filter)&&new Set(c),null,this.filter);this.matcher=x((c=a.matcher)&&new Map(c),null,this.matcher);this.mapper=x((c=a.mapper)&&new Map(c),null,this.mapper);this.stemmer=x((c=a.stemmer)&&new Map(c),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};
|
||||
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 b=!(this.dedupe||this.mapper||this.filter||this.matcher||this.stemmer||this.replacer);let c=[];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(b){c.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="",p,m;h<f.length;h++)p=
|
||||
f.charAt(h),p===k&&this.dedupe||((m=this.mapper&&this.mapper.get(p))||""===m?m===k&&this.dedupe||!(k=m)||(d+=m):d+=k=p);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&&c.push(f)}this.finalize&&(c=this.finalize(c)||c);return c};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 c=0;c<a.length;c++){var b=a[c];let d=b.charAt(0),e=ia[d];for(let f=1,g;f<b.length&&(g=b.charAt(f),"h"===g||
|
||||
"w"===g||!(g=ia[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(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,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 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 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}};y();N.prototype.add=function(a,b,c,d){if(b&&(a||0===a)){if(!d&&!c&&this.h.has(a))return this.update(a,b);b=this.encoder.encode(b);if(d=b.length){const p=y(),m=y(),r=this.depth,t=this.resolution;for(let n=0;n<d;n++){let l=b[this.rtl?d-1-n:n];var e=l.length;if(e&&(r||!m[l])){var f=this.score?this.score(b,l,n,null,0):P(t,d,n),g="";switch(this.tokenize){case "full":if(2<e){for(f=0;f<e;f++)for(var h=e;h>f;h--){g=l.substring(f,h);var k=this.score?this.score(b,l,n,g,f):P(t,d,n,e,f);Q(this,m,g,k,a,c)}break}case "reverse":if(1<
|
||||
e){for(h=e-1;0<h;h--)g=l[h]+g,k=this.score?this.score(b,l,n,g,h):P(t,d,n,e,h),Q(this,m,g,k,a,c);g=""}case "forward":if(1<e){for(h=0;h<e;h++)g+=l[h],Q(this,m,g,f,a,c);break}default:if(Q(this,m,l,f,a,c),r&&1<d&&n<d-1)for(e=y(),g=this.K,f=l,h=Math.min(r+1,d-n),e[f]=1,k=1;k<h;k++)if((l=b[this.rtl?d-1-n-k:n+k])&&!e[l]){e[l]=1;const w=this.score?this.score(b,f,n,l,k):P(g+(d/2>g?0:1),d,n,h-1,k-1),B=this.bidirectional&&l>f;Q(this,p,B?f:l,w,a,c,B?l:f)}}}}this.fastupdate||this.h.add(a)}}return this};
|
||||
function Q(a,b,c,d,e,f,g){let h=g?a.B:a.map,k;b[c]&&g&&(k=b[c])[g]||(g?(b=k||(b[c]=y()),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=[]),h=h[d]||(h[d]=[]),f&&h.includes(e)||(h.push(e),a.fastupdate&&((b=a.h.get(e))?b.push(h):a.h.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){if(1===a.length)return a=a[0],a=c||a.length>b?b?a.slice(c,c+b):a.slice(c):a;let d=[];for(let e=0,f,g;e<a.length;e++)if((f=a[e])&&(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(d.length)g>b&&(f=f.slice(0,b),g=f.length),d.push(f);else{if(g>=b)return g>b&&(f=f.slice(0,b)),f;d=[f]}b-=g;if(!b)break}return d.length?d=1<d.length?[].concat.apply([],d):d[0]:d};function qa(a,b){const c=y(),d=y(),e=[];for(let f=0;f<a.length;f++)c[a[f]]=1;for(let f=0,g;f<b.length;f++){g=b[f];for(let h=0,k;h<g.length;h++)k=g[h],c[k]&&!d[k]&&(d[k]=1,e.push(k))}return e};N.prototype.search=function(a,b,c){c||(!b&&E(a)?(c=a,a=""):E(b)&&(c=b,b=0));var d=[],e=0;if(c){a=c.query||a;b=c.limit||b;e=c.offset||0;var f=c.context;var g=c.suggest}a=this.encoder.encode(a);c=a.length;b||(b=100);if(1===c)return S.call(this,a[0],"",b,e);f=this.depth&&!1!==f;if(2===c&&f&&!g)return S.call(this,a[0],a[1],b,e);var h=0,k=0;if(1<c){var p=y();const r=[];for(let t=0,n;t<c;t++)if((n=a[t])&&!p[n]){if(g||T(this,n))r.push(n),p[n]=1;else return d;const l=n.length;h=Math.max(h,l);k=k?Math.min(k,
|
||||
l):l}a=r;c=a.length}if(!c)return d;p=0;if(1===c)return S.call(this,a[0],"",b,e);if(2===c&&f&&!g)return S.call(this,a[0],a[1],b,e);if(1<c)if(f){var m=a[0];p=1}else 9<h&&3<h/k&&a.sort(aa);for(let r,t;p<c;p++){t=a[p];m?(r=T(this,t,m),r=ra(r,d,g,this.K,b,e,2===c),g&&!1===r&&d.length||(m=t)):(r=T(this,t),r=ra(r,d,g,this.resolution,b,e,1===c));if(r)return r;if(g&&p===c-1){f=d.length;if(!f){if(m){m="";p=-1;continue}return d}if(1===f)return R(d[0],b,e)}}a:{a=d;d=this.resolution;m=g;c=a.length;g=[];f=y();
|
||||
for(let r=0,t,n,l,w;r<d;r++)for(k=0;k<c;k++)if(l=a[k],r<l.length&&(t=l[r]))for(p=0;p<t.length;p++)n=t[p],(h=f[n])?f[n]++:(h=0,f[n]=1),w=g[h]||(g[h]=[]),w.push(n);if(a=g.length)if(m){d=[];for(let r=a-1,t=0,n,l;0<=r;r--)if(n=g[r],l=n.length,e>=l)e-=l;else{if(l+t>b||e)n=n.slice(e,b-t+e),l=n.length;d.push(n);t+=l;if(b===t)break}g=1<d.length?[].concat.apply([],d):d[0]}else{if(a<c){d=[];break a}g=g[a-1];if(g.length>b||e)g=g.slice(e,b+e)}d=g}return d};
|
||||
function S(a,b,c,d){return(a=T(this,a,b))&&a.length?R(a,c,d):[]}function ra(a,b,c,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 R(h,e,0);b.push(h);return}}return!c&&h}function T(a,b,c){let d;c&&(d=a.bidirectional&&b>c);a=c?(a=a.B.get(d?b:c))&&a.get(d?c:b):a.map.get(b);return a};N.prototype.remove=function(a,b){const c=this.h.size&&(this.fastupdate?this.h.get(a):this.h.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 U(this.map,a),this.depth&&U(this.B,a);b||this.h.delete(a)}return this};
|
||||
this.minlength)continue;if(b){c.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,m;h<f.length;h++)n=
|
||||
f.charAt(h),n===k&&this.dedupe||((m=this.mapper&&this.mapper.get(n))||""===m?m===k&&this.dedupe||!(k=m)||(d+=m):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&&c.push(f)}this.finalize&&(c=this.finalize(c)||c);return c};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 c=0;c<a.length;c++){var b=a[c];let d=b.charAt(0),e=ia[d];for(let f=1,g;f<b.length&&(g=b.charAt(f),"h"===g||
|
||||
"w"===g||!(g=ia[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(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,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 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 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}};y();N.prototype.add=function(a,b,c,d){if(b&&(a||0===a)){if(!d&&!c&&this.h.has(a))return this.update(a,b);b=this.encoder.encode(b);if(d=b.length){const n=y(),m=y(),r=this.depth,t=this.resolution;for(let p=0;p<d;p++){let l=b[this.rtl?d-1-p:p];var e=l.length;if(e&&(r||!m[l])){var f=this.score?this.score(b,l,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=l.substring(f,h);var k=this.score?this.score(b,l,p,g,f):P(t,d,p,e,f);Q(this,m,g,k,a,c)}break}case "reverse":if(1<
|
||||
e){for(h=e-1;0<h;h--)g=l[h]+g,k=this.score?this.score(b,l,p,g,h):P(t,d,p,e,h),Q(this,m,g,k,a,c);g=""}case "forward":if(1<e){for(h=0;h<e;h++)g+=l[h],Q(this,m,g,f,a,c);break}default:if(Q(this,m,l,f,a,c),r&&1<d&&p<d-1)for(e=y(),g=this.K,f=l,h=Math.min(r+1,d-p),e[f]=1,k=1;k<h;k++)if((l=b[this.rtl?d-1-p-k:p+k])&&!e[l]){e[l]=1;const w=this.score?this.score(b,f,p,l,k):P(g+(d/2>g?0:1),d,p,h-1,k-1),B=this.bidirectional&&l>f;Q(this,n,B?f:l,w,a,c,B?l:f)}}}}this.fastupdate||this.h.add(a)}}return this};
|
||||
function Q(a,b,c,d,e,f,g){let h=g?a.B:a.map,k;b[c]&&g&&(k=b[c])[g]||(g?(b=k||(b[c]=y()),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=[]),h=h[d]||(h[d]=[]),f&&h.includes(e)||(h.push(e),a.fastupdate&&((b=a.h.get(e))?b.push(h):a.h.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){if(1===a.length)return a=a[0],a=c||a.length>b?b?a.slice(c,c+b):a.slice(c):a;let d=[];for(let e=0,f,g;e<a.length;e++)if((f=a[e])&&(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(d.length)g>b&&(f=f.slice(0,b),g=f.length),d.push(f);else{if(g>=b)return g>b&&(f=f.slice(0,b)),f;d=[f]}b-=g;if(!b)break}return d.length?d=1<d.length?[].concat.apply([],d):d[0]:d};function qa(a,b){const c=y(),d=y(),e=[];for(let f=0;f<a.length;f++)c[a[f]]=1;for(let f=0,g;f<b.length;f++){g=b[f];for(let h=0,k;h<g.length;h++)k=g[h],c[k]&&!d[k]&&(d[k]=1,e.push(k))}return e};N.prototype.search=function(a,b,c){c||(!b&&E(a)?(c=a,a=""):E(b)&&(c=b,b=0));var d=[],e=0;if(c){a=c.query||a;b=c.limit||b;e=c.offset||0;var f=c.context;var g=c.suggest}a=this.encoder.encode(a);c=a.length;b||(b=100);if(1===c)return S.call(this,a[0],"",b,e);f=this.depth&&!1!==f;if(2===c&&f&&!g)return S.call(this,a[0],a[1],b,e);var h=0,k=0;if(1<c){var n=y();const r=[];for(let t=0,p;t<c;t++)if((p=a[t])&&!n[p]){if(g||T(this,p))r.push(p),n[p]=1;else return d;const l=p.length;h=Math.max(h,l);k=k?Math.min(k,
|
||||
l):l}a=r;c=a.length}if(!c)return d;n=0;if(1===c)return S.call(this,a[0],"",b,e);if(2===c&&f&&!g)return S.call(this,a[0],a[1],b,e);if(1<c)if(f){var m=a[0];n=1}else 9<h&&3<h/k&&a.sort(aa);for(let r,t;n<c;n++){t=a[n];m?(r=T(this,t,m),r=ra(r,d,g,this.K,b,e,2===c),g&&!1===r&&d.length||(m=t)):(r=T(this,t),r=ra(r,d,g,this.resolution,b,e,1===c));if(r)return r;if(g&&n===c-1){f=d.length;if(!f){if(m){m="";n=-1;continue}return d}if(1===f)return R(d[0],b,e)}}a:{a=d;d=this.resolution;m=g;c=a.length;g=[];f=y();
|
||||
for(let r=0,t,p,l,w;r<d;r++)for(k=0;k<c;k++)if(l=a[k],r<l.length&&(t=l[r]))for(n=0;n<t.length;n++)p=t[n],(h=f[p])?f[p]++:(h=0,f[p]=1),w=g[h]||(g[h]=[]),w.push(p);if(a=g.length)if(m){d=[];for(let r=a-1,t=0,p,l;0<=r;r--)if(p=g[r],l=p.length,e>=l)e-=l;else{if(l+t>b||e)p=p.slice(e,b-t+e),l=p.length;d.push(p);t+=l;if(b===t)break}if(1<d.length){g=d;a=[];d=y();f=g.length;for(k=0;k<f;k++)for(m=g[k],h=m.length,n=0;n<h;n++)if(c=m[n],!d[c])if(d[c]=1,e)e--;else if(a.push(c),a.length===b)break;b=a}else b=d[0];
|
||||
g=b}else{if(a<c){d=[];break a}g=g[a-1];if(g.length>b||e)g=g.slice(e,b+e)}d=g}return d};function S(a,b,c,d){return(a=T(this,a,b))&&a.length?R(a,c,d):[]}function ra(a,b,c,d,e,f,g){let h=[];if(a){d=Math.min(a.length,d);for(let k=0,n=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&&(n+=m.length,n>=e)))break;if(h.length){if(g)return R(h,e,0);b.push(h);return}}return!c&&h}
|
||||
function T(a,b,c){let d;c&&(d=a.bidirectional&&b>c);a=c?(a=a.B.get(d?b:c))&&a.get(d?c:b):a.map.get(b);return a};N.prototype.remove=function(a,b){const c=this.h.size&&(this.fastupdate?this.h.get(a):this.h.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 U(this.map,a),this.depth&&U(this.B,a);b||this.h.delete(a)}return this};
|
||||
function U(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=U(d[1],b);f?c+=f:a.delete(e)}return c};function N(a,b){if(!this)return new N(a);if(a){var c=A(a)?a:a.preset;c&&(a=Object.assign({},oa[c],a))}else a={};c=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&&c.depth||0;this.bidirectional=!1!==c.bidirectional;this.fastupdate=!!a.fastupdate;this.score=a.score||null;this.map=new Map;this.B=new Map;this.h=b||(this.fastupdate?new Map:new Set);
|
||||
this.K=c.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,b){return this.add(a,b,!0)};v.contain=function(a){return this.h.has(a)};v.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 V(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=V(c[1]);e?b+=e:a.delete(d)}return b}v.cleanup=function(){if(!this.fastupdate)return this;V(this.map);this.depth&&V(this.B);return this};
|
||||
v.export=function(a,b,c,d,e,f){let g=!0;"undefined"===typeof f&&(g=new Promise(p=>{f=p}));let h,k;switch(e||(e=0)){case 0:h="reg";if(this.fastupdate){k=y();for(let p of this.h.keys())k[p]=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 c&&f&&f();return}na(a,b||this,c,h,d,e,k,f);return g};
|
||||
v.export=function(a,b,c,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 c&&f&&f();return}na(a,b||this,c,h,d,e,k,f);return g};
|
||||
v.import=function(a,b){if(b)switch(A(b)&&(b=JSON.parse(b)),a){case "cfg":this.F=!!b.opt;break;case "reg":this.fastupdate=!1;this.h=b;break;case "map":this.map=b;break;case "ctx":this.B=b}};pa(N.prototype);W.prototype.add=function(a,b,c){E(a)&&(b=a,a=F(b,this.key));if(b&&(a||0===a)){if(!c&&this.h.has(a))return this.update(a,b);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(b);d&&g.add(a,d,!1,!0)}else if(d=f.J,!d||d(b))f.constructor===String?f=[""+f]:A(f)&&(f=[f]),X(b,f,this.G,0,g,a,f[0],c)}if(this.store&&(!c||!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((c=g.J)&&!c(b))continue;
|
||||
let h;if("function"===typeof g){h=g(b);if(!h)continue;g=[g.L]}else if(A(g)||g.constructor===String){e[g]=b[g];continue}Y(b,e,g,0,g[0],h)}}this.store.set(a,e||b)}}return this};function Y(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++)Y(a,b,c,d,e);else b=b[e]||(b[e]=y()),e=c[++d],Y(a,b,c,d,e)}
|
||||
function X(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++)X(a,b,c,d,e,f,g,h);else g=b[++d],X(a,b,c,d,e,f,g,h)};W.prototype.search=function(a,b,c,d){c||(!b&&E(a)?(c=a,a=""):E(b)&&(c=b,b=0));let e=[];var f=[];let g,h,k,p,m;let r=0;if(c){c.constructor===Array&&(c={index:c});a=c.query||a;var t=c.pluck;h=c.merge;p=t||c.field||c.index;m=!1;g=this.store&&c.enrich;k=c.suggest;b=c.limit||b;var n=c.offset||0;b||(b=100);if(m){m.constructor!==Array&&(m=[m]);var l=[];for(let u=0,q;u<m.length;u++)if(q=m[u],q.field&&q.tag){var w=q.tag;if(w.constructor===Array)for(var B=0;B<w.length;B++)l.push(q.field,w[B]);else l.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++)l.push(D,z[B]);else l.push(D,z)}m=l;if(!a){d=[];if(l.length)for(f=0;f<l.length;f+=2)t=sa.call(this,l[f],l[f+1],b,n,g),e.push({field:l[f],tag:l[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(p)&&(p=[p])}p||(p=this.field);n=!d&&(this.worker||this.async)&&[];for(let u=0,q,C,D;u<p.length;u++){C=p[u];let z;A(C)||
|
||||
(z=C,C=z.field,a=z.query||a,b=z.limit||b,k=z.suggest||k);if(d)q=d[u];else if(l=z||c,w=this.index.get(C),m&&(l.enrich=!1),n){n[u]=w.searchAsync(a,b,l);l&&g&&(l.enrich=g);continue}else q=w.search(a,b,l),l&&g&&(l.enrich=g);D=q&&q.length;if(m&&D){l=[];w=0;for(let O=0,G,ua;O<m.length;O+=2){G=this.tag.get(m[O]);if(!G)if(k)continue;else return e;if(ua=(G=G&&G.get(m[O+1]))&&G.length)w++,l.push(G);else if(!k)return e}if(w){q=qa(q,l);D=q.length;if(!D&&!k)return e;w--}}if(D)f[r]=C,e.push(q),r++;else if(1===
|
||||
p.length)return e}if(n){const u=this;return Promise.all(n).then(function(q){return q.length?u.search(a,b,c,q):q})}if(!r)return e;if(t&&(!g||!this.store))return e[0];n=[];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,b):e};
|
||||
function va(a,b){const c=[],d=y();for(let e=0,f,g;e<a.length;e++){f=a[e];g=f.result;for(let h=0,k,p,m;h<g.length;h++)if(p=g[h],k=p.id,m=d[k])m.push(f.field);else{if(c.length===b)return c;p.field=d[k]=[f.field];c.push(p)}}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 X(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++)X(a,b,c,d,e,f,g,h);else g=b[++d],X(a,b,c,d,e,f,g,h)};W.prototype.search=function(a,b,c,d){c||(!b&&E(a)?(c=a,a=""):E(b)&&(c=b,b=0));let e=[];var f=[];let g,h,k,n,m;let r=0;if(c){c.constructor===Array&&(c={index:c});a=c.query||a;var t=c.pluck;h=c.merge;n=t||c.field||c.index;m=!1;g=this.store&&c.enrich;k=c.suggest;b=c.limit||b;var p=c.offset||0;b||(b=100);if(m){m.constructor!==Array&&(m=[m]);var l=[];for(let u=0,q;u<m.length;u++)if(q=m[u],q.field&&q.tag){var w=q.tag;if(w.constructor===Array)for(var B=0;B<w.length;B++)l.push(q.field,w[B]);else l.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++)l.push(D,z[B]);else l.push(D,z)}m=l;if(!a){d=[];if(l.length)for(f=0;f<l.length;f+=2)t=sa.call(this,l[f],l[f+1],b,p,g),e.push({field:l[f],tag:l[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,b=z.limit||b,k=z.suggest||k);if(d)q=d[u];else if(l=z||c,w=this.index.get(C),m&&(l.enrich=!1),p){p[u]=w.searchAsync(a,b,l);l&&g&&(l.enrich=g);continue}else q=w.search(a,b,l),l&&g&&(l.enrich=g);D=q&&q.length;if(m&&D){l=[];w=0;for(let O=0,G,ua;O<m.length;O+=2){G=this.tag.get(m[O]);if(!G)if(k)continue;else return e;if(ua=(G=G&&G.get(m[O+1]))&&G.length)w++,l.push(G);else if(!k)return e}if(w){q=qa(q,l);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,b,c,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,b):e};
|
||||
function va(a,b){const c=[],d=y();for(let e=0,f,g;e<a.length;e++){f=a[e];g=f.result;for(let h=0,k,n,m;h<g.length;h++)if(n=g[h],k=n.id,m=d[k])m.push(f.field);else{if(c.length===b)return c;n.field=d[k]=[f.field];c.push(n)}}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 W(a){if(!this)return new W(a);const b=a.document||a.doc||a;var c;this.C=[];this.field=[];this.G=[];this.key=(c=b.key||b.id)&&Z(c,this.G)||"id";this.h=(this.fastupdate=!!a.fastupdate)?new Map:new Set;this.A=(c=b.store||null)&&!0!==c&&[];this.store=c&&new Map;this.async=!1;c=new Map;let d=b.index||b.field||b;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,c.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=b.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=c}
|
||||
function Z(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]}v=W.prototype;v.append=function(a,b){return this.add(a,b,!0)};v.update=function(a,b){return this.remove(a).add(a,b)};v.remove=function(a){E(a)&&(a=F(a,this.key));for(const b of this.index.values())b.remove(a,!0);this.h.has(a)&&(this.store&&this.store.delete(a),this.h.delete(a));return this};
|
||||
|
83
dist/flexsearch.es5.debug.js
vendored
83
dist/flexsearch.es5.debug.js
vendored
@@ -41,7 +41,7 @@ function ca(a) {
|
||||
throw Error("Cannot find global object");
|
||||
}
|
||||
var z = ca(this);
|
||||
function C(a, b) {
|
||||
function B(a, b) {
|
||||
if (b) {
|
||||
a: {
|
||||
var c = z;
|
||||
@@ -207,7 +207,7 @@ function ra(a) {
|
||||
function sa(a) {
|
||||
return ra(new pa(new ma(a)));
|
||||
}
|
||||
C("Symbol", function(a) {
|
||||
B("Symbol", function(a) {
|
||||
function b(g) {
|
||||
if (this instanceof b) {
|
||||
throw new TypeError("Symbol is not a constructor");
|
||||
@@ -227,7 +227,7 @@ C("Symbol", function(a) {
|
||||
var d = "jscomp_symbol_" + (1E9 * Math.random() >>> 0) + "_", e = 0;
|
||||
return b;
|
||||
});
|
||||
C("Symbol.iterator", function(a) {
|
||||
B("Symbol.iterator", function(a) {
|
||||
if (a) {
|
||||
return a;
|
||||
}
|
||||
@@ -247,7 +247,7 @@ function ta(a) {
|
||||
};
|
||||
return a;
|
||||
}
|
||||
C("Promise", function(a) {
|
||||
B("Promise", function(a) {
|
||||
function b(f) {
|
||||
this.A = 0;
|
||||
this.C = void 0;
|
||||
@@ -489,7 +489,7 @@ function ua(a, b) {
|
||||
};
|
||||
return e;
|
||||
}
|
||||
C("Array.prototype.values", function(a) {
|
||||
B("Array.prototype.values", function(a) {
|
||||
return a ? a : function() {
|
||||
return ua(this, function(b, c) {
|
||||
return c;
|
||||
@@ -499,7 +499,7 @@ C("Array.prototype.values", function(a) {
|
||||
function H(a, b) {
|
||||
return Object.prototype.hasOwnProperty.call(a, b);
|
||||
}
|
||||
C("WeakMap", function(a) {
|
||||
B("WeakMap", function(a) {
|
||||
function b(k) {
|
||||
this.h = (h += Math.random() + 1).toString();
|
||||
if (k) {
|
||||
@@ -576,7 +576,7 @@ C("WeakMap", function(a) {
|
||||
};
|
||||
return b;
|
||||
});
|
||||
C("Map", function(a) {
|
||||
B("Map", function(a) {
|
||||
function b() {
|
||||
var h = {};
|
||||
return h.K = h.next = h.head = h;
|
||||
@@ -689,14 +689,14 @@ C("Map", function(a) {
|
||||
var f = 0;
|
||||
return e;
|
||||
});
|
||||
C("Array.prototype.keys", function(a) {
|
||||
B("Array.prototype.keys", function(a) {
|
||||
return a ? a : function() {
|
||||
return ua(this, function(b) {
|
||||
return b;
|
||||
});
|
||||
};
|
||||
});
|
||||
C("Set", function(a) {
|
||||
B("Set", function(a) {
|
||||
function b(c) {
|
||||
this.h = new Map();
|
||||
if (c) {
|
||||
@@ -762,12 +762,12 @@ C("Set", function(a) {
|
||||
};
|
||||
return b;
|
||||
});
|
||||
C("Object.is", function(a) {
|
||||
B("Object.is", function(a) {
|
||||
return a ? a : function(b, c) {
|
||||
return b === c ? 0 !== b || 1 / b === 1 / c : b !== b && c !== c;
|
||||
};
|
||||
});
|
||||
C("Array.prototype.includes", function(a) {
|
||||
B("Array.prototype.includes", function(a) {
|
||||
return a ? a : function(b, c) {
|
||||
var d = this;
|
||||
d instanceof String && (d = String(d));
|
||||
@@ -782,7 +782,7 @@ C("Array.prototype.includes", function(a) {
|
||||
return !1;
|
||||
};
|
||||
});
|
||||
C("String.prototype.includes", function(a) {
|
||||
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");
|
||||
@@ -793,7 +793,7 @@ C("String.prototype.includes", function(a) {
|
||||
return -1 !== this.indexOf(b, c || 0);
|
||||
};
|
||||
});
|
||||
C("Array.prototype.entries", function(a) {
|
||||
B("Array.prototype.entries", function(a) {
|
||||
return a ? a : function() {
|
||||
return ua(this, function(b, c) {
|
||||
return [b, c];
|
||||
@@ -811,10 +811,10 @@ var va = "function" == typeof Object.assign ? Object.assign : function(a, b) {
|
||||
}
|
||||
return a;
|
||||
};
|
||||
C("Object.assign", function(a) {
|
||||
B("Object.assign", function(a) {
|
||||
return a || va;
|
||||
});
|
||||
C("Array.prototype.flat", function(a) {
|
||||
B("Array.prototype.flat", function(a) {
|
||||
return a ? a : function(b) {
|
||||
b = void 0 === b ? 1 : b;
|
||||
var c = [];
|
||||
@@ -1883,7 +1883,28 @@ function ib(a, b, c, d, e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
f = 1 < e.length ? [].concat.apply([], e) : e[0];
|
||||
if (1 < e.length) {
|
||||
f = [];
|
||||
g = 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], !g[b]) {
|
||||
if (g[b] = 1, d) {
|
||||
d--;
|
||||
} else {
|
||||
if (f.push(b), f.length === c) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
c = f;
|
||||
} else {
|
||||
c = e[0];
|
||||
}
|
||||
f = c;
|
||||
} else {
|
||||
if (a < g) {
|
||||
return [];
|
||||
@@ -1975,7 +1996,7 @@ V.prototype.search = function(a, b, c) {
|
||||
}
|
||||
var v = this;
|
||||
return function() {
|
||||
var A, D, B;
|
||||
var A, D, C;
|
||||
return sa(function(E) {
|
||||
switch(E.h) {
|
||||
case 1:
|
||||
@@ -1999,8 +2020,8 @@ V.prototype.search = function(a, b, c) {
|
||||
return E.return(A);
|
||||
}
|
||||
if (h && u === m - 1) {
|
||||
B = d.length;
|
||||
if (!B) {
|
||||
C = d.length;
|
||||
if (!C) {
|
||||
if (t) {
|
||||
t = "";
|
||||
u = -1;
|
||||
@@ -2009,7 +2030,7 @@ V.prototype.search = function(a, b, c) {
|
||||
}
|
||||
return E.return(d);
|
||||
}
|
||||
if (1 === B) {
|
||||
if (1 === C) {
|
||||
return E.return(g ? W(d[0], b, e) : new X(d[0]));
|
||||
}
|
||||
}
|
||||
@@ -2513,8 +2534,8 @@ function tb(a, b, c, d, e, g, f, h) {
|
||||
v = 0;
|
||||
for (var A = void 0, D = void 0; v < t.length; v++) {
|
||||
if (A = t[v], D = u[A], D.constructor === Array) {
|
||||
for (var B = 0; B < D.length; B++) {
|
||||
r.push(A, D[B]);
|
||||
for (var C = 0; C < D.length; C++) {
|
||||
r.push(A, D[C]);
|
||||
}
|
||||
} else {
|
||||
r.push(A, D);
|
||||
@@ -2588,8 +2609,8 @@ function tb(a, b, c, d, e, g, f, h) {
|
||||
D = 0;
|
||||
if (this.db && d) {
|
||||
if (!E) {
|
||||
for (B = l.length; B < d.length; B++) {
|
||||
var J = d[B];
|
||||
for (C = l.length; C < d.length; C++) {
|
||||
var J = d[C];
|
||||
if (J && J.length) {
|
||||
D++, A.push(J);
|
||||
} else if (!p) {
|
||||
@@ -2598,17 +2619,17 @@ function tb(a, b, c, d, e, g, f, h) {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
B = 0;
|
||||
for (var Gb = J = void 0; B < m.length; B += 2) {
|
||||
J = this.tag.get(m[B]);
|
||||
C = 0;
|
||||
for (var Gb = J = void 0; C < m.length; C += 2) {
|
||||
J = this.tag.get(m[C]);
|
||||
if (!J) {
|
||||
if (console.warn("Tag '" + m[B] + ":" + m[B + 1] + "' will be skipped because there is no field '" + m[B] + "'."), p) {
|
||||
if (console.warn("Tag '" + m[C] + ":" + m[C + 1] + "' will be skipped because there is no field '" + m[C] + "'."), p) {
|
||||
continue;
|
||||
} else {
|
||||
return e;
|
||||
}
|
||||
}
|
||||
if (Gb = (J = J && J.get(m[B + 1])) && J.length) {
|
||||
if (Gb = (J = J && J.get(m[C + 1])) && J.length) {
|
||||
D++, A.push(J);
|
||||
} else if (!p) {
|
||||
return e;
|
||||
@@ -3172,8 +3193,8 @@ w.commit = function(a, b, c) {
|
||||
for (var v = Math.max(u.length, r.T.length), A = 0, D; A < v; A++) {
|
||||
if ((D = r.T[A]) && D.length) {
|
||||
if ((t = u[A]) && t.length) {
|
||||
for (var B = 0; B < D.length; B++) {
|
||||
t.push(D[B]);
|
||||
for (var C = 0; C < D.length; C++) {
|
||||
t.push(D[C]);
|
||||
}
|
||||
} else {
|
||||
u[A] = D;
|
||||
|
4
dist/flexsearch.es5.min.js
vendored
4
dist/flexsearch.es5.min.js
vendored
@@ -70,8 +70,8 @@ function eb(a,b,c,d,e){if(2>a.length)return[];var g=[],f=0,h=K(),k=za(a);if(!k)r
|
||||
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){e=[];g=a-1;for(a=0;0<=g;g--)if(b=f[g],k=b.length,d>=k)d-=k;else{if(k+a>c||d)b=b.slice(d,c-a+d),k=b.length;e.push(b);a+=k;if(c===a)break}f=1<e.length?[].concat.apply([],e):e[0]}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;
|
||||
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){e=[];g=a-1;for(a=0;0<=g;g--)if(b=f[g],k=b.length,d>=k)d-=k;else{if(k+a>c||d)b=b.slice(d,c-a+d),k=b.length;e.push(b);a+=k;if(c===a)break}if(1<e.length){f=[];g=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],!g[b])if(g[b]=1,d)d--;
|
||||
else if(f.push(b),f.length===c)break;c=f}else c=e[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=
|
||||
|
283
dist/flexsearch.light.debug.js
vendored
283
dist/flexsearch.light.debug.js
vendored
@@ -43,19 +43,22 @@ function t(a, c, b) {
|
||||
}
|
||||
return "undefined" === e ? c : a;
|
||||
}
|
||||
function u(a, c) {
|
||||
function u() {
|
||||
return Object.create(null);
|
||||
}
|
||||
function v(a, c) {
|
||||
return c.length - a.length;
|
||||
}
|
||||
;const v = /[^\p{L}\p{N}]+/u, w = /(\d{3})/g, x = /(\D)(\d{3})/g, y = /(\d{3})(\D)/g, A = "".normalize && /[\u0300-\u036f]/g;
|
||||
function B(a) {
|
||||
;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 B(...arguments);
|
||||
return new C(...arguments);
|
||||
}
|
||||
for (let c = 0; c < arguments.length; c++) {
|
||||
this.assign(arguments[c]);
|
||||
}
|
||||
}
|
||||
B.prototype.assign = function(a) {
|
||||
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) {
|
||||
@@ -72,7 +75,7 @@ B.prototype.assign = function(a) {
|
||||
this.split = new RegExp("[" + (c ? "^" : "") + e + "]+", "u");
|
||||
this.numeric = d;
|
||||
} else {
|
||||
this.split = t(b, v, this.split), this.numeric = t(this.numeric, !0);
|
||||
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);
|
||||
@@ -104,19 +107,19 @@ B.prototype.assign = function(a) {
|
||||
}
|
||||
return this;
|
||||
};
|
||||
B.prototype.encode = function(a) {
|
||||
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(C, 0, this);
|
||||
this.m = setTimeout(D, 0, this);
|
||||
}
|
||||
}
|
||||
this.normalize && (a = "function" === typeof this.normalize ? this.normalize(a) : A ? a.normalize("NFKD").replace(A, "").toLowerCase() : a.toLowerCase());
|
||||
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(x, "$1 $2").replace(y, "$1 $2").replace(w, "$1 "));
|
||||
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++) {
|
||||
@@ -141,17 +144,17 @@ B.prototype.encode = function(a) {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
this.m = setTimeout(C, 0, this);
|
||||
this.m = setTimeout(D, 0, this);
|
||||
}
|
||||
}
|
||||
let l;
|
||||
this.stemmer && 2 < f.length && (this.A || (this.A = new RegExp("(?!^)(" + this.u + ")$")), f = f.replace(this.A, r => this.stemmer.get(r)), l = 1);
|
||||
this.matcher && 1 < f.length && (this.v || (this.v = new RegExp("(" + this.s + ")", "g")), f = f.replace(this.v, r => this.matcher.get(r)), l = 1);
|
||||
f && l && (f.length < this.minlength || this.filter && this.filter.has(f)) && (f = "");
|
||||
let k;
|
||||
this.stemmer && 2 < f.length && (this.A || (this.A = new RegExp("(?!^)(" + this.u + ")$")), f = f.replace(this.A, p => this.stemmer.get(p)), k = 1);
|
||||
this.matcher && 1 < f.length && (this.v || (this.v = new RegExp("(" + this.s + ")", "g")), f = f.replace(this.v, p => this.matcher.get(p)), 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 r = 0, p = "", n, q; r < f.length; r++) {
|
||||
n = f.charAt(r), n === p && this.dedupe || ((q = this.mapper && this.mapper.get(n)) || "" === q ? q === p && this.dedupe || !(p = q) || (e += q) : e += p = n);
|
||||
for (let p = 0, m = "", q, r; p < f.length; p++) {
|
||||
q = f.charAt(p), q === m && this.dedupe || ((r = this.mapper && this.mapper.get(q)) || "" === r ? r === m && this.dedupe || !(m = r) || (e += r) : e += m = q);
|
||||
}
|
||||
f = e;
|
||||
}
|
||||
@@ -167,61 +170,61 @@ B.prototype.encode = function(a) {
|
||||
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 C(a) {
|
||||
function D(a) {
|
||||
a.m = null;
|
||||
a.i.clear();
|
||||
a.j.clear();
|
||||
}
|
||||
;function D(a) {
|
||||
;function E(a) {
|
||||
this.limit = a && !0 !== a ? a : 1000;
|
||||
this.cache = new Map();
|
||||
this.h = "";
|
||||
}
|
||||
D.prototype.set = function(a, c) {
|
||||
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);
|
||||
};
|
||||
D.prototype.get = function(a) {
|
||||
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;
|
||||
};
|
||||
D.prototype.remove = function(a) {
|
||||
E.prototype.remove = function(a) {
|
||||
for (const c of this.cache) {
|
||||
const b = c[0];
|
||||
c[1].includes(a) && this.cache.delete(b);
|
||||
}
|
||||
};
|
||||
D.prototype.clear = function() {
|
||||
E.prototype.clear = function() {
|
||||
this.cache.clear();
|
||||
this.h = "";
|
||||
};
|
||||
const E = {normalize:function(a) {
|
||||
const F = {normalize:function(a) {
|
||||
return a.toLowerCase();
|
||||
}, dedupe:!1};
|
||||
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}}};
|
||||
Object.create(null);
|
||||
G.prototype.add = function(a, c, b, d) {
|
||||
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 r = Object.create(null), p = Object.create(null), n = this.depth, q = this.resolution;
|
||||
for (let k = 0; k < d; k++) {
|
||||
let m = c[this.rtl ? d - 1 - k : k];
|
||||
var e = m.length;
|
||||
if (e && (n || !p[m])) {
|
||||
var g = this.score ? this.score(c, m, k, null, 0) : H(q, d, k), f = "";
|
||||
const p = u(), m = u(), 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 g = this.score ? this.score(c, n, l, null, 0) : I(r, d, l), f = "";
|
||||
switch(this.tokenize) {
|
||||
case "full":
|
||||
if (2 < e) {
|
||||
for (g = 0; g < e; g++) {
|
||||
for (var h = e; h > g; h--) {
|
||||
f = m.substring(g, h);
|
||||
var l = this.score ? this.score(c, m, k, f, g) : H(q, d, k, e, g);
|
||||
I(this, p, f, l, a, b);
|
||||
f = n.substring(g, h);
|
||||
var k = this.score ? this.score(c, n, l, f, g) : I(r, d, l, e, g);
|
||||
J(this, m, f, k, a, b);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -229,24 +232,24 @@ G.prototype.add = function(a, c, b, d) {
|
||||
case "reverse":
|
||||
if (1 < e) {
|
||||
for (h = e - 1; 0 < h; h--) {
|
||||
f = m[h] + f, l = this.score ? this.score(c, m, k, f, h) : H(q, d, k, e, h), I(this, p, f, l, a, b);
|
||||
f = n[h] + f, k = this.score ? this.score(c, n, l, f, h) : I(r, d, l, e, h), J(this, m, f, k, a, b);
|
||||
}
|
||||
f = "";
|
||||
}
|
||||
case "forward":
|
||||
if (1 < e) {
|
||||
for (h = 0; h < e; h++) {
|
||||
f += m[h], I(this, p, f, g, a, b);
|
||||
f += n[h], J(this, m, f, g, a, b);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
if (I(this, p, m, g, a, b), n && 1 < d && k < d - 1) {
|
||||
for (e = Object.create(null), f = this.C, g = m, h = Math.min(n + 1, d - k), e[g] = 1, l = 1; l < h; l++) {
|
||||
if ((m = c[this.rtl ? d - 1 - k - l : k + l]) && !e[m]) {
|
||||
e[m] = 1;
|
||||
const z = this.score ? this.score(c, g, k, m, l) : H(f + (d / 2 > f ? 0 : 1), d, k, h - 1, l - 1), L = this.bidirectional && m > g;
|
||||
I(this, r, L ? g : m, z, a, b, L ? m : g);
|
||||
if (J(this, m, n, g, a, b), q && 1 < d && l < d - 1) {
|
||||
for (e = u(), f = this.C, g = n, h = Math.min(q + 1, d - l), e[g] = 1, k = 1; k < h; k++) {
|
||||
if ((n = c[this.rtl ? d - 1 - l - k : l + k]) && !e[n]) {
|
||||
e[n] = 1;
|
||||
const A = this.score ? this.score(c, g, l, n, k) : I(f + (d / 2 > f ? 0 : 1), d, l, h - 1, k - 1), M = this.bidirectional && n > g;
|
||||
J(this, p, M ? g : n, A, a, b, M ? n : g);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -258,14 +261,14 @@ G.prototype.add = function(a, c, b, d) {
|
||||
}
|
||||
return this;
|
||||
};
|
||||
function I(a, c, b, d, e, g, f) {
|
||||
let h = f ? a.l : a.map, l;
|
||||
c[b] && f && (l = c[b])[f] || (f ? (c = l || (c[b] = Object.create(null)), c[f] = 1, (l = h.get(f)) ? h = l : h.set(f, h = new Map())) : c[b] = 1, (l = h.get(b)) ? h = l : 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 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 H(a, c, b, d, e) {
|
||||
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 J(a, c, b) {
|
||||
;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;
|
||||
}
|
||||
@@ -295,7 +298,7 @@ function H(a, c, b, d, e) {
|
||||
}
|
||||
return d.length ? d = 1 < d.length ? [].concat.apply([], d) : d[0] : d;
|
||||
}
|
||||
;G.prototype.search = function(a, c, b) {
|
||||
;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) {
|
||||
@@ -309,104 +312,126 @@ function H(a, c, b, d, e) {
|
||||
b = a.length;
|
||||
c || (c = 100);
|
||||
if (1 === b) {
|
||||
return K.call(this, a[0], "", c, e);
|
||||
return L.call(this, a[0], "", c, e);
|
||||
}
|
||||
g = this.depth && !1 !== g;
|
||||
if (2 === b && g && !f) {
|
||||
return K.call(this, a[0], a[1], c, e);
|
||||
return L.call(this, a[0], a[1], c, e);
|
||||
}
|
||||
var h = 0, l = 0;
|
||||
var h = 0, k = 0;
|
||||
if (1 < b) {
|
||||
var r = Object.create(null);
|
||||
const n = [];
|
||||
for (let q = 0, k; q < b; q++) {
|
||||
if ((k = a[q]) && !r[k]) {
|
||||
if (f || M(this, k)) {
|
||||
n.push(k), r[k] = 1;
|
||||
var p = u();
|
||||
const q = [];
|
||||
for (let r = 0, l; r < b; r++) {
|
||||
if ((l = a[r]) && !p[l]) {
|
||||
if (f || N(this, l)) {
|
||||
q.push(l), p[l] = 1;
|
||||
} else {
|
||||
return d;
|
||||
}
|
||||
const m = k.length;
|
||||
h = Math.max(h, m);
|
||||
l = l ? Math.min(l, m) : m;
|
||||
const n = l.length;
|
||||
h = Math.max(h, n);
|
||||
k = k ? Math.min(k, n) : n;
|
||||
}
|
||||
}
|
||||
a = n;
|
||||
a = q;
|
||||
b = a.length;
|
||||
}
|
||||
if (!b) {
|
||||
return d;
|
||||
}
|
||||
r = 0;
|
||||
p = 0;
|
||||
if (1 === b) {
|
||||
return K.call(this, a[0], "", c, e);
|
||||
return L.call(this, a[0], "", c, e);
|
||||
}
|
||||
if (2 === b && g && !f) {
|
||||
return K.call(this, a[0], a[1], c, e);
|
||||
return L.call(this, a[0], a[1], c, e);
|
||||
}
|
||||
if (1 < b) {
|
||||
if (g) {
|
||||
var p = a[0];
|
||||
r = 1;
|
||||
var m = a[0];
|
||||
p = 1;
|
||||
} else {
|
||||
9 < h && 3 < h / l && a.sort(u);
|
||||
9 < h && 3 < h / k && a.sort(v);
|
||||
}
|
||||
}
|
||||
for (let n, q; r < b; r++) {
|
||||
q = a[r];
|
||||
p ? (n = M(this, q, p), n = N(n, d, f, this.C, c, e, 2 === b), f && !1 === n && d.length || (p = q)) : (n = M(this, q), n = N(n, d, f, this.resolution, c, e, 1 === b));
|
||||
if (n) {
|
||||
return n;
|
||||
for (let q, r; p < b; p++) {
|
||||
r = a[p];
|
||||
m ? (q = N(this, r, m), q = O(q, d, f, this.C, c, e, 2 === b), f && !1 === q && d.length || (m = r)) : (q = N(this, r), q = O(q, d, f, this.resolution, c, e, 1 === b));
|
||||
if (q) {
|
||||
return q;
|
||||
}
|
||||
if (f && r === b - 1) {
|
||||
if (f && p === b - 1) {
|
||||
g = d.length;
|
||||
if (!g) {
|
||||
if (p) {
|
||||
p = "";
|
||||
r = -1;
|
||||
if (m) {
|
||||
m = "";
|
||||
p = -1;
|
||||
continue;
|
||||
}
|
||||
return d;
|
||||
}
|
||||
if (1 === g) {
|
||||
return J(d[0], c, e);
|
||||
return K(d[0], c, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
a: {
|
||||
a = d;
|
||||
d = this.resolution;
|
||||
p = f;
|
||||
m = f;
|
||||
b = a.length;
|
||||
f = [];
|
||||
g = Object.create(null);
|
||||
for (let n = 0, q, k, m, z; n < d; n++) {
|
||||
for (l = 0; l < b; l++) {
|
||||
if (m = a[l], n < m.length && (q = m[n])) {
|
||||
for (r = 0; r < q.length; r++) {
|
||||
k = q[r], (h = g[k]) ? g[k]++ : (h = 0, g[k] = 1), z = f[h] || (f[h] = []), z.push(k);
|
||||
g = u();
|
||||
for (let q = 0, r, l, n, A; q < d; q++) {
|
||||
for (k = 0; k < b; k++) {
|
||||
if (n = a[k], q < n.length && (r = n[q])) {
|
||||
for (p = 0; p < r.length; p++) {
|
||||
l = r[p], (h = g[l]) ? g[l]++ : (h = 0, g[l] = 1), A = f[h] || (f[h] = []), A.push(l);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (a = f.length) {
|
||||
if (p) {
|
||||
if (m) {
|
||||
d = [];
|
||||
for (let n = a - 1, q = 0, k, m; 0 <= n; n--) {
|
||||
if (k = f[n], m = k.length, e >= m) {
|
||||
e -= m;
|
||||
for (let q = a - 1, r = 0, l, n; 0 <= q; q--) {
|
||||
if (l = f[q], n = l.length, e >= n) {
|
||||
e -= n;
|
||||
} else {
|
||||
if (m + q > c || e) {
|
||||
k = k.slice(e, c - q + e), m = k.length;
|
||||
if (n + r > c || e) {
|
||||
l = l.slice(e, c - r + e), n = l.length;
|
||||
}
|
||||
d.push(k);
|
||||
q += m;
|
||||
if (c === q) {
|
||||
d.push(l);
|
||||
r += n;
|
||||
if (c === r) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
f = 1 < d.length ? [].concat.apply([], d) : d[0];
|
||||
if (1 < d.length) {
|
||||
f = d;
|
||||
a = [];
|
||||
d = u();
|
||||
g = f.length;
|
||||
for (k = 0; k < g; k++) {
|
||||
for (m = f[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 = d[0];
|
||||
}
|
||||
f = c;
|
||||
} else {
|
||||
if (a < b) {
|
||||
d = [];
|
||||
@@ -422,23 +447,23 @@ function H(a, c, b, d, e) {
|
||||
}
|
||||
return d;
|
||||
};
|
||||
function K(a, c, b, d) {
|
||||
return (a = M(this, a, c)) && a.length ? J(a, b, d) : [];
|
||||
function L(a, c, b, d) {
|
||||
return (a = N(this, a, c)) && a.length ? K(a, b, d) : [];
|
||||
}
|
||||
function N(a, c, b, d, e, g, f) {
|
||||
function O(a, c, b, d, e, g, f) {
|
||||
let h = [];
|
||||
if (a) {
|
||||
d = Math.min(a.length, d);
|
||||
for (let l = 0, r = 0, p; l < d; l++) {
|
||||
if (p = a[l]) {
|
||||
if (g && p && f && (p.length <= g ? (g -= p.length, p = null) : (p = p.slice(g), g = 0)), p && (h[l] = p, f && (r += p.length, r >= e))) {
|
||||
for (let k = 0, p = 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 && (p += m.length, p >= e))) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (h.length) {
|
||||
if (f) {
|
||||
return J(h, e, 0);
|
||||
return K(h, e, 0);
|
||||
}
|
||||
c.push(h);
|
||||
return;
|
||||
@@ -446,13 +471,13 @@ function N(a, c, b, d, e, g, f) {
|
||||
}
|
||||
return !b && h;
|
||||
}
|
||||
function M(a, c, b) {
|
||||
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;
|
||||
}
|
||||
;G.prototype.remove = function(a, c) {
|
||||
;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) {
|
||||
@@ -467,14 +492,14 @@ function M(a, c, b) {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
O(this.map, a), this.depth && O(this.l, a);
|
||||
P(this.map, a), this.depth && P(this.l, a);
|
||||
}
|
||||
c || this.g.delete(a);
|
||||
}
|
||||
this.cache && this.cache.remove(a);
|
||||
return this;
|
||||
};
|
||||
function O(a, c) {
|
||||
function P(a, c) {
|
||||
let b = 0;
|
||||
if (a.constructor === Array) {
|
||||
for (let d = 0, e, g; d < a.length; d++) {
|
||||
@@ -489,25 +514,25 @@ function O(a, c) {
|
||||
}
|
||||
} else {
|
||||
for (let d of a) {
|
||||
const e = d[0], g = O(d[1], c);
|
||||
const e = d[0], g = P(d[1], c);
|
||||
g ? b += g : a.delete(e);
|
||||
}
|
||||
}
|
||||
return b;
|
||||
}
|
||||
;function G(a, c) {
|
||||
;function H(a, c) {
|
||||
if (!this) {
|
||||
return new G(a);
|
||||
return new H(a);
|
||||
}
|
||||
if (a) {
|
||||
var b = "string" === typeof a ? a : a.preset;
|
||||
b && (F[b] || console.warn("Preset not found: " + b), a = Object.assign({}, F[b], a));
|
||||
b && (G[b] || console.warn("Preset not found: " + b), a = Object.assign({}, G[b], a));
|
||||
} else {
|
||||
a = {};
|
||||
}
|
||||
b = a.context || {};
|
||||
const d = a.encode || a.encoder || E;
|
||||
this.encoder = d.encode ? d : "object" === typeof d ? new B(d) : {encode:d};
|
||||
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";
|
||||
@@ -521,29 +546,29 @@ function O(a, c) {
|
||||
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 D(e);
|
||||
this.cache = (e = a.cache || null) && new E(e);
|
||||
}
|
||||
G.prototype.clear = function() {
|
||||
H.prototype.clear = function() {
|
||||
this.map.clear();
|
||||
this.l.clear();
|
||||
this.g.clear();
|
||||
this.cache && this.cache.clear();
|
||||
return this;
|
||||
};
|
||||
G.prototype.append = function(a, c) {
|
||||
H.prototype.append = function(a, c) {
|
||||
return this.add(a, c, !0);
|
||||
};
|
||||
G.prototype.contain = function(a) {
|
||||
H.prototype.contain = function(a) {
|
||||
return this.g.has(a);
|
||||
};
|
||||
G.prototype.update = function(a, c) {
|
||||
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 P(a) {
|
||||
function Q(a) {
|
||||
let c = 0;
|
||||
if (a.constructor === Array) {
|
||||
for (let b = 0, d; b < a.length; b++) {
|
||||
@@ -551,21 +576,21 @@ function P(a) {
|
||||
}
|
||||
} else {
|
||||
for (const b of a) {
|
||||
const d = b[0], e = P(b[1]);
|
||||
const d = b[0], e = Q(b[1]);
|
||||
e ? c += e : a.delete(d);
|
||||
}
|
||||
}
|
||||
return c;
|
||||
}
|
||||
G.prototype.cleanup = function() {
|
||||
H.prototype.cleanup = function() {
|
||||
if (!this.fastupdate) {
|
||||
return console.info('Cleanup the index isn\'t required when not using "fastupdate".'), this;
|
||||
}
|
||||
P(this.map);
|
||||
this.depth && P(this.l);
|
||||
Q(this.map);
|
||||
this.depth && Q(this.l);
|
||||
return this;
|
||||
};
|
||||
G.prototype.searchCache = function(a, c, b) {
|
||||
H.prototype.searchCache = function(a, c, b) {
|
||||
a = ("object" === typeof a ? "" + a.query : a).toLowerCase();
|
||||
let d = this.cache.get(a);
|
||||
if (!d) {
|
||||
@@ -581,9 +606,9 @@ G.prototype.searchCache = function(a, c, b) {
|
||||
}
|
||||
return d;
|
||||
};
|
||||
const Q = {Index:G, Charset:null, Encoder:B, Document:null, Worker:null, Resolver:null, IndexedDB:null, Language:{}}, R = self;
|
||||
let S;
|
||||
(S = R.define) && S.amd ? S([], function() {
|
||||
return Q;
|
||||
}) : "object" === typeof R.exports ? R.exports = Q : R.FlexSearch = Q;
|
||||
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));
|
||||
|
33
dist/flexsearch.light.min.js
vendored
33
dist/flexsearch.light.min.js
vendored
@@ -5,21 +5,22 @@
|
||||
* Hosted by Nextapps GmbH
|
||||
* https://github.com/nextapps-de/flexsearch
|
||||
*/
|
||||
(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(a,c){return c.length-a.length};const v=/[^\p{L}\p{N}]+/u,w=/(\d{3})/g,x=/(\D)(\d{3})/g,y=/(\d{3})(\D)/g,A="".normalize&&/[\u0300-\u036f]/g;function B(a){if(!this)return new B(...arguments);for(let c=0;c<arguments.length;c++)this.assign(arguments[c])}
|
||||
B.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,v,this.split),this.numeric=t(this.numeric,!0);this.prepare=
|
||||
(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};
|
||||
B.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(C,0,this);this.normalize&&(a="function"===typeof this.normalize?this.normalize(a):A?a.normalize("NFKD").replace(A,"").toLowerCase():a.toLowerCase());this.prepare&&(a=this.prepare(a));this.numeric&&3<a.length&&(a=a.replace(x,"$1 $2").replace(y,"$1 $2").replace(w,"$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(C,0,this);let l;this.stemmer&&2<f.length&&(this.A||(this.A=new RegExp("(?!^)("+this.u+")$")),f=f.replace(this.A,r=>this.stemmer.get(r)),l=1);this.matcher&&1<f.length&&
|
||||
(this.v||(this.v=new RegExp("("+this.s+")","g")),f=f.replace(this.v,r=>this.matcher.get(r)),l=1);f&&l&&(f.length<this.minlength||this.filter&&this.filter.has(f))&&(f="");if(f&&(this.mapper||this.dedupe&&1<f.length)){e="";for(let r=0,p="",n,q;r<f.length;r++)n=f.charAt(r),n===p&&this.dedupe||((q=this.mapper&&this.mapper.get(n))||""===q?q===p&&this.dedupe||!(p=q)||(e+=q):e+=p=n);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 C(a){a.m=null;a.i.clear();a.j.clear()};function D(a){this.limit=a&&!0!==a?a:1E3;this.cache=new Map;this.h=""}D.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)};D.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};D.prototype.remove=function(a){for(const c of this.cache){const b=c[0];c[1].includes(a)&&this.cache.delete(b)}};
|
||||
D.prototype.clear=function(){this.cache.clear();this.h=""};const E={normalize:function(a){return a.toLowerCase()},dedupe:!1};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}}};Object.create(null);G.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 r=Object.create(null),p=Object.create(null),n=this.depth,q=this.resolution;for(let k=0;k<d;k++){let m=c[this.rtl?d-1-k:k];var e=m.length;if(e&&(n||!p[m])){var g=this.score?this.score(c,m,k,null,0):H(q,d,k),f="";switch(this.tokenize){case "full":if(2<e){for(g=0;g<e;g++)for(var h=e;h>g;h--){f=m.substring(g,h);var l=this.score?this.score(c,m,k,f,g):H(q,d,
|
||||
k,e,g);I(this,p,f,l,a,b)}break}case "reverse":if(1<e){for(h=e-1;0<h;h--)f=m[h]+f,l=this.score?this.score(c,m,k,f,h):H(q,d,k,e,h),I(this,p,f,l,a,b);f=""}case "forward":if(1<e){for(h=0;h<e;h++)f+=m[h],I(this,p,f,g,a,b);break}default:if(I(this,p,m,g,a,b),n&&1<d&&k<d-1)for(e=Object.create(null),f=this.C,g=m,h=Math.min(n+1,d-k),e[g]=1,l=1;l<h;l++)if((m=c[this.rtl?d-1-k-l:k+l])&&!e[m]){e[m]=1;const z=this.score?this.score(c,g,k,m,l):H(f+(d/2>f?0:1),d,k,h-1,l-1),K=this.bidirectional&&m>g;I(this,r,K?g:m,
|
||||
z,a,b,K?m:g)}}}}this.fastupdate||this.g.add(a)}}return this};function I(a,c,b,d,e,g,f){let h=f?a.l:a.map,l;c[b]&&f&&(l=c[b])[f]||(f?(c=l||(c[b]=Object.create(null)),c[f]=1,(l=h.get(f))?h=l:h.set(f,h=new Map)):c[b]=1,(l=h.get(b))?h=l: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 H(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 J(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};G.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 L.call(this,a[0],"",c,e);g=this.depth&&!1!==g;if(2===b&&g&&!f)return L.call(this,a[0],a[1],c,e);var h=0,l=0;if(1<b){var r=Object.create(null);const n=[];for(let q=0,k;q<b;q++)if((k=a[q])&&!r[k]){if(f||M(this,k))n.push(k),r[k]=1;else return d;
|
||||
const m=k.length;h=Math.max(h,m);l=l?Math.min(l,m):m}a=n;b=a.length}if(!b)return d;r=0;if(1===b)return L.call(this,a[0],"",c,e);if(2===b&&g&&!f)return L.call(this,a[0],a[1],c,e);if(1<b)if(g){var p=a[0];r=1}else 9<h&&3<h/l&&a.sort(u);for(let n,q;r<b;r++){q=a[r];p?(n=M(this,q,p),n=N(n,d,f,this.C,c,e,2===b),f&&!1===n&&d.length||(p=q)):(n=M(this,q),n=N(n,d,f,this.resolution,c,e,1===b));if(n)return n;if(f&&r===b-1){g=d.length;if(!g){if(p){p="";r=-1;continue}return d}if(1===g)return J(d[0],c,e)}}a:{a=d;
|
||||
d=this.resolution;p=f;b=a.length;f=[];g=Object.create(null);for(let n=0,q,k,m,z;n<d;n++)for(l=0;l<b;l++)if(m=a[l],n<m.length&&(q=m[n]))for(r=0;r<q.length;r++)k=q[r],(h=g[k])?g[k]++:(h=0,g[k]=1),z=f[h]||(f[h]=[]),z.push(k);if(a=f.length)if(p){d=[];for(let n=a-1,q=0,k,m;0<=n;n--)if(k=f[n],m=k.length,e>=m)e-=m;else{if(m+q>c||e)k=k.slice(e,c-q+e),m=k.length;d.push(k);q+=m;if(c===q)break}f=1<d.length?[].concat.apply([],d):d[0]}else{if(a<b){d=[];break a}f=f[a-1];if(f.length>c||e)f=f.slice(e,c+e)}d=f}return d};
|
||||
function L(a,c,b,d){return(a=M(this,a,c))&&a.length?J(a,b,d):[]}function N(a,c,b,d,e,g,f){let h=[];if(a){d=Math.min(a.length,d);for(let l=0,r=0,p;l<d;l++)if(p=a[l])if(g&&p&&f&&(p.length<=g?(g-=p.length,p=null):(p=p.slice(g),g=0)),p&&(h[l]=p,f&&(r+=p.length,r>=e)))break;if(h.length){if(f)return J(h,e,0);c.push(h);return}}return!b&&h}function M(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};G.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 O(this.map,a),this.depth&&O(this.l,a);c||this.g.delete(a)}this.cache&&this.cache.remove(a);return this};
|
||||
function O(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=O(d[1],c);g?b+=g:a.delete(e)}return b};function G(a,c){if(!this)return new G(a);if(a){var b="string"===typeof a?a:a.preset;b&&(a=Object.assign({},F[b],a))}else a={};b=a.context||{};const d=a.encode||a.encoder||E;this.encoder=d.encode?d:"object"===typeof d?new B(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 D(e)}G.prototype.clear=function(){this.map.clear();this.l.clear();this.g.clear();this.cache&&this.cache.clear();return this};G.prototype.append=function(a,c){return this.add(a,c,!0)};G.prototype.contain=function(a){return this.g.has(a)};G.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 P(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=P(b[1]);e?c+=e:a.delete(d)}return c}G.prototype.cleanup=function(){if(!this.fastupdate)return this;P(this.map);this.depth&&P(this.l);return this};
|
||||
G.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 Q={Index:G,Charset:null,Encoder:B,Document:null,Worker:null,Resolver:null,IndexedDB:null,Language:{}},R=self;let S;(S=R.define)&&S.amd?S([],function(){return Q}):"object"===typeof R.exports?R.exports=Q:R.FlexSearch=Q;}(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,p=>this.stemmer.get(p)),k=1);this.matcher&&1<f.length&&
|
||||
(this.v||(this.v=new RegExp("("+this.s+")","g")),f=f.replace(this.v,p=>this.matcher.get(p)),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 p=0,m="",q,r;p<f.length;p++)q=f.charAt(p),q===m&&this.dedupe||((r=this.mapper&&this.mapper.get(q))||""===r?r===m&&this.dedupe||!(m=r)||(e+=r):e+=m=q);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 p=u(),m=u(),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 g=this.score?this.score(c,n,l,null,0):I(r,d,l),f="";switch(this.tokenize){case "full":if(2<e){for(g=0;g<e;g++)for(var h=e;h>g;h--){f=n.substring(g,h);var k=this.score?this.score(c,n,l,f,g):I(r,d,l,e,g);J(this,m,f,k,a,b)}break}case "reverse":if(1<
|
||||
e){for(h=e-1;0<h;h--)f=n[h]+f,k=this.score?this.score(c,n,l,f,h):I(r,d,l,e,h),J(this,m,f,k,a,b);f=""}case "forward":if(1<e){for(h=0;h<e;h++)f+=n[h],J(this,m,f,g,a,b);break}default:if(J(this,m,n,g,a,b),q&&1<d&&l<d-1)for(e=u(),f=this.C,g=n,h=Math.min(q+1,d-l),e[g]=1,k=1;k<h;k++)if((n=c[this.rtl?d-1-l-k:l+k])&&!e[n]){e[n]=1;const A=this.score?this.score(c,g,l,n,k):I(f+(d/2>f?0:1),d,l,h-1,k-1),L=this.bidirectional&&n>g;J(this,p,L?g:n,A,a,b,L?n: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 p=u();const q=[];for(let r=0,l;r<b;r++)if((l=a[r])&&!p[l]){if(f||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&&g&&!f)return M.call(this,a[0],a[1],c,e);if(1<b)if(g){var m=a[0];p=1}else 9<h&&3<h/k&&a.sort(v);for(let q,r;p<b;p++){r=a[p];m?(q=N(this,r,m),q=O(q,d,f,this.C,c,e,2===b),f&&!1===q&&d.length||(m=r)):(q=N(this,r),q=O(q,d,f,this.resolution,c,e,1===b));if(q)return q;if(f&&p===b-1){g=d.length;if(!g){if(m){m="";p=-1;continue}return d}if(1===g)return K(d[0],c,e)}}a:{a=d;d=this.resolution;
|
||||
m=f;b=a.length;f=[];g=u();for(let q=0,r,l,n,A;q<d;q++)for(k=0;k<b;k++)if(n=a[k],q<n.length&&(r=n[q]))for(p=0;p<r.length;p++)l=r[p],(h=g[l])?g[l]++:(h=0,g[l]=1),A=f[h]||(f[h]=[]),A.push(l);if(a=f.length)if(m){d=[];for(let q=a-1,r=0,l,n;0<=q;q--)if(l=f[q],n=l.length,e>=n)e-=n;else{if(n+r>c||e)l=l.slice(e,c-r+e),n=l.length;d.push(l);r+=n;if(c===r)break}if(1<d.length){f=d;a=[];d=u();g=f.length;for(k=0;k<g;k++)for(m=f[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=d[0];f=c}else{if(a<b){d=[];break a}f=f[a-1];if(f.length>c||e)f=f.slice(e,c+e)}d=f}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,p=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&&(p+=m.length,p>=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};
|
||||
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));
|
||||
|
259
dist/flexsearch.light.module.debug.js
vendored
259
dist/flexsearch.light.module.debug.js
vendored
@@ -5,84 +5,87 @@
|
||||
* Hosted by Nextapps GmbH
|
||||
* https://github.com/nextapps-de/flexsearch
|
||||
*/
|
||||
function t(a, b) {
|
||||
function t() {
|
||||
return Object.create(null);
|
||||
}
|
||||
function u(a, b) {
|
||||
return b.length - a.length;
|
||||
}
|
||||
;function u(a) {
|
||||
;function v(a) {
|
||||
this.limit = a && !0 !== a ? a : 1000;
|
||||
this.cache = new Map();
|
||||
this.B = "";
|
||||
}
|
||||
u.prototype.set = function(a, b) {
|
||||
v.prototype.set = function(a, b) {
|
||||
this.cache.set(this.B = a, b);
|
||||
this.cache.size > this.limit && this.cache.delete(this.cache.keys().next().value);
|
||||
};
|
||||
u.prototype.get = function(a) {
|
||||
v.prototype.get = function(a) {
|
||||
const b = this.cache.get(a);
|
||||
b && this.B !== a && (this.cache.delete(a), this.cache.set(this.B = a, b));
|
||||
return b;
|
||||
};
|
||||
u.prototype.remove = function(a) {
|
||||
v.prototype.remove = function(a) {
|
||||
for (const b of this.cache) {
|
||||
const c = b[0];
|
||||
b[1].includes(a) && this.cache.delete(c);
|
||||
}
|
||||
};
|
||||
u.prototype.clear = function() {
|
||||
v.prototype.clear = function() {
|
||||
this.cache.clear();
|
||||
this.B = "";
|
||||
};
|
||||
const v = 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 w = new Map([["ai", "ei"], ["ae", "a"], ["oe", "o"], ["ue", "u"], ["sh", "s"], ["ch", "c"], ["th", "t"], ["ph", "f"], ["pf", "f"]]), y = [/([^aeo])h([aeo$])/g, "$1$2", /([aeo])h([^aeo]|$)/g, "$1$2"];
|
||||
const z = {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 A = /[\x00-\x7F]+/g;
|
||||
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;
|
||||
var D = {LatinExact:{normalize:!1, dedupe:!1}, LatinDefault:{normalize:function(a) {
|
||||
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:v}, LatinAdvanced:{normalize:!0, dedupe:!0, mapper:v, replacer:y, matcher:w}, LatinExtra:{normalize:!0, dedupe:!0, mapper:v, replacer:y.concat([/(?!^)[aeoy]/g, ""]), matcher:w}, LatinSoundex:{normalize:!0, dedupe:!1, include:{letter:!0}, finalize:function(a) {
|
||||
}, 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 c = 0; c < a.length; c++) {
|
||||
var b = a[c];
|
||||
let d = b.charAt(0), e = z[d];
|
||||
for (let f = 1, g; f < b.length && (g = b.charAt(f), "h" === g || "w" === g || !(g = z[g]) || g === e || (d += g, e = g, 4 !== d.length)); f++) {
|
||||
let d = b.charAt(0), e = A[d];
|
||||
for (let f = 1, g; f < b.length && (g = b.charAt(f), "h" === g || "w" === g || !(g = A[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(A, " ");
|
||||
return ("" + a).replace(B, " ");
|
||||
}}, CjkDefault:{normalize:!1, dedupe:!0, split:"", prepare:function(a) {
|
||||
return ("" + a).replace(B, "");
|
||||
return ("" + a).replace(C, "");
|
||||
}}, CyrillicDefault:{normalize:!1, dedupe:!0, prepare:function(a) {
|
||||
return ("" + a).replace(C, " ");
|
||||
return ("" + a).replace(D, " ");
|
||||
}}};
|
||||
const E = {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 F(a) {
|
||||
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 b = "string" === typeof a ? a : a.preset;
|
||||
b && (E[b] || console.warn("Preset not found: " + b), a = Object.assign({}, E[b], a));
|
||||
b && (F[b] || console.warn("Preset not found: " + b), a = Object.assign({}, F[b], a));
|
||||
return a;
|
||||
}
|
||||
;Object.create(null);
|
||||
G.prototype.add = function(a, b, c, d) {
|
||||
;t();
|
||||
H.prototype.add = function(a, b, c, d) {
|
||||
if (b && (a || 0 === a)) {
|
||||
if (!d && !c && this.h.has(a)) {
|
||||
return this.update(a, b);
|
||||
}
|
||||
b = this.encoder.encode(b);
|
||||
if (d = b.length) {
|
||||
const r = Object.create(null), p = Object.create(null), n = this.depth, q = this.resolution;
|
||||
const q = t(), n = t(), p = this.depth, r = this.resolution;
|
||||
for (let k = 0; k < d; k++) {
|
||||
let l = b[this.rtl ? d - 1 - k : k];
|
||||
var e = l.length;
|
||||
if (e && (n || !p[l])) {
|
||||
var f = this.score ? this.score(b, l, k, null, 0) : H(q, d, k), g = "";
|
||||
let m = b[this.rtl ? d - 1 - k : k];
|
||||
var e = m.length;
|
||||
if (e && (p || !n[m])) {
|
||||
var f = this.score ? this.score(b, m, k, null, 0) : I(r, d, k), g = "";
|
||||
switch(this.tokenize) {
|
||||
case "full":
|
||||
if (2 < e) {
|
||||
for (f = 0; f < e; f++) {
|
||||
for (var h = e; h > f; h--) {
|
||||
g = l.substring(f, h);
|
||||
var m = this.score ? this.score(b, l, k, g, f) : H(q, d, k, e, f);
|
||||
J(this, p, g, m, a, c);
|
||||
g = m.substring(f, h);
|
||||
var l = this.score ? this.score(b, m, k, g, f) : I(r, d, k, e, f);
|
||||
K(this, n, g, l, a, c);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -90,24 +93,24 @@ G.prototype.add = function(a, b, c, d) {
|
||||
case "reverse":
|
||||
if (1 < e) {
|
||||
for (h = e - 1; 0 < h; h--) {
|
||||
g = l[h] + g, m = this.score ? this.score(b, l, k, g, h) : H(q, d, k, e, h), J(this, p, g, m, a, c);
|
||||
g = m[h] + g, l = this.score ? this.score(b, m, k, g, h) : I(r, d, k, e, h), K(this, n, g, l, a, c);
|
||||
}
|
||||
g = "";
|
||||
}
|
||||
case "forward":
|
||||
if (1 < e) {
|
||||
for (h = 0; h < e; h++) {
|
||||
g += l[h], J(this, p, g, f, a, c);
|
||||
g += m[h], K(this, n, g, f, a, c);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
if (J(this, p, l, f, a, c), n && 1 < d && k < d - 1) {
|
||||
for (e = Object.create(null), g = this.C, f = l, h = Math.min(n + 1, d - k), e[f] = 1, m = 1; m < h; m++) {
|
||||
if ((l = b[this.rtl ? d - 1 - k - m : k + m]) && !e[l]) {
|
||||
e[l] = 1;
|
||||
const x = this.score ? this.score(b, f, k, l, m) : H(g + (d / 2 > g ? 0 : 1), d, k, h - 1, m - 1), I = this.bidirectional && l > f;
|
||||
J(this, r, I ? f : l, x, a, c, I ? l : f);
|
||||
if (K(this, n, m, f, a, c), p && 1 < d && k < d - 1) {
|
||||
for (e = t(), g = this.C, f = m, h = Math.min(p + 1, d - k), e[f] = 1, l = 1; l < h; l++) {
|
||||
if ((m = b[this.rtl ? d - 1 - k - l : k + l]) && !e[m]) {
|
||||
e[m] = 1;
|
||||
const y = this.score ? this.score(b, f, k, m, l) : I(g + (d / 2 > g ? 0 : 1), d, k, h - 1, l - 1), J = this.bidirectional && m > f;
|
||||
K(this, q, J ? f : m, y, a, c, J ? m : f);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -119,14 +122,14 @@ G.prototype.add = function(a, b, c, d) {
|
||||
}
|
||||
return this;
|
||||
};
|
||||
function J(a, b, c, d, e, f, g) {
|
||||
let h = g ? a.A : a.map, m;
|
||||
b[c] && g && (m = b[c])[g] || (g ? (b = m || (b[c] = Object.create(null)), b[g] = 1, (m = h.get(g)) ? h = m : h.set(g, h = new Map())) : b[c] = 1, (m = h.get(c)) ? h = m : h.set(c, h = []), h = h[d] || (h[d] = []), f && h.includes(e) || (h.push(e), a.fastupdate && ((b = a.h.get(e)) ? b.push(h) : a.h.set(e, [h]))));
|
||||
function K(a, b, c, d, e, f, g) {
|
||||
let h = g ? a.A : a.map, l;
|
||||
b[c] && g && (l = b[c])[g] || (g ? (b = l || (b[c] = t()), b[g] = 1, (l = h.get(g)) ? h = l : h.set(g, h = new Map())) : b[c] = 1, (l = h.get(c)) ? h = l : h.set(c, h = []), h = h[d] || (h[d] = []), f && h.includes(e) || (h.push(e), a.fastupdate && ((b = a.h.get(e)) ? b.push(h) : a.h.set(e, [h]))));
|
||||
}
|
||||
function H(a, b, c, d, e) {
|
||||
function I(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 K(a, b, c) {
|
||||
;function L(a, b, c) {
|
||||
if (1 === a.length) {
|
||||
return a = a[0], a = c || a.length > b ? b ? a.slice(c, c + b) : a.slice(c) : a;
|
||||
}
|
||||
@@ -156,7 +159,7 @@ function H(a, b, c, d, e) {
|
||||
}
|
||||
return d.length ? d = 1 < d.length ? [].concat.apply([], d) : d[0] : d;
|
||||
}
|
||||
;G.prototype.search = function(a, b, c) {
|
||||
;H.prototype.search = function(a, b, c) {
|
||||
c || (b || "object" !== typeof a ? "object" === typeof b && (c = b, b = 0) : (c = a, a = ""));
|
||||
var d = [], e = 0;
|
||||
if (c) {
|
||||
@@ -170,104 +173,126 @@ function H(a, b, c, d, e) {
|
||||
c = a.length;
|
||||
b || (b = 100);
|
||||
if (1 === c) {
|
||||
return L.call(this, a[0], "", b, e);
|
||||
return M.call(this, a[0], "", b, e);
|
||||
}
|
||||
f = this.depth && !1 !== f;
|
||||
if (2 === c && f && !g) {
|
||||
return L.call(this, a[0], a[1], b, e);
|
||||
return M.call(this, a[0], a[1], b, e);
|
||||
}
|
||||
var h = 0, m = 0;
|
||||
var h = 0, l = 0;
|
||||
if (1 < c) {
|
||||
var r = Object.create(null);
|
||||
const n = [];
|
||||
for (let q = 0, k; q < c; q++) {
|
||||
if ((k = a[q]) && !r[k]) {
|
||||
if (g || M(this, k)) {
|
||||
n.push(k), r[k] = 1;
|
||||
var q = t();
|
||||
const p = [];
|
||||
for (let r = 0, k; r < c; r++) {
|
||||
if ((k = a[r]) && !q[k]) {
|
||||
if (g || N(this, k)) {
|
||||
p.push(k), q[k] = 1;
|
||||
} else {
|
||||
return d;
|
||||
}
|
||||
const l = k.length;
|
||||
h = Math.max(h, l);
|
||||
m = m ? Math.min(m, l) : l;
|
||||
const m = k.length;
|
||||
h = Math.max(h, m);
|
||||
l = l ? Math.min(l, m) : m;
|
||||
}
|
||||
}
|
||||
a = n;
|
||||
a = p;
|
||||
c = a.length;
|
||||
}
|
||||
if (!c) {
|
||||
return d;
|
||||
}
|
||||
r = 0;
|
||||
q = 0;
|
||||
if (1 === c) {
|
||||
return L.call(this, a[0], "", b, e);
|
||||
return M.call(this, a[0], "", b, e);
|
||||
}
|
||||
if (2 === c && f && !g) {
|
||||
return L.call(this, a[0], a[1], b, e);
|
||||
return M.call(this, a[0], a[1], b, e);
|
||||
}
|
||||
if (1 < c) {
|
||||
if (f) {
|
||||
var p = a[0];
|
||||
r = 1;
|
||||
var n = a[0];
|
||||
q = 1;
|
||||
} else {
|
||||
9 < h && 3 < h / m && a.sort(t);
|
||||
9 < h && 3 < h / l && a.sort(u);
|
||||
}
|
||||
}
|
||||
for (let n, q; r < c; r++) {
|
||||
q = a[r];
|
||||
p ? (n = M(this, q, p), n = N(n, d, g, this.C, b, e, 2 === c), g && !1 === n && d.length || (p = q)) : (n = M(this, q), n = N(n, d, g, this.resolution, b, e, 1 === c));
|
||||
if (n) {
|
||||
return n;
|
||||
for (let p, r; q < c; q++) {
|
||||
r = a[q];
|
||||
n ? (p = N(this, r, n), p = O(p, d, g, this.C, b, e, 2 === c), g && !1 === p && d.length || (n = r)) : (p = N(this, r), p = O(p, d, g, this.resolution, b, e, 1 === c));
|
||||
if (p) {
|
||||
return p;
|
||||
}
|
||||
if (g && r === c - 1) {
|
||||
if (g && q === c - 1) {
|
||||
f = d.length;
|
||||
if (!f) {
|
||||
if (p) {
|
||||
p = "";
|
||||
r = -1;
|
||||
if (n) {
|
||||
n = "";
|
||||
q = -1;
|
||||
continue;
|
||||
}
|
||||
return d;
|
||||
}
|
||||
if (1 === f) {
|
||||
return K(d[0], b, e);
|
||||
return L(d[0], b, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
a: {
|
||||
a = d;
|
||||
d = this.resolution;
|
||||
p = g;
|
||||
n = g;
|
||||
c = a.length;
|
||||
g = [];
|
||||
f = Object.create(null);
|
||||
for (let n = 0, q, k, l, x; n < d; n++) {
|
||||
for (m = 0; m < c; m++) {
|
||||
if (l = a[m], n < l.length && (q = l[n])) {
|
||||
for (r = 0; r < q.length; r++) {
|
||||
k = q[r], (h = f[k]) ? f[k]++ : (h = 0, f[k] = 1), x = g[h] || (g[h] = []), x.push(k);
|
||||
f = t();
|
||||
for (let p = 0, r, k, m, y; p < d; p++) {
|
||||
for (l = 0; l < c; l++) {
|
||||
if (m = a[l], p < m.length && (r = m[p])) {
|
||||
for (q = 0; q < r.length; q++) {
|
||||
k = r[q], (h = f[k]) ? f[k]++ : (h = 0, f[k] = 1), y = g[h] || (g[h] = []), y.push(k);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (a = g.length) {
|
||||
if (p) {
|
||||
if (n) {
|
||||
d = [];
|
||||
for (let n = a - 1, q = 0, k, l; 0 <= n; n--) {
|
||||
if (k = g[n], l = k.length, e >= l) {
|
||||
e -= l;
|
||||
for (let p = a - 1, r = 0, k, m; 0 <= p; p--) {
|
||||
if (k = g[p], m = k.length, e >= m) {
|
||||
e -= m;
|
||||
} else {
|
||||
if (l + q > b || e) {
|
||||
k = k.slice(e, b - q + e), l = k.length;
|
||||
if (m + r > b || e) {
|
||||
k = k.slice(e, b - r + e), m = k.length;
|
||||
}
|
||||
d.push(k);
|
||||
q += l;
|
||||
if (b === q) {
|
||||
r += m;
|
||||
if (b === r) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
g = 1 < d.length ? [].concat.apply([], d) : d[0];
|
||||
if (1 < d.length) {
|
||||
g = d;
|
||||
a = [];
|
||||
d = t();
|
||||
f = g.length;
|
||||
for (l = 0; l < f; l++) {
|
||||
for (n = g[l], h = n.length, q = 0; q < h; q++) {
|
||||
if (c = n[q], !d[c]) {
|
||||
if (d[c] = 1, e) {
|
||||
e--;
|
||||
} else {
|
||||
if (a.push(c), a.length === b) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
b = a;
|
||||
} else {
|
||||
b = d[0];
|
||||
}
|
||||
g = b;
|
||||
} else {
|
||||
if (a < c) {
|
||||
d = [];
|
||||
@@ -283,23 +308,23 @@ function H(a, b, c, d, e) {
|
||||
}
|
||||
return d;
|
||||
};
|
||||
function L(a, b, c, d) {
|
||||
return (a = M(this, a, b)) && a.length ? K(a, c, d) : [];
|
||||
function M(a, b, c, d) {
|
||||
return (a = N(this, a, b)) && a.length ? L(a, c, d) : [];
|
||||
}
|
||||
function N(a, b, c, d, e, f, g) {
|
||||
function O(a, b, c, d, e, f, g) {
|
||||
let h = [];
|
||||
if (a) {
|
||||
d = Math.min(a.length, d);
|
||||
for (let m = 0, r = 0, p; m < d; m++) {
|
||||
if (p = a[m]) {
|
||||
if (f && p && g && (p.length <= f ? (f -= p.length, p = null) : (p = p.slice(f), f = 0)), p && (h[m] = p, g && (r += p.length, r >= e))) {
|
||||
for (let l = 0, q = 0, n; l < d; l++) {
|
||||
if (n = a[l]) {
|
||||
if (f && n && g && (n.length <= f ? (f -= n.length, n = null) : (n = n.slice(f), f = 0)), n && (h[l] = n, g && (q += n.length, q >= e))) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (h.length) {
|
||||
if (g) {
|
||||
return K(h, e, 0);
|
||||
return L(h, e, 0);
|
||||
}
|
||||
b.push(h);
|
||||
return;
|
||||
@@ -307,13 +332,13 @@ function N(a, b, c, d, e, f, g) {
|
||||
}
|
||||
return !c && h;
|
||||
}
|
||||
function M(a, b, c) {
|
||||
function N(a, b, c) {
|
||||
let d;
|
||||
c && (d = a.bidirectional && b > c);
|
||||
a = c ? (a = a.A.get(d ? b : c)) && a.get(d ? c : b) : a.map.get(b);
|
||||
return a;
|
||||
}
|
||||
;G.prototype.remove = function(a, b) {
|
||||
;H.prototype.remove = function(a, b) {
|
||||
const c = this.h.size && (this.fastupdate ? this.h.get(a) : this.h.has(a));
|
||||
if (c) {
|
||||
if (this.fastupdate) {
|
||||
@@ -328,14 +353,14 @@ function M(a, b, c) {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
O(this.map, a), this.depth && O(this.A, a);
|
||||
P(this.map, a), this.depth && P(this.A, a);
|
||||
}
|
||||
b || this.h.delete(a);
|
||||
}
|
||||
this.cache && this.cache.remove(a);
|
||||
return this;
|
||||
};
|
||||
function O(a, b) {
|
||||
function P(a, b) {
|
||||
let c = 0;
|
||||
if (a.constructor === Array) {
|
||||
for (let d = 0, e, f; d < a.length; d++) {
|
||||
@@ -350,17 +375,17 @@ function O(a, b) {
|
||||
}
|
||||
} else {
|
||||
for (let d of a) {
|
||||
const e = d[0], f = O(d[1], b);
|
||||
const e = d[0], f = P(d[1], b);
|
||||
f ? c += f : a.delete(e);
|
||||
}
|
||||
}
|
||||
return c;
|
||||
}
|
||||
;function G(a, b) {
|
||||
;function H(a, b) {
|
||||
if (!this) {
|
||||
return new G(a);
|
||||
return new H(a);
|
||||
}
|
||||
a = a ? F(a) : {};
|
||||
a = a ? G(a) : {};
|
||||
const c = a.context || {}, d = a.encode || a.encoder || function(f) {
|
||||
return f.toLowerCase().trim().split(/\s+/);
|
||||
};
|
||||
@@ -378,29 +403,29 @@ function O(a, b) {
|
||||
this.h = b || (this.fastupdate ? new Map() : new Set());
|
||||
this.C = c.resolution || 1;
|
||||
this.rtl = d.rtl || a.rtl || !1;
|
||||
this.cache = (e = a.cache || null) && new u(e);
|
||||
this.cache = (e = a.cache || null) && new v(e);
|
||||
}
|
||||
G.prototype.clear = function() {
|
||||
H.prototype.clear = function() {
|
||||
this.map.clear();
|
||||
this.A.clear();
|
||||
this.h.clear();
|
||||
this.cache && this.cache.clear();
|
||||
return this;
|
||||
};
|
||||
G.prototype.append = function(a, b) {
|
||||
H.prototype.append = function(a, b) {
|
||||
return this.add(a, b, !0);
|
||||
};
|
||||
G.prototype.contain = function(a) {
|
||||
H.prototype.contain = function(a) {
|
||||
return this.h.has(a);
|
||||
};
|
||||
G.prototype.update = function(a, b) {
|
||||
H.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 P(a) {
|
||||
function Q(a) {
|
||||
let b = 0;
|
||||
if (a.constructor === Array) {
|
||||
for (let c = 0, d; c < a.length; c++) {
|
||||
@@ -408,21 +433,21 @@ function P(a) {
|
||||
}
|
||||
} else {
|
||||
for (const c of a) {
|
||||
const d = c[0], e = P(c[1]);
|
||||
const d = c[0], e = Q(c[1]);
|
||||
e ? b += e : a.delete(d);
|
||||
}
|
||||
}
|
||||
return b;
|
||||
}
|
||||
G.prototype.cleanup = function() {
|
||||
H.prototype.cleanup = function() {
|
||||
if (!this.fastupdate) {
|
||||
return console.info('Cleanup the index isn\'t required when not using "fastupdate".'), this;
|
||||
}
|
||||
P(this.map);
|
||||
this.depth && P(this.A);
|
||||
Q(this.map);
|
||||
this.depth && Q(this.A);
|
||||
return this;
|
||||
};
|
||||
G.prototype.searchCache = function(a, b, c) {
|
||||
H.prototype.searchCache = function(a, b, c) {
|
||||
a = ("object" === typeof a ? "" + a.query : a).toLowerCase();
|
||||
let d = this.cache.get(a);
|
||||
if (!d) {
|
||||
@@ -438,6 +463,6 @@ G.prototype.searchCache = function(a, b, c) {
|
||||
}
|
||||
return d;
|
||||
};
|
||||
export default {Index:G, Charset:D, Encoder:null, Document:null, Worker:null, Resolver:null, IndexedDB:null, Language:{}};
|
||||
export default {Index:H, Charset:E, Encoder:null, Document:null, Worker:null, Resolver:null, IndexedDB:null, Language:{}};
|
||||
|
||||
export const Index=G;export const Charset=D;export const Encoder=null;export const Document=null;export const Worker=null;export const Resolver=null;export const IndexedDB=null;export const 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={};
|
27
dist/flexsearch.light.module.min.js
vendored
27
dist/flexsearch.light.module.min.js
vendored
@@ -5,16 +5,17 @@
|
||||
* Hosted by Nextapps GmbH
|
||||
* https://github.com/nextapps-de/flexsearch
|
||||
*/
|
||||
function t(a,b){return b.length-a.length};function u(a){this.limit=a&&!0!==a?a:1E3;this.cache=new Map;this.B=""}u.prototype.set=function(a,b){this.cache.set(this.B=a,b);this.cache.size>this.limit&&this.cache.delete(this.cache.keys().next().value)};u.prototype.get=function(a){const b=this.cache.get(a);b&&this.B!==a&&(this.cache.delete(a),this.cache.set(this.B=a,b));return b};u.prototype.remove=function(a){for(const b of this.cache){const c=b[0];b[1].includes(a)&&this.cache.delete(c)}};
|
||||
u.prototype.clear=function(){this.cache.clear();this.B=""};const v=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 w=new Map([["ai","ei"],["ae","a"],["oe","o"],["ue","u"],["sh","s"],["ch","c"],["th","t"],["ph","f"],["pf","f"]]),y=[/([^aeo])h([aeo$])/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2"];const z={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 A=/[\x00-\x7F]+/g;const B=/[\x00-\x7F]+/g;const C=/[\x00-\x7F]+/g;var D={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:v},LatinAdvanced:{normalize:!0,dedupe:!0,mapper:v,replacer:y,matcher:w},LatinExtra:{normalize:!0,dedupe:!0,mapper:v,replacer:y.concat([/(?!^)[aeoy]/g,""]),matcher:w},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=z[d];
|
||||
for(let f=1,g;f<b.length&&(g=b.charAt(f),"h"===g||"w"===g||!(g=z[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(A," ")}},CjkDefault:{normalize:!1,dedupe:!0,split:"",prepare:function(a){return(""+a).replace(B,"")}},CyrillicDefault:{normalize:!1,dedupe:!0,prepare:function(a){return(""+a).replace(C," ")}}};const E={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 F(a){const b="string"===typeof a?a:a.preset;b&&(a=Object.assign({},E[b],a));return a};Object.create(null);G.prototype.add=function(a,b,c,d){if(b&&(a||0===a)){if(!d&&!c&&this.h.has(a))return this.update(a,b);b=this.encoder.encode(b);if(d=b.length){const r=Object.create(null),p=Object.create(null),n=this.depth,q=this.resolution;for(let k=0;k<d;k++){let l=b[this.rtl?d-1-k:k];var e=l.length;if(e&&(n||!p[l])){var f=this.score?this.score(b,l,k,null,0):I(q,d,k),g="";switch(this.tokenize){case "full":if(2<e){for(f=0;f<e;f++)for(var h=e;h>f;h--){g=l.substring(f,h);var m=this.score?this.score(b,l,k,g,f):I(q,d,
|
||||
k,e,f);J(this,p,g,m,a,c)}break}case "reverse":if(1<e){for(h=e-1;0<h;h--)g=l[h]+g,m=this.score?this.score(b,l,k,g,h):I(q,d,k,e,h),J(this,p,g,m,a,c);g=""}case "forward":if(1<e){for(h=0;h<e;h++)g+=l[h],J(this,p,g,f,a,c);break}default:if(J(this,p,l,f,a,c),n&&1<d&&k<d-1)for(e=Object.create(null),g=this.C,f=l,h=Math.min(n+1,d-k),e[f]=1,m=1;m<h;m++)if((l=b[this.rtl?d-1-k-m:k+m])&&!e[l]){e[l]=1;const x=this.score?this.score(b,f,k,l,m):I(g+(d/2>g?0:1),d,k,h-1,m-1),H=this.bidirectional&&l>f;J(this,r,H?f:l,
|
||||
x,a,c,H?l:f)}}}}this.fastupdate||this.h.add(a)}}return this};function J(a,b,c,d,e,f,g){let h=g?a.A:a.map,m;b[c]&&g&&(m=b[c])[g]||(g?(b=m||(b[c]=Object.create(null)),b[g]=1,(m=h.get(g))?h=m:h.set(g,h=new Map)):b[c]=1,(m=h.get(c))?h=m:h.set(c,h=[]),h=h[d]||(h[d]=[]),f&&h.includes(e)||(h.push(e),a.fastupdate&&((b=a.h.get(e))?b.push(h):a.h.set(e,[h]))))}function I(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 K(a,b,c){if(1===a.length)return a=a[0],a=c||a.length>b?b?a.slice(c,c+b):a.slice(c):a;let d=[];for(let e=0,f,g;e<a.length;e++)if((f=a[e])&&(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(d.length)g>b&&(f=f.slice(0,b),g=f.length),d.push(f);else{if(g>=b)return g>b&&(f=f.slice(0,b)),f;d=[f]}b-=g;if(!b)break}return d.length?d=1<d.length?[].concat.apply([],d):d[0]:d};G.prototype.search=function(a,b,c){c||(b||"object"!==typeof a?"object"===typeof b&&(c=b,b=0):(c=a,a=""));var d=[],e=0;if(c){a=c.query||a;b=c.limit||b;e=c.offset||0;var f=c.context;var g=!1}a=this.encoder.encode(a);c=a.length;b||(b=100);if(1===c)return L.call(this,a[0],"",b,e);f=this.depth&&!1!==f;if(2===c&&f&&!g)return L.call(this,a[0],a[1],b,e);var h=0,m=0;if(1<c){var r=Object.create(null);const n=[];for(let q=0,k;q<c;q++)if((k=a[q])&&!r[k]){if(g||M(this,k))n.push(k),r[k]=1;else return d;const l=
|
||||
k.length;h=Math.max(h,l);m=m?Math.min(m,l):l}a=n;c=a.length}if(!c)return d;r=0;if(1===c)return L.call(this,a[0],"",b,e);if(2===c&&f&&!g)return L.call(this,a[0],a[1],b,e);if(1<c)if(f){var p=a[0];r=1}else 9<h&&3<h/m&&a.sort(t);for(let n,q;r<c;r++){q=a[r];p?(n=M(this,q,p),n=N(n,d,g,this.C,b,e,2===c),g&&!1===n&&d.length||(p=q)):(n=M(this,q),n=N(n,d,g,this.resolution,b,e,1===c));if(n)return n;if(g&&r===c-1){f=d.length;if(!f){if(p){p="";r=-1;continue}return d}if(1===f)return K(d[0],b,e)}}a:{a=d;d=this.resolution;
|
||||
p=g;c=a.length;g=[];f=Object.create(null);for(let n=0,q,k,l,x;n<d;n++)for(m=0;m<c;m++)if(l=a[m],n<l.length&&(q=l[n]))for(r=0;r<q.length;r++)k=q[r],(h=f[k])?f[k]++:(h=0,f[k]=1),x=g[h]||(g[h]=[]),x.push(k);if(a=g.length)if(p){d=[];for(let n=a-1,q=0,k,l;0<=n;n--)if(k=g[n],l=k.length,e>=l)e-=l;else{if(l+q>b||e)k=k.slice(e,b-q+e),l=k.length;d.push(k);q+=l;if(b===q)break}g=1<d.length?[].concat.apply([],d):d[0]}else{if(a<c){d=[];break a}g=g[a-1];if(g.length>b||e)g=g.slice(e,b+e)}d=g}return d};
|
||||
function L(a,b,c,d){return(a=M(this,a,b))&&a.length?K(a,c,d):[]}function N(a,b,c,d,e,f,g){let h=[];if(a){d=Math.min(a.length,d);for(let m=0,r=0,p;m<d;m++)if(p=a[m])if(f&&p&&g&&(p.length<=f?(f-=p.length,p=null):(p=p.slice(f),f=0)),p&&(h[m]=p,g&&(r+=p.length,r>=e)))break;if(h.length){if(g)return K(h,e,0);b.push(h);return}}return!c&&h}function M(a,b,c){let d;c&&(d=a.bidirectional&&b>c);a=c?(a=a.A.get(d?b:c))&&a.get(d?c:b):a.map.get(b);return a};G.prototype.remove=function(a,b){const c=this.h.size&&(this.fastupdate?this.h.get(a):this.h.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 O(this.map,a),this.depth&&O(this.A,a);b||this.h.delete(a)}this.cache&&this.cache.remove(a);return this};
|
||||
function O(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=O(d[1],b);f?c+=f:a.delete(e)}return c};function G(a,b){if(!this)return new G(a);a=a?F(a):{};const c=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&&c.depth||0;this.bidirectional=!1!==c.bidirectional;this.fastupdate=!!a.fastupdate;this.score=a.score||null;e=!1;this.map=new Map;this.A=new Map;this.h=b||(this.fastupdate?new Map:new Set);this.C=
|
||||
c.resolution||1;this.rtl=d.rtl||a.rtl||!1;this.cache=(e=a.cache||null)&&new u(e)}G.prototype.clear=function(){this.map.clear();this.A.clear();this.h.clear();this.cache&&this.cache.clear();return this};G.prototype.append=function(a,b){return this.add(a,b,!0)};G.prototype.contain=function(a){return this.h.has(a)};G.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 P(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=P(c[1]);e?b+=e:a.delete(d)}return b}G.prototype.cleanup=function(){if(!this.fastupdate)return this;P(this.map);this.depth&&P(this.A);return this};
|
||||
G.prototype.searchCache=function(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};export default {Index:G,Charset:D,Encoder:null,Document:null,Worker:null,Resolver:null,IndexedDB:null,Language:{}};
|
||||
export const Index=G;export const Charset=D;export const Encoder=null;export const Document=null;export const Worker=null;export const Resolver=null;export const IndexedDB=null;export const Language={};
|
||||
function t(){return Object.create(null)}function u(a,b){return b.length-a.length};function v(a){this.limit=a&&!0!==a?a:1E3;this.cache=new Map;this.B=""}v.prototype.set=function(a,b){this.cache.set(this.B=a,b);this.cache.size>this.limit&&this.cache.delete(this.cache.keys().next().value)};v.prototype.get=function(a){const b=this.cache.get(a);b&&this.B!==a&&(this.cache.delete(a),this.cache.set(this.B=a,b));return b};v.prototype.remove=function(a){for(const b of this.cache){const c=b[0];b[1].includes(a)&&this.cache.delete(c)}};
|
||||
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 c=0;c<a.length;c++){var b=a[c];let d=b.charAt(0),e=A[d];
|
||||
for(let f=1,g;f<b.length&&(g=b.charAt(f),"h"===g||"w"===g||!(g=A[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(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 b="string"===typeof a?a:a.preset;b&&(a=Object.assign({},F[b],a));return a};t();H.prototype.add=function(a,b,c,d){if(b&&(a||0===a)){if(!d&&!c&&this.h.has(a))return this.update(a,b);b=this.encoder.encode(b);if(d=b.length){const q=t(),n=t(),p=this.depth,r=this.resolution;for(let k=0;k<d;k++){let m=b[this.rtl?d-1-k:k];var e=m.length;if(e&&(p||!n[m])){var f=this.score?this.score(b,m,k,null,0):J(r,d,k),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 l=this.score?this.score(b,m,k,g,f):J(r,d,k,e,f);K(this,n,g,l,a,c)}break}case "reverse":if(1<
|
||||
e){for(h=e-1;0<h;h--)g=m[h]+g,l=this.score?this.score(b,m,k,g,h):J(r,d,k,e,h),K(this,n,g,l,a,c);g=""}case "forward":if(1<e){for(h=0;h<e;h++)g+=m[h],K(this,n,g,f,a,c);break}default:if(K(this,n,m,f,a,c),p&&1<d&&k<d-1)for(e=t(),g=this.C,f=m,h=Math.min(p+1,d-k),e[f]=1,l=1;l<h;l++)if((m=b[this.rtl?d-1-k-l:k+l])&&!e[m]){e[m]=1;const y=this.score?this.score(b,f,k,m,l):J(g+(d/2>g?0:1),d,k,h-1,l-1),I=this.bidirectional&&m>f;K(this,q,I?f:m,y,a,c,I?m:f)}}}}this.fastupdate||this.h.add(a)}}return this};
|
||||
function K(a,b,c,d,e,f,g){let h=g?a.A:a.map,l;b[c]&&g&&(l=b[c])[g]||(g?(b=l||(b[c]=t()),b[g]=1,(l=h.get(g))?h=l:h.set(g,h=new Map)):b[c]=1,(l=h.get(c))?h=l:h.set(c,h=[]),h=h[d]||(h[d]=[]),f&&h.includes(e)||(h.push(e),a.fastupdate&&((b=a.h.get(e))?b.push(h):a.h.set(e,[h]))))}function J(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 L(a,b,c){if(1===a.length)return a=a[0],a=c||a.length>b?b?a.slice(c,c+b):a.slice(c):a;let d=[];for(let e=0,f,g;e<a.length;e++)if((f=a[e])&&(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(d.length)g>b&&(f=f.slice(0,b),g=f.length),d.push(f);else{if(g>=b)return g>b&&(f=f.slice(0,b)),f;d=[f]}b-=g;if(!b)break}return d.length?d=1<d.length?[].concat.apply([],d):d[0]:d};H.prototype.search=function(a,b,c){c||(b||"object"!==typeof a?"object"===typeof b&&(c=b,b=0):(c=a,a=""));var d=[],e=0;if(c){a=c.query||a;b=c.limit||b;e=c.offset||0;var f=c.context;var g=!1}a=this.encoder.encode(a);c=a.length;b||(b=100);if(1===c)return M.call(this,a[0],"",b,e);f=this.depth&&!1!==f;if(2===c&&f&&!g)return M.call(this,a[0],a[1],b,e);var h=0,l=0;if(1<c){var q=t();const p=[];for(let r=0,k;r<c;r++)if((k=a[r])&&!q[k]){if(g||N(this,k))p.push(k),q[k]=1;else return d;const m=k.length;h=Math.max(h,
|
||||
m);l=l?Math.min(l,m):m}a=p;c=a.length}if(!c)return d;q=0;if(1===c)return M.call(this,a[0],"",b,e);if(2===c&&f&&!g)return M.call(this,a[0],a[1],b,e);if(1<c)if(f){var n=a[0];q=1}else 9<h&&3<h/l&&a.sort(u);for(let p,r;q<c;q++){r=a[q];n?(p=N(this,r,n),p=O(p,d,g,this.C,b,e,2===c),g&&!1===p&&d.length||(n=r)):(p=N(this,r),p=O(p,d,g,this.resolution,b,e,1===c));if(p)return p;if(g&&q===c-1){f=d.length;if(!f){if(n){n="";q=-1;continue}return d}if(1===f)return L(d[0],b,e)}}a:{a=d;d=this.resolution;n=g;c=a.length;
|
||||
g=[];f=t();for(let p=0,r,k,m,y;p<d;p++)for(l=0;l<c;l++)if(m=a[l],p<m.length&&(r=m[p]))for(q=0;q<r.length;q++)k=r[q],(h=f[k])?f[k]++:(h=0,f[k]=1),y=g[h]||(g[h]=[]),y.push(k);if(a=g.length)if(n){d=[];for(let p=a-1,r=0,k,m;0<=p;p--)if(k=g[p],m=k.length,e>=m)e-=m;else{if(m+r>b||e)k=k.slice(e,b-r+e),m=k.length;d.push(k);r+=m;if(b===r)break}if(1<d.length){g=d;a=[];d=t();f=g.length;for(l=0;l<f;l++)for(n=g[l],h=n.length,q=0;q<h;q++)if(c=n[q],!d[c])if(d[c]=1,e)e--;else if(a.push(c),a.length===b)break;b=a}else b=
|
||||
d[0];g=b}else{if(a<c){d=[];break a}g=g[a-1];if(g.length>b||e)g=g.slice(e,b+e)}d=g}return d};function M(a,b,c,d){return(a=N(this,a,b))&&a.length?L(a,c,d):[]}function O(a,b,c,d,e,f,g){let h=[];if(a){d=Math.min(a.length,d);for(let l=0,q=0,n;l<d;l++)if(n=a[l])if(f&&n&&g&&(n.length<=f?(f-=n.length,n=null):(n=n.slice(f),f=0)),n&&(h[l]=n,g&&(q+=n.length,q>=e)))break;if(h.length){if(g)return L(h,e,0);b.push(h);return}}return!c&&h}
|
||||
function N(a,b,c){let d;c&&(d=a.bidirectional&&b>c);a=c?(a=a.A.get(d?b:c))&&a.get(d?c:b):a.map.get(b);return a};H.prototype.remove=function(a,b){const c=this.h.size&&(this.fastupdate?this.h.get(a):this.h.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 P(this.map,a),this.depth&&P(this.A,a);b||this.h.delete(a)}this.cache&&this.cache.remove(a);return this};
|
||||
function P(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=P(d[1],b);f?c+=f:a.delete(e)}return c};function H(a,b){if(!this)return new H(a);a=a?G(a):{};const c=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&&c.depth||0;this.bidirectional=!1!==c.bidirectional;this.fastupdate=!!a.fastupdate;this.score=a.score||null;e=!1;this.map=new Map;this.A=new Map;this.h=b||(this.fastupdate?new Map:new Set);this.C=
|
||||
c.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,b){return this.add(a,b,!0)};H.prototype.contain=function(a){return this.h.has(a)};H.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 Q(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=Q(c[1]);e?b+=e:a.delete(d)}return b}H.prototype.cleanup=function(){if(!this.fastupdate)return this;Q(this.map);this.depth&&Q(this.A);return this};
|
||||
H.prototype.searchCache=function(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};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={};
|
39
dist/module-debug/intersect.js
vendored
39
dist/module-debug/intersect.js
vendored
@@ -34,10 +34,6 @@ export function intersect(arrays, resolution, limit, offset, suggest) {
|
||||
count;
|
||||
|
||||
|
||||
// if(suggest){
|
||||
// suggest = [];
|
||||
// }
|
||||
|
||||
// alternatively the results could be sorted by length up
|
||||
//arrays.sort(sort_by_length_up);
|
||||
|
||||
@@ -120,7 +116,40 @@ export function intersect(arrays, resolution, limit, offset, suggest) {
|
||||
}
|
||||
}
|
||||
|
||||
result = 1 < final.length ? concat(final) : final[0];
|
||||
result = 1 < final.length ? union(final, offset, limit) : final[0];
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function union(arrays, offset, limit) {
|
||||
const result = [],
|
||||
check = create_object();
|
||||
|
||||
let ids,
|
||||
id,
|
||||
arr_len = arrays.length,
|
||||
ids_len;
|
||||
|
||||
for (let i = 0; i < arr_len; i++) {
|
||||
|
||||
ids = arrays[i];
|
||||
ids_len = ids.length;
|
||||
|
||||
for (let j = 0; j < ids_len; j++) {
|
||||
id = ids[j];
|
||||
if (!check[id]) {
|
||||
check[id] = 1;
|
||||
if (offset) {
|
||||
offset--;
|
||||
} else {
|
||||
result.push(id);
|
||||
if (result.length === limit) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
2
dist/module-min/intersect.js
vendored
2
dist/module-min/intersect.js
vendored
@@ -1 +1 @@
|
||||
import{create_object,concat,sort_by_length_up,get_max_len}from"./common.js";export function intersect(a,b,c,d,e){const f=a.length;let g,h,j=[];g=create_object();for(let i,k,l,m,n=0;n<b;n++)for(let b=0;b<f;b++)if(l=a[b],n<l.length&&(i=l[n]))for(let a=0;a<i.length;a++)k=i[a],(h=g[k])?g[k]++:(h=0,g[k]=1),m=j[h]||(j[h]=[]),m.push(k);const k=j.length;if(k)if(!e){if(k<f)return[];j=j[k-1],(j.length>c||d)&&(j=j.slice(d,c+d))}else{const a=[];for(let b,e,f=k-1,g=0;0<=f;f--){if(b=j[f],e=b.length,d>=e){d-=e;continue}if((e+g>c||d)&&(b=b.slice(d,c-g+d),e=b.length),a.push(b),g+=e,c===g)break}j=1<a.length?concat(a):a[0]}return j}export function intersect_union(a,b){const c=create_object(),d=create_object(),e=[];for(let d=0;d<a.length;d++)c[a[d]]=1;for(let f,g=0;g<b.length;g++){f=b[g];for(let a,b=0;b<f.length;b++)a=f[b],c[a]&&!d[a]&&(d[a]=1,e.push(a))}return e}
|
||||
import{create_object,concat,sort_by_length_up,get_max_len}from"./common.js";export function intersect(a,b,c,d,e){const f=a.length;let g,h,j=[];g=create_object();for(let i,k,l,m,n=0;n<b;n++)for(let b=0;b<f;b++)if(l=a[b],n<l.length&&(i=l[n]))for(let a=0;a<i.length;a++)k=i[a],(h=g[k])?g[k]++:(h=0,g[k]=1),m=j[h]||(j[h]=[]),m.push(k);const k=j.length;if(k)if(!e){if(k<f)return[];j=j[k-1],(j.length>c||d)&&(j=j.slice(d,c+d))}else{const a=[];for(let b,e,f=k-1,g=0;0<=f;f--){if(b=j[f],e=b.length,d>=e){d-=e;continue}if((e+g>c||d)&&(b=b.slice(d,c-g+d),e=b.length),a.push(b),g+=e,c===g)break}j=1<a.length?union(a,d,c):a[0]}return j}function union(a,b,c){const d=[],e=create_object();let f,g,h,j=a.length;for(let k=0;k<j;k++){f=a[k],h=f.length;for(let a=0;a<h;a++)if(g=f[a],!e[g])if(e[g]=1,b)b--;else if(d.push(g),d.length===c)break}return d}export function intersect_union(a,b){const c=create_object(),d=create_object(),e=[];for(let d=0;d<a.length;d++)c[a[d]]=1;for(let f,g=0;g<b.length;g++){f=b[g];for(let a,b=0;b<f.length;b++)a=f[b],c[a]&&!d[a]&&(d[a]=1,e.push(a))}return e}
|
39
dist/module/intersect.js
vendored
39
dist/module/intersect.js
vendored
@@ -34,10 +34,6 @@ export function intersect(arrays, resolution, limit, offset, suggest) {
|
||||
count;
|
||||
|
||||
|
||||
// if(suggest){
|
||||
// suggest = [];
|
||||
// }
|
||||
|
||||
// alternatively the results could be sorted by length up
|
||||
//arrays.sort(sort_by_length_up);
|
||||
|
||||
@@ -120,7 +116,40 @@ export function intersect(arrays, resolution, limit, offset, suggest) {
|
||||
}
|
||||
}
|
||||
|
||||
result = 1 < final.length ? concat(final) : final[0];
|
||||
result = 1 < final.length ? union(final, offset, limit) : final[0];
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function union(arrays, offset, limit) {
|
||||
const result = [],
|
||||
check = create_object();
|
||||
|
||||
let ids,
|
||||
id,
|
||||
arr_len = arrays.length,
|
||||
ids_len;
|
||||
|
||||
for (let i = 0; i < arr_len; i++) {
|
||||
|
||||
ids = arrays[i];
|
||||
ids_len = ids.length;
|
||||
|
||||
for (let j = 0; j < ids_len; j++) {
|
||||
id = ids[j];
|
||||
if (!check[id]) {
|
||||
check[id] = 1;
|
||||
if (offset) {
|
||||
offset--;
|
||||
} else {
|
||||
result.push(id);
|
||||
if (result.length === limit) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -33,10 +33,6 @@ export function intersect(arrays, resolution, limit, offset, suggest) {
|
||||
let check;
|
||||
let count;
|
||||
|
||||
// if(suggest){
|
||||
// suggest = [];
|
||||
// }
|
||||
|
||||
// alternatively the results could be sorted by length up
|
||||
//arrays.sort(sort_by_length_up);
|
||||
|
||||
@@ -122,7 +118,7 @@ export function intersect(arrays, resolution, limit, offset, suggest) {
|
||||
}
|
||||
|
||||
result = final.length > 1
|
||||
? concat(final)
|
||||
? union(final, offset, limit)
|
||||
: final[0];
|
||||
}
|
||||
}
|
||||
@@ -130,6 +126,37 @@ export function intersect(arrays, resolution, limit, offset, suggest) {
|
||||
return result;
|
||||
}
|
||||
|
||||
function union(arrays, offset, limit){
|
||||
|
||||
const result = [];
|
||||
const check = create_object();
|
||||
let ids, id, arr_len = arrays.length, ids_len;
|
||||
|
||||
for(let i = 0; i < arr_len; i++){
|
||||
|
||||
ids = arrays[i];
|
||||
ids_len = ids.length;
|
||||
|
||||
for(let j = 0; j < ids_len; j++){
|
||||
id = ids[j];
|
||||
if(!check[id]){
|
||||
check[id] = 1;
|
||||
if(offset){
|
||||
offset--;
|
||||
}
|
||||
else{
|
||||
result.push(id);
|
||||
if(result.length === limit){
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// /**
|
||||
// * Implementation based on Object[key] provides better suggestions
|
||||
|
Reference in New Issue
Block a user