"use client";
/**
   * table-core
   *
   * Copyright (c) TanStack
   *
   * This source code is licensed under the MIT license found in the
   * LICENSE.md file in the root directory of this source tree.
   *
   * @license MIT
   */
function I(e, o) {
  return typeof e == "function" ? e(o) : e;
}
function $(e, o) {
  return (t) => {
    o.setState((n) => ({
      ...n,
      [e]: I(t, n[e])
    }));
  };
}
function A(e) {
  return e instanceof Function;
}
function Se(e) {
  return Array.isArray(e) && e.every((o) => typeof o == "number");
}
function me(e, o) {
  const t = [], n = (i) => {
    i.forEach((r) => {
      t.push(r);
      const l = o(r);
      l != null && l.length && n(l);
    });
  };
  return n(e), t;
}
function m(e, o, t) {
  let n = [], i;
  return (r) => {
    let l;
    t.key && t.debug && (l = Date.now());
    const u = e(r);
    if (!(u.length !== n.length || u.some((f, S) => n[S] !== f)))
      return i;
    n = u;
    let a;
    if (t.key && t.debug && (a = Date.now()), i = o(...u), t == null || t.onChange == null || t.onChange(i), t.key && t.debug && t != null && t.debug()) {
      const f = Math.round((Date.now() - l) * 100) / 100, S = Math.round((Date.now() - a) * 100) / 100, d = S / 16, s = (c, p) => {
        for (c = String(c); c.length < p; )
          c = " " + c;
        return c;
      };
      console.info(`%c⏱ ${s(S, 5)} /${s(f, 5)} ms`, `
            font-size: .6rem;
            font-weight: bold;
            color: hsl(${Math.max(0, Math.min(120 - 120 * d, 120))}deg 100% 31%);`, t?.key);
    }
    return i;
  };
}
function C(e, o, t, n) {
  return {
    debug: () => {
      var i;
      return (i = e?.debugAll) != null ? i : e[o];
    },
    key: process.env.NODE_ENV === "development" && t,
    onChange: n
  };
}
function Ce(e, o, t, n) {
  const i = () => {
    var l;
    return (l = r.getValue()) != null ? l : e.options.renderFallbackValue;
  }, r = {
    id: `${o.id}_${t.id}`,
    row: o,
    column: t,
    getValue: () => o.getValue(n),
    renderValue: i,
    getContext: m(() => [e, t, o, r], (l, u, g, a) => ({
      table: l,
      column: u,
      row: g,
      cell: a,
      getValue: a.getValue,
      renderValue: a.renderValue
    }), C(e.options, "debugCells", "cell.getContext"))
  };
  return e._features.forEach((l) => {
    l.createCell == null || l.createCell(r, t, o, e);
  }, {}), r;
}
function Re(e, o, t, n) {
  var i, r;
  const u = {
    ...e._getDefaultColumnDef(),
    ...o
  }, g = u.accessorKey;
  let a = (i = (r = u.id) != null ? r : g ? typeof String.prototype.replaceAll == "function" ? g.replaceAll(".", "_") : g.replace(/\./g, "_") : void 0) != null ? i : typeof u.header == "string" ? u.header : void 0, f;
  if (u.accessorFn ? f = u.accessorFn : g && (g.includes(".") ? f = (d) => {
    let s = d;
    for (const p of g.split(".")) {
      var c;
      s = (c = s) == null ? void 0 : c[p], process.env.NODE_ENV !== "production" && s === void 0 && console.warn(`"${p}" in deeply nested key "${g}" returned undefined.`);
    }
    return s;
  } : f = (d) => d[u.accessorKey]), !a)
    throw process.env.NODE_ENV !== "production" ? new Error(u.accessorFn ? "Columns require an id when using an accessorFn" : "Columns require an id when using a non-string header") : new Error();
  let S = {
    id: `${String(a)}`,
    accessorFn: f,
    parent: n,
    depth: t,
    columnDef: u,
    columns: [],
    getFlatColumns: m(() => [!0], () => {
      var d;
      return [S, ...(d = S.columns) == null ? void 0 : d.flatMap((s) => s.getFlatColumns())];
    }, C(e.options, "debugColumns", "column.getFlatColumns")),
    getLeafColumns: m(() => [e._getOrderColumnsFn()], (d) => {
      var s;
      if ((s = S.columns) != null && s.length) {
        let c = S.columns.flatMap((p) => p.getLeafColumns());
        return d(c);
      }
      return [S];
    }, C(e.options, "debugColumns", "column.getLeafColumns"))
  };
  for (const d of e._features)
    d.createColumn == null || d.createColumn(S, e);
  return S;
}
const _ = "debugHeaders";
function ne(e, o, t) {
  var n;
  let r = {
    id: (n = t.id) != null ? n : o.id,
    column: o,
    index: t.index,
    isPlaceholder: !!t.isPlaceholder,
    placeholderId: t.placeholderId,
    depth: t.depth,
    subHeaders: [],
    colSpan: 0,
    rowSpan: 0,
    headerGroup: null,
    getLeafHeaders: () => {
      const l = [], u = (g) => {
        g.subHeaders && g.subHeaders.length && g.subHeaders.map(u), l.push(g);
      };
      return u(r), l;
    },
    getContext: () => ({
      table: e,
      header: r,
      column: o
    })
  };
  return e._features.forEach((l) => {
    l.createHeader == null || l.createHeader(r, e);
  }), r;
}
const we = {
  createTable: (e) => {
    e.getHeaderGroups = m(() => [e.getAllColumns(), e.getVisibleLeafColumns(), e.getState().columnPinning.left, e.getState().columnPinning.right], (o, t, n, i) => {
      var r, l;
      const u = (r = n?.map((S) => t.find((d) => d.id === S)).filter(Boolean)) != null ? r : [], g = (l = i?.map((S) => t.find((d) => d.id === S)).filter(Boolean)) != null ? l : [], a = t.filter((S) => !(n != null && n.includes(S.id)) && !(i != null && i.includes(S.id)));
      return G(o, [...u, ...a, ...g], e);
    }, C(e.options, _, "getHeaderGroups")), e.getCenterHeaderGroups = m(() => [e.getAllColumns(), e.getVisibleLeafColumns(), e.getState().columnPinning.left, e.getState().columnPinning.right], (o, t, n, i) => (t = t.filter((r) => !(n != null && n.includes(r.id)) && !(i != null && i.includes(r.id))), G(o, t, e, "center")), C(e.options, _, "getCenterHeaderGroups")), e.getLeftHeaderGroups = m(() => [e.getAllColumns(), e.getVisibleLeafColumns(), e.getState().columnPinning.left], (o, t, n) => {
      var i;
      const r = (i = n?.map((l) => t.find((u) => u.id === l)).filter(Boolean)) != null ? i : [];
      return G(o, r, e, "left");
    }, C(e.options, _, "getLeftHeaderGroups")), e.getRightHeaderGroups = m(() => [e.getAllColumns(), e.getVisibleLeafColumns(), e.getState().columnPinning.right], (o, t, n) => {
      var i;
      const r = (i = n?.map((l) => t.find((u) => u.id === l)).filter(Boolean)) != null ? i : [];
      return G(o, r, e, "right");
    }, C(e.options, _, "getRightHeaderGroups")), e.getFooterGroups = m(() => [e.getHeaderGroups()], (o) => [...o].reverse(), C(e.options, _, "getFooterGroups")), e.getLeftFooterGroups = m(() => [e.getLeftHeaderGroups()], (o) => [...o].reverse(), C(e.options, _, "getLeftFooterGroups")), e.getCenterFooterGroups = m(() => [e.getCenterHeaderGroups()], (o) => [...o].reverse(), C(e.options, _, "getCenterFooterGroups")), e.getRightFooterGroups = m(() => [e.getRightHeaderGroups()], (o) => [...o].reverse(), C(e.options, _, "getRightFooterGroups")), e.getFlatHeaders = m(() => [e.getHeaderGroups()], (o) => o.map((t) => t.headers).flat(), C(e.options, _, "getFlatHeaders")), e.getLeftFlatHeaders = m(() => [e.getLeftHeaderGroups()], (o) => o.map((t) => t.headers).flat(), C(e.options, _, "getLeftFlatHeaders")), e.getCenterFlatHeaders = m(() => [e.getCenterHeaderGroups()], (o) => o.map((t) => t.headers).flat(), C(e.options, _, "getCenterFlatHeaders")), e.getRightFlatHeaders = m(() => [e.getRightHeaderGroups()], (o) => o.map((t) => t.headers).flat(), C(e.options, _, "getRightFlatHeaders")), e.getCenterLeafHeaders = m(() => [e.getCenterFlatHeaders()], (o) => o.filter((t) => {
      var n;
      return !((n = t.subHeaders) != null && n.length);
    }), C(e.options, _, "getCenterLeafHeaders")), e.getLeftLeafHeaders = m(() => [e.getLeftFlatHeaders()], (o) => o.filter((t) => {
      var n;
      return !((n = t.subHeaders) != null && n.length);
    }), C(e.options, _, "getLeftLeafHeaders")), e.getRightLeafHeaders = m(() => [e.getRightFlatHeaders()], (o) => o.filter((t) => {
      var n;
      return !((n = t.subHeaders) != null && n.length);
    }), C(e.options, _, "getRightLeafHeaders")), e.getLeafHeaders = m(() => [e.getLeftHeaderGroups(), e.getCenterHeaderGroups(), e.getRightHeaderGroups()], (o, t, n) => {
      var i, r, l, u, g, a;
      return [...(i = (r = o[0]) == null ? void 0 : r.headers) != null ? i : [], ...(l = (u = t[0]) == null ? void 0 : u.headers) != null ? l : [], ...(g = (a = n[0]) == null ? void 0 : a.headers) != null ? g : []].map((f) => f.getLeafHeaders()).flat();
    }, C(e.options, _, "getLeafHeaders"));
  }
};
function G(e, o, t, n) {
  var i, r;
  let l = 0;
  const u = function(d, s) {
    s === void 0 && (s = 1), l = Math.max(l, s), d.filter((c) => c.getIsVisible()).forEach((c) => {
      var p;
      (p = c.columns) != null && p.length && u(c.columns, s + 1);
    }, 0);
  };
  u(e);
  let g = [];
  const a = (d, s) => {
    const c = {
      depth: s,
      id: [n, `${s}`].filter(Boolean).join("_"),
      headers: []
    }, p = [];
    d.forEach((R) => {
      const w = [...p].reverse()[0], h = R.column.depth === c.depth;
      let v, M = !1;
      if (h && R.column.parent ? v = R.column.parent : (v = R.column, M = !0), w && w?.column === v)
        w.subHeaders.push(R);
      else {
        const F = ne(t, v, {
          id: [n, s, v.id, R?.id].filter(Boolean).join("_"),
          isPlaceholder: M,
          placeholderId: M ? `${p.filter((E) => E.column === v).length}` : void 0,
          depth: s,
          index: p.length
        });
        F.subHeaders.push(R), p.push(F);
      }
      c.headers.push(R), R.headerGroup = c;
    }), g.push(c), s > 0 && a(p, s - 1);
  }, f = o.map((d, s) => ne(t, d, {
    depth: l,
    index: s
  }));
  a(f, l - 1), g.reverse();
  const S = (d) => d.filter((c) => c.column.getIsVisible()).map((c) => {
    let p = 0, R = 0, w = [0];
    c.subHeaders && c.subHeaders.length ? (w = [], S(c.subHeaders).forEach((v) => {
      let {
        colSpan: M,
        rowSpan: F
      } = v;
      p += M, w.push(F);
    })) : p = 1;
    const h = Math.min(...w);
    return R = R + h, c.colSpan = p, c.rowSpan = R, {
      colSpan: p,
      rowSpan: R
    };
  });
  return S((i = (r = g[0]) == null ? void 0 : r.headers) != null ? i : []), g;
}
const Q = (e, o, t, n, i, r, l) => {
  let u = {
    id: o,
    index: n,
    original: t,
    depth: i,
    parentId: l,
    _valuesCache: {},
    _uniqueValuesCache: {},
    getValue: (g) => {
      if (u._valuesCache.hasOwnProperty(g))
        return u._valuesCache[g];
      const a = e.getColumn(g);
      if (a != null && a.accessorFn)
        return u._valuesCache[g] = a.accessorFn(u.original, n), u._valuesCache[g];
    },
    getUniqueValues: (g) => {
      if (u._uniqueValuesCache.hasOwnProperty(g))
        return u._uniqueValuesCache[g];
      const a = e.getColumn(g);
      if (a != null && a.accessorFn)
        return a.columnDef.getUniqueValues ? (u._uniqueValuesCache[g] = a.columnDef.getUniqueValues(u.original, n), u._uniqueValuesCache[g]) : (u._uniqueValuesCache[g] = [u.getValue(g)], u._uniqueValuesCache[g]);
    },
    renderValue: (g) => {
      var a;
      return (a = u.getValue(g)) != null ? a : e.options.renderFallbackValue;
    },
    subRows: [],
    getLeafRows: () => me(u.subRows, (g) => g.subRows),
    getParentRow: () => u.parentId ? e.getRow(u.parentId, !0) : void 0,
    getParentRows: () => {
      let g = [], a = u;
      for (; ; ) {
        const f = a.getParentRow();
        if (!f) break;
        g.push(f), a = f;
      }
      return g.reverse();
    },
    getAllCells: m(() => [e.getAllLeafColumns()], (g) => g.map((a) => Ce(e, u, a, a.id)), C(e.options, "debugRows", "getAllCells")),
    _getAllCellsByColumnId: m(() => [u.getAllCells()], (g) => g.reduce((a, f) => (a[f.column.id] = f, a), {}), C(e.options, "debugRows", "getAllCellsByColumnId"))
  };
  for (let g = 0; g < e._features.length; g++) {
    const a = e._features[g];
    a == null || a.createRow == null || a.createRow(u, e);
  }
  return u;
}, he = {
  createColumn: (e, o) => {
    e._getFacetedRowModel = o.options.getFacetedRowModel && o.options.getFacetedRowModel(o, e.id), e.getFacetedRowModel = () => e._getFacetedRowModel ? e._getFacetedRowModel() : o.getPreFilteredRowModel(), e._getFacetedUniqueValues = o.options.getFacetedUniqueValues && o.options.getFacetedUniqueValues(o, e.id), e.getFacetedUniqueValues = () => e._getFacetedUniqueValues ? e._getFacetedUniqueValues() : /* @__PURE__ */ new Map(), e._getFacetedMinMaxValues = o.options.getFacetedMinMaxValues && o.options.getFacetedMinMaxValues(o, e.id), e.getFacetedMinMaxValues = () => {
      if (e._getFacetedMinMaxValues)
        return e._getFacetedMinMaxValues();
    };
  }
}, ie = (e, o, t) => {
  var n, i;
  const r = t == null || (n = t.toString()) == null ? void 0 : n.toLowerCase();
  return !!(!((i = e.getValue(o)) == null || (i = i.toString()) == null || (i = i.toLowerCase()) == null) && i.includes(r));
};
ie.autoRemove = (e) => V(e);
const re = (e, o, t) => {
  var n;
  return !!(!((n = e.getValue(o)) == null || (n = n.toString()) == null) && n.includes(t));
};
re.autoRemove = (e) => V(e);
const le = (e, o, t) => {
  var n;
  return ((n = e.getValue(o)) == null || (n = n.toString()) == null ? void 0 : n.toLowerCase()) === t?.toLowerCase();
};
le.autoRemove = (e) => V(e);
const se = (e, o, t) => {
  var n;
  return (n = e.getValue(o)) == null ? void 0 : n.includes(t);
};
se.autoRemove = (e) => V(e);
const ue = (e, o, t) => !t.some((n) => {
  var i;
  return !((i = e.getValue(o)) != null && i.includes(n));
});
ue.autoRemove = (e) => V(e) || !(e != null && e.length);
const ge = (e, o, t) => t.some((n) => {
  var i;
  return (i = e.getValue(o)) == null ? void 0 : i.includes(n);
});
ge.autoRemove = (e) => V(e) || !(e != null && e.length);
const ae = (e, o, t) => e.getValue(o) === t;
ae.autoRemove = (e) => V(e);
const de = (e, o, t) => e.getValue(o) == t;
de.autoRemove = (e) => V(e);
const W = (e, o, t) => {
  let [n, i] = t;
  const r = e.getValue(o);
  return r >= n && r <= i;
};
W.resolveFilterValue = (e) => {
  let [o, t] = e, n = typeof o != "number" ? parseFloat(o) : o, i = typeof t != "number" ? parseFloat(t) : t, r = o === null || Number.isNaN(n) ? -1 / 0 : n, l = t === null || Number.isNaN(i) ? 1 / 0 : i;
  if (r > l) {
    const u = r;
    r = l, l = u;
  }
  return [r, l];
};
W.autoRemove = (e) => V(e) || V(e[0]) && V(e[1]);
const P = {
  includesString: ie,
  includesStringSensitive: re,
  equalsString: le,
  arrIncludes: se,
  arrIncludesAll: ue,
  arrIncludesSome: ge,
  equals: ae,
  weakEquals: de,
  inNumberRange: W
};
function V(e) {
  return e == null || e === "";
}
const ve = {
  getDefaultColumnDef: () => ({
    filterFn: "auto"
  }),
  getInitialState: (e) => ({
    columnFilters: [],
    ...e
  }),
  getDefaultOptions: (e) => ({
    onColumnFiltersChange: $("columnFilters", e),
    filterFromLeafRows: !1,
    maxLeafRowFilterDepth: 100
  }),
  createColumn: (e, o) => {
    e.getAutoFilterFn = () => {
      const t = o.getCoreRowModel().flatRows[0], n = t?.getValue(e.id);
      return typeof n == "string" ? P.includesString : typeof n == "number" ? P.inNumberRange : typeof n == "boolean" || n !== null && typeof n == "object" ? P.equals : Array.isArray(n) ? P.arrIncludes : P.weakEquals;
    }, e.getFilterFn = () => {
      var t, n;
      return A(e.columnDef.filterFn) ? e.columnDef.filterFn : e.columnDef.filterFn === "auto" ? e.getAutoFilterFn() : (
        // @ts-ignore
        (t = (n = o.options.filterFns) == null ? void 0 : n[e.columnDef.filterFn]) != null ? t : P[e.columnDef.filterFn]
      );
    }, e.getCanFilter = () => {
      var t, n, i;
      return ((t = e.columnDef.enableColumnFilter) != null ? t : !0) && ((n = o.options.enableColumnFilters) != null ? n : !0) && ((i = o.options.enableFilters) != null ? i : !0) && !!e.accessorFn;
    }, e.getIsFiltered = () => e.getFilterIndex() > -1, e.getFilterValue = () => {
      var t;
      return (t = o.getState().columnFilters) == null || (t = t.find((n) => n.id === e.id)) == null ? void 0 : t.value;
    }, e.getFilterIndex = () => {
      var t, n;
      return (t = (n = o.getState().columnFilters) == null ? void 0 : n.findIndex((i) => i.id === e.id)) != null ? t : -1;
    }, e.setFilterValue = (t) => {
      o.setColumnFilters((n) => {
        const i = e.getFilterFn(), r = n?.find((f) => f.id === e.id), l = I(t, r ? r.value : void 0);
        if (oe(i, l, e)) {
          var u;
          return (u = n?.filter((f) => f.id !== e.id)) != null ? u : [];
        }
        const g = {
          id: e.id,
          value: l
        };
        if (r) {
          var a;
          return (a = n?.map((f) => f.id === e.id ? g : f)) != null ? a : [];
        }
        return n != null && n.length ? [...n, g] : [g];
      });
    };
  },
  createRow: (e, o) => {
    e.columnFilters = {}, e.columnFiltersMeta = {};
  },
  createTable: (e) => {
    e.setColumnFilters = (o) => {
      const t = e.getAllLeafColumns(), n = (i) => {
        var r;
        return (r = I(o, i)) == null ? void 0 : r.filter((l) => {
          const u = t.find((g) => g.id === l.id);
          if (u) {
            const g = u.getFilterFn();
            if (oe(g, l.value, u))
              return !1;
          }
          return !0;
        });
      };
      e.options.onColumnFiltersChange == null || e.options.onColumnFiltersChange(n);
    }, e.resetColumnFilters = (o) => {
      var t, n;
      e.setColumnFilters(o ? [] : (t = (n = e.initialState) == null ? void 0 : n.columnFilters) != null ? t : []);
    }, e.getPreFilteredRowModel = () => e.getCoreRowModel(), e.getFilteredRowModel = () => (!e._getFilteredRowModel && e.options.getFilteredRowModel && (e._getFilteredRowModel = e.options.getFilteredRowModel(e)), e.options.manualFiltering || !e._getFilteredRowModel ? e.getPreFilteredRowModel() : e._getFilteredRowModel());
  }
};
function oe(e, o, t) {
  return (e && e.autoRemove ? e.autoRemove(o, t) : !1) || typeof o > "u" || typeof o == "string" && !o;
}
const _e = (e, o, t) => t.reduce((n, i) => {
  const r = i.getValue(e);
  return n + (typeof r == "number" ? r : 0);
}, 0), Fe = (e, o, t) => {
  let n;
  return t.forEach((i) => {
    const r = i.getValue(e);
    r != null && (n > r || n === void 0 && r >= r) && (n = r);
  }), n;
}, $e = (e, o, t) => {
  let n;
  return t.forEach((i) => {
    const r = i.getValue(e);
    r != null && (n < r || n === void 0 && r >= r) && (n = r);
  }), n;
}, Ve = (e, o, t) => {
  let n, i;
  return t.forEach((r) => {
    const l = r.getValue(e);
    l != null && (n === void 0 ? l >= l && (n = i = l) : (n > l && (n = l), i < l && (i = l)));
  }), [n, i];
}, Me = (e, o) => {
  let t = 0, n = 0;
  if (o.forEach((i) => {
    let r = i.getValue(e);
    r != null && (r = +r) >= r && (++t, n += r);
  }), t) return n / t;
}, Pe = (e, o) => {
  if (!o.length)
    return;
  const t = o.map((r) => r.getValue(e));
  if (!Se(t))
    return;
  if (t.length === 1)
    return t[0];
  const n = Math.floor(t.length / 2), i = t.sort((r, l) => r - l);
  return t.length % 2 !== 0 ? i[n] : (i[n - 1] + i[n]) / 2;
}, Ie = (e, o) => Array.from(new Set(o.map((t) => t.getValue(e))).values()), xe = (e, o) => new Set(o.map((t) => t.getValue(e))).size, Ee = (e, o) => o.length, z = {
  sum: _e,
  min: Fe,
  max: $e,
  extent: Ve,
  mean: Me,
  median: Pe,
  unique: Ie,
  uniqueCount: xe,
  count: Ee
}, De = {
  getDefaultColumnDef: () => ({
    aggregatedCell: (e) => {
      var o, t;
      return (o = (t = e.getValue()) == null || t.toString == null ? void 0 : t.toString()) != null ? o : null;
    },
    aggregationFn: "auto"
  }),
  getInitialState: (e) => ({
    grouping: [],
    ...e
  }),
  getDefaultOptions: (e) => ({
    onGroupingChange: $("grouping", e),
    groupedColumnMode: "reorder"
  }),
  createColumn: (e, o) => {
    e.toggleGrouping = () => {
      o.setGrouping((t) => t != null && t.includes(e.id) ? t.filter((n) => n !== e.id) : [...t ?? [], e.id]);
    }, e.getCanGroup = () => {
      var t, n;
      return ((t = e.columnDef.enableGrouping) != null ? t : !0) && ((n = o.options.enableGrouping) != null ? n : !0) && (!!e.accessorFn || !!e.columnDef.getGroupingValue);
    }, e.getIsGrouped = () => {
      var t;
      return (t = o.getState().grouping) == null ? void 0 : t.includes(e.id);
    }, e.getGroupedIndex = () => {
      var t;
      return (t = o.getState().grouping) == null ? void 0 : t.indexOf(e.id);
    }, e.getToggleGroupingHandler = () => {
      const t = e.getCanGroup();
      return () => {
        t && e.toggleGrouping();
      };
    }, e.getAutoAggregationFn = () => {
      const t = o.getCoreRowModel().flatRows[0], n = t?.getValue(e.id);
      if (typeof n == "number")
        return z.sum;
      if (Object.prototype.toString.call(n) === "[object Date]")
        return z.extent;
    }, e.getAggregationFn = () => {
      var t, n;
      if (!e)
        throw new Error();
      return A(e.columnDef.aggregationFn) ? e.columnDef.aggregationFn : e.columnDef.aggregationFn === "auto" ? e.getAutoAggregationFn() : (t = (n = o.options.aggregationFns) == null ? void 0 : n[e.columnDef.aggregationFn]) != null ? t : z[e.columnDef.aggregationFn];
    };
  },
  createTable: (e) => {
    e.setGrouping = (o) => e.options.onGroupingChange == null ? void 0 : e.options.onGroupingChange(o), e.resetGrouping = (o) => {
      var t, n;
      e.setGrouping(o ? [] : (t = (n = e.initialState) == null ? void 0 : n.grouping) != null ? t : []);
    }, e.getPreGroupedRowModel = () => e.getFilteredRowModel(), e.getGroupedRowModel = () => (!e._getGroupedRowModel && e.options.getGroupedRowModel && (e._getGroupedRowModel = e.options.getGroupedRowModel(e)), e.options.manualGrouping || !e._getGroupedRowModel ? e.getPreGroupedRowModel() : e._getGroupedRowModel());
  },
  createRow: (e, o) => {
    e.getIsGrouped = () => !!e.groupingColumnId, e.getGroupingValue = (t) => {
      if (e._groupingValuesCache.hasOwnProperty(t))
        return e._groupingValuesCache[t];
      const n = o.getColumn(t);
      return n != null && n.columnDef.getGroupingValue ? (e._groupingValuesCache[t] = n.columnDef.getGroupingValue(e.original), e._groupingValuesCache[t]) : e.getValue(t);
    }, e._groupingValuesCache = {};
  },
  createCell: (e, o, t, n) => {
    e.getIsGrouped = () => o.getIsGrouped() && o.id === t.groupingColumnId, e.getIsPlaceholder = () => !e.getIsGrouped() && o.getIsGrouped(), e.getIsAggregated = () => {
      var i;
      return !e.getIsGrouped() && !e.getIsPlaceholder() && !!((i = t.subRows) != null && i.length);
    };
  }
};
function ye(e, o, t) {
  if (!(o != null && o.length) || !t)
    return e;
  const n = e.filter((r) => !o.includes(r.id));
  return t === "remove" ? n : [...o.map((r) => e.find((l) => l.id === r)).filter(Boolean), ...n];
}
const Ge = {
  getInitialState: (e) => ({
    columnOrder: [],
    ...e
  }),
  getDefaultOptions: (e) => ({
    onColumnOrderChange: $("columnOrder", e)
  }),
  createColumn: (e, o) => {
    e.getIndex = m((t) => [y(o, t)], (t) => t.findIndex((n) => n.id === e.id), C(o.options, "debugColumns", "getIndex")), e.getIsFirstColumn = (t) => {
      var n;
      return ((n = y(o, t)[0]) == null ? void 0 : n.id) === e.id;
    }, e.getIsLastColumn = (t) => {
      var n;
      const i = y(o, t);
      return ((n = i[i.length - 1]) == null ? void 0 : n.id) === e.id;
    };
  },
  createTable: (e) => {
    e.setColumnOrder = (o) => e.options.onColumnOrderChange == null ? void 0 : e.options.onColumnOrderChange(o), e.resetColumnOrder = (o) => {
      var t;
      e.setColumnOrder(o ? [] : (t = e.initialState.columnOrder) != null ? t : []);
    }, e._getOrderColumnsFn = m(() => [e.getState().columnOrder, e.getState().grouping, e.options.groupedColumnMode], (o, t, n) => (i) => {
      let r = [];
      if (!(o != null && o.length))
        r = i;
      else {
        const l = [...o], u = [...i];
        for (; u.length && l.length; ) {
          const g = l.shift(), a = u.findIndex((f) => f.id === g);
          a > -1 && r.push(u.splice(a, 1)[0]);
        }
        r = [...r, ...u];
      }
      return ye(r, t, n);
    }, C(e.options, "debugTable", "_getOrderColumnsFn"));
  }
}, O = () => ({
  left: [],
  right: []
}), He = {
  getInitialState: (e) => ({
    columnPinning: O(),
    ...e
  }),
  getDefaultOptions: (e) => ({
    onColumnPinningChange: $("columnPinning", e)
  }),
  createColumn: (e, o) => {
    e.pin = (t) => {
      const n = e.getLeafColumns().map((i) => i.id).filter(Boolean);
      o.setColumnPinning((i) => {
        var r, l;
        if (t === "right") {
          var u, g;
          return {
            left: ((u = i?.left) != null ? u : []).filter((S) => !(n != null && n.includes(S))),
            right: [...((g = i?.right) != null ? g : []).filter((S) => !(n != null && n.includes(S))), ...n]
          };
        }
        if (t === "left") {
          var a, f;
          return {
            left: [...((a = i?.left) != null ? a : []).filter((S) => !(n != null && n.includes(S))), ...n],
            right: ((f = i?.right) != null ? f : []).filter((S) => !(n != null && n.includes(S)))
          };
        }
        return {
          left: ((r = i?.left) != null ? r : []).filter((S) => !(n != null && n.includes(S))),
          right: ((l = i?.right) != null ? l : []).filter((S) => !(n != null && n.includes(S)))
        };
      });
    }, e.getCanPin = () => e.getLeafColumns().some((n) => {
      var i, r, l;
      return ((i = n.columnDef.enablePinning) != null ? i : !0) && ((r = (l = o.options.enableColumnPinning) != null ? l : o.options.enablePinning) != null ? r : !0);
    }), e.getIsPinned = () => {
      const t = e.getLeafColumns().map((u) => u.id), {
        left: n,
        right: i
      } = o.getState().columnPinning, r = t.some((u) => n?.includes(u)), l = t.some((u) => i?.includes(u));
      return r ? "left" : l ? "right" : !1;
    }, e.getPinnedIndex = () => {
      var t, n;
      const i = e.getIsPinned();
      return i ? (t = (n = o.getState().columnPinning) == null || (n = n[i]) == null ? void 0 : n.indexOf(e.id)) != null ? t : -1 : 0;
    };
  },
  createRow: (e, o) => {
    e.getCenterVisibleCells = m(() => [e._getAllVisibleCells(), o.getState().columnPinning.left, o.getState().columnPinning.right], (t, n, i) => {
      const r = [...n ?? [], ...i ?? []];
      return t.filter((l) => !r.includes(l.column.id));
    }, C(o.options, "debugRows", "getCenterVisibleCells")), e.getLeftVisibleCells = m(() => [e._getAllVisibleCells(), o.getState().columnPinning.left], (t, n) => (n ?? []).map((r) => t.find((l) => l.column.id === r)).filter(Boolean).map((r) => ({
      ...r,
      position: "left"
    })), C(o.options, "debugRows", "getLeftVisibleCells")), e.getRightVisibleCells = m(() => [e._getAllVisibleCells(), o.getState().columnPinning.right], (t, n) => (n ?? []).map((r) => t.find((l) => l.column.id === r)).filter(Boolean).map((r) => ({
      ...r,
      position: "right"
    })), C(o.options, "debugRows", "getRightVisibleCells"));
  },
  createTable: (e) => {
    e.setColumnPinning = (o) => e.options.onColumnPinningChange == null ? void 0 : e.options.onColumnPinningChange(o), e.resetColumnPinning = (o) => {
      var t, n;
      return e.setColumnPinning(o ? O() : (t = (n = e.initialState) == null ? void 0 : n.columnPinning) != null ? t : O());
    }, e.getIsSomeColumnsPinned = (o) => {
      var t;
      const n = e.getState().columnPinning;
      if (!o) {
        var i, r;
        return !!((i = n.left) != null && i.length || (r = n.right) != null && r.length);
      }
      return !!((t = n[o]) != null && t.length);
    }, e.getLeftLeafColumns = m(() => [e.getAllLeafColumns(), e.getState().columnPinning.left], (o, t) => (t ?? []).map((n) => o.find((i) => i.id === n)).filter(Boolean), C(e.options, "debugColumns", "getLeftLeafColumns")), e.getRightLeafColumns = m(() => [e.getAllLeafColumns(), e.getState().columnPinning.right], (o, t) => (t ?? []).map((n) => o.find((i) => i.id === n)).filter(Boolean), C(e.options, "debugColumns", "getRightLeafColumns")), e.getCenterLeafColumns = m(() => [e.getAllLeafColumns(), e.getState().columnPinning.left, e.getState().columnPinning.right], (o, t, n) => {
      const i = [...t ?? [], ...n ?? []];
      return o.filter((r) => !i.includes(r.id));
    }, C(e.options, "debugColumns", "getCenterLeafColumns"));
  }
};
function Le(e) {
  return e || (typeof document < "u" ? document : null);
}
const H = {
  size: 150,
  minSize: 20,
  maxSize: Number.MAX_SAFE_INTEGER
}, B = () => ({
  startOffset: null,
  startSize: null,
  deltaOffset: null,
  deltaPercentage: null,
  isResizingColumn: !1,
  columnSizingStart: []
}), Ae = {
  getDefaultColumnDef: () => H,
  getInitialState: (e) => ({
    columnSizing: {},
    columnSizingInfo: B(),
    ...e
  }),
  getDefaultOptions: (e) => ({
    columnResizeMode: "onEnd",
    columnResizeDirection: "ltr",
    onColumnSizingChange: $("columnSizing", e),
    onColumnSizingInfoChange: $("columnSizingInfo", e)
  }),
  createColumn: (e, o) => {
    e.getSize = () => {
      var t, n, i;
      const r = o.getState().columnSizing[e.id];
      return Math.min(Math.max((t = e.columnDef.minSize) != null ? t : H.minSize, (n = r ?? e.columnDef.size) != null ? n : H.size), (i = e.columnDef.maxSize) != null ? i : H.maxSize);
    }, e.getStart = m((t) => [t, y(o, t), o.getState().columnSizing], (t, n) => n.slice(0, e.getIndex(t)).reduce((i, r) => i + r.getSize(), 0), C(o.options, "debugColumns", "getStart")), e.getAfter = m((t) => [t, y(o, t), o.getState().columnSizing], (t, n) => n.slice(e.getIndex(t) + 1).reduce((i, r) => i + r.getSize(), 0), C(o.options, "debugColumns", "getAfter")), e.resetSize = () => {
      o.setColumnSizing((t) => {
        let {
          [e.id]: n,
          ...i
        } = t;
        return i;
      });
    }, e.getCanResize = () => {
      var t, n;
      return ((t = e.columnDef.enableResizing) != null ? t : !0) && ((n = o.options.enableColumnResizing) != null ? n : !0);
    }, e.getIsResizing = () => o.getState().columnSizingInfo.isResizingColumn === e.id;
  },
  createHeader: (e, o) => {
    e.getSize = () => {
      let t = 0;
      const n = (i) => {
        if (i.subHeaders.length)
          i.subHeaders.forEach(n);
        else {
          var r;
          t += (r = i.column.getSize()) != null ? r : 0;
        }
      };
      return n(e), t;
    }, e.getStart = () => {
      if (e.index > 0) {
        const t = e.headerGroup.headers[e.index - 1];
        return t.getStart() + t.getSize();
      }
      return 0;
    }, e.getResizeHandler = (t) => {
      const n = o.getColumn(e.column.id), i = n?.getCanResize();
      return (r) => {
        if (!n || !i || (r.persist == null || r.persist(), T(r) && r.touches && r.touches.length > 1))
          return;
        const l = e.getSize(), u = e ? e.getLeafHeaders().map((w) => [w.column.id, w.column.getSize()]) : [[n.id, n.getSize()]], g = T(r) ? Math.round(r.touches[0].clientX) : r.clientX, a = {}, f = (w, h) => {
          typeof h == "number" && (o.setColumnSizingInfo((v) => {
            var M, F;
            const E = o.options.columnResizeDirection === "rtl" ? -1 : 1, b = (h - ((M = v?.startOffset) != null ? M : 0)) * E, ee = Math.max(b / ((F = v?.startSize) != null ? F : 0), -0.999999);
            return v.columnSizingStart.forEach((ce) => {
              let [pe, te] = ce;
              a[pe] = Math.round(Math.max(te + te * ee, 0) * 100) / 100;
            }), {
              ...v,
              deltaOffset: b,
              deltaPercentage: ee
            };
          }), (o.options.columnResizeMode === "onChange" || w === "end") && o.setColumnSizing((v) => ({
            ...v,
            ...a
          })));
        }, S = (w) => f("move", w), d = (w) => {
          f("end", w), o.setColumnSizingInfo((h) => ({
            ...h,
            isResizingColumn: !1,
            startOffset: null,
            startSize: null,
            deltaOffset: null,
            deltaPercentage: null,
            columnSizingStart: []
          }));
        }, s = Le(t), c = {
          moveHandler: (w) => S(w.clientX),
          upHandler: (w) => {
            s?.removeEventListener("mousemove", c.moveHandler), s?.removeEventListener("mouseup", c.upHandler), d(w.clientX);
          }
        }, p = {
          moveHandler: (w) => (w.cancelable && (w.preventDefault(), w.stopPropagation()), S(w.touches[0].clientX), !1),
          upHandler: (w) => {
            var h;
            s?.removeEventListener("touchmove", p.moveHandler), s?.removeEventListener("touchend", p.upHandler), w.cancelable && (w.preventDefault(), w.stopPropagation()), d((h = w.touches[0]) == null ? void 0 : h.clientX);
          }
        }, R = ze() ? {
          passive: !1
        } : !1;
        T(r) ? (s?.addEventListener("touchmove", p.moveHandler, R), s?.addEventListener("touchend", p.upHandler, R)) : (s?.addEventListener("mousemove", c.moveHandler, R), s?.addEventListener("mouseup", c.upHandler, R)), o.setColumnSizingInfo((w) => ({
          ...w,
          startOffset: g,
          startSize: l,
          deltaOffset: 0,
          deltaPercentage: 0,
          columnSizingStart: u,
          isResizingColumn: n.id
        }));
      };
    };
  },
  createTable: (e) => {
    e.setColumnSizing = (o) => e.options.onColumnSizingChange == null ? void 0 : e.options.onColumnSizingChange(o), e.setColumnSizingInfo = (o) => e.options.onColumnSizingInfoChange == null ? void 0 : e.options.onColumnSizingInfoChange(o), e.resetColumnSizing = (o) => {
      var t;
      e.setColumnSizing(o ? {} : (t = e.initialState.columnSizing) != null ? t : {});
    }, e.resetHeaderSizeInfo = (o) => {
      var t;
      e.setColumnSizingInfo(o ? B() : (t = e.initialState.columnSizingInfo) != null ? t : B());
    }, e.getTotalSize = () => {
      var o, t;
      return (o = (t = e.getHeaderGroups()[0]) == null ? void 0 : t.headers.reduce((n, i) => n + i.getSize(), 0)) != null ? o : 0;
    }, e.getLeftTotalSize = () => {
      var o, t;
      return (o = (t = e.getLeftHeaderGroups()[0]) == null ? void 0 : t.headers.reduce((n, i) => n + i.getSize(), 0)) != null ? o : 0;
    }, e.getCenterTotalSize = () => {
      var o, t;
      return (o = (t = e.getCenterHeaderGroups()[0]) == null ? void 0 : t.headers.reduce((n, i) => n + i.getSize(), 0)) != null ? o : 0;
    }, e.getRightTotalSize = () => {
      var o, t;
      return (o = (t = e.getRightHeaderGroups()[0]) == null ? void 0 : t.headers.reduce((n, i) => n + i.getSize(), 0)) != null ? o : 0;
    };
  }
};
let L = null;
function ze() {
  if (typeof L == "boolean") return L;
  let e = !1;
  try {
    const o = {
      get passive() {
        return e = !0, !1;
      }
    }, t = () => {
    };
    window.addEventListener("test", t, o), window.removeEventListener("test", t);
  } catch {
    e = !1;
  }
  return L = e, L;
}
function T(e) {
  return e.type === "touchstart";
}
const Oe = {
  getInitialState: (e) => ({
    columnVisibility: {},
    ...e
  }),
  getDefaultOptions: (e) => ({
    onColumnVisibilityChange: $("columnVisibility", e)
  }),
  createColumn: (e, o) => {
    e.toggleVisibility = (t) => {
      e.getCanHide() && o.setColumnVisibility((n) => ({
        ...n,
        [e.id]: t ?? !e.getIsVisible()
      }));
    }, e.getIsVisible = () => {
      var t, n;
      const i = e.columns;
      return (t = i.length ? i.some((r) => r.getIsVisible()) : (n = o.getState().columnVisibility) == null ? void 0 : n[e.id]) != null ? t : !0;
    }, e.getCanHide = () => {
      var t, n;
      return ((t = e.columnDef.enableHiding) != null ? t : !0) && ((n = o.options.enableHiding) != null ? n : !0);
    }, e.getToggleVisibilityHandler = () => (t) => {
      e.toggleVisibility == null || e.toggleVisibility(t.target.checked);
    };
  },
  createRow: (e, o) => {
    e._getAllVisibleCells = m(() => [e.getAllCells(), o.getState().columnVisibility], (t) => t.filter((n) => n.column.getIsVisible()), C(o.options, "debugRows", "_getAllVisibleCells")), e.getVisibleCells = m(() => [e.getLeftVisibleCells(), e.getCenterVisibleCells(), e.getRightVisibleCells()], (t, n, i) => [...t, ...n, ...i], C(o.options, "debugRows", "getVisibleCells"));
  },
  createTable: (e) => {
    const o = (t, n) => m(() => [n(), n().filter((i) => i.getIsVisible()).map((i) => i.id).join("_")], (i) => i.filter((r) => r.getIsVisible == null ? void 0 : r.getIsVisible()), C(e.options, "debugColumns", t));
    e.getVisibleFlatColumns = o("getVisibleFlatColumns", () => e.getAllFlatColumns()), e.getVisibleLeafColumns = o("getVisibleLeafColumns", () => e.getAllLeafColumns()), e.getLeftVisibleLeafColumns = o("getLeftVisibleLeafColumns", () => e.getLeftLeafColumns()), e.getRightVisibleLeafColumns = o("getRightVisibleLeafColumns", () => e.getRightLeafColumns()), e.getCenterVisibleLeafColumns = o("getCenterVisibleLeafColumns", () => e.getCenterLeafColumns()), e.setColumnVisibility = (t) => e.options.onColumnVisibilityChange == null ? void 0 : e.options.onColumnVisibilityChange(t), e.resetColumnVisibility = (t) => {
      var n;
      e.setColumnVisibility(t ? {} : (n = e.initialState.columnVisibility) != null ? n : {});
    }, e.toggleAllColumnsVisible = (t) => {
      var n;
      t = (n = t) != null ? n : !e.getIsAllColumnsVisible(), e.setColumnVisibility(e.getAllLeafColumns().reduce((i, r) => ({
        ...i,
        [r.id]: t || !(r.getCanHide != null && r.getCanHide())
      }), {}));
    }, e.getIsAllColumnsVisible = () => !e.getAllLeafColumns().some((t) => !(t.getIsVisible != null && t.getIsVisible())), e.getIsSomeColumnsVisible = () => e.getAllLeafColumns().some((t) => t.getIsVisible == null ? void 0 : t.getIsVisible()), e.getToggleAllColumnsVisibilityHandler = () => (t) => {
      var n;
      e.toggleAllColumnsVisible((n = t.target) == null ? void 0 : n.checked);
    };
  }
};
function y(e, o) {
  return o ? o === "center" ? e.getCenterVisibleLeafColumns() : o === "left" ? e.getLeftVisibleLeafColumns() : e.getRightVisibleLeafColumns() : e.getVisibleLeafColumns();
}
const Be = {
  createTable: (e) => {
    e._getGlobalFacetedRowModel = e.options.getFacetedRowModel && e.options.getFacetedRowModel(e, "__global__"), e.getGlobalFacetedRowModel = () => e.options.manualFiltering || !e._getGlobalFacetedRowModel ? e.getPreFilteredRowModel() : e._getGlobalFacetedRowModel(), e._getGlobalFacetedUniqueValues = e.options.getFacetedUniqueValues && e.options.getFacetedUniqueValues(e, "__global__"), e.getGlobalFacetedUniqueValues = () => e._getGlobalFacetedUniqueValues ? e._getGlobalFacetedUniqueValues() : /* @__PURE__ */ new Map(), e._getGlobalFacetedMinMaxValues = e.options.getFacetedMinMaxValues && e.options.getFacetedMinMaxValues(e, "__global__"), e.getGlobalFacetedMinMaxValues = () => {
      if (e._getGlobalFacetedMinMaxValues)
        return e._getGlobalFacetedMinMaxValues();
    };
  }
}, Te = {
  getInitialState: (e) => ({
    globalFilter: void 0,
    ...e
  }),
  getDefaultOptions: (e) => ({
    onGlobalFilterChange: $("globalFilter", e),
    globalFilterFn: "auto",
    getColumnCanGlobalFilter: (o) => {
      var t;
      const n = (t = e.getCoreRowModel().flatRows[0]) == null || (t = t._getAllCellsByColumnId()[o.id]) == null ? void 0 : t.getValue();
      return typeof n == "string" || typeof n == "number";
    }
  }),
  createColumn: (e, o) => {
    e.getCanGlobalFilter = () => {
      var t, n, i, r;
      return ((t = e.columnDef.enableGlobalFilter) != null ? t : !0) && ((n = o.options.enableGlobalFilter) != null ? n : !0) && ((i = o.options.enableFilters) != null ? i : !0) && ((r = o.options.getColumnCanGlobalFilter == null ? void 0 : o.options.getColumnCanGlobalFilter(e)) != null ? r : !0) && !!e.accessorFn;
    };
  },
  createTable: (e) => {
    e.getGlobalAutoFilterFn = () => P.includesString, e.getGlobalFilterFn = () => {
      var o, t;
      const {
        globalFilterFn: n
      } = e.options;
      return A(n) ? n : n === "auto" ? e.getGlobalAutoFilterFn() : (o = (t = e.options.filterFns) == null ? void 0 : t[n]) != null ? o : P[n];
    }, e.setGlobalFilter = (o) => {
      e.options.onGlobalFilterChange == null || e.options.onGlobalFilterChange(o);
    }, e.resetGlobalFilter = (o) => {
      e.setGlobalFilter(o ? void 0 : e.initialState.globalFilter);
    };
  }
}, qe = {
  getInitialState: (e) => ({
    expanded: {},
    ...e
  }),
  getDefaultOptions: (e) => ({
    onExpandedChange: $("expanded", e),
    paginateExpandedRows: !0
  }),
  createTable: (e) => {
    let o = !1, t = !1;
    e._autoResetExpanded = () => {
      var n, i;
      if (!o) {
        e._queue(() => {
          o = !0;
        });
        return;
      }
      if ((n = (i = e.options.autoResetAll) != null ? i : e.options.autoResetExpanded) != null ? n : !e.options.manualExpanding) {
        if (t) return;
        t = !0, e._queue(() => {
          e.resetExpanded(), t = !1;
        });
      }
    }, e.setExpanded = (n) => e.options.onExpandedChange == null ? void 0 : e.options.onExpandedChange(n), e.toggleAllRowsExpanded = (n) => {
      n ?? !e.getIsAllRowsExpanded() ? e.setExpanded(!0) : e.setExpanded({});
    }, e.resetExpanded = (n) => {
      var i, r;
      e.setExpanded(n ? {} : (i = (r = e.initialState) == null ? void 0 : r.expanded) != null ? i : {});
    }, e.getCanSomeRowsExpand = () => e.getPrePaginationRowModel().flatRows.some((n) => n.getCanExpand()), e.getToggleAllRowsExpandedHandler = () => (n) => {
      n.persist == null || n.persist(), e.toggleAllRowsExpanded();
    }, e.getIsSomeRowsExpanded = () => {
      const n = e.getState().expanded;
      return n === !0 || Object.values(n).some(Boolean);
    }, e.getIsAllRowsExpanded = () => {
      const n = e.getState().expanded;
      return typeof n == "boolean" ? n === !0 : !(!Object.keys(n).length || e.getRowModel().flatRows.some((i) => !i.getIsExpanded()));
    }, e.getExpandedDepth = () => {
      let n = 0;
      return (e.getState().expanded === !0 ? Object.keys(e.getRowModel().rowsById) : Object.keys(e.getState().expanded)).forEach((r) => {
        const l = r.split(".");
        n = Math.max(n, l.length);
      }), n;
    }, e.getPreExpandedRowModel = () => e.getSortedRowModel(), e.getExpandedRowModel = () => (!e._getExpandedRowModel && e.options.getExpandedRowModel && (e._getExpandedRowModel = e.options.getExpandedRowModel(e)), e.options.manualExpanding || !e._getExpandedRowModel ? e.getPreExpandedRowModel() : e._getExpandedRowModel());
  },
  createRow: (e, o) => {
    e.toggleExpanded = (t) => {
      o.setExpanded((n) => {
        var i;
        const r = n === !0 ? !0 : !!(n != null && n[e.id]);
        let l = {};
        if (n === !0 ? Object.keys(o.getRowModel().rowsById).forEach((u) => {
          l[u] = !0;
        }) : l = n, t = (i = t) != null ? i : !r, !r && t)
          return {
            ...l,
            [e.id]: !0
          };
        if (r && !t) {
          const {
            [e.id]: u,
            ...g
          } = l;
          return g;
        }
        return n;
      });
    }, e.getIsExpanded = () => {
      var t;
      const n = o.getState().expanded;
      return !!((t = o.options.getIsRowExpanded == null ? void 0 : o.options.getIsRowExpanded(e)) != null ? t : n === !0 || n?.[e.id]);
    }, e.getCanExpand = () => {
      var t, n, i;
      return (t = o.options.getRowCanExpand == null ? void 0 : o.options.getRowCanExpand(e)) != null ? t : ((n = o.options.enableExpanding) != null ? n : !0) && !!((i = e.subRows) != null && i.length);
    }, e.getIsAllParentsExpanded = () => {
      let t = !0, n = e;
      for (; t && n.parentId; )
        n = o.getRow(n.parentId, !0), t = n.getIsExpanded();
      return t;
    }, e.getToggleExpandedHandler = () => {
      const t = e.getCanExpand();
      return () => {
        t && e.toggleExpanded();
      };
    };
  }
}, U = 0, j = 10, q = () => ({
  pageIndex: U,
  pageSize: j
}), Ne = {
  getInitialState: (e) => ({
    ...e,
    pagination: {
      ...q(),
      ...e?.pagination
    }
  }),
  getDefaultOptions: (e) => ({
    onPaginationChange: $("pagination", e)
  }),
  createTable: (e) => {
    let o = !1, t = !1;
    e._autoResetPageIndex = () => {
      var n, i;
      if (!o) {
        e._queue(() => {
          o = !0;
        });
        return;
      }
      if ((n = (i = e.options.autoResetAll) != null ? i : e.options.autoResetPageIndex) != null ? n : !e.options.manualPagination) {
        if (t) return;
        t = !0, e._queue(() => {
          e.resetPageIndex(), t = !1;
        });
      }
    }, e.setPagination = (n) => {
      const i = (r) => I(n, r);
      return e.options.onPaginationChange == null ? void 0 : e.options.onPaginationChange(i);
    }, e.resetPagination = (n) => {
      var i;
      e.setPagination(n ? q() : (i = e.initialState.pagination) != null ? i : q());
    }, e.setPageIndex = (n) => {
      e.setPagination((i) => {
        let r = I(n, i.pageIndex);
        const l = typeof e.options.pageCount > "u" || e.options.pageCount === -1 ? Number.MAX_SAFE_INTEGER : e.options.pageCount - 1;
        return r = Math.max(0, Math.min(r, l)), {
          ...i,
          pageIndex: r
        };
      });
    }, e.resetPageIndex = (n) => {
      var i, r;
      e.setPageIndex(n ? U : (i = (r = e.initialState) == null || (r = r.pagination) == null ? void 0 : r.pageIndex) != null ? i : U);
    }, e.resetPageSize = (n) => {
      var i, r;
      e.setPageSize(n ? j : (i = (r = e.initialState) == null || (r = r.pagination) == null ? void 0 : r.pageSize) != null ? i : j);
    }, e.setPageSize = (n) => {
      e.setPagination((i) => {
        const r = Math.max(1, I(n, i.pageSize)), l = i.pageSize * i.pageIndex, u = Math.floor(l / r);
        return {
          ...i,
          pageIndex: u,
          pageSize: r
        };
      });
    }, e.setPageCount = (n) => e.setPagination((i) => {
      var r;
      let l = I(n, (r = e.options.pageCount) != null ? r : -1);
      return typeof l == "number" && (l = Math.max(-1, l)), {
        ...i,
        pageCount: l
      };
    }), e.getPageOptions = m(() => [e.getPageCount()], (n) => {
      let i = [];
      return n && n > 0 && (i = [...new Array(n)].fill(null).map((r, l) => l)), i;
    }, C(e.options, "debugTable", "getPageOptions")), e.getCanPreviousPage = () => e.getState().pagination.pageIndex > 0, e.getCanNextPage = () => {
      const {
        pageIndex: n
      } = e.getState().pagination, i = e.getPageCount();
      return i === -1 ? !0 : i === 0 ? !1 : n < i - 1;
    }, e.previousPage = () => e.setPageIndex((n) => n - 1), e.nextPage = () => e.setPageIndex((n) => n + 1), e.firstPage = () => e.setPageIndex(0), e.lastPage = () => e.setPageIndex(e.getPageCount() - 1), e.getPrePaginationRowModel = () => e.getExpandedRowModel(), e.getPaginationRowModel = () => (!e._getPaginationRowModel && e.options.getPaginationRowModel && (e._getPaginationRowModel = e.options.getPaginationRowModel(e)), e.options.manualPagination || !e._getPaginationRowModel ? e.getPrePaginationRowModel() : e._getPaginationRowModel()), e.getPageCount = () => {
      var n;
      return (n = e.options.pageCount) != null ? n : Math.ceil(e.getRowCount() / e.getState().pagination.pageSize);
    }, e.getRowCount = () => {
      var n;
      return (n = e.options.rowCount) != null ? n : e.getPrePaginationRowModel().rows.length;
    };
  }
}, N = () => ({
  top: [],
  bottom: []
}), ke = {
  getInitialState: (e) => ({
    rowPinning: N(),
    ...e
  }),
  getDefaultOptions: (e) => ({
    onRowPinningChange: $("rowPinning", e)
  }),
  createRow: (e, o) => {
    e.pin = (t, n, i) => {
      const r = n ? e.getLeafRows().map((g) => {
        let {
          id: a
        } = g;
        return a;
      }) : [], l = i ? e.getParentRows().map((g) => {
        let {
          id: a
        } = g;
        return a;
      }) : [], u = /* @__PURE__ */ new Set([...l, e.id, ...r]);
      o.setRowPinning((g) => {
        var a, f;
        if (t === "bottom") {
          var S, d;
          return {
            top: ((S = g?.top) != null ? S : []).filter((p) => !(u != null && u.has(p))),
            bottom: [...((d = g?.bottom) != null ? d : []).filter((p) => !(u != null && u.has(p))), ...Array.from(u)]
          };
        }
        if (t === "top") {
          var s, c;
          return {
            top: [...((s = g?.top) != null ? s : []).filter((p) => !(u != null && u.has(p))), ...Array.from(u)],
            bottom: ((c = g?.bottom) != null ? c : []).filter((p) => !(u != null && u.has(p)))
          };
        }
        return {
          top: ((a = g?.top) != null ? a : []).filter((p) => !(u != null && u.has(p))),
          bottom: ((f = g?.bottom) != null ? f : []).filter((p) => !(u != null && u.has(p)))
        };
      });
    }, e.getCanPin = () => {
      var t;
      const {
        enableRowPinning: n,
        enablePinning: i
      } = o.options;
      return typeof n == "function" ? n(e) : (t = n ?? i) != null ? t : !0;
    }, e.getIsPinned = () => {
      const t = [e.id], {
        top: n,
        bottom: i
      } = o.getState().rowPinning, r = t.some((u) => n?.includes(u)), l = t.some((u) => i?.includes(u));
      return r ? "top" : l ? "bottom" : !1;
    }, e.getPinnedIndex = () => {
      var t, n;
      const i = e.getIsPinned();
      if (!i) return -1;
      const r = (t = i === "top" ? o.getTopRows() : o.getBottomRows()) == null ? void 0 : t.map((l) => {
        let {
          id: u
        } = l;
        return u;
      });
      return (n = r?.indexOf(e.id)) != null ? n : -1;
    };
  },
  createTable: (e) => {
    e.setRowPinning = (o) => e.options.onRowPinningChange == null ? void 0 : e.options.onRowPinningChange(o), e.resetRowPinning = (o) => {
      var t, n;
      return e.setRowPinning(o ? N() : (t = (n = e.initialState) == null ? void 0 : n.rowPinning) != null ? t : N());
    }, e.getIsSomeRowsPinned = (o) => {
      var t;
      const n = e.getState().rowPinning;
      if (!o) {
        var i, r;
        return !!((i = n.top) != null && i.length || (r = n.bottom) != null && r.length);
      }
      return !!((t = n[o]) != null && t.length);
    }, e._getPinnedRows = (o, t, n) => {
      var i;
      return ((i = e.options.keepPinnedRows) == null || i ? (
        //get all rows that are pinned even if they would not be otherwise visible
        //account for expanded parent rows, but not pagination or filtering
        (t ?? []).map((l) => {
          const u = e.getRow(l, !0);
          return u.getIsAllParentsExpanded() ? u : null;
        })
      ) : (
        //else get only visible rows that are pinned
        (t ?? []).map((l) => o.find((u) => u.id === l))
      )).filter(Boolean).map((l) => ({
        ...l,
        position: n
      }));
    }, e.getTopRows = m(() => [e.getRowModel().rows, e.getState().rowPinning.top], (o, t) => e._getPinnedRows(o, t, "top"), C(e.options, "debugRows", "getTopRows")), e.getBottomRows = m(() => [e.getRowModel().rows, e.getState().rowPinning.bottom], (o, t) => e._getPinnedRows(o, t, "bottom"), C(e.options, "debugRows", "getBottomRows")), e.getCenterRows = m(() => [e.getRowModel().rows, e.getState().rowPinning.top, e.getState().rowPinning.bottom], (o, t, n) => {
      const i = /* @__PURE__ */ new Set([...t ?? [], ...n ?? []]);
      return o.filter((r) => !i.has(r.id));
    }, C(e.options, "debugRows", "getCenterRows"));
  }
}, Ue = {
  getInitialState: (e) => ({
    rowSelection: {},
    ...e
  }),
  getDefaultOptions: (e) => ({
    onRowSelectionChange: $("rowSelection", e),
    enableRowSelection: !0,
    enableMultiRowSelection: !0,
    enableSubRowSelection: !0
    // enableGroupingRowSelection: false,
    // isAdditiveSelectEvent: (e: unknown) => !!e.metaKey,
    // isInclusiveSelectEvent: (e: unknown) => !!e.shiftKey,
  }),
  createTable: (e) => {
    e.setRowSelection = (o) => e.options.onRowSelectionChange == null ? void 0 : e.options.onRowSelectionChange(o), e.resetRowSelection = (o) => {
      var t;
      return e.setRowSelection(o ? {} : (t = e.initialState.rowSelection) != null ? t : {});
    }, e.toggleAllRowsSelected = (o) => {
      e.setRowSelection((t) => {
        o = typeof o < "u" ? o : !e.getIsAllRowsSelected();
        const n = {
          ...t
        }, i = e.getPreGroupedRowModel().flatRows;
        return o ? i.forEach((r) => {
          r.getCanSelect() && (n[r.id] = !0);
        }) : i.forEach((r) => {
          delete n[r.id];
        }), n;
      });
    }, e.toggleAllPageRowsSelected = (o) => e.setRowSelection((t) => {
      const n = typeof o < "u" ? o : !e.getIsAllPageRowsSelected(), i = {
        ...t
      };
      return e.getRowModel().rows.forEach((r) => {
        X(i, r.id, n, !0, e);
      }), i;
    }), e.getPreSelectedRowModel = () => e.getCoreRowModel(), e.getSelectedRowModel = m(() => [e.getState().rowSelection, e.getCoreRowModel()], (o, t) => Object.keys(o).length ? k(e, t) : {
      rows: [],
      flatRows: [],
      rowsById: {}
    }, C(e.options, "debugTable", "getSelectedRowModel")), e.getFilteredSelectedRowModel = m(() => [e.getState().rowSelection, e.getFilteredRowModel()], (o, t) => Object.keys(o).length ? k(e, t) : {
      rows: [],
      flatRows: [],
      rowsById: {}
    }, C(e.options, "debugTable", "getFilteredSelectedRowModel")), e.getGroupedSelectedRowModel = m(() => [e.getState().rowSelection, e.getSortedRowModel()], (o, t) => Object.keys(o).length ? k(e, t) : {
      rows: [],
      flatRows: [],
      rowsById: {}
    }, C(e.options, "debugTable", "getGroupedSelectedRowModel")), e.getIsAllRowsSelected = () => {
      const o = e.getFilteredRowModel().flatRows, {
        rowSelection: t
      } = e.getState();
      let n = !!(o.length && Object.keys(t).length);
      return n && o.some((i) => i.getCanSelect() && !t[i.id]) && (n = !1), n;
    }, e.getIsAllPageRowsSelected = () => {
      const o = e.getPaginationRowModel().flatRows.filter((i) => i.getCanSelect()), {
        rowSelection: t
      } = e.getState();
      let n = !!o.length;
      return n && o.some((i) => !t[i.id]) && (n = !1), n;
    }, e.getIsSomeRowsSelected = () => {
      var o;
      const t = Object.keys((o = e.getState().rowSelection) != null ? o : {}).length;
      return t > 0 && t < e.getFilteredRowModel().flatRows.length;
    }, e.getIsSomePageRowsSelected = () => {
      const o = e.getPaginationRowModel().flatRows;
      return e.getIsAllPageRowsSelected() ? !1 : o.filter((t) => t.getCanSelect()).some((t) => t.getIsSelected() || t.getIsSomeSelected());
    }, e.getToggleAllRowsSelectedHandler = () => (o) => {
      e.toggleAllRowsSelected(o.target.checked);
    }, e.getToggleAllPageRowsSelectedHandler = () => (o) => {
      e.toggleAllPageRowsSelected(o.target.checked);
    };
  },
  createRow: (e, o) => {
    e.toggleSelected = (t, n) => {
      const i = e.getIsSelected();
      o.setRowSelection((r) => {
        var l;
        if (t = typeof t < "u" ? t : !i, e.getCanSelect() && i === t)
          return r;
        const u = {
          ...r
        };
        return X(u, e.id, t, (l = n?.selectChildren) != null ? l : !0, o), u;
      });
    }, e.getIsSelected = () => {
      const {
        rowSelection: t
      } = o.getState();
      return Y(e, t);
    }, e.getIsSomeSelected = () => {
      const {
        rowSelection: t
      } = o.getState();
      return K(e, t) === "some";
    }, e.getIsAllSubRowsSelected = () => {
      const {
        rowSelection: t
      } = o.getState();
      return K(e, t) === "all";
    }, e.getCanSelect = () => {
      var t;
      return typeof o.options.enableRowSelection == "function" ? o.options.enableRowSelection(e) : (t = o.options.enableRowSelection) != null ? t : !0;
    }, e.getCanSelectSubRows = () => {
      var t;
      return typeof o.options.enableSubRowSelection == "function" ? o.options.enableSubRowSelection(e) : (t = o.options.enableSubRowSelection) != null ? t : !0;
    }, e.getCanMultiSelect = () => {
      var t;
      return typeof o.options.enableMultiRowSelection == "function" ? o.options.enableMultiRowSelection(e) : (t = o.options.enableMultiRowSelection) != null ? t : !0;
    }, e.getToggleSelectedHandler = () => {
      const t = e.getCanSelect();
      return (n) => {
        var i;
        t && e.toggleSelected((i = n.target) == null ? void 0 : i.checked);
      };
    };
  }
}, X = (e, o, t, n, i) => {
  var r;
  const l = i.getRow(o, !0);
  t ? (l.getCanMultiSelect() || Object.keys(e).forEach((u) => delete e[u]), l.getCanSelect() && (e[o] = !0)) : delete e[o], n && (r = l.subRows) != null && r.length && l.getCanSelectSubRows() && l.subRows.forEach((u) => X(e, u.id, t, n, i));
};
function k(e, o) {
  const t = e.getState().rowSelection, n = [], i = {}, r = function(l, u) {
    return l.map((g) => {
      var a;
      const f = Y(g, t);
      if (f && (n.push(g), i[g.id] = g), (a = g.subRows) != null && a.length && (g = {
        ...g,
        subRows: r(g.subRows)
      }), f)
        return g;
    }).filter(Boolean);
  };
  return {
    rows: r(o.rows),
    flatRows: n,
    rowsById: i
  };
}
function Y(e, o) {
  var t;
  return (t = o[e.id]) != null ? t : !1;
}
function K(e, o, t) {
  var n;
  if (!((n = e.subRows) != null && n.length)) return !1;
  let i = !0, r = !1;
  return e.subRows.forEach((l) => {
    if (!(r && !i) && (l.getCanSelect() && (Y(l, o) ? r = !0 : i = !1), l.subRows && l.subRows.length)) {
      const u = K(l, o);
      u === "all" ? r = !0 : (u === "some" && (r = !0), i = !1);
    }
  }), i ? "all" : r ? "some" : !1;
}
const J = /([0-9]+)/gm, je = (e, o, t) => fe(x(e.getValue(t)).toLowerCase(), x(o.getValue(t)).toLowerCase()), Xe = (e, o, t) => fe(x(e.getValue(t)), x(o.getValue(t))), Ke = (e, o, t) => Z(x(e.getValue(t)).toLowerCase(), x(o.getValue(t)).toLowerCase()), Je = (e, o, t) => Z(x(e.getValue(t)), x(o.getValue(t))), Qe = (e, o, t) => {
  const n = e.getValue(t), i = o.getValue(t);
  return n > i ? 1 : n < i ? -1 : 0;
}, We = (e, o, t) => Z(e.getValue(t), o.getValue(t));
function Z(e, o) {
  return e === o ? 0 : e > o ? 1 : -1;
}
function x(e) {
  return typeof e == "number" ? isNaN(e) || e === 1 / 0 || e === -1 / 0 ? "" : String(e) : typeof e == "string" ? e : "";
}
function fe(e, o) {
  const t = e.split(J).filter(Boolean), n = o.split(J).filter(Boolean);
  for (; t.length && n.length; ) {
    const i = t.shift(), r = n.shift(), l = parseInt(i, 10), u = parseInt(r, 10), g = [l, u].sort();
    if (isNaN(g[0])) {
      if (i > r)
        return 1;
      if (r > i)
        return -1;
      continue;
    }
    if (isNaN(g[1]))
      return isNaN(l) ? -1 : 1;
    if (l > u)
      return 1;
    if (u > l)
      return -1;
  }
  return t.length - n.length;
}
const D = {
  alphanumeric: je,
  alphanumericCaseSensitive: Xe,
  text: Ke,
  textCaseSensitive: Je,
  datetime: Qe,
  basic: We
}, Ye = {
  getInitialState: (e) => ({
    sorting: [],
    ...e
  }),
  getDefaultColumnDef: () => ({
    sortingFn: "auto",
    sortUndefined: 1
  }),
  getDefaultOptions: (e) => ({
    onSortingChange: $("sorting", e),
    isMultiSortEvent: (o) => o.shiftKey
  }),
  createColumn: (e, o) => {
    e.getAutoSortingFn = () => {
      const t = o.getFilteredRowModel().flatRows.slice(10);
      let n = !1;
      for (const i of t) {
        const r = i?.getValue(e.id);
        if (Object.prototype.toString.call(r) === "[object Date]")
          return D.datetime;
        if (typeof r == "string" && (n = !0, r.split(J).length > 1))
          return D.alphanumeric;
      }
      return n ? D.text : D.basic;
    }, e.getAutoSortDir = () => {
      const t = o.getFilteredRowModel().flatRows[0];
      return typeof t?.getValue(e.id) == "string" ? "asc" : "desc";
    }, e.getSortingFn = () => {
      var t, n;
      if (!e)
        throw new Error();
      return A(e.columnDef.sortingFn) ? e.columnDef.sortingFn : e.columnDef.sortingFn === "auto" ? e.getAutoSortingFn() : (t = (n = o.options.sortingFns) == null ? void 0 : n[e.columnDef.sortingFn]) != null ? t : D[e.columnDef.sortingFn];
    }, e.toggleSorting = (t, n) => {
      const i = e.getNextSortingOrder(), r = typeof t < "u" && t !== null;
      o.setSorting((l) => {
        const u = l?.find((s) => s.id === e.id), g = l?.findIndex((s) => s.id === e.id);
        let a = [], f, S = r ? t : i === "desc";
        if (l != null && l.length && e.getCanMultiSort() && n ? u ? f = "toggle" : f = "add" : l != null && l.length && g !== l.length - 1 ? f = "replace" : u ? f = "toggle" : f = "replace", f === "toggle" && (r || i || (f = "remove")), f === "add") {
          var d;
          a = [...l, {
            id: e.id,
            desc: S
          }], a.splice(0, a.length - ((d = o.options.maxMultiSortColCount) != null ? d : Number.MAX_SAFE_INTEGER));
        } else f === "toggle" ? a = l.map((s) => s.id === e.id ? {
          ...s,
          desc: S
        } : s) : f === "remove" ? a = l.filter((s) => s.id !== e.id) : a = [{
          id: e.id,
          desc: S
        }];
        return a;
      });
    }, e.getFirstSortDir = () => {
      var t, n;
      return ((t = (n = e.columnDef.sortDescFirst) != null ? n : o.options.sortDescFirst) != null ? t : e.getAutoSortDir() === "desc") ? "desc" : "asc";
    }, e.getNextSortingOrder = (t) => {
      var n, i;
      const r = e.getFirstSortDir(), l = e.getIsSorted();
      return l ? l !== r && ((n = o.options.enableSortingRemoval) == null || n) && // If enableSortRemove, enable in general
      (!(t && (i = o.options.enableMultiRemove) != null) || i) ? !1 : l === "desc" ? "asc" : "desc" : r;
    }, e.getCanSort = () => {
      var t, n;
      return ((t = e.columnDef.enableSorting) != null ? t : !0) && ((n = o.options.enableSorting) != null ? n : !0) && !!e.accessorFn;
    }, e.getCanMultiSort = () => {
      var t, n;
      return (t = (n = e.columnDef.enableMultiSort) != null ? n : o.options.enableMultiSort) != null ? t : !!e.accessorFn;
    }, e.getIsSorted = () => {
      var t;
      const n = (t = o.getState().sorting) == null ? void 0 : t.find((i) => i.id === e.id);
      return n ? n.desc ? "desc" : "asc" : !1;
    }, e.getSortIndex = () => {
      var t, n;
      return (t = (n = o.getState().sorting) == null ? void 0 : n.findIndex((i) => i.id === e.id)) != null ? t : -1;
    }, e.clearSorting = () => {
      o.setSorting((t) => t != null && t.length ? t.filter((n) => n.id !== e.id) : []);
    }, e.getToggleSortingHandler = () => {
      const t = e.getCanSort();
      return (n) => {
        t && (n.persist == null || n.persist(), e.toggleSorting == null || e.toggleSorting(void 0, e.getCanMultiSort() ? o.options.isMultiSortEvent == null ? void 0 : o.options.isMultiSortEvent(n) : !1));
      };
    };
  },
  createTable: (e) => {
    e.setSorting = (o) => e.options.onSortingChange == null ? void 0 : e.options.onSortingChange(o), e.resetSorting = (o) => {
      var t, n;
      e.setSorting(o ? [] : (t = (n = e.initialState) == null ? void 0 : n.sorting) != null ? t : []);
    }, e.getPreSortedRowModel = () => e.getGroupedRowModel(), e.getSortedRowModel = () => (!e._getSortedRowModel && e.options.getSortedRowModel && (e._getSortedRowModel = e.options.getSortedRowModel(e)), e.options.manualSorting || !e._getSortedRowModel ? e.getPreSortedRowModel() : e._getSortedRowModel());
  }
}, Ze = [
  we,
  Oe,
  Ge,
  He,
  he,
  ve,
  Be,
  //depends on ColumnFaceting
  Te,
  //depends on ColumnFiltering
  Ye,
  De,
  //depends on RowSorting
  qe,
  Ne,
  ke,
  Ue,
  Ae
];
function ot(e) {
  var o, t;
  process.env.NODE_ENV !== "production" && (e.debugAll || e.debugTable) && console.info("Creating Table Instance...");
  const n = [...Ze, ...(o = e._features) != null ? o : []];
  let i = {
    _features: n
  };
  const r = i._features.reduce((d, s) => Object.assign(d, s.getDefaultOptions == null ? void 0 : s.getDefaultOptions(i)), {}), l = (d) => i.options.mergeOptions ? i.options.mergeOptions(r, d) : {
    ...r,
    ...d
  };
  let g = {
    ...{},
    ...(t = e.initialState) != null ? t : {}
  };
  i._features.forEach((d) => {
    var s;
    g = (s = d.getInitialState == null ? void 0 : d.getInitialState(g)) != null ? s : g;
  });
  const a = [];
  let f = !1;
  const S = {
    _features: n,
    options: {
      ...r,
      ...e
    },
    initialState: g,
    _queue: (d) => {
      a.push(d), f || (f = !0, Promise.resolve().then(() => {
        for (; a.length; )
          a.shift()();
        f = !1;
      }).catch((s) => setTimeout(() => {
        throw s;
      })));
    },
    reset: () => {
      i.setState(i.initialState);
    },
    setOptions: (d) => {
      const s = I(d, i.options);
      i.options = l(s);
    },
    getState: () => i.options.state,
    setState: (d) => {
      i.options.onStateChange == null || i.options.onStateChange(d);
    },
    _getRowId: (d, s, c) => {
      var p;
      return (p = i.options.getRowId == null ? void 0 : i.options.getRowId(d, s, c)) != null ? p : `${c ? [c.id, s].join(".") : s}`;
    },
    getCoreRowModel: () => (i._getCoreRowModel || (i._getCoreRowModel = i.options.getCoreRowModel(i)), i._getCoreRowModel()),
    // The final calls start at the bottom of the model,
    // expanded rows, which then work their way up
    getRowModel: () => i.getPaginationRowModel(),
    //in next version, we should just pass in the row model as the optional 2nd arg
    getRow: (d, s) => {
      let c = (s ? i.getPrePaginationRowModel() : i.getRowModel()).rowsById[d];
      if (!c && (c = i.getCoreRowModel().rowsById[d], !c))
        throw process.env.NODE_ENV !== "production" ? new Error(`getRow could not find row with ID: ${d}`) : new Error();
      return c;
    },
    _getDefaultColumnDef: m(() => [i.options.defaultColumn], (d) => {
      var s;
      return d = (s = d) != null ? s : {}, {
        header: (c) => {
          const p = c.header.column.columnDef;
          return p.accessorKey ? p.accessorKey : p.accessorFn ? p.id : null;
        },
        // footer: props => props.header.column.id,
        cell: (c) => {
          var p, R;
          return (p = (R = c.renderValue()) == null || R.toString == null ? void 0 : R.toString()) != null ? p : null;
        },
        ...i._features.reduce((c, p) => Object.assign(c, p.getDefaultColumnDef == null ? void 0 : p.getDefaultColumnDef()), {}),
        ...d
      };
    }, C(e, "debugColumns", "_getDefaultColumnDef")),
    _getColumnDefs: () => i.options.columns,
    getAllColumns: m(() => [i._getColumnDefs()], (d) => {
      const s = function(c, p, R) {
        return R === void 0 && (R = 0), c.map((w) => {
          const h = Re(i, w, R, p), v = w;
          return h.columns = v.columns ? s(v.columns, h, R + 1) : [], h;
        });
      };
      return s(d);
    }, C(e, "debugColumns", "getAllColumns")),
    getAllFlatColumns: m(() => [i.getAllColumns()], (d) => d.flatMap((s) => s.getFlatColumns()), C(e, "debugColumns", "getAllFlatColumns")),
    _getAllFlatColumnsById: m(() => [i.getAllFlatColumns()], (d) => d.reduce((s, c) => (s[c.id] = c, s), {}), C(e, "debugColumns", "getAllFlatColumnsById")),
    getAllLeafColumns: m(() => [i.getAllColumns(), i._getOrderColumnsFn()], (d, s) => {
      let c = d.flatMap((p) => p.getLeafColumns());
      return s(c);
    }, C(e, "debugColumns", "getAllLeafColumns")),
    getColumn: (d) => {
      const s = i._getAllFlatColumnsById()[d];
      return process.env.NODE_ENV !== "production" && !s && console.error(`[Table] Column with id '${d}' does not exist.`), s;
    }
  };
  Object.assign(i, S);
  for (let d = 0; d < i._features.length; d++) {
    const s = i._features[d];
    s == null || s.createTable == null || s.createTable(i);
  }
  return i;
}
function it() {
  return (e) => m(() => [e.options.data], (o) => {
    const t = {
      rows: [],
      flatRows: [],
      rowsById: {}
    }, n = function(i, r, l) {
      r === void 0 && (r = 0);
      const u = [];
      for (let a = 0; a < i.length; a++) {
        const f = Q(e, e._getRowId(i[a], a, l), i[a], a, r, void 0, l?.id);
        if (t.flatRows.push(f), t.rowsById[f.id] = f, u.push(f), e.options.getSubRows) {
          var g;
          f.originalSubRows = e.options.getSubRows(i[a], a), (g = f.originalSubRows) != null && g.length && (f.subRows = n(f.originalSubRows, r + 1, f));
        }
      }
      return u;
    };
    return t.rows = n(o), t;
  }, C(e.options, "debugTable", "getRowModel", () => e._autoResetPageIndex()));
}
function be(e) {
  const o = [], t = (n) => {
    var i;
    o.push(n), (i = n.subRows) != null && i.length && n.getIsExpanded() && n.subRows.forEach(t);
  };
  return e.rows.forEach(t), {
    rows: o,
    flatRows: e.flatRows,
    rowsById: e.rowsById
  };
}
function et(e, o, t) {
  return t.options.filterFromLeafRows ? tt(e, o, t) : nt(e, o, t);
}
function tt(e, o, t) {
  var n;
  const i = [], r = {}, l = (n = t.options.maxLeafRowFilterDepth) != null ? n : 100, u = function(g, a) {
    a === void 0 && (a = 0);
    const f = [];
    for (let d = 0; d < g.length; d++) {
      var S;
      let s = g[d];
      const c = Q(t, s.id, s.original, s.index, s.depth, void 0, s.parentId);
      if (c.columnFilters = s.columnFilters, (S = s.subRows) != null && S.length && a < l) {
        if (c.subRows = u(s.subRows, a + 1), s = c, o(s) && !c.subRows.length) {
          f.push(s), r[s.id] = s, i.push(s);
          continue;
        }
        if (o(s) || c.subRows.length) {
          f.push(s), r[s.id] = s, i.push(s);
          continue;
        }
      } else
        s = c, o(s) && (f.push(s), r[s.id] = s, i.push(s));
    }
    return f;
  };
  return {
    rows: u(e),
    flatRows: i,
    rowsById: r
  };
}
function nt(e, o, t) {
  var n;
  const i = [], r = {}, l = (n = t.options.maxLeafRowFilterDepth) != null ? n : 100, u = function(g, a) {
    a === void 0 && (a = 0);
    const f = [];
    for (let d = 0; d < g.length; d++) {
      let s = g[d];
      if (o(s)) {
        var S;
        if ((S = s.subRows) != null && S.length && a < l) {
          const p = Q(t, s.id, s.original, s.index, s.depth, void 0, s.parentId);
          p.subRows = u(s.subRows, a + 1), s = p;
        }
        f.push(s), i.push(s), r[s.id] = s;
      }
    }
    return f;
  };
  return {
    rows: u(e),
    flatRows: i,
    rowsById: r
  };
}
function rt() {
  return (e) => m(() => [e.getPreFilteredRowModel(), e.getState().columnFilters, e.getState().globalFilter], (o, t, n) => {
    if (!o.rows.length || !(t != null && t.length) && !n) {
      for (let d = 0; d < o.flatRows.length; d++)
        o.flatRows[d].columnFilters = {}, o.flatRows[d].columnFiltersMeta = {};
      return o;
    }
    const i = [], r = [];
    (t ?? []).forEach((d) => {
      var s;
      const c = e.getColumn(d.id);
      if (!c)
        return;
      const p = c.getFilterFn();
      if (!p) {
        process.env.NODE_ENV !== "production" && console.warn(`Could not find a valid 'column.filterFn' for column with the ID: ${c.id}.`);
        return;
      }
      i.push({
        id: d.id,
        filterFn: p,
        resolvedValue: (s = p.resolveFilterValue == null ? void 0 : p.resolveFilterValue(d.value)) != null ? s : d.value
      });
    });
    const l = (t ?? []).map((d) => d.id), u = e.getGlobalFilterFn(), g = e.getAllLeafColumns().filter((d) => d.getCanGlobalFilter());
    n && u && g.length && (l.push("__global__"), g.forEach((d) => {
      var s;
      r.push({
        id: d.id,
        filterFn: u,
        resolvedValue: (s = u.resolveFilterValue == null ? void 0 : u.resolveFilterValue(n)) != null ? s : n
      });
    }));
    let a, f;
    for (let d = 0; d < o.flatRows.length; d++) {
      const s = o.flatRows[d];
      if (s.columnFilters = {}, i.length)
        for (let c = 0; c < i.length; c++) {
          a = i[c];
          const p = a.id;
          s.columnFilters[p] = a.filterFn(s, p, a.resolvedValue, (R) => {
            s.columnFiltersMeta[p] = R;
          });
        }
      if (r.length) {
        for (let c = 0; c < r.length; c++) {
          f = r[c];
          const p = f.id;
          if (f.filterFn(s, p, f.resolvedValue, (R) => {
            s.columnFiltersMeta[p] = R;
          })) {
            s.columnFilters.__global__ = !0;
            break;
          }
        }
        s.columnFilters.__global__ !== !0 && (s.columnFilters.__global__ = !1);
      }
    }
    const S = (d) => {
      for (let s = 0; s < l.length; s++)
        if (d.columnFilters[l[s]] === !1)
          return !1;
      return !0;
    };
    return et(o.rows, S, e);
  }, C(e.options, "debugTable", "getFilteredRowModel", () => e._autoResetPageIndex()));
}
function lt(e) {
  return (o) => m(() => [o.getState().pagination, o.getPrePaginationRowModel(), o.options.paginateExpandedRows ? void 0 : o.getState().expanded], (t, n) => {
    if (!n.rows.length)
      return n;
    const {
      pageSize: i,
      pageIndex: r
    } = t;
    let {
      rows: l,
      flatRows: u,
      rowsById: g
    } = n;
    const a = i * r, f = a + i;
    l = l.slice(a, f);
    let S;
    o.options.paginateExpandedRows ? S = {
      rows: l,
      flatRows: u,
      rowsById: g
    } : S = be({
      rows: l,
      flatRows: u,
      rowsById: g
    }), S.flatRows = [];
    const d = (s) => {
      S.flatRows.push(s), s.subRows.length && s.subRows.forEach(d);
    };
    return S.rows.forEach(d), S;
  }, C(o.options, "debugTable", "getPaginationRowModel"));
}
function st() {
  return (e) => m(() => [e.getState().sorting, e.getPreSortedRowModel()], (o, t) => {
    if (!t.rows.length || !(o != null && o.length))
      return t;
    const n = e.getState().sorting, i = [], r = n.filter((g) => {
      var a;
      return (a = e.getColumn(g.id)) == null ? void 0 : a.getCanSort();
    }), l = {};
    r.forEach((g) => {
      const a = e.getColumn(g.id);
      a && (l[g.id] = {
        sortUndefined: a.columnDef.sortUndefined,
        invertSorting: a.columnDef.invertSorting,
        sortingFn: a.getSortingFn()
      });
    });
    const u = (g) => {
      const a = g.map((f) => ({
        ...f
      }));
      return a.sort((f, S) => {
        for (let s = 0; s < r.length; s += 1) {
          var d;
          const c = r[s], p = l[c.id], R = p.sortUndefined, w = (d = c?.desc) != null ? d : !1;
          let h = 0;
          if (R) {
            const v = f.getValue(c.id), M = S.getValue(c.id), F = v === void 0, E = M === void 0;
            if (F || E) {
              if (R === "first") return F ? -1 : 1;
              if (R === "last") return F ? 1 : -1;
              h = F && E ? 0 : F ? R : -R;
            }
          }
          if (h === 0 && (h = p.sortingFn(f, S, c.id)), h !== 0)
            return w && (h *= -1), p.invertSorting && (h *= -1), h;
        }
        return f.index - S.index;
      }), a.forEach((f) => {
        var S;
        i.push(f), (S = f.subRows) != null && S.length && (f.subRows = u(f.subRows));
      }), a;
    };
    return {
      rows: u(t.rows),
      flatRows: i,
      rowsById: t.rowsById
    };
  }, C(e.options, "debugTable", "getSortedRowModel", () => e._autoResetPageIndex()));
}
export {
  he as ColumnFaceting,
  ve as ColumnFiltering,
  De as ColumnGrouping,
  Ge as ColumnOrdering,
  He as ColumnPinning,
  Ae as ColumnSizing,
  Oe as ColumnVisibility,
  Be as GlobalFaceting,
  Te as GlobalFiltering,
  we as Headers,
  qe as RowExpanding,
  Ne as RowPagination,
  ke as RowPinning,
  Ue as RowSelection,
  Ye as RowSorting,
  y as _getVisibleLeafColumns,
  z as aggregationFns,
  G as buildHeaderGroups,
  Ce as createCell,
  Re as createColumn,
  Q as createRow,
  ot as createTable,
  H as defaultColumnSizing,
  be as expandRows,
  P as filterFns,
  me as flattenBy,
  I as functionalUpdate,
  it as getCoreRowModel,
  rt as getFilteredRowModel,
  C as getMemoOptions,
  lt as getPaginationRowModel,
  st as getSortedRowModel,
  A as isFunction,
  Se as isNumberArray,
  Y as isRowSelected,
  K as isSubRowSelected,
  $ as makeStateUpdater,
  m as memo,
  ye as orderColumns,
  ze as passiveEventSupported,
  J as reSplitAlphaNumeric,
  k as selectRowsFn,
  oe as shouldAutoRemoveFilter,
  D as sortingFns
};
