@nivaro/react 0.3.137 → 0.3.139

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 (50) hide show
  1. package/dist/full.css +1 -1
  2. package/dist/hooks/useSessionRecorder.js +1 -1
  3. package/dist/index.d.ts +95 -4
  4. package/dist/index.js +748 -743
  5. package/dist/shared/components/CollectionBrowserView.js +392 -389
  6. package/dist/shared/components/DelegateCoverLine.js +80 -87
  7. package/dist/shared/components/ItemEditForm.js +589 -588
  8. package/dist/shared/components/MyWorkView.js +284 -286
  9. package/dist/shared/components/NotificationBell.js +251 -205
  10. package/dist/shared/components/ai/AiAnalyticsView.js +878 -417
  11. package/dist/shared/components/ai/AiPlanCard.js +164 -122
  12. package/dist/shared/components/ai/AiPlanUndo.js +291 -0
  13. package/dist/shared/components/ai/call-log/CallDrawer.js +357 -0
  14. package/dist/shared/components/ai/call-log/RawJson.js +126 -0
  15. package/dist/shared/components/ai/call-log/ThreadView.js +223 -0
  16. package/dist/shared/components/ai/call-log/TranscriptView.js +227 -0
  17. package/dist/shared/components/ai/call-log/controls.js +364 -0
  18. package/dist/shared/components/ai/call-log/format.js +46 -0
  19. package/dist/shared/components/ai/call-log/url.js +105 -0
  20. package/dist/shared/components/chat/chat-core.js +422 -346
  21. package/dist/shared/components/integrations/IntegrationObligationsView.js +98 -98
  22. package/dist/shared/components/integrations/RecordIntegrationPreview.js +102 -93
  23. package/dist/shared/components/integrations/console/api.js +11 -1
  24. package/dist/shared/components/item-edit/HeaderRollupExplainer.js +5 -1
  25. package/dist/shared/components/item-edit/RecordLiveSync.js +241 -229
  26. package/dist/shared/components/item-edit/RecordRecapChanges.js +166 -0
  27. package/dist/shared/components/item-edit/RecordRecapStrip.js +254 -84
  28. package/dist/shared/components/item-edit/live-related.js +34 -18
  29. package/dist/shared/components/panels/RevisionsPanel.js +735 -683
  30. package/dist/shared/components/queue/QueueWorklist.js +323 -316
  31. package/dist/shared/components/support/SupportRequestDialog.js +198 -181
  32. package/dist/shared/components/trackers/use-tracker-link.js +74 -65
  33. package/dist/shared/lib/activity-sentence.js +167 -151
  34. package/dist/shared/lib/config-update-refresh.js +34 -0
  35. package/dist/shared/lib/config-watch.js +17 -17
  36. package/dist/shared/lib/gap-refresh.js +49 -0
  37. package/dist/shared/lib/integration-dots.js +8 -8
  38. package/dist/shared/lib/live-ops.js +26 -23
  39. package/dist/shared/lib/live-pickers.js +1 -1
  40. package/dist/shared/lib/live-queries.js +223 -195
  41. package/dist/shared/lib/live.js +56 -51
  42. package/dist/shared/lib/obligation-banner.js +11 -10
  43. package/dist/shared/lib/obligation-filters.js +22 -18
  44. package/dist/shared/lib/obligation-reason-text.js +18 -8
  45. package/dist/shared/lib/presence-hooks.js +133 -132
  46. package/dist/shared/lib/reconnect-resync.js +90 -0
  47. package/dist/shared/lib/record-room-holds.js +43 -0
  48. package/dist/shared/lib/socket-realtime.js +116 -105
  49. package/dist/shared/lib/user-sync.js +1 -6
  50. package/package.json +1 -1
@@ -1,107 +1,136 @@
1
- import { useQueryClient as _, useMutation as g, useQuery as q, useInfiniteQuery as ee } from "@tanstack/react-query";
2
- import { useContext as te, useState as I, useEffect as S, useMemo as z, useCallback as P, useRef as Q, createContext as ne } from "react";
3
- import { useNivaroClient as f } from "../../context.js";
4
- import { get as p, patch as F, post as K, del as B } from "../../lib/commands.js";
5
- import { isDndActive as se } from "../../lib/dnd.js";
6
- import { playNotificationSound as re } from "../../lib/notification-sound.js";
7
- import { useOptionalRealtime as oe } from "../../lib/realtime.js";
8
- import { useTabAttention as ae } from "../../lib/tab-attention.js";
9
- import { announceLocalPrefs as ie } from "../../lib/user-sync.js";
10
- import { showChatMessageCard as ce, dismissChatCard as ue } from "./ChatMessageToast.js";
11
- import { bindChatOutbox as H, enqueueChatOutbox as V } from "./chat-outbox.js";
12
- import { discardOutbox as It, editOutbox as $t, holdOutbox as Pt, nudgeChatOutbox as Qt, retryOutbox as Ut, useOutbox as At } from "./chat-outbox.js";
13
- import { TYPING_REPEAT_MS as le, applyTypingEvent as de, typingSentence as me } from "./chat-typing.js";
14
- import { huddleHolds as fe, holdNotification as he } from "./huddle/huddle-hold.js";
15
- const Le = ["👍", "✅", "👀", "🎉", "❤️", "😂"], ye = ne(null);
1
+ import { useQueryClient as C, useMutation as g, useQuery as _, useInfiniteQuery as te } from "@tanstack/react-query";
2
+ import { useContext as ne, useState as E, useEffect as w, useMemo as z, useCallback as $, useRef as L, createContext as se } from "react";
3
+ import { useNivaroClient as h } from "../../context.js";
4
+ import { get as v, patch as K, post as O, del as H } from "../../lib/commands.js";
5
+ import { isDndActive as re } from "../../lib/dnd.js";
6
+ import { playNotificationSound as oe } from "../../lib/notification-sound.js";
7
+ import { useOptionalRealtime as ae } from "../../lib/realtime.js";
8
+ import { useTabAttention as ie } from "../../lib/tab-attention.js";
9
+ import { announceLocalPrefs as ce } from "../../lib/user-sync.js";
10
+ import { showChatMessageCard as ue, dismissChatCard as le } from "./ChatMessageToast.js";
11
+ import { bindChatOutbox as J, enqueueChatOutbox as Y } from "./chat-outbox.js";
12
+ import { discardOutbox as Ut, editOutbox as Dt, holdOutbox as jt, nudgeChatOutbox as zt, retryOutbox as Ht, useOutbox as Bt } from "./chat-outbox.js";
13
+ import { TYPING_REPEAT_MS as de, applyTypingEvent as me, typingSentence as fe } from "./chat-typing.js";
14
+ import { huddleHolds as he, holdNotification as ye } from "./huddle/huddle-hold.js";
15
+ const Je = ["👍", "✅", "👀", "🎉", "❤️", "😂"], pe = se(null);
16
16
  function T() {
17
- const e = te(ye);
17
+ const e = ne(pe);
18
18
  if (!e) throw new Error("Chat components must be wrapped in <ChatProvider>");
19
19
  return e;
20
20
  }
21
- const Ne = 0, De = {
21
+ const Ye = 0, Ve = {
22
22
  collections: { messages: "chat_messages", reads: "chat_last_read", presence: "user_presence" },
23
23
  globalRoom: "global",
24
24
  globalLabel: "General",
25
25
  entityPattern: String.raw`\b([A-Za-z]{2,4}\d{2}(?:INV)?-\d+)\b`
26
26
  };
27
- function je(e, t) {
27
+ function We(e, t) {
28
28
  return `dm:${[e.toUpperCase(), t.toUpperCase()].sort().join(":")}`;
29
29
  }
30
- function Y(e, t) {
30
+ function V(e, t) {
31
31
  if (!e.startsWith("dm:")) return null;
32
32
  const n = e.slice(3);
33
33
  return [n.slice(0, 36), n.slice(37)].find((o) => o.toLowerCase() !== t.toLowerCase()) ?? null;
34
34
  }
35
- function U(e, t) {
36
- const n = T(), s = _(), o = (t ?? []).join("|");
37
- S(() => {
38
- const r = () => {
39
- for (const a of e) s.invalidateQueries({ queryKey: a });
35
+ const ge = /* @__PURE__ */ new Set([
36
+ "nvr-chat",
37
+ "nvr-chat-thread",
38
+ "nvr-chat-peer-read",
39
+ "nvr-chat-pins"
40
+ ]), ve = 300;
41
+ function qe(e, t) {
42
+ const n = [];
43
+ for (const s of e)
44
+ if (t && s.length === 1 && ge.has(s[0]))
45
+ for (const o of t) n.push([s[0], o]);
46
+ else n.push(s);
47
+ return n;
48
+ }
49
+ function N(e, t) {
50
+ const n = T(), s = C(), o = (t ?? []).join("|"), r = JSON.stringify(e), a = n.collections.messages;
51
+ w(() => {
52
+ const i = o ? new Set(o.split("|")) : null, c = JSON.parse(r);
53
+ let u = null, l = /* @__PURE__ */ new Set();
54
+ const d = /* @__PURE__ */ new Set(), f = () => {
55
+ u = null;
56
+ const y = l;
57
+ l = /* @__PURE__ */ new Set(), d.clear();
58
+ for (const q of qe(c, y)) s.invalidateQueries({ queryKey: q });
59
+ }, p = (y) => {
60
+ const q = typeof (y == null ? void 0 : y.room) == "string" ? y.room : null;
61
+ if (!(i && q && !i.has(q))) {
62
+ if ((y == null ? void 0 : y.id) != null) {
63
+ if (d.has(y.id)) return;
64
+ d.add(y.id);
65
+ }
66
+ q && l ? l.add(q) : l = null, u || (u = setTimeout(f, ve));
67
+ }
68
+ }, m = n.subscribeRooms ? n.subscribeRooms(i ? [...i] : [], p) : n.realtime ? n.realtime(a, () => p(null)) : void 0;
69
+ return () => {
70
+ m == null || m(), u && clearTimeout(u);
40
71
  };
41
- if (n.subscribeRooms) return n.subscribeRooms(t ?? [], r);
42
- if (n.realtime) return n.realtime(n.collections.messages, r);
43
- }, [n.subscribeRooms, n.realtime, o, s]);
72
+ }, [n.subscribeRooms, n.realtime, a, o, r, s]);
44
73
  }
45
- function ze(e, t = null) {
46
- var w, R, M;
47
- const n = T(), s = f(), o = t ? "around" in t ? `around:${t.around}` : `date:${t.date}` : "latest", { data: r, isLoading: a } = q({
74
+ function Ze(e, t = null) {
75
+ var q, S, M;
76
+ const n = T(), s = h(), o = t ? "around" in t ? `around:${t.around}` : `date:${t.date}` : "latest", { data: r, isLoading: a } = _({
48
77
  queryKey: ["nvr-chat", e, o],
49
78
  queryFn: async () => {
50
- const v = { room: e, limit: 80 };
51
- return t && "around" in t && (v.around = t.around), t && "date" in t && (v.date = t.date), await s.request(
52
- p("/chat/messages", v)
79
+ const b = { room: e, limit: 80 };
80
+ return t && "around" in t && (b.around = t.around), t && "date" in t && (b.date = t.date), await s.request(
81
+ v("/chat/messages", b)
53
82
  );
54
83
  },
55
84
  enabled: !!e,
56
85
  staleTime: 5e3,
57
86
  refetchInterval: n.realtime || n.subscribeRooms ? void 0 : 1e4
58
87
  });
59
- U([["nvr-chat"], ["nvr-chat-rooms"], ["nvr-chat-thread"]], e ? [e] : []);
60
- const [i, c] = I([]), [d, u] = I(null), [l, h] = I(!1);
61
- S(() => {
62
- c([]), u(null);
88
+ N([["nvr-chat"], ["nvr-chat-rooms"], ["nvr-chat-thread"]], e ? [e] : []);
89
+ const [i, c] = E([]), [u, l] = E(null), [d, f] = E(!1);
90
+ w(() => {
91
+ c([]), l(null);
63
92
  }, [e, o]);
64
- const y = (r == null ? void 0 : r.data) ?? [], m = z(() => {
65
- if (i.length === 0) return y;
66
- const v = new Set(y.map((C) => C.id));
67
- return [...i.filter((C) => !v.has(C.id)), ...y];
68
- }, [i, y]), b = P(async () => {
69
- var C;
70
- if (!e || l) return;
71
- const v = m[0];
72
- if (v) {
73
- h(!0);
93
+ const p = (r == null ? void 0 : r.data) ?? [], m = z(() => {
94
+ if (i.length === 0) return p;
95
+ const b = new Set(p.map((R) => R.id));
96
+ return [...i.filter((R) => !b.has(R.id)), ...p];
97
+ }, [i, p]), y = $(async () => {
98
+ var R;
99
+ if (!e || d) return;
100
+ const b = m[0];
101
+ if (b) {
102
+ f(!0);
74
103
  try {
75
- const $ = await s.request(
76
- p("/chat/messages", { room: e, limit: 60, before: v.id })
104
+ const I = await s.request(
105
+ v("/chat/messages", { room: e, limit: 60, before: b.id })
77
106
  );
78
- c((A) => [...$.data ?? [], ...A]), u(!!((C = $.meta) != null && C.has_older));
107
+ c((P) => [...I.data ?? [], ...P]), l(!!((R = I.meta) != null && R.has_older));
79
108
  } finally {
80
- h(!1);
109
+ f(!1);
81
110
  }
82
111
  }
83
- }, [e, m, s, l]);
112
+ }, [e, m, s, d]);
84
113
  return {
85
114
  messages: m,
86
115
  loading: a,
87
- hasOlder: d ?? !!((w = r == null ? void 0 : r.meta) != null && w.has_older),
88
- hasNewer: !!((R = r == null ? void 0 : r.meta) != null && R.has_newer),
116
+ hasOlder: u ?? !!((q = r == null ? void 0 : r.meta) != null && q.has_older),
117
+ hasNewer: !!((S = r == null ? void 0 : r.meta) != null && S.has_newer),
89
118
  anchorId: ((M = r == null ? void 0 : r.meta) == null ? void 0 : M.anchor) ?? null,
90
- loadOlder: b,
91
- loadingOlder: l
119
+ loadOlder: y,
120
+ loadingOlder: d
92
121
  };
93
122
  }
94
- function Be(e, t) {
95
- const n = T(), s = f(), { data: o, isLoading: r } = q({
123
+ function Xe(e, t) {
124
+ const n = T(), s = h(), { data: o, isLoading: r } = _({
96
125
  queryKey: ["nvr-chat-thread", e, t],
97
126
  queryFn: async () => (await s.request(
98
- p("/chat/messages", { room: e, thread: t, limit: 300 })
127
+ v("/chat/messages", { room: e, thread: t, limit: 300 })
99
128
  )).data ?? [],
100
129
  enabled: !!e && !!t,
101
130
  staleTime: 5e3,
102
131
  refetchInterval: n.realtime || n.subscribeRooms ? void 0 : 1e4
103
132
  });
104
- U([["nvr-chat-thread"]], e ? [e] : []);
133
+ N([["nvr-chat-thread"]], e ? [e] : []);
105
134
  const a = o ?? [];
106
135
  return {
107
136
  root: a.find((i) => i.id === t) ?? null,
@@ -109,25 +138,25 @@ function Be(e, t) {
109
138
  loading: r
110
139
  };
111
140
  }
112
- function Ge(e) {
141
+ function et(e) {
113
142
  var r, a, i;
114
- const t = f(), n = _(), s = T();
115
- return H(t, n, ((r = s.me) == null ? void 0 : r.id) ?? null), { mutate: P(
143
+ const t = h(), n = C(), s = T();
144
+ return J(t, n, ((r = s.me) == null ? void 0 : r.id) ?? null), { mutate: $(
116
145
  (c) => {
117
- var u, l;
118
- const d = typeof c == "string" ? { text: c } : c;
119
- V({
146
+ var l, d;
147
+ const u = typeof c == "string" ? { text: c } : c;
148
+ Y({
120
149
  client_id: W(),
121
150
  room: e,
122
- text: d.text,
123
- mentions: d.mentions ?? [],
124
- attachments: d.attachments ?? [],
125
- parent_id: d.parentId ?? null,
126
- quote_id: d.quoteId ?? null,
127
- urgent: !!d.urgent,
151
+ text: u.text,
152
+ mentions: u.mentions ?? [],
153
+ attachments: u.attachments ?? [],
154
+ parent_id: u.parentId ?? null,
155
+ quote_id: u.quoteId ?? null,
156
+ urgent: !!u.urgent,
128
157
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
129
- sender: ((u = s.me) == null ? void 0 : u.id) ?? "",
130
- sender_name: ((l = s.me) == null ? void 0 : l.name) ?? null
158
+ sender: ((l = s.me) == null ? void 0 : l.id) ?? "",
159
+ sender_name: ((d = s.me) == null ? void 0 : d.name) ?? null
131
160
  });
132
161
  },
133
162
  [e, (a = s.me) == null ? void 0 : a.id, (i = s.me) == null ? void 0 : i.name]
@@ -141,15 +170,15 @@ function W() {
141
170
  function Z(e, t, n) {
142
171
  const s = (t == null ? void 0 : t.toLowerCase()) ?? "";
143
172
  return e.map((r) => {
144
- var c, d, u, l, h;
173
+ var c, u, l, d, f;
145
174
  const a = r.kind === "unknown" ? "entity" : r.kind, i = a === "global" ? (
146
175
  // The server names General only when an admin renamed it.
147
176
  r.label ?? n.globalLabel
148
177
  ) : a === "dm" ? (
149
178
  // The server resolves the peer's name from the user table; the
150
179
  // message sender is only a fallback for hosts that don't send one.
151
- r.label ?? (((d = (c = r.last_message) == null ? void 0 : c.sender) == null ? void 0 : d.toLowerCase()) !== s ? ((u = r.last_message) == null ? void 0 : u.sender_name) ?? null : null) ?? `User ${((l = Y(r.room, s)) == null ? void 0 : l.slice(0, 8)) ?? ""}`
152
- ) : r.label ?? ((h = n.roomLabel) == null ? void 0 : h.call(n, r.room)) ?? r.room.toUpperCase();
180
+ r.label ?? (((u = (c = r.last_message) == null ? void 0 : c.sender) == null ? void 0 : u.toLowerCase()) !== s ? ((l = r.last_message) == null ? void 0 : l.sender_name) ?? null : null) ?? `User ${((d = V(r.room, s)) == null ? void 0 : d.slice(0, 8)) ?? ""}`
181
+ ) : r.label ?? ((f = n.roomLabel) == null ? void 0 : f.call(n, r.room)) ?? r.room.toUpperCase();
153
182
  return {
154
183
  room: r.room,
155
184
  label: i,
@@ -172,101 +201,143 @@ function Z(e, t, n) {
172
201
  return (a.lastMessage ? new Date(a.lastMessage.date_created).getTime() : 0) - i;
173
202
  });
174
203
  }
175
- function He() {
176
- const e = T(), t = f(), n = e.me, s = q({
204
+ function tt() {
205
+ const e = T(), t = h(), n = e.me, s = _({
177
206
  queryKey: ["nvr-chat-rooms", n == null ? void 0 : n.id],
178
- queryFn: async () => (await t.request(p("/chat/rooms"))).data ?? [],
207
+ queryFn: async () => (await t.request(v("/chat/rooms"))).data ?? [],
179
208
  enabled: !!n,
180
209
  refetchInterval: 45e3,
181
210
  staleTime: 1e4
182
211
  });
183
- U([["nvr-chat-rooms"]]);
212
+ Re(s.data, n == null ? void 0 : n.id);
184
213
  const o = z(
185
214
  () => Z(s.data ?? [], n == null ? void 0 : n.id, e),
186
215
  [s.data, n == null ? void 0 : n.id, e]
187
- ), r = N().chat_badge_mode, a = o.reduce((i, c) => {
188
- var d;
216
+ ), r = U().chat_badge_mode, a = o.reduce((i, c) => {
217
+ var u;
189
218
  if (c.muted) return i;
190
219
  if (r === "conversations") {
191
- const u = c.kind === "dm" || c.kind === "channel" && !!((d = c.channel) != null && d.is_direct);
192
- return i + (u ? c.unread : c.mentions ?? 0);
220
+ const l = c.kind === "dm" || c.kind === "channel" && !!((u = c.channel) != null && u.is_direct);
221
+ return i + (l ? c.unread : c.mentions ?? 0);
193
222
  }
194
223
  return i + c.unread;
195
224
  }, 0);
196
225
  return { rooms: o, totalUnread: a, loading: s.isLoading };
197
226
  }
198
- function Ve(e) {
199
- const t = T(), n = f(), s = t.me, o = q({
227
+ const be = 40;
228
+ function _e(e) {
229
+ return (e ?? []).filter((t) => t.joined && !t.archived && (t.kind === "channel" || t.kind === "global")).slice(0, be).map((t) => t.room).sort();
230
+ }
231
+ function Ce(e, t, n) {
232
+ if (!e || !t.room || t.parent_id || n && String(t.sender ?? "").toLowerCase() === n.toLowerCase()) return e;
233
+ let s = !1;
234
+ const o = e.map((r) => r.room !== t.room ? r : (s = !0, { ...r, unread: (r.unread ?? 0) + 1, last_message: t }));
235
+ return s ? o : e;
236
+ }
237
+ const B = /* @__PURE__ */ new WeakMap();
238
+ function Re(e, t) {
239
+ const n = T(), s = C(), o = _e(e).join("|");
240
+ w(() => {
241
+ const r = new Set(o ? o.split("|") : []);
242
+ let a = null;
243
+ const i = () => {
244
+ a || (a = setTimeout(() => {
245
+ a = null, s.invalidateQueries({ queryKey: ["nvr-chat-rooms"] }, { cancelRefetch: !1 });
246
+ }, 1e3));
247
+ };
248
+ let c = B.get(s);
249
+ c || (c = /* @__PURE__ */ new Set(), B.set(s, c));
250
+ const u = c, l = (f) => {
251
+ if (f != null && f.room && r.has(f.room)) {
252
+ if (f.id != null) {
253
+ if (u.has(f.id)) return;
254
+ u.size > 500 && u.clear(), u.add(f.id);
255
+ }
256
+ s.setQueryData(
257
+ ["nvr-chat-rooms", t],
258
+ (p) => Ce(p, f, t)
259
+ );
260
+ return;
261
+ }
262
+ i();
263
+ }, d = n.subscribeRooms ? n.subscribeRooms([...r], l) : n.realtime ? n.realtime(n.collections.messages, () => i()) : void 0;
264
+ return () => {
265
+ d == null || d(), a && clearTimeout(a);
266
+ };
267
+ }, [n.subscribeRooms, n.realtime, n.collections.messages, o, t, s]);
268
+ }
269
+ function nt(e) {
270
+ const t = T(), n = h(), s = t.me, o = _({
200
271
  queryKey: ["nvr-chat-rooms", s == null ? void 0 : s.id, "archived"],
201
272
  queryFn: async () => (await n.request(
202
- p("/chat/rooms", { archived: "1" })
273
+ v("/chat/rooms", { archived: "1" })
203
274
  )).data ?? [],
204
275
  enabled: !!s && e,
205
276
  staleTime: 1e4
206
277
  });
207
278
  return { rooms: z(() => Z(o.data ?? [], s == null ? void 0 : s.id, t), [o.data, s == null ? void 0 : s.id, t]), loading: o.isLoading };
208
279
  }
209
- function Ye(e) {
210
- const t = f(), { data: n, isLoading: s } = q({
280
+ function st(e) {
281
+ const t = h(), { data: n, isLoading: s } = _({
211
282
  queryKey: ["nvr-chat-directory", e],
212
283
  queryFn: async () => (await t.request(
213
- p("/chat/directory", e ? { search: e } : void 0)
284
+ v("/chat/directory", e ? { search: e } : void 0)
214
285
  )).data ?? [],
215
286
  staleTime: 15e3
216
287
  });
217
288
  return { channels: n ?? [], loading: s };
218
289
  }
219
- function We() {
220
- const e = f(), t = _(), n = () => {
290
+ function rt() {
291
+ const e = h(), t = C(), n = () => {
221
292
  t.invalidateQueries({ queryKey: ["nvr-chat-rooms"] }), t.invalidateQueries({ queryKey: ["nvr-chat-directory"] });
222
293
  }, s = g({
223
- mutationFn: (u) => e.request(K(`/chat/rooms/${encodeURIComponent(u)}/join`)),
294
+ mutationFn: (l) => e.request(O(`/chat/rooms/${encodeURIComponent(l)}/join`)),
224
295
  onSuccess: n
225
296
  }), o = g({
226
- mutationFn: (u) => e.request(B(`/chat/rooms/${encodeURIComponent(u)}/join`)),
297
+ mutationFn: (l) => e.request(H(`/chat/rooms/${encodeURIComponent(l)}/join`)),
227
298
  onSuccess: n
228
299
  }), r = g({
229
- mutationFn: ({ room: u, muted: l }) => e.request(F(`/chat/rooms/${encodeURIComponent(u)}`, { muted: l })),
300
+ mutationFn: ({ room: l, muted: d }) => e.request(K(`/chat/rooms/${encodeURIComponent(l)}`, { muted: d })),
230
301
  onSuccess: n
231
302
  }), a = g({
232
- mutationFn: ({ room: u, mode: l }) => e.request(
233
- F(`/chat/rooms/${encodeURIComponent(u)}`, {
234
- notify_mode: l === "mentions" ? "mentions" : null
303
+ mutationFn: ({ room: l, mode: d }) => e.request(
304
+ K(`/chat/rooms/${encodeURIComponent(l)}`, {
305
+ notify_mode: d === "mentions" ? "mentions" : null
235
306
  })
236
307
  ),
237
308
  onSuccess: n
238
309
  }), i = g({
239
- mutationFn: ({ room: u, archived: l }) => e.request(F(`/chat/rooms/${encodeURIComponent(u)}`, { archived: l })),
310
+ mutationFn: ({ room: l, archived: d }) => e.request(K(`/chat/rooms/${encodeURIComponent(l)}`, { archived: d })),
240
311
  onSuccess: n
241
312
  }), c = g({
242
- mutationFn: ({ room: u, starred: l }) => e.request(F(`/chat/rooms/${encodeURIComponent(u)}`, { starred: l })),
313
+ mutationFn: ({ room: l, starred: d }) => e.request(K(`/chat/rooms/${encodeURIComponent(l)}`, { starred: d })),
243
314
  onSuccess: n
244
- }), d = g({
245
- mutationFn: (u) => e.request(F(`/chat/rooms/${encodeURIComponent(u)}`, { welcome_seen: !0 })),
315
+ }), u = g({
316
+ mutationFn: (l) => e.request(K(`/chat/rooms/${encodeURIComponent(l)}`, { welcome_seen: !0 })),
246
317
  onSuccess: n
247
318
  });
248
- return { join: s, leave: o, setMuted: r, setNotifyMode: a, setArchived: i, setStarred: c, dismissWelcome: d };
319
+ return { join: s, leave: o, setMuted: r, setNotifyMode: a, setArchived: i, setStarred: c, dismissWelcome: u };
249
320
  }
250
- function Ze(e) {
251
- const t = f(), { data: n, isLoading: s } = q({
321
+ function ot(e) {
322
+ const t = h(), { data: n, isLoading: s } = _({
252
323
  queryKey: ["nvr-chat-members", e],
253
324
  queryFn: async () => (await t.request(
254
- p(`/chat/channels/${e}/members`)
325
+ v(`/chat/channels/${e}/members`)
255
326
  )).data ?? [],
256
327
  enabled: e != null,
257
328
  staleTime: 1e4
258
329
  });
259
330
  return { members: n ?? [], loading: s };
260
331
  }
261
- const ge = 50;
262
- function Je(e, t) {
263
- const [n, s] = I(e);
264
- return S(() => {
332
+ const Se = 50;
333
+ function at(e, t) {
334
+ const [n, s] = E(e);
335
+ return w(() => {
265
336
  const o = setTimeout(() => s(e), t);
266
337
  return () => clearTimeout(o);
267
338
  }, [e, t]), n;
268
339
  }
269
- function pe(e) {
340
+ function we(e) {
270
341
  const t = String(e.id ?? e.user ?? ""), n = e.first_name ?? null, s = e.last_name ?? null, o = e.email ?? null;
271
342
  return {
272
343
  id: t,
@@ -278,24 +349,24 @@ function pe(e) {
278
349
  email: o
279
350
  };
280
351
  }
281
- function Xe(e, t, n, s) {
282
- var c, d, u;
283
- const o = f(), r = ee({
352
+ function it(e, t, n, s) {
353
+ var c, u, l;
354
+ const o = h(), r = te({
284
355
  queryKey: ["nvr-chat-members-page", e, t, n],
285
356
  initialPageParam: 0,
286
- queryFn: async ({ pageParam: l }) => {
287
- const h = new URLSearchParams({ limit: String(ge), offset: String(l) });
288
- return n.trim() && h.set("q", n.trim()), await o.request(
289
- p(`${t}?${h.toString()}`)
357
+ queryFn: async ({ pageParam: d }) => {
358
+ const f = new URLSearchParams({ limit: String(Se), offset: String(d) });
359
+ return n.trim() && f.set("q", n.trim()), await o.request(
360
+ v(`${t}?${f.toString()}`)
290
361
  );
291
362
  },
292
- getNextPageParam: (l, h) => l.has_more ? h.reduce((y, m) => {
293
- var b;
294
- return y + (((b = m.data) == null ? void 0 : b.length) ?? 0);
363
+ getNextPageParam: (d, f) => d.has_more ? f.reduce((p, m) => {
364
+ var y;
365
+ return p + (((y = m.data) == null ? void 0 : y.length) ?? 0);
295
366
  }, 0) : void 0,
296
367
  enabled: s && !!t,
297
368
  staleTime: 1e4
298
- }), a = (((c = r.data) == null ? void 0 : c.pages) ?? []).flatMap((l) => (l.data ?? []).map(pe)), i = ((u = (d = r.data) == null ? void 0 : d.pages[0]) == null ? void 0 : u.total) ?? a.length;
369
+ }), a = (((c = r.data) == null ? void 0 : c.pages) ?? []).flatMap((d) => (d.data ?? []).map(we)), i = ((l = (u = r.data) == null ? void 0 : u.pages[0]) == null ? void 0 : l.total) ?? a.length;
299
370
  return {
300
371
  members: a,
301
372
  total: i,
@@ -307,46 +378,46 @@ function Xe(e, t, n, s) {
307
378
  }
308
379
  };
309
380
  }
310
- function et(e) {
311
- const t = f(), n = _(), s = () => {
381
+ function ct(e) {
382
+ const t = h(), n = C(), s = () => {
312
383
  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"] });
313
384
  }, o = g({
314
- mutationFn: (i) => t.request(F(`/chat/channels/${e}`, i)),
385
+ mutationFn: (i) => t.request(K(`/chat/channels/${e}`, i)),
315
386
  onSuccess: s
316
387
  }), r = g({
317
- mutationFn: (i) => t.request(K(`/chat/channels/${e}/members`, { user_id: i })),
388
+ mutationFn: (i) => t.request(O(`/chat/channels/${e}/members`, { user_id: i })),
318
389
  onSuccess: s
319
390
  }), a = g({
320
- mutationFn: (i) => t.request(B(`/chat/channels/${e}/members/${i}`)),
391
+ mutationFn: (i) => t.request(H(`/chat/channels/${e}/members/${i}`)),
321
392
  onSuccess: s
322
393
  });
323
394
  return { update: o, addMember: r, removeMember: a };
324
395
  }
325
- function tt() {
326
- const e = f(), { data: t } = q({
396
+ function ut() {
397
+ const e = h(), { data: t } = _({
327
398
  queryKey: ["nvr-chat-roles"],
328
399
  queryFn: async () => (await e.request(
329
- p("/chat/roles")
400
+ v("/chat/roles")
330
401
  )).data ?? [],
331
402
  staleTime: 5 * 6e4
332
403
  });
333
404
  return t ?? [];
334
405
  }
335
- function nt(e, t) {
336
- const n = f(), { data: s, isLoading: o } = q({
406
+ function lt(e, t) {
407
+ const n = h(), { data: s, isLoading: o } = _({
337
408
  queryKey: ["nvr-chat-user-search", e],
338
409
  queryFn: async () => (await n.request(
339
- p("/users", { limit: 20, ...e.trim() ? { search: e.trim() } : {} })
410
+ v("/users", { limit: 20, ...e.trim() ? { search: e.trim() } : {} })
340
411
  )).data ?? [],
341
412
  enabled: t,
342
413
  staleTime: 3e4
343
414
  });
344
415
  return { users: s ?? [], loading: o };
345
416
  }
346
- function st() {
347
- const e = f(), t = _();
417
+ function dt() {
418
+ const e = h(), t = C();
348
419
  return g({
349
- mutationFn: (n) => e.request(K("/chat/channels", n)),
420
+ mutationFn: (n) => e.request(O("/chat/channels", n)),
350
421
  onSuccess: () => {
351
422
  t.invalidateQueries({ queryKey: ["nvr-chat-rooms"] }), t.invalidateQueries({ queryKey: ["nvr-chat-directory"] });
352
423
  }
@@ -359,8 +430,8 @@ function j(e) {
359
430
  return e.kind === "dm" || e.kind === "channel" && !!((t = e.channel) != null && t.is_direct);
360
431
  }
361
432
  const x = /* @__PURE__ */ new Map();
362
- function rt(e) {
363
- S(() => {
433
+ function mt(e) {
434
+ w(() => {
364
435
  if (e)
365
436
  return x.set(e, (x.get(e) ?? 0) + 1), () => {
366
437
  const t = (x.get(e) ?? 1) - 1;
@@ -368,20 +439,20 @@ function rt(e) {
368
439
  };
369
440
  }, [e]);
370
441
  }
371
- function ve() {
442
+ function Te() {
372
443
  return typeof document > "u" || document.visibilityState === "visible";
373
444
  }
374
- function E(e) {
375
- return x.has(e) && ve();
445
+ function Q(e) {
446
+ return x.has(e) && Te();
376
447
  }
377
- function qe() {
378
- const e = N().notification_sound;
448
+ function Me() {
449
+ const e = U().notification_sound;
379
450
  return typeof e == "string" ? e : "off";
380
451
  }
381
- function N() {
382
- const e = f(), { data: t } = q({
452
+ function U() {
453
+ const e = h(), { data: t } = _({
383
454
  queryKey: ["nvr-profile-prefs"],
384
- queryFn: () => e.request(p("/users/me")).then((n) => {
455
+ queryFn: () => e.request(v("/users/me")).then((n) => {
385
456
  var s;
386
457
  return ((s = n.data) == null ? void 0 : s.preferences) ?? {};
387
458
  }),
@@ -389,10 +460,10 @@ function N() {
389
460
  });
390
461
  return t ?? {};
391
462
  }
392
- function be() {
393
- const e = f(), t = _();
463
+ function Ke() {
464
+ const e = h(), t = C();
394
465
  return g({
395
- mutationFn: (n) => e.request(F("/users/me/preferences", n)),
466
+ mutationFn: (n) => e.request(K("/users/me/preferences", n)),
396
467
  onMutate: (n) => {
397
468
  const s = t.getQueryData(["nvr-profile-prefs"]);
398
469
  return t.setQueryData(["nvr-profile-prefs"], { ...s ?? {}, ...n }), { prev: s };
@@ -400,15 +471,15 @@ function be() {
400
471
  onError: (n, s, o) => {
401
472
  o != null && o.prev && t.setQueryData(["nvr-profile-prefs"], o.prev);
402
473
  },
403
- onSuccess: (n, s) => ie(Object.keys(s)),
474
+ onSuccess: (n, s) => ce(Object.keys(s)),
404
475
  onSettled: () => {
405
476
  t.invalidateQueries({ queryKey: ["nvr-profile-prefs"] }), t.invalidateQueries({ queryKey: ["presence-online"] });
406
477
  }
407
478
  });
408
479
  }
409
- function ot() {
410
- const e = N(), t = be(), n = Object.keys(e).length > 0;
411
- S(() => {
480
+ function ft() {
481
+ const e = U(), t = Ke(), n = Object.keys(e).length > 0;
482
+ w(() => {
412
483
  if (!n) return;
413
484
  let s = "";
414
485
  try {
@@ -426,51 +497,51 @@ function ot() {
426
497
  }
427
498
  }, [n, e.browser_timezone]);
428
499
  }
429
- function at(e, t) {
430
- const n = T(), s = qe(), o = N(), r = Q(o);
500
+ function ht(e, t) {
501
+ const n = T(), s = Me(), o = U(), r = L(o);
431
502
  r.current = o;
432
- const a = f(), i = _(), c = Q({
503
+ const a = h(), i = C(), c = L({
433
504
  client: a,
434
505
  qc: i,
435
506
  me: n.me,
436
- markRead: (d) => {
507
+ markRead: (u) => {
437
508
  }
438
509
  });
439
510
  c.current = {
440
511
  client: a,
441
512
  qc: i,
442
513
  me: n.me,
443
- markRead: (d) => {
444
- a.request(K(`/chat/rooms/${encodeURIComponent(d)}/read`)).then(() => i.invalidateQueries({ queryKey: ["nvr-chat-rooms"] })).catch(() => {
514
+ markRead: (u) => {
515
+ a.request(O(`/chat/rooms/${encodeURIComponent(u)}/read`)).then(() => i.invalidateQueries({ queryKey: ["nvr-chat-rooms"] })).catch(() => {
445
516
  });
446
517
  }
447
- }, ae(
448
- t ? t.filter((d) => j(d) && !d.muted && !E(d.room)).reduce((d, u) => d + u.unread, 0) : 0
449
- ), S(() => {
450
- const d = t ? t.filter((y) => j(y) && !E(y.room)).reduce((y, m) => y + m.unread, 0) : e, u = d > G, l = fe(r.current), h = se(r.current) || l;
451
- if (n.sound && u && !h && re(s), n.sound && u && l && he({ kind: "chat", title: "New message" }), t) {
452
- const y = D.size > 0;
518
+ }, ie(
519
+ t ? t.filter((u) => j(u) && !u.muted && !Q(u.room)).reduce((u, l) => u + l.unread, 0) : 0
520
+ ), w(() => {
521
+ const u = t ? t.filter((p) => j(p) && !Q(p.room)).reduce((p, m) => p + m.unread, 0) : e, l = u > G, d = he(r.current), f = re(r.current) || d;
522
+ if (n.sound && l && !f && oe(s), n.sound && l && d && ye({ kind: "chat", title: "New message" }), t) {
523
+ const p = D.size > 0;
453
524
  for (const m of t) {
454
- const b = D.get(m.room) ?? 0;
455
- if (y && !h && !m.muted && j(m) && m.unread > b && !E(m.room)) {
456
- const w = m.lastMessage;
457
- if (w) {
458
- const R = m.room;
459
- ce(
525
+ const y = D.get(m.room) ?? 0;
526
+ if (p && !f && !m.muted && j(m) && m.unread > y && !Q(m.room)) {
527
+ const q = m.lastMessage;
528
+ if (q) {
529
+ const S = m.room;
530
+ ue(
460
531
  {
461
- room: R,
532
+ room: S,
462
533
  label: m.label,
463
534
  kind: m.kind,
464
535
  mentioned: (m.mentions ?? 0) > 0
465
536
  },
466
- w,
537
+ q,
467
538
  {
468
539
  reply: (M) => {
469
- var C, $, A;
470
- const v = c.current;
471
- H(v.client, v.qc, ((C = v.me) == null ? void 0 : C.id) ?? null), V({
540
+ var R, I, P;
541
+ const b = c.current;
542
+ J(b.client, b.qc, ((R = b.me) == null ? void 0 : R.id) ?? null), Y({
472
543
  client_id: W(),
473
- room: R,
544
+ room: S,
474
545
  text: M,
475
546
  mentions: [],
476
547
  attachments: [],
@@ -478,63 +549,63 @@ function at(e, t) {
478
549
  quote_id: null,
479
550
  urgent: !1,
480
551
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
481
- sender: (($ = v.me) == null ? void 0 : $.id) ?? "",
482
- sender_name: ((A = v.me) == null ? void 0 : A.name) ?? null
483
- }), v.markRead(R);
552
+ sender: ((I = b.me) == null ? void 0 : I.id) ?? "",
553
+ sender_name: ((P = b.me) == null ? void 0 : P.name) ?? null
554
+ }), b.markRead(S);
484
555
  },
485
- markRead: () => c.current.markRead(R),
556
+ markRead: () => c.current.markRead(S),
486
557
  // Only when the host has somewhere to open it.
487
- ...Te() ? { open: () => X(R, m.label) } : {}
558
+ ...Ie() ? { open: () => ee(S, m.label) } : {}
488
559
  }
489
560
  );
490
561
  }
491
562
  }
492
- (m.unread === 0 || E(m.room)) && ue(m.room), D.set(m.room, m.unread);
563
+ (m.unread === 0 || Q(m.room)) && le(m.room), D.set(m.room, m.unread);
493
564
  }
494
565
  }
495
- G = d;
566
+ G = u;
496
567
  }, [e, n.sound, t, s]);
497
568
  }
498
- function it() {
499
- const e = f(), t = _();
569
+ function yt() {
570
+ const e = h(), t = C();
500
571
  return g({
501
- mutationFn: (n) => e.request(K(`/chat/rooms/${encodeURIComponent(n)}/read`)),
572
+ mutationFn: (n) => e.request(O(`/chat/rooms/${encodeURIComponent(n)}/read`)),
502
573
  onSuccess: () => void t.invalidateQueries({ queryKey: ["nvr-chat-rooms"] })
503
574
  });
504
575
  }
505
- const _e = ["nvr-chat-room-types"];
506
- function J(e) {
576
+ const Oe = ["nvr-chat-room-types"];
577
+ function X(e) {
507
578
  return {
508
- queryKey: _e,
579
+ queryKey: Oe,
509
580
  queryFn: async () => {
510
- const t = await e.request(p("/chat/room-types"));
581
+ const t = await e.request(v("/chat/room-types"));
511
582
  return ((t == null ? void 0 : t.data) ?? []).filter((n) => n.is_active);
512
583
  },
513
584
  staleTime: 5 * 6e4
514
585
  };
515
586
  }
516
- function ct(e) {
517
- const t = 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 } = q({ ...J(n), enabled: a }), c = a ? i == null ? void 0 : i.find((l) => l.is_active && l.prefix === o) : void 0, { data: d } = q({
587
+ function pt(e) {
588
+ const t = T(), n = h(), 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 } = _({ ...X(n), enabled: a }), c = a ? i == null ? void 0 : i.find((d) => d.is_active && d.prefix === o) : void 0, { data: u } = _({
518
589
  queryKey: ["nvr-chat-entity-record", c == null ? void 0 : c.collection, c == null ? void 0 : c.match_field, r],
519
590
  queryFn: async () => {
520
- var h, y;
521
- return c.match_field === "id" ? r : ((y = (h = (await n.request(
522
- p(`/items/${c.collection}`, {
591
+ var f, p;
592
+ return c.match_field === "id" ? r : ((p = (f = (await n.request(
593
+ v(`/items/${c.collection}`, {
523
594
  limit: 1,
524
595
  fields: "id",
525
596
  filter: JSON.stringify({ [c.match_field]: { _eq: r } })
526
597
  })
527
- )).data) == null ? void 0 : h[0]) == null ? void 0 : y.id) ?? null;
598
+ )).data) == null ? void 0 : f[0]) == null ? void 0 : p.id) ?? null;
528
599
  },
529
600
  enabled: !!c && !!r,
530
601
  staleTime: 5 * 6e4
531
602
  });
532
- return !c || d == null ? null : (t.recordUrl ?? ((l, h) => `/collections/${l}/${h}`))(c.collection, d);
603
+ return !c || u == null ? null : (t.recordUrl ?? ((d, f) => `/collections/${d}/${f}`))(c.collection, u);
533
604
  }
534
- const Ce = /@\[([^\]]+)\](?:\([^)]*\))?/g;
535
- function ut(e, t) {
605
+ const Fe = /@\[([^\]]+)\](?:\([^)]*\))?/g;
606
+ function gt(e, t) {
536
607
  const n = new RegExp(t, "gi"), s = [];
537
- for (const a of e.matchAll(Ce))
608
+ for (const a of e.matchAll(Fe))
538
609
  s.push({
539
610
  start: a.index,
540
611
  end: a.index + a[0].length,
@@ -553,51 +624,51 @@ function ut(e, t) {
553
624
  a.start > r && o.push({ text: e.slice(r, a.start) }), o.push(a.token), r = a.end;
554
625
  return r < e.length && o.push({ text: e.slice(r) }), o;
555
626
  }
556
- function lt(e, t) {
627
+ function vt(e, t) {
557
628
  const s = e.slice(0, t).match(/@([^@\n\r]*)$/);
558
629
  return s ? s[1] : null;
559
630
  }
560
- const Re = 3e3;
561
- function dt(e) {
562
- const t = T(), n = oe(), s = t.me, o = Q(!1), r = Q(0), a = Q(null), [i, c] = I(() => /* @__PURE__ */ new Map()), [, d] = I(0), u = P(
563
- (m, b) => n == null ? void 0 : n.emit("chat:typing", { room: m, state: b }),
631
+ const ke = 3e3;
632
+ function qt(e) {
633
+ const t = T(), n = ae(), s = t.me, o = L(!1), r = L(0), a = L(null), [i, c] = E(() => /* @__PURE__ */ new Map()), [, u] = E(0), l = $(
634
+ (m, y) => n == null ? void 0 : n.emit("chat:typing", { room: m, state: y }),
564
635
  [n]
565
- ), l = P(() => {
566
- a.current && clearTimeout(a.current), a.current = null, o.current && e && u(e, "stop"), o.current = !1, r.current = 0;
567
- }, [e, u]), h = P(() => {
636
+ ), d = $(() => {
637
+ a.current && clearTimeout(a.current), a.current = null, o.current && e && l(e, "stop"), o.current = !1, r.current = 0;
638
+ }, [e, l]), f = $(() => {
568
639
  if (!s || !e || !n) return;
569
640
  const m = Date.now();
570
- (!o.current || m - r.current >= le) && (o.current = !0, r.current = m, u(e, "start")), a.current && clearTimeout(a.current), a.current = setTimeout(l, Re);
571
- }, [s, e, n, u, l]);
572
- S(() => l, [l]), S(() => c(/* @__PURE__ */ new Map()), [e]), S(() => {
641
+ (!o.current || m - r.current >= de) && (o.current = !0, r.current = m, l(e, "start")), a.current && clearTimeout(a.current), a.current = setTimeout(d, ke);
642
+ }, [s, e, n, l, d]);
643
+ w(() => d, [d]), w(() => c(/* @__PURE__ */ new Map()), [e]), w(() => {
573
644
  if (!(!n || !e))
574
645
  return n.on("chat:typing", (m) => {
575
- c((b) => de(b, m, e, s == null ? void 0 : s.id) ?? b);
646
+ c((y) => me(y, m, e, s == null ? void 0 : s.id) ?? y);
576
647
  });
577
- }, [n, e, s == null ? void 0 : s.id]), S(() => {
648
+ }, [n, e, s == null ? void 0 : s.id]), w(() => {
578
649
  if (i.size === 0) return;
579
650
  const m = setInterval(() => {
580
- const b = Date.now();
581
- c((w) => {
582
- let R = !1;
583
- const M = new Map(w);
584
- for (const [v, C] of M)
585
- C.until <= b && (M.delete(v), R = !0);
586
- return R ? M : w;
587
- }), d((w) => w + 1);
651
+ const y = Date.now();
652
+ c((q) => {
653
+ let S = !1;
654
+ const M = new Map(q);
655
+ for (const [b, R] of M)
656
+ R.until <= y && (M.delete(b), S = !0);
657
+ return S ? M : q;
658
+ }), u((q) => q + 1);
588
659
  }, 1e3);
589
660
  return () => clearInterval(m);
590
661
  }, [i.size]);
591
- const y = me(i);
592
- return { onType: h, clearTyping: l, typingText: y };
662
+ const p = fe(i);
663
+ return { onType: f, clearTyping: d, typingText: p };
593
664
  }
594
- function mt(e) {
595
- const t = T(), n = f(), s = t.me, o = e && s ? Y(e, s.id) : null, { data: r } = q({
665
+ function bt(e) {
666
+ const t = T(), n = h(), s = t.me, o = e && s ? V(e, s.id) : null, { data: r } = _({
596
667
  queryKey: ["nvr-chat-peer-read", e],
597
668
  queryFn: async () => {
598
669
  var i;
599
670
  return ((i = (await n.request(
600
- p(
671
+ v(
601
672
  `/chat/rooms/${encodeURIComponent(e)}/peer-read`
602
673
  )
603
674
  )).data) == null ? void 0 : i.last_read_at) ?? null;
@@ -606,40 +677,40 @@ function mt(e) {
606
677
  refetchInterval: 3e4,
607
678
  staleTime: 5e3
608
679
  });
609
- return U([["nvr-chat-peer-read"]], e ? [e] : []), r ?? null;
680
+ return N([["nvr-chat-peer-read"]], e ? [e] : []), r ?? null;
610
681
  }
611
- function ft(e) {
612
- const t = f(), n = _();
682
+ function _t(e) {
683
+ const t = h(), n = C();
613
684
  return g({
614
- mutationFn: ({ messageId: s, emoji: o }) => t.request(K(`/chat/messages/${s}/reactions`, { emoji: o })),
685
+ mutationFn: ({ messageId: s, emoji: o }) => t.request(O(`/chat/messages/${s}/reactions`, { emoji: o })),
615
686
  onSuccess: () => void n.invalidateQueries({ queryKey: ["nvr-chat", e] })
616
687
  });
617
688
  }
618
- function ht(e) {
619
- const t = f(), n = _();
689
+ function Ct(e) {
690
+ const t = h(), n = C();
620
691
  return g({
621
- mutationFn: ({ messageId: s, text: o }) => t.request(F(`/chat/messages/${s}`, { message: o })),
692
+ mutationFn: ({ messageId: s, text: o }) => t.request(K(`/chat/messages/${s}`, { message: o })),
622
693
  onSuccess: () => void n.invalidateQueries({ queryKey: ["nvr-chat", e] })
623
694
  });
624
695
  }
625
- function yt(e) {
626
- const t = f(), n = _();
696
+ function Rt(e) {
697
+ const t = h(), n = C();
627
698
  return g({
628
- mutationFn: (s) => t.request(B(`/chat/messages/${s}`)),
699
+ mutationFn: (s) => t.request(H(`/chat/messages/${s}`)),
629
700
  onSuccess: () => {
630
701
  n.invalidateQueries({ queryKey: ["nvr-chat", e] }), n.invalidateQueries({ queryKey: ["nvr-chat-rooms"] });
631
702
  }
632
703
  });
633
704
  }
634
- function gt(e, t = {}) {
635
- const n = f(), s = { q: e };
705
+ function St(e, t = {}) {
706
+ const n = h(), s = { q: e };
636
707
  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");
637
- const o = Object.keys(s).length > 1, { data: r, isLoading: a } = q({
708
+ const o = Object.keys(s).length > 1, { data: r, isLoading: a } = _({
638
709
  queryKey: ["nvr-chat-search", s],
639
710
  queryFn: async () => {
640
711
  var c;
641
712
  const i = await n.request(
642
- p("/chat/search", s)
713
+ v("/chat/search", s)
643
714
  );
644
715
  return { hits: i.data ?? [], meaning: ((c = i.meta) == null ? void 0 : c.meaning) ?? null };
645
716
  },
@@ -648,43 +719,43 @@ function gt(e, t = {}) {
648
719
  });
649
720
  return { hits: (r == null ? void 0 : r.hits) ?? [], meaning: (r == null ? void 0 : r.meaning) ?? null, loading: a };
650
721
  }
651
- function pt() {
652
- const e = f(), t = _();
722
+ function wt() {
723
+ const e = h(), t = C();
653
724
  return g({
654
- mutationFn: async (n) => (await e.request(K("/chat/group-dm", n))).data,
725
+ mutationFn: async (n) => (await e.request(O("/chat/group-dm", n))).data,
655
726
  onSuccess: () => void t.invalidateQueries({ queryKey: ["nvr-chat-rooms"] })
656
727
  });
657
728
  }
658
- function we() {
659
- const e = f(), { data: t } = q({
729
+ function xe() {
730
+ const e = h(), { data: t } = _({
660
731
  queryKey: ["nvr-chat-config"],
661
- queryFn: async () => (await e.request(p("/chat/config"))).data ?? { bot_name: null, bot_user_id: null },
732
+ queryFn: async () => (await e.request(v("/chat/config"))).data ?? { bot_name: null, bot_user_id: null },
662
733
  staleTime: 5 * 6e4
663
734
  });
664
735
  return t ?? { bot_name: null, bot_user_id: null };
665
736
  }
666
- function vt() {
667
- return we().bot_name;
737
+ function Tt() {
738
+ return xe().bot_name;
668
739
  }
669
- function qt(e) {
670
- const t = f(), { data: n } = q({
740
+ function Mt(e) {
741
+ const t = h(), { data: n } = _({
671
742
  queryKey: ["nvr-chat-pins", e],
672
743
  queryFn: async () => (await t.request(
673
- p(`/chat/rooms/${encodeURIComponent(e)}/pins`)
744
+ v(`/chat/rooms/${encodeURIComponent(e)}/pins`)
674
745
  )).data ?? [],
675
746
  enabled: !!e,
676
747
  staleTime: 15e3
677
748
  });
678
- return U([["nvr-chat-pins"]], e ? [e] : []), n ?? [];
749
+ return N([["nvr-chat-pins"]], e ? [e] : []), n ?? [];
679
750
  }
680
- function bt(e) {
681
- const t = f(), n = _();
751
+ function Kt(e) {
752
+ const t = h(), n = C();
682
753
  return g({
683
- mutationFn: (s) => t.request(K(`/chat/messages/${s}/pin`)),
754
+ mutationFn: (s) => t.request(O(`/chat/messages/${s}/pin`)),
684
755
  onSuccess: () => void n.invalidateQueries({ queryKey: ["nvr-chat-pins", e] })
685
756
  });
686
757
  }
687
- const L = [
758
+ const A = [
688
759
  "#7dd3fc",
689
760
  "#86efac",
690
761
  "#fcd34d",
@@ -694,130 +765,135 @@ const L = [
694
765
  "#99f6e4",
695
766
  "#00ceff"
696
767
  ];
697
- function _t(e) {
698
- return L[Se(e)];
768
+ function Ot(e) {
769
+ return A[Ee(e)];
699
770
  }
700
- function Se(e) {
771
+ function Ee(e) {
701
772
  let t = 0;
702
773
  for (const n of e) t = t * 31 + n.charCodeAt(0) | 0;
703
- return Math.abs(t) % L.length;
774
+ return Math.abs(t) % A.length;
704
775
  }
705
- function Ct(e) {
706
- return Number.isInteger(e) && e >= 0 && e < L.length ? L[e] : null;
776
+ function Ft(e) {
777
+ return Number.isInteger(e) && e >= 0 && e < A.length ? A[e] : null;
707
778
  }
708
- function Rt(e) {
779
+ function kt(e) {
709
780
  return [...e].sort((t, n) => {
710
781
  const s = (t.display_name ?? "").trim(), o = (n.display_name ?? "").trim();
711
782
  return !s != !o ? s ? -1 : 1 : s.localeCompare(o, void 0, { sensitivity: "base" }) || String(t.user_id).localeCompare(String(n.user_id));
712
783
  });
713
784
  }
714
- function wt(e) {
785
+ function xt(e) {
715
786
  var n, s;
716
787
  if (!e) return "?";
717
788
  const t = e.trim().split(/\s+/);
718
789
  return ((((n = t[0]) == null ? void 0 : n[0]) ?? "") + (((s = t[1]) == null ? void 0 : s[0]) ?? "")).toUpperCase() || "?";
719
790
  }
720
- let O = null;
721
- function St(e) {
722
- return O = e, () => {
723
- O === e && (O = null);
791
+ let F = null;
792
+ function Et(e) {
793
+ return F = e, () => {
794
+ F === e && (F = null);
724
795
  };
725
796
  }
726
- function Tt() {
727
- return O !== null;
797
+ function It() {
798
+ return F !== null;
728
799
  }
729
- function Mt(e, t) {
730
- O == null || O(e, t);
800
+ function $t(e, t) {
801
+ F == null || F(e, t);
731
802
  }
732
803
  let k = null;
733
- function Ft(e) {
804
+ function Lt(e) {
734
805
  return k = e, () => {
735
806
  k === e && (k = null);
736
807
  };
737
808
  }
738
- function Te() {
809
+ function Ie() {
739
810
  return k !== null;
740
811
  }
741
- function X(e, t) {
812
+ function ee(e, t) {
742
813
  k == null || k(e, t);
743
814
  }
744
- function Kt(e = !0) {
745
- const t = f(), { data: n } = q({ ...J(t), enabled: e });
815
+ function Pt(e = !0) {
816
+ const t = h(), { data: n } = _({ ...X(t), enabled: e });
746
817
  return n;
747
818
  }
748
- async function Ot(e, t, n) {
819
+ async function Qt(e, t, n) {
749
820
  var r;
750
821
  const s = await e.request(
751
- p("/chat/record-room", { collection: t, item: n })
822
+ v("/chat/record-room", { collection: t, item: n })
752
823
  );
753
824
  if (!((r = s.data) != null && r.room)) return !1;
754
825
  const o = s.data.room.slice(s.data.room.indexOf(":") + 1);
755
- return X(s.data.room, o), !0;
826
+ return ee(s.data.room, o), !0;
756
827
  }
757
828
  export {
758
- De as CHAT_DEFAULTS,
759
- _e as CHAT_ROOM_TYPES_KEY,
760
- ye as ChatConfigContext,
761
- Ne as GENERAL_CHANNEL_ID,
762
- ge as MEMBER_PAGE_SIZE,
763
- Le as REACTION_EMOJI,
764
- Te as canOpenChatRoom,
765
- Tt as canOpenDm,
766
- _t as chatAvatarColor,
767
- Ct as chatAvatarColorAt,
768
- Se as chatAvatarColorIndex,
769
- wt as chatInitials,
770
- J as chatRoomTypesQuery,
771
- It as discardOutbox,
772
- Ot as discussRecord,
773
- Y as dmPeer,
774
- je as dmRoom,
775
- $t as editOutbox,
776
- lt as getMentionQuery,
777
- Pt as holdOutbox,
778
- Qt as nudgeChatOutbox,
779
- X as openChatRoom,
780
- Mt as openDmWith,
781
- St as registerDmOpener,
782
- Ft as registerRoomOpener,
783
- Ut as retryOutbox,
784
- Rt as sortOnlineUsers,
785
- ut as splitMessageTokens,
786
- pe as toPagedMember,
787
- Ve as useArchivedRooms,
788
- et as useChannelAdmin,
789
- Ye as useChannelDirectory,
790
- Ze as useChannelMembers,
791
- we as useChatBotInfo,
792
- vt as useChatBotName,
829
+ Ve as CHAT_DEFAULTS,
830
+ be as CHAT_LIST_LISTEN_MAX,
831
+ ve as CHAT_REFETCH_DEBOUNCE_MS,
832
+ Oe as CHAT_ROOM_TYPES_KEY,
833
+ pe as ChatConfigContext,
834
+ Ye as GENERAL_CHANNEL_ID,
835
+ Se as MEMBER_PAGE_SIZE,
836
+ Je as REACTION_EMOJI,
837
+ Ie as canOpenChatRoom,
838
+ It as canOpenDm,
839
+ Ot as chatAvatarColor,
840
+ Ft as chatAvatarColorAt,
841
+ Ee as chatAvatarColorIndex,
842
+ xt as chatInitials,
843
+ qe as chatInvalidationKeys,
844
+ _e as chatListListenRooms,
845
+ X as chatRoomTypesQuery,
846
+ Ut as discardOutbox,
847
+ Qt as discussRecord,
848
+ V as dmPeer,
849
+ We as dmRoom,
850
+ Dt as editOutbox,
851
+ vt as getMentionQuery,
852
+ jt as holdOutbox,
853
+ zt as nudgeChatOutbox,
854
+ ee as openChatRoom,
855
+ $t as openDmWith,
856
+ Ce as patchRoomsForMessage,
857
+ Et as registerDmOpener,
858
+ Lt as registerRoomOpener,
859
+ Ht as retryOutbox,
860
+ kt as sortOnlineUsers,
861
+ gt as splitMessageTokens,
862
+ we as toPagedMember,
863
+ nt as useArchivedRooms,
864
+ ct as useChannelAdmin,
865
+ st as useChannelDirectory,
866
+ ot as useChannelMembers,
867
+ xe as useChatBotInfo,
868
+ Tt as useChatBotName,
793
869
  T as useChatConfig,
794
- ze as useChatMessages,
795
- tt as useChatRoles,
796
- He as useChatRooms,
797
- gt as useChatSearch,
798
- Be as useChatThread,
799
- st as useCreateChannel,
800
- pt as useCreateGroupDm,
801
- Je as useDebouncedMemberQuery,
802
- yt as useDeleteMessage,
803
- ht as useEditMessage,
804
- ct as useEntityRoomLink,
805
- it as useMarkRoomRead,
806
- N as useMyPreferences,
807
- qe as useNotificationSoundPreference,
808
- rt as useOpenRoomRegistration,
809
- At as useOutbox,
810
- Xe as usePagedMembers,
811
- mt as usePeerReadAt,
812
- ot as useRecordBrowserTimezone,
813
- Kt as useRecordRoomTypes,
814
- We as useRoomMembership,
815
- qt as useRoomPins,
816
- Ge as useSendChatMessage,
817
- be as useSetMyPreferences,
818
- bt as useTogglePin,
819
- ft as useToggleReaction,
820
- dt as useTypingIndicator,
821
- at as useUnreadChirp,
822
- nt as useUserSearch
870
+ Ze as useChatMessages,
871
+ ut as useChatRoles,
872
+ tt as useChatRooms,
873
+ St as useChatSearch,
874
+ Xe as useChatThread,
875
+ dt as useCreateChannel,
876
+ wt as useCreateGroupDm,
877
+ at as useDebouncedMemberQuery,
878
+ Rt as useDeleteMessage,
879
+ Ct as useEditMessage,
880
+ pt as useEntityRoomLink,
881
+ yt as useMarkRoomRead,
882
+ U as useMyPreferences,
883
+ Me as useNotificationSoundPreference,
884
+ mt as useOpenRoomRegistration,
885
+ Bt as useOutbox,
886
+ it as usePagedMembers,
887
+ bt as usePeerReadAt,
888
+ ft as useRecordBrowserTimezone,
889
+ Pt as useRecordRoomTypes,
890
+ rt as useRoomMembership,
891
+ Mt as useRoomPins,
892
+ et as useSendChatMessage,
893
+ Ke as useSetMyPreferences,
894
+ Kt as useTogglePin,
895
+ _t as useToggleReaction,
896
+ qt as useTypingIndicator,
897
+ ht as useUnreadChirp,
898
+ lt as useUserSearch
823
899
  };