@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
@@ -0,0 +1,1227 @@
1
+ import { jsx as t, jsxs as r, Fragment as me } from "react/jsx-runtime";
2
+ import { useQuery as Ue } from "@tanstack/react-query";
3
+ import { GitMerge as Fe, ArrowRight as We, Loader2 as fe, Undo2 as ue, CheckCircle2 as Ae, AlertTriangle as ne, Lock as be, Check as De, Layers as He, Pencil as Ge } from "lucide-react";
4
+ import { useState as S, useMemo as X, useEffect as he, useRef as Qe } from "react";
5
+ import { useNivaroClient as ze, useItemNavigation as Xe } from "../../context.js";
6
+ import { get as Je, post as Te, patch as Ze } from "../../lib/commands.js";
7
+ import { cn as F, formatDate as Ve } from "../../lib/utils.js";
8
+ import { ErrorNotice as xe } from "../ErrorNotice.js";
9
+ import { Button as K } from "../ui/button.js";
10
+ import { Dialog as et, DialogContent as tt, DialogTitle as at, DialogDescription as rt } from "../ui/dialog.js";
11
+ import { Input as st } from "../ui/input.js";
12
+ import { SimpleSelect as nt } from "../ui/SimpleSelect.js";
13
+ import { Skeleton as je } from "../ui/skeleton.js";
14
+ import { Textarea as dt } from "../ui/textarea.js";
15
+ import { firstSurvivor as lt, defaultRoles as it, defaultPicks as ce, sameValue as Ie, differingFields as ot, survivorChanges as ct, relationTotal as ge, plural as L, combineValues as mt, displayValue as se, isEmptyValue as ut } from "./merge-values.js";
16
+ const ht = "__draft__", p = (e) => e.draft ? "New" : e.ref || `#${e.id}`, z = (e) => {
17
+ const a = p(e);
18
+ return e.label && e.label !== a ? `${a} ${e.label}` : a;
19
+ };
20
+ function gt(e) {
21
+ const a = e == null ? void 0 : e.response;
22
+ if (!a) return null;
23
+ const d = (l) => {
24
+ var m;
25
+ const s = a[l] ?? ((m = a.data) == null ? void 0 : m[l]);
26
+ return typeof s == "string" ? s : null;
27
+ };
28
+ return {
29
+ code: d("code"),
30
+ message: d("error") ?? "",
31
+ record: d("record"),
32
+ changedBy: d("changed_by")
33
+ };
34
+ }
35
+ function Ut({
36
+ collection: e,
37
+ ids: a,
38
+ open: d,
39
+ onOpenChange: l,
40
+ draft: s,
41
+ preferredSurvivor: m,
42
+ onMerged: o,
43
+ container: y
44
+ }) {
45
+ return /* @__PURE__ */ t(et, { open: d, onOpenChange: l, children: /* @__PURE__ */ t(
46
+ tt,
47
+ {
48
+ container: y,
49
+ "data-merge-records": !0,
50
+ className: "flex max-h-[min(92vh,940px)] w-[min(1320px,96vw)] max-w-none flex-col overflow-hidden p-0 dark:bg-card max-sm:h-[100dvh] max-sm:max-h-none max-sm:w-screen max-sm:rounded-none",
51
+ onPointerDownOutside: (v) => v.preventDefault(),
52
+ children: d && /* @__PURE__ */ t(
53
+ ft,
54
+ {
55
+ collection: e,
56
+ ids: a.map(String),
57
+ draft: s ?? null,
58
+ preferredSurvivor: m != null ? String(m) : null,
59
+ onClose: () => l(!1),
60
+ onMerged: o
61
+ }
62
+ )
63
+ }
64
+ ) });
65
+ }
66
+ function ft({
67
+ collection: e,
68
+ ids: a,
69
+ draft: d,
70
+ preferredSurvivor: l,
71
+ onClose: s,
72
+ onMerged: m
73
+ }) {
74
+ const o = ze(), [y, v] = S("choose"), k = Ue({
75
+ queryKey: ["record-merge-plan", e, a.join(","), d ? "draft" : ""],
76
+ queryFn: () => o.request(
77
+ Je(`/record-merge/${e}/plan`, {
78
+ ids: a.join(","),
79
+ ...d ? { draft: "1" } : {}
80
+ })
81
+ ).then((x) => x.data),
82
+ staleTime: 0,
83
+ gcTime: 0,
84
+ retry: !1
85
+ }), h = k.data, _ = X(() => {
86
+ var f;
87
+ if (!h) return [];
88
+ if (!d) return h.records;
89
+ const x = {};
90
+ for (const w of h.fields) x[w.field] = d.values[w.field] ?? null;
91
+ return [
92
+ ...h.records,
93
+ {
94
+ id: ht,
95
+ label: ((f = d.label) == null ? void 0 : f.trim()) || "Your new record",
96
+ values: x,
97
+ state: null,
98
+ can_survive: !1,
99
+ survive_reason: "It is not saved yet — keep the existing record instead.",
100
+ can_discard: !0,
101
+ discard_reason: null,
102
+ partner: null,
103
+ open_tasks: 0,
104
+ open_approvals: 0,
105
+ draft: !0
106
+ }
107
+ ];
108
+ }, [h, d]);
109
+ return /* @__PURE__ */ r(me, { children: [
110
+ /* @__PURE__ */ r("header", { className: "shrink-0 border-b border-slate-200 px-6 pb-4 pt-5 pr-12 dark:border-border max-sm:px-4", children: [
111
+ /* @__PURE__ */ r(at, { className: "flex items-center gap-2 text-[16px] font-semibold text-slate-900 dark:text-foreground", children: [
112
+ /* @__PURE__ */ t(Fe, { className: "h-4 w-4 text-nvr-cyan", "aria-hidden": !0 }),
113
+ h ? d ? `Merge your new ${h.noun} into an existing one` : `Merge ${_.length} ${h.plural}` : "Merge records"
114
+ ] }),
115
+ /* @__PURE__ */ t(
116
+ rt,
117
+ {
118
+ className: F(
119
+ "mt-1 max-w-[72ch] text-[12.5px] leading-relaxed text-slate-500 dark:text-muted-foreground",
120
+ y === "done" && "sr-only"
121
+ ),
122
+ children: y === "review" ? "Check what will change before you merge." : y === "done" ? "The merge is finished." : "Pick each value from any record, combine them, or type a new one. The record you keep keeps its number and history; the ones you discard go to the trash and can be restored."
123
+ }
124
+ )
125
+ ] }),
126
+ k.isLoading && /* @__PURE__ */ t(bt, {}),
127
+ k.isError && /* @__PURE__ */ t("div", { className: "p-6", children: /* @__PURE__ */ t(
128
+ xe,
129
+ {
130
+ error: k.error,
131
+ fallback: "Could not open the merge",
132
+ onRetry: () => void k.refetch()
133
+ }
134
+ ) }),
135
+ h && /* @__PURE__ */ t(
136
+ xt,
137
+ {
138
+ collection: e,
139
+ plan: h,
140
+ records: _,
141
+ draft: !!d,
142
+ preferredSurvivor: l,
143
+ onClose: s,
144
+ onMerged: m,
145
+ onStale: () => k.refetch(),
146
+ refreshing: k.isFetching,
147
+ onStep: v
148
+ }
149
+ )
150
+ ] });
151
+ }
152
+ function bt() {
153
+ return /* @__PURE__ */ r("div", { className: "flex-1 space-y-3 overflow-hidden p-6", "aria-busy": "true", children: [
154
+ /* @__PURE__ */ t("div", { className: "grid grid-cols-[12rem_1fr_1fr_1.2fr] gap-3", children: ["a", "b", "c", "d"].map((e) => /* @__PURE__ */ t(je, { className: "h-16 rounded-lg" }, e)) }),
155
+ ["1", "2", "3", "4", "5", "6", "7"].map((e) => /* @__PURE__ */ t("div", { className: "grid grid-cols-[12rem_1fr_1fr_1.2fr] gap-3", children: ["a", "b", "c", "d"].map((a) => /* @__PURE__ */ t(je, { className: "h-9 rounded-md" }, `${e}${a}`)) }, e))
156
+ ] });
157
+ }
158
+ function xt({
159
+ collection: e,
160
+ plan: a,
161
+ records: d,
162
+ draft: l,
163
+ preferredSurvivor: s,
164
+ onClose: m,
165
+ onMerged: o,
166
+ onStale: y,
167
+ onStep: v,
168
+ refreshing: k = !1
169
+ }) {
170
+ const h = ze(), _ = Xe(), x = lt(d, s), [f, w] = S(x), [u, i] = S(
171
+ () => it(d, x ?? "")
172
+ ), [R, E] = S(
173
+ () => ce(a, x ?? "", d)
174
+ ), [O, P] = S(() => /* @__PURE__ */ new Set()), [I, U] = S(
175
+ () => Object.fromEntries(a.relations.map((n) => [n.key, n.default]))
176
+ ), [pe, Ye] = S(!1), [Y, J] = S("choose");
177
+ he(() => v == null ? void 0 : v(Y), [Y, v]);
178
+ const [W, Z] = S(!1), [de, A] = S(null), [D, le] = S(
179
+ null
180
+ ), [V, ve] = S(null), [ke, we] = S(() => /* @__PURE__ */ new Set()), ye = Qe(d);
181
+ he(() => {
182
+ var Q;
183
+ const n = ye.current;
184
+ if (n === d) return;
185
+ ye.current = d;
186
+ const g = new Map(n.map((N) => [N.id, N])), c = /* @__PURE__ */ new Set();
187
+ for (const N of a.fields)
188
+ for (const T of d)
189
+ !T.draft && !Ie((Q = g.get(T.id)) == null ? void 0 : Q.values[N.field], T.values[N.field]) && c.add(`${T.id}${N.field}`);
190
+ we(c);
191
+ const C = a.fields.filter((N) => d.some((T) => c.has(`${T.id}${N.field}`))).map((N) => N.field);
192
+ if (C.length === 0) return;
193
+ const $ = ce(a, f ?? "", d);
194
+ E((N) => {
195
+ const T = { ...N };
196
+ for (const re of C) T[re] = $[re];
197
+ return T;
198
+ }), P((N) => {
199
+ const T = new Set(N);
200
+ for (const re of C) T.delete(re);
201
+ return T;
202
+ });
203
+ }, [d, a, f]);
204
+ const Ne = X(() => new Map(d.map((n) => [n.id, n])), [d]), $e = X(() => ot(a, d), [a, d]), B = d.filter((n) => u[n.id] === "discard"), j = B.filter((n) => !n.draft), _e = d.filter((n) => u[n.id] === "leave"), b = f ? Ne.get(f) : void 0, Ce = (n) => {
205
+ if (n === f) return;
206
+ const g = ce(a, n, d);
207
+ E((c) => {
208
+ const C = {};
209
+ for (const $ of a.fields)
210
+ C[$.field] = O.has($.field) && $.writable ? c[$.field] : g[$.field];
211
+ return C;
212
+ }), i((c) => {
213
+ const C = { ...c };
214
+ for (const $ of d)
215
+ $.id === n ? C[$.id] = "keep" : c[$.id] === "keep" && (C[$.id] = $.can_discard ? "discard" : "leave");
216
+ return C;
217
+ }), w(n);
218
+ }, Se = (n, g) => {
219
+ if (g === "keep") return Ce(n);
220
+ if (i((c) => ({ ...c, [n]: g })), g === "leave" && f) {
221
+ const c = d.find((C) => C.id === f);
222
+ E((C) => {
223
+ var Q;
224
+ const $ = { ...C };
225
+ for (const N of a.fields)
226
+ ((Q = $[N.field]) == null ? void 0 : Q.source) === n && ($[N.field] = { source: f, value: (c == null ? void 0 : c.values[N.field]) ?? null });
227
+ return $;
228
+ });
229
+ }
230
+ }, Be = (n, g) => {
231
+ E((c) => ({ ...c, [n]: g })), P((c) => new Set(c).add(n));
232
+ }, ee = X(
233
+ () => f ? ct(a, f, R, d) : {},
234
+ [a, f, R, d]
235
+ ), H = Object.keys(ee).length, M = a.relations.filter(
236
+ (n) => ge(
237
+ n,
238
+ j.map((g) => g.id)
239
+ ) > 0
240
+ ), te = M.filter((n) => I[n.key] === "move").reduce(
241
+ (n, g) => n + ge(
242
+ g,
243
+ j.map((c) => c.id)
244
+ ),
245
+ 0
246
+ ), ae = M.find((n) => I[n.key] === "move" && !n.movable), Me = j.filter((n) => n.partner), G = j.reduce((n, g) => n + g.open_approvals, 0), ie = B.length === 0, q = (() => {
247
+ if (!b || !ie) return null;
248
+ const n = d.filter((c) => !c.draft);
249
+ if (n.length !== 2) return null;
250
+ const g = n.find((c) => c.id !== b.id);
251
+ return !g || g.can_discard || !g.can_survive || !b.can_discard ? null : { keep: b, other: g };
252
+ })(), Re = !!b && !ie && !ae, Ee = a.fields.filter((n) => pe || $e.has(n.field)), oe = a.fields.length - $e.size, qe = async () => {
253
+ if (f) {
254
+ Z(!0), A(null);
255
+ try {
256
+ if (j.length === 0)
257
+ H > 0 && await h.request(
258
+ Ze(`/items/${e}/${encodeURIComponent(f)}`, ee)
259
+ ), le({ answer: null, undo: null }), o == null || o({ survivor: f, merge_id: null, discarded: [] });
260
+ else {
261
+ const n = {};
262
+ for (const c of M) n[c.key] = I[c.key] ?? c.default;
263
+ const g = await h.request(
264
+ Te(`/record-merge/${e}/apply`, {
265
+ survivor: f,
266
+ discard: j.map((c) => c.id),
267
+ keep: _e.filter((c) => !c.draft).map((c) => c.id),
268
+ values: ee,
269
+ relations: n,
270
+ // A record changed since this screen read it is refused (409 MERGE_STALE).
271
+ stamps: Object.fromEntries(
272
+ d.filter((c) => !c.draft && c.stamp).map((c) => [c.id, c.stamp])
273
+ ),
274
+ opened_at: a.read_at
275
+ })
276
+ );
277
+ le({ answer: g.data, undo: null }), o == null || o({ survivor: f, merge_id: g.data.merge_id, discarded: g.data.discarded });
278
+ }
279
+ J("done"), ve(null), we(/* @__PURE__ */ new Set());
280
+ } catch (n) {
281
+ const g = gt(n);
282
+ (g == null ? void 0 : g.code) === "MERGE_STALE" ? (ve({ who: g.changedBy, record: g.record, message: g.message }), J("choose"), await y()) : A(n);
283
+ } finally {
284
+ Z(!1);
285
+ }
286
+ }
287
+ }, Pe = async () => {
288
+ if (D != null && D.answer) {
289
+ Z(!0), A(null);
290
+ try {
291
+ const n = await h.request(
292
+ Te(`/record-merge/undo/${D.answer.merge_id}`, {})
293
+ );
294
+ le({ ...D, undo: n.data }), o == null || o({ survivor: D.answer.survivor, merge_id: null, discarded: [] });
295
+ } catch (n) {
296
+ A(n);
297
+ } finally {
298
+ Z(!1);
299
+ }
300
+ }
301
+ };
302
+ return Y === "done" && b ? /* @__PURE__ */ t(
303
+ Rt,
304
+ {
305
+ keep: b,
306
+ discarded: j,
307
+ answer: (D == null ? void 0 : D.answer) ?? null,
308
+ undone: (D == null ? void 0 : D.undo) ?? null,
309
+ busy: W,
310
+ error: de,
311
+ noun: a.noun,
312
+ draft: l,
313
+ onUndo: () => void Pe(),
314
+ onOpen: (n) => {
315
+ m(), _.open({ collection: e, itemId: n });
316
+ },
317
+ onClose: m
318
+ }
319
+ ) : /* @__PURE__ */ r(me, { children: [
320
+ /* @__PURE__ */ t("div", { className: "min-h-0 flex-1 overflow-auto overscroll-contain", "data-merge-step": Y, children: Y === "choose" ? /* @__PURE__ */ r("div", { className: "px-6 pb-8 max-sm:px-4", "data-merge-grid": !0, children: [
321
+ V && /* @__PURE__ */ t(
322
+ pt,
323
+ {
324
+ stale: V,
325
+ record: d.find((n) => n.id === V.record) ?? null,
326
+ fields: a.fields.filter((n) => ke.has(`${V.record}${n.field}`)).map((n) => n.label),
327
+ refreshing: k
328
+ }
329
+ ),
330
+ /* @__PURE__ */ t(
331
+ vt,
332
+ {
333
+ records: d,
334
+ roles: u,
335
+ onRole: Se,
336
+ resultLabel: b ? z(b) : null
337
+ }
338
+ ),
339
+ Ee.length === 0 && /* @__PURE__ */ t("p", { className: "py-8 text-center text-[13px] text-slate-500 dark:text-muted-foreground", children: "Every field holds the same value in all of these records." }),
340
+ /* @__PURE__ */ t("div", { className: "divide-y divide-slate-100 dark:divide-border", children: Ee.map((n) => /* @__PURE__ */ t(
341
+ $t,
342
+ {
343
+ field: n,
344
+ records: d,
345
+ roles: u,
346
+ survivor: f,
347
+ pickValue: R[n.field],
348
+ labels: a.labels[n.field],
349
+ onPick: (g) => Be(n.field, g),
350
+ changed: ke
351
+ },
352
+ n.field
353
+ )) }),
354
+ oe > 0 && /* @__PURE__ */ t(
355
+ "button",
356
+ {
357
+ type: "button",
358
+ onClick: () => Ye((n) => !n),
359
+ className: "mt-3 rounded-sm text-[12px] font-medium text-slate-500 underline decoration-slate-300 underline-offset-4 hover:text-slate-800 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan dark:text-muted-foreground dark:decoration-border dark:hover:text-foreground",
360
+ "data-merge-show-same": !0,
361
+ children: pe ? "Hide the fields that are the same" : `Show ${L(oe, "field")} that ${oe === 1 ? "is" : "are"} the same in every record`
362
+ }
363
+ ),
364
+ M.length > 0 && /* @__PURE__ */ t(
365
+ Ct,
366
+ {
367
+ relations: M,
368
+ discarded: j,
369
+ moves: I,
370
+ onMove: (n, g) => U((c) => ({ ...c, [n]: g })),
371
+ keepLabel: b ? z(b) : "the kept record",
372
+ keepRef: b ? p(b) : "the kept record"
373
+ }
374
+ ),
375
+ (G > 0 || j.some((n) => n.open_tasks > 0)) && /* @__PURE__ */ r("p", { className: "mt-4 max-w-[72ch] text-[12px] leading-relaxed text-slate-500 dark:text-muted-foreground", children: [
376
+ G > 0 && `${L(G, "open approval")} on the discarded records ${G === 1 ? "is" : "are"} closed with a merge note. `,
377
+ (b == null ? void 0 : b.state) && `${p(b)} stays at ${b.state.label}.`
378
+ ] })
379
+ ] }) : /* @__PURE__ */ t(
380
+ St,
381
+ {
382
+ plan: a,
383
+ keep: b,
384
+ discarded: B,
385
+ leftAlone: _e,
386
+ changes: ee,
387
+ picks: R,
388
+ byId: Ne,
389
+ relations: M,
390
+ moves: I,
391
+ partnerWarnings: Me,
392
+ openApprovals: G,
393
+ draft: l
394
+ }
395
+ ) }),
396
+ /* @__PURE__ */ r("footer", { className: "shrink-0 border-t border-slate-200 bg-slate-50/80 px-6 py-3 dark:border-border dark:bg-muted/30 max-sm:px-4", children: [
397
+ de != null && /* @__PURE__ */ t(xe, { error: de, fallback: "Could not merge", className: "mb-3" }),
398
+ /* @__PURE__ */ r("div", { className: "flex flex-wrap items-center gap-x-4 gap-y-2", children: [
399
+ /* @__PURE__ */ t(
400
+ "p",
401
+ {
402
+ className: "min-w-0 flex-1 text-[12.5px] text-slate-600 dark:text-muted-foreground max-sm:basis-full",
403
+ "aria-live": "polite",
404
+ children: b ? ie ? q ? /* @__PURE__ */ r("span", { className: "flex flex-wrap items-center gap-x-2 gap-y-1", children: [
405
+ /* @__PURE__ */ r("span", { children: [
406
+ q.other.ref,
407
+ " cannot be discarded."
408
+ ] }),
409
+ /* @__PURE__ */ r(
410
+ "button",
411
+ {
412
+ type: "button",
413
+ onClick: () => {
414
+ Ce(q.other.id), Se(q.keep.id, "discard");
415
+ },
416
+ className: "font-medium text-nvr-cyan-dark underline decoration-nvr-cyan/40 underline-offset-2 hover:decoration-nvr-cyan focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan dark:text-nvr-cyan",
417
+ "data-merge-swap": !0,
418
+ children: [
419
+ "Keep ",
420
+ q.other.ref,
421
+ " instead and discard ",
422
+ q.keep.ref
423
+ ]
424
+ }
425
+ )
426
+ ] }) : "Choose at least one record to discard." : ae ? /* @__PURE__ */ r("span", { className: "text-amber-700 dark:text-amber-400", children: [
427
+ ae.label,
428
+ ": ",
429
+ ae.reason
430
+ ] }) : /* @__PURE__ */ r(me, { children: [
431
+ /* @__PURE__ */ r("span", { className: "sm:hidden", children: [
432
+ "Keep",
433
+ " ",
434
+ /* @__PURE__ */ t("strong", { className: "font-medium text-slate-900 dark:text-foreground", children: p(b) }),
435
+ ` · discard ${B.length} · ${H === 0 ? "no changes" : L(H, "change")}`,
436
+ te > 0 && ` · ${L(te, "row")} move`
437
+ ] }),
438
+ /* @__PURE__ */ r("span", { className: "max-sm:hidden", children: [
439
+ "Keep",
440
+ " ",
441
+ /* @__PURE__ */ t("strong", { className: "font-medium text-slate-900 dark:text-foreground", children: p(b) }),
442
+ " · ",
443
+ "discard ",
444
+ B.length,
445
+ " · ",
446
+ H === 0 ? "no field changes" : `${L(H, "field")} change`,
447
+ te > 0 && ` · ${L(te, "linked row")} move`
448
+ ] })
449
+ ] }) : "Choose the record to keep."
450
+ }
451
+ ),
452
+ /* @__PURE__ */ r("div", { className: "flex items-center gap-2 max-sm:ml-auto", children: [
453
+ Y === "review" ? /* @__PURE__ */ t(
454
+ K,
455
+ {
456
+ type: "button",
457
+ variant: "outline",
458
+ size: "sm",
459
+ className: "dark:bg-transparent",
460
+ onClick: () => J("choose"),
461
+ disabled: W,
462
+ children: "Back"
463
+ }
464
+ ) : /* @__PURE__ */ t(K, { type: "button", variant: "ghost", size: "sm", onClick: m, children: "Cancel" }),
465
+ Y === "choose" ? /* @__PURE__ */ r(
466
+ K,
467
+ {
468
+ type: "button",
469
+ size: "sm",
470
+ className: "gap-1.5 bg-nvr-cyan text-white hover:bg-nvr-cyan-dark disabled:bg-slate-200 disabled:text-slate-500 disabled:opacity-100 dark:disabled:bg-transparent dark:disabled:text-slate-500 dark:disabled:ring-1 dark:disabled:ring-inset dark:disabled:ring-slate-700 dark:disabled:opacity-50",
471
+ disabled: !Re,
472
+ onClick: () => {
473
+ A(null), J("review");
474
+ },
475
+ "data-merge-review": !0,
476
+ children: [
477
+ "Review merge",
478
+ /* @__PURE__ */ t(We, { className: "h-3.5 w-3.5", "aria-hidden": !0 })
479
+ ]
480
+ }
481
+ ) : /* @__PURE__ */ r(
482
+ K,
483
+ {
484
+ type: "button",
485
+ size: "sm",
486
+ className: "gap-1.5 bg-nvr-cyan text-white hover:bg-nvr-cyan-dark disabled:bg-slate-200 disabled:text-slate-500 disabled:opacity-100 dark:disabled:bg-transparent dark:disabled:text-slate-500 dark:disabled:ring-1 dark:disabled:ring-inset dark:disabled:ring-slate-700 dark:disabled:opacity-50",
487
+ disabled: W || !Re,
488
+ onClick: () => void qe(),
489
+ "data-merge-apply": !0,
490
+ children: [
491
+ W ? /* @__PURE__ */ t(fe, { className: "h-3.5 w-3.5 animate-spin", "aria-hidden": !0 }) : /* @__PURE__ */ t(Fe, { className: "h-3.5 w-3.5", "aria-hidden": !0 }),
492
+ W ? "Merging…" : j.length === 0 ? `Save into ${(b == null ? void 0 : b.label) ?? "the record"}` : `Merge ${B.length + 1} ${a.plural}`
493
+ ]
494
+ }
495
+ )
496
+ ] })
497
+ ] })
498
+ ] })
499
+ ] });
500
+ }
501
+ function pt({
502
+ stale: e,
503
+ record: a,
504
+ fields: d,
505
+ refreshing: l
506
+ }) {
507
+ return /* @__PURE__ */ r(
508
+ "div",
509
+ {
510
+ className: "mt-4 flex gap-2.5 rounded-lg border border-amber-200 bg-amber-50 px-3.5 py-3 text-[12.5px] leading-relaxed text-amber-900 dark:border-amber-500/30 dark:bg-amber-500/10 dark:text-amber-100",
511
+ role: "status",
512
+ "data-merge-stale": !0,
513
+ children: [
514
+ /* @__PURE__ */ t(
515
+ ne,
516
+ {
517
+ className: "mt-0.5 h-4 w-4 shrink-0 text-amber-600 dark:text-amber-400",
518
+ "aria-hidden": !0
519
+ }
520
+ ),
521
+ /* @__PURE__ */ r("div", { className: "min-w-0", children: [
522
+ a ? /* @__PURE__ */ r("p", { children: [
523
+ /* @__PURE__ */ t("strong", { className: "font-semibold", children: e.who ?? "Someone" }),
524
+ " changed",
525
+ " ",
526
+ /* @__PURE__ */ t("strong", { className: "font-semibold", children: z(a) }),
527
+ d.length > 0 && ` (${d.join(", ")})`,
528
+ " while you were merging."
529
+ ] }) : /* @__PURE__ */ t("p", { children: e.message }),
530
+ /* @__PURE__ */ t("p", { className: "mt-0.5 text-amber-800/90 dark:text-amber-200/80", children: l ? /* @__PURE__ */ r("span", { className: "inline-flex items-center gap-1.5", children: [
531
+ /* @__PURE__ */ t(fe, { className: "h-3 w-3 animate-spin", "aria-hidden": !0 }),
532
+ "Reading the records again…"
533
+ ] }) : "The columns now show it as it is — changed values are marked. Your choices are kept wherever that field did not change; review them and merge again." })
534
+ ] })
535
+ ]
536
+ }
537
+ );
538
+ }
539
+ const Ke = (e) => ({
540
+ gridTemplateColumns: `minmax(8.5rem, 12rem) repeat(${e}, minmax(10rem, 1fr)) minmax(13rem, 1.25fr)`
541
+ });
542
+ function vt({
543
+ records: e,
544
+ roles: a,
545
+ onRole: d,
546
+ resultLabel: l
547
+ }) {
548
+ return /* @__PURE__ */ r(
549
+ "div",
550
+ {
551
+ className: "z-10 -mx-6 mb-1 md:sticky md:top-0 border-b border-slate-200 bg-white/95 px-6 pb-3 pt-4 backdrop-blur-sm dark:border-border dark:bg-card/95 max-sm:-mx-4 max-sm:px-4",
552
+ "data-merge-headers": !0,
553
+ children: [
554
+ /* @__PURE__ */ r("div", { className: "hidden gap-3 md:grid", style: Ke(e.length), children: [
555
+ /* @__PURE__ */ t("div", {}),
556
+ e.map((s) => /* @__PURE__ */ t(Le, { record: s, role: a[s.id], onRole: (m) => d(s.id, m) }, s.id)),
557
+ /* @__PURE__ */ r("div", { className: "flex min-w-0 flex-col justify-start self-stretch rounded-lg border border-nvr-cyan/30 bg-nvr-cyan/[0.06] px-3 py-2", children: [
558
+ /* @__PURE__ */ t("span", { className: "text-[12.5px] font-semibold text-slate-900 dark:text-foreground", children: "Result" }),
559
+ /* @__PURE__ */ t("span", { className: "truncate text-[11.5px] text-slate-500 dark:text-muted-foreground", children: l ? `${l} after the merge` : "Choose a record to keep" })
560
+ ] })
561
+ ] }),
562
+ /* @__PURE__ */ t("div", { className: "space-y-2 md:hidden", children: e.map((s) => /* @__PURE__ */ t(Le, { record: s, role: a[s.id], onRole: (m) => d(s.id, m) }, s.id)) })
563
+ ]
564
+ }
565
+ );
566
+ }
567
+ const kt = {
568
+ keep: "Keep",
569
+ discard: "Discard",
570
+ leave: "Not in this merge"
571
+ };
572
+ function Le({
573
+ record: e,
574
+ role: a,
575
+ onRole: d
576
+ }) {
577
+ const l = [
578
+ { role: "keep", disabled: e.can_survive ? null : e.survive_reason },
579
+ {
580
+ role: "discard",
581
+ disabled: e.draft || e.can_discard ? null : e.discard_reason
582
+ },
583
+ {
584
+ role: "leave",
585
+ disabled: e.draft ? "It is not saved yet — it is never kept." : null
586
+ }
587
+ ];
588
+ return /* @__PURE__ */ r(
589
+ "div",
590
+ {
591
+ className: F(
592
+ "min-w-0 rounded-lg border px-3 py-2 transition-colors",
593
+ a === "keep" ? "border-nvr-cyan/50 bg-white shadow-[0_1px_2px_rgba(15,23,42,0.06)] dark:bg-card" : a === "discard" ? "border-dashed border-slate-300 bg-slate-50 dark:border-border dark:bg-muted/40" : "border-dashed border-slate-200 bg-slate-50/60 dark:border-border dark:bg-muted/20"
594
+ ),
595
+ "data-merge-record": e.id,
596
+ "data-merge-role": a,
597
+ children: [
598
+ /* @__PURE__ */ r("div", { className: "flex min-w-0 items-baseline gap-2", children: [
599
+ /* @__PURE__ */ t(
600
+ "span",
601
+ {
602
+ className: F(
603
+ "shrink-0 text-[13px] font-semibold tabular-nums",
604
+ a === "discard" && !e.draft ? "text-slate-500 line-through decoration-slate-300 dark:text-muted-foreground dark:decoration-border" : "text-slate-900 dark:text-foreground"
605
+ ),
606
+ children: p(e)
607
+ }
608
+ ),
609
+ /* @__PURE__ */ t(
610
+ "span",
611
+ {
612
+ className: "min-w-0 truncate text-[12.5px] text-slate-600 dark:text-muted-foreground",
613
+ title: e.label,
614
+ children: e.label
615
+ }
616
+ )
617
+ ] }),
618
+ (e.created_at || e.state || e.draft) && /* @__PURE__ */ r("div", { className: "mt-0.5 flex min-w-0 items-center gap-2 text-[11px] text-slate-500 dark:text-muted-foreground", children: [
619
+ e.draft && /* @__PURE__ */ t("span", { className: "shrink-0 rounded bg-amber-100 px-1.5 text-[10.5px] font-medium leading-4 text-amber-800 dark:bg-amber-500/15 dark:text-amber-300", children: "Not saved" }),
620
+ e.created_at && /* @__PURE__ */ r("span", { className: "tabular-nums", children: [
621
+ "Created ",
622
+ Ve(e.created_at)
623
+ ] }),
624
+ e.state && /* @__PURE__ */ r("span", { className: "inline-flex min-w-0 shrink items-center gap-1", children: [
625
+ /* @__PURE__ */ t(
626
+ "span",
627
+ {
628
+ className: "h-1.5 w-1.5 shrink-0 rounded-full",
629
+ style: { background: e.state.color ?? "#94a3b8" },
630
+ "aria-hidden": !0
631
+ }
632
+ ),
633
+ /* @__PURE__ */ t("span", { className: "truncate", children: e.state.label })
634
+ ] })
635
+ ] }),
636
+ /* @__PURE__ */ t(
637
+ "div",
638
+ {
639
+ role: "radiogroup",
640
+ "aria-label": `What happens to ${e.label}`,
641
+ className: "mt-2 inline-flex max-w-full rounded-md border border-slate-200 bg-slate-100/70 p-0.5 dark:border-border dark:bg-muted/60",
642
+ children: l.map((s) => {
643
+ const m = a === s.role;
644
+ return (
645
+ // biome-ignore lint/a11y/useSemanticElements: a segmented choice drawn as buttons, not a form input
646
+ /* @__PURE__ */ t(
647
+ "button",
648
+ {
649
+ type: "button",
650
+ role: "radio",
651
+ "aria-checked": m,
652
+ disabled: !!s.disabled,
653
+ "data-tip": s.disabled ?? void 0,
654
+ onClick: () => d(s.role),
655
+ className: F(
656
+ "h-6 whitespace-nowrap rounded px-2 text-[11.5px] font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan disabled:cursor-not-allowed disabled:opacity-40",
657
+ m ? s.role === "keep" ? "bg-nvr-cyan text-white shadow-sm" : s.role === "discard" ? "bg-white text-red-700 shadow-sm dark:bg-card dark:text-red-400" : "bg-white text-slate-900 shadow-sm dark:bg-card dark:text-foreground" : "text-slate-600 hover:text-slate-900 dark:text-muted-foreground dark:hover:text-foreground"
658
+ ),
659
+ children: kt[s.role]
660
+ },
661
+ s.role
662
+ )
663
+ );
664
+ })
665
+ }
666
+ ),
667
+ a === "discard" && e.partner && /* @__PURE__ */ r("p", { className: "mt-1.5 flex gap-1 text-[11px] leading-snug text-amber-700 dark:text-amber-400", children: [
668
+ /* @__PURE__ */ t(ne, { className: "mt-px h-3 w-3 shrink-0", "aria-hidden": !0 }),
669
+ e.partner.warning
670
+ ] }),
671
+ a !== "discard" && !e.draft && [
672
+ ...new Set(
673
+ [
674
+ e.can_survive ? null : e.survive_reason,
675
+ e.can_discard ? null : e.discard_reason
676
+ ].filter((s) => !!s)
677
+ )
678
+ ].map((s) => /* @__PURE__ */ r(
679
+ "p",
680
+ {
681
+ className: "mt-1.5 flex gap-1 text-[11px] leading-snug text-slate-500 dark:text-muted-foreground",
682
+ "data-merge-record-reason": !0,
683
+ children: [
684
+ /* @__PURE__ */ t(be, { className: "mt-px h-3 w-3 shrink-0", "aria-hidden": !0 }),
685
+ s
686
+ ]
687
+ },
688
+ s
689
+ ))
690
+ ]
691
+ }
692
+ );
693
+ }
694
+ const wt = /* @__PURE__ */ new Set(["string", "text", "uuid", "csv"]), yt = /* @__PURE__ */ new Set(["integer", "bigInteger", "float", "decimal"]);
695
+ function Nt(e) {
696
+ var a;
697
+ return !e.writable || e.relation ? null : (a = e.choices) != null && a.length ? /multiple|checkbox|tags/.test(e.interface ?? "") ? null : "choice" : yt.has(e.type) ? "number" : e.type === "date" ? "date" : e.type === "text" || /textarea|markdown|code|multiline/.test(e.interface ?? "") ? "long" : wt.has(e.type) ? "text" : null;
698
+ }
699
+ function $t({
700
+ field: e,
701
+ records: a,
702
+ roles: d,
703
+ survivor: l,
704
+ pickValue: s,
705
+ labels: m,
706
+ onPick: o,
707
+ changed: y
708
+ }) {
709
+ const [v, k] = S(!1), h = a.filter((i) => d[i.id] !== "leave").map((i) => i.values[e.field]), _ = X(() => mt(e, h), [e, h]), x = e.writable && _ != null && !h.some((i) => Ie(i, _)), f = Nt(e), w = s == null ? void 0 : s.value, u = (s == null ? void 0 : s.source) === "combined" ? "Combined" : (s == null ? void 0 : s.source) === "custom" ? "Typed" : (() => {
710
+ const i = a.find((R) => R.id === (s == null ? void 0 : s.source));
711
+ return i ? p(i) : void 0;
712
+ })();
713
+ return he(() => {
714
+ (s == null ? void 0 : s.source) !== "custom" && k(!1);
715
+ }, [s == null ? void 0 : s.source]), /* @__PURE__ */ r(
716
+ "div",
717
+ {
718
+ className: "grid gap-x-3 gap-y-1.5 py-2.5 max-md:!grid-cols-1",
719
+ style: Ke(a.length),
720
+ "data-merge-field": e.field,
721
+ children: [
722
+ /* @__PURE__ */ r("div", { className: "flex min-w-0 items-start gap-1.5 pt-1.5", children: [
723
+ /* @__PURE__ */ t("span", { className: "text-[12.5px] font-medium text-slate-700 dark:text-foreground/90", children: e.label }),
724
+ !e.writable && /* @__PURE__ */ t(
725
+ be,
726
+ {
727
+ className: "mt-0.5 h-3 w-3 shrink-0 text-slate-400",
728
+ "aria-label": "You cannot change this field",
729
+ "data-tip": "You cannot change this field — the kept record’s value stays."
730
+ }
731
+ )
732
+ ] }),
733
+ a.map((i) => {
734
+ const R = i.values[e.field], E = se(e, R, m), O = (s == null ? void 0 : s.source) === i.id, P = d[i.id] === "leave", I = P || !e.writable && i.id !== l, U = !!(y != null && y.has(`${i.id}${e.field}`));
735
+ return (
736
+ // biome-ignore lint/a11y/useSemanticElements: a segmented choice drawn as buttons, not a form input
737
+ /* @__PURE__ */ r(
738
+ "button",
739
+ {
740
+ type: "button",
741
+ role: "radio",
742
+ "aria-checked": O,
743
+ "aria-label": `${e.label} from ${p(i)}: ${E ?? "empty"}${U ? " (changed)" : ""}`,
744
+ disabled: I,
745
+ onClick: () => o({ source: i.id, value: R ?? null }),
746
+ className: F(
747
+ "group relative flex min-w-0 items-start gap-2 rounded-md border px-2.5 py-1.5 text-left text-[12.5px] transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan disabled:cursor-default",
748
+ O ? "border-nvr-cyan bg-nvr-cyan/[0.07] text-slate-900 dark:text-foreground" : "border-slate-200 bg-white text-slate-700 hover:border-slate-300 hover:bg-slate-50 dark:border-border dark:bg-card dark:text-foreground/85 dark:hover:border-slate-500 dark:hover:bg-muted/50",
749
+ d[i.id] === "discard" && !O && "opacity-80",
750
+ I && "opacity-60 hover:border-slate-200 hover:bg-white dark:hover:border-border dark:hover:bg-card",
751
+ P && "border-dashed opacity-40",
752
+ U && "ring-2 ring-amber-400/70 dark:ring-amber-400/60"
753
+ ),
754
+ "data-merge-cell": i.id,
755
+ children: [
756
+ /* @__PURE__ */ t(
757
+ "span",
758
+ {
759
+ className: F(
760
+ "mt-0.5 flex h-3.5 w-3.5 shrink-0 items-center justify-center rounded-full border",
761
+ O ? "border-nvr-cyan bg-nvr-cyan text-white" : "border-slate-400 bg-white dark:border-slate-400 dark:bg-card"
762
+ ),
763
+ "aria-hidden": !0,
764
+ children: O && /* @__PURE__ */ t(De, { className: "h-2.5 w-2.5", strokeWidth: 3 })
765
+ }
766
+ ),
767
+ /* @__PURE__ */ r("span", { className: "min-w-0 flex-1", children: [
768
+ /* @__PURE__ */ t("span", { className: "mb-0.5 block text-[10.5px] font-medium text-slate-400 md:hidden", children: p(i) }),
769
+ E == null ? /* @__PURE__ */ t("span", { className: "text-slate-400 dark:text-muted-foreground/70", children: "Empty" }) : /* @__PURE__ */ t("span", { className: "line-clamp-3 whitespace-pre-line break-words", children: E })
770
+ ] }),
771
+ U && /* @__PURE__ */ t("span", { className: "shrink-0 rounded bg-amber-100 px-1.5 py-px text-[10.5px] font-medium text-amber-800 dark:bg-amber-500/15 dark:text-amber-300", children: "Changed" })
772
+ ]
773
+ },
774
+ i.id
775
+ )
776
+ );
777
+ }),
778
+ /* @__PURE__ */ r(
779
+ "div",
780
+ {
781
+ className: "min-w-0 rounded-md border border-nvr-cyan/25 bg-nvr-cyan/[0.04] px-2.5 py-1.5",
782
+ "data-merge-result": e.field,
783
+ children: [
784
+ /* @__PURE__ */ t("span", { className: "mb-0.5 block text-[10.5px] font-medium text-slate-400 md:hidden", children: "Result" }),
785
+ v && f ? /* @__PURE__ */ t(
786
+ _t,
787
+ {
788
+ kind: f,
789
+ field: e,
790
+ value: w,
791
+ onChange: (i) => o({ source: "custom", value: i })
792
+ }
793
+ ) : /* @__PURE__ */ t("div", { className: "text-[12.5px] text-slate-900 dark:text-foreground", children: ut(w) ? /* @__PURE__ */ t("span", { className: "text-slate-400 dark:text-muted-foreground/70", children: "Empty" }) : /* @__PURE__ */ t("span", { className: "line-clamp-4 whitespace-pre-line break-words", children: se(e, w, m) }) }),
794
+ /* @__PURE__ */ r("div", { className: "mt-1 flex flex-wrap items-center gap-x-2 gap-y-1", children: [
795
+ u && /* @__PURE__ */ t("span", { className: "truncate text-[11px] text-slate-500 dark:text-muted-foreground", children: (s == null ? void 0 : s.source) === "combined" || (s == null ? void 0 : s.source) === "custom" ? u : `From ${u}` }),
796
+ /* @__PURE__ */ r("span", { className: "ml-auto flex items-center gap-1", children: [
797
+ x && (s == null ? void 0 : s.source) !== "combined" && /* @__PURE__ */ r(
798
+ "button",
799
+ {
800
+ type: "button",
801
+ onClick: () => o({ source: "combined", value: _ }),
802
+ className: "inline-flex h-6 items-center gap-1 rounded px-1.5 text-[11.5px] font-medium text-nvr-cyan-dark hover:bg-nvr-cyan/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan dark:text-nvr-cyan",
803
+ "data-merge-combine": e.field,
804
+ children: [
805
+ /* @__PURE__ */ t(He, { className: "h-3 w-3", "aria-hidden": !0 }),
806
+ "Combine"
807
+ ]
808
+ }
809
+ ),
810
+ f && /* @__PURE__ */ r(
811
+ "button",
812
+ {
813
+ type: "button",
814
+ onClick: () => {
815
+ v || o({ source: "custom", value: w ?? null }), k((i) => !i);
816
+ },
817
+ className: "inline-flex h-6 items-center gap-1 rounded px-1.5 text-[11.5px] font-medium text-slate-600 hover:bg-slate-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan dark:text-muted-foreground dark:hover:bg-muted",
818
+ "data-merge-edit": e.field,
819
+ children: [
820
+ v ? /* @__PURE__ */ t(De, { className: "h-3 w-3", "aria-hidden": !0 }) : /* @__PURE__ */ t(Ge, { className: "h-3 w-3", "aria-hidden": !0 }),
821
+ v ? "Done" : "Edit"
822
+ ]
823
+ }
824
+ )
825
+ ] })
826
+ ] })
827
+ ]
828
+ }
829
+ )
830
+ ]
831
+ }
832
+ );
833
+ }
834
+ function _t({
835
+ kind: e,
836
+ field: a,
837
+ value: d,
838
+ onChange: l
839
+ }) {
840
+ const s = d == null ? "" : String(d);
841
+ return e === "choice" ? /* @__PURE__ */ t(
842
+ nt,
843
+ {
844
+ value: s,
845
+ onChange: (m) => l(m === "" ? null : m),
846
+ ariaLabel: a.label,
847
+ options: [
848
+ { value: "", label: "Empty" },
849
+ ...(a.choices ?? []).map((m) => ({ value: String(m.value), label: m.text }))
850
+ ],
851
+ className: "h-8 text-[12.5px]"
852
+ }
853
+ ) : e === "long" ? /* @__PURE__ */ t(
854
+ dt,
855
+ {
856
+ autoFocus: !0,
857
+ value: s,
858
+ onChange: (m) => l(m.target.value === "" ? null : m.target.value),
859
+ "aria-label": a.label,
860
+ className: "min-h-[84px] bg-white text-[12.5px] dark:bg-background"
861
+ }
862
+ ) : /* @__PURE__ */ t(
863
+ st,
864
+ {
865
+ autoFocus: !0,
866
+ type: e === "number" ? "number" : e === "date" ? "date" : "text",
867
+ value: e === "date" ? s.slice(0, 10) : s,
868
+ onChange: (m) => {
869
+ const o = m.target.value;
870
+ if (o === "") return l(null);
871
+ l(e === "number" ? Number(o) : o);
872
+ },
873
+ "aria-label": a.label,
874
+ className: "h-8 bg-white text-[12.5px] dark:bg-background"
875
+ }
876
+ );
877
+ }
878
+ function Oe(e, a) {
879
+ return e.kind === "m2m" || e.kind === "files" ? `Keep only ${a}’s ${e.label.toLowerCase()}` : e.leave_word;
880
+ }
881
+ function Ct({
882
+ relations: e,
883
+ discarded: a,
884
+ moves: d,
885
+ onMove: l,
886
+ keepLabel: s,
887
+ keepRef: m
888
+ }) {
889
+ return /* @__PURE__ */ r("section", { className: "mt-8", "data-merge-relations": !0, children: [
890
+ /* @__PURE__ */ r("h3", { className: "text-[13.5px] font-semibold text-slate-900 dark:text-foreground", children: [
891
+ "Linked to the discarded ",
892
+ a.length === 1 ? "record" : "records"
893
+ ] }),
894
+ /* @__PURE__ */ r("p", { className: "mt-0.5 max-w-[72ch] text-[12px] text-slate-500 dark:text-muted-foreground", children: [
895
+ "Move them to ",
896
+ s,
897
+ " so nothing is lost, or leave them with the record that goes to the trash."
898
+ ] }),
899
+ /* @__PURE__ */ t("div", { className: "mt-3 overflow-hidden rounded-lg border border-slate-200 dark:border-border", children: e.map((o, y) => {
900
+ const v = d[o.key] ?? o.default, k = a.map((h) => ({ d: h, n: (o.counts[h.id] ?? 0) + (o.hidden[h.id] ?? 0) })).filter((h) => h.n > 0);
901
+ return /* @__PURE__ */ r(
902
+ "div",
903
+ {
904
+ className: F(
905
+ "flex flex-wrap items-center gap-x-4 gap-y-2 px-3 py-2.5",
906
+ y > 0 && "border-t border-slate-100 dark:border-border"
907
+ ),
908
+ "data-merge-relation": o.key,
909
+ children: [
910
+ /* @__PURE__ */ r("div", { className: "min-w-[12rem] flex-1", children: [
911
+ /* @__PURE__ */ t("div", { className: "text-[12.5px] font-medium text-slate-800 dark:text-foreground", children: o.label }),
912
+ /* @__PURE__ */ t("div", { className: "text-[11.5px] tabular-nums text-slate-500 dark:text-muted-foreground", children: k.map((h) => `${h.n.toLocaleString()} on ${p(h.d)}`).join(" · ") }),
913
+ o.reason && /* @__PURE__ */ r(
914
+ "div",
915
+ {
916
+ className: F(
917
+ "mt-0.5 flex gap-1 text-[11.5px]",
918
+ o.movable ? "text-slate-500 dark:text-muted-foreground" : "text-amber-700 dark:text-amber-400"
919
+ ),
920
+ children: [
921
+ /* @__PURE__ */ t(be, { className: "mt-0.5 h-3 w-3 shrink-0", "aria-hidden": !0 }),
922
+ o.reason
923
+ ]
924
+ }
925
+ )
926
+ ] }),
927
+ /* @__PURE__ */ t(
928
+ "div",
929
+ {
930
+ role: "radiogroup",
931
+ "aria-label": o.label,
932
+ className: "grid w-full grid-cols-2 rounded-md border border-slate-200 bg-slate-100/70 p-0.5 dark:border-border dark:bg-muted/60 sm:w-[28rem]",
933
+ children: ["move", "leave"].map((h) => {
934
+ const _ = v === h, x = h === "move" && !o.movable;
935
+ return (
936
+ // biome-ignore lint/a11y/useSemanticElements: a segmented choice drawn as buttons, not a form input
937
+ /* @__PURE__ */ t(
938
+ "button",
939
+ {
940
+ type: "button",
941
+ role: "radio",
942
+ "aria-checked": _,
943
+ disabled: x,
944
+ onClick: () => l(o.key, h),
945
+ className: F(
946
+ "min-h-7 truncate rounded px-2.5 py-1 text-[12px] font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan disabled:cursor-not-allowed disabled:opacity-40",
947
+ _ ? "bg-white font-semibold text-slate-900 shadow-sm ring-1 ring-slate-300 dark:bg-slate-700 dark:text-white dark:ring-slate-500" : "text-slate-600 hover:text-slate-900 dark:text-muted-foreground dark:hover:text-foreground"
948
+ ),
949
+ children: h === "move" ? o.move_word : Oe(o, m)
950
+ },
951
+ h
952
+ )
953
+ );
954
+ })
955
+ }
956
+ )
957
+ ]
958
+ },
959
+ o.key
960
+ );
961
+ }) })
962
+ ] });
963
+ }
964
+ function St({
965
+ plan: e,
966
+ keep: a,
967
+ discarded: d,
968
+ leftAlone: l,
969
+ changes: s,
970
+ picks: m,
971
+ byId: o,
972
+ relations: y,
973
+ moves: v,
974
+ partnerWarnings: k,
975
+ openApprovals: h,
976
+ draft: _
977
+ }) {
978
+ if (!a) return null;
979
+ const x = e.fields.filter((u) => u.field in s), f = d.filter((u) => !u.draft), w = (u) => u.map((i) => z(i)).join(", ");
980
+ return /* @__PURE__ */ r("div", { className: "space-y-6 px-6 py-6 max-sm:px-4", "data-merge-review-view": !0, children: [
981
+ /* @__PURE__ */ r("ul", { className: "space-y-2.5 text-[13px] leading-relaxed text-slate-700 dark:text-foreground/90", children: [
982
+ /* @__PURE__ */ r("li", { className: "flex gap-2.5", children: [
983
+ /* @__PURE__ */ t("span", { className: "mt-1.5 h-2 w-2 shrink-0 rounded-full bg-nvr-cyan", "aria-hidden": !0 }),
984
+ /* @__PURE__ */ r("span", { children: [
985
+ /* @__PURE__ */ r("strong", { className: "font-semibold text-slate-900 dark:text-foreground", children: [
986
+ "Keep ",
987
+ z(a)
988
+ ] }),
989
+ " — ",
990
+ "it keeps its number and history",
991
+ a.state ? `, and stays at ${a.state.label}` : "",
992
+ "."
993
+ ] })
994
+ ] }),
995
+ f.length > 0 && /* @__PURE__ */ r("li", { className: "flex gap-2.5", children: [
996
+ /* @__PURE__ */ t("span", { className: "mt-1.5 h-2 w-2 shrink-0 rounded-full bg-red-500", "aria-hidden": !0 }),
997
+ /* @__PURE__ */ r("span", { children: [
998
+ /* @__PURE__ */ r("strong", { className: "font-semibold text-slate-900 dark:text-foreground", children: [
999
+ "Discard ",
1000
+ w(f)
1001
+ ] }),
1002
+ " — ",
1003
+ f.length === 1 ? "it goes" : "they go",
1004
+ " to the trash with a “Merged into",
1005
+ " ",
1006
+ p(a),
1007
+ "” note, and can be restored.",
1008
+ h > 0 && ` ${L(h, "open approval")} closed.`
1009
+ ] })
1010
+ ] }),
1011
+ _ && /* @__PURE__ */ r("li", { className: "flex gap-2.5", children: [
1012
+ /* @__PURE__ */ t("span", { className: "mt-1.5 h-2 w-2 shrink-0 rounded-full bg-amber-500", "aria-hidden": !0 }),
1013
+ /* @__PURE__ */ r("span", { children: [
1014
+ "Your new ",
1015
+ e.noun,
1016
+ " is not saved — its values go into ",
1017
+ z(a),
1018
+ "."
1019
+ ] })
1020
+ ] }),
1021
+ l.filter((u) => !u.draft).length > 0 && /* @__PURE__ */ r("li", { className: "flex gap-2.5", children: [
1022
+ /* @__PURE__ */ t(
1023
+ "span",
1024
+ {
1025
+ className: "mt-1.5 h-2 w-2 shrink-0 rounded-full bg-slate-300 dark:bg-border",
1026
+ "aria-hidden": !0
1027
+ }
1028
+ ),
1029
+ /* @__PURE__ */ r("span", { children: [
1030
+ /* @__PURE__ */ r("strong", { className: "font-semibold text-slate-900 dark:text-foreground", children: [
1031
+ w(l.filter((u) => !u.draft)),
1032
+ ": not in this merge"
1033
+ ] }),
1034
+ " ",
1035
+ "— ",
1036
+ l.length === 1 ? "it stays as it is" : "they stay as they are",
1037
+ " and",
1038
+ l.length === 1 ? " lends" : " lend",
1039
+ " no values."
1040
+ ] })
1041
+ ] })
1042
+ ] }),
1043
+ k.map((u) => {
1044
+ var i;
1045
+ return /* @__PURE__ */ r(
1046
+ "div",
1047
+ {
1048
+ className: "flex gap-2 rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-[12.5px] text-amber-900 dark:border-amber-500/30 dark:bg-amber-500/10 dark:text-amber-200",
1049
+ role: "note",
1050
+ children: [
1051
+ /* @__PURE__ */ t(ne, { className: "mt-0.5 h-3.5 w-3.5 shrink-0", "aria-hidden": !0 }),
1052
+ /* @__PURE__ */ r("span", { children: [
1053
+ /* @__PURE__ */ r("strong", { className: "font-semibold", children: [
1054
+ z(u),
1055
+ ":"
1056
+ ] }),
1057
+ " ",
1058
+ (i = u.partner) == null ? void 0 : i.warning
1059
+ ] })
1060
+ ]
1061
+ },
1062
+ u.id
1063
+ );
1064
+ }),
1065
+ /* @__PURE__ */ r("section", { children: [
1066
+ /* @__PURE__ */ t("h3", { className: "text-[13.5px] font-semibold text-slate-900 dark:text-foreground", children: x.length === 0 ? `${p(a)} keeps all its values` : `${L(x.length, "field")} change on ${p(a)}` }),
1067
+ x.length > 0 && /* @__PURE__ */ t("div", { className: "mt-2 overflow-x-auto rounded-lg border border-slate-200 dark:border-border", children: /* @__PURE__ */ r("table", { className: "w-full text-left text-[12.5px]", children: [
1068
+ /* @__PURE__ */ t("thead", { className: "bg-slate-50 text-[11.5px] text-slate-500 dark:bg-muted/40 dark:text-muted-foreground", children: /* @__PURE__ */ r("tr", { children: [
1069
+ /* @__PURE__ */ t("th", { className: "px-3 py-2 font-medium", children: "Field" }),
1070
+ /* @__PURE__ */ t("th", { className: "px-3 py-2 font-medium", children: "Now" }),
1071
+ /* @__PURE__ */ t("th", { className: "px-3 py-2 font-medium", children: "After the merge" })
1072
+ ] }) }),
1073
+ /* @__PURE__ */ t("tbody", { children: x.map((u) => {
1074
+ const i = m[u.field], R = (i == null ? void 0 : i.source) === "combined" ? "Combined" : (i == null ? void 0 : i.source) === "custom" ? "Typed" : (() => {
1075
+ const E = o.get((i == null ? void 0 : i.source) ?? "");
1076
+ return E ? `From ${p(E)}` : "";
1077
+ })();
1078
+ return /* @__PURE__ */ r(
1079
+ "tr",
1080
+ {
1081
+ className: "border-t border-slate-100 align-top dark:border-border",
1082
+ children: [
1083
+ /* @__PURE__ */ t("td", { className: "px-3 py-2 font-medium text-slate-700 dark:text-foreground/90", children: u.label }),
1084
+ /* @__PURE__ */ t("td", { className: "max-w-[18rem] px-3 py-2 text-slate-500 dark:text-muted-foreground", children: /* @__PURE__ */ t("span", { className: "line-clamp-3 whitespace-pre-line break-words", children: se(u, a.values[u.field], e.labels[u.field]) ?? "Empty" }) }),
1085
+ /* @__PURE__ */ r("td", { className: "max-w-[22rem] px-3 py-2 text-slate-900 dark:text-foreground", children: [
1086
+ /* @__PURE__ */ t("span", { className: "line-clamp-4 whitespace-pre-line break-words", children: se(u, i == null ? void 0 : i.value, e.labels[u.field]) ?? "Empty" }),
1087
+ /* @__PURE__ */ t("span", { className: "mt-0.5 block text-[11px] text-slate-500 dark:text-muted-foreground", children: R })
1088
+ ] })
1089
+ ]
1090
+ },
1091
+ u.field
1092
+ );
1093
+ }) })
1094
+ ] }) })
1095
+ ] }),
1096
+ y.length > 0 && /* @__PURE__ */ r("section", { children: [
1097
+ /* @__PURE__ */ t("h3", { className: "text-[13.5px] font-semibold text-slate-900 dark:text-foreground", children: "Linked rows" }),
1098
+ /* @__PURE__ */ t("ul", { className: "mt-2 space-y-1 text-[12.5px] text-slate-700 dark:text-foreground/90", children: y.map((u) => {
1099
+ const i = ge(
1100
+ u,
1101
+ f.map((E) => E.id)
1102
+ ), R = (v[u.key] ?? u.default) === "move";
1103
+ return /* @__PURE__ */ r("li", { className: "flex items-baseline gap-2", children: [
1104
+ /* @__PURE__ */ t("span", { className: "w-8 shrink-0 text-right tabular-nums text-slate-500 dark:text-muted-foreground", children: i.toLocaleString() }),
1105
+ /* @__PURE__ */ r("span", { children: [
1106
+ u.label,
1107
+ " —",
1108
+ " ",
1109
+ R ? u.move_word.toLowerCase() : Oe(u, p(a)).replace(/^Keep/, "keep").replace(/^Leave/, "leave")
1110
+ ] })
1111
+ ] }, u.key);
1112
+ }) })
1113
+ ] }),
1114
+ f.length > 0 && /* @__PURE__ */ r("p", { className: "flex items-center gap-1.5 text-[12px] text-slate-500 dark:text-muted-foreground", children: [
1115
+ /* @__PURE__ */ t(ue, { className: "h-3.5 w-3.5", "aria-hidden": !0 }),
1116
+ "You can undo this merge for ",
1117
+ e.undo_hours,
1118
+ " hours."
1119
+ ] })
1120
+ ] });
1121
+ }
1122
+ function Rt({
1123
+ keep: e,
1124
+ discarded: a,
1125
+ answer: d,
1126
+ undone: l,
1127
+ busy: s,
1128
+ error: m,
1129
+ noun: o,
1130
+ draft: y,
1131
+ onUndo: v,
1132
+ onOpen: k,
1133
+ onClose: h
1134
+ }) {
1135
+ const _ = a.map((w) => z(w)).join(", "), x = z(e), f = l != null && l.restored.length ? a.find((w) => w.id === l.restored[0]) : void 0;
1136
+ return /* @__PURE__ */ r(
1137
+ "div",
1138
+ {
1139
+ className: "flex min-h-0 flex-1 flex-col items-center justify-center px-6 py-12 text-center",
1140
+ "data-merge-done": l ? "undone" : "merged",
1141
+ children: [
1142
+ /* @__PURE__ */ t(
1143
+ "div",
1144
+ {
1145
+ className: F(
1146
+ "flex h-11 w-11 items-center justify-center rounded-full",
1147
+ l ? "bg-slate-100 text-slate-600 dark:bg-muted dark:text-muted-foreground" : "bg-emerald-50 text-emerald-600 dark:bg-emerald-500/15 dark:text-emerald-400"
1148
+ ),
1149
+ children: l ? /* @__PURE__ */ t(ue, { className: "h-5 w-5", "aria-hidden": !0 }) : /* @__PURE__ */ t(Ae, { className: "h-5 w-5", "aria-hidden": !0 })
1150
+ }
1151
+ ),
1152
+ /* @__PURE__ */ t("h3", { className: "mt-4 text-[16px] font-semibold text-slate-900 dark:text-foreground", children: l ? "Merge undone" : y && !d ? `Saved into ${x}` : `Merged into ${x}` }),
1153
+ /* @__PURE__ */ t("p", { className: "mt-1.5 max-w-[52ch] text-[13px] leading-relaxed text-slate-600 dark:text-muted-foreground", children: l ? `${_} ${a.length === 1 ? "is" : "are"} back, with ${a.length === 1 ? "its" : "their"} linked rows.${l.kept_fields.length ? ` ${L(l.kept_fields.length, "field")} on ${p(e)} changed after the merge and kept the newer value.` : ""}` : d ? `${_} went to the trash with a note saying where ${a.length === 1 ? "it" : "they"} went.${d.moved ? ` ${L(d.moved, "linked row")} moved to ${p(e)}.` : ""}` : `Your new ${o} was not saved; its values went into ${x}.` }),
1154
+ l && l.problems.length > 0 && /* @__PURE__ */ t("ul", { className: "mt-3 max-w-[60ch] space-y-1 text-left text-[12px] text-amber-800 dark:text-amber-300", children: l.problems.map((w) => /* @__PURE__ */ r("li", { className: "flex gap-1.5", children: [
1155
+ /* @__PURE__ */ t(ne, { className: "mt-0.5 h-3 w-3 shrink-0", "aria-hidden": !0 }),
1156
+ w
1157
+ ] }, w)) }),
1158
+ m != null && /* @__PURE__ */ t(xe, { error: m, fallback: "Could not undo the merge", className: "mt-4" }),
1159
+ /* @__PURE__ */ r("div", { className: "mt-6 flex flex-wrap items-center justify-center gap-2", children: [
1160
+ d && !l && /* @__PURE__ */ r(
1161
+ K,
1162
+ {
1163
+ type: "button",
1164
+ variant: "outline",
1165
+ size: "sm",
1166
+ className: "gap-1.5 dark:bg-transparent",
1167
+ disabled: s,
1168
+ onClick: v,
1169
+ "data-merge-undo": !0,
1170
+ children: [
1171
+ s ? /* @__PURE__ */ t(fe, { className: "h-3.5 w-3.5 animate-spin", "aria-hidden": !0 }) : /* @__PURE__ */ t(ue, { className: "h-3.5 w-3.5", "aria-hidden": !0 }),
1172
+ "Undo merge"
1173
+ ]
1174
+ }
1175
+ ),
1176
+ /* @__PURE__ */ t(
1177
+ K,
1178
+ {
1179
+ type: "button",
1180
+ variant: "outline",
1181
+ size: "sm",
1182
+ className: "dark:bg-transparent",
1183
+ onClick: h,
1184
+ children: "Close"
1185
+ }
1186
+ ),
1187
+ l ? f && /* @__PURE__ */ r(
1188
+ K,
1189
+ {
1190
+ type: "button",
1191
+ size: "sm",
1192
+ className: "bg-nvr-cyan text-white hover:bg-nvr-cyan-dark",
1193
+ onClick: () => k(f.id),
1194
+ "data-merge-open-restored": !0,
1195
+ children: [
1196
+ "Open ",
1197
+ p(f)
1198
+ ]
1199
+ }
1200
+ ) : /* @__PURE__ */ r(
1201
+ K,
1202
+ {
1203
+ type: "button",
1204
+ size: "sm",
1205
+ className: "bg-nvr-cyan text-white hover:bg-nvr-cyan-dark",
1206
+ onClick: () => k(e.id),
1207
+ children: [
1208
+ "Open ",
1209
+ p(e)
1210
+ ]
1211
+ }
1212
+ )
1213
+ ] }),
1214
+ d && !l && /* @__PURE__ */ r("p", { className: "mt-3 text-[11.5px] text-slate-500 dark:text-muted-foreground", children: [
1215
+ "Undo is offered for 24 hours, also from ",
1216
+ p(e),
1217
+ "’s ⋯ menu."
1218
+ ] })
1219
+ ]
1220
+ }
1221
+ );
1222
+ }
1223
+ export {
1224
+ ht as DRAFT_ID,
1225
+ Ut as MergeRecordsDialog,
1226
+ p as refOf
1227
+ };