@nivaro/react 0.3.113 → 0.3.115

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (285) hide show
  1. package/dist/components/ScreenShareHost.js +24 -0
  2. package/dist/full.css +50 -2
  3. package/dist/hooks/useSessionRecorder.js +61 -60
  4. package/dist/index.d.ts +1727 -19
  5. package/dist/index.js +1091 -950
  6. package/dist/shared/components/ActivityEntry.js +209 -97
  7. package/dist/shared/components/AgentPresenceChip.js +51 -0
  8. package/dist/shared/components/AnnouncementBanner.js +56 -41
  9. package/dist/shared/components/AutolinkedText.js +98 -85
  10. package/dist/shared/components/BroadcastView.js +149 -141
  11. package/dist/shared/components/CacheStamp.js +78 -30
  12. package/dist/shared/components/CollectionBrowserView.js +4088 -3592
  13. package/dist/shared/components/ConfigChangeStrip.js +63 -0
  14. package/dist/shared/components/ConfigReachNote.js +107 -0
  15. package/dist/shared/components/ConformanceView.js +389 -319
  16. package/dist/shared/components/DataTable.js +544 -504
  17. package/dist/shared/components/DelegateCoverLine.js +164 -0
  18. package/dist/shared/components/EnvironmentNotice.js +56 -65
  19. package/dist/shared/components/FilePreviewLightbox.js +89 -43
  20. package/dist/shared/components/FindingFixedMark.js +23 -0
  21. package/dist/shared/components/GridPresenceLine.js +100 -0
  22. package/dist/shared/components/IdleReloadWatcher.js +82 -43
  23. package/dist/shared/components/InStep.js +46 -0
  24. package/dist/shared/components/ItemEditForm.js +5504 -4889
  25. package/dist/shared/components/LiveAnnouncer.js +62 -0
  26. package/dist/shared/components/LiveCount.js +54 -0
  27. package/dist/shared/components/LiveFigure.js +28 -0
  28. package/dist/shared/components/LiveListControls.js +114 -0
  29. package/dist/shared/components/LiveNewMatchesPill.js +25 -0
  30. package/dist/shared/components/LiveOffNote.js +44 -0
  31. package/dist/shared/components/LivePreferenceHost.js +42 -0
  32. package/dist/shared/components/LiveRowMark.js +25 -20
  33. package/dist/shared/components/LiveTraceView.js +257 -0
  34. package/dist/shared/components/MapView.js +30 -29
  35. package/dist/shared/components/MatrixEditor.js +497 -462
  36. package/dist/shared/components/MyWorkView.js +346 -272
  37. package/dist/shared/components/NotificationBell.js +215 -201
  38. package/dist/shared/components/PageRenderer.js +636 -599
  39. package/dist/shared/components/PresenceDot.js +21 -0
  40. package/dist/shared/components/ProfileView.js +656 -536
  41. package/dist/shared/components/RealtimeStatusBanner.js +25 -25
  42. package/dist/shared/components/RecentRecordsRail.js +51 -48
  43. package/dist/shared/components/RecordCompare.js +241 -150
  44. package/dist/shared/components/RecordDrilldownSheet.js +66 -64
  45. package/dist/shared/components/RecordGridEditor.js +350 -311
  46. package/dist/shared/components/RecordHoverCard.js +147 -0
  47. package/dist/shared/components/RecordPeekHost.js +111 -0
  48. package/dist/shared/components/RecordReadView.js +414 -412
  49. package/dist/shared/components/RelativeTime.js +16 -0
  50. package/dist/shared/components/ReportView.js +1396 -1304
  51. package/dist/shared/components/ScreenRefreshButton.js +77 -0
  52. package/dist/shared/components/TabCountHost.js +10 -0
  53. package/dist/shared/components/TickerNumber.js +19 -18
  54. package/dist/shared/components/TipLayer.js +70 -58
  55. package/dist/shared/components/WidgetImageMenu.js +59 -0
  56. package/dist/shared/components/WidgetSlot.js +571 -524
  57. package/dist/shared/components/activity/RecordActivityStream.js +317 -0
  58. package/dist/shared/components/bulk/BulkSelectionNotices.js +220 -0
  59. package/dist/shared/components/cbv/approval-changed.js +20 -0
  60. package/dist/shared/components/cbv/changed-by-others.js +251 -0
  61. package/dist/shared/components/cbv/column-totals.js +75 -67
  62. package/dist/shared/components/change-proposals/ChangeProposalsPanel.js +320 -0
  63. package/dist/shared/components/change-proposals/ProposalValue.js +28 -0
  64. package/dist/shared/components/change-proposals/ProposeChangeButton.js +44 -0
  65. package/dist/shared/components/change-proposals/ProposeChangeDialog.js +359 -0
  66. package/dist/shared/components/change-proposals/types.js +4 -0
  67. package/dist/shared/components/chat/ChatPanel.js +1571 -1528
  68. package/dist/shared/components/chat/Composer.js +276 -298
  69. package/dist/shared/components/chat/room-due.js +13 -0
  70. package/dist/shared/components/collections-directory/CollectionRow.js +76 -75
  71. package/dist/shared/components/collections-directory/CollectionsDirectory.js +415 -395
  72. package/dist/shared/components/collections-directory/directory-data.js +75 -63
  73. package/dist/shared/components/imports/ImportConsole.js +159 -155
  74. package/dist/shared/components/imports/ImportDuplicatesNotice.js +46 -31
  75. package/dist/shared/components/integrations/SendStatus.js +202 -0
  76. package/dist/shared/components/integrations/console/IntegrationsConsole.js +45 -36
  77. package/dist/shared/components/integrations/console/ReadyToSendView.js +453 -0
  78. package/dist/shared/components/integrations/console/api.js +161 -117
  79. package/dist/shared/components/integrations/console/tone.js +15 -12
  80. package/dist/shared/components/item-edit/CatalogPickerField.js +1353 -1245
  81. package/dist/shared/components/item-edit/ChangedAfterApprovalBadge.js +162 -0
  82. package/dist/shared/components/item-edit/CloneDialog.js +208 -206
  83. package/dist/shared/components/item-edit/DerivedCauseNote.js +57 -0
  84. package/dist/shared/components/item-edit/DraftRecoveryBanner.js +81 -70
  85. package/dist/shared/components/item-edit/DuplicateNotice.js +169 -101
  86. package/dist/shared/components/item-edit/FieldAffordances.js +294 -385
  87. package/dist/shared/components/item-edit/FieldComments.js +159 -116
  88. package/dist/shared/components/item-edit/FieldPointer.js +132 -0
  89. package/dist/shared/components/item-edit/FieldRenderer.js +277 -273
  90. package/dist/shared/components/item-edit/FieldRow.js +519 -439
  91. package/dist/shared/components/item-edit/FieldSourceBadge.js +88 -0
  92. package/dist/shared/components/item-edit/FilePickerField.js +454 -369
  93. package/dist/shared/components/item-edit/GroupSection.js +618 -567
  94. package/dist/shared/components/item-edit/HeldEditsChip.js +113 -0
  95. package/dist/shared/components/item-edit/InlineTableField.js +2891 -2723
  96. package/dist/shared/components/item-edit/ListNeighborNav.js +79 -0
  97. package/dist/shared/components/item-edit/LiveTraceSheet.js +26 -0
  98. package/dist/shared/components/item-edit/M2MCombobox.js +284 -273
  99. package/dist/shared/components/item-edit/OutboxReviewTray.js +313 -0
  100. package/dist/shared/components/item-edit/PickerBadges.js +52 -0
  101. package/dist/shared/components/item-edit/PlanGrid.js +434 -439
  102. package/dist/shared/components/item-edit/RecalcValue.js +55 -0
  103. package/dist/shared/components/item-edit/RecordChatActions.js +76 -64
  104. package/dist/shared/components/item-edit/RecordChatMentionsChip.js +103 -0
  105. package/dist/shared/components/item-edit/RecordGrantTools.js +87 -86
  106. package/dist/shared/components/item-edit/RecordHelpChip.js +70 -0
  107. package/dist/shared/components/item-edit/RecordLiveSync.js +230 -217
  108. package/dist/shared/components/item-edit/RecordOutbox.js +53 -52
  109. package/dist/shared/components/item-edit/RecordRecapStrip.js +109 -36
  110. package/dist/shared/components/item-edit/RelationCombobox.js +229 -217
  111. package/dist/shared/components/item-edit/RelationGroupedCombobox.js +105 -100
  112. package/dist/shared/components/item-edit/RemoteChangeUi.js +454 -0
  113. package/dist/shared/components/item-edit/RemoteUploads.js +55 -0
  114. package/dist/shared/components/item-edit/RemovedLineNote.js +92 -0
  115. package/dist/shared/components/item-edit/RichTextEditorImpl.js +298 -223
  116. package/dist/shared/components/item-edit/ScheduledChangeChip.js +244 -0
  117. package/dist/shared/components/item-edit/SectionPresence.js +78 -0
  118. package/dist/shared/components/item-edit/SplitLinesButton.js +166 -0
  119. package/dist/shared/components/item-edit/catalog-line-watch.js +94 -0
  120. package/dist/shared/components/item-edit/coedit/collab.js +84 -0
  121. package/dist/shared/components/item-edit/coedit/context.js +24 -0
  122. package/dist/shared/components/item-edit/coedit/cursors.js +103 -0
  123. package/dist/shared/components/item-edit/coedit/safe-link.js +15 -0
  124. package/dist/shared/components/item-edit/coedit/session.js +382 -0
  125. package/dist/shared/components/item-edit/coedit/useCoedit.js +49 -0
  126. package/dist/shared/components/item-edit/file-live.js +77 -0
  127. package/dist/shared/components/item-edit/file-processing.js +87 -0
  128. package/dist/shared/components/item-edit/layout-switch.js +148 -0
  129. package/dist/shared/components/item-edit/live-related.js +23 -0
  130. package/dist/shared/components/item-edit/live-title.js +66 -0
  131. package/dist/shared/components/item-edit/partner-needs.js +142 -0
  132. package/dist/shared/components/item-edit/removed-line.js +58 -0
  133. package/dist/shared/components/item-edit/render-stability.js +70 -59
  134. package/dist/shared/components/layout-editor/ChangeNote.js +36 -34
  135. package/dist/shared/components/layout-editor/CollabParts.js +72 -70
  136. package/dist/shared/components/layout-editor/LayoutEditor.js +306 -303
  137. package/dist/shared/components/list/InlineEdit.js +504 -208
  138. package/dist/shared/components/list/ListViewers.js +81 -0
  139. package/dist/shared/components/merge/MergeRecordsDialog.js +1227 -0
  140. package/dist/shared/components/merge/MergeWithFlow.js +290 -0
  141. package/dist/shared/components/merge/merge-values.js +110 -0
  142. package/dist/shared/components/monitoring/InactiveUserLinksView.js +285 -258
  143. package/dist/shared/components/notifications/NotificationCenterView.js +388 -321
  144. package/dist/shared/components/notifications/NotificationDetailBits.js +205 -130
  145. package/dist/shared/components/notifications/NotificationRulesEditor.js +72 -52
  146. package/dist/shared/components/notifications/bundles.js +21 -19
  147. package/dist/shared/components/notifications/resolved-line.js +25 -0
  148. package/dist/shared/components/ops/OpsTasksView.js +45 -44
  149. package/dist/shared/components/panels/AccessGrantedNote.js +85 -0
  150. package/dist/shared/components/panels/AlertBanners.js +132 -0
  151. package/dist/shared/components/panels/AsyncUserPicker.js +54 -45
  152. package/dist/shared/components/panels/BranchLanes.js +82 -54
  153. package/dist/shared/components/panels/CommentAwareness.js +332 -0
  154. package/dist/shared/components/panels/CommentImages.js +219 -0
  155. package/dist/shared/components/panels/CommentPanel.js +649 -530
  156. package/dist/shared/components/panels/ExternalRequestsChip.js +98 -80
  157. package/dist/shared/components/panels/NewSinceChip.js +16 -0
  158. package/dist/shared/components/panels/OwnerOpenedLine.js +85 -0
  159. package/dist/shared/components/panels/PipelinePanel.js +1644 -1494
  160. package/dist/shared/components/panels/ResubmissionDiff.js +293 -0
  161. package/dist/shared/components/panels/SlaBreachBanner.js +30 -29
  162. package/dist/shared/components/panels/SlaClock.js +130 -99
  163. package/dist/shared/components/panels/TaskPanel.js +308 -287
  164. package/dist/shared/components/panels/unseen-move-check.js +101 -0
  165. package/dist/shared/components/pipeline/OwnerMatrix.js +80 -71
  166. package/dist/shared/components/pipeline/OwnerMatrixSheet.js +495 -0
  167. package/dist/shared/components/pipeline/PipelineEditorView.js +1855 -1771
  168. package/dist/shared/components/profile/AgentNameField.js +141 -0
  169. package/dist/shared/components/profile/AgentsPanel.js +55 -46
  170. package/dist/shared/components/profile/PersonAccess.js +398 -330
  171. package/dist/shared/components/profile/PersonAdminTools.js +127 -113
  172. package/dist/shared/components/profile/PersonProfile.js +81 -73
  173. package/dist/shared/components/profile/SignInTroubleshooter.js +361 -0
  174. package/dist/shared/components/queue/QueueBulkBar.js +101 -84
  175. package/dist/shared/components/queue/QueueItemSheet.js +66 -66
  176. package/dist/shared/components/queue/QueueTeamStrip.js +279 -0
  177. package/dist/shared/components/queue/QueueWorklist.js +2076 -1686
  178. package/dist/shared/components/queue/queue-totals.js +92 -0
  179. package/dist/shared/components/queue/worklist-helpers.js +18 -14
  180. package/dist/shared/components/send-view/SendViewButton.js +136 -0
  181. package/dist/shared/components/send-view/SentViewCards.js +147 -0
  182. package/dist/shared/components/support/ReportProblem.js +1 -0
  183. package/dist/shared/components/support/ScreenShare.js +554 -0
  184. package/dist/shared/components/support/SupportView.js +160 -129
  185. package/dist/shared/components/support/TicketDetailSheet.js +101 -89
  186. package/dist/shared/components/watch-list/WatchDock.js +1044 -0
  187. package/dist/shared/components/watch-list/WatchExtras.js +723 -0
  188. package/dist/shared/components/watch-list/WatchListButton.js +46 -0
  189. package/dist/shared/components/watch-list/WatchPinButton.js +67 -0
  190. package/dist/shared/components/watch-list/WatchRows.js +348 -0
  191. package/dist/shared/lib/activity-sentence.js +87 -75
  192. package/dist/shared/lib/agent-presence.js +46 -0
  193. package/dist/shared/lib/approval-progress.js +49 -0
  194. package/dist/shared/lib/attention-prefs.js +27 -0
  195. package/dist/shared/lib/cell-locks.js +56 -0
  196. package/dist/shared/lib/co-edit.js +166 -0
  197. package/dist/shared/lib/coedit-registry.js +44 -0
  198. package/dist/shared/lib/comment-awareness.js +124 -0
  199. package/dist/shared/lib/comment-images.js +45 -0
  200. package/dist/shared/lib/config-watch.js +94 -0
  201. package/dist/shared/lib/copy-rules.js +65 -0
  202. package/dist/shared/lib/count-step.js +30 -0
  203. package/dist/shared/lib/deadline-ticker.js +68 -0
  204. package/dist/shared/lib/derived-causes.js +115 -0
  205. package/dist/shared/lib/draft-store.js +114 -85
  206. package/dist/shared/lib/error-hints.js +1 -0
  207. package/dist/shared/lib/field-merge.js +126 -0
  208. package/dist/shared/lib/filter-sentence.js +10 -10
  209. package/dist/shared/lib/focus-mode.js +16 -12
  210. package/dist/shared/lib/grid-cursors.js +77 -0
  211. package/dist/shared/lib/grid-presence.js +182 -0
  212. package/dist/shared/lib/idle-reload.js +100 -73
  213. package/dist/shared/lib/in-step.js +45 -0
  214. package/dist/shared/lib/integration-chip.js +19 -18
  215. package/dist/shared/lib/line-locks.js +141 -0
  216. package/dist/shared/lib/line-split.js +41 -0
  217. package/dist/shared/lib/linked-changes.js +150 -0
  218. package/dist/shared/lib/list-link.js +56 -50
  219. package/dist/shared/lib/list-return.js +231 -0
  220. package/dist/shared/lib/list-viewers.js +52 -0
  221. package/dist/shared/lib/live-announcer.js +86 -0
  222. package/dist/shared/lib/live-counts.js +85 -0
  223. package/dist/shared/lib/live-data-changed.js +108 -0
  224. package/dist/shared/lib/live-deltas.js +81 -0
  225. package/dist/shared/lib/live-findings.js +113 -0
  226. package/dist/shared/lib/live-groups.js +122 -0
  227. package/dist/shared/lib/live-link-labels.js +162 -0
  228. package/dist/shared/lib/live-list-flow.js +334 -0
  229. package/dist/shared/lib/live-list.js +143 -129
  230. package/dist/shared/lib/live-moves.js +51 -0
  231. package/dist/shared/lib/live-ops.js +26 -26
  232. package/dist/shared/lib/live-pickers.js +7 -0
  233. package/dist/shared/lib/live-preference.js +184 -0
  234. package/dist/shared/lib/live-queries.js +226 -181
  235. package/dist/shared/lib/live-screen.js +333 -0
  236. package/dist/shared/lib/live-search.js +108 -0
  237. package/dist/shared/lib/live-seen.js +35 -0
  238. package/dist/shared/lib/live-views.js +100 -0
  239. package/dist/shared/lib/live.js +159 -133
  240. package/dist/shared/lib/missed-updates.js +198 -0
  241. package/dist/shared/lib/newer-file.js +56 -0
  242. package/dist/shared/lib/notification-sound.js +42 -20
  243. package/dist/shared/lib/own-writes.js +59 -41
  244. package/dist/shared/lib/picker-badges.js +94 -0
  245. package/dist/shared/lib/presence-signals.js +131 -84
  246. package/dist/shared/lib/realtime.js +49 -24
  247. package/dist/shared/lib/record-gaps.js +85 -0
  248. package/dist/shared/lib/record-outbox.js +369 -222
  249. package/dist/shared/lib/record-peek.js +75 -0
  250. package/dist/shared/lib/record-tabs.js +92 -72
  251. package/dist/shared/lib/relative-ticker.js +42 -0
  252. package/dist/shared/lib/request-gate.js +119 -119
  253. package/dist/shared/lib/rollup-recalc.js +107 -0
  254. package/dist/shared/lib/room-gaps.js +40 -36
  255. package/dist/shared/lib/rum.js +137 -87
  256. package/dist/shared/lib/save-progress.js +20 -0
  257. package/dist/shared/lib/scheduled-countdown.js +67 -0
  258. package/dist/shared/lib/screen-refresh.js +160 -0
  259. package/dist/shared/lib/screen-share.js +234 -0
  260. package/dist/shared/lib/seen-since.js +74 -0
  261. package/dist/shared/lib/selection-watch.js +205 -0
  262. package/dist/shared/lib/send-status.js +132 -0
  263. package/dist/shared/lib/send-view.js +23 -0
  264. package/dist/shared/lib/socket-liveness.js +155 -0
  265. package/dist/shared/lib/socket-realtime.js +168 -140
  266. package/dist/shared/lib/state-census.js +53 -0
  267. package/dist/shared/lib/summary-mode.js +61 -39
  268. package/dist/shared/lib/tab-attention.js +143 -32
  269. package/dist/shared/lib/table-density.js +64 -0
  270. package/dist/shared/lib/track-travel.js +40 -0
  271. package/dist/shared/lib/unseen-changes.js +68 -0
  272. package/dist/shared/lib/upload-file.js +33 -0
  273. package/dist/shared/lib/upload-presence.js +127 -0
  274. package/dist/shared/lib/urgent-chime.js +65 -0
  275. package/dist/shared/lib/use-online-users.js +32 -11
  276. package/dist/shared/lib/user-sync.js +155 -39
  277. package/dist/shared/lib/waiting-count.js +44 -0
  278. package/dist/shared/lib/watch-desktop.js +83 -0
  279. package/dist/shared/lib/watch-list.js +447 -0
  280. package/dist/shared/lib/widget-image-render.js +64 -0
  281. package/dist/shared/lib/widget-image.js +111 -0
  282. package/dist/shared/lib/worker-socket.js +130 -104
  283. package/dist/shared/lib/write-to-screen.js +133 -0
  284. package/package.json +1 -1
  285. package/styles.css +49 -1
@@ -0,0 +1,65 @@
1
+ import { useRef as s } from "react";
2
+ import { huddleHolds as m } from "../components/chat/huddle/huddle-hold.js";
3
+ import { isCleanRecording as p } from "../components/help-videos/recorder/cleanRecording.js";
4
+ import { isDndActive as g } from "./dnd.js";
5
+ import { isFocusModeOn as v } from "./focus-mode.js";
6
+ import { useLiveEvent as h } from "./live.js";
7
+ import { getLiveMode as y } from "./live-preference.js";
8
+ import { noteUrgentChime as A } from "./notification-sound.js";
9
+ import { shouldPlayHere as w } from "./tab-sound.js";
10
+ function C(e, t) {
11
+ return !t.enabled || (e == null ? void 0 : e.urgent) !== !0 || e.quiet === !0 || t.liveMode === "off" || t.dnd || t.focus || t.huddle || t.recording ? !1 : t.activated;
12
+ }
13
+ function d(e) {
14
+ return (e == null ? void 0 : e.urgent_sound) === !0;
15
+ }
16
+ function T() {
17
+ try {
18
+ const e = navigator.userActivation;
19
+ return (e == null ? void 0 : e.hasBeenActive) ?? !0;
20
+ } catch {
21
+ return !1;
22
+ }
23
+ }
24
+ let u = null;
25
+ function R(e = {}) {
26
+ if (typeof window > "u" || !e.preview && (!w() || !T())) return !1;
27
+ try {
28
+ u || (u = new AudioContext()), u.state === "suspended" && u.resume().catch(() => {
29
+ });
30
+ const t = u, a = t.currentTime, c = (o, n, l, f) => {
31
+ const i = t.createOscillator(), r = t.createGain();
32
+ i.type = "triangle", i.frequency.value = o, r.gain.setValueAtTime(1e-4, n), r.gain.exponentialRampToValueAtTime(f, n + 0.012), r.gain.exponentialRampToValueAtTime(1e-4, n + l), i.connect(r), r.connect(t.destination), i.start(n), i.stop(n + l + 0.05);
33
+ };
34
+ return c(659.25, a, 0.22, 0.07), c(987.77, a + 0.13, 0.36, 0.06), A(), !0;
35
+ } catch {
36
+ return !1;
37
+ }
38
+ }
39
+ function D(e) {
40
+ const t = s(e);
41
+ t.current = e;
42
+ const a = d(e);
43
+ h(
44
+ "notification:new",
45
+ (c) => {
46
+ const o = t.current;
47
+ C(c, {
48
+ enabled: d(o),
49
+ liveMode: y(),
50
+ dnd: g(o ?? null),
51
+ focus: v(),
52
+ huddle: m(o ?? null),
53
+ recording: p(),
54
+ activated: !0
55
+ }) && R();
56
+ },
57
+ { enabled: a, includeOwn: !0 }
58
+ );
59
+ }
60
+ export {
61
+ R as playUrgentChime,
62
+ C as shouldChime,
63
+ d as urgentSoundOn,
64
+ D as useUrgentChime
65
+ };
@@ -1,19 +1,40 @@
1
- import { readOnlinePresence as l } from "@nivaro/sdk";
2
- import { useQuery as s } from "@tanstack/react-query";
1
+ import { readOnlinePresence as a } from "@nivaro/sdk";
2
+ import { useQuery as c } from "@tanstack/react-query";
3
3
  import { useNivaroClient as u } from "../context.js";
4
- import { usePresenceOnlinePoll as a } from "./presence-live.js";
5
- function y(r = !0) {
6
- const t = u(), n = a(3e4, r), { data: o } = s({
4
+ import { usePresenceOnlinePoll as p } from "./presence-live.js";
5
+ function P(t = !0) {
6
+ const r = u(), o = p(3e4, t), { data: s } = c({
7
7
  queryKey: ["presence-online"],
8
- queryFn: () => t.request(l()),
9
- select: (e) => ((e == null ? void 0 : e.data) ?? []).map((i) => String(i.user_id ?? "").toUpperCase()).filter(Boolean),
10
- enabled: r,
11
- refetchInterval: n,
8
+ queryFn: () => r.request(a()),
9
+ select: (e) => ((e == null ? void 0 : e.data) ?? []).map((n) => String(n.user_id ?? "").toUpperCase()).filter(Boolean),
10
+ enabled: t,
11
+ refetchInterval: o,
12
12
  staleTime: 25e3,
13
13
  retry: !1
14
14
  });
15
- return new Set(o ?? []);
15
+ return new Set(s ?? []);
16
16
  }
17
+ function w(t = !0) {
18
+ const r = u(), o = p(3e4, t), { data: s } = c({
19
+ queryKey: ["presence-online"],
20
+ queryFn: () => r.request(a()),
21
+ select: (e) => {
22
+ const n = /* @__PURE__ */ new Map();
23
+ for (const i of (e == null ? void 0 : e.data) ?? []) {
24
+ const l = String(i.user_id ?? "").toUpperCase();
25
+ l && n.set(l, i.is_idle || i.away ? "idle" : "online");
26
+ }
27
+ return n;
28
+ },
29
+ enabled: t,
30
+ refetchInterval: o,
31
+ staleTime: 25e3,
32
+ retry: !1
33
+ });
34
+ return s ?? f;
35
+ }
36
+ const f = /* @__PURE__ */ new Map();
17
37
  export {
18
- y as useOnlineUsers
38
+ P as useOnlineUsers,
39
+ w as usePresenceStates
19
40
  };
@@ -1,66 +1,182 @@
1
- import { useQueryClient as d } from "@tanstack/react-query";
2
- import { useRef as a, useEffect as y } from "react";
3
- import { useLiveEvent as f } from "./live.js";
4
- const m = "nvr-prefs";
5
- let r = null;
6
- function l(n) {
1
+ import { useQueryClient as g } from "@tanstack/react-query";
2
+ import { useRef as f, useEffect as y } from "react";
3
+ import { useLiveEvent as u } from "./live.js";
4
+ import { forgetSettledReads as w } from "./request-gate.js";
5
+ const S = "nvr-prefs";
6
+ let c = null;
7
+ function p(n) {
7
8
  if (typeof BroadcastChannel > "u") return null;
8
- if (!r)
9
+ if (!c)
9
10
  try {
10
- r = new BroadcastChannel(`${m}:${n}`);
11
+ c = new BroadcastChannel(`${S}:${n}`);
11
12
  } catch {
12
- r = null;
13
+ c = null;
13
14
  }
14
- return r;
15
+ return c;
15
16
  }
16
- let s = "";
17
- function E(n) {
18
- if (n !== s) {
19
- s = n;
17
+ let d = "";
18
+ function k(n) {
19
+ if (n !== d) {
20
+ d = n;
20
21
  try {
21
- r == null || r.close();
22
+ c == null || c.close();
22
23
  } catch {
23
24
  }
24
- r = null;
25
+ c = null;
25
26
  }
26
27
  }
27
- function S(n = []) {
28
- var o;
28
+ function q() {
29
+ return d.endsWith(":as");
30
+ }
31
+ function L(n = []) {
32
+ var t;
29
33
  try {
30
- (o = l(s)) == null || o.postMessage({ keys: n });
34
+ (t = p(d)) == null || t.postMessage({ keys: n });
31
35
  } catch {
32
36
  }
33
37
  }
34
- const v = [["notification-count"], ["notifications"], ["my-work"]], h = [["nvr-chat-rooms"]];
35
- function T(n = {}) {
36
- const o = d(), c = a(n.onPrefsChanged);
37
- c.current = n.onPrefsChanged, f(
38
+ const E = /* @__PURE__ */ new Set([
39
+ "users",
40
+ "people-search",
41
+ "people-cards",
42
+ "task-people",
43
+ "task-people-search",
44
+ "sla-users",
45
+ "sla-user-search",
46
+ "role-users",
47
+ "record-chat-mentions",
48
+ "nvr-chat-directory",
49
+ "nvr-chat-members",
50
+ "nvr-chat-members-page",
51
+ "users-list-for-issues",
52
+ "users-list-for-approvals",
53
+ "presence-visible-people",
54
+ "team-members"
55
+ ]), b = /* @__PURE__ */ new Set([
56
+ "user-card",
57
+ "user-avatar",
58
+ "user-name",
59
+ "user-chip",
60
+ "user",
61
+ "activity-chip-user",
62
+ "nvr-directory-entry",
63
+ "nvr-profile-card"
64
+ ]);
65
+ function C(n, t) {
66
+ const i = n[0];
67
+ if (typeof i != "string") return !1;
68
+ if (E.has(i)) return !0;
69
+ if (!b.has(i)) return !1;
70
+ if (!t) return !0;
71
+ const o = n[1];
72
+ return (typeof o == "string" || typeof o == "number") && t.has(String(o).toUpperCase());
73
+ }
74
+ function m(n, t = 1200) {
75
+ setTimeout(n, Math.floor(Math.random() * t));
76
+ }
77
+ const M = [["notification-count"], ["notifications"], ["my-work"]], T = [["nvr-chat-rooms"], ["nvr-chat-record-room"]], K = {
78
+ "saved-views": [["cbv-views"], ["cbv-view-count"]],
79
+ "saved-searches": [["global-search-saved"]],
80
+ overview: [
81
+ ["overview", "prefs"],
82
+ ["overview", "pinned-widgets"]
83
+ ]
84
+ };
85
+ function P(n = {}) {
86
+ const t = g(), i = f(n.onPrefsChanged);
87
+ i.current = n.onPrefsChanged, u(
38
88
  "read:changed",
39
89
  (e) => {
40
- const t = (e == null ? void 0 : e.kind) === "chat" ? h : v;
41
- for (const i of t) o.invalidateQueries({ queryKey: i });
90
+ const r = (e == null ? void 0 : e.kind) === "chat" ? T : M;
91
+ for (const s of r) t.invalidateQueries({ queryKey: s });
42
92
  },
43
- { includeOwn: !0, debounceMs: 250 }
93
+ // Counts: a burst of reads (mark-all) is one re-read, not one per event.
94
+ { includeOwn: !0, debounceMs: 2e3 }
44
95
  );
45
- const u = a(() => {
96
+ const o = f(() => {
46
97
  });
47
- u.current = () => {
98
+ o.current = () => {
48
99
  var e;
49
- o.invalidateQueries({ queryKey: ["nvr-profile-prefs"] }), o.invalidateQueries({ queryKey: ["presence-online"] }), (e = c.current) == null || e.call(c);
50
- }, f("prefs:changed", () => u.current(), { includeOwn: !0, debounceMs: 250 }), y(() => {
51
- const e = l(s);
100
+ t.invalidateQueries({ queryKey: ["nvr-profile-prefs"] }), t.invalidateQueries({ queryKey: ["presence-online"] }), t.invalidateQueries({ queryKey: ["nvr-nav-favorites"] }), (e = i.current) == null || e.call(i);
101
+ }, u(
102
+ "prefs:changed",
103
+ (e) => {
104
+ const r = Array.isArray(e == null ? void 0 : e.keys) ? e.keys : null;
105
+ r && r.length > 0 && r.every((s) => s === "watch_list") || o.current();
106
+ },
107
+ { includeOwn: !0, debounceMs: 250 }
108
+ ), u(
109
+ "mine:changed",
110
+ (e) => {
111
+ for (const r of K[String(e == null ? void 0 : e.kind)] ?? [])
112
+ t.invalidateQueries({ queryKey: r, refetchType: "active" });
113
+ },
114
+ { includeOwn: !0, debounceMs: 300 }
115
+ ), u(
116
+ "pins:changed",
117
+ () => m(() => void t.invalidateQueries({ queryKey: ["collection-pins"] })),
118
+ { includeOwn: !0, debounceMs: 500 }
119
+ );
120
+ const v = f(n.onAccessChanged);
121
+ v.current = n.onAccessChanged, u(
122
+ "access:changed",
123
+ (e) => {
124
+ e != null && e.perms && m(() => {
125
+ var r;
126
+ w(), (r = v.current ?? i.current) == null || r(), t.invalidateQueries({ refetchType: "active" });
127
+ });
128
+ },
129
+ { includeOwn: !0, debounceMs: 400 }
130
+ );
131
+ const a = f(null);
132
+ u(
133
+ "people:changed",
134
+ (e) => {
135
+ const r = Array.isArray(e == null ? void 0 : e.user_ids) ? e.user_ids.map((l) => String(l).toUpperCase()) : null, s = a.current;
136
+ if (s) {
137
+ if (!r) s.ids = null;
138
+ else if (s.ids) for (const l of r) s.ids.add(l);
139
+ return;
140
+ }
141
+ const h = {
142
+ ids: r ? new Set(r) : null,
143
+ timer: setTimeout(
144
+ () => {
145
+ a.current = null, t.invalidateQueries({
146
+ refetchType: "active",
147
+ predicate: (l) => C(l.queryKey, h.ids)
148
+ });
149
+ },
150
+ 300 + Math.floor(Math.random() * 800)
151
+ )
152
+ };
153
+ a.current = h;
154
+ },
155
+ { includeOwn: !0 }
156
+ ), y(
157
+ () => () => {
158
+ a.current && clearTimeout(a.current.timer);
159
+ },
160
+ []
161
+ ), y(() => {
162
+ const e = p(d);
52
163
  if (!e) return;
53
- let t = null;
54
- const i = () => {
55
- t && clearTimeout(t), t = setTimeout(() => u.current(), 100);
164
+ let r = null;
165
+ const s = () => {
166
+ r && clearTimeout(r), r = setTimeout(() => o.current(), 100);
56
167
  };
57
- return e.addEventListener("message", i), () => {
58
- e.removeEventListener("message", i), t && clearTimeout(t);
168
+ return e.addEventListener("message", s), () => {
169
+ e.removeEventListener("message", s), r && clearTimeout(r);
59
170
  };
60
171
  }, []);
61
172
  }
62
173
  export {
63
- S as announceLocalPrefs,
64
- E as configureUserSync,
65
- T as useUserSync
174
+ K as MINE_KEYS,
175
+ E as PEOPLE_LIST_KEYS,
176
+ b as PERSON_KEYS,
177
+ L as announceLocalPrefs,
178
+ k as configureUserSync,
179
+ C as peopleQueryMatches,
180
+ P as useUserSync,
181
+ q as userSyncScoped
66
182
  };
@@ -0,0 +1,44 @@
1
+ import { useQueryClient as a, useQuery as l } from "@tanstack/react-query";
2
+ import { useRef as c, useEffect as p } from "react";
3
+ import { useOptionalNivaroClient as y } from "../context.js";
4
+ import { get as v } from "./commands.js";
5
+ import { useLiveEvent as w } from "./live.js";
6
+ import { useLiveOps as I } from "./live-ops.js";
7
+ import { useLiveRefetchInterval as k } from "./live-queries.js";
8
+ function q(e) {
9
+ if (!e) return 0;
10
+ let o = 0;
11
+ for (const r of [e.owned, e.approvals, e.questions])
12
+ typeof r == "number" && Number.isFinite(r) && r > 0 && (o += Math.floor(r));
13
+ return o;
14
+ }
15
+ const h = 3e4;
16
+ function Q(e = !0) {
17
+ const o = y(), r = a(), f = k(18e4, { safetyMs: 18e4, enabled: e }), { data: m } = l({
18
+ queryKey: ["my-work"],
19
+ queryFn: () => o.request(v("/my-work")).then((t) => t.data),
20
+ enabled: e && !!o,
21
+ staleTime: 6e4,
22
+ refetchInterval: f,
23
+ refetchIntervalInBackground: !0,
24
+ retry: !1,
25
+ select: (t) => q(t == null ? void 0 : t.counts)
26
+ }), i = c(0), n = c(null), u = () => {
27
+ if (n.current) return;
28
+ const t = () => {
29
+ n.current = null, i.current = Date.now(), r.invalidateQueries({ queryKey: ["my-work"] });
30
+ }, s = i.current + h - Date.now();
31
+ s <= 0 ? t() : n.current = setTimeout(t, s);
32
+ };
33
+ return I("my-work", u, { debounceMs: 1500, enabled: e }), w("notification:new", u, { debounceMs: 1500, enabled: e }), p(
34
+ () => () => {
35
+ n.current && clearTimeout(n.current);
36
+ },
37
+ []
38
+ ), e ? m ?? 0 : 0;
39
+ }
40
+ export {
41
+ h as WAITING_LIVE_GAP_MS,
42
+ Q as useWaitingCount,
43
+ q as waitingCount
44
+ };
@@ -0,0 +1,83 @@
1
+ const d = "nivaro-watch-list", w = 12e4, f = "nvr:watch-desktop:claim";
2
+ function s() {
3
+ return typeof window > "u" || typeof window.Notification > "u" ? "unsupported" : window.Notification.permission;
4
+ }
5
+ async function h() {
6
+ if (s() === "unsupported") return "unsupported";
7
+ try {
8
+ return await window.Notification.requestPermission();
9
+ } catch {
10
+ return s();
11
+ }
12
+ }
13
+ function l() {
14
+ return typeof document > "u" ? !1 : document.visibilityState === "hidden" || !document.hasFocus();
15
+ }
16
+ function p(t, n, e, o) {
17
+ const i = [];
18
+ for (const r of new Set(t)) {
19
+ const c = n[r];
20
+ if (!c) continue;
21
+ const a = new Date(c).getTime();
22
+ if (!Number.isFinite(a) || o - a > 12e4) continue;
23
+ const u = e.get(r);
24
+ u && u >= c || i.push(r);
25
+ }
26
+ return i;
27
+ }
28
+ function g(t, n) {
29
+ if (t.length === 1) {
30
+ const o = n[t[0]];
31
+ return {
32
+ title: "Watch list",
33
+ body: o ? `${o} changed` : "A record you watch changed"
34
+ };
35
+ }
36
+ const e = t.map((o) => n[o]).filter(Boolean);
37
+ return {
38
+ title: "Watch list",
39
+ body: e.length > 0 ? `${t.length} records you watch changed: ${e.slice(0, 2).join(", ")}${t.length > 2 ? "…" : ""}` : `${t.length} records you watch changed`
40
+ };
41
+ }
42
+ function m(t, n = Date.now()) {
43
+ const e = [...t].sort().join("|");
44
+ try {
45
+ const o = window.localStorage.getItem(f);
46
+ if (o) {
47
+ const i = JSON.parse(o);
48
+ if (i.sig === e && typeof i.at == "number" && n - i.at < 8e3) return !1;
49
+ }
50
+ window.localStorage.setItem(f, JSON.stringify({ sig: e, at: n }));
51
+ } catch {
52
+ }
53
+ return !0;
54
+ }
55
+ function S(t, n) {
56
+ if (s() === "granted")
57
+ try {
58
+ const e = new window.Notification(t.title, {
59
+ body: t.body,
60
+ tag: d,
61
+ silent: !1
62
+ });
63
+ e.onclick = () => {
64
+ try {
65
+ window.focus();
66
+ } catch {
67
+ }
68
+ n == null || n(), e.close();
69
+ };
70
+ } catch {
71
+ }
72
+ }
73
+ export {
74
+ w as DESKTOP_FRESH_MS,
75
+ d as DESKTOP_TAG,
76
+ m as claimBurst,
77
+ s as desktopPermission,
78
+ g as desktopText,
79
+ p as keysToNotify,
80
+ l as pageOutOfSight,
81
+ h as requestDesktopPermission,
82
+ S as showDesktop
83
+ };