@linktr.ee/messaging-react 1.40.1 → 2.0.0

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