@nivaro/react 0.3.52 → 0.3.54

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/dist/full.css +1 -1
  2. package/dist/hooks/useSessionRecorder.js +1 -1
  3. package/dist/index.d.ts +47 -3
  4. package/dist/shared/components/ItemEditForm.js +4196 -4163
  5. package/dist/shared/components/NotificationBell.js +163 -150
  6. package/dist/shared/components/PageRenderer.js +645 -593
  7. package/dist/shared/components/ProfileView.js +36 -34
  8. package/dist/shared/components/QueryStatStrip.js +96 -89
  9. package/dist/shared/components/QueryTable.js +214 -215
  10. package/dist/shared/components/ReportView.js +548 -529
  11. package/dist/shared/components/alerts/AlertManagerView.js +346 -320
  12. package/dist/shared/components/item-edit/CatalogPickerField.js +1300 -1219
  13. package/dist/shared/components/item-edit/DraftRecoveryBanner.js +52 -54
  14. package/dist/shared/components/item-edit/FieldAffordances.js +145 -136
  15. package/dist/shared/components/item-edit/FieldRenderer.js +366 -326
  16. package/dist/shared/components/item-edit/InlineTableField.js +3047 -2932
  17. package/dist/shared/components/item-edit/NestedRelationEditor.js +149 -143
  18. package/dist/shared/components/item-edit/PersonalDefaultControl.js +12 -11
  19. package/dist/shared/components/item-edit/PlanGrid.js +718 -705
  20. package/dist/shared/components/item-edit/RelationCombobox.js +23 -20
  21. package/dist/shared/components/item-edit/SummaryPanel.js +415 -361
  22. package/dist/shared/components/item-edit/line-qty.js +115 -53
  23. package/dist/shared/components/item-edit/save-outcome.js +48 -0
  24. package/dist/shared/components/item-edit/save-refusal.js +18 -18
  25. package/dist/shared/components/item-edit/stale-banner.js +13 -0
  26. package/dist/shared/components/item-edit/usePersonalDefaults.js +225 -220
  27. package/dist/shared/components/panels/CommentPanel.js +204 -197
  28. package/dist/shared/components/panels/ItemLockBanner.js +318 -291
  29. package/dist/shared/components/panels/PipelinePanel.js +1388 -1218
  30. package/dist/shared/components/panels/RecordIntegrityBanner.js +201 -172
  31. package/dist/shared/components/panels/RevisionsPanel.js +101 -106
  32. package/dist/shared/components/panels/TransitionRequirementsDialog.js +564 -534
  33. package/dist/shared/components/panels/requirement-side-effects.js +46 -29
  34. package/dist/shared/components/queue/QueueItemSheet.js +219 -146
  35. package/dist/shared/components/queue/QueueWorklist.js +738 -730
  36. package/dist/shared/components/widgets/ReviewListWidget.js +236 -201
  37. package/dist/shared/lib/activity-sentence.js +236 -227
  38. package/dist/shared/lib/draft-store.js +35 -29
  39. package/dist/shared/lib/page-widget-access.js +11 -0
  40. package/dist/shared/lib/record-ref.js +43 -34
  41. package/package.json +1 -1
@@ -1,22 +1,22 @@
1
- import { jsx as l, jsxs as g, Fragment as $e } from "react/jsx-runtime";
2
- import { useQueryClient as Ee, useQuery as ae } from "@tanstack/react-query";
3
- import { AlertCircle as B, CopyPlus as qe, Loader2 as Z, ChevronDown as ge, Check as xe, Paperclip as oe, X as Oe } from "lucide-react";
4
- import { useState as q, useRef as K, Fragment as Le, useEffect as ye, useLayoutEffect as Re } from "react";
5
- import { createPortal as Fe } from "react-dom";
6
- import { useNivaroClient as ne } from "../../context.js";
7
- import { patch as ce, get as z, del as de, post as ue } from "../../lib/commands.js";
8
- import { cn as P, titleCase as De } from "../../lib/utils.js";
9
- import { buildCascadeFilter as Pe } from "../item-edit/helpers.js";
10
- import { extractTemplateFields as Ke, renderDisplayTemplate as fe } from "../pipeline/relations.js";
11
- import { Button as H } from "../ui/button.js";
12
- import { Dialog as Te, DialogContent as Ue, DialogHeader as Ve, DialogTitle as Me, DialogBody as Be, DialogFooter as Ie } from "../ui/dialog.js";
13
- import { Input as M } from "../ui/input.js";
14
- import { keepValuesPatch as He, runPooled as me, overwrittenBySideEffect as Qe } from "./requirement-side-effects.js";
15
- const ze = "x-nivaro-requirements-for";
16
- function R(r, s) {
17
- return `${r}::${String(s)}`;
1
+ import { jsx as s, jsxs as k, Fragment as Le } from "react/jsx-runtime";
2
+ import { useQueryClient as Oe, useQuery as ce } from "@tanstack/react-query";
3
+ import { AlertCircle as I, CopyPlus as Fe, Loader2 as ee, ChevronDown as ye, Check as ke, Paperclip as de, X as Re } from "lucide-react";
4
+ import { useState as L, useRef as z, Fragment as De, useEffect as ve, useLayoutEffect as Pe } from "react";
5
+ import { createPortal as Te } from "react-dom";
6
+ import { useNivaroClient as ie } from "../../context.js";
7
+ import { patch as ue, get as Q, del as fe, post as me } from "../../lib/commands.js";
8
+ import { cn as K, titleCase as te } from "../../lib/utils.js";
9
+ import { buildCascadeFilter as Ke } from "../item-edit/helpers.js";
10
+ import { extractTemplateFields as ze, renderDisplayTemplate as pe } from "../pipeline/relations.js";
11
+ import { Button as B } from "../ui/button.js";
12
+ import { Dialog as Ue, DialogContent as Ve, DialogHeader as Ie, DialogTitle as Me, DialogBody as Be, DialogFooter as He } from "../ui/dialog.js";
13
+ import { Input as V } from "../ui/input.js";
14
+ import { keepValuesPatch as Qe, runPooled as he, overwrittenBySideEffect as Je } from "./requirement-side-effects.js";
15
+ const We = "x-nivaro-requirements-for";
16
+ function R(n, i) {
17
+ return `${n}::${String(i)}`;
18
18
  }
19
- const Je = [
19
+ const Ye = [
20
20
  "integer",
21
21
  "bigInteger",
22
22
  "float",
@@ -32,714 +32,741 @@ const Je = [
32
32
  "double",
33
33
  "number"
34
34
  ];
35
- function G(r, s) {
36
- if (s && Je.includes(s)) {
37
- const c = Number(r.trim());
38
- if (!Number.isNaN(c)) return c;
35
+ function X(n, i) {
36
+ if (i && Ye.includes(i)) {
37
+ const a = Number(n.trim());
38
+ if (!Number.isNaN(a)) return a;
39
39
  }
40
- return r;
40
+ return n;
41
41
  }
42
- function ee(r) {
43
- return r == null ? "" : String(r);
42
+ function ne(n) {
43
+ return n == null ? "" : String(n);
44
44
  }
45
- function I(r, s) {
46
- const c = ee(r);
47
- if (!s || c === "") return c;
48
- const y = Number(c);
49
- return Number.isNaN(y) ? c : s === "currency" ? y.toLocaleString("en-US", { style: "currency", currency: "USD" }) : y.toLocaleString("en-US");
45
+ function M(n, i) {
46
+ const a = ne(n);
47
+ if (!i || a === "") return a;
48
+ const b = Number(a);
49
+ return Number.isNaN(b) ? a : i === "currency" ? b.toLocaleString("en-US", {
50
+ style: "currency",
51
+ currency: "USD",
52
+ minimumFractionDigits: 2,
53
+ maximumFractionDigits: 4
54
+ }) : b.toLocaleString("en-US");
50
55
  }
51
- const te = (r) => r.kind === "m2m" || r.kind === "files";
52
- function Q(r) {
53
- return R(r.collection, `record:${r.item}`);
56
+ function G(n) {
57
+ const i = (n.label ?? "").trim();
58
+ return i ? /^[a-z0-9]+(_[a-z0-9]+)+$/.test(i) || i === n.field ? te(i) : i : te(n.field);
54
59
  }
55
- function pe(r, s = !1) {
56
- var y;
57
- const c = {};
58
- for (const d of r) {
59
- if (d.type === "record_fields") {
60
- const k = {};
61
- for (const p of d.fields) {
62
- const h = d.values[p.field];
63
- k[p.field] = te(p) ? Array.isArray(h) ? h.map(String) : [] : ee(h);
60
+ const re = (n) => n.kind === "m2m" || n.kind === "files";
61
+ function H(n) {
62
+ return R(n.collection, `record:${n.item}`);
63
+ }
64
+ function be(n, i = !1) {
65
+ var b;
66
+ const a = {};
67
+ for (const c of n) {
68
+ if (c.type === "record_fields") {
69
+ const y = {};
70
+ for (const m of c.fields) {
71
+ const p = c.values[m.field];
72
+ y[m.field] = re(m) ? Array.isArray(p) ? p.map(String) : [] : ne(p);
64
73
  }
65
- c[Q(d)] = k;
74
+ a[H(c)] = y;
66
75
  continue;
67
76
  }
68
- for (const k of d.rows) {
69
- const p = {};
70
- for (const h of d.fields) {
71
- let m = h.kind === "m2m" ? Array.isArray(k.values[h.field]) ? k.values[h.field].map(String) : [] : ee(k.values[h.field]);
72
- if (s && ((y = d.prefill_values) == null ? void 0 : y[h.field]) != null) {
73
- const j = d.prefill_values[h.field];
74
- h.kind === "m2m" && Array.isArray(m) && m.length === 0 ? m = [String(j)] : h.kind !== "m2m" && m === "" && (m = String(j));
77
+ for (const y of c.rows) {
78
+ const m = {};
79
+ for (const p of c.fields) {
80
+ let h = p.kind === "m2m" ? Array.isArray(y.values[p.field]) ? y.values[p.field].map(String) : [] : ne(y.values[p.field]);
81
+ if (i && ((b = c.prefill_values) == null ? void 0 : b[p.field]) != null) {
82
+ const S = c.prefill_values[p.field];
83
+ p.kind === "m2m" && Array.isArray(h) && h.length === 0 ? h = [String(S)] : p.kind !== "m2m" && h === "" && (h = String(S));
75
84
  }
76
- p[h.field] = m;
85
+ m[p.field] = h;
77
86
  }
78
- c[R(d.collection, k.id)] = p;
87
+ a[R(c.collection, y.id)] = m;
79
88
  }
80
89
  }
81
- return c;
90
+ return a;
82
91
  }
83
- function We(r) {
84
- if (Array.isArray(r)) {
85
- const s = {};
86
- for (const c of r)
87
- (c == null ? void 0 : c.id) != null && (s[String(c.id)] = String(c.name ?? c.id));
88
- return s;
92
+ function Ze(n) {
93
+ if (Array.isArray(n)) {
94
+ const i = {};
95
+ for (const a of n)
96
+ (a == null ? void 0 : a.id) != null && (i[String(a.id)] = String(a.name ?? a.id));
97
+ return i;
89
98
  }
90
- return typeof r == "string" ? { __single__: r } : {};
99
+ return typeof n == "string" ? { __single__: n } : {};
91
100
  }
92
- function Ye({
93
- multiple: r,
94
- ids: s,
95
- initialNames: c,
96
- onChange: y
101
+ function Xe({
102
+ multiple: n,
103
+ ids: i,
104
+ initialNames: a,
105
+ onChange: b
97
106
  }) {
98
- const d = ne(), k = K(null), [p, h] = q({}), [m, j] = q(!1), [N, v] = q(null), A = (_) => p[_] ?? c[_] ?? (r ? void 0 : c.__single__) ?? _;
99
- async function $(_) {
100
- if (!(_ != null && _.length)) return;
101
- j(!0), v(null);
102
- const O = [];
107
+ const c = ie(), y = z(null), [m, p] = L({}), [h, S] = L(!1), [q, $] = L(null), _ = (x) => m[x] ?? a[x] ?? (n ? void 0 : a.__single__) ?? x;
108
+ async function w(x) {
109
+ if (!(x != null && x.length)) return;
110
+ S(!0), $(null);
111
+ const j = [];
103
112
  try {
104
- for (const T of Array.from(_).slice(0, r ? 20 : 1)) {
105
- const U = await d.upload(T), L = String(U.id);
106
- O.push(L), h((J) => ({ ...J, [L]: T.name }));
113
+ for (const O of Array.from(x).slice(0, n ? 20 : 1)) {
114
+ const P = await c.upload(O), F = String(P.id);
115
+ j.push(F), p((J) => ({ ...J, [F]: O.name }));
107
116
  }
108
117
  } catch {
109
- v("A file could not be uploaded");
118
+ $("A file could not be uploaded");
110
119
  } finally {
111
- j(!1), k.current && (k.current.value = "");
120
+ S(!1), y.current && (y.current.value = "");
112
121
  }
113
- O.length && y(r ? [...s, ...O] : O.slice(0, 1));
122
+ j.length && b(n ? [...i, ...j] : j.slice(0, 1));
114
123
  }
115
- return /* @__PURE__ */ g("div", { className: "space-y-1.5", "data-requirement-file": r ? "files" : "file", children: [
116
- s.length > 0 && /* @__PURE__ */ l("ul", { className: "space-y-1", children: s.map((_) => /* @__PURE__ */ g(
124
+ return /* @__PURE__ */ k("div", { className: "space-y-1.5", "data-requirement-file": n ? "files" : "file", children: [
125
+ i.length > 0 && /* @__PURE__ */ s("ul", { className: "space-y-1", children: i.map((x) => /* @__PURE__ */ k(
117
126
  "li",
118
127
  {
119
128
  className: "flex items-center gap-1.5 rounded border border-slate-200 px-2 py-1 text-[12px] text-slate-700 dark:border-border dark:text-slate-200",
120
129
  children: [
121
- /* @__PURE__ */ l(oe, { className: "h-3 w-3 shrink-0 text-slate-400" }),
122
- /* @__PURE__ */ l("span", { className: "min-w-0 flex-1 truncate", children: A(_) }),
123
- /* @__PURE__ */ l(
130
+ /* @__PURE__ */ s(de, { className: "h-3 w-3 shrink-0 text-slate-400" }),
131
+ /* @__PURE__ */ s("span", { className: "min-w-0 flex-1 truncate", children: _(x) }),
132
+ /* @__PURE__ */ s(
124
133
  "button",
125
134
  {
126
135
  type: "button",
127
- "aria-label": `Remove ${A(_)}`,
128
- onClick: () => y(s.filter((O) => O !== _)),
136
+ "aria-label": `Remove ${_(x)}`,
137
+ onClick: () => b(i.filter((j) => j !== x)),
129
138
  className: "rounded p-0.5 text-slate-400 hover:bg-slate-100 hover:text-slate-700 dark:hover:bg-muted",
130
- children: /* @__PURE__ */ l(Oe, { className: "h-3 w-3" })
139
+ children: /* @__PURE__ */ s(Re, { className: "h-3 w-3" })
131
140
  }
132
141
  )
133
142
  ]
134
143
  },
135
- _
144
+ x
136
145
  )) }),
137
- (r || s.length === 0) && /* @__PURE__ */ g($e, { children: [
138
- /* @__PURE__ */ l(
146
+ (n || i.length === 0) && /* @__PURE__ */ k(Le, { children: [
147
+ /* @__PURE__ */ s(
139
148
  "input",
140
149
  {
141
- ref: k,
150
+ ref: y,
142
151
  type: "file",
143
- multiple: r,
152
+ multiple: n,
144
153
  className: "hidden",
145
- onChange: (_) => void $(_.target.files)
154
+ onChange: (x) => void w(x.target.files)
146
155
  }
147
156
  ),
148
- /* @__PURE__ */ g(
149
- H,
157
+ /* @__PURE__ */ k(
158
+ B,
150
159
  {
151
160
  type: "button",
152
161
  variant: "outline",
153
162
  size: "sm",
154
- disabled: m,
163
+ disabled: h,
155
164
  onClick: () => {
156
- var _;
157
- return (_ = k.current) == null ? void 0 : _.click();
165
+ var x;
166
+ return (x = y.current) == null ? void 0 : x.click();
158
167
  },
159
168
  className: "h-8 gap-1.5 text-[12px]",
160
169
  "data-requirement-upload": !0,
161
170
  children: [
162
- m ? /* @__PURE__ */ l(Z, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ l(oe, { className: "h-3.5 w-3.5" }),
163
- m ? "Uploading…" : r ? "Add files" : "Upload a file"
171
+ h ? /* @__PURE__ */ s(ee, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ s(de, { className: "h-3.5 w-3.5" }),
172
+ h ? "Uploading…" : n ? "Add files" : "Upload a file"
164
173
  ]
165
174
  }
166
175
  )
167
176
  ] }),
168
- N && /* @__PURE__ */ l("p", { className: "text-[11px] text-red-600", children: N })
177
+ q && /* @__PURE__ */ s("p", { className: "text-[11px] text-red-600", children: q })
169
178
  ] });
170
179
  }
171
- function ke({
172
- anchor: r,
173
- panelRef: s,
174
- children: c
180
+ function we({
181
+ anchor: n,
182
+ panelRef: i,
183
+ children: a
175
184
  }) {
176
- const y = r.closest('[role="dialog"]'), [d, k] = q(null);
177
- return Re(() => {
178
- if (!y) return;
179
- const p = () => {
180
- const h = r.getBoundingClientRect(), m = y.getBoundingClientRect(), j = h.bottom + 208 > window.innerHeight && h.top > 216;
181
- k(
182
- j ? { bottom: m.bottom - h.top + 4, left: h.left - m.left, width: h.width } : { top: h.bottom - m.top + 4, left: h.left - m.left, width: h.width }
185
+ const b = n.closest('[role="dialog"]'), [c, y] = L(null);
186
+ return Pe(() => {
187
+ if (!b) return;
188
+ const m = () => {
189
+ const p = n.getBoundingClientRect(), h = b.getBoundingClientRect(), S = p.bottom + 208 > window.innerHeight && p.top > 216;
190
+ y(
191
+ S ? { bottom: h.bottom - p.top + 4, left: p.left - h.left, width: p.width } : { top: p.bottom - h.top + 4, left: p.left - h.left, width: p.width }
183
192
  );
184
193
  };
185
- return p(), window.addEventListener("scroll", p, !0), window.addEventListener("resize", p), () => {
186
- window.removeEventListener("scroll", p, !0), window.removeEventListener("resize", p);
194
+ return m(), window.addEventListener("scroll", m, !0), window.addEventListener("resize", m), () => {
195
+ window.removeEventListener("scroll", m, !0), window.removeEventListener("resize", m);
187
196
  };
188
- }, [r, y]), !d || !y ? null : Fe(
189
- /* @__PURE__ */ l(
197
+ }, [n, b]), !c || !b ? null : Te(
198
+ /* @__PURE__ */ s(
190
199
  "div",
191
200
  {
192
- ref: s,
201
+ ref: i,
193
202
  role: "listbox",
194
203
  className: "absolute z-[120] max-h-48 w-56 overflow-y-auto rounded-md border border-slate-200 bg-white py-1 shadow-lg dark:border-border dark:bg-card",
195
- style: { top: d.top, bottom: d.bottom, left: d.left, minWidth: d.width },
196
- children: c
204
+ style: { top: c.top, bottom: c.bottom, left: c.left, minWidth: c.width },
205
+ children: a
197
206
  }
198
207
  ),
199
- y
208
+ b
200
209
  );
201
210
  }
202
- function Xe(r, s) {
203
- const c = String(s.id ?? "");
204
- if (r) {
205
- const d = fe(r, s).trim();
206
- if (/[\p{L}\p{N}]/u.test(d)) return d;
211
+ function Ge(n, i) {
212
+ const a = String(i.id ?? "");
213
+ if (n) {
214
+ const c = pe(n, i).trim();
215
+ if (/[\p{L}\p{N}]/u.test(c)) return c;
207
216
  }
208
- const y = fe(null, {
209
- ...s,
217
+ const b = pe(null, {
218
+ ...i,
210
219
  short_name: void 0
211
220
  }).trim();
212
- return y && y !== c ? y : s.short_name != null && s.short_name !== "" ? String(s.short_name) : c ? `#${c}` : "";
221
+ return b && b !== a ? b : i.short_name != null && i.short_name !== "" ? String(i.short_name) : a ? `#${a}` : "";
213
222
  }
214
- function ve(r, s) {
215
- var y;
216
- const c = [];
217
- if (r.option_filter && Object.keys(r.option_filter).length > 0 && c.push(r.option_filter), (y = r.cascade_filters) != null && y.length) {
218
- const { filter: d } = Pe({
219
- rules: r.cascade_filters,
220
- parentValue: (k) => s == null ? void 0 : s[k]
223
+ function Ne(n, i) {
224
+ var b;
225
+ const a = [];
226
+ if (n.option_filter && Object.keys(n.option_filter).length > 0 && a.push(n.option_filter), (b = n.cascade_filters) != null && b.length) {
227
+ const { filter: c } = Ke({
228
+ rules: n.cascade_filters,
229
+ parentValue: (y) => i == null ? void 0 : i[y]
221
230
  });
222
- d && Object.keys(d).length > 0 && c.push(d);
231
+ c && Object.keys(c).length > 0 && a.push(c);
223
232
  }
224
- if (c.length !== 0)
225
- return c.length === 1 ? c[0] : { _and: c };
233
+ if (a.length !== 0)
234
+ return a.length === 1 ? a[0] : { _and: a };
226
235
  }
227
- function we(r, s) {
228
- const c = ne(), { data: y, isPending: d } = ae({
229
- queryKey: ["col-meta", r],
230
- queryFn: () => c.request(z(`/collections/${r}`)).then((j) => j.data ?? {}),
231
- enabled: !!r,
236
+ function _e(n, i) {
237
+ const a = ie(), { data: b, isPending: c } = ce({
238
+ queryKey: ["col-meta", n],
239
+ queryFn: () => a.request(Q(`/collections/${n}`)).then((q) => q.data ?? {}),
240
+ enabled: !!n,
232
241
  staleTime: 3e5,
233
242
  retry: !1
234
- }), k = (y == null ? void 0 : y.display_template) ?? null, p = k ? Ke(k).join(",") : void 0, h = s ? JSON.stringify(s) : "", { data: m = [] } = ae({
235
- queryKey: ["req-related-options", r, k ?? "", h],
236
- queryFn: () => c.request(
237
- z(`/items/${r}`, {
243
+ }), y = (b == null ? void 0 : b.display_template) ?? null, m = y ? ze(y).join(",") : void 0, p = i ? JSON.stringify(i) : "", { data: h = [], isSuccess: S } = ce({
244
+ queryKey: ["req-related-options", n, y ?? "", p],
245
+ queryFn: () => a.request(
246
+ Q(`/items/${n}`, {
238
247
  limit: 500,
239
248
  picker: "1",
240
- ...p ? { fields: p } : {},
241
- ...h ? { filter: h } : {}
249
+ ...m ? { fields: m } : {},
250
+ ...p ? { filter: p } : {}
242
251
  })
243
252
  ).then(
244
- (j) => (j.data ?? []).map((N) => ({ id: String(N.id), label: Xe(k, N) })).sort((N, v) => N.label.localeCompare(v.label, void 0, { numeric: !0 }))
253
+ (q) => (q.data ?? []).map(($) => ({ id: String($.id), label: Ge(y, $) })).sort(($, _) => $.label.localeCompare(_.label, void 0, { numeric: !0 }))
245
254
  ).catch(() => []),
246
255
  // The template decides `fields`: wait for it (a miss just means none).
247
- enabled: !!r && !d,
256
+ enabled: !!n && !c,
248
257
  staleTime: 3e5
249
258
  });
250
- return m;
259
+ return { options: h, loaded: S };
260
+ }
261
+ const et = /^[A-Za-z][A-Za-z0-9_]*$/;
262
+ function tt(n) {
263
+ let i = n, a = null;
264
+ for (let b = 0; b < 6 && i && typeof i == "object"; b++) {
265
+ if (Array.isArray(i)) {
266
+ i = i[0];
267
+ continue;
268
+ }
269
+ const c = Object.entries(i), y = c.find(([p]) => p === "_and" || p === "_or"), m = c.find(([p]) => et.test(p));
270
+ if (m)
271
+ m[0] !== "id" && (a = m[0]), i = m[1];
272
+ else if (y) i = y[1];
273
+ else break;
274
+ }
275
+ return a ? a.replace(/_id$/, "").replace(/_/g, " ").toLowerCase() : null;
251
276
  }
252
- function he({
253
- meta: r,
254
- selected: s,
255
- onChange: c,
256
- rowValues: y
277
+ function nt(n) {
278
+ const i = n.trim().toLowerCase();
279
+ return i ? /[^aeiou]y$/.test(i) ? `${i.slice(0, -1)}ies` : /(s|x|z|ch|sh)$/.test(i) ? `${i}es` : `${i}s` : "options";
280
+ }
281
+ function Ae(n, i) {
282
+ const a = nt(n.label), b = tt(i);
283
+ return b ? `This ${b} has no ${a} set up. Ask an administrator, or pick another ${b}.` : `No ${a} are set up yet. Ask an administrator.`;
284
+ }
285
+ function ge({
286
+ meta: n,
287
+ selected: i,
288
+ onChange: a,
289
+ rowValues: b
257
290
  }) {
258
- const [d, k] = q(!1), p = K(null), h = K(null), m = we(
259
- r.related_collection,
260
- ve(r, y)
261
- );
262
- ye(() => {
263
- if (!d) return;
264
- const N = (v) => {
265
- var $, _;
266
- const A = v.target;
267
- ($ = p.current) != null && $.contains(A) || (_ = h.current) != null && _.contains(A) || k(!1);
291
+ const [c, y] = L(!1), m = z(null), p = z(null), h = Ne(n, b), { options: S, loaded: q } = _e(n.related_collection, h);
292
+ ve(() => {
293
+ if (!c) return;
294
+ const _ = (w) => {
295
+ var j, O;
296
+ const x = w.target;
297
+ (j = m.current) != null && j.contains(x) || (O = p.current) != null && O.contains(x) || y(!1);
268
298
  };
269
- return window.addEventListener("mousedown", N), () => window.removeEventListener("mousedown", N);
270
- }, [d]);
271
- const j = s.length === 0 ? `Select ${r.label.toLowerCase()}…` : s.map((N) => {
272
- var v;
273
- return ((v = m.find((A) => A.id === N)) == null ? void 0 : v.label) ?? N;
299
+ return window.addEventListener("mousedown", _), () => window.removeEventListener("mousedown", _);
300
+ }, [c]);
301
+ const $ = i.length === 0 ? `Select ${n.label.toLowerCase()}…` : i.map((_) => {
302
+ var w;
303
+ return ((w = S.find((x) => x.id === _)) == null ? void 0 : w.label) ?? _;
274
304
  }).join(", ");
275
- return /* @__PURE__ */ g("div", { ref: p, className: "relative", children: [
276
- /* @__PURE__ */ g(
305
+ return /* @__PURE__ */ k("div", { ref: m, className: "relative", children: [
306
+ /* @__PURE__ */ k(
277
307
  "button",
278
308
  {
279
309
  type: "button",
280
- onClick: () => k((N) => !N),
310
+ onClick: () => y((_) => !_),
281
311
  "aria-haspopup": "listbox",
282
- "aria-expanded": d,
283
- className: P(
312
+ "aria-expanded": c,
313
+ className: K(
284
314
  "flex h-8 w-full min-w-[10rem] items-center justify-between gap-1 rounded-md border border-slate-200 bg-white px-2 text-left text-[12px] dark:border-border dark:bg-card",
285
- s.length === 0 && "text-slate-400"
315
+ i.length === 0 && "text-slate-400"
286
316
  ),
287
317
  children: [
288
- /* @__PURE__ */ l("span", { className: "truncate", children: j }),
289
- /* @__PURE__ */ l(ge, { className: "h-3 w-3 shrink-0 text-slate-400" })
318
+ /* @__PURE__ */ s("span", { className: "truncate", children: $ }),
319
+ /* @__PURE__ */ s(ye, { className: "h-3 w-3 shrink-0 text-slate-400" })
290
320
  ]
291
321
  }
292
322
  ),
293
- d && p.current && /* @__PURE__ */ g(ke, { anchor: p.current, panelRef: h, children: [
294
- m.map((N) => {
295
- const v = s.includes(N.id), A = r.max_values === 1;
296
- return /* @__PURE__ */ g(
323
+ c && m.current && /* @__PURE__ */ k(we, { anchor: m.current, panelRef: p, children: [
324
+ S.map((_) => {
325
+ const w = i.includes(_.id), x = n.max_values === 1;
326
+ return /* @__PURE__ */ k(
297
327
  "button",
298
328
  {
299
329
  type: "button",
300
330
  role: "option",
301
- "aria-selected": v,
331
+ "aria-selected": w,
302
332
  onClick: () => {
303
- if (A) {
304
- c([N.id]), k(!1);
333
+ if (x) {
334
+ a([_.id]), y(!1);
305
335
  return;
306
336
  }
307
- c(v ? s.filter(($) => $ !== N.id) : [...s, N.id]);
337
+ a(w ? i.filter((j) => j !== _.id) : [...i, _.id]);
308
338
  },
309
- className: P(
339
+ className: K(
310
340
  "flex w-full items-center justify-between px-2.5 py-1.5 text-left text-[12px] hover:bg-slate-50 dark:hover:bg-muted/50",
311
- v ? "font-semibold text-nvr-navy dark:text-nvr-cyan" : "text-slate-700 dark:text-slate-200"
341
+ w ? "font-semibold text-nvr-navy dark:text-nvr-cyan" : "text-slate-700 dark:text-slate-200"
312
342
  ),
313
343
  children: [
314
- /* @__PURE__ */ l("span", { className: "truncate", children: N.label }),
315
- v && /* @__PURE__ */ l(xe, { className: "h-3 w-3 shrink-0" })
344
+ /* @__PURE__ */ s("span", { className: "truncate", children: _.label }),
345
+ w && /* @__PURE__ */ s(ke, { className: "h-3 w-3 shrink-0" })
316
346
  ]
317
347
  },
318
- N.id
348
+ _.id
319
349
  );
320
350
  }),
321
- m.length === 0 && /* @__PURE__ */ l("p", { className: "px-2.5 py-2 text-[11px] text-slate-400", children: "No options" })
351
+ S.length === 0 && /* @__PURE__ */ s("p", { className: "max-w-[18rem] px-2.5 py-2 text-[11px] text-slate-500 dark:text-muted-foreground", children: q ? Ae(n, h) : "Loading…" })
322
352
  ] })
323
353
  ] });
324
354
  }
325
- function be({
326
- meta: r,
327
- selected: s,
328
- onChange: c,
329
- rowValues: y
355
+ function xe({
356
+ meta: n,
357
+ selected: i,
358
+ onChange: a,
359
+ rowValues: b
330
360
  }) {
331
- var N;
332
- const [d, k] = q(!1), p = K(null), h = K(null), m = we(
333
- r.related_collection,
334
- ve(r, y)
335
- );
336
- ye(() => {
337
- if (!d) return;
338
- const v = (A) => {
339
- var _, O;
340
- const $ = A.target;
341
- (_ = p.current) != null && _.contains($) || (O = h.current) != null && O.contains($) || k(!1);
361
+ var _;
362
+ const [c, y] = L(!1), m = z(null), p = z(null), h = Ne(n, b), { options: S, loaded: q } = _e(n.related_collection, h);
363
+ ve(() => {
364
+ if (!c) return;
365
+ const w = (x) => {
366
+ var O, P;
367
+ const j = x.target;
368
+ (O = m.current) != null && O.contains(j) || (P = p.current) != null && P.contains(j) || y(!1);
342
369
  };
343
- return window.addEventListener("mousedown", v), () => window.removeEventListener("mousedown", v);
344
- }, [d]);
345
- const j = s ? ((N = m.find((v) => v.id === s)) == null ? void 0 : N.label) ?? s : `Select ${r.label.toLowerCase()}…`;
346
- return /* @__PURE__ */ g("div", { ref: p, className: "relative", children: [
347
- /* @__PURE__ */ g(
370
+ return window.addEventListener("mousedown", w), () => window.removeEventListener("mousedown", w);
371
+ }, [c]);
372
+ const $ = i ? ((_ = S.find((w) => w.id === i)) == null ? void 0 : _.label) ?? i : `Select ${n.label.toLowerCase()}…`;
373
+ return /* @__PURE__ */ k("div", { ref: m, className: "relative", children: [
374
+ /* @__PURE__ */ k(
348
375
  "button",
349
376
  {
350
377
  type: "button",
351
- onClick: () => k((v) => !v),
378
+ onClick: () => y((w) => !w),
352
379
  "aria-haspopup": "listbox",
353
- "aria-expanded": d,
354
- className: P(
380
+ "aria-expanded": c,
381
+ className: K(
355
382
  "flex h-8 w-full min-w-[10rem] items-center justify-between gap-1 rounded-md border border-slate-200 bg-white px-2 text-left text-[12px] dark:border-border dark:bg-card",
356
- !s && "text-slate-400"
383
+ !i && "text-slate-400"
357
384
  ),
358
385
  children: [
359
- /* @__PURE__ */ l("span", { className: "truncate", children: j }),
360
- /* @__PURE__ */ l(ge, { className: "h-3 w-3 shrink-0 text-slate-400" })
386
+ /* @__PURE__ */ s("span", { className: "truncate", children: $ }),
387
+ /* @__PURE__ */ s(ye, { className: "h-3 w-3 shrink-0 text-slate-400" })
361
388
  ]
362
389
  }
363
390
  ),
364
- d && p.current && /* @__PURE__ */ g(ke, { anchor: p.current, panelRef: h, children: [
365
- m.map((v) => {
366
- const A = s === v.id;
367
- return /* @__PURE__ */ g(
391
+ c && m.current && /* @__PURE__ */ k(we, { anchor: m.current, panelRef: p, children: [
392
+ S.map((w) => {
393
+ const x = i === w.id;
394
+ return /* @__PURE__ */ k(
368
395
  "button",
369
396
  {
370
397
  type: "button",
371
398
  role: "option",
372
- "aria-selected": A,
399
+ "aria-selected": x,
373
400
  onClick: () => {
374
- c(v.id), k(!1);
401
+ a(w.id), y(!1);
375
402
  },
376
- className: P(
403
+ className: K(
377
404
  "flex w-full items-center justify-between px-2.5 py-1.5 text-left text-[12px] hover:bg-slate-50 dark:hover:bg-muted/50",
378
- A ? "font-semibold text-nvr-navy dark:text-nvr-cyan" : "text-slate-700 dark:text-slate-200"
405
+ x ? "font-semibold text-nvr-navy dark:text-nvr-cyan" : "text-slate-700 dark:text-slate-200"
379
406
  ),
380
407
  children: [
381
- /* @__PURE__ */ l("span", { className: "truncate", children: v.label }),
382
- A && /* @__PURE__ */ l(xe, { className: "h-3 w-3 shrink-0" })
408
+ /* @__PURE__ */ s("span", { className: "truncate", children: w.label }),
409
+ x && /* @__PURE__ */ s(ke, { className: "h-3 w-3 shrink-0" })
383
410
  ]
384
411
  },
385
- v.id
412
+ w.id
386
413
  );
387
414
  }),
388
- m.length === 0 && /* @__PURE__ */ l("p", { className: "px-2.5 py-2 text-[11px] text-slate-400", children: "No options" })
415
+ S.length === 0 && /* @__PURE__ */ s("p", { className: "max-w-[18rem] px-2.5 py-2 text-[11px] text-slate-500 dark:text-muted-foreground", children: q ? Ae(n, h) : "Loading…" })
389
416
  ] })
390
417
  ] });
391
418
  }
392
- function ft({
393
- payload: r,
394
- transitionId: s,
395
- isRetry: c,
396
- onSubmitted: y,
397
- executing: d = !1,
398
- onClose: k
419
+ function gt({
420
+ payload: n,
421
+ transitionId: i,
422
+ isRetry: a,
423
+ onSubmitted: b,
424
+ executing: c = !1,
425
+ onClose: y
399
426
  }) {
400
- var se;
401
- const p = ne(), h = Ee(), [m, j] = q(
402
- () => pe(r, !0)
403
- ), N = K(pe(r)), [v, A] = q({}), [$, _] = q(!1), [O, T] = q("save"), U = (i) => s ? { ...i, _headers: { [ze]: s } } : i, L = (i, u, x) => {
404
- j((e) => ({ ...e, [i]: { ...e[i], [u]: x } })), A((e) => {
405
- if (!(i in e)) return e;
427
+ var oe;
428
+ const m = ie(), p = Oe(), [h, S] = L(
429
+ () => be(n, !0)
430
+ ), q = z(be(n)), [$, _] = L({}), [w, x] = L(!1), [j, O] = L("save"), P = (l) => i ? { ...l, _headers: { [We]: i } } : l, F = (l, u, v) => {
431
+ S((e) => ({ ...e, [l]: { ...e[l], [u]: v } })), _((e) => {
432
+ if (!(l in e)) return e;
406
433
  const t = { ...e };
407
- return delete t[i], t;
434
+ return delete t[l], t;
408
435
  });
409
- }, J = (i, u) => {
410
- const x = i.rows.map((e) => {
436
+ }, J = (l, u) => {
437
+ const v = l.rows.map((e) => {
411
438
  var t;
412
- return (t = m[R(i.collection, e.id)]) == null ? void 0 : t[u.field];
439
+ return (t = h[R(l.collection, e.id)]) == null ? void 0 : t[u.field];
413
440
  }).find(
414
441
  (e) => u.kind === "m2m" ? Array.isArray(e) && e.length > 0 : typeof e == "string" && e.trim()
415
442
  );
416
- x != null && (j((e) => {
443
+ v != null && (S((e) => {
417
444
  const t = { ...e };
418
- for (const n of i.rows) {
419
- const f = R(i.collection, n.id);
420
- t[f] = { ...t[f], [u.field]: Array.isArray(x) ? [...x] : x };
445
+ for (const r of l.rows) {
446
+ const f = R(l.collection, r.id);
447
+ t[f] = { ...t[f], [u.field]: Array.isArray(v) ? [...v] : v };
421
448
  }
422
449
  return t;
423
- }), A({}));
424
- }, V = (i, u) => {
450
+ }), _({}));
451
+ }, U = (l, u) => {
425
452
  var f;
426
- const x = u.optional_when;
427
- if (!x) return !1;
428
- const e = (f = m[i]) == null ? void 0 : f[x.field], t = new Set(x.in.map(String));
429
- return (Array.isArray(e) ? e : [e]).some((w) => w != null && w !== "" && t.has(String(w)));
430
- }, [Ne, _e] = q({}), re = (i, u) => {
431
- i.trim() && (j((x) => {
453
+ const v = u.optional_when;
454
+ if (!v) return !1;
455
+ const e = (f = h[l]) == null ? void 0 : f[v.field], t = new Set(v.in.map(String));
456
+ return (Array.isArray(e) ? e : [e]).some((N) => N != null && N !== "" && t.has(String(N)));
457
+ }, [Se, Ce] = L({}), le = (l, u) => {
458
+ l.trim() && (S((v) => {
432
459
  var t;
433
- const e = { ...x };
434
- for (const n of r) {
435
- if (n.type !== "child_fields") continue;
436
- const f = n.fields.find((w) => w.field === u);
460
+ const e = { ...v };
461
+ for (const r of n) {
462
+ if (r.type !== "child_fields") continue;
463
+ const f = r.fields.find((N) => N.field === u);
437
464
  if (!(!f || f.kind === "m2m"))
438
- for (const w of n.rows) {
439
- const b = R(n.collection, w.id), o = f.optional_when;
440
- if (o) {
441
- const a = (t = e[b]) == null ? void 0 : t[o.field], C = new Set(o.in.map(String));
442
- if ((Array.isArray(a) ? a : [a]).some((S) => S != null && S !== "" && C.has(String(S)))) continue;
465
+ for (const N of r.rows) {
466
+ const g = R(r.collection, N.id), d = f.optional_when;
467
+ if (d) {
468
+ const o = (t = e[g]) == null ? void 0 : t[d.field], C = new Set(d.in.map(String));
469
+ if ((Array.isArray(o) ? o : [o]).some((A) => A != null && A !== "" && C.has(String(A)))) continue;
443
470
  }
444
- e[b] = { ...e[b], [u]: i };
471
+ e[g] = { ...e[g], [u]: l };
445
472
  }
446
473
  }
447
474
  return e;
448
- }), A({}));
449
- }, Se = r.some((i) => {
450
- if (i.type === "record_fields") {
451
- if (i.optional) return !1;
452
- const u = Q(i);
453
- return i.fields.some((x) => {
475
+ }), _({}));
476
+ }, $e = n.some((l) => {
477
+ if (l.type === "record_fields") {
478
+ if (l.optional) return !1;
479
+ const u = H(l);
480
+ return l.fields.some((v) => {
454
481
  var t;
455
- if (V(u, x)) return !1;
456
- const e = (t = m[u]) == null ? void 0 : t[x.field];
457
- return te(x) ? !Array.isArray(e) || e.length === 0 : !(typeof e == "string" ? e : "").trim();
482
+ if (U(u, v)) return !1;
483
+ const e = (t = h[u]) == null ? void 0 : t[v.field];
484
+ return re(v) ? !Array.isArray(e) || e.length === 0 : !(typeof e == "string" ? e : "").trim();
458
485
  });
459
486
  }
460
- return i.rows.some((u) => {
461
- const x = R(i.collection, u.id);
462
- return i.fields.some((e) => {
463
- var n;
464
- if (V(x, e)) return !1;
465
- const t = (n = m[x]) == null ? void 0 : n[e.field];
487
+ return l.rows.some((u) => {
488
+ const v = R(l.collection, u.id);
489
+ return l.fields.some((e) => {
490
+ var r;
491
+ if (U(v, e)) return !1;
492
+ const t = (r = h[v]) == null ? void 0 : r[e.field];
466
493
  return e.kind === "m2m" ? !Array.isArray(t) || t.length === 0 : !(typeof t == "string" ? t : "").trim();
467
494
  });
468
495
  });
469
- }), ie = ((se = r.find((i) => i.type === "child_fields" && !!i.review)) == null ? void 0 : se.review_message) ?? null, [D, W] = q(null), Y = K({}), Ae = (i, u) => {
470
- const x = R(i.collection, u.id), e = m[x] ?? {}, t = N.current[x] ?? {}, n = {};
471
- for (const f of i.fields)
472
- f.kind === "m2m" || V(x, f) || e[f.field] !== t[f.field] && (n[f.field] = f.kind === "m2o" ? String(e[f.field] ?? "") || null : G(String(e[f.field] ?? ""), f.type));
473
- return n;
474
- }, Ce = async () => {
475
- const i = [];
476
- for (const u of r) {
496
+ }), se = ((oe = n.find((l) => l.type === "child_fields" && !!l.review)) == null ? void 0 : oe.review_message) ?? null, [T, W] = L(null), Y = z({}), je = (l, u) => {
497
+ const v = R(l.collection, u.id), e = h[v] ?? {}, t = q.current[v] ?? {}, r = {};
498
+ for (const f of l.fields)
499
+ f.kind === "m2m" || U(v, f) || e[f.field] !== t[f.field] && (r[f.field] = f.kind === "m2o" ? String(e[f.field] ?? "") || null : X(String(e[f.field] ?? ""), f.type));
500
+ return r;
501
+ }, Ee = async () => {
502
+ const l = [];
503
+ for (const u of n) {
477
504
  if (u.type !== "child_fields") continue;
478
- const x = (e) => u.display_fields.find((t) => t.field === e) ?? u.fields.find((t) => t.field === e);
505
+ const v = (e) => u.display_fields.find((t) => t.field === e) ?? u.fields.find((t) => t.field === e);
479
506
  for (const e of u.rows) {
480
- const t = Ae(u, e);
507
+ const t = je(u, e);
481
508
  if (Object.keys(t).length === 0) continue;
482
- const n = R(u.collection, e.id);
483
- i.push(
484
- () => p.request(
485
- U({
509
+ const r = R(u.collection, e.id);
510
+ l.push(
511
+ () => m.request(
512
+ P({
486
513
  _method: "PATCH",
487
514
  _path: `/items/${u.collection}/${e.id}`,
488
515
  _params: { dry_run: "1" },
489
516
  _body: t
490
517
  })
491
518
  ).then((f) => {
492
- const w = Qe(f, t);
493
- return w.length === 0 ? null : {
494
- rk: n,
519
+ const N = Je(f, t, (g) => !!v(g));
520
+ return N.length === 0 ? null : {
521
+ rk: r,
495
522
  rowLabel: e.label,
496
- changes: w.map((b) => {
497
- const o = x(b.field);
498
- return { ...b, label: (o == null ? void 0 : o.label) ?? De(b.field), format: o == null ? void 0 : o.format };
523
+ changes: N.map((g) => {
524
+ const d = v(g.field);
525
+ return { ...g, label: d ? G(d) : te(g.field), format: d == null ? void 0 : d.format };
499
526
  })
500
527
  };
501
528
  }).catch(() => null)
502
529
  );
503
530
  }
504
531
  }
505
- return (await me(i)).filter((u) => u != null);
506
- }, le = async (i) => {
507
- if (_(!0), i)
508
- Y.current = i === "keep" ? Object.fromEntries((D ?? []).map((e) => [e.rk, He(e.changes)])) : {}, W(null);
532
+ return (await he(l)).filter((u) => u != null);
533
+ }, ae = async (l) => {
534
+ if (x(!0), l)
535
+ Y.current = l === "keep" ? Object.fromEntries((T ?? []).map((e) => [e.rk, Qe(e.changes)])) : {}, W(null);
509
536
  else {
510
537
  Y.current = {};
511
- const e = await Ce();
538
+ const e = await Ee();
512
539
  if (e.length > 0) {
513
- W(e), _(!1);
540
+ W(e), x(!1);
514
541
  return;
515
542
  }
516
543
  }
517
- const u = await me(
518
- r.flatMap((e) => {
544
+ const u = await he(
545
+ n.flatMap((e) => {
519
546
  if (e.type === "record_fields") {
520
- const t = Q(e);
547
+ const t = H(e);
521
548
  return [
522
549
  async () => {
523
- const n = m[t] ?? {}, f = N.current[t] ?? {}, w = {}, b = [];
524
- for (const o of e.fields) {
525
- if (te(o)) {
526
- const a = Array.isArray(n[o.field]) ? n[o.field] : [], C = Array.isArray(f[o.field]) ? f[o.field] : [], E = a.filter((F) => !C.includes(F)), S = C.filter((F) => !a.includes(F));
527
- (E.length > 0 || S.length > 0) && b.push({ meta: o, add: E, remove: S });
550
+ const r = h[t] ?? {}, f = q.current[t] ?? {}, N = {}, g = [];
551
+ for (const d of e.fields) {
552
+ if (re(d)) {
553
+ const o = Array.isArray(r[d.field]) ? r[d.field] : [], C = Array.isArray(f[d.field]) ? f[d.field] : [], E = o.filter((D) => !C.includes(D)), A = C.filter((D) => !o.includes(D));
554
+ (E.length > 0 || A.length > 0) && g.push({ meta: d, add: E, remove: A });
528
555
  continue;
529
556
  }
530
- n[o.field] !== f[o.field] && (w[o.field] = o.kind === "m2o" || o.kind === "file" ? String(n[o.field] ?? "") || null : G(String(n[o.field] ?? ""), o.type));
557
+ r[d.field] !== f[d.field] && (N[d.field] = d.kind === "m2o" || d.kind === "file" ? String(r[d.field] ?? "") || null : X(String(r[d.field] ?? ""), d.type));
531
558
  }
532
- if (Object.keys(w).length === 0 && b.length === 0)
559
+ if (Object.keys(N).length === 0 && g.length === 0)
533
560
  return { rk: t, ok: !0 };
534
561
  try {
535
- Object.keys(w).length > 0 && await p.request(
536
- U(ce(`/items/${e.collection}/${e.item}`, w))
562
+ Object.keys(N).length > 0 && await m.request(
563
+ P(ue(`/items/${e.collection}/${e.item}`, N))
537
564
  );
538
- for (const { meta: o, add: a, remove: C } of b)
539
- if (!(!o.junction || !o.fk_to_child || !o.junction_field)) {
565
+ for (const { meta: d, add: o, remove: C } of g)
566
+ if (!(!d.junction || !d.fk_to_child || !d.junction_field)) {
540
567
  if (C.length > 0) {
541
- const E = await p.request(
542
- z(`/items/${o.junction}`, {
568
+ const E = await m.request(
569
+ Q(`/items/${d.junction}`, {
543
570
  limit: 500,
544
- filter: JSON.stringify({ [o.fk_to_child]: { _eq: e.item } })
571
+ filter: JSON.stringify({ [d.fk_to_child]: { _eq: e.item } })
545
572
  })
546
573
  );
547
- for (const S of E.data ?? [])
548
- C.includes(String(S[o.junction_field])) && await p.request(de(`/items/${o.junction}/${S.id}`));
574
+ for (const A of E.data ?? [])
575
+ C.includes(String(A[d.junction_field])) && await m.request(fe(`/items/${d.junction}/${A.id}`));
549
576
  }
550
- for (const E of a)
551
- await p.request(
552
- ue(`/items/${o.junction}`, {
553
- [o.fk_to_child]: e.item,
554
- [o.junction_field]: E
577
+ for (const E of o)
578
+ await m.request(
579
+ me(`/items/${d.junction}`, {
580
+ [d.fk_to_child]: e.item,
581
+ [d.junction_field]: E
555
582
  })
556
583
  );
557
584
  }
558
- return h.invalidateQueries({
585
+ return p.invalidateQueries({
559
586
  queryKey: ["item", e.collection, String(e.item)]
560
- }), { rk: t, ok: !0, saved: { ...f, ...n } };
561
- } catch (o) {
562
- const a = o == null ? void 0 : o.response;
563
- return { rk: t, ok: !1, error: (a == null ? void 0 : a.error) ?? "Failed to save" };
587
+ }), { rk: t, ok: !0, saved: { ...f, ...r } };
588
+ } catch (d) {
589
+ const o = d == null ? void 0 : d.response;
590
+ return { rk: t, ok: !1, error: (o == null ? void 0 : o.error) ?? "Failed to save" };
564
591
  }
565
592
  }
566
593
  ];
567
594
  }
568
595
  return e.rows.map((t) => async () => {
569
- const n = R(e.collection, t.id), f = m[n] ?? {}, w = N.current[n] ?? {}, b = {}, o = [];
570
- for (const a of e.fields) {
571
- if (a.kind === "m2m") {
572
- const C = Array.isArray(f[a.field]) ? f[a.field] : [], E = Array.isArray(w[a.field]) ? w[a.field] : [], S = C.filter((X) => !E.includes(X)), F = E.filter((X) => !C.includes(X));
573
- (S.length > 0 || F.length > 0) && o.push({ meta: a, add: S, remove: F });
596
+ const r = R(e.collection, t.id), f = h[r] ?? {}, N = q.current[r] ?? {}, g = {}, d = [];
597
+ for (const o of e.fields) {
598
+ if (o.kind === "m2m") {
599
+ const C = Array.isArray(f[o.field]) ? f[o.field] : [], E = Array.isArray(N[o.field]) ? N[o.field] : [], A = C.filter((Z) => !E.includes(Z)), D = E.filter((Z) => !C.includes(Z));
600
+ (A.length > 0 || D.length > 0) && d.push({ meta: o, add: A, remove: D });
574
601
  continue;
575
602
  }
576
- V(n, a) || f[a.field] !== w[a.field] && (b[a.field] = a.kind === "m2o" ? String(f[a.field] ?? "") || null : G(String(f[a.field] ?? ""), a.type));
603
+ U(r, o) || f[o.field] !== N[o.field] && (g[o.field] = o.kind === "m2o" ? String(f[o.field] ?? "") || null : X(String(f[o.field] ?? ""), o.type));
577
604
  }
578
- if (Object.keys(b).length === 0 && o.length === 0)
579
- return { rk: n, ok: !0 };
580
- if (Object.keys(b).length > 0)
581
- for (const [a, C] of Object.entries(Y.current[n] ?? {}))
582
- a in b || (b[a] = C);
605
+ if (Object.keys(g).length === 0 && d.length === 0)
606
+ return { rk: r, ok: !0 };
607
+ if (Object.keys(g).length > 0)
608
+ for (const [o, C] of Object.entries(Y.current[r] ?? {}))
609
+ o in g || (g[o] = C);
583
610
  try {
584
- Object.keys(b).length > 0 && await p.request(U(ce(`/items/${e.collection}/${t.id}`, b)));
585
- for (const { meta: a, add: C, remove: E } of o)
586
- if (!(!a.junction || !a.fk_to_child || !a.junction_field)) {
611
+ Object.keys(g).length > 0 && await m.request(P(ue(`/items/${e.collection}/${t.id}`, g)));
612
+ for (const { meta: o, add: C, remove: E } of d)
613
+ if (!(!o.junction || !o.fk_to_child || !o.junction_field)) {
587
614
  if (E.length > 0) {
588
- const S = await p.request(
589
- z(`/items/${a.junction}`, {
615
+ const A = await m.request(
616
+ Q(`/items/${o.junction}`, {
590
617
  limit: 500,
591
- filter: JSON.stringify({ [a.fk_to_child]: { _eq: t.id } })
618
+ filter: JSON.stringify({ [o.fk_to_child]: { _eq: t.id } })
592
619
  })
593
620
  );
594
- for (const F of S.data ?? [])
595
- E.includes(String(F[a.junction_field])) && await p.request(de(`/items/${a.junction}/${F.id}`));
621
+ for (const D of A.data ?? [])
622
+ E.includes(String(D[o.junction_field])) && await m.request(fe(`/items/${o.junction}/${D.id}`));
596
623
  }
597
- for (const S of C)
598
- await p.request(
599
- ue(`/items/${a.junction}`, {
600
- [a.fk_to_child]: t.id,
601
- [a.junction_field]: S
624
+ for (const A of C)
625
+ await m.request(
626
+ me(`/items/${o.junction}`, {
627
+ [o.fk_to_child]: t.id,
628
+ [o.junction_field]: A
602
629
  })
603
630
  );
604
631
  }
605
- return h.invalidateQueries({ queryKey: ["item", e.collection, String(t.id)] }), { rk: n, ok: !0, saved: { ...w, ...f } };
606
- } catch (a) {
607
- const C = a == null ? void 0 : a.response;
608
- return { rk: n, ok: !1, error: (C == null ? void 0 : C.error) ?? "Failed to save" };
632
+ return p.invalidateQueries({ queryKey: ["item", e.collection, String(t.id)] }), { rk: r, ok: !0, saved: { ...N, ...f } };
633
+ } catch (o) {
634
+ const C = o == null ? void 0 : o.response;
635
+ return { rk: r, ok: !1, error: (C == null ? void 0 : C.error) ?? "Failed to save" };
609
636
  }
610
637
  });
611
638
  })
612
- ), x = u.filter((e) => !e.ok);
639
+ ), v = u.filter((e) => !e.ok);
613
640
  for (const e of u)
614
- e.ok && e.saved && (N.current[e.rk] = e.saved);
615
- if (x.length > 0) {
616
- _(!1), A(Object.fromEntries(x.map((e) => [e.rk, e.ok ? "" : e.error])));
641
+ e.ok && e.saved && (q.current[e.rk] = e.saved);
642
+ if (v.length > 0) {
643
+ x(!1), _(Object.fromEntries(v.map((e) => [e.rk, e.ok ? "" : e.error])));
617
644
  return;
618
645
  }
619
- A({}), T("transition");
646
+ _({}), O("transition");
620
647
  try {
621
- await y();
648
+ await b();
622
649
  } catch {
623
650
  } finally {
624
- _(!1), T("save");
651
+ x(!1), O("save");
625
652
  }
626
- }, je = r.length === 1 && r[0].title ? r[0].title : "Required before continuing";
627
- return /* @__PURE__ */ l(Te, { open: !0, onOpenChange: (i) => !i && !$ && !d && k(), children: /* @__PURE__ */ g(
628
- Ue,
653
+ }, qe = n.length === 1 && n[0].title ? n[0].title : "Required before continuing";
654
+ return /* @__PURE__ */ s(Ue, { open: !0, onOpenChange: (l) => !l && !w && !c && y(), children: /* @__PURE__ */ k(
655
+ Ve,
629
656
  {
630
- className: P(
657
+ className: K(
631
658
  "max-w-2xl",
632
- r.some(
633
- (i) => i.type === "child_fields" && (i.display_fields ?? []).length + i.fields.length > 3
659
+ n.some(
660
+ (l) => l.type === "child_fields" && (l.display_fields ?? []).length + l.fields.length > 3
634
661
  ) && "max-w-5xl"
635
662
  ),
636
663
  style: (() => {
637
664
  var u;
638
- const i = (u = r.find(
639
- (x) => x.type === "child_fields" && !!x.width
665
+ const l = (u = n.find(
666
+ (v) => v.type === "child_fields" && !!v.width
640
667
  )) == null ? void 0 : u.width;
641
- return i ? { width: i, maxWidth: i } : void 0;
668
+ return l ? { width: l, maxWidth: l } : void 0;
642
669
  })(),
643
670
  children: [
644
- /* @__PURE__ */ l(Ve, { children: /* @__PURE__ */ l(Me, { className: "text-[15px]", children: je }) }),
645
- /* @__PURE__ */ g(
671
+ /* @__PURE__ */ s(Ie, { children: /* @__PURE__ */ s(Me, { className: "text-[15px]", children: qe }) }),
672
+ /* @__PURE__ */ k(
646
673
  Be,
647
674
  {
648
- className: P(
675
+ className: K(
649
676
  "max-h-[60vh] space-y-5 overflow-y-auto",
650
- ($ || d) && "pointer-events-none opacity-60 transition-opacity"
677
+ (w || c) && "pointer-events-none opacity-60 transition-opacity"
651
678
  ),
652
679
  children: [
653
- c && /* @__PURE__ */ g("p", { className: "flex items-center gap-2 rounded-md border border-amber-200 bg-amber-50 px-3 py-2 text-[12px] text-amber-700 dark:border-amber-500/20 dark:bg-amber-500/10 dark:text-amber-400", children: [
654
- /* @__PURE__ */ l("span", { className: "h-1.5 w-1.5 shrink-0 rounded-full bg-amber-400" }),
680
+ a && /* @__PURE__ */ k("p", { className: "flex items-center gap-2 rounded-md border border-amber-200 bg-amber-50 px-3 py-2 text-[12px] text-amber-700 dark:border-amber-500/20 dark:bg-amber-500/10 dark:text-amber-400", children: [
681
+ /* @__PURE__ */ s("span", { className: "h-1.5 w-1.5 shrink-0 rounded-full bg-amber-400" }),
655
682
  "Values changed since your last attempt — review the highlighted rows."
656
683
  ] }),
657
- D && /* @__PURE__ */ g(
684
+ T && /* @__PURE__ */ k(
658
685
  "div",
659
686
  {
660
687
  "data-req-side-effects": !0,
661
688
  className: "rounded-md border border-amber-200 bg-amber-50 px-3 py-2.5 text-[12px] text-amber-800 dark:border-amber-500/20 dark:bg-amber-500/10 dark:text-amber-300",
662
689
  children: [
663
- /* @__PURE__ */ g("p", { className: "flex items-center gap-2 font-medium", children: [
664
- /* @__PURE__ */ l(B, { className: "h-3.5 w-3.5 shrink-0" }),
690
+ /* @__PURE__ */ k("p", { className: "flex items-center gap-2 font-medium", children: [
691
+ /* @__PURE__ */ s(I, { className: "h-3.5 w-3.5 shrink-0" }),
665
692
  "Your choices also change values these lines already have"
666
693
  ] }),
667
- /* @__PURE__ */ l("ul", { className: "mt-1.5 space-y-0.5 pl-5", children: D.flatMap(
668
- (i) => i.changes.map((u) => /* @__PURE__ */ g("li", { children: [
669
- i.rowLabel,
694
+ /* @__PURE__ */ s("ul", { className: "mt-1.5 space-y-0.5 pl-5", children: T.flatMap(
695
+ (l) => l.changes.map((u) => /* @__PURE__ */ k("li", { children: [
696
+ l.rowLabel,
670
697
  " · ",
671
698
  u.label,
672
699
  ": ",
673
- I(u.from, u.format) || "—",
700
+ M(u.from, u.format) || "—",
674
701
  " →",
675
702
  " ",
676
- /* @__PURE__ */ l("span", { className: "font-medium", children: I(u.to, u.format) || "—" })
677
- ] }, `${i.rk}:${u.field}`))
703
+ /* @__PURE__ */ s("span", { className: "font-medium", children: M(u.to, u.format) || "—" })
704
+ ] }, `${l.rk}:${u.field}`))
678
705
  ) }),
679
- /* @__PURE__ */ l("p", { className: "mt-1.5 text-[11.5px] text-amber-700/90 dark:text-amber-300/80", children: "Keep the current values, or apply every change." })
706
+ /* @__PURE__ */ s("p", { className: "mt-1.5 text-[11.5px] text-amber-700/90 dark:text-amber-300/80", children: "Keep the current values, or apply every change." })
680
707
  ]
681
708
  }
682
709
  ),
683
- ie && !c && /* @__PURE__ */ g("p", { className: "flex items-center gap-2 rounded-md border border-red-200 bg-red-50 px-3 py-2 text-[12px] text-red-700 dark:border-red-500/20 dark:bg-red-500/10 dark:text-red-400", children: [
684
- /* @__PURE__ */ l(B, { className: "h-3.5 w-3.5 shrink-0" }),
685
- ie
710
+ se && !a && /* @__PURE__ */ k("p", { className: "flex items-center gap-2 rounded-md border border-red-200 bg-red-50 px-3 py-2 text-[12px] text-red-700 dark:border-red-500/20 dark:bg-red-500/10 dark:text-red-400", children: [
711
+ /* @__PURE__ */ s(I, { className: "h-3.5 w-3.5 shrink-0" }),
712
+ se
686
713
  ] }),
687
- r.map((i) => {
688
- if (i.type === "record_fields") {
689
- const e = Q(i);
690
- return /* @__PURE__ */ g("div", { className: "space-y-2", children: [
691
- r.length > 1 && /* @__PURE__ */ l("h4", { className: "text-[12px] font-semibold text-slate-500", children: i.title }),
692
- /* @__PURE__ */ l("div", { className: "grid grid-cols-1 gap-3 rounded-md border border-slate-200 p-3 sm:grid-cols-2 dark:border-border", children: i.fields.map((t) => {
693
- var f, w;
694
- const n = (f = m[e]) == null ? void 0 : f[t.field];
695
- return /* @__PURE__ */ g("div", { className: "space-y-1", children: [
696
- /* @__PURE__ */ l("label", { className: "text-[11px] font-medium text-slate-500", children: t.label }),
697
- t.kind === "m2o" ? /* @__PURE__ */ l(
698
- be,
714
+ n.map((l) => {
715
+ if (l.type === "record_fields") {
716
+ const e = H(l);
717
+ return /* @__PURE__ */ k("div", { className: "space-y-2", children: [
718
+ n.length > 1 && /* @__PURE__ */ s("h4", { className: "text-[12px] font-semibold text-slate-500", children: l.title }),
719
+ /* @__PURE__ */ s("div", { className: "grid grid-cols-1 gap-3 rounded-md border border-slate-200 p-3 sm:grid-cols-2 dark:border-border", children: l.fields.map((t) => {
720
+ var f, N;
721
+ const r = (f = h[e]) == null ? void 0 : f[t.field];
722
+ return /* @__PURE__ */ k("div", { className: "space-y-1", children: [
723
+ /* @__PURE__ */ s("label", { className: "text-[11px] font-medium text-slate-500", children: t.label }),
724
+ t.kind === "m2o" ? /* @__PURE__ */ s(
725
+ xe,
699
726
  {
700
727
  meta: t,
701
- selected: typeof n == "string" ? n : "",
702
- onChange: (b) => L(e, t.field, b)
728
+ selected: typeof r == "string" ? r : "",
729
+ onChange: (g) => F(e, t.field, g)
703
730
  }
704
- ) : t.kind === "m2m" ? /* @__PURE__ */ l(
705
- he,
731
+ ) : t.kind === "m2m" ? /* @__PURE__ */ s(
732
+ ge,
706
733
  {
707
734
  meta: t,
708
- selected: Array.isArray(n) ? n : [],
709
- onChange: (b) => L(e, t.field, b)
735
+ selected: Array.isArray(r) ? r : [],
736
+ onChange: (g) => F(e, t.field, g)
710
737
  }
711
- ) : t.kind === "file" || t.kind === "files" ? /* @__PURE__ */ l(
712
- Ye,
738
+ ) : t.kind === "file" || t.kind === "files" ? /* @__PURE__ */ s(
739
+ Xe,
713
740
  {
714
741
  multiple: t.kind === "files",
715
- ids: Array.isArray(n) ? n : typeof n == "string" && n ? [n] : [],
716
- initialNames: We(i.display[t.field]),
717
- onChange: (b) => L(
742
+ ids: Array.isArray(r) ? r : typeof r == "string" && r ? [r] : [],
743
+ initialNames: Ze(l.display[t.field]),
744
+ onChange: (g) => F(
718
745
  e,
719
746
  t.field,
720
- t.kind === "files" ? b : b[0] ?? ""
747
+ t.kind === "files" ? g : g[0] ?? ""
721
748
  )
722
749
  }
723
- ) : (w = i.copy_to_lines) != null && w[t.field] ? /* @__PURE__ */ g("div", { className: "flex items-center gap-1.5", children: [
724
- /* @__PURE__ */ l(
725
- M,
750
+ ) : (N = l.copy_to_lines) != null && N[t.field] ? /* @__PURE__ */ k("div", { className: "flex items-center gap-1.5", children: [
751
+ /* @__PURE__ */ s(
752
+ V,
726
753
  {
727
- value: typeof n == "string" ? n : "",
728
- onChange: (b) => L(e, t.field, b.target.value),
754
+ value: typeof r == "string" ? r : "",
755
+ onChange: (g) => F(e, t.field, g.target.value),
729
756
  placeholder: t.label,
730
757
  className: "h-8 w-full text-[12px]"
731
758
  }
732
759
  ),
733
- /* @__PURE__ */ l(
760
+ /* @__PURE__ */ s(
734
761
  "button",
735
762
  {
736
763
  type: "button",
737
- disabled: !(typeof n == "string" && n.trim()),
764
+ disabled: !(typeof r == "string" && r.trim()),
738
765
  onClick: () => {
739
- var b;
740
- return re(
741
- typeof n == "string" ? n : "",
742
- (b = i.copy_to_lines) == null ? void 0 : b[t.field]
766
+ var g;
767
+ return le(
768
+ typeof r == "string" ? r : "",
769
+ (g = l.copy_to_lines) == null ? void 0 : g[t.field]
743
770
  );
744
771
  },
745
772
  title: "Copy this value to every available line",
@@ -747,53 +774,53 @@ function ft({
747
774
  children: "Apply to lines ↓"
748
775
  }
749
776
  )
750
- ] }) : /* @__PURE__ */ l(
751
- M,
777
+ ] }) : /* @__PURE__ */ s(
778
+ V,
752
779
  {
753
- value: typeof n == "string" ? n : "",
754
- onChange: (b) => L(e, t.field, b.target.value),
780
+ value: typeof r == "string" ? r : "",
781
+ onChange: (g) => F(e, t.field, g.target.value),
755
782
  placeholder: t.label,
756
783
  className: "h-8 w-full text-[12px]"
757
784
  }
758
785
  )
759
786
  ] }, t.field);
760
787
  }) }),
761
- v[e] && /* @__PURE__ */ g("p", { className: "flex items-center gap-1 text-[11px] text-red-600", children: [
762
- /* @__PURE__ */ l(B, { className: "h-3 w-3 shrink-0" }),
763
- v[e]
788
+ $[e] && /* @__PURE__ */ k("p", { className: "flex items-center gap-1 text-[11px] text-red-600", children: [
789
+ /* @__PURE__ */ s(I, { className: "h-3 w-3 shrink-0" }),
790
+ $[e]
764
791
  ] })
765
792
  ] }, e);
766
793
  }
767
- const u = i.display_fields ?? [], x = 1 + u.length + i.fields.length;
768
- return /* @__PURE__ */ g(
794
+ const u = l.display_fields ?? [], v = 1 + u.length + l.fields.length;
795
+ return /* @__PURE__ */ k(
769
796
  "div",
770
797
  {
771
798
  className: "space-y-2",
772
799
  children: [
773
- r.length > 1 && /* @__PURE__ */ l("h4", { className: "text-[12px] font-semibold text-slate-500", children: i.title }),
774
- (i.apply_all ?? []).map((e) => i.fields.find((t) => t.field === e)).filter((e) => !!e && e.kind !== "m2m").map((e) => {
775
- const t = `__bulk__:${i.collection}:${e.field}`, n = Ne[t] ?? "";
776
- return /* @__PURE__ */ g(
800
+ n.length > 1 && /* @__PURE__ */ s("h4", { className: "text-[12px] font-semibold text-slate-500", children: l.title }),
801
+ (l.apply_all ?? []).map((e) => l.fields.find((t) => t.field === e)).filter((e) => !!e && e.kind !== "m2m").map((e) => {
802
+ const t = `__bulk__:${l.collection}:${e.field}`, r = Se[t] ?? "";
803
+ return /* @__PURE__ */ k(
777
804
  "div",
778
805
  {
779
806
  className: "flex items-center gap-2 rounded-md border border-slate-200 bg-slate-50/60 px-3 py-2 dark:border-border dark:bg-white/[0.03]",
780
807
  children: [
781
- /* @__PURE__ */ l("label", { className: "shrink-0 text-[11px] font-medium text-slate-500", children: e.label }),
782
- /* @__PURE__ */ l(
783
- M,
808
+ /* @__PURE__ */ s("label", { className: "shrink-0 text-[11px] font-medium text-slate-500", children: e.label }),
809
+ /* @__PURE__ */ s(
810
+ V,
784
811
  {
785
- value: n,
786
- onChange: (f) => _e((w) => ({ ...w, [t]: f.target.value })),
812
+ value: r,
813
+ onChange: (f) => Ce((N) => ({ ...N, [t]: f.target.value })),
787
814
  placeholder: `${e.label} for every line…`,
788
815
  className: "h-8 w-full max-w-xs text-[12px]"
789
816
  }
790
817
  ),
791
- /* @__PURE__ */ l(
818
+ /* @__PURE__ */ s(
792
819
  "button",
793
820
  {
794
821
  type: "button",
795
- disabled: !n.trim(),
796
- onClick: () => re(n, e.field),
822
+ disabled: !r.trim(),
823
+ onClick: () => le(r, e.field),
797
824
  className: "h-8 shrink-0 whitespace-nowrap rounded-md bg-nvr-cyan px-3 text-[11px] font-medium text-white transition-colors hover:opacity-90 disabled:opacity-40",
798
825
  children: "Apply to all lines"
799
826
  }
@@ -803,34 +830,34 @@ function ft({
803
830
  t
804
831
  );
805
832
  }),
806
- /* @__PURE__ */ l("div", { className: "overflow-x-auto rounded-md border border-slate-200 dark:border-border", children: /* @__PURE__ */ g("table", { className: "w-full border-collapse text-[12px]", children: [
807
- /* @__PURE__ */ l("thead", { children: /* @__PURE__ */ g("tr", { className: "border-b border-slate-200 bg-slate-50/60 text-left text-[11px] font-medium text-slate-400 dark:border-border dark:bg-white/[0.02]", children: [
808
- /* @__PURE__ */ l("th", { className: "px-2.5 py-1.5 font-medium", children: "Row" }),
809
- u.map((e) => /* @__PURE__ */ l("th", { className: "px-2.5 py-1.5 font-medium", children: e.label }, e.field)),
810
- i.fields.map((e) => /* @__PURE__ */ l("th", { className: "w-40 px-2.5 py-1.5 font-medium", children: /* @__PURE__ */ g("span", { className: "flex items-center gap-1.5", children: [
811
- e.label,
812
- i.rows.length > 1 && /* @__PURE__ */ l(
833
+ /* @__PURE__ */ s("div", { className: "overflow-x-auto rounded-md border border-slate-200 dark:border-border", children: /* @__PURE__ */ k("table", { className: "w-full border-collapse text-[12px]", children: [
834
+ /* @__PURE__ */ s("thead", { children: /* @__PURE__ */ k("tr", { className: "border-b border-slate-200 bg-slate-50/60 text-left text-[11px] font-medium text-slate-400 dark:border-border dark:bg-white/[0.02]", children: [
835
+ /* @__PURE__ */ s("th", { className: "px-2.5 py-1.5 font-medium", children: "Row" }),
836
+ u.map((e) => /* @__PURE__ */ s("th", { className: "px-2.5 py-1.5 font-medium", children: G(e) }, e.field)),
837
+ l.fields.map((e) => /* @__PURE__ */ s("th", { className: "w-40 px-2.5 py-1.5 font-medium", children: /* @__PURE__ */ k("span", { className: "flex items-center gap-1.5", children: [
838
+ G(e),
839
+ l.rows.length > 1 && /* @__PURE__ */ s(
813
840
  "button",
814
841
  {
815
842
  type: "button",
816
- onClick: () => J(i, e),
843
+ onClick: () => J(l, e),
817
844
  title: `Apply the first ${e.label} to all lines`,
818
845
  className: "rounded p-0.5 text-slate-300 transition-colors hover:bg-slate-100 hover:text-slate-600 dark:hover:bg-muted/50",
819
- children: /* @__PURE__ */ l(qe, { className: "h-3 w-3" })
846
+ children: /* @__PURE__ */ s(Fe, { className: "h-3 w-3" })
820
847
  }
821
848
  )
822
849
  ] }) }, e.field))
823
850
  ] }) }),
824
- /* @__PURE__ */ l("tbody", { children: i.rows.map((e) => {
825
- const t = R(i.collection, e.id);
826
- return /* @__PURE__ */ g(Le, { children: [
827
- /* @__PURE__ */ g("tr", { className: "border-b border-slate-100 last:border-b-0 dark:border-border/50", children: [
828
- /* @__PURE__ */ l("td", { className: "max-w-[220px] px-2.5 py-1.5", children: /* @__PURE__ */ g("span", { className: "flex items-center gap-1.5", children: [
829
- !e.complete && /* @__PURE__ */ l("span", { className: "h-1.5 w-1.5 shrink-0 rounded-full bg-amber-400 animate-pulse" }),
830
- /* @__PURE__ */ l(
851
+ /* @__PURE__ */ s("tbody", { children: l.rows.map((e) => {
852
+ const t = R(l.collection, e.id);
853
+ return /* @__PURE__ */ k(De, { children: [
854
+ /* @__PURE__ */ k("tr", { className: "border-b border-slate-100 last:border-b-0 dark:border-border/50", children: [
855
+ /* @__PURE__ */ s("td", { className: "max-w-[220px] px-2.5 py-1.5", children: /* @__PURE__ */ k("span", { className: "flex items-center gap-1.5", children: [
856
+ !e.complete && /* @__PURE__ */ s("span", { className: "h-1.5 w-1.5 shrink-0 rounded-full bg-amber-400 animate-pulse" }),
857
+ /* @__PURE__ */ s(
831
858
  "span",
832
859
  {
833
- className: P(
860
+ className: K(
834
861
  "truncate",
835
862
  e.complete ? "text-slate-400" : "font-medium text-slate-700"
836
863
  ),
@@ -839,110 +866,110 @@ function ft({
839
866
  }
840
867
  )
841
868
  ] }) }),
842
- u.map((n) => {
843
- var f, w;
844
- return /* @__PURE__ */ l(
869
+ u.map((r) => {
870
+ var f, N;
871
+ return /* @__PURE__ */ s(
845
872
  "td",
846
873
  {
847
- className: P(
874
+ className: K(
848
875
  "max-w-[200px] truncate px-2.5 py-1.5 text-slate-500",
849
- n.format && "text-right tabular-nums"
876
+ r.format && "text-right tabular-nums"
850
877
  ),
851
- title: I((f = e.display) == null ? void 0 : f[n.field], n.format),
852
- children: I((w = e.display) == null ? void 0 : w[n.field], n.format) || "—"
878
+ title: M((f = e.display) == null ? void 0 : f[r.field], r.format),
879
+ children: M((N = e.display) == null ? void 0 : N[r.field], r.format) || "—"
853
880
  },
854
- n.field
881
+ r.field
855
882
  );
856
883
  }),
857
- i.fields.map((n) => {
858
- var f, w, b, o, a, C, E;
859
- return /* @__PURE__ */ l("td", { className: "px-2 py-1", children: n.kind === "m2m" ? /* @__PURE__ */ l(
860
- he,
884
+ l.fields.map((r) => {
885
+ var f, N, g, d, o, C, E;
886
+ return /* @__PURE__ */ s("td", { className: "px-2 py-1", children: r.kind === "m2m" ? /* @__PURE__ */ s(
887
+ ge,
861
888
  {
862
- meta: n,
863
- selected: Array.isArray((f = m[t]) == null ? void 0 : f[n.field]) ? (w = m[t]) == null ? void 0 : w[n.field] : [],
864
- onChange: (S) => L(t, n.field, S),
865
- rowValues: { ...e.cascade_values, ...m[t] }
889
+ meta: r,
890
+ selected: Array.isArray((f = h[t]) == null ? void 0 : f[r.field]) ? (N = h[t]) == null ? void 0 : N[r.field] : [],
891
+ onChange: (A) => F(t, r.field, A),
892
+ rowValues: { ...e.cascade_values, ...h[t] }
866
893
  }
867
- ) : V(t, n) ? /* @__PURE__ */ l(
868
- M,
894
+ ) : U(t, r) ? /* @__PURE__ */ s(
895
+ V,
869
896
  {
870
897
  value: "",
871
898
  disabled: !0,
872
899
  readOnly: !0,
873
- placeholder: ((b = n.optional_when) == null ? void 0 : b.placeholder) ?? "Auto-assigned",
900
+ placeholder: ((g = r.optional_when) == null ? void 0 : g.placeholder) ?? "Auto-assigned",
874
901
  title: "Assigned automatically after submission",
875
902
  className: "h-8 w-full min-w-[9rem] bg-slate-50 text-[12px] italic dark:bg-muted/50"
876
903
  }
877
- ) : n.kind === "m2o" ? /* @__PURE__ */ l(
878
- be,
904
+ ) : r.kind === "m2o" ? /* @__PURE__ */ s(
905
+ xe,
879
906
  {
880
- meta: n,
881
- selected: typeof ((o = m[t]) == null ? void 0 : o[n.field]) == "string" ? (a = m[t]) == null ? void 0 : a[n.field] : "",
882
- onChange: (S) => L(t, n.field, S),
883
- rowValues: { ...e.cascade_values, ...m[t] }
907
+ meta: r,
908
+ selected: typeof ((d = h[t]) == null ? void 0 : d[r.field]) == "string" ? (o = h[t]) == null ? void 0 : o[r.field] : "",
909
+ onChange: (A) => F(t, r.field, A),
910
+ rowValues: { ...e.cascade_values, ...h[t] }
884
911
  }
885
- ) : /* @__PURE__ */ l(
886
- M,
912
+ ) : /* @__PURE__ */ s(
913
+ V,
887
914
  {
888
- value: typeof ((C = m[t]) == null ? void 0 : C[n.field]) == "string" ? (E = m[t]) == null ? void 0 : E[n.field] : "",
889
- onChange: (S) => L(t, n.field, S.target.value),
890
- placeholder: n.label,
915
+ value: typeof ((C = h[t]) == null ? void 0 : C[r.field]) == "string" ? (E = h[t]) == null ? void 0 : E[r.field] : "",
916
+ onChange: (A) => F(t, r.field, A.target.value),
917
+ placeholder: r.label,
891
918
  className: "h-8 w-full min-w-[9rem] text-[12px]"
892
919
  }
893
- ) }, n.field);
920
+ ) }, r.field);
894
921
  })
895
922
  ] }),
896
- v[t] && /* @__PURE__ */ l("tr", { children: /* @__PURE__ */ l("td", { colSpan: x, className: "px-2.5 pb-1.5", children: /* @__PURE__ */ g("p", { className: "flex items-center gap-1 text-[11px] text-red-600", children: [
897
- /* @__PURE__ */ l(B, { className: "h-3 w-3 shrink-0" }),
898
- v[t]
923
+ $[t] && /* @__PURE__ */ s("tr", { children: /* @__PURE__ */ s("td", { colSpan: v, className: "px-2.5 pb-1.5", children: /* @__PURE__ */ k("p", { className: "flex items-center gap-1 text-[11px] text-red-600", children: [
924
+ /* @__PURE__ */ s(I, { className: "h-3 w-3 shrink-0" }),
925
+ $[t]
899
926
  ] }) }) })
900
927
  ] }, t);
901
928
  }) })
902
929
  ] }) })
903
930
  ]
904
931
  },
905
- `${i.collection}-${i.fk_field}-${i.title}`
932
+ `${l.collection}-${l.fk_field}-${l.title}`
906
933
  );
907
934
  })
908
935
  ]
909
936
  }
910
937
  ),
911
- /* @__PURE__ */ g(Ie, { className: "items-center", children: [
912
- ($ || d) && /* @__PURE__ */ g("span", { className: "mr-auto flex items-center gap-2 text-[12px] text-slate-500 dark:text-slate-400", children: [
913
- /* @__PURE__ */ l(Z, { className: "h-3.5 w-3.5 animate-spin text-nvr-cyan" }),
914
- $ ? "Saving line values…" : "Submitting — contacting external systems, this can take a few seconds…"
938
+ /* @__PURE__ */ k(He, { className: "items-center", children: [
939
+ (w || c) && /* @__PURE__ */ k("span", { className: "mr-auto flex items-center gap-2 text-[12px] text-slate-500 dark:text-slate-400", children: [
940
+ /* @__PURE__ */ s(ee, { className: "h-3.5 w-3.5 animate-spin text-nvr-cyan" }),
941
+ w ? "Saving line values…" : "Submitting — contacting external systems, this can take a few seconds…"
915
942
  ] }),
916
- /* @__PURE__ */ l(
917
- H,
943
+ /* @__PURE__ */ s(
944
+ B,
918
945
  {
919
946
  type: "button",
920
947
  variant: "outline",
921
- onClick: D ? () => W(null) : k,
922
- disabled: $ || d,
923
- children: D ? "Back" : "Cancel"
948
+ onClick: T ? () => W(null) : y,
949
+ disabled: w || c,
950
+ children: T ? "Back" : "Cancel"
924
951
  }
925
952
  ),
926
- D && /* @__PURE__ */ l(
927
- H,
953
+ T && /* @__PURE__ */ s(
954
+ B,
928
955
  {
929
956
  type: "button",
930
957
  variant: "outline",
931
- onClick: () => void le("keep"),
932
- disabled: $ || d,
958
+ onClick: () => void ae("keep"),
959
+ disabled: w || c,
933
960
  children: "Keep current values"
934
961
  }
935
962
  ),
936
- /* @__PURE__ */ l(
937
- H,
963
+ /* @__PURE__ */ s(
964
+ B,
938
965
  {
939
966
  type: "button",
940
- onClick: () => void le(D ? "apply" : void 0),
941
- disabled: $ || d || Se,
942
- children: $ || d ? /* @__PURE__ */ g("span", { className: "flex items-center gap-1.5", children: [
943
- /* @__PURE__ */ l(Z, { className: "h-3.5 w-3.5 animate-spin" }),
944
- $ && O === "save" ? "Saving…" : "Submitting…"
945
- ] }) : D ? "Apply all changes" : "Submit"
967
+ onClick: () => void ae(T ? "apply" : void 0),
968
+ disabled: w || c || $e,
969
+ children: w || c ? /* @__PURE__ */ k("span", { className: "flex items-center gap-1.5", children: [
970
+ /* @__PURE__ */ s(ee, { className: "h-3.5 w-3.5 animate-spin" }),
971
+ w && j === "save" ? "Saving…" : "Submitting…"
972
+ ] }) : T ? "Apply all changes" : "Submit"
946
973
  }
947
974
  )
948
975
  ] })
@@ -951,7 +978,10 @@ function ft({
951
978
  ) });
952
979
  }
953
980
  export {
954
- ft as TransitionRequirementsDialog,
955
- Xe as relatedOptionLabel,
956
- ve as requirementOptionFilter
981
+ gt as TransitionRequirementsDialog,
982
+ G as columnLabel,
983
+ Ae as emptyOptionsText,
984
+ M as fmtDisplay,
985
+ Ge as relatedOptionLabel,
986
+ Ne as requirementOptionFilter
957
987
  };