@nivaro/react 0.3.48 → 0.3.50

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