import { s as he, aq as Ie, ag as Ae, G as Oe, ar as ke, y as Le, g as Re, H as Ce, as as je, at as $e, z as ve, au as Ne, av as Te, aw as Fe, ax as Pe, J as De, ay as Ke, az as We, r as ze, aA as Ve, aB as Be, aC as He } from "./Toggle-5mHDjpoq.js";
import { j as Ge } from "./jsx-runtime-NmMXPjeo.js";
import { useCallback as Ue } from "react";
import { V as Ye } from "./css-M9deYuc0.js";
import { j as Je } from "./aggregator-e8E2YGic.js";
import "./Center-ZEYtK6iF.js";
import "react-hook-form";
import { L as Qe } from "./List-XYe_oss-.js";
function b(t) {
  return Array.isArray ? Array.isArray(t) : fe(t) === "[object Array]";
}
const Xe = 1 / 0;
function Ze(t) {
  if (typeof t == "string")
    return t;
  let e = t + "";
  return e == "0" && 1 / t == -Xe ? "-0" : e;
}
function qe(t) {
  return t == null ? "" : Ze(t);
}
function S(t) {
  return typeof t == "string";
}
function le(t) {
  return typeof t == "number";
}
function et(t) {
  return t === !0 || t === !1 || tt(t) && fe(t) == "[object Boolean]";
}
function ue(t) {
  return typeof t == "object";
}
function tt(t) {
  return ue(t) && t !== null;
}
function y(t) {
  return t != null;
}
function D(t) {
  return !t.trim().length;
}
function fe(t) {
  return t == null ? t === void 0 ? "[object Undefined]" : "[object Null]" : Object.prototype.toString.call(t);
}
const st = "Incorrect 'index' type", rt = (t) => `Invalid value for key ${t}`, nt = (t) => `Pattern length exceeds max of ${t}.`, it = (t) => `Missing ${t} property in key`, ct = (t) => `Property 'weight' in key '${t}' must be a positive integer`, te = Object.prototype.hasOwnProperty;
class ot {
  constructor(e) {
    this._keys = [], this._keyMap = {};
    let s = 0;
    e.forEach((r) => {
      let n = de(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 de(t) {
  let e = null, s = null, r = null, n = 1, i = null;
  if (S(t) || b(t))
    r = t, e = se(t), s = K(t);
  else {
    if (!te.call(t, "name"))
      throw new Error(it("name"));
    const c = t.name;
    if (r = c, te.call(t, "weight") && (n = t.weight, n <= 0))
      throw new Error(ct(c));
    e = se(c), s = K(c), i = t.getFn;
  }
  return { path: e, id: s, weight: n, src: r, getFn: i };
}
function se(t) {
  return b(t) ? t : t.split(".");
}
function K(t) {
  return b(t) ? t.join(".") : t;
}
function at(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) || le(l) || et(l)))
          s.push(qe(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 ht = {
  // 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: (t, e) => t.score === e.score ? t.idx < e.idx ? -1 : 1 : t.score < e.score ? -1 : 1
}, ut = {
  // 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
}, ft = {
  // 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: at,
  // 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,
  ...ht,
  ...ut,
  ...ft
};
const dt = /[^ ]+/g;
function gt(t = 1, e = 3) {
  const s = /* @__PURE__ */ new Map(), r = Math.pow(10, e);
  return {
    get(n) {
      const i = n.match(dt).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 J {
  constructor({
    getFn: e = f.getFn,
    fieldNormWeight: s = f.fieldNormWeight
  } = {}) {
    this.norm = gt(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 ge(t, e, { getFn: s = f.getFn, fieldNormWeight: r = f.fieldNormWeight } = {}) {
  const n = new J({ getFn: s, fieldNormWeight: r });
  return n.setKeys(t.map(de)), n.setSources(e), n.create(), n;
}
function pt(t, { getFn: e = f.getFn, fieldNormWeight: s = f.fieldNormWeight } = {}) {
  const { keys: r, records: n } = t, i = new J({ getFn: e, fieldNormWeight: s });
  return i.setKeys(r), i.setIndexRecords(n), i;
}
function v(t, {
  errors: e = 0,
  currentLocation: s = 0,
  expectedLocation: r = 0,
  distance: n = f.distance,
  ignoreLocation: i = f.ignoreLocation
} = {}) {
  const c = e / t.length;
  if (i)
    return c;
  const o = Math.abs(r - s);
  return n ? c + o / n : o ? 1 : c;
}
function mt(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 Mt(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(nt(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 = v(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 we = 1 << h - 1;
  for (let x = 0; x < h; x += 1) {
    let w = 0, I = j;
    for (; w < I; )
      v(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 $ = E - 1, ee = s[t.charAt($)];
      if (m && (M[$] = +!!ee), R[E] = (R[E + 1] << 1 | 1) & ee, x && (R[E] |= (L[E + 1] | L[E]) << 1 | 1 | L[E + 1]), R[E] & we && (O = v(e, {
        errors: x,
        currentLocation: $,
        expectedLocation: d,
        distance: n,
        ignoreLocation: l
      }), O <= g)) {
        if (g = O, p = $, p <= d)
          break;
        q = Math.max(1, 2 * d - p);
      }
    }
    if (v(e, {
      errors: x + 1,
      currentLocation: d,
      expectedLocation: d,
      distance: n,
      ignoreLocation: l
    }) > g)
      break;
    L = R;
  }
  const F = {
    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 = mt(M, o);
    x.length ? a && (F.indices = x) : F.isMatch = !1;
  }
  return F;
}
function yt(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 pe {
  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: yt(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 } = Mt(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 re(e, this.multiRegex);
  }
  static isSingleMatch(e) {
    return re(e, this.singleRegex);
  }
  search() {
  }
}
function re(t, e) {
  const s = t.match(e);
  return s ? s[1] : null;
}
class xt 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 Et 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 St 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 _t 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 bt 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 wt 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 me 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 pe(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 Me 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 W = [
  xt,
  Me,
  St,
  _t,
  wt,
  bt,
  Et,
  me
], ne = W.length, It = / +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/, At = "|";
function Ot(t, e = {}) {
  return t.split(At).map((s) => {
    let r = s.trim().split(It).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 < ne; ) {
        const h = W[l];
        let u = h.isMultiMatch(o);
        u && (n.push(new h(u, e)), a = !0);
      }
      if (!a)
        for (l = -1; ++l < ne; ) {
          const h = W[l];
          let u = h.isSingleMatch(o);
          if (u) {
            n.push(new h(u, e));
            break;
          }
        }
    }
    return n;
  });
}
const kt = /* @__PURE__ */ new Set([me.type, Me.type]);
class Lt {
  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 = Ot(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;
            kt.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 z = [];
function Rt(...t) {
  z.push(...t);
}
function V(t, e) {
  for (let s = 0, r = z.length; s < r; s += 1) {
    let n = z[s];
    if (n.condition(t, e))
      return new n(t, e);
  }
  return new pe(t, e);
}
const T = {
  AND: "$and",
  OR: "$or"
}, B = {
  PATH: "$path",
  PATTERN: "$val"
}, H = (t) => !!(t[T.AND] || t[T.OR]), Ct = (t) => !!t[B.PATH], jt = (t) => !b(t) && ue(t) && !H(t), ie = (t) => ({
  [T.AND]: Object.keys(t).map((e) => ({
    [e]: t[e]
  }))
});
function ye(t, e, { auto: s = !0 } = {}) {
  const r = (n) => {
    let i = Object.keys(n);
    const c = Ct(n);
    if (!c && i.length > 1 && !H(n))
      return r(ie(n));
    if (jt(n)) {
      const a = c ? n[B.PATH] : i[0], l = c ? n[B.PATTERN] : n[a];
      if (!S(l))
        throw new Error(rt(a));
      const h = {
        keyId: K(a),
        pattern: l
      };
      return s && (h.searcher = V(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 H(t) || (t = ie(t)), r(t);
}
function $t(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 vt(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 Nt(t, e) {
  e.score = t.score;
}
function Tt(t, e, {
  includeMatches: s = f.includeMatches,
  includeScore: r = f.includeScore
} = {}) {
  const n = [];
  return s && n.push(vt), r && n.push(Nt), 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 ot(this.options.keys), this.setCollection(e, r);
  }
  setCollection(e, s) {
    if (this._docs = e, s && !(s instanceof J))
      throw new Error(st);
    this._myIndex = s || ge(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 $t(a, { ignoreFieldNorm: o }), i && a.sort(c), le(s) && s > -1 && (a = a.slice(0, s)), Tt(a, this._docs, {
      includeMatches: r,
      includeScore: n
    });
  }
  _searchStringList(e) {
    const s = V(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 = ye(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 === T.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 = V(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 = ge;
C.parseIndex = pt;
C.config = f;
C.parseQuery = ye;
Rt(Lt);
const G = Symbol(), xe = Symbol(), Q = Symbol();
let Ft = (t, e) => new Proxy(t, e);
const U = Object.getPrototypeOf, ce = /* @__PURE__ */ new WeakMap(), X = (t) => t && (ce.has(t) ? ce.get(t) : U(t) === Object.prototype || U(t) === Array.prototype), oe = (t) => typeof t == "object" && t !== null, ae = /* @__PURE__ */ new WeakMap(), Ee = (t) => t[Q] || t, Se = (t, e, s) => {
  if (!X(t))
    return t;
  const r = Ee(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(G) || p.add(d);
      }
    }, u = { get: (d, g) => g === Q ? c : (h(g), Se(d[g], a.a, a.c)), has: (d, g) => g === xe ? (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(G), Reflect.ownKeys(d)) };
    return o && (u.set = u.deleteProperty = () => !1), [u, a];
  })(r, n), i[1].p = Ft(n ? ((c) => {
    let o = ae.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(U(c), a);
      }
      ae.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;
}, Pt = (t, e) => {
  const s = Reflect.ownKeys(t), r = Reflect.ownKeys(e);
  return s.length !== r.length || s.some((n, i) => n !== r[i]);
}, _e = (t, e, s, r) => {
  if (Object.is(t, e))
    return !1;
  if (!oe(t) || !oe(e))
    return !0;
  const n = s.get(Ee(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 === G ? Pt(t, e) : _e(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;
}, Dt = (t) => !!X(t) && xe in t, Z = (t) => X(t) && t[Q] || null, Y = (t) => typeof t == "object" && t !== null, be = (t, e) => {
  if (!Y(t))
    return t;
  const s = Z(t);
  return s !== null ? (Dt(t), s) : (e.has(t) || (e.add(t), Object.entries(t).forEach(([r, n]) => {
    const i = be(n, e);
    Object.is(i, n) || (t[r] = i);
  })), t);
}, N = (t, e, s) => {
  if (!Y(t) || !Y(e))
    return;
  const r = s.get(Z(e) || e);
  r && r.forEach((n) => {
    N(t[n], e[n], s);
  });
}, Kt = (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 = Z(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 (!_e(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 = Se(a, u, o), g = be(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;
  };
}, Wt = (t, e) => Ye.RUNTIME === "browser" ? Kt(t, e) : t, zt = {
  threshold: 0.3
}, Vt = (t) => (e) => {
  const s = new C(e, {
    keys: Object.keys(e[0]),
    ...zt,
    ...t
  });
  return {
    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))
  };
}, Bt = Vt(), Ht = ({
  term: t,
  searcher: e = Bt
}) => Wt((s) => typeof e == "function" ? t.length === 0 || (s == null ? void 0 : s.length) === 0 ? s : e(s).search(t) : e.search(t)), Gt = ({
  children: t = (n) => /* @__PURE__ */ Ge.jsx(Ae, { ...n }),
  debounce: e = 250,
  onChange: s,
  value: r
}) => {
  const [n, i] = Je({
    onChange: s,
    value: r,
    initial: ""
  }), { setTransform: c, deleteTransform: o } = he(), a = Ie(c, e, []), l = Ue(
    (h) => {
      i(h), h.length === 0 ? o("filter") : a("filter", Ht({ term: h }));
    },
    [i]
  );
  return t({ value: n, onChange: l });
}, ss = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  Column: Oe,
  ColumnContext: ke,
  Core: Le,
  DataProvider: Re,
  Filter: Gt,
  Hover: Ce,
  ItemFrame: je,
  List: Qe,
  Search: $e,
  Selector: ve,
  selectValueIsZero: Ne,
  useDataContext: Te,
  useDataUtilContext: he,
  useGetTransformedData: Fe,
  useHoverContext: Pe,
  useSelect: De,
  useSelection: Ke,
  useSelectionContext: We,
  useSelectionUtils: ze,
  useSetSourceData: Ve,
  useSourceData: Be,
  useTransformedData: He
}, Symbol.toStringTag, { value: "Module" }));
export {
  Gt as F,
  Ht as c,
  ss as e,
  Vt as f,
  Wt as p
};
//# sourceMappingURL=external-3Ymlb0_2.js.map
