@nivaro/react 0.3.30 → 0.3.32

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