@nivaro/react 0.3.113 → 0.3.115

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (285) hide show
  1. package/dist/components/ScreenShareHost.js +24 -0
  2. package/dist/full.css +50 -2
  3. package/dist/hooks/useSessionRecorder.js +61 -60
  4. package/dist/index.d.ts +1727 -19
  5. package/dist/index.js +1091 -950
  6. package/dist/shared/components/ActivityEntry.js +209 -97
  7. package/dist/shared/components/AgentPresenceChip.js +51 -0
  8. package/dist/shared/components/AnnouncementBanner.js +56 -41
  9. package/dist/shared/components/AutolinkedText.js +98 -85
  10. package/dist/shared/components/BroadcastView.js +149 -141
  11. package/dist/shared/components/CacheStamp.js +78 -30
  12. package/dist/shared/components/CollectionBrowserView.js +4088 -3592
  13. package/dist/shared/components/ConfigChangeStrip.js +63 -0
  14. package/dist/shared/components/ConfigReachNote.js +107 -0
  15. package/dist/shared/components/ConformanceView.js +389 -319
  16. package/dist/shared/components/DataTable.js +544 -504
  17. package/dist/shared/components/DelegateCoverLine.js +164 -0
  18. package/dist/shared/components/EnvironmentNotice.js +56 -65
  19. package/dist/shared/components/FilePreviewLightbox.js +89 -43
  20. package/dist/shared/components/FindingFixedMark.js +23 -0
  21. package/dist/shared/components/GridPresenceLine.js +100 -0
  22. package/dist/shared/components/IdleReloadWatcher.js +82 -43
  23. package/dist/shared/components/InStep.js +46 -0
  24. package/dist/shared/components/ItemEditForm.js +5504 -4889
  25. package/dist/shared/components/LiveAnnouncer.js +62 -0
  26. package/dist/shared/components/LiveCount.js +54 -0
  27. package/dist/shared/components/LiveFigure.js +28 -0
  28. package/dist/shared/components/LiveListControls.js +114 -0
  29. package/dist/shared/components/LiveNewMatchesPill.js +25 -0
  30. package/dist/shared/components/LiveOffNote.js +44 -0
  31. package/dist/shared/components/LivePreferenceHost.js +42 -0
  32. package/dist/shared/components/LiveRowMark.js +25 -20
  33. package/dist/shared/components/LiveTraceView.js +257 -0
  34. package/dist/shared/components/MapView.js +30 -29
  35. package/dist/shared/components/MatrixEditor.js +497 -462
  36. package/dist/shared/components/MyWorkView.js +346 -272
  37. package/dist/shared/components/NotificationBell.js +215 -201
  38. package/dist/shared/components/PageRenderer.js +636 -599
  39. package/dist/shared/components/PresenceDot.js +21 -0
  40. package/dist/shared/components/ProfileView.js +656 -536
  41. package/dist/shared/components/RealtimeStatusBanner.js +25 -25
  42. package/dist/shared/components/RecentRecordsRail.js +51 -48
  43. package/dist/shared/components/RecordCompare.js +241 -150
  44. package/dist/shared/components/RecordDrilldownSheet.js +66 -64
  45. package/dist/shared/components/RecordGridEditor.js +350 -311
  46. package/dist/shared/components/RecordHoverCard.js +147 -0
  47. package/dist/shared/components/RecordPeekHost.js +111 -0
  48. package/dist/shared/components/RecordReadView.js +414 -412
  49. package/dist/shared/components/RelativeTime.js +16 -0
  50. package/dist/shared/components/ReportView.js +1396 -1304
  51. package/dist/shared/components/ScreenRefreshButton.js +77 -0
  52. package/dist/shared/components/TabCountHost.js +10 -0
  53. package/dist/shared/components/TickerNumber.js +19 -18
  54. package/dist/shared/components/TipLayer.js +70 -58
  55. package/dist/shared/components/WidgetImageMenu.js +59 -0
  56. package/dist/shared/components/WidgetSlot.js +571 -524
  57. package/dist/shared/components/activity/RecordActivityStream.js +317 -0
  58. package/dist/shared/components/bulk/BulkSelectionNotices.js +220 -0
  59. package/dist/shared/components/cbv/approval-changed.js +20 -0
  60. package/dist/shared/components/cbv/changed-by-others.js +251 -0
  61. package/dist/shared/components/cbv/column-totals.js +75 -67
  62. package/dist/shared/components/change-proposals/ChangeProposalsPanel.js +320 -0
  63. package/dist/shared/components/change-proposals/ProposalValue.js +28 -0
  64. package/dist/shared/components/change-proposals/ProposeChangeButton.js +44 -0
  65. package/dist/shared/components/change-proposals/ProposeChangeDialog.js +359 -0
  66. package/dist/shared/components/change-proposals/types.js +4 -0
  67. package/dist/shared/components/chat/ChatPanel.js +1571 -1528
  68. package/dist/shared/components/chat/Composer.js +276 -298
  69. package/dist/shared/components/chat/room-due.js +13 -0
  70. package/dist/shared/components/collections-directory/CollectionRow.js +76 -75
  71. package/dist/shared/components/collections-directory/CollectionsDirectory.js +415 -395
  72. package/dist/shared/components/collections-directory/directory-data.js +75 -63
  73. package/dist/shared/components/imports/ImportConsole.js +159 -155
  74. package/dist/shared/components/imports/ImportDuplicatesNotice.js +46 -31
  75. package/dist/shared/components/integrations/SendStatus.js +202 -0
  76. package/dist/shared/components/integrations/console/IntegrationsConsole.js +45 -36
  77. package/dist/shared/components/integrations/console/ReadyToSendView.js +453 -0
  78. package/dist/shared/components/integrations/console/api.js +161 -117
  79. package/dist/shared/components/integrations/console/tone.js +15 -12
  80. package/dist/shared/components/item-edit/CatalogPickerField.js +1353 -1245
  81. package/dist/shared/components/item-edit/ChangedAfterApprovalBadge.js +162 -0
  82. package/dist/shared/components/item-edit/CloneDialog.js +208 -206
  83. package/dist/shared/components/item-edit/DerivedCauseNote.js +57 -0
  84. package/dist/shared/components/item-edit/DraftRecoveryBanner.js +81 -70
  85. package/dist/shared/components/item-edit/DuplicateNotice.js +169 -101
  86. package/dist/shared/components/item-edit/FieldAffordances.js +294 -385
  87. package/dist/shared/components/item-edit/FieldComments.js +159 -116
  88. package/dist/shared/components/item-edit/FieldPointer.js +132 -0
  89. package/dist/shared/components/item-edit/FieldRenderer.js +277 -273
  90. package/dist/shared/components/item-edit/FieldRow.js +519 -439
  91. package/dist/shared/components/item-edit/FieldSourceBadge.js +88 -0
  92. package/dist/shared/components/item-edit/FilePickerField.js +454 -369
  93. package/dist/shared/components/item-edit/GroupSection.js +618 -567
  94. package/dist/shared/components/item-edit/HeldEditsChip.js +113 -0
  95. package/dist/shared/components/item-edit/InlineTableField.js +2891 -2723
  96. package/dist/shared/components/item-edit/ListNeighborNav.js +79 -0
  97. package/dist/shared/components/item-edit/LiveTraceSheet.js +26 -0
  98. package/dist/shared/components/item-edit/M2MCombobox.js +284 -273
  99. package/dist/shared/components/item-edit/OutboxReviewTray.js +313 -0
  100. package/dist/shared/components/item-edit/PickerBadges.js +52 -0
  101. package/dist/shared/components/item-edit/PlanGrid.js +434 -439
  102. package/dist/shared/components/item-edit/RecalcValue.js +55 -0
  103. package/dist/shared/components/item-edit/RecordChatActions.js +76 -64
  104. package/dist/shared/components/item-edit/RecordChatMentionsChip.js +103 -0
  105. package/dist/shared/components/item-edit/RecordGrantTools.js +87 -86
  106. package/dist/shared/components/item-edit/RecordHelpChip.js +70 -0
  107. package/dist/shared/components/item-edit/RecordLiveSync.js +230 -217
  108. package/dist/shared/components/item-edit/RecordOutbox.js +53 -52
  109. package/dist/shared/components/item-edit/RecordRecapStrip.js +109 -36
  110. package/dist/shared/components/item-edit/RelationCombobox.js +229 -217
  111. package/dist/shared/components/item-edit/RelationGroupedCombobox.js +105 -100
  112. package/dist/shared/components/item-edit/RemoteChangeUi.js +454 -0
  113. package/dist/shared/components/item-edit/RemoteUploads.js +55 -0
  114. package/dist/shared/components/item-edit/RemovedLineNote.js +92 -0
  115. package/dist/shared/components/item-edit/RichTextEditorImpl.js +298 -223
  116. package/dist/shared/components/item-edit/ScheduledChangeChip.js +244 -0
  117. package/dist/shared/components/item-edit/SectionPresence.js +78 -0
  118. package/dist/shared/components/item-edit/SplitLinesButton.js +166 -0
  119. package/dist/shared/components/item-edit/catalog-line-watch.js +94 -0
  120. package/dist/shared/components/item-edit/coedit/collab.js +84 -0
  121. package/dist/shared/components/item-edit/coedit/context.js +24 -0
  122. package/dist/shared/components/item-edit/coedit/cursors.js +103 -0
  123. package/dist/shared/components/item-edit/coedit/safe-link.js +15 -0
  124. package/dist/shared/components/item-edit/coedit/session.js +382 -0
  125. package/dist/shared/components/item-edit/coedit/useCoedit.js +49 -0
  126. package/dist/shared/components/item-edit/file-live.js +77 -0
  127. package/dist/shared/components/item-edit/file-processing.js +87 -0
  128. package/dist/shared/components/item-edit/layout-switch.js +148 -0
  129. package/dist/shared/components/item-edit/live-related.js +23 -0
  130. package/dist/shared/components/item-edit/live-title.js +66 -0
  131. package/dist/shared/components/item-edit/partner-needs.js +142 -0
  132. package/dist/shared/components/item-edit/removed-line.js +58 -0
  133. package/dist/shared/components/item-edit/render-stability.js +70 -59
  134. package/dist/shared/components/layout-editor/ChangeNote.js +36 -34
  135. package/dist/shared/components/layout-editor/CollabParts.js +72 -70
  136. package/dist/shared/components/layout-editor/LayoutEditor.js +306 -303
  137. package/dist/shared/components/list/InlineEdit.js +504 -208
  138. package/dist/shared/components/list/ListViewers.js +81 -0
  139. package/dist/shared/components/merge/MergeRecordsDialog.js +1227 -0
  140. package/dist/shared/components/merge/MergeWithFlow.js +290 -0
  141. package/dist/shared/components/merge/merge-values.js +110 -0
  142. package/dist/shared/components/monitoring/InactiveUserLinksView.js +285 -258
  143. package/dist/shared/components/notifications/NotificationCenterView.js +388 -321
  144. package/dist/shared/components/notifications/NotificationDetailBits.js +205 -130
  145. package/dist/shared/components/notifications/NotificationRulesEditor.js +72 -52
  146. package/dist/shared/components/notifications/bundles.js +21 -19
  147. package/dist/shared/components/notifications/resolved-line.js +25 -0
  148. package/dist/shared/components/ops/OpsTasksView.js +45 -44
  149. package/dist/shared/components/panels/AccessGrantedNote.js +85 -0
  150. package/dist/shared/components/panels/AlertBanners.js +132 -0
  151. package/dist/shared/components/panels/AsyncUserPicker.js +54 -45
  152. package/dist/shared/components/panels/BranchLanes.js +82 -54
  153. package/dist/shared/components/panels/CommentAwareness.js +332 -0
  154. package/dist/shared/components/panels/CommentImages.js +219 -0
  155. package/dist/shared/components/panels/CommentPanel.js +649 -530
  156. package/dist/shared/components/panels/ExternalRequestsChip.js +98 -80
  157. package/dist/shared/components/panels/NewSinceChip.js +16 -0
  158. package/dist/shared/components/panels/OwnerOpenedLine.js +85 -0
  159. package/dist/shared/components/panels/PipelinePanel.js +1644 -1494
  160. package/dist/shared/components/panels/ResubmissionDiff.js +293 -0
  161. package/dist/shared/components/panels/SlaBreachBanner.js +30 -29
  162. package/dist/shared/components/panels/SlaClock.js +130 -99
  163. package/dist/shared/components/panels/TaskPanel.js +308 -287
  164. package/dist/shared/components/panels/unseen-move-check.js +101 -0
  165. package/dist/shared/components/pipeline/OwnerMatrix.js +80 -71
  166. package/dist/shared/components/pipeline/OwnerMatrixSheet.js +495 -0
  167. package/dist/shared/components/pipeline/PipelineEditorView.js +1855 -1771
  168. package/dist/shared/components/profile/AgentNameField.js +141 -0
  169. package/dist/shared/components/profile/AgentsPanel.js +55 -46
  170. package/dist/shared/components/profile/PersonAccess.js +398 -330
  171. package/dist/shared/components/profile/PersonAdminTools.js +127 -113
  172. package/dist/shared/components/profile/PersonProfile.js +81 -73
  173. package/dist/shared/components/profile/SignInTroubleshooter.js +361 -0
  174. package/dist/shared/components/queue/QueueBulkBar.js +101 -84
  175. package/dist/shared/components/queue/QueueItemSheet.js +66 -66
  176. package/dist/shared/components/queue/QueueTeamStrip.js +279 -0
  177. package/dist/shared/components/queue/QueueWorklist.js +2076 -1686
  178. package/dist/shared/components/queue/queue-totals.js +92 -0
  179. package/dist/shared/components/queue/worklist-helpers.js +18 -14
  180. package/dist/shared/components/send-view/SendViewButton.js +136 -0
  181. package/dist/shared/components/send-view/SentViewCards.js +147 -0
  182. package/dist/shared/components/support/ReportProblem.js +1 -0
  183. package/dist/shared/components/support/ScreenShare.js +554 -0
  184. package/dist/shared/components/support/SupportView.js +160 -129
  185. package/dist/shared/components/support/TicketDetailSheet.js +101 -89
  186. package/dist/shared/components/watch-list/WatchDock.js +1044 -0
  187. package/dist/shared/components/watch-list/WatchExtras.js +723 -0
  188. package/dist/shared/components/watch-list/WatchListButton.js +46 -0
  189. package/dist/shared/components/watch-list/WatchPinButton.js +67 -0
  190. package/dist/shared/components/watch-list/WatchRows.js +348 -0
  191. package/dist/shared/lib/activity-sentence.js +87 -75
  192. package/dist/shared/lib/agent-presence.js +46 -0
  193. package/dist/shared/lib/approval-progress.js +49 -0
  194. package/dist/shared/lib/attention-prefs.js +27 -0
  195. package/dist/shared/lib/cell-locks.js +56 -0
  196. package/dist/shared/lib/co-edit.js +166 -0
  197. package/dist/shared/lib/coedit-registry.js +44 -0
  198. package/dist/shared/lib/comment-awareness.js +124 -0
  199. package/dist/shared/lib/comment-images.js +45 -0
  200. package/dist/shared/lib/config-watch.js +94 -0
  201. package/dist/shared/lib/copy-rules.js +65 -0
  202. package/dist/shared/lib/count-step.js +30 -0
  203. package/dist/shared/lib/deadline-ticker.js +68 -0
  204. package/dist/shared/lib/derived-causes.js +115 -0
  205. package/dist/shared/lib/draft-store.js +114 -85
  206. package/dist/shared/lib/error-hints.js +1 -0
  207. package/dist/shared/lib/field-merge.js +126 -0
  208. package/dist/shared/lib/filter-sentence.js +10 -10
  209. package/dist/shared/lib/focus-mode.js +16 -12
  210. package/dist/shared/lib/grid-cursors.js +77 -0
  211. package/dist/shared/lib/grid-presence.js +182 -0
  212. package/dist/shared/lib/idle-reload.js +100 -73
  213. package/dist/shared/lib/in-step.js +45 -0
  214. package/dist/shared/lib/integration-chip.js +19 -18
  215. package/dist/shared/lib/line-locks.js +141 -0
  216. package/dist/shared/lib/line-split.js +41 -0
  217. package/dist/shared/lib/linked-changes.js +150 -0
  218. package/dist/shared/lib/list-link.js +56 -50
  219. package/dist/shared/lib/list-return.js +231 -0
  220. package/dist/shared/lib/list-viewers.js +52 -0
  221. package/dist/shared/lib/live-announcer.js +86 -0
  222. package/dist/shared/lib/live-counts.js +85 -0
  223. package/dist/shared/lib/live-data-changed.js +108 -0
  224. package/dist/shared/lib/live-deltas.js +81 -0
  225. package/dist/shared/lib/live-findings.js +113 -0
  226. package/dist/shared/lib/live-groups.js +122 -0
  227. package/dist/shared/lib/live-link-labels.js +162 -0
  228. package/dist/shared/lib/live-list-flow.js +334 -0
  229. package/dist/shared/lib/live-list.js +143 -129
  230. package/dist/shared/lib/live-moves.js +51 -0
  231. package/dist/shared/lib/live-ops.js +26 -26
  232. package/dist/shared/lib/live-pickers.js +7 -0
  233. package/dist/shared/lib/live-preference.js +184 -0
  234. package/dist/shared/lib/live-queries.js +226 -181
  235. package/dist/shared/lib/live-screen.js +333 -0
  236. package/dist/shared/lib/live-search.js +108 -0
  237. package/dist/shared/lib/live-seen.js +35 -0
  238. package/dist/shared/lib/live-views.js +100 -0
  239. package/dist/shared/lib/live.js +159 -133
  240. package/dist/shared/lib/missed-updates.js +198 -0
  241. package/dist/shared/lib/newer-file.js +56 -0
  242. package/dist/shared/lib/notification-sound.js +42 -20
  243. package/dist/shared/lib/own-writes.js +59 -41
  244. package/dist/shared/lib/picker-badges.js +94 -0
  245. package/dist/shared/lib/presence-signals.js +131 -84
  246. package/dist/shared/lib/realtime.js +49 -24
  247. package/dist/shared/lib/record-gaps.js +85 -0
  248. package/dist/shared/lib/record-outbox.js +369 -222
  249. package/dist/shared/lib/record-peek.js +75 -0
  250. package/dist/shared/lib/record-tabs.js +92 -72
  251. package/dist/shared/lib/relative-ticker.js +42 -0
  252. package/dist/shared/lib/request-gate.js +119 -119
  253. package/dist/shared/lib/rollup-recalc.js +107 -0
  254. package/dist/shared/lib/room-gaps.js +40 -36
  255. package/dist/shared/lib/rum.js +137 -87
  256. package/dist/shared/lib/save-progress.js +20 -0
  257. package/dist/shared/lib/scheduled-countdown.js +67 -0
  258. package/dist/shared/lib/screen-refresh.js +160 -0
  259. package/dist/shared/lib/screen-share.js +234 -0
  260. package/dist/shared/lib/seen-since.js +74 -0
  261. package/dist/shared/lib/selection-watch.js +205 -0
  262. package/dist/shared/lib/send-status.js +132 -0
  263. package/dist/shared/lib/send-view.js +23 -0
  264. package/dist/shared/lib/socket-liveness.js +155 -0
  265. package/dist/shared/lib/socket-realtime.js +168 -140
  266. package/dist/shared/lib/state-census.js +53 -0
  267. package/dist/shared/lib/summary-mode.js +61 -39
  268. package/dist/shared/lib/tab-attention.js +143 -32
  269. package/dist/shared/lib/table-density.js +64 -0
  270. package/dist/shared/lib/track-travel.js +40 -0
  271. package/dist/shared/lib/unseen-changes.js +68 -0
  272. package/dist/shared/lib/upload-file.js +33 -0
  273. package/dist/shared/lib/upload-presence.js +127 -0
  274. package/dist/shared/lib/urgent-chime.js +65 -0
  275. package/dist/shared/lib/use-online-users.js +32 -11
  276. package/dist/shared/lib/user-sync.js +155 -39
  277. package/dist/shared/lib/waiting-count.js +44 -0
  278. package/dist/shared/lib/watch-desktop.js +83 -0
  279. package/dist/shared/lib/watch-list.js +447 -0
  280. package/dist/shared/lib/widget-image-render.js +64 -0
  281. package/dist/shared/lib/widget-image.js +111 -0
  282. package/dist/shared/lib/worker-socket.js +130 -104
  283. package/dist/shared/lib/write-to-screen.js +133 -0
  284. package/package.json +1 -1
  285. package/styles.css +49 -1
@@ -1,29 +1,31 @@
1
- import { jsx as t, jsxs as p, Fragment as J } from "react/jsx-runtime";
2
- import { useQuery as G, useQueryClient as Ye } from "@tanstack/react-query";
3
- import { useState as j, useEffect as re, useRef as Y, useMemo as Me, useCallback as Xe, useDeferredValue as Ze } from "react";
4
- import { createPortal as et } from "react-dom";
5
- import { useNivaroClient as X, useItemEditAuth as tt, useDrilldown as Le, useOverlayState as rt, DrilldownContext as nt, useItemNavigation as at } from "../context.js";
6
- import { useDebounced as lt } from "../hooks/useDebounced.js";
7
- import { get as me, post as ne } from "../lib/commands.js";
8
- import { describeError as st } from "../lib/error-message.js";
9
- import { visiblePageWidgets as ot } from "../lib/page-widget-access.js";
10
- import { explicitAllUrlParams as it, initialFilterSelection as dt, filterSelectionToSearch as ct } from "../lib/query-filter-seed.js";
11
- import { userErrorMessage as Be } from "../lib/safe-error.js";
12
- import { safeLinkKind as ut } from "../lib/safe-href.js";
13
- import { resolveSheetDef as mt } from "../lib/sheet-def.js";
14
- import { uniqueByValue as ht } from "../lib/unique-options.js";
15
- import { useMyScopes as pt, matchScopeDimension as Oe, effectiveScopeSeedIds as xt, translateScopeValues as ft } from "../lib/use-my-scopes.js";
16
- import { titleCase as K, formatRelative as bt, formatNumber as gt } from "../lib/utils.js";
17
- import { CacheStamp as yt } from "./CacheStamp.js";
18
- import { RelationCombobox as vt } from "./item-edit/RelationCombobox.js";
19
- import { MatrixEditor as he } from "./MatrixEditor.js";
20
- import { QueryStatStrip as kt } from "./QueryStatStrip.js";
21
- import { QueryTable as wt } from "./QueryTable.js";
22
- import { RecordDrilldownSheet as Nt } from "./RecordDrilldownSheet.js";
23
- import { RecordGridEditor as Fe } from "./RecordGridEditor.js";
24
- import { SheetHeaderBody as St } from "./SheetHeaderBody.js";
25
- const ce = 76;
26
- function ae() {
1
+ import { jsx as t, jsxs as h, Fragment as H } from "react/jsx-runtime";
2
+ import { useQueryClient as De, useQuery as Y } from "@tanstack/react-query";
3
+ import { useMemo as he, useState as T, useEffect as te, createContext as tt, useRef as ee, useCallback as rt, useContext as nt, useDeferredValue as at } from "react";
4
+ import { createPortal as st } from "react-dom";
5
+ import { useNivaroClient as re, useItemEditAuth as lt, useDrilldown as Ie, useOverlayState as ot, DrilldownContext as it, useItemNavigation as dt } from "../context.js";
6
+ import { useDebounced as ct } from "../hooks/useDebounced.js";
7
+ import { get as xe, post as le } from "../lib/commands.js";
8
+ import { describeError as ut } from "../lib/error-message.js";
9
+ import { liveQueryMeta as mt } from "../lib/live-queries.js";
10
+ import { useLiveFade as pt } from "../lib/live-screen.js";
11
+ import { visiblePageWidgets as ht } from "../lib/page-widget-access.js";
12
+ import { explicitAllUrlParams as xt, initialFilterSelection as ft, filterSelectionToSearch as bt } from "../lib/query-filter-seed.js";
13
+ import { userErrorMessage as ze } from "../lib/safe-error.js";
14
+ import { safeLinkKind as gt } from "../lib/safe-href.js";
15
+ import { resolveSheetDef as yt } from "../lib/sheet-def.js";
16
+ import { uniqueByValue as vt } from "../lib/unique-options.js";
17
+ import { useMyScopes as kt, matchScopeDimension as Oe, effectiveScopeSeedIds as wt, translateScopeValues as Nt } from "../lib/use-my-scopes.js";
18
+ import { titleCase as Q, formatRelative as St, formatNumber as $t } from "../lib/utils.js";
19
+ import { LiveCacheStamp as _t } from "./CacheStamp.js";
20
+ import { RelationCombobox as Ct } from "./item-edit/RelationCombobox.js";
21
+ import { MatrixEditor as fe } from "./MatrixEditor.js";
22
+ import { QueryStatStrip as qt } from "./QueryStatStrip.js";
23
+ import { QueryTable as jt } from "./QueryTable.js";
24
+ import { RecordDrilldownSheet as Tt } from "./RecordDrilldownSheet.js";
25
+ import { RecordGridEditor as Ae } from "./RecordGridEditor.js";
26
+ import { SheetHeaderBody as Mt } from "./SheetHeaderBody.js";
27
+ const me = 76;
28
+ function oe() {
27
29
  return /* @__PURE__ */ t("div", { className: "space-y-1.5 p-3", children: [1, 2, 3].map((e) => /* @__PURE__ */ t(
28
30
  "div",
29
31
  {
@@ -32,25 +34,25 @@ function ae() {
32
34
  e
33
35
  )) });
34
36
  }
35
- function le({ error: e, unresolved: r }) {
36
- const n = Ft(e, r) ?? Be(e, "Failed to load widget data");
37
+ function ie({ error: e, unresolved: r }) {
38
+ const n = zt(e, r) ?? ze(e, "Failed to load widget data");
37
39
  return /* @__PURE__ */ t("div", { className: "flex h-full items-center justify-center p-3 text-[12px] text-amber-600 dark:text-amber-500", children: n });
38
40
  }
39
- function $t(e) {
41
+ function Rt(e) {
40
42
  if (e == null) return "—";
41
43
  if (typeof e == "boolean") return e ? "true" : "false";
42
44
  const r = String(e);
43
45
  return r.length > 80 ? `${r.slice(0, 80)}…` : r;
44
46
  }
45
- function ue(e, r) {
46
- const n = [], a = /(\*\*[^*]+\*\*|\*[^*]+\*|`[^`]+`|\[[^\]]+\]\([^)]+\))/g;
47
- return e.split(a).forEach((l, u) => {
48
- const c = `${r}-${u}`;
47
+ function pe(e, r) {
48
+ const n = [], s = /(\*\*[^*]+\*\*|\*[^*]+\*|`[^`]+`|\[[^\]]+\]\([^)]+\))/g;
49
+ return e.split(s).forEach((l, m) => {
50
+ const u = `${r}-${m}`;
49
51
  if (l)
50
52
  if (l.startsWith("**") && l.endsWith("**"))
51
- n.push(/* @__PURE__ */ t("strong", { children: l.slice(2, -2) }, c));
53
+ n.push(/* @__PURE__ */ t("strong", { children: l.slice(2, -2) }, u));
52
54
  else if (l.startsWith("*") && l.endsWith("*") && l.length > 2)
53
- n.push(/* @__PURE__ */ t("em", { children: l.slice(1, -1) }, c));
55
+ n.push(/* @__PURE__ */ t("em", { children: l.slice(1, -1) }, u));
54
56
  else if (l.startsWith("`") && l.endsWith("`"))
55
57
  n.push(
56
58
  /* @__PURE__ */ t(
@@ -59,126 +61,133 @@ function ue(e, r) {
59
61
  className: "rounded bg-slate-100 px-1 py-0.5 font-mono text-[0.9em] dark:bg-muted",
60
62
  children: l.slice(1, -1)
61
63
  },
62
- c
64
+ u
63
65
  )
64
66
  );
65
67
  else {
66
- const o = l.match(/^\[([^\]]+)\]\(([^)]+)\)$/);
67
- o && ut(o[2]) !== null ? n.push(
68
- /* @__PURE__ */ t("a", { href: o[2], className: "text-nvr-cyan underline-offset-2 hover:underline", children: o[1] }, c)
68
+ const d = l.match(/^\[([^\]]+)\]\(([^)]+)\)$/);
69
+ d && gt(d[2]) !== null ? n.push(
70
+ /* @__PURE__ */ t("a", { href: d[2], className: "text-nvr-cyan underline-offset-2 hover:underline", children: d[1] }, u)
69
71
  ) : n.push(l);
70
72
  }
71
73
  }), n;
72
74
  }
73
- function _t({ content: e }) {
75
+ function Wt({ content: e }) {
74
76
  const r = [];
75
- let n = [], a = [], l = !1;
76
- const u = (o) => {
77
+ let n = [], s = [], l = !1;
78
+ const m = (d) => {
77
79
  n.length && (r.push(
78
- /* @__PURE__ */ t("p", { className: "leading-relaxed", children: ue(n.join(" "), o) }, o)
80
+ /* @__PURE__ */ t("p", { className: "leading-relaxed", children: pe(n.join(" "), d) }, d)
79
81
  ), n = []);
80
- }, c = (o) => {
81
- if (!a.length) return;
82
- const s = a.map((m, x) => /* @__PURE__ */ t("li", { children: ue(m, `${o}-${x}`) }, `${o}-${x}`));
82
+ }, u = (d) => {
83
+ if (!s.length) return;
84
+ const o = s.map((c, x) => /* @__PURE__ */ t("li", { children: pe(c, `${d}-${x}`) }, `${d}-${x}`));
83
85
  r.push(
84
- l ? /* @__PURE__ */ t("ol", { className: "list-decimal space-y-0.5 pl-5", children: s }, o) : /* @__PURE__ */ t("ul", { className: "list-disc space-y-0.5 pl-5", children: s }, o)
85
- ), a = [];
86
+ l ? /* @__PURE__ */ t("ol", { className: "list-decimal space-y-0.5 pl-5", children: o }, d) : /* @__PURE__ */ t("ul", { className: "list-disc space-y-0.5 pl-5", children: o }, d)
87
+ ), s = [];
86
88
  };
87
89
  return e.split(`
88
- `).forEach((o, s) => {
89
- const m = `md-${s}`, x = o.match(/^(#{1,3})\s+(.*)$/), k = o.match(/^[-*]\s+(.*)$/), _ = o.match(/^\d+\.\s+(.*)$/);
90
+ `).forEach((d, o) => {
91
+ const c = `md-${o}`, x = d.match(/^(#{1,3})\s+(.*)$/), N = d.match(/^[-*]\s+(.*)$/), C = d.match(/^\d+\.\s+(.*)$/);
90
92
  if (x) {
91
- c(`${m}-fl`), u(`${m}-fp`);
92
- const w = x[1].length, q = w === 1 ? "text-[17px] font-semibold" : w === 2 ? "text-[15px] font-semibold" : "text-[13.5px] font-semibold";
93
+ u(`${c}-fl`), m(`${c}-fp`);
94
+ const S = x[1].length, q = S === 1 ? "text-[17px] font-semibold" : S === 2 ? "text-[15px] font-semibold" : "text-[13.5px] font-semibold";
93
95
  r.push(
94
- /* @__PURE__ */ t("div", { className: `${q} text-slate-900 dark:text-slate-100`, children: ue(x[2], `${m}-h`) }, m)
96
+ /* @__PURE__ */ t("div", { className: `${q} text-slate-900 dark:text-slate-100`, children: pe(x[2], `${c}-h`) }, c)
95
97
  );
96
- } else if (k || _) {
97
- u(`${m}-fp`);
98
- const w = !!_;
99
- a.length && l !== w && c(`${m}-fl`), l = w, a.push((k == null ? void 0 : k[1]) ?? (_ == null ? void 0 : _[1]));
100
- } else o.trim() === "" ? (c(`${m}-fl`), u(`${m}-fp`)) : (c(`${m}-fl`), n.push(o.trim()));
101
- }), c("md-end-l"), u("md-end-p"), /* @__PURE__ */ t("div", { className: "space-y-2 p-4 text-[13px] text-slate-700 dark:text-slate-300", children: r });
98
+ } else if (N || C) {
99
+ m(`${c}-fp`);
100
+ const S = !!C;
101
+ s.length && l !== S && u(`${c}-fl`), l = S, s.push((N == null ? void 0 : N[1]) ?? (C == null ? void 0 : C[1]));
102
+ } else d.trim() === "" ? (u(`${c}-fl`), m(`${c}-fp`)) : (u(`${c}-fl`), n.push(d.trim()));
103
+ }), u("md-end-l"), m("md-end-p"), /* @__PURE__ */ t("div", { className: "space-y-2 p-4 text-[13px] text-slate-700 dark:text-slate-300", children: r });
102
104
  }
103
- function pe(e, r, n) {
104
- const a = X();
105
- return G({
105
+ const Ke = tt(null);
106
+ function be() {
107
+ const e = nt(Ke);
108
+ return e ? mt(e) : void 0;
109
+ }
110
+ const Pt = /* @__PURE__ */ new Set(["page-renderer-query", "page-renderer-widget-data"]);
111
+ function ge(e, r, n) {
112
+ const s = re();
113
+ return Y({
106
114
  queryKey: ["page-renderer-widget-data", e, r.id],
107
- queryFn: () => a.request(ne(`/pages/${e}/widget-data`, { widget_id: r.id })).then((l) => l.data),
115
+ queryFn: () => s.request(le(`/pages/${e}/widget-data`, { widget_id: r.id })).then((l) => l.data),
108
116
  enabled: n,
109
117
  retry: !1,
110
- staleTime: 3e4
118
+ staleTime: 3e4,
119
+ meta: be()
111
120
  });
112
121
  }
113
- function Ct({ slug: e, widget: r }) {
114
- var m;
115
- const n = r.config ?? {}, { data: a, isLoading: l, error: u } = pe(e, r, !!n.collection), c = at();
122
+ function Lt({ slug: e, widget: r }) {
123
+ var c;
124
+ const n = r.config ?? {}, { data: s, isLoading: l, error: m } = ge(e, r, !!n.collection), u = dt();
116
125
  if (!n.collection)
117
126
  return /* @__PURE__ */ t("div", { className: "p-3 text-[12px] text-slate-400", children: "Select a collection" });
118
- if (l) return /* @__PURE__ */ t(ae, {});
119
- if (u) return /* @__PURE__ */ t(le, { error: u });
120
- const o = (a == null ? void 0 : a.rows) ?? [];
121
- if (!o.length) return /* @__PURE__ */ t("div", { className: "p-3 text-[12px] text-slate-400", children: "No records" });
122
- const s = (m = n.columns) != null && m.length ? n.columns : Object.keys(o[0]).filter((x) => {
123
- const k = o[0][x];
124
- return k === null || ["string", "number", "boolean"].includes(typeof k);
127
+ if (l) return /* @__PURE__ */ t(oe, {});
128
+ if (m) return /* @__PURE__ */ t(ie, { error: m });
129
+ const d = (s == null ? void 0 : s.rows) ?? [];
130
+ if (!d.length) return /* @__PURE__ */ t("div", { className: "p-3 text-[12px] text-slate-400", children: "No records" });
131
+ const o = (c = n.columns) != null && c.length ? n.columns : Object.keys(d[0]).filter((x) => {
132
+ const N = d[0][x];
133
+ return N === null || ["string", "number", "boolean"].includes(typeof N);
125
134
  }).slice(0, 5);
126
- return /* @__PURE__ */ t("div", { className: "h-full overflow-auto", children: /* @__PURE__ */ p("table", { className: "w-full text-[12px]", children: [
127
- /* @__PURE__ */ t("thead", { children: /* @__PURE__ */ t("tr", { className: "border-b border-slate-100 dark:border-border", children: s.map((x) => /* @__PURE__ */ t(
135
+ return /* @__PURE__ */ t("div", { className: "h-full overflow-auto", children: /* @__PURE__ */ h("table", { className: "w-full text-[12px]", children: [
136
+ /* @__PURE__ */ t("thead", { children: /* @__PURE__ */ t("tr", { className: "border-b border-slate-100 dark:border-border", children: o.map((x) => /* @__PURE__ */ t(
128
137
  "th",
129
138
  {
130
139
  className: "whitespace-nowrap px-3 py-1.5 text-left font-medium text-slate-400",
131
- children: K(x)
140
+ children: Q(x)
132
141
  },
133
142
  x
134
143
  )) }) }),
135
- /* @__PURE__ */ t("tbody", { children: o.map((x, k) => /* @__PURE__ */ t(
144
+ /* @__PURE__ */ t("tbody", { children: d.map((x, N) => /* @__PURE__ */ t(
136
145
  "tr",
137
146
  {
138
- onClick: x.id != null ? () => c.open({ collection: n.collection, itemId: String(x.id) }) : void 0,
147
+ onClick: x.id != null ? () => u.open({ collection: n.collection, itemId: String(x.id) }) : void 0,
139
148
  className: `border-b border-slate-50 last:border-0 dark:border-border/50 ${x.id != null ? "cursor-pointer hover:bg-slate-50 dark:hover:bg-muted/40" : ""}`,
140
- children: s.map((_) => /* @__PURE__ */ t(
149
+ children: o.map((C) => /* @__PURE__ */ t(
141
150
  "td",
142
151
  {
143
152
  className: "whitespace-nowrap px-3 py-1.5 text-slate-700 dark:text-slate-300",
144
- children: $t(x[_])
153
+ children: Rt(x[C])
145
154
  },
146
- _
155
+ C
147
156
  ))
148
157
  },
149
- x.id != null ? `${x.id}-${k}` : k
158
+ x.id != null ? `${x.id}-${N}` : N
150
159
  )) })
151
160
  ] }) });
152
161
  }
153
- function qt({ slug: e, widget: r }) {
154
- const n = r.config ?? {}, { data: a, isLoading: l, error: u } = pe(e, r, !!n.collection);
155
- return n.collection ? u ? /* @__PURE__ */ t(le, { error: u }) : /* @__PURE__ */ p("div", { className: "flex h-full flex-col items-start justify-center px-4", children: [
156
- l ? /* @__PURE__ */ t("div", { className: "h-9 w-24 animate-pulse rounded bg-slate-100 dark:bg-[hsl(var(--nvr-skeleton))]" }) : /* @__PURE__ */ t("span", { className: "text-[32px] font-semibold leading-none tracking-tight text-slate-900 dark:text-slate-100", children: (a == null ? void 0 : a.value) != null ? gt(Number(a.value)) : "—" }),
162
+ function Ot({ slug: e, widget: r }) {
163
+ const n = r.config ?? {}, { data: s, isLoading: l, error: m } = ge(e, r, !!n.collection);
164
+ return n.collection ? m ? /* @__PURE__ */ t(ie, { error: m }) : /* @__PURE__ */ h("div", { className: "flex h-full flex-col items-start justify-center px-4", children: [
165
+ l ? /* @__PURE__ */ t("div", { className: "h-9 w-24 animate-pulse rounded bg-slate-100 dark:bg-[hsl(var(--nvr-skeleton))]" }) : /* @__PURE__ */ t("span", { className: "text-[32px] font-semibold leading-none tracking-tight text-slate-900 dark:text-slate-100", children: (s == null ? void 0 : s.value) != null ? $t(Number(s.value)) : "—" }),
157
166
  /* @__PURE__ */ t("span", { className: "mt-1.5 text-[12px] text-slate-400", children: n.label || `${n.aggregate ?? "count"} of ${n.collection}` })
158
167
  ] }) : /* @__PURE__ */ t("div", { className: "p-3 text-[12px] text-slate-400", children: "Select a collection" });
159
168
  }
160
- function Tt({ slug: e, widget: r }) {
161
- const { data: n, isLoading: a, error: l } = pe(e, r, !0);
162
- if (a) return /* @__PURE__ */ t(ae, {});
163
- if (l) return /* @__PURE__ */ t(le, { error: l });
164
- const u = (n == null ? void 0 : n.rows) ?? [];
165
- return u.length ? /* @__PURE__ */ t("div", { className: "h-full overflow-auto px-3 py-1.5", children: u.map((c) => /* @__PURE__ */ p(
169
+ function At({ slug: e, widget: r }) {
170
+ const { data: n, isLoading: s, error: l } = ge(e, r, !0);
171
+ if (s) return /* @__PURE__ */ t(oe, {});
172
+ if (l) return /* @__PURE__ */ t(ie, { error: l });
173
+ const m = (n == null ? void 0 : n.rows) ?? [];
174
+ return m.length ? /* @__PURE__ */ t("div", { className: "h-full overflow-auto px-3 py-1.5", children: m.map((u) => /* @__PURE__ */ h(
166
175
  "div",
167
176
  {
168
177
  className: "flex items-center gap-2 border-b border-slate-50 py-1.5 text-[12px] last:border-0 dark:border-border/50",
169
178
  children: [
170
- /* @__PURE__ */ t("span", { className: "font-medium text-slate-700 dark:text-slate-300", children: c.action }),
171
- c.collection && /* @__PURE__ */ p("span", { className: "truncate font-mono text-[11px] text-slate-400", children: [
172
- c.collection,
173
- c.item ? ` · ${c.item}` : ""
179
+ /* @__PURE__ */ t("span", { className: "font-medium text-slate-700 dark:text-slate-300", children: u.action }),
180
+ u.collection && /* @__PURE__ */ h("span", { className: "truncate font-mono text-[11px] text-slate-400", children: [
181
+ u.collection,
182
+ u.item ? ` · ${u.item}` : ""
174
183
  ] }),
175
- /* @__PURE__ */ t("span", { className: "ml-auto shrink-0 text-[11px] text-slate-400", children: bt(c.timestamp) })
184
+ /* @__PURE__ */ t("span", { className: "ml-auto shrink-0 text-[11px] text-slate-400", children: St(u.timestamp) })
176
185
  ]
177
186
  },
178
- c.id
187
+ u.id
179
188
  )) }) : /* @__PURE__ */ t("div", { className: "p-3 text-[12px] text-slate-400", children: "No activity" });
180
189
  }
181
- function jt({ widget: e }) {
190
+ function Ft({ widget: e }) {
182
191
  var n;
183
192
  const r = String(((n = e.config) == null ? void 0 : n.url) ?? "");
184
193
  return r ? /^https?:\/\//i.test(r) ? /* @__PURE__ */ t(
@@ -191,23 +200,23 @@ function jt({ widget: e }) {
191
200
  }
192
201
  ) : /* @__PURE__ */ t("div", { className: "p-3 text-[12px] text-amber-600", children: "URL must start with http(s)://" }) : /* @__PURE__ */ t("div", { className: "p-3 text-[12px] text-slate-400", children: "Set an iframe URL" });
193
202
  }
194
- function De({
203
+ function Qe({
195
204
  config: e,
196
205
  initialScope: r,
197
206
  width: n,
198
- title: a,
207
+ title: s,
199
208
  onClose: l
200
209
  }) {
201
- const u = typeof n == "number" ? `${n}px` : n ?? "85%";
202
- return /* @__PURE__ */ t("div", { className: "fixed inset-0 z-50 flex justify-end bg-black/30", onClick: l, children: /* @__PURE__ */ p(
210
+ const m = typeof n == "number" ? `${n}px` : n ?? "85%";
211
+ return /* @__PURE__ */ t("div", { className: "fixed inset-0 z-50 flex justify-end bg-black/30", onClick: l, children: /* @__PURE__ */ h(
203
212
  "div",
204
213
  {
205
214
  className: "flex h-full flex-col border-l border-slate-200 bg-white shadow-2xl dark:border-border dark:bg-background",
206
- style: { width: u, maxWidth: "96%" },
207
- onClick: (c) => c.stopPropagation(),
215
+ style: { width: m, maxWidth: "96%" },
216
+ onClick: (u) => u.stopPropagation(),
208
217
  children: [
209
- /* @__PURE__ */ p("div", { className: "flex shrink-0 items-center justify-between border-b border-slate-200 px-4 py-2.5 dark:border-border", children: [
210
- /* @__PURE__ */ t("p", { className: "text-[13px] font-semibold text-slate-700 dark:text-slate-200", children: a ?? e.title ?? "Manage" }),
218
+ /* @__PURE__ */ h("div", { className: "flex shrink-0 items-center justify-between border-b border-slate-200 px-4 py-2.5 dark:border-border", children: [
219
+ /* @__PURE__ */ t("p", { className: "text-[13px] font-semibold text-slate-700 dark:text-slate-200", children: s ?? e.title ?? "Manage" }),
211
220
  /* @__PURE__ */ t(
212
221
  "button",
213
222
  {
@@ -218,94 +227,95 @@ function De({
218
227
  }
219
228
  )
220
229
  ] }),
221
- /* @__PURE__ */ t("div", { className: "min-h-0 flex-1 overflow-auto", children: /* @__PURE__ */ t(he, { config: e, initialScope: r }) })
230
+ /* @__PURE__ */ t("div", { className: "min-h-0 flex-1 overflow-auto", children: /* @__PURE__ */ t(fe, { config: e, initialScope: r }) })
222
231
  ]
223
232
  }
224
233
  ) });
225
234
  }
226
- function Rt({ widget: e }) {
227
- const r = e.config ?? {}, [n, a] = j(!1);
228
- return !r.target_collection || !r.option_collection || !r.key_field || !r.value_field ? /* @__PURE__ */ t("div", { className: "p-3 text-[12px] text-slate-400", children: "Matrix editor not configured" }) : r.display === "drawer" ? /* @__PURE__ */ p("div", { className: "flex h-full items-center", children: [
235
+ function Et({ widget: e }) {
236
+ const r = e.config ?? {}, [n, s] = T(!1);
237
+ return !r.target_collection || !r.option_collection || !r.key_field || !r.value_field ? /* @__PURE__ */ t("div", { className: "p-3 text-[12px] text-slate-400", children: "Matrix editor not configured" }) : r.display === "drawer" ? /* @__PURE__ */ h("div", { className: "flex h-full items-center", children: [
229
238
  /* @__PURE__ */ t(
230
239
  "button",
231
240
  {
232
241
  type: "button",
233
- onClick: () => a(!0),
242
+ onClick: () => s(!0),
234
243
  className: "inline-flex h-8 items-center gap-1.5 whitespace-nowrap rounded-md border border-slate-200 bg-white px-3 text-[12.5px] font-medium text-slate-700 shadow-sm transition-colors hover:border-nvr-cyan hover:text-nvr-navy dark:border-border dark:bg-card dark:text-slate-200 dark:hover:text-nvr-cyan",
235
244
  children: r.button_label ?? r.title ?? "Manage"
236
245
  }
237
246
  ),
238
247
  n && /* @__PURE__ */ t(
239
- De,
248
+ Qe,
240
249
  {
241
250
  config: r,
242
251
  width: r.sheet_width,
243
- onClose: () => a(!1)
252
+ onClose: () => s(!1)
244
253
  }
245
254
  )
246
- ] }) : /* @__PURE__ */ t(he, { config: r });
255
+ ] }) : /* @__PURE__ */ t(fe, { config: r });
247
256
  }
248
- function Wt(e) {
249
- return dt(
257
+ function Bt(e) {
258
+ return ft(
250
259
  e,
251
260
  typeof window > "u" ? "" : window.location.search
252
261
  );
253
262
  }
254
- function Pe(e, r) {
255
- const n = [...new Set(e.map((a) => a[r]).filter((a) => a != null && a !== ""))];
263
+ function Fe(e, r) {
264
+ const n = [...new Set(e.map((s) => s[r]).filter((s) => s != null && s !== ""))];
256
265
  return n.length ? n.map(String).join(",") : void 0;
257
266
  }
258
- function Ie(e, r, n, a, l, u, c) {
267
+ function Ue(e, r, n, s, l, m, u) {
259
268
  if (typeof e != "string") return e;
260
269
  if (e.startsWith("$row.")) {
261
- const o = e.slice(5);
262
- return !r && c ? Pe(c, o) : r == null ? void 0 : r[o];
270
+ const d = e.slice(5);
271
+ return !r && u ? Fe(u, d) : r == null ? void 0 : r[d];
263
272
  }
264
- if (e.startsWith("$rows.")) return Pe(n, e.slice(6));
265
- if (e.startsWith("$param.")) return a[e.slice(7)];
273
+ if (e.startsWith("$rows.")) return Fe(n, e.slice(6));
274
+ if (e.startsWith("$param.")) return s[e.slice(7)];
266
275
  if (e.startsWith("$filters.")) {
267
- const o = e.slice(9), s = u == null ? void 0 : u.find((x) => x.param === o), m = l[o] ?? [];
268
- return m.length ? m.map((x) => String(x[(s == null ? void 0 : s.value_field) ?? "id"] ?? "")).join(",") : void 0;
276
+ const d = e.slice(9), o = m == null ? void 0 : m.find((x) => x.param === d), c = l[d] ?? [];
277
+ return c.length ? c.map((x) => String(x[(o == null ? void 0 : o.value_field) ?? "id"] ?? "")).join(",") : void 0;
269
278
  }
270
279
  return e;
271
280
  }
272
- function Mt(e, r, n, a, l, u, c) {
273
- const o = {}, s = [];
274
- for (const [m, x] of Object.entries(e.params ?? {})) {
275
- const k = Ie(x, r, n, a, l, u, c);
276
- k !== void 0 ? o[m] = k : typeof x == "string" && (x.startsWith("$row.") || x.startsWith("$rows.")) && s.push(m);
281
+ function Dt(e, r, n, s, l, m, u) {
282
+ const d = {}, o = [];
283
+ for (const [c, x] of Object.entries(e.params ?? {})) {
284
+ const N = Ue(x, r, n, s, l, m, u);
285
+ N !== void 0 ? d[c] = N : typeof x == "string" && (x.startsWith("$row.") || x.startsWith("$rows.")) && o.push(c);
277
286
  }
278
- return { ...e, params: o, ...s.length ? { unresolved_params: s } : {} };
287
+ return { ...e, params: d, ...o.length ? { unresolved_params: o } : {} };
279
288
  }
280
- function Ot(e, r) {
281
- var l, u;
289
+ function It(e, r) {
290
+ var l, m;
282
291
  let n = (l = e.row_noun) == null ? void 0 : l.trim();
283
292
  if (!n) {
284
- const c = (u = /\{\{\s*([a-z]+)_[\w.]*\s*\}\}/i.exec(e.title ?? "")) == null ? void 0 : u[1];
285
- n = c ? `${c.toLowerCase()}s` : "rows";
293
+ const u = (m = /\{\{\s*([a-z]+)_[\w.]*\s*\}\}/i.exec(e.title ?? "")) == null ? void 0 : m[1];
294
+ n = u ? `${u.toLowerCase()}s` : "rows";
286
295
  }
287
- const a = r === 1 && n.endsWith("s") ? n.slice(0, -1) : n;
288
- return `Total of ${r.toLocaleString("en-US")} ${a}`;
296
+ const s = r === 1 && n.endsWith("s") ? n.slice(0, -1) : n;
297
+ return `Total of ${r.toLocaleString("en-US")} ${s}`;
289
298
  }
290
- function Ft(e, r) {
291
- const n = st(e), a = [n.title, n.technical ?? ""].join(" "), l = /Missing required parameter:\s*([\w]+)/i.exec(a);
299
+ function zt(e, r) {
300
+ const n = ut(e), s = [n.title, n.technical ?? ""].join(" "), l = /Missing required parameter:\s*([\w]+)/i.exec(s);
292
301
  if (!l) return null;
293
- const u = K(l[1]).toLowerCase();
294
- return r != null && r.includes(l[1]) ? `Nothing to show: the row you opened has no ${u}.` : `Choose ${u} to see this view.`;
302
+ const m = Q(l[1]).toLowerCase();
303
+ return r != null && r.includes(l[1]) ? `Nothing to show: the row you opened has no ${m}.` : `Choose ${m} to see this view.`;
295
304
  }
296
- function Pt({
305
+ function Kt({
297
306
  config: e,
298
307
  stats: r,
299
308
  asOf: n,
300
- note: a
309
+ note: s
301
310
  }) {
302
- const l = X(), u = e.params ?? {}, { data: c, isPending: o, isError: s } = G({
311
+ const l = re(), m = be(), u = e.params ?? {}, { data: d, isPending: o, isError: c } = Y({
303
312
  queryKey: ["page-renderer-query", e.query_slug, JSON.stringify(u)],
304
313
  queryFn: () => l.request(
305
- ne(`/custom-queries/${e.query_slug}/execute`, { params: u })
314
+ le(`/custom-queries/${e.query_slug}/execute`, { params: u })
306
315
  ),
307
316
  enabled: !!e.query_slug,
308
- staleTime: 6e4
317
+ staleTime: 6e4,
318
+ meta: m
309
319
  });
310
320
  return /* @__PURE__ */ t(
311
321
  "div",
@@ -313,63 +323,63 @@ function Pt({
313
323
  className: "shrink-0 border-b border-slate-200 bg-white px-4 py-3 dark:border-border dark:bg-card",
314
324
  "data-sheet-header": !0,
315
325
  children: /* @__PURE__ */ t(
316
- St,
326
+ Mt,
317
327
  {
318
328
  stats: r,
319
- rows: (c == null ? void 0 : c.data) ?? [],
329
+ rows: (d == null ? void 0 : d.data) ?? [],
320
330
  params: u,
321
- loading: o && !s,
322
- error: s,
331
+ loading: o && !c,
332
+ error: c,
323
333
  asOf: n,
324
- note: a
334
+ note: s
325
335
  }
326
336
  )
327
337
  }
328
338
  );
329
339
  }
330
- function At({
340
+ function Qt({
331
341
  def: e,
332
342
  row: r,
333
343
  totalCount: n,
334
- onClose: a
344
+ onClose: s
335
345
  }) {
336
- const [l, u] = j(e.initialTab ?? 0), c = !r && n != null ? Ot(e, n) : e.title ? e.title.replace(/\{\{\s*([\w.]+)\s*\}\}/g, (m, x) => {
337
- const k = r == null ? void 0 : r[x];
338
- return k == null ? "" : String(k);
339
- }) : "Details", o = typeof e.width == "number" ? `${e.width}px` : e.width ?? "90%", s = e.resolvedTabs[l];
340
- return /* @__PURE__ */ t("div", { className: "fixed inset-0 z-50 flex justify-end bg-black/30", onClick: a, children: /* @__PURE__ */ p(
346
+ const [l, m] = T(e.initialTab ?? 0), u = !r && n != null ? It(e, n) : e.title ? e.title.replace(/\{\{\s*([\w.]+)\s*\}\}/g, (c, x) => {
347
+ const N = r == null ? void 0 : r[x];
348
+ return N == null ? "" : String(N);
349
+ }) : "Details", d = typeof e.width == "number" ? `${e.width}px` : e.width ?? "90%", o = e.resolvedTabs[l];
350
+ return /* @__PURE__ */ t("div", { className: "fixed inset-0 z-50 flex justify-end bg-black/30", onClick: s, children: /* @__PURE__ */ h(
341
351
  "div",
342
352
  {
343
353
  className: "flex h-full flex-col border-l border-slate-200 bg-slate-50 shadow-2xl dark:border-border dark:bg-background",
344
- style: { width: o, maxWidth: "96%" },
345
- onClick: (m) => m.stopPropagation(),
354
+ style: { width: d, maxWidth: "96%" },
355
+ onClick: (c) => c.stopPropagation(),
346
356
  children: [
347
- /* @__PURE__ */ p("div", { className: "flex shrink-0 items-center justify-between border-b border-slate-200 bg-white px-4 py-2.5 dark:border-border dark:bg-card", children: [
348
- /* @__PURE__ */ p("div", { className: "flex items-center gap-3", children: [
349
- /* @__PURE__ */ t("p", { className: "text-[13px] font-semibold text-slate-700 dark:text-slate-200", children: c }),
350
- e.resolvedTabs.length > 1 && /* @__PURE__ */ t("div", { className: "flex gap-1", children: e.resolvedTabs.map((m, x) => /* @__PURE__ */ t(
357
+ /* @__PURE__ */ h("div", { className: "flex shrink-0 items-center justify-between border-b border-slate-200 bg-white px-4 py-2.5 dark:border-border dark:bg-card", children: [
358
+ /* @__PURE__ */ h("div", { className: "flex items-center gap-3", children: [
359
+ /* @__PURE__ */ t("p", { className: "text-[13px] font-semibold text-slate-700 dark:text-slate-200", children: u }),
360
+ e.resolvedTabs.length > 1 && /* @__PURE__ */ t("div", { className: "flex gap-1", children: e.resolvedTabs.map((c, x) => /* @__PURE__ */ t(
351
361
  "button",
352
362
  {
353
363
  type: "button",
354
- onClick: () => u(x),
364
+ onClick: () => m(x),
355
365
  className: `rounded-md px-2.5 py-1 text-[12px] font-medium transition-colors ${x === l ? "bg-nvr-cyan/10 text-slate-800 dark:text-slate-100" : "text-slate-500 hover:text-slate-700 dark:hover:text-slate-300"}`,
356
- children: m.label
366
+ children: c.label
357
367
  },
358
- m.label
368
+ c.label
359
369
  )) })
360
370
  ] }),
361
371
  /* @__PURE__ */ t(
362
372
  "button",
363
373
  {
364
374
  type: "button",
365
- onClick: a,
375
+ onClick: s,
366
376
  className: "rounded px-2 py-1 text-[12px] text-slate-500 hover:bg-slate-100 hover:text-slate-700 dark:hover:bg-muted",
367
377
  children: "Close"
368
378
  }
369
379
  )
370
380
  ] }),
371
381
  e.header && /* @__PURE__ */ t(
372
- Pt,
382
+ Kt,
373
383
  {
374
384
  config: e.header.config,
375
385
  stats: e.header.stats,
@@ -377,148 +387,148 @@ function At({
377
387
  note: e.header.note
378
388
  }
379
389
  ),
380
- /* @__PURE__ */ t("div", { className: "min-h-0 flex-1 overflow-auto", children: s != null && s.matrix ? /* @__PURE__ */ t(
381
- he,
390
+ /* @__PURE__ */ t("div", { className: "min-h-0 flex-1 overflow-auto", children: o != null && o.matrix ? /* @__PURE__ */ t(
391
+ fe,
382
392
  {
383
- config: s.matrix.config,
384
- initialScope: s.matrix.initialScope,
393
+ config: o.matrix.config,
394
+ initialScope: o.matrix.initialScope,
385
395
  lockScope: !0
386
396
  },
387
397
  l
388
- ) : s != null && s.config ? /* @__PURE__ */ p(J, { children: [
389
- s.note && /* @__PURE__ */ t(
398
+ ) : o != null && o.config ? /* @__PURE__ */ h(H, { children: [
399
+ o.note && /* @__PURE__ */ t(
390
400
  "p",
391
401
  {
392
402
  className: "border-b border-slate-200 bg-white px-4 py-1.5 text-[11.5px] text-slate-500 dark:border-border dark:bg-card dark:text-slate-400",
393
403
  "data-sheet-tab-note": !0,
394
- children: s.note
404
+ children: o.note
395
405
  }
396
406
  ),
397
- /* @__PURE__ */ t(ze, { config: s.config }, l)
407
+ /* @__PURE__ */ t(Ve, { config: o.config }, l)
398
408
  ] }) : /* @__PURE__ */ t("p", { className: "p-4 text-[12px] text-slate-400", children: "Sheet not configured" }) })
399
409
  ]
400
410
  }
401
411
  ) });
402
412
  }
403
- function Et(e, r, n, a) {
413
+ function Ut(e, r, n, s) {
404
414
  if (!e) return;
405
- const l = (s) => {
406
- const m = /^\$filters\.(\w+)(?:\.(\w+))?$/.exec(s);
407
- if (!m) return;
408
- const x = a == null ? void 0 : a.find((w) => w.param === m[1]), k = (n == null ? void 0 : n[m[1]]) ?? [];
409
- if (k.length === 0) return;
410
- const _ = m[2] ?? (x == null ? void 0 : x.value_field) ?? "id";
411
- return k.map((w) => w[_]);
412
- }, u = (s) => typeof s == "string" && s.startsWith("$row.") ? r[s.slice(5)] : typeof s == "string" && s.startsWith("$filters.") ? l(s) : Array.isArray(s) ? s.map(u) : s && typeof s == "object" ? Object.fromEntries(
413
- Object.entries(s).map(([m, x]) => [m, u(x)])
414
- ) : s, c = (s) => s === void 0 ? !0 : Array.isArray(s) ? s.some(c) : s && typeof s == "object" ? Object.values(s).some(c) : !1, o = u(e);
415
- return Array.isArray(o._and) && (o._and = o._and.filter((s) => !c(s))), c(o) ? void 0 : o;
415
+ const l = (o) => {
416
+ const c = /^\$filters\.(\w+)(?:\.(\w+))?$/.exec(o);
417
+ if (!c) return;
418
+ const x = s == null ? void 0 : s.find((S) => S.param === c[1]), N = (n == null ? void 0 : n[c[1]]) ?? [];
419
+ if (N.length === 0) return;
420
+ const C = c[2] ?? (x == null ? void 0 : x.value_field) ?? "id";
421
+ return N.map((S) => S[C]);
422
+ }, m = (o) => typeof o == "string" && o.startsWith("$row.") ? r[o.slice(5)] : typeof o == "string" && o.startsWith("$filters.") ? l(o) : Array.isArray(o) ? o.map(m) : o && typeof o == "object" ? Object.fromEntries(
423
+ Object.entries(o).map(([c, x]) => [c, m(x)])
424
+ ) : o, u = (o) => o === void 0 ? !0 : Array.isArray(o) ? o.some(u) : o && typeof o == "object" ? Object.values(o).some(u) : !1, d = m(e);
425
+ return Array.isArray(d._and) && (d._and = d._and.filter((o) => !u(o))), u(d) ? void 0 : d;
416
426
  }
417
- const Lt = 400, Bt = 2500;
418
- function Ae(e, r) {
427
+ const Vt = 400, Gt = 2500;
428
+ function Ee(e, r) {
419
429
  return e.map((n) => String(n[r] ?? "")).sort().join("\0");
420
430
  }
421
- function Dt({
431
+ function Jt({
422
432
  filter: e,
423
433
  selected: r,
424
434
  onChange: n,
425
- allowedIds: a,
435
+ allowedIds: s,
426
436
  scopeDefault: l,
427
- onOpenChange: u
437
+ onOpenChange: m
428
438
  }) {
429
- const c = X(), [o, s] = j(!1), m = Y(u);
430
- m.current = u, re(() => {
431
- var b;
432
- (b = m.current) == null || b.call(m, o);
433
- }, [o]);
434
- const [x, k] = j(""), _ = Y(null), w = e.value_field ?? "id", q = e.label_field ?? w, S = e.secondary_field, O = [.../* @__PURE__ */ new Set(["id", w, q, S ?? ""])].filter(Boolean).join(","), { data: M } = G({
439
+ const u = re(), [d, o] = T(!1), c = ee(m);
440
+ c.current = m, te(() => {
441
+ var f;
442
+ (f = c.current) == null || f.call(c, d);
443
+ }, [d]);
444
+ const [x, N] = T(""), C = ee(null), S = e.value_field ?? "id", q = e.label_field ?? S, v = e.secondary_field, j = [.../* @__PURE__ */ new Set(["id", S, q, v ?? ""])].filter(Boolean).join(","), { data: W } = Y({
435
445
  queryKey: [
436
446
  "page-renderer-filter",
437
447
  e.collection,
438
- w,
448
+ S,
439
449
  q,
440
- S ?? "",
450
+ v ?? "",
441
451
  e.sort
442
452
  ],
443
- queryFn: () => c.request(
444
- me(`/items/${e.collection}`, {
445
- fields: O,
453
+ queryFn: () => u.request(
454
+ xe(`/items/${e.collection}`, {
455
+ fields: j,
446
456
  limit: e.limit ?? 500,
447
457
  ...e.sort ? { sort: e.sort } : {}
448
458
  })
449
- ).then((b) => {
450
- const C = b.data ?? [], B = typeof b.total == "number" && b.total > C.length || C.length >= (e.limit ?? 500);
451
- return { rows: C, more: B };
459
+ ).then((f) => {
460
+ const a = f.data ?? [], g = typeof f.total == "number" && f.total > a.length || a.length >= (e.limit ?? 500);
461
+ return { rows: a, more: g };
452
462
  }),
453
463
  staleTime: 6e4
454
- }), F = (M == null ? void 0 : M.rows) ?? [], T = (M == null ? void 0 : M.more) === !0, R = x.trim(), P = Ze(R), { data: d = [] } = G({
455
- queryKey: ["page-renderer-filter-search", e.collection, O, P],
456
- enabled: T && P.length > 0,
457
- queryFn: () => c.request(
458
- me(`/items/${e.collection}`, {
459
- fields: O,
464
+ }), U = (W == null ? void 0 : W.rows) ?? [], L = (W == null ? void 0 : W.more) === !0, $ = x.trim(), R = at($), { data: I = [] } = Y({
465
+ queryKey: ["page-renderer-filter-search", e.collection, j, R],
466
+ enabled: L && R.length > 0,
467
+ queryFn: () => u.request(
468
+ xe(`/items/${e.collection}`, {
469
+ fields: j,
460
470
  limit: 100,
461
- search: P,
462
- search_fields: [.../* @__PURE__ */ new Set([w, q, S ?? ""])].filter(Boolean).join(","),
471
+ search: R,
472
+ search_fields: [.../* @__PURE__ */ new Set([S, q, v ?? ""])].filter(Boolean).join(","),
463
473
  ...e.sort ? { sort: e.sort } : {}
464
474
  })
465
- ).then((b) => b.data ?? []),
475
+ ).then((f) => f.data ?? []),
466
476
  staleTime: 6e4
467
477
  });
468
- re(() => {
469
- if (!o) return;
470
- const b = (C) => {
471
- _.current && !_.current.contains(C.target) && s(!1);
478
+ te(() => {
479
+ if (!d) return;
480
+ const f = (a) => {
481
+ C.current && !C.current.contains(a.target) && o(!1);
472
482
  };
473
- return window.addEventListener("mousedown", b), () => window.removeEventListener("mousedown", b);
474
- }, [o]);
475
- const y = e.label ?? K(e.param), L = T && R ? [...r, ...d] : F, Q = ht(
476
- a != null && a.length ? L.filter((b) => a.some((C) => String(C) === String(b.id))) : L,
477
- (b) => String(b[w] ?? "")
478
- ), U = (b) => [b[w], b[q], S ? b[S] : null].filter((C) => C != null && C !== "").join(" ").toLowerCase(), I = Q.filter(
479
- (b) => R ? U(b).includes(R.toLowerCase()) : !0
480
- ), V = T && R.length > 0 && P !== R, D = a != null && a.length ? {
483
+ return window.addEventListener("mousedown", f), () => window.removeEventListener("mousedown", f);
484
+ }, [d]);
485
+ const K = e.label ?? Q(e.param), z = L && $ ? [...r, ...I] : U, E = vt(
486
+ s != null && s.length ? z.filter((f) => s.some((a) => String(a) === String(f.id))) : z,
487
+ (f) => String(f[S] ?? "")
488
+ ), O = (f) => [f[S], f[q], v ? f[v] : null].filter((a) => a != null && a !== "").join(" ").toLowerCase(), V = E.filter(
489
+ (f) => $ ? O(f).includes($.toLowerCase()) : !0
490
+ ), G = L && $.length > 0 && R !== $, B = s != null && s.length ? {
481
491
  label: "restricted",
482
492
  cls: "bg-amber-500/15 text-amber-700 dark:text-amber-300",
483
- title: `Options limited to your restricted ${y} scope${l ? "; selection seeded from your defaults" : ""}`
493
+ title: `Options limited to your restricted ${K} scope${l ? "; selection seeded from your defaults" : ""}`
484
494
  } : l && r.length > 0 ? {
485
495
  label: "your default",
486
496
  cls: "bg-nvr-cyan/[0.12] text-[#0284a8] dark:text-nvr-cyan",
487
- title: `Pre-selected from your default ${y} scope — adjust freely`
497
+ title: `Pre-selected from your default ${K} scope — adjust freely`
488
498
  } : null;
489
- return /* @__PURE__ */ p("div", { ref: _, className: "relative", children: [
490
- /* @__PURE__ */ p(
499
+ return /* @__PURE__ */ h("div", { ref: C, className: "relative", children: [
500
+ /* @__PURE__ */ h(
491
501
  "button",
492
502
  {
493
503
  type: "button",
494
- onClick: () => s((b) => !b),
504
+ onClick: () => o((f) => !f),
495
505
  className: `inline-flex h-8 items-center gap-1.5 rounded-md border px-2.5 text-[12px] transition-colors ${r.length > 0 ? "border-nvr-cyan bg-nvr-cyan/10 text-slate-700 dark:text-slate-200" : "border-slate-200 bg-white text-slate-600 hover:border-slate-400 dark:border-border dark:bg-card dark:text-slate-300"}`,
496
506
  children: [
497
- /* @__PURE__ */ t("span", { className: "font-medium", children: y }),
498
- D && /* @__PURE__ */ t(
507
+ /* @__PURE__ */ t("span", { className: "font-medium", children: K }),
508
+ B && /* @__PURE__ */ t(
499
509
  "span",
500
510
  {
501
- title: D.title,
502
- className: `rounded px-1 py-px text-[9px] font-semibold uppercase tracking-wide ${D.cls}`,
503
- children: D.label
511
+ title: B.title,
512
+ className: `rounded px-1 py-px text-[9px] font-semibold uppercase tracking-wide ${B.cls}`,
513
+ children: B.label
504
514
  }
505
515
  ),
506
- /* @__PURE__ */ t("span", { className: "text-slate-400", children: r.length === 0 ? "All" : r.length === 1 ? String(r[0][q] ?? r[0][w] ?? "") : `${r.length} selected` }),
516
+ /* @__PURE__ */ t("span", { className: "text-slate-400", children: r.length === 0 ? "All" : r.length === 1 ? String(r[0][q] ?? r[0][S] ?? "") : `${r.length} selected` }),
507
517
  /* @__PURE__ */ t("span", { className: "text-slate-400", children: "⌃" })
508
518
  ]
509
519
  }
510
520
  ),
511
- o && /* @__PURE__ */ p("div", { className: "absolute left-0 top-9 z-40 w-56 rounded-md border border-slate-200 bg-white p-1 shadow-md dark:border-border dark:bg-popover", children: [
521
+ d && /* @__PURE__ */ h("div", { className: "absolute left-0 top-9 z-40 w-56 rounded-md border border-slate-200 bg-white p-1 shadow-md dark:border-border dark:bg-popover", children: [
512
522
  /* @__PURE__ */ t(
513
523
  "input",
514
524
  {
515
525
  value: x,
516
- onChange: (b) => k(b.target.value),
526
+ onChange: (f) => N(f.target.value),
517
527
  placeholder: "Search…",
518
528
  className: "mb-1 h-7 w-full rounded border border-slate-200 bg-white px-2 text-[12px] outline-none dark:border-border dark:bg-background"
519
529
  }
520
530
  ),
521
- /* @__PURE__ */ p("div", { className: "max-h-64 overflow-y-auto", children: [
531
+ /* @__PURE__ */ h("div", { className: "max-h-64 overflow-y-auto", children: [
522
532
  r.length > 0 && /* @__PURE__ */ t(
523
533
  "button",
524
534
  {
@@ -528,52 +538,52 @@ function Dt({
528
538
  children: "Clear selection"
529
539
  }
530
540
  ),
531
- I.map((b) => {
532
- const C = String(b[w] ?? ""), B = r.some((A) => String(A[w] ?? "") === C);
533
- return /* @__PURE__ */ p(
541
+ V.map((f) => {
542
+ const a = String(f[S] ?? ""), g = r.some((P) => String(P[S] ?? "") === a);
543
+ return /* @__PURE__ */ h(
534
544
  "button",
535
545
  {
536
546
  type: "button",
537
547
  onClick: () => {
538
548
  if (e.single) {
539
- n(B ? [] : [b]), s(!1);
549
+ n(g ? [] : [f]), o(!1);
540
550
  return;
541
551
  }
542
552
  n(
543
- B ? r.filter((A) => String(A[w] ?? "") !== C) : [...r, b]
553
+ g ? r.filter((P) => String(P[S] ?? "") !== a) : [...r, f]
544
554
  );
545
555
  },
546
556
  className: "flex w-full items-center gap-2 rounded px-2 py-1 text-left text-[12px] text-slate-700 hover:bg-slate-100 dark:text-slate-200 dark:hover:bg-muted",
547
557
  children: [
548
- /* @__PURE__ */ t("span", { className: `w-3.5 shrink-0 text-nvr-cyan ${B ? "" : "invisible"}`, children: "✓" }),
549
- /* @__PURE__ */ t("span", { className: "truncate", children: String(b[q] ?? C) }),
550
- S && b[S] != null && b[S] !== "" && /* @__PURE__ */ t("span", { className: "min-w-0 truncate text-[11px] text-slate-400", children: String(b[S]) })
558
+ /* @__PURE__ */ t("span", { className: `w-3.5 shrink-0 text-nvr-cyan ${g ? "" : "invisible"}`, children: "✓" }),
559
+ /* @__PURE__ */ t("span", { className: "truncate", children: String(f[q] ?? a) }),
560
+ v && f[v] != null && f[v] !== "" && /* @__PURE__ */ t("span", { className: "min-w-0 truncate text-[11px] text-slate-400", children: String(f[v]) })
551
561
  ]
552
562
  },
553
- C
563
+ a
554
564
  );
555
565
  }),
556
- I.length === 0 && /* @__PURE__ */ t("p", { className: "px-2 py-1.5 text-[12px] text-slate-400", "aria-live": "polite", children: V ? "Searching…" : R ? `No matches for “${R}”` : "No options" }),
557
- T && !R && /* @__PURE__ */ p("p", { className: "px-2 py-1.5 text-[11px] text-slate-400", children: [
566
+ V.length === 0 && /* @__PURE__ */ t("p", { className: "px-2 py-1.5 text-[12px] text-slate-400", "aria-live": "polite", children: G ? "Searching…" : $ ? `No matches for “${$}”` : "No options" }),
567
+ L && !$ && /* @__PURE__ */ h("p", { className: "px-2 py-1.5 text-[11px] text-slate-400", children: [
558
568
  "Showing the first ",
559
- F.length.toLocaleString("en-US"),
569
+ U.length.toLocaleString("en-US"),
560
570
  " — type to search all"
561
571
  ] })
562
572
  ] })
563
573
  ] })
564
574
  ] });
565
575
  }
566
- function It({ widget: e }) {
567
- return /* @__PURE__ */ t(ze, { config: e.config ?? {} });
576
+ function Ht({ widget: e }) {
577
+ return /* @__PURE__ */ t(Ve, { config: e.config ?? {} });
568
578
  }
569
- function zt({ widget: e }) {
570
- const r = e.config ?? {}, [n, a] = j(!1);
571
- return r.collection ? r.display === "drawer" ? /* @__PURE__ */ p("div", { className: "flex h-full items-center", children: [
579
+ function Yt({ widget: e }) {
580
+ const r = e.config ?? {}, [n, s] = T(!1);
581
+ return r.collection ? r.display === "drawer" ? /* @__PURE__ */ h("div", { className: "flex h-full items-center", children: [
572
582
  /* @__PURE__ */ t(
573
583
  "button",
574
584
  {
575
585
  type: "button",
576
- onClick: () => a(!0),
586
+ onClick: () => s(!0),
577
587
  className: "inline-flex h-8 items-center gap-1.5 whitespace-nowrap rounded-md border border-slate-200 bg-white px-3 text-[12.5px] font-medium text-slate-700 shadow-sm transition-colors hover:border-nvr-cyan hover:text-nvr-navy dark:border-border dark:bg-card dark:text-slate-200 dark:hover:text-nvr-cyan",
578
588
  children: r.button_label ?? r.title ?? "Manage"
579
589
  }
@@ -582,8 +592,8 @@ function zt({ widget: e }) {
582
592
  "div",
583
593
  {
584
594
  className: "fixed inset-0 z-50 flex justify-end bg-black/30",
585
- onClick: () => a(!1),
586
- children: /* @__PURE__ */ p(
595
+ onClick: () => s(!1),
596
+ children: /* @__PURE__ */ h(
587
597
  "div",
588
598
  {
589
599
  className: "flex h-full flex-col border-l border-slate-200 bg-white shadow-2xl dark:border-border dark:bg-background",
@@ -593,31 +603,31 @@ function zt({ widget: e }) {
593
603
  },
594
604
  onClick: (l) => l.stopPropagation(),
595
605
  children: [
596
- /* @__PURE__ */ p("div", { className: "flex shrink-0 items-center justify-between border-b border-slate-200 px-4 py-2.5 dark:border-border", children: [
606
+ /* @__PURE__ */ h("div", { className: "flex shrink-0 items-center justify-between border-b border-slate-200 px-4 py-2.5 dark:border-border", children: [
597
607
  /* @__PURE__ */ t("p", { className: "text-[13px] font-semibold text-slate-700 dark:text-slate-200", children: r.button_label ?? r.title ?? "Manage" }),
598
608
  /* @__PURE__ */ t(
599
609
  "button",
600
610
  {
601
611
  type: "button",
602
- onClick: () => a(!1),
612
+ onClick: () => s(!1),
603
613
  className: "rounded px-2 py-1 text-[12px] text-slate-500 hover:bg-slate-100 hover:text-slate-700 dark:hover:bg-muted",
604
614
  children: "Close"
605
615
  }
606
616
  )
607
617
  ] }),
608
- /* @__PURE__ */ t("div", { className: "min-h-0 flex-1 overflow-auto", children: /* @__PURE__ */ t(Fe, { config: r }) })
618
+ /* @__PURE__ */ t("div", { className: "min-h-0 flex-1 overflow-auto", children: /* @__PURE__ */ t(Ae, { config: r }) })
609
619
  ]
610
620
  }
611
621
  )
612
622
  }
613
623
  )
614
- ] }) : /* @__PURE__ */ t(Fe, { config: r }) : /* @__PURE__ */ t("div", { className: "p-3 text-[12px] text-slate-400", children: "Configure the record grid (collection)" });
624
+ ] }) : /* @__PURE__ */ t(Ae, { config: r }) : /* @__PURE__ */ t("div", { className: "p-3 text-[12px] text-slate-400", children: "Configure the record grid (collection)" });
615
625
  }
616
- function Kt({
626
+ function Xt({
617
627
  cfg: e
618
628
  }) {
619
- const [r, n] = j(!1), a = { ...e };
620
- return delete a.display, /* @__PURE__ */ p("div", { className: "flex h-full items-center", children: [
629
+ const [r, n] = T(!1), s = { ...e };
630
+ return delete s.display, /* @__PURE__ */ h("div", { className: "flex h-full items-center", children: [
621
631
  /* @__PURE__ */ t(
622
632
  "button",
623
633
  {
@@ -632,7 +642,7 @@ function Kt({
632
642
  {
633
643
  className: "fixed inset-0 z-50 flex justify-end bg-black/30",
634
644
  onClick: () => n(!1),
635
- children: /* @__PURE__ */ p(
645
+ children: /* @__PURE__ */ h(
636
646
  "div",
637
647
  {
638
648
  className: "flex h-full flex-col border-l border-slate-200 bg-slate-50 shadow-2xl dark:border-border dark:bg-background",
@@ -642,7 +652,7 @@ function Kt({
642
652
  },
643
653
  onClick: (l) => l.stopPropagation(),
644
654
  children: [
645
- /* @__PURE__ */ p("div", { className: "flex shrink-0 items-center justify-between border-b border-slate-200 bg-white px-4 py-2.5 dark:border-border dark:bg-card", children: [
655
+ /* @__PURE__ */ h("div", { className: "flex shrink-0 items-center justify-between border-b border-slate-200 bg-white px-4 py-2.5 dark:border-border dark:bg-card", children: [
646
656
  /* @__PURE__ */ t("p", { className: "text-[13px] font-semibold text-slate-700 dark:text-slate-200", children: e.button_label ?? e.label ?? "View" }),
647
657
  /* @__PURE__ */ t(
648
658
  "button",
@@ -654,7 +664,7 @@ function Kt({
654
664
  }
655
665
  )
656
666
  ] }),
657
- /* @__PURE__ */ t("div", { className: "min-h-0 flex-1 overflow-auto", children: /* @__PURE__ */ t(Ke, { config: a }) })
667
+ /* @__PURE__ */ t("div", { className: "min-h-0 flex-1 overflow-auto", children: /* @__PURE__ */ t(Ge, { config: s }) })
658
668
  ]
659
669
  }
660
670
  )
@@ -662,194 +672,196 @@ function Kt({
662
672
  )
663
673
  ] });
664
674
  }
665
- function ze({ config: e }) {
666
- return e.display === "drawer" ? /* @__PURE__ */ t(Kt, { cfg: e }) : /* @__PURE__ */ t(Ke, { config: e });
675
+ function Ve({ config: e }) {
676
+ return e.display === "drawer" ? /* @__PURE__ */ t(Xt, { cfg: e }) : /* @__PURE__ */ t(Ge, { config: e });
667
677
  }
668
- function Ke({ config: e }) {
669
- var Ne, Se, $e, _e, Ce, qe, Te, je, Re, We;
670
- const r = X(), n = Le(), [a, l] = j(null), [u, c] = j(null), [o, s] = j(null), [m, x] = j(
671
- () => Wt(e.filters)
672
- ), [k] = j(
673
- () => it(e.filters, typeof window > "u" ? "" : window.location.search)
674
- ), _ = (i, h) => {
675
- const f = { ...m, [i]: h };
676
- if (x(f), typeof window > "u" || !(e.filters ?? []).some((v) => v.url_param)) return;
677
- const g = ct(e.filters, f, window.location.search);
678
- g !== window.location.search && window.history.replaceState(
678
+ function Ge({ config: e }) {
679
+ var _e, Ce, qe, je, Te, Me, Re, We, Pe, Le;
680
+ const r = re(), n = Ie(), [s, l] = T(null), [m, u] = T(null), [d, o] = T(null), [c, x] = T(
681
+ () => Bt(e.filters)
682
+ ), [N] = T(
683
+ () => xt(e.filters, typeof window > "u" ? "" : window.location.search)
684
+ ), C = (i, p) => {
685
+ const b = { ...c, [i]: p };
686
+ if (x(b), typeof window > "u" || !(e.filters ?? []).some((k) => k.url_param)) return;
687
+ const y = bt(e.filters, b, window.location.search);
688
+ y !== window.location.search && window.history.replaceState(
679
689
  window.history.state,
680
690
  "",
681
- `${window.location.pathname}${g}${window.location.hash}`
691
+ `${window.location.pathname}${y}${window.location.hash}`
682
692
  );
683
- }, [w, q] = j(null), [S, O] = j(null), M = (S == null ? void 0 : S.phase) === "running", F = Ye();
684
- re(() => {
685
- if ((S == null ? void 0 : S.phase) !== "running") return;
693
+ }, [S, q] = T(null), [v, j] = T(null), W = (v == null ? void 0 : v.phase) === "running", U = De(), L = be();
694
+ te(() => {
695
+ if ((v == null ? void 0 : v.phase) !== "running") return;
686
696
  const i = window.setInterval(() => {
687
- O(
688
- (h) => (h == null ? void 0 : h.phase) === "running" ? { ...h, elapsedMs: Date.now() - h.startedAt } : h
697
+ j(
698
+ (p) => (p == null ? void 0 : p.phase) === "running" ? { ...p, elapsedMs: Date.now() - p.startedAt } : p
689
699
  );
690
700
  }, 250);
691
701
  return () => window.clearInterval(i);
692
- }, [S == null ? void 0 : S.phase]);
693
- const { scopes: T, ready: R } = pt(), P = Y(!1), [d, y] = j(!1), [L, Q] = j(/* @__PURE__ */ new Map());
694
- re(() => {
695
- if (P.current || !R) return;
696
- P.current = !0;
702
+ }, [v == null ? void 0 : v.phase]);
703
+ const { scopes: $, ready: R } = kt(), I = ee(!1), [K, z] = T(!1), [E, O] = T(/* @__PURE__ */ new Map());
704
+ te(() => {
705
+ if (I.current || !R) return;
706
+ I.current = !0;
697
707
  const i = (e.filters ?? []).filter(
698
- (h) => !(m[h.param] ?? []).length && !k.has(h.param)
708
+ (p) => !(c[p.param] ?? []).length && !N.has(p.param)
699
709
  );
700
- if (!T || !i.length) {
701
- y(!0);
710
+ if (!$ || !i.length) {
711
+ z(!0);
702
712
  return;
703
713
  }
704
714
  (async () => {
705
715
  try {
706
- const h = {};
707
- for (const f of i) {
708
- const g = Oe(T, { key: f.param, collection: f.collection });
709
- if (!g) continue;
710
- const v = xt(T, g.name);
711
- if (!v.length) continue;
712
- const $ = f.value_field ?? "id", E = await ft(
716
+ const p = {};
717
+ for (const b of i) {
718
+ const y = Oe($, { key: b.param, collection: b.collection });
719
+ if (!y) continue;
720
+ const k = wt($, y.name);
721
+ if (!k.length) continue;
722
+ const _ = b.value_field ?? "id", F = await Nt(
713
723
  r,
714
- g,
715
- v,
716
- $
724
+ y,
725
+ k,
726
+ _
717
727
  );
718
- if (E.length) {
719
- const W = E.map((ee, ie) => ({ [$]: ee, id: v[ie] }));
720
- h[f.param] = f.single ? W.slice(0, 1) : W;
728
+ if (F.length) {
729
+ const M = F.map((ae, ce) => ({ [_]: ae, id: k[ce] }));
730
+ p[b.param] = b.single ? M.slice(0, 1) : M;
721
731
  }
722
732
  }
723
- Object.keys(h).length && (x((f) => {
724
- const g = { ...f };
725
- for (const [v, $] of Object.entries(h))
726
- (g[v] ?? []).length || (g[v] = $);
727
- return g;
728
- }), Q(
733
+ Object.keys(p).length && (x((b) => {
734
+ const y = { ...b };
735
+ for (const [k, _] of Object.entries(p))
736
+ (y[k] ?? []).length || (y[k] = _);
737
+ return y;
738
+ }), O(
729
739
  new Map(
730
- Object.entries(h).map(([f, g]) => {
731
- var $;
732
- const v = (($ = (e.filters ?? []).find((E) => E.param === f)) == null ? void 0 : $.value_field) ?? "id";
733
- return [f, Ae(g, v)];
740
+ Object.entries(p).map(([b, y]) => {
741
+ var _;
742
+ const k = ((_ = (e.filters ?? []).find((F) => F.param === b)) == null ? void 0 : _.value_field) ?? "id";
743
+ return [b, Ee(y, k)];
734
744
  })
735
745
  )
736
746
  ));
737
747
  } finally {
738
- y(!0);
748
+ z(!0);
739
749
  }
740
750
  })();
741
- }, [R, T, e.filters, m, r, k]);
742
- const U = Me(() => {
751
+ }, [R, $, e.filters, c, r, N]);
752
+ const V = he(() => {
743
753
  const i = { ...e.params ?? {} };
744
- for (const h of e.filters ?? []) {
745
- const f = m[h.param] ?? [];
746
- f.length > 0 && (i[h.param] = f.map((g) => String(g[h.value_field ?? "id"] ?? "")).join(","));
754
+ for (const p of e.filters ?? []) {
755
+ const b = c[p.param] ?? [];
756
+ b.length > 0 && (i[p.param] = b.map((y) => String(y[p.value_field ?? "id"] ?? "")).join(","));
747
757
  }
748
758
  return i;
749
- }, [e.params, e.filters, m]), [I, V] = j(/* @__PURE__ */ new Set()), D = Y(!1), b = JSON.stringify(U), C = lt(
750
- b,
751
- D.current ? I.size > 0 ? Bt : Lt : 0
752
- ), B = D.current ? C : b, A = Me(
753
- () => JSON.parse(B),
754
- [B]
755
- ), se = Y(!1), {
756
- data: z,
757
- isPending: xe,
758
- error: fe,
759
- refetch: be,
760
- isFetching: ge,
761
- isPlaceholderData: Qe
762
- } = G({
763
- queryKey: ["page-renderer-query", e.query_slug, B],
759
+ }, [e.params, e.filters, c]), [G, B] = T(/* @__PURE__ */ new Set()), f = ee(!1), a = JSON.stringify(V), g = ct(
760
+ a,
761
+ f.current ? G.size > 0 ? Gt : Vt : 0
762
+ ), P = f.current ? g : a, D = he(
763
+ () => JSON.parse(P),
764
+ [P]
765
+ ), J = ee(!1), {
766
+ data: A,
767
+ isPending: X,
768
+ error: ye,
769
+ refetch: ve,
770
+ isFetching: ke,
771
+ isPlaceholderData: Je
772
+ } = Y({
773
+ queryKey: ["page-renderer-query", e.query_slug, P],
764
774
  queryFn: () => {
765
- const i = se.current;
766
- return se.current = !1, r.request(
767
- ne(`/custom-queries/${e.query_slug}/execute`, {
768
- params: A,
775
+ const i = J.current;
776
+ return J.current = !1, r.request(
777
+ le(`/custom-queries/${e.query_slug}/execute`, {
778
+ params: D,
769
779
  ...i ? { refresh: !0 } : {}
770
780
  })
771
781
  );
772
782
  },
773
- enabled: !!e.query_slug && d,
783
+ enabled: !!e.query_slug && K,
774
784
  staleTime: 6e4,
785
+ meta: L,
775
786
  // A filter change (FY, zone) keeps the table on screen, dimmed, until the
776
787
  // new answer lands: swapping it for the loader unmounted QueryTable and
777
788
  // reset its view state — "Hide empty rows" switched itself off (L13).
778
789
  // Only the same query's answer stands in; another slug starts fresh.
779
- placeholderData: (i, h) => (h == null ? void 0 : h.queryKey[1]) === e.query_slug ? i : void 0
780
- }), H = z == null ? void 0 : z.data, Z = Qe && ge, Ue = Xe(() => {
781
- se.current = !0, be();
782
- }, [be]), ye = xe;
790
+ placeholderData: (i, p) => (p == null ? void 0 : p.queryKey[1]) === e.query_slug ? i : void 0
791
+ }), Z = A == null ? void 0 : A.data, ne = Je && ke, He = rt(() => {
792
+ J.current = !0, ve();
793
+ }, [ve]), we = X;
783
794
  if (!e.query_slug) return /* @__PURE__ */ t("div", { className: "p-3 text-[12px] text-slate-400", children: "Set a query slug" });
784
- const Ve = (i) => {
785
- var v;
786
- const h = {};
787
- for (const [$, E] of Object.entries(i.params ?? {})) {
788
- const W = Ie(E, null, H ?? [], A, m, e.filters);
789
- if (W === void 0) {
790
- q(`Select a value for "${$}" first`);
795
+ const Ye = (i) => {
796
+ var k;
797
+ const p = {};
798
+ for (const [_, F] of Object.entries(i.params ?? {})) {
799
+ const M = Ue(F, null, Z ?? [], D, c, e.filters);
800
+ if (M === void 0) {
801
+ q(`Select a value for "${_}" first`);
791
802
  return;
792
803
  }
793
- h[$] = W;
804
+ p[_] = M;
794
805
  }
795
- const f = (v = i.confirm) == null ? void 0 : v.replace(/\{(\w+)\}/g, ($, E) => String(h[E] ?? "")), g = {
806
+ const b = (k = i.confirm) == null ? void 0 : k.replace(/\{(\w+)\}/g, (_, F) => String(p[F] ?? "")), y = {
796
807
  action: i,
797
- params: h,
798
- phase: f ? "confirm" : "running",
799
- confirmText: f ?? null,
808
+ params: p,
809
+ phase: b ? "confirm" : "running",
810
+ confirmText: b ?? null,
800
811
  startedAt: Date.now(),
801
812
  elapsedMs: 0
802
813
  };
803
- O(g), f || ve(g);
804
- }, ve = async (i) => {
805
- const h = Date.now();
806
- O({ ...i, phase: "running", startedAt: h, elapsedMs: 0 });
814
+ j(y), b || Ne(y);
815
+ }, Ne = async (i) => {
816
+ const p = Date.now();
817
+ j({ ...i, phase: "running", startedAt: p, elapsedMs: 0 });
807
818
  try {
808
- const f = await r.request(
809
- ne(`/custom-queries/${i.action.query_slug}/execute`, { params: i.params })
810
- ), g = Array.isArray(f == null ? void 0 : f.data) ? f.data : [];
811
- O(
812
- (v) => v && v.action === i.action ? {
813
- ...v,
819
+ const b = await r.request(
820
+ le(`/custom-queries/${i.action.query_slug}/execute`, { params: i.params })
821
+ ), y = Array.isArray(b == null ? void 0 : b.data) ? b.data : [];
822
+ j(
823
+ (k) => k && k.action === i.action ? {
824
+ ...k,
814
825
  phase: "done",
815
- elapsedMs: Date.now() - h,
816
- resultRows: g.length,
817
- resultSample: g[0] ?? null
818
- } : v
826
+ elapsedMs: Date.now() - p,
827
+ resultRows: y.length,
828
+ resultSample: y[0] ?? null
829
+ } : k
819
830
  ), q(
820
- `${i.action.success_message ?? `${i.action.label} completed`} · ${te(Date.now() - h)}`
821
- ), F.invalidateQueries({ queryKey: ["page-renderer-query", e.query_slug] });
822
- } catch (f) {
823
- const g = Be(f, "unknown error");
824
- O(
825
- (v) => v && v.action === i.action ? { ...v, phase: "error", elapsedMs: Date.now() - h, error: g } : v
826
- ), q(`${i.action.label} failed: ${g}`);
831
+ `${i.action.success_message ?? `${i.action.label} completed`} · ${se(Date.now() - p)}`
832
+ ), U.invalidateQueries({ queryKey: ["page-renderer-query", e.query_slug] });
833
+ } catch (b) {
834
+ const y = ze(b, "unknown error");
835
+ j(
836
+ (k) => k && k.action === i.action ? { ...k, phase: "error", elapsedMs: Date.now() - p, error: y } : k
837
+ ), q(`${i.action.label} failed: ${y}`);
827
838
  }
828
- }, Je = /* @__PURE__ */ t(
829
- yt,
839
+ }, Xe = /* @__PURE__ */ t(
840
+ _t,
830
841
  {
831
- envelope: z,
832
- onRefresh: Ue,
833
- refreshing: ge && !xe,
842
+ scope: `query:${e.query_slug}`,
843
+ envelope: A,
844
+ onRefresh: He,
845
+ refreshing: ke && !X,
834
846
  className: "ml-auto"
835
847
  }
836
- ), oe = e.filters && e.filters.length > 0 || (Ne = e.actions) != null && Ne.length || z != null && z.cache_ttl ? /* @__PURE__ */ p("div", { className: "flex flex-wrap items-center gap-2 pb-2", children: [
848
+ ), de = e.filters && e.filters.length > 0 || (_e = e.actions) != null && _e.length || A != null && A.cache_ttl ? /* @__PURE__ */ h("div", { className: "flex flex-wrap items-center gap-2 pb-2", children: [
837
849
  (e.filters ?? []).map((i) => {
838
- const h = Oe(T, { key: i.param, collection: i.collection }), f = h ? (T == null ? void 0 : T.restricted[h.name]) ?? [] : [];
850
+ const p = Oe($, { key: i.param, collection: i.collection }), b = p ? ($ == null ? void 0 : $.restricted[p.name]) ?? [] : [];
839
851
  return /* @__PURE__ */ t(
840
- Dt,
852
+ Jt,
841
853
  {
842
854
  filter: i,
843
- selected: m[i.param] ?? [],
844
- allowedIds: f.length > 0 ? f : void 0,
845
- scopeDefault: L.has(i.param) && L.get(i.param) === Ae(m[i.param] ?? [], i.value_field ?? "id"),
846
- onChange: (g) => {
847
- D.current = !0, _(i.param, g);
855
+ selected: c[i.param] ?? [],
856
+ allowedIds: b.length > 0 ? b : void 0,
857
+ scopeDefault: E.has(i.param) && E.get(i.param) === Ee(c[i.param] ?? [], i.value_field ?? "id"),
858
+ onChange: (y) => {
859
+ f.current = !0, C(i.param, y);
848
860
  },
849
- onOpenChange: (g) => V((v) => {
850
- if (v.has(i.param) === g) return v;
851
- const $ = new Set(v);
852
- return g ? $.add(i.param) : $.delete(i.param), $;
861
+ onOpenChange: (y) => B((k) => {
862
+ if (k.has(i.param) === y) return k;
863
+ const _ = new Set(k);
864
+ return y ? _.add(i.param) : _.delete(i.param), _;
853
865
  })
854
866
  },
855
867
  i.param
@@ -859,94 +871,94 @@ function Ke({ config: e }) {
859
871
  "button",
860
872
  {
861
873
  type: "button",
862
- disabled: M,
863
- onClick: () => void Ve(i),
874
+ disabled: W,
875
+ onClick: () => void Ye(i),
864
876
  className: "ml-auto inline-flex h-8 items-center rounded-md bg-nvr-cyan px-3 text-[12px] font-semibold text-white hover:opacity-90 disabled:opacity-50",
865
- children: M ? "Running…" : i.label
877
+ children: W ? "Running…" : i.label
866
878
  },
867
879
  i.label
868
880
  )),
869
- w && /* @__PURE__ */ t("span", { className: "text-[12px] text-slate-500", children: w }),
870
- Je
871
- ] }) : null, ke = (Se = e.stats) != null && Se.length ? /* @__PURE__ */ t(
872
- kt,
881
+ S && /* @__PURE__ */ t("span", { className: "text-[12px] text-slate-500", children: S }),
882
+ Xe
883
+ ] }) : null, Se = (Ce = e.stats) != null && Ce.length ? /* @__PURE__ */ t(
884
+ qt,
873
885
  {
874
886
  stats: e.stats,
875
- rows: H ?? [],
876
- effectiveParams: A,
877
- loading: ye || Z,
878
- zeroDash: !!(($e = e.table) != null && $e.zero_dash)
887
+ rows: Z ?? [],
888
+ effectiveParams: D,
889
+ loading: we || ne,
890
+ zeroDash: !!((qe = e.table) != null && qe.zero_dash)
879
891
  }
880
892
  ) : null;
881
- if (ye)
882
- return /* @__PURE__ */ p("div", { className: "p-3", children: [
883
- oe,
884
- ke,
885
- /* @__PURE__ */ t(ae, {})
893
+ if (we)
894
+ return /* @__PURE__ */ h("div", { className: "p-3", children: [
895
+ de,
896
+ Se,
897
+ /* @__PURE__ */ t(oe, {})
886
898
  ] });
887
- if (fe)
888
- return /* @__PURE__ */ p("div", { className: "p-3", children: [
889
- oe,
890
- /* @__PURE__ */ t(le, { error: fe, unresolved: e.unresolved_params })
899
+ if (ye)
900
+ return /* @__PURE__ */ h("div", { className: "p-3", children: [
901
+ de,
902
+ /* @__PURE__ */ t(ie, { error: ye, unresolved: e.unresolved_params })
891
903
  ] });
892
- const N = e.row_click, we = (i, h, f) => {
893
- const g = h ? null : f ?? H ?? [], $ = mt(i, (W) => Mt(
894
- W,
895
- h,
896
- H ?? [],
897
- A,
898
- m,
904
+ const w = e.row_click, $e = (i, p, b) => {
905
+ const y = p ? null : b ?? Z ?? [], _ = yt(i, (M) => Dt(
906
+ M,
907
+ p,
908
+ Z ?? [],
909
+ D,
910
+ c,
899
911
  e.filters,
900
- g
901
- )), E = $.resolvedTabs.map((W) => {
902
- if ("matrix" in W) {
903
- const ee = {};
904
- for (const [ie, de] of Object.entries(W.matrix.scope))
905
- ee[ie] = de.startsWith("$row.") ? h == null ? void 0 : h[de.slice(5)] : de;
912
+ y
913
+ )), F = _.resolvedTabs.map((M) => {
914
+ if ("matrix" in M) {
915
+ const ae = {};
916
+ for (const [ce, ue] of Object.entries(M.matrix.scope))
917
+ ae[ce] = ue.startsWith("$row.") ? p == null ? void 0 : p[ue.slice(5)] : ue;
906
918
  return {
907
- label: W.label,
908
- matrix: { config: W.matrix.config, initialScope: ee }
919
+ label: M.label,
920
+ matrix: { config: M.matrix.config, initialScope: ae }
909
921
  };
910
922
  }
911
- return { label: W.label, note: W.note, config: W.config };
923
+ return { label: M.label, note: M.note, config: M.config };
912
924
  });
913
- s({
925
+ o({
914
926
  def: {
915
927
  ...i,
916
- resolvedTabs: E,
917
- header: $.header ? {
918
- config: $.header.config,
919
- stats: $.header.stats,
920
- asOf: $.header.asOf,
921
- note: $.header.note
928
+ resolvedTabs: F,
929
+ header: _.header ? {
930
+ config: _.header.config,
931
+ stats: _.header.stats,
932
+ asOf: _.header.asOf,
933
+ note: _.header.note
922
934
  } : null,
923
- initialTab: $.initialTab
935
+ initialTab: _.initialTab
924
936
  },
925
- row: h,
926
- totalCount: g ? g.length : null
937
+ row: p,
938
+ totalCount: y ? y.length : null
927
939
  });
928
- }, Ge = N ? (i) => {
929
- N.picker ? l(i) : N.sheet ? we(N.sheet, i) : N.matrix && i.id != null ? c(i.id) : N.drill && i.id != null && (n == null || n.open({
930
- collection: N.drill.collection ?? "",
940
+ }, Ze = w ? (i) => {
941
+ w.picker ? l(i) : w.sheet ? $e(w.sheet, i) : w.matrix && i.id != null ? u(i.id) : w.drill && i.id != null && (n == null || n.open({
942
+ collection: w.drill.collection ?? "",
931
943
  itemId: String(i.id),
932
- layoutId: N.drill.layout_id,
933
- width: N.drill.width
944
+ layoutId: w.drill.layout_id,
945
+ width: w.drill.width
934
946
  }));
935
- } : void 0, He = (_e = e.row_actions) != null && _e.length ? e.row_actions.map((i) => ({
947
+ } : void 0, et = (je = e.row_actions) != null && je.length ? e.row_actions.map((i) => ({
936
948
  label: i.label,
937
- onClick: (h, f) => we(i.sheet, h, f)
949
+ onClick: (p, b) => $e(i.sheet, p, b)
938
950
  })) : void 0;
939
- return /* @__PURE__ */ p(
951
+ return /* @__PURE__ */ h(
940
952
  "div",
941
953
  {
942
- className: (Ce = e.table) != null && Ce.sticky ? (
954
+ className: (Te = e.table) != null && Te.sticky ? (
943
955
  // Sticky grids own their scroll: filters/stats stay pinned above a
944
956
  // scrolling table region (header/first-column/totals pin inside it).
945
957
  "flex h-full min-h-0 flex-col overflow-hidden p-3"
946
958
  ) : "h-full overflow-auto p-3",
947
959
  children: [
948
- oe,
949
- ((qe = e.note) == null ? void 0 : qe.trim()) && /* @__PURE__ */ t(
960
+ de,
961
+ ((Me = e.note) == null ? void 0 : Me.trim()) && /* @__PURE__ */ t(
950
962
  "p",
951
963
  {
952
964
  "data-query-note": !0,
@@ -954,65 +966,65 @@ function Ke({ config: e }) {
954
966
  children: e.note
955
967
  }
956
968
  ),
957
- ke,
969
+ Se,
958
970
  /* @__PURE__ */ t(
959
971
  "div",
960
972
  {
961
- "data-qt-refetching": Z ? "" : void 0,
962
- "aria-busy": Z || void 0,
963
- className: `transition-opacity ${Z ? "opacity-60" : ""} ${(Te = e.table) != null && Te.sticky ? "flex min-h-0 flex-1 flex-col" : ""}`.trim(),
973
+ "data-qt-refetching": ne ? "" : void 0,
974
+ "aria-busy": ne || void 0,
975
+ className: `transition-opacity ${ne ? "opacity-60" : ""} ${(Re = e.table) != null && Re.sticky ? "flex min-h-0 flex-1 flex-col" : ""}`.trim(),
964
976
  children: /* @__PURE__ */ t(
965
- wt,
977
+ jt,
966
978
  {
967
- rows: H ?? [],
979
+ rows: Z ?? [],
968
980
  config: (
969
981
  // Current-month highlight only applies when the selected year param
970
982
  // IS the current year — otherwise strip it.
971
- (je = e.table) != null && je.highlight_group && e.table.highlight_year_param ? Number(
972
- String(A[e.table.highlight_year_param] ?? "").split(",")[0]
983
+ (We = e.table) != null && We.highlight_group && e.table.highlight_year_param ? Number(
984
+ String(D[e.table.highlight_year_param] ?? "").split(",")[0]
973
985
  ) === (/* @__PURE__ */ new Date()).getFullYear() ? e.table : { ...e.table, highlight_group: void 0 } : e.table
974
986
  ),
975
- onRowClick: Ge,
976
- rowActions: He,
987
+ onRowClick: Ze,
988
+ rowActions: et,
977
989
  emptyText: e.empty_label,
978
- pivotYear: (We = (Re = e.table) == null ? void 0 : Re.pivot) != null && We.year_param && Number(String(A[e.table.pivot.year_param] ?? "").split(",")[0]) || void 0
990
+ pivotYear: (Le = (Pe = e.table) == null ? void 0 : Pe.pivot) != null && Le.year_param && Number(String(D[e.table.pivot.year_param] ?? "").split(",")[0]) || void 0
979
991
  }
980
992
  )
981
993
  }
982
994
  ),
983
- (N == null ? void 0 : N.picker) && a && /* @__PURE__ */ t(
995
+ (w == null ? void 0 : w.picker) && s && /* @__PURE__ */ t(
984
996
  "div",
985
997
  {
986
998
  className: "fixed inset-0 z-50 flex items-start justify-center bg-black/30 pt-32",
987
999
  onClick: () => l(null),
988
- children: /* @__PURE__ */ p(
1000
+ children: /* @__PURE__ */ h(
989
1001
  "div",
990
1002
  {
991
1003
  className: "w-[420px] rounded-lg border border-slate-200 bg-white p-4 shadow-xl dark:border-border dark:bg-background",
992
1004
  onClick: (i) => i.stopPropagation(),
993
1005
  children: [
994
- /* @__PURE__ */ t("p", { className: "mb-2 text-[13px] font-semibold text-slate-700 dark:text-slate-200", children: N.picker.title ?? "Choose a record" }),
1006
+ /* @__PURE__ */ t("p", { className: "mb-2 text-[13px] font-semibold text-slate-700 dark:text-slate-200", children: w.picker.title ?? "Choose a record" }),
995
1007
  /* @__PURE__ */ t(
996
- vt,
1008
+ Ct,
997
1009
  {
998
- collection: N.picker.collection,
1010
+ collection: w.picker.collection,
999
1011
  value: null,
1000
1012
  onChange: (i) => {
1001
- var h, f, g, v;
1013
+ var p, b, y, k;
1002
1014
  if (l(null), i != null) {
1003
- if (N.matrix) {
1004
- c(i);
1015
+ if (w.matrix) {
1016
+ u(i);
1005
1017
  return;
1006
1018
  }
1007
1019
  n == null || n.open({
1008
- collection: ((h = N.drill) == null ? void 0 : h.collection) ?? ((f = N.picker) == null ? void 0 : f.collection) ?? "",
1020
+ collection: ((p = w.drill) == null ? void 0 : p.collection) ?? ((b = w.picker) == null ? void 0 : b.collection) ?? "",
1009
1021
  itemId: String(i),
1010
- layoutId: (g = N.drill) == null ? void 0 : g.layout_id,
1011
- width: (v = N.drill) == null ? void 0 : v.width
1022
+ layoutId: (y = w.drill) == null ? void 0 : y.layout_id,
1023
+ width: (k = w.drill) == null ? void 0 : k.width
1012
1024
  });
1013
1025
  }
1014
1026
  },
1015
- extraFilter: Et(N.picker.filter, a, m, e.filters),
1027
+ extraFilter: Ut(w.picker.filter, s, c, e.filters),
1016
1028
  placeholder: "Search…"
1017
1029
  }
1018
1030
  ),
@@ -1030,32 +1042,32 @@ function Ke({ config: e }) {
1030
1042
  )
1031
1043
  }
1032
1044
  ),
1033
- (N == null ? void 0 : N.matrix) && u != null && /* @__PURE__ */ t(
1034
- De,
1045
+ (w == null ? void 0 : w.matrix) && m != null && /* @__PURE__ */ t(
1046
+ Qe,
1035
1047
  {
1036
- config: N.matrix.config,
1037
- initialScope: { [N.matrix.scope_field]: u },
1038
- width: N.matrix.width,
1039
- title: N.matrix.title,
1040
- onClose: () => c(null)
1048
+ config: w.matrix.config,
1049
+ initialScope: { [w.matrix.scope_field]: m },
1050
+ width: w.matrix.width,
1051
+ title: w.matrix.title,
1052
+ onClose: () => u(null)
1041
1053
  }
1042
1054
  ),
1043
- o && /* @__PURE__ */ t(
1044
- At,
1055
+ d && /* @__PURE__ */ t(
1056
+ Qt,
1045
1057
  {
1046
- def: o.def,
1047
- row: o.row,
1048
- totalCount: o.totalCount,
1049
- onClose: () => s(null)
1058
+ def: d.def,
1059
+ row: d.row,
1060
+ totalCount: d.totalCount,
1061
+ onClose: () => o(null)
1050
1062
  }
1051
1063
  ),
1052
- S && /* @__PURE__ */ t(
1053
- Qt,
1064
+ v && /* @__PURE__ */ t(
1065
+ Zt,
1054
1066
  {
1055
- run: S,
1056
- onConfirm: () => void ve(S),
1067
+ run: v,
1068
+ onConfirm: () => void Ne(v),
1057
1069
  onClose: () => {
1058
- O(null);
1070
+ j(null);
1059
1071
  }
1060
1072
  }
1061
1073
  )
@@ -1063,15 +1075,15 @@ function Ke({ config: e }) {
1063
1075
  }
1064
1076
  );
1065
1077
  }
1066
- const te = (e) => e < 6e4 ? `${(e / 1e3).toFixed(e < 1e4 ? 1 : 0)}s` : `${Math.floor(e / 6e4)}m ${Math.round(e % 6e4 / 1e3)}s`;
1067
- function Qt({
1078
+ const se = (e) => e < 6e4 ? `${(e / 1e3).toFixed(e < 1e4 ? 1 : 0)}s` : `${Math.floor(e / 6e4)}m ${Math.round(e % 6e4 / 1e3)}s`;
1079
+ function Zt({
1068
1080
  run: e,
1069
1081
  onConfirm: r,
1070
1082
  onClose: n
1071
1083
  }) {
1072
- const a = Object.entries(e.params);
1073
- return et(
1074
- /* @__PURE__ */ p(J, { children: [
1084
+ const s = Object.entries(e.params);
1085
+ return st(
1086
+ /* @__PURE__ */ h(H, { children: [
1075
1087
  /* @__PURE__ */ t(
1076
1088
  "div",
1077
1089
  {
@@ -1080,7 +1092,7 @@ function Qt({
1080
1092
  onClick: e.phase === "running" ? void 0 : n
1081
1093
  }
1082
1094
  ),
1083
- /* @__PURE__ */ p(
1095
+ /* @__PURE__ */ h(
1084
1096
  "div",
1085
1097
  {
1086
1098
  role: "dialog",
@@ -1089,13 +1101,13 @@ function Qt({
1089
1101
  className: "fixed left-1/2 top-[24vh] z-50 w-[min(400px,92vw)] -translate-x-1/2 rounded-xl border border-slate-200 bg-white p-4 shadow-2xl dark:border-border dark:bg-card",
1090
1102
  children: [
1091
1103
  /* @__PURE__ */ t("p", { className: "text-[13.5px] font-semibold text-slate-900 dark:text-foreground", children: e.action.label }),
1092
- a.length > 0 && /* @__PURE__ */ t("dl", { className: "mt-2 space-y-0.5 rounded-lg bg-slate-50 px-2.5 py-1.5 text-[11.5px] dark:bg-muted", children: a.map(([l, u]) => /* @__PURE__ */ p("div", { className: "flex gap-2", children: [
1093
- /* @__PURE__ */ t("dt", { className: "text-slate-500 dark:text-slate-400", children: K(l) }),
1094
- /* @__PURE__ */ t("dd", { className: "ml-auto font-medium tabular-nums text-slate-800 dark:text-slate-100", children: String(u) })
1104
+ s.length > 0 && /* @__PURE__ */ t("dl", { className: "mt-2 space-y-0.5 rounded-lg bg-slate-50 px-2.5 py-1.5 text-[11.5px] dark:bg-muted", children: s.map(([l, m]) => /* @__PURE__ */ h("div", { className: "flex gap-2", children: [
1105
+ /* @__PURE__ */ t("dt", { className: "text-slate-500 dark:text-slate-400", children: Q(l) }),
1106
+ /* @__PURE__ */ t("dd", { className: "ml-auto font-medium tabular-nums text-slate-800 dark:text-slate-100", children: String(m) })
1095
1107
  ] }, l)) }),
1096
- e.phase === "confirm" && /* @__PURE__ */ p(J, { children: [
1108
+ e.phase === "confirm" && /* @__PURE__ */ h(H, { children: [
1097
1109
  /* @__PURE__ */ t("p", { className: "mt-2 text-[12.5px] text-slate-600 dark:text-slate-300", children: e.confirmText }),
1098
- /* @__PURE__ */ p("div", { className: "mt-3 flex gap-2", children: [
1110
+ /* @__PURE__ */ h("div", { className: "mt-3 flex gap-2", children: [
1099
1111
  /* @__PURE__ */ t(
1100
1112
  "button",
1101
1113
  {
@@ -1116,23 +1128,23 @@ function Qt({
1116
1128
  )
1117
1129
  ] })
1118
1130
  ] }),
1119
- e.phase === "running" && /* @__PURE__ */ p("div", { className: "mt-3 flex items-center gap-2.5 text-[12.5px] text-slate-600 dark:text-slate-300", children: [
1131
+ e.phase === "running" && /* @__PURE__ */ h("div", { className: "mt-3 flex items-center gap-2.5 text-[12.5px] text-slate-600 dark:text-slate-300", children: [
1120
1132
  /* @__PURE__ */ t("span", { className: "h-4 w-4 shrink-0 animate-spin rounded-full border-2 border-nvr-cyan border-t-transparent" }),
1121
1133
  "Running… ",
1122
- /* @__PURE__ */ t("span", { className: "tabular-nums", children: te(e.elapsedMs) })
1134
+ /* @__PURE__ */ t("span", { className: "tabular-nums", children: se(e.elapsedMs) })
1123
1135
  ] }),
1124
- e.phase === "done" && /* @__PURE__ */ p(J, { children: [
1125
- /* @__PURE__ */ p("p", { className: "mt-2 text-[12.5px] font-medium text-emerald-600 dark:text-emerald-400", children: [
1136
+ e.phase === "done" && /* @__PURE__ */ h(H, { children: [
1137
+ /* @__PURE__ */ h("p", { className: "mt-2 text-[12.5px] font-medium text-emerald-600 dark:text-emerald-400", children: [
1126
1138
  e.action.success_message ?? "Completed",
1127
1139
  " · ",
1128
- te(e.elapsedMs)
1140
+ se(e.elapsedMs)
1129
1141
  ] }),
1130
- e.resultRows != null && e.resultRows > 0 && e.resultSample && /* @__PURE__ */ p("dl", { className: "mt-2 max-h-40 space-y-0.5 overflow-y-auto rounded-lg bg-slate-50 px-2.5 py-1.5 text-[11.5px] dark:bg-muted", children: [
1131
- Object.entries(e.resultSample).slice(0, 8).map(([l, u]) => /* @__PURE__ */ p("div", { className: "flex gap-2", children: [
1132
- /* @__PURE__ */ t("dt", { className: "text-slate-500 dark:text-slate-400", children: K(l) }),
1133
- /* @__PURE__ */ t("dd", { className: "ml-auto font-medium tabular-nums text-slate-800 dark:text-slate-100", children: String(u ?? "—") })
1142
+ e.resultRows != null && e.resultRows > 0 && e.resultSample && /* @__PURE__ */ h("dl", { className: "mt-2 max-h-40 space-y-0.5 overflow-y-auto rounded-lg bg-slate-50 px-2.5 py-1.5 text-[11.5px] dark:bg-muted", children: [
1143
+ Object.entries(e.resultSample).slice(0, 8).map(([l, m]) => /* @__PURE__ */ h("div", { className: "flex gap-2", children: [
1144
+ /* @__PURE__ */ t("dt", { className: "text-slate-500 dark:text-slate-400", children: Q(l) }),
1145
+ /* @__PURE__ */ t("dd", { className: "ml-auto font-medium tabular-nums text-slate-800 dark:text-slate-100", children: String(m ?? "—") })
1134
1146
  ] }, l)),
1135
- e.resultRows > 1 && /* @__PURE__ */ p("p", { className: "pt-0.5 text-slate-400", children: [
1147
+ e.resultRows > 1 && /* @__PURE__ */ h("p", { className: "pt-0.5 text-slate-400", children: [
1136
1148
  "…",
1137
1149
  e.resultRows,
1138
1150
  " result rows"
@@ -1148,14 +1160,14 @@ function Qt({
1148
1160
  }
1149
1161
  )
1150
1162
  ] }),
1151
- e.phase === "error" && /* @__PURE__ */ p(J, { children: [
1152
- /* @__PURE__ */ p("p", { className: "mt-2 text-[12.5px] font-medium text-red-600 dark:text-red-400", children: [
1163
+ e.phase === "error" && /* @__PURE__ */ h(H, { children: [
1164
+ /* @__PURE__ */ h("p", { className: "mt-2 text-[12.5px] font-medium text-red-600 dark:text-red-400", children: [
1153
1165
  "Failed after ",
1154
- te(e.elapsedMs),
1166
+ se(e.elapsedMs),
1155
1167
  ": ",
1156
1168
  e.error
1157
1169
  ] }),
1158
- /* @__PURE__ */ p("div", { className: "mt-3 flex gap-2", children: [
1170
+ /* @__PURE__ */ h("div", { className: "mt-3 flex gap-2", children: [
1159
1171
  /* @__PURE__ */ t(
1160
1172
  "button",
1161
1173
  {
@@ -1183,45 +1195,70 @@ function Qt({
1183
1195
  document.body
1184
1196
  );
1185
1197
  }
1186
- function Ee({ slug: e, widget: r }) {
1198
+ function Be({ slug: e, widget: r }) {
1187
1199
  var n;
1188
1200
  switch (r.type) {
1189
1201
  case "table":
1190
- return /* @__PURE__ */ t(Ct, { slug: e, widget: r });
1202
+ return /* @__PURE__ */ t(Lt, { slug: e, widget: r });
1191
1203
  case "kpi":
1192
- return /* @__PURE__ */ t(qt, { slug: e, widget: r });
1204
+ return /* @__PURE__ */ t(Ot, { slug: e, widget: r });
1193
1205
  case "markdown":
1194
- return /* @__PURE__ */ t(_t, { content: String(((n = r.config) == null ? void 0 : n.content) ?? "") });
1206
+ return /* @__PURE__ */ t(Wt, { content: String(((n = r.config) == null ? void 0 : n.content) ?? "") });
1195
1207
  case "iframe":
1196
- return /* @__PURE__ */ t(jt, { widget: r });
1208
+ return /* @__PURE__ */ t(Ft, { widget: r });
1197
1209
  case "query":
1198
- return /* @__PURE__ */ t(It, { widget: r });
1210
+ return /* @__PURE__ */ t(Ht, { widget: r });
1199
1211
  case "matrix":
1200
- return /* @__PURE__ */ t(Rt, { widget: r });
1212
+ return /* @__PURE__ */ t(Et, { widget: r });
1201
1213
  case "record-grid":
1202
- return /* @__PURE__ */ t(zt, { widget: r });
1214
+ return /* @__PURE__ */ t(Yt, { widget: r });
1203
1215
  case "recent-activity":
1204
- return /* @__PURE__ */ t(Tt, { slug: e, widget: r });
1216
+ return /* @__PURE__ */ t(At, { slug: e, widget: r });
1205
1217
  default:
1206
1218
  return /* @__PURE__ */ t("div", { className: "p-3 text-[12px] text-slate-400", children: "Unknown widget" });
1207
1219
  }
1208
1220
  }
1209
- function fr({ slug: e, hideHeader: r, className: n }) {
1210
- var R, P;
1211
- const a = X(), { isAdmin: l } = tt(), u = Le(), c = rt("drill.page"), o = c.value, {
1212
- data: s,
1213
- isLoading: m,
1214
- error: x
1215
- } = G({
1221
+ function _r({
1222
+ slug: e,
1223
+ hideHeader: r,
1224
+ className: n,
1225
+ liveReads: s,
1226
+ liveGapMs: l
1227
+ }) {
1228
+ var B, f;
1229
+ const m = re(), u = De(), d = (s ?? []).filter(Boolean).join(","), o = he(
1230
+ () => d ? {
1231
+ reads: d.split(","),
1232
+ minGapMs: l ?? 15e3,
1233
+ // Server-cached figures are dropped a moment after the write (a few seconds'
1234
+ // window): read after that, and spread the viewers out.
1235
+ delayMs: 3500,
1236
+ jitterMs: 3e3
1237
+ } : null,
1238
+ [d, l]
1239
+ ), [c, x] = T(0);
1240
+ te(() => {
1241
+ if (o)
1242
+ return u.getQueryCache().subscribe((a) => {
1243
+ if (a.type !== "updated" || a.action.type !== "success") return;
1244
+ const g = a.query;
1245
+ !Pt.has(String(g.queryKey[0])) || g.state.dataUpdateCount < 2 || x(Date.now());
1246
+ });
1247
+ }, [u, o]);
1248
+ const N = pt(c, { enabled: !!o }), { isAdmin: C } = lt(), S = Ie(), q = ot("drill.page"), v = q.value, {
1249
+ data: j,
1250
+ isLoading: W,
1251
+ error: U
1252
+ } = Y({
1216
1253
  queryKey: ["page-renderer", e],
1217
- queryFn: () => a.request(me(`/pages/${e}`)).then((d) => d.data),
1254
+ queryFn: () => m.request(xe(`/pages/${e}`)).then((a) => a.data),
1218
1255
  enabled: !!e,
1219
1256
  retry: !1
1220
1257
  });
1221
- if (m)
1222
- return /* @__PURE__ */ t("div", { className: n ?? "p-6", children: /* @__PURE__ */ t(ae, {}) });
1223
- if (x || !s)
1224
- return /* @__PURE__ */ p(
1258
+ if (W)
1259
+ return /* @__PURE__ */ t("div", { className: n ?? "p-6", children: /* @__PURE__ */ t(oe, {}) });
1260
+ if (U || !j)
1261
+ return /* @__PURE__ */ h(
1225
1262
  "div",
1226
1263
  {
1227
1264
  className: `flex flex-col items-center justify-center p-10 text-center ${n ?? ""}`,
@@ -1231,81 +1268,81 @@ function fr({ slug: e, hideHeader: r, className: n }) {
1231
1268
  ]
1232
1269
  }
1233
1270
  );
1234
- const k = ((R = s.layout) == null ? void 0 : R.columns) ?? 12, _ = ot(((P = s.layout) == null ? void 0 : P.widgets) ?? [], l), w = (d) => {
1235
- var y;
1236
- return (d.type === "matrix" || d.type === "query" || d.type === "record-grid") && ((y = d.config) == null ? void 0 : y.display) === "drawer";
1237
- }, q = [...new Set(_.filter(w).map((d) => d.y))].filter((d) => _.every((y) => w(y) || d < y.y || d >= y.y + Math.max(y.h, 1))).sort((d, y) => d - y), S = q.map((d) => ({
1238
- y: d,
1239
- items: _.filter((y) => y.y === d && w(y)).sort((y, L) => y.x - L.x)
1240
- })), O = _.filter((d) => !(w(d) && q.includes(d.y))), M = (d) => d - q.filter((y) => y < d).length, F = O.find((d) => {
1241
- var y;
1242
- return (y = d.config) == null ? void 0 : y.full_height;
1243
- }), T = /* @__PURE__ */ p("div", { className: `flex h-full min-h-0 flex-col ${n ?? ""}`, children: [
1244
- !r && /* @__PURE__ */ t("div", { className: "shrink-0 pb-4", children: /* @__PURE__ */ t("h1", { className: "text-lg font-semibold text-slate-900 dark:text-slate-100", children: s.name }) }),
1245
- /* @__PURE__ */ t("div", { className: `min-h-0 flex-1 overflow-y-auto ${F ? "flex flex-col" : ""}`, children: _.length === 0 ? /* @__PURE__ */ t("p", { className: "p-6 text-center text-[13px] text-slate-400", children: "This page has no widgets yet." }) : /* @__PURE__ */ p(J, { children: [
1246
- S.map((d) => /* @__PURE__ */ t("div", { className: "mb-3 flex shrink-0 flex-wrap items-center gap-2", children: d.items.map((y) => /* @__PURE__ */ t(Ee, { slug: s.slug, widget: y }, y.id)) }, d.y)),
1271
+ const L = ((B = j.layout) == null ? void 0 : B.columns) ?? 12, $ = ht(((f = j.layout) == null ? void 0 : f.widgets) ?? [], C), R = (a) => {
1272
+ var g;
1273
+ return (a.type === "matrix" || a.type === "query" || a.type === "record-grid") && ((g = a.config) == null ? void 0 : g.display) === "drawer";
1274
+ }, I = [...new Set($.filter(R).map((a) => a.y))].filter((a) => $.every((g) => R(g) || a < g.y || a >= g.y + Math.max(g.h, 1))).sort((a, g) => a - g), K = I.map((a) => ({
1275
+ y: a,
1276
+ items: $.filter((g) => g.y === a && R(g)).sort((g, P) => g.x - P.x)
1277
+ })), z = $.filter((a) => !(R(a) && I.includes(a.y))), E = (a) => a - I.filter((g) => g < a).length, O = z.find((a) => {
1278
+ var g;
1279
+ return (g = a.config) == null ? void 0 : g.full_height;
1280
+ }), V = /* @__PURE__ */ h("div", { ref: N, className: `flex h-full min-h-0 flex-col ${n ?? ""}`, children: [
1281
+ !r && /* @__PURE__ */ t("div", { className: "shrink-0 pb-4", children: /* @__PURE__ */ t("h1", { className: "text-lg font-semibold text-slate-900 dark:text-slate-100", children: j.name }) }),
1282
+ /* @__PURE__ */ t("div", { className: `min-h-0 flex-1 overflow-y-auto ${O ? "flex flex-col" : ""}`, children: $.length === 0 ? /* @__PURE__ */ t("p", { className: "p-6 text-center text-[13px] text-slate-400", children: "This page has no widgets yet." }) : /* @__PURE__ */ h(H, { children: [
1283
+ K.map((a) => /* @__PURE__ */ t("div", { className: "mb-3 flex shrink-0 flex-wrap items-center gap-2", children: a.items.map((g) => /* @__PURE__ */ t(Be, { slug: j.slug, widget: g }, g.id)) }, a.y)),
1247
1284
  /* @__PURE__ */ t(
1248
1285
  "div",
1249
1286
  {
1250
- className: F ? "grid min-h-0 flex-1 gap-4" : "grid gap-4",
1287
+ className: O ? "grid min-h-0 flex-1 gap-4" : "grid gap-4",
1251
1288
  style: {
1252
- gridTemplateColumns: `repeat(${k}, minmax(0, 1fr))`,
1289
+ gridTemplateColumns: `repeat(${L}, minmax(0, 1fr))`,
1253
1290
  // repeat(0, …) is INVALID CSS (count must be ≥1) and drops the
1254
1291
  // whole declaration — a fill widget in the first row band emits
1255
1292
  // just the stretching track.
1256
- ...F ? {
1257
- gridTemplateRows: `${M(F.y) > 0 ? `repeat(${M(F.y)}, ${ce}px) ` : ""}minmax(${ce * 3}px, 1fr)`
1293
+ ...O ? {
1294
+ gridTemplateRows: `${E(O.y) > 0 ? `repeat(${E(O.y)}, ${me}px) ` : ""}minmax(${me * 3}px, 1fr)`
1258
1295
  } : {},
1259
- gridAutoRows: `${ce}px`
1296
+ gridAutoRows: `${me}px`
1260
1297
  },
1261
- children: O.map((d) => {
1262
- var Q, U, I, V;
1263
- const y = (d.type === "matrix" || d.type === "query" || d.type === "record-grid") && ((Q = d.config) == null ? void 0 : Q.display) === "drawer", L = d === F;
1264
- return /* @__PURE__ */ p(
1298
+ children: z.map((a) => {
1299
+ var D, J, A, X;
1300
+ const g = (a.type === "matrix" || a.type === "query" || a.type === "record-grid") && ((D = a.config) == null ? void 0 : D.display) === "drawer", P = a === O;
1301
+ return /* @__PURE__ */ h(
1265
1302
  "div",
1266
1303
  {
1267
- className: y ? "flex min-h-0 flex-col" : "flex min-h-0 flex-col overflow-hidden rounded-xl border border-slate-200 bg-white shadow-sm dark:border-border dark:bg-card",
1304
+ className: g ? "flex min-h-0 flex-col" : "flex min-h-0 flex-col overflow-hidden rounded-xl border border-slate-200 bg-white shadow-sm dark:border-border dark:bg-card",
1268
1305
  style: {
1269
- gridColumn: `${Math.min(d.x, k - 1) + 1} / span ${Math.min(d.w, k)}`,
1270
- gridRow: L ? `${M(d.y) + 1} / -1` : `${M(d.y) + 1} / span ${Math.max(d.h, 1)}`
1306
+ gridColumn: `${Math.min(a.x, L - 1) + 1} / span ${Math.min(a.w, L)}`,
1307
+ gridRow: P ? `${E(a.y) + 1} / -1` : `${E(a.y) + 1} / span ${Math.max(a.h, 1)}`
1271
1308
  },
1272
1309
  children: [
1273
- !y && d.type !== "kpi" && d.type !== "markdown" && ((U = d.config) == null ? void 0 : U.hide_label) !== !0 && /* @__PURE__ */ t("div", { className: "shrink-0 border-b border-slate-100 px-3 py-1.5 text-[11px] font-medium uppercase tracking-wide text-slate-400 dark:border-border", children: String(((I = d.config) == null ? void 0 : I.label) ?? "") || (typeof ((V = d.config) == null ? void 0 : V.collection) == "string" ? K(String(d.config.collection)) : K(d.type)) }),
1274
- /* @__PURE__ */ t("div", { className: "min-h-0 flex-1", children: /* @__PURE__ */ t(Ee, { slug: s.slug, widget: d }) })
1310
+ !g && a.type !== "kpi" && a.type !== "markdown" && ((J = a.config) == null ? void 0 : J.hide_label) !== !0 && /* @__PURE__ */ t("div", { className: "shrink-0 border-b border-slate-100 px-3 py-1.5 text-[11px] font-medium uppercase tracking-wide text-slate-400 dark:border-border", children: String(((A = a.config) == null ? void 0 : A.label) ?? "") || (typeof ((X = a.config) == null ? void 0 : X.collection) == "string" ? Q(String(a.config.collection)) : Q(a.type)) }),
1311
+ /* @__PURE__ */ t("div", { className: "min-h-0 flex-1", children: /* @__PURE__ */ t(Be, { slug: j.slug, widget: a }) })
1275
1312
  ]
1276
1313
  },
1277
- d.id
1314
+ a.id
1278
1315
  );
1279
1316
  })
1280
1317
  }
1281
1318
  )
1282
1319
  ] }) })
1283
- ] });
1284
- return u ? T : /* @__PURE__ */ p(nt.Provider, { value: { open: (d) => c.push([d]) }, children: [
1285
- o != null && o.length ? /* @__PURE__ */ t(
1286
- Nt,
1320
+ ] }), G = /* @__PURE__ */ t(Ke.Provider, { value: o, children: V });
1321
+ return S ? G : /* @__PURE__ */ h(it.Provider, { value: { open: (a) => q.push([a]) }, children: [
1322
+ v != null && v.length ? /* @__PURE__ */ t(
1323
+ Tt,
1287
1324
  {
1288
- collection: o[0].collection,
1289
- itemId: o[0].itemId,
1290
- layoutId: o[0].layoutId,
1291
- width: o[0].width,
1292
- title: o[0].title,
1293
- stack: o,
1294
- onPush: (d) => c.push([...o, d]),
1295
- onPop: () => c.back(),
1296
- onClose: () => c.back(o.length)
1325
+ collection: v[0].collection,
1326
+ itemId: v[0].itemId,
1327
+ layoutId: v[0].layoutId,
1328
+ width: v[0].width,
1329
+ title: v[0].title,
1330
+ stack: v,
1331
+ onPush: (a) => q.push([...v, a]),
1332
+ onPop: () => q.back(),
1333
+ onClose: () => q.back(v.length)
1297
1334
  }
1298
1335
  ) : null,
1299
- T
1336
+ G
1300
1337
  ] });
1301
1338
  }
1302
1339
  export {
1303
- fr as PageRenderer,
1304
- ze as QueryWidgetView,
1305
- zt as RecordGridWidgetBody,
1306
- Ft as missingRowParamMessage,
1307
- Mt as resolveSheetConfig,
1308
- Ie as resolveSheetValue,
1309
- Ae as selectionSignature,
1310
- Ot as totalSheetTitle
1340
+ _r as PageRenderer,
1341
+ Ve as QueryWidgetView,
1342
+ Yt as RecordGridWidgetBody,
1343
+ zt as missingRowParamMessage,
1344
+ Dt as resolveSheetConfig,
1345
+ Ue as resolveSheetValue,
1346
+ Ee as selectionSignature,
1347
+ It as totalSheetTitle
1311
1348
  };