@peam-ai/next 0.1.2 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/route.js CHANGED
@@ -1,9 +1,2562 @@
1
1
  'use strict';
2
2
 
3
3
  var server = require('peam/server');
4
+ var fs = require('fs/promises');
5
+ var path = require('path');
6
+
7
+ function _interopNamespace(e) {
8
+ if (e && e.__esModule) return e;
9
+ var n = Object.create(null);
10
+ if (e) {
11
+ Object.keys(e).forEach(function (k) {
12
+ if (k !== 'default') {
13
+ var d = Object.getOwnPropertyDescriptor(e, k);
14
+ Object.defineProperty(n, k, d.get ? d : {
15
+ enumerable: true,
16
+ get: function () { return e[k]; }
17
+ });
18
+ }
19
+ });
20
+ }
21
+ n.default = e;
22
+ return Object.freeze(n);
23
+ }
24
+
25
+ var fs__namespace = /*#__PURE__*/_interopNamespace(fs);
26
+ var path__namespace = /*#__PURE__*/_interopNamespace(path);
27
+
28
+ var __create = Object.create;
29
+ var __defProp = Object.defineProperty;
30
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
31
+ var __getOwnPropNames = Object.getOwnPropertyNames;
32
+ var __getProtoOf = Object.getPrototypeOf;
33
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
34
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
35
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
36
+ }) : x)(function(x) {
37
+ if (typeof require !== "undefined") return require.apply(this, arguments);
38
+ throw Error('Dynamic require of "' + x + '" is not supported');
39
+ });
40
+ var __commonJS = (cb2, mod) => function __require2() {
41
+ return mod || (0, cb2[__getOwnPropNames(cb2)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
42
+ };
43
+ var __copyProps = (to, from, except, desc) => {
44
+ if (from && typeof from === "object" || typeof from === "function") {
45
+ for (let key of __getOwnPropNames(from))
46
+ if (!__hasOwnProp.call(to, key) && key !== except)
47
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
48
+ }
49
+ return to;
50
+ };
51
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
52
+ // If the importer is in node compatibility mode or this is not an ESM
53
+ // file that has been converted to a CommonJS file using a Babel-
54
+ // compatible transform (i.e. "__esModule" has not been set), then set
55
+ // "default" to the CommonJS "module.exports" for node compatibility.
56
+ __defProp(target, "default", { value: mod, enumerable: true }) ,
57
+ mod
58
+ ));
59
+
60
+ // ../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js
61
+ var require_picocolors = __commonJS({
62
+ "../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js"(exports$1, module2) {
63
+ var p = process || {};
64
+ var argv = p.argv || [];
65
+ var env = p.env || {};
66
+ var isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || (p.stdout || {}).isTTY && env.TERM !== "dumb" || !!env.CI);
67
+ var formatter = (open, close, replace = open) => (input) => {
68
+ let string = "" + input, index = string.indexOf(close, open.length);
69
+ return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
70
+ };
71
+ var replaceClose = (string, close, replace, index) => {
72
+ let result = "", cursor = 0;
73
+ do {
74
+ result += string.substring(cursor, index) + replace;
75
+ cursor = index + close.length;
76
+ index = string.indexOf(close, cursor);
77
+ } while (~index);
78
+ return result + string.substring(cursor);
79
+ };
80
+ var createColors = (enabled = isColorSupported) => {
81
+ let f = enabled ? formatter : () => String;
82
+ return {
83
+ isColorSupported: enabled,
84
+ reset: f("\x1B[0m", "\x1B[0m"),
85
+ bold: f("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
86
+ dim: f("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
87
+ italic: f("\x1B[3m", "\x1B[23m"),
88
+ underline: f("\x1B[4m", "\x1B[24m"),
89
+ inverse: f("\x1B[7m", "\x1B[27m"),
90
+ hidden: f("\x1B[8m", "\x1B[28m"),
91
+ strikethrough: f("\x1B[9m", "\x1B[29m"),
92
+ black: f("\x1B[30m", "\x1B[39m"),
93
+ red: f("\x1B[31m", "\x1B[39m"),
94
+ green: f("\x1B[32m", "\x1B[39m"),
95
+ yellow: f("\x1B[33m", "\x1B[39m"),
96
+ blue: f("\x1B[34m", "\x1B[39m"),
97
+ magenta: f("\x1B[35m", "\x1B[39m"),
98
+ cyan: f("\x1B[36m", "\x1B[39m"),
99
+ white: f("\x1B[37m", "\x1B[39m"),
100
+ gray: f("\x1B[90m", "\x1B[39m"),
101
+ bgBlack: f("\x1B[40m", "\x1B[49m"),
102
+ bgRed: f("\x1B[41m", "\x1B[49m"),
103
+ bgGreen: f("\x1B[42m", "\x1B[49m"),
104
+ bgYellow: f("\x1B[43m", "\x1B[49m"),
105
+ bgBlue: f("\x1B[44m", "\x1B[49m"),
106
+ bgMagenta: f("\x1B[45m", "\x1B[49m"),
107
+ bgCyan: f("\x1B[46m", "\x1B[49m"),
108
+ bgWhite: f("\x1B[47m", "\x1B[49m"),
109
+ blackBright: f("\x1B[90m", "\x1B[39m"),
110
+ redBright: f("\x1B[91m", "\x1B[39m"),
111
+ greenBright: f("\x1B[92m", "\x1B[39m"),
112
+ yellowBright: f("\x1B[93m", "\x1B[39m"),
113
+ blueBright: f("\x1B[94m", "\x1B[39m"),
114
+ magentaBright: f("\x1B[95m", "\x1B[39m"),
115
+ cyanBright: f("\x1B[96m", "\x1B[39m"),
116
+ whiteBright: f("\x1B[97m", "\x1B[39m"),
117
+ bgBlackBright: f("\x1B[100m", "\x1B[49m"),
118
+ bgRedBright: f("\x1B[101m", "\x1B[49m"),
119
+ bgGreenBright: f("\x1B[102m", "\x1B[49m"),
120
+ bgYellowBright: f("\x1B[103m", "\x1B[49m"),
121
+ bgBlueBright: f("\x1B[104m", "\x1B[49m"),
122
+ bgMagentaBright: f("\x1B[105m", "\x1B[49m"),
123
+ bgCyanBright: f("\x1B[106m", "\x1B[49m"),
124
+ bgWhiteBright: f("\x1B[107m", "\x1B[49m")
125
+ };
126
+ };
127
+ module2.exports = createColors();
128
+ module2.exports.createColors = createColors;
129
+ }
130
+ });
131
+
132
+ // ../logger/dist/index.mjs
133
+ var import_picocolors = __toESM(require_picocolors());
134
+ var PEAM_LOGGING_KEY = "PEAM_LOGGING";
135
+ function readBrowserLoggingSetting() {
136
+ var _a;
137
+ try {
138
+ const g = globalThis;
139
+ if (!g.localStorage) return void 0;
140
+ return (_a = g.localStorage.getItem(PEAM_LOGGING_KEY)) != null ? _a : void 0;
141
+ } catch (e) {
142
+ return void 0;
143
+ }
144
+ }
145
+ function readServerLoggingSetting() {
146
+ try {
147
+ return typeof process !== "undefined" && typeof process.env !== "undefined" && PEAM_LOGGING_KEY in process.env ? process.env[PEAM_LOGGING_KEY] : void 0;
148
+ } catch (e) {
149
+ return void 0;
150
+ }
151
+ }
152
+ function isLoggingEnabled() {
153
+ const serverSetting = readServerLoggingSetting();
154
+ if (serverSetting !== void 0) return Boolean(serverSetting);
155
+ const browserSetting = readBrowserLoggingSetting();
156
+ if (browserSetting !== void 0) return Boolean(browserSetting);
157
+ return false;
158
+ }
159
+ function createLogger(namespace) {
160
+ return {
161
+ error: (message, ...args) => print(message, args, { namespace, color: "red" }),
162
+ warn: (message, ...args) => print(message, args, { namespace, color: "yellow" }),
163
+ debug: (message, ...args) => print(message, args, { namespace, color: "yellow" })
164
+ };
165
+ }
166
+ function print(message, args, { namespace, color = "white" }) {
167
+ var _a;
168
+ if (!isLoggingEnabled()) return;
169
+ const colorize = (_a = import_picocolors.default[color]) != null ? _a : import_picocolors.default.white;
170
+ const header = `${colorize("[Peam]")} `;
171
+ const ns = namespace ? `${import_picocolors.default.dim(namespace)} ` : "";
172
+ console.log(header + ns + colorize(String(message)), ...args);
173
+ }
174
+ var loggers = {
175
+ search: createLogger("peam:search")
176
+ };
177
+
178
+ // ../../node_modules/.pnpm/flexsearch@0.8.212/node_modules/flexsearch/dist/flexsearch.bundle.module.min.mjs
179
+ var import_meta = {};
180
+ var w;
181
+ function H(a, c, b) {
182
+ const e = typeof b, d = typeof a;
183
+ if (e !== "undefined") {
184
+ if (d !== "undefined") {
185
+ if (b) {
186
+ if (d === "function" && e === d) return function(k) {
187
+ return a(b(k));
188
+ };
189
+ c = a.constructor;
190
+ if (c === b.constructor) {
191
+ if (c === Array) return b.concat(a);
192
+ if (c === Map) {
193
+ var f = new Map(b);
194
+ for (var g of a) f.set(g[0], g[1]);
195
+ return f;
196
+ }
197
+ if (c === Set) {
198
+ g = new Set(b);
199
+ for (f of a.values()) g.add(f);
200
+ return g;
201
+ }
202
+ }
203
+ }
204
+ return a;
205
+ }
206
+ return b;
207
+ }
208
+ return d === "undefined" ? c : a;
209
+ }
210
+ function aa(a, c) {
211
+ return typeof a === "undefined" ? c : a;
212
+ }
213
+ function I() {
214
+ return /* @__PURE__ */ Object.create(null);
215
+ }
216
+ function M(a) {
217
+ return typeof a === "string";
218
+ }
219
+ function ba(a) {
220
+ return typeof a === "object";
221
+ }
222
+ function ca(a, c) {
223
+ if (M(c)) a = a[c];
224
+ else for (let b = 0; a && b < c.length; b++) a = a[c[b]];
225
+ return a;
226
+ }
227
+ var ea = /[^\p{L}\p{N}]+/u;
228
+ var fa = /(\d{3})/g;
229
+ var ha = /(\D)(\d{3})/g;
230
+ var ia = /(\d{3})(\D)/g;
231
+ var ja = /[\u0300-\u036f]/g;
232
+ function ka(a = {}) {
233
+ if (!this || this.constructor !== ka) return new ka(...arguments);
234
+ if (arguments.length) for (a = 0; a < arguments.length; a++) this.assign(arguments[a]);
235
+ else this.assign(a);
236
+ }
237
+ w = ka.prototype;
238
+ w.assign = function(a) {
239
+ this.normalize = H(a.normalize, true, this.normalize);
240
+ let c = a.include, b = c || a.exclude || a.split, e;
241
+ if (b || b === "") {
242
+ if (typeof b === "object" && b.constructor !== RegExp) {
243
+ let d = "";
244
+ e = !c;
245
+ c || (d += "\\p{Z}");
246
+ b.letter && (d += "\\p{L}");
247
+ b.number && (d += "\\p{N}", e = !!c);
248
+ b.symbol && (d += "\\p{S}");
249
+ b.punctuation && (d += "\\p{P}");
250
+ b.control && (d += "\\p{C}");
251
+ if (b = b.char) d += typeof b === "object" ? b.join("") : b;
252
+ try {
253
+ this.split = new RegExp("[" + (c ? "^" : "") + d + "]+", "u");
254
+ } catch (f) {
255
+ this.split = /\s+/;
256
+ }
257
+ } else this.split = b, e = b === false || "a1a".split(b).length < 2;
258
+ this.numeric = H(a.numeric, e);
259
+ } else {
260
+ try {
261
+ this.split = H(this.split, ea);
262
+ } catch (d) {
263
+ this.split = /\s+/;
264
+ }
265
+ this.numeric = H(a.numeric, H(this.numeric, true));
266
+ }
267
+ this.prepare = H(a.prepare, null, this.prepare);
268
+ this.finalize = H(a.finalize, null, this.finalize);
269
+ b = a.filter;
270
+ this.filter = typeof b === "function" ? b : H(b && new Set(b), null, this.filter);
271
+ this.dedupe = H(a.dedupe, true, this.dedupe);
272
+ this.matcher = H((b = a.matcher) && new Map(b), null, this.matcher);
273
+ this.mapper = H((b = a.mapper) && new Map(b), null, this.mapper);
274
+ this.stemmer = H(
275
+ (b = a.stemmer) && new Map(b),
276
+ null,
277
+ this.stemmer
278
+ );
279
+ this.replacer = H(a.replacer, null, this.replacer);
280
+ this.minlength = H(a.minlength, 1, this.minlength);
281
+ this.maxlength = H(a.maxlength, 1024, this.maxlength);
282
+ this.rtl = H(a.rtl, false, this.rtl);
283
+ if (this.cache = b = H(a.cache, true, this.cache)) this.F = null, this.L = typeof b === "number" ? b : 2e5, this.B = /* @__PURE__ */ new Map(), this.D = /* @__PURE__ */ new Map(), this.I = this.H = 128;
284
+ this.h = "";
285
+ this.J = null;
286
+ this.A = "";
287
+ this.K = null;
288
+ if (this.matcher) for (const d of this.matcher.keys()) this.h += (this.h ? "|" : "") + d;
289
+ if (this.stemmer) for (const d of this.stemmer.keys()) this.A += (this.A ? "|" : "") + d;
290
+ return this;
291
+ };
292
+ w.addStemmer = function(a, c) {
293
+ this.stemmer || (this.stemmer = /* @__PURE__ */ new Map());
294
+ this.stemmer.set(a, c);
295
+ this.A += (this.A ? "|" : "") + a;
296
+ this.K = null;
297
+ this.cache && Q(this);
298
+ return this;
299
+ };
300
+ w.addFilter = function(a) {
301
+ typeof a === "function" ? this.filter = a : (this.filter || (this.filter = /* @__PURE__ */ new Set()), this.filter.add(a));
302
+ this.cache && Q(this);
303
+ return this;
304
+ };
305
+ w.addMapper = function(a, c) {
306
+ if (typeof a === "object") return this.addReplacer(a, c);
307
+ if (a.length > 1) return this.addMatcher(a, c);
308
+ this.mapper || (this.mapper = /* @__PURE__ */ new Map());
309
+ this.mapper.set(a, c);
310
+ this.cache && Q(this);
311
+ return this;
312
+ };
313
+ w.addMatcher = function(a, c) {
314
+ if (typeof a === "object") return this.addReplacer(a, c);
315
+ if (a.length < 2 && (this.dedupe || this.mapper)) return this.addMapper(a, c);
316
+ this.matcher || (this.matcher = /* @__PURE__ */ new Map());
317
+ this.matcher.set(a, c);
318
+ this.h += (this.h ? "|" : "") + a;
319
+ this.J = null;
320
+ this.cache && Q(this);
321
+ return this;
322
+ };
323
+ w.addReplacer = function(a, c) {
324
+ if (typeof a === "string") return this.addMatcher(a, c);
325
+ this.replacer || (this.replacer = []);
326
+ this.replacer.push(a, c);
327
+ this.cache && Q(this);
328
+ return this;
329
+ };
330
+ w.encode = function(a, c) {
331
+ if (this.cache && a.length <= this.H) if (this.F) {
332
+ if (this.B.has(a)) return this.B.get(a);
333
+ } else this.F = setTimeout(Q, 50, this);
334
+ this.normalize && (typeof this.normalize === "function" ? a = this.normalize(a) : a = ja ? a.normalize("NFKD").replace(ja, "").toLowerCase() : a.toLowerCase());
335
+ this.prepare && (a = this.prepare(a));
336
+ this.numeric && a.length > 3 && (a = a.replace(ha, "$1 $2").replace(ia, "$1 $2").replace(fa, "$1 "));
337
+ const b = !(this.dedupe || this.mapper || this.filter || this.matcher || this.stemmer || this.replacer);
338
+ let e = [], d = I(), f, g, k = this.split || this.split === "" ? a.split(this.split) : [a];
339
+ for (let l = 0, m, p; l < k.length; l++) if ((m = p = k[l]) && !(m.length < this.minlength || m.length > this.maxlength)) {
340
+ if (c) {
341
+ if (d[m]) continue;
342
+ d[m] = 1;
343
+ } else {
344
+ if (f === m) continue;
345
+ f = m;
346
+ }
347
+ if (b) e.push(m);
348
+ else if (!this.filter || (typeof this.filter === "function" ? this.filter(m) : !this.filter.has(m))) {
349
+ if (this.cache && m.length <= this.I) if (this.F) {
350
+ var h = this.D.get(m);
351
+ if (h || h === "") {
352
+ h && e.push(h);
353
+ continue;
354
+ }
355
+ } else this.F = setTimeout(Q, 50, this);
356
+ if (this.stemmer) {
357
+ this.K || (this.K = new RegExp("(?!^)(" + this.A + ")$"));
358
+ let u;
359
+ for (; u !== m && m.length > 2; ) u = m, m = m.replace(this.K, (r) => this.stemmer.get(r));
360
+ }
361
+ if (m && (this.mapper || this.dedupe && m.length > 1)) {
362
+ h = "";
363
+ for (let u = 0, r = "", t, n; u < m.length; u++) t = m.charAt(u), t === r && this.dedupe || ((n = this.mapper && this.mapper.get(t)) || n === "" ? n === r && this.dedupe || !(r = n) || (h += n) : h += r = t);
364
+ m = h;
365
+ }
366
+ this.matcher && m.length > 1 && (this.J || (this.J = new RegExp("(" + this.h + ")", "g")), m = m.replace(this.J, (u) => this.matcher.get(u)));
367
+ if (m && this.replacer) for (h = 0; m && h < this.replacer.length; h += 2) m = m.replace(
368
+ this.replacer[h],
369
+ this.replacer[h + 1]
370
+ );
371
+ this.cache && p.length <= this.I && (this.D.set(p, m), this.D.size > this.L && (this.D.clear(), this.I = this.I / 1.1 | 0));
372
+ if (m) {
373
+ if (m !== p) if (c) {
374
+ if (d[m]) continue;
375
+ d[m] = 1;
376
+ } else {
377
+ if (g === m) continue;
378
+ g = m;
379
+ }
380
+ e.push(m);
381
+ }
382
+ }
383
+ }
384
+ this.finalize && (e = this.finalize(e) || e);
385
+ this.cache && a.length <= this.H && (this.B.set(a, e), this.B.size > this.L && (this.B.clear(), this.H = this.H / 1.1 | 0));
386
+ return e;
387
+ };
388
+ function Q(a) {
389
+ a.F = null;
390
+ a.B.clear();
391
+ a.D.clear();
392
+ }
393
+ function la(a, c, b) {
394
+ b || (c || typeof a !== "object" ? typeof c === "object" && (b = c, c = 0) : b = a);
395
+ b && (a = b.query || a, c = b.limit || c);
396
+ let e = "" + (c || 0);
397
+ b && (e += (b.offset || 0) + !!b.context + !!b.suggest + (b.resolve !== false) + (b.resolution || this.resolution) + (b.boost || 0));
398
+ a = ("" + a).toLowerCase();
399
+ this.cache || (this.cache = new ma());
400
+ let d = this.cache.get(a + e);
401
+ if (!d) {
402
+ const f = b && b.cache;
403
+ f && (b.cache = false);
404
+ d = this.search(a, c, b);
405
+ f && (b.cache = f);
406
+ this.cache.set(a + e, d);
407
+ }
408
+ return d;
409
+ }
410
+ function ma(a) {
411
+ this.limit = a && a !== true ? a : 1e3;
412
+ this.cache = /* @__PURE__ */ new Map();
413
+ this.h = "";
414
+ }
415
+ ma.prototype.set = function(a, c) {
416
+ this.cache.set(this.h = a, c);
417
+ this.cache.size > this.limit && this.cache.delete(this.cache.keys().next().value);
418
+ };
419
+ ma.prototype.get = function(a) {
420
+ const c = this.cache.get(a);
421
+ c && this.h !== a && (this.cache.delete(a), this.cache.set(this.h = a, c));
422
+ return c;
423
+ };
424
+ ma.prototype.remove = function(a) {
425
+ for (const c of this.cache) {
426
+ const b = c[0];
427
+ c[1].includes(a) && this.cache.delete(b);
428
+ }
429
+ };
430
+ ma.prototype.clear = function() {
431
+ this.cache.clear();
432
+ this.h = "";
433
+ };
434
+ var na = { normalize: false, numeric: false, dedupe: false };
435
+ var oa = {};
436
+ var ra = /* @__PURE__ */ 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"]]);
437
+ var sa = /* @__PURE__ */ new Map([["ae", "a"], ["oe", "o"], ["sh", "s"], ["kh", "k"], ["th", "t"], ["ph", "f"], ["pf", "f"]]);
438
+ var ta = [/([^aeo])h(.)/g, "$1$2", /([aeo])h([^aeo]|$)/g, "$1$2", /(.)\1+/g, "$1"];
439
+ var ua = { 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, "\xDF": 2, d: 3, t: 3, l: 4, m: 5, n: 5, r: 6 };
440
+ var va = { Exact: na, Default: oa, Normalize: oa, LatinBalance: { mapper: ra }, LatinAdvanced: { mapper: ra, matcher: sa, replacer: ta }, LatinExtra: { mapper: ra, replacer: ta.concat([/(?!^)[aeo]/g, ""]), matcher: sa }, LatinSoundex: { dedupe: false, include: { letter: true }, finalize: function(a) {
441
+ for (let b = 0; b < a.length; b++) {
442
+ var c = a[b];
443
+ let e = c.charAt(0), d = ua[e];
444
+ for (let f = 1, g; f < c.length && (g = c.charAt(f), g === "h" || g === "w" || !(g = ua[g]) || g === d || (e += g, d = g, e.length !== 4)); f++) ;
445
+ a[b] = e;
446
+ }
447
+ } }, CJK: { split: "" }, LatinExact: na, LatinDefault: oa, LatinSimple: oa };
448
+ function wa(a, c, b, e) {
449
+ let d = [];
450
+ for (let f = 0, g; f < a.index.length; f++) if (g = a.index[f], c >= g.length) c -= g.length;
451
+ else {
452
+ c = g[e ? "splice" : "slice"](c, b);
453
+ const k = c.length;
454
+ if (k && (d = d.length ? d.concat(c) : c, b -= k, e && (a.length -= k), !b)) break;
455
+ c = 0;
456
+ }
457
+ return d;
458
+ }
459
+ function xa(a) {
460
+ if (!this || this.constructor !== xa) return new xa(a);
461
+ this.index = a ? [a] : [];
462
+ this.length = a ? a.length : 0;
463
+ const c = this;
464
+ return new Proxy([], { get(b, e) {
465
+ if (e === "length") return c.length;
466
+ if (e === "push") return function(d) {
467
+ c.index[c.index.length - 1].push(d);
468
+ c.length++;
469
+ };
470
+ if (e === "pop") return function() {
471
+ if (c.length) return c.length--, c.index[c.index.length - 1].pop();
472
+ };
473
+ if (e === "indexOf") return function(d) {
474
+ let f = 0;
475
+ for (let g = 0, k, h; g < c.index.length; g++) {
476
+ k = c.index[g];
477
+ h = k.indexOf(d);
478
+ if (h >= 0) return f + h;
479
+ f += k.length;
480
+ }
481
+ return -1;
482
+ };
483
+ if (e === "includes") return function(d) {
484
+ for (let f = 0; f < c.index.length; f++) if (c.index[f].includes(d)) return true;
485
+ return false;
486
+ };
487
+ if (e === "slice") return function(d, f) {
488
+ return wa(c, d || 0, f || c.length, false);
489
+ };
490
+ if (e === "splice") return function(d, f) {
491
+ return wa(c, d || 0, f || c.length, true);
492
+ };
493
+ if (e === "constructor") return Array;
494
+ if (typeof e !== "symbol") return (b = c.index[e / 2 ** 31 | 0]) && b[e];
495
+ }, set(b, e, d) {
496
+ b = e / 2 ** 31 | 0;
497
+ (c.index[b] || (c.index[b] = []))[e] = d;
498
+ c.length++;
499
+ return true;
500
+ } });
501
+ }
502
+ xa.prototype.clear = function() {
503
+ this.index.length = 0;
504
+ };
505
+ xa.prototype.push = function() {
506
+ };
507
+ function R(a = 8) {
508
+ if (!this || this.constructor !== R) return new R(a);
509
+ this.index = I();
510
+ this.h = [];
511
+ this.size = 0;
512
+ a > 32 ? (this.B = Aa, this.A = BigInt(a)) : (this.B = Ba, this.A = a);
513
+ }
514
+ R.prototype.get = function(a) {
515
+ const c = this.index[this.B(a)];
516
+ return c && c.get(a);
517
+ };
518
+ R.prototype.set = function(a, c) {
519
+ var b = this.B(a);
520
+ let e = this.index[b];
521
+ e ? (b = e.size, e.set(a, c), (b -= e.size) && this.size++) : (this.index[b] = e = /* @__PURE__ */ new Map([[a, c]]), this.h.push(e), this.size++);
522
+ };
523
+ function S(a = 8) {
524
+ if (!this || this.constructor !== S) return new S(a);
525
+ this.index = I();
526
+ this.h = [];
527
+ this.size = 0;
528
+ a > 32 ? (this.B = Aa, this.A = BigInt(a)) : (this.B = Ba, this.A = a);
529
+ }
530
+ S.prototype.add = function(a) {
531
+ var c = this.B(a);
532
+ let b = this.index[c];
533
+ b ? (c = b.size, b.add(a), (c -= b.size) && this.size++) : (this.index[c] = b = /* @__PURE__ */ new Set([a]), this.h.push(b), this.size++);
534
+ };
535
+ w = R.prototype;
536
+ w.has = S.prototype.has = function(a) {
537
+ const c = this.index[this.B(a)];
538
+ return c && c.has(a);
539
+ };
540
+ w.delete = S.prototype.delete = function(a) {
541
+ const c = this.index[this.B(a)];
542
+ c && c.delete(a) && this.size--;
543
+ };
544
+ w.clear = S.prototype.clear = function() {
545
+ this.index = I();
546
+ this.h = [];
547
+ this.size = 0;
548
+ };
549
+ w.values = S.prototype.values = function* () {
550
+ for (let a = 0; a < this.h.length; a++) for (let c of this.h[a].values()) yield c;
551
+ };
552
+ w.keys = S.prototype.keys = function* () {
553
+ for (let a = 0; a < this.h.length; a++) for (let c of this.h[a].keys()) yield c;
554
+ };
555
+ w.entries = S.prototype.entries = function* () {
556
+ for (let a = 0; a < this.h.length; a++) for (let c of this.h[a].entries()) yield c;
557
+ };
558
+ function Ba(a) {
559
+ let c = 2 ** this.A - 1;
560
+ if (typeof a == "number") return a & c;
561
+ let b = 0, e = this.A + 1;
562
+ for (let d = 0; d < a.length; d++) b = (b * e ^ a.charCodeAt(d)) & c;
563
+ return this.A === 32 ? b + 2 ** 31 : b;
564
+ }
565
+ function Aa(a) {
566
+ let c = BigInt(2) ** this.A - BigInt(1);
567
+ var b = typeof a;
568
+ if (b === "bigint") return a & c;
569
+ if (b === "number") return BigInt(a) & c;
570
+ b = BigInt(0);
571
+ let e = this.A + BigInt(1);
572
+ for (let d = 0; d < a.length; d++) b = (b * e ^ BigInt(a.charCodeAt(d))) & c;
573
+ return b;
574
+ }
575
+ var Ca;
576
+ var Da;
577
+ async function Ea(a) {
578
+ a = a.data;
579
+ var c = a.task;
580
+ const b = a.id;
581
+ let e = a.args;
582
+ switch (c) {
583
+ case "init":
584
+ Da = a.options || {};
585
+ (c = a.factory) ? (Function("return " + c)()(self), Ca = new self.FlexSearch.Index(Da), delete self.FlexSearch) : Ca = new T(Da);
586
+ postMessage({ id: b });
587
+ break;
588
+ default:
589
+ let d;
590
+ c === "export" && (e[1] ? (e[0] = Da.export, e[2] = 0, e[3] = 1) : e = null);
591
+ c === "import" ? e[0] && (a = await Da.import.call(Ca, e[0]), Ca.import(e[0], a)) : ((d = e && Ca[c].apply(Ca, e)) && d.then && (d = await d), d && d.await && (d = await d.await), c === "search" && d.result && (d = d.result));
592
+ postMessage(c === "search" ? { id: b, msg: d } : { id: b });
593
+ }
594
+ }
595
+ function Fa(a) {
596
+ Ga.call(a, "add");
597
+ Ga.call(a, "append");
598
+ Ga.call(a, "search");
599
+ Ga.call(a, "update");
600
+ Ga.call(a, "remove");
601
+ Ga.call(a, "searchCache");
602
+ }
603
+ var Ha;
604
+ var Ia;
605
+ var Ja;
606
+ function Ka() {
607
+ Ha = Ja = 0;
608
+ }
609
+ function Ga(a) {
610
+ this[a + "Async"] = function() {
611
+ const c = arguments;
612
+ var b = c[c.length - 1];
613
+ let e;
614
+ typeof b === "function" && (e = b, delete c[c.length - 1]);
615
+ Ha ? Ja || (Ja = Date.now() - Ia >= this.priority * this.priority * 3) : (Ha = setTimeout(Ka, 0), Ia = Date.now());
616
+ if (Ja) {
617
+ const f = this;
618
+ return new Promise((g) => {
619
+ setTimeout(function() {
620
+ g(f[a + "Async"].apply(f, c));
621
+ }, 0);
622
+ });
623
+ }
624
+ const d = this[a].apply(this, c);
625
+ b = d.then ? d : new Promise((f) => f(d));
626
+ e && b.then(e);
627
+ return b;
628
+ };
629
+ }
630
+ var V = 0;
631
+ function La(a = {}, c) {
632
+ function b(k) {
633
+ function h(l) {
634
+ l = l.data || l;
635
+ const m = l.id, p = m && f.h[m];
636
+ p && (p(l.msg), delete f.h[m]);
637
+ }
638
+ this.worker = k;
639
+ this.h = I();
640
+ if (this.worker) {
641
+ d ? this.worker.on("message", h) : this.worker.onmessage = h;
642
+ if (a.config) return new Promise(function(l) {
643
+ V > 1e9 && (V = 0);
644
+ f.h[++V] = function() {
645
+ l(f);
646
+ };
647
+ f.worker.postMessage({ id: V, task: "init", factory: e, options: a });
648
+ });
649
+ this.priority = a.priority || 4;
650
+ this.encoder = c || null;
651
+ this.worker.postMessage({ task: "init", factory: e, options: a });
652
+ return this;
653
+ }
654
+ }
655
+ if (!this || this.constructor !== La) return new La(a);
656
+ let e = typeof self !== "undefined" ? self._factory : typeof window !== "undefined" ? window._factory : null;
657
+ e && (e = e.toString());
658
+ const d = typeof window === "undefined", f = this, g = Ma(e, d, a.worker);
659
+ return g.then ? g.then(function(k) {
660
+ return b.call(f, k);
661
+ }) : b.call(this, g);
662
+ }
663
+ W("add");
664
+ W("append");
665
+ W("search");
666
+ W("update");
667
+ W("remove");
668
+ W("clear");
669
+ W("export");
670
+ W("import");
671
+ La.prototype.searchCache = la;
672
+ Fa(La.prototype);
673
+ function W(a) {
674
+ La.prototype[a] = function() {
675
+ const c = this, b = [].slice.call(arguments);
676
+ var e = b[b.length - 1];
677
+ let d;
678
+ typeof e === "function" && (d = e, b.pop());
679
+ e = new Promise(function(f) {
680
+ a === "export" && typeof b[0] === "function" && (b[0] = null);
681
+ V > 1e9 && (V = 0);
682
+ c.h[++V] = f;
683
+ c.worker.postMessage({ task: a, id: V, args: b });
684
+ });
685
+ return d ? (e.then(d), this) : e;
686
+ };
687
+ }
688
+ function Ma(a, c, b) {
689
+ return c ? typeof module !== "undefined" ? new (__require("worker_threads"))["Worker"](__dirname + "/worker/node.js") : import('worker_threads').then(function(worker) {
690
+ return new worker["Worker"](import_meta.dirname + "/node/node.mjs");
691
+ }) : a ? new window.Worker(URL.createObjectURL(new Blob(["onmessage=" + Ea.toString()], { type: "text/javascript" }))) : new window.Worker(typeof b === "string" ? b : import_meta.url.replace("/worker.js", "/worker/worker.js").replace(
692
+ "flexsearch.bundle.module.min.js",
693
+ "module/worker/worker.js"
694
+ ).replace("flexsearch.bundle.module.min.mjs", "module/worker/worker.js"), { type: "module" });
695
+ }
696
+ Na.prototype.add = function(a, c, b) {
697
+ ba(a) && (c = a, a = ca(c, this.key));
698
+ if (c && (a || a === 0)) {
699
+ if (!b && this.reg.has(a)) return this.update(a, c);
700
+ for (let k = 0, h; k < this.field.length; k++) {
701
+ h = this.B[k];
702
+ var e = this.index.get(this.field[k]);
703
+ if (typeof h === "function") {
704
+ var d = h(c);
705
+ d && e.add(a, d, b, true);
706
+ } else if (d = h.G, !d || d(c)) h.constructor === String ? h = ["" + h] : M(h) && (h = [h]), Qa(c, h, this.D, 0, e, a, h[0], b);
707
+ }
708
+ if (this.tag) for (e = 0; e < this.A.length; e++) {
709
+ var f = this.A[e];
710
+ d = this.tag.get(this.F[e]);
711
+ let k = I();
712
+ if (typeof f === "function") {
713
+ if (f = f(c), !f) continue;
714
+ } else {
715
+ var g = f.G;
716
+ if (g && !g(c)) continue;
717
+ f.constructor === String && (f = "" + f);
718
+ f = ca(c, f);
719
+ }
720
+ if (d && f) {
721
+ M(f) && (f = [f]);
722
+ 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))) {
723
+ if (m.length === 2 ** 31 - 1) {
724
+ g = new xa(m);
725
+ if (this.fastupdate) for (let p of this.reg.values()) p.includes(m) && (p[p.indexOf(m)] = g);
726
+ d.set(l, m = g);
727
+ }
728
+ m.push(a);
729
+ this.fastupdate && ((g = this.reg.get(a)) ? g.push(m) : this.reg.set(a, [m]));
730
+ }
731
+ }
732
+ }
733
+ if (this.store && (!b || !this.store.has(a))) {
734
+ let k;
735
+ if (this.h) {
736
+ k = I();
737
+ for (let h = 0, l; h < this.h.length; h++) {
738
+ l = this.h[h];
739
+ if ((b = l.G) && !b(c)) continue;
740
+ let m;
741
+ if (typeof l === "function") {
742
+ m = l(c);
743
+ if (!m) continue;
744
+ l = [l.O];
745
+ } else if (M(l) || l.constructor === String) {
746
+ k[l] = c[l];
747
+ continue;
748
+ }
749
+ Ra(c, k, l, 0, l[0], m);
750
+ }
751
+ }
752
+ this.store.set(a, k || c);
753
+ }
754
+ this.worker && (this.fastupdate || this.reg.add(a));
755
+ }
756
+ return this;
757
+ };
758
+ function Ra(a, c, b, e, d, f) {
759
+ a = a[d];
760
+ if (e === b.length - 1) c[d] = f || a;
761
+ 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);
762
+ else c = c[d] || (c[d] = I()), d = b[++e], Ra(a, c, b, e, d);
763
+ }
764
+ function Qa(a, c, b, e, d, f, g, k) {
765
+ if (a = a[g]) if (e === c.length - 1) {
766
+ if (a.constructor === Array) {
767
+ if (b[e]) {
768
+ for (c = 0; c < a.length; c++) d.add(f, a[c], true, true);
769
+ return;
770
+ }
771
+ a = a.join(" ");
772
+ }
773
+ d.add(f, a, k, true);
774
+ } else if (a.constructor === Array) for (g = 0; g < a.length; g++) Qa(a, c, b, e, d, f, g, k);
775
+ else g = c[++e], Qa(a, c, b, e, d, f, g, k);
776
+ }
777
+ function Sa(a, c, b, e) {
778
+ if (!a.length) return a;
779
+ if (a.length === 1) return a = a[0], a = b || a.length > c ? a.slice(b, b + c) : a, e ? Ta.call(this, a) : a;
780
+ let d = [];
781
+ for (let f = 0, g, k; f < a.length; f++) if ((g = a[f]) && (k = g.length)) {
782
+ if (b) {
783
+ if (b >= k) {
784
+ b -= k;
785
+ continue;
786
+ }
787
+ g = g.slice(b, b + c);
788
+ k = g.length;
789
+ b = 0;
790
+ }
791
+ k > c && (g = g.slice(0, c), k = c);
792
+ if (!d.length && k >= c) return e ? Ta.call(this, g) : g;
793
+ d.push(g);
794
+ c -= k;
795
+ if (!c) break;
796
+ }
797
+ d = d.length > 1 ? [].concat.apply([], d) : d[0];
798
+ return e ? Ta.call(this, d) : d;
799
+ }
800
+ function Ua(a, c, b, e) {
801
+ var d = e[0];
802
+ if (d[0] && d[0].query) return a[c].apply(a, d);
803
+ if (!(c !== "and" && c !== "not" || a.result.length || a.await || d.suggest)) return e.length > 1 && (d = e[e.length - 1]), (e = d.resolve) ? a.await || a.result : a;
804
+ let f = [], g = 0, k = 0, h, l, m, p, u;
805
+ for (c = 0; c < e.length; c++) if (d = e[c]) {
806
+ var r = void 0;
807
+ if (d.constructor === X) r = d.await || d.result;
808
+ else if (d.then || d.constructor === Array) r = d;
809
+ else {
810
+ g = d.limit || 0;
811
+ k = d.offset || 0;
812
+ m = d.suggest;
813
+ l = d.resolve;
814
+ h = ((p = d.highlight || a.highlight) || d.enrich) && l;
815
+ r = d.queue;
816
+ let t = d.async || r, n = d.index, q = d.query;
817
+ n ? a.index || (a.index = n) : n = a.index;
818
+ if (q || d.tag) {
819
+ const x = d.field || d.pluck;
820
+ x && (!q || a.query && !p || (a.query = q, a.field = x, a.highlight = p), n = n.index.get(x));
821
+ if (r && (u || a.await)) {
822
+ u = 1;
823
+ let v;
824
+ const A = a.C.length, D = new Promise(function(F) {
825
+ v = F;
826
+ });
827
+ (function(F, E) {
828
+ D.h = function() {
829
+ E.index = null;
830
+ E.resolve = false;
831
+ let B = t ? F.searchAsync(E) : F.search(E);
832
+ if (B.then) return B.then(function(z) {
833
+ a.C[A] = z = z.result || z;
834
+ v(z);
835
+ return z;
836
+ });
837
+ B = B.result || B;
838
+ v(B);
839
+ return B;
840
+ };
841
+ })(n, Object.assign({}, d));
842
+ a.C.push(D);
843
+ f[c] = D;
844
+ continue;
845
+ } else d.resolve = false, d.index = null, r = t ? n.searchAsync(d) : n.search(d), d.resolve = l, d.index = n;
846
+ } else if (d.and) r = Va(d, "and", n);
847
+ else if (d.or) r = Va(d, "or", n);
848
+ else if (d.not) r = Va(d, "not", n);
849
+ else if (d.xor) r = Va(d, "xor", n);
850
+ else continue;
851
+ }
852
+ r.await ? (u = 1, r = r.await) : r.then ? (u = 1, r = r.then(function(t) {
853
+ return t.result || t;
854
+ })) : r = r.result || r;
855
+ f[c] = r;
856
+ }
857
+ u && !a.await && (a.await = new Promise(function(t) {
858
+ a.return = t;
859
+ }));
860
+ if (u) {
861
+ const t = Promise.all(f).then(function(n) {
862
+ for (let q = 0; q < a.C.length; q++) if (a.C[q] === t) {
863
+ a.C[q] = function() {
864
+ return b.call(a, n, g, k, h, l, m, p);
865
+ };
866
+ break;
867
+ }
868
+ Wa(a);
869
+ });
870
+ a.C.push(t);
871
+ } else if (a.await) a.C.push(function() {
872
+ return b.call(a, f, g, k, h, l, m, p);
873
+ });
874
+ else return b.call(a, f, g, k, h, l, m, p);
875
+ return l ? a.await || a.result : a;
876
+ }
877
+ function Va(a, c, b) {
878
+ a = a[c];
879
+ const e = a[0] || a;
880
+ e.index || (e.index = b);
881
+ b = new X(e);
882
+ a.length > 1 && (b = b[c].apply(b, a.slice(1)));
883
+ return b;
884
+ }
885
+ X.prototype.or = function() {
886
+ return Ua(this, "or", Xa, arguments);
887
+ };
888
+ function Xa(a, c, b, e, d, f, g) {
889
+ a.length && (this.result.length && a.push(this.result), a.length < 2 ? this.result = a[0] : (this.result = Ya(a, c, b, false, this.h), b = 0));
890
+ d && (this.await = null);
891
+ return d ? this.resolve(c, b, e, g) : this;
892
+ }
893
+ X.prototype.and = function() {
894
+ return Ua(this, "and", Za, arguments);
895
+ };
896
+ function Za(a, c, b, e, d, f, g) {
897
+ if (!f && !this.result.length) return d ? this.result : this;
898
+ let k;
899
+ if (a.length) if (this.result.length && a.unshift(this.result), a.length < 2) this.result = a[0];
900
+ else {
901
+ let h = 0;
902
+ for (let l = 0, m, p; l < a.length; l++) if ((m = a[l]) && (p = m.length)) h < p && (h = p);
903
+ else if (!f) {
904
+ h = 0;
905
+ break;
906
+ }
907
+ h ? (this.result = $a(a, h, c, b, f, this.h, d), k = true) : this.result = [];
908
+ }
909
+ else f || (this.result = a);
910
+ d && (this.await = null);
911
+ return d ? this.resolve(c, b, e, g, k) : this;
912
+ }
913
+ X.prototype.xor = function() {
914
+ return Ua(this, "xor", ab, arguments);
915
+ };
916
+ function ab(a, c, b, e, d, f, g) {
917
+ if (a.length) if (this.result.length && a.unshift(this.result), a.length < 2) this.result = a[0];
918
+ else {
919
+ a: {
920
+ f = b;
921
+ var k = this.h;
922
+ const h = [], l = I();
923
+ let m = 0;
924
+ for (let p = 0, u; p < a.length; p++) if (u = a[p]) {
925
+ m < u.length && (m = u.length);
926
+ for (let r = 0, t; r < u.length; r++) if (t = u[r]) for (let n = 0, q; n < t.length; n++) q = t[n], l[q] = l[q] ? 2 : 1;
927
+ }
928
+ for (let p = 0, u, r = 0; p < m; p++) for (let t = 0, n; t < a.length; t++) if (n = a[t]) {
929
+ if (u = n[p]) {
930
+ for (let q = 0, x; q < u.length; q++) if (x = u[q], l[x] === 1) if (f) f--;
931
+ else if (d) {
932
+ if (h.push(x), h.length === c) {
933
+ a = h;
934
+ break a;
935
+ }
936
+ } else {
937
+ const v = p + (t ? k : 0);
938
+ h[v] || (h[v] = []);
939
+ h[v].push(x);
940
+ if (++r === c) {
941
+ a = h;
942
+ break a;
943
+ }
944
+ }
945
+ }
946
+ }
947
+ a = h;
948
+ }
949
+ this.result = a;
950
+ k = true;
951
+ }
952
+ else f || (this.result = a);
953
+ d && (this.await = null);
954
+ return d ? this.resolve(c, b, e, g, k) : this;
955
+ }
956
+ X.prototype.not = function() {
957
+ return Ua(this, "not", bb, arguments);
958
+ };
959
+ function bb(a, c, b, e, d, f, g) {
960
+ if (!f && !this.result.length) return d ? this.result : this;
961
+ if (a.length && this.result.length) {
962
+ a: {
963
+ f = b;
964
+ var k = [];
965
+ a = new Set(a.flat().flat());
966
+ for (let h = 0, l, m = 0; h < this.result.length; h++) if (l = this.result[h]) {
967
+ for (let p = 0, u; p < l.length; p++) if (u = l[p], !a.has(u)) {
968
+ if (f) f--;
969
+ else if (d) {
970
+ if (k.push(u), k.length === c) {
971
+ a = k;
972
+ break a;
973
+ }
974
+ } else if (k[h] || (k[h] = []), k[h].push(u), ++m === c) {
975
+ a = k;
976
+ break a;
977
+ }
978
+ }
979
+ }
980
+ a = k;
981
+ }
982
+ this.result = a;
983
+ k = true;
984
+ }
985
+ d && (this.await = null);
986
+ return d ? this.resolve(c, b, e, g, k) : this;
987
+ }
988
+ function cb(a, c, b, e, d) {
989
+ let f, g, k;
990
+ typeof d === "string" ? (f = d, d = "") : f = d.template;
991
+ g = f.indexOf("$1");
992
+ k = f.substring(g + 2);
993
+ g = f.substring(0, g);
994
+ let h = d && d.boundary, l = !d || d.clip !== false, m = d && d.merge && k && g && new RegExp(k + " " + g, "g");
995
+ d = d && d.ellipsis;
996
+ var p = 0;
997
+ if (typeof d === "object") {
998
+ var u = d.template;
999
+ p = u.length - 2;
1000
+ d = d.pattern;
1001
+ }
1002
+ typeof d !== "string" && (d = d === false ? "" : "...");
1003
+ p && (d = u.replace("$1", d));
1004
+ u = d.length - p;
1005
+ let r, t;
1006
+ typeof h === "object" && (r = h.before, r === 0 && (r = -1), t = h.after, t === 0 && (t = -1), h = h.total || 9e5);
1007
+ p = /* @__PURE__ */ new Map();
1008
+ for (let Oa = 0, da, db, pa; Oa < c.length; Oa++) {
1009
+ let qa;
1010
+ if (e) qa = c, pa = e;
1011
+ else {
1012
+ var n = c[Oa];
1013
+ pa = n.field;
1014
+ if (!pa) continue;
1015
+ qa = n.result;
1016
+ }
1017
+ db = b.get(pa);
1018
+ da = db.encoder;
1019
+ n = p.get(da);
1020
+ typeof n !== "string" && (n = da.encode(a), p.set(da, n));
1021
+ for (let ya = 0; ya < qa.length; ya++) {
1022
+ var q = qa[ya].doc;
1023
+ if (!q) continue;
1024
+ q = ca(q, pa);
1025
+ if (!q) continue;
1026
+ var x = q.trim().split(/\s+/);
1027
+ if (!x.length) continue;
1028
+ q = "";
1029
+ var v = [];
1030
+ let za = [];
1031
+ var A = -1, D = -1, F = 0;
1032
+ for (var E = 0; E < x.length; E++) {
1033
+ var B = x[E], z = da.encode(B);
1034
+ z = z.length > 1 ? z.join(" ") : z[0];
1035
+ let y;
1036
+ if (z && B) {
1037
+ var C = B.length, J = (da.split ? B.replace(da.split, "") : B).length - z.length, G = "", N = 0;
1038
+ for (var O = 0; O < n.length; O++) {
1039
+ var P = n[O];
1040
+ if (P) {
1041
+ var L = P.length;
1042
+ L += J < 0 ? 0 : J;
1043
+ N && L <= N || (P = z.indexOf(P), P > -1 && (G = (P ? B.substring(0, P) : "") + g + B.substring(P, P + L) + k + (P + L < C ? B.substring(P + L) : ""), N = L, y = true));
1044
+ }
1045
+ }
1046
+ G && (h && (A < 0 && (A = q.length + (q ? 1 : 0)), D = q.length + (q ? 1 : 0) + G.length, F += C, za.push(v.length), v.push({ match: G })), q += (q ? " " : "") + G);
1047
+ }
1048
+ if (!y) B = x[E], q += (q ? " " : "") + B, h && v.push({ text: B });
1049
+ else if (h && F >= h) break;
1050
+ }
1051
+ F = za.length * (f.length - 2);
1052
+ if (r || t || h && q.length - F > h) if (F = h + F - u * 2, E = D - A, r > 0 && (E += r), t > 0 && (E += t), E <= F) x = r ? A - (r > 0 ? r : 0) : A - ((F - E) / 2 | 0), v = t ? D + (t > 0 ? t : 0) : x + F, l || (x > 0 && q.charAt(x) !== " " && q.charAt(x - 1) !== " " && (x = q.indexOf(" ", x), x < 0 && (x = 0)), v < q.length && q.charAt(v - 1) !== " " && q.charAt(v) !== " " && (v = q.lastIndexOf(" ", v), v < D ? v = D : ++v)), q = (x ? d : "") + q.substring(x, v) + (v < q.length ? d : "");
1053
+ else {
1054
+ D = [];
1055
+ A = {};
1056
+ F = {};
1057
+ E = {};
1058
+ B = {};
1059
+ z = {};
1060
+ G = J = C = 0;
1061
+ for (O = N = 1; ; ) {
1062
+ var U = void 0;
1063
+ for (let y = 0, K; y < za.length; y++) {
1064
+ K = za[y];
1065
+ if (G) if (J !== G) {
1066
+ if (E[y + 1]) continue;
1067
+ K += G;
1068
+ if (A[K]) {
1069
+ C -= u;
1070
+ F[y + 1] = 1;
1071
+ E[y + 1] = 1;
1072
+ continue;
1073
+ }
1074
+ if (K >= v.length - 1) {
1075
+ if (K >= v.length) {
1076
+ E[y + 1] = 1;
1077
+ K >= x.length && (F[y + 1] = 1);
1078
+ continue;
1079
+ }
1080
+ C -= u;
1081
+ }
1082
+ q = v[K].text;
1083
+ if (L = t && z[y]) if (L > 0) {
1084
+ if (q.length > L) if (E[y + 1] = 1, l) q = q.substring(0, L);
1085
+ else continue;
1086
+ (L -= q.length) || (L = -1);
1087
+ z[y] = L;
1088
+ } else {
1089
+ E[y + 1] = 1;
1090
+ continue;
1091
+ }
1092
+ if (C + q.length + 1 <= h) q = " " + q, D[y] += q;
1093
+ else if (l) U = h - C - 1, U > 0 && (q = " " + q.substring(0, U), D[y] += q), E[y + 1] = 1;
1094
+ else {
1095
+ E[y + 1] = 1;
1096
+ continue;
1097
+ }
1098
+ } else {
1099
+ if (E[y]) continue;
1100
+ K -= J;
1101
+ if (A[K]) {
1102
+ C -= u;
1103
+ E[y] = 1;
1104
+ F[y] = 1;
1105
+ continue;
1106
+ }
1107
+ if (K <= 0) {
1108
+ if (K < 0) {
1109
+ E[y] = 1;
1110
+ F[y] = 1;
1111
+ continue;
1112
+ }
1113
+ C -= u;
1114
+ }
1115
+ q = v[K].text;
1116
+ if (L = r && B[y]) if (L > 0) {
1117
+ if (q.length > L) if (E[y] = 1, l) q = q.substring(q.length - L);
1118
+ else continue;
1119
+ (L -= q.length) || (L = -1);
1120
+ B[y] = L;
1121
+ } else {
1122
+ E[y] = 1;
1123
+ continue;
1124
+ }
1125
+ if (C + q.length + 1 <= h) q += " ", D[y] = q + D[y];
1126
+ else if (l) U = q.length + 1 - (h - C), U >= 0 && U < q.length && (q = q.substring(U) + " ", D[y] = q + D[y]), E[y] = 1;
1127
+ else {
1128
+ E[y] = 1;
1129
+ continue;
1130
+ }
1131
+ }
1132
+ else {
1133
+ q = v[K].match;
1134
+ r && (B[y] = r);
1135
+ t && (z[y] = t);
1136
+ y && C++;
1137
+ let Pa;
1138
+ K ? !y && u && (C += u) : (F[y] = 1, E[y] = 1);
1139
+ K >= x.length - 1 ? Pa = 1 : K < v.length - 1 && v[K + 1].match ? Pa = 1 : u && (C += u);
1140
+ C -= f.length - 2;
1141
+ if (!y || C + q.length <= h) D[y] = q;
1142
+ else {
1143
+ U = N = O = F[y] = 0;
1144
+ break;
1145
+ }
1146
+ Pa && (F[y + 1] = 1, E[y + 1] = 1);
1147
+ }
1148
+ C += q.length;
1149
+ U = A[K] = 1;
1150
+ }
1151
+ if (U) J === G ? G++ : J++;
1152
+ else {
1153
+ J === G ? N = 0 : O = 0;
1154
+ if (!N && !O) break;
1155
+ N ? (J++, G = J) : G++;
1156
+ }
1157
+ }
1158
+ q = "";
1159
+ for (let y = 0, K; y < D.length; y++) K = (F[y] ? y ? " " : "" : (y && !d ? " " : "") + d) + D[y], q += K;
1160
+ d && !F[D.length] && (q += d);
1161
+ }
1162
+ m && (q = q.replace(m, " "));
1163
+ qa[ya].highlight = q;
1164
+ }
1165
+ if (e) break;
1166
+ }
1167
+ return c;
1168
+ }
1169
+ function X(a, c) {
1170
+ if (!this || this.constructor !== X) return new X(a, c);
1171
+ let b = 0, e, d, f, g, k, h;
1172
+ if (a && a.index) {
1173
+ const l = a;
1174
+ c = l.index;
1175
+ b = l.boost || 0;
1176
+ if (d = l.query) {
1177
+ f = l.field || l.pluck;
1178
+ g = l.highlight;
1179
+ const m = l.resolve;
1180
+ a = l.async || l.queue;
1181
+ l.resolve = false;
1182
+ l.index = null;
1183
+ a = a ? c.searchAsync(l) : c.search(l);
1184
+ l.resolve = m;
1185
+ l.index = c;
1186
+ a = a.result || a;
1187
+ } else a = [];
1188
+ }
1189
+ if (a && a.then) {
1190
+ const l = this;
1191
+ a = a.then(function(m) {
1192
+ l.C[0] = l.result = m.result || m;
1193
+ Wa(l);
1194
+ });
1195
+ e = [a];
1196
+ a = [];
1197
+ k = new Promise(function(m) {
1198
+ h = m;
1199
+ });
1200
+ }
1201
+ this.index = c || null;
1202
+ this.result = a || [];
1203
+ this.h = b;
1204
+ this.C = e || [];
1205
+ this.await = k || null;
1206
+ this.return = h || null;
1207
+ this.highlight = g || null;
1208
+ this.query = d || "";
1209
+ this.field = f || "";
1210
+ }
1211
+ w = X.prototype;
1212
+ w.limit = function(a) {
1213
+ if (this.await) {
1214
+ const c = this;
1215
+ this.C.push(function() {
1216
+ return c.limit(a).result;
1217
+ });
1218
+ } else if (this.result.length) {
1219
+ const c = [];
1220
+ for (let b = 0, e; b < this.result.length; b++) if (e = this.result[b]) if (e.length <= a) {
1221
+ if (c[b] = e, a -= e.length, !a) break;
1222
+ } else {
1223
+ c[b] = e.slice(0, a);
1224
+ break;
1225
+ }
1226
+ this.result = c;
1227
+ }
1228
+ return this;
1229
+ };
1230
+ w.offset = function(a) {
1231
+ if (this.await) {
1232
+ const c = this;
1233
+ this.C.push(function() {
1234
+ return c.offset(a).result;
1235
+ });
1236
+ } else if (this.result.length) {
1237
+ const c = [];
1238
+ 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);
1239
+ this.result = c;
1240
+ }
1241
+ return this;
1242
+ };
1243
+ w.boost = function(a) {
1244
+ if (this.await) {
1245
+ const c = this;
1246
+ this.C.push(function() {
1247
+ return c.boost(a).result;
1248
+ });
1249
+ } else this.h += a;
1250
+ return this;
1251
+ };
1252
+ function Wa(a, c) {
1253
+ let b = a.result;
1254
+ var e = a.await;
1255
+ a.await = null;
1256
+ for (let d = 0, f; d < a.C.length; d++) if (f = a.C[d]) {
1257
+ if (typeof f === "function") b = f(), a.C[d] = b = b.result || b, d--;
1258
+ else if (f.h) b = f.h(), a.C[d] = b = b.result || b, d--;
1259
+ else if (f.then) return a.await = e;
1260
+ }
1261
+ e = a.return;
1262
+ a.C = [];
1263
+ a.return = null;
1264
+ c || e(b);
1265
+ return b;
1266
+ }
1267
+ w.resolve = function(a, c, b, e, d) {
1268
+ let f = this.await ? Wa(this, true) : this.result;
1269
+ if (f.then) {
1270
+ const g = this;
1271
+ return f.then(function() {
1272
+ return g.resolve(a, c, b, e, d);
1273
+ });
1274
+ }
1275
+ f.length && (typeof a === "object" ? (e = a.highlight || this.highlight, b = !!e || a.enrich, c = a.offset, a = a.limit) : (e = e || this.highlight, b = !!e || b), f = d ? b ? Ta.call(this.index, f) : f : Sa.call(this.index, f, a || 100, c, b));
1276
+ return this.finalize(f, e);
1277
+ };
1278
+ w.finalize = function(a, c) {
1279
+ if (a.then) {
1280
+ const e = this;
1281
+ return a.then(function(d) {
1282
+ return e.finalize(d, c);
1283
+ });
1284
+ }
1285
+ c && a.length && this.query && (a = cb(this.query, a, this.index.index, this.field, c));
1286
+ const b = this.return;
1287
+ this.highlight = this.index = this.result = this.C = this.await = this.return = null;
1288
+ this.query = this.field = "";
1289
+ b && b(a);
1290
+ return a;
1291
+ };
1292
+ function $a(a, c, b, e, d, f, g) {
1293
+ const k = a.length;
1294
+ let h = [], l, m;
1295
+ l = I();
1296
+ for (let p = 0, u, r, t, n; p < c; p++) for (let q = 0; q < k; q++) if (t = a[q], p < t.length && (u = t[p])) for (let x = 0; x < u.length; x++) {
1297
+ r = u[x];
1298
+ (m = l[r]) ? l[r]++ : (m = 0, l[r] = 1);
1299
+ n = h[m] || (h[m] = []);
1300
+ if (!g) {
1301
+ let v = p + (q || !d ? 0 : f || 0);
1302
+ n = n[v] || (n[v] = []);
1303
+ }
1304
+ n.push(r);
1305
+ if (g && b && m === k - 1 && n.length - e === b) return e ? n.slice(e) : n;
1306
+ }
1307
+ if (a = h.length) if (d) h = h.length > 1 ? Ya(h, b, e, g, f) : (h = h[0]) && b && h.length > b || e ? h.slice(e, b + e) : h;
1308
+ else {
1309
+ if (a < k) return [];
1310
+ h = h[a - 1];
1311
+ if (b || e) if (g) {
1312
+ if (h.length > b || e) h = h.slice(e, b + e);
1313
+ } else {
1314
+ d = [];
1315
+ for (let p = 0, u; p < h.length; p++) if (u = h[p]) if (e && u.length > e) e -= u.length;
1316
+ else {
1317
+ if (b && u.length > b || e) u = u.slice(e, b + e), b -= u.length, e && (e -= u.length);
1318
+ d.push(u);
1319
+ if (!b) break;
1320
+ }
1321
+ h = d;
1322
+ }
1323
+ }
1324
+ return h;
1325
+ }
1326
+ function Ya(a, c, b, e, d) {
1327
+ const f = [], g = I();
1328
+ let k;
1329
+ var h = a.length;
1330
+ let l;
1331
+ if (e) for (d = h - 1; d >= 0; d--) {
1332
+ if (l = (e = a[d]) && e.length) {
1333
+ for (h = 0; h < l; h++) if (k = e[h], !g[k]) {
1334
+ if (g[k] = 1, b) b--;
1335
+ else if (f.push(k), f.length === c) return f;
1336
+ }
1337
+ }
1338
+ }
1339
+ else for (let m = h - 1, p, u = 0; m >= 0; m--) {
1340
+ p = a[m];
1341
+ for (let r = 0; r < p.length; r++) if (l = (e = p[r]) && e.length) {
1342
+ for (let t = 0; t < l; t++) if (k = e[t], !g[k]) if (g[k] = 1, b) b--;
1343
+ else {
1344
+ let n = (r + (m < h - 1 ? d || 0 : 0)) / (m + 1) | 0;
1345
+ (f[n] || (f[n] = [])).push(k);
1346
+ if (++u === c) return f;
1347
+ }
1348
+ }
1349
+ }
1350
+ return f;
1351
+ }
1352
+ function eb(a, c, b, e, d) {
1353
+ const f = I(), g = [];
1354
+ for (let k = 0, h; k < c.length; k++) {
1355
+ h = c[k];
1356
+ for (let l = 0; l < h.length; l++) f[h[l]] = 1;
1357
+ }
1358
+ if (d) for (let k = 0, h; k < a.length; k++) {
1359
+ if (h = a[k], f[h]) {
1360
+ if (e) e--;
1361
+ else if (g.push(h), f[h] = 0, b && --b === 0) break;
1362
+ }
1363
+ }
1364
+ else for (let k = 0, h, l; k < a.result.length; k++) for (h = a.result[k], c = 0; c < h.length; c++) l = h[c], f[l] && ((g[k] || (g[k] = [])).push(l), f[l] = 0);
1365
+ return g;
1366
+ }
1367
+ Na.prototype.search = function(a, c, b, e) {
1368
+ b || (!c && ba(a) ? (b = a, a = "") : ba(c) && (b = c, c = 0));
1369
+ let d = [];
1370
+ var f = [];
1371
+ let g;
1372
+ let k, h, l, m, p;
1373
+ let u = 0, r = true, t;
1374
+ if (b) {
1375
+ b.constructor === Array && (b = { index: b });
1376
+ a = b.query || a;
1377
+ g = b.pluck;
1378
+ k = b.merge;
1379
+ l = b.boost;
1380
+ p = g || b.field || (p = b.index) && (p.index ? null : p);
1381
+ var n = this.tag && b.tag;
1382
+ h = b.suggest;
1383
+ r = b.resolve !== false;
1384
+ m = b.cache;
1385
+ t = r && this.store && b.highlight;
1386
+ var q = !!t || r && this.store && b.enrich;
1387
+ c = b.limit || c;
1388
+ var x = b.offset || 0;
1389
+ c || (c = r ? 100 : 0);
1390
+ if (n && (!this.db || !e)) {
1391
+ n.constructor !== Array && (n = [n]);
1392
+ var v = [];
1393
+ for (let B = 0, z; B < n.length; B++) if (z = n[B], z.field && z.tag) {
1394
+ var A = z.tag;
1395
+ if (A.constructor === Array) for (var D = 0; D < A.length; D++) v.push(z.field, A[D]);
1396
+ else v.push(z.field, A);
1397
+ } else {
1398
+ A = Object.keys(z);
1399
+ for (let C = 0, J, G; C < A.length; C++) if (J = A[C], G = z[J], G.constructor === Array) for (D = 0; D < G.length; D++) v.push(J, G[D]);
1400
+ else v.push(J, G);
1401
+ }
1402
+ n = v;
1403
+ if (!a) {
1404
+ f = [];
1405
+ if (v.length) for (n = 0; n < v.length; n += 2) {
1406
+ if (this.db) {
1407
+ e = this.index.get(v[n]);
1408
+ if (!e) continue;
1409
+ f.push(e = e.db.tag(v[n + 1], c, x, q));
1410
+ } else e = fb.call(this, v[n], v[n + 1], c, x, q);
1411
+ d.push(r ? { field: v[n], tag: v[n + 1], result: e } : [e]);
1412
+ }
1413
+ if (f.length) {
1414
+ const B = this;
1415
+ return Promise.all(f).then(function(z) {
1416
+ for (let C = 0; C < z.length; C++) r ? d[C].result = z[C] : d[C] = z[C];
1417
+ return r ? d : new X(d.length > 1 ? $a(d, 1, 0, 0, h, l) : d[0], B);
1418
+ });
1419
+ }
1420
+ return r ? d : new X(d.length > 1 ? $a(d, 1, 0, 0, h, l) : d[0], this);
1421
+ }
1422
+ }
1423
+ r || g || !(p = p || this.field) || (M(p) ? g = p : (p.constructor === Array && p.length === 1 && (p = p[0]), g = p.field || p.index));
1424
+ p && p.constructor !== Array && (p = [p]);
1425
+ }
1426
+ p || (p = this.field);
1427
+ let F;
1428
+ v = (this.worker || this.db) && !e && [];
1429
+ for (let B = 0, z, C, J; B < p.length; B++) {
1430
+ C = p[B];
1431
+ if (this.db && this.tag && !this.B[B]) continue;
1432
+ let G;
1433
+ M(C) || (G = C, C = G.field, a = G.query || a, c = aa(G.limit, c), x = aa(G.offset, x), h = aa(G.suggest, h), t = r && this.store && aa(G.highlight, t), q = !!t || r && this.store && aa(G.enrich, q), m = aa(G.cache, m));
1434
+ if (e) z = e[B];
1435
+ else {
1436
+ A = G || b || {};
1437
+ D = A.enrich;
1438
+ var E = this.index.get(C);
1439
+ n && (this.db && (A.tag = n, A.field = p, F = E.db.support_tag_search), !F && D && (A.enrich = false), F || (A.limit = 0, A.offset = 0));
1440
+ z = m ? E.searchCache(a, n && !F ? 0 : c, A) : E.search(a, n && !F ? 0 : c, A);
1441
+ n && !F && (A.limit = c, A.offset = x);
1442
+ D && (A.enrich = D);
1443
+ if (v) {
1444
+ v[B] = z;
1445
+ continue;
1446
+ }
1447
+ }
1448
+ J = (z = z.result || z) && z.length;
1449
+ if (n && J) {
1450
+ A = [];
1451
+ D = 0;
1452
+ if (this.db && e) {
1453
+ if (!F) for (E = p.length; E < e.length; E++) {
1454
+ let N = e[E];
1455
+ if (N && N.length) D++, A.push(N);
1456
+ else if (!h) return r ? d : new X(d, this);
1457
+ }
1458
+ } else for (let N = 0, O, P; N < n.length; N += 2) {
1459
+ O = this.tag.get(n[N]);
1460
+ if (!O) if (h) continue;
1461
+ else return r ? d : new X(d, this);
1462
+ if (P = (O = O && O.get(n[N + 1])) && O.length) D++, A.push(O);
1463
+ else if (!h) return r ? d : new X(d, this);
1464
+ }
1465
+ if (D) {
1466
+ z = eb(z, A, c, x, r);
1467
+ J = z.length;
1468
+ if (!J && !h) return r ? z : new X(z, this);
1469
+ D--;
1470
+ }
1471
+ }
1472
+ if (J) f[u] = C, d.push(z), u++;
1473
+ else if (p.length === 1) return r ? d : new X(
1474
+ d,
1475
+ this
1476
+ );
1477
+ }
1478
+ if (v) {
1479
+ if (this.db && n && n.length && !F) for (q = 0; q < n.length; q += 2) {
1480
+ f = this.index.get(n[q]);
1481
+ if (!f) if (h) continue;
1482
+ else return r ? d : new X(d, this);
1483
+ v.push(f.db.tag(n[q + 1], c, x, false));
1484
+ }
1485
+ const B = this;
1486
+ return Promise.all(v).then(function(z) {
1487
+ b && (b.resolve = r);
1488
+ z.length && (z = B.search(a, c, b, z));
1489
+ return z;
1490
+ });
1491
+ }
1492
+ if (!u) return r ? d : new X(d, this);
1493
+ if (g && (!q || !this.store)) return d = d[0], r ? d : new X(d, this);
1494
+ v = [];
1495
+ for (x = 0; x < f.length; x++) {
1496
+ n = d[x];
1497
+ q && n.length && typeof n[0].doc === "undefined" && (this.db ? v.push(n = this.index.get(this.field[0]).db.enrich(n)) : n = Ta.call(this, n));
1498
+ if (g) return r ? t ? cb(a, n, this.index, g, t) : n : new X(n, this);
1499
+ d[x] = { field: f[x], result: n };
1500
+ }
1501
+ if (q && this.db && v.length) {
1502
+ const B = this;
1503
+ return Promise.all(v).then(function(z) {
1504
+ for (let C = 0; C < z.length; C++) d[C].result = z[C];
1505
+ t && (d = cb(a, d, B.index, g, t));
1506
+ return k ? gb(d) : d;
1507
+ });
1508
+ }
1509
+ t && (d = cb(a, d, this.index, g, t));
1510
+ return k ? gb(d) : d;
1511
+ };
1512
+ function gb(a) {
1513
+ const c = [], b = I(), e = I();
1514
+ for (let d = 0, f, g, k, h, l, m, p; d < a.length; d++) {
1515
+ f = a[d];
1516
+ g = f.field;
1517
+ k = f.result;
1518
+ for (let u = 0; u < k.length; u++) if (l = k[u], typeof l !== "object" ? l = { id: h = l } : h = l.id, (m = b[h]) ? m.push(g) : (l.field = b[h] = [g], c.push(l)), p = l.highlight) m = e[h], m || (e[h] = m = {}, l.highlight = m), m[g] = p;
1519
+ }
1520
+ return c;
1521
+ }
1522
+ function fb(a, c, b, e, d) {
1523
+ a = this.tag.get(a);
1524
+ if (!a) return [];
1525
+ a = a.get(c);
1526
+ if (!a) return [];
1527
+ c = a.length - e;
1528
+ if (c > 0) {
1529
+ if (b && c > b || e) a = a.slice(e, e + b);
1530
+ d && (a = Ta.call(this, a));
1531
+ }
1532
+ return a;
1533
+ }
1534
+ function Ta(a) {
1535
+ if (!this || !this.store) return a;
1536
+ if (this.db) return this.index.get(this.field[0]).db.enrich(a);
1537
+ const c = Array(a.length);
1538
+ for (let b = 0, e; b < a.length; b++) e = a[b], c[b] = { id: e, doc: this.store.get(e) };
1539
+ return c;
1540
+ }
1541
+ function Na(a) {
1542
+ if (!this || this.constructor !== Na) return new Na(a);
1543
+ const c = a.document || a.doc || a;
1544
+ let b, e;
1545
+ this.B = [];
1546
+ this.field = [];
1547
+ this.D = [];
1548
+ this.key = (b = c.key || c.id) && hb(b, this.D) || "id";
1549
+ (e = a.keystore || 0) && (this.keystore = e);
1550
+ this.fastupdate = !!a.fastupdate;
1551
+ this.reg = !this.fastupdate || a.worker || a.db ? e ? new S(e) : /* @__PURE__ */ new Set() : e ? new R(e) : /* @__PURE__ */ new Map();
1552
+ this.h = (b = c.store || null) && b && b !== true && [];
1553
+ this.store = b ? e ? new R(e) : /* @__PURE__ */ new Map() : null;
1554
+ this.cache = (b = a.cache || null) && new ma(b);
1555
+ a.cache = false;
1556
+ this.worker = a.worker || false;
1557
+ this.priority = a.priority || 4;
1558
+ this.index = ib.call(this, a, c);
1559
+ this.tag = null;
1560
+ if (b = c.tag) {
1561
+ if (typeof b === "string" && (b = [b]), b.length) {
1562
+ this.tag = /* @__PURE__ */ new Map();
1563
+ this.A = [];
1564
+ this.F = [];
1565
+ for (let d = 0, f, g; d < b.length; d++) {
1566
+ f = b[d];
1567
+ g = f.field || f;
1568
+ if (!g) throw Error("The tag field from the document descriptor is undefined.");
1569
+ f.custom ? this.A[d] = f.custom : (this.A[d] = hb(g, this.D), f.filter && (typeof this.A[d] === "string" && (this.A[d] = new String(this.A[d])), this.A[d].G = f.filter));
1570
+ this.F[d] = g;
1571
+ this.tag.set(g, /* @__PURE__ */ new Map());
1572
+ }
1573
+ }
1574
+ }
1575
+ if (this.worker) {
1576
+ this.fastupdate = false;
1577
+ a = [];
1578
+ for (const d of this.index.values()) d.then && a.push(d);
1579
+ if (a.length) {
1580
+ const d = this;
1581
+ return Promise.all(a).then(function(f) {
1582
+ let g = 0;
1583
+ for (const k of d.index.entries()) {
1584
+ const h = k[0];
1585
+ let l = k[1];
1586
+ l.then && (l = f[g], d.index.set(h, l), g++);
1587
+ }
1588
+ return d;
1589
+ });
1590
+ }
1591
+ } else a.db && (this.fastupdate = false, this.mount(a.db));
1592
+ }
1593
+ w = Na.prototype;
1594
+ w.mount = function(a) {
1595
+ let c = this.field;
1596
+ if (this.tag) for (let f = 0, g; f < this.F.length; f++) {
1597
+ g = this.F[f];
1598
+ var b = void 0;
1599
+ this.index.set(g, b = new T({}, this.reg));
1600
+ c === this.field && (c = c.slice(0));
1601
+ c.push(g);
1602
+ b.tag = this.tag.get(g);
1603
+ }
1604
+ b = [];
1605
+ const e = { db: a.db, type: a.type, fastupdate: a.fastupdate };
1606
+ for (let f = 0, g, k; f < c.length; f++) {
1607
+ e.field = k = c[f];
1608
+ g = this.index.get(k);
1609
+ const h = new a.constructor(a.id, e);
1610
+ h.id = a.id;
1611
+ b[f] = h.mount(g);
1612
+ g.document = true;
1613
+ f ? g.bypass = true : g.store = this.store;
1614
+ }
1615
+ const d = this;
1616
+ return this.db = Promise.all(b).then(function() {
1617
+ d.db = true;
1618
+ });
1619
+ };
1620
+ w.commit = async function() {
1621
+ const a = [];
1622
+ for (const c of this.index.values()) a.push(c.commit());
1623
+ await Promise.all(a);
1624
+ this.reg.clear();
1625
+ };
1626
+ w.destroy = function() {
1627
+ const a = [];
1628
+ for (const c of this.index.values()) a.push(c.destroy());
1629
+ return Promise.all(a);
1630
+ };
1631
+ function ib(a, c) {
1632
+ const b = /* @__PURE__ */ new Map();
1633
+ let e = c.index || c.field || c;
1634
+ M(e) && (e = [e]);
1635
+ for (let f = 0, g, k; f < e.length; f++) {
1636
+ g = e[f];
1637
+ M(g) || (k = g, g = g.field);
1638
+ k = ba(k) ? Object.assign({}, a, k) : a;
1639
+ if (this.worker) {
1640
+ var d = void 0;
1641
+ d = (d = k.encoder) && d.encode ? d : new ka(typeof d === "string" ? va[d] : d || {});
1642
+ d = new La(k, d);
1643
+ b.set(g, d);
1644
+ }
1645
+ this.worker || b.set(g, new T(k, this.reg));
1646
+ k.custom ? this.B[f] = k.custom : (this.B[f] = hb(g, this.D), k.filter && (typeof this.B[f] === "string" && (this.B[f] = new String(this.B[f])), this.B[f].G = k.filter));
1647
+ this.field[f] = g;
1648
+ }
1649
+ if (this.h) {
1650
+ a = c.store;
1651
+ M(a) && (a = [a]);
1652
+ for (let f = 0, g, k; f < a.length; f++) g = a[f], k = g.field || g, g.custom ? (this.h[f] = g.custom, g.custom.O = k) : (this.h[f] = hb(k, this.D), g.filter && (typeof this.h[f] === "string" && (this.h[f] = new String(this.h[f])), this.h[f].G = g.filter));
1653
+ }
1654
+ return b;
1655
+ }
1656
+ function hb(a, c) {
1657
+ const b = a.split(":");
1658
+ let e = 0;
1659
+ for (let d = 0; d < b.length; d++) a = b[d], a[a.length - 1] === "]" && (a = a.substring(0, a.length - 2)) && (c[e] = true), a && (b[e++] = a);
1660
+ e < b.length && (b.length = e);
1661
+ return e > 1 ? b : b[0];
1662
+ }
1663
+ w.append = function(a, c) {
1664
+ return this.add(a, c, true);
1665
+ };
1666
+ w.update = function(a, c) {
1667
+ return this.remove(a).add(a, c);
1668
+ };
1669
+ w.remove = function(a) {
1670
+ ba(a) && (a = ca(a, this.key));
1671
+ for (var c of this.index.values()) c.remove(a, true);
1672
+ if (this.reg.has(a)) {
1673
+ if (this.tag && !this.fastupdate) for (let b of this.tag.values()) for (let e of b) {
1674
+ c = e[0];
1675
+ const d = e[1], f = d.indexOf(a);
1676
+ f > -1 && (d.length > 1 ? d.splice(f, 1) : b.delete(c));
1677
+ }
1678
+ this.store && this.store.delete(a);
1679
+ this.reg.delete(a);
1680
+ }
1681
+ this.cache && this.cache.remove(a);
1682
+ return this;
1683
+ };
1684
+ w.clear = function() {
1685
+ const a = [];
1686
+ for (const c of this.index.values()) {
1687
+ const b = c.clear();
1688
+ b.then && a.push(b);
1689
+ }
1690
+ if (this.tag) for (const c of this.tag.values()) c.clear();
1691
+ this.store && this.store.clear();
1692
+ this.cache && this.cache.clear();
1693
+ return a.length ? Promise.all(a) : this;
1694
+ };
1695
+ w.contain = function(a) {
1696
+ return this.db ? this.index.get(this.field[0]).db.has(a) : this.reg.has(a);
1697
+ };
1698
+ w.cleanup = function() {
1699
+ for (const a of this.index.values()) a.cleanup();
1700
+ return this;
1701
+ };
1702
+ w.get = function(a) {
1703
+ return this.db ? this.index.get(this.field[0]).db.enrich(a).then(function(c) {
1704
+ return c[0] && c[0].doc || null;
1705
+ }) : this.store.get(a) || null;
1706
+ };
1707
+ w.set = function(a, c) {
1708
+ typeof a === "object" && (c = a, a = ca(c, this.key));
1709
+ this.store.set(a, c);
1710
+ return this;
1711
+ };
1712
+ w.searchCache = la;
1713
+ w.export = jb;
1714
+ w.import = kb;
1715
+ Fa(Na.prototype);
1716
+ function lb(a, c = 0) {
1717
+ let b = [], e = [];
1718
+ c && (c = 25e4 / c * 5e3 | 0);
1719
+ for (const d of a.entries()) e.push(d), e.length === c && (b.push(e), e = []);
1720
+ e.length && b.push(e);
1721
+ return b;
1722
+ }
1723
+ function mb(a, c) {
1724
+ c || (c = /* @__PURE__ */ new Map());
1725
+ for (let b = 0, e; b < a.length; b++) e = a[b], c.set(e[0], e[1]);
1726
+ return c;
1727
+ }
1728
+ function nb(a, c = 0) {
1729
+ let b = [], e = [];
1730
+ c && (c = 25e4 / c * 1e3 | 0);
1731
+ for (const d of a.entries()) e.push([d[0], lb(d[1])[0] || []]), e.length === c && (b.push(e), e = []);
1732
+ e.length && b.push(e);
1733
+ return b;
1734
+ }
1735
+ function ob(a, c) {
1736
+ c || (c = /* @__PURE__ */ new Map());
1737
+ for (let b = 0, e, d; b < a.length; b++) e = a[b], d = c.get(e[0]), c.set(e[0], mb(e[1], d));
1738
+ return c;
1739
+ }
1740
+ function pb(a) {
1741
+ let c = [], b = [];
1742
+ for (const e of a.keys()) b.push(e), b.length === 25e4 && (c.push(b), b = []);
1743
+ b.length && c.push(b);
1744
+ return c;
1745
+ }
1746
+ function qb(a, c) {
1747
+ c || (c = /* @__PURE__ */ new Set());
1748
+ for (let b = 0; b < a.length; b++) c.add(a[b]);
1749
+ return c;
1750
+ }
1751
+ function rb(a, c, b, e, d, f, g = 0) {
1752
+ const k = e && e.constructor === Array;
1753
+ var h = k ? e.shift() : e;
1754
+ if (!h) return this.export(a, c, d, f + 1);
1755
+ if ((h = a((c ? c + "." : "") + (g + 1) + "." + b, JSON.stringify(h))) && h.then) {
1756
+ const l = this;
1757
+ return h.then(function() {
1758
+ return rb.call(l, a, c, b, k ? e : null, d, f, g + 1);
1759
+ });
1760
+ }
1761
+ return rb.call(this, a, c, b, k ? e : null, d, f, g + 1);
1762
+ }
1763
+ function jb(a, c, b = 0, e = 0) {
1764
+ if (b < this.field.length) {
1765
+ const g = this.field[b];
1766
+ if ((c = this.index.get(g).export(a, g, b, e = 1)) && c.then) {
1767
+ const k = this;
1768
+ return c.then(function() {
1769
+ return k.export(a, g, b + 1);
1770
+ });
1771
+ }
1772
+ return this.export(a, g, b + 1);
1773
+ }
1774
+ let d, f;
1775
+ switch (e) {
1776
+ case 0:
1777
+ d = "reg";
1778
+ f = pb(this.reg);
1779
+ c = null;
1780
+ break;
1781
+ case 1:
1782
+ d = "tag";
1783
+ f = this.tag && nb(this.tag, this.reg.size);
1784
+ c = null;
1785
+ break;
1786
+ case 2:
1787
+ d = "doc";
1788
+ f = this.store && lb(this.store);
1789
+ c = null;
1790
+ break;
1791
+ default:
1792
+ return;
1793
+ }
1794
+ return rb.call(this, a, c, d, f || null, b, e);
1795
+ }
1796
+ function kb(a, c) {
1797
+ var b = a.split(".");
1798
+ b[b.length - 1] === "json" && b.pop();
1799
+ const e = b.length > 2 ? b[0] : "";
1800
+ b = b.length > 2 ? b[2] : b[1];
1801
+ if (this.worker && e) return this.index.get(e).import(a);
1802
+ if (c) {
1803
+ typeof c === "string" && (c = JSON.parse(c));
1804
+ if (e) return this.index.get(e).import(b, c);
1805
+ switch (b) {
1806
+ case "reg":
1807
+ this.fastupdate = false;
1808
+ this.reg = qb(c, this.reg);
1809
+ for (let d = 0, f; d < this.field.length; d++) f = this.index.get(this.field[d]), f.fastupdate = false, f.reg = this.reg;
1810
+ if (this.worker) {
1811
+ c = [];
1812
+ for (const d of this.index.values()) c.push(d.import(a));
1813
+ return Promise.all(c);
1814
+ }
1815
+ break;
1816
+ case "tag":
1817
+ this.tag = ob(c, this.tag);
1818
+ break;
1819
+ case "doc":
1820
+ this.store = mb(c, this.store);
1821
+ }
1822
+ }
1823
+ }
1824
+ function sb(a, c) {
1825
+ let b = "";
1826
+ for (const e of a.entries()) {
1827
+ a = e[0];
1828
+ const d = e[1];
1829
+ let f = "";
1830
+ for (let g = 0, k; g < d.length; g++) {
1831
+ k = d[g] || [""];
1832
+ let h = "";
1833
+ for (let l = 0; l < k.length; l++) h += (h ? "," : "") + (c === "string" ? '"' + k[l] + '"' : k[l]);
1834
+ h = "[" + h + "]";
1835
+ f += (f ? "," : "") + h;
1836
+ }
1837
+ f = '["' + a + '",[' + f + "]]";
1838
+ b += (b ? "," : "") + f;
1839
+ }
1840
+ return b;
1841
+ }
1842
+ T.prototype.remove = function(a, c) {
1843
+ const b = this.reg.size && (this.fastupdate ? this.reg.get(a) : this.reg.has(a));
1844
+ if (b) {
1845
+ if (this.fastupdate) for (let e = 0, d, f; e < b.length; e++) {
1846
+ if ((d = b[e]) && (f = d.length)) if (d[f - 1] === a) d.pop();
1847
+ else {
1848
+ const g = d.indexOf(a);
1849
+ g >= 0 && d.splice(g, 1);
1850
+ }
1851
+ }
1852
+ else tb(this.map, a), this.depth && tb(this.ctx, a);
1853
+ c || this.reg.delete(a);
1854
+ }
1855
+ this.db && (this.commit_task.push({ del: a }), this.M && ub(this));
1856
+ this.cache && this.cache.remove(a);
1857
+ return this;
1858
+ };
1859
+ function tb(a, c) {
1860
+ let b = 0;
1861
+ var e = typeof c === "undefined";
1862
+ if (a.constructor === Array) for (let d = 0, f, g, k; d < a.length; d++) {
1863
+ if ((f = a[d]) && f.length) {
1864
+ if (e) return 1;
1865
+ g = f.indexOf(c);
1866
+ if (g >= 0) {
1867
+ if (f.length > 1) return f.splice(g, 1), 1;
1868
+ delete a[d];
1869
+ if (b) return 1;
1870
+ k = 1;
1871
+ } else {
1872
+ if (k) return 1;
1873
+ b++;
1874
+ }
1875
+ }
1876
+ }
1877
+ else for (let d of a.entries()) e = d[0], tb(d[1], c) ? b++ : a.delete(e);
1878
+ return b;
1879
+ }
1880
+ var vb = { memory: { resolution: 1 }, performance: { resolution: 3, fastupdate: true, context: { depth: 1, resolution: 1 } }, match: { tokenize: "forward" }, score: { resolution: 9, context: { depth: 2, resolution: 3 } } };
1881
+ T.prototype.add = function(a, c, b, e) {
1882
+ if (c && (a || a === 0)) {
1883
+ if (!e && !b && this.reg.has(a)) return this.update(a, c);
1884
+ e = this.depth;
1885
+ c = this.encoder.encode(c, !e);
1886
+ const l = c.length;
1887
+ if (l) {
1888
+ const m = I(), p = I(), u = this.resolution;
1889
+ for (let r = 0; r < l; r++) {
1890
+ let t = c[this.rtl ? l - 1 - r : r];
1891
+ var d = t.length;
1892
+ if (d && (e || !p[t])) {
1893
+ var f = this.score ? this.score(c, t, r, null, 0) : wb(u, l, r), g = "";
1894
+ switch (this.tokenize) {
1895
+ case "tolerant":
1896
+ Y(this, p, t, f, a, b);
1897
+ if (d > 2) {
1898
+ for (let n = 1, q, x, v, A; n < d - 1; n++) q = t.charAt(n), x = t.charAt(n + 1), v = t.substring(0, n) + x, A = t.substring(n + 2), g = v + q + A, Y(this, p, g, f, a, b), g = v + A, Y(this, p, g, f, a, b);
1899
+ Y(this, p, t.substring(0, t.length - 1), f, a, b);
1900
+ }
1901
+ break;
1902
+ case "full":
1903
+ if (d > 2) {
1904
+ for (let n = 0, q; n < d; n++) for (f = d; f > n; f--) {
1905
+ g = t.substring(n, f);
1906
+ q = this.rtl ? d - 1 - n : n;
1907
+ var k = this.score ? this.score(c, t, r, g, q) : wb(u, l, r, d, q);
1908
+ Y(this, p, g, k, a, b);
1909
+ }
1910
+ break;
1911
+ }
1912
+ case "bidirectional":
1913
+ case "reverse":
1914
+ if (d > 1) {
1915
+ for (k = d - 1; k > 0; k--) {
1916
+ g = t[this.rtl ? d - 1 - k : k] + g;
1917
+ var h = this.score ? this.score(c, t, r, g, k) : wb(u, l, r, d, k);
1918
+ Y(this, p, g, h, a, b);
1919
+ }
1920
+ g = "";
1921
+ }
1922
+ case "forward":
1923
+ if (d > 1) {
1924
+ for (k = 0; k < d; k++) g += t[this.rtl ? d - 1 - k : k], Y(
1925
+ this,
1926
+ p,
1927
+ g,
1928
+ f,
1929
+ a,
1930
+ b
1931
+ );
1932
+ break;
1933
+ }
1934
+ default:
1935
+ if (Y(this, p, t, f, a, b), e && l > 1 && r < l - 1) for (d = this.N, g = t, f = Math.min(e + 1, this.rtl ? r + 1 : l - r), k = 1; k < f; k++) {
1936
+ t = c[this.rtl ? l - 1 - r - k : r + k];
1937
+ h = this.bidirectional && t > g;
1938
+ const n = this.score ? this.score(c, g, r, t, k - 1) : wb(d + (l / 2 > d ? 0 : 1), l, r, f - 1, k - 1);
1939
+ Y(this, m, h ? g : t, n, a, b, h ? t : g);
1940
+ }
1941
+ }
1942
+ }
1943
+ }
1944
+ this.fastupdate || this.reg.add(a);
1945
+ }
1946
+ }
1947
+ this.db && (this.commit_task.push(b ? { ins: a } : { del: a }), this.M && ub(this));
1948
+ return this;
1949
+ };
1950
+ function Y(a, c, b, e, d, f, g) {
1951
+ let k, h;
1952
+ if (!(k = c[b]) || g && !k[g]) {
1953
+ g ? (c = k || (c[b] = I()), c[g] = 1, h = a.ctx, (k = h.get(g)) ? h = k : h.set(g, h = a.keystore ? new R(a.keystore) : /* @__PURE__ */ new Map())) : (h = a.map, c[b] = 1);
1954
+ (k = h.get(b)) ? h = k : h.set(b, h = k = []);
1955
+ if (f) {
1956
+ for (let l = 0, m; l < k.length; l++) if ((m = k[l]) && m.includes(d)) {
1957
+ if (l <= e) return;
1958
+ m.splice(m.indexOf(d), 1);
1959
+ a.fastupdate && (c = a.reg.get(d)) && c.splice(c.indexOf(m), 1);
1960
+ break;
1961
+ }
1962
+ }
1963
+ h = h[e] || (h[e] = []);
1964
+ h.push(d);
1965
+ if (h.length === 2 ** 31 - 1) {
1966
+ c = new xa(h);
1967
+ if (a.fastupdate) for (let l of a.reg.values()) l.includes(h) && (l[l.indexOf(h)] = c);
1968
+ k[e] = h = c;
1969
+ }
1970
+ a.fastupdate && ((e = a.reg.get(d)) ? e.push(h) : a.reg.set(d, [h]));
1971
+ }
1972
+ }
1973
+ function wb(a, c, b, e, d) {
1974
+ return b && a > 1 ? c + (e || 0) <= a ? b + (d || 0) : (a - 1) / (c + (e || 0)) * (b + (d || 0)) + 1 | 0 : 0;
1975
+ }
1976
+ T.prototype.search = function(a, c, b) {
1977
+ b || (c || typeof a !== "object" ? typeof c === "object" && (b = c, c = 0) : (b = a, a = ""));
1978
+ if (b && b.cache) return b.cache = false, a = this.searchCache(a, c, b), b.cache = true, a;
1979
+ let e = [], d, f, g, k = 0, h, l, m, p, u;
1980
+ b && (a = b.query || a, c = b.limit || c, k = b.offset || 0, f = b.context, g = b.suggest, u = (h = b.resolve) && b.enrich, m = b.boost, p = b.resolution, l = this.db && b.tag);
1981
+ typeof h === "undefined" && (h = this.resolve);
1982
+ f = this.depth && f !== false;
1983
+ let r = this.encoder.encode(a, !f);
1984
+ d = r.length;
1985
+ c = c || (h ? 100 : 0);
1986
+ if (d === 1) return xb.call(
1987
+ this,
1988
+ r[0],
1989
+ "",
1990
+ c,
1991
+ k,
1992
+ h,
1993
+ u,
1994
+ l
1995
+ );
1996
+ if (d === 2 && f && !g) return xb.call(this, r[1], r[0], c, k, h, u, l);
1997
+ let t = I(), n = 0, q;
1998
+ f && (q = r[0], n = 1);
1999
+ p || p === 0 || (p = q ? this.N : this.resolution);
2000
+ if (this.db) {
2001
+ if (this.db.search && (b = this.db.search(this, r, c, k, g, h, u, l), b !== false)) return b;
2002
+ const x = this;
2003
+ return (async function() {
2004
+ for (let v, A; n < d; n++) {
2005
+ if ((A = r[n]) && !t[A]) {
2006
+ t[A] = 1;
2007
+ v = await yb(x, A, q, 0, 0, false, false);
2008
+ if (v = zb(v, e, g, p)) {
2009
+ e = v;
2010
+ break;
2011
+ }
2012
+ q && (g && v && e.length || (q = A));
2013
+ }
2014
+ g && q && n === d - 1 && !e.length && (p = x.resolution, q = "", n = -1, t = I());
2015
+ }
2016
+ return Ab(e, p, c, k, g, m, h);
2017
+ })();
2018
+ }
2019
+ for (let x, v; n < d; n++) {
2020
+ if ((v = r[n]) && !t[v]) {
2021
+ t[v] = 1;
2022
+ x = yb(this, v, q, 0, 0, false, false);
2023
+ if (x = zb(x, e, g, p)) {
2024
+ e = x;
2025
+ break;
2026
+ }
2027
+ q && (g && x && e.length || (q = v));
2028
+ }
2029
+ g && q && n === d - 1 && !e.length && (p = this.resolution, q = "", n = -1, t = I());
2030
+ }
2031
+ return Ab(e, p, c, k, g, m, h);
2032
+ };
2033
+ function Ab(a, c, b, e, d, f, g) {
2034
+ let k = a.length, h = a;
2035
+ if (k > 1) h = $a(a, c, b, e, d, f, g);
2036
+ else if (k === 1) return g ? Sa.call(null, a[0], b, e) : new X(a[0], this);
2037
+ return g ? h : new X(h, this);
2038
+ }
2039
+ function xb(a, c, b, e, d, f, g) {
2040
+ a = yb(this, a, c, b, e, d, f, g);
2041
+ return this.db ? a.then(function(k) {
2042
+ return d ? k || [] : new X(k, this);
2043
+ }) : a && a.length ? d ? Sa.call(this, a, b, e) : new X(a, this) : d ? [] : new X([], this);
2044
+ }
2045
+ function zb(a, c, b, e) {
2046
+ let d = [];
2047
+ if (a && a.length) {
2048
+ if (a.length <= e) {
2049
+ c.push(a);
2050
+ return;
2051
+ }
2052
+ for (let f = 0, g; f < e; f++) if (g = a[f]) d[f] = g;
2053
+ if (d.length) {
2054
+ c.push(d);
2055
+ return;
2056
+ }
2057
+ }
2058
+ if (!b) return d;
2059
+ }
2060
+ function yb(a, c, b, e, d, f, g, k) {
2061
+ let h;
2062
+ b && (h = a.bidirectional && c > b) && (h = b, b = c, c = h);
2063
+ if (a.db) return a.db.get(c, b, e, d, f, g, k);
2064
+ a = b ? (a = a.ctx.get(b)) && a.get(c) : a.map.get(c);
2065
+ return a;
2066
+ }
2067
+ function T(a, c) {
2068
+ if (!this || this.constructor !== T) return new T(a);
2069
+ if (a) {
2070
+ var b = M(a) ? a : a.preset;
2071
+ b && (a = Object.assign({}, vb[b], a));
2072
+ } else a = {};
2073
+ b = a.context;
2074
+ const e = b === true ? { depth: 1 } : b || {}, d = M(a.encoder) ? va[a.encoder] : a.encode || a.encoder || {};
2075
+ this.encoder = d.encode ? d : typeof d === "object" ? new ka(d) : { encode: d };
2076
+ this.resolution = a.resolution || 9;
2077
+ this.tokenize = b = (b = a.tokenize) && b !== "default" && b !== "exact" && b || "strict";
2078
+ this.depth = b === "strict" && e.depth || 0;
2079
+ this.bidirectional = e.bidirectional !== false;
2080
+ this.fastupdate = !!a.fastupdate;
2081
+ this.score = a.score || null;
2082
+ (b = a.keystore || 0) && (this.keystore = b);
2083
+ this.map = b ? new R(b) : /* @__PURE__ */ new Map();
2084
+ this.ctx = b ? new R(b) : /* @__PURE__ */ new Map();
2085
+ this.reg = c || (this.fastupdate ? b ? new R(b) : /* @__PURE__ */ new Map() : b ? new S(b) : /* @__PURE__ */ new Set());
2086
+ this.N = e.resolution || 3;
2087
+ this.rtl = d.rtl || a.rtl || false;
2088
+ this.cache = (b = a.cache || null) && new ma(b);
2089
+ this.resolve = a.resolve !== false;
2090
+ if (b = a.db) this.db = this.mount(b);
2091
+ this.M = a.commit !== false;
2092
+ this.commit_task = [];
2093
+ this.commit_timer = null;
2094
+ this.priority = a.priority || 4;
2095
+ }
2096
+ w = T.prototype;
2097
+ w.mount = function(a) {
2098
+ this.commit_timer && (clearTimeout(this.commit_timer), this.commit_timer = null);
2099
+ return a.mount(this);
2100
+ };
2101
+ w.commit = function() {
2102
+ this.commit_timer && (clearTimeout(this.commit_timer), this.commit_timer = null);
2103
+ return this.db.commit(this);
2104
+ };
2105
+ w.destroy = function() {
2106
+ this.commit_timer && (clearTimeout(this.commit_timer), this.commit_timer = null);
2107
+ return this.db.destroy();
2108
+ };
2109
+ function ub(a) {
2110
+ a.commit_timer || (a.commit_timer = setTimeout(function() {
2111
+ a.commit_timer = null;
2112
+ a.db.commit(a);
2113
+ }, 1));
2114
+ }
2115
+ w.clear = function() {
2116
+ this.map.clear();
2117
+ this.ctx.clear();
2118
+ this.reg.clear();
2119
+ this.cache && this.cache.clear();
2120
+ return this.db ? (this.commit_timer && clearTimeout(this.commit_timer), this.commit_timer = null, this.commit_task = [], this.db.clear()) : this;
2121
+ };
2122
+ w.append = function(a, c) {
2123
+ return this.add(a, c, true);
2124
+ };
2125
+ w.contain = function(a) {
2126
+ return this.db ? this.db.has(a) : this.reg.has(a);
2127
+ };
2128
+ w.update = function(a, c) {
2129
+ const b = this, e = this.remove(a);
2130
+ return e && e.then ? e.then(() => b.add(a, c)) : this.add(a, c);
2131
+ };
2132
+ w.cleanup = function() {
2133
+ if (!this.fastupdate) return this;
2134
+ tb(this.map);
2135
+ this.depth && tb(this.ctx);
2136
+ return this;
2137
+ };
2138
+ w.searchCache = la;
2139
+ w.export = function(a, c, b = 0, e = 0) {
2140
+ let d, f;
2141
+ switch (e) {
2142
+ case 0:
2143
+ d = "reg";
2144
+ f = pb(this.reg);
2145
+ break;
2146
+ case 1:
2147
+ d = "cfg";
2148
+ f = null;
2149
+ break;
2150
+ case 2:
2151
+ d = "map";
2152
+ f = lb(this.map, this.reg.size);
2153
+ break;
2154
+ case 3:
2155
+ d = "ctx";
2156
+ f = nb(this.ctx, this.reg.size);
2157
+ break;
2158
+ default:
2159
+ return;
2160
+ }
2161
+ return rb.call(this, a, c, d, f, b, e);
2162
+ };
2163
+ w.import = function(a, c) {
2164
+ if (c) switch (typeof c === "string" && (c = JSON.parse(c)), a = a.split("."), a[a.length - 1] === "json" && a.pop(), a.length === 3 && a.shift(), a = a.length > 1 ? a[1] : a[0], a) {
2165
+ case "reg":
2166
+ this.fastupdate = false;
2167
+ this.reg = qb(c, this.reg);
2168
+ break;
2169
+ case "map":
2170
+ this.map = mb(c, this.map);
2171
+ break;
2172
+ case "ctx":
2173
+ this.ctx = ob(c, this.ctx);
2174
+ }
2175
+ };
2176
+ w.serialize = function(a = true) {
2177
+ let c = "", b = "", e = "";
2178
+ if (this.reg.size) {
2179
+ let f;
2180
+ for (var d of this.reg.keys()) f || (f = typeof d), c += (c ? "," : "") + (f === "string" ? '"' + d + '"' : d);
2181
+ c = "index.reg=new Set([" + c + "]);";
2182
+ b = sb(this.map, f);
2183
+ b = "index.map=new Map([" + b + "]);";
2184
+ for (const g of this.ctx.entries()) {
2185
+ d = g[0];
2186
+ let k = sb(g[1], f);
2187
+ k = "new Map([" + k + "])";
2188
+ k = '["' + d + '",' + k + "]";
2189
+ e += (e ? "," : "") + k;
2190
+ }
2191
+ e = "index.ctx=new Map([" + e + "]);";
2192
+ }
2193
+ return a ? "function inject(index){" + c + b + e + "}" : c + b + e;
2194
+ };
2195
+ Fa(T.prototype);
2196
+ var Bb = typeof window !== "undefined" && (window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB);
2197
+ var Cb = ["map", "ctx", "tag", "reg", "cfg"];
2198
+ var Db = I();
2199
+ function Eb(a, c = {}) {
2200
+ if (!this || this.constructor !== Eb) return new Eb(a, c);
2201
+ typeof a === "object" && (c = a, a = a.name);
2202
+ a || console.info("Default storage space was used, because a name was not passed.");
2203
+ this.id = "flexsearch" + (a ? ":" + a.toLowerCase().replace(/[^a-z0-9_\-]/g, "") : "");
2204
+ this.field = c.field ? c.field.toLowerCase().replace(/[^a-z0-9_\-]/g, "") : "";
2205
+ this.type = c.type;
2206
+ this.fastupdate = this.support_tag_search = false;
2207
+ this.db = null;
2208
+ this.h = {};
2209
+ }
2210
+ w = Eb.prototype;
2211
+ w.mount = function(a) {
2212
+ if (a.index) return a.mount(this);
2213
+ a.db = this;
2214
+ return this.open();
2215
+ };
2216
+ w.open = function() {
2217
+ if (this.db) return this.db;
2218
+ let a = this;
2219
+ navigator.storage && navigator.storage.persist && navigator.storage.persist();
2220
+ Db[a.id] || (Db[a.id] = []);
2221
+ Db[a.id].push(a.field);
2222
+ const c = Bb.open(a.id, 1);
2223
+ c.onupgradeneeded = function() {
2224
+ const b = a.db = this.result;
2225
+ for (let e = 0, d; e < Cb.length; e++) {
2226
+ d = Cb[e];
2227
+ for (let f = 0, g; f < Db[a.id].length; f++) g = Db[a.id][f], b.objectStoreNames.contains(d + (d !== "reg" ? g ? ":" + g : "" : "")) || b.createObjectStore(d + (d !== "reg" ? g ? ":" + g : "" : ""));
2228
+ }
2229
+ };
2230
+ return a.db = Z(c, function(b) {
2231
+ a.db = b;
2232
+ a.db.onversionchange = function() {
2233
+ a.close();
2234
+ };
2235
+ });
2236
+ };
2237
+ w.close = function() {
2238
+ this.db && this.db.close();
2239
+ this.db = null;
2240
+ };
2241
+ w.destroy = function() {
2242
+ const a = Bb.deleteDatabase(this.id);
2243
+ return Z(a);
2244
+ };
2245
+ w.clear = function() {
2246
+ const a = [];
2247
+ for (let b = 0, e; b < Cb.length; b++) {
2248
+ e = Cb[b];
2249
+ for (let d = 0, f; d < Db[this.id].length; d++) f = Db[this.id][d], a.push(e + (e !== "reg" ? f ? ":" + f : "" : ""));
2250
+ }
2251
+ const c = this.db.transaction(a, "readwrite");
2252
+ for (let b = 0; b < a.length; b++) c.objectStore(a[b]).clear();
2253
+ return Z(c);
2254
+ };
2255
+ w.get = function(a, c, b = 0, e = 0, d = true, f = false) {
2256
+ 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);
2257
+ const g = this;
2258
+ return Z(a).then(function(k) {
2259
+ let h = [];
2260
+ if (!k || !k.length) return h;
2261
+ if (d) {
2262
+ if (!b && !e && k.length === 1) return k[0];
2263
+ for (let l = 0, m; l < k.length; l++) if ((m = k[l]) && m.length) {
2264
+ if (e >= m.length) {
2265
+ e -= m.length;
2266
+ continue;
2267
+ }
2268
+ const p = b ? e + Math.min(m.length - e, b) : m.length;
2269
+ for (let u = e; u < p; u++) h.push(m[u]);
2270
+ e = 0;
2271
+ if (h.length === b) break;
2272
+ }
2273
+ return f ? g.enrich(h) : h;
2274
+ }
2275
+ return k;
2276
+ });
2277
+ };
2278
+ w.tag = function(a, c = 0, b = 0, e = false) {
2279
+ a = this.db.transaction("tag" + (this.field ? ":" + this.field : ""), "readonly").objectStore("tag" + (this.field ? ":" + this.field : "")).get(a);
2280
+ const d = this;
2281
+ return Z(a).then(function(f) {
2282
+ if (!f || !f.length || b >= f.length) return [];
2283
+ if (!c && !b) return f;
2284
+ f = f.slice(b, b + c);
2285
+ return e ? d.enrich(f) : f;
2286
+ });
2287
+ };
2288
+ w.enrich = function(a) {
2289
+ typeof a !== "object" && (a = [a]);
2290
+ const c = this.db.transaction("reg", "readonly").objectStore("reg"), b = [];
2291
+ for (let e = 0; e < a.length; e++) b[e] = Z(c.get(a[e]));
2292
+ return Promise.all(b).then(function(e) {
2293
+ for (let d = 0; d < e.length; d++) e[d] = { id: a[d], doc: e[d] ? JSON.parse(e[d]) : null };
2294
+ return e;
2295
+ });
2296
+ };
2297
+ w.has = function(a) {
2298
+ a = this.db.transaction("reg", "readonly").objectStore("reg").getKey(a);
2299
+ return Z(a).then(function(c) {
2300
+ return !!c;
2301
+ });
2302
+ };
2303
+ w.search = null;
2304
+ w.info = function() {
2305
+ };
2306
+ w.transaction = function(a, c, b) {
2307
+ a += a !== "reg" ? this.field ? ":" + this.field : "" : "";
2308
+ let e = this.h[a + ":" + c];
2309
+ if (e) return b.call(this, e);
2310
+ let d = this.db.transaction(a, c);
2311
+ this.h[a + ":" + c] = e = d.objectStore(a);
2312
+ const f = b.call(this, e);
2313
+ this.h[a + ":" + c] = null;
2314
+ return Z(d).finally(function() {
2315
+ return f;
2316
+ });
2317
+ };
2318
+ w.commit = async function(a) {
2319
+ let c = a.commit_task, b = [];
2320
+ a.commit_task = [];
2321
+ for (let e = 0, d; e < c.length; e++) d = c[e], d.del && b.push(d.del);
2322
+ b.length && await this.remove(b);
2323
+ a.reg.size && (await this.transaction("map", "readwrite", function(e) {
2324
+ for (const d of a.map) {
2325
+ const f = d[0], g = d[1];
2326
+ g.length && (e.get(f).onsuccess = function() {
2327
+ let k = this.result;
2328
+ var h;
2329
+ if (k && k.length) {
2330
+ const l = Math.max(k.length, g.length);
2331
+ for (let m = 0, p, u; m < l; m++) if ((u = g[m]) && u.length) {
2332
+ if ((p = k[m]) && p.length) for (h = 0; h < u.length; h++) p.push(u[h]);
2333
+ else k[m] = u;
2334
+ h = 1;
2335
+ }
2336
+ } else k = g, h = 1;
2337
+ h && e.put(k, f);
2338
+ });
2339
+ }
2340
+ }), await this.transaction("ctx", "readwrite", function(e) {
2341
+ for (const d of a.ctx) {
2342
+ const f = d[0], g = d[1];
2343
+ for (const k of g) {
2344
+ const h = k[0], l = k[1];
2345
+ l.length && (e.get(f + ":" + h).onsuccess = function() {
2346
+ let m = this.result;
2347
+ var p;
2348
+ if (m && m.length) {
2349
+ const u = Math.max(m.length, l.length);
2350
+ for (let r = 0, t, n; r < u; r++) if ((n = l[r]) && n.length) {
2351
+ if ((t = m[r]) && t.length) for (p = 0; p < n.length; p++) t.push(n[p]);
2352
+ else m[r] = n;
2353
+ p = 1;
2354
+ }
2355
+ } else m = l, p = 1;
2356
+ p && e.put(m, f + ":" + h);
2357
+ });
2358
+ }
2359
+ }
2360
+ }), a.store ? await this.transaction(
2361
+ "reg",
2362
+ "readwrite",
2363
+ function(e) {
2364
+ for (const d of a.store) {
2365
+ const f = d[0], g = d[1];
2366
+ e.put(typeof g === "object" ? JSON.stringify(g) : 1, f);
2367
+ }
2368
+ }
2369
+ ) : a.bypass || await this.transaction("reg", "readwrite", function(e) {
2370
+ for (const d of a.reg.keys()) e.put(1, d);
2371
+ }), a.tag && await this.transaction("tag", "readwrite", function(e) {
2372
+ for (const d of a.tag) {
2373
+ const f = d[0], g = d[1];
2374
+ g.length && (e.get(f).onsuccess = function() {
2375
+ let k = this.result;
2376
+ k = k && k.length ? k.concat(g) : g;
2377
+ e.put(k, f);
2378
+ });
2379
+ }
2380
+ }), a.map.clear(), a.ctx.clear(), a.tag && a.tag.clear(), a.store && a.store.clear(), a.document || a.reg.clear());
2381
+ };
2382
+ function Fb(a, c, b) {
2383
+ const e = a.value;
2384
+ let d, f = 0;
2385
+ for (let g = 0, k; g < e.length; g++) {
2386
+ if (k = b ? e : e[g]) {
2387
+ for (let h = 0, l, m; h < c.length; h++) if (m = c[h], l = k.indexOf(m), l >= 0) if (d = 1, k.length > 1) k.splice(l, 1);
2388
+ else {
2389
+ e[g] = [];
2390
+ break;
2391
+ }
2392
+ f += k.length;
2393
+ }
2394
+ if (b) break;
2395
+ }
2396
+ f ? d && a.update(e) : a.delete();
2397
+ a.continue();
2398
+ }
2399
+ w.remove = function(a) {
2400
+ typeof a !== "object" && (a = [a]);
2401
+ return Promise.all([this.transaction("map", "readwrite", function(c) {
2402
+ c.openCursor().onsuccess = function() {
2403
+ const b = this.result;
2404
+ b && Fb(b, a);
2405
+ };
2406
+ }), this.transaction("ctx", "readwrite", function(c) {
2407
+ c.openCursor().onsuccess = function() {
2408
+ const b = this.result;
2409
+ b && Fb(b, a);
2410
+ };
2411
+ }), this.transaction("tag", "readwrite", function(c) {
2412
+ c.openCursor().onsuccess = function() {
2413
+ const b = this.result;
2414
+ b && Fb(b, a, true);
2415
+ };
2416
+ }), this.transaction("reg", "readwrite", function(c) {
2417
+ for (let b = 0; b < a.length; b++) c.delete(a[b]);
2418
+ })]);
2419
+ };
2420
+ function Z(a, c) {
2421
+ return new Promise((b, e) => {
2422
+ a.onsuccess = a.oncomplete = function() {
2423
+ c && c(this.result);
2424
+ c = null;
2425
+ b(this.result);
2426
+ };
2427
+ a.onerror = a.onblocked = e;
2428
+ a = null;
2429
+ });
2430
+ }
2431
+ var __defProp2 = Object.defineProperty;
2432
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
2433
+ var __hasOwnProp2 = Object.prototype.hasOwnProperty;
2434
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
2435
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2436
+ var __spreadValues = (a, b) => {
2437
+ for (var prop in b || (b = {}))
2438
+ if (__hasOwnProp2.call(b, prop))
2439
+ __defNormalProp(a, prop, b[prop]);
2440
+ if (__getOwnPropSymbols)
2441
+ for (var prop of __getOwnPropSymbols(b)) {
2442
+ if (__propIsEnum.call(b, prop))
2443
+ __defNormalProp(a, prop, b[prop]);
2444
+ }
2445
+ return a;
2446
+ };
2447
+ var __async = (__this, __arguments, generator) => {
2448
+ return new Promise((resolve, reject) => {
2449
+ var fulfilled = (value) => {
2450
+ try {
2451
+ step(generator.next(value));
2452
+ } catch (e) {
2453
+ reject(e);
2454
+ }
2455
+ };
2456
+ var rejected = (value) => {
2457
+ try {
2458
+ step(generator.throw(value));
2459
+ } catch (e) {
2460
+ reject(e);
2461
+ }
2462
+ };
2463
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
2464
+ step((generator = generator.apply(__this, __arguments)).next());
2465
+ });
2466
+ };
2467
+ var log3 = loggers.search;
2468
+ var FileBasedSearchIndexExporter = class {
2469
+ constructor(options) {
2470
+ this.cachedData = null;
2471
+ this.baseDir = options.baseDir;
2472
+ this.indexPath = options.indexPath;
2473
+ }
2474
+ getFullPath() {
2475
+ return path__namespace.join(this.baseDir, this.indexPath);
2476
+ }
2477
+ loadData() {
2478
+ return __async(this, null, function* () {
2479
+ if (this.cachedData) {
2480
+ return this.cachedData;
2481
+ }
2482
+ const fullPath = this.getFullPath();
2483
+ try {
2484
+ const fileContent = yield fs__namespace.readFile(fullPath, "utf-8");
2485
+ const data = JSON.parse(fileContent);
2486
+ if (!data || !data.keys || !Array.isArray(data.keys) || !data.data) {
2487
+ log3.warn("Invalid search index structure in file:", fullPath);
2488
+ return null;
2489
+ }
2490
+ if (data.keys.length === 0) {
2491
+ log3.debug("Search index is empty:", fullPath);
2492
+ return null;
2493
+ }
2494
+ this.cachedData = data;
2495
+ log3.debug("Search index loaded from file:", fullPath, "with", data.keys.length, "keys");
2496
+ return data;
2497
+ } catch (error) {
2498
+ log3.error("Failed to load search index from file:", fullPath, error);
2499
+ return null;
2500
+ }
2501
+ });
2502
+ }
2503
+ import() {
2504
+ return __async(this, null, function* () {
2505
+ const data = yield this.loadData();
2506
+ return data;
2507
+ });
2508
+ }
2509
+ export(data) {
2510
+ return __async(this, null, function* () {
2511
+ const fullPath = this.getFullPath();
2512
+ try {
2513
+ const dir = path__namespace.dirname(fullPath);
2514
+ yield fs__namespace.mkdir(dir, { recursive: true });
2515
+ yield fs__namespace.writeFile(fullPath, JSON.stringify(data, null, 2), "utf-8");
2516
+ log3.debug("Search index saved to file:", fullPath, "with", data.keys.length, "keys");
2517
+ } catch (error) {
2518
+ log3.error("Failed to save search index to file:", fullPath, error);
2519
+ throw error;
2520
+ }
2521
+ });
2522
+ }
2523
+ };
2524
+ function createExporterFromConfig(exporterConfig) {
2525
+ if (exporterConfig.type === "fileBased") {
2526
+ return new FileBasedSearchIndexExporter(__spreadValues({}, exporterConfig.config));
2527
+ }
2528
+ throw new Error(`Unknown exporter type: ${exporterConfig.type}`);
2529
+ }
2530
+
2531
+ // src/config.ts
2532
+ ({
2533
+ searchExporter: {
2534
+ config: { baseDir: process.cwd()}
2535
+ }});
2536
+ var getConfig = () => {
2537
+ if (!process.env.PEAM_SEARCH_EXPORTER_TYPE || !process.env.PEAM_SEARCH_EXPORTER_CONFIG) {
2538
+ throw new Error(
2539
+ "Peam configuration not found. Make sure withPeam() is properly configured in your next.config file."
2540
+ );
2541
+ }
2542
+ const searchExporter = {
2543
+ type: process.env.PEAM_SEARCH_EXPORTER_TYPE,
2544
+ config: JSON.parse(process.env.PEAM_SEARCH_EXPORTER_CONFIG)
2545
+ };
2546
+ const resolvedConfig = {
2547
+ searchIndexExporter: createExporterFromConfig(searchExporter),
2548
+ respectRobotsTxt: process.env.PEAM_RESPECT_ROBOTS_TXT === "true",
2549
+ robotsTxtPath: process.env.PEAM_ROBOTS_TXT_PATH || void 0,
2550
+ exclude: process.env.PEAM_EXCLUDE ? JSON.parse(process.env.PEAM_EXCLUDE) : []
2551
+ };
2552
+ return resolvedConfig;
2553
+ };
4
2554
 
5
2555
  // src/route.ts
6
- var POST = server.createHandler();
2556
+ var config = getConfig();
2557
+ var POST = server.createHandler({
2558
+ searchIndexExporter: config.searchIndexExporter
2559
+ });
7
2560
 
8
2561
  exports.POST = POST;
9
2562
  //# sourceMappingURL=route.js.map