@eox/itemfilter 0.0.1 → 0.0.2
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/eox-itemfilter.js +707 -907
- package/dist/eox-itemfilter.umd.cjs +4 -1212
- package/package.json +1 -1
- package/test/general.cy.ts +1 -0
- package/test/general.html +1 -1
|
@@ -1,1041 +1,4 @@
|
|
|
1
|
-
(function (E, m) {
|
|
2
|
-
typeof exports == "object" && typeof module < "u"
|
|
3
|
-
? m(exports)
|
|
4
|
-
: typeof define == "function" && define.amd
|
|
5
|
-
? define(["exports"], m)
|
|
6
|
-
: ((E = typeof globalThis < "u" ? globalThis : E || self),
|
|
7
|
-
m((E["eox-itemfilter"] = {})));
|
|
8
|
-
})(this, function (E) {
|
|
9
|
-
"use strict";
|
|
10
|
-
var Ze = Object.defineProperty;
|
|
11
|
-
var et = (E, m, R) =>
|
|
12
|
-
m in E
|
|
13
|
-
? Ze(E, m, { enumerable: !0, configurable: !0, writable: !0, value: R })
|
|
14
|
-
: (E[m] = R);
|
|
15
|
-
var _ = (E, m, R) => (et(E, typeof m != "symbol" ? m + "" : m, R), R);
|
|
16
|
-
function m(s) {
|
|
17
|
-
return Array.isArray ? Array.isArray(s) : J(s) === "[object Array]";
|
|
18
|
-
}
|
|
19
|
-
const R = 1 / 0;
|
|
20
|
-
function de(s) {
|
|
21
|
-
if (typeof s == "string") return s;
|
|
22
|
-
let e = s + "";
|
|
23
|
-
return e == "0" && 1 / s == -R ? "-0" : e;
|
|
24
|
-
}
|
|
25
|
-
function ge(s) {
|
|
26
|
-
return s == null ? "" : de(s);
|
|
27
|
-
}
|
|
28
|
-
function A(s) {
|
|
29
|
-
return typeof s == "string";
|
|
30
|
-
}
|
|
31
|
-
function Q(s) {
|
|
32
|
-
return typeof s == "number";
|
|
33
|
-
}
|
|
34
|
-
function pe(s) {
|
|
35
|
-
return s === !0 || s === !1 || (me(s) && J(s) == "[object Boolean]");
|
|
36
|
-
}
|
|
37
|
-
function X(s) {
|
|
38
|
-
return typeof s == "object";
|
|
39
|
-
}
|
|
40
|
-
function me(s) {
|
|
41
|
-
return X(s) && s !== null;
|
|
42
|
-
}
|
|
43
|
-
function M(s) {
|
|
44
|
-
return s != null;
|
|
45
|
-
}
|
|
46
|
-
function H(s) {
|
|
47
|
-
return !s.trim().length;
|
|
48
|
-
}
|
|
49
|
-
function J(s) {
|
|
50
|
-
return s == null
|
|
51
|
-
? s === void 0
|
|
52
|
-
? "[object Undefined]"
|
|
53
|
-
: "[object Null]"
|
|
54
|
-
: Object.prototype.toString.call(s);
|
|
55
|
-
}
|
|
56
|
-
const tt = "Extended search is not available",
|
|
57
|
-
ye = "Incorrect 'index' type",
|
|
58
|
-
Me = (s) => `Invalid value for key ${s}`,
|
|
59
|
-
Ee = (s) => `Pattern length exceeds max of ${s}.`,
|
|
60
|
-
xe = (s) => `Missing ${s} property in key`,
|
|
61
|
-
Se = (s) => `Property 'weight' in key '${s}' must be a positive integer`,
|
|
62
|
-
q = Object.prototype.hasOwnProperty;
|
|
63
|
-
class Ae {
|
|
64
|
-
constructor(e) {
|
|
65
|
-
(this._keys = []), (this._keyMap = {});
|
|
66
|
-
let t = 0;
|
|
67
|
-
e.forEach((r) => {
|
|
68
|
-
let n = Z(r);
|
|
69
|
-
(t += n.weight),
|
|
70
|
-
this._keys.push(n),
|
|
71
|
-
(this._keyMap[n.id] = n),
|
|
72
|
-
(t += n.weight);
|
|
73
|
-
}),
|
|
74
|
-
this._keys.forEach((r) => {
|
|
75
|
-
r.weight /= t;
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
get(e) {
|
|
79
|
-
return this._keyMap[e];
|
|
80
|
-
}
|
|
81
|
-
keys() {
|
|
82
|
-
return this._keys;
|
|
83
|
-
}
|
|
84
|
-
toJSON() {
|
|
85
|
-
return JSON.stringify(this._keys);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
function Z(s) {
|
|
89
|
-
let e = null,
|
|
90
|
-
t = null,
|
|
91
|
-
r = null,
|
|
92
|
-
n = 1,
|
|
93
|
-
i = null;
|
|
94
|
-
if (A(s) || m(s)) (r = s), (e = ee(s)), (t = B(s));
|
|
95
|
-
else {
|
|
96
|
-
if (!q.call(s, "name")) throw new Error(xe("name"));
|
|
97
|
-
const c = s.name;
|
|
98
|
-
if (((r = c), q.call(s, "weight") && ((n = s.weight), n <= 0)))
|
|
99
|
-
throw new Error(Se(c));
|
|
100
|
-
(e = ee(c)), (t = B(c)), (i = s.getFn);
|
|
101
|
-
}
|
|
102
|
-
return { path: e, id: t, weight: n, src: r, getFn: i };
|
|
103
|
-
}
|
|
104
|
-
function ee(s) {
|
|
105
|
-
return m(s) ? s : s.split(".");
|
|
106
|
-
}
|
|
107
|
-
function B(s) {
|
|
108
|
-
return m(s) ? s.join(".") : s;
|
|
109
|
-
}
|
|
110
|
-
function Ie(s, e) {
|
|
111
|
-
let t = [],
|
|
112
|
-
r = !1;
|
|
113
|
-
const n = (i, c, o) => {
|
|
114
|
-
if (M(i))
|
|
115
|
-
if (!c[o]) t.push(i);
|
|
116
|
-
else {
|
|
117
|
-
let a = c[o];
|
|
118
|
-
const h = i[a];
|
|
119
|
-
if (!M(h)) return;
|
|
120
|
-
if (o === c.length - 1 && (A(h) || Q(h) || pe(h))) t.push(ge(h));
|
|
121
|
-
else if (m(h)) {
|
|
122
|
-
r = !0;
|
|
123
|
-
for (let l = 0, u = h.length; l < u; l += 1) n(h[l], c, o + 1);
|
|
124
|
-
} else c.length && n(h, c, o + 1);
|
|
125
|
-
}
|
|
126
|
-
};
|
|
127
|
-
return n(s, A(e) ? e.split(".") : e, 0), r ? t : t[0];
|
|
128
|
-
}
|
|
129
|
-
var f = {
|
|
130
|
-
...{
|
|
131
|
-
isCaseSensitive: !1,
|
|
132
|
-
includeScore: !1,
|
|
133
|
-
keys: [],
|
|
134
|
-
shouldSort: !0,
|
|
135
|
-
sortFn: (s, e) =>
|
|
136
|
-
s.score === e.score
|
|
137
|
-
? s.idx < e.idx
|
|
138
|
-
? -1
|
|
139
|
-
: 1
|
|
140
|
-
: s.score < e.score
|
|
141
|
-
? -1
|
|
142
|
-
: 1,
|
|
143
|
-
},
|
|
144
|
-
...{ includeMatches: !1, findAllMatches: !1, minMatchCharLength: 1 },
|
|
145
|
-
...{ location: 0, threshold: 0.6, distance: 100 },
|
|
146
|
-
...{
|
|
147
|
-
useExtendedSearch: !1,
|
|
148
|
-
getFn: Ie,
|
|
149
|
-
ignoreLocation: !1,
|
|
150
|
-
ignoreFieldNorm: !1,
|
|
151
|
-
fieldNormWeight: 1,
|
|
152
|
-
},
|
|
153
|
-
};
|
|
154
|
-
const _e = /[^ ]+/g;
|
|
155
|
-
function we(s = 1, e = 3) {
|
|
156
|
-
const t = new Map(),
|
|
157
|
-
r = Math.pow(10, e);
|
|
158
|
-
return {
|
|
159
|
-
get(n) {
|
|
160
|
-
const i = n.match(_e).length;
|
|
161
|
-
if (t.has(i)) return t.get(i);
|
|
162
|
-
const c = 1 / Math.pow(i, 0.5 * s),
|
|
163
|
-
o = parseFloat(Math.round(c * r) / r);
|
|
164
|
-
return t.set(i, o), o;
|
|
165
|
-
},
|
|
166
|
-
clear() {
|
|
167
|
-
t.clear();
|
|
168
|
-
},
|
|
169
|
-
};
|
|
170
|
-
}
|
|
171
|
-
class K {
|
|
172
|
-
constructor({
|
|
173
|
-
getFn: e = f.getFn,
|
|
174
|
-
fieldNormWeight: t = f.fieldNormWeight,
|
|
175
|
-
} = {}) {
|
|
176
|
-
(this.norm = we(t, 3)),
|
|
177
|
-
(this.getFn = e),
|
|
178
|
-
(this.isCreated = !1),
|
|
179
|
-
this.setIndexRecords();
|
|
180
|
-
}
|
|
181
|
-
setSources(e = []) {
|
|
182
|
-
this.docs = e;
|
|
183
|
-
}
|
|
184
|
-
setIndexRecords(e = []) {
|
|
185
|
-
this.records = e;
|
|
186
|
-
}
|
|
187
|
-
setKeys(e = []) {
|
|
188
|
-
(this.keys = e),
|
|
189
|
-
(this._keysMap = {}),
|
|
190
|
-
e.forEach((t, r) => {
|
|
191
|
-
this._keysMap[t.id] = r;
|
|
192
|
-
});
|
|
193
|
-
}
|
|
194
|
-
create() {
|
|
195
|
-
this.isCreated ||
|
|
196
|
-
!this.docs.length ||
|
|
197
|
-
((this.isCreated = !0),
|
|
198
|
-
A(this.docs[0])
|
|
199
|
-
? this.docs.forEach((e, t) => {
|
|
200
|
-
this._addString(e, t);
|
|
201
|
-
})
|
|
202
|
-
: this.docs.forEach((e, t) => {
|
|
203
|
-
this._addObject(e, t);
|
|
204
|
-
}),
|
|
205
|
-
this.norm.clear());
|
|
206
|
-
}
|
|
207
|
-
add(e) {
|
|
208
|
-
const t = this.size();
|
|
209
|
-
A(e) ? this._addString(e, t) : this._addObject(e, t);
|
|
210
|
-
}
|
|
211
|
-
removeAt(e) {
|
|
212
|
-
this.records.splice(e, 1);
|
|
213
|
-
for (let t = e, r = this.size(); t < r; t += 1) this.records[t].i -= 1;
|
|
214
|
-
}
|
|
215
|
-
getValueForItemAtKeyId(e, t) {
|
|
216
|
-
return e[this._keysMap[t]];
|
|
217
|
-
}
|
|
218
|
-
size() {
|
|
219
|
-
return this.records.length;
|
|
220
|
-
}
|
|
221
|
-
_addString(e, t) {
|
|
222
|
-
if (!M(e) || H(e)) return;
|
|
223
|
-
let r = { v: e, i: t, n: this.norm.get(e) };
|
|
224
|
-
this.records.push(r);
|
|
225
|
-
}
|
|
226
|
-
_addObject(e, t) {
|
|
227
|
-
let r = { i: t, $: {} };
|
|
228
|
-
this.keys.forEach((n, i) => {
|
|
229
|
-
let c = n.getFn ? n.getFn(e) : this.getFn(e, n.path);
|
|
230
|
-
if (M(c)) {
|
|
231
|
-
if (m(c)) {
|
|
232
|
-
let o = [];
|
|
233
|
-
const a = [{ nestedArrIndex: -1, value: c }];
|
|
234
|
-
for (; a.length; ) {
|
|
235
|
-
const { nestedArrIndex: h, value: l } = a.pop();
|
|
236
|
-
if (M(l))
|
|
237
|
-
if (A(l) && !H(l)) {
|
|
238
|
-
let u = { v: l, i: h, n: this.norm.get(l) };
|
|
239
|
-
o.push(u);
|
|
240
|
-
} else
|
|
241
|
-
m(l) &&
|
|
242
|
-
l.forEach((u, d) => {
|
|
243
|
-
a.push({ nestedArrIndex: d, value: u });
|
|
244
|
-
});
|
|
245
|
-
}
|
|
246
|
-
r.$[i] = o;
|
|
247
|
-
} else if (A(c) && !H(c)) {
|
|
248
|
-
let o = { v: c, n: this.norm.get(c) };
|
|
249
|
-
r.$[i] = o;
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
}),
|
|
253
|
-
this.records.push(r);
|
|
254
|
-
}
|
|
255
|
-
toJSON() {
|
|
256
|
-
return { keys: this.keys, records: this.records };
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
function te(
|
|
260
|
-
s,
|
|
261
|
-
e,
|
|
262
|
-
{ getFn: t = f.getFn, fieldNormWeight: r = f.fieldNormWeight } = {}
|
|
263
|
-
) {
|
|
264
|
-
const n = new K({ getFn: t, fieldNormWeight: r });
|
|
265
|
-
return n.setKeys(s.map(Z)), n.setSources(e), n.create(), n;
|
|
266
|
-
}
|
|
267
|
-
function Le(
|
|
268
|
-
s,
|
|
269
|
-
{ getFn: e = f.getFn, fieldNormWeight: t = f.fieldNormWeight } = {}
|
|
270
|
-
) {
|
|
271
|
-
const { keys: r, records: n } = s,
|
|
272
|
-
i = new K({ getFn: e, fieldNormWeight: t });
|
|
273
|
-
return i.setKeys(r), i.setIndexRecords(n), i;
|
|
274
|
-
}
|
|
275
|
-
function v(
|
|
276
|
-
s,
|
|
277
|
-
{
|
|
278
|
-
errors: e = 0,
|
|
279
|
-
currentLocation: t = 0,
|
|
280
|
-
expectedLocation: r = 0,
|
|
281
|
-
distance: n = f.distance,
|
|
282
|
-
ignoreLocation: i = f.ignoreLocation,
|
|
283
|
-
} = {}
|
|
284
|
-
) {
|
|
285
|
-
const c = e / s.length;
|
|
286
|
-
if (i) return c;
|
|
287
|
-
const o = Math.abs(r - t);
|
|
288
|
-
return n ? c + o / n : o ? 1 : c;
|
|
289
|
-
}
|
|
290
|
-
function be(s = [], e = f.minMatchCharLength) {
|
|
291
|
-
let t = [],
|
|
292
|
-
r = -1,
|
|
293
|
-
n = -1,
|
|
294
|
-
i = 0;
|
|
295
|
-
for (let c = s.length; i < c; i += 1) {
|
|
296
|
-
let o = s[i];
|
|
297
|
-
o && r === -1
|
|
298
|
-
? (r = i)
|
|
299
|
-
: !o &&
|
|
300
|
-
r !== -1 &&
|
|
301
|
-
((n = i - 1), n - r + 1 >= e && t.push([r, n]), (r = -1));
|
|
302
|
-
}
|
|
303
|
-
return s[i - 1] && i - r >= e && t.push([r, i - 1]), t;
|
|
304
|
-
}
|
|
305
|
-
const k = 32;
|
|
306
|
-
function Re(
|
|
307
|
-
s,
|
|
308
|
-
e,
|
|
309
|
-
t,
|
|
310
|
-
{
|
|
311
|
-
location: r = f.location,
|
|
312
|
-
distance: n = f.distance,
|
|
313
|
-
threshold: i = f.threshold,
|
|
314
|
-
findAllMatches: c = f.findAllMatches,
|
|
315
|
-
minMatchCharLength: o = f.minMatchCharLength,
|
|
316
|
-
includeMatches: a = f.includeMatches,
|
|
317
|
-
ignoreLocation: h = f.ignoreLocation,
|
|
318
|
-
} = {}
|
|
319
|
-
) {
|
|
320
|
-
if (e.length > k) throw new Error(Ee(k));
|
|
321
|
-
const l = e.length,
|
|
322
|
-
u = s.length,
|
|
323
|
-
d = Math.max(0, Math.min(r, u));
|
|
324
|
-
let g = i,
|
|
325
|
-
p = d;
|
|
326
|
-
const y = o > 1 || a,
|
|
327
|
-
T = y ? Array(u) : [];
|
|
328
|
-
let I;
|
|
329
|
-
for (; (I = s.indexOf(e, p)) > -1; ) {
|
|
330
|
-
let x = v(e, {
|
|
331
|
-
currentLocation: I,
|
|
332
|
-
expectedLocation: d,
|
|
333
|
-
distance: n,
|
|
334
|
-
ignoreLocation: h,
|
|
335
|
-
});
|
|
336
|
-
if (((g = Math.min(x, g)), (p = I + l), y)) {
|
|
337
|
-
let L = 0;
|
|
338
|
-
for (; L < l; ) (T[I + L] = 1), (L += 1);
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
p = -1;
|
|
342
|
-
let N = [],
|
|
343
|
-
O = 1,
|
|
344
|
-
P = l + u;
|
|
345
|
-
const qe = 1 << (l - 1);
|
|
346
|
-
for (let x = 0; x < l; x += 1) {
|
|
347
|
-
let L = 0,
|
|
348
|
-
b = P;
|
|
349
|
-
for (; L < b; )
|
|
350
|
-
v(e, {
|
|
351
|
-
errors: x,
|
|
352
|
-
currentLocation: d + b,
|
|
353
|
-
expectedLocation: d,
|
|
354
|
-
distance: n,
|
|
355
|
-
ignoreLocation: h,
|
|
356
|
-
}) <= g
|
|
357
|
-
? (L = b)
|
|
358
|
-
: (P = b),
|
|
359
|
-
(b = Math.floor((P - L) / 2 + L));
|
|
360
|
-
P = b;
|
|
361
|
-
let ue = Math.max(1, d - b + 1),
|
|
362
|
-
U = c ? u : Math.min(d + b, u) + l,
|
|
363
|
-
C = Array(U + 2);
|
|
364
|
-
C[U + 1] = (1 << x) - 1;
|
|
365
|
-
for (let S = U; S >= ue; S -= 1) {
|
|
366
|
-
let j = S - 1,
|
|
367
|
-
fe = t[s.charAt(j)];
|
|
368
|
-
if (
|
|
369
|
-
(y && (T[j] = +!!fe),
|
|
370
|
-
(C[S] = ((C[S + 1] << 1) | 1) & fe),
|
|
371
|
-
x && (C[S] |= ((N[S + 1] | N[S]) << 1) | 1 | N[S + 1]),
|
|
372
|
-
C[S] & qe &&
|
|
373
|
-
((O = v(e, {
|
|
374
|
-
errors: x,
|
|
375
|
-
currentLocation: j,
|
|
376
|
-
expectedLocation: d,
|
|
377
|
-
distance: n,
|
|
378
|
-
ignoreLocation: h,
|
|
379
|
-
})),
|
|
380
|
-
O <= g))
|
|
381
|
-
) {
|
|
382
|
-
if (((g = O), (p = j), p <= d)) break;
|
|
383
|
-
ue = Math.max(1, 2 * d - p);
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
if (
|
|
387
|
-
v(e, {
|
|
388
|
-
errors: x + 1,
|
|
389
|
-
currentLocation: d,
|
|
390
|
-
expectedLocation: d,
|
|
391
|
-
distance: n,
|
|
392
|
-
ignoreLocation: h,
|
|
393
|
-
}) > g
|
|
394
|
-
)
|
|
395
|
-
break;
|
|
396
|
-
N = C;
|
|
397
|
-
}
|
|
398
|
-
const G = { isMatch: p >= 0, score: Math.max(0.001, O) };
|
|
399
|
-
if (y) {
|
|
400
|
-
const x = be(T, o);
|
|
401
|
-
x.length ? a && (G.indices = x) : (G.isMatch = !1);
|
|
402
|
-
}
|
|
403
|
-
return G;
|
|
404
|
-
}
|
|
405
|
-
function ke(s) {
|
|
406
|
-
let e = {};
|
|
407
|
-
for (let t = 0, r = s.length; t < r; t += 1) {
|
|
408
|
-
const n = s.charAt(t);
|
|
409
|
-
e[n] = (e[n] || 0) | (1 << (r - t - 1));
|
|
410
|
-
}
|
|
411
|
-
return e;
|
|
412
|
-
}
|
|
413
|
-
class se {
|
|
414
|
-
constructor(
|
|
415
|
-
e,
|
|
416
|
-
{
|
|
417
|
-
location: t = f.location,
|
|
418
|
-
threshold: r = f.threshold,
|
|
419
|
-
distance: n = f.distance,
|
|
420
|
-
includeMatches: i = f.includeMatches,
|
|
421
|
-
findAllMatches: c = f.findAllMatches,
|
|
422
|
-
minMatchCharLength: o = f.minMatchCharLength,
|
|
423
|
-
isCaseSensitive: a = f.isCaseSensitive,
|
|
424
|
-
ignoreLocation: h = f.ignoreLocation,
|
|
425
|
-
} = {}
|
|
426
|
-
) {
|
|
427
|
-
if (
|
|
428
|
-
((this.options = {
|
|
429
|
-
location: t,
|
|
430
|
-
threshold: r,
|
|
431
|
-
distance: n,
|
|
432
|
-
includeMatches: i,
|
|
433
|
-
findAllMatches: c,
|
|
434
|
-
minMatchCharLength: o,
|
|
435
|
-
isCaseSensitive: a,
|
|
436
|
-
ignoreLocation: h,
|
|
437
|
-
}),
|
|
438
|
-
(this.pattern = a ? e : e.toLowerCase()),
|
|
439
|
-
(this.chunks = []),
|
|
440
|
-
!this.pattern.length)
|
|
441
|
-
)
|
|
442
|
-
return;
|
|
443
|
-
const l = (d, g) => {
|
|
444
|
-
this.chunks.push({ pattern: d, alphabet: ke(d), startIndex: g });
|
|
445
|
-
},
|
|
446
|
-
u = this.pattern.length;
|
|
447
|
-
if (u > k) {
|
|
448
|
-
let d = 0;
|
|
449
|
-
const g = u % k,
|
|
450
|
-
p = u - g;
|
|
451
|
-
for (; d < p; ) l(this.pattern.substr(d, k), d), (d += k);
|
|
452
|
-
if (g) {
|
|
453
|
-
const y = u - k;
|
|
454
|
-
l(this.pattern.substr(y), y);
|
|
455
|
-
}
|
|
456
|
-
} else l(this.pattern, 0);
|
|
457
|
-
}
|
|
458
|
-
searchIn(e) {
|
|
459
|
-
const { isCaseSensitive: t, includeMatches: r } = this.options;
|
|
460
|
-
if ((t || (e = e.toLowerCase()), this.pattern === e)) {
|
|
461
|
-
let p = { isMatch: !0, score: 0 };
|
|
462
|
-
return r && (p.indices = [[0, e.length - 1]]), p;
|
|
463
|
-
}
|
|
464
|
-
const {
|
|
465
|
-
location: n,
|
|
466
|
-
distance: i,
|
|
467
|
-
threshold: c,
|
|
468
|
-
findAllMatches: o,
|
|
469
|
-
minMatchCharLength: a,
|
|
470
|
-
ignoreLocation: h,
|
|
471
|
-
} = this.options;
|
|
472
|
-
let l = [],
|
|
473
|
-
u = 0,
|
|
474
|
-
d = !1;
|
|
475
|
-
this.chunks.forEach(({ pattern: p, alphabet: y, startIndex: T }) => {
|
|
476
|
-
const {
|
|
477
|
-
isMatch: I,
|
|
478
|
-
score: N,
|
|
479
|
-
indices: O,
|
|
480
|
-
} = Re(e, p, y, {
|
|
481
|
-
location: n + T,
|
|
482
|
-
distance: i,
|
|
483
|
-
threshold: c,
|
|
484
|
-
findAllMatches: o,
|
|
485
|
-
minMatchCharLength: a,
|
|
486
|
-
includeMatches: r,
|
|
487
|
-
ignoreLocation: h,
|
|
488
|
-
});
|
|
489
|
-
I && (d = !0), (u += N), I && O && (l = [...l, ...O]);
|
|
490
|
-
});
|
|
491
|
-
let g = { isMatch: d, score: d ? u / this.chunks.length : 1 };
|
|
492
|
-
return d && r && (g.indices = l), g;
|
|
493
|
-
}
|
|
494
|
-
}
|
|
495
|
-
class w {
|
|
496
|
-
constructor(e) {
|
|
497
|
-
this.pattern = e;
|
|
498
|
-
}
|
|
499
|
-
static isMultiMatch(e) {
|
|
500
|
-
return ne(e, this.multiRegex);
|
|
501
|
-
}
|
|
502
|
-
static isSingleMatch(e) {
|
|
503
|
-
return ne(e, this.singleRegex);
|
|
504
|
-
}
|
|
505
|
-
search() {}
|
|
506
|
-
}
|
|
507
|
-
function ne(s, e) {
|
|
508
|
-
const t = s.match(e);
|
|
509
|
-
return t ? t[1] : null;
|
|
510
|
-
}
|
|
511
|
-
class Te extends w {
|
|
512
|
-
constructor(e) {
|
|
513
|
-
super(e);
|
|
514
|
-
}
|
|
515
|
-
static get type() {
|
|
516
|
-
return "exact";
|
|
517
|
-
}
|
|
518
|
-
static get multiRegex() {
|
|
519
|
-
return /^="(.*)"$/;
|
|
520
|
-
}
|
|
521
|
-
static get singleRegex() {
|
|
522
|
-
return /^=(.*)$/;
|
|
523
|
-
}
|
|
524
|
-
search(e) {
|
|
525
|
-
const t = e === this.pattern;
|
|
526
|
-
return {
|
|
527
|
-
isMatch: t,
|
|
528
|
-
score: t ? 0 : 1,
|
|
529
|
-
indices: [0, this.pattern.length - 1],
|
|
530
|
-
};
|
|
531
|
-
}
|
|
532
|
-
}
|
|
533
|
-
class Oe extends w {
|
|
534
|
-
constructor(e) {
|
|
535
|
-
super(e);
|
|
536
|
-
}
|
|
537
|
-
static get type() {
|
|
538
|
-
return "inverse-exact";
|
|
539
|
-
}
|
|
540
|
-
static get multiRegex() {
|
|
541
|
-
return /^!"(.*)"$/;
|
|
542
|
-
}
|
|
543
|
-
static get singleRegex() {
|
|
544
|
-
return /^!(.*)$/;
|
|
545
|
-
}
|
|
546
|
-
search(e) {
|
|
547
|
-
const r = e.indexOf(this.pattern) === -1;
|
|
548
|
-
return { isMatch: r, score: r ? 0 : 1, indices: [0, e.length - 1] };
|
|
549
|
-
}
|
|
550
|
-
}
|
|
551
|
-
class $e extends w {
|
|
552
|
-
constructor(e) {
|
|
553
|
-
super(e);
|
|
554
|
-
}
|
|
555
|
-
static get type() {
|
|
556
|
-
return "prefix-exact";
|
|
557
|
-
}
|
|
558
|
-
static get multiRegex() {
|
|
559
|
-
return /^\^"(.*)"$/;
|
|
560
|
-
}
|
|
561
|
-
static get singleRegex() {
|
|
562
|
-
return /^\^(.*)$/;
|
|
563
|
-
}
|
|
564
|
-
search(e) {
|
|
565
|
-
const t = e.startsWith(this.pattern);
|
|
566
|
-
return {
|
|
567
|
-
isMatch: t,
|
|
568
|
-
score: t ? 0 : 1,
|
|
569
|
-
indices: [0, this.pattern.length - 1],
|
|
570
|
-
};
|
|
571
|
-
}
|
|
572
|
-
}
|
|
573
|
-
class Ne extends w {
|
|
574
|
-
constructor(e) {
|
|
575
|
-
super(e);
|
|
576
|
-
}
|
|
577
|
-
static get type() {
|
|
578
|
-
return "inverse-prefix-exact";
|
|
579
|
-
}
|
|
580
|
-
static get multiRegex() {
|
|
581
|
-
return /^!\^"(.*)"$/;
|
|
582
|
-
}
|
|
583
|
-
static get singleRegex() {
|
|
584
|
-
return /^!\^(.*)$/;
|
|
585
|
-
}
|
|
586
|
-
search(e) {
|
|
587
|
-
const t = !e.startsWith(this.pattern);
|
|
588
|
-
return { isMatch: t, score: t ? 0 : 1, indices: [0, e.length - 1] };
|
|
589
|
-
}
|
|
590
|
-
}
|
|
591
|
-
class Ce extends w {
|
|
592
|
-
constructor(e) {
|
|
593
|
-
super(e);
|
|
594
|
-
}
|
|
595
|
-
static get type() {
|
|
596
|
-
return "suffix-exact";
|
|
597
|
-
}
|
|
598
|
-
static get multiRegex() {
|
|
599
|
-
return /^"(.*)"\$$/;
|
|
600
|
-
}
|
|
601
|
-
static get singleRegex() {
|
|
602
|
-
return /^(.*)\$$/;
|
|
603
|
-
}
|
|
604
|
-
search(e) {
|
|
605
|
-
const t = e.endsWith(this.pattern);
|
|
606
|
-
return {
|
|
607
|
-
isMatch: t,
|
|
608
|
-
score: t ? 0 : 1,
|
|
609
|
-
indices: [e.length - this.pattern.length, e.length - 1],
|
|
610
|
-
};
|
|
611
|
-
}
|
|
612
|
-
}
|
|
613
|
-
class ve extends w {
|
|
614
|
-
constructor(e) {
|
|
615
|
-
super(e);
|
|
616
|
-
}
|
|
617
|
-
static get type() {
|
|
618
|
-
return "inverse-suffix-exact";
|
|
619
|
-
}
|
|
620
|
-
static get multiRegex() {
|
|
621
|
-
return /^!"(.*)"\$$/;
|
|
622
|
-
}
|
|
623
|
-
static get singleRegex() {
|
|
624
|
-
return /^!(.*)\$$/;
|
|
625
|
-
}
|
|
626
|
-
search(e) {
|
|
627
|
-
const t = !e.endsWith(this.pattern);
|
|
628
|
-
return { isMatch: t, score: t ? 0 : 1, indices: [0, e.length - 1] };
|
|
629
|
-
}
|
|
630
|
-
}
|
|
631
|
-
class re extends w {
|
|
632
|
-
constructor(
|
|
633
|
-
e,
|
|
634
|
-
{
|
|
635
|
-
location: t = f.location,
|
|
636
|
-
threshold: r = f.threshold,
|
|
637
|
-
distance: n = f.distance,
|
|
638
|
-
includeMatches: i = f.includeMatches,
|
|
639
|
-
findAllMatches: c = f.findAllMatches,
|
|
640
|
-
minMatchCharLength: o = f.minMatchCharLength,
|
|
641
|
-
isCaseSensitive: a = f.isCaseSensitive,
|
|
642
|
-
ignoreLocation: h = f.ignoreLocation,
|
|
643
|
-
} = {}
|
|
644
|
-
) {
|
|
645
|
-
super(e),
|
|
646
|
-
(this._bitapSearch = new se(e, {
|
|
647
|
-
location: t,
|
|
648
|
-
threshold: r,
|
|
649
|
-
distance: n,
|
|
650
|
-
includeMatches: i,
|
|
651
|
-
findAllMatches: c,
|
|
652
|
-
minMatchCharLength: o,
|
|
653
|
-
isCaseSensitive: a,
|
|
654
|
-
ignoreLocation: h,
|
|
655
|
-
}));
|
|
656
|
-
}
|
|
657
|
-
static get type() {
|
|
658
|
-
return "fuzzy";
|
|
659
|
-
}
|
|
660
|
-
static get multiRegex() {
|
|
661
|
-
return /^"(.*)"$/;
|
|
662
|
-
}
|
|
663
|
-
static get singleRegex() {
|
|
664
|
-
return /^(.*)$/;
|
|
665
|
-
}
|
|
666
|
-
search(e) {
|
|
667
|
-
return this._bitapSearch.searchIn(e);
|
|
668
|
-
}
|
|
669
|
-
}
|
|
670
|
-
class ie extends w {
|
|
671
|
-
constructor(e) {
|
|
672
|
-
super(e);
|
|
673
|
-
}
|
|
674
|
-
static get type() {
|
|
675
|
-
return "include";
|
|
676
|
-
}
|
|
677
|
-
static get multiRegex() {
|
|
678
|
-
return /^'"(.*)"$/;
|
|
679
|
-
}
|
|
680
|
-
static get singleRegex() {
|
|
681
|
-
return /^'(.*)$/;
|
|
682
|
-
}
|
|
683
|
-
search(e) {
|
|
684
|
-
let t = 0,
|
|
685
|
-
r;
|
|
686
|
-
const n = [],
|
|
687
|
-
i = this.pattern.length;
|
|
688
|
-
for (; (r = e.indexOf(this.pattern, t)) > -1; )
|
|
689
|
-
(t = r + i), n.push([r, t - 1]);
|
|
690
|
-
const c = !!n.length;
|
|
691
|
-
return { isMatch: c, score: c ? 0 : 1, indices: n };
|
|
692
|
-
}
|
|
693
|
-
}
|
|
694
|
-
const D = [Te, ie, $e, Ne, ve, Ce, Oe, re],
|
|
695
|
-
ce = D.length,
|
|
696
|
-
Fe = / +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,
|
|
697
|
-
Pe = "|";
|
|
698
|
-
function je(s, e = {}) {
|
|
699
|
-
return s.split(Pe).map((t) => {
|
|
700
|
-
let r = t
|
|
701
|
-
.trim()
|
|
702
|
-
.split(Fe)
|
|
703
|
-
.filter((i) => i && !!i.trim()),
|
|
704
|
-
n = [];
|
|
705
|
-
for (let i = 0, c = r.length; i < c; i += 1) {
|
|
706
|
-
const o = r[i];
|
|
707
|
-
let a = !1,
|
|
708
|
-
h = -1;
|
|
709
|
-
for (; !a && ++h < ce; ) {
|
|
710
|
-
const l = D[h];
|
|
711
|
-
let u = l.isMultiMatch(o);
|
|
712
|
-
u && (n.push(new l(u, e)), (a = !0));
|
|
713
|
-
}
|
|
714
|
-
if (!a)
|
|
715
|
-
for (h = -1; ++h < ce; ) {
|
|
716
|
-
const l = D[h];
|
|
717
|
-
let u = l.isSingleMatch(o);
|
|
718
|
-
if (u) {
|
|
719
|
-
n.push(new l(u, e));
|
|
720
|
-
break;
|
|
721
|
-
}
|
|
722
|
-
}
|
|
723
|
-
}
|
|
724
|
-
return n;
|
|
725
|
-
});
|
|
726
|
-
}
|
|
727
|
-
const He = new Set([re.type, ie.type]);
|
|
728
|
-
class Be {
|
|
729
|
-
constructor(
|
|
730
|
-
e,
|
|
731
|
-
{
|
|
732
|
-
isCaseSensitive: t = f.isCaseSensitive,
|
|
733
|
-
includeMatches: r = f.includeMatches,
|
|
734
|
-
minMatchCharLength: n = f.minMatchCharLength,
|
|
735
|
-
ignoreLocation: i = f.ignoreLocation,
|
|
736
|
-
findAllMatches: c = f.findAllMatches,
|
|
737
|
-
location: o = f.location,
|
|
738
|
-
threshold: a = f.threshold,
|
|
739
|
-
distance: h = f.distance,
|
|
740
|
-
} = {}
|
|
741
|
-
) {
|
|
742
|
-
(this.query = null),
|
|
743
|
-
(this.options = {
|
|
744
|
-
isCaseSensitive: t,
|
|
745
|
-
includeMatches: r,
|
|
746
|
-
minMatchCharLength: n,
|
|
747
|
-
findAllMatches: c,
|
|
748
|
-
ignoreLocation: i,
|
|
749
|
-
location: o,
|
|
750
|
-
threshold: a,
|
|
751
|
-
distance: h,
|
|
752
|
-
}),
|
|
753
|
-
(this.pattern = t ? e : e.toLowerCase()),
|
|
754
|
-
(this.query = je(this.pattern, this.options));
|
|
755
|
-
}
|
|
756
|
-
static condition(e, t) {
|
|
757
|
-
return t.useExtendedSearch;
|
|
758
|
-
}
|
|
759
|
-
searchIn(e) {
|
|
760
|
-
const t = this.query;
|
|
761
|
-
if (!t) return { isMatch: !1, score: 1 };
|
|
762
|
-
const { includeMatches: r, isCaseSensitive: n } = this.options;
|
|
763
|
-
e = n ? e : e.toLowerCase();
|
|
764
|
-
let i = 0,
|
|
765
|
-
c = [],
|
|
766
|
-
o = 0;
|
|
767
|
-
for (let a = 0, h = t.length; a < h; a += 1) {
|
|
768
|
-
const l = t[a];
|
|
769
|
-
(c.length = 0), (i = 0);
|
|
770
|
-
for (let u = 0, d = l.length; u < d; u += 1) {
|
|
771
|
-
const g = l[u],
|
|
772
|
-
{ isMatch: p, indices: y, score: T } = g.search(e);
|
|
773
|
-
if (p) {
|
|
774
|
-
if (((i += 1), (o += T), r)) {
|
|
775
|
-
const I = g.constructor.type;
|
|
776
|
-
He.has(I) ? (c = [...c, ...y]) : c.push(y);
|
|
777
|
-
}
|
|
778
|
-
} else {
|
|
779
|
-
(o = 0), (i = 0), (c.length = 0);
|
|
780
|
-
break;
|
|
781
|
-
}
|
|
782
|
-
}
|
|
783
|
-
if (i) {
|
|
784
|
-
let u = { isMatch: !0, score: o / i };
|
|
785
|
-
return r && (u.indices = c), u;
|
|
786
|
-
}
|
|
787
|
-
}
|
|
788
|
-
return { isMatch: !1, score: 1 };
|
|
789
|
-
}
|
|
790
|
-
}
|
|
791
|
-
const W = [];
|
|
792
|
-
function Ke(...s) {
|
|
793
|
-
W.push(...s);
|
|
794
|
-
}
|
|
795
|
-
function z(s, e) {
|
|
796
|
-
for (let t = 0, r = W.length; t < r; t += 1) {
|
|
797
|
-
let n = W[t];
|
|
798
|
-
if (n.condition(s, e)) return new n(s, e);
|
|
799
|
-
}
|
|
800
|
-
return new se(s, e);
|
|
801
|
-
}
|
|
802
|
-
const F = { AND: "$and", OR: "$or" },
|
|
803
|
-
V = { PATH: "$path", PATTERN: "$val" },
|
|
804
|
-
Y = (s) => !!(s[F.AND] || s[F.OR]),
|
|
805
|
-
De = (s) => !!s[V.PATH],
|
|
806
|
-
We = (s) => !m(s) && X(s) && !Y(s),
|
|
807
|
-
oe = (s) => ({ [F.AND]: Object.keys(s).map((e) => ({ [e]: s[e] })) });
|
|
808
|
-
function ae(s, e, { auto: t = !0 } = {}) {
|
|
809
|
-
const r = (n) => {
|
|
810
|
-
let i = Object.keys(n);
|
|
811
|
-
const c = De(n);
|
|
812
|
-
if (!c && i.length > 1 && !Y(n)) return r(oe(n));
|
|
813
|
-
if (We(n)) {
|
|
814
|
-
const a = c ? n[V.PATH] : i[0],
|
|
815
|
-
h = c ? n[V.PATTERN] : n[a];
|
|
816
|
-
if (!A(h)) throw new Error(Me(a));
|
|
817
|
-
const l = { keyId: B(a), pattern: h };
|
|
818
|
-
return t && (l.searcher = z(h, e)), l;
|
|
819
|
-
}
|
|
820
|
-
let o = { children: [], operator: i[0] };
|
|
821
|
-
return (
|
|
822
|
-
i.forEach((a) => {
|
|
823
|
-
const h = n[a];
|
|
824
|
-
m(h) &&
|
|
825
|
-
h.forEach((l) => {
|
|
826
|
-
o.children.push(r(l));
|
|
827
|
-
});
|
|
828
|
-
}),
|
|
829
|
-
o
|
|
830
|
-
);
|
|
831
|
-
};
|
|
832
|
-
return Y(s) || (s = oe(s)), r(s);
|
|
833
|
-
}
|
|
834
|
-
function ze(s, { ignoreFieldNorm: e = f.ignoreFieldNorm }) {
|
|
835
|
-
s.forEach((t) => {
|
|
836
|
-
let r = 1;
|
|
837
|
-
t.matches.forEach(({ key: n, norm: i, score: c }) => {
|
|
838
|
-
const o = n ? n.weight : null;
|
|
839
|
-
r *= Math.pow(
|
|
840
|
-
c === 0 && o ? Number.EPSILON : c,
|
|
841
|
-
(o || 1) * (e ? 1 : i)
|
|
842
|
-
);
|
|
843
|
-
}),
|
|
844
|
-
(t.score = r);
|
|
845
|
-
});
|
|
846
|
-
}
|
|
847
|
-
function Ve(s, e) {
|
|
848
|
-
const t = s.matches;
|
|
849
|
-
(e.matches = []),
|
|
850
|
-
M(t) &&
|
|
851
|
-
t.forEach((r) => {
|
|
852
|
-
if (!M(r.indices) || !r.indices.length) return;
|
|
853
|
-
const { indices: n, value: i } = r;
|
|
854
|
-
let c = { indices: n, value: i };
|
|
855
|
-
r.key && (c.key = r.key.src),
|
|
856
|
-
r.idx > -1 && (c.refIndex = r.idx),
|
|
857
|
-
e.matches.push(c);
|
|
858
|
-
});
|
|
859
|
-
}
|
|
860
|
-
function Ye(s, e) {
|
|
861
|
-
e.score = s.score;
|
|
862
|
-
}
|
|
863
|
-
function Ge(
|
|
864
|
-
s,
|
|
865
|
-
e,
|
|
866
|
-
{
|
|
867
|
-
includeMatches: t = f.includeMatches,
|
|
868
|
-
includeScore: r = f.includeScore,
|
|
869
|
-
} = {}
|
|
870
|
-
) {
|
|
871
|
-
const n = [];
|
|
872
|
-
return (
|
|
873
|
-
t && n.push(Ve),
|
|
874
|
-
r && n.push(Ye),
|
|
875
|
-
s.map((i) => {
|
|
876
|
-
const { idx: c } = i,
|
|
877
|
-
o = { item: e[c], refIndex: c };
|
|
878
|
-
return (
|
|
879
|
-
n.length &&
|
|
880
|
-
n.forEach((a) => {
|
|
881
|
-
a(i, o);
|
|
882
|
-
}),
|
|
883
|
-
o
|
|
884
|
-
);
|
|
885
|
-
})
|
|
886
|
-
);
|
|
887
|
-
}
|
|
888
|
-
class $ {
|
|
889
|
-
constructor(e, t = {}, r) {
|
|
890
|
-
(this.options = { ...f, ...t }),
|
|
891
|
-
this.options.useExtendedSearch,
|
|
892
|
-
(this._keyStore = new Ae(this.options.keys)),
|
|
893
|
-
this.setCollection(e, r);
|
|
894
|
-
}
|
|
895
|
-
setCollection(e, t) {
|
|
896
|
-
if (((this._docs = e), t && !(t instanceof K))) throw new Error(ye);
|
|
897
|
-
this._myIndex =
|
|
898
|
-
t ||
|
|
899
|
-
te(this.options.keys, this._docs, {
|
|
900
|
-
getFn: this.options.getFn,
|
|
901
|
-
fieldNormWeight: this.options.fieldNormWeight,
|
|
902
|
-
});
|
|
903
|
-
}
|
|
904
|
-
add(e) {
|
|
905
|
-
M(e) && (this._docs.push(e), this._myIndex.add(e));
|
|
906
|
-
}
|
|
907
|
-
remove(e = () => !1) {
|
|
908
|
-
const t = [];
|
|
909
|
-
for (let r = 0, n = this._docs.length; r < n; r += 1) {
|
|
910
|
-
const i = this._docs[r];
|
|
911
|
-
e(i, r) && (this.removeAt(r), (r -= 1), (n -= 1), t.push(i));
|
|
912
|
-
}
|
|
913
|
-
return t;
|
|
914
|
-
}
|
|
915
|
-
removeAt(e) {
|
|
916
|
-
this._docs.splice(e, 1), this._myIndex.removeAt(e);
|
|
917
|
-
}
|
|
918
|
-
getIndex() {
|
|
919
|
-
return this._myIndex;
|
|
920
|
-
}
|
|
921
|
-
search(e, { limit: t = -1 } = {}) {
|
|
922
|
-
const {
|
|
923
|
-
includeMatches: r,
|
|
924
|
-
includeScore: n,
|
|
925
|
-
shouldSort: i,
|
|
926
|
-
sortFn: c,
|
|
927
|
-
ignoreFieldNorm: o,
|
|
928
|
-
} = this.options;
|
|
929
|
-
let a = A(e)
|
|
930
|
-
? A(this._docs[0])
|
|
931
|
-
? this._searchStringList(e)
|
|
932
|
-
: this._searchObjectList(e)
|
|
933
|
-
: this._searchLogical(e);
|
|
934
|
-
return (
|
|
935
|
-
ze(a, { ignoreFieldNorm: o }),
|
|
936
|
-
i && a.sort(c),
|
|
937
|
-
Q(t) && t > -1 && (a = a.slice(0, t)),
|
|
938
|
-
Ge(a, this._docs, { includeMatches: r, includeScore: n })
|
|
939
|
-
);
|
|
940
|
-
}
|
|
941
|
-
_searchStringList(e) {
|
|
942
|
-
const t = z(e, this.options),
|
|
943
|
-
{ records: r } = this._myIndex,
|
|
944
|
-
n = [];
|
|
945
|
-
return (
|
|
946
|
-
r.forEach(({ v: i, i: c, n: o }) => {
|
|
947
|
-
if (!M(i)) return;
|
|
948
|
-
const { isMatch: a, score: h, indices: l } = t.searchIn(i);
|
|
949
|
-
a &&
|
|
950
|
-
n.push({
|
|
951
|
-
item: i,
|
|
952
|
-
idx: c,
|
|
953
|
-
matches: [{ score: h, value: i, norm: o, indices: l }],
|
|
954
|
-
});
|
|
955
|
-
}),
|
|
956
|
-
n
|
|
957
|
-
);
|
|
958
|
-
}
|
|
959
|
-
_searchLogical(e) {
|
|
960
|
-
const t = ae(e, this.options),
|
|
961
|
-
r = (o, a, h) => {
|
|
962
|
-
if (!o.children) {
|
|
963
|
-
const { keyId: u, searcher: d } = o,
|
|
964
|
-
g = this._findMatches({
|
|
965
|
-
key: this._keyStore.get(u),
|
|
966
|
-
value: this._myIndex.getValueForItemAtKeyId(a, u),
|
|
967
|
-
searcher: d,
|
|
968
|
-
});
|
|
969
|
-
return g && g.length ? [{ idx: h, item: a, matches: g }] : [];
|
|
970
|
-
}
|
|
971
|
-
const l = [];
|
|
972
|
-
for (let u = 0, d = o.children.length; u < d; u += 1) {
|
|
973
|
-
const g = o.children[u],
|
|
974
|
-
p = r(g, a, h);
|
|
975
|
-
if (p.length) l.push(...p);
|
|
976
|
-
else if (o.operator === F.AND) return [];
|
|
977
|
-
}
|
|
978
|
-
return l;
|
|
979
|
-
},
|
|
980
|
-
n = this._myIndex.records,
|
|
981
|
-
i = {},
|
|
982
|
-
c = [];
|
|
983
|
-
return (
|
|
984
|
-
n.forEach(({ $: o, i: a }) => {
|
|
985
|
-
if (M(o)) {
|
|
986
|
-
let h = r(t, o, a);
|
|
987
|
-
h.length &&
|
|
988
|
-
(i[a] ||
|
|
989
|
-
((i[a] = { idx: a, item: o, matches: [] }), c.push(i[a])),
|
|
990
|
-
h.forEach(({ matches: l }) => {
|
|
991
|
-
i[a].matches.push(...l);
|
|
992
|
-
}));
|
|
993
|
-
}
|
|
994
|
-
}),
|
|
995
|
-
c
|
|
996
|
-
);
|
|
997
|
-
}
|
|
998
|
-
_searchObjectList(e) {
|
|
999
|
-
const t = z(e, this.options),
|
|
1000
|
-
{ keys: r, records: n } = this._myIndex,
|
|
1001
|
-
i = [];
|
|
1002
|
-
return (
|
|
1003
|
-
n.forEach(({ $: c, i: o }) => {
|
|
1004
|
-
if (!M(c)) return;
|
|
1005
|
-
let a = [];
|
|
1006
|
-
r.forEach((h, l) => {
|
|
1007
|
-
a.push(...this._findMatches({ key: h, value: c[l], searcher: t }));
|
|
1008
|
-
}),
|
|
1009
|
-
a.length && i.push({ idx: o, item: c, matches: a });
|
|
1010
|
-
}),
|
|
1011
|
-
i
|
|
1012
|
-
);
|
|
1013
|
-
}
|
|
1014
|
-
_findMatches({ key: e, value: t, searcher: r }) {
|
|
1015
|
-
if (!M(t)) return [];
|
|
1016
|
-
let n = [];
|
|
1017
|
-
if (m(t))
|
|
1018
|
-
t.forEach(({ v: i, i: c, n: o }) => {
|
|
1019
|
-
if (!M(i)) return;
|
|
1020
|
-
const { isMatch: a, score: h, indices: l } = r.searchIn(i);
|
|
1021
|
-
a &&
|
|
1022
|
-
n.push({ score: h, key: e, value: i, idx: c, norm: o, indices: l });
|
|
1023
|
-
});
|
|
1024
|
-
else {
|
|
1025
|
-
const { v: i, n: c } = t,
|
|
1026
|
-
{ isMatch: o, score: a, indices: h } = r.searchIn(i);
|
|
1027
|
-
o && n.push({ score: a, key: e, value: i, norm: c, indices: h });
|
|
1028
|
-
}
|
|
1029
|
-
return n;
|
|
1030
|
-
}
|
|
1031
|
-
}
|
|
1032
|
-
($.version = "6.6.2"),
|
|
1033
|
-
($.createIndex = te),
|
|
1034
|
-
($.parseIndex = Le),
|
|
1035
|
-
($.config = f),
|
|
1036
|
-
($.parseQuery = ae),
|
|
1037
|
-
Ke(Be);
|
|
1038
|
-
const Ue = `
|
|
1
|
+
(function(M,m){typeof exports=="object"&&typeof module<"u"?m(exports):typeof define=="function"&&define.amd?define(["exports"],m):(M=typeof globalThis<"u"?globalThis:M||self,m(M["eox-itemfilter"]={}))})(this,function(M){"use strict";var Ze=Object.defineProperty;var et=(M,m,b)=>m in M?Ze(M,m,{enumerable:!0,configurable:!0,writable:!0,value:b}):M[m]=b;var A=(M,m,b)=>(et(M,typeof m!="symbol"?m+"":m,b),b);function m(t){return Array.isArray?Array.isArray(t):J(t)==="[object Array]"}const b=1/0;function de(t){if(typeof t=="string")return t;let e=t+"";return e=="0"&&1/t==-b?"-0":e}function ge(t){return t==null?"":de(t)}function I(t){return typeof t=="string"}function Q(t){return typeof t=="number"}function pe(t){return t===!0||t===!1||me(t)&&J(t)=="[object Boolean]"}function X(t){return typeof t=="object"}function me(t){return X(t)&&t!==null}function y(t){return t!=null}function H(t){return!t.trim().length}function J(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const tt="Extended search is not available",ye="Incorrect 'index' type",Me=t=>`Invalid value for key ${t}`,Ee=t=>`Pattern length exceeds max of ${t}.`,xe=t=>`Missing ${t} property in key`,Se=t=>`Property 'weight' in key '${t}' must be a positive integer`,q=Object.prototype.hasOwnProperty;class Ie{constructor(e){this._keys=[],this._keyMap={};let s=0;e.forEach(r=>{let n=Z(r);s+=n.weight,this._keys.push(n),this._keyMap[n.id]=n,s+=n.weight}),this._keys.forEach(r=>{r.weight/=s})}get(e){return this._keyMap[e]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function Z(t){let e=null,s=null,r=null,n=1,i=null;if(I(t)||m(t))r=t,e=ee(t),s=B(t);else{if(!q.call(t,"name"))throw new Error(xe("name"));const c=t.name;if(r=c,q.call(t,"weight")&&(n=t.weight,n<=0))throw new Error(Se(c));e=ee(c),s=B(c),i=t.getFn}return{path:e,id:s,weight:n,src:r,getFn:i}}function ee(t){return m(t)?t:t.split(".")}function B(t){return m(t)?t.join("."):t}function Ae(t,e){let s=[],r=!1;const n=(i,c,o)=>{if(y(i))if(!c[o])s.push(i);else{let a=c[o];const h=i[a];if(!y(h))return;if(o===c.length-1&&(I(h)||Q(h)||pe(h)))s.push(ge(h));else if(m(h)){r=!0;for(let l=0,u=h.length;l<u;l+=1)n(h[l],c,o+1)}else c.length&&n(h,c,o+1)}};return n(t,I(e)?e.split("."):e,0),r?s:s[0]}var f={...{isCaseSensitive:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(t,e)=>t.score===e.score?t.idx<e.idx?-1:1:t.score<e.score?-1:1},...{includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},...{location:0,threshold:.6,distance:100},...{useExtendedSearch:!1,getFn:Ae,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1}};const _e=/[^ ]+/g;function we(t=1,e=3){const s=new Map,r=Math.pow(10,e);return{get(n){const i=n.match(_e).length;if(s.has(i))return s.get(i);const c=1/Math.pow(i,.5*t),o=parseFloat(Math.round(c*r)/r);return s.set(i,o),o},clear(){s.clear()}}}class K{constructor({getFn:e=f.getFn,fieldNormWeight:s=f.fieldNormWeight}={}){this.norm=we(s,3),this.getFn=e,this.isCreated=!1,this.setIndexRecords()}setSources(e=[]){this.docs=e}setIndexRecords(e=[]){this.records=e}setKeys(e=[]){this.keys=e,this._keysMap={},e.forEach((s,r)=>{this._keysMap[s.id]=r})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,I(this.docs[0])?this.docs.forEach((e,s)=>{this._addString(e,s)}):this.docs.forEach((e,s)=>{this._addObject(e,s)}),this.norm.clear())}add(e){const s=this.size();I(e)?this._addString(e,s):this._addObject(e,s)}removeAt(e){this.records.splice(e,1);for(let s=e,r=this.size();s<r;s+=1)this.records[s].i-=1}getValueForItemAtKeyId(e,s){return e[this._keysMap[s]]}size(){return this.records.length}_addString(e,s){if(!y(e)||H(e))return;let r={v:e,i:s,n:this.norm.get(e)};this.records.push(r)}_addObject(e,s){let r={i:s,$:{}};this.keys.forEach((n,i)=>{let c=n.getFn?n.getFn(e):this.getFn(e,n.path);if(y(c)){if(m(c)){let o=[];const a=[{nestedArrIndex:-1,value:c}];for(;a.length;){const{nestedArrIndex:h,value:l}=a.pop();if(y(l))if(I(l)&&!H(l)){let u={v:l,i:h,n:this.norm.get(l)};o.push(u)}else m(l)&&l.forEach((u,d)=>{a.push({nestedArrIndex:d,value:u})})}r.$[i]=o}else if(I(c)&&!H(c)){let o={v:c,n:this.norm.get(c)};r.$[i]=o}}}),this.records.push(r)}toJSON(){return{keys:this.keys,records:this.records}}}function te(t,e,{getFn:s=f.getFn,fieldNormWeight:r=f.fieldNormWeight}={}){const n=new K({getFn:s,fieldNormWeight:r});return n.setKeys(t.map(Z)),n.setSources(e),n.create(),n}function Le(t,{getFn:e=f.getFn,fieldNormWeight:s=f.fieldNormWeight}={}){const{keys:r,records:n}=t,i=new K({getFn:e,fieldNormWeight:s});return i.setKeys(r),i.setIndexRecords(n),i}function v(t,{errors:e=0,currentLocation:s=0,expectedLocation:r=0,distance:n=f.distance,ignoreLocation:i=f.ignoreLocation}={}){const c=e/t.length;if(i)return c;const o=Math.abs(r-s);return n?c+o/n:o?1:c}function Re(t=[],e=f.minMatchCharLength){let s=[],r=-1,n=-1,i=0;for(let c=t.length;i<c;i+=1){let o=t[i];o&&r===-1?r=i:!o&&r!==-1&&(n=i-1,n-r+1>=e&&s.push([r,n]),r=-1)}return t[i-1]&&i-r>=e&&s.push([r,i-1]),s}const k=32;function be(t,e,s,{location:r=f.location,distance:n=f.distance,threshold:i=f.threshold,findAllMatches:c=f.findAllMatches,minMatchCharLength:o=f.minMatchCharLength,includeMatches:a=f.includeMatches,ignoreLocation:h=f.ignoreLocation}={}){if(e.length>k)throw new Error(Ee(k));const l=e.length,u=t.length,d=Math.max(0,Math.min(r,u));let g=i,p=d;const E=o>1||a,T=E?Array(u):[];let _;for(;(_=t.indexOf(e,p))>-1;){let x=v(e,{currentLocation:_,expectedLocation:d,distance:n,ignoreLocation:h});if(g=Math.min(x,g),p=_+l,E){let L=0;for(;L<l;)T[_+L]=1,L+=1}}p=-1;let N=[],O=1,P=l+u;const qe=1<<l-1;for(let x=0;x<l;x+=1){let L=0,R=P;for(;L<R;)v(e,{errors:x,currentLocation:d+R,expectedLocation:d,distance:n,ignoreLocation:h})<=g?L=R:P=R,R=Math.floor((P-L)/2+L);P=R;let ue=Math.max(1,d-R+1),U=c?u:Math.min(d+R,u)+l,C=Array(U+2);C[U+1]=(1<<x)-1;for(let S=U;S>=ue;S-=1){let j=S-1,fe=s[t.charAt(j)];if(E&&(T[j]=+!!fe),C[S]=(C[S+1]<<1|1)&fe,x&&(C[S]|=(N[S+1]|N[S])<<1|1|N[S+1]),C[S]&qe&&(O=v(e,{errors:x,currentLocation:j,expectedLocation:d,distance:n,ignoreLocation:h}),O<=g)){if(g=O,p=j,p<=d)break;ue=Math.max(1,2*d-p)}}if(v(e,{errors:x+1,currentLocation:d,expectedLocation:d,distance:n,ignoreLocation:h})>g)break;N=C}const G={isMatch:p>=0,score:Math.max(.001,O)};if(E){const x=Re(T,o);x.length?a&&(G.indices=x):G.isMatch=!1}return G}function ke(t){let e={};for(let s=0,r=t.length;s<r;s+=1){const n=t.charAt(s);e[n]=(e[n]||0)|1<<r-s-1}return e}class se{constructor(e,{location:s=f.location,threshold:r=f.threshold,distance:n=f.distance,includeMatches:i=f.includeMatches,findAllMatches:c=f.findAllMatches,minMatchCharLength:o=f.minMatchCharLength,isCaseSensitive:a=f.isCaseSensitive,ignoreLocation:h=f.ignoreLocation}={}){if(this.options={location:s,threshold:r,distance:n,includeMatches:i,findAllMatches:c,minMatchCharLength:o,isCaseSensitive:a,ignoreLocation:h},this.pattern=a?e:e.toLowerCase(),this.chunks=[],!this.pattern.length)return;const l=(d,g)=>{this.chunks.push({pattern:d,alphabet:ke(d),startIndex:g})},u=this.pattern.length;if(u>k){let d=0;const g=u%k,p=u-g;for(;d<p;)l(this.pattern.substr(d,k),d),d+=k;if(g){const E=u-k;l(this.pattern.substr(E),E)}}else l(this.pattern,0)}searchIn(e){const{isCaseSensitive:s,includeMatches:r}=this.options;if(s||(e=e.toLowerCase()),this.pattern===e){let p={isMatch:!0,score:0};return r&&(p.indices=[[0,e.length-1]]),p}const{location:n,distance:i,threshold:c,findAllMatches:o,minMatchCharLength:a,ignoreLocation:h}=this.options;let l=[],u=0,d=!1;this.chunks.forEach(({pattern:p,alphabet:E,startIndex:T})=>{const{isMatch:_,score:N,indices:O}=be(e,p,E,{location:n+T,distance:i,threshold:c,findAllMatches:o,minMatchCharLength:a,includeMatches:r,ignoreLocation:h});_&&(d=!0),u+=N,_&&O&&(l=[...l,...O])});let g={isMatch:d,score:d?u/this.chunks.length:1};return d&&r&&(g.indices=l),g}}class w{constructor(e){this.pattern=e}static isMultiMatch(e){return ne(e,this.multiRegex)}static isSingleMatch(e){return ne(e,this.singleRegex)}search(){}}function ne(t,e){const s=t.match(e);return s?s[1]:null}class Te extends w{constructor(e){super(e)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(e){const s=e===this.pattern;return{isMatch:s,score:s?0:1,indices:[0,this.pattern.length-1]}}}class Oe extends w{constructor(e){super(e)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(e){const r=e.indexOf(this.pattern)===-1;return{isMatch:r,score:r?0:1,indices:[0,e.length-1]}}}class $e extends w{constructor(e){super(e)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(e){const s=e.startsWith(this.pattern);return{isMatch:s,score:s?0:1,indices:[0,this.pattern.length-1]}}}class Ne extends w{constructor(e){super(e)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(e){const s=!e.startsWith(this.pattern);return{isMatch:s,score:s?0:1,indices:[0,e.length-1]}}}class Ce extends w{constructor(e){super(e)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(e){const s=e.endsWith(this.pattern);return{isMatch:s,score:s?0:1,indices:[e.length-this.pattern.length,e.length-1]}}}class ve extends w{constructor(e){super(e)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(e){const s=!e.endsWith(this.pattern);return{isMatch:s,score:s?0:1,indices:[0,e.length-1]}}}class re extends w{constructor(e,{location:s=f.location,threshold:r=f.threshold,distance:n=f.distance,includeMatches:i=f.includeMatches,findAllMatches:c=f.findAllMatches,minMatchCharLength:o=f.minMatchCharLength,isCaseSensitive:a=f.isCaseSensitive,ignoreLocation:h=f.ignoreLocation}={}){super(e),this._bitapSearch=new se(e,{location:s,threshold:r,distance:n,includeMatches:i,findAllMatches:c,minMatchCharLength:o,isCaseSensitive:a,ignoreLocation:h})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(e){return this._bitapSearch.searchIn(e)}}class ie extends w{constructor(e){super(e)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(e){let s=0,r;const n=[],i=this.pattern.length;for(;(r=e.indexOf(this.pattern,s))>-1;)s=r+i,n.push([r,s-1]);const c=!!n.length;return{isMatch:c,score:c?0:1,indices:n}}}const D=[Te,ie,$e,Ne,ve,Ce,Oe,re],ce=D.length,Fe=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,Pe="|";function je(t,e={}){return t.split(Pe).map(s=>{let r=s.trim().split(Fe).filter(i=>i&&!!i.trim()),n=[];for(let i=0,c=r.length;i<c;i+=1){const o=r[i];let a=!1,h=-1;for(;!a&&++h<ce;){const l=D[h];let u=l.isMultiMatch(o);u&&(n.push(new l(u,e)),a=!0)}if(!a)for(h=-1;++h<ce;){const l=D[h];let u=l.isSingleMatch(o);if(u){n.push(new l(u,e));break}}}return n})}const He=new Set([re.type,ie.type]);class Be{constructor(e,{isCaseSensitive:s=f.isCaseSensitive,includeMatches:r=f.includeMatches,minMatchCharLength:n=f.minMatchCharLength,ignoreLocation:i=f.ignoreLocation,findAllMatches:c=f.findAllMatches,location:o=f.location,threshold:a=f.threshold,distance:h=f.distance}={}){this.query=null,this.options={isCaseSensitive:s,includeMatches:r,minMatchCharLength:n,findAllMatches:c,ignoreLocation:i,location:o,threshold:a,distance:h},this.pattern=s?e:e.toLowerCase(),this.query=je(this.pattern,this.options)}static condition(e,s){return s.useExtendedSearch}searchIn(e){const s=this.query;if(!s)return{isMatch:!1,score:1};const{includeMatches:r,isCaseSensitive:n}=this.options;e=n?e:e.toLowerCase();let i=0,c=[],o=0;for(let a=0,h=s.length;a<h;a+=1){const l=s[a];c.length=0,i=0;for(let u=0,d=l.length;u<d;u+=1){const g=l[u],{isMatch:p,indices:E,score:T}=g.search(e);if(p){if(i+=1,o+=T,r){const _=g.constructor.type;He.has(_)?c=[...c,...E]:c.push(E)}}else{o=0,i=0,c.length=0;break}}if(i){let u={isMatch:!0,score:o/i};return r&&(u.indices=c),u}}return{isMatch:!1,score:1}}}const W=[];function Ke(...t){W.push(...t)}function z(t,e){for(let s=0,r=W.length;s<r;s+=1){let n=W[s];if(n.condition(t,e))return new n(t,e)}return new se(t,e)}const F={AND:"$and",OR:"$or"},V={PATH:"$path",PATTERN:"$val"},Y=t=>!!(t[F.AND]||t[F.OR]),De=t=>!!t[V.PATH],We=t=>!m(t)&&X(t)&&!Y(t),oe=t=>({[F.AND]:Object.keys(t).map(e=>({[e]:t[e]}))});function ae(t,e,{auto:s=!0}={}){const r=n=>{let i=Object.keys(n);const c=De(n);if(!c&&i.length>1&&!Y(n))return r(oe(n));if(We(n)){const a=c?n[V.PATH]:i[0],h=c?n[V.PATTERN]:n[a];if(!I(h))throw new Error(Me(a));const l={keyId:B(a),pattern:h};return s&&(l.searcher=z(h,e)),l}let o={children:[],operator:i[0]};return i.forEach(a=>{const h=n[a];m(h)&&h.forEach(l=>{o.children.push(r(l))})}),o};return Y(t)||(t=oe(t)),r(t)}function ze(t,{ignoreFieldNorm:e=f.ignoreFieldNorm}){t.forEach(s=>{let r=1;s.matches.forEach(({key:n,norm:i,score:c})=>{const o=n?n.weight:null;r*=Math.pow(c===0&&o?Number.EPSILON:c,(o||1)*(e?1:i))}),s.score=r})}function Ve(t,e){const s=t.matches;e.matches=[],y(s)&&s.forEach(r=>{if(!y(r.indices)||!r.indices.length)return;const{indices:n,value:i}=r;let c={indices:n,value:i};r.key&&(c.key=r.key.src),r.idx>-1&&(c.refIndex=r.idx),e.matches.push(c)})}function Ye(t,e){e.score=t.score}function Ge(t,e,{includeMatches:s=f.includeMatches,includeScore:r=f.includeScore}={}){const n=[];return s&&n.push(Ve),r&&n.push(Ye),t.map(i=>{const{idx:c}=i,o={item:e[c],refIndex:c};return n.length&&n.forEach(a=>{a(i,o)}),o})}class ${constructor(e,s={},r){this.options={...f,...s},this.options.useExtendedSearch,this._keyStore=new Ie(this.options.keys),this.setCollection(e,r)}setCollection(e,s){if(this._docs=e,s&&!(s instanceof K))throw new Error(ye);this._myIndex=s||te(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(e){y(e)&&(this._docs.push(e),this._myIndex.add(e))}remove(e=()=>!1){const s=[];for(let r=0,n=this._docs.length;r<n;r+=1){const i=this._docs[r];e(i,r)&&(this.removeAt(r),r-=1,n-=1,s.push(i))}return s}removeAt(e){this._docs.splice(e,1),this._myIndex.removeAt(e)}getIndex(){return this._myIndex}search(e,{limit:s=-1}={}){const{includeMatches:r,includeScore:n,shouldSort:i,sortFn:c,ignoreFieldNorm:o}=this.options;let a=I(e)?I(this._docs[0])?this._searchStringList(e):this._searchObjectList(e):this._searchLogical(e);return ze(a,{ignoreFieldNorm:o}),i&&a.sort(c),Q(s)&&s>-1&&(a=a.slice(0,s)),Ge(a,this._docs,{includeMatches:r,includeScore:n})}_searchStringList(e){const s=z(e,this.options),{records:r}=this._myIndex,n=[];return r.forEach(({v:i,i:c,n:o})=>{if(!y(i))return;const{isMatch:a,score:h,indices:l}=s.searchIn(i);a&&n.push({item:i,idx:c,matches:[{score:h,value:i,norm:o,indices:l}]})}),n}_searchLogical(e){const s=ae(e,this.options),r=(o,a,h)=>{if(!o.children){const{keyId:u,searcher:d}=o,g=this._findMatches({key:this._keyStore.get(u),value:this._myIndex.getValueForItemAtKeyId(a,u),searcher:d});return g&&g.length?[{idx:h,item:a,matches:g}]:[]}const l=[];for(let u=0,d=o.children.length;u<d;u+=1){const g=o.children[u],p=r(g,a,h);if(p.length)l.push(...p);else if(o.operator===F.AND)return[]}return l},n=this._myIndex.records,i={},c=[];return n.forEach(({$:o,i:a})=>{if(y(o)){let h=r(s,o,a);h.length&&(i[a]||(i[a]={idx:a,item:o,matches:[]},c.push(i[a])),h.forEach(({matches:l})=>{i[a].matches.push(...l)}))}}),c}_searchObjectList(e){const s=z(e,this.options),{keys:r,records:n}=this._myIndex,i=[];return n.forEach(({$:c,i:o})=>{if(!y(c))return;let a=[];r.forEach((h,l)=>{a.push(...this._findMatches({key:h,value:c[l],searcher:s}))}),a.length&&i.push({idx:o,item:c,matches:a})}),i}_findMatches({key:e,value:s,searcher:r}){if(!y(s))return[];let n=[];if(m(s))s.forEach(({v:i,i:c,n:o})=>{if(!y(i))return;const{isMatch:a,score:h,indices:l}=r.searchIn(i);a&&n.push({score:h,key:e,value:i,idx:c,norm:o,indices:l})});else{const{v:i,n:c}=s,{isMatch:o,score:a,indices:h}=r.searchIn(i);o&&n.push({score:a,key:e,value:i,norm:c,indices:h})}return n}}$.version="6.6.2",$.createIndex=te,$.parseIndex=Le,$.config=f,$.parseQuery=ae,Ke(Be);const Ue=`
|
|
1039
2
|
<style>
|
|
1040
3
|
:host {
|
|
1041
4
|
display: block;
|
|
@@ -1047,187 +10,16 @@
|
|
|
1047
10
|
<input type="text" />
|
|
1048
11
|
<ul id="results"></ul>
|
|
1049
12
|
</div>
|
|
1050
|
-
`,
|
|
1051
|
-
Qe = `
|
|
13
|
+
`,Qe=`
|
|
1052
14
|
<li>
|
|
1053
15
|
<label>
|
|
1054
16
|
<input type="checkbox" />
|
|
1055
17
|
<span class="title">FILTERITEMTITLE</span>
|
|
1056
18
|
</label>
|
|
1057
19
|
</li>
|
|
1058
|
-
`,
|
|
1059
|
-
Xe = `
|
|
20
|
+
`,Xe=`
|
|
1060
21
|
<details open>
|
|
1061
22
|
<summary>TITLE</summar>
|
|
1062
23
|
<ul></ul>
|
|
1063
24
|
</details>
|
|
1064
|
-
`,
|
|
1065
|
-
Je = (s, e = "highlight") => {
|
|
1066
|
-
const t = (n, i, c) => {
|
|
1067
|
-
const o = i.split(".");
|
|
1068
|
-
let a;
|
|
1069
|
-
for (a = 0; a < o.length - 1; a++) n = n[o[a]];
|
|
1070
|
-
n[o[a]] = c;
|
|
1071
|
-
},
|
|
1072
|
-
r = (n, i = []) => {
|
|
1073
|
-
let c = "",
|
|
1074
|
-
o = 0;
|
|
1075
|
-
return (
|
|
1076
|
-
i.forEach((a) => {
|
|
1077
|
-
const h = a[1] + 1;
|
|
1078
|
-
(c += [
|
|
1079
|
-
n.substring(o, a[0]),
|
|
1080
|
-
`<mark class="${e}">`,
|
|
1081
|
-
n.substring(a[0], h),
|
|
1082
|
-
"</mark>",
|
|
1083
|
-
].join("")),
|
|
1084
|
-
(o = h);
|
|
1085
|
-
}),
|
|
1086
|
-
(c += n.substring(o)),
|
|
1087
|
-
c
|
|
1088
|
-
);
|
|
1089
|
-
};
|
|
1090
|
-
return s
|
|
1091
|
-
.filter(({ matches: n }) => n && n.length)
|
|
1092
|
-
.map(({ item: n, matches: i }) => {
|
|
1093
|
-
const c = { ...n };
|
|
1094
|
-
return (
|
|
1095
|
-
i.forEach((o) => {
|
|
1096
|
-
o.key === "name" && t(c, o.key, r(o.value, o.indices));
|
|
1097
|
-
}),
|
|
1098
|
-
c
|
|
1099
|
-
);
|
|
1100
|
-
});
|
|
1101
|
-
},
|
|
1102
|
-
he = document.createElement("template");
|
|
1103
|
-
he.innerHTML = Ue;
|
|
1104
|
-
class le extends HTMLElement {
|
|
1105
|
-
constructor() {
|
|
1106
|
-
super();
|
|
1107
|
-
_(this, "shadowRoot");
|
|
1108
|
-
_(this, "apply");
|
|
1109
|
-
_(this, "filterProperties");
|
|
1110
|
-
_(this, "items");
|
|
1111
|
-
_(this, "fuse");
|
|
1112
|
-
_(this, "filters");
|
|
1113
|
-
_(this, "aggregateBy");
|
|
1114
|
-
_(this, "fuseConfig");
|
|
1115
|
-
this.filters = {};
|
|
1116
|
-
const t = this.getAttribute("aggregateResults") || !1;
|
|
1117
|
-
(this.shadowRoot = this.attachShadow({ mode: "open" })),
|
|
1118
|
-
this.shadowRoot.appendChild(he.content.cloneNode(!0)),
|
|
1119
|
-
(this.apply = (i) => {
|
|
1120
|
-
(this.items = i),
|
|
1121
|
-
(this.fuse = new $(this.items, {
|
|
1122
|
-
minMatchCharLength: 1,
|
|
1123
|
-
includeMatches: !0,
|
|
1124
|
-
keys: ["name", ...this.filterProperties],
|
|
1125
|
-
useExtendedSearch: !0,
|
|
1126
|
-
...this.fuseConfig,
|
|
1127
|
-
})),
|
|
1128
|
-
this.filterProperties.forEach((c) => {
|
|
1129
|
-
const o = [
|
|
1130
|
-
...new Set(this.items.reduce((h, l) => h.concat(l[c]), [])),
|
|
1131
|
-
].sort(),
|
|
1132
|
-
a = this.shadowRoot.querySelector("ul#filters");
|
|
1133
|
-
o.forEach((h) => {
|
|
1134
|
-
const l = document.createElement("template");
|
|
1135
|
-
l.innerHTML = Qe;
|
|
1136
|
-
const u = l.content.cloneNode(!0);
|
|
1137
|
-
u
|
|
1138
|
-
.querySelector("input[type='checkbox']")
|
|
1139
|
-
.setAttribute("data-filter-key", c),
|
|
1140
|
-
u
|
|
1141
|
-
.querySelector("input[type='checkbox']")
|
|
1142
|
-
.setAttribute("data-filter-value", h),
|
|
1143
|
-
(u.querySelector("span.title").innerHTML = h),
|
|
1144
|
-
a.appendChild(u);
|
|
1145
|
-
}),
|
|
1146
|
-
t === c && (this.aggregateBy = o);
|
|
1147
|
-
}),
|
|
1148
|
-
r();
|
|
1149
|
-
});
|
|
1150
|
-
const r = () => {
|
|
1151
|
-
this.shadowRoot
|
|
1152
|
-
.querySelectorAll("input[type='checkbox']")
|
|
1153
|
-
.forEach((i) => {
|
|
1154
|
-
i.addEventListener("click", (c) => {
|
|
1155
|
-
const o = c.target,
|
|
1156
|
-
a = o.getAttribute("data-filter-key"),
|
|
1157
|
-
h = o.getAttribute("data-filter-value");
|
|
1158
|
-
o.checked
|
|
1159
|
-
? (this.filters[a] || (this.filters[a] = []),
|
|
1160
|
-
this.filters[a].push(h))
|
|
1161
|
-
: (this.filters[a].splice(this.filters[a].indexOf(h), 1),
|
|
1162
|
-
this.filters[a].length === 0 && delete this.filters[a]),
|
|
1163
|
-
n(this.shadowRoot.querySelector("input[type='text']").value);
|
|
1164
|
-
});
|
|
1165
|
-
});
|
|
1166
|
-
},
|
|
1167
|
-
n = (i, c = this.filters) => {
|
|
1168
|
-
const o = Object.entries(c).reduce((l, [u, d]) => {
|
|
1169
|
-
const g = (p) => {
|
|
1170
|
-
const y = {};
|
|
1171
|
-
(y[u] = `=${p}`), l.push(y);
|
|
1172
|
-
};
|
|
1173
|
-
return Array.isArray(d) ? d.forEach((p) => g(p)) : g(d), l;
|
|
1174
|
-
}, []),
|
|
1175
|
-
a = Je(
|
|
1176
|
-
this.fuse.search({
|
|
1177
|
-
...(i.length && Object.keys(o).length
|
|
1178
|
-
? { $and: [{ name: i }, { $or: o }] }
|
|
1179
|
-
: { $or: [{ name: i }, { $or: o }] }),
|
|
1180
|
-
})
|
|
1181
|
-
),
|
|
1182
|
-
h = this.shadowRoot.querySelector("ul#results");
|
|
1183
|
-
if (((h.innerHTML = ""), t)) {
|
|
1184
|
-
const l = document.createElement("template");
|
|
1185
|
-
(l.innerHTML = Xe),
|
|
1186
|
-
this.aggregateBy.forEach((u) => {
|
|
1187
|
-
if (
|
|
1188
|
-
!a.find((g) =>
|
|
1189
|
-
Array.isArray(g[t]) ? g[t].includes(u) : g[t] === u
|
|
1190
|
-
)
|
|
1191
|
-
)
|
|
1192
|
-
return;
|
|
1193
|
-
const d = l.content.cloneNode(!0);
|
|
1194
|
-
(d.querySelector("summary").innerHTML = u),
|
|
1195
|
-
d.querySelector("details").setAttribute("data-aggregate", u),
|
|
1196
|
-
h.appendChild(d);
|
|
1197
|
-
});
|
|
1198
|
-
}
|
|
1199
|
-
a.forEach((l) => {
|
|
1200
|
-
if (this.aggregateBy) {
|
|
1201
|
-
const u = l[t];
|
|
1202
|
-
if (Array.isArray(u))
|
|
1203
|
-
u.forEach((d) => {
|
|
1204
|
-
const g = document.createElement("li");
|
|
1205
|
-
(g.innerHTML = l.name),
|
|
1206
|
-
this.shadowRoot
|
|
1207
|
-
.querySelector(`details[data-aggregate=${d}]`)
|
|
1208
|
-
.appendChild(g);
|
|
1209
|
-
});
|
|
1210
|
-
else {
|
|
1211
|
-
const d = document.createElement("li");
|
|
1212
|
-
(d.innerHTML = l.name),
|
|
1213
|
-
this.shadowRoot
|
|
1214
|
-
.querySelector(`details[data-aggregate=${u}]`)
|
|
1215
|
-
.appendChild(d);
|
|
1216
|
-
}
|
|
1217
|
-
} else {
|
|
1218
|
-
const u = document.createElement("li");
|
|
1219
|
-
(u.innerHTML = l.name), h.appendChild(u);
|
|
1220
|
-
}
|
|
1221
|
-
});
|
|
1222
|
-
};
|
|
1223
|
-
this.shadowRoot
|
|
1224
|
-
.querySelector("input[type='text']")
|
|
1225
|
-
.addEventListener("input", (i) => {
|
|
1226
|
-
n(i.target.value);
|
|
1227
|
-
});
|
|
1228
|
-
}
|
|
1229
|
-
}
|
|
1230
|
-
customElements.define("eox-itemfilter", le),
|
|
1231
|
-
(E.EOxItemFilter = le),
|
|
1232
|
-
Object.defineProperty(E, Symbol.toStringTag, { value: "Module" });
|
|
1233
|
-
});
|
|
25
|
+
`,Je=(t,e="highlight")=>{const s=(n,i,c)=>{const o=i.split(".");let a;for(a=0;a<o.length-1;a++)n=n[o[a]];n[o[a]]=c},r=(n,i=[])=>{let c="",o=0;return i.forEach(a=>{const h=a[1]+1;c+=[n.substring(o,a[0]),`<mark class="${e}">`,n.substring(a[0],h),"</mark>"].join(""),o=h}),c+=n.substring(o),c};return t.filter(({matches:n})=>n&&n.length).map(({item:n,matches:i})=>{const c={...n};return i.forEach(o=>{o.key==="name"&&s(c,o.key,r(o.value,o.indices))}),c})},he=document.createElement("template");he.innerHTML=Ue;class le extends HTMLElement{constructor(){super();A(this,"shadowRoot");A(this,"apply");A(this,"filterProperties");A(this,"items");A(this,"fuse");A(this,"filters");A(this,"aggregateBy");A(this,"aggregateResults");A(this,"fuseConfig");this.filters={},this.shadowRoot=this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(he.content.cloneNode(!0)),this.apply=n=>{this.items=n,this.fuse=new $(this.items,{minMatchCharLength:1,includeMatches:!0,keys:["name",...this.filterProperties],useExtendedSearch:!0,...this.fuseConfig}),this.filterProperties.forEach(i=>{const c=[...new Set(this.items.reduce((a,h)=>a.concat(h[i]),[]))].sort(),o=this.shadowRoot.querySelector("ul#filters");c.forEach(a=>{const h=document.createElement("template");h.innerHTML=Qe;const l=h.content.cloneNode(!0);l.querySelector("input[type='checkbox']").setAttribute("data-filter-key",i),l.querySelector("input[type='checkbox']").setAttribute("data-filter-value",a),l.querySelector("span.title").innerHTML=a,o.appendChild(l)}),this.aggregateResults===i&&(this.aggregateBy=c)}),s()};const s=()=>{this.shadowRoot.querySelectorAll("input[type='checkbox']").forEach(n=>{n.addEventListener("click",i=>{const c=i.target,o=c.getAttribute("data-filter-key"),a=c.getAttribute("data-filter-value");c.checked?(this.filters[o]||(this.filters[o]=[]),this.filters[o].push(a)):(this.filters[o].splice(this.filters[o].indexOf(a),1),this.filters[o].length===0&&delete this.filters[o]),r(this.shadowRoot.querySelector("input[type='text']").value)})})},r=(n,i=this.filters)=>{const c=Object.entries(i).reduce((h,[l,u])=>{const d=g=>{const p={};p[l]=`=${g}`,h.push(p)};return Array.isArray(u)?u.forEach(g=>d(g)):d(u),h},[]),o=Je(this.fuse.search({...n.length&&Object.keys(c).length?{$and:[{name:n},{$or:c}]}:{$or:[{name:n},{$or:c}]}})),a=this.shadowRoot.querySelector("ul#results");if(a.innerHTML="",this.aggregateResults){const h=document.createElement("template");h.innerHTML=Xe,this.aggregateBy.forEach(l=>{if(!o.find(d=>Array.isArray(d[this.aggregateResults])?d[this.aggregateResults].includes(l):d[this.aggregateResults]===l))return;const u=h.content.cloneNode(!0);u.querySelector("summary").innerHTML=l,u.querySelector("details").setAttribute("data-aggregate",l),a.appendChild(u)})}o.forEach(h=>{if(this.aggregateBy){const l=h[this.aggregateResults];if(Array.isArray(l))l.forEach(u=>{const d=document.createElement("li");d.innerHTML=h.name,this.shadowRoot.querySelector(`details[data-aggregate=${u}]`).appendChild(d)});else{const u=document.createElement("li");u.innerHTML=h.name,this.shadowRoot.querySelector(`details[data-aggregate=${l}]`).appendChild(u)}}else{const l=document.createElement("li");l.innerHTML=h.name,a.appendChild(l)}})};this.shadowRoot.querySelector("input[type='text']").addEventListener("input",n=>{r(n.target.value)})}}customElements.define("eox-itemfilter",le),M.EOxItemFilter=le,Object.defineProperty(M,Symbol.toStringTag,{value:"Module"})});
|