diff --git a/README.md b/README.md index 7dcb184..30aa984 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ FlexSearch v0.8: [Overview and Migration Guide](doc/0.8.0.md) - + [Basic Start](#load-library)  •  diff --git a/dist/flexsearch.bundle.debug.js b/dist/flexsearch.bundle.debug.js index 30cab18..4680df6 100644 --- a/dist/flexsearch.bundle.debug.js +++ b/dist/flexsearch.bundle.debug.js @@ -1,36 +1,36 @@ /**! - * FlexSearch.js v0.8.163 (Bundle/Debug) + * FlexSearch.js v0.8.164 (Bundle/Debug) * Author and Copyright: Thomas Wilkerling * Licence: Apache-2.0 * Hosted by Nextapps GmbH * https://github.com/nextapps-de/flexsearch */ (function _f(self){'use strict';if(typeof module!=='undefined')self=module;else if(typeof process !== 'undefined')self=process;self._factory=_f; -var v; -function F(a, c, b) { - const e = typeof b, d = typeof a; - if ("undefined" !== e) { - if ("undefined" !== d) { - if (b) { - if ("function" === d && e === d) { - return function(k) { - return a(b(k)); +var w; +function E(a, b, c) { + const d = typeof c, e = typeof a; + if ("undefined" !== d) { + if ("undefined" !== e) { + if (c) { + if ("function" === e && d === e) { + return function(h) { + return a(c(h)); }; } - c = a.constructor; - if (c === b.constructor) { - if (c === Array) { - return b.concat(a); + b = a.constructor; + if (b === c.constructor) { + if (b === Array) { + return c.concat(a); } - if (c === Map) { - var f = new Map(b); + if (b === Map) { + var f = new Map(c); for (var g of a) { f.set(g[0], g[1]); } return f; } - if (c === Set) { - g = new Set(b); + if (b === Set) { + g = new Set(c); for (f of a.values()) { g.add(f); } @@ -40,42 +40,42 @@ function F(a, c, b) { } return a; } - return b; + return c; } - return "undefined" === d ? c : a; + return "undefined" === e ? b : a; } -function G() { +function H() { return Object.create(null); } -function L(a) { +function M(a) { return "string" === typeof a; } function aa(a) { return "object" === typeof a; } function da(a) { - const c = []; - for (const b of a.keys()) { - c.push(b); + const b = []; + for (const c of a.keys()) { + b.push(c); } - return c; + return b; } -function ea(a, c) { - if (L(c)) { - a = a[c]; +function ea(a, b) { + if (M(b)) { + a = a[b]; } else { - for (let b = 0; a && b < c.length; b++) { - a = a[c[b]]; + for (let c = 0; a && c < b.length; c++) { + a = a[b[c]]; } } return a; } function fa(a) { - let c = 0; - for (let b = 0, e; b < a.length; b++) { - (e = a[b]) && c < e.length && (c = e.length); + let b = 0; + for (let c = 0, d; c < a.length; c++) { + (d = a[c]) && b < d.length && (b = d.length); } - return c; + return b; } ;const ha = /[^\p{L}\p{N}]+/u, ia = /(\d{3})/g, ja = /(\D)(\d{3})/g, ka = /(\d{3})(\D)/g, la = /[\u0300-\u036f]/g; function ma(a = {}) { @@ -90,120 +90,120 @@ function ma(a = {}) { this.assign(a); } } -v = ma.prototype; -v.assign = function(a) { - this.normalize = F(a.normalize, !0, this.normalize); - let c = a.include, b = c || a.exclude || a.split, e; - if (b || "" === b) { - if ("object" === typeof b && b.constructor !== RegExp) { - let d = ""; - e = !c; - c || (d += "\\p{Z}"); - b.letter && (d += "\\p{L}"); - b.number && (d += "\\p{N}", e = !!c); - b.symbol && (d += "\\p{S}"); - b.punctuation && (d += "\\p{P}"); - b.control && (d += "\\p{C}"); - if (b = b.char) { - d += "object" === typeof b ? b.join("") : b; +w = ma.prototype; +w.assign = function(a) { + this.normalize = E(a.normalize, !0, this.normalize); + let b = a.include, c = b || a.exclude || a.split, d; + if (c || "" === c) { + if ("object" === typeof c && c.constructor !== RegExp) { + let e = ""; + d = !b; + b || (e += "\\p{Z}"); + c.letter && (e += "\\p{L}"); + c.number && (e += "\\p{N}", d = !!b); + c.symbol && (e += "\\p{S}"); + c.punctuation && (e += "\\p{P}"); + c.control && (e += "\\p{C}"); + if (c = c.char) { + e += "object" === typeof c ? c.join("") : c; } try { - this.split = new RegExp("[" + (c ? "^" : "") + d + "]+", "u"); + this.split = new RegExp("[" + (b ? "^" : "") + e + "]+", "u"); } catch (f) { - console.error("Your split configuration:", b, "is not supported on this platform. It falls back to using simple whitespace splitter instead: /s+/."), this.split = /\s+/; + console.error("Your split configuration:", c, "is not supported on this platform. It falls back to using simple whitespace splitter instead: /s+/."), this.split = /\s+/; } } else { - this.split = b, e = !1 === b || 2 > "a1a".split(b).length; + this.split = c, d = !1 === c || 2 > "a1a".split(c).length; } - this.numeric = F(a.numeric, e); + this.numeric = E(a.numeric, d); } else { try { - this.split = F(this.split, ha); - } catch (d) { + this.split = E(this.split, ha); + } catch (e) { console.warn("This platform does not support unicode regex. It falls back to using simple whitespace splitter instead: /s+/."), this.split = /\s+/; } - this.numeric = F(a.numeric, F(this.numeric, !0)); + this.numeric = E(a.numeric, E(this.numeric, !0)); } - this.prepare = F(a.prepare, null, this.prepare); - this.finalize = F(a.finalize, null, this.finalize); - b = a.filter; - this.filter = "function" === typeof b ? b : F(b && new Set(b), null, this.filter); - this.dedupe = F(a.dedupe, !0, this.dedupe); - this.matcher = F((b = a.matcher) && new Map(b), null, this.matcher); - this.mapper = F((b = a.mapper) && new Map(b), null, this.mapper); - this.stemmer = F((b = a.stemmer) && new Map(b), null, this.stemmer); - this.replacer = F(a.replacer, null, this.replacer); - this.minlength = F(a.minlength, 1, this.minlength); - this.maxlength = F(a.maxlength, 1024, this.maxlength); - this.rtl = F(a.rtl, !1, this.rtl); - if (this.cache = b = F(a.cache, !0, this.cache)) { - this.H = null, this.S = "number" === typeof b ? b : 2e5, this.B = new Map(), this.G = new Map(), this.L = this.K = 128; + this.prepare = E(a.prepare, null, this.prepare); + this.finalize = E(a.finalize, null, this.finalize); + c = a.filter; + this.filter = "function" === typeof c ? c : E(c && new Set(c), null, this.filter); + this.dedupe = E(a.dedupe, !0, this.dedupe); + this.matcher = E((c = a.matcher) && new Map(c), null, this.matcher); + this.mapper = E((c = a.mapper) && new Map(c), null, this.mapper); + this.stemmer = E((c = a.stemmer) && new Map(c), null, this.stemmer); + this.replacer = E(a.replacer, null, this.replacer); + this.minlength = E(a.minlength, 1, this.minlength); + this.maxlength = E(a.maxlength, 1024, this.maxlength); + this.rtl = E(a.rtl, !1, this.rtl); + if (this.cache = c = E(a.cache, !0, this.cache)) { + this.H = null, this.S = "number" === typeof c ? c : 2e5, this.B = new Map(), this.G = new Map(), this.L = this.K = 128; } this.h = ""; this.M = null; this.A = ""; this.N = null; if (this.matcher) { - for (const d of this.matcher.keys()) { - this.h += (this.h ? "|" : "") + d; + for (const e of this.matcher.keys()) { + this.h += (this.h ? "|" : "") + e; } } if (this.stemmer) { - for (const d of this.stemmer.keys()) { - this.A += (this.A ? "|" : "") + d; + for (const e of this.stemmer.keys()) { + this.A += (this.A ? "|" : "") + e; } } return this; }; -v.addStemmer = function(a, c) { +w.addStemmer = function(a, b) { this.stemmer || (this.stemmer = new Map()); - this.stemmer.set(a, c); + this.stemmer.set(a, b); this.A += (this.A ? "|" : "") + a; this.N = null; this.cache && N(this); return this; }; -v.addFilter = function(a) { +w.addFilter = function(a) { "function" === typeof a ? this.filter = a : (this.filter || (this.filter = new Set()), this.filter.add(a)); this.cache && N(this); return this; }; -v.addMapper = function(a, c) { +w.addMapper = function(a, b) { if ("object" === typeof a) { - return this.addReplacer(a, c); + return this.addReplacer(a, b); } if (1 < a.length) { - return this.addMatcher(a, c); + return this.addMatcher(a, b); } this.mapper || (this.mapper = new Map()); - this.mapper.set(a, c); + this.mapper.set(a, b); this.cache && N(this); return this; }; -v.addMatcher = function(a, c) { +w.addMatcher = function(a, b) { if ("object" === typeof a) { - return this.addReplacer(a, c); + return this.addReplacer(a, b); } if (2 > a.length && (this.dedupe || this.mapper)) { - return this.addMapper(a, c); + return this.addMapper(a, b); } this.matcher || (this.matcher = new Map()); - this.matcher.set(a, c); + this.matcher.set(a, b); this.h += (this.h ? "|" : "") + a; this.M = null; this.cache && N(this); return this; }; -v.addReplacer = function(a, c) { +w.addReplacer = function(a, b) { if ("string" === typeof a) { - return this.addMatcher(a, c); + return this.addMatcher(a, b); } this.replacer || (this.replacer = []); - this.replacer.push(a, c); + this.replacer.push(a, b); this.cache && N(this); return this; }; -v.encode = function(a, c) { +w.encode = function(a, b) { if (this.cache && a.length <= this.K) { if (this.H) { if (this.B.has(a)) { @@ -216,30 +216,30 @@ v.encode = function(a, c) { this.normalize && ("function" === typeof this.normalize ? a = this.normalize(a) : a = la ? a.normalize("NFKD").replace(la, "").toLowerCase() : a.toLowerCase()); this.prepare && (a = this.prepare(a)); this.numeric && 3 < a.length && (a = a.replace(ja, "$1 $2").replace(ka, "$1 $2").replace(ia, "$1 ")); - const b = !(this.dedupe || this.mapper || this.filter || this.matcher || this.stemmer || this.replacer); - let e = [], d = G(), f, g, k = this.split || "" === this.split ? a.split(this.split) : [a]; - for (let l = 0, m, t; l < k.length; l++) { - if ((m = t = k[l]) && !(m.length < this.minlength || m.length > this.maxlength)) { - if (c) { - if (d[m]) { + const c = !(this.dedupe || this.mapper || this.filter || this.matcher || this.stemmer || this.replacer); + let d = [], e = H(), f, g, h = this.split || "" === this.split ? a.split(this.split) : [a]; + for (let l = 0, m, p; l < h.length; l++) { + if ((m = p = h[l]) && !(m.length < this.minlength || m.length > this.maxlength)) { + if (b) { + if (e[m]) { continue; } - d[m] = 1; + e[m] = 1; } else { if (f === m) { continue; } f = m; } - if (b) { - e.push(m); + if (c) { + d.push(m); } else { if (!this.filter || ("function" === typeof this.filter ? this.filter(m) : !this.filter.has(m))) { if (this.cache && m.length <= this.L) { if (this.H) { - var h = this.G.get(m); - if (h || "" === h) { - h && e.push(h); + var k = this.G.get(m); + if (k || "" === k) { + k && d.push(k); continue; } } else { @@ -248,32 +248,32 @@ v.encode = function(a, c) { } if (this.stemmer) { this.N || (this.N = new RegExp("(?!^)(" + this.A + ")$")); - let q; - for (; q !== m && 2 < m.length;) { - q = m, m = m.replace(this.N, n => this.stemmer.get(n)); + let u; + for (; u !== m && 2 < m.length;) { + u = m, m = m.replace(this.N, q => this.stemmer.get(q)); } } if (m && (this.mapper || this.dedupe && 1 < m.length)) { - h = ""; - for (let q = 0, n = "", r, u; q < m.length; q++) { - r = m.charAt(q), r === n && this.dedupe || ((u = this.mapper && this.mapper.get(r)) || "" === u ? u === n && this.dedupe || !(n = u) || (h += u) : h += n = r); + k = ""; + for (let u = 0, q = "", r, n; u < m.length; u++) { + r = m.charAt(u), r === q && this.dedupe || ((n = this.mapper && this.mapper.get(r)) || "" === n ? n === q && this.dedupe || !(q = n) || (k += n) : k += q = r); } - m = h; + m = k; } - this.matcher && 1 < m.length && (this.M || (this.M = new RegExp("(" + this.h + ")", "g")), m = m.replace(this.M, q => this.matcher.get(q))); + this.matcher && 1 < m.length && (this.M || (this.M = new RegExp("(" + this.h + ")", "g")), m = m.replace(this.M, u => this.matcher.get(u))); if (m && this.replacer) { - for (h = 0; m && h < this.replacer.length; h += 2) { - m = m.replace(this.replacer[h], this.replacer[h + 1]); + for (k = 0; m && k < this.replacer.length; k += 2) { + m = m.replace(this.replacer[k], this.replacer[k + 1]); } } - this.cache && t.length <= this.L && (this.G.set(t, m), this.G.size > this.S && (this.G.clear(), this.L = this.L / 1.1 | 0)); + this.cache && p.length <= this.L && (this.G.set(p, m), this.G.size > this.S && (this.G.clear(), this.L = this.L / 1.1 | 0)); if (m) { - if (m !== t) { - if (c) { - if (d[m]) { + if (m !== p) { + if (b) { + if (e[m]) { continue; } - d[m] = 1; + e[m] = 1; } else { if (g === m) { continue; @@ -281,15 +281,15 @@ v.encode = function(a, c) { g = m; } } - e.push(m); + d.push(m); } } } } } - this.finalize && (e = this.finalize(e) || e); - this.cache && a.length <= this.K && (this.B.set(a, e), this.B.size > this.S && (this.B.clear(), this.K = this.K / 1.1 | 0)); - return e; + this.finalize && (d = this.finalize(d) || d); + this.cache && a.length <= this.K && (this.B.set(a, d), this.B.size > this.S && (this.B.clear(), this.K = this.K / 1.1 | 0)); + return d; }; function N(a) { a.H = null; @@ -299,32 +299,32 @@ function N(a) { ;let pa, O; async function qa(a) { a = a.data; - var c = a.task; - const b = a.id; - let e = a.args; - switch(c) { + var b = a.task; + const c = a.id; + let d = a.args; + switch(b) { case "init": O = a.options || {}; - (c = a.factory) ? (Function("return " + c)()(self), pa = new self.FlexSearch.Index(O), delete self.FlexSearch) : pa = new P(O); - postMessage({id:b}); + (b = a.factory) ? (Function("return " + b)()(self), pa = new self.FlexSearch.Index(O), delete self.FlexSearch) : pa = new P(O); + postMessage({id:c}); break; default: - let d; - if ("export" === c) { + let e; + if ("export" === b) { if (!O.export || "function" !== typeof O.export) { throw Error('Either no extern configuration provided for the Worker-Index or no method was defined on the config property "export".'); } - e[1] ? (e[0] = O.export, e[2] = 0, e[3] = 1) : e = null; + d[1] ? (d[0] = O.export, d[2] = 0, d[3] = 1) : d = null; } - if ("import" === c) { + if ("import" === b) { if (!O.import || "function" !== typeof O.import) { throw Error('Either no extern configuration provided for the Worker-Index or no method was defined on the config property "import".'); } - e[0] && (a = await O.import.call(pa, e[0]), pa.import(e[0], a)); + d[0] && (a = await O.import.call(pa, d[0]), pa.import(d[0], a)); } else { - (d = e && pa[c].apply(pa, e)) && d.then && (d = await d); + (e = d && pa[b].apply(pa, d)) && e.then && (e = await e); } - postMessage("search" === c ? {id:b, msg:d} : {id:b}); + postMessage("search" === b ? {id:c, msg:e} : {id:c}); } } ;function ra(a) { @@ -335,66 +335,67 @@ async function qa(a) { sa.call(a, "remove"); sa.call(a, "searchCache"); } -let ta, ua, xa; +let ta, ua, va; function ya() { - ta = xa = 0; + ta = va = 0; } function sa(a) { this[a + "Async"] = function() { - const c = arguments; - var b = c[c.length - 1]; - let e; - "function" === typeof b && (e = b, delete c[c.length - 1]); - ta ? xa || (xa = Date.now() - ua >= this.priority * this.priority * 3) : (ta = setTimeout(ya, 0), ua = Date.now()); - if (xa) { + const b = arguments; + var c = b[b.length - 1]; + let d; + "function" === typeof c && (d = c, delete b[b.length - 1]); + ta ? va || (va = Date.now() - ua >= this.priority * this.priority * 3) : (ta = setTimeout(ya, 0), ua = Date.now()); + if (va) { const f = this; return new Promise(g => { setTimeout(function() { - g(f[a + "Async"].apply(f, c)); + g(f[a + "Async"].apply(f, b)); }, 0); }); } - const d = this[a].apply(this, c); - b = d.then ? d : new Promise(f => f(d)); - e && b.then(e); - return b; + const e = this[a].apply(this, b); + c = e.then ? e : new Promise(f => f(e)); + d && c.then(d); + return c; }; } ;let za = 0; -function Aa(a = {}) { - function c(g) { - function k(h) { - h = h.data || h; - const l = h.id, m = l && d.h[l]; - m && (m(h.msg), delete d.h[l]); +function Aa(a = {}, b) { + function c(h) { + function k(l) { + l = l.data || l; + const m = l.id, p = m && f.h[m]; + p && (p(l.msg), delete f.h[m]); } - this.worker = g; - this.h = G(); + this.worker = h; + this.h = H(); if (this.worker) { e ? this.worker.on("message", k) : this.worker.onmessage = k; if (a.config) { - return new Promise(function(h) { - d.h[++za] = function() { - h(d); + return new Promise(function(l) { + f.h[++za] = function() { + l(f); 1e9 < za && (za = 0); }; - d.worker.postMessage({id:za, task:"init", factory:b, options:a}); + f.worker.postMessage({id:za, task:"init", factory:d, options:a}); }); } - this.worker.postMessage({task:"init", factory:b, options:a}); + this.worker.postMessage({task:"init", factory:d, options:a}); this.priority = a.priority || 4; + b && (this.encoder = b); return this; } } if (!this || this.constructor !== Aa) { return new Aa(a); } - let b = "undefined" !== typeof self ? self._factory : "undefined" !== typeof window ? window._factory : null; - b && (b = b.toString()); - const e = "undefined" === typeof window, d = this, f = Ba(b, e, a.worker); - return f.then ? f.then(function(g) { - return c.call(d, g); - }) : c.call(this, f); + let d = "undefined" !== typeof self ? self._factory : "undefined" !== typeof window ? window._factory : null; + d && (d = d.toString()); + const e = "undefined" === typeof window, f = this, g = Ba(d, e, a.worker); + return g.then ? g.then(function(h) { + return c.call(f, h); + }) : c.call(this, g); } R("add"); R("append"); @@ -407,757 +408,631 @@ R("import"); ra(Aa.prototype); function R(a) { Aa.prototype[a] = function() { - const c = this, b = [].slice.call(arguments); - var e = b[b.length - 1]; - let d; - "function" === typeof e && (d = e, b.pop()); - e = new Promise(function(f) { - "export" === a && "function" === typeof b[0] && (b[0] = null); - c.h[++za] = f; - c.worker.postMessage({task:a, id:za, args:b}); + const b = this, c = [].slice.call(arguments); + var d = c[c.length - 1]; + let e; + "function" === typeof d && (e = d, c.pop()); + d = new Promise(function(f) { + "export" === a && "function" === typeof c[0] && (c[0] = null); + b.h[++za] = f; + b.worker.postMessage({task:a, id:za, args:c}); }); - return d ? (e.then(d), this) : e; + return e ? (d.then(e), this) : d; }; } -function Ba(a, c, b) { - return c ? "undefined" !== typeof module ? new(require("worker_threads")["Worker"])(__dirname+"/node/node.js") : import("worker_threads").then(function(worker){return new worker["Worker"]((1,eval)("import.meta.dirname")+"/node/node.mjs")}) : a ? new window.Worker(URL.createObjectURL(new Blob(["onmessage=" + qa.toString()], {type:"text/javascript"}))) : new window.Worker("string" === typeof b ? b : (0,eval)("import.meta.url").replace("/worker.js", "/worker/worker.js").replace("flexsearch.bundle.module.min.js", +function Ba(a, b, c) { + return b ? "undefined" !== typeof module ? new(require("worker_threads")["Worker"])(__dirname+"/node/node.js") : import("worker_threads").then(function(worker){return new worker["Worker"]((1,eval)("import.meta.dirname")+"/node/node.mjs")}) : a ? new window.Worker(URL.createObjectURL(new Blob(["onmessage=" + qa.toString()], {type:"text/javascript"}))) : new window.Worker("string" === typeof c ? c : (0,eval)("import.meta.url").replace("/worker.js", "/worker/worker.js").replace("flexsearch.bundle.module.min.js", "module/worker/worker.js"), {type:"module"}); } -;function Ca(a, c = 0) { - let b = [], e = []; - c && (c = 250000 / c * 5000 | 0); - for (const d of a.entries()) { - e.push(d), e.length === c && (b.push(e), e = []); - } - e.length && b.push(e); - return b; -} -function Da(a, c) { - c || (c = new Map()); - for (let b = 0, e; b < a.length; b++) { - e = a[b], c.set(e[0], e[1]); +;function Ca(a, b = 0) { + let c = [], d = []; + b && (b = 250000 / b * 5000 | 0); + for (const e of a.entries()) { + d.push(e), d.length === b && (c.push(d), d = []); } + d.length && c.push(d); return c; } -function Ea(a, c = 0) { - let b = [], e = []; - c && (c = 250000 / c * 1000 | 0); - for (const d of a.entries()) { - e.push([d[0], Ca(d[1])[0]]), e.length === c && (b.push(e), e = []); +function Da(a, b) { + b || (b = new Map()); + for (let c = 0, d; c < a.length; c++) { + d = a[c], b.set(d[0], d[1]); } - e.length && b.push(e); return b; } -function Fa(a, c) { - c || (c = new Map()); - for (let b = 0, e, d; b < a.length; b++) { - e = a[b], d = c.get(e[0]), c.set(e[0], Da(e[1], d)); +function Ea(a, b = 0) { + let c = [], d = []; + b && (b = 250000 / b * 1000 | 0); + for (const e of a.entries()) { + d.push([e[0], Ca(e[1])[0]]), d.length === b && (c.push(d), d = []); } + d.length && c.push(d); return c; } +function Fa(a, b) { + b || (b = new Map()); + for (let c = 0, d, e; c < a.length; c++) { + d = a[c], e = b.get(d[0]), b.set(d[0], Da(d[1], e)); + } + return b; +} function Ga(a) { - let c = [], b = []; - for (const e of a.keys()) { - b.push(e), 250000 === b.length && (c.push(b), b = []); + let b = [], c = []; + for (const d of a.keys()) { + c.push(d), 250000 === c.length && (b.push(c), c = []); } - b.length && c.push(b); - return c; + c.length && b.push(c); + return b; } -function Ha(a, c) { - c || (c = new Set()); - for (let b = 0; b < a.length; b++) { - c.add(a[b]); - } - return c; -} -function Ia(a, c, b, e, d, f, g = 0) { - const k = e && e.constructor === Array; - var h = k ? e.shift() : e; - if (!h) { - return this.export(a, c, d, f + 1); - } - if ((h = a((c ? c + "." : "") + (g + 1) + "." + b, JSON.stringify(h))) && h.then) { - const l = this; - return h.then(function() { - return Ia.call(l, a, c, b, k ? e : null, d, f, g + 1); - }); - } - return Ia.call(this, a, c, b, k ? e : null, d, f, g + 1); -} -function Ja(a, c) { - let b = ""; - for (const e of a.entries()) { - a = e[0]; - const d = e[1]; - let f = ""; - for (let g = 0, k; g < d.length; g++) { - k = d[g] || [""]; - let h = ""; - for (let l = 0; l < k.length; l++) { - h += (h ? "," : "") + ("string" === c ? '"' + k[l] + '"' : k[l]); - } - h = "[" + h + "]"; - f += (f ? "," : "") + h; - } - f = '["' + a + '",[' + f + "]]"; - b += (b ? "," : "") + f; +function Ha(a, b) { + b || (b = new Set()); + for (let c = 0; c < a.length; c++) { + b.add(a[c]); } return b; } -;function Ka(a, c, b, e) { - let d = []; +function Ia(a, b, c, d, e, f, g = 0) { + const h = d && d.constructor === Array; + var k = h ? d.shift() : d; + if (!k) { + return this.export(a, b, e, f + 1); + } + if ((k = a((b ? b + "." : "") + (g + 1) + "." + c, JSON.stringify(k))) && k.then) { + const l = this; + return k.then(function() { + return Ia.call(l, a, b, c, h ? d : null, e, f, g + 1); + }); + } + return Ia.call(this, a, b, c, h ? d : null, e, f, g + 1); +} +function Ja(a, b) { + let c = ""; + for (const d of a.entries()) { + a = d[0]; + const e = d[1]; + let f = ""; + for (let g = 0, h; g < e.length; g++) { + h = e[g] || [""]; + let k = ""; + for (let l = 0; l < h.length; l++) { + k += (k ? "," : "") + ("string" === b ? '"' + h[l] + '"' : h[l]); + } + k = "[" + k + "]"; + f += (f ? "," : "") + k; + } + f = '["' + a + '",[' + f + "]]"; + c += (c ? "," : "") + f; + } + return c; +} +;function Ka(a, b, c, d) { + let e = []; for (let f = 0, g; f < a.index.length; f++) { - if (g = a.index[f], c >= g.length) { - c -= g.length; + if (g = a.index[f], b >= g.length) { + b -= g.length; } else { - c = g[e ? "splice" : "slice"](c, b); - const k = c.length; - if (k && (d = d.length ? d.concat(c) : c, b -= k, e && (a.length -= k), !b)) { + b = g[d ? "splice" : "slice"](b, c); + const h = b.length; + if (h && (e = e.length ? e.concat(b) : b, c -= h, d && (a.length -= h), !c)) { break; } - c = 0; + b = 0; } } - return d; + return e; } -function T(a) { - if (!this || this.constructor !== T) { - return new T(a); +function U(a) { + if (!this || this.constructor !== U) { + return new U(a); } this.index = a ? [a] : []; this.length = a ? a.length : 0; - const c = this; - return new Proxy([], {get(b, e) { - if ("length" === e) { - return c.length; + const b = this; + return new Proxy([], {get(c, d) { + if ("length" === d) { + return b.length; } - if ("push" === e) { - return function(d) { - c.index[c.index.length - 1].push(d); - c.length++; + if ("push" === d) { + return function(e) { + b.index[b.index.length - 1].push(e); + b.length++; }; } - if ("pop" === e) { + if ("pop" === d) { return function() { - if (c.length) { - return c.length--, c.index[c.index.length - 1].pop(); + if (b.length) { + return b.length--, b.index[b.index.length - 1].pop(); } }; } - if ("indexOf" === e) { - return function(d) { + if ("indexOf" === d) { + return function(e) { let f = 0; - for (let g = 0, k, h; g < c.index.length; g++) { - k = c.index[g]; - h = k.indexOf(d); - if (0 <= h) { - return f + h; + for (let g = 0, h, k; g < b.index.length; g++) { + h = b.index[g]; + k = h.indexOf(e); + if (0 <= k) { + return f + k; } - f += k.length; + f += h.length; } return -1; }; } - if ("includes" === e) { - return function(d) { - for (let f = 0; f < c.index.length; f++) { - if (c.index[f].includes(d)) { + if ("includes" === d) { + return function(e) { + for (let f = 0; f < b.index.length; f++) { + if (b.index[f].includes(e)) { return !0; } } return !1; }; } - if ("slice" === e) { - return function(d, f) { - return Ka(c, d || 0, f || c.length, !1); + if ("slice" === d) { + return function(e, f) { + return Ka(b, e || 0, f || b.length, !1); }; } - if ("splice" === e) { - return function(d, f) { - return Ka(c, d || 0, f || c.length, !0); + if ("splice" === d) { + return function(e, f) { + return Ka(b, e || 0, f || b.length, !0); }; } - if ("constructor" === e) { + if ("constructor" === d) { return Array; } - if ("symbol" !== typeof e) { - return (b = c.index[e / 2 ** 31 | 0]) && b[e]; + if ("symbol" !== typeof d) { + return (c = b.index[d / 2 ** 31 | 0]) && c[d]; } - }, set(b, e, d) { - b = e / 2 ** 31 | 0; - (c.index[b] || (c.index[b] = []))[e] = d; - c.length++; + }, set(c, d, e) { + c = d / 2 ** 31 | 0; + (b.index[c] || (b.index[c] = []))[d] = e; + b.length++; return !0; }}); } -T.prototype.clear = function() { +U.prototype.clear = function() { this.index.length = 0; }; -T.prototype.destroy = function() { +U.prototype.destroy = function() { this.proxy = this.index = null; }; -T.prototype.push = function() { -}; -function U(a = 8) { - if (!this || this.constructor !== U) { - return new U(a); - } - this.index = G(); - this.h = []; - this.size = 0; - 32 < a ? (this.B = Na, this.A = BigInt(a)) : (this.B = Oa, this.A = a); -} -U.prototype.get = function(a) { - const c = this.index[this.B(a)]; - return c && c.get(a); -}; -U.prototype.set = function(a, c) { - var b = this.B(a); - let e = this.index[b]; - e ? (b = e.size, e.set(a, c), (b -= e.size) && this.size++) : (this.index[b] = e = new Map([[a, c]]), this.h.push(e), this.size++); +U.prototype.push = function() { }; function V(a = 8) { if (!this || this.constructor !== V) { return new V(a); } - this.index = G(); + this.index = H(); this.h = []; this.size = 0; - 32 < a ? (this.B = Na, this.A = BigInt(a)) : (this.B = Oa, this.A = a); + 32 < a ? (this.B = La, this.A = BigInt(a)) : (this.B = Oa, this.A = a); } -V.prototype.add = function(a) { +V.prototype.get = function(a) { + const b = this.index[this.B(a)]; + return b && b.get(a); +}; +V.prototype.set = function(a, b) { var c = this.B(a); - let b = this.index[c]; - b ? (c = b.size, b.add(a), (c -= b.size) && this.size++) : (this.index[c] = b = new Set([a]), this.h.push(b), this.size++); + 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.h.push(d), this.size++); }; -v = U.prototype; -v.has = V.prototype.has = function(a) { - const c = this.index[this.B(a)]; - return c && c.has(a); +function W(a = 8) { + if (!this || this.constructor !== W) { + return new W(a); + } + this.index = H(); + this.h = []; + this.size = 0; + 32 < a ? (this.B = La, this.A = BigInt(a)) : (this.B = Oa, this.A = a); +} +W.prototype.add = function(a) { + var b = this.B(a); + let c = this.index[b]; + c ? (b = c.size, c.add(a), (b -= c.size) && this.size++) : (this.index[b] = c = new Set([a]), this.h.push(c), this.size++); }; -v.delete = V.prototype.delete = function(a) { - const c = this.index[this.B(a)]; - c && c.delete(a) && this.size--; +w = V.prototype; +w.has = W.prototype.has = function(a) { + const b = this.index[this.B(a)]; + return b && b.has(a); }; -v.clear = V.prototype.clear = function() { - this.index = G(); +w.delete = W.prototype.delete = function(a) { + const b = this.index[this.B(a)]; + b && b.delete(a) && this.size--; +}; +w.clear = W.prototype.clear = function() { + this.index = H(); this.h = []; this.size = 0; }; -v.values = V.prototype.values = function*() { +w.values = W.prototype.values = function*() { for (let a = 0; a < this.h.length; a++) { - for (let c of this.h[a].values()) { - yield c; + for (let b of this.h[a].values()) { + yield b; } } }; -v.keys = V.prototype.keys = function*() { +w.keys = W.prototype.keys = function*() { for (let a = 0; a < this.h.length; a++) { - for (let c of this.h[a].keys()) { - yield c; + for (let b of this.h[a].keys()) { + yield b; } } }; -v.entries = V.prototype.entries = function*() { +w.entries = W.prototype.entries = function*() { for (let a = 0; a < this.h.length; a++) { - for (let c of this.h[a].entries()) { - yield c; + for (let b of this.h[a].entries()) { + yield b; } } }; function Oa(a) { - let c = 2 ** this.A - 1; + let b = 2 ** this.A - 1; if ("number" == typeof a) { - return a & c; + return a & b; } - let b = 0, e = this.A + 1; - for (let d = 0; d < a.length; d++) { - b = (b * e ^ a.charCodeAt(d)) & c; + let c = 0, d = this.A + 1; + for (let e = 0; e < a.length; e++) { + c = (c * d ^ a.charCodeAt(e)) & b; } - return 32 === this.A ? b + 2 ** 31 : b; + return 32 === this.A ? c + 2 ** 31 : c; } -function Na(a) { - let c = BigInt(2) ** this.A - BigInt(1); - var b = typeof a; - if ("bigint" === b) { - return a & c; +function La(a) { + let b = BigInt(2) ** this.A - BigInt(1); + var c = typeof a; + if ("bigint" === c) { + return a & b; } - if ("number" === b) { - return BigInt(a) & c; + if ("number" === c) { + return BigInt(a) & b; } - b = BigInt(0); - let e = this.A + BigInt(1); - for (let d = 0; d < a.length; d++) { - b = (b * e ^ BigInt(a.charCodeAt(d))) & c; + c = BigInt(0); + let d = this.A + BigInt(1); + for (let e = 0; e < a.length; e++) { + c = (c * d ^ BigInt(a.charCodeAt(e))) & b; } - return b; + return c; } -;Pa.prototype.add = function(a, c, b) { - aa(a) && (c = a, a = ea(c, this.key)); - if (c && (a || 0 === a)) { - if (!b && this.reg.has(a)) { - return this.update(a, c); +;Pa.prototype.add = function(a, b, c) { + aa(a) && (b = a, a = ea(b, this.key)); + if (b && (a || 0 === a)) { + if (!c && this.reg.has(a)) { + return this.update(a, b); } - for (let k = 0, h; k < this.field.length; k++) { - h = this.F[k]; - var e = this.index.get(this.field[k]); - if ("function" === typeof h) { - var d = h(c); - d && e.add(a, d, !1, !0); + for (let h = 0, k; h < this.field.length; h++) { + k = this.F[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 (d = h.I, !d || d(c)) { - h.constructor === String ? h = ["" + h] : L(h) && (h = [h]), Qa(c, h, this.J, 0, e, a, h[0], b); + if (e = k.I, !e || e(b)) { + k.constructor === String ? k = ["" + k] : M(k) && (k = [k]), Qa(b, k, this.J, 0, d, a, k[0], c); } } } if (this.tag) { - for (e = 0; e < this.D.length; e++) { - var f = this.D[e], g = this.R[e]; - d = this.tag.get(g); - let k = G(); + for (d = 0; d < this.D.length; d++) { + var f = this.D[d], g = this.R[d]; + e = this.tag.get(g); + let h = H(); if ("function" === typeof f) { - if (f = f(c), !f) { + if (f = f(b), !f) { continue; } } else { - const h = f.I; - if (h && !h(c)) { + const k = f.I; + if (k && !k(b)) { continue; } f.constructor === String && (f = "" + f); - f = ea(c, f); + f = ea(b, f); } - if (d && f) { - L(f) && (f = [f]); - for (let h = 0, l, m; h < f.length; h++) { - if (l = f[h], !k[l] && (k[l] = 1, (g = d.get(l)) ? m = g : d.set(l, m = []), !b || !m.includes(a))) { + if (e && f) { + M(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 T(m); + g = new U(m); if (this.fastupdate) { - for (let t of this.reg.values()) { - t.includes(m) && (t[t.indexOf(m)] = g); + for (let p of this.reg.values()) { + p.includes(m) && (p[p.indexOf(m)] = g); } } - d.set(l, m = g); + e.set(l, m = g); } m.push(a); this.fastupdate && ((g = this.reg.get(a)) ? g.push(m) : this.reg.set(a, [m])); } } } else { - d || console.warn("Tag '" + g + "' was not found"); + e || console.warn("Tag '" + g + "' was not found"); } } } - if (this.store && (!b || !this.store.has(a))) { - let k; + if (this.store && (!c || !this.store.has(a))) { + let h; if (this.C) { - k = G(); - for (let h = 0, l; h < this.C.length; h++) { - l = this.C[h]; - if ((b = l.I) && !b(c)) { + h = H(); + for (let k = 0, l; k < this.C.length; k++) { + l = this.C[k]; + if ((c = l.I) && !c(b)) { continue; } let m; if ("function" === typeof l) { - m = l(c); + m = l(b); if (!m) { continue; } l = [l.V]; - } else if (L(l) || l.constructor === String) { - k[l] = c[l]; + } else if (M(l) || l.constructor === String) { + h[l] = b[l]; continue; } - Ra(c, k, l, 0, l[0], m); + Ra(b, h, l, 0, l[0], m); } } - this.store.set(a, k || c); + this.store.set(a, h || b); } this.worker && (this.fastupdate || this.reg.add(a)); } return this; }; -function Ra(a, c, b, e, d, f) { - a = a[d]; - if (e === b.length - 1) { - c[d] = f || a; +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 (c = c[d] = Array(a.length), d = 0; d < a.length; d++) { - Ra(a, c, b, e, d); + for (b = b[e] = Array(a.length), e = 0; e < a.length; e++) { + Ra(a, b, c, d, e); } } else { - c = c[d] || (c[d] = G()), d = b[++e], Ra(a, c, b, e, d); + b = b[e] || (b[e] = H()), e = c[++d], Ra(a, b, c, d, e); } } } -function Qa(a, c, b, e, d, f, g, k) { +function Qa(a, b, c, d, e, f, g, h) { if (a = a[g]) { - if (e === c.length - 1) { + if (d === b.length - 1) { if (a.constructor === Array) { - if (b[e]) { - for (c = 0; c < a.length; c++) { - d.add(f, a[c], !0, !0); + if (c[d]) { + for (b = 0; b < a.length; b++) { + e.add(f, a[b], !0, !0); } return; } a = a.join(" "); } - d.add(f, a, k, !0); + e.add(f, a, h, !0); } else { if (a.constructor === Array) { for (g = 0; g < a.length; g++) { - Qa(a, c, b, e, d, f, g, k); + Qa(a, b, c, d, e, f, g, h); } } else { - g = c[++e], Qa(a, c, b, e, d, f, g, k); + g = b[++d], Qa(a, b, c, d, e, f, g, h); } } } else { - d.db && d.remove(f); + e.db && e.remove(f); } } -;function Sa(a, c, b, e, d, f, g) { - const k = a.length; - let h = [], l, m; - l = G(); - for (let t = 0, q, n, r, u; t < c; t++) { - for (let p = 0; p < k; p++) { - if (r = a[p], t < r.length && (q = r[t])) { - for (let z = 0; z < q.length; z++) { - n = q[z]; - (m = l[n]) ? l[n]++ : (m = 0, l[n] = 1); - u = h[m] || (h[m] = []); - if (!g) { - let x = t + (p || !d ? 0 : f || 0); - u = u[x] || (u[x] = []); - } - u.push(n); - if (g && b && m === k - 1 && u.length - e === b) { - return e ? u.slice(e) : u; - } - } - } - } - } - if (a = h.length) { - if (d) { - h = 1 < h.length ? Ta(h, b, e, g, f) : (h = h[0]).length > b || e ? h.slice(e, b + e) : h; - } else { - if (a < k) { - return []; - } - h = h[a - 1]; - if (b || e) { - if (g) { - if (h.length > b || e) { - h = h.slice(e, b + e); - } - } else { - d = []; - for (let t = 0, q; t < h.length; t++) { - if (q = h[t]) { - if (e && q.length > e) { - e -= q.length; - } else { - if (b && q.length > b || e) { - q = q.slice(e, b + e), b -= q.length, e && (e -= q.length); - } - d.push(q); - if (!b) { - break; - } - } - } - } - h = d; - } - } - } - } - return h; -} -function Ta(a, c, b, e, d) { - const f = [], g = G(); - let k; - var h = a.length; - let l; - if (e) { - for (d = h - 1; 0 <= d; d--) { - if (l = (e = a[d]) && e.length) { - for (h = 0; h < l; h++) { - if (k = e[h], !g[k]) { - if (g[k] = 1, b) { - b--; - } else { - if (f.push(k), f.length === c) { - return f; - } - } - } - } - } - } - } else { - for (let m = h - 1, t, q = 0; 0 <= m; m--) { - t = a[m]; - for (let n = 0; n < t.length; n++) { - if (l = (e = t[n]) && e.length) { - for (let r = 0; r < l; r++) { - if (k = e[r], !g[k]) { - if (g[k] = 1, b) { - b--; - } else { - let u = (n + (m < h - 1 ? d || 0 : 0)) / (m + 1) | 0; - (f[u] || (f[u] = [])).push(k); - if (++q === c) { - return f; - } - } - } - } - } - } - } - } - return f; -} -function Ua(a, c, b) { - const e = G(), d = []; - for (let f = 0, g; f < c.length; f++) { - g = c[f]; - for (let k = 0; k < g.length; k++) { - e[g[k]] = 1; - } - } - if (b) { - for (let f = 0, g; f < a.length; f++) { - g = a[f], e[g] && (d.push(g), e[g] = 0); - } - } else { - for (let f = 0, g, k; f < a.result.length; f++) { - for (g = a.result[f], c = 0; c < g.length; c++) { - k = g[c], e[k] && ((d[f] || (d[f] = [])).push(k), e[k] = 0); - } - } - } - return d; -} -;function Va(a, c, b, e) { +;function Sa(a, b, c, d) { if (!a.length) { return a; } if (1 === a.length) { - return a = a[0], a = b || a.length > c ? c ? a.slice(b, b + c) : a.slice(b) : a, e ? X.call(this, a) : a; + return a = a[0], a = c || a.length > b ? b ? a.slice(c, c + b) : a.slice(c) : a, d ? X.call(this, a) : a; } - let d = []; - for (let f = 0, g, k; f < a.length; f++) { - if ((g = a[f]) && (k = g.length)) { - if (b) { - if (b >= k) { - b -= k; + 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; } - b < k && (g = c ? g.slice(b, b + c) : g.slice(b), k = g.length, b = 0); + c < h && (g = b ? g.slice(c, c + b) : g.slice(c), h = g.length, c = 0); } - k > c && (g = g.slice(0, c), k = c); - if (!d.length && k >= c) { - return e ? X.call(this, g) : g; + h > b && (g = g.slice(0, b), h = b); + if (!e.length && h >= b) { + return d ? X.call(this, g) : g; } - d.push(g); - c -= k; - if (!c) { + e.push(g); + b -= h; + if (!b) { break; } } } - d = 1 < d.length ? [].concat.apply([], d) : d[0]; - return e ? X.call(this, d) : d; + e = 1 < e.length ? [].concat.apply([], e) : e[0]; + return d ? X.call(this, e) : e; } -;function Wa(a, c, b) { - var e = b[0]; - if (e.then) { - return Promise.all(b).then(function(q) { - return a[c].apply(a, q); +;function Ta(a, b, c) { + var d = c[0]; + if (d.then) { + return Promise.all(c).then(function(q) { + return a[b].apply(a, q); }); } - if (e[0] && e[0].index) { - return a[c].apply(a, e); + if (d[0] && d[0].index) { + return a[b].apply(a, d); } - e = []; - let d = [], f = 0, g = 0, k, h, l, m, t; - for (let q = 0, n; q < b.length; q++) { - if (n = b[q]) { - let r; - if (n.constructor === Y) { - r = n.result; - } else if (n.constructor === Array) { - r = n; + d = []; + let e = [], f = 0, g = 0, h, k, l, m, p; + for (let q = 0, r; q < c.length; q++) { + if (r = c[q]) { + var u = void 0; + if (r.constructor === Y) { + u = r.result; + } else if (r.constructor === Array) { + u = r; } else { - f = n.limit || 0; - g = n.offset || 0; - l = n.suggest; - h = n.resolve; - k = (m = n.highlight && h) || n.enrich && h; - let u; - n.index && (a.index = u = n.index); - if (n.query || n.tag) { + f = r.limit || 0; + g = r.offset || 0; + l = r.suggest; + k = r.resolve; + h = (m = r.highlight && k) || r.enrich && k; + let n; + r.index ? a.index = n = r.index : n = a.index; + if (r.query || r.tag) { if (!a.index) { throw Error("Resolver can't apply because the corresponding Index was never specified"); } - if (n.field) { + if (u = r.field || r.pluck) { if (!a.index.index) { throw Error("Resolver can't apply because the corresponding Document Index was not specified"); } - u = a.index.index.get(n.field); - if (!u) { - throw Error("Resolver can't apply because the specified Document field '" + n.field + "' was not found"); + n = a.index.index.get(u); + if (!n) { + throw Error("Resolver can't apply because the specified Document Field '" + u + "' was not found"); } } - n.resolve = !1; - r = u.search(n).result; - n.resolve = h; - m && (t = n.query); - } else if (n.and) { - r = a.and(n.and); - } else if (n.or) { - r = a.or(n.or); - } else if (n.xor) { - r = a.xor(n.xor); - } else if (n.not) { - r = a.not(n.not); + r.resolve = !1; + u = n.search(r).result; + r.resolve = k; + m && (p = r.query); + } else if (r.and) { + u = a.and(r.and); + } else if (r.or) { + u = a.or(r.or); + } else if (r.xor) { + u = a.xor(r.xor); + } else if (r.not) { + u = a.not(r.not); } else { continue; } } - if (r.then) { - d.push(r); - } else if (r.length) { - e[q] = r; - } else if (!l && ("and" === c || "xor" === c)) { - e = []; + if (u.then) { + e.push(u); + } else if (u.length) { + d[q] = u; + } else if (!l && ("and" === b || "xor" === b)) { + d = []; break; } } } - return {O:e, P:d, limit:f, offset:g, enrich:k, resolve:h, suggest:l, highlight:m, W:t}; + return {O:d, P:e, limit:f, offset:g, enrich:h, resolve:k, suggest:l, highlight:m, W:p}; } ;Y.prototype.or = function() { - const {O:a, P:c, limit:b, offset:e, enrich:d, resolve:f} = Wa(this, "or", arguments); - return Xa.call(this, a, c, b, e, d, f); + const {O:a, P:b, limit:c, offset:d, enrich:e, resolve:f} = Ta(this, "or", arguments); + return Ua.call(this, a, b, c, d, e, f); }; -function Xa(a, c, b, e, d, f) { - if (c.length) { +function Ua(a, b, c, d, e, f) { + if (b.length) { const g = this; - return Promise.all(c).then(function(k) { + return Promise.all(b).then(function(h) { a = []; - for (let h = 0, l; h < k.length; h++) { - (l = k[h]).length && (a[h] = l); + for (let k = 0, l; k < h.length; k++) { + (l = h[k]).length && (a[k] = l); } - return Xa.call(g, a, [], b, e, d, f); + return Ua.call(g, a, [], c, d, e, f); }); } - a.length && (this.result.length && a.push(this.result), 2 > a.length ? this.result = a[0] : (this.result = Ta(a, b, e, !1, this.h), e = 0)); - return f ? this.resolve(b, e, d) : this; + a.length && (this.result.length && a.push(this.result), 2 > a.length ? this.result = a[0] : (this.result = Va(a, c, d, !1, this.h), d = 0)); + return f ? this.resolve(c, d, e) : this; } ;Y.prototype.and = function() { - let a = this.result.length, c, b, e, d; + let a = this.result.length, b, c, d, e; if (!a) { const f = arguments[0]; - f && (a = !!f.suggest, d = f.resolve, c = f.limit, b = f.offset, e = f.enrich && d); + f && (a = !!f.suggest, e = f.resolve, b = f.limit, c = f.offset, d = f.enrich && e); } if (a) { - const {O:f, P:g, limit:k, offset:h, enrich:l, resolve:m, suggest:t} = Wa(this, "and", arguments); - return Ya.call(this, f, g, k, h, l, m, t); + const {O:f, P:g, limit:h, offset:k, enrich:l, resolve:m, suggest:p} = Ta(this, "and", arguments); + return Wa.call(this, f, g, h, k, l, m, p); } - return d ? this.resolve(c, b, e) : this; + return e ? this.resolve(b, c, d) : this; }; -function Ya(a, c, b, e, d, f, g) { - if (c.length) { - const k = this; - return Promise.all(c).then(function(h) { +function Wa(a, b, c, d, e, f, g) { + if (b.length) { + const h = this; + return Promise.all(b).then(function(k) { a = []; - for (let l = 0, m; l < h.length; l++) { - (m = h[l]).length && (a[l] = m); + for (let l = 0, m; l < k.length; l++) { + (m = k[l]).length && (a[l] = m); } - return Ya.call(k, a, [], b, e, d, f, g); + return Wa.call(h, a, [], c, d, e, f, g); }); } if (a.length) { if (this.result.length && a.unshift(this.result), 2 > a.length) { this.result = a[0]; } else { - if (c = fa(a)) { - return this.result = Sa(a, c, b, e, g, this.h, f), f ? d ? X.call(this.index, this.result) : this.result : this; + if (b = fa(a)) { + return this.result = Xa(a, b, c, d, g, this.h, f), f ? e ? X.call(this.index, this.result) : this.result : this; } this.result = []; } } else { g || (this.result = a); } - return f ? this.resolve(b, e, d) : this; + return f ? this.resolve(c, d, e) : this; } ;Y.prototype.xor = function() { - const {O:a, P:c, limit:b, offset:e, enrich:d, resolve:f, suggest:g} = Wa(this, "xor", arguments); - return Za.call(this, a, c, b, e, d, f, g); + const {O:a, P:b, limit:c, offset:d, enrich:e, resolve:f, suggest:g} = Ta(this, "xor", arguments); + return Ya.call(this, a, b, c, d, e, f, g); }; -function Za(a, c, b, e, d, f, g) { - if (c.length) { - const k = this; - return Promise.all(c).then(function(h) { +function Ya(a, b, c, d, e, f, g) { + if (b.length) { + const h = this; + return Promise.all(b).then(function(k) { a = []; - for (let l = 0, m; l < h.length; l++) { - (m = h[l]).length && (a[l] = m); + for (let l = 0, m; l < k.length; l++) { + (m = k[l]).length && (a[l] = m); } - return Za.call(k, a, [], b, e, d, f, g); + return Ya.call(h, a, [], c, d, e, f, g); }); } if (a.length) { if (this.result.length && a.unshift(this.result), 2 > a.length) { this.result = a[0]; } else { - return this.result = $a.call(this, a, b, e, f, this.h), f ? d ? X.call(this.index, this.result) : this.result : this; + return this.result = Za.call(this, a, c, d, f, this.h), f ? e ? X.call(this.index, this.result) : this.result : this; } } else { g || (this.result = a); } - return f ? this.resolve(b, e, d) : this; + return f ? this.resolve(c, d, e) : this; } -function $a(a, c, b, e, d) { - const f = [], g = G(); - let k = 0; - for (let h = 0, l; h < a.length; h++) { - if (l = a[h]) { - k < l.length && (k = l.length); - for (let m = 0, t; m < l.length; m++) { - if (t = l[m]) { - for (let q = 0, n; q < t.length; q++) { - n = t[q], g[n] = g[n] ? 2 : 1; +function Za(a, b, c, d, e) { + const f = [], g = H(); + let h = 0; + for (let k = 0, l; k < a.length; k++) { + if (l = a[k]) { + h < l.length && (h = l.length); + for (let m = 0, p; m < l.length; m++) { + if (p = l[m]) { + for (let u = 0, q; u < p.length; u++) { + q = p[u], g[q] = g[q] ? 2 : 1; } } } } } - for (let h = 0, l, m = 0; h < k; h++) { - for (let t = 0, q; t < a.length; t++) { - if (q = a[t]) { - if (l = q[h]) { - for (let n = 0, r; n < l.length; n++) { - if (r = l[n], 1 === g[r]) { - if (b) { - b--; + for (let k = 0, l, m = 0; k < h; k++) { + for (let p = 0, u; p < a.length; p++) { + if (u = a[p]) { + if (l = u[k]) { + for (let q = 0, r; q < l.length; q++) { + if (r = l[q], 1 === g[r]) { + if (c) { + c--; } else { - if (e) { - if (f.push(r), f.length === c) { + if (d) { + if (f.push(r), f.length === b) { return f; } } else { - const u = h + (t ? d : 0); - f[u] || (f[u] = []); - f[u].push(r); - if (++m === c) { + const n = k + (p ? e : 0); + f[n] || (f[n] = []); + f[n].push(r); + if (++m === b) { return f; } } @@ -1171,44 +1046,44 @@ function $a(a, c, b, e, d) { return f; } ;Y.prototype.not = function() { - const {O:a, P:c, limit:b, offset:e, enrich:d, resolve:f, suggest:g} = Wa(this, "not", arguments); - return ab.call(this, a, c, b, e, d, f, g); + const {O:a, P:b, limit:c, offset:d, enrich:e, resolve:f, suggest:g} = Ta(this, "not", arguments); + return $a.call(this, a, b, c, d, e, f, g); }; -function ab(a, c, b, e, d, f, g) { - if (c.length) { - const k = this; - return Promise.all(c).then(function(h) { +function $a(a, b, c, d, e, f, g) { + if (b.length) { + const h = this; + return Promise.all(b).then(function(k) { a = []; - for (let l = 0, m; l < h.length; l++) { - (m = h[l]).length && (a[l] = m); + for (let l = 0, m; l < k.length; l++) { + (m = k[l]).length && (a[l] = m); } - return ab.call(k, a, [], b, e, d, f, g); + return $a.call(h, a, [], c, d, e, f, g); }); } if (a.length && this.result.length) { - this.result = bb.call(this, a, b, e, f); + this.result = ab.call(this, a, c, d, f); } else if (f) { - return this.resolve(b, e, d); + return this.resolve(c, d, e); } - return f ? d ? X.call(this.index, this.result) : this.result : this; + return f ? e ? X.call(this.index, this.result) : this.result : this; } -function bb(a, c, b, e) { - const d = []; +function ab(a, b, c, d) { + const e = []; a = new Set(a.flat().flat()); - for (let f = 0, g, k = 0; f < this.result.length; f++) { + for (let f = 0, g, h = 0; f < this.result.length; f++) { if (g = this.result[f]) { - for (let h = 0, l; h < g.length; h++) { - if (l = g[h], !a.has(l)) { - if (b) { - b--; + for (let k = 0, l; k < g.length; k++) { + if (l = g[k], !a.has(l)) { + if (c) { + c--; } else { - if (e) { - if (d.push(l), d.length === c) { - return d; + if (d) { + if (e.push(l), e.length === b) { + return e; } } else { - if (d[f] || (d[f] = []), d[f].push(l), ++k === c) { - return d; + if (e[f] || (e[f] = []), e[f].push(l), ++h === b) { + return e; } } } @@ -1216,11 +1091,11 @@ function bb(a, c, b, e) { } } } - return d; + return e; } -;function cb(a, c, b, e, d) { - let f, g, k; - "string" === typeof d ? (f = d, d = "") : f = d.template; +;function bb(a, b, c, d, e) { + let f, g, h; + "string" === typeof e ? (f = e, e = "") : f = e.template; if (!f) { throw Error('No template pattern was specified by the search option "highlight"'); } @@ -1228,268 +1103,268 @@ function bb(a, c, b, e) { if (-1 === g) { throw Error('Invalid highlight template. The replacement pattern "$1" was not found in template: ' + f); } - k = f.substring(g + 2); + h = f.substring(g + 2); g = f.substring(0, g); - let h = d && d.boundary, l = !d || !1 !== d.clip, m = d && d.merge && k && g && new RegExp(k + " " + g, "g"); - d = d && d.ellipsis; - var t = 0; - if ("object" === typeof d) { - var q = d.template; - t = q.length - 2; - d = d.pattern; + let k = e && e.boundary, l = !e || !1 !== e.clip, m = e && e.merge && h && g && new RegExp(h + " " + g, "g"); + e = e && e.ellipsis; + var p = 0; + if ("object" === typeof e) { + var u = e.template; + p = u.length - 2; + e = e.pattern; } - "string" !== typeof d && (d = !1 === d ? "" : "..."); - t && (d = q.replace("$1", d)); - q = d.length - t; - let n, r; - "object" === typeof h && (n = h.before, 0 === n && (n = -1), r = h.after, 0 === r && (r = -1), h = h.total || 9e5); - t = new Map(); - for (let La = 0, ba, hb, na; La < c.length; La++) { + "string" !== typeof e && (e = !1 === e ? "" : "..."); + p && (e = u.replace("$1", e)); + u = e.length - p; + let q, r; + "object" === typeof k && (q = k.before, 0 === q && (q = -1), r = k.after, 0 === r && (r = -1), k = k.total || 9e5); + p = new Map(); + for (let Ma = 0, ba, ib, na; Ma < b.length; Ma++) { let oa; - if (e) { - oa = c, na = e; + if (d) { + oa = b, na = d; } else { - var u = c[La]; - na = u.field; + var n = b[Ma]; + na = n.field; if (!na) { continue; } - oa = u.result; + oa = n.result; } - hb = b.get(na); - ba = hb.encoder; - u = t.get(ba); - "string" !== typeof u && (u = ba.encode(a), t.set(ba, u)); - for (let va = 0; va < oa.length; va++) { - var p = oa[va].doc; - if (!p) { + ib = c.get(na); + ba = ib.encoder; + n = p.get(ba); + "string" !== typeof n && (n = ba.encode(a), p.set(ba, n)); + for (let wa = 0; wa < oa.length; wa++) { + var t = oa[wa].doc; + if (!t) { continue; } - p = ea(p, na); - if (!p) { + t = ea(t, na); + if (!t) { continue; } - var z = p.trim().split(/\s+/); - if (!z.length) { + var x = t.trim().split(/\s+/); + if (!x.length) { continue; } - p = ""; - var x = []; - let wa = []; - var J = -1, B = -1, y = 0; - for (var A = 0; A < z.length; A++) { - var E = z[A], D = ba.encode(E); - D = 1 < D.length ? D.join(" ") : D[0]; - let w; - if (D && E) { - var C = E.length, H = (ba.split ? E.replace(ba.split, "") : E).length - D.length, M = "", W = 0; - for (var ca = 0; ca < u.length; ca++) { - var Q = u[ca]; + t = ""; + var y = []; + let xa = []; + var D = -1, G = -1, B = 0; + for (var v = 0; v < x.length; v++) { + var A = x[v], I = ba.encode(A); + I = 1 < I.length ? I.join(" ") : I[0]; + let z; + if (I && A) { + var C = A.length, J = (ba.split ? A.replace(ba.split, "") : A).length - I.length, F = "", S = 0; + for (var ca = 0; ca < n.length; ca++) { + var Q = n[ca]; if (Q) { - var K = Q.length; - K += H; - W && K <= W || (Q = D.indexOf(Q), -1 < Q && (M = (Q ? E.substring(0, Q) : "") + g + E.substring(Q, Q + K) + k + (Q + K < C ? E.substring(Q + K) : ""), W = K, w = !0)); + var L = Q.length; + L += J; + S && L <= S || (Q = I.indexOf(Q), -1 < Q && (F = (Q ? A.substring(0, Q) : "") + g + A.substring(Q, Q + L) + h + (Q + L < C ? A.substring(Q + L) : ""), S = L, z = !0)); } } - M && (h && (0 > J && (J = p.length + (p ? 1 : 0)), B = p.length + (p ? 1 : 0) + M.length, y += C, wa.push(x.length), x.push({match:M})), p += (p ? " " : "") + M); + F && (k && (0 > D && (D = t.length + (t ? 1 : 0)), G = t.length + (t ? 1 : 0) + F.length, B += C, xa.push(y.length), y.push({match:F})), t += (t ? " " : "") + F); } - if (!w) { - E = z[A], p += (p ? " " : "") + E, h && x.push({text:E}); - } else if (h && y >= h) { + if (!z) { + A = x[v], t += (t ? " " : "") + A, k && y.push({text:A}); + } else if (k && B >= k) { break; } } - y = wa.length * (f.length - 2); - if (n || r || h && p.length - y > h) { - if (y = h + y - 2 * q, A = B - J, 0 < n && (A += n), 0 < r && (A += r), A <= y) { - z = n ? J - (0 < n ? n : 0) : J - ((y - A) / 2 | 0), x = r ? B + (0 < r ? r : 0) : z + y, l || (0 < z && " " !== p.charAt(z) && " " !== p.charAt(z - 1) && (z = p.indexOf(" ", z), 0 > z && (z = 0)), x < p.length && " " !== p.charAt(x - 1) && " " !== p.charAt(x) && (x = p.lastIndexOf(" ", x), x < B ? x = B : ++x)), p = (z ? d : "") + p.substring(z, x) + (x < p.length ? d : ""); + B = xa.length * (f.length - 2); + if (q || r || k && t.length - B > k) { + if (B = k + B - 2 * u, v = G - D, 0 < q && (v += q), 0 < r && (v += r), v <= B) { + x = q ? D - (0 < q ? q : 0) : D - ((B - v) / 2 | 0), y = r ? G + (0 < r ? r : 0) : x + B, l || (0 < x && " " !== t.charAt(x) && " " !== t.charAt(x - 1) && (x = t.indexOf(" ", x), 0 > x && (x = 0)), y < t.length && " " !== t.charAt(y - 1) && " " !== t.charAt(y) && (y = t.lastIndexOf(" ", y), y < G ? y = G : ++y)), t = (x ? e : "") + t.substring(x, y) + (y < t.length ? e : ""); } else { - B = []; - J = {}; - y = {}; - A = {}; - E = {}; + G = []; D = {}; - M = H = C = 0; - for (ca = W = 1;;) { - var S = void 0; - for (let w = 0, I; w < wa.length; w++) { - I = wa[w]; - if (M) { - if (H !== M) { - if (A[w + 1]) { + B = {}; + v = {}; + A = {}; + I = {}; + F = J = C = 0; + for (ca = S = 1;;) { + var T = void 0; + for (let z = 0, K; z < xa.length; z++) { + K = xa[z]; + if (F) { + if (J !== F) { + if (v[z + 1]) { continue; } - I += M; - if (J[I]) { - C -= q; - y[w + 1] = 1; - A[w + 1] = 1; + K += F; + if (D[K]) { + C -= u; + B[z + 1] = 1; + v[z + 1] = 1; continue; } - if (I >= x.length - 1) { - if (I >= x.length) { - A[w + 1] = 1; - I >= z.length && (y[w + 1] = 1); + if (K >= y.length - 1) { + if (K >= y.length) { + v[z + 1] = 1; + K >= x.length && (B[z + 1] = 1); continue; } - C -= q; + C -= u; } - p = x[I].text; - if (K = r && D[w]) { - if (0 < K) { - if (p.length > K) { - if (A[w + 1] = 1, l) { - p = p.substring(0, K); + t = y[K].text; + if (L = r && I[z]) { + if (0 < L) { + if (t.length > L) { + if (v[z + 1] = 1, l) { + t = t.substring(0, L); } else { continue; } } - (K -= p.length) || (K = -1); - D[w] = K; + (L -= t.length) || (L = -1); + I[z] = L; } else { - A[w + 1] = 1; + v[z + 1] = 1; continue; } } - if (C + p.length + 1 <= h) { - p = " " + p, B[w] += p; + if (C + t.length + 1 <= k) { + t = " " + t, G[z] += t; } else if (l) { - S = h - C - 1, 0 < S && (p = " " + p.substring(0, S), B[w] += p), A[w + 1] = 1; + T = k - C - 1, 0 < T && (t = " " + t.substring(0, T), G[z] += t), v[z + 1] = 1; } else { - A[w + 1] = 1; + v[z + 1] = 1; continue; } } else { - if (A[w]) { + if (v[z]) { continue; } - I -= H; - if (J[I]) { - C -= q; - A[w] = 1; - y[w] = 1; + K -= J; + if (D[K]) { + C -= u; + v[z] = 1; + B[z] = 1; continue; } - if (0 >= I) { - if (0 > I) { - A[w] = 1; - y[w] = 1; + if (0 >= K) { + if (0 > K) { + v[z] = 1; + B[z] = 1; continue; } - C -= q; + C -= u; } - p = x[I].text; - if (K = n && E[w]) { - if (0 < K) { - if (p.length > K) { - if (A[w] = 1, l) { - p = p.substring(p.length - K); + t = y[K].text; + if (L = q && A[z]) { + if (0 < L) { + if (t.length > L) { + if (v[z] = 1, l) { + t = t.substring(t.length - L); } else { continue; } } - (K -= p.length) || (K = -1); - E[w] = K; + (L -= t.length) || (L = -1); + A[z] = L; } else { - A[w] = 1; + v[z] = 1; continue; } } - if (C + p.length + 1 <= h) { - p += " ", B[w] = p + B[w]; + if (C + t.length + 1 <= k) { + t += " ", G[z] = t + G[z]; } else if (l) { - S = p.length + 1 - (h - C), 0 <= S && S < p.length && (p = p.substring(S) + " ", B[w] = p + B[w]), A[w] = 1; + T = t.length + 1 - (k - C), 0 <= T && T < t.length && (t = t.substring(T) + " ", G[z] = t + G[z]), v[z] = 1; } else { - A[w] = 1; + v[z] = 1; continue; } } } else { - p = x[I].match; - n && (E[w] = n); - r && (D[w] = r); - w && C++; - let Ma; - I ? !w && q && (C += q) : (y[w] = 1, A[w] = 1); - I >= z.length - 1 ? Ma = 1 : I < x.length - 1 && x[I + 1].match ? Ma = 1 : q && (C += q); + t = y[K].match; + q && (A[z] = q); + r && (I[z] = r); + z && C++; + let Na; + K ? !z && u && (C += u) : (B[z] = 1, v[z] = 1); + K >= x.length - 1 ? Na = 1 : K < y.length - 1 && y[K + 1].match ? Na = 1 : u && (C += u); C -= f.length - 2; - if (!w || C + p.length <= h) { - B[w] = p; + if (!z || C + t.length <= k) { + G[z] = t; } else { - S = W = ca = y[w] = 0; + T = S = ca = B[z] = 0; break; } - Ma && (y[w + 1] = 1, A[w + 1] = 1); + Na && (B[z + 1] = 1, v[z + 1] = 1); } - C += p.length; - S = J[I] = 1; + C += t.length; + T = D[K] = 1; } - if (S) { - H === M ? M++ : H++; + if (T) { + J === F ? F++ : J++; } else { - H === M ? W = 0 : ca = 0; - if (!W && !ca) { + J === F ? S = 0 : ca = 0; + if (!S && !ca) { break; } - W ? (H++, M = H) : M++; + S ? (J++, F = J) : F++; } } - p = ""; - for (let w = 0, I; w < B.length; w++) { - I = (w && y[w] ? " " : (w && !d ? " " : "") + d) + B[w], p += I; + t = ""; + for (let z = 0, K; z < G.length; z++) { + K = (z && B[z] ? " " : (z && !e ? " " : "") + e) + G[z], t += K; } - d && !y[B.length] && (p += d); + e && !B[G.length] && (t += e); } } - m && (p = p.replace(m, " ")); - oa[va].highlight = p; + m && (t = t.replace(m, " ")); + oa[wa].highlight = t; } - if (e) { + if (d) { break; } } - return c; + return b; } -;function Y(a, c) { +;function Y(a, b) { if (!this || this.constructor !== Y) { - return new Y(a, c); + return new Y(a, b); } if (a && a.index) { return a.resolve = !1, this.index = a.index, this.h = a.boost || 0, this.result = this.index.search(a).result, this; } - this.index = c || null; + this.index = b || null; this.result = a || []; this.h = 0; } Y.prototype.limit = function(a) { if (this.result.length) { - const c = []; - for (let b = 0, e; b < this.result.length; b++) { - if (e = this.result[b]) { - if (e.length <= a) { - if (c[b] = e, a -= e.length, !a) { + const b = []; + for (let c = 0, d; c < this.result.length; c++) { + if (d = this.result[c]) { + if (d.length <= a) { + if (b[c] = d, a -= d.length, !a) { break; } } else { - c[b] = e.slice(0, a); + b[c] = d.slice(0, a); break; } } } - this.result = c; + this.result = b; } return this; }; Y.prototype.offset = function(a) { if (this.result.length) { - const c = []; - for (let b = 0, e; b < this.result.length; b++) { - if (e = this.result[b]) { - e.length <= a ? a -= e.length : (c[b] = e.slice(a), a = 0); + const b = []; + for (let c = 0, d; c < this.result.length; c++) { + if (d = this.result[c]) { + d.length <= a ? a -= d.length : (b[c] = d.slice(a), a = 0); } } - this.result = c; + this.result = b; } return this; }; @@ -1497,250 +1372,378 @@ Y.prototype.boost = function(a) { this.h += a; return this; }; -Y.prototype.resolve = function(a, c, b) { - const e = this.index; - let d = this.result; +Y.prototype.resolve = function(a, b, c) { + const d = this.index; + let e = this.result; this.result = this.index = null; - d.length && ("object" === typeof a && (b = a.enrich, c = a.offset, a = a.limit), d = Va.call(e, d, a || 100, c, b)); - return d; + e.length && ("object" === typeof a && (c = a.enrich, b = a.offset, a = a.limit), e = Sa.call(d, e, a || 100, b, c)); + return e; }; -G(); -Pa.prototype.search = function(a, c, b, e) { - b || (!c && aa(a) ? (b = a, a = "") : aa(c) && (b = c, c = 0)); - if (b && b.cache) { - b.cache = !1; - var d = this.searchCache(a, c, b); - b.cache = !0; - return d; +function Xa(a, b, c, d, e, f, g) { + const h = a.length; + let k = [], l, m; + l = H(); + for (let p = 0, u, q, r, n; p < b; p++) { + for (let t = 0; t < h; t++) { + if (r = a[t], p < r.length && (u = r[p])) { + for (let x = 0; x < u.length; x++) { + q = u[x]; + (m = l[q]) ? l[q]++ : (m = 0, l[q] = 1); + n = k[m] || (k[m] = []); + if (!g) { + let y = p + (t || !e ? 0 : f || 0); + n = n[y] || (n[y] = []); + } + n.push(q); + if (g && c && m === h - 1 && n.length - d === c) { + return d ? n.slice(d) : n; + } + } + } + } + } + if (a = k.length) { + if (e) { + k = 1 < k.length ? Va(k, c, d, g, f) : (k = k[0]).length > c || d ? k.slice(d, c + d) : k; + } else { + if (a < h) { + return []; + } + k = k[a - 1]; + if (c || d) { + if (g) { + if (k.length > c || d) { + k = k.slice(d, c + d); + } + } else { + e = []; + for (let p = 0, u; p < k.length; p++) { + if (u = k[p]) { + if (d && u.length > d) { + d -= u.length; + } else { + if (c && u.length > c || d) { + u = u.slice(d, c + d), c -= u.length, d && (d -= u.length); + } + e.push(u); + if (!c) { + break; + } + } + } + } + k = e; + } + } + } + } + return k; +} +function Va(a, b, c, d, e) { + const f = [], g = H(); + let h; + var k = a.length; + let l; + if (d) { + for (e = k - 1; 0 <= e; e--) { + if (l = (d = a[e]) && d.length) { + for (k = 0; k < l; k++) { + if (h = d[k], !g[h]) { + if (g[h] = 1, c) { + c--; + } else { + if (f.push(h), f.length === b) { + return f; + } + } + } + } + } + } + } else { + for (let m = k - 1, p, u = 0; 0 <= m; m--) { + p = a[m]; + for (let q = 0; q < p.length; q++) { + if (l = (d = p[q]) && d.length) { + for (let r = 0; r < l; r++) { + if (h = d[r], !g[h]) { + if (g[h] = 1, c) { + c--; + } else { + let n = (q + (m < k - 1 ? e || 0 : 0)) / (m + 1) | 0; + (f[n] || (f[n] = [])).push(h); + if (++u === b) { + return f; + } + } + } + } + } + } + } + } + return f; +} +function cb(a, b, c) { + const d = H(), e = []; + for (let f = 0, g; f < b.length; f++) { + g = b[f]; + for (let h = 0; h < g.length; h++) { + d[g[h]] = 1; + } + } + if (c) { + for (let f = 0, g; f < a.length; f++) { + g = a[f], d[g] && (e.push(g), d[g] = 0); + } + } else { + for (let f = 0, g, h; f < a.result.length; f++) { + for (g = a.result[f], b = 0; b < g.length; b++) { + h = g[b], d[h] && ((e[f] || (e[f] = [])).push(h), d[h] = 0); + } + } + } + return e; +} +;H(); +Pa.prototype.search = function(a, b, c, d) { + c || (!b && aa(a) ? (c = a, a = "") : aa(b) && (c = b, b = 0)); + if (c && c.cache) { + c.cache = !1; + var e = this.searchCache(a, b, c); + c.cache = !0; + return e; } let f = []; var g = []; - let k, h; - let l, m; - let t = 0; - var q = !0; - let n; - if (b) { - b.constructor === Array && (b = {index:b}); - a = b.query || a; - k = b.pluck; - h = b.merge; - l = k || b.field || (l = b.index) && (l.index ? null : l); - m = this.tag && b.tag; - var r = b.suggest; - q = !1 !== b.resolve; - if (!q && !k) { - if (l = l || this.field) { - L(l) ? k = l : (l.constructor === Array && 1 === l.length && (l = l[0]), k = l.field || l.index); + let h, k, l, m, p; + let u = 0, q = !0, r; + if (c) { + c.constructor === Array && (c = {index:c}); + a = c.query || a; + h = c.pluck; + k = c.merge; + m = c.boost; + p = h || c.field || (p = c.index) && (p.index ? null : p); + var n = this.tag && c.tag; + l = c.suggest; + q = !1 !== c.resolve; + this.store && c.highlight && !q ? console.warn("Highlighting results can only be done on a final resolver task or when calling .resolve({ highlight: ... })") : this.store && c.enrich && !q && console.warn("Enrich results can only be done on a final resolver task or when calling .resolve({ enrich: true })"); + r = q && this.store && c.highlight; + e = !!r || q && this.store && c.enrich; + b = c.limit || b; + var t = c.offset || 0; + b || (b = q ? 100 : 0); + if (n && (!this.db || !d)) { + n.constructor !== Array && (n = [n]); + var x = []; + for (let B = 0, v; B < n.length; B++) { + v = n[B]; + if (M(v)) { + throw Error("A tag option can't be a string, instead it needs a { field: tag } format."); + } + if (v.field && v.tag) { + var y = v.tag; + if (y.constructor === Array) { + for (var D = 0; D < y.length; D++) { + x.push(v.field, y[D]); + } + } else { + x.push(v.field, y); + } + } else { + y = Object.keys(v); + for (let A = 0, I, C; A < y.length; A++) { + if (I = y[A], C = v[I], C.constructor === Array) { + for (D = 0; D < C.length; D++) { + x.push(I, C[D]); + } + } else { + x.push(I, C); + } + } + } } - if (!k) { + if (!x.length) { + throw Error("Your tag definition within the search options is probably wrong. No valid tags found."); + } + n = x; + if (!a) { + g = []; + if (x.length) { + for (n = 0; n < x.length; n += 2) { + if (this.db) { + d = this.index.get(x[n]); + if (!d) { + console.warn("Tag '" + x[n] + ":" + x[n + 1] + "' will be skipped because there is no field '" + x[n] + "'."); + continue; + } + g.push(d = d.db.tag(x[n + 1], b, t, e)); + } else { + d = db.call(this, x[n], x[n + 1], b, t, e); + } + f.push(q ? {field:x[n], tag:x[n + 1], result:d} : [d]); + } + } + if (g.length) { + const B = this; + return Promise.all(g).then(function(v) { + for (let A = 0; A < v.length; A++) { + q ? f[A].result = v[A] : f[A] = v[A]; + } + return q ? f : new Y(1 < f.length ? Xa(f, 1, 0, 0, l, m) : f[0], B); + }); + } + return q ? f : new Y(1 < f.length ? Xa(f, 1, 0, 0, l, m) : f[0], this); + } + } + if (!q && !h) { + if (p = p || this.field) { + M(p) ? h = p : (p.constructor === Array && 1 === p.length && (p = p[0]), h = p.field || p.index); + } + if (!h) { throw Error("Apply resolver on document search requires either the option 'pluck' to be set or just select a single field name in your query."); } } - this.store && b.highlight && !q ? console.warn("Highlighting results can only be done on a final resolver task or when calling .resolve({ highlight: ... })") : this.store && b.enrich && !q && console.warn("Enrich results can only be done on a final resolver task or when calling .resolve({ enrich: true })"); - n = q && this.store && b.highlight; - d = !!n || q && this.store && b.enrich; - c = b.limit || c; - var u = b.offset || 0; - c || (c = 100); - if (m && (!this.db || !e)) { - m.constructor !== Array && (m = [m]); - var p = []; - for (let B = 0, y; B < m.length; B++) { - y = m[B]; - if (L(y)) { - throw Error("A tag option can't be a string, instead it needs a { field: tag } format."); - } - if (y.field && y.tag) { - var z = y.tag; - if (z.constructor === Array) { - for (var x = 0; x < z.length; x++) { - p.push(y.field, z[x]); - } - } else { - p.push(y.field, z); - } - } else { - z = Object.keys(y); - for (let A = 0, E, D; A < z.length; A++) { - if (E = z[A], D = y[E], D.constructor === Array) { - for (x = 0; x < D.length; x++) { - p.push(E, D[x]); - } - } else { - p.push(E, D); - } - } - } - } - if (!p.length) { - throw Error("Your tag definition within the search options is probably wrong. No valid tags found."); - } - m = p; - if (!a) { - q = []; - if (p.length) { - for (g = 0; g < p.length; g += 2) { - if (this.db) { - r = this.index.get(p[g]); - if (!r) { - console.warn("Tag '" + p[g] + ":" + p[g + 1] + "' will be skipped because there is no field '" + p[g] + "'."); - continue; - } - q.push(r = r.db.tag(p[g + 1], c, u, d)); - } else { - r = db.call(this, p[g], p[g + 1], c, u, d); - } - f.push({field:p[g], tag:p[g + 1], result:r}); - } - } - return q.length ? Promise.all(q).then(function(B) { - for (let y = 0; y < B.length; y++) { - f[y].result = B[y]; - } - return f; - }) : f; - } - } - l && l.constructor !== Array && (l = [l]); + p && p.constructor !== Array && (p = [p]); } - l || (l = this.field); - let J; - p = (this.worker || this.db) && !e && []; - for (let B = 0, y, A, E; B < l.length; B++) { - A = l[B]; + p || (p = this.field); + let G; + x = (this.worker || this.db) && !d && []; + for (let B = 0, v, A, I; B < p.length; B++) { + A = p[B]; if (this.db && this.tag && !this.F[B]) { continue; } - let D; - L(A) || (D = A, A = D.field, a = D.query || a, c = eb(D.limit, c), u = eb(D.offset, u), r = eb(D.suggest, r), n = q && this.store && eb(D.highlight, n), d = !!n || q && this.store && eb(D.enrich, d)); - if (e) { - y = e[B]; + let C; + M(A) || (C = A, A = C.field, a = C.query || a, b = eb(C.limit, b), t = eb(C.offset, t), l = eb(C.suggest, l), r = q && this.store && eb(C.highlight, r), e = !!r || q && this.store && eb(C.enrich, e)); + if (d) { + v = d[B]; } else { - if (z = D || b, x = this.index.get(A), m && (this.db && (z.tag = m, J = x.db.support_tag_search, z.field = l), J || (z.enrich = !1)), p) { - p[B] = x.search(a, c, z); - z && d && (z.enrich = d); + if (y = C || c, D = this.index.get(A), n && (this.db && (y.tag = n, G = D.db.support_tag_search, y.field = p), G || (y.enrich = !1)), x) { + x[B] = D.search(a, b, y); + y && e && (y.enrich = e); continue; } else { - y = x.search(a, c, z), z && d && (z.enrich = d); + v = D.search(a, b, y), y && e && (y.enrich = e); } } - E = y && (q ? y.length : y.result.length); - if (m && E) { - z = []; - x = 0; - if (this.db && e) { - if (!J) { - for (let C = l.length; C < e.length; C++) { - let H = e[C]; - if (H && H.length) { - x++, z.push(H); - } else if (!r) { + I = v && (q ? v.length : v.result.length); + if (n && I) { + y = []; + D = 0; + if (this.db && d) { + if (!G) { + for (let J = p.length; J < d.length; J++) { + let F = d[J]; + if (F && F.length) { + D++, y.push(F); + } else if (!l) { return q ? f : new Y(f, this); } } } } else { - for (let C = 0, H, M; C < m.length; C += 2) { - H = this.tag.get(m[C]); - if (!H) { - if (console.warn("Tag '" + m[C] + ":" + m[C + 1] + "' will be skipped because there is no field '" + m[C] + "'."), r) { + for (let J = 0, F, S; J < n.length; J += 2) { + F = this.tag.get(n[J]); + if (!F) { + if (console.warn("Tag '" + n[J] + ":" + n[J + 1] + "' will be skipped because there is no field '" + n[J] + "'."), l) { continue; } else { return q ? f : new Y(f, this); } } - if (M = (H = H && H.get(m[C + 1])) && H.length) { - x++, z.push(H); - } else if (!r) { + if (S = (F = F && F.get(n[J + 1])) && F.length) { + D++, y.push(F); + } else if (!l) { return q ? f : new Y(f, this); } } } - if (x) { - y = Ua(y, z, q); - E = y.length; - if (!E && !r) { - return q ? y : new Y(y, this); + if (D) { + v = cb(v, y, q); + I = v.length; + if (!I && !l) { + return q ? v : new Y(v, this); } - x--; + D--; } } - if (E) { - g[t] = A, f.push(y), t++; - } else if (1 === l.length) { + if (I) { + g[u] = A, f.push(v), u++; + } else if (1 === p.length) { return q ? f : new Y(f, this); } } - if (p) { - if (this.db && m && m.length && !J) { - for (d = 0; d < m.length; d += 2) { - g = this.index.get(m[d]); + if (x) { + if (this.db && n && n.length && !G) { + for (e = 0; e < n.length; e += 2) { + g = this.index.get(n[e]); if (!g) { - if (console.warn("Tag '" + m[d] + ":" + m[d + 1] + "' was not found because there is no field '" + m[d] + "'."), r) { + if (console.warn("Tag '" + n[e] + ":" + n[e + 1] + "' was not found because there is no field '" + n[e] + "'."), l) { continue; } else { return q ? f : new Y(f, this); } } - p.push(g.db.tag(m[d + 1], c, u, !1)); + x.push(g.db.tag(n[e + 1], b, t, !1)); } } const B = this; - return Promise.all(p).then(function(y) { - return y.length ? B.search(a, c, b, y) : y; + return Promise.all(x).then(function(v) { + return v.length ? B.search(a, b, c, v) : v; }); } - if (!t) { + if (!u) { return q ? f : new Y(f, this); } - if (k && (!d || !this.store)) { + if (h && (!e || !this.store)) { return f = f[0], q || (f.index = this), f; } - p = []; - for (u = 0; u < g.length; u++) { - r = f[u]; - d && r.length && "undefined" === typeof r[0].doc && (this.db ? p.push(r = this.index.get(this.field[0]).db.enrich(r)) : r = X.call(this, r)); - if (k) { - return q ? n ? cb(a, r, this.index, k, n) : r : new Y(r, this); + x = []; + for (t = 0; t < g.length; t++) { + n = f[t]; + e && n.length && "undefined" === typeof n[0].doc && (this.db ? x.push(n = this.index.get(this.field[0]).db.enrich(n)) : n = X.call(this, n)); + if (h) { + return q ? r ? bb(a, n, this.index, h, r) : n : new Y(n, this); } - f[u] = {field:g[u], result:r}; + f[t] = {field:g[t], result:n}; } - if (d && this.db && p.length) { + if (e && this.db && x.length) { const B = this; - return Promise.all(p).then(function(y) { - for (let A = 0; A < y.length; A++) { - f[A].result = y[A]; + return Promise.all(x).then(function(v) { + for (let A = 0; A < v.length; A++) { + f[A].result = v[A]; } - return h ? fb(f) : n ? cb(a, f, B.index, k, n) : f; + return k ? fb(f) : r ? bb(a, f, B.index, h, r) : f; }); } - return h ? fb(f) : n ? cb(a, f, this.index, k, n) : f; + return k ? fb(f) : r ? bb(a, f, this.index, h, r) : f; }; -function eb(a, c) { - return "undefined" === typeof a ? c : a; +function eb(a, b) { + return "undefined" === typeof a ? b : a; } function fb(a) { - const c = [], b = G(); - for (let e = 0, d, f; e < a.length; e++) { - d = a[e]; - f = d.result; - for (let g = 0, k, h, l; g < f.length; g++) { - h = f[g], "object" !== typeof h && (h = {id:h}), k = h.id, (l = b[k]) ? l.push(d.field) : (h.field = b[k] = [d.field], c.push(h)); + const b = [], c = H(); + for (let d = 0, e, f; d < a.length; d++) { + e = a[d]; + f = e.result; + for (let g = 0, h, k, l; g < f.length; g++) { + k = f[g], "object" !== typeof k && (k = {id:k}), h = k.id, (l = c[h]) ? l.push(e.field) : (k.field = c[h] = [e.field], b.push(k)); } } - return c; + return b; } -function db(a, c, b, e, d) { +function db(a, b, c, d, e) { let f = this.tag.get(a); if (!f) { - return console.warn("Tag '" + a + "' was not found"), []; + return console.warn("Tag-Field '" + a + "' was not found"), []; } - if ((a = (f = f && f.get(c)) && f.length - e) && 0 < a) { - if (a > b || e) { - f = f.slice(e, e + b); + if ((a = (f = f && f.get(b)) && f.length - d) && 0 < a) { + if (c && a > c || d) { + f = f.slice(d, d + c); } - d && (f = X.call(this, f)); + e && (f = X.call(this, f)); return f; } } @@ -1748,181 +1751,187 @@ function X(a) { if (!this || !this.store) { return a; } - const c = Array(a.length); - for (let b = 0, e; b < a.length; b++) { - e = a[b], c[b] = {id:e, doc:this.store.get(e)}; + 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 c; + return b; } -;function Pa(a) { +;const gb = {normalize:!1, numeric:!1, dedupe:!1}; +const hb = {}; +const jb = 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 kb = new Map([["ae", "a"], ["oe", "o"], ["sh", "s"], ["kh", "k"], ["th", "t"], ["ph", "f"], ["pf", "f"]]), lb = [/([^aeo])h(.)/g, "$1$2", /([aeo])h([^aeo]|$)/g, "$1$2", /(.)\1+/g, "$1"]; +const mb = {a:"", e:"", i:"", o:"", u:"", y:"", b:1, f:1, p:1, v:1, c:2, g:2, j:2, k:2, q:2, s:2, x:2, z:2, "\u00df":2, d:3, t:3, l:4, m:5, n:5, r:6}; +var nb = {Exact:gb, Default:hb, Normalize:hb, LatinBalance:{mapper:jb}, LatinAdvanced:{mapper:jb, matcher:kb, replacer:lb}, LatinExtra:{mapper:jb, replacer:lb.concat([/(?!^)[aeo]/g, ""]), matcher:kb}, LatinSoundex:{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 = mb[d]; + for (let f = 1, g; f < b.length && (g = b.charAt(f), "h" === g || "w" === g || !(g = mb[g]) || g === e || (d += g, e = g, 4 !== d.length)); f++) { + } + a[c] = d; + } +}}, CJK:{split:""}, LatinExact:gb, LatinDefault:hb, LatinSimple:hb}; +function Pa(a) { if (!this || this.constructor !== Pa) { return new Pa(a); } - const c = a.document || a.doc || a; - let b, e; + const b = a.document || a.doc || a; + let c, d; this.F = []; this.field = []; this.J = []; - this.key = (b = c.key || c.id) && gb(b, this.J) || "id"; - (e = a.keystore || 0) && (this.keystore = e); + this.key = (c = b.key || b.id) && ob(c, this.J) || "id"; + (d = a.keystore || 0) && (this.keystore = d); this.fastupdate = !!a.fastupdate; - this.reg = !this.fastupdate || a.worker || a.db ? e ? new V(e) : new Set() : e ? new U(e) : new Map(); - this.C = (b = c.store || null) && b && !0 !== b && []; - this.store = b && (e ? new U(e) : new Map()); - this.cache = (b = a.cache || null) && new ib(b); + this.reg = !this.fastupdate || a.worker || a.db ? d ? new W(d) : new Set() : d ? new V(d) : new Map(); + this.C = (c = b.store || null) && c && !0 !== c && []; + this.store = c && (d ? new V(d) : new Map()); + this.cache = (c = a.cache || null) && new pb(c); a.cache = !1; this.worker = a.worker || !1; this.priority = a.priority || 4; - this.index = jb.call(this, a, c); + this.index = qb.call(this, a, b); this.tag = null; - if (b = c.tag) { - if ("string" === typeof b && (b = [b]), b.length) { + if (c = b.tag) { + if ("string" === typeof c && (c = [c]), c.length) { this.tag = new Map(); this.D = []; this.R = []; - for (let d = 0, f, g; d < b.length; d++) { - f = b[d]; + for (let e = 0, f, g; e < c.length; e++) { + f = c[e]; g = f.field || f; if (!g) { throw Error("The tag field from the document descriptor is undefined."); } - f.custom ? this.D[d] = f.custom : (this.D[d] = gb(g, this.J), f.filter && ("string" === typeof this.D[d] && (this.D[d] = new String(this.D[d])), this.D[d].I = f.filter)); - this.R[d] = g; + f.custom ? this.D[e] = f.custom : (this.D[e] = ob(g, this.J), f.filter && ("string" === typeof this.D[e] && (this.D[e] = new String(this.D[e])), this.D[e].I = f.filter)); + this.R[e] = g; this.tag.set(g, new Map()); } } } if (this.worker) { this.fastupdate = !1; - const d = []; - for (const f of this.index.values()) { - f.then && d.push(f); + a = []; + for (const e of this.index.values()) { + e.then && a.push(e); } - if (d.length) { - const f = this; - return Promise.all(d).then(function(g) { - const k = new Map(); - let h = 0; - for (const m of f.index.entries()) { - const t = m[0]; - var l = m[1]; - if (l.then) { - l = d[h].encoder || {}; - let q = k.get(l); - q || (q = l.encode ? l : new ma(l), k.set(l, q)); - l = g[h]; - l.encoder = q; - f.index.set(t, l); - h++; - } + if (a.length) { + const e = this; + return Promise.all(a).then(function(f) { + let g = 0; + for (const h of e.index.entries()) { + const k = h[0]; + let l = h[1]; + l.then && (l = f[g], e.index.set(k, l), g++); } - return f; + return e; }); } } else { a.db && (this.fastupdate = !1, this.mount(a.db)); } } -v = Pa.prototype; -v.mount = function(a) { +w = Pa.prototype; +w.mount = function(a) { if (this.worker) { throw Error("You can't use Worker-Indexes on a persistent model. That would be useless, since each of the persistent model acts like Worker-Index by default (Master/Slave)."); } - let c = this.field; + let b = this.field; if (this.tag) { for (let f = 0, g; f < this.R.length; f++) { g = this.R[f]; - var b = void 0; - this.index.set(g, b = new P({}, this.reg)); - c === this.field && (c = c.slice(0)); - c.push(g); - b.tag = this.tag.get(g); + var c = void 0; + this.index.set(g, c = new P({}, this.reg)); + b === this.field && (b = b.slice(0)); + b.push(g); + c.tag = this.tag.get(g); } } - b = []; - const e = {db:a.db, type:a.type, fastupdate:a.fastupdate}; - for (let f = 0, g, k; f < c.length; f++) { - e.field = k = c[f]; - g = this.index.get(k); - const h = new a.constructor(a.id, e); - h.id = a.id; - b[f] = h.mount(g); + c = []; + const d = {db:a.db, type:a.type, fastupdate:a.fastupdate}; + for (let f = 0, g, h; f < b.length; f++) { + d.field = h = b[f]; + g = this.index.get(h); + const k = new a.constructor(a.id, d); + k.id = a.id; + c[f] = k.mount(g); g.document = !0; f ? g.bypass = !0 : g.store = this.store; } - const d = this; - return this.db = Promise.all(b).then(function() { - d.db = !0; + const e = this; + return this.db = Promise.all(c).then(function() { + e.db = !0; }); }; -v.commit = async function(a, c) { - const b = []; - for (const e of this.index.values()) { - b.push(e.commit(a, c)); +w.commit = async function(a, b) { + const c = []; + for (const d of this.index.values()) { + c.push(d.commit(a, b)); } - await Promise.all(b); + await Promise.all(c); this.reg.clear(); }; -v.destroy = function() { +w.destroy = function() { const a = []; - for (const c of this.index.values()) { - a.push(c.destroy()); + for (const b of this.index.values()) { + a.push(b.destroy()); } return Promise.all(a); }; -function jb(a, c) { - const b = new Map(); - let e = c.index || c.field || c; - L(e) && (e = [e]); - for (let d = 0, f, g; d < e.length; d++) { - f = e[d]; - L(f) || (g = f, f = f.field); - g = aa(g) ? Object.assign({}, a, g) : a; +function qb(a, b) { + const c = new Map(); + let d = b.index || b.field || b; + M(d) && (d = [d]); + for (let f = 0, g, h; f < d.length; f++) { + g = d[f]; + M(g) || (h = g, g = g.field); + h = aa(h) ? Object.assign({}, a, h) : a; if (this.worker) { - const k = new Aa(g); - k.encoder = g.encoder; - b.set(f, k); + var e = void 0; + e = (e = h.encoder) && e.encode ? e : new ma("string" === typeof e ? nb[e] : e); + e = new Aa(h, e); + c.set(g, e); } - this.worker || b.set(f, new P(g, this.reg)); - g.custom ? this.F[d] = g.custom : (this.F[d] = gb(f, this.J), g.filter && ("string" === typeof this.F[d] && (this.F[d] = new String(this.F[d])), this.F[d].I = g.filter)); - this.field[d] = f; + this.worker || c.set(g, new P(h, this.reg)); + h.custom ? this.F[f] = h.custom : (this.F[f] = ob(g, this.J), h.filter && ("string" === typeof this.F[f] && (this.F[f] = new String(this.F[f])), this.F[f].I = h.filter)); + this.field[f] = g; } if (this.C) { - a = c.store; - L(a) && (a = [a]); - for (let d = 0, f, g; d < a.length; d++) { - f = a[d], g = f.field || f, f.custom ? (this.C[d] = f.custom, f.custom.V = g) : (this.C[d] = gb(g, this.J), f.filter && ("string" === typeof this.C[d] && (this.C[d] = new String(this.C[d])), this.C[d].I = f.filter)); + a = b.store; + M(a) && (a = [a]); + for (let f = 0, g, h; f < a.length; f++) { + g = a[f], h = g.field || g, g.custom ? (this.C[f] = g.custom, g.custom.V = h) : (this.C[f] = ob(h, this.J), g.filter && ("string" === typeof this.C[f] && (this.C[f] = new String(this.C[f])), this.C[f].I = g.filter)); } } - return b; + return c; } -function gb(a, c) { - const b = a.split(":"); - let e = 0; - for (let d = 0; d < b.length; d++) { - a = b[d], "]" === a[a.length - 1] && (a = a.substring(0, a.length - 2)) && (c[e] = !0), a && (b[e++] = a); +function ob(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); } - e < b.length && (b.length = e); - return 1 < e ? b : b[0]; + d < c.length && (c.length = d); + return 1 < d ? c : c[0]; } -v.append = function(a, c) { - return this.add(a, c, !0); +w.append = function(a, b) { + return this.add(a, b, !0); }; -v.update = function(a, c) { - return this.remove(a).add(a, c); +w.update = function(a, b) { + return this.remove(a).add(a, b); }; -v.remove = function(a) { +w.remove = function(a) { aa(a) && (a = ea(a, this.key)); - for (var c of this.index.values()) { - c.remove(a, !0); + for (var b of this.index.values()) { + b.remove(a, !0); } if (this.reg.has(a)) { if (this.tag && !this.fastupdate) { - for (let b of this.tag.values()) { - for (let e of b) { - c = e[0]; - const d = e[1], f = d.indexOf(a); - -1 < f && (1 < d.length ? d.splice(f, 1) : b.delete(c)); + for (let c of this.tag.values()) { + for (let d of c) { + b = d[0]; + const e = d[1], f = e.indexOf(a); + -1 < f && (1 < e.length ? e.splice(f, 1) : c.delete(b)); } } } @@ -1932,269 +1941,255 @@ v.remove = function(a) { this.cache && this.cache.remove(a); return this; }; -v.clear = function() { +w.clear = function() { const a = []; - for (const c of this.index.values()) { - const b = c.clear(); - b.then && a.push(b); + for (const b of this.index.values()) { + const c = b.clear(); + c.then && a.push(c); } if (this.tag) { - for (const c of this.tag.values()) { - c.clear(); + for (const b of this.tag.values()) { + b.clear(); } } this.store && this.store.clear(); this.cache && this.cache.clear(); return a.length ? Promise.all(a) : this; }; -v.contain = function(a) { +w.contain = function(a) { return this.db ? this.index.get(this.field[0]).db.has(a) : this.reg.has(a); }; -v.cleanup = function() { +w.cleanup = function() { for (const a of this.index.values()) { a.cleanup(); } return this; }; -v.get = function(a) { - return this.db ? this.index.get(this.field[0]).db.enrich(a).then(function(c) { - return c[0] && c[0].doc || null; +w.get = function(a) { + return this.db ? this.index.get(this.field[0]).db.enrich(a).then(function(b) { + return b[0] && b[0].doc || null; }) : this.store.get(a) || null; }; -v.set = function(a, c) { - "object" === typeof a && (c = a, a = ea(c, this.key)); - this.store.set(a, c); +w.set = function(a, b) { + "object" === typeof a && (b = a, a = ea(b, this.key)); + this.store.set(a, b); return this; }; -v.searchCache = kb; -v.export = function(a, c, b = 0, e = 0) { - if (b < this.field.length) { - const g = this.field[b]; - if ((c = this.index.get(g).export(a, g, b, e = 1)) && c.then) { - const k = this; - return c.then(function() { - return k.export(a, g, b + 1); +w.searchCache = rb; +w.export = function(a, b, c = 0, d = 0) { + if (c < this.field.length) { + const g = this.field[c]; + if ((b = this.index.get(g).export(a, g, c, d = 1)) && b.then) { + const h = this; + return b.then(function() { + return h.export(a, g, c + 1); }); } - return this.export(a, g, b + 1); + return this.export(a, g, c + 1); } - let d, f; - switch(e) { + let e, f; + switch(d) { case 0: - d = "reg"; + e = "reg"; f = Ga(this.reg); - c = null; + b = null; break; case 1: - d = "tag"; + e = "tag"; f = this.tag && Ea(this.tag, this.reg.size); - c = null; + b = null; break; case 2: - d = "doc"; + e = "doc"; f = this.store && Ca(this.store); - c = null; + b = null; break; default: return; } - return Ia.call(this, a, c, d, f, b, e); + return Ia.call(this, a, b, e, f, c, d); }; -v.import = function(a, c) { - var b = a.split("."); - "json" === b[b.length - 1] && b.pop(); - const e = 2 < b.length ? b[0] : ""; - b = 2 < b.length ? b[2] : b[1]; - if (this.worker && e) { - return this.index.get(e).import(a); +w.import = function(a, b) { + var c = a.split("."); + "json" === c[c.length - 1] && c.pop(); + const d = 2 < c.length ? c[0] : ""; + c = 2 < c.length ? c[2] : c[1]; + if (this.worker && d) { + return this.index.get(d).import(a); } - if (c) { - "string" === typeof c && (c = JSON.parse(c)); - if (e) { - return this.index.get(e).import(b, c); + if (b) { + "string" === typeof b && (b = JSON.parse(b)); + if (d) { + return this.index.get(d).import(c, b); } - switch(b) { + switch(c) { case "reg": this.fastupdate = !1; - this.reg = Ha(c, this.reg); - for (let d = 0, f; d < this.field.length; d++) { - f = this.index.get(this.field[d]), f.fastupdate = !1, f.reg = this.reg; + this.reg = Ha(b, this.reg); + for (let e = 0, f; e < this.field.length; e++) { + f = this.index.get(this.field[e]), f.fastupdate = !1, f.reg = this.reg; } if (this.worker) { - c = []; - for (const d of this.index.values()) { - c.push(d.import(a)); + b = []; + for (const e of this.index.values()) { + b.push(e.import(a)); } - return Promise.all(c); + return Promise.all(b); } break; case "tag": - this.tag = Fa(c, this.tag); + this.tag = Fa(b, this.tag); break; case "doc": - this.store = Da(c, this.store); + this.store = Da(b, this.store); } } }; ra(Pa.prototype); -function kb(a, c, b) { - const e = (c ? "" + a : "object" === typeof a ? "" + a.query : a).toLowerCase(); - this.cache || (this.cache = new ib()); - let d = this.cache.get(e); - if (!d) { - d = this.search(a, c, b); - if (d.then) { +function rb(a, b, c) { + const d = (b ? "" + a : "object" === typeof a ? "" + a.query : a).toLowerCase(); + this.cache || (this.cache = new pb()); + let e = this.cache.get(d); + if (!e) { + e = this.search(a, b, c); + if (e.then) { const f = this; - d.then(function(g) { - f.cache.set(e, g); + e.then(function(g) { + f.cache.set(d, g); return g; }); } - this.cache.set(e, d); + this.cache.set(d, e); } - return d; + return e; } -function ib(a) { +function pb(a) { this.limit = a && !0 !== a ? a : 1000; this.cache = new Map(); this.h = ""; } -ib.prototype.set = function(a, c) { - this.cache.set(this.h = a, c); +pb.prototype.set = function(a, b) { + this.cache.set(this.h = a, b); this.cache.size > this.limit && this.cache.delete(this.cache.keys().next().value); }; -ib.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; +pb.prototype.get = function(a) { + const b = this.cache.get(a); + b && this.h !== a && (this.cache.delete(a), this.cache.set(this.h = a, b)); + return b; }; -ib.prototype.remove = function(a) { - for (const c of this.cache) { - const b = c[0]; - c[1].includes(a) && this.cache.delete(b); +pb.prototype.remove = function(a) { + for (const b of this.cache) { + const c = b[0]; + b[1].includes(a) && this.cache.delete(c); } }; -ib.prototype.clear = function() { +pb.prototype.clear = function() { this.cache.clear(); this.h = ""; }; -const lb = {normalize:!1, numeric:!1, dedupe:!1}; -const mb = {}; -const nb = 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 ob = new Map([["ae", "a"], ["oe", "o"], ["sh", "s"], ["kh", "k"], ["th", "t"], ["ph", "f"], ["pf", "f"]]), pb = [/([^aeo])h(.)/g, "$1$2", /([aeo])h([^aeo]|$)/g, "$1$2", /(.)\1+/g, "$1"]; -const qb = {a:"", e:"", i:"", o:"", u:"", y:"", b:1, f:1, p:1, v:1, c:2, g:2, j:2, k:2, q:2, s:2, x:2, z:2, "\u00df":2, d:3, t:3, l:4, m:5, n:5, r:6}; -var rb = {Exact:lb, Default:mb, Normalize:mb, LatinBalance:{mapper:nb}, LatinAdvanced:{mapper:nb, matcher:ob, replacer:pb}, LatinExtra:{mapper:nb, replacer:pb.concat([/(?!^)[aeo]/g, ""]), matcher:ob}, LatinSoundex:{dedupe:!1, include:{letter:!0}, finalize:function(a) { - for (let b = 0; b < a.length; b++) { - var c = a[b]; - let e = c.charAt(0), d = qb[e]; - for (let f = 1, g; f < c.length && (g = c.charAt(f), "h" === g || "w" === g || !(g = qb[g]) || g === d || (e += g, d = g, 4 !== e.length)); f++) { - } - a[b] = e; - } -}}, CJK:{split:""}, LatinExact:lb, LatinDefault:mb, LatinSimple:mb}; -P.prototype.remove = function(a, c) { - const b = this.reg.size && (this.fastupdate ? this.reg.get(a) : this.reg.has(a)); - if (b) { +P.prototype.remove = function(a, b) { + const c = this.reg.size && (this.fastupdate ? this.reg.get(a) : this.reg.has(a)); + if (c) { if (this.fastupdate) { - for (let e = 0, d; e < b.length; e++) { - if (d = b[e]) { - if (2 > d.length) { - d.pop(); + for (let d = 0, e; d < c.length; d++) { + if (e = c[d]) { + if (2 > e.length) { + e.pop(); } else { - const f = d.indexOf(a); - f === b.length - 1 ? d.pop() : d.splice(f, 1); + const f = e.indexOf(a); + f === c.length - 1 ? e.pop() : e.splice(f, 1); } } } } else { sb(this.map, a), this.depth && sb(this.ctx, a); } - c || this.reg.delete(a); + b || this.reg.delete(a); } this.db && (this.commit_task.push({del:a}), this.T && tb(this)); this.cache && this.cache.remove(a); return this; }; -function sb(a, c) { - let b = 0; - var e = "undefined" === typeof c; +function sb(a, b) { + let c = 0; + var d = "undefined" === typeof b; if (a.constructor === Array) { - for (let d = 0, f, g; d < a.length; d++) { - if ((f = a[d]) && f.length) { - if (e) { - b++; + for (let e = 0, f, g; e < a.length; e++) { + if ((f = a[e]) && f.length) { + if (d) { + c++; } else { - if (g = f.indexOf(c), 0 <= g) { - 1 < f.length ? (f.splice(g, 1), b++) : delete a[d]; + if (g = f.indexOf(b), 0 <= g) { + 1 < f.length ? (f.splice(g, 1), c++) : delete a[e]; break; } else { - b++; + c++; } } } } } else { - for (let d of a.entries()) { - e = d[0]; - const f = sb(d[1], c); - f ? b += f : a.delete(e); + for (let e of a.entries()) { + d = e[0]; + const f = sb(e[1], b); + f ? c += f : a.delete(d); } } - return b; + return c; } ;const ub = {memory:{resolution:1}, performance:{resolution:3, fastupdate:!0, context:{depth:1, resolution:1}}, match:{tokenize:"forward"}, score:{resolution:9, context:{depth:2, resolution:3}}}; -P.prototype.add = function(a, c, b, e) { - if (c && (a || 0 === a)) { - if (!e && !b && this.reg.has(a)) { - return this.update(a, c); +P.prototype.add = function(a, b, c, d) { + if (b && (a || 0 === a)) { + if (!d && !c && this.reg.has(a)) { + return this.update(a, b); } - e = this.depth; - c = this.encoder.encode(c, !e); - const l = c.length; + d = this.depth; + b = this.encoder.encode(b, !d); + const l = b.length; if (l) { - const m = G(), t = G(), q = this.resolution; - for (let n = 0; n < l; n++) { - let r = c[this.rtl ? l - 1 - n : n]; - var d = r.length; - if (d && (e || !t[r])) { - var f = this.score ? this.score(c, r, n, null, 0) : vb(q, l, n), g = ""; + const m = H(), p = H(), u = this.resolution; + for (let q = 0; q < l; q++) { + let r = b[this.rtl ? l - 1 - q : q]; + var e = r.length; + if (e && (d || !p[r])) { + var f = this.score ? this.score(b, r, q, null, 0) : vb(u, l, q), g = ""; switch(this.tokenize) { case "full": - if (2 < d) { - for (let u = 0, p; u < d; u++) { - for (f = d; f > u; f--) { - g = r.substring(u, f); - p = this.rtl ? d - 1 - u : u; - var k = this.score ? this.score(c, r, n, g, p) : vb(q, l, n, d, p); - wb(this, t, g, k, a, b); + if (2 < e) { + for (let n = 0, t; n < e; n++) { + for (f = e; f > n; f--) { + g = r.substring(n, f); + t = this.rtl ? e - 1 - n : n; + var h = this.score ? this.score(b, r, q, g, t) : vb(u, l, q, e, t); + wb(this, p, g, h, a, c); } } break; } case "bidirectional": case "reverse": - if (1 < d) { - for (k = d - 1; 0 < k; k--) { - g = r[this.rtl ? d - 1 - k : k] + g; - var h = this.score ? this.score(c, r, n, g, k) : vb(q, l, n, d, k); - wb(this, t, g, h, a, b); + if (1 < e) { + for (h = e - 1; 0 < h; h--) { + g = r[this.rtl ? e - 1 - h : h] + g; + var k = this.score ? this.score(b, r, q, g, h) : vb(u, l, q, e, h); + wb(this, p, g, k, a, c); } g = ""; } case "forward": - if (1 < d) { - for (k = 0; k < d; k++) { - g += r[this.rtl ? d - 1 - k : k], wb(this, t, g, f, a, b); + if (1 < e) { + for (h = 0; h < e; h++) { + g += r[this.rtl ? e - 1 - h : h], wb(this, p, g, f, a, c); } break; } default: - if (wb(this, t, r, f, a, b), e && 1 < l && n < l - 1) { - for (d = G(), g = this.U, f = r, k = Math.min(e + 1, this.rtl ? n + 1 : l - n), d[f] = 1, h = 1; h < k; h++) { - if ((r = c[this.rtl ? l - 1 - n - h : n + h]) && !d[r]) { - d[r] = 1; - const u = this.score ? this.score(c, f, n, r, h - 1) : vb(g + (l / 2 > g ? 0 : 1), l, n, k - 1, h - 1), p = this.bidirectional && r > f; - wb(this, m, p ? f : r, u, a, b, p ? r : f); + if (wb(this, p, r, f, a, c), d && 1 < l && q < l - 1) { + for (e = H(), g = this.U, f = r, h = Math.min(d + 1, this.rtl ? q + 1 : l - q), e[f] = 1, k = 1; k < h; k++) { + if ((r = b[this.rtl ? l - 1 - q - k : q + k]) && !e[r]) { + e[r] = 1; + const n = this.score ? this.score(b, f, q, r, k - 1) : vb(g + (l / 2 > g ? 0 : 1), l, q, h - 1, k - 1), t = this.bidirectional && r > f; + wb(this, m, t ? f : r, n, a, c, t ? r : f); } } } @@ -2203,180 +2198,180 @@ P.prototype.add = function(a, c, b, e) { } this.fastupdate || this.reg.add(a); } else { - c = ""; + b = ""; } } - this.db && (c || this.commit_task.push({del:a}), this.T && tb(this)); + this.db && (b || this.commit_task.push({del:a}), this.T && tb(this)); return this; }; -function wb(a, c, b, e, d, f, g) { - let k = g ? a.ctx : a.map, h; - if (!c[b] || g && !(h = c[b])[g]) { - if (g ? (c = h || (c[b] = G()), c[g] = 1, (h = k.get(g)) ? k = h : k.set(g, k = new Map())) : c[b] = 1, (h = k.get(b)) ? k = h : k.set(b, k = h = []), k = k[e] || (k[e] = []), !f || !k.includes(d)) { - if (k.length === 2 ** 31 - 1) { - c = new T(k); +function wb(a, b, c, d, e, f, g) { + let h = g ? a.ctx : a.map, k; + if (!b[c] || g && !(k = b[c])[g]) { + if (g ? (b = k || (b[c] = H()), 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 U(h); if (a.fastupdate) { for (let l of a.reg.values()) { - l.includes(k) && (l[l.indexOf(k)] = c); + l.includes(h) && (l[l.indexOf(h)] = b); } } - h[e] = k = c; + k[d] = h = b; } - k.push(d); - a.fastupdate && ((e = a.reg.get(d)) ? e.push(k) : a.reg.set(d, [k])); + h.push(e); + a.fastupdate && ((d = a.reg.get(e)) ? d.push(h) : a.reg.set(e, [h])); } } } -function vb(a, c, b, e, d) { - return b && 1 < a ? c + (e || 0) <= a ? b + (d || 0) : (a - 1) / (c + (e || 0)) * (b + (d || 0)) + 1 | 0 : 0; +function vb(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; } -;P.prototype.search = function(a, c, b) { - b || (c || "object" !== typeof a ? "object" === typeof c && (b = c, c = 0) : (b = a, a = "")); - if (b && b.cache) { - return b.cache = !1, a = this.searchCache(a, c, b), b.cache = !0, a; +;P.prototype.search = function(a, b, c) { + c || (b || "object" !== typeof a ? "object" === typeof b && (c = b, b = 0) : (c = a, a = "")); + if (c && c.cache) { + return c.cache = !1, a = this.searchCache(a, b, c), c.cache = !0, a; } - let e = [], d, f, g, k = 0, h, l, m, t, q; - b && (a = b.query || a, c = b.limit || c, k = b.offset || 0, f = b.context, g = b.suggest, q = (h = b.resolve) && b.enrich, m = b.boost, t = b.resolution, l = this.db && b.tag); - "undefined" === typeof h && (h = this.resolve); + let d = [], e, f, g, h = 0, k, l, m, p, u; + c && (a = c.query || a, b = c.limit || b, h = c.offset || 0, f = c.context, g = c.suggest, u = (k = c.resolve) && c.enrich, m = c.boost, p = c.resolution, l = this.db && c.tag); + "undefined" === typeof k && (k = this.resolve); f = this.depth && !1 !== f; - let n = this.encoder.encode(a, !f); - d = n.length; - c = c || (h ? 100 : 0); - if (1 === d) { - return xb.call(this, n[0], "", c, k, h, q, l); + let q = this.encoder.encode(a, !f); + e = q.length; + b = b || (k ? 100 : 0); + if (1 === e) { + return xb.call(this, q[0], "", b, h, k, u, l); } - if (2 === d && f && !g) { - return xb.call(this, n[1], n[0], c, k, h, q, l); + if (2 === e && f && !g) { + return xb.call(this, q[1], q[0], b, h, k, u, l); } - let r = G(), u = 0, p; - f && (p = n[0], u = 1); - t || 0 === t || (t = p ? this.U : this.resolution); + let r = H(), n = 0, t; + f && (t = q[0], n = 1); + p || 0 === p || (p = t ? this.U : this.resolution); if (this.db) { - if (this.db.search && (b = this.db.search(this, n, c, k, g, h, q, l), !1 !== b)) { - return b; + if (this.db.search && (c = this.db.search(this, q, b, h, g, k, u, l), !1 !== c)) { + return c; } - const z = this; + const x = this; return async function() { - for (let x, J; u < d; u++) { - if ((J = n[u]) && !r[J]) { - r[J] = 1; - x = await yb(z, J, p, 0, 0, !1, !1); - if (x = zb(x, e, g, t)) { - e = x; + for (let y, D; n < e; n++) { + if ((D = q[n]) && !r[D]) { + r[D] = 1; + y = await yb(x, D, t, 0, 0, !1, !1); + if (y = zb(y, d, g, p)) { + d = y; break; } - p && (g && x && e.length || (p = J)); + t && (g && y && d.length || (t = D)); } - g && p && u === d - 1 && !e.length && (t = z.resolution, p = "", u = -1, r = G()); + g && t && n === e - 1 && !d.length && (p = x.resolution, t = "", n = -1, r = H()); } - return Ab(e, t, c, k, g, m, h); + return Ab(d, p, b, h, g, m, k); }(); } - for (let z, x; u < d; u++) { - if ((x = n[u]) && !r[x]) { - r[x] = 1; - z = yb(this, x, p, 0, 0, !1, !1); - if (z = zb(z, e, g, t)) { - e = z; + for (let x, y; n < e; n++) { + if ((y = q[n]) && !r[y]) { + r[y] = 1; + x = yb(this, y, t, 0, 0, !1, !1); + if (x = zb(x, d, g, p)) { + d = x; break; } - p && (g && z && e.length || (p = x)); + t && (g && x && d.length || (t = y)); } - g && p && u === d - 1 && !e.length && (t = this.resolution, p = "", u = -1, r = G()); + g && t && n === e - 1 && !d.length && (p = this.resolution, t = "", n = -1, r = H()); } - return Ab(e, t, c, k, g, m, h); + return Ab(d, p, b, h, g, m, k); }; -function Ab(a, c, b, e, d, f, g) { - let k = a.length, h = a; - if (1 < k) { - h = Sa(a, c, b, e, d, f, g); - } else if (1 === k) { - return g ? Va.call(null, a[0], b, e) : new Y(a[0], this); +function Ab(a, b, c, d, e, f, g) { + let h = a.length, k = a; + if (1 < h) { + k = Xa(a, b, c, d, e, f, g); + } else if (1 === h) { + return g ? Sa.call(null, a[0], c, d) : new Y(a[0], this); } - return g ? h : new Y(h, this); + return g ? k : new Y(k, this); } -function xb(a, c, b, e, d, f, g) { - a = yb(this, a, c, b, e, d, f, g); - return this.db ? a.then(function(k) { - return d ? k || [] : new Y(k, this); - }) : a && a.length ? d ? Va.call(this, a, b, e) : new Y(a, this) : d ? [] : new Y([], this); +function xb(a, b, c, d, e, f, g) { + a = yb(this, a, b, c, d, e, f, g); + return this.db ? a.then(function(h) { + return e ? h || [] : new Y(h, this); + }) : a && a.length ? e ? Sa.call(this, a, c, d) : new Y(a, this) : e ? [] : new Y([], this); } -function zb(a, c, b, e) { - let d = []; +function zb(a, b, c, d) { + let e = []; if (a && a.length) { - if (a.length <= e) { - c.push(a); + if (a.length <= d) { + b.push(a); return; } - for (let f = 0, g; f < e; f++) { + for (let f = 0, g; f < d; f++) { if (g = a[f]) { - d[f] = g; + e[f] = g; } } - if (d.length) { - c.push(d); + if (e.length) { + b.push(e); return; } } - if (!b) { - return d; + if (!c) { + return e; } } -function yb(a, c, b, e, d, f, g, k) { - let h; - b && (h = a.bidirectional && c > b) && (h = b, b = c, c = h); +function yb(a, b, c, d, e, f, g, h) { + let k; + c && (k = a.bidirectional && b > c) && (k = c, c = b, b = k); if (a.db) { - return a.db.get(c, b, e, d, f, g, k); + return a.db.get(b, c, d, e, f, g, h); } - a = b ? (a = a.ctx.get(b)) && a.get(c) : a.map.get(c); + a = c ? (a = a.ctx.get(c)) && a.get(b) : a.map.get(b); return a; } -;function P(a, c) { +;function P(a, b) { if (!this || this.constructor !== P) { return new P(a); } if (a) { - var b = L(a) ? a : a.preset; - b && (ub[b] || console.warn("Preset not found: " + b), a = Object.assign({}, ub[b], a)); + var c = M(a) ? a : a.preset; + c && (ub[c] || console.warn("Preset not found: " + c), a = Object.assign({}, ub[c], a)); } else { a = {}; } - b = a.context; - const e = !0 === b ? {depth:1} : b || {}, d = L(a.encoder) ? rb[a.encoder] : a.encode || a.encoder || {}; - this.encoder = d.encode ? d : "object" === typeof d ? new ma(d) : {encode:d}; + c = a.context; + const d = !0 === c ? {depth:1} : c || {}, e = M(a.encoder) ? nb[a.encoder] : a.encode || a.encoder || {}; + this.encoder = e.encode ? e : "object" === typeof e ? new ma(e) : {encode:e}; this.resolution = a.resolution || 9; - this.tokenize = b = (b = a.tokenize) && "default" !== b && "exact" !== b && b || "strict"; - this.depth = "strict" === b && e.depth || 0; - this.bidirectional = !1 !== e.bidirectional; + this.tokenize = c = (c = a.tokenize) && "default" !== c && "exact" !== c && c || "strict"; + this.depth = "strict" === c && d.depth || 0; + this.bidirectional = !1 !== d.bidirectional; this.fastupdate = !!a.fastupdate; this.score = a.score || null; - e && e.depth && "strict" !== this.tokenize && console.warn('Context-Search could not applied, because it is just supported when using the tokenizer "strict".'); - (b = a.keystore || 0) && (this.keystore = b); - this.map = b ? new U(b) : new Map(); - this.ctx = b ? new U(b) : new Map(); - this.reg = c || (this.fastupdate ? b ? new U(b) : new Map() : b ? new V(b) : new Set()); - this.U = e.resolution || 3; - this.rtl = d.rtl || a.rtl || !1; - this.cache = (b = a.cache || null) && new ib(b); + d && d.depth && "strict" !== this.tokenize && console.warn('Context-Search could not applied, because it is just supported when using the tokenizer "strict".'); + (c = a.keystore || 0) && (this.keystore = c); + this.map = c ? new V(c) : new Map(); + this.ctx = c ? new V(c) : new Map(); + this.reg = b || (this.fastupdate ? c ? new V(c) : new Map() : c ? new W(c) : new Set()); + this.U = d.resolution || 3; + this.rtl = e.rtl || a.rtl || !1; + this.cache = (c = a.cache || null) && new pb(c); this.resolve = !1 !== a.resolve; - if (b = a.db) { - this.db = this.mount(b); + if (c = a.db) { + this.db = this.mount(c); } this.T = !1 !== a.commit; this.commit_task = []; this.commit_timer = null; this.priority = a.priority || 4; } -v = P.prototype; -v.mount = function(a) { +w = P.prototype; +w.mount = function(a) { this.commit_timer && (clearTimeout(this.commit_timer), this.commit_timer = null); return a.mount(this); }; -v.commit = function(a, c) { +w.commit = function(a, b) { this.commit_timer && (clearTimeout(this.commit_timer), this.commit_timer = null); - return this.db.commit(this, a, c); + return this.db.commit(this, a, b); }; -v.destroy = function() { +w.destroy = function() { this.commit_timer && (clearTimeout(this.commit_timer), this.commit_timer = null); return this.db.destroy(); }; @@ -2386,7 +2381,7 @@ function tb(a) { a.db.commit(a, void 0, void 0); }, 1)); } -v.clear = function() { +w.clear = function() { this.map.clear(); this.ctx.clear(); this.reg.clear(); @@ -2394,17 +2389,17 @@ v.clear = function() { this.db && (this.commit_timer && clearTimeout(this.commit_timer), this.commit_timer = null, this.commit_task = [{clear:!0}]); return this; }; -v.append = function(a, c) { - return this.add(a, c, !0); +w.append = function(a, b) { + return this.add(a, b, !0); }; -v.contain = function(a) { +w.contain = function(a) { return this.db ? this.db.has(a) : this.reg.has(a); }; -v.update = function(a, c) { - const b = this, e = this.remove(a); - return e && e.then ? e.then(() => b.add(a, c)) : this.add(a, c); +w.update = function(a, b) { + const c = this, d = this.remove(a); + return d && d.then ? d.then(() => c.add(a, b)) : this.add(a, b); }; -v.cleanup = function() { +w.cleanup = function() { if (!this.fastupdate) { return console.info('Cleanup the index isn\'t required when not using "fastupdate".'), this; } @@ -2412,91 +2407,91 @@ v.cleanup = function() { this.depth && sb(this.ctx); return this; }; -v.searchCache = kb; -v.export = function(a, c, b = 0, e = 0) { - let d, f; - switch(e) { +w.searchCache = rb; +w.export = function(a, b, c = 0, d = 0) { + let e, f; + switch(d) { case 0: - d = "reg"; + e = "reg"; f = Ga(this.reg); break; case 1: - d = "cfg"; + e = "cfg"; f = null; break; case 2: - d = "map"; + e = "map"; f = Ca(this.map, this.reg.size); break; case 3: - d = "ctx"; + e = "ctx"; f = Ea(this.ctx, this.reg.size); break; default: return; } - return Ia.call(this, a, c, d, f, b, e); + return Ia.call(this, a, b, e, f, c, d); }; -v.import = function(a, c) { - if (c) { - switch("string" === typeof c && (c = JSON.parse(c)), a = a.split("."), "json" === a[a.length - 1] && a.pop(), 3 === a.length && a.shift(), a = 1 < a.length ? a[1] : a[0], a) { +w.import = function(a, b) { + if (b) { + switch("string" === typeof b && (b = JSON.parse(b)), a = a.split("."), "json" === a[a.length - 1] && a.pop(), 3 === a.length && a.shift(), a = 1 < a.length ? a[1] : a[0], a) { case "reg": this.fastupdate = !1; - this.reg = Ha(c, this.reg); + this.reg = Ha(b, this.reg); break; case "map": - this.map = Da(c, this.map); + this.map = Da(b, this.map); break; case "ctx": - this.ctx = Fa(c, this.ctx); + this.ctx = Fa(b, this.ctx); } } }; -v.serialize = function(a = !0) { - let c = "", b = "", e = ""; +w.serialize = function(a = !0) { + let b = "", c = "", d = ""; if (this.reg.size) { let f; - for (var d of this.reg.keys()) { - f || (f = typeof d), c += (c ? "," : "") + ("string" === f ? '"' + d + '"' : d); + for (var e of this.reg.keys()) { + f || (f = typeof e), b += (b ? "," : "") + ("string" === f ? '"' + e + '"' : e); } - c = "index.reg=new Set([" + c + "]);"; - b = Ja(this.map, f); - b = "index.map=new Map([" + b + "]);"; + b = "index.reg=new Set([" + b + "]);"; + c = Ja(this.map, f); + c = "index.map=new Map([" + c + "]);"; for (const g of this.ctx.entries()) { - d = g[0]; - let k = Ja(g[1], f); - k = "new Map([" + k + "])"; - k = '["' + d + '",' + k + "]"; - e += (e ? "," : "") + k; + e = g[0]; + let h = Ja(g[1], f); + h = "new Map([" + h + "])"; + h = '["' + e + '",' + h + "]"; + d += (d ? "," : "") + h; } - e = "index.ctx=new Map([" + e + "]);"; + d = "index.ctx=new Map([" + d + "]);"; } - return a ? "function inject(index){" + c + b + e + "}" : c + b + e; + return a ? "function inject(index){" + b + c + d + "}" : b + c + d; }; ra(P.prototype); -const Bb = "undefined" !== typeof window && (window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB), Cb = ["map", "ctx", "tag", "reg", "cfg"], Db = G(); -function Eb(a, c = {}) { +const Bb = "undefined" !== typeof window && (window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB), Cb = ["map", "ctx", "tag", "reg", "cfg"], Db = H(); +function Eb(a, b = {}) { if (!this || this.constructor !== Eb) { - return new Eb(a, c); + return new Eb(a, b); } - "object" === typeof a && (c = a, a = a.name); + "object" === typeof a && (b = a, a = a.name); a || console.info("Default storage space was used, because a name was not passed."); this.id = "flexsearch" + (a ? ":" + a.toLowerCase().replace(/[^a-z0-9_\-]/g, "") : ""); - this.field = c.field ? c.field.toLowerCase().replace(/[^a-z0-9_\-]/g, "") : ""; - this.type = c.type; + this.field = b.field ? b.field.toLowerCase().replace(/[^a-z0-9_\-]/g, "") : ""; + this.type = b.type; this.fastupdate = this.support_tag_search = !1; this.db = null; this.h = {}; } -v = Eb.prototype; -v.mount = function(a) { +w = Eb.prototype; +w.mount = function(a) { if (a.index) { return a.mount(this); } a.db = this; return this.open(); }; -v.open = function() { +w.open = function() { if (this.db) { return this.db; } @@ -2504,280 +2499,280 @@ v.open = function() { navigator.storage && navigator.storage.persist(); Db[a.id] || (Db[a.id] = []); Db[a.id].push(a.field); - const c = Bb.open(a.id, 1); - c.onupgradeneeded = function() { - const b = a.db = this.result; - for (let e = 0, d; e < Cb.length; e++) { - d = Cb[e]; + const b = Bb.open(a.id, 1); + b.onupgradeneeded = function() { + const c = a.db = this.result; + for (let d = 0, e; d < Cb.length; d++) { + e = Cb[d]; for (let f = 0, g; f < Db[a.id].length; f++) { - g = Db[a.id][f], b.objectStoreNames.contains(d + ("reg" !== d ? g ? ":" + g : "" : "")) || b.createObjectStore(d + ("reg" !== d ? g ? ":" + g : "" : "")); + g = Db[a.id][f], c.objectStoreNames.contains(e + ("reg" !== e ? g ? ":" + g : "" : "")) || c.createObjectStore(e + ("reg" !== e ? g ? ":" + g : "" : "")); } } }; - return a.db = Z(c, function(b) { - a.db = b; + return a.db = Z(b, function(c) { + a.db = c; a.db.onversionchange = function() { a.close(); }; }); }; -v.close = function() { +w.close = function() { this.db && this.db.close(); this.db = null; }; -v.destroy = function() { +w.destroy = function() { const a = Bb.deleteDatabase(this.id); return Z(a); }; -v.clear = function() { +w.clear = function() { const a = []; - for (let b = 0, e; b < Cb.length; b++) { - e = Cb[b]; - for (let d = 0, f; d < Db[this.id].length; d++) { - f = Db[this.id][d], a.push(e + ("reg" !== e ? f ? ":" + f : "" : "")); + for (let c = 0, d; c < Cb.length; c++) { + d = Cb[c]; + for (let e = 0, f; e < Db[this.id].length; e++) { + f = Db[this.id][e], a.push(d + ("reg" !== d ? f ? ":" + f : "" : "")); } } - const c = this.db.transaction(a, "readwrite"); - for (let b = 0; b < a.length; b++) { - c.objectStore(a[b]).clear(); + const b = this.db.transaction(a, "readwrite"); + for (let c = 0; c < a.length; c++) { + b.objectStore(a[c]).clear(); } - return Z(c); + return Z(b); }; -v.get = function(a, c, b = 0, e = 0, d = !0, f = !1) { - a = this.db.transaction((c ? "ctx" : "map") + (this.field ? ":" + this.field : ""), "readonly").objectStore((c ? "ctx" : "map") + (this.field ? ":" + this.field : "")).get(c ? c + ":" + a : a); +w.get = function(a, b, c = 0, d = 0, e = !0, f = !1) { + a = this.db.transaction((b ? "ctx" : "map") + (this.field ? ":" + this.field : ""), "readonly").objectStore((b ? "ctx" : "map") + (this.field ? ":" + this.field : "")).get(b ? b + ":" + a : a); const g = this; - return Z(a).then(function(k) { - let h = []; - if (!k || !k.length) { - return h; + return Z(a).then(function(h) { + let k = []; + if (!h || !h.length) { + return k; } - if (d) { - if (!b && !e && 1 === k.length) { - return k[0]; + if (e) { + if (!c && !d && 1 === h.length) { + return h[0]; } - for (let l = 0, m; l < k.length; l++) { - if ((m = k[l]) && m.length) { - if (e >= m.length) { - e -= m.length; + for (let l = 0, m; l < h.length; l++) { + if ((m = h[l]) && m.length) { + if (d >= m.length) { + d -= m.length; continue; } - const t = b ? e + Math.min(m.length - e, b) : m.length; - for (let q = e; q < t; q++) { - h.push(m[q]); + const p = c ? d + Math.min(m.length - d, c) : m.length; + for (let u = d; u < p; u++) { + k.push(m[u]); } - e = 0; - if (h.length === b) { + d = 0; + if (k.length === c) { break; } } } - return f ? g.enrich(h) : h; + return f ? g.enrich(k) : k; } - return k; + return h; }); }; -v.tag = function(a, c = 0, b = 0, e = !1) { +w.tag = function(a, b = 0, c = 0, d = !1) { a = this.db.transaction("tag" + (this.field ? ":" + this.field : ""), "readonly").objectStore("tag" + (this.field ? ":" + this.field : "")).get(a); - const d = this; + const e = this; return Z(a).then(function(f) { - if (!f || !f.length || b >= f.length) { + if (!f || !f.length || c >= f.length) { return []; } - if (!c && !b) { + if (!b && !c) { return f; } - f = f.slice(b, b + c); - return e ? d.enrich(f) : f; + f = f.slice(c, c + b); + return d ? e.enrich(f) : f; }); }; -v.enrich = function(a) { +w.enrich = function(a) { "object" !== typeof a && (a = [a]); - const c = this.db.transaction("reg", "readonly").objectStore("reg"), b = []; - for (let e = 0; e < a.length; e++) { - b[e] = Z(c.get(a[e])); + 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(b).then(function(e) { - for (let d = 0; d < e.length; d++) { - e[d] = {id:a[d], doc:e[d] ? JSON.parse(e[d]) : null}; + 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 e; + return d; }); }; -v.has = function(a) { +w.has = function(a) { a = this.db.transaction("reg", "readonly").objectStore("reg").getKey(a); - return Z(a).then(function(c) { - return !!c; + return Z(a).then(function(b) { + return !!b; }); }; -v.search = null; -v.info = function() { +w.search = null; +w.info = function() { }; -v.transaction = function(a, c, b) { +w.transaction = function(a, b, c) { a += "reg" !== a ? this.field ? ":" + this.field : "" : ""; - let e = this.h[a + ":" + c]; - if (e) { - return b.call(this, e); + let d = this.h[a + ":" + b]; + if (d) { + return c.call(this, d); } - let d = this.db.transaction(a, c); - this.h[a + ":" + c] = e = d.objectStore(a); - const f = b.call(this, e); - this.h[a + ":" + c] = null; - return Z(d).finally(function() { - d = e = null; + let e = this.db.transaction(a, b); + this.h[a + ":" + b] = d = e.objectStore(a); + const f = c.call(this, d); + this.h[a + ":" + b] = null; + return Z(e).finally(function() { + e = d = null; return f; }); }; -v.commit = async function(a, c, b) { - if (c) { +w.commit = async function(a, b, c) { + if (b) { await this.clear(), a.commit_task = []; } else { - let e = a.commit_task; + let d = a.commit_task; a.commit_task = []; - for (let d = 0, f; d < e.length; d++) { - if (f = e[d], f.clear) { + for (let e = 0, f; e < d.length; e++) { + if (f = d[e], f.clear) { await this.clear(); - c = !0; + b = !0; break; } else { - e[d] = f.del; + d[e] = f.del; } } - c || (b || (e = e.concat(da(a.reg))), e.length && await this.remove(e)); + b || (c || (d = d.concat(da(a.reg))), d.length && await this.remove(d)); } - a.reg.size && (await this.transaction("map", "readwrite", function(e) { - for (const d of a.map) { - const f = d[0], g = d[1]; - g.length && (c ? e.put(g, f) : e.get(f).onsuccess = function() { - let k = this.result; - var h; - if (k && k.length) { - const l = Math.max(k.length, g.length); - for (let m = 0, t, q; m < l; m++) { - if ((q = g[m]) && q.length) { - if ((t = k[m]) && t.length) { - for (h = 0; h < q.length; h++) { - t.push(q[h]); + a.reg.size && (await this.transaction("map", "readwrite", function(d) { + for (const e of a.map) { + const f = e[0], g = e[1]; + g.length && (b ? d.put(g, f) : d.get(f).onsuccess = function() { + let h = this.result; + var k; + if (h && h.length) { + const l = Math.max(h.length, g.length); + for (let m = 0, p, u; m < l; m++) { + if ((u = g[m]) && u.length) { + if ((p = h[m]) && p.length) { + for (k = 0; k < u.length; k++) { + p.push(u[k]); } } else { - k[m] = q; + h[m] = u; } - h = 1; + k = 1; } } } else { - k = g, h = 1; + h = g, k = 1; } - h && e.put(k, f); + k && d.put(h, f); }); } - }), await this.transaction("ctx", "readwrite", function(e) { - for (const d of a.ctx) { - const f = d[0], g = d[1]; - for (const k of g) { - const h = k[0], l = k[1]; - l.length && (c ? e.put(l, f + ":" + h) : e.get(f + ":" + h).onsuccess = function() { + }), await this.transaction("ctx", "readwrite", function(d) { + for (const e of a.ctx) { + const f = e[0], g = e[1]; + for (const h of g) { + const k = h[0], l = h[1]; + l.length && (b ? d.put(l, f + ":" + k) : d.get(f + ":" + k).onsuccess = function() { let m = this.result; - var t; + var p; if (m && m.length) { - const q = Math.max(m.length, l.length); - for (let n = 0, r, u; n < q; n++) { - if ((u = l[n]) && u.length) { - if ((r = m[n]) && r.length) { - for (t = 0; t < u.length; t++) { - r.push(u[t]); + const u = Math.max(m.length, l.length); + for (let q = 0, r, n; q < u; q++) { + if ((n = l[q]) && n.length) { + if ((r = m[q]) && r.length) { + for (p = 0; p < n.length; p++) { + r.push(n[p]); } } else { - m[n] = u; + m[q] = n; } - t = 1; + p = 1; } } } else { - m = l, t = 1; + m = l, p = 1; } - t && e.put(m, f + ":" + h); + p && d.put(m, f + ":" + k); }); } } - }), a.store ? await this.transaction("reg", "readwrite", function(e) { - for (const d of a.store) { - const f = d[0], g = d[1]; - e.put("object" === typeof g ? JSON.stringify(g) : 1, f); + }), 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.bypass || await this.transaction("reg", "readwrite", function(e) { - for (const d of a.reg.keys()) { - e.put(1, d); + }) : a.bypass || await this.transaction("reg", "readwrite", function(d) { + for (const e of a.reg.keys()) { + d.put(1, e); } - }), a.tag && await this.transaction("tag", "readwrite", function(e) { - for (const d of a.tag) { - const f = d[0], g = d[1]; - g.length && (e.get(f).onsuccess = function() { - let k = this.result; - k = k && k.length ? k.concat(g) : g; - e.put(k, f); + }), a.tag && await this.transaction("tag", "readwrite", function(d) { + for (const e of a.tag) { + const f = e[0], g = e[1]; + g.length && (d.get(f).onsuccess = function() { + let h = this.result; + h = h && h.length ? h.concat(g) : g; + d.put(h, f); }); } }), a.map.clear(), a.ctx.clear(), a.tag && a.tag.clear(), a.store && a.store.clear(), a.document || a.reg.clear()); }; -function Fb(a, c, b) { - const e = a.value; - let d, f = 0; - for (let g = 0, k; g < e.length; g++) { - if (k = b ? e : e[g]) { - for (let h = 0, l, m; h < c.length; h++) { - if (m = c[h], l = k.indexOf(m), 0 <= l) { - if (d = 1, 1 < k.length) { - k.splice(l, 1); +function Fb(a, b, c) { + const d = a.value; + let e, f = 0; + for (let g = 0, h; g < d.length; g++) { + if (h = c ? d : d[g]) { + for (let k = 0, l, m; k < b.length; k++) { + if (m = b[k], l = h.indexOf(m), 0 <= l) { + if (e = 1, 1 < h.length) { + h.splice(l, 1); } else { - e[g] = []; + d[g] = []; break; } } } - f += k.length; + f += h.length; } - if (b) { + if (c) { break; } } - f ? d && a.update(e) : a.delete(); + f ? e && a.update(d) : a.delete(); a.continue(); } -v.remove = function(a) { +w.remove = function(a) { "object" !== typeof a && (a = [a]); - return Promise.all([this.transaction("map", "readwrite", function(c) { - c.openCursor().onsuccess = function() { - const b = this.result; - b && Fb(b, a); + return Promise.all([this.transaction("map", "readwrite", function(b) { + b.openCursor().onsuccess = function() { + const c = this.result; + c && Fb(c, a); }; - }), this.transaction("ctx", "readwrite", function(c) { - c.openCursor().onsuccess = function() { - const b = this.result; - b && Fb(b, a); + }), this.transaction("ctx", "readwrite", function(b) { + b.openCursor().onsuccess = function() { + const c = this.result; + c && Fb(c, a); }; - }), this.transaction("tag", "readwrite", function(c) { - c.openCursor().onsuccess = function() { - const b = this.result; - b && Fb(b, a, !0); + }), this.transaction("tag", "readwrite", function(b) { + b.openCursor().onsuccess = function() { + const c = this.result; + c && Fb(c, a, !0); }; - }), this.transaction("reg", "readwrite", function(c) { - for (let b = 0; b < a.length; b++) { - c.delete(a[b]); + }), this.transaction("reg", "readwrite", function(b) { + for (let c = 0; c < a.length; c++) { + b.delete(a[c]); } })]); }; -function Z(a, c) { - return new Promise((b, e) => { +function Z(a, b) { + return new Promise((c, d) => { a.onsuccess = a.oncomplete = function() { - c && c(this.result); - c = null; - b(this.result); + b && b(this.result); + b = null; + c(this.result); }; - a.onerror = a.onblocked = e; + a.onerror = a.onblocked = d; a = null; }); } -;const Gb = {Index:P, Charset:rb, Encoder:ma, Document:Pa, Worker:Aa, Resolver:Y, IndexedDB:Eb, Language:{}}, Hb = "undefined" !== typeof self ? self : "undefined" !== typeof global ? global : self; +;const Gb = {Index:P, Charset:nb, Encoder:ma, Document:Pa, Worker:Aa, Resolver:Y, IndexedDB:Eb, Language:{}}, Hb = "undefined" !== typeof self ? self : "undefined" !== typeof global ? global : self; let Ib; (Ib = Hb.define) && Ib.amd ? Ib([], function() { return Gb; diff --git a/dist/flexsearch.bundle.min.js b/dist/flexsearch.bundle.min.js index 37f94a3..5f6574b 100644 --- a/dist/flexsearch.bundle.min.js +++ b/dist/flexsearch.bundle.min.js @@ -1,100 +1,101 @@ /**! - * FlexSearch.js v0.8.163 (Bundle) + * FlexSearch.js v0.8.164 (Bundle) * Author and Copyright: Thomas Wilkerling * Licence: Apache-2.0 * Hosted by Nextapps GmbH * https://github.com/nextapps-de/flexsearch */ -(function _f(self){'use strict';if(typeof module!=='undefined')self=module;else if(typeof process !== 'undefined')self=process;self._factory=_f;var v;function F(a,b,c){const e=typeof c,d=typeof a;if("undefined"!==e){if("undefined"!==d){if(c){if("function"===d&&e===d)return function(k){return a(c(k))};b=a.constructor;if(b===c.constructor){if(b===Array)return c.concat(a);if(b===Map){var f=new Map(c);for(var g of a)f.set(g[0],g[1]);return f}if(b===Set){g=new Set(c);for(f of a.values())g.add(f);return g}}}return a}return c}return"undefined"===d?b:a}function G(){return Object.create(null)}function L(a){return"string"===typeof a} -function ca(a){return"object"===typeof a}function da(a){const b=[];for(const c of a.keys())b.push(c);return b}function ea(a,b){if(L(b))a=a[b];else for(let c=0;a&&c"a1a".split(c).length; -this.numeric=F(a.numeric,e)}else{try{this.split=F(this.split,ha)}catch(d){this.split=/\s+/}this.numeric=F(a.numeric,F(this.numeric,!0))}this.prepare=F(a.prepare,null,this.prepare);this.finalize=F(a.finalize,null,this.finalize);c=a.filter;this.filter="function"===typeof c?c:F(c&&new Set(c),null,this.filter);this.dedupe=F(a.dedupe,!0,this.dedupe);this.matcher=F((c=a.matcher)&&new Map(c),null,this.matcher);this.mapper=F((c=a.mapper)&&new Map(c),null,this.mapper);this.stemmer=F((c=a.stemmer)&&new Map(c), -null,this.stemmer);this.replacer=F(a.replacer,null,this.replacer);this.minlength=F(a.minlength,1,this.minlength);this.maxlength=F(a.maxlength,1024,this.maxlength);this.rtl=F(a.rtl,!1,this.rtl);if(this.cache=c=F(a.cache,!0,this.cache))this.H=null,this.S="number"===typeof c?c:2E5,this.B=new Map,this.G=new Map,this.L=this.K=128;this.h="";this.M=null;this.A="";this.N=null;if(this.matcher)for(const d of this.matcher.keys())this.h+=(this.h?"|":"")+d;if(this.stemmer)for(const d of this.stemmer.keys())this.A+= -(this.A?"|":"")+d;return this};v.addStemmer=function(a,b){this.stemmer||(this.stemmer=new Map);this.stemmer.set(a,b);this.A+=(this.A?"|":"")+a;this.N=null;this.cache&&N(this);return this};v.addFilter=function(a){"function"===typeof a?this.filter=a:(this.filter||(this.filter=new Set),this.filter.add(a));this.cache&&N(this);return this}; +(function _f(self){'use strict';if(typeof module!=='undefined')self=module;else if(typeof process !== 'undefined')self=process;self._factory=_f;var v;function E(a,b,c){const d=typeof c,e=typeof a;if("undefined"!==d){if("undefined"!==e){if(c){if("function"===e&&d===e)return function(h){return a(c(h))};b=a.constructor;if(b===c.constructor){if(b===Array)return c.concat(a);if(b===Map){var f=new Map(c);for(var g of a)f.set(g[0],g[1]);return f}if(b===Set){g=new Set(c);for(f of a.values())g.add(f);return g}}}return a}return c}return"undefined"===e?b:a}function H(){return Object.create(null)}function M(a){return"string"===typeof a} +function ca(a){return"object"===typeof a}function da(a){const b=[];for(const c of a.keys())b.push(c);return b}function ea(a,b){if(M(b))a=a[b];else for(let c=0;a&&c"a1a".split(c).length; +this.numeric=E(a.numeric,d)}else{try{this.split=E(this.split,ha)}catch(e){this.split=/\s+/}this.numeric=E(a.numeric,E(this.numeric,!0))}this.prepare=E(a.prepare,null,this.prepare);this.finalize=E(a.finalize,null,this.finalize);c=a.filter;this.filter="function"===typeof c?c:E(c&&new Set(c),null,this.filter);this.dedupe=E(a.dedupe,!0,this.dedupe);this.matcher=E((c=a.matcher)&&new Map(c),null,this.matcher);this.mapper=E((c=a.mapper)&&new Map(c),null,this.mapper);this.stemmer=E((c=a.stemmer)&&new Map(c), +null,this.stemmer);this.replacer=E(a.replacer,null,this.replacer);this.minlength=E(a.minlength,1,this.minlength);this.maxlength=E(a.maxlength,1024,this.maxlength);this.rtl=E(a.rtl,!1,this.rtl);if(this.cache=c=E(a.cache,!0,this.cache))this.H=null,this.S="number"===typeof c?c:2E5,this.B=new Map,this.G=new Map,this.L=this.K=128;this.h="";this.M=null;this.A="";this.N=null;if(this.matcher)for(const e of this.matcher.keys())this.h+=(this.h?"|":"")+e;if(this.stemmer)for(const e of this.stemmer.keys())this.A+= +(this.A?"|":"")+e;return this};v.addStemmer=function(a,b){this.stemmer||(this.stemmer=new Map);this.stemmer.set(a,b);this.A+=(this.A?"|":"")+a;this.N=null;this.cache&&N(this);return this};v.addFilter=function(a){"function"===typeof a?this.filter=a:(this.filter||(this.filter=new Set),this.filter.add(a));this.cache&&N(this);return this}; v.addMapper=function(a,b){if("object"===typeof a)return this.addReplacer(a,b);if(1a.length&&(this.dedupe||this.mapper))return this.addMapper(a,b);this.matcher||(this.matcher=new Map);this.matcher.set(a,b);this.h+=(this.h?"|":"")+a;this.M=null;this.cache&&N(this);return this}; v.addReplacer=function(a,b){if("string"===typeof a)return this.addMatcher(a,b);this.replacer||(this.replacer=[]);this.replacer.push(a,b);this.cache&&N(this);return this}; -v.encode=function(a,b){if(this.cache&&a.length<=this.K)if(this.H){if(this.B.has(a))return this.B.get(a)}else this.H=setTimeout(N,50,this);this.normalize&&("function"===typeof this.normalize?a=this.normalize(a):a=la?a.normalize("NFKD").replace(la,"").toLowerCase():a.toLowerCase());this.prepare&&(a=this.prepare(a));this.numeric&&3this.maxlength)){if(b){if(d[m])continue;d[m]=1}else{if(f===m)continue;f=m}if(c)e.push(m);else if(!this.filter||("function"===typeof this.filter?this.filter(m):!this.filter.has(m))){if(this.cache&&m.length<=this.L)if(this.H){var h=this.G.get(m);if(h||""===h){h&&e.push(h);continue}}else this.H=setTimeout(N,50,this);if(this.stemmer){this.N||(this.N=new RegExp("(?!^)("+ -this.A+")$"));let q;for(;q!==m&&2this.stemmer.get(n))}if(m&&(this.mapper||this.dedupe&&1this.matcher.get(q)));if(m&&this.replacer)for(h=0;m&&hthis.S&&(this.G.clear(),this.L=this.L/1.1|0));if(m){if(m!==t)if(b){if(d[m])continue;d[m]=1}else{if(g===m)continue;g=m}e.push(m)}}}this.finalize&&(e=this.finalize(e)||e);this.cache&&a.length<=this.K&&(this.B.set(a,e),this.B.size>this.S&&(this.B.clear(),this.K=this.K/1.1|0));return e};function N(a){a.H=null;a.B.clear();a.G.clear()};let pa,qa;async function ra(a){a=a.data;var b=a.task;const c=a.id;let e=a.args;switch(b){case "init":qa=a.options||{};(b=a.factory)?(Function("return "+b)()(self),pa=new self.FlexSearch.Index(qa),delete self.FlexSearch):pa=new O(qa);postMessage({id:c});break;default:let d;"export"===b&&(e[1]?(e[0]=qa.export,e[2]=0,e[3]=1):e=null);"import"===b?e[0]&&(a=await qa.import.call(pa,e[0]),pa.import(e[0],a)):(d=e&&pa[b].apply(pa,e))&&d.then&&(d=await d);postMessage("search"===b?{id:c,msg:d}:{id:c})}};function sa(a){ta.call(a,"add");ta.call(a,"append");ta.call(a,"search");ta.call(a,"update");ta.call(a,"remove");ta.call(a,"searchCache")}let ua,xa,ya;function za(){ua=ya=0} -function ta(a){this[a+"Async"]=function(){const b=arguments;var c=b[b.length-1];let e;"function"===typeof c&&(e=c,delete b[b.length-1]);ua?ya||(ya=Date.now()-xa>=this.priority*this.priority*3):(ua=setTimeout(za,0),xa=Date.now());if(ya){const f=this;return new Promise(g=>{setTimeout(function(){g(f[a+"Async"].apply(f,b))},0)})}const d=this[a].apply(this,b);c=d.then?d:new Promise(f=>f(d));e&&c.then(e);return c}};let Aa=0; -function Ba(a={}){function b(g){function k(h){h=h.data||h;const l=h.id,m=l&&d.h[l];m&&(m(h.msg),delete d.h[l])}this.worker=g;this.h=G();if(this.worker){e?this.worker.on("message",k):this.worker.onmessage=k;if(a.config)return new Promise(function(h){d.h[++Aa]=function(){h(d);1E9this.maxlength)){if(b){if(e[m])continue;e[m]=1}else{if(f===m)continue;f=m}if(c)d.push(m);else if(!this.filter||("function"===typeof this.filter?this.filter(m):!this.filter.has(m))){if(this.cache&&m.length<=this.L)if(this.H){var k=this.G.get(m);if(k||""===k){k&&d.push(k);continue}}else this.H=setTimeout(N,50,this);if(this.stemmer){this.N||(this.N=new RegExp("(?!^)("+ +this.A+")$"));let u;for(;u!==m&&2this.stemmer.get(r))}if(m&&(this.mapper||this.dedupe&&1this.matcher.get(u)));if(m&&this.replacer)for(k=0;m&&kthis.S&&(this.G.clear(),this.L=this.L/1.1|0));if(m){if(m!==n)if(b){if(e[m])continue;e[m]=1}else{if(g===m)continue;g=m}d.push(m)}}}this.finalize&&(d=this.finalize(d)||d);this.cache&&a.length<=this.K&&(this.B.set(a,d),this.B.size>this.S&&(this.B.clear(),this.K=this.K/1.1|0));return d};function N(a){a.H=null;a.B.clear();a.G.clear()};let pa,qa;async function ra(a){a=a.data;var b=a.task;const c=a.id;let d=a.args;switch(b){case "init":qa=a.options||{};(b=a.factory)?(Function("return "+b)()(self),pa=new self.FlexSearch.Index(qa),delete self.FlexSearch):pa=new O(qa);postMessage({id:c});break;default:let e;"export"===b&&(d[1]?(d[0]=qa.export,d[2]=0,d[3]=1):d=null);"import"===b?d[0]&&(a=await qa.import.call(pa,d[0]),pa.import(d[0],a)):(e=d&&pa[b].apply(pa,d))&&e.then&&(e=await e);postMessage("search"===b?{id:c,msg:e}:{id:c})}};function sa(a){ta.call(a,"add");ta.call(a,"append");ta.call(a,"search");ta.call(a,"update");ta.call(a,"remove");ta.call(a,"searchCache")}let ua,va,ya;function za(){ua=ya=0} +function ta(a){this[a+"Async"]=function(){const b=arguments;var c=b[b.length-1];let d;"function"===typeof c&&(d=c,delete b[b.length-1]);ua?ya||(ya=Date.now()-va>=this.priority*this.priority*3):(ua=setTimeout(za,0),va=Date.now());if(ya){const f=this;return new Promise(g=>{setTimeout(function(){g(f[a+"Async"].apply(f,b))},0)})}const e=this[a].apply(this,b);c=e.then?e:new Promise(f=>f(e));d&&c.then(d);return c}};let Aa=0; +function Ba(a={},b){function c(h){function k(l){l=l.data||l;const m=l.id,n=m&&f.h[m];n&&(n(l.msg),delete f.h[m])}this.worker=h;this.h=H();if(this.worker){e?this.worker.on("message",k):this.worker.onmessage=k;if(a.config)return new Promise(function(l){f.h[++Aa]=function(){l(f);1E9=g.length)b-=g.length;else{b=g[e?"splice":"slice"](b,c);const k=b.length;if(k&&(d=d.length?d.concat(b):b,c-=k,e&&(a.length-=k),!c))break;b=0}return d} -function R(a){if(!this||this.constructor!==R)return new R(a);this.index=a?[a]:[];this.length=a?a.length:0;const b=this;return new Proxy([],{get(c,e){if("length"===e)return b.length;if("push"===e)return function(d){b.index[b.index.length-1].push(d);b.length++};if("pop"===e)return function(){if(b.length)return b.length--,b.index[b.index.length-1].pop()};if("indexOf"===e)return function(d){let f=0;for(let g=0,k,h;gc||e?h.slice(e,c+e):h;else{if(ac||e)h=h.slice(e,c+e)}else{d= -[];for(let t=0,q;te)e-=q.length;else{if(c&&q.length>c||e)q=q.slice(e,c+e),c-=q.length,e&&(e-=q.length);d.push(q);if(!c)break}h=d}}return h} -function Ta(a,b,c,e,d){const f=[],g=G();let k;var h=a.length;let l;if(e)for(d=h-1;0<=d;d--){if(l=(e=a[d])&&e.length)for(h=0;hb?b?a.slice(c,c+b):a.slice(c):a,e?X.call(this,a):a;let d=[];for(let f=0,g,k;f=k){c-=k;continue}cb&&(g=g.slice(0,b),k=b);if(!d.length&&k>=b)return e?X.call(this,g):g;d.push(g);b-=k;if(!b)break}d=1a.length?this.result=a[0]:(this.result=Ta(a,c,e,!1,this.h),e=0));return f?this.resolve(c,e,d):this};Y.prototype.and=function(){let a=this.result.length,b,c,e,d;if(!a){const f=arguments[0];f&&(a=!!f.suggest,d=f.resolve,b=f.limit,c=f.offset,e=f.enrich&&d)}if(a){const {O:f,P:g,limit:k,offset:h,enrich:l,resolve:m,suggest:t}=Wa(this,"and",arguments);return Ya.call(this,f,g,k,h,l,m,t)}return d?this.resolve(b,c,e):this}; -function Ya(a,b,c,e,d,f,g){if(b.length){const k=this;return Promise.all(b).then(function(h){a=[];for(let l=0,m;la.length)this.result=a[0];else{if(b=fa(a))return this.result=Sa(a,b,c,e,g,this.h,f),f?d?X.call(this.index,this.result):this.result:this;this.result=[]}else g||(this.result=a);return f?this.resolve(c,e,d):this};Y.prototype.xor=function(){const {O:a,P:b,limit:c,offset:e,enrich:d,resolve:f,suggest:g}=Wa(this,"xor",arguments);return Za.call(this,a,b,c,e,d,f,g)}; -function Za(a,b,c,e,d,f,g){if(b.length){const k=this;return Promise.all(b).then(function(h){a=[];for(let l=0,m;la.length)this.result=a[0];else return this.result=$a.call(this,a,c,e,f,this.h),f?d?X.call(this.index,this.result):this.result:this;else g||(this.result=a);return f?this.resolve(c,e,d):this} -function $a(a,b,c,e,d){const f=[],g=G();let k=0;for(let h=0,l;hJ&&(J=p.length+(p?1:0)),B=p.length+(p?1:0)+M.length,z+=E,wa.push(x.length),x.push({match:M})),p+=(p?" ":"")+M)}if(!w)D=y[A],p+=(p?" ":"")+D,h&&x.push({text:D});else if(h&&z>=h)break}z=wa.length*(f.length-2);if(n||r||h&&p.length-z>h)if(z=h+z-2*q,A=B-J, -0y&&(y=0)),x=x.length-1){if(I>= -x.length){A[w+1]=1;I>=y.length&&(z[w+1]=1);continue}E-=q}p=x[I].text;if(K=r&&C[w])if(0K)if(A[w+1]=1,l)p=p.substring(0,K);else continue;(K-=p.length)||(K=-1);C[w]=K}else{A[w+1]=1;continue}if(E+p.length+1<=h)p=" "+p,B[w]+=p;else if(l)S=h-E-1,0=I){if(0>I){A[w]=1;z[w]=1;continue}E-=q}p=x[I].text;if(K=n&&D[w])if(0K)if(A[w]=1,l)p=p.substring(p.length- -K);else continue;(K-=p.length)||(K=-1);D[w]=K}else{A[w]=1;continue}if(E+p.length+1<=h)p+=" ",B[w]=p+B[w];else if(l)S=p.length+1-(h-E),0<=S&&S=y.length-1?Ma=1:Ic||e)a=a.slice(e,e+c);d&&(a=X.call(this,a));return a}}function X(a){if(!this||!this.store)return a;const b=Array(a.length);for(let c=0,e;c=g.length)b-=g.length;else{b=g[d?"splice":"slice"](b,c);const h=b.length;if(h&&(e=e.length?e.concat(b):b,c-=h,d&&(a.length-=h),!c))break;b=0}return e} +function R(a){if(!this||this.constructor!==R)return new R(a);this.index=a?[a]:[];this.length=a?a.length:0;const b=this;return new Proxy([],{get(c,d){if("length"===d)return b.length;if("push"===d)return function(e){b.index[b.index.length-1].push(e);b.length++};if("pop"===d)return function(){if(b.length)return b.length--,b.index[b.index.length-1].pop()};if("indexOf"===d)return function(e){let f=0;for(let g=0,h,k;gb?b?a.slice(c,c+b):a.slice(c):a,d?X.call(this,a):a;let e=[];for(let f=0,g,h;f=h){c-=h;continue}cb&&(g=g.slice(0,b),h=b);if(!e.length&&h>=b)return d?X.call(this,g):g;e.push(g);b-=h;if(!b)break}e=1a.length?this.result=a[0]:(this.result=Va(a,c,d,!1,this.h),d=0));return f?this.resolve(c,d,e):this};Y.prototype.and=function(){let a=this.result.length,b,c,d,e;if(!a){const f=arguments[0];f&&(a=!!f.suggest,e=f.resolve,b=f.limit,c=f.offset,d=f.enrich&&e)}if(a){const {O:f,P:g,limit:h,offset:k,enrich:l,resolve:m,suggest:n}=Ta(this,"and",arguments);return Wa.call(this,f,g,h,k,l,m,n)}return e?this.resolve(b,c,d):this}; +function Wa(a,b,c,d,e,f,g){if(b.length){const h=this;return Promise.all(b).then(function(k){a=[];for(let l=0,m;la.length)this.result=a[0];else{if(b=fa(a))return this.result=Xa(a,b,c,d,g,this.h,f),f?e?X.call(this.index,this.result):this.result:this;this.result=[]}else g||(this.result=a);return f?this.resolve(c,d,e):this};Y.prototype.xor=function(){const {O:a,P:b,limit:c,offset:d,enrich:e,resolve:f,suggest:g}=Ta(this,"xor",arguments);return Ya.call(this,a,b,c,d,e,f,g)}; +function Ya(a,b,c,d,e,f,g){if(b.length){const h=this;return Promise.all(b).then(function(k){a=[];for(let l=0,m;la.length)this.result=a[0];else return this.result=Za.call(this,a,c,d,f,this.h),f?e?X.call(this.index,this.result):this.result:this;else g||(this.result=a);return f?this.resolve(c,d,e):this} +function Za(a,b,c,d,e){const f=[],g=H();let h=0;for(let k=0,l;kD&&(D=t.length+(t?1:0)),G=t.length+(t?1:0)+F.length,B+=C,xa.push(w.length),w.push({match:F})),t+=(t?" ":"")+F)}if(!z)A=y[x],t+=(t?" ":"")+A,k&&w.push({text:A});else if(k&&B>=k)break}B=xa.length*(f.length-2);if(r||p||k&&t.length-B>k)if(B=k+B-2*u,x=G-D, +0y&&(y=0)),w=w.length-1){if(J>= +w.length){x[z+1]=1;J>=y.length&&(B[z+1]=1);continue}C-=u}t=w[J].text;if(K=p&&I[z])if(0K)if(x[z+1]=1,l)t=t.substring(0,K);else continue;(K-=t.length)||(K=-1);I[z]=K}else{x[z+1]=1;continue}if(C+t.length+1<=k)t=" "+t,G[z]+=t;else if(l)T=k-C-1,0=J){if(0>J){x[z]=1;B[z]=1;continue}C-=u}t=w[J].text;if(K=r&&A[z])if(0K)if(x[z]=1,l)t=t.substring(t.length- +K);else continue;(K-=t.length)||(K=-1);A[z]=K}else{x[z]=1;continue}if(C+t.length+1<=k)t+=" ",G[z]=t+G[z];else if(l)T=t.length+1-(k-C),0<=T&&T=y.length-1?Na=1:Jc||d?k.slice(d,c+d):k;else{if(ac||d)k=k.slice(d,c+d)}else{e= +[];for(let n=0,u;nd)d-=u.length;else{if(c&&u.length>c||d)u=u.slice(d,c+d),c-=u.length,d&&(d-=u.length);e.push(u);if(!c)break}k=e}}return k} +function Va(a,b,c,d,e){const f=[],g=H();let h;var k=a.length;let l;if(d)for(e=k-1;0<=e;e--){if(l=(d=a[e])&&d.length)for(k=0;kc||d)a=a.slice(d,d+c);e&&(a=X.call(this,a));return a}} +function X(a){if(!this||!this.store)return a;const b=Array(a.length);for(let c=0,d;cthis.limit&&this.cache.delete(this.cache.keys().next().value)}; -ib.prototype.get=function(a){const b=this.cache.get(a);b&&this.h!==a&&(this.cache.delete(a),this.cache.set(this.h=a,b));return b};ib.prototype.remove=function(a){for(const b of this.cache){const c=b[0];b[1].includes(a)&&this.cache.delete(c)}};ib.prototype.clear=function(){this.cache.clear();this.h=""};const lb={normalize:!1,numeric:!1,dedupe:!1};const mb={};const nb=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 ob=new Map([["ae","a"],["oe","o"],["sh","s"],["kh","k"],["th","t"],["ph","f"],["pf","f"]]),pb=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/(.)\1+/g,"$1"];const qb={a:"",e:"",i:"",o:"",u:"",y:"",b:1,f:1,p:1,v:1,c:2,g:2,j:2,k:2,q:2,s:2,x:2,z:2,"\u00df":2,d:3,t:3,l:4,m:5,n:5,r:6};var rb={Exact:lb,Default:mb,Normalize:mb,LatinBalance:{mapper:nb},LatinAdvanced:{mapper:nb,matcher:ob,replacer:pb},LatinExtra:{mapper:nb,replacer:pb.concat([/(?!^)[aeo]/g,""]),matcher:ob},LatinSoundex:{dedupe:!1,include:{letter:!0},finalize:function(a){for(let c=0;cd.length)d.pop();else{const f=d.indexOf(a);f===c.length-1?d.pop():d.splice(f,1)}}else sb(this.map,a),this.depth&&sb(this.ctx,a);b||this.reg.delete(a)}this.db&&(this.commit_task.push({del:a}),this.T&&tb(this));this.cache&&this.cache.remove(a);return this}; -function sb(a,b){let c=0;var e="undefined"===typeof b;if(a.constructor===Array)for(let d=0,f,g;du;f--){g=r.substring(u,f);p=this.rtl?d-1-u:u;var k=this.score?this.score(b,r,n,g,p):vb(q, -l,n,d,p);wb(this,t,g,k,a,c)}break}case "bidirectional":case "reverse":if(1g?0:1),l,n,k-1,h-1),p=this.bidirectional&&r>f;wb(this,m,p?f:r,u,a,c,p?r:f)}}}}this.fastupdate||this.reg.add(a)}else b=""}this.db&&(b||this.commit_task.push({del:a}),this.T&&tb(this));return this}; -function wb(a,b,c,e,d,f,g){let k=g?a.ctx:a.map,h;if(!b[c]||g&&!(h=b[c])[g])if(g?(b=h||(b[c]=G()),b[g]=1,(h=k.get(g))?k=h:k.set(g,k=new Map)):b[c]=1,(h=k.get(c))?k=h:k.set(c,k=h=[]),k=k[e]||(k[e]=[]),!f||!k.includes(d)){if(k.length===2**31-1){b=new R(k);if(a.fastupdate)for(let l of a.reg.values())l.includes(k)&&(l[l.indexOf(k)]=b);h[e]=k=b}k.push(d);a.fastupdate&&((e=a.reg.get(d))?e.push(k):a.reg.set(d,[k]))}} -function vb(a,b,c,e,d){return c&&1c)&&(h=c,c=b,b=h);if(a.db)return a.db.get(b,c,e,d,f,g,k);a=c?(a=a.ctx.get(c))&&a.get(b):a.map.get(b);return a};function O(a,b){if(!this||this.constructor!==O)return new O(a);if(a){var c=L(a)?a:a.preset;c&&(a=Object.assign({},ub[c],a))}else a={};c=a.context;const e=!0===c?{depth:1}:c||{},d=L(a.encoder)?rb[a.encoder]:a.encode||a.encoder||{};this.encoder=d.encode?d:"object"===typeof d?new ma(d):{encode:d};this.resolution=a.resolution||9;this.tokenize=c=(c=a.tokenize)&&"default"!==c&&"exact"!==c&&c||"strict";this.depth="strict"===c&&e.depth||0;this.bidirectional=!1!==e.bidirectional;this.fastupdate=!!a.fastupdate; -this.score=a.score||null;(c=a.keystore||0)&&(this.keystore=c);this.map=c?new T(c):new Map;this.ctx=c?new T(c):new Map;this.reg=b||(this.fastupdate?c?new T(c):new Map:c?new U(c):new Set);this.U=e.resolution||3;this.rtl=d.rtl||a.rtl||!1;this.cache=(c=a.cache||null)&&new ib(c);this.resolve=!1!==a.resolve;if(c=a.db)this.db=this.mount(c);this.T=!1!==a.commit;this.commit_task=[];this.commit_timer=null;this.priority=a.priority||4}v=O.prototype; +v.get=function(a){return this.db?this.index.get(this.field[0]).db.enrich(a).then(function(b){return b[0]&&b[0].doc||null}):this.store.get(a)||null};v.set=function(a,b){"object"===typeof a&&(b=a,a=ea(b,this.key));this.store.set(a,b);return this};v.searchCache=rb; +v.export=function(a,b,c=0,d=0){if(cthis.limit&&this.cache.delete(this.cache.keys().next().value)}; +pb.prototype.get=function(a){const b=this.cache.get(a);b&&this.h!==a&&(this.cache.delete(a),this.cache.set(this.h=a,b));return b};pb.prototype.remove=function(a){for(const b of this.cache){const c=b[0];b[1].includes(a)&&this.cache.delete(c)}};pb.prototype.clear=function(){this.cache.clear();this.h=""};O.prototype.remove=function(a,b){const c=this.reg.size&&(this.fastupdate?this.reg.get(a):this.reg.has(a));if(c){if(this.fastupdate)for(let d=0,e;de.length)e.pop();else{const f=e.indexOf(a);f===c.length-1?e.pop():e.splice(f,1)}}else sb(this.map,a),this.depth&&sb(this.ctx,a);b||this.reg.delete(a)}this.db&&(this.commit_task.push({del:a}),this.T&&tb(this));this.cache&&this.cache.remove(a);return this}; +function sb(a,b){let c=0;var d="undefined"===typeof b;if(a.constructor===Array)for(let e=0,f,g;eq;f--){g=p.substring(q,f);t=this.rtl?e-1-q:q;var h=this.score?this.score(b,p,r,g,t):vb(u, +l,r,e,t);wb(this,n,g,h,a,c)}break}case "bidirectional":case "reverse":if(1g?0:1),l,r,h-1,k-1),t=this.bidirectional&&p>f;wb(this,m,t?f:p,q,a,c,t?p:f)}}}}this.fastupdate||this.reg.add(a)}else b=""}this.db&&(b||this.commit_task.push({del:a}),this.T&&tb(this));return this}; +function wb(a,b,c,d,e,f,g){let h=g?a.ctx:a.map,k;if(!b[c]||g&&!(k=b[c])[g])if(g?(b=k||(b[c]=H()),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 R(h);if(a.fastupdate)for(let l of a.reg.values())l.includes(h)&&(l[l.indexOf(h)]=b);k[d]=h=b}h.push(e);a.fastupdate&&((d=a.reg.get(e))?d.push(h):a.reg.set(e,[h]))}} +function vb(a,b,c,d,e){return c&&1c)&&(k=c,c=b,b=k);if(a.db)return a.db.get(b,c,d,e,f,g,h);a=c?(a=a.ctx.get(c))&&a.get(b):a.map.get(b);return a};function O(a,b){if(!this||this.constructor!==O)return new O(a);if(a){var c=M(a)?a:a.preset;c&&(a=Object.assign({},ub[c],a))}else a={};c=a.context;const d=!0===c?{depth:1}:c||{},e=M(a.encoder)?nb[a.encoder]:a.encode||a.encoder||{};this.encoder=e.encode?e:"object"===typeof e?new ma(e):{encode:e};this.resolution=a.resolution||9;this.tokenize=c=(c=a.tokenize)&&"default"!==c&&"exact"!==c&&c||"strict";this.depth="strict"===c&&d.depth||0;this.bidirectional=!1!==d.bidirectional;this.fastupdate=!!a.fastupdate; +this.score=a.score||null;(c=a.keystore||0)&&(this.keystore=c);this.map=c?new U(c):new Map;this.ctx=c?new U(c):new Map;this.reg=b||(this.fastupdate?c?new U(c):new Map:c?new V(c):new Set);this.U=d.resolution||3;this.rtl=e.rtl||a.rtl||!1;this.cache=(c=a.cache||null)&&new pb(c);this.resolve=!1!==a.resolve;if(c=a.db)this.db=this.mount(c);this.T=!1!==a.commit;this.commit_task=[];this.commit_timer=null;this.priority=a.priority||4}v=O.prototype; v.mount=function(a){this.commit_timer&&(clearTimeout(this.commit_timer),this.commit_timer=null);return a.mount(this)};v.commit=function(a,b){this.commit_timer&&(clearTimeout(this.commit_timer),this.commit_timer=null);return this.db.commit(this,a,b)};v.destroy=function(){this.commit_timer&&(clearTimeout(this.commit_timer),this.commit_timer=null);return this.db.destroy()};function tb(a){a.commit_timer||(a.commit_timer=setTimeout(function(){a.commit_timer=null;a.db.commit(a,void 0,void 0)},1))} -v.clear=function(){this.map.clear();this.ctx.clear();this.reg.clear();this.cache&&this.cache.clear();this.db&&(this.commit_timer&&clearTimeout(this.commit_timer),this.commit_timer=null,this.commit_task=[{clear:!0}]);return this};v.append=function(a,b){return this.add(a,b,!0)};v.contain=function(a){return this.db?this.db.has(a):this.reg.has(a)};v.update=function(a,b){const c=this,e=this.remove(a);return e&&e.then?e.then(()=>c.add(a,b)):this.add(a,b)}; -v.cleanup=function(){if(!this.fastupdate)return this;sb(this.map);this.depth&&sb(this.ctx);return this};v.searchCache=kb;v.export=function(a,b,c=0,e=0){let d,f;switch(e){case 0:d="reg";f=Ha(this.reg);break;case 1:d="cfg";f=null;break;case 2:d="map";f=Da(this.map,this.reg.size);break;case 3:d="ctx";f=Fa(this.ctx,this.reg.size);break;default:return}return Ja.call(this,a,b,d,f,c,e)}; +v.clear=function(){this.map.clear();this.ctx.clear();this.reg.clear();this.cache&&this.cache.clear();this.db&&(this.commit_timer&&clearTimeout(this.commit_timer),this.commit_timer=null,this.commit_task=[{clear:!0}]);return this};v.append=function(a,b){return this.add(a,b,!0)};v.contain=function(a){return this.db?this.db.has(a):this.reg.has(a)};v.update=function(a,b){const c=this,d=this.remove(a);return d&&d.then?d.then(()=>c.add(a,b)):this.add(a,b)}; +v.cleanup=function(){if(!this.fastupdate)return this;sb(this.map);this.depth&&sb(this.ctx);return this};v.searchCache=rb;v.export=function(a,b,c=0,d=0){let e,f;switch(d){case 0:e="reg";f=Ha(this.reg);break;case 1:e="cfg";f=null;break;case 2:e="map";f=Da(this.map,this.reg.size);break;case 3:e="ctx";f=Fa(this.ctx,this.reg.size);break;default:return}return Ja.call(this,a,b,e,f,c,d)}; v.import=function(a,b){if(b)switch("string"===typeof b&&(b=JSON.parse(b)),a=a.split("."),"json"===a[a.length-1]&&a.pop(),3===a.length&&a.shift(),a=1=m.length){e-=m.length;continue}const t=c?e+Math.min(m.length-e,c):m.length;for(let q=e;q=f.length)return[];if(!b&&!c)return f;f=f.slice(c,c+b);return e?d.enrich(f):f})}; -v.enrich=function(a){"object"!==typeof a&&(a=[a]);const b=this.db.transaction("reg","readonly").objectStore("reg"),c=[];for(let e=0;e=m.length){d-=m.length;continue}const n=c?d+Math.min(m.length-d,c):m.length;for(let u=d;u=f.length)return[];if(!b&&!c)return f;f=f.slice(c,c+b);return d?e.enrich(f):f})}; +v.enrich=function(a){"object"!==typeof a&&(a=[a]);const b=this.db.transaction("reg","readonly").objectStore("reg"),c=[];for(let d=0;d{a.onsuccess=a.oncomplete=function(){b&&b(this.result);b=null;c(this.result)};a.onerror=a.onblocked=e;a=null})};const Gb={Index:O,Charset:rb,Encoder:ma,Document:W,Worker:Ba,Resolver:Y,IndexedDB:Eb,Language:{}},Hb="undefined"!==typeof self?self:"undefined"!==typeof global?global:self;let Ib;(Ib=Hb.define)&&Ib.amd?Ib([],function(){return Gb}):"object"===typeof Hb.exports?Hb.exports=Gb:Hb.FlexSearch=Gb;}(this||self)); +function Z(a,b){return new Promise((c,d)=>{a.onsuccess=a.oncomplete=function(){b&&b(this.result);b=null;c(this.result)};a.onerror=a.onblocked=d;a=null})};const Gb={Index:O,Charset:nb,Encoder:ma,Document:W,Worker:Ba,Resolver:Y,IndexedDB:Eb,Language:{}},Hb="undefined"!==typeof self?self:"undefined"!==typeof global?global:self;let Ib;(Ib=Hb.define)&&Ib.amd?Ib([],function(){return Gb}):"object"===typeof Hb.exports?Hb.exports=Gb:Hb.FlexSearch=Gb;}(this||self)); diff --git a/dist/flexsearch.bundle.module.debug.js b/dist/flexsearch.bundle.module.debug.js index d2617d6..6b53055 100644 --- a/dist/flexsearch.bundle.module.debug.js +++ b/dist/flexsearch.bundle.module.debug.js @@ -1,35 +1,35 @@ /**! - * FlexSearch.js v0.8.163 (Bundle/Module/Debug) + * FlexSearch.js v0.8.164 (Bundle/Module/Debug) * Author and Copyright: Thomas Wilkerling * Licence: Apache-2.0 * Hosted by Nextapps GmbH * https://github.com/nextapps-de/flexsearch */ -var v; -function F(a, c, b) { - const e = typeof b, d = typeof a; - if ("undefined" !== e) { - if ("undefined" !== d) { - if (b) { - if ("function" === d && e === d) { - return function(k) { - return a(b(k)); +var w; +function E(a, b, c) { + const d = typeof c, e = typeof a; + if ("undefined" !== d) { + if ("undefined" !== e) { + if (c) { + if ("function" === e && d === e) { + return function(h) { + return a(c(h)); }; } - c = a.constructor; - if (c === b.constructor) { - if (c === Array) { - return b.concat(a); + b = a.constructor; + if (b === c.constructor) { + if (b === Array) { + return c.concat(a); } - if (c === Map) { - var f = new Map(b); + if (b === Map) { + var f = new Map(c); for (var g of a) { f.set(g[0], g[1]); } return f; } - if (c === Set) { - g = new Set(b); + if (b === Set) { + g = new Set(c); for (f of a.values()) { g.add(f); } @@ -39,42 +39,42 @@ function F(a, c, b) { } return a; } - return b; + return c; } - return "undefined" === d ? c : a; + return "undefined" === e ? b : a; } -function G() { +function H() { return Object.create(null); } -function L(a) { +function M(a) { return "string" === typeof a; } function aa(a) { return "object" === typeof a; } function da(a) { - const c = []; - for (const b of a.keys()) { - c.push(b); + const b = []; + for (const c of a.keys()) { + b.push(c); } - return c; + return b; } -function ea(a, c) { - if (L(c)) { - a = a[c]; +function ea(a, b) { + if (M(b)) { + a = a[b]; } else { - for (let b = 0; a && b < c.length; b++) { - a = a[c[b]]; + for (let c = 0; a && c < b.length; c++) { + a = a[b[c]]; } } return a; } function fa(a) { - let c = 0; - for (let b = 0, e; b < a.length; b++) { - (e = a[b]) && c < e.length && (c = e.length); + let b = 0; + for (let c = 0, d; c < a.length; c++) { + (d = a[c]) && b < d.length && (b = d.length); } - return c; + return b; } ;const ha = /[^\p{L}\p{N}]+/u, ia = /(\d{3})/g, ja = /(\D)(\d{3})/g, ka = /(\d{3})(\D)/g, la = /[\u0300-\u036f]/g; function ma(a = {}) { @@ -89,120 +89,120 @@ function ma(a = {}) { this.assign(a); } } -v = ma.prototype; -v.assign = function(a) { - this.normalize = F(a.normalize, !0, this.normalize); - let c = a.include, b = c || a.exclude || a.split, e; - if (b || "" === b) { - if ("object" === typeof b && b.constructor !== RegExp) { - let d = ""; - e = !c; - c || (d += "\\p{Z}"); - b.letter && (d += "\\p{L}"); - b.number && (d += "\\p{N}", e = !!c); - b.symbol && (d += "\\p{S}"); - b.punctuation && (d += "\\p{P}"); - b.control && (d += "\\p{C}"); - if (b = b.char) { - d += "object" === typeof b ? b.join("") : b; +w = ma.prototype; +w.assign = function(a) { + this.normalize = E(a.normalize, !0, this.normalize); + let b = a.include, c = b || a.exclude || a.split, d; + if (c || "" === c) { + if ("object" === typeof c && c.constructor !== RegExp) { + let e = ""; + d = !b; + b || (e += "\\p{Z}"); + c.letter && (e += "\\p{L}"); + c.number && (e += "\\p{N}", d = !!b); + c.symbol && (e += "\\p{S}"); + c.punctuation && (e += "\\p{P}"); + c.control && (e += "\\p{C}"); + if (c = c.char) { + e += "object" === typeof c ? c.join("") : c; } try { - this.split = new RegExp("[" + (c ? "^" : "") + d + "]+", "u"); + this.split = new RegExp("[" + (b ? "^" : "") + e + "]+", "u"); } catch (f) { - console.error("Your split configuration:", b, "is not supported on this platform. It falls back to using simple whitespace splitter instead: /s+/."), this.split = /\s+/; + console.error("Your split configuration:", c, "is not supported on this platform. It falls back to using simple whitespace splitter instead: /s+/."), this.split = /\s+/; } } else { - this.split = b, e = !1 === b || 2 > "a1a".split(b).length; + this.split = c, d = !1 === c || 2 > "a1a".split(c).length; } - this.numeric = F(a.numeric, e); + this.numeric = E(a.numeric, d); } else { try { - this.split = F(this.split, ha); - } catch (d) { + this.split = E(this.split, ha); + } catch (e) { console.warn("This platform does not support unicode regex. It falls back to using simple whitespace splitter instead: /s+/."), this.split = /\s+/; } - this.numeric = F(a.numeric, F(this.numeric, !0)); + this.numeric = E(a.numeric, E(this.numeric, !0)); } - this.prepare = F(a.prepare, null, this.prepare); - this.finalize = F(a.finalize, null, this.finalize); - b = a.filter; - this.filter = "function" === typeof b ? b : F(b && new Set(b), null, this.filter); - this.dedupe = F(a.dedupe, !0, this.dedupe); - this.matcher = F((b = a.matcher) && new Map(b), null, this.matcher); - this.mapper = F((b = a.mapper) && new Map(b), null, this.mapper); - this.stemmer = F((b = a.stemmer) && new Map(b), null, this.stemmer); - this.replacer = F(a.replacer, null, this.replacer); - this.minlength = F(a.minlength, 1, this.minlength); - this.maxlength = F(a.maxlength, 1024, this.maxlength); - this.rtl = F(a.rtl, !1, this.rtl); - if (this.cache = b = F(a.cache, !0, this.cache)) { - this.H = null, this.S = "number" === typeof b ? b : 2e5, this.B = new Map(), this.G = new Map(), this.L = this.K = 128; + this.prepare = E(a.prepare, null, this.prepare); + this.finalize = E(a.finalize, null, this.finalize); + c = a.filter; + this.filter = "function" === typeof c ? c : E(c && new Set(c), null, this.filter); + this.dedupe = E(a.dedupe, !0, this.dedupe); + this.matcher = E((c = a.matcher) && new Map(c), null, this.matcher); + this.mapper = E((c = a.mapper) && new Map(c), null, this.mapper); + this.stemmer = E((c = a.stemmer) && new Map(c), null, this.stemmer); + this.replacer = E(a.replacer, null, this.replacer); + this.minlength = E(a.minlength, 1, this.minlength); + this.maxlength = E(a.maxlength, 1024, this.maxlength); + this.rtl = E(a.rtl, !1, this.rtl); + if (this.cache = c = E(a.cache, !0, this.cache)) { + this.H = null, this.S = "number" === typeof c ? c : 2e5, this.B = new Map(), this.G = new Map(), this.L = this.K = 128; } this.h = ""; this.M = null; this.A = ""; this.N = null; if (this.matcher) { - for (const d of this.matcher.keys()) { - this.h += (this.h ? "|" : "") + d; + for (const e of this.matcher.keys()) { + this.h += (this.h ? "|" : "") + e; } } if (this.stemmer) { - for (const d of this.stemmer.keys()) { - this.A += (this.A ? "|" : "") + d; + for (const e of this.stemmer.keys()) { + this.A += (this.A ? "|" : "") + e; } } return this; }; -v.addStemmer = function(a, c) { +w.addStemmer = function(a, b) { this.stemmer || (this.stemmer = new Map()); - this.stemmer.set(a, c); + this.stemmer.set(a, b); this.A += (this.A ? "|" : "") + a; this.N = null; this.cache && N(this); return this; }; -v.addFilter = function(a) { +w.addFilter = function(a) { "function" === typeof a ? this.filter = a : (this.filter || (this.filter = new Set()), this.filter.add(a)); this.cache && N(this); return this; }; -v.addMapper = function(a, c) { +w.addMapper = function(a, b) { if ("object" === typeof a) { - return this.addReplacer(a, c); + return this.addReplacer(a, b); } if (1 < a.length) { - return this.addMatcher(a, c); + return this.addMatcher(a, b); } this.mapper || (this.mapper = new Map()); - this.mapper.set(a, c); + this.mapper.set(a, b); this.cache && N(this); return this; }; -v.addMatcher = function(a, c) { +w.addMatcher = function(a, b) { if ("object" === typeof a) { - return this.addReplacer(a, c); + return this.addReplacer(a, b); } if (2 > a.length && (this.dedupe || this.mapper)) { - return this.addMapper(a, c); + return this.addMapper(a, b); } this.matcher || (this.matcher = new Map()); - this.matcher.set(a, c); + this.matcher.set(a, b); this.h += (this.h ? "|" : "") + a; this.M = null; this.cache && N(this); return this; }; -v.addReplacer = function(a, c) { +w.addReplacer = function(a, b) { if ("string" === typeof a) { - return this.addMatcher(a, c); + return this.addMatcher(a, b); } this.replacer || (this.replacer = []); - this.replacer.push(a, c); + this.replacer.push(a, b); this.cache && N(this); return this; }; -v.encode = function(a, c) { +w.encode = function(a, b) { if (this.cache && a.length <= this.K) { if (this.H) { if (this.B.has(a)) { @@ -215,30 +215,30 @@ v.encode = function(a, c) { this.normalize && ("function" === typeof this.normalize ? a = this.normalize(a) : a = la ? a.normalize("NFKD").replace(la, "").toLowerCase() : a.toLowerCase()); this.prepare && (a = this.prepare(a)); this.numeric && 3 < a.length && (a = a.replace(ja, "$1 $2").replace(ka, "$1 $2").replace(ia, "$1 ")); - const b = !(this.dedupe || this.mapper || this.filter || this.matcher || this.stemmer || this.replacer); - let e = [], d = G(), f, g, k = this.split || "" === this.split ? a.split(this.split) : [a]; - for (let l = 0, m, t; l < k.length; l++) { - if ((m = t = k[l]) && !(m.length < this.minlength || m.length > this.maxlength)) { - if (c) { - if (d[m]) { + const c = !(this.dedupe || this.mapper || this.filter || this.matcher || this.stemmer || this.replacer); + let d = [], e = H(), f, g, h = this.split || "" === this.split ? a.split(this.split) : [a]; + for (let l = 0, m, p; l < h.length; l++) { + if ((m = p = h[l]) && !(m.length < this.minlength || m.length > this.maxlength)) { + if (b) { + if (e[m]) { continue; } - d[m] = 1; + e[m] = 1; } else { if (f === m) { continue; } f = m; } - if (b) { - e.push(m); + if (c) { + d.push(m); } else { if (!this.filter || ("function" === typeof this.filter ? this.filter(m) : !this.filter.has(m))) { if (this.cache && m.length <= this.L) { if (this.H) { - var h = this.G.get(m); - if (h || "" === h) { - h && e.push(h); + var k = this.G.get(m); + if (k || "" === k) { + k && d.push(k); continue; } } else { @@ -247,32 +247,32 @@ v.encode = function(a, c) { } if (this.stemmer) { this.N || (this.N = new RegExp("(?!^)(" + this.A + ")$")); - let q; - for (; q !== m && 2 < m.length;) { - q = m, m = m.replace(this.N, n => this.stemmer.get(n)); + let u; + for (; u !== m && 2 < m.length;) { + u = m, m = m.replace(this.N, q => this.stemmer.get(q)); } } if (m && (this.mapper || this.dedupe && 1 < m.length)) { - h = ""; - for (let q = 0, n = "", r, u; q < m.length; q++) { - r = m.charAt(q), r === n && this.dedupe || ((u = this.mapper && this.mapper.get(r)) || "" === u ? u === n && this.dedupe || !(n = u) || (h += u) : h += n = r); + k = ""; + for (let u = 0, q = "", r, n; u < m.length; u++) { + r = m.charAt(u), r === q && this.dedupe || ((n = this.mapper && this.mapper.get(r)) || "" === n ? n === q && this.dedupe || !(q = n) || (k += n) : k += q = r); } - m = h; + m = k; } - this.matcher && 1 < m.length && (this.M || (this.M = new RegExp("(" + this.h + ")", "g")), m = m.replace(this.M, q => this.matcher.get(q))); + this.matcher && 1 < m.length && (this.M || (this.M = new RegExp("(" + this.h + ")", "g")), m = m.replace(this.M, u => this.matcher.get(u))); if (m && this.replacer) { - for (h = 0; m && h < this.replacer.length; h += 2) { - m = m.replace(this.replacer[h], this.replacer[h + 1]); + for (k = 0; m && k < this.replacer.length; k += 2) { + m = m.replace(this.replacer[k], this.replacer[k + 1]); } } - this.cache && t.length <= this.L && (this.G.set(t, m), this.G.size > this.S && (this.G.clear(), this.L = this.L / 1.1 | 0)); + this.cache && p.length <= this.L && (this.G.set(p, m), this.G.size > this.S && (this.G.clear(), this.L = this.L / 1.1 | 0)); if (m) { - if (m !== t) { - if (c) { - if (d[m]) { + if (m !== p) { + if (b) { + if (e[m]) { continue; } - d[m] = 1; + e[m] = 1; } else { if (g === m) { continue; @@ -280,15 +280,15 @@ v.encode = function(a, c) { g = m; } } - e.push(m); + d.push(m); } } } } } - this.finalize && (e = this.finalize(e) || e); - this.cache && a.length <= this.K && (this.B.set(a, e), this.B.size > this.S && (this.B.clear(), this.K = this.K / 1.1 | 0)); - return e; + this.finalize && (d = this.finalize(d) || d); + this.cache && a.length <= this.K && (this.B.set(a, d), this.B.size > this.S && (this.B.clear(), this.K = this.K / 1.1 | 0)); + return d; }; function N(a) { a.H = null; @@ -298,32 +298,32 @@ function N(a) { ;let pa, O; async function qa(a) { a = a.data; - var c = a.task; - const b = a.id; - let e = a.args; - switch(c) { + var b = a.task; + const c = a.id; + let d = a.args; + switch(b) { case "init": O = a.options || {}; - (c = a.factory) ? (Function("return " + c)()(self), pa = new self.FlexSearch.Index(O), delete self.FlexSearch) : pa = new P(O); - postMessage({id:b}); + (b = a.factory) ? (Function("return " + b)()(self), pa = new self.FlexSearch.Index(O), delete self.FlexSearch) : pa = new P(O); + postMessage({id:c}); break; default: - let d; - if ("export" === c) { + let e; + if ("export" === b) { if (!O.export || "function" !== typeof O.export) { throw Error('Either no extern configuration provided for the Worker-Index or no method was defined on the config property "export".'); } - e[1] ? (e[0] = O.export, e[2] = 0, e[3] = 1) : e = null; + d[1] ? (d[0] = O.export, d[2] = 0, d[3] = 1) : d = null; } - if ("import" === c) { + if ("import" === b) { if (!O.import || "function" !== typeof O.import) { throw Error('Either no extern configuration provided for the Worker-Index or no method was defined on the config property "import".'); } - e[0] && (a = await O.import.call(pa, e[0]), pa.import(e[0], a)); + d[0] && (a = await O.import.call(pa, d[0]), pa.import(d[0], a)); } else { - (d = e && pa[c].apply(pa, e)) && d.then && (d = await d); + (e = d && pa[b].apply(pa, d)) && e.then && (e = await e); } - postMessage("search" === c ? {id:b, msg:d} : {id:b}); + postMessage("search" === b ? {id:c, msg:e} : {id:c}); } } ;function ra(a) { @@ -334,66 +334,67 @@ async function qa(a) { sa.call(a, "remove"); sa.call(a, "searchCache"); } -let ta, ua, xa; +let ta, ua, va; function ya() { - ta = xa = 0; + ta = va = 0; } function sa(a) { this[a + "Async"] = function() { - const c = arguments; - var b = c[c.length - 1]; - let e; - "function" === typeof b && (e = b, delete c[c.length - 1]); - ta ? xa || (xa = Date.now() - ua >= this.priority * this.priority * 3) : (ta = setTimeout(ya, 0), ua = Date.now()); - if (xa) { + const b = arguments; + var c = b[b.length - 1]; + let d; + "function" === typeof c && (d = c, delete b[b.length - 1]); + ta ? va || (va = Date.now() - ua >= this.priority * this.priority * 3) : (ta = setTimeout(ya, 0), ua = Date.now()); + if (va) { const f = this; return new Promise(g => { setTimeout(function() { - g(f[a + "Async"].apply(f, c)); + g(f[a + "Async"].apply(f, b)); }, 0); }); } - const d = this[a].apply(this, c); - b = d.then ? d : new Promise(f => f(d)); - e && b.then(e); - return b; + const e = this[a].apply(this, b); + c = e.then ? e : new Promise(f => f(e)); + d && c.then(d); + return c; }; } ;let za = 0; -function Aa(a = {}) { - function c(g) { - function k(h) { - h = h.data || h; - const l = h.id, m = l && d.h[l]; - m && (m(h.msg), delete d.h[l]); +function Aa(a = {}, b) { + function c(h) { + function k(l) { + l = l.data || l; + const m = l.id, p = m && f.h[m]; + p && (p(l.msg), delete f.h[m]); } - this.worker = g; - this.h = G(); + this.worker = h; + this.h = H(); if (this.worker) { e ? this.worker.on("message", k) : this.worker.onmessage = k; if (a.config) { - return new Promise(function(h) { - d.h[++za] = function() { - h(d); + return new Promise(function(l) { + f.h[++za] = function() { + l(f); 1e9 < za && (za = 0); }; - d.worker.postMessage({id:za, task:"init", factory:b, options:a}); + f.worker.postMessage({id:za, task:"init", factory:d, options:a}); }); } - this.worker.postMessage({task:"init", factory:b, options:a}); + this.worker.postMessage({task:"init", factory:d, options:a}); this.priority = a.priority || 4; + b && (this.encoder = b); return this; } } if (!this || this.constructor !== Aa) { return new Aa(a); } - let b = "undefined" !== typeof self ? self._factory : "undefined" !== typeof window ? window._factory : null; - b && (b = b.toString()); - const e = "undefined" === typeof window, d = this, f = Ba(b, e, a.worker); - return f.then ? f.then(function(g) { - return c.call(d, g); - }) : c.call(this, f); + let d = "undefined" !== typeof self ? self._factory : "undefined" !== typeof window ? window._factory : null; + d && (d = d.toString()); + const e = "undefined" === typeof window, f = this, g = Ba(d, e, a.worker); + return g.then ? g.then(function(h) { + return c.call(f, h); + }) : c.call(this, g); } R("add"); R("append"); @@ -406,757 +407,631 @@ R("import"); ra(Aa.prototype); function R(a) { Aa.prototype[a] = function() { - const c = this, b = [].slice.call(arguments); - var e = b[b.length - 1]; - let d; - "function" === typeof e && (d = e, b.pop()); - e = new Promise(function(f) { - "export" === a && "function" === typeof b[0] && (b[0] = null); - c.h[++za] = f; - c.worker.postMessage({task:a, id:za, args:b}); + const b = this, c = [].slice.call(arguments); + var d = c[c.length - 1]; + let e; + "function" === typeof d && (e = d, c.pop()); + d = new Promise(function(f) { + "export" === a && "function" === typeof c[0] && (c[0] = null); + b.h[++za] = f; + b.worker.postMessage({task:a, id:za, args:c}); }); - return d ? (e.then(d), this) : e; + return e ? (d.then(e), this) : d; }; } -function Ba(a, c, b) { - return c ? "undefined" !== typeof module ? new(require("worker_threads")["Worker"])(__dirname+"/worker/node.js") : import("worker_threads").then(function(worker){return new worker["Worker"](import.meta.dirname+"/node/node.mjs")}) : a ? new window.Worker(URL.createObjectURL(new Blob(["onmessage=" + qa.toString()], {type:"text/javascript"}))) : new window.Worker("string" === typeof b ? b : import.meta.url.replace("/worker.js", "/worker/worker.js").replace("flexsearch.bundle.module.min.js", +function Ba(a, b, c) { + return b ? "undefined" !== typeof module ? new(require("worker_threads")["Worker"])(__dirname+"/worker/node.js") : import("worker_threads").then(function(worker){return new worker["Worker"](import.meta.dirname+"/node/node.mjs")}) : a ? new window.Worker(URL.createObjectURL(new Blob(["onmessage=" + qa.toString()], {type:"text/javascript"}))) : new window.Worker("string" === typeof c ? c : import.meta.url.replace("/worker.js", "/worker/worker.js").replace("flexsearch.bundle.module.min.js", "module/worker/worker.js"), {type:"module"}); } -;function Ca(a, c = 0) { - let b = [], e = []; - c && (c = 250000 / c * 5000 | 0); - for (const d of a.entries()) { - e.push(d), e.length === c && (b.push(e), e = []); - } - e.length && b.push(e); - return b; -} -function Da(a, c) { - c || (c = new Map()); - for (let b = 0, e; b < a.length; b++) { - e = a[b], c.set(e[0], e[1]); +;function Ca(a, b = 0) { + let c = [], d = []; + b && (b = 250000 / b * 5000 | 0); + for (const e of a.entries()) { + d.push(e), d.length === b && (c.push(d), d = []); } + d.length && c.push(d); return c; } -function Ea(a, c = 0) { - let b = [], e = []; - c && (c = 250000 / c * 1000 | 0); - for (const d of a.entries()) { - e.push([d[0], Ca(d[1])[0]]), e.length === c && (b.push(e), e = []); +function Da(a, b) { + b || (b = new Map()); + for (let c = 0, d; c < a.length; c++) { + d = a[c], b.set(d[0], d[1]); } - e.length && b.push(e); return b; } -function Fa(a, c) { - c || (c = new Map()); - for (let b = 0, e, d; b < a.length; b++) { - e = a[b], d = c.get(e[0]), c.set(e[0], Da(e[1], d)); +function Ea(a, b = 0) { + let c = [], d = []; + b && (b = 250000 / b * 1000 | 0); + for (const e of a.entries()) { + d.push([e[0], Ca(e[1])[0]]), d.length === b && (c.push(d), d = []); } + d.length && c.push(d); return c; } +function Fa(a, b) { + b || (b = new Map()); + for (let c = 0, d, e; c < a.length; c++) { + d = a[c], e = b.get(d[0]), b.set(d[0], Da(d[1], e)); + } + return b; +} function Ga(a) { - let c = [], b = []; - for (const e of a.keys()) { - b.push(e), 250000 === b.length && (c.push(b), b = []); + let b = [], c = []; + for (const d of a.keys()) { + c.push(d), 250000 === c.length && (b.push(c), c = []); } - b.length && c.push(b); - return c; + c.length && b.push(c); + return b; } -function Ha(a, c) { - c || (c = new Set()); - for (let b = 0; b < a.length; b++) { - c.add(a[b]); - } - return c; -} -function Ia(a, c, b, e, d, f, g = 0) { - const k = e && e.constructor === Array; - var h = k ? e.shift() : e; - if (!h) { - return this.export(a, c, d, f + 1); - } - if ((h = a((c ? c + "." : "") + (g + 1) + "." + b, JSON.stringify(h))) && h.then) { - const l = this; - return h.then(function() { - return Ia.call(l, a, c, b, k ? e : null, d, f, g + 1); - }); - } - return Ia.call(this, a, c, b, k ? e : null, d, f, g + 1); -} -function Ja(a, c) { - let b = ""; - for (const e of a.entries()) { - a = e[0]; - const d = e[1]; - let f = ""; - for (let g = 0, k; g < d.length; g++) { - k = d[g] || [""]; - let h = ""; - for (let l = 0; l < k.length; l++) { - h += (h ? "," : "") + ("string" === c ? '"' + k[l] + '"' : k[l]); - } - h = "[" + h + "]"; - f += (f ? "," : "") + h; - } - f = '["' + a + '",[' + f + "]]"; - b += (b ? "," : "") + f; +function Ha(a, b) { + b || (b = new Set()); + for (let c = 0; c < a.length; c++) { + b.add(a[c]); } return b; } -;function Ma(a, c, b, e) { - let d = []; +function Ia(a, b, c, d, e, f, g = 0) { + const h = d && d.constructor === Array; + var k = h ? d.shift() : d; + if (!k) { + return this.export(a, b, e, f + 1); + } + if ((k = a((b ? b + "." : "") + (g + 1) + "." + c, JSON.stringify(k))) && k.then) { + const l = this; + return k.then(function() { + return Ia.call(l, a, b, c, h ? d : null, e, f, g + 1); + }); + } + return Ia.call(this, a, b, c, h ? d : null, e, f, g + 1); +} +function Ja(a, b) { + let c = ""; + for (const d of a.entries()) { + a = d[0]; + const e = d[1]; + let f = ""; + for (let g = 0, h; g < e.length; g++) { + h = e[g] || [""]; + let k = ""; + for (let l = 0; l < h.length; l++) { + k += (k ? "," : "") + ("string" === b ? '"' + h[l] + '"' : h[l]); + } + k = "[" + k + "]"; + f += (f ? "," : "") + k; + } + f = '["' + a + '",[' + f + "]]"; + c += (c ? "," : "") + f; + } + return c; +} +;function Ka(a, b, c, d) { + let e = []; for (let f = 0, g; f < a.index.length; f++) { - if (g = a.index[f], c >= g.length) { - c -= g.length; + if (g = a.index[f], b >= g.length) { + b -= g.length; } else { - c = g[e ? "splice" : "slice"](c, b); - const k = c.length; - if (k && (d = d.length ? d.concat(c) : c, b -= k, e && (a.length -= k), !b)) { + b = g[d ? "splice" : "slice"](b, c); + const h = b.length; + if (h && (e = e.length ? e.concat(b) : b, c -= h, d && (a.length -= h), !c)) { break; } - c = 0; + b = 0; } } - return d; + return e; } -function T(a) { - if (!this || this.constructor !== T) { - return new T(a); +function U(a) { + if (!this || this.constructor !== U) { + return new U(a); } this.index = a ? [a] : []; this.length = a ? a.length : 0; - const c = this; - return new Proxy([], {get(b, e) { - if ("length" === e) { - return c.length; + const b = this; + return new Proxy([], {get(c, d) { + if ("length" === d) { + return b.length; } - if ("push" === e) { - return function(d) { - c.index[c.index.length - 1].push(d); - c.length++; + if ("push" === d) { + return function(e) { + b.index[b.index.length - 1].push(e); + b.length++; }; } - if ("pop" === e) { + if ("pop" === d) { return function() { - if (c.length) { - return c.length--, c.index[c.index.length - 1].pop(); + if (b.length) { + return b.length--, b.index[b.index.length - 1].pop(); } }; } - if ("indexOf" === e) { - return function(d) { + if ("indexOf" === d) { + return function(e) { let f = 0; - for (let g = 0, k, h; g < c.index.length; g++) { - k = c.index[g]; - h = k.indexOf(d); - if (0 <= h) { - return f + h; + for (let g = 0, h, k; g < b.index.length; g++) { + h = b.index[g]; + k = h.indexOf(e); + if (0 <= k) { + return f + k; } - f += k.length; + f += h.length; } return -1; }; } - if ("includes" === e) { - return function(d) { - for (let f = 0; f < c.index.length; f++) { - if (c.index[f].includes(d)) { + if ("includes" === d) { + return function(e) { + for (let f = 0; f < b.index.length; f++) { + if (b.index[f].includes(e)) { return !0; } } return !1; }; } - if ("slice" === e) { - return function(d, f) { - return Ma(c, d || 0, f || c.length, !1); + if ("slice" === d) { + return function(e, f) { + return Ka(b, e || 0, f || b.length, !1); }; } - if ("splice" === e) { - return function(d, f) { - return Ma(c, d || 0, f || c.length, !0); + if ("splice" === d) { + return function(e, f) { + return Ka(b, e || 0, f || b.length, !0); }; } - if ("constructor" === e) { + if ("constructor" === d) { return Array; } - if ("symbol" !== typeof e) { - return (b = c.index[e / 2 ** 31 | 0]) && b[e]; + if ("symbol" !== typeof d) { + return (c = b.index[d / 2 ** 31 | 0]) && c[d]; } - }, set(b, e, d) { - b = e / 2 ** 31 | 0; - (c.index[b] || (c.index[b] = []))[e] = d; - c.length++; + }, set(c, d, e) { + c = d / 2 ** 31 | 0; + (b.index[c] || (b.index[c] = []))[d] = e; + b.length++; return !0; }}); } -T.prototype.clear = function() { +U.prototype.clear = function() { this.index.length = 0; }; -T.prototype.destroy = function() { +U.prototype.destroy = function() { this.proxy = this.index = null; }; -T.prototype.push = function() { -}; -function U(a = 8) { - if (!this || this.constructor !== U) { - return new U(a); - } - this.index = G(); - this.h = []; - this.size = 0; - 32 < a ? (this.B = Na, this.A = BigInt(a)) : (this.B = Oa, this.A = a); -} -U.prototype.get = function(a) { - const c = this.index[this.B(a)]; - return c && c.get(a); -}; -U.prototype.set = function(a, c) { - var b = this.B(a); - let e = this.index[b]; - e ? (b = e.size, e.set(a, c), (b -= e.size) && this.size++) : (this.index[b] = e = new Map([[a, c]]), this.h.push(e), this.size++); +U.prototype.push = function() { }; function V(a = 8) { if (!this || this.constructor !== V) { return new V(a); } - this.index = G(); + this.index = H(); this.h = []; this.size = 0; 32 < a ? (this.B = Na, this.A = BigInt(a)) : (this.B = Oa, this.A = a); } -V.prototype.add = function(a) { +V.prototype.get = function(a) { + const b = this.index[this.B(a)]; + return b && b.get(a); +}; +V.prototype.set = function(a, b) { var c = this.B(a); - let b = this.index[c]; - b ? (c = b.size, b.add(a), (c -= b.size) && this.size++) : (this.index[c] = b = new Set([a]), this.h.push(b), this.size++); + 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.h.push(d), this.size++); }; -v = U.prototype; -v.has = V.prototype.has = function(a) { - const c = this.index[this.B(a)]; - return c && c.has(a); +function W(a = 8) { + if (!this || this.constructor !== W) { + return new W(a); + } + this.index = H(); + this.h = []; + this.size = 0; + 32 < a ? (this.B = Na, this.A = BigInt(a)) : (this.B = Oa, this.A = a); +} +W.prototype.add = function(a) { + var b = this.B(a); + let c = this.index[b]; + c ? (b = c.size, c.add(a), (b -= c.size) && this.size++) : (this.index[b] = c = new Set([a]), this.h.push(c), this.size++); }; -v.delete = V.prototype.delete = function(a) { - const c = this.index[this.B(a)]; - c && c.delete(a) && this.size--; +w = V.prototype; +w.has = W.prototype.has = function(a) { + const b = this.index[this.B(a)]; + return b && b.has(a); }; -v.clear = V.prototype.clear = function() { - this.index = G(); +w.delete = W.prototype.delete = function(a) { + const b = this.index[this.B(a)]; + b && b.delete(a) && this.size--; +}; +w.clear = W.prototype.clear = function() { + this.index = H(); this.h = []; this.size = 0; }; -v.values = V.prototype.values = function*() { +w.values = W.prototype.values = function*() { for (let a = 0; a < this.h.length; a++) { - for (let c of this.h[a].values()) { - yield c; + for (let b of this.h[a].values()) { + yield b; } } }; -v.keys = V.prototype.keys = function*() { +w.keys = W.prototype.keys = function*() { for (let a = 0; a < this.h.length; a++) { - for (let c of this.h[a].keys()) { - yield c; + for (let b of this.h[a].keys()) { + yield b; } } }; -v.entries = V.prototype.entries = function*() { +w.entries = W.prototype.entries = function*() { for (let a = 0; a < this.h.length; a++) { - for (let c of this.h[a].entries()) { - yield c; + for (let b of this.h[a].entries()) { + yield b; } } }; function Oa(a) { - let c = 2 ** this.A - 1; + let b = 2 ** this.A - 1; if ("number" == typeof a) { - return a & c; + return a & b; } - let b = 0, e = this.A + 1; - for (let d = 0; d < a.length; d++) { - b = (b * e ^ a.charCodeAt(d)) & c; + let c = 0, d = this.A + 1; + for (let e = 0; e < a.length; e++) { + c = (c * d ^ a.charCodeAt(e)) & b; } - return 32 === this.A ? b + 2 ** 31 : b; + return 32 === this.A ? c + 2 ** 31 : c; } function Na(a) { - let c = BigInt(2) ** this.A - BigInt(1); - var b = typeof a; - if ("bigint" === b) { - return a & c; + let b = BigInt(2) ** this.A - BigInt(1); + var c = typeof a; + if ("bigint" === c) { + return a & b; } - if ("number" === b) { - return BigInt(a) & c; + if ("number" === c) { + return BigInt(a) & b; } - b = BigInt(0); - let e = this.A + BigInt(1); - for (let d = 0; d < a.length; d++) { - b = (b * e ^ BigInt(a.charCodeAt(d))) & c; + c = BigInt(0); + let d = this.A + BigInt(1); + for (let e = 0; e < a.length; e++) { + c = (c * d ^ BigInt(a.charCodeAt(e))) & b; } - return b; + return c; } -;Pa.prototype.add = function(a, c, b) { - aa(a) && (c = a, a = ea(c, this.key)); - if (c && (a || 0 === a)) { - if (!b && this.reg.has(a)) { - return this.update(a, c); +;Pa.prototype.add = function(a, b, c) { + aa(a) && (b = a, a = ea(b, this.key)); + if (b && (a || 0 === a)) { + if (!c && this.reg.has(a)) { + return this.update(a, b); } - for (let k = 0, h; k < this.field.length; k++) { - h = this.F[k]; - var e = this.index.get(this.field[k]); - if ("function" === typeof h) { - var d = h(c); - d && e.add(a, d, !1, !0); + for (let h = 0, k; h < this.field.length; h++) { + k = this.F[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 (d = h.I, !d || d(c)) { - h.constructor === String ? h = ["" + h] : L(h) && (h = [h]), Qa(c, h, this.J, 0, e, a, h[0], b); + if (e = k.I, !e || e(b)) { + k.constructor === String ? k = ["" + k] : M(k) && (k = [k]), Qa(b, k, this.J, 0, d, a, k[0], c); } } } if (this.tag) { - for (e = 0; e < this.D.length; e++) { - var f = this.D[e], g = this.R[e]; - d = this.tag.get(g); - let k = G(); + for (d = 0; d < this.D.length; d++) { + var f = this.D[d], g = this.R[d]; + e = this.tag.get(g); + let h = H(); if ("function" === typeof f) { - if (f = f(c), !f) { + if (f = f(b), !f) { continue; } } else { - const h = f.I; - if (h && !h(c)) { + const k = f.I; + if (k && !k(b)) { continue; } f.constructor === String && (f = "" + f); - f = ea(c, f); + f = ea(b, f); } - if (d && f) { - L(f) && (f = [f]); - for (let h = 0, l, m; h < f.length; h++) { - if (l = f[h], !k[l] && (k[l] = 1, (g = d.get(l)) ? m = g : d.set(l, m = []), !b || !m.includes(a))) { + if (e && f) { + M(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 T(m); + g = new U(m); if (this.fastupdate) { - for (let t of this.reg.values()) { - t.includes(m) && (t[t.indexOf(m)] = g); + for (let p of this.reg.values()) { + p.includes(m) && (p[p.indexOf(m)] = g); } } - d.set(l, m = g); + e.set(l, m = g); } m.push(a); this.fastupdate && ((g = this.reg.get(a)) ? g.push(m) : this.reg.set(a, [m])); } } } else { - d || console.warn("Tag '" + g + "' was not found"); + e || console.warn("Tag '" + g + "' was not found"); } } } - if (this.store && (!b || !this.store.has(a))) { - let k; + if (this.store && (!c || !this.store.has(a))) { + let h; if (this.C) { - k = G(); - for (let h = 0, l; h < this.C.length; h++) { - l = this.C[h]; - if ((b = l.I) && !b(c)) { + h = H(); + for (let k = 0, l; k < this.C.length; k++) { + l = this.C[k]; + if ((c = l.I) && !c(b)) { continue; } let m; if ("function" === typeof l) { - m = l(c); + m = l(b); if (!m) { continue; } l = [l.V]; - } else if (L(l) || l.constructor === String) { - k[l] = c[l]; + } else if (M(l) || l.constructor === String) { + h[l] = b[l]; continue; } - Ra(c, k, l, 0, l[0], m); + Ra(b, h, l, 0, l[0], m); } } - this.store.set(a, k || c); + this.store.set(a, h || b); } this.worker && (this.fastupdate || this.reg.add(a)); } return this; }; -function Ra(a, c, b, e, d, f) { - a = a[d]; - if (e === b.length - 1) { - c[d] = f || a; +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 (c = c[d] = Array(a.length), d = 0; d < a.length; d++) { - Ra(a, c, b, e, d); + for (b = b[e] = Array(a.length), e = 0; e < a.length; e++) { + Ra(a, b, c, d, e); } } else { - c = c[d] || (c[d] = G()), d = b[++e], Ra(a, c, b, e, d); + b = b[e] || (b[e] = H()), e = c[++d], Ra(a, b, c, d, e); } } } -function Qa(a, c, b, e, d, f, g, k) { +function Qa(a, b, c, d, e, f, g, h) { if (a = a[g]) { - if (e === c.length - 1) { + if (d === b.length - 1) { if (a.constructor === Array) { - if (b[e]) { - for (c = 0; c < a.length; c++) { - d.add(f, a[c], !0, !0); + if (c[d]) { + for (b = 0; b < a.length; b++) { + e.add(f, a[b], !0, !0); } return; } a = a.join(" "); } - d.add(f, a, k, !0); + e.add(f, a, h, !0); } else { if (a.constructor === Array) { for (g = 0; g < a.length; g++) { - Qa(a, c, b, e, d, f, g, k); + Qa(a, b, c, d, e, f, g, h); } } else { - g = c[++e], Qa(a, c, b, e, d, f, g, k); + g = b[++d], Qa(a, b, c, d, e, f, g, h); } } } else { - d.db && d.remove(f); + e.db && e.remove(f); } } -;function Sa(a, c, b, e, d, f, g) { - const k = a.length; - let h = [], l, m; - l = G(); - for (let t = 0, q, n, r, u; t < c; t++) { - for (let p = 0; p < k; p++) { - if (r = a[p], t < r.length && (q = r[t])) { - for (let z = 0; z < q.length; z++) { - n = q[z]; - (m = l[n]) ? l[n]++ : (m = 0, l[n] = 1); - u = h[m] || (h[m] = []); - if (!g) { - let x = t + (p || !d ? 0 : f || 0); - u = u[x] || (u[x] = []); - } - u.push(n); - if (g && b && m === k - 1 && u.length - e === b) { - return e ? u.slice(e) : u; - } - } - } - } - } - if (a = h.length) { - if (d) { - h = 1 < h.length ? Ta(h, b, e, g, f) : (h = h[0]).length > b || e ? h.slice(e, b + e) : h; - } else { - if (a < k) { - return []; - } - h = h[a - 1]; - if (b || e) { - if (g) { - if (h.length > b || e) { - h = h.slice(e, b + e); - } - } else { - d = []; - for (let t = 0, q; t < h.length; t++) { - if (q = h[t]) { - if (e && q.length > e) { - e -= q.length; - } else { - if (b && q.length > b || e) { - q = q.slice(e, b + e), b -= q.length, e && (e -= q.length); - } - d.push(q); - if (!b) { - break; - } - } - } - } - h = d; - } - } - } - } - return h; -} -function Ta(a, c, b, e, d) { - const f = [], g = G(); - let k; - var h = a.length; - let l; - if (e) { - for (d = h - 1; 0 <= d; d--) { - if (l = (e = a[d]) && e.length) { - for (h = 0; h < l; h++) { - if (k = e[h], !g[k]) { - if (g[k] = 1, b) { - b--; - } else { - if (f.push(k), f.length === c) { - return f; - } - } - } - } - } - } - } else { - for (let m = h - 1, t, q = 0; 0 <= m; m--) { - t = a[m]; - for (let n = 0; n < t.length; n++) { - if (l = (e = t[n]) && e.length) { - for (let r = 0; r < l; r++) { - if (k = e[r], !g[k]) { - if (g[k] = 1, b) { - b--; - } else { - let u = (n + (m < h - 1 ? d || 0 : 0)) / (m + 1) | 0; - (f[u] || (f[u] = [])).push(k); - if (++q === c) { - return f; - } - } - } - } - } - } - } - } - return f; -} -function Ua(a, c, b) { - const e = G(), d = []; - for (let f = 0, g; f < c.length; f++) { - g = c[f]; - for (let k = 0; k < g.length; k++) { - e[g[k]] = 1; - } - } - if (b) { - for (let f = 0, g; f < a.length; f++) { - g = a[f], e[g] && (d.push(g), e[g] = 0); - } - } else { - for (let f = 0, g, k; f < a.result.length; f++) { - for (g = a.result[f], c = 0; c < g.length; c++) { - k = g[c], e[k] && ((d[f] || (d[f] = [])).push(k), e[k] = 0); - } - } - } - return d; -} -;function Va(a, c, b, e) { +;function Sa(a, b, c, d) { if (!a.length) { return a; } if (1 === a.length) { - return a = a[0], a = b || a.length > c ? c ? a.slice(b, b + c) : a.slice(b) : a, e ? X.call(this, a) : a; + return a = a[0], a = c || a.length > b ? b ? a.slice(c, c + b) : a.slice(c) : a, d ? X.call(this, a) : a; } - let d = []; - for (let f = 0, g, k; f < a.length; f++) { - if ((g = a[f]) && (k = g.length)) { - if (b) { - if (b >= k) { - b -= k; + 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; } - b < k && (g = c ? g.slice(b, b + c) : g.slice(b), k = g.length, b = 0); + c < h && (g = b ? g.slice(c, c + b) : g.slice(c), h = g.length, c = 0); } - k > c && (g = g.slice(0, c), k = c); - if (!d.length && k >= c) { - return e ? X.call(this, g) : g; + h > b && (g = g.slice(0, b), h = b); + if (!e.length && h >= b) { + return d ? X.call(this, g) : g; } - d.push(g); - c -= k; - if (!c) { + e.push(g); + b -= h; + if (!b) { break; } } } - d = 1 < d.length ? [].concat.apply([], d) : d[0]; - return e ? X.call(this, d) : d; + e = 1 < e.length ? [].concat.apply([], e) : e[0]; + return d ? X.call(this, e) : e; } -;function Wa(a, c, b) { - var e = b[0]; - if (e.then) { - return Promise.all(b).then(function(q) { - return a[c].apply(a, q); +;function Ta(a, b, c) { + var d = c[0]; + if (d.then) { + return Promise.all(c).then(function(q) { + return a[b].apply(a, q); }); } - if (e[0] && e[0].index) { - return a[c].apply(a, e); + if (d[0] && d[0].index) { + return a[b].apply(a, d); } - e = []; - let d = [], f = 0, g = 0, k, h, l, m, t; - for (let q = 0, n; q < b.length; q++) { - if (n = b[q]) { - let r; - if (n.constructor === Y) { - r = n.result; - } else if (n.constructor === Array) { - r = n; + d = []; + let e = [], f = 0, g = 0, h, k, l, m, p; + for (let q = 0, r; q < c.length; q++) { + if (r = c[q]) { + var u = void 0; + if (r.constructor === Y) { + u = r.result; + } else if (r.constructor === Array) { + u = r; } else { - f = n.limit || 0; - g = n.offset || 0; - l = n.suggest; - h = n.resolve; - k = (m = n.highlight && h) || n.enrich && h; - let u; - n.index && (a.index = u = n.index); - if (n.query || n.tag) { + f = r.limit || 0; + g = r.offset || 0; + l = r.suggest; + k = r.resolve; + h = (m = r.highlight && k) || r.enrich && k; + let n; + r.index ? a.index = n = r.index : n = a.index; + if (r.query || r.tag) { if (!a.index) { throw Error("Resolver can't apply because the corresponding Index was never specified"); } - if (n.field) { + if (u = r.field || r.pluck) { if (!a.index.index) { throw Error("Resolver can't apply because the corresponding Document Index was not specified"); } - u = a.index.index.get(n.field); - if (!u) { - throw Error("Resolver can't apply because the specified Document field '" + n.field + "' was not found"); + n = a.index.index.get(u); + if (!n) { + throw Error("Resolver can't apply because the specified Document Field '" + u + "' was not found"); } } - n.resolve = !1; - r = u.search(n).result; - n.resolve = h; - m && (t = n.query); - } else if (n.and) { - r = a.and(n.and); - } else if (n.or) { - r = a.or(n.or); - } else if (n.xor) { - r = a.xor(n.xor); - } else if (n.not) { - r = a.not(n.not); + r.resolve = !1; + u = n.search(r).result; + r.resolve = k; + m && (p = r.query); + } else if (r.and) { + u = a.and(r.and); + } else if (r.or) { + u = a.or(r.or); + } else if (r.xor) { + u = a.xor(r.xor); + } else if (r.not) { + u = a.not(r.not); } else { continue; } } - if (r.then) { - d.push(r); - } else if (r.length) { - e[q] = r; - } else if (!l && ("and" === c || "xor" === c)) { - e = []; + if (u.then) { + e.push(u); + } else if (u.length) { + d[q] = u; + } else if (!l && ("and" === b || "xor" === b)) { + d = []; break; } } } - return {O:e, P:d, limit:f, offset:g, enrich:k, resolve:h, suggest:l, highlight:m, W:t}; + return {O:d, P:e, limit:f, offset:g, enrich:h, resolve:k, suggest:l, highlight:m, W:p}; } ;Y.prototype.or = function() { - const {O:a, P:c, limit:b, offset:e, enrich:d, resolve:f} = Wa(this, "or", arguments); - return Xa.call(this, a, c, b, e, d, f); + const {O:a, P:b, limit:c, offset:d, enrich:e, resolve:f} = Ta(this, "or", arguments); + return Ua.call(this, a, b, c, d, e, f); }; -function Xa(a, c, b, e, d, f) { - if (c.length) { +function Ua(a, b, c, d, e, f) { + if (b.length) { const g = this; - return Promise.all(c).then(function(k) { + return Promise.all(b).then(function(h) { a = []; - for (let h = 0, l; h < k.length; h++) { - (l = k[h]).length && (a[h] = l); + for (let k = 0, l; k < h.length; k++) { + (l = h[k]).length && (a[k] = l); } - return Xa.call(g, a, [], b, e, d, f); + return Ua.call(g, a, [], c, d, e, f); }); } - a.length && (this.result.length && a.push(this.result), 2 > a.length ? this.result = a[0] : (this.result = Ta(a, b, e, !1, this.h), e = 0)); - return f ? this.resolve(b, e, d) : this; + a.length && (this.result.length && a.push(this.result), 2 > a.length ? this.result = a[0] : (this.result = Va(a, c, d, !1, this.h), d = 0)); + return f ? this.resolve(c, d, e) : this; } ;Y.prototype.and = function() { - let a = this.result.length, c, b, e, d; + let a = this.result.length, b, c, d, e; if (!a) { const f = arguments[0]; - f && (a = !!f.suggest, d = f.resolve, c = f.limit, b = f.offset, e = f.enrich && d); + f && (a = !!f.suggest, e = f.resolve, b = f.limit, c = f.offset, d = f.enrich && e); } if (a) { - const {O:f, P:g, limit:k, offset:h, enrich:l, resolve:m, suggest:t} = Wa(this, "and", arguments); - return Ya.call(this, f, g, k, h, l, m, t); + const {O:f, P:g, limit:h, offset:k, enrich:l, resolve:m, suggest:p} = Ta(this, "and", arguments); + return Wa.call(this, f, g, h, k, l, m, p); } - return d ? this.resolve(c, b, e) : this; + return e ? this.resolve(b, c, d) : this; }; -function Ya(a, c, b, e, d, f, g) { - if (c.length) { - const k = this; - return Promise.all(c).then(function(h) { +function Wa(a, b, c, d, e, f, g) { + if (b.length) { + const h = this; + return Promise.all(b).then(function(k) { a = []; - for (let l = 0, m; l < h.length; l++) { - (m = h[l]).length && (a[l] = m); + for (let l = 0, m; l < k.length; l++) { + (m = k[l]).length && (a[l] = m); } - return Ya.call(k, a, [], b, e, d, f, g); + return Wa.call(h, a, [], c, d, e, f, g); }); } if (a.length) { if (this.result.length && a.unshift(this.result), 2 > a.length) { this.result = a[0]; } else { - if (c = fa(a)) { - return this.result = Sa(a, c, b, e, g, this.h, f), f ? d ? X.call(this.index, this.result) : this.result : this; + if (b = fa(a)) { + return this.result = Xa(a, b, c, d, g, this.h, f), f ? e ? X.call(this.index, this.result) : this.result : this; } this.result = []; } } else { g || (this.result = a); } - return f ? this.resolve(b, e, d) : this; + return f ? this.resolve(c, d, e) : this; } ;Y.prototype.xor = function() { - const {O:a, P:c, limit:b, offset:e, enrich:d, resolve:f, suggest:g} = Wa(this, "xor", arguments); - return Za.call(this, a, c, b, e, d, f, g); + const {O:a, P:b, limit:c, offset:d, enrich:e, resolve:f, suggest:g} = Ta(this, "xor", arguments); + return Ya.call(this, a, b, c, d, e, f, g); }; -function Za(a, c, b, e, d, f, g) { - if (c.length) { - const k = this; - return Promise.all(c).then(function(h) { +function Ya(a, b, c, d, e, f, g) { + if (b.length) { + const h = this; + return Promise.all(b).then(function(k) { a = []; - for (let l = 0, m; l < h.length; l++) { - (m = h[l]).length && (a[l] = m); + for (let l = 0, m; l < k.length; l++) { + (m = k[l]).length && (a[l] = m); } - return Za.call(k, a, [], b, e, d, f, g); + return Ya.call(h, a, [], c, d, e, f, g); }); } if (a.length) { if (this.result.length && a.unshift(this.result), 2 > a.length) { this.result = a[0]; } else { - return this.result = $a.call(this, a, b, e, f, this.h), f ? d ? X.call(this.index, this.result) : this.result : this; + return this.result = Za.call(this, a, c, d, f, this.h), f ? e ? X.call(this.index, this.result) : this.result : this; } } else { g || (this.result = a); } - return f ? this.resolve(b, e, d) : this; + return f ? this.resolve(c, d, e) : this; } -function $a(a, c, b, e, d) { - const f = [], g = G(); - let k = 0; - for (let h = 0, l; h < a.length; h++) { - if (l = a[h]) { - k < l.length && (k = l.length); - for (let m = 0, t; m < l.length; m++) { - if (t = l[m]) { - for (let q = 0, n; q < t.length; q++) { - n = t[q], g[n] = g[n] ? 2 : 1; +function Za(a, b, c, d, e) { + const f = [], g = H(); + let h = 0; + for (let k = 0, l; k < a.length; k++) { + if (l = a[k]) { + h < l.length && (h = l.length); + for (let m = 0, p; m < l.length; m++) { + if (p = l[m]) { + for (let u = 0, q; u < p.length; u++) { + q = p[u], g[q] = g[q] ? 2 : 1; } } } } } - for (let h = 0, l, m = 0; h < k; h++) { - for (let t = 0, q; t < a.length; t++) { - if (q = a[t]) { - if (l = q[h]) { - for (let n = 0, r; n < l.length; n++) { - if (r = l[n], 1 === g[r]) { - if (b) { - b--; + for (let k = 0, l, m = 0; k < h; k++) { + for (let p = 0, u; p < a.length; p++) { + if (u = a[p]) { + if (l = u[k]) { + for (let q = 0, r; q < l.length; q++) { + if (r = l[q], 1 === g[r]) { + if (c) { + c--; } else { - if (e) { - if (f.push(r), f.length === c) { + if (d) { + if (f.push(r), f.length === b) { return f; } } else { - const u = h + (t ? d : 0); - f[u] || (f[u] = []); - f[u].push(r); - if (++m === c) { + const n = k + (p ? e : 0); + f[n] || (f[n] = []); + f[n].push(r); + if (++m === b) { return f; } } @@ -1170,44 +1045,44 @@ function $a(a, c, b, e, d) { return f; } ;Y.prototype.not = function() { - const {O:a, P:c, limit:b, offset:e, enrich:d, resolve:f, suggest:g} = Wa(this, "not", arguments); - return ab.call(this, a, c, b, e, d, f, g); + const {O:a, P:b, limit:c, offset:d, enrich:e, resolve:f, suggest:g} = Ta(this, "not", arguments); + return $a.call(this, a, b, c, d, e, f, g); }; -function ab(a, c, b, e, d, f, g) { - if (c.length) { - const k = this; - return Promise.all(c).then(function(h) { +function $a(a, b, c, d, e, f, g) { + if (b.length) { + const h = this; + return Promise.all(b).then(function(k) { a = []; - for (let l = 0, m; l < h.length; l++) { - (m = h[l]).length && (a[l] = m); + for (let l = 0, m; l < k.length; l++) { + (m = k[l]).length && (a[l] = m); } - return ab.call(k, a, [], b, e, d, f, g); + return $a.call(h, a, [], c, d, e, f, g); }); } if (a.length && this.result.length) { - this.result = bb.call(this, a, b, e, f); + this.result = ab.call(this, a, c, d, f); } else if (f) { - return this.resolve(b, e, d); + return this.resolve(c, d, e); } - return f ? d ? X.call(this.index, this.result) : this.result : this; + return f ? e ? X.call(this.index, this.result) : this.result : this; } -function bb(a, c, b, e) { - const d = []; +function ab(a, b, c, d) { + const e = []; a = new Set(a.flat().flat()); - for (let f = 0, g, k = 0; f < this.result.length; f++) { + for (let f = 0, g, h = 0; f < this.result.length; f++) { if (g = this.result[f]) { - for (let h = 0, l; h < g.length; h++) { - if (l = g[h], !a.has(l)) { - if (b) { - b--; + for (let k = 0, l; k < g.length; k++) { + if (l = g[k], !a.has(l)) { + if (c) { + c--; } else { - if (e) { - if (d.push(l), d.length === c) { - return d; + if (d) { + if (e.push(l), e.length === b) { + return e; } } else { - if (d[f] || (d[f] = []), d[f].push(l), ++k === c) { - return d; + if (e[f] || (e[f] = []), e[f].push(l), ++h === b) { + return e; } } } @@ -1215,11 +1090,11 @@ function bb(a, c, b, e) { } } } - return d; + return e; } -;function cb(a, c, b, e, d) { - let f, g, k; - "string" === typeof d ? (f = d, d = "") : f = d.template; +;function bb(a, b, c, d, e) { + let f, g, h; + "string" === typeof e ? (f = e, e = "") : f = e.template; if (!f) { throw Error('No template pattern was specified by the search option "highlight"'); } @@ -1227,268 +1102,268 @@ function bb(a, c, b, e) { if (-1 === g) { throw Error('Invalid highlight template. The replacement pattern "$1" was not found in template: ' + f); } - k = f.substring(g + 2); + h = f.substring(g + 2); g = f.substring(0, g); - let h = d && d.boundary, l = !d || !1 !== d.clip, m = d && d.merge && k && g && new RegExp(k + " " + g, "g"); - d = d && d.ellipsis; - var t = 0; - if ("object" === typeof d) { - var q = d.template; - t = q.length - 2; - d = d.pattern; + let k = e && e.boundary, l = !e || !1 !== e.clip, m = e && e.merge && h && g && new RegExp(h + " " + g, "g"); + e = e && e.ellipsis; + var p = 0; + if ("object" === typeof e) { + var u = e.template; + p = u.length - 2; + e = e.pattern; } - "string" !== typeof d && (d = !1 === d ? "" : "..."); - t && (d = q.replace("$1", d)); - q = d.length - t; - let n, r; - "object" === typeof h && (n = h.before, 0 === n && (n = -1), r = h.after, 0 === r && (r = -1), h = h.total || 9e5); - t = new Map(); - for (let Ka = 0, ba, eb, na; Ka < c.length; Ka++) { + "string" !== typeof e && (e = !1 === e ? "" : "..."); + p && (e = u.replace("$1", e)); + u = e.length - p; + let q, r; + "object" === typeof k && (q = k.before, 0 === q && (q = -1), r = k.after, 0 === r && (r = -1), k = k.total || 9e5); + p = new Map(); + for (let La = 0, ba, fb, na; La < b.length; La++) { let oa; - if (e) { - oa = c, na = e; + if (d) { + oa = b, na = d; } else { - var u = c[Ka]; - na = u.field; + var n = b[La]; + na = n.field; if (!na) { continue; } - oa = u.result; + oa = n.result; } - eb = b.get(na); - ba = eb.encoder; - u = t.get(ba); - "string" !== typeof u && (u = ba.encode(a), t.set(ba, u)); - for (let va = 0; va < oa.length; va++) { - var p = oa[va].doc; - if (!p) { + fb = c.get(na); + ba = fb.encoder; + n = p.get(ba); + "string" !== typeof n && (n = ba.encode(a), p.set(ba, n)); + for (let wa = 0; wa < oa.length; wa++) { + var t = oa[wa].doc; + if (!t) { continue; } - p = ea(p, na); - if (!p) { + t = ea(t, na); + if (!t) { continue; } - var z = p.trim().split(/\s+/); - if (!z.length) { + var x = t.trim().split(/\s+/); + if (!x.length) { continue; } - p = ""; - var x = []; - let wa = []; - var J = -1, B = -1, y = 0; - for (var A = 0; A < z.length; A++) { - var E = z[A], D = ba.encode(E); - D = 1 < D.length ? D.join(" ") : D[0]; - let w; - if (D && E) { - var C = E.length, H = (ba.split ? E.replace(ba.split, "") : E).length - D.length, M = "", W = 0; - for (var ca = 0; ca < u.length; ca++) { - var Q = u[ca]; + t = ""; + var y = []; + let xa = []; + var D = -1, G = -1, B = 0; + for (var v = 0; v < x.length; v++) { + var A = x[v], I = ba.encode(A); + I = 1 < I.length ? I.join(" ") : I[0]; + let z; + if (I && A) { + var C = A.length, J = (ba.split ? A.replace(ba.split, "") : A).length - I.length, F = "", S = 0; + for (var ca = 0; ca < n.length; ca++) { + var Q = n[ca]; if (Q) { - var K = Q.length; - K += H; - W && K <= W || (Q = D.indexOf(Q), -1 < Q && (M = (Q ? E.substring(0, Q) : "") + g + E.substring(Q, Q + K) + k + (Q + K < C ? E.substring(Q + K) : ""), W = K, w = !0)); + var L = Q.length; + L += J; + S && L <= S || (Q = I.indexOf(Q), -1 < Q && (F = (Q ? A.substring(0, Q) : "") + g + A.substring(Q, Q + L) + h + (Q + L < C ? A.substring(Q + L) : ""), S = L, z = !0)); } } - M && (h && (0 > J && (J = p.length + (p ? 1 : 0)), B = p.length + (p ? 1 : 0) + M.length, y += C, wa.push(x.length), x.push({match:M})), p += (p ? " " : "") + M); + F && (k && (0 > D && (D = t.length + (t ? 1 : 0)), G = t.length + (t ? 1 : 0) + F.length, B += C, xa.push(y.length), y.push({match:F})), t += (t ? " " : "") + F); } - if (!w) { - E = z[A], p += (p ? " " : "") + E, h && x.push({text:E}); - } else if (h && y >= h) { + if (!z) { + A = x[v], t += (t ? " " : "") + A, k && y.push({text:A}); + } else if (k && B >= k) { break; } } - y = wa.length * (f.length - 2); - if (n || r || h && p.length - y > h) { - if (y = h + y - 2 * q, A = B - J, 0 < n && (A += n), 0 < r && (A += r), A <= y) { - z = n ? J - (0 < n ? n : 0) : J - ((y - A) / 2 | 0), x = r ? B + (0 < r ? r : 0) : z + y, l || (0 < z && " " !== p.charAt(z) && " " !== p.charAt(z - 1) && (z = p.indexOf(" ", z), 0 > z && (z = 0)), x < p.length && " " !== p.charAt(x - 1) && " " !== p.charAt(x) && (x = p.lastIndexOf(" ", x), x < B ? x = B : ++x)), p = (z ? d : "") + p.substring(z, x) + (x < p.length ? d : ""); + B = xa.length * (f.length - 2); + if (q || r || k && t.length - B > k) { + if (B = k + B - 2 * u, v = G - D, 0 < q && (v += q), 0 < r && (v += r), v <= B) { + x = q ? D - (0 < q ? q : 0) : D - ((B - v) / 2 | 0), y = r ? G + (0 < r ? r : 0) : x + B, l || (0 < x && " " !== t.charAt(x) && " " !== t.charAt(x - 1) && (x = t.indexOf(" ", x), 0 > x && (x = 0)), y < t.length && " " !== t.charAt(y - 1) && " " !== t.charAt(y) && (y = t.lastIndexOf(" ", y), y < G ? y = G : ++y)), t = (x ? e : "") + t.substring(x, y) + (y < t.length ? e : ""); } else { - B = []; - J = {}; - y = {}; - A = {}; - E = {}; + G = []; D = {}; - M = H = C = 0; - for (ca = W = 1;;) { - var S = void 0; - for (let w = 0, I; w < wa.length; w++) { - I = wa[w]; - if (M) { - if (H !== M) { - if (A[w + 1]) { + B = {}; + v = {}; + A = {}; + I = {}; + F = J = C = 0; + for (ca = S = 1;;) { + var T = void 0; + for (let z = 0, K; z < xa.length; z++) { + K = xa[z]; + if (F) { + if (J !== F) { + if (v[z + 1]) { continue; } - I += M; - if (J[I]) { - C -= q; - y[w + 1] = 1; - A[w + 1] = 1; + K += F; + if (D[K]) { + C -= u; + B[z + 1] = 1; + v[z + 1] = 1; continue; } - if (I >= x.length - 1) { - if (I >= x.length) { - A[w + 1] = 1; - I >= z.length && (y[w + 1] = 1); + if (K >= y.length - 1) { + if (K >= y.length) { + v[z + 1] = 1; + K >= x.length && (B[z + 1] = 1); continue; } - C -= q; + C -= u; } - p = x[I].text; - if (K = r && D[w]) { - if (0 < K) { - if (p.length > K) { - if (A[w + 1] = 1, l) { - p = p.substring(0, K); + t = y[K].text; + if (L = r && I[z]) { + if (0 < L) { + if (t.length > L) { + if (v[z + 1] = 1, l) { + t = t.substring(0, L); } else { continue; } } - (K -= p.length) || (K = -1); - D[w] = K; + (L -= t.length) || (L = -1); + I[z] = L; } else { - A[w + 1] = 1; + v[z + 1] = 1; continue; } } - if (C + p.length + 1 <= h) { - p = " " + p, B[w] += p; + if (C + t.length + 1 <= k) { + t = " " + t, G[z] += t; } else if (l) { - S = h - C - 1, 0 < S && (p = " " + p.substring(0, S), B[w] += p), A[w + 1] = 1; + T = k - C - 1, 0 < T && (t = " " + t.substring(0, T), G[z] += t), v[z + 1] = 1; } else { - A[w + 1] = 1; + v[z + 1] = 1; continue; } } else { - if (A[w]) { + if (v[z]) { continue; } - I -= H; - if (J[I]) { - C -= q; - A[w] = 1; - y[w] = 1; + K -= J; + if (D[K]) { + C -= u; + v[z] = 1; + B[z] = 1; continue; } - if (0 >= I) { - if (0 > I) { - A[w] = 1; - y[w] = 1; + if (0 >= K) { + if (0 > K) { + v[z] = 1; + B[z] = 1; continue; } - C -= q; + C -= u; } - p = x[I].text; - if (K = n && E[w]) { - if (0 < K) { - if (p.length > K) { - if (A[w] = 1, l) { - p = p.substring(p.length - K); + t = y[K].text; + if (L = q && A[z]) { + if (0 < L) { + if (t.length > L) { + if (v[z] = 1, l) { + t = t.substring(t.length - L); } else { continue; } } - (K -= p.length) || (K = -1); - E[w] = K; + (L -= t.length) || (L = -1); + A[z] = L; } else { - A[w] = 1; + v[z] = 1; continue; } } - if (C + p.length + 1 <= h) { - p += " ", B[w] = p + B[w]; + if (C + t.length + 1 <= k) { + t += " ", G[z] = t + G[z]; } else if (l) { - S = p.length + 1 - (h - C), 0 <= S && S < p.length && (p = p.substring(S) + " ", B[w] = p + B[w]), A[w] = 1; + T = t.length + 1 - (k - C), 0 <= T && T < t.length && (t = t.substring(T) + " ", G[z] = t + G[z]), v[z] = 1; } else { - A[w] = 1; + v[z] = 1; continue; } } } else { - p = x[I].match; - n && (E[w] = n); - r && (D[w] = r); - w && C++; - let La; - I ? !w && q && (C += q) : (y[w] = 1, A[w] = 1); - I >= z.length - 1 ? La = 1 : I < x.length - 1 && x[I + 1].match ? La = 1 : q && (C += q); + t = y[K].match; + q && (A[z] = q); + r && (I[z] = r); + z && C++; + let Ma; + K ? !z && u && (C += u) : (B[z] = 1, v[z] = 1); + K >= x.length - 1 ? Ma = 1 : K < y.length - 1 && y[K + 1].match ? Ma = 1 : u && (C += u); C -= f.length - 2; - if (!w || C + p.length <= h) { - B[w] = p; + if (!z || C + t.length <= k) { + G[z] = t; } else { - S = W = ca = y[w] = 0; + T = S = ca = B[z] = 0; break; } - La && (y[w + 1] = 1, A[w + 1] = 1); + Ma && (B[z + 1] = 1, v[z + 1] = 1); } - C += p.length; - S = J[I] = 1; + C += t.length; + T = D[K] = 1; } - if (S) { - H === M ? M++ : H++; + if (T) { + J === F ? F++ : J++; } else { - H === M ? W = 0 : ca = 0; - if (!W && !ca) { + J === F ? S = 0 : ca = 0; + if (!S && !ca) { break; } - W ? (H++, M = H) : M++; + S ? (J++, F = J) : F++; } } - p = ""; - for (let w = 0, I; w < B.length; w++) { - I = (w && y[w] ? " " : (w && !d ? " " : "") + d) + B[w], p += I; + t = ""; + for (let z = 0, K; z < G.length; z++) { + K = (z && B[z] ? " " : (z && !e ? " " : "") + e) + G[z], t += K; } - d && !y[B.length] && (p += d); + e && !B[G.length] && (t += e); } } - m && (p = p.replace(m, " ")); - oa[va].highlight = p; + m && (t = t.replace(m, " ")); + oa[wa].highlight = t; } - if (e) { + if (d) { break; } } - return c; + return b; } -;function Y(a, c) { +;function Y(a, b) { if (!this || this.constructor !== Y) { - return new Y(a, c); + return new Y(a, b); } if (a && a.index) { return a.resolve = !1, this.index = a.index, this.h = a.boost || 0, this.result = this.index.search(a).result, this; } - this.index = c || null; + this.index = b || null; this.result = a || []; this.h = 0; } Y.prototype.limit = function(a) { if (this.result.length) { - const c = []; - for (let b = 0, e; b < this.result.length; b++) { - if (e = this.result[b]) { - if (e.length <= a) { - if (c[b] = e, a -= e.length, !a) { + const b = []; + for (let c = 0, d; c < this.result.length; c++) { + if (d = this.result[c]) { + if (d.length <= a) { + if (b[c] = d, a -= d.length, !a) { break; } } else { - c[b] = e.slice(0, a); + b[c] = d.slice(0, a); break; } } } - this.result = c; + this.result = b; } return this; }; Y.prototype.offset = function(a) { if (this.result.length) { - const c = []; - for (let b = 0, e; b < this.result.length; b++) { - if (e = this.result[b]) { - e.length <= a ? a -= e.length : (c[b] = e.slice(a), a = 0); + const b = []; + for (let c = 0, d; c < this.result.length; c++) { + if (d = this.result[c]) { + d.length <= a ? a -= d.length : (b[c] = d.slice(a), a = 0); } } - this.result = c; + this.result = b; } return this; }; @@ -1496,250 +1371,378 @@ Y.prototype.boost = function(a) { this.h += a; return this; }; -Y.prototype.resolve = function(a, c, b) { - const e = this.index; - let d = this.result; +Y.prototype.resolve = function(a, b, c) { + const d = this.index; + let e = this.result; this.result = this.index = null; - d.length && ("object" === typeof a && (b = a.enrich, c = a.offset, a = a.limit), d = Va.call(e, d, a || 100, c, b)); - return d; + e.length && ("object" === typeof a && (c = a.enrich, b = a.offset, a = a.limit), e = Sa.call(d, e, a || 100, b, c)); + return e; }; -G(); -Pa.prototype.search = function(a, c, b, e) { - b || (!c && aa(a) ? (b = a, a = "") : aa(c) && (b = c, c = 0)); - if (b && b.cache) { - b.cache = !1; - var d = this.searchCache(a, c, b); - b.cache = !0; - return d; +function Xa(a, b, c, d, e, f, g) { + const h = a.length; + let k = [], l, m; + l = H(); + for (let p = 0, u, q, r, n; p < b; p++) { + for (let t = 0; t < h; t++) { + if (r = a[t], p < r.length && (u = r[p])) { + for (let x = 0; x < u.length; x++) { + q = u[x]; + (m = l[q]) ? l[q]++ : (m = 0, l[q] = 1); + n = k[m] || (k[m] = []); + if (!g) { + let y = p + (t || !e ? 0 : f || 0); + n = n[y] || (n[y] = []); + } + n.push(q); + if (g && c && m === h - 1 && n.length - d === c) { + return d ? n.slice(d) : n; + } + } + } + } + } + if (a = k.length) { + if (e) { + k = 1 < k.length ? Va(k, c, d, g, f) : (k = k[0]).length > c || d ? k.slice(d, c + d) : k; + } else { + if (a < h) { + return []; + } + k = k[a - 1]; + if (c || d) { + if (g) { + if (k.length > c || d) { + k = k.slice(d, c + d); + } + } else { + e = []; + for (let p = 0, u; p < k.length; p++) { + if (u = k[p]) { + if (d && u.length > d) { + d -= u.length; + } else { + if (c && u.length > c || d) { + u = u.slice(d, c + d), c -= u.length, d && (d -= u.length); + } + e.push(u); + if (!c) { + break; + } + } + } + } + k = e; + } + } + } + } + return k; +} +function Va(a, b, c, d, e) { + const f = [], g = H(); + let h; + var k = a.length; + let l; + if (d) { + for (e = k - 1; 0 <= e; e--) { + if (l = (d = a[e]) && d.length) { + for (k = 0; k < l; k++) { + if (h = d[k], !g[h]) { + if (g[h] = 1, c) { + c--; + } else { + if (f.push(h), f.length === b) { + return f; + } + } + } + } + } + } + } else { + for (let m = k - 1, p, u = 0; 0 <= m; m--) { + p = a[m]; + for (let q = 0; q < p.length; q++) { + if (l = (d = p[q]) && d.length) { + for (let r = 0; r < l; r++) { + if (h = d[r], !g[h]) { + if (g[h] = 1, c) { + c--; + } else { + let n = (q + (m < k - 1 ? e || 0 : 0)) / (m + 1) | 0; + (f[n] || (f[n] = [])).push(h); + if (++u === b) { + return f; + } + } + } + } + } + } + } + } + return f; +} +function cb(a, b, c) { + const d = H(), e = []; + for (let f = 0, g; f < b.length; f++) { + g = b[f]; + for (let h = 0; h < g.length; h++) { + d[g[h]] = 1; + } + } + if (c) { + for (let f = 0, g; f < a.length; f++) { + g = a[f], d[g] && (e.push(g), d[g] = 0); + } + } else { + for (let f = 0, g, h; f < a.result.length; f++) { + for (g = a.result[f], b = 0; b < g.length; b++) { + h = g[b], d[h] && ((e[f] || (e[f] = [])).push(h), d[h] = 0); + } + } + } + return e; +} +;H(); +Pa.prototype.search = function(a, b, c, d) { + c || (!b && aa(a) ? (c = a, a = "") : aa(b) && (c = b, b = 0)); + if (c && c.cache) { + c.cache = !1; + var e = this.searchCache(a, b, c); + c.cache = !0; + return e; } let f = []; var g = []; - let k, h; - let l, m; - let t = 0; - var q = !0; - let n; - if (b) { - b.constructor === Array && (b = {index:b}); - a = b.query || a; - k = b.pluck; - h = b.merge; - l = k || b.field || (l = b.index) && (l.index ? null : l); - m = this.tag && b.tag; - var r = b.suggest; - q = !1 !== b.resolve; - if (!q && !k) { - if (l = l || this.field) { - L(l) ? k = l : (l.constructor === Array && 1 === l.length && (l = l[0]), k = l.field || l.index); + let h, k, l, m, p; + let u = 0, q = !0, r; + if (c) { + c.constructor === Array && (c = {index:c}); + a = c.query || a; + h = c.pluck; + k = c.merge; + m = c.boost; + p = h || c.field || (p = c.index) && (p.index ? null : p); + var n = this.tag && c.tag; + l = c.suggest; + q = !1 !== c.resolve; + this.store && c.highlight && !q ? console.warn("Highlighting results can only be done on a final resolver task or when calling .resolve({ highlight: ... })") : this.store && c.enrich && !q && console.warn("Enrich results can only be done on a final resolver task or when calling .resolve({ enrich: true })"); + r = q && this.store && c.highlight; + e = !!r || q && this.store && c.enrich; + b = c.limit || b; + var t = c.offset || 0; + b || (b = q ? 100 : 0); + if (n && (!this.db || !d)) { + n.constructor !== Array && (n = [n]); + var x = []; + for (let B = 0, v; B < n.length; B++) { + v = n[B]; + if (M(v)) { + throw Error("A tag option can't be a string, instead it needs a { field: tag } format."); + } + if (v.field && v.tag) { + var y = v.tag; + if (y.constructor === Array) { + for (var D = 0; D < y.length; D++) { + x.push(v.field, y[D]); + } + } else { + x.push(v.field, y); + } + } else { + y = Object.keys(v); + for (let A = 0, I, C; A < y.length; A++) { + if (I = y[A], C = v[I], C.constructor === Array) { + for (D = 0; D < C.length; D++) { + x.push(I, C[D]); + } + } else { + x.push(I, C); + } + } + } } - if (!k) { + if (!x.length) { + throw Error("Your tag definition within the search options is probably wrong. No valid tags found."); + } + n = x; + if (!a) { + g = []; + if (x.length) { + for (n = 0; n < x.length; n += 2) { + if (this.db) { + d = this.index.get(x[n]); + if (!d) { + console.warn("Tag '" + x[n] + ":" + x[n + 1] + "' will be skipped because there is no field '" + x[n] + "'."); + continue; + } + g.push(d = d.db.tag(x[n + 1], b, t, e)); + } else { + d = db.call(this, x[n], x[n + 1], b, t, e); + } + f.push(q ? {field:x[n], tag:x[n + 1], result:d} : [d]); + } + } + if (g.length) { + const B = this; + return Promise.all(g).then(function(v) { + for (let A = 0; A < v.length; A++) { + q ? f[A].result = v[A] : f[A] = v[A]; + } + return q ? f : new Y(1 < f.length ? Xa(f, 1, 0, 0, l, m) : f[0], B); + }); + } + return q ? f : new Y(1 < f.length ? Xa(f, 1, 0, 0, l, m) : f[0], this); + } + } + if (!q && !h) { + if (p = p || this.field) { + M(p) ? h = p : (p.constructor === Array && 1 === p.length && (p = p[0]), h = p.field || p.index); + } + if (!h) { throw Error("Apply resolver on document search requires either the option 'pluck' to be set or just select a single field name in your query."); } } - this.store && b.highlight && !q ? console.warn("Highlighting results can only be done on a final resolver task or when calling .resolve({ highlight: ... })") : this.store && b.enrich && !q && console.warn("Enrich results can only be done on a final resolver task or when calling .resolve({ enrich: true })"); - n = q && this.store && b.highlight; - d = !!n || q && this.store && b.enrich; - c = b.limit || c; - var u = b.offset || 0; - c || (c = 100); - if (m && (!this.db || !e)) { - m.constructor !== Array && (m = [m]); - var p = []; - for (let B = 0, y; B < m.length; B++) { - y = m[B]; - if (L(y)) { - throw Error("A tag option can't be a string, instead it needs a { field: tag } format."); - } - if (y.field && y.tag) { - var z = y.tag; - if (z.constructor === Array) { - for (var x = 0; x < z.length; x++) { - p.push(y.field, z[x]); - } - } else { - p.push(y.field, z); - } - } else { - z = Object.keys(y); - for (let A = 0, E, D; A < z.length; A++) { - if (E = z[A], D = y[E], D.constructor === Array) { - for (x = 0; x < D.length; x++) { - p.push(E, D[x]); - } - } else { - p.push(E, D); - } - } - } - } - if (!p.length) { - throw Error("Your tag definition within the search options is probably wrong. No valid tags found."); - } - m = p; - if (!a) { - q = []; - if (p.length) { - for (g = 0; g < p.length; g += 2) { - if (this.db) { - r = this.index.get(p[g]); - if (!r) { - console.warn("Tag '" + p[g] + ":" + p[g + 1] + "' will be skipped because there is no field '" + p[g] + "'."); - continue; - } - q.push(r = r.db.tag(p[g + 1], c, u, d)); - } else { - r = db.call(this, p[g], p[g + 1], c, u, d); - } - f.push({field:p[g], tag:p[g + 1], result:r}); - } - } - return q.length ? Promise.all(q).then(function(B) { - for (let y = 0; y < B.length; y++) { - f[y].result = B[y]; - } - return f; - }) : f; - } - } - l && l.constructor !== Array && (l = [l]); + p && p.constructor !== Array && (p = [p]); } - l || (l = this.field); - let J; - p = (this.worker || this.db) && !e && []; - for (let B = 0, y, A, E; B < l.length; B++) { - A = l[B]; + p || (p = this.field); + let G; + x = (this.worker || this.db) && !d && []; + for (let B = 0, v, A, I; B < p.length; B++) { + A = p[B]; if (this.db && this.tag && !this.F[B]) { continue; } - let D; - L(A) || (D = A, A = D.field, a = D.query || a, c = fb(D.limit, c), u = fb(D.offset, u), r = fb(D.suggest, r), n = q && this.store && fb(D.highlight, n), d = !!n || q && this.store && fb(D.enrich, d)); - if (e) { - y = e[B]; + let C; + M(A) || (C = A, A = C.field, a = C.query || a, b = eb(C.limit, b), t = eb(C.offset, t), l = eb(C.suggest, l), r = q && this.store && eb(C.highlight, r), e = !!r || q && this.store && eb(C.enrich, e)); + if (d) { + v = d[B]; } else { - if (z = D || b, x = this.index.get(A), m && (this.db && (z.tag = m, J = x.db.support_tag_search, z.field = l), J || (z.enrich = !1)), p) { - p[B] = x.search(a, c, z); - z && d && (z.enrich = d); + if (y = C || c, D = this.index.get(A), n && (this.db && (y.tag = n, G = D.db.support_tag_search, y.field = p), G || (y.enrich = !1)), x) { + x[B] = D.search(a, b, y); + y && e && (y.enrich = e); continue; } else { - y = x.search(a, c, z), z && d && (z.enrich = d); + v = D.search(a, b, y), y && e && (y.enrich = e); } } - E = y && (q ? y.length : y.result.length); - if (m && E) { - z = []; - x = 0; - if (this.db && e) { - if (!J) { - for (let C = l.length; C < e.length; C++) { - let H = e[C]; - if (H && H.length) { - x++, z.push(H); - } else if (!r) { + I = v && (q ? v.length : v.result.length); + if (n && I) { + y = []; + D = 0; + if (this.db && d) { + if (!G) { + for (let J = p.length; J < d.length; J++) { + let F = d[J]; + if (F && F.length) { + D++, y.push(F); + } else if (!l) { return q ? f : new Y(f, this); } } } } else { - for (let C = 0, H, M; C < m.length; C += 2) { - H = this.tag.get(m[C]); - if (!H) { - if (console.warn("Tag '" + m[C] + ":" + m[C + 1] + "' will be skipped because there is no field '" + m[C] + "'."), r) { + for (let J = 0, F, S; J < n.length; J += 2) { + F = this.tag.get(n[J]); + if (!F) { + if (console.warn("Tag '" + n[J] + ":" + n[J + 1] + "' will be skipped because there is no field '" + n[J] + "'."), l) { continue; } else { return q ? f : new Y(f, this); } } - if (M = (H = H && H.get(m[C + 1])) && H.length) { - x++, z.push(H); - } else if (!r) { + if (S = (F = F && F.get(n[J + 1])) && F.length) { + D++, y.push(F); + } else if (!l) { return q ? f : new Y(f, this); } } } - if (x) { - y = Ua(y, z, q); - E = y.length; - if (!E && !r) { - return q ? y : new Y(y, this); + if (D) { + v = cb(v, y, q); + I = v.length; + if (!I && !l) { + return q ? v : new Y(v, this); } - x--; + D--; } } - if (E) { - g[t] = A, f.push(y), t++; - } else if (1 === l.length) { + if (I) { + g[u] = A, f.push(v), u++; + } else if (1 === p.length) { return q ? f : new Y(f, this); } } - if (p) { - if (this.db && m && m.length && !J) { - for (d = 0; d < m.length; d += 2) { - g = this.index.get(m[d]); + if (x) { + if (this.db && n && n.length && !G) { + for (e = 0; e < n.length; e += 2) { + g = this.index.get(n[e]); if (!g) { - if (console.warn("Tag '" + m[d] + ":" + m[d + 1] + "' was not found because there is no field '" + m[d] + "'."), r) { + if (console.warn("Tag '" + n[e] + ":" + n[e + 1] + "' was not found because there is no field '" + n[e] + "'."), l) { continue; } else { return q ? f : new Y(f, this); } } - p.push(g.db.tag(m[d + 1], c, u, !1)); + x.push(g.db.tag(n[e + 1], b, t, !1)); } } const B = this; - return Promise.all(p).then(function(y) { - return y.length ? B.search(a, c, b, y) : y; + return Promise.all(x).then(function(v) { + return v.length ? B.search(a, b, c, v) : v; }); } - if (!t) { + if (!u) { return q ? f : new Y(f, this); } - if (k && (!d || !this.store)) { + if (h && (!e || !this.store)) { return f = f[0], q || (f.index = this), f; } - p = []; - for (u = 0; u < g.length; u++) { - r = f[u]; - d && r.length && "undefined" === typeof r[0].doc && (this.db ? p.push(r = this.index.get(this.field[0]).db.enrich(r)) : r = X.call(this, r)); - if (k) { - return q ? n ? cb(a, r, this.index, k, n) : r : new Y(r, this); + x = []; + for (t = 0; t < g.length; t++) { + n = f[t]; + e && n.length && "undefined" === typeof n[0].doc && (this.db ? x.push(n = this.index.get(this.field[0]).db.enrich(n)) : n = X.call(this, n)); + if (h) { + return q ? r ? bb(a, n, this.index, h, r) : n : new Y(n, this); } - f[u] = {field:g[u], result:r}; + f[t] = {field:g[t], result:n}; } - if (d && this.db && p.length) { + if (e && this.db && x.length) { const B = this; - return Promise.all(p).then(function(y) { - for (let A = 0; A < y.length; A++) { - f[A].result = y[A]; + return Promise.all(x).then(function(v) { + for (let A = 0; A < v.length; A++) { + f[A].result = v[A]; } - return h ? gb(f) : n ? cb(a, f, B.index, k, n) : f; + return k ? gb(f) : r ? bb(a, f, B.index, h, r) : f; }); } - return h ? gb(f) : n ? cb(a, f, this.index, k, n) : f; + return k ? gb(f) : r ? bb(a, f, this.index, h, r) : f; }; -function fb(a, c) { - return "undefined" === typeof a ? c : a; +function eb(a, b) { + return "undefined" === typeof a ? b : a; } function gb(a) { - const c = [], b = G(); - for (let e = 0, d, f; e < a.length; e++) { - d = a[e]; - f = d.result; - for (let g = 0, k, h, l; g < f.length; g++) { - h = f[g], "object" !== typeof h && (h = {id:h}), k = h.id, (l = b[k]) ? l.push(d.field) : (h.field = b[k] = [d.field], c.push(h)); + const b = [], c = H(); + for (let d = 0, e, f; d < a.length; d++) { + e = a[d]; + f = e.result; + for (let g = 0, h, k, l; g < f.length; g++) { + k = f[g], "object" !== typeof k && (k = {id:k}), h = k.id, (l = c[h]) ? l.push(e.field) : (k.field = c[h] = [e.field], b.push(k)); } } - return c; + return b; } -function db(a, c, b, e, d) { +function db(a, b, c, d, e) { let f = this.tag.get(a); if (!f) { - return console.warn("Tag '" + a + "' was not found"), []; + return console.warn("Tag-Field '" + a + "' was not found"), []; } - if ((a = (f = f && f.get(c)) && f.length - e) && 0 < a) { - if (a > b || e) { - f = f.slice(e, e + b); + if ((a = (f = f && f.get(b)) && f.length - d) && 0 < a) { + if (c && a > c || d) { + f = f.slice(d, d + c); } - d && (f = X.call(this, f)); + e && (f = X.call(this, f)); return f; } } @@ -1747,181 +1750,187 @@ function X(a) { if (!this || !this.store) { return a; } - const c = Array(a.length); - for (let b = 0, e; b < a.length; b++) { - e = a[b], c[b] = {id:e, doc:this.store.get(e)}; + 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 c; + return b; } -;function Pa(a) { +;const hb = {normalize:!1, numeric:!1, dedupe:!1}; +const ib = {}; +const jb = 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 kb = new Map([["ae", "a"], ["oe", "o"], ["sh", "s"], ["kh", "k"], ["th", "t"], ["ph", "f"], ["pf", "f"]]), lb = [/([^aeo])h(.)/g, "$1$2", /([aeo])h([^aeo]|$)/g, "$1$2", /(.)\1+/g, "$1"]; +const mb = {a:"", e:"", i:"", o:"", u:"", y:"", b:1, f:1, p:1, v:1, c:2, g:2, j:2, k:2, q:2, s:2, x:2, z:2, "\u00df":2, d:3, t:3, l:4, m:5, n:5, r:6}; +var nb = {Exact:hb, Default:ib, Normalize:ib, LatinBalance:{mapper:jb}, LatinAdvanced:{mapper:jb, matcher:kb, replacer:lb}, LatinExtra:{mapper:jb, replacer:lb.concat([/(?!^)[aeo]/g, ""]), matcher:kb}, LatinSoundex:{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 = mb[d]; + for (let f = 1, g; f < b.length && (g = b.charAt(f), "h" === g || "w" === g || !(g = mb[g]) || g === e || (d += g, e = g, 4 !== d.length)); f++) { + } + a[c] = d; + } +}}, CJK:{split:""}, LatinExact:hb, LatinDefault:ib, LatinSimple:ib}; +function Pa(a) { if (!this || this.constructor !== Pa) { return new Pa(a); } - const c = a.document || a.doc || a; - let b, e; + const b = a.document || a.doc || a; + let c, d; this.F = []; this.field = []; this.J = []; - this.key = (b = c.key || c.id) && hb(b, this.J) || "id"; - (e = a.keystore || 0) && (this.keystore = e); + this.key = (c = b.key || b.id) && ob(c, this.J) || "id"; + (d = a.keystore || 0) && (this.keystore = d); this.fastupdate = !!a.fastupdate; - this.reg = !this.fastupdate || a.worker || a.db ? e ? new V(e) : new Set() : e ? new U(e) : new Map(); - this.C = (b = c.store || null) && b && !0 !== b && []; - this.store = b && (e ? new U(e) : new Map()); - this.cache = (b = a.cache || null) && new ib(b); + this.reg = !this.fastupdate || a.worker || a.db ? d ? new W(d) : new Set() : d ? new V(d) : new Map(); + this.C = (c = b.store || null) && c && !0 !== c && []; + this.store = c && (d ? new V(d) : new Map()); + this.cache = (c = a.cache || null) && new pb(c); a.cache = !1; this.worker = a.worker || !1; this.priority = a.priority || 4; - this.index = jb.call(this, a, c); + this.index = qb.call(this, a, b); this.tag = null; - if (b = c.tag) { - if ("string" === typeof b && (b = [b]), b.length) { + if (c = b.tag) { + if ("string" === typeof c && (c = [c]), c.length) { this.tag = new Map(); this.D = []; this.R = []; - for (let d = 0, f, g; d < b.length; d++) { - f = b[d]; + for (let e = 0, f, g; e < c.length; e++) { + f = c[e]; g = f.field || f; if (!g) { throw Error("The tag field from the document descriptor is undefined."); } - f.custom ? this.D[d] = f.custom : (this.D[d] = hb(g, this.J), f.filter && ("string" === typeof this.D[d] && (this.D[d] = new String(this.D[d])), this.D[d].I = f.filter)); - this.R[d] = g; + f.custom ? this.D[e] = f.custom : (this.D[e] = ob(g, this.J), f.filter && ("string" === typeof this.D[e] && (this.D[e] = new String(this.D[e])), this.D[e].I = f.filter)); + this.R[e] = g; this.tag.set(g, new Map()); } } } if (this.worker) { this.fastupdate = !1; - const d = []; - for (const f of this.index.values()) { - f.then && d.push(f); + a = []; + for (const e of this.index.values()) { + e.then && a.push(e); } - if (d.length) { - const f = this; - return Promise.all(d).then(function(g) { - const k = new Map(); - let h = 0; - for (const m of f.index.entries()) { - const t = m[0]; - var l = m[1]; - if (l.then) { - l = d[h].encoder || {}; - let q = k.get(l); - q || (q = l.encode ? l : new ma(l), k.set(l, q)); - l = g[h]; - l.encoder = q; - f.index.set(t, l); - h++; - } + if (a.length) { + const e = this; + return Promise.all(a).then(function(f) { + let g = 0; + for (const h of e.index.entries()) { + const k = h[0]; + let l = h[1]; + l.then && (l = f[g], e.index.set(k, l), g++); } - return f; + return e; }); } } else { a.db && (this.fastupdate = !1, this.mount(a.db)); } } -v = Pa.prototype; -v.mount = function(a) { +w = Pa.prototype; +w.mount = function(a) { if (this.worker) { throw Error("You can't use Worker-Indexes on a persistent model. That would be useless, since each of the persistent model acts like Worker-Index by default (Master/Slave)."); } - let c = this.field; + let b = this.field; if (this.tag) { for (let f = 0, g; f < this.R.length; f++) { g = this.R[f]; - var b = void 0; - this.index.set(g, b = new P({}, this.reg)); - c === this.field && (c = c.slice(0)); - c.push(g); - b.tag = this.tag.get(g); + var c = void 0; + this.index.set(g, c = new P({}, this.reg)); + b === this.field && (b = b.slice(0)); + b.push(g); + c.tag = this.tag.get(g); } } - b = []; - const e = {db:a.db, type:a.type, fastupdate:a.fastupdate}; - for (let f = 0, g, k; f < c.length; f++) { - e.field = k = c[f]; - g = this.index.get(k); - const h = new a.constructor(a.id, e); - h.id = a.id; - b[f] = h.mount(g); + c = []; + const d = {db:a.db, type:a.type, fastupdate:a.fastupdate}; + for (let f = 0, g, h; f < b.length; f++) { + d.field = h = b[f]; + g = this.index.get(h); + const k = new a.constructor(a.id, d); + k.id = a.id; + c[f] = k.mount(g); g.document = !0; f ? g.bypass = !0 : g.store = this.store; } - const d = this; - return this.db = Promise.all(b).then(function() { - d.db = !0; + const e = this; + return this.db = Promise.all(c).then(function() { + e.db = !0; }); }; -v.commit = async function(a, c) { - const b = []; - for (const e of this.index.values()) { - b.push(e.commit(a, c)); +w.commit = async function(a, b) { + const c = []; + for (const d of this.index.values()) { + c.push(d.commit(a, b)); } - await Promise.all(b); + await Promise.all(c); this.reg.clear(); }; -v.destroy = function() { +w.destroy = function() { const a = []; - for (const c of this.index.values()) { - a.push(c.destroy()); + for (const b of this.index.values()) { + a.push(b.destroy()); } return Promise.all(a); }; -function jb(a, c) { - const b = new Map(); - let e = c.index || c.field || c; - L(e) && (e = [e]); - for (let d = 0, f, g; d < e.length; d++) { - f = e[d]; - L(f) || (g = f, f = f.field); - g = aa(g) ? Object.assign({}, a, g) : a; +function qb(a, b) { + const c = new Map(); + let d = b.index || b.field || b; + M(d) && (d = [d]); + for (let f = 0, g, h; f < d.length; f++) { + g = d[f]; + M(g) || (h = g, g = g.field); + h = aa(h) ? Object.assign({}, a, h) : a; if (this.worker) { - const k = new Aa(g); - k.encoder = g.encoder; - b.set(f, k); + var e = void 0; + e = (e = h.encoder) && e.encode ? e : new ma("string" === typeof e ? nb[e] : e); + e = new Aa(h, e); + c.set(g, e); } - this.worker || b.set(f, new P(g, this.reg)); - g.custom ? this.F[d] = g.custom : (this.F[d] = hb(f, this.J), g.filter && ("string" === typeof this.F[d] && (this.F[d] = new String(this.F[d])), this.F[d].I = g.filter)); - this.field[d] = f; + this.worker || c.set(g, new P(h, this.reg)); + h.custom ? this.F[f] = h.custom : (this.F[f] = ob(g, this.J), h.filter && ("string" === typeof this.F[f] && (this.F[f] = new String(this.F[f])), this.F[f].I = h.filter)); + this.field[f] = g; } if (this.C) { - a = c.store; - L(a) && (a = [a]); - for (let d = 0, f, g; d < a.length; d++) { - f = a[d], g = f.field || f, f.custom ? (this.C[d] = f.custom, f.custom.V = g) : (this.C[d] = hb(g, this.J), f.filter && ("string" === typeof this.C[d] && (this.C[d] = new String(this.C[d])), this.C[d].I = f.filter)); + a = b.store; + M(a) && (a = [a]); + for (let f = 0, g, h; f < a.length; f++) { + g = a[f], h = g.field || g, g.custom ? (this.C[f] = g.custom, g.custom.V = h) : (this.C[f] = ob(h, this.J), g.filter && ("string" === typeof this.C[f] && (this.C[f] = new String(this.C[f])), this.C[f].I = g.filter)); } } - return b; + return c; } -function hb(a, c) { - const b = a.split(":"); - let e = 0; - for (let d = 0; d < b.length; d++) { - a = b[d], "]" === a[a.length - 1] && (a = a.substring(0, a.length - 2)) && (c[e] = !0), a && (b[e++] = a); +function ob(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); } - e < b.length && (b.length = e); - return 1 < e ? b : b[0]; + d < c.length && (c.length = d); + return 1 < d ? c : c[0]; } -v.append = function(a, c) { - return this.add(a, c, !0); +w.append = function(a, b) { + return this.add(a, b, !0); }; -v.update = function(a, c) { - return this.remove(a).add(a, c); +w.update = function(a, b) { + return this.remove(a).add(a, b); }; -v.remove = function(a) { +w.remove = function(a) { aa(a) && (a = ea(a, this.key)); - for (var c of this.index.values()) { - c.remove(a, !0); + for (var b of this.index.values()) { + b.remove(a, !0); } if (this.reg.has(a)) { if (this.tag && !this.fastupdate) { - for (let b of this.tag.values()) { - for (let e of b) { - c = e[0]; - const d = e[1], f = d.indexOf(a); - -1 < f && (1 < d.length ? d.splice(f, 1) : b.delete(c)); + for (let c of this.tag.values()) { + for (let d of c) { + b = d[0]; + const e = d[1], f = e.indexOf(a); + -1 < f && (1 < e.length ? e.splice(f, 1) : c.delete(b)); } } } @@ -1931,269 +1940,255 @@ v.remove = function(a) { this.cache && this.cache.remove(a); return this; }; -v.clear = function() { +w.clear = function() { const a = []; - for (const c of this.index.values()) { - const b = c.clear(); - b.then && a.push(b); + for (const b of this.index.values()) { + const c = b.clear(); + c.then && a.push(c); } if (this.tag) { - for (const c of this.tag.values()) { - c.clear(); + for (const b of this.tag.values()) { + b.clear(); } } this.store && this.store.clear(); this.cache && this.cache.clear(); return a.length ? Promise.all(a) : this; }; -v.contain = function(a) { +w.contain = function(a) { return this.db ? this.index.get(this.field[0]).db.has(a) : this.reg.has(a); }; -v.cleanup = function() { +w.cleanup = function() { for (const a of this.index.values()) { a.cleanup(); } return this; }; -v.get = function(a) { - return this.db ? this.index.get(this.field[0]).db.enrich(a).then(function(c) { - return c[0] && c[0].doc || null; +w.get = function(a) { + return this.db ? this.index.get(this.field[0]).db.enrich(a).then(function(b) { + return b[0] && b[0].doc || null; }) : this.store.get(a) || null; }; -v.set = function(a, c) { - "object" === typeof a && (c = a, a = ea(c, this.key)); - this.store.set(a, c); +w.set = function(a, b) { + "object" === typeof a && (b = a, a = ea(b, this.key)); + this.store.set(a, b); return this; }; -v.searchCache = kb; -v.export = function(a, c, b = 0, e = 0) { - if (b < this.field.length) { - const g = this.field[b]; - if ((c = this.index.get(g).export(a, g, b, e = 1)) && c.then) { - const k = this; - return c.then(function() { - return k.export(a, g, b + 1); +w.searchCache = rb; +w.export = function(a, b, c = 0, d = 0) { + if (c < this.field.length) { + const g = this.field[c]; + if ((b = this.index.get(g).export(a, g, c, d = 1)) && b.then) { + const h = this; + return b.then(function() { + return h.export(a, g, c + 1); }); } - return this.export(a, g, b + 1); + return this.export(a, g, c + 1); } - let d, f; - switch(e) { + let e, f; + switch(d) { case 0: - d = "reg"; + e = "reg"; f = Ga(this.reg); - c = null; + b = null; break; case 1: - d = "tag"; + e = "tag"; f = this.tag && Ea(this.tag, this.reg.size); - c = null; + b = null; break; case 2: - d = "doc"; + e = "doc"; f = this.store && Ca(this.store); - c = null; + b = null; break; default: return; } - return Ia.call(this, a, c, d, f, b, e); + return Ia.call(this, a, b, e, f, c, d); }; -v.import = function(a, c) { - var b = a.split("."); - "json" === b[b.length - 1] && b.pop(); - const e = 2 < b.length ? b[0] : ""; - b = 2 < b.length ? b[2] : b[1]; - if (this.worker && e) { - return this.index.get(e).import(a); +w.import = function(a, b) { + var c = a.split("."); + "json" === c[c.length - 1] && c.pop(); + const d = 2 < c.length ? c[0] : ""; + c = 2 < c.length ? c[2] : c[1]; + if (this.worker && d) { + return this.index.get(d).import(a); } - if (c) { - "string" === typeof c && (c = JSON.parse(c)); - if (e) { - return this.index.get(e).import(b, c); + if (b) { + "string" === typeof b && (b = JSON.parse(b)); + if (d) { + return this.index.get(d).import(c, b); } - switch(b) { + switch(c) { case "reg": this.fastupdate = !1; - this.reg = Ha(c, this.reg); - for (let d = 0, f; d < this.field.length; d++) { - f = this.index.get(this.field[d]), f.fastupdate = !1, f.reg = this.reg; + this.reg = Ha(b, this.reg); + for (let e = 0, f; e < this.field.length; e++) { + f = this.index.get(this.field[e]), f.fastupdate = !1, f.reg = this.reg; } if (this.worker) { - c = []; - for (const d of this.index.values()) { - c.push(d.import(a)); + b = []; + for (const e of this.index.values()) { + b.push(e.import(a)); } - return Promise.all(c); + return Promise.all(b); } break; case "tag": - this.tag = Fa(c, this.tag); + this.tag = Fa(b, this.tag); break; case "doc": - this.store = Da(c, this.store); + this.store = Da(b, this.store); } } }; ra(Pa.prototype); -function kb(a, c, b) { - const e = (c ? "" + a : "object" === typeof a ? "" + a.query : a).toLowerCase(); - this.cache || (this.cache = new ib()); - let d = this.cache.get(e); - if (!d) { - d = this.search(a, c, b); - if (d.then) { +function rb(a, b, c) { + const d = (b ? "" + a : "object" === typeof a ? "" + a.query : a).toLowerCase(); + this.cache || (this.cache = new pb()); + let e = this.cache.get(d); + if (!e) { + e = this.search(a, b, c); + if (e.then) { const f = this; - d.then(function(g) { - f.cache.set(e, g); + e.then(function(g) { + f.cache.set(d, g); return g; }); } - this.cache.set(e, d); + this.cache.set(d, e); } - return d; + return e; } -function ib(a) { +function pb(a) { this.limit = a && !0 !== a ? a : 1000; this.cache = new Map(); this.h = ""; } -ib.prototype.set = function(a, c) { - this.cache.set(this.h = a, c); +pb.prototype.set = function(a, b) { + this.cache.set(this.h = a, b); this.cache.size > this.limit && this.cache.delete(this.cache.keys().next().value); }; -ib.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; +pb.prototype.get = function(a) { + const b = this.cache.get(a); + b && this.h !== a && (this.cache.delete(a), this.cache.set(this.h = a, b)); + return b; }; -ib.prototype.remove = function(a) { - for (const c of this.cache) { - const b = c[0]; - c[1].includes(a) && this.cache.delete(b); +pb.prototype.remove = function(a) { + for (const b of this.cache) { + const c = b[0]; + b[1].includes(a) && this.cache.delete(c); } }; -ib.prototype.clear = function() { +pb.prototype.clear = function() { this.cache.clear(); this.h = ""; }; -const lb = {normalize:!1, numeric:!1, dedupe:!1}; -const mb = {}; -const nb = 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 ob = new Map([["ae", "a"], ["oe", "o"], ["sh", "s"], ["kh", "k"], ["th", "t"], ["ph", "f"], ["pf", "f"]]), pb = [/([^aeo])h(.)/g, "$1$2", /([aeo])h([^aeo]|$)/g, "$1$2", /(.)\1+/g, "$1"]; -const qb = {a:"", e:"", i:"", o:"", u:"", y:"", b:1, f:1, p:1, v:1, c:2, g:2, j:2, k:2, q:2, s:2, x:2, z:2, "\u00df":2, d:3, t:3, l:4, m:5, n:5, r:6}; -var rb = {Exact:lb, Default:mb, Normalize:mb, LatinBalance:{mapper:nb}, LatinAdvanced:{mapper:nb, matcher:ob, replacer:pb}, LatinExtra:{mapper:nb, replacer:pb.concat([/(?!^)[aeo]/g, ""]), matcher:ob}, LatinSoundex:{dedupe:!1, include:{letter:!0}, finalize:function(a) { - for (let b = 0; b < a.length; b++) { - var c = a[b]; - let e = c.charAt(0), d = qb[e]; - for (let f = 1, g; f < c.length && (g = c.charAt(f), "h" === g || "w" === g || !(g = qb[g]) || g === d || (e += g, d = g, 4 !== e.length)); f++) { - } - a[b] = e; - } -}}, CJK:{split:""}, LatinExact:lb, LatinDefault:mb, LatinSimple:mb}; -P.prototype.remove = function(a, c) { - const b = this.reg.size && (this.fastupdate ? this.reg.get(a) : this.reg.has(a)); - if (b) { +P.prototype.remove = function(a, b) { + const c = this.reg.size && (this.fastupdate ? this.reg.get(a) : this.reg.has(a)); + if (c) { if (this.fastupdate) { - for (let e = 0, d; e < b.length; e++) { - if (d = b[e]) { - if (2 > d.length) { - d.pop(); + for (let d = 0, e; d < c.length; d++) { + if (e = c[d]) { + if (2 > e.length) { + e.pop(); } else { - const f = d.indexOf(a); - f === b.length - 1 ? d.pop() : d.splice(f, 1); + const f = e.indexOf(a); + f === c.length - 1 ? e.pop() : e.splice(f, 1); } } } } else { sb(this.map, a), this.depth && sb(this.ctx, a); } - c || this.reg.delete(a); + b || this.reg.delete(a); } this.db && (this.commit_task.push({del:a}), this.T && tb(this)); this.cache && this.cache.remove(a); return this; }; -function sb(a, c) { - let b = 0; - var e = "undefined" === typeof c; +function sb(a, b) { + let c = 0; + var d = "undefined" === typeof b; if (a.constructor === Array) { - for (let d = 0, f, g; d < a.length; d++) { - if ((f = a[d]) && f.length) { - if (e) { - b++; + for (let e = 0, f, g; e < a.length; e++) { + if ((f = a[e]) && f.length) { + if (d) { + c++; } else { - if (g = f.indexOf(c), 0 <= g) { - 1 < f.length ? (f.splice(g, 1), b++) : delete a[d]; + if (g = f.indexOf(b), 0 <= g) { + 1 < f.length ? (f.splice(g, 1), c++) : delete a[e]; break; } else { - b++; + c++; } } } } } else { - for (let d of a.entries()) { - e = d[0]; - const f = sb(d[1], c); - f ? b += f : a.delete(e); + for (let e of a.entries()) { + d = e[0]; + const f = sb(e[1], b); + f ? c += f : a.delete(d); } } - return b; + return c; } ;const ub = {memory:{resolution:1}, performance:{resolution:3, fastupdate:!0, context:{depth:1, resolution:1}}, match:{tokenize:"forward"}, score:{resolution:9, context:{depth:2, resolution:3}}}; -P.prototype.add = function(a, c, b, e) { - if (c && (a || 0 === a)) { - if (!e && !b && this.reg.has(a)) { - return this.update(a, c); +P.prototype.add = function(a, b, c, d) { + if (b && (a || 0 === a)) { + if (!d && !c && this.reg.has(a)) { + return this.update(a, b); } - e = this.depth; - c = this.encoder.encode(c, !e); - const l = c.length; + d = this.depth; + b = this.encoder.encode(b, !d); + const l = b.length; if (l) { - const m = G(), t = G(), q = this.resolution; - for (let n = 0; n < l; n++) { - let r = c[this.rtl ? l - 1 - n : n]; - var d = r.length; - if (d && (e || !t[r])) { - var f = this.score ? this.score(c, r, n, null, 0) : vb(q, l, n), g = ""; + const m = H(), p = H(), u = this.resolution; + for (let q = 0; q < l; q++) { + let r = b[this.rtl ? l - 1 - q : q]; + var e = r.length; + if (e && (d || !p[r])) { + var f = this.score ? this.score(b, r, q, null, 0) : vb(u, l, q), g = ""; switch(this.tokenize) { case "full": - if (2 < d) { - for (let u = 0, p; u < d; u++) { - for (f = d; f > u; f--) { - g = r.substring(u, f); - p = this.rtl ? d - 1 - u : u; - var k = this.score ? this.score(c, r, n, g, p) : vb(q, l, n, d, p); - wb(this, t, g, k, a, b); + if (2 < e) { + for (let n = 0, t; n < e; n++) { + for (f = e; f > n; f--) { + g = r.substring(n, f); + t = this.rtl ? e - 1 - n : n; + var h = this.score ? this.score(b, r, q, g, t) : vb(u, l, q, e, t); + wb(this, p, g, h, a, c); } } break; } case "bidirectional": case "reverse": - if (1 < d) { - for (k = d - 1; 0 < k; k--) { - g = r[this.rtl ? d - 1 - k : k] + g; - var h = this.score ? this.score(c, r, n, g, k) : vb(q, l, n, d, k); - wb(this, t, g, h, a, b); + if (1 < e) { + for (h = e - 1; 0 < h; h--) { + g = r[this.rtl ? e - 1 - h : h] + g; + var k = this.score ? this.score(b, r, q, g, h) : vb(u, l, q, e, h); + wb(this, p, g, k, a, c); } g = ""; } case "forward": - if (1 < d) { - for (k = 0; k < d; k++) { - g += r[this.rtl ? d - 1 - k : k], wb(this, t, g, f, a, b); + if (1 < e) { + for (h = 0; h < e; h++) { + g += r[this.rtl ? e - 1 - h : h], wb(this, p, g, f, a, c); } break; } default: - if (wb(this, t, r, f, a, b), e && 1 < l && n < l - 1) { - for (d = G(), g = this.U, f = r, k = Math.min(e + 1, this.rtl ? n + 1 : l - n), d[f] = 1, h = 1; h < k; h++) { - if ((r = c[this.rtl ? l - 1 - n - h : n + h]) && !d[r]) { - d[r] = 1; - const u = this.score ? this.score(c, f, n, r, h - 1) : vb(g + (l / 2 > g ? 0 : 1), l, n, k - 1, h - 1), p = this.bidirectional && r > f; - wb(this, m, p ? f : r, u, a, b, p ? r : f); + if (wb(this, p, r, f, a, c), d && 1 < l && q < l - 1) { + for (e = H(), g = this.U, f = r, h = Math.min(d + 1, this.rtl ? q + 1 : l - q), e[f] = 1, k = 1; k < h; k++) { + if ((r = b[this.rtl ? l - 1 - q - k : q + k]) && !e[r]) { + e[r] = 1; + const n = this.score ? this.score(b, f, q, r, k - 1) : vb(g + (l / 2 > g ? 0 : 1), l, q, h - 1, k - 1), t = this.bidirectional && r > f; + wb(this, m, t ? f : r, n, a, c, t ? r : f); } } } @@ -2202,180 +2197,180 @@ P.prototype.add = function(a, c, b, e) { } this.fastupdate || this.reg.add(a); } else { - c = ""; + b = ""; } } - this.db && (c || this.commit_task.push({del:a}), this.T && tb(this)); + this.db && (b || this.commit_task.push({del:a}), this.T && tb(this)); return this; }; -function wb(a, c, b, e, d, f, g) { - let k = g ? a.ctx : a.map, h; - if (!c[b] || g && !(h = c[b])[g]) { - if (g ? (c = h || (c[b] = G()), c[g] = 1, (h = k.get(g)) ? k = h : k.set(g, k = new Map())) : c[b] = 1, (h = k.get(b)) ? k = h : k.set(b, k = h = []), k = k[e] || (k[e] = []), !f || !k.includes(d)) { - if (k.length === 2 ** 31 - 1) { - c = new T(k); +function wb(a, b, c, d, e, f, g) { + let h = g ? a.ctx : a.map, k; + if (!b[c] || g && !(k = b[c])[g]) { + if (g ? (b = k || (b[c] = H()), 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 U(h); if (a.fastupdate) { for (let l of a.reg.values()) { - l.includes(k) && (l[l.indexOf(k)] = c); + l.includes(h) && (l[l.indexOf(h)] = b); } } - h[e] = k = c; + k[d] = h = b; } - k.push(d); - a.fastupdate && ((e = a.reg.get(d)) ? e.push(k) : a.reg.set(d, [k])); + h.push(e); + a.fastupdate && ((d = a.reg.get(e)) ? d.push(h) : a.reg.set(e, [h])); } } } -function vb(a, c, b, e, d) { - return b && 1 < a ? c + (e || 0) <= a ? b + (d || 0) : (a - 1) / (c + (e || 0)) * (b + (d || 0)) + 1 | 0 : 0; +function vb(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; } -;P.prototype.search = function(a, c, b) { - b || (c || "object" !== typeof a ? "object" === typeof c && (b = c, c = 0) : (b = a, a = "")); - if (b && b.cache) { - return b.cache = !1, a = this.searchCache(a, c, b), b.cache = !0, a; +;P.prototype.search = function(a, b, c) { + c || (b || "object" !== typeof a ? "object" === typeof b && (c = b, b = 0) : (c = a, a = "")); + if (c && c.cache) { + return c.cache = !1, a = this.searchCache(a, b, c), c.cache = !0, a; } - let e = [], d, f, g, k = 0, h, l, m, t, q; - b && (a = b.query || a, c = b.limit || c, k = b.offset || 0, f = b.context, g = b.suggest, q = (h = b.resolve) && b.enrich, m = b.boost, t = b.resolution, l = this.db && b.tag); - "undefined" === typeof h && (h = this.resolve); + let d = [], e, f, g, h = 0, k, l, m, p, u; + c && (a = c.query || a, b = c.limit || b, h = c.offset || 0, f = c.context, g = c.suggest, u = (k = c.resolve) && c.enrich, m = c.boost, p = c.resolution, l = this.db && c.tag); + "undefined" === typeof k && (k = this.resolve); f = this.depth && !1 !== f; - let n = this.encoder.encode(a, !f); - d = n.length; - c = c || (h ? 100 : 0); - if (1 === d) { - return xb.call(this, n[0], "", c, k, h, q, l); + let q = this.encoder.encode(a, !f); + e = q.length; + b = b || (k ? 100 : 0); + if (1 === e) { + return xb.call(this, q[0], "", b, h, k, u, l); } - if (2 === d && f && !g) { - return xb.call(this, n[1], n[0], c, k, h, q, l); + if (2 === e && f && !g) { + return xb.call(this, q[1], q[0], b, h, k, u, l); } - let r = G(), u = 0, p; - f && (p = n[0], u = 1); - t || 0 === t || (t = p ? this.U : this.resolution); + let r = H(), n = 0, t; + f && (t = q[0], n = 1); + p || 0 === p || (p = t ? this.U : this.resolution); if (this.db) { - if (this.db.search && (b = this.db.search(this, n, c, k, g, h, q, l), !1 !== b)) { - return b; + if (this.db.search && (c = this.db.search(this, q, b, h, g, k, u, l), !1 !== c)) { + return c; } - const z = this; + const x = this; return async function() { - for (let x, J; u < d; u++) { - if ((J = n[u]) && !r[J]) { - r[J] = 1; - x = await yb(z, J, p, 0, 0, !1, !1); - if (x = zb(x, e, g, t)) { - e = x; + for (let y, D; n < e; n++) { + if ((D = q[n]) && !r[D]) { + r[D] = 1; + y = await yb(x, D, t, 0, 0, !1, !1); + if (y = zb(y, d, g, p)) { + d = y; break; } - p && (g && x && e.length || (p = J)); + t && (g && y && d.length || (t = D)); } - g && p && u === d - 1 && !e.length && (t = z.resolution, p = "", u = -1, r = G()); + g && t && n === e - 1 && !d.length && (p = x.resolution, t = "", n = -1, r = H()); } - return Ab(e, t, c, k, g, m, h); + return Ab(d, p, b, h, g, m, k); }(); } - for (let z, x; u < d; u++) { - if ((x = n[u]) && !r[x]) { - r[x] = 1; - z = yb(this, x, p, 0, 0, !1, !1); - if (z = zb(z, e, g, t)) { - e = z; + for (let x, y; n < e; n++) { + if ((y = q[n]) && !r[y]) { + r[y] = 1; + x = yb(this, y, t, 0, 0, !1, !1); + if (x = zb(x, d, g, p)) { + d = x; break; } - p && (g && z && e.length || (p = x)); + t && (g && x && d.length || (t = y)); } - g && p && u === d - 1 && !e.length && (t = this.resolution, p = "", u = -1, r = G()); + g && t && n === e - 1 && !d.length && (p = this.resolution, t = "", n = -1, r = H()); } - return Ab(e, t, c, k, g, m, h); + return Ab(d, p, b, h, g, m, k); }; -function Ab(a, c, b, e, d, f, g) { - let k = a.length, h = a; - if (1 < k) { - h = Sa(a, c, b, e, d, f, g); - } else if (1 === k) { - return g ? Va.call(null, a[0], b, e) : new Y(a[0], this); +function Ab(a, b, c, d, e, f, g) { + let h = a.length, k = a; + if (1 < h) { + k = Xa(a, b, c, d, e, f, g); + } else if (1 === h) { + return g ? Sa.call(null, a[0], c, d) : new Y(a[0], this); } - return g ? h : new Y(h, this); + return g ? k : new Y(k, this); } -function xb(a, c, b, e, d, f, g) { - a = yb(this, a, c, b, e, d, f, g); - return this.db ? a.then(function(k) { - return d ? k || [] : new Y(k, this); - }) : a && a.length ? d ? Va.call(this, a, b, e) : new Y(a, this) : d ? [] : new Y([], this); +function xb(a, b, c, d, e, f, g) { + a = yb(this, a, b, c, d, e, f, g); + return this.db ? a.then(function(h) { + return e ? h || [] : new Y(h, this); + }) : a && a.length ? e ? Sa.call(this, a, c, d) : new Y(a, this) : e ? [] : new Y([], this); } -function zb(a, c, b, e) { - let d = []; +function zb(a, b, c, d) { + let e = []; if (a && a.length) { - if (a.length <= e) { - c.push(a); + if (a.length <= d) { + b.push(a); return; } - for (let f = 0, g; f < e; f++) { + for (let f = 0, g; f < d; f++) { if (g = a[f]) { - d[f] = g; + e[f] = g; } } - if (d.length) { - c.push(d); + if (e.length) { + b.push(e); return; } } - if (!b) { - return d; + if (!c) { + return e; } } -function yb(a, c, b, e, d, f, g, k) { - let h; - b && (h = a.bidirectional && c > b) && (h = b, b = c, c = h); +function yb(a, b, c, d, e, f, g, h) { + let k; + c && (k = a.bidirectional && b > c) && (k = c, c = b, b = k); if (a.db) { - return a.db.get(c, b, e, d, f, g, k); + return a.db.get(b, c, d, e, f, g, h); } - a = b ? (a = a.ctx.get(b)) && a.get(c) : a.map.get(c); + a = c ? (a = a.ctx.get(c)) && a.get(b) : a.map.get(b); return a; } -;function P(a, c) { +;function P(a, b) { if (!this || this.constructor !== P) { return new P(a); } if (a) { - var b = L(a) ? a : a.preset; - b && (ub[b] || console.warn("Preset not found: " + b), a = Object.assign({}, ub[b], a)); + var c = M(a) ? a : a.preset; + c && (ub[c] || console.warn("Preset not found: " + c), a = Object.assign({}, ub[c], a)); } else { a = {}; } - b = a.context; - const e = !0 === b ? {depth:1} : b || {}, d = L(a.encoder) ? rb[a.encoder] : a.encode || a.encoder || {}; - this.encoder = d.encode ? d : "object" === typeof d ? new ma(d) : {encode:d}; + c = a.context; + const d = !0 === c ? {depth:1} : c || {}, e = M(a.encoder) ? nb[a.encoder] : a.encode || a.encoder || {}; + this.encoder = e.encode ? e : "object" === typeof e ? new ma(e) : {encode:e}; this.resolution = a.resolution || 9; - this.tokenize = b = (b = a.tokenize) && "default" !== b && "exact" !== b && b || "strict"; - this.depth = "strict" === b && e.depth || 0; - this.bidirectional = !1 !== e.bidirectional; + this.tokenize = c = (c = a.tokenize) && "default" !== c && "exact" !== c && c || "strict"; + this.depth = "strict" === c && d.depth || 0; + this.bidirectional = !1 !== d.bidirectional; this.fastupdate = !!a.fastupdate; this.score = a.score || null; - e && e.depth && "strict" !== this.tokenize && console.warn('Context-Search could not applied, because it is just supported when using the tokenizer "strict".'); - (b = a.keystore || 0) && (this.keystore = b); - this.map = b ? new U(b) : new Map(); - this.ctx = b ? new U(b) : new Map(); - this.reg = c || (this.fastupdate ? b ? new U(b) : new Map() : b ? new V(b) : new Set()); - this.U = e.resolution || 3; - this.rtl = d.rtl || a.rtl || !1; - this.cache = (b = a.cache || null) && new ib(b); + d && d.depth && "strict" !== this.tokenize && console.warn('Context-Search could not applied, because it is just supported when using the tokenizer "strict".'); + (c = a.keystore || 0) && (this.keystore = c); + this.map = c ? new V(c) : new Map(); + this.ctx = c ? new V(c) : new Map(); + this.reg = b || (this.fastupdate ? c ? new V(c) : new Map() : c ? new W(c) : new Set()); + this.U = d.resolution || 3; + this.rtl = e.rtl || a.rtl || !1; + this.cache = (c = a.cache || null) && new pb(c); this.resolve = !1 !== a.resolve; - if (b = a.db) { - this.db = this.mount(b); + if (c = a.db) { + this.db = this.mount(c); } this.T = !1 !== a.commit; this.commit_task = []; this.commit_timer = null; this.priority = a.priority || 4; } -v = P.prototype; -v.mount = function(a) { +w = P.prototype; +w.mount = function(a) { this.commit_timer && (clearTimeout(this.commit_timer), this.commit_timer = null); return a.mount(this); }; -v.commit = function(a, c) { +w.commit = function(a, b) { this.commit_timer && (clearTimeout(this.commit_timer), this.commit_timer = null); - return this.db.commit(this, a, c); + return this.db.commit(this, a, b); }; -v.destroy = function() { +w.destroy = function() { this.commit_timer && (clearTimeout(this.commit_timer), this.commit_timer = null); return this.db.destroy(); }; @@ -2385,7 +2380,7 @@ function tb(a) { a.db.commit(a, void 0, void 0); }, 1)); } -v.clear = function() { +w.clear = function() { this.map.clear(); this.ctx.clear(); this.reg.clear(); @@ -2393,17 +2388,17 @@ v.clear = function() { this.db && (this.commit_timer && clearTimeout(this.commit_timer), this.commit_timer = null, this.commit_task = [{clear:!0}]); return this; }; -v.append = function(a, c) { - return this.add(a, c, !0); +w.append = function(a, b) { + return this.add(a, b, !0); }; -v.contain = function(a) { +w.contain = function(a) { return this.db ? this.db.has(a) : this.reg.has(a); }; -v.update = function(a, c) { - const b = this, e = this.remove(a); - return e && e.then ? e.then(() => b.add(a, c)) : this.add(a, c); +w.update = function(a, b) { + const c = this, d = this.remove(a); + return d && d.then ? d.then(() => c.add(a, b)) : this.add(a, b); }; -v.cleanup = function() { +w.cleanup = function() { if (!this.fastupdate) { return console.info('Cleanup the index isn\'t required when not using "fastupdate".'), this; } @@ -2411,91 +2406,91 @@ v.cleanup = function() { this.depth && sb(this.ctx); return this; }; -v.searchCache = kb; -v.export = function(a, c, b = 0, e = 0) { - let d, f; - switch(e) { +w.searchCache = rb; +w.export = function(a, b, c = 0, d = 0) { + let e, f; + switch(d) { case 0: - d = "reg"; + e = "reg"; f = Ga(this.reg); break; case 1: - d = "cfg"; + e = "cfg"; f = null; break; case 2: - d = "map"; + e = "map"; f = Ca(this.map, this.reg.size); break; case 3: - d = "ctx"; + e = "ctx"; f = Ea(this.ctx, this.reg.size); break; default: return; } - return Ia.call(this, a, c, d, f, b, e); + return Ia.call(this, a, b, e, f, c, d); }; -v.import = function(a, c) { - if (c) { - switch("string" === typeof c && (c = JSON.parse(c)), a = a.split("."), "json" === a[a.length - 1] && a.pop(), 3 === a.length && a.shift(), a = 1 < a.length ? a[1] : a[0], a) { +w.import = function(a, b) { + if (b) { + switch("string" === typeof b && (b = JSON.parse(b)), a = a.split("."), "json" === a[a.length - 1] && a.pop(), 3 === a.length && a.shift(), a = 1 < a.length ? a[1] : a[0], a) { case "reg": this.fastupdate = !1; - this.reg = Ha(c, this.reg); + this.reg = Ha(b, this.reg); break; case "map": - this.map = Da(c, this.map); + this.map = Da(b, this.map); break; case "ctx": - this.ctx = Fa(c, this.ctx); + this.ctx = Fa(b, this.ctx); } } }; -v.serialize = function(a = !0) { - let c = "", b = "", e = ""; +w.serialize = function(a = !0) { + let b = "", c = "", d = ""; if (this.reg.size) { let f; - for (var d of this.reg.keys()) { - f || (f = typeof d), c += (c ? "," : "") + ("string" === f ? '"' + d + '"' : d); + for (var e of this.reg.keys()) { + f || (f = typeof e), b += (b ? "," : "") + ("string" === f ? '"' + e + '"' : e); } - c = "index.reg=new Set([" + c + "]);"; - b = Ja(this.map, f); - b = "index.map=new Map([" + b + "]);"; + b = "index.reg=new Set([" + b + "]);"; + c = Ja(this.map, f); + c = "index.map=new Map([" + c + "]);"; for (const g of this.ctx.entries()) { - d = g[0]; - let k = Ja(g[1], f); - k = "new Map([" + k + "])"; - k = '["' + d + '",' + k + "]"; - e += (e ? "," : "") + k; + e = g[0]; + let h = Ja(g[1], f); + h = "new Map([" + h + "])"; + h = '["' + e + '",' + h + "]"; + d += (d ? "," : "") + h; } - e = "index.ctx=new Map([" + e + "]);"; + d = "index.ctx=new Map([" + d + "]);"; } - return a ? "function inject(index){" + c + b + e + "}" : c + b + e; + return a ? "function inject(index){" + b + c + d + "}" : b + c + d; }; ra(P.prototype); -const Bb = "undefined" !== typeof window && (window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB), Cb = ["map", "ctx", "tag", "reg", "cfg"], Db = G(); -function Eb(a, c = {}) { +const Bb = "undefined" !== typeof window && (window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB), Cb = ["map", "ctx", "tag", "reg", "cfg"], Db = H(); +function Eb(a, b = {}) { if (!this || this.constructor !== Eb) { - return new Eb(a, c); + return new Eb(a, b); } - "object" === typeof a && (c = a, a = a.name); + "object" === typeof a && (b = a, a = a.name); a || console.info("Default storage space was used, because a name was not passed."); this.id = "flexsearch" + (a ? ":" + a.toLowerCase().replace(/[^a-z0-9_\-]/g, "") : ""); - this.field = c.field ? c.field.toLowerCase().replace(/[^a-z0-9_\-]/g, "") : ""; - this.type = c.type; + this.field = b.field ? b.field.toLowerCase().replace(/[^a-z0-9_\-]/g, "") : ""; + this.type = b.type; this.fastupdate = this.support_tag_search = !1; this.db = null; this.h = {}; } -v = Eb.prototype; -v.mount = function(a) { +w = Eb.prototype; +w.mount = function(a) { if (a.index) { return a.mount(this); } a.db = this; return this.open(); }; -v.open = function() { +w.open = function() { if (this.db) { return this.db; } @@ -2503,279 +2498,279 @@ v.open = function() { navigator.storage && navigator.storage.persist(); Db[a.id] || (Db[a.id] = []); Db[a.id].push(a.field); - const c = Bb.open(a.id, 1); - c.onupgradeneeded = function() { - const b = a.db = this.result; - for (let e = 0, d; e < Cb.length; e++) { - d = Cb[e]; + const b = Bb.open(a.id, 1); + b.onupgradeneeded = function() { + const c = a.db = this.result; + for (let d = 0, e; d < Cb.length; d++) { + e = Cb[d]; for (let f = 0, g; f < Db[a.id].length; f++) { - g = Db[a.id][f], b.objectStoreNames.contains(d + ("reg" !== d ? g ? ":" + g : "" : "")) || b.createObjectStore(d + ("reg" !== d ? g ? ":" + g : "" : "")); + g = Db[a.id][f], c.objectStoreNames.contains(e + ("reg" !== e ? g ? ":" + g : "" : "")) || c.createObjectStore(e + ("reg" !== e ? g ? ":" + g : "" : "")); } } }; - return a.db = Z(c, function(b) { - a.db = b; + return a.db = Z(b, function(c) { + a.db = c; a.db.onversionchange = function() { a.close(); }; }); }; -v.close = function() { +w.close = function() { this.db && this.db.close(); this.db = null; }; -v.destroy = function() { +w.destroy = function() { const a = Bb.deleteDatabase(this.id); return Z(a); }; -v.clear = function() { +w.clear = function() { const a = []; - for (let b = 0, e; b < Cb.length; b++) { - e = Cb[b]; - for (let d = 0, f; d < Db[this.id].length; d++) { - f = Db[this.id][d], a.push(e + ("reg" !== e ? f ? ":" + f : "" : "")); + for (let c = 0, d; c < Cb.length; c++) { + d = Cb[c]; + for (let e = 0, f; e < Db[this.id].length; e++) { + f = Db[this.id][e], a.push(d + ("reg" !== d ? f ? ":" + f : "" : "")); } } - const c = this.db.transaction(a, "readwrite"); - for (let b = 0; b < a.length; b++) { - c.objectStore(a[b]).clear(); + const b = this.db.transaction(a, "readwrite"); + for (let c = 0; c < a.length; c++) { + b.objectStore(a[c]).clear(); } - return Z(c); + return Z(b); }; -v.get = function(a, c, b = 0, e = 0, d = !0, f = !1) { - a = this.db.transaction((c ? "ctx" : "map") + (this.field ? ":" + this.field : ""), "readonly").objectStore((c ? "ctx" : "map") + (this.field ? ":" + this.field : "")).get(c ? c + ":" + a : a); +w.get = function(a, b, c = 0, d = 0, e = !0, f = !1) { + a = this.db.transaction((b ? "ctx" : "map") + (this.field ? ":" + this.field : ""), "readonly").objectStore((b ? "ctx" : "map") + (this.field ? ":" + this.field : "")).get(b ? b + ":" + a : a); const g = this; - return Z(a).then(function(k) { - let h = []; - if (!k || !k.length) { - return h; + return Z(a).then(function(h) { + let k = []; + if (!h || !h.length) { + return k; } - if (d) { - if (!b && !e && 1 === k.length) { - return k[0]; + if (e) { + if (!c && !d && 1 === h.length) { + return h[0]; } - for (let l = 0, m; l < k.length; l++) { - if ((m = k[l]) && m.length) { - if (e >= m.length) { - e -= m.length; + for (let l = 0, m; l < h.length; l++) { + if ((m = h[l]) && m.length) { + if (d >= m.length) { + d -= m.length; continue; } - const t = b ? e + Math.min(m.length - e, b) : m.length; - for (let q = e; q < t; q++) { - h.push(m[q]); + const p = c ? d + Math.min(m.length - d, c) : m.length; + for (let u = d; u < p; u++) { + k.push(m[u]); } - e = 0; - if (h.length === b) { + d = 0; + if (k.length === c) { break; } } } - return f ? g.enrich(h) : h; + return f ? g.enrich(k) : k; } - return k; + return h; }); }; -v.tag = function(a, c = 0, b = 0, e = !1) { +w.tag = function(a, b = 0, c = 0, d = !1) { a = this.db.transaction("tag" + (this.field ? ":" + this.field : ""), "readonly").objectStore("tag" + (this.field ? ":" + this.field : "")).get(a); - const d = this; + const e = this; return Z(a).then(function(f) { - if (!f || !f.length || b >= f.length) { + if (!f || !f.length || c >= f.length) { return []; } - if (!c && !b) { + if (!b && !c) { return f; } - f = f.slice(b, b + c); - return e ? d.enrich(f) : f; + f = f.slice(c, c + b); + return d ? e.enrich(f) : f; }); }; -v.enrich = function(a) { +w.enrich = function(a) { "object" !== typeof a && (a = [a]); - const c = this.db.transaction("reg", "readonly").objectStore("reg"), b = []; - for (let e = 0; e < a.length; e++) { - b[e] = Z(c.get(a[e])); + 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(b).then(function(e) { - for (let d = 0; d < e.length; d++) { - e[d] = {id:a[d], doc:e[d] ? JSON.parse(e[d]) : null}; + 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 e; + return d; }); }; -v.has = function(a) { +w.has = function(a) { a = this.db.transaction("reg", "readonly").objectStore("reg").getKey(a); - return Z(a).then(function(c) { - return !!c; + return Z(a).then(function(b) { + return !!b; }); }; -v.search = null; -v.info = function() { +w.search = null; +w.info = function() { }; -v.transaction = function(a, c, b) { +w.transaction = function(a, b, c) { a += "reg" !== a ? this.field ? ":" + this.field : "" : ""; - let e = this.h[a + ":" + c]; - if (e) { - return b.call(this, e); + let d = this.h[a + ":" + b]; + if (d) { + return c.call(this, d); } - let d = this.db.transaction(a, c); - this.h[a + ":" + c] = e = d.objectStore(a); - const f = b.call(this, e); - this.h[a + ":" + c] = null; - return Z(d).finally(function() { - d = e = null; + let e = this.db.transaction(a, b); + this.h[a + ":" + b] = d = e.objectStore(a); + const f = c.call(this, d); + this.h[a + ":" + b] = null; + return Z(e).finally(function() { + e = d = null; return f; }); }; -v.commit = async function(a, c, b) { - if (c) { +w.commit = async function(a, b, c) { + if (b) { await this.clear(), a.commit_task = []; } else { - let e = a.commit_task; + let d = a.commit_task; a.commit_task = []; - for (let d = 0, f; d < e.length; d++) { - if (f = e[d], f.clear) { + for (let e = 0, f; e < d.length; e++) { + if (f = d[e], f.clear) { await this.clear(); - c = !0; + b = !0; break; } else { - e[d] = f.del; + d[e] = f.del; } } - c || (b || (e = e.concat(da(a.reg))), e.length && await this.remove(e)); + b || (c || (d = d.concat(da(a.reg))), d.length && await this.remove(d)); } - a.reg.size && (await this.transaction("map", "readwrite", function(e) { - for (const d of a.map) { - const f = d[0], g = d[1]; - g.length && (c ? e.put(g, f) : e.get(f).onsuccess = function() { - let k = this.result; - var h; - if (k && k.length) { - const l = Math.max(k.length, g.length); - for (let m = 0, t, q; m < l; m++) { - if ((q = g[m]) && q.length) { - if ((t = k[m]) && t.length) { - for (h = 0; h < q.length; h++) { - t.push(q[h]); + a.reg.size && (await this.transaction("map", "readwrite", function(d) { + for (const e of a.map) { + const f = e[0], g = e[1]; + g.length && (b ? d.put(g, f) : d.get(f).onsuccess = function() { + let h = this.result; + var k; + if (h && h.length) { + const l = Math.max(h.length, g.length); + for (let m = 0, p, u; m < l; m++) { + if ((u = g[m]) && u.length) { + if ((p = h[m]) && p.length) { + for (k = 0; k < u.length; k++) { + p.push(u[k]); } } else { - k[m] = q; + h[m] = u; } - h = 1; + k = 1; } } } else { - k = g, h = 1; + h = g, k = 1; } - h && e.put(k, f); + k && d.put(h, f); }); } - }), await this.transaction("ctx", "readwrite", function(e) { - for (const d of a.ctx) { - const f = d[0], g = d[1]; - for (const k of g) { - const h = k[0], l = k[1]; - l.length && (c ? e.put(l, f + ":" + h) : e.get(f + ":" + h).onsuccess = function() { + }), await this.transaction("ctx", "readwrite", function(d) { + for (const e of a.ctx) { + const f = e[0], g = e[1]; + for (const h of g) { + const k = h[0], l = h[1]; + l.length && (b ? d.put(l, f + ":" + k) : d.get(f + ":" + k).onsuccess = function() { let m = this.result; - var t; + var p; if (m && m.length) { - const q = Math.max(m.length, l.length); - for (let n = 0, r, u; n < q; n++) { - if ((u = l[n]) && u.length) { - if ((r = m[n]) && r.length) { - for (t = 0; t < u.length; t++) { - r.push(u[t]); + const u = Math.max(m.length, l.length); + for (let q = 0, r, n; q < u; q++) { + if ((n = l[q]) && n.length) { + if ((r = m[q]) && r.length) { + for (p = 0; p < n.length; p++) { + r.push(n[p]); } } else { - m[n] = u; + m[q] = n; } - t = 1; + p = 1; } } } else { - m = l, t = 1; + m = l, p = 1; } - t && e.put(m, f + ":" + h); + p && d.put(m, f + ":" + k); }); } } - }), a.store ? await this.transaction("reg", "readwrite", function(e) { - for (const d of a.store) { - const f = d[0], g = d[1]; - e.put("object" === typeof g ? JSON.stringify(g) : 1, f); + }), 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.bypass || await this.transaction("reg", "readwrite", function(e) { - for (const d of a.reg.keys()) { - e.put(1, d); + }) : a.bypass || await this.transaction("reg", "readwrite", function(d) { + for (const e of a.reg.keys()) { + d.put(1, e); } - }), a.tag && await this.transaction("tag", "readwrite", function(e) { - for (const d of a.tag) { - const f = d[0], g = d[1]; - g.length && (e.get(f).onsuccess = function() { - let k = this.result; - k = k && k.length ? k.concat(g) : g; - e.put(k, f); + }), a.tag && await this.transaction("tag", "readwrite", function(d) { + for (const e of a.tag) { + const f = e[0], g = e[1]; + g.length && (d.get(f).onsuccess = function() { + let h = this.result; + h = h && h.length ? h.concat(g) : g; + d.put(h, f); }); } }), a.map.clear(), a.ctx.clear(), a.tag && a.tag.clear(), a.store && a.store.clear(), a.document || a.reg.clear()); }; -function Fb(a, c, b) { - const e = a.value; - let d, f = 0; - for (let g = 0, k; g < e.length; g++) { - if (k = b ? e : e[g]) { - for (let h = 0, l, m; h < c.length; h++) { - if (m = c[h], l = k.indexOf(m), 0 <= l) { - if (d = 1, 1 < k.length) { - k.splice(l, 1); +function Fb(a, b, c) { + const d = a.value; + let e, f = 0; + for (let g = 0, h; g < d.length; g++) { + if (h = c ? d : d[g]) { + for (let k = 0, l, m; k < b.length; k++) { + if (m = b[k], l = h.indexOf(m), 0 <= l) { + if (e = 1, 1 < h.length) { + h.splice(l, 1); } else { - e[g] = []; + d[g] = []; break; } } } - f += k.length; + f += h.length; } - if (b) { + if (c) { break; } } - f ? d && a.update(e) : a.delete(); + f ? e && a.update(d) : a.delete(); a.continue(); } -v.remove = function(a) { +w.remove = function(a) { "object" !== typeof a && (a = [a]); - return Promise.all([this.transaction("map", "readwrite", function(c) { - c.openCursor().onsuccess = function() { - const b = this.result; - b && Fb(b, a); + return Promise.all([this.transaction("map", "readwrite", function(b) { + b.openCursor().onsuccess = function() { + const c = this.result; + c && Fb(c, a); }; - }), this.transaction("ctx", "readwrite", function(c) { - c.openCursor().onsuccess = function() { - const b = this.result; - b && Fb(b, a); + }), this.transaction("ctx", "readwrite", function(b) { + b.openCursor().onsuccess = function() { + const c = this.result; + c && Fb(c, a); }; - }), this.transaction("tag", "readwrite", function(c) { - c.openCursor().onsuccess = function() { - const b = this.result; - b && Fb(b, a, !0); + }), this.transaction("tag", "readwrite", function(b) { + b.openCursor().onsuccess = function() { + const c = this.result; + c && Fb(c, a, !0); }; - }), this.transaction("reg", "readwrite", function(c) { - for (let b = 0; b < a.length; b++) { - c.delete(a[b]); + }), this.transaction("reg", "readwrite", function(b) { + for (let c = 0; c < a.length; c++) { + b.delete(a[c]); } })]); }; -function Z(a, c) { - return new Promise((b, e) => { +function Z(a, b) { + return new Promise((c, d) => { a.onsuccess = a.oncomplete = function() { - c && c(this.result); - c = null; - b(this.result); + b && b(this.result); + b = null; + c(this.result); }; - a.onerror = a.onblocked = e; + a.onerror = a.onblocked = d; a = null; }); } -;export default {Index:P, Charset:rb, Encoder:ma, Document:Pa, Worker:Aa, Resolver:Y, IndexedDB:Eb, Language:{}}; +;export default {Index:P, Charset:nb, Encoder:ma, Document:Pa, Worker:Aa, Resolver:Y, IndexedDB:Eb, Language:{}}; -export const Index=P;export const Charset=rb;export const Encoder=ma;export const Document=Pa;export const Worker=Aa;export const Resolver=Y;export const IndexedDB=Eb;export const Language={}; \ No newline at end of file +export const Index=P;export const Charset=nb;export const Encoder=ma;export const Document=Pa;export const Worker=Aa;export const Resolver=Y;export const IndexedDB=Eb;export const Language={}; \ No newline at end of file diff --git a/dist/flexsearch.bundle.module.min.js b/dist/flexsearch.bundle.module.min.js index 909b4ac..8c78ef0 100644 --- a/dist/flexsearch.bundle.module.min.js +++ b/dist/flexsearch.bundle.module.min.js @@ -1,101 +1,102 @@ /**! - * FlexSearch.js v0.8.163 (Bundle/Module) + * FlexSearch.js v0.8.164 (Bundle/Module) * Author and Copyright: Thomas Wilkerling * Licence: Apache-2.0 * Hosted by Nextapps GmbH * https://github.com/nextapps-de/flexsearch */ -var v;function F(a,b,c){const e=typeof c,d=typeof a;if("undefined"!==e){if("undefined"!==d){if(c){if("function"===d&&e===d)return function(k){return a(c(k))};b=a.constructor;if(b===c.constructor){if(b===Array)return c.concat(a);if(b===Map){var f=new Map(c);for(var g of a)f.set(g[0],g[1]);return f}if(b===Set){g=new Set(c);for(f of a.values())g.add(f);return g}}}return a}return c}return"undefined"===d?b:a}function G(){return Object.create(null)}function L(a){return"string"===typeof a} -function ca(a){return"object"===typeof a}function da(a){const b=[];for(const c of a.keys())b.push(c);return b}function ea(a,b){if(L(b))a=a[b];else for(let c=0;a&&c"a1a".split(c).length; -this.numeric=F(a.numeric,e)}else{try{this.split=F(this.split,ha)}catch(d){this.split=/\s+/}this.numeric=F(a.numeric,F(this.numeric,!0))}this.prepare=F(a.prepare,null,this.prepare);this.finalize=F(a.finalize,null,this.finalize);c=a.filter;this.filter="function"===typeof c?c:F(c&&new Set(c),null,this.filter);this.dedupe=F(a.dedupe,!0,this.dedupe);this.matcher=F((c=a.matcher)&&new Map(c),null,this.matcher);this.mapper=F((c=a.mapper)&&new Map(c),null,this.mapper);this.stemmer=F((c=a.stemmer)&&new Map(c), -null,this.stemmer);this.replacer=F(a.replacer,null,this.replacer);this.minlength=F(a.minlength,1,this.minlength);this.maxlength=F(a.maxlength,1024,this.maxlength);this.rtl=F(a.rtl,!1,this.rtl);if(this.cache=c=F(a.cache,!0,this.cache))this.H=null,this.S="number"===typeof c?c:2E5,this.B=new Map,this.G=new Map,this.L=this.K=128;this.h="";this.M=null;this.A="";this.N=null;if(this.matcher)for(const d of this.matcher.keys())this.h+=(this.h?"|":"")+d;if(this.stemmer)for(const d of this.stemmer.keys())this.A+= -(this.A?"|":"")+d;return this};v.addStemmer=function(a,b){this.stemmer||(this.stemmer=new Map);this.stemmer.set(a,b);this.A+=(this.A?"|":"")+a;this.N=null;this.cache&&N(this);return this};v.addFilter=function(a){"function"===typeof a?this.filter=a:(this.filter||(this.filter=new Set),this.filter.add(a));this.cache&&N(this);return this}; +var v;function E(a,b,c){const d=typeof c,e=typeof a;if("undefined"!==d){if("undefined"!==e){if(c){if("function"===e&&d===e)return function(h){return a(c(h))};b=a.constructor;if(b===c.constructor){if(b===Array)return c.concat(a);if(b===Map){var f=new Map(c);for(var g of a)f.set(g[0],g[1]);return f}if(b===Set){g=new Set(c);for(f of a.values())g.add(f);return g}}}return a}return c}return"undefined"===e?b:a}function H(){return Object.create(null)}function M(a){return"string"===typeof a} +function ca(a){return"object"===typeof a}function da(a){const b=[];for(const c of a.keys())b.push(c);return b}function ea(a,b){if(M(b))a=a[b];else for(let c=0;a&&c"a1a".split(c).length; +this.numeric=E(a.numeric,d)}else{try{this.split=E(this.split,ha)}catch(e){this.split=/\s+/}this.numeric=E(a.numeric,E(this.numeric,!0))}this.prepare=E(a.prepare,null,this.prepare);this.finalize=E(a.finalize,null,this.finalize);c=a.filter;this.filter="function"===typeof c?c:E(c&&new Set(c),null,this.filter);this.dedupe=E(a.dedupe,!0,this.dedupe);this.matcher=E((c=a.matcher)&&new Map(c),null,this.matcher);this.mapper=E((c=a.mapper)&&new Map(c),null,this.mapper);this.stemmer=E((c=a.stemmer)&&new Map(c), +null,this.stemmer);this.replacer=E(a.replacer,null,this.replacer);this.minlength=E(a.minlength,1,this.minlength);this.maxlength=E(a.maxlength,1024,this.maxlength);this.rtl=E(a.rtl,!1,this.rtl);if(this.cache=c=E(a.cache,!0,this.cache))this.H=null,this.S="number"===typeof c?c:2E5,this.B=new Map,this.G=new Map,this.L=this.K=128;this.h="";this.M=null;this.A="";this.N=null;if(this.matcher)for(const e of this.matcher.keys())this.h+=(this.h?"|":"")+e;if(this.stemmer)for(const e of this.stemmer.keys())this.A+= +(this.A?"|":"")+e;return this};v.addStemmer=function(a,b){this.stemmer||(this.stemmer=new Map);this.stemmer.set(a,b);this.A+=(this.A?"|":"")+a;this.N=null;this.cache&&N(this);return this};v.addFilter=function(a){"function"===typeof a?this.filter=a:(this.filter||(this.filter=new Set),this.filter.add(a));this.cache&&N(this);return this}; v.addMapper=function(a,b){if("object"===typeof a)return this.addReplacer(a,b);if(1a.length&&(this.dedupe||this.mapper))return this.addMapper(a,b);this.matcher||(this.matcher=new Map);this.matcher.set(a,b);this.h+=(this.h?"|":"")+a;this.M=null;this.cache&&N(this);return this}; v.addReplacer=function(a,b){if("string"===typeof a)return this.addMatcher(a,b);this.replacer||(this.replacer=[]);this.replacer.push(a,b);this.cache&&N(this);return this}; -v.encode=function(a,b){if(this.cache&&a.length<=this.K)if(this.H){if(this.B.has(a))return this.B.get(a)}else this.H=setTimeout(N,50,this);this.normalize&&("function"===typeof this.normalize?a=this.normalize(a):a=la?a.normalize("NFKD").replace(la,"").toLowerCase():a.toLowerCase());this.prepare&&(a=this.prepare(a));this.numeric&&3this.maxlength)){if(b){if(d[m])continue;d[m]=1}else{if(f===m)continue;f=m}if(c)e.push(m);else if(!this.filter||("function"===typeof this.filter?this.filter(m):!this.filter.has(m))){if(this.cache&&m.length<=this.L)if(this.H){var h=this.G.get(m);if(h||""===h){h&&e.push(h);continue}}else this.H=setTimeout(N,50,this);if(this.stemmer){this.N||(this.N=new RegExp("(?!^)("+ -this.A+")$"));let q;for(;q!==m&&2this.stemmer.get(n))}if(m&&(this.mapper||this.dedupe&&1this.matcher.get(q)));if(m&&this.replacer)for(h=0;m&&hthis.S&&(this.G.clear(),this.L=this.L/1.1|0));if(m){if(m!==t)if(b){if(d[m])continue;d[m]=1}else{if(g===m)continue;g=m}e.push(m)}}}this.finalize&&(e=this.finalize(e)||e);this.cache&&a.length<=this.K&&(this.B.set(a,e),this.B.size>this.S&&(this.B.clear(),this.K=this.K/1.1|0));return e};function N(a){a.H=null;a.B.clear();a.G.clear()};let pa,qa;async function ra(a){a=a.data;var b=a.task;const c=a.id;let e=a.args;switch(b){case "init":qa=a.options||{};(b=a.factory)?(Function("return "+b)()(self),pa=new self.FlexSearch.Index(qa),delete self.FlexSearch):pa=new O(qa);postMessage({id:c});break;default:let d;"export"===b&&(e[1]?(e[0]=qa.export,e[2]=0,e[3]=1):e=null);"import"===b?e[0]&&(a=await qa.import.call(pa,e[0]),pa.import(e[0],a)):(d=e&&pa[b].apply(pa,e))&&d.then&&(d=await d);postMessage("search"===b?{id:c,msg:d}:{id:c})}};function sa(a){ta.call(a,"add");ta.call(a,"append");ta.call(a,"search");ta.call(a,"update");ta.call(a,"remove");ta.call(a,"searchCache")}let ua,xa,ya;function za(){ua=ya=0} -function ta(a){this[a+"Async"]=function(){const b=arguments;var c=b[b.length-1];let e;"function"===typeof c&&(e=c,delete b[b.length-1]);ua?ya||(ya=Date.now()-xa>=this.priority*this.priority*3):(ua=setTimeout(za,0),xa=Date.now());if(ya){const f=this;return new Promise(g=>{setTimeout(function(){g(f[a+"Async"].apply(f,b))},0)})}const d=this[a].apply(this,b);c=d.then?d:new Promise(f=>f(d));e&&c.then(e);return c}};let Aa=0; -function Ba(a={}){function b(g){function k(h){h=h.data||h;const l=h.id,m=l&&d.h[l];m&&(m(h.msg),delete d.h[l])}this.worker=g;this.h=G();if(this.worker){e?this.worker.on("message",k):this.worker.onmessage=k;if(a.config)return new Promise(function(h){d.h[++Aa]=function(){h(d);1E9this.maxlength)){if(b){if(e[m])continue;e[m]=1}else{if(f===m)continue;f=m}if(c)d.push(m);else if(!this.filter||("function"===typeof this.filter?this.filter(m):!this.filter.has(m))){if(this.cache&&m.length<=this.L)if(this.H){var k=this.G.get(m);if(k||""===k){k&&d.push(k);continue}}else this.H=setTimeout(N,50,this);if(this.stemmer){this.N||(this.N=new RegExp("(?!^)("+ +this.A+")$"));let u;for(;u!==m&&2this.stemmer.get(r))}if(m&&(this.mapper||this.dedupe&&1this.matcher.get(u)));if(m&&this.replacer)for(k=0;m&&kthis.S&&(this.G.clear(),this.L=this.L/1.1|0));if(m){if(m!==n)if(b){if(e[m])continue;e[m]=1}else{if(g===m)continue;g=m}d.push(m)}}}this.finalize&&(d=this.finalize(d)||d);this.cache&&a.length<=this.K&&(this.B.set(a,d),this.B.size>this.S&&(this.B.clear(),this.K=this.K/1.1|0));return d};function N(a){a.H=null;a.B.clear();a.G.clear()};let pa,qa;async function ra(a){a=a.data;var b=a.task;const c=a.id;let d=a.args;switch(b){case "init":qa=a.options||{};(b=a.factory)?(Function("return "+b)()(self),pa=new self.FlexSearch.Index(qa),delete self.FlexSearch):pa=new O(qa);postMessage({id:c});break;default:let e;"export"===b&&(d[1]?(d[0]=qa.export,d[2]=0,d[3]=1):d=null);"import"===b?d[0]&&(a=await qa.import.call(pa,d[0]),pa.import(d[0],a)):(e=d&&pa[b].apply(pa,d))&&e.then&&(e=await e);postMessage("search"===b?{id:c,msg:e}:{id:c})}};function sa(a){ta.call(a,"add");ta.call(a,"append");ta.call(a,"search");ta.call(a,"update");ta.call(a,"remove");ta.call(a,"searchCache")}let ua,va,ya;function za(){ua=ya=0} +function ta(a){this[a+"Async"]=function(){const b=arguments;var c=b[b.length-1];let d;"function"===typeof c&&(d=c,delete b[b.length-1]);ua?ya||(ya=Date.now()-va>=this.priority*this.priority*3):(ua=setTimeout(za,0),va=Date.now());if(ya){const f=this;return new Promise(g=>{setTimeout(function(){g(f[a+"Async"].apply(f,b))},0)})}const e=this[a].apply(this,b);c=e.then?e:new Promise(f=>f(e));d&&c.then(d);return c}};let Aa=0; +function Ba(a={},b){function c(h){function k(l){l=l.data||l;const m=l.id,n=m&&f.h[m];n&&(n(l.msg),delete f.h[m])}this.worker=h;this.h=H();if(this.worker){e?this.worker.on("message",k):this.worker.onmessage=k;if(a.config)return new Promise(function(l){f.h[++Aa]=function(){l(f);1E9=g.length)b-=g.length;else{b=g[e?"splice":"slice"](b,c);const k=b.length;if(k&&(d=d.length?d.concat(b):b,c-=k,e&&(a.length-=k),!c))break;b=0}return d} -function R(a){if(!this||this.constructor!==R)return new R(a);this.index=a?[a]:[];this.length=a?a.length:0;const b=this;return new Proxy([],{get(c,e){if("length"===e)return b.length;if("push"===e)return function(d){b.index[b.index.length-1].push(d);b.length++};if("pop"===e)return function(){if(b.length)return b.length--,b.index[b.index.length-1].pop()};if("indexOf"===e)return function(d){let f=0;for(let g=0,k,h;gc||e?h.slice(e,c+e):h;else{if(ac||e)h=h.slice(e,c+e)}else{d= -[];for(let t=0,q;te)e-=q.length;else{if(c&&q.length>c||e)q=q.slice(e,c+e),c-=q.length,e&&(e-=q.length);d.push(q);if(!c)break}h=d}}return h} -function Ta(a,b,c,e,d){const f=[],g=G();let k;var h=a.length;let l;if(e)for(d=h-1;0<=d;d--){if(l=(e=a[d])&&e.length)for(h=0;hb?b?a.slice(c,c+b):a.slice(c):a,e?X.call(this,a):a;let d=[];for(let f=0,g,k;f=k){c-=k;continue}cb&&(g=g.slice(0,b),k=b);if(!d.length&&k>=b)return e?X.call(this,g):g;d.push(g);b-=k;if(!b)break}d=1a.length?this.result=a[0]:(this.result=Ta(a,c,e,!1,this.h),e=0));return f?this.resolve(c,e,d):this};Y.prototype.and=function(){let a=this.result.length,b,c,e,d;if(!a){const f=arguments[0];f&&(a=!!f.suggest,d=f.resolve,b=f.limit,c=f.offset,e=f.enrich&&d)}if(a){const {O:f,P:g,limit:k,offset:h,enrich:l,resolve:m,suggest:t}=Wa(this,"and",arguments);return Ya.call(this,f,g,k,h,l,m,t)}return d?this.resolve(b,c,e):this}; -function Ya(a,b,c,e,d,f,g){if(b.length){const k=this;return Promise.all(b).then(function(h){a=[];for(let l=0,m;la.length)this.result=a[0];else{if(b=fa(a))return this.result=Sa(a,b,c,e,g,this.h,f),f?d?X.call(this.index,this.result):this.result:this;this.result=[]}else g||(this.result=a);return f?this.resolve(c,e,d):this};Y.prototype.xor=function(){const {O:a,P:b,limit:c,offset:e,enrich:d,resolve:f,suggest:g}=Wa(this,"xor",arguments);return Za.call(this,a,b,c,e,d,f,g)}; -function Za(a,b,c,e,d,f,g){if(b.length){const k=this;return Promise.all(b).then(function(h){a=[];for(let l=0,m;la.length)this.result=a[0];else return this.result=$a.call(this,a,c,e,f,this.h),f?d?X.call(this.index,this.result):this.result:this;else g||(this.result=a);return f?this.resolve(c,e,d):this} -function $a(a,b,c,e,d){const f=[],g=G();let k=0;for(let h=0,l;hJ&&(J=p.length+(p?1:0)),B=p.length+(p?1:0)+M.length,z+=E,wa.push(x.length),x.push({match:M})),p+=(p?" ":"")+M)}if(!w)D=y[A],p+=(p?" ":"")+D,h&&x.push({text:D});else if(h&&z>=h)break}z=wa.length*(f.length-2);if(n||r||h&&p.length-z>h)if(z=h+z-2*q,A=B-J, -0y&&(y=0)),x=x.length-1){if(I>= -x.length){A[w+1]=1;I>=y.length&&(z[w+1]=1);continue}E-=q}p=x[I].text;if(K=r&&C[w])if(0K)if(A[w+1]=1,l)p=p.substring(0,K);else continue;(K-=p.length)||(K=-1);C[w]=K}else{A[w+1]=1;continue}if(E+p.length+1<=h)p=" "+p,B[w]+=p;else if(l)S=h-E-1,0=I){if(0>I){A[w]=1;z[w]=1;continue}E-=q}p=x[I].text;if(K=n&&D[w])if(0K)if(A[w]=1,l)p=p.substring(p.length- -K);else continue;(K-=p.length)||(K=-1);D[w]=K}else{A[w]=1;continue}if(E+p.length+1<=h)p+=" ",B[w]=p+B[w];else if(l)S=p.length+1-(h-E),0<=S&&S=y.length-1?La=1:Ic||e)a=a.slice(e,e+c);d&&(a=X.call(this,a));return a}}function X(a){if(!this||!this.store)return a;const b=Array(a.length);for(let c=0,e;c=g.length)b-=g.length;else{b=g[d?"splice":"slice"](b,c);const h=b.length;if(h&&(e=e.length?e.concat(b):b,c-=h,d&&(a.length-=h),!c))break;b=0}return e} +function R(a){if(!this||this.constructor!==R)return new R(a);this.index=a?[a]:[];this.length=a?a.length:0;const b=this;return new Proxy([],{get(c,d){if("length"===d)return b.length;if("push"===d)return function(e){b.index[b.index.length-1].push(e);b.length++};if("pop"===d)return function(){if(b.length)return b.length--,b.index[b.index.length-1].pop()};if("indexOf"===d)return function(e){let f=0;for(let g=0,h,k;gb?b?a.slice(c,c+b):a.slice(c):a,d?X.call(this,a):a;let e=[];for(let f=0,g,h;f=h){c-=h;continue}cb&&(g=g.slice(0,b),h=b);if(!e.length&&h>=b)return d?X.call(this,g):g;e.push(g);b-=h;if(!b)break}e=1a.length?this.result=a[0]:(this.result=Va(a,c,d,!1,this.h),d=0));return f?this.resolve(c,d,e):this};Y.prototype.and=function(){let a=this.result.length,b,c,d,e;if(!a){const f=arguments[0];f&&(a=!!f.suggest,e=f.resolve,b=f.limit,c=f.offset,d=f.enrich&&e)}if(a){const {O:f,P:g,limit:h,offset:k,enrich:l,resolve:m,suggest:n}=Ta(this,"and",arguments);return Wa.call(this,f,g,h,k,l,m,n)}return e?this.resolve(b,c,d):this}; +function Wa(a,b,c,d,e,f,g){if(b.length){const h=this;return Promise.all(b).then(function(k){a=[];for(let l=0,m;la.length)this.result=a[0];else{if(b=fa(a))return this.result=Xa(a,b,c,d,g,this.h,f),f?e?X.call(this.index,this.result):this.result:this;this.result=[]}else g||(this.result=a);return f?this.resolve(c,d,e):this};Y.prototype.xor=function(){const {O:a,P:b,limit:c,offset:d,enrich:e,resolve:f,suggest:g}=Ta(this,"xor",arguments);return Ya.call(this,a,b,c,d,e,f,g)}; +function Ya(a,b,c,d,e,f,g){if(b.length){const h=this;return Promise.all(b).then(function(k){a=[];for(let l=0,m;la.length)this.result=a[0];else return this.result=Za.call(this,a,c,d,f,this.h),f?e?X.call(this.index,this.result):this.result:this;else g||(this.result=a);return f?this.resolve(c,d,e):this} +function Za(a,b,c,d,e){const f=[],g=H();let h=0;for(let k=0,l;kD&&(D=t.length+(t?1:0)),G=t.length+(t?1:0)+F.length,B+=C,xa.push(w.length),w.push({match:F})),t+=(t?" ":"")+F)}if(!z)A=y[x],t+=(t?" ":"")+A,k&&w.push({text:A});else if(k&&B>=k)break}B=xa.length*(f.length-2);if(r||p||k&&t.length-B>k)if(B=k+B-2*u,x=G-D, +0y&&(y=0)),w=w.length-1){if(J>= +w.length){x[z+1]=1;J>=y.length&&(B[z+1]=1);continue}C-=u}t=w[J].text;if(K=p&&I[z])if(0K)if(x[z+1]=1,l)t=t.substring(0,K);else continue;(K-=t.length)||(K=-1);I[z]=K}else{x[z+1]=1;continue}if(C+t.length+1<=k)t=" "+t,G[z]+=t;else if(l)T=k-C-1,0=J){if(0>J){x[z]=1;B[z]=1;continue}C-=u}t=w[J].text;if(K=r&&A[z])if(0K)if(x[z]=1,l)t=t.substring(t.length- +K);else continue;(K-=t.length)||(K=-1);A[z]=K}else{x[z]=1;continue}if(C+t.length+1<=k)t+=" ",G[z]=t+G[z];else if(l)T=t.length+1-(k-C),0<=T&&T=y.length-1?Ma=1:Jc||d?k.slice(d,c+d):k;else{if(ac||d)k=k.slice(d,c+d)}else{e= +[];for(let n=0,u;nd)d-=u.length;else{if(c&&u.length>c||d)u=u.slice(d,c+d),c-=u.length,d&&(d-=u.length);e.push(u);if(!c)break}k=e}}return k} +function Va(a,b,c,d,e){const f=[],g=H();let h;var k=a.length;let l;if(d)for(e=k-1;0<=e;e--){if(l=(d=a[e])&&d.length)for(k=0;kc||d)a=a.slice(d,d+c);e&&(a=X.call(this,a));return a}} +function X(a){if(!this||!this.store)return a;const b=Array(a.length);for(let c=0,d;cthis.limit&&this.cache.delete(this.cache.keys().next().value)}; -ib.prototype.get=function(a){const b=this.cache.get(a);b&&this.h!==a&&(this.cache.delete(a),this.cache.set(this.h=a,b));return b};ib.prototype.remove=function(a){for(const b of this.cache){const c=b[0];b[1].includes(a)&&this.cache.delete(c)}};ib.prototype.clear=function(){this.cache.clear();this.h=""};const lb={normalize:!1,numeric:!1,dedupe:!1};const mb={};const nb=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 ob=new Map([["ae","a"],["oe","o"],["sh","s"],["kh","k"],["th","t"],["ph","f"],["pf","f"]]),pb=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/(.)\1+/g,"$1"];const qb={a:"",e:"",i:"",o:"",u:"",y:"",b:1,f:1,p:1,v:1,c:2,g:2,j:2,k:2,q:2,s:2,x:2,z:2,"\u00df":2,d:3,t:3,l:4,m:5,n:5,r:6};var rb={Exact:lb,Default:mb,Normalize:mb,LatinBalance:{mapper:nb},LatinAdvanced:{mapper:nb,matcher:ob,replacer:pb},LatinExtra:{mapper:nb,replacer:pb.concat([/(?!^)[aeo]/g,""]),matcher:ob},LatinSoundex:{dedupe:!1,include:{letter:!0},finalize:function(a){for(let c=0;cd.length)d.pop();else{const f=d.indexOf(a);f===c.length-1?d.pop():d.splice(f,1)}}else sb(this.map,a),this.depth&&sb(this.ctx,a);b||this.reg.delete(a)}this.db&&(this.commit_task.push({del:a}),this.T&&tb(this));this.cache&&this.cache.remove(a);return this}; -function sb(a,b){let c=0;var e="undefined"===typeof b;if(a.constructor===Array)for(let d=0,f,g;du;f--){g=r.substring(u,f);p=this.rtl?d-1-u:u;var k=this.score?this.score(b,r,n,g,p):vb(q, -l,n,d,p);wb(this,t,g,k,a,c)}break}case "bidirectional":case "reverse":if(1g?0:1),l,n,k-1,h-1),p=this.bidirectional&&r>f;wb(this,m,p?f:r,u,a,c,p?r:f)}}}}this.fastupdate||this.reg.add(a)}else b=""}this.db&&(b||this.commit_task.push({del:a}),this.T&&tb(this));return this}; -function wb(a,b,c,e,d,f,g){let k=g?a.ctx:a.map,h;if(!b[c]||g&&!(h=b[c])[g])if(g?(b=h||(b[c]=G()),b[g]=1,(h=k.get(g))?k=h:k.set(g,k=new Map)):b[c]=1,(h=k.get(c))?k=h:k.set(c,k=h=[]),k=k[e]||(k[e]=[]),!f||!k.includes(d)){if(k.length===2**31-1){b=new R(k);if(a.fastupdate)for(let l of a.reg.values())l.includes(k)&&(l[l.indexOf(k)]=b);h[e]=k=b}k.push(d);a.fastupdate&&((e=a.reg.get(d))?e.push(k):a.reg.set(d,[k]))}} -function vb(a,b,c,e,d){return c&&1c)&&(h=c,c=b,b=h);if(a.db)return a.db.get(b,c,e,d,f,g,k);a=c?(a=a.ctx.get(c))&&a.get(b):a.map.get(b);return a};function O(a,b){if(!this||this.constructor!==O)return new O(a);if(a){var c=L(a)?a:a.preset;c&&(a=Object.assign({},ub[c],a))}else a={};c=a.context;const e=!0===c?{depth:1}:c||{},d=L(a.encoder)?rb[a.encoder]:a.encode||a.encoder||{};this.encoder=d.encode?d:"object"===typeof d?new ma(d):{encode:d};this.resolution=a.resolution||9;this.tokenize=c=(c=a.tokenize)&&"default"!==c&&"exact"!==c&&c||"strict";this.depth="strict"===c&&e.depth||0;this.bidirectional=!1!==e.bidirectional;this.fastupdate=!!a.fastupdate; -this.score=a.score||null;(c=a.keystore||0)&&(this.keystore=c);this.map=c?new T(c):new Map;this.ctx=c?new T(c):new Map;this.reg=b||(this.fastupdate?c?new T(c):new Map:c?new U(c):new Set);this.U=e.resolution||3;this.rtl=d.rtl||a.rtl||!1;this.cache=(c=a.cache||null)&&new ib(c);this.resolve=!1!==a.resolve;if(c=a.db)this.db=this.mount(c);this.T=!1!==a.commit;this.commit_task=[];this.commit_timer=null;this.priority=a.priority||4}v=O.prototype; +v.get=function(a){return this.db?this.index.get(this.field[0]).db.enrich(a).then(function(b){return b[0]&&b[0].doc||null}):this.store.get(a)||null};v.set=function(a,b){"object"===typeof a&&(b=a,a=ea(b,this.key));this.store.set(a,b);return this};v.searchCache=rb; +v.export=function(a,b,c=0,d=0){if(cthis.limit&&this.cache.delete(this.cache.keys().next().value)}; +pb.prototype.get=function(a){const b=this.cache.get(a);b&&this.h!==a&&(this.cache.delete(a),this.cache.set(this.h=a,b));return b};pb.prototype.remove=function(a){for(const b of this.cache){const c=b[0];b[1].includes(a)&&this.cache.delete(c)}};pb.prototype.clear=function(){this.cache.clear();this.h=""};O.prototype.remove=function(a,b){const c=this.reg.size&&(this.fastupdate?this.reg.get(a):this.reg.has(a));if(c){if(this.fastupdate)for(let d=0,e;de.length)e.pop();else{const f=e.indexOf(a);f===c.length-1?e.pop():e.splice(f,1)}}else sb(this.map,a),this.depth&&sb(this.ctx,a);b||this.reg.delete(a)}this.db&&(this.commit_task.push({del:a}),this.T&&tb(this));this.cache&&this.cache.remove(a);return this}; +function sb(a,b){let c=0;var d="undefined"===typeof b;if(a.constructor===Array)for(let e=0,f,g;eq;f--){g=p.substring(q,f);t=this.rtl?e-1-q:q;var h=this.score?this.score(b,p,r,g,t):vb(u, +l,r,e,t);wb(this,n,g,h,a,c)}break}case "bidirectional":case "reverse":if(1g?0:1),l,r,h-1,k-1),t=this.bidirectional&&p>f;wb(this,m,t?f:p,q,a,c,t?p:f)}}}}this.fastupdate||this.reg.add(a)}else b=""}this.db&&(b||this.commit_task.push({del:a}),this.T&&tb(this));return this}; +function wb(a,b,c,d,e,f,g){let h=g?a.ctx:a.map,k;if(!b[c]||g&&!(k=b[c])[g])if(g?(b=k||(b[c]=H()),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 R(h);if(a.fastupdate)for(let l of a.reg.values())l.includes(h)&&(l[l.indexOf(h)]=b);k[d]=h=b}h.push(e);a.fastupdate&&((d=a.reg.get(e))?d.push(h):a.reg.set(e,[h]))}} +function vb(a,b,c,d,e){return c&&1c)&&(k=c,c=b,b=k);if(a.db)return a.db.get(b,c,d,e,f,g,h);a=c?(a=a.ctx.get(c))&&a.get(b):a.map.get(b);return a};function O(a,b){if(!this||this.constructor!==O)return new O(a);if(a){var c=M(a)?a:a.preset;c&&(a=Object.assign({},ub[c],a))}else a={};c=a.context;const d=!0===c?{depth:1}:c||{},e=M(a.encoder)?nb[a.encoder]:a.encode||a.encoder||{};this.encoder=e.encode?e:"object"===typeof e?new ma(e):{encode:e};this.resolution=a.resolution||9;this.tokenize=c=(c=a.tokenize)&&"default"!==c&&"exact"!==c&&c||"strict";this.depth="strict"===c&&d.depth||0;this.bidirectional=!1!==d.bidirectional;this.fastupdate=!!a.fastupdate; +this.score=a.score||null;(c=a.keystore||0)&&(this.keystore=c);this.map=c?new U(c):new Map;this.ctx=c?new U(c):new Map;this.reg=b||(this.fastupdate?c?new U(c):new Map:c?new V(c):new Set);this.U=d.resolution||3;this.rtl=e.rtl||a.rtl||!1;this.cache=(c=a.cache||null)&&new pb(c);this.resolve=!1!==a.resolve;if(c=a.db)this.db=this.mount(c);this.T=!1!==a.commit;this.commit_task=[];this.commit_timer=null;this.priority=a.priority||4}v=O.prototype; v.mount=function(a){this.commit_timer&&(clearTimeout(this.commit_timer),this.commit_timer=null);return a.mount(this)};v.commit=function(a,b){this.commit_timer&&(clearTimeout(this.commit_timer),this.commit_timer=null);return this.db.commit(this,a,b)};v.destroy=function(){this.commit_timer&&(clearTimeout(this.commit_timer),this.commit_timer=null);return this.db.destroy()};function tb(a){a.commit_timer||(a.commit_timer=setTimeout(function(){a.commit_timer=null;a.db.commit(a,void 0,void 0)},1))} -v.clear=function(){this.map.clear();this.ctx.clear();this.reg.clear();this.cache&&this.cache.clear();this.db&&(this.commit_timer&&clearTimeout(this.commit_timer),this.commit_timer=null,this.commit_task=[{clear:!0}]);return this};v.append=function(a,b){return this.add(a,b,!0)};v.contain=function(a){return this.db?this.db.has(a):this.reg.has(a)};v.update=function(a,b){const c=this,e=this.remove(a);return e&&e.then?e.then(()=>c.add(a,b)):this.add(a,b)}; -v.cleanup=function(){if(!this.fastupdate)return this;sb(this.map);this.depth&&sb(this.ctx);return this};v.searchCache=kb;v.export=function(a,b,c=0,e=0){let d,f;switch(e){case 0:d="reg";f=Ha(this.reg);break;case 1:d="cfg";f=null;break;case 2:d="map";f=Da(this.map,this.reg.size);break;case 3:d="ctx";f=Fa(this.ctx,this.reg.size);break;default:return}return Ja.call(this,a,b,d,f,c,e)}; +v.clear=function(){this.map.clear();this.ctx.clear();this.reg.clear();this.cache&&this.cache.clear();this.db&&(this.commit_timer&&clearTimeout(this.commit_timer),this.commit_timer=null,this.commit_task=[{clear:!0}]);return this};v.append=function(a,b){return this.add(a,b,!0)};v.contain=function(a){return this.db?this.db.has(a):this.reg.has(a)};v.update=function(a,b){const c=this,d=this.remove(a);return d&&d.then?d.then(()=>c.add(a,b)):this.add(a,b)}; +v.cleanup=function(){if(!this.fastupdate)return this;sb(this.map);this.depth&&sb(this.ctx);return this};v.searchCache=rb;v.export=function(a,b,c=0,d=0){let e,f;switch(d){case 0:e="reg";f=Ha(this.reg);break;case 1:e="cfg";f=null;break;case 2:e="map";f=Da(this.map,this.reg.size);break;case 3:e="ctx";f=Fa(this.ctx,this.reg.size);break;default:return}return Ja.call(this,a,b,e,f,c,d)}; v.import=function(a,b){if(b)switch("string"===typeof b&&(b=JSON.parse(b)),a=a.split("."),"json"===a[a.length-1]&&a.pop(),3===a.length&&a.shift(),a=1=m.length){e-=m.length;continue}const t=c?e+Math.min(m.length-e,c):m.length;for(let q=e;q=f.length)return[];if(!b&&!c)return f;f=f.slice(c,c+b);return e?d.enrich(f):f})}; -v.enrich=function(a){"object"!==typeof a&&(a=[a]);const b=this.db.transaction("reg","readonly").objectStore("reg"),c=[];for(let e=0;e=m.length){d-=m.length;continue}const n=c?d+Math.min(m.length-d,c):m.length;for(let u=d;u=f.length)return[];if(!b&&!c)return f;f=f.slice(c,c+b);return d?e.enrich(f):f})}; +v.enrich=function(a){"object"!==typeof a&&(a=[a]);const b=this.db.transaction("reg","readonly").objectStore("reg"),c=[];for(let d=0;d{a.onsuccess=a.oncomplete=function(){b&&b(this.result);b=null;c(this.result)};a.onerror=a.onblocked=e;a=null})};export default {Index:O,Charset:rb,Encoder:ma,Document:W,Worker:Ba,Resolver:Y,IndexedDB:Eb,Language:{}}; -export const Index=O;export const Charset=rb;export const Encoder=ma;export const Document=W;export const Worker=Ba;export const Resolver=Y;export const IndexedDB=Eb;export const Language={}; \ No newline at end of file +function Z(a,b){return new Promise((c,d)=>{a.onsuccess=a.oncomplete=function(){b&&b(this.result);b=null;c(this.result)};a.onerror=a.onblocked=d;a=null})};export default {Index:O,Charset:nb,Encoder:ma,Document:W,Worker:Ba,Resolver:Y,IndexedDB:Eb,Language:{}}; +export const Index=O;export const Charset=nb;export const Encoder=ma;export const Document=W;export const Worker=Ba;export const Resolver=Y;export const IndexedDB=Eb;export const Language={}; \ No newline at end of file diff --git a/dist/flexsearch.compact.debug.js b/dist/flexsearch.compact.debug.js index a819b32..6779365 100644 --- a/dist/flexsearch.compact.debug.js +++ b/dist/flexsearch.compact.debug.js @@ -1,12 +1,12 @@ /**! - * FlexSearch.js v0.8.163 (Bundle/Debug) + * FlexSearch.js v0.8.164 (Bundle/Debug) * Author and Copyright: Thomas Wilkerling * Licence: Apache-2.0 * Hosted by Nextapps GmbH * https://github.com/nextapps-de/flexsearch */ (function(self){'use strict'; -var A; +var B; function I(a, c, b) { const f = typeof b, d = typeof a; if ("undefined" !== f) { @@ -76,8 +76,8 @@ function S(a = {}) { this.assign(a); } } -A = S.prototype; -A.assign = function(a) { +B = S.prototype; +B.assign = function(a) { this.normalize = I(a.normalize, !0, this.normalize); let c = a.include, b = c || a.exclude || a.split, f; if (b || "" === b) { @@ -141,7 +141,7 @@ A.assign = function(a) { } return this; }; -A.addStemmer = function(a, c) { +B.addStemmer = function(a, c) { this.stemmer || (this.stemmer = new Map()); this.stemmer.set(a, c); this.C += (this.C ? "|" : "") + a; @@ -149,12 +149,12 @@ A.addStemmer = function(a, c) { this.cache && V(this); return this; }; -A.addFilter = function(a) { +B.addFilter = function(a) { "function" === typeof a ? this.filter = a : (this.filter || (this.filter = new Set()), this.filter.add(a)); this.cache && V(this); return this; }; -A.addMapper = function(a, c) { +B.addMapper = function(a, c) { if ("object" === typeof a) { return this.addReplacer(a, c); } @@ -166,7 +166,7 @@ A.addMapper = function(a, c) { this.cache && V(this); return this; }; -A.addMatcher = function(a, c) { +B.addMatcher = function(a, c) { if ("object" === typeof a) { return this.addReplacer(a, c); } @@ -180,7 +180,7 @@ A.addMatcher = function(a, c) { this.cache && V(this); return this; }; -A.addReplacer = function(a, c) { +B.addReplacer = function(a, c) { if ("string" === typeof a) { return this.addMatcher(a, c); } @@ -189,7 +189,7 @@ A.addReplacer = function(a, c) { this.cache && V(this); return this; }; -A.encode = function(a, c) { +B.encode = function(a, c) { if (this.cache && a.length <= this.K) { if (this.H) { if (this.F.has(a)) { @@ -204,8 +204,8 @@ A.encode = function(a, c) { 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 f = [], d = J(), e, g, k = this.split || "" === this.split ? a.split(this.split) : [a]; - for (let m = 0, n, B; m < k.length; m++) { - if ((n = B = k[m]) && !(n.length < this.minlength || n.length > this.maxlength)) { + for (let m = 0, n, z; m < k.length; m++) { + if ((n = z = k[m]) && !(n.length < this.minlength || n.length > this.maxlength)) { if (c) { if (d[n]) { continue; @@ -236,13 +236,13 @@ A.encode = function(a, c) { this.N || (this.N = new RegExp("(?!^)(" + this.C + ")$")); let x; for (; x !== n && 2 < n.length;) { - x = n, n = n.replace(this.N, q => this.stemmer.get(q)); + x = n, n = n.replace(this.N, r => this.stemmer.get(r)); } } if (n && (this.mapper || this.dedupe && 1 < n.length)) { h = ""; - for (let x = 0, q = "", r, w; x < n.length; x++) { - r = n.charAt(x), r === q && this.dedupe || ((w = this.mapper && this.mapper.get(r)) || "" === w ? w === q && this.dedupe || !(q = w) || (h += w) : h += q = r); + for (let x = 0, r = "", p, w; x < n.length; x++) { + p = n.charAt(x), p === r && this.dedupe || ((w = this.mapper && this.mapper.get(p)) || "" === w ? w === r && this.dedupe || !(r = w) || (h += w) : h += r = p); } n = h; } @@ -252,9 +252,9 @@ A.encode = function(a, c) { n = n.replace(this.replacer[h], this.replacer[h + 1]); } } - this.cache && B.length <= this.L && (this.G.set(B, n), this.G.size > this.O && (this.G.clear(), this.L = this.L / 1.1 | 0)); + this.cache && z.length <= this.L && (this.G.set(z, n), this.G.size > this.O && (this.G.clear(), this.L = this.L / 1.1 | 0)); if (n) { - if (n !== B) { + if (n !== z) { if (c) { if (d[n]) { continue; @@ -507,20 +507,7 @@ function za(a, c, b, f, d, e, g, k) { } } } -;function Ba(a, c) { - const b = J(), f = []; - for (let d = 0, e; d < c.length; d++) { - e = c[d]; - for (let g = 0; g < e.length; g++) { - b[e[g]] = 1; - } - } - for (let d = 0, e; d < a.length; d++) { - e = a[d], b[e] && (f.push(e), b[e] = 0); - } - return f; -} -;function Ca(a, c, b) { +;function Ba(a, c, b) { if (!a.length) { return a; } @@ -550,7 +537,7 @@ function za(a, c, b, f, d, e, g, k) { } return f = 1 < f.length ? [].concat.apply([], f) : f[0]; } -;function Da(a, c, b, f, d) { +;function Ca(a, c, b, f, d) { let e, g, k; "string" === typeof d ? (e = d, d = "") : e = d.template; if (!e) { @@ -564,18 +551,18 @@ function za(a, c, b, f, d, e, g, k) { g = e.substring(0, g); let h = d && d.boundary, m = !d || !1 !== d.clip, n = d && d.merge && k && g && new RegExp(k + " " + g, "g"); d = d && d.ellipsis; - var B = 0; + var z = 0; if ("object" === typeof d) { var x = d.template; - B = x.length - 2; + z = x.length - 2; d = d.pattern; } "string" !== typeof d && (d = !1 === d ? "" : "..."); - B && (d = x.replace("$1", d)); - x = d.length - B; - let q, r; - "object" === typeof h && (q = h.before, 0 === q && (q = -1), r = h.after, 0 === r && (r = -1), h = h.total || 9e5); - B = new Map(); + z && (d = x.replace("$1", d)); + x = d.length - z; + let r, p; + "object" === typeof h && (r = h.before, 0 === r && (r = -1), p = h.after, 0 === p && (p = -1), h = h.total || 9e5); + z = new Map(); for (let ua = 0, T, Ja, aa; ua < c.length; ua++) { let ba; if (f) { @@ -590,8 +577,8 @@ function za(a, c, b, f, d, e, g, k) { } Ja = b.get(aa); T = Ja.encoder; - w = B.get(T); - "string" !== typeof w && (w = T.encode(a), B.set(T, w)); + w = z.get(T); + "string" !== typeof w && (w = T.encode(a), z.set(T, w)); for (let ia = 0; ia < ba.length; ia++) { var l = ba[ia].doc; if (!l) { @@ -608,154 +595,154 @@ function za(a, c, b, f, d, e, g, k) { l = ""; var v = []; let ja = []; - var E = -1, t = -1, C = 0; + var D = -1, t = -1, C = 0; for (var y = 0; y < u.length; y++) { - var z = u[y], H = T.encode(z); + var A = u[y], H = T.encode(A); H = 1 < H.length ? H.join(" ") : H[0]; - let p; - if (H && z) { - var D = z.length, M = (T.split ? z.replace(T.split, "") : z).length - H.length, K = "", Q = 0; + let q; + if (H && A) { + var E = A.length, M = (T.split ? A.replace(T.split, "") : A).length - H.length, K = "", Q = 0; for (var U = 0; U < w.length; U++) { var N = w[U]; if (N) { var G = N.length; G += M; - Q && G <= Q || (N = H.indexOf(N), -1 < N && (K = (N ? z.substring(0, N) : "") + g + z.substring(N, N + G) + k + (N + G < D ? z.substring(N + G) : ""), Q = G, p = !0)); + Q && G <= Q || (N = H.indexOf(N), -1 < N && (K = (N ? A.substring(0, N) : "") + g + A.substring(N, N + G) + k + (N + G < E ? A.substring(N + G) : ""), Q = G, q = !0)); } } - K && (h && (0 > E && (E = l.length + (l ? 1 : 0)), t = l.length + (l ? 1 : 0) + K.length, C += D, ja.push(v.length), v.push({match:K})), l += (l ? " " : "") + K); + K && (h && (0 > D && (D = l.length + (l ? 1 : 0)), t = l.length + (l ? 1 : 0) + K.length, C += E, ja.push(v.length), v.push({match:K})), l += (l ? " " : "") + K); } - if (!p) { - z = u[y], l += (l ? " " : "") + z, h && v.push({text:z}); + if (!q) { + A = u[y], l += (l ? " " : "") + A, h && v.push({text:A}); } else if (h && C >= h) { break; } } C = ja.length * (e.length - 2); - if (q || r || h && l.length - C > h) { - if (C = h + C - 2 * x, y = t - E, 0 < q && (y += q), 0 < r && (y += r), y <= C) { - u = q ? E - (0 < q ? q : 0) : E - ((C - y) / 2 | 0), v = r ? t + (0 < r ? r : 0) : u + C, m || (0 < u && " " !== l.charAt(u) && " " !== l.charAt(u - 1) && (u = l.indexOf(" ", u), 0 > u && (u = 0)), v < l.length && " " !== l.charAt(v - 1) && " " !== l.charAt(v) && (v = l.lastIndexOf(" ", v), v < t ? v = t : ++v)), l = (u ? d : "") + l.substring(u, v) + (v < l.length ? d : ""); + if (r || p || h && l.length - C > h) { + if (C = h + C - 2 * x, y = t - D, 0 < r && (y += r), 0 < p && (y += p), y <= C) { + u = r ? D - (0 < r ? r : 0) : D - ((C - y) / 2 | 0), v = p ? t + (0 < p ? p : 0) : u + C, m || (0 < u && " " !== l.charAt(u) && " " !== l.charAt(u - 1) && (u = l.indexOf(" ", u), 0 > u && (u = 0)), v < l.length && " " !== l.charAt(v - 1) && " " !== l.charAt(v) && (v = l.lastIndexOf(" ", v), v < t ? v = t : ++v)), l = (u ? d : "") + l.substring(u, v) + (v < l.length ? d : ""); } else { t = []; - E = {}; + D = {}; C = {}; y = {}; - z = {}; + A = {}; H = {}; - K = M = D = 0; + K = M = E = 0; for (U = Q = 1;;) { var O = void 0; - for (let p = 0, F; p < ja.length; p++) { - F = ja[p]; + for (let q = 0, F; q < ja.length; q++) { + F = ja[q]; if (K) { if (M !== K) { - if (y[p + 1]) { + if (y[q + 1]) { continue; } F += K; - if (E[F]) { - D -= x; - C[p + 1] = 1; - y[p + 1] = 1; + if (D[F]) { + E -= x; + C[q + 1] = 1; + y[q + 1] = 1; continue; } if (F >= v.length - 1) { if (F >= v.length) { - y[p + 1] = 1; - F >= u.length && (C[p + 1] = 1); + y[q + 1] = 1; + F >= u.length && (C[q + 1] = 1); continue; } - D -= x; + E -= x; } l = v[F].text; - if (G = r && H[p]) { + if (G = p && H[q]) { if (0 < G) { if (l.length > G) { - if (y[p + 1] = 1, m) { + if (y[q + 1] = 1, m) { l = l.substring(0, G); } else { continue; } } (G -= l.length) || (G = -1); - H[p] = G; + H[q] = G; } else { - y[p + 1] = 1; + y[q + 1] = 1; continue; } } - if (D + l.length + 1 <= h) { - l = " " + l, t[p] += l; + if (E + l.length + 1 <= h) { + l = " " + l, t[q] += l; } else if (m) { - O = h - D - 1, 0 < O && (l = " " + l.substring(0, O), t[p] += l), y[p + 1] = 1; + O = h - E - 1, 0 < O && (l = " " + l.substring(0, O), t[q] += l), y[q + 1] = 1; } else { - y[p + 1] = 1; + y[q + 1] = 1; continue; } } else { - if (y[p]) { + if (y[q]) { continue; } F -= M; - if (E[F]) { - D -= x; - y[p] = 1; - C[p] = 1; + if (D[F]) { + E -= x; + y[q] = 1; + C[q] = 1; continue; } if (0 >= F) { if (0 > F) { - y[p] = 1; - C[p] = 1; + y[q] = 1; + C[q] = 1; continue; } - D -= x; + E -= x; } l = v[F].text; - if (G = q && z[p]) { + if (G = r && A[q]) { if (0 < G) { if (l.length > G) { - if (y[p] = 1, m) { + if (y[q] = 1, m) { l = l.substring(l.length - G); } else { continue; } } (G -= l.length) || (G = -1); - z[p] = G; + A[q] = G; } else { - y[p] = 1; + y[q] = 1; continue; } } - if (D + l.length + 1 <= h) { - l += " ", t[p] = l + t[p]; + if (E + l.length + 1 <= h) { + l += " ", t[q] = l + t[q]; } else if (m) { - O = l.length + 1 - (h - D), 0 <= O && O < l.length && (l = l.substring(O) + " ", t[p] = l + t[p]), y[p] = 1; + O = l.length + 1 - (h - E), 0 <= O && O < l.length && (l = l.substring(O) + " ", t[q] = l + t[q]), y[q] = 1; } else { - y[p] = 1; + y[q] = 1; continue; } } } else { l = v[F].match; - q && (z[p] = q); - r && (H[p] = r); - p && D++; + r && (A[q] = r); + p && (H[q] = p); + q && E++; let va; - F ? !p && x && (D += x) : (C[p] = 1, y[p] = 1); - F >= u.length - 1 ? va = 1 : F < v.length - 1 && v[F + 1].match ? va = 1 : x && (D += x); - D -= e.length - 2; - if (!p || D + l.length <= h) { - t[p] = l; + F ? !q && x && (E += x) : (C[q] = 1, y[q] = 1); + F >= u.length - 1 ? va = 1 : F < v.length - 1 && v[F + 1].match ? va = 1 : x && (E += x); + E -= e.length - 2; + if (!q || E + l.length <= h) { + t[q] = l; } else { - O = Q = U = C[p] = 0; + O = Q = U = C[q] = 0; break; } - va && (C[p + 1] = 1, y[p + 1] = 1); + va && (C[q + 1] = 1, y[q + 1] = 1); } - D += l.length; - O = E[F] = 1; + E += l.length; + O = D[F] = 1; } if (O) { M === K ? K++ : M++; @@ -768,8 +755,8 @@ function za(a, c, b, f, d, e, g, k) { } } l = ""; - for (let p = 0, F; p < t.length; p++) { - F = (p && C[p] ? " " : (p && !d ? " " : "") + d) + t[p], l += F; + for (let q = 0, F; q < t.length; q++) { + F = (q && C[q] ? " " : (q && !d ? " " : "") + d) + t[q], l += F; } d && !C[t.length] && (l += d); } @@ -783,6 +770,19 @@ function za(a, c, b, f, d, e, g, k) { } return c; } +;function Da(a, c) { + const b = J(), f = []; + for (let d = 0, e; d < c.length; d++) { + e = c[d]; + for (let g = 0; g < e.length; g++) { + b[e[g]] = 1; + } + } + for (let d = 0, e; d < a.length; d++) { + e = a[d], b[e] && (f.push(e), b[e] = 0); + } + return f; +} ;J(); X.prototype.search = function(a, c, b, f) { b || (!c && P(a) ? (b = a, a = "") : P(c) && (b = c, c = 0)); @@ -795,27 +795,27 @@ X.prototype.search = function(a, c, b, f) { let e = []; var g = []; let k, h, m; - let n = 0, B = !0, x; + let n = 0, z = !0, x; if (b) { b.constructor === Array && (b = {index:b}); a = b.query || a; - var q = b.pluck; - var r = b.merge; - h = q || b.field || (h = b.index) && (h.index ? null : h); + var r = b.pluck; + var p = b.merge; + h = r || b.field || (h = b.index) && (h.index ? null : h); m = this.tag && b.tag; k = b.suggest; - B = !0; - this.store && b.highlight && !B ? console.warn("Highlighting results can only be done on a final resolver task or when calling .resolve({ highlight: ... })") : this.store && b.enrich && !B && console.warn("Enrich results can only be done on a final resolver task or when calling .resolve({ enrich: true })"); - x = B && this.store && b.highlight; - d = !!x || B && this.store && b.enrich; + z = !0; + this.store && b.highlight && !z ? console.warn("Highlighting results can only be done on a final resolver task or when calling .resolve({ highlight: ... })") : this.store && b.enrich && !z && console.warn("Enrich results can only be done on a final resolver task or when calling .resolve({ enrich: true })"); + x = z && this.store && b.highlight; + d = !!x || z && this.store && b.enrich; c = b.limit || c; var w = b.offset || 0; - c || (c = 100); + c || (c = z ? 100 : 0); if (m) { m.constructor !== Array && (m = [m]); var l = []; - for (let E = 0, t; E < m.length; E++) { - t = m[E]; + for (let D = 0, t; D < m.length; D++) { + t = m[D]; if (L(t)) { throw Error("A tag option can't be a string, instead it needs a { field: tag } format."); } @@ -830,13 +830,13 @@ X.prototype.search = function(a, c, b, f) { } } else { u = Object.keys(t); - for (let C = 0, y, z; C < u.length; C++) { - if (y = u[C], z = t[y], z.constructor === Array) { - for (v = 0; v < z.length; v++) { - l.push(y, z[v]); + for (let C = 0, y, A; C < u.length; C++) { + if (y = u[C], A = t[y], A.constructor === Array) { + for (v = 0; v < A.length; v++) { + l.push(y, A[v]); } } else { - l.push(y, z); + l.push(y, A); } } } @@ -848,13 +848,13 @@ X.prototype.search = function(a, c, b, f) { if (!a) { g = []; if (l.length) { - for (q = 0; q < l.length; q += 2) { - r = Ea.call(this, l[q], l[q + 1], c, w, d), e.push({field:l[q], tag:l[q + 1], result:r}); + for (r = 0; r < l.length; r += 2) { + p = Ea.call(this, l[r], l[r + 1], c, w, d), e.push(z ? {field:l[r], tag:l[r + 1], result:p} : [p]); } } - return g.length ? Promise.all(g).then(function(E) { - for (let t = 0; t < E.length; t++) { - e[t].result = E[t]; + return g.length ? Promise.all(g).then(function(D) { + for (let t = 0; t < D.length; t++) { + z ? e[t].result = D[t] : e[t] = D[t]; } return e; }) : e; @@ -864,42 +864,42 @@ X.prototype.search = function(a, c, b, f) { } h || (h = this.field); l = !1; - for (let E = 0, t, C, y; E < h.length; E++) { - C = h[E]; - let z; - L(C) || (z = C, C = z.field, a = z.query || a, c = Fa(z.limit, c), w = Fa(z.offset, w), k = Fa(z.suggest, k), x = B && this.store && Fa(z.highlight, x), d = !!x || B && this.store && Fa(z.enrich, d)); + for (let D = 0, t, C, y; D < h.length; D++) { + C = h[D]; + let A; + L(C) || (A = C, C = A.field, a = A.query || a, c = Fa(A.limit, c), w = Fa(A.offset, w), k = Fa(A.suggest, k), x = z && this.store && Fa(A.highlight, x), d = !!x || z && this.store && Fa(A.enrich, d)); if (f) { - t = f[E]; + t = f[D]; } else { - if (u = z || b, v = this.index.get(C), m && (u.enrich = !1), l) { - l[E] = v.search(a, c, u); + if (u = A || b, v = this.index.get(C), m && (u.enrich = !1), l) { + l[D] = v.search(a, c, u); u && d && (u.enrich = d); continue; } else { t = v.search(a, c, u), u && d && (u.enrich = d); } } - y = t && (B ? t.length : t.result.length); + y = t && (z ? t.length : t.result.length); if (m && y) { u = []; v = 0; - for (let H = 0, D, M; H < m.length; H += 2) { - D = this.tag.get(m[H]); - if (!D) { + for (let H = 0, E, M; H < m.length; H += 2) { + E = this.tag.get(m[H]); + if (!E) { if (console.warn("Tag '" + m[H] + ":" + m[H + 1] + "' will be skipped because there is no field '" + m[H] + "'."), k) { continue; } else { return e; } } - if (M = (D = D && D.get(m[H + 1])) && D.length) { - v++, u.push(D); + if (M = (E = E && E.get(m[H + 1])) && E.length) { + v++, u.push(E); } else if (!k) { return e; } } if (v) { - t = Ba(t, u); + t = Da(t, u); y = t.length; if (!y && !k) { return t; @@ -914,27 +914,27 @@ X.prototype.search = function(a, c, b, f) { } } if (l) { - const E = this; + const D = this; return Promise.all(l).then(function(t) { - return t.length ? E.search(a, c, b, t) : t; + return t.length ? D.search(a, c, b, t) : t; }); } if (!n) { return e; } - if (q && (!d || !this.store)) { - return e = e[0], B || (e.index = this), e; + if (r && (!d || !this.store)) { + return e = e[0], z || (e.index = this), e; } l = []; for (w = 0; w < g.length; w++) { f = e[w]; d && f.length && "undefined" === typeof f[0].doc && (f = Ga.call(this, f)); - if (q) { - return x ? Da(a, f, this.index, q, x) : f; + if (r) { + return x ? Ca(a, f, this.index, r, x) : f; } e[w] = {field:g[w], result:f}; } - return r ? Ha(e) : x ? Da(a, e, this.index, q, x) : e; + return p ? Ha(e) : x ? Ca(a, e, this.index, r, x) : e; }; function Fa(a, c) { return "undefined" === typeof a ? c : a; @@ -953,10 +953,10 @@ function Ha(a) { function Ea(a, c, b, f, d) { let e = this.tag.get(a); if (!e) { - return console.warn("Tag '" + a + "' was not found"), []; + return console.warn("Tag-Field '" + a + "' was not found"), []; } if ((a = (e = e && e.get(c)) && e.length - f) && 0 < a) { - if (a > b || f) { + if (b && a > b || f) { e = e.slice(f, f + b); } d && (e = Ga.call(this, e)); @@ -973,7 +973,21 @@ function Ga(a) { } return c; } -;function X(a) { +;const Ia = {normalize:!1, numeric:!1, dedupe:!1}; +const Ka = {}; +const La = 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 Ma = new Map([["ae", "a"], ["oe", "o"], ["sh", "s"], ["kh", "k"], ["th", "t"], ["ph", "f"], ["pf", "f"]]), Na = [/([^aeo])h(.)/g, "$1$2", /([aeo])h([^aeo]|$)/g, "$1$2", /(.)\1+/g, "$1"]; +const Oa = {a:"", e:"", i:"", o:"", u:"", y:"", b:1, f:1, p:1, v:1, c:2, g:2, j:2, k:2, q:2, s:2, x:2, z:2, "\u00df":2, d:3, t:3, l:4, m:5, n:5, r:6}; +var Pa = {Exact:Ia, Default:Ka, Normalize:Ka, LatinBalance:{mapper:La}, LatinAdvanced:{mapper:La, matcher:Ma, replacer:Na}, LatinExtra:{mapper:La, replacer:Na.concat([/(?!^)[aeo]/g, ""]), matcher:Ma}, LatinSoundex:{dedupe:!1, include:{letter:!0}, finalize:function(a) { + for (let b = 0; b < a.length; b++) { + var c = a[b]; + let f = c.charAt(0), d = Oa[f]; + for (let e = 1, g; e < c.length && (g = c.charAt(e), "h" === g || "w" === g || !(g = Oa[g]) || g === d || (f += g, d = g, 4 !== f.length)); e++) { + } + a[b] = f; + } +}}, CJK:{split:""}, LatinExact:Ia, LatinDefault:Ka, LatinSimple:Ka}; +function X(a) { if (!this || this.constructor !== X) { return new X(a); } @@ -982,7 +996,7 @@ function Ga(a) { this.D = []; this.field = []; this.J = []; - this.key = (b = c.key || c.id) && Ia(b, this.J) || "id"; + this.key = (b = c.key || c.id) && Qa(b, this.J) || "id"; this.reg = (this.fastupdate = !!a.fastupdate) ? new Map() : new Set(); this.A = (b = c.store || null) && b && !0 !== b && []; this.store = b && new Map(); @@ -993,13 +1007,13 @@ function Ga(a) { let f = c.index || c.field || c; L(f) && (f = [f]); for (let d = 0, e, g; d < f.length; d++) { - e = f[d], L(e) || (g = e, e = e.field), g = P(g) ? Object.assign({}, a, g) : a, b.set(e, new Z(g, this.reg)), g.custom ? this.D[d] = g.custom : (this.D[d] = Ia(e, this.J), g.filter && ("string" === typeof this.D[d] && (this.D[d] = new String(this.D[d])), this.D[d].I = g.filter)), this.field[d] = e; + e = f[d], L(e) || (g = e, e = e.field), g = P(g) ? Object.assign({}, a, g) : a, b.set(e, new Z(g, this.reg)), g.custom ? this.D[d] = g.custom : (this.D[d] = Qa(e, this.J), g.filter && ("string" === typeof this.D[d] && (this.D[d] = new String(this.D[d])), this.D[d].I = g.filter)), this.field[d] = e; } if (this.A) { a = c.store; L(a) && (a = [a]); for (let d = 0, e, g; d < a.length; d++) { - e = a[d], g = e.field || e, e.custom ? (this.A[d] = e.custom, e.custom.S = g) : (this.A[d] = Ia(g, this.J), e.filter && ("string" === typeof this.A[d] && (this.A[d] = new String(this.A[d])), this.A[d].I = e.filter)); + e = a[d], g = e.field || e, e.custom ? (this.A[d] = e.custom, e.custom.S = g) : (this.A[d] = Qa(g, this.J), e.filter && ("string" === typeof this.A[d] && (this.A[d] = new String(this.A[d])), this.A[d].I = e.filter)); } } this.index = b; @@ -1015,14 +1029,14 @@ function Ga(a) { if (!g) { throw Error("The tag field from the document descriptor is undefined."); } - e.custom ? this.B[d] = e.custom : (this.B[d] = Ia(g, this.J), e.filter && ("string" === typeof this.B[d] && (this.B[d] = new String(this.B[d])), this.B[d].I = e.filter)); + e.custom ? this.B[d] = e.custom : (this.B[d] = Qa(g, this.J), e.filter && ("string" === typeof this.B[d] && (this.B[d] = new String(this.B[d])), this.B[d].I = e.filter)); this.R[d] = g; this.tag.set(g, new Map()); } } } } -function Ia(a, c) { +function Qa(a, c) { const b = a.split(":"); let f = 0; for (let d = 0; d < b.length; d++) { @@ -1031,14 +1045,14 @@ function Ia(a, c) { f < b.length && (b.length = f); return 1 < f ? b : b[0]; } -A = X.prototype; -A.append = function(a, c) { +B = X.prototype; +B.append = function(a, c) { return this.add(a, c, !0); }; -A.update = function(a, c) { +B.update = function(a, c) { return this.remove(a).add(a, c); }; -A.remove = function(a) { +B.remove = function(a) { P(a) && (a = R(a, this.key)); for (var c of this.index.values()) { c.remove(a, !0); @@ -1059,7 +1073,7 @@ A.remove = function(a) { this.cache && this.cache.remove(a); return this; }; -A.clear = function() { +B.clear = function() { const a = []; for (const c of this.index.values()) { const b = c.clear(); @@ -1074,25 +1088,25 @@ A.clear = function() { this.cache && this.cache.clear(); return a.length ? Promise.all(a) : this; }; -A.contain = function(a) { +B.contain = function(a) { return this.reg.has(a); }; -A.cleanup = function() { +B.cleanup = function() { for (const a of this.index.values()) { a.cleanup(); } return this; }; -A.get = function(a) { +B.get = function(a) { return this.store.get(a) || null; }; -A.set = function(a, c) { +B.set = function(a, c) { "object" === typeof a && (c = a, a = R(c, this.key)); this.store.set(a, c); return this; }; -A.searchCache = Ka; -A.export = function(a, c, b = 0, f = 0) { +B.searchCache = Ra; +B.export = function(a, c, b = 0, f = 0) { if (b < this.field.length) { const g = this.field[b]; if ((c = this.index.get(g).export(a, g, b, f = 1)) && c.then) { @@ -1125,7 +1139,7 @@ A.export = function(a, c, b = 0, f = 0) { } return xa.call(this, a, c, d, e, b, f); }; -A.import = function(a, c) { +B.import = function(a, c) { var b = a.split("."); "json" === b[b.length - 1] && b.pop(); a = 2 < b.length ? b[0] : ""; @@ -1152,7 +1166,7 @@ A.import = function(a, c) { } }; ka(X.prototype); -function Ka(a, c, b) { +function Ra(a, c, b) { const f = (c ? "" + a : "object" === typeof a ? "" + a.query : a).toLowerCase(); this.cache || (this.cache = new Y()); let d = this.cache.get(f); @@ -1193,20 +1207,6 @@ Y.prototype.clear = function() { this.cache.clear(); this.h = ""; }; -const La = {normalize:!1, numeric:!1, dedupe:!1}; -const Ma = {}; -const Na = 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 Oa = new Map([["ae", "a"], ["oe", "o"], ["sh", "s"], ["kh", "k"], ["th", "t"], ["ph", "f"], ["pf", "f"]]), Pa = [/([^aeo])h(.)/g, "$1$2", /([aeo])h([^aeo]|$)/g, "$1$2", /(.)\1+/g, "$1"]; -const Qa = {a:"", e:"", i:"", o:"", u:"", y:"", b:1, f:1, p:1, v:1, c:2, g:2, j:2, k:2, q:2, s:2, x:2, z:2, "\u00df":2, d:3, t:3, l:4, m:5, n:5, r:6}; -var Ra = {Exact:La, Default:Ma, Normalize:Ma, LatinBalance:{mapper:Na}, LatinAdvanced:{mapper:Na, matcher:Oa, replacer:Pa}, LatinExtra:{mapper:Na, replacer:Pa.concat([/(?!^)[aeo]/g, ""]), matcher:Oa}, LatinSoundex:{dedupe:!1, include:{letter:!0}, finalize:function(a) { - for (let b = 0; b < a.length; b++) { - var c = a[b]; - let f = c.charAt(0), d = Qa[f]; - for (let e = 1, g; e < c.length && (g = c.charAt(e), "h" === g || "w" === g || !(g = Qa[g]) || g === d || (f += g, d = g, 4 !== f.length)); e++) { - } - a[b] = f; - } -}}, CJK:{split:""}, LatinExact:La, LatinDefault:Ma, LatinSimple:Ma}; Z.prototype.remove = function(a, c) { const b = this.reg.size && (this.fastupdate ? this.reg.get(a) : this.reg.has(a)); if (b) { @@ -1266,21 +1266,21 @@ Z.prototype.add = function(a, c, b, f) { c = this.encoder.encode(c, !f); const m = c.length; if (m) { - const n = J(), B = J(), x = this.resolution; - for (let q = 0; q < m; q++) { - let r = c[this.rtl ? m - 1 - q : q]; - var d = r.length; - if (d && (f || !B[r])) { - var e = this.score ? this.score(c, r, q, null, 0) : Ua(x, m, q), g = ""; + const n = J(), z = J(), x = this.resolution; + for (let r = 0; r < m; r++) { + let p = c[this.rtl ? m - 1 - r : r]; + var d = p.length; + if (d && (f || !z[p])) { + var e = this.score ? this.score(c, p, r, null, 0) : Ua(x, m, r), g = ""; switch(this.tokenize) { case "full": if (2 < d) { for (let w = 0, l; w < d; w++) { for (e = d; e > w; e--) { - g = r.substring(w, e); + g = p.substring(w, e); l = this.rtl ? d - 1 - w : w; - var k = this.score ? this.score(c, r, q, g, l) : Ua(x, m, q, d, l); - Va(this, B, g, k, a, b); + var k = this.score ? this.score(c, p, r, g, l) : Ua(x, m, r, d, l); + Va(this, z, g, k, a, b); } } break; @@ -1289,26 +1289,26 @@ Z.prototype.add = function(a, c, b, f) { case "reverse": if (1 < d) { for (k = d - 1; 0 < k; k--) { - g = r[this.rtl ? d - 1 - k : k] + g; - var h = this.score ? this.score(c, r, q, g, k) : Ua(x, m, q, d, k); - Va(this, B, g, h, a, b); + g = p[this.rtl ? d - 1 - k : k] + g; + var h = this.score ? this.score(c, p, r, g, k) : Ua(x, m, r, d, k); + Va(this, z, g, h, a, b); } g = ""; } case "forward": if (1 < d) { for (k = 0; k < d; k++) { - g += r[this.rtl ? d - 1 - k : k], Va(this, B, g, e, a, b); + g += p[this.rtl ? d - 1 - k : k], Va(this, z, g, e, a, b); } break; } default: - if (Va(this, B, r, e, a, b), f && 1 < m && q < m - 1) { - for (d = J(), g = this.P, e = r, k = Math.min(f + 1, this.rtl ? q + 1 : m - q), d[e] = 1, h = 1; h < k; h++) { - if ((r = c[this.rtl ? m - 1 - q - h : q + h]) && !d[r]) { - d[r] = 1; - const w = this.score ? this.score(c, e, q, r, h - 1) : Ua(g + (m / 2 > g ? 0 : 1), m, q, k - 1, h - 1), l = this.bidirectional && r > e; - Va(this, n, l ? e : r, w, a, b, l ? r : e); + if (Va(this, z, p, e, a, b), f && 1 < m && r < m - 1) { + for (d = J(), g = this.P, e = p, k = Math.min(f + 1, this.rtl ? r + 1 : m - r), d[e] = 1, h = 1; h < k; h++) { + if ((p = c[this.rtl ? m - 1 - r - h : r + h]) && !d[p]) { + d[p] = 1; + const w = this.score ? this.score(c, e, r, p, h - 1) : Ua(g + (m / 2 > g ? 0 : 1), m, r, k - 1, h - 1), l = this.bidirectional && p > e; + Va(this, n, l ? e : p, w, a, b, l ? p : e); } } } @@ -1350,10 +1350,10 @@ function Ua(a, c, b, f, d) { a = b.length; c = c || (k ? 100 : 0); if (1 === a) { - return g = d, (d = Wa(this, b[0], "")) && d.length ? Ca.call(this, d, c, g) : []; + return g = d, (d = Wa(this, b[0], "")) && d.length ? Ba.call(this, d, c, g) : []; } if (2 === a && e && !g) { - return g = d, (d = Wa(this, b[1], b[0])) && d.length ? Ca.call(this, d, c, g) : []; + return g = d, (d = Wa(this, b[1], b[0])) && d.length ? Ba.call(this, d, c, g) : []; } k = J(); var m = 0; @@ -1362,38 +1362,38 @@ function Ua(a, c, b, f, d) { m = 1; } h || 0 === h || (h = n ? this.P : this.resolution); - for (let r, w; m < a; m++) { + for (let p, w; m < a; m++) { if ((w = b[m]) && !k[w]) { k[w] = 1; - r = Wa(this, w, n); + p = Wa(this, w, n); a: { - e = r; - var B = f, x = g, q = h; + e = p; + var z = f, x = g, r = h; let l = []; if (e && e.length) { - if (e.length <= q) { - B.push(e); - r = void 0; + if (e.length <= r) { + z.push(e); + p = void 0; break a; } - for (let u = 0, v; u < q; u++) { + for (let u = 0, v; u < r; u++) { if (v = e[u]) { l[u] = v; } } if (l.length) { - B.push(l); - r = void 0; + z.push(l); + p = void 0; break a; } } - r = x ? void 0 : l; + p = x ? void 0 : l; } - if (r) { - f = r; + if (p) { + f = p; break; } - n && (g && r && f.length || (n = w)); + n && (g && p && f.length || (n = w)); } g && n && m === a - 1 && !f.length && (h = this.resolution, n = "", m = -1, k = J()); } @@ -1407,9 +1407,9 @@ function Ua(a, c, b, f, d) { n = b.length; g = []; a = J(); - for (let r = 0, w, l, u, v; r < h; r++) { + for (let p = 0, w, l, u, v; p < h; p++) { for (m = 0; m < n; m++) { - if (u = b[m], r < u.length && (w = u[r])) { + if (u = b[m], p < u.length && (w = u[p])) { for (e = 0; e < w.length; e++) { if (l = w[e], (k = a[l]) ? a[l]++ : (k = 0, a[l] = 1), v = g[k] || (g[k] = []), v.push(l), c && k === n - 1 && v.length - d === c) { n = d ? v.slice(d) : v; @@ -1459,7 +1459,7 @@ function Ua(a, c, b, f, d) { n = g; } } else if (1 === f) { - c = Ca.call(null, b[0], c, d); + c = Ba.call(null, b[0], c, d); break a; } c = n; @@ -1483,7 +1483,7 @@ function Wa(a, c, b) { a = {}; } b = a.context; - const f = !0 === b ? {depth:1} : b || {}, d = L(a.encoder) ? Ra[a.encoder] : a.encode || a.encoder || {}; + const f = !0 === b ? {depth:1} : b || {}, d = L(a.encoder) ? Pa[a.encoder] : a.encode || a.encoder || {}; this.encoder = d.encode ? d : "object" === typeof d ? new S(d) : {encode:d}; this.resolution = a.resolution || 9; this.tokenize = b = (b = a.tokenize) && "default" !== b && "exact" !== b && b || "strict"; @@ -1501,25 +1501,25 @@ function Wa(a, c, b) { this.cache = (b = a.cache || null) && new Y(b); this.priority = a.priority || 4; } -A = Z.prototype; -A.clear = function() { +B = Z.prototype; +B.clear = function() { this.map.clear(); this.ctx.clear(); this.reg.clear(); this.cache && this.cache.clear(); return this; }; -A.append = function(a, c) { +B.append = function(a, c) { return this.add(a, c, !0); }; -A.contain = function(a) { +B.contain = function(a) { return this.reg.has(a); }; -A.update = function(a, c) { +B.update = function(a, c) { const b = this, f = this.remove(a); return f && f.then ? f.then(() => b.add(a, c)) : this.add(a, c); }; -A.cleanup = function() { +B.cleanup = function() { if (!this.fastupdate) { return console.info('Cleanup the index isn\'t required when not using "fastupdate".'), this; } @@ -1527,8 +1527,8 @@ A.cleanup = function() { this.depth && Sa(this.ctx); return this; }; -A.searchCache = Ka; -A.export = function(a, c, b = 0, f = 0) { +B.searchCache = Ra; +B.export = function(a, c, b = 0, f = 0) { let d, e; switch(f) { case 0: @@ -1552,7 +1552,7 @@ A.export = function(a, c, b = 0, f = 0) { } return xa.call(this, a, c, d, e, b, f); }; -A.import = function(a, c) { +B.import = function(a, c) { if (c) { switch("string" === typeof c && (c = JSON.parse(c)), a = a.split("."), "json" === a[a.length - 1] && a.pop(), 3 === a.length && a.shift(), a = 1 < a.length ? a[1] : a[0], a) { case "reg": @@ -1567,7 +1567,7 @@ A.import = function(a, c) { } } }; -A.serialize = function(a = !0) { +B.serialize = function(a = !0) { let c = "", b = "", f = ""; if (this.reg.size) { let e; @@ -1590,7 +1590,7 @@ A.serialize = function(a = !0) { }; ka(Z.prototype); J(); -const Xa = {Index:Z, Charset:Ra, Encoder:S, Document:X, Worker:null, Resolver:null, IndexedDB:null, Language:{}}, Ya = "undefined" !== typeof self ? self : "undefined" !== typeof global ? global : self; +const Xa = {Index:Z, Charset:Pa, Encoder:S, Document:X, Worker:null, Resolver:null, IndexedDB:null, Language:{}}, Ya = "undefined" !== typeof self ? self : "undefined" !== typeof global ? global : self; let Za; (Za = Ya.define) && Za.amd ? Za([], function() { return Xa; diff --git a/dist/flexsearch.compact.min.js b/dist/flexsearch.compact.min.js index 193bf4a..a1d683b 100644 --- a/dist/flexsearch.compact.min.js +++ b/dist/flexsearch.compact.min.js @@ -1,5 +1,5 @@ /**! - * FlexSearch.js v0.8.163 (Bundle) + * FlexSearch.js v0.8.164 (Bundle) * Author and Copyright: Thomas Wilkerling * Licence: Apache-2.0 * Hosted by Nextapps GmbH @@ -14,44 +14,44 @@ null,this.stemmer);this.replacer=H(a.replacer,null,this.replacer);this.minlength A.addMapper=function(a,c){if("object"===typeof a)return this.addReplacer(a,c);if(1a.length&&(this.dedupe||this.mapper))return this.addMapper(a,c);this.matcher||(this.matcher=new Map);this.matcher.set(a,c);this.h+=(this.h?"|":"")+a;this.M=null;this.cache&&V(this);return this}; A.addReplacer=function(a,c){if("string"===typeof a)return this.addMatcher(a,c);this.replacer||(this.replacer=[]);this.replacer.push(a,c);this.cache&&V(this);return this}; A.encode=function(a,c){if(this.cache&&a.length<=this.K)if(this.H){if(this.F.has(a))return this.F.get(a)}else this.H=setTimeout(V,50,this);this.normalize&&("function"===typeof this.normalize?a=this.normalize(a):a=ha?a.normalize("NFKD").replace(ha,"").toLowerCase():a.toLowerCase());this.prepare&&(a=this.prepare(a));this.numeric&&3this.maxlength)){if(c){if(d[n])continue;d[n]=1}else{if(f===n)continue;f=n}if(b)e.push(n);else if(!this.filter||("function"===typeof this.filter?this.filter(n):!this.filter.has(n))){if(this.cache&&n.length<=this.L)if(this.H){var h=this.G.get(n);if(h||""===h){h&&e.push(h);continue}}else this.H=setTimeout(V,50,this);if(this.stemmer){this.N||(this.N=new RegExp("(?!^)("+ -this.C+")$"));let x;for(;x!==n&&2this.stemmer.get(q))}if(n&&(this.mapper||this.dedupe&&1this.matcher.get(x)));if(n&&this.replacer)for(h=0;n&&hthis.O&&(this.G.clear(),this.L=this.L/1.1|0));if(n){if(n!==C)if(c){if(d[n])continue;d[n]=1}else{if(g===n)continue;g=n}e.push(n)}}}this.finalize&&(e=this.finalize(e)||e);this.cache&&a.length<=this.K&&(this.F.set(a,e),this.F.size>this.O&&(this.F.clear(),this.K=this.K/1.1|0));return e};function V(a){a.H=null;a.F.clear();a.G.clear()};function ka(a){W.call(a,"add");W.call(a,"append");W.call(a,"search");W.call(a,"update");W.call(a,"remove");W.call(a,"searchCache")}let la,ma,na;function oa(){la=na=0} +[],d=I(),f,g,k=this.split||""===this.split?a.split(this.split):[a];for(let m=0,n,B;mthis.maxlength)){if(c){if(d[n])continue;d[n]=1}else{if(f===n)continue;f=n}if(b)e.push(n);else if(!this.filter||("function"===typeof this.filter?this.filter(n):!this.filter.has(n))){if(this.cache&&n.length<=this.L)if(this.H){var h=this.G.get(n);if(h||""===h){h&&e.push(h);continue}}else this.H=setTimeout(V,50,this);if(this.stemmer){this.N||(this.N=new RegExp("(?!^)("+ +this.C+")$"));let x;for(;x!==n&&2this.stemmer.get(r))}if(n&&(this.mapper||this.dedupe&&1this.matcher.get(x)));if(n&&this.replacer)for(h=0;n&&hthis.O&&(this.G.clear(),this.L=this.L/1.1|0));if(n){if(n!==B)if(c){if(d[n])continue;d[n]=1}else{if(g===n)continue;g=n}e.push(n)}}}this.finalize&&(e=this.finalize(e)||e);this.cache&&a.length<=this.K&&(this.F.set(a,e),this.F.size>this.O&&(this.F.clear(),this.K=this.K/1.1|0));return e};function V(a){a.H=null;a.F.clear();a.G.clear()};function ka(a){W.call(a,"add");W.call(a,"append");W.call(a,"search");W.call(a,"update");W.call(a,"remove");W.call(a,"searchCache")}let la,ma,na;function oa(){la=na=0} function W(a){this[a+"Async"]=function(){const c=arguments;var b=c[c.length-1];let e;"function"===typeof b&&(e=b,delete c[c.length-1]);la?na||(na=Date.now()-ma>=this.priority*this.priority*3):(la=setTimeout(oa,0),ma=Date.now());if(na){const f=this;return new Promise(g=>{setTimeout(function(){g(f[a+"Async"].apply(f,c))},0)})}const d=this[a].apply(this,c);b=d.then?d:new Promise(f=>f(d));e&&b.then(e);return b}};function pa(a,c=0){let b=[],e=[];c&&(c=25E4/c*5E3|0);for(const d of a.entries())e.push(d),e.length===c&&(b.push(e),e=[]);e.length&&b.push(e);return b}function qa(a,c){c||(c=new Map);for(let b=0,e;bc?c?a.slice(b,b+c):a.slice(b):a;let e=[];for(let d=0,f,g;d=g){b-=g;continue}bc&&(f=f.slice(0,c),g=c);if(!e.length&&g>=c)return f;e.push(f);c-=g;if(!c)break}return e=1E&&(E=l.length+(l?1:0)),t=l.length+(l?1:0)+K.length,B+=D,ja.push(v.length),v.push({match:K})),l+=(l?" ":"")+K)}if(!p)z=u[y],l+=(l?" ":"")+z,h&&v.push({text:z});else if(h&&B>=h)break}B=ja.length*(f.length-2);if(q||r||h&&l.length-B>h)if(B=h+B-2*x,y=t-E,0u&&(u=0)),v=v.length-1){if(F>=v.length){y[p+1]= -1;F>=u.length&&(B[p+1]=1);continue}D-=x}l=v[F].text;if(G=r&&J[p])if(0G)if(y[p+1]=1,m)l=l.substring(0,G);else continue;(G-=l.length)||(G=-1);J[p]=G}else{y[p+1]=1;continue}if(D+l.length+1<=h)l=" "+l,t[p]+=l;else if(m)O=h-D-1,0=F){if(0>F){y[p]=1;B[p]=1;continue}D-=x}l=v[F].text;if(G=q&&z[p])if(0G)if(y[p]=1,m)l=l.substring(l.length- -G);else continue;(G-=l.length)||(G=-1);z[p]=G}else{y[p]=1;continue}if(D+l.length+1<=h)l+=" ",t[p]=l+t[p];else if(m)O=l.length+1-(h-D),0<=O&&O=u.length-1?va=1:Fb||e)a=a.slice(e,e+b);d&&(a=Ga.call(this,a));return a}}function Ga(a){if(!this||!this.store)return a;const c=Array(a.length);for(let b=0,e;bc?c?a.slice(b,b+c):a.slice(b):a;let e=[];for(let d=0,f,g;d=g){b-=g;continue}bc&&(f=f.slice(0,c),g=c);if(!e.length&&g>=c)return f;e.push(f);c-=g;if(!c)break}return e=1D&&(D=l.length+(l?1:0)),t=l.length+(l?1:0)+K.length,C+=E,ja.push(v.length),v.push({match:K})),l+=(l?" ":"")+K)}if(!q)z=u[y],l+=(l?" ":"")+z,h&&v.push({text:z});else if(h&&C>=h)break}C=ja.length*(f.length-2);if(r||p||h&&l.length-C>h)if(C=h+C-2*x,y=t-D,0u&&(u=0)),v=v.length-1){if(F>=v.length){y[q+1]= +1;F>=u.length&&(C[q+1]=1);continue}E-=x}l=v[F].text;if(G=p&&J[q])if(0G)if(y[q+1]=1,m)l=l.substring(0,G);else continue;(G-=l.length)||(G=-1);J[q]=G}else{y[q+1]=1;continue}if(E+l.length+1<=h)l=" "+l,t[q]+=l;else if(m)O=h-E-1,0=F){if(0>F){y[q]=1;C[q]=1;continue}E-=x}l=v[F].text;if(G=r&&z[q])if(0G)if(y[q]=1,m)l=l.substring(l.length- +G);else continue;(G-=l.length)||(G=-1);z[q]=G}else{y[q]=1;continue}if(E+l.length+1<=h)l+=" ",t[q]=l+t[q];else if(m)O=l.length+1-(h-E),0<=O&&O=u.length-1?va=1:Fb||e)a=a.slice(e,e+b);d&&(a=Ga.call(this,a));return a}}function Ga(a){if(!this||!this.store)return a;const c=Array(a.length);for(let b=0,e;bthis.limit&&this.cache.delete(this.cache.keys().next().value)}; -Y.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};Y.prototype.remove=function(a){for(const c of this.cache){const b=c[0];c[1].includes(a)&&this.cache.delete(b)}};Y.prototype.clear=function(){this.cache.clear();this.h=""};const La={normalize:!1,numeric:!1,dedupe:!1};const Ma={};const Na=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 Oa=new Map([["ae","a"],["oe","o"],["sh","s"],["kh","k"],["th","t"],["ph","f"],["pf","f"]]),Pa=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/(.)\1+/g,"$1"];const Qa={a:"",e:"",i:"",o:"",u:"",y:"",b:1,f:1,p:1,v:1,c:2,g:2,j:2,k:2,q:2,s:2,x:2,z:2,"\u00df":2,d:3,t:3,l:4,m:5,n:5,r:6};var Ra={Exact:La,Default:Ma,Normalize:Ma,LatinBalance:{mapper:Na},LatinAdvanced:{mapper:Na,matcher:Oa,replacer:Pa},LatinExtra:{mapper:Na,replacer:Pa.concat([/(?!^)[aeo]/g,""]),matcher:Oa},LatinSoundex:{dedupe:!1,include:{letter:!0},finalize:function(a){for(let b=0;bd.length)d.pop();else{const f=d.indexOf(a);f===b.length-1?d.pop():d.splice(f,1)}}else Sa(this.map,a),this.depth&&Sa(this.ctx,a);c||this.reg.delete(a)}this.cache&&this.cache.remove(a);return this}; -function Sa(a,c){let b=0;var e="undefined"===typeof c;if(a.constructor===Array)for(let d=0,f,g;dw;f--){g=r.substring(w,f);l=this.rtl?d-1-w:w;var k=this.score?this.score(c,r,q,g,l):Ua(x, -m,q,d,l);Va(this,C,g,k,a,b)}break}case "bidirectional":case "reverse":if(1g?0:1),m,q,k-1,h-1),l=this.bidirectional&&r>f;Va(this,n,l?f:r,w,a,b,l?r:f)}}}}this.fastupdate||this.reg.add(a)}}return this};function Va(a,c,b,e,d,f,g){let k=g?a.ctx:a.map,h;if(!c[b]||g&&!(h=c[b])[g])g?(c=h||(c[b]=I()),c[g]=1,(h=k.get(g))?k=h:k.set(g,k=new Map)):c[b]=1,(h=k.get(b))?k=h:k.set(b,k=[]),k=k[e]||(k[e]=[]),f&&k.includes(d)||(k.push(d),a.fastupdate&&((c=a.reg.get(d))?c.push(k):a.reg.set(d,[k])))} -function Ua(a,c,b,e,d){return b&&1c||d?g.slice(d,c+d):g;g=b}else{if(b< -n){n=[];break b}g=g[b-1];if(c||d)if(g.length>c||d)g=g.slice(d,c+d)}n=g}else if(1===e){c=Ca.call(null,b[0],c,d);break a}c=n}return c};function Wa(a,c,b){let e;b&&(e=a.bidirectional&&c>b)&&(e=b,b=c,c=e);a=b?(a=a.ctx.get(b))&&a.get(c):a.map.get(c);return a};function Z(a,c){if(!this||this.constructor!==Z)return new Z(a);if(a){var b=N(a)?a:a.preset;b&&(a=Object.assign({},Ta[b],a))}else a={};b=a.context;const e=!0===b?{depth:1}:b||{},d=N(a.encoder)?Ra[a.encoder]:a.encode||a.encoder||{};this.encoder=d.encode?d:"object"===typeof d?new S(d):{encode:d};this.resolution=a.resolution||9;this.tokenize=b=(b=a.tokenize)&&"default"!==b&&"exact"!==b&&b||"strict";this.depth="strict"===b&&e.depth||0;this.bidirectional=!1!==e.bidirectional;this.fastupdate=!!a.fastupdate; +A.import=function(a,c){var b=a.split(".");"json"===b[b.length-1]&&b.pop();a=2this.limit&&this.cache.delete(this.cache.keys().next().value)}; +Y.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};Y.prototype.remove=function(a){for(const c of this.cache){const b=c[0];c[1].includes(a)&&this.cache.delete(b)}};Y.prototype.clear=function(){this.cache.clear();this.h=""};Z.prototype.remove=function(a,c){const b=this.reg.size&&(this.fastupdate?this.reg.get(a):this.reg.has(a));if(b){if(this.fastupdate)for(let e=0,d;ed.length)d.pop();else{const f=d.indexOf(a);f===b.length-1?d.pop():d.splice(f,1)}}else Sa(this.map,a),this.depth&&Sa(this.ctx,a);c||this.reg.delete(a)}this.cache&&this.cache.remove(a);return this}; +function Sa(a,c){let b=0;var e="undefined"===typeof c;if(a.constructor===Array)for(let d=0,f,g;dw;f--){g=p.substring(w,f);l=this.rtl?d-1-w:w;var k=this.score?this.score(c,p,r,g,l):Ua(x, +m,r,d,l);Va(this,B,g,k,a,b)}break}case "bidirectional":case "reverse":if(1g?0:1),m,r,k-1,h-1),l=this.bidirectional&&p>f;Va(this,n,l?f:p,w,a,b,l?p:f)}}}}this.fastupdate||this.reg.add(a)}}return this};function Va(a,c,b,e,d,f,g){let k=g?a.ctx:a.map,h;if(!c[b]||g&&!(h=c[b])[g])g?(c=h||(c[b]=I()),c[g]=1,(h=k.get(g))?k=h:k.set(g,k=new Map)):c[b]=1,(h=k.get(b))?k=h:k.set(b,k=[]),k=k[e]||(k[e]=[]),f&&k.includes(d)||(k.push(d),a.fastupdate&&((c=a.reg.get(d))?c.push(k):a.reg.set(d,[k])))} +function Ua(a,c,b,e,d){return b&&1c||d?g.slice(d,c+d):g;g=b}else{if(b< +n){n=[];break b}g=g[b-1];if(c||d)if(g.length>c||d)g=g.slice(d,c+d)}n=g}else if(1===e){c=Ba.call(null,b[0],c,d);break a}c=n}return c};function Wa(a,c,b){let e;b&&(e=a.bidirectional&&c>b)&&(e=b,b=c,c=e);a=b?(a=a.ctx.get(b))&&a.get(c):a.map.get(c);return a};function Z(a,c){if(!this||this.constructor!==Z)return new Z(a);if(a){var b=N(a)?a:a.preset;b&&(a=Object.assign({},Ta[b],a))}else a={};b=a.context;const e=!0===b?{depth:1}:b||{},d=N(a.encoder)?Pa[a.encoder]:a.encode||a.encoder||{};this.encoder=d.encode?d:"object"===typeof d?new S(d):{encode:d};this.resolution=a.resolution||9;this.tokenize=b=(b=a.tokenize)&&"default"!==b&&"exact"!==b&&b||"strict";this.depth="strict"===b&&e.depth||0;this.bidirectional=!1!==e.bidirectional;this.fastupdate=!!a.fastupdate; this.score=a.score||null;b=!1;this.map=new Map;this.ctx=new Map;this.reg=c||(this.fastupdate?new Map:new Set);this.P=e.resolution||3;this.rtl=d.rtl||a.rtl||!1;this.cache=(b=a.cache||null)&&new Y(b);this.priority=a.priority||4}A=Z.prototype;A.clear=function(){this.map.clear();this.ctx.clear();this.reg.clear();this.cache&&this.cache.clear();return this};A.append=function(a,c){return this.add(a,c,!0)};A.contain=function(a){return this.reg.has(a)}; -A.update=function(a,c){const b=this,e=this.remove(a);return e&&e.then?e.then(()=>b.add(a,c)):this.add(a,c)};A.cleanup=function(){if(!this.fastupdate)return this;Sa(this.map);this.depth&&Sa(this.ctx);return this};A.searchCache=Ka;A.export=function(a,c,b=0,e=0){let d,f;switch(e){case 0:d="reg";f=ta(this.reg);break;case 1:d="cfg";f=null;break;case 2:d="map";f=pa(this.map,this.reg.size);break;case 3:d="ctx";f=ra(this.ctx,this.reg.size);break;default:return}return xa.call(this,a,c,d,f,b,e)}; +A.update=function(a,c){const b=this,e=this.remove(a);return e&&e.then?e.then(()=>b.add(a,c)):this.add(a,c)};A.cleanup=function(){if(!this.fastupdate)return this;Sa(this.map);this.depth&&Sa(this.ctx);return this};A.searchCache=Ra;A.export=function(a,c,b=0,e=0){let d,f;switch(e){case 0:d="reg";f=ta(this.reg);break;case 1:d="cfg";f=null;break;case 2:d="map";f=pa(this.map,this.reg.size);break;case 3:d="ctx";f=ra(this.ctx,this.reg.size);break;default:return}return xa.call(this,a,c,d,f,b,e)}; A.import=function(a,c){if(c)switch("string"===typeof c&&(c=JSON.parse(c)),a=a.split("."),"json"===a[a.length-1]&&a.pop(),3===a.length&&a.shift(),a=1 this.maxlength)) { + for (let m = 0, n, z; m < k.length; m++) { + if ((n = z = k[m]) && !(n.length < this.minlength || n.length > this.maxlength)) { if (c) { if (d[n]) { continue; @@ -235,13 +235,13 @@ A.encode = function(a, c) { this.N || (this.N = new RegExp("(?!^)(" + this.C + ")$")); let x; for (; x !== n && 2 < n.length;) { - x = n, n = n.replace(this.N, q => this.stemmer.get(q)); + x = n, n = n.replace(this.N, r => this.stemmer.get(r)); } } if (n && (this.mapper || this.dedupe && 1 < n.length)) { h = ""; - for (let x = 0, q = "", r, w; x < n.length; x++) { - r = n.charAt(x), r === q && this.dedupe || ((w = this.mapper && this.mapper.get(r)) || "" === w ? w === q && this.dedupe || !(q = w) || (h += w) : h += q = r); + for (let x = 0, r = "", p, w; x < n.length; x++) { + p = n.charAt(x), p === r && this.dedupe || ((w = this.mapper && this.mapper.get(p)) || "" === w ? w === r && this.dedupe || !(r = w) || (h += w) : h += r = p); } n = h; } @@ -251,9 +251,9 @@ A.encode = function(a, c) { n = n.replace(this.replacer[h], this.replacer[h + 1]); } } - this.cache && B.length <= this.L && (this.G.set(B, n), this.G.size > this.O && (this.G.clear(), this.L = this.L / 1.1 | 0)); + this.cache && z.length <= this.L && (this.G.set(z, n), this.G.size > this.O && (this.G.clear(), this.L = this.L / 1.1 | 0)); if (n) { - if (n !== B) { + if (n !== z) { if (c) { if (d[n]) { continue; @@ -506,20 +506,7 @@ function za(a, c, b, f, d, e, g, k) { } } } -;function Ba(a, c) { - const b = J(), f = []; - for (let d = 0, e; d < c.length; d++) { - e = c[d]; - for (let g = 0; g < e.length; g++) { - b[e[g]] = 1; - } - } - for (let d = 0, e; d < a.length; d++) { - e = a[d], b[e] && (f.push(e), b[e] = 0); - } - return f; -} -;function Ca(a, c, b) { +;function Ba(a, c, b) { if (!a.length) { return a; } @@ -549,7 +536,7 @@ function za(a, c, b, f, d, e, g, k) { } return f = 1 < f.length ? [].concat.apply([], f) : f[0]; } -;function Da(a, c, b, f, d) { +;function Ca(a, c, b, f, d) { let e, g, k; "string" === typeof d ? (e = d, d = "") : e = d.template; if (!e) { @@ -563,18 +550,18 @@ function za(a, c, b, f, d, e, g, k) { g = e.substring(0, g); let h = d && d.boundary, m = !d || !1 !== d.clip, n = d && d.merge && k && g && new RegExp(k + " " + g, "g"); d = d && d.ellipsis; - var B = 0; + var z = 0; if ("object" === typeof d) { var x = d.template; - B = x.length - 2; + z = x.length - 2; d = d.pattern; } "string" !== typeof d && (d = !1 === d ? "" : "..."); - B && (d = x.replace("$1", d)); - x = d.length - B; - let q, r; - "object" === typeof h && (q = h.before, 0 === q && (q = -1), r = h.after, 0 === r && (r = -1), h = h.total || 9e5); - B = new Map(); + z && (d = x.replace("$1", d)); + x = d.length - z; + let r, p; + "object" === typeof h && (r = h.before, 0 === r && (r = -1), p = h.after, 0 === p && (p = -1), h = h.total || 9e5); + z = new Map(); for (let ta = 0, T, Ga, aa; ta < c.length; ta++) { let ba; if (f) { @@ -589,8 +576,8 @@ function za(a, c, b, f, d, e, g, k) { } Ga = b.get(aa); T = Ga.encoder; - w = B.get(T); - "string" !== typeof w && (w = T.encode(a), B.set(T, w)); + w = z.get(T); + "string" !== typeof w && (w = T.encode(a), z.set(T, w)); for (let ia = 0; ia < ba.length; ia++) { var l = ba[ia].doc; if (!l) { @@ -607,154 +594,154 @@ function za(a, c, b, f, d, e, g, k) { l = ""; var v = []; let ja = []; - var E = -1, t = -1, C = 0; + var D = -1, t = -1, C = 0; for (var y = 0; y < u.length; y++) { - var z = u[y], H = T.encode(z); + var A = u[y], H = T.encode(A); H = 1 < H.length ? H.join(" ") : H[0]; - let p; - if (H && z) { - var D = z.length, M = (T.split ? z.replace(T.split, "") : z).length - H.length, K = "", Q = 0; + let q; + if (H && A) { + var E = A.length, M = (T.split ? A.replace(T.split, "") : A).length - H.length, K = "", Q = 0; for (var U = 0; U < w.length; U++) { var N = w[U]; if (N) { var G = N.length; G += M; - Q && G <= Q || (N = H.indexOf(N), -1 < N && (K = (N ? z.substring(0, N) : "") + g + z.substring(N, N + G) + k + (N + G < D ? z.substring(N + G) : ""), Q = G, p = !0)); + Q && G <= Q || (N = H.indexOf(N), -1 < N && (K = (N ? A.substring(0, N) : "") + g + A.substring(N, N + G) + k + (N + G < E ? A.substring(N + G) : ""), Q = G, q = !0)); } } - K && (h && (0 > E && (E = l.length + (l ? 1 : 0)), t = l.length + (l ? 1 : 0) + K.length, C += D, ja.push(v.length), v.push({match:K})), l += (l ? " " : "") + K); + K && (h && (0 > D && (D = l.length + (l ? 1 : 0)), t = l.length + (l ? 1 : 0) + K.length, C += E, ja.push(v.length), v.push({match:K})), l += (l ? " " : "") + K); } - if (!p) { - z = u[y], l += (l ? " " : "") + z, h && v.push({text:z}); + if (!q) { + A = u[y], l += (l ? " " : "") + A, h && v.push({text:A}); } else if (h && C >= h) { break; } } C = ja.length * (e.length - 2); - if (q || r || h && l.length - C > h) { - if (C = h + C - 2 * x, y = t - E, 0 < q && (y += q), 0 < r && (y += r), y <= C) { - u = q ? E - (0 < q ? q : 0) : E - ((C - y) / 2 | 0), v = r ? t + (0 < r ? r : 0) : u + C, m || (0 < u && " " !== l.charAt(u) && " " !== l.charAt(u - 1) && (u = l.indexOf(" ", u), 0 > u && (u = 0)), v < l.length && " " !== l.charAt(v - 1) && " " !== l.charAt(v) && (v = l.lastIndexOf(" ", v), v < t ? v = t : ++v)), l = (u ? d : "") + l.substring(u, v) + (v < l.length ? d : ""); + if (r || p || h && l.length - C > h) { + if (C = h + C - 2 * x, y = t - D, 0 < r && (y += r), 0 < p && (y += p), y <= C) { + u = r ? D - (0 < r ? r : 0) : D - ((C - y) / 2 | 0), v = p ? t + (0 < p ? p : 0) : u + C, m || (0 < u && " " !== l.charAt(u) && " " !== l.charAt(u - 1) && (u = l.indexOf(" ", u), 0 > u && (u = 0)), v < l.length && " " !== l.charAt(v - 1) && " " !== l.charAt(v) && (v = l.lastIndexOf(" ", v), v < t ? v = t : ++v)), l = (u ? d : "") + l.substring(u, v) + (v < l.length ? d : ""); } else { t = []; - E = {}; + D = {}; C = {}; y = {}; - z = {}; + A = {}; H = {}; - K = M = D = 0; + K = M = E = 0; for (U = Q = 1;;) { var O = void 0; - for (let p = 0, F; p < ja.length; p++) { - F = ja[p]; + for (let q = 0, F; q < ja.length; q++) { + F = ja[q]; if (K) { if (M !== K) { - if (y[p + 1]) { + if (y[q + 1]) { continue; } F += K; - if (E[F]) { - D -= x; - C[p + 1] = 1; - y[p + 1] = 1; + if (D[F]) { + E -= x; + C[q + 1] = 1; + y[q + 1] = 1; continue; } if (F >= v.length - 1) { if (F >= v.length) { - y[p + 1] = 1; - F >= u.length && (C[p + 1] = 1); + y[q + 1] = 1; + F >= u.length && (C[q + 1] = 1); continue; } - D -= x; + E -= x; } l = v[F].text; - if (G = r && H[p]) { + if (G = p && H[q]) { if (0 < G) { if (l.length > G) { - if (y[p + 1] = 1, m) { + if (y[q + 1] = 1, m) { l = l.substring(0, G); } else { continue; } } (G -= l.length) || (G = -1); - H[p] = G; + H[q] = G; } else { - y[p + 1] = 1; + y[q + 1] = 1; continue; } } - if (D + l.length + 1 <= h) { - l = " " + l, t[p] += l; + if (E + l.length + 1 <= h) { + l = " " + l, t[q] += l; } else if (m) { - O = h - D - 1, 0 < O && (l = " " + l.substring(0, O), t[p] += l), y[p + 1] = 1; + O = h - E - 1, 0 < O && (l = " " + l.substring(0, O), t[q] += l), y[q + 1] = 1; } else { - y[p + 1] = 1; + y[q + 1] = 1; continue; } } else { - if (y[p]) { + if (y[q]) { continue; } F -= M; - if (E[F]) { - D -= x; - y[p] = 1; - C[p] = 1; + if (D[F]) { + E -= x; + y[q] = 1; + C[q] = 1; continue; } if (0 >= F) { if (0 > F) { - y[p] = 1; - C[p] = 1; + y[q] = 1; + C[q] = 1; continue; } - D -= x; + E -= x; } l = v[F].text; - if (G = q && z[p]) { + if (G = r && A[q]) { if (0 < G) { if (l.length > G) { - if (y[p] = 1, m) { + if (y[q] = 1, m) { l = l.substring(l.length - G); } else { continue; } } (G -= l.length) || (G = -1); - z[p] = G; + A[q] = G; } else { - y[p] = 1; + y[q] = 1; continue; } } - if (D + l.length + 1 <= h) { - l += " ", t[p] = l + t[p]; + if (E + l.length + 1 <= h) { + l += " ", t[q] = l + t[q]; } else if (m) { - O = l.length + 1 - (h - D), 0 <= O && O < l.length && (l = l.substring(O) + " ", t[p] = l + t[p]), y[p] = 1; + O = l.length + 1 - (h - E), 0 <= O && O < l.length && (l = l.substring(O) + " ", t[q] = l + t[q]), y[q] = 1; } else { - y[p] = 1; + y[q] = 1; continue; } } } else { l = v[F].match; - q && (z[p] = q); - r && (H[p] = r); - p && D++; + r && (A[q] = r); + p && (H[q] = p); + q && E++; let ua; - F ? !p && x && (D += x) : (C[p] = 1, y[p] = 1); - F >= u.length - 1 ? ua = 1 : F < v.length - 1 && v[F + 1].match ? ua = 1 : x && (D += x); - D -= e.length - 2; - if (!p || D + l.length <= h) { - t[p] = l; + F ? !q && x && (E += x) : (C[q] = 1, y[q] = 1); + F >= u.length - 1 ? ua = 1 : F < v.length - 1 && v[F + 1].match ? ua = 1 : x && (E += x); + E -= e.length - 2; + if (!q || E + l.length <= h) { + t[q] = l; } else { - O = Q = U = C[p] = 0; + O = Q = U = C[q] = 0; break; } - ua && (C[p + 1] = 1, y[p + 1] = 1); + ua && (C[q + 1] = 1, y[q + 1] = 1); } - D += l.length; - O = E[F] = 1; + E += l.length; + O = D[F] = 1; } if (O) { M === K ? K++ : M++; @@ -767,8 +754,8 @@ function za(a, c, b, f, d, e, g, k) { } } l = ""; - for (let p = 0, F; p < t.length; p++) { - F = (p && C[p] ? " " : (p && !d ? " " : "") + d) + t[p], l += F; + for (let q = 0, F; q < t.length; q++) { + F = (q && C[q] ? " " : (q && !d ? " " : "") + d) + t[q], l += F; } d && !C[t.length] && (l += d); } @@ -782,6 +769,19 @@ function za(a, c, b, f, d, e, g, k) { } return c; } +;function Da(a, c) { + const b = J(), f = []; + for (let d = 0, e; d < c.length; d++) { + e = c[d]; + for (let g = 0; g < e.length; g++) { + b[e[g]] = 1; + } + } + for (let d = 0, e; d < a.length; d++) { + e = a[d], b[e] && (f.push(e), b[e] = 0); + } + return f; +} ;J(); X.prototype.search = function(a, c, b, f) { b || (!c && P(a) ? (b = a, a = "") : P(c) && (b = c, c = 0)); @@ -794,27 +794,27 @@ X.prototype.search = function(a, c, b, f) { let e = []; var g = []; let k, h, m; - let n = 0, B = !0, x; + let n = 0, z = !0, x; if (b) { b.constructor === Array && (b = {index:b}); a = b.query || a; - var q = b.pluck; - var r = b.merge; - h = q || b.field || (h = b.index) && (h.index ? null : h); + var r = b.pluck; + var p = b.merge; + h = r || b.field || (h = b.index) && (h.index ? null : h); m = this.tag && b.tag; k = b.suggest; - B = !0; - this.store && b.highlight && !B ? console.warn("Highlighting results can only be done on a final resolver task or when calling .resolve({ highlight: ... })") : this.store && b.enrich && !B && console.warn("Enrich results can only be done on a final resolver task or when calling .resolve({ enrich: true })"); - x = B && this.store && b.highlight; - d = !!x || B && this.store && b.enrich; + z = !0; + this.store && b.highlight && !z ? console.warn("Highlighting results can only be done on a final resolver task or when calling .resolve({ highlight: ... })") : this.store && b.enrich && !z && console.warn("Enrich results can only be done on a final resolver task or when calling .resolve({ enrich: true })"); + x = z && this.store && b.highlight; + d = !!x || z && this.store && b.enrich; c = b.limit || c; var w = b.offset || 0; - c || (c = 100); + c || (c = z ? 100 : 0); if (m) { m.constructor !== Array && (m = [m]); var l = []; - for (let E = 0, t; E < m.length; E++) { - t = m[E]; + for (let D = 0, t; D < m.length; D++) { + t = m[D]; if (L(t)) { throw Error("A tag option can't be a string, instead it needs a { field: tag } format."); } @@ -829,13 +829,13 @@ X.prototype.search = function(a, c, b, f) { } } else { u = Object.keys(t); - for (let C = 0, y, z; C < u.length; C++) { - if (y = u[C], z = t[y], z.constructor === Array) { - for (v = 0; v < z.length; v++) { - l.push(y, z[v]); + for (let C = 0, y, A; C < u.length; C++) { + if (y = u[C], A = t[y], A.constructor === Array) { + for (v = 0; v < A.length; v++) { + l.push(y, A[v]); } } else { - l.push(y, z); + l.push(y, A); } } } @@ -847,13 +847,13 @@ X.prototype.search = function(a, c, b, f) { if (!a) { g = []; if (l.length) { - for (q = 0; q < l.length; q += 2) { - r = Ea.call(this, l[q], l[q + 1], c, w, d), e.push({field:l[q], tag:l[q + 1], result:r}); + for (r = 0; r < l.length; r += 2) { + p = Ea.call(this, l[r], l[r + 1], c, w, d), e.push(z ? {field:l[r], tag:l[r + 1], result:p} : [p]); } } - return g.length ? Promise.all(g).then(function(E) { - for (let t = 0; t < E.length; t++) { - e[t].result = E[t]; + return g.length ? Promise.all(g).then(function(D) { + for (let t = 0; t < D.length; t++) { + z ? e[t].result = D[t] : e[t] = D[t]; } return e; }) : e; @@ -863,42 +863,42 @@ X.prototype.search = function(a, c, b, f) { } h || (h = this.field); l = !1; - for (let E = 0, t, C, y; E < h.length; E++) { - C = h[E]; - let z; - L(C) || (z = C, C = z.field, a = z.query || a, c = Fa(z.limit, c), w = Fa(z.offset, w), k = Fa(z.suggest, k), x = B && this.store && Fa(z.highlight, x), d = !!x || B && this.store && Fa(z.enrich, d)); + for (let D = 0, t, C, y; D < h.length; D++) { + C = h[D]; + let A; + L(C) || (A = C, C = A.field, a = A.query || a, c = Fa(A.limit, c), w = Fa(A.offset, w), k = Fa(A.suggest, k), x = z && this.store && Fa(A.highlight, x), d = !!x || z && this.store && Fa(A.enrich, d)); if (f) { - t = f[E]; + t = f[D]; } else { - if (u = z || b, v = this.index.get(C), m && (u.enrich = !1), l) { - l[E] = v.search(a, c, u); + if (u = A || b, v = this.index.get(C), m && (u.enrich = !1), l) { + l[D] = v.search(a, c, u); u && d && (u.enrich = d); continue; } else { t = v.search(a, c, u), u && d && (u.enrich = d); } } - y = t && (B ? t.length : t.result.length); + y = t && (z ? t.length : t.result.length); if (m && y) { u = []; v = 0; - for (let H = 0, D, M; H < m.length; H += 2) { - D = this.tag.get(m[H]); - if (!D) { + for (let H = 0, E, M; H < m.length; H += 2) { + E = this.tag.get(m[H]); + if (!E) { if (console.warn("Tag '" + m[H] + ":" + m[H + 1] + "' will be skipped because there is no field '" + m[H] + "'."), k) { continue; } else { return e; } } - if (M = (D = D && D.get(m[H + 1])) && D.length) { - v++, u.push(D); + if (M = (E = E && E.get(m[H + 1])) && E.length) { + v++, u.push(E); } else if (!k) { return e; } } if (v) { - t = Ba(t, u); + t = Da(t, u); y = t.length; if (!y && !k) { return t; @@ -913,27 +913,27 @@ X.prototype.search = function(a, c, b, f) { } } if (l) { - const E = this; + const D = this; return Promise.all(l).then(function(t) { - return t.length ? E.search(a, c, b, t) : t; + return t.length ? D.search(a, c, b, t) : t; }); } if (!n) { return e; } - if (q && (!d || !this.store)) { - return e = e[0], B || (e.index = this), e; + if (r && (!d || !this.store)) { + return e = e[0], z || (e.index = this), e; } l = []; for (w = 0; w < g.length; w++) { f = e[w]; d && f.length && "undefined" === typeof f[0].doc && (f = Ha.call(this, f)); - if (q) { - return x ? Da(a, f, this.index, q, x) : f; + if (r) { + return x ? Ca(a, f, this.index, r, x) : f; } e[w] = {field:g[w], result:f}; } - return r ? Ia(e) : x ? Da(a, e, this.index, q, x) : e; + return p ? Ia(e) : x ? Ca(a, e, this.index, r, x) : e; }; function Fa(a, c) { return "undefined" === typeof a ? c : a; @@ -952,10 +952,10 @@ function Ia(a) { function Ea(a, c, b, f, d) { let e = this.tag.get(a); if (!e) { - return console.warn("Tag '" + a + "' was not found"), []; + return console.warn("Tag-Field '" + a + "' was not found"), []; } if ((a = (e = e && e.get(c)) && e.length - f) && 0 < a) { - if (a > b || f) { + if (b && a > b || f) { e = e.slice(f, f + b); } d && (e = Ha.call(this, e)); @@ -972,7 +972,21 @@ function Ha(a) { } return c; } -;function X(a) { +;const Ja = {normalize:!1, numeric:!1, dedupe:!1}; +const Ka = {}; +const La = 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 Ma = new Map([["ae", "a"], ["oe", "o"], ["sh", "s"], ["kh", "k"], ["th", "t"], ["ph", "f"], ["pf", "f"]]), Na = [/([^aeo])h(.)/g, "$1$2", /([aeo])h([^aeo]|$)/g, "$1$2", /(.)\1+/g, "$1"]; +const Oa = {a:"", e:"", i:"", o:"", u:"", y:"", b:1, f:1, p:1, v:1, c:2, g:2, j:2, k:2, q:2, s:2, x:2, z:2, "\u00df":2, d:3, t:3, l:4, m:5, n:5, r:6}; +var Pa = {Exact:Ja, Default:Ka, Normalize:Ka, LatinBalance:{mapper:La}, LatinAdvanced:{mapper:La, matcher:Ma, replacer:Na}, LatinExtra:{mapper:La, replacer:Na.concat([/(?!^)[aeo]/g, ""]), matcher:Ma}, LatinSoundex:{dedupe:!1, include:{letter:!0}, finalize:function(a) { + for (let b = 0; b < a.length; b++) { + var c = a[b]; + let f = c.charAt(0), d = Oa[f]; + for (let e = 1, g; e < c.length && (g = c.charAt(e), "h" === g || "w" === g || !(g = Oa[g]) || g === d || (f += g, d = g, 4 !== f.length)); e++) { + } + a[b] = f; + } +}}, CJK:{split:""}, LatinExact:Ja, LatinDefault:Ka, LatinSimple:Ka}; +function X(a) { if (!this || this.constructor !== X) { return new X(a); } @@ -981,7 +995,7 @@ function Ha(a) { this.D = []; this.field = []; this.J = []; - this.key = (b = c.key || c.id) && Ja(b, this.J) || "id"; + this.key = (b = c.key || c.id) && Qa(b, this.J) || "id"; this.reg = (this.fastupdate = !!a.fastupdate) ? new Map() : new Set(); this.A = (b = c.store || null) && b && !0 !== b && []; this.store = b && new Map(); @@ -992,13 +1006,13 @@ function Ha(a) { let f = c.index || c.field || c; L(f) && (f = [f]); for (let d = 0, e, g; d < f.length; d++) { - e = f[d], L(e) || (g = e, e = e.field), g = P(g) ? Object.assign({}, a, g) : a, b.set(e, new Z(g, this.reg)), g.custom ? this.D[d] = g.custom : (this.D[d] = Ja(e, this.J), g.filter && ("string" === typeof this.D[d] && (this.D[d] = new String(this.D[d])), this.D[d].I = g.filter)), this.field[d] = e; + e = f[d], L(e) || (g = e, e = e.field), g = P(g) ? Object.assign({}, a, g) : a, b.set(e, new Z(g, this.reg)), g.custom ? this.D[d] = g.custom : (this.D[d] = Qa(e, this.J), g.filter && ("string" === typeof this.D[d] && (this.D[d] = new String(this.D[d])), this.D[d].I = g.filter)), this.field[d] = e; } if (this.A) { a = c.store; L(a) && (a = [a]); for (let d = 0, e, g; d < a.length; d++) { - e = a[d], g = e.field || e, e.custom ? (this.A[d] = e.custom, e.custom.S = g) : (this.A[d] = Ja(g, this.J), e.filter && ("string" === typeof this.A[d] && (this.A[d] = new String(this.A[d])), this.A[d].I = e.filter)); + e = a[d], g = e.field || e, e.custom ? (this.A[d] = e.custom, e.custom.S = g) : (this.A[d] = Qa(g, this.J), e.filter && ("string" === typeof this.A[d] && (this.A[d] = new String(this.A[d])), this.A[d].I = e.filter)); } } this.index = b; @@ -1014,14 +1028,14 @@ function Ha(a) { if (!g) { throw Error("The tag field from the document descriptor is undefined."); } - e.custom ? this.B[d] = e.custom : (this.B[d] = Ja(g, this.J), e.filter && ("string" === typeof this.B[d] && (this.B[d] = new String(this.B[d])), this.B[d].I = e.filter)); + e.custom ? this.B[d] = e.custom : (this.B[d] = Qa(g, this.J), e.filter && ("string" === typeof this.B[d] && (this.B[d] = new String(this.B[d])), this.B[d].I = e.filter)); this.R[d] = g; this.tag.set(g, new Map()); } } } } -function Ja(a, c) { +function Qa(a, c) { const b = a.split(":"); let f = 0; for (let d = 0; d < b.length; d++) { @@ -1030,14 +1044,14 @@ function Ja(a, c) { f < b.length && (b.length = f); return 1 < f ? b : b[0]; } -A = X.prototype; -A.append = function(a, c) { +B = X.prototype; +B.append = function(a, c) { return this.add(a, c, !0); }; -A.update = function(a, c) { +B.update = function(a, c) { return this.remove(a).add(a, c); }; -A.remove = function(a) { +B.remove = function(a) { P(a) && (a = R(a, this.key)); for (var c of this.index.values()) { c.remove(a, !0); @@ -1058,7 +1072,7 @@ A.remove = function(a) { this.cache && this.cache.remove(a); return this; }; -A.clear = function() { +B.clear = function() { const a = []; for (const c of this.index.values()) { const b = c.clear(); @@ -1073,25 +1087,25 @@ A.clear = function() { this.cache && this.cache.clear(); return a.length ? Promise.all(a) : this; }; -A.contain = function(a) { +B.contain = function(a) { return this.reg.has(a); }; -A.cleanup = function() { +B.cleanup = function() { for (const a of this.index.values()) { a.cleanup(); } return this; }; -A.get = function(a) { +B.get = function(a) { return this.store.get(a) || null; }; -A.set = function(a, c) { +B.set = function(a, c) { "object" === typeof a && (c = a, a = R(c, this.key)); this.store.set(a, c); return this; }; -A.searchCache = Ka; -A.export = function(a, c, b = 0, f = 0) { +B.searchCache = Ra; +B.export = function(a, c, b = 0, f = 0) { if (b < this.field.length) { const g = this.field[b]; if ((c = this.index.get(g).export(a, g, b, f = 1)) && c.then) { @@ -1124,7 +1138,7 @@ A.export = function(a, c, b = 0, f = 0) { } return xa.call(this, a, c, d, e, b, f); }; -A.import = function(a, c) { +B.import = function(a, c) { var b = a.split("."); "json" === b[b.length - 1] && b.pop(); a = 2 < b.length ? b[0] : ""; @@ -1151,7 +1165,7 @@ A.import = function(a, c) { } }; ka(X.prototype); -function Ka(a, c, b) { +function Ra(a, c, b) { const f = (c ? "" + a : "object" === typeof a ? "" + a.query : a).toLowerCase(); this.cache || (this.cache = new Y()); let d = this.cache.get(f); @@ -1192,20 +1206,6 @@ Y.prototype.clear = function() { this.cache.clear(); this.h = ""; }; -const La = {normalize:!1, numeric:!1, dedupe:!1}; -const Ma = {}; -const Na = 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 Oa = new Map([["ae", "a"], ["oe", "o"], ["sh", "s"], ["kh", "k"], ["th", "t"], ["ph", "f"], ["pf", "f"]]), Pa = [/([^aeo])h(.)/g, "$1$2", /([aeo])h([^aeo]|$)/g, "$1$2", /(.)\1+/g, "$1"]; -const Qa = {a:"", e:"", i:"", o:"", u:"", y:"", b:1, f:1, p:1, v:1, c:2, g:2, j:2, k:2, q:2, s:2, x:2, z:2, "\u00df":2, d:3, t:3, l:4, m:5, n:5, r:6}; -var Ra = {Exact:La, Default:Ma, Normalize:Ma, LatinBalance:{mapper:Na}, LatinAdvanced:{mapper:Na, matcher:Oa, replacer:Pa}, LatinExtra:{mapper:Na, replacer:Pa.concat([/(?!^)[aeo]/g, ""]), matcher:Oa}, LatinSoundex:{dedupe:!1, include:{letter:!0}, finalize:function(a) { - for (let b = 0; b < a.length; b++) { - var c = a[b]; - let f = c.charAt(0), d = Qa[f]; - for (let e = 1, g; e < c.length && (g = c.charAt(e), "h" === g || "w" === g || !(g = Qa[g]) || g === d || (f += g, d = g, 4 !== f.length)); e++) { - } - a[b] = f; - } -}}, CJK:{split:""}, LatinExact:La, LatinDefault:Ma, LatinSimple:Ma}; Z.prototype.remove = function(a, c) { const b = this.reg.size && (this.fastupdate ? this.reg.get(a) : this.reg.has(a)); if (b) { @@ -1265,21 +1265,21 @@ Z.prototype.add = function(a, c, b, f) { c = this.encoder.encode(c, !f); const m = c.length; if (m) { - const n = J(), B = J(), x = this.resolution; - for (let q = 0; q < m; q++) { - let r = c[this.rtl ? m - 1 - q : q]; - var d = r.length; - if (d && (f || !B[r])) { - var e = this.score ? this.score(c, r, q, null, 0) : Ua(x, m, q), g = ""; + const n = J(), z = J(), x = this.resolution; + for (let r = 0; r < m; r++) { + let p = c[this.rtl ? m - 1 - r : r]; + var d = p.length; + if (d && (f || !z[p])) { + var e = this.score ? this.score(c, p, r, null, 0) : Ua(x, m, r), g = ""; switch(this.tokenize) { case "full": if (2 < d) { for (let w = 0, l; w < d; w++) { for (e = d; e > w; e--) { - g = r.substring(w, e); + g = p.substring(w, e); l = this.rtl ? d - 1 - w : w; - var k = this.score ? this.score(c, r, q, g, l) : Ua(x, m, q, d, l); - Va(this, B, g, k, a, b); + var k = this.score ? this.score(c, p, r, g, l) : Ua(x, m, r, d, l); + Va(this, z, g, k, a, b); } } break; @@ -1288,26 +1288,26 @@ Z.prototype.add = function(a, c, b, f) { case "reverse": if (1 < d) { for (k = d - 1; 0 < k; k--) { - g = r[this.rtl ? d - 1 - k : k] + g; - var h = this.score ? this.score(c, r, q, g, k) : Ua(x, m, q, d, k); - Va(this, B, g, h, a, b); + g = p[this.rtl ? d - 1 - k : k] + g; + var h = this.score ? this.score(c, p, r, g, k) : Ua(x, m, r, d, k); + Va(this, z, g, h, a, b); } g = ""; } case "forward": if (1 < d) { for (k = 0; k < d; k++) { - g += r[this.rtl ? d - 1 - k : k], Va(this, B, g, e, a, b); + g += p[this.rtl ? d - 1 - k : k], Va(this, z, g, e, a, b); } break; } default: - if (Va(this, B, r, e, a, b), f && 1 < m && q < m - 1) { - for (d = J(), g = this.P, e = r, k = Math.min(f + 1, this.rtl ? q + 1 : m - q), d[e] = 1, h = 1; h < k; h++) { - if ((r = c[this.rtl ? m - 1 - q - h : q + h]) && !d[r]) { - d[r] = 1; - const w = this.score ? this.score(c, e, q, r, h - 1) : Ua(g + (m / 2 > g ? 0 : 1), m, q, k - 1, h - 1), l = this.bidirectional && r > e; - Va(this, n, l ? e : r, w, a, b, l ? r : e); + if (Va(this, z, p, e, a, b), f && 1 < m && r < m - 1) { + for (d = J(), g = this.P, e = p, k = Math.min(f + 1, this.rtl ? r + 1 : m - r), d[e] = 1, h = 1; h < k; h++) { + if ((p = c[this.rtl ? m - 1 - r - h : r + h]) && !d[p]) { + d[p] = 1; + const w = this.score ? this.score(c, e, r, p, h - 1) : Ua(g + (m / 2 > g ? 0 : 1), m, r, k - 1, h - 1), l = this.bidirectional && p > e; + Va(this, n, l ? e : p, w, a, b, l ? p : e); } } } @@ -1349,10 +1349,10 @@ function Ua(a, c, b, f, d) { a = b.length; c = c || (k ? 100 : 0); if (1 === a) { - return g = d, (d = Wa(this, b[0], "")) && d.length ? Ca.call(this, d, c, g) : []; + return g = d, (d = Wa(this, b[0], "")) && d.length ? Ba.call(this, d, c, g) : []; } if (2 === a && e && !g) { - return g = d, (d = Wa(this, b[1], b[0])) && d.length ? Ca.call(this, d, c, g) : []; + return g = d, (d = Wa(this, b[1], b[0])) && d.length ? Ba.call(this, d, c, g) : []; } k = J(); var m = 0; @@ -1361,38 +1361,38 @@ function Ua(a, c, b, f, d) { m = 1; } h || 0 === h || (h = n ? this.P : this.resolution); - for (let r, w; m < a; m++) { + for (let p, w; m < a; m++) { if ((w = b[m]) && !k[w]) { k[w] = 1; - r = Wa(this, w, n); + p = Wa(this, w, n); a: { - e = r; - var B = f, x = g, q = h; + e = p; + var z = f, x = g, r = h; let l = []; if (e && e.length) { - if (e.length <= q) { - B.push(e); - r = void 0; + if (e.length <= r) { + z.push(e); + p = void 0; break a; } - for (let u = 0, v; u < q; u++) { + for (let u = 0, v; u < r; u++) { if (v = e[u]) { l[u] = v; } } if (l.length) { - B.push(l); - r = void 0; + z.push(l); + p = void 0; break a; } } - r = x ? void 0 : l; + p = x ? void 0 : l; } - if (r) { - f = r; + if (p) { + f = p; break; } - n && (g && r && f.length || (n = w)); + n && (g && p && f.length || (n = w)); } g && n && m === a - 1 && !f.length && (h = this.resolution, n = "", m = -1, k = J()); } @@ -1406,9 +1406,9 @@ function Ua(a, c, b, f, d) { n = b.length; g = []; a = J(); - for (let r = 0, w, l, u, v; r < h; r++) { + for (let p = 0, w, l, u, v; p < h; p++) { for (m = 0; m < n; m++) { - if (u = b[m], r < u.length && (w = u[r])) { + if (u = b[m], p < u.length && (w = u[p])) { for (e = 0; e < w.length; e++) { if (l = w[e], (k = a[l]) ? a[l]++ : (k = 0, a[l] = 1), v = g[k] || (g[k] = []), v.push(l), c && k === n - 1 && v.length - d === c) { n = d ? v.slice(d) : v; @@ -1458,7 +1458,7 @@ function Ua(a, c, b, f, d) { n = g; } } else if (1 === f) { - c = Ca.call(null, b[0], c, d); + c = Ba.call(null, b[0], c, d); break a; } c = n; @@ -1482,7 +1482,7 @@ function Wa(a, c, b) { a = {}; } b = a.context; - const f = !0 === b ? {depth:1} : b || {}, d = L(a.encoder) ? Ra[a.encoder] : a.encode || a.encoder || {}; + const f = !0 === b ? {depth:1} : b || {}, d = L(a.encoder) ? Pa[a.encoder] : a.encode || a.encoder || {}; this.encoder = d.encode ? d : "object" === typeof d ? new S(d) : {encode:d}; this.resolution = a.resolution || 9; this.tokenize = b = (b = a.tokenize) && "default" !== b && "exact" !== b && b || "strict"; @@ -1500,25 +1500,25 @@ function Wa(a, c, b) { this.cache = (b = a.cache || null) && new Y(b); this.priority = a.priority || 4; } -A = Z.prototype; -A.clear = function() { +B = Z.prototype; +B.clear = function() { this.map.clear(); this.ctx.clear(); this.reg.clear(); this.cache && this.cache.clear(); return this; }; -A.append = function(a, c) { +B.append = function(a, c) { return this.add(a, c, !0); }; -A.contain = function(a) { +B.contain = function(a) { return this.reg.has(a); }; -A.update = function(a, c) { +B.update = function(a, c) { const b = this, f = this.remove(a); return f && f.then ? f.then(() => b.add(a, c)) : this.add(a, c); }; -A.cleanup = function() { +B.cleanup = function() { if (!this.fastupdate) { return console.info('Cleanup the index isn\'t required when not using "fastupdate".'), this; } @@ -1526,8 +1526,8 @@ A.cleanup = function() { this.depth && Sa(this.ctx); return this; }; -A.searchCache = Ka; -A.export = function(a, c, b = 0, f = 0) { +B.searchCache = Ra; +B.export = function(a, c, b = 0, f = 0) { let d, e; switch(f) { case 0: @@ -1551,7 +1551,7 @@ A.export = function(a, c, b = 0, f = 0) { } return xa.call(this, a, c, d, e, b, f); }; -A.import = function(a, c) { +B.import = function(a, c) { if (c) { switch("string" === typeof c && (c = JSON.parse(c)), a = a.split("."), "json" === a[a.length - 1] && a.pop(), 3 === a.length && a.shift(), a = 1 < a.length ? a[1] : a[0], a) { case "reg": @@ -1566,7 +1566,7 @@ A.import = function(a, c) { } } }; -A.serialize = function(a = !0) { +B.serialize = function(a = !0) { let c = "", b = "", f = ""; if (this.reg.size) { let e; @@ -1589,6 +1589,6 @@ A.serialize = function(a = !0) { }; ka(Z.prototype); J(); -export default {Index:Z, Charset:Ra, Encoder:S, Document:X, Worker:null, Resolver:null, IndexedDB:null, Language:{}}; +export default {Index:Z, Charset:Pa, Encoder:S, Document:X, Worker:null, Resolver:null, IndexedDB:null, Language:{}}; -export const Index=Z;export const Charset=Ra;export const Encoder=S;export const Document=X;export const Worker=null;export const Resolver=null;export const IndexedDB=null;export const Language={}; \ No newline at end of file +export const Index=Z;export const Charset=Pa;export const Encoder=S;export const Document=X;export const Worker=null;export const Resolver=null;export const IndexedDB=null;export const Language={}; \ No newline at end of file diff --git a/dist/flexsearch.compact.module.min.js b/dist/flexsearch.compact.module.min.js index 1c0ce90..6f70dc3 100644 --- a/dist/flexsearch.compact.module.min.js +++ b/dist/flexsearch.compact.module.min.js @@ -1,5 +1,5 @@ /**! - * FlexSearch.js v0.8.163 (Bundle) + * FlexSearch.js v0.8.164 (Bundle) * Author and Copyright: Thomas Wilkerling * Licence: Apache-2.0 * Hosted by Nextapps GmbH @@ -14,45 +14,45 @@ null,this.stemmer);this.replacer=H(a.replacer,null,this.replacer);this.minlength A.addMapper=function(a,c){if("object"===typeof a)return this.addReplacer(a,c);if(1a.length&&(this.dedupe||this.mapper))return this.addMapper(a,c);this.matcher||(this.matcher=new Map);this.matcher.set(a,c);this.h+=(this.h?"|":"")+a;this.M=null;this.cache&&V(this);return this}; A.addReplacer=function(a,c){if("string"===typeof a)return this.addMatcher(a,c);this.replacer||(this.replacer=[]);this.replacer.push(a,c);this.cache&&V(this);return this}; A.encode=function(a,c){if(this.cache&&a.length<=this.K)if(this.H){if(this.F.has(a))return this.F.get(a)}else this.H=setTimeout(V,50,this);this.normalize&&("function"===typeof this.normalize?a=this.normalize(a):a=ha?a.normalize("NFKD").replace(ha,"").toLowerCase():a.toLowerCase());this.prepare&&(a=this.prepare(a));this.numeric&&3this.maxlength)){if(c){if(d[n])continue;d[n]=1}else{if(f===n)continue;f=n}if(b)e.push(n);else if(!this.filter||("function"===typeof this.filter?this.filter(n):!this.filter.has(n))){if(this.cache&&n.length<=this.L)if(this.H){var h=this.G.get(n);if(h||""===h){h&&e.push(h);continue}}else this.H=setTimeout(V,50,this);if(this.stemmer){this.N||(this.N=new RegExp("(?!^)("+ -this.C+")$"));let x;for(;x!==n&&2this.stemmer.get(q))}if(n&&(this.mapper||this.dedupe&&1this.matcher.get(x)));if(n&&this.replacer)for(h=0;n&&hthis.O&&(this.G.clear(),this.L=this.L/1.1|0));if(n){if(n!==C)if(c){if(d[n])continue;d[n]=1}else{if(g===n)continue;g=n}e.push(n)}}}this.finalize&&(e=this.finalize(e)||e);this.cache&&a.length<=this.K&&(this.F.set(a,e),this.F.size>this.O&&(this.F.clear(),this.K=this.K/1.1|0));return e};function V(a){a.H=null;a.F.clear();a.G.clear()};function ka(a){W.call(a,"add");W.call(a,"append");W.call(a,"search");W.call(a,"update");W.call(a,"remove");W.call(a,"searchCache")}let la,ma,na;function oa(){la=na=0} +[],d=I(),f,g,k=this.split||""===this.split?a.split(this.split):[a];for(let m=0,n,B;mthis.maxlength)){if(c){if(d[n])continue;d[n]=1}else{if(f===n)continue;f=n}if(b)e.push(n);else if(!this.filter||("function"===typeof this.filter?this.filter(n):!this.filter.has(n))){if(this.cache&&n.length<=this.L)if(this.H){var h=this.G.get(n);if(h||""===h){h&&e.push(h);continue}}else this.H=setTimeout(V,50,this);if(this.stemmer){this.N||(this.N=new RegExp("(?!^)("+ +this.C+")$"));let x;for(;x!==n&&2this.stemmer.get(r))}if(n&&(this.mapper||this.dedupe&&1this.matcher.get(x)));if(n&&this.replacer)for(h=0;n&&hthis.O&&(this.G.clear(),this.L=this.L/1.1|0));if(n){if(n!==B)if(c){if(d[n])continue;d[n]=1}else{if(g===n)continue;g=n}e.push(n)}}}this.finalize&&(e=this.finalize(e)||e);this.cache&&a.length<=this.K&&(this.F.set(a,e),this.F.size>this.O&&(this.F.clear(),this.K=this.K/1.1|0));return e};function V(a){a.H=null;a.F.clear();a.G.clear()};function ka(a){W.call(a,"add");W.call(a,"append");W.call(a,"search");W.call(a,"update");W.call(a,"remove");W.call(a,"searchCache")}let la,ma,na;function oa(){la=na=0} function W(a){this[a+"Async"]=function(){const c=arguments;var b=c[c.length-1];let e;"function"===typeof b&&(e=b,delete c[c.length-1]);la?na||(na=Date.now()-ma>=this.priority*this.priority*3):(la=setTimeout(oa,0),ma=Date.now());if(na){const f=this;return new Promise(g=>{setTimeout(function(){g(f[a+"Async"].apply(f,c))},0)})}const d=this[a].apply(this,c);b=d.then?d:new Promise(f=>f(d));e&&b.then(e);return b}};function pa(a,c=0){let b=[],e=[];c&&(c=25E4/c*5E3|0);for(const d of a.entries())e.push(d),e.length===c&&(b.push(e),e=[]);e.length&&b.push(e);return b}function qa(a,c){c||(c=new Map);for(let b=0,e;bc?c?a.slice(b,b+c):a.slice(b):a;let e=[];for(let d=0,f,g;d=g){b-=g;continue}bc&&(f=f.slice(0,c),g=c);if(!e.length&&g>=c)return f;e.push(f);c-=g;if(!c)break}return e=1E&&(E=l.length+(l?1:0)),t=l.length+(l?1:0)+K.length,B+=D,ja.push(v.length),v.push({match:K})),l+=(l?" ":"")+K)}if(!p)z=u[y],l+=(l?" ":"")+z,h&&v.push({text:z});else if(h&&B>=h)break}B=ja.length*(f.length-2);if(q||r||h&&l.length-B>h)if(B=h+B-2*x,y=t-E,0u&&(u=0)),v=v.length-1){if(F>=v.length){y[p+1]= -1;F>=u.length&&(B[p+1]=1);continue}D-=x}l=v[F].text;if(G=r&&J[p])if(0G)if(y[p+1]=1,m)l=l.substring(0,G);else continue;(G-=l.length)||(G=-1);J[p]=G}else{y[p+1]=1;continue}if(D+l.length+1<=h)l=" "+l,t[p]+=l;else if(m)O=h-D-1,0=F){if(0>F){y[p]=1;B[p]=1;continue}D-=x}l=v[F].text;if(G=q&&z[p])if(0G)if(y[p]=1,m)l=l.substring(l.length- -G);else continue;(G-=l.length)||(G=-1);z[p]=G}else{y[p]=1;continue}if(D+l.length+1<=h)l+=" ",t[p]=l+t[p];else if(m)O=l.length+1-(h-D),0<=O&&O=u.length-1?ua=1:Fb||e)a=a.slice(e,e+b);d&&(a=Ha.call(this,a));return a}}function Ha(a){if(!this||!this.store)return a;const c=Array(a.length);for(let b=0,e;bc?c?a.slice(b,b+c):a.slice(b):a;let e=[];for(let d=0,f,g;d=g){b-=g;continue}bc&&(f=f.slice(0,c),g=c);if(!e.length&&g>=c)return f;e.push(f);c-=g;if(!c)break}return e=1D&&(D=l.length+(l?1:0)),t=l.length+(l?1:0)+K.length,C+=E,ja.push(v.length),v.push({match:K})),l+=(l?" ":"")+K)}if(!q)z=u[y],l+=(l?" ":"")+z,h&&v.push({text:z});else if(h&&C>=h)break}C=ja.length*(f.length-2);if(r||p||h&&l.length-C>h)if(C=h+C-2*x,y=t-D,0u&&(u=0)),v=v.length-1){if(F>=v.length){y[q+1]= +1;F>=u.length&&(C[q+1]=1);continue}E-=x}l=v[F].text;if(G=p&&J[q])if(0G)if(y[q+1]=1,m)l=l.substring(0,G);else continue;(G-=l.length)||(G=-1);J[q]=G}else{y[q+1]=1;continue}if(E+l.length+1<=h)l=" "+l,t[q]+=l;else if(m)O=h-E-1,0=F){if(0>F){y[q]=1;C[q]=1;continue}E-=x}l=v[F].text;if(G=r&&z[q])if(0G)if(y[q]=1,m)l=l.substring(l.length- +G);else continue;(G-=l.length)||(G=-1);z[q]=G}else{y[q]=1;continue}if(E+l.length+1<=h)l+=" ",t[q]=l+t[q];else if(m)O=l.length+1-(h-E),0<=O&&O=u.length-1?ua=1:Fb||e)a=a.slice(e,e+b);d&&(a=Ha.call(this,a));return a}}function Ha(a){if(!this||!this.store)return a;const c=Array(a.length);for(let b=0,e;bthis.limit&&this.cache.delete(this.cache.keys().next().value)}; -Y.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};Y.prototype.remove=function(a){for(const c of this.cache){const b=c[0];c[1].includes(a)&&this.cache.delete(b)}};Y.prototype.clear=function(){this.cache.clear();this.h=""};const La={normalize:!1,numeric:!1,dedupe:!1};const Ma={};const Na=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 Oa=new Map([["ae","a"],["oe","o"],["sh","s"],["kh","k"],["th","t"],["ph","f"],["pf","f"]]),Pa=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/(.)\1+/g,"$1"];const Qa={a:"",e:"",i:"",o:"",u:"",y:"",b:1,f:1,p:1,v:1,c:2,g:2,j:2,k:2,q:2,s:2,x:2,z:2,"\u00df":2,d:3,t:3,l:4,m:5,n:5,r:6};var Ra={Exact:La,Default:Ma,Normalize:Ma,LatinBalance:{mapper:Na},LatinAdvanced:{mapper:Na,matcher:Oa,replacer:Pa},LatinExtra:{mapper:Na,replacer:Pa.concat([/(?!^)[aeo]/g,""]),matcher:Oa},LatinSoundex:{dedupe:!1,include:{letter:!0},finalize:function(a){for(let b=0;bd.length)d.pop();else{const f=d.indexOf(a);f===b.length-1?d.pop():d.splice(f,1)}}else Sa(this.map,a),this.depth&&Sa(this.ctx,a);c||this.reg.delete(a)}this.cache&&this.cache.remove(a);return this}; -function Sa(a,c){let b=0;var e="undefined"===typeof c;if(a.constructor===Array)for(let d=0,f,g;dw;f--){g=r.substring(w,f);l=this.rtl?d-1-w:w;var k=this.score?this.score(c,r,q,g,l):Ua(x, -m,q,d,l);Va(this,C,g,k,a,b)}break}case "bidirectional":case "reverse":if(1g?0:1),m,q,k-1,h-1),l=this.bidirectional&&r>f;Va(this,n,l?f:r,w,a,b,l?r:f)}}}}this.fastupdate||this.reg.add(a)}}return this};function Va(a,c,b,e,d,f,g){let k=g?a.ctx:a.map,h;if(!c[b]||g&&!(h=c[b])[g])g?(c=h||(c[b]=I()),c[g]=1,(h=k.get(g))?k=h:k.set(g,k=new Map)):c[b]=1,(h=k.get(b))?k=h:k.set(b,k=[]),k=k[e]||(k[e]=[]),f&&k.includes(d)||(k.push(d),a.fastupdate&&((c=a.reg.get(d))?c.push(k):a.reg.set(d,[k])))} -function Ua(a,c,b,e,d){return b&&1c||d?g.slice(d,c+d):g;g=b}else{if(b< -n){n=[];break b}g=g[b-1];if(c||d)if(g.length>c||d)g=g.slice(d,c+d)}n=g}else if(1===e){c=Ca.call(null,b[0],c,d);break a}c=n}return c};function Wa(a,c,b){let e;b&&(e=a.bidirectional&&c>b)&&(e=b,b=c,c=e);a=b?(a=a.ctx.get(b))&&a.get(c):a.map.get(c);return a};function Z(a,c){if(!this||this.constructor!==Z)return new Z(a);if(a){var b=N(a)?a:a.preset;b&&(a=Object.assign({},Ta[b],a))}else a={};b=a.context;const e=!0===b?{depth:1}:b||{},d=N(a.encoder)?Ra[a.encoder]:a.encode||a.encoder||{};this.encoder=d.encode?d:"object"===typeof d?new S(d):{encode:d};this.resolution=a.resolution||9;this.tokenize=b=(b=a.tokenize)&&"default"!==b&&"exact"!==b&&b||"strict";this.depth="strict"===b&&e.depth||0;this.bidirectional=!1!==e.bidirectional;this.fastupdate=!!a.fastupdate; +A.import=function(a,c){var b=a.split(".");"json"===b[b.length-1]&&b.pop();a=2this.limit&&this.cache.delete(this.cache.keys().next().value)}; +Y.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};Y.prototype.remove=function(a){for(const c of this.cache){const b=c[0];c[1].includes(a)&&this.cache.delete(b)}};Y.prototype.clear=function(){this.cache.clear();this.h=""};Z.prototype.remove=function(a,c){const b=this.reg.size&&(this.fastupdate?this.reg.get(a):this.reg.has(a));if(b){if(this.fastupdate)for(let e=0,d;ed.length)d.pop();else{const f=d.indexOf(a);f===b.length-1?d.pop():d.splice(f,1)}}else Sa(this.map,a),this.depth&&Sa(this.ctx,a);c||this.reg.delete(a)}this.cache&&this.cache.remove(a);return this}; +function Sa(a,c){let b=0;var e="undefined"===typeof c;if(a.constructor===Array)for(let d=0,f,g;dw;f--){g=p.substring(w,f);l=this.rtl?d-1-w:w;var k=this.score?this.score(c,p,r,g,l):Ua(x, +m,r,d,l);Va(this,B,g,k,a,b)}break}case "bidirectional":case "reverse":if(1g?0:1),m,r,k-1,h-1),l=this.bidirectional&&p>f;Va(this,n,l?f:p,w,a,b,l?p:f)}}}}this.fastupdate||this.reg.add(a)}}return this};function Va(a,c,b,e,d,f,g){let k=g?a.ctx:a.map,h;if(!c[b]||g&&!(h=c[b])[g])g?(c=h||(c[b]=I()),c[g]=1,(h=k.get(g))?k=h:k.set(g,k=new Map)):c[b]=1,(h=k.get(b))?k=h:k.set(b,k=[]),k=k[e]||(k[e]=[]),f&&k.includes(d)||(k.push(d),a.fastupdate&&((c=a.reg.get(d))?c.push(k):a.reg.set(d,[k])))} +function Ua(a,c,b,e,d){return b&&1c||d?g.slice(d,c+d):g;g=b}else{if(b< +n){n=[];break b}g=g[b-1];if(c||d)if(g.length>c||d)g=g.slice(d,c+d)}n=g}else if(1===e){c=Ba.call(null,b[0],c,d);break a}c=n}return c};function Wa(a,c,b){let e;b&&(e=a.bidirectional&&c>b)&&(e=b,b=c,c=e);a=b?(a=a.ctx.get(b))&&a.get(c):a.map.get(c);return a};function Z(a,c){if(!this||this.constructor!==Z)return new Z(a);if(a){var b=N(a)?a:a.preset;b&&(a=Object.assign({},Ta[b],a))}else a={};b=a.context;const e=!0===b?{depth:1}:b||{},d=N(a.encoder)?Pa[a.encoder]:a.encode||a.encoder||{};this.encoder=d.encode?d:"object"===typeof d?new S(d):{encode:d};this.resolution=a.resolution||9;this.tokenize=b=(b=a.tokenize)&&"default"!==b&&"exact"!==b&&b||"strict";this.depth="strict"===b&&e.depth||0;this.bidirectional=!1!==e.bidirectional;this.fastupdate=!!a.fastupdate; this.score=a.score||null;b=!1;this.map=new Map;this.ctx=new Map;this.reg=c||(this.fastupdate?new Map:new Set);this.P=e.resolution||3;this.rtl=d.rtl||a.rtl||!1;this.cache=(b=a.cache||null)&&new Y(b);this.priority=a.priority||4}A=Z.prototype;A.clear=function(){this.map.clear();this.ctx.clear();this.reg.clear();this.cache&&this.cache.clear();return this};A.append=function(a,c){return this.add(a,c,!0)};A.contain=function(a){return this.reg.has(a)}; -A.update=function(a,c){const b=this,e=this.remove(a);return e&&e.then?e.then(()=>b.add(a,c)):this.add(a,c)};A.cleanup=function(){if(!this.fastupdate)return this;Sa(this.map);this.depth&&Sa(this.ctx);return this};A.searchCache=Ka;A.export=function(a,c,b=0,e=0){let d,f;switch(e){case 0:d="reg";f=va(this.reg);break;case 1:d="cfg";f=null;break;case 2:d="map";f=pa(this.map,this.reg.size);break;case 3:d="ctx";f=ra(this.ctx,this.reg.size);break;default:return}return xa.call(this,a,c,d,f,b,e)}; +A.update=function(a,c){const b=this,e=this.remove(a);return e&&e.then?e.then(()=>b.add(a,c)):this.add(a,c)};A.cleanup=function(){if(!this.fastupdate)return this;Sa(this.map);this.depth&&Sa(this.ctx);return this};A.searchCache=Ra;A.export=function(a,c,b=0,e=0){let d,f;switch(e){case 0:d="reg";f=va(this.reg);break;case 1:d="cfg";f=null;break;case 2:d="map";f=pa(this.map,this.reg.size);break;case 3:d="ctx";f=ra(this.ctx,this.reg.size);break;default:return}return xa.call(this,a,c,d,f,b,e)}; A.import=function(a,c){if(c)switch("string"===typeof c&&(c=JSON.parse(c)),a=a.split("."),"json"===a[a.length-1]&&a.pop(),3===a.length&&a.shift(),a=1>> 0) + "_", e = 0; return b; }); -I("Symbol.iterator", function(a) { +H("Symbol.iterator", function(a) { if (a) { return a; } a = Symbol("Symbol.iterator"); for (var b = "Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array".split(" "), c = 0; c < b.length; c++) { - var d = ea[b[c]]; - "function" === typeof d && "function" != typeof d.prototype[a] && ca(d.prototype, a, {configurable:!0, writable:!0, value:function() { - return ya(ba(this)); + var d = fa[b[c]]; + "function" === typeof d && "function" != typeof d.prototype[a] && da(d.prototype, a, {configurable:!0, writable:!0, value:function() { + return ya(ca(this)); }}); } return a; @@ -247,25 +247,25 @@ function ya(a) { }; return a; } -I("Promise", function(a) { +H("Promise", function(a) { function b(g) { this.A = 0; this.B = void 0; this.h = []; this.H = !1; - var k = this.C(); + var h = this.C(); try { - g(k.resolve, k.reject); - } catch (h) { - k.reject(h); + g(h.resolve, h.reject); + } catch (k) { + h.reject(k); } } function c() { this.h = null; } function d(g) { - return g instanceof b ? g : new b(function(k) { - k(g); + return g instanceof b ? g : new b(function(h) { + h(g); }); } if (a) { @@ -274,14 +274,14 @@ I("Promise", function(a) { c.prototype.A = function(g) { if (null == this.h) { this.h = []; - var k = this; + var h = this; this.B(function() { - k.D(); + h.D(); }); } this.h.push(g); }; - var e = ea.setTimeout; + var e = fa.setTimeout; c.prototype.B = function(g) { e(g, 0); }; @@ -289,11 +289,11 @@ I("Promise", function(a) { for (; this.h && this.h.length;) { var g = this.h; this.h = []; - for (var k = 0; k < g.length; ++k) { - var h = g[k]; - g[k] = null; + for (var h = 0; h < g.length; ++h) { + var k = g[h]; + g[h] = null; try { - h(); + k(); } catch (l) { this.C(l); } @@ -309,10 +309,10 @@ I("Promise", function(a) { b.prototype.C = function() { function g(l) { return function(m) { - h || (h = !0, l.call(k, m)); + k || (k = !0, l.call(h, m)); }; } - var k = this, h = !1; + var h = this, k = !1; return {resolve:g(this.fa), reject:g(this.D)}; }; b.prototype.fa = function(g) { @@ -325,28 +325,28 @@ I("Promise", function(a) { a: { switch(typeof g) { case "object": - var k = null != g; + var h = null != g; break a; case "function": - k = !0; + h = !0; break a; default: - k = !1; + h = !1; } } - k ? this.ea(g) : this.G(g); + h ? this.ea(g) : this.G(g); } } }; b.prototype.ea = function(g) { - var k = void 0; + var h = void 0; try { - k = g.then; - } catch (h) { - this.D(h); + h = g.then; + } catch (k) { + this.D(k); return; } - "function" == typeof k ? this.ia(k, g) : this.G(g); + "function" == typeof h ? this.ia(h, g) : this.G(g); }; b.prototype.D = function(g) { this.M(2, g); @@ -354,12 +354,12 @@ I("Promise", function(a) { b.prototype.G = function(g) { this.M(1, g); }; - b.prototype.M = function(g, k) { + b.prototype.M = function(g, h) { if (0 != this.A) { - throw Error("Cannot settle(" + g + ", " + k + "): Promise already settled in state" + this.A); + throw Error("Cannot settle(" + g + ", " + h + "): Promise already settled in state" + this.A); } this.A = g; - this.B = k; + this.B = h; 2 === this.A && this.ga(); this.N(); }; @@ -367,8 +367,8 @@ I("Promise", function(a) { var g = this; e(function() { if (g.T()) { - var k = ea.console; - "undefined" !== typeof k && k.error(g.B); + var h = fa.console; + "undefined" !== typeof h && h.error(g.B); } }, 1); }; @@ -376,14 +376,14 @@ I("Promise", function(a) { if (this.H) { return !1; } - var g = ea.CustomEvent, k = ea.Event, h = ea.dispatchEvent; - if ("undefined" === typeof h) { + var g = fa.CustomEvent, h = fa.Event, k = fa.dispatchEvent; + if ("undefined" === typeof k) { return !0; } - "function" === typeof g ? g = new g("unhandledrejection", {cancelable:!0}) : "function" === typeof k ? g = new k("unhandledrejection", {cancelable:!0}) : (g = ea.document.createEvent("CustomEvent"), g.initCustomEvent("unhandledrejection", !1, !0, g)); + "function" === typeof g ? g = new g("unhandledrejection", {cancelable:!0}) : "function" === typeof h ? g = new h("unhandledrejection", {cancelable:!0}) : (g = fa.document.createEvent("CustomEvent"), g.initCustomEvent("unhandledrejection", !1, !0, g)); g.promise = this; g.reason = this.B; - return h(g); + return k(g); }; b.prototype.N = function() { if (null != this.h) { @@ -395,24 +395,24 @@ I("Promise", function(a) { }; var f = new c(); b.prototype.ha = function(g) { - var k = this.C(); - g.U(k.resolve, k.reject); - }; - b.prototype.ia = function(g, k) { var h = this.C(); + g.U(h.resolve, h.reject); + }; + b.prototype.ia = function(g, h) { + var k = this.C(); try { - g.call(k, h.resolve, h.reject); + g.call(h, k.resolve, k.reject); } catch (l) { - h.reject(l); + k.reject(l); } }; - b.prototype.then = function(g, k) { - function h(p, n) { + b.prototype.then = function(g, h) { + function k(p, n) { return "function" == typeof p ? function(r) { try { l(p(r)); - } catch (v) { - m(v); + } catch (u) { + m(u); } } : n; } @@ -420,56 +420,56 @@ I("Promise", function(a) { l = p; m = n; }); - this.U(h(g, l), h(k, m)); + this.U(k(g, l), k(h, m)); return q; }; b.prototype.catch = function(g) { return this.then(void 0, g); }; - b.prototype.U = function(g, k) { - function h() { + b.prototype.U = function(g, h) { + function k() { switch(l.A) { case 1: g(l.B); break; case 2: - k(l.B); + h(l.B); break; default: throw Error("Unexpected state: " + l.A); } } var l = this; - null == this.h ? f.A(h) : this.h.push(h); + null == this.h ? f.A(k) : this.h.push(k); this.H = !0; }; b.resolve = d; b.reject = function(g) { - return new b(function(k, h) { - h(g); + return new b(function(h, k) { + k(g); }); }; b.race = function(g) { - return new b(function(k, h) { - for (var l = z(g), m = l.next(); !m.done; m = l.next()) { - d(m.value).U(k, h); + return new b(function(h, k) { + for (var l = A(g), m = l.next(); !m.done; m = l.next()) { + d(m.value).U(h, k); } }); }; b.all = function(g) { - var k = z(g), h = k.next(); - return h.done ? d([]) : new b(function(l, m) { + var h = A(g), k = h.next(); + return k.done ? d([]) : new b(function(l, m) { function q(r) { - return function(v) { - p[r] = v; + return function(u) { + p[r] = u; n--; 0 == n && l(p); }; } var p = [], n = 0; do { - p.push(void 0), n++, d(h.value).U(q(p.length - 1), m), h = k.next(); - } while (!h.done); + p.push(void 0), n++, d(k.value).U(q(p.length - 1), m), k = h.next(); + } while (!k.done); }); }; return b; @@ -489,14 +489,14 @@ function za(a, b) { }; return e; } -I("Array.prototype.values", function(a) { +H("Array.prototype.values", function(a) { return a ? a : function() { return za(this, function(b, c) { return c; }); }; }); -I("Array.prototype.keys", function(a) { +H("Array.prototype.keys", function(a) { return a ? a : function() { return za(this, function(b) { return b; @@ -506,31 +506,31 @@ I("Array.prototype.keys", function(a) { function Aa(a, b) { return Object.prototype.hasOwnProperty.call(a, b); } -I("WeakMap", function(a) { - function b(h) { - this.h = (k += Math.random() + 1).toString(); - if (h) { - h = z(h); - for (var l; !(l = h.next()).done;) { +H("WeakMap", function(a) { + function b(k) { + this.h = (h += Math.random() + 1).toString(); + if (k) { + k = A(k); + for (var l; !(l = k.next()).done;) { l = l.value, this.set(l[0], l[1]); } } } function c() { } - function d(h) { - var l = typeof h; - return "object" === l && null !== h || "function" === l; + function d(k) { + var l = typeof k; + return "object" === l && null !== k || "function" === l; } - function e(h) { - if (!Aa(h, g)) { + function e(k) { + if (!Aa(k, g)) { var l = new c(); - ca(h, g, {value:l}); + da(k, g, {value:l}); } } - function f(h) { - var l = Object[h]; - l && (Object[h] = function(m) { + function f(k) { + var l = Object[k]; + l && (Object[k] = function(m) { if (m instanceof c) { return m; } @@ -543,13 +543,13 @@ I("WeakMap", function(a) { return !1; } try { - var h = Object.seal({}), l = Object.seal({}), m = new a([[h, 2], [l, 3]]); - if (2 != m.get(h) || 3 != m.get(l)) { + var k = Object.seal({}), l = Object.seal({}), m = new a([[k, 2], [l, 3]]); + if (2 != m.get(k) || 3 != m.get(l)) { return !1; } - m.delete(h); + m.delete(k); m.set(l, 4); - return !m.has(h) && 4 == m.get(l); + return !m.has(k) && 4 == m.get(l); } catch (q) { return !1; } @@ -560,71 +560,71 @@ I("WeakMap", function(a) { f("freeze"); f("preventExtensions"); f("seal"); - var k = 0; - b.prototype.set = function(h, l) { - if (!d(h)) { + var h = 0; + b.prototype.set = function(k, l) { + if (!d(k)) { throw Error("Invalid WeakMap key"); } - e(h); - if (!Aa(h, g)) { - throw Error("WeakMap key fail: " + h); + e(k); + if (!Aa(k, g)) { + throw Error("WeakMap key fail: " + k); } - h[g][this.h] = l; + k[g][this.h] = l; return this; }; - b.prototype.get = function(h) { - return d(h) && Aa(h, g) ? h[g][this.h] : void 0; + b.prototype.get = function(k) { + return d(k) && Aa(k, g) ? k[g][this.h] : void 0; }; - b.prototype.has = function(h) { - return d(h) && Aa(h, g) && Aa(h[g], this.h); + b.prototype.has = function(k) { + return d(k) && Aa(k, g) && Aa(k[g], this.h); }; - b.prototype.delete = function(h) { - return d(h) && Aa(h, g) && Aa(h[g], this.h) ? delete h[g][this.h] : !1; + b.prototype.delete = function(k) { + return d(k) && Aa(k, g) && Aa(k[g], this.h) ? delete k[g][this.h] : !1; }; return b; }); -I("Map", function(a) { +H("Map", function(a) { function b() { - var k = {}; - return k.J = k.next = k.head = k; + var h = {}; + return h.J = h.next = h.head = h; } - function c(k, h) { - var l = k[1]; + function c(h, k) { + var l = h[1]; return ya(function() { if (l) { - for (; l.head != k[1];) { + for (; l.head != h[1];) { l = l.J; } for (; l.next != l.head;) { - return l = l.next, {done:!1, value:h(l)}; + return l = l.next, {done:!1, value:k(l)}; } l = null; } return {done:!0, value:void 0}; }); } - function d(k, h) { - var l = h && typeof h; - "object" == l || "function" == l ? f.has(h) ? l = f.get(h) : (l = "" + ++g, f.set(h, l)) : l = "p_" + h; - var m = k[0][l]; - if (m && Aa(k[0], l)) { - for (k = 0; k < m.length; k++) { - var q = m[k]; - if (h !== h && q.key !== q.key || h === q.key) { - return {id:l, list:m, index:k, F:q}; + function d(h, k) { + var l = k && typeof k; + "object" == l || "function" == l ? f.has(k) ? l = f.get(k) : (l = "" + ++g, f.set(k, l)) : l = "p_" + k; + var m = h[0][l]; + if (m && Aa(h[0], l)) { + for (h = 0; h < m.length; h++) { + var q = m[h]; + if (k !== k && q.key !== q.key || k === q.key) { + return {id:l, list:m, index:h, F:q}; } } } return {id:l, list:m, index:-1, F:void 0}; } - function e(k) { + function e(h) { this[0] = {}; this[1] = b(); this.size = 0; - if (k) { - k = z(k); - for (var h; !(h = k.next()).done;) { - h = h.value, this.set(h[0], h[1]); + if (h) { + h = A(h); + for (var k; !(k = h.next()).done;) { + k = k.value, this.set(k[0], k[1]); } } } @@ -633,12 +633,12 @@ I("Map", function(a) { return !1; } try { - var k = Object.seal({x:4}), h = new a(z([[k, "s"]])); - if ("s" != h.get(k) || 1 != h.size || h.get({x:4}) || h.set({x:4}, "t") != h || 2 != h.size) { + var h = Object.seal({x:4}), k = new a(A([[h, "s"]])); + if ("s" != k.get(h) || 1 != k.size || k.get({x:4}) || k.set({x:4}, "t") != k || 2 != k.size) { return !1; } - var l = h.entries(), m = l.next(); - if (m.done || m.value[0] != k || "s" != m.value[1]) { + var l = k.entries(), m = l.next(); + if (m.done || m.value[0] != h || "s" != m.value[1]) { return !1; } m = l.next(); @@ -650,57 +650,57 @@ I("Map", function(a) { return a; } var f = new WeakMap(); - e.prototype.set = function(k, h) { - k = 0 === k ? 0 : k; - var l = d(this, k); + e.prototype.set = function(h, k) { + h = 0 === h ? 0 : h; + var l = d(this, h); l.list || (l.list = this[0][l.id] = []); - l.F ? l.F.value = h : (l.F = {next:this[1], J:this[1].J, head:this[1], key:k, value:h}, l.list.push(l.F), this[1].J.next = l.F, this[1].J = l.F, this.size++); + l.F ? l.F.value = k : (l.F = {next:this[1], J:this[1].J, head:this[1], key:h, value:k}, l.list.push(l.F), this[1].J.next = l.F, this[1].J = l.F, this.size++); return this; }; - e.prototype.delete = function(k) { - k = d(this, k); - return k.F && k.list ? (k.list.splice(k.index, 1), k.list.length || delete this[0][k.id], k.F.J.next = k.F.next, k.F.next.J = k.F.J, k.F.head = null, this.size--, !0) : !1; + e.prototype.delete = function(h) { + h = d(this, h); + return h.F && h.list ? (h.list.splice(h.index, 1), h.list.length || delete this[0][h.id], h.F.J.next = h.F.next, h.F.next.J = h.F.J, h.F.head = null, this.size--, !0) : !1; }; e.prototype.clear = function() { this[0] = {}; this[1] = this[1].J = b(); this.size = 0; }; - e.prototype.has = function(k) { - return !!d(this, k).F; + e.prototype.has = function(h) { + return !!d(this, h).F; }; - e.prototype.get = function(k) { - return (k = d(this, k).F) && k.value; + e.prototype.get = function(h) { + return (h = d(this, h).F) && h.value; }; e.prototype.entries = function() { - return c(this, function(k) { - return [k.key, k.value]; + return c(this, function(h) { + return [h.key, h.value]; }); }; e.prototype.keys = function() { - return c(this, function(k) { - return k.key; + return c(this, function(h) { + return h.key; }); }; e.prototype.values = function() { - return c(this, function(k) { - return k.value; + return c(this, function(h) { + return h.value; }); }; - e.prototype.forEach = function(k, h) { + e.prototype.forEach = function(h, k) { for (var l = this.entries(), m; !(m = l.next()).done;) { - m = m.value, k.call(h, m[1], m[0], this); + m = m.value, h.call(k, m[1], m[0], this); } }; e.prototype[Symbol.iterator] = e.prototype.entries; var g = 0; return e; }); -I("Set", function(a) { +H("Set", function(a) { function b(c) { this.h = new Map(); if (c) { - c = z(c); + c = A(c); for (var d; !(d = c.next()).done;) { this.add(d.value); } @@ -712,7 +712,7 @@ I("Set", function(a) { return !1; } try { - var c = Object.seal({x:4}), d = new a(z([c])); + var c = Object.seal({x:4}), d = new a(A([c])); if (!d.has(c) || 1 != d.size || d.add(c) != d || 1 != d.size || d.add({x:4}) != d || 2 != d.size) { return !1; } @@ -762,19 +762,19 @@ I("Set", function(a) { }; return b; }); -I("Array.prototype.entries", function(a) { +H("Array.prototype.entries", function(a) { return a ? a : function() { return za(this, function(b, c) { return [b, c]; }); }; }); -I("Object.is", function(a) { +H("Object.is", function(a) { return a ? a : function(b, c) { return b === c ? 0 !== b || 1 / b === 1 / c : b !== b && c !== c; }; }); -I("Array.prototype.includes", function(a) { +H("Array.prototype.includes", function(a) { return a ? a : function(b, c) { var d = this; d instanceof String && (d = String(d)); @@ -789,7 +789,7 @@ I("Array.prototype.includes", function(a) { return !1; }; }); -I("String.prototype.includes", function(a) { +H("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"); @@ -800,7 +800,7 @@ I("String.prototype.includes", function(a) { return -1 !== this.indexOf(b, c || 0); }; }); -I("Array.prototype.flat", function(a) { +H("Array.prototype.flat", function(a) { return a ? a : function(b) { b = void 0 === b ? 1 : b; var c = []; @@ -821,10 +821,10 @@ var Ba = "function" == typeof Object.assign ? Object.assign : function(a, b) { } return a; }; -I("Object.assign", function(a) { +H("Object.assign", function(a) { return a || Ba; }); -I("Promise.prototype.finally", function(a) { +H("Promise.prototype.finally", function(a) { return a ? a : function(b) { return this.then(function(c) { return Promise.resolve(b()).then(function() { @@ -837,7 +837,7 @@ I("Promise.prototype.finally", function(a) { }); }; }); -function O(a, b, c) { +function P(a, b, c) { var d = typeof c, e = typeof a; if ("undefined" !== d) { if ("undefined" !== e) { @@ -854,7 +854,7 @@ function O(a, b, c) { } if (b === Map) { b = new Map(c); - d = z(a); + d = A(a); for (e = d.next(); !e.done; e = d.next()) { e = e.value, b.set(e[0], e[1]); } @@ -862,7 +862,7 @@ function O(a, b, c) { } if (b === Set) { b = new Set(c); - d = z(a.values()); + d = A(a.values()); for (e = d.next(); !e.done; e = d.next()) { b.add(e.value); } @@ -876,10 +876,10 @@ function O(a, b, c) { } return "undefined" === e ? b : a; } -function Q() { +function S() { return Object.create(null); } -function R(a) { +function T(a) { return "string" === typeof a; } function Ca(a) { @@ -887,14 +887,14 @@ function Ca(a) { } function Da(a) { var b = []; - a = z(a.keys()); + a = A(a.keys()); for (var c = a.next(); !c.done; c = a.next()) { b.push(c.value); } return b; } function Ea(a, b) { - if (R(b)) { + if (T(b)) { a = a[b]; } else { for (var c = 0; a && c < b.length; c++) { @@ -917,11 +917,11 @@ function La(a) { if (arguments instanceof Array) { var f = arguments; } else { - f = z(arguments); - for (var g, k = []; !(g = f.next()).done;) { - k.push(g.value); + f = A(arguments); + for (var g, h = []; !(g = f.next()).done;) { + h.push(g.value); } - f = k; + f = h; } return new (c.call(b, La, e.call(d, f)))(); } @@ -933,9 +933,9 @@ function La(a) { this.assign(a); } } -w = La.prototype; -w.assign = function(a) { - this.normalize = O(a.normalize, !0, this.normalize); +v = La.prototype; +v.assign = function(a) { + this.normalize = P(a.normalize, !0, this.normalize); var b = a.include, c = b || a.exclude || a.split; if (c || "" === c) { if ("object" === typeof c && c.constructor !== RegExp) { @@ -958,28 +958,28 @@ w.assign = function(a) { } else { this.split = c, e = !1 === c || 2 > "a1a".split(c).length; } - this.numeric = O(a.numeric, e); + this.numeric = P(a.numeric, e); } else { try { - this.split = O(this.split, Ga); + this.split = P(this.split, Ga); } catch (f) { console.warn("This platform does not support unicode regex. It falls back to using simple whitespace splitter instead: /s+/."), this.split = /\s+/; } - this.numeric = O(a.numeric, O(this.numeric, !0)); + this.numeric = P(a.numeric, P(this.numeric, !0)); } - this.prepare = O(a.prepare, null, this.prepare); - this.finalize = O(a.finalize, null, this.finalize); + this.prepare = P(a.prepare, null, this.prepare); + this.finalize = P(a.finalize, null, this.finalize); c = a.filter; - this.filter = "function" === typeof c ? c : O(c && new Set(c), null, this.filter); - this.dedupe = O(a.dedupe, !0, this.dedupe); - this.matcher = O((c = a.matcher) && new Map(c), null, this.matcher); - this.mapper = O((c = a.mapper) && new Map(c), null, this.mapper); - this.stemmer = O((c = a.stemmer) && new Map(c), null, this.stemmer); - this.replacer = O(a.replacer, null, this.replacer); - this.minlength = O(a.minlength, 1, this.minlength); - this.maxlength = O(a.maxlength, 1024, this.maxlength); - this.rtl = O(a.rtl, !1, this.rtl); - if (this.cache = c = O(a.cache, !0, this.cache)) { + this.filter = "function" === typeof c ? c : P(c && new Set(c), null, this.filter); + this.dedupe = P(a.dedupe, !0, this.dedupe); + this.matcher = P((c = a.matcher) && new Map(c), null, this.matcher); + this.mapper = P((c = a.mapper) && new Map(c), null, this.mapper); + this.stemmer = P((c = a.stemmer) && new Map(c), null, this.stemmer); + this.replacer = P(a.replacer, null, this.replacer); + this.minlength = P(a.minlength, 1, this.minlength); + this.maxlength = P(a.maxlength, 1024, this.maxlength); + this.rtl = P(a.rtl, !1, this.rtl); + if (this.cache = c = P(a.cache, !0, this.cache)) { this.D = null, this.T = "number" === typeof c ? c : 2e5, this.B = new Map(), this.C = new Map(), this.H = this.G = 128; } this.h = ""; @@ -987,18 +987,18 @@ w.assign = function(a) { this.A = ""; this.N = null; if (this.matcher) { - for (a = z(this.matcher.keys()), b = a.next(); !b.done; b = a.next()) { + for (a = A(this.matcher.keys()), b = a.next(); !b.done; b = a.next()) { this.h += (this.h ? "|" : "") + b.value; } } if (this.stemmer) { - for (a = z(this.stemmer.keys()), b = a.next(); !b.done; b = a.next()) { + for (a = A(this.stemmer.keys()), b = a.next(); !b.done; b = a.next()) { this.A += (this.A ? "|" : "") + b.value; } } return this; }; -w.addStemmer = function(a, b) { +v.addStemmer = function(a, b) { this.stemmer || (this.stemmer = new Map()); this.stemmer.set(a, b); this.A += (this.A ? "|" : "") + a; @@ -1006,12 +1006,12 @@ w.addStemmer = function(a, b) { this.cache && Ma(this); return this; }; -w.addFilter = function(a) { +v.addFilter = function(a) { "function" === typeof a ? this.filter = a : (this.filter || (this.filter = new Set()), this.filter.add(a)); this.cache && Ma(this); return this; }; -w.addMapper = function(a, b) { +v.addMapper = function(a, b) { if ("object" === typeof a) { return this.addReplacer(a, b); } @@ -1023,7 +1023,7 @@ w.addMapper = function(a, b) { this.cache && Ma(this); return this; }; -w.addMatcher = function(a, b) { +v.addMatcher = function(a, b) { if ("object" === typeof a) { return this.addReplacer(a, b); } @@ -1037,7 +1037,7 @@ w.addMatcher = function(a, b) { this.cache && Ma(this); return this; }; -w.addReplacer = function(a, b) { +v.addReplacer = function(a, b) { if ("string" === typeof a) { return this.addMatcher(a, b); } @@ -1046,7 +1046,7 @@ w.addReplacer = function(a, b) { this.cache && Ma(this); return this; }; -w.encode = function(a, b) { +v.encode = function(a, b) { var c = this; if (this.cache && a.length <= this.G) { if (this.D) { @@ -1060,8 +1060,8 @@ w.encode = function(a, b) { this.normalize && ("function" === typeof this.normalize ? a = this.normalize(a) : a = Ka ? a.normalize("NFKD").replace(Ka, "").toLowerCase() : a.toLowerCase()); this.prepare && (a = this.prepare(a)); this.numeric && 3 < a.length && (a = a.replace(Ia, "$1 $2").replace(Ja, "$1 $2").replace(Ha, "$1 ")); - for (var d = !(this.dedupe || this.mapper || this.filter || this.matcher || this.stemmer || this.replacer), e = [], f = Q(), g, k, h = this.split || "" === this.split ? a.split(this.split) : [a], l = 0, m = void 0, q = void 0; l < h.length; l++) { - if ((m = q = h[l]) && !(m.length < this.minlength || m.length > this.maxlength)) { + for (var d = !(this.dedupe || this.mapper || this.filter || this.matcher || this.stemmer || this.replacer), e = [], f = S(), g, h, k = this.split || "" === this.split ? a.split(this.split) : [a], l = 0, m = void 0, q = void 0; l < k.length; l++) { + if ((m = q = k[l]) && !(m.length < this.minlength || m.length > this.maxlength)) { if (b) { if (f[m]) { continue; @@ -1090,20 +1090,20 @@ w.encode = function(a, b) { } if (this.stemmer) { for (this.N || (this.N = new RegExp("(?!^)(" + this.A + ")$")), p = void 0; p !== m && 2 < m.length;) { - p = m, m = m.replace(this.N, function(B) { - return c.stemmer.get(B); + p = m, m = m.replace(this.N, function(w) { + return c.stemmer.get(w); }); } } if (m && (this.mapper || this.dedupe && 1 < m.length)) { p = ""; - for (var n = 0, r = "", v = void 0, u = void 0; n < m.length; n++) { - v = m.charAt(n), v === r && this.dedupe || ((u = this.mapper && this.mapper.get(v)) || "" === u ? u === r && this.dedupe || !(r = u) || (p += u) : p += r = v); + for (var n = 0, r = "", u = void 0, x = void 0; n < m.length; n++) { + u = m.charAt(n), u === r && this.dedupe || ((x = this.mapper && this.mapper.get(u)) || "" === x ? x === r && this.dedupe || !(r = x) || (p += x) : p += r = u); } m = p; } - this.matcher && 1 < m.length && (this.M || (this.M = new RegExp("(" + this.h + ")", "g")), m = m.replace(this.M, function(B) { - return c.matcher.get(B); + this.matcher && 1 < m.length && (this.M || (this.M = new RegExp("(" + this.h + ")", "g")), m = m.replace(this.M, function(w) { + return c.matcher.get(w); })); if (m && this.replacer) { for (p = 0; m && p < this.replacer.length; p += 2) { @@ -1119,10 +1119,10 @@ w.encode = function(a, b) { } f[m] = 1; } else { - if (k === m) { + if (h === m) { continue; } - k = m; + h = m; } } e.push(m); @@ -1143,8 +1143,8 @@ function Ma(a) { ;var Na, Oa; function Pa(a) { var b, c, d, e, f, g; - return xa(function(k) { - switch(k.h) { + return xa(function(h) { + switch(h.h) { case 1: a = a.data; b = a.task; @@ -1153,13 +1153,13 @@ function Pa(a) { switch(b) { case "init": Oa = a.options || {}; - (e = a.factory) ? (Function("return " + e)()(self), Na = new self.FlexSearch.Index(Oa), delete self.FlexSearch) : Na = new U(Oa); + (e = a.factory) ? (Function("return " + e)()(self), Na = new self.FlexSearch.Index(Oa), delete self.FlexSearch) : Na = new W(Oa); postMessage({id:c}); break; default: - k.h = 2; + h.h = 2; return; - }k.h = 0; + }h.h = 0; break; case 2: if ("export" === b) { @@ -1173,25 +1173,25 @@ function Pa(a) { throw Error('Either no extern configuration provided for the Worker-Index or no method was defined on the config property "import".'); } if (!d[0]) { - k.h = 5; + h.h = 5; break; } - return L(k, Oa.import.call(Na, d[0]), 9); + return L(h, Oa.import.call(Na, d[0]), 9); } f = d && Na[b].apply(Na, d); if (!f || !f.then) { - k.h = 5; + h.h = 5; break; } - return L(k, f, 7); + return L(h, f, 7); case 7: - f = k.D; - k.h = 5; + f = h.D; + h.h = 5; break; case 9: - g = k.D, Na.import(d[0], g); + g = h.D, Na.import(d[0], g); case 5: - postMessage("search" === b ? {id:c, msg:f} : {id:c}), k.h = 0; + postMessage("search" === b ? {id:c, msg:f} : {id:c}), h.h = 0; } }); } @@ -1232,28 +1232,29 @@ function Ra(a) { }; } ;var Wa = 0; -function Xa(a) { - function b(g) { - function k(h) { - h = h.data || h; - var l = h.id, m = l && e.h[l]; - m && (m(h.msg), delete e.h[l]); +function Xa(a, b) { + function c(h) { + function k(l) { + l = l.data || l; + var m = l.id, q = m && f.h[m]; + q && (q(l.msg), delete f.h[m]); } - this.worker = g; - this.h = Q(); + this.worker = h; + this.h = S(); if (this.worker) { - d ? this.worker.on("message", k) : this.worker.onmessage = k; + e ? this.worker.on("message", k) : this.worker.onmessage = k; if (a.config) { - return new Promise(function(h) { - e.h[++Wa] = function() { - h(e); + return new Promise(function(l) { + f.h[++Wa] = function() { + l(f); 1e9 < Wa && (Wa = 0); }; - e.worker.postMessage({id:Wa, task:"init", factory:c, options:a}); + f.worker.postMessage({id:Wa, task:"init", factory:d, options:a}); }); } - this.worker.postMessage({task:"init", factory:c, options:a}); + this.worker.postMessage({task:"init", factory:d, options:a}); this.priority = a.priority || 4; + b && (this.encoder = b); return this; } } @@ -1261,12 +1262,12 @@ function Xa(a) { if (!this || this.constructor !== Xa) { return new Xa(a); } - var c = "undefined" !== typeof self ? self._factory : "undefined" !== typeof window ? window._factory : null; - c && (c = c.toString()); - var d = "undefined" === typeof window, e = this, f = Ya(c, d, a.worker); - return f.then ? f.then(function(g) { - return b.call(e, g); - }) : b.call(this, f); + var d = "undefined" !== typeof self ? self._factory : "undefined" !== typeof window ? window._factory : null; + d && (d = d.toString()); + var e = "undefined" === typeof window, f = this, g = Ya(d, e, a.worker); + return g.then ? g.then(function(h) { + return c.call(f, h); + }) : c.call(this, g); } Za("add"); Za("append"); @@ -1300,7 +1301,7 @@ function Ya(a, b, c) { b = void 0 === b ? 0 : b; var c = [], d = []; b && (b = 250000 / b * 5000 | 0); - a = z(a.entries()); + a = A(a.entries()); for (var e = a.next(); !e.done; e = a.next()) { d.push(e.value), d.length === b && (c.push(d), d = []); } @@ -1318,7 +1319,7 @@ function bb(a, b) { b = void 0 === b ? 0 : b; var c = [], d = []; b && (b = 250000 / b * 1000 | 0); - a = z(a.entries()); + a = A(a.entries()); for (var e = a.next(); !e.done; e = a.next()) { e = e.value, d.push([e[0], $a(e[1])[0]]), d.length === b && (c.push(d), d = []); } @@ -1334,7 +1335,7 @@ function cb(a, b) { } function db(a) { var b = [], c = []; - a = z(a.keys()); + a = A(a.keys()); for (var d = a.next(); !d.done; d = a.next()) { c.push(d.value), 250000 === c.length && (b.push(c), c = []); } @@ -1350,32 +1351,32 @@ function eb(a, b) { } function fb(a, b, c, d, e, f, g) { g = void 0 === g ? 0 : g; - var k = d && d.constructor === Array, h = k ? d.shift() : d; - if (!h) { + var h = d && d.constructor === Array, k = h ? d.shift() : d; + if (!k) { return this.export(a, b, e, f + 1); } - if ((h = a((b ? b + "." : "") + (g + 1) + "." + c, JSON.stringify(h))) && h.then) { + if ((k = a((b ? b + "." : "") + (g + 1) + "." + c, JSON.stringify(k))) && k.then) { var l = this; - return h.then(function() { - return fb.call(l, a, b, c, k ? d : null, e, f, g + 1); + return k.then(function() { + return fb.call(l, a, b, c, h ? d : null, e, f, g + 1); }); } - return fb.call(this, a, b, c, k ? d : null, e, f, g + 1); + return fb.call(this, a, b, c, h ? d : null, e, f, g + 1); } function gb(a, b) { var c = ""; - a = z(a.entries()); + a = A(a.entries()); for (var d = a.next(); !d.done; d = a.next()) { var e = d.value; d = e[0]; e = e[1]; - for (var f = "", g = 0, k; g < e.length; g++) { - k = e[g] || [""]; - for (var h = "", l = 0; l < k.length; l++) { - h += (h ? "," : "") + ("string" === b ? '"' + k[l] + '"' : k[l]); + for (var f = "", g = 0, h; g < e.length; g++) { + h = e[g] || [""]; + for (var k = "", l = 0; l < h.length; l++) { + k += (k ? "," : "") + ("string" === b ? '"' + h[l] + '"' : h[l]); } - h = "[" + h + "]"; - f += (f ? "," : "") + h; + k = "[" + k + "]"; + f += (f ? "," : "") + k; } f = '["' + d + '",[' + f + "]]"; c += (c ? "," : "") + f; @@ -1424,13 +1425,13 @@ function ib(a) { } if ("indexOf" === d) { return function(e) { - for (var f = 0, g = 0, k, h; g < b.index.length; g++) { - k = b.index[g]; - h = k.indexOf(e); - if (0 <= h) { - return f + h; + for (var f = 0, g = 0, h, k; g < b.index.length; g++) { + h = b.index[g]; + k = h.indexOf(e); + if (0 <= k) { + return f + k; } - f += k.length; + f += h.length; } return -1; }; @@ -1476,53 +1477,53 @@ ib.prototype.destroy = function() { }; ib.prototype.push = function() { }; -function V(a) { +function X(a) { a = void 0 === a ? 8 : a; - if (!this || this.constructor !== V) { - return new V(a); + if (!this || this.constructor !== X) { + return new X(a); } - this.index = Q(); + this.index = S(); this.h = []; this.size = 0; 32 < a ? (this.A = jb, this.B = BigInt(a)) : (this.A = kb, this.B = a); } -V.prototype.get = function(a) { +X.prototype.get = function(a) { var b = this.A(a); return (b = this.index[b]) && b.get(a); }; -V.prototype.set = function(a, b) { +X.prototype.set = function(a, b) { var c = this.A(a), d = this.index[c]; d ? (c = d.size, d.set(a, b), (c -= d.size) && this.size++) : (this.index[c] = d = new Map([[a, b]]), this.h.push(d), this.size++); }; -function W(a) { +function Y(a) { a = void 0 === a ? 8 : a; - if (!this || this.constructor !== W) { - return new W(a); + if (!this || this.constructor !== Y) { + return new Y(a); } - this.index = Q(); + this.index = S(); this.h = []; this.size = 0; 32 < a ? (this.A = jb, this.B = BigInt(a)) : (this.A = kb, this.B = a); } -W.prototype.add = function(a) { +Y.prototype.add = function(a) { var b = this.A(a), c = this.index[b]; c ? (b = c.size, c.add(a), (b -= c.size) && this.size++) : (this.index[b] = c = new Set([a]), this.h.push(c), this.size++); }; -w = V.prototype; -w.has = W.prototype.has = function(a) { +v = X.prototype; +v.has = Y.prototype.has = function(a) { var b = this.A(a); return (b = this.index[b]) && b.has(a); }; -w.delete = W.prototype.delete = function(a) { +v.delete = Y.prototype.delete = function(a) { var b = this.A(a); (b = this.index[b]) && b.delete(a) && this.size--; }; -w.clear = W.prototype.clear = function() { - this.index = Q(); +v.clear = Y.prototype.clear = function() { + this.index = S(); this.h = []; this.size = 0; }; -w.values = W.prototype.values = function lb() { +v.values = Y.prototype.values = function lb() { var b, c = this, d, e, f; return va(lb, function(g) { switch(g.h) { @@ -1533,7 +1534,7 @@ w.values = W.prototype.values = function lb() { g.h = 0; break; } - d = z(c.h[b].values()); + d = A(c.h[b].values()); e = d.next(); case 5: if (e.done) { @@ -1548,7 +1549,7 @@ w.values = W.prototype.values = function lb() { } }); }; -w.keys = W.prototype.keys = function mb() { +v.keys = Y.prototype.keys = function mb() { var b, c = this, d, e, f; return va(mb, function(g) { switch(g.h) { @@ -1559,7 +1560,7 @@ w.keys = W.prototype.keys = function mb() { g.h = 0; break; } - d = z(c.h[b].keys()); + d = A(c.h[b].keys()); e = d.next(); case 5: if (e.done) { @@ -1574,7 +1575,7 @@ w.keys = W.prototype.keys = function mb() { } }); }; -w.entries = W.prototype.entries = function nb() { +v.entries = Y.prototype.entries = function nb() { var b, c = this, d, e, f; return va(nb, function(g) { switch(g.h) { @@ -1585,7 +1586,7 @@ w.entries = W.prototype.entries = function nb() { g.h = 0; break; } - d = z(c.h[b].entries()); + d = A(c.h[b].entries()); e = d.next(); case 5: if (e.done) { @@ -1627,58 +1628,58 @@ function jb() { } else { var g = e.R; if (!g || g(b)) { - e.constructor === String ? e = ["" + e] : R(e) && (e = [e]), pb(b, e, this.S, 0, f, a, e[0], c); + e.constructor === String ? e = ["" + e] : T(e) && (e = [e]), pb(b, e, this.S, 0, f, a, e[0], c); } } } if (this.tag) { for (d = 0; d < this.K.length; d++) { g = this.K[d]; - var k = this.aa[d]; - f = this.tag.get(k); - e = Q(); + var h = this.aa[d]; + f = this.tag.get(h); + e = S(); if ("function" === typeof g) { if (g = g(b), !g) { continue; } } else { - var h = g.R; - if (h && !h(b)) { + var k = g.R; + if (k && !k(b)) { continue; } g.constructor === String && (g = "" + g); g = Ea(b, g); } if (f && g) { - for (R(g) && (g = [g]), k = 0, h = void 0; k < g.length; k++) { - var l = g[k]; + for (T(g) && (g = [g]), h = 0, k = void 0; h < g.length; h++) { + var l = g[h]; if (!e[l]) { e[l] = 1; var m; - (m = f.get(l)) ? h = m : f.set(l, h = []); - if (!c || !h.includes(a)) { - if (h.length === Math.pow(2, 31) - 1) { - m = new ib(h); + (m = f.get(l)) ? k = m : f.set(l, k = []); + if (!c || !k.includes(a)) { + if (k.length === Math.pow(2, 31) - 1) { + m = new ib(k); if (this.fastupdate) { - for (var q = z(this.reg.values()), p = q.next(); !p.done; p = q.next()) { - p = p.value, p.includes(h) && (p[p.indexOf(h)] = m); + for (var q = A(this.reg.values()), p = q.next(); !p.done; p = q.next()) { + p = p.value, p.includes(k) && (p[p.indexOf(k)] = m); } } - f.set(l, h = m); + f.set(l, k = m); } - h.push(a); - this.fastupdate && ((l = this.reg.get(a)) ? l.push(h) : this.reg.set(a, [h])); + k.push(a); + this.fastupdate && ((l = this.reg.get(a)) ? l.push(k) : this.reg.set(a, [k])); } } } } else { - f || console.warn("Tag '" + k + "' was not found"); + f || console.warn("Tag '" + h + "' was not found"); } } } if (this.store && (!c || !this.store.has(a))) { if (this.I) { - var n = Q(); + var n = S(); for (c = 0; c < this.I.length; c++) { if (d = this.I[c], f = d.R, !f || f(b)) { f = void 0; @@ -1688,7 +1689,7 @@ function jb() { continue; } d = [d.ja]; - } else if (R(d) || d.constructor === String) { + } else if (T(d) || d.constructor === String) { n[d] = b[d]; continue; } @@ -1712,11 +1713,11 @@ function qb(a, b, c, d, e, f) { qb(a, b, c, d, e); } } else { - b = b[e] || (b[e] = Q()), e = c[++d], qb(a, b, c, d, e); + b = b[e] || (b[e] = S()), e = c[++d], qb(a, b, c, d, e); } } } -function pb(a, b, c, d, e, f, g, k) { +function pb(a, b, c, d, e, f, g, h) { if (a = a[g]) { if (d === b.length - 1) { if (a.constructor === Array) { @@ -1728,208 +1729,86 @@ function pb(a, b, c, d, e, f, g, k) { } a = a.join(" "); } - e.add(f, a, k, !0); + e.add(f, a, h, !0); } else { if (a.constructor === Array) { for (g = 0; g < a.length; g++) { - pb(a, b, c, d, e, f, g, k); + pb(a, b, c, d, e, f, g, h); } } else { - g = b[++d], pb(a, b, c, d, e, f, g, k); + g = b[++d], pb(a, b, c, d, e, f, g, h); } } } else { e.db && e.remove(f); } } -;function rb(a, b, c, d, e, f, g) { - var k = a.length, h = []; - var l = Q(); - for (var m = 0, q = void 0, p, n; m < b; m++) { - for (var r = 0; r < k; r++) { - var v = a[r]; - if (m < v.length && (q = v[m])) { - for (var u = 0; u < q.length; u++) { - p = q[u]; - (v = l[p]) ? l[p]++ : (v = 0, l[p] = 1); - n = h[v] || (h[v] = []); - if (!g) { - var B = m + (r || !e ? 0 : f || 0); - n = n[B] || (n[B] = []); - } - n.push(p); - if (g && c && v === k - 1 && n.length - d === c) { - return d ? n.slice(d) : n; - } - } - } - } - } - if (a = h.length) { - if (e) { - h = 1 < h.length ? sb(h, c, d, g, f) : (h = h[0]).length > c || d ? h.slice(d, c + d) : h; - } else { - if (a < k) { - return []; - } - h = h[a - 1]; - if (c || d) { - if (g) { - if (h.length > c || d) { - h = h.slice(d, c + d); - } - } else { - e = []; - for (f = 0; f < h.length; f++) { - if (g = h[f]) { - if (d && g.length > d) { - d -= g.length; - } else { - if (c && g.length > c || d) { - g = g.slice(d, c + d), c -= g.length, d && (d -= g.length); - } - e.push(g); - if (!c) { - break; - } - } - } - } - h = e; - } - } - } - } - return h; -} -function sb(a, b, c, d, e) { - var f = [], g = Q(), k = a.length, h; - if (d) { - for (e = k - 1; 0 <= e; e--) { - if (h = (d = a[e]) && d.length) { - for (k = 0; k < h; k++) { - var l = d[k]; - if (!g[l]) { - if (g[l] = 1, c) { - c--; - } else { - if (f.push(l), f.length === b) { - return f; - } - } - } - } - } - } - } else { - for (var m = k - 1, q, p = 0; 0 <= m; m--) { - q = a[m]; - for (var n = 0; n < q.length; n++) { - if (h = (d = q[n]) && d.length) { - for (var r = 0; r < h; r++) { - if (l = d[r], !g[l]) { - if (g[l] = 1, c) { - c--; - } else { - var v = (n + (m < k - 1 ? e || 0 : 0)) / (m + 1) | 0; - (f[v] || (f[v] = [])).push(l); - if (++p === b) { - return f; - } - } - } - } - } - } - } - } - return f; -} -function tb(a, b, c) { - for (var d = Q(), e = [], f = 0, g; f < b.length; f++) { - g = b[f]; - for (var k = 0; k < g.length; k++) { - d[g[k]] = 1; - } - } - if (c) { - for (b = 0; b < a.length; b++) { - c = a[b], d[c] && (e.push(c), d[c] = 0); - } - } else { - for (b = 0; b < a.result.length; b++) { - for (c = a.result[b], g = 0; g < c.length; g++) { - f = c[g], d[f] && ((e[b] || (e[b] = [])).push(f), d[f] = 0); - } - } - } - return e; -} -;function ub(a, b, c, d) { +;function rb(a, b, c, d) { if (!a.length) { return a; } if (1 === a.length) { - return a = a[0], a = c || a.length > b ? b ? a.slice(c, c + b) : a.slice(c) : a, d ? vb.call(this, a) : a; + return a = a[0], a = c || a.length > b ? b ? a.slice(c, c + b) : a.slice(c) : a, d ? sb.call(this, a) : a; } - for (var e = [], f = 0, g = void 0, k = void 0; f < a.length; f++) { - if ((g = a[f]) && (k = g.length)) { + for (var e = [], f = 0, g = void 0, h = void 0; f < a.length; f++) { + if ((g = a[f]) && (h = g.length)) { if (c) { - if (c >= k) { - c -= k; + if (c >= h) { + c -= h; continue; } - c < k && (g = b ? g.slice(c, c + b) : g.slice(c), k = g.length, c = 0); + c < h && (g = b ? g.slice(c, c + b) : g.slice(c), h = g.length, c = 0); } - k > b && (g = g.slice(0, b), k = b); - if (!e.length && k >= b) { - return d ? vb.call(this, g) : g; + h > b && (g = g.slice(0, b), h = b); + if (!e.length && h >= b) { + return d ? sb.call(this, g) : g; } e.push(g); - b -= k; + b -= h; if (!b) { break; } } } e = 1 < e.length ? [].concat.apply([], e) : e[0]; - return d ? vb.call(this, e) : e; + return d ? sb.call(this, e) : e; } -;function wb(a, b, c) { +;function tb(a, b, c) { var d = c[0]; if (d.then) { - return Promise.all(c).then(function(v) { - return a[b].apply(a, v); + return Promise.all(c).then(function(x) { + return a[b].apply(a, x); }); } if (d[0] && d[0].index) { return a[b].apply(a, d); } d = []; - for (var e = [], f = 0, g = 0, k, h, l, m, q, p = 0, n = void 0; p < c.length; p++) { + for (var e = [], f = 0, g = 0, h, k, l, m, q, p = 0, n = void 0; p < c.length; p++) { if (n = c[p]) { var r = void 0; - if (n.constructor === X) { + if (n.constructor === Z) { r = n.result; } else if (n.constructor === Array) { r = n; } else { - if (f = n.limit || 0, g = n.offset || 0, l = n.suggest, h = n.resolve, k = (m = n.highlight && h) || n.enrich && h, r = void 0, n.index && (a.index = r = n.index), n.query || n.tag) { + if (f = n.limit || 0, g = n.offset || 0, l = n.suggest, k = n.resolve, h = (m = n.highlight && k) || n.enrich && k, r = void 0, n.index ? a.index = r = n.index : r = a.index, n.query || n.tag) { if (!a.index) { throw Error("Resolver can't apply because the corresponding Index was never specified"); } - if (n.field) { + var u = n.field || n.pluck; + if (u) { if (!a.index.index) { throw Error("Resolver can't apply because the corresponding Document Index was not specified"); } - r = a.index.index.get(n.field); + r = a.index.index.get(u); if (!r) { - throw Error("Resolver can't apply because the specified Document field '" + n.field + "' was not found"); + throw Error("Resolver can't apply because the specified Document Field '" + u + "' was not found"); } } n.resolve = !1; r = r.search(n).result; - n.resolve = h; + n.resolve = k; m && (q = n.query); } else if (n.and) { r = a.and(n.and); @@ -1953,27 +1832,27 @@ function tb(a, b, c) { } } } - return {W:d, $:e, limit:f, offset:g, enrich:k, resolve:h, suggest:l, highlight:m, ma:q}; + return {W:d, $:e, limit:f, offset:g, enrich:h, resolve:k, suggest:l, highlight:m, ma:q}; } -;X.prototype.or = function() { - var a = wb(this, "or", arguments); - return xb.call(this, a.W, a.$, a.limit, a.offset, a.enrich, a.resolve); +;Z.prototype.or = function() { + var a = tb(this, "or", arguments); + return ub.call(this, a.W, a.$, a.limit, a.offset, a.enrich, a.resolve); }; -function xb(a, b, c, d, e, f) { +function ub(a, b, c, d, e, f) { if (b.length) { var g = this; - return Promise.all(b).then(function(k) { + return Promise.all(b).then(function(h) { a = []; - for (var h = 0, l = void 0; h < k.length; h++) { - (l = k[h]).length && (a[h] = l); + for (var k = 0, l = void 0; k < h.length; k++) { + (l = h[k]).length && (a[k] = l); } - return xb.call(g, a, [], c, d, e, f); + return ub.call(g, a, [], c, d, e, f); }); } - a.length && (this.result.length && a.push(this.result), 2 > a.length ? this.result = a[0] : (this.result = sb(a, c, d, !1, this.h), d = 0)); + a.length && (this.result.length && a.push(this.result), 2 > a.length ? this.result = a[0] : (this.result = vb(a, c, d, !1, this.h), d = 0)); return f ? this.resolve(c, d, e) : this; } -;X.prototype.and = function() { +;Z.prototype.and = function() { var a = this.result.length; if (!a) { var b = arguments[0]; @@ -1985,17 +1864,17 @@ function xb(a, b, c, d, e, f) { var f = b.enrich && c; } } - return a ? (a = wb(this, "and", arguments), yb.call(this, a.W, a.$, a.limit, a.offset, a.enrich, a.resolve, a.suggest)) : c ? this.resolve(d, e, f) : this; + return a ? (a = tb(this, "and", arguments), wb.call(this, a.W, a.$, a.limit, a.offset, a.enrich, a.resolve, a.suggest)) : c ? this.resolve(d, e, f) : this; }; -function yb(a, b, c, d, e, f, g) { +function wb(a, b, c, d, e, f, g) { if (b.length) { - var k = this; - return Promise.all(b).then(function(h) { + var h = this; + return Promise.all(b).then(function(k) { a = []; - for (var l = 0, m = void 0; l < h.length; l++) { - (m = h[l]).length && (a[l] = m); + for (var l = 0, m = void 0; l < k.length; l++) { + (m = k[l]).length && (a[l] = m); } - return yb.call(k, a, [], c, d, e, f, g); + return wb.call(h, a, [], c, d, e, f, g); }); } if (a.length) { @@ -2003,7 +1882,7 @@ function yb(a, b, c, d, e, f, g) { this.result = a[0]; } else { if (b = Fa(a)) { - return this.result = rb(a, b, c, d, g, this.h, f), f ? e ? vb.call(this.index, this.result) : this.result : this; + return this.result = xb(a, b, c, d, g, this.h, f), f ? e ? sb.call(this.index, this.result) : this.result : this; } this.result = []; } @@ -2012,36 +1891,36 @@ function yb(a, b, c, d, e, f, g) { } return f ? this.resolve(c, d, e) : this; } -;X.prototype.xor = function() { - var a = wb(this, "xor", arguments); - return zb.call(this, a.W, a.$, a.limit, a.offset, a.enrich, a.resolve, a.suggest); +;Z.prototype.xor = function() { + var a = tb(this, "xor", arguments); + return yb.call(this, a.W, a.$, a.limit, a.offset, a.enrich, a.resolve, a.suggest); }; -function zb(a, b, c, d, e, f, g) { +function yb(a, b, c, d, e, f, g) { if (b.length) { - var k = this; - return Promise.all(b).then(function(h) { + var h = this; + return Promise.all(b).then(function(k) { a = []; - for (var l = 0, m = void 0; l < h.length; l++) { - (m = h[l]).length && (a[l] = m); + for (var l = 0, m = void 0; l < k.length; l++) { + (m = k[l]).length && (a[l] = m); } - return zb.call(k, a, [], c, d, e, f, g); + return yb.call(h, a, [], c, d, e, f, g); }); } if (a.length) { if (this.result.length && a.unshift(this.result), 2 > a.length) { this.result = a[0]; } else { - return this.result = Ab.call(this, a, c, d, f, this.h), f ? e ? vb.call(this.index, this.result) : this.result : this; + return this.result = zb.call(this, a, c, d, f, this.h), f ? e ? sb.call(this.index, this.result) : this.result : this; } } else { g || (this.result = a); } return f ? this.resolve(c, d, e) : this; } -function Ab(a, b, c, d, e) { - for (var f = [], g = Q(), k = 0, h = 0, l; h < a.length; h++) { - if (l = a[h]) { - k < l.length && (k = l.length); +function zb(a, b, c, d, e) { + for (var f = [], g = S(), h = 0, k = 0, l; k < a.length; k++) { + if (l = a[k]) { + h < l.length && (h = l.length); for (var m = 0, q; m < l.length; m++) { if (q = l[m]) { for (var p = 0, n; p < q.length; p++) { @@ -2051,10 +1930,10 @@ function Ab(a, b, c, d, e) { } } } - for (l = h = 0; h < k; h++) { + for (l = k = 0; k < h; k++) { for (m = 0; m < a.length; m++) { if (q = a[m]) { - if (q = q[h]) { + if (q = q[k]) { for (p = 0; p < q.length; p++) { if (n = q[p], 1 === g[n]) { if (c) { @@ -2065,7 +1944,7 @@ function Ab(a, b, c, d, e) { return f; } } else { - var r = h + (m ? e : 0); + var r = k + (m ? e : 0); f[r] || (f[r] = []); f[r].push(n); if (++l === b) { @@ -2081,35 +1960,35 @@ function Ab(a, b, c, d, e) { } return f; } -;X.prototype.not = function() { - var a = wb(this, "not", arguments); - return Bb.call(this, a.W, a.$, a.limit, a.offset, a.enrich, a.resolve, a.suggest); +;Z.prototype.not = function() { + var a = tb(this, "not", arguments); + return Ab.call(this, a.W, a.$, a.limit, a.offset, a.enrich, a.resolve, a.suggest); }; -function Bb(a, b, c, d, e, f, g) { +function Ab(a, b, c, d, e, f, g) { if (b.length) { - var k = this; - return Promise.all(b).then(function(h) { + var h = this; + return Promise.all(b).then(function(k) { a = []; - for (var l = 0, m = void 0; l < h.length; l++) { - (m = h[l]).length && (a[l] = m); + for (var l = 0, m = void 0; l < k.length; l++) { + (m = k[l]).length && (a[l] = m); } - return Bb.call(k, a, [], c, d, e, f, g); + return Ab.call(h, a, [], c, d, e, f, g); }); } if (a.length && this.result.length) { - this.result = Cb.call(this, a, c, d, f); + this.result = Bb.call(this, a, c, d, f); } else if (f) { return this.resolve(c, d, e); } - return f ? e ? vb.call(this.index, this.result) : this.result : this; + return f ? e ? sb.call(this.index, this.result) : this.result : this; } -function Cb(a, b, c, d) { +function Bb(a, b, c, d) { var e = []; a = new Set(a.flat().flat()); - for (var f = 0, g, k = 0; f < this.result.length; f++) { + for (var f = 0, g, h = 0; f < this.result.length; f++) { if (g = this.result[f]) { - for (var h = 0, l; h < g.length; h++) { - if (l = g[h], !a.has(l)) { + for (var k = 0, l; k < g.length; k++) { + if (l = g[k], !a.has(l)) { if (c) { c--; } else { @@ -2118,7 +1997,7 @@ function Cb(a, b, c, d) { return e; } } else { - if (e[f] || (e[f] = []), e[f].push(l), ++k === b) { + if (e[f] || (e[f] = []), e[f].push(l), ++h === b) { return e; } } @@ -2129,7 +2008,7 @@ function Cb(a, b, c, d) { } return e; } -;function Db(a, b, c, d, e) { +;function Cb(a, b, c, d, e) { if ("string" === typeof e) { var f = e; e = ""; @@ -2143,9 +2022,9 @@ function Cb(a, b, c, d) { if (-1 === g) { throw Error('Invalid highlight template. The replacement pattern "$1" was not found in template: ' + f); } - var k = f.substring(g + 2); + var h = f.substring(g + 2); g = f.substring(0, g); - var h = e && e.boundary, l = !e || !1 !== e.clip, m = e && e.merge && k && g && new RegExp(k + " " + g, "g"); + var k = e && e.boundary, l = !e || !1 !== e.clip, m = e && e.merge && h && g && new RegExp(h + " " + g, "g"); e = e && e.ellipsis; var q = 0; if ("object" === typeof e) { @@ -2156,203 +2035,203 @@ function Cb(a, b, c, d) { "string" !== typeof e && (e = !1 === e ? "" : "..."); q && (e = p.replace("$1", e)); p = e.length - q; - if ("object" === typeof h) { - var n = h.before; + if ("object" === typeof k) { + var n = k.before; 0 === n && (n = -1); - var r = h.after; + var r = k.after; 0 === r && (r = -1); - h = h.total || 9e5; + k = k.total || 9e5; } q = new Map(); - for (var v, u = 0, B, D; u < b.length; u++) { + for (var u, x = 0, w, E; x < b.length; x++) { if (d) { - var x = b; - D = d; + var B = b; + E = d; } else { - x = b[u]; - D = x.field; - if (!D) { + B = b[x]; + E = B.field; + if (!E) { continue; } - x = x.result; + B = B.result; } - v = c.get(D); - B = v.encoder; - v = q.get(B); - "string" !== typeof v && (v = B.encode(a), q.set(B, v)); - for (var A = 0; A < x.length; A++) { - var t = x[A].doc; - if (t && (t = Ea(t, D))) { - var E = t.trim().split(/\s+/); - if (E.length) { + u = c.get(E); + w = u.encoder; + u = q.get(w); + "string" !== typeof u && (u = w.encode(a), q.set(w, u)); + for (var y = 0; y < B.length; y++) { + var t = B[y].doc; + if (t && (t = Ea(t, E))) { + var D = t.trim().split(/\s+/); + if (D.length) { t = ""; - for (var C = [], ha = [], G = -1, N = -1, S = 0, F = 0; F < E.length; F++) { - var J = E[F], M = B.encode(J); - M = 1 < M.length ? M.join(" ") : M[0]; - var P = void 0; - if (M && J) { - for (var Y = J.length, Z = (B.split ? J.replace(B.split, "") : J).length - M.length, aa = "", ma = 0, y = 0; y < v.length; y++) { - var H = v[y]; - if (H) { - var K = H.length; - K += Z; - ma && K <= ma || (H = M.indexOf(H), -1 < H && (aa = (H ? J.substring(0, H) : "") + g + J.substring(H, H + K) + k + (H + K < Y ? J.substring(H + K) : ""), ma = K, P = !0)); + for (var C = [], O = [], Q = -1, M = -1, J = 0, F = 0; F < D.length; F++) { + var R = D[F], V = w.encode(R); + V = 1 < V.length ? V.join(" ") : V[0]; + var G = void 0; + if (V && R) { + for (var N = R.length, aa = (w.split ? R.replace(w.split, "") : R).length - V.length, ba = "", ma = 0, z = 0; z < u.length; z++) { + var I = u[z]; + if (I) { + var K = I.length; + K += aa; + ma && K <= ma || (I = V.indexOf(I), -1 < I && (ba = (I ? R.substring(0, I) : "") + g + R.substring(I, I + K) + h + (I + K < N ? R.substring(I + K) : ""), ma = K, G = !0)); } } - aa && (h && (0 > G && (G = t.length + (t ? 1 : 0)), N = t.length + (t ? 1 : 0) + aa.length, S += Y, ha.push(C.length), C.push({match:aa})), t += (t ? " " : "") + aa); + ba && (k && (0 > Q && (Q = t.length + (t ? 1 : 0)), M = t.length + (t ? 1 : 0) + ba.length, J += N, O.push(C.length), C.push({match:ba})), t += (t ? " " : "") + ba); } - if (!P) { - J = E[F], t += (t ? " " : "") + J, h && C.push({text:J}); - } else if (h && S >= h) { + if (!G) { + R = D[F], t += (t ? " " : "") + R, k && C.push({text:R}); + } else if (k && J >= k) { break; } } - S = ha.length * (f.length - 2); - if (n || r || h && t.length - S > h) { - if (S = h + S - 2 * p, F = N - G, 0 < n && (F += n), 0 < r && (F += r), F <= S) { - E = n ? G - (0 < n ? n : 0) : G - ((S - F) / 2 | 0), C = r ? N + (0 < r ? r : 0) : E + S, l || (0 < E && " " !== t.charAt(E) && " " !== t.charAt(E - 1) && (E = t.indexOf(" ", E), 0 > E && (E = 0)), C < t.length && " " !== t.charAt(C - 1) && " " !== t.charAt(C) && (C = t.lastIndexOf(" ", C), C < N ? C = N : ++C)), t = (E ? e : "") + t.substring(E, C) + (C < t.length ? e : ""); + J = O.length * (f.length - 2); + if (n || r || k && t.length - J > k) { + if (J = k + J - 2 * p, F = M - Q, 0 < n && (F += n), 0 < r && (F += r), F <= J) { + D = n ? Q - (0 < n ? n : 0) : Q - ((J - F) / 2 | 0), C = r ? M + (0 < r ? r : 0) : D + J, l || (0 < D && " " !== t.charAt(D) && " " !== t.charAt(D - 1) && (D = t.indexOf(" ", D), 0 > D && (D = 0)), C < t.length && " " !== t.charAt(C - 1) && " " !== t.charAt(C) && (C = t.lastIndexOf(" ", C), C < M ? C = M : ++C)), t = (D ? e : "") + t.substring(D, C) + (C < t.length ? e : ""); } else { - N = []; - S = {}; - G = {}; - F = {}; + M = []; J = {}; - M = {}; - Z = Y = P = 0; - for (ma = aa = 1;;) { - H = void 0; - for (y = 0; y < ha.length; y++) { - K = ha[y]; - if (Z) { - if (Y !== Z) { - if (F[y + 1]) { + Q = {}; + F = {}; + R = {}; + V = {}; + aa = N = G = 0; + for (ma = ba = 1;;) { + I = void 0; + for (z = 0; z < O.length; z++) { + K = O[z]; + if (aa) { + if (N !== aa) { + if (F[z + 1]) { continue; } - K += Z; - if (S[K]) { - P -= p; - G[y + 1] = 1; - F[y + 1] = 1; + K += aa; + if (J[K]) { + G -= p; + Q[z + 1] = 1; + F[z + 1] = 1; continue; } if (K >= C.length - 1) { if (K >= C.length) { - F[y + 1] = 1; - K >= E.length && (G[y + 1] = 1); + F[z + 1] = 1; + K >= D.length && (Q[z + 1] = 1); continue; } - P -= p; + G -= p; } t = C[K].text; - var T = r && M[y]; - if (T) { - if (0 < T) { - if (t.length > T) { - if (F[y + 1] = 1, l) { - t = t.substring(0, T); + var U = r && V[z]; + if (U) { + if (0 < U) { + if (t.length > U) { + if (F[z + 1] = 1, l) { + t = t.substring(0, U); } else { continue; } } - (T -= t.length) || (T = -1); - M[y] = T; + (U -= t.length) || (U = -1); + V[z] = U; } else { - F[y + 1] = 1; + F[z + 1] = 1; continue; } } - if (P + t.length + 1 <= h) { - t = " " + t, N[y] += t; + if (G + t.length + 1 <= k) { + t = " " + t, M[z] += t; } else if (l) { - H = h - P - 1, 0 < H && (t = " " + t.substring(0, H), N[y] += t), F[y + 1] = 1; + I = k - G - 1, 0 < I && (t = " " + t.substring(0, I), M[z] += t), F[z + 1] = 1; } else { - F[y + 1] = 1; + F[z + 1] = 1; continue; } } else { - if (F[y]) { + if (F[z]) { continue; } - K -= Y; - if (S[K]) { - P -= p; - F[y] = 1; - G[y] = 1; + K -= N; + if (J[K]) { + G -= p; + F[z] = 1; + Q[z] = 1; continue; } if (0 >= K) { if (0 > K) { - F[y] = 1; - G[y] = 1; + F[z] = 1; + Q[z] = 1; continue; } - P -= p; + G -= p; } t = C[K].text; - if (T = n && J[y]) { - if (0 < T) { - if (t.length > T) { - if (F[y] = 1, l) { - t = t.substring(t.length - T); + if (U = n && R[z]) { + if (0 < U) { + if (t.length > U) { + if (F[z] = 1, l) { + t = t.substring(t.length - U); } else { continue; } } - (T -= t.length) || (T = -1); - J[y] = T; + (U -= t.length) || (U = -1); + R[z] = U; } else { - F[y] = 1; + F[z] = 1; continue; } } - if (P + t.length + 1 <= h) { - t += " ", N[y] = t + N[y]; + if (G + t.length + 1 <= k) { + t += " ", M[z] = t + M[z]; } else if (l) { - H = t.length + 1 - (h - P), 0 <= H && H < t.length && (t = t.substring(H) + " ", N[y] = t + N[y]), F[y] = 1; + I = t.length + 1 - (k - G), 0 <= I && I < t.length && (t = t.substring(I) + " ", M[z] = t + M[z]), F[z] = 1; } else { - F[y] = 1; + F[z] = 1; continue; } } } else { t = C[K].match; - n && (J[y] = n); - r && (M[y] = r); - y && P++; - H = void 0; - K ? !y && p && (P += p) : (G[y] = 1, F[y] = 1); - K >= E.length - 1 ? H = 1 : K < C.length - 1 && C[K + 1].match ? H = 1 : p && (P += p); - P -= f.length - 2; - if (!y || P + t.length <= h) { - N[y] = t; + n && (R[z] = n); + r && (V[z] = r); + z && G++; + I = void 0; + K ? !z && p && (G += p) : (Q[z] = 1, F[z] = 1); + K >= D.length - 1 ? I = 1 : K < C.length - 1 && C[K + 1].match ? I = 1 : p && (G += p); + G -= f.length - 2; + if (!z || G + t.length <= k) { + M[z] = t; } else { - H = aa = ma = G[y] = 0; + I = ba = ma = Q[z] = 0; break; } - H && (G[y + 1] = 1, F[y + 1] = 1); + I && (Q[z + 1] = 1, F[z + 1] = 1); } - P += t.length; - H = S[K] = 1; + G += t.length; + I = J[K] = 1; } - if (H) { - Y === Z ? Z++ : Y++; + if (I) { + N === aa ? aa++ : N++; } else { - Y === Z ? aa = 0 : ma = 0; - if (!aa && !ma) { + N === aa ? ba = 0 : ma = 0; + if (!ba && !ma) { break; } - aa ? (Y++, Z = Y) : Z++; + ba ? (N++, aa = N) : aa++; } } t = ""; - for (E = 0; E < N.length; E++) { - C = (E && G[E] ? " " : (E && !e ? " " : "") + e) + N[E], t += C; + for (D = 0; D < M.length; D++) { + C = (D && Q[D] ? " " : (D && !e ? " " : "") + e) + M[D], t += C; } - e && !G[N.length] && (t += e); + e && !Q[M.length] && (t += e); } } m && (t = t.replace(m, " ")); - x[A].highlight = t; + B[y].highlight = t; } } } @@ -2362,9 +2241,9 @@ function Cb(a, b, c, d) { } return b; } -;function X(a, b) { - if (!this || this.constructor !== X) { - return new X(a, b); +;function Z(a, b) { + if (!this || this.constructor !== Z) { + return new Z(a, b); } if (a && a.index) { return a.resolve = !1, this.index = a.index, this.h = a.boost || 0, this.result = this.index.search(a).result, this; @@ -2373,7 +2252,7 @@ function Cb(a, b, c, d) { this.result = a || []; this.h = 0; } -X.prototype.limit = function(a) { +Z.prototype.limit = function(a) { if (this.result.length) { for (var b = [], c = 0, d; c < this.result.length; c++) { if (d = this.result[c]) { @@ -2391,7 +2270,7 @@ X.prototype.limit = function(a) { } return this; }; -X.prototype.offset = function(a) { +Z.prototype.offset = function(a) { if (this.result.length) { for (var b = [], c = 0, d; c < this.result.length; c++) { if (d = this.result[c]) { @@ -2402,17 +2281,140 @@ X.prototype.offset = function(a) { } return this; }; -X.prototype.boost = function(a) { +Z.prototype.boost = function(a) { this.h += a; return this; }; -X.prototype.resolve = function(a, b, c) { +Z.prototype.resolve = function(a, b, c) { var d = this.index, e = this.result; this.result = this.index = null; - e.length && ("object" === typeof a && (c = a.enrich, b = a.offset, a = a.limit), e = ub.call(d, e, a || 100, b, c)); + e.length && ("object" === typeof a && (c = a.enrich, b = a.offset, a = a.limit), e = rb.call(d, e, a || 100, b, c)); return e; }; -Q(); +function xb(a, b, c, d, e, f, g) { + var h = a.length, k = []; + var l = S(); + for (var m = 0, q = void 0, p, n; m < b; m++) { + for (var r = 0; r < h; r++) { + var u = a[r]; + if (m < u.length && (q = u[m])) { + for (var x = 0; x < q.length; x++) { + p = q[x]; + (u = l[p]) ? l[p]++ : (u = 0, l[p] = 1); + n = k[u] || (k[u] = []); + if (!g) { + var w = m + (r || !e ? 0 : f || 0); + n = n[w] || (n[w] = []); + } + n.push(p); + if (g && c && u === h - 1 && n.length - d === c) { + return d ? n.slice(d) : n; + } + } + } + } + } + if (a = k.length) { + if (e) { + k = 1 < k.length ? vb(k, c, d, g, f) : (k = k[0]).length > c || d ? k.slice(d, c + d) : k; + } else { + if (a < h) { + return []; + } + k = k[a - 1]; + if (c || d) { + if (g) { + if (k.length > c || d) { + k = k.slice(d, c + d); + } + } else { + e = []; + for (f = 0; f < k.length; f++) { + if (g = k[f]) { + if (d && g.length > d) { + d -= g.length; + } else { + if (c && g.length > c || d) { + g = g.slice(d, c + d), c -= g.length, d && (d -= g.length); + } + e.push(g); + if (!c) { + break; + } + } + } + } + k = e; + } + } + } + } + return k; +} +function vb(a, b, c, d, e) { + var f = [], g = S(), h = a.length, k; + if (d) { + for (e = h - 1; 0 <= e; e--) { + if (k = (d = a[e]) && d.length) { + for (h = 0; h < k; h++) { + var l = d[h]; + if (!g[l]) { + if (g[l] = 1, c) { + c--; + } else { + if (f.push(l), f.length === b) { + return f; + } + } + } + } + } + } + } else { + for (var m = h - 1, q, p = 0; 0 <= m; m--) { + q = a[m]; + for (var n = 0; n < q.length; n++) { + if (k = (d = q[n]) && d.length) { + for (var r = 0; r < k; r++) { + if (l = d[r], !g[l]) { + if (g[l] = 1, c) { + c--; + } else { + var u = (n + (m < h - 1 ? e || 0 : 0)) / (m + 1) | 0; + (f[u] || (f[u] = [])).push(l); + if (++p === b) { + return f; + } + } + } + } + } + } + } + } + return f; +} +function Db(a, b, c) { + for (var d = S(), e = [], f = 0, g; f < b.length; f++) { + g = b[f]; + for (var h = 0; h < g.length; h++) { + d[g[h]] = 1; + } + } + if (c) { + for (b = 0; b < a.length; b++) { + c = a[b], d[c] && (e.push(c), d[c] = 0); + } + } else { + for (b = 0; b < a.result.length; b++) { + for (c = a.result[b], g = 0; g < c.length; g++) { + f = c[g], d[f] && ((e[b] || (e[b] = [])).push(f), d[f] = 0); + } + } + } + return e; +} +;S(); ob.prototype.search = function(a, b, c, d) { c || (!b && Ca(a) ? (c = a, a = "") : Ca(b) && (c = b, b = 0)); if (c && c.cache) { @@ -2421,223 +2423,228 @@ ob.prototype.search = function(a, b, c, d) { c.cache = !0; return e; } - var f = [], g = [], k = 0, h = !0; + var f = [], g = [], h = 0, k = !0; if (c) { c.constructor === Array && (c = {index:c}); a = c.query || a; var l = c.pluck; var m = c.merge; - var q = l || c.field || (q = c.index) && (q.index ? null : q); - var p = this.tag && c.tag; - var n = c.suggest; - h = !1 !== c.resolve; - if (!h && !l) { - if (q = q || this.field) { - R(q) ? l = q : (q.constructor === Array && 1 === q.length && (q = q[0]), l = q.field || q.index); + var q = c.boost; + var p = l || c.field || (p = c.index) && (p.index ? null : p); + var n = this.tag && c.tag; + var r = c.suggest; + k = !1 !== c.resolve; + this.store && c.highlight && !k ? console.warn("Highlighting results can only be done on a final resolver task or when calling .resolve({ highlight: ... })") : this.store && c.enrich && !k && console.warn("Enrich results can only be done on a final resolver task or when calling .resolve({ enrich: true })"); + var u = k && this.store && c.highlight; + e = !!u || k && this.store && c.enrich; + b = c.limit || b; + var x = c.offset || 0; + b || (b = k ? 100 : 0); + if (n && (!this.db || !d)) { + n.constructor !== Array && (n = [n]); + for (var w = [], E = 0, B = void 0; E < n.length; E++) { + B = n[E]; + if (T(B)) { + throw Error("A tag option can't be a string, instead it needs a { field: tag } format."); + } + if (B.field && B.tag) { + var y = B.tag; + if (y.constructor === Array) { + for (var t = 0; t < y.length; t++) { + w.push(B.field, y[t]); + } + } else { + w.push(B.field, y); + } + } else { + y = Object.keys(B); + t = 0; + for (var D = void 0, C = void 0; t < y.length; t++) { + if (D = y[t], C = B[D], C.constructor === Array) { + for (var O = 0; O < C.length; O++) { + w.push(D, C[O]); + } + } else { + w.push(D, C); + } + } + } + } + if (!w.length) { + throw Error("Your tag definition within the search options is probably wrong. No valid tags found."); + } + n = w; + if (!a) { + g = []; + if (w.length) { + for (n = 0; n < w.length; n += 2) { + d = void 0; + if (this.db) { + d = this.index.get(w[n]); + if (!d) { + console.warn("Tag '" + w[n] + ":" + w[n + 1] + "' will be skipped because there is no field '" + w[n] + "'."); + continue; + } + g.push(d = d.db.tag(w[n + 1], b, x, e)); + } else { + d = Eb.call(this, w[n], w[n + 1], b, x, e); + } + f.push(k ? {field:w[n], tag:w[n + 1], result:d} : [d]); + } + } + if (g.length) { + var Q = this; + return Promise.all(g).then(function(G) { + for (var N = 0; N < G.length; N++) { + k ? f[N].result = G[N] : f[N] = G[N]; + } + return k ? f : new Z(1 < f.length ? xb(f, 1, 0, 0, r, q) : f[0], Q); + }); + } + return k ? f : new Z(1 < f.length ? xb(f, 1, 0, 0, r, q) : f[0], this); + } + } + if (!k && !l) { + if (p = p || this.field) { + T(p) ? l = p : (p.constructor === Array && 1 === p.length && (p = p[0]), l = p.field || p.index); } if (!l) { throw Error("Apply resolver on document search requires either the option 'pluck' to be set or just select a single field name in your query."); } } - this.store && c.highlight && !h ? console.warn("Highlighting results can only be done on a final resolver task or when calling .resolve({ highlight: ... })") : this.store && c.enrich && !h && console.warn("Enrich results can only be done on a final resolver task or when calling .resolve({ enrich: true })"); - var r = h && this.store && c.highlight; - e = !!r || h && this.store && c.enrich; - b = c.limit || b; - var v = c.offset || 0; - b || (b = 100); - if (p && (!this.db || !d)) { - p.constructor !== Array && (p = [p]); - for (var u = [], B = 0, D = void 0; B < p.length; B++) { - D = p[B]; - if (R(D)) { - throw Error("A tag option can't be a string, instead it needs a { field: tag } format."); - } - if (D.field && D.tag) { - var x = D.tag; - if (x.constructor === Array) { - for (var A = 0; A < x.length; A++) { - u.push(D.field, x[A]); - } - } else { - u.push(D.field, x); - } - } else { - x = Object.keys(D); - A = 0; - for (var t = void 0, E = void 0; A < x.length; A++) { - if (t = x[A], E = D[t], E.constructor === Array) { - for (var C = 0; C < E.length; C++) { - u.push(t, E[C]); - } - } else { - u.push(t, E); - } - } - } - } - if (!u.length) { - throw Error("Your tag definition within the search options is probably wrong. No valid tags found."); - } - p = u; - if (!a) { - h = []; - if (u.length) { - for (g = 0; g < u.length; g += 2) { - n = void 0; - if (this.db) { - n = this.index.get(u[g]); - if (!n) { - console.warn("Tag '" + u[g] + ":" + u[g + 1] + "' will be skipped because there is no field '" + u[g] + "'."); - continue; - } - h.push(n = n.db.tag(u[g + 1], b, v, e)); - } else { - n = Eb.call(this, u[g], u[g + 1], b, v, e); - } - f.push({field:u[g], tag:u[g + 1], result:n}); - } - } - return h.length ? Promise.all(h).then(function(J) { - for (var M = 0; M < J.length; M++) { - f[M].result = J[M]; - } - return f; - }) : f; - } - } - q && q.constructor !== Array && (q = [q]); + p && p.constructor !== Array && (p = [p]); } - q || (q = this.field); - u = (this.worker || this.db) && !d && []; - B = 0; - for (A = D = x = void 0; B < q.length; B++) { - if (D = q[B], !this.db || !this.tag || this.L[B]) { - x = void 0; - R(D) || (x = D, D = x.field, a = x.query || a, b = Fb(x.limit, b), v = Fb(x.offset, v), n = Fb(x.suggest, n), r = h && this.store && Fb(x.highlight, r), e = !!r || h && this.store && Fb(x.enrich, e)); + p || (p = this.field); + w = (this.worker || this.db) && !d && []; + E = 0; + for (t = B = y = void 0; E < p.length; E++) { + if (B = p[E], !this.db || !this.tag || this.L[E]) { + y = void 0; + T(B) || (y = B, B = y.field, a = y.query || a, b = Fb(y.limit, b), x = Fb(y.offset, x), r = Fb(y.suggest, r), u = k && this.store && Fb(y.highlight, u), e = !!u || k && this.store && Fb(y.enrich, e)); if (d) { - x = d[B]; + y = d[E]; } else { - A = x || c; - x = this.index.get(D); - if (p) { + t = y || c; + y = this.index.get(B); + if (n) { if (this.db) { - A.tag = p; - var ha = x.db.support_tag_search; - A.field = q; + t.tag = n; + var M = y.db.support_tag_search; + t.field = p; } - ha || (A.enrich = !1); + M || (t.enrich = !1); } - if (u) { - u[B] = x.search(a, b, A); - A && e && (A.enrich = e); + if (w) { + w[E] = y.search(a, b, t); + t && e && (t.enrich = e); continue; } else { - x = x.search(a, b, A), A && e && (A.enrich = e); + y = y.search(a, b, t), t && e && (t.enrich = e); } } - A = x && (h ? x.length : x.result.length); - if (p && A) { - t = []; - E = 0; + t = y && (k ? y.length : y.result.length); + if (n && t) { + D = []; + C = 0; if (this.db && d) { - if (!ha) { - for (C = q.length; C < d.length; C++) { - var G = d[C]; - if (G && G.length) { - E++, t.push(G); - } else if (!n) { - return h ? f : new X(f, this); + if (!M) { + for (O = p.length; O < d.length; O++) { + var J = d[O]; + if (J && J.length) { + C++, D.push(J); + } else if (!r) { + return k ? f : new Z(f, this); } } } } else { - C = 0; - for (var N = G = void 0; C < p.length; C += 2) { - G = this.tag.get(p[C]); - if (!G) { - if (console.warn("Tag '" + p[C] + ":" + p[C + 1] + "' will be skipped because there is no field '" + p[C] + "'."), n) { + O = 0; + for (var F = J = void 0; O < n.length; O += 2) { + J = this.tag.get(n[O]); + if (!J) { + if (console.warn("Tag '" + n[O] + ":" + n[O + 1] + "' will be skipped because there is no field '" + n[O] + "'."), r) { continue; } else { - return h ? f : new X(f, this); + return k ? f : new Z(f, this); } } - if (N = (G = G && G.get(p[C + 1])) && G.length) { - E++, t.push(G); - } else if (!n) { - return h ? f : new X(f, this); + if (F = (J = J && J.get(n[O + 1])) && J.length) { + C++, D.push(J); + } else if (!r) { + return k ? f : new Z(f, this); } } } - if (E) { - x = tb(x, t, h); - A = x.length; - if (!A && !n) { - return h ? x : new X(x, this); + if (C) { + y = Db(y, D, k); + t = y.length; + if (!t && !r) { + return k ? y : new Z(y, this); } - E--; + C--; } } - if (A) { - g[k] = D, f.push(x), k++; - } else if (1 === q.length) { - return h ? f : new X(f, this); + if (t) { + g[h] = B, f.push(y), h++; + } else if (1 === p.length) { + return k ? f : new Z(f, this); } } } - if (u) { - if (this.db && p && p.length && !ha) { - for (e = 0; e < p.length; e += 2) { - g = this.index.get(p[e]); + if (w) { + if (this.db && n && n.length && !M) { + for (e = 0; e < n.length; e += 2) { + g = this.index.get(n[e]); if (!g) { - if (console.warn("Tag '" + p[e] + ":" + p[e + 1] + "' was not found because there is no field '" + p[e] + "'."), n) { + if (console.warn("Tag '" + n[e] + ":" + n[e + 1] + "' was not found because there is no field '" + n[e] + "'."), r) { continue; } else { - return h ? f : new X(f, this); + return k ? f : new Z(f, this); } } - u.push(g.db.tag(p[e + 1], b, v, !1)); + w.push(g.db.tag(n[e + 1], b, x, !1)); } } - var S = this; - return Promise.all(u).then(function(J) { - return J.length ? S.search(a, b, c, J) : J; + var R = this; + return Promise.all(w).then(function(G) { + return G.length ? R.search(a, b, c, G) : G; }); } - if (!k) { - return h ? f : new X(f, this); + if (!h) { + return k ? f : new Z(f, this); } if (l && (!e || !this.store)) { - return f = f[0], h || (f.index = this), f; + return f = f[0], k || (f.index = this), f; } - u = []; - for (v = 0; v < g.length; v++) { - n = f[v]; - e && n.length && "undefined" === typeof n[0].doc && (this.db ? u.push(n = this.index.get(this.field[0]).db.enrich(n)) : n = vb.call(this, n)); + w = []; + for (x = 0; x < g.length; x++) { + n = f[x]; + e && n.length && "undefined" === typeof n[0].doc && (this.db ? w.push(n = this.index.get(this.field[0]).db.enrich(n)) : n = sb.call(this, n)); if (l) { - return h ? r ? Db(a, n, this.index, l, r) : n : new X(n, this); + return k ? u ? Cb(a, n, this.index, l, u) : n : new Z(n, this); } - f[v] = {field:g[v], result:n}; + f[x] = {field:g[x], result:n}; } - if (e && this.db && u.length) { - var F = this; - return Promise.all(u).then(function(J) { - for (var M = 0; M < J.length; M++) { - f[M].result = J[M]; + if (e && this.db && w.length) { + var V = this; + return Promise.all(w).then(function(G) { + for (var N = 0; N < G.length; N++) { + f[N].result = G[N]; } - return m ? Gb(f) : r ? Db(a, f, F.index, l, r) : f; + return m ? Gb(f) : u ? Cb(a, f, V.index, l, u) : f; }); } - return m ? Gb(f) : r ? Db(a, f, this.index, l, r) : f; + return m ? Gb(f) : u ? Cb(a, f, this.index, l, u) : f; }; function Fb(a, b) { return "undefined" === typeof a ? b : a; } function Gb(a) { - for (var b = [], c = Q(), d = 0, e, f; d < a.length; d++) { + for (var b = [], c = S(), d = 0, e, f; d < a.length; d++) { e = a[d]; f = e.result; - for (var g = 0, k, h, l; g < f.length; g++) { - h = f[g], "object" !== typeof h && (h = {id:h}), k = h.id, (l = c[k]) ? l.push(e.field) : (h.field = c[k] = [e.field], b.push(h)); + for (var g = 0, h, k, l; g < f.length; g++) { + k = f[g], "object" !== typeof k && (k = {id:k}), h = k.id, (l = c[h]) ? l.push(e.field) : (k.field = c[h] = [e.field], b.push(k)); } } return b; @@ -2645,17 +2652,17 @@ function Gb(a) { function Eb(a, b, c, d, e) { var f = this.tag.get(a); if (!f) { - return console.warn("Tag '" + a + "' was not found"), []; + return console.warn("Tag-Field '" + a + "' was not found"), []; } if ((a = (f = f && f.get(b)) && f.length - d) && 0 < a) { - if (a > c || d) { + if (c && a > c || d) { f = f.slice(d, d + c); } - e && (f = vb.call(this, f)); + e && (f = sb.call(this, f)); return f; } } -function vb(a) { +function sb(a) { if (!this || !this.store) { return a; } @@ -2664,7 +2671,19 @@ function vb(a) { } return b; } -;function ob(a) { +;var Hb = {normalize:!1, numeric:!1, dedupe:!1}; +var Ib = {}; +var Jb = new Map([["b", "p"], ["v", "f"], ["w", "f"], ["z", "s"], ["x", "s"], ["d", "t"], ["n", "m"], ["c", "k"], ["g", "k"], ["j", "k"], ["q", "k"], ["i", "e"], ["y", "e"], ["u", "o"]]); +var Kb = new Map([["ae", "a"], ["oe", "o"], ["sh", "s"], ["kh", "k"], ["th", "t"], ["ph", "f"], ["pf", "f"]]), Lb = [/([^aeo])h(.)/g, "$1$2", /([aeo])h([^aeo]|$)/g, "$1$2", /(.)\1+/g, "$1"]; +var Mb = {a:"", e:"", i:"", o:"", u:"", y:"", b:1, f:1, p:1, v:1, c:2, g:2, j:2, k:2, q:2, s:2, x:2, z:2, "\u00df":2, d:3, t:3, l:4, m:5, n:5, r:6}; +var Nb = {Exact:Hb, Default:Ib, Normalize:Ib, LatinBalance:{mapper:Jb}, LatinAdvanced:{mapper:Jb, matcher:Kb, replacer:Lb}, LatinExtra:{mapper:Jb, replacer:Lb.concat([/(?!^)[aeo]/g, ""]), matcher:Kb}, LatinSoundex:{dedupe:!1, include:{letter:!0}, finalize:function(a) { + for (var b = 0; b < a.length; b++) { + for (var c = a[b], d = c.charAt(0), e = Mb[d], f = 1, g; f < c.length && (g = c.charAt(f), "h" === g || "w" === g || !(g = Mb[g]) || g === e || (d += g, e = g, 4 !== d.length)); f++) { + } + a[b] = d; + } +}}, CJK:{split:""}, LatinExact:Hb, LatinDefault:Ib, LatinSimple:Ib}; +function ob(a) { if (!this || this.constructor !== ob) { return new ob(a); } @@ -2672,17 +2691,17 @@ function vb(a) { this.L = []; this.field = []; this.S = []; - this.key = (c = b.key || b.id) && Hb(c, this.S) || "id"; + this.key = (c = b.key || b.id) && Ob(c, this.S) || "id"; (d = a.keystore || 0) && (this.keystore = d); this.fastupdate = !!a.fastupdate; - this.reg = !this.fastupdate || a.worker || a.db ? d ? new W(d) : new Set() : d ? new V(d) : new Map(); + this.reg = !this.fastupdate || a.worker || a.db ? d ? new Y(d) : new Set() : d ? new X(d) : new Map(); this.I = (c = b.store || null) && c && !0 !== c && []; - this.store = c && (d ? new V(d) : new Map()); - this.cache = (c = a.cache || null) && new Ib(c); + this.store = c && (d ? new X(d) : new Map()); + this.cache = (c = a.cache || null) && new Pb(c); a.cache = !1; this.worker = a.worker || !1; this.priority = a.priority || 4; - this.index = Jb.call(this, a, b); + this.index = Qb.call(this, a, b); this.tag = null; if (c = b.tag) { if ("string" === typeof c && (c = [c]), c.length) { @@ -2696,7 +2715,7 @@ function vb(a) { if (!e) { throw Error("The tag field from the document descriptor is undefined."); } - d.custom ? this.K[b] = d.custom : (this.K[b] = Hb(e, this.S), d.filter && ("string" === typeof this.K[b] && (this.K[b] = new String(this.K[b])), this.K[b].R = d.filter)); + d.custom ? this.K[b] = d.custom : (this.K[b] = Ob(e, this.S), d.filter && ("string" === typeof this.K[b] && (this.K[b] = new String(this.K[b])), this.K[b].R = d.filter)); this.aa[b] = e; this.tag.set(e, new Map()); } @@ -2704,29 +2723,29 @@ function vb(a) { } if (this.worker) { this.fastupdate = !1; - var f = []; - a = z(this.index.values()); - for (c = a.next(); !c.done; c = a.next()) { - c = c.value, c.then && f.push(c); + a = []; + c = A(this.index.values()); + for (b = c.next(); !b.done; b = c.next()) { + b = b.value, b.then && a.push(b); } - if (f.length) { - var g = this; - return Promise.all(f).then(function(k) { - for (var h = new Map(), l = 0, m = z(g.index.entries()), q = m.next(); !q.done; q = m.next()) { - var p = q.value; - q = p[0]; - var n = p[1]; - n.then && (n = f[l].encoder || {}, p = h.get(n), p || (p = n.encode ? n : new La(n), h.set(n, p)), n = k[l], n.encoder = p, g.index.set(q, n), l++); + if (a.length) { + var f = this; + return Promise.all(a).then(function(g) { + for (var h = 0, k = A(f.index.entries()), l = k.next(); !l.done; l = k.next()) { + var m = l.value; + l = m[0]; + m = m[1]; + m.then && (m = g[h], f.index.set(l, m), h++); } - return g; + return f; }); } } else { a.db && (this.fastupdate = !1, this.mount(a.db)); } } -w = ob.prototype; -w.mount = function(a) { +v = ob.prototype; +v.mount = function(a) { if (this.worker) { throw Error("You can't use Worker-Indexes on a persistent model. That would be useless, since each of the persistent model acts like Worker-Index by default (Master/Slave)."); } @@ -2735,7 +2754,7 @@ w.mount = function(a) { for (var c = 0, d = void 0; c < this.aa.length; c++) { d = this.aa[c]; var e = void 0; - this.index.set(d, e = new U({}, this.reg)); + this.index.set(d, e = new W({}, this.reg)); b === this.field && (b = b.slice(0)); b.push(d); e.tag = this.tag.get(d); @@ -2754,78 +2773,78 @@ w.mount = function(a) { f.document = !0; e ? f.bypass = !0 : f.store = this.store; } - var k = this; + var h = this; return this.db = Promise.all(c).then(function() { - k.db = !0; + h.db = !0; }); }; -w.commit = function(a, b) { +v.commit = function(a, b) { var c = this, d, e, f, g; - return xa(function(k) { - if (1 == k.h) { + return xa(function(h) { + if (1 == h.h) { d = []; - e = z(c.index.values()); + e = A(c.index.values()); for (f = e.next(); !f.done; f = e.next()) { g = f.value, d.push(g.commit(a, b)); } - return L(k, Promise.all(d), 2); + return L(h, Promise.all(d), 2); } c.reg.clear(); - k.h = 0; + h.h = 0; }); }; -w.destroy = function() { - for (var a = [], b = z(this.index.values()), c = b.next(); !c.done; c = b.next()) { +v.destroy = function() { + for (var a = [], b = A(this.index.values()), c = b.next(); !c.done; c = b.next()) { a.push(c.value.destroy()); } return Promise.all(a); }; -function Jb(a, b) { +function Qb(a, b) { var c = new Map(), d = b.index || b.field || b; - R(d) && (d = [d]); + T(d) && (d = [d]); for (var e = 0, f, g = void 0; e < d.length; e++) { f = d[e]; - R(f) || (g = f, f = f.field); + T(f) || (g = f, f = f.field); g = Ca(g) ? Object.assign({}, a, g) : a; if (this.worker) { - var k = new Xa(g); - k.encoder = g.encoder; - c.set(f, k); + var h = (h = g.encoder) && h.encode ? h : new La("string" === typeof h ? Nb[h] : h); + h = new Xa(g, h); + c.set(f, h); } - this.worker || c.set(f, new U(g, this.reg)); - g.custom ? this.L[e] = g.custom : (this.L[e] = Hb(f, this.S), g.filter && ("string" === typeof this.L[e] && (this.L[e] = new String(this.L[e])), this.L[e].R = g.filter)); + this.worker || c.set(f, new W(g, this.reg)); + g.custom ? this.L[e] = g.custom : (this.L[e] = Ob(f, this.S), g.filter && ("string" === typeof this.L[e] && (this.L[e] = new String(this.L[e])), this.L[e].R = g.filter)); this.field[e] = f; } if (this.I) { - for (a = b.store, R(a) && (a = [a]), b = 0; b < a.length; b++) { - d = a[b], e = d.field || d, d.custom ? (this.I[b] = d.custom, d.custom.ja = e) : (this.I[b] = Hb(e, this.S), d.filter && ("string" === typeof this.I[b] && (this.I[b] = new String(this.I[b])), this.I[b].R = d.filter)); + for (a = b.store, T(a) && (a = [a]), b = 0; b < a.length; b++) { + d = a[b], e = d.field || d, d.custom ? (this.I[b] = d.custom, d.custom.ja = e) : (this.I[b] = Ob(e, this.S), d.filter && ("string" === typeof this.I[b] && (this.I[b] = new String(this.I[b])), this.I[b].R = d.filter)); } } return c; } -function Hb(a, b) { +function Ob(a, b) { for (var c = a.split(":"), d = 0, e = 0; e < c.length; e++) { a = c[e], "]" === a[a.length - 1] && (a = a.substring(0, a.length - 2)) && (b[d] = !0), a && (c[d++] = a); } d < c.length && (c.length = d); return 1 < d ? c : c[0]; } -w.append = function(a, b) { +v.append = function(a, b) { return this.add(a, b, !0); }; -w.update = function(a, b) { +v.update = function(a, b) { return this.remove(a).add(a, b); }; -w.remove = function(a) { +v.remove = function(a) { Ca(a) && (a = Ea(a, this.key)); - for (var b = z(this.index.values()), c = b.next(); !c.done; c = b.next()) { + for (var b = A(this.index.values()), c = b.next(); !c.done; c = b.next()) { c.value.remove(a, !0); } if (this.reg.has(a)) { if (this.tag && !this.fastupdate) { - for (b = z(this.tag.values()), c = b.next(); !c.done; c = b.next()) { + for (b = A(this.tag.values()), c = b.next(); !c.done; c = b.next()) { c = c.value; - for (var d = z(c), e = d.next(); !e.done; e = d.next()) { + for (var d = A(c), e = d.next(); !e.done; e = d.next()) { var f = e.value; e = f[0]; f = f[1]; @@ -2840,12 +2859,12 @@ w.remove = function(a) { this.cache && this.cache.remove(a); return this; }; -w.clear = function() { - for (var a = [], b = z(this.index.values()), c = b.next(); !c.done; c = b.next()) { +v.clear = function() { + for (var a = [], b = A(this.index.values()), c = b.next(); !c.done; c = b.next()) { c = c.value.clear(), c.then && a.push(c); } if (this.tag) { - for (b = z(this.tag.values()), c = b.next(); !c.done; c = b.next()) { + for (b = A(this.tag.values()), c = b.next(); !c.done; c = b.next()) { c.value.clear(); } } @@ -2853,27 +2872,27 @@ w.clear = function() { this.cache && this.cache.clear(); return a.length ? Promise.all(a) : this; }; -w.contain = function(a) { +v.contain = function(a) { return this.db ? this.index.get(this.field[0]).db.has(a) : this.reg.has(a); }; -w.cleanup = function() { - for (var a = z(this.index.values()), b = a.next(); !b.done; b = a.next()) { +v.cleanup = function() { + for (var a = A(this.index.values()), b = a.next(); !b.done; b = a.next()) { b.value.cleanup(); } return this; }; -w.get = function(a) { +v.get = function(a) { return this.db ? this.index.get(this.field[0]).db.enrich(a).then(function(b) { return b[0] && b[0].doc || null; }) : this.store.get(a) || null; }; -w.set = function(a, b) { +v.set = function(a, b) { "object" === typeof a && (b = a, a = Ea(b, this.key)); this.store.set(a, b); return this; }; -w.searchCache = Kb; -w.export = function(a, b, c, d) { +v.searchCache = Rb; +v.export = function(a, b, c, d) { c = void 0 === c ? 0 : c; d = void 0 === d ? 0 : d; if (c < this.field.length) { @@ -2889,25 +2908,25 @@ w.export = function(a, b, c, d) { switch(d) { case 0: var g = "reg"; - var k = db(this.reg); + var h = db(this.reg); b = null; break; case 1: g = "tag"; - k = this.tag && bb(this.tag, this.reg.size); + h = this.tag && bb(this.tag, this.reg.size); b = null; break; case 2: g = "doc"; - k = this.store && $a(this.store); + h = this.store && $a(this.store); b = null; break; default: return; } - return fb.call(this, a, b, g, k, c, d); + return fb.call(this, a, b, g, h, c, d); }; -w.import = function(a, b) { +v.import = function(a, b) { var c = a.split("."); "json" === c[c.length - 1] && c.pop(); var d = 2 < c.length ? c[0] : ""; @@ -2929,7 +2948,7 @@ w.import = function(a, b) { } if (this.worker) { b = []; - d = z(this.index.values()); + d = A(this.index.values()); for (c = d.next(); !c.done; c = d.next()) { b.push(c.value.import(a)); } @@ -2945,9 +2964,9 @@ w.import = function(a, b) { } }; Qa(ob.prototype); -function Kb(a, b, c) { +function Rb(a, b, c) { var d = (b ? "" + a : "object" === typeof a ? "" + a.query : a).toLowerCase(); - this.cache || (this.cache = new Ib()); + this.cache || (this.cache = new Pb()); var e = this.cache.get(d); if (!e) { e = this.search(a, b, c); @@ -2962,44 +2981,32 @@ function Kb(a, b, c) { } return e; } -function Ib(a) { +function Pb(a) { this.limit = a && !0 !== a ? a : 1000; this.cache = new Map(); this.h = ""; } -Ib.prototype.set = function(a, b) { +Pb.prototype.set = function(a, b) { this.cache.set(this.h = a, b); this.cache.size > this.limit && this.cache.delete(this.cache.keys().next().value); }; -Ib.prototype.get = function(a) { +Pb.prototype.get = function(a) { var b = this.cache.get(a); b && this.h !== a && (this.cache.delete(a), this.cache.set(this.h = a, b)); return b; }; -Ib.prototype.remove = function(a) { - for (var b = z(this.cache), c = b.next(); !c.done; c = b.next()) { +Pb.prototype.remove = function(a) { + for (var b = A(this.cache), c = b.next(); !c.done; c = b.next()) { c = c.value; var d = c[0]; c[1].includes(a) && this.cache.delete(d); } }; -Ib.prototype.clear = function() { +Pb.prototype.clear = function() { this.cache.clear(); this.h = ""; }; -var Lb = {normalize:!1, numeric:!1, dedupe:!1}; -var Mb = {}; -var Nb = new Map([["b", "p"], ["v", "f"], ["w", "f"], ["z", "s"], ["x", "s"], ["d", "t"], ["n", "m"], ["c", "k"], ["g", "k"], ["j", "k"], ["q", "k"], ["i", "e"], ["y", "e"], ["u", "o"]]); -var Ob = new Map([["ae", "a"], ["oe", "o"], ["sh", "s"], ["kh", "k"], ["th", "t"], ["ph", "f"], ["pf", "f"]]), Pb = [/([^aeo])h(.)/g, "$1$2", /([aeo])h([^aeo]|$)/g, "$1$2", /(.)\1+/g, "$1"]; -var Qb = {a:"", e:"", i:"", o:"", u:"", y:"", b:1, f:1, p:1, v:1, c:2, g:2, j:2, k:2, q:2, s:2, x:2, z:2, "\u00df":2, d:3, t:3, l:4, m:5, n:5, r:6}; -var Rb = {Exact:Lb, Default:Mb, Normalize:Mb, LatinBalance:{mapper:Nb}, LatinAdvanced:{mapper:Nb, matcher:Ob, replacer:Pb}, LatinExtra:{mapper:Nb, replacer:Pb.concat([/(?!^)[aeo]/g, ""]), matcher:Ob}, LatinSoundex:{dedupe:!1, include:{letter:!0}, finalize:function(a) { - for (var b = 0; b < a.length; b++) { - for (var c = a[b], d = c.charAt(0), e = Qb[d], f = 1, g; f < c.length && (g = c.charAt(f), "h" === g || "w" === g || !(g = Qb[g]) || g === e || (d += g, e = g, 4 !== d.length)); f++) { - } - a[b] = d; - } -}}, CJK:{split:""}, LatinExact:Lb, LatinDefault:Mb, LatinSimple:Mb}; -U.prototype.remove = function(a, b) { +W.prototype.remove = function(a, b) { var c = this.reg.size && (this.fastupdate ? this.reg.get(a) : this.reg.has(a)); if (c) { if (this.fastupdate) { @@ -3040,14 +3047,14 @@ function Sb(a, b) { } } } else { - for (d = z(a.entries()), e = d.next(); !e.done; e = d.next()) { + for (d = A(a.entries()), e = d.next(); !e.done; e = d.next()) { f = e.value, e = f[0], (f = Sb(f[1], b)) ? c += f : a.delete(e); } } return c; } ;var Ub = {memory:{resolution:1}, performance:{resolution:3, fastupdate:!0, context:{depth:1, resolution:1}}, match:{tokenize:"forward"}, score:{resolution:9, context:{depth:2, resolution:3}}}; -U.prototype.add = function(a, b, c, d) { +W.prototype.add = function(a, b, c, d) { if (b && (a || 0 === a)) { if (!d && !c && this.reg.has(a)) { return this.update(a, b); @@ -3056,17 +3063,17 @@ U.prototype.add = function(a, b, c, d) { b = this.encoder.encode(b, !d); var e = b.length; if (e) { - for (var f = Q(), g = Q(), k = this.resolution, h = 0; h < e; h++) { - var l = b[this.rtl ? e - 1 - h : h], m = l.length; + for (var f = S(), g = S(), h = this.resolution, k = 0; k < e; k++) { + var l = b[this.rtl ? e - 1 - k : k], m = l.length; if (m && (d || !g[l])) { - var q = this.score ? this.score(b, l, h, null, 0) : Vb(k, e, h), p = ""; + var q = this.score ? this.score(b, l, k, null, 0) : Vb(h, e, k), p = ""; switch(this.tokenize) { case "full": if (2 < m) { q = 0; for (var n; q < m; q++) { for (var r = m; r > q; r--) { - p = l.substring(q, r), n = this.rtl ? m - 1 - q : q, n = this.score ? this.score(b, l, h, p, n) : Vb(k, e, h, m, n), Wb(this, g, p, n, a, c); + p = l.substring(q, r), n = this.rtl ? m - 1 - q : q, n = this.score ? this.score(b, l, k, p, n) : Vb(h, e, k, m, n), Wb(this, g, p, n, a, c); } } break; @@ -3075,7 +3082,7 @@ U.prototype.add = function(a, b, c, d) { case "reverse": if (1 < m) { for (r = m - 1; 0 < r; r--) { - p = l[this.rtl ? m - 1 - r : r] + p, n = this.score ? this.score(b, l, h, p, r) : Vb(k, e, h, m, r), Wb(this, g, p, n, a, c); + p = l[this.rtl ? m - 1 - r : r] + p, n = this.score ? this.score(b, l, k, p, r) : Vb(h, e, k, m, r), Wb(this, g, p, n, a, c); } p = ""; } @@ -3087,12 +3094,12 @@ U.prototype.add = function(a, b, c, d) { break; } default: - if (Wb(this, g, l, q, a, c), d && 1 < e && h < e - 1) { - for (m = Q(), p = this.da, q = l, r = Math.min(d + 1, this.rtl ? h + 1 : e - h), n = m[q] = 1; n < r; n++) { - if ((l = b[this.rtl ? e - 1 - h - n : h + n]) && !m[l]) { + if (Wb(this, g, l, q, a, c), d && 1 < e && k < e - 1) { + for (m = S(), p = this.da, q = l, r = Math.min(d + 1, this.rtl ? k + 1 : e - k), n = m[q] = 1; n < r; n++) { + if ((l = b[this.rtl ? e - 1 - k - n : k + n]) && !m[l]) { m[l] = 1; - var v = this.score ? this.score(b, q, h, l, n - 1) : Vb(p + (e / 2 > p ? 0 : 1), e, h, r - 1, n - 1), u = this.bidirectional && l > q; - Wb(this, f, u ? q : l, v, a, c, u ? l : q); + var u = this.score ? this.score(b, q, k, l, n - 1) : Vb(p + (e / 2 > p ? 0 : 1), e, k, r - 1, n - 1), x = this.bidirectional && l > q; + Wb(this, f, x ? q : l, u, a, c, x ? l : q); } } } @@ -3108,27 +3115,27 @@ U.prototype.add = function(a, b, c, d) { return this; }; function Wb(a, b, c, d, e, f, g) { - var k = g ? a.ctx : a.map, h; - if (!b[c] || g && !(h = b[c])[g]) { - if (g ? (b = h || (b[c] = Q()), b[g] = 1, (h = k.get(g)) ? k = h : k.set(g, k = new Map())) : b[c] = 1, (h = k.get(c)) ? k = h : k.set(c, k = h = []), k = k[d] || (k[d] = []), !f || !k.includes(e)) { - if (k.length === Math.pow(2, 31) - 1) { - b = new ib(k); + var h = g ? a.ctx : a.map, k; + if (!b[c] || g && !(k = b[c])[g]) { + if (g ? (b = k || (b[c] = S()), 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 === Math.pow(2, 31) - 1) { + b = new ib(h); if (a.fastupdate) { - for (c = z(a.reg.values()), f = c.next(); !f.done; f = c.next()) { - f = f.value, f.includes(k) && (f[f.indexOf(k)] = b); + for (c = A(a.reg.values()), f = c.next(); !f.done; f = c.next()) { + f = f.value, f.includes(h) && (f[f.indexOf(h)] = b); } } - h[d] = k = b; + k[d] = h = b; } - k.push(e); - a.fastupdate && ((d = a.reg.get(e)) ? d.push(k) : a.reg.set(e, [k])); + h.push(e); + a.fastupdate && ((d = a.reg.get(e)) ? d.push(h) : a.reg.set(e, [h])); } } } function Vb(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; } -;U.prototype.search = function(a, b, c) { +;W.prototype.search = function(a, b, c) { c || (b || "object" !== typeof a ? "object" === typeof b && (c = b, b = 0) : (c = a, a = "")); if (c && c.cache) { return c.cache = !1, a = this.searchCache(a, b, c), c.cache = !0, a; @@ -3139,8 +3146,8 @@ function Vb(a, b, c, d, e) { b = c.limit || b; e = c.offset || 0; var g = c.context; - var k = c.suggest; - var h = (f = c.resolve) && c.enrich; + var h = c.suggest; + var k = (f = c.resolve) && c.enrich; var l = c.boost; var m = c.resolution; var q = this.db && c.tag; @@ -3151,87 +3158,87 @@ function Vb(a, b, c, d, e) { var n = p.length; b = b || (f ? 100 : 0); if (1 === n) { - return Xb.call(this, p[0], "", b, e, f, h, q); + return Xb.call(this, p[0], "", b, e, f, k, q); } - if (2 === n && g && !k) { - return Xb.call(this, p[1], p[0], b, e, f, h, q); + if (2 === n && g && !h) { + return Xb.call(this, p[1], p[0], b, e, f, k, q); } - var r = Q(), v = 0; + var r = S(), u = 0; if (g) { - var u = p[0]; - v = 1; + var x = p[0]; + u = 1; } - m || 0 === m || (m = u ? this.da : this.resolution); + m || 0 === m || (m = x ? this.da : this.resolution); if (this.db) { - if (this.db.search && (c = this.db.search(this, p, b, e, k, f, h, q), !1 !== c)) { + if (this.db.search && (c = this.db.search(this, p, b, e, h, f, k, q), !1 !== c)) { return c; } - var B = this; + var w = this; return function() { - var D, x; - return xa(function(A) { - switch(A.h) { + var E, B; + return xa(function(y) { + switch(y.h) { case 1: - x = D = void 0; + B = E = void 0; case 2: - if (!(v < n)) { - A.h = 4; + if (!(u < n)) { + y.h = 4; break; } - x = p[v]; - if (!x || r[x]) { - A.h = 5; + B = p[u]; + if (!B || r[B]) { + y.h = 5; break; } - r[x] = 1; - return L(A, Yb(B, x, u, 0, 0, !1, !1), 6); + r[B] = 1; + return L(y, Yb(w, B, x, 0, 0, !1, !1), 6); case 6: - D = A.D; - if (D = Zb(D, d, k, m)) { - d = D; - A.h = 4; + E = y.D; + if (E = Zb(E, d, h, m)) { + d = E; + y.h = 4; break; } - u && (k && D && d.length || (u = x)); + x && (h && E && d.length || (x = B)); case 5: - k && u && v === n - 1 && !d.length && (m = B.resolution, u = "", v = -1, r = Q()); - v++; - A.h = 2; + h && x && u === n - 1 && !d.length && (m = w.resolution, x = "", u = -1, r = S()); + u++; + y.h = 2; break; case 4: - return A.return($b(d, m, b, e, k, l, f)); + return y.return($b(d, m, b, e, h, l, f)); } }); }(); } - for (a = c = void 0; v < n; v++) { - if ((a = p[v]) && !r[a]) { + for (a = c = void 0; u < n; u++) { + if ((a = p[u]) && !r[a]) { r[a] = 1; - c = Yb(this, a, u, 0, 0, !1, !1); - if (c = Zb(c, d, k, m)) { + c = Yb(this, a, x, 0, 0, !1, !1); + if (c = Zb(c, d, h, m)) { d = c; break; } - u && (k && c && d.length || (u = a)); + x && (h && c && d.length || (x = a)); } - k && u && v === n - 1 && !d.length && (m = this.resolution, u = "", v = -1, r = Q()); + h && x && u === n - 1 && !d.length && (m = this.resolution, x = "", u = -1, r = S()); } - return $b(d, m, b, e, k, l, f); + return $b(d, m, b, e, h, l, f); }; function $b(a, b, c, d, e, f, g) { - var k = a.length, h = a; - if (1 < k) { - h = rb(a, b, c, d, e, f, g); - } else if (1 === k) { - return g ? ub.call(null, a[0], c, d) : new X(a[0], this); + var h = a.length, k = a; + if (1 < h) { + k = xb(a, b, c, d, e, f, g); + } else if (1 === h) { + return g ? rb.call(null, a[0], c, d) : new Z(a[0], this); } - return g ? h : new X(h, this); + return g ? k : new Z(k, this); } function Xb(a, b, c, d, e, f, g) { a = Yb(this, a, b, c, d, e, f, g); - return this.db ? a.then(function(k) { - return e ? k || [] : new X(k, this); - }) : a && a.length ? e ? ub.call(this, a, c, d) : new X(a, this) : e ? [] : new X([], this); + return this.db ? a.then(function(h) { + return e ? h || [] : new Z(h, this); + }) : a && a.length ? e ? rb.call(this, a, c, d) : new Z(a, this) : e ? [] : new Z([], this); } function Zb(a, b, c, d) { var e = []; @@ -3254,27 +3261,27 @@ function Zb(a, b, c, d) { return e; } } -function Yb(a, b, c, d, e, f, g, k) { - var h; - c && (h = a.bidirectional && b > c) && (h = c, c = b, b = h); +function Yb(a, b, c, d, e, f, g, h) { + var k; + c && (k = a.bidirectional && b > c) && (k = c, c = b, b = k); if (a.db) { - return a.db.get(b, c, d, e, f, g, k); + return a.db.get(b, c, d, e, f, g, h); } a = c ? (a = a.ctx.get(c)) && a.get(b) : a.map.get(b); return a; } -;function U(a, b) { - if (!this || this.constructor !== U) { - return new U(a); +;function W(a, b) { + if (!this || this.constructor !== W) { + return new W(a); } if (a) { - var c = R(a) ? a : a.preset; + var c = T(a) ? a : a.preset; c && (Ub[c] || console.warn("Preset not found: " + c), a = Object.assign({}, Ub[c], a)); } else { a = {}; } c = a.context; - var d = !0 === c ? {depth:1} : c || {}, e = R(a.encoder) ? Rb[a.encoder] : a.encode || a.encoder || {}; + var d = !0 === c ? {depth:1} : c || {}, e = T(a.encoder) ? Nb[a.encoder] : a.encode || a.encoder || {}; this.encoder = e.encode ? e : "object" === typeof e ? new La(e) : {encode:e}; this.resolution = a.resolution || 9; this.tokenize = c = (c = a.tokenize) && "default" !== c && "exact" !== c && c || "strict"; @@ -3284,12 +3291,12 @@ function Yb(a, b, c, d, e, f, g, k) { this.score = a.score || null; d && d.depth && "strict" !== this.tokenize && console.warn('Context-Search could not applied, because it is just supported when using the tokenizer "strict".'); (c = a.keystore || 0) && (this.keystore = c); - this.map = c ? new V(c) : new Map(); - this.ctx = c ? new V(c) : new Map(); - this.reg = b || (this.fastupdate ? c ? new V(c) : new Map() : c ? new W(c) : new Set()); + this.map = c ? new X(c) : new Map(); + this.ctx = c ? new X(c) : new Map(); + this.reg = b || (this.fastupdate ? c ? new X(c) : new Map() : c ? new Y(c) : new Set()); this.da = d.resolution || 3; this.rtl = e.rtl || a.rtl || !1; - this.cache = (c = a.cache || null) && new Ib(c); + this.cache = (c = a.cache || null) && new Pb(c); this.resolve = !1 !== a.resolve; if (c = a.db) { this.db = this.mount(c); @@ -3299,16 +3306,16 @@ function Yb(a, b, c, d, e, f, g, k) { this.commit_timer = null; this.priority = a.priority || 4; } -w = U.prototype; -w.mount = function(a) { +v = W.prototype; +v.mount = function(a) { this.commit_timer && (clearTimeout(this.commit_timer), this.commit_timer = null); return a.mount(this); }; -w.commit = function(a, b) { +v.commit = function(a, b) { this.commit_timer && (clearTimeout(this.commit_timer), this.commit_timer = null); return this.db.commit(this, a, b); }; -w.destroy = function() { +v.destroy = function() { this.commit_timer && (clearTimeout(this.commit_timer), this.commit_timer = null); return this.db.destroy(); }; @@ -3318,7 +3325,7 @@ function Tb(a) { a.db.commit(a, void 0, void 0); }, 1)); } -w.clear = function() { +v.clear = function() { this.map.clear(); this.ctx.clear(); this.reg.clear(); @@ -3326,19 +3333,19 @@ w.clear = function() { this.db && (this.commit_timer && clearTimeout(this.commit_timer), this.commit_timer = null, this.commit_task = [{clear:!0}]); return this; }; -w.append = function(a, b) { +v.append = function(a, b) { return this.add(a, b, !0); }; -w.contain = function(a) { +v.contain = function(a) { return this.db ? this.db.has(a) : this.reg.has(a); }; -w.update = function(a, b) { +v.update = function(a, b) { var c = this, d = this.remove(a); return d && d.then ? d.then(function() { return c.add(a, b); }) : this.add(a, b); }; -w.cleanup = function() { +v.cleanup = function() { if (!this.fastupdate) { return console.info('Cleanup the index isn\'t required when not using "fastupdate".'), this; } @@ -3346,8 +3353,8 @@ w.cleanup = function() { this.depth && Sb(this.ctx); return this; }; -w.searchCache = Kb; -w.export = function(a, b, c, d) { +v.searchCache = Rb; +v.export = function(a, b, c, d) { c = void 0 === c ? 0 : c; d = void 0 === d ? 0 : d; switch(d) { @@ -3372,7 +3379,7 @@ w.export = function(a, b, c, d) { } return fb.call(this, a, b, e, f, c, d); }; -w.import = function(a, b) { +v.import = function(a, b) { if (b) { switch("string" === typeof b && (b = JSON.parse(b)), a = a.split("."), "json" === a[a.length - 1] && a.pop(), 3 === a.length && a.shift(), a = 1 < a.length ? a[1] : a[0], a) { case "reg": @@ -3387,33 +3394,33 @@ w.import = function(a, b) { } } }; -w.serialize = function(a) { +v.serialize = function(a) { a = void 0 === a ? !0 : a; var b = "", c = "", d = ""; if (this.reg.size) { var e; - c = z(this.reg.keys()); + c = A(this.reg.keys()); for (var f = c.next(); !f.done; f = c.next()) { f = f.value, e || (e = typeof f), b += (b ? "," : "") + ("string" === e ? '"' + f + '"' : f); } b = "index.reg=new Set([" + b + "]);"; c = gb(this.map, e); c = "index.map=new Map([" + c + "]);"; - f = z(this.ctx.entries()); + f = A(this.ctx.entries()); for (var g = f.next(); !g.done; g = f.next()) { - var k = g.value; - g = k[0]; - k = gb(k[1], e); - k = "new Map([" + k + "])"; - k = '["' + g + '",' + k + "]"; - d += (d ? "," : "") + k; + var h = g.value; + g = h[0]; + h = gb(h[1], e); + h = "new Map([" + h + "])"; + h = '["' + g + '",' + h + "]"; + d += (d ? "," : "") + h; } d = "index.ctx=new Map([" + d + "]);"; } return a ? "function inject(index){" + b + c + d + "}" : b + c + d; }; -Qa(U.prototype); -var ac = "undefined" !== typeof window && (window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB), bc = ["map", "ctx", "tag", "reg", "cfg"], cc = Q(); +Qa(W.prototype); +var ac = "undefined" !== typeof window && (window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB), bc = ["map", "ctx", "tag", "reg", "cfg"], cc = S(); function dc(a, b) { b = void 0 === b ? {} : b; if (!this || this.constructor !== dc) { @@ -3428,15 +3435,15 @@ function dc(a, b) { this.db = null; this.h = {}; } -w = dc.prototype; -w.mount = function(a) { +v = dc.prototype; +v.mount = function(a) { if (a.index) { return a.mount(this); } a.db = this; return this.open(); }; -w.open = function() { +v.open = function() { if (this.db) { return this.db; } @@ -3460,15 +3467,15 @@ w.open = function() { }; }); }; -w.close = function() { +v.close = function() { this.db && this.db.close(); this.db = null; }; -w.destroy = function() { +v.destroy = function() { var a = ac.deleteDatabase(this.id); return ec(a); }; -w.clear = function() { +v.clear = function() { for (var a = [], b = 0, c; b < bc.length; b++) { c = bc[b]; for (var d = 0, e; d < cc[this.id].length; d++) { @@ -3481,43 +3488,43 @@ w.clear = function() { } return ec(b); }; -w.get = function(a, b, c, d, e, f) { +v.get = function(a, b, c, d, e, f) { c = void 0 === c ? 0 : c; d = void 0 === d ? 0 : d; e = void 0 === e ? !0 : e; f = void 0 === f ? !1 : f; a = this.db.transaction((b ? "ctx" : "map") + (this.field ? ":" + this.field : ""), "readonly").objectStore((b ? "ctx" : "map") + (this.field ? ":" + this.field : "")).get(b ? b + ":" + a : a); var g = this; - return ec(a).then(function(k) { - var h = []; - if (!k || !k.length) { - return h; + return ec(a).then(function(h) { + var k = []; + if (!h || !h.length) { + return k; } if (e) { - if (!c && !d && 1 === k.length) { - return k[0]; + if (!c && !d && 1 === h.length) { + return h[0]; } - for (var l = 0, m = void 0; l < k.length; l++) { - if ((m = k[l]) && m.length) { + for (var l = 0, m = void 0; l < h.length; l++) { + if ((m = h[l]) && m.length) { if (d >= m.length) { d -= m.length; } else { for (var q = c ? d + Math.min(m.length - d, c) : m.length, p = d; p < q; p++) { - h.push(m[p]); + k.push(m[p]); } d = 0; - if (h.length === c) { + if (k.length === c) { break; } } } } - return f ? g.enrich(h) : h; + return f ? g.enrich(k) : k; } - return k; + return h; }); }; -w.tag = function(a, b, c, d) { +v.tag = function(a, b, c, d) { b = void 0 === b ? 0 : b; c = void 0 === c ? 0 : c; d = void 0 === d ? !1 : d; @@ -3534,7 +3541,7 @@ w.tag = function(a, b, c, d) { return d ? e.enrich(f) : f; }); }; -w.enrich = function(a) { +v.enrich = function(a) { "object" !== typeof a && (a = [a]); for (var b = this.db.transaction("reg", "readonly").objectStore("reg"), c = [], d = 0; d < a.length; d++) { c[d] = ec(b.get(a[d])); @@ -3546,16 +3553,16 @@ w.enrich = function(a) { return e; }); }; -w.has = function(a) { +v.has = function(a) { a = this.db.transaction("reg", "readonly").objectStore("reg").getKey(a); return ec(a).then(function(b) { return !!b; }); }; -w.search = null; -w.info = function() { +v.search = null; +v.info = function() { }; -w.transaction = function(a, b, c) { +v.transaction = function(a, b, c) { a += "reg" !== a ? this.field ? ":" + this.field : "" : ""; var d = this.h[a + ":" + b]; if (d) { @@ -3570,13 +3577,13 @@ w.transaction = function(a, b, c) { return f; }); }; -w.commit = function(a, b, c) { +v.commit = function(a, b, c) { var d = this, e, f, g; - return xa(function(k) { - switch(k.h) { + return xa(function(h) { + switch(h.h) { case 1: if (b) { - return L(k, d.clear(), 12); + return L(h, d.clear(), 12); } e = a.commit_task; a.commit_task = []; @@ -3584,56 +3591,56 @@ w.commit = function(a, b, c) { g = void 0; case 4: if (!(f < e.length)) { - k.h = 6; + h.h = 6; break; } g = e[f]; if (!g.clear) { e[f] = g.del; - k.h = 5; + h.h = 5; break; } - return L(k, d.clear(), 8); + return L(h, d.clear(), 8); case 8: b = !0; - k.h = 6; + h.h = 6; break; case 5: f++; - k.h = 4; + h.h = 4; break; case 6: if (b) { - k.h = 3; + h.h = 3; break; } c || (e = e.concat(Da(a.reg))); if (!e.length) { - k.h = 10; + h.h = 10; break; } - return L(k, d.remove(e), 11); + return L(h, d.remove(e), 11); case 11: case 10: - k.h = 3; + h.h = 3; break; case 12: a.commit_task = []; case 3: - return a.reg.size ? L(k, d.transaction("map", "readwrite", function(h) { - for (var l = z(a.map), m = l.next(), q = {}; !m.done; q = {O:void 0, Y:void 0}, m = l.next()) { - m = m.value, q.Y = m[0], q.O = m[1], q.O.length && (b ? h.put(q.O, q.Y) : h.get(q.Y).onsuccess = function(p) { + return a.reg.size ? L(h, d.transaction("map", "readwrite", function(k) { + for (var l = A(a.map), m = l.next(), q = {}; !m.done; q = {O:void 0, Y:void 0}, m = l.next()) { + m = m.value, q.Y = m[0], q.O = m[1], q.O.length && (b ? k.put(q.O, q.Y) : k.get(q.Y).onsuccess = function(p) { return function() { var n = this.result, r; if (n && n.length) { - for (var v = Math.max(n.length, p.O.length), u = 0, B; u < v; u++) { - if ((B = p.O[u]) && B.length) { - if ((r = n[u]) && r.length) { - for (var D = 0; D < B.length; D++) { - r.push(B[D]); + for (var u = Math.max(n.length, p.O.length), x = 0, w; x < u; x++) { + if ((w = p.O[x]) && w.length) { + if ((r = n[x]) && r.length) { + for (var E = 0; E < w.length; E++) { + r.push(w[E]); } } else { - n[u] = B; + n[x] = w; } r = 1; } @@ -3641,38 +3648,38 @@ w.commit = function(a, b, c) { } else { n = p.O, r = 1; } - r && h.put(n, p.Y); + r && k.put(n, p.Y); }; }(q)); } - }), 13) : k.return(); + }), 13) : h.return(); case 13: - return L(k, d.transaction("ctx", "readwrite", function(h) { - for (var l = z(a.ctx), m = l.next(), q = {}; !m.done; q = {V:void 0}, m = l.next()) { + return L(h, d.transaction("ctx", "readwrite", function(k) { + for (var l = A(a.ctx), m = l.next(), q = {}; !m.done; q = {V:void 0}, m = l.next()) { m = m.value; q.V = m[0]; - m = z(m[1]); + m = A(m[1]); for (var p = m.next(), n = {}; !p.done; n = {P:void 0, Z:void 0}, p = m.next()) { - p = p.value, n.Z = p[0], n.P = p[1], n.P.length && (b ? h.put(n.P, q.V + ":" + n.Z) : h.get(q.V + ":" + n.Z).onsuccess = function(r, v) { + p = p.value, n.Z = p[0], n.P = p[1], n.P.length && (b ? k.put(n.P, q.V + ":" + n.Z) : k.get(q.V + ":" + n.Z).onsuccess = function(r, u) { return function() { - var u = this.result, B; - if (u && u.length) { - for (var D = Math.max(u.length, r.P.length), x = 0, A; x < D; x++) { - if ((A = r.P[x]) && A.length) { - if ((B = u[x]) && B.length) { - for (var t = 0; t < A.length; t++) { - B.push(A[t]); + var x = this.result, w; + if (x && x.length) { + for (var E = Math.max(x.length, r.P.length), B = 0, y; B < E; B++) { + if ((y = r.P[B]) && y.length) { + if ((w = x[B]) && w.length) { + for (var t = 0; t < y.length; t++) { + w.push(y[t]); } } else { - u[x] = A; + x[B] = y; } - B = 1; + w = 1; } } } else { - u = r.P, B = 1; + x = r.P, w = 1; } - B && h.put(u, v.V + ":" + r.Z); + w && k.put(x, u.V + ":" + r.Z); }; }(n, q)); } @@ -3680,59 +3687,59 @@ w.commit = function(a, b, c) { }), 14); case 14: if (a.store) { - return L(k, d.transaction("reg", "readwrite", function(h) { - for (var l = z(a.store), m = l.next(); !m.done; m = l.next()) { + return L(h, d.transaction("reg", "readwrite", function(k) { + for (var l = A(a.store), m = l.next(); !m.done; m = l.next()) { var q = m.value; m = q[0]; q = q[1]; - h.put("object" === typeof q ? JSON.stringify(q) : 1, m); + k.put("object" === typeof q ? JSON.stringify(q) : 1, m); } }), 16); } if (a.bypass) { - k.h = 16; + h.h = 16; break; } - return L(k, d.transaction("reg", "readwrite", function(h) { - for (var l = z(a.reg.keys()), m = l.next(); !m.done; m = l.next()) { - h.put(1, m.value); + return L(h, d.transaction("reg", "readwrite", function(k) { + for (var l = A(a.reg.keys()), m = l.next(); !m.done; m = l.next()) { + k.put(1, m.value); } }), 16); case 16: if (!a.tag) { - k.h = 20; + h.h = 20; break; } - return L(k, d.transaction("tag", "readwrite", function(h) { - for (var l = z(a.tag), m = l.next(), q = {}; !m.done; q = {X:void 0, ba:void 0}, m = l.next()) { - m = m.value, q.ba = m[0], q.X = m[1], q.X.length && (h.get(q.ba).onsuccess = function(p) { + return L(h, d.transaction("tag", "readwrite", function(k) { + for (var l = A(a.tag), m = l.next(), q = {}; !m.done; q = {X:void 0, ba:void 0}, m = l.next()) { + m = m.value, q.ba = m[0], q.X = m[1], q.X.length && (k.get(q.ba).onsuccess = function(p) { return function() { var n = this.result; n = n && n.length ? n.concat(p.X) : p.X; - h.put(n, p.ba); + k.put(n, p.ba); }; }(q)); } }), 20); case 20: - a.map.clear(), a.ctx.clear(), a.tag && a.tag.clear(), a.store && a.store.clear(), a.document || a.reg.clear(), k.h = 0; + a.map.clear(), a.ctx.clear(), a.tag && a.tag.clear(), a.store && a.store.clear(), a.document || a.reg.clear(), h.h = 0; } }); }; function fc(a, b, c) { - for (var d = a.value, e, f = 0, g = 0, k; g < d.length; g++) { - if (k = c ? d : d[g]) { - for (var h = 0, l; h < b.length; h++) { - if (l = b[h], l = k.indexOf(l), 0 <= l) { - if (e = 1, 1 < k.length) { - k.splice(l, 1); + for (var d = a.value, e, f = 0, g = 0, h; g < d.length; g++) { + if (h = c ? d : d[g]) { + for (var k = 0, l; k < b.length; k++) { + if (l = b[k], l = h.indexOf(l), 0 <= l) { + if (e = 1, 1 < h.length) { + h.splice(l, 1); } else { d[g] = []; break; } } } - f += k.length; + f += h.length; } if (c) { break; @@ -3741,7 +3748,7 @@ function fc(a, b, c) { f ? e && a.update(d) : a.delete(); a.continue(); } -w.remove = function(a) { +v.remove = function(a) { "object" !== typeof a && (a = [a]); return Promise.all([this.transaction("map", "readwrite", function(b) { b.openCursor().onsuccess = function() { @@ -3775,7 +3782,7 @@ function ec(a, b) { a = null; }); } -;var gc = {Index:U, Charset:Rb, Encoder:La, Document:ob, Worker:Xa, Resolver:X, IndexedDB:dc, Language:{}}, hc = "undefined" !== typeof self ? self : "undefined" !== typeof global ? global : self, ic; +;var gc = {Index:W, Charset:Nb, Encoder:La, Document:ob, Worker:Xa, Resolver:Z, IndexedDB:dc, Language:{}}, hc = "undefined" !== typeof self ? self : "undefined" !== typeof global ? global : self, ic; (ic = hc.define) && ic.amd ? ic([], function() { return gc; }) : "object" === typeof hc.exports ? hc.exports = gc : hc.FlexSearch = gc; diff --git a/dist/flexsearch.es5.min.js b/dist/flexsearch.es5.min.js index fee1f51..9991f36 100644 --- a/dist/flexsearch.es5.min.js +++ b/dist/flexsearch.es5.min.js @@ -1,140 +1,142 @@ /**! - * FlexSearch.js v0.8.163 (ES5) + * FlexSearch.js v0.8.164 (ES5) * Author and Copyright: Thomas Wilkerling * Licence: Apache-2.0 * Hosted by Nextapps GmbH * https://github.com/nextapps-de/flexsearch */ -(function _f(self){'use strict';if(typeof module!=='undefined')self=module;else if(typeof process !== 'undefined')self=process;self._factory=_f;var w;function ba(a){var b=0;return function(){return b>>0)+"_",e=0;return b}); -I("Symbol.iterator",function(a){if(a)return a;a=Symbol("Symbol.iterator");for(var b="Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array".split(" "),c=0;c>>0)+"_",e=0;return b}); +H("Symbol.iterator",function(a){if(a)return a;a=Symbol("Symbol.iterator");for(var b="Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array".split(" "),c=0;cc&&(c=Math.max(c+e,0));c"a1a".split(c).length; +b.prototype.values;b.prototype.forEach=function(c,d){var e=this;this.h.forEach(function(f){return c.call(d,f,f,e)})};return b});H("Array.prototype.entries",function(a){return a?a:function(){return za(this,function(b,c){return[b,c]})}});H("Object.is",function(a){return a?a:function(b,c){return b===c?0!==b||1/b===1/c:b!==b&&c!==c}}); +H("Array.prototype.includes",function(a){return a?a:function(b,c){var d=this;d instanceof String&&(d=String(d));var e=d.length;c=c||0;for(0>c&&(c=Math.max(c+e,0));c"a1a".split(c).length; this.numeric=O(a.numeric,e)}else{try{this.split=O(this.split,Ga)}catch(f){this.split=/\s+/}this.numeric=O(a.numeric,O(this.numeric,!0))}this.prepare=O(a.prepare,null,this.prepare);this.finalize=O(a.finalize,null,this.finalize);c=a.filter;this.filter="function"===typeof c?c:O(c&&new Set(c),null,this.filter);this.dedupe=O(a.dedupe,!0,this.dedupe);this.matcher=O((c=a.matcher)&&new Map(c),null,this.matcher);this.mapper=O((c=a.mapper)&&new Map(c),null,this.mapper);this.stemmer=O((c=a.stemmer)&&new Map(c), -null,this.stemmer);this.replacer=O(a.replacer,null,this.replacer);this.minlength=O(a.minlength,1,this.minlength);this.maxlength=O(a.maxlength,1024,this.maxlength);this.rtl=O(a.rtl,!1,this.rtl);if(this.cache=c=O(a.cache,!0,this.cache))this.D=null,this.T="number"===typeof c?c:2E5,this.B=new Map,this.C=new Map,this.H=this.G=128;this.h="";this.M=null;this.A="";this.N=null;if(this.matcher)for(a=z(this.matcher.keys()),b=a.next();!b.done;b=a.next())this.h+=(this.h?"|":"")+b.value;if(this.stemmer)for(a=z(this.stemmer.keys()), -b=a.next();!b.done;b=a.next())this.A+=(this.A?"|":"")+b.value;return this};w.addStemmer=function(a,b){this.stemmer||(this.stemmer=new Map);this.stemmer.set(a,b);this.A+=(this.A?"|":"")+a;this.N=null;this.cache&&Ma(this);return this};w.addFilter=function(a){"function"===typeof a?this.filter=a:(this.filter||(this.filter=new Set),this.filter.add(a));this.cache&&Ma(this);return this}; -w.addMapper=function(a,b){if("object"===typeof a)return this.addReplacer(a,b);if(1a.length&&(this.dedupe||this.mapper))return this.addMapper(a,b);this.matcher||(this.matcher=new Map);this.matcher.set(a,b);this.h+=(this.h?"|":"")+a;this.M=null;this.cache&&Ma(this);return this}; -w.addReplacer=function(a,b){if("string"===typeof a)return this.addMatcher(a,b);this.replacer||(this.replacer=[]);this.replacer.push(a,b);this.cache&&Ma(this);return this}; -w.encode=function(a,b){var c=this;if(this.cache&&a.length<=this.G)if(this.D){if(this.B.has(a))return this.B.get(a)}else this.D=setTimeout(Ma,50,this);this.normalize&&("function"===typeof this.normalize?a=this.normalize(a):a=Ka?a.normalize("NFKD").replace(Ka,"").toLowerCase():a.toLowerCase());this.prepare&&(a=this.prepare(a));this.numeric&&3this.maxlength)){if(b){if(f[m])continue;f[m]=1}else{if(g===m)continue;g=m}if(d)e.push(m);else if(!this.filter||("function"===typeof this.filter?this.filter(m):!this.filter.has(m))){if(this.cache&&m.length<=this.H)if(this.D){var p=this.C.get(m);if(p||""===p){p&&e.push(p);continue}}else this.D=setTimeout(Ma,50,this);if(this.stemmer)for(this.N|| -(this.N=new RegExp("(?!^)("+this.A+")$")),p=void 0;p!==m&&2a.length&&(this.dedupe||this.mapper))return this.addMapper(a,b);this.matcher||(this.matcher=new Map);this.matcher.set(a,b);this.h+=(this.h?"|":"")+a;this.M=null;this.cache&&Ma(this);return this}; +v.addReplacer=function(a,b){if("string"===typeof a)return this.addMatcher(a,b);this.replacer||(this.replacer=[]);this.replacer.push(a,b);this.cache&&Ma(this);return this}; +v.encode=function(a,b){var c=this;if(this.cache&&a.length<=this.G)if(this.D){if(this.B.has(a))return this.B.get(a)}else this.D=setTimeout(Ma,50,this);this.normalize&&("function"===typeof this.normalize?a=this.normalize(a):a=Ka?a.normalize("NFKD").replace(Ka,"").toLowerCase():a.toLowerCase());this.prepare&&(a=this.prepare(a));this.numeric&&3this.maxlength)){if(b){if(f[m])continue;f[m]=1}else{if(g===m)continue;g=m}if(d)e.push(m);else if(!this.filter||("function"===typeof this.filter?this.filter(m):!this.filter.has(m))){if(this.cache&&m.length<=this.H)if(this.D){var p=this.C.get(m);if(p||""===p){p&&e.push(p);continue}}else this.D=setTimeout(Ma,50,this);if(this.stemmer)for(this.N|| +(this.N=new RegExp("(?!^)("+this.A+")$")),p=void 0;p!==m&&2this.T&&(this.C.clear(),this.H=this.H/1.1|0));if(m){if(m!==q)if(b){if(f[m])continue;f[m]=1}else{if(h===m)continue;h=m}e.push(m)}}}this.finalize&&(e=this.finalize(e)||e);this.cache&&a.length<=this.G&&(this.B.set(a,e),this.B.size>this.T&&(this.B.clear(),this.G=this.G/1.1|0));return e};function Ma(a){a.D=null;a.B.clear();a.C.clear()};var Na,Oa; -function Pa(a){var b,c,d,e,f,g;return xa(function(h){switch(h.h){case 1:a=a.data;b=a.task;c=a.id;d=a.args;switch(b){case "init":Oa=a.options||{};(e=a.factory)?(Function("return "+e)()(self),Na=new self.FlexSearch.Index(Oa),delete self.FlexSearch):Na=new U(Oa);postMessage({id:c});break;default:h.h=2;return}h.h=0;break;case 2:"export"===b&&(d[1]?(d[0]=Oa.export,d[2]=0,d[3]=1):d=null);if("import"===b){if(!d[0]){h.h=5;break}return L(h,Oa.import.call(Na,d[0]),9)}f=d&&Na[b].apply(Na,d);if(!f||!f.then){h.h= +function Pa(a){var b,c,d,e,f,g;return xa(function(h){switch(h.h){case 1:a=a.data;b=a.task;c=a.id;d=a.args;switch(b){case "init":Oa=a.options||{};(e=a.factory)?(Function("return "+e)()(self),Na=new self.FlexSearch.Index(Oa),delete self.FlexSearch):Na=new W(Oa);postMessage({id:c});break;default:h.h=2;return}h.h=0;break;case 2:"export"===b&&(d[1]?(d[0]=Oa.export,d[2]=0,d[3]=1):d=null);if("import"===b){if(!d[0]){h.h=5;break}return L(h,Oa.import.call(Na,d[0]),9)}f=d&&Na[b].apply(Na,d);if(!f||!f.then){h.h= 5;break}return L(h,f,7);case 7:f=h.D;h.h=5;break;case 9:g=h.D,Na.import(d[0],g);case 5:postMessage("search"===b?{id:c,msg:f}:{id:c}),h.h=0}})};function Qa(a){Ra.call(a,"add");Ra.call(a,"append");Ra.call(a,"search");Ra.call(a,"update");Ra.call(a,"remove");Ra.call(a,"searchCache")}var Sa,Ta,Ua;function Va(){Sa=Ua=0} function Ra(a){this[a+"Async"]=function(){var b=arguments,c=b[b.length-1];if("function"===typeof c){var d=c;delete b[b.length-1]}Sa?Ua||(Ua=Date.now()-Ta>=this.priority*this.priority*3):(Sa=setTimeout(Va,0),Ta=Date.now());if(Ua){var e=this;return new Promise(function(g){setTimeout(function(){g(e[a+"Async"].apply(e,b))},0)})}var f=this[a].apply(this,b);c=f.then?f:new Promise(function(g){return g(f)});d&&c.then(d);return c}};var Wa=0; -function Xa(a){function b(g){function h(k){k=k.data||k;var l=k.id,m=l&&e.h[l];m&&(m(k.msg),delete e.h[l])}this.worker=g;this.h=Q();if(this.worker){d?this.worker.on("message",h):this.worker.onmessage=h;if(a.config)return new Promise(function(k){e.h[++Wa]=function(){k(e);1E9=g.length)b-=g.length;else{b=g[d?"splice":"slice"](b,c);if(g=b.length)if(e=e.length?e.concat(b):b,c-=g,d&&(a.length-=g),!c)break;b=0}return e} +function gb(a,b){var c="";a=A(a.entries());for(var d=a.next();!d.done;d=a.next()){var e=d.value;d=e[0];e=e[1];for(var f="",g=0,h;g=g.length)b-=g.length;else{b=g[d?"splice":"slice"](b,c);if(g=b.length)if(e=e.length?e.concat(b):b,c-=g,d&&(a.length-=g),!c)break;b=0}return e} function ib(a){if(!this||this.constructor!==ib)return new ib(a);this.index=a?[a]:[];this.length=a?a.length:0;var b=this;return new Proxy([],{get:function(c,d){if("length"===d)return b.length;if("push"===d)return function(e){b.index[b.index.length-1].push(e);b.length++};if("pop"===d)return function(){if(b.length)return b.length--,b.index[b.index.length-1].pop()};if("indexOf"===d)return function(e){for(var f=0,g=0,h,k;gc||d?k.slice(d,c+d):k;else{if(ac||d)k=k.slice(d,c+ +ib.prototype.clear=function(){this.index.length=0};ib.prototype.destroy=function(){this.proxy=this.index=null};ib.prototype.push=function(){};function X(a){a=void 0===a?8:a;if(!this||this.constructor!==X)return new X(a);this.index=S();this.h=[];this.size=0;32b?b?a.slice(c,c+b):a.slice(c):a,d?sb.call(this,a):a;for(var e=[],f=0,g=void 0,h=void 0;f=h){c-=h;continue}cb&&(g=g.slice(0,b),h=b);if(!e.length&&h>=b)return d?sb.call(this,g):g;e.push(g);b-=h;if(!b)break}e=1a.length?this.result=a[0]:(this.result=vb(a,c,d,!1,this.h),d=0));return f?this.resolve(c,d,e):this};Z.prototype.and=function(){var a=this.result.length;if(!a){var b=arguments[0];if(b){a=!!b.suggest;var c=b.resolve;var d=b.limit;var e=b.offset;var f=b.enrich&&c}}return a?(a=tb(this,"and",arguments),wb.call(this,a.W,a.$,a.limit,a.offset,a.enrich,a.resolve,a.suggest)):c?this.resolve(d,e,f):this}; +function wb(a,b,c,d,e,f,g){if(b.length){var h=this;return Promise.all(b).then(function(k){a=[];for(var l=0,m=void 0;la.length)this.result=a[0];else{if(b=Fa(a))return this.result=xb(a,b,c,d,g,this.h,f),f?e?sb.call(this.index,this.result):this.result:this;this.result=[]}else g||(this.result=a);return f?this.resolve(c,d,e):this};Z.prototype.xor=function(){var a=tb(this,"xor",arguments);return yb.call(this,a.W,a.$,a.limit,a.offset,a.enrich,a.resolve,a.suggest)}; +function yb(a,b,c,d,e,f,g){if(b.length){var h=this;return Promise.all(b).then(function(k){a=[];for(var l=0,m=void 0;la.length)this.result=a[0];else return this.result=zb.call(this,a,c,d,f,this.h),f?e?sb.call(this.index,this.result):this.result:this;else g||(this.result=a);return f?this.resolve(c,d,e):this} +function zb(a,b,c,d,e){for(var f=[],g=S(),h=0,k=0,l;kQ&&(Q=t.length+(t?1:0)),M=t.length+(t?1:0)+ba.length,J+=N,P.push(C.length),C.push({match:ba})),t+=(t?" ":"")+ba)}if(!G)R=D[F],t+=(t?" ":"")+R,k&&C.push({text:R});else if(k&&J>=k)break}J=P.length*(f.length-2);if(n||r||k&&t.length-J>k)if(J=k+J-2*p,F=M-Q,0D&&(D=0)),C=C.length-1){if(K>=C.length){F[z+1]=1;K>=D.length&&(Q[z+1]=1);continue}G-=p}t=C[K].text;var U=r&&V[z]; +if(U)if(0U)if(F[z+1]=1,l)t=t.substring(0,U);else continue;(U-=t.length)||(U=-1);V[z]=U}else{F[z+1]=1;continue}if(G+t.length+1<=k)t=" "+t,M[z]+=t;else if(l)I=k-G-1,0=K){if(0>K){F[z]=1;Q[z]=1;continue}G-=p}t=C[K].text;if(U=n&&R[z])if(0U)if(F[z]=1,l)t=t.substring(t.length-U);else continue;(U-=t.length)||(U=-1);R[z]=U}else{F[z]=1;continue}if(G+ +t.length+1<=k)t+=" ",M[z]=t+M[z];else if(l)I=t.length+1-(k-G),0<=I&&I=D.length-1?I=1:Kc||d?k.slice(d,c+d):k;else{if(ac||d)k=k.slice(d,c+ d)}else{e=[];for(f=0;fd)d-=g.length;else{if(c&&g.length>c||d)g=g.slice(d,c+d),c-=g.length,d&&(d-=g.length);e.push(g);if(!c)break}k=e}}return k} -function sb(a,b,c,d,e){var f=[],g=Q(),h=a.length,k;if(d)for(e=h-1;0<=e;e--){if(k=(d=a[e])&&d.length)for(h=0;hb?b?a.slice(c,c+b):a.slice(c):a,d?vb.call(this,a):a;for(var e=[],f=0,g=void 0,h=void 0;f=h){c-=h;continue}cb&&(g=g.slice(0,b),h=b);if(!e.length&&h>=b)return d?vb.call(this,g):g;e.push(g);b-=h;if(!b)break}e=1a.length?this.result=a[0]:(this.result=sb(a,c,d,!1,this.h),d=0));return f?this.resolve(c,d,e):this};X.prototype.and=function(){var a=this.result.length;if(!a){var b=arguments[0];if(b){a=!!b.suggest;var c=b.resolve;var d=b.limit;var e=b.offset;var f=b.enrich&&c}}return a?(a=wb(this,"and",arguments),yb.call(this,a.W,a.$,a.limit,a.offset,a.enrich,a.resolve,a.suggest)):c?this.resolve(d,e,f):this}; -function yb(a,b,c,d,e,f,g){if(b.length){var h=this;return Promise.all(b).then(function(k){a=[];for(var l=0,m=void 0;la.length)this.result=a[0];else{if(b=Fa(a))return this.result=rb(a,b,c,d,g,this.h,f),f?e?vb.call(this.index,this.result):this.result:this;this.result=[]}else g||(this.result=a);return f?this.resolve(c,d,e):this};X.prototype.xor=function(){var a=wb(this,"xor",arguments);return zb.call(this,a.W,a.$,a.limit,a.offset,a.enrich,a.resolve,a.suggest)}; -function zb(a,b,c,d,e,f,g){if(b.length){var h=this;return Promise.all(b).then(function(k){a=[];for(var l=0,m=void 0;la.length)this.result=a[0];else return this.result=Ab.call(this,a,c,d,f,this.h),f?e?vb.call(this.index,this.result):this.result:this;else g||(this.result=a);return f?this.resolve(c,d,e):this} -function Ab(a,b,c,d,e){for(var f=[],g=Q(),h=0,k=0,l;kG&&(G=t.length+(t?1:0)),N=t.length+(t?1:0)+aa.length,S+=Y,fa.push(C.length),C.push({match:aa})),t+=(t?" ":"")+aa)}if(!P)J=D[F],t+=(t?" ":"")+J,k&&C.push({text:J});else if(k&&S>=k)break}S=fa.length*(f.length-2);if(n||r||k&&t.length-S>k)if(S=k+S-2*p,F=N-G,0D&&(D=0)),C=C.length-1){if(K>=C.length){F[y+1]=1;K>=D.length&&(G[y+1]=1);continue}P-=p}t=C[K].text;var T=r&&M[y]; -if(T)if(0T)if(F[y+1]=1,l)t=t.substring(0,T);else continue;(T-=t.length)||(T=-1);M[y]=T}else{F[y+1]=1;continue}if(P+t.length+1<=k)t=" "+t,N[y]+=t;else if(l)H=k-P-1,0=K){if(0>K){F[y]=1;G[y]=1;continue}P-=p}t=C[K].text;if(T=n&&J[y])if(0T)if(F[y]=1,l)t=t.substring(t.length-T);else continue;(T-=t.length)||(T=-1);J[y]=T}else{F[y]=1;continue}if(P+ -t.length+1<=k)t+=" ",N[y]=t+N[y];else if(l)H=t.length+1-(k-P),0<=H&&H=D.length-1?H=1:Kc||d)a=a.slice(d,d+c);e&&(a=vb.call(this,a));return a}}function vb(a){if(!this||!this.store)return a;for(var b=Array(a.length),c=0,d;cthis.limit&&this.cache.delete(this.cache.keys().next().value)}; -Ib.prototype.get=function(a){var b=this.cache.get(a);b&&this.h!==a&&(this.cache.delete(a),this.cache.set(this.h=a,b));return b};Ib.prototype.remove=function(a){for(var b=z(this.cache),c=b.next();!c.done;c=b.next()){c=c.value;var d=c[0];c[1].includes(a)&&this.cache.delete(d)}};Ib.prototype.clear=function(){this.cache.clear();this.h=""};var Lb={normalize:!1,numeric:!1,dedupe:!1};var Mb={};var Nb=new Map([["b","p"],["v","f"],["w","f"],["z","s"],["x","s"],["d","t"],["n","m"],["c","k"],["g","k"],["j","k"],["q","k"],["i","e"],["y","e"],["u","o"]]);var Ob=new Map([["ae","a"],["oe","o"],["sh","s"],["kh","k"],["th","t"],["ph","f"],["pf","f"]]),Pb=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/(.)\1+/g,"$1"];var Qb={a:"",e:"",i:"",o:"",u:"",y:"",b:1,f:1,p:1,v:1,c:2,g:2,j:2,k:2,q:2,s:2,x:2,z:2,"\u00df":2,d:3,t:3,l:4,m:5,n:5,r:6};var Rb={Exact:Lb,Default:Mb,Normalize:Mb,LatinBalance:{mapper:Nb},LatinAdvanced:{mapper:Nb,matcher:Ob,replacer:Pb},LatinExtra:{mapper:Nb,replacer:Pb.concat([/(?!^)[aeo]/g,""]),matcher:Ob},LatinSoundex:{dedupe:!1,include:{letter:!0},finalize:function(a){for(var b=0;be.length)e.pop();else{var f=e.indexOf(a);f===c.length-1?e.pop():e.splice(f,1)}}else Sb(this.map,a),this.depth&&Sb(this.ctx,a);b||this.reg.delete(a)}this.db&&(this.commit_task.push({del:a}),this.ca&&Tb(this));this.cache&&this.cache.remove(a);return this}; -function Sb(a,b){var c=0,d="undefined"===typeof b;if(a.constructor===Array)for(var e=0,f=void 0,g;eq;r--)p=l.substring(q,r),n=this.rtl?m-1-q:q,n=this.score?this.score(b,l,k,p,n):Vb(h,e,k,m,n),Wb(this, -g,p,n,a,c);break}case "bidirectional":case "reverse":if(1p?0:1),e,k,r-1,n-1),u=this.bidirectional&& -l>q;Wb(this,f,u?q:l,v,a,c,u?l:q)}}}}this.fastupdate||this.reg.add(a)}else b=""}this.db&&(b||this.commit_task.push({del:a}),this.ca&&Tb(this));return this}; -function Wb(a,b,c,d,e,f,g){var h=g?a.ctx:a.map,k;if(!b[c]||g&&!(k=b[c])[g])if(g?(b=k||(b[c]=Q()),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===Math.pow(2,31)-1){b=new ib(h);if(a.fastupdate)for(c=z(a.reg.values()),f=c.next();!f.done;f=c.next())f=f.value,f.includes(h)&&(f[f.indexOf(h)]=b);k[d]=h=b}h.push(e);a.fastupdate&&((d=a.reg.get(e))?d.push(h):a.reg.set(e,[h]))}} -function Vb(a,b,c,d,e){return c&&1c)&&(k=c,c=b,b=k);if(a.db)return a.db.get(b,c,d,e,f,g,h);a=c?(a=a.ctx.get(c))&&a.get(b):a.map.get(b);return a};function U(a,b){if(!this||this.constructor!==U)return new U(a);if(a){var c=R(a)?a:a.preset;c&&(a=Object.assign({},Ub[c],a))}else a={};c=a.context;var d=!0===c?{depth:1}:c||{},e=R(a.encoder)?Rb[a.encoder]:a.encode||a.encoder||{};this.encoder=e.encode?e:"object"===typeof e?new La(e):{encode:e};this.resolution=a.resolution||9;this.tokenize=c=(c=a.tokenize)&&"default"!==c&&"exact"!==c&&c||"strict";this.depth="strict"===c&&d.depth||0;this.bidirectional=!1!==d.bidirectional;this.fastupdate=!!a.fastupdate; -this.score=a.score||null;(c=a.keystore||0)&&(this.keystore=c);this.map=c?new V(c):new Map;this.ctx=c?new V(c):new Map;this.reg=b||(this.fastupdate?c?new V(c):new Map:c?new W(c):new Set);this.da=d.resolution||3;this.rtl=e.rtl||a.rtl||!1;this.cache=(c=a.cache||null)&&new Ib(c);this.resolve=!1!==a.resolve;if(c=a.db)this.db=this.mount(c);this.ca=!1!==a.commit;this.commit_task=[];this.commit_timer=null;this.priority=a.priority||4}w=U.prototype; -w.mount=function(a){this.commit_timer&&(clearTimeout(this.commit_timer),this.commit_timer=null);return a.mount(this)};w.commit=function(a,b){this.commit_timer&&(clearTimeout(this.commit_timer),this.commit_timer=null);return this.db.commit(this,a,b)};w.destroy=function(){this.commit_timer&&(clearTimeout(this.commit_timer),this.commit_timer=null);return this.db.destroy()};function Tb(a){a.commit_timer||(a.commit_timer=setTimeout(function(){a.commit_timer=null;a.db.commit(a,void 0,void 0)},1))} -w.clear=function(){this.map.clear();this.ctx.clear();this.reg.clear();this.cache&&this.cache.clear();this.db&&(this.commit_timer&&clearTimeout(this.commit_timer),this.commit_timer=null,this.commit_task=[{clear:!0}]);return this};w.append=function(a,b){return this.add(a,b,!0)};w.contain=function(a){return this.db?this.db.has(a):this.reg.has(a)};w.update=function(a,b){var c=this,d=this.remove(a);return d&&d.then?d.then(function(){return c.add(a,b)}):this.add(a,b)}; -w.cleanup=function(){if(!this.fastupdate)return this;Sb(this.map);this.depth&&Sb(this.ctx);return this};w.searchCache=Kb;w.export=function(a,b,c,d){c=void 0===c?0:c;d=void 0===d?0:d;switch(d){case 0:var e="reg";var f=db(this.reg);break;case 1:e="cfg";f=null;break;case 2:e="map";f=$a(this.map,this.reg.size);break;case 3:e="ctx";f=bb(this.ctx,this.reg.size);break;default:return}return fb.call(this,a,b,e,f,c,d)}; -w.import=function(a,b){if(b)switch("string"===typeof b&&(b=JSON.parse(b)),a=a.split("."),"json"===a[a.length-1]&&a.pop(),3===a.length&&a.shift(),a=1=m.length)d-=m.length;else{for(var q=c?d+Math.min(m.length-d,c): -m.length,p=d;p=f.length)return[];if(!b&&!c)return f;f=f.slice(c,c+b);return d?e.enrich(f):f})}; -w.enrich=function(a){"object"!==typeof a&&(a=[a]);for(var b=this.db.transaction("reg","readonly").objectStore("reg"),c=[],d=0;dc||d)a=a.slice(d,d+c);e&&(a=sb.call(this,a));return a}} +function sb(a){if(!this||!this.store)return a;for(var b=Array(a.length),c=0,d;cthis.limit&&this.cache.delete(this.cache.keys().next().value)}; +Pb.prototype.get=function(a){var b=this.cache.get(a);b&&this.h!==a&&(this.cache.delete(a),this.cache.set(this.h=a,b));return b};Pb.prototype.remove=function(a){for(var b=A(this.cache),c=b.next();!c.done;c=b.next()){c=c.value;var d=c[0];c[1].includes(a)&&this.cache.delete(d)}};Pb.prototype.clear=function(){this.cache.clear();this.h=""};W.prototype.remove=function(a,b){var c=this.reg.size&&(this.fastupdate?this.reg.get(a):this.reg.has(a));if(c){if(this.fastupdate)for(var d=0,e;de.length)e.pop();else{var f=e.indexOf(a);f===c.length-1?e.pop():e.splice(f,1)}}else Sb(this.map,a),this.depth&&Sb(this.ctx,a);b||this.reg.delete(a)}this.db&&(this.commit_task.push({del:a}),this.ca&&Tb(this));this.cache&&this.cache.remove(a);return this}; +function Sb(a,b){var c=0,d="undefined"===typeof b;if(a.constructor===Array)for(var e=0,f=void 0,g;eq;r--)p=l.substring(q,r),n=this.rtl?m-1-q:q,n=this.score?this.score(b,l,k,p,n):Vb(h,e,k,m,n),Wb(this, +g,p,n,a,c);break}case "bidirectional":case "reverse":if(1p?0:1),e,k,r-1,n-1),w=this.bidirectional&& +l>q;Wb(this,f,w?q:l,u,a,c,w?l:q)}}}}this.fastupdate||this.reg.add(a)}else b=""}this.db&&(b||this.commit_task.push({del:a}),this.ca&&Tb(this));return this}; +function Wb(a,b,c,d,e,f,g){var h=g?a.ctx:a.map,k;if(!b[c]||g&&!(k=b[c])[g])if(g?(b=k||(b[c]=S()),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===Math.pow(2,31)-1){b=new ib(h);if(a.fastupdate)for(c=A(a.reg.values()),f=c.next();!f.done;f=c.next())f=f.value,f.includes(h)&&(f[f.indexOf(h)]=b);k[d]=h=b}h.push(e);a.fastupdate&&((d=a.reg.get(e))?d.push(h):a.reg.set(e,[h]))}} +function Vb(a,b,c,d,e){return c&&1c)&&(k=c,c=b,b=k);if(a.db)return a.db.get(b,c,d,e,f,g,h);a=c?(a=a.ctx.get(c))&&a.get(b):a.map.get(b);return a};function W(a,b){if(!this||this.constructor!==W)return new W(a);if(a){var c=T(a)?a:a.preset;c&&(a=Object.assign({},Ub[c],a))}else a={};c=a.context;var d=!0===c?{depth:1}:c||{},e=T(a.encoder)?Nb[a.encoder]:a.encode||a.encoder||{};this.encoder=e.encode?e:"object"===typeof e?new La(e):{encode:e};this.resolution=a.resolution||9;this.tokenize=c=(c=a.tokenize)&&"default"!==c&&"exact"!==c&&c||"strict";this.depth="strict"===c&&d.depth||0;this.bidirectional=!1!==d.bidirectional;this.fastupdate=!!a.fastupdate; +this.score=a.score||null;(c=a.keystore||0)&&(this.keystore=c);this.map=c?new X(c):new Map;this.ctx=c?new X(c):new Map;this.reg=b||(this.fastupdate?c?new X(c):new Map:c?new Y(c):new Set);this.da=d.resolution||3;this.rtl=e.rtl||a.rtl||!1;this.cache=(c=a.cache||null)&&new Pb(c);this.resolve=!1!==a.resolve;if(c=a.db)this.db=this.mount(c);this.ca=!1!==a.commit;this.commit_task=[];this.commit_timer=null;this.priority=a.priority||4}v=W.prototype; +v.mount=function(a){this.commit_timer&&(clearTimeout(this.commit_timer),this.commit_timer=null);return a.mount(this)};v.commit=function(a,b){this.commit_timer&&(clearTimeout(this.commit_timer),this.commit_timer=null);return this.db.commit(this,a,b)};v.destroy=function(){this.commit_timer&&(clearTimeout(this.commit_timer),this.commit_timer=null);return this.db.destroy()};function Tb(a){a.commit_timer||(a.commit_timer=setTimeout(function(){a.commit_timer=null;a.db.commit(a,void 0,void 0)},1))} +v.clear=function(){this.map.clear();this.ctx.clear();this.reg.clear();this.cache&&this.cache.clear();this.db&&(this.commit_timer&&clearTimeout(this.commit_timer),this.commit_timer=null,this.commit_task=[{clear:!0}]);return this};v.append=function(a,b){return this.add(a,b,!0)};v.contain=function(a){return this.db?this.db.has(a):this.reg.has(a)};v.update=function(a,b){var c=this,d=this.remove(a);return d&&d.then?d.then(function(){return c.add(a,b)}):this.add(a,b)}; +v.cleanup=function(){if(!this.fastupdate)return this;Sb(this.map);this.depth&&Sb(this.ctx);return this};v.searchCache=Rb;v.export=function(a,b,c,d){c=void 0===c?0:c;d=void 0===d?0:d;switch(d){case 0:var e="reg";var f=db(this.reg);break;case 1:e="cfg";f=null;break;case 2:e="map";f=$a(this.map,this.reg.size);break;case 3:e="ctx";f=bb(this.ctx,this.reg.size);break;default:return}return fb.call(this,a,b,e,f,c,d)}; +v.import=function(a,b){if(b)switch("string"===typeof b&&(b=JSON.parse(b)),a=a.split("."),"json"===a[a.length-1]&&a.pop(),3===a.length&&a.shift(),a=1=m.length)d-=m.length;else{for(var q=c?d+Math.min(m.length-d,c): +m.length,p=d;p=f.length)return[];if(!b&&!c)return f;f=f.slice(c,c+b);return d?e.enrich(f):f})}; +v.enrich=function(a){"object"!==typeof a&&(a=[a]);for(var b=this.db.transaction("reg","readonly").objectStore("reg"),c=[],d=0;d} + * @type {Map} */ this.index = parse_descriptor.call(this, options, document); @@ -92,7 +93,7 @@ export default function Document(options) { this.tagtree[i]._filter = params.filter; } } - // the tag fields needs to be hold by indices + // the tag fields need to be hold by indices this.tagfield[i] = field; this.tag.set(field, new Map()); } @@ -109,26 +110,38 @@ export default function Document(options) { if (promises.length) { const self = this; return Promise.all(promises).then(function (result) { - const encoder_last = new Map(); + new Map(); + let count = 0; for (const item of self.index.entries()) { const key = /** @type {string} */item[0]; - let index = item[1]; + let index = /** @type {Index|WorkerIndex | Promise} */item[1]; + // let encoder; + // if(SUPPORT_HIGHLIGHTING && SUPPORT_STORE){ + // // make encoder available for result highlighting + // let opt = promises[count].encoder || {}; + // // handle shared encoders + // let encoder = encoder_last.get(opt); + // if(!encoder){ + // encoder = opt.encode + // ? opt + // : SUPPORT_ENCODER + // ? new Encoder( + // SUPPORT_CHARSET && typeof opt === "string" + // ? Charset[opt] + // : opt) + // : { encode: fallback_encoder }; + // encoder_last.set(opt, encoder); + // } + // } if (index.then) { - // make encoder available for result highlighting - let opt = promises[count].encoder || {}, - encoder = encoder_last.get(opt); - // handle shared encoders - - if (!encoder) { - encoder = opt.encode ? opt : new Encoder(opt); - encoder_last.set(opt, encoder); - } index = result[count]; - index.encoder = encoder; self.index.set(key, index); count++; } + // if(encoder){ + // index.encoder = encoder; + // } } return self; }); @@ -136,7 +149,8 @@ export default function Document(options) { } else { if (options.db) { this.fastupdate = !1; - // actually it can be awaited on "await index.db" + // a constructor should not return a promise + // it can be awaited on "await index.db" this.mount(options.db); } } @@ -234,10 +248,12 @@ Document.prototype.destroy = function () { /** * @this {Document} + * @return {Map} */ function parse_descriptor(options, document) { + /** @type {Map} */ const index = new Map(); let field = document.index || document.field || document; @@ -257,10 +273,13 @@ function parse_descriptor(options, document) { opt = /** @type IndexOptions */is_object(opt) ? Object.assign({}, options, opt) : options; if (this.worker) { - const worker = new WorkerIndex(opt); + let encoder = opt.encoder; + // assign encoder for result highlighting + + encoder = encoder && encoder.encode ? encoder : new Encoder("string" == typeof encoder ? Charset[encoder] : encoder); + + const worker = new WorkerIndex(opt, /** @type {Encoder} */encoder); if (worker) { - // assign encoder for result highlighting - worker.encoder = opt.encoder; // worker could be a promise // it needs to be resolved and swapped later index.set(key, worker); diff --git a/dist/module-debug/document/search.js b/dist/module-debug/document/search.js index 4e6f56c..e497ebc 100644 --- a/dist/module-debug/document/search.js +++ b/dist/module-debug/document/search.js @@ -1,7 +1,7 @@ import { DocumentSearchOptions, DocumentSearchResults, EnrichedDocumentSearchResults, MergedDocumentSearchResults, MergedDocumentSearchEntry, EnrichedSearchResults, SearchResults, IntermediateSearchResults } from "../type.js"; import { create_object, is_array, is_object, is_string } from "../common.js"; -import { intersect_union } from "../intersect.js"; +import { intersect, intersect_union } from "../intersect.js"; import Document from "../document.js"; import Index from "../index.js"; import Resolver from "../resolver.js"; @@ -48,7 +48,8 @@ Document.prototype.search = function (query, limit, options, _promises) { if (options && options.cache) { options.cache = /* suggest */ /* append: */ /* enrich */!1; const res = this.searchCache(query, limit, options); - options.cache = /* tag? */ /* stringify */ /* stringify */ /* single param */ /* skip update: */ /* append: */ /* skip update: */ /* skip_update: */!0 /*await rows.hasNext()*/ /*await rows.hasNext()*/ /*await rows.hasNext()*/; + options.cache = /* tag? */ /* stringify */ /* stringify */ /* single param */ /* skip update: */ /* append: */ /* skip update: */ /* skip_update: */!0 /*await rows.hasNext()*/ /*await rows.hasNext()*/ + /*await rows.hasNext()*/; return res; } @@ -66,6 +67,7 @@ Document.prototype.search = function (query, limit, options, _promises) { enrich, merge, suggest, + boost, field, tag, offset, @@ -85,29 +87,12 @@ Document.prototype.search = function (query, limit, options, _promises) { query = options.query || query; pluck = options.pluck; merge = options.merge; + boost = options.boost; field = pluck || options.field || (field = options.index) && (field.index ? null : field); tag = this.tag && options.tag; suggest = options.suggest; resolve = !1 !== options.resolve; - // upgrade pluck when missing - if (!resolve && !pluck) { - field = field || this.field; - if (field) { - if (is_string(field)) { - pluck = field; - } else { - if (is_array(field) && 1 === field.length) { - field = field[0]; - } - pluck = field.field || field.index; - } - } - if (!pluck) { - throw new Error("Apply resolver on document search requires either the option 'pluck' to be set or just select a single field name in your query."); - } - } - if (this.store && options.highlight && !resolve) { console.warn("Highlighting results can only be done on a final resolver task or when calling .resolve({ highlight: ... })"); } else if (this.store && options.enrich && !resolve) { @@ -119,7 +104,7 @@ Document.prototype.search = function (query, limit, options, _promises) { enrich = !!highlight || resolve && this.store && options.enrich; limit = options.limit || limit; offset = options.offset || 0; - limit || (limit = 100); + limit || (limit = resolve ? 100 : 0); if (tag && (!this.db || !_promises)) { @@ -192,23 +177,46 @@ Document.prototype.search = function (query, limit, options, _promises) { } else { ids = get_tag.call(this, pairs[j], pairs[j + 1], limit, offset, enrich); } - result.push({ + result.push(resolve ? { field: pairs[j], tag: pairs[j + 1], result: ids - }); + } : [ids]); } if (promises.length) { + const self = this; return Promise.all(promises).then(function (promises) { for (let j = 0; j < promises.length; j++) { - result[j].result = promises[j]; + if (resolve) { + result[j].result = promises[j]; + } else { + result[j] = promises[j]; + } } - return result; + return resolve || !!0 ? result : new Resolver(1 < result.length ? intersect(result, 1, 0, 0, suggest, boost) : result[0], self); }); } - return result; + return resolve || !!0 ? result : new Resolver(1 < result.length ? intersect(result, 1, 0, 0, suggest, boost) : result[0], this); + } + } + + // upgrade pluck when missing + if (!resolve && !pluck) { + field = field || this.field; + if (field) { + if (is_string(field)) { + pluck = field; + } else { + if (is_array(field) && 1 === field.length) { + field = field[0]; + } + pluck = field.field || field.index; + } + } + if (!pluck) { + throw new Error("Apply resolver on document search requires either the option 'pluck' to be set or just select a single field name in your query."); } } @@ -493,7 +501,7 @@ function merge_fields(fields) { function get_tag(tag, key, limit, offset) { let res = this.tag.get(tag); if (!res) { - console.warn("Tag '" + tag + "' was not found"); + console.warn("Tag-Field '" + tag + "' was not found"); return []; } res = res && res.get(key); diff --git a/dist/module-debug/intersect.js b/dist/module-debug/intersect.js index 8181a6f..c77a41e 100644 --- a/dist/module-debug/intersect.js +++ b/dist/module-debug/intersect.js @@ -1,4 +1,5 @@ +import Resolver from "./resolver.js"; import { create_object, concat, sort_by_length_up, get_max_len } from "./common.js"; import { SearchResults, IntermediateSearchResults } from "./type.js"; @@ -239,7 +240,7 @@ export function union(arrays, limit, offset, resolve, boost) { } /** - * @param {SearchResults|IntermediateSearchResults} arrays + * @param {SearchResults|IntermediateSearchResults|Resolver} arrays * @param {Array} mandatory * @param {boolean=} resolve * @returns {SearchResults} diff --git a/dist/module-debug/resolve/handler.js b/dist/module-debug/resolve/handler.js index f069c15..6e3381d 100644 --- a/dist/module-debug/resolve/handler.js +++ b/dist/module-debug/resolve/handler.js @@ -63,29 +63,31 @@ Resolver.prototype.handler = function (fn, args) { if (query.index) { this.index = index = query.index; + } else { + index = this.index; } if (query.query || query.tag) { if (!this.index) { throw new Error("Resolver can't apply because the corresponding Index was never specified"); } - - if (query.field) { - if (!this.index.index) { - throw new Error("Resolver can't apply because the corresponding Document Index was not specified"); - } + { + const field = query.field || query.pluck; + if (field) { + if (!this.index.index) { + throw new Error("Resolver can't apply because the corresponding Document Index was not specified"); + } - index = this.index.index.get(query.field); + index = this.index.index.get(field); - if (!index) { - throw new Error("Resolver can't apply because the specified Document field '" + query.field + "' was not found"); + if (!index) { + throw new Error("Resolver can't apply because the specified Document Field '" + field + "' was not found"); + } } } - - query.resolve = /* suggest */ - /* append: */ /* enrich */!1; + query.resolve = /* suggest */ /* append: */ /* enrich */!1; //if(DEBUG) //query.enrich = false; result = index.search(query).result; diff --git a/dist/module-debug/type.js b/dist/module-debug/type.js index df3bbb6..51a8f87 100644 --- a/dist/module-debug/type.js +++ b/dist/module-debug/type.js @@ -10,7 +10,7 @@ import StorageInterface from "./db/interface.js"; * preset: (string|undefined), * context: (IndexOptions|undefined), * encoder: (Encoder|Function|Object|undefined), - * encode: (Function|undefined), + * encode: (function(string):Array|undefined), * resolution: (number|undefined), * tokenize: (string|undefined), * fastupdate: (boolean|undefined), diff --git a/dist/module-debug/worker.js b/dist/module-debug/worker.js index 48abcdd..69aef56 100644 --- a/dist/module-debug/worker.js +++ b/dist/module-debug/worker.js @@ -3,15 +3,17 @@ import { IndexOptions } from "./type.js"; import { create_object } from "./common.js"; import handler from "./worker/handler.js"; import apply_async from "./async.js"; +import Encoder from "./encoder.js"; let pid = 0; /** * @param {IndexOptions=} options + * @param {Encoder=} encoder * @constructor */ -export default function WorkerIndex(options = /** @type IndexOptions */{}) { +export default function WorkerIndex(options = /** @type IndexOptions */{}, encoder) { if (!this || this.constructor !== WorkerIndex) { return new WorkerIndex(options); @@ -80,6 +82,10 @@ export default function WorkerIndex(options = /** @type IndexOptions */{}) { this.priority = options.priority || 4; + // assign encoder for result highlighting + if (encoder) { + this.encoder = encoder; + } return this; } diff --git a/dist/module-min/document.js b/dist/module-min/document.js index 3fc1171..32bcb63 100644 --- a/dist/module-min/document.js +++ b/dist/module-min/document.js @@ -1 +1 @@ -import{IndexOptions,DocumentOptions,DocumentDescriptor,FieldOptions,StoreOptions,EncoderOptions}from"./type.js";import StorageInterface from"./db/interface.js";import Index from"./index.js";import WorkerIndex from"./worker.js";import Encoder from"./encoder.js";import Cache,{searchCache}from"./cache.js";import{is_string,is_object,parse_simple}from"./common.js";import apply_async from"./async.js";import{exportDocument,importDocument}from"./serialize.js";import{KeystoreMap,KeystoreSet}from"./keystore.js";import"./document/add.js";import"./document/search.js";export default function Document(a){if(!this||this.constructor!==Document)return new Document(a);const b=a.document||a.doc||a;let c,d;if(this.tree=[],this.field=[],this.marker=[],this.key=(c=b.key||b.id)&&parse_tree(c,this.marker)||"id",d=a.keystore||0,d&&(this.keystore=d),this.fastupdate=!!a.fastupdate,this.reg=!this.fastupdate||a.worker||a.db?d&&!0?new KeystoreSet(d):new Set:d&&!0?new KeystoreMap(d):new Map,this.storetree=(c=b.store||null)&&c&&!0!==c&&[],this.store=c&&(d&&!0?new KeystoreMap(d):new Map),this.cache=(c=a.cache||null)&&new Cache(c),a.cache=!1,this.worker=a.worker||!1,this.priority=a.priority||4,this.index=parse_descriptor.call(this,a,b),(this.tag=null,(c=b.tag)&&("string"==typeof c&&(c=[c]),c.length))){this.tag=new Map,this.tagtree=[],this.tagfield=[];for(let a,b,d=0;dc||d)&&(k=k.slice(d,c+d));else{const a=[];for(let b,e=0;ed){d-=b.length;continue}if((c&&b.length>c||d)&&(b=b.slice(d,c+d),c-=b.length,d&&(d-=b.length)),a.push(b),!c)break}k=a}}else k=1c||d?k.slice(d,c+d):k;return k}export function union(a,b,c,d,e){const f=[],g=create_object();let h,l,m,n=a.length;if(!d)for(let d,j=n-1,i=0;0<=j;j--){d=a[j];for(let a=0;ac||d)&&(k=k.slice(d,c+d));else{const a=[];for(let b,e=0;ed){d-=b.length;continue}if((c&&b.length>c||d)&&(b=b.slice(d,c+d),c-=b.length,d&&(d-=b.length)),a.push(b),!c)break}k=a}}else k=1c||d?k.slice(d,c+d):k;return k}export function union(a,b,c,d,e){const f=[],g=create_object();let h,l,m,n=a.length;if(!d)for(let d,j=n-1,i=0;0<=j;j--){d=a[j];for(let a=0;a} + * @type {Map} */ this.index = parse_descriptor.call(this, options, document); @@ -92,7 +93,7 @@ export default function Document(options) { this.tagtree[i]._filter = params.filter; } } - // the tag fields needs to be hold by indices + // the tag fields need to be hold by indices this.tagfield[i] = field; this.tag.set(field, new Map()); } @@ -109,26 +110,38 @@ export default function Document(options) { if (promises.length) { const self = this; return Promise.all(promises).then(function (result) { - const encoder_last = new Map(); + new Map(); + let count = 0; for (const item of self.index.entries()) { const key = /** @type {string} */item[0]; - let index = item[1]; + let index = /** @type {Index|WorkerIndex | Promise} */item[1]; + // let encoder; + // if(SUPPORT_HIGHLIGHTING && SUPPORT_STORE){ + // // make encoder available for result highlighting + // let opt = promises[count].encoder || {}; + // // handle shared encoders + // let encoder = encoder_last.get(opt); + // if(!encoder){ + // encoder = opt.encode + // ? opt + // : SUPPORT_ENCODER + // ? new Encoder( + // SUPPORT_CHARSET && typeof opt === "string" + // ? Charset[opt] + // : opt) + // : { encode: fallback_encoder }; + // encoder_last.set(opt, encoder); + // } + // } if (index.then) { - // make encoder available for result highlighting - let opt = promises[count].encoder || {}, - encoder = encoder_last.get(opt); - // handle shared encoders - - if (!encoder) { - encoder = opt.encode ? opt : new Encoder(opt); - encoder_last.set(opt, encoder); - } index = result[count]; - index.encoder = encoder; self.index.set(key, index); count++; } + // if(encoder){ + // index.encoder = encoder; + // } } return self; }); @@ -136,7 +149,8 @@ export default function Document(options) { } else { if (options.db) { this.fastupdate = !1; - // actually it can be awaited on "await index.db" + // a constructor should not return a promise + // it can be awaited on "await index.db" this.mount(options.db); } } @@ -230,10 +244,12 @@ Document.prototype.destroy = function () { /** * @this {Document} + * @return {Map} */ function parse_descriptor(options, document) { + /** @type {Map} */ const index = new Map(); let field = document.index || document.field || document; @@ -253,10 +269,13 @@ function parse_descriptor(options, document) { opt = /** @type IndexOptions */is_object(opt) ? Object.assign({}, options, opt) : options; if (this.worker) { - const worker = new WorkerIndex(opt); + let encoder = opt.encoder; + // assign encoder for result highlighting + + encoder = encoder && encoder.encode ? encoder : new Encoder("string" == typeof encoder ? Charset[encoder] : encoder); + + const worker = new WorkerIndex(opt, /** @type {Encoder} */encoder); if (worker) { - // assign encoder for result highlighting - worker.encoder = opt.encoder; // worker could be a promise // it needs to be resolved and swapped later index.set(key, worker); diff --git a/dist/module/document/search.js b/dist/module/document/search.js index bdeb4ec..9417aea 100644 --- a/dist/module/document/search.js +++ b/dist/module/document/search.js @@ -1,7 +1,7 @@ import { DocumentSearchOptions, DocumentSearchResults, EnrichedDocumentSearchResults, MergedDocumentSearchResults, MergedDocumentSearchEntry, EnrichedSearchResults, SearchResults, IntermediateSearchResults } from "../type.js"; import { create_object, is_array, is_object, is_string } from "../common.js"; -import { intersect_union } from "../intersect.js"; +import { intersect, intersect_union } from "../intersect.js"; import Document from "../document.js"; import Index from "../index.js"; import Resolver from "../resolver.js"; @@ -48,7 +48,8 @@ Document.prototype.search = function (query, limit, options, _promises) { if (options && options.cache) { options.cache = /* suggest */ /* append: */ /* enrich */!1; const res = this.searchCache(query, limit, options); - options.cache = /* tag? */ /* stringify */ /* stringify */ /* single param */ /* skip update: */ /* append: */ /* skip update: */ /* skip_update: */!0 /*await rows.hasNext()*/ /*await rows.hasNext()*/ /*await rows.hasNext()*/; + options.cache = /* tag? */ /* stringify */ /* stringify */ /* single param */ /* skip update: */ /* append: */ /* skip update: */ /* skip_update: */!0 /*await rows.hasNext()*/ /*await rows.hasNext()*/ + /*await rows.hasNext()*/; return res; } @@ -66,6 +67,7 @@ Document.prototype.search = function (query, limit, options, _promises) { enrich, merge, suggest, + boost, field, tag, offset, @@ -85,31 +87,17 @@ Document.prototype.search = function (query, limit, options, _promises) { query = options.query || query; pluck = options.pluck; merge = options.merge; + boost = options.boost; field = pluck || options.field || (field = options.index) && (field.index ? null : field); tag = this.tag && options.tag; suggest = options.suggest; resolve = !1 !== options.resolve; - // upgrade pluck when missing - if (!resolve && !pluck) { - field = field || this.field; - if (field) { - if (is_string(field)) { - pluck = field; - } else { - if (is_array(field) && 1 === field.length) { - field = field[0]; - } - pluck = field.field || field.index; - } - } - } - highlight = resolve && this.store && options.highlight; enrich = !!highlight || resolve && this.store && options.enrich; limit = options.limit || limit; offset = options.offset || 0; - limit || (limit = 100); + limit || (limit = resolve ? 100 : 0); if (tag && (!this.db || !_promises)) { @@ -174,23 +162,43 @@ Document.prototype.search = function (query, limit, options, _promises) { } else { ids = get_tag.call(this, pairs[j], pairs[j + 1], limit, offset, enrich); } - result.push({ + result.push(resolve ? { field: pairs[j], tag: pairs[j + 1], result: ids - }); + } : [ids]); } if (promises.length) { + const self = this; return Promise.all(promises).then(function (promises) { for (let j = 0; j < promises.length; j++) { - result[j].result = promises[j]; + if (resolve) { + result[j].result = promises[j]; + } else { + result[j] = promises[j]; + } } - return result; + return resolve || !!0 ? result : new Resolver(1 < result.length ? intersect(result, 1, 0, 0, suggest, boost) : result[0], self); }); } - return result; + return resolve || !!0 ? result : new Resolver(1 < result.length ? intersect(result, 1, 0, 0, suggest, boost) : result[0], this); + } + } + + // upgrade pluck when missing + if (!resolve && !pluck) { + field = field || this.field; + if (field) { + if (is_string(field)) { + pluck = field; + } else { + if (is_array(field) && 1 === field.length) { + field = field[0]; + } + pluck = field.field || field.index; + } } } diff --git a/dist/module/intersect.js b/dist/module/intersect.js index 8181a6f..c77a41e 100644 --- a/dist/module/intersect.js +++ b/dist/module/intersect.js @@ -1,4 +1,5 @@ +import Resolver from "./resolver.js"; import { create_object, concat, sort_by_length_up, get_max_len } from "./common.js"; import { SearchResults, IntermediateSearchResults } from "./type.js"; @@ -239,7 +240,7 @@ export function union(arrays, limit, offset, resolve, boost) { } /** - * @param {SearchResults|IntermediateSearchResults} arrays + * @param {SearchResults|IntermediateSearchResults|Resolver} arrays * @param {Array} mandatory * @param {boolean=} resolve * @returns {SearchResults} diff --git a/dist/module/resolve/handler.js b/dist/module/resolve/handler.js index a570e1a..8c32bd1 100644 --- a/dist/module/resolve/handler.js +++ b/dist/module/resolve/handler.js @@ -63,17 +63,20 @@ Resolver.prototype.handler = function (fn, args) { if (query.index) { this.index = index = query.index; + } else { + index = this.index; } if (query.query || query.tag) { - if (query.field) { + { + const field = query.field || query.pluck; + if (field) { - index = this.index.index.get(query.field); + index = this.index.index.get(field); + } } - - query.resolve = /* suggest */ - /* append: */ /* enrich */!1; + query.resolve = /* suggest */ /* append: */ /* enrich */!1; //if(DEBUG) //query.enrich = false; result = index.search(query).result; diff --git a/dist/module/type.js b/dist/module/type.js index df3bbb6..51a8f87 100644 --- a/dist/module/type.js +++ b/dist/module/type.js @@ -10,7 +10,7 @@ import StorageInterface from "./db/interface.js"; * preset: (string|undefined), * context: (IndexOptions|undefined), * encoder: (Encoder|Function|Object|undefined), - * encode: (Function|undefined), + * encode: (function(string):Array|undefined), * resolution: (number|undefined), * tokenize: (string|undefined), * fastupdate: (boolean|undefined), diff --git a/dist/module/worker.js b/dist/module/worker.js index 48abcdd..69aef56 100644 --- a/dist/module/worker.js +++ b/dist/module/worker.js @@ -3,15 +3,17 @@ import { IndexOptions } from "./type.js"; import { create_object } from "./common.js"; import handler from "./worker/handler.js"; import apply_async from "./async.js"; +import Encoder from "./encoder.js"; let pid = 0; /** * @param {IndexOptions=} options + * @param {Encoder=} encoder * @constructor */ -export default function WorkerIndex(options = /** @type IndexOptions */{}) { +export default function WorkerIndex(options = /** @type IndexOptions */{}, encoder) { if (!this || this.constructor !== WorkerIndex) { return new WorkerIndex(options); @@ -80,6 +82,10 @@ export default function WorkerIndex(options = /** @type IndexOptions */{}) { this.priority = options.priority || 4; + // assign encoder for result highlighting + if (encoder) { + this.encoder = encoder; + } return this; } diff --git a/doc/document-search.md b/doc/document-search.md index 9f9c7b1..4d201a5 100644 --- a/doc/document-search.md +++ b/doc/document-search.md @@ -298,7 +298,7 @@ To query against one or multiple specific fields you have to pass the exact key ```js index.search(query, { - index: [ + field: [ "record:title", "record:content:header", "record:content:footer" diff --git a/index.d.ts b/index.d.ts index 3c5afa3..b225e53 100644 --- a/index.d.ts +++ b/index.d.ts @@ -898,9 +898,9 @@ declare module "flexsearch" { offset?: number; resolve?: R; /** only usable when "resolve" was not set to false */ - enrich?: D extends DocumentData - ? R extends true ? E : false - : false; + enrich?: D extends undefined + ? false + : R extends true ? E : false; }; export type ResolverOptions< @@ -910,7 +910,7 @@ declare module "flexsearch" { H extends HighlightOptions | boolean = false, R extends boolean = false, E extends boolean = H extends HighlightOptions ? true : false - > = DefaultResolve & { + > = Resolver | (DefaultResolve & { query?: string; index?: Index | Document; pluck?: FieldName; @@ -923,10 +923,10 @@ declare module "flexsearch" { boost?: number; suggest?: boolean; /** only usable when "resolve" was not set to false */ - highlight?: D extends DocumentData - ? R extends true ? H : false - : false; - }; + highlight?: D extends undefined + ? false + : R extends true ? H : false; + }); export type HighlightBoundaryOptions = { before?: number; diff --git a/package-lock.json b/package-lock.json index b81f2a2..7c74128 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "flexsearch", - "version": "0.8.163", + "version": "0.8.164", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "flexsearch", - "version": "0.8.163", + "version": "0.8.164", "funding": [ { "type": "github", diff --git a/package.json b/package.json index 573ca93..0bbff5b 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "public": true, "preferGlobal": false, "name": "flexsearch", - "version": "0.8.163", + "version": "0.8.164", "description": "Next-Generation full-text search library for Browser and Node.js", "homepage": "https://github.com/nextapps-de/flexsearch/", "author": "Thomas Wilkerling", diff --git a/src/document.js b/src/document.js index 8546bfb..c9aa76f 100644 --- a/src/document.js +++ b/src/document.js @@ -11,6 +11,9 @@ import { DEBUG, SUPPORT_ASYNC, SUPPORT_CACHE, + SUPPORT_CHARSET, + SUPPORT_ENCODER, + SUPPORT_HIGHLIGHTING, SUPPORT_KEYSTORE, SUPPORT_PERSISTENT, SUPPORT_SERIALIZE, @@ -31,7 +34,7 @@ import { import StorageInterface from "./db/interface.js"; import Index from "./index.js"; import WorkerIndex from "./worker.js"; -import Encoder from "./encoder.js"; +import Encoder, { fallback_encoder } from "./encoder.js"; import Cache, { searchCache } from "./cache.js"; import { is_string, is_object, parse_simple } from "./common.js"; import apply_async from "./async.js"; @@ -39,6 +42,7 @@ import { exportDocument, importDocument } from "./serialize.js"; import { KeystoreMap, KeystoreSet } from "./keystore.js"; import "./document/add.js"; import "./document/search.js"; +import Charset from "./charset.js"; /** * @constructor @@ -97,7 +101,7 @@ export default function Document(options){ } /** - * @type {Map} + * @type {Map} */ this.index = parse_descriptor.call(this, options, document); @@ -131,7 +135,7 @@ export default function Document(options){ this.tagtree[i]._filter = params.filter; } } - // the tag fields needs to be hold by indices + // the tag fields need to be hold by indices this.tagfield[i] = field; this.tag.set(field, new Map()); } @@ -153,23 +157,33 @@ export default function Document(options){ let count = 0; for(const item of self.index.entries()){ const key = /** @type {string} */ (item[0]); - let index = item[1]; + let index = /** @type {Index|WorkerIndex | Promise} */ (item[1]); + // let encoder; + // if(SUPPORT_HIGHLIGHTING && SUPPORT_STORE){ + // // make encoder available for result highlighting + // let opt = promises[count].encoder || {}; + // // handle shared encoders + // let encoder = encoder_last.get(opt); + // if(!encoder){ + // encoder = opt.encode + // ? opt + // : SUPPORT_ENCODER + // ? new Encoder( + // SUPPORT_CHARSET && typeof opt === "string" + // ? Charset[opt] + // : opt) + // : { encode: fallback_encoder }; + // encoder_last.set(opt, encoder); + // } + // } if(index.then){ - // make encoder available for result highlighting - let opt = promises[count].encoder || {}; - // handle shared encoders - let encoder = encoder_last.get(opt); - if(!encoder){ - encoder = opt.encode - ? opt - : new Encoder(opt); - encoder_last.set(opt, encoder); - } index = result[count]; - index.encoder = encoder; self.index.set(key, index); count++; } + // if(encoder){ + // index.encoder = encoder; + // } } return self; }); @@ -178,7 +192,8 @@ export default function Document(options){ else if(SUPPORT_PERSISTENT){ if(options.db){ this.fastupdate = false; - // actually it can be awaited on "await index.db" + // a constructor should not return a promise + // it can be awaited on "await index.db" this.mount(options.db); } } @@ -281,10 +296,12 @@ if(SUPPORT_PERSISTENT){ /** * @this {Document} + * @return {Map} */ function parse_descriptor(options, document){ + /** @type {Map} */ const index = new Map(); let field = document.index || document.field || document; @@ -308,10 +325,21 @@ function parse_descriptor(options, document){ ); if(SUPPORT_WORKER && this.worker){ - const worker = new WorkerIndex(opt); + let encoder; + // assign encoder for result highlighting + if(SUPPORT_HIGHLIGHTING && SUPPORT_STORE){ + encoder = opt.encoder; + encoder = encoder && encoder.encode + ? encoder + : SUPPORT_ENCODER + ? new Encoder( + SUPPORT_CHARSET && typeof encoder === "string" + ? Charset[encoder] + : encoder) + : { encode: fallback_encoder }; + } + const worker = new WorkerIndex(opt, /** @type {Encoder} */ (encoder)); if(worker){ - // assign encoder for result highlighting - worker.encoder = opt.encoder; // worker could be a promise // it needs to be resolved and swapped later index.set(key, worker); diff --git a/src/document/search.js b/src/document/search.js index 12d7455..44a3944 100644 --- a/src/document/search.js +++ b/src/document/search.js @@ -22,7 +22,7 @@ import { IntermediateSearchResults } from "../type.js"; import { create_object, is_array, is_object, is_string } from "../common.js"; -import { intersect_union } from "../intersect.js"; +import { intersect, intersect_union } from "../intersect.js"; import Document from "../document.js"; import Index from "../index.js"; import Resolver from "../resolver.js"; @@ -86,7 +86,7 @@ Document.prototype.search = function(query, limit, options, _promises){ * } */ let result = []; let result_field = []; - let pluck, enrich, merge, suggest; + let pluck, enrich, merge, suggest, boost; let field, tag, offset, count = 0, resolve = true, highlight; if(options){ @@ -100,30 +100,12 @@ Document.prototype.search = function(query, limit, options, _promises){ query = options.query || query; pluck = options.pluck; merge = options.merge; + boost = options.boost; field = pluck || options.field || ((field = options.index) && (field.index ? null : field)); tag = SUPPORT_TAGS && this.tag && options.tag; suggest = SUPPORT_SUGGESTION && options.suggest; resolve = !SUPPORT_RESOLVER || (options.resolve !== false); - // upgrade pluck when missing - if(SUPPORT_RESOLVER && !resolve && !pluck){ - field = field || this.field; - if(field){ - if(is_string(field)){ - pluck = field; - } - else{ - if(is_array(field) && field.length === 1){ - field = field[0]; - } - pluck = field.field || field.index; - } - } - if(DEBUG && !pluck){ - throw new Error("Apply resolver on document search requires either the option 'pluck' to be set or just select a single field name in your query."); - } - } - if(DEBUG){ if(SUPPORT_STORE && this.store && options.highlight && !resolve){ console.warn("Highlighting results can only be done on a final resolver task or when calling .resolve({ highlight: ... })"); @@ -137,7 +119,7 @@ Document.prototype.search = function(query, limit, options, _promises){ enrich = SUPPORT_STORE && (!!highlight || (resolve && this.store && options.enrich)); limit = options.limit || limit; offset = options.offset || 0; - limit || (limit = 100); + limit || (limit = (resolve ? 100 : 0)); if(tag && (!SUPPORT_PERSISTENT || !this.db || !_promises)){ @@ -217,23 +199,56 @@ Document.prototype.search = function(query, limit, options, _promises){ PROFILER && tick("Document.search:tag:get:" + pairs[j + 1]); ids = get_tag.call(this, pairs[j], pairs[j + 1], limit, offset, enrich); } - result.push({ + result.push(resolve ? { "field": pairs[j], "tag": pairs[j + 1], "result": ids - }); + } : [ids]); } if(promises.length){ + const self = this; return Promise.all(promises).then(function(promises){ for(let j = 0; j < promises.length; j++){ - result[j].result = promises[j]; + if(resolve){ + result[j]["result"] = promises[j]; + } + else{ + result[j] = promises[j]; + } } - return result; + return resolve || !SUPPORT_RESOLVER + ? result + : new Resolver(result.length > 1 + ? intersect(result, 1, 0, 0, suggest, boost) + : result[0], self) }); } - return result; + return resolve || !SUPPORT_RESOLVER + ? result + : new Resolver(result.length > 1 + ? intersect(result, 1, 0, 0, suggest, boost) + : result[0], this) + } + } + + // upgrade pluck when missing + if(SUPPORT_RESOLVER && !resolve && !pluck){ + field = field || this.field; + if(field){ + if(is_string(field)){ + pluck = field; + } + else{ + if(is_array(field) && field.length === 1){ + field = field[0]; + } + pluck = field.field || field.index; + } + } + if(DEBUG && !pluck){ + throw new Error("Apply resolver on document search requires either the option 'pluck' to be set or just select a single field name in your query."); } } @@ -568,14 +583,14 @@ function get_tag(tag, key, limit, offset, enrich){ PROFILER && tick("Document.search:tag:get:" + key); let res = this.tag.get(tag); if(!res){ - DEBUG && console.warn("Tag '" + tag + "' was not found"); + DEBUG && console.warn("Tag-Field '" + tag + "' was not found"); return []; } res = res && res.get(key); let len = res && (res.length - offset); if(len && (len > 0)){ - if((len > limit) || offset){ + if((limit && len > limit) || offset){ res = res.slice(offset, offset + limit); } if(enrich){ diff --git a/src/intersect.js b/src/intersect.js index 22b7e52..5b78c54 100644 --- a/src/intersect.js +++ b/src/intersect.js @@ -1,6 +1,7 @@ // COMPILER BLOCK --> import { SUPPORT_RESOLVER } from "./config.js"; // <-- COMPILER BLOCK +import Resolver from "./resolver.js"; import { create_object, concat, sort_by_length_up, get_max_len } from "./common.js"; import { SearchResults, IntermediateSearchResults } from "./type.js"; @@ -250,7 +251,7 @@ export function union(arrays, limit, offset, resolve, boost){ } /** - * @param {SearchResults|IntermediateSearchResults} arrays + * @param {SearchResults|IntermediateSearchResults|Resolver} arrays * @param {Array} mandatory * @param {boolean=} resolve * @returns {SearchResults} diff --git a/src/resolve/handler.js b/src/resolve/handler.js index 22f14b8..6c137fe 100644 --- a/src/resolve/handler.js +++ b/src/resolve/handler.js @@ -73,6 +73,9 @@ Resolver.prototype.handler = function(fn, args){ if(query.index){ this.index = index = query.index; } + else{ + index = this.index; + } if(query.query || query.tag){ @@ -83,7 +86,8 @@ Resolver.prototype.handler = function(fn, args){ } if(SUPPORT_DOCUMENT){ - if(query.field){ + const field = query.field || query.pluck; + if(field){ if(DEBUG){ if(!this.index.index){ @@ -91,11 +95,11 @@ Resolver.prototype.handler = function(fn, args){ } } - index = this.index.index.get(query.field); + index = this.index.index.get(field); if(DEBUG){ if(!index){ - throw new Error("Resolver can't apply because the specified Document field '" + query.field + "' was not found"); + throw new Error("Resolver can't apply because the specified Document Field '" + field + "' was not found"); } } } diff --git a/src/type.js b/src/type.js index b380720..c409e46 100644 --- a/src/type.js +++ b/src/type.js @@ -10,7 +10,7 @@ import StorageInterface from "./db/interface.js"; * preset: (string|undefined), * context: (IndexOptions|undefined), * encoder: (Encoder|Function|Object|undefined), - * encode: (Function|undefined), + * encode: (function(string):Array|undefined), * resolution: (number|undefined), * tokenize: (string|undefined), * fastupdate: (boolean|undefined), diff --git a/src/worker.js b/src/worker.js index 09d6d40..ec812bd 100644 --- a/src/worker.js +++ b/src/worker.js @@ -1,19 +1,24 @@ // COMPILER BLOCK --> -import { SUPPORT_ASYNC, SUPPORT_WORKER } from "./config.js"; +import { + SUPPORT_ASYNC, + SUPPORT_WORKER +} from "./config.js"; // <-- COMPILER BLOCK import { IndexOptions } from "./type.js"; import { create_object } from "./common.js"; import handler from "./worker/handler.js"; import apply_async from "./async.js"; +import Encoder from "./encoder.js"; let pid = 0; /** * @param {IndexOptions=} options + * @param {Encoder=} encoder * @constructor */ -export default function WorkerIndex(options = /** @type IndexOptions */ ({})){ +export default function WorkerIndex(options = /** @type IndexOptions */ ({}), encoder){ if(!this || this.constructor !== WorkerIndex) { return new WorkerIndex(options); @@ -89,6 +94,11 @@ export default function WorkerIndex(options = /** @type IndexOptions */ ({})){ this.priority = options.priority || 4; } + // assign encoder for result highlighting + if(encoder){ + this.encoder = encoder; + } + return this; } diff --git a/test/issues.js b/test/issues.js index 5508e3c..4ae0cdb 100644 --- a/test/issues.js +++ b/test/issues.js @@ -106,12 +106,117 @@ describe("Github Issues", function(){ expect(usersResult).to.eql([1]); }); - it("#500", function(){ + if(!build_light && !build_compact) it("#499", function(){ + + const DocumentIndexConfig = { + document: { + id: "id", + store: true, + // fuzzy search fields + index: [ + { + field: "className", + tokenize: "forward", + }, + ], + // These get tagged as their specific key + tag: [ + { + field: "language", + }, + { + field: "feedbackScore", + custom: (data) => + Number(data.avgInstructorScore) >= 4 ? ">=4" : false, + }, + ], + }, + }; + + const index = new Document(DocumentIndexConfig); + + let all_docs = [{ + "id": "1234", + "className": "My Class Name", + "language": "German", + "avgInstructorScore": 4.69, + }]; + + for (const doc of all_docs) { + index.add(doc); + } + + const resolveOptions = { + enrich: true, + limit: index.store.size, + }; + + //console.log(index.search({ tag: { feedbackScore: ">=4", language: "German" }, resolve: true })) + //console.log(index.search({ tag: { feedbackScore: ">=4", language: "German" }, resolve: true, enrich: true })) + //console.log(index.search({ tag: { feedbackScore: ">=4", language: "German" }, resolve: false }).resolve({ enrich: true })) + + let results = index.search({ tag: { feedbackScore: ">=4", language: "German" }, resolve: false }) + .resolve(resolveOptions); + + expect(results).to.eql([{ + id: '1234', + doc: { + id: '1234', + className: 'My Class Name', + language: 'German', + avgInstructorScore: 4.69 + } + }]); + + results = index.search({ query: "class", field: "className", resolve: false }) + .and({ tag: { feedbackScore: ">=4", language: "German" } }) + .resolve(resolveOptions); + + expect(results).to.eql([{ + id: '1234', + doc: { + id: '1234', + className: 'My Class Name', + language: 'German', + avgInstructorScore: 4.69 + } + }]); + + results = index.search({ tag: { feedbackScore: ">=4" }, resolve: false }) + .and({ tag: { language: "German" } }) + .resolve(resolveOptions); + + expect(results).to.eql([{ + id: '1234', + doc: { + id: '1234', + className: 'My Class Name', + language: 'German', + avgInstructorScore: 4.69 + } + }]); + + results = index.search({ query: "class", field: "className", resolve: false }) + .and({ tag: { feedbackScore: ">=4", language: "German" }, resolve: true, enrich: true }); + + expect(results).to.eql([{ + id: '1234', + doc: { + id: '1234', + className: 'My Class Name', + language: 'German', + avgInstructorScore: 4.69 + } + }]); + }); + + if(!build_light && !build_compact) it("#500", function(){ const indexableFields = ['field1', 'field2']; const searchIndex = new Document({ document: { + store: true, id: '_id', index: indexableFields.map(f => ({field: f, tokenize: 'full', encoder: Charset.LatinExtra})), }, @@ -143,12 +248,76 @@ describe("Github Issues", function(){ return res; }; - // console.log('this works', submitSearch('123')); - // console.log('this throws an error', submitSearch('1234')); - // console.log('this throws an error', submitSearch('123 b')); + // console.log(submitSearch('123')); + // console.log(submitSearch('1234')); + // console.log(submitSearch('123 b')); expect(submitSearch('123')).to.eql(["123"]); expect(submitSearch('1234')).to.eql(["123"]); expect(submitSearch('123 b')).to.eql(["123"]); + + const submitSearch2 = query => { + + // Since there are subfields to account for, build up the query one field at a time + return searchIndex.search({ + query, + field: "field1", + resolve: false + }).or({ + query, + field: "field2", + resolve: true + }); + }; + + expect(submitSearch2('123')).to.eql(["123"]); + expect(submitSearch2('1234')).to.eql(["123"]); + expect(submitSearch2('123 b')).to.eql(["123"]); + + const submitSearch3 = query => { + + // Since there are subfields to account for, build up the query one field at a time + let res1 = searchIndex.search({ + query, + field: "field1", + resolve: false + }); + + let res2 = searchIndex.search({ + query, + field: "field2", + resolve: false + }); + + // Combine the queries with "or" and "resolve" them to get the results + return res1.or(res2).resolve({ enrich: true }); + }; + + expect(submitSearch3('123')).to.eql([{ + "id": "123", + "doc": { + "_id": "123", + "field1": "1234", + "field2": "123 b" + } + }]); + + expect(submitSearch3('1234')).to.eql([{ + "id": "123", + "doc": { + "_id": "123", + "field1": "1234", + "field2": "123 b" + } + }]); + + expect(submitSearch3('123 b')).to.eql([{ + "id": "123", + "doc": { + "_id": "123", + "field1": "1234", + "field2": "123 b" + } + }]); }); });