@nivaro/react 0.3.41 → 0.3.42

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 (96) hide show
  1. package/dist/components/LayoutForm.js +100 -98
  2. package/dist/full.css +1 -1
  3. package/dist/hooks/useSessionRecorder.js +1 -1
  4. package/dist/index.d.ts +644 -15
  5. package/dist/index.js +814 -775
  6. package/dist/shared/components/ActivityEntry.js +154 -0
  7. package/dist/shared/components/AudienceConfirmPanel.js +98 -0
  8. package/dist/shared/components/BackgroundRunOffer.js +43 -31
  9. package/dist/shared/components/BroadcastView.js +225 -204
  10. package/dist/shared/components/CollectionBrowserView.js +3924 -3584
  11. package/dist/shared/components/ConfigHistory.js +153 -0
  12. package/dist/shared/components/ConfigReadBack.js +65 -0
  13. package/dist/shared/components/DataTable.js +379 -346
  14. package/dist/shared/components/ForceReloadBanner.js +47 -40
  15. package/dist/shared/components/IdleReloadWatcher.js +69 -0
  16. package/dist/shared/components/ItemEditForm.js +4041 -3853
  17. package/dist/shared/components/MyWorkView.js +278 -213
  18. package/dist/shared/components/NotificationBell.js +130 -121
  19. package/dist/shared/components/ProfileView.js +776 -1003
  20. package/dist/shared/components/RecentRecordsRail.js +34 -16
  21. package/dist/shared/components/RecordReadView.js +500 -477
  22. package/dist/shared/components/Skeletons.js +199 -0
  23. package/dist/shared/components/SlowNotice.js +63 -0
  24. package/dist/shared/components/Term.js +23 -0
  25. package/dist/shared/components/WidgetSlot.js +350 -353
  26. package/dist/shared/components/access/PermissionSummary.js +106 -0
  27. package/dist/shared/components/bulk/BulkActionButtons.js +76 -73
  28. package/dist/shared/components/chat/ChatPanel.js +902 -886
  29. package/dist/shared/components/chat/MemberPaging.js +70 -0
  30. package/dist/shared/components/chat/RoomParts.js +147 -117
  31. package/dist/shared/components/chat/ScreenClip.js +73 -69
  32. package/dist/shared/components/chat/chat-core.js +449 -396
  33. package/dist/shared/components/chat/huddle/huddle-store.js +48 -43
  34. package/dist/shared/components/help-videos/api.js +2 -5
  35. package/dist/shared/components/help-videos/viewer/HelpVideoMatchChip.js +79 -0
  36. package/dist/shared/components/help-videos/viewer/matchChip.js +50 -0
  37. package/dist/shared/components/imports/CollectionImportPanel.js +139 -133
  38. package/dist/shared/components/imports/RunDetailSheet.js +222 -227
  39. package/dist/shared/components/integrations/console/ErrorExplanation.js +121 -0
  40. package/dist/shared/components/integrations/console/PartnerDetail.js +175 -174
  41. package/dist/shared/components/integrations/console/SubmissionRow.js +36 -34
  42. package/dist/shared/components/integrations/console/drill/SubmissionDrill.js +50 -48
  43. package/dist/shared/components/item-edit/FieldComments.js +212 -0
  44. package/dist/shared/components/item-edit/FieldRow.js +340 -336
  45. package/dist/shared/components/item-edit/RecordHeaderActions.js +23 -22
  46. package/dist/shared/components/item-edit/RelationCombobox.js +231 -222
  47. package/dist/shared/components/item-edit/RuleHiddenNotes.js +55 -0
  48. package/dist/shared/components/item-edit/field-comments-context.js +6 -0
  49. package/dist/shared/components/item-edit/field-sources.js +33 -0
  50. package/dist/shared/components/item-edit/rule-hidden.js +30 -0
  51. package/dist/shared/components/layout-editor/HistoryPanel.js +113 -96
  52. package/dist/shared/components/layout-editor/editors/cascade-filters.js +170 -145
  53. package/dist/shared/components/layout-editor/inspector/Breadcrumb.js +22 -18
  54. package/dist/shared/components/layout-editor/inspector/GroupInspector.js +177 -159
  55. package/dist/shared/components/layout-editor/inspector/PickerTab.js +35 -34
  56. package/dist/shared/components/layout-editor/inspector/RulesTab.js +124 -111
  57. package/dist/shared/components/layout-editor/inspector/kit.js +292 -277
  58. package/dist/shared/components/layout-editor/parity-keys.json.js +1 -1
  59. package/dist/shared/components/list/CopyListLinkButton.js +41 -0
  60. package/dist/shared/components/list/InlineEdit.js +363 -0
  61. package/dist/shared/components/notifications/NotificationCenterView.js +213 -181
  62. package/dist/shared/components/notifications/NotificationDetailBits.js +205 -82
  63. package/dist/shared/components/notifications/NotificationRulesEditor.js +515 -0
  64. package/dist/shared/components/notifications/TestMyRules.js +137 -0
  65. package/dist/shared/components/notifications/changes-lines.js +24 -0
  66. package/dist/shared/components/notifications/why-lines.js +64 -0
  67. package/dist/shared/components/panels/CommentPanel.js +316 -281
  68. package/dist/shared/components/panels/LegalHoldBanner.js +38 -0
  69. package/dist/shared/components/panels/PipelinePanel.js +201 -196
  70. package/dist/shared/components/panels/RevisionsPanel.js +496 -479
  71. package/dist/shared/components/pipeline/PipelineEditorView.js +1587 -1560
  72. package/dist/shared/components/pipeline/PipelineStateOwners.js +116 -103
  73. package/dist/shared/components/profile/PersonDidPanel.js +188 -0
  74. package/dist/shared/components/profile/PersonProfile.js +57 -52
  75. package/dist/shared/components/queue/QueueWorklist.js +1526 -1365
  76. package/dist/shared/hooks/useSlowReason.js +39 -0
  77. package/dist/shared/lib/activity-sentence.js +670 -0
  78. package/dist/shared/lib/config-sentences.js +418 -0
  79. package/dist/shared/lib/core-glossary.js +229 -0
  80. package/dist/shared/lib/error-hints.js +159 -0
  81. package/dist/shared/lib/error-message.js +105 -0
  82. package/dist/shared/lib/error-toast.js +22 -0
  83. package/dist/shared/lib/field-comments.js +25 -0
  84. package/dist/shared/lib/filter-sentence.js +261 -0
  85. package/dist/shared/lib/glossary.js +55 -48
  86. package/dist/shared/lib/idle-reload.js +138 -0
  87. package/dist/shared/lib/layout-resolve.js +42 -29
  88. package/dist/shared/lib/list-inline-edit.js +190 -0
  89. package/dist/shared/lib/list-link.js +147 -0
  90. package/dist/shared/lib/prefetch.js +259 -106
  91. package/dist/shared/lib/record-ref.js +72 -0
  92. package/dist/shared/lib/reload-holds.js +25 -0
  93. package/dist/shared/lib/safe-error.js +52 -24
  94. package/dist/shared/lib/skeleton-shapes.js +72 -0
  95. package/dist/shared/lib/slow-reason.js +63 -0
  96. package/package.json +1 -1
@@ -1,115 +1,115 @@
1
- import { readItems as J } from "@nivaro/sdk";
2
- import { useQueryClient as v, useMutation as h, useQuery as y } from "@tanstack/react-query";
3
- import { useContext as Z, useState as x, useEffect as K, useMemo as k, useCallback as M, useRef as U, createContext as X } from "react";
4
- import { toast as ee } from "sonner";
5
- import { useNivaroClient as m } from "../../context.js";
6
- import { get as g, patch as R, post as O, del as A } from "../../lib/commands.js";
7
- import { isDndActive as te } from "../../lib/dnd.js";
8
- import { useLiveRefetchInterval as ne } from "../../lib/live-queries.js";
9
- import { playNotificationSound as se } from "../../lib/notification-sound.js";
10
- import { announceLocalPrefs as re } from "../../lib/user-sync.js";
11
- import { bindChatOutbox as oe, enqueueChatOutbox as ae } from "./chat-outbox.js";
12
- import { discardOutbox as wt, editOutbox as St, holdOutbox as Tt, nudgeChatOutbox as $t, retryOutbox as Kt, useOutbox as Ot } from "./chat-outbox.js";
13
- import { huddleHolds as ie, holdNotification as ce } from "./huddle/huddle-hold.js";
14
- const ke = ["👍", "✅", "👀", "🎉", "❤️", "😂"], ue = X(null);
15
- function b() {
16
- const e = Z(ue);
1
+ import { readItems as Z } from "@nivaro/sdk";
2
+ import { useQueryClient as q, useMutation as y, useQuery as p, useInfiniteQuery as J } from "@tanstack/react-query";
3
+ import { useContext as X, useState as O, useEffect as w, useMemo as k, useCallback as I, useRef as Q, createContext as ee } from "react";
4
+ import { toast as te } from "sonner";
5
+ import { useNivaroClient as f } from "../../context.js";
6
+ import { get as g, patch as R, post as F, del as N } from "../../lib/commands.js";
7
+ import { isDndActive as ne } from "../../lib/dnd.js";
8
+ import { useLiveRefetchInterval as se } from "../../lib/live-queries.js";
9
+ import { playNotificationSound as re } from "../../lib/notification-sound.js";
10
+ import { announceLocalPrefs as oe } from "../../lib/user-sync.js";
11
+ import { bindChatOutbox as ae, enqueueChatOutbox as ie } from "./chat-outbox.js";
12
+ import { discardOutbox as Ft, editOutbox as Kt, holdOutbox as Ot, nudgeChatOutbox as It, retryOutbox as xt, useOutbox as kt } from "./chat-outbox.js";
13
+ import { huddleHolds as ce, holdNotification as ue } from "./huddle/huddle-hold.js";
14
+ const Pe = ["👍", "✅", "👀", "🎉", "❤️", "😂"], le = ee(null);
15
+ function _() {
16
+ const e = X(le);
17
17
  if (!e) throw new Error("Chat components must be wrapped in <ChatProvider>");
18
18
  return e;
19
19
  }
20
- const Le = 0, xe = {
20
+ const Qe = 0, Ne = {
21
21
  collections: { messages: "chat_messages", reads: "chat_last_read", presence: "user_presence" },
22
22
  globalRoom: "global",
23
23
  globalLabel: "General",
24
24
  entityPattern: String.raw`\b([A-Za-z]{2,4}\d{2}(?:INV)?-\d+)\b`
25
25
  };
26
- function Qe(e, t) {
26
+ function Ue(e, t) {
27
27
  return `dm:${[e.toUpperCase(), t.toUpperCase()].sort().join(":")}`;
28
28
  }
29
- function B(e, t) {
29
+ function H(e, t) {
30
30
  if (!e.startsWith("dm:")) return null;
31
- const s = e.slice(3);
32
- return [s.slice(0, 36), s.slice(37)].find((o) => o.toLowerCase() !== t.toLowerCase()) ?? null;
31
+ const n = e.slice(3);
32
+ return [n.slice(0, 36), n.slice(37)].find((o) => o.toLowerCase() !== t.toLowerCase()) ?? null;
33
33
  }
34
- function F(e, t) {
35
- const s = b(), n = v(), o = (t ?? []).join("|");
36
- K(() => {
34
+ function K(e, t) {
35
+ const n = _(), s = q(), o = (t ?? []).join("|");
36
+ w(() => {
37
37
  const r = () => {
38
- for (const a of e) n.invalidateQueries({ queryKey: a });
38
+ for (const a of e) s.invalidateQueries({ queryKey: a });
39
39
  };
40
- if (s.subscribeRooms) return s.subscribeRooms(t ?? [], r);
41
- if (s.realtime) return s.realtime(s.collections.messages, r);
42
- }, [s.subscribeRooms, s.realtime, o, n]);
43
- }
44
- function le(e, t) {
45
- const s = b(), n = v();
46
- K(() => {
47
- if (s.realtime)
48
- return s.realtime(e, () => {
49
- for (const o of t) n.invalidateQueries({ queryKey: o });
40
+ if (n.subscribeRooms) return n.subscribeRooms(t ?? [], r);
41
+ if (n.realtime) return n.realtime(n.collections.messages, r);
42
+ }, [n.subscribeRooms, n.realtime, o, s]);
43
+ }
44
+ function de(e, t) {
45
+ const n = _(), s = q();
46
+ w(() => {
47
+ if (n.realtime)
48
+ return n.realtime(e, () => {
49
+ for (const o of t) s.invalidateQueries({ queryKey: o });
50
50
  });
51
- }, [s.realtime, e, n]);
51
+ }, [n.realtime, e, s]);
52
52
  }
53
- function Ue(e, t = null) {
54
- var D, N, E;
55
- const s = b(), n = m(), o = t ? "around" in t ? `around:${t.around}` : `date:${t.date}` : "latest", { data: r, isLoading: a } = y({
53
+ function Ae(e, t = null) {
54
+ var U, A, D;
55
+ const n = _(), s = f(), o = t ? "around" in t ? `around:${t.around}` : `date:${t.date}` : "latest", { data: r, isLoading: a } = p({
56
56
  queryKey: ["nvr-chat", e, o],
57
57
  queryFn: async () => {
58
58
  const C = { room: e, limit: 80 };
59
- return t && "around" in t && (C.around = t.around), t && "date" in t && (C.date = t.date), await n.request(
59
+ return t && "around" in t && (C.around = t.around), t && "date" in t && (C.date = t.date), await s.request(
60
60
  g("/chat/messages", C)
61
61
  );
62
62
  },
63
63
  enabled: !!e,
64
64
  staleTime: 5e3,
65
- refetchInterval: s.realtime || s.subscribeRooms ? void 0 : 1e4
65
+ refetchInterval: n.realtime || n.subscribeRooms ? void 0 : 1e4
66
66
  });
67
- F([["nvr-chat"], ["nvr-chat-rooms"], ["nvr-chat-thread"]], e ? [e] : []);
68
- const [i, c] = x([]), [f, u] = x(null), [d, l] = x(!1);
69
- K(() => {
70
- c([]), u(null);
67
+ K([["nvr-chat"], ["nvr-chat-rooms"], ["nvr-chat-thread"]], e ? [e] : []);
68
+ const [i, c] = O([]), [m, l] = O(null), [d, u] = O(!1);
69
+ w(() => {
70
+ c([]), l(null);
71
71
  }, [e, o]);
72
- const q = (r == null ? void 0 : r.data) ?? [], p = k(() => {
73
- if (i.length === 0) return q;
74
- const C = new Set(q.map((w) => w.id));
75
- return [...i.filter((w) => !C.has(w.id)), ...q];
76
- }, [i, q]), _ = M(async () => {
77
- var w;
72
+ const v = (r == null ? void 0 : r.data) ?? [], h = k(() => {
73
+ if (i.length === 0) return v;
74
+ const C = new Set(v.map((S) => S.id));
75
+ return [...i.filter((S) => !C.has(S.id)), ...v];
76
+ }, [i, v]), b = I(async () => {
77
+ var S;
78
78
  if (!e || d) return;
79
- const C = p[0];
79
+ const C = h[0];
80
80
  if (C) {
81
- l(!0);
81
+ u(!0);
82
82
  try {
83
- const P = await n.request(
83
+ const E = await s.request(
84
84
  g("/chat/messages", { room: e, limit: 60, before: C.id })
85
85
  );
86
- c((Y) => [...P.data ?? [], ...Y]), u(!!((w = P.meta) != null && w.has_older));
86
+ c((Y) => [...E.data ?? [], ...Y]), l(!!((S = E.meta) != null && S.has_older));
87
87
  } finally {
88
- l(!1);
88
+ u(!1);
89
89
  }
90
90
  }
91
- }, [e, p, n, d]);
91
+ }, [e, h, s, d]);
92
92
  return {
93
- messages: p,
93
+ messages: h,
94
94
  loading: a,
95
- hasOlder: f ?? !!((D = r == null ? void 0 : r.meta) != null && D.has_older),
96
- hasNewer: !!((N = r == null ? void 0 : r.meta) != null && N.has_newer),
97
- anchorId: ((E = r == null ? void 0 : r.meta) == null ? void 0 : E.anchor) ?? null,
98
- loadOlder: _,
95
+ hasOlder: m ?? !!((U = r == null ? void 0 : r.meta) != null && U.has_older),
96
+ hasNewer: !!((A = r == null ? void 0 : r.meta) != null && A.has_newer),
97
+ anchorId: ((D = r == null ? void 0 : r.meta) == null ? void 0 : D.anchor) ?? null,
98
+ loadOlder: b,
99
99
  loadingOlder: d
100
100
  };
101
101
  }
102
- function Ae(e, t) {
103
- const s = b(), n = m(), { data: o, isLoading: r } = y({
102
+ function De(e, t) {
103
+ const n = _(), s = f(), { data: o, isLoading: r } = p({
104
104
  queryKey: ["nvr-chat-thread", e, t],
105
- queryFn: async () => (await n.request(
105
+ queryFn: async () => (await s.request(
106
106
  g("/chat/messages", { room: e, thread: t, limit: 300 })
107
107
  )).data ?? [],
108
108
  enabled: !!e && !!t,
109
109
  staleTime: 5e3,
110
- refetchInterval: s.realtime || s.subscribeRooms ? void 0 : 1e4
110
+ refetchInterval: n.realtime || n.subscribeRooms ? void 0 : 1e4
111
111
  });
112
- F([["nvr-chat-thread"]], e ? [e] : []);
112
+ K([["nvr-chat-thread"]], e ? [e] : []);
113
113
  const a = o ?? [];
114
114
  return {
115
115
  root: a.find((i) => i.id === t) ?? null,
@@ -117,47 +117,47 @@ function Ae(e, t) {
117
117
  loading: r
118
118
  };
119
119
  }
120
- function De(e) {
120
+ function Ee(e) {
121
121
  var r, a, i;
122
- const t = m(), s = v(), n = b();
123
- return oe(t, s, ((r = n.me) == null ? void 0 : r.id) ?? null), { mutate: M(
122
+ const t = f(), n = q(), s = _();
123
+ return ae(t, n, ((r = s.me) == null ? void 0 : r.id) ?? null), { mutate: I(
124
124
  (c) => {
125
- var u, d;
126
- const f = typeof c == "string" ? { text: c } : c;
127
- ae({
128
- client_id: de(),
125
+ var l, d;
126
+ const m = typeof c == "string" ? { text: c } : c;
127
+ ie({
128
+ client_id: me(),
129
129
  room: e,
130
- text: f.text,
131
- mentions: f.mentions ?? [],
132
- attachments: f.attachments ?? [],
133
- parent_id: f.parentId ?? null,
134
- quote_id: f.quoteId ?? null,
135
- urgent: !!f.urgent,
130
+ text: m.text,
131
+ mentions: m.mentions ?? [],
132
+ attachments: m.attachments ?? [],
133
+ parent_id: m.parentId ?? null,
134
+ quote_id: m.quoteId ?? null,
135
+ urgent: !!m.urgent,
136
136
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
137
- sender: ((u = n.me) == null ? void 0 : u.id) ?? "",
138
- sender_name: ((d = n.me) == null ? void 0 : d.name) ?? null
137
+ sender: ((l = s.me) == null ? void 0 : l.id) ?? "",
138
+ sender_name: ((d = s.me) == null ? void 0 : d.name) ?? null
139
139
  });
140
140
  },
141
- [e, (a = n.me) == null ? void 0 : a.id, (i = n.me) == null ? void 0 : i.name]
141
+ [e, (a = s.me) == null ? void 0 : a.id, (i = s.me) == null ? void 0 : i.name]
142
142
  ), isPending: !1 };
143
143
  }
144
- function de() {
144
+ function me() {
145
145
  var t;
146
146
  const e = globalThis.crypto;
147
147
  return ((t = e == null ? void 0 : e.randomUUID) == null ? void 0 : t.call(e)) ?? `${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;
148
148
  }
149
- function G(e, t, s) {
150
- const n = (t == null ? void 0 : t.toLowerCase()) ?? "";
149
+ function G(e, t, n) {
150
+ const s = (t == null ? void 0 : t.toLowerCase()) ?? "";
151
151
  return e.map((r) => {
152
- var c, f, u, d, l;
152
+ var c, m, l, d, u;
153
153
  const a = r.kind === "unknown" ? "entity" : r.kind, i = a === "global" ? (
154
154
  // The server names General only when an admin renamed it.
155
- r.label ?? s.globalLabel
155
+ r.label ?? n.globalLabel
156
156
  ) : a === "dm" ? (
157
157
  // The server resolves the peer's name from the user table; the
158
158
  // message sender is only a fallback for hosts that don't send one.
159
- r.label ?? (((f = (c = r.last_message) == null ? void 0 : c.sender) == null ? void 0 : f.toLowerCase()) !== n ? ((u = r.last_message) == null ? void 0 : u.sender_name) ?? null : null) ?? `User ${((d = B(r.room, n)) == null ? void 0 : d.slice(0, 8)) ?? ""}`
160
- ) : r.label ?? ((l = s.roomLabel) == null ? void 0 : l.call(s, r.room)) ?? r.room.toUpperCase();
159
+ r.label ?? (((m = (c = r.last_message) == null ? void 0 : c.sender) == null ? void 0 : m.toLowerCase()) !== s ? ((l = r.last_message) == null ? void 0 : l.sender_name) ?? null : null) ?? `User ${((d = H(r.room, s)) == null ? void 0 : d.slice(0, 8)) ?? ""}`
160
+ ) : r.label ?? ((u = n.roomLabel) == null ? void 0 : u.call(n, r.room)) ?? r.room.toUpperCase();
161
161
  return {
162
162
  room: r.room,
163
163
  label: i,
@@ -180,83 +180,83 @@ function G(e, t, s) {
180
180
  return (a.lastMessage ? new Date(a.lastMessage.date_created).getTime() : 0) - i;
181
181
  });
182
182
  }
183
- function Ne() {
184
- const e = b(), t = m(), s = e.me, n = y({
185
- queryKey: ["nvr-chat-rooms", s == null ? void 0 : s.id],
183
+ function je() {
184
+ const e = _(), t = f(), n = e.me, s = p({
185
+ queryKey: ["nvr-chat-rooms", n == null ? void 0 : n.id],
186
186
  queryFn: async () => (await t.request(g("/chat/rooms"))).data ?? [],
187
- enabled: !!s,
187
+ enabled: !!n,
188
188
  refetchInterval: 45e3,
189
189
  staleTime: 1e4
190
190
  });
191
- F([["nvr-chat-rooms"]]);
191
+ K([["nvr-chat-rooms"]]);
192
192
  const o = k(
193
- () => G(n.data ?? [], s == null ? void 0 : s.id, e),
194
- [n.data, s == null ? void 0 : s.id, e]
193
+ () => G(s.data ?? [], n == null ? void 0 : n.id, e),
194
+ [s.data, n == null ? void 0 : n.id, e]
195
195
  ), r = L().chat_badge_mode, a = o.reduce((i, c) => {
196
- var f;
196
+ var m;
197
197
  if (c.muted) return i;
198
198
  if (r === "conversations") {
199
- const u = c.kind === "dm" || c.kind === "channel" && !!((f = c.channel) != null && f.is_direct);
200
- return i + (u ? c.unread : c.mentions ?? 0);
199
+ const l = c.kind === "dm" || c.kind === "channel" && !!((m = c.channel) != null && m.is_direct);
200
+ return i + (l ? c.unread : c.mentions ?? 0);
201
201
  }
202
202
  return i + c.unread;
203
203
  }, 0);
204
- return { rooms: o, totalUnread: a, loading: n.isLoading };
204
+ return { rooms: o, totalUnread: a, loading: s.isLoading };
205
205
  }
206
- function Ee(e) {
207
- const t = b(), s = m(), n = t.me, o = y({
208
- queryKey: ["nvr-chat-rooms", n == null ? void 0 : n.id, "archived"],
209
- queryFn: async () => (await s.request(
206
+ function ze(e) {
207
+ const t = _(), n = f(), s = t.me, o = p({
208
+ queryKey: ["nvr-chat-rooms", s == null ? void 0 : s.id, "archived"],
209
+ queryFn: async () => (await n.request(
210
210
  g("/chat/rooms", { archived: "1" })
211
211
  )).data ?? [],
212
- enabled: !!n && e,
212
+ enabled: !!s && e,
213
213
  staleTime: 1e4
214
214
  });
215
- return { rooms: k(() => G(o.data ?? [], n == null ? void 0 : n.id, t), [o.data, n == null ? void 0 : n.id, t]), loading: o.isLoading };
215
+ return { rooms: k(() => G(o.data ?? [], s == null ? void 0 : s.id, t), [o.data, s == null ? void 0 : s.id, t]), loading: o.isLoading };
216
216
  }
217
- function Pe(e) {
218
- const t = m(), { data: s, isLoading: n } = y({
217
+ function Be(e) {
218
+ const t = f(), { data: n, isLoading: s } = p({
219
219
  queryKey: ["nvr-chat-directory", e],
220
220
  queryFn: async () => (await t.request(
221
221
  g("/chat/directory", e ? { search: e } : void 0)
222
222
  )).data ?? [],
223
223
  staleTime: 15e3
224
224
  });
225
- return { channels: s ?? [], loading: n };
225
+ return { channels: n ?? [], loading: s };
226
226
  }
227
- function je() {
228
- const e = m(), t = v(), s = () => {
227
+ function He() {
228
+ const e = f(), t = q(), n = () => {
229
229
  t.invalidateQueries({ queryKey: ["nvr-chat-rooms"] }), t.invalidateQueries({ queryKey: ["nvr-chat-directory"] });
230
- }, n = h({
231
- mutationFn: (u) => e.request(O(`/chat/rooms/${encodeURIComponent(u)}/join`)),
232
- onSuccess: s
233
- }), o = h({
234
- mutationFn: (u) => e.request(A(`/chat/rooms/${encodeURIComponent(u)}/join`)),
235
- onSuccess: s
236
- }), r = h({
237
- mutationFn: ({ room: u, muted: d }) => e.request(R(`/chat/rooms/${encodeURIComponent(u)}`, { muted: d })),
238
- onSuccess: s
239
- }), a = h({
240
- mutationFn: ({ room: u, mode: d }) => e.request(
241
- R(`/chat/rooms/${encodeURIComponent(u)}`, {
230
+ }, s = y({
231
+ mutationFn: (l) => e.request(F(`/chat/rooms/${encodeURIComponent(l)}/join`)),
232
+ onSuccess: n
233
+ }), o = y({
234
+ mutationFn: (l) => e.request(N(`/chat/rooms/${encodeURIComponent(l)}/join`)),
235
+ onSuccess: n
236
+ }), r = y({
237
+ mutationFn: ({ room: l, muted: d }) => e.request(R(`/chat/rooms/${encodeURIComponent(l)}`, { muted: d })),
238
+ onSuccess: n
239
+ }), a = y({
240
+ mutationFn: ({ room: l, mode: d }) => e.request(
241
+ R(`/chat/rooms/${encodeURIComponent(l)}`, {
242
242
  notify_mode: d === "mentions" ? "mentions" : null
243
243
  })
244
244
  ),
245
- onSuccess: s
246
- }), i = h({
247
- mutationFn: ({ room: u, archived: d }) => e.request(R(`/chat/rooms/${encodeURIComponent(u)}`, { archived: d })),
248
- onSuccess: s
249
- }), c = h({
250
- mutationFn: ({ room: u, starred: d }) => e.request(R(`/chat/rooms/${encodeURIComponent(u)}`, { starred: d })),
251
- onSuccess: s
252
- }), f = h({
253
- mutationFn: (u) => e.request(R(`/chat/rooms/${encodeURIComponent(u)}`, { welcome_seen: !0 })),
254
- onSuccess: s
245
+ onSuccess: n
246
+ }), i = y({
247
+ mutationFn: ({ room: l, archived: d }) => e.request(R(`/chat/rooms/${encodeURIComponent(l)}`, { archived: d })),
248
+ onSuccess: n
249
+ }), c = y({
250
+ mutationFn: ({ room: l, starred: d }) => e.request(R(`/chat/rooms/${encodeURIComponent(l)}`, { starred: d })),
251
+ onSuccess: n
252
+ }), m = y({
253
+ mutationFn: (l) => e.request(R(`/chat/rooms/${encodeURIComponent(l)}`, { welcome_seen: !0 })),
254
+ onSuccess: n
255
255
  });
256
- return { join: n, leave: o, setMuted: r, setNotifyMode: a, setArchived: i, setStarred: c, dismissWelcome: f };
256
+ return { join: s, leave: o, setMuted: r, setNotifyMode: a, setArchived: i, setStarred: c, dismissWelcome: m };
257
257
  }
258
- function ze(e) {
259
- const t = m(), { data: s, isLoading: n } = y({
258
+ function Ge(e) {
259
+ const t = f(), { data: n, isLoading: s } = p({
260
260
  queryKey: ["nvr-chat-members", e],
261
261
  queryFn: async () => (await t.request(
262
262
  g(`/chat/channels/${e}/members`)
@@ -264,25 +264,74 @@ function ze(e) {
264
264
  enabled: e != null,
265
265
  staleTime: 1e4
266
266
  });
267
- return { members: s ?? [], loading: n };
267
+ return { members: n ?? [], loading: s };
268
+ }
269
+ const fe = 50;
270
+ function Ve(e, t) {
271
+ const [n, s] = O(e);
272
+ return w(() => {
273
+ const o = setTimeout(() => s(e), t);
274
+ return () => clearTimeout(o);
275
+ }, [e, t]), n;
276
+ }
277
+ function he(e) {
278
+ const t = String(e.id ?? e.user ?? ""), n = e.first_name ?? null, s = e.last_name ?? null, o = e.email ?? null;
279
+ return {
280
+ id: t,
281
+ name: String(e.name ?? ([n, s].filter(Boolean).join(" ") || o || t)),
282
+ title: e.title ?? null,
283
+ online: e.online === !0,
284
+ first_name: n,
285
+ last_name: s,
286
+ email: o
287
+ };
288
+ }
289
+ function We(e, t, n, s) {
290
+ var c, m, l;
291
+ const o = f(), r = J({
292
+ queryKey: ["nvr-chat-members-page", e, t, n],
293
+ initialPageParam: 0,
294
+ queryFn: async ({ pageParam: d }) => {
295
+ const u = new URLSearchParams({ limit: String(fe), offset: String(d) });
296
+ return n.trim() && u.set("q", n.trim()), await o.request(
297
+ g(`${t}?${u.toString()}`)
298
+ );
299
+ },
300
+ getNextPageParam: (d, u) => d.has_more ? u.reduce((v, h) => {
301
+ var b;
302
+ return v + (((b = h.data) == null ? void 0 : b.length) ?? 0);
303
+ }, 0) : void 0,
304
+ enabled: s && !!t,
305
+ staleTime: 1e4
306
+ }), a = (((c = r.data) == null ? void 0 : c.pages) ?? []).flatMap((d) => (d.data ?? []).map(he)), i = ((l = (m = r.data) == null ? void 0 : m.pages[0]) == null ? void 0 : l.total) ?? a.length;
307
+ return {
308
+ members: a,
309
+ total: i,
310
+ loading: r.isLoading,
311
+ hasMore: !!r.hasNextPage,
312
+ loadingMore: r.isFetchingNextPage,
313
+ loadMore: () => {
314
+ r.hasNextPage && !r.isFetchingNextPage && r.fetchNextPage();
315
+ }
316
+ };
268
317
  }
269
- function He(e) {
270
- const t = m(), s = v(), n = () => {
271
- s.invalidateQueries({ queryKey: ["nvr-chat-members", e] }), s.invalidateQueries({ queryKey: ["nvr-chat-rooms"] }), s.invalidateQueries({ queryKey: ["nvr-chat-directory"] });
272
- }, o = h({
318
+ function Ye(e) {
319
+ const t = f(), n = q(), s = () => {
320
+ n.invalidateQueries({ queryKey: ["nvr-chat-members", e] }), n.invalidateQueries({ queryKey: ["nvr-chat-members-page"] }), n.invalidateQueries({ queryKey: ["nvr-chat-rooms"] }), n.invalidateQueries({ queryKey: ["nvr-chat-directory"] });
321
+ }, o = y({
273
322
  mutationFn: (i) => t.request(R(`/chat/channels/${e}`, i)),
274
- onSuccess: n
275
- }), r = h({
276
- mutationFn: (i) => t.request(O(`/chat/channels/${e}/members`, { user_id: i })),
277
- onSuccess: n
278
- }), a = h({
279
- mutationFn: (i) => t.request(A(`/chat/channels/${e}/members/${i}`)),
280
- onSuccess: n
323
+ onSuccess: s
324
+ }), r = y({
325
+ mutationFn: (i) => t.request(F(`/chat/channels/${e}/members`, { user_id: i })),
326
+ onSuccess: s
327
+ }), a = y({
328
+ mutationFn: (i) => t.request(N(`/chat/channels/${e}/members/${i}`)),
329
+ onSuccess: s
281
330
  });
282
331
  return { update: o, addMember: r, removeMember: a };
283
332
  }
284
- function Be() {
285
- const e = m(), { data: t } = y({
333
+ function Ze() {
334
+ const e = f(), { data: t } = p({
286
335
  queryKey: ["nvr-chat-roles"],
287
336
  queryFn: async () => (await e.request(
288
337
  g("/chat/roles")
@@ -291,217 +340,217 @@ function Be() {
291
340
  });
292
341
  return t ?? [];
293
342
  }
294
- function Ge(e, t) {
295
- const s = m(), { data: n, isLoading: o } = y({
343
+ function Je(e, t) {
344
+ const n = f(), { data: s, isLoading: o } = p({
296
345
  queryKey: ["nvr-chat-user-search", e],
297
- queryFn: async () => (await s.request(
346
+ queryFn: async () => (await n.request(
298
347
  g("/users", { limit: 20, ...e.trim() ? { search: e.trim() } : {} })
299
348
  )).data ?? [],
300
349
  enabled: t,
301
350
  staleTime: 3e4
302
351
  });
303
- return { users: n ?? [], loading: o };
352
+ return { users: s ?? [], loading: o };
304
353
  }
305
- function Ve() {
306
- const e = m(), t = v();
307
- return h({
308
- mutationFn: (s) => e.request(O("/chat/channels", s)),
354
+ function Xe() {
355
+ const e = f(), t = q();
356
+ return y({
357
+ mutationFn: (n) => e.request(F("/chat/channels", n)),
309
358
  onSuccess: () => {
310
359
  t.invalidateQueries({ queryKey: ["nvr-chat-rooms"] }), t.invalidateQueries({ queryKey: ["nvr-chat-directory"] });
311
360
  }
312
361
  });
313
362
  }
314
363
  let j = 0;
315
- const Q = /* @__PURE__ */ new Map();
364
+ const P = /* @__PURE__ */ new Map();
316
365
  function z(e) {
317
366
  var t;
318
367
  return e.kind === "dm" || e.kind === "channel" && !!((t = e.channel) != null && t.is_direct);
319
368
  }
320
- const S = /* @__PURE__ */ new Map();
321
- function We(e) {
322
- K(() => {
369
+ const T = /* @__PURE__ */ new Map();
370
+ function et(e) {
371
+ w(() => {
323
372
  if (e)
324
- return S.set(e, (S.get(e) ?? 0) + 1), () => {
325
- const t = (S.get(e) ?? 1) - 1;
326
- t <= 0 ? S.delete(e) : S.set(e, t);
373
+ return T.set(e, (T.get(e) ?? 0) + 1), () => {
374
+ const t = (T.get(e) ?? 1) - 1;
375
+ t <= 0 ? T.delete(e) : T.set(e, t);
327
376
  };
328
377
  }, [e]);
329
378
  }
330
- function me() {
379
+ function ye() {
331
380
  return typeof document > "u" || document.visibilityState === "visible";
332
381
  }
333
- function H(e) {
334
- return S.has(e) && me();
382
+ function B(e) {
383
+ return T.has(e) && ye();
335
384
  }
336
- function fe() {
385
+ function ge() {
337
386
  const e = L().notification_sound;
338
387
  return typeof e == "string" ? e : "off";
339
388
  }
340
389
  function L() {
341
- const e = m(), { data: t } = y({
390
+ const e = f(), { data: t } = p({
342
391
  queryKey: ["nvr-profile-prefs"],
343
- queryFn: () => e.request(g("/users/me")).then((s) => {
344
- var n;
345
- return ((n = s.data) == null ? void 0 : n.preferences) ?? {};
392
+ queryFn: () => e.request(g("/users/me")).then((n) => {
393
+ var s;
394
+ return ((s = n.data) == null ? void 0 : s.preferences) ?? {};
346
395
  }),
347
396
  staleTime: 6e4
348
397
  });
349
398
  return t ?? {};
350
399
  }
351
- function he() {
352
- const e = m(), t = v();
353
- return h({
354
- mutationFn: (s) => e.request(R("/users/me/preferences", s)),
355
- onMutate: (s) => {
356
- const n = t.getQueryData(["nvr-profile-prefs"]);
357
- return t.setQueryData(["nvr-profile-prefs"], { ...n ?? {}, ...s }), { prev: n };
400
+ function pe() {
401
+ const e = f(), t = q();
402
+ return y({
403
+ mutationFn: (n) => e.request(R("/users/me/preferences", n)),
404
+ onMutate: (n) => {
405
+ const s = t.getQueryData(["nvr-profile-prefs"]);
406
+ return t.setQueryData(["nvr-profile-prefs"], { ...s ?? {}, ...n }), { prev: s };
358
407
  },
359
- onError: (s, n, o) => {
408
+ onError: (n, s, o) => {
360
409
  o != null && o.prev && t.setQueryData(["nvr-profile-prefs"], o.prev);
361
410
  },
362
- onSuccess: (s, n) => re(Object.keys(n)),
411
+ onSuccess: (n, s) => oe(Object.keys(s)),
363
412
  onSettled: () => {
364
413
  t.invalidateQueries({ queryKey: ["nvr-profile-prefs"] }), t.invalidateQueries({ queryKey: ["presence-online"] });
365
414
  }
366
415
  });
367
416
  }
368
- function Ye() {
369
- const e = L(), t = he(), s = Object.keys(e).length > 0;
370
- K(() => {
371
- if (!s) return;
372
- let n = "";
417
+ function tt() {
418
+ const e = L(), t = pe(), n = Object.keys(e).length > 0;
419
+ w(() => {
420
+ if (!n) return;
421
+ let s = "";
373
422
  try {
374
- n = Intl.DateTimeFormat().resolvedOptions().timeZone || "";
423
+ s = Intl.DateTimeFormat().resolvedOptions().timeZone || "";
375
424
  } catch {
376
425
  return;
377
426
  }
378
- if (!(!n || e.browser_timezone === n)) {
427
+ if (!(!s || e.browser_timezone === s)) {
379
428
  try {
380
- if (sessionStorage.getItem("nvr-browser-tz") === n) return;
381
- sessionStorage.setItem("nvr-browser-tz", n);
429
+ if (sessionStorage.getItem("nvr-browser-tz") === s) return;
430
+ sessionStorage.setItem("nvr-browser-tz", s);
382
431
  } catch {
383
432
  }
384
- t.mutate({ browser_timezone: n });
433
+ t.mutate({ browser_timezone: s });
385
434
  }
386
- }, [s, e.browser_timezone]);
387
- }
388
- function Je(e, t) {
389
- const s = b(), n = fe(), o = L(), r = U(o);
390
- r.current = o, K(() => {
391
- const a = t ? t.filter((u) => z(u) && !H(u.room)).reduce((u, d) => u + d.unread, 0) : e, i = a > j, c = ie(r.current), f = te(r.current) || c;
392
- if (s.sound && i && !f && se(n), s.sound && i && c && ce({ kind: "chat", title: "New message" }), t) {
393
- const u = Q.size > 0, d = S.size > 0;
394
- for (const l of t) {
395
- const q = Q.get(l.room) ?? 0;
396
- if (u && !f && !l.muted && z(l) && l.unread > q && !H(l.room)) {
397
- const p = l.lastMessage, _ = p != null && p.sender_name ? String(p.sender_name).trim() : null;
398
- ee(
399
- l.kind === "dm" ? `New message from ${_ || l.label}` : `New message in ${l.label}${_ ? ` — ${_}` : ""}`,
435
+ }, [n, e.browser_timezone]);
436
+ }
437
+ function nt(e, t) {
438
+ const n = _(), s = ge(), o = L(), r = Q(o);
439
+ r.current = o, w(() => {
440
+ const a = t ? t.filter((l) => z(l) && !B(l.room)).reduce((l, d) => l + d.unread, 0) : e, i = a > j, c = ce(r.current), m = ne(r.current) || c;
441
+ if (n.sound && i && !m && re(s), n.sound && i && c && ue({ kind: "chat", title: "New message" }), t) {
442
+ const l = P.size > 0, d = T.size > 0;
443
+ for (const u of t) {
444
+ const v = P.get(u.room) ?? 0;
445
+ if (l && !m && !u.muted && z(u) && u.unread > v && !B(u.room)) {
446
+ const h = u.lastMessage, b = h != null && h.sender_name ? String(h.sender_name).trim() : null;
447
+ te(
448
+ u.kind === "dm" ? `New message from ${b || u.label}` : `New message in ${u.label}${b ? ` — ${b}` : ""}`,
400
449
  {
401
- description: p != null && p.message ? String(p.message).replace(/<[^>]*>/g, "").slice(0, 90) : void 0,
450
+ description: h != null && h.message ? String(h.message).replace(/<[^>]*>/g, "").slice(0, 90) : void 0,
402
451
  duration: 4e3,
403
452
  ...d ? { position: "top-center" } : {},
404
453
  // Reading the message is the whole reason the toast exists, so
405
454
  // it opens the conversation — only when a host has somewhere to
406
455
  // open it, otherwise the click would do nothing.
407
- ...be() ? {
456
+ ...Re() ? {
408
457
  className: "cursor-pointer",
409
458
  onDismiss: void 0,
410
459
  action: {
411
460
  label: "Open",
412
- onClick: () => W(l.room, l.label)
461
+ onClick: () => W(u.room, u.label)
413
462
  }
414
463
  } : {}
415
464
  }
416
465
  );
417
466
  }
418
- Q.set(l.room, l.unread);
467
+ P.set(u.room, u.unread);
419
468
  }
420
469
  }
421
470
  j = a;
422
- }, [e, s.sound, t, n]);
471
+ }, [e, n.sound, t, s]);
423
472
  }
424
- function Ze() {
425
- const e = m(), t = v();
426
- return h({
427
- mutationFn: (s) => e.request(O(`/chat/rooms/${encodeURIComponent(s)}/read`)),
473
+ function st() {
474
+ const e = f(), t = q();
475
+ return y({
476
+ mutationFn: (n) => e.request(F(`/chat/rooms/${encodeURIComponent(n)}/read`)),
428
477
  onSuccess: () => void t.invalidateQueries({ queryKey: ["nvr-chat-rooms"] })
429
478
  });
430
479
  }
431
- const ye = ["nvr-chat-room-types"];
480
+ const ve = ["nvr-chat-room-types"];
432
481
  function V(e) {
433
482
  return {
434
- queryKey: ye,
483
+ queryKey: ve,
435
484
  queryFn: async () => {
436
485
  const t = await e.request(g("/chat/room-types"));
437
- return ((t == null ? void 0 : t.data) ?? []).filter((s) => s.is_active);
486
+ return ((t == null ? void 0 : t.data) ?? []).filter((n) => n.is_active);
438
487
  },
439
488
  staleTime: 5 * 6e4
440
489
  };
441
490
  }
442
- function Xe(e) {
443
- const t = b(), s = m(), n = (e == null ? void 0 : e.indexOf(":")) ?? -1, o = e && n > 0 ? e.slice(0, n) : null, r = e && n > 0 ? e.slice(n + 1) : null, a = !!e && !!o && !!r && e !== t.globalRoom && o !== "dm" && o !== "ch", { data: i } = y({ ...V(s), enabled: a }), c = a ? i == null ? void 0 : i.find((d) => d.is_active && d.prefix === o) : void 0, { data: f } = y({
491
+ function rt(e) {
492
+ const t = _(), n = f(), s = (e == null ? void 0 : e.indexOf(":")) ?? -1, o = e && s > 0 ? e.slice(0, s) : null, r = e && s > 0 ? e.slice(s + 1) : null, a = !!e && !!o && !!r && e !== t.globalRoom && o !== "dm" && o !== "ch", { data: i } = p({ ...V(n), enabled: a }), c = a ? i == null ? void 0 : i.find((d) => d.is_active && d.prefix === o) : void 0, { data: m } = p({
444
493
  queryKey: ["nvr-chat-entity-record", c == null ? void 0 : c.collection, c == null ? void 0 : c.match_field, r],
445
494
  queryFn: async () => {
446
- var l, q;
447
- return c.match_field === "id" ? r : ((q = (l = (await s.request(
495
+ var u, v;
496
+ return c.match_field === "id" ? r : ((v = (u = (await n.request(
448
497
  g(`/items/${c.collection}`, {
449
498
  limit: 1,
450
499
  fields: "id",
451
500
  filter: JSON.stringify({ [c.match_field]: { _eq: r } })
452
501
  })
453
- )).data) == null ? void 0 : l[0]) == null ? void 0 : q.id) ?? null;
502
+ )).data) == null ? void 0 : u[0]) == null ? void 0 : v.id) ?? null;
454
503
  },
455
504
  enabled: !!c && !!r,
456
505
  staleTime: 5 * 6e4
457
506
  });
458
- return !c || f == null ? null : (t.recordUrl ?? ((d, l) => `/collections/${d}/${l}`))(c.collection, f);
507
+ return !c || m == null ? null : (t.recordUrl ?? ((d, u) => `/collections/${d}/${u}`))(c.collection, m);
459
508
  }
460
- const ge = /@\[([^\]]+)\](?:\([^)]*\))?/g;
461
- function et(e, t) {
462
- const s = new RegExp(t, "gi"), n = [];
463
- for (const a of e.matchAll(ge))
464
- n.push({
509
+ const qe = /@\[([^\]]+)\](?:\([^)]*\))?/g;
510
+ function ot(e, t) {
511
+ const n = new RegExp(t, "gi"), s = [];
512
+ for (const a of e.matchAll(qe))
513
+ s.push({
465
514
  start: a.index,
466
515
  end: a.index + a[0].length,
467
516
  token: { text: `@${a[1]}`, mention: a[1] }
468
517
  });
469
- for (const a of e.matchAll(s))
470
- n.some((i) => a.index >= i.start && a.index < i.end) || n.push({
518
+ for (const a of e.matchAll(n))
519
+ s.some((i) => a.index >= i.start && a.index < i.end) || s.push({
471
520
  start: a.index,
472
521
  end: a.index + a[0].length,
473
522
  token: { text: a[0], entity: a[0].toUpperCase() }
474
523
  });
475
- n.sort((a, i) => a.start - i.start);
524
+ s.sort((a, i) => a.start - i.start);
476
525
  const o = [];
477
526
  let r = 0;
478
- for (const a of n)
527
+ for (const a of s)
479
528
  a.start > r && o.push({ text: e.slice(r, a.start) }), o.push(a.token), r = a.end;
480
529
  return r < e.length && o.push({ text: e.slice(r) }), o;
481
530
  }
482
- function tt(e, t) {
483
- const n = e.slice(0, t).match(/@([^@\n\r]*)$/);
484
- return n ? n[1] : null;
485
- }
486
- const pe = 3e3;
487
- function nt(e) {
488
- const t = b(), s = m();
489
- v();
490
- const n = U(!1), o = U(null), r = t.me, a = M(() => {
491
- o.current && clearTimeout(o.current), o.current = null, n.current && r && t.setTypingRoom && (n.current = !1, t.setTypingRoom(r.id, null));
492
- }, [r, t]), i = M(() => {
493
- !r || !e || !t.setTypingRoom || (n.current || (n.current = !0, t.setTypingRoom(r.id, e)), o.current && clearTimeout(o.current), o.current = setTimeout(a, pe));
531
+ function at(e, t) {
532
+ const s = e.slice(0, t).match(/@([^@\n\r]*)$/);
533
+ return s ? s[1] : null;
534
+ }
535
+ const be = 3e3;
536
+ function it(e) {
537
+ const t = _(), n = f();
538
+ q();
539
+ const s = Q(!1), o = Q(null), r = t.me, a = I(() => {
540
+ o.current && clearTimeout(o.current), o.current = null, s.current && r && t.setTypingRoom && (s.current = !1, t.setTypingRoom(r.id, null));
541
+ }, [r, t]), i = I(() => {
542
+ !r || !e || !t.setTypingRoom || (s.current || (s.current = !0, t.setTypingRoom(r.id, e)), o.current && clearTimeout(o.current), o.current = setTimeout(a, be));
494
543
  }, [r, e, t, a]);
495
- K(() => a, [a]);
496
- const c = ne(6e3, {
544
+ w(() => a, [a]);
545
+ const c = se(6e3, {
497
546
  safetyMs: 3e4,
498
547
  enabled: !!t.realtime
499
- }), { data: f } = y({
548
+ }), { data: m } = p({
500
549
  queryKey: ["nvr-chat-typing", e],
501
550
  queryFn: async () => {
502
551
  const d = new Date(Date.now() - 6e4).toISOString();
503
- return (await s.request(
504
- J(t.collections.presence, {
552
+ return (await n.request(
553
+ Z(t.collections.presence, {
505
554
  limit: 10,
506
555
  fields: ["user_id", "display_name", "typing_room", "last_seen"],
507
556
  filter: { typing_room: { _eq: e }, last_seen: { _gte: d } }
@@ -512,23 +561,23 @@ function nt(e) {
512
561
  refetchInterval: c,
513
562
  staleTime: 2e3
514
563
  });
515
- le(t.collections.presence, [["nvr-chat-typing"]]);
516
- const u = k(() => {
517
- var q;
518
- const d = (q = r == null ? void 0 : r.id) == null ? void 0 : q.toLowerCase(), l = (f ?? []).filter((p) => {
519
- var _;
520
- return ((_ = p.user_id) == null ? void 0 : _.toLowerCase()) !== d;
521
- }).map((p) => p.display_name ?? "Someone");
522
- return l.length === 0 ? null : l.length === 1 ? `${l[0]} is typing…` : l.length === 2 ? `${l[0]} and ${l[1]} are typing…` : `${l.length} people are typing…`;
523
- }, [f, r == null ? void 0 : r.id]);
524
- return { onType: i, clearTyping: a, typingText: u };
525
- }
526
- function st(e) {
527
- const t = b(), s = m(), n = t.me, o = e && n ? B(e, n.id) : null, { data: r } = y({
564
+ de(t.collections.presence, [["nvr-chat-typing"]]);
565
+ const l = k(() => {
566
+ var v;
567
+ const d = (v = r == null ? void 0 : r.id) == null ? void 0 : v.toLowerCase(), u = (m ?? []).filter((h) => {
568
+ var b;
569
+ return ((b = h.user_id) == null ? void 0 : b.toLowerCase()) !== d;
570
+ }).map((h) => h.display_name ?? "Someone");
571
+ return u.length === 0 ? null : u.length === 1 ? `${u[0]} is typing…` : u.length === 2 ? `${u[0]} and ${u[1]} are typing…` : `${u.length} people are typing…`;
572
+ }, [m, r == null ? void 0 : r.id]);
573
+ return { onType: i, clearTyping: a, typingText: l };
574
+ }
575
+ function ct(e) {
576
+ const t = _(), n = f(), s = t.me, o = e && s ? H(e, s.id) : null, { data: r } = p({
528
577
  queryKey: ["nvr-chat-peer-read", e],
529
578
  queryFn: async () => {
530
579
  var i;
531
- return ((i = (await s.request(
580
+ return ((i = (await n.request(
532
581
  g(
533
582
  `/chat/rooms/${encodeURIComponent(e)}/peer-read`
534
583
  )
@@ -538,40 +587,40 @@ function st(e) {
538
587
  refetchInterval: 3e4,
539
588
  staleTime: 5e3
540
589
  });
541
- return F([["nvr-chat-peer-read"]], e ? [e] : []), r ?? null;
590
+ return K([["nvr-chat-peer-read"]], e ? [e] : []), r ?? null;
542
591
  }
543
- function rt(e) {
544
- const t = m(), s = v();
545
- return h({
546
- mutationFn: ({ messageId: n, emoji: o }) => t.request(O(`/chat/messages/${n}/reactions`, { emoji: o })),
547
- onSuccess: () => void s.invalidateQueries({ queryKey: ["nvr-chat", e] })
592
+ function ut(e) {
593
+ const t = f(), n = q();
594
+ return y({
595
+ mutationFn: ({ messageId: s, emoji: o }) => t.request(F(`/chat/messages/${s}/reactions`, { emoji: o })),
596
+ onSuccess: () => void n.invalidateQueries({ queryKey: ["nvr-chat", e] })
548
597
  });
549
598
  }
550
- function ot(e) {
551
- const t = m(), s = v();
552
- return h({
553
- mutationFn: ({ messageId: n, text: o }) => t.request(R(`/chat/messages/${n}`, { message: o })),
554
- onSuccess: () => void s.invalidateQueries({ queryKey: ["nvr-chat", e] })
599
+ function lt(e) {
600
+ const t = f(), n = q();
601
+ return y({
602
+ mutationFn: ({ messageId: s, text: o }) => t.request(R(`/chat/messages/${s}`, { message: o })),
603
+ onSuccess: () => void n.invalidateQueries({ queryKey: ["nvr-chat", e] })
555
604
  });
556
605
  }
557
- function at(e) {
558
- const t = m(), s = v();
559
- return h({
560
- mutationFn: (n) => t.request(A(`/chat/messages/${n}`)),
606
+ function dt(e) {
607
+ const t = f(), n = q();
608
+ return y({
609
+ mutationFn: (s) => t.request(N(`/chat/messages/${s}`)),
561
610
  onSuccess: () => {
562
- s.invalidateQueries({ queryKey: ["nvr-chat", e] }), s.invalidateQueries({ queryKey: ["nvr-chat-rooms"] });
611
+ n.invalidateQueries({ queryKey: ["nvr-chat", e] }), n.invalidateQueries({ queryKey: ["nvr-chat-rooms"] });
563
612
  }
564
613
  });
565
614
  }
566
- function it(e, t = {}) {
567
- const s = m(), n = { q: e };
568
- t.sender && (n.sender = t.sender), t.room && (n.room = t.room), t.from && (n.from = t.from), t.to && (n.to = t.to), t.has_attachment && (n.has_attachment = "1"), t.mentions_me && (n.mentions_me = "1");
569
- const o = Object.keys(n).length > 1, { data: r, isLoading: a } = y({
570
- queryKey: ["nvr-chat-search", n],
615
+ function mt(e, t = {}) {
616
+ const n = f(), s = { q: e };
617
+ t.sender && (s.sender = t.sender), t.room && (s.room = t.room), t.from && (s.from = t.from), t.to && (s.to = t.to), t.has_attachment && (s.has_attachment = "1"), t.mentions_me && (s.mentions_me = "1");
618
+ const o = Object.keys(s).length > 1, { data: r, isLoading: a } = p({
619
+ queryKey: ["nvr-chat-search", s],
571
620
  queryFn: async () => {
572
621
  var c;
573
- const i = await s.request(
574
- g("/chat/search", n)
622
+ const i = await n.request(
623
+ g("/chat/search", s)
575
624
  );
576
625
  return { hits: i.data ?? [], meaning: ((c = i.meta) == null ? void 0 : c.meaning) ?? null };
577
626
  },
@@ -580,26 +629,26 @@ function it(e, t = {}) {
580
629
  });
581
630
  return { hits: (r == null ? void 0 : r.hits) ?? [], meaning: (r == null ? void 0 : r.meaning) ?? null, loading: a };
582
631
  }
583
- function ct() {
584
- const e = m(), t = v();
585
- return h({
586
- mutationFn: async (s) => (await e.request(O("/chat/group-dm", s))).data,
632
+ function ft() {
633
+ const e = f(), t = q();
634
+ return y({
635
+ mutationFn: async (n) => (await e.request(F("/chat/group-dm", n))).data,
587
636
  onSuccess: () => void t.invalidateQueries({ queryKey: ["nvr-chat-rooms"] })
588
637
  });
589
638
  }
590
- function ve() {
591
- const e = m(), { data: t } = y({
639
+ function _e() {
640
+ const e = f(), { data: t } = p({
592
641
  queryKey: ["nvr-chat-config"],
593
642
  queryFn: async () => (await e.request(g("/chat/config"))).data ?? { bot_name: null, bot_user_id: null },
594
643
  staleTime: 5 * 6e4
595
644
  });
596
645
  return t ?? { bot_name: null, bot_user_id: null };
597
646
  }
598
- function ut() {
599
- return ve().bot_name;
647
+ function ht() {
648
+ return _e().bot_name;
600
649
  }
601
- function lt(e) {
602
- const t = m(), { data: s } = y({
650
+ function yt(e) {
651
+ const t = f(), { data: n } = p({
603
652
  queryKey: ["nvr-chat-pins", e],
604
653
  queryFn: async () => (await t.request(
605
654
  g(`/chat/rooms/${encodeURIComponent(e)}/pins`)
@@ -607,16 +656,16 @@ function lt(e) {
607
656
  enabled: !!e,
608
657
  staleTime: 15e3
609
658
  });
610
- return F([["nvr-chat-pins"]], e ? [e] : []), s ?? [];
659
+ return K([["nvr-chat-pins"]], e ? [e] : []), n ?? [];
611
660
  }
612
- function dt(e) {
613
- const t = m(), s = v();
614
- return h({
615
- mutationFn: (n) => t.request(O(`/chat/messages/${n}/pin`)),
616
- onSuccess: () => void s.invalidateQueries({ queryKey: ["nvr-chat-pins", e] })
661
+ function gt(e) {
662
+ const t = f(), n = q();
663
+ return y({
664
+ mutationFn: (s) => t.request(F(`/chat/messages/${s}/pin`)),
665
+ onSuccess: () => void n.invalidateQueries({ queryKey: ["nvr-chat-pins", e] })
617
666
  });
618
667
  }
619
- const I = [
668
+ const x = [
620
669
  "#7dd3fc",
621
670
  "#86efac",
622
671
  "#fcd34d",
@@ -626,126 +675,130 @@ const I = [
626
675
  "#99f6e4",
627
676
  "#00ceff"
628
677
  ];
629
- function mt(e) {
630
- return I[qe(e)];
678
+ function pt(e) {
679
+ return x[Ce(e)];
631
680
  }
632
- function qe(e) {
681
+ function Ce(e) {
633
682
  let t = 0;
634
- for (const s of e) t = t * 31 + s.charCodeAt(0) | 0;
635
- return Math.abs(t) % I.length;
683
+ for (const n of e) t = t * 31 + n.charCodeAt(0) | 0;
684
+ return Math.abs(t) % x.length;
636
685
  }
637
- function ft(e) {
638
- return Number.isInteger(e) && e >= 0 && e < I.length ? I[e] : null;
686
+ function vt(e) {
687
+ return Number.isInteger(e) && e >= 0 && e < x.length ? x[e] : null;
639
688
  }
640
- function ht(e) {
641
- return [...e].sort((t, s) => {
642
- const n = (t.display_name ?? "").trim(), o = (s.display_name ?? "").trim();
643
- return !n != !o ? n ? -1 : 1 : n.localeCompare(o, void 0, { sensitivity: "base" }) || String(t.user_id).localeCompare(String(s.user_id));
689
+ function qt(e) {
690
+ return [...e].sort((t, n) => {
691
+ const s = (t.display_name ?? "").trim(), o = (n.display_name ?? "").trim();
692
+ return !s != !o ? s ? -1 : 1 : s.localeCompare(o, void 0, { sensitivity: "base" }) || String(t.user_id).localeCompare(String(n.user_id));
644
693
  });
645
694
  }
646
- function yt(e) {
647
- var s, n;
695
+ function bt(e) {
696
+ var n, s;
648
697
  if (!e) return "?";
649
698
  const t = e.trim().split(/\s+/);
650
- return ((((s = t[0]) == null ? void 0 : s[0]) ?? "") + (((n = t[1]) == null ? void 0 : n[0]) ?? "")).toUpperCase() || "?";
699
+ return ((((n = t[0]) == null ? void 0 : n[0]) ?? "") + (((s = t[1]) == null ? void 0 : s[0]) ?? "")).toUpperCase() || "?";
651
700
  }
652
- let T = null;
653
- function gt(e) {
654
- return T = e, () => {
655
- T === e && (T = null);
701
+ let M = null;
702
+ function _t(e) {
703
+ return M = e, () => {
704
+ M === e && (M = null);
656
705
  };
657
706
  }
658
- function pt() {
659
- return T !== null;
707
+ function Ct() {
708
+ return M !== null;
660
709
  }
661
- function vt(e, t) {
662
- T == null || T(e, t);
710
+ function Rt(e, t) {
711
+ M == null || M(e, t);
663
712
  }
664
713
  let $ = null;
665
- function qt(e) {
714
+ function wt(e) {
666
715
  return $ = e, () => {
667
716
  $ === e && ($ = null);
668
717
  };
669
718
  }
670
- function be() {
719
+ function Re() {
671
720
  return $ !== null;
672
721
  }
673
722
  function W(e, t) {
674
723
  $ == null || $(e, t);
675
724
  }
676
- function bt(e = !0) {
677
- const t = m(), { data: s } = y({ ...V(t), enabled: e });
678
- return s;
725
+ function St(e = !0) {
726
+ const t = f(), { data: n } = p({ ...V(t), enabled: e });
727
+ return n;
679
728
  }
680
- async function _t(e, t, s) {
729
+ async function Tt(e, t, n) {
681
730
  var r;
682
- const n = await e.request(
683
- g("/chat/record-room", { collection: t, item: s })
731
+ const s = await e.request(
732
+ g("/chat/record-room", { collection: t, item: n })
684
733
  );
685
- if (!((r = n.data) != null && r.room)) return !1;
686
- const o = n.data.room.slice(n.data.room.indexOf(":") + 1);
687
- return W(n.data.room, o), !0;
734
+ if (!((r = s.data) != null && r.room)) return !1;
735
+ const o = s.data.room.slice(s.data.room.indexOf(":") + 1);
736
+ return W(s.data.room, o), !0;
688
737
  }
689
738
  export {
690
- xe as CHAT_DEFAULTS,
691
- ye as CHAT_ROOM_TYPES_KEY,
692
- ue as ChatConfigContext,
693
- Le as GENERAL_CHANNEL_ID,
694
- ke as REACTION_EMOJI,
695
- be as canOpenChatRoom,
696
- pt as canOpenDm,
697
- mt as chatAvatarColor,
698
- ft as chatAvatarColorAt,
699
- qe as chatAvatarColorIndex,
700
- yt as chatInitials,
739
+ Ne as CHAT_DEFAULTS,
740
+ ve as CHAT_ROOM_TYPES_KEY,
741
+ le as ChatConfigContext,
742
+ Qe as GENERAL_CHANNEL_ID,
743
+ fe as MEMBER_PAGE_SIZE,
744
+ Pe as REACTION_EMOJI,
745
+ Re as canOpenChatRoom,
746
+ Ct as canOpenDm,
747
+ pt as chatAvatarColor,
748
+ vt as chatAvatarColorAt,
749
+ Ce as chatAvatarColorIndex,
750
+ bt as chatInitials,
701
751
  V as chatRoomTypesQuery,
702
- wt as discardOutbox,
703
- _t as discussRecord,
704
- B as dmPeer,
705
- Qe as dmRoom,
706
- St as editOutbox,
707
- tt as getMentionQuery,
708
- Tt as holdOutbox,
709
- $t as nudgeChatOutbox,
752
+ Ft as discardOutbox,
753
+ Tt as discussRecord,
754
+ H as dmPeer,
755
+ Ue as dmRoom,
756
+ Kt as editOutbox,
757
+ at as getMentionQuery,
758
+ Ot as holdOutbox,
759
+ It as nudgeChatOutbox,
710
760
  W as openChatRoom,
711
- vt as openDmWith,
712
- gt as registerDmOpener,
713
- qt as registerRoomOpener,
714
- Kt as retryOutbox,
715
- ht as sortOnlineUsers,
716
- et as splitMessageTokens,
717
- Ee as useArchivedRooms,
718
- He as useChannelAdmin,
719
- Pe as useChannelDirectory,
720
- ze as useChannelMembers,
721
- ve as useChatBotInfo,
722
- ut as useChatBotName,
723
- b as useChatConfig,
724
- Ue as useChatMessages,
725
- Be as useChatRoles,
726
- Ne as useChatRooms,
727
- it as useChatSearch,
728
- Ae as useChatThread,
729
- Ve as useCreateChannel,
730
- ct as useCreateGroupDm,
731
- at as useDeleteMessage,
732
- ot as useEditMessage,
733
- Xe as useEntityRoomLink,
734
- Ze as useMarkRoomRead,
761
+ Rt as openDmWith,
762
+ _t as registerDmOpener,
763
+ wt as registerRoomOpener,
764
+ xt as retryOutbox,
765
+ qt as sortOnlineUsers,
766
+ ot as splitMessageTokens,
767
+ he as toPagedMember,
768
+ ze as useArchivedRooms,
769
+ Ye as useChannelAdmin,
770
+ Be as useChannelDirectory,
771
+ Ge as useChannelMembers,
772
+ _e as useChatBotInfo,
773
+ ht as useChatBotName,
774
+ _ as useChatConfig,
775
+ Ae as useChatMessages,
776
+ Ze as useChatRoles,
777
+ je as useChatRooms,
778
+ mt as useChatSearch,
779
+ De as useChatThread,
780
+ Xe as useCreateChannel,
781
+ ft as useCreateGroupDm,
782
+ Ve as useDebouncedMemberQuery,
783
+ dt as useDeleteMessage,
784
+ lt as useEditMessage,
785
+ rt as useEntityRoomLink,
786
+ st as useMarkRoomRead,
735
787
  L as useMyPreferences,
736
- fe as useNotificationSoundPreference,
737
- We as useOpenRoomRegistration,
738
- Ot as useOutbox,
739
- st as usePeerReadAt,
740
- Ye as useRecordBrowserTimezone,
741
- bt as useRecordRoomTypes,
742
- je as useRoomMembership,
743
- lt as useRoomPins,
744
- De as useSendChatMessage,
745
- he as useSetMyPreferences,
746
- dt as useTogglePin,
747
- rt as useToggleReaction,
748
- nt as useTypingIndicator,
749
- Je as useUnreadChirp,
750
- Ge as useUserSearch
788
+ ge as useNotificationSoundPreference,
789
+ et as useOpenRoomRegistration,
790
+ kt as useOutbox,
791
+ We as usePagedMembers,
792
+ ct as usePeerReadAt,
793
+ tt as useRecordBrowserTimezone,
794
+ St as useRecordRoomTypes,
795
+ He as useRoomMembership,
796
+ yt as useRoomPins,
797
+ Ee as useSendChatMessage,
798
+ pe as useSetMyPreferences,
799
+ gt as useTogglePin,
800
+ ut as useToggleReaction,
801
+ it as useTypingIndicator,
802
+ nt as useUnreadChirp,
803
+ Je as useUserSearch
751
804
  };