@linktr.ee/messaging-react 1.33.2 โ†’ 1.33.3-rc-1777507218

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.
@@ -1,2868 +0,0 @@
1
- import { jsx as e, jsxs as l, Fragment as re } from "react/jsx-runtime";
2
- import U from "classnames";
3
- import z, { createContext as nt, useContext as at, useCallback as A, useState as S, useRef as K, useEffect as X, useMemo as Ue, Suspense as rt } from "react";
4
- import { StreamChatService as _t } from "@linktr.ee/messaging-core";
5
- import { Chat as Et, ChannelList as St, DateSeparator as It, useChannelStateContext as fe, useChatContext as ot, areMessageUIPropsEqual as kt, useMessageReminder as Mt, useComponentContext as it, Attachment as Tt, EditMessageModal as Dt, MessageBlocked as Rt, MessageBouncePrompt as Lt, MessageDeleted as Pt, MessageIsThreadReplyInChannelButtonIndicator as Ft, MessageRepliesCountButton as At, ReminderNotification as Ot, StreamedMessageText as Ut, messageHasAttachments as Bt, messageHasReactions as zt, isDateSeparatorMessage as $t, isMessageBlocked as jt, isMessageBounced as Gt, MessageBounceModal as Ht, MessageText as Ye, Poll as Vt, MessageErrorIcon as Yt, useMessageContext as lt, useMessageComposer as Wt, useStateStore as qt, MessageInput as Zt, useMessageInputContext as Xt, useMessageComposerHasSendableData as Kt, SimpleAttachmentSelector as Jt, QuotedMessagePreview as Qt, AttachmentPreviewList as es, TextareaComposer as ts, MessageTimestamp as Fe, Channel as ss, WithComponents as ns, Window as as, MessageList as rs } from "stream-chat-react";
6
- import { StarIcon as Be, GiftIcon as os, XIcon as je, SpinnerGapIcon as Ie, SignOutIcon as is, ProhibitInsetIcon as We, FlagIcon as ls, ArrowUpIcon as cs, SparkleIcon as ds, ProhibitIcon as us, ArrowLeftIcon as qe, DotsThreeIcon as Ze, MagnifyingGlassIcon as ms, ChatCircleDotsIcon as Xe, FileIcon as ct, ImageIcon as hs, SpeakerHighIcon as fs, VideoCameraIcon as gs, FileMdIcon as bs, FileTextIcon as xs, FileZipIcon as ps, FilePptIcon as vs, FileCsvIcon as ys, FileXlsIcon as Ns, FileDocIcon as ws, FilePdfIcon as Cs, CircleNotchIcon as _s, PlayIcon as Ke, PauseIcon as Es } from "@phosphor-icons/react";
7
- import { LinkPreviewsManager as Je } from "stream-chat";
8
- const dt = nt({
9
- service: null,
10
- client: null,
11
- isConnected: !1,
12
- isLoading: !1,
13
- error: null,
14
- capabilities: {},
15
- refreshConnection: async () => {
16
- },
17
- debug: !1
18
- }), De = () => at(dt), Gn = ({
19
- children: t,
20
- user: s,
21
- serviceConfig: n,
22
- apiKey: o,
23
- capabilities: i = {},
24
- debug: u = !1
25
- }) => {
26
- const r = A(
27
- (d, ...C) => {
28
- u && console.log(`๐Ÿ”ฅ [MessagingProvider] ${d}`, ...C);
29
- },
30
- [u]
31
- );
32
- r("๐Ÿ”„ RENDER START", {
33
- userId: s == null ? void 0 : s.id,
34
- apiKey: (o == null ? void 0 : o.substring(0, 8)) + "...",
35
- serviceConfig: !!n,
36
- capabilities: Object.keys(i)
37
- });
38
- const [c, f] = S(null), [m, g] = S(null), [b, N] = S(!1), [a, w] = S(!1), [y, x] = S(null), E = K(!1), v = K({
39
- userId: s == null ? void 0 : s.id,
40
- apiKey: o,
41
- serviceConfig: n,
42
- capabilities: i
43
- }), I = K(0);
44
- I.current++, r("๐Ÿ“Š RENDER INFO", {
45
- renderCount: I.current,
46
- currentProps: { userId: s == null ? void 0 : s.id, apiKey: (o == null ? void 0 : o.substring(0, 8)) + "..." },
47
- propChanges: {
48
- userChanged: v.current.userId !== (s == null ? void 0 : s.id),
49
- apiKeyChanged: v.current.apiKey !== o,
50
- serviceConfigChanged: v.current.serviceConfig !== n,
51
- capabilitiesChanged: v.current.capabilities !== i
52
- }
53
- }), v.current = {
54
- userId: s == null ? void 0 : s.id,
55
- apiKey: o,
56
- serviceConfig: n,
57
- capabilities: i
58
- }, X(() => {
59
- const d = I.current;
60
- if (r("๐Ÿ”ง SERVICE INIT EFFECT TRIGGERED", {
61
- renderCount: d,
62
- apiKey: !!o,
63
- serviceConfig: !!n,
64
- dependencies: {
65
- apiKey: (o == null ? void 0 : o.substring(0, 8)) + "...",
66
- serviceConfigRef: n,
67
- serviceConfigStable: v.current.serviceConfig === n,
68
- apiKeyStable: v.current.apiKey === o
69
- }
70
- }), !o || !n) {
71
- r("โš ๏ธ SERVICE INIT SKIPPED", {
72
- renderCount: d,
73
- reason: "Missing apiKey or serviceConfig"
74
- });
75
- return;
76
- }
77
- r("๐Ÿš€ CREATING NEW SERVICE", {
78
- renderCount: d,
79
- apiKey: (o == null ? void 0 : o.substring(0, 8)) + "...",
80
- serviceConfigChanged: v.current.serviceConfig !== n
81
- });
82
- const C = new _t({
83
- ...n,
84
- apiKey: o,
85
- debug: u
86
- });
87
- return f(C), r("โœ… SERVICE SET", {
88
- renderCount: d,
89
- serviceInstance: !!C
90
- }), () => {
91
- r("๐Ÿงน SERVICE CLEANUP", {
92
- renderCount: d,
93
- reason: "Effect cleanup"
94
- }), C.disconnectUser().catch(console.error);
95
- };
96
- }, [o, n, u, r]);
97
- const k = K(null);
98
- X(() => {
99
- var C, _;
100
- if (r("๐Ÿ”— USER CONNECTION EFFECT TRIGGERED", {
101
- hasService: !!c,
102
- hasUser: !!s,
103
- userId: s == null ? void 0 : s.id,
104
- isConnecting: E.current,
105
- isConnected: b,
106
- dependencies: { service: !!c, userId: s == null ? void 0 : s.id }
107
- }), !c || !s) {
108
- r("โš ๏ธ USER CONNECTION SKIPPED", "Missing service or user");
109
- return;
110
- }
111
- if (E.current) {
112
- r("โš ๏ธ USER CONNECTION SKIPPED", "Already connecting");
113
- return;
114
- }
115
- if (((C = k.current) == null ? void 0 : C.serviceId) === c && ((_ = k.current) == null ? void 0 : _.userId) === s.id) {
116
- r(
117
- "โš ๏ธ USER CONNECTION SKIPPED",
118
- "Already connected this user with this service"
119
- );
120
- return;
121
- }
122
- (async () => {
123
- r("๐Ÿš€ STARTING USER CONNECTION", { userId: s.id }), E.current = !0, w(!0), x(null);
124
- try {
125
- r("๐Ÿ“ž CALLING SERVICE.CONNECTUSER", { userId: s.id });
126
- const T = await c.connectUser(s);
127
- g(T), N(!0), k.current = { serviceId: c, userId: s.id }, r("โœ… USER CONNECTION SUCCESS", {
128
- userId: s.id,
129
- clientId: T.userID
130
- });
131
- } catch (T) {
132
- const L = T instanceof Error ? T.message : "Connection failed";
133
- x(L), r("โŒ USER CONNECTION ERROR", {
134
- userId: s.id,
135
- error: L
136
- });
137
- } finally {
138
- w(!1), E.current = !1, r("๐Ÿ”„ USER CONNECTION FINISHED", {
139
- userId: s.id,
140
- isConnected: b
141
- });
142
- }
143
- })();
144
- }, [c, s, r, b]), X(() => (r("๐Ÿ”Œ CLEANUP EFFECT REGISTERED", {
145
- hasService: !!c,
146
- isConnected: b
147
- }), () => {
148
- c && b ? (r(
149
- "๐Ÿงน CLEANUP EFFECT TRIGGERED",
150
- "Cleaning up connection on unmount"
151
- ), k.current = null, c.disconnectUser().catch(console.error)) : r("๐Ÿ”‡ CLEANUP EFFECT SKIPPED", {
152
- hasService: !!c,
153
- isConnected: b
154
- });
155
- }), [c, b, r]);
156
- const P = A(async () => {
157
- if (r("๐Ÿ”„ REFRESH CONNECTION CALLED", {
158
- hasService: !!c,
159
- hasUser: !!s
160
- }), !c || !s) {
161
- r("โš ๏ธ REFRESH CONNECTION SKIPPED", "Missing service or user");
162
- return;
163
- }
164
- r("๐Ÿš€ STARTING CONNECTION REFRESH", { userId: s.id }), w(!0);
165
- try {
166
- r("๐Ÿ”Œ DISCONNECTING FOR REFRESH"), await c.disconnectUser(), r("๐Ÿ“ž RECONNECTING FOR REFRESH");
167
- const d = await c.connectUser(s);
168
- g(d), N(!0), x(null), r("โœ… CONNECTION REFRESH SUCCESS", { userId: s.id });
169
- } catch (d) {
170
- const C = d instanceof Error ? d.message : "Refresh failed";
171
- x(C), r("โŒ CONNECTION REFRESH ERROR", {
172
- userId: s.id,
173
- error: C
174
- });
175
- } finally {
176
- w(!1), r("๐Ÿ”„ CONNECTION REFRESH FINISHED", { userId: s.id });
177
- }
178
- }, [c, s, r]), p = z.useMemo(() => (r("๐Ÿ’ซ CONTEXT VALUE MEMOIZATION", {
179
- hasService: !!c,
180
- hasClient: !!m,
181
- isConnected: b,
182
- isLoading: a,
183
- hasError: !!y,
184
- capabilitiesKeys: Object.keys(i)
185
- }), {
186
- service: c,
187
- client: m,
188
- isConnected: b,
189
- isLoading: a,
190
- error: y,
191
- capabilities: i,
192
- refreshConnection: P,
193
- debug: u
194
- }), [
195
- c,
196
- m,
197
- b,
198
- a,
199
- y,
200
- i,
201
- P,
202
- u,
203
- r
204
- ]);
205
- return r("๐Ÿ”„ RENDER END", {
206
- renderCount: I.current,
207
- willRenderChat: !!(m && b),
208
- contextValueReady: !!p
209
- }), /* @__PURE__ */ e(dt.Provider, { value: p, children: m && b ? /* @__PURE__ */ e(
210
- Et,
211
- {
212
- client: m,
213
- customClasses: {
214
- channelList: "str-chat__channel-list str-chat__channel-list-react bg-transparent lg:border-r-2 border-r-0 border-[#0000000A]"
215
- },
216
- children: t
217
- }
218
- ) : t });
219
- }, Ss = () => De();
220
- function Is(t) {
221
- const s = t.state.pending_messages;
222
- if (s != null && s.length)
223
- for (const n of s)
224
- t.state.addMessageSorted(n.message);
225
- }
226
- const ut = z.createContext({
227
- selectedChannel: void 0,
228
- onChannelSelect: () => {
229
- },
230
- debug: !1,
231
- renderMessagePreview: void 0
232
- }), ks = ut.Provider, Ms = () => z.useContext(ut), mt = (t) => {
233
- var o, i;
234
- const [s, n] = S(
235
- !!((i = (o = t == null ? void 0 : t.state) == null ? void 0 : o.membership) != null && i.pinned_at)
236
- );
237
- return X(() => {
238
- var r;
239
- if (!t) {
240
- n(!1);
241
- return;
242
- }
243
- n(!!((r = t.state.membership) != null && r.pinned_at));
244
- const u = (c) => {
245
- var f;
246
- n(
247
- c != null && c.member ? !!c.member.pinned_at : !!((f = t.state.membership) != null && f.pinned_at)
248
- );
249
- };
250
- return t.on("member.updated", u), () => {
251
- t.off("member.updated", u);
252
- };
253
- }, [t]), s;
254
- }, Ts = (t, s) => {
255
- const n = new Date(
256
- Date.UTC(t.getUTCFullYear(), t.getUTCMonth(), t.getUTCDate())
257
- ), i = new Date(
258
- Date.UTC(s.getUTCFullYear(), s.getUTCMonth(), s.getUTCDate())
259
- ).getTime() - n.getTime();
260
- return Math.floor(i / (1e3 * 60 * 60 * 24));
261
- }, Ds = (t) => {
262
- const s = /* @__PURE__ */ new Date();
263
- if (Math.floor((s.getTime() - t.getTime()) / 1e3) < 60)
264
- return "Just now";
265
- const o = Ts(t, s);
266
- return o === 0 ? t.toLocaleTimeString([], {
267
- hour: "numeric",
268
- minute: "2-digit",
269
- hour12: !0
270
- }) : o === 1 ? "Yesterday" : o < 7 ? `${o}d` : o < 28 ? `${Math.floor(o / 7)}w` : t.toLocaleDateString("en-US", {
271
- month: "numeric",
272
- day: "numeric",
273
- year: "2-digit"
274
- });
275
- }, Qe = [
276
- "๐ŸŽ",
277
- // Apple
278
- "๐ŸŒ",
279
- // Banana
280
- "๐Ÿ‡",
281
- // Grape
282
- "๐ŸŠ",
283
- // Orange
284
- "๐Ÿ“",
285
- // Strawberry
286
- "๐Ÿฅฅ",
287
- // Coconut
288
- "๐Ÿ’",
289
- // Cherry
290
- "๐Ÿฅญ",
291
- // Mango
292
- "๐Ÿ‰",
293
- // Watermelon
294
- "๐Ÿ‹",
295
- // Lemon
296
- "๐Ÿฅ",
297
- // Kiwi
298
- "๐Ÿซ’",
299
- // Olive
300
- "๐Ÿˆ"
301
- // Melon
302
- ];
303
- function Rs(t) {
304
- let s = 0;
305
- for (let n = 0; n < t.length; n++) {
306
- const o = t.charCodeAt(n);
307
- s = (s << 5) - s + o, s = s & s;
308
- }
309
- return Math.abs(s);
310
- }
311
- function Ls(t) {
312
- const n = Rs(t) % Qe.length;
313
- return Qe[n];
314
- }
315
- const oe = ({
316
- id: t,
317
- image: s,
318
- size: n = 40,
319
- className: o,
320
- starred: i = !1,
321
- shape: u = "squircle"
322
- }) => {
323
- const r = Ls(t), f = n < 32 ? "text-xs" : n < 56 ? "text-sm" : n < 120 ? "text-lg" : "text-4xl", m = u === "circle" ? { borderRadius: "50%" } : {
324
- borderRadius: "33%",
325
- "corner-shape": "superellipse(1.3)"
326
- };
327
- return /* @__PURE__ */ l(
328
- "div",
329
- {
330
- className: U("relative flex-shrink-0", o),
331
- style: {
332
- width: `${n}px`,
333
- height: `${n}px`
334
- },
335
- children: [
336
- i && /* @__PURE__ */ e(
337
- "div",
338
- {
339
- "aria-hidden": "true",
340
- className: "absolute -left-1.5 -top-1.5 z-10 flex size-5 items-center justify-center rounded-full bg-white shadow-[0_0_0_1px_rgba(0,0,0,0.04),0_4px_8px_rgba(0,0,0,0.06)]",
341
- children: /* @__PURE__ */ e(Be, { className: "size-3 text-yellow-600", weight: "duotone" })
342
- }
343
- ),
344
- /* @__PURE__ */ e("div", { className: "h-full w-full overflow-hidden", style: m, children: s ? /* @__PURE__ */ e(
345
- "img",
346
- {
347
- src: s,
348
- alt: "",
349
- className: "aspect-square h-full w-full object-cover"
350
- }
351
- ) : /* @__PURE__ */ e(
352
- "div",
353
- {
354
- "aria-hidden": "true",
355
- className: U(
356
- "avatar-fallback flex h-full w-full items-center justify-center bg-[#E6E5E3] font-semibold select-none transition-colors",
357
- f
358
- ),
359
- children: r
360
- }
361
- ) })
362
- ]
363
- }
364
- );
365
- }, Ps = ({ size: t = 15 }) => /* @__PURE__ */ e(
366
- "svg",
367
- {
368
- width: t,
369
- height: t,
370
- viewBox: "0 0 15 15",
371
- fill: "none",
372
- "aria-hidden": "true",
373
- children: /* @__PURE__ */ e(
374
- "path",
375
- {
376
- d: "M12.003 9a.985.985 0 0 1-.652.934l-3.223 1.191-1.188 3.226a.995.995 0 0 1-1.867 0l-1.195-3.226L.65 9.937a.995.995 0 0 1 0-1.867l3.227-1.195 1.187-3.226a.995.995 0 0 1 1.868 0l1.195 3.226 3.226 1.187a.99.99 0 0 1 .649.938m3-5.83a.52.52 0 0 1-.344.492l-1.702.63-.627 1.703a.525.525 0 0 1-.986 0l-.63-1.704-1.704-.627a.525.525 0 0 1 0-.986l1.703-.63.627-1.704a.526.526 0 0 1 .986 0l.631 1.703 1.704.627a.52.52 0 0 1 .342.495",
377
- fill: "currentColor",
378
- fillOpacity: 0.55
379
- }
380
- )
381
- }
382
- ), Fs = (t) => {
383
- var s;
384
- return ((s = t.metadata) == null ? void 0 : s.custom_type) === "MESSAGE_TIP";
385
- }, As = (t) => {
386
- var s;
387
- return ((s = t.metadata) == null ? void 0 : s.custom_type) === "MESSAGE_PAID";
388
- }, Ge = (t) => {
389
- var s;
390
- return ((s = t.metadata) == null ? void 0 : s.custom_type) === "MESSAGE_CHATBOT";
391
- }, Os = (t) => {
392
- var s;
393
- return ((s = t.metadata) == null ? void 0 : s.custom_type) === "MESSAGE_ATTACHMENT";
394
- }, ht = (t) => Fs(t) || As(t), Us = (t) => {
395
- var s;
396
- return ht(t) && !((s = t.text) != null && s.trim());
397
- }, Ae = ({
398
- message: t,
399
- standalone: s = !1,
400
- isMyMessage: n = !1,
401
- hasAttachment: o = !1
402
- }) => {
403
- var b;
404
- const i = ht(t), u = Ge(t);
405
- if (!i && !u)
406
- return null;
407
- if (i) {
408
- const N = (b = t.metadata) == null ? void 0 : b.amount_text;
409
- if (!N) return null;
410
- const a = s ? "message-tip-standalone" : "message-tag message-tag--tip", w = s ? `${N} tip` : `Delivered with ${N} tip`;
411
- return /* @__PURE__ */ l("div", { className: a, children: [
412
- /* @__PURE__ */ e(os, { size: s ? 14 : 12 }),
413
- /* @__PURE__ */ e("span", { children: w })
414
- ] });
415
- }
416
- const r = n && o, c = r ? "Sent with AI" : "Sent with DM Agent", f = [
417
- "message-chatbot-indicator",
418
- n ? "message-chatbot-indicator--sender" : "message-chatbot-indicator--receiver",
419
- r ? "message-chatbot-indicator--attachment" : "message-chatbot-indicator--text"
420
- ].join(" "), m = /* @__PURE__ */ e("span", { className: "message-chatbot-indicator__label", children: c }), g = /* @__PURE__ */ e("span", { className: "message-chatbot-indicator__icon", children: /* @__PURE__ */ e(Ps, { size: r ? 12 : 15 }) });
421
- return /* @__PURE__ */ e("div", { className: f, "data-testid": "message-chatbot-indicator", children: n && !r ? /* @__PURE__ */ l(re, { children: [
422
- m,
423
- g
424
- ] }) : /* @__PURE__ */ l(re, { children: [
425
- g,
426
- m
427
- ] }) });
428
- }, ft = z.memo(
429
- ({ channel: t, unread: s }) => {
430
- var P, p, d, C;
431
- const { selectedChannel: n, onChannelSelect: o, debug: i, renderMessagePreview: u } = Ms(), r = (n == null ? void 0 : n.id) === (t == null ? void 0 : t.id), c = () => {
432
- t && o(t);
433
- }, f = (_) => {
434
- const T = _.key === "Enter" || _.key === " ", L = _.repeat;
435
- !T || L || (_.preventDefault(), c());
436
- }, g = Object.values(((P = t == null ? void 0 : t.state) == null ? void 0 : P.members) || {}).find(
437
- (_) => {
438
- var T, L;
439
- return ((T = _.user) == null ? void 0 : T.id) && _.user.id !== ((L = t == null ? void 0 : t._client) == null ? void 0 : L.userID);
440
- }
441
- ), b = ((p = g == null ? void 0 : g.user) == null ? void 0 : p.name) || "Conversation", N = (d = g == null ? void 0 : g.user) == null ? void 0 : d.image, a = (() => {
442
- var T;
443
- const _ = (T = t == null ? void 0 : t.state) == null ? void 0 : T.messages;
444
- if (_ != null && _.length) {
445
- for (let L = _.length - 1; L >= 0; L--)
446
- if (_[L].type !== "system") return _[L];
447
- }
448
- })(), y = (() => {
449
- var L, D;
450
- if (a != null && a.text) return a.text;
451
- if (((L = a == null ? void 0 : a.metadata) == null ? void 0 : L.custom_type) === "MESSAGE_TIP") return "๐Ÿ’ต Sent a tip";
452
- const T = (D = a == null ? void 0 : a.attachments) == null ? void 0 : D[0];
453
- return T ? T.og_scrape_url ? T.og_scrape_url : T.type === "image" ? "๐Ÿ“ท Sent an image" : T.type === "video" ? "๐ŸŽฅ Sent a video" : T.type === "audio" ? "๐ŸŽต Sent audio" : T.type === "file" ? "๐Ÿ“Ž Sent a file" : "๐Ÿ“Ž Sent an attachment" : "No messages yet";
454
- })(), x = a != null && a.created_at ? Ds(new Date(a.created_at)) : "", E = a ? Ge(a) : !1, v = u ? u(a, y) : `${E ? "โœจ " : ""}${y}`, I = mt(t), k = s ?? 0;
455
- return i && console.log("๐Ÿ“บ [ChannelList] ๐Ÿ“‹ CHANNEL PREVIEW RENDER", {
456
- channelId: t == null ? void 0 : t.id,
457
- isSelected: r,
458
- participantName: b,
459
- unreadCount: k,
460
- hasTimestamp: !!x
461
- }), /* @__PURE__ */ e(
462
- "div",
463
- {
464
- role: "button",
465
- tabIndex: 0,
466
- onClick: c,
467
- onKeyDown: f,
468
- className: U(
469
- "group w-full px-4 py-3 transition-colors text-left max-w-full overflow-hidden focus-ring",
470
- {
471
- "bg-primary-alt/10 border-l-4 border-l-primary": r,
472
- "hover:bg-sand": !r
473
- }
474
- ),
475
- children: /* @__PURE__ */ l("div", { className: "flex items-start gap-3", children: [
476
- /* @__PURE__ */ e(
477
- oe,
478
- {
479
- id: ((C = g == null ? void 0 : g.user) == null ? void 0 : C.id) || t.id || "unknown",
480
- name: b,
481
- image: N,
482
- size: 44,
483
- starred: I,
484
- className: "[&_.avatar-fallback]:group-hover:bg-[#eeeeee]"
485
- }
486
- ),
487
- /* @__PURE__ */ l("div", { className: "flex-1 min-w-0 flex flex-col gap-1", children: [
488
- /* @__PURE__ */ l("div", { className: "flex items-center justify-between gap-2", children: [
489
- /* @__PURE__ */ l(
490
- "h3",
491
- {
492
- className: U(
493
- "text-sm font-medium truncate",
494
- r ? "text-primary" : "text-charcoal"
495
- ),
496
- children: [
497
- I && /* @__PURE__ */ e("span", { className: "sr-only", children: "Starred conversation. " }),
498
- b
499
- ]
500
- }
501
- ),
502
- x && /* @__PURE__ */ e("span", { className: "text-xs text-stone flex-shrink-0", children: x })
503
- ] }),
504
- /* @__PURE__ */ l("div", { className: "flex items-center justify-between gap-2 min-w-0", children: [
505
- /* @__PURE__ */ e("p", { className: "text-xs text-stone flex-1 line-clamp-1", children: v }),
506
- k > 0 && /* @__PURE__ */ e("span", { className: "bg-[#7f22fe] text-white text-xs px-2 py-0.5 rounded-full min-w-[20px] text-center flex-shrink-0", children: k > 99 ? "99+" : k })
507
- ] })
508
- ] })
509
- ] })
510
- }
511
- );
512
- }
513
- );
514
- ft.displayName = "CustomChannelPreview";
515
- const Bs = { last_message_at: -1 }, gt = z.memo(
516
- ({
517
- onChannelSelect: t,
518
- selectedChannel: s,
519
- filters: n,
520
- allowNewMessagesFromUnfilteredChannels: o = !1,
521
- onMessageNew: i,
522
- onAddedToChannel: u,
523
- channelRenderFilterFn: r,
524
- sort: c = Bs,
525
- className: f,
526
- customEmptyStateIndicator: m,
527
- renderMessagePreview: g
528
- }) => {
529
- const b = z.useRef(0);
530
- b.current++;
531
- const { debug: N = !1 } = De(), a = z.useCallback(
532
- (y) => {
533
- for (const x of y)
534
- Is(x);
535
- return r ? r(y) : y;
536
- },
537
- [r]
538
- );
539
- N && console.log("๐Ÿ“บ [ChannelList] ๐Ÿ”„ RENDER START", {
540
- renderCount: b.current,
541
- selectedChannelId: s == null ? void 0 : s.id,
542
- filters: n
543
- });
544
- const w = z.useMemo(
545
- () => ({
546
- selectedChannel: s,
547
- onChannelSelect: t,
548
- debug: N,
549
- renderMessagePreview: g
550
- }),
551
- [s, t, N, g]
552
- );
553
- return /* @__PURE__ */ e(
554
- "div",
555
- {
556
- className: U(
557
- "messaging-channel-list h-full flex flex-col min-w-0 overflow-hidden",
558
- f
559
- ),
560
- children: /* @__PURE__ */ e("div", { className: "flex-1 overflow-hidden min-w-0", children: /* @__PURE__ */ e(ks, { value: w, children: /* @__PURE__ */ e(
561
- St,
562
- {
563
- filters: n,
564
- sort: c,
565
- options: { limit: 30 },
566
- allowNewMessagesFromUnfilteredChannels: o,
567
- onMessageNew: i,
568
- onAddedToChannel: u,
569
- channelRenderFilterFn: a,
570
- Preview: ft,
571
- EmptyStateIndicator: m
572
- },
573
- `${JSON.stringify(n)}:${JSON.stringify(c)}`
574
- ) }) })
575
- }
576
- );
577
- }
578
- );
579
- gt.displayName = "ChannelList";
580
- const Se = ({
581
- variant: t = "default",
582
- className: s,
583
- children: n,
584
- ...o
585
- }) => /* @__PURE__ */ e(
586
- "button",
587
- {
588
- type: "button",
589
- className: U(
590
- "flex w-full items-center gap-3 rounded-lg px-4 py-3 text-left text-sm transition-colors focus-ring disabled:cursor-not-allowed disabled:opacity-60",
591
- t === "danger" ? "text-danger hover:bg-danger/50" : "text-charcoal hover:bg-sand",
592
- s
593
- ),
594
- ...o,
595
- children: n
596
- }
597
- );
598
- function bt({ label: t, className: s, children: n, ...o }) {
599
- return /* @__PURE__ */ l(
600
- "button",
601
- {
602
- type: "button",
603
- className: U(
604
- "inline-flex items-center justify-center rounded-full transition-colors focus-ring p-2",
605
- {
606
- "cursor-not-allowed opacity-50": o.disabled,
607
- "hover:bg-sand": !o.disabled
608
- },
609
- s
610
- ),
611
- ...o,
612
- children: [
613
- /* @__PURE__ */ e("span", { className: "sr-only", children: t }),
614
- n
615
- ]
616
- }
617
- );
618
- }
619
- function xt({ onClick: t }) {
620
- return /* @__PURE__ */ e(bt, { label: "Close", onClick: t, className: "p-1", children: /* @__PURE__ */ e(je, { className: "h-5 w-5 text-stone", weight: "bold" }) });
621
- }
622
- const zs = ({
623
- dialogRef: t,
624
- onClose: s,
625
- participant: n,
626
- channel: o,
627
- followerStatusLabel: i,
628
- onLeaveConversation: u,
629
- onBlockParticipant: r,
630
- showDeleteConversation: c = !0,
631
- onDeleteConversationClick: f,
632
- onBlockParticipantClick: m,
633
- onReportParticipantClick: g,
634
- customProfileContent: b,
635
- customChannelActions: N
636
- }) => {
637
- var $, F, J, Z, Q, h, R;
638
- const { service: a, debug: w } = De(), [y, x] = S(!1), [E, v] = S(!1), [I, k] = S(!1), P = A(async () => {
639
- var O;
640
- if (!(!a || !((O = n == null ? void 0 : n.user) != null && O.id)))
641
- try {
642
- const j = (await a.getBlockedUsers()).some(
643
- (se) => {
644
- var ie;
645
- return se.blocked_user_id === ((ie = n == null ? void 0 : n.user) == null ? void 0 : ie.id);
646
- }
647
- );
648
- x(j);
649
- } catch (V) {
650
- console.error(
651
- "[ChannelInfoDialog] Failed to check blocked status:",
652
- V
653
- );
654
- }
655
- }, [a, ($ = n == null ? void 0 : n.user) == null ? void 0 : $.id]);
656
- X(() => {
657
- P();
658
- }, [P]);
659
- const p = async () => {
660
- var O;
661
- if (!E) {
662
- f == null || f(), w && console.log("[ChannelInfoDialog] Leave conversation", o.cid), v(!0);
663
- try {
664
- const V = ((O = o._client) == null ? void 0 : O.userID) ?? null;
665
- await o.hide(V, !1), u && await u(o), s();
666
- } catch (V) {
667
- console.error("[ChannelInfoDialog] Failed to leave conversation", V);
668
- } finally {
669
- v(!1);
670
- }
671
- }
672
- }, d = async () => {
673
- var O, V, j;
674
- if (!(I || !a)) {
675
- m == null || m(), w && console.log("[ChannelInfoDialog] Block member", (O = n == null ? void 0 : n.user) == null ? void 0 : O.id), k(!0);
676
- try {
677
- await a.blockUser((V = n == null ? void 0 : n.user) == null ? void 0 : V.id), r && await r((j = n == null ? void 0 : n.user) == null ? void 0 : j.id), s();
678
- } catch (se) {
679
- console.error("[ChannelInfoDialog] Failed to block member", se);
680
- } finally {
681
- k(!1);
682
- }
683
- }
684
- }, C = async () => {
685
- var O, V, j;
686
- if (!(I || !a)) {
687
- m == null || m(), w && console.log("[ChannelInfoDialog] Unblock member", (O = n == null ? void 0 : n.user) == null ? void 0 : O.id), k(!0);
688
- try {
689
- await a.unBlockUser((V = n == null ? void 0 : n.user) == null ? void 0 : V.id), r && await r((j = n == null ? void 0 : n.user) == null ? void 0 : j.id), s();
690
- } catch (se) {
691
- console.error("[ChannelInfoDialog] Failed to unblock member", se);
692
- } finally {
693
- k(!1);
694
- }
695
- }
696
- }, _ = () => {
697
- g == null || g(), s(), window.open(
698
- "https://linktr.ee/s/about/trust-center/report",
699
- "_blank",
700
- "noopener,noreferrer"
701
- );
702
- };
703
- if (!n) return null;
704
- const T = ((F = n.user) == null ? void 0 : F.name) || ((J = n.user) == null ? void 0 : J.id) || "Unknown member", L = (Z = n.user) == null ? void 0 : Z.image, D = (Q = n.user) == null ? void 0 : Q.email, G = (h = n.user) == null ? void 0 : h.username, ee = D || (G ? `linktr.ee/${G}` : void 0), q = ((R = n.user) == null ? void 0 : R.id) || "unknown";
705
- return (
706
- // eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-noninteractive-element-interactions
707
- /* @__PURE__ */ e(
708
- "dialog",
709
- {
710
- ref: t,
711
- className: "mes-dialog group",
712
- onClose: s,
713
- onClick: (O) => {
714
- O.target === t.current && s();
715
- },
716
- children: /* @__PURE__ */ l("div", { className: "ml-auto flex h-full w-full flex-col bg-white shadow-none transition-shadow duration-200 group-open:shadow-max-elevation-light", children: [
717
- /* @__PURE__ */ l("div", { className: "flex items-center justify-between border-b border-sand px-4 py-3", children: [
718
- /* @__PURE__ */ e("h2", { className: "text-base font-semibold text-charcoal", children: "Chat info" }),
719
- /* @__PURE__ */ e(xt, { onClick: s })
720
- ] }),
721
- /* @__PURE__ */ l("div", { className: "flex-1 px-2 overflow-y-auto w-full", children: [
722
- /* @__PURE__ */ e(
723
- "div",
724
- {
725
- className: "flex flex-col items-center gap-3 self-stretch px-4 py-2 mt-6 rounded-lg border border-black/[0.04]",
726
- style: { backgroundColor: "#FBFAF9" },
727
- children: /* @__PURE__ */ l("div", { className: "flex items-center gap-3 w-full", children: [
728
- /* @__PURE__ */ e(
729
- oe,
730
- {
731
- id: q,
732
- name: T,
733
- image: L,
734
- size: 88,
735
- shape: "circle"
736
- }
737
- ),
738
- /* @__PURE__ */ l("div", { className: "flex flex-col min-w-0 flex-1", children: [
739
- /* @__PURE__ */ e("p", { className: "truncate text-base font-semibold text-charcoal", children: T }),
740
- ee && /* @__PURE__ */ e("p", { className: "truncate text-sm text-[#00000055]", children: ee }),
741
- i && !b && /* @__PURE__ */ e(
742
- "span",
743
- {
744
- className: "mt-1 rounded-full text-xs font-normal w-fit",
745
- style: {
746
- padding: "4px 8px",
747
- backgroundColor: i === "Subscribed to you" ? "#DCFCE7" : "#F5F5F4",
748
- color: i === "Subscribed to you" ? "#008236" : "#78716C",
749
- lineHeight: "133.333%",
750
- letterSpacing: "0.21px"
751
- },
752
- children: i
753
- }
754
- ),
755
- b
756
- ] })
757
- ] })
758
- }
759
- ),
760
- /* @__PURE__ */ l("ul", { className: "flex flex-col gap-2 mt-2", children: [
761
- c && /* @__PURE__ */ e("li", { children: /* @__PURE__ */ l(
762
- Se,
763
- {
764
- onClick: p,
765
- disabled: E,
766
- "aria-busy": E,
767
- children: [
768
- E ? /* @__PURE__ */ e(Ie, { className: "h-5 w-5 animate-spin" }) : /* @__PURE__ */ e(is, { className: "h-5 w-5" }),
769
- /* @__PURE__ */ e("span", { children: "Delete Conversation" })
770
- ]
771
- }
772
- ) }),
773
- /* @__PURE__ */ e("li", { children: y ? /* @__PURE__ */ l(
774
- Se,
775
- {
776
- onClick: C,
777
- disabled: I,
778
- "aria-busy": I,
779
- children: [
780
- I ? /* @__PURE__ */ e(Ie, { className: "h-5 w-5 animate-spin" }) : /* @__PURE__ */ e(We, { className: "h-5 w-5" }),
781
- /* @__PURE__ */ e("span", { children: "Unblock" })
782
- ]
783
- }
784
- ) : /* @__PURE__ */ l(
785
- Se,
786
- {
787
- onClick: d,
788
- disabled: I,
789
- "aria-busy": I,
790
- children: [
791
- I ? /* @__PURE__ */ e(Ie, { className: "h-5 w-5 animate-spin" }) : /* @__PURE__ */ e(We, { className: "h-5 w-5" }),
792
- /* @__PURE__ */ e("span", { children: "Block" })
793
- ]
794
- }
795
- ) }),
796
- /* @__PURE__ */ e("li", { children: /* @__PURE__ */ l(Se, { variant: "danger", onClick: _, children: [
797
- /* @__PURE__ */ e(ls, { className: "h-5 w-5" }),
798
- /* @__PURE__ */ e("span", { children: "Report" })
799
- ] }) }),
800
- N
801
- ] })
802
- ] })
803
- ] })
804
- }
805
- )
806
- );
807
- }, $s = (t) => /* @__PURE__ */ e(It, { ...t, position: "center" }), ze = "vote_up", $e = "vote_down";
808
- function js(t) {
809
- return t != null && t.length ? t.some((s) => s.type === $e) ? "down" : t.some((s) => s.type === ze) ? "up" : null : null;
810
- }
811
- function Gs(t) {
812
- const { channel: s } = fe(), { client: n } = ot("useMessageVote"), o = Ue(
813
- () => js(t.own_reactions),
814
- [t.own_reactions]
815
- ), i = A(async () => {
816
- if (n != null && n.userID)
817
- try {
818
- o === "up" ? await s.deleteReaction(t.id, ze) : await s.sendReaction(
819
- t.id,
820
- { type: ze },
821
- { enforce_unique: !0, skip_push: !0 }
822
- );
823
- } catch {
824
- }
825
- }, [s, n == null ? void 0 : n.userID, t.id, o]), u = A(async () => {
826
- if (n != null && n.userID)
827
- try {
828
- o === "down" ? await s.deleteReaction(t.id, $e) : await s.sendReaction(
829
- t.id,
830
- { type: $e },
831
- { enforce_unique: !0, skip_push: !0 }
832
- );
833
- } catch {
834
- }
835
- }, [s, n == null ? void 0 : n.userID, t.id, o]);
836
- return { selected: o, voteUp: i, voteDown: u };
837
- }
838
- const Hs = z.lazy(() => import("./Card-DEe10CiS.js")), Vs = z.lazy(() => import("./Card-Ddi8bg90.js")), pt = () => /* @__PURE__ */ e(
839
- "div",
840
- {
841
- className: "w-[280px] min-h-[200px] animate-pulse rounded-[24px] bg-black/[0.06] shadow-[0_0_0_1px_rgba(0,0,0,0.04),0_4px_8px_rgba(0,0,0,0.06)]",
842
- "aria-hidden": !0
843
- }
844
- ), Ys = (t) => /* @__PURE__ */ e(rt, { fallback: /* @__PURE__ */ e(pt, {}), children: /* @__PURE__ */ e(Hs, { ...t }) }), Ws = (t) => /* @__PURE__ */ e(rt, { fallback: /* @__PURE__ */ e(pt, {}), children: /* @__PURE__ */ e(Vs, { ...t }) }), et = { Creator: Ys, Visitor: Ws }, qs = {
845
- isUnlocking: () => !1
846
- }, Zs = {
847
- LockedAttachment: qs
848
- }, vt = nt({}), Hn = vt.Provider;
849
- function Xs(t) {
850
- return at(vt)[t] ?? Zs[t];
851
- }
852
- const Ks = ({ filled: t }) => /* @__PURE__ */ e("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", children: /* @__PURE__ */ e(
853
- "path",
854
- {
855
- d: "M4.667 7.333l2.666-6A1.333 1.333 0 018.667 2v2.667a.667.667 0 00.666.666h3.764a1.334 1.334 0 011.192 1.93l-2.333 4.666a1.333 1.333 0 01-1.193.738H4.667m0-5.334v5.334m0-5.334H2.667a1.333 1.333 0 00-1.334 1.334v2.666a1.333 1.333 0 001.334 1.334h2",
856
- stroke: "currentColor",
857
- strokeWidth: "1.33",
858
- strokeLinecap: "round",
859
- strokeLinejoin: "round",
860
- fill: t ? "currentColor" : "none"
861
- }
862
- ) }), Js = ({ filled: t }) => /* @__PURE__ */ e("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", children: /* @__PURE__ */ e(
863
- "path",
864
- {
865
- d: "M11.333 8.667l-2.666 6A1.333 1.333 0 017.333 14v-2.667a.667.667 0 00-.666-.666H2.903a1.334 1.334 0 01-1.192-1.93l2.333-4.666a1.333 1.333 0 011.193-.738h6.096m0 5.334V3.333m0 5.334h2a1.333 1.333 0 001.334-1.334V4.667a1.333 1.333 0 00-1.334-1.334h-2",
866
- stroke: "currentColor",
867
- strokeWidth: "1.33",
868
- strokeLinecap: "round",
869
- strokeLinejoin: "round",
870
- fill: t ? "currentColor" : "none"
871
- }
872
- ) }), Qs = ({
873
- selected: t,
874
- onVoteUp: s,
875
- onVoteDown: n
876
- }) => /* @__PURE__ */ l("div", { className: "message-vote-buttons", children: [
877
- /* @__PURE__ */ e(
878
- "button",
879
- {
880
- type: "button",
881
- className: `message-vote-button${t === "up" ? " message-vote-button--selected" : ""} focus-ring`,
882
- onClick: s,
883
- "aria-label": "Helpful",
884
- "aria-pressed": t === "up",
885
- children: /* @__PURE__ */ e(Ks, { filled: t === "up" })
886
- }
887
- ),
888
- /* @__PURE__ */ e(
889
- "button",
890
- {
891
- type: "button",
892
- className: `message-vote-button${t === "down" ? " message-vote-button--selected" : ""} focus-ring`,
893
- onClick: n,
894
- "aria-label": "Not helpful",
895
- "aria-pressed": t === "down",
896
- children: /* @__PURE__ */ e(Js, { filled: t === "down" })
897
- }
898
- )
899
- ] }), en = (t) => {
900
- var ce, ne, ye, Ne, we, de, Ce, _e, Ee, ue, M, W, B, H;
901
- const {
902
- additionalMessageInputProps: s,
903
- chatbotVotingEnabled: n,
904
- editing: o,
905
- endOfGroup: i,
906
- firstOfGroup: u,
907
- groupedByUser: r,
908
- handleAction: c,
909
- handleOpenThread: f,
910
- handleRetry: m,
911
- highlighted: g,
912
- isMessageAIGenerated: b,
913
- isMyMessage: N,
914
- message: a,
915
- renderText: w,
916
- threadList: y
917
- } = t, { client: x } = ot("CustomMessage"), { channel: E } = fe("CustomMessage"), { isUnlocking: v, onUnlockClick: I, onFetchSource: k, onDownloadClick: P } = Xs("LockedAttachment"), [p, d] = S(!1), C = Mt(a.id), { selected: _, voteUp: T, voteDown: L } = Gs(a), {
918
- Attachment: D = Tt,
919
- EditMessageModal: G = Dt,
920
- MessageBlocked: ee = Rt,
921
- MessageBouncePrompt: q = Lt,
922
- MessageDeleted: $ = Pt,
923
- MessageIsThreadReplyInChannelButtonIndicator: F = Ft,
924
- MessageRepliesCountButton: J = At,
925
- ReminderNotification: Z = Ot,
926
- StreamedMessageText: Q = Ut,
927
- PinIndicator: h
928
- } = it("CustomMessage"), R = Bt(a), O = zt(a), V = Ue(
929
- () => b == null ? void 0 : b(a),
930
- [b, a]
931
- ), j = Ue(
932
- () => !a.shared_location && !a.attachments ? [] : a.shared_location ? [a.shared_location, ...a.attachments ?? []] : a.attachments,
933
- [a]
934
- );
935
- if ($t(a))
936
- return null;
937
- if (a.deleted_at || a.type === "deleted")
938
- return /* @__PURE__ */ e($, { message: a });
939
- if (jt(a))
940
- return /* @__PURE__ */ e(ee, {});
941
- const se = !y && !!a.reply_count, ie = !y && a.show_in_channel && a.parent_id, be = a.status === "failed" && ((ce = a.error) == null ? void 0 : ce.status) !== 403, Re = Gt(a);
942
- let Y;
943
- be ? Y = () => m(a) : Re && (Y = () => d(!0));
944
- const te = N(), xe = U(
945
- "str-chat__message str-chat__message-simple",
946
- `str-chat__message--${a.type}`,
947
- `str-chat__message--${a.status}`,
948
- te ? "str-chat__message--me str-chat__message-simple--me" : "str-chat__message--other",
949
- a.text ? "str-chat__message--has-text" : "has-no-text",
950
- {
951
- "str-chat__message--has-attachment": R,
952
- "str-chat__message--highlighted": g,
953
- "str-chat__message--pinned pinned-message": a.pinned,
954
- "str-chat__message--with-reactions": O,
955
- "str-chat__message-send-can-be-retried": (a == null ? void 0 : a.status) === "failed" && ((ne = a == null ? void 0 : a.error) == null ? void 0 : ne.status) !== 403,
956
- "str-chat__message-with-thread-link": se || ie,
957
- "str-chat__virtual-message__wrapper--end": i,
958
- "str-chat__virtual-message__wrapper--first": u,
959
- "str-chat__virtual-message__wrapper--group": r
960
- }
961
- ), ae = a.poll_id && x.polls.fromState(a.poll_id), me = Us(a), le = Ge(a), pe = Os(a), ge = !!(j != null && j.length && !a.quoted_message), ve = le && te && ge;
962
- return /* @__PURE__ */ l(re, { children: [
963
- o && /* @__PURE__ */ e(
964
- G,
965
- {
966
- additionalMessageInputProps: s
967
- }
968
- ),
969
- p && /* @__PURE__ */ e(
970
- Ht,
971
- {
972
- MessageBouncePrompt: q,
973
- onClose: () => d(!1),
974
- open: p
975
- }
976
- ),
977
- /* @__PURE__ */ l("div", { className: xe, children: [
978
- h && /* @__PURE__ */ e(h, {}),
979
- !!C && /* @__PURE__ */ e(Z, { reminder: C }),
980
- a.user && /* @__PURE__ */ e(
981
- oe,
982
- {
983
- className: "str-chat__avatar str-chat__message-sender-avatar",
984
- id: a.user.id,
985
- image: a.user.image,
986
- name: a.user.name || a.user.id
987
- }
988
- ),
989
- /* @__PURE__ */ e(
990
- "div",
991
- {
992
- className: U("str-chat__message-inner", {
993
- "str-chat__simple-message--error-failed": be || Re
994
- }),
995
- "data-testid": "message-inner",
996
- onClick: Y,
997
- onKeyDown: Y,
998
- role: Y ? "button" : void 0,
999
- tabIndex: Y ? 0 : void 0,
1000
- style: {
1001
- // Force margins to 0 to prevent hover layout shift
1002
- // Stream Chat CSS sets margin-inline-end/start to 78px, then 0 on hover
1003
- marginInlineEnd: 0,
1004
- marginInlineStart: 0
1005
- },
1006
- children: pe ? /* @__PURE__ */ l("div", { className: `flex flex-col gap-1 ${te ? "items-end" : "items-start"}`, children: [
1007
- te ? /* @__PURE__ */ e(
1008
- et.Creator,
1009
- {
1010
- title: (ye = a.metadata) == null ? void 0 : ye.attachment_title,
1011
- mimeType: (Ne = a.metadata) == null ? void 0 : Ne.attachment_mime_type,
1012
- thumbnailUrl: (we = a.metadata) == null ? void 0 : we.attachment_thumbnail,
1013
- amountText: (de = a.metadata) == null ? void 0 : de.amount_text,
1014
- detail: (Ce = a.metadata) == null ? void 0 : Ce.attachment_detail,
1015
- paymentStatus: (_e = a.metadata) == null ? void 0 : _e.payment_status
1016
- }
1017
- ) : /* @__PURE__ */ e(
1018
- et.Visitor,
1019
- {
1020
- title: (Ee = a.metadata) == null ? void 0 : Ee.attachment_title,
1021
- mimeType: (ue = a.metadata) == null ? void 0 : ue.attachment_mime_type,
1022
- thumbnailUrl: (M = a.metadata) == null ? void 0 : M.attachment_thumbnail,
1023
- amountText: (W = a.metadata) == null ? void 0 : W.amount_text,
1024
- detail: (B = a.metadata) == null ? void 0 : B.attachment_detail,
1025
- paymentStatus: (H = a.metadata) == null ? void 0 : H.payment_status,
1026
- isUnlocking: v(a.id),
1027
- onUnlockClick: () => I == null ? void 0 : I(a, E),
1028
- onFetchSource: async () => await (k == null ? void 0 : k(a, E)),
1029
- onDownloadClick: () => P == null ? void 0 : P(a, E)
1030
- }
1031
- ),
1032
- a.text && /* @__PURE__ */ e("div", { className: "str-chat__message-bubble-wrapper", children: /* @__PURE__ */ e("div", { className: "str-chat__message-bubble", children: /* @__PURE__ */ e(Ye, { message: a, renderText: w }) }) })
1033
- ] }) : me ? (
1034
- /* Tip-only messages render as a standalone bubble */
1035
- /* @__PURE__ */ e(Ae, { message: a, standalone: !0 })
1036
- ) : /* @__PURE__ */ l("div", { className: "str-chat__message-bubble-wrapper", children: [
1037
- /* @__PURE__ */ l("div", { className: "str-chat__message-bubble", children: [
1038
- le && !ve && /* @__PURE__ */ e(
1039
- Ae,
1040
- {
1041
- message: a,
1042
- hasAttachment: ge,
1043
- isMyMessage: te
1044
- }
1045
- ),
1046
- ae && /* @__PURE__ */ e(Vt, { poll: ae }),
1047
- j != null && j.length && !a.quoted_message ? /* @__PURE__ */ e(
1048
- D,
1049
- {
1050
- actionHandler: c,
1051
- attachments: j
1052
- }
1053
- ) : null,
1054
- V ? /* @__PURE__ */ e(
1055
- Q,
1056
- {
1057
- message: a,
1058
- renderText: w
1059
- }
1060
- ) : /* @__PURE__ */ e(Ye, { message: a, renderText: w }),
1061
- /* @__PURE__ */ e(Yt, {})
1062
- ] }),
1063
- (!le || ve) && /* @__PURE__ */ e(
1064
- Ae,
1065
- {
1066
- message: a,
1067
- hasAttachment: ge,
1068
- isMyMessage: te
1069
- }
1070
- ),
1071
- n && le && /* @__PURE__ */ e(
1072
- Qs,
1073
- {
1074
- selected: _,
1075
- onVoteUp: T,
1076
- onVoteDown: L
1077
- }
1078
- )
1079
- ] })
1080
- }
1081
- ),
1082
- se && /* @__PURE__ */ e(
1083
- J,
1084
- {
1085
- onClick: f,
1086
- reply_count: a.reply_count
1087
- }
1088
- ),
1089
- ie && /* @__PURE__ */ e(F, {})
1090
- ] }, a.id)
1091
- ] });
1092
- }, tn = z.memo(
1093
- en,
1094
- (t, s) => t.chatbotVotingEnabled !== s.chatbotVotingEnabled ? !1 : kt(t, s)
1095
- ), sn = (t) => {
1096
- const s = lt("CustomMessage");
1097
- return /* @__PURE__ */ e(tn, { ...s, ...t });
1098
- }, nn = (t) => ({
1099
- linkPreviews: Array.from(t.previews.values()).filter(
1100
- (s) => Je.previewIsLoaded(s) || Je.previewIsLoading(s)
1101
- )
1102
- }), an = ({
1103
- link: t,
1104
- onDismiss: s
1105
- }) => {
1106
- const { og_scrape_url: n, title: o, image_url: i } = t;
1107
- return /* @__PURE__ */ l(
1108
- "a",
1109
- {
1110
- href: n,
1111
- target: "_blank",
1112
- rel: "noopener noreferrer",
1113
- className: "relative w-full block rounded-[24px] bg-[#121110] p-2 no-underline transition-opacity hover:opacity-90",
1114
- children: [
1115
- i && /* @__PURE__ */ e(
1116
- "img",
1117
- {
1118
- src: i,
1119
- alt: o || "",
1120
- className: "h-[148px] w-full rounded-[20px] object-cover"
1121
- }
1122
- ),
1123
- /* @__PURE__ */ e(
1124
- "button",
1125
- {
1126
- type: "button",
1127
- onClick: (r) => {
1128
- r.preventDefault(), s(n);
1129
- },
1130
- className: "absolute right-4 top-4 flex size-6 items-center justify-center rounded-full border border-white/40 bg-white/70 backdrop-blur-2xl focus-ring",
1131
- "aria-label": "Close link preview",
1132
- children: /* @__PURE__ */ e(je, { className: "size-4 text-black/90" })
1133
- }
1134
- ),
1135
- /* @__PURE__ */ l("div", { className: "p-2", children: [
1136
- o && /* @__PURE__ */ e("div", { className: "text-[14px] font-medium leading-5 text-white", children: o }),
1137
- /* @__PURE__ */ e("div", { className: "text-[12px] leading-4 text-white/55", children: n })
1138
- ] })
1139
- ]
1140
- }
1141
- );
1142
- }, rn = () => {
1143
- const { linkPreviewsManager: t } = Wt(), { linkPreviews: s } = qt(
1144
- t.state,
1145
- nn
1146
- ), n = (i) => {
1147
- t.dismissPreview(i);
1148
- };
1149
- return s.length > 0 ? /* @__PURE__ */ e("div", { className: "flex flex-col items-center w-full gap-2 mb-4", children: s.map((i) => /* @__PURE__ */ e(
1150
- an,
1151
- {
1152
- link: i,
1153
- onDismiss: n
1154
- },
1155
- i.og_scrape_url
1156
- )) }) : null;
1157
- }, on = ({ sendMessage: t, disabled: s, ...n }) => /* @__PURE__ */ e(
1158
- "button",
1159
- {
1160
- ...n,
1161
- type: "button",
1162
- "aria-label": "Send",
1163
- disabled: s,
1164
- onClick: t,
1165
- children: /* @__PURE__ */ e(cs, { weight: "bold", className: "size-4" })
1166
- }
1167
- ), ln = () => {
1168
- var c;
1169
- const { channel: t } = fe(), s = ((c = t == null ? void 0 : t.data) == null ? void 0 : c.frozen) === !0, { handleSubmit: n } = Xt(), { SendButton: o } = it(
1170
- "CustomMessageInput"
1171
- ), i = o ?? on, u = Kt();
1172
- return /* @__PURE__ */ l(re, { children: [
1173
- /* @__PURE__ */ e("div", { className: "left-container", children: /* @__PURE__ */ e(Jt, {}) }),
1174
- /* @__PURE__ */ l("div", { className: "central-container min-w-0 w-full p-2 bg-white rounded-[1.5rem] shadow-[0_4px_16px_0_rgba(0,0,0,0.08),0_1px_2px_0_rgba(0,0,0,0.04),0_0_0_1px_rgba(0,0,0,0.04)]", children: [
1175
- /* @__PURE__ */ e(Qt, {}),
1176
- /* @__PURE__ */ e(rn, {}),
1177
- /* @__PURE__ */ e(es, {}),
1178
- /* @__PURE__ */ l("div", { className: "flex", children: [
1179
- /* @__PURE__ */ e("div", { className: "w-full ml-2 mr-4 self-center leading-[0]", children: /* @__PURE__ */ e(
1180
- ts,
1181
- {
1182
- "aria-disabled": s || void 0,
1183
- className: "w-full resize-none outline-none leading-6",
1184
- autoFocus: !s,
1185
- maxRows: 4,
1186
- readOnly: s,
1187
- tabIndex: s ? -1 : void 0
1188
- }
1189
- ) }),
1190
- /* @__PURE__ */ e(
1191
- i,
1192
- {
1193
- sendMessage: n,
1194
- "aria-label": "Send",
1195
- className: "str-chat__send-button mt-auto flex justify-center items-center flex-shrink-0 rounded-full size-8 bg-[#121110] disabled:bg-[#F1F0EE] disabled:text-black/20 text-white focus-ring",
1196
- "data-testid": "send-button",
1197
- disabled: s || !u,
1198
- type: "button"
1199
- }
1200
- )
1201
- ] })
1202
- ] })
1203
- ] });
1204
- }, cn = ({
1205
- renderActions: t
1206
- }) => {
1207
- var o;
1208
- const { channel: s } = fe(), n = ((o = s == null ? void 0 : s.data) == null ? void 0 : o.frozen) === !0;
1209
- return /* @__PURE__ */ l(
1210
- "div",
1211
- {
1212
- inert: n ? "" : void 0,
1213
- "aria-disabled": n || void 0,
1214
- className: "message-input flex items-center gap-2 p-4 aria-disabled:opacity-40",
1215
- children: [
1216
- t == null ? void 0 : t(),
1217
- /* @__PURE__ */ e(Zt, { Input: ln })
1218
- ]
1219
- }
1220
- );
1221
- }, dn = [
1222
- "SYSTEM_DM_AGENT_PAUSED",
1223
- "SYSTEM_DM_AGENT_RESUMED"
1224
- ], un = {
1225
- SYSTEM_DM_AGENT_PAUSED: "DM Agent has left the conversation",
1226
- SYSTEM_DM_AGENT_RESUMED: "DM Agent has rejoined the conversation"
1227
- }, mn = [
1228
- "SYSTEM_AGE_SAFETY_BLOCKED"
1229
- ], hn = {
1230
- SYSTEM_AGE_SAFETY_BLOCKED: "This user isnโ€™t able to reply because they donโ€™t meet our age safety guidelines."
1231
- }, Oe = "age safety guidelines.", fn = "https://linktr.ee/s/about/contact", tt = (t) => dn.includes(t), gn = (t) => mn.includes(t), bn = (t) => {
1232
- var o;
1233
- const s = (o = t.metadata) == null ? void 0 : o.custom_type;
1234
- if (tt(s))
1235
- return {
1236
- kind: "dm-agent",
1237
- type: s
1238
- };
1239
- if (gn(s))
1240
- return {
1241
- kind: "age-safety",
1242
- type: s
1243
- };
1244
- const n = t.dm_agent_system_type;
1245
- if (tt(n))
1246
- return {
1247
- kind: "dm-agent",
1248
- type: n
1249
- };
1250
- }, xn = (t) => {
1251
- const s = t.indexOf(Oe);
1252
- if (s === -1)
1253
- return t;
1254
- const n = s + Oe.length;
1255
- return /* @__PURE__ */ l(re, { children: [
1256
- t.slice(0, s),
1257
- /* @__PURE__ */ e(
1258
- "a",
1259
- {
1260
- href: fn,
1261
- target: "_blank",
1262
- rel: "noopener noreferrer",
1263
- className: "mes-age-safety-system-message__emphasis font-medium text-inherit underline",
1264
- children: Oe
1265
- }
1266
- ),
1267
- t.slice(n)
1268
- ] });
1269
- }, pn = (t) => {
1270
- var o, i;
1271
- const s = t.message.hide_date === !0, n = bn(
1272
- t.message
1273
- );
1274
- if ((n == null ? void 0 : n.kind) === "dm-agent") {
1275
- const u = ((o = t.message.text) == null ? void 0 : o.trim()) || un[n.type];
1276
- return /* @__PURE__ */ l("div", { className: "str-chat__message--system", "data-testid": "message-system", children: [
1277
- /* @__PURE__ */ l(
1278
- "div",
1279
- {
1280
- className: "mes-dm-agent-system-message mx-auto mb-2 inline-flex w-fit max-w-[min(100%,480px)] items-center justify-center gap-[10px] rounded-[12px] border border-[rgba(0,0,0,0.08)] p-3 text-[rgba(0,0,0,0.55)]",
1281
- "data-testid": "dm-agent-system-message",
1282
- "data-dm-agent-system-type": n.type,
1283
- children: [
1284
- /* @__PURE__ */ e(
1285
- ds,
1286
- {
1287
- size: 16,
1288
- weight: "regular",
1289
- "aria-hidden": !0,
1290
- className: "mes-dm-agent-system-message__sparkle shrink-0"
1291
- }
1292
- ),
1293
- /* @__PURE__ */ e("p", { className: "mes-dm-agent-system-message__text m-0 text-center text-[14px] font-normal leading-5 tracking-[0.21px]", children: u })
1294
- ]
1295
- }
1296
- ),
1297
- !s && /* @__PURE__ */ e(Fe, { message: t.message })
1298
- ] });
1299
- }
1300
- if ((n == null ? void 0 : n.kind) === "age-safety") {
1301
- const u = ((i = t.message.text) == null ? void 0 : i.trim()) || hn[n.type];
1302
- return /* @__PURE__ */ l("div", { className: "str-chat__message--system", "data-testid": "message-system", children: [
1303
- /* @__PURE__ */ l(
1304
- "div",
1305
- {
1306
- className: "mes-age-safety-system-message box-border mx-auto mb-2 flex w-full max-w-[329px] items-start justify-center gap-3 rounded-[12px] border border-[var(--border-secondary,rgba(0,0,0,0.08))] bg-[var(--bg-warning-subtle,#fef3c6)] px-2 py-4 pl-5 text-[color:var(--text-warning-on-warning,#894b00)]",
1307
- "data-testid": "age-safety-system-message",
1308
- "data-age-safety-system-type": n.type,
1309
- children: [
1310
- /* @__PURE__ */ e(
1311
- us,
1312
- {
1313
- size: 24,
1314
- weight: "duotone",
1315
- "aria-hidden": !0,
1316
- className: "mes-age-safety-system-message__icon shrink-0 text-[color:var(--text-warning-on-warning,#894b00)]",
1317
- "data-testid": "age-safety-system-message-icon"
1318
- }
1319
- ),
1320
- /* @__PURE__ */ e("div", { className: "mes-age-safety-system-message__content min-w-0 flex-[1_0_0]", children: /* @__PURE__ */ e("p", { className: "m-0 text-balance text-left text-[12px] font-normal leading-4 tracking-[0.21px] text-[color:var(--text-warning-on-warning,#894b00)]", children: xn(u) }) })
1321
- ]
1322
- }
1323
- ),
1324
- !s && /* @__PURE__ */ e(Fe, { message: t.message })
1325
- ] });
1326
- }
1327
- return /* @__PURE__ */ l("div", { className: "str-chat__message--system", "data-testid": "message-system", children: [
1328
- /* @__PURE__ */ l("div", { className: "str-chat__message--system__text", children: [
1329
- /* @__PURE__ */ e("div", { className: "str-chat__message--system__line" }),
1330
- /* @__PURE__ */ e("p", { children: t.message.text }),
1331
- /* @__PURE__ */ e("div", { className: "str-chat__message--system__line" })
1332
- ] }),
1333
- !s && /* @__PURE__ */ e(Fe, { message: t.message })
1334
- ] });
1335
- }, vn = () => null, yn = ({ className: t, message: s }) => /* @__PURE__ */ l(
1336
- "div",
1337
- {
1338
- className: U("flex items-center justify-center h-full", t),
1339
- children: [
1340
- /* @__PURE__ */ l("svg", { viewBox: "0 0 100 100", className: "size-8 fill-pebble", stroke: "none", children: [
1341
- /* @__PURE__ */ e("circle", { cx: "6", cy: "50", r: "6", children: /* @__PURE__ */ e(
1342
- "animateTransform",
1343
- {
1344
- attributeName: "transform",
1345
- dur: "1s",
1346
- type: "translate",
1347
- values: "0 15 ; 0 -15; 0 15",
1348
- repeatCount: "indefinite",
1349
- begin: "0.1"
1350
- }
1351
- ) }),
1352
- /* @__PURE__ */ e("circle", { cx: "30", cy: "50", r: "6", children: /* @__PURE__ */ e(
1353
- "animateTransform",
1354
- {
1355
- attributeName: "transform",
1356
- dur: "1s",
1357
- type: "translate",
1358
- values: "0 10 ; 0 -10; 0 10",
1359
- repeatCount: "indefinite",
1360
- begin: "0.2"
1361
- }
1362
- ) }),
1363
- /* @__PURE__ */ e("circle", { cx: "54", cy: "50", r: "6", children: /* @__PURE__ */ e(
1364
- "animateTransform",
1365
- {
1366
- attributeName: "transform",
1367
- dur: "1s",
1368
- type: "translate",
1369
- values: "0 5 ; 0 -5; 0 5",
1370
- repeatCount: "indefinite",
1371
- begin: "0.3"
1372
- }
1373
- ) })
1374
- ] }),
1375
- s && /* @__PURE__ */ e("span", { className: "text-stone", children: s })
1376
- ]
1377
- }
1378
- ), Me = z.memo(() => /* @__PURE__ */ e("div", { className: "messaging-loading-state flex items-center justify-center h-full", children: /* @__PURE__ */ l("div", { className: "flex items-center", children: [
1379
- /* @__PURE__ */ e(yn, { className: "w-6 h-6" }),
1380
- /* @__PURE__ */ e("span", { className: "text-sm text-stone", children: "Loading messages" })
1381
- ] }) }));
1382
- Me.displayName = "LoadingState";
1383
- const he = "size-10 rounded-full bg-[#F1F0EE] hover:bg-[#E5E4E1] flex items-center justify-center transition-colors duration-150 focus-ring", Nn = ({
1384
- onBack: t,
1385
- showBackButton: s,
1386
- onShowInfo: n,
1387
- canShowInfo: o,
1388
- showStarButton: i = !1
1389
- }) => {
1390
- var b, N, a, w, y;
1391
- const { channel: u } = fe(), r = z.useMemo(() => Object.values(u.state.members || {}).find(
1392
- (E) => {
1393
- var v;
1394
- return ((v = E.user) == null ? void 0 : v.id) && E.user.id !== u._client.userID;
1395
- }
1396
- ), [u._client.userID, u.state.members]), c = ((b = r == null ? void 0 : r.user) == null ? void 0 : b.name) || ((N = r == null ? void 0 : r.user) == null ? void 0 : N.id) || "Unknown member", f = (a = r == null ? void 0 : r.user) == null ? void 0 : a.image, m = mt(u), g = async () => {
1397
- try {
1398
- m ? await u.unpin() : await u.pin();
1399
- } catch (x) {
1400
- console.error(
1401
- "[CustomChannelHeader] Failed to update pinned status:",
1402
- x
1403
- );
1404
- }
1405
- };
1406
- return /* @__PURE__ */ l("div", { className: "@container", children: [
1407
- /* @__PURE__ */ l("div", { className: "grid grid-cols-[1fr_auto_1fr] w-full items-center @lg:hidden", children: [
1408
- /* @__PURE__ */ e("div", { className: "flex items-center gap-2", children: s && /* @__PURE__ */ e(
1409
- "button",
1410
- {
1411
- className: he,
1412
- onClick: t || (() => {
1413
- }),
1414
- type: "button",
1415
- "aria-label": "Back to conversations",
1416
- children: /* @__PURE__ */ e(qe, { className: "size-5 text-black/90" })
1417
- }
1418
- ) }),
1419
- /* @__PURE__ */ l("div", { className: "flex flex-col gap-1 items-center", children: [
1420
- /* @__PURE__ */ e(
1421
- oe,
1422
- {
1423
- id: ((w = r == null ? void 0 : r.user) == null ? void 0 : w.id) || u.id || "unknown",
1424
- name: c,
1425
- image: f,
1426
- starred: i && m,
1427
- size: 40
1428
- }
1429
- ),
1430
- /* @__PURE__ */ e("h1", { className: "text-xs font-medium text-black/90", children: c })
1431
- ] }),
1432
- /* @__PURE__ */ l("div", { className: "flex justify-end items-center gap-2", children: [
1433
- i && /* @__PURE__ */ e(
1434
- "button",
1435
- {
1436
- className: he,
1437
- onClick: g,
1438
- type: "button",
1439
- "aria-label": m ? "Unstar conversation" : "Star conversation",
1440
- children: /* @__PURE__ */ e(
1441
- Be,
1442
- {
1443
- className: U("size-5", {
1444
- "text-yellow-600": m,
1445
- "text-black/90": !m
1446
- }),
1447
- weight: m ? "duotone" : "regular"
1448
- }
1449
- )
1450
- }
1451
- ),
1452
- /* @__PURE__ */ e(
1453
- "button",
1454
- {
1455
- className: he,
1456
- onClick: n,
1457
- type: "button",
1458
- "aria-label": "Show info",
1459
- children: /* @__PURE__ */ e(Ze, { className: "size-5 text-black/90" })
1460
- }
1461
- )
1462
- ] })
1463
- ] }),
1464
- /* @__PURE__ */ l("div", { className: "hidden @lg:flex items-center justify-between gap-3 min-h-12", children: [
1465
- /* @__PURE__ */ l("div", { className: "flex items-center gap-4 min-w-0", children: [
1466
- s && t && /* @__PURE__ */ e(
1467
- "button",
1468
- {
1469
- type: "button",
1470
- onClick: t,
1471
- className: he,
1472
- "aria-label": "Back to conversations",
1473
- children: /* @__PURE__ */ e(qe, { className: "size-5 text-black/90" })
1474
- }
1475
- ),
1476
- /* @__PURE__ */ e(
1477
- oe,
1478
- {
1479
- id: ((y = r == null ? void 0 : r.user) == null ? void 0 : y.id) || u.id || "unknown",
1480
- name: c,
1481
- image: f,
1482
- starred: i && m,
1483
- size: 40
1484
- }
1485
- ),
1486
- /* @__PURE__ */ e("div", { className: "min-w-0", children: /* @__PURE__ */ e("h1", { className: "font-medium text-black/90 truncate", children: c }) })
1487
- ] }),
1488
- /* @__PURE__ */ l("div", { className: "flex items-center gap-2", children: [
1489
- i && /* @__PURE__ */ e(
1490
- "button",
1491
- {
1492
- className: he,
1493
- onClick: g,
1494
- type: "button",
1495
- "aria-label": m ? "Unstar conversation" : "Star conversation",
1496
- children: /* @__PURE__ */ e(
1497
- Be,
1498
- {
1499
- className: U("size-5", {
1500
- "text-yellow-600": m,
1501
- "text-black/90": !m
1502
- }),
1503
- weight: m ? "duotone" : "regular"
1504
- }
1505
- )
1506
- }
1507
- ),
1508
- o && n && /* @__PURE__ */ e(
1509
- "button",
1510
- {
1511
- className: he,
1512
- onClick: n,
1513
- type: "button",
1514
- "aria-label": "Show info",
1515
- children: /* @__PURE__ */ e(Ze, { className: "size-5 text-black/90" })
1516
- }
1517
- )
1518
- ] })
1519
- ] })
1520
- ] });
1521
- }, wn = ({
1522
- onBack: t,
1523
- showBackButton: s,
1524
- renderMessageInputActions: n,
1525
- renderConversationFooter: o,
1526
- onLeaveConversation: i,
1527
- onBlockParticipant: u,
1528
- showDeleteConversation: r = !0,
1529
- onDeleteConversationClick: c,
1530
- onBlockParticipantClick: f,
1531
- onReportParticipantClick: m,
1532
- showStarButton: g = !1,
1533
- chatbotVotingEnabled: b = !1,
1534
- renderChannelBanner: N,
1535
- customProfileContent: a,
1536
- customChannelActions: w,
1537
- renderMessage: y
1538
- }) => {
1539
- const { channel: x } = fe(), E = K(null), v = z.useMemo(() => Object.values(x.state.members || {}).find(
1540
- (C) => {
1541
- var _;
1542
- return ((_ = C.user) == null ? void 0 : _.id) && C.user.id !== x._client.userID;
1543
- }
1544
- ), [x._client.userID, x.state.members]), I = z.useMemo(() => {
1545
- const d = x.data ?? {};
1546
- if (d.followerStatus)
1547
- return String(d.followerStatus);
1548
- if (d.isFollower !== void 0)
1549
- return d.isFollower ? "Subscribed to you" : "Not subscribed";
1550
- }, [x.data]), k = A(() => {
1551
- var d;
1552
- (d = E.current) == null || d.showModal();
1553
- }, []), P = A(() => {
1554
- var d;
1555
- (d = E.current) == null || d.close();
1556
- }, []), p = A(
1557
- (d) => {
1558
- const { message: C } = lt("ChannelView"), _ = /* @__PURE__ */ e(
1559
- sn,
1560
- {
1561
- ...d,
1562
- chatbotVotingEnabled: b
1563
- }
1564
- );
1565
- return !y || !C ? _ : y(_, C);
1566
- },
1567
- [b, y]
1568
- );
1569
- return /* @__PURE__ */ l(re, { children: [
1570
- /* @__PURE__ */ e(ns, { overrides: { Message: p }, children: /* @__PURE__ */ l(as, { children: [
1571
- /* @__PURE__ */ e("div", { className: "p-4", children: /* @__PURE__ */ e(
1572
- Nn,
1573
- {
1574
- onBack: t,
1575
- showBackButton: s,
1576
- onShowInfo: k,
1577
- canShowInfo: !!v,
1578
- showStarButton: g
1579
- }
1580
- ) }),
1581
- N == null ? void 0 : N(),
1582
- /* @__PURE__ */ e("div", { className: "flex-1 overflow-hidden relative", children: /* @__PURE__ */ e(
1583
- rs,
1584
- {
1585
- hideDeletedMessages: !0,
1586
- hideNewMessageSeparator: !1,
1587
- messageActions: void 0
1588
- }
1589
- ) }),
1590
- o == null ? void 0 : o(x),
1591
- /* @__PURE__ */ e(
1592
- cn,
1593
- {
1594
- renderActions: () => n == null ? void 0 : n(x)
1595
- }
1596
- )
1597
- ] }) }),
1598
- /* @__PURE__ */ e(
1599
- zs,
1600
- {
1601
- dialogRef: E,
1602
- onClose: P,
1603
- participant: v,
1604
- channel: x,
1605
- followerStatusLabel: I,
1606
- onLeaveConversation: i,
1607
- onBlockParticipant: u,
1608
- showDeleteConversation: r,
1609
- onDeleteConversationClick: c,
1610
- onBlockParticipantClick: f,
1611
- onReportParticipantClick: m,
1612
- customProfileContent: a,
1613
- customChannelActions: w
1614
- }
1615
- )
1616
- ] });
1617
- }, yt = z.memo(
1618
- ({
1619
- channel: t,
1620
- onBack: s,
1621
- showBackButton: n = !1,
1622
- renderMessageInputActions: o,
1623
- renderConversationFooter: i,
1624
- onLeaveConversation: u,
1625
- onBlockParticipant: r,
1626
- className: c,
1627
- CustomChannelEmptyState: f = vn,
1628
- showDeleteConversation: m = !0,
1629
- onDeleteConversationClick: g,
1630
- onBlockParticipantClick: b,
1631
- onReportParticipantClick: N,
1632
- dmAgentEnabled: a,
1633
- messageMetadata: w,
1634
- onMessageSent: y,
1635
- showStarButton: x = !1,
1636
- chatbotVotingEnabled: E = !1,
1637
- renderChannelBanner: v,
1638
- customProfileContent: I,
1639
- customChannelActions: k,
1640
- renderMessage: P,
1641
- sendButton: p
1642
- }) => {
1643
- const d = A(
1644
- async (C, _, T) => {
1645
- var $;
1646
- const L = (($ = t.data) == null ? void 0 : $.chatbot_paused) === !0, D = a && !L, G = {
1647
- ..._,
1648
- ...D && { silent: !0 },
1649
- ...w && {
1650
- metadata: {
1651
- ..._.metadata ?? {},
1652
- ...w
1653
- }
1654
- }
1655
- }, ee = {
1656
- ...T,
1657
- ...D && { skip_push: !0 }
1658
- }, q = await t.sendMessage(G, ee);
1659
- return y == null || y(q), q;
1660
- },
1661
- [t, a, w, y]
1662
- );
1663
- return /* @__PURE__ */ e(
1664
- "div",
1665
- {
1666
- className: U(
1667
- "messaging-channel-view h-full flex flex-col",
1668
- c
1669
- ),
1670
- children: /* @__PURE__ */ e(
1671
- ss,
1672
- {
1673
- channel: t,
1674
- MessageSystem: pn,
1675
- EmptyStateIndicator: f,
1676
- LoadingIndicator: Me,
1677
- DateSeparator: $s,
1678
- doSendMessageRequest: d,
1679
- ...p ? { SendButton: p } : {},
1680
- children: /* @__PURE__ */ e(
1681
- wn,
1682
- {
1683
- onBack: s,
1684
- showBackButton: n,
1685
- renderMessageInputActions: o,
1686
- renderConversationFooter: i,
1687
- onLeaveConversation: u,
1688
- onBlockParticipant: r,
1689
- CustomChannelEmptyState: f,
1690
- showDeleteConversation: m,
1691
- onDeleteConversationClick: g,
1692
- onBlockParticipantClick: b,
1693
- onReportParticipantClick: N,
1694
- showStarButton: x,
1695
- chatbotVotingEnabled: E,
1696
- renderChannelBanner: v,
1697
- customProfileContent: I,
1698
- customChannelActions: k,
1699
- renderMessage: P
1700
- }
1701
- )
1702
- }
1703
- )
1704
- }
1705
- );
1706
- }
1707
- );
1708
- yt.displayName = "ChannelView";
1709
- function Cn({
1710
- searchQuery: t,
1711
- setSearchQuery: s,
1712
- placeholder: n
1713
- }) {
1714
- const o = K(null);
1715
- return /* @__PURE__ */ l("div", { className: "relative", children: [
1716
- /* @__PURE__ */ e(
1717
- ms,
1718
- {
1719
- className: "pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-stone",
1720
- weight: "bold"
1721
- }
1722
- ),
1723
- /* @__PURE__ */ e(
1724
- "input",
1725
- {
1726
- ref: o,
1727
- type: "text",
1728
- placeholder: n,
1729
- value: t,
1730
- onChange: (i) => s(i.target.value),
1731
- className: "w-full pl-10 pr-10 py-3 text-sm border border-sand rounded-xl focus:outline-none focus:ring-2 focus:ring-black focus:border-transparent"
1732
- }
1733
- ),
1734
- t && /* @__PURE__ */ e(
1735
- bt,
1736
- {
1737
- label: "Clear search",
1738
- onClick: () => {
1739
- var i;
1740
- s(""), (i = o.current) == null || i.focus();
1741
- },
1742
- className: "absolute right-3 top-1/2 -translate-y-1/2 p-1 text-stone hover:text-charcoal",
1743
- children: /* @__PURE__ */ e(je, { className: "h-4 w-4", weight: "bold" })
1744
- }
1745
- )
1746
- ] });
1747
- }
1748
- const _n = ({
1749
- participantSource: t,
1750
- onSelectParticipant: s,
1751
- onClose: n,
1752
- existingParticipantIds: o = /* @__PURE__ */ new Set(),
1753
- participantLabel: i = "participants",
1754
- searchPlaceholder: u = "Search participants...",
1755
- className: r
1756
- }) => {
1757
- const { debug: c } = De(), [f, m] = S(""), [g, b] = S([]), [N, a] = S(!1), [w, y] = S(null), [x, E] = S(
1758
- null
1759
- ), v = K(!1);
1760
- X(() => {
1761
- v.current = !1;
1762
- }, [t]), X(() => {
1763
- if (t.loading) {
1764
- c && console.log(
1765
- "[ParticipantPicker] Waiting for participant source to finish loading..."
1766
- );
1767
- return;
1768
- }
1769
- if (v.current) return;
1770
- (async () => {
1771
- c && console.log("[ParticipantPicker] Loading initial participants..."), a(!0), y(null);
1772
- try {
1773
- const d = await t.loadParticipants({
1774
- search: "",
1775
- // Load all participants initially
1776
- limit: 100
1777
- });
1778
- b(d.participants), v.current = !0, c && console.log(
1779
- "[ParticipantPicker] Participants loaded successfully:",
1780
- d.participants.length
1781
- );
1782
- } catch (d) {
1783
- const C = d instanceof Error ? d.message : "Failed to load participants";
1784
- y(C), console.error("[ParticipantPicker] Failed to load participants:", d);
1785
- } finally {
1786
- a(!1);
1787
- }
1788
- })();
1789
- }, [t, c]);
1790
- const I = g.filter((p) => !o.has(p.id)).filter((p) => {
1791
- var C;
1792
- if (!f) return !0;
1793
- const d = f.toLowerCase();
1794
- return p.name.toLowerCase().includes(d) || ((C = p.email) == null ? void 0 : C.toLowerCase().includes(d)) || !1;
1795
- }), k = A(
1796
- async (p) => {
1797
- if (!x) {
1798
- E(p.id);
1799
- try {
1800
- await s(p);
1801
- } catch (d) {
1802
- console.error("[ParticipantPicker] Failed to start chat:", d), E(null);
1803
- }
1804
- }
1805
- },
1806
- [s, x]
1807
- ), P = (p, d) => {
1808
- (p.key === "Enter" || p.key === " ") && (p.preventDefault(), k(d));
1809
- };
1810
- return /* @__PURE__ */ l("div", { className: U("flex flex-col h-full", r), children: [
1811
- /* @__PURE__ */ l("div", { className: "px-4 py-4 border-b border-sand bg-chalk", children: [
1812
- /* @__PURE__ */ l("div", { className: "flex items-center justify-between mb-3", children: [
1813
- /* @__PURE__ */ e("h2", { className: "text-lg font-semibold text-charcoal", children: "Start a new Conversation" }),
1814
- /* @__PURE__ */ e(xt, { onClick: n })
1815
- ] }),
1816
- /* @__PURE__ */ l("p", { className: "text-xs text-stone mb-3", children: [
1817
- "Select a ",
1818
- i.slice(0, -1),
1819
- " to start messaging (",
1820
- I.length,
1821
- " available)",
1822
- t.totalCount !== void 0 && ` โ€ข ${t.totalCount} ${i} total`
1823
- ] }),
1824
- /* @__PURE__ */ e(
1825
- Cn,
1826
- {
1827
- searchQuery: f,
1828
- setSearchQuery: m,
1829
- placeholder: u
1830
- }
1831
- )
1832
- ] }),
1833
- w && /* @__PURE__ */ l("div", { className: "p-4 text-sm text-danger bg-danger-alt", children: [
1834
- "Error loading ",
1835
- i,
1836
- ": ",
1837
- w
1838
- ] }),
1839
- /* @__PURE__ */ e("div", { className: "flex-1 overflow-auto", children: N && I.length === 0 ? /* @__PURE__ */ e("div", { className: "h-32 flex items-center justify-center", children: /* @__PURE__ */ l("div", { className: "flex items-center space-x-2", children: [
1840
- /* @__PURE__ */ e("div", { className: "w-4 h-4 animate-spin rounded-full border-2 border-primary border-t-transparent" }),
1841
- /* @__PURE__ */ l("span", { className: "text-sm text-stone", children: [
1842
- "Loading ",
1843
- i,
1844
- "..."
1845
- ] })
1846
- ] }) }) : I.length === 0 ? /* @__PURE__ */ l("div", { className: "p-6 text-center", children: [
1847
- /* @__PURE__ */ e("div", { className: "mx-auto mb-4 flex h-16 w-16 items-center justify-center rounded-full bg-sand", children: /* @__PURE__ */ e(Xe, { className: "h-8 w-8 text-charcoal" }) }),
1848
- /* @__PURE__ */ e("h3", { className: "text-sm font-semibold text-charcoal mb-2", children: f ? `No ${i} found` : g.length > 0 ? `Already chatting with all ${i}` : `No ${i} yet` }),
1849
- /* @__PURE__ */ e("p", { className: "text-xs text-stone", children: f ? "Try a different search term" : g.length > 0 ? `You have existing conversations with all your ${i}` : `${i.charAt(0).toUpperCase() + i.slice(1)} will appear here` })
1850
- ] }) : /* @__PURE__ */ l("ul", { className: "space-y-0", children: [
1851
- I.map((p) => {
1852
- const d = p.name || p.email || p.id, C = p.email && p.name ? p.email : p.phone;
1853
- return /* @__PURE__ */ e("li", { children: /* @__PURE__ */ e(
1854
- "button",
1855
- {
1856
- type: "button",
1857
- onClick: () => k(p),
1858
- onKeyDown: (_) => P(_, p),
1859
- className: "w-full px-4 py-3 hover:bg-sand transition-colors border-b border-sand text-left focus-ring",
1860
- children: /* @__PURE__ */ l("div", { className: "flex items-center justify-between", children: [
1861
- /* @__PURE__ */ l("div", { className: "flex items-center space-x-3 flex-1 min-w-0", children: [
1862
- /* @__PURE__ */ e(
1863
- oe,
1864
- {
1865
- id: p.id,
1866
- name: d,
1867
- image: p.image,
1868
- size: 40
1869
- }
1870
- ),
1871
- /* @__PURE__ */ l("div", { className: "flex-1 min-w-0", children: [
1872
- /* @__PURE__ */ e("h4", { className: "text-sm font-medium text-charcoal truncate", children: d }),
1873
- C && /* @__PURE__ */ e("p", { className: "text-xs text-stone truncate", children: C })
1874
- ] })
1875
- ] }),
1876
- /* @__PURE__ */ e("div", { className: "flex-shrink-0", children: x === p.id ? /* @__PURE__ */ e(Ie, { className: "h-5 w-5 text-primary animate-spin" }) : /* @__PURE__ */ e(Xe, { className: "h-5 w-5 text-stone" }) })
1877
- ] })
1878
- }
1879
- ) }, p.id);
1880
- }),
1881
- N && /* @__PURE__ */ e("li", { className: "p-4 flex justify-center", children: /* @__PURE__ */ l("div", { className: "flex items-center space-x-2", children: [
1882
- /* @__PURE__ */ e("div", { className: "w-4 h-4 animate-spin rounded-full border-2 border-primary border-t-transparent" }),
1883
- /* @__PURE__ */ e("span", { className: "text-sm text-stone", children: "Loading more..." })
1884
- ] }) })
1885
- ] }) })
1886
- ] });
1887
- }, En = ({ className: t }) => /* @__PURE__ */ l(
1888
- "svg",
1889
- {
1890
- width: "140",
1891
- height: "120",
1892
- viewBox: "44 -2 144 126",
1893
- fill: "none",
1894
- xmlns: "http://www.w3.org/2000/svg",
1895
- className: t,
1896
- children: [
1897
- /* @__PURE__ */ l("g", { clipPath: "url(#clip0_empty_state)", children: [
1898
- /* @__PURE__ */ e(
1899
- "path",
1900
- {
1901
- d: "M123.68 82.1932C123.383 103.675 105.839 121 84.2417 121C77.4724 121 71.0986 119.297 65.5327 116.299L52.5873 119.687L53.8036 106.673C48.1776 99.8701 44.7994 91.1453 44.7994 81.6356C44.7994 59.8965 62.4554 42.2754 84.2374 42.2754C89.1328 42.2754 93.8175 43.1633 98.1413 44.789",
1902
- fill: "#D7D4CE"
1903
- }
1904
- ),
1905
- /* @__PURE__ */ e(
1906
- "path",
1907
- {
1908
- d: "M84.2458 86.0364C82.2851 86.0364 80.6957 84.4501 80.6957 82.4933C80.6957 80.5365 82.2851 78.9502 84.2458 78.9502C86.2065 78.9502 87.7959 80.5365 87.7959 82.4933C87.7959 84.4501 86.2065 86.0364 84.2458 86.0364Z",
1909
- fill: "white"
1910
- }
1911
- ),
1912
- /* @__PURE__ */ e(
1913
- "path",
1914
- {
1915
- d: "M68.3044 86.0364C66.3437 86.0364 64.7543 84.4501 64.7543 82.4933C64.7543 80.5365 66.3437 78.9502 68.3044 78.9502C70.2651 78.9502 71.8545 80.5365 71.8545 82.4933C71.8545 84.4501 70.2651 86.0364 68.3044 86.0364Z",
1916
- fill: "white"
1917
- }
1918
- ),
1919
- /* @__PURE__ */ e(
1920
- "path",
1921
- {
1922
- d: "M100.183 86.0364C98.2226 86.0364 96.6332 84.4501 96.6332 82.4933C96.6332 80.5365 98.2226 78.9502 100.183 78.9502C102.144 78.9502 103.733 80.5365 103.733 82.4933C103.733 84.4501 102.144 86.0364 100.183 86.0364Z",
1923
- fill: "white"
1924
- }
1925
- ),
1926
- /* @__PURE__ */ l("g", { filter: "url(#filter0_empty_state)", children: [
1927
- /* @__PURE__ */ e(
1928
- "path",
1929
- {
1930
- d: "M171.522 68.7154C177.443 61.4539 181 52.1488 181 42C181 18.8027 162.421 0 139.5 0C116.579 0 98 18.8027 98 42C98 65.1973 116.579 84 139.5 84C146.622 84 153.328 82.1857 159.184 78.9829L172.801 82.5993L171.522 68.7154Z",
1931
- fill: "white"
1932
- }
1933
- ),
1934
- /* @__PURE__ */ e(
1935
- "path",
1936
- {
1937
- d: "M171.522 68.7154C177.443 61.4539 181 52.1488 181 42C181 18.8027 162.421 0 139.5 0C116.579 0 98 18.8027 98 42C98 65.1973 116.579 84 139.5 84C146.622 84 153.328 82.1857 159.184 78.9829L172.801 82.5993L171.522 68.7154Z",
1938
- stroke: "#D7D4CE",
1939
- strokeWidth: "2",
1940
- strokeMiterlimit: "10"
1941
- }
1942
- )
1943
- ] }),
1944
- /* @__PURE__ */ e(
1945
- "path",
1946
- {
1947
- d: "M139.502 45.5431C137.541 45.5431 135.952 43.9568 135.952 42C135.952 40.0432 137.541 38.4569 139.502 38.4569C141.462 38.4569 143.052 40.0432 143.052 42C143.052 43.9568 141.462 45.5431 139.502 45.5431Z",
1948
- fill: "#D7D4CE"
1949
- }
1950
- ),
1951
- /* @__PURE__ */ e(
1952
- "path",
1953
- {
1954
- d: "M123.561 45.5431C121.601 45.5431 120.011 43.9568 120.011 42C120.011 40.0432 121.601 38.4569 123.561 38.4569C125.522 38.4569 127.111 40.0432 127.111 42C127.111 43.9568 125.522 45.5431 123.561 45.5431Z",
1955
- fill: "#D7D4CE"
1956
- }
1957
- ),
1958
- /* @__PURE__ */ e(
1959
- "path",
1960
- {
1961
- d: "M155.439 45.5431C153.478 45.5431 151.889 43.9568 151.889 42C151.889 40.0432 153.478 38.4569 155.439 38.4569C157.4 38.4569 158.989 40.0432 158.989 42C158.989 43.9568 157.4 45.5431 155.439 45.5431Z",
1962
- fill: "#D7D4CE"
1963
- }
1964
- )
1965
- ] }),
1966
- /* @__PURE__ */ l("defs", { children: [
1967
- /* @__PURE__ */ l(
1968
- "filter",
1969
- {
1970
- id: "filter0_empty_state",
1971
- x: "97",
1972
- y: "-1",
1973
- width: "89",
1974
- height: "90",
1975
- filterUnits: "userSpaceOnUse",
1976
- colorInterpolationFilters: "sRGB",
1977
- children: [
1978
- /* @__PURE__ */ e("feFlood", { floodOpacity: "0", result: "BackgroundImageFix" }),
1979
- /* @__PURE__ */ e(
1980
- "feColorMatrix",
1981
- {
1982
- in: "SourceAlpha",
1983
- type: "matrix",
1984
- values: "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0",
1985
- result: "hardAlpha"
1986
- }
1987
- ),
1988
- /* @__PURE__ */ e("feOffset", { dx: "4", dy: "4" }),
1989
- /* @__PURE__ */ e("feComposite", { in2: "hardAlpha", operator: "out" }),
1990
- /* @__PURE__ */ e(
1991
- "feColorMatrix",
1992
- {
1993
- type: "matrix",
1994
- values: "0 0 0 0 0.8428 0 0 0 0 0.830064 0 0 0 0 0.8095 0 0 0 1 0"
1995
- }
1996
- ),
1997
- /* @__PURE__ */ e(
1998
- "feBlend",
1999
- {
2000
- mode: "normal",
2001
- in2: "BackgroundImageFix",
2002
- result: "effect1_dropShadow"
2003
- }
2004
- ),
2005
- /* @__PURE__ */ e(
2006
- "feBlend",
2007
- {
2008
- mode: "normal",
2009
- in: "SourceGraphic",
2010
- in2: "effect1_dropShadow",
2011
- result: "shape"
2012
- }
2013
- )
2014
- ]
2015
- }
2016
- ),
2017
- /* @__PURE__ */ e("clipPath", { id: "clip0_empty_state", children: /* @__PURE__ */ e("rect", { width: "233", height: "233", fill: "white" }) })
2018
- ] })
2019
- ]
2020
- }
2021
- ), Nt = z.memo(
2022
- ({ hasChannels: t, channelsLoaded: s }) => /* @__PURE__ */ e("div", { className: "messaging-empty-state flex items-center justify-center h-full p-8 text-balance", children: /* @__PURE__ */ l("div", { className: "flex flex-col items-center max-w-sm text-center", children: [
2023
- /* @__PURE__ */ e(En, {}),
2024
- s && !t && /* @__PURE__ */ l("div", { className: "mt-8", children: [
2025
- /* @__PURE__ */ e("h2", { className: "font-medium text-black text-[18px] mb-2", children: "Your inbox is empty" }),
2026
- /* @__PURE__ */ e("p", { className: "text-[#676B5F] text-sm mb-6", children: "Share with your followers to start receiving messages" })
2027
- ] })
2028
- ] }) })
2029
- );
2030
- Nt.displayName = "EmptyState";
2031
- const ke = z.memo(({ message: t, onBack: s }) => /* @__PURE__ */ e("div", { className: "messaging-error-state flex items-center justify-center h-full p-8", children: /* @__PURE__ */ l("div", { className: "text-center max-w-sm", children: [
2032
- /* @__PURE__ */ e("div", { className: "w-24 h-24 bg-danger-alt/20 rounded-full flex items-center justify-center mx-auto mb-6", children: /* @__PURE__ */ e("span", { className: "text-4xl", children: "โš ๏ธ" }) }),
2033
- /* @__PURE__ */ e("h2", { className: "font-semibold text-charcoal mb-2", children: "Oops!" }),
2034
- /* @__PURE__ */ e("p", { className: "text-stone text-sm mb-6", children: t }),
2035
- s && /* @__PURE__ */ e(
2036
- "button",
2037
- {
2038
- type: "button",
2039
- onClick: s,
2040
- className: "inline-flex items-center gap-2 px-4 py-2 text-sm font-medium text-white bg-[#7f22fe] hover:bg-primary-alt rounded-lg transition-colors focus-ring",
2041
- children: "Go Back"
2042
- }
2043
- )
2044
- ] }) }));
2045
- ke.displayName = "ErrorState";
2046
- const Vn = ({
2047
- capabilities: t = {},
2048
- className: s,
2049
- renderMessageInputActions: n,
2050
- renderConversationFooter: o,
2051
- onChannelSelect: i,
2052
- onParticipantSelect: u,
2053
- initialParticipantFilter: r,
2054
- initialParticipantData: c,
2055
- CustomChannelEmptyState: f,
2056
- showChannelList: m = !0,
2057
- filters: g,
2058
- channelRenderFilterFn: b,
2059
- channelListCustomEmptyStateIndicator: N,
2060
- onDeleteConversationClick: a,
2061
- onBlockParticipantClick: w,
2062
- onReportParticipantClick: y,
2063
- dmAgentEnabled: x,
2064
- messageMetadata: E,
2065
- onMessageSent: v,
2066
- showStarButton: I = !1,
2067
- chatbotVotingEnabled: k = !1,
2068
- renderMessagePreview: P,
2069
- renderChannelBanner: p,
2070
- customProfileContent: d,
2071
- customChannelActions: C,
2072
- renderMessage: _,
2073
- sendButton: T
2074
- }) => {
2075
- const {
2076
- service: L,
2077
- client: D,
2078
- isConnected: G,
2079
- isLoading: ee,
2080
- error: q,
2081
- refreshConnection: $,
2082
- debug: F
2083
- } = Ss(), [J, Z] = S(null), [Q, h] = S(!1), [R, O] = S(!1), [V, j] = S(!1), [se, ie] = S(/* @__PURE__ */ new Set()), [be, Re] = S(0), [Y, te] = S(!1), [xe, ae] = S(null), me = K(null), {
2084
- participantSource: le,
2085
- participantLabel: pe = "participants",
2086
- showDeleteConversation: ge = !0
2087
- } = t, ve = z.useMemo(() => {
2088
- const M = D == null ? void 0 : D.userID;
2089
- return {
2090
- ...{
2091
- type: "messaging",
2092
- last_message_at: { $exists: !0 },
2093
- ...M && {
2094
- members: { $in: [M] },
2095
- hidden: !1
2096
- }
2097
- },
2098
- ...g
2099
- };
2100
- }, [g, D == null ? void 0 : D.userID]), ce = K(null), ne = A(async () => {
2101
- if (!D || !G) return;
2102
- const M = D.userID;
2103
- if (M)
2104
- try {
2105
- F && console.log("[MessagingShell] Syncing channels for user:", M);
2106
- const W = await D.queryChannels(
2107
- {
2108
- type: "messaging",
2109
- members: { $in: [M] }
2110
- },
2111
- {},
2112
- { limit: 100 }
2113
- ), B = /* @__PURE__ */ new Set();
2114
- W.forEach((H) => {
2115
- const Le = H.state.members;
2116
- Object.values(Le).forEach((Ct) => {
2117
- var Ve;
2118
- const Pe = (Ve = Ct.user) == null ? void 0 : Ve.id;
2119
- Pe && Pe !== M && B.add(Pe);
2120
- });
2121
- }), ie((H) => H.size === B.size && [...H].every((Le) => B.has(Le)) ? H : B), h(W.length > 0), O(!0), ce.current = M, F && console.log("[MessagingShell] Channels synced successfully:", {
2122
- channelCount: W.length,
2123
- memberCount: B.size
2124
- });
2125
- } catch (W) {
2126
- console.error("[MessagingShell] Failed to sync channels:", W);
2127
- }
2128
- }, [D, G, F]);
2129
- X(() => {
2130
- if (!D || !G) return;
2131
- const M = D.userID;
2132
- M && ce.current !== M && ne();
2133
- }, [D, G, ne]), X(() => {
2134
- if (!r || !D || !G) return;
2135
- (async () => {
2136
- const W = D.userID;
2137
- if (W)
2138
- try {
2139
- F && console.log(
2140
- "[MessagingShell] Loading initial conversation with:",
2141
- r
2142
- );
2143
- const B = await D.queryChannels(
2144
- {
2145
- type: "messaging",
2146
- members: { $eq: [W, r] }
2147
- },
2148
- {},
2149
- { limit: 1 }
2150
- );
2151
- if (B.length > 0)
2152
- Z(B[0]), te(!0), ae(null), i && i(B[0]), F && console.log(
2153
- "[MessagingShell] Initial conversation loaded:",
2154
- B[0].id
2155
- );
2156
- else if (c && L) {
2157
- F && console.log(
2158
- "[MessagingShell] No conversation found, creating one for:",
2159
- c
2160
- );
2161
- try {
2162
- const H = await L.startChannelWithParticipant({
2163
- id: c.id,
2164
- name: c.name,
2165
- email: c.email,
2166
- phone: c.phone
2167
- });
2168
- Z(H), te(!0), ae(null), i && i(H), F && console.log(
2169
- "[MessagingShell] Channel created and loaded:",
2170
- H.id
2171
- );
2172
- } catch (H) {
2173
- console.error(
2174
- "[MessagingShell] Failed to create conversation:",
2175
- H
2176
- ), ae("Failed to create conversation");
2177
- }
2178
- } else
2179
- ae(
2180
- "No conversation found with this account"
2181
- ), F && console.log(
2182
- "[MessagingShell] No conversation found for:",
2183
- r
2184
- );
2185
- } catch (B) {
2186
- console.error(
2187
- "[MessagingShell] Failed to load initial conversation:",
2188
- B
2189
- ), ae("Failed to load conversation");
2190
- }
2191
- })();
2192
- }, [
2193
- r,
2194
- c,
2195
- D,
2196
- G,
2197
- L,
2198
- F,
2199
- i
2200
- ]);
2201
- const ye = A(
2202
- (M) => {
2203
- Z(M), i == null || i(M);
2204
- },
2205
- [i]
2206
- ), Ne = A(() => {
2207
- Y || Z(null);
2208
- }, [Y]), we = A(
2209
- async (M) => {
2210
- var W;
2211
- if (L)
2212
- try {
2213
- F && console.log(
2214
- "[MessagingShell] Starting conversation with:",
2215
- M.id
2216
- );
2217
- const B = await L.startChannelWithParticipant({
2218
- id: M.id,
2219
- name: M.name,
2220
- email: M.email,
2221
- phone: M.phone
2222
- });
2223
- try {
2224
- await B.show();
2225
- } catch (H) {
2226
- console.warn("[MessagingShell] Failed to unhide channel:", H);
2227
- }
2228
- Z(B), j(!1), (W = me.current) == null || W.close(), u == null || u(M);
2229
- } catch (B) {
2230
- console.error("[MessagingShell] Failed to start conversation:", B);
2231
- }
2232
- },
2233
- [L, u, F]
2234
- ), de = A(() => {
2235
- var M;
2236
- j(!1), (M = me.current) == null || M.close();
2237
- }, []), Ce = A(
2238
- (M) => {
2239
- M.target === me.current && de();
2240
- },
2241
- [de]
2242
- ), _e = A(
2243
- async (M) => {
2244
- F && console.log("[MessagingShell] Leaving conversation:", M.id), Z(null), te(!1), ce.current = null, await ne();
2245
- },
2246
- [ne, F]
2247
- ), Ee = A(
2248
- async (M) => {
2249
- F && console.log("[MessagingShell] Blocking participant:", M), Z(null), te(!1), ce.current = null, await ne();
2250
- },
2251
- [ne, F]
2252
- ), ue = !!J;
2253
- return ee ? /* @__PURE__ */ e("div", { className: U("h-full", s), children: /* @__PURE__ */ e(Me, {}) }) : q ? /* @__PURE__ */ e("div", { className: U("h-full", s), children: /* @__PURE__ */ e(ke, { message: q, onBack: $ }) }) : !G || !D ? /* @__PURE__ */ e("div", { className: U("h-full", s), children: /* @__PURE__ */ e(
2254
- ke,
2255
- {
2256
- message: "Not connected to messaging service",
2257
- onBack: $
2258
- }
2259
- ) }) : xe ? /* @__PURE__ */ e("div", { className: U("h-full", s), children: /* @__PURE__ */ e(ke, { message: xe }) }) : /* @__PURE__ */ l(
2260
- "div",
2261
- {
2262
- className: U(
2263
- "messaging-shell h-full bg-background-primary overflow-hidden",
2264
- s
2265
- ),
2266
- children: [
2267
- /* @__PURE__ */ l("div", { className: "flex h-full min-h-0", children: [
2268
- /* @__PURE__ */ e(
2269
- "div",
2270
- {
2271
- className: U(
2272
- "messaging-channel-list-sidebar min-h-0 min-w-0 lg:flex lg:flex-col",
2273
- {
2274
- "!hidden": m === !1 || Y,
2275
- // Hide on mobile when channel selected, show on desktop with consistent wide width
2276
- "hidden lg:flex lg:flex-1 lg:max-w-2xl": m !== !1 && !Y && ue,
2277
- // Show on mobile when no channel selected, use same wide width on desktop
2278
- "flex flex-col w-full lg:flex-1 lg:max-w-2xl": m !== !1 && !Y && !ue
2279
- }
2280
- ),
2281
- children: /* @__PURE__ */ e(
2282
- gt,
2283
- {
2284
- onChannelSelect: ye,
2285
- selectedChannel: J || void 0,
2286
- filters: ve,
2287
- channelRenderFilterFn: b,
2288
- customEmptyStateIndicator: N,
2289
- renderMessagePreview: P
2290
- }
2291
- )
2292
- }
2293
- ),
2294
- /* @__PURE__ */ e(
2295
- "div",
2296
- {
2297
- className: U(
2298
- "messaging-conversation-view flex-1 flex-col min-w-0 min-h-0",
2299
- {
2300
- // In direct conversation mode (or waiting for it), always show (full width)
2301
- flex: Y || ue || r,
2302
- // Normal mode: hide on mobile when no channel selected
2303
- "hidden lg:flex": !Y && !ue && !r
2304
- }
2305
- ),
2306
- children: J ? /* @__PURE__ */ e("div", { className: "flex-1 min-h-0 flex flex-col", children: /* @__PURE__ */ e(
2307
- yt,
2308
- {
2309
- channel: J,
2310
- onBack: Ne,
2311
- showBackButton: !Y,
2312
- renderMessageInputActions: n,
2313
- renderConversationFooter: o,
2314
- renderChannelBanner: p,
2315
- onLeaveConversation: _e,
2316
- onBlockParticipant: Ee,
2317
- CustomChannelEmptyState: f,
2318
- showDeleteConversation: ge,
2319
- onDeleteConversationClick: a,
2320
- onBlockParticipantClick: w,
2321
- onReportParticipantClick: y,
2322
- dmAgentEnabled: x,
2323
- messageMetadata: E,
2324
- onMessageSent: v,
2325
- showStarButton: I,
2326
- chatbotVotingEnabled: k,
2327
- customProfileContent: d,
2328
- customChannelActions: C,
2329
- renderMessage: _,
2330
- sendButton: T
2331
- },
2332
- J.id
2333
- ) }) : r ? (
2334
- // Show loading while creating/loading direct conversation channel
2335
- /* @__PURE__ */ e(Me, {})
2336
- ) : /* @__PURE__ */ e(
2337
- Nt,
2338
- {
2339
- hasChannels: Q,
2340
- channelsLoaded: R
2341
- }
2342
- )
2343
- }
2344
- )
2345
- ] }),
2346
- le && // eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-noninteractive-element-interactions
2347
- /* @__PURE__ */ e(
2348
- "dialog",
2349
- {
2350
- ref: me,
2351
- className: "mes-dialog",
2352
- onClick: Ce,
2353
- onClose: de,
2354
- children: /* @__PURE__ */ e("div", { className: "h-full w-full bg-white shadow-max-elevation-light", children: /* @__PURE__ */ e(
2355
- _n,
2356
- {
2357
- participantSource: le,
2358
- onSelectParticipant: we,
2359
- onClose: de,
2360
- existingParticipantIds: se,
2361
- participantLabel: pe,
2362
- searchPlaceholder: `Search ${pe}...`
2363
- },
2364
- be
2365
- ) })
2366
- }
2367
- )
2368
- ]
2369
- }
2370
- );
2371
- }, Sn = ({
2372
- question: t,
2373
- onClick: s,
2374
- loading: n = !1,
2375
- className: o
2376
- }) => /* @__PURE__ */ e(
2377
- "button",
2378
- {
2379
- type: "button",
2380
- onClick: s,
2381
- disabled: n,
2382
- style: { backgroundColor: "#E6E5E3" },
2383
- className: U(
2384
- "w-full text-center p-4 rounded-xl text-charcoal font-medium transition-colors focus-ring",
2385
- {
2386
- "hover:brightness-95 active:brightness-90": !n,
2387
- "opacity-50 cursor-not-allowed": n
2388
- },
2389
- o
2390
- ),
2391
- children: t
2392
- }
2393
- ), Yn = ({
2394
- faqs: t,
2395
- onFaqClick: s,
2396
- loadingFaqId: n,
2397
- headerText: o,
2398
- className: i,
2399
- avatarImage: u,
2400
- avatarName: r
2401
- }) => {
2402
- const c = t.filter((f) => f.enabled).sort((f, m) => (f.order ?? 0) - (m.order ?? 0));
2403
- return c.length === 0 ? null : /* @__PURE__ */ e("div", { className: i, children: /* @__PURE__ */ l("div", { className: "flex gap-3 items-end", children: [
2404
- (u || r) && /* @__PURE__ */ e("div", { className: "flex-none", children: /* @__PURE__ */ e(
2405
- oe,
2406
- {
2407
- id: r || "account",
2408
- name: r || "Account",
2409
- image: u,
2410
- size: 24,
2411
- shape: "circle"
2412
- }
2413
- ) }),
2414
- /* @__PURE__ */ l(
2415
- "div",
2416
- {
2417
- className: "flex-1 flex flex-col gap-3 rounded-lg p-4",
2418
- style: { backgroundColor: "#F1F0EE" },
2419
- children: [
2420
- o && /* @__PURE__ */ e("p", { className: "text-md text-charcoal mb-4", children: o }),
2421
- c.map((f) => /* @__PURE__ */ e(
2422
- Sn,
2423
- {
2424
- question: f.question,
2425
- onClick: () => s(f.id),
2426
- loading: n === f.id
2427
- },
2428
- f.id
2429
- ))
2430
- ]
2431
- }
2432
- )
2433
- ] }) });
2434
- }, In = [
2435
- [/pdf/, "pdf"],
2436
- [/wordprocessingml|msword|\.doc/, "doc"],
2437
- [/spreadsheetml|ms-excel|\.xls/, "xls"],
2438
- [/csv/, "csv"],
2439
- [/presentationml|ms-powerpoint|\.ppt/, "ppt"],
2440
- [/zip|x-rar|x-7z|x-tar|x-gzip/, "zip"],
2441
- [/plain|rtf/, "text"],
2442
- [/markdown/, "markdown"]
2443
- ];
2444
- function He(t) {
2445
- return t.startsWith("video/") ? "video" : t.startsWith("audio/") ? "audio" : t.startsWith("image/") ? "image" : "document";
2446
- }
2447
- function kn(t) {
2448
- const s = In.find(
2449
- ([n]) => n.test(t)
2450
- );
2451
- return s ? s[1] : "generic";
2452
- }
2453
- const Mn = {
2454
- video: gs,
2455
- audio: fs,
2456
- image: hs,
2457
- document: ct
2458
- }, Tn = {
2459
- pdf: Cs,
2460
- doc: ws,
2461
- xls: Ns,
2462
- csv: ys,
2463
- ppt: vs,
2464
- zip: ps,
2465
- text: xs,
2466
- markdown: bs,
2467
- generic: ct
2468
- };
2469
- function Dn(t) {
2470
- const s = He(t);
2471
- return s !== "document" ? Mn[s] : Tn[kn(t)];
2472
- }
2473
- function Te(t, s) {
2474
- return z.createElement(Dn(t), s);
2475
- }
2476
- const Rn = (t) => {
2477
- var s, n;
2478
- return "touches" in t ? ((s = t.touches[0]) == null ? void 0 : s.clientX) ?? ((n = t.changedTouches[0]) == null ? void 0 : n.clientX) ?? 0 : t.clientX;
2479
- }, Ln = ({
2480
- source: t,
2481
- mimeType: s,
2482
- poster: n,
2483
- autoPlay: o = !1,
2484
- playing: i,
2485
- loop: u = !1,
2486
- controls: r = !0,
2487
- showProgress: c = !1,
2488
- muted: f = !1
2489
- }) => {
2490
- const m = He(s), g = K(null), b = K(null), N = K(null), a = K(i), [w, y] = S(o), [x, E] = S(0), [v, I] = S(!1), [k, P] = S(!1), [p, d] = S(!1), [C, _] = S(!1), [T, L] = S(!0), [D, G] = S(null), ee = A(() => {
2491
- d(!1), y(!0);
2492
- }, []), q = A((h) => {
2493
- const R = b.current;
2494
- if (!R) return 0;
2495
- const O = R.getBoundingClientRect();
2496
- return Math.max(
2497
- 0,
2498
- Math.min(1, (Rn(h) - O.left) / O.width)
2499
- );
2500
- }, []), $ = A((h) => {
2501
- const R = g.current;
2502
- R && R.duration && (R.currentTime = h * R.duration);
2503
- }, []), F = (h) => {
2504
- h.stopPropagation(), I(!0);
2505
- const R = q(h);
2506
- E(R), $(R);
2507
- };
2508
- X(() => {
2509
- i !== void 0 && i !== a.current && (a.current = i, y(i));
2510
- }, [i]), X(() => {
2511
- if (!w) {
2512
- N.current !== null && (cancelAnimationFrame(N.current), N.current = null);
2513
- return;
2514
- }
2515
- const h = () => {
2516
- const R = g.current;
2517
- R && R.duration && !v && E(R.currentTime / R.duration), N.current = requestAnimationFrame(h);
2518
- };
2519
- return N.current = requestAnimationFrame(h), () => {
2520
- N.current !== null && cancelAnimationFrame(N.current);
2521
- };
2522
- }, [w, v]), X(() => {
2523
- const h = g.current;
2524
- h && (w ? h.play().catch((R) => {
2525
- y(!1), d(!0);
2526
- }) : h.pause());
2527
- }, [w]), X(() => {
2528
- if (!v) return;
2529
- const h = (O) => E(q(O)), R = (O) => {
2530
- I(!1), $(q(O));
2531
- };
2532
- return window.addEventListener("mousemove", h), window.addEventListener("mouseup", R), window.addEventListener("touchmove", h, { passive: !0 }), window.addEventListener("touchend", R), () => {
2533
- window.removeEventListener("mousemove", h), window.removeEventListener("mouseup", R), window.removeEventListener("touchmove", h), window.removeEventListener("touchend", R);
2534
- };
2535
- }, [v, q, $]);
2536
- const J = D ? { aspectRatio: String(D) } : void 0, Z = D ? "" : " aspect-video", Q = Math.round(x * 100);
2537
- return /* @__PURE__ */ l(
2538
- "div",
2539
- {
2540
- role: "button",
2541
- tabIndex: 0,
2542
- className: `relative cursor-pointer overflow-hidden bg-black ${Z}`,
2543
- style: J,
2544
- onClick: () => {
2545
- p || r && y((h) => !h);
2546
- },
2547
- onKeyDown: (h) => {
2548
- h.key !== "Enter" && h.key !== " " || (h.preventDefault(), !p && r && y((R) => !R));
2549
- },
2550
- children: [
2551
- n && (m === "audio" || T) && /* @__PURE__ */ e(
2552
- "img",
2553
- {
2554
- src: n,
2555
- alt: "",
2556
- className: "absolute inset-0 h-full w-full object-cover"
2557
- }
2558
- ),
2559
- !n && (m === "audio" || T) && /* @__PURE__ */ e("div", { className: "absolute inset-0 flex items-center justify-center", children: Te(s, {
2560
- className: "size-12 text-black/20",
2561
- weight: "regular"
2562
- }) }),
2563
- /* @__PURE__ */ e("div", { className: "absolute inset-0", children: m === "audio" ? /* @__PURE__ */ e(
2564
- "audio",
2565
- {
2566
- ref: g,
2567
- src: t,
2568
- loop: u,
2569
- muted: f,
2570
- style: { width: "100%", height: "100%" },
2571
- onLoadStart: () => _(!0),
2572
- onCanPlay: () => {
2573
- _(!1), L(!1);
2574
- },
2575
- onWaiting: () => _(!0),
2576
- onPlay: () => d(!1),
2577
- onEnded: () => {
2578
- u || (y(!1), E(0));
2579
- },
2580
- children: /* @__PURE__ */ e("track", { kind: "captions" })
2581
- }
2582
- ) : /* @__PURE__ */ e(
2583
- "video",
2584
- {
2585
- ref: g,
2586
- src: t,
2587
- loop: u,
2588
- muted: f,
2589
- playsInline: !0,
2590
- style: { width: "100%", height: "100%" },
2591
- onLoadStart: () => _(!0),
2592
- onCanPlay: () => {
2593
- _(!1), L(!1);
2594
- },
2595
- onWaiting: () => _(!0),
2596
- onPlay: () => d(!1),
2597
- onLoadedMetadata: () => {
2598
- const h = g.current;
2599
- h instanceof HTMLVideoElement && h.videoWidth && h.videoHeight && G(h.videoWidth / h.videoHeight);
2600
- },
2601
- onEnded: () => {
2602
- u || (y(!1), E(0));
2603
- },
2604
- children: /* @__PURE__ */ e("track", { kind: "captions" })
2605
- }
2606
- ) }),
2607
- C && !p && /* @__PURE__ */ e("div", { className: "absolute inset-0 z-10 flex items-center justify-center", children: /* @__PURE__ */ e(
2608
- _s,
2609
- {
2610
- className: "size-8 animate-spin text-white/80",
2611
- weight: "bold"
2612
- }
2613
- ) }),
2614
- p && !r && /* @__PURE__ */ e(
2615
- "div",
2616
- {
2617
- className: "absolute inset-0 z-30 flex cursor-pointer items-center justify-center bg-black/35",
2618
- role: "button",
2619
- tabIndex: 0,
2620
- "aria-label": "Play preview",
2621
- onClick: (h) => {
2622
- h.stopPropagation(), ee();
2623
- },
2624
- onKeyDown: (h) => {
2625
- h.key !== "Enter" && h.key !== " " || (h.preventDefault(), h.stopPropagation(), ee());
2626
- },
2627
- children: /* @__PURE__ */ e("span", { className: "flex size-16 items-center justify-center rounded-full bg-white/20 text-white backdrop-blur-sm", children: /* @__PURE__ */ e(Ke, { className: "size-9 translate-x-0.5", weight: "fill" }) })
2628
- }
2629
- ),
2630
- c && !r && /* @__PURE__ */ e("div", { className: "absolute inset-x-0 bottom-0 px-3 pb-2.5 pt-6 bg-gradient-to-t from-black/40 to-transparent", children: /* @__PURE__ */ e(
2631
- "div",
2632
- {
2633
- role: "slider",
2634
- "aria-label": "Playback position",
2635
- "aria-valuenow": Q,
2636
- "aria-valuemin": 0,
2637
- "aria-valuemax": 100,
2638
- tabIndex: 0,
2639
- ref: b,
2640
- className: "relative flex h-4 w-full cursor-pointer items-center",
2641
- onMouseDown: F,
2642
- onTouchStart: F,
2643
- onClick: (h) => h.stopPropagation(),
2644
- onKeyDown: (h) => {
2645
- h.key === "ArrowRight" && $(Math.min(1, x + 0.05)), h.key === "ArrowLeft" && $(Math.max(0, x - 0.05));
2646
- },
2647
- children: /* @__PURE__ */ e("div", { className: "w-full overflow-hidden rounded-full bg-white/30 h-1", children: /* @__PURE__ */ e(
2648
- "div",
2649
- {
2650
- className: "h-full rounded-full bg-white",
2651
- style: { width: `${Q}%` }
2652
- }
2653
- ) })
2654
- }
2655
- ) }),
2656
- r && /* @__PURE__ */ l("div", { className: "absolute inset-x-0 bottom-0 flex items-center gap-2 bg-gradient-to-t from-black/60 to-transparent px-3 pb-2.5 pt-6 transition-all duration-200", children: [
2657
- /* @__PURE__ */ e(
2658
- "button",
2659
- {
2660
- type: "button",
2661
- onClick: (h) => {
2662
- h.stopPropagation(), y((R) => !R);
2663
- },
2664
- className: "shrink-0 text-white",
2665
- "aria-label": w ? "Pause" : "Play",
2666
- children: w ? /* @__PURE__ */ e(Es, { className: "size-5", weight: "fill" }) : /* @__PURE__ */ e(Ke, { className: "size-5 translate-x-px", weight: "fill" })
2667
- }
2668
- ),
2669
- /* @__PURE__ */ l(
2670
- "div",
2671
- {
2672
- role: "slider",
2673
- "aria-label": "Playback position",
2674
- "aria-valuenow": Q,
2675
- "aria-valuemin": 0,
2676
- "aria-valuemax": 100,
2677
- tabIndex: 0,
2678
- ref: b,
2679
- className: "relative flex h-4 w-full cursor-pointer items-center",
2680
- onMouseDown: F,
2681
- onTouchStart: F,
2682
- onClick: (h) => h.stopPropagation(),
2683
- onMouseEnter: () => P(!0),
2684
- onMouseLeave: () => P(!1),
2685
- onKeyDown: (h) => {
2686
- h.key === "ArrowRight" && $(Math.min(1, x + 0.05)), h.key === "ArrowLeft" && $(Math.max(0, x - 0.05));
2687
- },
2688
- children: [
2689
- /* @__PURE__ */ e(
2690
- "div",
2691
- {
2692
- className: `w-full overflow-hidden rounded-full bg-white/30 transition-all duration-200 ${k || v ? "h-1.5" : "h-1"}`,
2693
- children: /* @__PURE__ */ e(
2694
- "div",
2695
- {
2696
- className: "h-full rounded-full bg-white",
2697
- style: { width: `${Q}%` }
2698
- }
2699
- )
2700
- }
2701
- ),
2702
- /* @__PURE__ */ e(
2703
- "div",
2704
- {
2705
- className: `absolute size-3 -translate-x-1/2 rounded-full bg-white shadow transition-[opacity,transform] duration-200 ${k || v ? "scale-100 opacity-100" : "scale-0 opacity-0"}`,
2706
- style: { left: `${Q}%` }
2707
- }
2708
- )
2709
- ]
2710
- }
2711
- )
2712
- ] })
2713
- ]
2714
- }
2715
- );
2716
- };
2717
- function wt(t) {
2718
- return t < 1024 ? `${t} B` : t < 1024 * 1024 ? `${(t / 1024).toFixed(1)} KB` : `${(t / (1024 * 1024)).toFixed(1)} MB`;
2719
- }
2720
- const Pn = "w-[280px] select-none overflow-hidden rounded-[24px] bg-white shadow-[0_0_0_1px_rgba(0,0,0,0.04),0_4px_8px_rgba(0,0,0,0.06)]", st = ({
2721
- mimeType: t,
2722
- title: s,
2723
- fileSize: n
2724
- }) => !s && n === void 0 ? null : /* @__PURE__ */ l("div", { className: "px-4 pb-3 pt-3", children: [
2725
- s && /* @__PURE__ */ e("p", { className: "mb-1.5 truncate text-base font-medium text-black", children: s }),
2726
- n !== void 0 && /* @__PURE__ */ l("div", { className: "flex items-center gap-1", children: [
2727
- Te(t, { className: "size-5 shrink-0 text-black/55", weight: "regular" }),
2728
- /* @__PURE__ */ e("span", { className: "text-xs font-medium text-black/55", children: wt(n) })
2729
- ] })
2730
- ] }), Fn = ({ url: t, mimeType: s, title: n, fileSize: o }) => /* @__PURE__ */ l("a", { href: t, target: "_blank", rel: "noopener noreferrer", className: "block no-underline", children: [
2731
- /* @__PURE__ */ e("div", { className: "aspect-video w-full bg-black/5 flex items-center justify-center", children: Te(s, { className: "size-12 text-black/20", weight: "regular" }) }),
2732
- /* @__PURE__ */ l("div", { className: "px-4 pb-3 pt-3", children: [
2733
- n && /* @__PURE__ */ e("p", { className: "mb-1.5 truncate text-base font-medium text-black", children: n }),
2734
- o !== void 0 && /* @__PURE__ */ l("div", { className: "flex items-center gap-1", children: [
2735
- Te(s, { className: "size-5 shrink-0 text-black/55", weight: "regular" }),
2736
- /* @__PURE__ */ e("span", { className: "text-xs font-medium text-black/55", children: wt(o) })
2737
- ] })
2738
- ] })
2739
- ] }), Wn = ({
2740
- message: t,
2741
- isMyMessage: s = !1
2742
- }) => {
2743
- var w, y, x, E;
2744
- const n = (w = t.attachments) == null ? void 0 : w.find(
2745
- (v) => v.type === "video" && v.asset_url
2746
- ), o = (y = t.attachments) == null ? void 0 : y.find(
2747
- (v) => v.type === "image" && v.image_url
2748
- ), i = (x = t.attachments) == null ? void 0 : x.find(
2749
- (v) => v.type === "audio" && v.asset_url
2750
- ), u = (E = t.attachments) == null ? void 0 : E.find(
2751
- (v) => v.type === "file" && v.asset_url
2752
- ), r = n ?? o ?? i ?? u, c = (n == null ? void 0 : n.asset_url) ?? (o == null ? void 0 : o.image_url) ?? (i == null ? void 0 : i.asset_url) ?? (u == null ? void 0 : u.asset_url), f = (r == null ? void 0 : r.mime_type) ?? (o ? "image/jpeg" : n ? "video/mp4" : i ? "audio/mpeg" : "application/octet-stream");
2753
- if (!c) return null;
2754
- const m = He(f), g = r == null ? void 0 : r.title, b = r == null ? void 0 : r.file_size, N = n == null ? void 0 : n.thumb_url;
2755
- return /* @__PURE__ */ l("div", { className: s ? "str-chat__message str-chat__message-simple str-chat__message--me str-chat__message-simple--me" : "str-chat__message str-chat__message-simple str-chat__message--other", children: [
2756
- !s && t.user && /* @__PURE__ */ e(
2757
- oe,
2758
- {
2759
- className: "str-chat__avatar str-chat__message-sender-avatar",
2760
- id: t.user.id,
2761
- image: t.user.image,
2762
- name: t.user.name ?? t.user.id
2763
- }
2764
- ),
2765
- /* @__PURE__ */ e(
2766
- "div",
2767
- {
2768
- className: "str-chat__message-inner",
2769
- style: { marginInlineEnd: 0, marginInlineStart: 0 },
2770
- children: /* @__PURE__ */ e("div", { className: "str-chat__message-bubble-wrapper", children: /* @__PURE__ */ e("div", { className: "str-chat__message-bubble", style: { padding: 0, borderRadius: 0, overflow: "visible", background: "transparent" }, children: /* @__PURE__ */ e("div", { className: Pn, children: m === "image" ? /* @__PURE__ */ l(re, { children: [
2771
- /* @__PURE__ */ e(
2772
- "img",
2773
- {
2774
- src: c,
2775
- alt: g ?? "",
2776
- className: "block w-full"
2777
- }
2778
- ),
2779
- /* @__PURE__ */ e(st, { mimeType: f, title: g, fileSize: b })
2780
- ] }) : m === "document" ? /* @__PURE__ */ e(
2781
- Fn,
2782
- {
2783
- url: c,
2784
- mimeType: f,
2785
- title: g,
2786
- fileSize: b
2787
- }
2788
- ) : /* @__PURE__ */ l(re, { children: [
2789
- /* @__PURE__ */ e(
2790
- Ln,
2791
- {
2792
- source: c,
2793
- mimeType: f,
2794
- poster: N,
2795
- controls: !0
2796
- }
2797
- ),
2798
- /* @__PURE__ */ e(st, { mimeType: f, title: g, fileSize: b })
2799
- ] }) }) }) })
2800
- }
2801
- )
2802
- ] });
2803
- }, qn = (t, s = {}) => {
2804
- const { initialSearch: n = "", pageSize: o = 20 } = s, [i, u] = S([]), [r, c] = S(!1), [f, m] = S(null), [g, b] = S(n), [N, a] = S(!0), [w, y] = S(), x = A(async (k = !1, P) => {
2805
- if (r) return;
2806
- const p = P !== void 0 ? P : g;
2807
- c(!0), m(null);
2808
- try {
2809
- const d = await t.loadParticipants({
2810
- search: p || void 0,
2811
- limit: o,
2812
- cursor: k ? void 0 : w
2813
- });
2814
- u(
2815
- (C) => k ? d.participants : [...C, ...d.participants]
2816
- ), a(d.hasMore), y(d.nextCursor);
2817
- } catch (d) {
2818
- const C = d instanceof Error ? d.message : "Failed to load participants";
2819
- m(C), console.error("[useParticipants] Load error:", d);
2820
- } finally {
2821
- c(!1);
2822
- }
2823
- }, [t, g, w, o, r]), E = A(() => {
2824
- N && !r && x(!1);
2825
- }, [N, r, x]), v = A((k) => {
2826
- b(k), y(void 0), x(!0, k);
2827
- }, [x]), I = A(() => {
2828
- y(void 0), x(!0);
2829
- }, [x]);
2830
- return X(() => {
2831
- x(!0);
2832
- }, [t.loadParticipants]), {
2833
- participants: i,
2834
- loading: r,
2835
- error: f,
2836
- searchQuery: g,
2837
- hasMore: N,
2838
- totalCount: t.totalCount,
2839
- loadMore: E,
2840
- search: v,
2841
- refresh: I
2842
- };
2843
- };
2844
- export {
2845
- Se as A,
2846
- vn as C,
2847
- Yn as F,
2848
- et as L,
2849
- Ln as M,
2850
- _n as P,
2851
- oe as a,
2852
- gt as b,
2853
- yt as c,
2854
- Hn as d,
2855
- Sn as e,
2856
- Wn as f,
2857
- He as g,
2858
- Qs as h,
2859
- Gn as i,
2860
- Vn as j,
2861
- Ds as k,
2862
- Gs as l,
2863
- Ss as m,
2864
- qn as n,
2865
- Te as r,
2866
- Xs as u
2867
- };
2868
- //# sourceMappingURL=index-BePLvyvi.js.map