@nivaro/react 0.3.114 → 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 (281) 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 +1717 -21
  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 +1 -0
  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/change-proposals/ChangeProposalsPanel.js +320 -0
  62. package/dist/shared/components/change-proposals/ProposalValue.js +28 -0
  63. package/dist/shared/components/change-proposals/ProposeChangeButton.js +44 -0
  64. package/dist/shared/components/change-proposals/ProposeChangeDialog.js +359 -0
  65. package/dist/shared/components/change-proposals/types.js +4 -0
  66. package/dist/shared/components/chat/ChatPanel.js +1571 -1528
  67. package/dist/shared/components/chat/Composer.js +276 -298
  68. package/dist/shared/components/chat/room-due.js +13 -0
  69. package/dist/shared/components/collections-directory/CollectionRow.js +76 -75
  70. package/dist/shared/components/collections-directory/CollectionsDirectory.js +415 -395
  71. package/dist/shared/components/collections-directory/directory-data.js +75 -63
  72. package/dist/shared/components/imports/ImportConsole.js +159 -155
  73. package/dist/shared/components/imports/ImportDuplicatesNotice.js +46 -31
  74. package/dist/shared/components/integrations/SendStatus.js +202 -0
  75. package/dist/shared/components/integrations/console/IntegrationsConsole.js +45 -36
  76. package/dist/shared/components/integrations/console/ReadyToSendView.js +453 -0
  77. package/dist/shared/components/integrations/console/api.js +161 -117
  78. package/dist/shared/components/integrations/console/tone.js +15 -12
  79. package/dist/shared/components/item-edit/CatalogPickerField.js +1353 -1245
  80. package/dist/shared/components/item-edit/ChangedAfterApprovalBadge.js +162 -0
  81. package/dist/shared/components/item-edit/CloneDialog.js +208 -206
  82. package/dist/shared/components/item-edit/DerivedCauseNote.js +57 -0
  83. package/dist/shared/components/item-edit/DraftRecoveryBanner.js +81 -70
  84. package/dist/shared/components/item-edit/DuplicateNotice.js +169 -101
  85. package/dist/shared/components/item-edit/FieldAffordances.js +294 -385
  86. package/dist/shared/components/item-edit/FieldComments.js +159 -116
  87. package/dist/shared/components/item-edit/FieldPointer.js +132 -0
  88. package/dist/shared/components/item-edit/FieldRenderer.js +277 -273
  89. package/dist/shared/components/item-edit/FieldRow.js +519 -439
  90. package/dist/shared/components/item-edit/FieldSourceBadge.js +88 -0
  91. package/dist/shared/components/item-edit/FilePickerField.js +454 -369
  92. package/dist/shared/components/item-edit/GroupSection.js +618 -567
  93. package/dist/shared/components/item-edit/HeldEditsChip.js +113 -0
  94. package/dist/shared/components/item-edit/InlineTableField.js +2891 -2723
  95. package/dist/shared/components/item-edit/ListNeighborNav.js +79 -0
  96. package/dist/shared/components/item-edit/LiveTraceSheet.js +26 -0
  97. package/dist/shared/components/item-edit/M2MCombobox.js +284 -273
  98. package/dist/shared/components/item-edit/OutboxReviewTray.js +313 -0
  99. package/dist/shared/components/item-edit/PickerBadges.js +52 -0
  100. package/dist/shared/components/item-edit/PlanGrid.js +434 -439
  101. package/dist/shared/components/item-edit/RecalcValue.js +55 -0
  102. package/dist/shared/components/item-edit/RecordChatActions.js +76 -64
  103. package/dist/shared/components/item-edit/RecordChatMentionsChip.js +103 -0
  104. package/dist/shared/components/item-edit/RecordGrantTools.js +87 -86
  105. package/dist/shared/components/item-edit/RecordHelpChip.js +70 -0
  106. package/dist/shared/components/item-edit/RecordLiveSync.js +230 -217
  107. package/dist/shared/components/item-edit/RecordOutbox.js +53 -52
  108. package/dist/shared/components/item-edit/RecordRecapStrip.js +109 -36
  109. package/dist/shared/components/item-edit/RelationCombobox.js +229 -217
  110. package/dist/shared/components/item-edit/RelationGroupedCombobox.js +105 -100
  111. package/dist/shared/components/item-edit/RemoteChangeUi.js +454 -0
  112. package/dist/shared/components/item-edit/RemoteUploads.js +55 -0
  113. package/dist/shared/components/item-edit/RemovedLineNote.js +92 -0
  114. package/dist/shared/components/item-edit/RichTextEditorImpl.js +298 -223
  115. package/dist/shared/components/item-edit/ScheduledChangeChip.js +244 -0
  116. package/dist/shared/components/item-edit/SectionPresence.js +78 -0
  117. package/dist/shared/components/item-edit/SplitLinesButton.js +166 -0
  118. package/dist/shared/components/item-edit/catalog-line-watch.js +94 -0
  119. package/dist/shared/components/item-edit/coedit/collab.js +84 -0
  120. package/dist/shared/components/item-edit/coedit/context.js +24 -0
  121. package/dist/shared/components/item-edit/coedit/cursors.js +103 -0
  122. package/dist/shared/components/item-edit/coedit/safe-link.js +15 -0
  123. package/dist/shared/components/item-edit/coedit/session.js +382 -0
  124. package/dist/shared/components/item-edit/coedit/useCoedit.js +49 -0
  125. package/dist/shared/components/item-edit/file-live.js +77 -0
  126. package/dist/shared/components/item-edit/file-processing.js +87 -0
  127. package/dist/shared/components/item-edit/layout-switch.js +148 -0
  128. package/dist/shared/components/item-edit/live-related.js +23 -0
  129. package/dist/shared/components/item-edit/live-title.js +66 -0
  130. package/dist/shared/components/item-edit/partner-needs.js +142 -0
  131. package/dist/shared/components/item-edit/removed-line.js +58 -0
  132. package/dist/shared/components/item-edit/render-stability.js +70 -59
  133. package/dist/shared/components/layout-editor/ChangeNote.js +36 -34
  134. package/dist/shared/components/layout-editor/CollabParts.js +72 -70
  135. package/dist/shared/components/layout-editor/LayoutEditor.js +306 -303
  136. package/dist/shared/components/list/InlineEdit.js +504 -208
  137. package/dist/shared/components/list/ListViewers.js +81 -0
  138. package/dist/shared/components/merge/MergeRecordsDialog.js +1227 -0
  139. package/dist/shared/components/merge/MergeWithFlow.js +290 -0
  140. package/dist/shared/components/merge/merge-values.js +110 -0
  141. package/dist/shared/components/monitoring/InactiveUserLinksView.js +285 -258
  142. package/dist/shared/components/notifications/NotificationCenterView.js +388 -321
  143. package/dist/shared/components/notifications/NotificationDetailBits.js +205 -130
  144. package/dist/shared/components/notifications/NotificationRulesEditor.js +72 -52
  145. package/dist/shared/components/notifications/bundles.js +21 -19
  146. package/dist/shared/components/notifications/resolved-line.js +25 -0
  147. package/dist/shared/components/ops/OpsTasksView.js +45 -44
  148. package/dist/shared/components/panels/AccessGrantedNote.js +85 -0
  149. package/dist/shared/components/panels/AlertBanners.js +132 -0
  150. package/dist/shared/components/panels/AsyncUserPicker.js +54 -45
  151. package/dist/shared/components/panels/BranchLanes.js +82 -54
  152. package/dist/shared/components/panels/CommentAwareness.js +332 -0
  153. package/dist/shared/components/panels/CommentImages.js +219 -0
  154. package/dist/shared/components/panels/CommentPanel.js +649 -530
  155. package/dist/shared/components/panels/ExternalRequestsChip.js +98 -80
  156. package/dist/shared/components/panels/NewSinceChip.js +16 -0
  157. package/dist/shared/components/panels/OwnerOpenedLine.js +85 -0
  158. package/dist/shared/components/panels/PipelinePanel.js +1644 -1494
  159. package/dist/shared/components/panels/ResubmissionDiff.js +293 -0
  160. package/dist/shared/components/panels/SlaBreachBanner.js +30 -29
  161. package/dist/shared/components/panels/SlaClock.js +130 -99
  162. package/dist/shared/components/panels/TaskPanel.js +308 -287
  163. package/dist/shared/components/panels/unseen-move-check.js +101 -0
  164. package/dist/shared/components/pipeline/OwnerMatrix.js +80 -71
  165. package/dist/shared/components/pipeline/OwnerMatrixSheet.js +495 -0
  166. package/dist/shared/components/pipeline/PipelineEditorView.js +1855 -1771
  167. package/dist/shared/components/profile/AgentNameField.js +141 -0
  168. package/dist/shared/components/profile/AgentsPanel.js +55 -46
  169. package/dist/shared/components/profile/PersonAccess.js +398 -330
  170. package/dist/shared/components/profile/PersonAdminTools.js +127 -113
  171. package/dist/shared/components/profile/PersonProfile.js +81 -73
  172. package/dist/shared/components/profile/SignInTroubleshooter.js +361 -0
  173. package/dist/shared/components/queue/QueueBulkBar.js +101 -84
  174. package/dist/shared/components/queue/QueueItemSheet.js +66 -66
  175. package/dist/shared/components/queue/QueueTeamStrip.js +279 -0
  176. package/dist/shared/components/queue/QueueWorklist.js +1927 -1635
  177. package/dist/shared/components/send-view/SendViewButton.js +136 -0
  178. package/dist/shared/components/send-view/SentViewCards.js +147 -0
  179. package/dist/shared/components/support/ReportProblem.js +1 -0
  180. package/dist/shared/components/support/ScreenShare.js +554 -0
  181. package/dist/shared/components/support/SupportView.js +160 -129
  182. package/dist/shared/components/support/TicketDetailSheet.js +101 -89
  183. package/dist/shared/components/watch-list/WatchDock.js +1044 -0
  184. package/dist/shared/components/watch-list/WatchExtras.js +723 -0
  185. package/dist/shared/components/watch-list/WatchListButton.js +46 -0
  186. package/dist/shared/components/watch-list/WatchPinButton.js +67 -0
  187. package/dist/shared/components/watch-list/WatchRows.js +348 -0
  188. package/dist/shared/lib/activity-sentence.js +87 -75
  189. package/dist/shared/lib/agent-presence.js +46 -0
  190. package/dist/shared/lib/approval-progress.js +49 -0
  191. package/dist/shared/lib/attention-prefs.js +27 -0
  192. package/dist/shared/lib/cell-locks.js +56 -0
  193. package/dist/shared/lib/co-edit.js +166 -0
  194. package/dist/shared/lib/coedit-registry.js +44 -0
  195. package/dist/shared/lib/comment-awareness.js +124 -0
  196. package/dist/shared/lib/comment-images.js +45 -0
  197. package/dist/shared/lib/config-watch.js +94 -0
  198. package/dist/shared/lib/copy-rules.js +65 -0
  199. package/dist/shared/lib/count-step.js +30 -0
  200. package/dist/shared/lib/deadline-ticker.js +68 -0
  201. package/dist/shared/lib/derived-causes.js +115 -0
  202. package/dist/shared/lib/draft-store.js +114 -85
  203. package/dist/shared/lib/error-hints.js +1 -0
  204. package/dist/shared/lib/field-merge.js +126 -0
  205. package/dist/shared/lib/filter-sentence.js +10 -10
  206. package/dist/shared/lib/focus-mode.js +16 -12
  207. package/dist/shared/lib/grid-cursors.js +77 -0
  208. package/dist/shared/lib/grid-presence.js +182 -0
  209. package/dist/shared/lib/idle-reload.js +100 -73
  210. package/dist/shared/lib/in-step.js +45 -0
  211. package/dist/shared/lib/integration-chip.js +19 -18
  212. package/dist/shared/lib/line-locks.js +141 -0
  213. package/dist/shared/lib/line-split.js +41 -0
  214. package/dist/shared/lib/linked-changes.js +150 -0
  215. package/dist/shared/lib/list-return.js +231 -0
  216. package/dist/shared/lib/list-viewers.js +52 -0
  217. package/dist/shared/lib/live-announcer.js +86 -0
  218. package/dist/shared/lib/live-counts.js +85 -0
  219. package/dist/shared/lib/live-data-changed.js +108 -0
  220. package/dist/shared/lib/live-deltas.js +81 -0
  221. package/dist/shared/lib/live-findings.js +113 -0
  222. package/dist/shared/lib/live-groups.js +122 -0
  223. package/dist/shared/lib/live-link-labels.js +162 -0
  224. package/dist/shared/lib/live-list-flow.js +334 -0
  225. package/dist/shared/lib/live-list.js +143 -129
  226. package/dist/shared/lib/live-moves.js +51 -0
  227. package/dist/shared/lib/live-ops.js +26 -26
  228. package/dist/shared/lib/live-pickers.js +7 -0
  229. package/dist/shared/lib/live-preference.js +184 -0
  230. package/dist/shared/lib/live-queries.js +226 -181
  231. package/dist/shared/lib/live-screen.js +333 -0
  232. package/dist/shared/lib/live-search.js +108 -0
  233. package/dist/shared/lib/live-seen.js +35 -0
  234. package/dist/shared/lib/live-views.js +100 -0
  235. package/dist/shared/lib/live.js +159 -133
  236. package/dist/shared/lib/missed-updates.js +198 -0
  237. package/dist/shared/lib/newer-file.js +56 -0
  238. package/dist/shared/lib/notification-sound.js +42 -20
  239. package/dist/shared/lib/own-writes.js +59 -41
  240. package/dist/shared/lib/picker-badges.js +94 -0
  241. package/dist/shared/lib/presence-signals.js +131 -84
  242. package/dist/shared/lib/realtime.js +49 -24
  243. package/dist/shared/lib/record-gaps.js +85 -0
  244. package/dist/shared/lib/record-outbox.js +369 -222
  245. package/dist/shared/lib/record-peek.js +75 -0
  246. package/dist/shared/lib/record-tabs.js +92 -72
  247. package/dist/shared/lib/relative-ticker.js +42 -0
  248. package/dist/shared/lib/request-gate.js +119 -119
  249. package/dist/shared/lib/rollup-recalc.js +107 -0
  250. package/dist/shared/lib/room-gaps.js +40 -36
  251. package/dist/shared/lib/rum.js +137 -87
  252. package/dist/shared/lib/save-progress.js +20 -0
  253. package/dist/shared/lib/scheduled-countdown.js +67 -0
  254. package/dist/shared/lib/screen-refresh.js +160 -0
  255. package/dist/shared/lib/screen-share.js +234 -0
  256. package/dist/shared/lib/seen-since.js +74 -0
  257. package/dist/shared/lib/selection-watch.js +205 -0
  258. package/dist/shared/lib/send-status.js +132 -0
  259. package/dist/shared/lib/send-view.js +23 -0
  260. package/dist/shared/lib/socket-liveness.js +155 -0
  261. package/dist/shared/lib/socket-realtime.js +168 -140
  262. package/dist/shared/lib/state-census.js +53 -0
  263. package/dist/shared/lib/summary-mode.js +61 -39
  264. package/dist/shared/lib/tab-attention.js +143 -32
  265. package/dist/shared/lib/table-density.js +64 -0
  266. package/dist/shared/lib/track-travel.js +40 -0
  267. package/dist/shared/lib/unseen-changes.js +68 -0
  268. package/dist/shared/lib/upload-file.js +33 -0
  269. package/dist/shared/lib/upload-presence.js +127 -0
  270. package/dist/shared/lib/urgent-chime.js +65 -0
  271. package/dist/shared/lib/use-online-users.js +32 -11
  272. package/dist/shared/lib/user-sync.js +155 -39
  273. package/dist/shared/lib/waiting-count.js +44 -0
  274. package/dist/shared/lib/watch-desktop.js +83 -0
  275. package/dist/shared/lib/watch-list.js +447 -0
  276. package/dist/shared/lib/widget-image-render.js +64 -0
  277. package/dist/shared/lib/widget-image.js +111 -0
  278. package/dist/shared/lib/worker-socket.js +130 -104
  279. package/dist/shared/lib/write-to-screen.js +133 -0
  280. package/package.json +1 -1
  281. package/styles.css +49 -1
@@ -1,39 +1,46 @@
1
- import { jsxs as u, jsx as n } from "react/jsx-runtime";
2
- import { useQueryClient as nt, useQueries as Ft, useQuery as le, useMutation as Ct } from "@tanstack/react-query";
3
- import { Info as Rt, Loader2 as Lt, Sparkles as St, Lock as $t, SlidersHorizontal as qt, History as At, BellRing as Tt, Bell as Et, Sigma as Pt } from "lucide-react";
4
- import { memo as jt, useState as ke, useRef as L, useId as Bt, useEffect as oe, useCallback as Je } from "react";
5
- import { toast as ae } from "sonner";
6
- import { useParentDraft as Dt, useNivaroClient as ie } from "../../context.js";
7
- import { showsAiButton as Mt, AUTOFILL_CHECK_KEY as Ot, readAiFill as Ht } from "../../lib/ai-fill.js";
8
- import { get as U, del as Kt, post as ve } from "../../lib/commands.js";
9
- import { toastError as Ut } from "../../lib/error-toast.js";
10
- import { titleCase as K, cn as D, formatDateTime as we, toLocalDateString as Wt } from "../../lib/utils.js";
11
- import { requiredByRules as Xe } from "../../lib/validation-rules.js";
12
- import { GlossaryLabel as Ze } from "../ai/GlossaryText.js";
13
- import { useFieldSource as Vt, FieldSourceInfo as zt } from "../ConfigReadBack.js";
14
- import { Label as Gt } from "../ui/label.js";
15
- import { TooltipProvider as ee, Tooltip as te, TooltipTrigger as ne, TooltipContent as re } from "../ui/tooltip.js";
16
- import { useAddendumFields as Qt } from "./AddendumFieldContext.js";
17
- import { AutoIdPreviewField as Yt } from "./AutoIdPreviewField.js";
18
- import { useCascadeClearNotifier as Jt } from "./cascade-clear-notice.js";
19
- import { DuplicateNotice as Xt } from "./DuplicateNotice.js";
20
- import { FOCUSABLE as Ie } from "./entry/entry-keys.js";
21
- import { useFieldAffordances as Zt, useFieldContextMenu as It, usePresenceSoftLock as en, LockReasonBadge as tn, PresenceSoftLockStrip as nn, RemoteChangeGhost as rn } from "./FieldAffordances.js";
22
- import { FieldCommentButton as ln } from "./FieldComments.js";
23
- import { FieldRenderer as on } from "./FieldRenderer.js";
24
- import { FormHelpVideoButton as an } from "./FormHelpVideoButton.js";
25
- import { primaryControl as sn, applyFieldA11y as dn } from "./field-a11y.js";
26
- import { getCascadeFilters as cn, SYSTEM_FIELDS as un, parseJson as mn, buildCascadeFilter as pn, CascadeEffectController as hn } from "./helpers.js";
27
- import { isDerivedForRecord as fn } from "./live-rollups.js";
28
- import { useM2MStaging as xn } from "./M2MStagingContext.js";
29
- import { personalDefaultSlotFor as yn, PersonalDefaultSlot as bn } from "./PersonalDefaultControl.js";
30
- import { PersonalDefaultHint as gn } from "./PersonalDefaultPill.js";
31
- import { isDisplayFormulaRow as et, usePlacementTextContext as vn, placementFieldText as wn, fieldCounterConfig as kn, fieldIsRecommended as _n, RecommendedMarker as Nn, RepeatLastButton as Fn, DisplayFormulaValue as Cn, FieldCounter as Rn } from "./placement-behaviour.js";
32
- import { keepIfEqual as Ln, jsonEqual as Sn } from "./render-stability.js";
33
- import { softRuleWarning as $n } from "./soft-rules.js";
34
- import { usePersonalDefaultsApi as qn } from "./usePersonalDefaults.js";
35
- import { resolveOptionFilterTokens as An } from "../../lib/option-filter-tokens.js";
36
- const tt = /* @__PURE__ */ new Set(["integer", "float", "decimal", "bigInteger", "number"]), Tn = /* @__PURE__ */ new Set(["string", "text", "richtext", "textarea", "markdown", "json", "csv"]), En = /* @__PURE__ */ new Set([
1
+ import { jsxs as m, jsx as n } from "react/jsx-runtime";
2
+ import { useQueryClient as at, useQueries as Bt, useQuery as se, useMutation as Mt } from "@tanstack/react-query";
3
+ import { Info as Dt, Crosshair as Ht, Loader2 as Ot, Sparkles as Kt, Lock as Ut, SlidersHorizontal as Wt, History as Vt, BellRing as zt, Bell as Qt, Sigma as Gt } from "lucide-react";
4
+ import { memo as Yt, useState as Le, useRef as L, useId as Jt, useEffect as ce, useCallback as et } from "react";
5
+ import { toast as de } from "sonner";
6
+ import { useParentDraft as Xt, useNivaroClient as ue } from "../../context.js";
7
+ import { showsAiButton as Zt, AUTOFILL_CHECK_KEY as It, readAiFill as en } from "../../lib/ai-fill.js";
8
+ import { useCoViewers as tn } from "../../lib/co-edit.js";
9
+ import { get as z, del as nn, post as Ce } from "../../lib/commands.js";
10
+ import { toastError as rn } from "../../lib/error-toast.js";
11
+ import { useOptionalRealtime as on } from "../../lib/realtime.js";
12
+ import { titleCase as j, cn as B, formatDateTime as Re, toLocalDateString as ln } from "../../lib/utils.js";
13
+ import { requiredByRules as tt } from "../../lib/validation-rules.js";
14
+ import { GlossaryLabel as nt } from "../ai/GlossaryText.js";
15
+ import { useFieldSource as an, FieldSourceInfo as sn } from "../ConfigReadBack.js";
16
+ import { Label as cn } from "../ui/label.js";
17
+ import { TooltipProvider as oe, Tooltip as ie, TooltipTrigger as le, TooltipContent as ae } from "../ui/tooltip.js";
18
+ import { useAddendumFields as dn } from "./AddendumFieldContext.js";
19
+ import { AutoIdPreviewField as un } from "./AutoIdPreviewField.js";
20
+ import { useCascadeClearNotifier as mn } from "./cascade-clear-notice.js";
21
+ import { useCoeditTarget as pn, isCoeditInterface as hn } from "./coedit/context.js";
22
+ import { DerivedCauseNote as fn } from "./DerivedCauseNote.js";
23
+ import { DuplicateNotice as xn } from "./DuplicateNotice.js";
24
+ import { FOCUSABLE as rt } from "./entry/entry-keys.js";
25
+ import { useFieldAffordances as yn, useFieldContextMenu as bn, usePresenceSoftLock as gn, LockReasonBadge as vn, PresenceSoftLockStrip as wn } from "./FieldAffordances.js";
26
+ import { FieldCommentButton as kn } from "./FieldComments.js";
27
+ import { FieldRenderer as Nn } from "./FieldRenderer.js";
28
+ import { FieldSourceBadge as _n } from "./FieldSourceBadge.js";
29
+ import { FormHelpVideoButton as Fn } from "./FormHelpVideoButton.js";
30
+ import { primaryControl as Cn, applyFieldA11y as Rn } from "./field-a11y.js";
31
+ import { getCascadeFilters as Ln, SYSTEM_FIELDS as Sn, parseJson as $n, buildCascadeFilter as Tn, CascadeEffectController as qn } from "./helpers.js";
32
+ import { isDerivedForRecord as An } from "./live-rollups.js";
33
+ import { useM2MStaging as Pn } from "./M2MStagingContext.js";
34
+ import { personalDefaultSlotFor as En, PersonalDefaultSlot as jn } from "./PersonalDefaultControl.js";
35
+ import { PersonalDefaultHint as Bn } from "./PersonalDefaultPill.js";
36
+ import { usePartnerNeeds as Mn, isEmptyValue as ot, PartnerNeedBadge as Dn, PartnerNeedHint as Hn } from "./partner-needs.js";
37
+ import { isDisplayFormulaRow as it, usePlacementTextContext as On, placementFieldText as Kn, fieldCounterConfig as Un, fieldIsRecommended as Wn, RecommendedMarker as Vn, RepeatLastButton as zn, DisplayFormulaValue as Qn, FieldCounter as Gn } from "./placement-behaviour.js";
38
+ import { RemoteChangeMark as Yn, RemoteConflictNotice as Jn } from "./RemoteChangeUi.js";
39
+ import { keepIfEqual as Xn, jsonEqual as Zn } from "./render-stability.js";
40
+ import { softRuleWarning as In } from "./soft-rules.js";
41
+ import { usePersonalDefaultsApi as er } from "./usePersonalDefaults.js";
42
+ import { resolveOptionFilterTokens as tr } from "../../lib/option-filter-tokens.js";
43
+ const lt = /* @__PURE__ */ new Set(["integer", "float", "decimal", "bigInteger", "number"]), nr = /* @__PURE__ */ new Set(["string", "text", "richtext", "textarea", "markdown", "json", "csv"]), rr = /* @__PURE__ */ new Set([
37
44
  "input",
38
45
  "textarea",
39
46
  "wysiwyg",
@@ -41,7 +48,7 @@ const tt = /* @__PURE__ */ new Set(["integer", "float", "decimal", "bigInteger",
41
48
  "input-rich-text-html",
42
49
  "rich_text",
43
50
  "extension-editorjs"
44
- ]), Pn = /* @__PURE__ */ new Set([
51
+ ]), or = /* @__PURE__ */ new Set([
45
52
  "relation-m2o",
46
53
  "relation-m2m",
47
54
  "select-multiple-m2m",
@@ -52,95 +59,95 @@ const tt = /* @__PURE__ */ new Set(["integer", "float", "decimal", "bigInteger",
52
59
  "file",
53
60
  "files",
54
61
  "image"
55
- ]), jn = /* @__PURE__ */ new Set(["file", "file-image", "files-m2m", "files", "image"]);
56
- function Bn(m) {
57
- const e = m.interface ?? "";
58
- return Pn.has(e) || e.startsWith("relation-") || e.endsWith("-m2o") || e.endsWith("-m2m") || tt.has(m.type ?? "") ? !1 : !!(Tn.has(m.type ?? "") || En.has(e) || !e && m.type && !tt.has(m.type));
62
+ ]), ir = /* @__PURE__ */ new Set(["file", "file-image", "files-m2m", "files", "image"]);
63
+ function lr(p) {
64
+ const e = p.interface ?? "";
65
+ return or.has(e) || e.startsWith("relation-") || e.endsWith("-m2o") || e.endsWith("-m2m") || lt.has(p.type ?? "") ? !1 : !!(nr.has(p.type ?? "") || rr.has(e) || !e && p.type && !lt.has(p.type));
59
66
  }
60
- function Dn(m, e, i) {
61
- return m.filter((h) => (i == null ? void 0 : i(h)) !== e);
67
+ function ar(p, e, s) {
68
+ return p.filter((h) => (s == null ? void 0 : s(h)) !== e);
62
69
  }
63
- function Mn(m, e, i, h) {
64
- const x = ie();
65
- return le({
66
- queryKey: ["field-lineage", m, e, i],
70
+ function sr(p, e, s, h) {
71
+ const x = ue();
72
+ return se({
73
+ queryKey: ["field-lineage", p, e, s],
67
74
  queryFn: () => x.request(
68
- U(`/lineage/${m}/${encodeURIComponent(e)}/${i}`)
69
- ).then((d) => d.data),
75
+ z(`/lineage/${p}/${encodeURIComponent(e)}/${s}`)
76
+ ).then((c) => c.data),
70
77
  enabled: h,
71
78
  staleTime: 3e4
72
79
  });
73
80
  }
74
- function Nr(m, e = "rows") {
75
- var l, w, g;
76
- if (m && (m.kind === "write" || m.kind === "read") && m.formula) {
77
- const p = (b) => typeof b == "number" ? b.toLocaleString(void 0, { maximumFractionDigits: 2 }) : b == null || b === "" ? "0" : String(b);
78
- return `= ${m.formula.replace(/item\.([A-Za-z_][A-Za-z0-9_]*)/g, (b, o) => {
81
+ function eo(p, e = "rows") {
82
+ var r, w, g;
83
+ if (p && (p.kind === "write" || p.kind === "read") && p.formula) {
84
+ const d = (b) => typeof b == "number" ? b.toLocaleString(void 0, { maximumFractionDigits: 2 }) : b == null || b === "" ? "0" : String(b);
85
+ return `= ${p.formula.replace(/item\.([A-Za-z_][A-Za-z0-9_]*)/g, (b, i) => {
79
86
  var f;
80
- return p((f = m.inputs) == null ? void 0 : f[o]);
87
+ return d((f = p.inputs) == null ? void 0 : f[i]);
81
88
  }).replace(/\s*-\s*/g, " − ").replace(/\s*\*\s*/g, " × ").replace(/\s*\/\s*/g, " ÷ ")}`;
82
89
  }
83
- if (!m || m.kind !== "rollup") return null;
84
- const i = (m.sources ?? []).reduce((p, a) => p + a.rows.length, 0), h = (m.sources ?? []).reduce((p, a) => {
90
+ if (!p || p.kind !== "rollup") return null;
91
+ const s = (p.sources ?? []).reduce((d, a) => d + a.rows.length, 0), h = (p.sources ?? []).reduce((d, a) => {
85
92
  var b;
86
- return p + (((b = a.excluded) == null ? void 0 : b.length) ?? 0);
87
- }, 0), x = (g = (w = (l = (m.sources ?? []).find((p) => {
93
+ return d + (((b = a.excluded) == null ? void 0 : b.length) ?? 0);
94
+ }, 0), x = (g = (w = (r = (p.sources ?? []).find((d) => {
88
95
  var a;
89
- return (a = p.excluded) == null ? void 0 : a.length;
90
- })) == null ? void 0 : l.excluded) == null ? void 0 : w[0]) == null ? void 0 : g.reason, d = [`= ${i} ${i === 1 ? e.replace(/s$/, "") : e}`];
91
- return h && d.push(
96
+ return (a = d.excluded) == null ? void 0 : a.length;
97
+ })) == null ? void 0 : r.excluded) == null ? void 0 : w[0]) == null ? void 0 : g.reason, c = [`= ${s} ${s === 1 ? e.replace(/s$/, "") : e}`];
98
+ return h && c.push(
92
99
  `${h} excluded${x ? ` (${x.replace(/^does not match: /, "")})` : ""}`
93
- ), d.join(" · ");
100
+ ), c.join(" · ");
94
101
  }
95
- function On({
96
- collection: m,
102
+ function cr({
103
+ collection: p,
97
104
  itemId: e,
98
- field: i
105
+ field: s
99
106
  }) {
100
- const [h, x] = ke(!1), d = L(null), { data: l, isLoading: w } = Mn(m, e, i, h);
101
- oe(() => {
107
+ const [h, x] = Le(!1), c = L(null), { data: r, isLoading: w } = sr(p, e, s, h);
108
+ ce(() => {
102
109
  if (!h) return;
103
110
  const a = (b) => {
104
- var o;
105
- (o = d.current) != null && o.contains(b.target) || x(!1);
111
+ var i;
112
+ (i = c.current) != null && i.contains(b.target) || x(!1);
106
113
  };
107
114
  return window.addEventListener("mousedown", a), () => window.removeEventListener("mousedown", a);
108
115
  }, [h]);
109
- const g = (a) => a == null ? "—" : Number(a).toLocaleString(void 0, { maximumFractionDigits: 2 }), p = (l == null ? void 0 : l.stored_value) != null ? Number(l.stored_value) : null;
110
- return /* @__PURE__ */ u("div", { ref: d, className: "relative inline-flex", children: [
116
+ const g = (a) => a == null ? "—" : Number(a).toLocaleString(void 0, { maximumFractionDigits: 2 }), d = (r == null ? void 0 : r.stored_value) != null ? Number(r.stored_value) : null;
117
+ return /* @__PURE__ */ m("div", { ref: c, className: "relative inline-flex", children: [
111
118
  /* @__PURE__ */ n(
112
119
  "button",
113
120
  {
114
121
  type: "button",
115
122
  onClick: () => x((a) => !a),
116
123
  title: "Where does this number come from?",
117
- className: D(
124
+ className: B(
118
125
  "inline-flex items-center rounded p-0.5 transition-opacity",
119
126
  h ? "text-nvr-cyan opacity-100" : "text-slate-400 hover:text-nvr-cyan dark:text-slate-300 dark:hover:text-nvr-cyan"
120
127
  ),
121
128
  "data-field-lineage": !0,
122
- children: /* @__PURE__ */ n(Pt, { className: "h-3 w-3" })
129
+ children: /* @__PURE__ */ n(Gt, { className: "h-3 w-3" })
123
130
  }
124
131
  ),
125
- h && /* @__PURE__ */ u("div", { className: "absolute left-0 top-full z-40 mt-1 max-h-[340px] w-[360px] overflow-y-auto rounded-lg border border-slate-200 bg-white p-2 shadow-lg dark:border-border dark:bg-card", children: [
132
+ h && /* @__PURE__ */ m("div", { className: "absolute left-0 top-full z-40 mt-1 max-h-[340px] w-[360px] overflow-y-auto rounded-lg border border-slate-200 bg-white p-2 shadow-lg dark:border-border dark:bg-card", children: [
126
133
  /* @__PURE__ */ n("p", { className: "mb-1 px-1 text-[10px] font-semibold uppercase tracking-wide text-slate-400", children: "Where this number comes from" }),
127
134
  w && /* @__PURE__ */ n("p", { className: "px-1 py-2 text-[11.5px] text-slate-400", children: "Loading…" }),
128
- (l == null ? void 0 : l.kind) === "write" && /* @__PURE__ */ u("div", { className: "space-y-1 px-1 py-1", children: [
129
- /* @__PURE__ */ n("p", { className: "font-mono text-[11px] text-slate-600 dark:text-slate-300", children: l.formula }),
130
- Object.entries(l.inputs ?? {}).map(([a, b]) => /* @__PURE__ */ u("p", { className: "text-[11.5px] text-slate-500 dark:text-muted-foreground", children: [
135
+ (r == null ? void 0 : r.kind) === "write" && /* @__PURE__ */ m("div", { className: "space-y-1 px-1 py-1", children: [
136
+ /* @__PURE__ */ n("p", { className: "font-mono text-[11px] text-slate-600 dark:text-slate-300", children: r.formula }),
137
+ Object.entries(r.inputs ?? {}).map(([a, b]) => /* @__PURE__ */ m("p", { className: "text-[11.5px] text-slate-500 dark:text-muted-foreground", children: [
131
138
  /* @__PURE__ */ n("span", { className: "font-mono", children: a }),
132
139
  " = ",
133
140
  g(b)
134
141
  ] }, a)),
135
- /* @__PURE__ */ u("p", { className: "pt-1 text-[11.5px] font-medium text-slate-700 dark:text-slate-200", children: [
142
+ /* @__PURE__ */ m("p", { className: "pt-1 text-[11.5px] font-medium text-slate-700 dark:text-slate-200", children: [
136
143
  "= ",
137
- g(l.stored_value)
144
+ g(r.stored_value)
138
145
  ] })
139
146
  ] }),
140
- (l == null ? void 0 : l.kind) === "rollup" && (l.sources ?? []).map((a, b) => {
141
- var o;
142
- return /* @__PURE__ */ u("div", { className: "mb-1.5", children: [
143
- /* @__PURE__ */ u("p", { className: "px-1 text-[10.5px] text-slate-400", children: [
147
+ (r == null ? void 0 : r.kind) === "rollup" && (r.sources ?? []).map((a, b) => {
148
+ var i;
149
+ return /* @__PURE__ */ m("div", { className: "mb-1.5", children: [
150
+ /* @__PURE__ */ m("p", { className: "px-1 text-[10.5px] text-slate-400", children: [
144
151
  (a.aggregate ?? "sum").toUpperCase(),
145
152
  a.value_field ? ` of ${a.value_field}` : "",
146
153
  " across ",
@@ -149,7 +156,7 @@ function On({
149
156
  ] }),
150
157
  a.error && /* @__PURE__ */ n("p", { className: "px-1 py-1 text-[11.5px] text-amber-600 dark:text-amber-400", children: a.error }),
151
158
  a.note && /* @__PURE__ */ n("p", { className: "px-1 py-1 text-[11.5px] text-slate-400", children: a.note }),
152
- a.rows.length > 0 && /* @__PURE__ */ n("div", { className: "mt-0.5 space-y-px", children: a.rows.map((f) => /* @__PURE__ */ u(
159
+ a.rows.length > 0 && /* @__PURE__ */ n("div", { className: "mt-0.5 space-y-px", children: a.rows.map((f) => /* @__PURE__ */ m(
153
160
  "div",
154
161
  {
155
162
  className: "flex items-baseline gap-2 rounded px-1 py-0.5 text-[11.5px] hover:bg-slate-50 dark:hover:bg-muted",
@@ -160,7 +167,7 @@ function On({
160
167
  "span",
161
168
  {
162
169
  className: "w-[88px] shrink-0 truncate text-right text-[10px] text-slate-400",
163
- "data-tip": f.updated_at ? `${f.updated_by ?? "unknown"} · ${we(f.updated_at)}` : void 0,
170
+ "data-tip": f.updated_at ? `${f.updated_by ?? "unknown"} · ${Re(f.updated_at)}` : void 0,
164
171
  children: f.updated_by ?? ""
165
172
  }
166
173
  )
@@ -169,18 +176,18 @@ function On({
169
176
  f.id
170
177
  )) }),
171
178
  a.truncated && /* @__PURE__ */ n("p", { className: "px-1 pt-0.5 text-[10.5px] text-amber-600 dark:text-amber-400", children: "Showing the first 200 rows — the subtotal covers only these." }),
172
- a.subtotal != null && /* @__PURE__ */ u("p", { className: "border-t border-slate-100 px-1 pt-1 text-right text-[11.5px] font-medium text-slate-700 dark:border-border dark:text-slate-200", children: [
179
+ a.subtotal != null && /* @__PURE__ */ m("p", { className: "border-t border-slate-100 px-1 pt-1 text-right text-[11.5px] font-medium text-slate-700 dark:border-border dark:text-slate-200", children: [
173
180
  "subtotal ",
174
181
  g(a.subtotal)
175
182
  ] }),
176
- (((o = a.excluded) == null ? void 0 : o.length) ?? 0) > 0 && /* @__PURE__ */ u("div", { className: "mt-1 rounded bg-slate-50 px-1 py-1 dark:bg-muted/40", children: [
177
- /* @__PURE__ */ u("p", { className: "text-[10.5px] text-slate-500 dark:text-muted-foreground", children: [
183
+ (((i = a.excluded) == null ? void 0 : i.length) ?? 0) > 0 && /* @__PURE__ */ m("div", { className: "mt-1 rounded bg-slate-50 px-1 py-1 dark:bg-muted/40", children: [
184
+ /* @__PURE__ */ m("p", { className: "text-[10.5px] text-slate-500 dark:text-muted-foreground", children: [
178
185
  a.excluded.length,
179
186
  " excluded —",
180
187
  " ",
181
188
  a.excluded[0].reason.replace(/^does not match: /, "")
182
189
  ] }),
183
- a.excluded.slice(0, 8).map((f) => /* @__PURE__ */ u(
190
+ a.excluded.slice(0, 8).map((f) => /* @__PURE__ */ m(
184
191
  "div",
185
192
  {
186
193
  className: "flex items-baseline gap-2 px-0.5 text-[11px] text-slate-400",
@@ -191,7 +198,7 @@ function On({
191
198
  },
192
199
  f.id
193
200
  )),
194
- a.excluded.length > 8 && /* @__PURE__ */ u("p", { className: "px-0.5 text-[10.5px] text-slate-400", children: [
201
+ a.excluded.length > 8 && /* @__PURE__ */ m("p", { className: "px-0.5 text-[10.5px] text-slate-400", children: [
195
202
  "+",
196
203
  a.excluded.length - 8,
197
204
  " more"
@@ -199,90 +206,90 @@ function On({
199
206
  ] })
200
207
  ] }, b);
201
208
  }),
202
- (l == null ? void 0 : l.kind) === "rollup" && p != null && /* @__PURE__ */ u("p", { className: "px-1 pt-0.5 text-right text-[11.5px] text-slate-500 dark:text-muted-foreground", children: [
209
+ (r == null ? void 0 : r.kind) === "rollup" && d != null && /* @__PURE__ */ m("p", { className: "px-1 pt-0.5 text-right text-[11.5px] text-slate-500 dark:text-muted-foreground", children: [
203
210
  "stored ",
204
- g(p),
211
+ g(d),
205
212
  (() => {
206
- const a = (l.sources ?? []).reduce((o, f) => o + (f.subtotal ?? 0), 0);
207
- return (l.sources ?? []).some((o) => o.truncated) ? null : Math.abs(a - p) < 0.01 ? /* @__PURE__ */ n("span", { className: "ml-1 text-emerald-600 dark:text-emerald-400", children: "✓ matches" }) : /* @__PURE__ */ n("span", { className: "ml-1 text-amber-600 dark:text-amber-400", children: "✕ differs from contributions" });
213
+ const a = (r.sources ?? []).reduce((i, f) => i + (f.subtotal ?? 0), 0);
214
+ return (r.sources ?? []).some((i) => i.truncated) ? null : Math.abs(a - d) < 0.01 ? /* @__PURE__ */ n("span", { className: "ml-1 text-emerald-600 dark:text-emerald-400", children: "✓ matches" }) : /* @__PURE__ */ n("span", { className: "ml-1 text-amber-600 dark:text-amber-400", children: "✕ differs from contributions" });
208
215
  })()
209
216
  ] })
210
217
  ] })
211
218
  ] });
212
219
  }
213
- function Hn({
214
- collection: m,
220
+ function dr({
221
+ collection: p,
215
222
  itemId: e,
216
- field: i,
223
+ field: s,
217
224
  formatValue: h,
218
225
  onRestore: x
219
226
  }) {
220
- const d = ie(), [l, w] = ke(!1), g = L(null), { data: p, isLoading: a } = le({
221
- queryKey: ["field-value-history", m, e, i],
222
- queryFn: () => d.request(U(`/field-history/${m}/${encodeURIComponent(e)}/${i}`)).then((o) => o.data ?? []),
223
- enabled: l,
227
+ const c = ue(), [r, w] = Le(!1), g = L(null), { data: d, isLoading: a } = se({
228
+ queryKey: ["field-value-history", p, e, s],
229
+ queryFn: () => c.request(z(`/field-history/${p}/${encodeURIComponent(e)}/${s}`)).then((i) => i.data ?? []),
230
+ enabled: r,
224
231
  staleTime: 6e4
225
232
  });
226
- oe(() => {
227
- if (!l) return;
228
- const o = (f) => {
229
- var W;
230
- (W = g.current) != null && W.contains(f.target) || w(!1);
233
+ ce(() => {
234
+ if (!r) return;
235
+ const i = (f) => {
236
+ var Q;
237
+ (Q = g.current) != null && Q.contains(f.target) || w(!1);
231
238
  };
232
- return window.addEventListener("mousedown", o), () => window.removeEventListener("mousedown", o);
233
- }, [l]);
234
- const b = (o, f) => f || (o == null || o === "" ? "—" : h ? h(o) : typeof o == "boolean" || o === "true" || o === "false" ? o === !0 || o === "true" ? "Yes" : "No" : typeof o == "string" && /^\d{4}-\d{2}-\d{2}$/.test(o) ? Wt(o) : typeof o == "string" && /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/.test(o) ? we(o) : typeof o == "object" ? JSON.stringify(o).slice(0, 60) : String(o).slice(0, 80));
235
- return /* @__PURE__ */ u("div", { ref: g, className: "relative inline-flex", children: [
239
+ return window.addEventListener("mousedown", i), () => window.removeEventListener("mousedown", i);
240
+ }, [r]);
241
+ const b = (i, f) => f || (i == null || i === "" ? "—" : h ? h(i) : typeof i == "boolean" || i === "true" || i === "false" ? i === !0 || i === "true" ? "Yes" : "No" : typeof i == "string" && /^\d{4}-\d{2}-\d{2}$/.test(i) ? ln(i) : typeof i == "string" && /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/.test(i) ? Re(i) : typeof i == "object" ? JSON.stringify(i).slice(0, 60) : String(i).slice(0, 80));
242
+ return /* @__PURE__ */ m("div", { ref: g, className: "relative inline-flex", children: [
236
243
  /* @__PURE__ */ n(
237
244
  "button",
238
245
  {
239
246
  type: "button",
240
- onClick: () => w((o) => !o),
247
+ onClick: () => w((i) => !i),
241
248
  title: "Value history",
242
- className: D(
249
+ className: B(
243
250
  "inline-flex items-center rounded p-0.5 transition-opacity",
244
- l ? "text-nvr-cyan opacity-100" : "text-slate-400 hover:text-nvr-cyan dark:text-slate-300 dark:hover:text-nvr-cyan"
251
+ r ? "text-nvr-cyan opacity-100" : "text-slate-400 hover:text-nvr-cyan dark:text-slate-300 dark:hover:text-nvr-cyan"
245
252
  ),
246
253
  "data-field-history": !0,
247
- children: /* @__PURE__ */ n(At, { className: "h-3 w-3" })
254
+ children: /* @__PURE__ */ n(Vt, { className: "h-3 w-3" })
248
255
  }
249
256
  ),
250
- l && /* @__PURE__ */ u("div", { className: "absolute left-0 top-full z-40 mt-1 max-h-64 w-[300px] overflow-y-auto rounded-lg border border-slate-200 bg-white p-2 shadow-lg dark:border-border dark:bg-card", children: [
257
+ r && /* @__PURE__ */ m("div", { className: "absolute left-0 top-full z-40 mt-1 max-h-64 w-[300px] overflow-y-auto rounded-lg border border-slate-200 bg-white p-2 shadow-lg dark:border-border dark:bg-card", children: [
251
258
  /* @__PURE__ */ n("p", { className: "mb-1 px-1 text-[10px] font-semibold uppercase tracking-wide text-slate-400", children: "Value history" }),
252
- a ? /* @__PURE__ */ n("p", { className: "px-1 py-2 text-[11.5px] text-slate-400", children: "Loading…" }) : (p ?? []).length === 0 ? /* @__PURE__ */ n("p", { className: "px-1 py-2 text-[11.5px] text-slate-400", children: "No recorded changes for this field." }) : /* @__PURE__ */ n("div", { className: "space-y-1", children: (p ?? []).map((o, f) => /* @__PURE__ */ u(
259
+ a ? /* @__PURE__ */ n("p", { className: "px-1 py-2 text-[11.5px] text-slate-400", children: "Loading…" }) : (d ?? []).length === 0 ? /* @__PURE__ */ n("p", { className: "px-1 py-2 text-[11.5px] text-slate-400", children: "No recorded changes for this field." }) : /* @__PURE__ */ n("div", { className: "space-y-1", children: (d ?? []).map((i, f) => /* @__PURE__ */ m(
253
260
  "div",
254
261
  {
255
262
  className: "rounded px-1 py-1 text-[11.5px] leading-snug hover:bg-slate-50 dark:hover:bg-muted",
256
263
  children: [
257
- /* @__PURE__ */ u("span", { className: "flex items-baseline justify-between gap-2", children: [
258
- /* @__PURE__ */ n("span", { className: "font-medium text-slate-700 dark:text-slate-200", children: b(o.value, o.display) }),
264
+ /* @__PURE__ */ m("span", { className: "flex items-baseline justify-between gap-2", children: [
265
+ /* @__PURE__ */ n("span", { className: "font-medium text-slate-700 dark:text-slate-200", children: b(i.value, i.display) }),
259
266
  x && f > 0 && /* @__PURE__ */ n(
260
267
  "button",
261
268
  {
262
269
  type: "button",
263
270
  onClick: () => {
264
- x(o.value ?? null), w(!1);
271
+ x(i.value ?? null), w(!1);
265
272
  },
266
273
  className: "shrink-0 rounded border border-slate-200 px-1.5 py-px text-[10px] text-slate-500 hover:border-nvr-cyan/60 hover:text-nvr-navy dark:border-border dark:hover:text-nvr-cyan",
267
274
  children: "Restore"
268
275
  }
269
276
  )
270
277
  ] }),
271
- /* @__PURE__ */ u("span", { className: "block text-[10.5px] text-slate-400", children: [
272
- o.action === "create" ? "initial value" : "changed",
273
- o.timestamp ? ` · ${we(o.timestamp)}` : "",
274
- o.user_name ? ` · ${o.user_name}` : "",
275
- o.origin && o.origin.kind !== "user" && /* @__PURE__ */ n(
278
+ /* @__PURE__ */ m("span", { className: "block text-[10.5px] text-slate-400", children: [
279
+ i.action === "create" ? "initial value" : "changed",
280
+ i.timestamp ? ` · ${Re(i.timestamp)}` : "",
281
+ i.user_name ? ` · ${i.user_name}` : "",
282
+ i.origin && i.origin.kind !== "user" && /* @__PURE__ */ n(
276
283
  "span",
277
284
  {
278
- className: o.origin.kind === "integration" ? "ml-1 rounded bg-purple-500/10 px-1 py-px text-[9.5px] font-medium text-purple-700 dark:text-purple-400" : o.origin.kind === "import" ? "ml-1 rounded bg-sky-500/10 px-1 py-px text-[9.5px] font-medium text-sky-700 dark:text-sky-400" : "ml-1 rounded bg-amber-500/10 px-1 py-px text-[9.5px] font-medium text-amber-700 dark:text-amber-400",
279
- children: o.origin.label ?? o.origin.kind
285
+ className: i.origin.kind === "integration" ? "ml-1 rounded bg-purple-500/10 px-1 py-px text-[9.5px] font-medium text-purple-700 dark:text-purple-400" : i.origin.kind === "import" ? "ml-1 rounded bg-sky-500/10 px-1 py-px text-[9.5px] font-medium text-sky-700 dark:text-sky-400" : "ml-1 rounded bg-amber-500/10 px-1 py-px text-[9.5px] font-medium text-amber-700 dark:text-amber-400",
286
+ children: i.origin.label ?? i.origin.kind
280
287
  }
281
288
  )
282
289
  ] }),
283
- o.note && /* @__PURE__ */ u("span", { className: "block text-[10.5px] italic text-slate-500 dark:text-slate-400", children: [
290
+ i.note && /* @__PURE__ */ m("span", { className: "block text-[10.5px] italic text-slate-500 dark:text-slate-400", children: [
284
291
  "“",
285
- o.note,
292
+ i.note,
286
293
  "”"
287
294
  ] })
288
295
  ]
@@ -292,379 +299,403 @@ function Hn({
292
299
  ] })
293
300
  ] });
294
301
  }
295
- function Kn({
296
- collection: m,
302
+ function ur({
303
+ collection: p,
297
304
  itemId: e,
298
- field: i
305
+ field: s
299
306
  }) {
300
- const h = ie(), x = nt(), { data: d } = le({
307
+ const h = ue(), x = at(), { data: c } = se({
301
308
  queryKey: ["field-watch-config"],
302
- queryFn: () => h.request(U("/field-watches/config")).then((a) => a.data).catch(() => ({ enabled: !1 })),
309
+ queryFn: () => h.request(z("/field-watches/config")).then((a) => a.data).catch(() => ({ enabled: !1 })),
303
310
  staleTime: 5 * 6e4
304
- }), l = ["field-watch-self", m, e], { data: w = [] } = le({
305
- queryKey: l,
306
- queryFn: () => h.request(U("/field-watches/self", { collection: m, item_id: e })).then((a) => a.data ?? []).catch(() => []),
307
- enabled: !!(d != null && d.enabled),
311
+ }), r = ["field-watch-self", p, e], { data: w = [] } = se({
312
+ queryKey: r,
313
+ queryFn: () => h.request(z("/field-watches/self", { collection: p, item_id: e })).then((a) => a.data ?? []).catch(() => []),
314
+ enabled: !!(c != null && c.enabled),
308
315
  staleTime: 6e4
309
- }), g = w.includes(i), p = Ct({
316
+ }), g = w.includes(s), d = Mt({
310
317
  mutationFn: () => g ? h.request(
311
- Kt(
312
- `/field-watches/self?collection=${encodeURIComponent(m)}&field=${encodeURIComponent(i)}&item_id=${encodeURIComponent(e)}`
318
+ nn(
319
+ `/field-watches/self?collection=${encodeURIComponent(p)}&field=${encodeURIComponent(s)}&item_id=${encodeURIComponent(e)}`
313
320
  )
314
- ) : h.request(ve("/field-watches/self", { collection: m, field: i, item_id: e })),
321
+ ) : h.request(Ce("/field-watches/self", { collection: p, field: s, item_id: e })),
315
322
  onSuccess: () => {
316
- x.invalidateQueries({ queryKey: l }), ae.success(
323
+ x.invalidateQueries({ queryKey: r }), de.success(
317
324
  g ? "No longer watching this field" : "Watching — you will be notified when it changes"
318
325
  );
319
326
  },
320
- onError: () => ae.error("Could not update the watch")
327
+ onError: () => de.error("Could not update the watch")
321
328
  });
322
- return d != null && d.enabled ? /* @__PURE__ */ n(
329
+ return c != null && c.enabled ? /* @__PURE__ */ n(
323
330
  "button",
324
331
  {
325
332
  type: "button",
326
- onClick: () => p.mutate(),
333
+ onClick: () => d.mutate(),
327
334
  title: g ? "Stop watching this field on this record" : "Watch this field on this record",
328
- "data-field-watch": i,
335
+ "data-field-watch": s,
329
336
  className: `rounded p-0.5 transition-colors ${g ? "text-nvr-navy dark:text-nvr-cyan" : "text-slate-300 hover:text-slate-500"}`,
330
- children: g ? /* @__PURE__ */ n(Tt, { className: "h-3 w-3" }) : /* @__PURE__ */ n(Et, { className: "h-3 w-3" })
337
+ children: g ? /* @__PURE__ */ n(zt, { className: "h-3 w-3" }) : /* @__PURE__ */ n(Qt, { className: "h-3 w-3" })
331
338
  }
332
339
  ) : null;
333
340
  }
334
- const Fr = jt(function({
341
+ const to = Yt(function({
335
342
  field: e,
336
- draft: i,
343
+ draft: s,
337
344
  onChange: h,
338
345
  relations: x,
339
- collection: d,
340
- itemId: l,
346
+ collection: c,
347
+ itemId: r,
341
348
  error: w,
342
349
  visible: g,
343
- locked: p,
350
+ locked: d,
344
351
  layoutAiEnabled: a,
345
352
  renderField: b,
346
- onCountChange: o,
353
+ onCountChange: i,
347
354
  swapButton: f,
348
- swapContent: W,
349
- forceVisible: rt,
350
- autoFillTick: se
355
+ swapContent: Q,
356
+ forceVisible: st,
357
+ autoFillTick: me
351
358
  }) {
352
- var We, Ve, ze, Ge, Qe;
353
- const V = jn.has(e.interface ?? ""), N = Dt(), y = xn(), _e = nt(), de = ie(), [Ne, z] = ke(!1), s = Zt(), ce = Jt(), Fe = Vt(e.field), G = L(null), P = Bt(), ue = L(null), Ce = L(!1), Re = L({
359
+ var Qe, Ge, Ye, Je, Xe, Ze;
360
+ const G = ir.has(e.interface ?? ""), _ = Xt(), y = Pn(), Se = at(), pe = ue(), [$e, Y] = Le(!1), l = yn(), he = mn(), Te = an(e.field), J = L(null), M = Jt(), fe = L(null), qe = L(!1), Ae = L({
354
361
  required: !1,
355
362
  hasError: !1
356
363
  });
357
- oe(() => {
358
- const t = Ce.current ? sn(ue.current) : null;
359
- if (!t || (dn(t, { ...Re.current, errorId: `${P}-error` }), t.hasAttribute("aria-label"))) return;
360
- t.id || (t.id = `${P}-control`);
361
- const r = t.tagName === "BUTTON" ? `${P} ${t.id}` : P;
362
- t.getAttribute("aria-labelledby") !== r && t.setAttribute("aria-labelledby", r);
364
+ ce(() => {
365
+ const t = qe.current ? Cn(fe.current) : null;
366
+ if (!t || (Rn(t, { ...Ae.current, errorId: `${M}-error` }), t.hasAttribute("aria-label"))) return;
367
+ t.id || (t.id = `${M}-control`);
368
+ const o = t.tagName === "BUTTON" ? `${M} ${t.id}` : M;
369
+ t.getAttribute("aria-labelledby") !== o && t.setAttribute("aria-labelledby", o);
363
370
  });
364
- const Le = p && !V, Se = L(null);
365
- oe(() => {
366
- const t = Se.current;
371
+ const Pe = d && !G, Ee = L(null);
372
+ ce(() => {
373
+ const t = Ee.current;
367
374
  if (!t) return;
368
- if (!Le) {
375
+ if (!Pe) {
369
376
  t.removeAttribute("inert");
370
377
  return;
371
378
  }
372
- const r = typeof document < "u" ? document.activeElement : null;
373
- r instanceof HTMLElement && t.contains(r) && r.blur(), t.setAttribute("inert", "");
374
- }, [Le, se]);
375
- const Q = e.field, $e = Je(
379
+ const o = typeof document < "u" ? document.activeElement : null;
380
+ o instanceof HTMLElement && t.contains(o) && o.blur(), t.setAttribute("inert", "");
381
+ }, [Pe, me]);
382
+ const X = e.field, je = et(
376
383
  (t) => {
377
- p || h(Q, t);
384
+ d || h(X, t);
378
385
  },
379
- [p, h, Q]
380
- ), lt = Je(
381
- (t) => o == null ? void 0 : o(Q, t),
382
- [o, Q]
383
- ), ot = L(void 0), qe = L(void 0), Ae = L(void 0), Te = !p && !e.readonly && !e.computed_formula && !(e.hidden && !e.layout_assigned) && !et(e), {
384
- onContextMenu: at,
385
- onKeyDown: it,
386
- menu: st,
387
- confirmSaveFrom: dt,
388
- openedBy: me
389
- } = It({
390
- wrapperRef: G,
386
+ [d, h, X]
387
+ ), ct = et(
388
+ (t) => i == null ? void 0 : i(X, t),
389
+ [i, X]
390
+ ), dt = L(void 0), Be = L(void 0), Me = L(void 0), De = !d && !e.readonly && !e.computed_formula && !(e.hidden && !e.layout_assigned) && !it(e), {
391
+ onContextMenu: ut,
392
+ onKeyDown: mt,
393
+ menu: pt,
394
+ openFrom: ht,
395
+ isOpen: ft,
396
+ confirmSaveFrom: xt,
397
+ openedBy: xe
398
+ } = bn({
399
+ wrapperRef: J,
391
400
  field: e,
392
- value: i[e.field],
401
+ value: s[e.field],
393
402
  relations: x,
394
- collection: d,
395
- itemId: l,
396
- openRelated: s == null ? void 0 : s.openRelated,
397
- editable: Te
398
- }), j = en(G), ct = vn(), Ee = s == null ? void 0 : s.remoteChanges[e.field], M = s == null ? void 0 : s.lockReasons[e.field], T = s == null ? void 0 : s.applyToLines[e.field], Pe = (We = s == null ? void 0 : s.duplicates) == null ? void 0 : We[e.field], R = qn(), ut = (R == null ? void 0 : R.applied(e.field)) ?? !1, je = (R == null ? void 0 : R.hintFor(e.field)) ?? null, pe = yn(R, e.field, Te), he = () => {
399
- var t, r;
400
- return ((t = ue.current) == null ? void 0 : t.querySelector(Ie)) ?? ((r = G.current) == null ? void 0 : r.querySelector(Ie));
401
- }, Y = Mt(e._overrides, a, Bn(e)), fe = !!(s != null && s.fromAutofill) && !!e._overrides && e._overrides[Ot] === !0;
402
- async function mt() {
403
+ collection: c,
404
+ itemId: r,
405
+ openRelated: l == null ? void 0 : l.openRelated,
406
+ editable: De
407
+ }), yt = on(), bt = pn(c, r, e.field), D = gn(J, {
408
+ off: !!yt && !!bt && hn(e)
409
+ }), ye = tn(c, r && r !== "new" ? r : null), gt = On(), S = l == null ? void 0 : l.remoteChanges[e.field], K = l == null ? void 0 : l.lockReasons[e.field], P = l == null ? void 0 : l.applyToLines[e.field], He = (Qe = l == null ? void 0 : l.duplicates) == null ? void 0 : Qe[e.field], H = Mn(), Z = H == null ? void 0 : H.fields[e.field], vt = H == null ? void 0 : H.hints[e.field], R = er(), wt = (R == null ? void 0 : R.applied(e.field)) ?? !1, Oe = (R == null ? void 0 : R.hintFor(e.field)) ?? null, be = En(R, e.field, De), ge = () => {
410
+ var t, o;
411
+ return ((t = fe.current) == null ? void 0 : t.querySelector(rt)) ?? ((o = J.current) == null ? void 0 : o.querySelector(rt));
412
+ }, I = Zt(e._overrides, a, lr(e)), ve = !!(l != null && l.fromAutofill) && !!e._overrides && e._overrides[It] === !0;
413
+ async function kt() {
403
414
  var t;
404
- if (Y.perField) return pt();
405
- z(!0);
415
+ if (I.perField) return Nt();
416
+ Y(!0);
406
417
  try {
407
- const r = await de.request(
408
- ve("/ai/generate", {
409
- collection: d,
410
- item_id: l !== "new" ? l : void 0,
418
+ const o = await pe.request(
419
+ Ce("/ai/generate", {
420
+ collection: c,
421
+ item_id: r !== "new" ? r : void 0,
411
422
  field: e.field
412
423
  })
413
424
  );
414
- ((t = r.data) == null ? void 0 : t.value) != null && h(e.field, r.data.value);
425
+ ((t = o.data) == null ? void 0 : t.value) != null && h(e.field, o.data.value);
415
426
  } catch {
416
427
  } finally {
417
- z(!1);
428
+ Y(!1);
418
429
  }
419
430
  }
420
- async function pt() {
421
- var r, c, k, S;
431
+ async function Nt() {
432
+ var o, u, k, T;
422
433
  const t = {};
423
- for (const _ of ((r = Ht(e._overrides)) == null ? void 0 : r.tokens) ?? []) _ in i && (t[_] = i[_]);
424
- z(!0);
434
+ for (const N of ((o = en(e._overrides)) == null ? void 0 : o.tokens) ?? []) N in s && (t[N] = s[N]);
435
+ Y(!0);
425
436
  try {
426
- const _ = await de.request(
427
- ve("/ai/field-fill", {
428
- collection: d,
429
- layout_id: (s == null ? void 0 : s.layoutId) ?? null,
437
+ const N = await pe.request(
438
+ Ce("/ai/field-fill", {
439
+ collection: c,
440
+ layout_id: (l == null ? void 0 : l.layoutId) ?? null,
430
441
  field: e.field,
431
- item_id: l && l !== "new" ? l : null,
442
+ item_id: r && r !== "new" ? r : null,
432
443
  values: t
433
444
  })
434
- ), F = (c = _.data) == null ? void 0 : c.value;
435
- typeof F == "string" && F !== "" ? h(e.field, F) : ae.info("The AI had nothing to write here"), (S = (k = _.data) == null ? void 0 : k.missing) != null && S.length && ae.info(`Filled without ${_.data.missing.join(", ")} (empty or not visible to you)`);
436
- } catch (_) {
437
- Ut(_, "AI fill failed", { action: "Fill with AI" });
445
+ ), C = (u = N.data) == null ? void 0 : u.value;
446
+ typeof C == "string" && C !== "" ? h(e.field, C) : de.info("The AI had nothing to write here"), (T = (k = N.data) == null ? void 0 : k.missing) != null && T.length && de.info(`Filled without ${N.data.missing.join(", ")} (empty or not visible to you)`);
447
+ } catch (N) {
448
+ rn(N, "AI fill failed", { action: "Fill with AI" });
438
449
  } finally {
439
- z(!1);
450
+ Y(!1);
440
451
  }
441
452
  }
442
- const E = cn(e.dependency_config), Be = E.flatMap((t) => {
443
- const r = x.find(
444
- (k) => k.one_collection === d && k.one_field === t.parent_field
453
+ const E = Ln(e.dependency_config), Ke = E.flatMap((t) => {
454
+ const o = x.find(
455
+ (k) => k.one_collection === c && k.one_field === t.parent_field
445
456
  );
446
- if (!r) return [];
447
- if (r.junction_field) return [{ rule: t, rel: r }];
448
- const c = x.find(
449
- (k) => k.many_collection === r.many_collection && k.id !== r.id
457
+ if (!o) return [];
458
+ if (o.junction_field) return [{ rule: t, rel: o }];
459
+ const u = x.find(
460
+ (k) => k.many_collection === o.many_collection && k.id !== o.id
450
461
  );
451
- return c != null && c.many_field ? [{ rule: t, rel: { ...r, junction_field: c.many_field } }] : [];
452
- }), ht = Ft({
453
- queries: Be.map(({ rel: t }) => ({
454
- queryKey: ["m2m-items", t.many_collection, t.many_field, l],
455
- queryFn: () => de.request(
456
- U(`/items/${t.many_collection}`, {
457
- filter: JSON.stringify({ [t.many_field]: { _eq: l } }),
462
+ return u != null && u.many_field ? [{ rule: t, rel: { ...o, junction_field: u.many_field } }] : [];
463
+ }), _t = Bt({
464
+ queries: Ke.map(({ rel: t }) => ({
465
+ queryKey: ["m2m-items", t.many_collection, t.many_field, r],
466
+ queryFn: () => pe.request(
467
+ z(`/items/${t.many_collection}`, {
468
+ filter: JSON.stringify({ [t.many_field]: { _eq: r } }),
458
469
  limit: 200,
459
470
  fields: `id,${t.junction_field}`
460
471
  })
461
- ).then((r) => r.data ?? []),
462
- enabled: !!l && l !== "new",
472
+ ).then((o) => o.data ?? []),
473
+ enabled: !!r && r !== "new",
463
474
  staleTime: 3e4
464
475
  }))
465
- }), ft = Object.fromEntries(
466
- Be.map(({ rule: t, rel: r }, c) => {
467
- var _;
468
- const k = r.one_field ?? `${r.many_collection}.${r.junction_field}`, S = (y == null ? void 0 : y.getStagedUnlinks(k)) ?? /* @__PURE__ */ new Set();
476
+ }), Ft = Object.fromEntries(
477
+ Ke.map(({ rule: t, rel: o }, u) => {
478
+ var N;
479
+ const k = o.one_field ?? `${o.many_collection}.${o.junction_field}`, T = (y == null ? void 0 : y.getStagedUnlinks(k)) ?? /* @__PURE__ */ new Set();
469
480
  return [
470
481
  t.parent_field,
471
- (((_ = ht[c]) == null ? void 0 : _.data) ?? []).filter((F) => !S.has(F.id)).map((F) => F[r.junction_field])
482
+ (((N = _t[u]) == null ? void 0 : N.data) ?? []).filter((C) => !T.has(C.id)).map((C) => C[o.junction_field])
472
483
  ];
473
484
  })
474
- ), J = Qt()[e.field] ?? [];
475
- if (!rt && (!g || !e.layout_assigned && (e.hidden || un.has(e.field))))
485
+ ), ee = dn()[e.field] ?? [];
486
+ if (!st && (!g || !e.layout_assigned && (e.hidden || Sn.has(e.field))))
476
487
  return null;
477
- const xe = i[e.field] ?? null, X = wn(e, ct), C = X.label ?? K(e.field);
478
- Ce.current = C !== "", Re.current = {
479
- required: !!(e.required || Xe(e.validation_rules, i)),
488
+ const U = s[e.field] ?? null, te = Kn(e, gt), F = te.label ?? j(e.field);
489
+ qe.current = F !== "", Ae.current = {
490
+ required: !!(e.required || tt(e.validation_rules, s)),
480
491
  hasError: !!w
481
492
  };
482
- const q = et(e), De = q ? null : kn(e), Me = q || !(l === "new" || !l || (Ve = N == null ? void 0 : N.dirtyFields) != null && Ve.has(e.field)) ? null : $n(e, i), xt = !q && !p && !e.readonly && ((ze = e._overrides) == null ? void 0 : ze.repeat_last) === !0, yt = fn(e, i), bt = (Qe = (Ge = mn(e.options)) == null ? void 0 : Ge.auto_id) == null ? void 0 : Qe.pattern, v = (() => {
493
+ const $ = it(e), Ue = $ ? null : Un(e), We = $ || !(r === "new" || !r || (Ge = _ == null ? void 0 : _.dirtyFields) != null && Ge.has(e.field)) ? null : In(e, s), Ct = !$ && !d && !e.readonly && ((Ye = e._overrides) == null ? void 0 : Ye.repeat_last) === !0, Rt = An(e, s), Lt = (Xe = (Je = $n(e.options)) == null ? void 0 : Je.auto_id) == null ? void 0 : Xe.pattern, v = (() => {
483
494
  const t = x.find(
484
- (c) => c.one_collection === d && c.one_field === e.field
495
+ (u) => u.one_collection === c && u.one_field === e.field
485
496
  );
486
497
  if (!t) return null;
487
498
  if (t.junction_field) return t;
488
- const r = x.find(
489
- (c) => c.many_collection === t.many_collection && c.id !== t.id
499
+ const o = x.find(
500
+ (u) => u.many_collection === t.many_collection && u.id !== t.id
490
501
  );
491
- return r ? { ...t, junction_field: r.many_field } : null;
492
- })(), ye = v ? null : x.find((t) => t.many_collection === d && t.many_field === e.field) ?? null, be = v ? x.find(
502
+ return o ? { ...t, junction_field: o.many_field } : null;
503
+ })(), we = v ? null : x.find((t) => t.many_collection === c && t.many_field === e.field) ?? null, ke = v ? x.find(
493
504
  (t) => t.many_collection === v.many_collection && t.many_field === v.junction_field && t.id !== v.id
494
- ) ?? null : null, B = v ? v.one_field ?? `${v.many_collection}.${v.junction_field}` : null, Oe = B ? (y == null ? void 0 : y.getStagedLinks(B)) ?? [] : [], gt = v ? (_e.getQueryData([
505
+ ) ?? null : null, O = v ? v.one_field ?? `${v.many_collection}.${v.junction_field}` : null, Ne = O ? (y == null ? void 0 : y.getStagedLinks(O)) ?? [] : [], St = v ? (Se.getQueryData([
495
506
  "m2m-items",
496
507
  v.many_collection,
497
508
  v.many_field,
498
- l
499
- ]) ?? []).map((t) => t[v.junction_field]) : [], He = v ? Oe[0] ?? gt[0] ?? null : xe, Ke = (be == null ? void 0 : be.one_collection) ?? (ye == null ? void 0 : ye.one_collection) ?? void 0, Z = (t) => {
500
- var r;
501
- return ((N == null ? void 0 : N.collection) === d ? (r = N == null ? void 0 : N.fieldLabels) == null ? void 0 : r[t] : void 0) ?? K(String(t));
502
- }, A = pn({
509
+ r
510
+ ]) ?? []).map((t) => t[v.junction_field]) : [], Ve = v ? Ne[0] ?? St[0] ?? null : U, _e = (ke == null ? void 0 : ke.one_collection) ?? (we == null ? void 0 : we.one_collection) ?? void 0, $t = !!Z && !d && !e.readonly && (v ? !(Z.filled || Ne.length > 0) : ot(U)), Tt = !!vt && !d && ot(U), ne = (t) => {
511
+ var o;
512
+ return ((_ == null ? void 0 : _.collection) === c ? (o = _ == null ? void 0 : _.fieldLabels) == null ? void 0 : o[t] : void 0) ?? j(String(t));
513
+ }, A = Tn({
503
514
  rules: E,
504
515
  // A parent whose value THIS field's own pick derived must not narrow this
505
516
  // field's options — otherwise picking a region locks the region picker
506
517
  // into the zone the pick itself filled, and cross-zone changes read as
507
518
  // "No results".
508
519
  skipParent: (t) => {
509
- var r;
510
- return ((r = y == null ? void 0 : y.getDerivedOrigin) == null ? void 0 : r.call(y, t)) === e.field;
520
+ var o;
521
+ return ((o = y == null ? void 0 : y.getDerivedOrigin) == null ? void 0 : o.call(y, t)) === e.field;
511
522
  },
512
523
  parentValue: (t) => {
513
- if (i[t] != null) return i[t];
514
- const r = x.find(($) => $.one_collection === d && $.one_field === t);
515
- if (!r) return null;
516
- let c = r;
517
- if (!c.junction_field) {
518
- const $ = x.find(
519
- (Ye) => Ye.many_collection === r.many_collection && Ye.id !== r.id
524
+ if (s[t] != null) return s[t];
525
+ const o = x.find((q) => q.one_collection === c && q.one_field === t);
526
+ if (!o) return null;
527
+ let u = o;
528
+ if (!u.junction_field) {
529
+ const q = x.find(
530
+ (Ie) => Ie.many_collection === o.many_collection && Ie.id !== o.id
520
531
  );
521
- if ($ != null && $.many_field) c = { ...r, junction_field: $.many_field };
532
+ if (q != null && q.many_field) u = { ...o, junction_field: q.many_field };
522
533
  else return null;
523
534
  }
524
- const k = c.one_field ?? `${c.many_collection}.${c.junction_field}`, S = (y == null ? void 0 : y.getStagedLinks(k)) ?? [], _ = ft[t] ?? [], F = [...new Set([...S, ..._].map(($) => String($)))];
525
- return F.length === 0 ? null : F.length === 1 ? F[0] : F;
535
+ const k = u.one_field ?? `${u.many_collection}.${u.junction_field}`, T = (y == null ? void 0 : y.getStagedLinks(k)) ?? [], N = Ft[t] ?? [], C = [...new Set([...T, ...N].map((q) => String(q)))];
536
+ return C.length === 0 ? null : C.length === 1 ? C[0] : C;
526
537
  },
527
538
  parentOptionFilter: (t) => {
528
- var c;
529
- const r = (N == null ? void 0 : N.collection) === d ? (c = N.fieldOptionFilters) == null ? void 0 : c[t] : void 0;
530
- return r ? An(r, i, l) : void 0;
539
+ var u;
540
+ const o = (_ == null ? void 0 : _.collection) === c ? (u = _.fieldOptionFilters) == null ? void 0 : u[t] : void 0;
541
+ return o ? tr(o, s, r) : void 0;
531
542
  }
532
- }), O = A.filter ? Ln(ot, A.filter, Sn) : A.filter, H = A.satisfiedParents.map(Z), I = A.satisfiedParents, vt = A.unsatisfiedParents.length ? Z(A.unsatisfiedParents[0]) : null, ge = A.missingRequiredParents, Ue = ge.length ? Z(ge[0]) : null;
533
- function wt() {
534
- const t = Ae.current;
543
+ }), W = A.filter ? Xn(dt, A.filter, Zn) : A.filter, V = A.satisfiedParents.map(ne), re = A.satisfiedParents, qt = A.unsatisfiedParents.length ? ne(A.unsatisfiedParents[0]) : null, Fe = A.missingRequiredParents, ze = Fe.length ? ne(Fe[0]) : null;
544
+ function At() {
545
+ const t = Me.current;
535
546
  if (t && t.src === e) return t.value;
536
- const r = { ...e, readonly: !0 };
537
- return Ae.current = { src: e, value: r }, r;
547
+ const o = { ...e, readonly: !0 };
548
+ return Me.current = { src: e, value: o }, o;
538
549
  }
539
- function kt() {
540
- const t = Dn(
541
- I,
550
+ function Pt() {
551
+ const t = ar(
552
+ re,
542
553
  e.field,
543
554
  y == null ? void 0 : y.getDerivedOrigin
544
- ), r = JSON.stringify([H, I, t]), c = qe.current;
545
- if (c && c.sig === r && c.onChange === h) return c.value;
555
+ ), o = JSON.stringify([V, re, t]), u = Be.current;
556
+ if (u && u.sig === o && u.onChange === h) return u.value;
546
557
  const k = {
547
- labels: H,
548
- keys: I,
558
+ labels: V,
559
+ keys: re,
549
560
  clearable: t,
550
- onClear: t.length > 0 ? (S) => {
551
- t.includes(S) && h(S, null);
561
+ onClear: t.length > 0 ? (T) => {
562
+ t.includes(T) && h(T, null);
552
563
  } : void 0
553
564
  };
554
- return qe.current = { sig: r, onChange: h, value: k }, k;
565
+ return Be.current = { sig: o, onChange: h, value: k }, k;
555
566
  }
556
- function _t() {
557
- for (const t of I) {
558
- const r = document.querySelector(`[data-field="${t}"]`);
559
- r && (r.scrollIntoView({ behavior: "smooth", block: "center" }), r.style.transition = "box-shadow 0.15s ease", r.style.boxShadow = "0 0 0 2px rgb(var(--nvr-cyan-rgb, 0 206 255)), 0 0 0 5px rgb(var(--nvr-cyan-rgb, 0 206 255) / 0.25)", r.style.borderRadius = "12px", setTimeout(() => {
560
- r.style.boxShadow = "none", setTimeout(() => {
561
- r.style.transition = "", r.style.borderRadius = "";
567
+ function Et() {
568
+ for (const t of re) {
569
+ const o = document.querySelector(`[data-field="${t}"]`);
570
+ o && (o.scrollIntoView({ behavior: "smooth", block: "center" }), o.style.transition = "box-shadow 0.15s ease", o.style.boxShadow = "0 0 0 2px rgb(var(--nvr-cyan-rgb, 0 206 255)), 0 0 0 5px rgb(var(--nvr-cyan-rgb, 0 206 255) / 0.25)", o.style.borderRadius = "12px", setTimeout(() => {
571
+ o.style.boxShadow = "none", setTimeout(() => {
572
+ o.style.transition = "", o.style.borderRadius = "";
562
573
  }, 300);
563
574
  }, 900));
564
575
  }
565
576
  }
566
- const Nt = () => {
567
- const t = v && B ? He : i[e.field];
568
- if (t != null && t !== "" && !(Array.isArray(t) && !t.length) && (ce == null || ce({
577
+ const jt = () => {
578
+ const t = v && O ? Ve : s[e.field];
579
+ if (t != null && t !== "" && !(Array.isArray(t) && !t.length) && (he == null || he({
569
580
  field: e.field,
570
- label: C || K(e.field),
571
- parents: E.map((r) => r.parent_field).filter(Boolean)
572
- })), v && B) {
573
- for (const c of Oe) y == null || y.unstageLink(B, c);
574
- const r = _e.getQueryData([
581
+ label: F || j(e.field),
582
+ parents: E.map((o) => o.parent_field).filter(Boolean)
583
+ })), v && O) {
584
+ for (const u of Ne) y == null || y.unstageLink(O, u);
585
+ const o = Se.getQueryData([
575
586
  "m2m-items",
576
587
  v.many_collection,
577
588
  v.many_field,
578
- l
589
+ r
579
590
  ]) ?? [];
580
- for (const c of r) y == null || y.stageUnlink(B, c.id);
591
+ for (const u of o) y == null || y.stageUnlink(O, u.id);
581
592
  } else
582
593
  h(e.field, null);
583
594
  };
584
595
  return (
585
596
  // biome-ignore lint/a11y/noStaticElementInteractions: the wrapper only hosts the field context menu (right-click / Shift+F10); the inputs inside stay the controls
586
- /* @__PURE__ */ u(
597
+ /* @__PURE__ */ m(
587
598
  "div",
588
599
  {
589
- ref: G,
600
+ ref: J,
590
601
  "data-field": e.field,
591
- "data-field-collection": d,
602
+ "data-field-collection": c,
592
603
  "data-field-interface": e.interface ?? void 0,
593
- "data-autofill-check": fe ? "" : void 0,
594
- className: D(
604
+ "data-autofill-check": ve ? "" : void 0,
605
+ className: B(
595
606
  "group/fieldrow space-y-1.5",
596
- fe && "rounded-md bg-amber-50/60 p-1.5 ring-1 ring-amber-300 dark:bg-amber-500/10 dark:ring-amber-500/40"
607
+ ve && "rounded-md bg-amber-50/60 p-1.5 ring-1 ring-amber-300 dark:bg-amber-500/10 dark:ring-amber-500/40"
597
608
  ),
598
- onContextMenu: at,
599
- onKeyDown: it,
600
- onFocusCapture: j.onFocusCapture,
609
+ onContextMenu: ut,
610
+ onKeyDown: mt,
611
+ onFocusCapture: D.onFocusCapture,
601
612
  children: [
602
- st,
613
+ pt,
603
614
  E.length > 0 && /* @__PURE__ */ n(
604
- hn,
615
+ qn,
605
616
  {
606
617
  cascadeRules: E,
607
- cascadeFilter: O,
608
- currentValue: He,
609
- relatedCollection: Ke,
610
- missingRequiredParents: ge,
611
- onClear: Nt
618
+ cascadeFilter: W,
619
+ currentValue: Ve,
620
+ relatedCollection: _e,
621
+ missingRequiredParents: Fe,
622
+ onClear: jt
612
623
  }
613
624
  ),
614
- (C !== "" || J.length > 0) && /* @__PURE__ */ u(
625
+ (F !== "" || ee.length > 0) && /* @__PURE__ */ m(
615
626
  "div",
616
627
  {
617
628
  className: "flex flex-wrap items-center gap-1.5 min-h-[1.5rem]",
618
- "data-pd-row": pe ? "" : void 0,
629
+ "data-pd-row": be ? "" : void 0,
619
630
  children: [
620
- C !== "" && /* @__PURE__ */ u(Gt, { id: P, "data-field-label": !0, className: "text-sm font-medium", children: [
621
- /* @__PURE__ */ n(Ze, { text: C, collection: d }),
622
- (e.required || Xe(e.validation_rules, i)) && /* @__PURE__ */ n("span", { className: "ml-0.5 text-destructive", children: "*" }),
623
- _n(e) && /* @__PURE__ */ n(Nn, {})
631
+ F !== "" && /* @__PURE__ */ m(cn, { id: M, "data-field-label": !0, className: "text-sm font-medium", children: [
632
+ /* @__PURE__ */ n(nt, { text: F, collection: c }),
633
+ (e.required || tt(e.validation_rules, s)) && /* @__PURE__ */ n("span", { className: "ml-0.5 text-destructive", children: "*" }),
634
+ Wn(e) && /* @__PURE__ */ n(Vn, {})
624
635
  ] }),
625
- X.note && /* @__PURE__ */ n(ee, { delayDuration: 100, children: /* @__PURE__ */ u(te, { children: [
626
- /* @__PURE__ */ n(ne, { asChild: !0, children: /* @__PURE__ */ n(Rt, { className: "h-3.5 w-3.5 shrink-0 cursor-help text-slate-400 hover:text-slate-600" }) }),
627
- /* @__PURE__ */ n(re, { side: "top", className: "max-w-[240px] text-[12px]", children: (s == null ? void 0 : s.glossaryHelp) === !1 ? X.note : /* @__PURE__ */ n(Ze, { text: X.note, collection: d }) })
636
+ $t && Z && /* @__PURE__ */ n(Dn, { field: e.field, mark: Z }),
637
+ te.note && /* @__PURE__ */ n(oe, { delayDuration: 100, children: /* @__PURE__ */ m(ie, { children: [
638
+ /* @__PURE__ */ n(le, { asChild: !0, children: /* @__PURE__ */ n(Dt, { className: "h-3.5 w-3.5 shrink-0 cursor-help text-slate-400 hover:text-slate-600" }) }),
639
+ /* @__PURE__ */ n(ae, { side: "top", className: "max-w-[240px] text-[12px]", children: (l == null ? void 0 : l.glossaryHelp) === !1 ? te.note : /* @__PURE__ */ n(nt, { text: te.note, collection: c }) })
628
640
  ] }) }),
629
- Fe && /* @__PURE__ */ n(zt, { source: Fe, label: C }),
630
- !q && l && l !== "new" && /* @__PURE__ */ n(
631
- Hn,
641
+ Te && /* @__PURE__ */ n(sn, { source: Te, label: F }),
642
+ !$ && r && r !== "new" && /* @__PURE__ */ n(
643
+ dr,
632
644
  {
633
- collection: d,
634
- itemId: l,
645
+ collection: c,
646
+ itemId: r,
635
647
  field: e.field,
636
648
  onRestore: e.readonly ? void 0 : (t) => h(e.field, t)
637
649
  }
638
650
  ),
639
- !q && l && l !== "new" && /* @__PURE__ */ n(Kn, { collection: d, itemId: l, field: e.field }),
640
- !q && l && l !== "new" && /* @__PURE__ */ n(ln, { field: e.field, label: C || K(e.field) }),
641
- l && l !== "new" && yt && /* @__PURE__ */ n(On, { collection: d, itemId: l, field: e.field }),
642
- xt && /* @__PURE__ */ n(
643
- Fn,
651
+ !$ && r && r !== "new" && /* @__PURE__ */ n(ur, { collection: c, itemId: r, field: e.field }),
652
+ !$ && r && r !== "new" && /* @__PURE__ */ n(kn, { field: e.field, label: F || j(e.field) }),
653
+ r && r !== "new" && ye.length > 0 && // Realtime round 7 #4 — "Point Beth to this field": opens the field menu, whose
654
+ // Point items name each person on the record now. Revealed on hover/focus; the
655
+ // slot is kept (opacity) so the row never shifts.
656
+ /* @__PURE__ */ n(
657
+ "button",
644
658
  {
645
- collection: d,
646
- itemId: l,
659
+ type: "button",
660
+ "data-field-menu-trigger": "",
661
+ "data-field-point-trigger": "",
662
+ "aria-label": `Point someone to ${F || j(e.field)}`,
663
+ "data-tip": ye.length === 1 ? `Point ${ye[0].name} to this field` : "Point someone on this record to this field",
664
+ onClick: (t) => ht(t.currentTarget),
665
+ className: B(
666
+ "inline-flex items-center rounded p-0.5 text-slate-400 transition-opacity hover:text-nvr-cyan focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan/50 dark:text-slate-400 dark:hover:text-nvr-cyan",
667
+ ft ? "opacity-100 text-nvr-cyan" : "opacity-0 group-hover/fieldrow:opacity-100"
668
+ ),
669
+ children: /* @__PURE__ */ n(Ht, { className: "h-3 w-3" })
670
+ }
671
+ ),
672
+ r && r !== "new" && Rt && /* @__PURE__ */ n(cr, { collection: c, itemId: r, field: e.field }),
673
+ Ct && /* @__PURE__ */ n(
674
+ zn,
675
+ {
676
+ collection: c,
677
+ itemId: r,
647
678
  field: e.field,
648
- label: C || K(e.field),
679
+ label: F || j(e.field),
649
680
  onFill: (t) => h(e.field, t)
650
681
  }
651
682
  ),
652
- !q && Y.show && !(Y.perField && (p || e.readonly)) && /* @__PURE__ */ u(
683
+ !$ && I.show && !(I.perField && (d || e.readonly)) && /* @__PURE__ */ m(
653
684
  "button",
654
685
  {
655
686
  type: "button",
656
- onClick: mt,
657
- disabled: Ne,
658
- "data-ai-fill": Y.perField ? e.field : void 0,
687
+ onClick: kt,
688
+ disabled: $e,
689
+ "data-ai-fill": I.perField ? e.field : void 0,
659
690
  className: "inline-flex items-center gap-0.5 rounded px-1 py-0.5 text-[10px] font-medium text-nvr-cyan hover:bg-nvr-cyan/10 disabled:opacity-50 transition-colors",
660
691
  title: "Generate with AI",
661
692
  children: [
662
- Ne ? /* @__PURE__ */ n(Lt, { className: "h-3 w-3 animate-spin" }) : /* @__PURE__ */ n(St, { className: "h-3 w-3" }),
693
+ $e ? /* @__PURE__ */ n(Ot, { className: "h-3 w-3 animate-spin" }) : /* @__PURE__ */ n(Kt, { className: "h-3 w-3" }),
663
694
  "AI"
664
695
  ]
665
696
  }
666
697
  ),
667
- fe && /* @__PURE__ */ n(
698
+ ve && /* @__PURE__ */ n(
668
699
  "span",
669
700
  {
670
701
  "data-tip": "People often change what the AI read from the document here — check it",
@@ -673,36 +704,36 @@ const Fr = jt(function({
673
704
  }
674
705
  ),
675
706
  f,
676
- T && !p && !e.readonly && /* @__PURE__ */ u(
707
+ P && !d && !e.readonly && /* @__PURE__ */ m(
677
708
  "button",
678
709
  {
679
710
  type: "button",
680
- onClick: () => T.onApply(i[e.field] ?? null),
681
- disabled: i[e.field] == null || i[e.field] === "" || T.count === 0,
711
+ onClick: () => P.onApply(s[e.field] ?? null),
712
+ disabled: s[e.field] == null || s[e.field] === "" || P.count === 0,
682
713
  "data-apply-to-lines": e.field,
683
- "data-tip": T.count === 0 ? "No lines yet — add lines first" : i[e.field] == null || i[e.field] === "" ? "Pick a value first" : T.count != null ? `Copy this value onto all ${T.count} lines (staged until you save)` : "Copy this value onto every line (staged until you save)",
714
+ "data-tip": P.count === 0 ? "No lines yet — add lines first" : s[e.field] == null || s[e.field] === "" ? "Pick a value first" : P.count != null ? `Copy this value onto all ${P.count} lines (staged until you save)` : "Copy this value onto every line (staged until you save)",
684
715
  className: "inline-flex items-center gap-1 rounded border border-nvr-cyan/40 px-1.5 py-0.5 text-[10.5px] font-medium text-[#0e7490] transition-colors hover:bg-nvr-cyan/10 disabled:cursor-not-allowed disabled:opacity-40 dark:text-nvr-cyan",
685
716
  children: [
686
- T.label ?? "Apply to lines",
717
+ P.label ?? "Apply to lines",
687
718
  " ↓"
688
719
  ]
689
720
  }
690
721
  ),
691
- J.length > 0 && /* @__PURE__ */ n(ee, { delayDuration: 100, children: /* @__PURE__ */ u(te, { children: [
692
- /* @__PURE__ */ n(ne, { asChild: !0, children: /* @__PURE__ */ u("span", { className: "inline-flex items-center gap-1 rounded-full bg-amber-50 px-1.5 py-0.5 text-[10px] font-medium text-amber-700 border border-amber-200 dark:bg-amber-500/10 dark:text-amber-400 dark:border-amber-500/20 cursor-default", children: [
722
+ ee.length > 0 && /* @__PURE__ */ n(oe, { delayDuration: 100, children: /* @__PURE__ */ m(ie, { children: [
723
+ /* @__PURE__ */ n(le, { asChild: !0, children: /* @__PURE__ */ m("span", { className: "inline-flex items-center gap-1 rounded-full bg-amber-50 px-1.5 py-0.5 text-[10px] font-medium text-amber-700 border border-amber-200 dark:bg-amber-500/10 dark:text-amber-400 dark:border-amber-500/20 cursor-default", children: [
693
724
  /* @__PURE__ */ n("span", { className: "h-1.5 w-1.5 rounded-full bg-amber-400 shrink-0" }),
694
725
  "addendum"
695
726
  ] }) }),
696
- /* @__PURE__ */ u(re, { side: "top", className: "max-w-[220px] text-[12px]", children: [
697
- /* @__PURE__ */ u("p", { className: "font-medium mb-1", children: [
727
+ /* @__PURE__ */ m(ae, { side: "top", className: "max-w-[220px] text-[12px]", children: [
728
+ /* @__PURE__ */ m("p", { className: "font-medium mb-1", children: [
698
729
  "In active addendum",
699
- J.length > 1 ? "s" : "",
730
+ ee.length > 1 ? "s" : "",
700
731
  ":"
701
732
  ] }),
702
- J.map((t) => /* @__PURE__ */ u("p", { className: "text-slate-400", children: [
733
+ ee.map((t) => /* @__PURE__ */ m("p", { className: "text-slate-400", children: [
703
734
  t.title,
704
735
  " ",
705
- /* @__PURE__ */ u("span", { className: "capitalize", children: [
736
+ /* @__PURE__ */ m("span", { className: "capitalize", children: [
706
737
  "(",
707
738
  t.status,
708
739
  ")"
@@ -711,65 +742,86 @@ const Fr = jt(function({
711
742
  ] })
712
743
  ] }) }),
713
744
  /* @__PURE__ */ n(
714
- an,
745
+ Fn,
715
746
  {
716
- collection: d,
747
+ collection: c,
717
748
  kind: "field",
718
749
  name: e.field,
719
- label: C
750
+ label: F
751
+ }
752
+ ),
753
+ S && !S.conflict && /* @__PURE__ */ n(
754
+ Yn,
755
+ {
756
+ change: S,
757
+ now: s[e.field],
758
+ field: e,
759
+ relatedCollection: _e ?? null,
760
+ onDismiss: () => l == null ? void 0 : l.dismissRemoteChange(e.field)
720
761
  }
721
762
  ),
722
- (p || e.readonly) && M ? /* @__PURE__ */ n(tn, { reason: M, onHover: s == null ? void 0 : s.onLockHover }) : p ? /* @__PURE__ */ n(ee, { delayDuration: 200, children: /* @__PURE__ */ u(te, { children: [
723
- /* @__PURE__ */ n(ne, { asChild: !0, children: /* @__PURE__ */ n("span", { className: "inline-flex items-center text-amber-400 dark:text-amber-500", children: /* @__PURE__ */ n($t, { className: "h-3 w-3" }) }) }),
724
- /* @__PURE__ */ n(re, { side: "top", className: "text-[12px]", children: "This field is locked" })
763
+ (d || e.readonly) && K ? /* @__PURE__ */ n(vn, { reason: K, onHover: l == null ? void 0 : l.onLockHover }) : d ? /* @__PURE__ */ n(oe, { delayDuration: 200, children: /* @__PURE__ */ m(ie, { children: [
764
+ /* @__PURE__ */ n(le, { asChild: !0, children: /* @__PURE__ */ n("span", { className: "inline-flex items-center text-amber-400 dark:text-amber-500", children: /* @__PURE__ */ n(Ut, { className: "h-3 w-3" }) }) }),
765
+ /* @__PURE__ */ n(ae, { side: "top", className: "text-[12px]", children: "This field is locked" })
725
766
  ] }) }) : null,
726
767
  E.length > 0 && (() => {
727
- const t = !!O && Object.keys(O).length > 0 && H.length > 0, r = E.map(
728
- (c) => Z(String(c.parent_field))
768
+ const t = !!W && Object.keys(W).length > 0 && V.length > 0, o = E.map(
769
+ (u) => ne(String(u.parent_field))
729
770
  );
730
- return /* @__PURE__ */ n(ee, { delayDuration: 100, children: /* @__PURE__ */ u(te, { children: [
731
- /* @__PURE__ */ n(ne, { asChild: !0, children: /* @__PURE__ */ n(
771
+ return /* @__PURE__ */ n(oe, { delayDuration: 100, children: /* @__PURE__ */ m(ie, { children: [
772
+ /* @__PURE__ */ n(le, { asChild: !0, children: /* @__PURE__ */ n(
732
773
  "button",
733
774
  {
734
775
  type: "button",
735
- "aria-label": `Show the fields that narrow ${C || "this list"}`,
736
- onClick: _t,
737
- className: D(
776
+ "aria-label": `Show the fields that narrow ${F || "this list"}`,
777
+ onClick: Et,
778
+ className: B(
738
779
  "inline-flex items-center transition-colors",
739
780
  t ? "text-nvr-cyan hover:text-nvr-cyan" : "text-slate-300 hover:text-nvr-cyan dark:text-slate-600 dark:hover:text-nvr-cyan"
740
781
  ),
741
- children: /* @__PURE__ */ n(qt, { className: "h-3 w-3" })
782
+ children: /* @__PURE__ */ n(Wt, { className: "h-3 w-3" })
742
783
  }
743
784
  ) }),
744
- /* @__PURE__ */ n(re, { side: "top", className: "text-[12px]", children: t ? `Filtered by ${H.join(", ")} — click to highlight` : `Options filter by ${r.join(", ")} once set` })
785
+ /* @__PURE__ */ n(ae, { side: "top", className: "text-[12px]", children: t ? `Filtered by ${V.join(", ")} — click to highlight` : `Options filter by ${o.join(", ")} once set` })
745
786
  ] }) });
746
787
  })(),
747
- pe && // Right-anchored: the personal-default control flush with the field's right edge
788
+ !$ && r && r !== "new" && e.type !== "alias" && !e.field.startsWith("__") && // Realtime round 7 #7 — where the value came from ("Set by ERP Sync · 2 m ago"):
789
+ // while it has just changed live, and when the pointer rests on the field.
790
+ /* @__PURE__ */ n(
791
+ _n,
792
+ {
793
+ collection: c,
794
+ itemId: r,
795
+ field: e.field,
796
+ live: !!S && !S.conflict
797
+ }
798
+ ),
799
+ be && // Right-anchored: the personal-default control flush with the field's right edge
748
800
  // (it carries Make / Update / Clear itself — no ⋯ button; right-click and
749
801
  // Shift+F10 still open the field menu). The slot keeps one box whatever it shows,
750
802
  // so nothing to its left moves.
751
803
  /* @__PURE__ */ n("span", { className: "ml-auto inline-flex shrink-0 items-center gap-1", children: /* @__PURE__ */ n(
752
- bn,
804
+ jn,
753
805
  {
754
806
  field: e.field,
755
- label: C,
756
- state: pe,
757
- confirmOpen: me === "make" || me === "update" ? me : null,
758
- onConfirm: (t, r) => (
807
+ label: F,
808
+ state: be,
809
+ confirmOpen: xe === "make" || xe === "update" ? xe : null,
810
+ onConfirm: (t, o) => (
759
811
  // After a save the button becomes "Your default": focus goes to the field.
760
- dt(t, he, r)
812
+ xt(t, ge, o)
761
813
  ),
762
814
  onUndo: () => {
763
815
  R == null || R.undo(e.field), requestAnimationFrame(() => {
764
816
  var t;
765
- return (t = he()) == null ? void 0 : t.focus();
817
+ return (t = ge()) == null ? void 0 : t.focus();
766
818
  });
767
819
  },
768
820
  onCleared: () => (
769
821
  // The Clear button is gone (and not a tab stop): focus goes to the field.
770
822
  requestAnimationFrame(() => {
771
823
  var t;
772
- return (t = he()) == null ? void 0 : t.focus();
824
+ return (t = ge()) == null ? void 0 : t.focus();
773
825
  })
774
826
  )
775
827
  }
@@ -777,78 +829,88 @@ const Fr = jt(function({
777
829
  ]
778
830
  }
779
831
  ),
780
- j.editor && !p && /* @__PURE__ */ n(
781
- nn,
832
+ D.editor && !d && /* @__PURE__ */ n(
833
+ wn,
782
834
  {
783
- editor: j.editor,
784
- confirming: j.confirming,
785
- onConfirm: j.confirm,
786
- onCancel: j.cancel
835
+ editor: D.editor,
836
+ confirming: D.confirming,
837
+ onConfirm: D.confirm,
838
+ onCancel: D.cancel
787
839
  }
788
840
  ),
789
- W ?? /* @__PURE__ */ n(
841
+ Q ?? /* @__PURE__ */ n(
790
842
  "div",
791
843
  {
792
- ref: ue,
793
- className: D(p && !V && "cursor-not-allowed"),
794
- "data-tip": (p || e.readonly) && M ? M : void 0,
795
- onPointerEnter: (p || e.readonly) && M ? s == null ? void 0 : s.onLockHover : void 0,
844
+ ref: fe,
845
+ className: B(d && !G && "cursor-not-allowed"),
846
+ "data-tip": (d || e.readonly) && K ? K : void 0,
847
+ onPointerEnter: (d || e.readonly) && K ? l == null ? void 0 : l.onLockHover : void 0,
796
848
  children: /* @__PURE__ */ n(
797
849
  "div",
798
850
  {
799
- ref: Se,
800
- className: D(
851
+ ref: Ee,
852
+ className: B(
801
853
  // A locked FILE field stays interactive: its chips keep the
802
854
  // download link and preview click (the component itself hides
803
855
  // upload/replace/remove when readonly) — blocking pointer events
804
856
  // made attachments unopenable on every locked form (addendum
805
857
  // view, terminal states).
806
- p && !V && "pointer-events-none opacity-60",
858
+ d && !G && "pointer-events-none opacity-60",
807
859
  // The ring lands with a 2px shake so the eye finds the field;
808
860
  // the animation runs once when the class is added.
809
861
  w && "nvr-shake ring-1 ring-red-400 rounded-md",
810
- se && "nvr-autofill-glow"
862
+ me && "nvr-autofill-glow"
811
863
  ),
812
- children: q ? /* @__PURE__ */ n(Cn, { field: e, values: i }) : bt ? /* @__PURE__ */ n(
813
- Yt,
864
+ children: $ ? /* @__PURE__ */ n(Qn, { field: e, values: s }) : Lt ? /* @__PURE__ */ n(
865
+ un,
814
866
  {
815
- collection: d,
867
+ collection: c,
816
868
  field: e,
817
- draft: i,
818
- itemId: l
869
+ draft: s,
870
+ itemId: r
819
871
  }
820
872
  ) : b ? b({
821
873
  field: e,
822
- value: xe,
823
- onChange: $e,
824
- disabled: p,
825
- collection: d,
826
- itemId: l,
874
+ value: U,
875
+ onChange: je,
876
+ disabled: d,
877
+ collection: c,
878
+ itemId: r,
827
879
  relations: x,
828
- cascadeFilter: O,
829
- unsatisfiedParentLabel: vt,
830
- requiredParentLabel: Ue
880
+ cascadeFilter: W,
881
+ unsatisfiedParentLabel: qt,
882
+ requiredParentLabel: ze
831
883
  }) : /* @__PURE__ */ n(
832
- on,
884
+ Nn,
833
885
  {
834
- field: p && V ? wt() : e,
835
- value: xe,
836
- onChange: $e,
886
+ field: d && G ? At() : e,
887
+ value: U,
888
+ onChange: je,
837
889
  relations: x,
838
- collection: d,
839
- itemId: l,
840
- cascadeFilter: O,
841
- requiredParentLabel: Ue,
842
- narrowedBy: H.length > 0 ? kt() : void 0,
843
- onCountChange: o ? lt : void 0
890
+ collection: c,
891
+ itemId: r,
892
+ cascadeFilter: W,
893
+ requiredParentLabel: ze,
894
+ narrowedBy: V.length > 0 ? Pt() : void 0,
895
+ onCountChange: i ? ct : void 0
844
896
  }
845
897
  )
846
898
  },
847
- se ?? 0
899
+ me ?? 0
848
900
  )
849
901
  }
850
902
  ),
851
- De && /* @__PURE__ */ n(Rn, { value: i[e.field], config: De }),
903
+ Ue && /* @__PURE__ */ n(Gn, { value: s[e.field], config: Ue }),
904
+ r && r !== "new" && // rt9 #10: "Moved 2 days later because PO due date changed" when the app re-derived it.
905
+ /* @__PURE__ */ n(
906
+ fn,
907
+ {
908
+ collection: c,
909
+ itemId: r,
910
+ field: e.field,
911
+ type: e.type
912
+ }
913
+ ),
852
914
  w && // The message under the field: a red border alone never said WHY (Service End before
853
915
  // Start, b01-N5). The form's summary at the top lists it too — and is
854
916
  // the ONE live announcement (army11 f3: ten role=alert regions fired at
@@ -856,32 +918,50 @@ const Fr = jt(function({
856
918
  /* @__PURE__ */ n(
857
919
  "p",
858
920
  {
859
- id: `${P}-error`,
921
+ id: `${M}-error`,
860
922
  "data-field-error": e.field,
861
923
  className: "text-[11.5px] leading-snug text-red-600 dark:text-red-400",
862
924
  children: w
863
925
  }
864
926
  ),
865
- !w && Me && // A soft (warning-only) rule the value breaks: said here, never blocks the save.
927
+ !w && We && // A soft (warning-only) rule the value breaks: said here, never blocks the save.
866
928
  /* @__PURE__ */ n(
867
929
  "p",
868
930
  {
869
931
  "data-field-warning": e.field,
870
932
  className: "text-[11.5px] leading-snug text-amber-700 dark:text-amber-400",
871
- children: Me
933
+ children: We
934
+ }
935
+ ),
936
+ ((Ze = l == null ? void 0 : l.linkedChanges) == null ? void 0 : Ze[e.field]) && // rt4 #6 — the record this field links to changed while the form was open and is
937
+ // no longer offered here: what happened, under the field. The value stays.
938
+ /* @__PURE__ */ n(
939
+ "p",
940
+ {
941
+ "data-field-linked-change": e.field,
942
+ className: "text-[11.5px] leading-snug text-amber-700 dark:text-amber-400",
943
+ children: l.linkedChanges[e.field]
872
944
  }
873
945
  ),
874
- je && !ut && /* @__PURE__ */ n(gn, { field: e.field, text: je }),
875
- Pe && /* @__PURE__ */ n(Xt, { field: e.field, hint: Pe }),
876
- Ee && /* @__PURE__ */ n(
877
- rn,
946
+ Tt && /* @__PURE__ */ n(Hn, { field: e.field, label: F || j(e.field) }),
947
+ Oe && !wt && /* @__PURE__ */ n(Bn, { field: e.field, text: Oe }),
948
+ He && /* @__PURE__ */ n(xn, { field: e.field, hint: He }),
949
+ (S == null ? void 0 : S.conflict) && /* @__PURE__ */ n(
950
+ Jn,
878
951
  {
879
- change: Ee,
880
- relatedCollection: Ke ?? null,
881
- onDismiss: () => s == null ? void 0 : s.dismissRemoteChange(e.field),
882
- onTakeTheirs: s != null && s.takeRemoteChange ? () => {
952
+ change: S,
953
+ mine: s[e.field],
954
+ field: e,
955
+ relatedCollection: _e ?? null,
956
+ locked: d || !!e.readonly,
957
+ onKeepMine: () => l == null ? void 0 : l.dismissRemoteChange(e.field),
958
+ onTakeTheirs: l != null && l.takeRemoteChange ? () => {
883
959
  var t;
884
- return (t = s.takeRemoteChange) == null ? void 0 : t.call(s, e.field);
960
+ return (t = l.takeRemoteChange) == null ? void 0 : t.call(l, e.field);
961
+ } : void 0,
962
+ onMerge: l != null && l.mergeRemoteChange ? (t) => {
963
+ var o;
964
+ return (o = l.mergeRemoteChange) == null ? void 0 : o.call(l, e.field, t);
885
965
  } : void 0
886
966
  }
887
967
  )
@@ -891,9 +971,9 @@ const Fr = jt(function({
891
971
  );
892
972
  });
893
973
  export {
894
- Fr as FieldRow,
895
- Dn as clearableParents,
896
- Bn as isAiEligible,
897
- Nr as lineageSummary,
898
- Mn as useFieldLineage
974
+ to as FieldRow,
975
+ ar as clearableParents,
976
+ lr as isAiEligible,
977
+ eo as lineageSummary,
978
+ sr as useFieldLineage
899
979
  };