@eox/itemfilter 0.0.2 → 0.1.0

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.
@@ -1,57 +1,57 @@
1
- var ut = Object.defineProperty;
2
- var ft = (e, t, s) => t in e ? ut(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s;
3
- var x = (e, t, s) => (ft(e, typeof t != "symbol" ? t + "" : t, s), s);
4
- function A(e) {
5
- return Array.isArray ? Array.isArray(e) : st(e) === "[object Array]";
1
+ var he = Object.defineProperty;
2
+ var ue = (s, e, t) => e in s ? he(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
3
+ var b = (s, e, t) => (ue(s, typeof e != "symbol" ? e + "" : e, t), t);
4
+ function L(s) {
5
+ return Array.isArray ? Array.isArray(s) : se(s) === "[object Array]";
6
6
  }
7
- const dt = 1 / 0;
8
- function gt(e) {
9
- if (typeof e == "string")
10
- return e;
11
- let t = e + "";
12
- return t == "0" && 1 / e == -dt ? "-0" : t;
7
+ const fe = 1 / 0;
8
+ function de(s) {
9
+ if (typeof s == "string")
10
+ return s;
11
+ let e = s + "";
12
+ return e == "0" && 1 / s == -fe ? "-0" : e;
13
13
  }
14
- function pt(e) {
15
- return e == null ? "" : gt(e);
14
+ function ge(s) {
15
+ return s == null ? "" : de(s);
16
16
  }
17
- function S(e) {
18
- return typeof e == "string";
17
+ function w(s) {
18
+ return typeof s == "string";
19
19
  }
20
- function tt(e) {
21
- return typeof e == "number";
20
+ function ee(s) {
21
+ return typeof s == "number";
22
22
  }
23
- function mt(e) {
24
- return e === !0 || e === !1 || yt(e) && st(e) == "[object Boolean]";
23
+ function pe(s) {
24
+ return s === !0 || s === !1 || me(s) && se(s) == "[object Boolean]";
25
25
  }
26
- function et(e) {
27
- return typeof e == "object";
26
+ function te(s) {
27
+ return typeof s == "object";
28
28
  }
29
- function yt(e) {
30
- return et(e) && e !== null;
29
+ function me(s) {
30
+ return te(s) && s !== null;
31
31
  }
32
- function m(e) {
33
- return e != null;
32
+ function y(s) {
33
+ return s != null;
34
34
  }
35
- function H(e) {
36
- return !e.trim().length;
35
+ function P(s) {
36
+ return !s.trim().length;
37
37
  }
38
- function st(e) {
39
- return e == null ? e === void 0 ? "[object Undefined]" : "[object Null]" : Object.prototype.toString.call(e);
38
+ function se(s) {
39
+ return s == null ? s === void 0 ? "[object Undefined]" : "[object Null]" : Object.prototype.toString.call(s);
40
40
  }
41
- const Mt = "Incorrect 'index' type", Et = (e) => `Invalid value for key ${e}`, xt = (e) => `Pattern length exceeds max of ${e}.`, St = (e) => `Missing ${e} property in key`, It = (e) => `Property 'weight' in key '${e}' must be a positive integer`, Q = Object.prototype.hasOwnProperty;
42
- class At {
43
- constructor(t) {
41
+ const ye = "Incorrect 'index' type", xe = (s) => `Invalid value for key ${s}`, Me = (s) => `Pattern length exceeds max of ${s}.`, Ee = (s) => `Missing ${s} property in key`, we = (s) => `Property 'weight' in key '${s}' must be a positive integer`, G = Object.prototype.hasOwnProperty;
42
+ class Se {
43
+ constructor(e) {
44
44
  this._keys = [], this._keyMap = {};
45
- let s = 0;
46
- t.forEach((n) => {
47
- let r = rt(n);
48
- s += r.weight, this._keys.push(r), this._keyMap[r.id] = r, s += r.weight;
49
- }), this._keys.forEach((n) => {
50
- n.weight /= s;
45
+ let t = 0;
46
+ e.forEach((r) => {
47
+ let i = ie(r);
48
+ t += i.weight, this._keys.push(i), this._keyMap[i.id] = i, t += i.weight;
49
+ }), this._keys.forEach((r) => {
50
+ r.weight /= t;
51
51
  });
52
52
  }
53
- get(t) {
54
- return this._keyMap[t];
53
+ get(e) {
54
+ return this._keyMap[e];
55
55
  }
56
56
  keys() {
57
57
  return this._keys;
@@ -60,50 +60,50 @@ class At {
60
60
  return JSON.stringify(this._keys);
61
61
  }
62
62
  }
63
- function rt(e) {
64
- let t = null, s = null, n = null, r = 1, i = null;
65
- if (S(e) || A(e))
66
- n = e, t = X(e), s = K(e);
63
+ function ie(s) {
64
+ let e = null, t = null, r = null, i = 1, c = null;
65
+ if (w(s) || L(s))
66
+ r = s, e = Q(s), t = B(s);
67
67
  else {
68
- if (!Q.call(e, "name"))
69
- throw new Error(St("name"));
70
- const c = e.name;
71
- if (n = c, Q.call(e, "weight") && (r = e.weight, r <= 0))
72
- throw new Error(It(c));
73
- t = X(c), s = K(c), i = e.getFn;
74
- }
75
- return { path: t, id: s, weight: r, src: n, getFn: i };
76
- }
77
- function X(e) {
78
- return A(e) ? e : e.split(".");
79
- }
80
- function K(e) {
81
- return A(e) ? e.join(".") : e;
82
- }
83
- function _t(e, t) {
84
- let s = [], n = !1;
85
- const r = (i, c, o) => {
86
- if (m(i))
87
- if (!c[o])
88
- s.push(i);
68
+ if (!G.call(s, "name"))
69
+ throw new Error(Ee("name"));
70
+ const n = s.name;
71
+ if (r = n, G.call(s, "weight") && (i = s.weight, i <= 0))
72
+ throw new Error(we(n));
73
+ e = Q(n), t = B(n), c = s.getFn;
74
+ }
75
+ return { path: e, id: t, weight: i, src: r, getFn: c };
76
+ }
77
+ function Q(s) {
78
+ return L(s) ? s : s.split(".");
79
+ }
80
+ function B(s) {
81
+ return L(s) ? s.join(".") : s;
82
+ }
83
+ function Le(s, e) {
84
+ let t = [], r = !1;
85
+ const i = (c, n, o) => {
86
+ if (y(c))
87
+ if (!n[o])
88
+ t.push(c);
89
89
  else {
90
- let a = c[o];
91
- const h = i[a];
92
- if (!m(h))
90
+ let l = n[o];
91
+ const a = c[l];
92
+ if (!y(a))
93
93
  return;
94
- if (o === c.length - 1 && (S(h) || tt(h) || mt(h)))
95
- s.push(pt(h));
96
- else if (A(h)) {
97
- n = !0;
98
- for (let l = 0, u = h.length; l < u; l += 1)
99
- r(h[l], c, o + 1);
94
+ if (o === n.length - 1 && (w(a) || ee(a) || pe(a)))
95
+ t.push(ge(a));
96
+ else if (L(a)) {
97
+ r = !0;
98
+ for (let h = 0, u = a.length; h < u; h += 1)
99
+ i(a[h], n, o + 1);
100
100
  } else
101
- c.length && r(h, c, o + 1);
101
+ n.length && i(a, n, o + 1);
102
102
  }
103
103
  };
104
- return r(e, S(t) ? t.split(".") : t, 0), n ? s : s[0];
104
+ return i(s, w(e) ? e.split(".") : e, 0), r ? t : t[0];
105
105
  }
106
- const wt = {
106
+ const Ae = {
107
107
  // Whether the matches should be included in the result set. When `true`, each record in the result
108
108
  // set will include the indices of the matched characters.
109
109
  // These can consequently be used for highlighting purposes.
@@ -113,7 +113,7 @@ const wt = {
113
113
  findAllMatches: !1,
114
114
  // Minimum number of characters that must be matched before a result is considered a match
115
115
  minMatchCharLength: 1
116
- }, Lt = {
116
+ }, Ie = {
117
117
  // When `true`, the algorithm continues searching to the end of the input even if a perfect
118
118
  // match is found before the end of the same input.
119
119
  isCaseSensitive: !1,
@@ -124,8 +124,8 @@ const wt = {
124
124
  // Whether to sort the result list, by score
125
125
  shouldSort: !0,
126
126
  // Default sort function: sort by ascending score, ascending index
127
- sortFn: (e, t) => e.score === t.score ? e.idx < t.idx ? -1 : 1 : e.score < t.score ? -1 : 1
128
- }, Rt = {
127
+ sortFn: (s, e) => s.score === e.score ? s.idx < e.idx ? -1 : 1 : s.score < e.score ? -1 : 1
128
+ }, be = {
129
129
  // Approximately where in the text is the pattern expected to be found?
130
130
  location: 0,
131
131
  // At what point does the match algorithm give up. A threshold of '0.0' requires a perfect match
@@ -137,12 +137,12 @@ const wt = {
137
137
  // the exact location specified, a threshold of '1000' would require a perfect match
138
138
  // to be within 800 characters of the fuzzy location to be found using a 0.8 threshold.
139
139
  distance: 100
140
- }, bt = {
140
+ }, _e = {
141
141
  // When `true`, it enables the use of unix-like search commands
142
142
  useExtendedSearch: !1,
143
143
  // The get function to use when fetching an object's properties.
144
144
  // The default will search nested paths *ie foo.bar.baz*
145
- getFn: _t,
145
+ getFn: Le,
146
146
  // When `true`, search will ignore `location` and `distance`, so it won't matter
147
147
  // where in the string the pattern appears.
148
148
  // More info: https://fusejs.io/concepts/scoring-theory.html#fuzziness-score
@@ -154,116 +154,116 @@ const wt = {
154
154
  // The weight to determine how much field length norm effects scoring.
155
155
  fieldNormWeight: 1
156
156
  };
157
- var f = {
158
- ...Lt,
159
- ...wt,
160
- ...Rt,
161
- ...bt
157
+ var d = {
158
+ ...Ie,
159
+ ...Ae,
160
+ ...be,
161
+ ..._e
162
162
  };
163
- const kt = /[^ ]+/g;
164
- function Tt(e = 1, t = 3) {
165
- const s = /* @__PURE__ */ new Map(), n = Math.pow(10, t);
163
+ const Re = /[^ ]+/g;
164
+ function ve(s = 1, e = 3) {
165
+ const t = /* @__PURE__ */ new Map(), r = Math.pow(10, e);
166
166
  return {
167
- get(r) {
168
- const i = r.match(kt).length;
169
- if (s.has(i))
170
- return s.get(i);
171
- const c = 1 / Math.pow(i, 0.5 * e), o = parseFloat(Math.round(c * n) / n);
172
- return s.set(i, o), o;
167
+ get(i) {
168
+ const c = i.match(Re).length;
169
+ if (t.has(c))
170
+ return t.get(c);
171
+ const n = 1 / Math.pow(c, 0.5 * s), o = parseFloat(Math.round(n * r) / r);
172
+ return t.set(c, o), o;
173
173
  },
174
174
  clear() {
175
- s.clear();
175
+ t.clear();
176
176
  }
177
177
  };
178
178
  }
179
- class Y {
179
+ class V {
180
180
  constructor({
181
- getFn: t = f.getFn,
182
- fieldNormWeight: s = f.fieldNormWeight
181
+ getFn: e = d.getFn,
182
+ fieldNormWeight: t = d.fieldNormWeight
183
183
  } = {}) {
184
- this.norm = Tt(s, 3), this.getFn = t, this.isCreated = !1, this.setIndexRecords();
184
+ this.norm = ve(t, 3), this.getFn = e, this.isCreated = !1, this.setIndexRecords();
185
185
  }
186
- setSources(t = []) {
187
- this.docs = t;
186
+ setSources(e = []) {
187
+ this.docs = e;
188
188
  }
189
- setIndexRecords(t = []) {
190
- this.records = t;
189
+ setIndexRecords(e = []) {
190
+ this.records = e;
191
191
  }
192
- setKeys(t = []) {
193
- this.keys = t, this._keysMap = {}, t.forEach((s, n) => {
194
- this._keysMap[s.id] = n;
192
+ setKeys(e = []) {
193
+ this.keys = e, this._keysMap = {}, e.forEach((t, r) => {
194
+ this._keysMap[t.id] = r;
195
195
  });
196
196
  }
197
197
  create() {
198
- this.isCreated || !this.docs.length || (this.isCreated = !0, S(this.docs[0]) ? this.docs.forEach((t, s) => {
199
- this._addString(t, s);
200
- }) : this.docs.forEach((t, s) => {
201
- this._addObject(t, s);
198
+ this.isCreated || !this.docs.length || (this.isCreated = !0, w(this.docs[0]) ? this.docs.forEach((e, t) => {
199
+ this._addString(e, t);
200
+ }) : this.docs.forEach((e, t) => {
201
+ this._addObject(e, t);
202
202
  }), this.norm.clear());
203
203
  }
204
204
  // Adds a doc to the end of the index
205
- add(t) {
206
- const s = this.size();
207
- S(t) ? this._addString(t, s) : this._addObject(t, s);
205
+ add(e) {
206
+ const t = this.size();
207
+ w(e) ? this._addString(e, t) : this._addObject(e, t);
208
208
  }
209
209
  // Removes the doc at the specified index of the index
210
- removeAt(t) {
211
- this.records.splice(t, 1);
212
- for (let s = t, n = this.size(); s < n; s += 1)
213
- this.records[s].i -= 1;
210
+ removeAt(e) {
211
+ this.records.splice(e, 1);
212
+ for (let t = e, r = this.size(); t < r; t += 1)
213
+ this.records[t].i -= 1;
214
214
  }
215
- getValueForItemAtKeyId(t, s) {
216
- return t[this._keysMap[s]];
215
+ getValueForItemAtKeyId(e, t) {
216
+ return e[this._keysMap[t]];
217
217
  }
218
218
  size() {
219
219
  return this.records.length;
220
220
  }
221
- _addString(t, s) {
222
- if (!m(t) || H(t))
221
+ _addString(e, t) {
222
+ if (!y(e) || P(e))
223
223
  return;
224
- let n = {
225
- v: t,
226
- i: s,
227
- n: this.norm.get(t)
224
+ let r = {
225
+ v: e,
226
+ i: t,
227
+ n: this.norm.get(e)
228
228
  };
229
- this.records.push(n);
230
- }
231
- _addObject(t, s) {
232
- let n = { i: s, $: {} };
233
- this.keys.forEach((r, i) => {
234
- let c = r.getFn ? r.getFn(t) : this.getFn(t, r.path);
235
- if (m(c)) {
236
- if (A(c)) {
229
+ this.records.push(r);
230
+ }
231
+ _addObject(e, t) {
232
+ let r = { i: t, $: {} };
233
+ this.keys.forEach((i, c) => {
234
+ let n = i.getFn ? i.getFn(e) : this.getFn(e, i.path);
235
+ if (y(n)) {
236
+ if (L(n)) {
237
237
  let o = [];
238
- const a = [{ nestedArrIndex: -1, value: c }];
239
- for (; a.length; ) {
240
- const { nestedArrIndex: h, value: l } = a.pop();
241
- if (m(l))
242
- if (S(l) && !H(l)) {
238
+ const l = [{ nestedArrIndex: -1, value: n }];
239
+ for (; l.length; ) {
240
+ const { nestedArrIndex: a, value: h } = l.pop();
241
+ if (y(h))
242
+ if (w(h) && !P(h)) {
243
243
  let u = {
244
- v: l,
245
- i: h,
246
- n: this.norm.get(l)
244
+ v: h,
245
+ i: a,
246
+ n: this.norm.get(h)
247
247
  };
248
248
  o.push(u);
249
249
  } else
250
- A(l) && l.forEach((u, d) => {
251
- a.push({
252
- nestedArrIndex: d,
250
+ L(h) && h.forEach((u, f) => {
251
+ l.push({
252
+ nestedArrIndex: f,
253
253
  value: u
254
254
  });
255
255
  });
256
256
  }
257
- n.$[i] = o;
258
- } else if (S(c) && !H(c)) {
257
+ r.$[c] = o;
258
+ } else if (w(n) && !P(n)) {
259
259
  let o = {
260
- v: c,
261
- n: this.norm.get(c)
260
+ v: n,
261
+ n: this.norm.get(n)
262
262
  };
263
- n.$[i] = o;
263
+ r.$[c] = o;
264
264
  }
265
265
  }
266
- }), this.records.push(n);
266
+ }), this.records.push(r);
267
267
  }
268
268
  toJSON() {
269
269
  return {
@@ -272,221 +272,221 @@ class Y {
272
272
  };
273
273
  }
274
274
  }
275
- function nt(e, t, { getFn: s = f.getFn, fieldNormWeight: n = f.fieldNormWeight } = {}) {
276
- const r = new Y({ getFn: s, fieldNormWeight: n });
277
- return r.setKeys(e.map(rt)), r.setSources(t), r.create(), r;
275
+ function re(s, e, { getFn: t = d.getFn, fieldNormWeight: r = d.fieldNormWeight } = {}) {
276
+ const i = new V({ getFn: t, fieldNormWeight: r });
277
+ return i.setKeys(s.map(ie)), i.setSources(e), i.create(), i;
278
278
  }
279
- function $t(e, { getFn: t = f.getFn, fieldNormWeight: s = f.fieldNormWeight } = {}) {
280
- const { keys: n, records: r } = e, i = new Y({ getFn: t, fieldNormWeight: s });
281
- return i.setKeys(n), i.setIndexRecords(r), i;
279
+ function Te(s, { getFn: e = d.getFn, fieldNormWeight: t = d.fieldNormWeight } = {}) {
280
+ const { keys: r, records: i } = s, c = new V({ getFn: e, fieldNormWeight: t });
281
+ return c.setKeys(r), c.setIndexRecords(i), c;
282
282
  }
283
- function v(e, {
284
- errors: t = 0,
285
- currentLocation: s = 0,
286
- expectedLocation: n = 0,
287
- distance: r = f.distance,
288
- ignoreLocation: i = f.ignoreLocation
283
+ function C(s, {
284
+ errors: e = 0,
285
+ currentLocation: t = 0,
286
+ expectedLocation: r = 0,
287
+ distance: i = d.distance,
288
+ ignoreLocation: c = d.ignoreLocation
289
289
  } = {}) {
290
- const c = t / e.length;
291
- if (i)
292
- return c;
293
- const o = Math.abs(n - s);
294
- return r ? c + o / r : o ? 1 : c;
295
- }
296
- function Nt(e = [], t = f.minMatchCharLength) {
297
- let s = [], n = -1, r = -1, i = 0;
298
- for (let c = e.length; i < c; i += 1) {
299
- let o = e[i];
300
- o && n === -1 ? n = i : !o && n !== -1 && (r = i - 1, r - n + 1 >= t && s.push([n, r]), n = -1);
301
- }
302
- return e[i - 1] && i - n >= t && s.push([n, i - 1]), s;
303
- }
304
- const k = 32;
305
- function Ot(e, t, s, {
306
- location: n = f.location,
307
- distance: r = f.distance,
308
- threshold: i = f.threshold,
309
- findAllMatches: c = f.findAllMatches,
310
- minMatchCharLength: o = f.minMatchCharLength,
311
- includeMatches: a = f.includeMatches,
312
- ignoreLocation: h = f.ignoreLocation
290
+ const n = e / s.length;
291
+ if (c)
292
+ return n;
293
+ const o = Math.abs(r - t);
294
+ return i ? n + o / i : o ? 1 : n;
295
+ }
296
+ function ke(s = [], e = d.minMatchCharLength) {
297
+ let t = [], r = -1, i = -1, c = 0;
298
+ for (let n = s.length; c < n; c += 1) {
299
+ let o = s[c];
300
+ o && r === -1 ? r = c : !o && r !== -1 && (i = c - 1, i - r + 1 >= e && t.push([r, i]), r = -1);
301
+ }
302
+ return s[c - 1] && c - r >= e && t.push([r, c - 1]), t;
303
+ }
304
+ const v = 32;
305
+ function $e(s, e, t, {
306
+ location: r = d.location,
307
+ distance: i = d.distance,
308
+ threshold: c = d.threshold,
309
+ findAllMatches: n = d.findAllMatches,
310
+ minMatchCharLength: o = d.minMatchCharLength,
311
+ includeMatches: l = d.includeMatches,
312
+ ignoreLocation: a = d.ignoreLocation
313
313
  } = {}) {
314
- if (t.length > k)
315
- throw new Error(xt(k));
316
- const l = t.length, u = e.length, d = Math.max(0, Math.min(n, u));
317
- let g = i, p = d;
318
- const y = o > 1 || a, R = y ? Array(u) : [];
319
- let I;
320
- for (; (I = e.indexOf(t, p)) > -1; ) {
321
- let M = v(t, {
322
- currentLocation: I,
323
- expectedLocation: d,
324
- distance: r,
325
- ignoreLocation: h
314
+ if (e.length > v)
315
+ throw new Error(Me(v));
316
+ const h = e.length, u = s.length, f = Math.max(0, Math.min(r, u));
317
+ let g = c, p = f;
318
+ const m = o > 1 || l, E = m ? Array(u) : [];
319
+ let S;
320
+ for (; (S = s.indexOf(e, p)) > -1; ) {
321
+ let x = C(e, {
322
+ currentLocation: S,
323
+ expectedLocation: f,
324
+ distance: i,
325
+ ignoreLocation: a
326
326
  });
327
- if (g = Math.min(M, g), p = I + l, y) {
328
- let _ = 0;
329
- for (; _ < l; )
330
- R[I + _] = 1, _ += 1;
327
+ if (g = Math.min(x, g), p = S + h, m) {
328
+ let A = 0;
329
+ for (; A < h; )
330
+ E[S + A] = 1, A += 1;
331
331
  }
332
332
  }
333
333
  p = -1;
334
- let T = [], b = 1, O = l + u;
335
- const lt = 1 << l - 1;
336
- for (let M = 0; M < l; M += 1) {
337
- let _ = 0, w = O;
338
- for (; _ < w; )
339
- v(t, {
340
- errors: M,
341
- currentLocation: d + w,
342
- expectedLocation: d,
343
- distance: r,
344
- ignoreLocation: h
345
- }) <= g ? _ = w : O = w, w = Math.floor((O - _) / 2 + _);
346
- O = w;
347
- let G = Math.max(1, d - w + 1), j = c ? u : Math.min(d + w, u) + l, $ = Array(j + 2);
348
- $[j + 1] = (1 << M) - 1;
349
- for (let E = j; E >= G; E -= 1) {
350
- let C = E - 1, U = s[e.charAt(C)];
351
- if (y && (R[C] = +!!U), $[E] = ($[E + 1] << 1 | 1) & U, M && ($[E] |= (T[E + 1] | T[E]) << 1 | 1 | T[E + 1]), $[E] & lt && (b = v(t, {
352
- errors: M,
353
- currentLocation: C,
354
- expectedLocation: d,
355
- distance: r,
356
- ignoreLocation: h
357
- }), b <= g)) {
358
- if (g = b, p = C, p <= d)
334
+ let T = [], R = 1, N = h + u;
335
+ const ae = 1 << h - 1;
336
+ for (let x = 0; x < h; x += 1) {
337
+ let A = 0, I = N;
338
+ for (; A < I; )
339
+ C(e, {
340
+ errors: x,
341
+ currentLocation: f + I,
342
+ expectedLocation: f,
343
+ distance: i,
344
+ ignoreLocation: a
345
+ }) <= g ? A = I : N = I, I = Math.floor((N - A) / 2 + A);
346
+ N = I;
347
+ let U = Math.max(1, f - I + 1), H = n ? u : Math.min(f + I, u) + h, k = Array(H + 2);
348
+ k[H + 1] = (1 << x) - 1;
349
+ for (let M = H; M >= U; M -= 1) {
350
+ let O = M - 1, Y = t[s.charAt(O)];
351
+ if (m && (E[O] = +!!Y), k[M] = (k[M + 1] << 1 | 1) & Y, x && (k[M] |= (T[M + 1] | T[M]) << 1 | 1 | T[M + 1]), k[M] & ae && (R = C(e, {
352
+ errors: x,
353
+ currentLocation: O,
354
+ expectedLocation: f,
355
+ distance: i,
356
+ ignoreLocation: a
357
+ }), R <= g)) {
358
+ if (g = R, p = O, p <= f)
359
359
  break;
360
- G = Math.max(1, 2 * d - p);
360
+ U = Math.max(1, 2 * f - p);
361
361
  }
362
362
  }
363
- if (v(t, {
364
- errors: M + 1,
365
- currentLocation: d,
366
- expectedLocation: d,
367
- distance: r,
368
- ignoreLocation: h
363
+ if (C(e, {
364
+ errors: x + 1,
365
+ currentLocation: f,
366
+ expectedLocation: f,
367
+ distance: i,
368
+ ignoreLocation: a
369
369
  }) > g)
370
370
  break;
371
- T = $;
371
+ T = k;
372
372
  }
373
- const P = {
373
+ const j = {
374
374
  isMatch: p >= 0,
375
375
  // Count exact matches (those with a score of 0) to be "almost" exact
376
- score: Math.max(1e-3, b)
376
+ score: Math.max(1e-3, R)
377
377
  };
378
- if (y) {
379
- const M = Nt(R, o);
380
- M.length ? a && (P.indices = M) : P.isMatch = !1;
381
- }
382
- return P;
383
- }
384
- function Ct(e) {
385
- let t = {};
386
- for (let s = 0, n = e.length; s < n; s += 1) {
387
- const r = e.charAt(s);
388
- t[r] = (t[r] || 0) | 1 << n - s - 1;
389
- }
390
- return t;
391
- }
392
- class it {
393
- constructor(t, {
394
- location: s = f.location,
395
- threshold: n = f.threshold,
396
- distance: r = f.distance,
397
- includeMatches: i = f.includeMatches,
398
- findAllMatches: c = f.findAllMatches,
399
- minMatchCharLength: o = f.minMatchCharLength,
400
- isCaseSensitive: a = f.isCaseSensitive,
401
- ignoreLocation: h = f.ignoreLocation
378
+ if (m) {
379
+ const x = ke(E, o);
380
+ x.length ? l && (j.indices = x) : j.isMatch = !1;
381
+ }
382
+ return j;
383
+ }
384
+ function Ne(s) {
385
+ let e = {};
386
+ for (let t = 0, r = s.length; t < r; t += 1) {
387
+ const i = s.charAt(t);
388
+ e[i] = (e[i] || 0) | 1 << r - t - 1;
389
+ }
390
+ return e;
391
+ }
392
+ class ne {
393
+ constructor(e, {
394
+ location: t = d.location,
395
+ threshold: r = d.threshold,
396
+ distance: i = d.distance,
397
+ includeMatches: c = d.includeMatches,
398
+ findAllMatches: n = d.findAllMatches,
399
+ minMatchCharLength: o = d.minMatchCharLength,
400
+ isCaseSensitive: l = d.isCaseSensitive,
401
+ ignoreLocation: a = d.ignoreLocation
402
402
  } = {}) {
403
403
  if (this.options = {
404
- location: s,
405
- threshold: n,
406
- distance: r,
407
- includeMatches: i,
408
- findAllMatches: c,
404
+ location: t,
405
+ threshold: r,
406
+ distance: i,
407
+ includeMatches: c,
408
+ findAllMatches: n,
409
409
  minMatchCharLength: o,
410
- isCaseSensitive: a,
411
- ignoreLocation: h
412
- }, this.pattern = a ? t : t.toLowerCase(), this.chunks = [], !this.pattern.length)
410
+ isCaseSensitive: l,
411
+ ignoreLocation: a
412
+ }, this.pattern = l ? e : e.toLowerCase(), this.chunks = [], !this.pattern.length)
413
413
  return;
414
- const l = (d, g) => {
414
+ const h = (f, g) => {
415
415
  this.chunks.push({
416
- pattern: d,
417
- alphabet: Ct(d),
416
+ pattern: f,
417
+ alphabet: Ne(f),
418
418
  startIndex: g
419
419
  });
420
420
  }, u = this.pattern.length;
421
- if (u > k) {
422
- let d = 0;
423
- const g = u % k, p = u - g;
424
- for (; d < p; )
425
- l(this.pattern.substr(d, k), d), d += k;
421
+ if (u > v) {
422
+ let f = 0;
423
+ const g = u % v, p = u - g;
424
+ for (; f < p; )
425
+ h(this.pattern.substr(f, v), f), f += v;
426
426
  if (g) {
427
- const y = u - k;
428
- l(this.pattern.substr(y), y);
427
+ const m = u - v;
428
+ h(this.pattern.substr(m), m);
429
429
  }
430
430
  } else
431
- l(this.pattern, 0);
431
+ h(this.pattern, 0);
432
432
  }
433
- searchIn(t) {
434
- const { isCaseSensitive: s, includeMatches: n } = this.options;
435
- if (s || (t = t.toLowerCase()), this.pattern === t) {
433
+ searchIn(e) {
434
+ const { isCaseSensitive: t, includeMatches: r } = this.options;
435
+ if (t || (e = e.toLowerCase()), this.pattern === e) {
436
436
  let p = {
437
437
  isMatch: !0,
438
438
  score: 0
439
439
  };
440
- return n && (p.indices = [[0, t.length - 1]]), p;
440
+ return r && (p.indices = [[0, e.length - 1]]), p;
441
441
  }
442
442
  const {
443
- location: r,
444
- distance: i,
445
- threshold: c,
443
+ location: i,
444
+ distance: c,
445
+ threshold: n,
446
446
  findAllMatches: o,
447
- minMatchCharLength: a,
448
- ignoreLocation: h
447
+ minMatchCharLength: l,
448
+ ignoreLocation: a
449
449
  } = this.options;
450
- let l = [], u = 0, d = !1;
451
- this.chunks.forEach(({ pattern: p, alphabet: y, startIndex: R }) => {
452
- const { isMatch: I, score: T, indices: b } = Ot(t, p, y, {
453
- location: r + R,
454
- distance: i,
455
- threshold: c,
450
+ let h = [], u = 0, f = !1;
451
+ this.chunks.forEach(({ pattern: p, alphabet: m, startIndex: E }) => {
452
+ const { isMatch: S, score: T, indices: R } = $e(e, p, m, {
453
+ location: i + E,
454
+ distance: c,
455
+ threshold: n,
456
456
  findAllMatches: o,
457
- minMatchCharLength: a,
458
- includeMatches: n,
459
- ignoreLocation: h
457
+ minMatchCharLength: l,
458
+ includeMatches: r,
459
+ ignoreLocation: a
460
460
  });
461
- I && (d = !0), u += T, I && b && (l = [...l, ...b]);
461
+ S && (f = !0), u += T, S && R && (h = [...h, ...R]);
462
462
  });
463
463
  let g = {
464
- isMatch: d,
465
- score: d ? u / this.chunks.length : 1
464
+ isMatch: f,
465
+ score: f ? u / this.chunks.length : 1
466
466
  };
467
- return d && n && (g.indices = l), g;
467
+ return f && r && (g.indices = h), g;
468
468
  }
469
469
  }
470
- class L {
471
- constructor(t) {
472
- this.pattern = t;
470
+ class _ {
471
+ constructor(e) {
472
+ this.pattern = e;
473
473
  }
474
- static isMultiMatch(t) {
475
- return J(t, this.multiRegex);
474
+ static isMultiMatch(e) {
475
+ return X(e, this.multiRegex);
476
476
  }
477
- static isSingleMatch(t) {
478
- return J(t, this.singleRegex);
477
+ static isSingleMatch(e) {
478
+ return X(e, this.singleRegex);
479
479
  }
480
480
  search() {
481
481
  }
482
482
  }
483
- function J(e, t) {
484
- const s = e.match(t);
485
- return s ? s[1] : null;
483
+ function X(s, e) {
484
+ const t = s.match(e);
485
+ return t ? t[1] : null;
486
486
  }
487
- class vt extends L {
488
- constructor(t) {
489
- super(t);
487
+ class Oe extends _ {
488
+ constructor(e) {
489
+ super(e);
490
490
  }
491
491
  static get type() {
492
492
  return "exact";
@@ -497,18 +497,18 @@ class vt extends L {
497
497
  static get singleRegex() {
498
498
  return /^=(.*)$/;
499
499
  }
500
- search(t) {
501
- const s = t === this.pattern;
500
+ search(e) {
501
+ const t = e === this.pattern;
502
502
  return {
503
- isMatch: s,
504
- score: s ? 0 : 1,
503
+ isMatch: t,
504
+ score: t ? 0 : 1,
505
505
  indices: [0, this.pattern.length - 1]
506
506
  };
507
507
  }
508
508
  }
509
- class Ft extends L {
510
- constructor(t) {
511
- super(t);
509
+ class Ce extends _ {
510
+ constructor(e) {
511
+ super(e);
512
512
  }
513
513
  static get type() {
514
514
  return "inverse-exact";
@@ -519,18 +519,18 @@ class Ft extends L {
519
519
  static get singleRegex() {
520
520
  return /^!(.*)$/;
521
521
  }
522
- search(t) {
523
- const n = t.indexOf(this.pattern) === -1;
522
+ search(e) {
523
+ const r = e.indexOf(this.pattern) === -1;
524
524
  return {
525
- isMatch: n,
526
- score: n ? 0 : 1,
527
- indices: [0, t.length - 1]
525
+ isMatch: r,
526
+ score: r ? 0 : 1,
527
+ indices: [0, e.length - 1]
528
528
  };
529
529
  }
530
530
  }
531
- class Pt extends L {
532
- constructor(t) {
533
- super(t);
531
+ class Fe extends _ {
532
+ constructor(e) {
533
+ super(e);
534
534
  }
535
535
  static get type() {
536
536
  return "prefix-exact";
@@ -541,18 +541,18 @@ class Pt extends L {
541
541
  static get singleRegex() {
542
542
  return /^\^(.*)$/;
543
543
  }
544
- search(t) {
545
- const s = t.startsWith(this.pattern);
544
+ search(e) {
545
+ const t = e.startsWith(this.pattern);
546
546
  return {
547
- isMatch: s,
548
- score: s ? 0 : 1,
547
+ isMatch: t,
548
+ score: t ? 0 : 1,
549
549
  indices: [0, this.pattern.length - 1]
550
550
  };
551
551
  }
552
552
  }
553
- class jt extends L {
554
- constructor(t) {
555
- super(t);
553
+ class je extends _ {
554
+ constructor(e) {
555
+ super(e);
556
556
  }
557
557
  static get type() {
558
558
  return "inverse-prefix-exact";
@@ -563,18 +563,18 @@ class jt extends L {
563
563
  static get singleRegex() {
564
564
  return /^!\^(.*)$/;
565
565
  }
566
- search(t) {
567
- const s = !t.startsWith(this.pattern);
566
+ search(e) {
567
+ const t = !e.startsWith(this.pattern);
568
568
  return {
569
- isMatch: s,
570
- score: s ? 0 : 1,
571
- indices: [0, t.length - 1]
569
+ isMatch: t,
570
+ score: t ? 0 : 1,
571
+ indices: [0, e.length - 1]
572
572
  };
573
573
  }
574
574
  }
575
- class Ht extends L {
576
- constructor(t) {
577
- super(t);
575
+ class He extends _ {
576
+ constructor(e) {
577
+ super(e);
578
578
  }
579
579
  static get type() {
580
580
  return "suffix-exact";
@@ -585,18 +585,18 @@ class Ht extends L {
585
585
  static get singleRegex() {
586
586
  return /^(.*)\$$/;
587
587
  }
588
- search(t) {
589
- const s = t.endsWith(this.pattern);
588
+ search(e) {
589
+ const t = e.endsWith(this.pattern);
590
590
  return {
591
- isMatch: s,
592
- score: s ? 0 : 1,
593
- indices: [t.length - this.pattern.length, t.length - 1]
591
+ isMatch: t,
592
+ score: t ? 0 : 1,
593
+ indices: [e.length - this.pattern.length, e.length - 1]
594
594
  };
595
595
  }
596
596
  }
597
- class Kt extends L {
598
- constructor(t) {
599
- super(t);
597
+ class Pe extends _ {
598
+ constructor(e) {
599
+ super(e);
600
600
  }
601
601
  static get type() {
602
602
  return "inverse-suffix-exact";
@@ -607,35 +607,35 @@ class Kt extends L {
607
607
  static get singleRegex() {
608
608
  return /^!(.*)\$$/;
609
609
  }
610
- search(t) {
611
- const s = !t.endsWith(this.pattern);
610
+ search(e) {
611
+ const t = !e.endsWith(this.pattern);
612
612
  return {
613
- isMatch: s,
614
- score: s ? 0 : 1,
615
- indices: [0, t.length - 1]
613
+ isMatch: t,
614
+ score: t ? 0 : 1,
615
+ indices: [0, e.length - 1]
616
616
  };
617
617
  }
618
618
  }
619
- class ct extends L {
620
- constructor(t, {
621
- location: s = f.location,
622
- threshold: n = f.threshold,
623
- distance: r = f.distance,
624
- includeMatches: i = f.includeMatches,
625
- findAllMatches: c = f.findAllMatches,
626
- minMatchCharLength: o = f.minMatchCharLength,
627
- isCaseSensitive: a = f.isCaseSensitive,
628
- ignoreLocation: h = f.ignoreLocation
619
+ class ce extends _ {
620
+ constructor(e, {
621
+ location: t = d.location,
622
+ threshold: r = d.threshold,
623
+ distance: i = d.distance,
624
+ includeMatches: c = d.includeMatches,
625
+ findAllMatches: n = d.findAllMatches,
626
+ minMatchCharLength: o = d.minMatchCharLength,
627
+ isCaseSensitive: l = d.isCaseSensitive,
628
+ ignoreLocation: a = d.ignoreLocation
629
629
  } = {}) {
630
- super(t), this._bitapSearch = new it(t, {
631
- location: s,
632
- threshold: n,
633
- distance: r,
634
- includeMatches: i,
635
- findAllMatches: c,
630
+ super(e), this._bitapSearch = new ne(e, {
631
+ location: t,
632
+ threshold: r,
633
+ distance: i,
634
+ includeMatches: c,
635
+ findAllMatches: n,
636
636
  minMatchCharLength: o,
637
- isCaseSensitive: a,
638
- ignoreLocation: h
637
+ isCaseSensitive: l,
638
+ ignoreLocation: a
639
639
  });
640
640
  }
641
641
  static get type() {
@@ -647,13 +647,13 @@ class ct extends L {
647
647
  static get singleRegex() {
648
648
  return /^(.*)$/;
649
649
  }
650
- search(t) {
651
- return this._bitapSearch.searchIn(t);
650
+ search(e) {
651
+ return this._bitapSearch.searchIn(e);
652
652
  }
653
653
  }
654
- class ot extends L {
655
- constructor(t) {
656
- super(t);
654
+ class oe extends _ {
655
+ constructor(e) {
656
+ super(e);
657
657
  }
658
658
  static get type() {
659
659
  return "include";
@@ -664,110 +664,110 @@ class ot extends L {
664
664
  static get singleRegex() {
665
665
  return /^'(.*)$/;
666
666
  }
667
- search(t) {
668
- let s = 0, n;
669
- const r = [], i = this.pattern.length;
670
- for (; (n = t.indexOf(this.pattern, s)) > -1; )
671
- s = n + i, r.push([n, s - 1]);
672
- const c = !!r.length;
667
+ search(e) {
668
+ let t = 0, r;
669
+ const i = [], c = this.pattern.length;
670
+ for (; (r = e.indexOf(this.pattern, t)) > -1; )
671
+ t = r + c, i.push([r, t - 1]);
672
+ const n = !!i.length;
673
673
  return {
674
- isMatch: c,
675
- score: c ? 0 : 1,
676
- indices: r
674
+ isMatch: n,
675
+ score: n ? 0 : 1,
676
+ indices: i
677
677
  };
678
678
  }
679
679
  }
680
- const B = [
681
- vt,
682
- ot,
683
- Pt,
684
- jt,
685
- Kt,
686
- Ht,
687
- Ft,
688
- ct
689
- ], q = B.length, Bt = / +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/, Dt = "|";
690
- function Wt(e, t = {}) {
691
- return e.split(Dt).map((s) => {
692
- let n = s.trim().split(Bt).filter((i) => i && !!i.trim()), r = [];
693
- for (let i = 0, c = n.length; i < c; i += 1) {
694
- const o = n[i];
695
- let a = !1, h = -1;
696
- for (; !a && ++h < q; ) {
697
- const l = B[h];
698
- let u = l.isMultiMatch(o);
699
- u && (r.push(new l(u, t)), a = !0);
680
+ const K = [
681
+ Oe,
682
+ oe,
683
+ Fe,
684
+ je,
685
+ Pe,
686
+ He,
687
+ Ce,
688
+ ce
689
+ ], J = K.length, Be = / +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/, Ke = "|";
690
+ function We(s, e = {}) {
691
+ return s.split(Ke).map((t) => {
692
+ let r = t.trim().split(Be).filter((c) => c && !!c.trim()), i = [];
693
+ for (let c = 0, n = r.length; c < n; c += 1) {
694
+ const o = r[c];
695
+ let l = !1, a = -1;
696
+ for (; !l && ++a < J; ) {
697
+ const h = K[a];
698
+ let u = h.isMultiMatch(o);
699
+ u && (i.push(new h(u, e)), l = !0);
700
700
  }
701
- if (!a)
702
- for (h = -1; ++h < q; ) {
703
- const l = B[h];
704
- let u = l.isSingleMatch(o);
701
+ if (!l)
702
+ for (a = -1; ++a < J; ) {
703
+ const h = K[a];
704
+ let u = h.isSingleMatch(o);
705
705
  if (u) {
706
- r.push(new l(u, t));
706
+ i.push(new h(u, e));
707
707
  break;
708
708
  }
709
709
  }
710
710
  }
711
- return r;
711
+ return i;
712
712
  });
713
713
  }
714
- const zt = /* @__PURE__ */ new Set([ct.type, ot.type]);
715
- class Vt {
716
- constructor(t, {
717
- isCaseSensitive: s = f.isCaseSensitive,
718
- includeMatches: n = f.includeMatches,
719
- minMatchCharLength: r = f.minMatchCharLength,
720
- ignoreLocation: i = f.ignoreLocation,
721
- findAllMatches: c = f.findAllMatches,
722
- location: o = f.location,
723
- threshold: a = f.threshold,
724
- distance: h = f.distance
714
+ const De = /* @__PURE__ */ new Set([ce.type, oe.type]);
715
+ class ze {
716
+ constructor(e, {
717
+ isCaseSensitive: t = d.isCaseSensitive,
718
+ includeMatches: r = d.includeMatches,
719
+ minMatchCharLength: i = d.minMatchCharLength,
720
+ ignoreLocation: c = d.ignoreLocation,
721
+ findAllMatches: n = d.findAllMatches,
722
+ location: o = d.location,
723
+ threshold: l = d.threshold,
724
+ distance: a = d.distance
725
725
  } = {}) {
726
726
  this.query = null, this.options = {
727
- isCaseSensitive: s,
728
- includeMatches: n,
729
- minMatchCharLength: r,
730
- findAllMatches: c,
731
- ignoreLocation: i,
727
+ isCaseSensitive: t,
728
+ includeMatches: r,
729
+ minMatchCharLength: i,
730
+ findAllMatches: n,
731
+ ignoreLocation: c,
732
732
  location: o,
733
- threshold: a,
734
- distance: h
735
- }, this.pattern = s ? t : t.toLowerCase(), this.query = Wt(this.pattern, this.options);
733
+ threshold: l,
734
+ distance: a
735
+ }, this.pattern = t ? e : e.toLowerCase(), this.query = We(this.pattern, this.options);
736
736
  }
737
- static condition(t, s) {
738
- return s.useExtendedSearch;
737
+ static condition(e, t) {
738
+ return t.useExtendedSearch;
739
739
  }
740
- searchIn(t) {
741
- const s = this.query;
742
- if (!s)
740
+ searchIn(e) {
741
+ const t = this.query;
742
+ if (!t)
743
743
  return {
744
744
  isMatch: !1,
745
745
  score: 1
746
746
  };
747
- const { includeMatches: n, isCaseSensitive: r } = this.options;
748
- t = r ? t : t.toLowerCase();
749
- let i = 0, c = [], o = 0;
750
- for (let a = 0, h = s.length; a < h; a += 1) {
751
- const l = s[a];
752
- c.length = 0, i = 0;
753
- for (let u = 0, d = l.length; u < d; u += 1) {
754
- const g = l[u], { isMatch: p, indices: y, score: R } = g.search(t);
747
+ const { includeMatches: r, isCaseSensitive: i } = this.options;
748
+ e = i ? e : e.toLowerCase();
749
+ let c = 0, n = [], o = 0;
750
+ for (let l = 0, a = t.length; l < a; l += 1) {
751
+ const h = t[l];
752
+ n.length = 0, c = 0;
753
+ for (let u = 0, f = h.length; u < f; u += 1) {
754
+ const g = h[u], { isMatch: p, indices: m, score: E } = g.search(e);
755
755
  if (p) {
756
- if (i += 1, o += R, n) {
757
- const I = g.constructor.type;
758
- zt.has(I) ? c = [...c, ...y] : c.push(y);
756
+ if (c += 1, o += E, r) {
757
+ const S = g.constructor.type;
758
+ De.has(S) ? n = [...n, ...m] : n.push(m);
759
759
  }
760
760
  } else {
761
- o = 0, i = 0, c.length = 0;
761
+ o = 0, c = 0, n.length = 0;
762
762
  break;
763
763
  }
764
764
  }
765
- if (i) {
765
+ if (c) {
766
766
  let u = {
767
767
  isMatch: !0,
768
- score: o / i
768
+ score: o / c
769
769
  };
770
- return n && (u.indices = c), u;
770
+ return r && (u.indices = n), u;
771
771
  }
772
772
  }
773
773
  return {
@@ -776,17 +776,17 @@ class Vt {
776
776
  };
777
777
  }
778
778
  }
779
- const D = [];
780
- function Yt(...e) {
781
- D.push(...e);
779
+ const W = [];
780
+ function qe(...s) {
781
+ W.push(...s);
782
782
  }
783
- function W(e, t) {
784
- for (let s = 0, n = D.length; s < n; s += 1) {
785
- let r = D[s];
786
- if (r.condition(e, t))
787
- return new r(e, t);
783
+ function D(s, e) {
784
+ for (let t = 0, r = W.length; t < r; t += 1) {
785
+ let i = W[t];
786
+ if (i.condition(s, e))
787
+ return new i(s, e);
788
788
  }
789
- return new it(e, t);
789
+ return new ne(s, e);
790
790
  }
791
791
  const F = {
792
792
  AND: "$and",
@@ -794,412 +794,584 @@ const F = {
794
794
  }, z = {
795
795
  PATH: "$path",
796
796
  PATTERN: "$val"
797
- }, V = (e) => !!(e[F.AND] || e[F.OR]), Gt = (e) => !!e[z.PATH], Ut = (e) => !A(e) && et(e) && !V(e), Z = (e) => ({
798
- [F.AND]: Object.keys(e).map((t) => ({
799
- [t]: e[t]
797
+ }, q = (s) => !!(s[F.AND] || s[F.OR]), Ve = (s) => !!s[z.PATH], Ue = (s) => !L(s) && te(s) && !q(s), Z = (s) => ({
798
+ [F.AND]: Object.keys(s).map((e) => ({
799
+ [e]: s[e]
800
800
  }))
801
801
  });
802
- function at(e, t, { auto: s = !0 } = {}) {
803
- const n = (r) => {
804
- let i = Object.keys(r);
805
- const c = Gt(r);
806
- if (!c && i.length > 1 && !V(r))
807
- return n(Z(r));
808
- if (Ut(r)) {
809
- const a = c ? r[z.PATH] : i[0], h = c ? r[z.PATTERN] : r[a];
810
- if (!S(h))
811
- throw new Error(Et(a));
812
- const l = {
813
- keyId: K(a),
814
- pattern: h
802
+ function le(s, e, { auto: t = !0 } = {}) {
803
+ const r = (i) => {
804
+ let c = Object.keys(i);
805
+ const n = Ve(i);
806
+ if (!n && c.length > 1 && !q(i))
807
+ return r(Z(i));
808
+ if (Ue(i)) {
809
+ const l = n ? i[z.PATH] : c[0], a = n ? i[z.PATTERN] : i[l];
810
+ if (!w(a))
811
+ throw new Error(xe(l));
812
+ const h = {
813
+ keyId: B(l),
814
+ pattern: a
815
815
  };
816
- return s && (l.searcher = W(h, t)), l;
816
+ return t && (h.searcher = D(a, e)), h;
817
817
  }
818
818
  let o = {
819
819
  children: [],
820
- operator: i[0]
820
+ operator: c[0]
821
821
  };
822
- return i.forEach((a) => {
823
- const h = r[a];
824
- A(h) && h.forEach((l) => {
825
- o.children.push(n(l));
822
+ return c.forEach((l) => {
823
+ const a = i[l];
824
+ L(a) && a.forEach((h) => {
825
+ o.children.push(r(h));
826
826
  });
827
827
  }), o;
828
828
  };
829
- return V(e) || (e = Z(e)), n(e);
830
- }
831
- function Qt(e, { ignoreFieldNorm: t = f.ignoreFieldNorm }) {
832
- e.forEach((s) => {
833
- let n = 1;
834
- s.matches.forEach(({ key: r, norm: i, score: c }) => {
835
- const o = r ? r.weight : null;
836
- n *= Math.pow(
837
- c === 0 && o ? Number.EPSILON : c,
838
- (o || 1) * (t ? 1 : i)
829
+ return q(s) || (s = Z(s)), r(s);
830
+ }
831
+ function Ye(s, { ignoreFieldNorm: e = d.ignoreFieldNorm }) {
832
+ s.forEach((t) => {
833
+ let r = 1;
834
+ t.matches.forEach(({ key: i, norm: c, score: n }) => {
835
+ const o = i ? i.weight : null;
836
+ r *= Math.pow(
837
+ n === 0 && o ? Number.EPSILON : n,
838
+ (o || 1) * (e ? 1 : c)
839
839
  );
840
- }), s.score = n;
840
+ }), t.score = r;
841
841
  });
842
842
  }
843
- function Xt(e, t) {
844
- const s = e.matches;
845
- t.matches = [], m(s) && s.forEach((n) => {
846
- if (!m(n.indices) || !n.indices.length)
843
+ function Ge(s, e) {
844
+ const t = s.matches;
845
+ e.matches = [], y(t) && t.forEach((r) => {
846
+ if (!y(r.indices) || !r.indices.length)
847
847
  return;
848
- const { indices: r, value: i } = n;
849
- let c = {
850
- indices: r,
851
- value: i
848
+ const { indices: i, value: c } = r;
849
+ let n = {
850
+ indices: i,
851
+ value: c
852
852
  };
853
- n.key && (c.key = n.key.src), n.idx > -1 && (c.refIndex = n.idx), t.matches.push(c);
853
+ r.key && (n.key = r.key.src), r.idx > -1 && (n.refIndex = r.idx), e.matches.push(n);
854
854
  });
855
855
  }
856
- function Jt(e, t) {
857
- t.score = e.score;
856
+ function Qe(s, e) {
857
+ e.score = s.score;
858
858
  }
859
- function qt(e, t, {
860
- includeMatches: s = f.includeMatches,
861
- includeScore: n = f.includeScore
859
+ function Xe(s, e, {
860
+ includeMatches: t = d.includeMatches,
861
+ includeScore: r = d.includeScore
862
862
  } = {}) {
863
- const r = [];
864
- return s && r.push(Xt), n && r.push(Jt), e.map((i) => {
865
- const { idx: c } = i, o = {
866
- item: t[c],
867
- refIndex: c
863
+ const i = [];
864
+ return t && i.push(Ge), r && i.push(Qe), s.map((c) => {
865
+ const { idx: n } = c, o = {
866
+ item: e[n],
867
+ refIndex: n
868
868
  };
869
- return r.length && r.forEach((a) => {
870
- a(i, o);
869
+ return i.length && i.forEach((l) => {
870
+ l(c, o);
871
871
  }), o;
872
872
  });
873
873
  }
874
- class N {
875
- constructor(t, s = {}, n) {
876
- this.options = { ...f, ...s }, this.options.useExtendedSearch, this._keyStore = new At(this.options.keys), this.setCollection(t, n);
877
- }
878
- setCollection(t, s) {
879
- if (this._docs = t, s && !(s instanceof Y))
880
- throw new Error(Mt);
881
- this._myIndex = s || nt(this.options.keys, this._docs, {
874
+ class $ {
875
+ constructor(e, t = {}, r) {
876
+ this.options = { ...d, ...t }, this.options.useExtendedSearch, this._keyStore = new Se(this.options.keys), this.setCollection(e, r);
877
+ }
878
+ setCollection(e, t) {
879
+ if (this._docs = e, t && !(t instanceof V))
880
+ throw new Error(ye);
881
+ this._myIndex = t || re(this.options.keys, this._docs, {
882
882
  getFn: this.options.getFn,
883
883
  fieldNormWeight: this.options.fieldNormWeight
884
884
  });
885
885
  }
886
- add(t) {
887
- m(t) && (this._docs.push(t), this._myIndex.add(t));
886
+ add(e) {
887
+ y(e) && (this._docs.push(e), this._myIndex.add(e));
888
888
  }
889
- remove(t = () => !1) {
890
- const s = [];
891
- for (let n = 0, r = this._docs.length; n < r; n += 1) {
892
- const i = this._docs[n];
893
- t(i, n) && (this.removeAt(n), n -= 1, r -= 1, s.push(i));
889
+ remove(e = () => !1) {
890
+ const t = [];
891
+ for (let r = 0, i = this._docs.length; r < i; r += 1) {
892
+ const c = this._docs[r];
893
+ e(c, r) && (this.removeAt(r), r -= 1, i -= 1, t.push(c));
894
894
  }
895
- return s;
895
+ return t;
896
896
  }
897
- removeAt(t) {
898
- this._docs.splice(t, 1), this._myIndex.removeAt(t);
897
+ removeAt(e) {
898
+ this._docs.splice(e, 1), this._myIndex.removeAt(e);
899
899
  }
900
900
  getIndex() {
901
901
  return this._myIndex;
902
902
  }
903
- search(t, { limit: s = -1 } = {}) {
903
+ search(e, { limit: t = -1 } = {}) {
904
904
  const {
905
- includeMatches: n,
906
- includeScore: r,
907
- shouldSort: i,
908
- sortFn: c,
905
+ includeMatches: r,
906
+ includeScore: i,
907
+ shouldSort: c,
908
+ sortFn: n,
909
909
  ignoreFieldNorm: o
910
910
  } = this.options;
911
- let a = S(t) ? S(this._docs[0]) ? this._searchStringList(t) : this._searchObjectList(t) : this._searchLogical(t);
912
- return Qt(a, { ignoreFieldNorm: o }), i && a.sort(c), tt(s) && s > -1 && (a = a.slice(0, s)), qt(a, this._docs, {
913
- includeMatches: n,
914
- includeScore: r
911
+ let l = w(e) ? w(this._docs[0]) ? this._searchStringList(e) : this._searchObjectList(e) : this._searchLogical(e);
912
+ return Ye(l, { ignoreFieldNorm: o }), c && l.sort(n), ee(t) && t > -1 && (l = l.slice(0, t)), Xe(l, this._docs, {
913
+ includeMatches: r,
914
+ includeScore: i
915
915
  });
916
916
  }
917
- _searchStringList(t) {
918
- const s = W(t, this.options), { records: n } = this._myIndex, r = [];
919
- return n.forEach(({ v: i, i: c, n: o }) => {
920
- if (!m(i))
917
+ _searchStringList(e) {
918
+ const t = D(e, this.options), { records: r } = this._myIndex, i = [];
919
+ return r.forEach(({ v: c, i: n, n: o }) => {
920
+ if (!y(c))
921
921
  return;
922
- const { isMatch: a, score: h, indices: l } = s.searchIn(i);
923
- a && r.push({
924
- item: i,
925
- idx: c,
926
- matches: [{ score: h, value: i, norm: o, indices: l }]
922
+ const { isMatch: l, score: a, indices: h } = t.searchIn(c);
923
+ l && i.push({
924
+ item: c,
925
+ idx: n,
926
+ matches: [{ score: a, value: c, norm: o, indices: h }]
927
927
  });
928
- }), r;
928
+ }), i;
929
929
  }
930
- _searchLogical(t) {
931
- const s = at(t, this.options), n = (o, a, h) => {
930
+ _searchLogical(e) {
931
+ const t = le(e, this.options), r = (o, l, a) => {
932
932
  if (!o.children) {
933
- const { keyId: u, searcher: d } = o, g = this._findMatches({
933
+ const { keyId: u, searcher: f } = o, g = this._findMatches({
934
934
  key: this._keyStore.get(u),
935
- value: this._myIndex.getValueForItemAtKeyId(a, u),
936
- searcher: d
935
+ value: this._myIndex.getValueForItemAtKeyId(l, u),
936
+ searcher: f
937
937
  });
938
938
  return g && g.length ? [
939
939
  {
940
- idx: h,
941
- item: a,
940
+ idx: a,
941
+ item: l,
942
942
  matches: g
943
943
  }
944
944
  ] : [];
945
945
  }
946
- const l = [];
947
- for (let u = 0, d = o.children.length; u < d; u += 1) {
948
- const g = o.children[u], p = n(g, a, h);
946
+ const h = [];
947
+ for (let u = 0, f = o.children.length; u < f; u += 1) {
948
+ const g = o.children[u], p = r(g, l, a);
949
949
  if (p.length)
950
- l.push(...p);
950
+ h.push(...p);
951
951
  else if (o.operator === F.AND)
952
952
  return [];
953
953
  }
954
- return l;
955
- }, r = this._myIndex.records, i = {}, c = [];
956
- return r.forEach(({ $: o, i: a }) => {
957
- if (m(o)) {
958
- let h = n(s, o, a);
959
- h.length && (i[a] || (i[a] = { idx: a, item: o, matches: [] }, c.push(i[a])), h.forEach(({ matches: l }) => {
960
- i[a].matches.push(...l);
954
+ return h;
955
+ }, i = this._myIndex.records, c = {}, n = [];
956
+ return i.forEach(({ $: o, i: l }) => {
957
+ if (y(o)) {
958
+ let a = r(t, o, l);
959
+ a.length && (c[l] || (c[l] = { idx: l, item: o, matches: [] }, n.push(c[l])), a.forEach(({ matches: h }) => {
960
+ c[l].matches.push(...h);
961
961
  }));
962
962
  }
963
- }), c;
963
+ }), n;
964
964
  }
965
- _searchObjectList(t) {
966
- const s = W(t, this.options), { keys: n, records: r } = this._myIndex, i = [];
967
- return r.forEach(({ $: c, i: o }) => {
968
- if (!m(c))
965
+ _searchObjectList(e) {
966
+ const t = D(e, this.options), { keys: r, records: i } = this._myIndex, c = [];
967
+ return i.forEach(({ $: n, i: o }) => {
968
+ if (!y(n))
969
969
  return;
970
- let a = [];
971
- n.forEach((h, l) => {
972
- a.push(
970
+ let l = [];
971
+ r.forEach((a, h) => {
972
+ l.push(
973
973
  ...this._findMatches({
974
- key: h,
975
- value: c[l],
976
- searcher: s
974
+ key: a,
975
+ value: n[h],
976
+ searcher: t
977
977
  })
978
978
  );
979
- }), a.length && i.push({
979
+ }), l.length && c.push({
980
980
  idx: o,
981
- item: c,
982
- matches: a
981
+ item: n,
982
+ matches: l
983
983
  });
984
- }), i;
984
+ }), c;
985
985
  }
986
- _findMatches({ key: t, value: s, searcher: n }) {
987
- if (!m(s))
986
+ _findMatches({ key: e, value: t, searcher: r }) {
987
+ if (!y(t))
988
988
  return [];
989
- let r = [];
990
- if (A(s))
991
- s.forEach(({ v: i, i: c, n: o }) => {
992
- if (!m(i))
989
+ let i = [];
990
+ if (L(t))
991
+ t.forEach(({ v: c, i: n, n: o }) => {
992
+ if (!y(c))
993
993
  return;
994
- const { isMatch: a, score: h, indices: l } = n.searchIn(i);
995
- a && r.push({
996
- score: h,
997
- key: t,
998
- value: i,
999
- idx: c,
994
+ const { isMatch: l, score: a, indices: h } = r.searchIn(c);
995
+ l && i.push({
996
+ score: a,
997
+ key: e,
998
+ value: c,
999
+ idx: n,
1000
1000
  norm: o,
1001
- indices: l
1001
+ indices: h
1002
1002
  });
1003
1003
  });
1004
1004
  else {
1005
- const { v: i, n: c } = s, { isMatch: o, score: a, indices: h } = n.searchIn(i);
1006
- o && r.push({ score: a, key: t, value: i, norm: c, indices: h });
1005
+ const { v: c, n } = t, { isMatch: o, score: l, indices: a } = r.searchIn(c);
1006
+ o && i.push({ score: l, key: e, value: c, norm: n, indices: a });
1007
1007
  }
1008
- return r;
1008
+ return i;
1009
1009
  }
1010
1010
  }
1011
- N.version = "6.6.2";
1012
- N.createIndex = nt;
1013
- N.parseIndex = $t;
1014
- N.config = f;
1015
- N.parseQuery = at;
1016
- Yt(Vt);
1017
- const Zt = `
1011
+ $.version = "6.6.2";
1012
+ $.createIndex = re;
1013
+ $.parseIndex = Te;
1014
+ $.config = d;
1015
+ $.parseQuery = le;
1016
+ qe(ze);
1017
+ const Je = `
1018
1018
  <style>
1019
1019
  :host {
1020
- display: block;
1020
+ display: flex;
1021
+ box-sizing: border-box;
1022
+ height: 100%;
1023
+ overflow: hidden;
1024
+ }
1025
+ *, *:before, *:after {
1026
+ box-sizing: inherit;
1027
+ }
1028
+ form {
1029
+ height: 100%;
1030
+ max-width: 100%;
1031
+ display: flex;
1032
+ flex-direction: column;
1033
+ }
1034
+ ul {
1035
+ padding-left: 0;
1036
+ margin-top: 0;
1037
+ }
1038
+ li {
1039
+ list-style: none;
1040
+ }
1041
+ li span {
1042
+ font-size: small;
1043
+ overflow: hidden;
1044
+ text-overflow: ellipsis;
1045
+ white-space: nowrap;
1046
+ }
1047
+ label {
1048
+ display: flex;
1049
+ align-items: center;
1050
+ }
1051
+ details {
1052
+ margin-bottom: 0.5rem;
1053
+ }
1054
+ details summary > * {
1055
+ display: inline;
1056
+ }
1057
+ details summary {
1058
+ display: flex;
1059
+ align-items: center;
1060
+ }
1061
+ #details-filter summary {
1062
+ justify-content: space-between;
1063
+ }
1064
+ #details-results summary {
1065
+ list-style: none;
1066
+ }
1067
+ #details-filter summary svg,
1068
+ #details-results summary svg {
1069
+ width: 24px;
1070
+ height: 24px;
1071
+ transition: all ease-in-out 0.3s;
1072
+ }
1073
+ #details-results summary svg {
1074
+ transform: rotate(-90deg);
1075
+ }
1076
+ #details-filter[open] summary svg {
1077
+ transform: rotate(180deg);
1078
+ }
1079
+ #details-results[open] summary svg {
1080
+ transform: rotate(0deg);
1081
+ }
1082
+ li span,
1083
+ details summary {
1084
+ text-transform: capitalize;
1085
+ }
1086
+ li,
1087
+ label,
1088
+ details,
1089
+ input[type=checkbox],
1090
+ input[type=radio] {
1091
+ cursor: pointer;
1092
+ }
1093
+ input[type=checkbox],
1094
+ input[type=radio] {
1095
+ margin: 0;
1096
+ margin-right: 0.5rem;
1097
+ }
1098
+ input[type=text] {
1099
+ display: none;
1100
+ width: 100%;
1101
+ margin-bottom: 0.5rem;
1102
+ }
1103
+ section {
1104
+ padding-left: 1rem;
1105
+ padding-right: 1rem;
1106
+ }
1107
+ section:first-of-type {
1108
+ padding-top: 1rem;
1109
+ }
1110
+ #section-results {
1111
+ overflow: hidden;
1112
+ flex: 1;
1113
+ display: flex;
1114
+ flex-direction: column;
1115
+ }
1116
+ #container-results {
1117
+ margin-right: -1rem;
1118
+ }
1119
+ ul#results {
1120
+ padding-right: 1rem;
1121
+ }
1122
+ ul#results li {
1123
+ padding-left: 0.5rem;
1124
+ }
1125
+ .scroll {
1126
+ height: 100%;
1127
+ overflow-x: hidden;
1128
+ overflow-y: auto;
1021
1129
  }
1022
1130
  </style>
1023
- <div>
1024
- <slot></slot>
1025
- <ul id="filters"></ul>
1026
- <input type="text" />
1027
- <ul id="results"></ul>
1028
- </div>
1029
- `, te = `
1131
+ <form>
1132
+ <section>
1133
+ <input type="text" placeholder="Search" />
1134
+ </section>
1135
+ <section>
1136
+ <slot name="filterstitle"></slot>
1137
+ <ul id="filters"></ul>
1138
+ </section>
1139
+ <section id="section-results">
1140
+ <div>
1141
+ <slot name="resultstitle"></slot>
1142
+ </div>
1143
+ <div id="container-results" class="scroll">
1144
+ <ul id="results"></ul>
1145
+ </div>
1146
+ </section>
1147
+ </form>
1148
+ `, Ze = `
1030
1149
  <li>
1031
1150
  <label>
1032
1151
  <input type="checkbox" />
1033
1152
  <span class="title">FILTERITEMTITLE</span>
1034
1153
  </label>
1035
1154
  </li>
1036
- `, ee = `
1037
- <details open>
1038
- <summary>TITLE</summar>
1155
+ `, et = `
1156
+ <details id="details-filter">
1157
+ <summary>
1158
+ <small>
1159
+ <strong class="title">
1160
+ FILTERTITLE
1161
+ </strong>
1162
+ </small>
1163
+ <div>
1164
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><title>chevron-down</title><path d="M7.41,8.58L12,13.17L16.59,8.58L18,10L12,16L6,10L7.41,8.58Z" /></svg>
1165
+ </div>
1166
+ </summary>
1167
+ <ul></ul>
1168
+ </details>
1169
+ `, tt = `
1170
+ <li>
1171
+ <label>
1172
+ <input type="radio" name="result" />
1173
+ <span class="title">RESULTTITLE</span>
1174
+ </label>
1175
+ </li>
1176
+ `, st = `
1177
+ <details id="details-results" open>
1178
+ <summary>
1179
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><title>chevron-down</title><path d="M7.41,8.58L12,13.17L16.59,8.58L18,10L12,16L6,10L7.41,8.58Z" /></svg>
1180
+ <strong class="title">
1181
+ SUMMARYTITLE
1182
+ </strong>
1183
+ <span style="margin-left: 0.25rem">(<span class="count"></span>)</span>
1184
+ </summary>
1039
1185
  <ul></ul>
1040
1186
  </details>
1041
- `, se = (e, t = "highlight") => {
1042
- const s = (r, i, c) => {
1043
- const o = i.split(".");
1044
- let a;
1045
- for (a = 0; a < o.length - 1; a++)
1046
- r = r[o[a]];
1047
- r[o[a]] = c;
1048
- }, n = (r, i = []) => {
1049
- let c = "", o = 0;
1050
- return i.forEach((a) => {
1051
- const h = a[1] + 1;
1052
- c += [
1053
- r.substring(o, a[0]),
1054
- `<mark class="${t}">`,
1055
- r.substring(a[0], h),
1187
+ `, it = (s, e = "highlight") => {
1188
+ const t = (i, c, n) => {
1189
+ const o = c.split(".");
1190
+ let l;
1191
+ for (l = 0; l < o.length - 1; l++)
1192
+ i = i[o[l]];
1193
+ i[o[l]] = n;
1194
+ }, r = (i, c = []) => {
1195
+ let n = "", o = 0;
1196
+ return c.forEach((l) => {
1197
+ const a = l[1] + 1;
1198
+ n += [
1199
+ i.substring(o, l[0]),
1200
+ `<mark class="${e}">`,
1201
+ i.substring(l[0], a),
1056
1202
  "</mark>"
1057
- ].join(""), o = h;
1058
- }), c += r.substring(o), c;
1203
+ ].join(""), o = a;
1204
+ }), n += i.substring(o), n;
1059
1205
  };
1060
- return e.filter(({ matches: r }) => r && r.length).map(({ item: r, matches: i }) => {
1061
- const c = { ...r };
1062
- return i.forEach((o) => {
1063
- o.key === "name" && s(
1064
- c,
1206
+ return s.filter(({ matches: i }) => i && i.length).map(({ item: i, matches: c }) => {
1207
+ const n = { ...i };
1208
+ return c.forEach((o) => {
1209
+ o.key === "name" && t(
1210
+ n,
1065
1211
  o.key,
1066
- n(o.value, o.indices)
1212
+ r(o.value, o.indices)
1067
1213
  );
1068
- }), c;
1214
+ }), n;
1069
1215
  });
1070
- }, ht = document.createElement("template");
1071
- ht.innerHTML = Zt;
1072
- class re extends HTMLElement {
1216
+ };
1217
+ class rt extends HTMLElement {
1073
1218
  constructor() {
1074
1219
  super();
1075
- x(this, "shadowRoot");
1220
+ b(this, "shadowRoot");
1076
1221
  /**
1077
1222
  * Apply JSON items to itemfilter.
1078
1223
  * @param json
1079
1224
  */
1080
- x(this, "apply");
1081
- /**
1082
- * The filter properties.
1083
- * @param filterProperties
1084
- */
1085
- x(this, "filterProperties");
1086
- x(this, "items");
1087
- x(this, "fuse");
1225
+ b(this, "apply");
1226
+ b(this, "items");
1227
+ b(this, "fuse");
1088
1228
  // TODO proper typing
1089
- x(this, "filters");
1090
- x(this, "aggregateBy");
1091
- /**
1092
- * Aggregate results by a property key
1093
- */
1094
- x(this, "aggregateResults");
1095
- /**
1096
- * Native fuse.js config override
1097
- */
1098
- x(this, "fuseConfig");
1099
- this.filters = {}, this.shadowRoot = this.attachShadow({ mode: "open" }), this.shadowRoot.appendChild(ht.content.cloneNode(!0)), this.apply = (r) => {
1100
- this.items = r, this.fuse = new N(this.items, {
1229
+ b(this, "filters");
1230
+ b(this, "aggregateBy");
1231
+ b(this, "config");
1232
+ this.filters = {}, this.shadowRoot = this.attachShadow({ mode: "open" });
1233
+ const t = document.createElement("template");
1234
+ t.innerHTML = Je, this.shadowRoot.appendChild(t.content.cloneNode(!0)), this.apply = (n) => {
1235
+ this.config.enableSearch && (this.shadowRoot.querySelector("input[type=text").style.display = "block"), this.items = n, this.fuse = new $(this.items, {
1101
1236
  minMatchCharLength: 1,
1102
1237
  includeMatches: !0,
1103
1238
  // Search in same fields as specified by filter properties, plus name
1104
1239
  // @ts-ignore
1105
- keys: ["name", ...this.filterProperties],
1240
+ keys: ["name", ...this.config.filterProperties],
1106
1241
  useExtendedSearch: !0,
1107
- ...this.fuseConfig
1108
- }), this.filterProperties.forEach((i) => {
1109
- const c = [
1242
+ ...this.config.fuseConfig
1243
+ }), this.config.filterProperties.forEach((o) => {
1244
+ const l = [
1110
1245
  ...new Set(
1111
- this.items.reduce((a, h) => a.concat(h[i]), [])
1246
+ this.items.reduce((f, g) => f.concat(g[o]), [])
1112
1247
  )
1113
- ].sort(), o = this.shadowRoot.querySelector("ul#filters");
1114
- c.forEach((a) => {
1115
- const h = document.createElement("template");
1116
- h.innerHTML = te;
1117
- const l = h.content.cloneNode(!0);
1118
- 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);
1119
- }), this.aggregateResults === i && (this.aggregateBy = c);
1120
- }), s();
1248
+ ].sort(), a = this.shadowRoot.querySelector("ul#filters"), h = document.createElement("template");
1249
+ h.innerHTML = et;
1250
+ const u = h.content.cloneNode(!0);
1251
+ u.querySelector(".title").innerHTML = o, u.querySelector("details").setAttribute("data-filter", o), a.appendChild(u), l.forEach((f) => {
1252
+ const g = document.createElement("template");
1253
+ g.innerHTML = Ze;
1254
+ const p = g.content.cloneNode(!0), m = p.querySelector("input[type='checkbox']");
1255
+ m.setAttribute("data-filter-key", o), m.setAttribute("name", "filter"), this.config.exclusiveFilters === !0 && (m.type = "radio"), m.setAttribute("data-filter-value", f), p.querySelector("span.title").innerHTML = f, this.shadowRoot.querySelector(`details[data-filter='${o}']`).appendChild(p);
1256
+ }), this.config.aggregateResults === o && (this.aggregateBy = l);
1257
+ }), r(), this.config.matchAllWhenEmpty !== !1 && i(this.items);
1121
1258
  };
1122
- const s = () => {
1123
- this.shadowRoot.querySelectorAll("input[type='checkbox']").forEach((r) => {
1124
- r.addEventListener("click", (i) => {
1125
- const c = i.target, o = c.getAttribute("data-filter-key"), a = c.getAttribute("data-filter-value");
1126
- c.checked ? (this.filters[o] || (this.filters[o] = []), this.filters[o].push(a)) : (this.filters[o].splice(
1127
- // @ts-ignore
1128
- this.filters[o].indexOf(a),
1129
- 1
1130
- ), this.filters[o].length === 0 && delete this.filters[o]), n(
1259
+ const r = () => {
1260
+ const n = this.shadowRoot.querySelectorAll(
1261
+ `input[type="${this.config.exclusiveFilters === !0 ? "radio" : "checkbox"}"]`
1262
+ ), o = (l) => {
1263
+ n.forEach((a) => {
1264
+ var f, g;
1265
+ const h = a.getAttribute("data-filter-key"), u = a.getAttribute("data-filter-value");
1266
+ if (a.checked)
1267
+ this.filters[h] || (this.filters[h] = []), this.filters[h].includes(u) || this.filters[h].push(u);
1268
+ else {
1269
+ if (l === a) {
1270
+ if (!this.filters[h])
1271
+ return;
1272
+ this.filters[h].splice(
1273
+ // @ts-ignore
1274
+ this.filters[h].indexOf(u),
1275
+ 1
1276
+ );
1277
+ } else
1278
+ this.config.exclusiveFilters === !0 && // @ts-ignore
1279
+ this.filters[h] && // @ts-ignore
1280
+ this.filters[h].includes(u) && ((f = this.filters[h]) == null || f.splice(
1281
+ // @ts-ignore
1282
+ this.filters[h].indexOf(u),
1283
+ 1
1284
+ ));
1285
+ ((g = this.filters[h]) == null ? void 0 : g.length) === 0 && delete this.filters[h];
1286
+ }
1287
+ });
1288
+ };
1289
+ n.forEach((l) => {
1290
+ l.addEventListener("click", (a) => {
1291
+ o(a.target), this.config.matchAllWhenEmpty !== !1 && Object.keys(this.filters).length === 0 ? i(this.items) : c(
1131
1292
  // @ts-ignore
1132
1293
  this.shadowRoot.querySelector("input[type='text']").value
1133
1294
  );
1134
1295
  });
1135
1296
  });
1136
- }, n = (r, i = this.filters) => {
1137
- const c = Object.entries(i).reduce(
1138
- (h, [l, u]) => {
1139
- const d = (g) => {
1140
- const p = {};
1141
- p[l] = `=${g}`, h.push(p);
1142
- };
1143
- return Array.isArray(u) ? u.forEach((g) => d(g)) : d(u), h;
1144
- },
1145
- []
1146
- ), o = se(
1147
- this.fuse.search({
1148
- ...r.length && Object.keys(c).length ? {
1149
- $and: [
1150
- { name: r },
1151
- {
1152
- $or: c
1153
- }
1154
- ]
1155
- } : {
1156
- $or: [
1157
- { name: r },
1158
- {
1159
- $or: c
1160
- }
1161
- ]
1162
- }
1163
- })
1164
- ), a = this.shadowRoot.querySelector("ul#results");
1165
- if (a.innerHTML = "", this.aggregateResults) {
1166
- const h = document.createElement("template");
1167
- h.innerHTML = ee, this.aggregateBy.forEach((l) => {
1297
+ }, i = (n) => {
1298
+ const o = this.shadowRoot.querySelector("ul#results");
1299
+ if (o.innerHTML = "", this.config.aggregateResults) {
1300
+ const l = document.createElement("template");
1301
+ l.innerHTML = st, this.aggregateBy.forEach((a) => {
1168
1302
  if (
1169
1303
  // @ts-ignore
1170
- !o.find(
1171
- (d) => Array.isArray(d[this.aggregateResults]) ? d[this.aggregateResults].includes(l) : d[this.aggregateResults] === l
1304
+ !n.find(
1305
+ (u) => Array.isArray(u[this.config.aggregateResults]) ? u[this.config.aggregateResults].includes(a) : u[this.config.aggregateResults] === a
1172
1306
  )
1173
1307
  )
1174
1308
  return;
1175
- const u = h.content.cloneNode(!0);
1176
- u.querySelector("summary").innerHTML = l, u.querySelector("details").setAttribute("data-aggregate", l), a.appendChild(u);
1309
+ const h = l.content.cloneNode(!0);
1310
+ h.querySelector("summary .title").innerHTML = a, h.querySelector("details").setAttribute("data-aggregate", a), o.appendChild(h);
1177
1311
  });
1178
1312
  }
1179
- o.forEach((h) => {
1313
+ n.forEach((l) => {
1314
+ const a = document.createElement("template");
1315
+ a.innerHTML = tt;
1316
+ const h = a.content.cloneNode(!0);
1317
+ h.querySelector(".title").innerHTML = l.name;
1318
+ let u;
1180
1319
  if (this.aggregateBy) {
1181
- const l = h[this.aggregateResults];
1182
- if (Array.isArray(l))
1183
- l.forEach((u) => {
1184
- const d = document.createElement("li");
1185
- d.innerHTML = h.name, this.shadowRoot.querySelector(`details[data-aggregate=${u}]`).appendChild(d);
1186
- });
1187
- else {
1188
- const u = document.createElement("li");
1189
- u.innerHTML = h.name, this.shadowRoot.querySelector(`details[data-aggregate=${l}]`).appendChild(u);
1190
- }
1191
- } else {
1192
- const l = document.createElement("li");
1193
- l.innerHTML = h.name, a.appendChild(l);
1194
- }
1320
+ const f = l[this.config.aggregateResults];
1321
+ Array.isArray(f) ? f.forEach((g) => {
1322
+ u = this.shadowRoot.querySelector(
1323
+ `details[data-aggregate=${g}]`
1324
+ );
1325
+ }) : u = this.shadowRoot.querySelector(
1326
+ `details[data-aggregate=${f}]`
1327
+ );
1328
+ } else
1329
+ u = o;
1330
+ h.querySelector("input").addEventListener("click", () => {
1331
+ this.config.onSelect && this.config.onSelect(l);
1332
+ }), u.appendChild(h);
1333
+ }), this.config.aggregateResults && this.shadowRoot.querySelectorAll("#results details").forEach((a) => {
1334
+ a.querySelector("summary .count").innerHTML = a.querySelectorAll("li").length;
1195
1335
  });
1336
+ }, c = (n, o = this.filters) => {
1337
+ const l = Object.entries(o).reduce(
1338
+ (u, [f, g]) => {
1339
+ const p = (m) => {
1340
+ const E = {};
1341
+ E[f] = `=${m}`, u.push(E);
1342
+ };
1343
+ return Array.isArray(g) ? g.forEach((m) => p(m)) : p(g), u;
1344
+ },
1345
+ []
1346
+ ), a = this.fuse.search({
1347
+ ...n.length && Object.keys(l).length ? {
1348
+ $and: [
1349
+ { name: n },
1350
+ {
1351
+ $or: l
1352
+ }
1353
+ ]
1354
+ } : {
1355
+ $or: [
1356
+ { name: n },
1357
+ {
1358
+ $or: l
1359
+ }
1360
+ ]
1361
+ }
1362
+ }), h = this.config.enableHighlighting ? it(a) : (
1363
+ // @ts-ignore
1364
+ a.map((u) => u.item)
1365
+ );
1366
+ i(h);
1196
1367
  };
1197
- this.shadowRoot.querySelector("input[type='text']").addEventListener("input", (r) => {
1198
- n(r.target.value);
1368
+ this.shadowRoot.querySelector("input[type='text']").addEventListener("input", (n) => {
1369
+ const o = n.target.value;
1370
+ !o && this.config.matchAllWhenEmpty !== !1 ? i(this.items) : c(o);
1199
1371
  });
1200
1372
  }
1201
1373
  }
1202
- customElements.define("eox-itemfilter", re);
1374
+ customElements.define("eox-itemfilter", rt);
1203
1375
  export {
1204
- re as EOxItemFilter
1376
+ rt as EOxItemFilter
1205
1377
  };