@nivaro/react 0.3.63 → 0.3.65

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.
Files changed (64) hide show
  1. package/dist/full.css +1 -1
  2. package/dist/hooks/useSessionRecorder.js +1 -1
  3. package/dist/index.d.ts +54 -5
  4. package/dist/shared/components/CollectionBrowserView.js +3029 -2947
  5. package/dist/shared/components/ConformanceView.js +235 -221
  6. package/dist/shared/components/DataTable.js +478 -459
  7. package/dist/shared/components/ItemEditForm.js +4469 -4266
  8. package/dist/shared/components/PageRenderer.js +146 -138
  9. package/dist/shared/components/RecordDrilldownSheet.js +73 -65
  10. package/dist/shared/components/bulk/BulkActionButtons.js +72 -72
  11. package/dist/shared/components/bulk/BulkFieldUpdate.js +114 -103
  12. package/dist/shared/components/bulk/BulkFieldUpdateButton.js +73 -0
  13. package/dist/shared/components/bulk/bulk-field-options.js +29 -23
  14. package/dist/shared/components/integrations/IntegrationObligationsView.js +191 -173
  15. package/dist/shared/components/integrations/IntegrationStatusLines.js +101 -85
  16. package/dist/shared/components/integrations/RecordIntegrationPreview.js +11 -9
  17. package/dist/shared/components/integrations/SendCurrentData.js +126 -0
  18. package/dist/shared/components/item-edit/CatalogPickerField.js +1530 -1437
  19. package/dist/shared/components/item-edit/FieldRenderer.js +49 -45
  20. package/dist/shared/components/item-edit/FieldRow.js +413 -403
  21. package/dist/shared/components/item-edit/InlineTableField.js +2903 -2816
  22. package/dist/shared/components/item-edit/M2MCombobox.js +172 -168
  23. package/dist/shared/components/item-edit/MidairCollisionDialog.js +341 -114
  24. package/dist/shared/components/item-edit/NestedRelationEditor.js +171 -163
  25. package/dist/shared/components/item-edit/PlanGrid.js +783 -724
  26. package/dist/shared/components/item-edit/QuickCreateButton.js +291 -224
  27. package/dist/shared/components/item-edit/RecordInsights.js +113 -111
  28. package/dist/shared/components/item-edit/RecordLiveSync.js +4 -1
  29. package/dist/shared/components/item-edit/RelationCombobox.js +332 -314
  30. package/dist/shared/components/item-edit/cascade-clear-notice.js +52 -0
  31. package/dist/shared/components/item-edit/collision-format.js +37 -0
  32. package/dist/shared/components/item-edit/field-a11y.js +25 -0
  33. package/dist/shared/components/item-edit/line-merge.js +58 -0
  34. package/dist/shared/components/item-edit/line-midair.js +94 -87
  35. package/dist/shared/components/item-edit/move-guard.js +17 -0
  36. package/dist/shared/components/item-edit/picker-search.js +22 -15
  37. package/dist/shared/components/item-edit/rail-width.js +8 -0
  38. package/dist/shared/components/monitoring/InactiveUserLinksView.js +322 -291
  39. package/dist/shared/components/panels/AccessDeniedPanel.js +96 -55
  40. package/dist/shared/components/panels/CommentPanel.js +142 -136
  41. package/dist/shared/components/panels/ItemLockBanner.js +246 -240
  42. package/dist/shared/components/panels/PipelinePanel.js +1366 -1194
  43. package/dist/shared/components/panels/RevisionsPanel.js +106 -102
  44. package/dist/shared/components/panels/SlaBreachBanner.js +16 -20
  45. package/dist/shared/components/panels/SlaClock.js +90 -68
  46. package/dist/shared/components/queue/QueueItemSheet.js +94 -87
  47. package/dist/shared/components/queue/QueueWorklist.js +1502 -1354
  48. package/dist/shared/components/queue/worklist-csv.js +75 -0
  49. package/dist/shared/components/queue/worklist-helpers.js +20 -0
  50. package/dist/shared/components/widgets/ReviewListWidget.js +226 -207
  51. package/dist/shared/lib/bulk-copy.js +17 -0
  52. package/dist/shared/lib/cbv-export.js +122 -0
  53. package/dist/shared/lib/delete-offer.js +13 -0
  54. package/dist/shared/lib/error-hints.js +1 -0
  55. package/dist/shared/lib/leave-guard.js +41 -26
  56. package/dist/shared/lib/list-link.js +72 -56
  57. package/dist/shared/lib/live-queries.js +32 -30
  58. package/dist/shared/lib/moved-notice.js +25 -0
  59. package/dist/shared/lib/notification-target.js +56 -54
  60. package/dist/shared/lib/obligation-banner.js +11 -8
  61. package/dist/shared/lib/obligation-reason-text.js +6 -6
  62. package/dist/shared/lib/sort-cycle.js +6 -0
  63. package/dist/shared/lib/summary-mode.js +59 -41
  64. package/package.json +1 -1
@@ -1,87 +1,105 @@
1
- import { jsxs as u, jsx as s, Fragment as ve } from "react/jsx-runtime";
2
- import { useQueryClient as In, useQuery as K, useQueries as lr } from "@tanstack/react-query";
3
- import { Search as Rt, Loader2 as ce, PackageCheck as zn, ChevronRight as or, Star as it, AlertTriangle as De, AlertCircle as ar, X as Pt, Plus as Qn, ChevronDown as Bn } from "lucide-react";
4
- import { useState as H, useRef as Ee, useMemo as F, useEffect as Te, Fragment as at } from "react";
5
- import { createPortal as Vn } from "react-dom";
6
- import { useNivaroClient as Lt, useParentDraft as Wn, useReimportHandler as Dn, useItemEditAuth as Ur } from "../../context.js";
7
- import { canOpenCatalogItem as en, openCatalogItem as tn } from "../../lib/catalog-item-open.js";
8
- import { get as R, del as Mn, patch as Hr, post as Yr } from "../../lib/commands.js";
9
- import { evaluateBoolean as Un } from "../../lib/expression.js";
10
- import { useLiveRefetchInterval as Hn } from "../../lib/live-queries.js";
11
- import { tokenize as Yn, matchesSearch as Zn } from "../../lib/search-text.js";
12
- import { submissionLineErrors as Gn, normalizeIdent as Xn } from "../../lib/submission-errors.js";
13
- import { titleCase as M, cn as C, matchesAllTokens as es } from "../../lib/utils.js";
14
- import { ImportFromFileButton as ts } from "../import/ImportFromFileButton.js";
15
- import { SearchHighlight as dr } from "../SearchHighlight.js";
16
- import { useOverflowTip as rs } from "../TipLayer.js";
17
- import { useColumnWidths as Zr, ResetColumnsButton as ir, ColResizeHandle as ns, fitWidth as ss } from "./catalog-columns.js";
18
- import { orderCatalogMatches as as, rowMatchesFields as is } from "./catalog-search.js";
1
+ import { jsxs as u, jsx as a, Fragment as Se } from "react/jsx-runtime";
2
+ import { useQueryClient as Br, useQuery as C, useQueries as un } from "@tanstack/react-query";
3
+ import { Search as Et, Loader2 as ce, PackageCheck as Dr, ChevronRight as mn, Star as dt, AlertTriangle as Be, AlertCircle as dn, X as Lt, Plus as Hr, ChevronDown as Yr } from "lucide-react";
4
+ import { useState as Y, useRef as pe, useMemo as F, useEffect as xe, Fragment as ot } from "react";
5
+ import { createPortal as Zr } from "react-dom";
6
+ import { useNivaroClient as Kt, useParentDraft as Gr, useReimportHandler as Xr, useItemEditAuth as nr } from "../../context.js";
7
+ import { canOpenCatalogItem as or, openCatalogItem as dr } from "../../lib/catalog-item-open.js";
8
+ import { get as R, del as es, patch as rr, post as sr } from "../../lib/commands.js";
9
+ import { evaluateBoolean as ts } from "../../lib/expression.js";
10
+ import { useLiveRefetchInterval as ns } from "../../lib/live-queries.js";
11
+ import { tokenize as rs, matchesSearch as ss } from "../../lib/search-text.js";
12
+ import { registerStagedRowLabel as as } from "../../lib/staged-row-labels.js";
13
+ import { submissionLineErrors as is, normalizeIdent as ls } from "../../lib/submission-errors.js";
14
+ import { titleCase as D, cn as I, matchesAllTokens as os } from "../../lib/utils.js";
15
+ import { ImportFromFileButton as ds } from "../import/ImportFromFileButton.js";
16
+ import { SearchHighlight as fn } from "../SearchHighlight.js";
17
+ import { useOverflowTip as cs } from "../TipLayer.js";
18
+ import { useColumnWidths as ar, ResetColumnsButton as cn, ColResizeHandle as us, fitWidth as ms } from "./catalog-columns.js";
19
+ import { orderCatalogMatches as fs, rowMatchesFields as hs } from "./catalog-search.js";
19
20
  import { applyDisplayTemplate as ze } from "./helpers.js";
20
- import { evalClientFormula as Le } from "./InlineTableField.js";
21
- import { isIntegerFieldType as Ot, checkNumberEntry as cr, mergePendingQtyRow as ls, decimalPlacesProblem as os, lineRuleErrors as ds, MAX_LINE_MONEY as cs } from "./line-qty.js";
22
- import { resolveM2MRelatedCollection as us } from "./M2MCombobox.js";
23
- import { useO2MStaging as ms } from "./O2MStagingContext.js";
24
- import { RelationCombobox as fs, RelatedItemLabel as hs } from "./RelationCombobox.js";
25
- const rn = (d, h) => {
26
- let y = d;
27
- for (const N of h.split(".")) {
28
- if (y == null || typeof y != "object") return;
29
- y = y[N];
21
+ import { evalClientFormula as Pe } from "./InlineTableField.js";
22
+ import { isIntegerFieldType as Pt, checkNumberEntry as hn, mergePendingQtyRow as bs, decimalPlacesProblem as ps, lineRuleErrors as xs, MAX_LINE_MONEY as ys } from "./line-qty.js";
23
+ import { resolveM2MRelatedCollection as gs } from "./M2MCombobox.js";
24
+ import { useO2MStaging as ks } from "./O2MStagingContext.js";
25
+ import { RelationCombobox as ws, RelatedItemLabel as Ns } from "./RelationCombobox.js";
26
+ const cr = (i, m) => {
27
+ let b = i;
28
+ for (const x of m.split(".")) {
29
+ if (b == null || typeof b != "object") return;
30
+ b = b[x];
30
31
  }
31
- return y;
32
+ return b;
32
33
  };
33
- async function Et(d, h, y) {
34
- const N = [];
35
- for (let a = 1; a <= 50; a++) {
36
- const b = await d.request(R(h, { ...y, limit: 1e3, page: a })).then((k) => k.data ?? []);
37
- if (N.push(...b), b.length < 1e3) break;
34
+ async function At(i, m, b) {
35
+ const x = [];
36
+ for (let S = 1; S <= 50; S++) {
37
+ const s = await i.request(R(m, { ...b, limit: 1e3, page: S })).then((w) => w.data ?? []);
38
+ if (x.push(...s), s.length < 1e3) break;
38
39
  }
39
- return N;
40
+ return x;
40
41
  }
41
- function Me(d, h) {
42
- const y = {};
43
- let N = !1;
44
- const a = (b) => {
45
- if (typeof b == "string" && b.startsWith("$parent.")) {
46
- const k = h == null ? void 0 : h[b.slice(8)];
47
- return k == null || k === "" ? (N = !0, b) : k;
42
+ function vs(i, m, b, x) {
43
+ const S = {}, s = { ...x ?? {} };
44
+ for (const w of m) {
45
+ const k = i[w], j = k == null || k === "", v = !j && (x == null ? void 0 : x[w]) !== void 0 && x[w] === String(k);
46
+ if (!j && !v) continue;
47
+ const T = b(w);
48
+ T == null || T === "" || !j && String(T) === String(k) || (S[w] = T, s[w] = String(T));
49
+ }
50
+ return Object.keys(S).length > 0 ? { updates: S, auto: s } : null;
51
+ }
52
+ function bn(i, m = /* @__PURE__ */ new Set()) {
53
+ if (typeof i == "string" && i.startsWith("$parent.")) m.add(i.slice(8));
54
+ else if (Array.isArray(i)) for (const b of i) bn(b, m);
55
+ else if (i && typeof i == "object")
56
+ for (const b of Object.values(i)) bn(b, m);
57
+ return m;
58
+ }
59
+ function De(i, m) {
60
+ const b = {};
61
+ let x = !1;
62
+ const S = (s) => {
63
+ if (typeof s == "string" && s.startsWith("$parent.")) {
64
+ const w = m == null ? void 0 : m[s.slice(8)];
65
+ return w == null || w === "" ? (x = !0, s) : w;
48
66
  }
49
- return Array.isArray(b) ? b.map(a) : b && typeof b == "object" ? Object.fromEntries(Object.entries(b).map(([k, j]) => [k, a(j)])) : b;
67
+ return Array.isArray(s) ? s.map(S) : s && typeof s == "object" ? Object.fromEntries(Object.entries(s).map(([w, k]) => [w, S(k)])) : s;
50
68
  };
51
- for (const [b, k] of Object.entries(d ?? {}))
52
- if (typeof k == "string" && k.startsWith("$parent.")) {
53
- const j = h == null ? void 0 : h[k.slice(8)];
54
- if (j == null || j === "") {
55
- N = !0;
69
+ for (const [s, w] of Object.entries(i ?? {}))
70
+ if (typeof w == "string" && w.startsWith("$parent.")) {
71
+ const k = m == null ? void 0 : m[w.slice(8)];
72
+ if (k == null || k === "") {
73
+ x = !0;
56
74
  continue;
57
75
  }
58
- y[b] = { _eq: j };
59
- } else k && typeof k == "object" ? y[b] = a(k) : y[b] = { _eq: k };
60
- return N ? null : y;
76
+ b[s] = { _eq: k };
77
+ } else w && typeof w == "object" ? b[s] = S(w) : b[s] = { _eq: w };
78
+ return x ? null : b;
61
79
  }
62
- function Gr(d, h) {
63
- if (!d) return !0;
64
- for (const [y, N] of Object.entries(d)) {
65
- const a = h == null ? void 0 : h[y], b = a == null ? null : String(a), k = N && typeof N == "object" ? N : { _eq: N };
66
- for (const [j, w] of Object.entries(k))
67
- switch (j) {
80
+ function ir(i, m) {
81
+ if (!i) return !0;
82
+ for (const [b, x] of Object.entries(i)) {
83
+ const S = m == null ? void 0 : m[b], s = S == null ? null : String(S), w = x && typeof x == "object" ? x : { _eq: x };
84
+ for (const [k, j] of Object.entries(w))
85
+ switch (k) {
68
86
  case "_eq":
69
- if (b !== String(w)) return !1;
87
+ if (s !== String(j)) return !1;
70
88
  break;
71
89
  case "_neq":
72
- if (b === String(w)) return !1;
90
+ if (s === String(j)) return !1;
73
91
  break;
74
92
  case "_in":
75
- if (!Array.isArray(w) || !w.map(String).includes(b ?? "")) return !1;
93
+ if (!Array.isArray(j) || !j.map(String).includes(s ?? "")) return !1;
76
94
  break;
77
95
  case "_nin":
78
- if (Array.isArray(w) && w.map(String).includes(b ?? "")) return !1;
96
+ if (Array.isArray(j) && j.map(String).includes(s ?? "")) return !1;
79
97
  break;
80
98
  case "_null":
81
- if (b !== null) return !1;
99
+ if (s !== null) return !1;
82
100
  break;
83
101
  case "_nnull":
84
- if (b === null) return !1;
102
+ if (s === null) return !1;
85
103
  break;
86
104
  default:
87
105
  return !1;
@@ -89,78 +107,80 @@ function Gr(d, h) {
89
107
  }
90
108
  return !0;
91
109
  }
92
- const bs = 2e3;
93
- function ps(d, h) {
94
- const y = Number(d);
95
- if (Ot(h) && d.trim() !== "" && !Number.isNaN(y) && !Number.isInteger(y))
110
+ const _s = 2e3;
111
+ function Ss(i, m) {
112
+ if (/e/i.test(i.trim())) return "Type the quantity in full digits";
113
+ const b = Number(i);
114
+ if (Pt(m) && i.trim() !== "" && !Number.isNaN(b) && !Number.isInteger(b))
96
115
  return "Whole numbers only";
97
- const N = cr(d, { type: h, min: 0, label: "Quantity" });
98
- return N.ok ? null : N.message;
116
+ const x = hn(i, { type: m, min: 0, label: "Quantity" });
117
+ return x.ok ? null : x.message;
99
118
  }
100
- function xs(d, h, y) {
101
- const N = d.reduce((a, b) => {
102
- const k = b[h], j = k != null && k !== "" ? k : y != null && y[h] ? Le(y[h], b) : null, w = Number(j);
103
- return a + (j != null && Number.isFinite(w) ? w : 0);
119
+ function qs(i, m, b) {
120
+ const x = i.reduce((S, s) => {
121
+ const w = s[m], k = w != null && w !== "" ? w : b != null && b[m] ? Pe(b[m], s) : null, j = Number(k);
122
+ return S + (k != null && Number.isFinite(j) ? j : 0);
104
123
  }, 0);
105
- return Math.round(N * 1e6) / 1e6;
124
+ return Math.round(x * 1e6) / 1e6;
106
125
  }
107
- function ys(d, h) {
108
- const y = h.trim();
109
- return y ? `${d} — ${y} not used` : d;
126
+ function $s(i, m) {
127
+ const b = m.trim();
128
+ return b ? `${i} — ${b} not used` : i;
110
129
  }
111
- function gs(d) {
112
- const h = { ...d.probe };
113
- for (const [y, N] of Object.entries(d.compute)) {
114
- const a = Le(N, h);
115
- if (a === null) continue;
116
- h[y] = a;
117
- const b = d.ruleError(y, a, h);
118
- if (b) return b;
119
- if (Math.abs(a) > cs)
120
- return `${d.labelOf(y)} would be ${a.toLocaleString(void 0, { maximumFractionDigits: 2 })} — too large to save`;
130
+ function js(i) {
131
+ const m = { ...i.probe };
132
+ for (const [b, x] of Object.entries(i.compute)) {
133
+ const S = Pe(x, m);
134
+ if (S === null) continue;
135
+ m[b] = S;
136
+ const s = i.ruleError(b, S, m);
137
+ if (s) return s;
138
+ if (Math.abs(S) > ys)
139
+ return `${i.labelOf(b)} would be ${S.toLocaleString(void 0, { maximumFractionDigits: 2 })} — too large to save`;
121
140
  }
122
141
  return null;
123
142
  }
124
- function ks(d) {
125
- const h = Object.entries(d.copyFields ?? {}).filter(([, y]) => y === d.field).map(([y]) => y);
126
- for (const y of h)
127
- for (const N of d.related ?? []) {
128
- if (N.copy_to !== y) continue;
129
- const a = d.lookup(N.key);
130
- if (a != null && a !== "") return a;
143
+ function Fs(i) {
144
+ const m = Object.entries(i.copyFields ?? {}).filter(([, b]) => b === i.field).map(([b]) => b);
145
+ for (const b of m)
146
+ for (const x of i.related ?? []) {
147
+ if (x.copy_to !== b) continue;
148
+ const S = i.lookup(x.key);
149
+ if (S != null && S !== "") return S;
131
150
  }
132
- return d.catalogValue;
151
+ return i.catalogValue;
133
152
  }
134
- function ws(d, h) {
135
- return d.map((y) => [y.id, ...h.map((N) => y[N])].map((N) => String(N ?? "")).join("")).join("");
153
+ function Ts(i, m) {
154
+ return i.map((b) => [b.id, ...m.map((x) => b[x])].map((x) => String(x ?? "")).join("")).join("");
136
155
  }
137
- function Ns(d) {
138
- const h = Object.keys(d).filter((N) => d[N].kind === "error");
139
- if (h.length === 0) return d;
140
- const y = { ...d };
141
- for (const N of h) delete y[N];
142
- return y;
156
+ function Os(i) {
157
+ const m = Object.keys(i).filter((x) => i[x].kind === "error");
158
+ if (m.length === 0) return i;
159
+ const b = { ...i };
160
+ for (const x of m) delete b[x];
161
+ return b;
143
162
  }
144
- function vs(d, h, y) {
145
- const N = Number(d[h]);
146
- if (!Number.isFinite(N) || N <= 0) return !1;
147
- const a = y.find((k) => k in d);
148
- if (!a) return !1;
149
- const b = d[a];
150
- return b == null || b === "" || Number(b) === 0;
163
+ function Rs(i, m, b) {
164
+ const x = Number(i[m]);
165
+ if (!Number.isFinite(x) || x <= 0) return !1;
166
+ const S = b.find((w) => w in i);
167
+ if (!S) return !1;
168
+ const s = i[S];
169
+ return s == null || s === "" || Number(s) === 0;
151
170
  }
152
- function Gs({
153
- relatedCollection: d,
154
- manyField: h,
155
- parentId: y,
156
- parentCollection: N,
157
- config: a,
158
- readOnly: b = !1
171
+ function da({
172
+ relatedCollection: i,
173
+ manyField: m,
174
+ parentId: b,
175
+ parentCollection: x,
176
+ field: S,
177
+ config: s,
178
+ readOnly: w = !1
159
179
  }) {
160
- var Cr, Jr, Ir, zr, Qr, Br, Vr, Wr;
161
- const k = Lt(), j = In(), w = ms(), P = Wn(), ee = Dn(), Y = a.editable_fields ?? [], _e = a.catalog_locked_fields ?? [], { isAdmin: Z } = Ur(), z = y === "new", ne = N && !z ? `?parent_collection=${encodeURIComponent(N)}&parent_id=${encodeURIComponent(y)}` : "", G = a.qty_field ?? "quantity", [se, xe] = H(/* @__PURE__ */ new Set()), Oe = Ee(!1), [U, Ae] = H(""), [ye, ue] = H({}), [ie, ae] = H(/* @__PURE__ */ new Set()), [Q, X] = H({}), [Se, me] = H({}), { data: Ke = [], isPending: q } = K({
162
- queryKey: ["collection-relations", d],
163
- queryFn: () => k.request(R(`/collections/${d}`)).then((e) => {
180
+ var Un, Bn, Dn, Hn, Yn, Zn, Gn, Xn;
181
+ const k = Kt(), j = Br(), v = ks(), T = Gr(), ye = Xr(), Z = s.editable_fields ?? [], G = s.catalog_locked_fields ?? [], { isAdmin: Ae } = nr(), P = b === "new", qe = x && !P ? `?parent_collection=${encodeURIComponent(x)}&parent_id=${encodeURIComponent(b)}` : "", J = s.qty_field ?? "quantity", [fe, $e] = Y(/* @__PURE__ */ new Set()), je = pe(!1), [X, ge] = Y(""), [ke, le] = Y({}), [ie, V] = Y(/* @__PURE__ */ new Set()), [oe, de] = Y({}), [he, Ee] = Y({}), { data: $ = [], isPending: W } = C({
182
+ queryKey: ["collection-relations", i],
183
+ queryFn: () => k.request(R(`/collections/${i}`)).then((e) => {
164
184
  var t;
165
185
  return ((t = e.data) == null ? void 0 : t.relations) ?? [];
166
186
  }),
@@ -168,128 +188,128 @@ function Gs({
168
188
  }), g = F(
169
189
  () => {
170
190
  var e;
171
- return ((e = Ke.find(
172
- (t) => t.many_collection === d && t.many_field === a.item_field && !t.junction_field
191
+ return ((e = $.find(
192
+ (t) => t.many_collection === i && t.many_field === s.item_field && !t.junction_field
173
193
  )) == null ? void 0 : e.one_collection) ?? null;
174
194
  },
175
- [Ke, d, a.item_field]
176
- ), { data: L = [] } = K({
177
- queryKey: ["field-config", d, null],
178
- queryFn: () => k.request(R(`/field-config/${d}`)).then((e) => e.data ?? []),
195
+ [$, i, s.item_field]
196
+ ), { data: te = [] } = C({
197
+ queryKey: ["field-config", i, null],
198
+ queryFn: () => k.request(R(`/field-config/${i}`)).then((e) => e.data ?? []),
179
199
  staleTime: 6e4
180
- }), le = ((Cr = L.find((e) => e.field === G)) == null ? void 0 : Cr.type) ?? null, B = (e, t, r) => {
181
- var n;
182
- return ((n = ds(
183
- L.filter((l) => l.field === e).map((l) => ({
200
+ }), M = ((Un = te.find((e) => e.field === J)) == null ? void 0 : Un.type) ?? null, U = (e, t, n) => {
201
+ var r;
202
+ return ((r = xs(
203
+ te.filter((l) => l.field === e).map((l) => ({
184
204
  field: l.field,
185
- label: l.label || M(l.field),
205
+ label: l.label || D(l.field),
186
206
  type: l.type,
187
207
  validation_rules: l.validation_rules
188
208
  })),
189
209
  { [e]: t },
190
- { ...r, [e]: t }
191
- )[0]) == null ? void 0 : n.message) ?? null;
192
- }, { data: $ } = K({
210
+ { ...n, [e]: t }
211
+ )[0]) == null ? void 0 : r.message) ?? null;
212
+ }, { data: O } = C({
193
213
  queryKey: ["col-meta", g],
194
214
  queryFn: () => k.request(R(`/collections/${g}`)).then((e) => e.data),
195
215
  enabled: !!g,
196
216
  staleTime: 3e5
197
- }), J = $ == null ? void 0 : $.display_template, E = F(() => {
198
- const e = a.section_by.split(".")[0];
199
- return (($ == null ? void 0 : $.relations) ?? []).find(
217
+ }), z = O == null ? void 0 : O.display_template, L = F(() => {
218
+ const e = s.section_by.split(".")[0];
219
+ return ((O == null ? void 0 : O.relations) ?? []).find(
200
220
  (t) => t.one_collection === g && t.one_field === e && !!t.junction_field
201
221
  ) ?? null;
202
- }, [$, g, a.section_by]), oe = (E == null ? void 0 : E.many_collection) ?? null, { data: lt = [] } = K({
203
- queryKey: ["collection-relations", oe],
204
- queryFn: () => k.request(R(`/collections/${oe}`)).then((e) => {
222
+ }, [O, g, s.section_by]), Fe = (L == null ? void 0 : L.many_collection) ?? null, { data: He = [] } = C({
223
+ queryKey: ["collection-relations", Fe],
224
+ queryFn: () => k.request(R(`/collections/${Fe}`)).then((e) => {
205
225
  var t;
206
226
  return ((t = e.data) == null ? void 0 : t.relations) ?? [];
207
227
  }),
208
- enabled: !!oe,
228
+ enabled: !!Fe,
209
229
  staleTime: 10 * 6e4
210
- }), V = F(() => {
211
- if (!(E != null && E.many_field) || !oe) return null;
212
- const e = String(E.junction_field), t = lt.find(
213
- (n) => n.many_collection === oe && n.many_field === e
214
- ), r = us(t);
215
- return r ? {
216
- junction: oe,
217
- fkToItem: E.many_field,
230
+ }), d = F(() => {
231
+ if (!(L != null && L.many_field) || !Fe) return null;
232
+ const e = String(L.junction_field), t = He.find(
233
+ (r) => r.many_collection === Fe && r.many_field === e
234
+ ), n = gs(t);
235
+ return n ? {
236
+ junction: Fe,
237
+ fkToItem: L.many_field,
218
238
  fkToSection: e,
219
- target: r,
220
- labelPath: a.section_by.split(".").slice(1).join(".") || "id"
239
+ target: n,
240
+ labelPath: s.section_by.split(".").slice(1).join(".") || "id"
221
241
  } : null;
222
- }, [E, oe, lt, a.section_by]), i = P == null ? void 0 : P.draft, { resolvedFilter: S, resolvedSectionFilter: I, resolvedLinkFilter: W, missingParents: D } = F(() => {
242
+ }, [L, Fe, He, s.section_by]), N = T == null ? void 0 : T.draft, { resolvedFilter: B, resolvedSectionFilter: ne, resolvedLinkFilter: Q, missingParents: ee } = F(() => {
223
243
  const e = [], t = (o) => {
224
244
  if (typeof o == "string" && o.startsWith("$parent.")) {
225
- const p = o.slice(8), c = i == null ? void 0 : i[p];
226
- return c == null || c === "" ? (e.push(p), o) : c;
245
+ const h = o.slice(8), c = N == null ? void 0 : N[h];
246
+ return c == null || c === "" ? (e.push(h), o) : c;
227
247
  }
228
- return Array.isArray(o) ? o.map(t) : o && typeof o == "object" ? Object.fromEntries(Object.entries(o).map(([p, c]) => [p, t(c)])) : o;
229
- }, r = a.filter ? t(a.filter) : void 0, n = a.section_filter ? t(a.section_filter) : void 0, l = a.link_filter ? t(a.link_filter) : void 0;
248
+ return Array.isArray(o) ? o.map(t) : o && typeof o == "object" ? Object.fromEntries(Object.entries(o).map(([h, c]) => [h, t(c)])) : o;
249
+ }, n = s.filter ? t(s.filter) : void 0, r = s.section_filter ? t(s.section_filter) : void 0, l = s.link_filter ? t(s.link_filter) : void 0;
230
250
  return {
231
- resolvedFilter: r,
232
- resolvedSectionFilter: n,
251
+ resolvedFilter: n,
252
+ resolvedSectionFilter: r,
233
253
  resolvedLinkFilter: l,
234
254
  missingParents: [...new Set(e)]
235
255
  };
236
- }, [a.filter, a.section_filter, a.link_filter, i]), fe = F(() => {
237
- if (!E || !I && !W) return S;
256
+ }, [s.filter, s.section_filter, s.link_filter, N]), H = F(() => {
257
+ if (!L || !ne && !Q) return B;
238
258
  const e = {
239
- ...I ?? {},
240
- ...W ? { _link: W } : {}
241
- }, t = { [E.one_field]: { _some: e } };
242
- return S ? { _and: [S, t] } : t;
243
- }, [E, I, W, S]), T = F(() => {
259
+ ...ne ?? {},
260
+ ...Q ? { _link: Q } : {}
261
+ }, t = { [L.one_field]: { _some: e } };
262
+ return B ? { _and: [B, t] } : t;
263
+ }, [L, ne, Q, B]), A = F(() => {
244
264
  const e = /* @__PURE__ */ new Set(["id"]);
245
- $ && !E && e.add(a.section_by);
246
- for (const t of [...(J ?? "").matchAll(/\{\{([\w.]+)\}\}/g)]) e.add(t[1]);
247
- for (const t of Object.values(a.copy_fields ?? {})) e.add(t);
248
- for (const t of a.columns ?? []) e.add(t.field);
265
+ O && !L && e.add(s.section_by);
266
+ for (const t of [...(z ?? "").matchAll(/\{\{([\w.]+)\}\}/g)]) e.add(t[1]);
267
+ for (const t of Object.values(s.copy_fields ?? {})) e.add(t);
268
+ for (const t of s.columns ?? []) e.add(t.field);
249
269
  return [...e].join(",");
250
- }, [J, $, E, a.section_by, a.copy_fields, a.columns]), be = JSON.stringify(fe ?? null), { data: de = [], isLoading: qe } = K(
270
+ }, [z, O, L, s.section_by, s.copy_fields, s.columns]), Ke = JSON.stringify(H ?? null), { data: re = [], isLoading: pn } = C(
251
271
  {
252
- queryKey: ["catalog-picker", g, T, be],
272
+ queryKey: ["catalog-picker", g, A, Ke],
253
273
  queryFn: () => k.request(
254
274
  R(`/items/${g}`, {
255
- limit: bs,
256
- fields: T,
257
- ...fe ? { filter: JSON.stringify(fe) } : {}
275
+ limit: _s,
276
+ fields: A,
277
+ ...H ? { filter: JSON.stringify(H) } : {}
258
278
  })
259
279
  ).then((e) => e.data ?? []),
260
280
  // Wait for the catalog meta: a to-many section path both narrows this
261
281
  // read and must stay out of its `fields=`.
262
- enabled: !!g && !!$ && D.length === 0 && (!E || !!V),
282
+ enabled: !!g && !!O && ee.length === 0 && (!L || !!d),
263
283
  staleTime: 6e4
264
284
  }
265
- ), nn = JSON.stringify(I ?? null), { data: ot = [], isLoading: sn } = K({
266
- queryKey: ["catalog-sections", V == null ? void 0 : V.target, V == null ? void 0 : V.labelPath, nn],
285
+ ), ur = JSON.stringify(ne ?? null), { data: ct = [], isLoading: mr } = C({
286
+ queryKey: ["catalog-sections", d == null ? void 0 : d.target, d == null ? void 0 : d.labelPath, ur],
267
287
  queryFn: async () => {
268
- const e = V;
269
- return (await Et(k, `/items/${e.target}`, {
288
+ const e = d;
289
+ return (await At(k, `/items/${e.target}`, {
270
290
  fields: `id,${e.labelPath}`,
271
- ...I ? { filter: JSON.stringify(I) } : {}
272
- })).map((r) => ({
273
- id: String(r.id),
274
- name: String(rn(r, e.labelPath) ?? "").trim()
291
+ ...ne ? { filter: JSON.stringify(ne) } : {}
292
+ })).map((n) => ({
293
+ id: String(n.id),
294
+ name: String(cr(n, e.labelPath) ?? "").trim()
275
295
  }));
276
296
  },
277
- enabled: !!V && D.length === 0,
297
+ enabled: !!d && ee.length === 0,
278
298
  staleTime: 6e4
279
- }), Ue = F(() => ot.map((e) => e.id), [ot]), { data: ur = [], isLoading: an } = K({
299
+ }), Ye = F(() => ct.map((e) => e.id), [ct]), { data: xn = [], isLoading: fr } = C({
280
300
  queryKey: [
281
301
  "catalog-section-links",
282
- V == null ? void 0 : V.junction,
283
- Ue.join(","),
284
- JSON.stringify(W ?? null)
302
+ d == null ? void 0 : d.junction,
303
+ Ye.join(","),
304
+ JSON.stringify(Q ?? null)
285
305
  ],
286
306
  queryFn: async () => {
287
- const e = V, t = [];
288
- for (let r = 0; r < Ue.length; r += 200) {
289
- const n = Ue.slice(r, r + 200), l = await Et(k, `/items/${e.junction}`, {
307
+ const e = d, t = [];
308
+ for (let n = 0; n < Ye.length; n += 200) {
309
+ const r = Ye.slice(n, n + 200), l = await At(k, `/items/${e.junction}`, {
290
310
  fields: `${e.fkToItem},${e.fkToSection}`,
291
311
  filter: JSON.stringify(
292
- W ? { _and: [{ [e.fkToSection]: { _in: n } }, W] } : { [e.fkToSection]: { _in: n } }
312
+ Q ? { _and: [{ [e.fkToSection]: { _in: r } }, Q] } : { [e.fkToSection]: { _in: r } }
293
313
  )
294
314
  });
295
315
  for (const o of l)
@@ -297,433 +317,454 @@ function Gs({
297
317
  }
298
318
  return t;
299
319
  },
300
- enabled: !!V && Ue.length > 0,
320
+ enabled: !!d && Ye.length > 0,
301
321
  staleTime: 6e4
302
- }), mr = F(() => {
303
- const e = new Map(ot.map((r) => [r.id, r.name])), t = /* @__PURE__ */ new Map();
304
- for (const r of ur) {
305
- const n = e.get(r.section);
306
- if (!n) continue;
307
- const l = t.get(r.item) ?? [];
308
- l.includes(n) || l.push(n), t.set(r.item, l);
322
+ }), yn = F(() => {
323
+ const e = new Map(ct.map((n) => [n.id, n.name])), t = /* @__PURE__ */ new Map();
324
+ for (const n of xn) {
325
+ const r = e.get(n.section);
326
+ if (!r) continue;
327
+ const l = t.get(n.item) ?? [];
328
+ l.includes(r) || l.push(r), t.set(n.item, l);
309
329
  }
310
330
  return t;
311
- }, [ot, ur]), dt = !!E && (!V || sn || Ue.length > 0 && an), ct = F(() => {
331
+ }, [ct, xn]), ut = !!L && (!d || mr || Ye.length > 0 && fr), mt = F(() => {
312
332
  const e = /* @__PURE__ */ new Map();
313
- for (const t of de) e.set(String(t.id), t);
333
+ for (const t of re) e.set(String(t.id), t);
314
334
  return e;
315
- }, [de]), { data: ge = [] } = K({
316
- queryKey: ["o2m-rows", d, h, y],
335
+ }, [re]), { data: me = [] } = C({
336
+ queryKey: ["o2m-rows", i, m, b],
317
337
  queryFn: () => k.request(
318
- R(`/items/${d}`, {
319
- filter: JSON.stringify({ [h]: { _eq: y } }),
338
+ R(`/items/${i}`, {
339
+ filter: JSON.stringify({ [m]: { _eq: b } }),
320
340
  limit: 1e3
321
341
  })
322
342
  ).then((e) => e.data ?? []),
323
- enabled: !z,
343
+ enabled: !P,
324
344
  staleTime: 15e3
325
- }), At = F(
326
- () => ws(ge, [
327
- a.item_field,
328
- G,
329
- ...Y,
330
- ...Object.keys(a.compute_fields ?? {})
345
+ }), Ct = F(
346
+ () => Ts(me, [
347
+ s.item_field,
348
+ J,
349
+ ...Z,
350
+ ...Object.keys(s.compute_fields ?? {})
331
351
  ]),
332
- [ge, a.item_field, G, Y, a.compute_fields]
333
- ), fr = Ee(null), Kt = Ee(Q);
334
- Kt.current = Q, Te(() => {
335
- const e = fr.current;
336
- if (fr.current = At, e === null || e === At) return;
337
- const t = Object.keys(Kt.current).filter(
338
- (r) => Kt.current[r].kind === "error"
352
+ [me, s.item_field, J, Z, s.compute_fields]
353
+ ), gn = pe(null), Jt = pe(oe);
354
+ Jt.current = oe, xe(() => {
355
+ const e = gn.current;
356
+ if (gn.current = Ct, e === null || e === Ct) return;
357
+ const t = Object.keys(Jt.current).filter(
358
+ (n) => Jt.current[n].kind === "error"
339
359
  );
340
- X((r) => Ns(r)), me((r) => Object.keys(r).length === 0 ? r : {}), t.length > 0 && ue((r) => {
341
- if (!t.some((l) => l in r)) return r;
342
- const n = { ...r };
343
- for (const l of t) delete n[l];
344
- return n;
360
+ de((n) => Os(n)), Ee((n) => Object.keys(n).length === 0 ? n : {}), t.length > 0 && le((n) => {
361
+ if (!t.some((l) => l in n)) return n;
362
+ const r = { ...n };
363
+ for (const l of t) delete r[l];
364
+ return r;
345
365
  });
346
- }, [At]);
347
- const He = !z && !!w, Re = w ? w.getPendingRows(d, h) : [], ut = He ? w.getPendingEdits(d, h) : /* @__PURE__ */ new Map(), ln = JSON.stringify([...ut.entries()]), mt = F(
348
- () => ut.size === 0 ? ge : ge.map((e) => {
349
- const t = ut.get(String(e.id));
366
+ }, [Ct]);
367
+ const Ze = !P && !!v, we = v ? v.getPendingRows(i, m) : [], ft = Ze ? v.getPendingEdits(i, m) : /* @__PURE__ */ new Map(), hr = JSON.stringify([...ft.entries()]), ht = F(
368
+ () => ft.size === 0 ? me : me.map((e) => {
369
+ const t = ft.get(String(e.id));
350
370
  return t ? { ...e, ...t } : e;
351
371
  }),
352
- [ge, ln]
353
- ), ft = !z && w ? w.getPendingDeletes(d, h) : /* @__PURE__ */ new Set(), Ye = F(() => {
372
+ [me, hr]
373
+ ), bt = !P && v ? v.getPendingDeletes(i, m) : /* @__PURE__ */ new Set(), Ge = F(() => {
354
374
  const e = /* @__PURE__ */ new Map();
355
- for (const t of mt) {
356
- const r = t[a.item_field];
357
- r != null && e.set(String(r), t);
375
+ for (const t of ht) {
376
+ const n = t[s.item_field];
377
+ n != null && e.set(String(n), t);
358
378
  }
359
379
  return e;
360
- }, [mt, a.item_field]), ht = F(() => {
380
+ }, [ht, s.item_field]), pt = F(() => {
361
381
  const e = /* @__PURE__ */ new Map();
362
- return Re.forEach((t, r) => {
363
- const n = t[a.item_field];
364
- n != null && e.set(String(n), r);
382
+ return we.forEach((t, n) => {
383
+ const r = t[s.item_field];
384
+ r != null && e.set(String(r), n);
365
385
  }), e;
366
- }, [Re, a.item_field]), pe = F(() => {
367
- const e = Re.filter((n) => n[a.item_field] != null).map((n) => ({ key: String(n[a.item_field]), row: n }));
368
- if (z) return e;
369
- const t = mt.filter((n) => n[a.item_field] != null).map((n) => ({ key: String(n[a.item_field]), row: n })), r = new Set(t.map((n) => n.key));
370
- return [...t, ...e.filter((n) => !r.has(n.key))];
371
- }, [z, Re, mt, a.item_field]), bt = F(
372
- () => pe.filter((e) => !ct.has(e.key)).map((e) => e.key),
373
- [pe, ct]
374
- ), { data: hr = [] } = K({
375
- queryKey: ["catalog-picker-labels", g, T, bt.join(",")],
386
+ }, [we, s.item_field]), be = F(() => {
387
+ const e = we.filter((r) => r[s.item_field] != null).map((r) => ({ key: String(r[s.item_field]), row: r }));
388
+ if (P) return e;
389
+ const t = ht.filter((r) => r[s.item_field] != null).map((r) => ({ key: String(r[s.item_field]), row: r })), n = new Set(t.map((r) => r.key));
390
+ return [...t, ...e.filter((r) => !n.has(r.key))];
391
+ }, [P, we, ht, s.item_field]), xt = F(
392
+ () => be.filter((e) => !mt.has(e.key)).map((e) => e.key),
393
+ [be, mt]
394
+ ), { data: It = [] } = C({
395
+ queryKey: ["catalog-picker-labels", g, A, xt.join(",")],
376
396
  queryFn: () => k.request(
377
397
  R(`/items/${g}`, {
378
- filter: JSON.stringify({ id: { _in: bt } }),
379
- fields: T,
380
- limit: bt.length
398
+ filter: JSON.stringify({ id: { _in: xt } }),
399
+ fields: A,
400
+ limit: xt.length
381
401
  })
382
402
  ).then((e) => e.data ?? []),
383
- enabled: !!g && bt.length > 0,
403
+ enabled: !!g && xt.length > 0,
384
404
  staleTime: 6e4
385
- }), { data: $e = [] } = K({
405
+ }), { data: Te = [] } = C({
386
406
  queryKey: ["pinned-items", g],
387
407
  queryFn: () => k.request(R(`/pinned/${g}`)).then((e) => e.data ?? []),
388
- enabled: !!g && !!a.favorites,
408
+ enabled: !!g && !!s.favorites,
389
409
  staleTime: 6e4
390
- }), Ct = F(() => new Set($e), [$e]), { data: Ze = [] } = K({
391
- queryKey: ["pinned-item-rows", g, T, $e.join(",")],
410
+ }), zt = F(() => new Set(Te), [Te]), { data: Xe = [] } = C({
411
+ queryKey: ["pinned-item-rows", g, A, Te.join(",")],
392
412
  queryFn: () => k.request(
393
413
  R(`/items/${g}`, {
394
- filter: JSON.stringify({ id: { _in: $e } }),
395
- fields: T,
396
- limit: $e.length
414
+ filter: JSON.stringify({ id: { _in: Te } }),
415
+ fields: A,
416
+ limit: Te.length
397
417
  })
398
418
  ).then((e) => e.data ?? []),
399
- enabled: !!g && !!a.favorites && $e.length > 0,
419
+ enabled: !!g && !!s.favorites && Te.length > 0,
400
420
  staleTime: 6e4
401
- }), [pt, br] = H(/* @__PURE__ */ new Set());
402
- async function pr(e) {
403
- if (!(!g || pt.has(e))) {
404
- br((t) => new Set(t).add(e));
421
+ }), [yt, kn] = Y(/* @__PURE__ */ new Set());
422
+ async function wn(e) {
423
+ if (!(!g || yt.has(e))) {
424
+ kn((t) => new Set(t).add(e));
405
425
  try {
406
- await k.request(Yr(`/pinned/${g}/${e}/toggle`)).catch(() => {
426
+ await k.request(sr(`/pinned/${g}/${e}/toggle`)).catch(() => {
407
427
  }), await j.invalidateQueries({ queryKey: ["pinned-items", g] });
408
428
  } finally {
409
- br((t) => {
410
- const r = new Set(t);
411
- return r.delete(e), r;
429
+ kn((t) => {
430
+ const n = new Set(t);
431
+ return n.delete(e), n;
412
432
  });
413
433
  }
414
434
  }
415
435
  }
416
- const [on, xr] = H(!1), yr = Ee(null), Jt = (e) => a.favorites ? /* @__PURE__ */ s(
436
+ const [br, Nn] = Y(!1), vn = pe(null), Qt = (e) => s.favorites ? /* @__PURE__ */ a(
417
437
  "button",
418
438
  {
419
439
  type: "button",
420
- title: Ct.has(e) ? "Remove from favorites" : "Add to favorites",
421
- disabled: pt.has(e),
440
+ title: zt.has(e) ? "Remove from favorites" : "Add to favorites",
441
+ disabled: yt.has(e),
422
442
  onClick: (t) => {
423
- t.stopPropagation(), pr(e);
443
+ t.stopPropagation(), wn(e);
424
444
  },
425
445
  className: "shrink-0 rounded p-0.5 transition-colors",
426
- children: pt.has(e) ? /* @__PURE__ */ s(ce, { className: "h-3.5 w-3.5 animate-spin text-amber-400" }) : /* @__PURE__ */ s(
427
- it,
446
+ children: yt.has(e) ? /* @__PURE__ */ a(ce, { className: "h-3.5 w-3.5 animate-spin text-amber-400" }) : /* @__PURE__ */ a(
447
+ dt,
428
448
  {
429
- className: C(
449
+ className: I(
430
450
  "h-3.5 w-3.5",
431
- Ct.has(e) ? "fill-amber-400 text-amber-400" : "text-slate-300 hover:text-amber-400"
451
+ zt.has(e) ? "fill-amber-400 text-amber-400" : "text-slate-300 hover:text-amber-400"
432
452
  )
433
453
  }
434
454
  )
435
455
  }
436
- ) : null, [he, dn] = H("");
437
- Te(() => {
438
- const e = setTimeout(() => dn(U), 300);
456
+ ) : null, [ue, pr] = Y("");
457
+ xe(() => {
458
+ const e = setTimeout(() => pr(X), 300);
439
459
  return () => clearTimeout(e);
440
- }, [U]);
441
- const gr = F(() => {
460
+ }, [X]);
461
+ const _n = F(() => {
442
462
  var t;
443
- const e = (t = [...(J ?? "").matchAll(/\{\{([\w.]+)\}\}/g)][0]) == null ? void 0 : t[1];
463
+ const e = (t = [...(z ?? "").matchAll(/\{\{([\w.]+)\}\}/g)][0]) == null ? void 0 : t[1];
444
464
  return e && !e.includes(".") ? e : "id";
445
- }, [J]), { shownSearchFields: Ce, otherSearchFields: kr } = F(() => {
465
+ }, [z]), { shownSearchFields: Ce, otherSearchFields: Sn } = F(() => {
446
466
  const e = new Set(
447
- (($ == null ? void 0 : $.relations) ?? []).filter((n) => n.one_collection === g && n.one_field).map((n) => n.one_field)
467
+ ((O == null ? void 0 : O.relations) ?? []).filter((r) => r.one_collection === g && r.one_field).map((r) => r.one_field)
448
468
  ), t = new Set(
449
- (($ == null ? void 0 : $.fields) ?? []).filter((n) => (n.type === "string" || n.type === "text") && !e.has(n.field)).map((n) => n.field)
450
- ), r = /* @__PURE__ */ new Set();
451
- for (const n of (J ?? "").matchAll(/\{\{([\w.]+)\}\}/g)) t.has(n[1]) && r.add(n[1]);
452
- for (const n of a.columns ?? []) t.has(n.field) && r.add(n.field);
469
+ ((O == null ? void 0 : O.fields) ?? []).filter((r) => (r.type === "string" || r.type === "text") && !e.has(r.field)).map((r) => r.field)
470
+ ), n = /* @__PURE__ */ new Set();
471
+ for (const r of (z ?? "").matchAll(/\{\{([\w.]+)\}\}/g)) t.has(r[1]) && n.add(r[1]);
472
+ for (const r of s.columns ?? []) t.has(r.field) && n.add(r.field);
453
473
  return {
454
- shownSearchFields: [...r],
455
- otherSearchFields: [...t].filter((n) => !r.has(n))
474
+ shownSearchFields: [...n],
475
+ otherSearchFields: [...t].filter((r) => !n.has(r))
456
476
  };
457
- }, [$, g, J, a.columns]), Ge = F(() => {
458
- const e = a.related_columns ?? [], t = e.findIndex((r) => r.stock === !0);
459
- return t !== -1 ? t : e.findIndex((r) => r.key === "on_hand" && r.stock !== !1);
460
- }, [a.related_columns]), te = Ge === -1 ? null : (a.related_columns ?? [])[Ge] ?? null, je = te ? Me(te.match, i) : null, Je = F(() => {
461
- for (const e of Object.values((te == null ? void 0 : te.match) ?? {}))
477
+ }, [O, g, z, s.columns]), et = F(() => {
478
+ const e = s.related_columns ?? [], t = e.findIndex((n) => n.stock === !0);
479
+ return t !== -1 ? t : e.findIndex((n) => n.key === "on_hand" && n.stock !== !1);
480
+ }, [s.related_columns]), se = et === -1 ? null : (s.related_columns ?? [])[et] ?? null, Oe = se ? De(se.match, N) : null, Je = F(() => {
481
+ for (const e of Object.values((se == null ? void 0 : se.match) ?? {}))
462
482
  if (typeof e == "string" && e.startsWith("$parent.")) return e.slice(8);
463
483
  return null;
464
- }, [te]), wr = Je ? i == null ? void 0 : i[Je] : null, cn = Je ? ((Jr = P == null ? void 0 : P.fieldLabels) == null ? void 0 : Jr[Je]) ?? M(Je) : null, Qe = g ? `nvr:catalog-in-stock:${g}:${d}.${h}` : null, [Nr, vr] = H(!1);
465
- Te(() => {
484
+ }, [se]), qn = Je ? N == null ? void 0 : N[Je] : null, xr = Je ? ((Bn = T == null ? void 0 : T.fieldLabels) == null ? void 0 : Bn[Je]) ?? D(Je) : null, Qe = g ? `nvr:catalog-in-stock:${g}:${i}.${m}` : null, [$n, jn] = Y(!1);
485
+ xe(() => {
466
486
  if (Qe)
467
487
  try {
468
- vr(localStorage.getItem(Qe) === "1");
488
+ jn(localStorage.getItem(Qe) === "1");
469
489
  } catch {
470
490
  }
471
491
  }, [Qe]);
472
- const It = (e) => {
473
- if (vr(e), !!Qe)
492
+ const Vt = (e) => {
493
+ if (jn(e), !!Qe)
474
494
  try {
475
495
  e ? localStorage.setItem(Qe, "1") : localStorage.removeItem(Qe);
476
496
  } catch {
477
497
  }
478
- }, re = !!te && Nr && je !== null, zt = F(() => {
479
- if (!te) return null;
480
- const e = (($ == null ? void 0 : $.relations) ?? []).find(
481
- (t) => t.many_collection === te.collection && t.many_field === te.item_field && t.one_collection === g && !!t.one_field && !t.junction_field
498
+ }, ae = !!se && $n && Oe !== null, Wt = F(() => {
499
+ if (!se) return null;
500
+ const e = ((O == null ? void 0 : O.relations) ?? []).find(
501
+ (t) => t.many_collection === se.collection && t.many_field === se.item_field && t.one_collection === g && !!t.one_field && !t.junction_field
482
502
  );
483
503
  return (e == null ? void 0 : e.one_field) ?? null;
484
- }, [te, $, g]), Qt = F(
485
- () => re && zt && te && je ? { [zt]: { _some: { ...je, [te.value_field]: { _gt: 0 } } } } : null,
486
- [re, zt, te, je]
487
- ), Bt = JSON.stringify(Qt), xt = re && !Qt ? 100 : 25, Vt = (e, t) => {
488
- const r = [t, Qt].filter(Boolean);
489
- return r.length === 0 ? e : { ...e, filter: JSON.stringify(r.length === 1 ? r[0] : { _and: r }) };
490
- }, Wt = Ur().userId, yt = a.recent === !1 ? 0 : typeof a.recent == "object" && Number((Ir = a.recent) == null ? void 0 : Ir.days) || 30, Dt = ["user_created", "created_by", "creator"].find(
491
- (e) => L.some((t) => t.field === e)
492
- ), Xe = ["date_created", "created_at"].find(
493
- (e) => L.some((t) => t.field === e)
494
- ), { data: et = [] } = K({
504
+ }, [se, O, g]), Mt = F(
505
+ () => ae && Wt && se && Oe ? { [Wt]: { _some: { ...Oe, [se.value_field]: { _gt: 0 } } } } : null,
506
+ [ae, Wt, se, Oe]
507
+ ), Ut = JSON.stringify(Mt), gt = ae && !Mt ? 100 : 25, Bt = (e, t) => {
508
+ const n = [t, Mt].filter(Boolean);
509
+ return n.length === 0 ? e : { ...e, filter: JSON.stringify(n.length === 1 ? n[0] : { _and: n }) };
510
+ }, Dt = nr().userId, kt = s.recent === !1 ? 0 : typeof s.recent == "object" && Number((Dn = s.recent) == null ? void 0 : Dn.days) || 30, Ht = ["user_created", "created_by", "creator"].find(
511
+ (e) => te.some((t) => t.field === e)
512
+ ), tt = ["date_created", "created_at"].find(
513
+ (e) => te.some((t) => t.field === e)
514
+ ), { data: nt = [] } = C({
495
515
  queryKey: [
496
516
  "catalog-recent-picks",
497
- d,
498
- a.item_field,
499
- Wt,
517
+ i,
518
+ s.item_field,
500
519
  Dt,
501
- Xe,
502
- yt
520
+ Ht,
521
+ tt,
522
+ kt
503
523
  ],
504
524
  queryFn: async () => {
505
- const e = new Date(Date.now() - yt * 864e5).toISOString(), t = { [Dt]: { _eq: Wt } };
506
- Xe && (t[Xe] = { _gte: e });
507
- const r = await k.request(
508
- R(`/items/${d}`, {
509
- fields: a.item_field,
525
+ const e = new Date(Date.now() - kt * 864e5).toISOString(), t = { [Ht]: { _eq: Dt } };
526
+ tt && (t[tt] = { _gte: e });
527
+ const n = await k.request(
528
+ R(`/items/${i}`, {
529
+ fields: s.item_field,
510
530
  filter: JSON.stringify(t),
511
531
  limit: 500,
512
532
  count: "false",
513
- ...Xe ? { sort: `-${Xe}` } : {}
533
+ ...tt ? { sort: `-${tt}` } : {}
514
534
  })
515
- ).then((l) => l.data ?? []).catch(() => []), n = [];
516
- for (const l of r) {
517
- const o = l[a.item_field], p = o != null && typeof o == "object" ? o.id : o;
518
- if (p != null && p !== "" && !n.includes(String(p)) && n.push(String(p)), n.length >= 150) break;
535
+ ).then((l) => l.data ?? []).catch(() => []), r = [];
536
+ for (const l of n) {
537
+ const o = l[s.item_field], h = o != null && typeof o == "object" ? o.id : o;
538
+ if (h != null && h !== "" && !r.includes(String(h)) && r.push(String(h)), r.length >= 150) break;
519
539
  }
520
- return n;
540
+ return r;
521
541
  },
522
- enabled: yt > 0 && !!Wt && !!Dt && !b,
542
+ enabled: kt > 0 && !!Dt && !!Ht && !w,
523
543
  staleTime: 5 * 6e4
524
- }), un = F(() => new Set(et), [et]), Mt = !!g && he.trim().length > 0, { data: Ut = [], isFetching: mn } = K({
544
+ }), yr = F(() => new Set(nt), [nt]), Yt = !!g && ue.trim().length > 0, { data: Zt = [], isFetching: gr } = C({
525
545
  queryKey: [
526
546
  "catalog-shown-search",
527
547
  g,
528
- T,
529
- he,
548
+ A,
549
+ ue,
530
550
  Ce,
531
- Bt,
532
- xt
551
+ Ut,
552
+ gt
533
553
  ],
534
554
  queryFn: () => k.request(
535
555
  R(
536
556
  `/items/${g}`,
537
- Vt({
538
- search: he,
557
+ Bt({
558
+ search: ue,
539
559
  search_fields: Ce.join(","),
540
560
  search_rank: "1",
541
- fields: T,
542
- limit: xt,
543
- sort: gr
561
+ fields: A,
562
+ limit: gt,
563
+ sort: _n
544
564
  })
545
565
  )
546
566
  ).then((e) => e.data ?? []),
547
- enabled: Mt && Ce.length > 0,
567
+ enabled: Yt && Ce.length > 0,
548
568
  staleTime: 3e4,
549
569
  placeholderData: (e) => e
550
- }), gt = kr.join(","), { data: _r = [], isFetching: fn } = K({
570
+ }), wt = Sn.join(","), { data: Fn = [], isFetching: kr } = C({
551
571
  queryKey: [
552
572
  "catalog-full-search",
553
573
  g,
554
- T,
555
- he,
556
- gt,
557
- Bt,
558
- xt
574
+ A,
575
+ ue,
576
+ wt,
577
+ Ut,
578
+ gt
559
579
  ],
560
580
  queryFn: () => k.request(
561
581
  R(
562
582
  `/items/${g}`,
563
- Vt({
564
- search: he,
565
- fields: [T, gt].filter(Boolean).join(","),
566
- limit: xt,
567
- sort: gr
583
+ Bt({
584
+ search: ue,
585
+ fields: [A, wt].filter(Boolean).join(","),
586
+ limit: gt,
587
+ sort: _n
568
588
  })
569
589
  )
570
590
  ).then((e) => e.data ?? []),
571
- enabled: Mt,
591
+ enabled: Yt,
572
592
  staleTime: 3e4,
573
593
  placeholderData: (e) => e
574
- }), hn = et.join(","), { data: Sr = [] } = K({
594
+ }), wr = nt.join(","), { data: Tn = [] } = C({
575
595
  queryKey: [
576
596
  "catalog-recent-search",
577
597
  g,
578
- T,
579
- he,
580
- gt,
581
- hn,
582
- Bt
598
+ A,
599
+ ue,
600
+ wt,
601
+ wr,
602
+ Ut
583
603
  ],
584
604
  queryFn: () => k.request(
585
605
  R(
586
606
  `/items/${g}`,
587
- Vt(
607
+ Bt(
588
608
  {
589
- search: he,
590
- fields: [T, gt].filter(Boolean).join(","),
609
+ search: ue,
610
+ fields: [A, wt].filter(Boolean).join(","),
591
611
  limit: 10,
592
612
  count: "false"
593
613
  },
594
- { id: { _in: et } }
614
+ { id: { _in: nt } }
595
615
  )
596
616
  )
597
617
  ).then((e) => e.data ?? []).catch(() => []),
598
- enabled: Mt && et.length > 0,
618
+ enabled: Yt && nt.length > 0,
599
619
  staleTime: 3e4,
600
620
  placeholderData: (e) => e
601
- }), Ht = mn || fn, Be = F(
602
- () => as({
603
- shown: Ut,
604
- other: _r,
605
- recent: Sr,
621
+ }), Gt = gr || kr, Ve = F(
622
+ () => fs({
623
+ shown: Zt,
624
+ other: Fn,
625
+ recent: Tn,
606
626
  shownFields: Ce,
607
- q: he
627
+ q: ue
608
628
  }),
609
- [Ut, _r, Sr, Ce, he]
610
- ), bn = (e) => {
611
- if (Ce.length === 0 || Ut.some((r) => String(r.id) === String(e.id)) || is(e, Ce, he)) return null;
612
- const t = Yn(he);
613
- for (const r of kr) {
614
- const n = e[r];
615
- if (n == null || typeof n == "object") continue;
616
- const l = String(n);
617
- if (t.some((o) => Zn(l, o)))
618
- return `${M(r)}: ${l.length > 40 ? `${l.slice(0, 40)}…` : l}`;
629
+ [Zt, Fn, Tn, Ce, ue]
630
+ ), Nr = (e) => {
631
+ if (Ce.length === 0 || Zt.some((n) => String(n.id) === String(e.id)) || hs(e, Ce, ue)) return null;
632
+ const t = rs(ue);
633
+ for (const n of Sn) {
634
+ const r = e[n];
635
+ if (r == null || typeof r == "object") continue;
636
+ const l = String(r);
637
+ if (t.some((o) => ss(l, o)))
638
+ return `${D(n)}: ${l.length > 40 ? `${l.slice(0, 40)}…` : l}`;
619
639
  }
620
640
  return null;
621
- }, kt = F(() => {
641
+ }, We = F(() => {
622
642
  const e = /* @__PURE__ */ new Set();
623
- for (const t of de) e.add(String(t.id));
624
- for (const t of pe) e.add(t.key);
625
- for (const t of $e) e.add(t);
626
- for (const t of Be) e.add(String(t.id));
643
+ for (const t of re) e.add(String(t.id));
644
+ for (const t of be) e.add(t.key);
645
+ for (const t of Te) e.add(t);
646
+ for (const t of Ve) e.add(String(t.id));
627
647
  return [...e];
628
- }, [de, pe, $e, Be]), wt = lr({
629
- queries: (a.related_columns ?? []).map((e) => {
630
- const t = Me(e.match, i);
648
+ }, [re, be, Te, Ve]), rt = un({
649
+ queries: (s.related_columns ?? []).map((e) => {
650
+ const t = De(e.match, N);
631
651
  return {
632
652
  queryKey: [
633
653
  "catalog-related",
634
654
  e.key,
635
655
  e.collection,
636
656
  JSON.stringify(t),
637
- kt.join(",")
657
+ We.join(",")
638
658
  ],
639
659
  queryFn: async () => {
640
- const r = {}, n = e.aggregate === "sum", l = n ? 150 : 400;
641
- for (let o = 0; o < kt.length; o += l) {
642
- const p = kt.slice(o, o + l);
660
+ const n = {};
661
+ if (e.count_all && e.aggregate === "sum" && x && S) {
662
+ const o = {};
663
+ if (P)
664
+ for (const h of bn(e.match))
665
+ o[h] = (N == null ? void 0 : N[h]) ?? null;
666
+ for (let h = 0; h < We.length; h += 200) {
667
+ const c = We.slice(h, h + 200), f = await k.request(
668
+ R("/catalog-related/count-all", {
669
+ collection: x,
670
+ field: S,
671
+ key: e.key,
672
+ record: P ? "new" : b,
673
+ ...P ? { parent: JSON.stringify(o) } : {},
674
+ ids: c.join(",")
675
+ })
676
+ );
677
+ Object.assign(n, f.data ?? {});
678
+ }
679
+ return n;
680
+ }
681
+ const r = e.aggregate === "sum", l = r ? 150 : 400;
682
+ for (let o = 0; o < We.length; o += l) {
683
+ const h = We.slice(o, o + l);
643
684
  let c = 1;
644
685
  for (; ; ) {
645
- const m = await k.request(
686
+ const f = await k.request(
646
687
  R(`/items/${e.collection}`, {
647
- limit: n ? 1e3 : p.length,
648
- ...n ? { page: c } : {},
688
+ limit: r ? 1e3 : h.length,
689
+ ...r ? { page: c } : {},
649
690
  fields: `${e.item_field},${e.value_field}`,
650
- filter: JSON.stringify({ ...t, [e.item_field]: { _in: p } })
691
+ filter: JSON.stringify({ ...t, [e.item_field]: { _in: h } })
651
692
  })
652
- ).then((f) => f.data ?? []);
653
- for (const f of m) {
654
- const v = f[e.item_field];
655
- if (v != null)
656
- if (n) {
657
- const _ = Number(f[e.value_field]);
658
- r[String(v)] = (Number(r[String(v)]) || 0) + (Number.isNaN(_) ? 0 : _);
693
+ ).then((p) => p.data ?? []);
694
+ for (const p of f) {
695
+ const _ = p[e.item_field];
696
+ if (_ != null)
697
+ if (r) {
698
+ const q = Number(p[e.value_field]);
699
+ n[String(_)] = (Number(n[String(_)]) || 0) + (Number.isNaN(q) ? 0 : q);
659
700
  } else
660
- r[String(v)] = f[e.value_field];
701
+ n[String(_)] = p[e.value_field];
661
702
  }
662
- if (!n || m.length < 1e3) break;
703
+ if (!r || f.length < 1e3) break;
663
704
  c += 1;
664
705
  }
665
706
  }
666
- return r;
707
+ return n;
667
708
  },
668
- enabled: !!g && t !== null && kt.length > 0,
709
+ enabled: !!g && t !== null && We.length > 0,
669
710
  staleTime: 3e4
670
711
  };
671
712
  })
672
- }), tt = (e, t) => {
673
- var n, l;
674
- const r = (a.related_columns ?? []).findIndex((o) => o.key === e);
675
- if (r !== -1)
676
- return (l = (n = wt[r]) == null ? void 0 : n.data) == null ? void 0 : l[t];
677
- }, rt = Ge === -1 || (zr = wt[Ge]) == null ? void 0 : zr.data, pn = re && !!((Qr = wt[Ge]) != null && Qr.isFetching), qr = (e) => {
678
- if (!re || rt === void 0) return !0;
679
- const t = Number(rt[e]);
713
+ }), st = (e, t) => {
714
+ var r, l;
715
+ const n = (s.related_columns ?? []).findIndex((o) => o.key === e);
716
+ if (n !== -1)
717
+ return (l = (r = rt[n]) == null ? void 0 : r.data) == null ? void 0 : l[t];
718
+ }, at = et === -1 || (Hn = rt[et]) == null ? void 0 : Hn.data, vr = ae && !!((Yn = rt[et]) != null && Yn.isFetching), On = (e) => {
719
+ if (!ae || at === void 0) return !0;
720
+ const t = Number(at[e]);
680
721
  return Number.isFinite(t) && t > 0;
681
- }, nt = re ? Be.filter((e) => qr(String(e.id))) : Be, Yt = re ? Ze.filter((e) => qr(String(e.id))) : Ze, Zt = (e) => {
722
+ }, it = ae ? Ve.filter((e) => On(String(e.id))) : Ve, Xt = ae ? Xe.filter((e) => On(String(e.id))) : Xe, en = (e) => {
682
723
  var c;
683
- const t = a.qty_warning;
724
+ const t = s.qty_warning;
684
725
  if (!t) return null;
685
- const r = Ne(e) ?? 0;
686
- if (r <= 0) return null;
687
- const n = (a.related_columns ?? []).findIndex((m) => m.key === t.column);
688
- if (n === -1) return null;
689
- const l = (c = wt[n]) == null ? void 0 : c.data;
726
+ const n = _e(e) ?? 0;
727
+ if (n <= 0) return null;
728
+ const r = (s.related_columns ?? []).findIndex((f) => f.key === t.column);
729
+ if (r === -1) return null;
730
+ const l = (c = rt[r]) == null ? void 0 : c.data;
690
731
  if (l === void 0) return null;
691
- const o = l[e], p = o == null || o === "" ? 0 : Number(o);
692
- return Number.isNaN(p) ? null : r > p ? { available: p, qty: r } : null;
693
- }, xn = (e) => {
694
- const t = a.row_flags ?? [];
732
+ const o = l[e], h = o == null || o === "" ? 0 : Number(o);
733
+ return Number.isNaN(h) ? null : n > h ? { available: h, qty: n } : null;
734
+ }, _r = (e) => {
735
+ const t = s.row_flags ?? [];
695
736
  if (t.length === 0) return [];
696
- const r = [];
697
- for (const n of t)
698
- if (!(!(n != null && n.when) || !n.label))
737
+ const n = [];
738
+ for (const r of t)
739
+ if (!(!(r != null && r.when) || !r.label))
699
740
  try {
700
- const l = n.when.replace(/\{\{\s*([A-Za-z_][A-Za-z0-9_.]*)\s*\}\}/g, "$1");
701
- Un(l, e) && r.push(n.label);
741
+ const l = r.when.replace(/\{\{\s*([A-Za-z_][A-Za-z0-9_.]*)\s*\}\}/g, "$1");
742
+ ts(l, e) && n.push(r.label);
702
743
  } catch {
703
744
  }
704
- return r;
705
- }, Gt = a.qty_warning ? a.qty_warning.label ?? ((Br = (a.related_columns ?? []).find((e) => {
745
+ return n;
746
+ }, tn = s.qty_warning ? s.qty_warning.label ?? ((Zn = (s.related_columns ?? []).find((e) => {
706
747
  var t;
707
- return e.key === ((t = a.qty_warning) == null ? void 0 : t.column);
708
- })) == null ? void 0 : Br.label) ?? M(a.qty_warning.column) : "", yn = !!a.submission_errors, Nt = F(
748
+ return e.key === ((t = s.qty_warning) == null ? void 0 : t.column);
749
+ })) == null ? void 0 : Zn.label) ?? D(s.qty_warning.column) : "", Sr = !!s.submission_errors, Nt = F(
709
750
  () => {
710
751
  var e;
711
- return typeof a.submission_errors == "object" && Array.isArray((e = a.submission_errors) == null ? void 0 : e.match_fields) ? a.submission_errors.match_fields.filter((t) => /^[A-Za-z_][A-Za-z0-9_]*$/.test(t)) : [];
752
+ return typeof s.submission_errors == "object" && Array.isArray((e = s.submission_errors) == null ? void 0 : e.match_fields) ? s.submission_errors.match_fields.filter((t) => /^[A-Za-z_][A-Za-z0-9_]*$/.test(t)) : [];
712
753
  },
713
- [a.submission_errors]
714
- ), gn = Hn(6e4), { data: $r } = K({
715
- queryKey: ["erp-submissions", N ?? "", String(y)],
716
- queryFn: () => k.request(R(`/erp-submissions/${N}/${encodeURIComponent(y)}`)).then((e) => e.data ?? []),
717
- enabled: yn && !z && !!N,
754
+ [s.submission_errors]
755
+ ), qr = ns(6e4), { data: Rn } = C({
756
+ queryKey: ["erp-submissions", x ?? "", String(b)],
757
+ queryFn: () => k.request(R(`/erp-submissions/${x}/${encodeURIComponent(b)}`)).then((e) => e.data ?? []),
758
+ enabled: Sr && !P && !!x,
718
759
  staleTime: 15e3,
719
- refetchInterval: gn
720
- }), Xt = F(() => {
721
- const e = ($r ?? [])[0];
722
- return !e || e.status !== "failed" ? null : Gn(e.payload, e.last_error);
723
- }, [$r]), kn = pe.map((e) => e.key).join(","), { data: er } = K({
724
- queryKey: ["catalog-suberr-idents", g, Nt.join(","), kn],
760
+ refetchInterval: qr
761
+ }), nn = F(() => {
762
+ const e = (Rn ?? [])[0];
763
+ return !e || e.status !== "failed" ? null : is(e.payload, e.last_error);
764
+ }, [Rn]), $r = be.map((e) => e.key).join(","), { data: rn } = C({
765
+ queryKey: ["catalog-suberr-idents", g, Nt.join(","), $r],
725
766
  queryFn: async () => {
726
- const e = pe.map((r) => r.key);
767
+ const e = be.map((n) => n.key);
727
768
  if (e.length === 0) return {};
728
769
  const t = await k.request(
729
770
  R(`/items/${g}`, {
@@ -731,67 +772,67 @@ function Gs({
731
772
  fields: ["id", ...Nt].join(","),
732
773
  filter: JSON.stringify({ id: { _in: e } })
733
774
  })
734
- ).then((r) => r.data ?? []);
735
- return Object.fromEntries(t.map((r) => [String(r.id), r]));
775
+ ).then((n) => n.data ?? []);
776
+ return Object.fromEntries(t.map((n) => [String(n.id), n]));
736
777
  },
737
- enabled: !!g && !!Xt && Nt.length > 0 && pe.length > 0,
778
+ enabled: !!g && !!nn && Nt.length > 0 && be.length > 0,
738
779
  staleTime: 6e4
739
- }), wn = (e) => {
740
- if (!Xt) return null;
741
- const t = er == null ? void 0 : er[e], r = [
742
- Kr(e),
743
- ...Nt.map((n) => {
744
- const l = (t == null ? void 0 : t[n]) ?? Ie(e)[n];
780
+ }), jr = (e) => {
781
+ if (!nn) return null;
782
+ const t = rn == null ? void 0 : rn[e], n = [
783
+ jt(e),
784
+ ...Nt.map((r) => {
785
+ const l = (t == null ? void 0 : t[r]) ?? Ie(e)[r];
745
786
  return l != null && l !== "" ? String(l) : null;
746
787
  })
747
- ].filter((n) => !!n).map(Xn);
748
- return Xt.reasonFor(r);
749
- }, vt = a.summary_fields ?? [], Nn = ge.map((e) => String(e.id)).join(","), vn = lr({
788
+ ].filter((r) => !!r).map(ls);
789
+ return nn.reasonFor(n);
790
+ }, vt = s.summary_fields ?? [], Fr = me.map((e) => String(e.id)).join(","), Tr = un({
750
791
  queries: vt.filter((e) => e.m2m).map((e) => ({
751
- queryKey: ["catalog-summary-m2m", e.field, e.m2m.junction, Nn],
792
+ queryKey: ["catalog-summary-m2m", e.field, e.m2m.junction, Fr],
752
793
  queryFn: async () => {
753
- const t = ge.map((f) => String(f.id));
794
+ const t = me.map((p) => String(p.id));
754
795
  if (t.length === 0) return {};
755
- const r = e.m2m, n = await k.request(
756
- R(`/items/${r.junction}`, {
796
+ const n = e.m2m, r = await k.request(
797
+ R(`/items/${n.junction}`, {
757
798
  limit: 1e3,
758
- fields: `${r.fk_to_child},${r.related_field}`,
759
- filter: JSON.stringify({ [r.fk_to_child]: { _in: t } })
799
+ fields: `${n.fk_to_child},${n.related_field}`,
800
+ filter: JSON.stringify({ [n.fk_to_child]: { _in: t } })
760
801
  })
761
- ).then((f) => f.data ?? []).catch(() => []), l = [...new Set(n.map((f) => String(f[r.related_field])))], o = r.label_field ?? "name", p = l.length ? await k.request(
762
- R(`/items/${r.related_collection}`, {
802
+ ).then((p) => p.data ?? []).catch(() => []), l = [...new Set(r.map((p) => String(p[n.related_field])))], o = n.label_field ?? "name", h = l.length ? await k.request(
803
+ R(`/items/${n.related_collection}`, {
763
804
  limit: 500,
764
805
  fields: `id,${o}`,
765
806
  filter: JSON.stringify({ id: { _in: l } })
766
807
  })
767
- ).then((f) => f.data ?? []).catch(() => []) : [], c = new Map(p.map((f) => [String(f.id), String(f[o] ?? f.id)])), m = {};
768
- for (const f of n) {
769
- const v = String(f[r.fk_to_child]), _ = c.get(String(f[r.related_field]));
770
- _ && (m[v] = m[v] ? `${m[v]}, ${_}` : _);
808
+ ).then((p) => p.data ?? []).catch(() => []) : [], c = new Map(h.map((p) => [String(p.id), String(p[o] ?? p.id)])), f = {};
809
+ for (const p of r) {
810
+ const _ = String(p[n.fk_to_child]), q = c.get(String(p[n.related_field]));
811
+ q && (f[_] = f[_] ? `${f[_]}, ${q}` : q);
771
812
  }
772
- return m;
813
+ return f;
773
814
  },
774
- enabled: !z && ge.length > 0,
815
+ enabled: !P && me.length > 0,
775
816
  staleTime: 15e3
776
817
  }))
777
- }), _n = (e, t) => {
818
+ }), Or = (e, t) => {
778
819
  var l, o;
779
820
  if (!e.m2m) return t.row[e.field];
780
- const r = vt.filter((p) => p.m2m).findIndex((p) => p.field === e.field);
781
- if (r === -1) return;
782
- const n = t.row.id;
783
- if (n != null)
784
- return (o = (l = vn[r]) == null ? void 0 : l.data) == null ? void 0 : o[String(n)];
785
- }, Sn = !!((Vr = a.fulfilment) != null && Vr.shipped_field) && (a.fulfilment.show_when ? Gr(a.fulfilment.show_when, i) : !0), qn = (e) => {
786
- if (!Sn || !a.fulfilment) return null;
787
- const t = Number(e[a.fulfilment.qty_field ?? G] ?? 0) || 0, r = Number(e[a.fulfilment.shipped_field] ?? 0) || 0, n = t > 0 && r >= t ? {
821
+ const n = vt.filter((h) => h.m2m).findIndex((h) => h.field === e.field);
822
+ if (n === -1) return;
823
+ const r = t.row.id;
824
+ if (r != null)
825
+ return (o = (l = Tr[n]) == null ? void 0 : l.data) == null ? void 0 : o[String(r)];
826
+ }, Rr = !!((Gn = s.fulfilment) != null && Gn.shipped_field) && (s.fulfilment.show_when ? ir(s.fulfilment.show_when, N) : !0), Pr = (e) => {
827
+ if (!Rr || !s.fulfilment) return null;
828
+ const t = Number(e[s.fulfilment.qty_field ?? J] ?? 0) || 0, n = Number(e[s.fulfilment.shipped_field] ?? 0) || 0, r = t > 0 && n >= t ? {
788
829
  dot: "bg-emerald-500",
789
830
  text: "text-emerald-700 dark:text-emerald-400",
790
831
  label: "Shipped"
791
- } : r > 0 ? {
832
+ } : n > 0 ? {
792
833
  dot: "bg-amber-500",
793
834
  text: "text-amber-700 dark:text-amber-300",
794
- label: `Partial · ${r}/${t}`
835
+ label: `Partial · ${n}/${t}`
795
836
  } : {
796
837
  dot: "bg-slate-300 dark:bg-slate-600",
797
838
  text: "text-slate-500 dark:text-slate-400",
@@ -801,32 +842,32 @@ function Gs({
801
842
  "span",
802
843
  {
803
844
  className: "inline-flex items-center gap-1.5 whitespace-nowrap",
804
- "data-catalog-fulfilment": n.label.split(" ")[0].toLowerCase(),
805
- title: `${a.fulfilment.label ?? "Warehouse"} · ${r} of ${t} shipped`,
845
+ "data-catalog-fulfilment": r.label.split(" ")[0].toLowerCase(),
846
+ title: `${s.fulfilment.label ?? "Warehouse"} · ${n} of ${t} shipped`,
806
847
  children: [
807
- /* @__PURE__ */ s("span", { "aria-hidden": !0, className: `h-1.5 w-1.5 rounded-full ${n.dot}` }),
808
- /* @__PURE__ */ s("span", { className: `text-[11px] font-medium ${n.text}`, children: n.label })
848
+ /* @__PURE__ */ a("span", { "aria-hidden": !0, className: `h-1.5 w-1.5 rounded-full ${r.dot}` }),
849
+ /* @__PURE__ */ a("span", { className: `text-[11px] font-medium ${r.text}`, children: r.label })
809
850
  ]
810
851
  }
811
852
  );
812
- }, jr = a.columns ?? [], Fr = a.related_columns ?? [], _t = jr.filter((e) => !e.summary_only), tr = Fr.filter((e) => !e.summary_only), Tr = jr.filter((e) => !e.sections_only), Or = Fr.filter((e) => !e.sections_only), Rr = _t.length > 0 || tr.length > 0, rr = Ee(null), Pr = (e) => {
853
+ }, Pn = s.columns ?? [], En = s.related_columns ?? [], _t = Pn.filter((e) => !e.summary_only), sn = En.filter((e) => !e.summary_only), Ln = Pn.filter((e) => !e.sections_only), An = En.filter((e) => !e.sections_only), Kn = _t.length > 0 || sn.length > 0, an = pe(null), Cn = (e) => {
813
854
  let t = e.parentElement;
814
855
  for (; t; ) {
815
- const r = getComputedStyle(t);
816
- if (/(auto|scroll)/.test(r.overflowY) && t.scrollHeight > t.clientHeight + 4) {
817
- e.style.top = `-${Number.parseFloat(r.paddingTop) || 0}px`;
856
+ const n = getComputedStyle(t);
857
+ if (/(auto|scroll)/.test(n.overflowY) && t.scrollHeight > t.clientHeight + 4) {
858
+ e.style.top = `-${Number.parseFloat(n.paddingTop) || 0}px`;
818
859
  return;
819
860
  }
820
861
  t = t.parentElement;
821
862
  }
822
- }, $n = (e) => {
823
- rr.current = e, e && Pr(e);
863
+ }, Er = (e) => {
864
+ an.current = e, e && Cn(e);
824
865
  };
825
- Te(() => {
866
+ xe(() => {
826
867
  let e = 0;
827
868
  const t = () => {
828
869
  e || (e = requestAnimationFrame(() => {
829
- e = 0, rr.current && Pr(rr.current);
870
+ e = 0, an.current && Cn(an.current);
830
871
  }));
831
872
  };
832
873
  return window.addEventListener("scroll", t, !0), () => {
@@ -834,401 +875,443 @@ function Gs({
834
875
  };
835
876
  }, []);
836
877
  const St = (e, t) => {
837
- let r = e;
838
- for (const n of t.split(".")) {
839
- if (r == null || typeof r != "object") return;
840
- r = r[n];
878
+ let n = e;
879
+ for (const r of t.split(".")) {
880
+ if (n == null || typeof n != "object") return;
881
+ n = n[r];
841
882
  }
842
- return r;
843
- }, ke = (e, t) => {
883
+ return n;
884
+ }, Ne = (e, t) => {
844
885
  if (t === "presence")
845
886
  return e == null || e === "" || Number(e) === 0 ? "No" : "Yes";
846
887
  if (e == null || e === "") return "—";
847
- const r = Number(e);
848
- return t === "currency" ? Number.isNaN(r) ? String(e) : r.toLocaleString(void 0, { style: "currency", currency: "USD" }) : t === "number" ? Number.isNaN(r) ? String(e) : r.toLocaleString(void 0, { maximumFractionDigits: 2 }) : String(e);
849
- }, qt = g ? `${g}:${d}.${h}` : null, Pe = Zr(qt && `${qt}:catalog`), we = Zr(qt && `${qt}:summary`), Er = Ee(null), jn = (e, t) => {
850
- const r = ss(Er.current, t);
851
- r != null && e.setWidth(t, r);
852
- }, $t = (e, t, r, n, l) => {
853
- const o = e.box(t, n, l);
854
- return /* @__PURE__ */ u("span", { ...o, className: C("relative", o.className), children: [
855
- /* @__PURE__ */ s("span", { "data-cpf-fit": !0, className: "block truncate", children: r }),
856
- /* @__PURE__ */ s(
857
- ns,
888
+ const n = Number(e);
889
+ return t === "currency" ? Number.isNaN(n) ? String(e) : n.toLocaleString(void 0, { style: "currency", currency: "USD" }) : t === "number" ? Number.isNaN(n) ? String(e) : n.toLocaleString(void 0, { maximumFractionDigits: 2 }) : String(e);
890
+ }, qt = g ? `${g}:${i}.${m}` : null, Le = ar(qt && `${qt}:catalog`), ve = ar(qt && `${qt}:summary`), Jn = pe(null), Lr = (e, t) => {
891
+ const n = ms(Jn.current, t);
892
+ n != null && e.setWidth(t, n);
893
+ }, $t = (e, t, n, r, l) => {
894
+ const o = e.box(t, r, l);
895
+ return /* @__PURE__ */ u("span", { ...o, className: I("relative", o.className), children: [
896
+ /* @__PURE__ */ a("span", { "data-cpf-fit": !0, className: "block truncate", children: n }),
897
+ /* @__PURE__ */ a(
898
+ us,
858
899
  {
859
- label: r,
860
- onResize: (p) => e.setWidth(t, p),
861
- onFit: () => jn(e, t)
900
+ label: n,
901
+ onResize: (h) => e.setWidth(t, h),
902
+ onFit: () => Lr(e, t)
862
903
  }
863
904
  )
864
905
  ] }, t);
865
- }, Fn = (Wr = _t.find((e) => !e.format)) == null ? void 0 : Wr.field, Lr = (e) => e.format ? ["w-20 shrink-0", "text-right"] : e.field === Fn ? ["min-w-0 flex-[3]", ""] : ["w-36 shrink-0", ""], nr = (e, t, r) => /* @__PURE__ */ u(ve, { children: [
866
- _t.map((n) => {
867
- const [l, o] = Lr(n);
868
- return /* @__PURE__ */ s(
869
- Xr,
906
+ }, Ar = (Xn = _t.find((e) => !e.format)) == null ? void 0 : Xn.field, In = (e) => e.format ? ["w-20 shrink-0", "text-right"] : e.field === Ar ? ["min-w-0 flex-[3]", ""] : ["w-36 shrink-0", ""], ln = (e, t, n) => /* @__PURE__ */ u(Se, { children: [
907
+ _t.map((r) => {
908
+ const [l, o] = In(r);
909
+ return /* @__PURE__ */ a(
910
+ lr,
870
911
  {
871
- text: ke(
872
- ks({
873
- field: n.field,
874
- catalogValue: St(t, n.field),
875
- copyFields: a.copy_fields,
876
- related: a.related_columns,
877
- lookup: (p) => tt(p, e)
912
+ text: Ne(
913
+ Fs({
914
+ field: r.field,
915
+ catalogValue: St(t, r.field),
916
+ copyFields: s.copy_fields,
917
+ related: s.related_columns,
918
+ lookup: (h) => st(h, e)
878
919
  }),
879
- n.format
920
+ r.format
880
921
  ),
881
- highlight: n.format ? void 0 : r,
882
- ...Pe.box(n.field, l, C("text-slate-500 dark:text-slate-400", o))
922
+ highlight: r.format ? void 0 : n,
923
+ ...Le.box(r.field, l, I("text-slate-500 dark:text-slate-400", o))
883
924
  },
884
- n.field
925
+ r.field
885
926
  );
886
927
  }),
887
- tr.map((n) => /* @__PURE__ */ s(
928
+ sn.map((r) => /* @__PURE__ */ a(
888
929
  "span",
889
930
  {
890
- ...Pe.box(
891
- `rel:${n.key}`,
931
+ ...Le.box(
932
+ `rel:${r.key}`,
892
933
  "w-20 shrink-0",
893
934
  "truncate text-right text-slate-500 dark:text-slate-400"
894
935
  ),
895
- children: ke(tt(n.key, e), n.format)
936
+ children: Ne(st(r.key, e), r.format)
896
937
  },
897
- n.key
938
+ r.key
898
939
  )),
899
- /* @__PURE__ */ s("span", { "aria-hidden": !0, className: "ml-auto" })
900
- ] }), Tn = en(g), Ar = (e, t, r, n, l) => Tn ? /* @__PURE__ */ s(
940
+ /* @__PURE__ */ a("span", { "aria-hidden": !0, className: "ml-auto" })
941
+ ] }), Kr = or(g), zn = (e, t, n, r, l) => Kr ? /* @__PURE__ */ a(
901
942
  "button",
902
943
  {
903
944
  type: "button",
904
- "data-cpf-fit": n || void 0,
905
- onClick: () => g && tn(g, e, i),
945
+ "data-cpf-fit": r || void 0,
946
+ onClick: () => g && dr(g, e, N),
906
947
  title: "View stock & planning detail",
907
- className: C(
908
- r,
948
+ className: I(
949
+ n,
909
950
  "text-left underline decoration-slate-300 decoration-1 underline-offset-2 hover:text-[#009abe] hover:decoration-[#009abe] dark:decoration-slate-600"
910
951
  ),
911
- children: l ? /* @__PURE__ */ s(dr, { text: t, query: l }) : t
952
+ children: l ? /* @__PURE__ */ a(fn, { text: t, query: l }) : t
912
953
  }
913
- ) : /* @__PURE__ */ s("span", { className: r, "data-cpf-fit": n || void 0, children: l ? /* @__PURE__ */ s(dr, { text: t, query: l }) : t }), sr = (e, t, r, n) => {
914
- const l = Pe.box("item", Rr ? "w-36 shrink-0" : "min-w-0 flex-1");
915
- return /* @__PURE__ */ u("span", { ...l, className: C("flex min-w-0 items-center gap-1.5", l.className), children: [
916
- Ar(
954
+ ) : /* @__PURE__ */ a("span", { className: n, "data-cpf-fit": r || void 0, children: l ? /* @__PURE__ */ a(fn, { text: t, query: l }) : t }), on = (e, t, n, r) => {
955
+ const l = Le.box("item", Kn ? "w-36 shrink-0" : "min-w-0 flex-1");
956
+ return /* @__PURE__ */ u("span", { ...l, className: I("flex min-w-0 items-center gap-1.5", l.className), children: [
957
+ zn(
917
958
  e,
918
959
  t,
919
960
  "min-w-0 truncate text-slate-700 dark:text-slate-200",
920
961
  !0,
921
- n
962
+ r
922
963
  ),
923
- r
964
+ n
924
965
  ] });
925
- }, Kr = (e) => {
926
- const t = ct.get(e) ?? hr.find((r) => String(r.id) === e) ?? Ze.find((r) => String(r.id) === e);
927
- return t ? ze(J, t) : `#${e}`;
928
- }, Ie = (e) => ct.get(e) ?? hr.find((t) => String(t.id) === e) ?? Ze.find((t) => String(t.id) === e) ?? { id: e }, Ne = (e) => {
929
- var n;
930
- const t = z ? void 0 : Ye.get(e);
931
- if (t) return ft.has(String(t.id)) ? null : Number(t[G] ?? 0);
932
- const r = ht.get(e);
933
- return r === void 0 ? null : Number(((n = Re[r]) == null ? void 0 : n[G]) ?? 0);
934
- }, On = (e) => {
966
+ }, jt = (e) => {
967
+ const t = mt.get(e) ?? It.find((n) => String(n.id) === e) ?? Xe.find((n) => String(n.id) === e);
968
+ return t ? ze(z, t) : `#${e}`;
969
+ }, Qn = pe(jt);
970
+ Qn.current = jt;
971
+ const Vn = pe(me);
972
+ Vn.current = me, xe(
973
+ () => as(i, (e) => {
974
+ const t = Vn.current.find((o) => String(o.id) === String(e)), n = t == null ? void 0 : t[s.item_field], r = n && typeof n == "object" ? n.id : n;
975
+ if (r == null || r === "") return null;
976
+ const l = Qn.current(String(r));
977
+ return l.startsWith("#") ? null : l;
978
+ }),
979
+ [i, s.item_field]
980
+ );
981
+ const Ie = (e) => mt.get(e) ?? It.find((t) => String(t.id) === e) ?? Xe.find((t) => String(t.id) === e) ?? { id: e }, _e = (e) => {
982
+ var r;
983
+ const t = P ? void 0 : Ge.get(e);
984
+ if (t) return bt.has(String(t.id)) ? null : Number(t[J] ?? 0);
985
+ const n = pt.get(e);
986
+ return n === void 0 ? null : Number(((r = we[n]) == null ? void 0 : r[J]) ?? 0);
987
+ }, Cr = (e) => {
935
988
  let t = e;
936
- for (const r of a.section_by.split(".")) {
989
+ for (const n of s.section_by.split(".")) {
937
990
  if (t == null || typeof t != "object") return "";
938
- t = t[r];
991
+ t = t[n];
939
992
  }
940
993
  return String(t ?? "").trim();
941
- }, jt = F(() => {
942
- if (dt) return [];
943
- U.trim().toLowerCase();
994
+ }, Ft = F(() => {
995
+ if (ut) return [];
996
+ X.trim().toLowerCase();
944
997
  const e = /* @__PURE__ */ new Map();
945
- for (const t of de) {
946
- if (re && rt !== void 0 && !(Number(rt[String(t.id)]) > 0)) continue;
947
- const r = ze(J, t), n = E ? mr.get(String(t.id)) ?? [] : [On(t)];
948
- if (!(E && W && n.length === 0))
949
- for (const l of n.length ? n : [""]) {
998
+ for (const t of re) {
999
+ if (ae && at !== void 0 && !(Number(at[String(t.id)]) > 0)) continue;
1000
+ const n = ze(z, t), r = L ? yn.get(String(t.id)) ?? [] : [Cr(t)];
1001
+ if (!(L && Q && r.length === 0))
1002
+ for (const l of r.length ? r : [""]) {
950
1003
  const o = l || "Uncategorized";
951
- e.has(o) || e.set(o, []), e.get(o).push({ id: String(t.id), label: r, row: t });
1004
+ e.has(o) || e.set(o, []), e.get(o).push({ id: String(t.id), label: n, row: t });
952
1005
  }
953
1006
  }
954
1007
  return [...e.entries()].sort(
955
- ([t], [r]) => t === "Uncategorized" ? 1 : r === "Uncategorized" ? -1 : t.localeCompare(r)
956
- ).map(([t, r]) => ({
1008
+ ([t], [n]) => t === "Uncategorized" ? 1 : n === "Uncategorized" ? -1 : t.localeCompare(n)
1009
+ ).map(([t, n]) => ({
957
1010
  name: t,
958
- items: r.sort((n, l) => n.label.localeCompare(l.label))
1011
+ items: n.sort((r, l) => r.label.localeCompare(l.label))
959
1012
  }));
960
1013
  }, [
961
- de,
962
- J,
963
- U,
964
- a.section_by,
965
- E,
966
- mr,
967
- dt,
968
- W,
969
1014
  re,
970
- rt
1015
+ z,
1016
+ X,
1017
+ s.section_by,
1018
+ L,
1019
+ yn,
1020
+ ut,
1021
+ Q,
1022
+ ae,
1023
+ at
971
1024
  ]);
972
- if (!Oe.current && jt.length > 0) {
973
- Oe.current = !0;
1025
+ if (!je.current && Ft.length > 0) {
1026
+ je.current = !0;
974
1027
  const e = /* @__PURE__ */ new Set();
975
- for (const t of jt)
976
- t.items.some((n) => (Ne(n.id) ?? 0) > 0) || e.add(t.name);
977
- xe(e);
1028
+ for (const t of Ft)
1029
+ t.items.some((r) => (_e(r.id) ?? 0) > 0) || e.add(t.name);
1030
+ $e(e);
978
1031
  }
979
- async function Rn(e) {
1032
+ async function Jr(e) {
980
1033
  const t = {};
981
- for (const r of a.related_columns ?? []) {
982
- if (!r.copy_to) continue;
983
- let n = tt(r.key, e);
984
- if (n === void 0) {
985
- const l = Me(r.match, i);
1034
+ for (const n of s.related_columns ?? []) {
1035
+ if (!n.copy_to) continue;
1036
+ let r = st(n.key, e);
1037
+ if (r === void 0) {
1038
+ const l = De(n.match, N);
986
1039
  if (l === null) continue;
987
- n = await k.request(
988
- R(`/items/${r.collection}`, {
1040
+ r = await k.request(
1041
+ R(`/items/${n.collection}`, {
989
1042
  limit: 1,
990
- fields: `${r.item_field},${r.value_field}`,
991
- filter: JSON.stringify({ ...l, [r.item_field]: { _eq: e } })
1043
+ fields: `${n.item_field},${n.value_field}`,
1044
+ filter: JSON.stringify({ ...l, [n.item_field]: { _eq: e } })
992
1045
  })
993
1046
  ).then((o) => {
994
- var p, c;
995
- return (c = (p = o.data) == null ? void 0 : p[0]) == null ? void 0 : c[r.value_field];
1047
+ var h, c;
1048
+ return (c = (h = o.data) == null ? void 0 : h[0]) == null ? void 0 : c[n.value_field];
996
1049
  }).catch(() => {
997
1050
  });
998
1051
  }
999
- n != null && (t[r.copy_to] = n);
1052
+ r != null && (t[n.copy_to] = r);
1000
1053
  }
1001
1054
  return t;
1002
1055
  }
1003
- const Pn = (e, t) => {
1004
- var n;
1005
- for (const l of a.related_columns ?? []) {
1056
+ const Wn = (e, t) => {
1057
+ var r;
1058
+ for (const l of s.related_columns ?? []) {
1006
1059
  if (l.copy_to !== t) continue;
1007
- const o = tt(l.key, e);
1060
+ const o = st(l.key, e);
1008
1061
  if (o != null && o !== "") return o;
1009
1062
  }
1010
- const r = (n = a.copy_fields) == null ? void 0 : n[t];
1011
- return r ? Ie(e)[r] : void 0;
1012
- }, En = (e, t) => {
1013
- if (b || !Y.includes(t)) return !1;
1014
- if (Z || !_e.includes(t)) return !0;
1015
- const r = Pn(e, t);
1016
- return r == null || r === "" || !(Number(r) > 0);
1063
+ const n = (r = s.copy_fields) == null ? void 0 : r[t];
1064
+ return n ? Ie(e)[n] : void 0;
1065
+ }, Mn = pe(/* @__PURE__ */ new Map()), Tt = F(() => {
1066
+ const e = new Set(Object.keys(s.copy_fields ?? {}));
1067
+ for (const t of s.related_columns ?? []) t.copy_to && e.add(t.copy_to);
1068
+ return [...e];
1069
+ }, [s.copy_fields, s.related_columns]), Ir = JSON.stringify([
1070
+ we.map((e) => [e[s.item_field], ...Tt.map((t) => e[t] ?? null)]),
1071
+ rt.map((e) => e.dataUpdatedAt),
1072
+ re.length,
1073
+ It.length
1074
+ ]);
1075
+ xe(() => {
1076
+ w || !v || Tt.length === 0 || we.forEach((e, t) => {
1077
+ const n = e[s.item_field];
1078
+ if (n == null) return;
1079
+ const r = vs(
1080
+ e,
1081
+ Tt,
1082
+ (o) => Wn(String(n), o),
1083
+ Mn.current.get(String(n))
1084
+ );
1085
+ if (!r) return;
1086
+ Mn.current.set(String(n), r.auto);
1087
+ const l = { ...e, ...r.updates };
1088
+ for (const [o, h] of Object.entries(s.compute_fields ?? {})) {
1089
+ const c = Pe(h, l);
1090
+ c !== null && (l[o] = c);
1091
+ }
1092
+ v.updateRow(i, m, t, l);
1093
+ });
1094
+ }, [Ir, w, Tt]);
1095
+ const zr = (e, t) => {
1096
+ if (w || !Z.includes(t)) return !1;
1097
+ if (Ae || !G.includes(t)) return !0;
1098
+ const n = Wn(e, t);
1099
+ return n == null || n === "" || !(Number(n) > 0);
1017
1100
  };
1018
- function Ve(e, t, r, n = {}) {
1101
+ function Me(e, t, n, r = {}) {
1019
1102
  const l = {
1020
- [a.item_field]: r.id ?? e,
1021
- [G]: t
1103
+ [s.item_field]: n.id ?? e,
1104
+ [J]: t
1022
1105
  };
1023
- for (const [o, p] of Object.entries(a.copy_fields ?? {}))
1024
- r[p] !== void 0 && (l[o] = r[p]);
1025
- Object.assign(l, n);
1026
- for (const [o, p] of Object.entries(a.compute_fields ?? {})) {
1027
- const c = Le(p, l);
1106
+ for (const [o, h] of Object.entries(s.copy_fields ?? {}))
1107
+ n[h] !== void 0 && (l[o] = n[h]);
1108
+ Object.assign(l, r);
1109
+ for (const [o, h] of Object.entries(s.compute_fields ?? {})) {
1110
+ const c = Pe(h, l);
1028
1111
  c !== null && (l[o] = c);
1029
1112
  }
1030
1113
  return l;
1031
1114
  }
1032
- function Ln(e, t, r, n) {
1033
- return gs({
1034
- compute: a.compute_fields ?? {},
1035
- probe: { ...Ve(e, t, r), ...n, [G]: t },
1036
- ruleError: B,
1115
+ function Qr(e, t, n, r) {
1116
+ return js({
1117
+ compute: s.compute_fields ?? {},
1118
+ probe: { ...Me(e, t, n), ...r, [J]: t },
1119
+ ruleError: U,
1037
1120
  labelOf: (l) => {
1038
1121
  var o;
1039
- return ((o = L.find((p) => p.field === l)) == null ? void 0 : o.label) || M(l);
1122
+ return ((o = te.find((h) => h.field === l)) == null ? void 0 : o.label) || D(l);
1040
1123
  }
1041
1124
  });
1042
1125
  }
1043
- async function st(e, t, r, n = {}) {
1044
- const l = cr(t, { type: le, min: 0, label: "Quantity" });
1126
+ async function lt(e, t, n, r = {}) {
1127
+ const l = hn(t, { type: M, min: 0, label: "Quantity" });
1045
1128
  if (!l.ok) {
1046
- X((m) => ({ ...m, [e]: { kind: "error", message: l.message } }));
1129
+ de((f) => ({ ...f, [e]: { kind: "error", message: l.message } }));
1047
1130
  return;
1048
1131
  }
1049
1132
  const o = l.value ?? 0;
1050
- if ((Ne(e) ?? 0) === o) return;
1051
- if (o === 0 && !n.confirmedRemove) {
1052
- X((m) => ({ ...m, [e]: { kind: "remove", row: r } }));
1133
+ if ((_e(e) ?? 0) === o) return;
1134
+ if (o === 0 && !r.confirmedRemove) {
1135
+ de((f) => ({ ...f, [e]: { kind: "remove", row: n } }));
1053
1136
  return;
1054
1137
  }
1055
1138
  if (o > 0) {
1056
- const m = ht.get(e), f = (z ? void 0 : Ye.get(e)) ?? (m !== void 0 ? Re[m] : void 0) ?? {}, v = B(G, o, f) ?? Ln(e, o, r, f);
1057
- if (v) {
1058
- X((_) => ({ ..._, [e]: { kind: "error", message: v } }));
1139
+ const f = pt.get(e), p = (P ? void 0 : Ge.get(e)) ?? (f !== void 0 ? we[f] : void 0) ?? {}, _ = U(J, o, p) ?? Qr(e, o, n, p);
1140
+ if (_) {
1141
+ de((q) => ({ ...q, [e]: { kind: "error", message: _ } }));
1059
1142
  return;
1060
1143
  }
1061
1144
  }
1062
- const c = o > 0 ? await Rn(e) : {};
1063
- if (He && w) {
1064
- const m = Ye.get(e);
1065
- if ((m == null ? void 0 : m.id) != null) {
1066
- const f = String(m.id);
1145
+ const c = o > 0 ? await Jr(e) : {};
1146
+ if (Ze && v) {
1147
+ const f = Ge.get(e);
1148
+ if ((f == null ? void 0 : f.id) != null) {
1149
+ const p = String(f.id);
1067
1150
  if (o === 0) {
1068
- w.cancelPendingEdit(d, h, f), w.queueDelete(d, h, f);
1151
+ v.cancelPendingEdit(i, m, p), v.queueDelete(i, m, p);
1069
1152
  return;
1070
1153
  }
1071
- ft.has(f) && w.cancelPendingDelete(d, h, f);
1072
- const v = Ve(e, o, r, c);
1073
- for (const x of Y)
1074
- m[x] != null && m[x] !== "" && (v[x] = m[x]);
1075
- for (const [x, A] of Object.entries(a.compute_fields ?? {})) {
1076
- const Fe = Le(A, { ...m, ...v });
1077
- Fe !== null && (v[x] = Fe);
1154
+ bt.has(p) && v.cancelPendingDelete(i, m, p);
1155
+ const _ = Me(e, o, n, c);
1156
+ for (const y of Z)
1157
+ f[y] != null && f[y] !== "" && (_[y] = f[y]);
1158
+ for (const [y, K] of Object.entries(s.compute_fields ?? {})) {
1159
+ const Re = Pe(K, { ...f, ..._ });
1160
+ Re !== null && (_[y] = Re);
1078
1161
  }
1079
- const _ = ge.find((x) => String(x.id) === f) ?? {}, O = Object.fromEntries(
1080
- Object.entries(v).filter(([x, A]) => String(A ?? "") !== String(_[x] ?? ""))
1162
+ const q = me.find((y) => String(y.id) === p) ?? {}, E = Object.fromEntries(
1163
+ Object.entries(_).filter(([y, K]) => String(K ?? "") !== String(q[y] ?? ""))
1081
1164
  );
1082
- Object.keys(O).length === 0 ? w.cancelPendingEdit(d, h, f) : (w.cancelPendingEdit(d, h, f), w.queueEdit(d, h, f, O));
1165
+ Object.keys(E).length === 0 ? v.cancelPendingEdit(i, m, p) : (v.cancelPendingEdit(i, m, p), v.queueEdit(i, m, p, E));
1083
1166
  return;
1084
1167
  }
1085
1168
  }
1086
- if (z || He) {
1087
- const m = ht.get(e);
1088
- o === 0 ? m !== void 0 && (w == null || w.removeRow(d, h, m)) : m !== void 0 ? w == null || w.updateRow(
1089
- d,
1090
- h,
1169
+ if (P || Ze) {
1170
+ const f = pt.get(e);
1171
+ o === 0 ? f !== void 0 && (v == null || v.removeRow(i, m, f)) : f !== void 0 ? v == null || v.updateRow(
1172
+ i,
1091
1173
  m,
1092
- ls(
1093
- Re[m],
1094
- Ve(e, o, r, c),
1095
- Y,
1096
- a.compute_fields
1174
+ f,
1175
+ bs(
1176
+ we[f],
1177
+ Me(e, o, n, c),
1178
+ Z,
1179
+ s.compute_fields
1097
1180
  )
1098
- ) : w == null || w.queueRow(
1099
- d,
1100
- h,
1101
- Ve(e, o, r, c)
1181
+ ) : v == null || v.queueRow(
1182
+ i,
1183
+ m,
1184
+ Me(e, o, n, c)
1102
1185
  );
1103
1186
  return;
1104
1187
  }
1105
- ae((m) => new Set(m).add(e));
1188
+ V((f) => new Set(f).add(e));
1106
1189
  try {
1107
- const m = Ye.get(e);
1190
+ const f = Ge.get(e);
1108
1191
  if (o === 0)
1109
- (m == null ? void 0 : m.id) != null && await k.request(Mn(`/items/${d}/${m.id}${ne}`));
1110
- else if ((m == null ? void 0 : m.id) != null) {
1111
- const f = Ve(e, o, r, c);
1112
- for (const x of Y)
1113
- m[x] != null && m[x] !== "" && (f[x] = m[x]);
1114
- for (const [x, A] of Object.entries(a.compute_fields ?? {})) {
1115
- const Fe = Le(A, { ...m, ...f });
1116
- Fe !== null && (f[x] = Fe);
1192
+ (f == null ? void 0 : f.id) != null && await k.request(es(`/items/${i}/${f.id}${qe}`));
1193
+ else if ((f == null ? void 0 : f.id) != null) {
1194
+ const p = Me(e, o, n, c);
1195
+ for (const y of Z)
1196
+ f[y] != null && f[y] !== "" && (p[y] = f[y]);
1197
+ for (const [y, K] of Object.entries(s.compute_fields ?? {})) {
1198
+ const Re = Pe(K, { ...f, ...p });
1199
+ Re !== null && (p[y] = Re);
1117
1200
  }
1118
- const v = { ...m, ...f }, { id: _, ...O } = v;
1119
- await k.request(Hr(`/items/${d}/${m.id}${ne}`, O));
1201
+ const _ = { ...f, ...p }, { id: q, ...E } = _;
1202
+ await k.request(rr(`/items/${i}/${f.id}${qe}`, E));
1120
1203
  } else
1121
1204
  await k.request(
1122
- Yr(`/items/${d}${ne}`, {
1123
- [h]: y,
1124
- ...Ve(e, o, r, c)
1205
+ sr(`/items/${i}${qe}`, {
1206
+ [m]: b,
1207
+ ...Me(e, o, n, c)
1125
1208
  })
1126
1209
  );
1127
- j.invalidateQueries({ queryKey: ["o2m-rows", d, h, y] });
1210
+ j.invalidateQueries({ queryKey: ["o2m-rows", i, m, b] });
1128
1211
  } catch {
1129
1212
  } finally {
1130
- ae((m) => {
1131
- const f = new Set(m);
1132
- return f.delete(e), f;
1213
+ V((f) => {
1214
+ const p = new Set(f);
1215
+ return p.delete(e), p;
1133
1216
  });
1134
1217
  }
1135
1218
  }
1136
- async function An(e, t, r) {
1137
- const n = r.trim() === "" ? null : Number(r);
1138
- if (r.trim() !== "" && Number.isNaN(n)) return;
1139
- const l = (p) => {
1140
- const c = { ...p, [t]: n };
1141
- for (const [m, f] of Object.entries(a.compute_fields ?? {})) {
1142
- const v = Le(f, c);
1143
- v !== null && (c[m] = v);
1219
+ async function Vr(e, t, n) {
1220
+ const r = n.trim() === "" ? null : Number(n);
1221
+ if (n.trim() !== "" && Number.isNaN(r)) return;
1222
+ const l = (h) => {
1223
+ const c = { ...h, [t]: r };
1224
+ for (const [f, p] of Object.entries(s.compute_fields ?? {})) {
1225
+ const _ = Pe(p, c);
1226
+ _ !== null && (c[f] = _);
1144
1227
  }
1145
1228
  return c;
1146
- }, o = z ? void 0 : Ye.get(e);
1229
+ }, o = P ? void 0 : Ge.get(e);
1147
1230
  if ((o == null ? void 0 : o.id) == null) {
1148
- const p = ht.get(e);
1149
- if (p === void 0) return;
1150
- w == null || w.updateRow(d, h, p, l(Re[p]));
1231
+ const h = pt.get(e);
1232
+ if (h === void 0) return;
1233
+ v == null || v.updateRow(i, m, h, l(we[h]));
1151
1234
  return;
1152
1235
  }
1153
- if (He && w) {
1154
- const p = l(o), c = ge.find((f) => String(f.id) === String(o.id)) ?? {}, m = Object.fromEntries(
1155
- Object.entries(p).filter(
1156
- ([f, v]) => f !== "id" && String(v ?? "") !== String(c[f] ?? "")
1236
+ if (Ze && v) {
1237
+ const h = l(o), c = me.find((p) => String(p.id) === String(o.id)) ?? {}, f = Object.fromEntries(
1238
+ Object.entries(h).filter(
1239
+ ([p, _]) => p !== "id" && String(_ ?? "") !== String(c[p] ?? "")
1157
1240
  )
1158
1241
  );
1159
- w.cancelPendingEdit(d, h, String(o.id)), Object.keys(m).length > 0 && w.queueEdit(d, h, String(o.id), m);
1242
+ v.cancelPendingEdit(i, m, String(o.id)), Object.keys(f).length > 0 && v.queueEdit(i, m, String(o.id), f);
1160
1243
  return;
1161
1244
  }
1162
- ae((p) => new Set(p).add(e));
1245
+ V((h) => new Set(h).add(e));
1163
1246
  try {
1164
- const { id: p, ...c } = l(o);
1165
- await k.request(Hr(`/items/${d}/${o.id}${ne}`, c)), j.invalidateQueries({ queryKey: ["o2m-rows", d, h, y] });
1247
+ const { id: h, ...c } = l(o);
1248
+ await k.request(rr(`/items/${i}/${o.id}${qe}`, c)), j.invalidateQueries({ queryKey: ["o2m-rows", i, m, b] });
1166
1249
  } catch {
1167
1250
  } finally {
1168
- ae((p) => {
1169
- const c = new Set(p);
1251
+ V((h) => {
1252
+ const c = new Set(h);
1170
1253
  return c.delete(e), c;
1171
1254
  });
1172
1255
  }
1173
1256
  }
1174
- async function Kn(e) {
1257
+ async function Wr(e) {
1175
1258
  if (e == null || e === "" || !g) return;
1176
- const t = String(e), r = Ie(t);
1177
- let n = r;
1178
- Object.keys(r).length <= 1 && (n = await k.request(
1259
+ const t = String(e), n = Ie(t);
1260
+ let r = n;
1261
+ Object.keys(n).length <= 1 && (r = await k.request(
1179
1262
  R(`/items/${g}`, {
1180
1263
  filter: JSON.stringify({ id: { _eq: e } }),
1181
- fields: T,
1264
+ fields: A,
1182
1265
  limit: 1
1183
1266
  })
1184
1267
  ).then((o) => {
1185
- var p;
1186
- return ((p = o.data) == null ? void 0 : p[0]) ?? { id: e };
1268
+ var h;
1269
+ return ((h = o.data) == null ? void 0 : h[0]) ?? { id: e };
1187
1270
  }).catch(() => ({ id: e })));
1188
- const l = (Ne(t) ?? 0) + 1;
1189
- await st(t, String(l), n);
1271
+ const l = (_e(t) ?? 0) + 1;
1272
+ await lt(t, String(l), r);
1190
1273
  }
1191
- const Cn = pe.length, Ft = Object.keys(a.copy_fields ?? {}), We = Object.keys(a.compute_fields ?? {}), Tt = (e, t) => {
1192
- const r = Ne(e);
1193
- if (b)
1194
- return /* @__PURE__ */ s("span", { className: "inline-block w-20 shrink-0 text-right tabular-nums text-slate-700 dark:text-slate-200", children: r && r > 0 ? r : "—" });
1195
- const n = ye[e], l = n !== void 0 ? n : r && r > 0 ? String(r) : "", o = Q[e], p = () => X((m) => {
1196
- if (!(e in m)) return m;
1197
- const f = { ...m };
1198
- return delete f[e], f;
1199
- }), c = /* @__PURE__ */ s(
1274
+ const Mr = be.length, Ot = Object.keys(s.copy_fields ?? {}), Ue = Object.keys(s.compute_fields ?? {}), Rt = (e, t) => {
1275
+ const n = _e(e);
1276
+ if (w)
1277
+ return /* @__PURE__ */ a("span", { className: "inline-block w-20 shrink-0 text-right tabular-nums text-slate-700 dark:text-slate-200", children: n && n > 0 ? n : "—" });
1278
+ const r = ke[e], l = r !== void 0 ? r : n && n > 0 ? String(n) : "", o = oe[e], h = () => de((f) => {
1279
+ if (!(e in f)) return f;
1280
+ const p = { ...f };
1281
+ return delete p[e], p;
1282
+ }), c = /* @__PURE__ */ a(
1200
1283
  "input",
1201
1284
  {
1202
1285
  type: "number",
1203
1286
  min: 0,
1204
- step: Ot(le) ? 1 : "any",
1205
- disabled: b,
1287
+ step: Pt(M) ? 1 : "any",
1288
+ disabled: w,
1206
1289
  value: l,
1207
1290
  placeholder: "0",
1208
1291
  "aria-invalid": (o == null ? void 0 : o.kind) === "error" || void 0,
1209
- onFocus: p,
1210
- onChange: (m) => ue((f) => ({ ...f, [e]: m.target.value })),
1211
- onBlur: (m) => {
1212
- const f = m.target.value, v = ps(f, le);
1213
- if (v) {
1214
- ue((_) => {
1215
- const O = { ..._ };
1216
- return delete O[e], O;
1217
- }), X((_) => ({
1218
- ..._,
1219
- [e]: { kind: "error", message: ys(v, f) }
1292
+ onFocus: h,
1293
+ onChange: (f) => le((p) => ({ ...p, [e]: f.target.value })),
1294
+ onBlur: (f) => {
1295
+ const p = f.target.value, _ = Ss(p, M);
1296
+ if (_) {
1297
+ le((q) => {
1298
+ const E = { ...q };
1299
+ return delete E[e], E;
1300
+ }), de((q) => ({
1301
+ ...q,
1302
+ [e]: { kind: "error", message: $s(_, p) }
1220
1303
  }));
1221
1304
  return;
1222
1305
  }
1223
- ue((_) => {
1224
- const O = { ..._ };
1225
- return delete O[e], O;
1226
- }), st(e, f, t);
1306
+ le((q) => {
1307
+ const E = { ...q };
1308
+ return delete E[e], E;
1309
+ }), lt(e, p, t);
1227
1310
  },
1228
- onKeyDown: (m) => {
1229
- m.key === "Enter" && m.currentTarget.blur();
1311
+ onKeyDown: (f) => {
1312
+ f.key === "Enter" && f.currentTarget.blur();
1230
1313
  },
1231
- className: C(
1314
+ className: I(
1232
1315
  "h-7 w-20 shrink-0 rounded border border-slate-200 bg-white px-2 text-right text-[12px] outline-none focus:border-nvr-cyan disabled:opacity-50 dark:border-border dark:bg-background",
1233
1316
  (o == null ? void 0 : o.kind) === "error" && "border-red-400 dark:border-red-600"
1234
1317
  )
@@ -1243,9 +1326,9 @@ function Gs({
1243
1326
  className: "mt-0.5 flex max-w-[220px] items-start gap-1 text-right text-[11px] leading-snug text-red-600 dark:text-red-400",
1244
1327
  "data-catalog-qty-error": !0,
1245
1328
  children: [
1246
- /* @__PURE__ */ s(ar, { className: "mt-px h-3 w-3 shrink-0" }),
1329
+ /* @__PURE__ */ a(dn, { className: "mt-px h-3 w-3 shrink-0" }),
1247
1330
  o.message,
1248
- r && r > 0 ? ` — still ${r}` : ""
1331
+ n && n > 0 ? ` — still ${n.toLocaleString("en-US")}` : ""
1249
1332
  ]
1250
1333
  }
1251
1334
  ),
@@ -1256,23 +1339,23 @@ function Gs({
1256
1339
  "data-catalog-qty-remove": !0,
1257
1340
  className: "mt-1 flex max-w-[240px] flex-wrap items-center justify-end gap-1.5 text-right text-[11px] leading-snug text-slate-700 dark:text-slate-200",
1258
1341
  children: [
1259
- /* @__PURE__ */ s("span", { children: "Remove this line?" }),
1260
- /* @__PURE__ */ s(
1342
+ /* @__PURE__ */ a("span", { children: "Remove this line?" }),
1343
+ /* @__PURE__ */ a(
1261
1344
  "button",
1262
1345
  {
1263
1346
  type: "button",
1264
- onClick: p,
1347
+ onClick: h,
1265
1348
  className: "h-6 rounded border border-slate-200 px-2 text-[11px] text-slate-600 hover:bg-muted dark:border-border dark:text-slate-300",
1266
1349
  children: "Keep"
1267
1350
  }
1268
1351
  ),
1269
- /* @__PURE__ */ s(
1352
+ /* @__PURE__ */ a(
1270
1353
  "button",
1271
1354
  {
1272
1355
  type: "button",
1273
1356
  onClick: () => {
1274
- const m = o.row;
1275
- p(), st(e, "0", m, { confirmedRemove: !0 });
1357
+ const f = o.row;
1358
+ h(), lt(e, "0", f, { confirmedRemove: !0 });
1276
1359
  },
1277
1360
  className: "h-6 rounded bg-red-600 px-2 text-[11px] font-medium text-white hover:bg-red-700",
1278
1361
  children: "Remove"
@@ -1282,42 +1365,42 @@ function Gs({
1282
1365
  }
1283
1366
  )
1284
1367
  ] });
1285
- }, Jn = (e, t, r) => {
1286
- const n = `${e}:${t}`, l = Se[n], o = () => me((f) => {
1287
- if (!(n in f)) return f;
1288
- const v = { ...f };
1289
- return delete v[n], v;
1290
- }), p = r[t] == null ? "" : String(r[t]), c = L.find((f) => f.field === t), m = !Ot(c == null ? void 0 : c.type);
1368
+ }, Ur = (e, t, n) => {
1369
+ const r = `${e}:${t}`, l = he[r], o = () => Ee((p) => {
1370
+ if (!(r in p)) return p;
1371
+ const _ = { ...p };
1372
+ return delete _[r], _;
1373
+ }), h = n[t] == null ? "" : String(n[t]), c = te.find((p) => p.field === t), f = !Pt(c == null ? void 0 : c.type);
1291
1374
  return /* @__PURE__ */ u("span", { className: "inline-flex shrink-0 flex-col items-end", children: [
1292
- /* @__PURE__ */ s(
1375
+ /* @__PURE__ */ a(
1293
1376
  "input",
1294
1377
  {
1295
1378
  type: "number",
1296
1379
  min: 0,
1297
- step: m ? "0.01" : "any",
1298
- defaultValue: p,
1380
+ step: f ? "0.01" : "any",
1381
+ defaultValue: h,
1299
1382
  "aria-invalid": !!l || void 0,
1300
1383
  onFocus: o,
1301
- onBlur: (f) => {
1302
- const v = f.target.value;
1303
- if (v !== p) {
1304
- const _ = c, O = (_ == null ? void 0 : _.label) || M(t), x = cr(v, { type: _ == null ? void 0 : _.type, label: O }), A = x.ok ? (m ? os(v, O) : null) ?? B(t, x.value, r) : x.message;
1305
- if (A) {
1306
- f.target.value = p, me((Fe) => ({ ...Fe, [n]: A }));
1384
+ onBlur: (p) => {
1385
+ const _ = p.target.value;
1386
+ if (_ !== h) {
1387
+ const q = c, E = (q == null ? void 0 : q.label) || D(t), y = hn(_, { type: q == null ? void 0 : q.type, label: E }), K = y.ok ? (f ? ps(_, E) : null) ?? U(t, y.value, n) : y.message;
1388
+ if (K) {
1389
+ p.target.value = h, Ee((Re) => ({ ...Re, [r]: K }));
1307
1390
  return;
1308
1391
  }
1309
1392
  }
1310
- An(e, t, v);
1393
+ Vr(e, t, _);
1311
1394
  },
1312
- onKeyDown: (f) => {
1313
- f.key === "Enter" && f.currentTarget.blur();
1395
+ onKeyDown: (p) => {
1396
+ p.key === "Enter" && p.currentTarget.blur();
1314
1397
  },
1315
- className: C(
1398
+ className: I(
1316
1399
  "h-7 w-20 shrink-0 rounded border border-slate-200 bg-white px-2 text-right text-[12px] outline-none focus:border-nvr-cyan dark:border-border dark:bg-background",
1317
1400
  l && "border-red-400 dark:border-red-600"
1318
1401
  )
1319
1402
  },
1320
- `${n}:${p}`
1403
+ `${r}:${h}`
1321
1404
  ),
1322
1405
  l && /* @__PURE__ */ u(
1323
1406
  "span",
@@ -1326,58 +1409,58 @@ function Gs({
1326
1409
  className: "mt-0.5 flex max-w-[220px] items-start gap-1 text-right text-[11px] leading-snug text-red-600 dark:text-red-400",
1327
1410
  "data-catalog-cell-error": !0,
1328
1411
  children: [
1329
- /* @__PURE__ */ s(ar, { className: "mt-px h-3 w-3 shrink-0" }),
1412
+ /* @__PURE__ */ a(dn, { className: "mt-px h-3 w-3 shrink-0" }),
1330
1413
  l,
1331
- p !== "" ? ` — still ${p}` : ""
1414
+ h !== "" ? ` — still ${h}` : ""
1332
1415
  ]
1333
1416
  }
1334
1417
  )
1335
- ] }, n);
1418
+ ] }, r);
1336
1419
  };
1337
- return !g && q ? /* @__PURE__ */ u("div", { className: "space-y-2 py-1", "aria-busy": "true", children: [
1338
- /* @__PURE__ */ s("div", { className: "h-8 w-full animate-pulse rounded bg-slate-100 dark:bg-[hsl(var(--nvr-skeleton))]" }),
1339
- /* @__PURE__ */ s("div", { className: "h-8 w-2/3 animate-pulse rounded bg-slate-100 dark:bg-[hsl(var(--nvr-skeleton))]" })
1340
- ] }) : g ? /* @__PURE__ */ u("div", { ref: Er, className: "space-y-3", children: [
1341
- !b && /* @__PURE__ */ u(ve, { children: [
1420
+ return !g && W ? /* @__PURE__ */ u("div", { className: "space-y-2 py-1", "aria-busy": "true", children: [
1421
+ /* @__PURE__ */ a("div", { className: "h-8 w-full animate-pulse rounded bg-slate-100 dark:bg-[hsl(var(--nvr-skeleton))]" }),
1422
+ /* @__PURE__ */ a("div", { className: "h-8 w-2/3 animate-pulse rounded bg-slate-100 dark:bg-[hsl(var(--nvr-skeleton))]" })
1423
+ ] }) : g ? /* @__PURE__ */ u("div", { ref: Jn, className: "space-y-3", children: [
1424
+ !w && /* @__PURE__ */ u(Se, { children: [
1342
1425
  /* @__PURE__ */ u("div", { className: "rounded-lg border border-slate-200 text-[12px] dark:border-border", children: [
1343
1426
  /* @__PURE__ */ u("div", { className: "flex items-center gap-2 border-b border-slate-200 px-3 py-2 dark:border-border", children: [
1344
- /* @__PURE__ */ s(Rt, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" }),
1345
- /* @__PURE__ */ s(
1427
+ /* @__PURE__ */ a(Et, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" }),
1428
+ /* @__PURE__ */ a(
1346
1429
  "input",
1347
1430
  {
1348
- value: U,
1349
- onChange: (e) => Ae(e.target.value),
1431
+ value: X,
1432
+ onChange: (e) => ge(e.target.value),
1350
1433
  placeholder: "Search catalog…",
1351
1434
  className: "w-full bg-transparent text-[12px] outline-none placeholder:text-slate-400"
1352
1435
  }
1353
1436
  ),
1354
- te && /* @__PURE__ */ u(
1437
+ se && /* @__PURE__ */ u(
1355
1438
  "button",
1356
1439
  {
1357
1440
  type: "button",
1358
- "aria-pressed": re,
1359
- "aria-disabled": je === null ? "true" : void 0,
1441
+ "aria-pressed": ae,
1442
+ "aria-disabled": Oe === null ? "true" : void 0,
1360
1443
  onClick: () => {
1361
- je !== null && It(!Nr);
1444
+ Oe !== null && Vt(!$n);
1362
1445
  },
1363
- "data-catalog-in-stock": re ? "on" : "off",
1364
- "data-tip": je === null ? `Choose ${cn ?? "where stock is counted"} to show only items in stock there` : re ? "Showing only items with stock on hand — click to show everything" : "Show only items with stock on hand",
1365
- className: C(
1446
+ "data-catalog-in-stock": ae ? "on" : "off",
1447
+ "data-tip": Oe === null ? `Choose ${xr ?? "where stock is counted"} to show only items in stock there` : ae ? "Showing only items with stock on hand — click to show everything" : "Show only items with stock on hand",
1448
+ className: I(
1366
1449
  "inline-flex h-6 max-w-[220px] shrink-0 items-center gap-1 rounded border px-1.5 text-[11px] font-medium transition-colors duration-150 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan aria-disabled:cursor-not-allowed aria-disabled:opacity-50",
1367
- re ? "border-nvr-cyan/40 bg-nvr-cyan/10 text-[#00728d] dark:border-nvr-cyan/40 dark:bg-nvr-cyan/15 dark:text-nvr-cyan" : "border-slate-200 bg-white text-slate-600 hover:bg-muted dark:border-border dark:bg-background dark:text-slate-300"
1450
+ ae ? "border-nvr-cyan/40 bg-nvr-cyan/10 text-[#00728d] dark:border-nvr-cyan/40 dark:bg-nvr-cyan/15 dark:text-nvr-cyan" : "border-slate-200 bg-white text-slate-600 hover:bg-muted dark:border-border dark:bg-background dark:text-slate-300"
1368
1451
  ),
1369
1452
  children: [
1370
- pn ? /* @__PURE__ */ s(ce, { className: "h-3 w-3 shrink-0 animate-spin" }) : /* @__PURE__ */ s(zn, { className: "h-3 w-3 shrink-0" }),
1453
+ vr ? /* @__PURE__ */ a(ce, { className: "h-3 w-3 shrink-0 animate-spin" }) : /* @__PURE__ */ a(Dr, { className: "h-3 w-3 shrink-0" }),
1371
1454
  /* @__PURE__ */ u("span", { className: "truncate", children: [
1372
1455
  "In stock",
1373
- je !== null && Je && wr != null && /* @__PURE__ */ u(ve, { children: [
1456
+ Oe !== null && Je && qn != null && /* @__PURE__ */ u(Se, { children: [
1374
1457
  " at ",
1375
- /* @__PURE__ */ s(
1376
- Ss,
1458
+ /* @__PURE__ */ a(
1459
+ Es,
1377
1460
  {
1378
- parentCollection: N,
1461
+ parentCollection: x,
1379
1462
  field: Je,
1380
- id: wr
1463
+ id: qn
1381
1464
  }
1382
1465
  )
1383
1466
  ] })
@@ -1385,117 +1468,117 @@ function Gs({
1385
1468
  ]
1386
1469
  }
1387
1470
  ),
1388
- te && je === null && /* @__PURE__ */ s("span", { className: "shrink-0 text-[11px] text-slate-500 dark:text-slate-400", children: "Pick a place first" }),
1471
+ se && Oe === null && /* @__PURE__ */ a("span", { className: "shrink-0 text-[11px] text-slate-500 dark:text-slate-400", children: "Pick a place first" }),
1389
1472
  /* @__PURE__ */ u("span", { className: "shrink-0 rounded border border-slate-200 bg-slate-50 px-1.5 py-0.5 text-[10px] font-medium text-slate-500 dark:border-border dark:bg-muted dark:text-slate-400", children: [
1390
- Cn,
1473
+ Mr,
1391
1474
  " picked"
1392
1475
  ] }),
1393
- /* @__PURE__ */ s(ir, { show: Pe.customized, onReset: Pe.reset })
1476
+ /* @__PURE__ */ a(cn, { show: Le.customized, onReset: Le.reset })
1394
1477
  ] }),
1395
- Rr && // Sticky: the catalog list is tall and the page scroller carries it —
1478
+ Kn && // Sticky: the catalog list is tall and the page scroller carries it —
1396
1479
  // without this the labels scroll away and favorites/section rows
1397
1480
  // read as headerless columns. Opaque bg (not the /60 tint) so rows
1398
1481
  // never bleed through while pinned.
1399
1482
  /* @__PURE__ */ u(
1400
1483
  "div",
1401
1484
  {
1402
- ref: $n,
1485
+ ref: Er,
1403
1486
  className: "sticky top-0 z-[5] flex items-center gap-4 border-b border-slate-200 bg-slate-50 px-3 py-1 text-[10px] font-medium uppercase tracking-wide text-slate-500 dark:border-border dark:bg-muted dark:text-slate-400",
1404
1487
  children: [
1405
- a.favorites && /* @__PURE__ */ s("span", { className: "w-[18px] shrink-0" }),
1406
- $t(Pe, "item", "Item", "w-36 shrink-0"),
1488
+ s.favorites && /* @__PURE__ */ a("span", { className: "w-[18px] shrink-0" }),
1489
+ $t(Le, "item", "Item", "w-36 shrink-0"),
1407
1490
  _t.map((e) => {
1408
- const [t, r] = Lr(e);
1491
+ const [t, n] = In(e);
1409
1492
  return $t(
1410
- Pe,
1493
+ Le,
1411
1494
  e.field,
1412
- e.label ?? M(e.field.split(".")[0]),
1495
+ e.label ?? D(e.field.split(".")[0]),
1413
1496
  t,
1414
- r
1497
+ n
1415
1498
  );
1416
1499
  }),
1417
- tr.map(
1500
+ sn.map(
1418
1501
  (e) => $t(
1419
- Pe,
1502
+ Le,
1420
1503
  `rel:${e.key}`,
1421
- e.label ?? M(e.key),
1504
+ e.label ?? D(e.key),
1422
1505
  "w-20 shrink-0",
1423
1506
  "text-right"
1424
1507
  )
1425
1508
  ),
1426
- /* @__PURE__ */ s("span", { "aria-hidden": !0, className: "ml-auto" }),
1427
- /* @__PURE__ */ s("span", { "aria-hidden": !0, className: "w-3.5 shrink-0" }),
1428
- /* @__PURE__ */ s("span", { className: "w-20 shrink-0 text-right", children: "Qty" })
1509
+ /* @__PURE__ */ a("span", { "aria-hidden": !0, className: "ml-auto" }),
1510
+ /* @__PURE__ */ a("span", { "aria-hidden": !0, className: "w-3.5 shrink-0" }),
1511
+ /* @__PURE__ */ a("span", { className: "w-20 shrink-0 text-right", children: "Qty" })
1429
1512
  ]
1430
1513
  }
1431
1514
  ),
1432
- U.trim().length > 0 && nt.length === 0 && Ht && /* @__PURE__ */ u("div", { className: "flex items-center justify-center gap-2 border-b border-slate-100 px-3 py-3 text-slate-500 dark:border-border/50 dark:text-slate-400", children: [
1433
- /* @__PURE__ */ s(ce, { className: "h-3.5 w-3.5 animate-spin" }),
1515
+ X.trim().length > 0 && it.length === 0 && Gt && /* @__PURE__ */ u("div", { className: "flex items-center justify-center gap-2 border-b border-slate-100 px-3 py-3 text-slate-500 dark:border-border/50 dark:text-slate-400", children: [
1516
+ /* @__PURE__ */ a(ce, { className: "h-3.5 w-3.5 animate-spin" }),
1434
1517
  " Searching the catalog…"
1435
1518
  ] }),
1436
- U.trim().length > 0 && nt.length === 0 && !Ht && /* @__PURE__ */ s("p", { className: "px-3 py-4 text-center text-slate-500 dark:text-slate-400", children: re && Be.length > 0 ? /* @__PURE__ */ u(ve, { children: [
1519
+ X.trim().length > 0 && it.length === 0 && !Gt && /* @__PURE__ */ a("p", { className: "px-3 py-4 text-center text-slate-500 dark:text-slate-400", children: ae && Ve.length > 0 ? /* @__PURE__ */ u(Se, { children: [
1437
1520
  'Nothing in stock matches "',
1438
- U.trim(),
1521
+ X.trim(),
1439
1522
  '" —',
1440
1523
  " ",
1441
1524
  /* @__PURE__ */ u(
1442
1525
  "button",
1443
1526
  {
1444
1527
  type: "button",
1445
- onClick: () => It(!1),
1528
+ onClick: () => Vt(!1),
1446
1529
  className: "font-medium text-[#00728d] underline-offset-2 hover:underline dark:text-nvr-cyan",
1447
1530
  children: [
1448
1531
  "show ",
1449
- Be.length,
1532
+ Ve.length,
1450
1533
  " out of stock"
1451
1534
  ]
1452
1535
  }
1453
1536
  )
1454
- ] }) : /* @__PURE__ */ u(ve, { children: [
1537
+ ] }) : /* @__PURE__ */ u(Se, { children: [
1455
1538
  'No items match "',
1456
- U.trim(),
1539
+ X.trim(),
1457
1540
  '"'
1458
1541
  ] }) }),
1459
- U.trim().length > 0 && nt.length > 0 && /* @__PURE__ */ u(at, { children: [
1542
+ X.trim().length > 0 && it.length > 0 && /* @__PURE__ */ u(ot, { children: [
1460
1543
  /* @__PURE__ */ u("div", { className: "flex w-full items-center gap-1.5 border-b border-t border-slate-200 bg-sky-50/70 px-2 py-1.5 dark:border-border dark:bg-sky-900/10", children: [
1461
- /* @__PURE__ */ s(Rt, { className: "h-3 w-3 shrink-0 text-sky-500" }),
1462
- /* @__PURE__ */ s("span", { className: "text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: "Search results" }),
1463
- /* @__PURE__ */ s("span", { className: "rounded border border-slate-200 bg-white px-1.5 py-0.5 text-[10px] font-medium text-slate-500 dark:border-border dark:bg-background dark:text-slate-400", children: nt.length }),
1544
+ /* @__PURE__ */ a(Et, { className: "h-3 w-3 shrink-0 text-sky-500" }),
1545
+ /* @__PURE__ */ a("span", { className: "text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: "Search results" }),
1546
+ /* @__PURE__ */ a("span", { className: "rounded border border-slate-200 bg-white px-1.5 py-0.5 text-[10px] font-medium text-slate-500 dark:border-border dark:bg-background dark:text-slate-400", children: it.length }),
1464
1547
  /* @__PURE__ */ u("span", { className: "text-[11px] text-slate-500 dark:text-slate-400", children: [
1465
1548
  "across the entire catalog",
1466
- re ? ", in stock only" : "",
1549
+ ae ? ", in stock only" : "",
1467
1550
  " — enter a quantity to add"
1468
1551
  ] }),
1469
- Ht && /* @__PURE__ */ s(ce, { className: "h-3 w-3 shrink-0 animate-spin text-slate-400" })
1552
+ Gt && /* @__PURE__ */ a(ce, { className: "h-3 w-3 shrink-0 animate-spin text-slate-400" })
1470
1553
  ] }),
1471
- nt.map((e, t) => {
1472
- const r = String(e.id), n = Ne(r);
1554
+ it.map((e, t) => {
1555
+ const n = String(e.id), r = _e(n);
1473
1556
  return /* @__PURE__ */ u(
1474
1557
  "div",
1475
1558
  {
1476
- className: C(
1559
+ className: I(
1477
1560
  "flex items-center gap-4 border-b border-slate-100 px-3 py-1 dark:border-border/50",
1478
1561
  t % 2 === 0 ? "bg-white dark:bg-background" : "bg-slate-50/50 dark:bg-muted/30",
1479
- (n ?? 0) > 0 && "bg-nvr-cyan/5"
1562
+ (r ?? 0) > 0 && "bg-nvr-cyan/5"
1480
1563
  ),
1481
1564
  children: [
1482
- Jt(r),
1483
- sr(
1484
- r,
1485
- ze(J, e),
1565
+ Qt(n),
1566
+ on(
1567
+ n,
1568
+ ze(z, e),
1486
1569
  (() => {
1487
- const l = bn(e), o = un.has(r);
1488
- return !l && !o ? null : /* @__PURE__ */ u(ve, { children: [
1489
- o && /* @__PURE__ */ s(
1570
+ const l = Nr(e), o = yr.has(n);
1571
+ return !l && !o ? null : /* @__PURE__ */ u(Se, { children: [
1572
+ o && /* @__PURE__ */ a(
1490
1573
  "span",
1491
1574
  {
1492
1575
  "data-catalog-recent": !0,
1493
- "data-tip": `You added this in the last ${yt} days`,
1576
+ "data-tip": `You added this in the last ${kt} days`,
1494
1577
  className: "shrink-0 rounded bg-slate-100 px-1.5 py-0.5 text-[10px] font-medium text-slate-600 dark:bg-muted dark:text-slate-400",
1495
1578
  children: "Recent"
1496
1579
  }
1497
1580
  ),
1498
- l && /* @__PURE__ */ s(
1581
+ l && /* @__PURE__ */ a(
1499
1582
  "span",
1500
1583
  {
1501
1584
  "data-catalog-match-why": !0,
@@ -1507,611 +1590,612 @@ function Gs({
1507
1590
  )
1508
1591
  ] });
1509
1592
  })(),
1510
- he
1593
+ ue
1511
1594
  ),
1512
- nr(r, e, he),
1513
- /* @__PURE__ */ s("span", { className: "flex w-3.5 shrink-0 items-center justify-center", children: ie.has(r) && /* @__PURE__ */ s(ce, { className: "h-3 w-3 animate-spin text-slate-400" }) }),
1514
- Tt(r, e)
1595
+ ln(n, e, ue),
1596
+ /* @__PURE__ */ a("span", { className: "flex w-3.5 shrink-0 items-center justify-center", children: ie.has(n) && /* @__PURE__ */ a(ce, { className: "h-3 w-3 animate-spin text-slate-400" }) }),
1597
+ Rt(n, e)
1515
1598
  ]
1516
1599
  },
1517
- r
1600
+ n
1518
1601
  );
1519
1602
  })
1520
1603
  ] }),
1521
- D.length > 0 && !U.trim() && /* @__PURE__ */ u("p", { className: "px-3 py-6 text-center text-slate-400", children: [
1604
+ ee.length > 0 && !X.trim() && /* @__PURE__ */ u("p", { className: "px-3 py-6 text-center text-slate-400", children: [
1522
1605
  "Search the full catalog above, or select",
1523
1606
  " ",
1524
- D.map((e) => {
1607
+ ee.map((e) => {
1525
1608
  var t;
1526
- return ((t = P == null ? void 0 : P.fieldLabels) == null ? void 0 : t[e]) ?? M(e);
1609
+ return ((t = T == null ? void 0 : T.fieldLabels) == null ? void 0 : t[e]) ?? D(e);
1527
1610
  }).join(", "),
1528
1611
  " ",
1529
1612
  "to browse by category"
1530
1613
  ] }),
1531
- D.length === 0 && (qe || dt) && /* @__PURE__ */ u("div", { className: "flex items-center justify-center gap-2 py-6 text-slate-500 dark:text-slate-400", children: [
1532
- /* @__PURE__ */ s(ce, { className: "h-4 w-4 animate-spin" }),
1614
+ ee.length === 0 && (pn || ut) && /* @__PURE__ */ u("div", { className: "flex items-center justify-center gap-2 py-6 text-slate-500 dark:text-slate-400", children: [
1615
+ /* @__PURE__ */ a(ce, { className: "h-4 w-4 animate-spin" }),
1533
1616
  " Loading catalog…"
1534
1617
  ] }),
1535
- D.length === 0 && !qe && !dt && jt.length === 0 && /* @__PURE__ */ s("p", { className: "px-3 py-6 text-center text-slate-500 dark:text-slate-400", children: re && de.length > 0 ? /* @__PURE__ */ u(ve, { children: [
1618
+ ee.length === 0 && !pn && !ut && Ft.length === 0 && /* @__PURE__ */ a("p", { className: "px-3 py-6 text-center text-slate-500 dark:text-slate-400", children: ae && re.length > 0 ? /* @__PURE__ */ u(Se, { children: [
1536
1619
  "Nothing in this catalog is in stock here —",
1537
1620
  " ",
1538
1621
  /* @__PURE__ */ u(
1539
1622
  "button",
1540
1623
  {
1541
1624
  type: "button",
1542
- onClick: () => It(!1),
1625
+ onClick: () => Vt(!1),
1543
1626
  className: "font-medium text-[#00728d] underline-offset-2 hover:underline dark:text-nvr-cyan",
1544
1627
  children: [
1545
1628
  "show all ",
1546
- de.length
1629
+ re.length
1547
1630
  ]
1548
1631
  }
1549
1632
  )
1550
1633
  ] }) : "No catalog items" }),
1551
- a.favorites && /* @__PURE__ */ u(at, { children: [
1634
+ s.favorites && /* @__PURE__ */ u(ot, { children: [
1552
1635
  /* @__PURE__ */ u("div", { className: "flex w-full items-center gap-1.5 border-b border-slate-200 bg-amber-50/70 px-2 py-1 dark:border-border dark:bg-amber-900/10", children: [
1553
1636
  /* @__PURE__ */ u(
1554
1637
  "button",
1555
1638
  {
1556
1639
  type: "button",
1557
- onClick: () => xe((e) => {
1640
+ onClick: () => $e((e) => {
1558
1641
  const t = new Set(e);
1559
1642
  return t.has("__favorites__") ? t.delete("__favorites__") : t.add("__favorites__"), t;
1560
1643
  }),
1561
1644
  className: "flex min-w-0 flex-1 items-center gap-1.5 py-0.5 text-left",
1562
1645
  children: [
1563
- /* @__PURE__ */ s(
1564
- or,
1646
+ /* @__PURE__ */ a(
1647
+ mn,
1565
1648
  {
1566
- className: C(
1649
+ className: I(
1567
1650
  "h-3 w-3 shrink-0 text-slate-400 transition-transform",
1568
- !se.has("__favorites__") && "rotate-90"
1651
+ !fe.has("__favorites__") && "rotate-90"
1569
1652
  )
1570
1653
  }
1571
1654
  ),
1572
- /* @__PURE__ */ s(it, { className: "h-3 w-3 shrink-0 fill-amber-400 text-amber-400" }),
1573
- /* @__PURE__ */ s("span", { className: "text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: "Favorites" }),
1574
- /* @__PURE__ */ s("span", { className: "rounded border border-slate-200 bg-white px-1.5 py-0.5 text-[10px] font-medium text-slate-500 dark:border-border dark:bg-background dark:text-slate-400", children: Yt.length })
1655
+ /* @__PURE__ */ a(dt, { className: "h-3 w-3 shrink-0 fill-amber-400 text-amber-400" }),
1656
+ /* @__PURE__ */ a("span", { className: "text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: "Favorites" }),
1657
+ /* @__PURE__ */ a("span", { className: "rounded border border-slate-200 bg-white px-1.5 py-0.5 text-[10px] font-medium text-slate-500 dark:border-border dark:bg-background dark:text-slate-400", children: Xt.length })
1575
1658
  ]
1576
1659
  }
1577
1660
  ),
1578
- /* @__PURE__ */ s(
1661
+ /* @__PURE__ */ a(
1579
1662
  "button",
1580
1663
  {
1581
- ref: yr,
1664
+ ref: vn,
1582
1665
  type: "button",
1583
- onClick: () => xr(!0),
1666
+ onClick: () => Nn(!0),
1584
1667
  className: "shrink-0 rounded border border-amber-200 bg-white px-2 py-0.5 text-[10px] font-semibold text-amber-700 transition-colors hover:border-amber-300 hover:bg-amber-50 dark:border-amber-400/30 dark:bg-transparent dark:text-amber-300 dark:hover:bg-amber-400/10",
1585
1668
  children: "Manage"
1586
1669
  }
1587
1670
  )
1588
1671
  ] }),
1589
- !se.has("__favorites__") && Yt.length === 0 && /* @__PURE__ */ s("p", { className: "border-b border-slate-100 px-3 py-2 text-center text-[11px] text-slate-400 dark:border-border/50", children: Ze.length > 0 ? "None of your favorites are in stock here." : "No favorites yet — Manage lets you search the full catalog and star items." }),
1590
- !se.has("__favorites__") && Yt.map((e, t) => {
1591
- const r = String(e.id), n = Ne(r), l = Zt(r);
1672
+ !fe.has("__favorites__") && Xt.length === 0 && /* @__PURE__ */ a("p", { className: "border-b border-slate-100 px-3 py-2 text-center text-[11px] text-slate-400 dark:border-border/50", children: Xe.length > 0 ? "None of your favorites are in stock here." : "No favorites yet — Manage lets you search the full catalog and star items." }),
1673
+ !fe.has("__favorites__") && Xt.map((e, t) => {
1674
+ const n = String(e.id), r = _e(n), l = en(n);
1592
1675
  return /* @__PURE__ */ u(
1593
1676
  "div",
1594
1677
  {
1595
- className: C(
1678
+ className: I(
1596
1679
  "flex items-center gap-4 border-b border-slate-100 px-3 py-1 dark:border-border/50",
1597
1680
  t % 2 === 0 ? "bg-white dark:bg-background" : "bg-slate-50/50 dark:bg-muted/30",
1598
- (n ?? 0) > 0 && "bg-nvr-cyan/5",
1681
+ (r ?? 0) > 0 && "bg-nvr-cyan/5",
1599
1682
  l && "bg-amber-50 dark:bg-amber-900/15"
1600
1683
  ),
1601
1684
  children: [
1602
- Jt(r),
1603
- sr(r, ze(J, e)),
1604
- nr(r, e),
1605
- /* @__PURE__ */ s("span", { className: "flex w-3.5 shrink-0 items-center justify-center", children: ie.has(r) ? /* @__PURE__ */ s(ce, { className: "h-3 w-3 animate-spin text-slate-400" }) : l && /* @__PURE__ */ s(
1606
- De,
1685
+ Qt(n),
1686
+ on(n, ze(z, e)),
1687
+ ln(n, e),
1688
+ /* @__PURE__ */ a("span", { className: "flex w-3.5 shrink-0 items-center justify-center", children: ie.has(n) ? /* @__PURE__ */ a(ce, { className: "h-3 w-3 animate-spin text-slate-400" }) : l && /* @__PURE__ */ a(
1689
+ Be,
1607
1690
  {
1608
1691
  className: "h-3.5 w-3.5 text-amber-500",
1609
- "aria-label": `${Gt} ${l.available} — ${l.qty} requested`
1692
+ "aria-label": `${tn} ${l.available} — ${l.qty} requested`
1610
1693
  }
1611
1694
  ) }),
1612
- Tt(r, e)
1695
+ Rt(n, e)
1613
1696
  ]
1614
1697
  },
1615
- r
1698
+ n
1616
1699
  );
1617
1700
  })
1618
1701
  ] }),
1619
- D.length === 0 && jt.map((e) => {
1620
- const t = se.has(e.name), r = e.items.reduce(
1621
- (n, l) => n + ((Ne(l.id) ?? 0) > 0 ? 1 : 0),
1702
+ ee.length === 0 && Ft.map((e) => {
1703
+ const t = fe.has(e.name), n = e.items.reduce(
1704
+ (r, l) => r + ((_e(l.id) ?? 0) > 0 ? 1 : 0),
1622
1705
  0
1623
1706
  );
1624
- return /* @__PURE__ */ u(at, { children: [
1707
+ return /* @__PURE__ */ u(ot, { children: [
1625
1708
  /* @__PURE__ */ u(
1626
1709
  "button",
1627
1710
  {
1628
1711
  type: "button",
1629
- onClick: () => xe((n) => {
1630
- const l = new Set(n);
1712
+ onClick: () => $e((r) => {
1713
+ const l = new Set(r);
1631
1714
  return l.has(e.name) ? l.delete(e.name) : l.add(e.name), l;
1632
1715
  }),
1633
1716
  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",
1634
1717
  children: [
1635
- /* @__PURE__ */ s(
1636
- or,
1718
+ /* @__PURE__ */ a(
1719
+ mn,
1637
1720
  {
1638
- className: C(
1721
+ className: I(
1639
1722
  "h-3 w-3 shrink-0 text-slate-400 transition-transform",
1640
1723
  !t && "rotate-90"
1641
1724
  )
1642
1725
  }
1643
1726
  ),
1644
- /* @__PURE__ */ s("span", { className: "text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: e.name }),
1645
- /* @__PURE__ */ s("span", { className: "rounded border border-slate-200 bg-white px-1.5 py-0.5 text-[10px] font-medium text-slate-500 dark:border-border dark:bg-background dark:text-slate-400", children: e.items.length }),
1646
- r > 0 && /* @__PURE__ */ u("span", { className: "rounded bg-nvr-cyan/10 px-1.5 py-0.5 text-[10px] font-semibold text-[#00728d] dark:bg-nvr-cyan/15 dark:text-nvr-cyan", children: [
1647
- r,
1727
+ /* @__PURE__ */ a("span", { className: "text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: e.name }),
1728
+ /* @__PURE__ */ a("span", { className: "rounded border border-slate-200 bg-white px-1.5 py-0.5 text-[10px] font-medium text-slate-500 dark:border-border dark:bg-background dark:text-slate-400", children: e.items.length }),
1729
+ n > 0 && /* @__PURE__ */ u("span", { className: "rounded bg-nvr-cyan/10 px-1.5 py-0.5 text-[10px] font-semibold text-[#00728d] dark:bg-nvr-cyan/15 dark:text-nvr-cyan", children: [
1730
+ n,
1648
1731
  " picked"
1649
1732
  ] })
1650
1733
  ]
1651
1734
  }
1652
1735
  ),
1653
- !t && e.items.map((n, l) => {
1654
- const o = Ne(n.id), p = Zt(n.id);
1736
+ !t && e.items.map((r, l) => {
1737
+ const o = _e(r.id), h = en(r.id);
1655
1738
  return /* @__PURE__ */ u(
1656
1739
  "div",
1657
1740
  {
1658
- className: C(
1741
+ className: I(
1659
1742
  "flex items-center gap-4 border-b border-slate-100 px-3 py-1 dark:border-border/50",
1660
1743
  l % 2 === 0 ? "bg-white dark:bg-background" : "bg-slate-50/50 dark:bg-muted/30",
1661
1744
  (o ?? 0) > 0 && "bg-nvr-cyan/5",
1662
- p && "bg-amber-50 dark:bg-amber-900/15"
1745
+ h && "bg-amber-50 dark:bg-amber-900/15"
1663
1746
  ),
1664
1747
  children: [
1665
- Jt(n.id),
1666
- sr(n.id, n.label),
1667
- nr(n.id, n.row),
1668
- /* @__PURE__ */ s("span", { className: "flex w-3.5 shrink-0 items-center justify-center", children: ie.has(n.id) ? /* @__PURE__ */ s(ce, { className: "h-3 w-3 animate-spin text-slate-400" }) : p && /* @__PURE__ */ s(
1669
- De,
1748
+ Qt(r.id),
1749
+ on(r.id, r.label),
1750
+ ln(r.id, r.row),
1751
+ /* @__PURE__ */ a("span", { className: "flex w-3.5 shrink-0 items-center justify-center", children: ie.has(r.id) ? /* @__PURE__ */ a(ce, { className: "h-3 w-3 animate-spin text-slate-400" }) : h && /* @__PURE__ */ a(
1752
+ Be,
1670
1753
  {
1671
1754
  className: "h-3.5 w-3.5 text-amber-500",
1672
- "aria-label": `${Gt} ${p.available} — ${p.qty} requested`
1755
+ "aria-label": `${tn} ${h.available} — ${h.qty} requested`
1673
1756
  }
1674
1757
  ) }),
1675
- Tt(n.id, n.row)
1758
+ Rt(r.id, r.row)
1676
1759
  ]
1677
1760
  },
1678
- n.id
1761
+ r.id
1679
1762
  );
1680
1763
  })
1681
1764
  ] }, e.name);
1682
1765
  })
1683
1766
  ] }),
1684
- (a.builders ?? []).filter((e) => Gr(e.show_when, i)).map((e) => /* @__PURE__ */ s(
1685
- _s,
1767
+ (s.builders ?? []).filter((e) => ir(e.show_when, N)).map((e) => /* @__PURE__ */ a(
1768
+ Ps,
1686
1769
  {
1687
1770
  builder: e,
1688
- defaultItemField: a.item_field,
1771
+ defaultItemField: s.item_field,
1689
1772
  catalogCol: g,
1690
- catalogFields: T,
1691
- tmpl: J,
1692
- currentQty: Ne,
1693
- addQty: (t, r, n) => st(t, String(r), n),
1694
- qtyStep: Ot(le) ? 1 : "any",
1695
- readOnly: b
1773
+ catalogFields: A,
1774
+ tmpl: z,
1775
+ currentQty: _e,
1776
+ addQty: (t, n, r) => lt(t, String(n), r),
1777
+ qtyStep: Pt(M) ? 1 : "any",
1778
+ readOnly: w
1696
1779
  },
1697
1780
  e.label
1698
1781
  ))
1699
1782
  ] }),
1700
1783
  /* @__PURE__ */ u("div", { className: "rounded-lg border border-slate-200 text-[12px] dark:border-border", children: [
1701
1784
  /* @__PURE__ */ u("div", { className: "flex items-center justify-between gap-2 border-b border-slate-200 bg-slate-50 px-3 py-2 dark:border-border dark:bg-muted", children: [
1702
- /* @__PURE__ */ s("span", { className: "text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: "Summary" }),
1703
- !b && /* @__PURE__ */ u("div", { className: "flex items-center gap-2", onClick: (e) => e.stopPropagation(), children: [
1704
- a.upload_template && !z && ee && N && /* @__PURE__ */ s(
1705
- ts,
1785
+ /* @__PURE__ */ a("span", { className: "text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: "Summary" }),
1786
+ !w && /* @__PURE__ */ u("div", { className: "flex items-center gap-2", onClick: (e) => e.stopPropagation(), children: [
1787
+ s.upload_template && !P && ye && x && /* @__PURE__ */ a(
1788
+ ds,
1706
1789
  {
1707
- collection: N,
1790
+ collection: x,
1708
1791
  templateFilter: (e) => {
1709
1792
  var t;
1710
- return e.name === a.upload_template && ((t = e.reimport) == null ? void 0 : t.enabled) === !0;
1793
+ return e.name === s.upload_template && ((t = e.reimport) == null ? void 0 : t.enabled) === !0;
1711
1794
  },
1712
1795
  getLabel: (e) => {
1713
1796
  var t;
1714
1797
  return ((t = e.reimport) == null ? void 0 : t.button_label) ?? e.button_label;
1715
1798
  },
1716
- onParsed: (e, t) => ee(e, t),
1799
+ onParsed: (e, t) => ye(e, t),
1717
1800
  compact: !0
1718
1801
  }
1719
1802
  ),
1720
- /* @__PURE__ */ s("div", { className: "w-64", children: /* @__PURE__ */ s(
1721
- fs,
1803
+ /* @__PURE__ */ a("div", { className: "w-64", children: /* @__PURE__ */ a(
1804
+ ws,
1722
1805
  {
1723
1806
  collection: g,
1724
1807
  value: null,
1725
- onChange: (e) => void Kn(e),
1726
- placeholder: "+ Add any item…"
1808
+ onChange: (e) => void Wr(e),
1809
+ placeholder: "+ Add any item…",
1810
+ displayTemplate: Ks(z, s.columns)
1727
1811
  }
1728
1812
  ) })
1729
1813
  ] })
1730
1814
  ] }),
1731
- pe.length === 0 ? /* @__PURE__ */ s("p", { className: "px-3 py-4 text-center text-slate-400", children: "Nothing picked yet" }) : (() => {
1732
- const e = Tr.filter((c) => !c.format), t = e[0], r = e.slice(1), n = Tr.filter((c) => !!c.format), l = (c, m) => m === "presence" ? c == null || c === "" || Number(c) === 0 ? "No" : "Yes" : c === !0 || c === "true" ? "✓" : c === !1 || c === "false" || c == null || c === "" ? "—" : ke(c, m), o = (c, m) => m ? $t(
1733
- we,
1734
- m,
1815
+ be.length === 0 ? /* @__PURE__ */ a("p", { className: "px-3 py-4 text-center text-slate-400", children: "Nothing picked yet" }) : (() => {
1816
+ const e = Ln.filter((c) => !c.format), t = e[0], n = e.slice(1), r = Ln.filter((c) => !!c.format), l = (c, f) => f === "presence" ? c == null || c === "" || Number(c) === 0 ? "No" : "Yes" : c === !0 || c === "true" ? "✓" : c === !1 || c === "false" || c == null || c === "" ? "—" : Ne(c, f), o = (c, f) => f ? $t(
1817
+ ve,
1818
+ f,
1735
1819
  c,
1736
1820
  "w-20 shrink-0",
1737
1821
  "text-right text-[11px] font-medium text-slate-500 dark:text-slate-400"
1738
- ) : /* @__PURE__ */ s("span", { className: "w-20 shrink-0 text-right text-[11px] font-medium text-slate-500 dark:text-slate-400", children: c }), p = (c) => Y.includes(c) && !b ? void 0 : `s:${c}`;
1822
+ ) : /* @__PURE__ */ a("span", { className: "w-20 shrink-0 text-right text-[11px] font-medium text-slate-500 dark:text-slate-400", children: c }), h = (c) => Z.includes(c) && !w ? void 0 : `s:${c}`;
1739
1823
  return /* @__PURE__ */ u("div", { children: [
1740
1824
  /* @__PURE__ */ u("div", { className: "flex items-center gap-4 border-b border-slate-200 px-3 py-1.5 dark:border-border", children: [
1741
1825
  /* @__PURE__ */ u("span", { className: "flex flex-1 items-center gap-1 text-[11px] font-medium text-slate-500 dark:text-slate-400", children: [
1742
1826
  "Item",
1743
- b && /* @__PURE__ */ s(
1744
- ir,
1827
+ w && /* @__PURE__ */ a(
1828
+ cn,
1745
1829
  {
1746
- show: we.customized,
1747
- onReset: we.reset,
1830
+ show: ve.customized,
1831
+ onReset: ve.reset,
1748
1832
  className: "-my-1"
1749
1833
  }
1750
1834
  )
1751
1835
  ] }),
1752
- Ft.map((c) => /* @__PURE__ */ s(at, { children: o(M(c), p(c)) }, c)),
1753
- o(M(G)),
1754
- We.map((c) => /* @__PURE__ */ s(at, { children: o(M(c), `s:${c}`) }, c)),
1755
- !b && /* @__PURE__ */ s("span", { className: "-my-1 flex w-6 shrink-0 justify-end", children: /* @__PURE__ */ s(ir, { show: we.customized, onReset: we.reset }) })
1836
+ Ot.map((c) => /* @__PURE__ */ a(ot, { children: o(D(c), h(c)) }, c)),
1837
+ o(D(J)),
1838
+ Ue.map((c) => /* @__PURE__ */ a(ot, { children: o(D(c), `s:${c}`) }, c)),
1839
+ !w && /* @__PURE__ */ a("span", { className: "-my-1 flex w-6 shrink-0 justify-end", children: /* @__PURE__ */ a(cn, { show: ve.customized, onReset: ve.reset }) })
1756
1840
  ] }),
1757
- pe.map((c, m) => {
1758
- const f = c.row.id != null ? String(c.row.id) : null, v = f != null && ft.has(f), _ = v ? null : Zt(c.key), O = v ? null : wn(c.key);
1841
+ be.map((c, f) => {
1842
+ const p = c.row.id != null ? String(c.row.id) : null, _ = p != null && bt.has(p), q = _ ? null : en(c.key), E = _ ? null : jr(c.key);
1759
1843
  return /* @__PURE__ */ u(
1760
1844
  "div",
1761
1845
  {
1762
- className: C(
1846
+ className: I(
1763
1847
  "border-b border-slate-100 px-3 py-2 last:border-b-0 dark:border-border/50",
1764
- m % 2 === 0 ? "bg-white dark:bg-background" : "bg-slate-50/50 dark:bg-muted/30",
1765
- _ && "bg-amber-50 dark:bg-amber-900/15",
1766
- O && "bg-red-50/70 dark:bg-red-900/15",
1767
- v && "opacity-60"
1848
+ f % 2 === 0 ? "bg-white dark:bg-background" : "bg-slate-50/50 dark:bg-muted/30",
1849
+ q && "bg-amber-50 dark:bg-amber-900/15",
1850
+ E && "bg-red-50/70 dark:bg-red-900/15",
1851
+ _ && "opacity-60"
1768
1852
  ),
1769
1853
  children: [
1770
1854
  /* @__PURE__ */ u(
1771
1855
  "div",
1772
1856
  {
1773
- className: C(
1857
+ className: I(
1774
1858
  "flex items-center gap-4",
1775
- v && "line-through decoration-slate-400"
1859
+ _ && "line-through decoration-slate-400"
1776
1860
  ),
1777
1861
  children: [
1778
- Ar(
1862
+ zn(
1779
1863
  c.key,
1780
- Kr(c.key),
1864
+ jt(c.key),
1781
1865
  "shrink-0 font-semibold text-slate-800 dark:text-slate-100"
1782
1866
  ),
1783
- He && !v && (f == null || ut.has(f)) && /* @__PURE__ */ s(
1867
+ Ze && !_ && (p == null || ft.has(p)) && /* @__PURE__ */ a(
1784
1868
  "span",
1785
1869
  {
1786
- "data-catalog-staged": f == null ? "new" : "edited",
1870
+ "data-catalog-staged": p == null ? "new" : "edited",
1787
1871
  "data-tip": "Applies when you save the record",
1788
1872
  className: "shrink-0 rounded bg-amber-100 px-1.5 py-px text-[10px] font-semibold text-amber-800 dark:bg-amber-400/15 dark:text-amber-300",
1789
- children: f == null ? "New" : "Edited"
1873
+ children: p == null ? "New" : "Edited"
1790
1874
  }
1791
1875
  ),
1792
- O && /* @__PURE__ */ s(
1876
+ E && /* @__PURE__ */ a(
1793
1877
  "span",
1794
1878
  {
1795
1879
  className: "shrink-0",
1796
1880
  "data-tip": `This line was in the failed submission
1797
- ${O}`,
1881
+ ${E}`,
1798
1882
  "data-submission-error": !0,
1799
- children: /* @__PURE__ */ s(ar, { className: "h-3.5 w-3.5 text-red-500", strokeWidth: 2 })
1883
+ children: /* @__PURE__ */ a(dn, { className: "h-3.5 w-3.5 text-red-500", strokeWidth: 2 })
1800
1884
  }
1801
1885
  ),
1802
- t && /* @__PURE__ */ s(
1803
- Xr,
1886
+ t && /* @__PURE__ */ a(
1887
+ lr,
1804
1888
  {
1805
- text: ke(St(Ie(c.key), t.field), void 0),
1889
+ text: Ne(St(Ie(c.key), t.field), void 0),
1806
1890
  className: "min-w-0 flex-1 text-slate-600 dark:text-slate-300"
1807
1891
  }
1808
1892
  ),
1809
- !t && /* @__PURE__ */ s("span", { className: "flex-1" }),
1810
- r.map((x) => {
1811
- const A = St(Ie(c.key), x.field);
1812
- return A == null || A === "" ? null : /* @__PURE__ */ s(
1893
+ !t && /* @__PURE__ */ a("span", { className: "flex-1" }),
1894
+ n.map((y) => {
1895
+ const K = St(Ie(c.key), y.field);
1896
+ return K == null || K === "" ? null : /* @__PURE__ */ a(
1813
1897
  "span",
1814
1898
  {
1815
1899
  className: "shrink-0 rounded bg-slate-100 px-1.5 py-0.5 text-[10.5px] font-medium text-slate-600 dark:bg-muted dark:text-slate-300",
1816
- children: String(A)
1900
+ children: String(K)
1817
1901
  },
1818
- x.field
1902
+ y.field
1819
1903
  );
1820
1904
  }),
1821
- Ft.map(
1822
- (x) => {
1823
- var A;
1824
- return En(c.key, x) ? Jn(c.key, x, c.row) : /* @__PURE__ */ s(
1905
+ Ot.map(
1906
+ (y) => {
1907
+ var K;
1908
+ return zr(c.key, y) ? Ur(c.key, y, c.row) : /* @__PURE__ */ a(
1825
1909
  "span",
1826
1910
  {
1827
- "data-catalog-locked": !b && Y.includes(x) ? x : void 0,
1828
- "data-tip": !b && Y.includes(x) ? "Set by the catalog — only an administrator can change it" : void 0,
1829
- ...we.box(
1830
- `s:${x}`,
1911
+ "data-catalog-locked": !w && Z.includes(y) ? y : void 0,
1912
+ "data-tip": !w && Z.includes(y) ? "Set by the catalog — only an administrator can change it" : void 0,
1913
+ ...ve.box(
1914
+ `s:${y}`,
1831
1915
  "w-20 shrink-0",
1832
1916
  "truncate text-right tabular-nums text-slate-600 dark:text-slate-300"
1833
1917
  ),
1834
- children: ke(c.row[x], (A = a.field_formats) == null ? void 0 : A[x])
1918
+ children: Ne(c.row[y], (K = s.field_formats) == null ? void 0 : K[y])
1835
1919
  },
1836
- x
1920
+ y
1837
1921
  );
1838
1922
  }
1839
1923
  ),
1840
1924
  /* @__PURE__ */ u("span", { className: "inline-flex w-20 shrink-0 items-center justify-end gap-1", children: [
1841
- ie.has(c.key) && /* @__PURE__ */ s(ce, { className: "h-3 w-3 animate-spin text-slate-400" }),
1842
- Tt(c.key, Ie(c.key))
1925
+ ie.has(c.key) && /* @__PURE__ */ a(ce, { className: "h-3 w-3 animate-spin text-slate-400" }),
1926
+ Rt(c.key, Ie(c.key))
1843
1927
  ] }),
1844
- We.map((x) => {
1845
- var Dr, Mr;
1846
- if (v)
1847
- return /* @__PURE__ */ s(
1928
+ Ue.map((y) => {
1929
+ var er, tr;
1930
+ if (_)
1931
+ return /* @__PURE__ */ a(
1848
1932
  "span",
1849
1933
  {
1850
1934
  "data-tip": "Not counted — this line is removed when you save",
1851
- ...we.box(
1852
- `s:${x}`,
1935
+ ...ve.box(
1936
+ `s:${y}`,
1853
1937
  "w-20 shrink-0",
1854
1938
  "text-right tabular-nums text-slate-400 dark:text-slate-500"
1855
1939
  ),
1856
1940
  children: "—"
1857
1941
  },
1858
- x
1942
+ y
1859
1943
  );
1860
- const A = c.row[x], Fe = A != null && A !== "" ? A : Le(((Dr = a.compute_fields) == null ? void 0 : Dr[x]) ?? "", c.row);
1861
- return /* @__PURE__ */ s(
1944
+ const K = c.row[y], Re = K != null && K !== "" ? K : Pe(((er = s.compute_fields) == null ? void 0 : er[y]) ?? "", c.row);
1945
+ return /* @__PURE__ */ a(
1862
1946
  "span",
1863
1947
  {
1864
- ...we.box(
1865
- `s:${x}`,
1948
+ ...ve.box(
1949
+ `s:${y}`,
1866
1950
  "w-20 shrink-0",
1867
1951
  "truncate text-right tabular-nums text-slate-600 dark:text-slate-300"
1868
1952
  ),
1869
- children: ke(Fe, (Mr = a.field_formats) == null ? void 0 : Mr[x])
1953
+ children: Ne(Re, (tr = s.field_formats) == null ? void 0 : tr[y])
1870
1954
  },
1871
- x
1955
+ y
1872
1956
  );
1873
1957
  }),
1874
- !b && v && /* @__PURE__ */ s(
1958
+ !w && _ && /* @__PURE__ */ a(
1875
1959
  "button",
1876
1960
  {
1877
1961
  type: "button",
1878
- onClick: () => w == null ? void 0 : w.cancelPendingDelete(d, h, f),
1962
+ onClick: () => v == null ? void 0 : v.cancelPendingDelete(i, m, p),
1879
1963
  className: "shrink-0 rounded px-1.5 py-0.5 text-[11px] font-medium text-nvr-navy underline dark:text-nvr-cyan",
1880
1964
  children: "Undo"
1881
1965
  }
1882
1966
  ),
1883
- !b && !v && /* @__PURE__ */ s(
1967
+ !w && !_ && /* @__PURE__ */ a(
1884
1968
  "button",
1885
1969
  {
1886
1970
  type: "button",
1887
1971
  title: "Remove (applies on Save)",
1888
1972
  onClick: () => {
1889
- if (!z && w && f != null) {
1890
- w.queueDelete(d, h, f);
1973
+ if (!P && v && p != null) {
1974
+ v.queueDelete(i, m, p);
1891
1975
  return;
1892
1976
  }
1893
- st(c.key, "0", {}, { confirmedRemove: !0 });
1977
+ lt(c.key, "0", {}, { confirmedRemove: !0 });
1894
1978
  },
1895
1979
  className: "w-6 shrink-0 rounded p-0.5 text-slate-300 transition-colors hover:text-red-500",
1896
- children: /* @__PURE__ */ s(Pt, { className: "mx-auto h-3.5 w-3.5" })
1980
+ children: /* @__PURE__ */ a(Lt, { className: "mx-auto h-3.5 w-3.5" })
1897
1981
  }
1898
1982
  )
1899
1983
  ]
1900
1984
  }
1901
1985
  ),
1902
- (n.length > 0 || Or.length > 0 || vt.length > 0) && /* @__PURE__ */ u("div", { className: "mt-1 flex flex-wrap items-baseline gap-x-4 gap-y-0.5 pl-0.5 text-[11px]", children: [
1903
- n.map((x) => /* @__PURE__ */ u("span", { className: "whitespace-nowrap", children: [
1904
- /* @__PURE__ */ s("span", { className: "text-slate-500 dark:text-muted-foreground", children: x.label ?? M(x.field.split(".")[0]) }),
1986
+ (r.length > 0 || An.length > 0 || vt.length > 0) && /* @__PURE__ */ u("div", { className: "mt-1 flex flex-wrap items-baseline gap-x-4 gap-y-0.5 pl-0.5 text-[11px]", children: [
1987
+ r.map((y) => /* @__PURE__ */ u("span", { className: "whitespace-nowrap", children: [
1988
+ /* @__PURE__ */ a("span", { className: "text-slate-500 dark:text-muted-foreground", children: y.label ?? D(y.field.split(".")[0]) }),
1905
1989
  " ",
1906
- /* @__PURE__ */ s("span", { className: "font-medium tabular-nums text-slate-700 dark:text-slate-200", children: l(St(Ie(c.key), x.field), x.format) })
1907
- ] }, x.field)),
1908
- Or.map((x) => /* @__PURE__ */ u("span", { className: "whitespace-nowrap", children: [
1909
- /* @__PURE__ */ s("span", { className: "text-slate-500 dark:text-muted-foreground", children: x.label ?? M(x.key) }),
1990
+ /* @__PURE__ */ a("span", { className: "font-medium tabular-nums text-slate-700 dark:text-slate-200", children: l(St(Ie(c.key), y.field), y.format) })
1991
+ ] }, y.field)),
1992
+ An.map((y) => /* @__PURE__ */ u("span", { className: "whitespace-nowrap", children: [
1993
+ /* @__PURE__ */ a("span", { className: "text-slate-500 dark:text-muted-foreground", children: y.label ?? D(y.key) }),
1910
1994
  " ",
1911
- /* @__PURE__ */ s("span", { className: "font-medium tabular-nums text-slate-700 dark:text-slate-200", children: l(tt(x.key, c.key), x.format) })
1912
- ] }, x.key)),
1913
- qn(c.row),
1914
- xn(c.row).map((x) => /* @__PURE__ */ u(
1995
+ /* @__PURE__ */ a("span", { className: "font-medium tabular-nums text-slate-700 dark:text-slate-200", children: l(st(y.key, c.key), y.format) })
1996
+ ] }, y.key)),
1997
+ Pr(c.row),
1998
+ _r(c.row).map((y) => /* @__PURE__ */ u(
1915
1999
  "span",
1916
2000
  {
1917
2001
  className: "inline-flex items-center gap-1 whitespace-nowrap rounded bg-amber-50 px-1.5 py-px text-[10.5px] font-medium text-amber-700 dark:bg-amber-500/10 dark:text-amber-300",
1918
- "data-catalog-row-flag": x,
2002
+ "data-catalog-row-flag": y,
1919
2003
  children: [
1920
- /* @__PURE__ */ s(De, { className: "h-3 w-3" }),
1921
- x
2004
+ /* @__PURE__ */ a(Be, { className: "h-3 w-3" }),
2005
+ y
1922
2006
  ]
1923
2007
  },
1924
- x
2008
+ y
1925
2009
  )),
1926
- vt.map((x) => {
1927
- const A = _n(x, c);
2010
+ vt.map((y) => {
2011
+ const K = Or(y, c);
1928
2012
  return /* @__PURE__ */ u("span", { className: "whitespace-nowrap", children: [
1929
- /* @__PURE__ */ s("span", { className: "text-slate-500 dark:text-muted-foreground", children: x.label ?? M(x.field) }),
2013
+ /* @__PURE__ */ a("span", { className: "text-slate-500 dark:text-muted-foreground", children: y.label ?? D(y.field) }),
1930
2014
  " ",
1931
- /* @__PURE__ */ s("span", { className: "font-medium text-slate-700 dark:text-slate-200", children: l(A, x.format) })
1932
- ] }, x.field);
2015
+ /* @__PURE__ */ a("span", { className: "font-medium text-slate-700 dark:text-slate-200", children: l(K, y.format) })
2016
+ ] }, y.field);
1933
2017
  })
1934
2018
  ] }),
1935
- _ && /* @__PURE__ */ u("p", { className: "mt-1 flex items-center gap-1 pl-0.5 text-[11px] font-medium text-amber-600 dark:text-amber-400", children: [
1936
- /* @__PURE__ */ s(De, { className: "h-3 w-3 shrink-0" }),
1937
- Gt,
2019
+ q && /* @__PURE__ */ u("p", { className: "mt-1 flex items-center gap-1 pl-0.5 text-[11px] font-medium text-amber-600 dark:text-amber-400", children: [
2020
+ /* @__PURE__ */ a(Be, { className: "h-3 w-3 shrink-0" }),
2021
+ tn,
1938
2022
  " is ",
1939
- ke(_.available, "number"),
2023
+ Ne(q.available, "number"),
1940
2024
  " —",
1941
2025
  " ",
1942
- ke(_.qty, "number"),
2026
+ Ne(q.qty, "number"),
1943
2027
  " requested"
1944
2028
  ] }),
1945
- !v && vs(
2029
+ !_ && Rs(
1946
2030
  {
1947
2031
  ...c.row,
1948
2032
  ...Object.fromEntries(
1949
- We.filter((x) => c.row[x] == null || c.row[x] === "").map((x) => {
1950
- var A;
2033
+ Ue.filter((y) => c.row[y] == null || c.row[y] === "").map((y) => {
2034
+ var K;
1951
2035
  return [
1952
- x,
1953
- Le(((A = a.compute_fields) == null ? void 0 : A[x]) ?? "", c.row)
2036
+ y,
2037
+ Pe(((K = s.compute_fields) == null ? void 0 : K[y]) ?? "", c.row)
1954
2038
  ];
1955
2039
  })
1956
2040
  )
1957
2041
  },
1958
- G,
1959
- We.length > 0 ? We : Ft
2042
+ J,
2043
+ Ue.length > 0 ? Ue : Ot
1960
2044
  ) && /* @__PURE__ */ u(
1961
2045
  "p",
1962
2046
  {
1963
2047
  "data-catalog-unpriced": !0,
1964
2048
  className: "mt-1 flex items-center gap-1 pl-0.5 text-[11px] font-medium text-amber-600 dark:text-amber-400",
1965
2049
  children: [
1966
- /* @__PURE__ */ s(De, { className: "h-3 w-3 shrink-0" }),
2050
+ /* @__PURE__ */ a(Be, { className: "h-3 w-3 shrink-0" }),
1967
2051
  "No catalog price: check the price or hand-price it"
1968
2052
  ]
1969
2053
  }
1970
2054
  ),
1971
- v && /* @__PURE__ */ s("p", { className: "mt-1 pl-0.5 text-[11px] text-red-500", children: "Removed — applies when you save" })
2055
+ _ && /* @__PURE__ */ a("p", { className: "mt-1 pl-0.5 text-[11px] text-red-500", children: "Removed — applies when you save" })
1972
2056
  ]
1973
2057
  },
1974
2058
  c.key
1975
2059
  );
1976
2060
  }),
1977
2061
  (() => {
1978
- const c = pe.filter((_) => {
1979
- const O = _.row.id != null ? String(_.row.id) : null;
1980
- return !(O != null && ft.has(O));
1981
- }), m = (_) => xs(
1982
- c.map((O) => O.row),
1983
- _,
1984
- a.compute_fields
1985
- ), f = (_) => {
1986
- var O;
1987
- return ((O = a.field_formats) == null ? void 0 : O[_]) ?? "number";
1988
- }, v = (_) => /* @__PURE__ */ s(
2062
+ const c = be.filter((q) => {
2063
+ const E = q.row.id != null ? String(q.row.id) : null;
2064
+ return !(E != null && bt.has(E));
2065
+ }), f = (q) => qs(
2066
+ c.map((E) => E.row),
2067
+ q,
2068
+ s.compute_fields
2069
+ ), p = (q) => {
2070
+ var E;
2071
+ return ((E = s.field_formats) == null ? void 0 : E[q]) ?? "number";
2072
+ }, _ = (q) => /* @__PURE__ */ a(
1989
2073
  "span",
1990
2074
  {
1991
- ...we.box(
1992
- `s:${_}`,
2075
+ ...ve.box(
2076
+ `s:${q}`,
1993
2077
  "w-20 shrink-0",
1994
2078
  "truncate text-right text-[12px] font-semibold tabular-nums text-slate-800 dark:text-slate-100"
1995
2079
  ),
1996
- children: ke(m(_), f(_))
2080
+ children: Ne(f(q), p(q))
1997
2081
  },
1998
- _
2082
+ q
1999
2083
  );
2000
2084
  return /* @__PURE__ */ u("div", { className: "flex items-center gap-4 border-t border-slate-200 bg-slate-50 px-3 py-1.5 dark:border-border dark:bg-muted/40", children: [
2001
- /* @__PURE__ */ s("span", { className: "flex-1 text-[11px] font-semibold uppercase tracking-wide text-slate-500 dark:text-slate-400", children: "Total" }),
2002
- Ft.map((_) => {
2003
- const O = p(_);
2004
- return O ? /* @__PURE__ */ s("span", { ...we.box(O, "w-20 shrink-0") }, _) : /* @__PURE__ */ s("span", { className: "w-20 shrink-0" }, _);
2085
+ /* @__PURE__ */ a("span", { className: "flex-1 text-[11px] font-semibold uppercase tracking-wide text-slate-500 dark:text-slate-400", children: "Total" }),
2086
+ Ot.map((q) => {
2087
+ const E = h(q);
2088
+ return E ? /* @__PURE__ */ a("span", { ...ve.box(E, "w-20 shrink-0") }, q) : /* @__PURE__ */ a("span", { className: "w-20 shrink-0" }, q);
2005
2089
  }),
2006
- /* @__PURE__ */ s("span", { className: "w-20 shrink-0 text-right text-[12px] font-semibold tabular-nums text-slate-800 dark:text-slate-100", children: ke(m(G), "number") }),
2007
- We.map(v),
2008
- !b && /* @__PURE__ */ s("span", { className: "w-6 shrink-0" })
2090
+ /* @__PURE__ */ a("span", { className: "w-20 shrink-0 text-right text-[12px] font-semibold tabular-nums text-slate-800 dark:text-slate-100", children: Ne(f(J), "number") }),
2091
+ Ue.map(_),
2092
+ !w && /* @__PURE__ */ a("span", { className: "w-6 shrink-0" })
2009
2093
  ] });
2010
2094
  })()
2011
2095
  ] });
2012
2096
  })()
2013
2097
  ] }),
2014
- on && g && /* @__PURE__ */ s(
2015
- $s,
2098
+ br && g && /* @__PURE__ */ a(
2099
+ As,
2016
2100
  {
2017
2101
  catalogCol: g,
2018
- tmpl: J,
2019
- sectionBy: a.section_by,
2020
- sectionM2M: V,
2021
- pinnedSet: Ct,
2022
- pinnedIds: $e,
2023
- savingIds: pt,
2024
- relatedCols: (a.favorites_manager_columns ?? []).map((e) => (a.related_columns ?? []).find((t) => t.key === e)).filter((e) => !!e),
2025
- parentDraft: i,
2026
- onToggle: (e) => void pr(e),
2027
- onClose: () => xr(!1),
2028
- anchor: yr.current
2102
+ tmpl: z,
2103
+ sectionBy: s.section_by,
2104
+ sectionM2M: d,
2105
+ pinnedSet: zt,
2106
+ pinnedIds: Te,
2107
+ savingIds: yt,
2108
+ relatedCols: (s.favorites_manager_columns ?? []).map((e) => (s.related_columns ?? []).find((t) => t.key === e)).filter((e) => !!e),
2109
+ parentDraft: N,
2110
+ onToggle: (e) => void wn(e),
2111
+ onClose: () => Nn(!1),
2112
+ anchor: vn.current
2029
2113
  }
2030
2114
  )
2031
2115
  ] }) : /* @__PURE__ */ u("p", { className: "py-1 text-[12px] text-slate-400", children: [
2032
2116
  'Catalog picker: field "',
2033
- a.item_field,
2117
+ s.item_field,
2034
2118
  '" does not resolve to an M2O relation on',
2035
2119
  " ",
2036
- d
2120
+ i
2037
2121
  ] });
2038
2122
  }
2039
- function _s({
2040
- builder: d,
2041
- defaultItemField: h,
2042
- catalogCol: y,
2043
- catalogFields: N,
2044
- tmpl: a,
2045
- currentQty: b,
2046
- addQty: k,
2047
- qtyStep: j,
2048
- readOnly: w
2123
+ function Ps({
2124
+ builder: i,
2125
+ defaultItemField: m,
2126
+ catalogCol: b,
2127
+ catalogFields: x,
2128
+ tmpl: S,
2129
+ currentQty: s,
2130
+ addQty: w,
2131
+ qtyStep: k,
2132
+ readOnly: j
2049
2133
  }) {
2050
- const P = Lt(), ee = d.item_field ?? h, [Y, _e] = H(!1), [Z, z] = H({}), [ne, G] = H("1"), [se, xe] = H(!1), Oe = F(
2134
+ const v = Kt(), T = i.item_field ?? m, [ye, Z] = Y(!1), [G, Ae] = Y({}), [P, qe] = Y("1"), [J, fe] = Y(!1), $e = F(
2051
2135
  () => [
2052
2136
  "id",
2053
- ee,
2054
- ...d.attributes.flatMap((q) => [`${q.field}.id`, `${q.field}.${q.label_field}`])
2137
+ T,
2138
+ ...i.attributes.flatMap(($) => [`${$.field}.id`, `${$.field}.${$.label_field}`])
2055
2139
  ].join(","),
2056
- [ee, d.attributes]
2057
- ), { data: U = [], isLoading: Ae } = K({
2140
+ [T, i.attributes]
2141
+ ), { data: je = [], isLoading: X } = C({
2058
2142
  queryKey: [
2059
2143
  "catalog-builder",
2060
- d.collection,
2061
- Oe,
2062
- JSON.stringify(d.filter ?? null)
2144
+ i.collection,
2145
+ $e,
2146
+ JSON.stringify(i.filter ?? null)
2063
2147
  ],
2064
- queryFn: () => P.request(
2065
- R(`/items/${d.collection}`, {
2148
+ queryFn: () => v.request(
2149
+ R(`/items/${i.collection}`, {
2066
2150
  limit: 2e3,
2067
- fields: Oe,
2068
- ...d.filter ? { filter: JSON.stringify(d.filter) } : {}
2151
+ fields: $e,
2152
+ ...i.filter ? { filter: JSON.stringify(i.filter) } : {}
2069
2153
  })
2070
- ).then((q) => q.data ?? []),
2071
- enabled: Y,
2154
+ ).then(($) => $.data ?? []),
2155
+ enabled: ye,
2072
2156
  staleTime: 6e4
2073
- }), ye = (q, g) => {
2074
- var le;
2075
- const L = q[g];
2076
- if (L == null) return null;
2077
- if (typeof L == "object") {
2078
- const B = L, $ = ((le = d.attributes.find((J) => J.field === g)) == null ? void 0 : le.label_field) ?? "id";
2079
- return { id: String(B.id ?? ""), label: String(B[$] ?? B.id ?? "") };
2157
+ }), ge = ($, W) => {
2158
+ var te;
2159
+ const g = $[W];
2160
+ if (g == null) return null;
2161
+ if (typeof g == "object") {
2162
+ const M = g, U = ((te = i.attributes.find((O) => O.field === W)) == null ? void 0 : te.label_field) ?? "id";
2163
+ return { id: String(M.id ?? ""), label: String(M[U] ?? M.id ?? "") };
2080
2164
  }
2081
- return { id: String(L), label: String(L) };
2082
- }, ue = (q) => U.filter(
2083
- (g) => d.attributes.slice(0, q).every((L) => {
2084
- var B;
2085
- const le = Z[L.field];
2086
- return le ? ((B = ye(g, L.field)) == null ? void 0 : B.id) === le : !0;
2165
+ return { id: String(g), label: String(g) };
2166
+ }, ke = ($) => je.filter(
2167
+ (W) => i.attributes.slice(0, $).every((g) => {
2168
+ var M;
2169
+ const te = G[g.field];
2170
+ return te ? ((M = ge(W, g.field)) == null ? void 0 : M.id) === te : !0;
2087
2171
  })
2088
- ), ie = d.attributes.every((q) => Z[q.field]), ae = ie ? U.find(
2089
- (q) => d.attributes.every((g) => {
2090
- var L;
2091
- return ((L = ye(q, g.field)) == null ? void 0 : L.id) === Z[g.field];
2172
+ ), le = i.attributes.every(($) => G[$.field]), ie = le ? je.find(
2173
+ ($) => i.attributes.every((W) => {
2174
+ var g;
2175
+ return ((g = ge($, W.field)) == null ? void 0 : g.id) === G[W.field];
2092
2176
  })
2093
- ) : void 0, Q = (ae == null ? void 0 : ae[ee]) != null ? String(ae[ee]) : null, { data: X } = K({
2094
- queryKey: ["catalog-builder-item", y, N, Q],
2095
- queryFn: () => P.request(
2096
- R(`/items/${y}`, {
2097
- filter: JSON.stringify({ id: { _eq: Q } }),
2098
- fields: N,
2177
+ ) : void 0, V = (ie == null ? void 0 : ie[T]) != null ? String(ie[T]) : null, { data: oe } = C({
2178
+ queryKey: ["catalog-builder-item", b, x, V],
2179
+ queryFn: () => v.request(
2180
+ R(`/items/${b}`, {
2181
+ filter: JSON.stringify({ id: { _eq: V } }),
2182
+ fields: x,
2099
2183
  limit: 1
2100
2184
  })
2101
- ).then((q) => {
2102
- var g;
2103
- return ((g = q.data) == null ? void 0 : g[0]) ?? null;
2185
+ ).then(($) => {
2186
+ var W;
2187
+ return ((W = $.data) == null ? void 0 : W[0]) ?? null;
2104
2188
  }),
2105
- enabled: !!Q,
2189
+ enabled: !!V,
2106
2190
  staleTime: 6e4
2107
- }), Se = Number(ne), me = !!Q && !!X && !se && ne.trim() !== "" && Number.isFinite(Se) && Se > 0 && (j === "any" || Number.isInteger(Se));
2108
- async function Ke() {
2109
- if (!(!me || !Q || !X)) {
2110
- xe(!0);
2191
+ }), de = Number(P), he = !!V && !!oe && !J && P.trim() !== "" && Number.isFinite(de) && de > 0 && (k === "any" || Number.isInteger(de));
2192
+ async function Ee() {
2193
+ if (!(!he || !V || !oe)) {
2194
+ fe(!0);
2111
2195
  try {
2112
- await k(Q, (b(Q) ?? 0) + Se, X), z({}), G("1");
2196
+ await w(V, (s(V) ?? 0) + de, oe), Ae({}), qe("1");
2113
2197
  } finally {
2114
- xe(!1);
2198
+ fe(!1);
2115
2199
  }
2116
2200
  }
2117
2201
  }
@@ -2120,73 +2204,73 @@ function _s({
2120
2204
  "button",
2121
2205
  {
2122
2206
  type: "button",
2123
- onClick: () => _e((q) => !q),
2207
+ onClick: () => Z(($) => !$),
2124
2208
  className: "flex w-full items-center gap-1.5 rounded-t-lg bg-slate-100/80 px-2 py-1.5 text-left dark:bg-muted",
2125
2209
  children: [
2126
- /* @__PURE__ */ s(
2127
- or,
2210
+ /* @__PURE__ */ a(
2211
+ mn,
2128
2212
  {
2129
- className: C(
2213
+ className: I(
2130
2214
  "h-3 w-3 shrink-0 text-slate-400 transition-transform",
2131
- Y && "rotate-90"
2215
+ ye && "rotate-90"
2132
2216
  )
2133
2217
  }
2134
2218
  ),
2135
- /* @__PURE__ */ s("span", { className: "text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: d.label })
2219
+ /* @__PURE__ */ a("span", { className: "text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: i.label })
2136
2220
  ]
2137
2221
  }
2138
2222
  ),
2139
- Y && /* @__PURE__ */ s("div", { className: "space-y-2 border-t border-slate-200 p-3 dark:border-border", children: Ae ? /* @__PURE__ */ u("div", { className: "flex items-center gap-2 py-2 text-slate-400", children: [
2140
- /* @__PURE__ */ s(ce, { className: "h-4 w-4 animate-spin" }),
2223
+ ye && /* @__PURE__ */ a("div", { className: "space-y-2 border-t border-slate-200 p-3 dark:border-border", children: X ? /* @__PURE__ */ u("div", { className: "flex items-center gap-2 py-2 text-slate-400", children: [
2224
+ /* @__PURE__ */ a(ce, { className: "h-4 w-4 animate-spin" }),
2141
2225
  " Loading options…"
2142
2226
  ] }) : /* @__PURE__ */ u("div", { className: "flex flex-wrap items-end gap-3", children: [
2143
- d.attributes.map((q, g) => {
2144
- const L = /* @__PURE__ */ new Map();
2145
- for (const B of ue(g)) {
2146
- const $ = ye(B, q.field);
2147
- $ != null && $.id && L.set($.id, $.label);
2227
+ i.attributes.map(($, W) => {
2228
+ const g = /* @__PURE__ */ new Map();
2229
+ for (const M of ke(W)) {
2230
+ const U = ge(M, $.field);
2231
+ U != null && U.id && g.set(U.id, U.label);
2148
2232
  }
2149
- const le = [...L.entries()].sort(
2150
- ([, B], [, $]) => B.localeCompare($, void 0, { numeric: !0 })
2233
+ const te = [...g.entries()].sort(
2234
+ ([, M], [, U]) => M.localeCompare(U, void 0, { numeric: !0 })
2151
2235
  );
2152
- return /* @__PURE__ */ s(
2153
- qs,
2236
+ return /* @__PURE__ */ a(
2237
+ Ls,
2154
2238
  {
2155
- label: M(q.field),
2156
- value: Z[q.field] ?? null,
2157
- valueLabel: Z[q.field] ? L.get(Z[q.field]) ?? Z[q.field] : null,
2158
- options: le,
2159
- disabled: g > 0 && !Z[d.attributes[g - 1].field],
2160
- onChange: (B) => z(($) => {
2161
- const J = {};
2162
- for (let E = 0; E < g; E++) {
2163
- const oe = d.attributes[E].field;
2164
- $[oe] && (J[oe] = $[oe]);
2239
+ label: D($.field),
2240
+ value: G[$.field] ?? null,
2241
+ valueLabel: G[$.field] ? g.get(G[$.field]) ?? G[$.field] : null,
2242
+ options: te,
2243
+ disabled: W > 0 && !G[i.attributes[W - 1].field],
2244
+ onChange: (M) => Ae((U) => {
2245
+ const O = {};
2246
+ for (let z = 0; z < W; z++) {
2247
+ const L = i.attributes[z].field;
2248
+ U[L] && (O[L] = U[L]);
2165
2249
  }
2166
- return B && (J[q.field] = B), J;
2250
+ return M && (O[$.field] = M), O;
2167
2251
  })
2168
2252
  },
2169
- q.field
2253
+ $.field
2170
2254
  );
2171
2255
  }),
2172
- /* @__PURE__ */ s("div", { className: "flex min-h-[28px] flex-1 items-center gap-2", children: Q && X ? /* @__PURE__ */ u(ve, { children: [
2173
- /* @__PURE__ */ s("span", { className: "min-w-0 flex-1 truncate text-slate-700 dark:text-slate-200", children: ze(a, X) }),
2174
- (b(Q) ?? 0) > 0 && /* @__PURE__ */ u("span", { className: "rounded bg-nvr-cyan/10 px-1.5 py-0.5 text-[10px] font-semibold text-[#00728d] dark:bg-nvr-cyan/15 dark:text-nvr-cyan", children: [
2175
- b(Q),
2256
+ /* @__PURE__ */ a("div", { className: "flex min-h-[28px] flex-1 items-center gap-2", children: V && oe ? /* @__PURE__ */ u(Se, { children: [
2257
+ /* @__PURE__ */ a("span", { className: "min-w-0 flex-1 truncate text-slate-700 dark:text-slate-200", children: ze(S, oe) }),
2258
+ (s(V) ?? 0) > 0 && /* @__PURE__ */ u("span", { className: "rounded bg-nvr-cyan/10 px-1.5 py-0.5 text-[10px] font-semibold text-[#00728d] dark:bg-nvr-cyan/15 dark:text-nvr-cyan", children: [
2259
+ s(V),
2176
2260
  " in summary"
2177
2261
  ] }),
2178
- !w && /* @__PURE__ */ u(ve, { children: [
2179
- /* @__PURE__ */ s(
2262
+ !j && /* @__PURE__ */ u(Se, { children: [
2263
+ /* @__PURE__ */ a(
2180
2264
  "input",
2181
2265
  {
2182
2266
  type: "number",
2183
2267
  min: 0,
2184
- step: j,
2185
- value: ne,
2268
+ step: k,
2269
+ value: P,
2186
2270
  "aria-label": "Quantity to add",
2187
- onChange: (q) => G(q.target.value),
2188
- onKeyDown: (q) => {
2189
- q.key === "Enter" && (q.preventDefault(), Ke());
2271
+ onChange: ($) => qe($.target.value),
2272
+ onKeyDown: ($) => {
2273
+ $.key === "Enter" && ($.preventDefault(), Ee());
2190
2274
  },
2191
2275
  className: "h-7 w-20 shrink-0 rounded border border-slate-200 bg-white px-2 text-right text-[12px] outline-none focus:border-nvr-cyan dark:border-border dark:bg-background"
2192
2276
  }
@@ -2195,315 +2279,315 @@ function _s({
2195
2279
  "button",
2196
2280
  {
2197
2281
  type: "button",
2198
- onClick: () => void Ke(),
2199
- disabled: !me,
2282
+ onClick: () => void Ee(),
2283
+ disabled: !he,
2200
2284
  className: "flex h-7 shrink-0 items-center gap-1 rounded bg-nvr-cyan px-2.5 text-[12px] font-medium text-white hover:bg-nvr-cyan/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan focus-visible:ring-offset-1 disabled:opacity-50",
2201
2285
  children: [
2202
- se ? /* @__PURE__ */ s(ce, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ s(Qn, { className: "h-3.5 w-3.5" }),
2286
+ J ? /* @__PURE__ */ a(ce, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ a(Hr, { className: "h-3.5 w-3.5" }),
2203
2287
  "Add"
2204
2288
  ]
2205
2289
  }
2206
2290
  )
2207
2291
  ] })
2208
- ] }) : ie ? /* @__PURE__ */ s("span", { className: "text-slate-400", children: "No matching item for this combination" }) : /* @__PURE__ */ s("span", { className: "text-slate-400", children: "Pick each attribute to resolve an item" }) })
2292
+ ] }) : le ? /* @__PURE__ */ a("span", { className: "text-slate-400", children: "No matching item for this combination" }) : /* @__PURE__ */ a("span", { className: "text-slate-400", children: "Pick each attribute to resolve an item" }) })
2209
2293
  ] }) })
2210
2294
  ] });
2211
2295
  }
2212
- function Ss({
2213
- parentCollection: d,
2214
- field: h,
2215
- id: y
2296
+ function Es({
2297
+ parentCollection: i,
2298
+ field: m,
2299
+ id: b
2216
2300
  }) {
2217
- var j;
2218
- const N = Lt(), { data: a = [] } = K({
2219
- queryKey: ["collection-relations", d],
2220
- queryFn: () => N.request(R(`/collections/${d}`)).then((w) => {
2221
- var P;
2222
- return ((P = w.data) == null ? void 0 : P.relations) ?? [];
2301
+ var k;
2302
+ const x = Kt(), { data: S = [] } = C({
2303
+ queryKey: ["collection-relations", i],
2304
+ queryFn: () => x.request(R(`/collections/${i}`)).then((j) => {
2305
+ var v;
2306
+ return ((v = j.data) == null ? void 0 : v.relations) ?? [];
2223
2307
  }),
2224
- enabled: !!d,
2308
+ enabled: !!i,
2225
2309
  staleTime: 10 * 6e4
2226
- }), b = ((j = a.find(
2227
- (w) => w.many_collection === d && w.many_field === h && !w.junction_field
2228
- )) == null ? void 0 : j.one_collection) ?? null, { data: k } = K({
2229
- queryKey: ["col-meta", b],
2230
- queryFn: () => N.request(R(`/collections/${b}`)).then((w) => w.data),
2231
- enabled: !!b,
2310
+ }), s = ((k = S.find(
2311
+ (j) => j.many_collection === i && j.many_field === m && !j.junction_field
2312
+ )) == null ? void 0 : k.one_collection) ?? null, { data: w } = C({
2313
+ queryKey: ["col-meta", s],
2314
+ queryFn: () => x.request(R(`/collections/${s}`)).then((j) => j.data),
2315
+ enabled: !!s,
2232
2316
  staleTime: 3e5
2233
2317
  });
2234
- return b ? /* @__PURE__ */ s(hs, { collection: b, id: y, displayTemplate: k == null ? void 0 : k.display_template }) : /* @__PURE__ */ u(ve, { children: [
2318
+ return s ? /* @__PURE__ */ a(Ns, { collection: s, id: b, displayTemplate: w == null ? void 0 : w.display_template }) : /* @__PURE__ */ u(Se, { children: [
2235
2319
  "this ",
2236
- M(h)
2320
+ D(m)
2237
2321
  ] });
2238
2322
  }
2239
- function Xr({
2240
- text: d,
2241
- highlight: h,
2242
- className: y,
2243
- ...N
2323
+ function lr({
2324
+ text: i,
2325
+ highlight: m,
2326
+ className: b,
2327
+ ...x
2244
2328
  }) {
2245
- const a = rs(d);
2246
- return /* @__PURE__ */ s("span", { ref: a, className: C("truncate", y), ...N, children: h ? /* @__PURE__ */ s(dr, { text: d, query: h }) : d });
2329
+ const S = cs(i);
2330
+ return /* @__PURE__ */ a("span", { ref: S, className: I("truncate", b), ...x, children: m ? /* @__PURE__ */ a(fn, { text: i, query: m }) : i });
2247
2331
  }
2248
- function qs({
2249
- label: d,
2250
- value: h,
2251
- valueLabel: y,
2252
- options: N,
2253
- disabled: a,
2254
- onChange: b
2332
+ function Ls({
2333
+ label: i,
2334
+ value: m,
2335
+ valueLabel: b,
2336
+ options: x,
2337
+ disabled: S,
2338
+ onChange: s
2255
2339
  }) {
2256
- const [k, j] = H(!1), w = Ee(null);
2257
- return Te(() => {
2258
- if (!k) return;
2259
- const P = (ee) => {
2260
- w.current && !w.current.contains(ee.target) && j(!1);
2340
+ const [w, k] = Y(!1), j = pe(null);
2341
+ return xe(() => {
2342
+ if (!w) return;
2343
+ const v = (T) => {
2344
+ j.current && !j.current.contains(T.target) && k(!1);
2261
2345
  };
2262
- return document.addEventListener("mousedown", P), () => document.removeEventListener("mousedown", P);
2263
- }, [k]), /* @__PURE__ */ u("div", { ref: w, className: "relative", children: [
2264
- /* @__PURE__ */ s("p", { className: "mb-1 text-[10px] font-medium text-slate-500 dark:text-slate-400", children: d }),
2346
+ return document.addEventListener("mousedown", v), () => document.removeEventListener("mousedown", v);
2347
+ }, [w]), /* @__PURE__ */ u("div", { ref: j, className: "relative", children: [
2348
+ /* @__PURE__ */ a("p", { className: "mb-1 text-[10px] font-medium text-slate-500 dark:text-slate-400", children: i }),
2265
2349
  /* @__PURE__ */ u(
2266
2350
  "button",
2267
2351
  {
2268
2352
  type: "button",
2269
- disabled: a,
2270
- onClick: () => j((P) => !P),
2353
+ disabled: S,
2354
+ onClick: () => k((v) => !v),
2271
2355
  className: "flex w-44 items-center justify-between rounded border border-slate-200 bg-white px-2 py-1.5 text-left text-[12px] text-slate-700 hover:border-slate-300 disabled:opacity-50 dark:border-border dark:bg-background dark:text-slate-200",
2272
2356
  children: [
2273
- /* @__PURE__ */ s("span", { className: C("truncate", !y && "text-slate-400"), children: y ?? "Select…" }),
2274
- /* @__PURE__ */ s(Bn, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" })
2357
+ /* @__PURE__ */ a("span", { className: I("truncate", !b && "text-slate-400"), children: b ?? "Select…" }),
2358
+ /* @__PURE__ */ a(Yr, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" })
2275
2359
  ]
2276
2360
  }
2277
2361
  ),
2278
- k && /* @__PURE__ */ u("div", { className: "absolute z-50 mt-1 max-h-52 w-44 overflow-y-auto rounded-md border border-border bg-popover py-1 shadow-md", children: [
2279
- h && /* @__PURE__ */ u(
2362
+ w && /* @__PURE__ */ u("div", { className: "absolute z-50 mt-1 max-h-52 w-44 overflow-y-auto rounded-md border border-border bg-popover py-1 shadow-md", children: [
2363
+ m && /* @__PURE__ */ u(
2280
2364
  "button",
2281
2365
  {
2282
2366
  type: "button",
2283
2367
  onClick: () => {
2284
- b(null), j(!1);
2368
+ s(null), k(!1);
2285
2369
  },
2286
2370
  className: "flex w-full items-center gap-1.5 border-b border-slate-100 px-2 py-1 text-left text-[12px] text-slate-500 hover:bg-muted dark:border-border dark:text-slate-400",
2287
2371
  children: [
2288
- /* @__PURE__ */ s(Pt, { className: "h-3 w-3 text-slate-400" }),
2372
+ /* @__PURE__ */ a(Lt, { className: "h-3 w-3 text-slate-400" }),
2289
2373
  " Clear"
2290
2374
  ]
2291
2375
  }
2292
2376
  ),
2293
- N.map(([P, ee]) => /* @__PURE__ */ s(
2377
+ x.map(([v, T]) => /* @__PURE__ */ a(
2294
2378
  "button",
2295
2379
  {
2296
2380
  type: "button",
2297
2381
  onClick: () => {
2298
- b(P), j(!1);
2382
+ s(v), k(!1);
2299
2383
  },
2300
- className: C(
2384
+ className: I(
2301
2385
  "block w-full truncate px-2 py-1 text-left text-[12px] hover:bg-muted",
2302
- P === h ? "font-medium text-nvr-cyan" : "text-slate-700 dark:text-slate-200"
2386
+ v === m ? "font-medium text-nvr-cyan" : "text-slate-700 dark:text-slate-200"
2303
2387
  ),
2304
- children: ee
2388
+ children: T
2305
2389
  },
2306
- P
2390
+ v
2307
2391
  ))
2308
2392
  ] })
2309
2393
  ] });
2310
2394
  }
2311
- function $s({
2312
- catalogCol: d,
2313
- tmpl: h,
2314
- sectionBy: y,
2315
- sectionM2M: N,
2316
- pinnedSet: a,
2317
- pinnedIds: b,
2318
- savingIds: k,
2319
- relatedCols: j,
2320
- parentDraft: w,
2321
- onToggle: P,
2322
- onClose: ee,
2323
- anchor: Y
2395
+ function As({
2396
+ catalogCol: i,
2397
+ tmpl: m,
2398
+ sectionBy: b,
2399
+ sectionM2M: x,
2400
+ pinnedSet: S,
2401
+ pinnedIds: s,
2402
+ savingIds: w,
2403
+ relatedCols: k,
2404
+ parentDraft: j,
2405
+ onToggle: v,
2406
+ onClose: T,
2407
+ anchor: ye
2324
2408
  }) {
2325
- const _e = Lt(), [Z, z] = H(""), [ne, G] = H(""), [se, xe] = H(1), Oe = Ee(null);
2326
- Te(() => {
2327
- const i = setTimeout(() => G(Z), 300);
2328
- return () => clearTimeout(i);
2329
- }, [Z]), Te(() => xe(1), [ne]), Te(() => {
2330
- var i;
2331
- (i = Oe.current) == null || i.focus();
2332
- }, []), Te(() => {
2333
- const i = (S) => {
2334
- S.key === "Escape" && (S.stopPropagation(), ee());
2409
+ const Z = Kt(), [G, Ae] = Y(""), [P, qe] = Y(""), [J, fe] = Y(1), $e = pe(null);
2410
+ xe(() => {
2411
+ const d = setTimeout(() => qe(G), 300);
2412
+ return () => clearTimeout(d);
2413
+ }, [G]), xe(() => fe(1), [P]), xe(() => {
2414
+ var d;
2415
+ (d = $e.current) == null || d.focus();
2416
+ }, []), xe(() => {
2417
+ const d = (N) => {
2418
+ N.key === "Escape" && (N.stopPropagation(), T());
2335
2419
  };
2336
- return window.addEventListener("keydown", i, !0), () => window.removeEventListener("keydown", i, !0);
2337
- }, [ee]);
2338
- const U = F(() => {
2339
- var S;
2340
- const i = (S = [...(h ?? "").matchAll(/\{\{([\w.]+)\}\}/g)][0]) == null ? void 0 : S[1];
2341
- return i && !i.includes(".") ? i : "id";
2342
- }, [h]), Ae = !N && y.includes(".") ? `*,${y}` : "*", ye = 50, { data: ue, isFetching: ie } = K({
2343
- queryKey: ["favorites-manager-list", d, ne, U, se],
2344
- queryFn: () => _e.request(
2345
- R(`/items/${d}`, {
2346
- fields: Ae,
2347
- limit: ye,
2348
- page: se,
2349
- sort: U,
2350
- ...ne.trim() ? { search: ne } : {}
2420
+ return window.addEventListener("keydown", d, !0), () => window.removeEventListener("keydown", d, !0);
2421
+ }, [T]);
2422
+ const je = F(() => {
2423
+ var N;
2424
+ const d = (N = [...(m ?? "").matchAll(/\{\{([\w.]+)\}\}/g)][0]) == null ? void 0 : N[1];
2425
+ return d && !d.includes(".") ? d : "id";
2426
+ }, [m]), X = !x && b.includes(".") ? `*,${b}` : "*", ge = 50, { data: ke, isFetching: le } = C({
2427
+ queryKey: ["favorites-manager-list", i, P, je, J],
2428
+ queryFn: () => Z.request(
2429
+ R(`/items/${i}`, {
2430
+ fields: X,
2431
+ limit: ge,
2432
+ page: J,
2433
+ sort: je,
2434
+ ...P.trim() ? { search: P } : {}
2351
2435
  })
2352
2436
  ),
2353
2437
  staleTime: 3e4,
2354
- placeholderData: (i) => i
2355
- }), ae = ((ue == null ? void 0 : ue.data) ?? []).filter((i) => !a.has(String(i.id))), Q = (ue == null ? void 0 : ue.total) ?? ae.length, X = Math.max(1, Math.ceil(Q / ye)), { data: Se = [] } = K({
2356
- queryKey: ["favorites-manager-pinned", d, Ae, b.join(",")],
2357
- queryFn: () => _e.request(
2358
- R(`/items/${d}`, {
2359
- filter: JSON.stringify({ id: { _in: b } }),
2360
- fields: Ae,
2361
- limit: b.length,
2362
- sort: U
2438
+ placeholderData: (d) => d
2439
+ }), ie = ((ke == null ? void 0 : ke.data) ?? []).filter((d) => !S.has(String(d.id))), V = (ke == null ? void 0 : ke.total) ?? ie.length, oe = Math.max(1, Math.ceil(V / ge)), { data: de = [] } = C({
2440
+ queryKey: ["favorites-manager-pinned", i, X, s.join(",")],
2441
+ queryFn: () => Z.request(
2442
+ R(`/items/${i}`, {
2443
+ filter: JSON.stringify({ id: { _in: s } }),
2444
+ fields: X,
2445
+ limit: s.length,
2446
+ sort: je
2363
2447
  })
2364
- ).then((i) => i.data ?? []),
2365
- enabled: b.length > 0,
2448
+ ).then((d) => d.data ?? []),
2449
+ enabled: s.length > 0,
2366
2450
  staleTime: 3e4
2367
- }), me = F(() => {
2368
- const i = /* @__PURE__ */ new Set();
2369
- for (const S of ae) i.add(String(S.id));
2370
- for (const S of b) i.add(S);
2371
- return [...i];
2372
- }, [ae, b]), { data: Ke = /* @__PURE__ */ new Map() } = K({
2373
- queryKey: ["favorites-manager-sections", N == null ? void 0 : N.junction, me.join(",")],
2451
+ }), he = F(() => {
2452
+ const d = /* @__PURE__ */ new Set();
2453
+ for (const N of ie) d.add(String(N.id));
2454
+ for (const N of s) d.add(N);
2455
+ return [...d];
2456
+ }, [ie, s]), { data: Ee = /* @__PURE__ */ new Map() } = C({
2457
+ queryKey: ["favorites-manager-sections", x == null ? void 0 : x.junction, he.join(",")],
2374
2458
  queryFn: async () => {
2375
- const i = N, S = await Et(_e, `/items/${i.junction}`, {
2376
- fields: `${i.fkToItem},${i.fkToSection}`,
2377
- filter: JSON.stringify({ [i.fkToItem]: { _in: me } })
2378
- }), I = [...new Set(S.map((T) => String(T[i.fkToSection])))], W = I.length ? await Et(_e, `/items/${i.target}`, {
2379
- fields: `id,${i.labelPath}`,
2380
- filter: JSON.stringify({ id: { _in: I } })
2381
- }) : [], D = new Map(
2382
- W.map((T) => [String(T.id), String(rn(T, i.labelPath) ?? "")])
2383
- ), fe = /* @__PURE__ */ new Map();
2384
- for (const T of S) {
2385
- const be = D.get(String(T[i.fkToSection]));
2386
- if (!be) continue;
2387
- const de = String(T[i.fkToItem]), qe = fe.get(de) ?? [];
2388
- qe.includes(be) || qe.push(be), fe.set(de, qe);
2459
+ const d = x, N = await At(Z, `/items/${d.junction}`, {
2460
+ fields: `${d.fkToItem},${d.fkToSection}`,
2461
+ filter: JSON.stringify({ [d.fkToItem]: { _in: he } })
2462
+ }), B = [...new Set(N.map((H) => String(H[d.fkToSection])))], ne = B.length ? await At(Z, `/items/${d.target}`, {
2463
+ fields: `id,${d.labelPath}`,
2464
+ filter: JSON.stringify({ id: { _in: B } })
2465
+ }) : [], Q = new Map(
2466
+ ne.map((H) => [String(H.id), String(cr(H, d.labelPath) ?? "")])
2467
+ ), ee = /* @__PURE__ */ new Map();
2468
+ for (const H of N) {
2469
+ const A = Q.get(String(H[d.fkToSection]));
2470
+ if (!A) continue;
2471
+ const Ke = String(H[d.fkToItem]), re = ee.get(Ke) ?? [];
2472
+ re.includes(A) || re.push(A), ee.set(Ke, re);
2389
2473
  }
2390
- return fe;
2474
+ return ee;
2391
2475
  },
2392
- enabled: !!N && me.length > 0,
2476
+ enabled: !!x && he.length > 0,
2393
2477
  staleTime: 6e4
2394
- }), q = (i) => h ? ze(h, i) : String(i.cifa_number ?? i.name ?? `#${i.id}`), g = (i) => {
2395
- const S = i.description ?? i.long_description ?? i.name;
2396
- return typeof S == "string" && S.trim() && S.trim() !== q(i) ? S : "";
2397
- }, L = (i) => {
2398
- if (N) return (Ke.get(String(i.id)) ?? []).join(", ");
2399
- if (!y) return "";
2400
- const S = ze(`{{${y}}}`, i);
2401
- return S === `{{${y}}}` ? "" : S;
2402
- }, le = (i, S) => {
2403
- if (S === "presence")
2404
- return i == null || i === "" || Number(i) === 0 ? "No" : "Yes";
2405
- if (i == null || i === "") return "—";
2406
- const I = Number(i);
2407
- return S === "currency" && Number.isFinite(I) ? I.toLocaleString("en-US", { style: "currency", currency: "USD" }) : S === "number" && Number.isFinite(I) ? I.toLocaleString() : String(i);
2408
- }, B = lr({
2409
- queries: j.map((i) => {
2410
- const S = Me(i.match, w);
2478
+ }), $ = (d) => m ? ze(m, d) : String(d.cifa_number ?? d.name ?? `#${d.id}`), W = (d) => {
2479
+ const N = d.description ?? d.long_description ?? d.name;
2480
+ return typeof N == "string" && N.trim() && N.trim() !== $(d) ? N : "";
2481
+ }, g = (d) => {
2482
+ if (x) return (Ee.get(String(d.id)) ?? []).join(", ");
2483
+ if (!b) return "";
2484
+ const N = ze(`{{${b}}}`, d);
2485
+ return N === `{{${b}}}` ? "" : N;
2486
+ }, te = (d, N) => {
2487
+ if (N === "presence")
2488
+ return d == null || d === "" || Number(d) === 0 ? "No" : "Yes";
2489
+ if (d == null || d === "") return "—";
2490
+ const B = Number(d);
2491
+ return N === "currency" && Number.isFinite(B) ? B.toLocaleString("en-US", { style: "currency", currency: "USD" }) : N === "number" && Number.isFinite(B) ? B.toLocaleString() : String(d);
2492
+ }, M = un({
2493
+ queries: k.map((d) => {
2494
+ const N = De(d.match, j);
2411
2495
  return {
2412
2496
  queryKey: [
2413
2497
  "favorites-manager-related",
2414
- i.key,
2415
- i.collection,
2416
- JSON.stringify(S),
2417
- me.join(",")
2498
+ d.key,
2499
+ d.collection,
2500
+ JSON.stringify(N),
2501
+ he.join(",")
2418
2502
  ],
2419
2503
  queryFn: async () => {
2420
- const I = await _e.request(
2421
- R(`/items/${i.collection}`, {
2422
- filter: JSON.stringify({ [i.item_field]: { _in: me }, ...S ?? {} }),
2423
- fields: `${i.item_field},${i.value_field}`,
2504
+ const B = await Z.request(
2505
+ R(`/items/${d.collection}`, {
2506
+ filter: JSON.stringify({ [d.item_field]: { _in: he }, ...N ?? {} }),
2507
+ fields: `${d.item_field},${d.value_field}`,
2424
2508
  limit: 1e3
2425
2509
  })
2426
- ).then((D) => D.data ?? []), W = /* @__PURE__ */ new Map();
2427
- for (const D of I) {
2428
- const fe = String(D[i.item_field]), T = D[i.value_field], be = W.get(fe);
2429
- be === void 0 ? W.set(fe, T) : Number.isFinite(Number(be)) && Number.isFinite(Number(T)) && W.set(fe, Number(be) + Number(T));
2510
+ ).then((Q) => Q.data ?? []), ne = /* @__PURE__ */ new Map();
2511
+ for (const Q of B) {
2512
+ const ee = String(Q[d.item_field]), H = Q[d.value_field], A = ne.get(ee);
2513
+ A === void 0 ? ne.set(ee, H) : Number.isFinite(Number(A)) && Number.isFinite(Number(H)) && ne.set(ee, Number(A) + Number(H));
2430
2514
  }
2431
- return W;
2515
+ return ne;
2432
2516
  },
2433
- enabled: me.length > 0 && (i.match === void 0 || S !== null),
2517
+ enabled: he.length > 0 && (d.match === void 0 || N !== null),
2434
2518
  staleTime: 3e4
2435
2519
  };
2436
2520
  })
2437
- }), $ = j.filter(
2438
- (i) => i.match !== void 0 && Me(i.match, w) === null
2439
- ), J = (i) => {
2440
- const S = a.has(i);
2441
- return /* @__PURE__ */ s(
2521
+ }), U = k.filter(
2522
+ (d) => d.match !== void 0 && De(d.match, j) === null
2523
+ ), O = (d) => {
2524
+ const N = S.has(d);
2525
+ return /* @__PURE__ */ a(
2442
2526
  "button",
2443
2527
  {
2444
2528
  type: "button",
2445
- title: S ? "Remove from favorites" : "Add to favorites",
2446
- disabled: k.has(i),
2447
- onClick: () => P(i),
2529
+ title: N ? "Remove from favorites" : "Add to favorites",
2530
+ disabled: w.has(d),
2531
+ onClick: () => v(d),
2448
2532
  className: "shrink-0 rounded p-1 transition-colors hover:bg-amber-100/60 dark:hover:bg-amber-400/10",
2449
- children: k.has(i) ? /* @__PURE__ */ s(ce, { className: "h-4 w-4 animate-spin text-amber-400" }) : /* @__PURE__ */ s(
2450
- it,
2533
+ children: w.has(d) ? /* @__PURE__ */ a(ce, { className: "h-4 w-4 animate-spin text-amber-400" }) : /* @__PURE__ */ a(
2534
+ dt,
2451
2535
  {
2452
- className: C(
2536
+ className: I(
2453
2537
  "h-4 w-4",
2454
- S ? "fill-amber-400 text-amber-400" : "text-slate-300 hover:text-amber-400"
2538
+ N ? "fill-amber-400 text-amber-400" : "text-slate-300 hover:text-amber-400"
2455
2539
  )
2456
2540
  }
2457
2541
  )
2458
2542
  }
2459
2543
  );
2460
- }, E = (i, S) => /* @__PURE__ */ s("tr", { children: /* @__PURE__ */ s("td", { colSpan: 4 + j.length, className: C("border-b px-3 py-1.5", S), children: i }) }), oe = (i, S) => {
2461
- const I = String(i.id), W = g(i);
2544
+ }, z = (d, N) => /* @__PURE__ */ a("tr", { children: /* @__PURE__ */ a("td", { colSpan: 4 + k.length, className: I("border-b px-3 py-1.5", N), children: d }) }), L = (d, N) => {
2545
+ const B = String(d.id), ne = W(d);
2462
2546
  return /* @__PURE__ */ u(
2463
2547
  "tr",
2464
2548
  {
2465
- className: C(
2549
+ className: I(
2466
2550
  "border-b border-slate-100 dark:border-border/50",
2467
- S % 2 === 0 ? "bg-white dark:bg-background" : "bg-slate-50/50 dark:bg-muted/30"
2551
+ N % 2 === 0 ? "bg-white dark:bg-background" : "bg-slate-50/50 dark:bg-muted/30"
2468
2552
  ),
2469
2553
  children: [
2470
- /* @__PURE__ */ s("td", { className: "px-2 py-1", children: J(I) }),
2471
- /* @__PURE__ */ s("td", { className: "px-2 py-1 font-medium tabular-nums text-slate-700 dark:text-slate-200", children: en(d) ? /* @__PURE__ */ s(
2554
+ /* @__PURE__ */ a("td", { className: "px-2 py-1", children: O(B) }),
2555
+ /* @__PURE__ */ a("td", { className: "px-2 py-1 font-medium tabular-nums text-slate-700 dark:text-slate-200", children: or(i) ? /* @__PURE__ */ a(
2472
2556
  "button",
2473
2557
  {
2474
2558
  type: "button",
2475
- onClick: () => tn(d, I, w),
2559
+ onClick: () => dr(i, B, j),
2476
2560
  title: "View stock & planning detail",
2477
2561
  className: "text-left underline decoration-slate-300 decoration-1 underline-offset-2 hover:text-[#009abe] hover:decoration-[#009abe] dark:decoration-slate-600",
2478
- children: q(i)
2562
+ children: $(d)
2479
2563
  }
2480
- ) : q(i) }),
2481
- /* @__PURE__ */ s("td", { className: "max-w-0 px-2 py-1", children: /* @__PURE__ */ s("p", { className: "truncate text-slate-600 dark:text-slate-300", "data-tip": W || void 0, children: W || "—" }) }),
2482
- /* @__PURE__ */ s("td", { className: "px-2 py-1", children: /* @__PURE__ */ s("p", { className: "truncate text-slate-500 dark:text-slate-400", children: L(i) || "—" }) }),
2483
- j.map((D, fe) => {
2484
- var de, qe;
2485
- const T = D.match !== void 0 && Me(D.match, w) === null, be = T || (qe = (de = B[fe]) == null ? void 0 : de.data) == null ? void 0 : qe.get(I);
2486
- return /* @__PURE__ */ s(
2564
+ ) : $(d) }),
2565
+ /* @__PURE__ */ a("td", { className: "max-w-0 px-2 py-1", children: /* @__PURE__ */ a("p", { className: "truncate text-slate-600 dark:text-slate-300", "data-tip": ne || void 0, children: ne || "—" }) }),
2566
+ /* @__PURE__ */ a("td", { className: "px-2 py-1", children: /* @__PURE__ */ a("p", { className: "truncate text-slate-500 dark:text-slate-400", children: g(d) || "—" }) }),
2567
+ k.map((Q, ee) => {
2568
+ var Ke, re;
2569
+ const H = Q.match !== void 0 && De(Q.match, j) === null, A = H || (re = (Ke = M[ee]) == null ? void 0 : Ke.data) == null ? void 0 : re.get(B);
2570
+ return /* @__PURE__ */ a(
2487
2571
  "td",
2488
2572
  {
2489
2573
  className: "whitespace-nowrap px-2 py-1 text-right tabular-nums text-slate-600 dark:text-slate-300",
2490
- children: T ? "—" : le(be, D.format)
2574
+ children: H ? "—" : te(A, Q.format)
2491
2575
  },
2492
- D.key
2576
+ Q.key
2493
2577
  );
2494
2578
  })
2495
2579
  ]
2496
2580
  },
2497
- I
2581
+ B
2498
2582
  );
2499
- }, lt = (Y == null ? void 0 : Y.closest('[role="dialog"]')) ?? document.body, V = Z.trim() ? Se.filter((i) => es(`${q(i)} ${g(i)} ${L(i)}`, Z)) : Se;
2500
- return Vn(
2583
+ }, Fe = (ye == null ? void 0 : ye.closest('[role="dialog"]')) ?? document.body, He = G.trim() ? de.filter((d) => os(`${$(d)} ${W(d)} ${g(d)}`, G)) : de;
2584
+ return Zr(
2501
2585
  /* @__PURE__ */ u("div", { className: "fixed inset-0 z-[125]", role: "presentation", children: [
2502
- /* @__PURE__ */ s(
2586
+ /* @__PURE__ */ a(
2503
2587
  "div",
2504
2588
  {
2505
2589
  className: "absolute inset-0 bg-slate-900/30 motion-safe:animate-in motion-safe:fade-in",
2506
- onClick: ee
2590
+ onClick: T
2507
2591
  }
2508
2592
  ),
2509
2593
  /* @__PURE__ */ u(
@@ -2515,140 +2599,140 @@ function $s({
2515
2599
  className: "absolute inset-y-0 right-0 flex flex-col border-l border-slate-200 bg-white shadow-2xl motion-safe:animate-in motion-safe:slide-in-from-right dark:border-border dark:bg-background",
2516
2600
  children: [
2517
2601
  /* @__PURE__ */ u("div", { className: "flex items-start gap-2.5 border-b border-slate-200 px-4 py-3 dark:border-border", children: [
2518
- /* @__PURE__ */ s(it, { className: "mt-0.5 h-4 w-4 shrink-0 fill-amber-400 text-amber-400" }),
2602
+ /* @__PURE__ */ a(dt, { className: "mt-0.5 h-4 w-4 shrink-0 fill-amber-400 text-amber-400" }),
2519
2603
  /* @__PURE__ */ u("div", { className: "min-w-0 flex-1", children: [
2520
- /* @__PURE__ */ s("p", { className: "text-[13px] font-semibold text-slate-800 dark:text-slate-100", children: "CIFA favorites" }),
2521
- /* @__PURE__ */ s("p", { className: "text-[11px] leading-snug text-slate-500 dark:text-slate-400", children: "Browse the full catalog and star items — favorites appear at the top of every request's item list." })
2604
+ /* @__PURE__ */ a("p", { className: "text-[13px] font-semibold text-slate-800 dark:text-slate-100", children: "CIFA favorites" }),
2605
+ /* @__PURE__ */ a("p", { className: "text-[11px] leading-snug text-slate-500 dark:text-slate-400", children: "Browse the full catalog and star items — favorites appear at the top of every request's item list." })
2522
2606
  ] }),
2523
- /* @__PURE__ */ s(
2607
+ /* @__PURE__ */ a(
2524
2608
  "button",
2525
2609
  {
2526
2610
  type: "button",
2527
- onClick: ee,
2611
+ onClick: T,
2528
2612
  className: "shrink-0 rounded p-1 text-slate-400 transition-colors hover:bg-slate-100 hover:text-slate-600 dark:hover:bg-white/[0.06]",
2529
2613
  "aria-label": "Close",
2530
- children: /* @__PURE__ */ s(Pt, { className: "h-4 w-4" })
2614
+ children: /* @__PURE__ */ a(Lt, { className: "h-4 w-4" })
2531
2615
  }
2532
2616
  )
2533
2617
  ] }),
2534
2618
  /* @__PURE__ */ u("div", { className: "border-b border-slate-200 px-3 py-2 dark:border-border", children: [
2535
2619
  /* @__PURE__ */ u("div", { className: "flex items-center gap-2 rounded-md border border-slate-200 bg-slate-50 px-2.5 py-1.5 focus-within:border-nvr-cyan focus-within:bg-white dark:border-border dark:bg-muted/40 dark:focus-within:bg-background", children: [
2536
- /* @__PURE__ */ s(Rt, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" }),
2537
- /* @__PURE__ */ s(
2620
+ /* @__PURE__ */ a(Et, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" }),
2621
+ /* @__PURE__ */ a(
2538
2622
  "input",
2539
2623
  {
2540
- ref: Oe,
2541
- value: Z,
2542
- onChange: (i) => z(i.target.value),
2624
+ ref: $e,
2625
+ value: G,
2626
+ onChange: (d) => Ae(d.target.value),
2543
2627
  placeholder: "Search by number or description…",
2544
2628
  className: "min-w-0 flex-1 bg-transparent text-[12px] text-slate-700 outline-none placeholder:text-slate-400 dark:text-slate-200"
2545
2629
  }
2546
2630
  ),
2547
- Z && /* @__PURE__ */ s(
2631
+ G && /* @__PURE__ */ a(
2548
2632
  "button",
2549
2633
  {
2550
2634
  type: "button",
2551
- onClick: () => z(""),
2635
+ onClick: () => Ae(""),
2552
2636
  className: "shrink-0 text-slate-400 hover:text-slate-600",
2553
2637
  "aria-label": "Clear search",
2554
- children: /* @__PURE__ */ s(Pt, { className: "h-3.5 w-3.5" })
2638
+ children: /* @__PURE__ */ a(Lt, { className: "h-3.5 w-3.5" })
2555
2639
  }
2556
2640
  )
2557
2641
  ] }),
2558
- $.length > 0 && /* @__PURE__ */ u("p", { className: "mt-1.5 flex items-center gap-1 text-[10px] text-amber-600 dark:text-amber-400", children: [
2559
- /* @__PURE__ */ s(De, { className: "h-3 w-3 shrink-0" }),
2560
- $.map((i) => i.label ?? M(i.key)).join(", "),
2642
+ U.length > 0 && /* @__PURE__ */ u("p", { className: "mt-1.5 flex items-center gap-1 text-[10px] text-amber-600 dark:text-amber-400", children: [
2643
+ /* @__PURE__ */ a(Be, { className: "h-3 w-3 shrink-0" }),
2644
+ U.map((d) => d.label ?? D(d.key)).join(", "),
2561
2645
  " fill in once the form's warehouse selection is made."
2562
2646
  ] })
2563
2647
  ] }),
2564
- /* @__PURE__ */ s("div", { className: "min-h-0 flex-1 overflow-y-auto", children: /* @__PURE__ */ u("table", { className: "w-full table-fixed border-collapse text-[11px]", children: [
2648
+ /* @__PURE__ */ a("div", { className: "min-h-0 flex-1 overflow-y-auto", children: /* @__PURE__ */ u("table", { className: "w-full table-fixed border-collapse text-[11px]", children: [
2565
2649
  /* @__PURE__ */ u("colgroup", { children: [
2566
- /* @__PURE__ */ s("col", { className: "w-9" }),
2567
- /* @__PURE__ */ s("col", { className: "w-[88px]" }),
2568
- /* @__PURE__ */ s("col", {}),
2569
- /* @__PURE__ */ s("col", { className: "w-[130px]" }),
2570
- j.map((i) => /* @__PURE__ */ s("col", { className: "w-[86px]" }, i.key))
2650
+ /* @__PURE__ */ a("col", { className: "w-9" }),
2651
+ /* @__PURE__ */ a("col", { className: "w-[88px]" }),
2652
+ /* @__PURE__ */ a("col", {}),
2653
+ /* @__PURE__ */ a("col", { className: "w-[130px]" }),
2654
+ k.map((d) => /* @__PURE__ */ a("col", { className: "w-[86px]" }, d.key))
2571
2655
  ] }),
2572
- /* @__PURE__ */ s("thead", { className: "sticky top-0 z-[1]", children: /* @__PURE__ */ u("tr", { className: "bg-slate-100 text-left text-[10px] font-semibold uppercase tracking-wide text-slate-500 dark:bg-muted dark:text-slate-400", children: [
2573
- /* @__PURE__ */ s("th", { className: "px-2 py-1.5", "aria-label": "Favorite" }),
2574
- /* @__PURE__ */ s("th", { className: "px-2 py-1.5", children: "CIFA #" }),
2575
- /* @__PURE__ */ s("th", { className: "px-2 py-1.5", children: "Description" }),
2576
- /* @__PURE__ */ s("th", { className: "px-2 py-1.5", children: "Category" }),
2577
- j.map((i) => /* @__PURE__ */ s("th", { className: "px-2 py-1.5 text-right", children: i.label ?? M(i.key) }, i.key))
2656
+ /* @__PURE__ */ a("thead", { className: "sticky top-0 z-[1]", children: /* @__PURE__ */ u("tr", { className: "bg-slate-100 text-left text-[10px] font-semibold uppercase tracking-wide text-slate-500 dark:bg-muted dark:text-slate-400", children: [
2657
+ /* @__PURE__ */ a("th", { className: "px-2 py-1.5", "aria-label": "Favorite" }),
2658
+ /* @__PURE__ */ a("th", { className: "px-2 py-1.5", children: "CIFA #" }),
2659
+ /* @__PURE__ */ a("th", { className: "px-2 py-1.5", children: "Description" }),
2660
+ /* @__PURE__ */ a("th", { className: "px-2 py-1.5", children: "Category" }),
2661
+ k.map((d) => /* @__PURE__ */ a("th", { className: "px-2 py-1.5 text-right", children: d.label ?? D(d.key) }, d.key))
2578
2662
  ] }) }),
2579
- /* @__PURE__ */ u("tbody", { className: C(ie && "opacity-50 transition-opacity"), children: [
2580
- E(
2663
+ /* @__PURE__ */ u("tbody", { className: I(le && "opacity-50 transition-opacity"), children: [
2664
+ z(
2581
2665
  /* @__PURE__ */ u("span", { className: "flex items-center gap-1.5", children: [
2582
- /* @__PURE__ */ s(it, { className: "h-3 w-3 shrink-0 fill-amber-400 text-amber-400" }),
2583
- /* @__PURE__ */ s("span", { className: "text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: "Your favorites" }),
2584
- /* @__PURE__ */ s("span", { className: "rounded border border-slate-200 bg-white px-1.5 py-0.5 text-[10px] font-medium tabular-nums text-slate-500 dark:border-border dark:bg-background dark:text-slate-400", children: b.length })
2666
+ /* @__PURE__ */ a(dt, { className: "h-3 w-3 shrink-0 fill-amber-400 text-amber-400" }),
2667
+ /* @__PURE__ */ a("span", { className: "text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: "Your favorites" }),
2668
+ /* @__PURE__ */ a("span", { className: "rounded border border-slate-200 bg-white px-1.5 py-0.5 text-[10px] font-medium tabular-nums text-slate-500 dark:border-border dark:bg-background dark:text-slate-400", children: s.length })
2585
2669
  ] }),
2586
2670
  "border-slate-200 bg-amber-50/70 dark:border-border dark:bg-amber-900/10"
2587
2671
  ),
2588
- V.length === 0 && /* @__PURE__ */ s("tr", { children: /* @__PURE__ */ s(
2672
+ He.length === 0 && /* @__PURE__ */ a("tr", { children: /* @__PURE__ */ a(
2589
2673
  "td",
2590
2674
  {
2591
- colSpan: 4 + j.length,
2675
+ colSpan: 4 + k.length,
2592
2676
  className: "border-b border-slate-100 px-4 py-3 text-center text-[11px] text-slate-400 dark:border-border/50",
2593
- children: b.length === 0 ? "No favorites yet — star the items you order most." : "No favorites match your search."
2677
+ children: s.length === 0 ? "No favorites yet — star the items you order most." : "No favorites match your search."
2594
2678
  }
2595
2679
  ) }),
2596
- V.map((i, S) => oe(i, S)),
2597
- E(
2680
+ He.map((d, N) => L(d, N)),
2681
+ z(
2598
2682
  /* @__PURE__ */ u("span", { className: "flex items-center gap-1.5", children: [
2599
- /* @__PURE__ */ s(Rt, { className: "h-3 w-3 shrink-0 text-slate-400" }),
2600
- /* @__PURE__ */ s("span", { className: "text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: "All CIFAs" }),
2601
- /* @__PURE__ */ s("span", { className: "rounded border border-slate-200 bg-white px-1.5 py-0.5 text-[10px] font-medium tabular-nums text-slate-500 dark:border-border dark:bg-background dark:text-slate-400", children: Q.toLocaleString() }),
2602
- ie && /* @__PURE__ */ s(ce, { className: "h-3 w-3 animate-spin text-slate-400" })
2683
+ /* @__PURE__ */ a(Et, { className: "h-3 w-3 shrink-0 text-slate-400" }),
2684
+ /* @__PURE__ */ a("span", { className: "text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: "All CIFAs" }),
2685
+ /* @__PURE__ */ a("span", { className: "rounded border border-slate-200 bg-white px-1.5 py-0.5 text-[10px] font-medium tabular-nums text-slate-500 dark:border-border dark:bg-background dark:text-slate-400", children: V.toLocaleString() }),
2686
+ le && /* @__PURE__ */ a(ce, { className: "h-3 w-3 animate-spin text-slate-400" })
2603
2687
  ] }),
2604
2688
  "border-t border-slate-200 bg-slate-50 dark:border-border dark:bg-muted/40"
2605
2689
  ),
2606
- !ie && ae.length === 0 && /* @__PURE__ */ s("tr", { children: /* @__PURE__ */ s(
2690
+ !le && ie.length === 0 && /* @__PURE__ */ a("tr", { children: /* @__PURE__ */ a(
2607
2691
  "td",
2608
2692
  {
2609
- colSpan: 4 + j.length,
2693
+ colSpan: 4 + k.length,
2610
2694
  className: "px-4 py-4 text-center text-[11px] text-slate-400",
2611
- children: ne.trim() ? `No CIFAs match "${ne}".` : "No catalog items."
2695
+ children: P.trim() ? `No CIFAs match "${P}".` : "No catalog items."
2612
2696
  }
2613
2697
  ) }),
2614
- ae.map((i, S) => oe(i, S))
2698
+ ie.map((d, N) => L(d, N))
2615
2699
  ] })
2616
2700
  ] }) }),
2617
- X > 1 && /* @__PURE__ */ u("div", { className: "flex shrink-0 items-center justify-between border-t border-slate-200 px-3 py-2 dark:border-border", children: [
2701
+ oe > 1 && /* @__PURE__ */ u("div", { className: "flex shrink-0 items-center justify-between border-t border-slate-200 px-3 py-2 dark:border-border", children: [
2618
2702
  /* @__PURE__ */ u("span", { className: "flex items-center gap-2 text-[10px] tabular-nums text-slate-400", children: [
2619
- (se - 1) * ye + 1,
2703
+ (J - 1) * ge + 1,
2620
2704
  "–",
2621
- Math.min(se * ye, Q),
2705
+ Math.min(J * ge, V),
2622
2706
  " of",
2623
2707
  " ",
2624
- Q.toLocaleString(),
2625
- ie && /* @__PURE__ */ u("span", { className: "flex items-center gap-1 text-slate-500", children: [
2626
- /* @__PURE__ */ s(ce, { className: "h-3 w-3 animate-spin" }),
2708
+ V.toLocaleString(),
2709
+ le && /* @__PURE__ */ u("span", { className: "flex items-center gap-1 text-slate-500", children: [
2710
+ /* @__PURE__ */ a(ce, { className: "h-3 w-3 animate-spin" }),
2627
2711
  " Loading…"
2628
2712
  ] })
2629
2713
  ] }),
2630
2714
  /* @__PURE__ */ u("div", { className: "flex items-center gap-1", children: [
2631
- /* @__PURE__ */ s(
2715
+ /* @__PURE__ */ a(
2632
2716
  "button",
2633
2717
  {
2634
2718
  type: "button",
2635
- disabled: se <= 1 || ie,
2636
- onClick: () => xe((i) => Math.max(1, i - 1)),
2719
+ disabled: J <= 1 || le,
2720
+ onClick: () => fe((d) => Math.max(1, d - 1)),
2637
2721
  className: "rounded border border-slate-200 px-2 py-0.5 text-[11px] text-slate-600 transition-colors hover:bg-slate-50 disabled:opacity-40 dark:border-border dark:text-slate-300 dark:hover:bg-white/[0.04]",
2638
2722
  children: "‹ Prev"
2639
2723
  }
2640
2724
  ),
2641
2725
  /* @__PURE__ */ u("span", { className: "px-1 text-[10px] tabular-nums text-slate-400", children: [
2642
- se,
2726
+ J,
2643
2727
  " / ",
2644
- X.toLocaleString()
2728
+ oe.toLocaleString()
2645
2729
  ] }),
2646
- /* @__PURE__ */ s(
2730
+ /* @__PURE__ */ a(
2647
2731
  "button",
2648
2732
  {
2649
2733
  type: "button",
2650
- disabled: se >= X || ie,
2651
- onClick: () => xe((i) => Math.min(X, i + 1)),
2734
+ disabled: J >= oe || le,
2735
+ onClick: () => fe((d) => Math.min(oe, d + 1)),
2652
2736
  className: "rounded border border-slate-200 px-2 py-0.5 text-[11px] text-slate-600 transition-colors hover:bg-slate-50 disabled:opacity-40 dark:border-border dark:text-slate-300 dark:hover:bg-white/[0.04]",
2653
2737
  children: "Next ›"
2654
2738
  }
@@ -2659,19 +2743,28 @@ function $s({
2659
2743
  }
2660
2744
  )
2661
2745
  ] }),
2662
- lt
2746
+ Fe
2663
2747
  );
2664
2748
  }
2749
+ function Ks(i, m) {
2750
+ var x;
2751
+ if (!i) return null;
2752
+ const b = (x = (m ?? []).find((S) => !S.format && !S.sections_only)) == null ? void 0 : x.field;
2753
+ return !b || i.includes(`{{${b}}}`) ? i : `${i} · {{${b}}}`;
2754
+ }
2665
2755
  export {
2666
- Gs as CatalogPickerField,
2667
- cs as MAX_LINE_MONEY,
2668
- xs as footerSum,
2669
- ks as gridPriceValue,
2670
- vs as isUnpricedLine,
2671
- Ns as issuesAfterLinesChanged,
2672
- gs as lineComputeError,
2673
- Gr as matchesShowWhen,
2674
- ps as qtyEntryProblem,
2675
- ys as refusedQtyNote,
2676
- ws as savedLinesSignature
2756
+ da as CatalogPickerField,
2757
+ ys as MAX_LINE_MONEY,
2758
+ Ks as catalogOptionTemplate,
2759
+ qs as footerSum,
2760
+ Fs as gridPriceValue,
2761
+ Rs as isUnpricedLine,
2762
+ Os as issuesAfterLinesChanged,
2763
+ js as lineComputeError,
2764
+ ir as matchesShowWhen,
2765
+ Ss as qtyEntryProblem,
2766
+ $s as refusedQtyNote,
2767
+ bn as relatedParentTokens,
2768
+ Ts as savedLinesSignature,
2769
+ vs as stagedCatalogFill
2677
2770
  };