@nivaro/react 0.3.50 → 0.3.51

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