@nivaro/react 0.3.82 → 0.3.83

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