import { w as he, au as Ae, ak as Oe, K as ke, av as Le, A as Re, i as Ce, J as je, aw as ve, ax as $e, E as Ne, ay as Fe, az as Te, aA as Pe, aB as De, aC as Ke, L as We, aD as ze, aE as He, v as Ve, aF as Be, aG as Ge, aH as Ue } from "./Toggle-B5c5wLIa.js";
import { j as Ye } from "./jsx-runtime-B6kdoens.js";
import { useCallback as Je } from "react";
import { k as Qe, j as Xe } from "./aggregator-J7DZKy5x.js";
import "./css-BHfxGWOW.js";
import "./Pack-CcDPYCmE.js";
import { L as Ze } from "./List-BF7beadf.js";
const K = Symbol(), le = Symbol(), J = Symbol();
let qe = (t, e) => new Proxy(t, e);
const W = Object.getPrototypeOf, te = /* @__PURE__ */ new WeakMap(), Q = (t) => t && (te.has(t) ? te.get(t) : W(t) === Object.prototype || W(t) === Array.prototype), se = (t) => typeof t == "object" && t !== null, re = /* @__PURE__ */ new WeakMap(), ue = (t) => t[J] || t, fe = (t, e, s) => {
  if (!Q(t)) return t;
  const r = ue(t), n = ((c) => Object.isFrozen(c) || Object.values(Object.getOwnPropertyDescriptors(c)).some((o) => !o.writable))(r);
  let i = s && s.get(r);
  return i && i[1].f === n || (i = ((c, o) => {
    const a = { f: o };
    let l = !1;
    const h = (d, g) => {
      if (!l) {
        let p = a.a.get(c);
        p || (p = /* @__PURE__ */ new Set(), a.a.set(c, p)), g && p.has(K) || p.add(d);
      }
    }, u = { get: (d, g) => g === J ? c : (h(g), fe(d[g], a.a, a.c)), has: (d, g) => g === le ? (l = !0, a.a.delete(c), !0) : (h(g), g in d), getOwnPropertyDescriptor: (d, g) => (h(g, !0), Object.getOwnPropertyDescriptor(d, g)), ownKeys: (d) => (h(K), Reflect.ownKeys(d)) };
    return o && (u.set = u.deleteProperty = () => !1), [u, a];
  })(r, n), i[1].p = qe(n ? ((c) => {
    let o = re.get(c);
    if (!o) {
      if (Array.isArray(c)) o = Array.from(c);
      else {
        const a = Object.getOwnPropertyDescriptors(c);
        Object.values(a).forEach((l) => {
          l.configurable = !0;
        }), o = Object.create(W(c), a);
      }
      re.set(c, o);
    }
    return o;
  })(r) : r, i[0]), s && s.set(r, i)), i[1].a = e, i[1].c = s, i[1].p;
}, et = (t, e) => {
  const s = Reflect.ownKeys(t), r = Reflect.ownKeys(e);
  return s.length !== r.length || s.some((n, i) => n !== r[i]);
}, de = (t, e, s, r) => {
  if (Object.is(t, e)) return !1;
  if (!se(t) || !se(e)) return !0;
  const n = s.get(ue(t));
  if (!n) return !0;
  if (r) {
    const c = r.get(t);
    if (c && c.n === e) return c.g;
    r.set(t, { n: e, g: !1 });
  }
  let i = null;
  for (const c of n) {
    const o = c === K ? et(t, e) : de(t[c], e[c], s, r);
    if (o !== !0 && o !== !1 || (i = o), i) break;
  }
  return i === null && (i = !0), r && r.set(t, { n: e, g: i }), i;
}, tt = (t) => !!Q(t) && le in t, X = (t) => Q(t) && t[J] || null, z = (t) => typeof t == "object" && t !== null, ge = (t, e) => {
  if (!z(t)) return t;
  const s = X(t);
  return s !== null ? (tt(t), s) : (e.has(t) || (e.add(t), Object.entries(t).forEach(([r, n]) => {
    const i = ge(n, e);
    Object.is(i, n) || (t[r] = i);
  })), t);
}, N = (t, e, s) => {
  if (!z(t) || !z(e)) return;
  const r = s.get(X(e) || e);
  r && r.forEach((n) => {
    N(t[n], e[n], s);
  });
}, st = (t, e) => {
  var s;
  let r = 0;
  const n = (s = e == null ? void 0 : e.size) != null ? s : 1, i = [], c = /* @__PURE__ */ new WeakMap(), o = /* @__PURE__ */ new WeakMap();
  return (a) => {
    const l = X(a) || a, h = c.get(l);
    if (h) return N(a, h.o, h.a), h.r;
    for (let m = 0; m < n; m += 1) {
      const M = i[(r + m) % n];
      if (!M) break;
      if (!de(M.o, a, M.a, /* @__PURE__ */ new WeakMap())) return c.set(l, M), N(a, M.o, M.a), M.r;
    }
    const u = /* @__PURE__ */ new WeakMap(), d = fe(a, u, o), g = ge(t(d), /* @__PURE__ */ new Set());
    N(a, a, u);
    const p = { o: a, r: g, a: u };
    return r = (r - 1 + n) % n, i[r] = p, c.set(l, p), g;
  };
}, rt = (t, e) => Qe.RUNTIME === "browser" ? st(t, e) : t;
function b(t) {
  return Array.isArray ? Array.isArray(t) : Me(t) === "[object Array]";
}
const nt = 1 / 0;
function it(t) {
  if (typeof t == "string")
    return t;
  let e = t + "";
  return e == "0" && 1 / t == -nt ? "-0" : e;
}
function ct(t) {
  return t == null ? "" : it(t);
}
function S(t) {
  return typeof t == "string";
}
function pe(t) {
  return typeof t == "number";
}
function ot(t) {
  return t === !0 || t === !1 || at(t) && Me(t) == "[object Boolean]";
}
function me(t) {
  return typeof t == "object";
}
function at(t) {
  return me(t) && t !== null;
}
function y(t) {
  return t != null;
}
function D(t) {
  return !t.trim().length;
}
function Me(t) {
  return t == null ? t === void 0 ? "[object Undefined]" : "[object Null]" : Object.prototype.toString.call(t);
}
const ht = "Incorrect 'index' type", lt = (t) => `Invalid value for key ${t}`, ut = (t) => `Pattern length exceeds max of ${t}.`, ft = (t) => `Missing ${t} property in key`, dt = (t) => `Property 'weight' in key '${t}' must be a positive integer`, ne = Object.prototype.hasOwnProperty;
class gt {
  constructor(e) {
    this._keys = [], this._keyMap = {};
    let s = 0;
    e.forEach((r) => {
      let n = ye(r);
      this._keys.push(n), this._keyMap[n.id] = n, s += n.weight;
    }), this._keys.forEach((r) => {
      r.weight /= s;
    });
  }
  get(e) {
    return this._keyMap[e];
  }
  keys() {
    return this._keys;
  }
  toJSON() {
    return JSON.stringify(this._keys);
  }
}
function ye(t) {
  let e = null, s = null, r = null, n = 1, i = null;
  if (S(t) || b(t))
    r = t, e = ie(t), s = H(t);
  else {
    if (!ne.call(t, "name"))
      throw new Error(ft("name"));
    const c = t.name;
    if (r = c, ne.call(t, "weight") && (n = t.weight, n <= 0))
      throw new Error(dt(c));
    e = ie(c), s = H(c), i = t.getFn;
  }
  return { path: e, id: s, weight: n, src: r, getFn: i };
}
function ie(t) {
  return b(t) ? t : t.split(".");
}
function H(t) {
  return b(t) ? t.join(".") : t;
}
function pt(t, e) {
  let s = [], r = !1;
  const n = (i, c, o) => {
    if (y(i))
      if (!c[o])
        s.push(i);
      else {
        let a = c[o];
        const l = i[a];
        if (!y(l))
          return;
        if (o === c.length - 1 && (S(l) || pe(l) || ot(l)))
          s.push(ct(l));
        else if (b(l)) {
          r = !0;
          for (let h = 0, u = l.length; h < u; h += 1)
            n(l[h], c, o + 1);
        } else c.length && n(l, c, o + 1);
      }
  };
  return n(t, S(e) ? e.split(".") : e, 0), r ? s : s[0];
}
const mt = {
  // 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
}, Mt = {
  // 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: (t, e) => t.score === e.score ? t.idx < e.idx ? -1 : 1 : t.score < e.score ? -1 : 1
}, yt = {
  // 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
}, xt = {
  // 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: pt,
  // 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 = {
  ...Mt,
  ...mt,
  ...yt,
  ...xt
};
const Et = /[^ ]+/g;
function St(t = 1, e = 3) {
  const s = /* @__PURE__ */ new Map(), r = Math.pow(10, e);
  return {
    get(n) {
      const i = n.match(Et).length;
      if (s.has(i))
        return s.get(i);
      const c = 1 / Math.pow(i, 0.5 * t), o = parseFloat(Math.round(c * r) / r);
      return s.set(i, o), o;
    },
    clear() {
      s.clear();
    }
  };
}
class Z {
  constructor({
    getFn: e = f.getFn,
    fieldNormWeight: s = f.fieldNormWeight
  } = {}) {
    this.norm = St(s, 3), this.getFn = e, this.isCreated = !1, this.setIndexRecords();
  }
  setSources(e = []) {
    this.docs = e;
  }
  setIndexRecords(e = []) {
    this.records = e;
  }
  setKeys(e = []) {
    this.keys = e, this._keysMap = {}, e.forEach((s, r) => {
      this._keysMap[s.id] = r;
    });
  }
  create() {
    this.isCreated || !this.docs.length || (this.isCreated = !0, S(this.docs[0]) ? this.docs.forEach((e, s) => {
      this._addString(e, s);
    }) : this.docs.forEach((e, s) => {
      this._addObject(e, s);
    }), this.norm.clear());
  }
  // Adds a doc to the end of the index
  add(e) {
    const s = this.size();
    S(e) ? this._addString(e, s) : this._addObject(e, s);
  }
  // Removes the doc at the specified index of the index
  removeAt(e) {
    this.records.splice(e, 1);
    for (let s = e, r = this.size(); s < r; s += 1)
      this.records[s].i -= 1;
  }
  getValueForItemAtKeyId(e, s) {
    return e[this._keysMap[s]];
  }
  size() {
    return this.records.length;
  }
  _addString(e, s) {
    if (!y(e) || D(e))
      return;
    let r = {
      v: e,
      i: s,
      n: this.norm.get(e)
    };
    this.records.push(r);
  }
  _addObject(e, s) {
    let r = { i: s, $: {} };
    this.keys.forEach((n, i) => {
      let c = n.getFn ? n.getFn(e) : this.getFn(e, n.path);
      if (y(c)) {
        if (b(c)) {
          let o = [];
          const a = [{ nestedArrIndex: -1, value: c }];
          for (; a.length; ) {
            const { nestedArrIndex: l, value: h } = a.pop();
            if (y(h))
              if (S(h) && !D(h)) {
                let u = {
                  v: h,
                  i: l,
                  n: this.norm.get(h)
                };
                o.push(u);
              } else b(h) && h.forEach((u, d) => {
                a.push({
                  nestedArrIndex: d,
                  value: u
                });
              });
          }
          r.$[i] = o;
        } else if (S(c) && !D(c)) {
          let o = {
            v: c,
            n: this.norm.get(c)
          };
          r.$[i] = o;
        }
      }
    }), this.records.push(r);
  }
  toJSON() {
    return {
      keys: this.keys,
      records: this.records
    };
  }
}
function xe(t, e, { getFn: s = f.getFn, fieldNormWeight: r = f.fieldNormWeight } = {}) {
  const n = new Z({ getFn: s, fieldNormWeight: r });
  return n.setKeys(t.map(ye)), n.setSources(e), n.create(), n;
}
function _t(t, { getFn: e = f.getFn, fieldNormWeight: s = f.fieldNormWeight } = {}) {
  const { keys: r, records: n } = t, i = new Z({ getFn: e, fieldNormWeight: s });
  return i.setKeys(r), i.setIndexRecords(n), i;
}
function $(t, {
  errors: e = 0,
  currentLocation: s = 0,
  expectedLocation: r = 0,
  distance: n = f.distance,
  ignoreLocation: i = f.ignoreLocation
} = {}) {
  const c = e / t.length;
  if (i)
    return c;
  const o = Math.abs(r - s);
  return n ? c + o / n : o ? 1 : c;
}
function bt(t = [], e = f.minMatchCharLength) {
  let s = [], r = -1, n = -1, i = 0;
  for (let c = t.length; i < c; i += 1) {
    let o = t[i];
    o && r === -1 ? r = i : !o && r !== -1 && (n = i - 1, n - r + 1 >= e && s.push([r, n]), r = -1);
  }
  return t[i - 1] && i - r >= e && s.push([r, i - 1]), s;
}
const k = 32;
function wt(t, e, s, {
  location: r = f.location,
  distance: n = f.distance,
  threshold: i = f.threshold,
  findAllMatches: c = f.findAllMatches,
  minMatchCharLength: o = f.minMatchCharLength,
  includeMatches: a = f.includeMatches,
  ignoreLocation: l = f.ignoreLocation
} = {}) {
  if (e.length > k)
    throw new Error(ut(k));
  const h = e.length, u = t.length, d = Math.max(0, Math.min(r, u));
  let g = i, p = d;
  const m = o > 1 || a, M = m ? Array(u) : [];
  let _;
  for (; (_ = t.indexOf(e, p)) > -1; ) {
    let x = $(e, {
      currentLocation: _,
      expectedLocation: d,
      distance: n,
      ignoreLocation: l
    });
    if (g = Math.min(x, g), p = _ + h, m) {
      let w = 0;
      for (; w < h; )
        M[_ + w] = 1, w += 1;
    }
  }
  p = -1;
  let L = [], O = 1, j = h + u;
  const Ie = 1 << h - 1;
  for (let x = 0; x < h; x += 1) {
    let w = 0, I = j;
    for (; w < I; )
      $(e, {
        errors: x,
        currentLocation: d + I,
        expectedLocation: d,
        distance: n,
        ignoreLocation: l
      }) <= g ? w = I : j = I, I = Math.floor((j - w) / 2 + w);
    j = I;
    let q = Math.max(1, d - I + 1), P = c ? u : Math.min(d + I, u) + h, R = Array(P + 2);
    R[P + 1] = (1 << x) - 1;
    for (let E = P; E >= q; E -= 1) {
      let v = E - 1, ee = s[t.charAt(v)];
      if (m && (M[v] = +!!ee), R[E] = (R[E + 1] << 1 | 1) & ee, x && (R[E] |= (L[E + 1] | L[E]) << 1 | 1 | L[E + 1]), R[E] & Ie && (O = $(e, {
        errors: x,
        currentLocation: v,
        expectedLocation: d,
        distance: n,
        ignoreLocation: l
      }), O <= g)) {
        if (g = O, p = v, p <= d)
          break;
        q = Math.max(1, 2 * d - p);
      }
    }
    if ($(e, {
      errors: x + 1,
      currentLocation: d,
      expectedLocation: d,
      distance: n,
      ignoreLocation: l
    }) > g)
      break;
    L = R;
  }
  const T = {
    isMatch: p >= 0,
    // Count exact matches (those with a score of 0) to be "almost" exact
    score: Math.max(1e-3, O)
  };
  if (m) {
    const x = bt(M, o);
    x.length ? a && (T.indices = x) : T.isMatch = !1;
  }
  return T;
}
function It(t) {
  let e = {};
  for (let s = 0, r = t.length; s < r; s += 1) {
    const n = t.charAt(s);
    e[n] = (e[n] || 0) | 1 << r - s - 1;
  }
  return e;
}
class Ee {
  constructor(e, {
    location: s = f.location,
    threshold: r = f.threshold,
    distance: n = f.distance,
    includeMatches: i = f.includeMatches,
    findAllMatches: c = f.findAllMatches,
    minMatchCharLength: o = f.minMatchCharLength,
    isCaseSensitive: a = f.isCaseSensitive,
    ignoreLocation: l = f.ignoreLocation
  } = {}) {
    if (this.options = {
      location: s,
      threshold: r,
      distance: n,
      includeMatches: i,
      findAllMatches: c,
      minMatchCharLength: o,
      isCaseSensitive: a,
      ignoreLocation: l
    }, this.pattern = a ? e : e.toLowerCase(), this.chunks = [], !this.pattern.length)
      return;
    const h = (d, g) => {
      this.chunks.push({
        pattern: d,
        alphabet: It(d),
        startIndex: g
      });
    }, u = this.pattern.length;
    if (u > k) {
      let d = 0;
      const g = u % k, p = u - g;
      for (; d < p; )
        h(this.pattern.substr(d, k), d), d += k;
      if (g) {
        const m = u - k;
        h(this.pattern.substr(m), m);
      }
    } else
      h(this.pattern, 0);
  }
  searchIn(e) {
    const { isCaseSensitive: s, includeMatches: r } = this.options;
    if (s || (e = e.toLowerCase()), this.pattern === e) {
      let p = {
        isMatch: !0,
        score: 0
      };
      return r && (p.indices = [[0, e.length - 1]]), p;
    }
    const {
      location: n,
      distance: i,
      threshold: c,
      findAllMatches: o,
      minMatchCharLength: a,
      ignoreLocation: l
    } = this.options;
    let h = [], u = 0, d = !1;
    this.chunks.forEach(({ pattern: p, alphabet: m, startIndex: M }) => {
      const { isMatch: _, score: L, indices: O } = wt(e, p, m, {
        location: n + M,
        distance: i,
        threshold: c,
        findAllMatches: o,
        minMatchCharLength: a,
        includeMatches: r,
        ignoreLocation: l
      });
      _ && (d = !0), u += L, _ && O && (h = [...h, ...O]);
    });
    let g = {
      isMatch: d,
      score: d ? u / this.chunks.length : 1
    };
    return d && r && (g.indices = h), g;
  }
}
class A {
  constructor(e) {
    this.pattern = e;
  }
  static isMultiMatch(e) {
    return ce(e, this.multiRegex);
  }
  static isSingleMatch(e) {
    return ce(e, this.singleRegex);
  }
  search() {
  }
}
function ce(t, e) {
  const s = t.match(e);
  return s ? s[1] : null;
}
class At extends A {
  constructor(e) {
    super(e);
  }
  static get type() {
    return "exact";
  }
  static get multiRegex() {
    return /^="(.*)"$/;
  }
  static get singleRegex() {
    return /^=(.*)$/;
  }
  search(e) {
    const s = e === this.pattern;
    return {
      isMatch: s,
      score: s ? 0 : 1,
      indices: [0, this.pattern.length - 1]
    };
  }
}
class Ot extends A {
  constructor(e) {
    super(e);
  }
  static get type() {
    return "inverse-exact";
  }
  static get multiRegex() {
    return /^!"(.*)"$/;
  }
  static get singleRegex() {
    return /^!(.*)$/;
  }
  search(e) {
    const r = e.indexOf(this.pattern) === -1;
    return {
      isMatch: r,
      score: r ? 0 : 1,
      indices: [0, e.length - 1]
    };
  }
}
class kt extends A {
  constructor(e) {
    super(e);
  }
  static get type() {
    return "prefix-exact";
  }
  static get multiRegex() {
    return /^\^"(.*)"$/;
  }
  static get singleRegex() {
    return /^\^(.*)$/;
  }
  search(e) {
    const s = e.startsWith(this.pattern);
    return {
      isMatch: s,
      score: s ? 0 : 1,
      indices: [0, this.pattern.length - 1]
    };
  }
}
class Lt extends A {
  constructor(e) {
    super(e);
  }
  static get type() {
    return "inverse-prefix-exact";
  }
  static get multiRegex() {
    return /^!\^"(.*)"$/;
  }
  static get singleRegex() {
    return /^!\^(.*)$/;
  }
  search(e) {
    const s = !e.startsWith(this.pattern);
    return {
      isMatch: s,
      score: s ? 0 : 1,
      indices: [0, e.length - 1]
    };
  }
}
class Rt extends A {
  constructor(e) {
    super(e);
  }
  static get type() {
    return "suffix-exact";
  }
  static get multiRegex() {
    return /^"(.*)"\$$/;
  }
  static get singleRegex() {
    return /^(.*)\$$/;
  }
  search(e) {
    const s = e.endsWith(this.pattern);
    return {
      isMatch: s,
      score: s ? 0 : 1,
      indices: [e.length - this.pattern.length, e.length - 1]
    };
  }
}
class Ct extends A {
  constructor(e) {
    super(e);
  }
  static get type() {
    return "inverse-suffix-exact";
  }
  static get multiRegex() {
    return /^!"(.*)"\$$/;
  }
  static get singleRegex() {
    return /^!(.*)\$$/;
  }
  search(e) {
    const s = !e.endsWith(this.pattern);
    return {
      isMatch: s,
      score: s ? 0 : 1,
      indices: [0, e.length - 1]
    };
  }
}
class Se extends A {
  constructor(e, {
    location: s = f.location,
    threshold: r = f.threshold,
    distance: n = f.distance,
    includeMatches: i = f.includeMatches,
    findAllMatches: c = f.findAllMatches,
    minMatchCharLength: o = f.minMatchCharLength,
    isCaseSensitive: a = f.isCaseSensitive,
    ignoreLocation: l = f.ignoreLocation
  } = {}) {
    super(e), this._bitapSearch = new Ee(e, {
      location: s,
      threshold: r,
      distance: n,
      includeMatches: i,
      findAllMatches: c,
      minMatchCharLength: o,
      isCaseSensitive: a,
      ignoreLocation: l
    });
  }
  static get type() {
    return "fuzzy";
  }
  static get multiRegex() {
    return /^"(.*)"$/;
  }
  static get singleRegex() {
    return /^(.*)$/;
  }
  search(e) {
    return this._bitapSearch.searchIn(e);
  }
}
class _e extends A {
  constructor(e) {
    super(e);
  }
  static get type() {
    return "include";
  }
  static get multiRegex() {
    return /^'"(.*)"$/;
  }
  static get singleRegex() {
    return /^'(.*)$/;
  }
  search(e) {
    let s = 0, r;
    const n = [], i = this.pattern.length;
    for (; (r = e.indexOf(this.pattern, s)) > -1; )
      s = r + i, n.push([r, s - 1]);
    const c = !!n.length;
    return {
      isMatch: c,
      score: c ? 0 : 1,
      indices: n
    };
  }
}
const V = [
  At,
  _e,
  kt,
  Lt,
  Ct,
  Rt,
  Ot,
  Se
], oe = V.length, jt = / +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/, vt = "|";
function $t(t, e = {}) {
  return t.split(vt).map((s) => {
    let r = s.trim().split(jt).filter((i) => i && !!i.trim()), n = [];
    for (let i = 0, c = r.length; i < c; i += 1) {
      const o = r[i];
      let a = !1, l = -1;
      for (; !a && ++l < oe; ) {
        const h = V[l];
        let u = h.isMultiMatch(o);
        u && (n.push(new h(u, e)), a = !0);
      }
      if (!a)
        for (l = -1; ++l < oe; ) {
          const h = V[l];
          let u = h.isSingleMatch(o);
          if (u) {
            n.push(new h(u, e));
            break;
          }
        }
    }
    return n;
  });
}
const Nt = /* @__PURE__ */ new Set([Se.type, _e.type]);
class Ft {
  constructor(e, {
    isCaseSensitive: s = f.isCaseSensitive,
    includeMatches: r = f.includeMatches,
    minMatchCharLength: n = f.minMatchCharLength,
    ignoreLocation: i = f.ignoreLocation,
    findAllMatches: c = f.findAllMatches,
    location: o = f.location,
    threshold: a = f.threshold,
    distance: l = f.distance
  } = {}) {
    this.query = null, this.options = {
      isCaseSensitive: s,
      includeMatches: r,
      minMatchCharLength: n,
      findAllMatches: c,
      ignoreLocation: i,
      location: o,
      threshold: a,
      distance: l
    }, this.pattern = s ? e : e.toLowerCase(), this.query = $t(this.pattern, this.options);
  }
  static condition(e, s) {
    return s.useExtendedSearch;
  }
  searchIn(e) {
    const s = this.query;
    if (!s)
      return {
        isMatch: !1,
        score: 1
      };
    const { includeMatches: r, isCaseSensitive: n } = this.options;
    e = n ? e : e.toLowerCase();
    let i = 0, c = [], o = 0;
    for (let a = 0, l = s.length; a < l; a += 1) {
      const h = s[a];
      c.length = 0, i = 0;
      for (let u = 0, d = h.length; u < d; u += 1) {
        const g = h[u], { isMatch: p, indices: m, score: M } = g.search(e);
        if (p) {
          if (i += 1, o += M, r) {
            const _ = g.constructor.type;
            Nt.has(_) ? c = [...c, ...m] : c.push(m);
          }
        } else {
          o = 0, i = 0, c.length = 0;
          break;
        }
      }
      if (i) {
        let u = {
          isMatch: !0,
          score: o / i
        };
        return r && (u.indices = c), u;
      }
    }
    return {
      isMatch: !1,
      score: 1
    };
  }
}
const B = [];
function Tt(...t) {
  B.push(...t);
}
function G(t, e) {
  for (let s = 0, r = B.length; s < r; s += 1) {
    let n = B[s];
    if (n.condition(t, e))
      return new n(t, e);
  }
  return new Ee(t, e);
}
const F = {
  AND: "$and",
  OR: "$or"
}, U = {
  PATH: "$path",
  PATTERN: "$val"
}, Y = (t) => !!(t[F.AND] || t[F.OR]), Pt = (t) => !!t[U.PATH], Dt = (t) => !b(t) && me(t) && !Y(t), ae = (t) => ({
  [F.AND]: Object.keys(t).map((e) => ({
    [e]: t[e]
  }))
});
function be(t, e, { auto: s = !0 } = {}) {
  const r = (n) => {
    let i = Object.keys(n);
    const c = Pt(n);
    if (!c && i.length > 1 && !Y(n))
      return r(ae(n));
    if (Dt(n)) {
      const a = c ? n[U.PATH] : i[0], l = c ? n[U.PATTERN] : n[a];
      if (!S(l))
        throw new Error(lt(a));
      const h = {
        keyId: H(a),
        pattern: l
      };
      return s && (h.searcher = G(l, e)), h;
    }
    let o = {
      children: [],
      operator: i[0]
    };
    return i.forEach((a) => {
      const l = n[a];
      b(l) && l.forEach((h) => {
        o.children.push(r(h));
      });
    }), o;
  };
  return Y(t) || (t = ae(t)), r(t);
}
function Kt(t, { ignoreFieldNorm: e = f.ignoreFieldNorm }) {
  t.forEach((s) => {
    let r = 1;
    s.matches.forEach(({ key: n, norm: i, score: c }) => {
      const o = n ? n.weight : null;
      r *= Math.pow(
        c === 0 && o ? Number.EPSILON : c,
        (o || 1) * (e ? 1 : i)
      );
    }), s.score = r;
  });
}
function Wt(t, e) {
  const s = t.matches;
  e.matches = [], y(s) && s.forEach((r) => {
    if (!y(r.indices) || !r.indices.length)
      return;
    const { indices: n, value: i } = r;
    let c = {
      indices: n,
      value: i
    };
    r.key && (c.key = r.key.src), r.idx > -1 && (c.refIndex = r.idx), e.matches.push(c);
  });
}
function zt(t, e) {
  e.score = t.score;
}
function Ht(t, e, {
  includeMatches: s = f.includeMatches,
  includeScore: r = f.includeScore
} = {}) {
  const n = [];
  return s && n.push(Wt), r && n.push(zt), t.map((i) => {
    const { idx: c } = i, o = {
      item: e[c],
      refIndex: c
    };
    return n.length && n.forEach((a) => {
      a(i, o);
    }), o;
  });
}
class C {
  constructor(e, s = {}, r) {
    this.options = { ...f, ...s }, this.options.useExtendedSearch, this._keyStore = new gt(this.options.keys), this.setCollection(e, r);
  }
  setCollection(e, s) {
    if (this._docs = e, s && !(s instanceof Z))
      throw new Error(ht);
    this._myIndex = s || xe(this.options.keys, this._docs, {
      getFn: this.options.getFn,
      fieldNormWeight: this.options.fieldNormWeight
    });
  }
  add(e) {
    y(e) && (this._docs.push(e), this._myIndex.add(e));
  }
  remove(e = () => !1) {
    const s = [];
    for (let r = 0, n = this._docs.length; r < n; r += 1) {
      const i = this._docs[r];
      e(i, r) && (this.removeAt(r), r -= 1, n -= 1, s.push(i));
    }
    return s;
  }
  removeAt(e) {
    this._docs.splice(e, 1), this._myIndex.removeAt(e);
  }
  getIndex() {
    return this._myIndex;
  }
  search(e, { limit: s = -1 } = {}) {
    const {
      includeMatches: r,
      includeScore: n,
      shouldSort: i,
      sortFn: c,
      ignoreFieldNorm: o
    } = this.options;
    let a = S(e) ? S(this._docs[0]) ? this._searchStringList(e) : this._searchObjectList(e) : this._searchLogical(e);
    return Kt(a, { ignoreFieldNorm: o }), i && a.sort(c), pe(s) && s > -1 && (a = a.slice(0, s)), Ht(a, this._docs, {
      includeMatches: r,
      includeScore: n
    });
  }
  _searchStringList(e) {
    const s = G(e, this.options), { records: r } = this._myIndex, n = [];
    return r.forEach(({ v: i, i: c, n: o }) => {
      if (!y(i))
        return;
      const { isMatch: a, score: l, indices: h } = s.searchIn(i);
      a && n.push({
        item: i,
        idx: c,
        matches: [{ score: l, value: i, norm: o, indices: h }]
      });
    }), n;
  }
  _searchLogical(e) {
    const s = be(e, this.options), r = (o, a, l) => {
      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: l,
            item: a,
            matches: g
          }
        ] : [];
      }
      const h = [];
      for (let u = 0, d = o.children.length; u < d; u += 1) {
        const g = o.children[u], p = r(g, a, l);
        if (p.length)
          h.push(...p);
        else if (o.operator === F.AND)
          return [];
      }
      return h;
    }, n = this._myIndex.records, i = {}, c = [];
    return n.forEach(({ $: o, i: a }) => {
      if (y(o)) {
        let l = r(s, o, a);
        l.length && (i[a] || (i[a] = { idx: a, item: o, matches: [] }, c.push(i[a])), l.forEach(({ matches: h }) => {
          i[a].matches.push(...h);
        }));
      }
    }), c;
  }
  _searchObjectList(e) {
    const s = G(e, this.options), { keys: r, records: n } = this._myIndex, i = [];
    return n.forEach(({ $: c, i: o }) => {
      if (!y(c))
        return;
      let a = [];
      r.forEach((l, h) => {
        a.push(
          ...this._findMatches({
            key: l,
            value: c[h],
            searcher: s
          })
        );
      }), a.length && i.push({
        idx: o,
        item: c,
        matches: a
      });
    }), i;
  }
  _findMatches({ key: e, value: s, searcher: r }) {
    if (!y(s))
      return [];
    let n = [];
    if (b(s))
      s.forEach(({ v: i, i: c, n: o }) => {
        if (!y(i))
          return;
        const { isMatch: a, score: l, indices: h } = r.searchIn(i);
        a && n.push({
          score: l,
          key: e,
          value: i,
          idx: c,
          norm: o,
          indices: h
        });
      });
    else {
      const { v: i, n: c } = s, { isMatch: o, score: a, indices: l } = r.searchIn(i);
      o && n.push({ score: a, key: e, value: i, norm: c, indices: l });
    }
    return n;
  }
}
C.version = "7.0.0";
C.createIndex = xe;
C.parseIndex = _t;
C.config = f;
C.parseQuery = be;
Tt(Ft);
const Vt = {
  threshold: 0.3
}, Bt = (t) => (e) => {
  const s = new C(e, {
    keys: Object.keys(e[0]),
    ...Vt,
    ...t
  });
  return {
    type: "fuse",
    page: (r, n) => e.slice(r * n, (r + 1) * n),
    search: (r) => s.search(r).map(({ item: n }) => n),
    retrieve: (r) => e.filter((n) => r.includes(n.key))
  };
}, Gt = Bt(), Ut = ({
  term: t,
  searcher: e = Gt
}) => rt(({ data: s }) => typeof e == "function" ? t.length === 0 || (s == null ? void 0 : s.length) === 0 ? { data: s, transformed: !1 } : { data: e(s).search(t), transformed: !0 } : { data: e.search(t), transformed: !0 }), we = ({
  debounce: t = 250,
  value: e,
  onChange: s,
  transformBefore: r
}) => {
  const [n, i] = Xe({
    onChange: s,
    value: e,
    initial: ""
  }), { setTransform: c, deleteTransform: o } = he(), a = Ae(c, t, []), l = Je(
    (h) => {
      i(h), h.length === 0 ? o("filter") : (r != null && (h = r(h)), a("filter", Ut({ term: h })));
    },
    [i, r]
  );
  return { value: n, onChange: l };
}, Yt = ({
  children: t = (s) => /* @__PURE__ */ Ye.jsx(Oe, { placeholder: "Filter", ...s }),
  ...e
}) => t(we(e)), rs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  Column: ke,
  ColumnContext: Le,
  Core: Re,
  DataProvider: Ce,
  Filter: Yt,
  Hover: je,
  ItemFrame: ve,
  List: Ze,
  Search: $e,
  Selector: Ne,
  selectValueIsZero: Fe,
  useDataContext: Te,
  useDataUtilContext: he,
  useFilter: we,
  useGetTransformedData: Pe,
  useHoverContext: De,
  useSearch: Ke,
  useSelect: We,
  useSelection: ze,
  useSelectionContext: He,
  useSelectionUtils: Ve,
  useSetSourceData: Be,
  useSourceData: Ge,
  useTransformedData: Ue
}, Symbol.toStringTag, { value: "Module" }));
export {
  Yt as F,
  Ut as c,
  rs as e,
  Bt as f,
  rt as p
};
