UNPKG

lumarc-grid

Version:

lumArc Grid는 고성능, 유연하고 프레임워크에 구애받지 않는 데이터 그리드 라이브러리

9,965 lines 316 kB
import { jsx as p, Fragment as ft, jsxs as V } from "react/jsx-runtime";
import * as d from "react";
import He, { useCallback as E, useState as ae, useMemo as ce, useRef as Ue, useEffect as Ct, forwardRef as mo, createElement as Mn, useLayoutEffect as Ca } from "react";
import * as Zt from "react-dom";
import Sa, { flushSync as Ra } from "react-dom";
import { d as Ia, v as Pn, h as Ea, l as Na, c as te, i as Ma, j as Pa } from "./pagination-DL0UwSLP.mjs";
class Ta {
  constructor(t) {
    this.isDirty = !1, this.getRowId = t.getRowId, this.rows = [], this.rowMap = /* @__PURE__ */ new Map(), this.initializeFromData(t.data || []);
  }
  initializeFromData(t) {
    this.rows = t.map((n, r) => {
      const o = this.getRowId ? this.getRowId(n, r) : r, s = {
        id: o,
        data: n,
        state: {
          isDeleted: !1,
          isCreated: !1,
          isModified: !1
        },
        originalData: { ...n }
      };
      return this.rowMap.set(o, s), s;
    }), this.invalidateCache();
  }
  invalidateCache() {
    this.sortedIndices = void 0, this.filteredIndices = void 0, this.isDirty = !0;
  }
  /**
   * 🎯 모든 데이터 반환 (삭제 표시된 것도 포함) - 기존 API 호환
   * 삭제 표시된 행도 그리드에 계속 보여야 함!
   */
  getData() {
    return this.rows.map((t) => t.data);
  }
  /**
   * 전체 데이터 길이 - 기존 API 호환
   */
  getLength() {
    return this.rows.length;
  }
  /**
   * Row ID로 관리 객체 가져오기 (UI 스타일링용)
   */
  getManagedRow(t) {
    return this.rowMap.get(t);
  }
  /**
   * Row ID로 데이터 가져오기 - 기존 API 호환
   */
  getRowById(t) {
    const n = this.rowMap.get(t);
    return n ? n.data : void 0;
  }
  /**
   * 인덱스로 데이터 가져오기 - 기존 API 호환
   */
  getRowByIndex(t) {
    var n;
    return (n = this.rows[t]) == null ? void 0 : n.data;
  }
  /**
   * Row ID로 인덱스 가져오기 - 기존 API 호환
   */
  getIndexByRowId(t) {
    if (this.rowMap.get(t))
      return this.rows.findIndex((r) => r.id === t);
  }
  /**
   * 인덱스로 Row ID 가져오기 - 기존 API 호환
   */
  getRowIdByIndex(t) {
    var n;
    return (n = this.rows[t]) == null ? void 0 : n.id;
  }
  /**
   * 행 데이터 업데이트 - 기존 API 호환
   */
  updateRow(t, n) {
    const r = this.rowMap.get(t);
    return r ? (r.originalData || (r.originalData = { ...r.data }), Object.assign(r.data, n), r.state.isCreated || (r.state.isModified = !0, r.state.modifiedAt = /* @__PURE__ */ new Date()), this.invalidateCache(), !0) : !1;
  }
  addRow(t) {
    const n = `new_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`, r = {
      id: n,
      data: t,
      state: {
        isDeleted: !1,
        isCreated: !0,
        isModified: !1,
        createdAt: /* @__PURE__ */ new Date()
      }
    };
    return this.rows.push(r), this.rowMap.set(n, r), this.invalidateCache(), n;
  }
  addRowAtPosition(t, n) {
    const r = Math.min(n, this.rows.length), o = `new_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`, s = {
      id: o,
      data: t,
      state: {
        isDeleted: !1,
        isCreated: !0,
        isModified: !1,
        createdAt: /* @__PURE__ */ new Date()
      }
    };
    return this.rows.splice(r, 0, s), this.rowMap.set(o, s), this.invalidateCache(), o;
  }
  deleteRow(t) {
    const n = this.rowMap.get(t);
    if (!n)
      return !1;
    if (n.state.isCreated) {
      const r = this.rows.indexOf(n);
      return r !== -1 ? (this.rows.splice(r, 1), this.rowMap.delete(t), this.invalidateCache(), !0) : !1;
    }
    return n.state.isDeleted = !0, n.state.deletedAt = /* @__PURE__ */ new Date(), this.invalidateCache(), !0;
  }
  /**
   * 🎯 여러 행 삭제 표시
   */
  deleteRows(t) {
    let n = 0;
    return t.forEach((r) => {
      this.deleteRow(r) && n++;
    }), n;
  }
  /**
   * 삭제 표시 제거 (삭제 취소)
   */
  restoreRow(t) {
    const n = this.rowMap.get(t);
    return !n || !n.state.isDeleted ? !1 : (n.state.isDeleted = !1, n.state.deletedAt = void 0, !0);
  }
  /**
   * 정렬 - 기존 API 호환
   */
  sort(t) {
    if (!this.sortedIndices || this.isDirty) {
      const n = Array.from({ length: this.rows.length }, (r, o) => o);
      this.sortedIndices = n.sort(
        (r, o) => t(this.rows[r].data, this.rows[o].data)
      ), this.isDirty = !1;
    }
    return this.sortedIndices;
  }
  /**
   * 필터링 - 기존 API 호환
   */
  filter(t) {
    const n = this.sortedIndices || Array.from({ length: this.rows.length }, (r, o) => o);
    return this.filteredIndices = n.filter(
      (r) => t(this.rows[r].data, r)
    ), this.filteredIndices;
  }
  /**
   * 화면 표시 인덱스로 행 데이터 가져오기 - 기존 API 호환
   */
  getRowByDisplayIndex(t) {
    var o;
    const n = this.filteredIndices || this.sortedIndices, r = n ? n[t] : t;
    return (o = this.rows[r]) == null ? void 0 : o.data;
  }
  /**
   * 화면 표시 인덱스로 Row ID 가져오기 - 기존 API 호환
   */
  getRowIdByDisplayIndex(t) {
    var o;
    const n = this.filteredIndices || this.sortedIndices, r = n ? n[t] : t;
    return (o = this.rows[r]) == null ? void 0 : o.id;
  }
  /**
   * 화면에 표시되는 데이터 길이 - 기존 API 호환
   */
  getDisplayLength() {
    const t = this.filteredIndices || this.sortedIndices;
    return t ? t.length : this.rows.length;
  }
  /**
   * 변경 추적 정보 가져오기 - 새로운 기능
   */
  getChanges() {
    const t = [], n = [], r = [];
    return this.rows.forEach((o) => {
      if (o.state.isCreated && !o.state.isDeleted)
        t.push(o.data);
      else if (o.state.isModified && !o.state.isDeleted && o.originalData) {
        const s = this.getChangedFields(o.originalData, o.data);
        n.push({
          original: o.originalData,
          current: o.data,
          changedFields: s
        });
      } else o.state.isDeleted && !o.state.isCreated && r.push(o.originalData || o.data);
    }), { created: t, modified: n, deleted: r };
  }
  getChangedFields(t, n) {
    const r = [];
    for (const o in n)
      t[o] !== n[o] && r.push(o);
    return r;
  }
  /**
   * 🎯 변경사항 커밋 - 삭제 표시된 항목들을 실제로 제거
   */
  commitChanges() {
    this.rows = this.rows.filter((t) => t.state.isDeleted ? (this.rowMap.delete(t.id), !1) : !0), this.rows.forEach((t) => {
      (t.state.isCreated || t.state.isModified) && (t.originalData = { ...t.data }), t.state = {
        isDeleted: !1,
        isCreated: !1,
        isModified: !1
      };
    }), this.invalidateCache();
  }
  /**
   * 모든 변경사항 되돌리기
   */
  resetChanges() {
    this.rows = this.rows.filter((t) => t.state.isCreated && t.state.isDeleted ? (this.rowMap.delete(t.id), !1) : t.state.isCreated && !t.state.isDeleted ? (this.rowMap.delete(t.id), !1) : (t.state.isDeleted && (t.state.isDeleted = !1, t.state.deletedAt = void 0), t.state.isModified && t.originalData && (t.data = { ...t.originalData }, t.state.isModified = !1, t.state.modifiedAt = void 0), !0)), this.invalidateCache();
  }
  /**
   * 상태 확인 메서드들
   */
  isRowCreated(t) {
    const n = this.rowMap.get(t);
    return (n == null ? void 0 : n.state.isCreated) || !1;
  }
  isRowModified(t) {
    const n = this.rowMap.get(t);
    return (n == null ? void 0 : n.state.isModified) || !1;
  }
  isRowDeleted(t) {
    const n = this.rowMap.get(t);
    return (n == null ? void 0 : n.state.isDeleted) || !1;
  }
  getModifiedFields(t) {
    const n = this.rowMap.get(t);
    return !n || !n.state.isModified || !n.originalData ? [] : this.getChangedFields(n.originalData, n.data);
  }
  /**
   * 변경사항 요약
   */
  getChangesSummary() {
    let t = 0, n = 0, r = 0;
    return this.rows.forEach((o) => {
      o.state.isCreated && !o.state.isDeleted ? t++ : o.state.isModified && !o.state.isDeleted ? n++ : o.state.isDeleted && !o.state.isCreated && r++;
    }), { created: t, modified: n, deleted: r };
  }
  /**
   * 변경사항 존재 여부
   */
  hasChanges() {
    return this.rows.some(
      (t) => t.state.isCreated && !t.state.isDeleted || t.state.isModified && !t.state.isDeleted || t.state.isDeleted && !t.state.isCreated
    );
  }
  /**
   * 현재 상태 정보 (디버깅용) - 기존 API 호환
   */
  getStats() {
    var s, i;
    const t = this.rows.length, n = this.rows.filter((a) => a.state.isDeleted).length, r = this.rows.filter((a) => a.state.isCreated).length, o = this.rows.filter((a) => a.state.isModified).length;
    return {
      dataLength: t,
      total: t,
      deleted: n,
      created: r,
      modified: o,
      sortedLength: ((s = this.sortedIndices) == null ? void 0 : s.length) || 0,
      filteredLength: ((i = this.filteredIndices) == null ? void 0 : i.length) || 0,
      displayLength: this.getDisplayLength(),
      isDirty: this.isDirty,
      memoryUsage: {
        rows: this.rows.length,
        rowMap: this.rowMap.size
      }
    };
  }
  /**
   * 모든 Row ID 반환 - 기존 API 호환
   */
  getAllRowIds() {
    return this.rows.map((t) => t.id);
  }
  getDisplayRowIds() {
    const t = this.filteredIndices || this.sortedIndices;
    return t ? t.map((n) => this.rows[n].id) : this.rows.map((n) => n.id);
  }
  /**
   * 데이터 완전 교체 - 기존 API 호환
   */
  setData(t) {
    this.rowMap.clear(), this.initializeFromData(t);
  }
  /**
   * Row ID로 행 데이터 가져오기 (별칭) - 기존 API 호환
   */
  getRowByRowId(t) {
    return this.getRowById(t);
  }
  /**
   * 행 데이터로 Row ID 가져오기 - 기존 API 호환
   */
  getRowIdByData(t) {
    for (const [n, r] of this.rowMap)
      if (r.data === t)
        return n;
  }
  /**
   * 데이터 업데이트 (외부에서 새로운 데이터 설정) - 기존 API 호환
   */
  updateData(t, n) {
    n !== void 0 && (this.getRowId = n), this.setData(t);
  }
}
function Aa(e) {
  const { rowManager: t, isServerSide: n, onDataChange: r } = e, o = E(
    (f = {}) => {
      if (n)
        return -1;
      const v = t.addRow(f), g = t.getData();
      return r == null || r(g), v;
    },
    [t, r, n]
  ), s = E(
    (f, v) => {
      if (n)
        return !1;
      const g = t.updateRow(f, v);
      if (g) {
        const b = t.getData();
        r == null || r(b);
      }
      return g;
    },
    [t, r, n]
  ), i = E(
    (f) => {
      if (n)
        return;
      f.forEach(({ id: g, data: b }) => {
        t.updateRow(g, b);
      });
      const v = t.getData();
      r == null || r(v);
    },
    [t, r, n]
  ), a = E(
    (f) => {
      if (n)
        return !1;
      const v = t.deleteRow(f);
      if (v) {
        const g = t.getData();
        r == null || r(g);
      }
      return v;
    },
    [t, r, n]
  ), l = E(
    (f) => {
      if (n)
        return 0;
      const v = t.deleteRows(f);
      if (v > 0) {
        const g = t.getData();
        r == null || r(g);
      }
      return v;
    },
    [t, r, n]
  ), c = E(
    (f = {}, v) => {
      if (n)
        return -1;
      const g = t.addRowAtPosition(f, v), b = t.getData();
      return r == null || r(b), g;
    },
    [t, r, n]
  ), u = E(() => t.getData(), [t]);
  return {
    addRow: o,
    addRowAtPosition: c,
    updateRow: s,
    updateRows: i,
    deleteRow: a,
    deleteRows: l,
    getData: u
  };
}
function ka(e) {
  const { rowManager: t, isServerSide: n } = e, [r, o] = ae(0), s = E(() => {
    o((m) => m + 1);
  }, []), i = E(() => n ? { created: [], modified: [], deleted: [] } : t.getChanges(), [t, n, r]), a = E(() => n ? { created: 0, modified: 0, deleted: 0 } : t.getChangesSummary(), [t, n, r]), l = ce(() => n ? !1 : t.hasChanges(), [t, n, r]), c = E(() => {
    n || (t.commitChanges(), s());
  }, [t, n, s]), u = E(() => {
    n || (t.resetChanges(), s());
  }, [t, n, s]), f = E(
    (m) => n ? !1 : t.isRowCreated(m),
    [t, n]
  ), v = E(
    (m) => n ? !1 : t.isRowModified(m),
    [t, n]
  ), g = E(
    (m) => n ? !1 : t.isRowDeleted(m),
    [t, n]
  ), b = E(
    (m) => n ? [] : t.getModifiedFields(m),
    [t, n]
  ), h = E(
    (m, y, x) => {
      n || s();
    },
    [n, s]
  );
  return {
    changes: ce(() => i(), [i]),
    hasChanges: l,
    getChanges: i,
    getChangesSummary: a,
    commitChanges: c,
    resetChanges: u,
    isRowCreated: f,
    isRowModified: v,
    isRowDeleted: g,
    getModifiedFields: b,
    updateChangeTracking: h
  };
}
function Xn(e) {
  return `row-${e}`;
}
function Da(e) {
  if (e.startsWith("row-")) {
    const t = e.replace("row-", ""), n = Number(t);
    return !isNaN(n) && isFinite(n) ? n : t;
  }
  return e;
}
function Oa(e, t) {
  const n = t.map((o) => Xn(o.id)), r = n.indexOf(e);
  return r >= 0 && r < n.length - 1 ? n[r + 1] : null;
}
function _a(e, t) {
  const n = t.map((o) => Xn(o.id)), r = n.indexOf(e);
  return r > 0 ? n[r - 1] : null;
}
function po(e) {
  return Xn(e);
}
function La(e, t) {
  const n = Da(e);
  return typeof n == "number" && Number.isInteger(n) ? n : t.findIndex((r) => r.id === n);
}
function Fa(e) {
  const { columns: t, data: n } = e, [r, o] = ae({}), s = E(
    (f, v, g, b) => {
      const h = isNaN(Number(f)) ? f : Number(f);
      let w;
      if (typeof h == "number" ? w = n[h] : w = n.find((C) => {
        var S;
        return ((S = C.id) == null ? void 0 : S.toString()) === f;
      }), !w) return null;
      const m = t.find((C) => C.accessorKey === v);
      if (!m || !Ia(m, b)) return null;
      const y = Pn(g, m, w), x = `${f}-${v}`;
      return o(y ? (C) => ({ ...C, [x]: y }) : (C) => {
        const S = { ...C };
        return delete S[x], S;
      }), y;
    },
    [n, t]
  ), i = E(
    (f, v = "submit") => {
      const g = n.find((h) => typeof f == "number" ? n.indexOf(h) === f : h.id === f);
      if (!g) return {};
      const b = Ea(g, t);
      return Object.keys(b).length > 0 && o((h) => ({
        ...h,
        ...Object.fromEntries(
          Object.entries(b).map(([w, m]) => [
            `${f}-${w}`,
            m
          ])
        )
      })), b;
    },
    [n, t]
  ), a = E(
    (f, v, g) => s(f, v, g, "realtime"),
    [s]
  ), l = E((f, v) => {
    const g = `${f}-${v}`;
    o((b) => {
      const h = { ...b };
      return delete h[g], h;
    });
  }, []), c = E(() => {
    o({});
  }, []), u = Object.keys(r).length > 0;
  return {
    validationErrors: r,
    hasValidationErrors: u,
    clearValidationError: l,
    clearAllValidationErrors: c,
    validateCell: s,
    validateRow: i,
    handleCellValueChange: a
  };
}
function $a(e) {
  const { gridSelection: t } = e, n = E(
    (u, f = !0) => {
      const v = `row-${u}`;
      t.handleRowSelect(v, f);
    },
    [t]
  ), r = E(
    (u) => {
      u.forEach((f) => n(f, !0));
    },
    [n]
  );
  E(
    (u) => {
      t.handleSelectAll(u);
    },
    [t]
  );
  const o = E(() => {
    const u = !t.isAllSelected;
    t.handleSelectAll(u);
  }, [t]), s = E(() => {
    t.clearSelection();
  }, [t]), i = E(() => t.getSelectedRowIds(), [t]), a = E(() => t.getSelectedData(), [t]), l = E(
    (u, f) => {
      const v = u.replace("row-", "");
      n(v, f);
    },
    [n]
  ), c = ce(() => new Set(i().map((u) => `row-${u}`)), [i]);
  return {
    selectRow: n,
    selectRows: r,
    selectAll: o,
    clearSelection: s,
    getSelectedIds: i,
    getSelectedRows: a,
    selectedRows: c,
    isAllSelected: t.isAllSelected,
    isIndeterminate: t.isIndeterminate,
    handleSelectAll: t.handleSelectAll,
    handleRowSelectChange: l
  };
}
function za(e) {
  const {
    rowManager: t,
    gridEditing: n,
    validationAPI: r,
    isServerSide: o,
    updateRow: s,
    onEditComplete: i
  } = e, a = E(
    (c, u, f) => {
      const v = c.replace("row-", ""), g = isNaN(Number(v)) ? v : Number(v), b = t.getRowById(g);
      if (b) {
        const h = b[u];
        let w = !1;
        typeof h == "number" || !isNaN(Number(f)) ? w = Number(h) !== Number(f) : w = String(h || "") !== String(f || ""), w ? (r.validateCell(v, u, f, "blur"), o || s(g, { [u]: f }), n.handleCellEdit(c, u, f)) : n.handleEditCancel(), i == null || i(c, u);
      } else
        n.handleEditCancel(), i == null || i(c, u);
    },
    [t, r, o, s, n, i]
  ), l = E(() => {
    const c = n.editingCell;
    n.handleEditCancel(), c && (i == null || i(c.rowId, c.field));
  }, [n, i]);
  return {
    editingCell: n.editingCell,
    recentlySavedCells: n.recentlySavedCells,
    singleClickEdit: n.singleClickEdit,
    setSingleClickEdit: n.setSingleClickEdit,
    startEdit: n.handleEditStart,
    cancelEdit: n.handleEditCancel,
    handleCellEditComplete: a,
    handleEditCancel: l
  };
}
function Va({
  totalRows: e,
  totalColumns: t,
  onCellFocus: n,
  onEditStart: r,
  onTabNext: o,
  onTabPrevious: s,
  disabled: i = !1
}) {
  const [a, l] = ae(
    null
  ), c = Ue(/* @__PURE__ */ new Map()), u = E(
    (b, h) => {
      const w = `${b.rowIndex}-${b.columnIndex}`;
      h ? c.current.set(w, h) : c.current.delete(w);
    },
    []
  ), f = E(
    (b) => {
      if (b.rowIndex < 0 || b.rowIndex >= e || b.columnIndex < 0 || b.columnIndex >= t)
        return;
      l(b);
      const h = `${b.rowIndex}-${b.columnIndex}`, w = c.current.get(h);
      if (w)
        try {
          w.focus(), n == null || n(b);
        } catch (m) {
          console.error(m);
        }
    },
    [e, t, n]
  ), v = E(
    (b) => {
      const h = a || { rowIndex: 0, columnIndex: 0 };
      let w = h.rowIndex, m = h.columnIndex;
      switch (b) {
        case "up":
          w = Math.max(0, w - 1);
          break;
        case "down":
          w = Math.min(e - 1, w + 1);
          break;
        case "left":
          m = Math.max(0, m - 1);
          break;
        case "right":
          m = Math.min(t - 1, m + 1);
          break;
      }
      (w !== h.rowIndex || m !== h.columnIndex) && f({ rowIndex: w, columnIndex: m });
    },
    [a, e, t, f]
  ), g = E(
    (b, h) => {
      if (!i) {
        if (b.key === "Escape") {
          b.preventDefault(), b.stopPropagation(), l(null);
          return;
        }
        switch (a || l(h), b.key) {
          case "ArrowUp":
          case "ArrowDown":
          case "ArrowLeft":
          case "ArrowRight":
            b.preventDefault(), b.stopPropagation(), v(b.key.replace("Arrow", "").toLowerCase());
            break;
          case "Enter":
            b.preventDefault(), b.stopPropagation(), r == null || r(a || h);
            break;
          case "Tab":
            b.preventDefault(), b.stopPropagation(), b.shiftKey ? s == null || s(a || h) : o == null || o(a || h);
            break;
        }
      }
    },
    [i, a, v, r, o, s]
  );
  return {
    currentPosition: a,
    setCurrentPosition: l,
    handleKeyDown: g,
    focusCell: f,
    moveTo: v,
    registerCellRef: u
  };
}
const Tn = (e) => `${e.rowIndex}-${e.columnIndex}`, Nr = (e) => {
  const [t, n] = e.split("-").map(Number);
  return { rowIndex: t, columnIndex: n };
}, Mr = (e, t) => {
  const n = /* @__PURE__ */ new Set(), r = Math.min(e.rowIndex, t.rowIndex), o = Math.max(e.rowIndex, t.rowIndex), s = Math.min(e.columnIndex, t.columnIndex), i = Math.max(e.columnIndex, t.columnIndex);
  for (let a = r; a <= o; a++)
    for (let l = s; l <= i; l++)
      n.add(Tn({ rowIndex: a, columnIndex: l }));
  return n;
};
function Ba({
  totalRows: e,
  totalColumns: t,
  onSelectionChange: n,
  disabled: r = !1
}) {
  const [o, s] = ae(null), [i, a] = ae(/* @__PURE__ */ new Set()), [l, c] = ae(!1), u = E(
    (x) => x.rowIndex >= 0 && x.rowIndex < e && x.columnIndex >= 0 && x.columnIndex < t,
    [e, t]
  ), f = E(
    (x) => {
      const C = Array.from(x).map(Nr);
      n == null || n(C);
    },
    [n]
  ), v = E(
    (x) => {
      if (r || !u(x)) return;
      c(!0), s({ start: x, end: x });
      const C = Tn(x), S = /* @__PURE__ */ new Set([C]);
      a(S), f(S);
    },
    [r, u, f]
  ), g = E(
    (x) => {
      if (r || !l || !o || !u(x))
        return;
      const C = { ...o, end: x };
      s(C);
      const S = Mr(o.start, x);
      a(S), f(S);
    },
    [
      r,
      l,
      o,
      u,
      f
    ]
  ), b = E(() => {
    c(!1);
  }, []), h = E(() => {
    s(null), a(/* @__PURE__ */ new Set()), c(!1), f(/* @__PURE__ */ new Set());
  }, [f]), w = E(
    (x, C) => {
      if (r || !u(x) || !u(C)) return;
      const S = Mr(x, C);
      s({ start: x, end: C }), a(S), f(S);
    },
    [r, u, f]
  ), m = E(
    (x) => r || !u(x) ? !1 : i.has(Tn(x)),
    [r, u, i]
  ), y = E(() => Array.from(i).map(Nr), [i]);
  return {
    selectedRange: o,
    selectedCells: i,
    isSelecting: l,
    startSelection: v,
    updateSelection: g,
    endSelection: b,
    clearSelection: h,
    selectRange: w,
    isCellSelected: m,
    getSelectedPositions: y
  };
}
function Wa({
  data: e,
  columns: t,
  selectedPositions: n,
  onCellUpdate: r,
  onPasteComplete: o
}) {
  const [s, i] = ae(
    null
  ), a = E(() => {
    var y, x;
    if (n.length === 0) return [];
    const g = Math.min(...n.map((C) => C.rowIndex)), b = Math.max(...n.map((C) => C.rowIndex)), h = Math.min(...n.map((C) => C.columnIndex)), w = Math.max(...n.map((C) => C.columnIndex)), m = [];
    for (let C = g; C <= b; C++) {
      const S = [];
      for (let R = h; R <= w; R++)
        if (n.find(
          (k) => k.rowIndex === C && k.columnIndex === R
        ) && C < e.length && R < t.length) {
          const k = ((y = t[R]) == null ? void 0 : y.accessorKey) || ((x = t[R]) == null ? void 0 : x.id), W = e[C], O = W == null ? void 0 : W[k];
          S.push(
            O != null ? String(O) : ""
          );
        } else
          S.push("");
      m.push(S);
    }
    return m;
  }, [n, e, t]), l = E(async () => {
    if (n.length === 0) return;
    const g = a();
    i({
      values: g,
      positions: n,
      type: "copy"
    });
    try {
      const b = g.map((h) => h.join("	")).join(`
`);
      await navigator.clipboard.writeText(b);
    } catch (b) {
      console.error("Failed to copy to clipboard:", b);
    }
  }, [n, a]), c = E(async () => {
    n.length !== 0 && (await l(), i({
      values: a(),
      positions: n,
      type: "cut"
    }), n.forEach((g) => {
      var h, w;
      const b = ((h = t[g.columnIndex]) == null ? void 0 : h.accessorKey) || ((w = t[g.columnIndex]) == null ? void 0 : w.id);
      b && r && r(g.rowIndex, b, "");
    }), o && o(n));
  }, [n, l, r]), u = E(
    async (g) => {
      var b, h;
      try {
        const w = await navigator.clipboard.readText();
        if (!w.trim()) return;
        const y = w.split(`
`).map((C) => C.split("	")), x = [];
        for (let C = 0; C < y.length; C++) {
          const S = g.rowIndex + C;
          if (S >= e.length) break;
          for (let R = 0; R < y[C].length; R++) {
            const N = g.columnIndex + R;
            if (N >= t.length) break;
            const k = y[C][R], W = ((b = t[N]) == null ? void 0 : b.accessorKey) || ((h = t[N]) == null ? void 0 : h.id);
            W && r && (r(S, W, k), x.push({
              rowIndex: S,
              columnIndex: N
            }));
          }
        }
        o && o(x);
      } catch (w) {
        console.error("Failed to paste from clipboard:", w);
      }
    },
    [e, t, r, o]
  ), f = E(
    (g, b) => {
      if (navigator.platform.toUpperCase().indexOf("MAC") >= 0 ? g.metaKey : g.ctrlKey)
        switch (g.key.toLowerCase()) {
          case "c":
            g.preventDefault(), l();
            break;
          case "x":
            g.preventDefault(), c();
            break;
          case "v":
            g.preventDefault();
            const m = b || (n.length > 0 ? n[0] : { rowIndex: 0, columnIndex: 0 });
            u(m);
            break;
        }
    },
    [l, c, u, n]
  );
  return {
    clipboardData: s,
    copySelection: l,
    cutSelection: c,
    paste: u,
    handleKeyboardShortcuts: f,
    canPaste: !!s
  };
}
function Ka({
  data: e,
  columns: t,
  onCellEdit: n,
  onEditStart: r,
  incrementDataVersion: o
}) {
  const s = e.length, i = t.length, a = Va({
    totalRows: s,
    totalColumns: i,
    onCellFocus: E((m) => {
    }, []),
    onEditStart: E(
      (m) => {
        const y = t[m.columnIndex];
        y && n && n(m.rowIndex, String(y.accessorKey), "");
      },
      [t, n]
    ),
    disabled: !1
  }), l = Ba({
    totalRows: s,
    totalColumns: i,
    onSelectionChange: E(() => {
    }, []),
    disabled: !1
  }), c = Wa({
    data: e,
    columns: t.map((m) => ({
      id: m.id,
      accessorKey: String(m.accessorKey)
    })),
    selectedPositions: l.getSelectedPositions(),
    onCellUpdate: E(
      (m, y, x) => {
        n && n(m, y, x);
      },
      [n]
    ),
    onPasteComplete: E(
      (m) => {
        o();
      },
      [o]
    )
  }), u = Ue(0), f = Ue(null), v = E(
    (m, y) => {
      y.preventDefault(), y.stopPropagation(), f.current = m, a.focusCell(m), y.shiftKey && a.currentPosition ? l.selectRange(a.currentPosition, m) : y.ctrlKey || y.metaKey ? l.isCellSelected(m) ? l.clearSelection() : l.startSelection(m) : (l.clearSelection(), l.startSelection(m), l.endSelection());
    },
    [l, a]
  ), g = E(
    (m, y) => {
      !l.isSelecting || !f.current || y.buttons === 1 && l.updateSelection(m);
    },
    [l]
  ), b = E(
    (m) => {
      l.endSelection(), f.current = null;
    },
    [l]
  ), h = E(
    (m, y) => {
      if (/Mac|iPod|iPhone|iPad/.test(navigator.userAgent) ? y.metaKey : y.ctrlKey) {
        c.handleKeyboardShortcuts(y, m);
        return;
      }
      if (y.key === "Enter" || y.key === "F2") {
        if (y.preventDefault(), y.stopPropagation(), n) {
          const S = t[m.columnIndex];
          S && n(m.rowIndex, String(S.accessorKey), "");
        }
        return;
      }
      switch (y.key) {
        case "Escape":
          y.preventDefault(), l.clearSelection();
          return;
        case "Delete":
        case "Backspace":
          y.preventDefault();
          const S = l.getSelectedPositions();
          if (S.length > 0)
            S.forEach((R) => {
              const N = t[R.columnIndex];
              N && n && n(R.rowIndex, String(N.accessorKey), "");
            });
          else {
            const R = t[m.columnIndex];
            R && n && n(m.rowIndex, String(R.accessorKey), "");
          }
          return;
      }
      if (y.shiftKey) {
        let S = null;
        switch (y.key) {
          case "ArrowUp":
            S = {
              rowIndex: Math.max(0, m.rowIndex - 1),
              columnIndex: m.columnIndex
            };
            break;
          case "ArrowDown":
            S = {
              rowIndex: Math.min(s - 1, m.rowIndex + 1),
              columnIndex: m.columnIndex
            };
            break;
          case "ArrowLeft":
            S = {
              rowIndex: m.rowIndex,
              columnIndex: Math.max(0, m.columnIndex - 1)
            };
            break;
          case "ArrowRight":
            S = {
              rowIndex: m.rowIndex,
              columnIndex: Math.min(i - 1, m.columnIndex + 1)
            };
            break;
        }
        if (S) {
          y.preventDefault(), l.selectedRange || l.startSelection(m), l.updateSelection(S), a.focusCell(S);
          return;
        }
      }
      a.handleKeyDown(y, m);
    },
    [
      a,
      c,
      l,
      t,
      n,
      r,
      s,
      i
    ]
  ), w = E(
    (m, y) => {
      const x = Date.now(), C = x - u.current;
      if (u.current = x, C < 300 && n) {
        const S = t[m.columnIndex];
        S && n(m.rowIndex, String(S.accessorKey), "");
      }
    },
    [a, l, t, n, r]
  );
  return {
    currentPosition: a.currentPosition,
    focusCell: a.focusCell,
    registerCellRef: a.registerCellRef,
    selectedCells: l.selectedCells,
    selectedRange: l.selectedRange,
    isSelecting: l.isSelecting,
    isCellSelected: l.isCellSelected,
    clearCellSelection: l.clearSelection,
    canPaste: c.canPaste,
    copySelection: c.copySelection,
    cutSelection: c.cutSelection,
    paste: c.paste,
    handleCellMouseDown: v,
    handleCellMouseEnter: g,
    handleCellMouseUp: b,
    handleCellKeyDown: h,
    handleCellClick: w
  };
}
function Ha(e) {
  var J, ne, X;
  const t = Ue(e.data || e.initialData || []), [n, r] = ae(0), o = E(
    () => r((M) => M + 1),
    []
  ), s = ce(() => new Ta({
    data: [...t.current],
    getRowId: e.getRowId
  }), []), i = !!((J = e.serverSide) != null && J.enabled), a = ce(() => {
    var z;
    const M = (z = e.features) == null ? void 0 : z.pagination;
    return M ? M === !0 ? { pageSize: e.pageSize || 10 } : {
      pageSize: M.pageSize || e.pageSize || 10
    } : { pageSize: e.pageSize || 10 };
  }, [(ne = e.features) == null ? void 0 : ne.pagination, e.pageSize]), l = cm({
    config: e.serverSide || {
      enabled: !1,
      onDataLoad: async () => ({
        data: [],
        totalCount: 0,
        filteredCount: 0,
        page: 0,
        pageSize: 10,
        totalPages: 0
      })
    },
    initialPagination: a
  }), c = sm({
    rowManager: s,
    columns: e.columns,
    initialSorting: e.initialSorting,
    initialFiltering: e.initialFiltering,
    initialPagination: a,
    dataVersion: n
  }), u = i ? l.data : s.getData(), f = ce(() => i ? l.data : c.displayIndices.map((z) => {
    const Q = s.getRowByIndex(z);
    if (!Q) return null;
    const re = s.getRowIdByIndex(z);
    return {
      ...Q,
      id: re
    };
  }).filter((z) => z !== null), [i, l.data, c.displayIndices, n]), v = im({
    rowManager: s,
    displayData: f,
    onRowSelect: e.onSelectionChange
  }), g = am({
    columns: e.columns,
    onCellEdit: e.onCellEdit,
    data: u
  }), b = lm({
    onRowAction: e.onRowAction
  }), h = Aa({
    rowManager: s,
    isServerSide: i,
    onDataChange: e.onDataChange
  }), w = ka({
    rowManager: s,
    initialData: t.current,
    isServerSide: i
  }), m = Fa({
    columns: e.columns,
    data: u
  }), y = $a({
    gridSelection: v,
    onSelectionChange: e.onSelectionChange
  }), x = E(
    (M, z) => {
      const Q = h.updateRow(M, z);
      return Q && (w.updateChangeTracking(h.getData(), "update"), o()), Q;
    },
    [h, w, o]
  ), C = Ka({
    data: f,
    columns: e.columns,
    onCellEdit: e.onCellEdit,
    onEditStart: void 0,
    incrementDataVersion: o
  }), S = za({
    rowManager: s,
    gridEditing: g,
    validationAPI: m,
    isServerSide: i,
    updateRow: x,
    onEditComplete: E(
      (M, z) => {
        const Q = M.replace("row-", ""), re = isNaN(Number(Q)) ? Q : Number(Q), oe = f.findIndex(
          (ue) => String(ue.id || ue) === String(re)
        ), de = e.columns.findIndex(
          (ue) => ue.id === z
        );
        oe >= 0 && de >= 0 && setTimeout(() => {
          C.focusCell({ rowIndex: oe, columnIndex: de });
        }, 100);
      },
      [f, e.columns, C]
    )
  }), R = {
    ...C,
    handleCellKeyDown: E(
      (M, z) => {
        if (!(/Mac|iPod|iPhone|iPad/.test(navigator.userAgent) ? z.metaKey : z.ctrlKey)) {
          if (z.key === "Enter" || z.key === "F2") {
            z.preventDefault(), z.stopPropagation();
            const oe = `row-${M.rowIndex}`, de = e.columns[M.columnIndex];
            de && S.startEdit(oe, de.id);
            return;
          }
          C.handleCellKeyDown(M, z);
        }
      },
      [S, e.columns, C]
    )
  }, N = E(
    (M = {}) => {
      const z = c.pagination.pageIndex, Q = c.pagination.pageSize, oe = z * Q + Q, de = h.addRowAtPosition(M, oe);
      return de !== -1 && (w.updateChangeTracking(h.getData(), "create"), c.handleTemporaryPageSizeIncrease()), de;
    },
    [h, w, c]
  ), k = E(
    (M) => {
      h.updateRows(M), w.updateChangeTracking(h.getData(), "update");
    },
    [h, w]
  ), W = E(
    (M) => {
      const z = s.getRowByRowId(M), Q = w.isRowCreated(M), re = h.deleteRow(M);
      return re && z && (y.selectRow(M, !1), w.updateChangeTracking(h.getData(), "delete", [
        z
      ]), Q && c.handleTemporaryPageSizeDecrease(), o()), re;
    },
    [
      h,
      w,
      s,
      y,
      c,
      o
    ]
  ), O = E(
    (M) => {
      const z = M.map((oe) => s.getRowByRowId(oe)).filter(Boolean), Q = M.filter(
        (oe) => w.isRowCreated(oe)
      ).length, re = h.deleteRows(M);
      if (re > 0) {
        M.forEach((oe) => {
          y.selectRow(oe, !1);
        }), w.updateChangeTracking(
          h.getData(),
          "delete",
          z
        );
        for (let oe = 0; oe < Q; oe++)
          c.handleTemporaryPageSizeDecrease();
        o();
      }
      return re;
    },
    [
      h,
      w,
      s,
      y,
      c,
      o
    ]
  ), T = E(
    (M) => {
      c.handleSort(M);
    },
    [c]
  ), _ = E(
    (M, z) => {
      c.handleFilter(M, z);
    },
    [c]
  ), $ = E(
    (M) => {
      c.handlePageChange(M);
    },
    [c]
  ), A = E(
    (M) => {
      c.handlePageSizeChange(M);
    },
    [c]
  ), H = E(() => {
    c.clearSorting();
  }, [c]), L = E(() => {
    c.clearFiltering();
  }, [c]), j = E(() => u, [u]), B = E(() => f, [f]), P = E(() => i ? l.totalCount : s.getLength(), [i, l.totalCount, s]), Z = E(() => i ? l.filteredCount : c.filteredCount, [i, l.filteredCount, c.filteredCount]), D = E(() => {
    console.log("Export to CSV - Coming soon!");
  }, []), U = E(() => s.getStats(), [s]), F = E(
    (M, z, Q) => {
      b.handleRowAction(M, z, Q);
    },
    [b]
  ), K = ce(
    () => ({
      sorting: c.sorting,
      filtering: c.filtering,
      pagination: {
        pageIndex: c.pagination.pageIndex,
        pageSize: c.pagination.pageSize,
        totalCount: c.pagination.totalCount
      },
      selection: {
        selectedCount: y.getSelectedRows().length,
        isAllSelected: y.isAllSelected,
        isIndeterminate: y.isIndeterminate
      }
    }),
    [c, y]
  ), Y = ce(() => {
    const z = y.getSelectedIds().map((Q) => `row-${Q}`);
    return new Set(z);
  }, [y]), ee = ce(
    () => {
      var M;
      return {
        data: f,
        columns: e.columns,
        features: {
          sorting: e.sortable !== !1,
          filtering: e.filterable !== !1,
          pagination: e.showPagination !== !1 ? {
            enabled: !0,
            pageSize: e.pageSize || 10,
            showPageSizeSelector: !0,
            showPageInfo: !0,
            showFirstLast: !0,
            siblingCount: 1
          } : !1,
          editing: e.editable !== !1,
          selection: e.selectable !== !1,
          globalSearch: !0,
          ...e.features
        },
        loading: i ? l.serverState.loading : !1,
        error: i && ((M = l.serverState.error) == null ? void 0 : M.message) || null,
        sorting: c.sorting,
        selectedRows: Y,
        isAllSelected: y.isAllSelected,
        isIndeterminate: y.isIndeterminate,
        selectedCount: y.getSelectedRows().length,
        totalCount: P(),
        filteredCount: Z(),
        currentPage: c.pagination.pageIndex,
        totalPages: Math.ceil(Z() / c.pagination.pageSize),
        currentPageSize: c.pagination.pageSize,
        editingCell: S.editingCell,
        recentlySavedCells: S.recentlySavedCells,
        singleClickEdit: S.singleClickEdit,
        validationErrors: m.validationErrors,
        onRowSelect: e.onSelectionChange,
        onCellEdit: e.onCellEdit,
        onRowAction: e.onRowAction,
        onSelectAll: y.handleSelectAll,
        onRowSelectChange: y.handleRowSelectChange,
        onSort: T,
        onPageChange: $,
        onPageSizeChange: A,
        onEditStart: S.startEdit,
        onEditCancel: S.handleEditCancel,
        onCellEditComplete: S.handleCellEditComplete,
        onCellValueChange: m.handleCellValueChange,
        isRowCreated: w.isRowCreated,
        isRowModified: w.isRowModified,
        isRowDeleted: w.isRowDeleted,
        getModifiedFields: w.getModifiedFields,
        validateCell: m.validateCell,
        currentPosition: R.currentPosition,
        selectedCell: R.currentPosition,
        isCellSelected: R.isCellSelected,
        registerCellRef: R.registerCellRef,
        onCellMouseDown: R.handleCellMouseDown,
        onCellKeyDown: R.handleCellKeyDown,
        onCellClick: R.handleCellClick
      };
    },
    [
      f,
      e,
      i,
      l,
      c,
      Y,
      y,
      S,
      m,
      w,
      T,
      $,
      A,
      P,
      Z,
      R
    ]
  ), I = E(() => {
    w.resetChanges(), y.clearSelection(), R.clearCellSelection(), c.clearAll(), m.clearAllValidationErrors(), o();
  }, [
    w,
    y,
    R,
    c,
    m,
    o
  ]);
  return {
    ...R,
    addRow: N,
    updateRow: x,
    updateRows: k,
    deleteRow: W,
    deleteRows: O,
    selectRow: y.selectRow,
    selectRows: y.selectRows,
    selectAll: y.selectAll,
    clearSelection: y.clearSelection,
    getSelectedIds: y.getSelectedIds,
    getSelectedRows: y.getSelectedRows,
    selectedRows: Y,
    isAllSelected: y.isAllSelected,
    isIndeterminate: y.isIndeterminate,
    editingCell: S.editingCell,
    recentlySavedCells: S.recentlySavedCells,
    singleClickEdit: S.singleClickEdit,
    setSingleClickEdit: S.setSingleClickEdit,
    startEdit: S.startEdit,
    cancelEdit: S.handleEditCancel,
    paste: R.paste,
    changes: w.changes,
    hasChanges: w.hasChanges,
    getChanges: w.getChanges,
    getChangesSummary: w.getChangesSummary,
    commitChanges: w.commitChanges,
    resetChanges: I,
    isRowCreated: w.isRowCreated,
    isRowModified: w.isRowModified,
    isRowDeleted: w.isRowDeleted,
    getModifiedFields: w.getModifiedFields,
    validationErrors: m.validationErrors,
    clearValidationError: m.clearValidationError,
    clearAllValidationErrors: m.clearAllValidationErrors,
    hasValidationErrors: m.hasValidationErrors,
    validateCell: m.validateCell,
    validateRow: m.validateRow,
    handleCellValueChange: m.handleCellValueChange,
    sort: T,
    filter: _,
    goToPage: $,
    setPageSize: A,
    clearSorting: H,
    clearFiltering: L,
    getData: j,
    getDisplayData: B,
    getTotalCount: P,
    getFilteredCount: Z,
    data: u,
    processedData: f,
    isServerSide: i,
    loading: i ? l.serverState.loading : !1,
    error: i && ((X = l.serverState.error) == null ? void 0 : X.message) || null,
    refresh: i ? l.refresh : void 0,
    retry: i ? l.retry : void 0,
    clearError: i ? l.clearError : void 0,
    state: K,
    exportToCSV: D,
    getStats: U,
    handleRowAction: F,
    tableProps: ee
  };
}
function nt(e, t, n) {
  let r = n.initialDeps ?? [], o;
  function s() {
    var i, a, l, c;
    let u;
    n.key && ((i = n.debug) != null && i.call(n)) && (u = Date.now());
    const f = e();
    if (!(f.length !== r.length || f.some((b, h) => r[h] !== b)))
      return o;
    r = f;
    let g;
    if (n.key && ((a = n.debug) != null && a.call(n)) && (g = Date.now()), o = t(...f), n.key && ((l = n.debug) != null && l.call(n))) {
      const b = Math.round((Date.now() - u) * 100) / 100, h = Math.round((Date.now() - g) * 100) / 100, w = h / 16, m = (y, x) => {
        for (y = String(y); y.length < x; )
          y = " " + y;
        return y;
      };
      console.info(
        `%c⏱ ${m(h, 5)} /${m(b, 5)} ms`,
        `
            font-size: .6rem;
            font-weight: bold;
            color: hsl(${Math.max(
          0,
          Math.min(120 - 120 * w, 120)
        )}deg 100% 31%);`,
        n == null ? void 0 : n.key
      );
    }
    return (c = n == null ? void 0 : n.onChange) == null || c.call(n, o), o;
  }
  return s.updateDeps = (i) => {
    r = i;
  }, s;
}
function Pr(e, t) {
  if (e === void 0)
    throw new Error("Unexpected undefined");
  return e;
}
const Ga = (e, t) => Math.abs(e - t) < 1.01, Ua = (e, t, n) => {
  let r;
  return function(...o) {
    e.clearTimeout(r), r = e.setTimeout(() => t.apply(this, o), n);
  };
}, Tr = (e) => {
  const { offsetWidth: t, offsetHeight: n } = e;
  return { width: t, height: n };
}, ja = (e) => e, Ya = (e) => {
  const t = Math.max(e.startIndex - e.overscan, 0), n = Math.min(e.endIndex + e.overscan, e.count - 1), r = [];
  for (let o = t; o <= n; o++)
    r.push(o);
  return r;
}, Xa = (e, t) => {
  const n = e.scrollElement;
  if (!n)
    return;
  const r = e.targetWindow;
  if (!r)
    return;
  const o = (i) => {
    const { width: a, height: l } = i;
    t({ width: Math.round(a), height: Math.round(l) });
  };
  if (o(Tr(n)), !r.ResizeObserver)
    return () => {
    };
  const s = new r.ResizeObserver((i) => {
    const a = () => {
      const l = i[0];
      if (l != null && l.borderBoxSize) {
        const c = l.borderBoxSize[0];
        if (c) {
          o({ width: c.inlineSize, height: c.blockSize });
          return;
        }
      }
      o(Tr(n));
    };
    e.options.useAnimationFrameWithResizeObserver ? requestAnimationFrame(a) : a();
  });
  return s.observe(n, { box: "border-box" }), () => {
    s.unobserve(n);
  };
}, Ar = {
  passive: !0
}, kr = typeof window > "u" ? !0 : "onscrollend" in window, qa = (e, t) => {
  const n = e.scrollElement;
  if (!n)
    return;
  const r = e.targetWindow;
  if (!r)
    return;
  let o = 0;
  const s = e.options.useScrollendEvent && kr ? () => {
  } : Ua(
    r,
    () => {
      t(o, !1);
    },
    e.options.isScrollingResetDelay
  ), i = (u) => () => {
    const { horizontal: f, isRtl: v } = e.options;
    o = f ? n.scrollLeft * (v && -1 || 1) : n.scrollTop, s(), t(o, u);
  }, a = i(!0), l = i(!1);
  l(), n.addEventListener("scroll", a, Ar);
  const c = e.options.useScrollendEvent && kr;
  return c && n.addEventListener("scrollend", l, Ar), () => {
    n.removeEventListener("scroll", a), c && n.removeEventListener("scrollend", l);
  };
}, Za = (e, t, n) => {
  if (t != null && t.borderBoxSize) {
    const r = t.borderBoxSize[0];
    if (r)
      return Math.round(
        r[n.options.horizontal ? "inlineSize" : "blockSize"]
      );
  }
  return e[n.options.horizontal ? "offsetWidth" : "offsetHeight"];
}, Ja = (e, {
  adjustments: t = 0,
  behavior: n
}, r) => {
  var o, s;
  const i = e + t;
  (s = (o = r.scrollElement) == null ? void 0 : o.scrollTo) == null || s.call(o, {
    [r.options.horizontal ? "left" : "top"]: i,
    behavior: n
  });
};
class Qa {
  constructor(t) {
    this.unsubs = [], this.scrollElement = null, this.targetWindow = null, this.isScrolling = !1, this.measurementsCache = [], this.itemSizeCache = /* @__PURE__ */ new Map(), this.pendingMeasuredCacheIndexes = [], this.scrollRect = null, this.scrollOffset = null, this.scrollDirection = null, this.scrollAdjustments = 0, this.elementsCache = /* @__PURE__ */ new Map(), this.observer = /* @__PURE__ */ (() => {
      let n = null;
      const r = () => n || (!this.targetWindow || !this.targetWindow.ResizeObserver ? null : n = new this.targetWindow.ResizeObserver((o) => {
        o.forEach((s) => {
          const i = () => {
            this._measureElement(s.target, s);
          };
          this.options.useAnimationFrameWithResizeObserver ? requestAnimationFrame(i) : i();
        });
      }));
      return {
        disconnect: () => {
          var o;
          (o = r()) == null || o.disconnect(), n = null;
        },
        observe: (o) => {
          var s;
          return (s = r()) == null ? void 0 : s.observe(o, { box: "border-box" });
        },
        unobserve: (o) => {
          var s;
          return (s = r()) == null ? void 0 : s.unobserve(o);
        }
      };
    })(), this.range = null, this.setOptions = (n) => {
      Object.entries(n).forEach(([r, o]) => {
        typeof o > "u" && delete n[r];
      }), this.options = {
        debug: !1,
        initialOffset: 0,
        overscan: 1,
        paddingStart: 0,
        paddingEnd: 0,
        scrollPaddingStart: 0,
        scrollPaddingEnd: 0,
        horizontal: !1,
        getItemKey: ja,
        rangeExtractor: Ya,
        onChange: () => {
        },
        measureElement: Za,
        initialRect: { width: 0, height: 0 },
        scrollMargin: 0,
        gap: 0,
        indexAttribute: "data-index",
        initialMeasurementsCache: [],
        lanes: 1,
        isScrollingResetDelay: 150,
        enabled: !0,
        isRtl: !1,
        useScrollendEvent: !1,
        useAnimationFrameWithResizeObserver: !1,
        ...n
      };
    }, this.notify = (n) => {
      var r, o;
      (o = (r = this.options).onChange) == null || o.call(r, this, n);
    }, this.maybeNotify = nt(
      () => (this.calculateRange(), [
        this.isScrolling,
        this.range ? this.range.startIndex : null,
        this.range ? this.range.endIndex : null
      ]),
      (n) => {
        this.notify(n);
      },
      {
        key: process.env.NODE_ENV !== "production" && "maybeNotify",
        debug: () => this.options.debug,
        initialDeps: [
          this.isScrolling,
          this.range ? this.range.startIndex : null,
          this.range ? this.range.endIndex : null
        ]
      }
    ), this.cleanup = () => {
      this.unsubs.filter(Boolean).forEach((n) => n()), this.unsubs = [], this.observer.disconnect(), this.scrollElement = null, this.targetWindow = null;
    }, this._didMount = () => () => {
      this.cleanup();
    }, this._willUpdate = () => {
      var n;
      const r = this.options.enabled ? this.options.getScrollElement() : null;
      if (this.scrollElement !== r) {
        if (this.cleanup(), !r) {
          this.maybeNotify();
          return;
        }
        this.scrollElement = r, this.scrollElement && "ownerDocument" in this.scrollElement ? this.targetWindow = this.scrollElement.ownerDocument.defaultView : this.targetWindow = ((n = this.scrollElement) == null ? void 0 : n.window) ?? null, this.elementsCache.forEach((o) => {
          this.observer.observe(o);
        }), this._scrollToOffset(this.getScrollOffset(), {
          adjustments: void 0,
          behavior: void 0
        }), this.unsubs.push(
          this.options.observeElementRect(this, (o) => {
            this.scrollRect = o, this.maybeNotify();
          })
        ), this.unsubs.push(
          this.options.observeElementOffset(this, (o, s) => {
            this.scrollAdjustments = 0, this.scrollDirection = s ? this.getScrollOffset() < o ? "forward" : "backward" : null, this.scrollOffset = o, this.isScrolling = s, this.maybeNotify();
          })
        );
      }
    }, this.getSize = () => this.options.enabled ? (this.scrollRect = this.scrollRect ?? this.options.initialRect, this.scrollRect[this.options.horizontal ? "width" : "height"]) : (this.scrollRect = null, 0), this.getScrollOffset = () => this.options.enabled ? (this.scrollOffset = this.scrollOffset ?? (typeof this.options.initialOffset == "function" ? this.options.initialOffset() : this.options.initialOffset), this.scrollOffset) : (this.scrollOffset = null, 0), this.getFurthestMeasurement = (n, r) => {
      const o = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map();
      for (let i = r - 1; i >= 0; i--) {
        const a = n[i];
        if (o.has(a.lane))
          continue;
        const l = s.get(
          a.lane
        );
        if (l == null || a.end > l.end ? s.set(a.lane, a) : a.end < l.end && o.set(a.lane, !0), o.size === this.options.lanes)
          break;
      }
      return s.size === this.options.lanes ? Array.from(s.values()).sort((i, a) => i.end === a.end ? i.index - a.index : i.end - a.end)[0] : void 0;
    }, this.getMeasurementOptions = nt(
      () => [
        this.options.count,
        this.options.paddingStart,
        this.options.scrollMargin,
        this.options.getItemKey,
        this.options.enabled
      ],
      (n, r, o, s, i) => (this.pendingMeasuredCacheIndexes = [], {
        count: n,
        paddingStart: r,
        scrollMargin: o,
        getItemKey: s,
        enabled: i
      }),
      {
        key: !1
      }
    ), this.getMeasurements = nt(
      () => [this.getMeasurementOptions(), this.itemSizeCache],
      ({ count: n, paddingStart: r, scrollMargin: o, getItemKey: s, enabled: i }, a) => {
        if (!i)
          return this.measurementsCache = [], this.itemSizeCache.clear(), [];
        this.measurementsCache.length === 0 && (this.measurementsCache = this.options.initialMeasurementsCache, this.measurementsCache.forEach((u) => {
          this.itemSizeCache.set(u.key, u.size);
        }));
        const l = this.pendingMeasuredCacheIndexes.length > 0 ? Math.min(...this.pendingMeasuredCacheIndexes) : 0;
        this.pendingMeasuredCacheIndexes = [];
        const c = this.measurementsCache.slice(0, l);
        for (let u = l; u < n; u++) {
          const f = s(u), v = this.options.lanes === 1 ? c[u - 1] : this.getFurthestMeasurement(c, u), g = v ? v.end + this.options.gap : r + o, b = a.get(f), h = typeof b == "number" ? b : this.options.estimateSize(u), w = g + h, m = v ? v.lane : u % this.options.lanes;
          c[u] = {
            index: u,
            start: g,
            size: h,
            end: w,
            key: f,
            lane: m
          };
        }
        return this.measurementsCache = c, c;
      },
      {
        key: process.env.NODE_ENV !== "production" && "getMeasurements",
        debug: () => this.options.debug
      }
    ), this.calculateRange = nt(
      () => [
        this.getMeasurements(),
        this.getSize(),
        this.getScrollOffset(),
        this.options.lanes
      ],
      (n, r, o, s) => this.range = n.length > 0 && r > 0 ? el({
        measurements: n,
        outerSize: r,
        scrollOffset: o,
        lanes: s
      }) : null,
      {
        key: process.env.NODE_ENV !== "production" && "calculateRange",
        debug: () => this.options.debug
      }
    ), this.getVirtualIndexes = nt(
      () => {
        let n = null, r = null;
        const o = this.calculateRange();
        return o && (n = o.startIndex, r = o.endIndex), this.maybeNotify.updateDeps([this.isScrolling, n, r]), [
          this.options.rangeExtractor,
          this.options.overscan,
          this.options.count,
          n,
          r
        ];
      },
      (n, r, o, s, i) => s === null || i === null ? [] : n({
        startIndex: s,
        endIndex: i,
        overscan: r,
        count: o
      }),
      {
        key: process.env.NODE_ENV !== "production" && "getVirtualIndexes",
        debug: () => this.options.debug
      }
    ), this.indexFromElement = (n) => {
      const r = this.options.indexAttribute, o = n.getAttribute(r);
      return o ? parseInt(o, 10) : (console.warn(
        `Missing attribute name '${r}={index}' on measured element.`
      ), -1);
    }, this._measureElement = (n, r) => {
      const o = this.indexFromElement(n), s = this.measurementsCache[o];
      if (!s)
        return;
      const i = s.key, a = this.elementsCache.get(i);
      a !== n && (a && this.observer.unobserve(a), this.observer.observe(n), this.elementsCache.set(i, n)), n.isConnected && this.resizeItem(o, this.options.measureElement(n, r, this));
    }, this.resizeItem = (n, r) => {
      const o = this.measurementsCache[n];
      if (!o)
        return;
      const s = this.itemSizeCache.get(o.key) ?? o.size, i = r - s;
      i !== 0 && ((this.shouldAdjustScrollPositionOnItemSizeChange !== void 0 ? this.shouldAdjustScrollPositionOnItemSizeChange(o, i, this) : o.start < this.getScrollOffset() + this.scrollAdjustments) && (process.env.NODE_ENV !== "production" && this.options.debug && console.info("correction", i), this._scrollToOffset(this.getScrollOffset(), {
        adjustments: this.scrollAdjustments += i,
        behavior: void 0
      })), this.pendingMeasuredCacheIndexes.push(o.index), this.itemSizeCache = new Map(this.itemSizeCache.set(o.key, r)), this.notify(!1));
    }, this.measureElement = (n) => {
      if (!n) {
        this.elementsCache.forEach((r, o) => {
          r.isConnected || (this.observer.unobserve(r), this.elementsCache.delete(o));
        });
        return;
      }
      this._measureElement(n, void 0);
    }, this.getVirtualItems = nt(
      () => [this.getVirtualIndexes(), this.getMeasurements()],
      (n, r) => {
        const o = [];
        for (let s = 0, i = n.length; s < i; s++) {
          const a = n[s], l = r[a];
          o.push(l);
        }
        return o;
      },
      {
        key: process.env.NODE_ENV !== "production" && "getVirtualItems",
        debug: () => this.options.debug
      }
    ), this.getVirtualItemForOffset = (n) => {
      const r = this.getMeasurements();
      if (r.length !== 0)
        return Pr(
          r[go(
            0,
            r.length - 1,
            (o) => Pr(r[o]).start,
            n
          )]
        );
    }, this.getOffsetForAlignment = (n, r, o = 0) => {
      const s = this.getSize(), i = this.getScrollOffset();
      r === "auto" && (r = n >= i + s ? "end" : "start"), r === "center" ? n += (o - s) / 2 : r === "end" && (n -= s);
      const a = this.getTotalSize() + this.options.scrollMargin - s;
      return Math.max(Math.min(a, n), 0);
    }, this.getOffsetForIndex = (n, r = "auto") => {
      n = Math.max(0, Math.min(n, this.options.count - 1));
      const o = this.measurementsCache[n];
      if (!o)
        return;
      const s = this.getSize(), i = this.getScrollOffset();
      if (r === "auto")
        if (o.end >= i + s - this.options.scrollPaddingEnd)
          r = "end";
        else if (o.start <= i + this.options.scrollPaddingStart)
          r = "start";
        else
          return [i, r];
      const a = r === "end" ? o.end + this.options.scrollPaddingEnd : o.start - this.options.scrollPaddingStart;
      return [
        this.getOffsetForAlignment(a, r, o.size),
        r
      ];
    }, this.isDynamicMode = () => this.elementsCache.size > 0, this.scrollToOffset = (n, { align: r = "start", behavior: o } = {}) => {
      o === "smooth" && this.isDynamicMode() && console.warn(
        "The `smooth` scroll behavior is not fully supported with dynamic size."
      ), this._scrollToOffset(this.getOffsetForAlignment(n, r), {
        adjustments: void 0,
        behavior: o
      });
    }, this.scrollToIndex = (n, { align: r = "auto", behavior: o } = {}) => {
      o === "smooth" && this.isDynamicMode() && console.warn(
        "The `smooth` scroll behavior is not fully supported with dynamic size."
      ), n = Math.max(0, Math.min(n, this.options.count - 1));
      let s = 0;
      const i = 10, a = (c) => {
        if (!this.targetWindow) return;
        const u = this.getOffsetForIndex(n, c);
        if (!u) {
          console.warn("Failed to get offset for index:", n);
          return;
        }
        const [f, v] = u;
        this._scrollToOffset(f, { adjustments: void 0, behavior: o }), this.targetWindow.requestAnimationFrame(() => {
          const g = this.getScrollOffset(), b = this.getOffsetForIndex(n, v);
          if (!b) {
            console.warn("Failed to get offset for index:", n);
            return;
          }
          Ga(b[0], g) || l(v);
        });
      }, l = (c) => {
        this.targetWindow && (s++, s < i ? (process.env.NODE_ENV !== "production" && this.options.debug && console.info("Schedule retry", s, i), this.targetWindow.requestAnimationFrame(() => a(c))) : console.warn(
          `Failed to scroll to index ${n} after ${i} attempts.`
        ));
      };
      a(r);
    }, this.scrollBy = (n, { behavior: r } = {}) => {
      r === "smooth" && this.isDynamicMode() && console.warn(
        "The `smooth` scroll behavior is not fully supported with dynamic size."
      ), this._scrollToOffset(this.getScrollOffset() + n, {
        adjustments: void 0,
        behavior: r
      });
    }, this.getTotalSize = () => {
      var n;
      const r = this.getMeasurements();
      let o;
      if (r.length === 0)
        o = this.options.paddingStart;
      else if (this.options.lanes === 1)
        o = ((n = r[r.length - 1]) == null ? void 0 : n.end) ?? 0;
      else {
        const s = Array(this.options.lanes).fill(null);
        let i = r.length - 1;
        for (; i >= 0 && s.some((a) => a === null); ) {
          const a = r[i];
          s[a.lane] === null && (s[a.lane] = a.end), i--;
        }
        o = Math.max(...s.filter((a) => a !== null));
      }
      return Math.max(
        o - this.options.scrollMargin + this.options.paddingEnd,
        0
      );
    }, this._scrollToOffset = (n, {
      adjustments: r,
      behavior: o
    }) => {
      this.options.scrollToFn(n, { behavior: o, adjustments: r }, this);
    }, this.measure = () => {
      this.itemSizeCache = /* @__PURE__ */ new Map(), this.notify(!1);
    }, this.setOptions(t);
  }
}
const go = (e, t, n, r) => {
  for (; e <= t; ) {
    const o = (e + t) / 2 | 0, s = n(o);
    if (s < r)
      e = o + 1;
    else if (s > r)
      t = o - 1;
    else
      return o;
  }
  return e > 0 ? e - 1 : 0;
};
function el({
  measurements: e,
  outerSize: t,
  scrollOffset: n,
  lanes: r
}) {
  const o = e.length - 1, s = (l) => e[l].start;
  if (e.length <= r)
    return {
      startIndex: 0,
      endIndex: o
    };
  let i = go(
    0,
    o,
    s,
    n
  ), a = i;
  if (r === 1)
    for (; a < o && e[a].end < n + t; )
      a++;
  else if (r > 1) {
    const l = Array(r).fill(0);
    for (; a < o && l.some((u) => u < n + t); ) {
      const u = e[a];
      l[u.lane] = u.end, a++;
    }
    const c = Array(r).fill(n + t);
    for (; i >= 0 && c.some((u) => u >= n); ) {
      const u = e[i];
      c[u.lane] = u.start, i--;
    }
    i = Math.max(0, i - i % r), a = Math.min(o, a + (r - 1 - a % r));
  }
  return { startIndex: i, endIndex: a };
}
const Dr = typeof document < "u" ? d.useLayoutEffect : d.useEffect;
function tl(e) {
  const t = d.useReducer(() => ({}), {})[1], n = {
    ...e,
    onChange: (o, s) => {
      var i;
      s ? Ra(t) : t(), (i = e.onChange) == null || i.call(e, o, s);
    }
  }, [r] = d.useState(
    () => new Qa(n)
  );
  return r.setOptions(n), Dr(() => r._didMount(), []), Dr(() => r._willUpdate()), r;
}
function nl(e) {
  return tl({
    observeElementRect: Xa,
    observeElementOffset: qa,
    scrollToFn: Ja,
    ...e
  });
}
function rl({
  data: e,
  config: t,
  containerRef: n,
  enabled: r = !0
}) {
  const o = r && t.enabled, [s, i] = ae(!1);
  Ct(() => {
    n.current ? i(!0) : i(!1);
  }, [n.current]);
  const a = nl({
    count: e.length,
    getScrollElement: () => n.current,
    estimateSize: E(() => typeof t.rowHeight == "number" ? t.rowHeight : t.estimatedRowHeight || 50, [t.rowHeight, t.estimatedRowHeight]),
    overscan: t.overscan || 10,
    horizontal: !1,
    measureElement: void 0,
    scrollMargin: 0
  }), [l, c] = ae(0);
  Ct(() => {
    if (o && n.current) {
      const m = n.current, y = () => {
        c((x) => x + 1);
      };
      return m.addEventListener("scroll", y, { passive: !0 }), setTimeout(() => {
        m && y();
      }, 100), () => {
        m.removeEventListener("scroll", y);
      };
    }
  }, [o, n.current]);
  const u = ce(() => {
    if (!o)
      return [];
    if (!s || !n.current)
      return [];
    try {
      return a.getVirtualItems().map((x) => ({
        index: x.index,
        start: x.start,
        size: x.size,
        end: x.end,
        key: String(x.key)
      }));
    } catch {
      return [];
    }
  }, [
    a,
    o,
    s,
    n,
    e.length,
    l
  ]), f = ce(() => !o || u.length === 0 ? e : u.map((m) => e[m.index]).filter(Boolean), [e, u, o]), v = ce(() => ({
    height: `${a.getTotalSize()}px`,
    width: "100%",
    position: "relative"
  }), [a]), g = ce(() => {
    var m, y;
    return {
      scrollOffset: a.scrollOffset || 0,
      totalHeight: a.getTotalSize(),
      containerHeight: t.containerHeight || 500,
      visibleStartIndex: ((m = u[0]) == null ? void 0 : m.index) || 0,
      visibleEndIndex: ((y = u[u.length - 1]) == null ? void 0 : y.index) || 0,
      isVirtualizing: !!o
    };
  }, [
    a,
    u,
    t.containerHeight,
    o
  ]), b = E(
    (m, y) => {
      !o || !a || a.scrollToIndex(m, {
        align: (y == null ? void 0 : y.align) || "start"
      });
    },
    [a, o]
  ), h = E(() => {
    !o || !a || a.scrollToIndex(0);
  }, [a, o]), w = E(() => {
    !o || !a || a.scrollToIndex(e.length - 1);
  }, [a, o, e.length]);
  return {
    virtualItems: u,
    visibleData: f,
    containerStyle: v,
    virtualizer: a,
    scrollInfo: g,
    scrollToIndex: b,
    scrollToTop: h,
    scrollToBottom: w
  };
}
/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */
const ol = (e) => e.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), vo = (...e) => e.filter((t, n, r) => !!t && t.trim() !== "" && r.indexOf(t) === n).join(" ").trim();
/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */
var sl = {
  xmlns: "http://www.w3.org/2000/svg",
  width: 24,
  height: 24,
  viewBox: "0 0 24 24",
  fill: "none",
  stroke: "currentColor",
  strokeWidth: 2,
  strokeLinecap: "round",
  strokeLinejoin: "round"
};
/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */
const il = mo(
  ({
    color: e = "currentColor",
    size: t = 24,
    strokeWidth: n = 2,
    absoluteStrokeWidth: r,
    className: o = "",
    children: s,
    iconNode: i,
    ...a
  }, l) => Mn(
    "svg",
    {
      ref: l,
      ...sl,
      width: t,
      height: t,
      stroke: e,
      strokeWidth: r ? Number(n) * 24 / Number(t) : n,
      className: vo("lucide", o),
      ...a
    },
    [
      ...i.map(([c, u]) => Mn(c, u)),
      ...Array.isArray(s) ? s : [s]
    ]
  )
);
/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */
const pe = (e, t) => {
  const n = mo(
    ({ className: r, ...o }, s) => Mn(il, {
      ref: s,
      iconNode: t,
      className: vo(`lucide-${ol(e)}`, r),
      ...o
    })
  );
  return n.displayName = `${e}`, n;
};
/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */
const Jt = pe("Check", [["path", { d: "M20 6 9 17l-5-5", key: "1gmf2c" }]]);
/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */
const wo = pe("ChevronDown", [
  ["path", { d: "m6 9 6 6 6-6", key: "qrunsl" }]
]);
/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */
const al = pe("ChevronLeft", [
  ["path", { d: "m15 18-6-6 6-6", key: "1wnfg3" }]
]);
/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */
const yo = pe("ChevronRight", [
  ["path", { d: "m9 18 6-6-6-6", key: "mthhwq" }]
]);
/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */
const ll = pe("ChevronUp", [["path", { d: "m18 15-6-6-6 6", key: "153udz" }]]);
/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */
const cl = pe("ChevronsLeft", [
  ["path", { d: "m11 17-5-5 5-5", key: "13zhaf" }],
  ["path", { d: "m18 17-5-5 5-5", key: "h8a8et" }]
]);
/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */
const dl = pe("ChevronsRight", [
  ["path", { d: "m6 17 5-5-5-5", key: "xnjwq" }],
  ["path", { d: "m13 17 5-5-5-5", key: "17xmmf" }]
]);
/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */
const Or = pe("CircleAlert", [
  ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
  ["line", { x1: "12", x2: "12", y1: "8", y2: "12", key: "1pkeuh" }],
  ["line", { x1: "12", x2: "12.01", y1: "16", y2: "16", key: "4dfq90" }]
]);
/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */
const ul = pe("Circle", [
  ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }]
]);
/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */
const qn = pe("Ellipsis", [
  ["circle", { cx: "12", cy: "12", r: "1", key: "41hilf" }],
  ["circle", { cx: "19", cy: "12", r: "1", key: "1wjl8i" }],
  ["circle", { cx: "5", cy: "12", r: "1", key: "1pcz8c" }]
]);
/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */
const fl = pe("Minus", [["path", { d: "M5 12h14", key: "1ays0h" }]]);
/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */
const hl = pe("PenLine", [
  ["path", { d: "M12 20h9", key: "t2du7b" }],
  [
    "path",
    {
      d: "M16.376 3.622a1 1 0 0 1 3.002 3.002L7.368 18.635a2 2 0 0 1-.855.506l-2.872.838a.5.5 0 0 1-.62-.62l.838-2.872a2 2 0 0 1 .506-.854z",
      key: "1ykcvy"
    }
  ]
]);
/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */
const ml = pe("RefreshCw", [
  ["path", { d: "M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8", key: "v9h5vc" }],
  ["path", { d: "M21 3v5h-5", key: "1q7to0" }],
  ["path", { d: "M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16", key: "3uifl3" }],
  ["path", { d: "M8 16H3v5", key: "1cv678" }]
]);
/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */
const pl = pe("TriangleAlert", [
  [
    "path",
    {
      d: "m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",
      key: "wmoenq"
    }
  ],
  ["path", { d: "M12 9v4", key: "juzpu7" }],
  ["path", { d: "M12 17h.01", key: "p32p05" }]
]);
function _r(e, t) {
  if (typeof e == "function")
    return e(t);
  e != null && (e.current = t);
}
function Qt(...e) {
  return (t) => {
    let n = !1;
    const r = e.map((o) => {
      const s = _r(o, t);
      return !n && typeof s == "function" && (n = !0), s;
    });
    if (n)
      return () => {
        for (let o = 0; o < r.length; o++) {
          const s = r[o];
          typeof s == "function" ? s() : _r(e[o], null);
        }
      };
  };
}
function ie(...e) {
  return d.useCallback(Qt(...e), e);
}
// @__NO_SIDE_EFFECTS__
function lt(e) {
  const t = /* @__PURE__ */ vl(e), n = d.forwardRef((r, o) => {
    const { children: s, ...i } = r, a = d.Children.toArray(s), l = a.find(yl);
    if (l) {
      const c = l.props.children, u = a.map((f) => f === l ? d.Children.count(c) > 1 ? d.Children.only(null) : d.isValidElement(c) ? c.props.children : null : f);
      return /* @__PURE__ */ p(t, { ...i, ref: o, children: d.isValidElement(c) ? d.cloneElement(c, void 0, u) : null });
    }
    return /* @__PURE__ */ p(t, { ...i, ref: o, children: s });
  });
  return n.displayName = `${e}.Slot`, n;
}
var gl = /* @__PURE__ */ lt("Slot");
// @__NO_SIDE_EFFECTS__
function vl(e) {
  const t = d.forwardRef((n, r) => {
    const { children: o, ...s } = n;
    if (d.isValidElement(o)) {
      const i = xl(o), a = bl(s, o.props);
      return o.type !== d.Fragment && (a.ref = r ? Qt(r, i) : i), d.cloneElement(o, a);
    }
    return d.Children.count(o) > 1 ? d.Children.only(null) : null;
  });
  return t.displayName = `${e}.SlotClone`, t;
}
var bo = Symbol("radix.slottable");
// @__NO_SIDE_EFFECTS__
function wl(e) {
  const t = ({ children: n }) => /* @__PURE__ */ p(ft, { children: n });
  return t.displayName = `${e}.Slottable`, t.__radixId = bo, t;
}
function yl(e) {
  return d.isValidElement(e) && typeof e.type == "function" && "__radixId" in e.type && e.type.__radixId === bo;
}
function bl(e, t) {
  const n = { ...t };
  for (const r in t) {
    const o = e[r], s = t[r];
    /^on[A-Z]/.test(r) ? o && s ? n[r] = (...a) => {
      const l = s(...a);
      return o(...a), l;
    } : o && (n[r] = o) : r === "style" ? n[r] = { ...o, ...s } : r === "className" && (n[r] = [o, s].filter(Boolean).join(" "));
  }
  return { ...e, ...n };
}
function xl(e) {
  var r, o;
  let t = (r = Object.getOwnPropertyDescriptor(e.props, "ref")) == null ? void 0 : r.get, n = t && "isReactWarning" in t && t.isReactWarning;
  return n ? e.ref : (t = (o = Object.getOwnPropertyDescriptor(e, "ref")) == null ? void 0 : o.get, n = t && "isReactWarning" in t && t.isReactWarning, n ? e.props.ref : e.props.ref || e.ref);
}
const Lr = (e) => typeof e == "boolean" ? `${e}` : e === 0 ? "0" : e, Fr = Na, ze = (e, t) => (n) => {
  var r;
  if ((t == null ? void 0 : t.variants) == null) return Fr(e, n == null ? void 0 : n.class, n == null ? void 0 : n.className);
  const { variants: o, defaultVariants: s } = t, i = Object.keys(o).map((c) => {
    const u = n == null ? void 0 : n[c], f = s == null ? void 0 : s[c];
    if (u === null) return null;
    const v = Lr(u) || Lr(f);
    return o[c][v];
  }), a = n && Object.entries(n).reduce((c, u) => {
    let [f, v] = u;
    return v === void 0 || (c[f] = v), c;
  }, {}), l = t == null || (r = t.compoundVariants) === null || r === void 0 ? void 0 : r.reduce((c, u) => {
    let { class: f, className: v, ...g } = u;
    return Object.entries(g).every((b) => {
      let [h, w] = b;
      return Array.isArray(w) ? w.includes({
        ...s,
        ...a
      }[h]) : {
        ...s,
        ...a
      }[h] === w;
    }) ? [
      ...c,
      f,
      v
    ] : c;
  }, []);
  return Fr(e, i, l, n == null ? void 0 : n.class, n == null ? void 0 : n.className);
}, xo = ze(
  "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
  {
    variants: {
      variant: {
        default: "bg-primary text-primary-foreground hover:bg-primary/90",
        destructive: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
        outline: "border border-input bg-background hover:bg-accent hover:text-accent-foreground",
        secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
        ghost: "hover:bg-accent hover:text-accent-foreground",
        link: "text-primary underline-offset-4 hover:underline",
        sort: "hover:bg-muted/50 text-muted-foreground hover:text-foreground",
        filter: "border border-dashed border-input bg-background hover:bg-accent hover:text-accent-foreground"
      },
      size: {
        default: "h-10 px-4 py-2",
        sm: "h-9 rounded-md px-3",
        lg: "h-11 rounded-md px-8",
        icon: "h-10 w-10",
        xs: "h-8 rounded px-2 text-xs"
      }
    },
    defaultVariants: {
      variant: "default",
      size: "default"
    }
  }
), Ie = d.forwardRef(
  ({
    className: e,
    variant: t,
    size: n,
    asChild: r = !1,
    loading: o = !1,
    icon: s,
    iconPosition: i = "left",
    children: a,
    disabled: l,
    ...c
  }, u) => /* @__PURE__ */ V(
    r ? gl : "button",
    {
      className: te(xo({ variant: t, size: n, className: e })),
      ref: u,
      disabled: l || o,
      ...c,
      children: [
        o && /* @__PURE__ */ V(
          "svg",
          {
            className: "animate-spin -ml-1 mr-2 h-4 w-4",
            xmlns: "http://www.w3.org/2000/svg",
            fill: "none",
            viewBox: "0 0 24 24",
            children: [
              /* @__PURE__ */ p("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }),
              /* @__PURE__ */ p(
                "path",
                {
                  className: "opacity-75",
                  fill: "currentColor",
                  d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
                }
              )
            ]
          }
        ),
        !o && s && i === "left" && s,
        a,
        !o && s && i === "right" && s
      ]
    }
  )
);
Ie.displayName = "Button";
const Co = ({ className: e, ...t }) => /* @__PURE__ */ p(
  "nav",
  {
    role: "navigation",
    "aria-label": "pagination",
    className: te("mx-auto flex w-full justify-center", e),
    ...t
  }
);
Co.displayName = "Pagination";
const So = d.forwardRef(({ className: e, ...t }, n) => /* @__PURE__ */ p(
  "ul",
  {
    ref: n,
    className: te("flex flex-row items-center gap-1", e),
    ...t
  }
));
So.displayName = "PaginationContent";
const Ge = d.forwardRef(({ className: e, ...t }, n) => /* @__PURE__ */ p("li", { ref: n, className: te("", e), ...t }));
Ge.displayName = "PaginationItem";
const en = ({
  className: e,
  isActive: t,
  size: n = "icon",
  ...r
}) => /* @__PURE__ */ p(
  "a",
  {
    "aria-current": t ? "page" : void 0,
    className: te(
      xo({
        variant: t ? "outline" : "ghost",
        size: n
      }),
      e
    ),
    ...r
  }
);
en.displayName = "PaginationLink";
const Ro = ({
  className: e,
  ...t
}) => /* @__PURE__ */ V(
  en,
  {
    "aria-label": "Go to previous page",
    size: "default",
    className: te("gap-1 pl-2.5", e),
    ...t,
    children: [
      /* @__PURE__ */ p(al, { className: "h-4 w-4" }),
      /* @__PURE__ */ p("span", { children: "Previous" })
    ]
  }
);
Ro.displayName = "PaginationPrevious";
const Io = ({
  className: e,
  ...t
}) => /* @__PURE__ */ V(
  en,
  {
    "aria-label": "Go to next page",
    size: "default",
    className: te("gap-1 pr-2.5", e),
    ...t,
    children: [
      /* @__PURE__ */ p("span", { children: "Next" }),
      /* @__PURE__ */ p(yo, { className: "h-4 w-4" })
    ]
  }
);
Io.displayName = "PaginationNext";
const Eo = ({
  className: e,
  ...t
}) => /* @__PURE__ */ V(
  "span",
  {
    "aria-hidden": !0,
    className: te("flex h-9 w-9 items-center justify-center", e),
    ...t,
    children: [
      /* @__PURE__ */ p(qn, { className: "h-4 w-4" }),
      /* @__PURE__ */ p("span", { className: "sr-only", children: "More pages" })
    ]
  }
);
Eo.displayName = "PaginationEllipsis";
function Cl({
  currentPage: e,
  totalPages: t,
  pageSize: n,
  totalCount: r,
  onPageChange: o,
  showInfo: s = !0,
  showFirstLast: i = !0,
  siblingCount: a = 1,
  className: l
}) {
  const c = e + 1, u = Ma(
    c,
    t,
    a
  ), f = Pa(
    c,
    n,
    r
  ), v = d.useCallback(
    (w) => {
      if (typeof w == "number") {
        const m = w - 1;
        m >= 0 && m < t && o(m);
      }
    },
    [o, t]
  ), g = d.useMemo(() => e === 0, [e]), b = d.useMemo(
    () => e >= t - 1,
    [e, t]
  ), h = t > 1 && u.length > 0;
  return /* @__PURE__ */ V(
    "div",
    {
      className: `${h ? "flex flex-col sm:flex-row items-center justify-between gap-4" : "flex items-center justify-between"} ${l}`,
      children: [
        s && /* @__PURE__ */ p(
          "div",
          {
            className: `text-sm text-muted-foreground ${h ? "order-2 sm:order-1" : ""}`,
            children: f.description
          }
        ),
        h && /* @__PURE__ */ p("div", { className: "flex items-center space-x-2 order-1 sm:order-2", children: /* @__PURE__ */ p(Co, { children: /* @__PURE__ */ V(So, { children: [
          i && !g && /* @__PURE__ */ p(Ge, { children: /* @__PURE__ */ p(
            Ie,
            {
              variant: "outline",
              size: "icon",
              onClick: () => v(1),
              disabled: g,
              "aria-label": "Go to first page",
              children: /* @__PURE__ */ p(cl, { className: "h-4 w-4" })
            }
          ) }),
          /* @__PURE__ */ p(Ge, { children: /* @__PURE__ */ p(
            Ro,
            {
              onClick: () => v(c - 1),
              className: g ? "pointer-events-none opacity-50" : "cursor-pointer"
            }
          ) }),
          u.map((w, m) => {
            if (w === "...")
              return /* @__PURE__ */ p(Ge, { children: /* @__PURE__ */ p(Eo, {}) }, `ellipsis-${m}`);
            const y = w;
            return /* @__PURE__ */ p(Ge, { children: /* @__PURE__ */ p(
              en,
              {
                onClick: () => v(y),
                isActive: y === c,
                className: "cursor-pointer",
                children: y
              }
            ) }, y);
          }),
          /* @__PURE__ */ p(Ge, { children: /* @__PURE__ */ p(
            Io,
            {
              onClick: () => v(c + 1),
              className: b ? "pointer-events-none opacity-50" : "cursor-pointer"
            }
          ) }),
          i && !b && /* @__PURE__ */ p(Ge, { children: /* @__PURE__ */ p(
            Ie,
            {
              variant: "outline",
              size: "icon",
              onClick: () => v(t),
              disabled: b,
              "aria-label": "Go to last page",
              children: /* @__PURE__ */ p(dl, { className: "h-4 w-4" })
            }
          ) })
        ] }) }) })
      ]
    }
  );
}
function Sl({ title: e }) {
  return /* @__PURE__ */ p("div", { className: "flex items-center justify-between", children: /* @__PURE__ */ p("h1", { className: "text-2xl font-bold", children: e }) });
}
function $r(e, [t, n]) {
  return Math.min(n, Math.max(t, e));
}
function G(e, t, { checkForDefaultPrevented: n = !0 } = {}) {
  return function(o) {
    if (e == null || e(o), n === !1 || !o.defaultPrevented)
      return t == null ? void 0 : t(o);
  };
}
function Ve(e, t = []) {
  let n = [];
  function r(s, i) {
    const a = d.createContext(i), l = n.length;
    n = [...n, i];
    const c = (f) => {
      var m;
      const { scope: v, children: g, ...b } = f, h = ((m = v == null ? void 0 : v[e]) == null ? void 0 : m[l]) || a, w = d.useMemo(() => b, Object.values(b));
      return /* @__PURE__ */ p(h.Provider, { value: w, children: g });
    };
    c.displayName = s + "Provider";
    function u(f, v) {
      var h;
      const g = ((h = v == null ? void 0 : v[e]) == null ? void 0 : h[l]) || a, b = d.useContext(g);
      if (b) return b;
      if (i !== void 0) return i;
      throw new Error(`\`${f}\` must be used within \`${s}\``);
    }
    return [c, u];
  }
  const o = () => {
    const s = n.map((i) => d.createContext(i));
    return function(a) {
      const l = (a == null ? void 0 : a[e]) || s;
      return d.useMemo(
        () => ({ [`__scope${e}`]: { ...a, [e]: l } }),
        [a, l]
      );
    };
  };
  return o.scopeName = e, [r, Rl(o, ...t)];
}
function Rl(...e) {
  const t = e[0];
  if (e.length === 1) return t;
  const n = () => {
    const r = e.map((o) => ({
      useScope: o(),
      scopeName: o.scopeName
    }));
    return function(s) {
      const i = r.reduce((a, { useScope: l, scopeName: c }) => {
        const f = l(s)[`__scope${c}`];
        return { ...a, ...f };
      }, {});
      return d.useMemo(() => ({ [`__scope${t.scopeName}`]: i }), [i]);
    };
  };
  return n.scopeName = t.scopeName, n;
}
function Zn(e) {
  const t = e + "CollectionProvider", [n, r] = Ve(t), [o, s] = n(
    t,
    { collectionRef: { current: null }, itemMap: /* @__PURE__ */ new Map() }
  ), i = (h) => {
    const { scope: w, children: m } = h, y = He.useRef(null), x = He.useRef(/* @__PURE__ */ new Map()).current;
    return /* @__PURE__ */ p(o, { scope: w, itemMap: x, collectionRef: y, children: m });
  };
  i.displayName = t;
  const a = e + "CollectionSlot", l = /* @__PURE__ */ lt(a), c = He.forwardRef(
    (h, w) => {
      const { scope: m, children: y } = h, x = s(a, m), C = ie(w, x.collectionRef);
      return /* @__PURE__ */ p(l, { ref: C, children: y });
    }
  );
  c.displayName = a;
  const u = e + "CollectionItemSlot", f = "data-radix-collection-item", v = /* @__PURE__ */ lt(u), g = He.forwardRef(
    (h, w) => {
      const { scope: m, children: y, ...x } = h, C = He.useRef(null), S = ie(w, C), R = s(u, m);
      return He.useEffect(() => (R.itemMap.set(C, { ref: C, ...x }), () => void R.itemMap.delete(C))), /* @__PURE__ */ p(v, { [f]: "", ref: S, children: y });
    }
  );
  g.displayName = u;
  function b(h) {
    const w = s(e + "CollectionConsumer", h);
    return He.useCallback(() => {
      const y = w.collectionRef.current;
      if (!y) return [];
      const x = Array.from(y.querySelectorAll(`[${f}]`));
      return Array.from(w.itemMap.values()).sort(
        (R, N) => x.indexOf(R.ref.current) - x.indexOf(N.ref.current)
      );
    }, [w.collectionRef, w.itemMap]);
  }
  return [
    { Provider: i, Slot: c, ItemSlot: g },
    b,
    r
  ];
}
var Il = d.createContext(void 0);
function Jn(e) {
  const t = d.useContext(Il);
  return e || t || "ltr";
}
var El = [
  "a",
  "button",
  "div",
  "form",
  "h2",
  "h3",
  "img",
  "input",
  "label",
  "li",
  "nav",
  "ol",
  "p",
  "select",
  "span",
  "svg",
  "ul"
], se = El.reduce((e, t) => {
  const n = /* @__PURE__ */ lt(`Primitive.${t}`), r = d.forwardRef((o, s) => {
    const { asChild: i, ...a } = o, l = i ? n : t;
    return typeof window < "u" && (window[Symbol.for("radix-ui")] = !0), /* @__PURE__ */ p(l, { ...a, ref: s });
  });
  return r.displayName = `Primitive.${t}`, { ...e, [t]: r };
}, {});
function No(e, t) {
  e && Zt.flushSync(() => e.dispatchEvent(t));
}
function Me(e) {
  const t = d.useRef(e);
  return d.useEffect(() => {
    t.current = e;
  }), d.useMemo(() => (...n) => {
    var r;
    return (r = t.current) == null ? void 0 : r.call(t, ...n);
  }, []);
}
function Nl(e, t = globalThis == null ? void 0 : globalThis.document) {
  const n = Me(e);
  d.useEffect(() => {
    const r = (o) => {
      o.key === "Escape" && n(o);
    };
    return t.addEventListener("keydown", r, { capture: !0 }), () => t.removeEventListener("keydown", r, { capture: !0 });
  }, [n, t]);
}
var Ml = "DismissableLayer", An = "dismissableLayer.update", Pl = "dismissableLayer.pointerDownOutside", Tl = "dismissableLayer.focusOutside", zr, Mo = d.createContext({
  layers: /* @__PURE__ */ new Set(),
  layersWithOutsidePointerEventsDisabled: /* @__PURE__ */ new Set(),
  branches: /* @__PURE__ */ new Set()
}), tn = d.forwardRef(
  (e, t) => {
    const {
      disableOutsidePointerEvents: n = !1,
      onEscapeKeyDown: r,
      onPointerDownOutside: o,
      onFocusOutside: s,
      onInteractOutside: i,
      onDismiss: a,
      ...l
    } = e, c = d.useContext(Mo), [u, f] = d.useState(null), v = (u == null ? void 0 : u.ownerDocument) ?? (globalThis == null ? void 0 : globalThis.document), [, g] = d.useState({}), b = ie(t, (N) => f(N)), h = Array.from(c.layers), [w] = [...c.layersWithOutsidePointerEventsDisabled].slice(-1), m = h.indexOf(w), y = u ? h.indexOf(u) : -1, x = c.layersWithOutsidePointerEventsDisabled.size > 0, C = y >= m, S = Dl((N) => {
      const k = N.target, W = [...c.branches].some((O) => O.contains(k));
      !C || W || (o == null || o(N), i == null || i(N), N.defaultPrevented || a == null || a());
    }, v), R = Ol((N) => {
      const k = N.target;
      [...c.branches].some((O) => O.contains(k)) || (s == null || s(N), i == null || i(N), N.defaultPrevented || a == null || a());
    }, v);
    return Nl((N) => {
      y === c.layers.size - 1 && (r == null || r(N), !N.defaultPrevented && a && (N.preventDefault(), a()));
    }, v), d.useEffect(() => {
      if (u)
        return n && (c.layersWithOutsidePointerEventsDisabled.size === 0 && (zr = v.body.style.pointerEvents, v.body.style.pointerEvents = "none"), c.layersWithOutsidePointerEventsDisabled.add(u)), c.layers.add(u), Vr(), () => {
          n && c.layersWithOutsidePointerEventsDisabled.size === 1 && (v.body.style.pointerEvents = zr);
        };
    }, [u, v, n, c]), d.useEffect(() => () => {
      u && (c.layers.delete(u), c.layersWithOutsidePointerEventsDisabled.delete(u), Vr());
    }, [u, c]), d.useEffect(() => {
      const N = () => g({});
      return document.addEventListener(An, N), () => document.removeEventListener(An, N);
    }, []), /* @__PURE__ */ p(
      se.div,
      {
        ...l,
        ref: b,
        style: {
          pointerEvents: x ? C ? "auto" : "none" : void 0,
          ...e.style
        },
        onFocusCapture: G(e.onFocusCapture, R.onFocusCapture),
        onBlurCapture: G(e.onBlurCapture, R.onBlurCapture),
        onPointerDownCapture: G(
          e.onPointerDownCapture,
          S.onPointerDownCapture
        )
      }
    );
  }
);
tn.displayName = Ml;
var Al = "DismissableLayerBranch", kl = d.forwardRef((e, t) => {
  const n = d.useContext(Mo), r = d.useRef(null), o = ie(t, r);
  return d.useEffect(() => {
    const s = r.current;
    if (s)
      return n.branches.add(s), () => {
        n.branches.delete(s);
      };
  }, [n.branches]), /* @__PURE__ */ p(se.div, { ...e, ref: o });
});
kl.displayName = Al;
function Dl(e, t = globalThis == null ? void 0 : globalThis.document) {
  const n = Me(e), r = d.useRef(!1), o = d.useRef(() => {
  });
  return d.useEffect(() => {
    const s = (a) => {
      if (a.target && !r.current) {
        let l = function() {
          Po(
            Pl,
            n,
            c,
            { discrete: !0 }
          );
        };
        const c = { originalEvent: a };
        a.pointerType === "touch" ? (t.removeEventListener("click", o.current), o.current = l, t.addEventListener("click", o.current, { once: !0 })) : l();
      } else
        t.removeEventListener("click", o.current);
      r.current = !1;
    }, i = window.setTimeout(() => {
      t.addEventListener("pointerdown", s);
    }, 0);
    return () => {
      window.clearTimeout(i), t.removeEventListener("pointerdown", s), t.removeEventListener("click", o.current);
    };
  }, [t, n]), {
    // ensures we check React component tree (not just DOM tree)
    onPointerDownCapture: () => r.current = !0
  };
}
function Ol(e, t = globalThis == null ? void 0 : globalThis.document) {
  const n = Me(e), r = d.useRef(!1);
  return d.useEffect(() => {
    const o = (s) => {
      s.target && !r.current && Po(Tl, n, { originalEvent: s }, {
        discrete: !1
      });
    };
    return t.addEventListener("focusin", o), () => t.removeEventListener("focusin", o);
  }, [t, n]), {
    onFocusCapture: () => r.current = !0,
    onBlurCapture: () => r.current = !1
  };
}
function Vr() {
  const e = new CustomEvent(An);
  document.dispatchEvent(e);
}
function Po(e, t, n, { discrete: r }) {
  const o = n.originalEvent.target, s = new CustomEvent(e, { bubbles: !1, cancelable: !0, detail: n });
  t && o.addEventListener(e, t, { once: !0 }), r ? No(o, s) : o.dispatchEvent(s);
}
var vn = 0;
function To() {
  d.useEffect(() => {
    const e = document.querySelectorAll("[data-radix-focus-guard]");
    return document.body.insertAdjacentElement("afterbegin", e[0] ?? Br()), document.body.insertAdjacentElement("beforeend", e[1] ?? Br()), vn++, () => {
      vn === 1 && document.querySelectorAll("[data-radix-focus-guard]").forEach((t) => t.remove()), vn--;
    };
  }, []);
}
function Br() {
  const e = document.createElement("span");
  return e.setAttribute("data-radix-focus-guard", ""), e.tabIndex = 0, e.style.outline = "none", e.style.opacity = "0", e.style.position = "fixed", e.style.pointerEvents = "none", e;
}
var wn = "focusScope.autoFocusOnMount", yn = "focusScope.autoFocusOnUnmount", Wr = { bubbles: !1, cancelable: !0 }, _l = "FocusScope", Qn = d.forwardRef((e, t) => {
  const {
    loop: n = !1,
    trapped: r = !1,
    onMountAutoFocus: o,
    onUnmountAutoFocus: s,
    ...i
  } = e, [a, l] = d.useState(null), c = Me(o), u = Me(s), f = d.useRef(null), v = ie(t, (h) => l(h)), g = d.useRef({
    paused: !1,
    pause() {
      this.paused = !0;
    },
    resume() {
      this.paused = !1;
    }
  }).current;
  d.useEffect(() => {
    if (r) {
      let h = function(x) {
        if (g.paused || !a) return;
        const C = x.target;
        a.contains(C) ? f.current = C : _e(f.current, { select: !0 });
      }, w = function(x) {
        if (g.paused || !a) return;
        const C = x.relatedTarget;
        C !== null && (a.contains(C) || _e(f.current, { select: !0 }));
      }, m = function(x) {
        if (document.activeElement === document.body)
          for (const S of x)
            S.removedNodes.length > 0 && _e(a);
      };
      document.addEventListener("focusin", h), document.addEventListener("focusout", w);
      const y = new MutationObserver(m);
      return a && y.observe(a, { childList: !0, subtree: !0 }), () => {
        document.removeEventListener("focusin", h), document.removeEventListener("focusout", w), y.disconnect();
      };
    }
  }, [r, a, g.paused]), d.useEffect(() => {
    if (a) {
      Hr.add(g);
      const h = document.activeElement;
      if (!a.contains(h)) {
        const m = new CustomEvent(wn, Wr);
        a.addEventListener(wn, c), a.dispatchEvent(m), m.defaultPrevented || (Ll(Bl(Ao(a)), { select: !0 }), document.activeElement === h && _e(a));
      }
      return () => {
        a.removeEventListener(wn, c), setTimeout(() => {
          const m = new CustomEvent(yn, Wr);
          a.addEventListener(yn, u), a.dispatchEvent(m), m.defaultPrevented || _e(h ?? document.body, { select: !0 }), a.removeEventListener(yn, u), Hr.remove(g);
        }, 0);
      };
    }
  }, [a, c, u, g]);
  const b = d.useCallback(
    (h) => {
      if (!n && !r || g.paused) return;
      const w = h.key === "Tab" && !h.altKey && !h.ctrlKey && !h.metaKey, m = document.activeElement;
      if (w && m) {
        const y = h.currentTarget, [x, C] = Fl(y);
        x && C ? !h.shiftKey && m === C ? (h.preventDefault(), n && _e(x, { select: !0 })) : h.shiftKey && m === x && (h.preventDefault(), n && _e(C, { select: !0 })) : m === y && h.preventDefault();
      }
    },
    [n, r, g.paused]
  );
  return /* @__PURE__ */ p(se.div, { tabIndex: -1, ...i, ref: v, onKeyDown: b });
});
Qn.displayName = _l;
function Ll(e, { select: t = !1 } = {}) {
  const n = document.activeElement;
  for (const r of e)
    if (_e(r, { select: t }), document.activeElement !== n) return;
}
function Fl(e) {
  const t = Ao(e), n = Kr(t, e), r = Kr(t.reverse(), e);
  return [n, r];
}
function Ao(e) {
  const t = [], n = document.createTreeWalker(e, NodeFilter.SHOW_ELEMENT, {
    acceptNode: (r) => {
      const o = r.tagName === "INPUT" && r.type === "hidden";
      return r.disabled || r.hidden || o ? NodeFilter.FILTER_SKIP : r.tabIndex >= 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
    }
  });
  for (; n.nextNode(); ) t.push(n.currentNode);
  return t;
}
function Kr(e, t) {
  for (const n of e)
    if (!$l(n, { upTo: t })) return n;
}
function $l(e, { upTo: t }) {
  if (getComputedStyle(e).visibility === "hidden") return !0;
  for (; e; ) {
    if (t !== void 0 && e === t) return !1;
    if (getComputedStyle(e).display === "none") return !0;
    e = e.parentElement;
  }
  return !1;
}
function zl(e) {
  return e instanceof HTMLInputElement && "select" in e;
}
function _e(e, { select: t = !1 } = {}) {
  if (e && e.focus) {
    const n = document.activeElement;
    e.focus({ preventScroll: !0 }), e !== n && zl(e) && t && e.select();
  }
}
var Hr = Vl();
function Vl() {
  let e = [];
  return {
    add(t) {
      const n = e[0];
      t !== n && (n == null || n.pause()), e = Gr(e, t), e.unshift(t);
    },
    remove(t) {
      var n;
      e = Gr(e, t), (n = e[0]) == null || n.resume();
    }
  };
}
function Gr(e, t) {
  const n = [...e], r = n.indexOf(t);
  return r !== -1 && n.splice(r, 1), n;
}
function Bl(e) {
  return e.filter((t) => t.tagName !== "A");
}
var fe = globalThis != null && globalThis.document ? d.useLayoutEffect : () => {
}, Wl = d[" useId ".trim().toString()] || (() => {
}), Kl = 0;
function Ye(e) {
  const [t, n] = d.useState(Wl());
  return fe(() => {
    n((r) => r ?? String(Kl++));
  }, [e]), t ? `radix-${t}` : "";
}
const Hl = ["top", "right", "bottom", "left"], Fe = Math.min, ge = Math.max, Ht = Math.round, Dt = Math.floor, Ne = (e) => ({
  x: e,
  y: e
}), Gl = {
  left: "right",
  right: "left",
  bottom: "top",
  top: "bottom"
}, Ul = {
  start: "end",
  end: "start"
};
function kn(e, t, n) {
  return ge(e, Fe(t, n));
}
function Ae(e, t) {
  return typeof e == "function" ? e(t) : e;
}
function ke(e) {
  return e.split("-")[0];
}
function ht(e) {
  return e.split("-")[1];
}
function er(e) {
  return e === "x" ? "y" : "x";
}
function tr(e) {
  return e === "y" ? "height" : "width";
}
const jl = /* @__PURE__ */ new Set(["top", "bottom"]);
function Ee(e) {
  return jl.has(ke(e)) ? "y" : "x";
}
function nr(e) {
  return er(Ee(e));
}
function Yl(e, t, n) {
  n === void 0 && (n = !1);
  const r = ht(e), o = nr(e), s = tr(o);
  let i = o === "x" ? r === (n ? "end" : "start") ? "right" : "left" : r === "start" ? "bottom" : "top";
  return t.reference[s] > t.floating[s] && (i = Gt(i)), [i, Gt(i)];
}
function Xl(e) {
  const t = Gt(e);
  return [Dn(e), t, Dn(t)];
}
function Dn(e) {
  return e.replace(/start|end/g, (t) => Ul[t]);
}
const Ur = ["left", "right"], jr = ["right", "left"], ql = ["top", "bottom"], Zl = ["bottom", "top"];
function Jl(e, t, n) {
  switch (e) {
    case "top":
    case "bottom":
      return n ? t ? jr : Ur : t ? Ur : jr;
    case "left":
    case "right":
      return t ? ql : Zl;
    default:
      return [];
  }
}
function Ql(e, t, n, r) {
  const o = ht(e);
  let s = Jl(ke(e), n === "start", r);
  return o && (s = s.map((i) => i + "-" + o), t && (s = s.concat(s.map(Dn)))), s;
}
function Gt(e) {
  return e.replace(/left|right|bottom|top/g, (t) => Gl[t]);
}
function ec(e) {
  return {
    top: 0,
    right: 0,
    bottom: 0,
    left: 0,
    ...e
  };
}
function ko(e) {
  return typeof e != "number" ? ec(e) : {
    top: e,
    right: e,
    bottom: e,
    left: e
  };
}
function Ut(e) {
  const {
    x: t,
    y: n,
    width: r,
    height: o
  } = e;
  return {
    width: r,
    height: o,
    top: n,
    left: t,
    right: t + r,
    bottom: n + o,
    x: t,
    y: n
  };
}
function Yr(e, t, n) {
  let {
    reference: r,
    floating: o
  } = e;
  const s = Ee(t), i = nr(t), a = tr(i), l = ke(t), c = s === "y", u = r.x + r.width / 2 - o.width / 2, f = r.y + r.height / 2 - o.height / 2, v = r[a] / 2 - o[a] / 2;
  let g;
  switch (l) {
    case "top":
      g = {
        x: u,
        y: r.y - o.height
      };
      break;
    case "bottom":
      g = {
        x: u,
        y: r.y + r.height
      };
      break;
    case "right":
      g = {
        x: r.x + r.width,
        y: f
      };
      break;
    case "left":
      g = {
        x: r.x - o.width,
        y: f
      };
      break;
    default:
      g = {
        x: r.x,
        y: r.y
      };
  }
  switch (ht(t)) {
    case "start":
      g[i] -= v * (n && c ? -1 : 1);
      break;
    case "end":
      g[i] += v * (n && c ? -1 : 1);
      break;
  }
  return g;
}
const tc = async (e, t, n) => {
  const {
    placement: r = "bottom",
    strategy: o = "absolute",
    middleware: s = [],
    platform: i
  } = n, a = s.filter(Boolean), l = await (i.isRTL == null ? void 0 : i.isRTL(t));
  let c = await i.getElementRects({
    reference: e,
    floating: t,
    strategy: o
  }), {
    x: u,
    y: f
  } = Yr(c, r, l), v = r, g = {}, b = 0;
  for (let h = 0; h < a.length; h++) {
    const {
      name: w,
      fn: m
    } = a[h], {
      x: y,
      y: x,
      data: C,
      reset: S
    } = await m({
      x: u,
      y: f,
      initialPlacement: r,
      placement: v,
      strategy: o,
      middlewareData: g,
      rects: c,
      platform: i,
      elements: {
        reference: e,
        floating: t
      }
    });
    u = y ?? u, f = x ?? f, g = {
      ...g,
      [w]: {
        ...g[w],
        ...C
      }
    }, S && b <= 50 && (b++, typeof S == "object" && (S.placement && (v = S.placement), S.rects && (c = S.rects === !0 ? await i.getElementRects({
      reference: e,
      floating: t,
      strategy: o
    }) : S.rects), {
      x: u,
      y: f
    } = Yr(c, v, l)), h = -1);
  }
  return {
    x: u,
    y: f,
    placement: v,
    strategy: o,
    middlewareData: g
  };
};
async function St(e, t) {
  var n;
  t === void 0 && (t = {});
  const {
    x: r,
    y: o,
    platform: s,
    rects: i,
    elements: a,
    strategy: l
  } = e, {
    boundary: c = "clippingAncestors",
    rootBoundary: u = "viewport",
    elementContext: f = "floating",
    altBoundary: v = !1,
    padding: g = 0
  } = Ae(t, e), b = ko(g), w = a[v ? f === "floating" ? "reference" : "floating" : f], m = Ut(await s.getClippingRect({
    element: (n = await (s.isElement == null ? void 0 : s.isElement(w))) == null || n ? w : w.contextElement || await (s.getDocumentElement == null ? void 0 : s.getDocumentElement(a.floating)),
    boundary: c,
    rootBoundary: u,
    strategy: l
  })), y = f === "floating" ? {
    x: r,
    y: o,
    width: i.floating.width,
    height: i.floating.height
  } : i.reference, x = await (s.getOffsetParent == null ? void 0 : s.getOffsetParent(a.floating)), C = await (s.isElement == null ? void 0 : s.isElement(x)) ? await (s.getScale == null ? void 0 : s.getScale(x)) || {
    x: 1,
    y: 1
  } : {
    x: 1,
    y: 1
  }, S = Ut(s.convertOffsetParentRelativeRectToViewportRelativeRect ? await s.convertOffsetParentRelativeRectToViewportRelativeRect({
    elements: a,
    rect: y,
    offsetParent: x,
    strategy: l
  }) : y);
  return {
    top: (m.top - S.top + b.top) / C.y,
    bottom: (S.bottom - m.bottom + b.bottom) / C.y,
    left: (m.left - S.left + b.left) / C.x,
    right: (S.right - m.right + b.right) / C.x
  };
}
const nc = (e) => ({
  name: "arrow",
  options: e,
  async fn(t) {
    const {
      x: n,
      y: r,
      placement: o,
      rects: s,
      platform: i,
      elements: a,
      middlewareData: l
    } = t, {
      element: c,
      padding: u = 0
    } = Ae(e, t) || {};
    if (c == null)
      return {};
    const f = ko(u), v = {
      x: n,
      y: r
    }, g = nr(o), b = tr(g), h = await i.getDimensions(c), w = g === "y", m = w ? "top" : "left", y = w ? "bottom" : "right", x = w ? "clientHeight" : "clientWidth", C = s.reference[b] + s.reference[g] - v[g] - s.floating[b], S = v[g] - s.reference[g], R = await (i.getOffsetParent == null ? void 0 : i.getOffsetParent(c));
    let N = R ? R[x] : 0;
    (!N || !await (i.isElement == null ? void 0 : i.isElement(R))) && (N = a.floating[x] || s.floating[b]);
    const k = C / 2 - S / 2, W = N / 2 - h[b] / 2 - 1, O = Fe(f[m], W), T = Fe(f[y], W), _ = O, $ = N - h[b] - T, A = N / 2 - h[b] / 2 + k, H = kn(_, A, $), L = !l.arrow && ht(o) != null && A !== H && s.reference[b] / 2 - (A < _ ? O : T) - h[b] / 2 < 0, j = L ? A < _ ? A - _ : A - $ : 0;
    return {
      [g]: v[g] + j,
      data: {
        [g]: H,
        centerOffset: A - H - j,
        ...L && {
          alignmentOffset: j
        }
      },
      reset: L
    };
  }
}), rc = function(e) {
  return e === void 0 && (e = {}), {
    name: "flip",
    options: e,
    async fn(t) {
      var n, r;
      const {
        placement: o,
        middlewareData: s,
        rects: i,
        initialPlacement: a,
        platform: l,
        elements: c
      } = t, {
        mainAxis: u = !0,
        crossAxis: f = !0,
        fallbackPlacements: v,
        fallbackStrategy: g = "bestFit",
        fallbackAxisSideDirection: b = "none",
        flipAlignment: h = !0,
        ...w
      } = Ae(e, t);
      if ((n = s.arrow) != null && n.alignmentOffset)
        return {};
      const m = ke(o), y = Ee(a), x = ke(a) === a, C = await (l.isRTL == null ? void 0 : l.isRTL(c.floating)), S = v || (x || !h ? [Gt(a)] : Xl(a)), R = b !== "none";
      !v && R && S.push(...Ql(a, h, b, C));
      const N = [a, ...S], k = await St(t, w), W = [];
      let O = ((r = s.flip) == null ? void 0 : r.overflows) || [];
      if (u && W.push(k[m]), f) {
        const A = Yl(o, i, C);
        W.push(k[A[0]], k[A[1]]);
      }
      if (O = [...O, {
        placement: o,
        overflows: W
      }], !W.every((A) => A <= 0)) {
        var T, _;
        const A = (((T = s.flip) == null ? void 0 : T.index) || 0) + 1, H = N[A];
        if (H && (!(f === "alignment" ? y !== Ee(H) : !1) || // We leave the current main axis only if every placement on that axis
        // overflows the main axis.
        O.every((B) => B.overflows[0] > 0 && Ee(B.placement) === y)))
          return {
            data: {
              index: A,
              overflows: O
            },
            reset: {
              placement: H
            }
          };
        let L = (_ = O.filter((j) => j.overflows[0] <= 0).sort((j, B) => j.overflows[1] - B.overflows[1])[0]) == null ? void 0 : _.placement;
        if (!L)
          switch (g) {
            case "bestFit": {
              var $;
              const j = ($ = O.filter((B) => {
                if (R) {
                  const P = Ee(B.placement);
                  return P === y || // Create a bias to the `y` side axis due to horizontal
                  // reading directions favoring greater width.
                  P === "y";
                }
                return !0;
              }).map((B) => [B.placement, B.overflows.filter((P) => P > 0).reduce((P, Z) => P + Z, 0)]).sort((B, P) => B[1] - P[1])[0]) == null ? void 0 : $[0];
              j && (L = j);
              break;
            }
            case "initialPlacement":
              L = a;
              break;
          }
        if (o !== L)
          return {
            reset: {
              placement: L
            }
          };
      }
      return {};
    }
  };
};
function Xr(e, t) {
  return {
    top: e.top - t.height,
    right: e.right - t.width,
    bottom: e.bottom - t.height,
    left: e.left - t.width
  };
}
function qr(e) {
  return Hl.some((t) => e[t] >= 0);
}
const oc = function(e) {
  return e === void 0 && (e = {}), {
    name: "hide",
    options: e,
    async fn(t) {
      const {
        rects: n
      } = t, {
        strategy: r = "referenceHidden",
        ...o
      } = Ae(e, t);
      switch (r) {
        case "referenceHidden": {
          const s = await St(t, {
            ...o,
            elementContext: "reference"
          }), i = Xr(s, n.reference);
          return {
            data: {
              referenceHiddenOffsets: i,
              referenceHidden: qr(i)
            }
          };
        }
        case "escaped": {
          const s = await St(t, {
            ...o,
            altBoundary: !0
          }), i = Xr(s, n.floating);
          return {
            data: {
              escapedOffsets: i,
              escaped: qr(i)
            }
          };
        }
        default:
          return {};
      }
    }
  };
}, Do = /* @__PURE__ */ new Set(["left", "top"]);
async function sc(e, t) {
  const {
    placement: n,
    platform: r,
    elements: o
  } = e, s = await (r.isRTL == null ? void 0 : r.isRTL(o.floating)), i = ke(n), a = ht(n), l = Ee(n) === "y", c = Do.has(i) ? -1 : 1, u = s && l ? -1 : 1, f = Ae(t, e);
  let {
    mainAxis: v,
    crossAxis: g,
    alignmentAxis: b
  } = typeof f == "number" ? {
    mainAxis: f,
    crossAxis: 0,
    alignmentAxis: null
  } : {
    mainAxis: f.mainAxis || 0,
    crossAxis: f.crossAxis || 0,
    alignmentAxis: f.alignmentAxis
  };
  return a && typeof b == "number" && (g = a === "end" ? b * -1 : b), l ? {
    x: g * u,
    y: v * c
  } : {
    x: v * c,
    y: g * u
  };
}
const ic = function(e) {
  return e === void 0 && (e = 0), {
    name: "offset",
    options: e,
    async fn(t) {
      var n, r;
      const {
        x: o,
        y: s,
        placement: i,
        middlewareData: a
      } = t, l = await sc(t, e);
      return i === ((n = a.offset) == null ? void 0 : n.placement) && (r = a.arrow) != null && r.alignmentOffset ? {} : {
        x: o + l.x,
        y: s + l.y,
        data: {
          ...l,
          placement: i
        }
      };
    }
  };
}, ac = function(e) {
  return e === void 0 && (e = {}), {
    name: "shift",
    options: e,
    async fn(t) {
      const {
        x: n,
        y: r,
        placement: o
      } = t, {
        mainAxis: s = !0,
        crossAxis: i = !1,
        limiter: a = {
          fn: (w) => {
            let {
              x: m,
              y
            } = w;
            return {
              x: m,
              y
            };
          }
        },
        ...l
      } = Ae(e, t), c = {
        x: n,
        y: r
      }, u = await St(t, l), f = Ee(ke(o)), v = er(f);
      let g = c[v], b = c[f];
      if (s) {
        const w = v === "y" ? "top" : "left", m = v === "y" ? "bottom" : "right", y = g + u[w], x = g - u[m];
        g = kn(y, g, x);
      }
      if (i) {
        const w = f === "y" ? "top" : "left", m = f === "y" ? "bottom" : "right", y = b + u[w], x = b - u[m];
        b = kn(y, b, x);
      }
      const h = a.fn({
        ...t,
        [v]: g,
        [f]: b
      });
      return {
        ...h,
        data: {
          x: h.x - n,
          y: h.y - r,
          enabled: {
            [v]: s,
            [f]: i
          }
        }
      };
    }
  };
}, lc = function(e) {
  return e === void 0 && (e = {}), {
    options: e,
    fn(t) {
      const {
        x: n,
        y: r,
        placement: o,
        rects: s,
        middlewareData: i
      } = t, {
        offset: a = 0,
        mainAxis: l = !0,
        crossAxis: c = !0
      } = Ae(e, t), u = {
        x: n,
        y: r
      }, f = Ee(o), v = er(f);
      let g = u[v], b = u[f];
      const h = Ae(a, t), w = typeof h == "number" ? {
        mainAxis: h,
        crossAxis: 0
      } : {
        mainAxis: 0,
        crossAxis: 0,
        ...h
      };
      if (l) {
        const x = v === "y" ? "height" : "width", C = s.reference[v] - s.floating[x] + w.mainAxis, S = s.reference[v] + s.reference[x] - w.mainAxis;
        g < C ? g = C : g > S && (g = S);
      }
      if (c) {
        var m, y;
        const x = v === "y" ? "width" : "height", C = Do.has(ke(o)), S = s.reference[f] - s.floating[x] + (C && ((m = i.offset) == null ? void 0 : m[f]) || 0) + (C ? 0 : w.crossAxis), R = s.reference[f] + s.reference[x] + (C ? 0 : ((y = i.offset) == null ? void 0 : y[f]) || 0) - (C ? w.crossAxis : 0);
        b < S ? b = S : b > R && (b = R);
      }
      return {
        [v]: g,
        [f]: b
      };
    }
  };
}, cc = function(e) {
  return e === void 0 && (e = {}), {
    name: "size",
    options: e,
    async fn(t) {
      var n, r;
      const {
        placement: o,
        rects: s,
        platform: i,
        elements: a
      } = t, {
        apply: l = () => {
        },
        ...c
      } = Ae(e, t), u = await St(t, c), f = ke(o), v = ht(o), g = Ee(o) === "y", {
        width: b,
        height: h
      } = s.floating;
      let w, m;
      f === "top" || f === "bottom" ? (w = f, m = v === (await (i.isRTL == null ? void 0 : i.isRTL(a.floating)) ? "start" : "end") ? "left" : "right") : (m = f, w = v === "end" ? "top" : "bottom");
      const y = h - u.top - u.bottom, x = b - u.left - u.right, C = Fe(h - u[w], y), S = Fe(b - u[m], x), R = !t.middlewareData.shift;
      let N = C, k = S;
      if ((n = t.middlewareData.shift) != null && n.enabled.x && (k = x), (r = t.middlewareData.shift) != null && r.enabled.y && (N = y), R && !v) {
        const O = ge(u.left, 0), T = ge(u.right, 0), _ = ge(u.top, 0), $ = ge(u.bottom, 0);
        g ? k = b - 2 * (O !== 0 || T !== 0 ? O + T : ge(u.left, u.right)) : N = h - 2 * (_ !== 0 || $ !== 0 ? _ + $ : ge(u.top, u.bottom));
      }
      await l({
        ...t,
        availableWidth: k,
        availableHeight: N
      });
      const W = await i.getDimensions(a.floating);
      return b !== W.width || h !== W.height ? {
        reset: {
          rects: !0
        }
      } : {};
    }
  };
};
function nn() {
  return typeof window < "u";
}
function mt(e) {
  return Oo(e) ? (e.nodeName || "").toLowerCase() : "#document";
}
function ve(e) {
  var t;
  return (e == null || (t = e.ownerDocument) == null ? void 0 : t.defaultView) || window;
}
function Te(e) {
  var t;
  return (t = (Oo(e) ? e.ownerDocument : e.document) || window.document) == null ? void 0 : t.documentElement;
}
function Oo(e) {
  return nn() ? e instanceof Node || e instanceof ve(e).Node : !1;
}
function Ce(e) {
  return nn() ? e instanceof Element || e instanceof ve(e).Element : !1;
}
function Pe(e) {
  return nn() ? e instanceof HTMLElement || e instanceof ve(e).HTMLElement : !1;
}
function Zr(e) {
  return !nn() || typeof ShadowRoot > "u" ? !1 : e instanceof ShadowRoot || e instanceof ve(e).ShadowRoot;
}
const dc = /* @__PURE__ */ new Set(["inline", "contents"]);
function Pt(e) {
  const {
    overflow: t,
    overflowX: n,
    overflowY: r,
    display: o
  } = Se(e);
  return /auto|scroll|overlay|hidden|clip/.test(t + r + n) && !dc.has(o);
}
const uc = /* @__PURE__ */ new Set(["table", "td", "th"]);
function fc(e) {
  return uc.has(mt(e));
}
const hc = [":popover-open", ":modal"];
function rn(e) {
  return hc.some((t) => {
    try {
      return e.matches(t);
    } catch {
      return !1;
    }
  });
}
const mc = ["transform", "translate", "scale", "rotate", "perspective"], pc = ["transform", "translate", "scale", "rotate", "perspective", "filter"], gc = ["paint", "layout", "strict", "content"];
function rr(e) {
  const t = or(), n = Ce(e) ? Se(e) : e;
  return mc.some((r) => n[r] ? n[r] !== "none" : !1) || (n.containerType ? n.containerType !== "normal" : !1) || !t && (n.backdropFilter ? n.backdropFilter !== "none" : !1) || !t && (n.filter ? n.filter !== "none" : !1) || pc.some((r) => (n.willChange || "").includes(r)) || gc.some((r) => (n.contain || "").includes(r));
}
function vc(e) {
  let t = $e(e);
  for (; Pe(t) && !ct(t); ) {
    if (rr(t))
      return t;
    if (rn(t))
      return null;
    t = $e(t);
  }
  return null;
}
function or() {
  return typeof CSS > "u" || !CSS.supports ? !1 : CSS.supports("-webkit-backdrop-filter", "none");
}
const wc = /* @__PURE__ */ new Set(["html", "body", "#document"]);
function ct(e) {
  return wc.has(mt(e));
}
function Se(e) {
  return ve(e).getComputedStyle(e);
}
function on(e) {
  return Ce(e) ? {
    scrollLeft: e.scrollLeft,
    scrollTop: e.scrollTop
  } : {
    scrollLeft: e.scrollX,
    scrollTop: e.scrollY
  };
}
function $e(e) {
  if (mt(e) === "html")
    return e;
  const t = (
    // Step into the shadow DOM of the parent of a slotted node.
    e.assignedSlot || // DOM Element detected.
    e.parentNode || // ShadowRoot detected.
    Zr(e) && e.host || // Fallback.
    Te(e)
  );
  return Zr(t) ? t.host : t;
}
function _o(e) {
  const t = $e(e);
  return ct(t) ? e.ownerDocument ? e.ownerDocument.body : e.body : Pe(t) && Pt(t) ? t : _o(t);
}
function Rt(e, t, n) {
  var r;
  t === void 0 && (t = []), n === void 0 && (n = !0);
  const o = _o(e), s = o === ((r = e.ownerDocument) == null ? void 0 : r.body), i = ve(o);
  if (s) {
    const a = On(i);
    return t.concat(i, i.visualViewport || [], Pt(o) ? o : [], a && n ? Rt(a) : []);
  }
  return t.concat(o, Rt(o, [], n));
}
function On(e) {
  return e.parent && Object.getPrototypeOf(e.parent) ? e.frameElement : null;
}
function Lo(e) {
  const t = Se(e);
  let n = parseFloat(t.width) || 0, r = parseFloat(t.height) || 0;
  const o = Pe(e), s = o ? e.offsetWidth : n, i = o ? e.offsetHeight : r, a = Ht(n) !== s || Ht(r) !== i;
  return a && (n = s, r = i), {
    width: n,
    height: r,
    $: a
  };
}
function sr(e) {
  return Ce(e) ? e : e.contextElement;
}
function it(e) {
  const t = sr(e);
  if (!Pe(t))
    return Ne(1);
  const n = t.getBoundingClientRect(), {
    width: r,
    height: o,
    $: s
  } = Lo(t);
  let i = (s ? Ht(n.width) : n.width) / r, a = (s ? Ht(n.height) : n.height) / o;
  return (!i || !Number.isFinite(i)) && (i = 1), (!a || !Number.isFinite(a)) && (a = 1), {
    x: i,
    y: a
  };
}
const yc = /* @__PURE__ */ Ne(0);
function Fo(e) {
  const t = ve(e);
  return !or() || !t.visualViewport ? yc : {
    x: t.visualViewport.offsetLeft,
    y: t.visualViewport.offsetTop
  };
}
function bc(e, t, n) {
  return t === void 0 && (t = !1), !n || t && n !== ve(e) ? !1 : t;
}
function Xe(e, t, n, r) {
  t === void 0 && (t = !1), n === void 0 && (n = !1);
  const o = e.getBoundingClientRect(), s = sr(e);
  let i = Ne(1);
  t && (r ? Ce(r) && (i = it(r)) : i = it(e));
  const a = bc(s, n, r) ? Fo(s) : Ne(0);
  let l = (o.left + a.x) / i.x, c = (o.top + a.y) / i.y, u = o.width / i.x, f = o.height / i.y;
  if (s) {
    const v = ve(s), g = r && Ce(r) ? ve(r) : r;
    let b = v, h = On(b);
    for (; h && r && g !== b; ) {
      const w = it(h), m = h.getBoundingClientRect(), y = Se(h), x = m.left + (h.clientLeft + parseFloat(y.paddingLeft)) * w.x, C = m.top + (h.clientTop + parseFloat(y.paddingTop)) * w.y;
      l *= w.x, c *= w.y, u *= w.x, f *= w.y, l += x, c += C, b = ve(h), h = On(b);
    }
  }
  return Ut({
    width: u,
    height: f,
    x: l,
    y: c
  });
}
function ir(e, t) {
  const n = on(e).scrollLeft;
  return t ? t.left + n : Xe(Te(e)).left + n;
}
function $o(e, t, n) {
  n === void 0 && (n = !1);
  const r = e.getBoundingClientRect(), o = r.left + t.scrollLeft - (n ? 0 : (
    // RTL <body> scrollbar.
    ir(e, r)
  )), s = r.top + t.scrollTop;
  return {
    x: o,
    y: s
  };
}
function xc(e) {
  let {
    elements: t,
    rect: n,
    offsetParent: r,
    strategy: o
  } = e;
  const s = o === "fixed", i = Te(r), a = t ? rn(t.floating) : !1;
  if (r === i || a && s)
    return n;
  let l = {
    scrollLeft: 0,
    scrollTop: 0
  }, c = Ne(1);
  const u = Ne(0), f = Pe(r);
  if ((f || !f && !s) && ((mt(r) !== "body" || Pt(i)) && (l = on(r)), Pe(r))) {
    const g = Xe(r);
    c = it(r), u.x = g.x + r.clientLeft, u.y = g.y + r.clientTop;
  }
  const v = i && !f && !s ? $o(i, l, !0) : Ne(0);
  return {
    width: n.width * c.x,
    height: n.height * c.y,
    x: n.x * c.x - l.scrollLeft * c.x + u.x + v.x,
    y: n.y * c.y - l.scrollTop * c.y + u.y + v.y
  };
}
function Cc(e) {
  return Array.from(e.getClientRects());
}
function Sc(e) {
  const t = Te(e), n = on(e), r = e.ownerDocument.body, o = ge(t.scrollWidth, t.clientWidth, r.scrollWidth, r.clientWidth), s = ge(t.scrollHeight, t.clientHeight, r.scrollHeight, r.clientHeight);
  let i = -n.scrollLeft + ir(e);
  const a = -n.scrollTop;
  return Se(r).direction === "rtl" && (i += ge(t.clientWidth, r.clientWidth) - o), {
    width: o,
    height: s,
    x: i,
    y: a
  };
}
function Rc(e, t) {
  const n = ve(e), r = Te(e), o = n.visualViewport;
  let s = r.clientWidth, i = r.clientHeight, a = 0, l = 0;
  if (o) {
    s = o.width, i = o.height;
    const c = or();
    (!c || c && t === "fixed") && (a = o.offsetLeft, l = o.offsetTop);
  }
  return {
    width: s,
    height: i,
    x: a,
    y: l
  };
}
const Ic = /* @__PURE__ */ new Set(["absolute", "fixed"]);
function Ec(e, t) {
  const n = Xe(e, !0, t === "fixed"), r = n.top + e.clientTop, o = n.left + e.clientLeft, s = Pe(e) ? it(e) : Ne(1), i = e.clientWidth * s.x, a = e.clientHeight * s.y, l = o * s.x, c = r * s.y;
  return {
    width: i,
    height: a,
    x: l,
    y: c
  };
}
function Jr(e, t, n) {
  let r;
  if (t === "viewport")
    r = Rc(e, n);
  else if (t === "document")
    r = Sc(Te(e));
  else if (Ce(t))
    r = Ec(t, n);
  else {
    const o = Fo(e);
    r = {
      x: t.x - o.x,
      y: t.y - o.y,
      width: t.width,
      height: t.height
    };
  }
  return Ut(r);
}
function zo(e, t) {
  const n = $e(e);
  return n === t || !Ce(n) || ct(n) ? !1 : Se(n).position === "fixed" || zo(n, t);
}
function Nc(e, t) {
  const n = t.get(e);
  if (n)
    return n;
  let r = Rt(e, [], !1).filter((a) => Ce(a) && mt(a) !== "body"), o = null;
  const s = Se(e).position === "fixed";
  let i = s ? $e(e) : e;
  for (; Ce(i) && !ct(i); ) {
    const a = Se(i), l = rr(i);
    !l && a.position === "fixed" && (o = null), (s ? !l && !o : !l && a.position === "static" && !!o && Ic.has(o.position) || Pt(i) && !l && zo(e, i)) ? r = r.filter((u) => u !== i) : o = a, i = $e(i);
  }
  return t.set(e, r), r;
}
function Mc(e) {
  let {
    element: t,
    boundary: n,
    rootBoundary: r,
    strategy: o
  } = e;
  const i = [...n === "clippingAncestors" ? rn(t) ? [] : Nc(t, this._c) : [].concat(n), r], a = i[0], l = i.reduce((c, u) => {
    const f = Jr(t, u, o);
    return c.top = ge(f.top, c.top), c.right = Fe(f.right, c.right), c.bottom = Fe(f.bottom, c.bottom), c.left = ge(f.left, c.left), c;
  }, Jr(t, a, o));
  return {
    width: l.right - l.left,
    height: l.bottom - l.top,
    x: l.left,
    y: l.top
  };
}
function Pc(e) {
  const {
    width: t,
    height: n
  } = Lo(e);
  return {
    width: t,
    height: n
  };
}
function Tc(e, t, n) {
  const r = Pe(t), o = Te(t), s = n === "fixed", i = Xe(e, !0, s, t);
  let a = {
    scrollLeft: 0,
    scrollTop: 0
  };
  const l = Ne(0);
  function c() {
    l.x = ir(o);
  }
  if (r || !r && !s)
    if ((mt(t) !== "body" || Pt(o)) && (a = on(t)), r) {
      const g = Xe(t, !0, s, t);
      l.x = g.x + t.clientLeft, l.y = g.y + t.clientTop;
    } else o && c();
  s && !r && o && c();
  const u = o && !r && !s ? $o(o, a) : Ne(0), f = i.left + a.scrollLeft - l.x - u.x, v = i.top + a.scrollTop - l.y - u.y;
  return {
    x: f,
    y: v,
    width: i.width,
    height: i.height
  };
}
function bn(e) {
  return Se(e).position === "static";
}
function Qr(e, t) {
  if (!Pe(e) || Se(e).position === "fixed")
    return null;
  if (t)
    return t(e);
  let n = e.offsetParent;
  return Te(e) === n && (n = n.ownerDocument.body), n;
}
function Vo(e, t) {
  const n = ve(e);
  if (rn(e))
    return n;
  if (!Pe(e)) {
    let o = $e(e);
    for (; o && !ct(o); ) {
      if (Ce(o) && !bn(o))
        return o;
      o = $e(o);
    }
    return n;
  }
  let r = Qr(e, t);
  for (; r && fc(r) && bn(r); )
    r = Qr(r, t);
  return r && ct(r) && bn(r) && !rr(r) ? n : r || vc(e) || n;
}
const Ac = async function(e) {
  const t = this.getOffsetParent || Vo, n = this.getDimensions, r = await n(e.floating);
  return {
    reference: Tc(e.reference, await t(e.floating), e.strategy),
    floating: {
      x: 0,
      y: 0,
      width: r.width,
      height: r.height
    }
  };
};
function kc(e) {
  return Se(e).direction === "rtl";
}
const Dc = {
  convertOffsetParentRelativeRectToViewportRelativeRect: xc,
  getDocumentElement: Te,
  getClippingRect: Mc,
  getOffsetParent: Vo,
  getElementRects: Ac,
  getClientRects: Cc,
  getDimensions: Pc,
  getScale: it,
  isElement: Ce,
  isRTL: kc
};
function Bo(e, t) {
  return e.x === t.x && e.y === t.y && e.width === t.width && e.height === t.height;
}
function Oc(e, t) {
  let n = null, r;
  const o = Te(e);
  function s() {
    var a;
    clearTimeout(r), (a = n) == null || a.disconnect(), n = null;
  }
  function i(a, l) {
    a === void 0 && (a = !1), l === void 0 && (l = 1), s();
    const c = e.getBoundingClientRect(), {
      left: u,
      top: f,
      width: v,
      height: g
    } = c;
    if (a || t(), !v || !g)
      return;
    const b = Dt(f), h = Dt(o.clientWidth - (u + v)), w = Dt(o.clientHeight - (f + g)), m = Dt(u), x = {
      rootMargin: -b + "px " + -h + "px " + -w + "px " + -m + "px",
      threshold: ge(0, Fe(1, l)) || 1
    };
    let C = !0;
    function S(R) {
      const N = R[0].intersectionRatio;
      if (N !== l) {
        if (!C)
          return i();
        N ? i(!1, N) : r = setTimeout(() => {
          i(!1, 1e-7);
        }, 1e3);
      }
      N === 1 && !Bo(c, e.getBoundingClientRect()) && i(), C = !1;
    }
    try {
      n = new IntersectionObserver(S, {
        ...x,
        // Handle <iframe>s
        root: o.ownerDocument
      });
    } catch {
      n = new IntersectionObserver(S, x);
    }
    n.observe(e);
  }
  return i(!0), s;
}
function _c(e, t, n, r) {
  r === void 0 && (r = {});
  const {
    ancestorScroll: o = !0,
    ancestorResize: s = !0,
    elementResize: i = typeof ResizeObserver == "function",
    layoutShift: a = typeof IntersectionObserver == "function",
    animationFrame: l = !1
  } = r, c = sr(e), u = o || s ? [...c ? Rt(c) : [], ...Rt(t)] : [];
  u.forEach((m) => {
    o && m.addEventListener("scroll", n, {
      passive: !0
    }), s && m.addEventListener("resize", n);
  });
  const f = c && a ? Oc(c, n) : null;
  let v = -1, g = null;
  i && (g = new ResizeObserver((m) => {
    let [y] = m;
    y && y.target === c && g && (g.unobserve(t), cancelAnimationFrame(v), v = requestAnimationFrame(() => {
      var x;
      (x = g) == null || x.observe(t);
    })), n();
  }), c && !l && g.observe(c), g.observe(t));
  let b, h = l ? Xe(e) : null;
  l && w();
  function w() {
    const m = Xe(e);
    h && !Bo(h, m) && n(), h = m, b = requestAnimationFrame(w);
  }
  return n(), () => {
    var m;
    u.forEach((y) => {
      o && y.removeEventListener("scroll", n), s && y.removeEventListener("resize", n);
    }), f == null || f(), (m = g) == null || m.disconnect(), g = null, l && cancelAnimationFrame(b);
  };
}
const Lc = ic, Fc = ac, $c = rc, zc = cc, Vc = oc, eo = nc, Bc = lc, Wc = (e, t, n) => {
  const r = /* @__PURE__ */ new Map(), o = {
    platform: Dc,
    ...n
  }, s = {
    ...o.platform,
    _c: r
  };
  return tc(e, t, {
    ...o,
    platform: s
  });
};
var Kc = typeof document < "u", Hc = function() {
}, Vt = Kc ? Ca : Hc;
function jt(e, t) {
  if (e === t)
    return !0;
  if (typeof e != typeof t)
    return !1;
  if (typeof e == "function" && e.toString() === t.toString())
    return !0;
  let n, r, o;
  if (e && t && typeof e == "object") {
    if (Array.isArray(e)) {
      if (n = e.length, n !== t.length) return !1;
      for (r = n; r-- !== 0; )
        if (!jt(e[r], t[r]))
          return !1;
      return !0;
    }
    if (o = Object.keys(e), n = o.length, n !== Object.keys(t).length)
      return !1;
    for (r = n; r-- !== 0; )
      if (!{}.hasOwnProperty.call(t, o[r]))
        return !1;
    for (r = n; r-- !== 0; ) {
      const s = o[r];
      if (!(s === "_owner" && e.$$typeof) && !jt(e[s], t[s]))
        return !1;
    }
    return !0;
  }
  return e !== e && t !== t;
}
function Wo(e) {
  return typeof window > "u" ? 1 : (e.ownerDocument.defaultView || window).devicePixelRatio || 1;
}
function to(e, t) {
  const n = Wo(e);
  return Math.round(t * n) / n;
}
function xn(e) {
  const t = d.useRef(e);
  return Vt(() => {
    t.current = e;
  }), t;
}
function Gc(e) {
  e === void 0 && (e = {});
  const {
    placement: t = "bottom",
    strategy: n = "absolute",
    middleware: r = [],
    platform: o,
    elements: {
      reference: s,
      floating: i
    } = {},
    transform: a = !0,
    whileElementsMounted: l,
    open: c
  } = e, [u, f] = d.useState({
    x: 0,
    y: 0,
    strategy: n,
    placement: t,
    middlewareData: {},
    isPositioned: !1
  }), [v, g] = d.useState(r);
  jt(v, r) || g(r);
  const [b, h] = d.useState(null), [w, m] = d.useState(null), y = d.useCallback((B) => {
    B !== R.current && (R.current = B, h(B));
  }, []), x = d.useCallback((B) => {
    B !== N.current && (N.current = B, m(B));
  }, []), C = s || b, S = i || w, R = d.useRef(null), N = d.useRef(null), k = d.useRef(u), W = l != null, O = xn(l), T = xn(o), _ = xn(c), $ = d.useCallback(() => {
    if (!R.current || !N.current)
      return;
    const B = {
      placement: t,
      strategy: n,
      middleware: v
    };
    T.current && (B.platform = T.current), Wc(R.current, N.current, B).then((P) => {
      const Z = {
        ...P,
        // The floating element's position may be recomputed while it's closed
        // but still mounted (such as when transitioning out). To ensure
        // `isPositioned` will be `false` initially on the next open, avoid
        // setting it to `true` when `open === false` (must be specified).
        isPositioned: _.current !== !1
      };
      A.current && !jt(k.current, Z) && (k.current = Z, Zt.flushSync(() => {
        f(Z);
      }));
    });
  }, [v, t, n, T, _]);
  Vt(() => {
    c === !1 && k.current.isPositioned && (k.current.isPositioned = !1, f((B) => ({
      ...B,
      isPositioned: !1
    })));
  }, [c]);
  const A = d.useRef(!1);
  Vt(() => (A.current = !0, () => {
    A.current = !1;
  }), []), Vt(() => {
    if (C && (R.current = C), S && (N.current = S), C && S) {
      if (O.current)
        return O.current(C, S, $);
      $();
    }
  }, [C, S, $, O, W]);
  const H = d.useMemo(() => ({
    reference: R,
    floating: N,
    setReference: y,
    setFloating: x
  }), [y, x]), L = d.useMemo(() => ({
    reference: C,
    floating: S
  }), [C, S]), j = d.useMemo(() => {
    const B = {
      position: n,
      left: 0,
      top: 0
    };
    if (!L.floating)
      return B;
    const P = to(L.floating, u.x), Z = to(L.floating, u.y);
    return a ? {
      ...B,
      transform: "translate(" + P + "px, " + Z + "px)",
      ...Wo(L.floating) >= 1.5 && {
        willChange: "transform"
      }
    } : {
      position: n,
      left: P,
      top: Z
    };
  }, [n, a, L.floating, u.x, u.y]);
  return d.useMemo(() => ({
    ...u,
    update: $,
    refs: H,
    elements: L,
    floatingStyles: j
  }), [u, $, H, L, j]);
}
const Uc = (e) => {
  function t(n) {
    return {}.hasOwnProperty.call(n, "current");
  }
  return {
    name: "arrow",
    options: e,
    fn(n) {
      const {
        element: r,
        padding: o
      } = typeof e == "function" ? e(n) : e;
      return r && t(r) ? r.current != null ? eo({
        element: r.current,
        padding: o
      }).fn(n) : {} : r ? eo({
        element: r,
        padding: o
      }).fn(n) : {};
    }
  };
}, jc = (e, t) => ({
  ...Lc(e),
  options: [e, t]
}), Yc = (e, t) => ({
  ...Fc(e),
  options: [e, t]
}), Xc = (e, t) => ({
  ...Bc(e),
  options: [e, t]
}), qc = (e, t) => ({
  ...$c(e),
  options: [e, t]
}), Zc = (e, t) => ({
  ...zc(e),
  options: [e, t]
}), Jc = (e, t) => ({
  ...Vc(e),
  options: [e, t]
}), Qc = (e, t) => ({
  ...Uc(e),
  options: [e, t]
});
var ed = "Arrow", Ko = d.forwardRef((e, t) => {
  const { children: n, width: r = 10, height: o = 5, ...s } = e;
  return /* @__PURE__ */ p(
    se.svg,
    {
      ...s,
      ref: t,
      width: r,
      height: o,
      viewBox: "0 0 30 10",
      preserveAspectRatio: "none",
      children: e.asChild ? n : /* @__PURE__ */ p("polygon", { points: "0,0 30,0 15,10" })
    }
  );
});
Ko.displayName = ed;
var td = Ko;
function Ho(e) {
  const [t, n] = d.useState(void 0);
  return fe(() => {
    if (e) {
      n({ width: e.offsetWidth, height: e.offsetHeight });
      const r = new ResizeObserver((o) => {
        if (!Array.isArray(o) || !o.length)
          return;
        const s = o[0];
        let i, a;
        if ("borderBoxSize" in s) {
          const l = s.borderBoxSize, c = Array.isArray(l) ? l[0] : l;
          i = c.inlineSize, a = c.blockSize;
        } else
          i = e.offsetWidth, a = e.offsetHeight;
        n({ width: i, height: a });
      });
      return r.observe(e, { box: "border-box" }), () => r.unobserve(e);
    } else
      n(void 0);
  }, [e]), t;
}
var ar = "Popper", [Go, pt] = Ve(ar), [nd, Uo] = Go(ar), jo = (e) => {
  const { __scopePopper: t, children: n } = e, [r, o] = d.useState(null);
  return /* @__PURE__ */ p(nd, { scope: t, anchor: r, onAnchorChange: o, children: n });
};
jo.displayName = ar;
var Yo = "PopperAnchor", Xo = d.forwardRef(
  (e, t) => {
    const { __scopePopper: n, virtualRef: r, ...o } = e, s = Uo(Yo, n), i = d.useRef(null), a = ie(t, i);
    return d.useEffect(() => {
      s.onAnchorChange((r == null ? void 0 : r.current) || i.current);
    }), r ? null : /* @__PURE__ */ p(se.div, { ...o, ref: a });
  }
);
Xo.displayName = Yo;
var lr = "PopperContent", [rd, od] = Go(lr), qo = d.forwardRef(
  (e, t) => {
    var I, J, ne, X, M, z;
    const {
      __scopePopper: n,
      side: r = "bottom",
      sideOffset: o = 0,
      align: s = "center",
      alignOffset: i = 0,
      arrowPadding: a = 0,
      avoidCollisions: l = !0,
      collisionBoundary: c = [],
      collisionPadding: u = 0,
      sticky: f = "partial",
      hideWhenDetached: v = !1,
      updatePositionStrategy: g = "optimized",
      onPlaced: b,
      ...h
    } = e, w = Uo(lr, n), [m, y] = d.useState(null), x = ie(t, (Q) => y(Q)), [C, S] = d.useState(null), R = Ho(C), N = (R == null ? void 0 : R.width) ?? 0, k = (R == null ? void 0 : R.height) ?? 0, W = r + (s !== "center" ? "-" + s : ""), O = typeof u == "number" ? u : { top: 0, right: 0, bottom: 0, left: 0, ...u }, T = Array.isArray(c) ? c : [c], _ = T.length > 0, $ = {
      padding: O,
      boundary: T.filter(id),
      // with `strategy: 'fixed'`, this is the only way to get it to respect boundaries
      altBoundary: _
    }, { refs: A, floatingStyles: H, placement: L, isPositioned: j, middlewareData: B } = Gc({
      // default to `fixed` strategy so users don't have to pick and we also avoid focus scroll issues
      strategy: "fixed",
      placement: W,
      whileElementsMounted: (...Q) => _c(...Q, {
        animationFrame: g === "always"
      }),
      elements: {
        reference: w.anchor
      },
      middleware: [
        jc({ mainAxis: o + k, alignmentAxis: i }),
        l && Yc({
          mainAxis: !0,
          crossAxis: !1,
          limiter: f === "partial" ? Xc() : void 0,
          ...$
        }),
        l && qc({ ...$ }),
        Zc({
          ...$,
          apply: ({ elements: Q, rects: re, availableWidth: oe, availableHeight: de }) => {
            const { width: ue, height: me } = re.reference, be = Q.floating.style;
            be.setProperty("--radix-popper-available-width", `${oe}px`), be.setProperty("--radix-popper-available-height", `${de}px`), be.setProperty("--radix-popper-anchor-width", `${ue}px`), be.setProperty("--radix-popper-anchor-height", `${me}px`);
          }
        }),
        C && Qc({ element: C, padding: a }),
        ad({ arrowWidth: N, arrowHeight: k }),
        v && Jc({ strategy: "referenceHidden", ...$ })
      ]
    }), [P, Z] = Qo(L), D = Me(b);
    fe(() => {
      j && (D == null || D());
    }, [j, D]);
    const U = (I = B.arrow) == null ? void 0 : I.x, F = (J = B.arrow) == null ? void 0 : J.y, K = ((ne = B.arrow) == null ? void 0 : ne.centerOffset) !== 0, [Y, ee] = d.useState();
    return fe(() => {
      m && ee(window.getComputedStyle(m).zIndex);
    }, [m]), /* @__PURE__ */ p(
      "div",
      {
        ref: A.setFloating,
        "data-radix-popper-content-wrapper": "",
        style: {
          ...H,
          transform: j ? H.transform : "translate(0, -200%)",
          // keep off the page when measuring
          minWidth: "max-content",
          zIndex: Y,
          "--radix-popper-transform-origin": [
            (X = B.transformOrigin) == null ? void 0 : X.x,
            (M = B.transformOrigin) == null ? void 0 : M.y
          ].join(" "),
          // hide the content if using the hide middleware and should be hidden
          // set visibility to hidden and disable pointer events so the UI behaves
          // as if the PopperContent isn't there at all
          ...((z = B.hide) == null ? void 0 : z.referenceHidden) && {
            visibility: "hidden",
            pointerEvents: "none"
          }
        },
        dir: e.dir,
        children: /* @__PURE__ */ p(
          rd,
          {
            scope: n,
            placedSide: P,
            onArrowChange: S,
            arrowX: U,
            arrowY: F,
            shouldHideArrow: K,
            children: /* @__PURE__ */ p(
              se.div,
              {
                "data-side": P,
                "data-align": Z,
                ...h,
                ref: x,
                style: {
                  ...h.style,
                  // if the PopperContent hasn't been placed yet (not all measurements done)
                  // we prevent animations so that users's animation don't kick in too early referring wrong sides
                  animation: j ? void 0 : "none"
                }
              }
            )
          }
        )
      }
    );
  }
);
qo.displayName = lr;
var Zo = "PopperArrow", sd = {
  top: "bottom",
  right: "left",
  bottom: "top",
  left: "right"
}, Jo = d.forwardRef(function(t, n) {
  const { __scopePopper: r, ...o } = t, s = od(Zo, r), i = sd[s.placedSide];
  return (
    // we have to use an extra wrapper because `ResizeObserver` (used by `useSize`)
    // doesn't report size as we'd expect on SVG elements.
    // it reports their bounding box which is effectively the largest path inside the SVG.
    /* @__PURE__ */ p(
      "span",
      {
        ref: s.onArrowChange,
        style: {
          position: "absolute",
          left: s.arrowX,
          top: s.arrowY,
          [i]: 0,
          transformOrigin: {
            top: "",
            right: "0 0",
            bottom: "center 0",
            left: "100% 0"
          }[s.placedSide],
          transform: {
            top: "translateY(100%)",
            right: "translateY(50%) rotate(90deg) translateX(-50%)",
            bottom: "rotate(180deg)",
            left: "translateY(50%) rotate(-90deg) translateX(50%)"
          }[s.placedSide],
          visibility: s.shouldHideArrow ? "hidden" : void 0
        },
        children: /* @__PURE__ */ p(
          td,
          {
            ...o,
            ref: n,
            style: {
              ...o.style,
              // ensures the element can be measured correctly (mostly for if SVG)
              display: "block"
            }
          }
        )
      }
    )
  );
});
Jo.displayName = Zo;
function id(e) {
  return e !== null;
}
var ad = (e) => ({
  name: "transformOrigin",
  options: e,
  fn(t) {
    var w, m, y;
    const { placement: n, rects: r, middlewareData: o } = t, i = ((w = o.arrow) == null ? void 0 : w.centerOffset) !== 0, a = i ? 0 : e.arrowWidth, l = i ? 0 : e.arrowHeight, [c, u] = Qo(n), f = { start: "0%", center: "50%", end: "100%" }[u], v = (((m = o.arrow) == null ? void 0 : m.x) ?? 0) + a / 2, g = (((y = o.arrow) == null ? void 0 : y.y) ?? 0) + l / 2;
    let b = "", h = "";
    return c === "bottom" ? (b = i ? f : `${v}px`, h = `${-l}px`) : c === "top" ? (b = i ? f : `${v}px`, h = `${r.floating.height + l}px`) : c === "right" ? (b = `${-l}px`, h = i ? f : `${g}px`) : c === "left" && (b = `${r.floating.width + l}px`, h = i ? f : `${g}px`), { data: { x: b, y: h } };
  }
});
function Qo(e) {
  const [t, n = "center"] = e.split("-");
  return [t, n];
}
var cr = jo, dr = Xo, ur = qo, fr = Jo, ld = "Portal", hr = d.forwardRef((e, t) => {
  var a;
  const { container: n, ...r } = e, [o, s] = d.useState(!1);
  fe(() => s(!0), []);
  const i = n || o && ((a = globalThis == null ? void 0 : globalThis.document) == null ? void 0 : a.body);
  return i ? Sa.createPortal(/* @__PURE__ */ p(se.div, { ...r, ref: t }), i) : null;
});
hr.displayName = ld;
var cd = d[" useInsertionEffect ".trim().toString()] || fe;
function dt({
  prop: e,
  defaultProp: t,
  onChange: n = () => {
  },
  caller: r
}) {
  const [o, s, i] = dd({
    defaultProp: t,
    onChange: n
  }), a = e !== void 0, l = a ? e : o;
  {
    const u = d.useRef(e !== void 0);
    d.useEffect(() => {
      const f = u.current;
      f !== a && console.warn(
        `${r} is changing from ${f ? "controlled" : "uncontrolled"} to ${a ? "controlled" : "uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`
      ), u.current = a;
    }, [a, r]);
  }
  const c = d.useCallback(
    (u) => {
      var f;
      if (a) {
        const v = ud(u) ? u(e) : u;
        v !== e && ((f = i.current) == null || f.call(i, v));
      } else
        s(u);
    },
    [a, e, s, i]
  );
  return [l, c];
}
function dd({
  defaultProp: e,
  onChange: t
}) {
  const [n, r] = d.useState(e), o = d.useRef(n), s = d.useRef(t);
  return cd(() => {
    s.current = t;
  }, [t]), d.useEffect(() => {
    var i;
    o.current !== n && ((i = s.current) == null || i.call(s, n), o.current = n);
  }, [n, o]), [n, r, s];
}
function ud(e) {
  return typeof e == "function";
}
function es(e) {
  const t = d.useRef({ value: e, previous: e });
  return d.useMemo(() => (t.current.value !== e && (t.current.previous = t.current.value, t.current.value = e), t.current.previous), [e]);
}
var ts = Object.freeze({
  // See: https://github.com/twbs/bootstrap/blob/main/scss/mixins/_visually-hidden.scss
  position: "absolute",
  border: 0,
  width: 1,
  height: 1,
  padding: 0,
  margin: -1,
  overflow: "hidden",
  clip: "rect(0, 0, 0, 0)",
  whiteSpace: "nowrap",
  wordWrap: "normal"
}), fd = "VisuallyHidden", ns = d.forwardRef(
  (e, t) => /* @__PURE__ */ p(
    se.span,
    {
      ...e,
      ref: t,
      style: { ...ts, ...e.style }
    }
  )
);
ns.displayName = fd;
var hd = ns, md = function(e) {
  if (typeof document > "u")
    return null;
  var t = Array.isArray(e) ? e[0] : e;
  return t.ownerDocument.body;
}, rt = /* @__PURE__ */ new WeakMap(), Ot = /* @__PURE__ */ new WeakMap(), _t = {}, Cn = 0, rs = function(e) {
  return e && (e.host || rs(e.parentNode));
}, pd = function(e, t) {
  return t.map(function(n) {
    if (e.contains(n))
      return n;
    var r = rs(n);
    return r && e.contains(r) ? r : (console.error("aria-hidden", n, "in not contained inside", e, ". Doing nothing"), null);
  }).filter(function(n) {
    return !!n;
  });
}, gd = function(e, t, n, r) {
  var o = pd(t, Array.isArray(e) ? e : [e]);
  _t[n] || (_t[n] = /* @__PURE__ */ new WeakMap());
  var s = _t[n], i = [], a = /* @__PURE__ */ new Set(), l = new Set(o), c = function(f) {
    !f || a.has(f) || (a.add(f), c(f.parentNode));
  };
  o.forEach(c);
  var u = function(f) {
    !f || l.has(f) || Array.prototype.forEach.call(f.children, function(v) {
      if (a.has(v))
        u(v);
      else
        try {
          var g = v.getAttribute(r), b = g !== null && g !== "false", h = (rt.get(v) || 0) + 1, w = (s.get(v) || 0) + 1;
          rt.set(v, h), s.set(v, w), i.push(v), h === 1 && b && Ot.set(v, !0), w === 1 && v.setAttribute(n, "true"), b || v.setAttribute(r, "true");
        } catch (m) {
          console.error("aria-hidden: cannot operate on ", v, m);
        }
    });
  };
  return u(t), a.clear(), Cn++, function() {
    i.forEach(function(f) {
      var v = rt.get(f) - 1, g = s.get(f) - 1;
      rt.set(f, v), s.set(f, g), v || (Ot.has(f) || f.removeAttribute(r), Ot.delete(f)), g || f.removeAttribute(n);
    }), Cn--, Cn || (rt = /* @__PURE__ */ new WeakMap(), rt = /* @__PURE__ */ new WeakMap(), Ot = /* @__PURE__ */ new WeakMap(), _t = {});
  };
}, os = function(e, t, n) {
  n === void 0 && (n = "data-aria-hidden");
  var r = Array.from(Array.isArray(e) ? e : [e]), o = md(e);
  return o ? (r.push.apply(r, Array.from(o.querySelectorAll("[aria-live], script"))), gd(r, o, n, "aria-hidden")) : function() {
    return null;
  };
}, Re = function() {
  return Re = Object.assign || function(t) {
    for (var n, r = 1, o = arguments.length; r < o; r++) {
      n = arguments[r];
      for (var s in n) Object.prototype.hasOwnProperty.call(n, s) && (t[s] = n[s]);
    }
    return t;
  }, Re.apply(this, arguments);
};
function ss(e, t) {
  var n = {};
  for (var r in e) Object.prototype.hasOwnProperty.call(e, r) && t.indexOf(r) < 0 && (n[r] = e[r]);
  if (e != null && typeof Object.getOwnPropertySymbols == "function")
    for (var o = 0, r = Object.getOwnPropertySymbols(e); o < r.length; o++)
      t.indexOf(r[o]) < 0 && Object.prototype.propertyIsEnumerable.call(e, r[o]) && (n[r[o]] = e[r[o]]);
  return n;
}
function vd(e, t, n) {
  if (n || arguments.length === 2) for (var r = 0, o = t.length, s; r < o; r++)
    (s || !(r in t)) && (s || (s = Array.prototype.slice.call(t, 0, r)), s[r] = t[r]);
  return e.concat(s || Array.prototype.slice.call(t));
}
var Bt = "right-scroll-bar-position", Wt = "width-before-scroll-bar", wd = "with-scroll-bars-hidden", yd = "--removed-body-scroll-bar-size";
function Sn(e, t) {
  return typeof e == "function" ? e(t) : e && (e.current = t), e;
}
function bd(e, t) {
  var n = ae(function() {
    return {
      // value
      value: e,
      // last callback
      callback: t,
      // "memoized" public interface
      facade: {
        get current() {
          return n.value;
        },
        set current(r) {
          var o = n.value;
          o !== r && (n.value = r, n.callback(r, o));
        }
      }
    };
  })[0];
  return n.callback = t, n.facade;
}
var xd = typeof window < "u" ? d.useLayoutEffect : d.useEffect, no = /* @__PURE__ */ new WeakMap();
function Cd(e, t) {
  var n = bd(null, function(r) {
    return e.forEach(function(o) {
      return Sn(o, r);
    });
  });
  return xd(function() {
    var r = no.get(n);
    if (r) {
      var o = new Set(r), s = new Set(e), i = n.current;
      o.forEach(function(a) {
        s.has(a) || Sn(a, null);
      }), s.forEach(function(a) {
        o.has(a) || Sn(a, i);
      });
    }
    no.set(n, e);
  }, [e]), n;
}
function Sd(e) {
  return e;
}
function Rd(e, t) {
  t === void 0 && (t = Sd);
  var n = [], r = !1, o = {
    read: function() {
      if (r)
        throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");
      return n.length ? n[n.length - 1] : e;
    },
    useMedium: function(s) {
      var i = t(s, r);
      return n.push(i), function() {
        n = n.filter(function(a) {
          return a !== i;
        });
      };
    },
    assignSyncMedium: function(s) {
      for (r = !0; n.length; ) {
        var i = n;
        n = [], i.forEach(s);
      }
      n = {
        push: function(a) {
          return s(a);
        },
        filter: function() {
          return n;
        }
      };
    },
    assignMedium: function(s) {
      r = !0;
      var i = [];
      if (n.length) {
        var a = n;
        n = [], a.forEach(s), i = n;
      }
      var l = function() {
        var u = i;
        i = [], u.forEach(s);
      }, c = function() {
        return Promise.resolve().then(l);
      };
      c(), n = {
        push: function(u) {
          i.push(u), c();
        },
        filter: function(u) {
          return i = i.filter(u), n;
        }
      };
    }
  };
  return o;
}
function Id(e) {
  e === void 0 && (e = {});
  var t = Rd(null);
  return t.options = Re({ async: !0, ssr: !1 }, e), t;
}
var is = function(e) {
  var t = e.sideCar, n = ss(e, ["sideCar"]);
  if (!t)
    throw new Error("Sidecar: please provide `sideCar` property to import the right car");
  var r = t.read();
  if (!r)
    throw new Error("Sidecar medium not found");
  return d.createElement(r, Re({}, n));
};
is.isSideCarExport = !0;
function Ed(e, t) {
  return e.useMedium(t), is;
}
var as = Id(), Rn = function() {
}, sn = d.forwardRef(function(e, t) {
  var n = d.useRef(null), r = d.useState({
    onScrollCapture: Rn,
    onWheelCapture: Rn,
    onTouchMoveCapture: Rn
  }), o = r[0], s = r[1], i = e.forwardProps, a = e.children, l = e.className, c = e.removeScrollBar, u = e.enabled, f = e.shards, v = e.sideCar, g = e.noRelative, b = e.noIsolation, h = e.inert, w = e.allowPinchZoom, m = e.as, y = m === void 0 ? "div" : m, x = e.gapMode, C = ss(e, ["forwardProps", "children", "className", "removeScrollBar", "enabled", "shards", "sideCar", "noRelative", "noIsolation", "inert", "allowPinchZoom", "as", "gapMode"]), S = v, R = Cd([n, t]), N = Re(Re({}, C), o);
  return d.createElement(
    d.Fragment,
    null,
    u && d.createElement(S, { sideCar: as, removeScrollBar: c, shards: f, noRelative: g, noIsolation: b, inert: h, setCallbacks: s, allowPinchZoom: !!w, lockRef: n, gapMode: x }),
    i ? d.cloneElement(d.Children.only(a), Re(Re({}, N), { ref: R })) : d.createElement(y, Re({}, N, { className: l, ref: R }), a)
  );
});
sn.defaultProps = {
  enabled: !0,
  removeScrollBar: !0,
  inert: !1
};
sn.classNames = {
  fullWidth: Wt,
  zeroRight: Bt
};
var Nd = function() {
  if (typeof __webpack_nonce__ < "u")
    return __webpack_nonce__;
};
function Md() {
  if (!document)
    return null;
  var e = document.createElement("style");
  e.type = "text/css";
  var t = Nd();
  return t && e.setAttribute("nonce", t), e;
}
function Pd(e, t) {
  e.styleSheet ? e.styleSheet.cssText = t : e.appendChild(document.createTextNode(t));
}
function Td(e) {
  var t = document.head || document.getElementsByTagName("head")[0];
  t.appendChild(e);
}
var Ad = function() {
  var e = 0, t = null;
  return {
    add: function(n) {
      e == 0 && (t = Md()) && (Pd(t, n), Td(t)), e++;
    },
    remove: function() {
      e--, !e && t && (t.parentNode && t.parentNode.removeChild(t), t = null);
    }
  };
}, kd = function() {
  var e = Ad();
  return function(t, n) {
    d.useEffect(function() {
      return e.add(t), function() {
        e.remove();
      };
    }, [t && n]);
  };
}, ls = function() {
  var e = kd(), t = function(n) {
    var r = n.styles, o = n.dynamic;
    return e(r, o), null;
  };
  return t;
}, Dd = {
  left: 0,
  top: 0,
  right: 0,
  gap: 0
}, In = function(e) {
  return parseInt(e || "", 10) || 0;
}, Od = function(e) {
  var t = window.getComputedStyle(document.body), n = t[e === "padding" ? "paddingLeft" : "marginLeft"], r = t[e === "padding" ? "paddingTop" : "marginTop"], o = t[e === "padding" ? "paddingRight" : "marginRight"];
  return [In(n), In(r), In(o)];
}, _d = function(e) {
  if (e === void 0 && (e = "margin"), typeof window > "u")
    return Dd;
  var t = Od(e), n = document.documentElement.clientWidth, r = window.innerWidth;
  return {
    left: t[0],
    top: t[1],
    right: t[2],
    gap: Math.max(0, r - n + t[2] - t[0])
  };
}, Ld = ls(), at = "data-scroll-locked", Fd = function(e, t, n, r) {
  var o = e.left, s = e.top, i = e.right, a = e.gap;
  return n === void 0 && (n = "margin"), `
  .`.concat(wd, ` {
   overflow: hidden `).concat(r, `;
   padding-right: `).concat(a, "px ").concat(r, `;
  }
  body[`).concat(at, `] {
    overflow: hidden `).concat(r, `;
    overscroll-behavior: contain;
    `).concat([
    t && "position: relative ".concat(r, ";"),
    n === "margin" && `
    padding-left: `.concat(o, `px;
    padding-top: `).concat(s, `px;
    padding-right: `).concat(i, `px;
    margin-left:0;
    margin-top:0;
    margin-right: `).concat(a, "px ").concat(r, `;
    `),
    n === "padding" && "padding-right: ".concat(a, "px ").concat(r, ";")
  ].filter(Boolean).join(""), `
  }
  
  .`).concat(Bt, ` {
    right: `).concat(a, "px ").concat(r, `;
  }
  
  .`).concat(Wt, ` {
    margin-right: `).concat(a, "px ").concat(r, `;
  }
  
  .`).concat(Bt, " .").concat(Bt, ` {
    right: 0 `).concat(r, `;
  }
  
  .`).concat(Wt, " .").concat(Wt, ` {
    margin-right: 0 `).concat(r, `;
  }
  
  body[`).concat(at, `] {
    `).concat(yd, ": ").concat(a, `px;
  }
`);
}, ro = function() {
  var e = parseInt(document.body.getAttribute(at) || "0", 10);
  return isFinite(e) ? e : 0;
}, $d = function() {
  d.useEffect(function() {
    return document.body.setAttribute(at, (ro() + 1).toString()), function() {
      var e = ro() - 1;
      e <= 0 ? document.body.removeAttribute(at) : document.body.setAttribute(at, e.toString());
    };
  }, []);
}, zd = function(e) {
  var t = e.noRelative, n = e.noImportant, r = e.gapMode, o = r === void 0 ? "margin" : r;
  $d();
  var s = d.useMemo(function() {
    return _d(o);
  }, [o]);
  return d.createElement(Ld, { styles: Fd(s, !t, o, n ? "" : "!important") });
}, _n = !1;
if (typeof window < "u")
  try {
    var Lt = Object.defineProperty({}, "passive", {
      get: function() {
        return _n = !0, !0;
      }
    });
    window.addEventListener("test", Lt, Lt), window.removeEventListener("test", Lt, Lt);
  } catch {
    _n = !1;
  }
var ot = _n ? { passive: !1 } : !1, Vd = function(e) {
  return e.tagName === "TEXTAREA";
}, cs = function(e, t) {
  if (!(e instanceof Element))
    return !1;
  var n = window.getComputedStyle(e);
  return (
    // not-not-scrollable
    n[t] !== "hidden" && // contains scroll inside self
    !(n.overflowY === n.overflowX && !Vd(e) && n[t] === "visible")
  );
}, Bd = function(e) {
  return cs(e, "overflowY");
}, Wd = function(e) {
  return cs(e, "overflowX");
}, oo = function(e, t) {
  var n = t.ownerDocument, r = t;
  do {
    typeof ShadowRoot < "u" && r instanceof ShadowRoot && (r = r.host);
    var o = ds(e, r);
    if (o) {
      var s = us(e, r), i = s[1], a = s[2];
      if (i > a)
        return !0;
    }
    r = r.parentNode;
  } while (r && r !== n.body);
  return !1;
}, Kd = function(e) {
  var t = e.scrollTop, n = e.scrollHeight, r = e.clientHeight;
  return [
    t,
    n,
    r
  ];
}, Hd = function(e) {
  var t = e.scrollLeft, n = e.scrollWidth, r = e.clientWidth;
  return [
    t,
    n,
    r
  ];
}, ds = function(e, t) {
  return e === "v" ? Bd(t) : Wd(t);
}, us = function(e, t) {
  return e === "v" ? Kd(t) : Hd(t);
}, Gd = function(e, t) {
  return e === "h" && t === "rtl" ? -1 : 1;
}, Ud = function(e, t, n, r, o) {
  var s = Gd(e, window.getComputedStyle(t).direction), i = s * r, a = n.target, l = t.contains(a), c = !1, u = i > 0, f = 0, v = 0;
  do {
    if (!a)
      break;
    var g = us(e, a), b = g[0], h = g[1], w = g[2], m = h - w - s * b;
    (b || m) && ds(e, a) && (f += m, v += b);
    var y = a.parentNode;
    a = y && y.nodeType === Node.DOCUMENT_FRAGMENT_NODE ? y.host : y;
  } while (
    // portaled content
    !l && a !== document.body || // self content
    l && (t.contains(a) || t === a)
  );
  return (u && Math.abs(f) < 1 || !u && Math.abs(v) < 1) && (c = !0), c;
}, Ft = function(e) {
  return "changedTouches" in e ? [e.changedTouches[0].clientX, e.changedTouches[0].clientY] : [0, 0];
}, so = function(e) {
  return [e.deltaX, e.deltaY];
}, io = function(e) {
  return e && "current" in e ? e.current : e;
}, jd = function(e, t) {
  return e[0] === t[0] && e[1] === t[1];
}, Yd = function(e) {
  return `
  .block-interactivity-`.concat(e, ` {pointer-events: none;}
  .allow-interactivity-`).concat(e, ` {pointer-events: all;}
`);
}, Xd = 0, st = [];
function qd(e) {
  var t = d.useRef([]), n = d.useRef([0, 0]), r = d.useRef(), o = d.useState(Xd++)[0], s = d.useState(ls)[0], i = d.useRef(e);
  d.useEffect(function() {
    i.current = e;
  }, [e]), d.useEffect(function() {
    if (e.inert) {
      document.body.classList.add("block-interactivity-".concat(o));
      var h = vd([e.lockRef.current], (e.shards || []).map(io), !0).filter(Boolean);
      return h.forEach(function(w) {
        return w.classList.add("allow-interactivity-".concat(o));
      }), function() {
        document.body.classList.remove("block-interactivity-".concat(o)), h.forEach(function(w) {
          return w.classList.remove("allow-interactivity-".concat(o));
        });
      };
    }
  }, [e.inert, e.lockRef.current, e.shards]);
  var a = d.useCallback(function(h, w) {
    if ("touches" in h && h.touches.length === 2 || h.type === "wheel" && h.ctrlKey)
      return !i.current.allowPinchZoom;
    var m = Ft(h), y = n.current, x = "deltaX" in h ? h.deltaX : y[0] - m[0], C = "deltaY" in h ? h.deltaY : y[1] - m[1], S, R = h.target, N = Math.abs(x) > Math.abs(C) ? "h" : "v";
    if ("touches" in h && N === "h" && R.type === "range")
      return !1;
    var k = oo(N, R);
    if (!k)
      return !0;
    if (k ? S = N : (S = N === "v" ? "h" : "v", k = oo(N, R)), !k)
      return !1;
    if (!r.current && "changedTouches" in h && (x || C) && (r.current = S), !S)
      return !0;
    var W = r.current || S;
    return Ud(W, w, h, W === "h" ? x : C);
  }, []), l = d.useCallback(function(h) {
    var w = h;
    if (!(!st.length || st[st.length - 1] !== s)) {
      var m = "deltaY" in w ? so(w) : Ft(w), y = t.current.filter(function(S) {
        return S.name === w.type && (S.target === w.target || w.target === S.shadowParent) && jd(S.delta, m);
      })[0];
      if (y && y.should) {
        w.cancelable && w.preventDefault();
        return;
      }
      if (!y) {
        var x = (i.current.shards || []).map(io).filter(Boolean).filter(function(S) {
          return S.contains(w.target);
        }), C = x.length > 0 ? a(w, x[0]) : !i.current.noIsolation;
        C && w.cancelable && w.preventDefault();
      }
    }
  }, []), c = d.useCallback(function(h, w, m, y) {
    var x = { name: h, delta: w, target: m, should: y, shadowParent: Zd(m) };
    t.current.push(x), setTimeout(function() {
      t.current = t.current.filter(function(C) {
        return C !== x;
      });
    }, 1);
  }, []), u = d.useCallback(function(h) {
    n.current = Ft(h), r.current = void 0;
  }, []), f = d.useCallback(function(h) {
    c(h.type, so(h), h.target, a(h, e.lockRef.current));
  }, []), v = d.useCallback(function(h) {
    c(h.type, Ft(h), h.target, a(h, e.lockRef.current));
  }, []);
  d.useEffect(function() {
    return st.push(s), e.setCallbacks({
      onScrollCapture: f,
      onWheelCapture: f,
      onTouchMoveCapture: v
    }), document.addEventListener("wheel", l, ot), document.addEventListener("touchmove", l, ot), document.addEventListener("touchstart", u, ot), function() {
      st = st.filter(function(h) {
        return h !== s;
      }), document.removeEventListener("wheel", l, ot), document.removeEventListener("touchmove", l, ot), document.removeEventListener("touchstart", u, ot);
    };
  }, []);
  var g = e.removeScrollBar, b = e.inert;
  return d.createElement(
    d.Fragment,
    null,
    b ? d.createElement(s, { styles: Yd(o) }) : null,
    g ? d.createElement(zd, { noRelative: e.noRelative, gapMode: e.gapMode }) : null
  );
}
function Zd(e) {
  for (var t = null; e !== null; )
    e instanceof ShadowRoot && (t = e.host, e = e.host), e = e.parentNode;
  return t;
}
const Jd = Ed(as, qd);
var mr = d.forwardRef(function(e, t) {
  return d.createElement(sn, Re({}, e, { ref: t, sideCar: Jd }));
});
mr.classNames = sn.classNames;
var Qd = [" ", "Enter", "ArrowUp", "ArrowDown"], eu = [" ", "Enter"], qe = "Select", [an, ln, tu] = Zn(qe), [gt, mm] = Ve(qe, [
  tu,
  pt
]), cn = pt(), [nu, Be] = gt(qe), [ru, ou] = gt(qe), fs = (e) => {
  const {
    __scopeSelect: t,
    children: n,
    open: r,
    defaultOpen: o,
    onOpenChange: s,
    value: i,
    defaultValue: a,
    onValueChange: l,
    dir: c,
    name: u,
    autoComplete: f,
    disabled: v,
    required: g,
    form: b
  } = e, h = cn(t), [w, m] = d.useState(null), [y, x] = d.useState(null), [C, S] = d.useState(!1), R = Jn(c), [N, k] = dt({
    prop: r,
    defaultProp: o ?? !1,
    onChange: s,
    caller: qe
  }), [W, O] = dt({
    prop: i,
    defaultProp: a,
    onChange: l,
    caller: qe
  }), T = d.useRef(null), _ = w ? b || !!w.closest("form") : !0, [$, A] = d.useState(/* @__PURE__ */ new Set()), H = Array.from($).map((L) => L.props.value).join(";");
  return /* @__PURE__ */ p(cr, { ...h, children: /* @__PURE__ */ V(
    nu,
    {
      required: g,
      scope: t,
      trigger: w,
      onTriggerChange: m,
      valueNode: y,
      onValueNodeChange: x,
      valueNodeHasChildren: C,
      onValueNodeHasChildrenChange: S,
      contentId: Ye(),
      value: W,
      onValueChange: O,
      open: N,
      onOpenChange: k,
      dir: R,
      triggerPointerDownPosRef: T,
      disabled: v,
      children: [
        /* @__PURE__ */ p(an.Provider, { scope: t, children: /* @__PURE__ */ p(
          ru,
          {
            scope: e.__scopeSelect,
            onNativeOptionAdd: d.useCallback((L) => {
              A((j) => new Set(j).add(L));
            }, []),
            onNativeOptionRemove: d.useCallback((L) => {
              A((j) => {
                const B = new Set(j);
                return B.delete(L), B;
              });
            }, []),
            children: n
          }
        ) }),
        _ ? /* @__PURE__ */ V(
          Ls,
          {
            "aria-hidden": !0,
            required: g,
            tabIndex: -1,
            name: u,
            autoComplete: f,
            value: W,
            onChange: (L) => O(L.target.value),
            disabled: v,
            form: b,
            children: [
              W === void 0 ? /* @__PURE__ */ p("option", { value: "" }) : null,
              Array.from($)
            ]
          },
          H
        ) : null
      ]
    }
  ) });
};
fs.displayName = qe;
var hs = "SelectTrigger", ms = d.forwardRef(
  (e, t) => {
    const { __scopeSelect: n, disabled: r = !1, ...o } = e, s = cn(n), i = Be(hs, n), a = i.disabled || r, l = ie(t, i.onTriggerChange), c = ln(n), u = d.useRef("touch"), [f, v, g] = $s((h) => {
      const w = c().filter((x) => !x.disabled), m = w.find((x) => x.value === i.value), y = zs(w, h, m);
      y !== void 0 && i.onValueChange(y.value);
    }), b = (h) => {
      a || (i.onOpenChange(!0), g()), h && (i.triggerPointerDownPosRef.current = {
        x: Math.round(h.pageX),
        y: Math.round(h.pageY)
      });
    };
    return /* @__PURE__ */ p(dr, { asChild: !0, ...s, children: /* @__PURE__ */ p(
      se.button,
      {
        type: "button",
        role: "combobox",
        "aria-controls": i.contentId,
        "aria-expanded": i.open,
        "aria-required": i.required,
        "aria-autocomplete": "none",
        dir: i.dir,
        "data-state": i.open ? "open" : "closed",
        disabled: a,
        "data-disabled": a ? "" : void 0,
        "data-placeholder": Fs(i.value) ? "" : void 0,
        ...o,
        ref: l,
        onClick: G(o.onClick, (h) => {
          h.currentTarget.focus(), u.current !== "mouse" && b(h);
        }),
        onPointerDown: G(o.onPointerDown, (h) => {
          u.current = h.pointerType;
          const w = h.target;
          w.hasPointerCapture(h.pointerId) && w.releasePointerCapture(h.pointerId), h.button === 0 && h.ctrlKey === !1 && h.pointerType === "mouse" && (b(h), h.preventDefault());
        }),
        onKeyDown: G(o.onKeyDown, (h) => {
          const w = f.current !== "";
          !(h.ctrlKey || h.altKey || h.metaKey) && h.key.length === 1 && v(h.key), !(w && h.key === " ") && Qd.includes(h.key) && (b(), h.preventDefault());
        })
      }
    ) });
  }
);
ms.displayName = hs;
var ps = "SelectValue", gs = d.forwardRef(
  (e, t) => {
    const { __scopeSelect: n, className: r, style: o, children: s, placeholder: i = "", ...a } = e, l = Be(ps, n), { onValueNodeHasChildrenChange: c } = l, u = s !== void 0, f = ie(t, l.onValueNodeChange);
    return fe(() => {
      c(u);
    }, [c, u]), /* @__PURE__ */ p(
      se.span,
      {
        ...a,
        ref: f,
        style: { pointerEvents: "none" },
        children: Fs(l.value) ? /* @__PURE__ */ p(ft, { children: i }) : s
      }
    );
  }
);
gs.displayName = ps;
var su = "SelectIcon", vs = d.forwardRef(
  (e, t) => {
    const { __scopeSelect: n, children: r, ...o } = e;
    return /* @__PURE__ */ p(se.span, { "aria-hidden": !0, ...o, ref: t, children: r || "▼" });
  }
);
vs.displayName = su;
var iu = "SelectPortal", ws = (e) => /* @__PURE__ */ p(hr, { asChild: !0, ...e });
ws.displayName = iu;
var Ze = "SelectContent", ys = d.forwardRef(
  (e, t) => {
    const n = Be(Ze, e.__scopeSelect), [r, o] = d.useState();
    if (fe(() => {
      o(new DocumentFragment());
    }, []), !n.open) {
      const s = r;
      return s ? Zt.createPortal(
        /* @__PURE__ */ p(bs, { scope: e.__scopeSelect, children: /* @__PURE__ */ p(an.Slot, { scope: e.__scopeSelect, children: /* @__PURE__ */ p("div", { children: e.children }) }) }),
        s
      ) : null;
    }
    return /* @__PURE__ */ p(xs, { ...e, ref: t });
  }
);
ys.displayName = Ze;
var xe = 10, [bs, We] = gt(Ze), au = "SelectContentImpl", lu = /* @__PURE__ */ lt("SelectContent.RemoveScroll"), xs = d.forwardRef(
  (e, t) => {
    const {
      __scopeSelect: n,
      position: r = "item-aligned",
      onCloseAutoFocus: o,
      onEscapeKeyDown: s,
      onPointerDownOutside: i,
      //
      // PopperContent props
      side: a,
      sideOffset: l,
      align: c,
      alignOffset: u,
      arrowPadding: f,
      collisionBoundary: v,
      collisionPadding: g,
      sticky: b,
      hideWhenDetached: h,
      avoidCollisions: w,
      //
      ...m
    } = e, y = Be(Ze, n), [x, C] = d.useState(null), [S, R] = d.useState(null), N = ie(t, (I) => C(I)), [k, W] = d.useState(null), [O, T] = d.useState(
      null
    ), _ = ln(n), [$, A] = d.useState(!1), H = d.useRef(!1);
    d.useEffect(() => {
      if (x) return os(x);
    }, [x]), To();
    const L = d.useCallback(
      (I) => {
        const [J, ...ne] = _().map((z) => z.ref.current), [X] = ne.slice(-1), M = document.activeElement;
        for (const z of I)
          if (z === M || (z == null || z.scrollIntoView({ block: "nearest" }), z === J && S && (S.scrollTop = 0), z === X && S && (S.scrollTop = S.scrollHeight), z == null || z.focus(), document.activeElement !== M)) return;
      },
      [_, S]
    ), j = d.useCallback(
      () => L([k, x]),
      [L, k, x]
    );
    d.useEffect(() => {
      $ && j();
    }, [$, j]);
    const { onOpenChange: B, triggerPointerDownPosRef: P } = y;
    d.useEffect(() => {
      if (x) {
        let I = { x: 0, y: 0 };
        const J = (X) => {
          var M, z;
          I = {
            x: Math.abs(Math.round(X.pageX) - (((M = P.current) == null ? void 0 : M.x) ?? 0)),
            y: Math.abs(Math.round(X.pageY) - (((z = P.current) == null ? void 0 : z.y) ?? 0))
          };
        }, ne = (X) => {
          I.x <= 10 && I.y <= 10 ? X.preventDefault() : x.contains(X.target) || B(!1), document.removeEventListener("pointermove", J), P.current = null;
        };
        return P.current !== null && (document.addEventListener("pointermove", J), document.addEventListener("pointerup", ne, { capture: !0, once: !0 })), () => {
          document.removeEventListener("pointermove", J), document.removeEventListener("pointerup", ne, { capture: !0 });
        };
      }
    }, [x, B, P]), d.useEffect(() => {
      const I = () => B(!1);
      return window.addEventListener("blur", I), window.addEventListener("resize", I), () => {
        window.removeEventListener("blur", I), window.removeEventListener("resize", I);
      };
    }, [B]);
    const [Z, D] = $s((I) => {
      const J = _().filter((M) => !M.disabled), ne = J.find((M) => M.ref.current === document.activeElement), X = zs(J, I, ne);
      X && setTimeout(() => X.ref.current.focus());
    }), U = d.useCallback(
      (I, J, ne) => {
        const X = !H.current && !ne;
        (y.value !== void 0 && y.value === J || X) && (W(I), X && (H.current = !0));
      },
      [y.value]
    ), F = d.useCallback(() => x == null ? void 0 : x.focus(), [x]), K = d.useCallback(
      (I, J, ne) => {
        const X = !H.current && !ne;
        (y.value !== void 0 && y.value === J || X) && T(I);
      },
      [y.value]
    ), Y = r === "popper" ? Ln : Cs, ee = Y === Ln ? {
      side: a,
      sideOffset: l,
      align: c,
      alignOffset: u,
      arrowPadding: f,
      collisionBoundary: v,
      collisionPadding: g,
      sticky: b,
      hideWhenDetached: h,
      avoidCollisions: w
    } : {};
    return /* @__PURE__ */ p(
      bs,
      {
        scope: n,
        content: x,
        viewport: S,
        onViewportChange: R,
        itemRefCallback: U,
        selectedItem: k,
        onItemLeave: F,
        itemTextRefCallback: K,
        focusSelectedItem: j,
        selectedItemText: O,
        position: r,
        isPositioned: $,
        searchRef: Z,
        children: /* @__PURE__ */ p(mr, { as: lu, allowPinchZoom: !0, children: /* @__PURE__ */ p(
          Qn,
          {
            asChild: !0,
            trapped: y.open,
            onMountAutoFocus: (I) => {
              I.preventDefault();
            },
            onUnmountAutoFocus: G(o, (I) => {
              var J;
              (J = y.trigger) == null || J.focus({ preventScroll: !0 }), I.preventDefault();
            }),
            children: /* @__PURE__ */ p(
              tn,
              {
                asChild: !0,
                disableOutsidePointerEvents: !0,
                onEscapeKeyDown: s,
                onPointerDownOutside: i,
                onFocusOutside: (I) => I.preventDefault(),
                onDismiss: () => y.onOpenChange(!1),
                children: /* @__PURE__ */ p(
                  Y,
                  {
                    role: "listbox",
                    id: y.contentId,
                    "data-state": y.open ? "open" : "closed",
                    dir: y.dir,
                    onContextMenu: (I) => I.preventDefault(),
                    ...m,
                    ...ee,
                    onPlaced: () => A(!0),
                    ref: N,
                    style: {
                      // flex layout so we can place the scroll buttons properly
                      display: "flex",
                      flexDirection: "column",
                      // reset the outline by default as the content MAY get focused
                      outline: "none",
                      ...m.style
                    },
                    onKeyDown: G(m.onKeyDown, (I) => {
                      const J = I.ctrlKey || I.altKey || I.metaKey;
                      if (I.key === "Tab" && I.preventDefault(), !J && I.key.length === 1 && D(I.key), ["ArrowUp", "ArrowDown", "Home", "End"].includes(I.key)) {
                        let X = _().filter((M) => !M.disabled).map((M) => M.ref.current);
                        if (["ArrowUp", "End"].includes(I.key) && (X = X.slice().reverse()), ["ArrowUp", "ArrowDown"].includes(I.key)) {
                          const M = I.target, z = X.indexOf(M);
                          X = X.slice(z + 1);
                        }
                        setTimeout(() => L(X)), I.preventDefault();
                      }
                    })
                  }
                )
              }
            )
          }
        ) })
      }
    );
  }
);
xs.displayName = au;
var cu = "SelectItemAlignedPosition", Cs = d.forwardRef((e, t) => {
  const { __scopeSelect: n, onPlaced: r, ...o } = e, s = Be(Ze, n), i = We(Ze, n), [a, l] = d.useState(null), [c, u] = d.useState(null), f = ie(t, (N) => u(N)), v = ln(n), g = d.useRef(!1), b = d.useRef(!0), { viewport: h, selectedItem: w, selectedItemText: m, focusSelectedItem: y } = i, x = d.useCallback(() => {
    if (s.trigger && s.valueNode && a && c && h && w && m) {
      const N = s.trigger.getBoundingClientRect(), k = c.getBoundingClientRect(), W = s.valueNode.getBoundingClientRect(), O = m.getBoundingClientRect();
      if (s.dir !== "rtl") {
        const M = O.left - k.left, z = W.left - M, Q = N.left - z, re = N.width + Q, oe = Math.max(re, k.width), de = window.innerWidth - xe, ue = $r(z, [
          xe,
          // Prevents the content from going off the starting edge of the
          // viewport. It may still go off the ending edge, but this can be
          // controlled by the user since they may want to manage overflow in a
          // specific way.
          // https://github.com/radix-ui/primitives/issues/2049
          Math.max(xe, de - oe)
        ]);
        a.style.minWidth = re + "px", a.style.left = ue + "px";
      } else {
        const M = k.right - O.right, z = window.innerWidth - W.right - M, Q = window.innerWidth - N.right - z, re = N.width + Q, oe = Math.max(re, k.width), de = window.innerWidth - xe, ue = $r(z, [
          xe,
          Math.max(xe, de - oe)
        ]);
        a.style.minWidth = re + "px", a.style.right = ue + "px";
      }
      const T = v(), _ = window.innerHeight - xe * 2, $ = h.scrollHeight, A = window.getComputedStyle(c), H = parseInt(A.borderTopWidth, 10), L = parseInt(A.paddingTop, 10), j = parseInt(A.borderBottomWidth, 10), B = parseInt(A.paddingBottom, 10), P = H + L + $ + B + j, Z = Math.min(w.offsetHeight * 5, P), D = window.getComputedStyle(h), U = parseInt(D.paddingTop, 10), F = parseInt(D.paddingBottom, 10), K = N.top + N.height / 2 - xe, Y = _ - K, ee = w.offsetHeight / 2, I = w.offsetTop + ee, J = H + L + I, ne = P - J;
      if (J <= K) {
        const M = T.length > 0 && w === T[T.length - 1].ref.current;
        a.style.bottom = "0px";
        const z = c.clientHeight - h.offsetTop - h.offsetHeight, Q = Math.max(
          Y,
          ee + // viewport might have padding bottom, include it to avoid a scrollable viewport
          (M ? F : 0) + z + j
        ), re = J + Q;
        a.style.height = re + "px";
      } else {
        const M = T.length > 0 && w === T[0].ref.current;
        a.style.top = "0px";
        const Q = Math.max(
          K,
          H + h.offsetTop + // viewport might have padding top, include it to avoid a scrollable viewport
          (M ? U : 0) + ee
        ) + ne;
        a.style.height = Q + "px", h.scrollTop = J - K + h.offsetTop;
      }
      a.style.margin = `${xe}px 0`, a.style.minHeight = Z + "px", a.style.maxHeight = _ + "px", r == null || r(), requestAnimationFrame(() => g.current = !0);
    }
  }, [
    v,
    s.trigger,
    s.valueNode,
    a,
    c,
    h,
    w,
    m,
    s.dir,
    r
  ]);
  fe(() => x(), [x]);
  const [C, S] = d.useState();
  fe(() => {
    c && S(window.getComputedStyle(c).zIndex);
  }, [c]);
  const R = d.useCallback(
    (N) => {
      N && b.current === !0 && (x(), y == null || y(), b.current = !1);
    },
    [x, y]
  );
  return /* @__PURE__ */ p(
    uu,
    {
      scope: n,
      contentWrapper: a,
      shouldExpandOnScrollRef: g,
      onScrollButtonChange: R,
      children: /* @__PURE__ */ p(
        "div",
        {
          ref: l,
          style: {
            display: "flex",
            flexDirection: "column",
            position: "fixed",
            zIndex: C
          },
          children: /* @__PURE__ */ p(
            se.div,
            {
              ...o,
              ref: f,
              style: {
                // When we get the height of the content, it includes borders. If we were to set
                // the height without having `boxSizing: 'border-box'` it would be too big.
                boxSizing: "border-box",
                // We need to ensure the content doesn't get taller than the wrapper
                maxHeight: "100%",
                ...o.style
              }
            }
          )
        }
      )
    }
  );
});
Cs.displayName = cu;
var du = "SelectPopperPosition", Ln = d.forwardRef((e, t) => {
  const {
    __scopeSelect: n,
    align: r = "start",
    collisionPadding: o = xe,
    ...s
  } = e, i = cn(n);
  return /* @__PURE__ */ p(
    ur,
    {
      ...i,
      ...s,
      ref: t,
      align: r,
      collisionPadding: o,
      style: {
        // Ensure border-box for floating-ui calculations
        boxSizing: "border-box",
        ...s.style,
        "--radix-select-content-transform-origin": "var(--radix-popper-transform-origin)",
        "--radix-select-content-available-width": "var(--radix-popper-available-width)",
        "--radix-select-content-available-height": "var(--radix-popper-available-height)",
        "--radix-select-trigger-width": "var(--radix-popper-anchor-width)",
        "--radix-select-trigger-height": "var(--radix-popper-anchor-height)"
      }
    }
  );
});
Ln.displayName = du;
var [uu, pr] = gt(Ze, {}), Fn = "SelectViewport", Ss = d.forwardRef(
  (e, t) => {
    const { __scopeSelect: n, nonce: r, ...o } = e, s = We(Fn, n), i = pr(Fn, n), a = ie(t, s.onViewportChange), l = d.useRef(0);
    return /* @__PURE__ */ V(ft, { children: [
      /* @__PURE__ */ p(
        "style",
        {
          dangerouslySetInnerHTML: {
            __html: "[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"
          },
          nonce: r
        }
      ),
      /* @__PURE__ */ p(an.Slot, { scope: n, children: /* @__PURE__ */ p(
        se.div,
        {
          "data-radix-select-viewport": "",
          role: "presentation",
          ...o,
          ref: a,
          style: {
            // we use position: 'relative' here on the `viewport` so that when we call
            // `selectedItem.offsetTop` in calculations, the offset is relative to the viewport
            // (independent of the scrollUpButton).
            position: "relative",
            flex: 1,
            // Viewport should only be scrollable in the vertical direction.
            // This won't work in vertical writing modes, so we'll need to
            // revisit this if/when that is supported
            // https://developer.chrome.com/blog/vertical-form-controls
            overflow: "hidden auto",
            ...o.style
          },
          onScroll: G(o.onScroll, (c) => {
            const u = c.currentTarget, { contentWrapper: f, shouldExpandOnScrollRef: v } = i;
            if (v != null && v.current && f) {
              const g = Math.abs(l.current - u.scrollTop);
              if (g > 0) {
                const b = window.innerHeight - xe * 2, h = parseFloat(f.style.minHeight), w = parseFloat(f.style.height), m = Math.max(h, w);
                if (m < b) {
                  const y = m + g, x = Math.min(b, y), C = y - x;
                  f.style.height = x + "px", f.style.bottom === "0px" && (u.scrollTop = C > 0 ? C : 0, f.style.justifyContent = "flex-end");
                }
              }
            }
            l.current = u.scrollTop;
          })
        }
      ) })
    ] });
  }
);
Ss.displayName = Fn;
var Rs = "SelectGroup", [fu, hu] = gt(Rs), mu = d.forwardRef(
  (e, t) => {
    const { __scopeSelect: n, ...r } = e, o = Ye();
    return /* @__PURE__ */ p(fu, { scope: n, id: o, children: /* @__PURE__ */ p(se.div, { role: "group", "aria-labelledby": o, ...r, ref: t }) });
  }
);
mu.displayName = Rs;
var Is = "SelectLabel", Es = d.forwardRef(
  (e, t) => {
    const { __scopeSelect: n, ...r } = e, o = hu(Is, n);
    return /* @__PURE__ */ p(se.div, { id: o.id, ...r, ref: t });
  }
);
Es.displayName = Is;
var Yt = "SelectItem", [pu, Ns] = gt(Yt), Ms = d.forwardRef(
  (e, t) => {
    const {
      __scopeSelect: n,
      value: r,
      disabled: o = !1,
      textValue: s,
      ...i
    } = e, a = Be(Yt, n), l = We(Yt, n), c = a.value === r, [u, f] = d.useState(s ?? ""), [v, g] = d.useState(!1), b = ie(
      t,
      (y) => {
        var x;
        return (x = l.itemRefCallback) == null ? void 0 : x.call(l, y, r, o);
      }
    ), h = Ye(), w = d.useRef("touch"), m = () => {
      o || (a.onValueChange(r), a.onOpenChange(!1));
    };
    if (r === "")
      throw new Error(
        "A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder."
      );
    return /* @__PURE__ */ p(
      pu,
      {
        scope: n,
        value: r,
        disabled: o,
        textId: h,
        isSelected: c,
        onItemTextChange: d.useCallback((y) => {
          f((x) => x || ((y == null ? void 0 : y.textContent) ?? "").trim());
        }, []),
        children: /* @__PURE__ */ p(
          an.ItemSlot,
          {
            scope: n,
            value: r,
            disabled: o,
            textValue: u,
            children: /* @__PURE__ */ p(
              se.div,
              {
                role: "option",
                "aria-labelledby": h,
                "data-highlighted": v ? "" : void 0,
                "aria-selected": c && v,
                "data-state": c ? "checked" : "unchecked",
                "aria-disabled": o || void 0,
                "data-disabled": o ? "" : void 0,
                tabIndex: o ? void 0 : -1,
                ...i,
                ref: b,
                onFocus: G(i.onFocus, () => g(!0)),
                onBlur: G(i.onBlur, () => g(!1)),
                onClick: G(i.onClick, () => {
                  w.current !== "mouse" && m();
                }),
                onPointerUp: G(i.onPointerUp, () => {
                  w.current === "mouse" && m();
                }),
                onPointerDown: G(i.onPointerDown, (y) => {
                  w.current = y.pointerType;
                }),
                onPointerMove: G(i.onPointerMove, (y) => {
                  var x;
                  w.current = y.pointerType, o ? (x = l.onItemLeave) == null || x.call(l) : w.current === "mouse" && y.currentTarget.focus({ preventScroll: !0 });
                }),
                onPointerLeave: G(i.onPointerLeave, (y) => {
                  var x;
                  y.currentTarget === document.activeElement && ((x = l.onItemLeave) == null || x.call(l));
                }),
                onKeyDown: G(i.onKeyDown, (y) => {
                  var C;
                  ((C = l.searchRef) == null ? void 0 : C.current) !== "" && y.key === " " || (eu.includes(y.key) && m(), y.key === " " && y.preventDefault());
                })
              }
            )
          }
        )
      }
    );
  }
);
Ms.displayName = Yt;
var bt = "SelectItemText", Ps = d.forwardRef(
  (e, t) => {
    const { __scopeSelect: n, className: r, style: o, ...s } = e, i = Be(bt, n), a = We(bt, n), l = Ns(bt, n), c = ou(bt, n), [u, f] = d.useState(null), v = ie(
      t,
      (m) => f(m),
      l.onItemTextChange,
      (m) => {
        var y;
        return (y = a.itemTextRefCallback) == null ? void 0 : y.call(a, m, l.value, l.disabled);
      }
    ), g = u == null ? void 0 : u.textContent, b = d.useMemo(
      () => /* @__PURE__ */ p("option", { value: l.value, disabled: l.disabled, children: g }, l.value),
      [l.disabled, l.value, g]
    ), { onNativeOptionAdd: h, onNativeOptionRemove: w } = c;
    return fe(() => (h(b), () => w(b)), [h, w, b]), /* @__PURE__ */ V(ft, { children: [
      /* @__PURE__ */ p(se.span, { id: l.textId, ...s, ref: v }),
      l.isSelected && i.valueNode && !i.valueNodeHasChildren ? Zt.createPortal(s.children, i.valueNode) : null
    ] });
  }
);
Ps.displayName = bt;
var Ts = "SelectItemIndicator", As = d.forwardRef(
  (e, t) => {
    const { __scopeSelect: n, ...r } = e;
    return Ns(Ts, n).isSelected ? /* @__PURE__ */ p(se.span, { "aria-hidden": !0, ...r, ref: t }) : null;
  }
);
As.displayName = Ts;
var $n = "SelectScrollUpButton", ks = d.forwardRef((e, t) => {
  const n = We($n, e.__scopeSelect), r = pr($n, e.__scopeSelect), [o, s] = d.useState(!1), i = ie(t, r.onScrollButtonChange);
  return fe(() => {
    if (n.viewport && n.isPositioned) {
      let a = function() {
        const c = l.scrollTop > 0;
        s(c);
      };
      const l = n.viewport;
      return a(), l.addEventListener("scroll", a), () => l.removeEventListener("scroll", a);
    }
  }, [n.viewport, n.isPositioned]), o ? /* @__PURE__ */ p(
    Os,
    {
      ...e,
      ref: i,
      onAutoScroll: () => {
        const { viewport: a, selectedItem: l } = n;
        a && l && (a.scrollTop = a.scrollTop - l.offsetHeight);
      }
    }
  ) : null;
});
ks.displayName = $n;
var zn = "SelectScrollDownButton", Ds = d.forwardRef((e, t) => {
  const n = We(zn, e.__scopeSelect), r = pr(zn, e.__scopeSelect), [o, s] = d.useState(!1), i = ie(t, r.onScrollButtonChange);
  return fe(() => {
    if (n.viewport && n.isPositioned) {
      let a = function() {
        const c = l.scrollHeight - l.clientHeight, u = Math.ceil(l.scrollTop) < c;
        s(u);
      };
      const l = n.viewport;
      return a(), l.addEventListener("scroll", a), () => l.removeEventListener("scroll", a);
    }
  }, [n.viewport, n.isPositioned]), o ? /* @__PURE__ */ p(
    Os,
    {
      ...e,
      ref: i,
      onAutoScroll: () => {
        const { viewport: a, selectedItem: l } = n;
        a && l && (a.scrollTop = a.scrollTop + l.offsetHeight);
      }
    }
  ) : null;
});
Ds.displayName = zn;
var Os = d.forwardRef((e, t) => {
  const { __scopeSelect: n, onAutoScroll: r, ...o } = e, s = We("SelectScrollButton", n), i = d.useRef(null), a = ln(n), l = d.useCallback(() => {
    i.current !== null && (window.clearInterval(i.current), i.current = null);
  }, []);
  return d.useEffect(() => () => l(), [l]), fe(() => {
    var u;
    const c = a().find((f) => f.ref.current === document.activeElement);
    (u = c == null ? void 0 : c.ref.current) == null || u.scrollIntoView({ block: "nearest" });
  }, [a]), /* @__PURE__ */ p(
    se.div,
    {
      "aria-hidden": !0,
      ...o,
      ref: t,
      style: { flexShrink: 0, ...o.style },
      onPointerDown: G(o.onPointerDown, () => {
        i.current === null && (i.current = window.setInterval(r, 50));
      }),
      onPointerMove: G(o.onPointerMove, () => {
        var c;
        (c = s.onItemLeave) == null || c.call(s), i.current === null && (i.current = window.setInterval(r, 50));
      }),
      onPointerLeave: G(o.onPointerLeave, () => {
        l();
      })
    }
  );
}), gu = "SelectSeparator", _s = d.forwardRef(
  (e, t) => {
    const { __scopeSelect: n, ...r } = e;
    return /* @__PURE__ */ p(se.div, { "aria-hidden": !0, ...r, ref: t });
  }
);
_s.displayName = gu;
var Vn = "SelectArrow", vu = d.forwardRef(
  (e, t) => {
    const { __scopeSelect: n, ...r } = e, o = cn(n), s = Be(Vn, n), i = We(Vn, n);
    return s.open && i.position === "popper" ? /* @__PURE__ */ p(fr, { ...o, ...r, ref: t }) : null;
  }
);
vu.displayName = Vn;
var wu = "SelectBubbleInput", Ls = d.forwardRef(
  ({ __scopeSelect: e, value: t, ...n }, r) => {
    const o = d.useRef(null), s = ie(r, o), i = es(t);
    return d.useEffect(() => {
      const a = o.current;
      if (!a) return;
      const l = window.HTMLSelectElement.prototype, u = Object.getOwnPropertyDescriptor(
        l,
        "value"
      ).set;
      if (i !== t && u) {
        const f = new Event("change", { bubbles: !0 });
        u.call(a, t), a.dispatchEvent(f);
      }
    }, [i, t]), /* @__PURE__ */ p(
      se.select,
      {
        ...n,
        style: { ...ts, ...n.style },
        ref: s,
        defaultValue: t
      }
    );
  }
);
Ls.displayName = wu;
function Fs(e) {
  return e === "" || e === void 0;
}
function $s(e) {
  const t = Me(e), n = d.useRef(""), r = d.useRef(0), o = d.useCallback(
    (i) => {
      const a = n.current + i;
      t(a), function l(c) {
        n.current = c, window.clearTimeout(r.current), c !== "" && (r.current = window.setTimeout(() => l(""), 1e3));
      }(a);
    },
    [t]
  ), s = d.useCallback(() => {
    n.current = "", window.clearTimeout(r.current);
  }, []);
  return d.useEffect(() => () => window.clearTimeout(r.current), []), [n, o, s];
}
function zs(e, t, n) {
  const o = t.length > 1 && Array.from(t).every((c) => c === t[0]) ? t[0] : t, s = n ? e.indexOf(n) : -1;
  let i = yu(e, Math.max(s, 0));
  o.length === 1 && (i = i.filter((c) => c !== n));
  const l = i.find(
    (c) => c.textValue.toLowerCase().startsWith(o.toLowerCase())
  );
  return l !== n ? l : void 0;
}
function yu(e, t) {
  return e.map((n, r) => e[(t + r) % e.length]);
}
var bu = fs, Vs = ms, xu = gs, Cu = vs, Su = ws, Bs = ys, Ru = Ss, Ws = Es, Ks = Ms, Iu = Ps, Eu = As, Hs = ks, Gs = Ds, Us = _s;
const Nu = ze(
  "flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",
  {
    variants: {
      variant: {
        default: "",
        ghost: "border-transparent bg-transparent",
        filled: "bg-muted border-transparent"
      },
      size: {
        default: "h-10",
        sm: "h-9",
        lg: "h-11"
      }
    },
    defaultVariants: {
      variant: "default",
      size: "default"
    }
  }
), Mu = bu, Pu = xu, js = d.forwardRef(
  ({ className: e, variant: t, size: n, children: r, ...o }, s) => /* @__PURE__ */ V(Vs, { ref: s, className: te(Nu({ variant: t, size: n }), e), ...o, children: [
    r,
    /* @__PURE__ */ p(Cu, { asChild: !0, children: /* @__PURE__ */ p(wo, { className: "h-4 w-4 opacity-50" }) })
  ] })
);
js.displayName = Vs.displayName;
const Ys = d.forwardRef(({ className: e, ...t }, n) => /* @__PURE__ */ p(
  Hs,
  {
    ref: n,
    className: te("flex cursor-default items-center justify-center py-1", e),
    ...t,
    children: /* @__PURE__ */ p(ll, { className: "h-4 w-4" })
  }
));
Ys.displayName = Hs.displayName;
const Xs = d.forwardRef(({ className: e, ...t }, n) => /* @__PURE__ */ p(
  Gs,
  {
    ref: n,
    className: te("flex cursor-default items-center justify-center py-1", e),
    ...t,
    children: /* @__PURE__ */ p(wo, { className: "h-4 w-4" })
  }
));
Xs.displayName = Gs.displayName;
const qs = d.forwardRef(({ className: e, children: t, position: n = "popper", ...r }, o) => /* @__PURE__ */ p(Su, { children: /* @__PURE__ */ V(
  Bs,
  {
    ref: o,
    className: te(
      "relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
      n === "popper" && "data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",
      e
    ),
    position: n,
    ...r,
    children: [
      /* @__PURE__ */ p(Ys, {}),
      /* @__PURE__ */ p(
        Ru,
        {
          className: te(
            "p-1",
            n === "popper" && "h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"
          ),
          children: t
        }
      ),
      /* @__PURE__ */ p(Xs, {})
    ]
  }
) }));
qs.displayName = Bs.displayName;
const Tu = d.forwardRef(({ className: e, ...t }, n) => /* @__PURE__ */ p(Ws, { ref: n, className: te("py-1.5 pl-8 pr-2 text-sm font-semibold", e), ...t }));
Tu.displayName = Ws.displayName;
const Zs = d.forwardRef(({ className: e, children: t, ...n }, r) => /* @__PURE__ */ V(
  Ks,
  {
    ref: r,
    className: te(
      "relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
      e
    ),
    ...n,
    children: [
      /* @__PURE__ */ p("span", { className: "absolute left-2 flex h-3.5 w-3.5 items-center justify-center", children: /* @__PURE__ */ p(Eu, { children: /* @__PURE__ */ p(Jt, { className: "h-4 w-4" }) }) }),
      /* @__PURE__ */ p(Iu, { children: t })
    ]
  }
));
Zs.displayName = Ks.displayName;
const Au = d.forwardRef(({ className: e, ...t }, n) => /* @__PURE__ */ p(Us, { ref: n, className: te("-mx-1 my-1 h-px bg-muted", e), ...t }));
Au.displayName = Us.displayName;
function ku({
  totalCount: e,
  features: t = {},
  currentPageSize: n = 10,
  pageSizeOptions: r = [5, 10, 20, 50, 100],
  onPageSizeChange: o,
  leftSlot: s,
  rightSlot: i,
  centerSlot: a,
  className: l = ""
}) {
  const { pageSizeSelector: c = !1 } = t;
  return /* @__PURE__ */ V(
    "div",
    {
      className: `flex items-center justify-between gap-4 p-4 bg-muted/30 rounded-lg ${l}`,
      children: [
        /* @__PURE__ */ V("div", { className: "flex items-center gap-4", children: [
          /* @__PURE__ */ p("div", { className: "flex items-center gap-4 text-sm text-muted-foreground", children: /* @__PURE__ */ V("span", { children: [
            "Total: ",
            e.toLocaleString()
          ] }) }),
          s
        ] }),
        a && /* @__PURE__ */ p("div", { className: "flex items-center gap-4", children: a }),
        /* @__PURE__ */ V("div", { className: "flex items-center gap-4", children: [
          c && /* @__PURE__ */ V("div", { className: "flex items-center gap-2", children: [
            /* @__PURE__ */ p("span", { className: "text-sm text-muted-foreground whitespace-nowrap", children: "Show:" }),
            /* @__PURE__ */ V(
              Mu,
              {
                value: n.toString(),
                onValueChange: (u) => o == null ? void 0 : o(Number(u)),
                children: [
                  /* @__PURE__ */ p(js, { className: "w-20", children: /* @__PURE__ */ p(Pu, {}) }),
                  /* @__PURE__ */ p(qs, { children: r.map((u) => /* @__PURE__ */ p(Zs, { value: u.toString(), children: u }, u)) })
                ]
              }
            )
          ] }),
          i
        ] })
      ]
    }
  );
}
function Du({
  totalCount: e,
  visibleCount: t,
  scrollInfo: n,
  onScrollToTop: r,
  onScrollToMiddle: o,
  onScrollToBottom: s,
  onScrollToRandom: i
}) {
  return /* @__PURE__ */ V(ft, { children: [
    /* @__PURE__ */ V("div", { className: "p-3 bg-blue-100 dark:bg-blue-900/20 rounded border border-blue-300 dark:border-blue-700 text-sm", children: [
      /* @__PURE__ */ p("div", { className: "font-semibold text-blue-800 dark:text-blue-200 mb-1", children: "Virtual Scrolling Active" }),
      /* @__PURE__ */ V("div", { className: "grid grid-cols-2 md:grid-cols-4 gap-2 text-xs text-blue-700 dark:text-blue-300", children: [
        /* @__PURE__ */ V("div", { children: [
          "Total: ",
          e
        ] }),
        /* @__PURE__ */ V("div", { children: [
          "Visible: ",
          t
        ] }),
        /* @__PURE__ */ V("div", { children: [
          "Range: ",
          n.visibleStartIndex,
          "-",
          n.visibleEndIndex
        ] }),
        /* @__PURE__ */ V("div", { children: [
          "Height: ",
          n.totalHeight,
          "px"
        ] })
      ] })
    ] }),
    /* @__PURE__ */ V("div", { className: "flex gap-2 items-center p-3 bg-gray-100 dark:bg-gray-800 rounded", children: [
      /* @__PURE__ */ p("span", { className: "text-sm font-medium", children: "Virtual Scroll Controls:" }),
      /* @__PURE__ */ p(Ie, { size: "sm", variant: "outline", onClick: r, children: "↑ Top" }),
      /* @__PURE__ */ p(Ie, { size: "sm", variant: "outline", onClick: o, children: "↕ Middle" }),
      /* @__PURE__ */ p(Ie, { size: "sm", variant: "outline", onClick: s, children: "↓ Bottom" }),
      /* @__PURE__ */ p(Ie, { size: "sm", variant: "outline", onClick: i, children: "🎲 Random" })
    ] })
  ] });
}
function Ou(e, t) {
  return d.useReducer((n, r) => t[n][r] ?? n, e);
}
var Je = (e) => {
  const { present: t, children: n } = e, r = _u(t), o = typeof n == "function" ? n({ present: r.isPresent }) : d.Children.only(n), s = ie(r.ref, Lu(o));
  return typeof n == "function" || r.isPresent ? d.cloneElement(o, { ref: s }) : null;
};
Je.displayName = "Presence";
function _u(e) {
  const [t, n] = d.useState(), r = d.useRef(null), o = d.useRef(e), s = d.useRef("none"), i = e ? "mounted" : "unmounted", [a, l] = Ou(i, {
    mounted: {
      UNMOUNT: "unmounted",
      ANIMATION_OUT: "unmountSuspended"
    },
    unmountSuspended: {
      MOUNT: "mounted",
      ANIMATION_END: "unmounted"
    },
    unmounted: {
      MOUNT: "mounted"
    }
  });
  return d.useEffect(() => {
    const c = $t(r.current);
    s.current = a === "mounted" ? c : "none";
  }, [a]), fe(() => {
    const c = r.current, u = o.current;
    if (u !== e) {
      const v = s.current, g = $t(c);
      e ? l("MOUNT") : g === "none" || (c == null ? void 0 : c.display) === "none" ? l("UNMOUNT") : l(u && v !== g ? "ANIMATION_OUT" : "UNMOUNT"), o.current = e;
    }
  }, [e, l]), fe(() => {
    if (t) {
      let c;
      const u = t.ownerDocument.defaultView ?? window, f = (g) => {
        const h = $t(r.current).includes(g.animationName);
        if (g.target === t && h && (l("ANIMATION_END"), !o.current)) {
          const w = t.style.animationFillMode;
          t.style.animationFillMode = "forwards", c = u.setTimeout(() => {
            t.style.animationFillMode === "forwards" && (t.style.animationFillMode = w);
          });
        }
      }, v = (g) => {
        g.target === t && (s.current = $t(r.current));
      };
      return t.addEventListener("animationstart", v), t.addEventListener("animationcancel", f), t.addEventListener("animationend", f), () => {
        u.clearTimeout(c), t.removeEventListener("animationstart", v), t.removeEventListener("animationcancel", f), t.removeEventListener("animationend", f);
      };
    } else
      l("ANIMATION_END");
  }, [t, l]), {
    isPresent: ["mounted", "unmountSuspended"].includes(a),
    ref: d.useCallback((c) => {
      r.current = c ? getComputedStyle(c) : null, n(c);
    }, [])
  };
}
function $t(e) {
  return (e == null ? void 0 : e.animationName) || "none";
}
function Lu(e) {
  var r, o;
  let t = (r = Object.getOwnPropertyDescriptor(e.props, "ref")) == null ? void 0 : r.get, n = t && "isReactWarning" in t && t.isReactWarning;
  return n ? e.ref : (t = (o = Object.getOwnPropertyDescriptor(e, "ref")) == null ? void 0 : o.get, n = t && "isReactWarning" in t && t.isReactWarning, n ? e.props.ref : e.props.ref || e.ref);
}
var dn = "Checkbox", [Fu, pm] = Ve(dn), [$u, gr] = Fu(dn);
function zu(e) {
  const {
    __scopeCheckbox: t,
    checked: n,
    children: r,
    defaultChecked: o,
    disabled: s,
    form: i,
    name: a,
    onCheckedChange: l,
    required: c,
    value: u = "on",
    // @ts-expect-error
    internal_do_not_use_render: f
  } = e, [v, g] = dt({
    prop: n,
    defaultProp: o ?? !1,
    onChange: l,
    caller: dn
  }), [b, h] = d.useState(null), [w, m] = d.useState(null), y = d.useRef(!1), x = b ? !!i || !!b.closest("form") : (
    // We set this to true by default so that events bubble to forms without JS (SSR)
    !0
  ), C = {
    checked: v,
    disabled: s,
    setChecked: g,
    control: b,
    setControl: h,
    name: a,
    form: i,
    value: u,
    hasConsumerStoppedPropagationRef: y,
    required: c,
    defaultChecked: Le(o) ? !1 : o,
    isFormControl: x,
    bubbleInput: w,
    setBubbleInput: m
  };
  return /* @__PURE__ */ p(
    $u,
    {
      scope: t,
      ...C,
      children: Vu(f) ? f(C) : r
    }
  );
}
var Js = "CheckboxTrigger", Qs = d.forwardRef(
  ({ __scopeCheckbox: e, onKeyDown: t, onClick: n, ...r }, o) => {
    const {
      control: s,
      value: i,
      disabled: a,
      checked: l,
      required: c,
      setControl: u,
      setChecked: f,
      hasConsumerStoppedPropagationRef: v,
      isFormControl: g,
      bubbleInput: b
    } = gr(Js, e), h = ie(o, u), w = d.useRef(l);
    return d.useEffect(() => {
      const m = s == null ? void 0 : s.form;
      if (m) {
        const y = () => f(w.current);
        return m.addEventListener("reset", y), () => m.removeEventListener("reset", y);
      }
    }, [s, f]), /* @__PURE__ */ p(
      se.button,
      {
        type: "button",
        role: "checkbox",
        "aria-checked": Le(l) ? "mixed" : l,
        "aria-required": c,
        "data-state": oi(l),
        "data-disabled": a ? "" : void 0,
        disabled: a,
        value: i,
        ...r,
        ref: h,
        onKeyDown: G(t, (m) => {
          m.key === "Enter" && m.preventDefault();
        }),
        onClick: G(n, (m) => {
          f((y) => Le(y) ? !0 : !y), b && g && (v.current = m.isPropagationStopped(), v.current || m.stopPropagation());
        })
      }
    );
  }
);
Qs.displayName = Js;
var vr = d.forwardRef(
  (e, t) => {
    const {
      __scopeCheckbox: n,
      name: r,
      checked: o,
      defaultChecked: s,
      required: i,
      disabled: a,
      value: l,
      onCheckedChange: c,
      form: u,
      ...f
    } = e;
    return /* @__PURE__ */ p(
      zu,
      {
        __scopeCheckbox: n,
        checked: o,
        defaultChecked: s,
        disabled: a,
        required: i,
        onCheckedChange: c,
        name: r,
        form: u,
        value: l,
        internal_do_not_use_render: ({ isFormControl: v }) => /* @__PURE__ */ V(ft, { children: [
          /* @__PURE__ */ p(
            Qs,
            {
              ...f,
              ref: t,
              __scopeCheckbox: n
            }
          ),
          v && /* @__PURE__ */ p(
            ri,
            {
              __scopeCheckbox: n
            }
          )
        ] })
      }
    );
  }
);
vr.displayName = dn;
var ei = "CheckboxIndicator", ti = d.forwardRef(
  (e, t) => {
    const { __scopeCheckbox: n, forceMount: r, ...o } = e, s = gr(ei, n);
    return /* @__PURE__ */ p(
      Je,
      {
        present: r || Le(s.checked) || s.checked === !0,
        children: /* @__PURE__ */ p(
          se.span,
          {
            "data-state": oi(s.checked),
            "data-disabled": s.disabled ? "" : void 0,
            ...o,
            ref: t,
            style: { pointerEvents: "none", ...e.style }
          }
        )
      }
    );
  }
);
ti.displayName = ei;
var ni = "CheckboxBubbleInput", ri = d.forwardRef(
  ({ __scopeCheckbox: e, ...t }, n) => {
    const {
      control: r,
      hasConsumerStoppedPropagationRef: o,
      checked: s,
      defaultChecked: i,
      required: a,
      disabled: l,
      name: c,
      value: u,
      form: f,
      bubbleInput: v,
      setBubbleInput: g
    } = gr(ni, e), b = ie(n, g), h = es(s), w = Ho(r);
    d.useEffect(() => {
      const y = v;
      if (!y) return;
      const x = window.HTMLInputElement.prototype, S = Object.getOwnPropertyDescriptor(
        x,
        "checked"
      ).set, R = !o.current;
      if (h !== s && S) {
        const N = new Event("click", { bubbles: R });
        y.indeterminate = Le(s), S.call(y, Le(s) ? !1 : s), y.dispatchEvent(N);
      }
    }, [v, h, s, o]);
    const m = d.useRef(Le(s) ? !1 : s);
    return /* @__PURE__ */ p(
      se.input,
      {
        type: "checkbox",
        "aria-hidden": !0,
        defaultChecked: i ?? m.current,
        required: a,
        disabled: l,
        name: c,
        value: u,
        form: f,
        ...t,
        tabIndex: -1,
        ref: b,
        style: {
          ...t.style,
          ...w,
          position: "absolute",
          pointerEvents: "none",
          opacity: 0,
          margin: 0,
          // We transform because the input is absolutely positioned but we have
          // rendered it **after** the button. This pulls it back to sit on top
          // of the button.
          transform: "translateX(-100%)"
        }
      }
    );
  }
);
ri.displayName = ni;
function Vu(e) {
  return typeof e == "function";
}
function Le(e) {
  return e === "indeterminate";
}
function oi(e) {
  return Le(e) ? "indeterminate" : e ? "checked" : "unchecked";
}
const Bu = ze(
  "peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",
  {
    variants: {
      variant: {
        default: "",
        destructive: "border-destructive data-[state=checked]:bg-destructive",
        success: "border-green-500 data-[state=checked]:bg-green-500"
      },
      size: {
        default: "h-4 w-4",
        sm: "h-3 w-3",
        lg: "h-5 w-5"
      }
    },
    defaultVariants: {
      variant: "default",
      size: "default"
    }
  }
), It = d.forwardRef(
  ({ className: e, variant: t, size: n, indeterminate: r, ...o }, s) => /* @__PURE__ */ p(vr, { ref: s, className: te(Bu({ variant: t, size: n }), e), ...o, children: /* @__PURE__ */ p(ti, { className: te("flex items-center justify-center text-current"), children: r ? /* @__PURE__ */ p(fl, { className: "h-3 w-3" }) : /* @__PURE__ */ p(Jt, { className: "h-3 w-3" }) }) })
);
It.displayName = vr.displayName;
function Wu({
  columns: e,
  sorting: t,
  showSelection: n = !0,
  showActions: r = !0,
  isAllSelected: o,
  isIndeterminate: s,
  onSelectAll: i,
  onSort: a,
  sortable: l = !0
}) {
  return /* @__PURE__ */ p("div", { className: "bg-muted/50 sticky top-0 z-10", children: /* @__PURE__ */ V("div", { className: "flex border-b", children: [
    n && /* @__PURE__ */ p("div", { className: "flex items-center justify-center w-12 p-3 border-r font-medium text-sm bg-muted/50", children: /* @__PURE__ */ p(
      It,
      {
        checked: o,
        indeterminate: s,
        onCheckedChange: i,
        "aria-label": "Select all rows"
      }
    ) }),
    e.map((c) => {
      const u = t.find((f) => f.id === c.id);
      return /* @__PURE__ */ V(
        "div",
        {
          className: `
                flex items-center p-3 font-medium text-sm border-r hover:bg-muted/50 bg-muted/50
                ${l && c.sortable ? "cursor-pointer" : ""}
                ${c.headerClassName || ""}
              `,
          style: {
            textAlign: c.headerAlign || c.align || "left",
            width: c.width ? `${c.width}px` : void 0,
            minWidth: c.minWidth ? `${c.minWidth}px` : void 0,
            maxWidth: c.maxWidth ? `${c.maxWidth}px` : void 0,
            flex: c.flex ? c.flex : void 0
          },
          onClick: () => {
            l && c.sortable && a(c.id);
          },
          children: [
            /* @__PURE__ */ p("span", { className: c.ellipsis ? "truncate" : "", children: c.header }),
            l && c.sortable && /* @__PURE__ */ p("span", { className: "ml-1 text-muted-foreground", children: u ? u.desc ? "↓" : "↑" : "↕️" })
          ]
        },
        c.id
      );
    }),
    r && /* @__PURE__ */ p("div", { className: "flex items-center justify-center w-12 p-3 font-medium text-sm bg-muted/50", children: "Actions" })
  ] }) });
}
var En = "rovingFocusGroup.onEntryFocus", Ku = { bubbles: !1, cancelable: !0 }, Tt = "RovingFocusGroup", [Bn, si, Hu] = Zn(Tt), [Gu, ii] = Ve(
  Tt,
  [Hu]
), [Uu, ju] = Gu(Tt), ai = d.forwardRef(
  (e, t) => /* @__PURE__ */ p(Bn.Provider, { scope: e.__scopeRovingFocusGroup, children: /* @__PURE__ */ p(Bn.Slot, { scope: e.__scopeRovingFocusGroup, children: /* @__PURE__ */ p(Yu, { ...e, ref: t }) }) })
);
ai.displayName = Tt;
var Yu = d.forwardRef((e, t) => {
  const {
    __scopeRovingFocusGroup: n,
    orientation: r,
    loop: o = !1,
    dir: s,
    currentTabStopId: i,
    defaultCurrentTabStopId: a,
    onCurrentTabStopIdChange: l,
    onEntryFocus: c,
    preventScrollOnEntryFocus: u = !1,
    ...f
  } = e, v = d.useRef(null), g = ie(t, v), b = Jn(s), [h, w] = dt({
    prop: i,
    defaultProp: a ?? null,
    onChange: l,
    caller: Tt
  }), [m, y] = d.useState(!1), x = Me(c), C = si(n), S = d.useRef(!1), [R, N] = d.useState(0);
  return d.useEffect(() => {
    const k = v.current;
    if (k)
      return k.addEventListener(En, x), () => k.removeEventListener(En, x);
  }, [x]), /* @__PURE__ */ p(
    Uu,
    {
      scope: n,
      orientation: r,
      dir: b,
      loop: o,
      currentTabStopId: h,
      onItemFocus: d.useCallback(
        (k) => w(k),
        [w]
      ),
      onItemShiftTab: d.useCallback(() => y(!0), []),
      onFocusableItemAdd: d.useCallback(
        () => N((k) => k + 1),
        []
      ),
      onFocusableItemRemove: d.useCallback(
        () => N((k) => k - 1),
        []
      ),
      children: /* @__PURE__ */ p(
        se.div,
        {
          tabIndex: m || R === 0 ? -1 : 0,
          "data-orientation": r,
          ...f,
          ref: g,
          style: { outline: "none", ...e.style },
          onMouseDown: G(e.onMouseDown, () => {
            S.current = !0;
          }),
          onFocus: G(e.onFocus, (k) => {
            const W = !S.current;
            if (k.target === k.currentTarget && W && !m) {
              const O = new CustomEvent(En, Ku);
              if (k.currentTarget.dispatchEvent(O), !O.defaultPrevented) {
                const T = C().filter((L) => L.focusable), _ = T.find((L) => L.active), $ = T.find((L) => L.id === h), H = [_, $, ...T].filter(
                  Boolean
                ).map((L) => L.ref.current);
                di(H, u);
              }
            }
            S.current = !1;
          }),
          onBlur: G(e.onBlur, () => y(!1))
        }
      )
    }
  );
}), li = "RovingFocusGroupItem", ci = d.forwardRef(
  (e, t) => {
    const {
      __scopeRovingFocusGroup: n,
      focusable: r = !0,
      active: o = !1,
      tabStopId: s,
      children: i,
      ...a
    } = e, l = Ye(), c = s || l, u = ju(li, n), f = u.currentTabStopId === c, v = si(n), { onFocusableItemAdd: g, onFocusableItemRemove: b, currentTabStopId: h } = u;
    return d.useEffect(() => {
      if (r)
        return g(), () => b();
    }, [r, g, b]), /* @__PURE__ */ p(
      Bn.ItemSlot,
      {
        scope: n,
        id: c,
        focusable: r,
        active: o,
        children: /* @__PURE__ */ p(
          se.span,
          {
            tabIndex: f ? 0 : -1,
            "data-orientation": u.orientation,
            ...a,
            ref: t,
            onMouseDown: G(e.onMouseDown, (w) => {
              r ? u.onItemFocus(c) : w.preventDefault();
            }),
            onFocus: G(e.onFocus, () => u.onItemFocus(c)),
            onKeyDown: G(e.onKeyDown, (w) => {
              if (w.key === "Tab" && w.shiftKey) {
                u.onItemShiftTab();
                return;
              }
              if (w.target !== w.currentTarget) return;
              const m = Zu(w, u.orientation, u.dir);
              if (m !== void 0) {
                if (w.metaKey || w.ctrlKey || w.altKey || w.shiftKey) return;
                w.preventDefault();
                let x = v().filter((C) => C.focusable).map((C) => C.ref.current);
                if (m === "last") x.reverse();
                else if (m === "prev" || m === "next") {
                  m === "prev" && x.reverse();
                  const C = x.indexOf(w.currentTarget);
                  x = u.loop ? Ju(x, C + 1) : x.slice(C + 1);
                }
                setTimeout(() => di(x));
              }
            }),
            children: typeof i == "function" ? i({ isCurrentTabStop: f, hasTabStop: h != null }) : i
          }
        )
      }
    );
  }
);
ci.displayName = li;
var Xu = {
  ArrowLeft: "prev",
  ArrowUp: "prev",
  ArrowRight: "next",
  ArrowDown: "next",
  PageUp: "first",
  Home: "first",
  PageDown: "last",
  End: "last"
};
function qu(e, t) {
  return t !== "rtl" ? e : e === "ArrowLeft" ? "ArrowRight" : e === "ArrowRight" ? "ArrowLeft" : e;
}
function Zu(e, t, n) {
  const r = qu(e.key, n);
  if (!(t === "vertical" && ["ArrowLeft", "ArrowRight"].includes(r)) && !(t === "horizontal" && ["ArrowUp", "ArrowDown"].includes(r)))
    return Xu[r];
}
function di(e, t = !1) {
  const n = document.activeElement;
  for (const r of e)
    if (r === n || (r.focus({ preventScroll: t }), document.activeElement !== n)) return;
}
function Ju(e, t) {
  return e.map((n, r) => e[(t + r) % e.length]);
}
var Qu = ai, ef = ci, Wn = ["Enter", " "], tf = ["ArrowDown", "PageUp", "Home"], ui = ["ArrowUp", "PageDown", "End"], nf = [...tf, ...ui], rf = {
  ltr: [...Wn, "ArrowRight"],
  rtl: [...Wn, "ArrowLeft"]
}, of = {
  ltr: ["ArrowLeft"],
  rtl: ["ArrowRight"]
}, At = "Menu", [Et, sf, af] = Zn(At), [Qe, fi] = Ve(At, [
  af,
  pt,
  ii
]), un = pt(), hi = ii(), [lf, et] = Qe(At), [cf, kt] = Qe(At), mi = (e) => {
  const { __scopeMenu: t, open: n = !1, children: r, dir: o, onOpenChange: s, modal: i = !0 } = e, a = un(t), [l, c] = d.useState(null), u = d.useRef(!1), f = Me(s), v = Jn(o);
  return d.useEffect(() => {
    const g = () => {
      u.current = !0, document.addEventListener("pointerdown", b, { capture: !0, once: !0 }), document.addEventListener("pointermove", b, { capture: !0, once: !0 });
    }, b = () => u.current = !1;
    return document.addEventListener("keydown", g, { capture: !0 }), () => {
      document.removeEventListener("keydown", g, { capture: !0 }), document.removeEventListener("pointerdown", b, { capture: !0 }), document.removeEventListener("pointermove", b, { capture: !0 });
    };
  }, []), /* @__PURE__ */ p(cr, { ...a, children: /* @__PURE__ */ p(
    lf,
    {
      scope: t,
      open: n,
      onOpenChange: f,
      content: l,
      onContentChange: c,
      children: /* @__PURE__ */ p(
        cf,
        {
          scope: t,
          onClose: d.useCallback(() => f(!1), [f]),
          isUsingKeyboardRef: u,
          dir: v,
          modal: i,
          children: r
        }
      )
    }
  ) });
};
mi.displayName = At;
var df = "MenuAnchor", wr = d.forwardRef(
  (e, t) => {
    const { __scopeMenu: n, ...r } = e, o = un(n);
    return /* @__PURE__ */ p(dr, { ...o, ...r, ref: t });
  }
);
wr.displayName = df;
var yr = "MenuPortal", [uf, pi] = Qe(yr, {
  forceMount: void 0
}), gi = (e) => {
  const { __scopeMenu: t, forceMount: n, children: r, container: o } = e, s = et(yr, t);
  return /* @__PURE__ */ p(uf, { scope: t, forceMount: n, children: /* @__PURE__ */ p(Je, { present: n || s.open, children: /* @__PURE__ */ p(hr, { asChild: !0, container: o, children: r }) }) });
};
gi.displayName = yr;
var ye = "MenuContent", [ff, br] = Qe(ye), vi = d.forwardRef(
  (e, t) => {
    const n = pi(ye, e.__scopeMenu), { forceMount: r = n.forceMount, ...o } = e, s = et(ye, e.__scopeMenu), i = kt(ye, e.__scopeMenu);
    return /* @__PURE__ */ p(Et.Provider, { scope: e.__scopeMenu, children: /* @__PURE__ */ p(Je, { present: r || s.open, children: /* @__PURE__ */ p(Et.Slot, { scope: e.__scopeMenu, children: i.modal ? /* @__PURE__ */ p(hf, { ...o, ref: t }) : /* @__PURE__ */ p(mf, { ...o, ref: t }) }) }) });
  }
), hf = d.forwardRef(
  (e, t) => {
    const n = et(ye, e.__scopeMenu), r = d.useRef(null), o = ie(t, r);
    return d.useEffect(() => {
      const s = r.current;
      if (s) return os(s);
    }, []), /* @__PURE__ */ p(
      xr,
      {
        ...e,
        ref: o,
        trapFocus: n.open,
        disableOutsidePointerEvents: n.open,
        disableOutsideScroll: !0,
        onFocusOutside: G(
          e.onFocusOutside,
          (s) => s.preventDefault(),
          { checkForDefaultPrevented: !1 }
        ),
        onDismiss: () => n.onOpenChange(!1)
      }
    );
  }
), mf = d.forwardRef((e, t) => {
  const n = et(ye, e.__scopeMenu);
  return /* @__PURE__ */ p(
    xr,
    {
      ...e,
      ref: t,
      trapFocus: !1,
      disableOutsidePointerEvents: !1,
      disableOutsideScroll: !1,
      onDismiss: () => n.onOpenChange(!1)
    }
  );
}), pf = /* @__PURE__ */ lt("MenuContent.ScrollLock"), xr = d.forwardRef(
  (e, t) => {
    const {
      __scopeMenu: n,
      loop: r = !1,
      trapFocus: o,
      onOpenAutoFocus: s,
      onCloseAutoFocus: i,
      disableOutsidePointerEvents: a,
      onEntryFocus: l,
      onEscapeKeyDown: c,
      onPointerDownOutside: u,
      onFocusOutside: f,
      onInteractOutside: v,
      onDismiss: g,
      disableOutsideScroll: b,
      ...h
    } = e, w = et(ye, n), m = kt(ye, n), y = un(n), x = hi(n), C = sf(n), [S, R] = d.useState(null), N = d.useRef(null), k = ie(t, N, w.onContentChange), W = d.useRef(0), O = d.useRef(""), T = d.useRef(0), _ = d.useRef(null), $ = d.useRef("right"), A = d.useRef(0), H = b ? mr : d.Fragment, L = b ? { as: pf, allowPinchZoom: !0 } : void 0, j = (P) => {
      var I, J;
      const Z = O.current + P, D = C().filter((ne) => !ne.disabled), U = document.activeElement, F = (I = D.find((ne) => ne.ref.current === U)) == null ? void 0 : I.textValue, K = D.map((ne) => ne.textValue), Y = Nf(K, Z, F), ee = (J = D.find((ne) => ne.textValue === Y)) == null ? void 0 : J.ref.current;
      (function ne(X) {
        O.current = X, window.clearTimeout(W.current), X !== "" && (W.current = window.setTimeout(() => ne(""), 1e3));
      })(Z), ee && setTimeout(() => ee.focus());
    };
    d.useEffect(() => () => window.clearTimeout(W.current), []), To();
    const B = d.useCallback((P) => {
      var D, U;
      return $.current === ((D = _.current) == null ? void 0 : D.side) && Pf(P, (U = _.current) == null ? void 0 : U.area);
    }, []);
    return /* @__PURE__ */ p(
      ff,
      {
        scope: n,
        searchRef: O,
        onItemEnter: d.useCallback(
          (P) => {
            B(P) && P.preventDefault();
          },
          [B]
        ),
        onItemLeave: d.useCallback(
          (P) => {
            var Z;
            B(P) || ((Z = N.current) == null || Z.focus(), R(null));
          },
          [B]
        ),
        onTriggerLeave: d.useCallback(
          (P) => {
            B(P) && P.preventDefault();
          },
          [B]
        ),
        pointerGraceTimerRef: T,
        onPointerGraceIntentChange: d.useCallback((P) => {
          _.current = P;
        }, []),
        children: /* @__PURE__ */ p(H, { ...L, children: /* @__PURE__ */ p(
          Qn,
          {
            asChild: !0,
            trapped: o,
            onMountAutoFocus: G(s, (P) => {
              var Z;
              P.preventDefault(), (Z = N.current) == null || Z.focus({ preventScroll: !0 });
            }),
            onUnmountAutoFocus: i,
            children: /* @__PURE__ */ p(
              tn,
              {
                asChild: !0,
                disableOutsidePointerEvents: a,
                onEscapeKeyDown: c,
                onPointerDownOutside: u,
                onFocusOutside: f,
                onInteractOutside: v,
                onDismiss: g,
                children: /* @__PURE__ */ p(
                  Qu,
                  {
                    asChild: !0,
                    ...x,
                    dir: m.dir,
                    orientation: "vertical",
                    loop: r,
                    currentTabStopId: S,
                    onCurrentTabStopIdChange: R,
                    onEntryFocus: G(l, (P) => {
                      m.isUsingKeyboardRef.current || P.preventDefault();
                    }),
                    preventScrollOnEntryFocus: !0,
                    children: /* @__PURE__ */ p(
                      ur,
                      {
                        role: "menu",
                        "aria-orientation": "vertical",
                        "data-state": Di(w.open),
                        "data-radix-menu-content": "",
                        dir: m.dir,
                        ...y,
                        ...h,
                        ref: k,
                        style: { outline: "none", ...h.style },
                        onKeyDown: G(h.onKeyDown, (P) => {
                          const D = P.target.closest("[data-radix-menu-content]") === P.currentTarget, U = P.ctrlKey || P.altKey || P.metaKey, F = P.key.length === 1;
                          D && (P.key === "Tab" && P.preventDefault(), !U && F && j(P.key));
                          const K = N.current;
                          if (P.target !== K || !nf.includes(P.key)) return;
                          P.preventDefault();
                          const ee = C().filter((I) => !I.disabled).map((I) => I.ref.current);
                          ui.includes(P.key) && ee.reverse(), If(ee);
                        }),
                        onBlur: G(e.onBlur, (P) => {
                          P.currentTarget.contains(P.target) || (window.clearTimeout(W.current), O.current = "");
                        }),
                        onPointerMove: G(
                          e.onPointerMove,
                          Nt((P) => {
                            const Z = P.target, D = A.current !== P.clientX;
                            if (P.currentTarget.contains(Z) && D) {
                              const U = P.clientX > A.current ? "right" : "left";
                              $.current = U, A.current = P.clientX;
                            }
                          })
                        )
                      }
                    )
                  }
                )
              }
            )
          }
        ) })
      }
    );
  }
);
vi.displayName = ye;
var gf = "MenuGroup", Cr = d.forwardRef(
  (e, t) => {
    const { __scopeMenu: n, ...r } = e;
    return /* @__PURE__ */ p(se.div, { role: "group", ...r, ref: t });
  }
);
Cr.displayName = gf;
var vf = "MenuLabel", wi = d.forwardRef(
  (e, t) => {
    const { __scopeMenu: n, ...r } = e;
    return /* @__PURE__ */ p(se.div, { ...r, ref: t });
  }
);
wi.displayName = vf;
var Xt = "MenuItem", ao = "menu.itemSelect", fn = d.forwardRef(
  (e, t) => {
    const { disabled: n = !1, onSelect: r, ...o } = e, s = d.useRef(null), i = kt(Xt, e.__scopeMenu), a = br(Xt, e.__scopeMenu), l = ie(t, s), c = d.useRef(!1), u = () => {
      const f = s.current;
      if (!n && f) {
        const v = new CustomEvent(ao, { bubbles: !0, cancelable: !0 });
        f.addEventListener(ao, (g) => r == null ? void 0 : r(g), { once: !0 }), No(f, v), v.defaultPrevented ? c.current = !1 : i.onClose();
      }
    };
    return /* @__PURE__ */ p(
      yi,
      {
        ...o,
        ref: l,
        disabled: n,
        onClick: G(e.onClick, u),
        onPointerDown: (f) => {
          var v;
          (v = e.onPointerDown) == null || v.call(e, f), c.current = !0;
        },
        onPointerUp: G(e.onPointerUp, (f) => {
          var v;
          c.current || (v = f.currentTarget) == null || v.click();
        }),
        onKeyDown: G(e.onKeyDown, (f) => {
          const v = a.searchRef.current !== "";
          n || v && f.key === " " || Wn.includes(f.key) && (f.currentTarget.click(), f.preventDefault());
        })
      }
    );
  }
);
fn.displayName = Xt;
var yi = d.forwardRef(
  (e, t) => {
    const { __scopeMenu: n, disabled: r = !1, textValue: o, ...s } = e, i = br(Xt, n), a = hi(n), l = d.useRef(null), c = ie(t, l), [u, f] = d.useState(!1), [v, g] = d.useState("");
    return d.useEffect(() => {
      const b = l.current;
      b && g((b.textContent ?? "").trim());
    }, [s.children]), /* @__PURE__ */ p(
      Et.ItemSlot,
      {
        scope: n,
        disabled: r,
        textValue: o ?? v,
        children: /* @__PURE__ */ p(ef, { asChild: !0, ...a, focusable: !r, children: /* @__PURE__ */ p(
          se.div,
          {
            role: "menuitem",
            "data-highlighted": u ? "" : void 0,
            "aria-disabled": r || void 0,
            "data-disabled": r ? "" : void 0,
            ...s,
            ref: c,
            onPointerMove: G(
              e.onPointerMove,
              Nt((b) => {
                r ? i.onItemLeave(b) : (i.onItemEnter(b), b.defaultPrevented || b.currentTarget.focus({ preventScroll: !0 }));
              })
            ),
            onPointerLeave: G(
              e.onPointerLeave,
              Nt((b) => i.onItemLeave(b))
            ),
            onFocus: G(e.onFocus, () => f(!0)),
            onBlur: G(e.onBlur, () => f(!1))
          }
        ) })
      }
    );
  }
), wf = "MenuCheckboxItem", bi = d.forwardRef(
  (e, t) => {
    const { checked: n = !1, onCheckedChange: r, ...o } = e;
    return /* @__PURE__ */ p(Ii, { scope: e.__scopeMenu, checked: n, children: /* @__PURE__ */ p(
      fn,
      {
        role: "menuitemcheckbox",
        "aria-checked": qt(n) ? "mixed" : n,
        ...o,
        ref: t,
        "data-state": Rr(n),
        onSelect: G(
          o.onSelect,
          () => r == null ? void 0 : r(qt(n) ? !0 : !n),
          { checkForDefaultPrevented: !1 }
        )
      }
    ) });
  }
);
bi.displayName = wf;
var xi = "MenuRadioGroup", [yf, bf] = Qe(
  xi,
  { value: void 0, onValueChange: () => {
  } }
), Ci = d.forwardRef(
  (e, t) => {
    const { value: n, onValueChange: r, ...o } = e, s = Me(r);
    return /* @__PURE__ */ p(yf, { scope: e.__scopeMenu, value: n, onValueChange: s, children: /* @__PURE__ */ p(Cr, { ...o, ref: t }) });
  }
);
Ci.displayName = xi;
var Si = "MenuRadioItem", Ri = d.forwardRef(
  (e, t) => {
    const { value: n, ...r } = e, o = bf(Si, e.__scopeMenu), s = n === o.value;
    return /* @__PURE__ */ p(Ii, { scope: e.__scopeMenu, checked: s, children: /* @__PURE__ */ p(
      fn,
      {
        role: "menuitemradio",
        "aria-checked": s,
        ...r,
        ref: t,
        "data-state": Rr(s),
        onSelect: G(
          r.onSelect,
          () => {
            var i;
            return (i = o.onValueChange) == null ? void 0 : i.call(o, n);
          },
          { checkForDefaultPrevented: !1 }
        )
      }
    ) });
  }
);
Ri.displayName = Si;
var Sr = "MenuItemIndicator", [Ii, xf] = Qe(
  Sr,
  { checked: !1 }
), Ei = d.forwardRef(
  (e, t) => {
    const { __scopeMenu: n, forceMount: r, ...o } = e, s = xf(Sr, n);
    return /* @__PURE__ */ p(
      Je,
      {
        present: r || qt(s.checked) || s.checked === !0,
        children: /* @__PURE__ */ p(
          se.span,
          {
            ...o,
            ref: t,
            "data-state": Rr(s.checked)
          }
        )
      }
    );
  }
);
Ei.displayName = Sr;
var Cf = "MenuSeparator", Ni = d.forwardRef(
  (e, t) => {
    const { __scopeMenu: n, ...r } = e;
    return /* @__PURE__ */ p(
      se.div,
      {
        role: "separator",
        "aria-orientation": "horizontal",
        ...r,
        ref: t
      }
    );
  }
);
Ni.displayName = Cf;
var Sf = "MenuArrow", Mi = d.forwardRef(
  (e, t) => {
    const { __scopeMenu: n, ...r } = e, o = un(n);
    return /* @__PURE__ */ p(fr, { ...o, ...r, ref: t });
  }
);
Mi.displayName = Sf;
var Rf = "MenuSub", [gm, Pi] = Qe(Rf), xt = "MenuSubTrigger", Ti = d.forwardRef(
  (e, t) => {
    const n = et(xt, e.__scopeMenu), r = kt(xt, e.__scopeMenu), o = Pi(xt, e.__scopeMenu), s = br(xt, e.__scopeMenu), i = d.useRef(null), { pointerGraceTimerRef: a, onPointerGraceIntentChange: l } = s, c = { __scopeMenu: e.__scopeMenu }, u = d.useCallback(() => {
      i.current && window.clearTimeout(i.current), i.current = null;
    }, []);
    return d.useEffect(() => u, [u]), d.useEffect(() => {
      const f = a.current;
      return () => {
        window.clearTimeout(f), l(null);
      };
    }, [a, l]), /* @__PURE__ */ p(wr, { asChild: !0, ...c, children: /* @__PURE__ */ p(
      yi,
      {
        id: o.triggerId,
        "aria-haspopup": "menu",
        "aria-expanded": n.open,
        "aria-controls": o.contentId,
        "data-state": Di(n.open),
        ...e,
        ref: Qt(t, o.onTriggerChange),
        onClick: (f) => {
          var v;
          (v = e.onClick) == null || v.call(e, f), !(e.disabled || f.defaultPrevented) && (f.currentTarget.focus(), n.open || n.onOpenChange(!0));
        },
        onPointerMove: G(
          e.onPointerMove,
          Nt((f) => {
            s.onItemEnter(f), !f.defaultPrevented && !e.disabled && !n.open && !i.current && (s.onPointerGraceIntentChange(null), i.current = window.setTimeout(() => {
              n.onOpenChange(!0), u();
            }, 100));
          })
        ),
        onPointerLeave: G(
          e.onPointerLeave,
          Nt((f) => {
            var g, b;
            u();
            const v = (g = n.content) == null ? void 0 : g.getBoundingClientRect();
            if (v) {
              const h = (b = n.content) == null ? void 0 : b.dataset.side, w = h === "right", m = w ? -5 : 5, y = v[w ? "left" : "right"], x = v[w ? "right" : "left"];
              s.onPointerGraceIntentChange({
                area: [
                  // Apply a bleed on clientX to ensure that our exit point is
                  // consistently within polygon bounds
                  { x: f.clientX + m, y: f.clientY },
                  { x: y, y: v.top },
                  { x, y: v.top },
                  { x, y: v.bottom },
                  { x: y, y: v.bottom }
                ],
                side: h
              }), window.clearTimeout(a.current), a.current = window.setTimeout(
                () => s.onPointerGraceIntentChange(null),
                300
              );
            } else {
              if (s.onTriggerLeave(f), f.defaultPrevented) return;
              s.onPointerGraceIntentChange(null);
            }
          })
        ),
        onKeyDown: G(e.onKeyDown, (f) => {
          var g;
          const v = s.searchRef.current !== "";
          e.disabled || v && f.key === " " || rf[r.dir].includes(f.key) && (n.onOpenChange(!0), (g = n.content) == null || g.focus(), f.preventDefault());
        })
      }
    ) });
  }
);
Ti.displayName = xt;
var Ai = "MenuSubContent", ki = d.forwardRef(
  (e, t) => {
    const n = pi(ye, e.__scopeMenu), { forceMount: r = n.forceMount, ...o } = e, s = et(ye, e.__scopeMenu), i = kt(ye, e.__scopeMenu), a = Pi(Ai, e.__scopeMenu), l = d.useRef(null), c = ie(t, l);
    return /* @__PURE__ */ p(Et.Provider, { scope: e.__scopeMenu, children: /* @__PURE__ */ p(Je, { present: r || s.open, children: /* @__PURE__ */ p(Et.Slot, { scope: e.__scopeMenu, children: /* @__PURE__ */ p(
      xr,
      {
        id: a.contentId,
        "aria-labelledby": a.triggerId,
        ...o,
        ref: c,
        align: "start",
        side: i.dir === "rtl" ? "left" : "right",
        disableOutsidePointerEvents: !1,
        disableOutsideScroll: !1,
        trapFocus: !1,
        onOpenAutoFocus: (u) => {
          var f;
          i.isUsingKeyboardRef.current && ((f = l.current) == null || f.focus()), u.preventDefault();
        },
        onCloseAutoFocus: (u) => u.preventDefault(),
        onFocusOutside: G(e.onFocusOutside, (u) => {
          u.target !== a.trigger && s.onOpenChange(!1);
        }),
        onEscapeKeyDown: G(e.onEscapeKeyDown, (u) => {
          i.onClose(), u.preventDefault();
        }),
        onKeyDown: G(e.onKeyDown, (u) => {
          var g;
          const f = u.currentTarget.contains(u.target), v = of[i.dir].includes(u.key);
          f && v && (s.onOpenChange(!1), (g = a.trigger) == null || g.focus(), u.preventDefault());
        })
      }
    ) }) }) });
  }
);
ki.displayName = Ai;
function Di(e) {
  return e ? "open" : "closed";
}
function qt(e) {
  return e === "indeterminate";
}
function Rr(e) {
  return qt(e) ? "indeterminate" : e ? "checked" : "unchecked";
}
function If(e) {
  const t = document.activeElement;
  for (const n of e)
    if (n === t || (n.focus(), document.activeElement !== t)) return;
}
function Ef(e, t) {
  return e.map((n, r) => e[(t + r) % e.length]);
}
function Nf(e, t, n) {
  const o = t.length > 1 && Array.from(t).every((c) => c === t[0]) ? t[0] : t, s = n ? e.indexOf(n) : -1;
  let i = Ef(e, Math.max(s, 0));
  o.length === 1 && (i = i.filter((c) => c !== n));
  const l = i.find(
    (c) => c.toLowerCase().startsWith(o.toLowerCase())
  );
  return l !== n ? l : void 0;
}
function Mf(e, t) {
  const { x: n, y: r } = e;
  let o = !1;
  for (let s = 0, i = t.length - 1; s < t.length; i = s++) {
    const a = t[s], l = t[i], c = a.x, u = a.y, f = l.x, v = l.y;
    u > r != v > r && n < (f - c) * (r - u) / (v - u) + c && (o = !o);
  }
  return o;
}
function Pf(e, t) {
  if (!t) return !1;
  const n = { x: e.clientX, y: e.clientY };
  return Mf(n, t);
}
function Nt(e) {
  return (t) => t.pointerType === "mouse" ? e(t) : void 0;
}
var Tf = mi, Af = wr, kf = gi, Df = vi, Of = Cr, _f = wi, Lf = fn, Ff = bi, $f = Ci, zf = Ri, Vf = Ei, Bf = Ni, Wf = Mi, Kf = Ti, Hf = ki, hn = "DropdownMenu", [Gf, vm] = Ve(
  hn,
  [fi]
), he = fi(), [Uf, Oi] = Gf(hn), _i = (e) => {
  const {
    __scopeDropdownMenu: t,
    children: n,
    dir: r,
    open: o,
    defaultOpen: s,
    onOpenChange: i,
    modal: a = !0
  } = e, l = he(t), c = d.useRef(null), [u, f] = dt({
    prop: o,
    defaultProp: s ?? !1,
    onChange: i,
    caller: hn
  });
  return /* @__PURE__ */ p(
    Uf,
    {
      scope: t,
      triggerId: Ye(),
      triggerRef: c,
      contentId: Ye(),
      open: u,
      onOpenChange: f,
      onOpenToggle: d.useCallback(() => f((v) => !v), [f]),
      modal: a,
      children: /* @__PURE__ */ p(Tf, { ...l, open: u, onOpenChange: f, dir: r, modal: a, children: n })
    }
  );
};
_i.displayName = hn;
var Li = "DropdownMenuTrigger", Fi = d.forwardRef(
  (e, t) => {
    const { __scopeDropdownMenu: n, disabled: r = !1, ...o } = e, s = Oi(Li, n), i = he(n);
    return /* @__PURE__ */ p(Af, { asChild: !0, ...i, children: /* @__PURE__ */ p(
      se.button,
      {
        type: "button",
        id: s.triggerId,
        "aria-haspopup": "menu",
        "aria-expanded": s.open,
        "aria-controls": s.open ? s.contentId : void 0,
        "data-state": s.open ? "open" : "closed",
        "data-disabled": r ? "" : void 0,
        disabled: r,
        ...o,
        ref: Qt(t, s.triggerRef),
        onPointerDown: G(e.onPointerDown, (a) => {
          !r && a.button === 0 && a.ctrlKey === !1 && (s.onOpenToggle(), s.open || a.preventDefault());
        }),
        onKeyDown: G(e.onKeyDown, (a) => {
          r || (["Enter", " "].includes(a.key) && s.onOpenToggle(), a.key === "ArrowDown" && s.onOpenChange(!0), ["Enter", " ", "ArrowDown"].includes(a.key) && a.preventDefault());
        })
      }
    ) });
  }
);
Fi.displayName = Li;
var jf = "DropdownMenuPortal", $i = (e) => {
  const { __scopeDropdownMenu: t, ...n } = e, r = he(t);
  return /* @__PURE__ */ p(kf, { ...r, ...n });
};
$i.displayName = jf;
var zi = "DropdownMenuContent", Vi = d.forwardRef(
  (e, t) => {
    const { __scopeDropdownMenu: n, ...r } = e, o = Oi(zi, n), s = he(n), i = d.useRef(!1);
    return /* @__PURE__ */ p(
      Df,
      {
        id: o.contentId,
        "aria-labelledby": o.triggerId,
        ...s,
        ...r,
        ref: t,
        onCloseAutoFocus: G(e.onCloseAutoFocus, (a) => {
          var l;
          i.current || (l = o.triggerRef.current) == null || l.focus(), i.current = !1, a.preventDefault();
        }),
        onInteractOutside: G(e.onInteractOutside, (a) => {
          const l = a.detail.originalEvent, c = l.button === 0 && l.ctrlKey === !0, u = l.button === 2 || c;
          (!o.modal || u) && (i.current = !0);
        }),
        style: {
          ...e.style,
          "--radix-dropdown-menu-content-transform-origin": "var(--radix-popper-transform-origin)",
          "--radix-dropdown-menu-content-available-width": "var(--radix-popper-available-width)",
          "--radix-dropdown-menu-content-available-height": "var(--radix-popper-available-height)",
          "--radix-dropdown-menu-trigger-width": "var(--radix-popper-anchor-width)",
          "--radix-dropdown-menu-trigger-height": "var(--radix-popper-anchor-height)"
        }
      }
    );
  }
);
Vi.displayName = zi;
var Yf = "DropdownMenuGroup", Xf = d.forwardRef(
  (e, t) => {
    const { __scopeDropdownMenu: n, ...r } = e, o = he(n);
    return /* @__PURE__ */ p(Of, { ...o, ...r, ref: t });
  }
);
Xf.displayName = Yf;
var qf = "DropdownMenuLabel", Bi = d.forwardRef(
  (e, t) => {
    const { __scopeDropdownMenu: n, ...r } = e, o = he(n);
    return /* @__PURE__ */ p(_f, { ...o, ...r, ref: t });
  }
);
Bi.displayName = qf;
var Zf = "DropdownMenuItem", Wi = d.forwardRef(
  (e, t) => {
    const { __scopeDropdownMenu: n, ...r } = e, o = he(n);
    return /* @__PURE__ */ p(Lf, { ...o, ...r, ref: t });
  }
);
Wi.displayName = Zf;
var Jf = "DropdownMenuCheckboxItem", Ki = d.forwardRef((e, t) => {
  const { __scopeDropdownMenu: n, ...r } = e, o = he(n);
  return /* @__PURE__ */ p(Ff, { ...o, ...r, ref: t });
});
Ki.displayName = Jf;
var Qf = "DropdownMenuRadioGroup", eh = d.forwardRef((e, t) => {
  const { __scopeDropdownMenu: n, ...r } = e, o = he(n);
  return /* @__PURE__ */ p($f, { ...o, ...r, ref: t });
});
eh.displayName = Qf;
var th = "DropdownMenuRadioItem", Hi = d.forwardRef((e, t) => {
  const { __scopeDropdownMenu: n, ...r } = e, o = he(n);
  return /* @__PURE__ */ p(zf, { ...o, ...r, ref: t });
});
Hi.displayName = th;
var nh = "DropdownMenuItemIndicator", Gi = d.forwardRef((e, t) => {
  const { __scopeDropdownMenu: n, ...r } = e, o = he(n);
  return /* @__PURE__ */ p(Vf, { ...o, ...r, ref: t });
});
Gi.displayName = nh;
var rh = "DropdownMenuSeparator", Ui = d.forwardRef((e, t) => {
  const { __scopeDropdownMenu: n, ...r } = e, o = he(n);
  return /* @__PURE__ */ p(Bf, { ...o, ...r, ref: t });
});
Ui.displayName = rh;
var oh = "DropdownMenuArrow", sh = d.forwardRef(
  (e, t) => {
    const { __scopeDropdownMenu: n, ...r } = e, o = he(n);
    return /* @__PURE__ */ p(Wf, { ...o, ...r, ref: t });
  }
);
sh.displayName = oh;
var ih = "DropdownMenuSubTrigger", ji = d.forwardRef((e, t) => {
  const { __scopeDropdownMenu: n, ...r } = e, o = he(n);
  return /* @__PURE__ */ p(Kf, { ...o, ...r, ref: t });
});
ji.displayName = ih;
var ah = "DropdownMenuSubContent", Yi = d.forwardRef((e, t) => {
  const { __scopeDropdownMenu: n, ...r } = e, o = he(n);
  return /* @__PURE__ */ p(
    Hf,
    {
      ...o,
      ...r,
      ref: t,
      style: {
        ...e.style,
        "--radix-dropdown-menu-content-transform-origin": "var(--radix-popper-transform-origin)",
        "--radix-dropdown-menu-content-available-width": "var(--radix-popper-available-width)",
        "--radix-dropdown-menu-content-available-height": "var(--radix-popper-available-height)",
        "--radix-dropdown-menu-trigger-width": "var(--radix-popper-anchor-width)",
        "--radix-dropdown-menu-trigger-height": "var(--radix-popper-anchor-height)"
      }
    }
  );
});
Yi.displayName = ah;
var lh = _i, ch = Fi, dh = $i, Xi = Vi, qi = Bi, Zi = Wi, Ji = Ki, Qi = Hi, ea = Gi, ta = Ui, na = ji, ra = Yi;
const oa = lh, sa = ch, uh = d.forwardRef(({ className: e, inset: t, children: n, ...r }, o) => /* @__PURE__ */ V(
  na,
  {
    ref: o,
    className: te(
      "flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",
      t && "pl-8",
      e
    ),
    ...r,
    children: [
      n,
      /* @__PURE__ */ p(yo, { className: "ml-auto h-4 w-4" })
    ]
  }
));
uh.displayName = na.displayName;
const fh = d.forwardRef(({ className: e, ...t }, n) => /* @__PURE__ */ p(
  ra,
  {
    ref: n,
    className: te(
      "z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
      e
    ),
    ...t
  }
));
fh.displayName = ra.displayName;
const Ir = d.forwardRef(({ className: e, sideOffset: t = 4, ...n }, r) => /* @__PURE__ */ p(dh, { children: /* @__PURE__ */ p(
  Xi,
  {
    ref: r,
    sideOffset: t,
    className: te(
      "z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
      e
    ),
    ...n
  }
) }));
Ir.displayName = Xi.displayName;
const je = d.forwardRef(({ className: e, inset: t, ...n }, r) => /* @__PURE__ */ p(
  Zi,
  {
    ref: r,
    className: te(
      "relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
      t && "pl-8",
      e
    ),
    ...n
  }
));
je.displayName = Zi.displayName;
const hh = d.forwardRef(({ className: e, children: t, checked: n, ...r }, o) => /* @__PURE__ */ V(
  Ji,
  {
    ref: o,
    className: te(
      "relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
      e
    ),
    checked: n,
    ...r,
    children: [
      /* @__PURE__ */ p("span", { className: "absolute left-2 flex h-3.5 w-3.5 items-center justify-center", children: /* @__PURE__ */ p(ea, { children: /* @__PURE__ */ p(Jt, { className: "h-4 w-4" }) }) }),
      t
    ]
  }
));
hh.displayName = Ji.displayName;
const mh = d.forwardRef(({ className: e, children: t, ...n }, r) => /* @__PURE__ */ V(
  Qi,
  {
    ref: r,
    className: te(
      "relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
      e
    ),
    ...n,
    children: [
      /* @__PURE__ */ p("span", { className: "absolute left-2 flex h-3.5 w-3.5 items-center justify-center", children: /* @__PURE__ */ p(ea, { children: /* @__PURE__ */ p(ul, { className: "h-2 w-2 fill-current" }) }) }),
      t
    ]
  }
));
mh.displayName = Qi.displayName;
const ph = d.forwardRef(({ className: e, inset: t, ...n }, r) => /* @__PURE__ */ p(
  qi,
  {
    ref: r,
    className: te("px-2 py-1.5 text-sm font-semibold", t && "pl-8", e),
    ...n
  }
));
ph.displayName = qi.displayName;
const gh = d.forwardRef(({ className: e, ...t }, n) => /* @__PURE__ */ p(ta, { ref: n, className: te("-mx-1 my-1 h-px bg-muted", e), ...t }));
gh.displayName = ta.displayName;
function vh({
  virtualItem: e,
  rowData: t,
  columns: n,
  showSelection: r = !0,
  showActions: o = !0,
  isSelected: s,
  isRowCreated: i,
  isRowModified: a,
  isRowDeleted: l,
  onRowSelect: c,
  onRowAction: u
}) {
  if (!t)
    return /* @__PURE__ */ p(
      "div",
      {
        className: "absolute left-0 right-0 flex border-b bg-red-100 dark:bg-red-900/20",
        style: {
          top: `${e.start}px`,
          height: `${e.size}px`,
          display: "flex",
          alignItems: "center",
          justifyContent: "center"
        },
        children: /* @__PURE__ */ V("div", { className: "text-red-600 text-sm", children: [
          "Missing data for index ",
          e.index
        ] })
      },
      `missing-${e.key}`
    );
  const f = t.id, v = po(f), g = d.useMemo(() => {
    let m = "absolute left-0 right-0 flex border-b hover:bg-muted/30 transition-colors bg-white dark:bg-gray-800";
    return l && f !== void 0 && f !== null && l(f) ? m += " bg-gray-100 dark:bg-gray-800/60 opacity-60 !border-l-4 !border-l-red-500" : a && f !== void 0 && f !== null && a(f) ? m += " bg-green-50 dark:bg-green-950/30 !border-l-4 !border-l-green-500" : i && f !== void 0 && f !== null && i(f) && (m += " bg-blue-50 dark:bg-blue-950/30 !border-l-4 !border-l-blue-500"), m;
  }, [i, a, l, f]), b = () => u("edit", t, e.index), h = () => u("duplicate", t, e.index), w = () => u("delete", t, e.index);
  return /* @__PURE__ */ V(
    "div",
    {
      className: g,
      style: {
        top: `${e.start}px`,
        height: `${e.size}px`,
        minHeight: `${e.size}px`,
        maxHeight: `${e.size}px`,
        overflow: "hidden",
        display: "flex",
        alignItems: "center",
        zIndex: 1
      },
      children: [
        r && /* @__PURE__ */ p("div", { className: "flex items-center justify-center w-12 border-r px-3 bg-inherit", children: /* @__PURE__ */ p(
          It,
          {
            checked: s,
            onCheckedChange: (m) => c(v, m)
          }
        ) }),
        n.map((m) => {
          const y = t[m.accessorKey], x = m.cellClassName ? typeof m.cellClassName == "function" ? m.cellClassName(y, t) : m.cellClassName : "", S = l && f !== void 0 && f !== null && l(f) ? "line-through text-gray-500" : "";
          return /* @__PURE__ */ p(
            "div",
            {
              className: `flex items-center border-r px-3 py-2 text-sm bg-inherit ${x} ${S}`,
              style: {
                textAlign: m.align || "left",
                width: m.width ? `${m.width}px` : void 0,
                minWidth: m.minWidth ? `${m.minWidth}px` : void 0,
                maxWidth: m.maxWidth ? `${m.maxWidth}px` : void 0,
                flex: m.flex ? m.flex : void 0
              },
              children: /* @__PURE__ */ p(
                "div",
                {
                  className: `${m.ellipsis ? "truncate" : ""} ${S}`,
                  title: m.showTooltip && m.ellipsis ? String(y) : void 0,
                  children: m.type === "text" && m.id === "status" ? /* @__PURE__ */ p(
                    "span",
                    {
                      className: `inline-flex items-center rounded-full px-2 py-1 text-xs font-medium ${y === "active" ? "bg-green-100 text-green-800 dark:bg-green-900/20 dark:text-green-400" : "bg-gray-100 text-gray-800 dark:bg-gray-900/20 dark:text-gray-400"}`,
                      children: y
                    }
                  ) : String(y || "")
                }
              )
            },
            m.id
          );
        }),
        o && /* @__PURE__ */ p("div", { className: "flex items-center justify-center w-12 px-3 bg-inherit", children: /* @__PURE__ */ V(oa, { children: [
          /* @__PURE__ */ p(sa, { asChild: !0, children: /* @__PURE__ */ p(Ie, { variant: "ghost", size: "icon", className: "h-6 w-6", children: /* @__PURE__ */ p(qn, { className: "h-3 w-3" }) }) }),
          /* @__PURE__ */ V(Ir, { align: "end", children: [
            /* @__PURE__ */ p(je, { onClick: b, children: "Edit" }),
            /* @__PURE__ */ p(je, { onClick: h, children: "Duplicate" }),
            /* @__PURE__ */ p(
              je,
              {
                className: "text-destructive",
                onClick: w,
                children: "Delete"
              }
            )
          ] })
        ] }) })
      ]
    },
    `virt-${e.key}-${f}`
  );
}
const wh = ze("w-full caption-bottom text-sm border-collapse", {
  variants: {
    variant: {
      default: "border border-border rounded-lg overflow-hidden",
      ghost: "",
      bordered: "border-2 border-border"
    },
    size: {
      sm: "text-xs",
      default: "text-sm",
      lg: "text-base"
    }
  },
  defaultVariants: {
    variant: "default",
    size: "default"
  }
}), ia = d.forwardRef(
  ({ className: e, variant: t, size: n, virtualScrolling: r, height: o, style: s, ...i }, a) => {
    const l = r ? { ...s, height: typeof o == "number" ? `${o}px` : o } : s;
    return /* @__PURE__ */ p("div", { className: te("relative overflow-auto", r && "max-h-full"), children: /* @__PURE__ */ p("table", { ref: a, className: te(wh({ variant: t, size: n }), e), style: l, ...i }) });
  }
);
ia.displayName = "Table";
const aa = d.forwardRef(
  ({ className: e, sticky: t, ...n }, r) => /* @__PURE__ */ p(
    "thead",
    {
      ref: r,
      className: te("border-b border-border bg-muted/50", t && "sticky top-0 z-10", e),
      ...n
    }
  )
);
aa.displayName = "TableHeader";
const la = d.forwardRef(
  ({ className: e, ...t }, n) => /* @__PURE__ */ p("tbody", { ref: n, className: te("[&_tr:last-child]:border-b-0", e), ...t })
);
la.displayName = "TableBody";
const yh = d.forwardRef(
  ({ className: e, ...t }, n) => /* @__PURE__ */ p(
    "tfoot",
    {
      ref: n,
      className: te("border-t border-border bg-muted/50 font-medium [&>tr]:last:border-b-0", e),
      ...t
    }
  )
);
yh.displayName = "TableFooter";
const bh = ze(
  "border-b border-border transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",
  {
    variants: {
      variant: {
        default: "",
        ghost: "border-transparent"
      },
      state: {
        default: "",
        selected: "bg-muted",
        hover: "hover:bg-muted/50"
      }
    },
    defaultVariants: {
      variant: "default",
      state: "default"
    }
  }
), Kn = d.forwardRef(
  ({ className: e, variant: t, state: n, selected: r, disableHover: o, ...s }, i) => /* @__PURE__ */ p(
    "tr",
    {
      ref: i,
      className: te(
        bh({ variant: t, state: n }),
        r && "data-[state=selected]:bg-muted",
        o && "hover:bg-transparent",
        e
      ),
      "data-state": r ? "selected" : void 0,
      ...s
    }
  )
);
Kn.displayName = "TableRow";
const xh = ze(
  "h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",
  {
    variants: {
      sortable: {
        true: "cursor-pointer select-none hover:text-foreground transition-colors",
        false: ""
      },
      resizable: {
        true: "relative",
        false: ""
      }
    },
    defaultVariants: {
      sortable: !1,
      resizable: !1
    }
  }
), Kt = d.forwardRef(
  ({ className: e, sortable: t, resizable: n, sortDirection: r, minWidth: o, maxWidth: s, children: i, onClick: a, ...l }, c) => {
    const u = (f) => {
      t && a && a(f);
    };
    return /* @__PURE__ */ V(
      "th",
      {
        ref: c,
        className: te(xh({ sortable: t, resizable: n }), e),
        onClick: u,
        role: t ? "columnheader button" : "columnheader",
        "aria-sort": r === "asc" ? "ascending" : r === "desc" ? "descending" : "none",
        style: {
          minWidth: o ? `${o}px` : void 0,
          maxWidth: s ? `${s}px` : void 0
        },
        ...l,
        children: [
          /* @__PURE__ */ V("div", { className: "flex items-center gap-2", children: [
            i,
            t && r && /* @__PURE__ */ p(Ch, { direction: r })
          ] }),
          n && /* @__PURE__ */ p("div", { className: "absolute right-0 top-0 h-full w-1 cursor-col-resize bg-border opacity-0 hover:opacity-100 transition-opacity" })
        ]
      }
    );
  }
);
Kt.displayName = "TableHead";
const Ch = ({ direction: e, className: t }) => /* @__PURE__ */ p("svg", { className: te("h-4 w-4", t), fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", "aria-hidden": "true", children: e === "asc" ? /* @__PURE__ */ p("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M5 15l7-7 7 7" }) : /* @__PURE__ */ p("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M19 9l-7 7-7-7" }) }), Hn = d.forwardRef(
  ({ className: e, ...t }, n) => /* @__PURE__ */ p("td", { ref: n, className: te("p-4 align-middle [&:has([role=checkbox])]:pr-0", e), ...t })
);
Hn.displayName = "TableCell";
const lo = ze(
  "flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
  {
    variants: {
      variant: {
        default: "",
        ghost: "border-transparent bg-transparent",
        filled: "bg-muted border-transparent"
      },
      inputSize: {
        default: "h-10",
        sm: "h-9",
        lg: "h-11"
      },
      state: {
        default: "",
        error: "border-destructive focus-visible:ring-destructive",
        success: "border-green-500 focus-visible:ring-green-500"
      }
    },
    defaultVariants: {
      variant: "default",
      inputSize: "default",
      state: "default"
    }
  }
), ca = d.forwardRef(
  ({
    className: e,
    type: t = "text",
    variant: n,
    inputSize: r,
    state: o,
    error: s,
    success: i,
    leftIcon: a,
    rightIcon: l,
    ...c
  }, u) => {
    const f = d.useMemo(() => s ? "error" : i ? "success" : o || "default", [s, i, o]);
    return a || l ? /* @__PURE__ */ V("div", { className: "relative", children: [
      a && /* @__PURE__ */ p("div", { className: "absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground", children: a }),
      /* @__PURE__ */ p(
        "input",
        {
          type: t,
          className: te(
            lo({ variant: n, inputSize: r, state: f }),
            a && "pl-10",
            l && "pr-10",
            e
          ),
          ref: u,
          ...c
        }
      ),
      l && /* @__PURE__ */ p("div", { className: "absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground", children: l })
    ] }) : /* @__PURE__ */ p(
      "input",
      {
        type: t,
        className: te(
          lo({ variant: n, inputSize: r, state: f }),
          e
        ),
        ref: u,
        ...c
      }
    );
  }
);
ca.displayName = "Input";
var [mn, wm] = Ve("Tooltip", [
  pt
]), pn = pt(), da = "TooltipProvider", Sh = 700, Gn = "tooltip.open", [Rh, Er] = mn(da), ua = (e) => {
  const {
    __scopeTooltip: t,
    delayDuration: n = Sh,
    skipDelayDuration: r = 300,
    disableHoverableContent: o = !1,
    children: s
  } = e, i = d.useRef(!0), a = d.useRef(!1), l = d.useRef(0);
  return d.useEffect(() => {
    const c = l.current;
    return () => window.clearTimeout(c);
  }, []), /* @__PURE__ */ p(
    Rh,
    {
      scope: t,
      isOpenDelayedRef: i,
      delayDuration: n,
      onOpen: d.useCallback(() => {
        window.clearTimeout(l.current), i.current = !1;
      }, []),
      onClose: d.useCallback(() => {
        window.clearTimeout(l.current), l.current = window.setTimeout(
          () => i.current = !0,
          r
        );
      }, [r]),
      isPointerInTransitRef: a,
      onPointerInTransitChange: d.useCallback((c) => {
        a.current = c;
      }, []),
      disableHoverableContent: o,
      children: s
    }
  );
};
ua.displayName = da;
var Mt = "Tooltip", [Ih, gn] = mn(Mt), fa = (e) => {
  const {
    __scopeTooltip: t,
    children: n,
    open: r,
    defaultOpen: o,
    onOpenChange: s,
    disableHoverableContent: i,
    delayDuration: a
  } = e, l = Er(Mt, e.__scopeTooltip), c = pn(t), [u, f] = d.useState(null), v = Ye(), g = d.useRef(0), b = i ?? l.disableHoverableContent, h = a ?? l.delayDuration, w = d.useRef(!1), [m, y] = dt({
    prop: r,
    defaultProp: o ?? !1,
    onChange: (N) => {
      N ? (l.onOpen(), document.dispatchEvent(new CustomEvent(Gn))) : l.onClose(), s == null || s(N);
    },
    caller: Mt
  }), x = d.useMemo(() => m ? w.current ? "delayed-open" : "instant-open" : "closed", [m]), C = d.useCallback(() => {
    window.clearTimeout(g.current), g.current = 0, w.current = !1, y(!0);
  }, [y]), S = d.useCallback(() => {
    window.clearTimeout(g.current), g.current = 0, y(!1);
  }, [y]), R = d.useCallback(() => {
    window.clearTimeout(g.current), g.current = window.setTimeout(() => {
      w.current = !0, y(!0), g.current = 0;
    }, h);
  }, [h, y]);
  return d.useEffect(() => () => {
    g.current && (window.clearTimeout(g.current), g.current = 0);
  }, []), /* @__PURE__ */ p(cr, { ...c, children: /* @__PURE__ */ p(
    Ih,
    {
      scope: t,
      contentId: v,
      open: m,
      stateAttribute: x,
      trigger: u,
      onTriggerChange: f,
      onTriggerEnter: d.useCallback(() => {
        l.isOpenDelayedRef.current ? R() : C();
      }, [l.isOpenDelayedRef, R, C]),
      onTriggerLeave: d.useCallback(() => {
        b ? S() : (window.clearTimeout(g.current), g.current = 0);
      }, [S, b]),
      onOpen: C,
      onClose: S,
      disableHoverableContent: b,
      children: n
    }
  ) });
};
fa.displayName = Mt;
var Un = "TooltipTrigger", ha = d.forwardRef(
  (e, t) => {
    const { __scopeTooltip: n, ...r } = e, o = gn(Un, n), s = Er(Un, n), i = pn(n), a = d.useRef(null), l = ie(t, a, o.onTriggerChange), c = d.useRef(!1), u = d.useRef(!1), f = d.useCallback(() => c.current = !1, []);
    return d.useEffect(() => () => document.removeEventListener("pointerup", f), [f]), /* @__PURE__ */ p(dr, { asChild: !0, ...i, children: /* @__PURE__ */ p(
      se.button,
      {
        "aria-describedby": o.open ? o.contentId : void 0,
        "data-state": o.stateAttribute,
        ...r,
        ref: l,
        onPointerMove: G(e.onPointerMove, (v) => {
          v.pointerType !== "touch" && !u.current && !s.isPointerInTransitRef.current && (o.onTriggerEnter(), u.current = !0);
        }),
        onPointerLeave: G(e.onPointerLeave, () => {
          o.onTriggerLeave(), u.current = !1;
        }),
        onPointerDown: G(e.onPointerDown, () => {
          o.open && o.onClose(), c.current = !0, document.addEventListener("pointerup", f, { once: !0 });
        }),
        onFocus: G(e.onFocus, () => {
          c.current || o.onOpen();
        }),
        onBlur: G(e.onBlur, o.onClose),
        onClick: G(e.onClick, o.onClose)
      }
    ) });
  }
);
ha.displayName = Un;
var Eh = "TooltipPortal", [ym, Nh] = mn(Eh, {
  forceMount: void 0
}), ut = "TooltipContent", ma = d.forwardRef(
  (e, t) => {
    const n = Nh(ut, e.__scopeTooltip), { forceMount: r = n.forceMount, side: o = "top", ...s } = e, i = gn(ut, e.__scopeTooltip);
    return /* @__PURE__ */ p(Je, { present: r || i.open, children: i.disableHoverableContent ? /* @__PURE__ */ p(pa, { side: o, ...s, ref: t }) : /* @__PURE__ */ p(Mh, { side: o, ...s, ref: t }) });
  }
), Mh = d.forwardRef((e, t) => {
  const n = gn(ut, e.__scopeTooltip), r = Er(ut, e.__scopeTooltip), o = d.useRef(null), s = ie(t, o), [i, a] = d.useState(null), { trigger: l, onClose: c } = n, u = o.current, { onPointerInTransitChange: f } = r, v = d.useCallback(() => {
    a(null), f(!1);
  }, [f]), g = d.useCallback(
    (b, h) => {
      const w = b.currentTarget, m = { x: b.clientX, y: b.clientY }, y = Dh(m, w.getBoundingClientRect()), x = Oh(m, y), C = _h(h.getBoundingClientRect()), S = Fh([...x, ...C]);
      a(S), f(!0);
    },
    [f]
  );
  return d.useEffect(() => () => v(), [v]), d.useEffect(() => {
    if (l && u) {
      const b = (w) => g(w, u), h = (w) => g(w, l);
      return l.addEventListener("pointerleave", b), u.addEventListener("pointerleave", h), () => {
        l.removeEventListener("pointerleave", b), u.removeEventListener("pointerleave", h);
      };
    }
  }, [l, u, g, v]), d.useEffect(() => {
    if (i) {
      const b = (h) => {
        const w = h.target, m = { x: h.clientX, y: h.clientY }, y = (l == null ? void 0 : l.contains(w)) || (u == null ? void 0 : u.contains(w)), x = !Lh(m, i);
        y ? v() : x && (v(), c());
      };
      return document.addEventListener("pointermove", b), () => document.removeEventListener("pointermove", b);
    }
  }, [l, u, i, c, v]), /* @__PURE__ */ p(pa, { ...e, ref: s });
}), [Ph, Th] = mn(Mt, { isInside: !1 }), Ah = /* @__PURE__ */ wl("TooltipContent"), pa = d.forwardRef(
  (e, t) => {
    const {
      __scopeTooltip: n,
      children: r,
      "aria-label": o,
      onEscapeKeyDown: s,
      onPointerDownOutside: i,
      ...a
    } = e, l = gn(ut, n), c = pn(n), { onClose: u } = l;
    return d.useEffect(() => (document.addEventListener(Gn, u), () => document.removeEventListener(Gn, u)), [u]), d.useEffect(() => {
      if (l.trigger) {
        const f = (v) => {
          const g = v.target;
          g != null && g.contains(l.trigger) && u();
        };
        return window.addEventListener("scroll", f, { capture: !0 }), () => window.removeEventListener("scroll", f, { capture: !0 });
      }
    }, [l.trigger, u]), /* @__PURE__ */ p(
      tn,
      {
        asChild: !0,
        disableOutsidePointerEvents: !1,
        onEscapeKeyDown: s,
        onPointerDownOutside: i,
        onFocusOutside: (f) => f.preventDefault(),
        onDismiss: u,
        children: /* @__PURE__ */ V(
          ur,
          {
            "data-state": l.stateAttribute,
            ...c,
            ...a,
            ref: t,
            style: {
              ...a.style,
              "--radix-tooltip-content-transform-origin": "var(--radix-popper-transform-origin)",
              "--radix-tooltip-content-available-width": "var(--radix-popper-available-width)",
              "--radix-tooltip-content-available-height": "var(--radix-popper-available-height)",
              "--radix-tooltip-trigger-width": "var(--radix-popper-anchor-width)",
              "--radix-tooltip-trigger-height": "var(--radix-popper-anchor-height)"
            },
            children: [
              /* @__PURE__ */ p(Ah, { children: r }),
              /* @__PURE__ */ p(Ph, { scope: n, isInside: !0, children: /* @__PURE__ */ p(hd, { id: l.contentId, role: "tooltip", children: o || r }) })
            ]
          }
        )
      }
    );
  }
);
ma.displayName = ut;
var ga = "TooltipArrow", kh = d.forwardRef(
  (e, t) => {
    const { __scopeTooltip: n, ...r } = e, o = pn(n);
    return Th(
      ga,
      n
    ).isInside ? null : /* @__PURE__ */ p(fr, { ...o, ...r, ref: t });
  }
);
kh.displayName = ga;
function Dh(e, t) {
  const n = Math.abs(t.top - e.y), r = Math.abs(t.bottom - e.y), o = Math.abs(t.right - e.x), s = Math.abs(t.left - e.x);
  switch (Math.min(n, r, o, s)) {
    case s:
      return "left";
    case o:
      return "right";
    case n:
      return "top";
    case r:
      return "bottom";
    default:
      throw new Error("unreachable");
  }
}
function Oh(e, t, n = 5) {
  const r = [];
  switch (t) {
    case "top":
      r.push(
        { x: e.x - n, y: e.y + n },
        { x: e.x + n, y: e.y + n }
      );
      break;
    case "bottom":
      r.push(
        { x: e.x - n, y: e.y - n },
        { x: e.x + n, y: e.y - n }
      );
      break;
    case "left":
      r.push(
        { x: e.x + n, y: e.y - n },
        { x: e.x + n, y: e.y + n }
      );
      break;
    case "right":
      r.push(
        { x: e.x - n, y: e.y - n },
        { x: e.x - n, y: e.y + n }
      );
      break;
  }
  return r;
}
function _h(e) {
  const { top: t, right: n, bottom: r, left: o } = e;
  return [
    { x: o, y: t },
    { x: n, y: t },
    { x: n, y: r },
    { x: o, y: r }
  ];
}
function Lh(e, t) {
  const { x: n, y: r } = e;
  let o = !1;
  for (let s = 0, i = t.length - 1; s < t.length; i = s++) {
    const a = t[s], l = t[i], c = a.x, u = a.y, f = l.x, v = l.y;
    u > r != v > r && n < (f - c) * (r - u) / (v - u) + c && (o = !o);
  }
  return o;
}
function Fh(e) {
  const t = e.slice();
  return t.sort((n, r) => n.x < r.x ? -1 : n.x > r.x ? 1 : n.y < r.y ? -1 : n.y > r.y ? 1 : 0), $h(t);
}
function $h(e) {
  if (e.length <= 1) return e.slice();
  const t = [];
  for (let r = 0; r < e.length; r++) {
    const o = e[r];
    for (; t.length >= 2; ) {
      const s = t[t.length - 1], i = t[t.length - 2];
      if ((s.x - i.x) * (o.y - i.y) >= (s.y - i.y) * (o.x - i.x)) t.pop();
      else break;
    }
    t.push(o);
  }
  t.pop();
  const n = [];
  for (let r = e.length - 1; r >= 0; r--) {
    const o = e[r];
    for (; n.length >= 2; ) {
      const s = n[n.length - 1], i = n[n.length - 2];
      if ((s.x - i.x) * (o.y - i.y) >= (s.y - i.y) * (o.x - i.x)) n.pop();
      else break;
    }
    n.push(o);
  }
  return n.pop(), t.length === 1 && n.length === 1 && t[0].x === n[0].x && t[0].y === n[0].y ? t : t.concat(n);
}
var zh = ua, Vh = fa, Bh = ha, va = ma;
const bm = zh, co = Vh, uo = Bh, jn = d.forwardRef(({ className: e, sideOffset: t = 4, ...n }, r) => /* @__PURE__ */ p(
  va,
  {
    ref: r,
    sideOffset: t,
    className: te(
      "z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
      e
    ),
    ...n
  }
));
jn.displayName = va.displayName;
const Wh = ze(
  "px-4 py-3 align-middle [&:has([role=checkbox])]:pr-0 transition-all duration-200 relative",
  {
    variants: {
      variant: {
        default: "",
        numeric: "text-right font-mono",
        center: "text-center"
      },
      state: {
        default: "",
        editing: "ring-2 ring-primary ring-offset-1 bg-background shadow-sm scale-[1.02] z-10 relative",
        error: "ring-2 ring-destructive ring-offset-1 bg-destructive/5 border-destructive/20",
        success: "ring-2 ring-green-500 ring-offset-1 bg-green-50 dark:bg-green-950/20",
        saved: "bg-green-200 dark:bg-green-800/50 ring-1 ring-green-300 dark:ring-green-700 transition-all duration-1200 ease-out"
      },
      size: {
        sm: "px-2 py-1 text-xs",
        default: "px-4 py-3 text-sm",
        lg: "px-6 py-4 text-base"
      },
      editable: {
        true: "cursor-pointer hover:bg-muted/30 hover:ring-1 hover:ring-muted-foreground/20 group relative",
        false: ""
      }
    },
    defaultVariants: {
      variant: "default",
      state: "default",
      size: "default",
      editable: !1
    }
  }
), wa = d.forwardRef(
  ({
    className: e,
    variant: t,
    state: n,
    size: r,
    editable: o = !1,
    isEditing: s = !1,
    value: i = "",
    inputType: a = "text",
    hasError: l = !1,
    errorMessage: c,
    hasSuccess: u = !1,
    recentlySaved: f = !1,
    placeholder: v,
    onEditStart: g,
    onEditEnd: b,
    onEditCancel: h,
    validate: w,
    disabled: m = !1,
    singleClickEdit: y = !1,
    onTabToNext: x,
    onTabToPrevious: C,
    onValueChange: S,
    enhancedMode: R = !1,
    onEnhancedMouseDown: N,
    onEnhancedMouseEnter: k,
    onEnhancedClick: W,
    onEnhancedKeyDown: O,
    children: T,
    onClick: _,
    onDoubleClick: $,
    onKeyDown: A,
    onMouseDown: H,
    onMouseEnter: L,
    ...j
  }, B) => {
    const [P, Z] = d.useState(i), [D, U] = d.useState(
      null
    ), [F, K] = d.useState(!1), [Y, ee] = d.useState(!1), I = d.useRef(null), J = d.useRef(null);
    d.useEffect(() => {
      Z(i);
    }, [i]), d.useEffect(() => {
      if (s && I.current) {
        const q = I.current, Oe = setTimeout(() => {
          q.focus(), q.select();
        }, 50);
        return () => clearTimeout(Oe);
      }
    }, [s]), d.useEffect(() => {
      if (f) {
        K(!0);
        const q = setTimeout(() => {
          K(!1);
        }, 1200);
        return () => clearTimeout(q);
      } else
        K(!1);
    }, [f]);
    const ne = d.useMemo(() => {
      const q = D || l || c;
      return s ? "editing" : q ? "error" : F ? "saved" : u && !q ? "success" : n || "default";
    }, [
      s,
      l,
      u,
      F,
      D,
      c,
      n,
      i,
      f
    ]), X = d.useMemo(
      () => D || c,
      [D, c]
    ), M = d.useCallback(
      (q) => {
        R && W && W(q), o && !m && !s && y && (g == null || g()), _ == null || _(q);
      },
      [
        R,
        W,
        o,
        m,
        s,
        y,
        g,
        _
      ]
    ), z = d.useCallback(
      (q) => {
        R && N && N(q), H == null || H(q);
      },
      [R, N, H]
    ), Q = d.useCallback(
      (q) => {
        ee(!0), R && k && k(q), L == null || L(q);
      },
      [R, k, L]
    ), re = d.useCallback(
      (q) => {
        o && !m && !s && (g == null || g()), $ == null || $(q);
      },
      [o, m, s, g, $]
    ), oe = d.useCallback(
      (q) => {
        if (s) {
          A == null || A(q);
          return;
        }
        if (R && O) {
          O(q);
          return;
        }
        !R && o && !m && !s && (q.key === "Enter" || q.key === " ") && (q.preventDefault(), g == null || g()), A == null || A(q);
      },
      [
        R,
        O,
        o,
        m,
        s,
        g,
        A
      ]
    ), de = d.useCallback(
      (q) => {
        const Oe = a === "number" ? Number(q.target.value) : q.target.value;
        if (Z(Oe), S) {
          const yt = S(Oe);
          U(yt);
        }
      },
      [a, S]
    ), ue = d.useCallback(() => {
      let q = !1;
      if (a === "number") {
        const Oe = Number(i), yt = Number(P);
        q = Oe !== yt;
      } else {
        const Oe = String(i || ""), yt = String(P || "");
        q = Oe !== yt;
      }
      q ? (U(null), b == null || b(P)) : (U(null), h == null || h());
    }, [a, i, P, b, h]), me = d.useCallback(() => {
      Z(i), U(null), h == null || h();
    }, [i, h]), be = d.useCallback(
      (q) => {
        q.key === "Enter" ? (q.preventDefault(), q.stopPropagation(), ue()) : q.key === "Escape" ? (q.preventDefault(), q.stopPropagation(), me()) : q.key === "Tab" && (q.preventDefault(), q.shiftKey ? C == null || C() : x == null || x(), ue());
      },
      [ue, me, x, C]
    ), vt = d.useCallback(
      (q) => {
        q.stopPropagation(), ue();
      },
      [ue]
    ), Ke = d.useCallback(() => {
      ee(!1);
    }, []), tt = d.useCallback(
      (q) => {
        J.current = q, typeof B == "function" ? B(q) : B && (B.current = q);
      },
      [B]
    ), De = d.useMemo(
      () => ({
        variant: t,
        state: ne,
        size: r,
        editable: o && !m
      }),
      [t, ne, r, o, m]
    ), le = d.useMemo(
      () => te(
        Wh(De),
        m && "opacity-50 cursor-not-allowed",
        e
      ),
      [De, m, e]
    ), wt = d.useMemo(
      () => te(
        "w-full h-8 border-none bg-transparent p-1 focus:ring-0 focus:ring-offset-0 text-sm",
        (D || l || c) && "text-destructive"
      ),
      [D, l, c]
    ), xa = d.useMemo(
      () => te(
        "h-3 w-3 text-muted-foreground transition-opacity duration-200",
        Y ? "opacity-60" : "opacity-0"
      ),
      [Y]
    );
    return /* @__PURE__ */ V(
      "td",
      {
        ref: tt,
        className: le,
        onClick: M,
        onDoubleClick: re,
        onKeyDown: oe,
        onMouseDown: z,
        onMouseEnter: Q,
        onMouseLeave: Ke,
        tabIndex: R || o && !m ? 0 : void 0,
        role: R || o ? "gridcell" : "cell",
        "aria-label": o && !R ? y ? "Click to edit" : "Double-click to edit" : R ? "Grid cell" : void 0,
        title: X || void 0,
        style: {
          userSelect: R ? "none" : void 0,
          cursor: R ? "cell" : void 0,
          ...j.style
        },
        ...j,
        children: [
          s ? /* @__PURE__ */ V("div", { className: "relative flex items-center gap-2", children: [
            /* @__PURE__ */ p(
              ca,
              {
                ref: I,
                type: a,
                value: P,
                onChange: de,
                onKeyDown: be,
                onBlur: vt,
                placeholder: v,
                className: wt,
                "aria-invalid": !!X,
                "aria-describedby": X ? `${j.id}-error` : void 0
              }
            ),
            /* @__PURE__ */ V("div", { className: "flex items-center gap-1 opacity-40 text-xs", children: [
              /* @__PURE__ */ p("span", { className: "text-green-600", children: "↵" }),
              /* @__PURE__ */ p("span", { className: "text-red-600", children: "Esc" })
            ] }),
            X && /* @__PURE__ */ V(co, { children: [
              /* @__PURE__ */ p(uo, { asChild: !0, children: /* @__PURE__ */ p(Or, { className: "h-4 w-4 text-destructive flex-shrink-0" }) }),
              /* @__PURE__ */ p(jn, { side: "top", className: "max-w-xs", children: /* @__PURE__ */ p("p", { className: "text-sm", children: X }) })
            ] })
          ] }) : /* @__PURE__ */ V("div", { className: "relative flex items-center justify-between group min-h-[1.5rem]", children: [
            /* @__PURE__ */ p("span", { className: "flex-1 pr-8", children: T || i }),
            /* @__PURE__ */ V("div", { className: "absolute right-0 top-1/2 -translate-y-1/2 flex items-center gap-1", children: [
              X && !s && /* @__PURE__ */ V(co, { children: [
                /* @__PURE__ */ p(uo, { asChild: !0, children: /* @__PURE__ */ p(Or, { className: "h-4 w-4 text-destructive flex-shrink-0" }) }),
                /* @__PURE__ */ p(jn, { side: "top", className: "max-w-xs", children: /* @__PURE__ */ p("p", { className: "text-sm", children: X }) })
              ] }),
              o && !m && !X && /* @__PURE__ */ p(hl, { className: xa })
            ] })
          ] }),
          X && /* @__PURE__ */ p(
            "div",
            {
              id: `${j.id}-error`,
              className: "sr-only",
              role: "alert",
              "aria-live": "polite",
              children: X
            }
          ),
          F && !X && /* @__PURE__ */ p("div", { className: "absolute top-1 right-1 pointer-events-none", children: /* @__PURE__ */ p("div", { className: "bg-green-500 text-white rounded-full p-1 shadow-sm animate-in fade-in-0 zoom-in-95 duration-300", children: /* @__PURE__ */ p(Jt, { className: "h-3 w-3" }) }) })
        ]
      }
    );
  }
);
wa.displayName = "TableCell";
function Kh({
  data: e,
  columns: t,
  sorting: n,
  selectedRows: r,
  showSelection: o = !0,
  showActions: s = !0,
  sortable: i = !0,
  isAllSelected: a,
  isIndeterminate: l,
  editingCell: c,
  recentlySavedCells: u = /* @__PURE__ */ new Set(),
  singleClickEdit: f = !1,
  validationErrors: v = {},
  isRowCreated: g,
  isRowModified: b,
  isRowDeleted: h,
  onSelectAll: w,
  onRowSelectChange: m,
  onSort: y,
  onRowAction: x,
  onEditStart: C,
  onEditCancel: S,
  onCellEditComplete: R,
  onCellValueChange: N,
  onTabToNext: k,
  onTabToPrevious: W,
  currentPosition: O,
  isCellSelected: T,
  registerCellRef: _,
  onCellMouseDown: $,
  onCellKeyDown: A,
  onCellClick: H
}) {
  const L = (D, U) => x("edit", D, U), j = (D, U) => x("duplicate", D, U), B = (D, U) => x("delete", D, U), P = d.useRef(null);
  d.useEffect(() => {
    P.current && O && P.current.focus();
  }, [O]), d.useEffect(() => {
    const D = (U) => {
      var I;
      const K = /Mac|iPod|iPhone|iPad/.test(navigator.userAgent) ? U.metaKey : U.ctrlKey, Y = document.activeElement;
      if ((Y === P.current || ((I = P.current) == null ? void 0 : I.contains(Y))) && K && A && O && ["c", "v", "x"].includes(U.key.toLowerCase())) {
        const J = {
          key: U.key,
          code: U.code,
          ctrlKey: U.ctrlKey,
          metaKey: U.metaKey,
          shiftKey: U.shiftKey,
          altKey: U.altKey,
          preventDefault: () => U.preventDefault(),
          stopPropagation: () => U.stopPropagation(),
          currentTarget: Y,
          target: Y
        };
        A(O, J);
      }
    };
    return document.addEventListener("keydown", D), () => document.removeEventListener("keydown", D);
  }, [A, O]);
  const Z = (D) => `row-${D}`;
  return /* @__PURE__ */ V("div", { className: "rounded-lg border overflow-auto", children: [
    /* @__PURE__ */ p("style", { children: `
        .enhanced-grid {
          user-select: none;
          outline: none;
        }
        .enhanced-grid:focus {
          outline: none;
        }
        .enhanced-grid .cell-selected {
          background-color: #dbeafe !important;
        }
        .enhanced-grid .dark .cell-selected {
          background-color: rgba(59, 130, 246, 0.3) !important;
        }
        .enhanced-grid .cell-range-selecting {
          background-color: #bfdbfe !important;
        }
        .enhanced-grid .dark .cell-range-selecting {
          background-color: rgba(59, 130, 246, 0.5) !important;
        }
        .enhanced-grid td {
          cursor: cell;
          position: relative;
        }
        /* 브라우저 기본 포커스 스타일 제거 - JavaScript로 제어 */
        .enhanced-grid td:focus {
          outline: none !important;
          background-color: transparent !important;
        }
        .enhanced-grid td[tabindex="0"] {
          outline: none !important;
        }
        .enhanced-grid td[tabindex="0"]:focus {
          outline: none !important;
          background-color: transparent !important;
        }
      ` }),
    /* @__PURE__ */ V(
      ia,
      {
        ref: P,
        className: "enhanced-grid",
        tabIndex: 0,
        role: "grid",
        onKeyDown: (D) => {
          O && A && A(O, D);
        },
        children: [
          /* @__PURE__ */ p(aa, { children: /* @__PURE__ */ V(Kn, { children: [
            o && /* @__PURE__ */ p(Kt, { className: "w-12", children: /* @__PURE__ */ p(
              It,
              {
                checked: a,
                indeterminate: l,
                onCheckedChange: (D) => {
                  typeof D == "boolean" && w(D);
                },
                "aria-label": "Select all rows"
              }
            ) }),
            t.map((D) => {
              const U = n.find((F) => F.id === D.id);
              return /* @__PURE__ */ p(
                Kt,
                {
                  className: `
                    ${i && D.sortable ? "cursor-pointer hover:bg-muted/50" : ""}
                    ${D.headerClassName || ""}
                  `,
                  style: {
                    textAlign: D.headerAlign || D.align || "left",
                    width: D.width ? `${D.width}px` : void 0,
                    minWidth: D.minWidth ? `${D.minWidth}px` : void 0,
                    maxWidth: D.maxWidth ? `${D.maxWidth}px` : void 0,
                    flex: D.flex ? D.flex : void 0
                  },
                  onClick: () => {
                    i && D.sortable && y(D.id);
                  },
                  children: /* @__PURE__ */ V("div", { className: "flex items-center gap-1", children: [
                    /* @__PURE__ */ p("span", { className: D.ellipsis ? "truncate" : "", children: D.header }),
                    i && D.sortable && /* @__PURE__ */ p("span", { className: "text-muted-foreground", children: U ? U.desc ? "↓" : "↑" : "↕️" })
                  ] })
                },
                D.id
              );
            }),
            s && /* @__PURE__ */ p(Kt, { className: "w-12", children: "Actions" })
          ] }) }),
          /* @__PURE__ */ p(la, { children: e.map((D, U) => {
            const F = D.id ?? U, K = Z(F);
            let Y = "transition-colors duration-200";
            return t.some((I) => {
              const J = `${F}-${I.id}`;
              return !!(v != null && v[J]);
            }) ? Y += " bg-red-50 dark:bg-red-950/30 !border-l-4 !border-l-red-500 hover:bg-red-100 dark:hover:bg-red-950/50" : h && F !== void 0 && F !== null && h(F) ? Y += " bg-gray-100 dark:bg-gray-800/60 !border-l-4 !border-l-gray-400 opacity-60 hover:bg-gray-200 dark:hover:bg-gray-800/80" : b && F !== void 0 && F !== null && b(F) ? Y += " bg-green-50 dark:bg-green-950/30 !border-l-4 !border-l-green-500 hover:bg-green-100 dark:hover:bg-green-950/50" : g && F !== void 0 && F !== null && g(F) && (Y += " bg-blue-50 dark:bg-blue-950/30 !border-l-4 !border-l-blue-500 hover:bg-blue-100 dark:hover:bg-blue-950/50"), /* @__PURE__ */ V(Kn, { className: Y, children: [
              o && /* @__PURE__ */ p(Hn, { children: /* @__PURE__ */ p(
                It,
                {
                  checked: r.has(K),
                  onCheckedChange: (I) => {
                    typeof I == "boolean" && (m == null || m(K, I));
                  },
                  onClick: (I) => {
                    I.stopPropagation();
                  },
                  "aria-label": `Select row ${U + 1}`
                }
              ) }),
              t.map((I, J) => {
                var tt, De;
                const ne = D[I.accessorKey], X = (c == null ? void 0 : c.rowId) === K && (c == null ? void 0 : c.field) === I.id;
                let M = I.type && ["text", "number", "email"].includes(I.type);
                I.editable !== void 0 && (typeof I.editable == "function" ? M = M && I.editable(D, U) : M = M && I.editable);
                const z = `${F}-${I.id}`, Q = !!(v != null && v[z]), re = v == null ? void 0 : v[z], oe = I.cellClassName ? typeof I.cellClassName == "function" ? I.cellClassName(ne, D) : I.cellClassName : "", ue = h && F !== void 0 && F !== null && h(F) ? "line-through text-gray-500" : "", me = {
                  rowIndex: U,
                  columnIndex: J
                }, be = (O == null ? void 0 : O.rowIndex) === U && (O == null ? void 0 : O.columnIndex) === J, vt = T ? T(me) : !1;
                let Ke = `${oe} ${ue}`;
                return be && (Ke += " ring-2 ring-blue-500 ring-inset bg-blue-50 dark:bg-blue-900/20"), vt && !be && (Ke += " bg-blue-100 dark:bg-blue-900/30"), /* @__PURE__ */ p(
                  wa,
                  {
                    ref: (le) => {
                      _ && _(me, le);
                    },
                    tabIndex: 0,
                    variant: I.type === "number" ? "numeric" : "default",
                    editable: M,
                    value: ne,
                    inputType: I.type === "email" ? "email" : I.type === "number" ? "number" : "text",
                    singleClickEdit: f,
                    recentlySaved: u.has(
                      `${K}-${I.id}`
                    ),
                    isEditing: X,
                    onEditStart: () => M && (C == null ? void 0 : C(K, I.id)),
                    onEditEnd: (le) => R == null ? void 0 : R(K, I.id, le),
                    onEditCancel: S,
                    onTabToNext: () => k == null ? void 0 : k(K, I.id, e.length),
                    onTabToPrevious: () => W == null ? void 0 : W(K, I.id),
                    validate: M && I.validation ? (le) => {
                      const wt = Pn(
                        le,
                        I,
                        D
                      );
                      return wt || !0;
                    } : void 0,
                    placeholder: `Enter ${I.header.toLowerCase()}`,
                    hasError: Q,
                    errorMessage: re,
                    onValueChange: N && (((tt = I == null ? void 0 : I.validation) == null ? void 0 : tt.validateOn) === "realtime" || ((De = I == null ? void 0 : I.validation) == null ? void 0 : De.validateOn) === "both") ? (le) => (N(K, I.id, le), I.validation && Pn(
                      le,
                      I,
                      D
                    ) || null) : void 0,
                    enhancedMode: !0,
                    onEnhancedMouseDown: (le) => {
                      $ && $(me, le);
                    },
                    onEnhancedClick: (le) => {
                      H && H(me, le);
                    },
                    onEnhancedKeyDown: (le) => {
                      A && A(me, le);
                    },
                    className: Ke,
                    style: {
                      textAlign: I.align || "left",
                      width: I.width ? `${I.width}px` : void 0,
                      minWidth: I.minWidth ? `${I.minWidth}px` : void 0,
                      maxWidth: I.maxWidth ? `${I.maxWidth}px` : void 0,
                      flex: I.flex ? I.flex : void 0
                    },
                    children: /* @__PURE__ */ p(
                      "div",
                      {
                        className: `${I.ellipsis ? "truncate" : ""} ${ue}`,
                        title: I.showTooltip && I.ellipsis ? String(ne) : void 0,
                        children: I.type === "text" && I.id === "status" ? /* @__PURE__ */ p(
                          "span",
                          {
                            className: `inline-flex items-center rounded-full px-2 py-1 text-xs font-medium ${ne === "active" ? "bg-green-100 text-green-800 dark:bg-green-900/20 dark:text-green-400" : "bg-gray-100 text-gray-800 dark:bg-gray-900/20 dark:text-gray-400"}`,
                            children: ne
                          }
                        ) : ne
                      }
                    )
                  },
                  I.id
                );
              }),
              s && /* @__PURE__ */ p(Hn, { children: /* @__PURE__ */ V(oa, { children: [
                /* @__PURE__ */ p(sa, { asChild: !0, children: /* @__PURE__ */ p(Ie, { variant: "ghost", size: "icon", children: /* @__PURE__ */ p(qn, { className: "h-4 w-4" }) }) }),
                /* @__PURE__ */ V(Ir, { align: "end", children: [
                  /* @__PURE__ */ p(
                    je,
                    {
                      onClick: () => L(D, U),
                      children: "Edit"
                    }
                  ),
                  /* @__PURE__ */ p(
                    je,
                    {
                      onClick: () => j(D, U),
                      children: "Duplicate"
                    }
                  ),
                  /* @__PURE__ */ p(
                    je,
                    {
                      className: "text-destructive",
                      onClick: () => B(D, U),
                      children: "Delete"
                    }
                  )
                ] })
              ] }) })
            ] }, K);
          }) })
        ]
      }
    )
  ] });
}
function Hh({
  data: e,
  columns: t,
  sorting: n,
  selectedRows: r,
  virtualizationConfig: o,
  virtualization: s,
  containerRef: i,
  showSelection: a = !0,
  showActions: l = !0,
  sortable: c = !0,
  isAllSelected: u,
  isIndeterminate: f,
  isRowCreated: v,
  isRowModified: g,
  isRowDeleted: b,
  onSelectAll: h,
  onRowSelect: w,
  onSort: m,
  onRowAction: y
}) {
  return /* @__PURE__ */ V("div", { className: "rounded-lg border overflow-hidden", children: [
    /* @__PURE__ */ p(
      Wu,
      {
        columns: t,
        sorting: n,
        showSelection: a,
        showActions: l,
        isAllSelected: u,
        isIndeterminate: f,
        onSelectAll: h,
        onSort: m,
        sortable: c
      }
    ),
    /* @__PURE__ */ p(
      "div",
      {
        ref: i,
        className: "relative",
        style: {
          height: `${o.containerHeight}px`,
          overflowY: "auto",
          overflowX: "hidden"
        },
        children: /* @__PURE__ */ p(
          "div",
          {
            style: {
              height: `${s.scrollInfo.totalHeight}px`,
              position: "relative",
              width: "100%"
            },
            children: s.virtualItems.length === 0 ? /* @__PURE__ */ V("div", { className: "p-4 text-center text-muted-foreground", children: [
              /* @__PURE__ */ p("div", { children: "No virtual items to display" }),
              /* @__PURE__ */ V("div", { className: "text-xs mt-2", children: [
                "Data length: ",
                e.length,
                " | Container ref:",
                " ",
                i.current ? "Yes" : "No"
              ] })
            ] }) : s.virtualItems.map((x) => {
              const C = e[x.index], S = C ? C.id ?? x.index : x.index, R = po(S), N = r.has(R);
              return /* @__PURE__ */ p(
                vh,
                {
                  virtualItem: x,
                  rowData: C,
                  columns: t,
                  showSelection: a,
                  showActions: l,
                  isSelected: N,
                  isRowCreated: v,
                  isRowModified: g,
                  isRowDeleted: b,
                  onRowSelect: w,
                  onRowAction: y
                },
                `virt-${x.key}-${S}`
              );
            })
          }
        )
      }
    )
  ] });
}
function we({
  className: e,
  ...t
}) {
  return /* @__PURE__ */ p(
    "div",
    {
      className: te("animate-pulse rounded-md bg-muted", e),
      ...t
    }
  );
}
function Gh({
  rows: e = 5,
  columns: t = 4,
  showHeader: n = !0,
  showControls: r = !0,
  className: o = ""
}) {
  return /* @__PURE__ */ V("div", { className: `space-y-4 ${o}`, children: [
    n && /* @__PURE__ */ p("div", { className: "flex items-center justify-between", children: /* @__PURE__ */ p(we, { className: "h-6 w-48" }) }),
    r && /* @__PURE__ */ V("div", { className: "flex items-center justify-between", children: [
      /* @__PURE__ */ V("div", { className: "flex items-center gap-2", children: [
        /* @__PURE__ */ p(we, { className: "h-4 w-16" }),
        /* @__PURE__ */ p(we, { className: "h-4 w-24" })
      ] }),
      /* @__PURE__ */ V("div", { className: "flex items-center gap-2", children: [
        /* @__PURE__ */ p(we, { className: "h-8 w-20" }),
        /* @__PURE__ */ p(we, { className: "h-8 w-24" })
      ] })
    ] }),
    /* @__PURE__ */ V("div", { className: "border rounded-md", children: [
      /* @__PURE__ */ p("div", { className: "border-b p-4", children: /* @__PURE__ */ p("div", { className: "flex items-center gap-4", children: Array.from({ length: t }).map((s, i) => /* @__PURE__ */ p(we, { className: "h-4 flex-1" }, `header-${i}`)) }) }),
      /* @__PURE__ */ p("div", { className: "divide-y", children: Array.from({ length: e }).map((s, i) => /* @__PURE__ */ p("div", { className: "p-4", children: /* @__PURE__ */ p("div", { className: "flex items-center gap-4", children: Array.from({ length: t }).map((a, l) => /* @__PURE__ */ p(
        we,
        {
          className: "h-4 flex-1"
        },
        `cell-${i}-${l}`
      )) }) }, `row-${i}`)) })
    ] }),
    /* @__PURE__ */ V("div", { className: "flex items-center justify-between", children: [
      /* @__PURE__ */ p(we, { className: "h-4 w-32" }),
      /* @__PURE__ */ V("div", { className: "flex items-center gap-2", children: [
        /* @__PURE__ */ p(we, { className: "h-8 w-8" }),
        /* @__PURE__ */ p(we, { className: "h-8 w-8" }),
        /* @__PURE__ */ p(we, { className: "h-8 w-8" }),
        /* @__PURE__ */ p(we, { className: "h-8 w-8" })
      ] })
    ] })
  ] });
}
function Uh({
  error: e,
  title: t = "Something went wrong",
  onRetry: n,
  className: r = ""
}) {
  return /* @__PURE__ */ V(
    "div",
    {
      className: `flex flex-col items-center justify-center py-16 ${r} border rounded-md`,
      children: [
        /* @__PURE__ */ p("div", { className: "mb-4 text-destructive", children: /* @__PURE__ */ p(pl, { className: "h-12 w-12" }) }),
        /* @__PURE__ */ V("div", { className: "text-center space-y-2", children: [
          /* @__PURE__ */ p("h3", { className: "text-lg font-semibold text-foreground", children: t }),
          /* @__PURE__ */ p("p", { className: "text-sm text-muted-foreground max-w-sm", children: e })
        ] }),
        n && /* @__PURE__ */ p("div", { className: "mt-6", children: /* @__PURE__ */ V(Ie, { onClick: n, variant: "outline", className: "gap-2", children: [
          /* @__PURE__ */ p(ml, { className: "h-4 w-4" }),
          "Try again"
        ] }) })
      ]
    }
  );
}
function jh({
  title: e = "No data available",
  description: t = "There is no data to display at the moment.",
  icon: n,
  className: r = ""
}) {
  return /* @__PURE__ */ V(
    "div",
    {
      className: `flex flex-col items-center justify-center py-16 ${r} border rounded-md`,
      children: [
        n && /* @__PURE__ */ p("div", { className: "mb-4 text-muted-foreground", children: n }),
        !n && /* @__PURE__ */ p("div", { className: "mb-4 text-muted-foreground", children: /* @__PURE__ */ p(
          "svg",
          {
            className: "h-12 w-12",
            fill: "none",
            stroke: "currentColor",
            viewBox: "0 0 24 24",
            children: /* @__PURE__ */ p(
              "path",
              {
                strokeLinecap: "round",
                strokeLinejoin: "round",
                strokeWidth: 1.5,
                d: "M20 13V6a2 2 0 00-2-2H6a2 2 0 00-2 2v7m16 0v5a2 2 0 01-2 2H6a2 2 0 01-2-2v-5m16 0h-4.586a1 1 0 00-.707.293L16 14H8l-2.707-1.414A1 1 0 004.586 13H0"
              }
            )
          }
        ) }),
        /* @__PURE__ */ V("div", { className: "text-center space-y-2", children: [
          /* @__PURE__ */ p("h3", { className: "text-lg font-semibold text-foreground", children: e }),
          /* @__PURE__ */ p("p", { className: "text-sm text-muted-foreground max-w-sm", children: t })
        ] })
      ]
    }
  );
}
const zt = {
  sorting: !0,
  filtering: !0,
  pagination: {
    enabled: !0,
    pageSize: 10,
    showPageSizeSelector: !0,
    showPageInfo: !0,
    showFirstLast: !0,
    siblingCount: 1
  },
  editing: !0,
  selection: !0,
  globalSearch: !0
}, Yn = {
  enabled: !0,
  rowHeight: 50,
  overscan: 10,
  estimatedRowHeight: 50,
  containerHeight: 600
};
function Yh(e) {
  return e ? e === !0 ? Yn : { ...Yn, ...e } : null;
}
function Xh(e) {
  const {
    data: t,
    columns: n,
    editable: r = !0,
    selectable: o = !0,
    sortable: s = !0,
    filterable: i = !0,
    pageSize: a = 10,
    showPagination: l = !0,
    showGlobalSearch: c = !0,
    showPageSizeSelector: u = !0,
    pageSizeOptions: f,
    virtualized: v = !1,
    virtualRowHeight: g = 50,
    virtualContainerHeight: b = 600,
    onRowSelect: h,
    onCellEdit: w,
    onRowAction: m,
    ...y
  } = e;
  return {
    initialData: t,
    columns: n,
    features: {
      sorting: s,
      filtering: i,
      pagination: l ? {
        enabled: !0,
        pageSize: a,
        showPageSizeSelector: u,
        pageSizeOptions: f,
        showPageInfo: !0,
        showFirstLast: !0,
        siblingCount: 1
      } : !1,
      editing: r,
      selection: o,
      globalSearch: c,
      virtualization: v ? {
        enabled: !0,
        rowHeight: g,
        containerHeight: b,
        overscan: 10
      } : !1
    },
    onRowSelect: h,
    onCellEdit: w,
    onRowAction: m,
    ...y
  };
}
function qh(e) {
  return {
    addRow: e.addRow,
    deleteRow: e.deleteRow,
    deleteRows: e.deleteRows,
    updateRow: e.updateRow,
    updateRows: e.updateRows,
    getSelectedRows: e.getSelectedRows,
    getSelectedIds: e.getSelectedIds,
    selectRow: e.selectRow,
    selectAll: e.selectAll,
    clearSelection: e.clearSelection,
    startEdit: e.startEdit,
    cancelEdit: e.cancelEdit,
    getChanges: e.getChanges,
    getChangesSummary: e.getChangesSummary,
    commitChanges: e.commitChanges,
    resetChanges: e.resetChanges,
    hasChanges: e.hasChanges,
    validateRow: (t) => e.validateRow(t, "submit"),
    clearValidationErrors: e.clearAllValidationErrors,
    hasValidationErrors: e.hasValidationErrors
  };
}
const xm = d.forwardRef(
  (e, t) => {
    if (!("features" in e)) {
      const r = e, o = Xh(r), s = Ha(o), i = qh(s);
      return d.useImperativeHandle(t, () => i, [i]), d.useEffect(() => {
        r.onGridReady && r.onGridReady(i);
      }, [i, r.onGridReady]), /* @__PURE__ */ p(fo, { ...s.tableProps });
    } else
      return /* @__PURE__ */ p(fo, { ...e });
  }
);
function fo({
  data: e,
  columns: t,
  features: n = zt,
  className: r,
  style: o,
  title: s = "LumGrid - Simple by Design, Profound by Nature",
  showHeader: i = !0,
  showControls: a = !0,
  loading: l,
  error: c,
  sorting: u = [],
  selectedRows: f = /* @__PURE__ */ new Set(),
  isAllSelected: v = !1,
  isIndeterminate: g = !1,
  selectedCount: b = 0,
  totalCount: h = 0,
  filteredCount: w = 0,
  currentPage: m = 0,
  totalPages: y = 1,
  currentPageSize: x = 10,
  editingCell: C,
  recentlySavedCells: S = /* @__PURE__ */ new Set(),
  singleClickEdit: R = !1,
  validationErrors: N = {},
  onRowSelect: k,
  onSelectAll: W,
  onRowSelectChange: O,
  onSort: T,
  onPageChange: _,
  onPageSizeChange: $,
  onEditStart: A,
  onEditCancel: H,
  onCellEditComplete: L,
  onCellValueChange: j,
  isRowCreated: B,
  isRowModified: P,
  isRowDeleted: Z,
  leftSlot: D,
  rightSlot: U,
  centerSlot: F,
  currentPosition: K,
  selectedCell: Y,
  isCellSelected: ee,
  registerCellRef: I,
  onCellMouseDown: J,
  onCellKeyDown: ne,
  onCellClick: X
}) {
  var De;
  const M = { ...zt, ...n }, z = Yh(
    M.virtualization
  ), Q = !!(z != null && z.enabled), re = d.useRef(null), oe = rl({
    data: e,
    config: z || Yn,
    containerRef: re,
    enabled: Q
  }), de = d.useMemo(() => ({
    totalCount: h || e.length,
    filteredCount: w || e.length
  }), [h, w, e.length]), ue = d.useMemo(() => !Q && !!M.pagination && (M.pagination === !0 || typeof M.pagination == "object" && M.pagination.enabled), [M.pagination, Q]), me = d.useMemo(() => {
    const le = M.pagination;
    return le ? le === !0 ? zt.pagination : {
      ...zt.pagination,
      ...le
    } : {
      enabled: !1,
      pageSize: 10,
      showPageSizeSelector: !1,
      showPageInfo: !1,
      showFirstLast: !1,
      siblingCount: 1
    };
  }, [M.pagination]), be = () => {
    re.current && (re.current.scrollTop = 0, oe.scrollToTop());
  }, vt = () => {
    const le = Math.floor(e.length / 2);
    re.current && (re.current.scrollTop = le * 50, oe.scrollToIndex(le));
  }, Ke = () => {
    re.current && (re.current.scrollTop = re.current.scrollHeight - re.current.clientHeight, oe.scrollToBottom());
  }, tt = () => {
    const le = Math.floor(Math.random() * e.length);
    re.current && (re.current.scrollTop = le * 50, oe.scrollToIndex(le));
  };
  return l ? /* @__PURE__ */ p(Gh, { columns: t.length }) : c ? /* @__PURE__ */ p(Uh, { error: c }) : e.length === 0 ? /* @__PURE__ */ p(jh, {}) : /* @__PURE__ */ V("div", { className: `space-y-4 ${r}`, style: o, children: [
    i && /* @__PURE__ */ p(Sl, { title: s }),
    a && /* @__PURE__ */ p(
      ku,
      {
        totalCount: de.totalCount,
        filteredCount: de.filteredCount,
        selectedCount: b || 0,
        features: {
          pageSizeSelector: typeof M.pagination == "object" && ((De = M.pagination) == null ? void 0 : De.showPageSizeSelector)
        },
        currentPageSize: x || 10,
        pageSizeOptions: [5, 10, 20, 50, 100],
        onPageSizeChange: $,
        leftSlot: D,
        centerSlot: F,
        rightSlot: U
      }
    ),
    Q && /* @__PURE__ */ p(
      Du,
      {
        totalCount: e.length,
        visibleCount: oe.virtualItems.length,
        scrollInfo: {
          visibleStartIndex: oe.scrollInfo.visibleStartIndex,
          visibleEndIndex: oe.scrollInfo.visibleEndIndex,
          totalHeight: oe.scrollInfo.totalHeight
        },
        onScrollToTop: be,
        onScrollToMiddle: vt,
        onScrollToBottom: Ke,
        onScrollToRandom: tt
      }
    ),
    Q ? /* @__PURE__ */ p(
      Hh,
      {
        data: e,
        columns: t,
        sorting: u,
        selectedRows: f,
        virtualizationConfig: z,
        virtualization: oe,
        containerRef: re,
        showSelection: M.selection,
        showActions: !0,
        sortable: M.sorting,
        isAllSelected: v,
        isIndeterminate: g,
        isRowCreated: B,
        isRowModified: P,
        isRowDeleted: Z,
        onSelectAll: W || (() => {
        }),
        onRowSelect: O || (() => {
        }),
        onSort: T || (() => {
        }),
        onRowAction: () => {
        }
      }
    ) : /* @__PURE__ */ p(
      Kh,
      {
        data: e,
        columns: t,
        sorting: u,
        selectedRows: f,
        showSelection: M.selection,
        showActions: !0,
        sortable: M.sorting,
        isAllSelected: v,
        isIndeterminate: g,
        editingCell: C,
        recentlySavedCells: S,
        singleClickEdit: R,
        validationErrors: N,
        isRowCreated: B,
        isRowModified: P,
        isRowDeleted: Z,
        onSelectAll: W || (() => {
        }),
        onRowSelect: k || (() => {
        }),
        onRowSelectChange: O || (() => {
        }),
        onSort: T || (() => {
        }),
        onRowAction: () => {
        },
        onEditStart: A || (() => {
        }),
        onEditCancel: H || (() => {
        }),
        onCellEditComplete: L || (() => {
        }),
        onCellValueChange: j,
        onTabToNext: () => {
        },
        onTabToPrevious: () => {
        },
        currentPosition: K,
        selectedCell: Y,
        isCellSelected: ee,
        registerCellRef: I,
        onCellMouseDown: J,
        onCellKeyDown: ne,
        onCellClick: X
      }
    ),
    ue && /* @__PURE__ */ p(
      Cl,
      {
        currentPage: m || 0,
        totalPages: y || 1,
        pageSize: x || 10,
        totalCount: de.filteredCount,
        onPageChange: _ || (() => {
        }),
        onPageSizeChange: $ || (() => {
        }),
        showInfo: me.showPageInfo,
        showFirstLast: me.showFirstLast,
        siblingCount: me.siblingCount
      }
    )
  ] });
}
var Zh = (e, t, n, r, o, s, i, a) => {
  let l = document.documentElement, c = ["light", "dark"];
  function u(g) {
    (Array.isArray(e) ? e : [e]).forEach((b) => {
      let h = b === "class", w = h && s ? o.map((m) => s[m] || m) : o;
      h ? (l.classList.remove(...w), l.classList.add(s && s[g] ? s[g] : g)) : l.setAttribute(b, g);
    }), f(g);
  }
  function f(g) {
    a && c.includes(g) && (l.style.colorScheme = g);
  }
  function v() {
    return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
  }
  if (r) u(r);
  else try {
    let g = localStorage.getItem(t) || n, b = i && g === "system" ? v() : g;
    u(b);
  } catch {
  }
}, ho = ["light", "dark"], ya = "(prefers-color-scheme: dark)", Jh = typeof window > "u", ba = d.createContext(void 0), Qh = (e) => d.useContext(ba) ? d.createElement(d.Fragment, null, e.children) : d.createElement(tm, { ...e }), em = ["light", "dark"], tm = ({ forcedTheme: e, disableTransitionOnChange: t = !1, enableSystem: n = !0, enableColorScheme: r = !0, storageKey: o = "theme", themes: s = em, defaultTheme: i = n ? "system" : "light", attribute: a = "data-theme", value: l, children: c, nonce: u, scriptProps: f }) => {
  let [v, g] = d.useState(() => rm(o, i)), [b, h] = d.useState(() => v === "system" ? Nn() : v), w = l ? Object.values(l) : s, m = d.useCallback((S) => {
    let R = S;
    if (!R) return;
    S === "system" && n && (R = Nn());
    let N = l ? l[R] : R, k = t ? om(u) : null, W = document.documentElement, O = (T) => {
      T === "class" ? (W.classList.remove(...w), N && W.classList.add(N)) : T.startsWith("data-") && (N ? W.setAttribute(T, N) : W.removeAttribute(T));
    };
    if (Array.isArray(a) ? a.forEach(O) : O(a), r) {
      let T = ho.includes(i) ? i : null, _ = ho.includes(R) ? R : T;
      W.style.colorScheme = _;
    }
    k == null || k();
  }, [u]), y = d.useCallback((S) => {
    let R = typeof S == "function" ? S(v) : S;
    g(R);
    try {
      localStorage.setItem(o, R);
    } catch {
    }
  }, [v]), x = d.useCallback((S) => {
    let R = Nn(S);
    h(R), v === "system" && n && !e && m("system");
  }, [v, e]);
  d.useEffect(() => {
    let S = window.matchMedia(ya);
    return S.addListener(x), x(S), () => S.removeListener(x);
  }, [x]), d.useEffect(() => {
    let S = (R) => {
      R.key === o && (R.newValue ? g(R.newValue) : y(i));
    };
    return window.addEventListener("storage", S), () => window.removeEventListener("storage", S);
  }, [y]), d.useEffect(() => {
    m(e ?? v);
  }, [e, v]);
  let C = d.useMemo(() => ({ theme: v, setTheme: y, forcedTheme: e, resolvedTheme: v === "system" ? b : v, themes: n ? [...s, "system"] : s, systemTheme: n ? b : void 0 }), [v, y, e, b, n, s]);
  return d.createElement(ba.Provider, { value: C }, d.createElement(nm, { forcedTheme: e, storageKey: o, attribute: a, enableSystem: n, enableColorScheme: r, defaultTheme: i, value: l, themes: s, nonce: u, scriptProps: f }), c);
}, nm = d.memo(({ forcedTheme: e, storageKey: t, attribute: n, enableSystem: r, enableColorScheme: o, defaultTheme: s, value: i, themes: a, nonce: l, scriptProps: c }) => {
  let u = JSON.stringify([n, t, s, e, a, i, r, o]).slice(1, -1);
  return d.createElement("script", { ...c, suppressHydrationWarning: !0, nonce: typeof window > "u" ? l : "", dangerouslySetInnerHTML: { __html: `(${Zh.toString()})(${u})` } });
}), rm = (e, t) => {
  if (Jh) return;
  let n;
  try {
    n = localStorage.getItem(e) || void 0;
  } catch {
  }
  return n || t;
}, om = (e) => {
  let t = document.createElement("style");
  return e && t.setAttribute("nonce", e), t.appendChild(document.createTextNode("*,*::before,*::after{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}")), document.head.appendChild(t), () => {
    window.getComputedStyle(document.body), setTimeout(() => {
      document.head.removeChild(t);
    }, 1);
  };
}, Nn = (e) => (e || (e = window.matchMedia(ya)), e.matches ? "dark" : "light");
function Cm({ children: e, ...t }) {
  return /* @__PURE__ */ p(Qh, { ...t, children: e });
}
function sm(e) {
  var O;
  if (!e.rowManager)
    throw new Error("useGridState: rowManager is required");
  const t = ce(
    () => e.initialSorting || [],
    [e.initialSorting]
  ), n = ce(
    () => e.initialFiltering || {},
    [e.initialFiltering]
  ), r = ce(
    () => {
      var T;
      return {
        pageIndex: 0,
        pageSize: 10,
        totalCount: ((T = e.rowManager) == null ? void 0 : T.getLength()) || 0,
        ...e.initialPagination
      };
    },
    [e.initialPagination, e.rowManager]
  ), [o, s] = ae(t), [i, a] = ae(n), [l, c] = ae(r), [u, f] = ae(0), v = ce(() => {
    if (o.length === 0)
      return;
    const T = o[0], _ = e.columns.find(($) => $.id === T.id);
    if (_)
      return e.rowManager.sort(($, A) => {
        let H = $[_.accessorKey], L = A[_.accessorKey];
        if (_.sortFn) {
          const j = _.sortFn(H, L);
          return T.desc ? -j : j;
        }
        return H == null && (H = ""), L == null && (L = ""), H < L ? T.desc ? 1 : -1 : H > L ? T.desc ? -1 : 1 : 0;
      });
  }, [e.rowManager, e.columns, o, e.dataVersion]), g = ce(() => {
    const T = Object.keys(i);
    return T.length === 0 ? v : e.rowManager.filter((_, $) => T.every((A) => {
      const H = e.columns.find((Z) => Z.id === A);
      if (!H) return !0;
      const L = _[H.accessorKey], j = i[A];
      if (H.filterFn)
        return H.filterFn(L, j);
      if (j == null || j === "")
        return !0;
      const B = String(L || "").toLowerCase(), P = String(j).toLowerCase();
      return B.includes(P);
    }));
  }, [
    e.rowManager,
    e.columns,
    i,
    v,
    e.dataVersion
  ]), { displayIndices: b, filteredCount: h } = ce(() => {
    var B;
    const T = ((B = e.rowManager) == null ? void 0 : B.getLength()) || 0, _ = g || Array.from({ length: T }, (P, Z) => Z), $ = _.length, A = l.pageSize + u, H = l.pageIndex * l.pageSize, L = H + A;
    return {
      displayIndices: _.slice(H, L),
      filteredCount: $
    };
  }, [
    g,
    e.rowManager,
    l,
    u,
    e.dataVersion
  ]), w = ce(() => Math.ceil(h / l.pageSize), [h, l.pageSize]);
  Ct(() => {
    var _;
    const T = (g == null ? void 0 : g.length) || ((_ = e.rowManager) == null ? void 0 : _.getLength()) || 0;
    if (T > 0) {
      const $ = Math.max(
        0,
        Math.ceil(T / l.pageSize) - 1
      );
      l.pageIndex > $ && c((A) => ({
        ...A,
        pageIndex: $
      }));
    }
  }, [
    g,
    l.pageSize,
    l.pageIndex,
    e.rowManager,
    e.dataVersion
  ]);
  const m = E((T) => {
    s((_) => {
      const $ = _.find((A) => A.id === T);
      return $ ? $.desc ? [] : [{ id: T, desc: !0 }] : [{ id: T, desc: !1 }];
    });
  }, []), y = E((T, _) => {
    a(($) => {
      const A = { ...$ };
      return !_ || _ === "" ? delete A[T] : A[T] = _, A;
    }), c(($) => ({
      ...$,
      pageIndex: 0
    }));
  }, []), x = E(
    (T) => {
      c((_) => {
        var L;
        const $ = (g == null ? void 0 : g.length) || ((L = e.rowManager) == null ? void 0 : L.getLength()) || 0, A = Math.max(
          0,
          Math.ceil($ / T) - 1
        ), H = Math.max(
          0,
          Math.min(_.pageIndex, A)
        );
        return {
          ..._,
          pageSize: T,
          pageIndex: H
        };
      });
    },
    [g, e.rowManager, e.dataVersion]
  ), C = E(() => {
    s([]);
  }, []), S = E(() => {
    a({}), c((T) => ({ ...T, pageIndex: 0 }));
  }, []), R = E(() => {
    f((T) => T + 1);
  }, []), N = E(() => {
    f((T) => Math.max(0, T - 1));
  }, []), k = E(() => {
    s([]), a({}), c((T) => ({
      ...T,
      pageIndex: 0
    })), f(0);
  }, []), W = E(
    (T) => {
      f(0), c((_) => {
        var L;
        const $ = (g == null ? void 0 : g.length) || ((L = e.rowManager) == null ? void 0 : L.getLength()) || 0, A = Math.max(
          0,
          Math.ceil($ / _.pageSize) - 1
        ), H = Math.max(0, Math.min(T, A));
        return {
          ..._,
          pageIndex: H
        };
      });
    },
    [g, e.rowManager, e.dataVersion]
  );
  return {
    sorting: o,
    filtering: i,
    pagination: l,
    displayIndices: b,
    totalCount: ((O = e.rowManager) == null ? void 0 : O.getLength()) || 0,
    filteredCount: h,
    totalPages: w,
    temporaryPageSizeIncrease: u,
    handleSort: m,
    handleFilter: y,
    handlePageChange: W,
    handlePageSizeChange: x,
    handleTemporaryPageSizeIncrease: R,
    handleTemporaryPageSizeDecrease: N,
    clearSorting: C,
    clearFiltering: S,
    clearAll: k
  };
}
function im({
  rowManager: e,
  displayData: t = [],
  onRowSelect: n
}) {
  const [r, o] = ae(/* @__PURE__ */ new Set()), s = E(() => {
    const v = [];
    return r.forEach((g) => {
      let b;
      if (g.startsWith("row-")) {
        const w = g.replace("row-", "");
        b = isNaN(Number(w)) ? w : Number(w);
      } else
        b = isNaN(Number(g)) ? g : Number(g);
      const h = e.getRowById(b);
      h ? v.push(h) : process.env.NODE_ENV === "development" && console.warn(
        "Could not find data for selected key:",
        g,
        "actual ID:",
        b
      );
    }), v;
  }, [e, r]), i = E(() => {
    const v = [];
    return r.forEach((g) => {
      if (g.startsWith("row-")) {
        const b = g.replace("row-", ""), h = isNaN(Number(b)) ? b : Number(b);
        v.push(h);
      } else {
        const b = isNaN(Number(g)) ? g : Number(g);
        v.push(b);
      }
    }), v;
  }, [r]), a = E(
    (v, g) => {
      o((b) => {
        const h = new Set(b);
        if (g ? h.add(v) : h.delete(v), n) {
          const w = [];
          h.forEach((m) => {
            const y = m.replace("row-", ""), x = isNaN(Number(y)) ? y : Number(y), C = e.getRowById(x);
            C ? w.push(C) : console.warn(
              "Could not find row for key:",
              m,
              "parsed ID:",
              x
            );
          }), n(w);
        }
        return h;
      });
    },
    [e, n]
  ), l = E(
    (v) => {
      if (v) {
        const g = t.map((b, h) => {
          const w = e.getRowIdByData(b);
          return w ? `row-${w}` : `row-${h}`;
        });
        o((b) => {
          const h = new Set(b);
          return g.forEach((w) => h.add(w)), h;
        });
      } else {
        const g = t.map((b, h) => {
          const w = e.getRowIdByData(b);
          return w ? `row-${w}` : `row-${h}`;
        });
        o((b) => {
          const h = new Set(b);
          return g.forEach((w) => h.delete(w)), h;
        });
      }
      if (n) {
        const g = s();
        n(g);
      }
    },
    [t, e, n, s]
  ), c = E(() => {
    o(/* @__PURE__ */ new Set()), n && n([]);
  }, [n]), { isAllSelected: u, isIndeterminate: f } = ce(() => {
    const g = t.map((x) => e.getRowIdByData(x)).filter((x) => x !== void 0).map((x) => `row-${x}`), b = Array.from(r), h = g.filter(
      (x) => b.includes(x)
    ).length, w = g.length;
    if (w === 0)
      return { isAllSelected: !1, isIndeterminate: !1 };
    const m = h === w && h > 0, y = h > 0 && h < w;
    return {
      isAllSelected: m,
      isIndeterminate: y
    };
  }, [t, e, r]);
  return {
    selectedRowIds: r,
    isAllSelected: u,
    isIndeterminate: f,
    handleRowSelect: a,
    handleSelectAll: l,
    clearSelection: c,
    getSelectedData: s,
    getSelectedRowIds: i
  };
}
function am({
  columns: e,
  onCellEdit: t,
  data: n = []
}) {
  const [r, o] = ae(null), [s, i] = ae(
    /* @__PURE__ */ new Set()
  ), [a, l] = ae(!1), c = E(() => e.filter(
    (m) => m.type && ["text", "number", "email"].includes(m.type)
  ), [e]), u = E(
    (m, y, x) => {
      const C = La(m, n);
      t && C >= 0 && t(C, y, x), o(null);
      const S = `${m}-${y}`;
      i((R) => /* @__PURE__ */ new Set([...R, S])), setTimeout(() => {
        i((R) => {
          const N = new Set(R);
          return N.delete(S), N;
        });
      }, 1e3);
    },
    [t, n]
  ), f = E((m, y) => {
    o({ rowId: m, field: y });
  }, []), v = E(() => {
    o(null);
  }, []), g = E(
    (m, y, x) => {
      const C = c(), S = C.findIndex(
        (R) => R.id === y
      );
      if (S < C.length - 1)
        o({
          rowId: m,
          field: C[S + 1].id
        });
      else {
        const R = Oa(m, n);
        R && o({
          rowId: R,
          field: C[0].id
        });
      }
    },
    [c, n]
  ), b = E(
    (m, y) => {
      const x = c(), C = x.findIndex(
        (S) => S.id === y
      );
      if (C > 0)
        o({
          rowId: m,
          field: x[C - 1].id
        });
      else {
        const S = _a(m, n);
        S && o({
          rowId: S,
          field: x[x.length - 1].id
        });
      }
    },
    [c, n]
  ), h = E(
    (m) => {
      const y = String(m);
      return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(y) || "Please enter a valid email address";
    },
    []
  ), w = E(
    (m) => {
      const y = Number(m);
      return y > 0 && y < 120 || "Age must be between 1 and 119";
    },
    []
  );
  return {
    editingCell: r,
    recentlySavedCells: s,
    singleClickEdit: a,
    setEditingCell: o,
    setSingleClickEdit: l,
    handleCellEdit: u,
    handleEditStart: f,
    handleEditCancel: v,
    handleTabToNext: g,
    handleTabToPrevious: b,
    getEditableColumns: c,
    validateEmail: h,
    validateAge: w
  };
}
function lm({
  onRowAction: e
}) {
  const t = E((i, a, l) => {
    e && e(i, a, l);
  }, [e]), n = E((i, a) => {
    t("edit", i, a);
  }, [t]), r = E((i, a) => {
    t("duplicate", i, a);
  }, [t]), o = E((i, a) => {
    t("delete", i, a);
  }, [t]), s = E((i, a, l) => {
    t(i, a, l);
  }, [t]);
  return {
    handleRowAction: t,
    handleEdit: n,
    handleDuplicate: r,
    handleDelete: o,
    handleCustomAction: s
  };
}
function cm({
  config: e,
  initialPagination: t = {},
  initialSorting: n = [],
  initialFiltering: r = {},
  initialGlobalSearch: o = ""
}) {
  const [s, i] = ae([]), [a, l] = ae(0), [c, u] = ae(0), [f, v] = ae({
    pageIndex: 0,
    pageSize: 10,
    ...t
  }), [g, b] = ae(n), [h, w] = ae(r), [m, y] = ae(o), [x, C] = ae({
    loading: !1,
    error: null,
    lastRequest: null,
    retryCount: 0
  }), S = Ue(/* @__PURE__ */ new Map()), R = Ue(null), N = Ue(null), k = ce(() => Math.ceil(c / f.pageSize), [c, f.pageSize]), W = E(() => ({
    pagination: {
      page: f.pageIndex,
      pageSize: f.pageSize
    },
    sorting: g,
    filtering: h,
    globalSearch: m
  }), [f, g, h, m]), O = E(
    (F) => {
      var K;
      return (K = e.caching) != null && K.keyGenerator ? e.caching.keyGenerator(F) : JSON.stringify({
        page: F.pagination.page,
        pageSize: F.pagination.pageSize,
        sorting: F.sorting,
        filtering: F.filtering,
        globalSearch: F.globalSearch
      });
    },
    [e.caching]
  ), T = E(
    (F) => {
      var J;
      if (!((J = e.caching) != null && J.enabled)) return null;
      const K = O(F), Y = S.current.get(K);
      if (!Y) return null;
      const ee = e.caching.ttl || 5 * 60 * 1e3;
      return Date.now() - Y.timestamp > ee ? (S.current.delete(K), null) : Y.data;
    },
    [e.caching, O]
  ), _ = E(
    (F, K) => {
      var ee;
      if (!((ee = e.caching) != null && ee.enabled)) return;
      const Y = O(F);
      S.current.set(Y, {
        data: K,
        timestamp: Date.now()
      });
    },
    [e.caching, O]
  ), $ = E(
    (F) => {
      var Y;
      const K = {
        message: F.message || "An error occurred while loading data",
        code: F.code,
        details: F
      };
      C((ee) => ({
        ...ee,
        loading: !1,
        error: K,
        retryCount: ee.retryCount + 1
      })), (Y = e.onError) == null || Y.call(e, K);
    },
    [e.onError]
  ), A = E(async () => {
    var Y, ee;
    const F = W(), K = T(F);
    if (K) {
      i(K.data), l(K.totalCount), u(K.filteredCount);
      return;
    }
    N.current && N.current.abort(), N.current = new AbortController(), C((I) => ({
      ...I,
      loading: !0,
      error: null,
      lastRequest: F
    })), (Y = e.onLoadingChange) == null || Y.call(e, !0);
    try {
      const I = await e.onDataLoad(F);
      if (!I || typeof I != "object")
        throw new Error("Invalid response format");
      i(I.data || []), l(I.totalCount || 0), u(I.filteredCount || I.totalCount || 0), _(F, I), C((J) => ({
        ...J,
        loading: !1,
        error: null,
        retryCount: 0
      }));
    } catch (I) {
      I.name !== "AbortError" && $(I);
    } finally {
      (ee = e.onLoadingChange) == null || ee.call(e, !1), N.current = null;
    }
  }, [W, T, _, e, $]), H = E(async (F) => {
    b((K) => {
      const Y = K.find((I) => I.id === F);
      let ee;
      return Y ? Y.desc ? ee = [] : ee = [{ id: F, desc: !0 }] : ee = [{ id: F, desc: !1 }], ee;
    }), v((K) => ({ ...K, pageIndex: 0 }));
  }, []), L = E(async (F, K) => {
    w((Y) => {
      const ee = { ...Y };
      return !K || K === "" ? delete ee[F] : ee[F] = K, ee;
    }), v((Y) => ({ ...Y, pageIndex: 0 }));
  }, []), j = E(async (F) => {
    v((K) => ({ ...K, pageIndex: F }));
  }, []), B = E(async (F) => {
    v((K) => ({
      ...K,
      pageSize: F,
      pageIndex: 0
    }));
  }, []), P = E(
    async (F) => {
      R.current && clearTimeout(R.current);
      const K = e.debounceMs || 300;
      y(F), R.current = setTimeout(() => {
        v((Y) => ({ ...Y, pageIndex: 0 }));
      }, K);
    },
    [e.debounceMs]
  ), Z = E(async () => {
    var F;
    (F = e.caching) != null && F.enabled && S.current.clear(), await A();
  }, [A, e.caching]), D = E(async () => {
    await A();
  }, [A]), U = E(() => {
    C((F) => ({ ...F, error: null }));
  }, []);
  return Ct(() => {
    e.enabled && A();
  }, [e.enabled, f, g, h, m, A]), Ct(() => () => {
    R.current && clearTimeout(R.current), N.current && N.current.abort();
  }, []), {
    data: s,
    totalCount: a,
    filteredCount: c,
    totalPages: k,
    pagination: f,
    sorting: g,
    filtering: h,
    globalSearch: m,
    serverState: x,
    loadData: A,
    handleSort: H,
    handleFilter: L,
    handlePageChange: j,
    handlePageSizeChange: B,
    handleGlobalSearch: P,
    refresh: Z,
    retry: D,
    clearError: U,
    getCurrentRequest: W
  };
}
export {
  Ie as B,
  xm as L,
  Ta as R,
  Cm as T,
  bm as a,
  Cl as b,
  sm as c,
  im as d,
  am as e,
  lm as f,
  cm as g,
  Ha as u
};
//# sourceMappingURL=use-server-side-CFxBv0fU.mjs.map