@nivaro/react 0.3.136 → 0.3.138
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.
- package/dist/full.css +1 -1
- package/dist/hooks/useSessionRecorder.js +1 -1
- package/dist/index.d.ts +95 -4
- package/dist/index.js +748 -743
- package/dist/shared/components/CollectionBrowserView.js +392 -389
- package/dist/shared/components/DelegateCoverLine.js +80 -87
- package/dist/shared/components/ItemEditForm.js +589 -588
- package/dist/shared/components/MyWorkView.js +284 -286
- package/dist/shared/components/NotificationBell.js +251 -205
- package/dist/shared/components/ai/AiAnalyticsView.js +878 -417
- package/dist/shared/components/ai/AiPlanCard.js +164 -122
- package/dist/shared/components/ai/AiPlanUndo.js +291 -0
- package/dist/shared/components/ai/call-log/CallDrawer.js +357 -0
- package/dist/shared/components/ai/call-log/RawJson.js +126 -0
- package/dist/shared/components/ai/call-log/ThreadView.js +223 -0
- package/dist/shared/components/ai/call-log/TranscriptView.js +227 -0
- package/dist/shared/components/ai/call-log/controls.js +364 -0
- package/dist/shared/components/ai/call-log/format.js +46 -0
- package/dist/shared/components/ai/call-log/url.js +105 -0
- package/dist/shared/components/chat/ChatPanel.js +86 -86
- package/dist/shared/components/chat/chat-core.js +422 -346
- package/dist/shared/components/integrations/IntegrationObligationsView.js +98 -98
- package/dist/shared/components/integrations/RecordIntegrationPreview.js +102 -93
- package/dist/shared/components/integrations/console/api.js +11 -1
- package/dist/shared/components/item-edit/HeaderRollupExplainer.js +5 -1
- package/dist/shared/components/item-edit/RecordLiveSync.js +241 -229
- package/dist/shared/components/item-edit/RecordRecapChanges.js +166 -0
- package/dist/shared/components/item-edit/RecordRecapStrip.js +254 -84
- package/dist/shared/components/item-edit/live-related.js +34 -18
- package/dist/shared/components/panels/RevisionsPanel.js +735 -683
- package/dist/shared/components/queue/QueueWorklist.js +323 -316
- package/dist/shared/components/support/SupportRequestDialog.js +198 -181
- package/dist/shared/components/trackers/use-tracker-link.js +74 -65
- package/dist/shared/lib/config-update-refresh.js +34 -0
- package/dist/shared/lib/config-watch.js +17 -17
- package/dist/shared/lib/gap-refresh.js +49 -0
- package/dist/shared/lib/integration-dots.js +8 -8
- package/dist/shared/lib/live-ops.js +26 -23
- package/dist/shared/lib/live-pickers.js +1 -1
- package/dist/shared/lib/live-queries.js +223 -195
- package/dist/shared/lib/live.js +56 -51
- package/dist/shared/lib/obligation-banner.js +11 -10
- package/dist/shared/lib/obligation-filters.js +22 -18
- package/dist/shared/lib/obligation-reason-text.js +18 -8
- package/dist/shared/lib/presence-hooks.js +133 -132
- package/dist/shared/lib/reconnect-resync.js +90 -0
- package/dist/shared/lib/record-room-holds.js +43 -0
- package/dist/shared/lib/socket-realtime.js +116 -105
- package/dist/shared/lib/user-sync.js +1 -6
- package/package.json +1 -1
|
@@ -1,107 +1,136 @@
|
|
|
1
|
-
import { useQueryClient as
|
|
2
|
-
import { useContext as
|
|
3
|
-
import { useNivaroClient as
|
|
4
|
-
import { get as
|
|
5
|
-
import { isDndActive as
|
|
6
|
-
import { playNotificationSound as
|
|
7
|
-
import { useOptionalRealtime as
|
|
8
|
-
import { useTabAttention as
|
|
9
|
-
import { announceLocalPrefs as
|
|
10
|
-
import { showChatMessageCard as
|
|
11
|
-
import { bindChatOutbox as
|
|
12
|
-
import { discardOutbox as
|
|
13
|
-
import { TYPING_REPEAT_MS as
|
|
14
|
-
import { huddleHolds as
|
|
15
|
-
const
|
|
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 =
|
|
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
|
|
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
|
|
27
|
+
function We(e, t) {
|
|
28
28
|
return `dm:${[e.toUpperCase(), t.toUpperCase()].sort().join(":")}`;
|
|
29
29
|
}
|
|
30
|
-
function
|
|
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
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
-
|
|
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
|
|
46
|
-
var
|
|
47
|
-
const n = T(), s =
|
|
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
|
|
51
|
-
return t && "around" in t && (
|
|
52
|
-
|
|
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
|
-
|
|
60
|
-
const [i, c] =
|
|
61
|
-
|
|
62
|
-
c([]),
|
|
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
|
|
65
|
-
if (i.length === 0) return
|
|
66
|
-
const
|
|
67
|
-
return [...i.filter((
|
|
68
|
-
}, [i,
|
|
69
|
-
var
|
|
70
|
-
if (!e ||
|
|
71
|
-
const
|
|
72
|
-
if (
|
|
73
|
-
|
|
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
|
|
76
|
-
|
|
104
|
+
const I = await s.request(
|
|
105
|
+
v("/chat/messages", { room: e, limit: 60, before: b.id })
|
|
77
106
|
);
|
|
78
|
-
c((
|
|
107
|
+
c((P) => [...I.data ?? [], ...P]), l(!!((R = I.meta) != null && R.has_older));
|
|
79
108
|
} finally {
|
|
80
|
-
|
|
109
|
+
f(!1);
|
|
81
110
|
}
|
|
82
111
|
}
|
|
83
|
-
}, [e, m, s,
|
|
112
|
+
}, [e, m, s, d]);
|
|
84
113
|
return {
|
|
85
114
|
messages: m,
|
|
86
115
|
loading: a,
|
|
87
|
-
hasOlder:
|
|
88
|
-
hasNewer: !!((
|
|
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:
|
|
91
|
-
loadingOlder:
|
|
119
|
+
loadOlder: y,
|
|
120
|
+
loadingOlder: d
|
|
92
121
|
};
|
|
93
122
|
}
|
|
94
|
-
function
|
|
95
|
-
const n = T(), s =
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
141
|
+
function et(e) {
|
|
113
142
|
var r, a, i;
|
|
114
|
-
const t =
|
|
115
|
-
return
|
|
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
|
|
118
|
-
const
|
|
119
|
-
|
|
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:
|
|
123
|
-
mentions:
|
|
124
|
-
attachments:
|
|
125
|
-
parent_id:
|
|
126
|
-
quote_id:
|
|
127
|
-
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: ((
|
|
130
|
-
sender_name: ((
|
|
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,
|
|
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 ?? (((
|
|
152
|
-
) : r.label ?? ((
|
|
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
|
|
176
|
-
const e = T(), t =
|
|
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(
|
|
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
|
-
|
|
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 =
|
|
188
|
-
var
|
|
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
|
|
192
|
-
return i + (
|
|
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
|
-
|
|
199
|
-
|
|
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
|
-
|
|
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
|
|
210
|
-
const t =
|
|
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
|
-
|
|
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
|
|
220
|
-
const e =
|
|
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: (
|
|
294
|
+
mutationFn: (l) => e.request(O(`/chat/rooms/${encodeURIComponent(l)}/join`)),
|
|
224
295
|
onSuccess: n
|
|
225
296
|
}), o = g({
|
|
226
|
-
mutationFn: (
|
|
297
|
+
mutationFn: (l) => e.request(H(`/chat/rooms/${encodeURIComponent(l)}/join`)),
|
|
227
298
|
onSuccess: n
|
|
228
299
|
}), r = g({
|
|
229
|
-
mutationFn: ({ room:
|
|
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:
|
|
233
|
-
|
|
234
|
-
notify_mode:
|
|
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:
|
|
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:
|
|
313
|
+
mutationFn: ({ room: l, starred: d }) => e.request(K(`/chat/rooms/${encodeURIComponent(l)}`, { starred: d })),
|
|
243
314
|
onSuccess: n
|
|
244
|
-
}),
|
|
245
|
-
mutationFn: (
|
|
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:
|
|
319
|
+
return { join: s, leave: o, setMuted: r, setNotifyMode: a, setArchived: i, setStarred: c, dismissWelcome: u };
|
|
249
320
|
}
|
|
250
|
-
function
|
|
251
|
-
const t =
|
|
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
|
-
|
|
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
|
|
262
|
-
function
|
|
263
|
-
const [n, s] =
|
|
264
|
-
return
|
|
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
|
|
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
|
|
282
|
-
var c,
|
|
283
|
-
const o =
|
|
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:
|
|
287
|
-
const
|
|
288
|
-
return n.trim() &&
|
|
289
|
-
|
|
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: (
|
|
293
|
-
var
|
|
294
|
-
return
|
|
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((
|
|
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
|
|
311
|
-
const t =
|
|
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(
|
|
385
|
+
mutationFn: (i) => t.request(K(`/chat/channels/${e}`, i)),
|
|
315
386
|
onSuccess: s
|
|
316
387
|
}), r = g({
|
|
317
|
-
mutationFn: (i) => t.request(
|
|
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(
|
|
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
|
|
326
|
-
const e =
|
|
396
|
+
function ut() {
|
|
397
|
+
const e = h(), { data: t } = _({
|
|
327
398
|
queryKey: ["nvr-chat-roles"],
|
|
328
399
|
queryFn: async () => (await e.request(
|
|
329
|
-
|
|
400
|
+
v("/chat/roles")
|
|
330
401
|
)).data ?? [],
|
|
331
402
|
staleTime: 5 * 6e4
|
|
332
403
|
});
|
|
333
404
|
return t ?? [];
|
|
334
405
|
}
|
|
335
|
-
function
|
|
336
|
-
const n =
|
|
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
|
-
|
|
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
|
|
347
|
-
const e =
|
|
417
|
+
function dt() {
|
|
418
|
+
const e = h(), t = C();
|
|
348
419
|
return g({
|
|
349
|
-
mutationFn: (n) => e.request(
|
|
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
|
|
363
|
-
|
|
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
|
|
442
|
+
function Te() {
|
|
372
443
|
return typeof document > "u" || document.visibilityState === "visible";
|
|
373
444
|
}
|
|
374
|
-
function
|
|
375
|
-
return x.has(e) &&
|
|
445
|
+
function Q(e) {
|
|
446
|
+
return x.has(e) && Te();
|
|
376
447
|
}
|
|
377
|
-
function
|
|
378
|
-
const e =
|
|
448
|
+
function Me() {
|
|
449
|
+
const e = U().notification_sound;
|
|
379
450
|
return typeof e == "string" ? e : "off";
|
|
380
451
|
}
|
|
381
|
-
function
|
|
382
|
-
const e =
|
|
452
|
+
function U() {
|
|
453
|
+
const e = h(), { data: t } = _({
|
|
383
454
|
queryKey: ["nvr-profile-prefs"],
|
|
384
|
-
queryFn: () => e.request(
|
|
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
|
|
393
|
-
const e =
|
|
463
|
+
function Ke() {
|
|
464
|
+
const e = h(), t = C();
|
|
394
465
|
return g({
|
|
395
|
-
mutationFn: (n) => e.request(
|
|
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) =>
|
|
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
|
|
410
|
-
const e =
|
|
411
|
-
|
|
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
|
|
430
|
-
const n = T(), s =
|
|
500
|
+
function ht(e, t) {
|
|
501
|
+
const n = T(), s = Me(), o = U(), r = L(o);
|
|
431
502
|
r.current = o;
|
|
432
|
-
const a =
|
|
503
|
+
const a = h(), i = C(), c = L({
|
|
433
504
|
client: a,
|
|
434
505
|
qc: i,
|
|
435
506
|
me: n.me,
|
|
436
|
-
markRead: (
|
|
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: (
|
|
444
|
-
a.request(
|
|
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
|
-
},
|
|
448
|
-
t ? t.filter((
|
|
449
|
-
),
|
|
450
|
-
const
|
|
451
|
-
if (n.sound &&
|
|
452
|
-
const
|
|
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
|
|
455
|
-
if (
|
|
456
|
-
const
|
|
457
|
-
if (
|
|
458
|
-
const
|
|
459
|
-
|
|
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:
|
|
532
|
+
room: S,
|
|
462
533
|
label: m.label,
|
|
463
534
|
kind: m.kind,
|
|
464
535
|
mentioned: (m.mentions ?? 0) > 0
|
|
465
536
|
},
|
|
466
|
-
|
|
537
|
+
q,
|
|
467
538
|
{
|
|
468
539
|
reply: (M) => {
|
|
469
|
-
var
|
|
470
|
-
const
|
|
471
|
-
|
|
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:
|
|
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: ((
|
|
482
|
-
sender_name: ((
|
|
483
|
-
}),
|
|
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(
|
|
556
|
+
markRead: () => c.current.markRead(S),
|
|
486
557
|
// Only when the host has somewhere to open it.
|
|
487
|
-
...
|
|
558
|
+
...Ie() ? { open: () => ee(S, m.label) } : {}
|
|
488
559
|
}
|
|
489
560
|
);
|
|
490
561
|
}
|
|
491
562
|
}
|
|
492
|
-
(m.unread === 0 ||
|
|
563
|
+
(m.unread === 0 || Q(m.room)) && le(m.room), D.set(m.room, m.unread);
|
|
493
564
|
}
|
|
494
565
|
}
|
|
495
|
-
G =
|
|
566
|
+
G = u;
|
|
496
567
|
}, [e, n.sound, t, s]);
|
|
497
568
|
}
|
|
498
|
-
function
|
|
499
|
-
const e =
|
|
569
|
+
function yt() {
|
|
570
|
+
const e = h(), t = C();
|
|
500
571
|
return g({
|
|
501
|
-
mutationFn: (n) => e.request(
|
|
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
|
|
506
|
-
function
|
|
576
|
+
const Oe = ["nvr-chat-room-types"];
|
|
577
|
+
function X(e) {
|
|
507
578
|
return {
|
|
508
|
-
queryKey:
|
|
579
|
+
queryKey: Oe,
|
|
509
580
|
queryFn: async () => {
|
|
510
|
-
const t = await e.request(
|
|
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
|
|
517
|
-
const t = T(), n =
|
|
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
|
|
521
|
-
return c.match_field === "id" ? r : ((
|
|
522
|
-
|
|
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 :
|
|
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 ||
|
|
603
|
+
return !c || u == null ? null : (t.recordUrl ?? ((d, f) => `/collections/${d}/${f}`))(c.collection, u);
|
|
533
604
|
}
|
|
534
|
-
const
|
|
535
|
-
function
|
|
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(
|
|
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
|
|
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
|
|
561
|
-
function
|
|
562
|
-
const t = T(), n =
|
|
563
|
-
(m,
|
|
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
|
-
),
|
|
566
|
-
a.current && clearTimeout(a.current), a.current = null, o.current && e &&
|
|
567
|
-
}, [e,
|
|
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 >=
|
|
571
|
-
}, [s, e, n,
|
|
572
|
-
|
|
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((
|
|
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]),
|
|
648
|
+
}, [n, e, s == null ? void 0 : s.id]), w(() => {
|
|
578
649
|
if (i.size === 0) return;
|
|
579
650
|
const m = setInterval(() => {
|
|
580
|
-
const
|
|
581
|
-
c((
|
|
582
|
-
let
|
|
583
|
-
const M = new Map(
|
|
584
|
-
for (const [
|
|
585
|
-
|
|
586
|
-
return
|
|
587
|
-
}),
|
|
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
|
|
592
|
-
return { onType:
|
|
662
|
+
const p = fe(i);
|
|
663
|
+
return { onType: f, clearTyping: d, typingText: p };
|
|
593
664
|
}
|
|
594
|
-
function
|
|
595
|
-
const t = T(), n =
|
|
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
|
-
|
|
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
|
|
680
|
+
return N([["nvr-chat-peer-read"]], e ? [e] : []), r ?? null;
|
|
610
681
|
}
|
|
611
|
-
function
|
|
612
|
-
const t =
|
|
682
|
+
function _t(e) {
|
|
683
|
+
const t = h(), n = C();
|
|
613
684
|
return g({
|
|
614
|
-
mutationFn: ({ messageId: s, emoji: o }) => t.request(
|
|
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
|
|
619
|
-
const t =
|
|
689
|
+
function Ct(e) {
|
|
690
|
+
const t = h(), n = C();
|
|
620
691
|
return g({
|
|
621
|
-
mutationFn: ({ messageId: s, text: o }) => t.request(
|
|
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
|
|
626
|
-
const t =
|
|
696
|
+
function Rt(e) {
|
|
697
|
+
const t = h(), n = C();
|
|
627
698
|
return g({
|
|
628
|
-
mutationFn: (s) => t.request(
|
|
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
|
|
635
|
-
const n =
|
|
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 } =
|
|
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
|
-
|
|
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
|
|
652
|
-
const e =
|
|
722
|
+
function wt() {
|
|
723
|
+
const e = h(), t = C();
|
|
653
724
|
return g({
|
|
654
|
-
mutationFn: async (n) => (await e.request(
|
|
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
|
|
659
|
-
const e =
|
|
729
|
+
function xe() {
|
|
730
|
+
const e = h(), { data: t } = _({
|
|
660
731
|
queryKey: ["nvr-chat-config"],
|
|
661
|
-
queryFn: async () => (await e.request(
|
|
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
|
|
667
|
-
return
|
|
737
|
+
function Tt() {
|
|
738
|
+
return xe().bot_name;
|
|
668
739
|
}
|
|
669
|
-
function
|
|
670
|
-
const t =
|
|
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
|
-
|
|
744
|
+
v(`/chat/rooms/${encodeURIComponent(e)}/pins`)
|
|
674
745
|
)).data ?? [],
|
|
675
746
|
enabled: !!e,
|
|
676
747
|
staleTime: 15e3
|
|
677
748
|
});
|
|
678
|
-
return
|
|
749
|
+
return N([["nvr-chat-pins"]], e ? [e] : []), n ?? [];
|
|
679
750
|
}
|
|
680
|
-
function
|
|
681
|
-
const t =
|
|
751
|
+
function Kt(e) {
|
|
752
|
+
const t = h(), n = C();
|
|
682
753
|
return g({
|
|
683
|
-
mutationFn: (s) => t.request(
|
|
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
|
|
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
|
|
698
|
-
return
|
|
768
|
+
function Ot(e) {
|
|
769
|
+
return A[Ee(e)];
|
|
699
770
|
}
|
|
700
|
-
function
|
|
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) %
|
|
774
|
+
return Math.abs(t) % A.length;
|
|
704
775
|
}
|
|
705
|
-
function
|
|
706
|
-
return Number.isInteger(e) && e >= 0 && e <
|
|
776
|
+
function Ft(e) {
|
|
777
|
+
return Number.isInteger(e) && e >= 0 && e < A.length ? A[e] : null;
|
|
707
778
|
}
|
|
708
|
-
function
|
|
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
|
|
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
|
|
721
|
-
function
|
|
722
|
-
return
|
|
723
|
-
|
|
791
|
+
let F = null;
|
|
792
|
+
function Et(e) {
|
|
793
|
+
return F = e, () => {
|
|
794
|
+
F === e && (F = null);
|
|
724
795
|
};
|
|
725
796
|
}
|
|
726
|
-
function
|
|
727
|
-
return
|
|
797
|
+
function It() {
|
|
798
|
+
return F !== null;
|
|
728
799
|
}
|
|
729
|
-
function
|
|
730
|
-
|
|
800
|
+
function $t(e, t) {
|
|
801
|
+
F == null || F(e, t);
|
|
731
802
|
}
|
|
732
803
|
let k = null;
|
|
733
|
-
function
|
|
804
|
+
function Lt(e) {
|
|
734
805
|
return k = e, () => {
|
|
735
806
|
k === e && (k = null);
|
|
736
807
|
};
|
|
737
808
|
}
|
|
738
|
-
function
|
|
809
|
+
function Ie() {
|
|
739
810
|
return k !== null;
|
|
740
811
|
}
|
|
741
|
-
function
|
|
812
|
+
function ee(e, t) {
|
|
742
813
|
k == null || k(e, t);
|
|
743
814
|
}
|
|
744
|
-
function
|
|
745
|
-
const t =
|
|
815
|
+
function Pt(e = !0) {
|
|
816
|
+
const t = h(), { data: n } = _({ ...X(t), enabled: e });
|
|
746
817
|
return n;
|
|
747
818
|
}
|
|
748
|
-
async function
|
|
819
|
+
async function Qt(e, t, n) {
|
|
749
820
|
var r;
|
|
750
821
|
const s = await e.request(
|
|
751
|
-
|
|
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
|
|
826
|
+
return ee(s.data.room, o), !0;
|
|
756
827
|
}
|
|
757
828
|
export {
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
we as
|
|
792
|
-
|
|
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
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
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
|
};
|