@nivaro/react 0.3.113 → 0.3.115

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