@nivaro/react 0.3.29 → 0.3.30

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.
@@ -1,83 +1,84 @@
1
- import { jsxs as m, jsx as n, Fragment as qt } from "react/jsx-runtime";
2
- import { useQueryClient as $r, useQuery as z, useQueries as $t } from "@tanstack/react-query";
3
- import { Search as it, Loader2 as ae, ChevronRight as jt, Star as Be, AlertTriangle as ze, AlertCircle as St, X as lt, ChevronDown as jr } from "lucide-react";
4
- import { useState as Y, useRef as Ve, useMemo as O, useEffect as je, Fragment as Je } from "react";
5
- import { createPortal as Fr } from "react-dom";
6
- import { useNivaroClient as Ft, useParentDraft as Tr, useReimportHandler as Or } from "../../context.js";
7
- import { canOpenCatalogItem as er, openCatalogItem as tr } from "../../lib/catalog-item-open.js";
8
- import { get as R, del as Rr, patch as Yt, post as Zt } from "../../lib/commands.js";
9
- import { evaluateBoolean as Pr } from "../../lib/expression.js";
10
- import { useLiveRefetchInterval as Er } from "../../lib/live-queries.js";
11
- import { submissionLineErrors as Lr, normalizeIdent as Ar } from "../../lib/submission-errors.js";
12
- import { titleCase as I, cn as B, matchesAllTokens as Cr } from "../../lib/utils.js";
13
- import { ImportFromFileButton as Kr } from "../import/ImportFromFileButton.js";
14
- import { Popover as Jr, PopoverAnchor as Qr, PopoverContent as zr } from "../ui/popover.js";
15
- import { applyDisplayTemplate as Fe } from "./helpers.js";
1
+ import { jsxs as m, jsx as n, Fragment as lt } from "react/jsx-runtime";
2
+ import { useQueryClient as Pr, useQuery as V, useQueries as $t } from "@tanstack/react-query";
3
+ import { Search as ot, Loader2 as ne, ChevronRight as jt, Star as Be, AlertTriangle as ze, AlertCircle as qt, X as dt, Plus as Rr, ChevronDown as Er } from "lucide-react";
4
+ import { useState as W, useRef as Ve, useMemo as E, useEffect as Fe, Fragment as Je } from "react";
5
+ import { createPortal as Ar } from "react-dom";
6
+ import { useNivaroClient as Ft, useParentDraft as Cr, useReimportHandler as Lr } from "../../context.js";
7
+ import { canOpenCatalogItem as sr, openCatalogItem as ar } from "../../lib/catalog-item-open.js";
8
+ import { get as A, del as Kr, patch as Gt, post as Xt } from "../../lib/commands.js";
9
+ import { evaluateBoolean as Jr } from "../../lib/expression.js";
10
+ import { useLiveRefetchInterval as Qr } from "../../lib/live-queries.js";
11
+ import { submissionLineErrors as zr, normalizeIdent as Br } from "../../lib/submission-errors.js";
12
+ import { titleCase as Z, cn as Q, matchesAllTokens as Vr } from "../../lib/utils.js";
13
+ import { ImportFromFileButton as Dr } from "../import/ImportFromFileButton.js";
14
+ import { useOverflowTip as Ur } from "../TipLayer.js";
15
+ import { Popover as Hr, PopoverAnchor as Mr, PopoverContent as Wr } from "../ui/popover.js";
16
+ import { applyDisplayTemplate as Te } from "./helpers.js";
16
17
  import { evalClientFormula as Qe } from "./InlineTableField.js";
17
- import { isIntegerFieldType as Br, checkNumberEntry as Gt, mergePendingQtyRow as Vr, lineRuleErrors as Ur } from "./line-qty.js";
18
- import { resolveM2MRelatedCollection as Dr } from "./M2MCombobox.js";
19
- import { useO2MStaging as Hr } from "./O2MStagingContext.js";
20
- import { RelationCombobox as Mr } from "./RelationCombobox.js";
21
- const rr = (f, y) => {
18
+ import { isIntegerFieldType as er, checkNumberEntry as tr, mergePendingQtyRow as Ir, lineRuleErrors as Yr } from "./line-qty.js";
19
+ import { resolveM2MRelatedCollection as Zr } from "./M2MCombobox.js";
20
+ import { useO2MStaging as Gr } from "./O2MStagingContext.js";
21
+ import { RelationCombobox as Xr } from "./RelationCombobox.js";
22
+ const ir = (f, g) => {
22
23
  let _ = f;
23
- for (const q of y.split(".")) {
24
+ for (const $ of g.split(".")) {
24
25
  if (_ == null || typeof _ != "object") return;
25
- _ = _[q];
26
+ _ = _[$];
26
27
  }
27
28
  return _;
28
29
  };
29
- async function ot(f, y, _) {
30
- const q = [];
30
+ async function ct(f, g, _) {
31
+ const $ = [];
31
32
  for (let l = 1; l <= 50; l++) {
32
- const g = await f.request(R(y, { ..._, limit: 1e3, page: l })).then((h) => h.data ?? []);
33
- if (q.push(...g), g.length < 1e3) break;
33
+ const h = await f.request(A(g, { ..._, limit: 1e3, page: l })).then((p) => p.data ?? []);
34
+ if ($.push(...h), h.length < 1e3) break;
34
35
  }
35
- return q;
36
+ return $;
36
37
  }
37
- function Ue(f, y) {
38
+ function De(f, g) {
38
39
  const _ = {};
39
- let q = !1;
40
- const l = (g) => {
41
- if (typeof g == "string" && g.startsWith("$parent.")) {
42
- const h = y == null ? void 0 : y[g.slice(8)];
43
- return h == null || h === "" ? (q = !0, g) : h;
40
+ let $ = !1;
41
+ const l = (h) => {
42
+ if (typeof h == "string" && h.startsWith("$parent.")) {
43
+ const p = g == null ? void 0 : g[h.slice(8)];
44
+ return p == null || p === "" ? ($ = !0, h) : p;
44
45
  }
45
- return Array.isArray(g) ? g.map(l) : g && typeof g == "object" ? Object.fromEntries(Object.entries(g).map(([h, $]) => [h, l($)])) : g;
46
+ return Array.isArray(h) ? h.map(l) : h && typeof h == "object" ? Object.fromEntries(Object.entries(h).map(([p, j]) => [p, l(j)])) : h;
46
47
  };
47
- for (const [g, h] of Object.entries(f ?? {}))
48
- if (typeof h == "string" && h.startsWith("$parent.")) {
49
- const $ = y == null ? void 0 : y[h.slice(8)];
50
- if ($ == null || $ === "") {
51
- q = !0;
48
+ for (const [h, p] of Object.entries(f ?? {}))
49
+ if (typeof p == "string" && p.startsWith("$parent.")) {
50
+ const j = g == null ? void 0 : g[p.slice(8)];
51
+ if (j == null || j === "") {
52
+ $ = !0;
52
53
  continue;
53
54
  }
54
- _[g] = { _eq: $ };
55
- } else h && typeof h == "object" ? _[g] = l(h) : _[g] = { _eq: h };
56
- return q ? null : _;
55
+ _[h] = { _eq: j };
56
+ } else p && typeof p == "object" ? _[h] = l(p) : _[h] = { _eq: p };
57
+ return $ ? null : _;
57
58
  }
58
- function Xt(f, y) {
59
+ function rr(f, g) {
59
60
  if (!f) return !0;
60
- for (const [_, q] of Object.entries(f)) {
61
- const l = y == null ? void 0 : y[_], g = l == null ? null : String(l), h = q && typeof q == "object" ? q : { _eq: q };
62
- for (const [$, p] of Object.entries(h))
63
- switch ($) {
61
+ for (const [_, $] of Object.entries(f)) {
62
+ const l = g == null ? void 0 : g[_], h = l == null ? null : String(l), p = $ && typeof $ == "object" ? $ : { _eq: $ };
63
+ for (const [j, x] of Object.entries(p))
64
+ switch (j) {
64
65
  case "_eq":
65
- if (g !== String(p)) return !1;
66
+ if (h !== String(x)) return !1;
66
67
  break;
67
68
  case "_neq":
68
- if (g === String(p)) return !1;
69
+ if (h === String(x)) return !1;
69
70
  break;
70
71
  case "_in":
71
- if (!Array.isArray(p) || !p.map(String).includes(g ?? "")) return !1;
72
+ if (!Array.isArray(x) || !x.map(String).includes(h ?? "")) return !1;
72
73
  break;
73
74
  case "_nin":
74
- if (Array.isArray(p) && p.map(String).includes(g ?? "")) return !1;
75
+ if (Array.isArray(x) && x.map(String).includes(h ?? "")) return !1;
75
76
  break;
76
77
  case "_null":
77
- if (g !== null) return !1;
78
+ if (h !== null) return !1;
78
79
  break;
79
80
  case "_nnull":
80
- if (g === null) return !1;
81
+ if (h === null) return !1;
81
82
  break;
82
83
  default:
83
84
  return !1;
@@ -85,83 +86,83 @@ function Xt(f, y) {
85
86
  }
86
87
  return !0;
87
88
  }
88
- const Wr = 2e3;
89
- function yn({
89
+ const en = 2e3;
90
+ function qn({
90
91
  relatedCollection: f,
91
- manyField: y,
92
+ manyField: g,
92
93
  parentId: _,
93
- parentCollection: q,
94
+ parentCollection: $,
94
95
  config: l,
95
- readOnly: g = !1
96
+ readOnly: h = !1
96
97
  }) {
97
- var Ht, Mt, Wt;
98
- const h = Ft(), $ = $r(), p = Hr(), P = Tr(), Z = Or(), D = l.editable_fields ?? [], E = _ === "new", V = l.qty_field ?? "quantity", [oe, ne] = Y(/* @__PURE__ */ new Set()), ge = Ve(!1), [C, ye] = Y(""), [be, G] = Y({}), [se, v] = Y(/* @__PURE__ */ new Set()), [T, F] = Y({}), [W, L] = Y({}), { data: K = [], isPending: de } = z({
98
+ var Mt, Wt, It, Yt;
99
+ const p = Ft(), j = Pr(), x = Gr(), z = Cr(), I = Lr(), se = l.editable_fields ?? [], C = _ === "new", O = l.qty_field ?? "quantity", [oe, G] = W(/* @__PURE__ */ new Set()), Se = Ve(!1), [L, ye] = W(""), [qe, pe] = W({}), [de, ee] = W(/* @__PURE__ */ new Set()), [ce, X] = W({}), [ae, D] = W({}), { data: te = [], isPending: he } = V({
99
100
  queryKey: ["collection-relations", f],
100
- queryFn: () => h.request(R(`/collections/${f}`)).then((e) => {
101
+ queryFn: () => p.request(A(`/collections/${f}`)).then((e) => {
101
102
  var t;
102
103
  return ((t = e.data) == null ? void 0 : t.relations) ?? [];
103
104
  }),
104
105
  staleTime: 10 * 6e4
105
- }), x = O(
106
+ }), y = E(
106
107
  () => {
107
108
  var e;
108
- return ((e = K.find(
109
+ return ((e = te.find(
109
110
  (t) => t.many_collection === f && t.many_field === l.item_field && !t.junction_field
110
111
  )) == null ? void 0 : e.one_collection) ?? null;
111
112
  },
112
- [K, f, l.item_field]
113
- ), { data: pe = [] } = z({
113
+ [te, f, l.item_field]
114
+ ), { data: ke = [] } = V({
114
115
  queryKey: ["field-config", f, null],
115
- queryFn: () => h.request(R(`/field-config/${f}`)).then((e) => e.data ?? []),
116
+ queryFn: () => p.request(A(`/field-config/${f}`)).then((e) => e.data ?? []),
116
117
  staleTime: 6e4
117
- }), _e = ((Ht = pe.find((e) => e.field === V)) == null ? void 0 : Ht.type) ?? null, Oe = (e, t, r) => {
118
+ }), v = ((Mt = ke.find((e) => e.field === O)) == null ? void 0 : Mt.type) ?? null, K = (e, t, r) => {
118
119
  var s;
119
- return ((s = Ur(
120
- pe.filter((c) => c.field === e).map((c) => ({
120
+ return ((s = Yr(
121
+ ke.filter((c) => c.field === e).map((c) => ({
121
122
  field: c.field,
122
- label: c.label || I(c.field),
123
+ label: c.label || Z(c.field),
123
124
  type: c.type,
124
125
  validation_rules: c.validation_rules
125
126
  })),
126
127
  { [e]: t },
127
128
  { ...r, [e]: t }
128
129
  )[0]) == null ? void 0 : s.message) ?? null;
129
- }, { data: X } = z({
130
- queryKey: ["col-meta", x],
131
- queryFn: () => h.request(
132
- R(`/collections/${x}`)
130
+ }, { data: F } = V({
131
+ queryKey: ["col-meta", y],
132
+ queryFn: () => p.request(
133
+ A(`/collections/${y}`)
133
134
  ).then((e) => e.data),
134
- enabled: !!x,
135
+ enabled: !!y,
135
136
  staleTime: 3e5
136
- }), ee = X == null ? void 0 : X.display_template, A = O(() => {
137
+ }), J = F == null ? void 0 : F.display_template, S = E(() => {
137
138
  const e = l.section_by.split(".")[0];
138
- return ((X == null ? void 0 : X.relations) ?? []).find(
139
- (t) => t.one_collection === x && t.one_field === e && !!t.junction_field
139
+ return ((F == null ? void 0 : F.relations) ?? []).find(
140
+ (t) => t.one_collection === y && t.one_field === e && !!t.junction_field
140
141
  ) ?? null;
141
- }, [X, x, l.section_by]), ce = (A == null ? void 0 : A.many_collection) ?? null, { data: De = [] } = z({
142
- queryKey: ["collection-relations", ce],
143
- queryFn: () => h.request(R(`/collections/${ce}`)).then((e) => {
142
+ }, [F, y, l.section_by]), P = (S == null ? void 0 : S.many_collection) ?? null, { data: me = [] } = V({
143
+ queryKey: ["collection-relations", P],
144
+ queryFn: () => p.request(A(`/collections/${P}`)).then((e) => {
144
145
  var t;
145
146
  return ((t = e.data) == null ? void 0 : t.relations) ?? [];
146
147
  }),
147
- enabled: !!ce,
148
+ enabled: !!P,
148
149
  staleTime: 10 * 6e4
149
- }), Q = O(() => {
150
- if (!(A != null && A.many_field) || !ce) return null;
151
- const e = String(A.junction_field), t = De.find(
152
- (s) => s.many_collection === ce && s.many_field === e
153
- ), r = Dr(t);
150
+ }), R = E(() => {
151
+ if (!(S != null && S.many_field) || !P) return null;
152
+ const e = String(S.junction_field), t = me.find(
153
+ (s) => s.many_collection === P && s.many_field === e
154
+ ), r = Zr(t);
154
155
  return r ? {
155
- junction: ce,
156
- fkToItem: A.many_field,
156
+ junction: P,
157
+ fkToItem: S.many_field,
157
158
  fkToSection: e,
158
159
  target: r,
159
160
  labelPath: l.section_by.split(".").slice(1).join(".") || "id"
160
161
  } : null;
161
- }, [A, ce, De, l.section_by]), te = P == null ? void 0 : P.draft, { resolvedFilter: Te, resolvedSectionFilter: he, resolvedLinkFilter: a, missingParents: k } = O(() => {
162
+ }, [S, P, me, l.section_by]), H = z == null ? void 0 : z.draft, { resolvedFilter: Oe, resolvedSectionFilter: xe, resolvedLinkFilter: a, missingParents: k } = E(() => {
162
163
  const e = [], t = (o) => {
163
164
  if (typeof o == "string" && o.startsWith("$parent.")) {
164
- const i = o.slice(8), b = te == null ? void 0 : te[i];
165
+ const i = o.slice(8), b = H == null ? void 0 : H[i];
165
166
  return b == null || b === "" ? (e.push(i), o) : b;
166
167
  }
167
168
  return Array.isArray(o) ? o.map(t) : o && typeof o == "object" ? Object.fromEntries(Object.entries(o).map(([i, b]) => [i, t(b)])) : o;
@@ -172,60 +173,60 @@ function yn({
172
173
  resolvedLinkFilter: c,
173
174
  missingParents: [...new Set(e)]
174
175
  };
175
- }, [l.filter, l.section_filter, l.link_filter, te]), U = O(() => {
176
- if (!A || !he && !a) return Te;
176
+ }, [l.filter, l.section_filter, l.link_filter, H]), U = E(() => {
177
+ if (!S || !xe && !a) return Oe;
177
178
  const e = {
178
- ...he ?? {},
179
+ ...xe ?? {},
179
180
  ...a ? { _link: a } : {}
180
- }, t = { [A.one_field]: { _some: e } };
181
- return Te ? { _and: [Te, t] } : t;
182
- }, [A, he, a, Te]), J = O(() => {
181
+ }, t = { [S.one_field]: { _some: e } };
182
+ return Oe ? { _and: [Oe, t] } : t;
183
+ }, [S, xe, a, Oe]), B = E(() => {
183
184
  const e = /* @__PURE__ */ new Set(["id"]);
184
- X && !A && e.add(l.section_by);
185
- for (const t of [...(ee ?? "").matchAll(/\{\{([\w.]+)\}\}/g)]) e.add(t[1]);
185
+ F && !S && e.add(l.section_by);
186
+ for (const t of [...(J ?? "").matchAll(/\{\{([\w.]+)\}\}/g)]) e.add(t[1]);
186
187
  for (const t of Object.values(l.copy_fields ?? {})) e.add(t);
187
188
  for (const t of l.columns ?? []) e.add(t.field);
188
189
  return [...e].join(",");
189
- }, [ee, X, A, l.section_by, l.copy_fields, l.columns]), re = JSON.stringify(U ?? null), { data: M = [], isLoading: H } = z(
190
+ }, [J, F, S, l.section_by, l.copy_fields, l.columns]), re = JSON.stringify(U ?? null), { data: Y = [], isLoading: M } = V(
190
191
  {
191
- queryKey: ["catalog-picker", x, J, re],
192
- queryFn: () => h.request(
193
- R(`/items/${x}`, {
194
- limit: Wr,
195
- fields: J,
192
+ queryKey: ["catalog-picker", y, B, re],
193
+ queryFn: () => p.request(
194
+ A(`/items/${y}`, {
195
+ limit: en,
196
+ fields: B,
196
197
  ...U ? { filter: JSON.stringify(U) } : {}
197
198
  })
198
199
  ).then((e) => e.data ?? []),
199
200
  // Wait for the catalog meta: a to-many section path both narrows this
200
201
  // read and must stay out of its `fields=`.
201
- enabled: !!x && !!X && k.length === 0 && (!A || !!Q),
202
+ enabled: !!y && !!F && k.length === 0 && (!S || !!R),
202
203
  staleTime: 6e4
203
204
  }
204
- ), ie = JSON.stringify(he ?? null), { data: me = [], isLoading: ke } = z({
205
- queryKey: ["catalog-sections", Q == null ? void 0 : Q.target, Q == null ? void 0 : Q.labelPath, ie],
205
+ ), ie = JSON.stringify(xe ?? null), { data: ue = [], isLoading: we } = V({
206
+ queryKey: ["catalog-sections", R == null ? void 0 : R.target, R == null ? void 0 : R.labelPath, ie],
206
207
  queryFn: async () => {
207
- const e = Q;
208
- return (await ot(h, `/items/${e.target}`, {
208
+ const e = R;
209
+ return (await ct(p, `/items/${e.target}`, {
209
210
  fields: `id,${e.labelPath}`,
210
- ...he ? { filter: JSON.stringify(he) } : {}
211
+ ...xe ? { filter: JSON.stringify(xe) } : {}
211
212
  })).map((r) => ({
212
213
  id: String(r.id),
213
- name: String(rr(r, e.labelPath) ?? "").trim()
214
+ name: String(ir(r, e.labelPath) ?? "").trim()
214
215
  }));
215
216
  },
216
- enabled: !!Q && k.length === 0,
217
+ enabled: !!R && k.length === 0,
217
218
  staleTime: 6e4
218
- }), Re = O(() => me.map((e) => e.id), [me]), { data: Tt = [], isLoading: nr } = z({
219
+ }), Re = E(() => ue.map((e) => e.id), [ue]), { data: Tt = [], isLoading: lr } = V({
219
220
  queryKey: [
220
221
  "catalog-section-links",
221
- Q == null ? void 0 : Q.junction,
222
+ R == null ? void 0 : R.junction,
222
223
  Re.join(","),
223
224
  JSON.stringify(a ?? null)
224
225
  ],
225
226
  queryFn: async () => {
226
- const e = Q, t = [];
227
+ const e = R, t = [];
227
228
  for (let r = 0; r < Re.length; r += 200) {
228
- const s = Re.slice(r, r + 200), c = await ot(h, `/items/${e.junction}`, {
229
+ const s = Re.slice(r, r + 200), c = await ct(p, `/items/${e.junction}`, {
229
230
  fields: `${e.fkToItem},${e.fkToSection}`,
230
231
  filter: JSON.stringify(
231
232
  a ? { _and: [{ [e.fkToSection]: { _in: s } }, a] } : { [e.fkToSection]: { _in: s } }
@@ -236,10 +237,10 @@ function yn({
236
237
  }
237
238
  return t;
238
239
  },
239
- enabled: !!Q && Re.length > 0,
240
+ enabled: !!R && Re.length > 0,
240
241
  staleTime: 6e4
241
- }), Ot = O(() => {
242
- const e = new Map(me.map((r) => [r.id, r.name])), t = /* @__PURE__ */ new Map();
242
+ }), Ot = E(() => {
243
+ const e = new Map(ue.map((r) => [r.id, r.name])), t = /* @__PURE__ */ new Map();
243
244
  for (const r of Tt) {
244
245
  const s = e.get(r.section);
245
246
  if (!s) continue;
@@ -247,157 +248,157 @@ function yn({
247
248
  c.includes(s) || c.push(s), t.set(r.item, c);
248
249
  }
249
250
  return t;
250
- }, [me, Tt]), He = !!A && (!Q || ke || Re.length > 0 && nr), Me = O(() => {
251
+ }, [ue, Tt]), Ue = !!S && (!R || we || Re.length > 0 && lr), He = E(() => {
251
252
  const e = /* @__PURE__ */ new Map();
252
- for (const t of M) e.set(String(t.id), t);
253
+ for (const t of Y) e.set(String(t.id), t);
253
254
  return e;
254
- }, [M]), { data: we = [] } = z({
255
- queryKey: ["o2m-rows", f, y, _],
256
- queryFn: () => h.request(
257
- R(`/items/${f}`, {
258
- filter: JSON.stringify({ [y]: { _eq: _ } }),
255
+ }, [Y]), { data: Ne = [] } = V({
256
+ queryKey: ["o2m-rows", f, g, _],
257
+ queryFn: () => p.request(
258
+ A(`/items/${f}`, {
259
+ filter: JSON.stringify({ [g]: { _eq: _ } }),
259
260
  limit: 1e3
260
261
  })
261
262
  ).then((e) => e.data ?? []),
262
- enabled: !E,
263
+ enabled: !C,
263
264
  staleTime: 15e3
264
- }), Pe = !E && !!p, Ne = p ? p.getPendingRows(f, y) : [], We = Pe ? p.getPendingEdits(f, y) : /* @__PURE__ */ new Map(), sr = JSON.stringify([...We.entries()]), Ie = O(
265
- () => We.size === 0 ? we : we.map((e) => {
266
- const t = We.get(String(e.id));
265
+ }), Ee = !C && !!x, ve = x ? x.getPendingRows(f, g) : [], Me = Ee ? x.getPendingEdits(f, g) : /* @__PURE__ */ new Map(), or = JSON.stringify([...Me.entries()]), We = E(
266
+ () => Me.size === 0 ? Ne : Ne.map((e) => {
267
+ const t = Me.get(String(e.id));
267
268
  return t ? { ...e, ...t } : e;
268
269
  }),
269
- [we, sr]
270
- ), Ye = !E && p ? p.getPendingDeletes(f, y) : /* @__PURE__ */ new Set(), Ee = O(() => {
270
+ [Ne, or]
271
+ ), Ie = !C && x ? x.getPendingDeletes(f, g) : /* @__PURE__ */ new Set(), Ae = E(() => {
271
272
  const e = /* @__PURE__ */ new Map();
272
- for (const t of Ie) {
273
+ for (const t of We) {
273
274
  const r = t[l.item_field];
274
275
  r != null && e.set(String(r), t);
275
276
  }
276
277
  return e;
277
- }, [Ie, l.item_field]), Ze = O(() => {
278
+ }, [We, l.item_field]), Ye = E(() => {
278
279
  const e = /* @__PURE__ */ new Map();
279
- return Ne.forEach((t, r) => {
280
+ return ve.forEach((t, r) => {
280
281
  const s = t[l.item_field];
281
282
  s != null && e.set(String(s), r);
282
283
  }), e;
283
- }, [Ne, l.item_field]), le = O(() => {
284
- const e = Ne.filter((s) => s[l.item_field] != null).map((s) => ({ key: String(s[l.item_field]), row: s }));
285
- if (E) return e;
286
- const t = Ie.filter((s) => s[l.item_field] != null).map((s) => ({ key: String(s[l.item_field]), row: s })), r = new Set(t.map((s) => s.key));
284
+ }, [ve, l.item_field]), le = E(() => {
285
+ const e = ve.filter((s) => s[l.item_field] != null).map((s) => ({ key: String(s[l.item_field]), row: s }));
286
+ if (C) return e;
287
+ const t = We.filter((s) => s[l.item_field] != null).map((s) => ({ key: String(s[l.item_field]), row: s })), r = new Set(t.map((s) => s.key));
287
288
  return [...t, ...e.filter((s) => !r.has(s.key))];
288
- }, [E, Ne, Ie, l.item_field]), Ge = O(
289
- () => le.filter((e) => !Me.has(e.key)).map((e) => e.key),
290
- [le, Me]
291
- ), { data: Rt = [] } = z({
292
- queryKey: ["catalog-picker-labels", x, J, Ge.join(",")],
293
- queryFn: () => h.request(
294
- R(`/items/${x}`, {
295
- filter: JSON.stringify({ id: { _in: Ge } }),
296
- fields: J,
297
- limit: Ge.length
289
+ }, [C, ve, We, l.item_field]), Ze = E(
290
+ () => le.filter((e) => !He.has(e.key)).map((e) => e.key),
291
+ [le, He]
292
+ ), { data: Pt = [] } = V({
293
+ queryKey: ["catalog-picker-labels", y, B, Ze.join(",")],
294
+ queryFn: () => p.request(
295
+ A(`/items/${y}`, {
296
+ filter: JSON.stringify({ id: { _in: Ze } }),
297
+ fields: B,
298
+ limit: Ze.length
298
299
  })
299
300
  ).then((e) => e.data ?? []),
300
- enabled: !!x && Ge.length > 0,
301
+ enabled: !!y && Ze.length > 0,
301
302
  staleTime: 6e4
302
- }), { data: xe = [] } = z({
303
- queryKey: ["pinned-items", x],
304
- queryFn: () => h.request(R(`/pinned/${x}`)).then((e) => e.data ?? []),
305
- enabled: !!x && !!l.favorites,
303
+ }), { data: ge = [] } = V({
304
+ queryKey: ["pinned-items", y],
305
+ queryFn: () => p.request(A(`/pinned/${y}`)).then((e) => e.data ?? []),
306
+ enabled: !!y && !!l.favorites,
306
307
  staleTime: 6e4
307
- }), dt = O(() => new Set(xe), [xe]), { data: Le = [] } = z({
308
- queryKey: ["pinned-item-rows", x, J, xe.join(",")],
309
- queryFn: () => h.request(
310
- R(`/items/${x}`, {
311
- filter: JSON.stringify({ id: { _in: xe } }),
312
- fields: J,
313
- limit: xe.length
308
+ }), mt = E(() => new Set(ge), [ge]), { data: Ce = [] } = V({
309
+ queryKey: ["pinned-item-rows", y, B, ge.join(",")],
310
+ queryFn: () => p.request(
311
+ A(`/items/${y}`, {
312
+ filter: JSON.stringify({ id: { _in: ge } }),
313
+ fields: B,
314
+ limit: ge.length
314
315
  })
315
316
  ).then((e) => e.data ?? []),
316
- enabled: !!x && !!l.favorites && xe.length > 0,
317
+ enabled: !!y && !!l.favorites && ge.length > 0,
317
318
  staleTime: 6e4
318
- }), [Xe, Pt] = Y(/* @__PURE__ */ new Set());
319
+ }), [Ge, Rt] = W(/* @__PURE__ */ new Set());
319
320
  async function Et(e) {
320
- if (!(!x || Xe.has(e))) {
321
- Pt((t) => new Set(t).add(e));
321
+ if (!(!y || Ge.has(e))) {
322
+ Rt((t) => new Set(t).add(e));
322
323
  try {
323
- await h.request(Zt(`/pinned/${x}/${e}/toggle`)).catch(() => {
324
- }), await $.invalidateQueries({ queryKey: ["pinned-items", x] });
324
+ await p.request(Xt(`/pinned/${y}/${e}/toggle`)).catch(() => {
325
+ }), await j.invalidateQueries({ queryKey: ["pinned-items", y] });
325
326
  } finally {
326
- Pt((t) => {
327
+ Rt((t) => {
327
328
  const r = new Set(t);
328
329
  return r.delete(e), r;
329
330
  });
330
331
  }
331
332
  }
332
333
  }
333
- const [ar, Lt] = Y(!1), At = Ve(null), ct = (e) => l.favorites ? /* @__PURE__ */ n(
334
+ const [dr, At] = W(!1), Ct = Ve(null), ut = (e) => l.favorites ? /* @__PURE__ */ n(
334
335
  "button",
335
336
  {
336
337
  type: "button",
337
- title: dt.has(e) ? "Remove from favorites" : "Add to favorites",
338
- disabled: Xe.has(e),
338
+ title: mt.has(e) ? "Remove from favorites" : "Add to favorites",
339
+ disabled: Ge.has(e),
339
340
  onClick: (t) => {
340
341
  t.stopPropagation(), Et(e);
341
342
  },
342
343
  className: "shrink-0 rounded p-0.5 transition-colors",
343
- children: Xe.has(e) ? /* @__PURE__ */ n(ae, { className: "h-3.5 w-3.5 animate-spin text-amber-400" }) : /* @__PURE__ */ n(
344
+ children: Ge.has(e) ? /* @__PURE__ */ n(ne, { className: "h-3.5 w-3.5 animate-spin text-amber-400" }) : /* @__PURE__ */ n(
344
345
  Be,
345
346
  {
346
- className: B(
347
+ className: Q(
347
348
  "h-3.5 w-3.5",
348
- dt.has(e) ? "fill-amber-400 text-amber-400" : "text-slate-300 hover:text-amber-400"
349
+ mt.has(e) ? "fill-amber-400 text-amber-400" : "text-slate-300 hover:text-amber-400"
349
350
  )
350
351
  }
351
352
  )
352
353
  }
353
- ) : null, [mt, ir] = Y("");
354
- je(() => {
355
- const e = setTimeout(() => ir(C), 300);
354
+ ) : null, [ft, cr] = W("");
355
+ Fe(() => {
356
+ const e = setTimeout(() => cr(L), 300);
356
357
  return () => clearTimeout(e);
357
- }, [C]);
358
- const lr = O(() => {
358
+ }, [L]);
359
+ const mr = E(() => {
359
360
  var t;
360
- const e = (t = [...(ee ?? "").matchAll(/\{\{([\w.]+)\}\}/g)][0]) == null ? void 0 : t[1];
361
+ const e = (t = [...(J ?? "").matchAll(/\{\{([\w.]+)\}\}/g)][0]) == null ? void 0 : t[1];
361
362
  return e && !e.includes(".") ? e : "id";
362
- }, [ee]), { data: or = [], isFetching: ut } = z({
363
- queryKey: ["catalog-full-search", x, J, mt],
364
- queryFn: () => h.request(
365
- R(`/items/${x}`, {
366
- search: mt,
367
- fields: J,
363
+ }, [J]), { data: ur = [], isFetching: bt } = V({
364
+ queryKey: ["catalog-full-search", y, B, ft],
365
+ queryFn: () => p.request(
366
+ A(`/items/${y}`, {
367
+ search: ft,
368
+ fields: B,
368
369
  limit: 25,
369
- sort: lr
370
+ sort: mr
370
371
  })
371
372
  ).then((e) => e.data ?? []),
372
- enabled: !!x && mt.trim().length > 0,
373
+ enabled: !!y && ft.trim().length > 0,
373
374
  staleTime: 3e4,
374
375
  placeholderData: (e) => e
375
- }), Se = or, et = O(() => {
376
+ }), $e = ur, Xe = E(() => {
376
377
  const e = /* @__PURE__ */ new Set();
377
- for (const t of M) e.add(String(t.id));
378
+ for (const t of Y) e.add(String(t.id));
378
379
  for (const t of le) e.add(t.key);
379
- for (const t of xe) e.add(t);
380
- for (const t of Se) e.add(String(t.id));
380
+ for (const t of ge) e.add(t);
381
+ for (const t of $e) e.add(String(t.id));
381
382
  return [...e];
382
- }, [M, le, xe, Se]), Ct = $t({
383
+ }, [Y, le, ge, $e]), Lt = $t({
383
384
  queries: (l.related_columns ?? []).map((e) => {
384
- const t = Ue(e.match, te);
385
+ const t = De(e.match, H);
385
386
  return {
386
387
  queryKey: [
387
388
  "catalog-related",
388
389
  e.key,
389
390
  e.collection,
390
391
  JSON.stringify(t),
391
- et.join(",")
392
+ Xe.join(",")
392
393
  ],
393
394
  queryFn: async () => {
394
395
  const r = {}, s = e.aggregate === "sum", c = s ? 150 : 400;
395
- for (let o = 0; o < et.length; o += c) {
396
- const i = et.slice(o, o + c);
396
+ for (let o = 0; o < Xe.length; o += c) {
397
+ const i = Xe.slice(o, o + c);
397
398
  let b = 1;
398
399
  for (; ; ) {
399
- const d = await h.request(
400
- R(`/items/${e.collection}`, {
400
+ const d = await p.request(
401
+ A(`/items/${e.collection}`, {
401
402
  limit: s ? 1e3 : i.length,
402
403
  ...s ? { page: b } : {},
403
404
  fields: `${e.item_field},${e.value_field}`,
@@ -408,8 +409,8 @@ function yn({
408
409
  const w = u[e.item_field];
409
410
  if (w != null)
410
411
  if (s) {
411
- const j = Number(u[e.value_field]);
412
- r[String(w)] = (Number(r[String(w)]) || 0) + (Number.isNaN(j) ? 0 : j);
412
+ const T = Number(u[e.value_field]);
413
+ r[String(w)] = (Number(r[String(w)]) || 0) + (Number.isNaN(T) ? 0 : T);
413
414
  } else
414
415
  r[String(w)] = u[e.value_field];
415
416
  }
@@ -419,28 +420,28 @@ function yn({
419
420
  }
420
421
  return r;
421
422
  },
422
- enabled: !!x && t !== null && et.length > 0,
423
+ enabled: !!y && t !== null && Xe.length > 0,
423
424
  staleTime: 3e4
424
425
  };
425
426
  })
426
- }), ft = (e, t) => {
427
+ }), pt = (e, t) => {
427
428
  var s, c;
428
429
  const r = (l.related_columns ?? []).findIndex((o) => o.key === e);
429
430
  if (r !== -1)
430
- return (c = (s = Ct[r]) == null ? void 0 : s.data) == null ? void 0 : c[t];
431
- }, bt = (e) => {
431
+ return (c = (s = Lt[r]) == null ? void 0 : s.data) == null ? void 0 : c[t];
432
+ }, ht = (e) => {
432
433
  var b;
433
434
  const t = l.qty_warning;
434
435
  if (!t) return null;
435
- const r = fe(e) ?? 0;
436
+ const r = be(e) ?? 0;
436
437
  if (r <= 0) return null;
437
438
  const s = (l.related_columns ?? []).findIndex((d) => d.key === t.column);
438
439
  if (s === -1) return null;
439
- const c = (b = Ct[s]) == null ? void 0 : b.data;
440
+ const c = (b = Lt[s]) == null ? void 0 : b.data;
440
441
  if (c === void 0) return null;
441
442
  const o = c[e], i = o == null || o === "" ? 0 : Number(o);
442
443
  return Number.isNaN(i) ? null : r > i ? { available: i, qty: r } : null;
443
- }, dr = (e) => {
444
+ }, fr = (e) => {
444
445
  const t = l.row_flags ?? [];
445
446
  if (t.length === 0) return [];
446
447
  const r = [];
@@ -448,93 +449,93 @@ function yn({
448
449
  if (!(!(s != null && s.when) || !s.label))
449
450
  try {
450
451
  const c = s.when.replace(/\{\{\s*([A-Za-z_][A-Za-z0-9_.]*)\s*\}\}/g, "$1");
451
- Pr(c, e) && r.push(s.label);
452
+ Jr(c, e) && r.push(s.label);
452
453
  } catch {
453
454
  }
454
455
  return r;
455
- }, pt = l.qty_warning ? l.qty_warning.label ?? ((Mt = (l.related_columns ?? []).find((e) => {
456
+ }, xt = l.qty_warning ? l.qty_warning.label ?? ((Wt = (l.related_columns ?? []).find((e) => {
456
457
  var t;
457
458
  return e.key === ((t = l.qty_warning) == null ? void 0 : t.column);
458
- })) == null ? void 0 : Mt.label) ?? I(l.qty_warning.column) : "", cr = !!l.submission_errors, tt = O(
459
+ })) == null ? void 0 : Wt.label) ?? Z(l.qty_warning.column) : "", br = !!l.submission_errors, et = E(
459
460
  () => {
460
461
  var e;
461
462
  return typeof l.submission_errors == "object" && Array.isArray((e = l.submission_errors) == null ? void 0 : e.match_fields) ? l.submission_errors.match_fields.filter((t) => /^[A-Za-z_][A-Za-z0-9_]*$/.test(t)) : [];
462
463
  },
463
464
  [l.submission_errors]
464
- ), mr = Er(6e4), { data: Kt } = z({
465
- queryKey: ["erp-submissions", q ?? "", String(_)],
466
- queryFn: () => h.request(R(`/erp-submissions/${q}/${encodeURIComponent(_)}`)).then((e) => e.data ?? []),
467
- enabled: cr && !E && !!q,
465
+ ), pr = Qr(6e4), { data: Kt } = V({
466
+ queryKey: ["erp-submissions", $ ?? "", String(_)],
467
+ queryFn: () => p.request(A(`/erp-submissions/${$}/${encodeURIComponent(_)}`)).then((e) => e.data ?? []),
468
+ enabled: br && !C && !!$,
468
469
  staleTime: 15e3,
469
- refetchInterval: mr
470
- }), ht = O(() => {
470
+ refetchInterval: pr
471
+ }), gt = E(() => {
471
472
  const e = (Kt ?? [])[0];
472
- return !e || e.status !== "failed" ? null : Lr(e.payload, e.last_error);
473
- }, [Kt]), ur = le.map((e) => e.key).join(","), { data: xt } = z({
474
- queryKey: ["catalog-suberr-idents", x, tt.join(","), ur],
473
+ return !e || e.status !== "failed" ? null : zr(e.payload, e.last_error);
474
+ }, [Kt]), hr = le.map((e) => e.key).join(","), { data: yt } = V({
475
+ queryKey: ["catalog-suberr-idents", y, et.join(","), hr],
475
476
  queryFn: async () => {
476
477
  const e = le.map((r) => r.key);
477
478
  if (e.length === 0) return {};
478
- const t = await h.request(
479
- R(`/items/${x}`, {
479
+ const t = await p.request(
480
+ A(`/items/${y}`, {
480
481
  limit: e.length,
481
- fields: ["id", ...tt].join(","),
482
+ fields: ["id", ...et].join(","),
482
483
  filter: JSON.stringify({ id: { _in: e } })
483
484
  })
484
485
  ).then((r) => r.data ?? []);
485
486
  return Object.fromEntries(t.map((r) => [String(r.id), r]));
486
487
  },
487
- enabled: !!x && !!ht && tt.length > 0 && le.length > 0,
488
+ enabled: !!y && !!gt && et.length > 0 && le.length > 0,
488
489
  staleTime: 6e4
489
- }), fr = (e) => {
490
- if (!ht) return null;
491
- const t = xt == null ? void 0 : xt[e], r = [
492
- Dt(e),
493
- ...tt.map((s) => {
494
- const c = (t == null ? void 0 : t[s]) ?? qe(e)[s];
490
+ }), xr = (e) => {
491
+ if (!gt) return null;
492
+ const t = yt == null ? void 0 : yt[e], r = [
493
+ Ht(e),
494
+ ...et.map((s) => {
495
+ const c = (t == null ? void 0 : t[s]) ?? Pe(e)[s];
495
496
  return c != null && c !== "" ? String(c) : null;
496
497
  })
497
- ].filter((s) => !!s).map(Ar);
498
- return ht.reasonFor(r);
499
- }, rt = l.summary_fields ?? [], br = we.map((e) => String(e.id)).join(","), pr = $t({
500
- queries: rt.filter((e) => e.m2m).map((e) => ({
501
- queryKey: ["catalog-summary-m2m", e.field, e.m2m.junction, br],
498
+ ].filter((s) => !!s).map(Br);
499
+ return gt.reasonFor(r);
500
+ }, tt = l.summary_fields ?? [], gr = Ne.map((e) => String(e.id)).join(","), yr = $t({
501
+ queries: tt.filter((e) => e.m2m).map((e) => ({
502
+ queryKey: ["catalog-summary-m2m", e.field, e.m2m.junction, gr],
502
503
  queryFn: async () => {
503
- const t = we.map((u) => String(u.id));
504
+ const t = Ne.map((u) => String(u.id));
504
505
  if (t.length === 0) return {};
505
- const r = e.m2m, s = await h.request(
506
- R(`/items/${r.junction}`, {
506
+ const r = e.m2m, s = await p.request(
507
+ A(`/items/${r.junction}`, {
507
508
  limit: 1e3,
508
509
  fields: `${r.fk_to_child},${r.related_field}`,
509
510
  filter: JSON.stringify({ [r.fk_to_child]: { _in: t } })
510
511
  })
511
- ).then((u) => u.data ?? []).catch(() => []), c = [...new Set(s.map((u) => String(u[r.related_field])))], o = r.label_field ?? "name", i = c.length ? await h.request(
512
- R(`/items/${r.related_collection}`, {
512
+ ).then((u) => u.data ?? []).catch(() => []), c = [...new Set(s.map((u) => String(u[r.related_field])))], o = r.label_field ?? "name", i = c.length ? await p.request(
513
+ A(`/items/${r.related_collection}`, {
513
514
  limit: 500,
514
515
  fields: `id,${o}`,
515
516
  filter: JSON.stringify({ id: { _in: c } })
516
517
  })
517
518
  ).then((u) => u.data ?? []).catch(() => []) : [], b = new Map(i.map((u) => [String(u.id), String(u[o] ?? u.id)])), d = {};
518
519
  for (const u of s) {
519
- const w = String(u[r.fk_to_child]), j = b.get(String(u[r.related_field]));
520
- j && (d[w] = d[w] ? `${d[w]}, ${j}` : j);
520
+ const w = String(u[r.fk_to_child]), T = b.get(String(u[r.related_field]));
521
+ T && (d[w] = d[w] ? `${d[w]}, ${T}` : T);
521
522
  }
522
523
  return d;
523
524
  },
524
- enabled: !E && we.length > 0,
525
+ enabled: !C && Ne.length > 0,
525
526
  staleTime: 15e3
526
527
  }))
527
- }), hr = (e, t) => {
528
+ }), kr = (e, t) => {
528
529
  var c, o;
529
530
  if (!e.m2m) return t.row[e.field];
530
- const r = rt.filter((i) => i.m2m).findIndex((i) => i.field === e.field);
531
+ const r = tt.filter((i) => i.m2m).findIndex((i) => i.field === e.field);
531
532
  if (r === -1) return;
532
533
  const s = t.row.id;
533
534
  if (s != null)
534
- return (o = (c = pr[r]) == null ? void 0 : c.data) == null ? void 0 : o[String(s)];
535
- }, xr = !!((Wt = l.fulfilment) != null && Wt.shipped_field) && (l.fulfilment.show_when ? Xt(l.fulfilment.show_when, te) : !0), gr = (e) => {
536
- if (!xr || !l.fulfilment) return null;
537
- const t = Number(e[l.fulfilment.qty_field ?? V] ?? 0) || 0, r = Number(e[l.fulfilment.shipped_field] ?? 0) || 0, s = t > 0 && r >= t ? {
535
+ return (o = (c = yr[r]) == null ? void 0 : c.data) == null ? void 0 : o[String(s)];
536
+ }, wr = !!((It = l.fulfilment) != null && It.shipped_field) && (l.fulfilment.show_when ? rr(l.fulfilment.show_when, H) : !0), Nr = (e) => {
537
+ if (!wr || !l.fulfilment) return null;
538
+ const t = Number(e[l.fulfilment.qty_field ?? O] ?? 0) || 0, r = Number(e[l.fulfilment.shipped_field] ?? 0) || 0, s = t > 0 && r >= t ? {
538
539
  dot: "bg-emerald-500",
539
540
  text: "text-emerald-700 dark:text-emerald-400",
540
541
  label: "Shipped"
@@ -559,7 +560,7 @@ function yn({
559
560
  ]
560
561
  }
561
562
  );
562
- }, Jt = l.columns ?? [], Qt = l.related_columns ?? [], gt = Jt.filter((e) => !e.summary_only), yt = Qt.filter((e) => !e.summary_only), zt = Jt.filter((e) => !e.sections_only), Bt = Qt.filter((e) => !e.sections_only), Vt = gt.length > 0 || yt.length > 0, kt = Ve(null), Ut = (e) => {
563
+ }, Jt = l.columns ?? [], Qt = l.related_columns ?? [], rt = Jt.filter((e) => !e.summary_only), kt = Qt.filter((e) => !e.summary_only), zt = Jt.filter((e) => !e.sections_only), Bt = Qt.filter((e) => !e.sections_only), Vt = rt.length > 0 || kt.length > 0, wt = Ve(null), Dt = (e) => {
563
564
  let t = e.parentElement;
564
565
  for (; t; ) {
565
566
  const r = getComputedStyle(t);
@@ -569,88 +570,85 @@ function yn({
569
570
  }
570
571
  t = t.parentElement;
571
572
  }
572
- }, yr = (e) => {
573
- kt.current = e, e && Ut(e);
573
+ }, vr = (e) => {
574
+ wt.current = e, e && Dt(e);
574
575
  };
575
- je(() => {
576
+ Fe(() => {
576
577
  let e = 0;
577
578
  const t = () => {
578
579
  e || (e = requestAnimationFrame(() => {
579
- e = 0, kt.current && Ut(kt.current);
580
+ e = 0, wt.current && Dt(wt.current);
580
581
  }));
581
582
  };
582
583
  return window.addEventListener("scroll", t, !0), () => {
583
584
  e && cancelAnimationFrame(e), window.removeEventListener("scroll", t, !0);
584
585
  };
585
586
  }, []);
586
- const Ae = (e, t) => {
587
+ const nt = (e, t) => {
587
588
  let r = e;
588
589
  for (const s of t.split(".")) {
589
590
  if (r == null || typeof r != "object") return;
590
591
  r = r[s];
591
592
  }
592
593
  return r;
593
- }, ue = (e, t) => {
594
+ }, fe = (e, t) => {
594
595
  if (t === "presence")
595
596
  return e == null || e === "" || Number(e) === 0 ? "No" : "Yes";
596
597
  if (e == null || e === "") return "—";
597
598
  const r = Number(e);
598
599
  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);
599
- }, wt = (e, t) => /* @__PURE__ */ m(qt, { children: [
600
- gt.map((r) => /* @__PURE__ */ n(
601
- "span",
600
+ }, _r = (Yt = rt.find((e) => !e.format)) == null ? void 0 : Yt.field, Ut = (e) => e.format ? "w-20 shrink-0 text-right" : e.field === _r ? "min-w-0 flex-[3]" : "w-36 shrink-0", Nt = (e, t) => /* @__PURE__ */ m(lt, { children: [
601
+ rt.map((r) => /* @__PURE__ */ n(
602
+ nr,
602
603
  {
603
- className: B(
604
- "truncate text-slate-500 dark:text-slate-400",
605
- r.format ? "w-20 shrink-0 text-right" : "min-w-0 flex-1"
606
- ),
607
- children: ue(Ae(t, r.field), r.format)
604
+ text: fe(nt(t, r.field), r.format),
605
+ className: Q("text-slate-500 dark:text-slate-400", Ut(r))
608
606
  },
609
607
  r.field
610
608
  )),
611
- yt.map((r) => /* @__PURE__ */ n(
609
+ kt.map((r) => /* @__PURE__ */ n(
612
610
  "span",
613
611
  {
614
612
  className: "w-20 shrink-0 truncate text-right text-slate-500 dark:text-slate-400",
615
- children: ue(ft(r.key, e), r.format)
613
+ children: fe(pt(r.key, e), r.format)
616
614
  },
617
615
  r.key
618
616
  ))
619
- ] }), Nt = Vt ? "w-36 shrink-0 truncate text-slate-700 dark:text-slate-200" : "min-w-0 flex-1 truncate text-slate-700 dark:text-slate-200", kr = er(x), nt = (e, t, r) => kr ? /* @__PURE__ */ n(
617
+ ] }), vt = Vt ? "w-36 shrink-0 truncate text-slate-700 dark:text-slate-200" : "min-w-0 flex-1 truncate text-slate-700 dark:text-slate-200", Sr = sr(y), st = (e, t, r) => Sr ? /* @__PURE__ */ n(
620
618
  "button",
621
619
  {
622
620
  type: "button",
623
- onClick: () => x && tr(x, e, te),
621
+ onClick: () => y && ar(y, e, H),
624
622
  title: "View stock & planning detail",
625
- className: B(
623
+ className: Q(
626
624
  r,
627
625
  "text-left underline decoration-slate-300 decoration-1 underline-offset-2 hover:text-[#009abe] hover:decoration-[#009abe] dark:decoration-slate-600"
628
626
  ),
629
627
  children: t
630
628
  }
631
- ) : /* @__PURE__ */ n("span", { className: r, children: t }), Dt = (e) => {
632
- const t = Me.get(e) ?? Rt.find((r) => String(r.id) === e) ?? Le.find((r) => String(r.id) === e);
633
- return t ? Fe(ee, t) : `#${e}`;
634
- }, qe = (e) => Me.get(e) ?? Rt.find((t) => String(t.id) === e) ?? Le.find((t) => String(t.id) === e) ?? { id: e }, fe = (e) => {
629
+ ) : /* @__PURE__ */ n("span", { className: r, children: t }), Ht = (e) => {
630
+ const t = He.get(e) ?? Pt.find((r) => String(r.id) === e) ?? Ce.find((r) => String(r.id) === e);
631
+ return t ? Te(J, t) : `#${e}`;
632
+ }, Pe = (e) => He.get(e) ?? Pt.find((t) => String(t.id) === e) ?? Ce.find((t) => String(t.id) === e) ?? { id: e }, be = (e) => {
635
633
  var s;
636
- const t = E ? void 0 : Ee.get(e);
637
- if (t) return Ye.has(String(t.id)) ? null : Number(t[V] ?? 0);
638
- const r = Ze.get(e);
639
- return r === void 0 ? null : Number(((s = Ne[r]) == null ? void 0 : s[V]) ?? 0);
640
- }, wr = (e) => {
634
+ const t = C ? void 0 : Ae.get(e);
635
+ if (t) return Ie.has(String(t.id)) ? null : Number(t[O] ?? 0);
636
+ const r = Ye.get(e);
637
+ return r === void 0 ? null : Number(((s = ve[r]) == null ? void 0 : s[O]) ?? 0);
638
+ }, qr = (e) => {
641
639
  let t = e;
642
640
  for (const r of l.section_by.split(".")) {
643
641
  if (t == null || typeof t != "object") return "";
644
642
  t = t[r];
645
643
  }
646
644
  return String(t ?? "").trim();
647
- }, st = O(() => {
648
- if (He) return [];
649
- C.trim().toLowerCase();
645
+ }, at = E(() => {
646
+ if (Ue) return [];
647
+ L.trim().toLowerCase();
650
648
  const e = /* @__PURE__ */ new Map();
651
- for (const t of M) {
652
- const r = Fe(ee, t), s = A ? Ot.get(String(t.id)) ?? [] : [wr(t)];
653
- if (!(A && a && s.length === 0))
649
+ for (const t of Y) {
650
+ const r = Te(J, t), s = S ? Ot.get(String(t.id)) ?? [] : [qr(t)];
651
+ if (!(S && a && s.length === 0))
654
652
  for (const c of s.length ? s : [""]) {
655
653
  const o = c || "Uncategorized";
656
654
  e.has(o) || e.set(o, []), e.get(o).push({ id: String(t.id), label: r, row: t });
@@ -663,32 +661,32 @@ function yn({
663
661
  items: r.sort((s, c) => s.label.localeCompare(c.label))
664
662
  }));
665
663
  }, [
666
- M,
667
- ee,
668
- C,
664
+ Y,
665
+ J,
666
+ L,
669
667
  l.section_by,
670
- A,
668
+ S,
671
669
  Ot,
672
- He,
670
+ Ue,
673
671
  a
674
672
  ]);
675
- if (!ge.current && st.length > 0) {
676
- ge.current = !0;
673
+ if (!Se.current && at.length > 0) {
674
+ Se.current = !0;
677
675
  const e = /* @__PURE__ */ new Set();
678
- for (const t of st)
679
- t.items.some((s) => (fe(s.id) ?? 0) > 0) || e.add(t.name);
680
- ne(e);
676
+ for (const t of at)
677
+ t.items.some((s) => (be(s.id) ?? 0) > 0) || e.add(t.name);
678
+ G(e);
681
679
  }
682
- async function Nr(e) {
680
+ async function $r(e) {
683
681
  const t = {};
684
682
  for (const r of l.related_columns ?? []) {
685
683
  if (!r.copy_to) continue;
686
- let s = ft(r.key, e);
684
+ let s = pt(r.key, e);
687
685
  if (s === void 0) {
688
- const c = Ue(r.match, te);
686
+ const c = De(r.match, H);
689
687
  if (c === null) continue;
690
- s = await h.request(
691
- R(`/items/${r.collection}`, {
688
+ s = await p.request(
689
+ A(`/items/${r.collection}`, {
692
690
  limit: 1,
693
691
  fields: `${r.item_field},${r.value_field}`,
694
692
  filter: JSON.stringify({ ...c, [r.item_field]: { _eq: e } })
@@ -703,10 +701,10 @@ function yn({
703
701
  }
704
702
  return t;
705
703
  }
706
- function Ce(e, t, r, s = {}) {
704
+ function Le(e, t, r, s = {}) {
707
705
  const c = {
708
706
  [l.item_field]: r.id ?? e,
709
- [V]: t
707
+ [O]: t
710
708
  };
711
709
  for (const [o, i] of Object.entries(l.copy_fields ?? {}))
712
710
  r[i] !== void 0 && (c[o] = r[i]);
@@ -717,100 +715,100 @@ function yn({
717
715
  }
718
716
  return c;
719
717
  }
720
- async function at(e, t, r, s = {}) {
721
- const c = Gt(t, { type: _e, min: 0, label: "Quantity" });
718
+ async function Ke(e, t, r, s = {}) {
719
+ const c = tr(t, { type: v, min: 0, label: "Quantity" });
722
720
  if (!c.ok) {
723
- F((d) => ({ ...d, [e]: { kind: "error", message: c.message } }));
721
+ X((d) => ({ ...d, [e]: { kind: "error", message: c.message } }));
724
722
  return;
725
723
  }
726
724
  const o = c.value ?? 0;
727
- if ((fe(e) ?? 0) === o) return;
725
+ if ((be(e) ?? 0) === o) return;
728
726
  if (o === 0 && !s.confirmedRemove) {
729
- F((d) => ({ ...d, [e]: { kind: "remove", row: r } }));
727
+ X((d) => ({ ...d, [e]: { kind: "remove", row: r } }));
730
728
  return;
731
729
  }
732
730
  if (o > 0) {
733
- const d = Ze.get(e), u = (E ? void 0 : Ee.get(e)) ?? (d !== void 0 ? Ne[d] : void 0) ?? {}, w = Oe(V, o, u);
731
+ const d = Ye.get(e), u = (C ? void 0 : Ae.get(e)) ?? (d !== void 0 ? ve[d] : void 0) ?? {}, w = K(O, o, u);
734
732
  if (w) {
735
- F((j) => ({ ...j, [e]: { kind: "error", message: w } }));
733
+ X((T) => ({ ...T, [e]: { kind: "error", message: w } }));
736
734
  return;
737
735
  }
738
736
  }
739
- const b = o > 0 ? await Nr(e) : {};
740
- if (Pe && p) {
741
- const d = Ee.get(e);
737
+ const b = o > 0 ? await $r(e) : {};
738
+ if (Ee && x) {
739
+ const d = Ae.get(e);
742
740
  if ((d == null ? void 0 : d.id) != null) {
743
741
  const u = String(d.id);
744
742
  if (o === 0) {
745
- p.cancelPendingEdit(f, y, u), p.queueDelete(f, y, u);
743
+ x.cancelPendingEdit(f, g, u), x.queueDelete(f, g, u);
746
744
  return;
747
745
  }
748
- Ye.has(u) && p.cancelPendingDelete(f, y, u);
749
- const w = Ce(e, o, r, b);
750
- for (const S of D)
751
- d[S] != null && d[S] !== "" && (w[S] = d[S]);
752
- for (const [S, $e] of Object.entries(l.compute_fields ?? {})) {
753
- const ve = Qe($e, { ...d, ...w });
754
- ve !== null && (w[S] = ve);
746
+ Ie.has(u) && x.cancelPendingDelete(f, g, u);
747
+ const w = Le(e, o, r, b);
748
+ for (const q of se)
749
+ d[q] != null && d[q] !== "" && (w[q] = d[q]);
750
+ for (const [q, je] of Object.entries(l.compute_fields ?? {})) {
751
+ const _e = Qe(je, { ...d, ...w });
752
+ _e !== null && (w[q] = _e);
755
753
  }
756
- const j = we.find((S) => String(S.id) === u) ?? {}, N = Object.fromEntries(
757
- Object.entries(w).filter(([S, $e]) => String($e ?? "") !== String(j[S] ?? ""))
754
+ const T = Ne.find((q) => String(q.id) === u) ?? {}, N = Object.fromEntries(
755
+ Object.entries(w).filter(([q, je]) => String(je ?? "") !== String(T[q] ?? ""))
758
756
  );
759
- Object.keys(N).length === 0 ? p.cancelPendingEdit(f, y, u) : (p.cancelPendingEdit(f, y, u), p.queueEdit(f, y, u, N));
757
+ Object.keys(N).length === 0 ? x.cancelPendingEdit(f, g, u) : (x.cancelPendingEdit(f, g, u), x.queueEdit(f, g, u, N));
760
758
  return;
761
759
  }
762
760
  }
763
- if (E || Pe) {
764
- const d = Ze.get(e);
765
- o === 0 ? d !== void 0 && (p == null || p.removeRow(f, y, d)) : d !== void 0 ? p == null || p.updateRow(
761
+ if (C || Ee) {
762
+ const d = Ye.get(e);
763
+ o === 0 ? d !== void 0 && (x == null || x.removeRow(f, g, d)) : d !== void 0 ? x == null || x.updateRow(
766
764
  f,
767
- y,
765
+ g,
768
766
  d,
769
- Vr(
770
- Ne[d],
771
- Ce(e, o, r, b),
772
- D,
767
+ Ir(
768
+ ve[d],
769
+ Le(e, o, r, b),
770
+ se,
773
771
  l.compute_fields
774
772
  )
775
- ) : p == null || p.queueRow(
773
+ ) : x == null || x.queueRow(
776
774
  f,
777
- y,
778
- Ce(e, o, r, b)
775
+ g,
776
+ Le(e, o, r, b)
779
777
  );
780
778
  return;
781
779
  }
782
- v((d) => new Set(d).add(e));
780
+ ee((d) => new Set(d).add(e));
783
781
  try {
784
- const d = Ee.get(e);
782
+ const d = Ae.get(e);
785
783
  if (o === 0)
786
- (d == null ? void 0 : d.id) != null && await h.request(Rr(`/items/${f}/${d.id}`));
784
+ (d == null ? void 0 : d.id) != null && await p.request(Kr(`/items/${f}/${d.id}`));
787
785
  else if ((d == null ? void 0 : d.id) != null) {
788
- const u = Ce(e, o, r, b);
789
- for (const S of D)
790
- d[S] != null && d[S] !== "" && (u[S] = d[S]);
791
- for (const [S, $e] of Object.entries(l.compute_fields ?? {})) {
792
- const ve = Qe($e, { ...d, ...u });
793
- ve !== null && (u[S] = ve);
786
+ const u = Le(e, o, r, b);
787
+ for (const q of se)
788
+ d[q] != null && d[q] !== "" && (u[q] = d[q]);
789
+ for (const [q, je] of Object.entries(l.compute_fields ?? {})) {
790
+ const _e = Qe(je, { ...d, ...u });
791
+ _e !== null && (u[q] = _e);
794
792
  }
795
- const w = { ...d, ...u }, { id: j, ...N } = w;
796
- await h.request(Yt(`/items/${f}/${d.id}`, N));
793
+ const w = { ...d, ...u }, { id: T, ...N } = w;
794
+ await p.request(Gt(`/items/${f}/${d.id}`, N));
797
795
  } else
798
- await h.request(
799
- Zt(`/items/${f}`, {
800
- [y]: _,
801
- ...Ce(e, o, r, b)
796
+ await p.request(
797
+ Xt(`/items/${f}`, {
798
+ [g]: _,
799
+ ...Le(e, o, r, b)
802
800
  })
803
801
  );
804
- $.invalidateQueries({ queryKey: ["o2m-rows", f, y, _] });
802
+ j.invalidateQueries({ queryKey: ["o2m-rows", f, g, _] });
805
803
  } catch {
806
804
  } finally {
807
- v((d) => {
805
+ ee((d) => {
808
806
  const u = new Set(d);
809
807
  return u.delete(e), u;
810
808
  });
811
809
  }
812
810
  }
813
- async function vr(e, t, r) {
811
+ async function jr(e, t, r) {
814
812
  const s = r.trim() === "" ? null : Number(r);
815
813
  if (r.trim() !== "" && Number.isNaN(s)) return;
816
814
  const c = (i) => {
@@ -820,56 +818,56 @@ function yn({
820
818
  w !== null && (b[d] = w);
821
819
  }
822
820
  return b;
823
- }, o = E ? void 0 : Ee.get(e);
821
+ }, o = C ? void 0 : Ae.get(e);
824
822
  if ((o == null ? void 0 : o.id) == null) {
825
- const i = Ze.get(e);
823
+ const i = Ye.get(e);
826
824
  if (i === void 0) return;
827
- p == null || p.updateRow(f, y, i, c(Ne[i]));
825
+ x == null || x.updateRow(f, g, i, c(ve[i]));
828
826
  return;
829
827
  }
830
- if (Pe && p) {
831
- const i = c(o), b = we.find((u) => String(u.id) === String(o.id)) ?? {}, d = Object.fromEntries(
828
+ if (Ee && x) {
829
+ const i = c(o), b = Ne.find((u) => String(u.id) === String(o.id)) ?? {}, d = Object.fromEntries(
832
830
  Object.entries(i).filter(
833
831
  ([u, w]) => u !== "id" && String(w ?? "") !== String(b[u] ?? "")
834
832
  )
835
833
  );
836
- p.cancelPendingEdit(f, y, String(o.id)), Object.keys(d).length > 0 && p.queueEdit(f, y, String(o.id), d);
834
+ x.cancelPendingEdit(f, g, String(o.id)), Object.keys(d).length > 0 && x.queueEdit(f, g, String(o.id), d);
837
835
  return;
838
836
  }
839
- v((i) => new Set(i).add(e));
837
+ ee((i) => new Set(i).add(e));
840
838
  try {
841
839
  const { id: i, ...b } = c(o);
842
- await h.request(Yt(`/items/${f}/${o.id}`, b)), $.invalidateQueries({ queryKey: ["o2m-rows", f, y, _] });
840
+ await p.request(Gt(`/items/${f}/${o.id}`, b)), j.invalidateQueries({ queryKey: ["o2m-rows", f, g, _] });
843
841
  } catch {
844
842
  } finally {
845
- v((i) => {
843
+ ee((i) => {
846
844
  const b = new Set(i);
847
845
  return b.delete(e), b;
848
846
  });
849
847
  }
850
848
  }
851
- async function _r(e) {
852
- if (e == null || e === "" || !x) return;
853
- const t = String(e), r = qe(t);
849
+ async function Fr(e) {
850
+ if (e == null || e === "" || !y) return;
851
+ const t = String(e), r = Pe(t);
854
852
  let s = r;
855
- Object.keys(r).length <= 1 && (s = await h.request(
856
- R(`/items/${x}`, {
853
+ Object.keys(r).length <= 1 && (s = await p.request(
854
+ A(`/items/${y}`, {
857
855
  filter: JSON.stringify({ id: { _eq: e } }),
858
- fields: J,
856
+ fields: B,
859
857
  limit: 1
860
858
  })
861
859
  ).then((o) => {
862
860
  var i;
863
861
  return ((i = o.data) == null ? void 0 : i[0]) ?? { id: e };
864
862
  }).catch(() => ({ id: e })));
865
- const c = (fe(t) ?? 0) + 1;
866
- await at(t, String(c), s);
863
+ const c = (be(t) ?? 0) + 1;
864
+ await Ke(t, String(c), s);
867
865
  }
868
- const Sr = le.length, vt = Object.keys(l.copy_fields ?? {}), _t = Object.keys(l.compute_fields ?? {}), Ke = (e, t) => {
869
- const r = fe(e);
870
- if (g)
866
+ const Tr = le.length, _t = Object.keys(l.copy_fields ?? {}), St = Object.keys(l.compute_fields ?? {}), it = (e, t) => {
867
+ const r = be(e);
868
+ if (h)
871
869
  return /* @__PURE__ */ n("span", { className: "inline-block w-20 shrink-0 text-right tabular-nums text-slate-700 dark:text-slate-200", children: r && r > 0 ? r : "—" });
872
- const s = be[e], c = s !== void 0 ? s : r && r > 0 ? String(r) : "", o = T[e], i = () => F((d) => {
870
+ const s = qe[e], c = s !== void 0 ? s : r && r > 0 ? String(r) : "", o = ce[e], i = () => X((d) => {
873
871
  if (!(e in d)) return d;
874
872
  const u = { ...d };
875
873
  return delete u[e], u;
@@ -878,31 +876,31 @@ function yn({
878
876
  {
879
877
  type: "number",
880
878
  min: 0,
881
- step: Br(_e) ? 1 : "any",
882
- disabled: g,
879
+ step: er(v) ? 1 : "any",
880
+ disabled: h,
883
881
  value: c,
884
882
  placeholder: "0",
885
883
  "aria-invalid": (o == null ? void 0 : o.kind) === "error" || void 0,
886
884
  onFocus: i,
887
- onChange: (d) => G((u) => ({ ...u, [e]: d.target.value })),
885
+ onChange: (d) => pe((u) => ({ ...u, [e]: d.target.value })),
888
886
  onBlur: (d) => {
889
887
  const u = d.target.value;
890
- G((w) => {
891
- const j = { ...w };
892
- return delete j[e], j;
893
- }), at(e, u, t);
888
+ pe((w) => {
889
+ const T = { ...w };
890
+ return delete T[e], T;
891
+ }), Ke(e, u, t);
894
892
  },
895
893
  onKeyDown: (d) => {
896
894
  d.key === "Enter" && d.currentTarget.blur();
897
895
  },
898
- className: B(
896
+ className: Q(
899
897
  "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",
900
898
  (o == null ? void 0 : o.kind) === "error" && "border-red-400 dark:border-red-600"
901
899
  )
902
900
  }
903
901
  );
904
- return /* @__PURE__ */ m(Jr, { open: (o == null ? void 0 : o.kind) === "remove", onOpenChange: (d) => !d && i(), children: [
905
- /* @__PURE__ */ n(Qr, { asChild: !0, children: /* @__PURE__ */ m("span", { className: "inline-flex shrink-0 flex-col items-end", children: [
902
+ return /* @__PURE__ */ m(Hr, { open: (o == null ? void 0 : o.kind) === "remove", onOpenChange: (d) => !d && i(), children: [
903
+ /* @__PURE__ */ n(Mr, { asChild: !0, children: /* @__PURE__ */ m("span", { className: "inline-flex shrink-0 flex-col items-end", children: [
906
904
  b,
907
905
  (o == null ? void 0 : o.kind) === "error" && /* @__PURE__ */ m(
908
906
  "span",
@@ -911,7 +909,7 @@ function yn({
911
909
  className: "mt-0.5 flex max-w-[220px] items-start gap-1 text-right text-[11px] leading-snug text-red-600 dark:text-red-400",
912
910
  "data-catalog-qty-error": !0,
913
911
  children: [
914
- /* @__PURE__ */ n(St, { className: "mt-px h-3 w-3 shrink-0" }),
912
+ /* @__PURE__ */ n(qt, { className: "mt-px h-3 w-3 shrink-0" }),
915
913
  o.message,
916
914
  r && r > 0 ? ` — still ${r}` : ""
917
915
  ]
@@ -919,7 +917,7 @@ function yn({
919
917
  )
920
918
  ] }) }),
921
919
  /* @__PURE__ */ n(
922
- zr,
920
+ Wr,
923
921
  {
924
922
  align: "end",
925
923
  side: "bottom",
@@ -942,7 +940,7 @@ function yn({
942
940
  type: "button",
943
941
  onClick: () => {
944
942
  const d = o.row;
945
- i(), at(e, "0", d, { confirmedRemove: !0 });
943
+ i(), Ke(e, "0", d, { confirmedRemove: !0 });
946
944
  },
947
945
  className: "h-6 rounded bg-red-600 px-2 text-[11px] font-medium text-white hover:bg-red-700",
948
946
  children: "Remove"
@@ -953,8 +951,8 @@ function yn({
953
951
  }
954
952
  )
955
953
  ] });
956
- }, qr = (e, t, r) => {
957
- const s = `${e}:${t}`, c = W[s], o = () => L((b) => {
954
+ }, Or = (e, t, r) => {
955
+ const s = `${e}:${t}`, c = ae[s], o = () => D((b) => {
958
956
  if (!(s in b)) return b;
959
957
  const d = { ...b };
960
958
  return delete d[s], d;
@@ -972,21 +970,21 @@ function yn({
972
970
  onBlur: (b) => {
973
971
  const d = b.target.value;
974
972
  if (d !== i) {
975
- const u = pe.find((N) => N.field === t), w = Gt(d, {
973
+ const u = ke.find((N) => N.field === t), w = tr(d, {
976
974
  type: u == null ? void 0 : u.type,
977
- label: (u == null ? void 0 : u.label) || I(t)
978
- }), j = w.ok ? Oe(t, w.value, r) : w.message;
979
- if (j) {
980
- b.target.value = i, L((N) => ({ ...N, [s]: j }));
975
+ label: (u == null ? void 0 : u.label) || Z(t)
976
+ }), T = w.ok ? K(t, w.value, r) : w.message;
977
+ if (T) {
978
+ b.target.value = i, D((N) => ({ ...N, [s]: T }));
981
979
  return;
982
980
  }
983
981
  }
984
- vr(e, t, d);
982
+ jr(e, t, d);
985
983
  },
986
984
  onKeyDown: (b) => {
987
985
  b.key === "Enter" && b.currentTarget.blur();
988
986
  },
989
- className: B(
987
+ className: Q(
990
988
  "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",
991
989
  c && "border-red-400 dark:border-red-600"
992
990
  )
@@ -1000,7 +998,7 @@ function yn({
1000
998
  className: "mt-0.5 flex max-w-[220px] items-start gap-1 text-right text-[11px] leading-snug text-red-600 dark:text-red-400",
1001
999
  "data-catalog-cell-error": !0,
1002
1000
  children: [
1003
- /* @__PURE__ */ n(St, { className: "mt-px h-3 w-3 shrink-0" }),
1001
+ /* @__PURE__ */ n(qt, { className: "mt-px h-3 w-3 shrink-0" }),
1004
1002
  c,
1005
1003
  i !== "" ? ` — still ${i}` : ""
1006
1004
  ]
@@ -1008,25 +1006,25 @@ function yn({
1008
1006
  )
1009
1007
  ] }, s);
1010
1008
  };
1011
- return !x && de ? /* @__PURE__ */ m("div", { className: "space-y-2 py-1", "aria-busy": "true", children: [
1009
+ return !y && he ? /* @__PURE__ */ m("div", { className: "space-y-2 py-1", "aria-busy": "true", children: [
1012
1010
  /* @__PURE__ */ n("div", { className: "h-8 w-full animate-pulse rounded bg-slate-100 dark:bg-[hsl(var(--nvr-skeleton))]" }),
1013
1011
  /* @__PURE__ */ n("div", { className: "h-8 w-2/3 animate-pulse rounded bg-slate-100 dark:bg-[hsl(var(--nvr-skeleton))]" })
1014
- ] }) : x ? /* @__PURE__ */ m("div", { className: "space-y-3", children: [
1015
- !g && /* @__PURE__ */ m(qt, { children: [
1012
+ ] }) : y ? /* @__PURE__ */ m("div", { className: "space-y-3", children: [
1013
+ !h && /* @__PURE__ */ m(lt, { children: [
1016
1014
  /* @__PURE__ */ m("div", { className: "rounded-lg border border-slate-200 text-[12px] dark:border-border", children: [
1017
1015
  /* @__PURE__ */ m("div", { className: "flex items-center gap-2 border-b border-slate-200 px-3 py-2 dark:border-border", children: [
1018
- /* @__PURE__ */ n(it, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" }),
1016
+ /* @__PURE__ */ n(ot, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" }),
1019
1017
  /* @__PURE__ */ n(
1020
1018
  "input",
1021
1019
  {
1022
- value: C,
1020
+ value: L,
1023
1021
  onChange: (e) => ye(e.target.value),
1024
1022
  placeholder: "Search catalog…",
1025
1023
  className: "w-full bg-transparent text-[12px] outline-none placeholder:text-slate-400"
1026
1024
  }
1027
1025
  ),
1028
1026
  /* @__PURE__ */ m("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: [
1029
- Sr,
1027
+ Tr,
1030
1028
  " picked"
1031
1029
  ] })
1032
1030
  ] }),
@@ -1037,85 +1035,78 @@ function yn({
1037
1035
  /* @__PURE__ */ m(
1038
1036
  "div",
1039
1037
  {
1040
- ref: yr,
1038
+ ref: vr,
1041
1039
  className: "sticky top-0 z-[5] flex items-center gap-2 border-b border-slate-200 bg-slate-50 px-3 py-1 text-[10px] font-medium uppercase tracking-wide text-slate-400 dark:border-border dark:bg-muted",
1042
1040
  children: [
1043
1041
  l.favorites && /* @__PURE__ */ n("span", { className: "w-[18px] shrink-0" }),
1044
1042
  /* @__PURE__ */ n("span", { className: "w-36 shrink-0", children: "Item" }),
1045
- gt.map((e) => /* @__PURE__ */ n(
1046
- "span",
1047
- {
1048
- className: e.format ? "w-20 shrink-0 text-right" : "min-w-0 flex-1",
1049
- children: e.label ?? I(e.field.split(".")[0])
1050
- },
1051
- e.field
1052
- )),
1053
- yt.map((e) => /* @__PURE__ */ n("span", { className: "w-20 shrink-0 text-right", children: e.label ?? I(e.key) }, e.key)),
1043
+ rt.map((e) => /* @__PURE__ */ n("span", { className: Q("truncate", Ut(e)), children: e.label ?? Z(e.field.split(".")[0]) }, e.field)),
1044
+ kt.map((e) => /* @__PURE__ */ n("span", { className: "w-20 shrink-0 text-right", children: e.label ?? Z(e.key) }, e.key)),
1054
1045
  /* @__PURE__ */ n("span", { className: "w-20 shrink-0 text-right", children: "Qty" })
1055
1046
  ]
1056
1047
  }
1057
1048
  ),
1058
- C.trim().length > 0 && Se.length === 0 && ut && /* @__PURE__ */ m("div", { className: "flex items-center justify-center gap-2 border-b border-slate-100 px-3 py-3 text-slate-400 dark:border-border/50", children: [
1059
- /* @__PURE__ */ n(ae, { className: "h-3.5 w-3.5 animate-spin" }),
1049
+ L.trim().length > 0 && $e.length === 0 && bt && /* @__PURE__ */ m("div", { className: "flex items-center justify-center gap-2 border-b border-slate-100 px-3 py-3 text-slate-400 dark:border-border/50", children: [
1050
+ /* @__PURE__ */ n(ne, { className: "h-3.5 w-3.5 animate-spin" }),
1060
1051
  " Searching the catalog…"
1061
1052
  ] }),
1062
- C.trim().length > 0 && Se.length === 0 && !ut && /* @__PURE__ */ m("p", { className: "px-3 py-4 text-center text-slate-400", children: [
1053
+ L.trim().length > 0 && $e.length === 0 && !bt && /* @__PURE__ */ m("p", { className: "px-3 py-4 text-center text-slate-400", children: [
1063
1054
  'No CIFAs match "',
1064
- C.trim(),
1055
+ L.trim(),
1065
1056
  '"'
1066
1057
  ] }),
1067
- C.trim().length > 0 && Se.length > 0 && /* @__PURE__ */ m(Je, { children: [
1058
+ L.trim().length > 0 && $e.length > 0 && /* @__PURE__ */ m(Je, { children: [
1068
1059
  /* @__PURE__ */ m("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: [
1069
- /* @__PURE__ */ n(it, { className: "h-3 w-3 shrink-0 text-sky-500" }),
1060
+ /* @__PURE__ */ n(ot, { className: "h-3 w-3 shrink-0 text-sky-500" }),
1070
1061
  /* @__PURE__ */ n("span", { className: "text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: "Search results" }),
1071
- /* @__PURE__ */ n("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: Se.length }),
1062
+ /* @__PURE__ */ n("span", { className: "rounded border border-slate-200 bg-white px-1.5 py-0.5 text-[10px] font-medium text-slate-500 dark:border-border dark:bg-background dark:text-slate-400", children: $e.length }),
1072
1063
  /* @__PURE__ */ n("span", { className: "text-[10px] text-slate-400", children: "across the entire catalog — enter a quantity to add" }),
1073
- ut && /* @__PURE__ */ n(ae, { className: "h-3 w-3 shrink-0 animate-spin text-slate-400" })
1064
+ bt && /* @__PURE__ */ n(ne, { className: "h-3 w-3 shrink-0 animate-spin text-slate-400" })
1074
1065
  ] }),
1075
- Se.map((e, t) => {
1076
- const r = String(e.id), s = fe(r);
1066
+ $e.map((e, t) => {
1067
+ const r = String(e.id), s = be(r);
1077
1068
  return /* @__PURE__ */ m(
1078
1069
  "div",
1079
1070
  {
1080
- className: B(
1071
+ className: Q(
1081
1072
  "flex items-center gap-2 border-b border-slate-100 px-3 py-1 dark:border-border/50",
1082
1073
  t % 2 === 0 ? "bg-white dark:bg-background" : "bg-slate-50/50 dark:bg-muted/30",
1083
1074
  (s ?? 0) > 0 && "bg-nvr-cyan/5"
1084
1075
  ),
1085
1076
  children: [
1086
- ct(r),
1087
- nt(r, Fe(ee, e), Nt),
1088
- wt(r, e),
1089
- se.has(r) && /* @__PURE__ */ n(ae, { className: "h-3 w-3 shrink-0 animate-spin text-slate-400" }),
1090
- Ke(r, e)
1077
+ ut(r),
1078
+ st(r, Te(J, e), vt),
1079
+ Nt(r, e),
1080
+ de.has(r) && /* @__PURE__ */ n(ne, { className: "h-3 w-3 shrink-0 animate-spin text-slate-400" }),
1081
+ it(r, e)
1091
1082
  ]
1092
1083
  },
1093
1084
  r
1094
1085
  );
1095
1086
  })
1096
1087
  ] }),
1097
- k.length > 0 && !C.trim() && /* @__PURE__ */ m("p", { className: "px-3 py-6 text-center text-slate-400", children: [
1088
+ k.length > 0 && !L.trim() && /* @__PURE__ */ m("p", { className: "px-3 py-6 text-center text-slate-400", children: [
1098
1089
  "Search the full catalog above, or select",
1099
1090
  " ",
1100
1091
  k.map((e) => {
1101
1092
  var t;
1102
- return ((t = P == null ? void 0 : P.fieldLabels) == null ? void 0 : t[e]) ?? I(e);
1093
+ return ((t = z == null ? void 0 : z.fieldLabels) == null ? void 0 : t[e]) ?? Z(e);
1103
1094
  }).join(", "),
1104
1095
  " ",
1105
1096
  "to browse by category"
1106
1097
  ] }),
1107
- k.length === 0 && (H || He) && /* @__PURE__ */ m("div", { className: "flex items-center justify-center gap-2 py-6 text-slate-400", children: [
1108
- /* @__PURE__ */ n(ae, { className: "h-4 w-4 animate-spin" }),
1098
+ k.length === 0 && (M || Ue) && /* @__PURE__ */ m("div", { className: "flex items-center justify-center gap-2 py-6 text-slate-400", children: [
1099
+ /* @__PURE__ */ n(ne, { className: "h-4 w-4 animate-spin" }),
1109
1100
  " Loading catalog…"
1110
1101
  ] }),
1111
- k.length === 0 && !H && !He && st.length === 0 && /* @__PURE__ */ n("p", { className: "px-3 py-6 text-center text-slate-400", children: "No catalog items" }),
1102
+ k.length === 0 && !M && !Ue && at.length === 0 && /* @__PURE__ */ n("p", { className: "px-3 py-6 text-center text-slate-400", children: "No catalog items" }),
1112
1103
  l.favorites && /* @__PURE__ */ m(Je, { children: [
1113
1104
  /* @__PURE__ */ m("div", { className: "flex w-full items-center gap-1.5 border-b border-slate-200 bg-amber-50/70 px-2 py-1 dark:border-border dark:bg-amber-900/10", children: [
1114
1105
  /* @__PURE__ */ m(
1115
1106
  "button",
1116
1107
  {
1117
1108
  type: "button",
1118
- onClick: () => ne((e) => {
1109
+ onClick: () => G((e) => {
1119
1110
  const t = new Set(e);
1120
1111
  return t.has("__favorites__") ? t.delete("__favorites__") : t.add("__favorites__"), t;
1121
1112
  }),
@@ -1124,7 +1115,7 @@ function yn({
1124
1115
  /* @__PURE__ */ n(
1125
1116
  jt,
1126
1117
  {
1127
- className: B(
1118
+ className: Q(
1128
1119
  "h-3 w-3 shrink-0 text-slate-400 transition-transform",
1129
1120
  !oe.has("__favorites__") && "rotate-90"
1130
1121
  )
@@ -1132,55 +1123,55 @@ function yn({
1132
1123
  ),
1133
1124
  /* @__PURE__ */ n(Be, { className: "h-3 w-3 shrink-0 fill-amber-400 text-amber-400" }),
1134
1125
  /* @__PURE__ */ n("span", { className: "text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: "Favorites" }),
1135
- /* @__PURE__ */ n("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: Le.length })
1126
+ /* @__PURE__ */ n("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: Ce.length })
1136
1127
  ]
1137
1128
  }
1138
1129
  ),
1139
1130
  /* @__PURE__ */ n(
1140
1131
  "button",
1141
1132
  {
1142
- ref: At,
1133
+ ref: Ct,
1143
1134
  type: "button",
1144
- onClick: () => Lt(!0),
1135
+ onClick: () => At(!0),
1145
1136
  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",
1146
1137
  children: "Manage"
1147
1138
  }
1148
1139
  )
1149
1140
  ] }),
1150
- !oe.has("__favorites__") && Le.length === 0 && /* @__PURE__ */ n("p", { className: "border-b border-slate-100 px-3 py-2 text-center text-[11px] text-slate-400 dark:border-border/50", children: "No favorites yet — Manage lets you search the full catalog and star items." }),
1151
- !oe.has("__favorites__") && Le.map((e, t) => {
1152
- const r = String(e.id), s = fe(r), c = bt(r);
1141
+ !oe.has("__favorites__") && Ce.length === 0 && /* @__PURE__ */ n("p", { className: "border-b border-slate-100 px-3 py-2 text-center text-[11px] text-slate-400 dark:border-border/50", children: "No favorites yet — Manage lets you search the full catalog and star items." }),
1142
+ !oe.has("__favorites__") && Ce.map((e, t) => {
1143
+ const r = String(e.id), s = be(r), c = ht(r);
1153
1144
  return /* @__PURE__ */ m(
1154
1145
  "div",
1155
1146
  {
1156
- className: B(
1147
+ className: Q(
1157
1148
  "flex items-center gap-2 border-b border-slate-100 px-3 py-1 dark:border-border/50",
1158
1149
  t % 2 === 0 ? "bg-white dark:bg-background" : "bg-slate-50/50 dark:bg-muted/30",
1159
1150
  (s ?? 0) > 0 && "bg-nvr-cyan/5",
1160
1151
  c && "bg-amber-50 dark:bg-amber-900/15"
1161
1152
  ),
1162
1153
  children: [
1163
- ct(r),
1164
- nt(r, Fe(ee, e), Nt),
1165
- wt(r, e),
1154
+ ut(r),
1155
+ st(r, Te(J, e), vt),
1156
+ Nt(r, e),
1166
1157
  c && /* @__PURE__ */ n(
1167
1158
  ze,
1168
1159
  {
1169
1160
  className: "h-3.5 w-3.5 shrink-0 text-amber-500",
1170
- "aria-label": `${pt} ${c.available} — ${c.qty} requested`
1161
+ "aria-label": `${xt} ${c.available} — ${c.qty} requested`
1171
1162
  }
1172
1163
  ),
1173
- se.has(r) && /* @__PURE__ */ n(ae, { className: "h-3 w-3 shrink-0 animate-spin text-slate-400" }),
1174
- Ke(r, e)
1164
+ de.has(r) && /* @__PURE__ */ n(ne, { className: "h-3 w-3 shrink-0 animate-spin text-slate-400" }),
1165
+ it(r, e)
1175
1166
  ]
1176
1167
  },
1177
1168
  r
1178
1169
  );
1179
1170
  })
1180
1171
  ] }),
1181
- k.length === 0 && st.map((e) => {
1172
+ k.length === 0 && at.map((e) => {
1182
1173
  const t = oe.has(e.name), r = e.items.reduce(
1183
- (s, c) => s + ((fe(c.id) ?? 0) > 0 ? 1 : 0),
1174
+ (s, c) => s + ((be(c.id) ?? 0) > 0 ? 1 : 0),
1184
1175
  0
1185
1176
  );
1186
1177
  return /* @__PURE__ */ m(Je, { children: [
@@ -1188,7 +1179,7 @@ function yn({
1188
1179
  "button",
1189
1180
  {
1190
1181
  type: "button",
1191
- onClick: () => ne((s) => {
1182
+ onClick: () => G((s) => {
1192
1183
  const c = new Set(s);
1193
1184
  return c.has(e.name) ? c.delete(e.name) : c.add(e.name), c;
1194
1185
  }),
@@ -1197,7 +1188,7 @@ function yn({
1197
1188
  /* @__PURE__ */ n(
1198
1189
  jt,
1199
1190
  {
1200
- className: B(
1191
+ className: Q(
1201
1192
  "h-3 w-3 shrink-0 text-slate-400 transition-transform",
1202
1193
  !t && "rotate-90"
1203
1194
  )
@@ -1213,29 +1204,29 @@ function yn({
1213
1204
  }
1214
1205
  ),
1215
1206
  !t && e.items.map((s, c) => {
1216
- const o = fe(s.id), i = bt(s.id);
1207
+ const o = be(s.id), i = ht(s.id);
1217
1208
  return /* @__PURE__ */ m(
1218
1209
  "div",
1219
1210
  {
1220
- className: B(
1211
+ className: Q(
1221
1212
  "flex items-center gap-2 border-b border-slate-100 px-3 py-1 dark:border-border/50",
1222
1213
  c % 2 === 0 ? "bg-white dark:bg-background" : "bg-slate-50/50 dark:bg-muted/30",
1223
1214
  (o ?? 0) > 0 && "bg-nvr-cyan/5",
1224
1215
  i && "bg-amber-50 dark:bg-amber-900/15"
1225
1216
  ),
1226
1217
  children: [
1227
- ct(s.id),
1228
- nt(s.id, s.label, Nt),
1229
- wt(s.id, s.row),
1218
+ ut(s.id),
1219
+ st(s.id, s.label, vt),
1220
+ Nt(s.id, s.row),
1230
1221
  i && /* @__PURE__ */ n(
1231
1222
  ze,
1232
1223
  {
1233
1224
  className: "h-3.5 w-3.5 shrink-0 text-amber-500",
1234
- "aria-label": `${pt} ${i.available} — ${i.qty} requested`
1225
+ "aria-label": `${xt} ${i.available} — ${i.qty} requested`
1235
1226
  }
1236
1227
  ),
1237
- se.has(s.id) && /* @__PURE__ */ n(ae, { className: "h-3 w-3 shrink-0 animate-spin text-slate-400" }),
1238
- Ke(s.id, s.row)
1228
+ de.has(s.id) && /* @__PURE__ */ n(ne, { className: "h-3 w-3 shrink-0 animate-spin text-slate-400" }),
1229
+ it(s.id, s.row)
1239
1230
  ]
1240
1231
  },
1241
1232
  s.id
@@ -1244,16 +1235,18 @@ function yn({
1244
1235
  ] }, e.name);
1245
1236
  })
1246
1237
  ] }),
1247
- (l.builders ?? []).filter((e) => Xt(e.show_when, te)).map((e) => /* @__PURE__ */ n(
1248
- Ir,
1238
+ (l.builders ?? []).filter((e) => rr(e.show_when, H)).map((e) => /* @__PURE__ */ n(
1239
+ tn,
1249
1240
  {
1250
1241
  builder: e,
1251
1242
  defaultItemField: l.item_field,
1252
- catalogCol: x,
1253
- catalogFields: J,
1254
- tmpl: ee,
1255
- qtyInput: Ke,
1256
- currentQty: fe
1243
+ catalogCol: y,
1244
+ catalogFields: B,
1245
+ tmpl: J,
1246
+ currentQty: be,
1247
+ addQty: (t, r, s) => Ke(t, String(r), s),
1248
+ qtyStep: er(v) ? 1 : "any",
1249
+ readOnly: h
1257
1250
  },
1258
1251
  e.label
1259
1252
  ))
@@ -1261,11 +1254,11 @@ function yn({
1261
1254
  /* @__PURE__ */ m("div", { className: "rounded-lg border border-slate-200 text-[12px] dark:border-border", children: [
1262
1255
  /* @__PURE__ */ m("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: [
1263
1256
  /* @__PURE__ */ n("span", { className: "text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: "Summary" }),
1264
- !g && /* @__PURE__ */ m("div", { className: "flex items-center gap-2", onClick: (e) => e.stopPropagation(), children: [
1265
- l.upload_template && !E && Z && q && /* @__PURE__ */ n(
1266
- Kr,
1257
+ !h && /* @__PURE__ */ m("div", { className: "flex items-center gap-2", onClick: (e) => e.stopPropagation(), children: [
1258
+ l.upload_template && !C && I && $ && /* @__PURE__ */ n(
1259
+ Dr,
1267
1260
  {
1268
- collection: q,
1261
+ collection: $,
1269
1262
  templateFilter: (e) => {
1270
1263
  var t;
1271
1264
  return e.name === l.upload_template && ((t = e.reimport) == null ? void 0 : t.enabled) === !0;
@@ -1274,58 +1267,58 @@ function yn({
1274
1267
  var t;
1275
1268
  return ((t = e.reimport) == null ? void 0 : t.button_label) ?? e.button_label;
1276
1269
  },
1277
- onParsed: (e, t) => Z(e, t),
1270
+ onParsed: (e, t) => I(e, t),
1278
1271
  compact: !0
1279
1272
  }
1280
1273
  ),
1281
1274
  /* @__PURE__ */ n("div", { className: "w-64", children: /* @__PURE__ */ n(
1282
- Mr,
1275
+ Xr,
1283
1276
  {
1284
- collection: x,
1277
+ collection: y,
1285
1278
  value: null,
1286
- onChange: (e) => void _r(e),
1279
+ onChange: (e) => void Fr(e),
1287
1280
  placeholder: "+ Add any item…"
1288
1281
  }
1289
1282
  ) })
1290
1283
  ] })
1291
1284
  ] }),
1292
1285
  le.length === 0 ? /* @__PURE__ */ n("p", { className: "px-3 py-4 text-center text-slate-400", children: "Nothing picked yet" }) : (() => {
1293
- const e = zt.filter((i) => !i.format), t = e[0], r = e.slice(1), s = zt.filter((i) => !!i.format), c = (i, b) => b === "presence" ? i == null || i === "" || Number(i) === 0 ? "No" : "Yes" : i === !0 || i === "true" ? "✓" : i === !1 || i === "false" || i == null || i === "" ? "—" : ue(i, b), o = (i) => /* @__PURE__ */ n("span", { className: "w-20 shrink-0 text-right text-[11px] font-medium text-slate-500", children: i });
1286
+ const e = zt.filter((i) => !i.format), t = e[0], r = e.slice(1), s = zt.filter((i) => !!i.format), c = (i, b) => b === "presence" ? i == null || i === "" || Number(i) === 0 ? "No" : "Yes" : i === !0 || i === "true" ? "✓" : i === !1 || i === "false" || i == null || i === "" ? "—" : fe(i, b), o = (i) => /* @__PURE__ */ n("span", { className: "w-20 shrink-0 text-right text-[11px] font-medium text-slate-500", children: i });
1294
1287
  return /* @__PURE__ */ m("div", { children: [
1295
1288
  /* @__PURE__ */ m("div", { className: "flex items-center gap-2 border-b border-slate-200 px-3 py-1.5 dark:border-border", children: [
1296
1289
  /* @__PURE__ */ n("span", { className: "flex-1 text-[11px] font-medium text-slate-500", children: "Item" }),
1297
- vt.map((i) => /* @__PURE__ */ n(Je, { children: o(I(i)) }, i)),
1298
- o(I(V)),
1299
- _t.map((i) => /* @__PURE__ */ n(Je, { children: o(I(i)) }, i)),
1300
- !g && /* @__PURE__ */ n("span", { className: "w-6 shrink-0" })
1290
+ _t.map((i) => /* @__PURE__ */ n(Je, { children: o(Z(i)) }, i)),
1291
+ o(Z(O)),
1292
+ St.map((i) => /* @__PURE__ */ n(Je, { children: o(Z(i)) }, i)),
1293
+ !h && /* @__PURE__ */ n("span", { className: "w-6 shrink-0" })
1301
1294
  ] }),
1302
1295
  le.map((i, b) => {
1303
- const d = i.row.id != null ? String(i.row.id) : null, u = d != null && Ye.has(d), w = u ? null : bt(i.key), j = u ? null : fr(i.key);
1296
+ const d = i.row.id != null ? String(i.row.id) : null, u = d != null && Ie.has(d), w = u ? null : ht(i.key), T = u ? null : xr(i.key);
1304
1297
  return /* @__PURE__ */ m(
1305
1298
  "div",
1306
1299
  {
1307
- className: B(
1300
+ className: Q(
1308
1301
  "border-b border-slate-100 px-3 py-2 last:border-b-0 dark:border-border/50",
1309
1302
  b % 2 === 0 ? "bg-white dark:bg-background" : "bg-slate-50/50 dark:bg-muted/30",
1310
1303
  w && "bg-amber-50 dark:bg-amber-900/15",
1311
- j && "bg-red-50/70 dark:bg-red-900/15",
1304
+ T && "bg-red-50/70 dark:bg-red-900/15",
1312
1305
  u && "opacity-60"
1313
1306
  ),
1314
1307
  children: [
1315
1308
  /* @__PURE__ */ m(
1316
1309
  "div",
1317
1310
  {
1318
- className: B(
1311
+ className: Q(
1319
1312
  "flex items-center gap-2",
1320
1313
  u && "line-through decoration-slate-400"
1321
1314
  ),
1322
1315
  children: [
1323
- nt(
1316
+ st(
1324
1317
  i.key,
1325
- Dt(i.key),
1318
+ Ht(i.key),
1326
1319
  "shrink-0 font-semibold text-slate-800 dark:text-slate-100"
1327
1320
  ),
1328
- Pe && !u && (d == null || We.has(d)) && /* @__PURE__ */ n(
1321
+ Ee && !u && (d == null || Me.has(d)) && /* @__PURE__ */ n(
1329
1322
  "span",
1330
1323
  {
1331
1324
  "data-catalog-staged": d == null ? "new" : "edited",
@@ -1334,55 +1327,54 @@ function yn({
1334
1327
  children: d == null ? "New" : "Edited"
1335
1328
  }
1336
1329
  ),
1337
- j && /* @__PURE__ */ n(
1330
+ T && /* @__PURE__ */ n(
1338
1331
  "span",
1339
1332
  {
1340
1333
  className: "shrink-0",
1341
1334
  "data-tip": `This line was in the failed submission
1342
- ${j}`,
1335
+ ${T}`,
1343
1336
  "data-submission-error": !0,
1344
- children: /* @__PURE__ */ n(St, { className: "h-3.5 w-3.5 text-red-500", strokeWidth: 2 })
1337
+ children: /* @__PURE__ */ n(qt, { className: "h-3.5 w-3.5 text-red-500", strokeWidth: 2 })
1345
1338
  }
1346
1339
  ),
1347
1340
  t && /* @__PURE__ */ n(
1348
- "span",
1341
+ nr,
1349
1342
  {
1350
- className: "min-w-0 flex-1 truncate text-slate-600 dark:text-slate-300",
1351
- title: String(Ae(qe(i.key), t.field) ?? ""),
1352
- children: ue(Ae(qe(i.key), t.field), void 0)
1343
+ text: fe(nt(Pe(i.key), t.field), void 0),
1344
+ className: "min-w-0 flex-1 text-slate-600 dark:text-slate-300"
1353
1345
  }
1354
1346
  ),
1355
1347
  !t && /* @__PURE__ */ n("span", { className: "flex-1" }),
1356
1348
  r.map((N) => {
1357
- const S = Ae(qe(i.key), N.field);
1358
- return S == null || S === "" ? null : /* @__PURE__ */ n(
1349
+ const q = nt(Pe(i.key), N.field);
1350
+ return q == null || q === "" ? null : /* @__PURE__ */ n(
1359
1351
  "span",
1360
1352
  {
1361
1353
  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",
1362
- children: String(S)
1354
+ children: String(q)
1363
1355
  },
1364
1356
  N.field
1365
1357
  );
1366
1358
  }),
1367
- vt.map(
1359
+ _t.map(
1368
1360
  (N) => {
1369
- var S;
1370
- return D.includes(N) && !g ? qr(i.key, N, i.row) : /* @__PURE__ */ n(
1361
+ var q;
1362
+ return se.includes(N) && !h ? Or(i.key, N, i.row) : /* @__PURE__ */ n(
1371
1363
  "span",
1372
1364
  {
1373
1365
  className: "w-20 shrink-0 text-right tabular-nums text-slate-600 dark:text-slate-300",
1374
- children: ue(i.row[N], (S = l.field_formats) == null ? void 0 : S[N])
1366
+ children: fe(i.row[N], (q = l.field_formats) == null ? void 0 : q[N])
1375
1367
  },
1376
1368
  N
1377
1369
  );
1378
1370
  }
1379
1371
  ),
1380
1372
  /* @__PURE__ */ m("span", { className: "inline-flex w-20 shrink-0 items-center justify-end gap-1", children: [
1381
- se.has(i.key) && /* @__PURE__ */ n(ae, { className: "h-3 w-3 animate-spin text-slate-400" }),
1382
- Ke(i.key, qe(i.key))
1373
+ de.has(i.key) && /* @__PURE__ */ n(ne, { className: "h-3 w-3 animate-spin text-slate-400" }),
1374
+ it(i.key, Pe(i.key))
1383
1375
  ] }),
1384
- _t.map((N) => {
1385
- var ve, It;
1376
+ St.map((N) => {
1377
+ var _e, Zt;
1386
1378
  if (u)
1387
1379
  return /* @__PURE__ */ n(
1388
1380
  "span",
@@ -1393,57 +1385,57 @@ ${j}`,
1393
1385
  },
1394
1386
  N
1395
1387
  );
1396
- const S = i.row[N], $e = S != null && S !== "" ? S : Qe(((ve = l.compute_fields) == null ? void 0 : ve[N]) ?? "", i.row);
1388
+ const q = i.row[N], je = q != null && q !== "" ? q : Qe(((_e = l.compute_fields) == null ? void 0 : _e[N]) ?? "", i.row);
1397
1389
  return /* @__PURE__ */ n(
1398
1390
  "span",
1399
1391
  {
1400
1392
  className: "w-20 shrink-0 text-right tabular-nums text-slate-600 dark:text-slate-300",
1401
- children: ue($e, (It = l.field_formats) == null ? void 0 : It[N])
1393
+ children: fe(je, (Zt = l.field_formats) == null ? void 0 : Zt[N])
1402
1394
  },
1403
1395
  N
1404
1396
  );
1405
1397
  }),
1406
- !g && u && /* @__PURE__ */ n(
1398
+ !h && u && /* @__PURE__ */ n(
1407
1399
  "button",
1408
1400
  {
1409
1401
  type: "button",
1410
- onClick: () => p == null ? void 0 : p.cancelPendingDelete(f, y, d),
1402
+ onClick: () => x == null ? void 0 : x.cancelPendingDelete(f, g, d),
1411
1403
  className: "shrink-0 rounded px-1.5 py-0.5 text-[11px] font-medium text-nvr-navy underline dark:text-nvr-cyan",
1412
1404
  children: "Undo"
1413
1405
  }
1414
1406
  ),
1415
- !g && !u && /* @__PURE__ */ n(
1407
+ !h && !u && /* @__PURE__ */ n(
1416
1408
  "button",
1417
1409
  {
1418
1410
  type: "button",
1419
1411
  title: "Remove (applies on Save)",
1420
1412
  onClick: () => {
1421
- if (!E && p && d != null) {
1422
- p.queueDelete(f, y, d);
1413
+ if (!C && x && d != null) {
1414
+ x.queueDelete(f, g, d);
1423
1415
  return;
1424
1416
  }
1425
- at(i.key, "0", {}, { confirmedRemove: !0 });
1417
+ Ke(i.key, "0", {}, { confirmedRemove: !0 });
1426
1418
  },
1427
1419
  className: "w-6 shrink-0 rounded p-0.5 text-slate-300 transition-colors hover:text-red-500",
1428
- children: /* @__PURE__ */ n(lt, { className: "mx-auto h-3.5 w-3.5" })
1420
+ children: /* @__PURE__ */ n(dt, { className: "mx-auto h-3.5 w-3.5" })
1429
1421
  }
1430
1422
  )
1431
1423
  ]
1432
1424
  }
1433
1425
  ),
1434
- (s.length > 0 || Bt.length > 0 || rt.length > 0) && /* @__PURE__ */ m("div", { className: "mt-1 flex flex-wrap items-baseline gap-x-4 gap-y-0.5 pl-0.5 text-[11px]", children: [
1426
+ (s.length > 0 || Bt.length > 0 || tt.length > 0) && /* @__PURE__ */ m("div", { className: "mt-1 flex flex-wrap items-baseline gap-x-4 gap-y-0.5 pl-0.5 text-[11px]", children: [
1435
1427
  s.map((N) => /* @__PURE__ */ m("span", { className: "whitespace-nowrap", children: [
1436
- /* @__PURE__ */ n("span", { className: "text-slate-500 dark:text-muted-foreground", children: N.label ?? I(N.field.split(".")[0]) }),
1428
+ /* @__PURE__ */ n("span", { className: "text-slate-500 dark:text-muted-foreground", children: N.label ?? Z(N.field.split(".")[0]) }),
1437
1429
  " ",
1438
- /* @__PURE__ */ n("span", { className: "font-medium tabular-nums text-slate-700 dark:text-slate-200", children: c(Ae(qe(i.key), N.field), N.format) })
1430
+ /* @__PURE__ */ n("span", { className: "font-medium tabular-nums text-slate-700 dark:text-slate-200", children: c(nt(Pe(i.key), N.field), N.format) })
1439
1431
  ] }, N.field)),
1440
1432
  Bt.map((N) => /* @__PURE__ */ m("span", { className: "whitespace-nowrap", children: [
1441
- /* @__PURE__ */ n("span", { className: "text-slate-500 dark:text-muted-foreground", children: N.label ?? I(N.key) }),
1433
+ /* @__PURE__ */ n("span", { className: "text-slate-500 dark:text-muted-foreground", children: N.label ?? Z(N.key) }),
1442
1434
  " ",
1443
- /* @__PURE__ */ n("span", { className: "font-medium tabular-nums text-slate-700 dark:text-slate-200", children: c(ft(N.key, i.key), N.format) })
1435
+ /* @__PURE__ */ n("span", { className: "font-medium tabular-nums text-slate-700 dark:text-slate-200", children: c(pt(N.key, i.key), N.format) })
1444
1436
  ] }, N.key)),
1445
- gr(i.row),
1446
- dr(i.row).map((N) => /* @__PURE__ */ m(
1437
+ Nr(i.row),
1438
+ fr(i.row).map((N) => /* @__PURE__ */ m(
1447
1439
  "span",
1448
1440
  {
1449
1441
  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",
@@ -1455,23 +1447,23 @@ ${j}`,
1455
1447
  },
1456
1448
  N
1457
1449
  )),
1458
- rt.map((N) => {
1459
- const S = hr(N, i);
1450
+ tt.map((N) => {
1451
+ const q = kr(N, i);
1460
1452
  return /* @__PURE__ */ m("span", { className: "whitespace-nowrap", children: [
1461
- /* @__PURE__ */ n("span", { className: "text-slate-500 dark:text-muted-foreground", children: N.label ?? I(N.field) }),
1453
+ /* @__PURE__ */ n("span", { className: "text-slate-500 dark:text-muted-foreground", children: N.label ?? Z(N.field) }),
1462
1454
  " ",
1463
- /* @__PURE__ */ n("span", { className: "font-medium text-slate-700 dark:text-slate-200", children: c(S, N.format) })
1455
+ /* @__PURE__ */ n("span", { className: "font-medium text-slate-700 dark:text-slate-200", children: c(q, N.format) })
1464
1456
  ] }, N.field);
1465
1457
  })
1466
1458
  ] }),
1467
1459
  w && /* @__PURE__ */ m("p", { className: "mt-1 flex items-center gap-1 pl-0.5 text-[11px] font-medium text-amber-600 dark:text-amber-400", children: [
1468
1460
  /* @__PURE__ */ n(ze, { className: "h-3 w-3 shrink-0" }),
1469
- pt,
1461
+ xt,
1470
1462
  " is ",
1471
- ue(w.available, "number"),
1463
+ fe(w.available, "number"),
1472
1464
  " —",
1473
1465
  " ",
1474
- ue(w.qty, "number"),
1466
+ fe(w.qty, "number"),
1475
1467
  " requested"
1476
1468
  ] }),
1477
1469
  u && /* @__PURE__ */ n("p", { className: "mt-1 pl-0.5 text-[11px] text-red-500", children: "Removed — applies when you save" })
@@ -1482,48 +1474,48 @@ ${j}`,
1482
1474
  }),
1483
1475
  (() => {
1484
1476
  const i = le.filter((w) => {
1485
- const j = w.row.id != null ? String(w.row.id) : null;
1486
- return !(j != null && Ye.has(j));
1487
- }), b = (w) => i.reduce((j, N) => {
1488
- const S = Number(N.row[w]);
1489
- return j + (Number.isFinite(S) ? S : 0);
1477
+ const T = w.row.id != null ? String(w.row.id) : null;
1478
+ return !(T != null && Ie.has(T));
1479
+ }), b = (w) => i.reduce((T, N) => {
1480
+ const q = Number(N.row[w]);
1481
+ return T + (Number.isFinite(q) ? q : 0);
1490
1482
  }, 0), d = (w) => {
1491
- var j;
1492
- return ((j = l.field_formats) == null ? void 0 : j[w]) ?? "number";
1483
+ var T;
1484
+ return ((T = l.field_formats) == null ? void 0 : T[w]) ?? "number";
1493
1485
  }, u = (w) => /* @__PURE__ */ n(
1494
1486
  "span",
1495
1487
  {
1496
1488
  className: "w-20 shrink-0 text-right text-[12px] font-semibold tabular-nums text-slate-800 dark:text-slate-100",
1497
- children: ue(b(w), d(w))
1489
+ children: fe(b(w), d(w))
1498
1490
  },
1499
1491
  w
1500
1492
  );
1501
1493
  return /* @__PURE__ */ m("div", { className: "flex items-center gap-2 border-t border-slate-200 bg-slate-50 px-3 py-1.5 dark:border-border dark:bg-muted/40", children: [
1502
1494
  /* @__PURE__ */ n("span", { className: "flex-1 text-[11px] font-semibold uppercase tracking-wide text-slate-500", children: "Total" }),
1503
- vt.map((w) => /* @__PURE__ */ n("span", { className: "w-20 shrink-0" }, w)),
1504
- /* @__PURE__ */ n("span", { className: "w-20 shrink-0 text-right text-[12px] font-semibold tabular-nums text-slate-800 dark:text-slate-100", children: ue(b(V), "number") }),
1505
- _t.map(u),
1506
- !g && /* @__PURE__ */ n("span", { className: "w-6 shrink-0" })
1495
+ _t.map((w) => /* @__PURE__ */ n("span", { className: "w-20 shrink-0" }, w)),
1496
+ /* @__PURE__ */ n("span", { className: "w-20 shrink-0 text-right text-[12px] font-semibold tabular-nums text-slate-800 dark:text-slate-100", children: fe(b(O), "number") }),
1497
+ St.map(u),
1498
+ !h && /* @__PURE__ */ n("span", { className: "w-6 shrink-0" })
1507
1499
  ] });
1508
1500
  })()
1509
1501
  ] });
1510
1502
  })()
1511
1503
  ] }),
1512
- ar && x && /* @__PURE__ */ n(
1513
- Zr,
1504
+ dr && y && /* @__PURE__ */ n(
1505
+ nn,
1514
1506
  {
1515
- catalogCol: x,
1516
- tmpl: ee,
1507
+ catalogCol: y,
1508
+ tmpl: J,
1517
1509
  sectionBy: l.section_by,
1518
- sectionM2M: Q,
1519
- pinnedSet: dt,
1520
- pinnedIds: xe,
1521
- savingIds: Xe,
1510
+ sectionM2M: R,
1511
+ pinnedSet: mt,
1512
+ pinnedIds: ge,
1513
+ savingIds: Ge,
1522
1514
  relatedCols: (l.favorites_manager_columns ?? []).map((e) => (l.related_columns ?? []).find((t) => t.key === e)).filter((e) => !!e),
1523
- parentDraft: te,
1515
+ parentDraft: H,
1524
1516
  onToggle: (e) => void Et(e),
1525
- onClose: () => Lt(!1),
1526
- anchor: At.current
1517
+ onClose: () => At(!1),
1518
+ anchor: Ct.current
1527
1519
  }
1528
1520
  )
1529
1521
  ] }) : /* @__PURE__ */ m("p", { className: "py-1 text-[12px] text-slate-400", children: [
@@ -1534,87 +1526,99 @@ ${j}`,
1534
1526
  f
1535
1527
  ] });
1536
1528
  }
1537
- function Ir({
1529
+ function tn({
1538
1530
  builder: f,
1539
- defaultItemField: y,
1531
+ defaultItemField: g,
1540
1532
  catalogCol: _,
1541
- catalogFields: q,
1533
+ catalogFields: $,
1542
1534
  tmpl: l,
1543
- qtyInput: g,
1544
- currentQty: h
1535
+ currentQty: h,
1536
+ addQty: p,
1537
+ qtyStep: j,
1538
+ readOnly: x
1545
1539
  }) {
1546
- const $ = Ft(), p = f.item_field ?? y, [P, Z] = Y(!1), [D, E] = Y({}), V = O(
1540
+ const z = Ft(), I = f.item_field ?? g, [se, C] = W(!1), [O, oe] = W({}), [G, Se] = W("1"), [L, ye] = W(!1), qe = E(
1547
1541
  () => [
1548
1542
  "id",
1549
- p,
1543
+ I,
1550
1544
  ...f.attributes.flatMap((v) => [`${v.field}.id`, `${v.field}.${v.label_field}`])
1551
1545
  ].join(","),
1552
- [p, f.attributes]
1553
- ), { data: oe = [], isLoading: ne } = z({
1546
+ [I, f.attributes]
1547
+ ), { data: pe = [], isLoading: de } = V({
1554
1548
  queryKey: [
1555
1549
  "catalog-builder",
1556
1550
  f.collection,
1557
- V,
1551
+ qe,
1558
1552
  JSON.stringify(f.filter ?? null)
1559
1553
  ],
1560
- queryFn: () => $.request(
1561
- R(`/items/${f.collection}`, {
1554
+ queryFn: () => z.request(
1555
+ A(`/items/${f.collection}`, {
1562
1556
  limit: 2e3,
1563
- fields: V,
1557
+ fields: qe,
1564
1558
  ...f.filter ? { filter: JSON.stringify(f.filter) } : {}
1565
1559
  })
1566
1560
  ).then((v) => v.data ?? []),
1567
- enabled: P,
1561
+ enabled: se,
1568
1562
  staleTime: 6e4
1569
- }), ge = (v, T) => {
1570
- var W;
1571
- const F = v[T];
1563
+ }), ee = (v, K) => {
1564
+ var J;
1565
+ const F = v[K];
1572
1566
  if (F == null) return null;
1573
1567
  if (typeof F == "object") {
1574
- const L = F, K = ((W = f.attributes.find((de) => de.field === T)) == null ? void 0 : W.label_field) ?? "id";
1575
- return { id: String(L.id ?? ""), label: String(L[K] ?? L.id ?? "") };
1568
+ const S = F, P = ((J = f.attributes.find((me) => me.field === K)) == null ? void 0 : J.label_field) ?? "id";
1569
+ return { id: String(S.id ?? ""), label: String(S[P] ?? S.id ?? "") };
1576
1570
  }
1577
1571
  return { id: String(F), label: String(F) };
1578
- }, C = (v) => oe.filter(
1579
- (T) => f.attributes.slice(0, v).every((F) => {
1580
- var L;
1581
- const W = D[F.field];
1582
- return W ? ((L = ge(T, F.field)) == null ? void 0 : L.id) === W : !0;
1572
+ }, ce = (v) => pe.filter(
1573
+ (K) => f.attributes.slice(0, v).every((F) => {
1574
+ var S;
1575
+ const J = O[F.field];
1576
+ return J ? ((S = ee(K, F.field)) == null ? void 0 : S.id) === J : !0;
1583
1577
  })
1584
- ), ye = f.attributes.every((v) => D[v.field]), be = ye ? oe.find(
1585
- (v) => f.attributes.every((T) => {
1578
+ ), X = f.attributes.every((v) => O[v.field]), ae = X ? pe.find(
1579
+ (v) => f.attributes.every((K) => {
1586
1580
  var F;
1587
- return ((F = ge(v, T.field)) == null ? void 0 : F.id) === D[T.field];
1581
+ return ((F = ee(v, K.field)) == null ? void 0 : F.id) === O[K.field];
1588
1582
  })
1589
- ) : void 0, G = (be == null ? void 0 : be[p]) != null ? String(be[p]) : null, { data: se } = z({
1590
- queryKey: ["catalog-builder-item", _, q, G],
1591
- queryFn: () => $.request(
1592
- R(`/items/${_}`, {
1593
- filter: JSON.stringify({ id: { _eq: G } }),
1594
- fields: q,
1583
+ ) : void 0, D = (ae == null ? void 0 : ae[I]) != null ? String(ae[I]) : null, { data: te } = V({
1584
+ queryKey: ["catalog-builder-item", _, $, D],
1585
+ queryFn: () => z.request(
1586
+ A(`/items/${_}`, {
1587
+ filter: JSON.stringify({ id: { _eq: D } }),
1588
+ fields: $,
1595
1589
  limit: 1
1596
1590
  })
1597
1591
  ).then((v) => {
1598
- var T;
1599
- return ((T = v.data) == null ? void 0 : T[0]) ?? null;
1592
+ var K;
1593
+ return ((K = v.data) == null ? void 0 : K[0]) ?? null;
1600
1594
  }),
1601
- enabled: !!G,
1595
+ enabled: !!D,
1602
1596
  staleTime: 6e4
1603
- });
1597
+ }), he = Number(G), y = !!D && !!te && !L && G.trim() !== "" && Number.isFinite(he) && he > 0 && (j === "any" || Number.isInteger(he));
1598
+ async function ke() {
1599
+ if (!(!y || !D || !te)) {
1600
+ ye(!0);
1601
+ try {
1602
+ await p(D, (h(D) ?? 0) + he, te), oe({}), Se("1");
1603
+ } finally {
1604
+ ye(!1);
1605
+ }
1606
+ }
1607
+ }
1604
1608
  return /* @__PURE__ */ m("div", { className: "rounded-lg border border-slate-200 text-[12px] dark:border-border", children: [
1605
1609
  /* @__PURE__ */ m(
1606
1610
  "button",
1607
1611
  {
1608
1612
  type: "button",
1609
- onClick: () => Z((v) => !v),
1613
+ onClick: () => C((v) => !v),
1610
1614
  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",
1611
1615
  children: [
1612
1616
  /* @__PURE__ */ n(
1613
1617
  jt,
1614
1618
  {
1615
- className: B(
1619
+ className: Q(
1616
1620
  "h-3 w-3 shrink-0 text-slate-400 transition-transform",
1617
- P && "rotate-90"
1621
+ se && "rotate-90"
1618
1622
  )
1619
1623
  }
1620
1624
  ),
@@ -1622,252 +1626,288 @@ function Ir({
1622
1626
  ]
1623
1627
  }
1624
1628
  ),
1625
- P && /* @__PURE__ */ n("div", { className: "space-y-2 border-t border-slate-200 p-3 dark:border-border", children: ne ? /* @__PURE__ */ m("div", { className: "flex items-center gap-2 py-2 text-slate-400", children: [
1626
- /* @__PURE__ */ n(ae, { className: "h-4 w-4 animate-spin" }),
1629
+ se && /* @__PURE__ */ n("div", { className: "space-y-2 border-t border-slate-200 p-3 dark:border-border", children: de ? /* @__PURE__ */ m("div", { className: "flex items-center gap-2 py-2 text-slate-400", children: [
1630
+ /* @__PURE__ */ n(ne, { className: "h-4 w-4 animate-spin" }),
1627
1631
  " Loading options…"
1628
1632
  ] }) : /* @__PURE__ */ m("div", { className: "flex flex-wrap items-end gap-3", children: [
1629
- f.attributes.map((v, T) => {
1633
+ f.attributes.map((v, K) => {
1630
1634
  const F = /* @__PURE__ */ new Map();
1631
- for (const L of C(T)) {
1632
- const K = ge(L, v.field);
1633
- K != null && K.id && F.set(K.id, K.label);
1635
+ for (const S of ce(K)) {
1636
+ const P = ee(S, v.field);
1637
+ P != null && P.id && F.set(P.id, P.label);
1634
1638
  }
1635
- const W = [...F.entries()].sort(
1636
- ([, L], [, K]) => L.localeCompare(K, void 0, { numeric: !0 })
1639
+ const J = [...F.entries()].sort(
1640
+ ([, S], [, P]) => S.localeCompare(P, void 0, { numeric: !0 })
1637
1641
  );
1638
1642
  return /* @__PURE__ */ n(
1639
- Yr,
1643
+ rn,
1640
1644
  {
1641
- label: I(v.field),
1642
- value: D[v.field] ?? null,
1643
- valueLabel: D[v.field] ? F.get(D[v.field]) ?? D[v.field] : null,
1644
- options: W,
1645
- disabled: T > 0 && !D[f.attributes[T - 1].field],
1646
- onChange: (L) => E((K) => {
1647
- const de = {};
1648
- for (let x = 0; x < T; x++) {
1649
- const pe = f.attributes[x].field;
1650
- K[pe] && (de[pe] = K[pe]);
1645
+ label: Z(v.field),
1646
+ value: O[v.field] ?? null,
1647
+ valueLabel: O[v.field] ? F.get(O[v.field]) ?? O[v.field] : null,
1648
+ options: J,
1649
+ disabled: K > 0 && !O[f.attributes[K - 1].field],
1650
+ onChange: (S) => oe((P) => {
1651
+ const me = {};
1652
+ for (let R = 0; R < K; R++) {
1653
+ const H = f.attributes[R].field;
1654
+ P[H] && (me[H] = P[H]);
1651
1655
  }
1652
- return L && (de[v.field] = L), de;
1656
+ return S && (me[v.field] = S), me;
1653
1657
  })
1654
1658
  },
1655
1659
  v.field
1656
1660
  );
1657
1661
  }),
1658
- /* @__PURE__ */ n("div", { className: "flex min-h-[28px] flex-1 items-center gap-2", children: G && se ? /* @__PURE__ */ m(qt, { children: [
1659
- /* @__PURE__ */ n("span", { className: "min-w-0 flex-1 truncate text-slate-700 dark:text-slate-200", children: Fe(l, se) }),
1660
- (h(G) ?? 0) > 0 && /* @__PURE__ */ n("span", { className: "rounded bg-nvr-cyan/10 px-1.5 py-0.5 text-[10px] font-semibold text-[#009abe]", children: "picked" }),
1661
- g(G, se)
1662
- ] }) : ye ? /* @__PURE__ */ n("span", { className: "text-slate-400", children: "No matching item for this combination" }) : /* @__PURE__ */ n("span", { className: "text-slate-400", children: "Pick each attribute to resolve an item" }) })
1662
+ /* @__PURE__ */ n("div", { className: "flex min-h-[28px] flex-1 items-center gap-2", children: D && te ? /* @__PURE__ */ m(lt, { children: [
1663
+ /* @__PURE__ */ n("span", { className: "min-w-0 flex-1 truncate text-slate-700 dark:text-slate-200", children: Te(l, te) }),
1664
+ (h(D) ?? 0) > 0 && /* @__PURE__ */ m("span", { className: "rounded bg-nvr-cyan/10 px-1.5 py-0.5 text-[10px] font-semibold text-[#009abe]", children: [
1665
+ h(D),
1666
+ " in summary"
1667
+ ] }),
1668
+ !x && /* @__PURE__ */ m(lt, { children: [
1669
+ /* @__PURE__ */ n(
1670
+ "input",
1671
+ {
1672
+ type: "number",
1673
+ min: 0,
1674
+ step: j,
1675
+ value: G,
1676
+ "aria-label": "Quantity to add",
1677
+ onChange: (v) => Se(v.target.value),
1678
+ onKeyDown: (v) => {
1679
+ v.key === "Enter" && (v.preventDefault(), ke());
1680
+ },
1681
+ 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"
1682
+ }
1683
+ ),
1684
+ /* @__PURE__ */ m(
1685
+ "button",
1686
+ {
1687
+ type: "button",
1688
+ onClick: () => void ke(),
1689
+ disabled: !y,
1690
+ 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",
1691
+ children: [
1692
+ L ? /* @__PURE__ */ n(ne, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ n(Rr, { className: "h-3.5 w-3.5" }),
1693
+ "Add"
1694
+ ]
1695
+ }
1696
+ )
1697
+ ] })
1698
+ ] }) : X ? /* @__PURE__ */ n("span", { className: "text-slate-400", children: "No matching item for this combination" }) : /* @__PURE__ */ n("span", { className: "text-slate-400", children: "Pick each attribute to resolve an item" }) })
1663
1699
  ] }) })
1664
1700
  ] });
1665
1701
  }
1666
- function Yr({
1702
+ function nr({ text: f, className: g }) {
1703
+ const _ = Ur(f);
1704
+ return /* @__PURE__ */ n("span", { ref: _, className: Q("truncate", g), children: f });
1705
+ }
1706
+ function rn({
1667
1707
  label: f,
1668
- value: y,
1708
+ value: g,
1669
1709
  valueLabel: _,
1670
- options: q,
1710
+ options: $,
1671
1711
  disabled: l,
1672
- onChange: g
1712
+ onChange: h
1673
1713
  }) {
1674
- const [h, $] = Y(!1), p = Ve(null);
1675
- return je(() => {
1676
- if (!h) return;
1677
- const P = (Z) => {
1678
- p.current && !p.current.contains(Z.target) && $(!1);
1714
+ const [p, j] = W(!1), x = Ve(null);
1715
+ return Fe(() => {
1716
+ if (!p) return;
1717
+ const z = (I) => {
1718
+ x.current && !x.current.contains(I.target) && j(!1);
1679
1719
  };
1680
- return document.addEventListener("mousedown", P), () => document.removeEventListener("mousedown", P);
1681
- }, [h]), /* @__PURE__ */ m("div", { ref: p, className: "relative", children: [
1720
+ return document.addEventListener("mousedown", z), () => document.removeEventListener("mousedown", z);
1721
+ }, [p]), /* @__PURE__ */ m("div", { ref: x, className: "relative", children: [
1682
1722
  /* @__PURE__ */ n("p", { className: "mb-1 text-[10px] font-medium text-slate-500 dark:text-slate-400", children: f }),
1683
1723
  /* @__PURE__ */ m(
1684
1724
  "button",
1685
1725
  {
1686
1726
  type: "button",
1687
1727
  disabled: l,
1688
- onClick: () => $((P) => !P),
1728
+ onClick: () => j((z) => !z),
1689
1729
  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",
1690
1730
  children: [
1691
- /* @__PURE__ */ n("span", { className: B("truncate", !_ && "text-slate-400"), children: _ ?? "Select…" }),
1692
- /* @__PURE__ */ n(jr, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" })
1731
+ /* @__PURE__ */ n("span", { className: Q("truncate", !_ && "text-slate-400"), children: _ ?? "Select…" }),
1732
+ /* @__PURE__ */ n(Er, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" })
1693
1733
  ]
1694
1734
  }
1695
1735
  ),
1696
- h && /* @__PURE__ */ m("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: [
1697
- y && /* @__PURE__ */ m(
1736
+ p && /* @__PURE__ */ m("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: [
1737
+ g && /* @__PURE__ */ m(
1698
1738
  "button",
1699
1739
  {
1700
1740
  type: "button",
1701
1741
  onClick: () => {
1702
- g(null), $(!1);
1742
+ h(null), j(!1);
1703
1743
  },
1704
1744
  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",
1705
1745
  children: [
1706
- /* @__PURE__ */ n(lt, { className: "h-3 w-3 text-slate-400" }),
1746
+ /* @__PURE__ */ n(dt, { className: "h-3 w-3 text-slate-400" }),
1707
1747
  " Clear"
1708
1748
  ]
1709
1749
  }
1710
1750
  ),
1711
- q.map(([P, Z]) => /* @__PURE__ */ n(
1751
+ $.map(([z, I]) => /* @__PURE__ */ n(
1712
1752
  "button",
1713
1753
  {
1714
1754
  type: "button",
1715
1755
  onClick: () => {
1716
- g(P), $(!1);
1756
+ h(z), j(!1);
1717
1757
  },
1718
- className: B(
1758
+ className: Q(
1719
1759
  "block w-full truncate px-2 py-1 text-left text-[12px] hover:bg-muted",
1720
- P === y ? "font-medium text-nvr-cyan" : "text-slate-700 dark:text-slate-200"
1760
+ z === g ? "font-medium text-nvr-cyan" : "text-slate-700 dark:text-slate-200"
1721
1761
  ),
1722
- children: Z
1762
+ children: I
1723
1763
  },
1724
- P
1764
+ z
1725
1765
  ))
1726
1766
  ] })
1727
1767
  ] });
1728
1768
  }
1729
- function Zr({
1769
+ function nn({
1730
1770
  catalogCol: f,
1731
- tmpl: y,
1771
+ tmpl: g,
1732
1772
  sectionBy: _,
1733
- sectionM2M: q,
1773
+ sectionM2M: $,
1734
1774
  pinnedSet: l,
1735
- pinnedIds: g,
1736
- savingIds: h,
1737
- relatedCols: $,
1738
- parentDraft: p,
1739
- onToggle: P,
1740
- onClose: Z,
1741
- anchor: D
1775
+ pinnedIds: h,
1776
+ savingIds: p,
1777
+ relatedCols: j,
1778
+ parentDraft: x,
1779
+ onToggle: z,
1780
+ onClose: I,
1781
+ anchor: se
1742
1782
  }) {
1743
- const E = Ft(), [V, oe] = Y(""), [ne, ge] = Y(""), [C, ye] = Y(1), be = Ve(null);
1744
- je(() => {
1745
- const a = setTimeout(() => ge(V), 300);
1783
+ const C = Ft(), [O, oe] = W(""), [G, Se] = W(""), [L, ye] = W(1), qe = Ve(null);
1784
+ Fe(() => {
1785
+ const a = setTimeout(() => Se(O), 300);
1746
1786
  return () => clearTimeout(a);
1747
- }, [V]), je(() => ye(1), [ne]), je(() => {
1787
+ }, [O]), Fe(() => ye(1), [G]), Fe(() => {
1748
1788
  var a;
1749
- (a = be.current) == null || a.focus();
1750
- }, []), je(() => {
1789
+ (a = qe.current) == null || a.focus();
1790
+ }, []), Fe(() => {
1751
1791
  const a = (k) => {
1752
- k.key === "Escape" && (k.stopPropagation(), Z());
1792
+ k.key === "Escape" && (k.stopPropagation(), I());
1753
1793
  };
1754
1794
  return window.addEventListener("keydown", a, !0), () => window.removeEventListener("keydown", a, !0);
1755
- }, [Z]);
1756
- const G = O(() => {
1795
+ }, [I]);
1796
+ const pe = E(() => {
1757
1797
  var k;
1758
- const a = (k = [...(y ?? "").matchAll(/\{\{([\w.]+)\}\}/g)][0]) == null ? void 0 : k[1];
1798
+ const a = (k = [...(g ?? "").matchAll(/\{\{([\w.]+)\}\}/g)][0]) == null ? void 0 : k[1];
1759
1799
  return a && !a.includes(".") ? a : "id";
1760
- }, [y]), se = !q && _.includes(".") ? `*,${_}` : "*", v = 50, { data: T, isFetching: F } = z({
1761
- queryKey: ["favorites-manager-list", f, ne, G, C],
1762
- queryFn: () => E.request(
1763
- R(`/items/${f}`, {
1764
- fields: se,
1765
- limit: v,
1766
- page: C,
1767
- sort: G,
1768
- ...ne.trim() ? { search: ne } : {}
1800
+ }, [g]), de = !$ && _.includes(".") ? `*,${_}` : "*", ee = 50, { data: ce, isFetching: X } = V({
1801
+ queryKey: ["favorites-manager-list", f, G, pe, L],
1802
+ queryFn: () => C.request(
1803
+ A(`/items/${f}`, {
1804
+ fields: de,
1805
+ limit: ee,
1806
+ page: L,
1807
+ sort: pe,
1808
+ ...G.trim() ? { search: G } : {}
1769
1809
  })
1770
1810
  ),
1771
1811
  staleTime: 3e4,
1772
1812
  placeholderData: (a) => a
1773
- }), W = ((T == null ? void 0 : T.data) ?? []).filter((a) => !l.has(String(a.id))), L = (T == null ? void 0 : T.total) ?? W.length, K = Math.max(1, Math.ceil(L / v)), { data: de = [] } = z({
1774
- queryKey: ["favorites-manager-pinned", f, se, g.join(",")],
1775
- queryFn: () => E.request(
1776
- R(`/items/${f}`, {
1777
- filter: JSON.stringify({ id: { _in: g } }),
1778
- fields: se,
1779
- limit: g.length,
1780
- sort: G
1813
+ }), ae = ((ce == null ? void 0 : ce.data) ?? []).filter((a) => !l.has(String(a.id))), D = (ce == null ? void 0 : ce.total) ?? ae.length, te = Math.max(1, Math.ceil(D / ee)), { data: he = [] } = V({
1814
+ queryKey: ["favorites-manager-pinned", f, de, h.join(",")],
1815
+ queryFn: () => C.request(
1816
+ A(`/items/${f}`, {
1817
+ filter: JSON.stringify({ id: { _in: h } }),
1818
+ fields: de,
1819
+ limit: h.length,
1820
+ sort: pe
1781
1821
  })
1782
1822
  ).then((a) => a.data ?? []),
1783
- enabled: g.length > 0,
1823
+ enabled: h.length > 0,
1784
1824
  staleTime: 3e4
1785
- }), x = O(() => {
1825
+ }), y = E(() => {
1786
1826
  const a = /* @__PURE__ */ new Set();
1787
- for (const k of W) a.add(String(k.id));
1788
- for (const k of g) a.add(k);
1827
+ for (const k of ae) a.add(String(k.id));
1828
+ for (const k of h) a.add(k);
1789
1829
  return [...a];
1790
- }, [W, g]), { data: pe = /* @__PURE__ */ new Map() } = z({
1791
- queryKey: ["favorites-manager-sections", q == null ? void 0 : q.junction, x.join(",")],
1830
+ }, [ae, h]), { data: ke = /* @__PURE__ */ new Map() } = V({
1831
+ queryKey: ["favorites-manager-sections", $ == null ? void 0 : $.junction, y.join(",")],
1792
1832
  queryFn: async () => {
1793
- const a = q, k = await ot(E, `/items/${a.junction}`, {
1833
+ const a = $, k = await ct(C, `/items/${a.junction}`, {
1794
1834
  fields: `${a.fkToItem},${a.fkToSection}`,
1795
- filter: JSON.stringify({ [a.fkToItem]: { _in: x } })
1796
- }), U = [...new Set(k.map((H) => String(H[a.fkToSection])))], J = U.length ? await ot(E, `/items/${a.target}`, {
1835
+ filter: JSON.stringify({ [a.fkToItem]: { _in: y } })
1836
+ }), U = [...new Set(k.map((M) => String(M[a.fkToSection])))], B = U.length ? await ct(C, `/items/${a.target}`, {
1797
1837
  fields: `id,${a.labelPath}`,
1798
1838
  filter: JSON.stringify({ id: { _in: U } })
1799
1839
  }) : [], re = new Map(
1800
- J.map((H) => [String(H.id), String(rr(H, a.labelPath) ?? "")])
1801
- ), M = /* @__PURE__ */ new Map();
1802
- for (const H of k) {
1803
- const ie = re.get(String(H[a.fkToSection]));
1840
+ B.map((M) => [String(M.id), String(ir(M, a.labelPath) ?? "")])
1841
+ ), Y = /* @__PURE__ */ new Map();
1842
+ for (const M of k) {
1843
+ const ie = re.get(String(M[a.fkToSection]));
1804
1844
  if (!ie) continue;
1805
- const me = String(H[a.fkToItem]), ke = M.get(me) ?? [];
1806
- ke.includes(ie) || ke.push(ie), M.set(me, ke);
1845
+ const ue = String(M[a.fkToItem]), we = Y.get(ue) ?? [];
1846
+ we.includes(ie) || we.push(ie), Y.set(ue, we);
1807
1847
  }
1808
- return M;
1848
+ return Y;
1809
1849
  },
1810
- enabled: !!q && x.length > 0,
1850
+ enabled: !!$ && y.length > 0,
1811
1851
  staleTime: 6e4
1812
- }), _e = (a) => y ? Fe(y, a) : String(a.cifa_number ?? a.name ?? `#${a.id}`), Oe = (a) => {
1852
+ }), v = (a) => g ? Te(g, a) : String(a.cifa_number ?? a.name ?? `#${a.id}`), K = (a) => {
1813
1853
  const k = a.description ?? a.long_description ?? a.name;
1814
- return typeof k == "string" && k.trim() && k.trim() !== _e(a) ? k : "";
1815
- }, X = (a) => {
1816
- if (q) return (pe.get(String(a.id)) ?? []).join(", ");
1854
+ return typeof k == "string" && k.trim() && k.trim() !== v(a) ? k : "";
1855
+ }, F = (a) => {
1856
+ if ($) return (ke.get(String(a.id)) ?? []).join(", ");
1817
1857
  if (!_) return "";
1818
- const k = Fe(`{{${_}}}`, a);
1858
+ const k = Te(`{{${_}}}`, a);
1819
1859
  return k === `{{${_}}}` ? "" : k;
1820
- }, ee = (a, k) => {
1860
+ }, J = (a, k) => {
1821
1861
  if (k === "presence")
1822
1862
  return a == null || a === "" || Number(a) === 0 ? "No" : "Yes";
1823
1863
  if (a == null || a === "") return "—";
1824
1864
  const U = Number(a);
1825
1865
  return k === "currency" && Number.isFinite(U) ? U.toLocaleString("en-US", { style: "currency", currency: "USD" }) : k === "number" && Number.isFinite(U) ? U.toLocaleString() : String(a);
1826
- }, A = $t({
1827
- queries: $.map((a) => {
1828
- const k = Ue(a.match, p);
1866
+ }, S = $t({
1867
+ queries: j.map((a) => {
1868
+ const k = De(a.match, x);
1829
1869
  return {
1830
1870
  queryKey: [
1831
1871
  "favorites-manager-related",
1832
1872
  a.key,
1833
1873
  a.collection,
1834
1874
  JSON.stringify(k),
1835
- x.join(",")
1875
+ y.join(",")
1836
1876
  ],
1837
1877
  queryFn: async () => {
1838
- const U = await E.request(
1839
- R(`/items/${a.collection}`, {
1840
- filter: JSON.stringify({ [a.item_field]: { _in: x }, ...k ?? {} }),
1878
+ const U = await C.request(
1879
+ A(`/items/${a.collection}`, {
1880
+ filter: JSON.stringify({ [a.item_field]: { _in: y }, ...k ?? {} }),
1841
1881
  fields: `${a.item_field},${a.value_field}`,
1842
1882
  limit: 1e3
1843
1883
  })
1844
- ).then((re) => re.data ?? []), J = /* @__PURE__ */ new Map();
1884
+ ).then((re) => re.data ?? []), B = /* @__PURE__ */ new Map();
1845
1885
  for (const re of U) {
1846
- const M = String(re[a.item_field]), H = re[a.value_field], ie = J.get(M);
1847
- ie === void 0 ? J.set(M, H) : Number.isFinite(Number(ie)) && Number.isFinite(Number(H)) && J.set(M, Number(ie) + Number(H));
1886
+ const Y = String(re[a.item_field]), M = re[a.value_field], ie = B.get(Y);
1887
+ ie === void 0 ? B.set(Y, M) : Number.isFinite(Number(ie)) && Number.isFinite(Number(M)) && B.set(Y, Number(ie) + Number(M));
1848
1888
  }
1849
- return J;
1889
+ return B;
1850
1890
  },
1851
- enabled: x.length > 0 && (a.match === void 0 || k !== null),
1891
+ enabled: y.length > 0 && (a.match === void 0 || k !== null),
1852
1892
  staleTime: 3e4
1853
1893
  };
1854
1894
  })
1855
- }), ce = $.filter(
1856
- (a) => a.match !== void 0 && Ue(a.match, p) === null
1857
- ), De = (a) => {
1895
+ }), P = j.filter(
1896
+ (a) => a.match !== void 0 && De(a.match, x) === null
1897
+ ), me = (a) => {
1858
1898
  const k = l.has(a);
1859
1899
  return /* @__PURE__ */ n(
1860
1900
  "button",
1861
1901
  {
1862
1902
  type: "button",
1863
1903
  title: k ? "Remove from favorites" : "Add to favorites",
1864
- disabled: h.has(a),
1865
- onClick: () => P(a),
1904
+ disabled: p.has(a),
1905
+ onClick: () => z(a),
1866
1906
  className: "shrink-0 rounded p-1 transition-colors hover:bg-amber-100/60 dark:hover:bg-amber-400/10",
1867
- children: h.has(a) ? /* @__PURE__ */ n(ae, { className: "h-4 w-4 animate-spin text-amber-400" }) : /* @__PURE__ */ n(
1907
+ children: p.has(a) ? /* @__PURE__ */ n(ne, { className: "h-4 w-4 animate-spin text-amber-400" }) : /* @__PURE__ */ n(
1868
1908
  Be,
1869
1909
  {
1870
- className: B(
1910
+ className: Q(
1871
1911
  "h-4 w-4",
1872
1912
  k ? "fill-amber-400 text-amber-400" : "text-slate-300 hover:text-amber-400"
1873
1913
  )
@@ -1875,37 +1915,37 @@ function Zr({
1875
1915
  )
1876
1916
  }
1877
1917
  );
1878
- }, Q = (a, k) => /* @__PURE__ */ n("tr", { children: /* @__PURE__ */ n("td", { colSpan: 4 + $.length, className: B("border-b px-3 py-1.5", k), children: a }) }), te = (a, k) => {
1879
- const U = String(a.id), J = Oe(a);
1918
+ }, R = (a, k) => /* @__PURE__ */ n("tr", { children: /* @__PURE__ */ n("td", { colSpan: 4 + j.length, className: Q("border-b px-3 py-1.5", k), children: a }) }), H = (a, k) => {
1919
+ const U = String(a.id), B = K(a);
1880
1920
  return /* @__PURE__ */ m(
1881
1921
  "tr",
1882
1922
  {
1883
- className: B(
1923
+ className: Q(
1884
1924
  "border-b border-slate-100 dark:border-border/50",
1885
1925
  k % 2 === 0 ? "bg-white dark:bg-background" : "bg-slate-50/50 dark:bg-muted/30"
1886
1926
  ),
1887
1927
  children: [
1888
- /* @__PURE__ */ n("td", { className: "px-2 py-1", children: De(U) }),
1889
- /* @__PURE__ */ n("td", { className: "px-2 py-1 font-medium tabular-nums text-slate-700 dark:text-slate-200", children: er(f) ? /* @__PURE__ */ n(
1928
+ /* @__PURE__ */ n("td", { className: "px-2 py-1", children: me(U) }),
1929
+ /* @__PURE__ */ n("td", { className: "px-2 py-1 font-medium tabular-nums text-slate-700 dark:text-slate-200", children: sr(f) ? /* @__PURE__ */ n(
1890
1930
  "button",
1891
1931
  {
1892
1932
  type: "button",
1893
- onClick: () => tr(f, U, p),
1933
+ onClick: () => ar(f, U, x),
1894
1934
  title: "View stock & planning detail",
1895
1935
  className: "text-left underline decoration-slate-300 decoration-1 underline-offset-2 hover:text-[#009abe] hover:decoration-[#009abe] dark:decoration-slate-600",
1896
- children: _e(a)
1936
+ children: v(a)
1897
1937
  }
1898
- ) : _e(a) }),
1899
- /* @__PURE__ */ n("td", { className: "max-w-0 px-2 py-1", children: /* @__PURE__ */ n("p", { className: "truncate text-slate-600 dark:text-slate-300", "data-tip": J || void 0, children: J || "—" }) }),
1900
- /* @__PURE__ */ n("td", { className: "px-2 py-1", children: /* @__PURE__ */ n("p", { className: "truncate text-slate-500 dark:text-slate-400", children: X(a) || "—" }) }),
1901
- $.map((re, M) => {
1902
- var me, ke;
1903
- const H = re.match !== void 0 && Ue(re.match, p) === null, ie = H || (ke = (me = A[M]) == null ? void 0 : me.data) == null ? void 0 : ke.get(U);
1938
+ ) : v(a) }),
1939
+ /* @__PURE__ */ n("td", { className: "max-w-0 px-2 py-1", children: /* @__PURE__ */ n("p", { className: "truncate text-slate-600 dark:text-slate-300", "data-tip": B || void 0, children: B || "—" }) }),
1940
+ /* @__PURE__ */ n("td", { className: "px-2 py-1", children: /* @__PURE__ */ n("p", { className: "truncate text-slate-500 dark:text-slate-400", children: F(a) || "—" }) }),
1941
+ j.map((re, Y) => {
1942
+ var ue, we;
1943
+ const M = re.match !== void 0 && De(re.match, x) === null, ie = M || (we = (ue = S[Y]) == null ? void 0 : ue.data) == null ? void 0 : we.get(U);
1904
1944
  return /* @__PURE__ */ n(
1905
1945
  "td",
1906
1946
  {
1907
1947
  className: "whitespace-nowrap px-2 py-1 text-right tabular-nums text-slate-600 dark:text-slate-300",
1908
- children: H ? "—" : ee(ie, re.format)
1948
+ children: M ? "—" : J(ie, re.format)
1909
1949
  },
1910
1950
  re.key
1911
1951
  );
@@ -1914,14 +1954,14 @@ function Zr({
1914
1954
  },
1915
1955
  U
1916
1956
  );
1917
- }, Te = (D == null ? void 0 : D.closest('[role="dialog"]')) ?? document.body, he = V.trim() ? de.filter((a) => Cr(`${_e(a)} ${Oe(a)} ${X(a)}`, V)) : de;
1918
- return Fr(
1957
+ }, Oe = (se == null ? void 0 : se.closest('[role="dialog"]')) ?? document.body, xe = O.trim() ? he.filter((a) => Vr(`${v(a)} ${K(a)} ${F(a)}`, O)) : he;
1958
+ return Ar(
1919
1959
  /* @__PURE__ */ m("div", { className: "fixed inset-0 z-[125]", role: "presentation", children: [
1920
1960
  /* @__PURE__ */ n(
1921
1961
  "div",
1922
1962
  {
1923
1963
  className: "absolute inset-0 bg-slate-900/30 motion-safe:animate-in motion-safe:fade-in",
1924
- onClick: Z
1964
+ onClick: I
1925
1965
  }
1926
1966
  ),
1927
1967
  /* @__PURE__ */ m(
@@ -1942,40 +1982,40 @@ function Zr({
1942
1982
  "button",
1943
1983
  {
1944
1984
  type: "button",
1945
- onClick: Z,
1985
+ onClick: I,
1946
1986
  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]",
1947
1987
  "aria-label": "Close",
1948
- children: /* @__PURE__ */ n(lt, { className: "h-4 w-4" })
1988
+ children: /* @__PURE__ */ n(dt, { className: "h-4 w-4" })
1949
1989
  }
1950
1990
  )
1951
1991
  ] }),
1952
1992
  /* @__PURE__ */ m("div", { className: "border-b border-slate-200 px-3 py-2 dark:border-border", children: [
1953
1993
  /* @__PURE__ */ m("div", { className: "flex items-center gap-2 rounded-md border border-slate-200 bg-slate-50 px-2.5 py-1.5 focus-within:border-nvr-cyan focus-within:bg-white dark:border-border dark:bg-muted/40 dark:focus-within:bg-background", children: [
1954
- /* @__PURE__ */ n(it, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" }),
1994
+ /* @__PURE__ */ n(ot, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" }),
1955
1995
  /* @__PURE__ */ n(
1956
1996
  "input",
1957
1997
  {
1958
- ref: be,
1959
- value: V,
1998
+ ref: qe,
1999
+ value: O,
1960
2000
  onChange: (a) => oe(a.target.value),
1961
2001
  placeholder: "Search by number or description…",
1962
2002
  className: "min-w-0 flex-1 bg-transparent text-[12px] text-slate-700 outline-none placeholder:text-slate-400 dark:text-slate-200"
1963
2003
  }
1964
2004
  ),
1965
- V && /* @__PURE__ */ n(
2005
+ O && /* @__PURE__ */ n(
1966
2006
  "button",
1967
2007
  {
1968
2008
  type: "button",
1969
2009
  onClick: () => oe(""),
1970
2010
  className: "shrink-0 text-slate-400 hover:text-slate-600",
1971
2011
  "aria-label": "Clear search",
1972
- children: /* @__PURE__ */ n(lt, { className: "h-3.5 w-3.5" })
2012
+ children: /* @__PURE__ */ n(dt, { className: "h-3.5 w-3.5" })
1973
2013
  }
1974
2014
  )
1975
2015
  ] }),
1976
- ce.length > 0 && /* @__PURE__ */ m("p", { className: "mt-1.5 flex items-center gap-1 text-[10px] text-amber-600 dark:text-amber-400", children: [
2016
+ P.length > 0 && /* @__PURE__ */ m("p", { className: "mt-1.5 flex items-center gap-1 text-[10px] text-amber-600 dark:text-amber-400", children: [
1977
2017
  /* @__PURE__ */ n(ze, { className: "h-3 w-3 shrink-0" }),
1978
- ce.map((a) => a.label ?? I(a.key)).join(", "),
2018
+ P.map((a) => a.label ?? Z(a.key)).join(", "),
1979
2019
  " fill in once the form's warehouse selection is made."
1980
2020
  ] })
1981
2021
  ] }),
@@ -1985,63 +2025,63 @@ function Zr({
1985
2025
  /* @__PURE__ */ n("col", { className: "w-[88px]" }),
1986
2026
  /* @__PURE__ */ n("col", {}),
1987
2027
  /* @__PURE__ */ n("col", { className: "w-[130px]" }),
1988
- $.map((a) => /* @__PURE__ */ n("col", { className: "w-[86px]" }, a.key))
2028
+ j.map((a) => /* @__PURE__ */ n("col", { className: "w-[86px]" }, a.key))
1989
2029
  ] }),
1990
2030
  /* @__PURE__ */ n("thead", { className: "sticky top-0 z-[1]", children: /* @__PURE__ */ m("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: [
1991
2031
  /* @__PURE__ */ n("th", { className: "px-2 py-1.5", "aria-label": "Favorite" }),
1992
2032
  /* @__PURE__ */ n("th", { className: "px-2 py-1.5", children: "CIFA #" }),
1993
2033
  /* @__PURE__ */ n("th", { className: "px-2 py-1.5", children: "Description" }),
1994
2034
  /* @__PURE__ */ n("th", { className: "px-2 py-1.5", children: "Category" }),
1995
- $.map((a) => /* @__PURE__ */ n("th", { className: "px-2 py-1.5 text-right", children: a.label ?? I(a.key) }, a.key))
2035
+ j.map((a) => /* @__PURE__ */ n("th", { className: "px-2 py-1.5 text-right", children: a.label ?? Z(a.key) }, a.key))
1996
2036
  ] }) }),
1997
- /* @__PURE__ */ m("tbody", { className: B(F && "opacity-50 transition-opacity"), children: [
1998
- Q(
2037
+ /* @__PURE__ */ m("tbody", { className: Q(X && "opacity-50 transition-opacity"), children: [
2038
+ R(
1999
2039
  /* @__PURE__ */ m("span", { className: "flex items-center gap-1.5", children: [
2000
2040
  /* @__PURE__ */ n(Be, { className: "h-3 w-3 shrink-0 fill-amber-400 text-amber-400" }),
2001
2041
  /* @__PURE__ */ n("span", { className: "text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: "Your favorites" }),
2002
- /* @__PURE__ */ n("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: g.length })
2042
+ /* @__PURE__ */ n("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: h.length })
2003
2043
  ] }),
2004
2044
  "border-slate-200 bg-amber-50/70 dark:border-border dark:bg-amber-900/10"
2005
2045
  ),
2006
- he.length === 0 && /* @__PURE__ */ n("tr", { children: /* @__PURE__ */ n(
2046
+ xe.length === 0 && /* @__PURE__ */ n("tr", { children: /* @__PURE__ */ n(
2007
2047
  "td",
2008
2048
  {
2009
- colSpan: 4 + $.length,
2049
+ colSpan: 4 + j.length,
2010
2050
  className: "border-b border-slate-100 px-4 py-3 text-center text-[11px] text-slate-400 dark:border-border/50",
2011
- children: g.length === 0 ? "No favorites yet — star the items you order most." : "No favorites match your search."
2051
+ children: h.length === 0 ? "No favorites yet — star the items you order most." : "No favorites match your search."
2012
2052
  }
2013
2053
  ) }),
2014
- he.map((a, k) => te(a, k)),
2015
- Q(
2054
+ xe.map((a, k) => H(a, k)),
2055
+ R(
2016
2056
  /* @__PURE__ */ m("span", { className: "flex items-center gap-1.5", children: [
2017
- /* @__PURE__ */ n(it, { className: "h-3 w-3 shrink-0 text-slate-400" }),
2057
+ /* @__PURE__ */ n(ot, { className: "h-3 w-3 shrink-0 text-slate-400" }),
2018
2058
  /* @__PURE__ */ n("span", { className: "text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: "All CIFAs" }),
2019
- /* @__PURE__ */ n("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: L.toLocaleString() }),
2020
- F && /* @__PURE__ */ n(ae, { className: "h-3 w-3 animate-spin text-slate-400" })
2059
+ /* @__PURE__ */ n("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: D.toLocaleString() }),
2060
+ X && /* @__PURE__ */ n(ne, { className: "h-3 w-3 animate-spin text-slate-400" })
2021
2061
  ] }),
2022
2062
  "border-t border-slate-200 bg-slate-50 dark:border-border dark:bg-muted/40"
2023
2063
  ),
2024
- !F && W.length === 0 && /* @__PURE__ */ n("tr", { children: /* @__PURE__ */ n(
2064
+ !X && ae.length === 0 && /* @__PURE__ */ n("tr", { children: /* @__PURE__ */ n(
2025
2065
  "td",
2026
2066
  {
2027
- colSpan: 4 + $.length,
2067
+ colSpan: 4 + j.length,
2028
2068
  className: "px-4 py-4 text-center text-[11px] text-slate-400",
2029
- children: ne.trim() ? `No CIFAs match "${ne}".` : "No catalog items."
2069
+ children: G.trim() ? `No CIFAs match "${G}".` : "No catalog items."
2030
2070
  }
2031
2071
  ) }),
2032
- W.map((a, k) => te(a, k))
2072
+ ae.map((a, k) => H(a, k))
2033
2073
  ] })
2034
2074
  ] }) }),
2035
- K > 1 && /* @__PURE__ */ m("div", { className: "flex shrink-0 items-center justify-between border-t border-slate-200 px-3 py-2 dark:border-border", children: [
2075
+ te > 1 && /* @__PURE__ */ m("div", { className: "flex shrink-0 items-center justify-between border-t border-slate-200 px-3 py-2 dark:border-border", children: [
2036
2076
  /* @__PURE__ */ m("span", { className: "flex items-center gap-2 text-[10px] tabular-nums text-slate-400", children: [
2037
- (C - 1) * v + 1,
2077
+ (L - 1) * ee + 1,
2038
2078
  "–",
2039
- Math.min(C * v, L),
2079
+ Math.min(L * ee, D),
2040
2080
  " of",
2041
2081
  " ",
2042
- L.toLocaleString(),
2043
- F && /* @__PURE__ */ m("span", { className: "flex items-center gap-1 text-slate-500", children: [
2044
- /* @__PURE__ */ n(ae, { className: "h-3 w-3 animate-spin" }),
2082
+ D.toLocaleString(),
2083
+ X && /* @__PURE__ */ m("span", { className: "flex items-center gap-1 text-slate-500", children: [
2084
+ /* @__PURE__ */ n(ne, { className: "h-3 w-3 animate-spin" }),
2045
2085
  " Loading…"
2046
2086
  ] })
2047
2087
  ] }),
@@ -2050,23 +2090,23 @@ function Zr({
2050
2090
  "button",
2051
2091
  {
2052
2092
  type: "button",
2053
- disabled: C <= 1 || F,
2093
+ disabled: L <= 1 || X,
2054
2094
  onClick: () => ye((a) => Math.max(1, a - 1)),
2055
2095
  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]",
2056
2096
  children: "‹ Prev"
2057
2097
  }
2058
2098
  ),
2059
2099
  /* @__PURE__ */ m("span", { className: "px-1 text-[10px] tabular-nums text-slate-400", children: [
2060
- C,
2100
+ L,
2061
2101
  " / ",
2062
- K.toLocaleString()
2102
+ te.toLocaleString()
2063
2103
  ] }),
2064
2104
  /* @__PURE__ */ n(
2065
2105
  "button",
2066
2106
  {
2067
2107
  type: "button",
2068
- disabled: C >= K || F,
2069
- onClick: () => ye((a) => Math.min(K, a + 1)),
2108
+ disabled: L >= te || X,
2109
+ onClick: () => ye((a) => Math.min(te, a + 1)),
2070
2110
  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]",
2071
2111
  children: "Next ›"
2072
2112
  }
@@ -2077,10 +2117,10 @@ function Zr({
2077
2117
  }
2078
2118
  )
2079
2119
  ] }),
2080
- Te
2120
+ Oe
2081
2121
  );
2082
2122
  }
2083
2123
  export {
2084
- yn as CatalogPickerField,
2085
- Xt as matchesShowWhen
2124
+ qn as CatalogPickerField,
2125
+ rr as matchesShowWhen
2086
2126
  };