@nivaro/react 0.3.63 → 0.3.65

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 (64) hide show
  1. package/dist/full.css +1 -1
  2. package/dist/hooks/useSessionRecorder.js +1 -1
  3. package/dist/index.d.ts +54 -5
  4. package/dist/shared/components/CollectionBrowserView.js +3029 -2947
  5. package/dist/shared/components/ConformanceView.js +235 -221
  6. package/dist/shared/components/DataTable.js +478 -459
  7. package/dist/shared/components/ItemEditForm.js +4469 -4266
  8. package/dist/shared/components/PageRenderer.js +146 -138
  9. package/dist/shared/components/RecordDrilldownSheet.js +73 -65
  10. package/dist/shared/components/bulk/BulkActionButtons.js +72 -72
  11. package/dist/shared/components/bulk/BulkFieldUpdate.js +114 -103
  12. package/dist/shared/components/bulk/BulkFieldUpdateButton.js +73 -0
  13. package/dist/shared/components/bulk/bulk-field-options.js +29 -23
  14. package/dist/shared/components/integrations/IntegrationObligationsView.js +191 -173
  15. package/dist/shared/components/integrations/IntegrationStatusLines.js +101 -85
  16. package/dist/shared/components/integrations/RecordIntegrationPreview.js +11 -9
  17. package/dist/shared/components/integrations/SendCurrentData.js +126 -0
  18. package/dist/shared/components/item-edit/CatalogPickerField.js +1530 -1437
  19. package/dist/shared/components/item-edit/FieldRenderer.js +49 -45
  20. package/dist/shared/components/item-edit/FieldRow.js +413 -403
  21. package/dist/shared/components/item-edit/InlineTableField.js +2903 -2816
  22. package/dist/shared/components/item-edit/M2MCombobox.js +172 -168
  23. package/dist/shared/components/item-edit/MidairCollisionDialog.js +341 -114
  24. package/dist/shared/components/item-edit/NestedRelationEditor.js +171 -163
  25. package/dist/shared/components/item-edit/PlanGrid.js +783 -724
  26. package/dist/shared/components/item-edit/QuickCreateButton.js +291 -224
  27. package/dist/shared/components/item-edit/RecordInsights.js +113 -111
  28. package/dist/shared/components/item-edit/RecordLiveSync.js +4 -1
  29. package/dist/shared/components/item-edit/RelationCombobox.js +332 -314
  30. package/dist/shared/components/item-edit/cascade-clear-notice.js +52 -0
  31. package/dist/shared/components/item-edit/collision-format.js +37 -0
  32. package/dist/shared/components/item-edit/field-a11y.js +25 -0
  33. package/dist/shared/components/item-edit/line-merge.js +58 -0
  34. package/dist/shared/components/item-edit/line-midair.js +94 -87
  35. package/dist/shared/components/item-edit/move-guard.js +17 -0
  36. package/dist/shared/components/item-edit/picker-search.js +22 -15
  37. package/dist/shared/components/item-edit/rail-width.js +8 -0
  38. package/dist/shared/components/monitoring/InactiveUserLinksView.js +322 -291
  39. package/dist/shared/components/panels/AccessDeniedPanel.js +96 -55
  40. package/dist/shared/components/panels/CommentPanel.js +142 -136
  41. package/dist/shared/components/panels/ItemLockBanner.js +246 -240
  42. package/dist/shared/components/panels/PipelinePanel.js +1366 -1194
  43. package/dist/shared/components/panels/RevisionsPanel.js +106 -102
  44. package/dist/shared/components/panels/SlaBreachBanner.js +16 -20
  45. package/dist/shared/components/panels/SlaClock.js +90 -68
  46. package/dist/shared/components/queue/QueueItemSheet.js +94 -87
  47. package/dist/shared/components/queue/QueueWorklist.js +1502 -1354
  48. package/dist/shared/components/queue/worklist-csv.js +75 -0
  49. package/dist/shared/components/queue/worklist-helpers.js +20 -0
  50. package/dist/shared/components/widgets/ReviewListWidget.js +226 -207
  51. package/dist/shared/lib/bulk-copy.js +17 -0
  52. package/dist/shared/lib/cbv-export.js +122 -0
  53. package/dist/shared/lib/delete-offer.js +13 -0
  54. package/dist/shared/lib/error-hints.js +1 -0
  55. package/dist/shared/lib/leave-guard.js +41 -26
  56. package/dist/shared/lib/list-link.js +72 -56
  57. package/dist/shared/lib/live-queries.js +32 -30
  58. package/dist/shared/lib/moved-notice.js +25 -0
  59. package/dist/shared/lib/notification-target.js +56 -54
  60. package/dist/shared/lib/obligation-banner.js +11 -8
  61. package/dist/shared/lib/obligation-reason-text.js +6 -6
  62. package/dist/shared/lib/sort-cycle.js +6 -0
  63. package/dist/shared/lib/summary-mode.js +59 -41
  64. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
- import { jsx as t, jsxs as c, Fragment as ra } from "react/jsx-runtime";
1
+ import { jsx as t, jsxs as u, Fragment as It } from "react/jsx-runtime";
2
2
  import { useQueryClient as sa, useQuery as he } from "@tanstack/react-query";
3
- import { ChevronDown as Lt, ChevronRight as Mt, Lock as oa, MoreHorizontal as ia, Split as Et, Undo2 as da, History as ca, Trash2 as ua, Plus as pa } from "lucide-react";
3
+ import { ChevronDown as Rt, ChevronRight as Mt, Lock as oa, MoreHorizontal as ia, Split as Et, Undo2 as da, History as ca, Trash2 as ua, Plus as pa } from "lucide-react";
4
4
  import { useRef as me, useEffect as ue, useMemo as Z, useCallback as ee, useState as W } from "react";
5
5
  import { toast as ie } from "sonner";
6
6
  import { useNivaroClient as ma, useParentDraft as ha, useItemEditAuth as fa } from "../../context.js";
@@ -10,156 +10,156 @@ import { evaluateNumeric as nt } from "../../lib/expression.js";
10
10
  import { parseMoneyInput as ct } from "../../lib/money-input.js";
11
11
  import { userErrorMessage as ga } from "../../lib/safe-error.js";
12
12
  import { registerStagedRowLabel as ya } from "../../lib/staged-row-labels.js";
13
- import { cn as D, formatRelative as ba } from "../../lib/utils.js";
13
+ import { cn as B, formatRelative as ba } from "../../lib/utils.js";
14
14
  import { NumberDraftInput as ka } from "../ui/number-draft-input.js";
15
15
  import { Popover as ut, PopoverTrigger as pt, PopoverContent as mt } from "../ui/popover.js";
16
- import { resolveCompareEndpoint as va, useCompareSeries as Na, compareColumnClosed as wa, planLabel as It, closedThroughLabel as $a, CompareProposalBanner as Ca, CompareStripChips as Sa, GridStatChip as Tt, monthLabel as it, extraSeriesValue as Ce, SeriesFigurePopover as Pt, monthLabelLong as je, unitWord as _a } from "./CompareSeries.js";
17
- import { useO2MStaging as Oa, useLiveRows as Ra } from "./O2MStagingContext.js";
18
- import { usePlanGridHost as La } from "./PlanGridHost.js";
16
+ import { resolveCompareEndpoint as va, useCompareSeries as Na, compareColumnClosed as wa, planLabel as Dt, closedThroughLabel as $a, CompareProposalBanner as Ca, CompareStripChips as Sa, GridStatChip as Tt, monthLabel as it, extraSeriesValue as Ce, SeriesFigurePopover as Pt, monthLabelLong as je, unitWord as _a } from "./CompareSeries.js";
17
+ import { useO2MStaging as Oa, useLiveRows as La } from "./O2MStagingContext.js";
18
+ import { usePlanGridHost as Ra } from "./PlanGridHost.js";
19
19
  import { RowHistorySheet as Ma } from "./RowHistorySheet.js";
20
20
  import { RowWatchButton as Ea } from "./RowWatchButton.js";
21
- const ze = "unclassified", B = (b) => Number(b) || 0, F = (b) => Math.round(b * 100) / 100;
22
- function z(b) {
23
- const n = Math.abs(b - Math.round(b)) < 5e-3;
24
- return b.toLocaleString("en-US", {
21
+ const Ue = "unclassified", D = (k) => Number(k) || 0, K = (k) => Math.round(k * 100) / 100;
22
+ function U(k) {
23
+ const n = Math.abs(k - Math.round(k)) < 5e-3;
24
+ return k.toLocaleString("en-US", {
25
25
  style: "currency",
26
26
  currency: "USD",
27
27
  minimumFractionDigits: n ? 0 : 2,
28
28
  maximumFractionDigits: n ? 0 : 2
29
29
  });
30
30
  }
31
- function Bt(b) {
32
- const n = ct(b);
31
+ function Bt(k) {
32
+ const n = ct(k);
33
33
  return n.ok ? n.value : null;
34
34
  }
35
- function Dt(b) {
36
- const n = ct(b);
35
+ function Ut(k) {
36
+ const n = ct(k);
37
37
  return n.ok ? "Enter an amount of zero or more" : n.error;
38
38
  }
39
- function Ta(b, n, x, f = {}) {
40
- const i = b ? Object.keys(x).filter((M) => Math.abs(B(x[M]) - B(b[M])) < 5e-3) : [];
41
- if (i.length === 0) return { merge: { ...x, ...f }, replace: null };
42
- const k = Object.fromEntries(
43
- Object.entries({ ...n ?? {}, ...x, ...f }).filter(([M]) => !i.includes(M))
39
+ function Ta(k, n, h, f = {}) {
40
+ const i = k ? Object.keys(h).filter((P) => Math.abs(D(h[P]) - D(k[P])) < 5e-3) : [];
41
+ if (i.length === 0) return { merge: { ...h, ...f }, replace: null };
42
+ const b = Object.fromEntries(
43
+ Object.entries({ ...n ?? {}, ...h, ...f }).filter(([P]) => !i.includes(P))
44
44
  );
45
45
  return {
46
46
  merge: null,
47
- replace: Object.keys(k).some((M) => !M.startsWith("_")) ? k : null
47
+ replace: Object.keys(b).some((P) => !P.startsWith("_")) ? b : null
48
48
  };
49
49
  }
50
- function Pa(b, n) {
51
- return b[0] === "item" && b.length >= 3 && String(b[2]) === String(n);
50
+ function Pa(k, n) {
51
+ return k[0] === "item" && k.length >= 3 && String(k[2]) === String(n);
52
52
  }
53
- function ja(b) {
54
- const { column: n, actual: x, openColumns: f, mode: i } = b, k = b.targetRow != null, M = F(B(b.row[n]) - x), E = { [n]: F(x) }, K = b.targetRow ?? b.row, L = k ? {} : E;
55
- if (i === "none" || Math.abs(M) < 5e-3 || f.length === 0)
56
- return { patch: E, moved: 0, unabsorbed: i === "none" ? 0 : M, targets: [] };
57
- let p, N;
58
- if (i === "next" ? (p = [f[0]], N = [1]) : i === "weighted" ? (p = f.filter((g) => B(K[g]) > 5e-3), N = p.map((g) => B(K[g])), p.length === 0 && k && M > 0 && (p = f, N = p.map(() => 1))) : (p = f, N = p.map(() => 1)), p.length === 0) return { patch: E, moved: 0, unabsorbed: M, targets: [] };
59
- const v = N.reduce((g, j) => g + j, 0) || 1;
60
- let y = M;
61
- if (p.forEach((g, j) => {
62
- const C = j === p.length - 1 ? y : F(M * N[j] / v), q = Math.max(0, F(B(K[g]) + C)), s = F(q - B(K[g]));
63
- L[g] = q, y = F(y - s);
64
- }), Math.abs(y) >= 5e-3 && y < 0)
65
- for (const g of p) {
66
- if (Math.abs(y) < 5e-3) break;
67
- const j = Math.min(L[g], -y);
68
- L[g] = F(L[g] - j), y = F(y + j);
53
+ function ja(k) {
54
+ const { column: n, actual: h, openColumns: f, mode: i } = k, b = k.targetRow != null, P = K(D(k.row[n]) - h), j = { [n]: K(h) }, I = k.targetRow ?? k.row, T = b ? {} : j;
55
+ if (i === "none" || Math.abs(P) < 5e-3 || f.length === 0)
56
+ return { patch: j, moved: 0, unabsorbed: i === "none" ? 0 : P, targets: [] };
57
+ let x, N;
58
+ if (i === "next" ? (x = [f[0]], N = [1]) : i === "weighted" ? (x = f.filter((y) => D(I[y]) > 5e-3), N = x.map((y) => D(I[y])), x.length === 0 && b && P > 0 && (x = f, N = x.map(() => 1))) : (x = f, N = x.map(() => 1)), x.length === 0) return { patch: j, moved: 0, unabsorbed: P, targets: [] };
59
+ const M = N.reduce((y, _) => y + _, 0) || 1;
60
+ let w = P;
61
+ if (x.forEach((y, _) => {
62
+ const v = _ === x.length - 1 ? w : K(P * N[_] / M), R = Math.max(0, K(D(I[y]) + v)), s = K(R - D(I[y]));
63
+ T[y] = R, w = K(w - s);
64
+ }), Math.abs(w) >= 5e-3 && w < 0)
65
+ for (const y of x) {
66
+ if (Math.abs(w) < 5e-3) break;
67
+ const _ = Math.min(T[y], -w);
68
+ T[y] = K(T[y] - _), w = K(w + _);
69
69
  }
70
- return k ? {
71
- patch: E,
72
- targetPatch: L,
73
- moved: F(M - y),
74
- unabsorbed: y,
75
- targets: p
76
- } : { patch: L, moved: F(M - y), unabsorbed: y, targets: p };
70
+ return b ? {
71
+ patch: j,
72
+ targetPatch: T,
73
+ moved: K(P - w),
74
+ unabsorbed: w,
75
+ targets: x
76
+ } : { patch: T, moved: K(P - w), unabsorbed: w, targets: x };
77
77
  }
78
78
  const jt = 176, qt = 112, At = 128, Ne = "sticky left-0 z-[2] bg-white dark:bg-[hsl(var(--card))] border-r border-slate-200 dark:border-border", we = "sticky right-0 z-[2] bg-white dark:bg-[hsl(var(--card))] border-l border-slate-200 dark:border-border", Se = "bg-slate-50 dark:bg-white/[0.035]";
79
- function il(b) {
79
+ function dl(k) {
80
80
  const {
81
81
  relatedCollection: n,
82
- manyField: x,
82
+ manyField: h,
83
83
  parentId: f,
84
84
  config: i,
85
- compareSeries: k,
86
- stats: M,
87
- sumCap: E,
88
- remaining: K,
89
- readOnly: L = !1,
90
- showHistory: p = !0,
85
+ compareSeries: b,
86
+ stats: P,
87
+ sumCap: j,
88
+ remaining: I,
89
+ readOnly: T = !1,
90
+ showHistory: x = !0,
91
91
  emptyLabel: N
92
- } = b, v = ma(), y = sa(), g = Oa(), j = Ra(), I = ha(), C = I == null ? void 0 : I.draft, { isAdmin: q } = fa(), s = !f || f === "new", O = !L && !!g, h = i.value_fields, R = i.total_field ?? null, {
93
- data: T = [],
92
+ } = k, M = ma(), w = sa(), y = Oa(), _ = La(), O = ha(), v = O == null ? void 0 : O.draft, { isAdmin: R } = fa(), s = !f || f === "new", c = !T && !!y, d = i.value_fields, E = i.total_field ?? null, {
93
+ data: q = [],
94
94
  isLoading: de,
95
95
  dataUpdatedAt: re
96
96
  } = he({
97
- queryKey: ["o2m-rows", n, x, f, ""],
98
- queryFn: () => v.request(
99
- fe(`/items/${n}`, { filter: JSON.stringify({ [x]: { _eq: f } }), limit: 200 })
97
+ queryKey: ["o2m-rows", n, h, f, ""],
98
+ queryFn: () => M.request(
99
+ fe(`/items/${n}`, { filter: JSON.stringify({ [h]: { _eq: f } }), limit: 200 })
100
100
  ).then((e) => e.data ?? []),
101
101
  enabled: !s,
102
102
  staleTime: 3e4
103
- }), A = xa(2e3), { data: le = {} } = he({
104
- queryKey: ["o2m-cell-provenance", n, x, f, re],
105
- queryFn: () => v.request(
103
+ }), F = xa(2e3), { data: le = {} } = he({
104
+ queryKey: ["o2m-cell-provenance", n, h, f, re],
105
+ queryFn: () => M.request(
106
106
  fe("/revisions/o2m-cell-provenance", {
107
107
  collection: n,
108
- many_field: x,
108
+ many_field: h,
109
109
  parent_id: f
110
110
  })
111
111
  ).then((e) => e.data ?? {}),
112
- enabled: A && p && !s && T.length > 0,
112
+ enabled: F && x && !s && q.length > 0,
113
113
  staleTime: 6e4,
114
114
  placeholderData: (e) => e
115
115
  }), V = (e, a) => e.id ? `${n}:${e.id}:${a}` : void 0, ce = (e, a) => {
116
116
  var l;
117
117
  return e.id && !e.edited ? (l = le[e.id]) == null ? void 0 : l[a] : void 0;
118
- }, w = me(null), xe = (e, a) => {
118
+ }, $ = me(null), xe = (e, a) => {
119
119
  !e || typeof window > "u" || window.dispatchEvent(new CustomEvent("nvr:cell-editing", { detail: { cell: e, state: a } }));
120
120
  }, zt = (e) => {
121
121
  var l, r, o;
122
122
  const a = ((o = (r = (l = e.target) == null ? void 0 : l.closest) == null ? void 0 : r.call(l, "[data-grid-cell]")) == null ? void 0 : o.getAttribute("data-grid-cell")) ?? null;
123
- a !== w.current && (w.current && xe(w.current, "end"), w.current = a, a && xe(a, "start"));
124
- }, Ut = (e) => {
123
+ a !== $.current && ($.current && xe($.current, "end"), $.current = a, a && xe(a, "start"));
124
+ }, Wt = (e) => {
125
125
  var a, l;
126
- (l = (a = e.relatedTarget) == null ? void 0 : a.closest) != null && l.call(a, "[data-grid-cell]") || (w.current && xe(w.current, "end"), w.current = null);
126
+ (l = (a = e.relatedTarget) == null ? void 0 : a.closest) != null && l.call(a, "[data-grid-cell]") || ($.current && xe($.current, "end"), $.current = null);
127
127
  };
128
128
  ue(
129
129
  () => () => {
130
- w.current && xe(w.current, "end");
130
+ $.current && xe($.current, "end");
131
131
  },
132
132
  []
133
133
  );
134
134
  const qe = Z(
135
- () => k != null && k.endpoint ? va(k.endpoint, C) : null,
136
- [k == null ? void 0 : k.endpoint, C]
135
+ () => b != null && b.endpoint ? va(b.endpoint, v) : null,
136
+ [b == null ? void 0 : b.endpoint, v]
137
137
  ), Ae = Na({
138
- client: v,
138
+ client: M,
139
139
  endpoint: qe,
140
- enabled: !!k && !s
141
- }), u = k && !s ? Ae.data ?? null : null, ht = Ae.refetch, Fe = me(0);
140
+ enabled: !!b && !s
141
+ }), m = b && !s ? Ae.data ?? null : null, ht = Ae.refetch, Fe = me(0);
142
142
  ue(() => {
143
- if (!(!re || !k || s)) {
143
+ if (!(!re || !b || s)) {
144
144
  if (Fe.current === 0) {
145
145
  Fe.current = re;
146
146
  return;
147
147
  }
148
148
  re !== Fe.current && (Fe.current = re, ht());
149
149
  }
150
- }, [re, ht, k, s]);
150
+ }, [re, ht, b, s]);
151
151
  const ge = Z(() => !i.split_endpoint || s ? null : i.split_endpoint.replace(
152
152
  /\$parent\.([A-Za-z_][A-Za-z0-9_]*)/g,
153
- (e, a) => String(a === "id" ? f : (C == null ? void 0 : C[a]) ?? "")
154
- ), [i.split_endpoint, s, f, C]), Ue = Z(() => ["plan-grid-split-info", ge], [ge]), { data: pe = null } = he({
155
- queryKey: Ue,
156
- queryFn: () => v.request(fe(ge)).then((e) => e.data ?? null).catch(() => null),
153
+ (e, a) => String(a === "id" ? f : (v == null ? void 0 : v[a]) ?? "")
154
+ ), [i.split_endpoint, s, f, v]), ze = Z(() => ["plan-grid-split-info", ge], [ge]), { data: pe = null } = he({
155
+ queryKey: ze,
156
+ queryFn: () => M.request(fe(ge)).then((e) => e.data ?? null).catch(() => null),
157
157
  enabled: !!ge,
158
158
  staleTime: 3e4
159
159
  }), { data: ft = {} } = he({
160
160
  queryKey: ["plan-grid-categories", i.category_collection, i.category_label_field],
161
161
  queryFn: async () => {
162
- const e = i.category_label_field ?? "name", a = await v.request(
162
+ const e = i.category_label_field ?? "name", a = await M.request(
163
163
  fe(`/items/${i.category_collection}`, { fields: `id,${e}`, limit: 100 })
164
164
  );
165
165
  return Object.fromEntries((a.data ?? []).map((l) => [String(l.id), String(l[e] ?? l.id)]));
@@ -167,31 +167,31 @@ function il(b) {
167
167
  enabled: !!i.category_collection,
168
168
  staleTime: 10 * 6e4
169
169
  }), ye = ee(
170
- (e) => e === ze ? i.unclassified_label ?? "Unclassified" : ft[e] ?? `#${e}`,
170
+ (e) => e === Ue ? i.unclassified_label ?? "Unclassified" : ft[e] ?? `#${e}`,
171
171
  [ft, i.unclassified_label]
172
- ), We = Z(() => (i.categories ?? []).map(String), [i.categories]), He = (g == null ? void 0 : g.getPendingRows(n, x)) ?? [], se = g == null ? void 0 : g.getPendingEdits(n, x), be = g == null ? void 0 : g.getPendingDeletes(n, x), Ke = He.length + ((se == null ? void 0 : se.size) ?? 0) + ((be == null ? void 0 : be.size) ?? 0), xt = me(Ke);
172
+ ), We = Z(() => (i.categories ?? []).map(String), [i.categories]), He = (y == null ? void 0 : y.getPendingRows(n, h)) ?? [], se = y == null ? void 0 : y.getPendingEdits(n, h), be = y == null ? void 0 : y.getPendingDeletes(n, h), Ke = He.length + ((se == null ? void 0 : se.size) ?? 0) + ((be == null ? void 0 : be.size) ?? 0), xt = me(Ke);
173
173
  ue(() => {
174
174
  const e = xt.current;
175
175
  if (xt.current = Ke, s || !(e > 0 && Ke === 0)) return;
176
- const a = () => void y.invalidateQueries({ predicate: (r) => Pa(r.queryKey, f) });
176
+ const a = () => void w.invalidateQueries({ predicate: (r) => Pa(r.queryKey, f) });
177
177
  a();
178
178
  const l = setTimeout(a, 2e3);
179
179
  return () => clearTimeout(l);
180
- }, [Ke, s, f, y]);
180
+ }, [Ke, s, f, w]);
181
181
  const J = Z(() => {
182
182
  const e = [], a = (l) => l && typeof l == "object" && "id" in l ? l.id : l;
183
- for (const l of T) {
183
+ for (const l of q) {
184
184
  const r = String(l.id);
185
185
  if (be != null && be.has(r)) continue;
186
- const o = se == null ? void 0 : se.get(r), m = o ? { ...l, ...o } : l, _ = a(m[i.category_field]);
186
+ const o = se == null ? void 0 : se.get(r), g = o ? { ...l, ...o } : l, L = a(g[i.category_field]);
187
187
  e.push({
188
188
  uid: `s:${r}`,
189
189
  id: r,
190
190
  pendingIndex: null,
191
- key: String(a(m[i.key_field]) ?? ""),
192
- cat: _ == null || _ === "" ? null : String(_),
193
- values: m,
194
- edited: !!o && Object.keys(o).some((U) => !U.startsWith("_")),
191
+ key: String(a(g[i.key_field]) ?? ""),
192
+ cat: L == null || L === "" ? null : String(L),
193
+ values: g,
194
+ edited: !!o && Object.keys(o).some((z) => !z.startsWith("_")),
195
195
  isNew: !1
196
196
  });
197
197
  }
@@ -208,7 +208,7 @@ function il(b) {
208
208
  isNew: !0
209
209
  });
210
210
  }), e;
211
- }, [T, He, se, be, i.key_field, i.category_field]), gt = me(J);
211
+ }, [q, He, se, be, i.key_field, i.category_field]), gt = me(J);
212
212
  gt.current = J;
213
213
  const yt = me(() => "");
214
214
  ue(
@@ -219,8 +219,8 @@ function il(b) {
219
219
  [n]
220
220
  );
221
221
  const Y = ee(
222
- (e) => F(h.reduce((a, l) => a + B(e[l]), 0)),
223
- [h]
222
+ (e) => K(d.reduce((a, l) => a + D(e[l]), 0)),
223
+ [d]
224
224
  ), oe = Z(() => {
225
225
  const e = /* @__PURE__ */ new Map();
226
226
  for (const a of J) {
@@ -230,50 +230,50 @@ function il(b) {
230
230
  }
231
231
  for (const a of e.values())
232
232
  a.cats.length && (a.mode = "split", a.cats.sort((l, r) => {
233
- const o = We.indexOf(l.cat), m = We.indexOf(r.cat);
234
- return (o < 0 ? 99 : o) - (m < 0 ? 99 : m);
233
+ const o = We.indexOf(l.cat), g = We.indexOf(r.cat);
234
+ return (o < 0 ? 99 : o) - (g < 0 ? 99 : g);
235
235
  }));
236
- for (const a of (u == null ? void 0 : u.rows) ?? []) {
236
+ for (const a of (m == null ? void 0 : m.rows) ?? []) {
237
237
  const l = String(a.key);
238
- e.has(l) || h.some((r) => Math.abs(B(a.values[r])) >= 5e-3) && e.set(l, { key: l, mode: "ghost", top: null, cats: [] });
238
+ e.has(l) || d.some((r) => Math.abs(D(a.values[r])) >= 5e-3) && e.set(l, { key: l, mode: "ghost", top: null, cats: [] });
239
239
  }
240
240
  return [...e.values()].sort(
241
241
  (a, l) => Number(a.key) - Number(l.key) || a.key.localeCompare(l.key)
242
242
  );
243
- }, [J, u, h, We]), _e = Z(
244
- () => J.map((e) => R ? { ...e.values, [R]: Y(e.values) } : e.values),
245
- [J, R, Y]
246
- ), ke = j == null ? void 0 : j.report;
243
+ }, [J, m, d, We]), _e = Z(
244
+ () => J.map((e) => E ? { ...e.values, [E]: Y(e.values) } : e.values),
245
+ [J, E, Y]
246
+ ), ke = _ == null ? void 0 : _.report;
247
247
  ue(() => {
248
248
  if (ke) {
249
249
  if (de) {
250
- ke(n, x, null);
250
+ ke(n, h, null);
251
251
  return;
252
252
  }
253
- ke(n, x, _e);
253
+ ke(n, h, _e);
254
254
  }
255
- }, [ke, n, x, _e, de]);
255
+ }, [ke, n, h, _e, de]);
256
256
  const bt = me(() => {
257
257
  });
258
- bt.current = () => ke == null ? void 0 : ke(n, x, null), ue(() => () => bt.current(), []);
258
+ bt.current = () => ke == null ? void 0 : ke(n, h, null), ue(() => () => bt.current(), []);
259
259
  const Oe = ee(
260
260
  (e) => {
261
- if (e.startsWith("$parent.")) return (C == null ? void 0 : C[e.slice(8)]) ?? 0;
261
+ if (e.startsWith("$parent.")) return (v == null ? void 0 : v[e.slice(8)]) ?? 0;
262
262
  if (e.startsWith("$sum.")) {
263
263
  const a = e.slice(5);
264
- return _e.reduce((l, r) => l + B(r[a]), 0);
264
+ return _e.reduce((l, r) => l + D(r[a]), 0);
265
265
  }
266
- return e === "$count" ? _e.length : C == null ? void 0 : C[e];
266
+ return e === "$count" ? _e.length : v == null ? void 0 : v[e];
267
267
  },
268
- [C, _e]
268
+ [v, _e]
269
269
  ), kt = Z(
270
- () => (M ?? []).map((e) => ({ ...e, result: nt(e.value, Oe) })),
271
- [M, Oe]
270
+ () => (P ?? []).map((e) => ({ ...e, result: nt(e.value, Oe) })),
271
+ [P, Oe]
272
272
  ), Qe = Z(
273
- () => F(J.reduce((e, a) => e + Y(a.values), 0)),
273
+ () => K(J.reduce((e, a) => e + Y(a.values), 0)),
274
274
  [J, Y]
275
- ), Re = Z(() => pe ? pe.categories.filter((e) => e.cap > 5e-3 || J.some((a) => a.cat === String(e.id))).map((e) => {
276
- const a = F(
275
+ ), Le = Z(() => pe ? pe.categories.filter((e) => e.cap > 5e-3 || J.some((a) => a.cat === String(e.id))).map((e) => {
276
+ const a = K(
277
277
  J.filter((l) => l.cat === String(e.id)).reduce((l, r) => l + Y(r.values), 0)
278
278
  );
279
279
  return {
@@ -281,59 +281,59 @@ function il(b) {
281
281
  label: e.label,
282
282
  cap: e.cap,
283
283
  planned: a,
284
- left: F(e.cap - a)
284
+ left: K(e.cap - a)
285
285
  };
286
286
  }) : [], [pe, J, Y]), G = ee(
287
- (e, a) => wa(u, e, a),
288
- [u]
287
+ (e, a) => wa(m, e, a),
288
+ [m]
289
289
  ), Ie = ee(
290
- (e, a) => !O || G(e, a) && !!(u != null && u.closed_locked) && !q,
291
- [O, G, u == null ? void 0 : u.closed_locked, q]
292
- ), Le = ee(
290
+ (e, a) => !c || G(e, a) && !!(m != null && m.closed_locked) && !R,
291
+ [c, G, m == null ? void 0 : m.closed_locked, R]
292
+ ), Re = ee(
293
293
  (e, a, l) => {
294
- var m, _, U;
295
- const r = u == null ? void 0 : u.rows.find((P) => String(P.key) === e);
294
+ var g, L, z;
295
+ const r = m == null ? void 0 : m.rows.find((A) => String(A.key) === e);
296
296
  if (!r) return { value: 0, details: [] };
297
- if (a == null) return { value: B(r.values[l]), details: ((m = r.details) == null ? void 0 : m[l]) ?? [] };
298
- const o = (_ = r.by_category) == null ? void 0 : _[a];
299
- return { value: B(o == null ? void 0 : o.values[l]), details: ((U = o == null ? void 0 : o.details) == null ? void 0 : U[l]) ?? [] };
297
+ if (a == null) return { value: D(r.values[l]), details: ((g = r.details) == null ? void 0 : g[l]) ?? [] };
298
+ const o = (L = r.by_category) == null ? void 0 : L[a];
299
+ return { value: D(o == null ? void 0 : o.values[l]), details: ((z = o == null ? void 0 : o.details) == null ? void 0 : z[l]) ?? [] };
300
300
  },
301
- [u]
301
+ [m]
302
302
  ), [vt, Ve] = W(null), X = ee(
303
303
  (e, a, l, r) => {
304
- if (!g) return !1;
305
- const o = (r == null ? void 0 : r.credit) ?? 0, m = { ...e.values, ...a }, _ = Y(e.values), U = Y(m);
306
- if (U - o > _ + 5e-3) {
307
- if (E) {
308
- const P = nt(E.cap, Oe), $ = F(Qe - _ + U - o);
309
- if (P != null && $ > P + 5e-3)
304
+ if (!y) return !1;
305
+ const o = (r == null ? void 0 : r.credit) ?? 0, g = { ...e.values, ...a }, L = Y(e.values), z = Y(g);
306
+ if (z - o > L + 5e-3) {
307
+ if (j) {
308
+ const A = nt(j.cap, Oe), C = K(Qe - L + z - o);
309
+ if (A != null && C > A + 5e-3)
310
310
  return Ve(
311
- `${E.message ?? `${E.label ?? "The total"} cannot exceed ${z(P)}`} — this would reach ${z($)}, ${z(F($ - P))} over.`
311
+ `${j.message ?? `${j.label ?? "The total"} cannot exceed ${U(A)}`} — this would reach ${U(C)}, ${U(K(C - A))} over.`
312
312
  ), !1;
313
313
  }
314
314
  if (e.cat != null) {
315
- const P = Re.find(($) => $.id === e.cat);
316
- if (P) {
317
- const $ = F(P.planned - _ + U - o);
318
- if ($ > P.cap + 5e-3)
315
+ const A = Le.find((C) => C.id === e.cat);
316
+ if (A) {
317
+ const C = K(A.planned - L + z - o);
318
+ if (C > A.cap + 5e-3)
319
319
  return Ve(
320
- `${P.label} would reach ${z($)} — ${z(F($ - P.cap))} over its ${z(P.cap)}.`
320
+ `${A.label} would reach ${U(C)} — ${U(K(C - A.cap))} over its ${U(A.cap)}.`
321
321
  ), !1;
322
322
  }
323
323
  }
324
324
  }
325
325
  if (Ve(null), e.id) {
326
- const P = {
326
+ const A = {
327
327
  ...l ? { _change_reason: l } : {},
328
328
  ...r != null && r.early ? { __flush_early: !0 } : {}
329
- }, $ = Ta(
330
- T.find((H) => String(H.id) === e.id),
329
+ }, C = Ta(
330
+ q.find((H) => String(H.id) === e.id),
331
331
  se == null ? void 0 : se.get(e.id),
332
332
  a,
333
- P
333
+ A
334
334
  );
335
- $.merge ? g.queueEdit(n, x, e.id, $.merge) : (g.cancelPendingEdit(n, x, e.id), $.replace && g.queueEdit(n, x, e.id, $.replace));
336
- } else e.pendingIndex != null && g.updateRow(n, x, e.pendingIndex, {
335
+ C.merge ? y.queueEdit(n, h, e.id, C.merge) : (y.cancelPendingEdit(n, h, e.id), C.replace && y.queueEdit(n, h, e.id, C.replace));
336
+ } else e.pendingIndex != null && y.updateRow(n, h, e.pendingIndex, {
337
337
  ...e.values,
338
338
  ...a,
339
339
  ...l ? { _change_reason: l } : {}
@@ -341,64 +341,64 @@ function il(b) {
341
341
  return !0;
342
342
  },
343
343
  [
344
- g,
344
+ y,
345
345
  Y,
346
- E,
346
+ j,
347
347
  Oe,
348
348
  Qe,
349
- Re,
349
+ Le,
350
350
  n,
351
- x,
352
- T,
351
+ h,
352
+ q,
353
353
  se
354
354
  ]
355
355
  ), Me = ee(
356
356
  (e, a, l, r) => {
357
- g && g.queueRow(n, x, {
357
+ y && y.queueRow(n, h, {
358
358
  [i.key_field]: e,
359
359
  ...r != null ? { [i.category_field]: /^\d+$/.test(r) ? Number(r) : r } : {},
360
- ...Object.fromEntries(h.map((o) => [o, (a == null ? void 0 : a[o]) ?? 0])),
360
+ ...Object.fromEntries(d.map((o) => [o, (a == null ? void 0 : a[o]) ?? 0])),
361
361
  ...l ? { _change_reason: l } : {}
362
362
  });
363
363
  },
364
- [g, n, x, i.key_field, i.category_field, h]
364
+ [y, n, h, i.key_field, i.category_field, d]
365
365
  ), { data: Je } = he({
366
366
  queryKey: ["plan-grid-keys", i.key_collection],
367
- queryFn: () => v.request(
367
+ queryFn: () => M.request(
368
368
  fe(`/items/${i.key_collection}`, { fields: "id", sort: "-id", limit: 200 })
369
369
  ).then((e) => (e.data ?? []).map((a) => a.id)),
370
- enabled: !!i.key_collection && !!(u != null && u.closed_through),
370
+ enabled: !!i.key_collection && !!(m != null && m.closed_through),
371
371
  staleTime: 10 * 6e4
372
372
  }), Ge = ee(
373
373
  (e, a) => {
374
374
  const l = Number(e);
375
375
  if (!Number.isInteger(l)) return null;
376
- const r = String(l + 1), o = h.filter((P) => !G(r, P)), m = oe.find((P) => P.key === r);
377
- let _ = null, U = null;
378
- return i.key_collection && Je && !Je.some((P) => String(P) === r) ? U = `${r} is not set up yet` : o.length === 0 ? U = `${r} has no open period either` : (m == null ? void 0 : m.mode) === "split" ? a == null ? U = `${r} is planned by category and this line is not` : _ = m.cats.find((P) => P.cat === a) ?? null : (m == null ? void 0 : m.mode) === "top" && (a != null ? U = `${r} is planned as one line and this one is by category` : _ = m.top), { key: r, cat: a, openColumns: o, row: _, blocked: U };
376
+ const r = String(l + 1), o = d.filter((A) => !G(r, A)), g = oe.find((A) => A.key === r);
377
+ let L = null, z = null;
378
+ return i.key_collection && Je && !Je.some((A) => String(A) === r) ? z = `${r} is not set up yet` : o.length === 0 ? z = `${r} has no open period either` : (g == null ? void 0 : g.mode) === "split" ? a == null ? z = `${r} is planned by category and this line is not` : L = g.cats.find((A) => A.cat === a) ?? null : (g == null ? void 0 : g.mode) === "top" && (a != null ? z = `${r} is planned as one line and this one is by category` : L = g.top), { key: r, cat: a, openColumns: o, row: L, blocked: z };
379
379
  },
380
- [h, G, oe, i.key_collection, Je]
380
+ [d, G, oe, i.key_collection, Je]
381
381
  ), Ze = ee(
382
382
  (e, a, l, r) => {
383
383
  if (!r || Object.keys(r.patch).length === 0) return X(e, a, l);
384
- const o = F(Y({ ...e.values, ...a }) - Y(e.values)), m = r.target.row, _ = F(
385
- Y({ ...(m == null ? void 0 : m.values) ?? {}, ...r.patch }) - Y((m == null ? void 0 : m.values) ?? {})
384
+ const o = K(Y({ ...e.values, ...a }) - Y(e.values)), g = r.target.row, L = K(
385
+ Y({ ...(g == null ? void 0 : g.values) ?? {}, ...r.patch }) - Y((g == null ? void 0 : g.values) ?? {})
386
386
  );
387
- return o <= 0 ? m ? X(m, r.patch, l, { credit: -o }) ? X(e, a, l, { early: !0 }) : !1 : _ > -o + 5e-3 || !X(e, a, l, { early: !0 }) ? !1 : (Me(Number(r.target.key), r.patch, l, r.target.cat), !0) : m ? X(e, a, l, { credit: -_ }) ? X(m, r.patch, l, { early: !0 }) : !1 : X(e, a, l);
387
+ return o <= 0 ? g ? X(g, r.patch, l, { credit: -o }) ? X(e, a, l, { early: !0 }) : !1 : L > -o + 5e-3 || !X(e, a, l, { early: !0 }) ? !1 : (Me(Number(r.target.key), r.patch, l, r.target.cat), !0) : g ? X(e, a, l, { credit: -L }) ? X(g, r.patch, l, { early: !0 }) : !1 : X(e, a, l);
388
388
  },
389
389
  [X, Y, Me]
390
- ), Wt = ee(
390
+ ), Ht = ee(
391
391
  (e) => {
392
- if (!g) return;
392
+ if (!y) return;
393
393
  const a = [...e.top ? [e.top] : [], ...e.cats];
394
394
  for (const l of a.filter((r) => r.pendingIndex != null).sort((r, o) => (o.pendingIndex ?? 0) - (r.pendingIndex ?? 0)))
395
- g.removeRow(n, x, l.pendingIndex);
396
- for (const l of a) l.id && g.queueDelete(n, x, l.id);
395
+ y.removeRow(n, h, l.pendingIndex);
396
+ for (const l of a) l.id && y.queueDelete(n, h, l.id);
397
397
  },
398
- [g, n, x]
399
- ), Ht = ee(() => {
400
- y.invalidateQueries({ queryKey: ["o2m-rows", n, x, f] }), y.invalidateQueries({ queryKey: Ue }), qe && y.invalidateQueries({ queryKey: ["o2m-compare", qe] });
401
- }, [y, n, x, f, Ue, qe]), Ye = me(null), ve = Z(() => {
398
+ [y, n, h]
399
+ ), Qt = ee(() => {
400
+ w.invalidateQueries({ queryKey: ["o2m-rows", n, h, f] }), w.invalidateQueries({ queryKey: ze }), qe && w.invalidateQueries({ queryKey: ["o2m-compare", qe] });
401
+ }, [w, n, h, f, ze, qe]), Ye = me(null), ve = Z(() => {
402
402
  const e = [];
403
403
  for (const a of oe)
404
404
  if (a.mode === "top" && a.top && e.push(a.top.uid), a.mode === "split") for (const l of a.cats) e.push(l.uid);
@@ -409,37 +409,37 @@ function il(b) {
409
409
  return l ? (l.focus(), l.select(), !0) : !1;
410
410
  }, []), wt = ee(
411
411
  (e, a, l, r) => {
412
- let o = ve.indexOf(e), m = h.indexOf(a);
413
- for (let _ = 0; _ < 40; _++)
414
- if (o += l, m += r, o < 0 || o >= ve.length || m < 0 || m >= h.length || Nt(ve[o], h[m])) return;
412
+ let o = ve.indexOf(e), g = d.indexOf(a);
413
+ for (let L = 0; L < 40; L++)
414
+ if (o += l, g += r, o < 0 || o >= ve.length || g < 0 || g >= d.length || Nt(ve[o], d[g])) return;
415
415
  },
416
- [ve, h, Nt]
416
+ [ve, d, Nt]
417
417
  ), $t = ee(
418
418
  (e, a, l) => {
419
419
  const r = l.replace(/\r/g, "").split(`
420
- `).filter((P) => P.trim() !== ""), o = ve.indexOf(e.uid), m = h.indexOf(a);
421
- let _ = 0;
422
- const U = [];
423
- r.forEach((P, $) => {
424
- const H = J.find((d) => d.uid === ve[o + $]);
420
+ `).filter((A) => A.trim() !== ""), o = ve.indexOf(e.uid), g = d.indexOf(a);
421
+ let L = 0;
422
+ const z = [];
423
+ r.forEach((A, C) => {
424
+ const H = J.find((p) => p.uid === ve[o + C]);
425
425
  if (!H) return;
426
426
  const te = {};
427
- P.split(" ").forEach((d, S) => {
428
- const ae = h[m + S];
427
+ A.split(" ").forEach((p, S) => {
428
+ const ae = d[g + S];
429
429
  if (!ae || Ie(H.key, ae)) return;
430
- const Pe = Bt(d);
430
+ const Pe = Bt(p);
431
431
  if (Pe == null || Pe < 0) {
432
- U.push(d.trim());
432
+ z.push(p.trim());
433
433
  return;
434
434
  }
435
435
  te[ae] = Pe;
436
- }), Object.keys(te).length && X(H, te) && (_ += Object.keys(te).length);
437
- }), U.length && ie.error(
438
- `${U.length} pasted ${U.length === 1 ? "cell was" : "cells were"} left out — ${Dt(U[0])}`
439
- ), _ && ie.success(`Pasted ${_} ${_ === 1 ? "figure" : "figures"}`);
436
+ }), Object.keys(te).length && X(H, te) && (L += Object.keys(te).length);
437
+ }), z.length && ie.error(
438
+ `${z.length} pasted ${z.length === 1 ? "cell was" : "cells were"} left out — ${Ut(z[0])}`
439
+ ), L && ie.success(`Pasted ${L} ${L === 1 ? "figure" : "figures"}`);
440
440
  },
441
- [ve, h, J, Ie, X]
442
- ), [Qt, Ct] = W(/* @__PURE__ */ new Set()), Xe = me(null);
441
+ [ve, d, J, Ie, X]
442
+ ), [Vt, Ct] = W(/* @__PURE__ */ new Set()), Xe = me(null);
443
443
  ue(() => {
444
444
  const e = (a) => {
445
445
  const l = a.detail;
@@ -449,17 +449,17 @@ function il(b) {
449
449
  Xe.current = null;
450
450
  }, 8e3), Ct((o) => {
451
451
  if (!o.has(r.key)) return o;
452
- const m = new Set(o);
453
- return m.delete(r.key), m;
452
+ const g = new Set(o);
453
+ return g.delete(r.key), g;
454
454
  }), window.setTimeout(() => {
455
- var m;
456
- const o = (m = Ye.current) == null ? void 0 : m.querySelector(`[data-o2m-row="${n}:${r.id}"]`);
455
+ var g;
456
+ const o = (g = Ye.current) == null ? void 0 : g.querySelector(`[data-o2m-row="${n}:${r.id}"]`);
457
457
  o && (o.scrollIntoView({ block: "center", behavior: "smooth" }), o.classList.remove("nvr-row-flash"), o.offsetWidth, o.classList.add("nvr-row-flash"));
458
458
  }, 60)));
459
459
  };
460
460
  return window.addEventListener("nvr:grid-open-row", e), () => window.removeEventListener("nvr:grid-open-row", e);
461
461
  }, [n, J]);
462
- const [Vt, Jt] = W(() => {
462
+ const [Jt, Gt] = W(() => {
463
463
  try {
464
464
  return new Set(
465
465
  JSON.parse(localStorage.getItem(`nvr_pg_dismissed:${n}:${f}`) ?? "[]")
@@ -467,8 +467,8 @@ function il(b) {
467
467
  } catch {
468
468
  return /* @__PURE__ */ new Set();
469
469
  }
470
- }), St = ((u == null ? void 0 : u.proposals) ?? []).filter((e) => !Vt.has(e.id)), _t = (e, a) => {
471
- Jt((l) => {
470
+ }), St = ((m == null ? void 0 : m.proposals) ?? []).filter((e) => !Jt.has(e.id)), _t = (e, a) => {
471
+ Gt((l) => {
472
472
  const r = new Set(l).add(e.id);
473
473
  if (a)
474
474
  try {
@@ -477,36 +477,36 @@ function il(b) {
477
477
  }
478
478
  return r;
479
479
  });
480
- }, Gt = (e) => {
480
+ }, Zt = (e) => {
481
481
  let a = 0;
482
482
  for (const l of e.rows) {
483
- const r = String(l.key), o = oe.find(($) => $.key === r);
483
+ const r = String(l.key), o = oe.find((C) => C.key === r);
484
484
  if ((o == null ? void 0 : o.mode) === "split" != (l.category != null)) continue;
485
- const m = e.mode === "add", _ = Object.fromEntries(
485
+ const g = e.mode === "add", L = Object.fromEntries(
486
486
  Object.entries(l.values).filter(
487
- ([$, H]) => h.includes($) && !G(r, $) && (m ? B(H) !== 0 : B(H) > 0)
487
+ ([C, H]) => d.includes(C) && !G(r, C) && (g ? D(H) !== 0 : D(H) > 0)
488
488
  )
489
- ), U = ($) => Object.fromEntries(
490
- Object.entries(_).map(([H, te]) => [H, Math.max(0, F(B($ == null ? void 0 : $[H]) + B(te)))]).filter(([H, te]) => Math.abs(te - B($ == null ? void 0 : $[H])) >= 5e-3)
491
- ), P = l.category != null ? o == null ? void 0 : o.cats.find(($) => String($.cat) === String(l.category)) : null;
489
+ ), z = (C) => Object.fromEntries(
490
+ Object.entries(L).map(([H, te]) => [H, Math.max(0, K(D(C == null ? void 0 : C[H]) + D(te)))]).filter(([H, te]) => Math.abs(te - D(C == null ? void 0 : C[H])) >= 5e-3)
491
+ ), A = l.category != null ? o == null ? void 0 : o.cats.find((C) => String(C.cat) === String(l.category)) : null;
492
492
  if (l.category != null) {
493
- if (!P) continue;
494
- const $ = m ? U(P.values) : Object.fromEntries(Object.entries(_).filter(([H]) => B(P.values[H]) === 0));
495
- Object.keys($).length && X(P, $, e.change_reason) && (a += Object.keys($).length);
493
+ if (!A) continue;
494
+ const C = g ? z(A.values) : Object.fromEntries(Object.entries(L).filter(([H]) => D(A.values[H]) === 0));
495
+ Object.keys(C).length && X(A, C, e.change_reason) && (a += Object.keys(C).length);
496
496
  } else if (o != null && o.top) {
497
- const $ = m ? U(o.top.values) : Object.fromEntries(Object.entries(_).filter(([H]) => {
497
+ const C = g ? z(o.top.values) : Object.fromEntries(Object.entries(L).filter(([H]) => {
498
498
  var te;
499
- return B((te = o.top) == null ? void 0 : te.values[H]) === 0;
499
+ return D((te = o.top) == null ? void 0 : te.values[H]) === 0;
500
500
  }));
501
- Object.keys($).length && X(o.top, $, e.change_reason) && (a += Object.keys($).length);
502
- } else Object.keys(_).length && !(m && Object.values(_).every(($) => B($) < 0)) && (Me(l.key, m ? U(void 0) : _, e.change_reason), a += Object.keys(_).length);
501
+ Object.keys(C).length && X(o.top, C, e.change_reason) && (a += Object.keys(C).length);
502
+ } else Object.keys(L).length && !(g && Object.values(L).every((C) => D(C) < 0)) && (Me(l.key, g ? z(void 0) : L, e.change_reason), a += Object.keys(L).length);
503
503
  }
504
504
  a ? ie.success(
505
505
  `${e.label}: ${a} ${a === 1 ? "figure" : "figures"} staged — Save to keep them`
506
506
  ) : ie.message(
507
507
  e.mode === "add" ? "Nothing to move — no open period could take it" : "Nothing to fill — those periods already hold a figure"
508
508
  ), _t(e, !1);
509
- }, [Q, et] = W(null), Be = La(), tt = Q && (Be != null && Be.renderRowHistory) ? Be.renderRowHistory({
509
+ }, [Q, et] = W(null), De = Ra(), tt = Q && (De != null && De.renderRowHistory) ? De.renderRowHistory({
510
510
  collection: n,
511
511
  parentId: f,
512
512
  rowId: Q.id,
@@ -514,34 +514,34 @@ function il(b) {
514
514
  category: Q.cat,
515
515
  categoryLabel: (e) => ye(String(e)),
516
516
  onClose: () => et(null)
517
- }) : null, { data: Zt = [], isLoading: Yt } = he({
517
+ }) : null, { data: Yt = [], isLoading: Xt } = he({
518
518
  queryKey: ["o2m-row-revisions", n, Q == null ? void 0 : Q.id],
519
- queryFn: () => v.request(
519
+ queryFn: () => M.request(
520
520
  fe("/revisions", { collection: n, item: String(Q == null ? void 0 : Q.id) })
521
521
  ).then((e) => e.data ?? []),
522
522
  enabled: !!(Q != null && Q.id) && tt == null,
523
523
  staleTime: 15e3
524
524
  }), { data: Ot = [] } = he({
525
525
  queryKey: ["plan-grid-fields", n],
526
- queryFn: () => v.request(fe(`/field-config/${n}`)).then((e) => e.data ?? []),
526
+ queryFn: () => M.request(fe(`/field-config/${n}`)).then((e) => e.data ?? []),
527
527
  enabled: !!Q,
528
528
  staleTime: 5 * 6e4
529
- }), [at, Xt] = W(!1), Rt = oe.some((e) => e.mode === "split"), Ee = It(u);
529
+ }), [at, ea] = W(!1), Lt = oe.some((e) => e.mode === "split"), Ee = Dt(m);
530
530
  yt.current = (e) => `${e.key} ${Ee.toLowerCase()}${e.cat != null ? ` · ${ye(e.cat)}` : ""}`;
531
- const $e = (u == null ? void 0 : u.label) ?? (k == null ? void 0 : k.label) ?? "Actual", De = $a(u == null ? void 0 : u.closed_through), Te = u != null && u.closed_through ? Number(u.closed_through.split("-")[0]) : null, ea = Z(() => {
531
+ const $e = (m == null ? void 0 : m.label) ?? (b == null ? void 0 : b.label) ?? "Actual", Be = $a(m == null ? void 0 : m.closed_through), Te = m != null && m.closed_through ? Number(m.closed_through.split("-")[0]) : null, ta = Z(() => {
532
532
  if (Te == null) return null;
533
- const e = h.filter((a) => G(String(Te), a));
533
+ const e = d.filter((a) => G(String(Te), a));
534
534
  return e[e.length - 1] ?? null;
535
- }, [Te, h, G]), ta = Z(
535
+ }, [Te, d, G]), aa = Z(
536
536
  () => new Set(oe.filter((e) => e.mode !== "ghost").map((e) => e.key)),
537
537
  [oe]
538
- ), aa = K ? nt(K, Oe) : null, la = (e) => {
539
- let a = aa ?? 0;
538
+ ), la = I ? nt(I, Oe) : null, na = (e) => {
539
+ let a = la ?? 0;
540
540
  if (e.cat != null) {
541
- const m = Re.find((_) => _.id === e.cat);
542
- m && (a = Math.min(a, m.left));
541
+ const g = Le.find((L) => L.id === e.cat);
542
+ g && (a = Math.min(a, g.left));
543
543
  }
544
- const l = h.filter((m) => !G(e.key, m) && B(e.values[m]) === 0);
544
+ const l = d.filter((g) => !G(e.key, g) && D(e.values[g]) === 0);
545
545
  if (a < 5e-3 || l.length === 0) {
546
546
  ie.message(
547
547
  a < 5e-3 ? "Nothing is left to spread" : "No empty open periods on this line"
@@ -549,15 +549,15 @@ function il(b) {
549
549
  return;
550
550
  }
551
551
  const r = Math.floor(a / l.length * 100) / 100, o = {};
552
- l.forEach((m, _) => {
553
- o[m] = _ === l.length - 1 ? F(a - r * (l.length - 1)) : r;
554
- }), X(e, o) && ie.success(`${z(a)} spread over ${l.length} open periods`);
552
+ l.forEach((g, L) => {
553
+ o[g] = L === l.length - 1 ? K(a - r * (l.length - 1)) : r;
554
+ }), X(e, o) && ie.success(`${U(a)} spread over ${l.length} open periods`);
555
555
  }, lt = Z(() => {
556
556
  const e = {}, a = {};
557
- for (const l of h)
558
- e[l] = F(J.reduce((r, o) => r + B(o.values[l]), 0)), a[l] = F(((u == null ? void 0 : u.rows) ?? []).reduce((r, o) => r + B(o.values[l]), 0));
557
+ for (const l of d)
558
+ e[l] = K(J.reduce((r, o) => r + D(o.values[l]), 0)), a[l] = K(((m == null ? void 0 : m.rows) ?? []).reduce((r, o) => r + D(o.values[l]), 0));
559
559
  return { planBy: e, actualBy: a };
560
- }, [h, J, u]), na = jt + h.length * qt + At;
560
+ }, [d, J, m]), ra = jt + d.length * qt + At;
561
561
  return !s && de ? /* @__PURE__ */ t("div", { className: "space-y-1.5", "data-plan-grid-loading": !0, children: [0, 1, 2].map((e) => /* @__PURE__ */ t(
562
562
  "div",
563
563
  {
@@ -565,22 +565,22 @@ function il(b) {
565
565
  style: { background: "hsl(var(--nvr-skeleton))" }
566
566
  },
567
567
  e
568
- )) }) : /* @__PURE__ */ c("div", { ref: Ye, "data-plan-grid": n, className: "min-w-0", children: [
569
- u && St.length > 0 && O && /* @__PURE__ */ t(
568
+ )) }) : /* @__PURE__ */ u("div", { ref: Ye, "data-plan-grid": n, className: "min-w-0", children: [
569
+ m && St.length > 0 && c && /* @__PURE__ */ t(
570
570
  Ca,
571
571
  {
572
572
  proposals: St,
573
- onApply: Gt,
573
+ onApply: Zt,
574
574
  onDismiss: (e) => _t(e, !0)
575
575
  }
576
576
  ),
577
- (kt.length > 0 || k) && /* @__PURE__ */ c("div", { className: "mb-2 flex flex-wrap items-center gap-1.5", "data-o2m-stats": !0, children: [
577
+ (kt.length > 0 || b) && /* @__PURE__ */ u("div", { className: "mb-2 flex flex-wrap items-center gap-1.5", "data-o2m-stats": !0, children: [
578
578
  /* @__PURE__ */ t(
579
579
  Sa,
580
580
  {
581
- data: u,
582
- loading: !!k && !s && Ae.isLoading,
583
- error: !!k && !s && Ae.isError
581
+ data: m,
582
+ loading: !!b && !s && Ae.isLoading,
583
+ error: !!b && !s && Ae.isError
584
584
  }
585
585
  ),
586
586
  kt.map((e) => /* @__PURE__ */ t(
@@ -593,26 +593,26 @@ function il(b) {
593
593
  },
594
594
  e.label
595
595
  )),
596
- Re.length > 1 && Rt && /* @__PURE__ */ c(
596
+ Le.length > 1 && Lt && /* @__PURE__ */ u(
597
597
  "button",
598
598
  {
599
599
  type: "button",
600
600
  "data-plan-grid-categories-toggle": !0,
601
601
  "aria-expanded": at,
602
- onClick: () => Xt((e) => !e),
602
+ onClick: () => ea((e) => !e),
603
603
  className: "inline-flex h-[28px] items-center gap-1 rounded-md px-2 text-[11.5px] font-medium text-slate-600 hover:bg-muted dark:text-slate-300",
604
604
  children: [
605
- at ? /* @__PURE__ */ t(Lt, { className: "h-3.5 w-3.5" }) : /* @__PURE__ */ t(Mt, { className: "h-3.5 w-3.5" }),
605
+ at ? /* @__PURE__ */ t(Rt, { className: "h-3.5 w-3.5" }) : /* @__PURE__ */ t(Mt, { className: "h-3.5 w-3.5" }),
606
606
  "By category"
607
607
  ]
608
608
  }
609
609
  )
610
610
  ] }),
611
- at && Rt && /* @__PURE__ */ t("div", { className: "mb-2 flex flex-wrap gap-1.5", "data-plan-grid-categories": !0, children: Re.map((e) => /* @__PURE__ */ t(
611
+ at && Lt && /* @__PURE__ */ t("div", { className: "mb-2 flex flex-wrap gap-1.5", "data-plan-grid-categories": !0, children: Le.map((e) => /* @__PURE__ */ t(
612
612
  Tt,
613
613
  {
614
614
  dataKey: `category:${e.id}`,
615
- label: `${e.label} left of ${z(e.cap)}`,
615
+ label: `${e.label} left of ${U(e.cap)}`,
616
616
  value: e.left,
617
617
  format: "currency",
618
618
  negative: e.left < -5e-3
@@ -625,50 +625,50 @@ function il(b) {
625
625
  className: "overflow-x-auto rounded-lg border border-slate-200 dark:border-border",
626
626
  "data-plan-grid-scroll": !0,
627
627
  onFocusCapture: zt,
628
- onBlurCapture: Ut,
629
- children: /* @__PURE__ */ c(
628
+ onBlurCapture: Wt,
629
+ children: /* @__PURE__ */ u(
630
630
  "table",
631
631
  {
632
632
  className: "border-separate border-spacing-0 text-[12px] tabular-nums",
633
- style: { width: "100%", minWidth: na, tableLayout: "fixed" },
633
+ style: { width: "100%", minWidth: ra, tableLayout: "fixed" },
634
634
  children: [
635
- /* @__PURE__ */ c("colgroup", { children: [
635
+ /* @__PURE__ */ u("colgroup", { children: [
636
636
  /* @__PURE__ */ t("col", { style: { width: jt } }),
637
- h.map((e) => /* @__PURE__ */ t("col", { style: { width: qt } }, e)),
637
+ d.map((e) => /* @__PURE__ */ t("col", { style: { width: qt } }, e)),
638
638
  /* @__PURE__ */ t("col", { style: { width: At } })
639
639
  ] }),
640
- /* @__PURE__ */ t("thead", { children: /* @__PURE__ */ c("tr", { children: [
640
+ /* @__PURE__ */ t("thead", { children: /* @__PURE__ */ u("tr", { children: [
641
641
  /* @__PURE__ */ t(
642
642
  "th",
643
643
  {
644
- className: D(
644
+ className: B(
645
645
  Ne,
646
646
  "z-[3] border-b px-3 py-1.5 text-left text-[10.5px] font-semibold uppercase tracking-wide text-slate-500 dark:text-slate-400"
647
647
  ),
648
648
  children: rt(i.key_field)
649
649
  }
650
650
  ),
651
- h.map((e) => {
651
+ d.map((e) => {
652
652
  const a = Te != null && G(String(Te), e);
653
653
  return /* @__PURE__ */ t(
654
654
  "th",
655
655
  {
656
- className: D(
656
+ className: B(
657
657
  "border-b border-slate-200 px-2.5 py-1.5 text-right text-[10.5px] font-semibold uppercase tracking-wide text-slate-500 dark:border-border dark:text-slate-400",
658
658
  a && Se
659
659
  ),
660
- children: /* @__PURE__ */ c("span", { className: "inline-flex items-center justify-end gap-1", children: [
661
- e === ea && /* @__PURE__ */ t(
660
+ children: /* @__PURE__ */ u("span", { className: "inline-flex items-center justify-end gap-1", children: [
661
+ e === ta && /* @__PURE__ */ t(
662
662
  "span",
663
663
  {
664
664
  "data-plan-grid-lock": !0,
665
- "data-tip": `Closed through ${De ?? ""}${u != null && u.closed_rule ? ` — ${u.closed_rule}` : ""}`,
665
+ "data-tip": `Closed through ${Be ?? ""}${m != null && m.closed_rule ? ` — ${m.closed_rule}` : ""}`,
666
666
  className: "inline-flex",
667
667
  children: /* @__PURE__ */ t(
668
668
  oa,
669
669
  {
670
670
  className: "h-3 w-3",
671
- "aria-label": `Closed through ${De ?? ""}`
671
+ "aria-label": `Closed through ${Be ?? ""}`
672
672
  }
673
673
  )
674
674
  }
@@ -682,7 +682,7 @@ function il(b) {
682
682
  /* @__PURE__ */ t(
683
683
  "th",
684
684
  {
685
- className: D(
685
+ className: B(
686
686
  we,
687
687
  "z-[3] border-b px-3 py-1.5 text-right text-[10.5px] font-semibold uppercase tracking-wide text-slate-500 dark:text-slate-400"
688
688
  ),
@@ -690,59 +690,59 @@ function il(b) {
690
690
  }
691
691
  )
692
692
  ] }) }),
693
- oe.length === 0 && /* @__PURE__ */ t("tbody", { children: /* @__PURE__ */ t("tr", { children: /* @__PURE__ */ c(
693
+ oe.length === 0 && /* @__PURE__ */ t("tbody", { children: /* @__PURE__ */ t("tr", { children: /* @__PURE__ */ u(
694
694
  "td",
695
695
  {
696
- colSpan: h.length + 2,
696
+ colSpan: d.length + 2,
697
697
  className: "px-3 py-6 text-[12.5px] text-slate-500 dark:text-slate-400",
698
698
  children: [
699
699
  `No ${(N ?? "rows").toLowerCase()} yet.`,
700
- O ? ` Add a ${rt(i.key_field).toLowerCase()} to start planning.` : ""
700
+ c ? ` Add a ${rt(i.key_field).toLowerCase()} to start planning.` : ""
701
701
  ]
702
702
  }
703
703
  ) }) }),
704
704
  oe.map((e, a) => {
705
- var $, H, te;
706
- const l = !Qt.has(e.key), r = (d) => {
705
+ var C, H, te;
706
+ const l = !Vt.has(e.key), r = (p) => {
707
707
  var S;
708
- return e.mode === "split" ? F(e.cats.reduce((ae, Pe) => ae + B(Pe.values[d]), 0)) : B((S = e.top) == null ? void 0 : S.values[d]);
709
- }, o = F(h.reduce((d, S) => d + r(S), 0)), m = h.some(
710
- (d) => Math.abs(Le(e.key, ze, d).value) >= 5e-3
711
- ), _ = ((u == null ? void 0 : u.series) ?? []).filter(
712
- (d) => h.some((S) => Math.abs(Ce(d, e.key, S) ?? 0) >= 5e-3)
713
- ), U = h.some((d) => Math.abs(Le(e.key, null, d).value) >= 5e-3), P = ((($ = e.top) == null ? void 0 : $.edited) || ((H = e.top) == null ? void 0 : H.isNew) || e.cats.some((d) => d.edited || d.isNew)) ?? !1;
714
- return /* @__PURE__ */ c(
708
+ return e.mode === "split" ? K(e.cats.reduce((ae, Pe) => ae + D(Pe.values[p]), 0)) : D((S = e.top) == null ? void 0 : S.values[p]);
709
+ }, o = K(d.reduce((p, S) => p + r(S), 0)), g = d.some(
710
+ (p) => Math.abs(Re(e.key, Ue, p).value) >= 5e-3
711
+ ), L = ((m == null ? void 0 : m.series) ?? []).filter(
712
+ (p) => d.some((S) => Math.abs(Ce(p, e.key, S) ?? 0) >= 5e-3)
713
+ ), z = d.some((p) => Math.abs(Re(e.key, null, p).value) >= 5e-3), A = (((C = e.top) == null ? void 0 : C.edited) || ((H = e.top) == null ? void 0 : H.isNew) || e.cats.some((p) => p.edited || p.isNew)) ?? !1;
714
+ return /* @__PURE__ */ u(
715
715
  "tbody",
716
716
  {
717
717
  "data-plan-block": e.key,
718
718
  "data-plan-mode": e.mode,
719
- className: D(a > 0 && "pg-block"),
719
+ className: B(a > 0 && "pg-block"),
720
720
  children: [
721
- /* @__PURE__ */ c(
721
+ /* @__PURE__ */ u(
722
722
  "tr",
723
723
  {
724
724
  "data-o2m-row": (te = e.top) != null && te.id ? `${n}:${e.top.id}` : void 0,
725
- className: D(
725
+ className: B(
726
726
  a > 0 && "[&>td]:border-t [&>td]:border-slate-200 dark:[&>td]:border-border"
727
727
  ),
728
728
  children: [
729
- /* @__PURE__ */ t("td", { className: D(Ne, "px-2 py-1"), children: /* @__PURE__ */ c("div", { className: "flex items-center gap-1", children: [
729
+ /* @__PURE__ */ t("td", { className: B(Ne, "px-2 py-1"), children: /* @__PURE__ */ u("div", { className: "flex items-center gap-1", children: [
730
730
  e.mode === "split" ? /* @__PURE__ */ t(
731
731
  "button",
732
732
  {
733
733
  type: "button",
734
734
  "aria-expanded": l,
735
735
  "aria-label": `${l ? "Collapse" : "Expand"} ${e.key}`,
736
- onClick: () => Ct((d) => {
737
- const S = new Set(d);
736
+ onClick: () => Ct((p) => {
737
+ const S = new Set(p);
738
738
  return S.has(e.key) ? S.delete(e.key) : S.add(e.key), S;
739
739
  }),
740
740
  className: "rounded p-0.5 text-slate-500 hover:bg-muted",
741
- children: l ? /* @__PURE__ */ t(Lt, { className: "h-3.5 w-3.5" }) : /* @__PURE__ */ t(Mt, { className: "h-3.5 w-3.5" })
741
+ children: l ? /* @__PURE__ */ t(Rt, { className: "h-3.5 w-3.5" }) : /* @__PURE__ */ t(Mt, { className: "h-3.5 w-3.5" })
742
742
  }
743
743
  ) : /* @__PURE__ */ t("span", { className: "w-[18px]" }),
744
744
  /* @__PURE__ */ t("span", { className: "text-[13px] font-semibold text-slate-900 dark:text-slate-100", children: e.key }),
745
- P && /* @__PURE__ */ t(
745
+ A && /* @__PURE__ */ t(
746
746
  "span",
747
747
  {
748
748
  "data-plan-edited": !0,
@@ -751,37 +751,37 @@ function il(b) {
751
751
  }
752
752
  ),
753
753
  /* @__PURE__ */ t("span", { className: "ml-auto text-[10.5px] font-medium text-slate-500 dark:text-slate-400", children: e.mode === "ghost" ? "" : Ee }),
754
- O && e.mode !== "ghost" && /* @__PURE__ */ t(
754
+ c && e.mode !== "ghost" && /* @__PURE__ */ t(
755
755
  Fa,
756
756
  {
757
757
  block: e,
758
758
  config: i,
759
759
  canSplit: !!ge && !!(pe != null && pe.can_split) && !s,
760
760
  splitUnavailable: ge && pe && !pe.can_split && !s ? (() => {
761
- const d = pe.categories.filter((S) => S.cap > 5e-3);
762
- return d.length === 1 ? `Every line on this record is ${d[0].label} — there is nothing to split between.` : "This record has no categorised lines yet — add lines first.";
761
+ const p = pe.categories.filter((S) => S.cap > 5e-3);
762
+ return p.length === 1 ? `Every line on this record is ${p[0].label} — there is nothing to split between.` : "This record has no categorised lines yet — add lines first.";
763
763
  })() : null,
764
764
  splitBase: ge,
765
- client: v,
766
- cols: h,
765
+ client: M,
766
+ cols: d,
767
767
  catLabel: ye,
768
- showHistory: p,
768
+ showHistory: x,
769
769
  onHistory: et,
770
- onSpread: K ? la : null,
771
- onRemove: () => Wt(e),
772
- onDone: Ht,
770
+ onSpread: I ? na : null,
771
+ onRemove: () => Ht(e),
772
+ onDone: Qt,
773
773
  rc: n
774
774
  }
775
775
  )
776
776
  ] }) }),
777
- e.mode === "ghost" ? /* @__PURE__ */ c(
777
+ e.mode === "ghost" ? /* @__PURE__ */ u(
778
778
  "td",
779
779
  {
780
- colSpan: h.length,
780
+ colSpan: d.length,
781
781
  className: "px-3 py-1 text-[12px] text-slate-500 dark:text-slate-400",
782
782
  children: [
783
783
  `No ${Ee.toLowerCase()} for ${e.key}`,
784
- O && /* @__PURE__ */ t(
784
+ c && /* @__PURE__ */ t(
785
785
  "button",
786
786
  {
787
787
  type: "button",
@@ -793,39 +793,39 @@ function il(b) {
793
793
  )
794
794
  ]
795
795
  }
796
- ) : h.map((d) => {
797
- const S = G(e.key, d);
796
+ ) : d.map((p) => {
797
+ const S = G(e.key, p);
798
798
  return e.mode === "split" ? /* @__PURE__ */ t(
799
799
  "td",
800
800
  {
801
- className: D(
801
+ className: B(
802
802
  "px-2.5 py-1 text-right font-semibold text-slate-900 dark:text-slate-100",
803
803
  S && Se
804
804
  ),
805
- children: /* @__PURE__ */ t(ne, { n: r(d) })
805
+ children: /* @__PURE__ */ t(ne, { n: r(p) })
806
806
  },
807
- d
807
+ p
808
808
  ) : /* @__PURE__ */ t(
809
809
  Ft,
810
810
  {
811
811
  row: e.top,
812
- col: d,
812
+ col: p,
813
813
  closed: S,
814
- prov: ce(e.top, d),
815
- cellKey: V(e.top, d),
816
- locked: Ie(e.key, d),
817
- lockedTip: S ? (u == null ? void 0 : u.closed_locked_message) ?? "This period is closed" : void 0,
818
- onCommit: (ae) => X(e.top, { [d]: ae }),
814
+ prov: ce(e.top, p),
815
+ cellKey: V(e.top, p),
816
+ locked: Ie(e.key, p),
817
+ lockedTip: S ? (m == null ? void 0 : m.closed_locked_message) ?? "This period is closed" : void 0,
818
+ onCommit: (ae) => X(e.top, { [p]: ae }),
819
819
  onMove: wt,
820
820
  onPaste: $t
821
821
  },
822
- d
822
+ p
823
823
  );
824
824
  }),
825
825
  /* @__PURE__ */ t(
826
826
  "td",
827
827
  {
828
- className: D(
828
+ className: B(
829
829
  we,
830
830
  "px-3 py-1 text-right font-semibold text-slate-900 dark:text-slate-100"
831
831
  ),
@@ -835,46 +835,46 @@ function il(b) {
835
835
  ]
836
836
  }
837
837
  ),
838
- u && /* @__PURE__ */ t(
838
+ m && /* @__PURE__ */ t(
839
839
  st,
840
840
  {
841
841
  label: $e,
842
842
  blockKey: e.key,
843
843
  cat: null,
844
- cols: h,
845
- compare: u,
844
+ cols: d,
845
+ compare: m,
846
846
  planOf: r,
847
- actualFor: Le,
847
+ actualFor: Re,
848
848
  isClosed: G,
849
849
  row: e.mode === "top" ? e.top : null,
850
- canReconcile: O && e.mode === "top",
850
+ canReconcile: c && e.mode === "top",
851
851
  onReconcile: Ze,
852
852
  carryFor: Ge
853
853
  }
854
854
  ),
855
- e.mode !== "split" && _.map((d) => /* @__PURE__ */ c("tr", { "data-compare-series": d.key, children: [
856
- /* @__PURE__ */ t("td", { className: D(Ne, "px-2 py-0.5"), children: /* @__PURE__ */ t(
855
+ e.mode !== "split" && L.map((p) => /* @__PURE__ */ u("tr", { "data-compare-series": p.key, children: [
856
+ /* @__PURE__ */ t("td", { className: B(Ne, "px-2 py-0.5"), children: /* @__PURE__ */ t(
857
857
  "span",
858
858
  {
859
- "data-tip": d.hint ?? "",
859
+ "data-tip": p.hint ?? "",
860
860
  className: "block pl-[22px] text-right text-[10.5px] font-medium text-slate-500 dark:text-slate-400",
861
- children: d.label
861
+ children: p.label
862
862
  }
863
863
  ) }),
864
- h.map((S) => /* @__PURE__ */ t(
864
+ d.map((S) => /* @__PURE__ */ t(
865
865
  "td",
866
866
  {
867
- className: D(
867
+ className: B(
868
868
  "px-2.5 py-0.5 text-right text-[11.5px] text-slate-500 dark:text-slate-400",
869
869
  G(e.key, S) && Se
870
870
  ),
871
- children: Math.abs(Ce(d, e.key, S) ?? 0) >= 5e-3 ? /* @__PURE__ */ t(
871
+ children: Math.abs(Ce(p, e.key, S) ?? 0) >= 5e-3 ? /* @__PURE__ */ t(
872
872
  Pt,
873
873
  {
874
- series: d,
875
- value: Ce(d, e.key, S) ?? 0,
874
+ series: p,
875
+ value: Ce(p, e.key, S) ?? 0,
876
876
  periodLabel: `${je(S)} ${e.key}`,
877
- children: /* @__PURE__ */ t(ne, { n: Ce(d, e.key, S) ?? 0, muted: !0 })
877
+ children: /* @__PURE__ */ t(ne, { n: Ce(p, e.key, S) ?? 0, muted: !0 })
878
878
  }
879
879
  ) : /* @__PURE__ */ t(ne, { n: 0, muted: !0 })
880
880
  },
@@ -883,24 +883,24 @@ function il(b) {
883
883
  /* @__PURE__ */ t(
884
884
  "td",
885
885
  {
886
- className: D(
886
+ className: B(
887
887
  we,
888
888
  "px-3 py-0.5 text-right text-[11.5px] text-slate-500 dark:text-slate-400"
889
889
  ),
890
890
  children: /* @__PURE__ */ t(
891
891
  Pt,
892
892
  {
893
- series: d,
894
- value: F(
895
- h.reduce((S, ae) => S + (Ce(d, e.key, ae) ?? 0), 0)
893
+ series: p,
894
+ value: K(
895
+ d.reduce((S, ae) => S + (Ce(p, e.key, ae) ?? 0), 0)
896
896
  ),
897
897
  periodLabel: String(e.key),
898
898
  whole: !0,
899
899
  children: /* @__PURE__ */ t(
900
900
  ne,
901
901
  {
902
- n: F(
903
- h.reduce((S, ae) => S + (Ce(d, e.key, ae) ?? 0), 0)
902
+ n: K(
903
+ d.reduce((S, ae) => S + (Ce(p, e.key, ae) ?? 0), 0)
904
904
  ),
905
905
  muted: !0
906
906
  }
@@ -909,31 +909,31 @@ function il(b) {
909
909
  )
910
910
  }
911
911
  )
912
- ] }, d.key)),
913
- e.mode === "split" && l && e.cats.map((d) => /* @__PURE__ */ c(qa, { children: [
914
- /* @__PURE__ */ c(
912
+ ] }, p.key)),
913
+ e.mode === "split" && l && e.cats.map((p) => /* @__PURE__ */ u(qa, { children: [
914
+ /* @__PURE__ */ u(
915
915
  "tr",
916
916
  {
917
- "data-o2m-row": d.id ? `${n}:${d.id}` : void 0,
918
- "data-plan-category": d.cat ?? "",
917
+ "data-o2m-row": p.id ? `${n}:${p.id}` : void 0,
918
+ "data-plan-category": p.cat ?? "",
919
919
  children: [
920
- /* @__PURE__ */ t("td", { className: D(Ne, "px-2 py-1"), children: /* @__PURE__ */ c("div", { className: "flex items-center gap-1 pl-[22px]", children: [
921
- /* @__PURE__ */ t("span", { className: "truncate text-[12.5px] font-medium text-slate-800 dark:text-slate-100", children: ye(d.cat) }),
922
- (d.edited || d.isNew) && /* @__PURE__ */ t("span", { className: "h-1.5 w-1.5 rounded-full bg-amber-500" }),
920
+ /* @__PURE__ */ t("td", { className: B(Ne, "px-2 py-1"), children: /* @__PURE__ */ u("div", { className: "flex items-center gap-1 pl-[22px]", children: [
921
+ /* @__PURE__ */ t("span", { className: "truncate text-[12.5px] font-medium text-slate-800 dark:text-slate-100", children: ye(p.cat) }),
922
+ (p.edited || p.isNew) && /* @__PURE__ */ t("span", { className: "h-1.5 w-1.5 rounded-full bg-amber-500" }),
923
923
  /* @__PURE__ */ t("span", { className: "ml-auto text-[10.5px] font-medium text-slate-500 dark:text-slate-400", children: Ee })
924
924
  ] }) }),
925
- h.map((S) => /* @__PURE__ */ t(
925
+ d.map((S) => /* @__PURE__ */ t(
926
926
  Ft,
927
927
  {
928
- row: d,
929
- rowLabel: d.cat != null ? ye(String(d.cat)) : void 0,
928
+ row: p,
929
+ rowLabel: p.cat != null ? ye(String(p.cat)) : void 0,
930
930
  col: S,
931
931
  closed: G(e.key, S),
932
- prov: ce(d, S),
933
- cellKey: V(d, S),
932
+ prov: ce(p, S),
933
+ cellKey: V(p, S),
934
934
  locked: Ie(e.key, S),
935
- lockedTip: G(e.key, S) ? (u == null ? void 0 : u.closed_locked_message) ?? "This period is closed" : void 0,
936
- onCommit: (ae) => X(d, { [S]: ae }),
935
+ lockedTip: G(e.key, S) ? (m == null ? void 0 : m.closed_locked_message) ?? "This period is closed" : void 0,
936
+ onCommit: (ae) => X(p, { [S]: ae }),
937
937
  onMove: wt,
938
938
  onPaste: $t
939
939
  },
@@ -942,46 +942,46 @@ function il(b) {
942
942
  /* @__PURE__ */ t(
943
943
  "td",
944
944
  {
945
- className: D(
945
+ className: B(
946
946
  we,
947
947
  "px-3 py-1 text-right font-medium text-slate-800 dark:text-slate-100"
948
948
  ),
949
- children: /* @__PURE__ */ t(ne, { n: Y(d.values) })
949
+ children: /* @__PURE__ */ t(ne, { n: Y(p.values) })
950
950
  }
951
951
  )
952
952
  ]
953
953
  }
954
954
  ),
955
- u && U && /* @__PURE__ */ t(
955
+ m && z && /* @__PURE__ */ t(
956
956
  st,
957
957
  {
958
958
  label: $e,
959
959
  blockKey: e.key,
960
- cat: d.cat,
961
- cols: h,
962
- compare: u,
963
- planOf: (S) => B(d.values[S]),
964
- actualFor: Le,
960
+ cat: p.cat,
961
+ cols: d,
962
+ compare: m,
963
+ planOf: (S) => D(p.values[S]),
964
+ actualFor: Re,
965
965
  isClosed: G,
966
- row: d,
967
- canReconcile: O,
966
+ row: p,
967
+ canReconcile: c,
968
968
  onReconcile: Ze,
969
969
  carryFor: Ge,
970
970
  indent: !0
971
971
  }
972
972
  )
973
- ] }, d.uid)),
974
- e.mode === "split" && l && u && m && /* @__PURE__ */ t(
973
+ ] }, p.uid)),
974
+ e.mode === "split" && l && m && g && /* @__PURE__ */ t(
975
975
  st,
976
976
  {
977
- label: `${ye(ze)} · ${$e.toLowerCase()}`,
977
+ label: `${ye(Ue)} · ${$e.toLowerCase()}`,
978
978
  tip: `${$e} the source could not place in a category — it counts in the ${e.key} total only.`,
979
979
  blockKey: e.key,
980
- cat: ze,
981
- cols: h,
982
- compare: u,
980
+ cat: Ue,
981
+ cols: d,
982
+ compare: m,
983
983
  planOf: () => 0,
984
- actualFor: Le,
984
+ actualFor: Re,
985
985
  isClosed: G,
986
986
  row: null,
987
987
  canReconcile: !1,
@@ -996,13 +996,13 @@ function il(b) {
996
996
  e.key
997
997
  );
998
998
  }),
999
- oe.length > 1 && /* @__PURE__ */ c("tfoot", { children: [
1000
- /* @__PURE__ */ c("tr", { className: "[&>td]:border-t [&>td]:border-slate-300 dark:[&>td]:border-border", children: [
1001
- /* @__PURE__ */ t("td", { className: D(Ne, "px-2 py-1.5"), children: /* @__PURE__ */ c("div", { className: "flex items-center pl-[22px]", children: [
999
+ oe.length > 1 && /* @__PURE__ */ u("tfoot", { children: [
1000
+ /* @__PURE__ */ u("tr", { className: "[&>td]:border-t [&>td]:border-slate-300 dark:[&>td]:border-border", children: [
1001
+ /* @__PURE__ */ t("td", { className: B(Ne, "px-2 py-1.5"), children: /* @__PURE__ */ u("div", { className: "flex items-center pl-[22px]", children: [
1002
1002
  /* @__PURE__ */ t("span", { className: "text-[12px] font-semibold text-slate-900 dark:text-slate-100", children: "All" }),
1003
1003
  /* @__PURE__ */ t("span", { className: "ml-auto text-[10.5px] font-medium text-slate-500 dark:text-slate-400", children: Ee })
1004
1004
  ] }) }),
1005
- h.map((e) => /* @__PURE__ */ t(
1005
+ d.map((e) => /* @__PURE__ */ t(
1006
1006
  "td",
1007
1007
  {
1008
1008
  className: "px-2.5 py-1.5 text-right font-semibold text-slate-900 dark:text-slate-100",
@@ -1013,7 +1013,7 @@ function il(b) {
1013
1013
  /* @__PURE__ */ t(
1014
1014
  "td",
1015
1015
  {
1016
- className: D(
1016
+ className: B(
1017
1017
  we,
1018
1018
  "px-3 py-1.5 text-right font-semibold text-slate-900 dark:text-slate-100"
1019
1019
  ),
@@ -1021,9 +1021,9 @@ function il(b) {
1021
1021
  }
1022
1022
  )
1023
1023
  ] }),
1024
- u && /* @__PURE__ */ c("tr", { children: [
1025
- /* @__PURE__ */ t("td", { className: D(Ne, "px-2 pb-1.5 pt-0"), children: /* @__PURE__ */ t("span", { className: "block text-right text-[10.5px] font-medium text-slate-500 dark:text-slate-400", children: $e }) }),
1026
- h.map((e) => /* @__PURE__ */ t(
1024
+ m && /* @__PURE__ */ u("tr", { children: [
1025
+ /* @__PURE__ */ t("td", { className: B(Ne, "px-2 pb-1.5 pt-0"), children: /* @__PURE__ */ t("span", { className: "block text-right text-[10.5px] font-medium text-slate-500 dark:text-slate-400", children: $e }) }),
1026
+ d.map((e) => /* @__PURE__ */ t(
1027
1027
  "td",
1028
1028
  {
1029
1029
  className: "px-2.5 pb-1.5 pt-0 text-right text-[11.5px] text-slate-600 dark:text-slate-300",
@@ -1034,11 +1034,11 @@ function il(b) {
1034
1034
  /* @__PURE__ */ t(
1035
1035
  "td",
1036
1036
  {
1037
- className: D(
1037
+ className: B(
1038
1038
  we,
1039
1039
  "px-3 pb-1.5 pt-0 text-right text-[11.5px] text-slate-600 dark:text-slate-300"
1040
1040
  ),
1041
- children: /* @__PURE__ */ t(ne, { n: F(h.reduce((e, a) => e + lt.actualBy[a], 0)), muted: !0 })
1041
+ children: /* @__PURE__ */ t(ne, { n: K(d.reduce((e, a) => e + lt.actualBy[a], 0)), muted: !0 })
1042
1042
  }
1043
1043
  )
1044
1044
  ] })
@@ -1057,18 +1057,18 @@ function il(b) {
1057
1057
  children: vt
1058
1058
  }
1059
1059
  ),
1060
- O && /* @__PURE__ */ c("div", { className: "mt-2 flex items-center gap-2", children: [
1060
+ c && /* @__PURE__ */ u("div", { className: "mt-2 flex items-center gap-2", children: [
1061
1061
  /* @__PURE__ */ t(
1062
- Ba,
1062
+ Da,
1063
1063
  {
1064
1064
  config: i,
1065
- client: v,
1066
- used: ta,
1065
+ client: M,
1066
+ used: aa,
1067
1067
  onAdd: (e) => Me(e),
1068
1068
  label: `Add ${rt(i.key_field).toLowerCase()}`
1069
1069
  }
1070
1070
  ),
1071
- (u == null ? void 0 : u.closed_locked) && !q && De && /* @__PURE__ */ t("span", { className: "text-[11.5px] text-slate-500 dark:text-slate-400", children: `Periods through ${De} are closed — open a highlighted ${$e.toLowerCase()} figure to reconcile one.` })
1071
+ (m == null ? void 0 : m.closed_locked) && !R && Be && /* @__PURE__ */ t("span", { className: "text-[11.5px] text-slate-500 dark:text-slate-400", children: `Periods through ${Be} are closed — open a highlighted ${$e.toLowerCase()} figure to reconcile one.` })
1072
1072
  ] }),
1073
1073
  tt,
1074
1074
  Q && tt == null && /* @__PURE__ */ t(
@@ -1079,18 +1079,18 @@ function il(b) {
1079
1079
  e || et(null);
1080
1080
  },
1081
1081
  rowTitle: `${Q.key}${Q.cat ? ` · ${ye(Q.cat)}` : ""}`,
1082
- revisions: Zt,
1083
- loading: Yt,
1082
+ revisions: Yt,
1083
+ loading: Xt,
1084
1084
  fields: Ot,
1085
1085
  displayCols: Ot.filter(
1086
- (e) => h.includes(e.field) || e.field === i.category_field
1086
+ (e) => d.includes(e.field) || e.field === i.category_field
1087
1087
  ),
1088
- parentField: x,
1088
+ parentField: h,
1089
1089
  m2oRelMap: /* @__PURE__ */ new Map(),
1090
1090
  relations: [],
1091
1091
  collection: n,
1092
1092
  m2oDisplays: {},
1093
- client: v,
1093
+ client: M,
1094
1094
  allowRestore: !1,
1095
1095
  onRestore: () => {
1096
1096
  }
@@ -1098,97 +1098,97 @@ function il(b) {
1098
1098
  )
1099
1099
  ] });
1100
1100
  }
1101
- function rt(b) {
1102
- return b.replace(/_/g, " ").replace(/^\w/, (n) => n.toUpperCase());
1101
+ function rt(k) {
1102
+ return k.replace(/_/g, " ").replace(/^\w/, (n) => n.toUpperCase());
1103
1103
  }
1104
- function qa(b) {
1105
- return /* @__PURE__ */ t(ra, { children: b.children });
1104
+ function qa(k) {
1105
+ return /* @__PURE__ */ t(It, { children: k.children });
1106
1106
  }
1107
- function ne(b) {
1108
- return Math.abs(b.n) < 5e-3 ? /* @__PURE__ */ t("span", { className: "text-slate-400 dark:text-slate-500", children: "—" }) : /* @__PURE__ */ t("span", { children: z(b.n) });
1107
+ function ne(k) {
1108
+ return Math.abs(k.n) < 5e-3 ? /* @__PURE__ */ t("span", { className: "text-slate-400 dark:text-slate-500", children: "—" }) : /* @__PURE__ */ t("span", { children: U(k.n) });
1109
1109
  }
1110
- function Ft(b) {
1110
+ function Ft(k) {
1111
1111
  const {
1112
1112
  row: n,
1113
- rowLabel: x,
1113
+ rowLabel: h,
1114
1114
  col: f,
1115
1115
  closed: i,
1116
- locked: k,
1117
- lockedTip: M,
1118
- prov: E,
1119
- cellKey: K,
1120
- onCommit: L,
1121
- onMove: p,
1116
+ locked: b,
1117
+ lockedTip: P,
1118
+ prov: j,
1119
+ cellKey: I,
1120
+ onCommit: T,
1121
+ onMove: x,
1122
1122
  onPaste: N
1123
- } = b, v = B(n.values[f]), y = E ? `${je(f)} · changed ${ba(E.at)} by ${E.who}${E.reason ? `
1124
- Reason: “${E.reason}”` : ""}` : void 0, g = E != null && E.reason ? /* @__PURE__ */ t(
1123
+ } = k, M = D(n.values[f]), w = j ? `${je(f)} · changed ${ba(j.at)} by ${j.who}${j.reason ? `
1124
+ Reason: “${j.reason}”` : ""}` : void 0, y = j != null && j.reason ? /* @__PURE__ */ t(
1125
1125
  "span",
1126
1126
  {
1127
1127
  "aria-hidden": "true",
1128
1128
  "data-cell-reason": !0,
1129
1129
  className: "pointer-events-none absolute left-0 top-0 h-0 w-0 border-r-[6px] border-t-[6px] border-r-transparent border-t-nvr-cyan"
1130
1130
  }
1131
- ) : null, [j, I] = W(null), C = me(!1);
1132
- if (k)
1133
- return /* @__PURE__ */ c(
1131
+ ) : null, [_, O] = W(null), v = me(!1);
1132
+ if (b)
1133
+ return /* @__PURE__ */ u(
1134
1134
  "td",
1135
1135
  {
1136
1136
  "data-plan-locked": i ? "closed" : "readonly",
1137
- "data-tip": [M, y].filter(Boolean).join(`
1137
+ "data-tip": [P, w].filter(Boolean).join(`
1138
1138
  `) || void 0,
1139
- "data-grid-cell": K,
1140
- className: D(
1139
+ "data-grid-cell": I,
1140
+ className: B(
1141
1141
  "relative px-2.5 py-1 text-right text-slate-700 dark:text-slate-200",
1142
1142
  i && Se
1143
1143
  ),
1144
1144
  children: [
1145
- g,
1146
- /* @__PURE__ */ t(ne, { n: v })
1145
+ y,
1146
+ /* @__PURE__ */ t(ne, { n: M })
1147
1147
  ]
1148
1148
  }
1149
1149
  );
1150
- const q = () => {
1151
- if (j == null) return;
1152
- const s = Bt(j);
1153
- if (I(null), C.current) {
1154
- C.current = !1;
1150
+ const R = () => {
1151
+ if (_ == null) return;
1152
+ const s = Bt(_);
1153
+ if (O(null), v.current) {
1154
+ v.current = !1;
1155
1155
  return;
1156
1156
  }
1157
1157
  if (s == null || s < 0) {
1158
- ie.error(Dt(j));
1158
+ ie.error(Ut(_));
1159
1159
  return;
1160
1160
  }
1161
- const O = ct(j);
1162
- O.ok && O.rounded && ie.message(`Rounded to ${z(s)} — amounts are kept to the cent`), !(Math.abs(s - v) < 5e-3) && L(s);
1161
+ const c = ct(_);
1162
+ c.ok && c.rounded && ie.message(`Rounded to ${U(s)} — amounts are kept to the cent`), !(Math.abs(s - M) < 5e-3) && T(s);
1163
1163
  };
1164
- return /* @__PURE__ */ c(
1164
+ return /* @__PURE__ */ u(
1165
1165
  "td",
1166
1166
  {
1167
- className: D("relative p-0", i && Se),
1168
- "data-grid-cell": K,
1169
- "data-tip": y,
1167
+ className: B("relative p-0", i && Se),
1168
+ "data-grid-cell": I,
1169
+ "data-tip": w,
1170
1170
  children: [
1171
- g,
1171
+ y,
1172
1172
  /* @__PURE__ */ t(
1173
1173
  "input",
1174
1174
  {
1175
1175
  "data-pg-cell": `${n.uid}:${f}`,
1176
- "aria-label": `${je(f)} ${n.key}${x ? ` · ${x}` : ""}`,
1176
+ "aria-label": `${je(f)} ${n.key}${h ? ` · ${h}` : ""}`,
1177
1177
  inputMode: "decimal",
1178
- value: j ?? (v === 0 ? "" : z(v)),
1178
+ value: _ ?? (M === 0 ? "" : U(M)),
1179
1179
  placeholder: "—",
1180
1180
  onFocus: (s) => {
1181
- I(v === 0 ? "" : String(v)), requestAnimationFrame(() => s.target.select());
1181
+ O(M === 0 ? "" : String(M)), requestAnimationFrame(() => s.target.select());
1182
1182
  },
1183
- onChange: (s) => I(s.target.value),
1184
- onBlur: q,
1183
+ onChange: (s) => O(s.target.value),
1184
+ onBlur: R,
1185
1185
  onPaste: (s) => {
1186
- const O = s.clipboardData.getData("text");
1187
- /[\t\n]/.test(O.trim()) && (s.preventDefault(), C.current = !0, s.target.blur(), N(n, f, O));
1186
+ const c = s.clipboardData.getData("text");
1187
+ /[\t\n]/.test(c.trim()) && (s.preventDefault(), v.current = !0, s.target.blur(), N(n, f, c));
1188
1188
  },
1189
1189
  onKeyDown: (s) => {
1190
- const O = s.currentTarget, h = O.selectionStart === 0 && O.selectionEnd === 0, R = O.selectionStart === O.value.length && O.selectionEnd === O.value.length;
1191
- s.key === "Enter" || s.key === "ArrowDown" ? (s.preventDefault(), q(), p(n.uid, f, 1, 0)) : s.key === "ArrowUp" ? (s.preventDefault(), q(), p(n.uid, f, -1, 0)) : s.key === "ArrowLeft" && h ? (s.preventDefault(), q(), p(n.uid, f, 0, -1)) : s.key === "ArrowRight" && R ? (s.preventDefault(), q(), p(n.uid, f, 0, 1)) : s.key === "Escape" && (C.current = !0, O.blur());
1190
+ const c = s.currentTarget, d = c.selectionStart === 0 && c.selectionEnd === 0, E = c.selectionStart === c.value.length && c.selectionEnd === c.value.length;
1191
+ s.key === "Enter" || s.key === "ArrowDown" ? (s.preventDefault(), R(), x(n.uid, f, 1, 0)) : s.key === "ArrowUp" ? (s.preventDefault(), R(), x(n.uid, f, -1, 0)) : s.key === "ArrowLeft" && d ? (s.preventDefault(), R(), x(n.uid, f, 0, -1)) : s.key === "ArrowRight" && E ? (s.preventDefault(), R(), x(n.uid, f, 0, 1)) : s.key === "Escape" && (v.current = !0, c.blur());
1192
1192
  },
1193
1193
  className: "h-[30px] w-full bg-transparent px-2.5 text-right text-[12px] tabular-nums text-slate-900 outline-none placeholder:text-slate-400 hover:bg-muted/60 focus:bg-white focus:shadow-[inset_0_0_0_2px_rgb(var(--nvr-cyan-rgb))] dark:text-slate-100 dark:placeholder:text-slate-500 dark:focus:bg-[hsl(var(--background))]"
1194
1194
  }
@@ -1197,72 +1197,72 @@ Reason: “${E.reason}”` : ""}` : void 0, g = E != null && E.reason ? /* @__PU
1197
1197
  }
1198
1198
  );
1199
1199
  }
1200
- function st(b) {
1200
+ function st(k) {
1201
1201
  const {
1202
1202
  label: n,
1203
- tip: x,
1203
+ tip: h,
1204
1204
  blockKey: f,
1205
1205
  cat: i,
1206
- cols: k,
1207
- compare: M,
1208
- planOf: E,
1209
- actualFor: K,
1210
- isClosed: L,
1211
- row: p,
1206
+ cols: b,
1207
+ compare: P,
1208
+ planOf: j,
1209
+ actualFor: I,
1210
+ isClosed: T,
1211
+ row: x,
1212
1212
  canReconcile: N,
1213
- onReconcile: v,
1214
- carryFor: y,
1215
- plain: g
1216
- } = b, j = F(k.reduce((I, C) => I + K(f, i, C).value, 0));
1217
- return /* @__PURE__ */ c("tr", { "data-plan-actual": i ?? "all", children: [
1218
- /* @__PURE__ */ t("td", { className: D(Ne, "px-2 pb-1 pt-0"), children: /* @__PURE__ */ t(
1213
+ onReconcile: M,
1214
+ carryFor: w,
1215
+ plain: y
1216
+ } = k, _ = K(b.reduce((O, v) => O + I(f, i, v).value, 0));
1217
+ return /* @__PURE__ */ u("tr", { "data-plan-actual": i ?? "all", children: [
1218
+ /* @__PURE__ */ t("td", { className: B(Ne, "px-2 pb-1 pt-0"), children: /* @__PURE__ */ t(
1219
1219
  "span",
1220
1220
  {
1221
- "data-tip": x,
1221
+ "data-tip": h,
1222
1222
  className: "block text-right text-[10.5px] font-medium text-slate-500 dark:text-slate-400",
1223
1223
  children: n
1224
1224
  }
1225
1225
  ) }),
1226
- k.map((I) => {
1227
- const C = L(f, I), q = K(f, i, I), s = E(I), O = !g && C && Math.abs(q.value - s) >= 5e-3, h = !g && !C && q.value > s + 5e-3;
1226
+ b.map((O) => {
1227
+ const v = T(f, O), R = I(f, i, O), s = j(O), c = !y && v && Math.abs(R.value - s) >= 5e-3, d = !y && !v && R.value > s + 5e-3;
1228
1228
  return /* @__PURE__ */ t(
1229
1229
  "td",
1230
1230
  {
1231
- "data-compare-cell": I,
1232
- className: D("px-2.5 pb-1 pt-0 text-right text-[11.5px]", C && Se),
1233
- children: Math.abs(q.value) < 5e-3 && !O ? /* @__PURE__ */ t("span", { className: "text-slate-400 dark:text-slate-500", children: "—" }) : /* @__PURE__ */ t(
1231
+ "data-compare-cell": O,
1232
+ className: B("px-2.5 pb-1 pt-0 text-right text-[11.5px]", v && Se),
1233
+ children: Math.abs(R.value) < 5e-3 && !c ? /* @__PURE__ */ t("span", { className: "text-slate-400 dark:text-slate-500", children: "—" }) : /* @__PURE__ */ t(
1234
1234
  Aa,
1235
1235
  {
1236
- title: `${je(I)} ${f}`,
1237
- compare: M,
1236
+ title: `${je(O)} ${f}`,
1237
+ compare: P,
1238
1238
  actualName: n,
1239
- actual: q.value,
1239
+ actual: R.value,
1240
1240
  planned: s,
1241
- closed: C,
1242
- plain: !!g,
1243
- details: q.details,
1244
- tone: O ? "warn" : h ? "danger" : "neutral",
1245
- reconcile: O && N && p ? {
1246
- row: p,
1247
- column: I,
1248
- openColumns: k.filter((R) => !L(f, R)),
1249
- carry: (y == null ? void 0 : y(f, i)) ?? null,
1250
- onApply: (R, T, de) => v(p, R, T, de)
1241
+ closed: v,
1242
+ plain: !!y,
1243
+ details: R.details,
1244
+ tone: c ? "warn" : d ? "danger" : "neutral",
1245
+ reconcile: c && N && x ? {
1246
+ row: x,
1247
+ column: O,
1248
+ openColumns: b.filter((E) => !T(f, E)),
1249
+ carry: (w == null ? void 0 : w(f, i)) ?? null,
1250
+ onApply: (E, q, de) => M(x, E, q, de)
1251
1251
  } : null
1252
1252
  }
1253
1253
  )
1254
1254
  },
1255
- I
1255
+ O
1256
1256
  );
1257
1257
  }),
1258
1258
  /* @__PURE__ */ t(
1259
1259
  "td",
1260
1260
  {
1261
- className: D(
1261
+ className: B(
1262
1262
  we,
1263
1263
  "px-3 pb-1 pt-0 text-right text-[11.5px] text-slate-600 dark:text-slate-300"
1264
1264
  ),
1265
- children: /* @__PURE__ */ t(ne, { n: j, muted: !0 })
1265
+ children: /* @__PURE__ */ t(ne, { n: _, muted: !0 })
1266
1266
  }
1267
1267
  )
1268
1268
  ] });
@@ -1272,117 +1272,117 @@ const Kt = {
1272
1272
  danger: "text-red-700 dark:text-red-300 font-medium",
1273
1273
  neutral: "text-slate-600 dark:text-slate-300"
1274
1274
  };
1275
- function Aa(b) {
1275
+ function Aa(k) {
1276
1276
  var V, ce;
1277
- const { title: n, compare: x, actualName: f, actual: i, planned: k, closed: M, plain: E, details: K, tone: L, reconcile: p } = b, [N, v] = W(!1), [y, g] = W("next"), [j, I] = W(""), C = It(x), q = F(k - i), s = p && p.openColumns.length === 0 && p.carry && !p.carry.blocked ? p.carry : null, O = p && p.openColumns.length === 0 ? ((V = p.carry) == null ? void 0 : V.blocked) ?? null : null, h = s ? ((ce = s.row) == null ? void 0 : ce.values) ?? {} : (p == null ? void 0 : p.row.values) ?? {}, R = s ? s.openColumns : (p == null ? void 0 : p.openColumns) ?? [], T = Z(
1277
+ const { title: n, compare: h, actualName: f, actual: i, planned: b, closed: P, plain: j, details: I, tone: T, reconcile: x } = k, [N, M] = W(!1), [w, y] = W("next"), [_, O] = W(""), v = Dt(h), R = K(b - i), s = x && x.openColumns.length === 0 && x.carry && !x.carry.blocked ? x.carry : null, c = x && x.openColumns.length === 0 ? ((V = x.carry) == null ? void 0 : V.blocked) ?? null : null, d = s ? ((ce = s.row) == null ? void 0 : ce.values) ?? {} : (x == null ? void 0 : x.row.values) ?? {}, E = s ? s.openColumns : (x == null ? void 0 : x.openColumns) ?? [], q = Z(
1278
1278
  () => {
1279
- var w;
1280
- return p ? ja({
1281
- row: p.row.values,
1282
- column: p.column,
1279
+ var $;
1280
+ return x ? ja({
1281
+ row: x.row.values,
1282
+ column: x.column,
1283
1283
  actual: i,
1284
- openColumns: s ? s.openColumns : p.openColumns,
1285
- mode: y,
1286
- ...s ? { targetRow: ((w = s.row) == null ? void 0 : w.values) ?? {} } : {}
1284
+ openColumns: s ? s.openColumns : x.openColumns,
1285
+ mode: w,
1286
+ ...s ? { targetRow: (($ = s.row) == null ? void 0 : $.values) ?? {} } : {}
1287
1287
  }) : null;
1288
1288
  },
1289
- [p, s, i, y]
1290
- ), de = T ? T.targetPatch ?? T.patch : {}, re = R.some((w) => B(h[w]) > 5e-3), A = Z(() => {
1291
- const w = `Reconciled ${n} to ${f.toLowerCase()} (${z(i)})`;
1292
- if (!T || Math.abs(T.moved) < 5e-3) return w;
1293
- const xe = `${T.targets.length === 1 ? je(T.targets[0]) : `${T.targets.length} open periods`}${s ? ` ${s.key}` : ""}`;
1294
- return T.moved > 0 ? `${w} — moved ${z(T.moved)} to ${xe}` : `${w} — took ${z(-T.moved)} from ${xe}`;
1295
- }, [n, f, i, T, s]);
1289
+ [x, s, i, w]
1290
+ ), de = q ? q.targetPatch ?? q.patch : {}, re = E.some(($) => D(d[$]) > 5e-3), F = Z(() => {
1291
+ const $ = `Reconciled ${n} to ${f.toLowerCase()} (${U(i)})`;
1292
+ if (!q || Math.abs(q.moved) < 5e-3) return $;
1293
+ const xe = `${q.targets.length === 1 ? je(q.targets[0]) : `${q.targets.length} open periods`}${s ? ` ${s.key}` : ""}`;
1294
+ return q.moved > 0 ? `${$} — moved ${U(q.moved)} to ${xe}` : `${$} — took ${U(-q.moved)} from ${xe}`;
1295
+ }, [n, f, i, q, s]);
1296
1296
  ue(() => {
1297
- N && I(A);
1298
- }, [N, A]);
1299
- const le = p ? [
1297
+ N && O(F);
1298
+ }, [N, F]);
1299
+ const le = x ? [
1300
1300
  {
1301
1301
  key: "next",
1302
- label: R[0] ? `Next open period (${it(R[0])}${s ? ` ${s.key}` : ""})` : "Next open period",
1303
- disabled: R.length === 0
1302
+ label: E[0] ? `Next open period (${it(E[0])}${s ? ` ${s.key}` : ""})` : "Next open period",
1303
+ disabled: E.length === 0
1304
1304
  },
1305
1305
  {
1306
1306
  key: "even",
1307
1307
  label: s ? `Evenly over ${s.key}'s open periods` : "Evenly over every open period",
1308
- disabled: R.length === 0
1308
+ disabled: E.length === 0
1309
1309
  },
1310
1310
  {
1311
1311
  key: "weighted",
1312
- label: s ? `In proportion to the ${C.toLowerCase()} already in ${s.key}` : `In proportion to the ${C.toLowerCase()} already there`,
1312
+ label: s ? `In proportion to the ${v.toLowerCase()} already in ${s.key}` : `In proportion to the ${v.toLowerCase()} already there`,
1313
1313
  disabled: !re
1314
1314
  },
1315
1315
  { key: "none", label: "Nowhere — drop it from the plan" }
1316
1316
  ] : [];
1317
- return /* @__PURE__ */ c(ut, { open: N, onOpenChange: v, children: [
1317
+ return /* @__PURE__ */ u(ut, { open: N, onOpenChange: M, children: [
1318
1318
  /* @__PURE__ */ t(pt, { asChild: !0, children: /* @__PURE__ */ t(
1319
1319
  "button",
1320
1320
  {
1321
1321
  type: "button",
1322
1322
  "data-compare-details": !0,
1323
1323
  "data-tip": "",
1324
- "data-plan-off": L === "warn" ? "true" : void 0,
1325
- className: D(
1324
+ "data-plan-off": T === "warn" ? "true" : void 0,
1325
+ className: B(
1326
1326
  "rounded px-0.5 underline-offset-2 hover:underline focus-visible:underline",
1327
- Kt[L]
1327
+ Kt[T]
1328
1328
  ),
1329
- children: z(i)
1329
+ children: U(i)
1330
1330
  }
1331
1331
  ) }),
1332
- /* @__PURE__ */ c(mt, { align: "end", sideOffset: 6, className: "w-[360px] p-0 text-[12px]", children: [
1333
- /* @__PURE__ */ c("div", { className: "border-b border-slate-200 px-3 py-2 dark:border-border", children: [
1332
+ /* @__PURE__ */ u(mt, { align: "end", sideOffset: 6, className: "w-[360px] p-0 text-[12px]", children: [
1333
+ /* @__PURE__ */ u("div", { className: "border-b border-slate-200 px-3 py-2 dark:border-border", children: [
1334
1334
  /* @__PURE__ */ t("p", { className: "text-[12.5px] font-semibold text-slate-900 dark:text-slate-100", children: n }),
1335
- /* @__PURE__ */ c("dl", { className: "mt-1 grid grid-cols-3 gap-2 tabular-nums", children: [
1336
- !E && /* @__PURE__ */ c("div", { children: [
1337
- /* @__PURE__ */ t("dt", { className: "text-[10.5px] text-slate-500 dark:text-slate-400", children: C }),
1338
- /* @__PURE__ */ t("dd", { className: "font-medium text-slate-800 dark:text-slate-100", children: z(k) })
1335
+ /* @__PURE__ */ u("dl", { className: "mt-1 grid grid-cols-3 gap-2 tabular-nums", children: [
1336
+ !j && /* @__PURE__ */ u("div", { children: [
1337
+ /* @__PURE__ */ t("dt", { className: "text-[10.5px] text-slate-500 dark:text-slate-400", children: v }),
1338
+ /* @__PURE__ */ t("dd", { className: "font-medium text-slate-800 dark:text-slate-100", children: U(b) })
1339
1339
  ] }),
1340
- /* @__PURE__ */ c("div", { children: [
1340
+ /* @__PURE__ */ u("div", { children: [
1341
1341
  /* @__PURE__ */ t("dt", { className: "text-[10.5px] text-slate-500 dark:text-slate-400", children: f }),
1342
- /* @__PURE__ */ t("dd", { className: "font-medium text-slate-800 dark:text-slate-100", children: z(i) })
1342
+ /* @__PURE__ */ t("dd", { className: "font-medium text-slate-800 dark:text-slate-100", children: U(i) })
1343
1343
  ] }),
1344
- !E && /* @__PURE__ */ c("div", { children: [
1345
- /* @__PURE__ */ t("dt", { className: "text-[10.5px] text-slate-500 dark:text-slate-400", children: M ? "Difference" : "Still to come" }),
1344
+ !j && /* @__PURE__ */ u("div", { children: [
1345
+ /* @__PURE__ */ t("dt", { className: "text-[10.5px] text-slate-500 dark:text-slate-400", children: P ? "Difference" : "Still to come" }),
1346
1346
  /* @__PURE__ */ t(
1347
1347
  "dd",
1348
1348
  {
1349
- className: D(
1349
+ className: B(
1350
1350
  "font-medium",
1351
- Math.abs(q) < 5e-3 ? "text-slate-800 dark:text-slate-100" : Kt[L === "neutral" ? "neutral" : L]
1351
+ Math.abs(R) < 5e-3 ? "text-slate-800 dark:text-slate-100" : Kt[T === "neutral" ? "neutral" : T]
1352
1352
  ),
1353
- children: z(q)
1353
+ children: U(R)
1354
1354
  }
1355
1355
  )
1356
1356
  ] })
1357
1357
  ] })
1358
1358
  ] }),
1359
- K.length > 0 && /* @__PURE__ */ t("ul", { className: "max-h-[168px] overflow-y-auto px-3 py-1.5", children: K.map((w) => /* @__PURE__ */ c("li", { className: "flex items-baseline gap-2 py-0.5", children: [
1360
- /* @__PURE__ */ c("span", { className: "min-w-0 flex-1 truncate text-slate-700 dark:text-slate-200", children: [
1361
- w.label,
1362
- w.sub ? /* @__PURE__ */ t("span", { className: "text-slate-500 dark:text-slate-400", children: ` · ${w.sub}` }) : null
1359
+ I.length > 0 && /* @__PURE__ */ t("ul", { className: "max-h-[168px] overflow-y-auto px-3 py-1.5", children: I.map(($) => /* @__PURE__ */ u("li", { className: "flex items-baseline gap-2 py-0.5", children: [
1360
+ /* @__PURE__ */ u("span", { className: "min-w-0 flex-1 truncate text-slate-700 dark:text-slate-200", children: [
1361
+ $.label,
1362
+ $.sub ? /* @__PURE__ */ t("span", { className: "text-slate-500 dark:text-slate-400", children: ` · ${$.sub}` }) : null
1363
1363
  ] }),
1364
- /* @__PURE__ */ t("span", { className: "tabular-nums text-slate-800 dark:text-slate-100", children: z(w.amount) })
1365
- ] }, String(w.id))) }),
1366
- K.length === 0 && /* @__PURE__ */ t("p", { className: "px-3 py-2 text-slate-500 dark:text-slate-400", children: `No ${_a(x, 2)} behind this figure.` }),
1367
- p && T && /* @__PURE__ */ c(
1364
+ /* @__PURE__ */ t("span", { className: "tabular-nums text-slate-800 dark:text-slate-100", children: U($.amount) })
1365
+ ] }, String($.id))) }),
1366
+ I.length === 0 && /* @__PURE__ */ t("p", { className: "px-3 py-2 text-slate-500 dark:text-slate-400", children: `No ${_a(h, 2)} behind this figure.` }),
1367
+ x && q && /* @__PURE__ */ u(
1368
1368
  "div",
1369
1369
  {
1370
1370
  className: "border-t border-slate-200 px-3 py-2 dark:border-border",
1371
1371
  "data-plan-reconcile": !0,
1372
1372
  children: [
1373
- /* @__PURE__ */ t("p", { className: "font-medium text-slate-900 dark:text-slate-100", children: `Set the ${C.toLowerCase()} to ${z(i)} and put the ${z(Math.abs(q))} ${q > 0 ? "left over" : "shortfall"}…` }),
1373
+ /* @__PURE__ */ t("p", { className: "font-medium text-slate-900 dark:text-slate-100", children: `Set the ${v.toLowerCase()} to ${U(i)} and put the ${U(Math.abs(R))} ${R > 0 ? "left over" : "shortfall"}…` }),
1374
1374
  /* @__PURE__ */ t(
1375
1375
  "div",
1376
1376
  {
1377
1377
  className: "mt-1.5 space-y-1",
1378
1378
  role: "radiogroup",
1379
1379
  "aria-label": "Where the difference goes",
1380
- children: le.map((w) => /* @__PURE__ */ c(
1380
+ children: le.map(($) => /* @__PURE__ */ u(
1381
1381
  "label",
1382
1382
  {
1383
- className: D(
1383
+ className: B(
1384
1384
  "flex cursor-pointer items-center gap-2",
1385
- w.disabled && "cursor-not-allowed opacity-50"
1385
+ $.disabled && "cursor-not-allowed opacity-50"
1386
1386
  ),
1387
1387
  children: [
1388
1388
  /* @__PURE__ */ t(
@@ -1390,21 +1390,21 @@ function Aa(b) {
1390
1390
  {
1391
1391
  type: "radio",
1392
1392
  name: "pg-reconcile",
1393
- "data-plan-reconcile-mode": w.key,
1394
- disabled: w.disabled,
1395
- checked: y === w.key,
1396
- onChange: () => g(w.key),
1393
+ "data-plan-reconcile-mode": $.key,
1394
+ disabled: $.disabled,
1395
+ checked: w === $.key,
1396
+ onChange: () => y($.key),
1397
1397
  className: "accent-[rgb(var(--nvr-cyan-rgb))]"
1398
1398
  }
1399
1399
  ),
1400
- /* @__PURE__ */ t("span", { className: "text-slate-700 dark:text-slate-200", children: w.label })
1400
+ /* @__PURE__ */ t("span", { className: "text-slate-700 dark:text-slate-200", children: $.label })
1401
1401
  ]
1402
1402
  },
1403
- w.key
1403
+ $.key
1404
1404
  ))
1405
1405
  }
1406
1406
  ),
1407
- s && y !== "none" && /* @__PURE__ */ t(
1407
+ s && w !== "none" && /* @__PURE__ */ t(
1408
1408
  "p",
1409
1409
  {
1410
1410
  className: "mt-1.5 text-[11.5px] text-slate-600 dark:text-slate-300",
@@ -1412,33 +1412,33 @@ function Aa(b) {
1412
1412
  children: s.row ? `Every period of this row is closed, so it goes to ${s.key}.` : `Every period of this row is closed and ${s.key} has no row for this line — one is added, and shows as pending until you save.`
1413
1413
  }
1414
1414
  ),
1415
- O && /* @__PURE__ */ t(
1415
+ c && /* @__PURE__ */ t(
1416
1416
  "p",
1417
1417
  {
1418
1418
  className: "mt-1.5 text-[11.5px] text-amber-700 dark:text-amber-300",
1419
1419
  "data-plan-reconcile-blocked": !0,
1420
- children: `Every period of this row is closed, and ${O} — the difference can only be dropped from here.`
1420
+ children: `Every period of this row is closed, and ${c} — the difference can only be dropped from here.`
1421
1421
  }
1422
1422
  ),
1423
- T.targets.length > 0 && /* @__PURE__ */ c(
1423
+ q.targets.length > 0 && /* @__PURE__ */ u(
1424
1424
  "p",
1425
1425
  {
1426
1426
  className: "mt-1.5 text-[11.5px] tabular-nums text-slate-600 dark:text-slate-300",
1427
1427
  "data-plan-reconcile-preview": !0,
1428
1428
  children: [
1429
- T.targets.slice(0, 6).map(
1430
- (w) => `${it(w)}${s ? ` ${s.key}` : ""} ${z(B(h[w]))} → ${z(de[w])}`
1429
+ q.targets.slice(0, 6).map(
1430
+ ($) => `${it($)}${s ? ` ${s.key}` : ""} ${U(D(d[$]))} → ${U(de[$])}`
1431
1431
  ).join(" · "),
1432
- T.targets.length > 6 ? ` · +${T.targets.length - 6} more` : ""
1432
+ q.targets.length > 6 ? ` · +${q.targets.length - 6} more` : ""
1433
1433
  ]
1434
1434
  }
1435
1435
  ),
1436
- y !== "none" && Math.abs(T.unabsorbed) >= 5e-3 && /* @__PURE__ */ t("p", { className: "mt-1 text-[11.5px] text-amber-700 dark:text-amber-300", children: `${z(Math.abs(T.unabsorbed))} has nowhere to go — it leaves the ${C.toLowerCase()}.` }),
1436
+ w !== "none" && Math.abs(q.unabsorbed) >= 5e-3 && /* @__PURE__ */ t("p", { className: "mt-1 text-[11.5px] text-amber-700 dark:text-amber-300", children: `${U(Math.abs(q.unabsorbed))} has nowhere to go — it leaves the ${v.toLowerCase()}.` }),
1437
1437
  /* @__PURE__ */ t(
1438
1438
  "textarea",
1439
1439
  {
1440
- value: j,
1441
- onChange: (w) => I(w.target.value),
1440
+ value: _,
1441
+ onChange: ($) => O($.target.value),
1442
1442
  rows: 2,
1443
1443
  "aria-label": "Reason",
1444
1444
  className: "mt-2 w-full resize-none rounded-md border border-slate-200 bg-background px-2 py-1 text-[12px] text-slate-800 outline-none focus:border-slate-400 dark:border-border dark:text-slate-100"
@@ -1450,10 +1450,10 @@ function Aa(b) {
1450
1450
  type: "button",
1451
1451
  "data-plan-reconcile-apply": !0,
1452
1452
  onClick: () => {
1453
- const w = s && T.targetPatch && Object.keys(T.targetPatch).length > 0 ? { target: s, patch: T.targetPatch } : void 0;
1454
- p.onApply(T.patch, j.trim() || A, w) && (ie.success(
1455
- w ? `Reconcile staged across ${n.split(" ").pop()} and ${s == null ? void 0 : s.key} — Save to keep it` : "Reconcile staged — Save to keep it"
1456
- ), v(!1));
1453
+ const $ = s && q.targetPatch && Object.keys(q.targetPatch).length > 0 ? { target: s, patch: q.targetPatch } : void 0;
1454
+ x.onApply(q.patch, _.trim() || F, $) && (ie.success(
1455
+ $ ? `Reconcile staged across ${n.split(" ").pop()} and ${s == null ? void 0 : s.key} — Save to keep it` : "Reconcile staged — Save to keep it"
1456
+ ), M(!1));
1457
1457
  },
1458
1458
  className: "rounded-md bg-nvr-cyan px-3 py-1 text-[12px] font-medium text-white",
1459
1459
  children: "Stage it"
@@ -1465,28 +1465,28 @@ function Aa(b) {
1465
1465
  ] })
1466
1466
  ] });
1467
1467
  }
1468
- function Fa(b) {
1468
+ function Fa(k) {
1469
1469
  const {
1470
1470
  block: n,
1471
- config: x,
1471
+ config: h,
1472
1472
  canSplit: f,
1473
1473
  splitUnavailable: i,
1474
- splitBase: k,
1475
- client: M,
1476
- cols: E,
1477
- catLabel: K,
1478
- showHistory: L,
1479
- onHistory: p,
1474
+ splitBase: b,
1475
+ client: P,
1476
+ cols: j,
1477
+ catLabel: I,
1478
+ showHistory: T,
1479
+ onHistory: x,
1480
1480
  onSpread: N,
1481
- onRemove: v,
1482
- onDone: y,
1483
- rc: g
1484
- } = b, [j, I] = W(!1), [C, q] = W("menu");
1481
+ onRemove: M,
1482
+ onDone: w,
1483
+ rc: y
1484
+ } = k, [_, O] = W(!1), [v, R] = W("menu");
1485
1485
  ue(() => {
1486
- j && q("menu");
1487
- }, [j]);
1488
- const s = [...n.top ? [n.top] : [], ...n.cats], O = s.some((R) => R.edited || R.isNew), h = "flex w-full items-center gap-2 rounded px-2 py-1.5 text-left text-[12.5px] text-slate-700 hover:bg-muted disabled:cursor-not-allowed disabled:opacity-50 dark:text-slate-200";
1489
- return /* @__PURE__ */ c(ut, { open: j, onOpenChange: I, children: [
1486
+ _ && R("menu");
1487
+ }, [_]);
1488
+ const s = [...n.top ? [n.top] : [], ...n.cats], c = s.some((E) => E.edited || E.isNew), d = "flex w-full items-center gap-2 rounded px-2 py-1.5 text-left text-[12.5px] text-slate-700 hover:bg-muted disabled:cursor-not-allowed disabled:opacity-50 dark:text-slate-200";
1489
+ return /* @__PURE__ */ u(ut, { open: _, onOpenChange: O, children: [
1490
1490
  /* @__PURE__ */ t(pt, { asChild: !0, children: /* @__PURE__ */ t(
1491
1491
  "button",
1492
1492
  {
@@ -1497,97 +1497,97 @@ function Fa(b) {
1497
1497
  children: /* @__PURE__ */ t(ia, { className: "h-3.5 w-3.5" })
1498
1498
  }
1499
1499
  ) }),
1500
- /* @__PURE__ */ c(
1500
+ /* @__PURE__ */ u(
1501
1501
  mt,
1502
1502
  {
1503
1503
  align: "start",
1504
1504
  sideOffset: 6,
1505
- className: D("p-1.5", C === "split" ? "w-[440px]" : "w-[300px]"),
1505
+ className: B("p-1.5", v === "split" ? "w-[440px]" : "w-[300px]"),
1506
1506
  children: [
1507
- C === "menu" && /* @__PURE__ */ c("div", { children: [
1508
- n.mode === "top" && f && /* @__PURE__ */ c(
1507
+ v === "menu" && /* @__PURE__ */ u("div", { children: [
1508
+ n.mode === "top" && f && /* @__PURE__ */ u(
1509
1509
  "button",
1510
1510
  {
1511
1511
  type: "button",
1512
1512
  "data-plan-split": n.key,
1513
- disabled: O,
1514
- onClick: () => q("split"),
1515
- className: h,
1513
+ disabled: c,
1514
+ onClick: () => R("split"),
1515
+ className: d,
1516
1516
  children: [
1517
1517
  /* @__PURE__ */ t(Et, { className: "h-3.5 w-3.5" }),
1518
- x.split_label ?? "Plan by category"
1518
+ h.split_label ?? "Plan by category"
1519
1519
  ]
1520
1520
  }
1521
1521
  ),
1522
- n.mode === "top" && !f && i && /* @__PURE__ */ c("div", { "data-plan-split-unavailable": !0, className: "px-2 py-1.5", children: [
1523
- /* @__PURE__ */ c("p", { className: "flex items-center gap-2 text-[12.5px] text-slate-400 dark:text-slate-500", children: [
1522
+ n.mode === "top" && !f && i && /* @__PURE__ */ u("div", { "data-plan-split-unavailable": !0, className: "px-2 py-1.5", children: [
1523
+ /* @__PURE__ */ u("p", { className: "flex items-center gap-2 text-[12.5px] text-slate-400 dark:text-slate-500", children: [
1524
1524
  /* @__PURE__ */ t(Et, { className: "h-3.5 w-3.5" }),
1525
- x.split_label ?? "Plan by category"
1525
+ h.split_label ?? "Plan by category"
1526
1526
  ] }),
1527
1527
  /* @__PURE__ */ t("p", { className: "mt-0.5 pl-[22px] text-[11px] text-slate-500 dark:text-slate-400", children: i })
1528
1528
  ] }),
1529
- n.mode === "split" && k && /* @__PURE__ */ c(
1529
+ n.mode === "split" && b && /* @__PURE__ */ u(
1530
1530
  "button",
1531
1531
  {
1532
1532
  type: "button",
1533
1533
  "data-plan-merge": n.key,
1534
- disabled: O,
1535
- onClick: () => q("merge"),
1536
- className: h,
1534
+ disabled: c,
1535
+ onClick: () => R("merge"),
1536
+ className: d,
1537
1537
  children: [
1538
1538
  /* @__PURE__ */ t(da, { className: "h-3.5 w-3.5" }),
1539
- x.merge_label ?? "Merge back to one line"
1539
+ h.merge_label ?? "Merge back to one line"
1540
1540
  ]
1541
1541
  }
1542
1542
  ),
1543
- O && (n.mode === "split" || f) && /* @__PURE__ */ t("p", { className: "px-2 pb-1 text-[11px] text-slate-500 dark:text-slate-400", children: "Save your changes to this block first." }),
1544
- N && s.map((R) => /* @__PURE__ */ c(
1543
+ c && (n.mode === "split" || f) && /* @__PURE__ */ t("p", { className: "px-2 pb-1 text-[11px] text-slate-500 dark:text-slate-400", children: "Save your changes to this block first." }),
1544
+ N && s.map((E) => /* @__PURE__ */ u(
1545
1545
  "button",
1546
1546
  {
1547
1547
  type: "button",
1548
- "data-plan-spread": R.uid,
1548
+ "data-plan-spread": E.uid,
1549
1549
  onClick: () => {
1550
- N(R), I(!1);
1550
+ N(E), O(!1);
1551
1551
  },
1552
- className: h,
1552
+ className: d,
1553
1553
  children: [
1554
1554
  /* @__PURE__ */ t("span", { className: "w-3.5" }),
1555
- `Spread what is left${R.cat ? ` · ${K(R.cat)}` : ""}`
1555
+ `Spread what is left${E.cat ? ` · ${I(E.cat)}` : ""}`
1556
1556
  ]
1557
1557
  },
1558
- R.uid
1558
+ E.uid
1559
1559
  )),
1560
- L && s.filter((R) => R.id).map((R) => /* @__PURE__ */ c("div", { className: "flex items-center", children: [
1561
- /* @__PURE__ */ c(
1560
+ T && s.filter((E) => E.id).map((E) => /* @__PURE__ */ u("div", { className: "flex items-center", children: [
1561
+ /* @__PURE__ */ u(
1562
1562
  "button",
1563
1563
  {
1564
1564
  type: "button",
1565
1565
  onClick: () => {
1566
- p(R), I(!1);
1566
+ x(E), O(!1);
1567
1567
  },
1568
- className: h,
1568
+ className: d,
1569
1569
  children: [
1570
1570
  /* @__PURE__ */ t(ca, { className: "h-3.5 w-3.5" }),
1571
- `History${R.cat ? ` · ${K(R.cat)}` : ""}`
1571
+ `History${E.cat ? ` · ${I(E.cat)}` : ""}`
1572
1572
  ]
1573
1573
  }
1574
1574
  ),
1575
1575
  /* @__PURE__ */ t(
1576
1576
  Ea,
1577
1577
  {
1578
- collection: g,
1579
- rowId: R.id,
1580
- rowLabel: `${n.key}${R.cat ? ` ${K(R.cat)}` : ""}`
1578
+ collection: y,
1579
+ rowId: E.id,
1580
+ rowLabel: `${n.key}${E.cat ? ` ${I(E.cat)}` : ""}`
1581
1581
  }
1582
1582
  )
1583
- ] }, R.uid)),
1584
- /* @__PURE__ */ c(
1583
+ ] }, E.uid)),
1584
+ /* @__PURE__ */ u(
1585
1585
  "button",
1586
1586
  {
1587
1587
  type: "button",
1588
1588
  "data-plan-remove": n.key,
1589
- onClick: () => q("remove"),
1590
- className: D(h, "text-red-700 dark:text-red-300"),
1589
+ onClick: () => R("remove"),
1590
+ className: B(d, "text-red-700 dark:text-red-300"),
1591
1591
  children: [
1592
1592
  /* @__PURE__ */ t(ua, { className: "h-3.5 w-3.5" }),
1593
1593
  `Remove ${n.key}`
@@ -1595,14 +1595,14 @@ function Fa(b) {
1595
1595
  }
1596
1596
  )
1597
1597
  ] }),
1598
- C === "remove" && /* @__PURE__ */ c("div", { className: "p-1.5", children: [
1598
+ v === "remove" && /* @__PURE__ */ u("div", { className: "p-1.5", children: [
1599
1599
  /* @__PURE__ */ t("p", { className: "text-[12.5px] text-slate-700 dark:text-slate-200", children: `Remove the ${n.key} plan? It leaves with the next Save.` }),
1600
- /* @__PURE__ */ c("div", { className: "mt-2 flex justify-end gap-2", children: [
1600
+ /* @__PURE__ */ u("div", { className: "mt-2 flex justify-end gap-2", children: [
1601
1601
  /* @__PURE__ */ t(
1602
1602
  "button",
1603
1603
  {
1604
1604
  type: "button",
1605
- onClick: () => q("menu"),
1605
+ onClick: () => R("menu"),
1606
1606
  className: "rounded-md px-2.5 py-1 text-[12px] text-slate-600 hover:bg-muted dark:text-slate-300",
1607
1607
  children: "Keep it"
1608
1608
  }
@@ -1613,7 +1613,7 @@ function Fa(b) {
1613
1613
  type: "button",
1614
1614
  "data-plan-remove-confirm": !0,
1615
1615
  onClick: () => {
1616
- v(), I(!1);
1616
+ M(), O(!1);
1617
1617
  },
1618
1618
  className: "rounded-md bg-red-600 px-2.5 py-1 text-[12px] font-medium text-white",
1619
1619
  children: "Remove"
@@ -1621,30 +1621,30 @@ function Fa(b) {
1621
1621
  )
1622
1622
  ] })
1623
1623
  ] }),
1624
- C === "split" && k && n.top && /* @__PURE__ */ t(
1624
+ v === "split" && b && n.top && /* @__PURE__ */ t(
1625
1625
  Ka,
1626
1626
  {
1627
1627
  block: n,
1628
- config: x,
1629
- splitBase: k,
1630
- client: M,
1631
- cols: E,
1632
- onCancel: () => q("menu"),
1628
+ config: h,
1629
+ splitBase: b,
1630
+ client: P,
1631
+ cols: j,
1632
+ onCancel: () => R("menu"),
1633
1633
  onDone: () => {
1634
- I(!1), y();
1634
+ O(!1), w();
1635
1635
  }
1636
1636
  }
1637
1637
  ),
1638
- C === "merge" && k && /* @__PURE__ */ t(
1638
+ v === "merge" && b && /* @__PURE__ */ t(
1639
1639
  Ia,
1640
1640
  {
1641
1641
  block: n,
1642
- config: x,
1643
- splitBase: k,
1644
- client: M,
1645
- onCancel: () => q("menu"),
1642
+ config: h,
1643
+ splitBase: b,
1644
+ client: P,
1645
+ onCancel: () => R("menu"),
1646
1646
  onDone: () => {
1647
- I(!1), y();
1647
+ O(!1), w();
1648
1648
  }
1649
1649
  }
1650
1650
  )
@@ -1653,146 +1653,146 @@ function Fa(b) {
1653
1653
  )
1654
1654
  ] });
1655
1655
  }
1656
- function dt(b) {
1657
- return ga(b, "Something went wrong");
1656
+ function dt(k) {
1657
+ return ga(k, "Something went wrong");
1658
1658
  }
1659
- function Ka(b) {
1659
+ function Ka(k) {
1660
1660
  var de, re;
1661
- const { block: n, config: x, splitBase: f, client: i, cols: k, onCancel: M, onDone: E } = b, K = Number.isFinite(Number(n.key)) ? Number(n.key) : n.key, [L, p] = W(null), [N, v] = W(null), [y, g] = W(null), [j, I] = W(!1), [C, q] = W(""), s = JSON.stringify(L);
1661
+ const { block: n, config: h, splitBase: f, client: i, cols: b, onCancel: P, onDone: j } = k, I = Number.isFinite(Number(n.key)) ? Number(n.key) : n.key, [T, x] = W(null), [N, M] = W(null), [w, y] = W(null), [_, O] = W(!1), [v, R] = W(""), s = JSON.stringify(T);
1662
1662
  ue(() => {
1663
- let A = !0;
1663
+ let F = !0;
1664
1664
  const le = window.setTimeout(
1665
1665
  () => {
1666
1666
  i.request(
1667
1667
  ot(`${f}/split`, {
1668
- [x.key_field]: K,
1668
+ [h.key_field]: I,
1669
1669
  preview: !0,
1670
- ...L ? { shares: L } : {}
1670
+ ...T ? { shares: T } : {}
1671
1671
  })
1672
1672
  ).then((V) => {
1673
- A && (v(V.data), g(null), L || p(
1673
+ F && (M(V.data), y(null), T || x(
1674
1674
  Object.fromEntries(
1675
1675
  V.data.categories.map((ce) => [String(ce.id), Math.round(ce.share * 1e3) / 10])
1676
1676
  )
1677
1677
  ));
1678
- }).catch((V) => A && g(dt(V)));
1678
+ }).catch((V) => F && y(dt(V)));
1679
1679
  },
1680
- L ? 250 : 0
1680
+ T ? 250 : 0
1681
1681
  );
1682
1682
  return () => {
1683
- A = !1, window.clearTimeout(le);
1683
+ F = !1, window.clearTimeout(le);
1684
1684
  };
1685
1685
  }, [s, f]);
1686
- const O = (N == null ? void 0 : N.categories.map((A) => A.label).join(" / ")) ?? "", h = `Split the ${n.key} plan into ${O}`, R = async () => {
1687
- I(!0);
1686
+ const c = (N == null ? void 0 : N.categories.map((F) => F.label).join(" / ")) ?? "", d = `Split the ${n.key} plan into ${c}`, E = async () => {
1687
+ O(!0);
1688
1688
  try {
1689
1689
  await i.request(
1690
1690
  ot(`${f}/split`, {
1691
- [x.key_field]: K,
1692
- shares: L ?? void 0,
1693
- reason: C.trim() || h
1691
+ [h.key_field]: I,
1692
+ shares: T ?? void 0,
1693
+ reason: v.trim() || d
1694
1694
  })
1695
- ), ie.success(`${n.key} is now planned by ${O}`), E();
1696
- } catch (A) {
1697
- g(dt(A));
1695
+ ), ie.success(`${n.key} is now planned by ${c}`), j();
1696
+ } catch (F) {
1697
+ y(dt(F));
1698
1698
  } finally {
1699
- I(!1);
1699
+ O(!1);
1700
1700
  }
1701
- }, T = (A) => F(k.reduce((le, V) => le + B(A[V]), 0));
1702
- return /* @__PURE__ */ c("div", { className: "p-1.5", "data-plan-split-pane": !0, children: [
1703
- /* @__PURE__ */ t("p", { className: "text-[12.5px] font-semibold text-slate-900 dark:text-slate-100", children: `${x.split_label ?? "Plan by category"} · ${n.key}` }),
1701
+ }, q = (F) => K(b.reduce((le, V) => le + D(F[V]), 0));
1702
+ return /* @__PURE__ */ u("div", { className: "p-1.5", "data-plan-split-pane": !0, children: [
1703
+ /* @__PURE__ */ t("p", { className: "text-[12.5px] font-semibold text-slate-900 dark:text-slate-100", children: `${h.split_label ?? "Plan by category"} · ${n.key}` }),
1704
1704
  /* @__PURE__ */ t("p", { className: "mt-0.5 text-[11.5px] text-slate-600 dark:text-slate-300", children: "Every period is divided by these shares. Closed periods keep their totals; open ones can be changed in the grid afterwards." }),
1705
- !N && !y && /* @__PURE__ */ t(
1705
+ !N && !w && /* @__PURE__ */ t(
1706
1706
  "div",
1707
1707
  {
1708
1708
  className: "mt-2 h-16 animate-pulse rounded",
1709
1709
  style: { background: "hsl(var(--nvr-skeleton))" }
1710
1710
  }
1711
1711
  ),
1712
- N && (((de = N.share_sets) == null ? void 0 : de.length) ?? 0) > 1 && /* @__PURE__ */ c("div", { className: "mt-2 flex flex-wrap items-center gap-1", "data-plan-share-sets": !0, children: [
1712
+ N && (((de = N.share_sets) == null ? void 0 : de.length) ?? 0) > 1 && /* @__PURE__ */ u("div", { className: "mt-2 flex flex-wrap items-center gap-1", "data-plan-share-sets": !0, children: [
1713
1713
  /* @__PURE__ */ t("span", { className: "text-[11px] text-slate-500 dark:text-slate-400", children: "Shares from" }),
1714
- (re = N.share_sets) == null ? void 0 : re.map((A) => {
1714
+ (re = N.share_sets) == null ? void 0 : re.map((F) => {
1715
1715
  const le = Object.fromEntries(
1716
- Object.entries(A.shares).map(([ce, w]) => [ce, Math.round(w * 1e3) / 10])
1716
+ Object.entries(F.shares).map(([ce, $]) => [ce, Math.round($ * 1e3) / 10])
1717
1717
  ), V = JSON.stringify(le) === s;
1718
1718
  return /* @__PURE__ */ t(
1719
1719
  "button",
1720
1720
  {
1721
1721
  type: "button",
1722
- "data-plan-share-set": A.key,
1722
+ "data-plan-share-set": F.key,
1723
1723
  "aria-pressed": V,
1724
- "data-tip": A.hint ?? "",
1725
- onClick: () => p(le),
1724
+ "data-tip": F.hint ?? "",
1725
+ onClick: () => x(le),
1726
1726
  className: `h-6 rounded-md border px-1.5 text-[11px] font-medium ${V ? "border-transparent bg-nvr-cyan text-white" : "border-slate-200 text-slate-600 hover:bg-muted dark:border-border dark:text-slate-300"}`,
1727
- children: A.label
1727
+ children: F.label
1728
1728
  },
1729
- A.key
1729
+ F.key
1730
1730
  );
1731
1731
  })
1732
1732
  ] }),
1733
- N && /* @__PURE__ */ c("table", { className: "mt-2 w-full text-[12px] tabular-nums", children: [
1734
- /* @__PURE__ */ t("thead", { children: /* @__PURE__ */ c("tr", { className: "text-left text-[10.5px] text-slate-500 dark:text-slate-400", children: [
1733
+ N && /* @__PURE__ */ u("table", { className: "mt-2 w-full text-[12px] tabular-nums", children: [
1734
+ /* @__PURE__ */ t("thead", { children: /* @__PURE__ */ u("tr", { className: "text-left text-[10.5px] text-slate-500 dark:text-slate-400", children: [
1735
1735
  /* @__PURE__ */ t("th", { className: "py-1 font-medium", children: "Category" }),
1736
1736
  /* @__PURE__ */ t("th", { className: "py-1 text-right font-medium", children: "Share" }),
1737
1737
  /* @__PURE__ */ t("th", { className: "py-1 text-right font-medium", children: `${n.key} plan` }),
1738
1738
  /* @__PURE__ */ t("th", { className: "py-1 text-right font-medium", children: "Ceiling" })
1739
1739
  ] }) }),
1740
- /* @__PURE__ */ c("tbody", { children: [
1741
- N.categories.map((A) => /* @__PURE__ */ c("tr", { className: "border-t border-slate-100 dark:border-border", children: [
1742
- /* @__PURE__ */ t("td", { className: "py-1 text-slate-800 dark:text-slate-100", children: A.label }),
1743
- /* @__PURE__ */ c("td", { className: "py-1 text-right", children: [
1740
+ /* @__PURE__ */ u("tbody", { children: [
1741
+ N.categories.map((F) => /* @__PURE__ */ u("tr", { className: "border-t border-slate-100 dark:border-border", children: [
1742
+ /* @__PURE__ */ t("td", { className: "py-1 text-slate-800 dark:text-slate-100", children: F.label }),
1743
+ /* @__PURE__ */ u("td", { className: "py-1 text-right", children: [
1744
1744
  /* @__PURE__ */ t(
1745
1745
  ka,
1746
1746
  {
1747
1747
  bare: !0,
1748
1748
  type: "text",
1749
1749
  allowNegative: !1,
1750
- "data-plan-share": String(A.id),
1751
- "aria-label": `${A.label} share`,
1752
- value: (L == null ? void 0 : L[String(A.id)]) ?? "",
1753
- onValue: (le) => p((V) => ({ ...V ?? {}, [String(A.id)]: le ?? 0 })),
1750
+ "data-plan-share": String(F.id),
1751
+ "aria-label": `${F.label} share`,
1752
+ value: (T == null ? void 0 : T[String(F.id)]) ?? "",
1753
+ onValue: (le) => x((V) => ({ ...V ?? {}, [String(F.id)]: le ?? 0 })),
1754
1754
  className: "h-6 w-16 rounded border border-slate-200 bg-background px-1.5 text-right text-[12px] outline-none focus:border-slate-400 dark:border-border"
1755
1755
  }
1756
1756
  ),
1757
1757
  /* @__PURE__ */ t("span", { className: "ml-0.5 text-slate-500", children: "%" })
1758
1758
  ] }),
1759
- /* @__PURE__ */ t("td", { className: "py-1 text-right text-slate-800 dark:text-slate-100", children: z(T(A.values)) }),
1760
- /* @__PURE__ */ t("td", { className: "py-1 text-right text-slate-500 dark:text-slate-400", children: z(A.cap) })
1761
- ] }, String(A.id))),
1762
- /* @__PURE__ */ c("tr", { className: "border-t border-slate-200 font-medium dark:border-border", children: [
1763
- /* @__PURE__ */ t("td", { className: "py-1 text-slate-800 dark:text-slate-100", children: x.total_label ?? "Total" }),
1759
+ /* @__PURE__ */ t("td", { className: "py-1 text-right text-slate-800 dark:text-slate-100", children: U(q(F.values)) }),
1760
+ /* @__PURE__ */ t("td", { className: "py-1 text-right text-slate-500 dark:text-slate-400", children: U(F.cap) })
1761
+ ] }, String(F.id))),
1762
+ /* @__PURE__ */ u("tr", { className: "border-t border-slate-200 font-medium dark:border-border", children: [
1763
+ /* @__PURE__ */ t("td", { className: "py-1 text-slate-800 dark:text-slate-100", children: h.total_label ?? "Total" }),
1764
1764
  /* @__PURE__ */ t("td", {}),
1765
- /* @__PURE__ */ t("td", { className: "py-1 text-right text-slate-800 dark:text-slate-100", children: z(T(N.original)) }),
1765
+ /* @__PURE__ */ t("td", { className: "py-1 text-right text-slate-800 dark:text-slate-100", children: U(q(N.original)) }),
1766
1766
  /* @__PURE__ */ t("td", {})
1767
1767
  ] })
1768
1768
  ] })
1769
1769
  ] }),
1770
- (y || (N == null ? void 0 : N.blocked)) && /* @__PURE__ */ t(
1770
+ (w || (N == null ? void 0 : N.blocked)) && /* @__PURE__ */ t(
1771
1771
  "p",
1772
1772
  {
1773
1773
  role: "alert",
1774
1774
  "data-plan-split-blocked": !0,
1775
1775
  className: "mt-1.5 text-[11.5px] font-medium text-red-700 dark:text-red-300",
1776
- children: y ?? (N == null ? void 0 : N.blocked)
1776
+ children: w ?? (N == null ? void 0 : N.blocked)
1777
1777
  }
1778
1778
  ),
1779
1779
  /* @__PURE__ */ t(
1780
1780
  "textarea",
1781
1781
  {
1782
- value: C,
1783
- onChange: (A) => q(A.target.value),
1784
- placeholder: h,
1782
+ value: v,
1783
+ onChange: (F) => R(F.target.value),
1784
+ placeholder: d,
1785
1785
  rows: 2,
1786
1786
  "aria-label": "Reason",
1787
1787
  className: "mt-2 w-full resize-none rounded-md border border-slate-200 bg-background px-2 py-1 text-[12px] text-slate-800 outline-none focus:border-slate-400 dark:border-border dark:text-slate-100"
1788
1788
  }
1789
1789
  ),
1790
- /* @__PURE__ */ c("div", { className: "mt-1.5 flex justify-end gap-2", children: [
1790
+ /* @__PURE__ */ u("div", { className: "mt-1.5 flex justify-end gap-2", children: [
1791
1791
  /* @__PURE__ */ t(
1792
1792
  "button",
1793
1793
  {
1794
1794
  type: "button",
1795
- onClick: M,
1795
+ onClick: P,
1796
1796
  className: "rounded-md px-2.5 py-1 text-[12px] text-slate-600 hover:bg-muted dark:text-slate-300",
1797
1797
  children: "Back"
1798
1798
  }
@@ -1802,38 +1802,38 @@ function Ka(b) {
1802
1802
  {
1803
1803
  type: "button",
1804
1804
  "data-plan-split-apply": !0,
1805
- disabled: j || !N || !!N.blocked,
1806
- onClick: R,
1805
+ disabled: _ || !N || !!N.blocked,
1806
+ onClick: E,
1807
1807
  className: "rounded-md bg-nvr-cyan px-3 py-1 text-[12px] font-medium text-white disabled:opacity-50",
1808
- children: j ? "Splitting…" : "Split it"
1808
+ children: _ ? "Splitting…" : "Split it"
1809
1809
  }
1810
1810
  )
1811
1811
  ] })
1812
1812
  ] });
1813
1813
  }
1814
- function Ia(b) {
1815
- const { block: n, config: x, splitBase: f, client: i, onCancel: k, onDone: M } = b, E = Number.isFinite(Number(n.key)) ? Number(n.key) : n.key, [K, L] = W(""), [p, N] = W(!1), [v, y] = W(null), g = `Merged the ${n.key} plan back to one line`;
1816
- return /* @__PURE__ */ c("div", { className: "p-1.5", "data-plan-merge-pane": !0, children: [
1817
- /* @__PURE__ */ t("p", { className: "text-[12.5px] font-semibold text-slate-900 dark:text-slate-100", children: `${x.merge_label ?? "Merge back to one line"} · ${n.key}` }),
1814
+ function Ia(k) {
1815
+ const { block: n, config: h, splitBase: f, client: i, onCancel: b, onDone: P } = k, j = Number.isFinite(Number(n.key)) ? Number(n.key) : n.key, [I, T] = W(""), [x, N] = W(!1), [M, w] = W(null), y = `Merged the ${n.key} plan back to one line`;
1816
+ return /* @__PURE__ */ u("div", { className: "p-1.5", "data-plan-merge-pane": !0, children: [
1817
+ /* @__PURE__ */ t("p", { className: "text-[12.5px] font-semibold text-slate-900 dark:text-slate-100", children: `${h.merge_label ?? "Merge back to one line"} · ${n.key}` }),
1818
1818
  /* @__PURE__ */ t("p", { className: "mt-0.5 text-[11.5px] text-slate-600 dark:text-slate-300", children: "The category lines are added together, period by period. Their history stays on the record." }),
1819
- v && /* @__PURE__ */ t("p", { role: "alert", className: "mt-1.5 text-[11.5px] font-medium text-red-700 dark:text-red-300", children: v }),
1819
+ M && /* @__PURE__ */ t("p", { role: "alert", className: "mt-1.5 text-[11.5px] font-medium text-red-700 dark:text-red-300", children: M }),
1820
1820
  /* @__PURE__ */ t(
1821
1821
  "textarea",
1822
1822
  {
1823
- value: K,
1824
- onChange: (j) => L(j.target.value),
1825
- placeholder: g,
1823
+ value: I,
1824
+ onChange: (_) => T(_.target.value),
1825
+ placeholder: y,
1826
1826
  rows: 2,
1827
1827
  "aria-label": "Reason",
1828
1828
  className: "mt-2 w-full resize-none rounded-md border border-slate-200 bg-background px-2 py-1 text-[12px] text-slate-800 outline-none focus:border-slate-400 dark:border-border dark:text-slate-100"
1829
1829
  }
1830
1830
  ),
1831
- /* @__PURE__ */ c("div", { className: "mt-1.5 flex justify-end gap-2", children: [
1831
+ /* @__PURE__ */ u("div", { className: "mt-1.5 flex justify-end gap-2", children: [
1832
1832
  /* @__PURE__ */ t(
1833
1833
  "button",
1834
1834
  {
1835
1835
  type: "button",
1836
- onClick: k,
1836
+ onClick: b,
1837
1837
  className: "rounded-md px-2.5 py-1 text-[12px] text-slate-600 hover:bg-muted dark:text-slate-300",
1838
1838
  children: "Back"
1839
1839
  }
@@ -1843,90 +1843,149 @@ function Ia(b) {
1843
1843
  {
1844
1844
  type: "button",
1845
1845
  "data-plan-merge-apply": !0,
1846
- disabled: p,
1846
+ disabled: x,
1847
1847
  onClick: async () => {
1848
1848
  N(!0);
1849
1849
  try {
1850
1850
  await i.request(
1851
1851
  ot(`${f}/merge`, {
1852
- [x.key_field]: E,
1853
- reason: K.trim() || g
1852
+ [h.key_field]: j,
1853
+ reason: I.trim() || y
1854
1854
  })
1855
- ), ie.success(`${n.key} is one line again`), M();
1856
- } catch (j) {
1857
- y(dt(j));
1855
+ ), ie.success(`${n.key} is one line again`), P();
1856
+ } catch (_) {
1857
+ w(dt(_));
1858
1858
  } finally {
1859
1859
  N(!1);
1860
1860
  }
1861
1861
  },
1862
1862
  className: "rounded-md bg-nvr-cyan px-3 py-1 text-[12px] font-medium text-white disabled:opacity-50",
1863
- children: p ? "Merging…" : "Merge it"
1863
+ children: x ? "Merging…" : "Merge it"
1864
1864
  }
1865
1865
  )
1866
1866
  ] })
1867
1867
  ] });
1868
1868
  }
1869
- function Ba(b) {
1870
- const { config: n, client: x, used: f, onAdd: i, label: k } = b, [M, E] = W(!1), [K, L] = W(""), { data: p = [] } = he({
1869
+ function Da(k) {
1870
+ const { config: n, client: h, used: f, onAdd: i, label: b } = k, [P, j] = W(!1), [I, T] = W(""), { data: x = [] } = he({
1871
1871
  queryKey: ["plan-grid-keys", n.key_collection],
1872
- queryFn: () => x.request(
1872
+ queryFn: () => h.request(
1873
1873
  fe(`/items/${n.key_collection}`, { fields: "id", sort: "-id", limit: 200 })
1874
- ).then((v) => (v.data ?? []).map((y) => y.id)),
1875
- enabled: M && !!n.key_collection,
1874
+ ).then((c) => (c.data ?? []).map((d) => d.id)),
1875
+ enabled: P && !!n.key_collection,
1876
1876
  staleTime: 10 * 6e4
1877
- }), N = p.filter((v) => !f.has(String(v)));
1878
- return /* @__PURE__ */ c(ut, { open: M, onOpenChange: E, children: [
1879
- /* @__PURE__ */ t(pt, { asChild: !0, children: /* @__PURE__ */ c(
1880
- "button",
1881
- {
1882
- type: "button",
1883
- "data-plan-add": !0,
1884
- className: "inline-flex h-7 items-center gap-1 rounded-md border border-slate-200 px-2 text-[12px] font-medium text-slate-700 hover:bg-muted dark:border-border dark:text-slate-200",
1885
- children: [
1886
- /* @__PURE__ */ t(pa, { className: "h-3.5 w-3.5" }),
1887
- k
1888
- ]
1889
- }
1890
- ) }),
1891
- /* @__PURE__ */ t(mt, { align: "start", sideOffset: 6, className: "w-[200px] p-1.5", children: n.key_collection ? /* @__PURE__ */ c("ul", { className: "max-h-[220px] overflow-y-auto", children: [
1892
- N.length === 0 && /* @__PURE__ */ t("li", { className: "px-2 py-1.5 text-[12px] text-slate-500", children: "Every one is already here." }),
1893
- N.map((v) => /* @__PURE__ */ t("li", { children: /* @__PURE__ */ t(
1894
- "button",
1895
- {
1896
- type: "button",
1897
- "data-plan-add-key": String(v),
1898
- onClick: () => {
1899
- i(v), E(!1);
1900
- },
1901
- className: "w-full rounded px-2 py-1.5 text-left text-[12.5px] text-slate-700 hover:bg-muted dark:text-slate-200",
1902
- children: String(v)
1903
- }
1904
- ) }, String(v)))
1905
- ] }) : /* @__PURE__ */ t(
1906
- "form",
1907
- {
1908
- onSubmit: (v) => {
1909
- v.preventDefault();
1910
- const y = K.trim();
1911
- !y || f.has(y) || (i(Number.isFinite(Number(y)) ? Number(y) : y), L(""), E(!1));
1912
- },
1913
- children: /* @__PURE__ */ t(
1914
- "input",
1877
+ }), N = x.filter((c) => !f.has(String(c))), [M, w] = W(""), [y, _] = W(0), O = Ba(N, M), v = Math.min(y, Math.max(0, O.length - 1)), R = `plan-add-${n.key_collection ?? "keys"}`, s = (c) => {
1878
+ i(c), j(!1);
1879
+ };
1880
+ return /* @__PURE__ */ u(
1881
+ ut,
1882
+ {
1883
+ open: P,
1884
+ onOpenChange: (c) => {
1885
+ j(c), c || (w(""), _(0));
1886
+ },
1887
+ children: [
1888
+ /* @__PURE__ */ t(pt, { asChild: !0, children: /* @__PURE__ */ u(
1889
+ "button",
1890
+ {
1891
+ type: "button",
1892
+ "data-plan-add": !0,
1893
+ className: "inline-flex h-7 items-center gap-1 rounded-md border border-slate-200 px-2 text-[12px] font-medium text-slate-700 hover:bg-muted dark:border-border dark:text-slate-200",
1894
+ children: [
1895
+ /* @__PURE__ */ t(pa, { className: "h-3.5 w-3.5" }),
1896
+ b
1897
+ ]
1898
+ }
1899
+ ) }),
1900
+ /* @__PURE__ */ t(mt, { align: "start", sideOffset: 6, className: "w-[200px] p-1.5", children: n.key_collection ? /* @__PURE__ */ u(It, { children: [
1901
+ /* @__PURE__ */ t(
1902
+ "input",
1903
+ {
1904
+ autoFocus: !0,
1905
+ value: M,
1906
+ onChange: (c) => {
1907
+ w(c.target.value), _(0);
1908
+ },
1909
+ onKeyDown: (c) => {
1910
+ if (c.key === "ArrowDown")
1911
+ c.preventDefault(), _(Math.min(v + 1, O.length - 1));
1912
+ else if (c.key === "ArrowUp")
1913
+ c.preventDefault(), _(Math.max(v - 1, 0));
1914
+ else if (c.key === "Enter") {
1915
+ c.preventDefault();
1916
+ const d = O[v];
1917
+ d !== void 0 && s(d);
1918
+ }
1919
+ },
1920
+ role: "combobox",
1921
+ "aria-expanded": "true",
1922
+ "aria-controls": R,
1923
+ "aria-activedescendant": O.length ? `${R}-${String(O[v])}` : void 0,
1924
+ "aria-label": `${b}: type to find`,
1925
+ placeholder: "Type to find…",
1926
+ "data-plan-add-filter": !0,
1927
+ className: "mb-1 h-7 w-full rounded border border-slate-200 bg-background px-2 text-[12.5px] outline-none focus:border-slate-400 dark:border-border"
1928
+ }
1929
+ ),
1930
+ N.length === 0 && /* @__PURE__ */ t("p", { className: "px-2 py-1.5 text-[12px] text-slate-500", children: "Every one is already here." }),
1931
+ N.length > 0 && O.length === 0 && /* @__PURE__ */ u("p", { className: "px-2 py-1.5 text-[12px] text-slate-500", children: [
1932
+ "Nothing matches “",
1933
+ M.trim(),
1934
+ "”."
1935
+ ] }),
1936
+ /* @__PURE__ */ t("div", { id: R, role: "listbox", className: "max-h-[220px] overflow-y-auto", children: O.map((c, d) => /* @__PURE__ */ t(
1937
+ "button",
1938
+ {
1939
+ id: `${R}-${String(c)}`,
1940
+ type: "button",
1941
+ role: "option",
1942
+ "aria-selected": d === v,
1943
+ tabIndex: -1,
1944
+ "data-plan-add-key": String(c),
1945
+ onClick: () => s(c),
1946
+ onMouseEnter: () => _(d),
1947
+ className: B(
1948
+ "block w-full rounded px-2 py-1.5 text-left text-[12.5px] text-slate-700 hover:bg-muted dark:text-slate-200",
1949
+ d === v && "bg-accent"
1950
+ ),
1951
+ children: String(c)
1952
+ },
1953
+ String(c)
1954
+ )) })
1955
+ ] }) : /* @__PURE__ */ t(
1956
+ "form",
1915
1957
  {
1916
- value: K,
1917
- onChange: (v) => L(v.target.value),
1918
- "aria-label": k,
1919
- className: "h-7 w-full rounded border border-slate-200 bg-background px-2 text-[12.5px] outline-none focus:border-slate-400 dark:border-border"
1958
+ onSubmit: (c) => {
1959
+ c.preventDefault();
1960
+ const d = I.trim();
1961
+ !d || f.has(d) || (i(Number.isFinite(Number(d)) ? Number(d) : d), T(""), j(!1));
1962
+ },
1963
+ children: /* @__PURE__ */ t(
1964
+ "input",
1965
+ {
1966
+ value: I,
1967
+ onChange: (c) => T(c.target.value),
1968
+ "aria-label": b,
1969
+ className: "h-7 w-full rounded border border-slate-200 bg-background px-2 text-[12.5px] outline-none focus:border-slate-400 dark:border-border"
1970
+ }
1971
+ )
1920
1972
  }
1921
- )
1922
- }
1923
- ) })
1924
- ] });
1973
+ ) })
1974
+ ]
1975
+ }
1976
+ );
1977
+ }
1978
+ function Ba(k, n) {
1979
+ const h = n.trim().toLowerCase();
1980
+ if (!h) return k;
1981
+ const f = k.filter((b) => String(b).toLowerCase().includes(h));
1982
+ return [...f.filter((b) => String(b).toLowerCase() === h), ...f.filter((b) => String(b).toLowerCase() !== h)];
1925
1983
  }
1926
1984
  export {
1927
- il as PlanGridField,
1928
- Dt as figureError,
1929
- z as fmtFigure,
1985
+ dl as PlanGridField,
1986
+ Ut as figureError,
1987
+ Ba as filterAddKeys,
1988
+ U as fmtFigure,
1930
1989
  Pa as isParentItemKey,
1931
1990
  Ta as nextStagedEdit,
1932
1991
  Bt as parseFigure,