@nivaro/react 0.3.50 → 0.3.52

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 +4801 -4666
  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,83 +1,111 @@
1
1
  import { jsx as a, jsxs as k, Fragment as An } from "react/jsx-runtime";
2
2
  import { useQueryClient as Vo, useQuery as Be, useQueries as on } from "@tanstack/react-query";
3
- import { Loader2 as jn, ListChecks as cl, SquarePen as ul, Rows3 as fl, PanelBottomOpen as ml, Zap as pl, Clock as Ri, History as Qr, AlertTriangle as sr, ChevronRight as Fo, GripVertical as To, FileUp as Ko, X as Mo, GripHorizontal as hl, Lock as gl } from "lucide-react";
4
- import { useState as D, useMemo as L, useEffect as ke, useRef as ue, useCallback as At, Fragment as Pi } from "react";
5
- import { createPortal as bl } from "react-dom";
6
- import { ChangeReasonDialog as yl, changeReasonChallenge as Di } from "./ChangeReasonDialog.js";
3
+ import { Loader2 as jn, ListChecks as cl, SquarePen as ul, Rows3 as fl, PanelBottomOpen as ml, Zap as pl, Clock as Ri, History as Qr, AlertTriangle as sr, ChevronRight as Fo, GripVertical as To, FileUp as Ko, GripHorizontal as hl, X as gl, Lock as bl } from "lucide-react";
4
+ import { useState as W, useMemo as L, useEffect as _e, useRef as ue, useCallback as At, Fragment as Pi } from "react";
5
+ import { createPortal as yl } from "react-dom";
6
+ import { ChangeReasonDialog as xl, changeReasonChallenge as Di } from "./ChangeReasonDialog.js";
7
7
  import { toast as ge } from "sonner";
8
- import { useNivaroClient as Hr, useDrilldown as xl, useParentDraft as vl, useReimportHandler as wl, useItemEditAuth as _l, fieldDrilldownConfig as Ro } from "../../context.js";
8
+ import { useNivaroClient as Hr, useDrilldown as vl, useParentDraft as wl, useReimportHandler as _l, useItemEditAuth as kl, fieldDrilldownConfig as Mo } from "../../context.js";
9
9
  import { get as ie, post as Ae, patch as Vr, del as Ho } from "../../lib/commands.js";
10
- import { useAfterIdle as kl } from "../../lib/defer.js";
11
- import { evaluateNumeric as ft, evaluateBoolean as Nl } from "../../lib/expression.js";
10
+ import { useAfterIdle as Nl } from "../../lib/defer.js";
11
+ import { evaluateNumeric as ft, evaluateBoolean as Sl } from "../../lib/expression.js";
12
12
  import { numericIntlOptions as xt } from "../../lib/format-value.js";
13
- import { useOptionalRealtime as Sl } from "../../lib/realtime.js";
14
- import { useRecordReader as $l } from "../../lib/record-loader.js";
15
- import { midairCollisionOf as ql } from "../../lib/record-outbox.js";
16
- import { restoreSkippedNote as El } from "../../lib/restore-skipped.js";
13
+ import { useOptionalRealtime as $l } from "../../lib/realtime.js";
14
+ import { useRecordReader as ql } from "../../lib/record-loader.js";
15
+ import { midairCollisionOf as El } from "../../lib/record-outbox.js";
16
+ import { restoreSkippedNote as Ol } from "../../lib/restore-skipped.js";
17
17
  import { userErrorMessage as In } from "../../lib/safe-error.js";
18
- import { titleCase as Ne, cn as be, formatRelative as Po, toLocalDateString as Ol } from "../../lib/utils.js";
19
- import { formulaInputsChanged as Al } from "../../lib/write-formula.js";
20
- import { ImportFromFileButton as Il } from "../import/ImportFromFileButton.js";
21
- import { Sheet as jl, SheetContent as Ll, SheetHeader as Tl, SheetTitle as Kl } from "../ui/sheet.js";
22
- import { useAddendumO2M as Ml, useAddendumView as Rl } from "./AddendumFieldContext.js";
23
- import { resolveCompareEndpoint as Pl, useCompareSeries as Dl, compareColumnClosed as Wt, fmtMoney as Wi, CompareProposalBanner as Wl, CompareStripChips as Ul, GridStatChip as Jl, CompareCell as Ui, compareRowFor as Ji, compareColumnSum as Ql, ReconcileAction as zl } from "./CompareSeries.js";
18
+ import { titleCase as Ne, cn as be, formatRelative as Ro, toLocalDateString as Al } from "../../lib/utils.js";
19
+ import { formulaInputsChanged as Il } from "../../lib/write-formula.js";
20
+ import { ImportFromFileButton as jl } from "../import/ImportFromFileButton.js";
21
+ import { Sheet as Ll, SheetContent as Tl, SheetHeader as Kl, SheetTitle as Ml } from "../ui/sheet.js";
22
+ import { useAddendumO2M as Rl, useAddendumView as Pl } from "./AddendumFieldContext.js";
23
+ import { resolveCompareEndpoint as Dl, useCompareSeries as Wl, compareColumnClosed as Wt, fmtMoney as Wi, CompareProposalBanner as Ul, CompareStripChips as Jl, GridStatChip as Ql, CompareCell as Ui, compareRowFor as Ji, compareColumnSum as zl, ReconcileAction as Bl } from "./CompareSeries.js";
24
24
  import { FieldRenderer as On } from "./FieldRenderer.js";
25
- import { GridBulkEditDialog as Bl } from "./GridBulkEditDialog.js";
26
- import { parseJson as Qi, SENTINEL_FIELDS as Yi, applyDisplayTemplate as rr, EMPTY_NESTED_OPS as zr, SYSTEM_FIELDS as Do } from "./helpers.js";
27
- import { rowBaseBookFor as Vl, writeLineGuarded as Fl, lineLabelOf as Hl, lineConflictKey as Yl, resolveLineCollision as Gl, incrementGuarded as Cl } from "./line-midair.js";
28
- import { NUMBER_FIELD_TYPES as Xl, checkNumberEntry as Zl, changedRowFields as Wo, lineRuleErrors as ed } from "./line-qty.js";
29
- import { LineCollisionDialog as td } from "./MidairCollisionDialog.js";
25
+ import { GridBulkEditDialog as Vl } from "./GridBulkEditDialog.js";
26
+ import { parseJson as Qi, SENTINEL_FIELDS as Yi, applyDisplayTemplate as rr, EMPTY_NESTED_OPS as zr, SYSTEM_FIELDS as Po } from "./helpers.js";
27
+ import { rowBaseBookFor as Fl, writeLineGuarded as Hl, lineLabelOf as Yl, lineConflictKey as Gl, resolveLineCollision as Cl, incrementGuarded as Xl } from "./line-midair.js";
28
+ import { NUMBER_FIELD_TYPES as Zl, checkNumberEntry as ed, changedRowFields as Do, lineRuleErrors as td } from "./line-qty.js";
29
+ import { LineCollisionDialog as nd } from "./MidairCollisionDialog.js";
30
30
  import { NestedRelationEditor as zi } from "./NestedRelationEditor.js";
31
- import { useO2MStaging as nd, useLiveRows as rd, useStagedRelations as id } from "./O2MStagingContext.js";
31
+ import { useO2MStaging as rd, useLiveRows as id, useStagedRelations as sd } from "./O2MStagingContext.js";
32
32
  import { RelationCombobox as Bi } from "./RelationCombobox.js";
33
- import { useRowCommentCounts as sd, RowCommentButton as od } from "./RowComments.js";
34
- import { RowHistorySheet as Uo, parseImportStamp as ad } from "./RowHistorySheet.js";
35
- import { useRowMatches as ld, RowMatchDot as Jo, rowFromCandidate as dd, RowMatchPanel as cd } from "./RowMatchPanel.js";
36
- import { RowWatchButton as ud } from "./RowWatchButton.js";
37
- import { RuleProvenanceChip as fd } from "./RuleProvenancePopover.js";
33
+ import { useRowCommentCounts as od, RowCommentButton as ad } from "./RowComments.js";
34
+ import { RowHistorySheet as Wo, parseImportStamp as ld } from "./RowHistorySheet.js";
35
+ import { useRowMatches as dd, RowMatchDot as Uo, rowFromCandidate as cd, RowMatchPanel as ud } from "./RowMatchPanel.js";
36
+ import { RowWatchButton as fd } from "./RowWatchButton.js";
37
+ import { RuleProvenanceChip as md } from "./RuleProvenancePopover.js";
38
38
  import { resolveOptionFilterTokens as Yo } from "../../lib/option-filter-tokens.js";
39
- function Qo(s, f) {
40
- const x = s[f.field], A = x == null || x === "", Q = f.op ?? "eq";
41
- if (Q === "null") return A;
42
- if (Q === "nnull") return !A;
43
- if (A) return !1;
44
- const W = String(typeof x == "object" && x ? x.id ?? "" : x);
45
- if (Q === "in")
46
- return (Array.isArray(f.value) ? f.value : String(f.value ?? "").split(",")).map((J) => String(J).trim()).includes(W);
39
+ function Jo(s, f) {
40
+ const x = s[f.field], E = x == null || x === "", D = f.op ?? "eq";
41
+ if (D === "null") return E;
42
+ if (D === "nnull") return !E;
43
+ if (E) return !1;
44
+ const U = String(typeof x == "object" && x ? x.id ?? "" : x);
45
+ if (D === "in")
46
+ return (Array.isArray(f.value) ? f.value : String(f.value ?? "").split(",")).map((Q) => String(Q).trim()).includes(U);
47
47
  const ne = String(f.value ?? "");
48
- return Q === "neq" ? W !== ne : W === ne;
48
+ return D === "neq" ? U !== ne : U === ne;
49
49
  }
50
50
  function Vi(s, f) {
51
- var A, Q;
51
+ var E, D;
52
52
  if (!(f != null && f.length)) return [];
53
53
  const x = [];
54
- for (const W of f)
55
- !((A = W == null ? void 0 : W.when) != null && A.field) || !((Q = W == null ? void 0 : W.expect) != null && Q.field) || Qo(s, W.when) && (Qo(s, W.expect) || x.push(W.label || `${W.when.field} vs ${W.expect.field}`));
54
+ for (const U of f)
55
+ !((E = U == null ? void 0 : U.when) != null && E.field) || !((D = U == null ? void 0 : U.expect) != null && D.field) || Jo(s, U.when) && (Jo(s, U.expect) || x.push(U.label || `${U.when.field} vs ${U.expect.field}`));
56
56
  return x;
57
57
  }
58
- const md = {
58
+ const pd = {
59
59
  lt: "<",
60
60
  gt: ">",
61
61
  quot: '"',
62
62
  amp: "&",
63
63
  "#39": "'"
64
64
  };
65
- function pd({ children: s }) {
66
- const [f, x] = D(null);
65
+ function Qo({
66
+ saved: s,
67
+ onDelete: f
68
+ }) {
69
+ const [x, E] = W(!1);
70
+ return _e(() => {
71
+ if (!x) return;
72
+ const D = setTimeout(() => E(!1), 3e3);
73
+ return () => clearTimeout(D);
74
+ }, [x]), /* @__PURE__ */ a(
75
+ "button",
76
+ {
77
+ type: "button",
78
+ "aria-label": x ? "Click again to delete this line" : "Delete line",
79
+ "data-tip": x ? "Click again to delete" : "Delete line",
80
+ "data-armed": x ? "" : void 0,
81
+ onClick: (D) => {
82
+ if (D.stopPropagation(), s && !x) {
83
+ E(!0);
84
+ return;
85
+ }
86
+ E(!1), f(D);
87
+ },
88
+ className: x ? "rounded bg-red-50 p-0.5 text-red-600 dark:bg-red-900/20 dark:text-red-400" : "rounded p-0.5 text-slate-300 hover:text-red-500",
89
+ children: /* @__PURE__ */ a(gl, { className: "h-3 w-3" })
90
+ }
91
+ );
92
+ }
93
+ function hd({ children: s }) {
94
+ const [f, x] = W(null);
67
95
  return /* @__PURE__ */ k(
68
96
  "span",
69
97
  {
70
98
  "data-stale-flag": !0,
71
99
  className: "inline-flex max-w-full items-center gap-1 rounded border border-amber-300 bg-amber-50/70 px-1.5 py-0.5 dark:border-amber-500/50 dark:bg-amber-500/10",
72
- onMouseEnter: (A) => {
73
- const Q = A.currentTarget.getBoundingClientRect(), W = window.innerHeight - Q.bottom < 80;
74
- x({ x: Q.left, y: W ? Q.top - 54 : Q.bottom + 4 });
100
+ onMouseEnter: (E) => {
101
+ const D = E.currentTarget.getBoundingClientRect(), U = window.innerHeight - D.bottom < 80;
102
+ x({ x: D.left, y: U ? D.top - 54 : D.bottom + 4 });
75
103
  },
76
104
  onMouseLeave: () => x(null),
77
105
  children: [
78
106
  /* @__PURE__ */ a(sr, { className: "h-3 w-3 shrink-0 text-amber-500" }),
79
107
  /* @__PURE__ */ a("span", { className: "min-w-0 truncate", children: s }),
80
- f && bl(
108
+ f && yl(
81
109
  /* @__PURE__ */ a(
82
110
  "div",
83
111
  {
@@ -92,24 +120,24 @@ function pd({ children: s }) {
92
120
  }
93
121
  );
94
122
  }
95
- function hd(s) {
123
+ function gd(s) {
96
124
  if (typeof s != "string" || !s.trim()) return [];
97
125
  const f = s.replace(
98
126
  /&(lt|gt|quot|amp|#39);/g,
99
- (W, ne) => md[ne] ?? ""
100
- ), x = [], A = /"detail"\s*:\s*"((?:[^"\\]|\\.)*)"/g;
101
- let Q = A.exec(f);
102
- for (; Q; ) {
127
+ (U, ne) => pd[ne] ?? ""
128
+ ), x = [], E = /"detail"\s*:\s*"((?:[^"\\]|\\.)*)"/g;
129
+ let D = E.exec(f);
130
+ for (; D; ) {
103
131
  try {
104
- x.push(JSON.parse(`"${Q[1]}"`));
132
+ x.push(JSON.parse(`"${D[1]}"`));
105
133
  } catch {
106
- x.push(Q[1]);
134
+ x.push(D[1]);
107
135
  }
108
- Q = A.exec(f);
136
+ D = E.exec(f);
109
137
  }
110
138
  if (x.length === 0) {
111
- const W = f.replace(/<[^>]+>/g, " ").replace(/\s+/g, " ").trim();
112
- W && x.push(W.slice(0, 400));
139
+ const U = f.replace(/<[^>]+>/g, " ").replace(/\s+/g, " ").trim();
140
+ U && x.push(U.slice(0, 400));
113
141
  }
114
142
  return x;
115
143
  }
@@ -122,28 +150,28 @@ const Gi = /* @__PURE__ */ new Set([
122
150
  "group",
123
151
  "divider"
124
152
  ]), ir = "__all__";
125
- function Go(s, f, x, A) {
153
+ function Go(s, f, x, E) {
126
154
  if (f <= 0) return [];
127
- let Q;
128
- for (x === "front" ? Q = Array.from({ length: f }, (J, T) => f - T) : x === "back" ? Q = Array.from({ length: f }, (J, T) => T + 1) : x === "shape" && A && A.some((J) => J > 0) ? Q = A.slice(0, f).map((J) => Math.max(0, J)) : Q = Array.from({ length: f }, () => 1); Q.length < f; ) Q.push(0);
129
- const W = Q.reduce((J, T) => J + T, 0) || 1, ne = [];
155
+ let D;
156
+ for (x === "front" ? D = Array.from({ length: f }, (Q, T) => f - T) : x === "back" ? D = Array.from({ length: f }, (Q, T) => T + 1) : x === "shape" && E && E.some((Q) => Q > 0) ? D = E.slice(0, f).map((Q) => Math.max(0, Q)) : D = Array.from({ length: f }, () => 1); D.length < f; ) D.push(0);
157
+ const U = D.reduce((Q, T) => Q + T, 0) || 1, ne = [];
130
158
  let ae = 0;
131
- for (let J = 0; J < f; J++)
132
- if (J === f - 1)
159
+ for (let Q = 0; Q < f; Q++)
160
+ if (Q === f - 1)
133
161
  ne.push(Math.round((s - ae) * 100) / 100);
134
162
  else {
135
- const T = Math.floor(s * Q[J] / W * 100) / 100;
163
+ const T = Math.floor(s * D[Q] / U * 100) / 100;
136
164
  ne.push(T), ae += T;
137
165
  }
138
166
  return ne;
139
167
  }
140
168
  const Fi = 1e3;
141
- function gd(s) {
169
+ function bd(s) {
142
170
  let f = 0;
143
171
  for (let x = 0; x < s.length; x++) f = f * 31 + s.charCodeAt(x) | 0;
144
172
  return f;
145
173
  }
146
- function bd(s) {
174
+ function yd(s) {
147
175
  if (s.line_number != null && s.line_number !== "") return `line ${s.line_number}`;
148
176
  for (const f of ["year", "name", "title", "label", "number"]) {
149
177
  const x = s[f];
@@ -156,57 +184,57 @@ function Ut(s, f) {
156
184
  }
157
185
  function Hi(s, f) {
158
186
  return f.map((x) => {
159
- const A = s[`__m2m_${x}`];
160
- return String(A !== void 0 ? A ?? "" : s[x] ?? "");
187
+ const E = s[`__m2m_${x}`];
188
+ return String(E !== void 0 ? E ?? "" : s[x] ?? "");
161
189
  }).join("\0");
162
190
  }
163
- function Ci(s, f, x, A) {
164
- return typeof s != "string" ? s : s === "$parent.id" ? x : s.startsWith("$parent.") ? A == null ? void 0 : A[s.slice(8)] : s.startsWith("$row.") ? f[s.slice(5)] : s;
191
+ function Ci(s, f, x, E) {
192
+ return typeof s != "string" ? s : s === "$parent.id" ? x : s.startsWith("$parent.") ? E == null ? void 0 : E[s.slice(8)] : s.startsWith("$row.") ? f[s.slice(5)] : s;
165
193
  }
166
- function Fr(s, f, x, A) {
167
- const Q = {};
194
+ function Fr(s, f, x, E) {
195
+ const D = {};
168
196
  for (const [ne, ae] of Object.entries(s.filters ?? {})) {
169
- const J = Ci(ae, f, x, A);
170
- if (J == null || J === "") return null;
197
+ const Q = Ci(ae, f, x, E);
198
+ if (Q == null || Q === "") return null;
171
199
  if (ne.startsWith("_")) {
172
- Q[ne] = J;
200
+ D[ne] = Q;
173
201
  continue;
174
202
  }
175
- const T = typeof J == "object" && !Array.isArray(J) ? J : { _eq: J };
203
+ const T = typeof Q == "object" && !Array.isArray(Q) ? Q : { _eq: Q };
176
204
  if (ne.includes(".")) {
177
205
  const ee = ne.split(".");
178
206
  let Ee = T;
179
207
  for (let K = ee.length - 1; K >= 1; K--) Ee = { [ee[K]]: Ee };
180
- Q[ee[0]] = Ee;
208
+ D[ee[0]] = Ee;
181
209
  } else
182
- Q[ne] = T;
210
+ D[ne] = T;
183
211
  }
184
- const W = {};
212
+ const U = {};
185
213
  for (const [ne, ae] of Object.entries(s.defaults ?? {})) {
186
- const J = Ci(ae, f, x, A);
187
- J != null && J !== "" && (W[ne] = J);
214
+ const Q = Ci(ae, f, x, E);
215
+ Q != null && Q !== "" && (U[ne] = Q);
188
216
  }
189
- return { query: Q, seed: W };
217
+ return { query: D, seed: U };
190
218
  }
191
219
  function Br(s, f) {
192
220
  return f.split(".").reduce(
193
- (x, A) => x && typeof x == "object" ? x[A] : void 0,
221
+ (x, E) => x && typeof x == "object" ? x[E] : void 0,
194
222
  s
195
223
  );
196
224
  }
197
- function yd(s, f, x) {
225
+ function xd(s, f, x) {
198
226
  return f === "presence" ? s != null && String(s).trim() !== "" ? "Yes" : "No" : s == null || s === "" ? "—" : f === "currency" && Number.isFinite(Number(s)) ? Number(s).toLocaleString("en-US", xt(x, "currency")) : String(s);
199
227
  }
200
- function xd({
228
+ function vd({
201
229
  config: s,
202
230
  relatedCollection: f,
203
231
  manyField: x,
204
- parentId: A,
205
- rows: Q,
206
- rowDefaults: W,
232
+ parentId: E,
233
+ rows: D,
234
+ rowDefaults: U,
207
235
  parentDraft: ne,
208
236
  invalidate: ae,
209
- onLocalWrite: J,
237
+ onLocalWrite: Q,
210
238
  staging: T,
211
239
  stagingActive: ee,
212
240
  pendingRows: Ee,
@@ -215,7 +243,7 @@ function xd({
215
243
  writeRow: we,
216
244
  stagedBase: X
217
245
  }) {
218
- const _e = Hr(), [De, oe] = D(!1), [Qe, he] = D(null), [F, fe] = D({}), [Ve, Ie] = D(null), Se = L(
246
+ const ke = Hr(), [De, oe] = W(!1), [Qe, he] = W(null), [F, fe] = W({}), [Ve, Ie] = W(null), Se = L(
219
247
  () => (s.columns ?? []).map(
220
248
  (P) => typeof P == "string" ? {
221
249
  path: P,
@@ -227,8 +255,8 @@ function xd({
227
255
  ),
228
256
  [s.columns]
229
257
  ), Ge = L(
230
- () => Yo(s.filter, ne, A),
231
- [s.filter, ne, A]
258
+ () => Yo(s.filter, ne, E),
259
+ [s.filter, ne, E]
232
260
  ), vt = L(() => {
233
261
  const P = /* @__PURE__ */ new Set(["id"]);
234
262
  s.group_by && P.add(s.group_by);
@@ -247,7 +275,7 @@ function xd({
247
275
  JSON.stringify(Ge ?? null),
248
276
  vt
249
277
  ],
250
- queryFn: () => _e.request(
278
+ queryFn: () => ke.request(
251
279
  ie(`/items/${s.collection}`, {
252
280
  ...Ge ? { filter: JSON.stringify(Ge) } : {},
253
281
  fields: vt,
@@ -258,12 +286,12 @@ function xd({
258
286
  staleTime: 0
259
287
  }), mt = L(() => {
260
288
  const P = /* @__PURE__ */ new Map();
261
- for (const $ of Q) {
289
+ for (const $ of D) {
262
290
  const z = $[s.target_field];
263
291
  z != null && P.set(String(z), $);
264
292
  }
265
293
  return P;
266
- }, [Q, s.target_field]);
294
+ }, [D, s.target_field]);
267
295
  function je(P) {
268
296
  const $ = mt.get(P), z = ($ == null ? void 0 : $.id) != null ? String($.id) : null, H = !!(z && (Z != null && Z.has(z))), S = (Ee ?? []).findIndex(
269
297
  (pe) => String(pe[s.target_field]) === P
@@ -286,15 +314,15 @@ function xd({
286
314
  me !== null && H > me && (H = Math.max(0, Math.round(me * 100) / 100), fe((pe) => ({ ...pe, [P]: String(H) })));
287
315
  }
288
316
  if (ee && T) {
289
- const { savedRow: me, pendingIdx: pe, deleted: U } = je(P), w = (me == null ? void 0 : me.id) != null ? String(me.id) : null;
290
- H === null || H === 0 ? pe >= 0 ? T.removeRow(f, x, pe) : w && !U && (T.cancelPendingEdit(f, x, w), T.queueDelete(f, x, w)) : pe >= 0 ? T.updateRow(f, x, pe, {
317
+ const { savedRow: me, pendingIdx: pe, deleted: J } = je(P), w = (me == null ? void 0 : me.id) != null ? String(me.id) : null;
318
+ H === null || H === 0 ? pe >= 0 ? T.removeRow(f, x, pe) : w && !J && (T.cancelPendingEdit(f, x, w), T.queueDelete(f, x, w)) : pe >= 0 ? T.updateRow(f, x, pe, {
291
319
  ...(Ee ?? [])[pe],
292
320
  [s.value_field]: H
293
- }) : w ? (U && T.cancelPendingDelete(f, x, w), T.queueEdit(f, x, w, {
321
+ }) : w ? (J && T.cancelPendingDelete(f, x, w), T.queueEdit(f, x, w, {
294
322
  [s.value_field]: H,
295
323
  ...(X == null ? void 0 : X(w)) ?? {}
296
324
  })) : T.queueRow(f, x, {
297
- ...W,
325
+ ...U,
298
326
  [s.target_field]: P,
299
327
  [s.value_field]: H
300
328
  });
@@ -304,22 +332,22 @@ function xd({
304
332
  he(P);
305
333
  try {
306
334
  if (H === null || H === 0)
307
- (S == null ? void 0 : S.id) != null && await _e.request(Ho(`/items/${f}/${S.id}`));
335
+ (S == null ? void 0 : S.id) != null && await ke.request(Ho(`/items/${f}/${S.id}`));
308
336
  else if ((S == null ? void 0 : S.id) != null) {
309
337
  if (Number(S[s.value_field]) !== H) {
310
338
  const me = { [s.value_field]: H };
311
- we ? await we(String(S.id), me) : await _e.request(Vr(`/items/${f}/${S.id}`, me));
339
+ we ? await we(String(S.id), me) : await ke.request(Vr(`/items/${f}/${S.id}`, me));
312
340
  }
313
341
  } else
314
- await _e.request(
342
+ await ke.request(
315
343
  Ae(`/items/${f}`, {
316
- ...W,
344
+ ...U,
317
345
  [s.target_field]: P,
318
346
  [s.value_field]: H,
319
- [x]: A
347
+ [x]: E
320
348
  })
321
349
  );
322
- J == null || J((S == null ? void 0 : S.id) != null ? String(S.id) : null), ae();
350
+ Q == null || Q((S == null ? void 0 : S.id) != null ? String(S.id) : null), ae();
323
351
  } catch {
324
352
  } finally {
325
353
  he(null);
@@ -351,8 +379,8 @@ function xd({
351
379
  children: "Allocate…"
352
380
  }
353
381
  ),
354
- /* @__PURE__ */ a(jl, { open: De, onOpenChange: oe, children: /* @__PURE__ */ k(Ll, { side: "right", className: "w-[92vw] sm:max-w-[1200px] overflow-y-auto p-0", children: [
355
- /* @__PURE__ */ a(Tl, { className: "border-b border-slate-200 px-5 py-3", children: /* @__PURE__ */ a(Kl, { className: "text-[14px]", children: s.title ?? "Allocate" }) }),
382
+ /* @__PURE__ */ a(Ll, { open: De, onOpenChange: oe, children: /* @__PURE__ */ k(Tl, { side: "right", className: "w-[92vw] sm:max-w-[1200px] overflow-y-auto p-0", children: [
383
+ /* @__PURE__ */ a(Kl, { className: "border-b border-slate-200 px-5 py-3", children: /* @__PURE__ */ a(Ml, { className: "text-[14px]", children: s.title ?? "Allocate" }) }),
356
384
  /* @__PURE__ */ k("div", { className: "p-4", children: [
357
385
  /* @__PURE__ */ a("p", { className: "mb-2 text-[11px] text-slate-400", children: "Enter an amount to allocate a line — clearing it removes the allocation." }),
358
386
  it ? /* @__PURE__ */ a("div", { className: "py-10 text-center", children: /* @__PURE__ */ a(jn, { className: "inline h-4 w-4 animate-spin text-slate-400" }) }) : te.length === 0 ? /* @__PURE__ */ a("p", { className: "py-10 text-center text-[12px] text-slate-400", children: "No eligible rows for the current record's filters." }) : /* @__PURE__ */ a("div", { className: "overflow-x-auto rounded-lg border border-slate-200", children: /* @__PURE__ */ k("table", { className: "w-full text-left text-[12px]", children: [
@@ -368,20 +396,20 @@ function xd({
368
396
  /* @__PURE__ */ a("th", { className: "whitespace-nowrap px-2.5 py-1.5 text-[11px] font-medium text-slate-500", children: s.value_label ?? "Allocate" })
369
397
  ] }) }),
370
398
  /* @__PURE__ */ a("tbody", { className: "divide-y divide-slate-100", children: (() => {
371
- const P = (U) => s.group_by ? String(Br(U, s.group_by) ?? "—") : "";
399
+ const P = (J) => s.group_by ? String(Br(J, s.group_by) ?? "—") : "";
372
400
  let $ = te, z = [];
373
401
  s.group_by && (z = [...new Set(te.map(P))], $ = z.flatMap(
374
- (U) => te.filter((w) => P(w) === U)
402
+ (J) => te.filter((w) => P(w) === J)
375
403
  ));
376
404
  const H = Ve ?? new Set(
377
- te.filter((U) => je(String(U.id)).amount > 0).map(P)
378
- ), S = (U) => Ie((w) => {
405
+ te.filter((J) => je(String(J.id)).amount > 0).map(P)
406
+ ), S = (J) => Ie((w) => {
379
407
  const Ue = new Set(w ?? H);
380
- return Ue.has(U) ? Ue.delete(U) : Ue.add(U), Ue;
408
+ return Ue.has(J) ? Ue.delete(J) : Ue.add(J), Ue;
381
409
  }), me = [];
382
410
  let pe = null;
383
- for (const U of $) {
384
- const w = String(U.id), Ue = P(U);
411
+ for (const J of $) {
412
+ const w = String(J.id), Ue = P(J);
385
413
  if (s.group_by && Ue !== pe) {
386
414
  pe = Ue;
387
415
  const N = te.filter((Xe) => P(Xe) === Ue), _t = N.filter(
@@ -461,7 +489,7 @@ function xd({
461
489
  me.push(
462
490
  /* @__PURE__ */ k("tr", { className: be(wt && "bg-nvr-cyan/5"), children: [
463
491
  Se.map((N, _t) => {
464
- const Ce = N.formula ? Jt(N.formula, U) : yd(Br(U, N.path ?? ""), N.format);
492
+ const Ce = N.formula ? Jt(N.formula, J) : xd(Br(J, N.path ?? ""), N.format);
465
493
  return /* @__PURE__ */ a(
466
494
  "td",
467
495
  {
@@ -478,7 +506,7 @@ function xd({
478
506
  }),
479
507
  /* @__PURE__ */ a("td", { className: "px-2.5 py-1", children: /* @__PURE__ */ k("div", { className: "flex items-center gap-1.5", children: [
480
508
  (() => {
481
- const N = pt(U), _t = N !== null && I !== "" && Number(I) > N;
509
+ const N = pt(J), _t = N !== null && I !== "" && Number(I) > N;
482
510
  return /* @__PURE__ */ a(
483
511
  "input",
484
512
  {
@@ -488,10 +516,10 @@ function xd({
488
516
  title: N !== null ? `Max ${N.toLocaleString("en-US", { style: "currency", currency: "USD" })}` : void 0,
489
517
  onChange: (Ce) => fe((Qt) => ({ ...Qt, [w]: Ce.target.value })),
490
518
  onBlur: () => {
491
- F[w] !== void 0 && Ke(w, F[w], U);
519
+ F[w] !== void 0 && Ke(w, F[w], J);
492
520
  },
493
521
  onKeyDown: (Ce) => {
494
- Ce.key === "Enter" && F[w] !== void 0 && Ke(w, F[w], U);
522
+ Ce.key === "Enter" && F[w] !== void 0 && Ke(w, F[w], J);
495
523
  },
496
524
  placeholder: "0",
497
525
  className: be(
@@ -513,27 +541,27 @@ function xd({
513
541
  ] }) })
514
542
  ] });
515
543
  }
516
- function vd({
544
+ function wd({
517
545
  config: s,
518
546
  rows: f,
519
547
  relatedCollection: x,
520
- computedWriteFields: A,
521
- applyRow: Q
548
+ computedWriteFields: E,
549
+ applyRow: D
522
550
  }) {
523
- const W = Hr(), [ne, ae] = D(!1), [J, T] = D(!1), ee = async () => {
551
+ const U = Hr(), [ne, ae] = W(!1), [Q, T] = W(!1), ee = async () => {
524
552
  T(!1);
525
- const Ee = Object.keys(s.set).filter((K) => A.has(K));
553
+ const Ee = Object.keys(s.set).filter((K) => E.has(K));
526
554
  if (Ee.length > 0) {
527
555
  const K = Ee[0];
528
556
  ge.error(
529
- `${s.label}: "${K}" is calculated from ${A.get(K)} and cannot be set directly — target those fields instead`,
557
+ `${s.label}: "${K}" is calculated from ${E.get(K)} and cannot be set directly — target those fields instead`,
530
558
  { duration: 12e3 }
531
559
  );
532
560
  return;
533
561
  }
534
562
  ae(!0);
535
563
  try {
536
- const K = await W.request(ie(`/collections/${x}`)).then((F) => F.data), Z = ((K == null ? void 0 : K.relations) ?? []).find(
564
+ const K = await U.request(ie(`/collections/${x}`)).then((F) => F.data), Z = ((K == null ? void 0 : K.relations) ?? []).find(
537
565
  (F) => F.one_collection === x && F.one_field === s.relation
538
566
  );
539
567
  if (!(Z != null && Z.many_collection) || !(Z != null && Z.many_field)) {
@@ -547,25 +575,25 @@ function vd({
547
575
  ge.message(`${s.label}: no saved rows to update`);
548
576
  return;
549
577
  }
550
- const X = await W.request(
578
+ const X = await U.request(
551
579
  ie(`/items/${Z.many_collection}`, {
552
580
  filter: JSON.stringify({ [Z.many_field]: { _in: we } }),
553
581
  fields: `id,${Z.many_field},${s.aggregate.field}`,
554
582
  limit: "2000"
555
583
  })
556
- ).then((F) => F.data ?? []), _e = s.aggregate.op ?? "sum", De = /* @__PURE__ */ new Map();
584
+ ).then((F) => F.data ?? []), ke = s.aggregate.op ?? "sum", De = /* @__PURE__ */ new Map();
557
585
  for (const F of X) {
558
586
  const fe = String(F[Z.many_field] ?? ""), Ve = Number(F[s.aggregate.field]);
559
587
  !fe || Number.isNaN(Ve) || De.set(fe, [...De.get(fe) ?? [], Ve]);
560
588
  }
561
589
  const oe = (F) => {
562
590
  const fe = De.get(String(F)) ?? [];
563
- return _e === "count" ? fe.length : fe.length === 0 ? 0 : _e === "min" ? Math.min(...fe) : _e === "max" ? Math.max(...fe) : fe.reduce((Ve, Ie) => Ve + Ie, 0);
591
+ return ke === "count" ? fe.length : fe.length === 0 ? 0 : ke === "min" ? Math.min(...fe) : ke === "max" ? Math.max(...fe) : fe.reduce((Ve, Ie) => Ve + Ie, 0);
564
592
  };
565
593
  let Qe = 0, he = 0;
566
594
  for (const F of f) {
567
595
  const fe = { ...F, __agg__: oe(F.id) };
568
- if (s.guard && !Nl(s.guard, fe)) {
596
+ if (s.guard && !Sl(s.guard, fe)) {
569
597
  he++;
570
598
  continue;
571
599
  }
@@ -578,7 +606,7 @@ function vd({
578
606
  he++;
579
607
  continue;
580
608
  }
581
- await Q(F, Ve), Qe++;
609
+ await D(F, Ve), Qe++;
582
610
  }
583
611
  ge.success(
584
612
  `${s.label}: ${Qe} row${Qe === 1 ? "" : "s"} updated` + (he > 0 ? `, ${he} unchanged` : "")
@@ -589,7 +617,7 @@ function vd({
589
617
  ae(!1);
590
618
  }
591
619
  };
592
- return J ? /* @__PURE__ */ k("span", { className: "inline-flex items-center gap-1.5 text-[11px]", children: [
620
+ return Q ? /* @__PURE__ */ k("span", { className: "inline-flex items-center gap-1.5 text-[11px]", children: [
593
621
  /* @__PURE__ */ a("span", { className: "text-slate-600 dark:text-slate-300", children: s.confirm ?? "Apply to all rows?" }),
594
622
  /* @__PURE__ */ a(
595
623
  "button",
@@ -623,28 +651,28 @@ function vd({
623
651
  }
624
652
  );
625
653
  }
626
- function wd({
654
+ function _d({
627
655
  config: s,
628
656
  matchCfg: f,
629
657
  rows: x,
630
- parentId: A,
631
- parentDraft: Q,
632
- relatedCollection: W,
658
+ parentId: E,
659
+ parentDraft: D,
660
+ relatedCollection: U,
633
661
  manyField: ne
634
662
  }) {
635
- const ae = Hr(), J = Vo(), [T, ee] = D(!1), [Ee, K] = D(null), Z = async () => {
663
+ const ae = Hr(), Q = Vo(), [T, ee] = W(!1), [Ee, K] = W(null), Z = async () => {
636
664
  if (T) return;
637
665
  ee(!0), K(null);
638
- const we = s.fk_field, X = s.alloc_qty_field, _e = s.candidates.min_capacity ?? 1, De = [
666
+ const we = s.fk_field, X = s.alloc_qty_field, ke = s.candidates.min_capacity ?? 1, De = [
639
667
  ...s.candidates.capacity_formula.matchAll(/\{\{\s*(\w+)\s*\}\}/g)
640
668
  ].map((Ie) => Ie[1]), oe = {};
641
669
  let Qe = 0, he = 0, F = 0;
642
- const fe = [], Ve = (Ie, Se) => Cl(ae, f.collection, Ie, X, Se);
670
+ const fe = [], Ve = (Ie, Se) => Xl(ae, f.collection, Ie, X, Se);
643
671
  try {
644
672
  for (let Se = 0; Se < x.length; Se++) {
645
673
  const Ge = x[Se], vt = Number(Ge[s.row_qty_field]);
646
674
  if (!Number.isFinite(vt) || vt <= 0) continue;
647
- const te = Fr(f, Ge, A, Q);
675
+ const te = Fr(f, Ge, E, D);
648
676
  if (!te) continue;
649
677
  const it = await ae.request(
650
678
  ie(`/items/${f.collection}`, {
@@ -662,8 +690,8 @@ function wd({
662
690
  defaults: {}
663
691
  },
664
692
  Ge,
665
- A,
666
- Q
693
+ E,
694
+ D
667
695
  );
668
696
  if (!Ke) continue;
669
697
  const We = await ae.request(
@@ -693,8 +721,8 @@ function wd({
693
721
  for (const $ of We) {
694
722
  if (je <= 0) break;
695
723
  const z = String($.id), S = (Ut(s.candidates.capacity_formula, $) ?? 0) - (pt[z] ?? 0) - (oe[z] ?? 0);
696
- if (S < _e) continue;
697
- const me = Math.min(je, S), pe = it.find((U) => String(U[we]) === z);
724
+ if (S < ke) continue;
725
+ const me = Math.min(je, S), pe = it.find((J) => String(J[we]) === z);
698
726
  if (pe) {
699
727
  if (!await Ve(String(pe.id), me)) {
700
728
  F++;
@@ -713,7 +741,7 @@ function wd({
713
741
  Qe > 0 ? `Allocated ${Qe.toLocaleString("en-US", { maximumFractionDigits: 2 })} across ${he} row${he === 1 ? "" : "s"}` : "Nothing to allocate"
714
742
  ), fe.length > 0 && Ie.push(`short on row${fe.length === 1 ? "" : "s"} ${fe.join(", ")}`), F > 0 && Ie.push(
715
743
  `${F} allocation${F === 1 ? "" : "s"} kept changing while this ran — left as saved; run again`
716
- ), K(Ie.join(" — ")), J.invalidateQueries({ queryKey: ["o2m-rows", W, ne, A] }), J.invalidateQueries({ queryKey: ["match-agg"] });
744
+ ), K(Ie.join(" — ")), Q.invalidateQueries({ queryKey: ["o2m-rows", U, ne, E] }), Q.invalidateQueries({ queryKey: ["match-agg"] });
717
745
  } catch (Ie) {
718
746
  K(`Auto-allocate failed: ${In(Ie, "unknown error")}`);
719
747
  } finally {
@@ -734,21 +762,21 @@ function wd({
734
762
  Ee && /* @__PURE__ */ a("span", { className: "text-[11px] text-slate-500", children: Ee })
735
763
  ] });
736
764
  }
737
- function _d(s) {
765
+ function kd(s) {
738
766
  return s.filter(
739
767
  (f) => f.group_key === "__apply_values__" && !Gi.has(f.type ?? "") && !Yi.has(f.field) && !f.readonly && !(f.computed_type === "write" && f.computed_formula) && f.interface !== "formula-column" && f.interface !== "match-agg-column" && f.interface !== "relation-path"
740
768
  );
741
769
  }
742
- function dc({
770
+ function cc({
743
771
  relatedCollection: s,
744
772
  manyField: f,
745
773
  parentId: x,
746
- parentCollection: A,
747
- layoutId: Q,
748
- showRowRevisions: W,
774
+ parentCollection: E,
775
+ layoutId: D,
776
+ showRowRevisions: U,
749
777
  rowComments: ne,
750
778
  allowRevisionRestore: ae = !0,
751
- saveMode: J = "immediate",
779
+ saveMode: Q = "immediate",
752
780
  showLineNumbers: T = !1,
753
781
  enableReorder: ee = !0,
754
782
  parentCascades: Ee,
@@ -756,7 +784,7 @@ function dc({
756
784
  columnPresets: Z,
757
785
  defaultPreset: we,
758
786
  drawerRelations: X,
759
- parentContextFields: _e,
787
+ parentContextFields: ke,
760
788
  uniqueBy: De,
761
789
  sortField: oe,
762
790
  sortDir: Qe = "asc",
@@ -783,7 +811,7 @@ function dc({
783
811
  editorMode: H
784
812
  }) {
785
813
  var jo, Lo;
786
- const S = Hr(), me = $l(), pe = xl(), U = Vo(), w = nd(), Ue = rd(), It = id(), wt = Ml()[P ?? ""] ?? [], I = x === "new", N = vl(), _t = wl(), Ce = Sl(), Qt = `nvr_grid_editor_${s}_${P ?? f}`, [an, Yr] = D(() => {
814
+ const S = Hr(), me = ql(), pe = vl(), J = Vo(), w = rd(), Ue = id(), It = sd(), wt = Rl()[P ?? ""] ?? [], I = x === "new", N = wl(), _t = _l(), Ce = $l(), Qt = `nvr_grid_editor_${s}_${P ?? f}`, [an, Yr] = W(() => {
787
815
  if (typeof localStorage > "u") return null;
788
816
  try {
789
817
  const e = localStorage.getItem(Qt);
@@ -792,9 +820,9 @@ function dc({
792
820
  return null;
793
821
  }
794
822
  }), { data: zt } = Be({
795
- queryKey: ["field-config", A ?? "", null],
796
- queryFn: () => S.request(ie(`/field-config/${A}`)).then((e) => e.data ?? []),
797
- enabled: H === void 0 && !!A && !!P,
823
+ queryKey: ["field-config", E ?? "", null],
824
+ queryFn: () => S.request(ie(`/field-config/${E}`)).then((e) => e.data ?? []),
825
+ enabled: H === void 0 && !!E && !!P,
798
826
  staleTime: 5 * 6e4
799
827
  }), Xe = L(() => {
800
828
  if (H) return H;
@@ -812,7 +840,7 @@ function dc({
812
840
  localStorage.setItem(Qt, e);
813
841
  } catch {
814
842
  }
815
- }, Bt = `nvr_grid_split_h_${s}`, [jt, Xi] = D(() => {
843
+ }, Bt = `nvr_grid_split_h_${s}`, [jt, Xi] = W(() => {
816
844
  if (typeof localStorage > "u") return 320;
817
845
  try {
818
846
  const e = Number(localStorage.getItem(Bt));
@@ -821,7 +849,7 @@ function dc({
821
849
  return 320;
822
850
  }
823
851
  });
824
- ke(() => {
852
+ _e(() => {
825
853
  try {
826
854
  localStorage.setItem(Bt, String(jt));
827
855
  } catch {
@@ -832,11 +860,11 @@ function dc({
832
860
  async () => {
833
861
  }
834
862
  ), dr = ue(null), es = ue(!1);
835
- ke(() => {
863
+ _e(() => {
836
864
  if ($ || typeof window > "u") return;
837
865
  const e = (n) => {
838
866
  const t = n.detail;
839
- if (!t || typeof t.target != "string" || !t.target || A && t.collection !== A) return;
867
+ if (!t || typeof t.target != "string" || !t.target || E && t.collection !== E) return;
840
868
  const r = P ?? f;
841
869
  if (!(t.grid !== r && t.grid !== s)) {
842
870
  if (t.handled = !0, !es.current) {
@@ -847,7 +875,7 @@ function dc({
847
875
  }
848
876
  };
849
877
  return window.addEventListener("nvr:grid-apply-field", e), () => window.removeEventListener("nvr:grid-apply-field", e);
850
- }, [$, A, P, f, s]), ke(() => {
878
+ }, [$, E, P, f, s]), _e(() => {
851
879
  const e = lr.current;
852
880
  if (!e || !le) return;
853
881
  const n = (t) => {
@@ -859,13 +887,13 @@ function dc({
859
887
  };
860
888
  return e.addEventListener("keydown", n), () => e.removeEventListener("keydown", n);
861
889
  }, [le]);
862
- const [ln, Xo] = D(!1), [Vt, cr] = D(/* @__PURE__ */ new Set()), [Zo, ts] = D(!1), ns = (e) => cr((n) => {
890
+ const [ln, Xo] = W(!1), [Vt, cr] = W(/* @__PURE__ */ new Set()), [Zo, ts] = W(!1), ns = (e) => cr((n) => {
863
891
  const t = new Set(n);
864
892
  return t.has(e) ? t.delete(e) : t.add(e), t;
865
893
  }), rs = Jt ? Jt.line_field ?? "line_number" : null, { data: ur } = Be({
866
- queryKey: ["erp-submissions", A ?? "", String(x)],
867
- queryFn: () => S.request(ie(`/erp-submissions/${A}/${encodeURIComponent(String(x))}`)).then((e) => e.data ?? []),
868
- enabled: !!Jt && !!A && !I && !!x,
894
+ queryKey: ["erp-submissions", E ?? "", String(x)],
895
+ queryFn: () => S.request(ie(`/erp-submissions/${E}/${encodeURIComponent(String(x))}`)).then((e) => e.data ?? []),
896
+ enabled: !!Jt && !!E && !I && !!x,
869
897
  staleTime: 15e3
870
898
  }), ea = L(() => {
871
899
  const e = /* @__PURE__ */ new Map(), n = ur == null ? void 0 : ur[0];
@@ -878,7 +906,7 @@ function dc({
878
906
  if (!["ERROR", "FAILED"].includes(d)) continue;
879
907
  const u = String((o == null ? void 0 : o.lineNumber) ?? "");
880
908
  if (!u || e.has(u)) continue;
881
- const c = hd(o == null ? void 0 : o.lineDetailedMessage), m = c.find(
909
+ const c = gd(o == null ? void 0 : o.lineDetailedMessage), m = c.find(
882
910
  (g) => new RegExp(`^Line(?:Number)?\\s*${u}\\s*:`, "i").test(g.trim())
883
911
  ) ?? c[0];
884
912
  m && e.set(u, m.replace(/^Line(?:Number)?\s*\d+\s*:\s*/i, ""));
@@ -889,8 +917,8 @@ function dc({
889
917
  o && !e.has(o[1]) && e.set(o[1], o[2] || i.trim());
890
918
  }
891
919
  return e;
892
- }, [ur]), is = ue(!1), [ss, Cr] = D(I && !!pt);
893
- ke(() => {
920
+ }, [ur]), is = ue(!1), [ss, Cr] = W(I && !!pt);
921
+ _e(() => {
894
922
  if (!is.current) {
895
923
  if (!I || !pt || !w) {
896
924
  Cr(!1);
@@ -908,7 +936,7 @@ function dc({
908
936
  }).catch(() => Cr(!1));
909
937
  }
910
938
  }, []);
911
- const [ta, os] = D(!1), na = L(
939
+ const [ta, os] = W(!1), na = L(
912
940
  () => /* @__PURE__ */ new Set([
913
941
  "id",
914
942
  f,
@@ -942,7 +970,7 @@ function dc({
942
970
  } catch {
943
971
  ge.error("Could not copy lines");
944
972
  }
945
- }, st = A && !I ? `?parent_collection=${encodeURIComponent(A)}&parent_id=${encodeURIComponent(x)}` : "", [$e, Ln] = D(null), [ia, Xr] = D(null), [as, fr] = D(!1), [sa, ls] = D(!1), { data: oa = [], isLoading: aa } = Be({
973
+ }, st = E && !I ? `?parent_collection=${encodeURIComponent(E)}&parent_id=${encodeURIComponent(x)}` : "", [$e, Ln] = W(null), [ia, Xr] = W(null), [as, fr] = W(!1), [sa, ls] = W(!1), { data: oa = [], isLoading: aa } = Be({
946
974
  queryKey: ["o2m-row-revisions", s, $e == null ? void 0 : $e.id],
947
975
  queryFn: () => S.request(
948
976
  ie("/revisions", { collection: s, item: String($e == null ? void 0 : $e.id) })
@@ -985,8 +1013,8 @@ function dc({
985
1013
  parent_id: x,
986
1014
  target_timestamp: e
987
1015
  })
988
- ), t = El(n);
989
- t && ge.warning(t, { duration: 1e4 }), U.invalidateQueries({ queryKey: ["o2m-rows", s, f, x] }), U.invalidateQueries({
1016
+ ), t = Ol(n);
1017
+ t && ge.warning(t, { duration: 1e4 }), J.invalidateQueries({ queryKey: ["o2m-rows", s, f, x] }), J.invalidateQueries({
990
1018
  queryKey: ["o2m-field-snapshots", s, f, x]
991
1019
  }), fr(!1);
992
1020
  } catch {
@@ -1000,7 +1028,7 @@ function dc({
1000
1028
  (K ?? []).filter((e) => e.target_type === "lock").map((e) => e.target_field)
1001
1029
  ),
1002
1030
  [K]
1003
- ), [p, Me] = D(null), He = ue(null), ds = (e, n) => e && e !== "new" && !e.startsWith("pending:") ? `${s}:${e}:${n}` : void 0, kt = ue(null), mr = (e, n) => {
1031
+ ), [p, Me] = W(null), He = ue(null), ds = (e, n) => e && e !== "new" && !e.startsWith("pending:") ? `${s}:${e}:${n}` : void 0, kt = ue(null), mr = (e, n) => {
1004
1032
  !e || typeof window > "u" || window.dispatchEvent(new CustomEvent("nvr:cell-editing", { detail: { cell: e, state: n } }));
1005
1033
  }, ua = (e) => {
1006
1034
  var t, r, i;
@@ -1010,14 +1038,14 @@ function dc({
1010
1038
  var t, r;
1011
1039
  (r = (t = e.relatedTarget) == null ? void 0 : t.closest) != null && r.call(t, "[data-grid-cell]") || (kt.current && mr(kt.current, "end"), kt.current = null);
1012
1040
  };
1013
- ke(
1041
+ _e(
1014
1042
  () => () => {
1015
1043
  kt.current && mr(kt.current, "end");
1016
1044
  },
1017
1045
  []
1018
1046
  );
1019
1047
  const dn = ue(null);
1020
- ke(() => {
1048
+ _e(() => {
1021
1049
  const e = p == null ? void 0 : p.rowId, n = e && e !== "new" && !e.startsWith("pending:") ? `${s}:${e}` : null;
1022
1050
  n !== dn.current && (typeof window > "u" || (dn.current && window.dispatchEvent(
1023
1051
  new CustomEvent("nvr:row-editing", {
@@ -1026,7 +1054,7 @@ function dc({
1026
1054
  ), n && window.dispatchEvent(
1027
1055
  new CustomEvent("nvr:row-editing", { detail: { row: n, state: "start" } })
1028
1056
  ), dn.current = n));
1029
- }, [p == null ? void 0 : p.rowId, s]), ke(
1057
+ }, [p == null ? void 0 : p.rowId, s]), _e(
1030
1058
  () => () => {
1031
1059
  dn.current && typeof window < "u" && window.dispatchEvent(
1032
1060
  new CustomEvent("nvr:row-editing", {
@@ -1040,9 +1068,9 @@ function dc({
1040
1068
  rowId: null,
1041
1069
  seqs: /* @__PURE__ */ new Map()
1042
1070
  });
1043
- ke(() => {
1071
+ _e(() => {
1044
1072
  He.current = p;
1045
- }, [p]), ke(() => {
1073
+ }, [p]), _e(() => {
1046
1074
  if (!p || $) return;
1047
1075
  const e = (n) => {
1048
1076
  const t = n.target;
@@ -1060,7 +1088,7 @@ function dc({
1060
1088
  };
1061
1089
  return document.addEventListener("mousedown", e, !0), () => document.removeEventListener("mousedown", e, !0);
1062
1090
  }, [p, $]);
1063
- const [ht, cn] = D(!1), [cs, Lt] = D(null), [Kn, pr] = D(null), [us, fs] = D(!1);
1091
+ const [ht, cn] = W(!1), [cs, Lt] = W(null), [Kn, pr] = W(null), [us, fs] = W(!1);
1064
1092
  async function ma() {
1065
1093
  if (!Kn) return;
1066
1094
  fs(!0);
@@ -1076,7 +1104,7 @@ function dc({
1076
1104
  }
1077
1105
  i.length && e.push({ ...r, members: i });
1078
1106
  }
1079
- fs(!1), U.invalidateQueries({ queryKey: ["o2m-rows", s, f, x] });
1107
+ fs(!1), J.invalidateQueries({ queryKey: ["o2m-rows", s, f, x] });
1080
1108
  const t = e.reduce((r, i) => r + i.members.length, 0);
1081
1109
  pr(
1082
1110
  t > 0 ? {
@@ -1085,7 +1113,7 @@ function dc({
1085
1113
  } : null
1086
1114
  );
1087
1115
  }
1088
- const [hr, Mn] = D(null), Oe = Rl(), [ei, pa] = D(() => {
1116
+ const [hr, Mn] = W(null), Oe = Pl(), [ei, pa] = W(() => {
1089
1117
  var e;
1090
1118
  return we === ir ? ir : we && (Z != null && Z.some((n) => n.name === we)) ? we : (e = Z == null ? void 0 : Z[0]) == null ? void 0 : e.name;
1091
1119
  });
@@ -1100,9 +1128,9 @@ function dc({
1100
1128
  queryFn: () => S.request(
1101
1129
  ie("/collection-layouts", { collection: s })
1102
1130
  ).then((e) => (e.data ?? []).find((n) => n.layout_type === "table") ?? null),
1103
- enabled: !Q,
1131
+ enabled: !D,
1104
1132
  staleTime: 5 * 6e4
1105
- }), Ht = Q ?? (ti == null ? void 0 : ti.id) ?? null, { data: xe = [], isLoading: ps } = Be({
1133
+ }), Ht = D ?? (ti == null ? void 0 : ti.id) ?? null, { data: xe = [], isLoading: ps } = Be({
1106
1134
  queryKey: ["field-config", s, Ht],
1107
1135
  queryFn: () => S.request(
1108
1136
  ie(
@@ -1161,24 +1189,24 @@ function dc({
1161
1189
  enabled: !I,
1162
1190
  staleTime: 3e4
1163
1191
  }), Nt = L(
1164
- () => Vl(S, s),
1192
+ () => Fl(S, s),
1165
1193
  [S, s]
1166
1194
  );
1167
- ke(() => {
1195
+ _e(() => {
1168
1196
  !I && !$ && Nt.noteRows(ze);
1169
1197
  }, [ze, Nt, I, $]);
1170
1198
  const fn = (e) => {
1171
1199
  if (I) return {};
1172
1200
  const n = Nt.settled(e);
1173
1201
  return typeof n == "number" && n > 0 ? { __base_revision: n } : {};
1174
- }, [xr, ri] = D(null), mn = ue(async () => !1), ii = ue([]), Pn = () => {
1202
+ }, [xr, ri] = W(null), mn = ue(async () => !1), ii = ue([]), Pn = () => {
1175
1203
  const e = ii.current;
1176
1204
  ii.current = [], e.length !== 0 && ri((n) => {
1177
1205
  const t = new Map((n ?? []).map((r) => [r.rowId, r]));
1178
1206
  for (const r of e) t.set(r.rowId, r);
1179
1207
  return [...t.values()];
1180
1208
  });
1181
- }, ha = kl(2e3), { data: pn } = Be({
1209
+ }, ha = Nl(2e3), { data: pn } = Be({
1182
1210
  queryKey: ["o2m-cell-provenance", s, f, x, yr],
1183
1211
  queryFn: () => S.request(
1184
1212
  ie("/revisions/o2m-cell-provenance", {
@@ -1187,25 +1215,25 @@ function dc({
1187
1215
  parent_id: x
1188
1216
  })
1189
1217
  ).then((e) => ({ data: e.data ?? {}, created: e.created ?? {} })),
1190
- enabled: ha && !!W && !I && ze.length > 0,
1218
+ enabled: ha && !!U && !I && ze.length > 0,
1191
1219
  staleTime: 6e4,
1192
1220
  placeholderData: (e) => e
1193
1221
  }), ga = !!(it != null && it.enabled) && typeof (it == null ? void 0 : it.field) == "string", { data: Ze } = Be({
1194
1222
  queryKey: [
1195
1223
  "line-aging",
1196
- A ?? "",
1224
+ E ?? "",
1197
1225
  P ?? f,
1198
1226
  x,
1199
1227
  yr
1200
1228
  ],
1201
1229
  queryFn: () => S.request(
1202
1230
  ie("/sla/line-aging", {
1203
- collection: A ?? "",
1231
+ collection: E ?? "",
1204
1232
  field: P ?? f,
1205
1233
  parent_id: x
1206
1234
  })
1207
1235
  ).then((e) => e.data ?? null),
1208
- enabled: ga && !I && !!A,
1236
+ enabled: ga && !I && !!E,
1209
1237
  staleTime: 6e4,
1210
1238
  placeholderData: (e) => e
1211
1239
  }), hs = L(
@@ -1214,8 +1242,8 @@ function dc({
1214
1242
  ), gs = Ze != null && Ze.overdue ? `${Ze.label} still missing · ${Ze.days} ${Ze.days === 1 ? "day" : "days"} on the clock (limit ${Ze.threshold_days})` : void 0, si = (pn == null ? void 0 : pn.data) ?? {}, ba = (pn == null ? void 0 : pn.created) ?? {}, vr = (e) => {
1215
1243
  const n = ba[e];
1216
1244
  if (!n) return null;
1217
- const t = ad(n.comment);
1218
- return t ? `From ${t.template} · ${Po(n.at)} by ${n.who}` : null;
1245
+ const t = ld(n.comment);
1246
+ return t ? `From ${t.template} · ${Ro(n.at)} by ${n.who}` : null;
1219
1247
  }, Dn = Ee ?? [], bs = on({
1220
1248
  queries: Dn.map((e) => ({
1221
1249
  queryKey: [
@@ -1252,8 +1280,8 @@ function dc({
1252
1280
  }
1253
1281
  }));
1254
1282
  }), e;
1255
- }, [Dn, bs, N]), M = J === "pending", R = w ? w.getPendingRows(s, f) : [], Y = M && w ? w.getPendingEdits(s, f) : /* @__PURE__ */ new Map(), [wr, _r] = D({});
1256
- ke(() => {
1283
+ }, [Dn, bs, N]), M = Q === "pending", R = w ? w.getPendingRows(s, f) : [], Y = M && w ? w.getPendingEdits(s, f) : /* @__PURE__ */ new Map(), [wr, _r] = W({});
1284
+ _e(() => {
1257
1285
  He.current || _r({});
1258
1286
  }, [yr]);
1259
1287
  const Je = M && w ? w.getPendingDeletes(s, f) : /* @__PURE__ */ new Set(), oi = L(
@@ -1397,7 +1425,7 @@ function dc({
1397
1425
  for (const [r, i] of Object.entries(t)) e[n][r] = i.value;
1398
1426
  }
1399
1427
  return e;
1400
- }, [qe]), E = L(() => {
1428
+ }, [qe]), O = L(() => {
1401
1429
  let e = lt ? ze.map((n) => ({ ...n, ...lt[String(n.id)] ?? {} })) : ze;
1402
1430
  if (C) {
1403
1431
  const n = (t) => {
@@ -1427,7 +1455,7 @@ function dc({
1427
1455
  oe,
1428
1456
  Qe,
1429
1457
  he
1430
- ]), ks = !!he && !!lt, kr = he ? `nvr_grid_sections:${s}:${P ?? f}` : null, [Ns, va] = D(() => {
1458
+ ]), ks = !!he && !!lt, kr = he ? `nvr_grid_sections:${s}:${P ?? f}` : null, [Ns, va] = W(() => {
1431
1459
  if (!kr || typeof localStorage > "u") return /* @__PURE__ */ new Set();
1432
1460
  try {
1433
1461
  const e = localStorage.getItem(kr), n = e ? JSON.parse(e) : null;
@@ -1475,7 +1503,7 @@ function dc({
1475
1503
  const t = n === void 0 ? $s(e.id) : n, r = { ...e };
1476
1504
  for (const i of Ss) {
1477
1505
  const o = i.computed_formula;
1478
- if (t && !Al(o, r, t)) continue;
1506
+ if (t && !Il(o, r, t)) continue;
1479
1507
  const d = Ut(o, r);
1480
1508
  d !== null && (r[i.field] = d);
1481
1509
  }
@@ -1485,7 +1513,7 @@ function dc({
1485
1513
  if (e == null || e === "") return;
1486
1514
  const n = String(e);
1487
1515
  if (!(n.startsWith("pending:") || n === "new"))
1488
- return E.find((t) => String(t.id) === n);
1516
+ return O.find((t) => String(t.id) === n);
1489
1517
  }
1490
1518
  const ka = /* @__PURE__ */ new Set(["__apply_values__", "__create_with_defaults__"]), Un = (e) => e === "select-multiple-m2m" || (e ?? "").endsWith("-m2m");
1491
1519
  function ci(e) {
@@ -1507,7 +1535,7 @@ function dc({
1507
1535
  var o;
1508
1536
  if (!C) return e;
1509
1537
  const t = new Set(n);
1510
- for (const d of E) {
1538
+ for (const d of O) {
1511
1539
  const u = Number(
1512
1540
  (M ? (o = Y.get(String(d.id))) == null ? void 0 : o[C] : void 0) ?? d[C]
1513
1541
  );
@@ -1530,7 +1558,7 @@ function dc({
1530
1558
  });
1531
1559
  }, fi = L(() => {
1532
1560
  const e = [
1533
- ...(E ?? []).filter((n) => !Je.has(String(n.id))).map((n) => {
1561
+ ...(O ?? []).filter((n) => !Je.has(String(n.id))).map((n) => {
1534
1562
  const t = String(n.id), r = Y.has(t) ? { ...n, ...Y.get(t) } : n;
1535
1563
  return de(r);
1536
1564
  }),
@@ -1541,7 +1569,7 @@ function dc({
1541
1569
  r >= 0 && r < e.length && (e[r] = n);
1542
1570
  }
1543
1571
  return e;
1544
- }, [E, ui, p]), Jn = L(() => {
1572
+ }, [O, ui, p]), Jn = L(() => {
1545
1573
  if (Oe === "original") return fi;
1546
1574
  const e = wt.find((n) => n.addendumId === Oe);
1547
1575
  return e ? e.rows.map(
@@ -1562,24 +1590,24 @@ function dc({
1562
1590
  },
1563
1591
  [St, Jn]
1564
1592
  ), mi = L(() => je != null && je.length ? je.map((e) => ({ ...e, result: ft(e.value, Gt) })) : null, [je, Gt]), Nr = L(
1565
- () => Ke != null && Ke.endpoint ? Pl(Ke.endpoint, St) : null,
1593
+ () => Ke != null && Ke.endpoint ? Dl(Ke.endpoint, St) : null,
1566
1594
  [Ke == null ? void 0 : Ke.endpoint, St]
1567
- ), pi = Dl({
1595
+ ), pi = Wl({
1568
1596
  client: S,
1569
1597
  endpoint: Nr,
1570
1598
  enabled: !!Ke && !I
1571
- }), O = Ke && !I ? pi.data ?? null : null, Es = !!Ke && !I && !!Nr && pi.isLoading, Os = !!Ke && !I && pi.isError, Sr = At(
1599
+ }), A = Ke && !I ? pi.data ?? null : null, Es = !!Ke && !I && !!Nr && pi.isLoading, Os = !!Ke && !I && pi.isError, Sr = At(
1572
1600
  (e) => e.label || Ne(e.field),
1573
1601
  []
1574
- ), { isAdmin: Qn } = _l(), $r = At(
1602
+ ), { isAdmin: Qn } = kl(), $r = At(
1575
1603
  (e) => {
1576
1604
  var n;
1577
1605
  return !Qn && ((n = Qi(e.options)) == null ? void 0 : n.admin_only_edit) === !0;
1578
1606
  },
1579
1607
  [Qn]
1580
1608
  ), hi = At(
1581
- (e, n) => !!(O != null && O.closed_locked) && !Qn && O.columns.includes(e) && Wt(O, n[O.key_field], e),
1582
- [O, Qn]
1609
+ (e, n) => !!(A != null && A.closed_locked) && !Qn && A.columns.includes(e) && Wt(A, n[A.key_field], e),
1610
+ [A, Qn]
1583
1611
  ), bn = At(
1584
1612
  async (e, n, t) => {
1585
1613
  if (e.startsWith("pending:")) {
@@ -1604,14 +1632,14 @@ function dc({
1604
1632
  await vi(`/items/${s}/${e}`, e, {
1605
1633
  ...n,
1606
1634
  _change_reason: t
1607
- }), U.invalidateQueries({ queryKey: ["o2m-rows", s, f, x] });
1635
+ }), J.invalidateQueries({ queryKey: ["o2m-rows", s, f, x] });
1608
1636
  } catch (r) {
1609
1637
  ge.error(`Could not save: ${In(r, "unknown error")}`);
1610
1638
  }
1611
1639
  },
1612
1640
  // eslint-disable-next-line react-hooks/exhaustive-deps
1613
- [R, w, M, s, f, S, U, x]
1614
- ), zn = Nr ? `nvr_compare_dismiss:${Nr}` : null, [As, Na] = D(() => {
1641
+ [R, w, M, s, f, S, J, x]
1642
+ ), zn = Nr ? `nvr_compare_dismiss:${Nr}` : null, [As, Na] = W(() => {
1615
1643
  try {
1616
1644
  return !zn || typeof window > "u" ? /* @__PURE__ */ new Set() : new Set(JSON.parse(window.localStorage.getItem(zn) ?? "[]"));
1617
1645
  } catch {
@@ -1619,10 +1647,10 @@ function dc({
1619
1647
  }
1620
1648
  }), Is = L(
1621
1649
  // `add` proposals need the plan grid's per-period arithmetic; the flat grid only fills.
1622
- () => ((O == null ? void 0 : O.proposals) ?? []).filter(
1650
+ () => ((A == null ? void 0 : A.proposals) ?? []).filter(
1623
1651
  (e) => e.mode !== "add" && !As.has(e.id)
1624
1652
  ),
1625
- [O == null ? void 0 : O.proposals, As]
1653
+ [A == null ? void 0 : A.proposals, As]
1626
1654
  ), gi = At(
1627
1655
  (e, n = !0) => {
1628
1656
  Na((t) => {
@@ -1638,15 +1666,15 @@ function dc({
1638
1666
  [zn]
1639
1667
  ), Sa = At(
1640
1668
  (e) => {
1641
- if (!O) return;
1642
- const n = O.key_field, t = e.change_reason ?? e.label, r = (d) => d == null || d === "" || Number(d) === 0;
1669
+ if (!A) return;
1670
+ const n = A.key_field, t = e.change_reason ?? e.label, r = (d) => d == null || d === "" || Number(d) === 0;
1643
1671
  let i = 0;
1644
1672
  const o = (w == null ? void 0 : w.getPendingEdits(s, f)) ?? /* @__PURE__ */ new Map();
1645
1673
  for (const d of e.rows) {
1646
1674
  if (d.category != null) continue;
1647
- const u = E.find((g) => String(g[n]) === String(d.key)), c = R.findIndex((g) => String(g[n]) === String(d.key)), l = u ? { ...u, ...o.get(String(u.id)) ?? {} } : c >= 0 ? R[c] : null, m = {};
1675
+ const u = O.find((g) => String(g[n]) === String(d.key)), c = R.findIndex((g) => String(g[n]) === String(d.key)), l = u ? { ...u, ...o.get(String(u.id)) ?? {} } : c >= 0 ? R[c] : null, m = {};
1648
1676
  for (const [g, b] of Object.entries(d.values))
1649
- Wt(O, d.key, g) || l && !r(l[g]) || (m[g] = b);
1677
+ Wt(A, d.key, g) || l && !r(l[g]) || (m[g] = b);
1650
1678
  Object.keys(m).length !== 0 && (i++, u ? bn(String(u.id), m, t) : c >= 0 ? bn(`pending:${c}`, m, t) : w && w.queueRow(
1651
1679
  s,
1652
1680
  f,
@@ -1659,8 +1687,8 @@ function dc({
1659
1687
  },
1660
1688
  // eslint-disable-next-line react-hooks/exhaustive-deps
1661
1689
  [
1690
+ A,
1662
1691
  O,
1663
- E,
1664
1692
  R,
1665
1693
  w,
1666
1694
  s,
@@ -1674,8 +1702,8 @@ function dc({
1674
1702
  if (!((v = ye == null ? void 0 : ye.fields) != null && v.length)) return;
1675
1703
  const n = ft(ye.remaining, Gt), t = n == null || !Number.isFinite(n) ? 0 : Math.round(n * 100) / 100;
1676
1704
  if (t <= 0) return;
1677
- const r = ye.only_empty !== !1, i = (_) => _ == null || _ === "" || Number(_) === 0, o = (w == null ? void 0 : w.getPendingEdits(s, f)) ?? /* @__PURE__ */ new Map(), d = (w == null ? void 0 : w.getPendingDeletes(s, f)) ?? /* @__PURE__ */ new Set(), u = O == null ? void 0 : O.key_field, c = [];
1678
- for (const _ of E) {
1705
+ const r = ye.only_empty !== !1, i = (_) => _ == null || _ === "" || Number(_) === 0, o = (w == null ? void 0 : w.getPendingEdits(s, f)) ?? /* @__PURE__ */ new Map(), d = (w == null ? void 0 : w.getPendingDeletes(s, f)) ?? /* @__PURE__ */ new Set(), u = A == null ? void 0 : A.key_field, c = [];
1706
+ for (const _ of O) {
1679
1707
  const h = String(_.id);
1680
1708
  d.has(h) || c.push({ id: h, row: { ..._, ...o.get(h) ?? {} } });
1681
1709
  }
@@ -1683,7 +1711,7 @@ function dc({
1683
1711
  const l = [], m = [];
1684
1712
  for (const _ of c)
1685
1713
  for (const h of ye.fields)
1686
- r && !i(_.row[h]) || O && Wt(O, _.row[O.key_field], h) || (l.push({ id: _.id, field: h }), m.push(0));
1714
+ r && !i(_.row[h]) || A && Wt(A, _.row[A.key_field], h) || (l.push({ id: _.id, field: h }), m.push(0));
1687
1715
  if (l.length === 0) {
1688
1716
  ge.message("Nothing to spread into — every target is filled or closed");
1689
1717
  return;
@@ -1715,13 +1743,13 @@ function dc({
1715
1743
  w,
1716
1744
  s,
1717
1745
  f,
1746
+ A,
1718
1747
  O,
1719
- E,
1720
1748
  R,
1721
1749
  bn
1722
1750
  ]
1723
1751
  ), Ct = Ue == null ? void 0 : Ue.report;
1724
- ke(() => {
1752
+ _e(() => {
1725
1753
  if (Ct) {
1726
1754
  if (qs || un) {
1727
1755
  Ct(s, f, null);
@@ -1732,7 +1760,7 @@ function dc({
1732
1760
  }, [Ct, s, f, Jn, qs, un]);
1733
1761
  const js = ue(() => {
1734
1762
  });
1735
- js.current = () => Ct == null ? void 0 : Ct(s, f, null), ke(() => () => js.current(), []);
1763
+ js.current = () => Ct == null ? void 0 : Ct(s, f, null), _e(() => () => js.current(), []);
1736
1764
  const Bn = L(() => {
1737
1765
  const e = /* @__PURE__ */ new Map();
1738
1766
  for (const n of xe) {
@@ -1892,8 +1920,8 @@ function dc({
1892
1920
  e.set(n, i);
1893
1921
  }
1894
1922
  return e;
1895
- }, [Xt, qt, Us, yn]), Or = L(() => E.map((e) => String(e.id)), [E]), Fn = L(
1896
- () => `nvr-gf-${Math.abs(gd(`${s}:${P ?? f}`)) % 1e5}`,
1923
+ }, [Xt, qt, Us, yn]), Or = L(() => O.map((e) => String(e.id)), [O]), Fn = L(
1924
+ () => `nvr-gf-${Math.abs(bd(`${s}:${P ?? f}`)) % 1e5}`,
1897
1925
  [s, P, f]
1898
1926
  ), Js = L(() => {
1899
1927
  if (!F) return null;
@@ -1917,10 +1945,10 @@ function dc({
1917
1945
  I,
1918
1946
  M,
1919
1947
  T
1920
- ]), [vn, Oa] = D(150), Qs = ue(null);
1921
- ke(() => {
1948
+ ]), [vn, Oa] = W(150), Qs = ue(null);
1949
+ _e(() => {
1922
1950
  const e = Qs.current;
1923
- if (!e || E.length <= vn) return;
1951
+ if (!e || O.length <= vn) return;
1924
1952
  const n = new IntersectionObserver(
1925
1953
  (t) => {
1926
1954
  t.some((r) => r.isIntersecting) && Oa((r) => r + 150);
@@ -1928,8 +1956,8 @@ function dc({
1928
1956
  { rootMargin: "400px" }
1929
1957
  );
1930
1958
  return n.observe(e), () => n.disconnect();
1931
- }, [E.length, vn]);
1932
- const Aa = Or.join(","), Ia = sd(
1959
+ }, [O.length, vn]);
1960
+ const Aa = Or.join(","), Ia = od(
1933
1961
  s,
1934
1962
  Or,
1935
1963
  !!ne && !I
@@ -1969,7 +1997,7 @@ function dc({
1969
1997
  e.set(n, i);
1970
1998
  }), e;
1971
1999
  }, [Xt, qt, zs]), Bs = It == null ? void 0 : It.report;
1972
- ke(() => {
2000
+ _e(() => {
1973
2001
  if (!Bs || !X || X.length === 0) return;
1974
2002
  const e = `${s}.${f}`, n = (r, i) => {
1975
2003
  const o = {};
@@ -1992,7 +2020,7 @@ function dc({
1992
2020
  for (const [c, l] of Y) {
1993
2021
  const m = l[`__nested_ops_${i}`];
1994
2022
  if (!m) continue;
1995
- const g = E.find((v) => String(v.id) === c), b = n(
2023
+ const g = O.find((v) => String(v.id) === c), b = n(
1996
2024
  de({ ...g ?? {}, ...l }),
1997
2025
  d
1998
2026
  );
@@ -2168,11 +2196,11 @@ function dc({
2168
2196
  `${m.id}:${g}`
2169
2197
  )) });
2170
2198
  }
2171
- const Le = $t && (Rs.length > 0 || Fs.length > 0) ? [...Rs, ...Fs] : ve, wn = ue(null), [ja, xi] = D(0), Ys = ue(/* @__PURE__ */ new Map()), Tt = ue(0), Gs = 1e4, gt = (e) => Ys.current.set(String(e), Date.now());
2199
+ const Le = $t && (Rs.length > 0 || Fs.length > 0) ? [...Rs, ...Fs] : ve, wn = ue(null), [ja, xi] = W(0), Ys = ue(/* @__PURE__ */ new Map()), Tt = ue(0), Gs = 1e4, gt = (e) => Ys.current.set(String(e), Date.now());
2172
2200
  mn.current = async (e, n, t) => {
2173
- const r = await Fl(S, Nt, e, n, t, {
2201
+ const r = await Hl(S, Nt, e, n, t, {
2174
2202
  key: `${s}.${f}`,
2175
- label: Hl(E, n, C)
2203
+ label: Yl(O, n, C)
2176
2204
  });
2177
2205
  return r.ok ? (gt(n), !0) : (ii.current.push(r.conflict), !1);
2178
2206
  };
@@ -2185,8 +2213,8 @@ function dc({
2185
2213
  let t = 0;
2186
2214
  for (const r of n) {
2187
2215
  const i = new Set(
2188
- r.conflicts.filter((d) => e.has(Yl(r, d.field))).map((d) => d.field)
2189
- ), o = Gl(r.mine, i);
2216
+ r.conflicts.filter((d) => e.has(Gl(r, d.field))).map((d) => d.field)
2217
+ ), o = Cl(r.mine, i);
2190
2218
  if (o) {
2191
2219
  r.latest > 0 && Nt.set(r.rowId, r.latest);
2192
2220
  try {
@@ -2196,7 +2224,7 @@ function dc({
2196
2224
  }
2197
2225
  }
2198
2226
  }
2199
- Pn(), U.invalidateQueries({ queryKey: ["o2m-rows", s, f, x] }), t === 0 && n.length > 0 && ge.success("Kept the newer values");
2227
+ Pn(), J.invalidateQueries({ queryKey: ["o2m-rows", s, f, x] }), t === 0 && n.length > 0 && ge.success("Kept the newer values");
2200
2228
  }, Yn = ve.map((e) => e.field).filter((e) => !e.includes(".")).join(","), Et = At(
2201
2229
  (e) => {
2202
2230
  const n = {};
@@ -2214,7 +2242,7 @@ function dc({
2214
2242
  const t = Ys.current.get(e);
2215
2243
  return !!t && n - t < Gs;
2216
2244
  };
2217
- ke(() => {
2245
+ _e(() => {
2218
2246
  if (I || un || !Yn) return;
2219
2247
  if (!wn.current) {
2220
2248
  wn.current = new Map(ze.map((i) => [String(i.id), Et(i)])), xi((i) => i + 1);
@@ -2248,7 +2276,7 @@ function dc({
2248
2276
  return t.size === 0 && r.size === 0 && i.length === 0 ? null : { added: t, changed: r, removed: i, total: t.size + r.size + i.length };
2249
2277
  }, [ze, ja, ui, I, Et]), Ka = () => {
2250
2278
  wn.current = new Map(ze.map((e) => [String(e.id), Et(e)])), xi((e) => e + 1);
2251
- }, _n = ue(null), [Lr, Cs] = D({}), kn = L(() => {
2279
+ }, _n = ue(null), [Lr, Cs] = W({}), kn = L(() => {
2252
2280
  const e = _n.current, n = p == null ? void 0 : p.rowId;
2253
2281
  if (!e || !n || e.rowId !== n || n === "new" || n.startsWith("pending:")) return [];
2254
2282
  const t = ze.find((o) => String(o.id) === n);
@@ -2334,7 +2362,7 @@ function dc({
2334
2362
  r.who && e.add(r.who);
2335
2363
  }
2336
2364
  return [...e];
2337
- }, [dt, si]), [Ye, Zt] = D(null), wi = ue(/* @__PURE__ */ new Set()), eo = (e, n) => JSON.stringify([e, n]), [Nn, Ma] = D(() => /* @__PURE__ */ new Map()), to = ue(""), _i = ue(() => {
2365
+ }, [dt, si]), [Ye, Zt] = W(null), wi = ue(/* @__PURE__ */ new Set()), eo = (e, n) => JSON.stringify([e, n]), [Nn, Ma] = W(() => /* @__PURE__ */ new Map()), to = ue(""), _i = ue(() => {
2338
2366
  }), Ra = (e) => {
2339
2367
  const n = lr.current;
2340
2368
  if (!n) return null;
@@ -2346,7 +2374,7 @@ function dc({
2346
2374
  }
2347
2375
  return null;
2348
2376
  }, no = !ps && (I || !un);
2349
- ke(() => {
2377
+ _e(() => {
2350
2378
  const e = lr.current;
2351
2379
  if (!e || !no || typeof MutationObserver > "u") return;
2352
2380
  const n = `${s}:`, t = () => {
@@ -2372,14 +2400,14 @@ function dc({
2372
2400
  r.disconnect(), _i.current = () => {
2373
2401
  };
2374
2402
  };
2375
- }, [no, s]), ke(() => {
2403
+ }, [no, s]), _e(() => {
2376
2404
  const e = wi.current;
2377
2405
  for (const n of [...e]) {
2378
2406
  const [t, r] = JSON.parse(n);
2379
2407
  Nn.get(t) !== r && e.delete(n);
2380
2408
  }
2381
2409
  Ye && Nn.get(Ye.rowKey) !== Ye.editor && Zt(null);
2382
- }, [Nn, Ye]), ke(() => {
2410
+ }, [Nn, Ye]), _e(() => {
2383
2411
  if (!Ye || typeof window > "u") return;
2384
2412
  const e = (n) => {
2385
2413
  n.key === "Escape" && Zt(null);
@@ -2389,27 +2417,27 @@ function dc({
2389
2417
  const ki = L(() => {
2390
2418
  if (Nn.size === 0) return [];
2391
2419
  const e = [];
2392
- return E.forEach((n, t) => {
2420
+ return O.forEach((n, t) => {
2393
2421
  const r = Nn.get(String(n.id));
2394
2422
  if (!r) return;
2395
2423
  const i = n.line_number, o = typeof i == "number" || typeof i == "string" && i.trim() !== "";
2396
2424
  e.push(`${r} is editing line ${String(o ? i : t + 1)}`);
2397
2425
  }), e;
2398
- }, [Nn, E]);
2399
- ke(() => {
2426
+ }, [Nn, O]);
2427
+ _e(() => {
2400
2428
  if (!Ce || I) return;
2401
2429
  let e = null;
2402
2430
  const n = Ce.subscribeCollections([s], () => {
2403
2431
  e && clearTimeout(e), e = setTimeout(() => {
2404
- e = null, U.invalidateQueries({ queryKey: ["o2m-rows", s, f, x] });
2432
+ e = null, J.invalidateQueries({ queryKey: ["o2m-rows", s, f, x] });
2405
2433
  }, 1500);
2406
2434
  });
2407
2435
  return () => {
2408
2436
  n(), e && clearTimeout(e);
2409
2437
  };
2410
- }, [Ce, s, f, x, I, U]);
2438
+ }, [Ce, s, f, x, I, J]);
2411
2439
  const ro = ue(null);
2412
- ke(() => {
2440
+ _e(() => {
2413
2441
  const e = {
2414
2442
  edits: new Set(Y.keys()),
2415
2443
  deletes: new Set(Je),
@@ -2421,7 +2449,7 @@ function dc({
2421
2449
  e.pending < n.pending && (Tt.current = Date.now());
2422
2450
  }
2423
2451
  }, [ui]);
2424
- const Ni = L(() => _d(xe), [xe]), io = L(
2452
+ const Ni = L(() => kd(xe), [xe]), io = L(
2425
2453
  () => xe.filter(
2426
2454
  (e) => e.group_key === "__create_with_defaults__" && !Gi.has(e.type ?? "") && !Yi.has(e.field)
2427
2455
  ),
@@ -2467,13 +2495,13 @@ function dc({
2467
2495
  (u) => !!u
2468
2496
  ), o = i.length === 1 ? i[0] : { _and: i }, d = [
2469
2497
  ...new Set(
2470
- [...E, ...R].map((u) => u[t]).filter((u) => u != null && u !== "").map(String)
2498
+ [...O, ...R].map((u) => u[t]).filter((u) => u != null && u !== "").map(String)
2471
2499
  )
2472
2500
  ].sort();
2473
2501
  d.length && e.push({ field: t, target: r.one_collection, filter: o, ids: d });
2474
2502
  }
2475
2503
  return e;
2476
- }, [et, Si, Fe, E, R]), so = on({
2504
+ }, [et, Si, Fe, O, R]), so = on({
2477
2505
  queries: $i.map((e) => ({
2478
2506
  queryKey: [
2479
2507
  "cascade-stale-sweep",
@@ -2499,7 +2527,7 @@ function dc({
2499
2527
  if (!r) return;
2500
2528
  const i = /* @__PURE__ */ new Set();
2501
2529
  if (Bn.has(n.field))
2502
- for (const u of [...E, ...R]) {
2530
+ for (const u of [...O, ...R]) {
2503
2531
  const c = Vn(n.field, u);
2504
2532
  (c == null ? void 0 : c.id) != null && i.add(String(c.id));
2505
2533
  }
@@ -2512,10 +2540,10 @@ function dc({
2512
2540
  Bn,
2513
2541
  qr,
2514
2542
  N == null ? void 0 : N.draft,
2515
- E,
2543
+ O,
2516
2544
  R
2517
2545
  ]), Tr = ue(/* @__PURE__ */ new Set()), Ei = ue(!1);
2518
- ke(() => {
2546
+ _e(() => {
2519
2547
  var t;
2520
2548
  if ($ || !S || Ei.current) return;
2521
2549
  const e = N == null ? void 0 : N.dirtyFields;
@@ -2627,7 +2655,7 @@ function dc({
2627
2655
  const ce = await B(G);
2628
2656
  w == null || w.updateRow(s, f, se, { ...G, ...ce }), r++;
2629
2657
  }
2630
- const yt = E.filter((G) => {
2658
+ const yt = O.filter((G) => {
2631
2659
  var re;
2632
2660
  const se = String(G.id);
2633
2661
  if (Je.has(se)) return !1;
@@ -2653,7 +2681,7 @@ function dc({
2653
2681
  (re) => re && re.rowId === se ? { ...re, draft: de({ ...re.draft, ...ce }) } : re
2654
2682
  );
2655
2683
  }
2656
- yt.length && !((M || I) && w) && await U.invalidateQueries({
2684
+ yt.length && !((M || I) && w) && await J.invalidateQueries({
2657
2685
  queryKey: ["o2m-rows", s, f, x]
2658
2686
  });
2659
2687
  }
@@ -2668,14 +2696,14 @@ function dc({
2668
2696
  }));
2669
2697
  }, [qi, et, N == null ? void 0 : N.dirtyFields, qr]);
2670
2698
  const Gn = L(() => {
2671
- const e = /* @__PURE__ */ new Map(), n = [...E, ...R], t = [...Y.values()], r = wt.flatMap((i) => i.rows);
2699
+ const e = /* @__PURE__ */ new Map(), n = [...O, ...R], t = [...Y.values()], r = wt.flatMap((i) => i.rows);
2672
2700
  for (const [i, o] of Fe) {
2673
2701
  if (!o.one_collection) continue;
2674
2702
  const d = n.map((m) => m[i]).filter((m) => m != null).map(String), u = t.map((m) => m[i]).filter((m) => m != null).map(String), c = r.map((m) => m[i]).filter((m) => m != null).map(String), l = [.../* @__PURE__ */ new Set([...d, ...u, ...c])].sort();
2675
2703
  l.length && e.set(o.one_collection, l);
2676
2704
  }
2677
2705
  return e;
2678
- }, [E, R, Y, Fe, wt]), Pa = L(() => {
2706
+ }, [O, R, Y, Fe, wt]), Pa = L(() => {
2679
2707
  const e = /* @__PURE__ */ new Map();
2680
2708
  for (const n of ve) {
2681
2709
  const t = Fe.get(n.field);
@@ -2696,7 +2724,7 @@ function dc({
2696
2724
  queryFn: async () => {
2697
2725
  const e = {}, n = await Promise.all(
2698
2726
  [...Gn.keys()].map(
2699
- (t) => U.fetchQuery({
2727
+ (t) => J.fetchQuery({
2700
2728
  queryKey: ["collection-display-meta", t],
2701
2729
  queryFn: () => S.request(
2702
2730
  ie(`/collections/${t}`)
@@ -2742,9 +2770,9 @@ function dc({
2742
2770
  () => te != null && te.unmatched_banner ? R.map((e) => de({ ...e })) : void 0,
2743
2771
  // eslint-disable-next-line react-hooks/exhaustive-deps
2744
2772
  [te == null ? void 0 : te.unmatched_banner, R]
2745
- ), Kt = ld({
2773
+ ), Kt = dd({
2746
2774
  config: te,
2747
- rows: E,
2775
+ rows: O,
2748
2776
  stagedRows: Ua,
2749
2777
  relatedCollection: s,
2750
2778
  childRelations: Re,
@@ -2767,7 +2795,7 @@ function dc({
2767
2795
  fk_field: f,
2768
2796
  ...I ? {} : { parent_id: x },
2769
2797
  parent_context: Mt(),
2770
- parent_collection: A,
2798
+ parent_collection: E,
2771
2799
  row_rules: K,
2772
2800
  mode: Li,
2773
2801
  dry_run: e || n || t.length > 0,
@@ -2811,7 +2839,7 @@ function dc({
2811
2839
  fk_field: f,
2812
2840
  parent_id: x,
2813
2841
  parent_context: Mt(),
2814
- parent_collection: A,
2842
+ parent_collection: E,
2815
2843
  row_rules: K,
2816
2844
  mode: Li,
2817
2845
  dry_run: !1,
@@ -2821,7 +2849,7 @@ function dc({
2821
2849
  o.applied = c.data.applied + d.length, o.failed = c.data.failed;
2822
2850
  }
2823
2851
  for (const c of u) gt(String(c.id));
2824
- U.invalidateQueries({ queryKey: ["o2m-rows", s, f, x] }), U.invalidateQueries({
2852
+ J.invalidateQueries({ queryKey: ["o2m-rows", s, f, x] }), J.invalidateQueries({
2825
2853
  queryKey: ["o2m-field-snapshots", s, f, x]
2826
2854
  }), o.failed.length ? ge.error(
2827
2855
  `Rules applied to ${o.applied} ${o.applied === 1 ? "line" : "lines"} — ${o.failed.length} failed: ${o.failed.slice(0, 3).map((c) => `#${c.id} ${c.error}`).join("; ")}`
@@ -2835,8 +2863,8 @@ function dc({
2835
2863
  function Mt() {
2836
2864
  const e = {};
2837
2865
  if (N != null && N.draft) {
2838
- if (_e != null && _e.length)
2839
- for (const n of _e) e[n] = N.draft[n] ?? null;
2866
+ if (ke != null && ke.length)
2867
+ for (const n of ke) e[n] = N.draft[n] ?? null;
2840
2868
  for (const n of K ?? []) {
2841
2869
  const t = n.trigger_field;
2842
2870
  if (typeof t == "string" && t.startsWith("$parent.")) {
@@ -2855,7 +2883,7 @@ function dc({
2855
2883
  locks_only: !0,
2856
2884
  probe: !0,
2857
2885
  parent_context: Mt(),
2858
- parent_collection: A,
2886
+ parent_collection: E,
2859
2887
  row_rules: K
2860
2888
  })
2861
2889
  ).then((t) => {
@@ -2898,11 +2926,11 @@ function dc({
2898
2926
  const r = de({ ...e });
2899
2927
  _n.current = { rowId: n, snap: Et(e) }, Oi(n), Me({ rowId: n, draft: r, locksPending: Tn.size > 0 }), Kr(n, r);
2900
2928
  }
2901
- ke(() => {
2929
+ _e(() => {
2902
2930
  const e = (n) => {
2903
2931
  const t = n.detail;
2904
2932
  if (!t || t.collection !== s || t.field !== f || !t.rowId) return;
2905
- const r = E.find((i) => String(i.id) === String(t.rowId));
2933
+ const r = O.find((i) => String(i.id) === String(t.rowId));
2906
2934
  r && (Mr(r), window.setTimeout(() => {
2907
2935
  const i = document.querySelector(
2908
2936
  `[data-o2m-row="${s}:${String(t.rowId)}"]`
@@ -2911,7 +2939,7 @@ function dc({
2911
2939
  }, 120));
2912
2940
  };
2913
2941
  return window.addEventListener("nvr:grid-open-row", e), () => window.removeEventListener("nvr:grid-open-row", e);
2914
- }, [s, f, E]);
2942
+ }, [s, f, O]);
2915
2943
  function lo(e, n) {
2916
2944
  if ($) return;
2917
2945
  const t = `pending:${n}`;
@@ -2951,7 +2979,7 @@ function dc({
2951
2979
  target_fields: [e],
2952
2980
  probe: !0,
2953
2981
  parent_context: Mt(),
2954
- parent_collection: A,
2982
+ parent_collection: E,
2955
2983
  row_rules: K
2956
2984
  })
2957
2985
  ).then(
@@ -2998,7 +3026,7 @@ function dc({
2998
3026
  const t = { ...e };
2999
3027
  if (n.rowDeleted || !n.itemId) {
3000
3028
  delete t.id;
3001
- for (const r of Object.keys(t)) Do.has(r) && delete t[r];
3029
+ for (const r of Object.keys(t)) Po.has(r) && delete t[r];
3002
3030
  delete t[f], Me({
3003
3031
  rowId: "new",
3004
3032
  draft: hn(t),
@@ -3069,7 +3097,7 @@ function dc({
3069
3097
  };
3070
3098
  if (De != null && De.length) {
3071
3099
  const l = p.rowId.startsWith("pending:"), m = l ? parseInt(p.rowId.split(":")[1], 10) : null, g = p.rowId === "new" || l ? null : p.rowId, b = Hi(p.draft, De);
3072
- if (E.some((_) => {
3100
+ if (O.some((_) => {
3073
3101
  if (String(_.id) === g || Je.has(String(_.id))) return !1;
3074
3102
  const h = Y.has(String(_.id)) ? { ..._, ...Y.get(String(_.id)) } : _;
3075
3103
  return Hi(h, De) === b;
@@ -3089,10 +3117,10 @@ function dc({
3089
3117
  const i = $s(p.rowId), o = ve.flatMap((l) => {
3090
3118
  var g;
3091
3119
  if (nr(l) || (g = p.locks) != null && g.includes(l.field)) return [];
3092
- if (!Xl.has(l.type ?? "")) return [];
3120
+ if (!Zl.has(l.type ?? "")) return [];
3093
3121
  if (i && String(i[l.field] ?? "") === String(p.draft[l.field] ?? ""))
3094
3122
  return [];
3095
- const m = Zl(p.draft[l.field], {
3123
+ const m = ed(p.draft[l.field], {
3096
3124
  type: l.type,
3097
3125
  label: l.label || Ne(l.field)
3098
3126
  });
@@ -3100,7 +3128,7 @@ function dc({
3100
3128
  });
3101
3129
  if (o.length > 0)
3102
3130
  return Lt(o.map((l) => l.message).join(" · ")), Me((l) => l && { ...l, missing: o.map((m) => m.field) }), !1;
3103
- const d = i ? Wo(p.draft, i, new Set(Object.keys(p.draft))) : p.draft, u = ed(
3131
+ const d = i ? Do(p.draft, i, new Set(Object.keys(p.draft))) : p.draft, u = td(
3104
3132
  xe.map((l) => ({
3105
3133
  field: l.field,
3106
3134
  label: l.label || Ne(l.field),
@@ -3115,14 +3143,14 @@ function dc({
3115
3143
  if (We != null && We.field && We.cap) {
3116
3144
  const l = ft(We.cap, Gt);
3117
3145
  if (l != null) {
3118
- const m = We.field, g = de({ ...p.draft }), b = p.rowId.startsWith("pending:") ? Number(p.rowId.slice(8)) : -1, v = (E ?? []).some((q) => String(q.id) === p.rowId), _ = (E ?? []).filter((q) => !Je.has(String(q.id)) && String(q.id) !== p.rowId).reduce((q, V) => {
3146
+ const m = We.field, g = de({ ...p.draft }), b = p.rowId.startsWith("pending:") ? Number(p.rowId.slice(8)) : -1, v = (O ?? []).some((q) => String(q.id) === p.rowId), _ = (O ?? []).filter((q) => !Je.has(String(q.id)) && String(q.id) !== p.rowId).reduce((q, V) => {
3119
3147
  const B = String(V.id), Te = Y.has(B) ? { ...V, ...Y.get(B) } : V;
3120
3148
  return q + (Number(de(Te)[m]) || 0);
3121
3149
  }, 0) + R.reduce(
3122
3150
  (q, V, B) => B === b ? q : q + (Number(de(V)[m]) || 0),
3123
3151
  0
3124
3152
  ), h = v ? (() => {
3125
- const q = (E ?? []).find((B) => String(B.id) === p.rowId), V = Y.has(p.rowId) ? { ...q, ...Y.get(p.rowId) } : q;
3153
+ const q = (O ?? []).find((B) => String(B.id) === p.rowId), V = Y.has(p.rowId) ? { ...q, ...Y.get(p.rowId) } : q;
3126
3154
  return Number(de(V)[m]) || 0;
3127
3155
  })() : b >= 0 && Number(
3128
3156
  de(R[b])[m]
@@ -3167,7 +3195,7 @@ function dc({
3167
3195
  _change_reason: j
3168
3196
  })
3169
3197
  );
3170
- Tt.current = Date.now(), ((V = q == null ? void 0 : q.data) == null ? void 0 : V.id) != null && gt(String(q.data.id)), U.invalidateQueries({
3198
+ Tt.current = Date.now(), ((V = q == null ? void 0 : q.data) == null ? void 0 : V.id) != null && gt(String(q.data.id)), J.invalidateQueries({
3171
3199
  queryKey: ["o2m-rows", s, f, x]
3172
3200
  }), n();
3173
3201
  }
@@ -3232,7 +3260,7 @@ function dc({
3232
3260
  groups: h
3233
3261
  });
3234
3262
  }
3235
- U.invalidateQueries({ queryKey: ["o2m-rows", s, f, x] });
3263
+ J.invalidateQueries({ queryKey: ["o2m-rows", s, f, x] });
3236
3264
  } else {
3237
3265
  const l = (K ?? []).filter((h) => h.target_type !== "lock").map((h) => h.target_field).filter((h) => typeof h == "string" && h.length > 0 && h !== "id"), m = /* @__PURE__ */ new Set([
3238
3266
  ...ve.map((h) => h.field).filter((h) => !h.startsWith("__m2m_")),
@@ -3240,7 +3268,7 @@ function dc({
3240
3268
  // A reason an editor action prefilled (carry-forward) rides the row:
3241
3269
  // the server stores it on the activity row, never in a column.
3242
3270
  "_change_reason"
3243
- ]), g = E.find((h) => String(h.id) === p.rowId), b = Wo(p.draft, g, m);
3271
+ ]), g = O.find((h) => String(h.id) === p.rowId), b = Do(p.draft, g, m);
3244
3272
  if (M && w) {
3245
3273
  const h = Object.entries(p.draft).filter(
3246
3274
  ([q]) => q.startsWith("__nested_ops_")
@@ -3270,20 +3298,20 @@ function dc({
3270
3298
  retry: async (V) => {
3271
3299
  await S.request(
3272
3300
  Vr(q, _({ ...b, _change_reason: V }))
3273
- ), en.current.delete(e), Nt.forget(e), gt(e), U.invalidateQueries({
3301
+ ), en.current.delete(e), Nt.forget(e), gt(e), J.invalidateQueries({
3274
3302
  queryKey: ["o2m-rows", s, f, x]
3275
3303
  }), n();
3276
3304
  }
3277
3305
  }), cn(!1), !1;
3278
3306
  }
3279
- const j = ql(h);
3307
+ const j = El(h);
3280
3308
  if (j)
3281
- return en.current.set(e, Promise.resolve(j.latest || null)), j.latest > 0 && Nt.set(e, j.latest), U.invalidateQueries({ queryKey: ["o2m-rows", s, f, x] }), ge.warning(
3309
+ return en.current.set(e, Promise.resolve(j.latest || null)), j.latest > 0 && Nt.set(e, j.latest), J.invalidateQueries({ queryKey: ["o2m-rows", s, f, x] }), ge.warning(
3282
3310
  "Someone else changed this line while you edited it — take their values or keep yours, then save again"
3283
3311
  ), cn(!1), !1;
3284
3312
  throw h;
3285
3313
  }
3286
- en.current.delete(e), Nt.forget(e), gt(e), U.invalidateQueries({ queryKey: ["o2m-rows", s, f, x] });
3314
+ en.current.delete(e), Nt.forget(e), gt(e), J.invalidateQueries({ queryKey: ["o2m-rows", s, f, x] });
3287
3315
  }
3288
3316
  return n(), !0;
3289
3317
  } catch {
@@ -3292,7 +3320,7 @@ function dc({
3292
3320
  cn(!1);
3293
3321
  }
3294
3322
  }
3295
- const [Ba, Va] = D(/* @__PURE__ */ new Set()), [bt, mo] = D(null), [Pt, po] = D(null), [Fa, ho] = D(!1), [tn, Ha] = D(1), [nn, $n] = D(!1), [go, Ya] = D(!1), [ji, Ga] = D({}), [bo, yo] = D(!1), [xo, Rr] = D(!1), [Li, Ca] = D("empty-only"), [Pr, vo] = D(null), [Dt, qn] = D(null), [rn, wo] = D({}), [_o, ko] = D(!1);
3323
+ const [Ba, Va] = W(/* @__PURE__ */ new Set()), [bt, mo] = W(null), [Pt, po] = W(null), [Fa, ho] = W(!1), [tn, Ha] = W(1), [nn, $n] = W(!1), [go, Ya] = W(!1), [ji, Ga] = W({}), [bo, yo] = W(!1), [xo, Rr] = W(!1), [Li, Ca] = W("empty-only"), [Pr, vo] = W(null), [Dt, qn] = W(null), [rn, wo] = W({}), [_o, ko] = W(!1);
3296
3324
  function Xa(e, n) {
3297
3325
  Ga((t) => ({ ...t, [e]: n }));
3298
3326
  }
@@ -3302,9 +3330,9 @@ function dc({
3302
3330
  )) {
3303
3331
  ko(!0);
3304
3332
  try {
3305
- if (E.length)
3333
+ if (O.length)
3306
3334
  if (M && w)
3307
- E.filter((n) => !Je.has(String(n.id))).forEach(
3335
+ O.filter((n) => !Je.has(String(n.id))).forEach(
3308
3336
  (n) => w.queueEdit(s, f, String(n.id), {
3309
3337
  ...rn,
3310
3338
  ...fn(String(n.id))
@@ -3313,7 +3341,7 @@ function dc({
3313
3341
  else
3314
3342
  try {
3315
3343
  await Promise.all(
3316
- E.map(
3344
+ O.map(
3317
3345
  (n) => mn.current(
3318
3346
  `/items/${s}/${n.id}${st}`,
3319
3347
  String(n.id),
@@ -3322,7 +3350,7 @@ function dc({
3322
3350
  )
3323
3351
  );
3324
3352
  } finally {
3325
- Pn(), U.invalidateQueries({
3353
+ Pn(), J.invalidateQueries({
3326
3354
  queryKey: ["o2m-rows", s, f, x]
3327
3355
  });
3328
3356
  }
@@ -3350,7 +3378,7 @@ function dc({
3350
3378
  await S.request(
3351
3379
  Ae(`/items/${s}${st}`, { ...i, [f]: x })
3352
3380
  );
3353
- Tt.current = Date.now(), U.invalidateQueries({ queryKey: ["o2m-rows", s, f, x] });
3381
+ Tt.current = Date.now(), J.invalidateQueries({ queryKey: ["o2m-rows", s, f, x] });
3354
3382
  } catch {
3355
3383
  } finally {
3356
3384
  $n(!1);
@@ -3361,7 +3389,7 @@ function dc({
3361
3389
  if (!e || Kt.unmatchedCandidates.length === 0) return;
3362
3390
  const n = Kt.unmatchedCandidates.map((t) => ({
3363
3391
  ...Yt,
3364
- ...dd(e, t)
3392
+ ...cd(e, t)
3365
3393
  }));
3366
3394
  if ((I || M) && w) {
3367
3395
  for (const t of gn(n)) w.queueRow(s, f, t);
@@ -3373,7 +3401,7 @@ function dc({
3373
3401
  await S.request(
3374
3402
  Ae(`/items/${s}${st}`, { ...t, [f]: x })
3375
3403
  );
3376
- Tt.current = Date.now(), U.invalidateQueries({ queryKey: ["o2m-rows", s, f, x] });
3404
+ Tt.current = Date.now(), J.invalidateQueries({ queryKey: ["o2m-rows", s, f, x] });
3377
3405
  } catch (t) {
3378
3406
  ge.error(`Could not add rows: ${In(t, "unknown error")}`);
3379
3407
  } finally {
@@ -3393,7 +3421,7 @@ function dc({
3393
3421
  await S.request(
3394
3422
  Ae(`/items/${s}${st}`, { ...r, [f]: x })
3395
3423
  );
3396
- Tt.current = Date.now(), U.invalidateQueries({ queryKey: ["o2m-rows", s, f, x] });
3424
+ Tt.current = Date.now(), J.invalidateQueries({ queryKey: ["o2m-rows", s, f, x] });
3397
3425
  } catch {
3398
3426
  } finally {
3399
3427
  $n(!1);
@@ -3413,7 +3441,7 @@ function dc({
3413
3441
  En();
3414
3442
  return;
3415
3443
  }
3416
- const n = [...E], [t] = n.splice(bt, 1);
3444
+ const n = [...O], [t] = n.splice(bt, 1);
3417
3445
  n.splice(Pt, 0, t);
3418
3446
  const r = n.map((i, o) => ({ row: i, newOrder: o })).filter(({ row: i, newOrder: o }) => {
3419
3447
  const d = M ? Y.get(String(i.id)) : void 0, u = (d == null ? void 0 : d[C]) ?? i[C];
@@ -3435,7 +3463,7 @@ function dc({
3435
3463
  Vr(`/items/${s}/${i.id}${st}`, { [C]: o })
3436
3464
  )
3437
3465
  )
3438
- ), U.invalidateQueries({ queryKey: ["o2m-rows", s, f, x] });
3466
+ ), J.invalidateQueries({ queryKey: ["o2m-rows", s, f, x] });
3439
3467
  } catch {
3440
3468
  } finally {
3441
3469
  ho(!1), En();
@@ -3449,7 +3477,7 @@ function dc({
3449
3477
  return;
3450
3478
  }
3451
3479
  try {
3452
- await S.request(Ho(`/items/${s}/${t}${st}`)), gt(String(t)), U.invalidateQueries({ queryKey: ["o2m-rows", s, f, x] }), (p == null ? void 0 : p.rowId) === String(t) && Me(null), W && U.invalidateQueries({
3480
+ await S.request(Ho(`/items/${s}/${t}${st}`)), gt(String(t)), J.invalidateQueries({ queryKey: ["o2m-rows", s, f, x] }), (p == null ? void 0 : p.rowId) === String(t) && Me(null), U && J.invalidateQueries({
3453
3481
  queryKey: ["o2m-field-snapshots", s, f, x]
3454
3482
  });
3455
3483
  } catch {
@@ -3467,7 +3495,7 @@ function dc({
3467
3495
  if (e.interface === "formula-column") {
3468
3496
  const m = typeof i.column_formula == "string" ? i.column_formula : "";
3469
3497
  if (!m || !t && !r) return /* @__PURE__ */ a("span", { className: "text-slate-300", children: "—" });
3470
- const g = r ?? E.find((y) => String(y.id) === t) ?? {}, b = (y) => typeof y == "string" && /^-?\d+(\.\d+)?$/.test(y.trim()) ? Number(y) : y, v = ft(
3498
+ const g = r ?? O.find((y) => String(y.id) === t) ?? {}, b = (y) => typeof y == "string" && /^-?\d+(\.\d+)?$/.test(y.trim()) ? Number(y) : y, v = ft(
3471
3499
  m,
3472
3500
  (y) => {
3473
3501
  var j, q;
@@ -3490,7 +3518,7 @@ function dc({
3490
3518
  if (e.interface === "match-agg-column") {
3491
3519
  const m = ya.get(e.field);
3492
3520
  if (!m || !t) return /* @__PURE__ */ a("span", { className: "text-slate-300", children: "—" });
3493
- const g = E.find((y) => String(y.id) === t) ?? {}, b = (y, j) => j.split(".").reduce(
3521
+ const g = O.find((y) => String(y.id) === t) ?? {}, b = (y, j) => j.split(".").reduce(
3494
3522
  (q, V) => q && typeof q == "object" ? q[V] : void 0,
3495
3523
  y
3496
3524
  ), v = m.rows.filter(
@@ -3532,7 +3560,7 @@ function dc({
3532
3560
  }
3533
3561
  if (n == null) return /* @__PURE__ */ a("span", { className: "text-slate-300", children: "—" });
3534
3562
  if (e.interface === "relation-path" && pe && t) {
3535
- const m = Ro(e), g = (u = qe == null ? void 0 : qe.rows[t]) == null ? void 0 : u[e.field], b = qe == null ? void 0 : qe.targets[e.field];
3563
+ const m = Mo(e), g = (u = qe == null ? void 0 : qe.rows[t]) == null ? void 0 : u[e.field], b = qe == null ? void 0 : qe.targets[e.field];
3536
3564
  if (m && g && b && g.ids.length > 0)
3537
3565
  return /* @__PURE__ */ a(
3538
3566
  "button",
@@ -3557,7 +3585,7 @@ function dc({
3557
3585
  const m = (c = Sn[o.one_collection]) == null ? void 0 : c[String(n)];
3558
3586
  if (!m && Wa)
3559
3587
  return /* @__PURE__ */ a(jn, { className: "h-3 w-3 animate-spin text-slate-300" });
3560
- const g = pe ? Ro(e) : null, b = n != null && ((l = qi.get(e.field)) == null ? void 0 : l.has(String(n))) === !0;
3588
+ const g = pe ? Mo(e) : null, b = n != null && ((l = qi.get(e.field)) == null ? void 0 : l.has(String(n))) === !0;
3561
3589
  let v;
3562
3590
  return g && pe ? v = /* @__PURE__ */ a(
3563
3591
  "button",
@@ -3575,13 +3603,13 @@ function dc({
3575
3603
  className: "block max-w-full truncate text-left underline decoration-slate-300 decoration-dotted underline-offset-2 hover:text-[#172940] hover:decoration-nvr-cyan dark:hover:text-nvr-cyan",
3576
3604
  children: m ?? String(n)
3577
3605
  }
3578
- ) : v = /* @__PURE__ */ a("span", { className: "block truncate", children: m ?? String(n) }), b ? /* @__PURE__ */ a(pd, { children: v }) : v;
3606
+ ) : v = /* @__PURE__ */ a("span", { className: "block truncate", children: m ?? String(n) }), b ? /* @__PURE__ */ a(hd, { children: v }) : v;
3579
3607
  }
3580
3608
  if (e.type === "boolean")
3581
3609
  return /* @__PURE__ */ a("span", { className: n ? "text-emerald-600" : "text-slate-400", children: n ? "Yes" : "No" });
3582
3610
  if (e.type === "datetime" || e.type === "date")
3583
3611
  try {
3584
- return /* @__PURE__ */ a("span", { className: "block truncate", children: Ol(n) });
3612
+ return /* @__PURE__ */ a("span", { className: "block truncate", children: Al(n) });
3585
3613
  } catch {
3586
3614
  }
3587
3615
  if ([
@@ -3639,7 +3667,7 @@ function dc({
3639
3667
  ) : null;
3640
3668
  }, er = () => {
3641
3669
  const e = [];
3642
- return Oe !== "original" || (I || E.slice(0, vn).forEach((n, t) => {
3670
+ return Oe !== "original" || (I || O.slice(0, vn).forEach((n, t) => {
3643
3671
  const r = String(n.id);
3644
3672
  if (!Je.has(r)) {
3645
3673
  if (ks) {
@@ -3701,7 +3729,7 @@ function dc({
3701
3729
  }
3702
3730
  const ll = () => {
3703
3731
  const e = [];
3704
- return Oe !== "original" || (I || E.forEach((n, t) => {
3732
+ return Oe !== "original" || (I || O.forEach((n, t) => {
3705
3733
  const r = String(n.id);
3706
3734
  Je.has(r) || e.push({
3707
3735
  key: r,
@@ -3731,7 +3759,7 @@ function dc({
3731
3759
  locks_only: !0,
3732
3760
  probe: !0,
3733
3761
  parent_context: Mt(),
3734
- parent_collection: A,
3762
+ parent_collection: E,
3735
3763
  row_rules: K
3736
3764
  })
3737
3765
  );
@@ -3750,7 +3778,7 @@ function dc({
3750
3778
  changed_field: y,
3751
3779
  probe: !0,
3752
3780
  parent_context: Mt(),
3753
- parent_collection: A,
3781
+ parent_collection: E,
3754
3782
  row_rules: K
3755
3783
  })
3756
3784
  ), B = {};
@@ -3809,14 +3837,14 @@ function dc({
3809
3837
  } catch (y) {
3810
3838
  const j = b ? null : Di(y);
3811
3839
  if (j) {
3812
- Mn({ challenge: j, retry: (q) => m(v, q) }), U.invalidateQueries({ queryKey: ["o2m-rows", s, f, x] });
3840
+ Mn({ challenge: j, retry: (q) => m(v, q) }), J.invalidateQueries({ queryKey: ["o2m-rows", s, f, x] });
3813
3841
  return;
3814
3842
  }
3815
3843
  l.push(`#${_.key} ${In(y, "failed")}`);
3816
3844
  }
3817
3845
  }
3818
3846
  }
3819
- Pn(), U.invalidateQueries({ queryKey: ["o2m-rows", s, f, x] }), u(c, l);
3847
+ Pn(), J.invalidateQueries({ queryKey: ["o2m-rows", s, f, x] }), u(c, l);
3820
3848
  };
3821
3849
  await m(0);
3822
3850
  }
@@ -4032,7 +4060,7 @@ function dc({
4032
4060
  return ((j = ve.find((q) => q.field === y)) == null ? void 0 : j.label) ?? y.replace(/_/g, " ");
4033
4061
  };
4034
4062
  return /* @__PURE__ */ a(
4035
- fd,
4063
+ md,
4036
4064
  {
4037
4065
  kind: m,
4038
4066
  provenance: (_ = p == null ? void 0 : p.provenance) == null ? void 0 : _[t.field],
@@ -4053,7 +4081,7 @@ function dc({
4053
4081
  {
4054
4082
  className: "text-[12px] text-slate-500",
4055
4083
  "data-compare-locked": hi(t.field, e.draft) ? t.field : void 0,
4056
- "data-tip": (l = p == null ? void 0 : p.locks) != null && l.includes(t.field) ? co(t.field) : hi(t.field, e.draft) ? (O == null ? void 0 : O.closed_locked_message) || "This month is closed — only reconciling it to the actual is allowed" : void 0,
4084
+ "data-tip": (l = p == null ? void 0 : p.locks) != null && l.includes(t.field) ? co(t.field) : hi(t.field, e.draft) ? (A == null ? void 0 : A.closed_locked_message) || "This month is closed — only reconciling it to the actual is allowed" : void 0,
4057
4085
  children: Pe(t, e.draft[t.field], e.rowId)
4058
4086
  }
4059
4087
  ) : p != null && p.locksPending && Tn.has(t.field) ? (
@@ -4081,10 +4109,10 @@ function dc({
4081
4109
  pinnedOption: Vn(t.field, e.draft)
4082
4110
  }
4083
4111
  ),
4084
- O && O.columns.includes(t.field) && (() => {
4085
- const m = Ji(O, e.draft), g = m == null ? void 0 : m.values[t.field], b = Wt(
4086
- O,
4087
- e.draft[O.key_field],
4112
+ A && A.columns.includes(t.field) && (() => {
4113
+ const m = Ji(A, e.draft), g = m == null ? void 0 : m.values[t.field], b = Wt(
4114
+ A,
4115
+ e.draft[A.key_field],
4088
4116
  t.field
4089
4117
  );
4090
4118
  return /* @__PURE__ */ k(
@@ -4093,24 +4121,24 @@ function dc({
4093
4121
  "data-compare-editor-hint": t.field,
4094
4122
  className: "mt-1 flex items-center gap-1 text-[11px] text-slate-500 dark:text-muted-foreground",
4095
4123
  children: [
4096
- /* @__PURE__ */ a("span", { className: "font-mono text-[9px] uppercase tracking-wide text-slate-400", children: O.label }),
4124
+ /* @__PURE__ */ a("span", { className: "font-mono text-[9px] uppercase tracking-wide text-slate-400", children: A.label }),
4097
4125
  /* @__PURE__ */ a("span", { className: "tabular-nums font-medium text-slate-700 dark:text-slate-200", children: g == null ? "—" : Wi(g) }),
4098
4126
  b && /* @__PURE__ */ k(
4099
4127
  "span",
4100
4128
  {
4101
4129
  className: "inline-flex items-center gap-0.5 text-[10px] uppercase tracking-wide text-slate-400",
4102
- "data-tip": O.closed_locked && Qn ? `${O.closed_rule ?? ""} A change here needs a reason.`.trim() : O.closed_rule,
4130
+ "data-tip": A.closed_locked && Qn ? `${A.closed_rule ?? ""} A change here needs a reason.`.trim() : A.closed_rule,
4103
4131
  children: [
4104
- /* @__PURE__ */ a(gl, { className: "h-2.5 w-2.5", "aria-hidden": "true" }),
4132
+ /* @__PURE__ */ a(bl, { className: "h-2.5 w-2.5", "aria-hidden": "true" }),
4105
4133
  " closed"
4106
4134
  ]
4107
4135
  }
4108
4136
  ),
4109
4137
  b && !$ && /* @__PURE__ */ a(
4110
- zl,
4138
+ Bl,
4111
4139
  {
4112
- data: O,
4113
- rowKey: e.draft[O.key_field],
4140
+ data: A,
4141
+ rowKey: e.draft[A.key_field],
4114
4142
  column: t.field,
4115
4143
  columnLabel: Sr(t),
4116
4144
  plannedRow: e.draft,
@@ -4131,22 +4159,22 @@ function dc({
4131
4159
  }
4132
4160
  ),
4133
4161
  ye && ((n = ye.fields) == null ? void 0 : n.length) > 0 && !$ && /* @__PURE__ */ a(
4134
- kd,
4162
+ Nd,
4135
4163
  {
4136
4164
  config: ye,
4137
4165
  draft: e.draft,
4138
4166
  remaining: ft(ye.remaining, Gt),
4139
4167
  onApply: Ii,
4140
- closedFields: O ? new Set(
4168
+ closedFields: A ? new Set(
4141
4169
  ye.fields.filter(
4142
- (t) => Wt(O, e.draft[O.key_field], t)
4170
+ (t) => Wt(A, e.draft[A.key_field], t)
4143
4171
  )
4144
4172
  ) : void 0,
4145
4173
  shapeSource: (() => {
4146
- if (!O) return null;
4147
- const t = Number(e.draft[O.key_field]);
4174
+ if (!A) return null;
4175
+ const t = Number(e.draft[A.key_field]);
4148
4176
  if (!Number.isFinite(t)) return null;
4149
- const r = E.find((d) => Number(d[O.key_field]) === t - 1);
4177
+ const r = O.find((d) => Number(d[A.key_field]) === t - 1);
4150
4178
  if (!r) return null;
4151
4179
  const i = {};
4152
4180
  let o = !1;
@@ -4158,7 +4186,7 @@ function dc({
4158
4186
  })()
4159
4187
  }
4160
4188
  ),
4161
- te && e.rowId && !e.rowId.startsWith("pending:") && e.rowId !== "new" && /* @__PURE__ */ a(cd, { config: te, result: Kt.byRow.get(e.rowId) }),
4189
+ te && e.rowId && !e.rowId.startsWith("pending:") && e.rowId !== "new" && /* @__PURE__ */ a(ud, { config: te, result: Kt.byRow.get(e.rowId) }),
4162
4190
  e.drawer
4163
4191
  ]
4164
4192
  }
@@ -4166,7 +4194,7 @@ function dc({
4166
4194
  }, Mi = (e) => /* @__PURE__ */ a("td", { colSpan: Ot, className: "p-0", children: Eo(e) }), Oo = (e, n) => {
4167
4195
  const t = e.editor.split(/\s+/).map((i) => i[0]).filter(Boolean).slice(0, 2).join("").toUpperCase(), r = () => {
4168
4196
  wi.current.add(eo(e.rowKey, e.editor)), Zt(null);
4169
- const i = E.find((o) => String(o.id) === e.rowKey);
4197
+ const i = O.find((o) => String(o.id) === e.rowKey);
4170
4198
  i && Mr(Y.has(e.rowKey) ? { ...i, ...Y.get(e.rowKey) } : i);
4171
4199
  };
4172
4200
  return /* @__PURE__ */ k(
@@ -4245,7 +4273,7 @@ function dc({
4245
4273
  onBlurCapture: fa,
4246
4274
  children: [
4247
4275
  /* @__PURE__ */ a(
4248
- yl,
4276
+ xl,
4249
4277
  {
4250
4278
  challenge: (hr == null ? void 0 : hr.challenge) ?? null,
4251
4279
  onCancel: () => Mn(null),
@@ -4256,7 +4284,7 @@ function dc({
4256
4284
  }
4257
4285
  ),
4258
4286
  xr && xr.length > 0 && /* @__PURE__ */ a(
4259
- td,
4287
+ nd,
4260
4288
  {
4261
4289
  lines: xr,
4262
4290
  intro: "Someone else saved these line values after this table loaded, so your change was not written. Pick which value wins for each.",
@@ -4266,7 +4294,7 @@ function dc({
4266
4294
  return ((n = xe.find((t) => t.field === e)) == null ? void 0 : n.label) || Ne(e);
4267
4295
  },
4268
4296
  onCancel: () => {
4269
- ri(null), U.invalidateQueries({
4297
+ ri(null), J.invalidateQueries({
4270
4298
  queryKey: ["o2m-rows", s, f, x]
4271
4299
  });
4272
4300
  },
@@ -4319,16 +4347,16 @@ function dc({
4319
4347
  );
4320
4348
  })(),
4321
4349
  Ie && (!I || w) && /* @__PURE__ */ a(
4322
- xd,
4350
+ vd,
4323
4351
  {
4324
4352
  config: Ie,
4325
4353
  relatedCollection: s,
4326
4354
  manyField: f,
4327
4355
  parentId: x,
4328
- rows: I ? [] : E,
4356
+ rows: I ? [] : O,
4329
4357
  rowDefaults: Yt,
4330
4358
  parentDraft: N == null ? void 0 : N.draft,
4331
- invalidate: () => U.invalidateQueries({
4359
+ invalidate: () => J.invalidateQueries({
4332
4360
  queryKey: ["o2m-rows", s, f, x]
4333
4361
  }),
4334
4362
  onLocalWrite: (e) => {
@@ -4348,11 +4376,11 @@ function dc({
4348
4376
  (n) => typeof n == "object" && n.field === Se.relation && !!n.match
4349
4377
  );
4350
4378
  return e != null && e.match ? /* @__PURE__ */ a(
4351
- wd,
4379
+ _d,
4352
4380
  {
4353
4381
  config: Se,
4354
4382
  matchCfg: e.match,
4355
- rows: E,
4383
+ rows: O,
4356
4384
  parentId: x,
4357
4385
  parentDraft: N == null ? void 0 : N.draft,
4358
4386
  relatedCollection: s,
@@ -4361,10 +4389,10 @@ function dc({
4361
4389
  ) : null;
4362
4390
  })(),
4363
4391
  (Ge ?? []).map((e) => /* @__PURE__ */ a(
4364
- vd,
4392
+ wd,
4365
4393
  {
4366
4394
  config: e,
4367
- rows: [...E, ...R.map((n, t) => ({ ...n, __pendingIndex: t }))],
4395
+ rows: [...O, ...R.map((n, t) => ({ ...n, __pendingIndex: t }))],
4368
4396
  relatedCollection: s,
4369
4397
  computedWriteFields: oi,
4370
4398
  applyRow: async (n, t) => {
@@ -4381,17 +4409,17 @@ function dc({
4381
4409
  });
4382
4410
  return;
4383
4411
  }
4384
- await vi(`/items/${s}/${i}`, i, t), await U.invalidateQueries({
4412
+ await vi(`/items/${s}/${i}`, i, t), await J.invalidateQueries({
4385
4413
  queryKey: ["o2m-rows", s, f, x]
4386
4414
  });
4387
4415
  }
4388
4416
  },
4389
4417
  e.label
4390
4418
  )),
4391
- vt && !I && !$ && _t && A && /* @__PURE__ */ a(
4392
- Il,
4419
+ vt && !I && !$ && _t && E && /* @__PURE__ */ a(
4420
+ jl,
4393
4421
  {
4394
- collection: A,
4422
+ collection: E,
4395
4423
  templateFilter: (e) => {
4396
4424
  var n;
4397
4425
  return e.name === vt && ((n = e.reimport) == null ? void 0 : n.enabled) === !0;
@@ -4404,7 +4432,7 @@ function dc({
4404
4432
  compact: !0
4405
4433
  }
4406
4434
  ),
4407
- A && w && !$ && /* @__PURE__ */ k("span", { className: "relative inline-flex", children: [
4435
+ E && w && !$ && /* @__PURE__ */ k("span", { className: "relative inline-flex", children: [
4408
4436
  /* @__PURE__ */ a(
4409
4437
  "button",
4410
4438
  {
@@ -4418,7 +4446,7 @@ function dc({
4418
4446
  ta && /* @__PURE__ */ a("span", { className: "absolute left-0 top-full z-[70] mt-1 w-[300px] rounded-lg border border-slate-200 bg-white p-2 shadow-xl dark:border-border dark:bg-card", children: /* @__PURE__ */ a(
4419
4447
  Bi,
4420
4448
  {
4421
- collection: A,
4449
+ collection: E,
4422
4450
  value: null,
4423
4451
  onChange: (e) => {
4424
4452
  e != null && ra(String(e));
@@ -4451,16 +4479,16 @@ function dc({
4451
4479
  children: "apply values…"
4452
4480
  }
4453
4481
  ),
4454
- ye && ((Lo = ye.fields) == null ? void 0 : Lo.length) > 0 && ye.across_rows !== !1 && E.length + R.length > 1 && /* @__PURE__ */ a(
4455
- Nd,
4482
+ ye && ((Lo = ye.fields) == null ? void 0 : Lo.length) > 0 && ye.across_rows !== !1 && O.length + R.length > 1 && /* @__PURE__ */ a(
4483
+ Sd,
4456
4484
  {
4457
4485
  config: ye,
4458
4486
  remaining: ft(ye.remaining, Gt),
4459
- rowNoun: O ? Ne(O.key_field).toLowerCase() : "row",
4487
+ rowNoun: A ? Ne(A.key_field).toLowerCase() : "row",
4460
4488
  onApply: $a
4461
4489
  }
4462
4490
  ),
4463
- !!(K != null && K.length) && E.length + R.length > 0 && /* @__PURE__ */ a(
4491
+ !!(K != null && K.length) && O.length + R.length > 0 && /* @__PURE__ */ a(
4464
4492
  "button",
4465
4493
  {
4466
4494
  type: "button",
@@ -4475,7 +4503,7 @@ function dc({
4475
4503
  children: "re-run rules…"
4476
4504
  }
4477
4505
  ),
4478
- Oe === "original" && E.length + R.length > 0 && /* @__PURE__ */ k(
4506
+ Oe === "original" && O.length + R.length > 0 && /* @__PURE__ */ k(
4479
4507
  "button",
4480
4508
  {
4481
4509
  type: "button",
@@ -4559,7 +4587,7 @@ function dc({
4559
4587
  );
4560
4588
  })(),
4561
4589
  Io,
4562
- W && !I && /* @__PURE__ */ a(
4590
+ U && !I && /* @__PURE__ */ a(
4563
4591
  "button",
4564
4592
  {
4565
4593
  type: "button",
@@ -4573,7 +4601,7 @@ function dc({
4573
4601
  bo && Ni.length > 0 && /* @__PURE__ */ k("div", { className: "rounded-lg border border-amber-200 bg-amber-50/60 p-3 space-y-2 dark:border-amber-500/30 dark:bg-amber-400/10", children: [
4574
4602
  /* @__PURE__ */ k("p", { className: "text-[11px] font-medium text-amber-700 dark:text-amber-300", children: [
4575
4603
  "Apply values to all ",
4576
- E.length + R.length,
4604
+ O.length + R.length,
4577
4605
  " rows"
4578
4606
  ] }),
4579
4607
  /* @__PURE__ */ k("div", { className: "flex flex-wrap gap-2 items-end", children: [
@@ -4595,10 +4623,10 @@ function dc({
4595
4623
  "button",
4596
4624
  {
4597
4625
  type: "button",
4598
- disabled: _o || !(E.length + R.length),
4626
+ disabled: _o || !(O.length + R.length),
4599
4627
  onClick: Za,
4600
4628
  className: "h-9 rounded px-3 bg-amber-500 text-white text-[11px] font-medium hover:brightness-110 disabled:opacity-50 whitespace-nowrap",
4601
- children: _o ? "Applying…" : `Apply to all ${E.length + R.length} rows`
4629
+ children: _o ? "Applying…" : `Apply to all ${O.length + R.length} rows`
4602
4630
  }
4603
4631
  )
4604
4632
  ] })
@@ -4606,13 +4634,13 @@ function dc({
4606
4634
  xo && !!(K != null && K.length) && /* @__PURE__ */ k("div", { className: "rounded-lg border border-nvr-cyan/40 bg-nvr-cyan/5 p-3 space-y-2 dark:bg-nvr-cyan/5", children: [
4607
4635
  /* @__PURE__ */ k("p", { className: "text-[11px] font-medium text-slate-700 dark:text-slate-200", children: [
4608
4636
  "Re-run rules on ",
4609
- E.length + R.length,
4637
+ O.length + R.length,
4610
4638
  " ",
4611
- E.length + R.length === 1 ? "line" : "lines",
4639
+ O.length + R.length === 1 ? "line" : "lines",
4612
4640
  R.length > 0 && /* @__PURE__ */ k("span", { className: "font-normal text-slate-500", children: [
4613
4641
  " ",
4614
4642
  "(",
4615
- E.length,
4643
+ O.length,
4616
4644
  " saved, ",
4617
4645
  R.length,
4618
4646
  " not yet saved)"
@@ -4790,17 +4818,17 @@ function dc({
4790
4818
  /* @__PURE__ */ a("div", { className: "h-8 rounded bg-slate-100 dark:bg-[hsl(var(--nvr-skeleton))] animate-pulse" })
4791
4819
  ] }),
4792
4820
  !$ && Is.length > 0 && /* @__PURE__ */ a(
4793
- Wl,
4821
+ Ul,
4794
4822
  {
4795
4823
  proposals: Is,
4796
4824
  onApply: Sa,
4797
4825
  onDismiss: (e) => gi(e, !0)
4798
4826
  }
4799
4827
  ),
4800
- (mi && mi.length > 0 || Ke && !I && (O || Es || Os)) && /* @__PURE__ */ k("div", { "data-o2m-stats": !0, className: "mb-2 flex flex-wrap items-stretch gap-1.5", children: [
4801
- /* @__PURE__ */ a(Ul, { data: O, loading: Es, error: Os }),
4828
+ (mi && mi.length > 0 || Ke && !I && (A || Es || Os)) && /* @__PURE__ */ k("div", { "data-o2m-stats": !0, className: "mb-2 flex flex-wrap items-stretch gap-1.5", children: [
4829
+ /* @__PURE__ */ a(Jl, { data: A, loading: Es, error: Os }),
4802
4830
  (mi ?? []).map((e) => /* @__PURE__ */ a(
4803
- Jl,
4831
+ Ql,
4804
4832
  {
4805
4833
  label: e.label,
4806
4834
  value: e.result,
@@ -4886,8 +4914,8 @@ function dc({
4886
4914
  }
4887
4915
  ) })
4888
4916
  ] }),
4889
- !I && Oe === "original" && E.slice(0, vn).map((e, n) => {
4890
- const t = String(e.id), r = ks ? Wn(e) : null, i = r !== null && (n === 0 || Wn(E[n - 1]) !== r), o = r !== null && Ns.has(r), d = i && r !== null ? /* @__PURE__ */ a("tr", { className: "border-b border-slate-200 bg-slate-100/80 dark:border-border dark:bg-muted", children: /* @__PURE__ */ a("td", { colSpan: Ot, className: "px-2 py-1", children: /* @__PURE__ */ k(
4917
+ !I && Oe === "original" && O.slice(0, vn).map((e, n) => {
4918
+ const t = String(e.id), r = ks ? Wn(e) : null, i = r !== null && (n === 0 || Wn(O[n - 1]) !== r), o = r !== null && Ns.has(r), d = i && r !== null ? /* @__PURE__ */ a("tr", { className: "border-b border-slate-200 bg-slate-100/80 dark:border-border dark:bg-muted", children: /* @__PURE__ */ a("td", { colSpan: Ot, className: "px-2 py-1", children: /* @__PURE__ */ k(
4891
4919
  "button",
4892
4920
  {
4893
4921
  type: "button",
@@ -4906,10 +4934,10 @@ function dc({
4906
4934
  }
4907
4935
  ),
4908
4936
  /* @__PURE__ */ a("span", { className: "text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: r }),
4909
- /* @__PURE__ */ a("span", { className: "rounded border border-slate-200 bg-white px-1.5 py-0.5 text-[10px] font-medium text-slate-500 dark:border-border dark:bg-background dark:text-slate-400", children: E.reduce((h, y) => h + (Wn(y) === r ? 1 : 0), 0) }),
4937
+ /* @__PURE__ */ a("span", { className: "rounded border border-slate-200 bg-white px-1.5 py-0.5 text-[10px] font-medium text-slate-500 dark:border-border dark:bg-background dark:text-slate-400", children: O.reduce((h, y) => h + (Wn(y) === r ? 1 : 0), 0) }),
4910
4938
  (() => {
4911
4939
  const h = _a(
4912
- E.filter(
4940
+ O.filter(
4913
4941
  (y) => Wn(y) === r && !Je.has(String(y.id))
4914
4942
  )
4915
4943
  );
@@ -5001,7 +5029,7 @@ function dc({
5001
5029
  /* @__PURE__ */ k("span", { className: "inline-flex items-center gap-1", children: [
5002
5030
  n + 1,
5003
5031
  te && /* @__PURE__ */ a(
5004
- Jo,
5032
+ Uo,
5005
5033
  {
5006
5034
  result: Kt.byRow.get(t),
5007
5035
  title: te.title
@@ -5039,7 +5067,7 @@ function dc({
5039
5067
  M && /* @__PURE__ */ k("td", { className: "relative px-3 py-1 align-middle w-20", children: [
5040
5068
  Xn === "status" && Zn(t),
5041
5069
  !T && te && /* @__PURE__ */ a(
5042
- Jo,
5070
+ Uo,
5043
5071
  {
5044
5072
  result: Kt.byRow.get(t),
5045
5073
  title: te.title
@@ -5099,7 +5127,7 @@ function dc({
5099
5127
  const q = y.computed_type === "write" && !!y.computed_formula, V = q ? Ut(
5100
5128
  y.computed_formula,
5101
5129
  u ? (p == null ? void 0 : p.draft) ?? v : v
5102
- ) ?? v[y.field] : null, B = W && !u && !b ? (yt = si[t]) == null ? void 0 : yt[y.field] : void 0, Te = B ? `${y.label || Ne(y.field)} · changed ${Po(B.at)} by ${B.who}${B.reason ? `
5130
+ ) ?? v[y.field] : null, B = U && !u && !b ? (yt = si[t]) == null ? void 0 : yt[y.field] : void 0, Te = B ? `${y.label || Ne(y.field)} · changed ${Ro(B.at)} by ${B.who}${B.reason ? `
5103
5131
  Reason: “${B.reason}”` : ""}` : void 0;
5104
5132
  return /* @__PURE__ */ k(
5105
5133
  "td",
@@ -5107,15 +5135,15 @@ Reason: “${B.reason}”` : ""}` : void 0;
5107
5135
  className: be(
5108
5136
  "px-2 py-1 align-top",
5109
5137
  (B || j === 0 && Xn === "data") && "relative",
5110
- O && Wt(
5111
- O,
5112
- v[O.key_field],
5138
+ A && Wt(
5139
+ A,
5140
+ v[A.key_field],
5113
5141
  y.field
5114
5142
  ) && "bg-slate-50/80 dark:bg-white/[0.035]"
5115
5143
  ),
5116
- "data-compare-closed": O && Wt(
5117
- O,
5118
- v[O.key_field],
5144
+ "data-compare-closed": A && Wt(
5145
+ A,
5146
+ v[A.key_field],
5119
5147
  y.field
5120
5148
  ) ? "" : void 0,
5121
5149
  "data-tip": Te,
@@ -5186,12 +5214,12 @@ Reason: “${B.reason}”` : ""}` : void 0;
5186
5214
  v[y.field],
5187
5215
  e.id != null ? String(e.id) : void 0
5188
5216
  ) }),
5189
- O && /* @__PURE__ */ a(
5217
+ A && /* @__PURE__ */ a(
5190
5218
  Ui,
5191
5219
  {
5192
- data: O,
5193
- row: Ji(O, v),
5194
- rowKey: v[O.key_field],
5220
+ data: A,
5221
+ row: Ji(A, v),
5222
+ rowKey: v[A.key_field],
5195
5223
  column: y.field,
5196
5224
  planned: c && !b ? p == null ? void 0 : p.draft[y.field] : v[y.field],
5197
5225
  columnLabel: Sr(y),
@@ -5262,14 +5290,14 @@ Reason: “${B.reason}”` : ""}` : void 0;
5262
5290
  }
5263
5291
  ),
5264
5292
  ne && t != null && /* @__PURE__ */ a(
5265
- od,
5293
+ ad,
5266
5294
  {
5267
5295
  collection: s,
5268
5296
  rowId: String(t),
5269
5297
  count: Ia[String(t)] ?? 0
5270
5298
  }
5271
5299
  ),
5272
- W && /* @__PURE__ */ a(
5300
+ U && /* @__PURE__ */ a(
5273
5301
  "button",
5274
5302
  {
5275
5303
  type: "button",
@@ -5282,20 +5310,18 @@ Reason: “${B.reason}”` : ""}` : void 0;
5282
5310
  }
5283
5311
  ),
5284
5312
  t != null && !String(t).startsWith("pending") && /* @__PURE__ */ a(
5285
- ud,
5313
+ fd,
5286
5314
  {
5287
5315
  collection: s,
5288
5316
  rowId: String(t),
5289
- rowLabel: bd(e)
5317
+ rowLabel: yd(e)
5290
5318
  }
5291
5319
  ),
5292
5320
  !$ && /* @__PURE__ */ a(
5293
- "button",
5321
+ Qo,
5294
5322
  {
5295
- type: "button",
5296
- onClick: (h) => Ti(e, h),
5297
- className: "rounded p-0.5 text-slate-300 hover:text-red-500",
5298
- children: /* @__PURE__ */ a(Mo, { className: "h-3 w-3" })
5323
+ saved: t != null && !String(t).startsWith("pending"),
5324
+ onDelete: (h) => Ti(e, h)
5299
5325
  }
5300
5326
  )
5301
5327
  ] }) }) })
@@ -5369,7 +5395,7 @@ Reason: “${B.reason}”` : ""}` : void 0;
5369
5395
  colSpan: Ot,
5370
5396
  className: "px-3 py-1.5 text-[11px] text-slate-500 dark:text-slate-400",
5371
5397
  children: [
5372
- T ? `Line ${E.length + R.length + 1} · ` : "",
5398
+ T ? `Line ${O.length + R.length + 1} · ` : "",
5373
5399
  "New line — fill it in below"
5374
5400
  ]
5375
5401
  }
@@ -5385,11 +5411,11 @@ Reason: “${B.reason}”` : ""}` : void 0;
5385
5411
  rt !== "panel" && /* @__PURE__ */ k(An, { children: [
5386
5412
  nt && /* @__PURE__ */ a("td", { className: "w-7" }),
5387
5413
  (C || I || M) && /* @__PURE__ */ a("td", { className: "w-6" }),
5388
- T && /* @__PURE__ */ a("td", { className: "w-8 px-2 align-middle text-slate-400 text-[11px] select-none", children: E.length + R.length + 1 }),
5414
+ T && /* @__PURE__ */ a("td", { className: "w-8 px-2 align-middle text-slate-400 text-[11px] select-none", children: O.length + R.length + 1 }),
5389
5415
  (I || M) && /* @__PURE__ */ a("td", { className: "px-3 py-1.5" })
5390
5416
  ] }),
5391
5417
  rt === "panel" ? Mi({
5392
- identity: `${T ? `Line ${E.length + R.length + 1} · ` : ""}New line`,
5418
+ identity: `${T ? `Line ${O.length + R.length + 1} · ` : ""}New line`,
5393
5419
  draft: p.draft,
5394
5420
  rowId: void 0,
5395
5421
  saveLabel: "Save",
@@ -5447,18 +5473,18 @@ Reason: “${B.reason}”` : ""}` : void 0;
5447
5473
  ]
5448
5474
  }
5449
5475
  ),
5450
- E.length === 0 && R.length === 0 && !Dr && /* @__PURE__ */ a("tr", { children: /* @__PURE__ */ a("td", { colSpan: Ot, className: "px-3 py-14 text-center text-slate-400", children: z ? `No ${z.toLowerCase()} yet` : I ? "No pending rows" : "No rows yet" }) }),
5476
+ O.length === 0 && R.length === 0 && !Dr && /* @__PURE__ */ a("tr", { children: /* @__PURE__ */ a("td", { colSpan: Ot, className: "px-3 py-14 text-center text-slate-400", children: z ? `No ${z.toLowerCase()} yet` : I ? "No pending rows" : "No rows yet" }) }),
5451
5477
  !I && Oe !== "original" && (() => {
5452
5478
  const e = wt.find((u) => u.addendumId === Oe), n = (ee && (C || M) ? 1 : 0) + (T ? 1 : 0) + (M ? 1 : 0) + Le.length + 1;
5453
5479
  if (!e)
5454
- return E.length === 0 ? /* @__PURE__ */ a("tr", { children: /* @__PURE__ */ a(
5480
+ return O.length === 0 ? /* @__PURE__ */ a("tr", { children: /* @__PURE__ */ a(
5455
5481
  "td",
5456
5482
  {
5457
5483
  colSpan: n,
5458
5484
  className: "px-3 py-8 text-center text-[11px] text-slate-400",
5459
5485
  children: z ? `No ${z.toLowerCase()} yet` : "No rows"
5460
5486
  }
5461
- ) }) : E.map((u, c) => /* @__PURE__ */ k("tr", { className: "border-b border-slate-100", children: [
5487
+ ) }) : O.map((u, c) => /* @__PURE__ */ k("tr", { className: "border-b border-slate-100", children: [
5462
5488
  ee && (C || M) && /* @__PURE__ */ a("td", { className: "w-6" }),
5463
5489
  T && /* @__PURE__ */ a("td", { className: "w-8 px-2 align-middle text-[11px] text-slate-400 select-none", children: c + 1 }),
5464
5490
  M && /* @__PURE__ */ a("td", { className: "w-20" }),
@@ -5469,7 +5495,7 @@ Reason: “${B.reason}”` : ""}` : void 0;
5469
5495
  ) }, l.field)),
5470
5496
  /* @__PURE__ */ a("td", { className: "w-20" })
5471
5497
  ] }, c));
5472
- const t = e.baseRows ?? E, r = new Set(
5498
+ const t = e.baseRows ?? O, r = new Set(
5473
5499
  e.rows.filter((u) => u.id != null).map((u) => String(u.id))
5474
5500
  ), i = t.filter(
5475
5501
  (u) => u.id != null && !r.has(String(u.id))
@@ -5563,18 +5589,18 @@ Reason: “${B.reason}”` : ""}` : void 0;
5563
5589
  );
5564
5590
  }), ...o];
5565
5591
  })(),
5566
- !I && Oe === "original" && E.length > vn && /* @__PURE__ */ a("tr", { ref: Qs, children: /* @__PURE__ */ k("td", { colSpan: 99, className: "px-3 py-2 text-center text-[11px] text-slate-400", children: [
5592
+ !I && Oe === "original" && O.length > vn && /* @__PURE__ */ a("tr", { ref: Qs, children: /* @__PURE__ */ k("td", { colSpan: 99, className: "px-3 py-2 text-center text-[11px] text-slate-400", children: [
5567
5593
  "Showing ",
5568
5594
  vn,
5569
5595
  " of ",
5570
- E.length,
5596
+ O.length,
5571
5597
  " rows — scroll to load more"
5572
5598
  ] }) }),
5573
- O && Oe === "original" && (() => {
5599
+ A && Oe === "original" && (() => {
5574
5600
  const e = /* @__PURE__ */ new Set();
5575
- for (const t of E ?? []) e.add(String(t[O.key_field] ?? ""));
5576
- for (const t of R) e.add(String(t[O.key_field] ?? ""));
5577
- const n = O.rows.filter((t) => !e.has(String(t.key)));
5601
+ for (const t of O ?? []) e.add(String(t[A.key_field] ?? ""));
5602
+ for (const t of R) e.add(String(t[A.key_field] ?? ""));
5603
+ const n = A.rows.filter((t) => !e.has(String(t.key)));
5578
5604
  return n.length === 0 ? null : n.map((t) => /* @__PURE__ */ k(
5579
5605
  "tr",
5580
5606
  {
@@ -5585,20 +5611,20 @@ Reason: “${B.reason}”` : ""}` : void 0;
5585
5611
  ee && (C || I || M) && /* @__PURE__ */ a("td", {}),
5586
5612
  T && /* @__PURE__ */ a("td", {}),
5587
5613
  (I || M) && /* @__PURE__ */ a("td", { className: "px-3 py-1 align-top", children: /* @__PURE__ */ k("span", { className: "text-[10px] font-medium uppercase tracking-wide text-slate-500 dark:text-slate-400", children: [
5588
- O.label,
5614
+ A.label,
5589
5615
  " only"
5590
5616
  ] }) }),
5591
5617
  Le.map(
5592
- (r) => r.field === O.key_field ? /* @__PURE__ */ k("td", { className: "px-2 py-1 align-top", children: [
5618
+ (r) => r.field === A.key_field ? /* @__PURE__ */ k("td", { className: "px-2 py-1 align-top", children: [
5593
5619
  /* @__PURE__ */ a("div", { className: "py-0.5 text-[12px] font-medium text-slate-700 dark:text-slate-200", children: String(t.key) }),
5594
5620
  /* @__PURE__ */ k(
5595
5621
  "div",
5596
5622
  {
5597
5623
  className: "mt-0.5 text-[10.5px] text-slate-600 dark:text-slate-300",
5598
- "data-tip": `${O.label} recorded for ${String(t.key)} with no ${z ? z.toLowerCase() : "row"} to compare against — add a row for ${String(t.key)} to plan against it`,
5624
+ "data-tip": `${A.label} recorded for ${String(t.key)} with no ${z ? z.toLowerCase() : "row"} to compare against — add a row for ${String(t.key)} to plan against it`,
5599
5625
  children: [
5600
5626
  "No plan for this ",
5601
- Ne(O.key_field).toLowerCase()
5627
+ Ne(A.key_field).toLowerCase()
5602
5628
  ]
5603
5629
  }
5604
5630
  )
@@ -5607,14 +5633,14 @@ Reason: “${B.reason}”` : ""}` : void 0;
5607
5633
  {
5608
5634
  className: be(
5609
5635
  "px-2 py-1 align-top",
5610
- Wt(O, t.key, r.field) && "bg-slate-100/70 dark:bg-white/[0.035]"
5636
+ Wt(A, t.key, r.field) && "bg-slate-100/70 dark:bg-white/[0.035]"
5611
5637
  ),
5612
5638
  children: [
5613
- O.columns.includes(r.field) && /* @__PURE__ */ a("div", { className: "py-0.5 text-[12px] text-slate-300 dark:text-slate-600", children: "—" }),
5639
+ A.columns.includes(r.field) && /* @__PURE__ */ a("div", { className: "py-0.5 text-[12px] text-slate-300 dark:text-slate-600", children: "—" }),
5614
5640
  /* @__PURE__ */ a(
5615
5641
  Ui,
5616
5642
  {
5617
- data: O,
5643
+ data: A,
5618
5644
  row: t,
5619
5645
  rowKey: t.key,
5620
5646
  column: r.field,
@@ -5676,7 +5702,7 @@ Reason: “${B.reason}”` : ""}` : void 0;
5676
5702
  "input",
5677
5703
  {
5678
5704
  type: "checkbox",
5679
- "aria-label": `Select line ${E.length + n + 1}`,
5705
+ "aria-label": `Select line ${O.length + n + 1}`,
5680
5706
  className: "accent-nvr-cyan",
5681
5707
  checked: Vt.has(t),
5682
5708
  onChange: () => ns(t)
@@ -5693,7 +5719,7 @@ Reason: “${B.reason}”` : ""}` : void 0;
5693
5719
  }
5694
5720
  ),
5695
5721
  T && /* @__PURE__ */ a("td", { className: "w-8 px-2 align-middle text-slate-400 text-[11px] select-none", children: /* @__PURE__ */ k("span", { className: "inline-flex items-center gap-1", children: [
5696
- E.length + n + 1,
5722
+ O.length + n + 1,
5697
5723
  (() => {
5698
5724
  const c = Vi(
5699
5725
  r ? (p == null ? void 0 : p.draft) ?? e : e,
@@ -5715,7 +5741,7 @@ Reason: “${B.reason}”` : ""}` : void 0;
5715
5741
  ] })
5716
5742
  ] }),
5717
5743
  r && rt === "panel" ? Mi({
5718
- identity: `${T ? `Line ${E.length + n + 1} · ` : ""}${Wr(r ? p.draft : e)}`,
5744
+ identity: `${T ? `Line ${O.length + n + 1} · ` : ""}${Wr(r ? p.draft : e)}`,
5719
5745
  draft: (p == null ? void 0 : p.draft) ?? e,
5720
5746
  rowId: t,
5721
5747
  saveLabel: "Save",
@@ -5776,15 +5802,15 @@ Reason: “${B.reason}”` : ""}` : void 0;
5776
5802
  c[l.field] ?? e[l.field],
5777
5803
  String(e.id)
5778
5804
  ) }) : /* @__PURE__ */ a("div", { className: "py-0.5 overflow-hidden", children: Pe(l, h, String(e.id)) }),
5779
- O && /* @__PURE__ */ a(
5805
+ A && /* @__PURE__ */ a(
5780
5806
  Ui,
5781
5807
  {
5782
- data: O,
5808
+ data: A,
5783
5809
  row: Ji(
5784
- O,
5810
+ A,
5785
5811
  r ? p.draft : e
5786
5812
  ),
5787
- rowKey: (r ? p.draft : e)[O.key_field],
5813
+ rowKey: (r ? p.draft : e)[A.key_field],
5788
5814
  column: l.field,
5789
5815
  planned: r ? p.draft[l.field] : e[l.field],
5790
5816
  columnLabel: Sr(l)
@@ -5824,7 +5850,7 @@ Reason: “${B.reason}”` : ""}` : void 0;
5824
5850
  ]
5825
5851
  }
5826
5852
  ) : /* @__PURE__ */ k("div", { className: "flex items-center justify-end gap-0.5", children: [
5827
- W && u && e.id != null && /* @__PURE__ */ a(
5853
+ U && u && e.id != null && /* @__PURE__ */ a(
5828
5854
  "button",
5829
5855
  {
5830
5856
  type: "button",
@@ -5837,14 +5863,12 @@ Reason: “${B.reason}”` : ""}` : void 0;
5837
5863
  }
5838
5864
  ),
5839
5865
  /* @__PURE__ */ a(
5840
- "button",
5866
+ Qo,
5841
5867
  {
5842
- type: "button",
5843
- onClick: (c) => {
5868
+ saved: !1,
5869
+ onDelete: (c) => {
5844
5870
  c.stopPropagation(), w == null || w.removeRow(s, f, n);
5845
- },
5846
- className: "rounded p-0.5 text-slate-400 hover:text-red-500",
5847
- children: /* @__PURE__ */ a(Mo, { className: "h-3 w-3" })
5871
+ }
5848
5872
  }
5849
5873
  )
5850
5874
  ] }) })
@@ -5886,7 +5910,7 @@ Reason: “${B.reason}”` : ""}` : void 0;
5886
5910
  }
5887
5911
  })() : t.options : {}).aggregate).length === 0) return null;
5888
5912
  const n = [
5889
- ...(E ?? []).filter((t) => !Je.has(String(t.id))).map((t) => {
5913
+ ...(O ?? []).filter((t) => !Je.has(String(t.id))).map((t) => {
5890
5914
  const r = String(t.id), i = Y.has(r) ? { ...t, ...Y.get(r) } : t;
5891
5915
  return tr(
5892
5916
  de(i),
@@ -5913,13 +5937,13 @@ Reason: “${B.reason}”` : ""}` : void 0;
5913
5937
  } catch {
5914
5938
  return {};
5915
5939
  }
5916
- })() : t.options : {}, i = r.aggregate, o = Ql(O, t.field), d = o != null ? /* @__PURE__ */ k(
5940
+ })() : t.options : {}, i = r.aggregate, o = zl(A, t.field), d = o != null ? /* @__PURE__ */ k(
5917
5941
  "div",
5918
5942
  {
5919
5943
  "data-compare-footer": t.field,
5920
5944
  className: "mt-0.5 flex min-w-0 flex-wrap items-baseline gap-x-1 text-[11px] font-normal leading-4 text-slate-500 dark:text-slate-400",
5921
5945
  children: [
5922
- /* @__PURE__ */ a("span", { className: "font-mono text-[9px] uppercase tracking-wide text-slate-500 dark:text-slate-400", children: O == null ? void 0 : O.label }),
5946
+ /* @__PURE__ */ a("span", { className: "font-mono text-[9px] uppercase tracking-wide text-slate-500 dark:text-slate-400", children: A == null ? void 0 : A.label }),
5923
5947
  /* @__PURE__ */ a("span", { className: "tabular-nums", children: Wi(o) })
5924
5948
  ]
5925
5949
  }
@@ -6021,7 +6045,7 @@ Reason: “${B.reason}”` : ""}` : void 0;
6021
6045
  ),
6022
6046
  le && Ye && Oe === "original" && /* @__PURE__ */ a("div", { "data-grid-split-editor-lock": "", children: Oo(Ye, "docked") }),
6023
6047
  le && p && Oe === "original" && (() => {
6024
- const e = p.rowId, n = e.startsWith("pending:"), t = n ? parseInt(e.split(":")[1], 10) : -1, r = !n && e !== "new" ? E.findIndex((c) => String(c.id) === e) : -1, i = r >= 0 ? E[r] : void 0, o = e === "new" ? E.length + R.length + 1 : n ? E.length + t + 1 : r + 1, d = T ? `Line ${o} · ` : "", u = e === "new" ? `${d}New line` : `${d}${Wr(p.draft)}`;
6048
+ const e = p.rowId, n = e.startsWith("pending:"), t = n ? parseInt(e.split(":")[1], 10) : -1, r = !n && e !== "new" ? O.findIndex((c) => String(c.id) === e) : -1, i = r >= 0 ? O[r] : void 0, o = e === "new" ? O.length + R.length + 1 : n ? O.length + t + 1 : r + 1, d = T ? `Line ${o} · ` : "", u = e === "new" ? `${d}New line` : `${d}${Wr(p.draft)}`;
6025
6049
  return /* @__PURE__ */ k(
6026
6050
  "div",
6027
6051
  {
@@ -6075,12 +6099,12 @@ Reason: “${B.reason}”` : ""}` : void 0;
6075
6099
  );
6076
6100
  })(),
6077
6101
  /* @__PURE__ */ a(
6078
- Bl,
6102
+ Vl,
6079
6103
  {
6080
6104
  open: Zo,
6081
6105
  onOpenChange: ts,
6082
6106
  columns: ve.filter(
6083
- (e) => !nr(e) && !e.field.includes(".") && !Un(e.interface) && !Do.has(e.field)
6107
+ (e) => !nr(e) && !e.field.includes(".") && !Un(e.interface) && !Po.has(e.field)
6084
6108
  ),
6085
6109
  rows: il.map((e) => e.row),
6086
6110
  relations: Re,
@@ -6090,12 +6114,12 @@ Reason: “${B.reason}”` : ""}` : void 0;
6090
6114
  }
6091
6115
  ),
6092
6116
  /* @__PURE__ */ a(
6093
- Uo,
6117
+ Wo,
6094
6118
  {
6095
6119
  mode: "timeline",
6096
6120
  open: as,
6097
6121
  onOpenChange: fr,
6098
- rowTitle: `${E.length} ${E.length === 1 ? "line" : "lines"} on this record`,
6122
+ rowTitle: `${O.length} ${O.length === 1 ? "line" : "lines"} on this record`,
6099
6123
  revisions: da,
6100
6124
  loading: la,
6101
6125
  truncated: !!(Ft != null && Ft.truncated),
@@ -6120,7 +6144,7 @@ Reason: “${B.reason}”` : ""}` : void 0;
6120
6144
  }
6121
6145
  ),
6122
6146
  /* @__PURE__ */ a(
6123
- Uo,
6147
+ Wo,
6124
6148
  {
6125
6149
  open: !!$e,
6126
6150
  onOpenChange: (e) => {
@@ -6180,33 +6204,33 @@ function Co(s) {
6180
6204
  f
6181
6205
  )) });
6182
6206
  }
6183
- function kd({
6207
+ function Nd({
6184
6208
  config: s,
6185
6209
  draft: f,
6186
6210
  remaining: x,
6187
- onApply: A,
6188
- closedFields: Q,
6189
- shapeSource: W
6211
+ onApply: E,
6212
+ closedFields: D,
6213
+ shapeSource: U
6190
6214
  }) {
6191
- const ne = s.only_empty !== !1, ae = (oe) => oe == null || oe === "" || Number(oe) === 0, J = s.fields.filter(
6192
- (oe) => (Q == null ? void 0 : Q.has(oe)) && (!ne || ae(f[oe]))
6215
+ const ne = s.only_empty !== !1, ae = (oe) => oe == null || oe === "" || Number(oe) === 0, Q = s.fields.filter(
6216
+ (oe) => (D == null ? void 0 : D.has(oe)) && (!ne || ae(f[oe]))
6193
6217
  ).length, T = s.fields.filter(
6194
- (oe) => !(Q != null && Q.has(oe)) && (!ne || ae(f[oe]))
6195
- ), ee = L(() => (s.presets ?? ["even", "front", "back", "shape"]).filter((Qe) => Qe !== "shape" || !!W), [s.presets, W]), [Ee, K] = D("even"), Z = ee.includes(Ee) ? Ee : ee[0] ?? "even", we = x == null || !Number.isFinite(x) ? 0 : Math.round(x * 100) / 100, X = (oe) => s.format === "number" ? oe.toLocaleString(void 0, { maximumFractionDigits: 2 }) : oe.toLocaleString(void 0, { style: "currency", currency: "USD" }), _e = we <= 0 ? we < 0 ? `${X(-we)} over — nothing to spread` : "Nothing left to spread" : T.length === 0 ? J > 0 ? "Every open target field already holds a value" : "Every target field already holds a value" : null;
6218
+ (oe) => !(D != null && D.has(oe)) && (!ne || ae(f[oe]))
6219
+ ), ee = L(() => (s.presets ?? ["even", "front", "back", "shape"]).filter((Qe) => Qe !== "shape" || !!U), [s.presets, U]), [Ee, K] = W("even"), Z = ee.includes(Ee) ? Ee : ee[0] ?? "even", we = x == null || !Number.isFinite(x) ? 0 : Math.round(x * 100) / 100, X = (oe) => s.format === "number" ? oe.toLocaleString(void 0, { maximumFractionDigits: 2 }) : oe.toLocaleString(void 0, { style: "currency", currency: "USD" }), ke = we <= 0 ? we < 0 ? `${X(-we)} over — nothing to spread` : "Nothing left to spread" : T.length === 0 ? Q > 0 ? "Every open target field already holds a value" : "Every target field already holds a value" : null;
6196
6220
  return /* @__PURE__ */ k("div", { className: "mt-2 flex flex-wrap items-center gap-2", "data-o2m-spread": !0, children: [
6197
6221
  /* @__PURE__ */ k(
6198
6222
  "button",
6199
6223
  {
6200
6224
  type: "button",
6201
6225
  onClick: () => {
6202
- if (_e) return;
6203
- const oe = W ? T.map((F) => W.values[F] ?? 0) : void 0, Qe = Go(we, T.length, Z, oe), he = {};
6226
+ if (ke) return;
6227
+ const oe = U ? T.map((F) => U.values[F] ?? 0) : void 0, Qe = Go(we, T.length, Z, oe), he = {};
6204
6228
  T.forEach((F, fe) => {
6205
6229
  he[F] = Qe[fe];
6206
- }), A(he);
6230
+ }), E(he);
6207
6231
  },
6208
- disabled: !!_e,
6209
- title: _e ?? `${X(we)} across ${T.length} ${T.length === 1 ? "field" : "fields"}`,
6232
+ disabled: !!ke,
6233
+ title: ke ?? `${X(we)} across ${T.length} ${T.length === 1 ? "field" : "fields"}`,
6210
6234
  className: "inline-flex h-7 items-center gap-1.5 rounded-md border border-slate-200 bg-white px-2.5 text-[11.5px] font-medium text-slate-700 hover:bg-slate-50 disabled:cursor-not-allowed disabled:opacity-50 dark:border-border dark:bg-background dark:text-slate-200 dark:hover:bg-white/5",
6211
6235
  children: [
6212
6236
  s.label ?? "Spread remaining",
@@ -6214,49 +6238,49 @@ function kd({
6214
6238
  ]
6215
6239
  }
6216
6240
  ),
6217
- !_e && /* @__PURE__ */ a(
6241
+ !ke && /* @__PURE__ */ a(
6218
6242
  Co,
6219
6243
  {
6220
6244
  presets: ee,
6221
6245
  value: Z,
6222
6246
  onChange: K,
6223
- shapeLabel: W == null ? void 0 : W.label
6247
+ shapeLabel: U == null ? void 0 : U.label
6224
6248
  }
6225
6249
  ),
6226
- !_e && /* @__PURE__ */ k("span", { className: "text-[11px] text-slate-400 dark:text-slate-500", children: [
6250
+ !ke && /* @__PURE__ */ k("span", { className: "text-[11px] text-slate-400 dark:text-slate-500", children: [
6227
6251
  "across ",
6228
6252
  T.length,
6229
6253
  " empty ",
6230
6254
  T.length === 1 ? "field" : "fields",
6231
- J > 0 && /* @__PURE__ */ k("span", { "data-o2m-spread-skipped": J, children: [
6255
+ Q > 0 && /* @__PURE__ */ k("span", { "data-o2m-spread-skipped": Q, children: [
6232
6256
  " ",
6233
6257
  "· ",
6234
- J,
6258
+ Q,
6235
6259
  " closed ",
6236
- J === 1 ? "month" : "months",
6260
+ Q === 1 ? "month" : "months",
6237
6261
  " skipped"
6238
6262
  ] })
6239
6263
  ] }),
6240
- _e && /* @__PURE__ */ a("span", { className: "text-[11px] text-slate-400 dark:text-slate-500", children: _e })
6264
+ ke && /* @__PURE__ */ a("span", { className: "text-[11px] text-slate-400 dark:text-slate-500", children: ke })
6241
6265
  ] });
6242
6266
  }
6243
- function Nd(s) {
6244
- const [f, x] = D(!1), [A, Q] = D("even"), W = s.remaining == null || !Number.isFinite(s.remaining) ? 0 : Math.round(s.remaining * 100) / 100, ne = (J) => s.config.format === "number" ? J.toLocaleString(void 0, { maximumFractionDigits: 2 }) : J.toLocaleString(void 0, { style: "currency", currency: "USD" });
6245
- if (W <= 0) return null;
6267
+ function Sd(s) {
6268
+ const [f, x] = W(!1), [E, D] = W("even"), U = s.remaining == null || !Number.isFinite(s.remaining) ? 0 : Math.round(s.remaining * 100) / 100, ne = (Q) => s.config.format === "number" ? Q.toLocaleString(void 0, { maximumFractionDigits: 2 }) : Q.toLocaleString(void 0, { style: "currency", currency: "USD" });
6269
+ if (U <= 0) return null;
6246
6270
  const ae = (s.config.presets ?? ["even", "front", "back"]).filter(
6247
- (J) => J !== "shape"
6271
+ (Q) => Q !== "shape"
6248
6272
  );
6249
6273
  return /* @__PURE__ */ k("span", { className: "relative inline-flex items-center", "data-o2m-spread-rows": !0, children: [
6250
6274
  /* @__PURE__ */ k(
6251
6275
  "button",
6252
6276
  {
6253
6277
  type: "button",
6254
- onClick: () => x((J) => !J),
6278
+ onClick: () => x((Q) => !Q),
6255
6279
  className: be(
6256
6280
  "h-6 px-2.5 rounded border transition-colors",
6257
6281
  f ? "border-nvr-cyan bg-nvr-cyan/10 text-nvr-cyan" : "border-slate-200 text-slate-600 hover:border-slate-400 hover:text-slate-800"
6258
6282
  ),
6259
- "data-tip": `Put the remaining ${ne(W)} onto every empty open month across all ${s.rowNoun}s at once`,
6283
+ "data-tip": `Put the remaining ${ne(U)} onto every empty open month across all ${s.rowNoun}s at once`,
6260
6284
  children: [
6261
6285
  "spread across ",
6262
6286
  s.rowNoun,
@@ -6272,7 +6296,7 @@ function Nd(s) {
6272
6296
  children: [
6273
6297
  /* @__PURE__ */ k("div", { className: "text-slate-700 dark:text-slate-200", children: [
6274
6298
  "Spread ",
6275
- /* @__PURE__ */ a("b", { className: "tabular-nums", children: ne(W) }),
6299
+ /* @__PURE__ */ a("b", { className: "tabular-nums", children: ne(U) }),
6276
6300
  " over every empty open month, oldest",
6277
6301
  " ",
6278
6302
  s.rowNoun,
@@ -6282,8 +6306,8 @@ function Nd(s) {
6282
6306
  Co,
6283
6307
  {
6284
6308
  presets: ae,
6285
- value: ae.includes(A) ? A : ae[0],
6286
- onChange: Q
6309
+ value: ae.includes(E) ? E : ae[0],
6310
+ onChange: D
6287
6311
  }
6288
6312
  ) }),
6289
6313
  /* @__PURE__ */ k("div", { className: "mt-2.5 flex justify-end gap-1.5", children: [
@@ -6302,7 +6326,7 @@ function Nd(s) {
6302
6326
  type: "button",
6303
6327
  "data-o2m-spread-rows-apply": !0,
6304
6328
  onClick: () => {
6305
- s.onApply(ae.includes(A) ? A : ae[0]), x(!1);
6329
+ s.onApply(ae.includes(E) ? E : ae[0]), x(!1);
6306
6330
  },
6307
6331
  className: "h-7 rounded-md bg-nvr-cyan px-3 text-[12px] font-semibold text-white hover:opacity-90",
6308
6332
  children: "Stage the spread"
@@ -6315,13 +6339,14 @@ function Nd(s) {
6315
6339
  ] });
6316
6340
  }
6317
6341
  function Bo(s) {
6318
- var x, A;
6342
+ var x, E;
6319
6343
  const f = s;
6320
- return ((x = f == null ? void 0 : f.response) == null ? void 0 : x.error) ?? ((A = f == null ? void 0 : f.response) == null ? void 0 : A.message) ?? (f == null ? void 0 : f.message) ?? "the server refused it";
6344
+ return ((x = f == null ? void 0 : f.response) == null ? void 0 : x.error) ?? ((E = f == null ? void 0 : f.response) == null ? void 0 : E.message) ?? (f == null ? void 0 : f.message) ?? "the server refused it";
6321
6345
  }
6322
6346
  export {
6323
- dc as InlineTableField,
6324
- _d as applyValueColumns,
6347
+ Qo as DeleteLineButton,
6348
+ cc as InlineTableField,
6349
+ kd as applyValueColumns,
6325
6350
  Ut as evalClientFormula,
6326
6351
  Vi as failingLints,
6327
6352
  Go as spreadAmounts