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