@nivaro/react 0.3.58 → 0.3.59

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