@nivaro/react 0.1.27 → 0.1.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -3251,7 +3251,7 @@ function StripCell({
3251
3251
  const r = s.prefix ?? "", a = s.suffix ?? "", l = n ? null : formatStatValue(t, s.format ?? "");
3252
3252
  return /* @__PURE__ */ jsxs("div", { className: "flex flex-col justify-start px-4 py-2 min-w-0", children: [
3253
3253
  /* @__PURE__ */ jsx("span", { className: "flex h-4 items-end truncate text-[10px] font-medium leading-none text-slate-400 dark:text-slate-500", children: e }),
3254
- /* @__PURE__ */ jsx("span", { className: "mt-1 leading-none truncate max-w-[220px]", children: n ? /* @__PURE__ */ jsx("span", { className: "animate-pulse inline-block h-3.5 w-16 rounded bg-slate-200 dark:bg-[hsl(var(--nvr-skeleton))]" }) : /* @__PURE__ */ jsxs("span", { className: "text-[13px] font-semibold tabular-nums text-slate-900 dark:text-slate-100", children: [
3254
+ /* @__PURE__ */ jsx("span", { className: "mt-1 leading-tight truncate max-w-[220px]", children: n ? /* @__PURE__ */ jsx("span", { className: "animate-pulse inline-block h-3.5 w-16 rounded bg-slate-200 dark:bg-[hsl(var(--nvr-skeleton))]" }) : /* @__PURE__ */ jsxs("span", { className: "text-[13px] font-semibold tabular-nums text-slate-900 dark:text-slate-100", children: [
3255
3255
  r,
3256
3256
  l,
3257
3257
  a
@@ -7524,7 +7524,7 @@ function InlineTableField({
7524
7524
  _exists_junction: { table: pe.table, self_fk: pe.self_fk, filter_fk: pe.filter_fk, value: _e }
7525
7525
  }));
7526
7526
  }), A;
7527
- }, [_s, Ms, xe]), te = i === "pending", ke = E ? E.getPendingRows(e, t) : [], Se = te && E ? E.getPendingEdits(e, t) : /* @__PURE__ */ new Map(), Le = te && E ? E.getPendingDeletes(e, t) : /* @__PURE__ */ new Set(), Qe = useMemo(
7527
+ }, [_s, Ms, xe]), te = i === "pending", ke = E ? E.getPendingRows(e, t) : [], Se = te && E ? E.getPendingEdits(e, t) : /* @__PURE__ */ new Map(), Le = te && E ? E.getPendingDeletes(e, t) : /* @__PURE__ */ new Set(), Ue = useMemo(
7528
7528
  () => new Map(
7529
7529
  De.filter((A) => A.computed_type === "write" && !!A.computed_formula).map((A) => [A.field, String(A.computed_formula)])
7530
7530
  ),
@@ -7729,9 +7729,9 @@ function InlineTableField({
7729
7729
  const ms = useRef(() => {
7730
7730
  });
7731
7731
  ms.current = () => Ss == null ? void 0 : Ss(e, t, null), useEffect(() => () => ms.current(), []);
7732
- const Ut = De.filter(
7732
+ const Qt = De.filter(
7733
7733
  (A) => !A.hidden && (!NON_DISPLAY_TYPES$1.has(A.type) || Ls(A.interface)) && A.field !== t && A.field !== "id" && (!ie || A.layout_assigned === !0) && !SENTINEL_FIELDS.has(A.field) && !js.has(A.group_key ?? "")
7734
- ), ts = m && m.length >= 2 && _t !== ALL_PRESET_SENTINEL ? m.find((A) => A.name === _t) : void 0, Un = ts ? new Set(ts.columns.filter((A) => !A.includes("."))) : null, Gn = Un ? Ut.filter((A) => Un.has(A.field)) : [], gs = useMemo(() => {
7734
+ ), ts = m && m.length >= 2 && _t !== ALL_PRESET_SENTINEL ? m.find((A) => A.name === _t) : void 0, Qn = ts ? new Set(ts.columns.filter((A) => !A.includes("."))) : null, Gn = Qn ? Qt.filter((A) => Qn.has(A.field)) : [], gs = useMemo(() => {
7735
7735
  if (!ts) return [];
7736
7736
  const A = [];
7737
7737
  for (const V of ts.columns) {
@@ -7812,7 +7812,7 @@ function InlineTableField({
7812
7812
  staleTime: 3e4
7813
7813
  };
7814
7814
  })
7815
- }), Us = useMemo(() => {
7815
+ }), Qs = useMemo(() => {
7816
7816
  const A = /* @__PURE__ */ new Map();
7817
7817
  return Ks.forEach((V, oe) => {
7818
7818
  var Fe;
@@ -7828,7 +7828,7 @@ function InlineTableField({
7828
7828
  const A = /* @__PURE__ */ new Map(), V = (oe, pe) => {
7829
7829
  pe == null || pe === "" || (A.has(oe) || A.set(oe, []), A.get(oe).push(String(pe)));
7830
7830
  };
7831
- for (const [oe, pe] of Us) {
7831
+ for (const [oe, pe] of Qs) {
7832
7832
  const _e = As.get(oe);
7833
7833
  if (!(!_e || _e.size === 0)) {
7834
7834
  for (const Fe of pe.values())
@@ -7846,7 +7846,7 @@ function InlineTableField({
7846
7846
  }
7847
7847
  for (const [oe, pe] of A) A.set(oe, [...new Set(pe)].sort());
7848
7848
  return A;
7849
- }, [Us, As, ke]), { data: Qn = {} } = useQuery({
7849
+ }, [Qs, As, ke]), { data: Un = {} } = useQuery({
7850
7850
  queryKey: ["summary-m2o-display", e, ...Array.from(os.entries()).flat(2)],
7851
7851
  queryFn: async () => {
7852
7852
  const A = {};
@@ -7895,12 +7895,12 @@ function InlineTableField({
7895
7895
  var Ge, ct;
7896
7896
  const pe = A.field.indexOf(".");
7897
7897
  if (pe < 0) return "—";
7898
- const _e = A.field.slice(0, pe), Fe = A.field.slice(pe + 1), Me = V[`__o2m_${_e}`], Ee = oe ? Array.isArray(Me) ? Me : [] : ((Ge = Us.get(_e)) == null ? void 0 : Ge.get(String(V.id))) ?? [];
7898
+ const _e = A.field.slice(0, pe), Fe = A.field.slice(pe + 1), Me = V[`__o2m_${_e}`], Ee = oe ? Array.isArray(Me) ? Me : [] : ((Ge = Qs.get(_e)) == null ? void 0 : Ge.get(String(V.id))) ?? [];
7899
7899
  if (Ee.length === 0) return "—";
7900
7900
  const rt = (ct = As.get(_e)) == null ? void 0 : ct.get(Fe), ze = Ee.map((gt) => {
7901
7901
  var it;
7902
7902
  const Wt = gt[Fe];
7903
- return Wt == null || Wt === "" ? null : rt != null && rt.one_collection ? ((it = Qn[rt.one_collection]) == null ? void 0 : it[String(Wt)]) ?? String(Wt) : String(Wt);
7903
+ return Wt == null || Wt === "" ? null : rt != null && rt.one_collection ? ((it = Un[rt.one_collection]) == null ? void 0 : it[String(Wt)]) ?? String(Wt) : String(Wt);
7904
7904
  }).filter((gt) => !!gt);
7905
7905
  return ze.length > 0 ? ze.join(", ") : "—";
7906
7906
  }
@@ -7908,14 +7908,14 @@ function InlineTableField({
7908
7908
  var ze, Ge;
7909
7909
  const oe = A.field.indexOf(".");
7910
7910
  if (oe < 0) return "—";
7911
- const pe = A.field.slice(0, oe), _e = A.field.slice(oe + 1), Fe = ((ze = Us.get(pe)) == null ? void 0 : ze.get(String(V.id))) ?? [];
7911
+ const pe = A.field.slice(0, oe), _e = A.field.slice(oe + 1), Fe = ((ze = Qs.get(pe)) == null ? void 0 : ze.get(String(V.id))) ?? [];
7912
7912
  if (Fe.length === 0) return "—";
7913
7913
  const Me = (Ge = As.get(pe)) == null ? void 0 : Ge.get(_e);
7914
7914
  if (!(Me != null && Me.one_collection) || !L) return Zs(A, V, !1);
7915
7915
  const Ee = Me.one_collection, rt = Fe.map((ct) => {
7916
7916
  var Wt;
7917
7917
  const gt = ct[_e];
7918
- return gt == null || gt === "" ? null : { id: String(gt), label: ((Wt = Qn[Ee]) == null ? void 0 : Wt[String(gt)]) ?? String(gt) };
7918
+ return gt == null || gt === "" ? null : { id: String(gt), label: ((Wt = Un[Ee]) == null ? void 0 : Wt[String(gt)]) ?? String(gt) };
7919
7919
  }).filter((ct) => !!ct);
7920
7920
  return rt.length === 0 ? "—" : /* @__PURE__ */ jsx("span", { className: "inline-flex flex-wrap gap-x-1.5", children: rt.map((ct, gt) => /* @__PURE__ */ jsx(
7921
7921
  "button",
@@ -7930,7 +7930,7 @@ function InlineTableField({
7930
7930
  `${ct.id}:${gt}`
7931
7931
  )) });
7932
7932
  }
7933
- const ls = ts && (Gn.length > 0 || Wn.length > 0) ? [...Gn, ...Wn] : Ut, Cs = useMemo(
7933
+ const ls = ts && (Gn.length > 0 || Wn.length > 0) ? [...Gn, ...Wn] : Qt, Cs = useMemo(
7934
7934
  () => De.filter((A) => A.group_key === "__apply_values__" && !NON_DISPLAY_TYPES$1.has(A.type ?? "") && !SENTINEL_FIELDS.has(A.field)),
7935
7935
  [De]
7936
7936
  ), vn = useMemo(
@@ -7938,14 +7938,14 @@ function InlineTableField({
7938
7938
  [De]
7939
7939
  ), Os = useMemo(() => {
7940
7940
  const A = /* @__PURE__ */ new Map();
7941
- for (const V of Ut) {
7941
+ for (const V of Qt) {
7942
7942
  const oe = lt.find(
7943
7943
  (pe) => pe.many_collection === e && pe.many_field === V.field && !pe.junction_field
7944
7944
  );
7945
7945
  oe != null && oe.one_collection && A.set(V.field, oe);
7946
7946
  }
7947
7947
  return A;
7948
- }, [Ut, lt, e]), Qs = useMemo(() => {
7948
+ }, [Qt, lt, e]), Us = useMemo(() => {
7949
7949
  const A = [];
7950
7950
  for (const [V, oe] of Object.entries(Bt)) {
7951
7951
  const pe = Os.get(V);
@@ -7959,7 +7959,7 @@ function InlineTableField({
7959
7959
  }
7960
7960
  return A;
7961
7961
  }, [Bt, Os, tt, ke]), ps = useQueries({
7962
- queries: Qs.map((A) => ({
7962
+ queries: Us.map((A) => ({
7963
7963
  queryKey: [
7964
7964
  "cascade-stale-sweep",
7965
7965
  e,
@@ -7978,14 +7978,14 @@ function InlineTableField({
7978
7978
  }))
7979
7979
  }), en = useMemo(() => {
7980
7980
  const A = /* @__PURE__ */ new Map();
7981
- return Qs.forEach((V, oe) => {
7981
+ return Us.forEach((V, oe) => {
7982
7982
  var Fe;
7983
7983
  const pe = (Fe = ps[oe]) == null ? void 0 : Fe.data;
7984
7984
  if (!pe) return;
7985
7985
  const _e = V.ids.filter((Me) => !pe.has(Me));
7986
7986
  _e.length && A.set(V.field, new Set(_e));
7987
7987
  }), A;
7988
- }, [Qs, ps]), Zt = useMemo(() => {
7988
+ }, [Us, ps]), Zt = useMemo(() => {
7989
7989
  const A = /* @__PURE__ */ new Map(), V = [...tt, ...ke], oe = [...Se.values()], pe = H.flatMap((_e) => _e.rows);
7990
7990
  for (const [_e, Fe] of Os) {
7991
7991
  if (!Fe.one_collection) continue;
@@ -7995,7 +7995,7 @@ function InlineTableField({
7995
7995
  return A;
7996
7996
  }, [tt, ke, Se, Os, H]), Yn = useMemo(() => {
7997
7997
  const A = /* @__PURE__ */ new Map();
7998
- for (const V of Ut) {
7998
+ for (const V of Qt) {
7999
7999
  const oe = Os.get(V.field);
8000
8000
  if (oe != null && oe.one_collection && V.interface === "relation-grouped") {
8001
8001
  const pe = parseJson(V.options);
@@ -8003,7 +8003,7 @@ function InlineTableField({
8003
8003
  }
8004
8004
  }
8005
8005
  return A;
8006
- }, [Ut, Os]), qn = useMemo(
8006
+ }, [Qt, Os]), qn = useMemo(
8007
8007
  () => ["m2o-display", e, ...Array.from(Zt.entries()).flat(2)],
8008
8008
  [e, Zt]
8009
8009
  ), { data: jn = {}, isFetching: tn } = useQuery({
@@ -8134,7 +8134,7 @@ function InlineTableField({
8134
8134
  }
8135
8135
  P.invalidateQueries({ queryKey: ["o2m-rows", e, t, s] });
8136
8136
  } else {
8137
- const V = new Set(Ut.map((pe) => pe.field).filter((pe) => !pe.startsWith("__m2m_"))), oe = Object.fromEntries(Object.entries(ge.draft).filter(([pe]) => V.has(pe)));
8137
+ const V = new Set(Qt.map((pe) => pe.field).filter((pe) => !pe.startsWith("__m2m_"))), oe = Object.fromEntries(Object.entries(ge.draft).filter(([pe]) => V.has(pe)));
8138
8138
  if (te && E) {
8139
8139
  const pe = Object.entries(ge.draft).filter(([Me]) => Me.startsWith("__nested_ops_")), _e = tt.find((Me) => String(Me.id) === ge.rowId), Fe = _e ? Object.fromEntries(Object.entries(oe).filter(([Me, Ee]) => String(Ee ?? "") !== String(_e[Me] ?? ""))) : oe;
8140
8140
  E.queueEdit(e, t, ge.rowId, { ...Fe, ...Object.fromEntries(pe) }), He(null);
@@ -8165,7 +8165,7 @@ function InlineTableField({
8165
8165
  }
8166
8166
  }
8167
8167
  }
8168
- const [wn, $s] = useState(/* @__PURE__ */ new Set()), [Ts, Rn] = useState(null), [Hs, Dn] = useState(null), [U, w] = useState(!1), [Q, se] = useState(1), [$e, Oe] = useState(!1), [Ve, dt] = useState(!1), [Nt, We] = useState({}), [Ct, Ft] = useState(!1), [Gt, ds] = useState({}), [nn, On] = useState(!1);
8168
+ const [wn, $s] = useState(/* @__PURE__ */ new Set()), [Ts, Rn] = useState(null), [Hs, Dn] = useState(null), [Q, w] = useState(!1), [U, se] = useState(1), [$e, Oe] = useState(!1), [Ve, dt] = useState(!1), [Nt, We] = useState({}), [Ct, Ft] = useState(!1), [Gt, ds] = useState({}), [nn, On] = useState(!1);
8169
8169
  function zn(A, V) {
8170
8170
  We((oe) => ({ ...oe, [A]: V }));
8171
8171
  }
@@ -8187,7 +8187,7 @@ function InlineTableField({
8187
8187
  }
8188
8188
  }
8189
8189
  async function Is(A) {
8190
- const V = Math.max(1, Math.min(100, Q)), oe = A ? { ...ss, ...Nt } : { ...ss };
8190
+ const V = Math.max(1, Math.min(100, U)), oe = A ? { ...ss, ...Nt } : { ...ss };
8191
8191
  if ((K || te) && E) {
8192
8192
  for (let pe = 0; pe < V; pe++) E.queueRow(e, t, { ...oe });
8193
8193
  return;
@@ -8409,7 +8409,7 @@ function InlineTableField({
8409
8409
  }
8410
8410
  if (at || !K && Vt)
8411
8411
  return /* @__PURE__ */ jsx("div", { className: "py-3 text-center text-[12px] text-slate-400", children: /* @__PURE__ */ jsx(Loader2, { className: "h-4 w-4 animate-spin inline" }) });
8412
- const Pn = (ge == null ? void 0 : ge.rowId) === "new", Qt = ls.length + (K || te ? 2 : 1) + (et || K || te ? 1 : 0), Fn = ls.filter((A) => !Xs(A)).length >= 6 ? "panel" : "inline", hn = (A) => {
8412
+ const Pn = (ge == null ? void 0 : ge.rowId) === "new", Ut = ls.length + (K || te ? 2 : 1) + (et || K || te ? 1 : 0), Fn = ls.filter((A) => !Xs(A)).length >= 6 ? "panel" : "inline", hn = (A) => {
8413
8413
  for (const V of ls) {
8414
8414
  if (Xs(V)) continue;
8415
8415
  const oe = A[V.field];
@@ -8439,7 +8439,7 @@ function InlineTableField({
8439
8439
  },
8440
8440
  pe
8441
8441
  );
8442
- }) }), tr = (A) => A.computed_type === "write" && !!A.computed_formula || A.interface === "formula-column" || A.interface === "match-agg-column" || A.interface === "relation-path" || !!A.readonly || Xs(A), cr = (A) => /* @__PURE__ */ jsx("td", { colSpan: Qt, className: "p-0", children: /* @__PURE__ */ jsxs(
8442
+ }) }), tr = (A) => A.computed_type === "write" && !!A.computed_formula || A.interface === "formula-column" || A.interface === "match-agg-column" || A.interface === "relation-path" || !!A.readonly || Xs(A), cr = (A) => /* @__PURE__ */ jsx("td", { colSpan: Ut, className: "p-0", children: /* @__PURE__ */ jsxs(
8443
8443
  "div",
8444
8444
  {
8445
8445
  className: "my-1.5 rounded-lg border border-nvr-cyan/40 bg-white px-4 py-3 shadow-[0_6px_24px_-8px_rgba(15,23,42,0.35)] ring-1 ring-nvr-cyan/15 dark:border-nvr-cyan/30 dark:bg-card",
@@ -8570,7 +8570,7 @@ function InlineTableField({
8570
8570
  type: "number",
8571
8571
  min: 1,
8572
8572
  max: 100,
8573
- value: Q,
8573
+ value: U,
8574
8574
  onChange: (A) => se(Math.max(1, Math.min(100, parseInt(A.target.value, 10) || 1))),
8575
8575
  className: "w-14 h-6 rounded border border-slate-200 px-2 text-[11px] text-slate-700 text-center focus:outline-none focus:ring-1 focus:ring-[#00ceff]"
8576
8576
  }
@@ -8584,7 +8584,7 @@ function InlineTableField({
8584
8584
  className: "h-6 px-2.5 rounded border border-slate-200 text-slate-600 hover:border-slate-400 hover:text-slate-800 disabled:opacity-40 transition-colors",
8585
8585
  children: [
8586
8586
  "blank ",
8587
- Q === 1 ? "row" : "rows"
8587
+ U === 1 ? "row" : "rows"
8588
8588
  ]
8589
8589
  }
8590
8590
  ),
@@ -8632,7 +8632,7 @@ function InlineTableField({
8632
8632
  ...ke.map((V, oe) => ({ ...V, __pendingIndex: oe }))
8633
8633
  ],
8634
8634
  relatedCollection: e,
8635
- computedWriteFields: Qe,
8635
+ computedWriteFields: Ue,
8636
8636
  applyRow: async (V, oe) => {
8637
8637
  const pe = V.__pendingIndex;
8638
8638
  if (typeof pe == "number" && E) {
@@ -8744,7 +8744,7 @@ function InlineTableField({
8744
8744
  ] }),
8745
8745
  g && In,
8746
8746
  /* @__PURE__ */ jsxs("div", { className: z ? "hidden" : "relative rounded-lg border border-slate-200 text-[12px]", children: [
8747
- U && /* @__PURE__ */ jsx("div", { className: "absolute inset-0 z-10 flex items-center justify-center rounded-lg bg-white/60 backdrop-blur-[1px]", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 rounded-md border border-slate-200 bg-white px-3 py-1.5 shadow-sm text-[12px] text-slate-500", children: [
8747
+ Q && /* @__PURE__ */ jsx("div", { className: "absolute inset-0 z-10 flex items-center justify-center rounded-lg bg-white/60 backdrop-blur-[1px]", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 rounded-md border border-slate-200 bg-white px-3 py-1.5 shadow-sm text-[12px] text-slate-500", children: [
8748
8748
  /* @__PURE__ */ jsx(Loader2, { className: "h-3.5 w-3.5 animate-spin" }),
8749
8749
  "Saving order…"
8750
8750
  ] }) }),
@@ -8779,7 +8779,7 @@ function InlineTableField({
8779
8779
  disabled: $e,
8780
8780
  onClick: () => Is(!0),
8781
8781
  className: "rounded px-2 h-9 bg-[#00ceff] text-white text-[11px] font-medium hover:brightness-110 disabled:opacity-50 whitespace-nowrap",
8782
- children: $e ? "…" : `Add ${Q}`
8782
+ children: $e ? "…" : `Add ${U}`
8783
8783
  }
8784
8784
  ) })
8785
8785
  ] }),
@@ -8927,7 +8927,7 @@ function InlineTableField({
8927
8927
  Wt && /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsxs(
8928
8928
  "td",
8929
8929
  {
8930
- colSpan: Qt,
8930
+ colSpan: Ut,
8931
8931
  className: "border-b border-red-100 bg-red-50/60 px-3 py-1 text-[11px] leading-snug text-red-700 dark:border-red-900/30 dark:bg-red-900/10 dark:text-red-400",
8932
8932
  children: [
8933
8933
  "⚠ ",
@@ -8935,7 +8935,7 @@ function InlineTableField({
8935
8935
  ]
8936
8936
  }
8937
8937
  ) }),
8938
- Ee && !ct && Fn !== "panel" && N && N.length > 0 && /* @__PURE__ */ jsx("tr", { className: "border-b border-slate-100 bg-[#f0fbff]/60 dark:bg-nvr-cyan/5", children: /* @__PURE__ */ jsx("td", { colSpan: Qt, className: "px-3 py-2", children: /* @__PURE__ */ jsx("div", { className: "space-y-2", children: N.map((it) => {
8938
+ Ee && !ct && Fn !== "panel" && N && N.length > 0 && /* @__PURE__ */ jsx("tr", { className: "border-b border-slate-100 bg-[#f0fbff]/60 dark:bg-nvr-cyan/5", children: /* @__PURE__ */ jsx("td", { colSpan: Ut, className: "px-3 py-2", children: /* @__PURE__ */ jsx("div", { className: "space-y-2", children: N.map((it) => {
8939
8939
  const ns = typeof it == "string" ? it : it.field, xs = typeof it == "string" ? void 0 : it.hint, Dt = typeof it == "string" ? void 0 : it.match, rn = (ge == null ? void 0 : ge.draft) ?? gt, Js = Dt ? buildMatchedDrawer(Dt, rn, s, xe == null ? void 0 : xe.draft) : null;
8940
8940
  return /* @__PURE__ */ jsx(
8941
8941
  NestedRelationEditor,
@@ -9023,7 +9023,7 @@ function InlineTableField({
9023
9023
  const A = H.find((oe) => oe.addendumId === st), V = (d && (et || te) ? 1 : 0) + (o ? 1 : 0) + (te ? 1 : 0) + ls.length + 1;
9024
9024
  return A ? A.rows.length === 0 ? /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsx("td", { colSpan: V, className: "px-3 py-8 text-center text-[11px] text-amber-500", children: "No proposed rows in this addendum" }) }) : A.rows.map((oe, pe) => {
9025
9025
  const _e = rs({ ...oe }), Fe = tt.find((Ge) => String(Ge.id) === String(_e.id)), Me = Fe ? rs({ ...Fe }) : void 0, Ee = !Me, rt = new Set(
9026
- Ee ? Ut.map((Ge) => Ge.field) : Ut.filter((Ge) => String(_e[Ge.field] ?? "") !== String(Me[Ge.field] ?? "")).map((Ge) => Ge.field)
9026
+ Ee ? Qt.map((Ge) => Ge.field) : Qt.filter((Ge) => String(_e[Ge.field] ?? "") !== String(Me[Ge.field] ?? "")).map((Ge) => Ge.field)
9027
9027
  ), ze = Ee || rt.size > 0;
9028
9028
  return /* @__PURE__ */ jsxs("tr", { className: ze ? "border-b border-amber-100 bg-amber-50/40" : "border-b border-slate-100", children: [
9029
9029
  d && (et || te) && /* @__PURE__ */ jsx("td", { className: "w-6" }),
@@ -9157,7 +9157,7 @@ function InlineTableField({
9157
9157
  ]
9158
9158
  }
9159
9159
  ),
9160
- pe && N && N.length > 0 && /* @__PURE__ */ jsx("tr", { className: "border-b border-slate-100 bg-[#f0fbff]/60 dark:bg-nvr-cyan/5", children: /* @__PURE__ */ jsx("td", { colSpan: Qt, className: "px-3 py-2", children: /* @__PURE__ */ jsx("div", { className: "space-y-2", children: N.map((Ee) => {
9160
+ pe && N && N.length > 0 && /* @__PURE__ */ jsx("tr", { className: "border-b border-slate-100 bg-[#f0fbff]/60 dark:bg-nvr-cyan/5", children: /* @__PURE__ */ jsx("td", { colSpan: Ut, className: "px-3 py-2", children: /* @__PURE__ */ jsx("div", { className: "space-y-2", children: N.map((Ee) => {
9161
9161
  const rt = typeof Ee == "string" ? Ee : Ee.field, ze = typeof Ee == "string" ? void 0 : Ee.hint;
9162
9162
  return /* @__PURE__ */ jsx(
9163
9163
  NestedRelationEditor,
@@ -9252,7 +9252,7 @@ function InlineTableField({
9252
9252
  DeletedRowsSection,
9253
9253
  {
9254
9254
  deletedRows: oe,
9255
- displayCols: Ut,
9255
+ displayCols: Qt,
9256
9256
  onOpenHistory: (pe, _e) => ve({ id: pe, ..._e })
9257
9257
  }
9258
9258
  );
@@ -9403,10 +9403,10 @@ function CatalogPickerField({
9403
9403
  }), T = q == null ? void 0 : q.display_template, j = d == null ? void 0 : d.draft, { resolvedFilter: _, missingParents: g } = useMemo(() => {
9404
9404
  const te = [], ke = (Le) => {
9405
9405
  if (typeof Le == "string" && Le.startsWith("$parent.")) {
9406
- const Qe = Le.slice(8), Ye = j == null ? void 0 : j[Qe];
9407
- return Ye == null || Ye === "" ? (te.push(Qe), Le) : Ye;
9406
+ const Ue = Le.slice(8), Ye = j == null ? void 0 : j[Ue];
9407
+ return Ye == null || Ye === "" ? (te.push(Ue), Le) : Ye;
9408
9408
  }
9409
- return Array.isArray(Le) ? Le.map(ke) : Le && typeof Le == "object" ? Object.fromEntries(Object.entries(Le).map(([Qe, Ye]) => [Qe, ke(Ye)])) : Le;
9409
+ return Array.isArray(Le) ? Le.map(ke) : Le && typeof Le == "object" ? Object.fromEntries(Object.entries(Le).map(([Ue, Ye]) => [Ue, ke(Ye)])) : Le;
9410
9410
  };
9411
9411
  return { resolvedFilter: r.filter ? ke(r.filter) : void 0, missingParents: [...new Set(te)] };
9412
9412
  }, [r.filter, j]), M = useMemo(() => {
@@ -9527,9 +9527,9 @@ function CatalogPickerField({
9527
9527
  ce.join(",")
9528
9528
  ],
9529
9529
  queryFn: async () => {
9530
- const Se = {}, Le = te.aggregate === "sum", Qe = Le ? 150 : 400;
9531
- for (let Ye = 0; Ye < ce.length; Ye += Qe) {
9532
- const Re = ce.slice(Ye, Ye + Qe);
9530
+ const Se = {}, Le = te.aggregate === "sum", Ue = Le ? 150 : 400;
9531
+ for (let Ye = 0; Ye < ce.length; Ye += Ue) {
9532
+ const Re = ce.slice(Ye, Ye + Ue);
9533
9533
  let wt = 1;
9534
9534
  for (; ; ) {
9535
9535
  const Rt = await l.request(
@@ -9560,10 +9560,10 @@ function CatalogPickerField({
9560
9560
  };
9561
9561
  })
9562
9562
  }), le = (te, ke) => {
9563
- var Le, Qe;
9563
+ var Le, Ue;
9564
9564
  const Se = (r.related_columns ?? []).findIndex((Ye) => Ye.key === te);
9565
9565
  if (Se !== -1)
9566
- return (Qe = (Le = I[Se]) == null ? void 0 : Le.data) == null ? void 0 : Qe[ke];
9566
+ return (Ue = (Le = I[Se]) == null ? void 0 : Le.data) == null ? void 0 : Ue[ke];
9567
9567
  }, J = (te) => {
9568
9568
  var wt;
9569
9569
  const ke = r.qty_warning;
@@ -9572,9 +9572,9 @@ function CatalogPickerField({
9572
9572
  if (Se <= 0) return null;
9573
9573
  const Le = (r.related_columns ?? []).findIndex((Rt) => Rt.key === ke.column);
9574
9574
  if (Le === -1) return null;
9575
- const Qe = (wt = I[Le]) == null ? void 0 : wt.data;
9576
- if (Qe === void 0) return null;
9577
- const Ye = Qe[te], Re = Ye == null || Ye === "" ? 0 : Number(Ye);
9575
+ const Ue = (wt = I[Le]) == null ? void 0 : wt.data;
9576
+ if (Ue === void 0) return null;
9577
+ const Ye = Ue[te], Re = Ye == null || Ye === "" ? 0 : Number(Ye);
9578
9578
  return Number.isNaN(Re) ? null : Se > Re ? { available: Re, qty: Se } : null;
9579
9579
  }, be = r.qty_warning ? r.qty_warning.label ?? ((Bt = (r.related_columns ?? []).find((te) => {
9580
9580
  var ke;
@@ -9596,8 +9596,8 @@ function CatalogPickerField({
9596
9596
  if (!te || te.status !== "failed") return null;
9597
9597
  const ke = te.payload, Se = /* @__PURE__ */ new Set();
9598
9598
  for (const Le of Array.isArray(ke == null ? void 0 : ke.products) ? ke.products : [])
9599
- for (const Qe of Object.values(Le ?? {}))
9600
- (typeof Qe == "string" || typeof Qe == "number") && Qe !== "" && Se.add(String(Qe));
9599
+ for (const Ue of Object.values(Le ?? {}))
9600
+ (typeof Ue == "string" || typeof Ue == "number") && Ue !== "" && Se.add(String(Ue));
9601
9601
  return Se.size === 0 ? null : { idents: Se, error: te.last_error ?? "Submission failed" };
9602
9602
  }, [Y]), de = ne.map((te) => te.key).join(","), { data: he } = useQuery({
9603
9603
  queryKey: ["catalog-suberr-idents", C, Ne.join(","), de],
@@ -9621,8 +9621,8 @@ function CatalogPickerField({
9621
9621
  return [
9622
9622
  Ht(te),
9623
9623
  ...Ne.map((Le) => {
9624
- const Qe = (ke == null ? void 0 : ke[Le]) ?? $t(te)[Le];
9625
- return Qe != null && Qe !== "" ? String(Qe) : null;
9624
+ const Ue = (ke == null ? void 0 : ke[Le]) ?? $t(te)[Le];
9625
+ return Ue != null && Ue !== "" ? String(Ue) : null;
9626
9626
  })
9627
9627
  ].some((Le) => Le && ue.idents.has(Le)) ? ue.error : null;
9628
9628
  }, qe = r.summary_fields ?? [], Pe = H.map((te) => String(te.id)).join(","), ge = useQueries({
@@ -9637,11 +9637,11 @@ function CatalogPickerField({
9637
9637
  fields: `${Se.fk_to_child},${Se.related_field}`,
9638
9638
  filter: JSON.stringify({ [Se.fk_to_child]: { _in: ke } })
9639
9639
  })
9640
- ).then((vt) => vt.data ?? []).catch(() => []), Qe = [...new Set(Le.map((vt) => String(vt[Se.related_field])))], Ye = Se.label_field ?? "name", Re = Qe.length ? await l.request(
9640
+ ).then((vt) => vt.data ?? []).catch(() => []), Ue = [...new Set(Le.map((vt) => String(vt[Se.related_field])))], Ye = Se.label_field ?? "name", Re = Ue.length ? await l.request(
9641
9641
  get$1(`/items/${Se.related_collection}`, {
9642
9642
  limit: 500,
9643
9643
  fields: `id,${Ye}`,
9644
- filter: JSON.stringify({ id: { _in: Qe } })
9644
+ filter: JSON.stringify({ id: { _in: Ue } })
9645
9645
  })
9646
9646
  ).then((vt) => vt.data ?? []).catch(() => []) : [], wt = new Map(Re.map((vt) => [String(vt.id), String(vt[Ye] ?? vt.id)])), Rt = {};
9647
9647
  for (const vt of Le) {
@@ -9654,13 +9654,13 @@ function CatalogPickerField({
9654
9654
  staleTime: 15e3
9655
9655
  }))
9656
9656
  }), He = (te, ke) => {
9657
- var Qe, Ye;
9657
+ var Ue, Ye;
9658
9658
  if (!te.m2m) return ke.row[te.field];
9659
9659
  const Se = qe.filter((Re) => Re.m2m).findIndex((Re) => Re.field === te.field);
9660
9660
  if (Se === -1) return;
9661
9661
  const Le = ke.row.id;
9662
9662
  if (Le != null)
9663
- return (Ye = (Qe = ge[Se]) == null ? void 0 : Qe.data) == null ? void 0 : Ye[String(Le)];
9663
+ return (Ye = (Ue = ge[Se]) == null ? void 0 : Ue.data) == null ? void 0 : Ye[String(Le)];
9664
9664
  }, mt = r.columns ?? [], yt = r.related_columns ?? [], jt = mt.filter((te) => !te.summary_only), Tt = yt.filter((te) => !te.summary_only), ot = mt.filter((te) => !te.sections_only), ht = yt.filter((te) => !te.sections_only), Pt = jt.length > 0 || Tt.length > 0, st = (te, ke) => {
9665
9665
  let Se = te;
9666
9666
  for (const Le of ke.split(".")) {
@@ -9715,14 +9715,14 @@ function CatalogPickerField({
9715
9715
  for (const Se of P) {
9716
9716
  const Le = applyDisplayTemplate(T, Se);
9717
9717
  if (te && !Le.toLowerCase().includes(te)) continue;
9718
- const Qe = De(Se) || "Uncategorized";
9719
- ke.has(Qe) || ke.set(Qe, []), ke.get(Qe).push({ id: String(Se.id), label: Le, row: Se });
9718
+ const Ue = De(Se) || "Uncategorized";
9719
+ ke.has(Ue) || ke.set(Ue, []), ke.get(Ue).push({ id: String(Se.id), label: Le, row: Se });
9720
9720
  }
9721
9721
  return [...ke.entries()].sort(
9722
9722
  ([Se], [Le]) => Se === "Uncategorized" ? 1 : Le === "Uncategorized" ? -1 : Se.localeCompare(Le)
9723
9723
  ).map(([Se, Le]) => ({
9724
9724
  name: Se,
9725
- items: Le.sort((Qe, Ye) => Qe.label.localeCompare(Ye.label))
9725
+ items: Le.sort((Ue, Ye) => Ue.label.localeCompare(Ye.label))
9726
9726
  }));
9727
9727
  }, [P, T, x, r.section_by]);
9728
9728
  if (!k.current && at.length > 0) {
@@ -9738,13 +9738,13 @@ function CatalogPickerField({
9738
9738
  if (!Se.copy_to) continue;
9739
9739
  let Le = le(Se.key, te);
9740
9740
  if (Le === void 0) {
9741
- const Qe = resolveRelatedMatch(Se.match, j);
9742
- if (Qe === null) continue;
9741
+ const Ue = resolveRelatedMatch(Se.match, j);
9742
+ if (Ue === null) continue;
9743
9743
  Le = await l.request(
9744
9744
  get$1(`/items/${Se.collection}`, {
9745
9745
  limit: 1,
9746
9746
  fields: `${Se.item_field},${Se.value_field}`,
9747
- filter: JSON.stringify({ ...Qe, [Se.item_field]: { _eq: te } })
9747
+ filter: JSON.stringify({ ...Ue, [Se.item_field]: { _eq: te } })
9748
9748
  })
9749
9749
  ).then((Ye) => {
9750
9750
  var Re, wt;
@@ -9757,18 +9757,18 @@ function CatalogPickerField({
9757
9757
  return ke;
9758
9758
  }
9759
9759
  function qt(te, ke, Se, Le = {}) {
9760
- const Qe = {
9760
+ const Ue = {
9761
9761
  [r.item_field]: Se.id ?? te,
9762
9762
  [h]: ke
9763
9763
  };
9764
9764
  for (const [Ye, Re] of Object.entries(r.copy_fields ?? {}))
9765
- Se[Re] !== void 0 && (Qe[Ye] = Se[Re]);
9766
- Object.assign(Qe, Le);
9765
+ Se[Re] !== void 0 && (Ue[Ye] = Se[Re]);
9766
+ Object.assign(Ue, Le);
9767
9767
  for (const [Ye, Re] of Object.entries(r.compute_fields ?? {})) {
9768
- const wt = evalClientFormula(Re, Qe);
9769
- wt !== null && (Qe[Ye] = wt);
9768
+ const wt = evalClientFormula(Re, Ue);
9769
+ wt !== null && (Ue[Ye] = wt);
9770
9770
  }
9771
- return Qe;
9771
+ return Ue;
9772
9772
  }
9773
9773
  async function et(te, ke, Se) {
9774
9774
  const Le = ke.trim() === "" ? 0 : Number(ke);
@@ -9820,7 +9820,7 @@ function CatalogPickerField({
9820
9820
  async function Jt(te, ke, Se) {
9821
9821
  const Le = Se.trim() === "" ? null : Number(Se);
9822
9822
  if (Se.trim() !== "" && Number.isNaN(Le)) return;
9823
- const Qe = (Re) => {
9823
+ const Ue = (Re) => {
9824
9824
  const wt = { ...Re, [ke]: Le };
9825
9825
  for (const [Rt, vt] of Object.entries(r.compute_fields ?? {})) {
9826
9826
  const Kt = evalClientFormula(vt, wt);
@@ -9831,14 +9831,14 @@ function CatalogPickerField({
9831
9831
  if (m) {
9832
9832
  const Re = B.get(te);
9833
9833
  if (Re === void 0) return;
9834
- o == null || o.updateRow(e, t, Re, Qe(K[Re]));
9834
+ o == null || o.updateRow(e, t, Re, Ue(K[Re]));
9835
9835
  return;
9836
9836
  }
9837
9837
  const Ye = G.get(te);
9838
9838
  if ((Ye == null ? void 0 : Ye.id) != null) {
9839
9839
  f((Re) => new Set(Re).add(te));
9840
9840
  try {
9841
- const { id: Re, ...wt } = Qe(Ye);
9841
+ const { id: Re, ...wt } = Ue(Ye);
9842
9842
  await l.request(patch$1(`/items/${e}/${Ye.id}`, wt)), i.invalidateQueries({ queryKey: ["o2m-rows", e, t, s] });
9843
9843
  } catch {
9844
9844
  } finally {
@@ -9863,18 +9863,18 @@ function CatalogPickerField({
9863
9863
  var Re;
9864
9864
  return ((Re = Ye.data) == null ? void 0 : Re[0]) ?? { id: te };
9865
9865
  }).catch(() => ({ id: te })));
9866
- const Qe = (ie(ke) ?? 0) + 1;
9867
- await et(ke, String(Qe), Le);
9866
+ const Ue = (ie(ke) ?? 0) + 1;
9867
+ await et(ke, String(Ue), Le);
9868
9868
  }
9869
9869
  const is = ne.length, Vt = Object.keys(r.copy_fields ?? {}), _s = Object.keys(r.compute_fields ?? {}), Ms = (te, ke) => {
9870
- const Se = ie(te), Le = F[te], Qe = Le !== void 0 ? Le : Se && Se > 0 ? String(Se) : "";
9870
+ const Se = ie(te), Le = F[te], Ue = Le !== void 0 ? Le : Se && Se > 0 ? String(Se) : "";
9871
9871
  return /* @__PURE__ */ jsx(
9872
9872
  "input",
9873
9873
  {
9874
9874
  type: "number",
9875
9875
  min: 0,
9876
9876
  disabled: a,
9877
- value: Qe,
9877
+ value: Ue,
9878
9878
  placeholder: "0",
9879
9879
  onChange: (Ye) => y((Re) => ({ ...Re, [te]: Ye.target.value })),
9880
9880
  onBlur: (Ye) => {
@@ -9965,7 +9965,7 @@ function CatalogPickerField({
9965
9965
  !N.has("__favorites__") && we.filter(
9966
9966
  (te) => !x.trim() || applyDisplayTemplate(T, te).toLowerCase().includes(x.trim().toLowerCase())
9967
9967
  ).map((te, ke) => {
9968
- const Se = String(te.id), Le = ie(Se), Qe = J(Se);
9968
+ const Se = String(te.id), Le = ie(Se), Ue = J(Se);
9969
9969
  return /* @__PURE__ */ jsxs(
9970
9970
  "div",
9971
9971
  {
@@ -9973,17 +9973,17 @@ function CatalogPickerField({
9973
9973
  "flex items-center gap-2 border-b border-slate-100 px-3 py-1 dark:border-border/50",
9974
9974
  ke % 2 === 0 ? "bg-white dark:bg-background" : "bg-slate-50/50 dark:bg-muted/30",
9975
9975
  (Le ?? 0) > 0 && "bg-[#00ceff0d]",
9976
- Qe && "bg-amber-50 dark:bg-amber-900/15"
9976
+ Ue && "bg-amber-50 dark:bg-amber-900/15"
9977
9977
  ),
9978
9978
  children: [
9979
9979
  ve(Se),
9980
9980
  /* @__PURE__ */ jsx("span", { className: Xt, children: applyDisplayTemplate(T, te) }),
9981
9981
  It(Se, te),
9982
- Qe && /* @__PURE__ */ jsx(
9982
+ Ue && /* @__PURE__ */ jsx(
9983
9983
  AlertTriangle,
9984
9984
  {
9985
9985
  className: "h-3.5 w-3.5 shrink-0 text-amber-500",
9986
- "aria-label": `${be} ${Qe.available} — ${Qe.qty} requested`
9986
+ "aria-label": `${be} ${Ue.available} — ${Ue.qty} requested`
9987
9987
  }
9988
9988
  ),
9989
9989
  b.has(Se) && /* @__PURE__ */ jsx(Loader2, { className: "h-3 w-3 shrink-0 animate-spin text-slate-400" }),
@@ -9996,7 +9996,7 @@ function CatalogPickerField({
9996
9996
  ] }),
9997
9997
  g.length === 0 && at.map((te) => {
9998
9998
  const ke = N.has(te.name), Se = te.items.reduce(
9999
- (Le, Qe) => Le + ((ie(Qe.id) ?? 0) > 0 ? 1 : 0),
9999
+ (Le, Ue) => Le + ((ie(Ue.id) ?? 0) > 0 ? 1 : 0),
10000
10000
  0
10001
10001
  );
10002
10002
  return /* @__PURE__ */ jsxs(Fragment$1, { children: [
@@ -10005,8 +10005,8 @@ function CatalogPickerField({
10005
10005
  {
10006
10006
  type: "button",
10007
10007
  onClick: () => v((Le) => {
10008
- const Qe = new Set(Le);
10009
- return Qe.has(te.name) ? Qe.delete(te.name) : Qe.add(te.name), Qe;
10008
+ const Ue = new Set(Le);
10009
+ return Ue.has(te.name) ? Ue.delete(te.name) : Ue.add(te.name), Ue;
10010
10010
  }),
10011
10011
  className: "flex w-full items-center gap-1.5 border-b border-slate-200 bg-slate-100/80 px-2 py-1.5 text-left dark:border-border dark:bg-muted",
10012
10012
  children: [
@@ -10028,14 +10028,14 @@ function CatalogPickerField({
10028
10028
  ]
10029
10029
  }
10030
10030
  ),
10031
- !ke && te.items.map((Le, Qe) => {
10031
+ !ke && te.items.map((Le, Ue) => {
10032
10032
  const Ye = ie(Le.id), Re = J(Le.id);
10033
10033
  return /* @__PURE__ */ jsxs(
10034
10034
  "div",
10035
10035
  {
10036
10036
  className: cn$1(
10037
10037
  "flex items-center gap-2 border-b border-slate-100 px-3 py-1 dark:border-border/50",
10038
- Qe % 2 === 0 ? "bg-white dark:bg-background" : "bg-slate-50/50 dark:bg-muted/30",
10038
+ Ue % 2 === 0 ? "bg-white dark:bg-background" : "bg-slate-50/50 dark:bg-muted/30",
10039
10039
  (Ye ?? 0) > 0 && "bg-[#00ceff0d]",
10040
10040
  Re && "bg-amber-50 dark:bg-amber-900/15"
10041
10041
  ),
@@ -10105,7 +10105,7 @@ function CatalogPickerField({
10105
10105
  ] })
10106
10106
  ] }),
10107
10107
  ne.length === 0 ? /* @__PURE__ */ jsx("p", { className: "px-3 py-4 text-center text-slate-400", children: "Nothing picked yet" }) : (() => {
10108
- const te = ot.filter((Re) => !Re.format), ke = te[0], Se = te.slice(1), Le = ot.filter((Re) => !!Re.format), Qe = (Re, wt) => Re === !0 || Re === "true" ? "✓" : Re === !1 || Re === "false" || Re == null || Re === "" ? "—" : _t(Re, wt), Ye = (Re) => /* @__PURE__ */ jsx("span", { className: "w-20 shrink-0 text-right text-[11px] font-medium text-slate-500", children: Re });
10108
+ const te = ot.filter((Re) => !Re.format), ke = te[0], Se = te.slice(1), Le = ot.filter((Re) => !!Re.format), Ue = (Re, wt) => Re === !0 || Re === "true" ? "✓" : Re === !1 || Re === "false" || Re == null || Re === "" ? "—" : _t(Re, wt), Ye = (Re) => /* @__PURE__ */ jsx("span", { className: "w-20 shrink-0 text-right text-[11px] font-medium text-slate-500", children: Re });
10109
10109
  return /* @__PURE__ */ jsxs("div", { children: [
10110
10110
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 border-b border-slate-200 px-3 py-1.5 dark:border-border", children: [
10111
10111
  /* @__PURE__ */ jsx("span", { className: "flex-1 text-[11px] font-medium text-slate-500", children: "Item" }),
@@ -10229,19 +10229,19 @@ function CatalogPickerField({
10229
10229
  Le.map((bt) => /* @__PURE__ */ jsxs("span", { className: "whitespace-nowrap", children: [
10230
10230
  /* @__PURE__ */ jsx("span", { className: "text-slate-500 dark:text-muted-foreground", children: bt.label ?? titleCase$2(bt.field.split(".")[0]) }),
10231
10231
  " ",
10232
- /* @__PURE__ */ jsx("span", { className: "font-medium tabular-nums text-slate-700 dark:text-slate-200", children: Qe(st($t(Re.key), bt.field), bt.format) })
10232
+ /* @__PURE__ */ jsx("span", { className: "font-medium tabular-nums text-slate-700 dark:text-slate-200", children: Ue(st($t(Re.key), bt.field), bt.format) })
10233
10233
  ] }, bt.field)),
10234
10234
  ht.map((bt) => /* @__PURE__ */ jsxs("span", { className: "whitespace-nowrap", children: [
10235
10235
  /* @__PURE__ */ jsx("span", { className: "text-slate-500 dark:text-muted-foreground", children: bt.label ?? titleCase$2(bt.key) }),
10236
10236
  " ",
10237
- /* @__PURE__ */ jsx("span", { className: "font-medium tabular-nums text-slate-700 dark:text-slate-200", children: Qe(le(bt.key, Re.key), bt.format) })
10237
+ /* @__PURE__ */ jsx("span", { className: "font-medium tabular-nums text-slate-700 dark:text-slate-200", children: Ue(le(bt.key, Re.key), bt.format) })
10238
10238
  ] }, bt.key)),
10239
10239
  qe.map((bt) => {
10240
10240
  const St = He(bt, Re);
10241
10241
  return /* @__PURE__ */ jsxs("span", { className: "whitespace-nowrap", children: [
10242
10242
  /* @__PURE__ */ jsx("span", { className: "text-slate-500 dark:text-muted-foreground", children: bt.label ?? titleCase$2(bt.field) }),
10243
10243
  " ",
10244
- /* @__PURE__ */ jsx("span", { className: "font-medium text-slate-700 dark:text-slate-200", children: Qe(St, bt.format) })
10244
+ /* @__PURE__ */ jsx("span", { className: "font-medium text-slate-700 dark:text-slate-200", children: Ue(St, bt.format) })
10245
10245
  ] }, bt.field);
10246
10246
  })
10247
10247
  ] }),
@@ -15355,7 +15355,7 @@ function ItemActionButtons({
15355
15355
  ),
15356
15356
  onSuccess: (o) => {
15357
15357
  var d;
15358
- toast.success(((d = o == null ? void 0 : o.data) == null ? void 0 : d.message) ?? "Action completed"), n.invalidateQueries({ queryKey: ["item", e, String(t)] }), n.invalidateQueries({ queryKey: ["erp-submissions", e, String(t)] });
15358
+ toast.success(((d = o == null ? void 0 : o.data) == null ? void 0 : d.message) ?? "Action completed"), n.invalidateQueries({ queryKey: ["item", e, String(t)] }), n.invalidateQueries({ queryKey: ["erp-submissions", e, String(t)] }), n.invalidateQueries({ queryKey: ["o2m-rows"] }), n.invalidateQueries({ queryKey: ["pipeline-instance", e, String(t)] });
15359
15359
  },
15360
15360
  onError: (o, d) => {
15361
15361
  const c = o == null ? void 0 : o.response;
@@ -18591,7 +18591,7 @@ function ItemEditForm({
18591
18591
  is((O) => [...O, $]);
18592
18592
  }, []), [_s, Ms] = useState([]), Bt = useCallback(($) => {
18593
18593
  Ms((O) => [...O, $]);
18594
- }, []), [te, ke] = useState(/* @__PURE__ */ new Map()), [Se, Le] = useState(/* @__PURE__ */ new Map()), [Qe, Ye] = useState(/* @__PURE__ */ new Map()), Re = useMemo(() => ({
18594
+ }, []), [te, ke] = useState(/* @__PURE__ */ new Map()), [Se, Le] = useState(/* @__PURE__ */ new Map()), [Ue, Ye] = useState(/* @__PURE__ */ new Map()), Re = useMemo(() => ({
18595
18595
  getPendingRows: ($, O) => te.get(`${$}.${O}`) ?? [],
18596
18596
  queueRow: ($, O, W) => ke((Z) => {
18597
18597
  const ae = new Map(Z), ye = `${$}.${O}`;
@@ -18610,7 +18610,7 @@ function ItemEditForm({
18610
18610
  return Ke.splice(Z, 0, Ae), ye.set(Te, Ke), ye;
18611
18611
  }),
18612
18612
  getPendingEdits: ($, O) => Se.get(`${$}.${O}`) ?? /* @__PURE__ */ new Map(),
18613
- getPendingDeletes: ($, O) => Qe.get(`${$}.${O}`) ?? /* @__PURE__ */ new Set(),
18613
+ getPendingDeletes: ($, O) => Ue.get(`${$}.${O}`) ?? /* @__PURE__ */ new Set(),
18614
18614
  queueEdit: ($, O, W, Z) => Le((ae) => {
18615
18615
  const ye = new Map(ae), Te = `${$}.${O}`, Ke = new Map(ye.get(Te) ?? []);
18616
18616
  return Ke.set(W, { ...Ke.get(W) ?? {}, ...Z }), ye.set(Te, Ke), ye;
@@ -18632,7 +18632,7 @@ function ItemEditForm({
18632
18632
  const ae = new Map(Z), ye = `${$}.${O}`, Te = new Set(ae.get(ye) ?? []);
18633
18633
  return Te.delete(W), ae.set(ye, Te), ae;
18634
18634
  })
18635
- }), [te, Se, Qe]), [wt, Rt] = useState([]), vt = useRef(!1), Kt = useRef(!1), [xt, bt] = useState(/* @__PURE__ */ new Map()), [St, bs] = useState(/* @__PURE__ */ new Map()), tt = useMemo(
18635
+ }), [te, Se, Ue]), [wt, Rt] = useState([]), vt = useRef(!1), Kt = useRef(!1), [xt, bt] = useState(/* @__PURE__ */ new Map()), [St, bs] = useState(/* @__PURE__ */ new Map()), tt = useMemo(
18636
18636
  () => ({
18637
18637
  getStagedLinks: ($) => xt.get($) ?? [],
18638
18638
  getStagedUnlinks: ($) => St.get($) ?? /* @__PURE__ */ new Set(),
@@ -18686,9 +18686,9 @@ function ItemEditForm({
18686
18686
  }
18687
18687
  const Ze = [];
18688
18688
  let ut = !1;
18689
- const Ue = 10;
18690
- for (let Be = 0; Be < $.lines.length; Be += Ue) {
18691
- const Xe = $.lines.slice(Be, Be + Ue), pt = await Promise.all(
18689
+ const Qe = 10;
18690
+ for (let Be = 0; Be < $.lines.length; Be += Qe) {
18691
+ const Xe = $.lines.slice(Be, Be + Qe), pt = await Promise.all(
18692
18692
  Xe.map(
18693
18693
  (kt) => q.request(
18694
18694
  post$1("/field-rules/evaluate", {
@@ -18743,7 +18743,7 @@ function ItemEditForm({
18743
18743
  }, [e, K, Re, tt, E, q]), [es, un] = useState(null), [ln, Ln] = useState(!1), En = useCallback(
18744
18744
  async ($, O) => {
18745
18745
  const W = O.reimport;
18746
- if (!W || (It || [...te.values()].some((Ae) => Ae.length > 0) || [...Se.values()].some((Ae) => Ae.size > 0) || [...Qe.values()].some((Ae) => Ae.size > 0)) && !window.confirm(
18746
+ if (!W || (It || [...te.values()].some((Ae) => Ae.length > 0) || [...Se.values()].some((Ae) => Ae.size > 0) || [...Ue.values()].some((Ae) => Ae.size > 0)) && !window.confirm(
18747
18747
  "Unsaved changes will be combined with the re-import staging. Continue?"
18748
18748
  ))
18749
18749
  return;
@@ -18790,7 +18790,7 @@ function ItemEditForm({
18790
18790
  }
18791
18791
  Rt([]), un({ diff: Ke, result: $, template: O, existingRows: Te });
18792
18792
  },
18793
- [It, te, Se, Qe, K, e, q, g]
18793
+ [It, te, Se, Ue, K, e, q, g]
18794
18794
  ), rs = useCallback(
18795
18795
  async ($, O, W, Z) => {
18796
18796
  const ae = W.reimport;
@@ -18803,8 +18803,8 @@ function ItemEditForm({
18803
18803
  if (ae.header_fields === "overwrite")
18804
18804
  Je[Ze] = ut;
18805
18805
  else {
18806
- const Ue = ge.current[Ze];
18807
- (Ue == null || Ue === "") && (Je[Ze] = ut);
18806
+ const Qe = ge.current[Ze];
18807
+ (Qe == null || Qe === "") && (Je[Ze] = ut);
18808
18808
  }
18809
18809
  Object.keys(Je).length > 0 && (ge.current = { ...ge.current, ...Je }, Pe((Ze) => ({ ...Ze, ...Je })));
18810
18810
  }
@@ -18815,7 +18815,7 @@ function ItemEditForm({
18815
18815
  const Je = Ke.many_collection, Ze = Ke.many_field;
18816
18816
  let ut = $.creates;
18817
18817
  if (ut.length > 0) {
18818
- const Ue = (E ?? []).find((kt) => kt.field === O.line_target_field), Be = Ue == null ? void 0 : Ue.options, Xe = typeof Be == "string" ? (() => {
18818
+ const Qe = (E ?? []).find((kt) => kt.field === O.line_target_field), Be = Qe == null ? void 0 : Qe.options, Xe = typeof Be == "string" ? (() => {
18819
18819
  try {
18820
18820
  return JSON.parse(Be);
18821
18821
  } catch {
@@ -18860,18 +18860,18 @@ function ItemEditForm({
18860
18860
  }), ut = ut.map((Ie, nt) => ({ ...Ie, ...Ot[nt] }));
18861
18861
  }
18862
18862
  }
18863
- for (const Ue of ut)
18864
- Re.queueRow(Je, Ze, Ue);
18865
- for (const Ue of $.updates)
18866
- Re.queueEdit(Je, Ze, Ue.id, Ue.changes);
18867
- for (const Ue of $.deletes)
18868
- Re.queueDelete(Je, Ze, Ue);
18863
+ for (const Qe of ut)
18864
+ Re.queueRow(Je, Ze, Qe);
18865
+ for (const Qe of $.updates)
18866
+ Re.queueEdit(Je, Ze, Qe.id, Qe.changes);
18867
+ for (const Qe of $.deletes)
18868
+ Re.queueDelete(Je, Ze, Qe);
18869
18869
  if (ae.lines === "upsert" || ae.lines === "upsert_delete") {
18870
- const Ue = buildReimportFileRows(O), Be = /* @__PURE__ */ new Map();
18870
+ const Qe = buildReimportFileRows(O), Be = /* @__PURE__ */ new Map();
18871
18871
  for (const pt of Z)
18872
18872
  Be.set(reimportMatchKey(pt, ae.match_by), String(pt.id));
18873
18873
  const Xe = /* @__PURE__ */ new Map();
18874
- for (const pt of Ue) {
18874
+ for (const pt of Qe) {
18875
18875
  const kt = Be.get(reimportMatchKey(pt, ae.match_by));
18876
18876
  if (kt)
18877
18877
  for (const [Et, Ot] of Object.entries(pt)) {
@@ -18947,8 +18947,8 @@ function ItemEditForm({
18947
18947
  fields: "id",
18948
18948
  limit: 2e3
18949
18949
  })
18950
- ).then((Ue) => Ue.data ?? []);
18951
- for (const Ue of ut) tt.stageUnlink(Ze, Ue.id);
18950
+ ).then((Qe) => Qe.data ?? []);
18951
+ for (const Qe of ut) tt.stageUnlink(Ze, Qe.id);
18952
18952
  } catch {
18953
18953
  Te.push({
18954
18954
  severity: "error",
@@ -18964,7 +18964,7 @@ function ItemEditForm({
18964
18964
  if (ye && Je === ye) continue;
18965
18965
  const ut = Ae(Je);
18966
18966
  if (ut) {
18967
- const Ue = ut.one_field ?? `${ut.many_collection}.${ut.junction_field}`;
18967
+ const Qe = ut.one_field ?? `${ut.many_collection}.${ut.junction_field}`;
18968
18968
  let Be = /* @__PURE__ */ new Set();
18969
18969
  try {
18970
18970
  const Xe = await q.request(
@@ -18980,7 +18980,7 @@ function ItemEditForm({
18980
18980
  } catch {
18981
18981
  }
18982
18982
  for (const Xe of Ze)
18983
- Be.has(String(Xe)) || tt.stageLink(Ue, Xe);
18983
+ Be.has(String(Xe)) || tt.stageLink(Qe, Xe);
18984
18984
  } else
18985
18985
  Te.push({
18986
18986
  severity: "error",
@@ -19084,15 +19084,15 @@ function ItemEditForm({
19084
19084
  St.get(W.stagingKey)
19085
19085
  );
19086
19086
  }), $;
19087
- }, [Bs, Ss, xt, St, g, M]), Ut = useRef(ms);
19088
- Ut.current = ms;
19087
+ }, [Bs, Ss, xt, St, g, M]), Qt = useRef(ms);
19088
+ Qt.current = ms;
19089
19089
  const ts = useCallback(
19090
19090
  ($) => {
19091
19091
  var O;
19092
19092
  return (O = ms[$]) == null ? void 0 : O.ids;
19093
19093
  },
19094
19094
  [ms]
19095
- ), Un = useCallback(
19095
+ ), Qn = useCallback(
19096
19096
  ($) => {
19097
19097
  var O;
19098
19098
  return ((O = ms[$]) == null ? void 0 : O.known) ?? !0;
@@ -19127,16 +19127,16 @@ function ItemEditForm({
19127
19127
  const Ze = Je.data;
19128
19128
  if (!Ze) return;
19129
19129
  const ut = {};
19130
- for (const [Ue, Be] of Object.entries(Ke)) {
19130
+ for (const [Qe, Be] of Object.entries(Ke)) {
19131
19131
  const Xe = String(Be).split("||").map((kt) => kt.trim());
19132
19132
  let pt = null;
19133
19133
  for (const kt of Xe)
19134
19134
  if (pt = Ze[kt], pt != null && pt !== "") break;
19135
- ut[Ue] = pt ?? null;
19135
+ ut[Qe] = pt ?? null;
19136
19136
  }
19137
- ge.current = { ...ge.current, ...ut }, Pe((Ue) => ({ ...Ue, ...ut })), Xt(!0);
19138
- for (const [Ue, Be] of Object.entries(ut))
19139
- Ue !== $ && Be != null && Be !== "" && gs(Ue, Be, W + 1);
19137
+ ge.current = { ...ge.current, ...ut }, Pe((Qe) => ({ ...Qe, ...ut })), Xt(!0);
19138
+ for (const [Qe, Be] of Object.entries(ut))
19139
+ Qe !== $ && Be != null && Be !== "" && gs(Qe, Be, W + 1);
19140
19140
  }).catch(() => {
19141
19141
  });
19142
19142
  }
@@ -19149,7 +19149,7 @@ function ItemEditForm({
19149
19149
  for (const [ye, Te] of Object.entries(Z)) {
19150
19150
  const Ke = Bs.get(ye);
19151
19151
  if (!Ke) continue;
19152
- const Ae = idsNeedingStaging(Te, (ae = Ut.current[ye]) == null ? void 0 : ae.ids);
19152
+ const Ae = idsNeedingStaging(Te, (ae = Qt.current[ye]) == null ? void 0 : ae.ids);
19153
19153
  for (const Je of Ae) tt.stageLink(Ke.stagingKey, Je);
19154
19154
  }
19155
19155
  if (Object.keys(O).length > 0) {
@@ -19208,14 +19208,14 @@ function ItemEditForm({
19208
19208
  }
19209
19209
  for (const [$, O] of Tn) {
19210
19210
  const W = xt.get(O.stagingKey), Z = St.get(O.stagingKey), ae = gn.current[$];
19211
- ae && ae.links === W && ae.unlinks === Z || (gn.current[$] = { links: W, unlinks: Z }, Un($) && zs($, ts($) ?? []));
19211
+ ae && ae.links === W && ae.unlinks === Z || (gn.current[$] = { links: W, unlinks: Z }, Qn($) && zs($, ts($) ?? []));
19212
19212
  }
19213
19213
  }, [
19214
19214
  xt,
19215
19215
  St,
19216
19216
  Tn,
19217
19217
  ts,
19218
- Un,
19218
+ Qn,
19219
19219
  zs
19220
19220
  ]);
19221
19221
  const Es = useCallback(
@@ -19256,7 +19256,7 @@ function ItemEditForm({
19256
19256
  enabled: !!g && !M,
19257
19257
  staleTime: 3e4
19258
19258
  }))
19259
- }), Us = useMemo(() => {
19259
+ }), Qs = useMemo(() => {
19260
19260
  const $ = {};
19261
19261
  return on.forEach((O, W) => {
19262
19262
  var ae;
@@ -19273,13 +19273,13 @@ function ItemEditForm({
19273
19273
  });
19274
19274
  },
19275
19275
  [E]
19276
- ), Qn = N && !M && !!(B != null && B.item_locking_enabled), {
19276
+ ), Un = N && !M && !!(B != null && B.item_locking_enabled), {
19277
19277
  lockHolder: Wn,
19278
19278
  acquired: Xs,
19279
19279
  isReadOnly: Zs,
19280
19280
  takeOver: Vn,
19281
19281
  takingOver: ls
19282
- } = useItemLock(e, M ? void 0 : g, Qn), Cs = (L == null ? void 0 : L.assignments) ?? [], vn = Cs.some(($) => $.lock_conditions), Os = !!(B != null && B.addendums_enabled) && !M, { data: Qs } = useQuery({
19282
+ } = useItemLock(e, M ? void 0 : g, Un), Cs = (L == null ? void 0 : L.assignments) ?? [], vn = Cs.some(($) => $.lock_conditions), Os = !!(B != null && B.addendums_enabled) && !M, { data: Us } = useQuery({
19283
19283
  queryKey: ["current-user-me"],
19284
19284
  queryFn: () => q.request(get$1("/users/me")).then(($) => $.data ?? null),
19285
19285
  staleTime: 5 * 6e4,
@@ -19296,7 +19296,7 @@ function ItemEditForm({
19296
19296
  try {
19297
19297
  const Z = JSON.parse(B.addendum_allowed_roles);
19298
19298
  if (Array.isArray(Z) && Z.length > 0) {
19299
- const ae = (Qs == null ? void 0 : Qs.role) ?? null;
19299
+ const ae = (Us == null ? void 0 : Us.role) ?? null;
19300
19300
  if (!ae || !Z.includes(ae)) return !1;
19301
19301
  }
19302
19302
  } catch {
@@ -19311,7 +19311,7 @@ function ItemEditForm({
19311
19311
  } catch {
19312
19312
  }
19313
19313
  return !0;
19314
- }, [Os, B == null ? void 0 : B.addendum_allowed_roles, B == null ? void 0 : B.addendum_allowed_states, Qs == null ? void 0 : Qs.role, ps]), { data: Zt = [] } = useQuery({
19314
+ }, [Os, B == null ? void 0 : B.addendum_allowed_roles, B == null ? void 0 : B.addendum_allowed_states, Us == null ? void 0 : Us.role, ps]), { data: Zt = [] } = useQuery({
19315
19315
  queryKey: ["addendums", e, g],
19316
19316
  queryFn: () => q.request(
19317
19317
  get$1(`/addendums/${e}/${g}`)
@@ -19406,7 +19406,7 @@ function ItemEditForm({
19406
19406
  })
19407
19407
  );
19408
19408
  }), $;
19409
- }, [$s, Ts]), [Hs, Dn] = useState(() => /* @__PURE__ */ new Set()), U = useCallback(($, O) => {
19409
+ }, [$s, Ts]), [Hs, Dn] = useState(() => /* @__PURE__ */ new Set()), Q = useCallback(($, O) => {
19410
19410
  Dn((W) => {
19411
19411
  if (W.has($) === O) return W;
19412
19412
  const Z = new Set(W);
@@ -19422,7 +19422,7 @@ function ItemEditForm({
19422
19422
  Z !== null && $.set(O.field, Z);
19423
19423
  }
19424
19424
  return $;
19425
- }, [E, pn, Rn]), Q = useMemo(
19425
+ }, [E, pn, Rn]), U = useMemo(
19426
19426
  () => tn ? { ...qe, ...tn } : qe,
19427
19427
  [qe, tn]
19428
19428
  ), se = J !== "original", $e = se ? "nivaro_addendums" : e, Oe = se ? J : g, Ve = useMemo(() => {
@@ -19487,22 +19487,22 @@ function ItemEditForm({
19487
19487
  if (!O.one_field || !O.many_collection || !O.many_field) return;
19488
19488
  const Z = ((ut = nn[W]) == null ? void 0 : ut.data) ?? [], ae = ds[O.one_field];
19489
19489
  if (!ae) return;
19490
- const ye = `${O.many_collection}.${O.many_field}`, Te = Se.get(ye) ?? /* @__PURE__ */ new Map(), Ke = Qe.get(ye) ?? /* @__PURE__ */ new Set(), Ae = te.get(ye) ?? [], Je = [
19491
- ...Z.filter((Ue) => !Ke.has(String(Ue.id))).map((Ue) => Te.has(String(Ue.id)) ? { ...Ue, ...Te.get(String(Ue.id)) } : Ue),
19490
+ const ye = `${O.many_collection}.${O.many_field}`, Te = Se.get(ye) ?? /* @__PURE__ */ new Map(), Ke = Ue.get(ye) ?? /* @__PURE__ */ new Set(), Ae = te.get(ye) ?? [], Je = [
19491
+ ...Z.filter((Qe) => !Ke.has(String(Qe.id))).map((Qe) => Te.has(String(Qe.id)) ? { ...Qe, ...Te.get(String(Qe.id)) } : Qe),
19492
19492
  ...Ae
19493
19493
  ];
19494
19494
  if (ae.agg === "count") {
19495
19495
  $[O.one_field] = Je.length;
19496
19496
  return;
19497
19497
  }
19498
- const Ze = Je.map((Ue) => Number(Ue[ae.agg_field])).filter((Ue) => !Number.isNaN(Ue));
19498
+ const Ze = Je.map((Qe) => Number(Qe[ae.agg_field])).filter((Qe) => !Number.isNaN(Qe));
19499
19499
  if (!Ze.length) {
19500
19500
  $[O.one_field] = 0;
19501
19501
  return;
19502
19502
  }
19503
- ae.agg === "sum" ? $[O.one_field] = Ze.reduce((Ue, Be) => Ue + Be, 0) : ae.agg === "avg" ? $[O.one_field] = Ze.reduce((Ue, Be) => Ue + Be, 0) / Ze.length : ae.agg === "min" ? $[O.one_field] = Math.min(...Ze) : ae.agg === "max" && ($[O.one_field] = Math.max(...Ze));
19503
+ ae.agg === "sum" ? $[O.one_field] = Ze.reduce((Qe, Be) => Qe + Be, 0) : ae.agg === "avg" ? $[O.one_field] = Ze.reduce((Qe, Be) => Qe + Be, 0) / Ze.length : ae.agg === "min" ? $[O.one_field] = Math.min(...Ze) : ae.agg === "max" && ($[O.one_field] = Math.max(...Ze));
19504
19504
  }), $;
19505
- }, [Ft, nn, Ct, te, Se, Qe]), zn = useMemo(() => {
19505
+ }, [Ft, nn, Ct, te, Se, Ue]), zn = useMemo(() => {
19506
19506
  const $ = /* @__PURE__ */ new Set();
19507
19507
  return on.forEach((O, W) => {
19508
19508
  var Z;
@@ -19542,7 +19542,7 @@ function ItemEditForm({
19542
19542
  () => Nt.filter(($) => SYSTEM_FIELDS.has($.field) || $.readonly),
19543
19543
  [Nt]
19544
19544
  );
19545
- const Nn = useMemo(() => We.filter(($) => $.type === "container"), [We]), ys = useMemo(() => We.filter(($) => $.type === "tab" && !$.container_id), [We]), gr = useMemo(() => We.filter(($) => $.type === "tab").sort(($, O) => $.sort - O.sort), [We]), Ws = useMemo(() => We.filter(($) => $.type === "section" || $.type === "metadata"), [We]), fn = Nn.length > 0, Pn = ys.length > 0, Qt = L == null ? void 0 : L.layout, Fn = Qt ? !!Qt.ai_enabled : !0, hn = Pn && (Qt == null ? void 0 : Qt.tab_mode) === "steps", dr = !!(Qt != null && Qt.validate_before_next), tr = !!(Qt != null && Qt.summary_enabled), cr = !!(Qt != null && Qt.summary_hide_empty), ur = Qt ? !Qt.disable_revisions && o : o, Hn = Qt ? !Qt.disable_comments && m : m, In = Qt ? !Qt.disable_tasks && h : h, mr = Qt ? !Qt.disable_clone && d : d, A = Qt ? !Qt.disable_delete : !0, V = !!(Qt != null && Qt.accordion_mode), [oe, pe] = useState(!1), [_e, Fe] = useState(null), [Me, Ee] = useState(/* @__PURE__ */ new Set()), rt = useRef(!1);
19545
+ const Nn = useMemo(() => We.filter(($) => $.type === "container"), [We]), ys = useMemo(() => We.filter(($) => $.type === "tab" && !$.container_id), [We]), gr = useMemo(() => We.filter(($) => $.type === "tab").sort(($, O) => $.sort - O.sort), [We]), Ws = useMemo(() => We.filter(($) => $.type === "section" || $.type === "metadata"), [We]), fn = Nn.length > 0, Pn = ys.length > 0, Ut = L == null ? void 0 : L.layout, Fn = Ut ? !!Ut.ai_enabled : !0, hn = Pn && (Ut == null ? void 0 : Ut.tab_mode) === "steps", dr = !!(Ut != null && Ut.validate_before_next), tr = !!(Ut != null && Ut.summary_enabled), cr = !!(Ut != null && Ut.summary_hide_empty), ur = Ut ? !Ut.disable_revisions && o : o, Hn = Ut ? !Ut.disable_comments && m : m, In = Ut ? !Ut.disable_tasks && h : h, mr = Ut ? !Ut.disable_clone && d : d, A = Ut ? !Ut.disable_delete : !0, V = !!(Ut != null && Ut.accordion_mode), [oe, pe] = useState(!1), [_e, Fe] = useState(null), [Me, Ee] = useState(/* @__PURE__ */ new Set()), rt = useRef(!1);
19546
19546
  useEffect(() => {
19547
19547
  if (!V) {
19548
19548
  rt.current = !1;
@@ -19773,8 +19773,8 @@ function ItemEditForm({
19773
19773
  const O = (E ?? []).find((ut) => ut.field === $.field);
19774
19774
  let W = "text", Z, ae, ye, Te;
19775
19775
  try {
19776
- const ut = $.input_bindings, Ue = typeof ut == "string" ? JSON.parse(ut) : Array.isArray(ut) ? ut : [], Be = Ue.find((Xe) => Xe.key === "__display_format__");
19777
- Be != null && Be.binding_value && (W = Be.binding_value), Z = ((Ke = Ue.find((Xe) => Xe.key === "__color__")) == null ? void 0 : Ke.binding_value) || void 0, ae = ((Ae = Ue.find((Xe) => Xe.key === "__weight__")) == null ? void 0 : Ae.binding_value) || void 0, ye = ((Je = Ue.find((Xe) => Xe.key === "__display_as__")) == null ? void 0 : Je.binding_value) || void 0, Te = ((Ze = Ue.find((Xe) => Xe.key === "__link_template__")) == null ? void 0 : Ze.binding_value) || void 0;
19776
+ const ut = $.input_bindings, Qe = typeof ut == "string" ? JSON.parse(ut) : Array.isArray(ut) ? ut : [], Be = Qe.find((Xe) => Xe.key === "__display_format__");
19777
+ Be != null && Be.binding_value && (W = Be.binding_value), Z = ((Ke = Qe.find((Xe) => Xe.key === "__color__")) == null ? void 0 : Ke.binding_value) || void 0, ae = ((Ae = Qe.find((Xe) => Xe.key === "__weight__")) == null ? void 0 : Ae.binding_value) || void 0, ye = ((Je = Qe.find((Xe) => Xe.key === "__display_as__")) == null ? void 0 : Je.binding_value) || void 0, Te = ((Ze = Qe.find((Xe) => Xe.key === "__link_template__")) == null ? void 0 : Ze.binding_value) || void 0;
19778
19778
  } catch {
19779
19779
  }
19780
19780
  return {
@@ -19930,14 +19930,14 @@ function ItemEditForm({
19930
19930
  return ((ft = nt == null ? void 0 : nt.data) == null ? void 0 : ft.error) ?? (Ie instanceof Error ? Ie.message : "Failed");
19931
19931
  }
19932
19932
  let O = null;
19933
- const W = [...xt.entries()].some(([, Ie]) => Ie.length > 0) || [...St.entries()].some(([, Ie]) => Ie.size > 0), Z = [...te.entries()].filter(([, Ie]) => Ie.length > 0).map(([Ie]) => Ie), ae = [...Se.entries()].filter(([, Ie]) => Ie.size > 0).map(([Ie]) => Ie), ye = [...Qe.entries()].filter(([, Ie]) => Ie.size > 0).map(([Ie]) => Ie), Te = M ? Nt.filter((Ie) => !SYSTEM_FIELDS.has(Ie.field) && !Ie.readonly && Ie.field in qe).length : Nt.filter((Ie) => SYSTEM_FIELDS.has(Ie.field) || Ie.readonly || !(Ie.field in qe) ? !1 : !valuesEqual(qe[Ie.field], lt.current[Ie.field])).length, Ke = M ? `${Te} field${Te !== 1 ? "s" : ""} set` : Te === 0 ? "No field changes" : `${Te} field${Te !== 1 ? "s" : ""} changed`;
19933
+ const W = [...xt.entries()].some(([, Ie]) => Ie.length > 0) || [...St.entries()].some(([, Ie]) => Ie.size > 0), Z = [...te.entries()].filter(([, Ie]) => Ie.length > 0).map(([Ie]) => Ie), ae = [...Se.entries()].filter(([, Ie]) => Ie.size > 0).map(([Ie]) => Ie), ye = [...Ue.entries()].filter(([, Ie]) => Ie.size > 0).map(([Ie]) => Ie), Te = M ? Nt.filter((Ie) => !SYSTEM_FIELDS.has(Ie.field) && !Ie.readonly && Ie.field in qe).length : Nt.filter((Ie) => SYSTEM_FIELDS.has(Ie.field) || Ie.readonly || !(Ie.field in qe) ? !1 : !valuesEqual(qe[Ie.field], lt.current[Ie.field])).length, Ke = M ? `${Te} field${Te !== 1 ? "s" : ""} set` : Te === 0 ? "No field changes" : `${Te} field${Te !== 1 ? "s" : ""} changed`;
19934
19934
  let Ae = 0, Je = 0;
19935
19935
  for (const [, Ie] of xt.entries()) Ae += Ie.length;
19936
19936
  for (const [, Ie] of St.entries()) Je += Ie.size;
19937
19937
  const Ze = [
19938
19938
  Ae > 0 ? `+${Ae} linked` : "",
19939
19939
  Je > 0 ? `-${Je} unlinked` : ""
19940
- ].filter(Boolean).join(" · "), ut = [...mt.current.entries()], Ue = [
19940
+ ].filter(Boolean).join(" · "), ut = [...mt.current.entries()], Qe = [
19941
19941
  ...ut.length > 0 ? [{ id: "flush", label: "Save attachments", status: "pending", detail: `${ut.length} field${ut.length !== 1 ? "s" : ""} with pending changes` }] : [],
19942
19942
  { id: "main", label: M ? `Create ${(B == null ? void 0 : B.singular) || titleCase$2(e)}` : `Save ${(B == null ? void 0 : B.singular) || titleCase$2(e)}`, status: "pending", detail: Ke },
19943
19943
  ...W ? [{ id: "m2m", label: "Update relationships", status: "pending", detail: Ze }] : [],
@@ -19953,11 +19953,11 @@ function ItemEditForm({
19953
19953
  }),
19954
19954
  ...ye.map((Ie) => {
19955
19955
  var ft;
19956
- const nt = ((ft = Qe.get(Ie)) == null ? void 0 : ft.size) ?? 0;
19956
+ const nt = ((ft = Ue.get(Ie)) == null ? void 0 : ft.size) ?? 0;
19957
19957
  return { id: `o2m:del:${Ie}`, label: `Remove from ${titleCase$2(Ie.split(".")[0])}`, status: "pending", detail: `${nt} row${nt !== 1 ? "s" : ""} deleted`, progress: { done: 0, total: nt } };
19958
19958
  })
19959
19959
  ];
19960
- if (De(Ue), $t(!0), ut.length > 0) {
19960
+ if (De(Qe), $t(!0), ut.length > 0) {
19961
19961
  at("flush", { status: "running" });
19962
19962
  try {
19963
19963
  for (const [, Ie] of ut) await Ie();
@@ -20121,9 +20121,9 @@ function ItemEditForm({
20121
20121
  })), Mt.size > 0 ? Ot.set(Ie, Mt) : Ot.delete(Ie), !Yt && zt === 0 ? at(nt, { status: "done" }) : Yt || at(nt, { status: "error", error: `${zt} nested row${zt !== 1 ? "s" : ""} failed` });
20122
20122
  }
20123
20123
  Le(Ot), O && ht(O);
20124
- const vs = new Map(Qe);
20124
+ const vs = new Map(Ue);
20125
20125
  for (const Ie of ye) {
20126
- const nt = `o2m:del:${Ie}`, [ft] = Ie.split("."), Lt = Qe.get(Ie) ?? /* @__PURE__ */ new Set();
20126
+ const nt = `o2m:del:${Ie}`, [ft] = Ie.split("."), Lt = Ue.get(Ie) ?? /* @__PURE__ */ new Set();
20127
20127
  at(nt, { status: "running", progress: { done: 0, total: Lt.size } });
20128
20128
  let Yt = !1;
20129
20129
  await Promise.all([...Lt].map(async (zt) => {
@@ -20145,7 +20145,7 @@ function ItemEditForm({
20145
20145
  const O = /* @__PURE__ */ new Set([
20146
20146
  ...te.keys(),
20147
20147
  ...Se.keys(),
20148
- ...Qe.keys()
20148
+ ...Ue.keys()
20149
20149
  ]);
20150
20150
  for (const W of O) {
20151
20151
  const Z = W.indexOf("."), ae = W.slice(0, Z), ye = W.slice(Z + 1);
@@ -20169,7 +20169,7 @@ function ItemEditForm({
20169
20169
  if (Zs)
20170
20170
  for (const $ of E ?? []) hr.add($.field);
20171
20171
  if (vn) {
20172
- const $ = (Qs == null ? void 0 : Qs.role) ?? null, O = ((zr = ps == null ? void 0 : ps.instance) == null ? void 0 : zr.current_state) ?? null, W = O ? ((Hr = ((ps == null ? void 0 : ps.states) ?? []).find((Z) => Z.id === O)) == null ? void 0 : Hr.key) ?? null : null;
20172
+ const $ = (Us == null ? void 0 : Us.role) ?? null, O = ((zr = ps == null ? void 0 : ps.instance) == null ? void 0 : zr.current_state) ?? null, W = O ? ((Hr = ((ps == null ? void 0 : ps.states) ?? []).find((Z) => Z.id === O)) == null ? void 0 : Hr.key) ?? null : null;
20173
20173
  for (const Z of Cs) {
20174
20174
  if (!Z.lock_conditions) continue;
20175
20175
  let ae = [];
@@ -20299,7 +20299,7 @@ function ItemEditForm({
20299
20299
  FieldRow,
20300
20300
  {
20301
20301
  field: W,
20302
- draft: Q,
20302
+ draft: U,
20303
20303
  onChange: Es,
20304
20304
  relations: K,
20305
20305
  collection: e,
@@ -20325,7 +20325,7 @@ function ItemEditForm({
20325
20325
  }) }) }, "__ungrouped__");
20326
20326
  }
20327
20327
  function na($) {
20328
- var Ue;
20328
+ var Qe;
20329
20329
  const O = We.filter((Be) => Be.type === "tab" && Be.container_id === $.id).sort((Be, Xe) => Be.sort - Xe.sort);
20330
20330
  if (O.length === 0) return null;
20331
20331
  const W = $.tab_mode === "steps", Z = it($, O), ae = O.find((Be) => Be.key === Z) ?? O[0], ye = (() => {
@@ -20405,7 +20405,7 @@ function ItemEditForm({
20405
20405
  FieldRow,
20406
20406
  {
20407
20407
  field: At,
20408
- draft: Q,
20408
+ draft: U,
20409
20409
  onChange: Es,
20410
20410
  relations: K,
20411
20411
  collection: e,
@@ -20425,7 +20425,7 @@ function ItemEditForm({
20425
20425
  FieldRow,
20426
20426
  {
20427
20427
  field: Xe,
20428
- draft: Q,
20428
+ draft: U,
20429
20429
  onChange: Es,
20430
20430
  relations: K,
20431
20431
  collection: e,
@@ -20477,7 +20477,7 @@ function ItemEditForm({
20477
20477
  /* @__PURE__ */ jsx("line", { x1: "9", y1: "13", x2: "15", y2: "13" }),
20478
20478
  /* @__PURE__ */ jsx("line", { x1: "9", y1: "17", x2: "13", y2: "17" })
20479
20479
  ] }),
20480
- ve ? "Generating…" : ((Ue = cs == null ? void 0 : cs.label_override) == null ? void 0 : Ue.trim()) || "Generate PDF"
20480
+ ve ? "Generating…" : ((Qe = cs == null ? void 0 : cs.label_override) == null ? void 0 : Qe.trim()) || "Generate PDF"
20481
20481
  ]
20482
20482
  }
20483
20483
  ) }),
@@ -20533,15 +20533,15 @@ function ItemEditForm({
20533
20533
  } catch {
20534
20534
  return null;
20535
20535
  }
20536
- })(), Z = ((W == null ? void 0 : W.alternate_fields) ?? []).map((Ue) => typeof Ue == "string" ? { field: Ue, width: 2 } : Ue), ae = W != null && W.enabled ? Me.has(O.id) : !1, Te = (Is[O.key] ?? []).map((Ue) => {
20537
- const Be = w.get(Ue.field);
20538
- if (Be === void 0) return Ue;
20539
- const Xe = qe[Ue.field];
20540
- return Xe != null && Math.round(Number(Xe) * 100) === Math.round(Number(Be) * 100) ? Ue : {
20541
- ...Ue,
20542
- options: { ...Ue.options ?? {}, __live_delta: { original: Xe, live: Be } }
20536
+ })(), Z = ((W == null ? void 0 : W.alternate_fields) ?? []).map((Qe) => typeof Qe == "string" ? { field: Qe, width: 2 } : Qe), ae = W != null && W.enabled ? Me.has(O.id) : !1, Te = (Is[O.key] ?? []).map((Qe) => {
20537
+ const Be = w.get(Qe.field);
20538
+ if (Be === void 0) return Qe;
20539
+ const Xe = qe[Qe.field];
20540
+ return Xe != null && Math.round(Number(Xe) * 100) === Math.round(Number(Be) * 100) ? Qe : {
20541
+ ...Qe,
20542
+ options: { ...Qe.options ?? {}, __live_delta: { original: Xe, live: Be } }
20543
20543
  };
20544
- }), Ke = xr && or === O.key && c, Ae = pr && ir === O.key && !M, Je = yr.filter((Ue) => (Ue.group_key ?? null) === O.key);
20544
+ }), Ke = xr && or === O.key && c, Ae = pr && ir === O.key && !M, Je = yr.filter((Qe) => (Qe.group_key ?? null) === O.key);
20545
20545
  if (Te.length === 0 && !Ke && !Ae && Je.length === 0) return null;
20546
20546
  const Ze = V && O.type !== "tab";
20547
20547
  return /* @__PURE__ */ jsx(
@@ -20568,12 +20568,12 @@ function ItemEditForm({
20568
20568
  renderField: x,
20569
20569
  onCountChange: os,
20570
20570
  isNew: M,
20571
- fieldValues: Te.map((Ue) => qe[Ue.field]),
20571
+ fieldValues: Te.map((Qe) => qe[Qe.field]),
20572
20572
  isOpen: Ze ? _e === O.id : void 0,
20573
- onToggle: Ze ? () => Fe((Ue) => Ue === O.id ? null : O.id) : void 0,
20573
+ onToggle: Ze ? () => Fe((Qe) => Qe === O.id ? null : O.id) : void 0,
20574
20574
  summaryFields: parseSummaryFields(O.summary_fields),
20575
20575
  m2mCounts: As,
20576
- o2mCounts: Us,
20576
+ o2mCounts: Qs,
20577
20577
  o2mAggValues: On,
20578
20578
  summaryAggConfigs: ds,
20579
20579
  o2mLoading: zn,
@@ -20581,12 +20581,12 @@ function ItemEditForm({
20581
20581
  fieldInlineDisplay: Bn,
20582
20582
  swapConfig: W,
20583
20583
  swapped: ae,
20584
- onSwapToggle: W != null && W.enabled ? () => Ee((Ue) => {
20585
- const Be = new Set(Ue);
20584
+ onSwapToggle: W != null && W.enabled ? () => Ee((Qe) => {
20585
+ const Be = new Set(Qe);
20586
20586
  return Be.has(O.id) ? Be.delete(O.id) : Be.add(O.id), Be;
20587
20587
  }) : void 0,
20588
- alternateFields: W != null && W.enabled ? (E ?? []).filter((Ue) => Z.some((Be) => Be.field === Ue.field)) : void 0,
20589
- alternateWidths: W != null && W.enabled ? Object.fromEntries(Z.map((Ue) => [Ue.field, Ue.width])) : void 0
20588
+ alternateFields: W != null && W.enabled ? (E ?? []).filter((Qe) => Z.some((Be) => Be.field === Qe.field)) : void 0,
20589
+ alternateWidths: W != null && W.enabled ? Object.fromEntries(Z.map((Qe) => [Qe.field, Qe.width])) : void 0
20590
20590
  },
20591
20591
  O.key
20592
20592
  );
@@ -20619,7 +20619,7 @@ function ItemEditForm({
20619
20619
  )
20620
20620
  ] });
20621
20621
  }
20622
- function Ur($, O = !1) {
20622
+ function Qr($, O = !1) {
20623
20623
  const W = ($ === "__general__" ? O ? ws : [...ws, ...Ws.flatMap((Ke) => Is[Ke.key] ?? [])] : Is[$] ?? []).filter((Ke) => !Ke.hidden), Z = xr && or === $ && c, ae = pr && ir === $ && !M, ye = yr.filter((Ke) => (Ke.group_key ?? null) === $), Te = W.map((Ke) => ({ _k: Ke.field, sort: Ke.sort ?? 0, _t: "field", f: Ke }));
20624
20624
  Z && Fs && Te.push({ _k: "__owners__", sort: Fs.sort, _t: "owners", slot: Fs }), ae && cs && Te.push({ _k: "__pdf__", sort: cs.sort, _t: "pdf", slot: cs });
20625
20625
  for (const Ke of ye)
@@ -20665,13 +20665,13 @@ function ItemEditForm({
20665
20665
  }
20666
20666
  ) }, Ae.slot.field);
20667
20667
  }
20668
- const Je = Ae.f, Ze = Bn == null ? void 0 : Bn[Je.field], ut = Ze == null ? void 0 : Ze.entries, Ue = (Ze == null ? void 0 : Ze.separator) ?? null, Be = qe[Je.field], Xe = Be != null && Be !== "", pt = ut != null && ut.length && Xe ? ((Et = K.find((Ot) => Ot.many_collection === e && Ot.many_field === Je.field && !Ot.junction_field)) == null ? void 0 : Et.one_collection) ?? null : null;
20668
+ const Je = Ae.f, Ze = Bn == null ? void 0 : Bn[Je.field], ut = Ze == null ? void 0 : Ze.entries, Qe = (Ze == null ? void 0 : Ze.separator) ?? null, Be = qe[Je.field], Xe = Be != null && Be !== "", pt = ut != null && ut.length && Xe ? ((Et = K.find((Ot) => Ot.many_collection === e && Ot.many_field === Je.field && !Ot.junction_field)) == null ? void 0 : Et.one_collection) ?? null : null;
20669
20669
  return /* @__PURE__ */ jsxs("div", { style: { gridColumn: `span ${resolveColSpan(Je.options, Ke)}` }, children: [
20670
20670
  /* @__PURE__ */ jsx(
20671
20671
  FieldRow,
20672
20672
  {
20673
20673
  field: Je,
20674
- draft: Q,
20674
+ draft: U,
20675
20675
  onChange: Es,
20676
20676
  relations: K,
20677
20677
  collection: e,
@@ -20690,7 +20690,7 @@ function ItemEditForm({
20690
20690
  relCollection: pt,
20691
20691
  relId: Be,
20692
20692
  entries: ut,
20693
- separator: Ue
20693
+ separator: Qe
20694
20694
  }
20695
20695
  )
20696
20696
  ] }, Je.field);
@@ -20726,7 +20726,7 @@ function ItemEditForm({
20726
20726
  W.key
20727
20727
  );
20728
20728
  }) }),
20729
- Ur(Dt),
20729
+ Qr(Dt),
20730
20730
  wr.filter((W) => typeof W == "string" && W !== "__ungrouped__").map((W) => Br(W)),
20731
20731
  !fs && c && /* @__PURE__ */ jsx(PipelinePanel, { collection: $e, item: Oe, onBeforeTransition: nr, addendumPending: !se && I > 0 && !!(B != null && B.addendums_enabled), addendumView: se }),
20732
20732
  !Rs && In && /* @__PURE__ */ jsx(TaskPanel, { collection: e, item: g, queuedTasks: M ? _s : void 0, onQueueTask: M ? Bt : void 0 }),
@@ -20835,7 +20835,7 @@ function ItemEditForm({
20835
20835
  onStepClick: Xn
20836
20836
  }
20837
20837
  ),
20838
- Ur(Dt, !0),
20838
+ Qr(Dt, !0),
20839
20839
  Te.map((Ae, Je) => {
20840
20840
  const Ze = typeof Ae == "string" ? Ae : Ae.key;
20841
20841
  return /* @__PURE__ */ jsx("div", { children: Tr(Ae) }, Ze ?? Je);
@@ -20879,8 +20879,8 @@ function ItemEditForm({
20879
20879
  /* @__PURE__ */ jsx(Skeleton, { className: "h-32 rounded-xl" })
20880
20880
  ] })
20881
20881
  ] });
20882
- const Qr = (B == null ? void 0 : B.display_name) ?? titleCase$2(e ?? ""), ia = (B == null ? void 0 : B.singular) || Qr, qr = !M && ue && (B != null && B.display_template) ? applyDisplayTemplate(B.display_template, ue) : Qr, Wr = !M && j && A;
20883
- return /* @__PURE__ */ jsx(ReimportHandlerContext.Provider, { value: M ? null : En, children: /* @__PURE__ */ jsx(RelationPathDataContext.Provider, { value: An, children: /* @__PURE__ */ jsx(AddendumO2MContext.Provider, { value: Ve, children: /* @__PURE__ */ jsx(AddendumViewContext.Provider, { value: J, children: /* @__PURE__ */ jsx(AddendumFieldContext.Provider, { value: Yn, children: /* @__PURE__ */ jsx(ParentDraftContext.Provider, { value: { draft: Gn, collection: e, dirtyFields: He.current }, children: /* @__PURE__ */ jsx(GridFlushContext.Provider, { value: M ? null : yt, children: /* @__PURE__ */ jsx(StaleFieldReportContext.Provider, { value: U, children: /* @__PURE__ */ jsx(O2MStagingContext.Provider, { value: Re, children: /* @__PURE__ */ jsx(LiveRowsContext.Provider, { value: wn, children: /* @__PURE__ */ jsxs(M2MStagingContext.Provider, { value: tt, children: [
20882
+ const Ur = (B == null ? void 0 : B.display_name) ?? titleCase$2(e ?? ""), ia = (B == null ? void 0 : B.singular) || Ur, qr = !M && ue && (B != null && B.display_template) ? applyDisplayTemplate(B.display_template, ue) : Ur, Wr = !M && j && A;
20883
+ return /* @__PURE__ */ jsx(ReimportHandlerContext.Provider, { value: M ? null : En, children: /* @__PURE__ */ jsx(RelationPathDataContext.Provider, { value: An, children: /* @__PURE__ */ jsx(AddendumO2MContext.Provider, { value: Ve, children: /* @__PURE__ */ jsx(AddendumViewContext.Provider, { value: J, children: /* @__PURE__ */ jsx(AddendumFieldContext.Provider, { value: Yn, children: /* @__PURE__ */ jsx(ParentDraftContext.Provider, { value: { draft: Gn, collection: e, dirtyFields: He.current }, children: /* @__PURE__ */ jsx(GridFlushContext.Provider, { value: M ? null : yt, children: /* @__PURE__ */ jsx(StaleFieldReportContext.Provider, { value: Q, children: /* @__PURE__ */ jsx(O2MStagingContext.Provider, { value: Re, children: /* @__PURE__ */ jsx(LiveRowsContext.Provider, { value: wn, children: /* @__PURE__ */ jsxs(M2MStagingContext.Provider, { value: tt, children: [
20884
20884
  /* @__PURE__ */ jsx(TipLayer, {}),
20885
20885
  /* @__PURE__ */ jsx(
20886
20886
  SaveProgressDialog,
@@ -21241,41 +21241,41 @@ function ItemEditForm({
21241
21241
  ...jr.map(($) => ({ type: "widget", sort: $.sort, key: $.field, data: $ })),
21242
21242
  ...Or.map(($) => ({ type: "field", sort: $.sort, key: $.field, data: $ }))
21243
21243
  ].sort(($, O) => $.sort - O.sort).map(($) => {
21244
- const O = (Ue, Be) => {
21244
+ const O = (Qe, Be) => {
21245
21245
  var kt;
21246
- if (!Ue) return;
21247
- const Xe = Ue.cloneNode(!0);
21246
+ if (!Qe) return;
21247
+ const Xe = Qe.cloneNode(!0);
21248
21248
  Xe.querySelectorAll("[data-copy-skip], button").forEach((Et) => Et.remove());
21249
21249
  const pt = ((kt = Xe.textContent) == null ? void 0 : kt.trim()) ?? "";
21250
21250
  pt && (navigator.clipboard.writeText(pt).catch(() => {
21251
21251
  }), Jt(Be), setTimeout(() => Jt((Et) => Et === Be ? null : Et), 1500));
21252
21252
  };
21253
21253
  if ($.type === "widget") {
21254
- const Ue = $.data, Be = fe[Ue.field] === "button-group";
21254
+ const Qe = $.data, Be = fe[Qe.field] === "button-group";
21255
21255
  return /* @__PURE__ */ jsxs("div", { className: "group relative self-stretch border-r border-slate-200 dark:border-border", children: [
21256
21256
  /* @__PURE__ */ jsx(
21257
21257
  WidgetSlot,
21258
21258
  {
21259
- widgetId: Ue.widgetId,
21260
- inputBindings: Ue.inputBindings,
21261
- itemDraft: Q,
21259
+ widgetId: Qe.widgetId,
21260
+ inputBindings: Qe.inputBindings,
21261
+ itemDraft: U,
21262
21262
  itemCollection: e,
21263
- label: Ue.label ?? void 0,
21263
+ label: Qe.label ?? void 0,
21264
21264
  compact: !0,
21265
21265
  strip: !0,
21266
- onWidgetType: (Xe) => ee((pt) => ({ ...pt, [Ue.field]: Xe }))
21266
+ onWidgetType: (Xe) => ee((pt) => ({ ...pt, [Qe.field]: Xe }))
21267
21267
  }
21268
21268
  ),
21269
- !Be && (et === Ue.field ? /* @__PURE__ */ jsx(Check, { className: "absolute top-2 right-2 h-3 w-3 text-green-500" }) : /* @__PURE__ */ jsx(
21269
+ !Be && (et === Qe.field ? /* @__PURE__ */ jsx(Check, { className: "absolute top-2 right-2 h-3 w-3 text-green-500" }) : /* @__PURE__ */ jsx(
21270
21270
  "button",
21271
21271
  {
21272
21272
  type: "button",
21273
21273
  className: "absolute top-2 right-2 cursor-pointer opacity-0 group-hover:opacity-100 transition-opacity",
21274
- onClick: (Xe) => O(Xe.currentTarget.closest(".group"), Ue.field),
21274
+ onClick: (Xe) => O(Xe.currentTarget.closest(".group"), Qe.field),
21275
21275
  children: /* @__PURE__ */ jsx(Copy, { className: "h-3 w-3 text-slate-300 dark:text-slate-600 hover:text-slate-500 dark:hover:text-slate-400" })
21276
21276
  }
21277
21277
  ))
21278
- ] }, Ue.field);
21278
+ ] }, Qe.field);
21279
21279
  }
21280
21280
  const W = $.data;
21281
21281
  if (W.field === "__owners__")
@@ -21287,22 +21287,22 @@ function ItemEditForm({
21287
21287
  {
21288
21288
  type: "button",
21289
21289
  className: "absolute top-2 right-2 cursor-pointer opacity-0 group-hover:opacity-100 transition-opacity",
21290
- onClick: (Ue) => O(Ue.currentTarget.closest(".group"), "__owners__"),
21290
+ onClick: (Qe) => O(Qe.currentTarget.closest(".group"), "__owners__"),
21291
21291
  children: /* @__PURE__ */ jsx(Copy, { className: "h-3 w-3 text-slate-300 dark:text-slate-600 hover:text-slate-500 dark:hover:text-slate-400" })
21292
21292
  }
21293
21293
  )
21294
21294
  ] }, "__owners__");
21295
- const Z = ms[W.field], ae = w.get(W.field), ye = Z ? Z.ids : ae ?? Q[W.field], Ke = se && !Z && tn != null && W.field in tn && String(qe[W.field] ?? "") !== String(tn[W.field] ?? "") ? "text-amber-600 dark:text-amber-400" : W.color === "cyan" ? "text-nvr-cyan" : W.color === "blue" ? "text-blue-600 dark:text-blue-400" : W.color === "green" ? "text-emerald-600 dark:text-emerald-400" : W.color === "amber" ? "text-amber-600 dark:text-amber-400" : W.color === "red" ? "text-red-600 dark:text-red-400" : W.color === "purple" ? "text-purple-600 dark:text-purple-400" : "text-slate-900 dark:text-slate-100", Ae = W.weight === "bold" ? "font-bold" : W.weight === "semibold" ? "font-semibold" : W.weight === "medium" ? "font-medium" : "font-semibold", Je = `${Ke} ${Ae}`, Ze = W.displayAs === "pill", ut = W.displayAs === "tag";
21295
+ const Z = ms[W.field], ae = w.get(W.field), ye = Z ? Z.ids : ae ?? U[W.field], Ke = se && !Z && tn != null && W.field in tn && String(qe[W.field] ?? "") !== String(tn[W.field] ?? "") ? "text-amber-600 dark:text-amber-400" : W.color === "cyan" ? "text-nvr-cyan" : W.color === "blue" ? "text-blue-600 dark:text-blue-400" : W.color === "green" ? "text-emerald-600 dark:text-emerald-400" : W.color === "amber" ? "text-amber-600 dark:text-amber-400" : W.color === "red" ? "text-red-600 dark:text-red-400" : W.color === "purple" ? "text-purple-600 dark:text-purple-400" : "text-slate-900 dark:text-slate-100", Ae = W.weight === "bold" ? "font-bold" : W.weight === "semibold" ? "font-semibold" : W.weight === "medium" ? "font-medium" : "font-semibold", Je = `${Ke} ${Ae}`, Ze = W.displayAs === "pill", ut = W.displayAs === "tag";
21296
21296
  return /* @__PURE__ */ jsxs(
21297
21297
  "div",
21298
21298
  {
21299
21299
  "data-header-field": W.field,
21300
- className: "group relative flex flex-col justify-start border-r border-slate-200 dark:border-border px-4 py-2 min-w-0 transition-colors hover:bg-white/60 dark:hover:bg-white/[0.025]",
21300
+ className: "group relative flex flex-col justify-start self-stretch border-r border-slate-200 dark:border-border px-4 py-2 min-w-0 transition-colors hover:bg-white/60 dark:hover:bg-white/[0.025]",
21301
21301
  children: [
21302
21302
  /* @__PURE__ */ jsx("span", { className: "flex h-4 items-end truncate text-[10px] font-medium leading-none text-slate-400 dark:text-slate-500", children: W.label }),
21303
21303
  /* @__PURE__ */ jsx("span", { className: ["mt-1 leading-tight truncate max-w-[220px] pb-px", Ze ? `rounded-full px-2 py-0.5 text-[11px] inline-block ${Ke} bg-current/10` : ut ? `rounded px-1.5 py-0.5 border border-current/30 text-[11px] inline-block ${Ke}` : ""].filter(Boolean).join(" "), children: (() => {
21304
- const Ue = W.cmsField ? /* @__PURE__ */ jsx(StripFieldValue, { field: W.cmsField, val: ye, relations: K, collection: e, displayFormat: W.displayFormat, textClassName: Je }) : /* @__PURE__ */ jsx("span", { className: `text-[13px] ${Je}`, children: formatHeaderFieldValue(ye, W.displayFormat) }), Be = W.linkTemplate;
21305
- if (!Be || ye === null || ye === void 0 || ye === "" || Array.isArray(ye)) return Ue;
21304
+ const Qe = W.cmsField ? /* @__PURE__ */ jsx(StripFieldValue, { field: W.cmsField, val: ye, relations: K, collection: e, displayFormat: W.displayFormat, textClassName: Je }) : /* @__PURE__ */ jsx("span", { className: `text-[13px] ${Je}`, children: formatHeaderFieldValue(ye, W.displayFormat) }), Be = W.linkTemplate;
21305
+ if (!Be || ye === null || ye === void 0 || ye === "" || Array.isArray(ye)) return Qe;
21306
21306
  const Xe = Be.replace(/\{\{\s*value\s*\}\}/g, encodeURIComponent(String(ye))).replace(/\{\{\s*([\w.]+)\s*\}\}/g, (pt, kt) => encodeURIComponent(String(qe[kt] ?? "")));
21307
21307
  return /^https?:\/\//i.test(Xe) ? /* @__PURE__ */ jsx(
21308
21308
  "a",
@@ -21312,18 +21312,18 @@ function ItemEditForm({
21312
21312
  rel: "noopener noreferrer",
21313
21313
  className: "underline decoration-dotted underline-offset-2 hover:decoration-solid",
21314
21314
  onClick: (pt) => pt.stopPropagation(),
21315
- children: Ue
21315
+ children: Qe
21316
21316
  }
21317
- ) : Ue;
21317
+ ) : Qe;
21318
21318
  })() }),
21319
21319
  et === W.field ? /* @__PURE__ */ jsx(Check, { className: "absolute top-2 right-2 h-3 w-3 text-green-500" }) : /* @__PURE__ */ jsx(
21320
21320
  "button",
21321
21321
  {
21322
21322
  type: "button",
21323
21323
  className: "absolute top-2 right-2 cursor-pointer opacity-0 group-hover:opacity-100 transition-opacity",
21324
- onClick: (Ue) => {
21324
+ onClick: (Qe) => {
21325
21325
  var kt;
21326
- const Be = Ue.currentTarget.closest(".group"), Xe = Be == null ? void 0 : Be.querySelectorAll(":scope > span")[1];
21326
+ const Be = Qe.currentTarget.closest(".group"), Xe = Be == null ? void 0 : Be.querySelectorAll(":scope > span")[1];
21327
21327
  let pt = "";
21328
21328
  if (Xe) {
21329
21329
  const Et = Xe.cloneNode(!0);
@@ -26484,166 +26484,166 @@ function CollectionBrowserView({
26484
26484
  Pt.current !== e && (Pt.current = e, v(1), x(a), y([]), f(n ?? ""), C(s ?? null), T({}), M({}), de([]), Ce(null), xe({}), B({}), I({}), fe([]), J != null && J.length && le.back(J.length), je(null), ot.current = !1);
26485
26485
  }, [e]), useEffect(() => {
26486
26486
  if (!Ne) return;
26487
- const U = (w) => {
26488
- var Q;
26489
- (Q = jt.current) != null && Q.contains(w.target) || Y(!1);
26487
+ const Q = (w) => {
26488
+ var U;
26489
+ (U = jt.current) != null && U.contains(w.target) || Y(!1);
26490
26490
  };
26491
- return window.addEventListener("mousedown", U), () => window.removeEventListener("mousedown", U);
26491
+ return window.addEventListener("mousedown", Q), () => window.removeEventListener("mousedown", Q);
26492
26492
  }, [Ne]);
26493
26493
  const { data: st } = useQuery({
26494
26494
  queryKey: ["cbv-collection-meta", e],
26495
- queryFn: () => c.request(get$1(`/collections/${e}`)).then((U) => U.data),
26495
+ queryFn: () => c.request(get$1(`/collections/${e}`)).then((Q) => Q.data),
26496
26496
  staleTime: 10 * 6e4,
26497
26497
  retry: !1
26498
- }), _t = useMemo(() => ((st == null ? void 0 : st.fields) ?? []).filter((U) => !U.hidden), [st]), It = (st == null ? void 0 : st.browser_config) ?? {}, Xt = It.checkbox_selection !== !1, Ht = It.show_actions !== !1, $t = o && It.allow_create !== !1, ie = It.page_size && It.page_size > 0 ? Math.min(It.page_size, 200) : r, De = t.length > 0 ? t : It.quick_filters ?? [];
26498
+ }), _t = useMemo(() => ((st == null ? void 0 : st.fields) ?? []).filter((Q) => !Q.hidden), [st]), It = (st == null ? void 0 : st.browser_config) ?? {}, Xt = It.checkbox_selection !== !1, Ht = It.show_actions !== !1, $t = o && It.allow_create !== !1, ie = It.page_size && It.page_size > 0 ? Math.min(It.page_size, 200) : r, De = t.length > 0 ? t : It.quick_filters ?? [];
26499
26499
  useEffect(() => {
26500
26500
  if (re || !z || t.length === 0 && !st) return;
26501
- const U = ee, w = Object.values((U == null ? void 0 : U.defaults) ?? {}).some((Q) => Q.length > 0) || Object.values((U == null ? void 0 : U.restricted) ?? {}).some((Q) => Q.length > 0);
26502
- if (!U || De.length === 0 || !w) {
26501
+ const Q = ee, w = Object.values((Q == null ? void 0 : Q.defaults) ?? {}).some((U) => U.length > 0) || Object.values((Q == null ? void 0 : Q.restricted) ?? {}).some((U) => U.length > 0);
26502
+ if (!Q || De.length === 0 || !w) {
26503
26503
  we(!0);
26504
26504
  return;
26505
26505
  }
26506
26506
  (async () => {
26507
- const Q = {};
26507
+ const U = {};
26508
26508
  for (const se of De) {
26509
- const $e = matchScopeDimension(U, { key: se.key, collection: se.collection });
26509
+ const $e = matchScopeDimension(Q, { key: se.key, collection: se.collection });
26510
26510
  if (!$e) continue;
26511
- const Oe = effectiveScopeSeedIds(U, $e.name);
26511
+ const Oe = effectiveScopeSeedIds(Q, $e.name);
26512
26512
  if (Oe.length === 0) continue;
26513
26513
  const Ve = await translateScopeValues(c, $e, Oe, se.value_field).catch(
26514
26514
  () => []
26515
26515
  );
26516
- Ve.length > 0 && (Q[se.key] = Ve);
26516
+ Ve.length > 0 && (U[se.key] = Ve);
26517
26517
  }
26518
- if (Object.keys(Q).length > 0) {
26518
+ if (Object.keys(U).length > 0) {
26519
26519
  const se = ($e) => {
26520
26520
  var Ve;
26521
26521
  const Oe = { ...$e };
26522
- for (const [dt, Nt] of Object.entries(Q))
26522
+ for (const [dt, Nt] of Object.entries(U))
26523
26523
  (((Ve = Oe[dt]) == null ? void 0 : Ve.length) ?? 0) > 0 || (Oe[dt] = Nt);
26524
26524
  return Oe;
26525
26525
  };
26526
- xe(se), B(se), ve(new Set(Object.keys(Q)));
26526
+ xe(se), B(se), ve(new Set(Object.keys(U)));
26527
26527
  }
26528
26528
  we(!0);
26529
26529
  })();
26530
26530
  }, [re, z, ee, st, De]);
26531
- const at = (U) => {
26532
- const w = matchScopeDimension(ee, { key: U.key, collection: U.collection }), Q = w ? (ee == null ? void 0 : ee.restricted[w.name]) ?? [] : [];
26533
- return Q.length > 0 ? Q : void 0;
26534
- }, lt = useMemo(() => new Map(_t.map((U) => [U.field, U])), [_t]), qt = (st == null ? void 0 : st.relations) ?? [], et = useMemo(() => (S ?? _t.slice(0, 7).map((w) => w.field)).filter((w) => w.includes(".") || lt.has(w)), [S, _t, lt]), [Jt, ss] = useState(null), is = useMemo(
26531
+ const at = (Q) => {
26532
+ const w = matchScopeDimension(ee, { key: Q.key, collection: Q.collection }), U = w ? (ee == null ? void 0 : ee.restricted[w.name]) ?? [] : [];
26533
+ return U.length > 0 ? U : void 0;
26534
+ }, lt = useMemo(() => new Map(_t.map((Q) => [Q.field, Q])), [_t]), qt = (st == null ? void 0 : st.relations) ?? [], et = useMemo(() => (S ?? _t.slice(0, 7).map((w) => w.field)).filter((w) => w.includes(".") || lt.has(w)), [S, _t, lt]), [Jt, ss] = useState(null), is = useMemo(
26535
26535
  () => Jt ?? (et[0] ? { [et[0]]: "left" } : {}),
26536
26536
  [Jt, et]
26537
- ), Vt = (U) => is[U], _s = (U) => {
26538
- const w = { ...is }, Q = w[U];
26539
- Q ? Q === "left" ? w[U] = "right" : delete w[U] : w[U] = "left", ss(w);
26540
- }, Ms = (U) => q[U] ?? (U.includes(".") ? U.split(".").map(titleCase$1).join(" › ") : U === "id" ? "ID" : titleCase$1(U)), Bt = useMemo(
26541
- () => et.filter((U) => !U.includes(".")).map((U) => ({ field: U, info: aliasRelationFor(qt, e, U) })).filter((U) => !!U.info),
26537
+ ), Vt = (Q) => is[Q], _s = (Q) => {
26538
+ const w = { ...is }, U = w[Q];
26539
+ U ? U === "left" ? w[Q] = "right" : delete w[Q] : w[Q] = "left", ss(w);
26540
+ }, Ms = (Q) => q[Q] ?? (Q.includes(".") ? Q.split(".").map(titleCase$1).join(" › ") : Q === "id" ? "ID" : titleCase$1(Q)), Bt = useMemo(
26541
+ () => et.filter((Q) => !Q.includes(".")).map((Q) => ({ field: Q, info: aliasRelationFor(qt, e, Q) })).filter((Q) => !!Q.info),
26542
26542
  [et, lt, qt, e]
26543
26543
  ), te = useMemo(
26544
- () => [...new Set(Bt.map((U) => U.info.relation.many_collection ?? "").filter(Boolean))],
26544
+ () => [...new Set(Bt.map((Q) => Q.info.relation.many_collection ?? "").filter(Boolean))],
26545
26545
  [Bt]
26546
26546
  ), ke = useQueries({
26547
- queries: te.map((U) => ({
26548
- queryKey: ["cbv-collection-meta", U],
26549
- queryFn: () => c.request(get$1(`/collections/${U}`)).then((w) => w.data),
26547
+ queries: te.map((Q) => ({
26548
+ queryKey: ["cbv-collection-meta", Q],
26549
+ queryFn: () => c.request(get$1(`/collections/${Q}`)).then((w) => w.data),
26550
26550
  staleTime: 10 * 6e4,
26551
26551
  retry: !1
26552
26552
  }))
26553
26553
  }), Se = useMemo(() => {
26554
- const U = /* @__PURE__ */ new Map();
26555
- return te.forEach((w, Q) => {
26554
+ const Q = /* @__PURE__ */ new Map();
26555
+ return te.forEach((w, U) => {
26556
26556
  var se;
26557
- return U.set(w, (se = ke[Q]) == null ? void 0 : se.data);
26558
- }), U;
26557
+ return Q.set(w, (se = ke[U]) == null ? void 0 : se.data);
26558
+ }), Q;
26559
26559
  }, [te, ke]), Le = useMemo(
26560
26560
  () => [
26561
26561
  ...new Set(
26562
- Bt.filter((U) => U.info.kind === "m2m").map((U) => {
26563
- const w = U.info.relation.many_collection ?? "", Q = Se.get(w), se = Q == null ? void 0 : Q.relations.find(
26564
- ($e) => $e.many_collection === w && $e.many_field === U.info.relation.junction_field
26562
+ Bt.filter((Q) => Q.info.kind === "m2m").map((Q) => {
26563
+ const w = Q.info.relation.many_collection ?? "", U = Se.get(w), se = U == null ? void 0 : U.relations.find(
26564
+ ($e) => $e.many_collection === w && $e.many_field === Q.info.relation.junction_field
26565
26565
  );
26566
26566
  return (se == null ? void 0 : se.one_collection) ?? "";
26567
26567
  }).filter(Boolean)
26568
26568
  )
26569
26569
  ],
26570
26570
  [Bt, Se]
26571
- ), Qe = useQueries({
26572
- queries: Le.map((U) => ({
26573
- queryKey: ["cbv-collection-meta", U],
26574
- queryFn: () => c.request(get$1(`/collections/${U}`)).then((w) => w.data),
26571
+ ), Ue = useQueries({
26572
+ queries: Le.map((Q) => ({
26573
+ queryKey: ["cbv-collection-meta", Q],
26574
+ queryFn: () => c.request(get$1(`/collections/${Q}`)).then((w) => w.data),
26575
26575
  staleTime: 10 * 6e4,
26576
26576
  retry: !1
26577
26577
  }))
26578
26578
  }), Ye = useMemo(() => {
26579
- const U = /* @__PURE__ */ new Map();
26580
- return Le.forEach((w, Q) => {
26579
+ const Q = /* @__PURE__ */ new Map();
26580
+ return Le.forEach((w, U) => {
26581
26581
  var se;
26582
- return U.set(w, (se = Qe[Q]) == null ? void 0 : se.data);
26583
- }), U;
26584
- }, [Le, Qe]), Re = useMemo(() => {
26585
- const U = {};
26582
+ return Q.set(w, (se = Ue[U]) == null ? void 0 : se.data);
26583
+ }), Q;
26584
+ }, [Le, Ue]), Re = useMemo(() => {
26585
+ const Q = {};
26586
26586
  for (const w of Bt) {
26587
- const Q = w.info.relation.many_collection ?? "";
26587
+ const U = w.info.relation.many_collection ?? "";
26588
26588
  if (w.info.kind === "o2m")
26589
- U[w.field] = `${w.field}.${labelFieldFor(Se.get(Q))}`;
26589
+ Q[w.field] = `${w.field}.${labelFieldFor(Se.get(U))}`;
26590
26590
  else {
26591
- const se = Se.get(Q), $e = se == null ? void 0 : se.relations.find(
26592
- (Ve) => Ve.many_collection === Q && Ve.many_field === w.info.relation.junction_field
26591
+ const se = Se.get(U), $e = se == null ? void 0 : se.relations.find(
26592
+ (Ve) => Ve.many_collection === U && Ve.many_field === w.info.relation.junction_field
26593
26593
  ), Oe = ($e == null ? void 0 : $e.one_collection) ?? "";
26594
- U[w.field] = `${w.field}.${labelFieldFor(Oe ? Ye.get(Oe) : void 0)}`;
26594
+ Q[w.field] = `${w.field}.${labelFieldFor(Oe ? Ye.get(Oe) : void 0)}`;
26595
26595
  }
26596
26596
  }
26597
- return U;
26597
+ return Q;
26598
26598
  }, [Bt, Se, Ye]), wt = useMemo(() => {
26599
- const U = {};
26599
+ const Q = {};
26600
26600
  for (const w of Bt)
26601
26601
  if (w.info.kind === "o2m")
26602
- U[w.field] = { kind: "o2m" };
26602
+ Q[w.field] = { kind: "o2m" };
26603
26603
  else {
26604
- const Q = w.info.relation.many_collection ?? "", se = Se.get(Q), $e = se == null ? void 0 : se.relations.find(
26605
- (Oe) => Oe.many_collection === Q && Oe.many_field === w.info.relation.junction_field
26604
+ const U = w.info.relation.many_collection ?? "", se = Se.get(U), $e = se == null ? void 0 : se.relations.find(
26605
+ (Oe) => Oe.many_collection === U && Oe.many_field === w.info.relation.junction_field
26606
26606
  );
26607
- $e != null && $e.one_collection && (U[w.field] = { kind: "m2m", target: $e.one_collection });
26607
+ $e != null && $e.one_collection && (Q[w.field] = { kind: "m2m", target: $e.one_collection });
26608
26608
  }
26609
- return U;
26609
+ return Q;
26610
26610
  }, [Bt, Se]), Rt = useDebounced(ce, 350), vt = useMemo(() => {
26611
26611
  var w;
26612
- const U = [];
26613
- for (const Q of F) {
26614
- const se = Q.fieldType === "date" || Q.fieldType === "datetime" || Q.fieldType === "timestamp";
26615
- if (Q.op === "_between") {
26616
- const [Ve, dt] = String(Q.value).split("..");
26617
- Ve && U.push({ path: Q.path, op: "_gte", value: Ve }), dt && U.push({ path: Q.path, op: "_lte", value: se ? `${dt}T23:59:59` : dt });
26612
+ const Q = [];
26613
+ for (const U of F) {
26614
+ const se = U.fieldType === "date" || U.fieldType === "datetime" || U.fieldType === "timestamp";
26615
+ if (U.op === "_between") {
26616
+ const [Ve, dt] = String(U.value).split("..");
26617
+ Ve && Q.push({ path: U.path, op: "_gte", value: Ve }), dt && Q.push({ path: U.path, op: "_lte", value: se ? `${dt}T23:59:59` : dt });
26618
26618
  continue;
26619
26619
  }
26620
- const $e = Q.op.includes(":") ? Q.op.split(":")[0] : Q.op;
26621
- let Oe = Q.op.includes(":") ? Q.op.split(":")[1] : Q.value || null;
26622
- Q.fieldType === "boolean" && (Oe === "true" || Oe === "false") && (Oe = Oe === "true"), U.push({ path: Q.path, op: $e, value: Oe });
26620
+ const $e = U.op.includes(":") ? U.op.split(":")[0] : U.op;
26621
+ let Oe = U.op.includes(":") ? U.op.split(":")[1] : U.value || null;
26622
+ U.fieldType === "boolean" && (Oe === "true" || Oe === "false") && (Oe = Oe === "true"), Q.push({ path: U.path, op: $e, value: Oe });
26623
26623
  }
26624
- for (const Q of De) {
26625
- const se = G[Q.key] ?? [];
26626
- se.length !== 0 && ((w = Q.or_paths) != null && w.length ? U.push({ or: Q.or_paths.map(($e) => ({ path: $e, op: "_in", value: se })) }) : U.push({ path: Q.path, op: "_in", value: se }));
26624
+ for (const U of De) {
26625
+ const se = G[U.key] ?? [];
26626
+ se.length !== 0 && ((w = U.or_paths) != null && w.length ? Q.push({ or: U.or_paths.map(($e) => ({ path: $e, op: "_in", value: se })) }) : Q.push({ path: U.path, op: "_in", value: se }));
26627
26627
  }
26628
- for (const [Q, se] of Object.entries(Rt))
26628
+ for (const [U, se] of Object.entries(Rt))
26629
26629
  if (se) {
26630
- if (se.kind === "in" && se.value.length) U.push({ path: [Q], op: "_in", value: se.value });
26631
- else if (se.kind === "state" && se.value.length) U.push({ path: ["$state"], op: "_in", value: se.value });
26630
+ if (se.kind === "in" && se.value.length) Q.push({ path: [U], op: "_in", value: se.value });
26631
+ else if (se.kind === "state" && se.value.length) Q.push({ path: ["$state"], op: "_in", value: se.value });
26632
26632
  else if (se.kind === "text" && se.value.trim())
26633
- U.push({ path: se.path, op: "_contains", value: se.value.trim() });
26633
+ Q.push({ path: se.path, op: "_contains", value: se.value.trim() });
26634
26634
  else if (se.kind === "num" && se.value !== "" && !Number.isNaN(Number(se.value)))
26635
- U.push({ path: [Q], op: se.op, value: Number(se.value) });
26636
- else if (se.kind === "bool") U.push({ path: [Q], op: "_eq", value: se.value === "true" });
26635
+ Q.push({ path: [U], op: se.op, value: Number(se.value) });
26636
+ else if (se.kind === "bool") Q.push({ path: [U], op: "_eq", value: se.value === "true" });
26637
26637
  else if (se.kind === "date" && se.value) {
26638
26638
  const $e = se.value.startsWith("r:") ? (() => {
26639
26639
  const [Oe, Ve] = se.value.slice(2).split("..");
26640
26640
  return Oe ? { from: Oe, to: Ve || Oe } : null;
26641
26641
  })() : dateRangeFor(se.value);
26642
- $e && (U.push({ path: [Q], op: "_gte", value: $e.from }), U.push({ path: [Q], op: "_lte", value: `${$e.to}T23:59:59` }));
26642
+ $e && (Q.push({ path: [U], op: "_gte", value: $e.from }), Q.push({ path: [U], op: "_lte", value: `${$e.to}T23:59:59` }));
26643
26643
  }
26644
26644
  }
26645
- for (const Q of ne) U.push({ path: Q.path, op: Q.op, value: Q.value });
26646
- return U.length > 0 ? JSON.stringify(U) : void 0;
26645
+ for (const U of ne) Q.push({ path: U.path, op: U.op, value: U.value });
26646
+ return Q.length > 0 ? JSON.stringify(Q) : void 0;
26647
26647
  }, [F, De, G, Rt, ne]), Kt = useRef(vt);
26648
26648
  useEffect(() => {
26649
26649
  Kt.current !== vt && (Kt.current = vt, v(1));
@@ -26666,39 +26666,39 @@ function CollectionBrowserView({
26666
26666
  })
26667
26667
  ),
26668
26668
  enabled: !!e && re,
26669
- placeholderData: (U) => U,
26669
+ placeholderData: (Q) => Q,
26670
26670
  retry: !1
26671
26671
  }), us = (xt == null ? void 0 : xt.data) ?? [], es = (xt == null ? void 0 : xt.total) ?? 0, un = Math.max(1, Math.ceil(es / ie)), { data: ln = [] } = useQuery({
26672
26672
  queryKey: ["cbv-risk-rules", e],
26673
26673
  queryFn: () => c.request(
26674
26674
  get$1("/at-risk/rules/active", { collection: e })
26675
- ).then((U) => U.data ?? []).catch(() => []),
26675
+ ).then((Q) => Q.data ?? []).catch(() => []),
26676
26676
  enabled: !!e,
26677
26677
  staleTime: 6e4,
26678
26678
  retry: !1
26679
- }), Ln = ((xt == null ? void 0 : xt.data) ?? []).map((U) => String(U.id)).join(","), { data: En = {} } = useQuery({
26679
+ }), Ln = ((xt == null ? void 0 : xt.data) ?? []).map((Q) => String(Q.id)).join(","), { data: En = {} } = useQuery({
26680
26680
  queryKey: ["cbv-risk", e, Ln],
26681
26681
  queryFn: () => c.request(
26682
26682
  post$1("/at-risk/evaluate", {
26683
26683
  collection: e,
26684
- ids: ((xt == null ? void 0 : xt.data) ?? []).map((U) => String(U.id))
26684
+ ids: ((xt == null ? void 0 : xt.data) ?? []).map((Q) => String(Q.id))
26685
26685
  })
26686
- ).then((U) => U.data ?? {}).catch(() => ({})),
26686
+ ).then((Q) => Q.data ?? {}).catch(() => ({})),
26687
26687
  enabled: !!e && ln.length > 0 && ((xt == null ? void 0 : xt.data) ?? []).length > 0,
26688
26688
  staleTime: 3e4,
26689
26689
  retry: !1
26690
- }), rs = ((xt == null ? void 0 : xt.data) ?? []).map((U) => String(U.id)).join(","), { data: js } = useQuery({
26690
+ }), rs = ((xt == null ? void 0 : xt.data) ?? []).map((Q) => String(Q.id)).join(","), { data: js } = useQuery({
26691
26691
  queryKey: ["cbv-pipeline-instances", e, rs],
26692
26692
  queryFn: () => c.request(
26693
26693
  get$1(`/pipelines/instances/${e}`, rs ? { ids: rs } : void 0)
26694
- ).then((U) => U.data),
26694
+ ).then((Q) => Q.data),
26695
26695
  enabled: !!e && rs.length > 0,
26696
- placeholderData: (U) => U,
26696
+ placeholderData: (Q) => Q,
26697
26697
  staleTime: 3e4,
26698
26698
  retry: !1
26699
26699
  }), Ls = (Dn = js == null ? void 0 : js.binding) == null ? void 0 : Dn.template, { data: ks } = useQuery({
26700
26700
  queryKey: ["cbv-pipeline-template", Ls],
26701
- queryFn: () => c.request(get$1(`/pipelines/${Ls}`)).then((U) => U.data),
26701
+ queryFn: () => c.request(get$1(`/pipelines/${Ls}`)).then((Q) => Q.data),
26702
26702
  enabled: !!Ls,
26703
26703
  retry: !1
26704
26704
  }), An = !!(js != null && js.binding), { data: Bs } = useQuery({
@@ -26707,62 +26707,62 @@ function CollectionBrowserView({
26707
26707
  post$1(`/pipelines/instance/${e}/owners/batch`, {
26708
26708
  ids: rs.split(",").filter(Boolean)
26709
26709
  })
26710
- ).then((U) => U.data ?? {}),
26710
+ ).then((Q) => Q.data ?? {}),
26711
26711
  enabled: An && rs.length > 0,
26712
26712
  staleTime: 6e4,
26713
26713
  retry: !1
26714
- }), $n = useMemo(() => et.filter((U) => U.includes(".")), [et]), Ss = useMemo(
26714
+ }), $n = useMemo(() => et.filter((Q) => Q.includes(".")), [et]), Ss = useMemo(
26715
26715
  () => [.../* @__PURE__ */ new Set([...$n, ...Object.values(Re)])].slice(0, 20),
26716
26716
  [$n, Re]
26717
- ), ms = us.map((U) => String(U.id)).join(","), { data: Ut } = useQuery({
26717
+ ), ms = us.map((Q) => String(Q.id)).join(","), { data: Qt } = useQuery({
26718
26718
  queryKey: ["cbv-resolved", e, ms, Ss.join(",")],
26719
- queryFn: () => c.request(get$1(`/items/${e}/resolve-paths`, { ids: ms, paths: Ss.join(",") })).then((U) => U.data ?? { rows: {}, targets: {} }),
26719
+ queryFn: () => c.request(get$1(`/items/${e}/resolve-paths`, { ids: ms, paths: Ss.join(",") })).then((Q) => Q.data ?? { rows: {}, targets: {} }),
26720
26720
  enabled: us.length > 0 && Ss.length > 0,
26721
26721
  staleTime: 3e4,
26722
26722
  retry: !1
26723
- }), ts = (U, w) => {
26723
+ }), ts = (Q, w) => {
26724
26724
  var $e, Oe, Ve;
26725
- const Q = w.includes(".") ? w : Re[w];
26726
- if (!Q) return null;
26727
- const se = (Ve = (Oe = ($e = Ut == null ? void 0 : Ut.rows) == null ? void 0 : $e[String(U)]) == null ? void 0 : Oe[Q]) == null ? void 0 : Ve.value;
26725
+ const U = w.includes(".") ? w : Re[w];
26726
+ if (!U) return null;
26727
+ const se = (Ve = (Oe = ($e = Qt == null ? void 0 : Qt.rows) == null ? void 0 : $e[String(Q)]) == null ? void 0 : Oe[U]) == null ? void 0 : Ve.value;
26728
26728
  return se == null || se === "" ? "—" : se;
26729
- }, Un = (U) => {
26730
- var Q;
26731
- const w = U.includes(".") ? U : Re[U];
26732
- return w ? ((Q = Ut == null ? void 0 : Ut.targets) == null ? void 0 : Q[w]) ?? null : null;
26733
- }, Gn = (U, w) => {
26729
+ }, Qn = (Q) => {
26730
+ var U;
26731
+ const w = Q.includes(".") ? Q : Re[Q];
26732
+ return w ? ((U = Qt == null ? void 0 : Qt.targets) == null ? void 0 : U[w]) ?? null : null;
26733
+ }, Gn = (Q, w) => {
26734
26734
  var Oe, Ve, dt, Nt;
26735
- const Q = w.includes(".") ? w : Re[w];
26736
- if (!Q) return null;
26737
- const se = (Oe = Ut == null ? void 0 : Ut.targets) == null ? void 0 : Oe[Q], $e = ((Nt = (dt = (Ve = Ut == null ? void 0 : Ut.rows) == null ? void 0 : Ve[String(U)]) == null ? void 0 : dt[Q]) == null ? void 0 : Nt.ids) ?? [];
26735
+ const U = w.includes(".") ? w : Re[w];
26736
+ if (!U) return null;
26737
+ const se = (Oe = Qt == null ? void 0 : Qt.targets) == null ? void 0 : Oe[U], $e = ((Nt = (dt = (Ve = Qt == null ? void 0 : Qt.rows) == null ? void 0 : Ve[String(Q)]) == null ? void 0 : dt[U]) == null ? void 0 : Nt.ids) ?? [];
26738
26738
  return !se || isSystemCol(se) || $e.length === 0 ? null : { target: se, id: String($e[0]) };
26739
- }, gs = (U) => U.includes(".") || U in Re, Ks = (U) => {
26740
- if (U.includes(".")) return { kind: "text", path: U.split(".") };
26741
- const w = isM2OField(qt, e, U);
26739
+ }, gs = (Q) => Q.includes(".") || Q in Re, Ks = (Q) => {
26740
+ if (Q.includes(".")) return { kind: "text", path: Q.split(".") };
26741
+ const w = isM2OField(qt, e, Q);
26742
26742
  if (w != null && w.one_collection)
26743
26743
  return isSystemCol(w.one_collection) && w.one_collection !== "nivaro_users" ? null : { kind: "in", target: w.one_collection };
26744
- const Q = wt[U];
26745
- if (Q) {
26746
- if (Q.kind === "m2m") return { kind: "in", target: Q.target };
26747
- const $e = Re[U];
26744
+ const U = wt[Q];
26745
+ if (U) {
26746
+ if (U.kind === "m2m") return { kind: "in", target: U.target };
26747
+ const $e = Re[Q];
26748
26748
  return $e ? { kind: "text", path: $e.split(".") } : null;
26749
26749
  }
26750
- const se = lt.get(U);
26751
- return !se || se.computed_formula && !se.computed_store ? null : se.type === "integer" || se.type === "decimal" || se.type === "float" ? { kind: "num" } : se.type === "boolean" ? { kind: "bool" } : se.type === "date" || se.type === "datetime" || se.type === "timestamp" ? { kind: "date" } : se.interface === "select-dropdown" ? { kind: "enum" } : se.type === "string" || se.type === "text" ? { kind: "text", path: [U] } : null;
26752
- }, as = (U, w) => I((Q) => {
26753
- const se = { ...Q };
26754
- return w ? se[U] = w : delete se[U], se;
26755
- }), zs = (U) => {
26756
- const w = Ks(U);
26750
+ const se = lt.get(Q);
26751
+ return !se || se.computed_formula && !se.computed_store ? null : se.type === "integer" || se.type === "decimal" || se.type === "float" ? { kind: "num" } : se.type === "boolean" ? { kind: "bool" } : se.type === "date" || se.type === "datetime" || se.type === "timestamp" ? { kind: "date" } : se.interface === "select-dropdown" ? { kind: "enum" } : se.type === "string" || se.type === "text" ? { kind: "text", path: [Q] } : null;
26752
+ }, as = (Q, w) => I((U) => {
26753
+ const se = { ...U };
26754
+ return w ? se[Q] = w : delete se[Q], se;
26755
+ }), zs = (Q) => {
26756
+ const w = Ks(Q);
26757
26757
  if (!w) return null;
26758
- const Q = ce[U];
26758
+ const U = ce[Q];
26759
26759
  if (w.kind === "in")
26760
26760
  return /* @__PURE__ */ jsx(
26761
26761
  RelationColFilter,
26762
26762
  {
26763
26763
  target: w.target,
26764
- selected: (Q == null ? void 0 : Q.kind) === "in" ? Q.value : [],
26765
- onChange: (se) => as(U, se.length ? { kind: "in", value: se } : null)
26764
+ selected: (U == null ? void 0 : U.kind) === "in" ? U.value : [],
26765
+ onChange: (se) => as(Q, se.length ? { kind: "in", value: se } : null)
26766
26766
  }
26767
26767
  );
26768
26768
  if (w.kind === "enum")
@@ -26770,32 +26770,32 @@ function CollectionBrowserView({
26770
26770
  EnumColFilter,
26771
26771
  {
26772
26772
  collection: e,
26773
- field: U,
26774
- selected: (Q == null ? void 0 : Q.kind) === "in" ? Q.value : [],
26775
- onChange: (se) => as(U, se.length ? { kind: "in", value: se } : null)
26773
+ field: Q,
26774
+ selected: (U == null ? void 0 : U.kind) === "in" ? U.value : [],
26775
+ onChange: (se) => as(Q, se.length ? { kind: "in", value: se } : null)
26776
26776
  }
26777
26777
  );
26778
26778
  if (w.kind === "text")
26779
26779
  return /* @__PURE__ */ jsx(
26780
26780
  "input",
26781
26781
  {
26782
- value: (Q == null ? void 0 : Q.kind) === "text" ? Q.value : "",
26783
- onChange: (se) => as(U, se.target.value ? { kind: "text", value: se.target.value, path: w.path } : null),
26782
+ value: (U == null ? void 0 : U.kind) === "text" ? U.value : "",
26783
+ onChange: (se) => as(Q, se.target.value ? { kind: "text", value: se.target.value, path: w.path } : null),
26784
26784
  placeholder: "Filter…",
26785
- "aria-label": `Filter ${U}`,
26785
+ "aria-label": `Filter ${Q}`,
26786
26786
  className: "h-6 w-full min-w-[64px] rounded border border-slate-200 bg-white px-1.5 text-[11px] font-normal normal-case tracking-normal outline-none focus:border-[#00ceff80] dark:border-slate-700 dark:bg-slate-900 dark:text-slate-100"
26787
26787
  }
26788
26788
  );
26789
26789
  if (w.kind === "num") {
26790
- const se = (Q == null ? void 0 : Q.kind) === "num" ? Q.op : "_eq", $e = (Q == null ? void 0 : Q.kind) === "num" ? Q.value : "";
26790
+ const se = (U == null ? void 0 : U.kind) === "num" ? U.op : "_eq", $e = (U == null ? void 0 : U.kind) === "num" ? U.value : "";
26791
26791
  return /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-0.5", children: [
26792
26792
  /* @__PURE__ */ jsx(
26793
26793
  SimpleSelectXs,
26794
26794
  {
26795
26795
  value: se,
26796
- onChange: (Oe) => as(U, { kind: "num", op: Oe, value: $e }),
26796
+ onChange: (Oe) => as(Q, { kind: "num", op: Oe, value: $e }),
26797
26797
  options: NUM_FILTER_OPS.map((Oe) => ({ value: Oe.value, label: Oe.label })),
26798
- ariaLabel: `Filter operator ${U}`
26798
+ ariaLabel: `Filter operator ${Q}`
26799
26799
  }
26800
26800
  ),
26801
26801
  /* @__PURE__ */ jsx(
@@ -26803,8 +26803,8 @@ function CollectionBrowserView({
26803
26803
  {
26804
26804
  type: "number",
26805
26805
  value: $e,
26806
- onChange: (Oe) => as(U, Oe.target.value ? { kind: "num", op: se, value: Oe.target.value } : null),
26807
- "aria-label": `Filter value ${U}`,
26806
+ onChange: (Oe) => as(Q, Oe.target.value ? { kind: "num", op: se, value: Oe.target.value } : null),
26807
+ "aria-label": `Filter value ${Q}`,
26808
26808
  className: "h-6 w-full min-w-[52px] rounded border border-slate-200 bg-white px-1.5 text-[11px] font-normal outline-none focus:border-[#00ceff80] dark:border-slate-700 dark:bg-slate-900 dark:text-slate-100"
26809
26809
  }
26810
26810
  )
@@ -26813,52 +26813,52 @@ function CollectionBrowserView({
26813
26813
  return w.kind === "bool" ? /* @__PURE__ */ jsx(
26814
26814
  SimpleSelectXs,
26815
26815
  {
26816
- value: (Q == null ? void 0 : Q.kind) === "bool" ? Q.value : "",
26817
- onChange: (se) => as(U, se ? { kind: "bool", value: se } : null),
26816
+ value: (U == null ? void 0 : U.kind) === "bool" ? U.value : "",
26817
+ onChange: (se) => as(Q, se ? { kind: "bool", value: se } : null),
26818
26818
  options: [
26819
26819
  { value: "", label: "All" },
26820
26820
  { value: "true", label: "Yes" },
26821
26821
  { value: "false", label: "No" }
26822
26822
  ],
26823
- ariaLabel: `Filter ${U}`,
26823
+ ariaLabel: `Filter ${Q}`,
26824
26824
  className: "w-full"
26825
26825
  }
26826
26826
  ) : w.kind === "date" ? /* @__PURE__ */ jsx(
26827
26827
  DateColFilter,
26828
26828
  {
26829
- value: (Q == null ? void 0 : Q.kind) === "date" ? Q.value : "",
26830
- onChange: (se) => as(U, se ? { kind: "date", value: se } : null)
26829
+ value: (U == null ? void 0 : U.kind) === "date" ? U.value : "",
26830
+ onChange: (se) => as(Q, se ? { kind: "date", value: se } : null)
26831
26831
  }
26832
26832
  ) : null;
26833
- }, gn = et.some((U) => Ks(U) != null), mn = (U) => {
26834
- var Q, se;
26835
- if (((Q = g[U]) == null ? void 0 : Q.type) === "number") return !0;
26836
- if (U.includes(".") || U in Re || isM2OField(qt, e, U)) return !1;
26837
- const w = (se = lt.get(U)) == null ? void 0 : se.type;
26833
+ }, gn = et.some((Q) => Ks(Q) != null), mn = (Q) => {
26834
+ var U, se;
26835
+ if (((U = g[Q]) == null ? void 0 : U.type) === "number") return !0;
26836
+ if (Q.includes(".") || Q in Re || isM2OField(qt, e, Q)) return !1;
26837
+ const w = (se = lt.get(Q)) == null ? void 0 : se.type;
26838
26838
  return w === "integer" || w === "decimal" || w === "float";
26839
- }, Tn = (U, w) => {
26840
- const Q = g[w];
26841
- return Q && U && U !== "—" ? formatMultiValue(U, Q) : U;
26839
+ }, Tn = (Q, w) => {
26840
+ const U = g[w];
26841
+ return U && Q && Q !== "—" ? formatMultiValue(Q, U) : Q;
26842
26842
  }, { data: Es = [] } = useQuery({
26843
26843
  queryKey: ["cbv-views", e],
26844
- queryFn: () => c.request(get$1("/saved-views", { collection: e })).then((U) => U.data ?? []),
26844
+ queryFn: () => c.request(get$1("/saved-views", { collection: e })).then((Q) => Q.data ?? []),
26845
26845
  staleTime: 3e4
26846
- }), As = () => p.invalidateQueries({ queryKey: ["cbv-views", e] }), yn = (U) => {
26846
+ }), As = () => p.invalidateQueries({ queryKey: ["cbv-views", e] }), yn = (Q) => {
26847
26847
  var w;
26848
- if (Ce(U.id), y(U.filters ?? []), f(U.sort ?? ""), (w = U.columns) != null && w.length) {
26849
- const se = U.columns.map(viewColumnKey).filter((dt) => dt.includes(".") || lt.has(dt));
26848
+ if (Ce(Q.id), y(Q.filters ?? []), f(Q.sort ?? ""), (w = Q.columns) != null && w.length) {
26849
+ const se = Q.columns.map(viewColumnKey).filter((dt) => dt.includes(".") || lt.has(dt));
26850
26850
  se.length > 0 && C(se);
26851
26851
  const $e = {}, Oe = {}, Ve = {};
26852
- for (const dt of U.columns)
26852
+ for (const dt of Q.columns)
26853
26853
  typeof dt != "string" && dt.label && ($e[dt.key] = dt.label), typeof dt != "string" && dt.format && (Oe[dt.key] = dt.format), typeof dt != "string" && dt.pin && (Ve[dt.key] = dt.pin);
26854
26854
  T($e), M(Oe), ss(Object.keys(Ve).length ? Ve : null);
26855
26855
  } else
26856
26856
  ss(null);
26857
26857
  v(1);
26858
26858
  }, on = () => {
26859
- const U = Es.find((w) => w.is_default);
26860
- if (U) {
26861
- yn(U);
26859
+ const Q = Es.find((w) => w.is_default);
26860
+ if (Q) {
26861
+ yn(Q);
26862
26862
  return;
26863
26863
  }
26864
26864
  Ce(null), y([]), f(n ?? ""), C(s ?? null), T({}), M({}), ss(null), v(1);
@@ -26866,43 +26866,43 @@ function CollectionBrowserView({
26866
26866
  filters: F,
26867
26867
  sort: b,
26868
26868
  columns: [
26869
- ...et.map((U) => {
26870
- const w = q[U], Q = g[U], se = is[U];
26871
- return !w && !Q && !se ? U : {
26872
- key: U,
26869
+ ...et.map((Q) => {
26870
+ const w = q[Q], U = g[Q], se = is[Q];
26871
+ return !w && !U && !se ? Q : {
26872
+ key: Q,
26873
26873
  ...w ? { label: w } : {},
26874
- ...Q ? { format: Q } : {},
26874
+ ...U ? { format: U } : {},
26875
26875
  ...se ? { pin: se } : {}
26876
26876
  };
26877
26877
  }),
26878
26878
  // Synthetic columns (State/Owners/Actions) persist pins as pin-only
26879
26879
  // entries; applyView drops them from the display-column list.
26880
- ...["__state__", "__owners__", "__actions__"].filter((U) => is[U]).map((U) => ({ key: U, pin: is[U] }))
26880
+ ...["__state__", "__owners__", "__actions__"].filter((Q) => is[Q]).map((Q) => ({ key: Q, pin: is[Q] }))
26881
26881
  ]
26882
26882
  });
26883
26883
  useEffect(() => {
26884
26884
  if (ot.current || Es.length === 0 || _t.length === 0) return;
26885
26885
  ot.current = !0;
26886
- const U = Es.find((w) => w.is_default);
26887
- U && he == null && yn(U);
26886
+ const Q = Es.find((w) => w.is_default);
26887
+ Q && he == null && yn(Q);
26888
26888
  }, [Es, _t]);
26889
- const Us = useMutation({
26889
+ const Qs = useMutation({
26890
26890
  mutationFn: () => c.request(
26891
26891
  post$1("/saved-views", { collection: e, name: ge.trim(), ...Ds() })
26892
26892
  ),
26893
- onSuccess: (U) => {
26894
- Pe(!1), He(""), Ce(U.data.id), As();
26893
+ onSuccess: (Q) => {
26894
+ Pe(!1), He(""), Ce(Q.data.id), As();
26895
26895
  }
26896
26896
  }), os = useMutation({
26897
- mutationFn: (U) => c.request(patch$1(`/saved-views/${U}`, Ds())),
26897
+ mutationFn: (Q) => c.request(patch$1(`/saved-views/${Q}`, Ds())),
26898
26898
  onSuccess: As
26899
- }), Qn = useMutation({
26900
- mutationFn: ({ id: U, on: w }) => c.request(patch$1(`/saved-views/${U}`, { is_default: w })),
26899
+ }), Un = useMutation({
26900
+ mutationFn: ({ id: Q, on: w }) => c.request(patch$1(`/saved-views/${Q}`, { is_default: w })),
26901
26901
  onSuccess: As
26902
26902
  }), Wn = useMutation({
26903
26903
  mutationFn: () => {
26904
- const U = Es.find((w) => w.is_default);
26905
- return U ? c.request(patch$1(`/saved-views/${U.id}`, { ...Ds(), is_default: !0 })) : c.request(
26904
+ const Q = Es.find((w) => w.is_default);
26905
+ return Q ? c.request(patch$1(`/saved-views/${Q.id}`, { ...Ds(), is_default: !0 })) : c.request(
26906
26906
  post$1("/saved-views", { collection: e, name: "Default", is_default: !0, ...Ds() })
26907
26907
  );
26908
26908
  },
@@ -26910,18 +26910,18 @@ function CollectionBrowserView({
26910
26910
  Y(!1), As();
26911
26911
  }
26912
26912
  }), Xs = useMutation({
26913
- mutationFn: (U) => c.request(del$1(`/items/${e}/${U}`)),
26913
+ mutationFn: (Q) => c.request(del$1(`/items/${e}/${Q}`)),
26914
26914
  onSuccess: () => void p.invalidateQueries({ queryKey: ["cbv-items", e] })
26915
26915
  }), Zs = useMutation({
26916
- mutationFn: (U) => c.request(del$1(`/saved-views/${U}`)),
26917
- onSuccess: (U, w) => {
26916
+ mutationFn: (Q) => c.request(del$1(`/saved-views/${Q}`)),
26917
+ onSuccess: (Q, w) => {
26918
26918
  he === w && on(), As();
26919
26919
  }
26920
26920
  }), Vn = async () => {
26921
26921
  if (!mt) {
26922
26922
  yt(!0);
26923
26923
  try {
26924
- const U = await c.request(
26924
+ const Q = await c.request(
26925
26925
  get$1(`/items/${e}`, {
26926
26926
  limit: 2e3,
26927
26927
  ...u ? { search: u } : {},
@@ -26929,12 +26929,12 @@ function CollectionBrowserView({
26929
26929
  ...vt ? { conditions: vt } : {}
26930
26930
  })
26931
26931
  ).then((We) => We.data ?? []), w = et;
26932
- let Q = {};
26932
+ let U = {};
26933
26933
  if (Ss.length > 0)
26934
26934
  try {
26935
- Q = await c.request(
26935
+ U = await c.request(
26936
26936
  get$1(`/items/${e}/resolve-paths`, {
26937
- ids: U.slice(0, 500).map((We) => String(We.id)).join(","),
26937
+ ids: Q.slice(0, 500).map((We) => String(We.id)).join(","),
26938
26938
  paths: Ss.join(",")
26939
26939
  })
26940
26940
  ).then((We) => {
@@ -26942,7 +26942,7 @@ function CollectionBrowserView({
26942
26942
  return ((Ct = We.data) == null ? void 0 : Ct.rows) ?? {};
26943
26943
  });
26944
26944
  } catch {
26945
- Q = {};
26945
+ U = {};
26946
26946
  }
26947
26947
  const se = (We) => {
26948
26948
  const Ct = We == null ? "" : String(typeof We == "object" ? JSON.stringify(We) : We);
@@ -26951,14 +26951,14 @@ function CollectionBrowserView({
26951
26951
  var ds, nn;
26952
26952
  const Ft = g[Ct];
26953
26953
  if (Ct.includes(".") || Ct in Re) {
26954
- const On = Ct.includes(".") ? Ct : Re[Ct], zn = ((nn = (ds = Q[String(We.id)]) == null ? void 0 : ds[On]) == null ? void 0 : nn.value) ?? "";
26954
+ const On = Ct.includes(".") ? Ct : Re[Ct], zn = ((nn = (ds = U[String(We.id)]) == null ? void 0 : ds[On]) == null ? void 0 : nn.value) ?? "";
26955
26955
  return Ft && zn ? formatMultiValue(zn, Ft) : zn;
26956
26956
  }
26957
26957
  const Gt = We[Ct];
26958
26958
  return Ft && Gt != null ? formatValue$1(String(Gt), Ft) : Gt;
26959
26959
  }, Oe = [
26960
26960
  ["id", ...w.map((We) => Ms(We))].map(se).join(","),
26961
- ...U.map((We) => [We.id, ...w.map((Ct) => $e(We, Ct))].map(se).join(","))
26961
+ ...Q.map((We) => [We.id, ...w.map((Ct) => $e(We, Ct))].map(se).join(","))
26962
26962
  ], Ve = new Blob([Oe.join(`
26963
26963
  `)], { type: "text/csv;charset=utf-8" }), dt = URL.createObjectURL(Ve), Nt = document.createElement("a");
26964
26964
  Nt.href = dt, Nt.download = `${e}.csv`, Nt.click(), URL.revokeObjectURL(dt);
@@ -26966,73 +26966,73 @@ function CollectionBrowserView({
26966
26966
  yt(!1);
26967
26967
  }
26968
26968
  }
26969
- }, ls = (U) => {
26970
- i ? i(U) : m({ collection: e, itemId: String(U) });
26971
- }, Cs = (U) => {
26972
- b === U ? f(`-${U}`) : b === `-${U}` ? f("") : f(U), v(1);
26973
- }, vn = us.length > 0 && us.every((U) => ue.includes(U.id)), Os = () => de(
26974
- vn ? ue.filter((U) => !us.some((w) => w.id === U)) : [.../* @__PURE__ */ new Set([...ue, ...us.map((U) => U.id)])]
26975
- ), Qs = (U) => de((w) => w.includes(U) ? w.filter((Q) => Q !== U) : [...w, U]), ps = es === 0 ? 0 : (N - 1) * ie + 1, en = Math.min(N * ie, es), Zt = !!(js != null && js.instances), Yn = (Xt ? 1 : 0) + (Zt ? 2 : 0) + (Ht ? 1 : 0), qn = [
26976
- ...et.map((U) => ({ key: U, kind: "data" })),
26969
+ }, ls = (Q) => {
26970
+ i ? i(Q) : m({ collection: e, itemId: String(Q) });
26971
+ }, Cs = (Q) => {
26972
+ b === Q ? f(`-${Q}`) : b === `-${Q}` ? f("") : f(Q), v(1);
26973
+ }, vn = us.length > 0 && us.every((Q) => ue.includes(Q.id)), Os = () => de(
26974
+ vn ? ue.filter((Q) => !us.some((w) => w.id === Q)) : [.../* @__PURE__ */ new Set([...ue, ...us.map((Q) => Q.id)])]
26975
+ ), Us = (Q) => de((w) => w.includes(Q) ? w.filter((U) => U !== Q) : [...w, Q]), ps = es === 0 ? 0 : (N - 1) * ie + 1, en = Math.min(N * ie, es), Zt = !!(js != null && js.instances), Yn = (Xt ? 1 : 0) + (Zt ? 2 : 0) + (Ht ? 1 : 0), qn = [
26976
+ ...et.map((Q) => ({ key: Q, kind: "data" })),
26977
26977
  ...Zt ? [
26978
26978
  { key: "__state__", kind: "state" },
26979
26979
  { key: "__owners__", kind: "owners" }
26980
26980
  ] : [],
26981
26981
  ...Ht ? [{ key: "__actions__", kind: "actions" }] : []
26982
26982
  ], jn = [
26983
- ...qn.filter((U) => Vt(U.key) === "left"),
26984
- ...qn.filter((U) => !Vt(U.key)),
26985
- ...qn.filter((U) => Vt(U.key) === "right")
26986
- ], tn = jn.filter((U) => Vt(U.key) === "left").map((U) => U.key), pn = jn.filter((U) => Vt(U.key) === "right").map((U) => U.key), xn = useRef(/* @__PURE__ */ new Map()), [sn, kn] = useState({});
26983
+ ...qn.filter((Q) => Vt(Q.key) === "left"),
26984
+ ...qn.filter((Q) => !Vt(Q.key)),
26985
+ ...qn.filter((Q) => Vt(Q.key) === "right")
26986
+ ], tn = jn.filter((Q) => Vt(Q.key) === "left").map((Q) => Q.key), pn = jn.filter((Q) => Vt(Q.key) === "right").map((Q) => Q.key), xn = useRef(/* @__PURE__ */ new Map()), [sn, kn] = useState({});
26987
26987
  useLayoutEffect(() => {
26988
- const U = {};
26989
- for (const [Q, se] of xn.current)
26990
- se != null && se.isConnected && (U[Q] = se.getBoundingClientRect().width);
26991
- const w = /* @__PURE__ */ new Set([...Object.keys(U), ...Object.keys(sn)]);
26992
- for (const Q of w)
26993
- if (Math.abs((U[Q] ?? -1) - (sn[Q] ?? -1)) > 0.5) {
26994
- kn(U);
26988
+ const Q = {};
26989
+ for (const [U, se] of xn.current)
26990
+ se != null && se.isConnected && (Q[U] = se.getBoundingClientRect().width);
26991
+ const w = /* @__PURE__ */ new Set([...Object.keys(Q), ...Object.keys(sn)]);
26992
+ for (const U of w)
26993
+ if (Math.abs((Q[U] ?? -1) - (sn[U] ?? -1)) > 0.5) {
26994
+ kn(Q);
26995
26995
  return;
26996
26996
  }
26997
26997
  });
26998
- const Ps = 36, dn = (U) => {
26999
- if (Vt(U) === "left") {
26998
+ const Ps = 36, dn = (Q) => {
26999
+ if (Vt(Q) === "left") {
27000
27000
  let se = Xt ? sn.__checkbox__ ?? Ps : 0;
27001
27001
  for (const $e of tn) {
27002
- if ($e === U) break;
27002
+ if ($e === Q) break;
27003
27003
  se += sn[$e] ?? 0;
27004
27004
  }
27005
27005
  return Math.floor(se);
27006
27006
  }
27007
- let Q = 0;
27007
+ let U = 0;
27008
27008
  for (const se of [...pn].reverse()) {
27009
- if (se === U) break;
27010
- Q += sn[se] ?? 0;
27009
+ if (se === Q) break;
27010
+ U += sn[se] ?? 0;
27011
27011
  }
27012
- return Math.floor(Q);
27013
- }, wn = (U, w, Q) => {
27014
- const se = Vt(U);
27012
+ return Math.floor(U);
27013
+ }, wn = (Q, w, U) => {
27014
+ const se = Vt(Q);
27015
27015
  if (!se) return "";
27016
- const $e = se === "left" && tn[tn.length - 1] === U ? "border-r border-slate-200 dark:border-slate-700" : se === "right" && pn[0] === U ? "border-l border-slate-200 dark:border-slate-700" : "";
27017
- return `sticky ${w} ${Q} ${$e}`;
27018
- }, $s = (U) => {
27019
- const w = Vt(U);
27016
+ const $e = se === "left" && tn[tn.length - 1] === Q ? "border-r border-slate-200 dark:border-slate-700" : se === "right" && pn[0] === Q ? "border-l border-slate-200 dark:border-slate-700" : "";
27017
+ return `sticky ${w} ${U} ${$e}`;
27018
+ }, $s = (Q) => {
27019
+ const w = Vt(Q);
27020
27020
  if (w)
27021
- return w === "left" ? { left: dn(U) } : { right: dn(U) };
27022
- }, Ts = (U) => (w) => {
27023
- w ? xn.current.set(U, w) : xn.current.delete(U);
27021
+ return w === "left" ? { left: dn(Q) } : { right: dn(Q) };
27022
+ }, Ts = (Q) => (w) => {
27023
+ w ? xn.current.set(Q, w) : xn.current.delete(Q);
27024
27024
  }, Rn = {
27025
27025
  left: "Pinned left — click to pin right",
27026
27026
  right: "Pinned right — click to unpin",
27027
27027
  none: "Pin column left"
27028
- }, Hs = (U) => {
27029
- const w = Vt(U);
27028
+ }, Hs = (Q) => {
27029
+ const w = Vt(Q);
27030
27030
  return /* @__PURE__ */ jsx(
27031
27031
  "button",
27032
27032
  {
27033
27033
  type: "button",
27034
- onClick: (Q) => {
27035
- Q.stopPropagation(), _s(U);
27034
+ onClick: (U) => {
27035
+ U.stopPropagation(), _s(Q);
27036
27036
  },
27037
27037
  title: Rn[w ?? "none"],
27038
27038
  "aria-label": Rn[w ?? "none"],
@@ -27115,12 +27115,12 @@ function CollectionBrowserView({
27115
27115
  collection: e,
27116
27116
  meta: st,
27117
27117
  search: k,
27118
- onSearch: (U) => {
27119
- x(U), v(1);
27118
+ onSearch: (Q) => {
27119
+ x(Q), v(1);
27120
27120
  },
27121
27121
  filters: F,
27122
- onFiltersChange: (U) => {
27123
- y(U), v(1);
27122
+ onFiltersChange: (Q) => {
27123
+ y(Q), v(1);
27124
27124
  }
27125
27125
  }
27126
27126
  ),
@@ -27140,7 +27140,7 @@ function CollectionBrowserView({
27140
27140
  "button",
27141
27141
  {
27142
27142
  type: "button",
27143
- onClick: () => Y((U) => !U),
27143
+ onClick: () => Y((Q) => !Q),
27144
27144
  className: "h-8 rounded-md border border-slate-200 px-2.5 text-[12px] font-medium text-slate-500 hover:text-slate-700 dark:border-slate-700 dark:text-slate-400",
27145
27145
  children: "Columns"
27146
27146
  }
@@ -27148,13 +27148,13 @@ function CollectionBrowserView({
27148
27148
  Ne && /* @__PURE__ */ jsxs("div", { className: "absolute right-0 top-full z-50 mt-1 flex max-h-[440px] w-72 flex-col overflow-hidden rounded-xl border border-slate-200 bg-white shadow-lg dark:border-slate-700 dark:bg-slate-900", children: [
27149
27149
  /* @__PURE__ */ jsxs("div", { className: "flex-1 overflow-y-auto p-1.5", children: [
27150
27150
  /* @__PURE__ */ jsx("p", { className: "px-1.5 pb-1 pt-0.5 text-[10.5px] font-semibold uppercase tracking-wide text-slate-400", children: "Visible columns" }),
27151
- et.map((U, w) => {
27152
- var Q;
27151
+ et.map((Q, w) => {
27152
+ var U;
27153
27153
  return /* @__PURE__ */ jsxs("div", { children: [
27154
27154
  /* @__PURE__ */ jsxs(
27155
27155
  "div",
27156
27156
  {
27157
- draggable: j !== U,
27157
+ draggable: j !== Q,
27158
27158
  onDragStart: () => {
27159
27159
  H.current = w;
27160
27160
  },
@@ -27169,15 +27169,15 @@ function CollectionBrowserView({
27169
27169
  className: "group flex items-center gap-1.5 rounded px-1.5 py-1 hover:bg-slate-50 dark:hover:bg-slate-800",
27170
27170
  children: [
27171
27171
  /* @__PURE__ */ jsx("span", { "aria-hidden": !0, className: "cursor-grab text-[10px] leading-none text-slate-300 group-hover:text-slate-400", children: "⠿" }),
27172
- j === U ? /* @__PURE__ */ jsx(
27172
+ j === Q ? /* @__PURE__ */ jsx(
27173
27173
  "input",
27174
27174
  {
27175
27175
  autoFocus: !0,
27176
- value: q[U] ?? "",
27177
- placeholder: U.includes(".") ? U.split(".").map(titleCase$1).join(" › ") : titleCase$1(U),
27176
+ value: q[Q] ?? "",
27177
+ placeholder: Q.includes(".") ? Q.split(".").map(titleCase$1).join(" › ") : titleCase$1(Q),
27178
27178
  onChange: (se) => T(($e) => {
27179
27179
  const Oe = { ...$e };
27180
- return se.target.value ? Oe[U] = se.target.value : delete Oe[U], Oe;
27180
+ return se.target.value ? Oe[Q] = se.target.value : delete Oe[Q], Oe;
27181
27181
  }),
27182
27182
  onKeyDown: (se) => {
27183
27183
  (se.key === "Enter" || se.key === "Escape") && _(null);
@@ -27185,14 +27185,14 @@ function CollectionBrowserView({
27185
27185
  onBlur: () => _(null),
27186
27186
  className: "h-5 w-full min-w-0 flex-1 rounded border border-slate-200 bg-slate-50 px-1 text-[11.5px] outline-none focus:border-[#00ceff80] dark:border-slate-700 dark:bg-slate-800 dark:text-slate-100"
27187
27187
  }
27188
- ) : /* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1 truncate text-[12px] text-slate-700 dark:text-slate-200", children: Ms(U) }),
27189
- j !== U && /* @__PURE__ */ jsx(
27188
+ ) : /* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1 truncate text-[12px] text-slate-700 dark:text-slate-200", children: Ms(Q) }),
27189
+ j !== Q && /* @__PURE__ */ jsx(
27190
27190
  "button",
27191
27191
  {
27192
27192
  type: "button",
27193
- onClick: () => _(U),
27193
+ onClick: () => _(Q),
27194
27194
  title: "Rename column",
27195
- "aria-label": `Rename ${U}`,
27195
+ "aria-label": `Rename ${Q}`,
27196
27196
  className: "text-slate-300 opacity-0 hover:text-slate-500 group-hover:opacity-100",
27197
27197
  children: "✎"
27198
27198
  }
@@ -27201,10 +27201,10 @@ function CollectionBrowserView({
27201
27201
  "button",
27202
27202
  {
27203
27203
  type: "button",
27204
- onClick: () => P(L === U ? null : U),
27204
+ onClick: () => P(L === Q ? null : Q),
27205
27205
  title: "Format column",
27206
- "aria-label": `Format ${U}`,
27207
- className: g[U] ? "text-[11px] font-bold text-[#00a5cc]" : "text-[11px] text-slate-300 opacity-0 hover:text-slate-500 group-hover:opacity-100",
27206
+ "aria-label": `Format ${Q}`,
27207
+ className: g[Q] ? "text-[11px] font-bold text-[#00a5cc]" : "text-[11px] text-slate-300 opacity-0 hover:text-slate-500 group-hover:opacity-100",
27208
27208
  children: "$"
27209
27209
  }
27210
27210
  ),
@@ -27212,9 +27212,9 @@ function CollectionBrowserView({
27212
27212
  "button",
27213
27213
  {
27214
27214
  type: "button",
27215
- onClick: () => C(et.filter((se) => se !== U)),
27215
+ onClick: () => C(et.filter((se) => se !== Q)),
27216
27216
  title: "Remove column",
27217
- "aria-label": `Remove ${U}`,
27217
+ "aria-label": `Remove ${Q}`,
27218
27218
  className: "text-slate-300 hover:text-slate-500",
27219
27219
  children: "✕"
27220
27220
  }
@@ -27222,9 +27222,9 @@ function CollectionBrowserView({
27222
27222
  ]
27223
27223
  }
27224
27224
  ),
27225
- L === U && /* @__PURE__ */ jsxs("div", { className: "mb-1 ml-5 mr-1 rounded-md border border-slate-100 bg-slate-50 p-1.5 dark:border-slate-800 dark:bg-slate-800/60", children: [
27225
+ L === Q && /* @__PURE__ */ jsxs("div", { className: "mb-1 ml-5 mr-1 rounded-md border border-slate-100 bg-slate-50 p-1.5 dark:border-slate-800 dark:bg-slate-800/60", children: [
27226
27226
  /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-1", children: FORMAT_PRESETS.map((se) => {
27227
- const $e = JSON.stringify(g[U] ?? null) === JSON.stringify(se.cfg);
27227
+ const $e = JSON.stringify(g[Q] ?? null) === JSON.stringify(se.cfg);
27228
27228
  return /* @__PURE__ */ jsx(
27229
27229
  "button",
27230
27230
  {
@@ -27232,7 +27232,7 @@ function CollectionBrowserView({
27232
27232
  onClick: () => {
27233
27233
  M((Oe) => {
27234
27234
  const Ve = { ...Oe };
27235
- return se.cfg ? Ve[U] = se.cfg : delete Ve[U], Ve;
27235
+ return se.cfg ? Ve[Q] = se.cfg : delete Ve[Q], Ve;
27236
27236
  }), P(null);
27237
27237
  },
27238
27238
  className: `rounded border px-1.5 py-0.5 text-[10.5px] ${$e ? "border-[#00ceff66] bg-[#00ceff14] text-slate-800 dark:text-slate-100" : "border-slate-200 bg-white text-slate-500 hover:text-slate-700 dark:border-slate-700 dark:bg-slate-900 dark:text-slate-400"}`,
@@ -27245,11 +27245,11 @@ function CollectionBrowserView({
27245
27245
  "input",
27246
27246
  {
27247
27247
  placeholder: "Custom date… e.g. DD MMM YY hh:mm A — Enter",
27248
- defaultValue: ((Q = g[U]) == null ? void 0 : Q.type) === "datetime" ? g[U].template : "",
27248
+ defaultValue: ((U = g[Q]) == null ? void 0 : U.type) === "datetime" ? g[Q].template : "",
27249
27249
  onKeyDown: (se) => {
27250
27250
  if (se.key === "Enter") {
27251
27251
  const $e = se.target.value.trim();
27252
- $e && M((Oe) => ({ ...Oe, [U]: { type: "datetime", template: $e } })), P(null);
27252
+ $e && M((Oe) => ({ ...Oe, [Q]: { type: "datetime", template: $e } })), P(null);
27253
27253
  }
27254
27254
  se.key === "Escape" && P(null);
27255
27255
  },
@@ -27257,21 +27257,21 @@ function CollectionBrowserView({
27257
27257
  }
27258
27258
  )
27259
27259
  ] })
27260
- ] }, U);
27260
+ ] }, Q);
27261
27261
  }),
27262
27262
  /* @__PURE__ */ jsx("p", { className: "mt-2 border-t border-slate-100 px-1.5 pb-1 pt-2 text-[10.5px] font-semibold uppercase tracking-wide text-slate-400 dark:border-slate-800", children: "Add column" }),
27263
- _t.filter((U) => !et.includes(U.field)).map((U) => /* @__PURE__ */ jsxs(
27263
+ _t.filter((Q) => !et.includes(Q.field)).map((Q) => /* @__PURE__ */ jsxs(
27264
27264
  "button",
27265
27265
  {
27266
27266
  type: "button",
27267
- onClick: () => C([...et, U.field]),
27267
+ onClick: () => C([...et, Q.field]),
27268
27268
  className: "flex w-full items-center gap-1.5 rounded px-1.5 py-1 text-left text-[12px] text-slate-600 hover:bg-slate-50 dark:text-slate-300 dark:hover:bg-slate-800",
27269
27269
  children: [
27270
27270
  /* @__PURE__ */ jsx("span", { "aria-hidden": !0, className: "text-slate-400", children: "+" }),
27271
- /* @__PURE__ */ jsx("span", { className: "truncate", children: titleCase$1(U.field) })
27271
+ /* @__PURE__ */ jsx("span", { className: "truncate", children: titleCase$1(Q.field) })
27272
27272
  ]
27273
27273
  },
27274
- U.field
27274
+ Q.field
27275
27275
  )),
27276
27276
  st && /* @__PURE__ */ jsxs("div", { className: "mt-1 border-t border-slate-100 pt-1.5 dark:border-slate-800", children: [
27277
27277
  /* @__PURE__ */ jsx("p", { className: "px-1.5 pb-1 text-[10.5px] font-semibold uppercase tracking-wide text-slate-400", children: "+ Related column" }),
@@ -27280,8 +27280,8 @@ function CollectionBrowserView({
27280
27280
  {
27281
27281
  collection: e,
27282
27282
  meta: st,
27283
- onPick: (U) => {
27284
- const w = U.join(".");
27283
+ onPick: (Q) => {
27284
+ const w = Q.join(".");
27285
27285
  et.includes(w) || C([...et, w]), Y(!1);
27286
27286
  }
27287
27287
  }
@@ -27297,9 +27297,9 @@ function CollectionBrowserView({
27297
27297
  autoFocus: !0,
27298
27298
  value: ge,
27299
27299
  placeholder: "Preset name…",
27300
- onChange: (U) => He(U.target.value),
27301
- onKeyDown: (U) => {
27302
- U.key === "Enter" && ge.trim() && (Us.mutate(), D(!1)), U.key === "Escape" && D(!1);
27300
+ onChange: (Q) => He(Q.target.value),
27301
+ onKeyDown: (Q) => {
27302
+ Q.key === "Enter" && ge.trim() && (Qs.mutate(), D(!1)), Q.key === "Escape" && D(!1);
27303
27303
  },
27304
27304
  className: "h-6 w-full min-w-0 flex-1 rounded border border-slate-200 bg-slate-50 px-1.5 text-[11.5px] outline-none focus:border-[#00ceff80] dark:border-slate-700 dark:bg-slate-800 dark:text-slate-100"
27305
27305
  }
@@ -27308,9 +27308,9 @@ function CollectionBrowserView({
27308
27308
  "button",
27309
27309
  {
27310
27310
  type: "button",
27311
- disabled: !ge.trim() || Us.isPending,
27311
+ disabled: !ge.trim() || Qs.isPending,
27312
27312
  onClick: () => {
27313
- Us.mutate(), D(!1);
27313
+ Qs.mutate(), D(!1);
27314
27314
  },
27315
27315
  className: "text-[11.5px] font-medium text-[#00a5cc] disabled:opacity-40",
27316
27316
  children: "Save"
@@ -27369,11 +27369,11 @@ function CollectionBrowserView({
27369
27369
  ] }),
27370
27370
  ne.length > 0 && /* @__PURE__ */ jsxs("div", { className: "flex shrink-0 flex-wrap items-center gap-1.5 border-b border-slate-100 bg-[#00ceff08] px-4 py-1.5 dark:border-slate-800", children: [
27371
27371
  /* @__PURE__ */ jsx("span", { className: "text-[11px] font-medium text-slate-500 dark:text-slate-400", children: "Showing:" }),
27372
- ne.map((U, w) => /* @__PURE__ */ jsx(
27372
+ ne.map((Q, w) => /* @__PURE__ */ jsx(
27373
27373
  "span",
27374
27374
  {
27375
27375
  className: "rounded border border-[#00ceff66] bg-[#00ceff14] px-1.5 py-px text-[11px] text-slate-800 dark:text-slate-100",
27376
- children: U.label ?? U.path.join(".")
27376
+ children: Q.label ?? Q.path.join(".")
27377
27377
  },
27378
27378
  w
27379
27379
  )),
@@ -27388,16 +27388,16 @@ function CollectionBrowserView({
27388
27388
  )
27389
27389
  ] }),
27390
27390
  De.length > 0 && /* @__PURE__ */ jsxs("div", { className: "flex shrink-0 flex-wrap items-center gap-1.5 border-b border-slate-100 bg-white px-4 py-1.5 dark:border-slate-800 dark:bg-slate-900", children: [
27391
- De.map((U) => /* @__PURE__ */ jsx(
27391
+ De.map((Q) => /* @__PURE__ */ jsx(
27392
27392
  QuickFilterSelect,
27393
27393
  {
27394
- def: U,
27395
- allowedIds: at(U),
27396
- scopeDefault: me.has(U.key),
27397
- selected: K[U.key] ?? [],
27398
- onChange: (w) => xe((Q) => ({ ...Q, [U.key]: w }))
27394
+ def: Q,
27395
+ allowedIds: at(Q),
27396
+ scopeDefault: me.has(Q.key),
27397
+ selected: K[Q.key] ?? [],
27398
+ onChange: (w) => xe((U) => ({ ...U, [Q.key]: w }))
27399
27399
  },
27400
- U.key
27400
+ Q.key
27401
27401
  )),
27402
27402
  /* @__PURE__ */ jsx(
27403
27403
  "button",
@@ -27428,7 +27428,7 @@ function CollectionBrowserView({
27428
27428
  ] })
27429
27429
  ] }),
27430
27430
  /* @__PURE__ */ jsxs("div", { className: "flex shrink-0 flex-wrap items-center gap-1.5 border-b border-slate-100 bg-white px-4 py-1.5 dark:border-slate-800 dark:bg-slate-900", children: [
27431
- !Es.some((U) => U.is_default) && /* @__PURE__ */ jsx(
27431
+ !Es.some((Q) => Q.is_default) && /* @__PURE__ */ jsx(
27432
27432
  "button",
27433
27433
  {
27434
27434
  type: "button",
@@ -27437,39 +27437,39 @@ function CollectionBrowserView({
27437
27437
  children: "Default"
27438
27438
  }
27439
27439
  ),
27440
- Es.map((U) => /* @__PURE__ */ jsxs(
27440
+ Es.map((Q) => /* @__PURE__ */ jsxs(
27441
27441
  "span",
27442
27442
  {
27443
- className: `inline-flex h-6 items-center gap-1 rounded-full border px-2.5 text-[12px] transition-colors ${he === U.id ? "border-[#00ceff66] bg-[#00ceff1a] text-slate-900 dark:text-white" : "border-slate-200 bg-white text-slate-600 hover:bg-slate-50 dark:border-slate-700 dark:bg-slate-900 dark:text-slate-300"}`,
27443
+ className: `inline-flex h-6 items-center gap-1 rounded-full border px-2.5 text-[12px] transition-colors ${he === Q.id ? "border-[#00ceff66] bg-[#00ceff1a] text-slate-900 dark:text-white" : "border-slate-200 bg-white text-slate-600 hover:bg-slate-50 dark:border-slate-700 dark:bg-slate-900 dark:text-slate-300"}`,
27444
27444
  children: [
27445
- U.is_default && /* @__PURE__ */ jsx("span", { title: "Collection default view", className: "text-[#00a5cc]", children: "★" }),
27446
- U.is_shared && !U.is_default && /* @__PURE__ */ jsx("span", { title: "Shared", children: "⚭" }),
27447
- /* @__PURE__ */ jsx("button", { type: "button", onClick: () => yn(U), children: U.name }),
27448
- he === U.id && /* @__PURE__ */ jsxs(Fragment, { children: [
27449
- /* @__PURE__ */ jsx("button", { type: "button", onClick: () => os.mutate(U.id), title: "Update with current state", "aria-label": `Update ${U.name}`, children: "↺" }),
27445
+ Q.is_default && /* @__PURE__ */ jsx("span", { title: "Collection default view", className: "text-[#00a5cc]", children: "★" }),
27446
+ Q.is_shared && !Q.is_default && /* @__PURE__ */ jsx("span", { title: "Shared", children: "⚭" }),
27447
+ /* @__PURE__ */ jsx("button", { type: "button", onClick: () => yn(Q), children: Q.name }),
27448
+ he === Q.id && /* @__PURE__ */ jsxs(Fragment, { children: [
27449
+ /* @__PURE__ */ jsx("button", { type: "button", onClick: () => os.mutate(Q.id), title: "Update with current state", "aria-label": `Update ${Q.name}`, children: "↺" }),
27450
27450
  ht && /* @__PURE__ */ jsx(
27451
27451
  "button",
27452
27452
  {
27453
27453
  type: "button",
27454
- onClick: () => Qn.mutate({ id: U.id, on: !U.is_default }),
27455
- title: U.is_default ? "Unset collection default" : "Make collection default",
27456
- "aria-label": `Toggle default ${U.name}`,
27457
- className: U.is_default ? "text-[#00a5cc]" : "text-slate-400 hover:text-[#00a5cc]",
27454
+ onClick: () => Un.mutate({ id: Q.id, on: !Q.is_default }),
27455
+ title: Q.is_default ? "Unset collection default" : "Make collection default",
27456
+ "aria-label": `Toggle default ${Q.name}`,
27457
+ className: Q.is_default ? "text-[#00a5cc]" : "text-slate-400 hover:text-[#00a5cc]",
27458
27458
  children: "★"
27459
27459
  }
27460
27460
  ),
27461
- /* @__PURE__ */ jsx("button", { type: "button", onClick: () => Zs.mutate(U.id), title: "Delete view", "aria-label": `Delete ${U.name}`, className: "hover:text-red-500", children: "✕" })
27461
+ /* @__PURE__ */ jsx("button", { type: "button", onClick: () => Zs.mutate(Q.id), title: "Delete view", "aria-label": `Delete ${Q.name}`, className: "hover:text-red-500", children: "✕" })
27462
27462
  ] })
27463
27463
  ]
27464
27464
  },
27465
- U.id
27465
+ Q.id
27466
27466
  )),
27467
27467
  qe ? /* @__PURE__ */ jsxs(
27468
27468
  "form",
27469
27469
  {
27470
27470
  className: "flex items-center gap-1",
27471
- onSubmit: (U) => {
27472
- U.preventDefault(), ge.trim() && Us.mutate();
27471
+ onSubmit: (Q) => {
27472
+ Q.preventDefault(), ge.trim() && Qs.mutate();
27473
27473
  },
27474
27474
  children: [
27475
27475
  /* @__PURE__ */ jsx(
@@ -27477,7 +27477,7 @@ function CollectionBrowserView({
27477
27477
  {
27478
27478
  autoFocus: !0,
27479
27479
  value: ge,
27480
- onChange: (U) => He(U.target.value),
27480
+ onChange: (Q) => He(Q.target.value),
27481
27481
  placeholder: "View name…",
27482
27482
  className: "h-6 w-32 rounded border border-slate-200 bg-slate-50 px-1.5 text-[11.5px] outline-none focus:border-[#00ceff80] dark:border-slate-700 dark:bg-slate-800 dark:text-slate-100"
27483
27483
  }
@@ -27504,16 +27504,16 @@ function CollectionBrowserView({
27504
27504
  "data-cbv-scroll": !0,
27505
27505
  className: "min-h-0 flex-1 overflow-y-auto overflow-x-hidden",
27506
27506
  children: et.length === 0 ? /* @__PURE__ */ jsxs("div", { className: "p-0", children: [
27507
- /* @__PURE__ */ jsx("div", { className: "flex h-8 items-center gap-6 border-b border-slate-200 bg-slate-50 px-4 dark:border-slate-700 dark:bg-slate-800", children: [64, 90, 140, 80, 110, 70, 96, 120].map((U, w) => /* @__PURE__ */ jsx("span", { className: "cbv-shimmer h-2.5 rounded", style: { width: U } }, w)) }),
27508
- Array.from({ length: 14 }, (U, w) => /* @__PURE__ */ jsx(
27507
+ /* @__PURE__ */ jsx("div", { className: "flex h-8 items-center gap-6 border-b border-slate-200 bg-slate-50 px-4 dark:border-slate-700 dark:bg-slate-800", children: [64, 90, 140, 80, 110, 70, 96, 120].map((Q, w) => /* @__PURE__ */ jsx("span", { className: "cbv-shimmer h-2.5 rounded", style: { width: Q } }, w)) }),
27508
+ Array.from({ length: 14 }, (Q, w) => /* @__PURE__ */ jsx(
27509
27509
  "div",
27510
27510
  {
27511
27511
  className: "flex h-8 items-center gap-6 border-b border-slate-100 px-4 dark:border-slate-800",
27512
- children: [64, 90, 140, 80, 110, 70, 96, 120].map((Q, se) => /* @__PURE__ */ jsx(
27512
+ children: [64, 90, 140, 80, 110, 70, 96, 120].map((U, se) => /* @__PURE__ */ jsx(
27513
27513
  "span",
27514
27514
  {
27515
27515
  className: "cbv-shimmer h-3 rounded",
27516
- style: { width: Q * (0.6 + (w * 7 + se * 3) % 5 * 0.12) }
27516
+ style: { width: U * (0.6 + (w * 7 + se * 3) % 5 * 0.12) }
27517
27517
  },
27518
27518
  se
27519
27519
  ))
@@ -27531,16 +27531,16 @@ function CollectionBrowserView({
27531
27531
  children: /* @__PURE__ */ jsx("input", { type: "checkbox", checked: vn, onChange: Os, "aria-label": "Select all" })
27532
27532
  }
27533
27533
  ),
27534
- jn.map((U) => {
27535
- const w = U.key, Q = !!Vt(w), se = `group/hcell sticky top-0 h-8 select-none whitespace-nowrap bg-slate-50 px-3 py-0 text-[10px] font-bold uppercase tracking-wider text-slate-500 dark:bg-slate-800 dark:text-slate-400 ${Q ? "z-[4]" : "z-[2]"}`, $e = wn(w, "", "");
27536
- if (U.kind !== "data") {
27537
- const Ft = U.kind === "state" ? "State" : U.kind === "owners" ? "Owners" : "";
27534
+ jn.map((Q) => {
27535
+ const w = Q.key, U = !!Vt(w), se = `group/hcell sticky top-0 h-8 select-none whitespace-nowrap bg-slate-50 px-3 py-0 text-[10px] font-bold uppercase tracking-wider text-slate-500 dark:bg-slate-800 dark:text-slate-400 ${U ? "z-[4]" : "z-[2]"}`, $e = wn(w, "", "");
27536
+ if (Q.kind !== "data") {
27537
+ const Ft = Q.kind === "state" ? "State" : Q.kind === "owners" ? "Owners" : "";
27538
27538
  return /* @__PURE__ */ jsxs(
27539
27539
  "th",
27540
27540
  {
27541
- ref: Q ? Ts(w) : void 0,
27541
+ ref: U ? Ts(w) : void 0,
27542
27542
  style: $s(w),
27543
- className: `${se} text-left ${U.kind === "actions" ? "w-20 px-2" : ""} ${$e}`,
27543
+ className: `${se} text-left ${Q.kind === "actions" ? "w-20 px-2" : ""} ${$e}`,
27544
27544
  children: [
27545
27545
  Ft,
27546
27546
  Hs(w)
@@ -27553,7 +27553,7 @@ function CollectionBrowserView({
27553
27553
  return /* @__PURE__ */ jsxs(
27554
27554
  "th",
27555
27555
  {
27556
- ref: Q ? Ts(w) : void 0,
27556
+ ref: U ? Ts(w) : void 0,
27557
27557
  style: $s(w),
27558
27558
  onClick: () => {
27559
27559
  Ve || Cs(w);
@@ -27572,10 +27572,10 @@ function CollectionBrowserView({
27572
27572
  ] }),
27573
27573
  (gn || Zt) && /* @__PURE__ */ jsxs("tr", { className: "border-b border-slate-200 dark:border-slate-700", children: [
27574
27574
  Xt && /* @__PURE__ */ jsx("th", { className: "sticky left-0 top-8 z-[4] w-9 bg-slate-50 px-3 py-1 dark:bg-slate-800" }),
27575
- jn.map((U) => {
27575
+ jn.map((Q) => {
27576
27576
  var $e;
27577
- const w = U.key, se = `sticky top-8 bg-slate-50 px-2 py-1 text-left font-normal dark:bg-slate-800 ${!!Vt(w) ? "z-[4]" : "z-[2]"} ${wn(w, "", "")}`;
27578
- return U.kind === "state" ? /* @__PURE__ */ jsx("th", { style: $s(w), className: se, children: /* @__PURE__ */ jsx(
27577
+ const w = Q.key, se = `sticky top-8 bg-slate-50 px-2 py-1 text-left font-normal dark:bg-slate-800 ${!!Vt(w) ? "z-[4]" : "z-[2]"} ${wn(w, "", "")}`;
27578
+ return Q.kind === "state" ? /* @__PURE__ */ jsx("th", { style: $s(w), className: se, children: /* @__PURE__ */ jsx(
27579
27579
  MultiPick,
27580
27580
  {
27581
27581
  block: !0,
@@ -27590,18 +27590,18 @@ function CollectionBrowserView({
27590
27590
  Oe.length ? { kind: "state", value: Oe.map(String) } : null
27591
27591
  )
27592
27592
  }
27593
- ) }, w) : U.kind !== "data" ? /* @__PURE__ */ jsx(
27593
+ ) }, w) : Q.kind !== "data" ? /* @__PURE__ */ jsx(
27594
27594
  "th",
27595
27595
  {
27596
27596
  style: $s(w),
27597
- className: `${se} ${U.kind === "actions" ? "w-20" : ""}`
27597
+ className: `${se} ${Q.kind === "actions" ? "w-20" : ""}`
27598
27598
  },
27599
27599
  w
27600
27600
  ) : /* @__PURE__ */ jsx("th", { style: $s(w), className: se, children: zs(w) }, w);
27601
27601
  })
27602
27602
  ] })
27603
27603
  ] }),
27604
- /* @__PURE__ */ jsx("tbody", { className: "text-[12px] tabular-nums", children: bt ? Array.from({ length: 12 }, (U, w) => /* @__PURE__ */ jsx("tr", { className: "border-b border-slate-100 dark:border-slate-800", children: /* @__PURE__ */ jsx("td", { className: "px-3 py-2", colSpan: et.length + Yn, children: /* @__PURE__ */ jsx(
27604
+ /* @__PURE__ */ jsx("tbody", { className: "text-[12px] tabular-nums", children: bt ? Array.from({ length: 12 }, (Q, w) => /* @__PURE__ */ jsx("tr", { className: "border-b border-slate-100 dark:border-slate-800", children: /* @__PURE__ */ jsx("td", { className: "px-3 py-2", colSpan: et.length + Yn, children: /* @__PURE__ */ jsx(
27605
27605
  "span",
27606
27606
  {
27607
27607
  className: "cbv-shimmer block h-3.5 rounded",
@@ -27611,7 +27611,7 @@ function CollectionBrowserView({
27611
27611
  /* @__PURE__ */ jsx("span", { className: "flex h-10 w-10 items-center justify-center rounded-full bg-slate-100 dark:bg-slate-800", children: /* @__PURE__ */ jsx(Search, { "aria-hidden": !0, className: "h-4.5 w-4.5 h-5 w-5 text-slate-400" }) }),
27612
27612
  /* @__PURE__ */ jsx("p", { className: "text-[13.5px] font-medium text-slate-600 dark:text-slate-300", children: "No records match" }),
27613
27613
  /* @__PURE__ */ jsx("p", { className: "text-[12px] text-slate-400", children: "Try adjusting your search or filters." }),
27614
- (F.length > 0 || Object.keys(ce).length > 0 || Object.values(G).some((U) => U.length > 0) || u) && /* @__PURE__ */ jsx(
27614
+ (F.length > 0 || Object.keys(ce).length > 0 || Object.values(G).some((Q) => Q.length > 0) || u) && /* @__PURE__ */ jsx(
27615
27615
  "button",
27616
27616
  {
27617
27617
  type: "button",
@@ -27622,15 +27622,15 @@ function CollectionBrowserView({
27622
27622
  children: "Clear all filters"
27623
27623
  }
27624
27624
  )
27625
- ] }) }) }) : us.map((U) => {
27625
+ ] }) }) }) : us.map((Q) => {
27626
27626
  var dt;
27627
- const w = U.id, Q = ue.includes(w), se = (dt = js == null ? void 0 : js.instances) == null ? void 0 : dt[String(w)], $e = En[String(w)], Oe = !Q && $e ? rowHighlightClass($e.color) : void 0, Ve = Q ? "bg-[#e6fafe] dark:bg-[#0c2a33]" : Oe ?? "bg-white group-hover:bg-[#f2fcff] dark:bg-slate-900 dark:group-hover:bg-[#0e2d3a]";
27627
+ const w = Q.id, U = ue.includes(w), se = (dt = js == null ? void 0 : js.instances) == null ? void 0 : dt[String(w)], $e = En[String(w)], Oe = !U && $e ? rowHighlightClass($e.color) : void 0, Ve = U ? "bg-[#e6fafe] dark:bg-[#0c2a33]" : Oe ?? "bg-white group-hover:bg-[#f2fcff] dark:bg-slate-900 dark:group-hover:bg-[#0e2d3a]";
27628
27628
  return /* @__PURE__ */ jsxs(
27629
27629
  "tr",
27630
27630
  {
27631
27631
  onClick: () => ls(w),
27632
27632
  title: $e ? `At risk — ${$e.rule}` : void 0,
27633
- className: `group h-8 cursor-pointer border-b border-slate-100 transition-colors duration-75 hover:bg-[#00ceff0a] dark:border-slate-800 dark:hover:bg-[#00ceff14] ${Q ? "bg-[#00ceff14]" : Oe ?? ""}`,
27633
+ className: `group h-8 cursor-pointer border-b border-slate-100 transition-colors duration-75 hover:bg-[#00ceff0a] dark:border-slate-800 dark:hover:bg-[#00ceff14] ${U ? "bg-[#00ceff14]" : Oe ?? ""}`,
27634
27634
  children: [
27635
27635
  Xt && /* @__PURE__ */ jsx(
27636
27636
  "td",
@@ -27641,8 +27641,8 @@ function CollectionBrowserView({
27641
27641
  "input",
27642
27642
  {
27643
27643
  type: "checkbox",
27644
- checked: Q,
27645
- onChange: () => Qs(w),
27644
+ checked: U,
27645
+ onChange: () => Us(w),
27646
27646
  "aria-label": `Select ${w}`
27647
27647
  }
27648
27648
  )
@@ -27724,9 +27724,9 @@ function CollectionBrowserView({
27724
27724
  {
27725
27725
  style: $s(We),
27726
27726
  className: `whitespace-nowrap px-3 py-1.5 ${mn(We) ? "text-right" : ""} ${wn(We, "z-[1]", Ve)}`,
27727
- children: gs(We) ? Un(We) === "nivaro_users" ? (() => {
27727
+ children: gs(We) ? Qn(We) === "nivaro_users" ? (() => {
27728
27728
  var lr, Is, ws;
27729
- const ds = We.includes(".") ? We : Re[We], nn = ((ws = (Is = (lr = Ut == null ? void 0 : Ut.rows) == null ? void 0 : lr[String(w)]) == null ? void 0 : Is[ds]) == null ? void 0 : ws.ids) ?? [], On = ts(w, We) ?? "";
27729
+ const ds = We.includes(".") ? We : Re[We], nn = ((ws = (Is = (lr = Qt == null ? void 0 : Qt.rows) == null ? void 0 : lr[String(w)]) == null ? void 0 : Is[ds]) == null ? void 0 : ws.ids) ?? [], On = ts(w, We) ?? "";
27730
27730
  if (nn.length === 0 || !On || On === "—")
27731
27731
  return /* @__PURE__ */ jsx("span", { className: "text-[12px] text-slate-300", children: "—" });
27732
27732
  if (nn.length === 1)
@@ -27760,7 +27760,7 @@ function CollectionBrowserView({
27760
27760
  "data-tip": ts(w, We) ?? void 0,
27761
27761
  children: ts(w, We) != null ? Tn(ts(w, We) ?? "", We) : /* @__PURE__ */ jsx("span", { className: "inline-block h-3.5 w-16 animate-pulse rounded bg-slate-100 dark:bg-[hsl(var(--nvr-skeleton))]" })
27762
27762
  }
27763
- ) : (Ft == null ? void 0 : Ft.one_collection) === "nivaro_users" && U[We] != null ? /* @__PURE__ */ jsx("span", { onClick: (ds) => ds.stopPropagation(), children: /* @__PURE__ */ jsx(UserChip, { userId: String(U[We]), size: "compact" }) }) : Ft != null && Ft.one_collection && U[We] != null && !isSystemCol(Ft.one_collection) ? /* @__PURE__ */ jsx(
27763
+ ) : (Ft == null ? void 0 : Ft.one_collection) === "nivaro_users" && Q[We] != null ? /* @__PURE__ */ jsx("span", { onClick: (ds) => ds.stopPropagation(), children: /* @__PURE__ */ jsx(UserChip, { userId: String(Q[We]), size: "compact" }) }) : Ft != null && Ft.one_collection && Q[We] != null && !isSystemCol(Ft.one_collection) ? /* @__PURE__ */ jsx(
27764
27764
  "button",
27765
27765
  {
27766
27766
  type: "button",
@@ -27768,20 +27768,20 @@ function CollectionBrowserView({
27768
27768
  ds.stopPropagation(), le.push([
27769
27769
  {
27770
27770
  collection: Ft.one_collection,
27771
- itemId: String(U[We])
27771
+ itemId: String(Q[We])
27772
27772
  }
27773
27773
  ]);
27774
27774
  },
27775
27775
  className: "text-left text-[12px] font-medium text-slate-700 underline decoration-slate-300 underline-offset-2 transition-colors hover:text-[#0284c7] hover:decoration-[#0284c7] dark:text-slate-200 dark:decoration-slate-600 dark:hover:text-[#38bdf8]",
27776
- children: /* @__PURE__ */ jsx(RelationLabel, { relatedCollection: Ft.one_collection, id: U[We] })
27776
+ children: /* @__PURE__ */ jsx(RelationLabel, { relatedCollection: Ft.one_collection, id: Q[We] })
27777
27777
  }
27778
- ) : g[We] && U[We] != null ? /* @__PURE__ */ jsx("span", { className: "text-[12px] tabular-nums text-slate-700 dark:text-slate-200", children: formatValue$1(String(U[We]), g[We]) }) : /* @__PURE__ */ jsx(
27778
+ ) : g[We] && Q[We] != null ? /* @__PURE__ */ jsx("span", { className: "text-[12px] tabular-nums text-slate-700 dark:text-slate-200", children: formatValue$1(String(Q[We]), g[We]) }) : /* @__PURE__ */ jsx(
27779
27779
  CellValue,
27780
27780
  {
27781
27781
  collection: e,
27782
27782
  field: We,
27783
27783
  fieldType: ((Gt = lt.get(We)) == null ? void 0 : Gt.type) ?? null,
27784
- value: U[We],
27784
+ value: Q[We],
27785
27785
  relations: qt
27786
27786
  }
27787
27787
  )
@@ -27834,7 +27834,7 @@ function CollectionBrowserView({
27834
27834
  {
27835
27835
  type: "button",
27836
27836
  disabled: N <= 1,
27837
- onClick: () => v((U) => Math.max(1, U - 1)),
27837
+ onClick: () => v((Q) => Math.max(1, Q - 1)),
27838
27838
  className: "h-7 rounded px-2.5 text-[12px] text-slate-600 hover:bg-slate-100 disabled:opacity-30 dark:text-slate-300 dark:hover:bg-slate-800",
27839
27839
  children: "← Prev"
27840
27840
  }
@@ -27849,7 +27849,7 @@ function CollectionBrowserView({
27849
27849
  {
27850
27850
  type: "button",
27851
27851
  disabled: N >= un,
27852
- onClick: () => v((U) => U + 1),
27852
+ onClick: () => v((Q) => Q + 1),
27853
27853
  className: "h-7 rounded px-2.5 text-[12px] text-slate-600 hover:bg-slate-100 disabled:opacity-30 dark:text-slate-300 dark:hover:bg-slate-800",
27854
27854
  children: "Next →"
27855
27855
  }
@@ -27875,7 +27875,7 @@ function CollectionBrowserView({
27875
27875
  itemId: J[0].itemId,
27876
27876
  width: "85%",
27877
27877
  stack: J,
27878
- onPush: (U) => le.push([...J, U]),
27878
+ onPush: (Q) => le.push([...J, Q]),
27879
27879
  onPop: () => le.back(),
27880
27880
  onClose: () => le.back(J.length)
27881
27881
  }
@@ -27886,8 +27886,8 @@ function CollectionBrowserView({
27886
27886
  collection: e,
27887
27887
  item: be,
27888
27888
  open: !0,
27889
- onOpenChange: (U) => {
27890
- U || je(null);
27889
+ onOpenChange: (Q) => {
27890
+ Q || je(null);
27891
27891
  }
27892
27892
  }
27893
27893
  ),
@@ -28090,7 +28090,7 @@ function SortableColumnToggle({
28090
28090
  ] });
28091
28091
  }
28092
28092
  function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
28093
- var Rn, Hs, Dn, U;
28093
+ var Rn, Hs, Dn, Q;
28094
28094
  const n = useQueryClient(), r = useNivaroClient(), { userId: a } = useItemEditAuth(), l = useItemNavigation(), { navigate: i } = useNavigation(), [o, d] = useState("all"), [c, p] = useState(1), [m, h] = useState("table"), [N, v] = useState(""), [k, x] = useState({}), [u, F] = useState(null), [y, b] = useState(/* @__PURE__ */ new Set()), [f, S] = useState(null), [C, q] = useState(null), [T, j] = useState(0), _ = 25, { data: g, error: M } = useQuery({
28095
28095
  queryKey: ["queue-meta", e],
28096
28096
  queryFn: () => r.request(get$1(`/queues/${e}`)).then((w) => w.data),
@@ -28100,14 +28100,14 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
28100
28100
  if (E.current || !P || !g) return;
28101
28101
  E.current = !0;
28102
28102
  const w = (g.extra_field_meta ?? []).filter(
28103
- (Q) => Q.kind === "relation" && Q.target_collection && Q.display_field
28103
+ (U) => U.kind === "relation" && U.target_collection && U.display_field
28104
28104
  );
28105
28105
  if (w.length === 0 || !L) {
28106
28106
  H(!0);
28107
28107
  return;
28108
28108
  }
28109
28109
  (async () => {
28110
- const Q = {}, se = {}, $e = async (Oe, Ve) => {
28110
+ const U = {}, se = {}, $e = async (Oe, Ve) => {
28111
28111
  const dt = await r.request(
28112
28112
  get$1(`/items/${Oe.target_collection}`, {
28113
28113
  filter: JSON.stringify({ id: { _in: Ve } }),
@@ -28134,21 +28134,21 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
28134
28134
  const Ct = k[dt];
28135
28135
  if (Ct && (Array.isArray(Ct) ? Ct.length > 0 : Ct !== "")) continue;
28136
28136
  const Ft = We.length ? await $e(Oe, We) : [];
28137
- Ft.length > 0 && (Q[dt] = Ft);
28137
+ Ft.length > 0 && (U[dt] = Ft);
28138
28138
  } catch {
28139
28139
  }
28140
28140
  }
28141
- Object.keys(se).length > 0 && xe(se), Object.keys(Q).length > 0 && (G.current = Q, x((Oe) => ({ ...Oe, ...Q }))), H(!0);
28141
+ Object.keys(se).length > 0 && xe(se), Object.keys(U).length > 0 && (G.current = U, x((Oe) => ({ ...Oe, ...U }))), H(!0);
28142
28142
  })();
28143
28143
  }, [P, L, g]);
28144
28144
  const B = ((Hs = (Rn = g == null ? void 0 : g.sources) == null ? void 0 : Rn.find((w) => w.type === "collection")) == null ? void 0 : Hs.collection) ?? null, ne = useMemo(() => {
28145
- const w = /* @__PURE__ */ new Set(), Q = [];
28145
+ const w = /* @__PURE__ */ new Set(), U = [];
28146
28146
  for (const se of (g == null ? void 0 : g.sources) ?? [])
28147
- se.type !== "collection" || !se.collection || w.has(se.collection) || (w.add(se.collection), Q.push(se.collection));
28148
- return Q;
28149
- }, [g == null ? void 0 : g.sources]), fe = (g == null ? void 0 : g.claims_enabled) !== !1, ee = g == null ? void 0 : g.display_config, z = (ee == null ? void 0 : ee.views) ?? ["table", "kanban", "workload"], re = (ee == null ? void 0 : ee.work_next) !== !1, we = (ee == null ? void 0 : ee.bulk_actions) !== !1, me = (w, Q) => {
28147
+ se.type !== "collection" || !se.collection || w.has(se.collection) || (w.add(se.collection), U.push(se.collection));
28148
+ return U;
28149
+ }, [g == null ? void 0 : g.sources]), fe = (g == null ? void 0 : g.claims_enabled) !== !1, ee = g == null ? void 0 : g.display_config, z = (ee == null ? void 0 : ee.views) ?? ["table", "kanban", "workload"], re = (ee == null ? void 0 : ee.work_next) !== !1, we = (ee == null ? void 0 : ee.bulk_actions) !== !1, me = (w, U) => {
28150
28150
  var se, $e;
28151
- return (($e = (se = g == null ? void 0 : g.column_aliases) == null ? void 0 : se[w]) == null ? void 0 : $e.trim()) || Q;
28151
+ return (($e = (se = g == null ? void 0 : g.column_aliases) == null ? void 0 : se[w]) == null ? void 0 : $e.trim()) || U;
28152
28152
  }, ve = useRef(!1);
28153
28153
  useEffect(() => {
28154
28154
  !g || ve.current || (ve.current = !0, v("-priority"));
@@ -28160,36 +28160,36 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
28160
28160
  if (!t || !(g != null && g.sources)) return;
28161
28161
  const w = [
28162
28162
  ...new Set(
28163
- g.sources.filter((Q) => Q.type === "collection" && Q.collection).map((Q) => Q.collection)
28163
+ g.sources.filter((U) => U.type === "collection" && U.collection).map((U) => U.collection)
28164
28164
  )
28165
28165
  ];
28166
28166
  if (w.length !== 0)
28167
- return t.subscribe(w, () => j((Q) => Q + 1));
28167
+ return t.subscribe(w, () => j((U) => U + 1));
28168
28168
  }, [t, g == null ? void 0 : g.sources]);
28169
28169
  const le = useDebounced(k, 350), J = (() => {
28170
28170
  const w = {};
28171
- for (const [Q, se] of Object.entries(le))
28171
+ for (const [U, se] of Object.entries(le))
28172
28172
  if (se) {
28173
28173
  if (Array.isArray(se)) {
28174
- se.length > 0 && (w[Q] = se);
28174
+ se.length > 0 && (w[U] = se);
28175
28175
  continue;
28176
28176
  }
28177
- if (Q === "aging_hours") {
28177
+ if (U === "aging_hours") {
28178
28178
  const [$e, Oe] = se.split(":"), Ve = {};
28179
- $e && (Ve.min = Number($e)), Oe && (Ve.max = Number(Oe)), (Ve.min !== void 0 || Ve.max !== void 0) && (w[Q] = Ve);
28179
+ $e && (Ve.min = Number($e)), Oe && (Ve.max = Number(Oe)), (Ve.min !== void 0 || Ve.max !== void 0) && (w[U] = Ve);
28180
28180
  continue;
28181
28181
  }
28182
- w[Q] = se;
28182
+ w[U] = se;
28183
28183
  }
28184
28184
  return w;
28185
28185
  })();
28186
- function be(w, Q) {
28187
- x((se) => ({ ...se, [w]: se[w] === Q ? "" : Q })), p(1);
28186
+ function be(w, U) {
28187
+ x((se) => ({ ...se, [w]: se[w] === U ? "" : U })), p(1);
28188
28188
  }
28189
28189
  function je(w) {
28190
- x((Q) => {
28191
- const se = Q.state, $e = Array.isArray(se) ? se : se ? [se] : [], Oe = $e.includes(w) ? $e.filter((Ve) => Ve !== w) : [...$e, w];
28192
- return { ...Q, state: Oe };
28190
+ x((U) => {
28191
+ const se = U.state, $e = Array.isArray(se) ? se : se ? [se] : [], Oe = $e.includes(w) ? $e.filter((Ve) => Ve !== w) : [...$e, w];
28192
+ return { ...U, state: Oe };
28193
28193
  }), p(1);
28194
28194
  }
28195
28195
  const Ne = Array.isArray(k.state) ? k.state : k.state ? [k.state] : [], Y = (w) => !w || Array.isArray(w) && w.length === 0;
@@ -28236,11 +28236,11 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
28236
28236
  // swapping to skeletons collapsed the table height and jittered the page.
28237
28237
  placeholderData: (w) => w
28238
28238
  }), mt = Pe && !qe || !ce || !D && !qe, yt = ge && !Pe || He && ge;
28239
- async function jt(w, Q) {
28239
+ async function jt(w, U) {
28240
28240
  const $e = (await r.request(get$1(`/pipelines/instance/${w.collection}/${w.item_id}`))).data;
28241
28241
  if (!$e || $e.states.length === 0)
28242
28242
  throw new Error("This item has no workflow instance");
28243
- const Oe = $e.states.find((dt) => dt.key === Q);
28243
+ const Oe = $e.states.find((dt) => dt.key === U);
28244
28244
  if (!Oe) throw new Error("Target state not found");
28245
28245
  const Ve = $e.available_transitions.find(
28246
28246
  (dt) => dt.to_state === Oe.id
@@ -28253,8 +28253,8 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
28253
28253
  );
28254
28254
  }
28255
28255
  const Tt = useMutation({
28256
- mutationFn: async ({ item: w, targetState: Q }) => {
28257
- await jt(w, Q);
28256
+ mutationFn: async ({ item: w, targetState: U }) => {
28257
+ await jt(w, U);
28258
28258
  },
28259
28259
  onSuccess: () => {
28260
28260
  n.invalidateQueries({ queryKey: ["queue-items", e, o] });
@@ -28328,51 +28328,51 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
28328
28328
  queryKey: ["queue-collection-states", w],
28329
28329
  queryFn: () => r.request(
28330
28330
  get$1(`/queues/collection-states/${w}`)
28331
- ).then((Q) => Q.data),
28331
+ ).then((U) => U.data),
28332
28332
  staleTime: 300 * 1e3
28333
28333
  }))
28334
- }), is = (w) => w.replace(/_/g, " ").replace(/\b\w/g, (Q) => Q.toUpperCase()), Vt = useMemo(() => {
28334
+ }), is = (w) => w.replace(/_/g, " ").replace(/\b\w/g, (U) => U.toUpperCase()), Vt = useMemo(() => {
28335
28335
  const w = {};
28336
- for (const Q of ss)
28337
- (Q.data ?? []).forEach((se, $e) => {
28336
+ for (const U of ss)
28337
+ (U.data ?? []).forEach((se, $e) => {
28338
28338
  w[se.key] = { label: se.label, color: se.color, sort: $e };
28339
28339
  });
28340
28340
  return w;
28341
28341
  }, [ss.map((w) => w.data)]), _s = $t ? Object.entries($t.by_state).sort(
28342
- (w, Q) => {
28342
+ (w, U) => {
28343
28343
  var se, $e;
28344
- return (((se = Vt[w[0]]) == null ? void 0 : se.sort) ?? Number.MAX_SAFE_INTEGER) - ((($e = Vt[Q[0]]) == null ? void 0 : $e.sort) ?? Number.MAX_SAFE_INTEGER);
28344
+ return (((se = Vt[w[0]]) == null ? void 0 : se.sort) ?? Number.MAX_SAFE_INTEGER) - ((($e = Vt[U[0]]) == null ? void 0 : $e.sort) ?? Number.MAX_SAFE_INTEGER);
28345
28345
  }
28346
28346
  ) : [], Ms = useMemo(() => {
28347
28347
  const w = {};
28348
- for (const [Q, se] of Object.entries(Vt)) w[Q] = se.label;
28348
+ for (const [U, se] of Object.entries(Vt)) w[U] = se.label;
28349
28349
  return w;
28350
28350
  }, [Vt]), Bt = (w) => w ? w === "none" ? "No State" : Ms[w] ?? is(w) : "—", te = (w) => {
28351
- const Q = (Jt ?? []).find((se) => se.collection === w);
28352
- return (Q == null ? void 0 : Q.display_name) || (Q == null ? void 0 : Q.plural) || is(w);
28351
+ const U = (Jt ?? []).find((se) => se.collection === w);
28352
+ return (U == null ? void 0 : U.display_name) || (U == null ? void 0 : U.plural) || is(w);
28353
28353
  }, ke = useMemo(() => u ? buildGroups(Ht, u) : null, [Ht, u]);
28354
28354
  useEffect(() => {
28355
28355
  !u || !ke || b(Ht.length > 200 ? new Set(ke.map((w) => w.key)) : /* @__PURE__ */ new Set());
28356
28356
  }, [u]);
28357
28357
  function Se(w) {
28358
- b((Q) => {
28359
- const se = new Set(Q);
28358
+ b((U) => {
28359
+ const se = new Set(U);
28360
28360
  return se.has(w) ? se.delete(w) : se.add(w), se;
28361
28361
  });
28362
28362
  }
28363
- const Le = useMemo(() => ke ? ke.filter((w) => !y.has(w.key)).flatMap((w) => w.rows) : Ht, [ke, Ht, y]), Qe = (w) => `${w.collection}:${w.item_id}`, [Ye, Re] = useState(null), [wt, Rt] = useState(!1), [vt, Kt] = useState(null), xt = (w) => l.open({
28363
+ const Le = useMemo(() => ke ? ke.filter((w) => !y.has(w.key)).flatMap((w) => w.rows) : Ht, [ke, Ht, y]), Ue = (w) => `${w.collection}:${w.item_id}`, [Ye, Re] = useState(null), [wt, Rt] = useState(!1), [vt, Kt] = useState(null), xt = (w) => l.open({
28364
28364
  collection: w.collection,
28365
28365
  itemId: w.item_id,
28366
28366
  layoutSlug: (ee == null ? void 0 : ee.item_layout) ?? null
28367
28367
  }), bt = (w) => {
28368
- Kt(Qe(w));
28369
- const Q = (ee == null ? void 0 : ee.row_click) ?? "preview";
28370
- if (Q === "full") {
28368
+ Kt(Ue(w));
28369
+ const U = (ee == null ? void 0 : ee.row_click) ?? "preview";
28370
+ if (U === "full") {
28371
28371
  xt(w);
28372
28372
  return;
28373
28373
  }
28374
- if (Q === "layout") {
28375
- Qn({
28374
+ if (U === "layout") {
28375
+ Un({
28376
28376
  collection: w.collection,
28377
28377
  itemId: w.item_id,
28378
28378
  rootLayoutSlug: (ee == null ? void 0 : ee.item_layout) ?? null,
@@ -28385,17 +28385,17 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
28385
28385
  };
28386
28386
  useEffect(() => {
28387
28387
  if (!Ye) return;
28388
- const w = Ht.find((Q) => Qe(Q) === Qe(Ye));
28388
+ const w = Ht.find((U) => Ue(U) === Ue(Ye));
28389
28389
  w && w !== Ye && Re(w);
28390
28390
  }, [Ht]);
28391
28391
  const St = (w) => !w.claimed_by || w.claimed_by.id === a;
28392
28392
  function bs(w) {
28393
- const Q = w ? Le.findIndex(($e) => Qe($e) === Qe(w)) + 1 : 0, se = Le.slice(Q).find(St);
28393
+ const U = w ? Le.findIndex(($e) => Ue($e) === Ue(w)) + 1 : 0, se = Le.slice(U).find(St);
28394
28394
  if (!se) {
28395
28395
  Rt(!1), Re(null), toast.info("Nothing left to work on — queue clear!");
28396
28396
  return;
28397
28397
  }
28398
- if (Kt(Qe(se)), fe && !se.claimed_by && ot.mutate(se), (ee == null ? void 0 : ee.row_click) === "full") {
28398
+ if (Kt(Ue(se)), fe && !se.claimed_by && ot.mutate(se), (ee == null ? void 0 : ee.row_click) === "full") {
28399
28399
  xt(se);
28400
28400
  return;
28401
28401
  }
@@ -28403,27 +28403,27 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
28403
28403
  }
28404
28404
  useEffect(() => {
28405
28405
  if (m !== "table") return;
28406
- function w(Q) {
28406
+ function w(U) {
28407
28407
  var Oe;
28408
- const se = Q.target;
28408
+ const se = U.target;
28409
28409
  if (se && (se.tagName === "INPUT" || se.tagName === "TEXTAREA" || se.tagName === "SELECT" || se.isContentEditable))
28410
28410
  return;
28411
- const $e = vt ? Le.findIndex((Ve) => Qe(Ve) === vt) : -1;
28412
- if (Q.key === "j" || Q.key === "ArrowDown") {
28413
- Q.preventDefault();
28411
+ const $e = vt ? Le.findIndex((Ve) => Ue(Ve) === vt) : -1;
28412
+ if (U.key === "j" || U.key === "ArrowDown") {
28413
+ U.preventDefault();
28414
28414
  const Ve = Le[Math.min($e + 1, Le.length - 1)];
28415
- Ve && Kt(Qe(Ve));
28416
- } else if (Q.key === "k" || Q.key === "ArrowUp") {
28417
- Q.preventDefault();
28415
+ Ve && Kt(Ue(Ve));
28416
+ } else if (U.key === "k" || U.key === "ArrowUp") {
28417
+ U.preventDefault();
28418
28418
  const Ve = Le[Math.max($e - 1, 0)];
28419
- Ve && Kt(Qe(Ve));
28420
- } else if (Q.key === "Enter" && $e >= 0 && !Ye)
28421
- Q.preventDefault(), bt(Le[$e]);
28422
- else if (Q.key === "c" && $e >= 0 && fe) {
28423
- Q.preventDefault();
28419
+ Ve && Kt(Ue(Ve));
28420
+ } else if (U.key === "Enter" && $e >= 0 && !Ye)
28421
+ U.preventDefault(), bt(Le[$e]);
28422
+ else if (U.key === "c" && $e >= 0 && fe) {
28423
+ U.preventDefault();
28424
28424
  const Ve = Le[$e];
28425
28425
  ((Oe = Ve.claimed_by) == null ? void 0 : Oe.id) === a ? ht.mutate(Ve) : ot.mutate(Ve);
28426
- } else Q.key === "o" && $e >= 0 && (Q.preventDefault(), xt(Le[$e]));
28426
+ } else U.key === "o" && $e >= 0 && (U.preventDefault(), xt(Le[$e]));
28427
28427
  }
28428
28428
  return window.addEventListener("keydown", w), () => window.removeEventListener("keydown", w);
28429
28429
  }, [m, Le, vt, Ye, a, ot, ht, fe]);
@@ -28433,30 +28433,30 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
28433
28433
  enabled: !!e
28434
28434
  }), [us, es] = useState(null), [un, ln] = useState(!1), [Ln, En] = useState(""), [rs, js] = useState(!1), [Ls, ks] = useState(!1);
28435
28435
  function An(w) {
28436
- const Q = w.state ?? {};
28437
- d(Q.scope ?? "all"), x({ ...G.current, ...Q.filters ?? {} }), v(Q.sort ?? ""), F(Q.group_by ?? null), _t(Q.columns ?? null), q(Q.pins ?? null), Q.view && h(z.includes(Q.view) ? Q.view : z[0]), p(1), es(w.id);
28436
+ const U = w.state ?? {};
28437
+ d(U.scope ?? "all"), x({ ...G.current, ...U.filters ?? {} }), v(U.sort ?? ""), F(U.group_by ?? null), _t(U.columns ?? null), q(U.pins ?? null), U.view && h(z.includes(U.view) ? U.view : z[0]), p(1), es(w.id);
28438
28438
  }
28439
28439
  function Bs() {
28440
- var Q, se;
28440
+ var U, se;
28441
28441
  const w = tt == null ? void 0 : tt.data.find(($e) => $e.is_default);
28442
28442
  if (w) {
28443
28443
  An(w);
28444
28444
  return;
28445
28445
  }
28446
- d(((Q = g == null ? void 0 : g.display_config) == null ? void 0 : Q.default_scope) ?? "all"), x({ ...G.current }), v(""), F(null), _t(null), q(null), (se = g == null ? void 0 : g.display_config) != null && se.default_view && h(g.display_config.default_view), p(1), es(null);
28446
+ d(((U = g == null ? void 0 : g.display_config) == null ? void 0 : U.default_scope) ?? "all"), x({ ...G.current }), v(""), F(null), _t(null), q(null), (se = g == null ? void 0 : g.display_config) != null && se.default_view && h(g.display_config.default_view), p(1), es(null);
28447
28447
  }
28448
28448
  useEffect(() => {
28449
28449
  if (ce || !(g != null && g.display_config) || Pt === void 0 || tt === void 0) return;
28450
- const w = Pt.data.default_view_id, Q = w != null ? tt.data.find(($e) => $e.id === w) : void 0, se = tt.data.find(($e) => $e.is_default);
28451
- Q ? An(Q) : se ? An(se) : (h(g.display_config.default_view), d(g.display_config.default_scope)), I(!0);
28450
+ const w = Pt.data.default_view_id, U = w != null ? tt.data.find(($e) => $e.id === w) : void 0, se = tt.data.find(($e) => $e.is_default);
28451
+ U ? An(U) : se ? An(se) : (h(g.display_config.default_view), d(g.display_config.default_scope)), I(!0);
28452
28452
  }, [g, Pt, tt, ce]);
28453
28453
  const { isAdmin: $n } = useItemEditAuth(), Ss = $n || (g == null ? void 0 : g.owner) != null && g.owner === a, ms = useMutation({
28454
- mutationFn: ({ viewId: w, on: Q }) => r.request(patch$1(`/queues/views/${w}`, { is_default: Q })),
28454
+ mutationFn: ({ viewId: w, on: U }) => r.request(patch$1(`/queues/views/${w}`, { is_default: U })),
28455
28455
  onSuccess: () => {
28456
28456
  n.invalidateQueries({ queryKey: ["queue-views", e] }), toast.success("Queue default view updated");
28457
28457
  },
28458
28458
  onError: () => toast.error("Could not update the queue default view")
28459
- }), Ut = useMutation({
28459
+ }), Qt = useMutation({
28460
28460
  mutationFn: () => r.request(
28461
28461
  post$1(`/queues/${e}/views`, {
28462
28462
  name: Ln.trim(),
@@ -28495,34 +28495,34 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
28495
28495
  n.invalidateQueries({ queryKey: ["queue-views", e] }), toast.success("View updated");
28496
28496
  },
28497
28497
  onError: () => toast.error("Failed to update view")
28498
- }), Un = useMutation({
28498
+ }), Qn = useMutation({
28499
28499
  mutationFn: (w) => r.request(del$1(`/queues/views/${w}`)),
28500
- onSuccess: (w, Q) => {
28501
- n.invalidateQueries({ queryKey: ["queue-views", e] }), es(null), It === Q && Xt(null);
28500
+ onSuccess: (w, U) => {
28501
+ n.invalidateQueries({ queryKey: ["queue-views", e] }), es(null), It === U && Xt(null);
28502
28502
  },
28503
28503
  onError: () => toast.error("Failed to delete view")
28504
28504
  }), Gn = useMutation({
28505
28505
  mutationFn: (w) => r.request(put(`/queues/${e}/default-view`, { view_id: w })),
28506
28506
  onMutate: (w) => Xt(w),
28507
- onSuccess: (w, Q) => {
28507
+ onSuccess: (w, U) => {
28508
28508
  n.invalidateQueries({ queryKey: ["queue-column-prefs", e] }), toast.success(
28509
- Q === null ? "Reverted to the general default" : "Set as your default view"
28509
+ U === null ? "Reverted to the general default" : "Set as your default view"
28510
28510
  );
28511
28511
  },
28512
28512
  onError: () => {
28513
28513
  n.invalidateQueries({ queryKey: ["queue-column-prefs", e] }), toast.error("Failed to update default view");
28514
28514
  }
28515
28515
  }), [gs, Ks] = useState([]), [as, zs] = useState(!1);
28516
- async function gn(w, Q) {
28517
- const se = Ht.filter((dt) => gs.includes(Qe(dt)));
28516
+ async function gn(w, U) {
28517
+ const se = Ht.filter((dt) => gs.includes(Ue(dt)));
28518
28518
  zs(!0);
28519
- const $e = await Promise.allSettled(se.map(Q)), Oe = $e.filter((dt) => dt.status === "fulfilled").length, Ve = $e.length - Oe;
28519
+ const $e = await Promise.allSettled(se.map(U)), Oe = $e.filter((dt) => dt.status === "fulfilled").length, Ve = $e.length - Oe;
28520
28520
  zs(!1), Ks([]), n.invalidateQueries({ queryKey: ["queue-items", e] }), Ve ? toast.warning(`${w}: ${Oe} succeeded, ${Ve} failed`) : toast.success(`${w}: ${Oe} succeeded`);
28521
28521
  }
28522
28522
  const mn = (w) => {
28523
- var Q;
28523
+ var U;
28524
28524
  for (const se of (g == null ? void 0 : g.sources) ?? []) {
28525
- const $e = (Q = se.column_formats) == null ? void 0 : Q[w];
28525
+ const $e = (U = se.column_formats) == null ? void 0 : U[w];
28526
28526
  if ($e) return $e;
28527
28527
  }
28528
28528
  return null;
@@ -28530,8 +28530,8 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
28530
28530
  if (u === "state") return w === "No state" ? w : Bt(w);
28531
28531
  if (u === "collection") return te(w);
28532
28532
  if (u != null && u.startsWith("extra.") && w !== "—") {
28533
- const Q = mn(u.slice(6));
28534
- if (Q) return formatMultiValue(w, Q);
28533
+ const U = mn(u.slice(6));
28534
+ if (U) return formatMultiValue(w, U);
28535
28535
  }
28536
28536
  return w;
28537
28537
  }, Es = ke == null ? void 0 : ke.map((w) => ({
@@ -28628,8 +28628,8 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
28628
28628
  "button",
28629
28629
  {
28630
28630
  type: "button",
28631
- onClick: (Q) => {
28632
- Q.stopPropagation(), ht.mutate(w);
28631
+ onClick: (U) => {
28632
+ U.stopPropagation(), ht.mutate(w);
28633
28633
  },
28634
28634
  className: "text-[11px] text-slate-400 underline hover:text-slate-600",
28635
28635
  children: "Release"
@@ -28638,17 +28638,17 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
28638
28638
  "button",
28639
28639
  {
28640
28640
  type: "button",
28641
- onClick: (Q) => {
28642
- Q.stopPropagation(), ot.mutate(w);
28641
+ onClick: (U) => {
28642
+ U.stopPropagation(), ot.mutate(w);
28643
28643
  },
28644
28644
  className: "text-[11px] font-medium text-nvr-navy underline dark:text-nvr-cyan",
28645
28645
  children: "Claim"
28646
28646
  }
28647
28647
  )
28648
- }, Ds = (g == null ? void 0 : g.available_extra_fields) ?? [], Us = useOverlayState("drill.queue"), os = Us.value, Qn = (w) => Us.push([w]), Wn = (w) => {
28649
- var Q;
28648
+ }, Ds = (g == null ? void 0 : g.available_extra_fields) ?? [], Qs = useOverlayState("drill.queue"), os = Qs.value, Un = (w) => Qs.push([w]), Wn = (w) => {
28649
+ var U;
28650
28650
  for (const se of (g == null ? void 0 : g.sources) ?? []) {
28651
- const $e = (Q = se.drilldown) == null ? void 0 : Q[w];
28651
+ const $e = (U = se.drilldown) == null ? void 0 : U[w];
28652
28652
  if ($e)
28653
28653
  return {
28654
28654
  enabled: $e.enabled !== !1,
@@ -28659,19 +28659,19 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
28659
28659
  return { enabled: !0, layout_id: null, width: null };
28660
28660
  }, Xs = useMemo(() => {
28661
28661
  const w = {};
28662
- for (const Q of (g == null ? void 0 : g.sources) ?? [])
28663
- for (const [se, $e] of Object.entries(Q.column_formats ?? {}))
28662
+ for (const U of (g == null ? void 0 : g.sources) ?? [])
28663
+ for (const [se, $e] of Object.entries(U.column_formats ?? {}))
28664
28664
  se in w || (w[se] = $e);
28665
28665
  return w;
28666
28666
  }, [g == null ? void 0 : g.sources]), Zs = /^[^\s@]+@[^\s@]+\.[^\s@]+$/, Vn = /^\d{4}-\d{2}-\d{2}T\d{2}:/;
28667
28667
  function ls(w) {
28668
28668
  if (Zs.test(w)) return { text: w.split("@")[0], title: w };
28669
28669
  if (Vn.test(w)) {
28670
- const Q = new Date(w);
28671
- if (!Number.isNaN(Q.getTime()))
28670
+ const U = new Date(w);
28671
+ if (!Number.isNaN(U.getTime()))
28672
28672
  return {
28673
- text: formatDate(Q, { month: "2-digit", day: "2-digit", year: "2-digit" }),
28674
- title: formatDateTime(Q)
28673
+ text: formatDate(U, { month: "2-digit", day: "2-digit", year: "2-digit" }),
28674
+ title: formatDateTime(U)
28675
28675
  };
28676
28676
  }
28677
28677
  return { text: w, title: w };
@@ -28680,17 +28680,17 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
28680
28680
  key: `extra.${w}`,
28681
28681
  header: me(`extra.${w}`, formatColumnHeader(w)),
28682
28682
  sortable: !0,
28683
- render: (Q) => {
28683
+ render: (U) => {
28684
28684
  var Ft, Gt;
28685
- const se = (Ft = Q.extra) == null ? void 0 : Ft[w];
28685
+ const se = (Ft = U.extra) == null ? void 0 : Ft[w];
28686
28686
  if (se == null || se === "") return /* @__PURE__ */ jsx("span", { className: "text-slate-300", children: "—" });
28687
- const $e = mn(w), Oe = $e ? formatMultiValue(String(se), $e) : String(se), { text: Ve, title: dt } = ls(Oe), Nt = ((g == null ? void 0 : g.extra_field_meta) ?? []).find((ds) => ds.path === w), We = ((Gt = Q.extra_ids) == null ? void 0 : Gt[w]) ?? [], Ct = Wn(w);
28687
+ const $e = mn(w), Oe = $e ? formatMultiValue(String(se), $e) : String(se), { text: Ve, title: dt } = ls(Oe), Nt = ((g == null ? void 0 : g.extra_field_meta) ?? []).find((ds) => ds.path === w), We = ((Gt = U.extra_ids) == null ? void 0 : Gt[w]) ?? [], Ct = Wn(w);
28688
28688
  return (Nt == null ? void 0 : Nt.kind) === "relation" && Nt.target_collection && We.length > 0 && Ct.enabled && !Nt.aggregate ? /* @__PURE__ */ jsx(
28689
28689
  "button",
28690
28690
  {
28691
28691
  type: "button",
28692
28692
  onClick: (ds) => {
28693
- ds.stopPropagation(), Qn({
28693
+ ds.stopPropagation(), Un({
28694
28694
  collection: Nt.target_collection,
28695
28695
  itemId: We[0],
28696
28696
  layoutId: Ct.layout_id,
@@ -28720,14 +28720,14 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
28720
28720
  "sla_status",
28721
28721
  "at_risk",
28722
28722
  ...Ds.slice(0, 2).map((w) => `extra.${w}`)
28723
- ], Qs = (ee == null ? void 0 : ee.default_columns) ?? null, ps = st ?? Qs, en = new Set(ps ?? Os), Zt = [
28723
+ ], Us = (ee == null ? void 0 : ee.default_columns) ?? null, ps = st ?? Us, en = new Set(ps ?? Os), Zt = [
28724
28724
  ...(ps ?? []).filter((w) => vn.includes(w)),
28725
28725
  ...vn.filter((w) => !(ps ?? []).includes(w))
28726
28726
  ], Yn = useSensors(useSensor(PointerSensor, { activationConstraint: { distance: 4 } }));
28727
28727
  function qn(w) {
28728
- const { active: Q, over: se } = w;
28729
- if (!se || Q.id === se.id) return;
28730
- const $e = Zt.indexOf(String(Q.id)), Oe = Zt.indexOf(String(se.id));
28728
+ const { active: U, over: se } = w;
28729
+ if (!se || U.id === se.id) return;
28730
+ const $e = Zt.indexOf(String(U.id)), Oe = Zt.indexOf(String(se.id));
28731
28731
  $e === -1 || Oe === -1 || _t(
28732
28732
  arrayMove(Zt, $e, Oe).filter((Ve) => en.has(Ve))
28733
28733
  );
@@ -28735,7 +28735,7 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
28735
28735
  const jn = yn.find((w) => w.key === "label"), tn = [...yn, ...Cs], pn = {
28736
28736
  key: "__actions__",
28737
28737
  header: "",
28738
- render: (w) => w.collection === "tasks" ? null : /* @__PURE__ */ jsx("span", { onClick: (Q) => Q.stopPropagation(), children: /* @__PURE__ */ jsx(
28738
+ render: (w) => w.collection === "tasks" ? null : /* @__PURE__ */ jsx("span", { onClick: (U) => U.stopPropagation(), children: /* @__PURE__ */ jsx(
28739
28739
  RowActionsMenu,
28740
28740
  {
28741
28741
  collection: w.collection,
@@ -28748,7 +28748,7 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
28748
28748
  r.request(del$1(`/items/${w.collection}/${w.item_id}`)).then(() => {
28749
28749
  toast.success("Moved to trash"), n.invalidateQueries({ queryKey: ["queue-items", e] });
28750
28750
  }).catch(
28751
- (Q) => toast.error(Q instanceof Error ? Q.message : "Delete failed")
28751
+ (U) => toast.error(U instanceof Error ? U.message : "Delete failed")
28752
28752
  );
28753
28753
  },
28754
28754
  onAfterTransition: () => void n.invalidateQueries({ queryKey: ["queue-items", e] })
@@ -28756,13 +28756,13 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
28756
28756
  ) })
28757
28757
  }, xn = [
28758
28758
  jn,
28759
- ...Zt.filter((w) => en.has(w)).map((w) => tn.find((Q) => Q.key === w)).filter((w) => w !== void 0),
28759
+ ...Zt.filter((w) => en.has(w)).map((w) => tn.find((U) => U.key === w)).filter((w) => w !== void 0),
28760
28760
  ...fe ? [on] : [],
28761
28761
  pn
28762
28762
  ], sn = useMemo(() => {
28763
28763
  var $e;
28764
- const w = ee == null ? void 0 : ee.default_pins, Q = C ?? (w && Object.keys(w).length > 0 ? w : { [(($e = xn[0]) == null ? void 0 : $e.key) ?? "label"]: "left" }), se = new Set(xn.map((Oe) => Oe.key));
28765
- return Object.fromEntries(Object.entries(Q).filter(([Oe]) => se.has(Oe)));
28764
+ const w = ee == null ? void 0 : ee.default_pins, U = C ?? (w && Object.keys(w).length > 0 ? w : { [(($e = xn[0]) == null ? void 0 : $e.key) ?? "label"]: "left" }), se = new Set(xn.map((Oe) => Oe.key));
28765
+ return Object.fromEntries(Object.entries(U).filter(([Oe]) => se.has(Oe)));
28766
28766
  }, [C, ee == null ? void 0 : ee.default_pins, xn.map((w) => w.key).join("|")]), kn = [
28767
28767
  { value: "state", label: "State" },
28768
28768
  { value: "collection", label: "Collection" },
@@ -28771,13 +28771,13 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
28771
28771
  { value: "owners", label: "Owner" },
28772
28772
  { value: "aging", label: "Aging" },
28773
28773
  ...Ds.filter((w) => en.has(`extra.${w}`)).map((w) => ({ value: `extra.${w}`, label: me(`extra.${w}`, formatColumnHeader(w)) }))
28774
- ], Ps = (w) => async (Q) => {
28774
+ ], Ps = (w) => async (U) => {
28775
28775
  if (!w.target_collection || !w.display_field) return [];
28776
28776
  const se = {
28777
28777
  limit: 25,
28778
28778
  sort: w.display_field
28779
28779
  };
28780
- Q.trim() && (se.filter = JSON.stringify({ [w.display_field]: { _contains: Q.trim() } }));
28780
+ U.trim() && (se.filter = JSON.stringify({ [w.display_field]: { _contains: U.trim() } }));
28781
28781
  const Oe = (await r.request(
28782
28782
  get$1(`/items/${w.target_collection}`, se)
28783
28783
  )).data ?? [], Ve = mn(w.path), dt = K[w.path] ? new Set(K[w.path]) : null, Nt = /* @__PURE__ */ new Set(), We = [];
@@ -28788,15 +28788,15 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
28788
28788
  Nt.has(Gt) || dt && !dt.has(Gt) || (Nt.add(Gt), We.push({ label: Ve ? formatMultiValue(Gt, Ve) : Gt, value: Gt }));
28789
28789
  }
28790
28790
  return We;
28791
- }, dn = new Map(((g == null ? void 0 : g.extra_field_meta) ?? []).map((w) => [w.path, w])), wn = (w, Q) => {
28791
+ }, dn = new Map(((g == null ? void 0 : g.extra_field_meta) ?? []).map((w) => [w.path, w])), wn = (w, U) => {
28792
28792
  if (w.key.startsWith("extra.")) {
28793
28793
  const se = mn(w.key.slice(6));
28794
28794
  if (se) {
28795
- const Oe = (Array.isArray(Q) ? Q : [Q]).filter((Ve) => Ve !== "").map((Ve) => formatMultiValue(String(Ve), se));
28795
+ const Oe = (Array.isArray(U) ? U : [U]).filter((Ve) => Ve !== "").map((Ve) => formatMultiValue(String(Ve), se));
28796
28796
  return Oe.slice(0, 2).join(", ") + (Oe.length > 2 ? ` +${Oe.length - 2}` : "");
28797
28797
  }
28798
28798
  }
28799
- return filterValueDisplay(w, Q);
28799
+ return filterValueDisplay(w, U);
28800
28800
  }, $s = [
28801
28801
  {
28802
28802
  key: "collection",
@@ -28859,14 +28859,14 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
28859
28859
  },
28860
28860
  ...Ds.map((w) => {
28861
28861
  var se;
28862
- const Q = dn.get(w);
28863
- return (Q == null ? void 0 : Q.kind) === "relation" ? {
28862
+ const U = dn.get(w);
28863
+ return (U == null ? void 0 : U.kind) === "relation" ? {
28864
28864
  key: `extra.${w}`,
28865
28865
  placeholder: me(`extra.${w}`, formatColumnHeader(w)),
28866
28866
  type: "combobox",
28867
28867
  multi: !0,
28868
28868
  restricted: !!((se = K[w]) != null && se.length),
28869
- loadOptions: Ps(Q)
28869
+ loadOptions: Ps(U)
28870
28870
  } : {
28871
28871
  key: `extra.${w}`,
28872
28872
  placeholder: `Search ${me(`extra.${w}`, formatColumnHeader(w))}…`,
@@ -28875,8 +28875,8 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
28875
28875
  })
28876
28876
  ].filter((w) => en.has(w.key) || w.key === "label" || w.key === "owners");
28877
28877
  function Ts(w) {
28878
- const Q = new Set(en);
28879
- Q.has(w) ? Q.delete(w) : Q.add(w), _t([...Q]);
28878
+ const U = new Set(en);
28879
+ U.has(w) ? U.delete(w) : U.add(w), _t([...U]);
28880
28880
  }
28881
28881
  return M ? (s == null ? void 0 : s((M == null ? void 0 : M.status) ?? 500)) ?? null : /* @__PURE__ */ jsxs("div", { className: "flex flex-1 min-h-0 flex-col", children: [
28882
28882
  /* @__PURE__ */ jsxs("div", { className: "shrink-0 px-6 pt-6", children: [
@@ -28967,13 +28967,13 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
28967
28967
  }
28968
28968
  )
28969
28969
  ] }),
28970
- _s.length > 0 && /* @__PURE__ */ jsx("div", { className: "flex min-w-0 flex-wrap items-center gap-1.5", children: _s.map(([w, Q]) => {
28970
+ _s.length > 0 && /* @__PURE__ */ jsx("div", { className: "flex min-w-0 flex-wrap items-center gap-1.5", children: _s.map(([w, U]) => {
28971
28971
  var se;
28972
28972
  return /* @__PURE__ */ jsx(
28973
28973
  StateChip,
28974
28974
  {
28975
28975
  label: Bt(w),
28976
- count: Q,
28976
+ count: U,
28977
28977
  filteredCount: ie ? ie.by_state[w] ?? 0 : null,
28978
28978
  color: ((se = Vt[w]) == null ? void 0 : se.color) ?? null,
28979
28979
  active: Ne.includes(w),
@@ -28985,7 +28985,7 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
28985
28985
  ] }),
28986
28986
  /* @__PURE__ */ jsxs("div", { className: "mb-4 flex flex-wrap items-center gap-2", children: [
28987
28987
  ce ? /* @__PURE__ */ jsx("div", { className: "flex overflow-hidden rounded-md border border-slate-200 dark:border-border", children: SCOPE_TABS.filter((w) => fe || w.value !== "claimed").map(
28988
- (w, Q) => /* @__PURE__ */ jsx(
28988
+ (w, U) => /* @__PURE__ */ jsx(
28989
28989
  "button",
28990
28990
  {
28991
28991
  type: "button",
@@ -28994,7 +28994,7 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
28994
28994
  },
28995
28995
  className: cn$1(
28996
28996
  "px-3 py-1.5 text-[12px] font-medium transition-colors",
28997
- Q > 0 && "border-l border-slate-200 dark:border-border",
28997
+ U > 0 && "border-l border-slate-200 dark:border-border",
28998
28998
  o === w.value ? "bg-nvr-cyan/10 text-nvr-navy dark:text-nvr-cyan" : "bg-white text-slate-500 hover:text-slate-700 dark:bg-card dark:hover:text-foreground"
28999
28999
  ),
29000
29000
  children: w.label
@@ -29023,14 +29023,14 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
29023
29023
  { value: "table", label: "Table" },
29024
29024
  { value: "kanban", label: "Kanban" },
29025
29025
  { value: "workload", label: "Workload" }
29026
- ].filter((w) => z.includes(w.value)).map((w, Q) => /* @__PURE__ */ jsx(
29026
+ ].filter((w) => z.includes(w.value)).map((w, U) => /* @__PURE__ */ jsx(
29027
29027
  "button",
29028
29028
  {
29029
29029
  type: "button",
29030
29030
  onClick: () => h(w.value),
29031
29031
  className: cn$1(
29032
29032
  "px-3 py-1.5 text-[12px] font-medium transition-colors",
29033
- Q > 0 && "border-l border-slate-200 dark:border-border",
29033
+ U > 0 && "border-l border-slate-200 dark:border-border",
29034
29034
  m === w.value ? "bg-nvr-cyan/10 text-nvr-navy dark:text-nvr-cyan" : "bg-white text-slate-500 hover:text-slate-700 dark:bg-card dark:hover:text-foreground"
29035
29035
  ),
29036
29036
  children: w.label
@@ -29048,7 +29048,7 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
29048
29048
  ),
29049
29049
  children: [
29050
29050
  /* @__PURE__ */ jsx(Rows3, { className: "h-3.5 w-3.5" }),
29051
- u ? `Group: ${((U = kn.find((w) => w.value === u)) == null ? void 0 : U.label) ?? u}` : "Group"
29051
+ u ? `Group: ${((Q = kn.find((w) => w.value === u)) == null ? void 0 : Q.label) ?? u}` : "Group"
29052
29052
  ]
29053
29053
  }
29054
29054
  ) }),
@@ -29208,7 +29208,7 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
29208
29208
  "button",
29209
29209
  {
29210
29210
  type: "button",
29211
- onClick: () => Un.mutate(w.id),
29211
+ onClick: () => Qn.mutate(w.id),
29212
29212
  className: "hidden text-slate-400 hover:text-red-500 group-hover:inline",
29213
29213
  "aria-label": `Delete view ${w.name}`,
29214
29214
  children: "×"
@@ -29229,7 +29229,7 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
29229
29229
  ) }),
29230
29230
  /* @__PURE__ */ jsxs(PopoverContent, { className: "w-[240px] p-3", align: "end", children: [
29231
29231
  (() => {
29232
- const w = tt == null ? void 0 : tt.data.find((Q) => Q.id === us);
29232
+ const w = tt == null ? void 0 : tt.data.find((U) => U.id === us);
29233
29233
  return !w || w.user !== a && !$n ? null : /* @__PURE__ */ jsxs(
29234
29234
  "button",
29235
29235
  {
@@ -29281,8 +29281,8 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
29281
29281
  "button",
29282
29282
  {
29283
29283
  type: "button",
29284
- disabled: !Ln.trim() || Ut.isPending,
29285
- onClick: () => Ut.mutate(),
29284
+ disabled: !Ln.trim() || Qt.isPending,
29285
+ onClick: () => Qt.mutate(),
29286
29286
  className: "w-full rounded-md bg-nvr-cyan px-2 py-1.5 text-[12px] font-semibold text-white hover:bg-nvr-cyan/90 disabled:opacity-50",
29287
29287
  children: "Save current view"
29288
29288
  }
@@ -29313,12 +29313,12 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
29313
29313
  items: Zt,
29314
29314
  strategy: verticalListSortingStrategy,
29315
29315
  children: /* @__PURE__ */ jsx("div", { className: "space-y-1.5", children: Zt.map((w) => {
29316
- const Q = tn.find((se) => se.key === w);
29316
+ const U = tn.find((se) => se.key === w);
29317
29317
  return /* @__PURE__ */ jsx(
29318
29318
  SortableColumnToggle,
29319
29319
  {
29320
29320
  id: w,
29321
- label: typeof (Q == null ? void 0 : Q.header) == "string" ? Q.header : w,
29321
+ label: typeof (U == null ? void 0 : U.header) == "string" ? U.header : w,
29322
29322
  checked: en.has(w),
29323
29323
  onCheckedChange: () => Ts(w)
29324
29324
  },
@@ -29396,8 +29396,8 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
29396
29396
  ImportFromFileButton,
29397
29397
  {
29398
29398
  collection: B,
29399
- onParsed: (w, Q) => i(`/collections/${B}/new`, {
29400
- state: { importResult: w, importTemplateId: Q.id }
29399
+ onParsed: (w, U) => i(`/collections/${B}/new`, {
29400
+ state: { importResult: w, importTemplateId: U.id }
29401
29401
  })
29402
29402
  }
29403
29403
  )
@@ -29434,9 +29434,9 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
29434
29434
  type: "button",
29435
29435
  "aria-label": `Clear ${filterDefLabel(w)} filter`,
29436
29436
  onClick: () => {
29437
- x((Q) => ({
29438
- ...Q,
29439
- [w.key]: Array.isArray(Q[w.key]) ? [] : ""
29437
+ x((U) => ({
29438
+ ...U,
29439
+ [w.key]: Array.isArray(U[w.key]) ? [] : ""
29440
29440
  })), p(1);
29441
29441
  },
29442
29442
  className: "self-stretch px-1.5 text-slate-400 hover:bg-slate-100 hover:text-slate-600 dark:hover:bg-muted dark:hover:text-foreground",
@@ -29493,8 +29493,8 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
29493
29493
  def: w,
29494
29494
  layout: "stacked",
29495
29495
  value: k[w.key] ?? "",
29496
- onChange: (Q) => {
29497
- x((se) => ({ ...se, [w.key]: Q })), p(1);
29496
+ onChange: (U) => {
29497
+ x((se) => ({ ...se, [w.key]: U })), p(1);
29498
29498
  }
29499
29499
  },
29500
29500
  w.key
@@ -29522,7 +29522,7 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
29522
29522
  isLoading: mt,
29523
29523
  onPageChange: p,
29524
29524
  onRowClick: (w) => bt(w),
29525
- rowClassName: (w) => vt === Qe(w) ? (
29525
+ rowClassName: (w) => vt === Ue(w) ? (
29526
29526
  // Pinned sticky cells use bg-inherit — the highlight must be
29527
29527
  // OPAQUE (nvr-cyan/5-over-white equivalents) or horizontally
29528
29528
  // scrolled content bleeds through the pinned columns. Same
@@ -29536,8 +29536,8 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
29536
29536
  },
29537
29537
  filterDefs: $s,
29538
29538
  filterValues: k,
29539
- onFilterChange: (w, Q) => {
29540
- x((se) => ({ ...se, [w]: Q })), p(1);
29539
+ onFilterChange: (w, U) => {
29540
+ x((se) => ({ ...se, [w]: U })), p(1);
29541
29541
  },
29542
29542
  rowGroups: Es ?? void 0,
29543
29543
  collapsedGroups: y,
@@ -29547,10 +29547,10 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
29547
29547
  hideFilterRow: !0,
29548
29548
  nowrapCells: !0,
29549
29549
  columnPins: sn,
29550
- onColumnPinChange: (w, Q) => {
29550
+ onColumnPinChange: (w, U) => {
29551
29551
  q((se) => {
29552
29552
  const $e = { ...se ?? sn };
29553
- return Q ? $e[w] = Q : delete $e[w], $e;
29553
+ return U ? $e[w] = U : delete $e[w], $e;
29554
29554
  });
29555
29555
  },
29556
29556
  columnFilterRow: !0,
@@ -29565,7 +29565,7 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
29565
29565
  {
29566
29566
  items: Ht,
29567
29567
  onCardClick: (w) => bt(w),
29568
- onDrop: (w, Q) => Tt.mutate({ item: w, targetState: Q }),
29568
+ onDrop: (w, U) => Tt.mutate({ item: w, targetState: U }),
29569
29569
  onClaim: (w) => ot.mutate(w),
29570
29570
  onRelease: (w) => ht.mutate(w),
29571
29571
  swimlaneBy: f,
@@ -29602,7 +29602,7 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
29602
29602
  })
29603
29603
  )
29604
29604
  ),
29605
- onTransition: (w) => gn("Transition", (Q) => jt(Q, w)),
29605
+ onTransition: (w) => gn("Transition", (U) => jt(U, w)),
29606
29606
  onClear: () => Ks([])
29607
29607
  }
29608
29608
  ),
@@ -29616,9 +29616,9 @@ function QueueWorklist({ queueId: e, realtime: t, renderError: s }) {
29616
29616
  width: os[0].width,
29617
29617
  title: os[0].title,
29618
29618
  stack: os,
29619
- onPush: (w) => Us.push([...os, w]),
29620
- onPop: () => Us.back(),
29621
- onClose: () => Us.back(os.length)
29619
+ onPush: (w) => Qs.push([...os, w]),
29620
+ onPop: () => Qs.back(),
29621
+ onClose: () => Qs.back(os.length)
29622
29622
  }
29623
29623
  ) : null,
29624
29624
  /* @__PURE__ */ jsx(
@@ -37216,12 +37216,12 @@ function PageRenderer({ slug: e, hideHeader: t, className: s }) {
37216
37216
  }
37217
37217
  const POLL_MS = 6e4;
37218
37218
  let baseline = null, updateInfo = null;
37219
- const listeners = /* @__PURE__ */ new Set();
37219
+ const listeners$1 = /* @__PURE__ */ new Set();
37220
37220
  let pollTimer = null, checking = !1, fetcher = null, watching = !1;
37221
37221
  const emit = (e) => {
37222
37222
  if ((e == null ? void 0 : e.version) !== (updateInfo == null ? void 0 : updateInfo.version)) {
37223
37223
  updateInfo = e;
37224
- for (const t of listeners) t();
37224
+ for (const t of listeners$1) t();
37225
37225
  }
37226
37226
  };
37227
37227
  async function checkApiVersion() {
@@ -37257,7 +37257,7 @@ function getApiUpdate() {
37257
37257
  }
37258
37258
  function useApiUpdate() {
37259
37259
  return useSyncExternalStore(
37260
- (e) => (listeners.add(e), () => listeners.delete(e)),
37260
+ (e) => (listeners$1.add(e), () => listeners$1.delete(e)),
37261
37261
  getApiUpdate,
37262
37262
  getApiUpdate
37263
37263
  );
@@ -37307,6 +37307,52 @@ function ApiUpdateBanner({
37307
37307
  }
37308
37308
  );
37309
37309
  }
37310
+ const IDLE_AFTER_MS = 5 * 6e4, ACTIVITY_EVENTS = [
37311
+ "pointerdown",
37312
+ "keydown",
37313
+ "wheel",
37314
+ "touchstart",
37315
+ "scroll",
37316
+ "mousemove",
37317
+ "focus"
37318
+ ];
37319
+ let lastActivity = Date.now(), installed = !1, lastReported = null;
37320
+ const listeners = /* @__PURE__ */ new Set();
37321
+ function onIdleChange(e) {
37322
+ return listeners.add(e), () => listeners.delete(e);
37323
+ }
37324
+ function publish() {
37325
+ const e = idleState().is_idle;
37326
+ if (e !== lastReported) {
37327
+ lastReported = e;
37328
+ for (const t of listeners)
37329
+ try {
37330
+ t(e);
37331
+ } catch {
37332
+ }
37333
+ }
37334
+ }
37335
+ function trackActivity() {
37336
+ if (installed || typeof window > "u") return;
37337
+ installed = !0;
37338
+ let e = 0;
37339
+ const t = () => {
37340
+ const s = Date.now();
37341
+ s - e < 1e3 || (e = s, lastActivity = s, publish());
37342
+ };
37343
+ for (const s of ACTIVITY_EVENTS)
37344
+ window.addEventListener(s, t, { passive: !0, capture: !0 });
37345
+ document.addEventListener("visibilitychange", () => {
37346
+ document.visibilityState === "visible" ? (lastActivity = Date.now(), e = 0) : lastActivity = 0, publish();
37347
+ }), setInterval(publish, 15e3);
37348
+ }
37349
+ function idleState() {
37350
+ const e = typeof document < "u" && document.visibilityState === "hidden", t = Date.now() - lastActivity > IDLE_AFTER_MS;
37351
+ return {
37352
+ is_idle: e || t,
37353
+ last_active: new Date(lastActivity || Date.now()).toISOString()
37354
+ };
37355
+ }
37310
37356
  function BooleanField({
37311
37357
  field: e,
37312
37358
  value: t,
@@ -40605,6 +40651,7 @@ export {
40605
40651
  DrilldownContext,
40606
40652
  FileField,
40607
40653
  GridFlushContext,
40654
+ IDLE_AFTER_MS,
40608
40655
  ImportConsole,
40609
40656
  ItemEditAuthContext,
40610
40657
  ItemEditForm,
@@ -40650,12 +40697,15 @@ export {
40650
40697
  fetchSchema,
40651
40698
  getApiUpdate,
40652
40699
  getMentionQuery,
40700
+ idleState,
40653
40701
  matchScopeDimension,
40654
40702
  normalizeFieldType,
40703
+ onIdleChange,
40655
40704
  openDmWith,
40656
40705
  registerDmOpener,
40657
40706
  splitMessageTokens,
40658
40707
  startApiVersionWatch,
40708
+ trackActivity,
40659
40709
  translateScopeValues,
40660
40710
  useApiUpdate,
40661
40711
  useChatConfig,