New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@eox/itemfilter

Package Overview
Dependencies
Maintainers
5
Versions
61
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@eox/itemfilter - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

1606

dist/eox-itemfilter.js
var ut = Object.defineProperty;
var ft = (s, t, e) =>
t in s
? ut(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e })
: (s[t] = e);
var A = (s, t, e) => (ft(s, typeof t != "symbol" ? t + "" : t, e), e);
function I(s) {
return Array.isArray ? Array.isArray(s) : st(s) === "[object Array]";
var ft = (e, t, s) => t in e ? ut(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s;
var x = (e, t, s) => (ft(e, typeof t != "symbol" ? t + "" : t, s), s);
function A(e) {
return Array.isArray ? Array.isArray(e) : st(e) === "[object Array]";
}
const dt = 1 / 0;
function gt(s) {
if (typeof s == "string") return s;
let t = s + "";
return t == "0" && 1 / s == -dt ? "-0" : t;
function gt(e) {
if (typeof e == "string")
return e;
let t = e + "";
return t == "0" && 1 / e == -dt ? "-0" : t;
}
function pt(s) {
return s == null ? "" : gt(s);
function pt(e) {
return e == null ? "" : gt(e);
}
function x(s) {
return typeof s == "string";
function S(e) {
return typeof e == "string";
}
function tt(s) {
return typeof s == "number";
function tt(e) {
return typeof e == "number";
}
function mt(s) {
return s === !0 || s === !1 || (yt(s) && st(s) == "[object Boolean]");
function mt(e) {
return e === !0 || e === !1 || yt(e) && st(e) == "[object Boolean]";
}
function et(s) {
return typeof s == "object";
function et(e) {
return typeof e == "object";
}
function yt(s) {
return et(s) && s !== null;
function yt(e) {
return et(e) && e !== null;
}
function y(s) {
return s != null;
function m(e) {
return e != null;
}
function H(s) {
return !s.trim().length;
function H(e) {
return !e.trim().length;
}
function st(s) {
return s == null
? s === void 0
? "[object Undefined]"
: "[object Null]"
: Object.prototype.toString.call(s);
function st(e) {
return e == null ? e === void 0 ? "[object Undefined]" : "[object Null]" : Object.prototype.toString.call(e);
}
const Mt = "Incorrect 'index' type",
Et = (s) => `Invalid value for key ${s}`,
xt = (s) => `Pattern length exceeds max of ${s}.`,
St = (s) => `Missing ${s} property in key`,
At = (s) => `Property 'weight' in key '${s}' must be a positive integer`,
Q = Object.prototype.hasOwnProperty;
class It {
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;
class At {
constructor(t) {
(this._keys = []), (this._keyMap = {});
let e = 0;
this._keys = [], this._keyMap = {};
let s = 0;
t.forEach((n) => {
let r = rt(n);
(e += r.weight),
this._keys.push(r),
(this._keyMap[r.id] = r),
(e += r.weight);
}),
this._keys.forEach((n) => {
n.weight /= e;
});
s += r.weight, this._keys.push(r), this._keyMap[r.id] = r, s += r.weight;
}), this._keys.forEach((n) => {
n.weight /= s;
});
}

@@ -78,125 +63,116 @@ get(t) {

}
function rt(s) {
let t = null,
e = null,
n = null,
r = 1,
i = null;
if (x(s) || I(s)) (n = s), (t = X(s)), (e = K(s));
function rt(e) {
let t = null, s = null, n = null, r = 1, i = null;
if (S(e) || A(e))
n = e, t = X(e), s = K(e);
else {
if (!Q.call(s, "name")) throw new Error(St("name"));
const c = s.name;
if (((n = c), Q.call(s, "weight") && ((r = s.weight), r <= 0)))
throw new Error(At(c));
(t = X(c)), (e = K(c)), (i = s.getFn);
if (!Q.call(e, "name"))
throw new Error(St("name"));
const c = e.name;
if (n = c, Q.call(e, "weight") && (r = e.weight, r <= 0))
throw new Error(It(c));
t = X(c), s = K(c), i = e.getFn;
}
return { path: t, id: e, weight: r, src: n, getFn: i };
return { path: t, id: s, weight: r, src: n, getFn: i };
}
function X(s) {
return I(s) ? s : s.split(".");
function X(e) {
return A(e) ? e : e.split(".");
}
function K(s) {
return I(s) ? s.join(".") : s;
function K(e) {
return A(e) ? e.join(".") : e;
}
function _t(s, t) {
let e = [],
n = !1;
function _t(e, t) {
let s = [], n = !1;
const r = (i, c, o) => {
if (y(i))
if (!c[o]) e.push(i);
if (m(i))
if (!c[o])
s.push(i);
else {
let a = c[o];
const h = i[a];
if (!y(h)) return;
if (o === c.length - 1 && (x(h) || tt(h) || mt(h))) e.push(pt(h));
else if (I(h)) {
if (!m(h))
return;
if (o === c.length - 1 && (S(h) || tt(h) || mt(h)))
s.push(pt(h));
else if (A(h)) {
n = !0;
for (let l = 0, u = h.length; l < u; l += 1) r(h[l], c, o + 1);
} else c.length && r(h, c, o + 1);
for (let l = 0, u = h.length; l < u; l += 1)
r(h[l], c, o + 1);
} else
c.length && r(h, c, o + 1);
}
};
return r(s, x(t) ? t.split(".") : t, 0), n ? e : e[0];
return r(e, S(t) ? t.split(".") : t, 0), n ? s : s[0];
}
const wt = {
// Whether the matches should be included in the result set. When `true`, each record in the result
// set will include the indices of the matched characters.
// These can consequently be used for highlighting purposes.
includeMatches: !1,
// When `true`, the matching function will continue to the end of a search pattern even if
// a perfect match has already been located in the string.
findAllMatches: !1,
// Minimum number of characters that must be matched before a result is considered a match
minMatchCharLength: 1,
},
Lt = {
// When `true`, the algorithm continues searching to the end of the input even if a perfect
// match is found before the end of the same input.
isCaseSensitive: !1,
// When true, the matching function will continue to the end of a search pattern even if
includeScore: !1,
// List of properties that will be searched. This also supports nested properties.
keys: [],
// Whether to sort the result list, by score
shouldSort: !0,
// Default sort function: sort by ascending score, ascending index
sortFn: (s, t) =>
s.score === t.score
? s.idx < t.idx
? -1
: 1
: s.score < t.score
? -1
: 1,
},
bt = {
// Approximately where in the text is the pattern expected to be found?
location: 0,
// At what point does the match algorithm give up. A threshold of '0.0' requires a perfect match
// (of both letters and location), a threshold of '1.0' would match anything.
threshold: 0.6,
// Determines how close the match must be to the fuzzy location (specified above).
// An exact letter match which is 'distance' characters away from the fuzzy location
// would score as a complete mismatch. A distance of '0' requires the match be at
// the exact location specified, a threshold of '1000' would require a perfect match
// to be within 800 characters of the fuzzy location to be found using a 0.8 threshold.
distance: 100,
},
Rt = {
// When `true`, it enables the use of unix-like search commands
useExtendedSearch: !1,
// The get function to use when fetching an object's properties.
// The default will search nested paths *ie foo.bar.baz*
getFn: _t,
// When `true`, search will ignore `location` and `distance`, so it won't matter
// where in the string the pattern appears.
// More info: https://fusejs.io/concepts/scoring-theory.html#fuzziness-score
ignoreLocation: !1,
// When `true`, the calculation for the relevance score (used for sorting) will
// ignore the field-length norm.
// More info: https://fusejs.io/concepts/scoring-theory.html#field-length-norm
ignoreFieldNorm: !1,
// The weight to determine how much field length norm effects scoring.
fieldNormWeight: 1,
};
var d = {
// Whether the matches should be included in the result set. When `true`, each record in the result
// set will include the indices of the matched characters.
// These can consequently be used for highlighting purposes.
includeMatches: !1,
// When `true`, the matching function will continue to the end of a search pattern even if
// a perfect match has already been located in the string.
findAllMatches: !1,
// Minimum number of characters that must be matched before a result is considered a match
minMatchCharLength: 1
}, Lt = {
// When `true`, the algorithm continues searching to the end of the input even if a perfect
// match is found before the end of the same input.
isCaseSensitive: !1,
// When true, the matching function will continue to the end of a search pattern even if
includeScore: !1,
// List of properties that will be searched. This also supports nested properties.
keys: [],
// Whether to sort the result list, by score
shouldSort: !0,
// Default sort function: sort by ascending score, ascending index
sortFn: (e, t) => e.score === t.score ? e.idx < t.idx ? -1 : 1 : e.score < t.score ? -1 : 1
}, Rt = {
// Approximately where in the text is the pattern expected to be found?
location: 0,
// At what point does the match algorithm give up. A threshold of '0.0' requires a perfect match
// (of both letters and location), a threshold of '1.0' would match anything.
threshold: 0.6,
// Determines how close the match must be to the fuzzy location (specified above).
// An exact letter match which is 'distance' characters away from the fuzzy location
// would score as a complete mismatch. A distance of '0' requires the match be at
// the exact location specified, a threshold of '1000' would require a perfect match
// to be within 800 characters of the fuzzy location to be found using a 0.8 threshold.
distance: 100
}, bt = {
// When `true`, it enables the use of unix-like search commands
useExtendedSearch: !1,
// The get function to use when fetching an object's properties.
// The default will search nested paths *ie foo.bar.baz*
getFn: _t,
// When `true`, search will ignore `location` and `distance`, so it won't matter
// where in the string the pattern appears.
// More info: https://fusejs.io/concepts/scoring-theory.html#fuzziness-score
ignoreLocation: !1,
// When `true`, the calculation for the relevance score (used for sorting) will
// ignore the field-length norm.
// More info: https://fusejs.io/concepts/scoring-theory.html#field-length-norm
ignoreFieldNorm: !1,
// The weight to determine how much field length norm effects scoring.
fieldNormWeight: 1
};
var f = {
...Lt,
...wt,
...bt,
...Rt,
...bt
};
const kt = /[^ ]+/g;
function Tt(s = 1, t = 3) {
const e = /* @__PURE__ */ new Map(),
n = Math.pow(10, t);
function Tt(e = 1, t = 3) {
const s = /* @__PURE__ */ new Map(), n = Math.pow(10, t);
return {
get(r) {
const i = r.match(kt).length;
if (e.has(i)) return e.get(i);
const c = 1 / Math.pow(i, 0.5 * s),
o = parseFloat(Math.round(c * n) / n);
return e.set(i, o), o;
if (s.has(i))
return s.get(i);
const c = 1 / Math.pow(i, 0.5 * e), o = parseFloat(Math.round(c * n) / n);
return s.set(i, o), o;
},
clear() {
e.clear();
},
s.clear();
}
};

@@ -206,9 +182,6 @@ }

constructor({
getFn: t = d.getFn,
fieldNormWeight: e = d.fieldNormWeight,
getFn: t = f.getFn,
fieldNormWeight: s = f.fieldNormWeight
} = {}) {
(this.norm = Tt(e, 3)),
(this.getFn = t),
(this.isCreated = !1),
this.setIndexRecords();
this.norm = Tt(s, 3), this.getFn = t, this.isCreated = !1, this.setIndexRecords();
}

@@ -222,25 +195,17 @@ setSources(t = []) {

setKeys(t = []) {
(this.keys = t),
(this._keysMap = {}),
t.forEach((e, n) => {
this._keysMap[e.id] = n;
});
this.keys = t, this._keysMap = {}, t.forEach((s, n) => {
this._keysMap[s.id] = n;
});
}
create() {
this.isCreated ||
!this.docs.length ||
((this.isCreated = !0),
x(this.docs[0])
? this.docs.forEach((t, e) => {
this._addString(t, e);
})
: this.docs.forEach((t, e) => {
this._addObject(t, e);
}),
this.norm.clear());
this.isCreated || !this.docs.length || (this.isCreated = !0, S(this.docs[0]) ? this.docs.forEach((t, s) => {
this._addString(t, s);
}) : this.docs.forEach((t, s) => {
this._addObject(t, s);
}), this.norm.clear());
}
// Adds a doc to the end of the index
add(t) {
const e = this.size();
x(t) ? this._addString(t, e) : this._addObject(t, e);
const s = this.size();
S(t) ? this._addString(t, s) : this._addObject(t, s);
}

@@ -250,6 +215,7 @@ // Removes the doc at the specified index of the index

this.records.splice(t, 1);
for (let e = t, n = this.size(); e < n; e += 1) this.records[e].i -= 1;
for (let s = t, n = this.size(); s < n; s += 1)
this.records[s].i -= 1;
}
getValueForItemAtKeyId(t, e) {
return t[this._keysMap[e]];
getValueForItemAtKeyId(t, s) {
return t[this._keysMap[s]];
}

@@ -259,17 +225,18 @@ size() {

}
_addString(t, e) {
if (!y(t) || H(t)) return;
_addString(t, s) {
if (!m(t) || H(t))
return;
let n = {
v: t,
i: e,
n: this.norm.get(t),
i: s,
n: this.norm.get(t)
};
this.records.push(n);
}
_addObject(t, e) {
let n = { i: e, $: {} };
_addObject(t, s) {
let n = { i: s, $: {} };
this.keys.forEach((r, i) => {
let c = r.getFn ? r.getFn(t) : this.getFn(t, r.path);
if (y(c)) {
if (I(c)) {
if (m(c)) {
if (A(c)) {
let o = [];

@@ -279,24 +246,23 @@ const a = [{ nestedArrIndex: -1, value: c }];

const { nestedArrIndex: h, value: l } = a.pop();
if (y(l))
if (x(l) && !H(l)) {
if (m(l))
if (S(l) && !H(l)) {
let u = {
v: l,
i: h,
n: this.norm.get(l),
n: this.norm.get(l)
};
o.push(u);
} else
I(l) &&
l.forEach((u, f) => {
a.push({
nestedArrIndex: f,
value: u,
});
A(l) && l.forEach((u, d) => {
a.push({
nestedArrIndex: d,
value: u
});
});
}
n.$[i] = o;
} else if (x(c) && !H(c)) {
} else if (S(c) && !H(c)) {
let o = {
v: c,
n: this.norm.get(c),
n: this.norm.get(c)
};

@@ -306,4 +272,3 @@ n.$[i] = o;

}
}),
this.records.push(n);
}), this.records.push(n);
}

@@ -313,142 +278,101 @@ toJSON() {

keys: this.keys,
records: this.records,
records: this.records
};
}
}
function nt(
s,
t,
{ getFn: e = d.getFn, fieldNormWeight: n = d.fieldNormWeight } = {}
) {
const r = new Y({ getFn: e, fieldNormWeight: n });
return r.setKeys(s.map(rt)), r.setSources(t), r.create(), r;
function nt(e, t, { getFn: s = f.getFn, fieldNormWeight: n = f.fieldNormWeight } = {}) {
const r = new Y({ getFn: s, fieldNormWeight: n });
return r.setKeys(e.map(rt)), r.setSources(t), r.create(), r;
}
function $t(
s,
{ getFn: t = d.getFn, fieldNormWeight: e = d.fieldNormWeight } = {}
) {
const { keys: n, records: r } = s,
i = new Y({ getFn: t, fieldNormWeight: e });
function $t(e, { getFn: t = f.getFn, fieldNormWeight: s = f.fieldNormWeight } = {}) {
const { keys: n, records: r } = e, i = new Y({ getFn: t, fieldNormWeight: s });
return i.setKeys(n), i.setIndexRecords(r), i;
}
function v(
s,
{
errors: t = 0,
currentLocation: e = 0,
expectedLocation: n = 0,
distance: r = d.distance,
ignoreLocation: i = d.ignoreLocation,
} = {}
) {
const c = t / s.length;
if (i) return c;
const o = Math.abs(n - e);
function v(e, {
errors: t = 0,
currentLocation: s = 0,
expectedLocation: n = 0,
distance: r = f.distance,
ignoreLocation: i = f.ignoreLocation
} = {}) {
const c = t / e.length;
if (i)
return c;
const o = Math.abs(n - s);
return r ? c + o / r : o ? 1 : c;
}
function Nt(s = [], t = d.minMatchCharLength) {
let e = [],
n = -1,
r = -1,
i = 0;
for (let c = s.length; i < c; i += 1) {
let o = s[i];
o && n === -1
? (n = i)
: !o &&
n !== -1 &&
((r = i - 1), r - n + 1 >= t && e.push([n, r]), (n = -1));
function Nt(e = [], t = f.minMatchCharLength) {
let s = [], n = -1, r = -1, i = 0;
for (let c = e.length; i < c; i += 1) {
let o = e[i];
o && n === -1 ? n = i : !o && n !== -1 && (r = i - 1, r - n + 1 >= t && s.push([n, r]), n = -1);
}
return s[i - 1] && i - n >= t && e.push([n, i - 1]), e;
return e[i - 1] && i - n >= t && s.push([n, i - 1]), s;
}
const k = 32;
function Ot(
s,
t,
e,
{
location: n = d.location,
distance: r = d.distance,
threshold: i = d.threshold,
findAllMatches: c = d.findAllMatches,
minMatchCharLength: o = d.minMatchCharLength,
includeMatches: a = d.includeMatches,
ignoreLocation: h = d.ignoreLocation,
} = {}
) {
if (t.length > k) throw new Error(xt(k));
const l = t.length,
u = s.length,
f = Math.max(0, Math.min(n, u));
let g = i,
p = f;
const m = o > 1 || a,
b = m ? Array(u) : [];
let S;
for (; (S = s.indexOf(t, p)) > -1; ) {
function Ot(e, t, s, {
location: n = f.location,
distance: r = f.distance,
threshold: i = f.threshold,
findAllMatches: c = f.findAllMatches,
minMatchCharLength: o = f.minMatchCharLength,
includeMatches: a = f.includeMatches,
ignoreLocation: h = f.ignoreLocation
} = {}) {
if (t.length > k)
throw new Error(xt(k));
const l = t.length, u = e.length, d = Math.max(0, Math.min(n, u));
let g = i, p = d;
const y = o > 1 || a, R = y ? Array(u) : [];
let I;
for (; (I = e.indexOf(t, p)) > -1; ) {
let M = v(t, {
currentLocation: S,
expectedLocation: f,
currentLocation: I,
expectedLocation: d,
distance: r,
ignoreLocation: h,
ignoreLocation: h
});
if (((g = Math.min(M, g)), (p = S + l), m)) {
if (g = Math.min(M, g), p = I + l, y) {
let _ = 0;
for (; _ < l; ) (b[S + _] = 1), (_ += 1);
for (; _ < l; )
R[I + _] = 1, _ += 1;
}
}
p = -1;
let T = [],
R = 1,
O = l + u;
const lt = 1 << (l - 1);
let T = [], b = 1, O = l + u;
const lt = 1 << l - 1;
for (let M = 0; M < l; M += 1) {
let _ = 0,
w = O;
let _ = 0, w = O;
for (; _ < w; )
v(t, {
errors: M,
currentLocation: f + w,
expectedLocation: f,
currentLocation: d + w,
expectedLocation: d,
distance: r,
ignoreLocation: h,
}) <= g
? (_ = w)
: (O = w),
(w = Math.floor((O - _) / 2 + _));
ignoreLocation: h
}) <= g ? _ = w : O = w, w = Math.floor((O - _) / 2 + _);
O = w;
let G = Math.max(1, f - w + 1),
j = c ? u : Math.min(f + w, u) + l,
$ = Array(j + 2);
let G = Math.max(1, d - w + 1), j = c ? u : Math.min(d + w, u) + l, $ = Array(j + 2);
$[j + 1] = (1 << M) - 1;
for (let E = j; E >= G; E -= 1) {
let C = E - 1,
U = e[s.charAt(C)];
if (
(m && (b[C] = +!!U),
($[E] = (($[E + 1] << 1) | 1) & U),
M && ($[E] |= ((T[E + 1] | T[E]) << 1) | 1 | T[E + 1]),
$[E] & lt &&
((R = v(t, {
errors: M,
currentLocation: C,
expectedLocation: f,
distance: r,
ignoreLocation: h,
})),
R <= g))
) {
if (((g = R), (p = C), p <= f)) break;
G = Math.max(1, 2 * f - p);
let C = E - 1, U = s[e.charAt(C)];
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, {
errors: M,
currentLocation: C,
expectedLocation: d,
distance: r,
ignoreLocation: h
}), b <= g)) {
if (g = b, p = C, p <= d)
break;
G = Math.max(1, 2 * d - p);
}
}
if (
v(t, {
errors: M + 1,
currentLocation: f,
expectedLocation: f,
distance: r,
ignoreLocation: h,
}) > g
)
if (v(t, {
errors: M + 1,
currentLocation: d,
expectedLocation: d,
distance: r,
ignoreLocation: h
}) > g)
break;

@@ -460,15 +384,15 @@ T = $;

// Count exact matches (those with a score of 0) to be "almost" exact
score: Math.max(1e-3, R),
score: Math.max(1e-3, b)
};
if (m) {
const M = Nt(b, o);
M.length ? a && (P.indices = M) : (P.isMatch = !1);
if (y) {
const M = Nt(R, o);
M.length ? a && (P.indices = M) : P.isMatch = !1;
}
return P;
}
function Ct(s) {
function Ct(e) {
let t = {};
for (let e = 0, n = s.length; e < n; e += 1) {
const r = s.charAt(e);
t[r] = (t[r] || 0) | (1 << (n - e - 1));
for (let s = 0, n = e.length; s < n; s += 1) {
const r = e.charAt(s);
t[r] = (t[r] || 0) | 1 << n - s - 1;
}

@@ -478,56 +402,48 @@ return t;

class it {
constructor(
t,
{
location: e = d.location,
threshold: n = d.threshold,
distance: r = d.distance,
includeMatches: i = d.includeMatches,
findAllMatches: c = d.findAllMatches,
minMatchCharLength: o = d.minMatchCharLength,
isCaseSensitive: a = d.isCaseSensitive,
ignoreLocation: h = d.ignoreLocation,
} = {}
) {
if (
((this.options = {
location: e,
threshold: n,
distance: r,
includeMatches: i,
findAllMatches: c,
minMatchCharLength: o,
isCaseSensitive: a,
ignoreLocation: h,
}),
(this.pattern = a ? t : t.toLowerCase()),
(this.chunks = []),
!this.pattern.length)
)
constructor(t, {
location: s = f.location,
threshold: n = f.threshold,
distance: r = f.distance,
includeMatches: i = f.includeMatches,
findAllMatches: c = f.findAllMatches,
minMatchCharLength: o = f.minMatchCharLength,
isCaseSensitive: a = f.isCaseSensitive,
ignoreLocation: h = f.ignoreLocation
} = {}) {
if (this.options = {
location: s,
threshold: n,
distance: r,
includeMatches: i,
findAllMatches: c,
minMatchCharLength: o,
isCaseSensitive: a,
ignoreLocation: h
}, this.pattern = a ? t : t.toLowerCase(), this.chunks = [], !this.pattern.length)
return;
const l = (f, g) => {
this.chunks.push({
pattern: f,
alphabet: Ct(f),
startIndex: g,
});
},
u = this.pattern.length;
const l = (d, g) => {
this.chunks.push({
pattern: d,
alphabet: Ct(d),
startIndex: g
});
}, u = this.pattern.length;
if (u > k) {
let f = 0;
const g = u % k,
p = u - g;
for (; f < p; ) l(this.pattern.substr(f, k), f), (f += k);
let d = 0;
const g = u % k, p = u - g;
for (; d < p; )
l(this.pattern.substr(d, k), d), d += k;
if (g) {
const m = u - k;
l(this.pattern.substr(m), m);
const y = u - k;
l(this.pattern.substr(y), y);
}
} else l(this.pattern, 0);
} else
l(this.pattern, 0);
}
searchIn(t) {
const { isCaseSensitive: e, includeMatches: n } = this.options;
if ((e || (t = t.toLowerCase()), this.pattern === t)) {
const { isCaseSensitive: s, includeMatches: n } = this.options;
if (s || (t = t.toLowerCase()), this.pattern === t) {
let p = {
isMatch: !0,
score: 0,
score: 0
};

@@ -542,14 +458,8 @@ return n && (p.indices = [[0, t.length - 1]]), p;

minMatchCharLength: a,
ignoreLocation: h,
ignoreLocation: h
} = this.options;
let l = [],
u = 0,
f = !1;
this.chunks.forEach(({ pattern: p, alphabet: m, startIndex: b }) => {
const {
isMatch: S,
score: T,
indices: R,
} = Ot(t, p, m, {
location: r + b,
let l = [], u = 0, d = !1;
this.chunks.forEach(({ pattern: p, alphabet: y, startIndex: R }) => {
const { isMatch: I, score: T, indices: b } = Ot(t, p, y, {
location: r + R,
distance: i,

@@ -560,11 +470,11 @@ threshold: c,

includeMatches: n,
ignoreLocation: h,
ignoreLocation: h
});
S && (f = !0), (u += T), S && R && (l = [...l, ...R]);
I && (d = !0), u += T, I && b && (l = [...l, ...b]);
});
let g = {
isMatch: f,
score: f ? u / this.chunks.length : 1,
isMatch: d,
score: d ? u / this.chunks.length : 1
};
return f && n && (g.indices = l), g;
return d && n && (g.indices = l), g;
}

@@ -582,7 +492,8 @@ }

}
search() {}
search() {
}
}
function J(s, t) {
const e = s.match(t);
return e ? e[1] : null;
function J(e, t) {
const s = e.match(t);
return s ? s[1] : null;
}

@@ -603,7 +514,7 @@ class vt extends L {

search(t) {
const e = t === this.pattern;
const s = t === this.pattern;
return {
isMatch: e,
score: e ? 0 : 1,
indices: [0, this.pattern.length - 1],
isMatch: s,
score: s ? 0 : 1,
indices: [0, this.pattern.length - 1]
};

@@ -630,3 +541,3 @@ }

score: n ? 0 : 1,
indices: [0, t.length - 1],
indices: [0, t.length - 1]
};

@@ -649,7 +560,7 @@ }

search(t) {
const e = t.startsWith(this.pattern);
const s = t.startsWith(this.pattern);
return {
isMatch: e,
score: e ? 0 : 1,
indices: [0, this.pattern.length - 1],
isMatch: s,
score: s ? 0 : 1,
indices: [0, this.pattern.length - 1]
};

@@ -672,7 +583,7 @@ }

search(t) {
const e = !t.startsWith(this.pattern);
const s = !t.startsWith(this.pattern);
return {
isMatch: e,
score: e ? 0 : 1,
indices: [0, t.length - 1],
isMatch: s,
score: s ? 0 : 1,
indices: [0, t.length - 1]
};

@@ -695,7 +606,7 @@ }

search(t) {
const e = t.endsWith(this.pattern);
const s = t.endsWith(this.pattern);
return {
isMatch: e,
score: e ? 0 : 1,
indices: [t.length - this.pattern.length, t.length - 1],
isMatch: s,
score: s ? 0 : 1,
indices: [t.length - this.pattern.length, t.length - 1]
};

@@ -718,7 +629,7 @@ }

search(t) {
const e = !t.endsWith(this.pattern);
const s = !t.endsWith(this.pattern);
return {
isMatch: e,
score: e ? 0 : 1,
indices: [0, t.length - 1],
isMatch: s,
score: s ? 0 : 1,
indices: [0, t.length - 1]
};

@@ -728,26 +639,22 @@ }

class ct extends L {
constructor(
t,
{
location: e = d.location,
threshold: n = d.threshold,
distance: r = d.distance,
includeMatches: i = d.includeMatches,
findAllMatches: c = d.findAllMatches,
minMatchCharLength: o = d.minMatchCharLength,
isCaseSensitive: a = d.isCaseSensitive,
ignoreLocation: h = d.ignoreLocation,
} = {}
) {
super(t),
(this._bitapSearch = new it(t, {
location: e,
threshold: n,
distance: r,
includeMatches: i,
findAllMatches: c,
minMatchCharLength: o,
isCaseSensitive: a,
ignoreLocation: h,
}));
constructor(t, {
location: s = f.location,
threshold: n = f.threshold,
distance: r = f.distance,
includeMatches: i = f.includeMatches,
findAllMatches: c = f.findAllMatches,
minMatchCharLength: o = f.minMatchCharLength,
isCaseSensitive: a = f.isCaseSensitive,
ignoreLocation: h = f.ignoreLocation
} = {}) {
super(t), this._bitapSearch = new it(t, {
location: s,
threshold: n,
distance: r,
includeMatches: i,
findAllMatches: c,
minMatchCharLength: o,
isCaseSensitive: a,
ignoreLocation: h
});
}

@@ -781,8 +688,6 @@ static get type() {

search(t) {
let e = 0,
n;
const r = [],
i = this.pattern.length;
for (; (n = t.indexOf(this.pattern, e)) > -1; )
(e = n + i), r.push([n, e - 1]);
let s = 0, n;
const r = [], i = this.pattern.length;
for (; (n = t.indexOf(this.pattern, s)) > -1; )
s = n + i, r.push([n, s - 1]);
const c = !!r.length;

@@ -792,25 +697,26 @@ return {

score: c ? 0 : 1,
indices: r,
indices: r
};
}
}
const B = [vt, ot, Pt, jt, Kt, Ht, Ft, ct],
q = B.length,
Bt = / +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,
Dt = "|";
function Wt(s, t = {}) {
return s.split(Dt).map((e) => {
let n = e
.trim()
.split(Bt)
.filter((i) => i && !!i.trim()),
r = [];
const B = [
vt,
ot,
Pt,
jt,
Kt,
Ht,
Ft,
ct
], q = B.length, Bt = / +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/, Dt = "|";
function Wt(e, t = {}) {
return e.split(Dt).map((s) => {
let n = s.trim().split(Bt).filter((i) => i && !!i.trim()), r = [];
for (let i = 0, c = n.length; i < c; i += 1) {
const o = n[i];
let a = !1,
h = -1;
let a = !1, h = -1;
for (; !a && ++h < q; ) {
const l = B[h];
let u = l.isMultiMatch(o);
u && (r.push(new l(u, t)), (a = !0));
u && (r.push(new l(u, t)), a = !0);
}

@@ -832,57 +738,48 @@ if (!a)

class Vt {
constructor(
t,
{
isCaseSensitive: e = d.isCaseSensitive,
includeMatches: n = d.includeMatches,
minMatchCharLength: r = d.minMatchCharLength,
ignoreLocation: i = d.ignoreLocation,
findAllMatches: c = d.findAllMatches,
location: o = d.location,
threshold: a = d.threshold,
distance: h = d.distance,
} = {}
) {
(this.query = null),
(this.options = {
isCaseSensitive: e,
includeMatches: n,
minMatchCharLength: r,
findAllMatches: c,
ignoreLocation: i,
location: o,
threshold: a,
distance: h,
}),
(this.pattern = e ? t : t.toLowerCase()),
(this.query = Wt(this.pattern, this.options));
constructor(t, {
isCaseSensitive: s = f.isCaseSensitive,
includeMatches: n = f.includeMatches,
minMatchCharLength: r = f.minMatchCharLength,
ignoreLocation: i = f.ignoreLocation,
findAllMatches: c = f.findAllMatches,
location: o = f.location,
threshold: a = f.threshold,
distance: h = f.distance
} = {}) {
this.query = null, this.options = {
isCaseSensitive: s,
includeMatches: n,
minMatchCharLength: r,
findAllMatches: c,
ignoreLocation: i,
location: o,
threshold: a,
distance: h
}, this.pattern = s ? t : t.toLowerCase(), this.query = Wt(this.pattern, this.options);
}
static condition(t, e) {
return e.useExtendedSearch;
static condition(t, s) {
return s.useExtendedSearch;
}
searchIn(t) {
const e = this.query;
if (!e)
const s = this.query;
if (!s)
return {
isMatch: !1,
score: 1,
score: 1
};
const { includeMatches: n, isCaseSensitive: r } = this.options;
t = r ? t : t.toLowerCase();
let i = 0,
c = [],
o = 0;
for (let a = 0, h = e.length; a < h; a += 1) {
const l = e[a];
(c.length = 0), (i = 0);
for (let u = 0, f = l.length; u < f; u += 1) {
const g = l[u],
{ isMatch: p, indices: m, score: b } = g.search(t);
let i = 0, c = [], o = 0;
for (let a = 0, h = s.length; a < h; a += 1) {
const l = s[a];
c.length = 0, i = 0;
for (let u = 0, d = l.length; u < d; u += 1) {
const g = l[u], { isMatch: p, indices: y, score: R } = g.search(t);
if (p) {
if (((i += 1), (o += b), n)) {
const S = g.constructor.type;
zt.has(S) ? (c = [...c, ...m]) : c.push(m);
if (i += 1, o += R, n) {
const I = g.constructor.type;
zt.has(I) ? c = [...c, ...y] : c.push(y);
}
} else {
(o = 0), (i = 0), (c.length = 0);
o = 0, i = 0, c.length = 0;
break;

@@ -894,3 +791,3 @@ }

isMatch: !0,
score: o / i,
score: o / i
};

@@ -902,3 +799,3 @@ return n && (u.indices = c), u;

isMatch: !1,
score: 1,
score: 1
};

@@ -908,143 +805,118 @@ }

const D = [];
function Yt(...s) {
D.push(...s);
function Yt(...e) {
D.push(...e);
}
function W(s, t) {
for (let e = 0, n = D.length; e < n; e += 1) {
let r = D[e];
if (r.condition(s, t)) return new r(s, t);
function W(e, t) {
for (let s = 0, n = D.length; s < n; s += 1) {
let r = D[s];
if (r.condition(e, t))
return new r(e, t);
}
return new it(s, t);
return new it(e, t);
}
const F = {
AND: "$and",
OR: "$or",
},
z = {
PATH: "$path",
PATTERN: "$val",
},
V = (s) => !!(s[F.AND] || s[F.OR]),
Gt = (s) => !!s[z.PATH],
Ut = (s) => !I(s) && et(s) && !V(s),
Z = (s) => ({
[F.AND]: Object.keys(s).map((t) => ({
[t]: s[t],
})),
});
function at(s, t, { auto: e = !0 } = {}) {
AND: "$and",
OR: "$or"
}, z = {
PATH: "$path",
PATTERN: "$val"
}, V = (e) => !!(e[F.AND] || e[F.OR]), Gt = (e) => !!e[z.PATH], Ut = (e) => !A(e) && et(e) && !V(e), Z = (e) => ({
[F.AND]: Object.keys(e).map((t) => ({
[t]: e[t]
}))
});
function at(e, t, { auto: s = !0 } = {}) {
const n = (r) => {
let i = Object.keys(r);
const c = Gt(r);
if (!c && i.length > 1 && !V(r)) return n(Z(r));
if (!c && i.length > 1 && !V(r))
return n(Z(r));
if (Ut(r)) {
const a = c ? r[z.PATH] : i[0],
h = c ? r[z.PATTERN] : r[a];
if (!x(h)) throw new Error(Et(a));
const a = c ? r[z.PATH] : i[0], h = c ? r[z.PATTERN] : r[a];
if (!S(h))
throw new Error(Et(a));
const l = {
keyId: K(a),
pattern: h,
pattern: h
};
return e && (l.searcher = W(h, t)), l;
return s && (l.searcher = W(h, t)), l;
}
let o = {
children: [],
operator: i[0],
operator: i[0]
};
return (
i.forEach((a) => {
const h = r[a];
I(h) &&
h.forEach((l) => {
o.children.push(n(l));
});
}),
o
);
return i.forEach((a) => {
const h = r[a];
A(h) && h.forEach((l) => {
o.children.push(n(l));
});
}), o;
};
return V(s) || (s = Z(s)), n(s);
return V(e) || (e = Z(e)), n(e);
}
function Qt(s, { ignoreFieldNorm: t = d.ignoreFieldNorm }) {
s.forEach((e) => {
function Qt(e, { ignoreFieldNorm: t = f.ignoreFieldNorm }) {
e.forEach((s) => {
let n = 1;
e.matches.forEach(({ key: r, norm: i, score: c }) => {
s.matches.forEach(({ key: r, norm: i, score: c }) => {
const o = r ? r.weight : null;
n *= Math.pow(c === 0 && o ? Number.EPSILON : c, (o || 1) * (t ? 1 : i));
}),
(e.score = n);
n *= Math.pow(
c === 0 && o ? Number.EPSILON : c,
(o || 1) * (t ? 1 : i)
);
}), s.score = n;
});
}
function Xt(s, t) {
const e = s.matches;
(t.matches = []),
y(e) &&
e.forEach((n) => {
if (!y(n.indices) || !n.indices.length) return;
const { indices: r, value: i } = n;
let c = {
indices: r,
value: i,
};
n.key && (c.key = n.key.src),
n.idx > -1 && (c.refIndex = n.idx),
t.matches.push(c);
});
function Xt(e, t) {
const s = e.matches;
t.matches = [], m(s) && s.forEach((n) => {
if (!m(n.indices) || !n.indices.length)
return;
const { indices: r, value: i } = n;
let c = {
indices: r,
value: i
};
n.key && (c.key = n.key.src), n.idx > -1 && (c.refIndex = n.idx), t.matches.push(c);
});
}
function Jt(s, t) {
t.score = s.score;
function Jt(e, t) {
t.score = e.score;
}
function qt(
s,
t,
{
includeMatches: e = d.includeMatches,
includeScore: n = d.includeScore,
} = {}
) {
function qt(e, t, {
includeMatches: s = f.includeMatches,
includeScore: n = f.includeScore
} = {}) {
const r = [];
return (
e && r.push(Xt),
n && r.push(Jt),
s.map((i) => {
const { idx: c } = i,
o = {
item: t[c],
refIndex: c,
};
return (
r.length &&
r.forEach((a) => {
a(i, o);
}),
o
);
})
);
return s && r.push(Xt), n && r.push(Jt), e.map((i) => {
const { idx: c } = i, o = {
item: t[c],
refIndex: c
};
return r.length && r.forEach((a) => {
a(i, o);
}), o;
});
}
class N {
constructor(t, e = {}, n) {
(this.options = { ...d, ...e }),
this.options.useExtendedSearch,
(this._keyStore = new It(this.options.keys)),
this.setCollection(t, n);
constructor(t, s = {}, n) {
this.options = { ...f, ...s }, this.options.useExtendedSearch, this._keyStore = new At(this.options.keys), this.setCollection(t, n);
}
setCollection(t, e) {
if (((this._docs = t), e && !(e instanceof Y))) throw new Error(Mt);
this._myIndex =
e ||
nt(this.options.keys, this._docs, {
getFn: this.options.getFn,
fieldNormWeight: this.options.fieldNormWeight,
});
setCollection(t, s) {
if (this._docs = t, s && !(s instanceof Y))
throw new Error(Mt);
this._myIndex = s || nt(this.options.keys, this._docs, {
getFn: this.options.getFn,
fieldNormWeight: this.options.fieldNormWeight
});
}
add(t) {
y(t) && (this._docs.push(t), this._myIndex.add(t));
m(t) && (this._docs.push(t), this._myIndex.add(t));
}
remove(t = () => !1) {
const e = [];
const s = [];
for (let n = 0, r = this._docs.length; n < r; n += 1) {
const i = this._docs[n];
t(i, n) && (this.removeAt(n), (n -= 1), (r -= 1), e.push(i));
t(i, n) && (this.removeAt(n), n -= 1, r -= 1, s.push(i));
}
return e;
return s;
}

@@ -1057,3 +929,3 @@ removeAt(t) {

}
search(t, { limit: e = -1 } = {}) {
search(t, { limit: s = -1 } = {}) {
const {

@@ -1064,130 +936,99 @@ includeMatches: n,

sortFn: c,
ignoreFieldNorm: o,
ignoreFieldNorm: o
} = this.options;
let a = x(t)
? x(this._docs[0])
? this._searchStringList(t)
: this._searchObjectList(t)
: this._searchLogical(t);
return (
Qt(a, { ignoreFieldNorm: o }),
i && a.sort(c),
tt(e) && e > -1 && (a = a.slice(0, e)),
qt(a, this._docs, {
includeMatches: n,
includeScore: r,
})
);
let a = S(t) ? S(this._docs[0]) ? this._searchStringList(t) : this._searchObjectList(t) : this._searchLogical(t);
return Qt(a, { ignoreFieldNorm: o }), i && a.sort(c), tt(s) && s > -1 && (a = a.slice(0, s)), qt(a, this._docs, {
includeMatches: n,
includeScore: r
});
}
_searchStringList(t) {
const e = W(t, this.options),
{ records: n } = this._myIndex,
r = [];
return (
n.forEach(({ v: i, i: c, n: o }) => {
if (!y(i)) return;
const { isMatch: a, score: h, indices: l } = e.searchIn(i);
a &&
r.push({
item: i,
idx: c,
matches: [{ score: h, value: i, norm: o, indices: l }],
});
}),
r
);
const s = W(t, this.options), { records: n } = this._myIndex, r = [];
return n.forEach(({ v: i, i: c, n: o }) => {
if (!m(i))
return;
const { isMatch: a, score: h, indices: l } = s.searchIn(i);
a && r.push({
item: i,
idx: c,
matches: [{ score: h, value: i, norm: o, indices: l }]
});
}), r;
}
_searchLogical(t) {
const e = at(t, this.options),
n = (o, a, h) => {
if (!o.children) {
const { keyId: u, searcher: f } = o,
g = this._findMatches({
key: this._keyStore.get(u),
value: this._myIndex.getValueForItemAtKeyId(a, u),
searcher: f,
});
return g && g.length
? [
{
idx: h,
item: a,
matches: g,
},
]
: [];
}
const l = [];
for (let u = 0, f = o.children.length; u < f; u += 1) {
const g = o.children[u],
p = n(g, a, h);
if (p.length) l.push(...p);
else if (o.operator === F.AND) return [];
}
return l;
},
r = this._myIndex.records,
i = {},
c = [];
return (
r.forEach(({ $: o, i: a }) => {
if (y(o)) {
let h = n(e, o, a);
h.length &&
(i[a] || ((i[a] = { idx: a, item: o, matches: [] }), c.push(i[a])),
h.forEach(({ matches: l }) => {
i[a].matches.push(...l);
}));
}
}),
c
);
const s = at(t, this.options), n = (o, a, h) => {
if (!o.children) {
const { keyId: u, searcher: d } = o, g = this._findMatches({
key: this._keyStore.get(u),
value: this._myIndex.getValueForItemAtKeyId(a, u),
searcher: d
});
return g && g.length ? [
{
idx: h,
item: a,
matches: g
}
] : [];
}
const l = [];
for (let u = 0, d = o.children.length; u < d; u += 1) {
const g = o.children[u], p = n(g, a, h);
if (p.length)
l.push(...p);
else if (o.operator === F.AND)
return [];
}
return l;
}, r = this._myIndex.records, i = {}, c = [];
return r.forEach(({ $: o, i: a }) => {
if (m(o)) {
let h = n(s, o, a);
h.length && (i[a] || (i[a] = { idx: a, item: o, matches: [] }, c.push(i[a])), h.forEach(({ matches: l }) => {
i[a].matches.push(...l);
}));
}
}), c;
}
_searchObjectList(t) {
const e = W(t, this.options),
{ keys: n, records: r } = this._myIndex,
i = [];
return (
r.forEach(({ $: c, i: o }) => {
if (!y(c)) return;
let a = [];
n.forEach((h, l) => {
a.push(
...this._findMatches({
key: h,
value: c[l],
searcher: e,
})
);
}),
a.length &&
i.push({
idx: o,
item: c,
matches: a,
});
}),
i
);
const s = W(t, this.options), { keys: n, records: r } = this._myIndex, i = [];
return r.forEach(({ $: c, i: o }) => {
if (!m(c))
return;
let a = [];
n.forEach((h, l) => {
a.push(
...this._findMatches({
key: h,
value: c[l],
searcher: s
})
);
}), a.length && i.push({
idx: o,
item: c,
matches: a
});
}), i;
}
_findMatches({ key: t, value: e, searcher: n }) {
if (!y(e)) return [];
_findMatches({ key: t, value: s, searcher: n }) {
if (!m(s))
return [];
let r = [];
if (I(e))
e.forEach(({ v: i, i: c, n: o }) => {
if (!y(i)) return;
if (A(s))
s.forEach(({ v: i, i: c, n: o }) => {
if (!m(i))
return;
const { isMatch: a, score: h, indices: l } = n.searchIn(i);
a &&
r.push({
score: h,
key: t,
value: i,
idx: c,
norm: o,
indices: l,
});
a && r.push({
score: h,
key: t,
value: i,
idx: c,
norm: o,
indices: l
});
});
else {
const { v: i, n: c } = e,
{ isMatch: o, score: a, indices: h } = n.searchIn(i);
const { v: i, n: c } = s, { isMatch: o, score: a, indices: h } = n.searchIn(i);
o && r.push({ score: a, key: t, value: i, norm: c, indices: h });

@@ -1201,3 +1042,3 @@ }

N.parseIndex = $t;
N.config = d;
N.config = f;
N.parseQuery = at;

@@ -1217,4 +1058,3 @@ Yt(Vt);

</div>
`,
te = `
`, te = `
<li>

@@ -1226,4 +1066,3 @@ <label>

</li>
`,
ee = `
`, ee = `
<details open>

@@ -1233,41 +1072,32 @@ <summary>TITLE</summar>

</details>
`,
se = (s, t = "highlight") => {
const e = (r, i, c) => {
const o = i.split(".");
let a;
for (a = 0; a < o.length - 1; a++) r = r[o[a]];
r[o[a]] = c;
},
n = (r, i = []) => {
let c = "",
o = 0;
return (
i.forEach((a) => {
const h = a[1] + 1;
(c += [
r.substring(o, a[0]),
`<mark class="${t}">`,
r.substring(a[0], h),
"</mark>",
].join("")),
(o = h);
}),
(c += r.substring(o)),
c
);
};
return s
.filter(({ matches: r }) => r && r.length)
.map(({ item: r, matches: i }) => {
const c = { ...r };
return (
i.forEach((o) => {
o.key === "name" && e(c, o.key, n(o.value, o.indices));
}),
c
);
});
},
ht = document.createElement("template");
`, se = (e, t = "highlight") => {
const s = (r, i, c) => {
const o = i.split(".");
let a;
for (a = 0; a < o.length - 1; a++)
r = r[o[a]];
r[o[a]] = c;
}, n = (r, i = []) => {
let c = "", o = 0;
return i.forEach((a) => {
const h = a[1] + 1;
c += [
r.substring(o, a[0]),
`<mark class="${t}">`,
r.substring(a[0], h),
"</mark>"
].join(""), o = h;
}), c += r.substring(o), c;
};
return e.filter(({ matches: r }) => r && r.length).map(({ item: r, matches: i }) => {
const c = { ...r };
return i.forEach((o) => {
o.key === "name" && s(
c,
o.key,
n(o.value, o.indices)
);
}), c;
});
}, ht = document.createElement("template");
ht.innerHTML = Zt;

@@ -1277,3 +1107,3 @@ class re extends HTMLElement {

super();
A(this, "shadowRoot");
x(this, "shadowRoot");
/**

@@ -1283,3 +1113,3 @@ * Apply JSON items to itemfilter.

*/
A(this, "apply");
x(this, "apply");
/**

@@ -1289,152 +1119,122 @@ * The filter properties.

*/
A(this, "filterProperties");
A(this, "items");
A(this, "fuse");
x(this, "filterProperties");
x(this, "items");
x(this, "fuse");
// TODO proper typing
A(this, "filters");
A(this, "aggregateBy");
x(this, "filters");
x(this, "aggregateBy");
/**
* Aggregate results by a property key
*/
x(this, "aggregateResults");
/**
* Native fuse.js config override
*/
A(this, "fuseConfig");
this.filters = {};
const e = this.getAttribute("aggregateResults") || !1;
(this.shadowRoot = this.attachShadow({ mode: "open" })),
this.shadowRoot.appendChild(ht.content.cloneNode(!0)),
(this.apply = (i) => {
(this.items = i),
(this.fuse = new N(this.items, {
minMatchCharLength: 1,
includeMatches: !0,
// Search in same fields as specified by filter properties, plus name
x(this, "fuseConfig");
this.filters = {}, this.shadowRoot = this.attachShadow({ mode: "open" }), this.shadowRoot.appendChild(ht.content.cloneNode(!0)), this.apply = (r) => {
this.items = r, this.fuse = new N(this.items, {
minMatchCharLength: 1,
includeMatches: !0,
// Search in same fields as specified by filter properties, plus name
// @ts-ignore
keys: ["name", ...this.filterProperties],
useExtendedSearch: !0,
...this.fuseConfig
}), this.filterProperties.forEach((i) => {
const c = [
...new Set(
this.items.reduce((a, h) => a.concat(h[i]), [])
)
].sort(), o = this.shadowRoot.querySelector("ul#filters");
c.forEach((a) => {
const h = document.createElement("template");
h.innerHTML = te;
const l = h.content.cloneNode(!0);
l.querySelector("input[type='checkbox']").setAttribute("data-filter-key", i), l.querySelector("input[type='checkbox']").setAttribute("data-filter-value", a), l.querySelector("span.title").innerHTML = a, o.appendChild(l);
}), this.aggregateResults === i && (this.aggregateBy = c);
}), s();
};
const s = () => {
this.shadowRoot.querySelectorAll("input[type='checkbox']").forEach((r) => {
r.addEventListener("click", (i) => {
const c = i.target, o = c.getAttribute("data-filter-key"), a = c.getAttribute("data-filter-value");
c.checked ? (this.filters[o] || (this.filters[o] = []), this.filters[o].push(a)) : (this.filters[o].splice(
// @ts-ignore
keys: ["name", ...this.filterProperties],
useExtendedSearch: !0,
...this.fuseConfig,
})),
this.filterProperties.forEach((c) => {
const o = [
...new Set(this.items.reduce((h, l) => h.concat(l[c]), [])),
].sort(),
a = this.shadowRoot.querySelector("ul#filters");
o.forEach((h) => {
const l = document.createElement("template");
l.innerHTML = te;
const u = l.content.cloneNode(!0);
u
.querySelector("input[type='checkbox']")
.setAttribute("data-filter-key", c),
u
.querySelector("input[type='checkbox']")
.setAttribute("data-filter-value", h),
(u.querySelector("span.title").innerHTML = h),
a.appendChild(u);
}),
e === c && (this.aggregateBy = o);
}),
n();
this.filters[o].indexOf(a),
1
), this.filters[o].length === 0 && delete this.filters[o]), n(
// @ts-ignore
this.shadowRoot.querySelector("input[type='text']").value
);
});
});
const n = () => {
this.shadowRoot
.querySelectorAll("input[type='checkbox']")
.forEach((i) => {
i.addEventListener("click", (c) => {
const o = c.target,
a = o.getAttribute("data-filter-key"),
h = o.getAttribute("data-filter-value");
o.checked
? (this.filters[a] || (this.filters[a] = []),
this.filters[a].push(h))
: (this.filters[a].splice(
// @ts-ignore
this.filters[a].indexOf(h),
1
),
this.filters[a].length === 0 && delete this.filters[a]),
r(
// @ts-ignore
this.shadowRoot.querySelector("input[type='text']").value
);
}, n = (r, i = this.filters) => {
const c = Object.entries(i).reduce(
(h, [l, u]) => {
const d = (g) => {
const p = {};
p[l] = `=${g}`, h.push(p);
};
return Array.isArray(u) ? u.forEach((g) => d(g)) : d(u), h;
},
[]
), o = se(
this.fuse.search({
...r.length && Object.keys(c).length ? {
$and: [
{ name: r },
{
$or: c
}
]
} : {
$or: [
{ name: r },
{
$or: c
}
]
}
})
), a = this.shadowRoot.querySelector("ul#results");
if (a.innerHTML = "", this.aggregateResults) {
const h = document.createElement("template");
h.innerHTML = ee, this.aggregateBy.forEach((l) => {
if (
// @ts-ignore
!o.find(
(d) => Array.isArray(d[this.aggregateResults]) ? d[this.aggregateResults].includes(l) : d[this.aggregateResults] === l
)
)
return;
const u = h.content.cloneNode(!0);
u.querySelector("summary").innerHTML = l, u.querySelector("details").setAttribute("data-aggregate", l), a.appendChild(u);
});
}
o.forEach((h) => {
if (this.aggregateBy) {
const l = h[this.aggregateResults];
if (Array.isArray(l))
l.forEach((u) => {
const d = document.createElement("li");
d.innerHTML = h.name, this.shadowRoot.querySelector(`details[data-aggregate=${u}]`).appendChild(d);
});
});
},
r = (i, c = this.filters) => {
const o = Object.entries(c).reduce((l, [u, f]) => {
const g = (p) => {
const m = {};
(m[u] = `=${p}`), l.push(m);
};
return Array.isArray(f) ? f.forEach((p) => g(p)) : g(f), l;
}, []),
a = se(
this.fuse.search({
...(i.length && Object.keys(o).length
? {
$and: [
{ name: i },
{
$or: o,
},
],
}
: {
$or: [
{ name: i },
{
$or: o,
},
],
}),
})
),
h = this.shadowRoot.querySelector("ul#results");
if (((h.innerHTML = ""), e)) {
const l = document.createElement("template");
(l.innerHTML = ee),
this.aggregateBy.forEach((u) => {
if (
// @ts-ignore
!a.find((g) =>
Array.isArray(g[e]) ? g[e].includes(u) : g[e] === u
)
)
return;
const f = l.content.cloneNode(!0);
(f.querySelector("summary").innerHTML = u),
f.querySelector("details").setAttribute("data-aggregate", u),
h.appendChild(f);
});
}
a.forEach((l) => {
if (this.aggregateBy) {
const u = l[e];
if (Array.isArray(u))
u.forEach((f) => {
const g = document.createElement("li");
(g.innerHTML = l.name),
this.shadowRoot
.querySelector(`details[data-aggregate=${f}]`)
.appendChild(g);
});
else {
const f = document.createElement("li");
(f.innerHTML = l.name),
this.shadowRoot
.querySelector(`details[data-aggregate=${u}]`)
.appendChild(f);
}
} else {
else {
const u = document.createElement("li");
(u.innerHTML = l.name), h.appendChild(u);
u.innerHTML = h.name, this.shadowRoot.querySelector(`details[data-aggregate=${l}]`).appendChild(u);
}
});
};
this.shadowRoot
.querySelector("input[type='text']")
.addEventListener("input", (i) => {
r(i.target.value);
} else {
const l = document.createElement("li");
l.innerHTML = h.name, a.appendChild(l);
}
});
};
this.shadowRoot.querySelector("input[type='text']").addEventListener("input", (r) => {
n(r.target.value);
});
}
}
customElements.define("eox-itemfilter", re);
export { re as EOxItemFilter };
export {
re as EOxItemFilter
};
{
"name": "@eox/itemfilter",
"version": "0.0.1",
"version": "0.0.2",
"type": "module",

@@ -5,0 +5,0 @@ "devDependencies": {

@@ -13,2 +13,3 @@ import { EOxItemFilter } from "../src/main";

EOxItemFilter.filterProperties = ["themes", "code"];
EOxItemFilter.aggregateResults = "themes";
EOxItemFilter.apply(testItems);

@@ -15,0 +16,0 @@ });

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc