@nivaro/react 0.3.52 → 0.3.53

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