@nivaro/react 0.3.127 → 0.3.129

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