@nivaro/react 0.3.50 → 0.3.51

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