@nivaro/react 0.3.52 → 0.3.54

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