@linktr.ee/messaging-react 3.4.2-rc-1782480798 → 3.4.3-rc-1782553322
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{Card-VO-i6CuV.cjs → Card-1oglowd2.cjs} +2 -2
- package/dist/{Card-VO-i6CuV.cjs.map → Card-1oglowd2.cjs.map} +1 -1
- package/dist/{Card-BYu6OBuX.js → Card-BmVutVEt.js} +2 -2
- package/dist/{Card-BYu6OBuX.js.map → Card-BmVutVEt.js.map} +1 -1
- package/dist/{Card-BKi2g6x-.js → Card-CKn-iPjf.js} +2 -2
- package/dist/{Card-BKi2g6x-.js.map → Card-CKn-iPjf.js.map} +1 -1
- package/dist/{Card-BMmrCMqJ.cjs → Card-DEEK3wsC.cjs} +2 -2
- package/dist/{Card-BMmrCMqJ.cjs.map → Card-DEEK3wsC.cjs.map} +1 -1
- package/dist/{Card-DvE5BCPf.js → Card-DoBWURRU.js} +3 -3
- package/dist/{Card-DvE5BCPf.js.map → Card-DoBWURRU.js.map} +1 -1
- package/dist/{Card-DtIjtWy6.cjs → Card-DwaOIthl.cjs} +2 -2
- package/dist/{Card-DtIjtWy6.cjs.map → Card-DwaOIthl.cjs.map} +1 -1
- package/dist/{LockedThumbnail-Cl8uwCxM.cjs → LockedThumbnail-B59cJFsF.cjs} +2 -2
- package/dist/{LockedThumbnail-Cl8uwCxM.cjs.map → LockedThumbnail-B59cJFsF.cjs.map} +1 -1
- package/dist/{LockedThumbnail-DTkd_kEt.js → LockedThumbnail-DI-aReA7.js} +2 -2
- package/dist/{LockedThumbnail-DTkd_kEt.js.map → LockedThumbnail-DI-aReA7.js.map} +1 -1
- package/dist/index-12HxQ_GM.cjs +2 -0
- package/dist/index-12HxQ_GM.cjs.map +1 -0
- package/dist/{index-IzhF38yj.js → index-Dv13-2iu.js} +3200 -3445
- package/dist/index-Dv13-2iu.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/package.json +2 -2
- package/src/components/ChannelView.stories.tsx +7 -5
- package/src/components/ChannelView.test.tsx +10 -0
- package/src/components/ChannelView.tsx +95 -59
- package/src/components/CustomMessage/index.tsx +0 -42
- package/dist/index-CSSe9eu7.cjs +0 -2
- package/dist/index-CSSe9eu7.cjs.map +0 -1
- package/dist/index-IzhF38yj.js.map +0 -1
- package/src/components/CustomMessage/StreamAttachmentMessage.test.tsx +0 -109
- package/src/components/CustomMessage/StreamAttachmentMessage.tsx +0 -408
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-12HxQ_GM.cjs");exports.ActionButton=e.ActionButton;exports.Avatar=e.Avatar;exports.ChannelEmptyState=e.ChannelEmptyState;exports.ChannelList=e.ChannelList;exports.ChannelView=e.ChannelView;exports.CustomMessageProvider=e.CustomMessageProvider;exports.FaqList=e.FaqList;exports.FaqListItem=e.FaqListItem;exports.LinkAttachment=e.LinkAttachment;exports.LockedAttachment=e.LockedAttachment;exports.MediaMessage=e.MediaMessage;exports.MessageAttachment=e.MessageAttachment;exports.MessageVoteButtons=e.MessageVoteButtons;exports.MessagingProvider=e.MessagingProvider;exports.MessagingShell=e.MessagingShell;exports.buildCompactMetaLabel=e.buildCompactMetaLabel;exports.formatFileSize=e.formatFileSize;exports.formatRelativeTime=e.formatRelativeTime;exports.getFileExtensionLabel=e.getFileExtensionLabel;exports.getMessageDisplayText=e.getMessageDisplayText;exports.isLinkAttachment=e.isLinkAttachment;exports.isUuidLike=e.isUuidLike;exports.messageAttachmentGroupPositionFromStream=e.bubbleGroupPositionFromStream;exports.normalizeLanguageCode=e.normalizeLanguageCode;exports.resolveLinkAttachment=e.resolveLinkAttachment;exports.resolveMediaFromMessage=e.resolveMediaFromMessage;exports.resolveParticipantDisplayName=e.resolveParticipantDisplayName;exports.useComposerLocked=e.useComposerLocked;exports.useCustomMessage=e.useCustomMessage;exports.useMessageVote=e.useMessageVote;exports.useMessaging=e.useMessaging;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as e, b as t, C as i, c as o, d as n, e as m, F as g, f as r, L as l, h as M, M as u, i as L, j as c, k as h, l as d, m as p, n as C, o as v, p as A, q as k, s as F, t as b, u as f, v as x, w as y, x as P, y as S, z as q, B as z, D as B, E as D } from "./index-
|
|
1
|
+
import { a as e, b as t, C as i, c as o, d as n, e as m, F as g, f as r, L as l, h as M, M as u, i as L, j as c, k as h, l as d, m as p, n as C, o as v, p as A, q as k, s as F, t as b, u as f, v as x, w as y, x as P, y as S, z as q, B as z, D as B, E as D } from "./index-Dv13-2iu.js";
|
|
2
2
|
export {
|
|
3
3
|
e as ActionButton,
|
|
4
4
|
t as Avatar,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@linktr.ee/messaging-react",
|
|
3
|
-
"version": "3.4.
|
|
3
|
+
"version": "3.4.3-rc-1782553322",
|
|
4
4
|
"description": "React messaging components built on messaging-core for web applications",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@linktr.ee/component-library": "11.8.6",
|
|
41
|
-
"@linktr.ee/messaging-core": "2.3.0-rc-
|
|
41
|
+
"@linktr.ee/messaging-core": "2.3.0-rc-1782553322",
|
|
42
42
|
"@phosphor-icons/react": "^2.1.10"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
@@ -251,18 +251,20 @@ Default.parameters = {
|
|
|
251
251
|
},
|
|
252
252
|
}
|
|
253
253
|
|
|
254
|
-
export const
|
|
255
|
-
|
|
254
|
+
export const ParticipantIdentityTrigger: StoryFn<TemplateProps> = Template.bind(
|
|
255
|
+
{}
|
|
256
|
+
)
|
|
257
|
+
ParticipantIdentityTrigger.args = {
|
|
256
258
|
showBackButton: false,
|
|
257
259
|
onParticipantNameClick: () =>
|
|
258
260
|
// eslint-disable-next-line no-alert
|
|
259
|
-
window.alert('Participant
|
|
261
|
+
window.alert('Participant details clicked — open Thread content'),
|
|
260
262
|
}
|
|
261
|
-
|
|
263
|
+
ParticipantIdentityTrigger.parameters = {
|
|
262
264
|
docs: {
|
|
263
265
|
description: {
|
|
264
266
|
story:
|
|
265
|
-
'Header with `onParticipantNameClick` set: the participant name
|
|
267
|
+
'Header with `onParticipantNameClick` set: the participant avatar and name render as one button with a trailing caret in both the mobile and desktop header layouts. Click the identity block to fire the callback (shows an alert here). With the prop omitted (see Default) the header remains non-interactive.',
|
|
266
268
|
},
|
|
267
269
|
},
|
|
268
270
|
}
|
|
@@ -208,6 +208,16 @@ describe('ChannelView', () => {
|
|
|
208
208
|
name: /view details for linker/i,
|
|
209
209
|
})
|
|
210
210
|
expect(buttons.length).toBeGreaterThanOrEqual(1)
|
|
211
|
+
expect(buttons[0]).toHaveClass(
|
|
212
|
+
'appearance-none',
|
|
213
|
+
'border-0',
|
|
214
|
+
'bg-transparent',
|
|
215
|
+
'p-0'
|
|
216
|
+
)
|
|
217
|
+
|
|
218
|
+
const avatars = screen.getAllByTestId('avatar')
|
|
219
|
+
expect(avatars.length).toBeGreaterThanOrEqual(1)
|
|
220
|
+
expect(avatars[0].closest('button')).toBe(buttons[0])
|
|
211
221
|
|
|
212
222
|
buttons[0].click()
|
|
213
223
|
expect(onParticipantNameClick).toHaveBeenCalledTimes(1)
|
|
@@ -97,6 +97,12 @@ const CustomChannelHeader: React.FC<{
|
|
|
97
97
|
channel,
|
|
98
98
|
participant,
|
|
99
99
|
})
|
|
100
|
+
const participantTitle = (
|
|
101
|
+
<>
|
|
102
|
+
<span className="min-w-0 truncate">{participantName}</span>
|
|
103
|
+
{headerTitleBadges && <span className="shrink-0">{headerTitleBadges}</span>}
|
|
104
|
+
</>
|
|
105
|
+
)
|
|
100
106
|
|
|
101
107
|
const handleStarClick = async () => {
|
|
102
108
|
try {
|
|
@@ -132,40 +138,52 @@ const CustomChannelHeader: React.FC<{
|
|
|
132
138
|
)}
|
|
133
139
|
</div>
|
|
134
140
|
<div className="flex flex-col gap-1 items-center">
|
|
135
|
-
<Avatar
|
|
136
|
-
id={participant?.user?.id || channel.id || 'unknown'}
|
|
137
|
-
name={participantName}
|
|
138
|
-
image={participantImage}
|
|
139
|
-
starred={showStarButton && isStarred}
|
|
140
|
-
dmAgentEnabled={dmAgentEnabled}
|
|
141
|
-
size={48}
|
|
142
|
-
/>
|
|
143
141
|
{onParticipantNameClick ? (
|
|
144
142
|
<button
|
|
145
143
|
type="button"
|
|
146
144
|
onClick={onParticipantNameClick}
|
|
147
145
|
aria-label={`View details for ${participantName}`}
|
|
148
|
-
className="flex max-w-full items-center gap-
|
|
146
|
+
className="flex max-w-full flex-col items-center gap-1 appearance-none rounded border-0 bg-transparent p-0 text-center text-xs font-medium text-black/90 transition-opacity hover:opacity-70 focus-ring focus-visible:outline-none"
|
|
149
147
|
>
|
|
150
|
-
<
|
|
151
|
-
|
|
152
|
-
|
|
148
|
+
<Avatar
|
|
149
|
+
id={participant?.user?.id || channel.id || 'unknown'}
|
|
150
|
+
name={participantName}
|
|
151
|
+
image={participantImage}
|
|
152
|
+
starred={showStarButton && isStarred}
|
|
153
|
+
dmAgentEnabled={dmAgentEnabled}
|
|
154
|
+
size={48}
|
|
155
|
+
/>
|
|
156
|
+
<span className="flex max-w-full items-center gap-0.5">
|
|
157
|
+
{participantTitle}
|
|
158
|
+
<CaretRightIcon className="size-3 shrink-0" weight="bold" />
|
|
159
|
+
</span>
|
|
160
|
+
{dmAgentEnabled && (
|
|
161
|
+
<div className="flex items-center gap-1 text-[10px] leading-3 text-black/55">
|
|
162
|
+
<SparkleIcon className="size-3 shrink-0 text-black/55" />
|
|
163
|
+
<span>{DM_AGENT_HEADER_HELPER_TEXT}</span>
|
|
164
|
+
</div>
|
|
153
165
|
)}
|
|
154
|
-
<CaretRightIcon className="size-3 shrink-0" weight="bold" />
|
|
155
166
|
</button>
|
|
156
167
|
) : (
|
|
157
|
-
|
|
158
|
-
<
|
|
159
|
-
|
|
160
|
-
|
|
168
|
+
<>
|
|
169
|
+
<Avatar
|
|
170
|
+
id={participant?.user?.id || channel.id || 'unknown'}
|
|
171
|
+
name={participantName}
|
|
172
|
+
image={participantImage}
|
|
173
|
+
starred={showStarButton && isStarred}
|
|
174
|
+
dmAgentEnabled={dmAgentEnabled}
|
|
175
|
+
size={48}
|
|
176
|
+
/>
|
|
177
|
+
<p className="flex max-w-full items-center justify-center gap-1 text-center text-xs font-medium text-black/90">
|
|
178
|
+
{participantTitle}
|
|
179
|
+
</p>
|
|
180
|
+
{dmAgentEnabled && (
|
|
181
|
+
<div className="flex items-center gap-1 text-[10px] leading-3 text-black/55">
|
|
182
|
+
<SparkleIcon className="size-3 shrink-0 text-black/55" />
|
|
183
|
+
<span>{DM_AGENT_HEADER_HELPER_TEXT}</span>
|
|
184
|
+
</div>
|
|
161
185
|
)}
|
|
162
|
-
|
|
163
|
-
)}
|
|
164
|
-
{dmAgentEnabled && (
|
|
165
|
-
<div className="flex items-center gap-1 text-[10px] leading-3 text-black/55">
|
|
166
|
-
<SparkleIcon className="size-3 shrink-0 text-black/55" />
|
|
167
|
-
<span>{DM_AGENT_HEADER_HELPER_TEXT}</span>
|
|
168
|
-
</div>
|
|
186
|
+
</>
|
|
169
187
|
)}
|
|
170
188
|
</div>
|
|
171
189
|
<div className="flex justify-end items-center gap-2">
|
|
@@ -223,44 +241,62 @@ const CustomChannelHeader: React.FC<{
|
|
|
223
241
|
<ArrowLeftIcon className="size-5 text-black/90" />
|
|
224
242
|
</button>
|
|
225
243
|
)}
|
|
226
|
-
{
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
244
|
+
{onParticipantNameClick ? (
|
|
245
|
+
<button
|
|
246
|
+
type="button"
|
|
247
|
+
onClick={onParticipantNameClick}
|
|
248
|
+
aria-label={`View details for ${participantName}`}
|
|
249
|
+
className="flex min-w-0 max-w-full items-center gap-4 appearance-none rounded border-0 bg-transparent p-0 text-left text-black/90 transition-opacity hover:opacity-70 focus-ring focus-visible:outline-none"
|
|
250
|
+
>
|
|
251
|
+
<Avatar
|
|
252
|
+
id={participant?.user?.id || channel.id || 'unknown'}
|
|
253
|
+
name={participantName}
|
|
254
|
+
image={participantImage}
|
|
255
|
+
starred={showStarButton && isStarred}
|
|
256
|
+
dmAgentEnabled={dmAgentEnabled}
|
|
257
|
+
size={48}
|
|
258
|
+
/>
|
|
259
|
+
<div className="min-w-0">
|
|
260
|
+
<h1 className="flex min-w-0 items-center gap-1 font-medium text-black/90">
|
|
261
|
+
{participantTitle}
|
|
262
|
+
<CaretRightIcon className="size-4 shrink-0" weight="bold" />
|
|
263
|
+
</h1>
|
|
264
|
+
{dmAgentEnabled && (
|
|
265
|
+
<div className="mt-0.5 flex items-center gap-1 text-[10px] leading-3 text-black/55">
|
|
266
|
+
<SparkleIcon className="size-3 shrink-0 text-black/55" />
|
|
267
|
+
<span className="truncate">
|
|
268
|
+
{DM_AGENT_HEADER_HELPER_TEXT}
|
|
269
|
+
</span>
|
|
270
|
+
</div>
|
|
246
271
|
)}
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
272
|
+
</div>
|
|
273
|
+
</button>
|
|
274
|
+
) : (
|
|
275
|
+
<>
|
|
276
|
+
{/* Avatar */}
|
|
277
|
+
<Avatar
|
|
278
|
+
id={participant?.user?.id || channel.id || 'unknown'}
|
|
279
|
+
name={participantName}
|
|
280
|
+
image={participantImage}
|
|
281
|
+
starred={showStarButton && isStarred}
|
|
282
|
+
dmAgentEnabled={dmAgentEnabled}
|
|
283
|
+
size={48}
|
|
284
|
+
/>
|
|
285
|
+
<div className="min-w-0">
|
|
286
|
+
<h1 className="flex min-w-0 items-center gap-1 font-medium text-black/90">
|
|
287
|
+
{participantTitle}
|
|
288
|
+
</h1>
|
|
289
|
+
{dmAgentEnabled && (
|
|
290
|
+
<div className="mt-0.5 flex items-center gap-1 text-[10px] leading-3 text-black/55">
|
|
291
|
+
<SparkleIcon className="size-3 shrink-0 text-black/55" />
|
|
292
|
+
<span className="truncate">
|
|
293
|
+
{DM_AGENT_HEADER_HELPER_TEXT}
|
|
294
|
+
</span>
|
|
295
|
+
</div>
|
|
254
296
|
)}
|
|
255
|
-
</h1>
|
|
256
|
-
)}
|
|
257
|
-
{dmAgentEnabled && (
|
|
258
|
-
<div className="mt-0.5 flex items-center gap-1 text-[10px] leading-3 text-black/55">
|
|
259
|
-
<SparkleIcon className="size-3 shrink-0 text-black/55" />
|
|
260
|
-
<span className="truncate">{DM_AGENT_HEADER_HELPER_TEXT}</span>
|
|
261
297
|
</div>
|
|
262
|
-
|
|
263
|
-
|
|
298
|
+
</>
|
|
299
|
+
)}
|
|
264
300
|
</div>
|
|
265
301
|
<div className="flex items-center gap-2">
|
|
266
302
|
{showStarButton && (
|
|
@@ -34,9 +34,6 @@ import { getMessageDisplayText } from '../../utils/getMessageDisplayText'
|
|
|
34
34
|
import { Avatar } from '../Avatar'
|
|
35
35
|
import LockedAttachment from '../LockedAttachment'
|
|
36
36
|
import { isLinkAttachment } from '../MediaMessage'
|
|
37
|
-
import {
|
|
38
|
-
bubbleGroupPositionFromStream as messageAttachmentGroupPositionFromStream,
|
|
39
|
-
} from '../MessageAttachment'
|
|
40
37
|
|
|
41
38
|
import { useCustomMessage } from './context'
|
|
42
39
|
import {
|
|
@@ -46,9 +43,6 @@ import {
|
|
|
46
43
|
isTipOnlyMessage,
|
|
47
44
|
} from './MessageTag'
|
|
48
45
|
import { MessageVoteButtons } from './MessageVoteButtons'
|
|
49
|
-
import StreamAttachmentMessage, {
|
|
50
|
-
buildOrderedAttachmentSegments,
|
|
51
|
-
} from './StreamAttachmentMessage'
|
|
52
46
|
|
|
53
47
|
type CustomMessageUIComponentProps = MessageUIComponentProps & {
|
|
54
48
|
chatbotVotingEnabled?: boolean
|
|
@@ -119,26 +113,12 @@ const CustomMessageWithContext = (props: CustomMessageWithContextProps) => {
|
|
|
119
113
|
const filtered = raw.filter((a) => !('type' in a) || !isLinkAttachment(a))
|
|
120
114
|
return filtered.length === raw.length ? raw : filtered
|
|
121
115
|
}, [message])
|
|
122
|
-
const attachmentSegments = useMemo(
|
|
123
|
-
() => buildOrderedAttachmentSegments(finalAttachments),
|
|
124
|
-
[finalAttachments]
|
|
125
|
-
)
|
|
126
116
|
const displayMessage = useMemo(() => {
|
|
127
117
|
const displayText = getMessageDisplayText({ message, viewerLanguage })
|
|
128
118
|
return displayText === message.text
|
|
129
119
|
? message
|
|
130
120
|
: { ...message, text: displayText }
|
|
131
121
|
}, [message, viewerLanguage])
|
|
132
|
-
const hasLinkAttachmentSegments = attachmentSegments.some(
|
|
133
|
-
(segment) => segment.type === 'link'
|
|
134
|
-
)
|
|
135
|
-
const streamAttachmentGroupPosition = messageAttachmentGroupPositionFromStream(
|
|
136
|
-
{
|
|
137
|
-
endOfGroup,
|
|
138
|
-
firstOfGroup,
|
|
139
|
-
groupedByUser,
|
|
140
|
-
}
|
|
141
|
-
)
|
|
142
122
|
|
|
143
123
|
if (isDateSeparatorMessage(message)) {
|
|
144
124
|
return null
|
|
@@ -298,28 +278,6 @@ const CustomMessageWithContext = (props: CustomMessageWithContextProps) => {
|
|
|
298
278
|
) : isTipOnly ? (
|
|
299
279
|
/* Tip-only messages render as a standalone bubble */
|
|
300
280
|
<MessageTag message={message} standalone />
|
|
301
|
-
) : hasLinkAttachmentSegments ? (
|
|
302
|
-
<div className="str-chat__message-bubble-wrapper">
|
|
303
|
-
<div
|
|
304
|
-
className="str-chat__message-bubble"
|
|
305
|
-
style={{
|
|
306
|
-
background: 'transparent',
|
|
307
|
-
borderRadius: 0,
|
|
308
|
-
overflow: 'visible',
|
|
309
|
-
padding: 0,
|
|
310
|
-
}}
|
|
311
|
-
>
|
|
312
|
-
<StreamAttachmentMessage
|
|
313
|
-
groupPosition={streamAttachmentGroupPosition}
|
|
314
|
-
isMyMessage={isMine}
|
|
315
|
-
message={{
|
|
316
|
-
attachments: finalAttachments,
|
|
317
|
-
text: displayMessage.text,
|
|
318
|
-
}}
|
|
319
|
-
/>
|
|
320
|
-
<MessageErrorIcon />
|
|
321
|
-
</div>
|
|
322
|
-
</div>
|
|
323
281
|
) : (
|
|
324
282
|
<div className="str-chat__message-bubble-wrapper">
|
|
325
283
|
<div className="str-chat__message-bubble">
|
package/dist/index-CSSe9eu7.cjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";const t=require("react/jsx-runtime"),m=require("react"),Ns=require("@linktr.ee/messaging-core"),Re=require("stream-chat"),_=require("stream-chat-react"),N=require("@phosphor-icons/react"),C=require("classnames"),Oe=require("stream-chat-react/experimental"),Lt=m.createContext({service:null,client:null,isConnected:!1,isLoading:!1,error:null,capabilities:{},refreshConnection:async()=>{},debug:!1}),Fe=()=>m.useContext(Lt),ys=({children:e,user:s,serviceConfig:n,apiKey:a,capabilities:r={},debug:i=!1})=>{var O,y;const o=m.useCallback((I,...T)=>{i&&console.log(`🔥 [MessagingProvider] ${I}`,...T)},[i]);o("🔄 RENDER START",{userId:s==null?void 0:s.id,apiKey:(a==null?void 0:a.substring(0,8))+"...",serviceConfig:!!n,capabilities:Object.keys(r)});const[l,d]=m.useState(null),[h,x]=m.useState(null),[u,f]=m.useState(!1),[c,g]=m.useState(!1),[w,p]=m.useState(null),b=m.useRef(!1),v=m.useRef(null),S=m.useRef(n);S.current=n;const R=m.useRef(i);R.current=i;const k=m.useRef({userId:s==null?void 0:s.id,apiKey:a,serviceConfig:n,capabilities:r}),L=m.useRef(0);L.current++,o("📊 RENDER INFO",{renderCount:L.current,currentProps:{userId:s==null?void 0:s.id,apiKey:(a==null?void 0:a.substring(0,8))+"..."},propChanges:{userChanged:k.current.userId!==(s==null?void 0:s.id),apiKeyChanged:k.current.apiKey!==a,serviceConfigChanged:k.current.serviceConfig!==n,capabilitiesChanged:k.current.capabilities!==r}}),k.current={userId:s==null?void 0:s.id,apiKey:a,serviceConfig:n,capabilities:r};const F=m.useRef(null);a&&((O=F.current)==null?void 0:O.apiKey)!==a&&(F.current={apiKey:a,client:new Re.StreamChat(a)});const z=a?((y=F.current)==null?void 0:y.client)??null:null;m.useEffect(()=>{const I=L.current,T=S.current;if(!a||!z||!T){o("⚠️ SERVICE INIT SKIPPED",{renderCount:I,reason:"Missing apiKey, client, or serviceConfig"});return}o("🚀 CREATING SERVICE",{renderCount:I,apiKey:(a==null?void 0:a.substring(0,8))+"..."});const B=new Ns.StreamChatService({...T,apiKey:a,debug:R.current,client:z});v.current=B,d(B),o("✅ SERVICE SET",{renderCount:I,serviceInstance:!!B})},[a,z]);const E=m.useRef(null);m.useEffect(()=>{var T,B;if(o("🔗 USER CONNECTION EFFECT TRIGGERED",{hasService:!!l,hasUser:!!s,userId:s==null?void 0:s.id,isConnecting:b.current,isConnected:u,dependencies:{service:!!l,userId:s==null?void 0:s.id}}),!l||!s){o("⚠️ USER CONNECTION SKIPPED","Missing service or user");return}if(b.current){o("⚠️ USER CONNECTION SKIPPED","Already connecting");return}if(((T=E.current)==null?void 0:T.serviceId)===l&&((B=E.current)==null?void 0:B.userId)===s.id){o("⚠️ USER CONNECTION SKIPPED","Already connected this user with this service");return}(async()=>{o("🚀 STARTING USER CONNECTION",{userId:s.id}),b.current=!0,g(!0),p(null);try{o("📞 CALLING SERVICE.CONNECTUSER",{userId:s.id});const $=await l.connectUser(s);x($),f(!0),E.current={serviceId:l,userId:s.id},o("✅ USER CONNECTION SUCCESS",{userId:s.id,clientId:$.userID})}catch($){const H=$ instanceof Error?$.message:"Connection failed";p(H),o("❌ USER CONNECTION ERROR",{userId:s.id,error:H})}finally{g(!1),b.current=!1,o("🔄 USER CONNECTION FINISHED",{userId:s.id,isConnected:u})}})()},[l,s,o,u]),m.useEffect(()=>{const I=z;return()=>{var T;I&&(E.current=null,(T=v.current)==null||T.disconnectUser().catch(console.error))}},[z]);const D=m.useCallback(async()=>{if(o("🔄 REFRESH CONNECTION CALLED",{hasService:!!l,hasUser:!!s}),!l||!s){o("⚠️ REFRESH CONNECTION SKIPPED","Missing service or user");return}o("🚀 STARTING CONNECTION REFRESH",{userId:s.id}),g(!0);try{o("🔌 DISCONNECTING FOR REFRESH"),await l.disconnectUser(),o("📞 RECONNECTING FOR REFRESH");const I=await l.connectUser(s);x(I),f(!0),p(null),o("✅ CONNECTION REFRESH SUCCESS",{userId:s.id})}catch(I){const T=I instanceof Error?I.message:"Refresh failed";p(T),o("❌ CONNECTION REFRESH ERROR",{userId:s.id,error:T})}finally{g(!1),o("🔄 CONNECTION REFRESH FINISHED",{userId:s.id})}},[l,s,o]),A=m.useMemo(()=>(o("💫 CONTEXT VALUE MEMOIZATION",{hasService:!!l,hasClient:!!h,isConnected:u,isLoading:c,hasError:!!w,capabilitiesKeys:Object.keys(r)}),{service:l,client:h,isConnected:u,isLoading:c,error:w,capabilities:r,refreshConnection:D,debug:i}),[l,h,u,c,w,r,D,i,o]);return o("🔄 RENDER END",{renderCount:L.current,willRenderChat:!!z,contextValueReady:!!A}),t.jsx(Lt.Provider,{value:A,children:z?t.jsx(_.Chat,{client:z,customClasses:{channelList:"str-chat__channel-list str-chat__channel-list-react bg-transparent lg:border-r-2 border-r-0 border-[#0000000A]"},children:e}):e})},Dt=()=>Fe(),Pt=e=>{var a,r;const[s,n]=m.useState(!!((r=(a=e==null?void 0:e.state)==null?void 0:a.membership)!=null&&r.pinned_at));return m.useEffect(()=>{var o;if(!e){n(!1);return}n(!!((o=e.state.membership)!=null&&o.pinned_at));const i=l=>{var d;n(l!=null&&l.member?!!l.member.pinned_at:!!((d=e.state.membership)!=null&&d.pinned_at))};return e.on("member.updated",i),()=>{e.off("member.updated",i)}},[e]),s},Cs=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;function zt(e){return Cs.test(e.trim())}function yt(e,s){const n=e==null?void 0:e.trim();return!n||s&&n===s?!1:!zt(n)}function $e(e){return yt(e==null?void 0:e.name,e==null?void 0:e.id)?e.name.trim():yt(e==null?void 0:e.username,e==null?void 0:e.id)?e.username.trim():"Unknown member"}const Ct=["🍎","🍌","🍇","🍊","🍓","🥥","🍒","🥭","🍉","🍋","🥝","🫒","🍈"];function ks(e){let s=0;for(let n=0;n<e.length;n++){const a=e.charCodeAt(n);s=(s<<5)-s+a,s=s&s}return Math.abs(s)}function Ss(e){const n=ks(e)%Ct.length;return Ct[n]}const se=({id:e,image:s,size:n=40,className:a,starred:r=!1,shape:i="squircle",dmAgentEnabled:o=!1})=>{const l=Ss(e),h=n<32?"text-xs":n<56?"text-sm":n<120?"text-lg":"text-4xl",x=n>=40?2:1,u=i==="circle"?{borderRadius:"50%"}:{borderRadius:"1rem"},f=t.jsx("div",{className:"h-full w-full overflow-hidden",style:u,children:s?t.jsx("img",{src:s,alt:"",className:"h-full w-full object-cover"}):t.jsx("div",{"aria-hidden":"true",className:C("avatar-fallback flex h-full w-full items-center justify-center bg-[#E6E5E3] font-semibold select-none transition-colors",h),children:l})});return t.jsxs("div",{className:C("relative flex-shrink-0 !bg-transparent",a),style:{"--str-chat__avatar-size":`${n}px`,width:`${n}px`,height:`${n}px`},children:[r&&t.jsx("div",{"aria-hidden":"true",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)]",children:t.jsx(N.StarIcon,{className:"size-3 text-yellow-600",weight:"duotone"})}),t.jsx("div",{"data-testid":"avatar-ring",className:C("h-full w-full","bg-transparent"),style:{...u,...o&&{borderWidth:`${x}px`,borderStyle:"solid",borderColor:"var(--AI-Gradient, #7F22FE)",boxShadow:"inset 0 1px 2px 0 rgba(255, 255, 255, 0.5)"}},children:f})]})},Is="https://linktr.ee/s/about/trust-center/report",Es=({channel:e,participant:s,showBlockParticipant:n=!0,enabled:a=!0,onLeaveConversation:r,onBlockParticipant:i,onDeleteConversationClick:o,onBlockParticipantClick:l,onReportParticipantClick:d,onActionComplete:h,logLabel:x="useChannelModerationActions"})=>{var O;const{service:u,debug:f}=Fe(),c=(O=s==null?void 0:s.user)==null?void 0:O.id,g=!!(a&&n&&u&&c),[w,p]=m.useState(!1),[b,v]=m.useState(null),[S,R]=m.useState(!1),[k,L]=m.useState(!1),F=g&&((b==null?void 0:b.participantId)!==c||(b==null?void 0:b.service)!==u);return m.useEffect(()=>{if(!g||!u||!c){p(!1),v(null);return}let y=!1;return(async()=>{try{const I=await u.getBlockedUsers();if(y)return;p(I.some(T=>T.blocked_user_id===c))}catch(I){y||console.error(`[${x}] Failed to check blocked status:`,I)}finally{y||v({participantId:c,service:u})}})(),()=>{y=!0}},[g,u,c,x]),{isParticipantBlocked:w,isCheckingBlockedStatus:F,isLeaving:S,isUpdatingBlockStatus:k,handleLeaveConversation:async()=>{var y;if(!S){o==null||o(),f&&console.log(`[${x}] Leave conversation`,e.cid),R(!0);try{const I=((y=e._client)==null?void 0:y.userID)??null;await e.hide(I,!1),r&&await r(e),h==null||h()}catch(I){console.error(`[${x}] Failed to leave conversation`,I)}finally{R(!1)}}},handleBlockUser:async()=>{var y,I,T;if(!(k||!u)){l==null||l(),f&&console.log(`[${x}] Block member`,(y=s==null?void 0:s.user)==null?void 0:y.id),L(!0);try{await u.blockUser((I=s==null?void 0:s.user)==null?void 0:I.id),i&&await i((T=s==null?void 0:s.user)==null?void 0:T.id),h==null||h()}catch(B){console.error(`[${x}] Failed to block member`,B)}finally{L(!1)}}},handleUnblockUser:async()=>{var y,I,T;if(!(k||!u)){l==null||l(),f&&console.log(`[${x}] Unblock member`,(y=s==null?void 0:s.user)==null?void 0:y.id),L(!0);try{await u.unBlockUser((I=s==null?void 0:s.user)==null?void 0:I.id),i&&await i((T=s==null?void 0:s.user)==null?void 0:T.id),h==null||h()}catch(B){console.error(`[${x}] Failed to unblock member`,B)}finally{L(!1)}}},handleReportUser:()=>{d==null||d(),h==null||h(),window.open(Is,"_blank","noopener,noreferrer")}}},ce=({variant:e="default",className:s,children:n,...a})=>{const r=e==="danger";return t.jsx("button",{type:"button",className:C("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",r?"text-danger hover:bg-danger/50":"text-charcoal hover:bg-sand",s),...a,children:n})},kt=({channel:e,participant:s,showDeleteConversation:n=!0,showBlockParticipant:a=!0,showReportParticipant:r=!0,onLeaveConversation:i,onBlockParticipant:o,onDeleteConversationClick:l,onBlockParticipantClick:d,onReportParticipantClick:h,customChannelActions:x,triggerClassName:u})=>{const[f,c]=m.useState(!1),g=m.useRef(null),w=m.useId(),p=m.useCallback(()=>c(!1),[]),{isParticipantBlocked:b,isCheckingBlockedStatus:v,isLeaving:S,isUpdatingBlockStatus:R,handleLeaveConversation:k,handleBlockUser:L,handleUnblockUser:F,handleReportUser:z}=Es({channel:e,participant:s,showBlockParticipant:a,enabled:f,onLeaveConversation:i,onBlockParticipant:o,onDeleteConversationClick:l,onBlockParticipantClick:d,onReportParticipantClick:h,onActionComplete:p,logLabel:"ChannelActionsMenu"});return m.useEffect(()=>{if(!f)return;const D=O=>{g.current&&!g.current.contains(O.target)&&c(!1)},A=O=>{O.key==="Escape"&&c(!1)};return document.addEventListener("mousedown",D),document.addEventListener("keydown",A),()=>{document.removeEventListener("mousedown",D),document.removeEventListener("keydown",A)}},[f]),!s||!(n||a||r||!!x)?null:t.jsxs("div",{ref:g,className:"relative",children:[t.jsxs("button",{className:u,type:"button","aria-haspopup":"true","aria-expanded":f,"aria-controls":f?w:void 0,onClick:()=>c(D=>!D),children:[t.jsx(N.DotsThreeIcon,{className:"size-5 text-black/90"}),t.jsx("span",{className:"sr-only",children:"More options"})]}),f&&t.jsx("div",{id:w,"aria-label":"Conversation options",className:C("absolute right-0 top-full z-50 mt-2 w-56 overflow-hidden","rounded-lg border border-sand bg-white p-1 shadow-max-elevation-light"),children:t.jsxs("ul",{className:"flex flex-col gap-1",children:[n&&t.jsx("li",{children:t.jsxs(ce,{onClick:k,disabled:S,"aria-busy":S,children:[S?t.jsx(N.SpinnerGapIcon,{className:"h-5 w-5 animate-spin"}):t.jsx(N.SignOutIcon,{className:"h-5 w-5"}),t.jsx("span",{children:"Delete Conversation"})]})}),a&&t.jsx("li",{children:v?t.jsxs(ce,{disabled:!0,"aria-busy":!0,children:[t.jsx(N.SpinnerGapIcon,{className:"h-5 w-5 animate-spin"}),t.jsx("span",{children:"Block"})]}):b?t.jsxs(ce,{onClick:F,disabled:R,"aria-busy":R,children:[R?t.jsx(N.SpinnerGapIcon,{className:"h-5 w-5 animate-spin"}):t.jsx(N.ProhibitInsetIcon,{className:"h-5 w-5"}),t.jsx("span",{children:"Unblock"})]}):t.jsxs(ce,{onClick:L,disabled:R,"aria-busy":R,children:[R?t.jsx(N.SpinnerGapIcon,{className:"h-5 w-5 animate-spin"}):t.jsx(N.ProhibitInsetIcon,{className:"h-5 w-5"}),t.jsx("span",{children:"Block"})]})}),r&&t.jsx("li",{children:t.jsxs(ce,{variant:"danger",onClick:z,children:[t.jsx(N.FlagIcon,{className:"h-5 w-5"}),t.jsx("span",{children:"Report"})]})}),x]})})]})},Ts=e=>t.jsx(_.DateSeparator,{...e,position:"center"}),Le="vote_up",De="vote_down";function As(e){return e!=null&&e.length?e.some(s=>s.type===De)?"down":e.some(s=>s.type===Le)?"up":null:null}function Ot(e){const{channel:s}=_.useChannelStateContext(),{client:n}=_.useChatContext("useMessageVote"),a=m.useMemo(()=>As(e.own_reactions),[e.own_reactions]),r=m.useCallback(async()=>{if(n!=null&&n.userID)try{a==="up"?await s.deleteReaction(e.id,Le):await s.sendReaction(e.id,{type:Le},{enforce_unique:!0,skip_push:!0})}catch{}},[s,n==null?void 0:n.userID,e.id,a]),i=m.useCallback(async()=>{if(n!=null&&n.userID)try{a==="down"?await s.deleteReaction(e.id,De):await s.sendReaction(e.id,{type:De},{enforce_unique:!0,skip_push:!0})}catch{}},[s,n==null?void 0:n.userID,e.id,a]);return{selected:a,voteUp:r,voteDown:i}}function Ft(e){return(e==null?void 0:e.trim().toLowerCase().split(/[-_]/)[0])||void 0}function Be({message:e,viewerLanguage:s}){var r;const n=e==null?void 0:e.text,a=Ft(s);return a?((r=e==null?void 0:e.i18n)==null?void 0:r[`${a}_text`])??n:n}const Ms=m.lazy(()=>Promise.resolve().then(()=>require("./Card-DtIjtWy6.cjs"))),Rs=m.lazy(()=>Promise.resolve().then(()=>require("./Card-VO-i6CuV.cjs"))),Ls=m.lazy(()=>Promise.resolve().then(()=>require("./Card-BMmrCMqJ.cjs"))),Ue=()=>t.jsx("div",{className:"w-[280px] min-h-[200px] animate-pulse rounded-md bg-black/[0.06] shadow-[0_0_0_1px_rgba(0,0,0,0.04),0_1px_2px_rgba(0,0,0,0.04),0_8px_32px_rgba(0,0,0,0.1)]","aria-hidden":!0}),Ds=e=>t.jsx(m.Suspense,{fallback:t.jsx(Ue,{}),children:t.jsx(Ms,{...e})}),$t=e=>t.jsx(m.Suspense,{fallback:t.jsx(Ue,{}),children:t.jsx(Rs,{...e})}),Bt=e=>t.jsx(m.Suspense,{fallback:t.jsx(Ue,{}),children:t.jsx(Ls,{...e})}),Ps=$t,zs=Bt,Pe={Composer:Ds,Sent:$t,Received:Bt,Creator:Ps,Visitor:zs},Os=[[/pdf/,"pdf"],[/wordprocessingml|msword|\.doc/,"doc"],[/spreadsheetml|ms-excel|\.xls/,"xls"],[/csv/,"csv"],[/presentationml|ms-powerpoint|\.ppt/,"ppt"],[/zip|x-rar|x-7z|x-tar|x-gzip/,"zip"],[/plain|rtf/,"text"],[/markdown/,"markdown"]];function ee(e){return e.startsWith("video/")?"video":e.startsWith("audio/")?"audio":e.startsWith("image/")?"image":"document"}function Ut(e){const s=Os.find(([n])=>n.test(e));return s?s[1]:"generic"}const Fs={video:N.VideoCameraIcon,audio:N.SpeakerHighIcon,image:N.ImageIcon,document:N.FileIcon},$s={pdf:N.FilePdfIcon,doc:N.FileDocIcon,xls:N.FileXlsIcon,csv:N.FileCsvIcon,ppt:N.FilePptIcon,zip:N.FileZipIcon,text:N.FileTextIcon,markdown:N.FileMdIcon,generic:N.FileIcon};function Bs(e){const s=ee(e);return s!=="document"?Fs[s]:$s[Ut(e)]}function re(e,s){return m.createElement(Bs(e),s)}const Us=e=>{var s,n;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},Vs=({source:e,mimeType:s,poster:n,autoPlay:a=!1,playing:r,loop:i=!1,controls:o=!0,showProgress:l=!1,muted:d=!1,onContainerClick:h})=>{const x=ee(s),u=m.useRef(null),f=m.useRef(null),c=m.useRef(null),g=m.useRef(r),[w,p]=m.useState(a),[b,v]=m.useState(0),[S,R]=m.useState(!1),[k,L]=m.useState(!1),[F,z]=m.useState(!1),[E,D]=m.useState(!1),[A,O]=m.useState(!0),[y,I]=m.useState(null),T=m.useCallback(()=>{z(!1),p(!0)},[]),B=m.useCallback(j=>{const M=f.current;if(!M)return 0;const V=M.getBoundingClientRect();return Math.max(0,Math.min(1,(Us(j)-V.left)/V.width))},[]),$=m.useCallback(j=>{const M=u.current;M&&M.duration&&(M.currentTime=j*M.duration)},[]),H=j=>{j.stopPropagation(),R(!0);const M=B(j);v(M),$(M)};m.useEffect(()=>{r!==void 0&&r!==g.current&&(g.current=r,p(r))},[r]),m.useEffect(()=>{if(!w){c.current!==null&&(cancelAnimationFrame(c.current),c.current=null);return}const j=()=>{const M=u.current;M&&M.duration&&!S&&v(M.currentTime/M.duration),c.current=requestAnimationFrame(j)};return c.current=requestAnimationFrame(j),()=>{c.current!==null&&cancelAnimationFrame(c.current)}},[w,S]),m.useEffect(()=>{const j=u.current;j&&(w?j.play().catch(M=>{p(!1),z(!0)}):j.pause())},[w]),m.useEffect(()=>{if(!S)return;const j=V=>v(B(V)),M=V=>{R(!1),$(B(V))};return window.addEventListener("mousemove",j),window.addEventListener("mouseup",M),window.addEventListener("touchmove",j,{passive:!0}),window.addEventListener("touchend",M),()=>{window.removeEventListener("mousemove",j),window.removeEventListener("mouseup",M),window.removeEventListener("touchmove",j),window.removeEventListener("touchend",M)}},[S,B,$]);const J=y?{aspectRatio:String(y)}:void 0,K=y?"":" aspect-video",q=Math.round(b*100);return t.jsxs("div",{role:"button",tabIndex:0,className:`relative cursor-pointer overflow-hidden bg-black ${K}`,style:J,onClick:j=>{if(h){h(j);return}F||o&&p(M=>!M)},onKeyDown:j=>{if(!(j.key!=="Enter"&&j.key!==" ")){if(j.preventDefault(),h){h(j);return}F||o&&p(M=>!M)}},children:[n&&(x==="audio"||A)&&t.jsx("img",{src:n,alt:"",className:"absolute inset-0 h-full w-full object-cover"}),!n&&(x==="audio"||A)&&t.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:re(s,{className:"size-12 text-black/20",weight:"regular"})}),t.jsx("div",{className:"absolute inset-0",children:x==="audio"?t.jsx("audio",{ref:u,src:e,loop:i,muted:d,style:{width:"100%",height:"100%"},onLoadStart:()=>D(!0),onCanPlay:()=>{D(!1),O(!1)},onWaiting:()=>D(!0),onPlay:()=>z(!1),onEnded:()=>{i||(p(!1),v(0))},children:t.jsx("track",{kind:"captions"})}):t.jsx("video",{ref:u,src:e,loop:i,muted:d,playsInline:!0,style:{width:"100%",height:"100%"},onLoadStart:()=>D(!0),onCanPlay:()=>{D(!1),O(!1)},onWaiting:()=>D(!0),onPlay:()=>z(!1),onLoadedMetadata:()=>{const j=u.current;j instanceof HTMLVideoElement&&j.videoWidth&&j.videoHeight&&I(j.videoWidth/j.videoHeight)},onEnded:()=>{i||(p(!1),v(0))},children:t.jsx("track",{kind:"captions"})})}),E&&!F&&t.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center",children:t.jsx(N.CircleNotchIcon,{className:"size-8 animate-spin text-white/80",weight:"bold"})}),F&&!o&&t.jsx("div",{className:"absolute inset-0 z-30 flex cursor-pointer items-center justify-center bg-black/35",role:"button",tabIndex:0,"aria-label":"Play preview",onClick:j=>{j.stopPropagation(),T()},onKeyDown:j=>{j.key!=="Enter"&&j.key!==" "||(j.preventDefault(),j.stopPropagation(),T())},children:t.jsx("span",{className:"flex size-16 items-center justify-center rounded-full bg-white/20 text-white backdrop-blur-sm",children:t.jsx(N.PlayIcon,{className:"size-9 translate-x-0.5",weight:"fill"})})}),l&&!o&&t.jsx("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:t.jsx("div",{role:"slider","aria-label":"Playback position","aria-valuenow":q,"aria-valuemin":0,"aria-valuemax":100,tabIndex:0,ref:f,className:"relative flex h-4 w-full cursor-pointer items-center",onMouseDown:H,onTouchStart:H,onClick:j=>j.stopPropagation(),onKeyDown:j=>{j.key==="ArrowRight"&&$(Math.min(1,b+.05)),j.key==="ArrowLeft"&&$(Math.max(0,b-.05))},children:t.jsx("div",{className:"w-full overflow-hidden rounded-full bg-white/30 h-1",children:t.jsx("div",{className:"h-full rounded-full bg-white",style:{width:`${q}%`}})})})}),o&&t.jsxs("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:[t.jsx("button",{type:"button",onClick:j=>{j.stopPropagation(),p(M=>!M)},className:"shrink-0 text-white","aria-label":w?"Pause":"Play",children:w?t.jsx(N.PauseIcon,{className:"size-5",weight:"fill"}):t.jsx(N.PlayIcon,{className:"size-5 translate-x-px",weight:"fill"})}),t.jsxs("div",{role:"slider","aria-label":"Playback position","aria-valuenow":q,"aria-valuemin":0,"aria-valuemax":100,tabIndex:0,ref:f,className:"relative flex h-4 w-full cursor-pointer items-center",onMouseDown:H,onTouchStart:H,onClick:j=>j.stopPropagation(),onMouseEnter:()=>L(!0),onMouseLeave:()=>L(!1),onKeyDown:j=>{j.key==="ArrowRight"&&$(Math.min(1,b+.05)),j.key==="ArrowLeft"&&$(Math.max(0,b-.05))},children:[t.jsx("div",{className:`w-full overflow-hidden rounded-full bg-white/30 transition-all duration-200 ${k||S?"h-1.5":"h-1"}`,children:t.jsx("div",{className:"h-full rounded-full bg-white",style:{width:`${q}%`}})}),t.jsx("div",{className:`absolute size-3 -translate-x-1/2 rounded-full bg-white shadow transition-[opacity,transform] duration-200 ${k||S?"scale-100 opacity-100":"scale-0 opacity-0"}`,style:{left:`${q}%`}})]})]})]})},St=e=>e==="dark"?"size-12 text-white/20":"size-12 text-black/20",Gs=e=>e==="dark"?"aspect-video overflow-hidden bg-white/10":"aspect-video overflow-hidden bg-black/5",Ve=({mimeType:e,sourceUrl:s,thumbnailUrl:n,title:a,variant:r,mediaPlayerProps:i,containedImage:o=!1})=>{const l=ee(e),[d,h]=m.useState(!1);return s&&(l==="video"||l==="audio")?t.jsx(Vs,{source:s,mimeType:e,poster:n,controls:!0,...i}):s&&l==="image"?o?t.jsx("div",{className:"relative aspect-video overflow-hidden bg-black/5",children:t.jsx("img",{src:s,alt:a??"",className:`absolute inset-0 h-full w-full object-contain transition-opacity duration-300 ${d?"opacity-100":"opacity-0"}`,draggable:!1,onLoad:()=>h(!0)})}):t.jsx("img",{src:s,alt:a??"",className:"block w-full",draggable:!1}):s&&l==="document"?n?o?t.jsx("div",{className:"relative aspect-video overflow-hidden bg-black/5",children:t.jsx("img",{src:n,alt:a??"",className:`absolute inset-0 h-full w-full object-contain transition-opacity duration-300 ${d?"opacity-100":"opacity-0"}`,draggable:!1,onLoad:()=>h(!0)})}):t.jsx("img",{src:n,alt:"",className:"block w-full",draggable:!1}):t.jsx("div",{className:`flex aspect-video w-full items-center justify-center ${r==="dark"?"bg-white/10":"bg-black/5"}`,children:re(e,{className:St(r),weight:"regular"})}):n?t.jsx("div",{className:`relative ${Gs(r)}`,children:t.jsx("img",{src:n,alt:a??"",draggable:!1,className:"absolute inset-0 h-full w-full object-cover"})}):t.jsx("div",{className:`flex aspect-video w-full items-center justify-center ${r==="dark"?"bg-white/10":"bg-black/5"}`,children:re(e,{className:St(r),weight:"regular"})})},Vt=({variant:e,thumbnail:s,title:n,placeholderTitle:a="Attachment title",mimeType:r,detail:i,statusBadge:o,action:l,topLeft:d,topRight:h,rootRef:x,"data-testid":u})=>{const f=e==="dark",c=f?n??a:n??"",g=f&&!n;return t.jsxs("div",{ref:x,"data-testid":u,className:C("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)]",f?"bg-[#121110]":"bg-white"),children:[d?t.jsx("div",{className:"pointer-events-auto absolute left-3 top-3 z-50",children:d}):null,h?t.jsx("div",{className:"pointer-events-auto absolute right-3 top-3 z-50",children:h}):null,s,t.jsxs("div",{className:"px-4 pb-3 pt-3",children:[c.trim()!==""&&t.jsx("p",{className:C("mb-0.5 truncate text-base font-medium",{"text-black":!f,"text-white/30":f&&g,"text-white":f&&!g}),children:c}),t.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[re(r,{className:C("size-5 shrink-0",f?"text-white/55":"text-black/55"),weight:"regular"}),i!=null&&i!==""&&t.jsx("span",{className:C("text-xs font-medium",f?"text-white/55":"text-black/55"),children:i}),o]}),l]})]})};function Gt(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function Ge(e){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)]`}function Hs(e){return e?"bg-white/10":"bg-black/5"}function Ys(e){return e?"text-white":"text-black"}function qs(e){return e?"text-white/55":"text-black/55"}function Ws(e){return e?"text-white/40":"text-black/40"}function Xs(e){return e?"text-white/20":"text-black/20"}const He=({attachment:e,isMyMessage:s})=>{const{title:n,text:a,image_url:r,og_scrape_url:i,title_link:o}=e,l=i??o,d=typeof l=="string"&&l.trim()!==""?l:void 0,h=t.jsxs(m.Fragment,{children:[t.jsx("div",{className:"p-2",children:r?t.jsx("img",{src:r,alt:n??"",className:"aspect-video w-full rounded-[20px] object-cover"}):t.jsx("div",{className:`aspect-video w-full rounded-[20px] ${Hs(s)} flex items-center justify-center`,children:t.jsx(N.LinkIcon,{className:`size-12 ${Xs(s)}`})})}),t.jsxs("div",{className:"px-3 pb-3",children:[n&&t.jsx("p",{className:`truncate text-[14px] font-medium leading-5 ${Ys(s)}`,children:n}),a&&t.jsx("p",{className:`truncate text-[12px] leading-4 ${qs(s)}`,children:a}),d&&t.jsx("p",{className:`mt-1 truncate text-[12px] leading-4 ${Ws(s)}`,children:d})]})]});return d?t.jsx("a",{href:d,target:"_blank",rel:"noopener noreferrer",className:"block no-underline",children:h}):t.jsx("div",{className:"block",children:h})};function Ye(e){return e.type==="link"||!!e.og_scrape_url&&!e.asset_url}function Ce(e){var s;return(s=e.attachments)==null?void 0:s.find(Ye)}async function Ks(e,s){let n;try{n=s??new URL(e).pathname.split("/").pop()??"download"}catch{n=s??"download"}const a=await fetch(e,{mode:"cors"});if(!a.ok)throw new Error(`HTTP ${a.status}`);const r=await a.blob(),i=URL.createObjectURL(r),o=document.createElement("a");o.href=i,o.download=n,o.style.display="none",document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(i)}const Js=({url:e,filename:s})=>{const[n,a]=m.useState(!1),r=i=>{i.stopPropagation();const o=window.open("","_blank","noopener,noreferrer");a(!0),Ks(e,s).then(()=>{o==null||o.close()}).catch(()=>{o&&(o.location.href=e)}).finally(()=>a(!1))};return t.jsx("button",{type:"button",onClick:r,disabled:n,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",children:n?t.jsx(N.CircleNotchIcon,{className:"size-4 animate-spin text-white",weight:"bold"}):t.jsxs(m.Fragment,{children:[t.jsx(N.DownloadSimpleIcon,{className:"size-4 text-white",weight:"bold"}),"Download"]})})};function ke(e){var u,f,c,g;const s=(u=e.attachments)==null?void 0:u.find(w=>w.type==="video"&&w.asset_url),n=(f=e.attachments)==null?void 0:f.find(w=>w.type==="image"&&w.image_url),a=(c=e.attachments)==null?void 0:c.find(w=>w.type==="audio"&&w.asset_url),r=(g=e.attachments)==null?void 0:g.find(w=>w.type==="file"&&w.asset_url),i=s??n??a??r,o=(s==null?void 0:s.asset_url)??(n==null?void 0:n.image_url)??(a==null?void 0:a.asset_url)??(r==null?void 0:r.asset_url);if(!o)return null;const l=(i==null?void 0:i.mime_type)??((i==null?void 0:i.type)==="image"?"image/jpeg":(i==null?void 0:i.type)==="video"?"video/mp4":(i==null?void 0:i.type)==="audio"?"audio/mpeg":"application/octet-stream"),d=i==null?void 0:i.title,h=i==null?void 0:i.file_size,x=s==null?void 0:s.thumb_url;return{resolvedUrl:o,resolvedType:l,title:d,fileSize:h,thumbnailUrl:x}}const Ht=({resolvedUrl:e,resolvedType:s,title:n,fileSize:a,thumbnailUrl:r})=>{const i=a!==void 0?Gt(a):void 0;return t.jsx(Vt,{variant:"dark",title:n,placeholderTitle:"",mimeType:s,detail:i,thumbnail:t.jsx(Ve,{mimeType:s,sourceUrl:e,thumbnailUrl:r,title:n,variant:"dark"})})},Yt=({resolvedUrl:e,resolvedType:s,title:n,fileSize:a,thumbnailUrl:r})=>{const i=ee(s),o=a!==void 0?Gt(a):void 0;return t.jsx(Vt,{variant:"light",title:n,mimeType:s,detail:o,thumbnail:t.jsx(Ve,{mimeType:s,sourceUrl:e,thumbnailUrl:r,title:n,variant:"light",containedImage:i==="image"||i==="document"}),action:t.jsx(Js,{url:e,filename:n})})},Zs=({message:e,isMyMessage:s=!1})=>{const n=Ce(e),a=ke(e);if(!n&&!a)return null;const r=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";return t.jsxs("div",{className:r,children:[!s&&e.user&&t.jsx(se,{className:"str-chat__avatar str-chat__message-sender-avatar",id:e.user.id,image:e.user.image,name:e.user.name??e.user.id}),t.jsx("div",{className:"str-chat__message-inner",style:{marginInlineEnd:0,marginInlineStart:0},children:t.jsx("div",{className:"str-chat__message-bubble-wrapper",children:t.jsx("div",{className:"str-chat__message-bubble",style:{padding:0,borderRadius:0,overflow:"visible",background:"transparent"},children:n?t.jsx("div",{className:Ge(s),children:t.jsx(He,{attachment:n,isMyMessage:s})}):s?t.jsx(Ht,{...a}):t.jsx(Yt,{...a})})})})]})},Qs=({message:e})=>{const s=Ce(e);if(s)return t.jsx("div",{className:Ge(!0),children:t.jsx(He,{attachment:s,isMyMessage:!0})});const n=ke(e);return n?t.jsx(Ht,{...n}):null},en=({message:e})=>{const s=Ce(e);if(s)return t.jsx("div",{className:Ge(!1),children:t.jsx(He,{attachment:s,isMyMessage:!1})});const n=ke(e);return n?t.jsx(Yt,{...n}):null},tn=Object.assign(Zs,{Creator:Qs,Visitor:en}),sn={dark:"bg-[#121110]",light:"bg-[#e9eaed]"},nn={dark:"text-white",light:"text-[#080707]"},an={dark:"border-white/[0.08]",light:"border-black/[0.08]"},rn=e=>e==="dark"?"sender":"receiver",on={sender:{single:"rounded-tl-[18px] rounded-tr-[18px] rounded-bl-[18px] rounded-br-[18px]",first:"rounded-tl-[18px] rounded-tr-[18px] rounded-bl-[18px] rounded-br-[4px]",middle:"rounded-tl-[18px] rounded-tr-[4px] rounded-bl-[18px] rounded-br-[4px]",end:"rounded-tl-[18px] rounded-tr-[4px] rounded-bl-[18px] rounded-br-[18px]"},receiver:{single:"rounded-tl-[18px] rounded-tr-[18px] rounded-bl-[18px] rounded-br-[18px]",first:"rounded-tl-[18px] rounded-tr-[18px] rounded-bl-[4px] rounded-br-[18px]",middle:"rounded-tl-[4px] rounded-tr-[18px] rounded-bl-[4px] rounded-br-[18px]",end:"rounded-tl-[4px] rounded-tr-[18px] rounded-bl-[18px] rounded-br-[18px]"}},fe=({variant:e,text:s,bordered:n=!0,groupPosition:a="single",className:r,children:i,"data-testid":o})=>{const l=s!=null&&s!=="",d=on[rn(e)][a];return t.jsxs("div",{"data-testid":o,"data-group-position":a,className:C("relative w-[280px] overflow-hidden px-2 py-2",d,sn[e],nn[e],n&&"border",n&&an[e],r),children:[i,l?t.jsx("p",{className:C("whitespace-pre-wrap break-words leading-snug","pt-2","px-2"),children:s}):null]})},xe=({onClick:e,variant:s="overlay",ariaLabel:n="Dismiss attachment"})=>t.jsx("button",{type:"button",onClick:a=>{a.stopPropagation(),e()},"aria-label":n,className:C("flex size-6 items-center justify-center rounded-full text-white",s==="overlay"?"bg-[#121110]/85 backdrop-blur":"bg-white/15 hover:bg-white/25"),children:t.jsx(N.XIcon,{className:"size-3",weight:"bold"})}),ge=e=>e==="received"?"light":"dark",qt=({firstOfGroup:e,endOfGroup:s,groupedByUser:n})=>!n||e&&s?"single":e?"first":s?"end":"middle",ln=({src:e,mimeType:s,filename:n,items:a})=>a&&a.length>0?a:e?[{src:e,mimeType:s,filename:n}]:[],cn=({item:e,preload:s,trailingAction:n})=>t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("audio",{src:e.src,controls:!0,preload:e.preload??s,className:"block min-w-0 flex-1",children:e.mimeType?t.jsx("source",{src:e.src,type:e.mimeType}):null}),n??null]}),qe=({state:e,src:s,mimeType:n,filename:a,items:r,text:i,groupPosition:o,preload:l,onDismiss:d})=>{const h=ge(e),x=e==="composer"&&!!d,u=ln({src:s,mimeType:n,filename:a,items:r});if(u.length===0)return null;const f=l??(u.length>1?"none":"metadata");return t.jsx(fe,{variant:h,text:i,groupPosition:o,"data-testid":"audio-attachment",children:t.jsx("div",{className:"flex flex-col gap-2",children:u.map((c,g)=>t.jsx(cn,{item:c,preload:f,trailingAction:x&&g===0?t.jsx(xe,{onClick:d,variant:"inline"}):void 0},`${c.src}-${g}`))})})},dn=e=>t.jsx(qe,{...e,state:"composer"}),un=e=>t.jsx(qe,{...e,state:"sent"}),mn=e=>t.jsx(qe,{...e,state:"received"}),hn={Composer:dn,Sent:un,Received:mn};function Wt(e){return!Number.isFinite(e)||e<0?"":e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:e<1024*1024*1024?`${(e/(1024*1024)).toFixed(2)} MB`:`${(e/(1024*1024*1024)).toFixed(2)} GB`}const fn={pdf:"PDF",doc:"DOC",xls:"XLS",csv:"CSV",ppt:"PPT",zip:"ZIP",text:"TXT",markdown:"MD"};function Xt(e,s){if(s){const r=s.lastIndexOf(".");if(r>0&&r<s.length-1){const i=s.slice(r+1);if(i&&i.length<=5)return i.toUpperCase()}}if(!e)return;if(ee(e)==="document"){const r=Ut(e),i=fn[r];if(i)return i;if(e==="application/octet-stream")return}const a=e.split("/")[1];if(!(!a||a==="*"))return a.toUpperCase()}function Kt(e,s,n){const a=Xt(e,s),r=typeof n=="number"&&n>0?Wt(n):void 0;return[a,r].filter(Boolean).join(" · ")||void 0}function Q(e){try{const n=new URL(e).pathname.split("/").pop();return n&&n.length>0?decodeURIComponent(n):"download"}catch{return"download"}}const xn={dark:"text-white/55",light:"text-black/65"},gn={dark:"bg-white/10",light:"bg-black/5"},pn={dark:"text-white/85",light:"text-black/85"},Jt=({variant:e,filename:s,title:n,mimeType:a="application/octet-stream",fileSize:r,onActivate:i,activateLabel:o,trailingAction:l})=>{const d=n??s??"File",h=Kt(a,s,r),x=t.jsx("div",{className:C("flex size-10 shrink-0 items-center justify-center rounded-sm",gn[e]),"aria-hidden":!0,children:re(a,{className:C("size-6",pn[e]),weight:"regular"})}),u=t.jsxs("div",{className:"flex min-w-0 flex-1 flex-col text-left",children:[t.jsx("p",{className:"truncate font-medium leading-snug",children:d}),h?t.jsx("p",{className:C("truncate text-xs leading-4",xn[e]),children:h}):null]}),f=i?t.jsxs("button",{type:"button",onClick:i,"aria-label":o,className:C("flex min-w-0 flex-1 items-center gap-3 rounded-sm text-left transition-colors",e==="dark"?"hover:bg-white/[0.04]":"hover:bg-black/[0.04]"),children:[x,u]}):t.jsxs(t.Fragment,{children:[x,u]});return t.jsxs("div",{className:"flex items-center gap-3 px-3 py-2",children:[f,l?t.jsx("div",{className:"shrink-0",children:l}):null]})};async function Zt(e,s){const n=s??Q(e);try{const a=await fetch(e,{mode:"cors"});if(!a.ok)throw new Error(`HTTP ${a.status}`);const r=await a.blob(),i=URL.createObjectURL(r),o=document.createElement("a");o.href=i,o.download=n,o.style.display="none",document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(i)}catch{if(!window.open(e,"_blank","noopener,noreferrer")){const r=document.createElement("a");r.href=e,r.download=n,r.target="_blank",r.rel="noopener noreferrer",r.style.display="none",document.body.appendChild(r),r.click(),document.body.removeChild(r)}}}const bn=({src:e,filename:s,fileSize:n,mimeType:a,title:r,items:i})=>i&&i.length>0?i:e?[{src:e,filename:s,fileSize:n,mimeType:a,title:r}]:[],vn=({variant:e,item:s,index:n,onActivate:a,trailingAction:r})=>{const i=s.filename??Q(s.src);return t.jsx(Jt,{variant:e,filename:i,title:s.title,mimeType:s.mimeType??"application/octet-stream",fileSize:s.fileSize,onActivate:()=>a(n),activateLabel:`Download ${i}`,trailingAction:r})},We=({state:e,src:s,filename:n,fileSize:a,mimeType:r,title:i,items:o,text:l,groupPosition:d,onClick:h,onDismiss:x})=>{const u=ge(e),f=e==="composer"&&!!x,c=bn({src:s,filename:n,fileSize:a,mimeType:r,title:i,items:o}),g=p=>{if((h==null?void 0:h(p))===!1)return;const b=c[p];if(!b)return;const v=b.filename??Q(b.src);Zt(b.src,v)};if(c.length===0)return null;const w=t.jsx("span",{className:C("flex size-8 items-center justify-center rounded-full",u==="dark"?"text-white/70":"text-black/70"),"aria-hidden":!0,children:t.jsx(N.DownloadSimpleIcon,{className:"size-5",weight:"bold"})});return t.jsx(fe,{variant:u,text:l,groupPosition:d,"data-testid":"file-attachment",children:t.jsx("div",{className:"flex flex-col gap-2",children:c.map((p,b)=>{const v=f&&b===0?t.jsx(xe,{onClick:x,variant:"inline"}):w;return t.jsx(vn,{variant:u,item:p,index:b,onActivate:g,trailingAction:v},`${p.src}-${b}`)})})})},jn=e=>t.jsx(We,{...e,state:"composer"}),wn=e=>t.jsx(We,{...e,state:"sent"}),_n=e=>t.jsx(We,{...e,state:"received"}),Nn={Composer:jn,Sent:wn,Received:_n},Xe=({onPrev:e,onNext:s,prevLabel:n="Previous",nextLabel:a="Next"})=>t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:e,"aria-label":n,className:"mes-media-viewer__nav mes-media-viewer__nav--prev",children:t.jsx(N.CaretLeftIcon,{size:20,weight:"bold","aria-hidden":!0})}),t.jsx("button",{type:"button",onClick:s,"aria-label":a,className:"mes-media-viewer__nav mes-media-viewer__nav--next",children:t.jsx(N.CaretRightIcon,{size:20,weight:"bold","aria-hidden":!0})})]}),Qt=({url:e,filename:s,variant:n="pill",label:a="Download",iconOnly:r,tone:i="dark",onTriggered:o})=>{const[l,d]=m.useState(!1),h=m.useCallback(c=>{c.stopPropagation(),!l&&(d(!0),Zt(e,s).catch(()=>{}).finally(()=>{d(!1),o==null||o()}))},[l,e,s,o]),x=r??n!=="pill",f={className:C(n==="pill"?"size-4":"size-5","shrink-0"),weight:"bold"};if(n==="inline"){const c={dark:"text-white/70 hover:bg-white/[0.08] hover:text-white",light:"text-black/70 hover:bg-black/[0.08] hover:text-black"};return t.jsx("button",{type:"button",onClick:h,disabled:l,"aria-label":a,className:C("flex size-8 shrink-0 items-center justify-center rounded-full transition-colors disabled:opacity-70",c[i]),children:l?t.jsx(N.CircleNotchIcon,{className:"size-4 animate-spin",weight:"bold","aria-hidden":!0}):t.jsx(N.DownloadSimpleIcon,{className:"size-5 shrink-0",weight:"bold","aria-hidden":!0})})}return n==="viewer"?t.jsx("button",{type:"button",onClick:h,disabled:l,"aria-label":a,className:"mes-media-viewer__action",children:l?t.jsx(N.CircleNotchIcon,{size:20,weight:"bold","aria-hidden":!0}):t.jsx(N.DownloadSimpleIcon,{size:20,weight:"bold","aria-hidden":!0})}):t.jsxs("button",{type:"button",onClick:h,disabled:l,"aria-label":x?a:void 0,className:C("mt-3 inline-flex h-10 w-full items-center justify-center gap-2 rounded-full px-4 text-sm font-medium leading-none transition-colors disabled:opacity-70",i==="dark"?"bg-[#121110] text-white hover:bg-[#2a2928]":"bg-white text-[#121110] hover:bg-white/90"),children:[l?t.jsx(N.CircleNotchIcon,{className:"size-4 animate-spin",weight:"bold","aria-hidden":!0}):t.jsx(N.DownloadSimpleIcon,{...f,"aria-hidden":!0}),x?null:a]})},Ee=(e,s,n)=>Math.min(Math.max(e,s),n),Ke=({length:e,initialIndex:s,open:n})=>{const a=Ee(s,0,Math.max(e-1,0)),[r,i]=m.useState(a);m.useEffect(()=>{n&&i(Ee(s,0,Math.max(e-1,0)))},[n,s,e]),m.useEffect(()=>{i(d=>Ee(d,0,Math.max(e-1,0)))},[e]);const o=m.useCallback(()=>{e<=1||i(d=>d<=0?e-1:d-1)},[e]),l=m.useCallback(()=>{e<=1||i(d=>d>=e-1?0:d+1)},[e]);return m.useEffect(()=>{if(!n||e<=1)return;const d=h=>{if(h.key!=="ArrowLeft"&&h.key!=="ArrowRight")return;const x=document.activeElement;x&&(x.tagName==="VIDEO"||x.tagName==="AUDIO")||(h.preventDefault(),h.key==="ArrowLeft"?o():l())};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[n,e,o,l]),{index:r,prev:o,next:l}},Je=({open:e,onClose:s,ariaLabel:n,counter:a,actions:r,children:i,"data-testid":o})=>{const l=m.useRef(null),d=m.useRef(null);m.useEffect(()=>{var f;const u=l.current;if(u){if(e){if(!u.open)if(typeof u.showModal=="function")try{u.showModal()}catch{u.setAttribute("open","")}else u.setAttribute("open","");const c=typeof document<"u"?document.activeElement:null;return(f=d.current)==null||f.focus(),()=>{if(u.open)if(typeof u.close=="function")try{u.close()}catch{u.removeAttribute("open")}else u.removeAttribute("open");c&&document.body.contains(c)&&c.focus()}}if(u.open)if(typeof u.close=="function")try{u.close()}catch{u.removeAttribute("open")}else u.removeAttribute("open")}},[e]);const h=()=>{s()},x=u=>{u.target===l.current&&s()};return t.jsxs("dialog",{ref:l,className:"mes-media-viewer","aria-label":n??"Attachment viewer","data-testid":o,onClose:h,onClick:x,children:[t.jsxs("div",{className:"mes-media-viewer__chrome",children:[a?t.jsx("span",{className:"mes-media-viewer__counter",children:a}):null,t.jsxs("div",{className:"mes-media-viewer__actions",children:[r,t.jsx("button",{ref:d,type:"button",onClick:s,"aria-label":"Close viewer",className:"mes-media-viewer__action",children:t.jsx(N.XIcon,{size:20,weight:"bold","aria-hidden":!0})})]})]}),t.jsx("div",{className:"mes-media-viewer__body",children:i})]})},es=({open:e,items:s,initialIndex:n=0,onClose:a})=>{const{index:r,prev:i,next:o}=Ke({length:s.length,initialIndex:n,open:e}),l=s[r],d=m.useMemo(()=>(l==null?void 0:l.filename)??(l?Q(l.src):"image"),[l]);return l?t.jsxs(Je,{open:e,onClose:a,ariaLabel:d,counter:s.length>1?`${r+1} / ${s.length}`:void 0,actions:t.jsx(Qt,{url:l.src,filename:d,variant:"viewer",label:`Download ${d}`}),"data-testid":"image-viewer",children:[t.jsx("img",{src:l.src,alt:l.alt??d,draggable:!1,loading:"eager",decoding:"async",className:"mes-media-viewer__image"},`${r}:${l.src}`),s.length>1?t.jsx(Xe,{onPrev:i,onNext:o,prevLabel:"Previous image",nextLabel:"Next image"}):null]}):null},yn="relative block size-full overflow-hidden bg-black/5 outline-none focus-visible:ring-2 focus-visible:ring-white/80 focus-visible:ring-offset-2 focus-visible:ring-offset-black",ts=({tiles:e,onTileActivate:s,maxVisible:n=4,className:a})=>{const r=e.length;if(r===0)return null;const i=e.slice(0,Math.min(r,n)),o=r-i.length,l=(d,h,x)=>{const u=C(yn,"h-full w-full");return s?t.jsxs("button",{type:"button",onClick:()=>s(h),"aria-label":d.ariaLabel??`Open media ${h+1}`,className:C(u,"cursor-zoom-in"),children:[d.content,x]},h):t.jsxs("div",{className:u,children:[d.content,x]},h)};return i.length===1?t.jsx("div",{className:C("aspect-square w-full",a),children:l(i[0],0)}):i.length===2?t.jsx("div",{className:C("grid aspect-[16/9] w-full grid-cols-2 gap-0.5",a),children:i.map((d,h)=>l(d,h))}):i.length===3?t.jsxs("div",{className:C("grid aspect-[4/3] w-full grid-cols-2 grid-rows-2 gap-0.5",a),children:[t.jsx("div",{className:"row-span-2",children:l(i[0],0)}),l(i[1],1),l(i[2],2)]}):t.jsx("div",{className:C("grid aspect-[4/3] w-full grid-cols-2 grid-rows-2 gap-0.5",a),children:i.map((d,h)=>{const x=o>0&&h===i.length-1;return l(d,h,x?t.jsxs("div",{className:"absolute inset-0 flex items-center justify-center bg-black/55 text-2xl font-semibold text-white",children:["+",o]}):null)})})},pe=e=>{const[s,n]=m.useState(!1),[a,r]=m.useState(0),i=m.useCallback(l=>{(e==null?void 0:e(l))!==!1&&(r(l),n(!0))},[e]),o=m.useCallback(()=>n(!1),[]);return{viewerOpen:s,viewerIndex:a,handleActivate:i,closeViewer:o}},Cn=(e,s,n,a)=>({ariaLabel:`Open image ${s+1} of ${n}`,content:t.jsx("img",{src:e.src,alt:e.alt??"",width:e.width,height:e.height,draggable:!1,loading:e.loading??a,decoding:"async",className:"absolute inset-0 size-full rounded-md object-cover"})}),kn=({src:e,alt:s,items:n})=>n&&n.length>0?n:e?[{src:e,alt:s}]:[],ss=(e,s)=>e.map((n,a)=>({src:n.src,alt:n.alt,filename:s&&e.length===1?s:s?`${s} (${a+1})`:void 0})),Sn=({src:e,alt:s,filename:n,loading:a="lazy",onClick:r,onDismiss:i})=>{const{viewerOpen:o,viewerIndex:l,handleActivate:d,closeViewer:h}=pe(r);return t.jsxs("div",{className:"relative w-fit",children:[t.jsx("button",{type:"button",onClick:()=>d(0),"aria-label":"Open image",className:"block size-[280px] cursor-zoom-in overflow-hidden rounded-md outline-none focus-visible:ring-2 focus-visible:ring-black/40",children:t.jsx("img",{src:e,alt:s??"",draggable:!1,loading:a,decoding:"async",className:"size-full object-cover"})}),i?t.jsx("div",{className:"absolute right-2 top-2 z-10",children:t.jsx(xe,{onClick:i})}):null,t.jsx(es,{open:o,items:ss([{src:e,alt:s}],n),initialIndex:l,onClose:h})]})},ns=({state:e,src:s,alt:n,filename:a,items:r,text:i,groupPosition:o,loading:l="lazy",onClick:d})=>{const h=kn({src:s,alt:n,items:r}),x=ge(e),{viewerOpen:u,viewerIndex:f,handleActivate:c,closeViewer:g}=pe(d);if(h.length===0)return null;const w=h.map((p,b)=>Cn(p,b,h.length,l));return t.jsxs(fe,{variant:x,text:i,groupPosition:o,"data-testid":"image-attachment",children:[t.jsx("div",{className:"relative",children:t.jsx(ts,{tiles:w,onTileActivate:c})}),t.jsx(es,{open:u,items:ss(h,a),initialIndex:f,onClose:g})]})},In=e=>t.jsx(Sn,{...e}),En=e=>t.jsx(ns,{...e,state:"sent"}),Tn=e=>t.jsx(ns,{...e,state:"received"}),An={Composer:In,Sent:En,Received:Tn},Mn=({open:e,items:s,initialIndex:n=0,onClose:a})=>{const{index:r,prev:i,next:o}=Ke({length:s.length,initialIndex:n,open:e}),l=s[r],d=m.useMemo(()=>(l==null?void 0:l.filename)??(l?Q(l.src):"document"),[l]),h=m.useMemo(()=>l?Rn(l.src):void 0,[l]);return!l||!h?null:t.jsxs(Je,{open:e,onClose:a,ariaLabel:d,counter:s.length>1?`${r+1} / ${s.length}`:void 0,"data-testid":"pdf-viewer",children:[t.jsx("iframe",{src:h,title:d,className:"mes-media-viewer__iframe",sandbox:"allow-scripts allow-forms allow-popups allow-downloads"},`${r}:${l.src}`),s.length>1?t.jsx(Xe,{onPrev:i,onNext:o,prevLabel:"Previous document",nextLabel:"Next document"}):null]})},Rn=e=>{const s=e.indexOf("#"),n=s===-1?e:e.slice(0,s),a=s===-1?"":e.slice(s+1),r=new URLSearchParams(a);return r.has("toolbar")||r.set("toolbar","0"),r.has("navpanes")||r.set("navpanes","0"),`${n}#${r.toString()}`},Ln=({src:e,filename:s,fileSize:n,title:a,items:r})=>r&&r.length>0?r:e?[{src:e,filename:s,fileSize:n,title:a}]:[],Dn=({variant:e,item:s,index:n,onActivate:a,trailingAction:r})=>{const i=s.filename??Q(s.src);return t.jsx(Jt,{variant:e,filename:i,title:s.title,mimeType:"application/pdf",fileSize:s.fileSize,onActivate:()=>a(n),activateLabel:`Open ${i}`,trailingAction:r})},Ze=({state:e,src:s,filename:n,fileSize:a,title:r,items:i,text:o,groupPosition:l,onClick:d,onDismiss:h})=>{const x=ge(e),u=Ln({src:s,filename:n,fileSize:a,title:r,items:i}),{viewerOpen:f,viewerIndex:c,handleActivate:g,closeViewer:w}=pe(d),p=e==="composer"&&!!h;if(u.length===0)return null;const b=u.map(v=>({src:v.src,filename:v.filename??Q(v.src)}));return t.jsxs(fe,{variant:x,text:o,groupPosition:l,"data-testid":"pdf-attachment",children:[t.jsx("div",{className:"flex flex-col gap-2",children:u.map((v,S)=>{const R=v.filename??Q(v.src),k=p&&S===0?t.jsx(xe,{onClick:h,variant:"inline"}):e==="composer"?void 0:t.jsx(Qt,{url:v.src,filename:R,variant:"inline",label:`Download ${R}`,tone:x});return t.jsx(Dn,{variant:x,item:v,index:S,onActivate:g,trailingAction:k},`${v.src}-${S}`)})}),t.jsx(Mn,{open:f,items:b,initialIndex:c,onClose:w})]})},Pn=e=>t.jsx(Ze,{...e,state:"composer"}),zn=e=>t.jsx(Ze,{...e,state:"sent"}),On=e=>t.jsx(Ze,{...e,state:"received"}),Fn={Composer:Pn,Sent:zn,Received:On},as=({open:e,items:s,initialIndex:n=0,onClose:a})=>{const{index:r,prev:i,next:o}=Ke({length:s.length,initialIndex:n,open:e}),l=s[r],d=m.useMemo(()=>(l==null?void 0:l.filename)??(l?Q(l.src):"video"),[l]);return l?t.jsxs(Je,{open:e,onClose:a,ariaLabel:d,counter:s.length>1?`${r+1} / ${s.length}`:void 0,"data-testid":"video-viewer",children:[t.jsx("video",{src:l.src,poster:l.poster,controls:!0,autoPlay:!0,muted:!0,playsInline:!0,preload:l.preload??"metadata",className:"mes-media-viewer__video",children:l.mimeType?t.jsx("source",{src:l.src,type:l.mimeType}):null},`${r}:${l.src}`),s.length>1?t.jsx(Xe,{onPrev:i,onNext:o,prevLabel:"Previous video",nextLabel:"Next video"}):null]}):null},$n=()=>t.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center",children:t.jsx("span",{className:"flex size-12 items-center justify-center rounded-full bg-black/55 text-white backdrop-blur",children:t.jsx(N.PlayIcon,{className:"size-6",weight:"fill","aria-hidden":!0})})}),rs=({item:e,index:s})=>t.jsxs("div",{className:"absolute inset-0 size-full bg-[#0d0d0d]",children:[e.poster?t.jsx("img",{src:e.poster,alt:`Video ${s+1} thumbnail`,draggable:!1,loading:"lazy",decoding:"async",className:"absolute inset-0 size-full rounded-md object-cover"}):t.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:t.jsx(N.VideoCameraIcon,{className:"size-16 rounded-md text-white/30",weight:"regular","aria-hidden":!0})}),t.jsx($n,{})]}),Bn=(e,s,n)=>({ariaLabel:`Play video ${s+1} of ${n}`,content:t.jsx(rs,{item:e,index:s})}),Un=({src:e,poster:s,mimeType:n,preload:a,items:r})=>r&&r.length>0?a?r.map(i=>({...i,preload:i.preload??a})):r:e?[{src:e,poster:s,mimeType:n,preload:a}]:[],is=(e,s)=>e.map((n,a)=>({src:n.src,poster:n.poster,mimeType:n.mimeType,preload:n.preload,filename:s&&e.length===1?s:s?`${s} (${a+1})`:void 0})),Vn=({src:e,poster:s,mimeType:n,filename:a,preload:r,onClick:i,onDismiss:o})=>{const{viewerOpen:l,viewerIndex:d,handleActivate:h,closeViewer:x}=pe(i);return t.jsxs("div",{className:"relative w-fit",children:[t.jsx("button",{type:"button",onClick:()=>h(0),"aria-label":"Play video",className:"relative block size-[280px] cursor-pointer overflow-hidden rounded-md outline-none focus-visible:ring-2 focus-visible:ring-black/40",children:t.jsx(rs,{item:{src:e,poster:s,mimeType:n},index:0})}),o?t.jsx("div",{className:"absolute right-2 top-2 z-10",children:t.jsx(xe,{onClick:o})}):null,t.jsx(as,{open:l,items:is([{src:e,poster:s,mimeType:n,preload:r}],a),initialIndex:d,onClose:x})]})},os=({state:e,src:s,poster:n,mimeType:a,filename:r,items:i,text:o,groupPosition:l,preload:d,onClick:h})=>{const x=Un({src:s,poster:n,mimeType:a,preload:d,items:i}),u=ge(e),{viewerOpen:f,viewerIndex:c,handleActivate:g,closeViewer:w}=pe(h);if(x.length===0)return null;const p=x.map((b,v)=>Bn(b,v,x.length));return t.jsxs(fe,{variant:u,text:o,groupPosition:l,"data-testid":"video-attachment",children:[t.jsx("div",{className:"relative",children:t.jsx(ts,{tiles:p,onTileActivate:g,className:"overflow-hidden rounded-md"})}),t.jsx(as,{open:f,items:is(x,r),initialIndex:c,onClose:w})]})},Gn=e=>t.jsx(Vn,{...e}),Hn=e=>t.jsx(os,{...e,state:"sent"}),Yn=e=>t.jsx(os,{...e,state:"received"}),qn={Composer:Gn,Sent:Hn,Received:Yn},de={Image:An,Video:qn,Audio:hn,Pdf:Fn,File:Nn},Wn={isUnlocking:()=>!1},Xn={LockedAttachment:Wn},ls=m.createContext({}),Kn=ls.Provider;function cs(e){return m.useContext(ls)[e]??Xn[e]}const Jn=({size:e=15})=>t.jsx("svg",{width:e,height:e,viewBox:"0 0 15 15",fill:"none","aria-hidden":"true",children:t.jsx("path",{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",fill:"currentColor",fillOpacity:.55})}),Zn=e=>{var s;return((s=e.metadata)==null?void 0:s.custom_type)==="MESSAGE_TIP"},Qn=e=>{var s;return((s=e.metadata)==null?void 0:s.custom_type)==="MESSAGE_PAID"},we=e=>{var s;return((s=e.metadata)==null?void 0:s.custom_type)==="MESSAGE_CHATBOT"},ea=e=>{var s;return((s=e.metadata)==null?void 0:s.custom_type)==="MESSAGE_ATTACHMENT"},ds=e=>Zn(e)||Qn(e),ta=e=>{var s;return ds(e)&&!((s=e.text)!=null&&s.trim())},Te=({message:e,standalone:s=!1,isMyMessage:n=!1,hasAttachment:a=!1})=>{var u;const r=ds(e),i=we(e);if(!r&&!i)return null;if(r){const f=(u=e.metadata)==null?void 0:u.amount_text;if(!f)return null;const c=s?"message-tip-standalone":"message-tag message-tag--tip",g=s?`${f} tip`:`Delivered with ${f} tip`;return t.jsxs("div",{className:c,children:[t.jsx(N.GiftIcon,{size:s?14:12}),t.jsx("span",{children:g})]})}const o=n&&a,l=o?"Sent with AI":"Sent by AI Assistant",d=["message-chatbot-indicator",n?"message-chatbot-indicator--sender":"message-chatbot-indicator--receiver",o?"message-chatbot-indicator--attachment":"message-chatbot-indicator--text"].join(" "),h=t.jsx("span",{className:"message-chatbot-indicator__label",children:l}),x=t.jsx("span",{className:"message-chatbot-indicator__icon",children:t.jsx(Jn,{size:o?12:15})});return t.jsx("div",{className:d,"data-testid":"message-chatbot-indicator",children:n&&!o?t.jsxs(t.Fragment,{children:[h,x]}):t.jsxs(t.Fragment,{children:[x,h]})})},us=({selected:e,onVoteUp:s,onVoteDown:n})=>t.jsxs("div",{className:"message-vote-buttons",children:[t.jsx("button",{type:"button",className:C("message-vote-button focus-ring",{"message-vote-button--selected":e==="up"}),onClick:s,"aria-label":"Good response","aria-pressed":e==="up","data-tooltip":"Good response",children:t.jsx(N.ThumbsUpIcon,{size:16,weight:e==="up"?"fill":"regular"})}),t.jsx("button",{type:"button",className:C("message-vote-button focus-ring",{"message-vote-button--selected":e==="down"}),onClick:n,"aria-label":"Bad response","aria-pressed":e==="down","data-tooltip":"Bad response",children:t.jsx(N.ThumbsDownIcon,{size:16,weight:e==="down"?"fill":"regular"})})]}),sa=/^([a-z][a-z0-9+.-]*):/i,na=new Set(["http","https","mailto","tel","sms"]);function Qe(e){if(typeof e!="string")return;const s=e.trim();if(s==="")return;const n=sa.exec(s);if(n){const a=n[1].toLowerCase();return na.has(a)?s:void 0}return s.startsWith("//")||s.startsWith("/")?s:`https://${s}`}const aa={dark:"bg-white text-[#121110] hover:bg-white/90",light:"bg-[#121110] text-white hover:bg-[#2a2928]"},ra=({variant:e,cta:s})=>{const n=C("mt-2 inline-flex h-10 w-full items-center justify-center rounded-full px-4 text-sm font-medium leading-none transition-colors",aa[e]),a=Qe(s.href);return a?t.jsx("a",{href:a,target:"_blank",rel:"noopener noreferrer",onClick:r=>{var i;r.stopPropagation(),(i=s.onClick)==null||i.call(s)},className:`${n} no-underline`,children:s.label}):t.jsx("button",{type:"button",onClick:r=>{var i;r.stopPropagation(),(i=s.onClick)==null||i.call(s)},className:n,children:s.label})},ia={dark:"text-white",light:"text-black/90"},oa="text-white/30",la={dark:"text-white/55",light:"text-black/55"},et=({variant:e,title:s,placeholderTitle:n,description:a,url:r,appIcon:i,cta:o,trailingAction:l})=>{const d=e==="dark",h=s??(d?n:void 0)??"",x=h.trim()!=="",u=a!=null&&a.trim()!=="",f=typeof r=="string"?r.trim():"",c=f!=="",g=o!=null;if(!x&&!u&&!c&&!g)return null;const p=C("truncate text-base font-medium leading-6",d&&!s?oa:ia[e]),b=C("truncate text-xs leading-4",la[e]);return t.jsxs("div",{className:"px-4 py-3",children:[t.jsxs("div",{className:"flex items-end gap-3",children:[t.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-2",children:[t.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[x&&t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[i?t.jsx("span",{className:"shrink-0",children:i}):null,t.jsx("p",{className:C("min-w-0",p),children:h})]}),u&&t.jsx("p",{className:b,children:a})]}),!g&&c&&t.jsx("p",{className:b,children:f})]}),l&&t.jsx("div",{className:"shrink-0",children:l})]}),o&&t.jsx(ra,{variant:e,cta:o})]})},ca=C("relative block w-[280px] select-none overflow-hidden rounded-md","border border-black/[0.08]","shadow-[0_1px_2px_rgba(0,0,0,0.04),0_8px_32px_rgba(0,0,0,0.1)]"),_e=({variant:e,children:s,href:n,onClick:a,ariaLabel:r,rootRef:i,topRight:o,bgClassName:l,"data-testid":d})=>{const h=n!=null||a!=null,x=C(ca,l??(e==="dark"?"bg-[#121110]":"bg-white"),h?"cursor-pointer no-underline focus-ring":null),u=o?t.jsx("div",{className:"pointer-events-auto absolute right-3 top-3 z-10",children:o}):null;return n?t.jsxs("a",{ref:i,href:n,target:"_blank",rel:"noopener noreferrer",onClick:a,"data-testid":d,className:x,children:[s,u]}):a?t.jsxs("button",{ref:i,type:"button",onClick:a,"aria-label":r,"data-testid":d,className:C(x,"text-left"),children:[s,u]}):t.jsxs("div",{ref:i,"data-testid":d,className:x,children:[s,u]})},da={dark:"bg-white/10",light:"bg-black/5"},ua={dark:"size-16 text-white/25",light:"size-16 text-black/25"},Se=(e,s)=>!!s&&!!e&&ee(e)==="audio",ms=(e,s)=>{if(!s||!e)return!1;const n=ee(e);return n==="video"||n==="audio"},tt="bg-[#F2F3F4]",Ne=({variant:e,thumbnailUrl:s,sourceUrl:n,title:a,mimeType:r="image/*",topLeft:i,topRight:o})=>{const l=ee(r),d=!!n&&l==="video";return Se(r,n)?t.jsx("div",{className:"p-3",children:t.jsx("audio",{src:n,controls:!0,preload:"metadata",className:"block w-full",children:t.jsx("track",{kind:"captions"})})}):t.jsxs("div",{className:C("relative h-[180px] w-full overflow-hidden",d&&"bg-black"),children:[d?t.jsx("video",{src:n,poster:s,controls:!0,playsInline:!0,preload:"metadata",className:"absolute inset-0 h-full w-full object-contain",children:t.jsx("track",{kind:"captions"})}):s?t.jsx("img",{src:s,alt:a??"",draggable:!1,className:"absolute inset-0 h-full w-full object-cover"}):t.jsx("div",{className:C("flex h-full w-full items-center justify-center",da[e]),children:re(r,{className:ua[e],weight:"regular"})}),i?t.jsx("div",{className:"pointer-events-auto absolute left-3 top-3 z-10",children:i}):null,o?t.jsx("div",{className:"pointer-events-auto absolute right-3 top-3 z-10",children:o}):null]})},ma=({title:e,placeholderTitle:s,description:n,url:a,mimeType:r,thumbnailUrl:i,sourceUrl:o,layout:l="featured",appIcon:d,cta:h,onDismiss:x,onEditClick:u})=>{const f=l==="classic",c=Se(r,o),g=x?t.jsx("button",{type:"button",onClick:x,"aria-label":"Dismiss attachment",className:"flex size-6 items-center justify-center rounded-full bg-[#121110] text-white",children:t.jsx(N.XIcon,{className:"size-3",weight:"bold"})}):void 0,w=u?t.jsx("button",{type:"button",onClick:u,"aria-label":"Edit attachment",className:"flex size-10 items-center justify-center rounded-full bg-white/10 text-white hover:bg-white/15",children:t.jsx(N.PencilSimpleIcon,{className:"size-5",weight:"regular"})}):void 0;return c?t.jsx(_e,{variant:"dark",bgClassName:tt,children:t.jsxs("div",{className:"flex items-center gap-2 pr-3",children:[t.jsx("div",{className:"min-w-0 flex-1",children:t.jsx(Ne,{variant:"dark",sourceUrl:o,title:e,mimeType:r})}),g&&t.jsx("div",{className:"shrink-0",children:g})]})}):t.jsxs(_e,{variant:"dark",topRight:f?g:void 0,children:[!f&&t.jsx(Ne,{variant:"dark",thumbnailUrl:i,sourceUrl:o,title:e,mimeType:r,topRight:g}),t.jsx(et,{variant:"dark",title:e,placeholderTitle:s,description:n,url:a,appIcon:d,cta:h,trailingAction:w})]})},ha=({title:e,description:s,url:n,mimeType:a,thumbnailUrl:r,sourceUrl:i,layout:o="featured",appIcon:l,cta:d,onClick:h})=>{const x=ms(a,i),u=Qe(n),f=d==null&&u!=null&&!x?u:void 0,c=d==null&&!x?h:void 0,g=Se(a,i)?tt:void 0,w=d&&h?{...d,onClick:()=>{var p;h(),(p=d.onClick)==null||p.call(d)}}:d;return t.jsxs(_e,{variant:"light",href:f,onClick:c,ariaLabel:e??"Open attachment preview",bgClassName:g,"data-testid":"link-attachment",children:[o==="featured"&&t.jsx(Ne,{variant:"light",thumbnailUrl:r,sourceUrl:i,title:e,mimeType:a}),t.jsx(et,{variant:"light",title:e,description:s,url:n,appIcon:l,cta:w})]})},fa=({title:e,placeholderTitle:s,description:n,url:a,mimeType:r,thumbnailUrl:i,sourceUrl:o,layout:l="featured",appIcon:d,cta:h,onClick:x})=>{const u=ms(r,o),f=Qe(a),c=h==null&&f!=null&&!u?f:void 0,g=h==null&&!u&&c!=null?x:void 0;return t.jsxs(_e,{variant:"dark",href:c,onClick:g,bgClassName:Se(r,o)?tt:void 0,children:[l==="featured"&&t.jsx(Ne,{variant:"dark",thumbnailUrl:i,sourceUrl:o,title:e,mimeType:r}),t.jsx(et,{variant:"dark",title:e,placeholderTitle:s,description:n,url:a,appIcon:d,cta:h})]})},ze={Composer:ma,Sent:fa,Received:ha},xa="mt-[2px] max-w-[280px] whitespace-pre-wrap break-words rounded-[18px] bg-[#121110] px-4 py-2 text-white",ga="mt-[2px] max-w-[280px] whitespace-pre-wrap break-words rounded-[18px] bg-[#e9eaed] px-4 py-2 text-[#080707]";function P(e){const s=e==null?void 0:e.trim();return s||void 0}function It(e){return e.trim().replace(/^https?:\/\//i,"").replace(/\/+$/,"").toLowerCase()}function pa(e,s){if(!(e!=null&&e.trim())||!(s!=null&&s.trim()))return!1;const n=It(e),a=It(s);if(n===a)return!0;if(!n.includes(a))return!1;const r=n.split(a).join("");return!/[^\p{P}\p{Z}\p{C}]/u.test(r)}function Et(e){const s=P(e.og_scrape_url)??P(e.title_link),n=P(e.image_url)??P(e.thumb_url);return{title:P(e.title),description:P(e.text),url:s,thumbnailUrl:n,layout:n?"featured":"classic",mimeType:P(e.mime_type)}}function ba(e){var s;return hs(e)?null:e.type==="image"?e.image_url||e.asset_url?"image":null:e.type==="video"&&e.asset_url?"video":e.type==="audio"&&e.asset_url?"audio":e.type==="file"&&e.asset_url?e.mime_type==="application/pdf"?"pdf":(s=e.mime_type)!=null&&s.startsWith("audio/")?"audio":"file":null}function hs(e){const s=P(e.og_scrape_url);return e.type==="link"||!!s&&!e.asset_url}function fs(e){if(!(e!=null&&e.length))return[];const s=[],n=(r,i)=>{const o=s[s.length-1];if((o==null?void 0:o.type)==="media"&&o.kind===r){o.attachments.push(i);return}s.push({type:"media",kind:r,attachments:[i]})},a=r=>{const i=s[s.length-1];if((i==null?void 0:i.type)==="link"){i.attachments.push(r);return}s.push({type:"link",attachments:[r]})};for(const r of e){if(hs(r)){a(r);continue}const i=ba(r);i&&n(i,r)}return s}function va(e){let s=0;for(const n of e)s+=n.type==="link"?n.attachments.length:1;return s}function ja(e){return e.filter(s=>s.type==="media").length}function wa(e,s,n){return s<=1?n:e===0?"first":e===s-1?"end":"middle"}function Tt(e){return P(e.image_url)??P(e.asset_url)??""}function _a(e){switch(e){case"image":return de.Image;case"video":return de.Video;case"audio":return de.Audio;case"pdf":return de.Pdf;default:return de.File}}function Na(e,s){if(s.length>1)switch(e){case"image":return{items:s.map(a=>({src:Tt(a),alt:P(a.title)}))};case"video":return{items:s.map(a=>({src:P(a.asset_url)??"",poster:P(a.thumb_url),mimeType:P(a.mime_type)}))};case"audio":return{items:s.map(a=>({src:P(a.asset_url)??"",mimeType:P(a.mime_type)??"audio/mpeg",filename:P(a.title)}))};case"pdf":return{items:s.map(a=>({src:P(a.asset_url)??"",filename:P(a.title),fileSize:a.file_size}))};case"file":return{items:s.map(a=>({src:P(a.asset_url)??"",filename:P(a.title),fileSize:a.file_size,mimeType:P(a.mime_type)??"application/octet-stream"}))}}const n=s[0];if(!n)return{};switch(e){case"image":return{src:Tt(n),alt:P(n.title)};case"video":return{src:P(n.asset_url)??"",poster:P(n.thumb_url),mimeType:P(n.mime_type)};case"audio":return{src:P(n.asset_url)??"",mimeType:P(n.mime_type)??"audio/mpeg",filename:P(n.title)};case"pdf":return{src:P(n.asset_url)??"",filename:P(n.title),fileSize:n.file_size};case"file":return{src:P(n.asset_url)??"",filename:P(n.title),fileSize:n.file_size,mimeType:P(n.mime_type)??"application/octet-stream"}}}function ya({groupPosition:e,isMyMessage:s,segment:n,text:a}){const r=_a(n.kind),i={...Na(n.kind,n.attachments),groupPosition:e,...a?{text:a}:{}};return s?t.jsx(r.Sent,{...i}):t.jsx(r.Received,{...i})}const Ca=({groupPosition:e,isMyMessage:s,message:n})=>{var w;const a=fs(n.attachments);if(a.length===0)return null;const r=va(a),i=ja(a),o=(w=n.text)==null?void 0:w.trim(),l=a.find(p=>p.type==="link"),d=(l==null?void 0:l.type)==="link"?Et(l.attachments[0]??{}).url:void 0,h=o&&pa(o,d)?void 0:o;let x=0,u=0;const f=[],c=(p,b)=>{const v=x===r-1;x+=1;const S=s?ze.Sent:ze.Received;f.push(t.jsxs(m.Fragment,{children:[t.jsx(S,{...Et(p)}),v&&h?t.jsx("div",{className:s?xa:ga,children:h}):null]},b))},g=(p,b)=>{const v=x===r-1,S=wa(u,i,e);x+=1,u+=1,f.push(t.jsx(ya,{groupPosition:S,isMyMessage:s,segment:p,text:v?h:void 0},b))};return a.forEach((p,b)=>{if(p.type==="link"){p.attachments.forEach((v,S)=>{c(v,`link-${b}-${S}`)});return}g(p,`media-${b}`)}),t.jsx(t.Fragment,{children:f})},ka=e=>{var lt,ct,dt,ut,mt,ht,ft,xt,gt,pt,bt,vt,jt,wt;const{additionalMessageInputProps:s,chatbotVotingEnabled:n,editing:a,endOfGroup:r,firstOfGroup:i,groupedByUser:o,handleAction:l,handleOpenThread:d,handleRetry:h,highlighted:x,isMessageAIGenerated:u,isMyMessage:f,message:c,renderText:g,threadList:w,viewerLanguage:p}=e,{client:b}=_.useChatContext("CustomMessage"),{channel:v}=_.useChannelStateContext("CustomMessage"),{isUnlocking:S,onUnlockClick:R,onFetchSource:k,onDownloadClick:L}=cs("LockedAttachment"),[F,z]=m.useState(!1),E=_.useMessageReminder(c.id),{selected:D,voteUp:A,voteDown:O}=Ot(c),{Attachment:y=_.Attachment,EditMessageModal:I=_.EditMessageModal,MessageActions:T,MessageBlocked:B=_.MessageBlocked,MessageBouncePrompt:$=_.MessageBouncePrompt,MessageDeleted:H=_.MessageDeleted,MessageIsThreadReplyInChannelButtonIndicator:J=_.MessageIsThreadReplyInChannelButtonIndicator,MessageRepliesCountButton:K=_.MessageRepliesCountButton,ReminderNotification:q=_.ReminderNotification,StreamedMessageText:j=_.StreamedMessageText,PinIndicator:M}=_.useComponentContext("CustomMessage"),V=_.messageHasAttachments(c),G=_.messageHasReactions(c),W=m.useMemo(()=>u==null?void 0:u(c),[u,c]),U=m.useMemo(()=>{const ae=c.attachments??[],je=c.shared_location?[c.shared_location,...ae]:ae;if(!we(c))return je;const _t=je.filter(Nt=>!("type"in Nt)||!Ye(Nt));return _t.length===je.length?je:_t},[c]),X=m.useMemo(()=>fs(U),[U]),Y=m.useMemo(()=>{const ae=Be({message:c,viewerLanguage:p});return ae===c.text?c:{...c,text:ae}},[c,p]),be=X.some(ae=>ae.type==="link"),ve=qt({endOfGroup:r,firstOfGroup:i,groupedByUser:o});if(_.isDateSeparatorMessage(c))return null;if(c.deleted_at||c.type==="deleted")return t.jsx(H,{message:c});if(_.isMessageBlocked(c))return t.jsx(B,{});const ue=!w&&!!c.reply_count,Z=!w&&c.show_in_channel&&c.parent_id,ne=c.status==="failed"&&((lt=c.error)==null?void 0:lt.status)!==403,te=_.isMessageBounced(c);let ie;ne?ie=()=>h(c):te&&(ie=()=>z(!0));const oe=f(),_s=C("str-chat__message str-chat__message-simple",`str-chat__message--${c.type}`,`str-chat__message--${c.status}`,oe?"str-chat__message--me str-chat__message-simple--me":"str-chat__message--other",c.text?"str-chat__message--has-text":"has-no-text",{"str-chat__message--has-attachment":V,"str-chat__message--highlighted":x,"str-chat__message--pinned pinned-message":c.pinned,"str-chat__message--with-reactions":G,"str-chat__message-send-can-be-retried":(c==null?void 0:c.status)==="failed"&&((ct=c==null?void 0:c.error)==null?void 0:ct.status)!==403,"str-chat__message-with-thread-link":ue||Z,"str-chat__virtual-message__wrapper--end":r,"str-chat__virtual-message__wrapper--first":i,"str-chat__virtual-message__wrapper--group":o}),at=c.poll_id&&b.polls.fromState(c.poll_id),rt=ta(c),me=we(c),it=ea(c),Ie=!!(U!=null&&U.length&&!c.quoted_message),ot=me&&oe&&Ie;return t.jsxs(t.Fragment,{children:[a&&t.jsx(I,{additionalMessageInputProps:s}),F&&t.jsx(_.MessageBounceModal,{MessageBouncePrompt:$,onClose:()=>z(!1),open:F}),t.jsxs("div",{className:_s,"data-message-id":c.id,children:[M&&t.jsx(M,{}),!!E&&t.jsx(q,{reminder:E}),c.user&&t.jsx(se,{className:"str-chat__avatar str-chat__message-sender-avatar",id:c.user.id,image:c.user.image,name:c.user.name||c.user.id,size:24,shape:"circle",dmAgentEnabled:me}),t.jsx("div",{className:C("str-chat__message-inner",{"str-chat__simple-message--error-failed":ne||te}),"data-testid":"message-inner",onClick:ie,onKeyDown:ie,role:ie?"button":void 0,tabIndex:ie?0:void 0,style:{marginInlineEnd:0,marginInlineStart:0},children:it?t.jsxs("div",{className:"str-chat__message-bubble-wrapper",children:[oe?t.jsxs("div",{className:"flex items-center gap-2",children:[T&&t.jsx(T,{}),t.jsx(Pe.Sent,{title:(dt=c.metadata)==null?void 0:dt.attachment_title,mimeType:(ut=c.metadata)==null?void 0:ut.attachment_mime_type,thumbnailUrl:(mt=c.metadata)==null?void 0:mt.attachment_thumbnail,amountText:(ht=c.metadata)==null?void 0:ht.amount_text,detail:(ft=c.metadata)==null?void 0:ft.attachment_detail,paymentStatus:(xt=c.metadata)==null?void 0:xt.payment_status,onPreviewClick:()=>R==null?void 0:R(c,v),onFetchSource:async()=>await(k==null?void 0:k(c,v))})]}):t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Pe.Received,{title:(gt=c.metadata)==null?void 0:gt.attachment_title,mimeType:(pt=c.metadata)==null?void 0:pt.attachment_mime_type,thumbnailUrl:(bt=c.metadata)==null?void 0:bt.attachment_thumbnail,amountText:(vt=c.metadata)==null?void 0:vt.amount_text,detail:(jt=c.metadata)==null?void 0:jt.attachment_detail,paymentStatus:(wt=c.metadata)==null?void 0:wt.payment_status,isUnlocking:S(c.id),onUnlockClick:()=>R==null?void 0:R(c,v),onFetchSource:async()=>await(k==null?void 0:k(c,v)),onDownloadClick:()=>L==null?void 0:L(c,v)}),T&&t.jsx(T,{})]}),c.text&&t.jsx("div",{className:"str-chat__message-bubble",children:t.jsx(_.MessageText,{message:Y,renderText:g})})]}):rt?t.jsx(Te,{message:c,standalone:!0}):be?t.jsx("div",{className:"str-chat__message-bubble-wrapper",children:t.jsxs("div",{className:"str-chat__message-bubble",style:{background:"transparent",borderRadius:0,overflow:"visible",padding:0},children:[t.jsx(Ca,{groupPosition:ve,isMyMessage:oe,message:{attachments:U,text:Y.text}}),t.jsx(_.MessageErrorIcon,{})]})}):t.jsx("div",{className:"str-chat__message-bubble-wrapper",children:t.jsxs("div",{className:"str-chat__message-bubble",children:[me&&!ot&&t.jsx(Te,{message:c,hasAttachment:Ie,isMyMessage:oe}),at&&t.jsx(_.Poll,{poll:at}),U!=null&&U.length&&!c.quoted_message?t.jsx(y,{actionHandler:l,attachments:U}):null,W?t.jsx(j,{message:Y,renderText:g}):t.jsx(_.MessageText,{message:Y,renderText:g}),t.jsx(_.MessageErrorIcon,{})]})})}),!it&&!rt&&t.jsxs("div",{className:"str-chat__message-footer",children:[(!me||ot)&&t.jsx(Te,{message:c,hasAttachment:Ie,isMyMessage:oe}),n&&me&&t.jsx(us,{selected:D,onVoteUp:A,onVoteDown:O})]}),ue&&t.jsx(K,{onClick:d,reply_count:c.reply_count}),Z&&t.jsx(J,{})]},c.id)]})},Sa=m.memo(ka,(e,s)=>e.chatbotVotingEnabled!==s.chatbotVotingEnabled||e.viewerLanguage!==s.viewerLanguage?!1:_.areMessageUIPropsEqual(e,s)),Ia=e=>{const s=_.useMessageContext("CustomMessage");return t.jsx(Sa,{...s,...e})},Ea=()=>{var n;const{handleDelete:e,message:s}=_.useMessageContext("CustomMessageActions");return((n=s.metadata)==null?void 0:n.payment_status)==="paid"?null:t.jsx(Oe.DefaultDropdownActionButton,{onClick:e,"aria-label":"Delete",title:"Delete",className:"bg-marble rounded-full p-2 hover:bg-sand transition-all",children:t.jsx(N.TrashSimpleIcon,{size:16,weight:"light","aria-hidden":!0})})},Ta=()=>{const{handleFlag:e}=_.useMessageContext("CustomMessageActions");return t.jsx(Oe.DefaultDropdownActionButton,{onClick:e,"aria-label":"Report",title:"Report",className:"bg-marble rounded-full p-2 hover:bg-sand transition-all",children:t.jsx(N.FlagIcon,{size:16,weight:"light","aria-hidden":!0})})},Aa=()=>{var s;const{message:e}=_.useMessageContext("CustomMessageActions");return((s=e.metadata)==null?void 0:s.custom_type)!=="MESSAGE_ATTACHMENT"?null:t.jsx(Oe.MessageActions,{messageActionSet:[{Component:Ea,placement:"quick",type:"delete"},{Component:Ta,placement:"quick",type:"flag"}]})},Ma=({link:e,onDismiss:s})=>{const{og_scrape_url:n,title:a,image_url:r}=e,i=o=>{o.preventDefault(),s(n)};return t.jsxs("a",{href:n,target:"_blank",rel:"noopener noreferrer",className:"relative block w-full rounded-[24px] bg-[#121110] p-2 no-underline transition-opacity hover:opacity-90",children:[r&&t.jsx("img",{src:r,alt:a||"",className:"h-[180px] w-full rounded-[20px] object-cover"}),t.jsx("button",{type:"button",onClick:i,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","aria-label":"Close link preview",children:t.jsx(N.XIcon,{className:"size-4 text-black/90"})}),t.jsxs("div",{className:"p-2",children:[a&&t.jsx("div",{className:"truncate text-[14px] font-medium leading-5 text-white",children:a}),t.jsx("div",{className:"truncate text-[12px] leading-4 text-white/55",children:n})]})]})},Ra=e=>({linkPreviews:Array.from(e.previews.values()).filter(s=>Re.LinkPreviewsManager.previewIsLoaded(s)||Re.LinkPreviewsManager.previewIsLoading(s))}),La=()=>{const{linkPreviewsManager:e}=_.useMessageComposer(),{linkPreviews:s}=_.useStateStore(e.state,Ra),n=r=>{e.dismissPreview(r)};return s.length>0?t.jsx("div",{className:"flex flex-col items-stretch w-full gap-2 mb-4",children:s.map(r=>t.jsx(Ma,{link:r,onDismiss:n},r.og_scrape_url))}):null},st=m.createContext(!1),Da=()=>m.useContext(st),Pa=({sendMessage:e,disabled:s,...n})=>t.jsx("button",{...n,type:"button","aria-label":"Send",disabled:s,onClick:e,children:t.jsx(N.ArrowUpIcon,{weight:"bold",className:"size-4"})}),za=()=>{const e=m.useContext(st),{handleSubmit:s}=_.useMessageInputContext(),n=_.useMessageComposerHasSendableData(),a=e||!n,{SendButton:r=Pa,AttachmentPreviewList:i=_.AttachmentPreviewList}=_.useComponentContext("CustomMessageInput");return t.jsxs("div",{className:"central-container flex flex-col gap-2 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:[t.jsx(_.QuotedMessagePreview,{}),t.jsx(La,{}),t.jsx(i,{}),t.jsxs("div",{className:"flex",children:[t.jsx("div",{className:"w-full ml-2 mr-4 self-center leading-[0]",children:t.jsx(_.TextareaComposer,{"aria-disabled":e||void 0,className:"w-full resize-none outline-none leading-5 placeholder:text-black/30 text-sm",autoFocus:!e,maxRows:4,readOnly:e,tabIndex:e?-1:void 0})}),t.jsx(r,{sendMessage:s,"aria-label":"Send",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","data-testid":"send-button",disabled:a,type:"button"})]})]})},Oa=({renderActions:e,renderFooter:s,disabled:n=!1,disabledReason:a,composerInput:r})=>{var l;const{channel:i}=_.useChannelStateContext(),o=((l=i==null?void 0:i.data)==null?void 0:l.frozen)===!0;return n?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"messaging-composer-locked-panel flex w-full flex-col items-center justify-center gap-3 px-6 py-4",children:a?t.jsx("p",{className:"max-w-[345px] text-center text-xs font-normal leading-[1.3] tracking-[0.12px] text-black/40",children:a}):null}),s==null?void 0:s()]}):t.jsxs("div",{className:"flex flex-col gap-4 p-4",children:[t.jsxs("div",{inert:o?"":void 0,"aria-disabled":o||void 0,className:"message-input flex items-end gap-4 aria-disabled:opacity-40",children:[e&&t.jsx("div",{className:"flex h-12 shrink-0 items-center justify-center",children:e()}),t.jsx(st.Provider,{value:o,children:t.jsx(_.MessageInput,{Input:r??za})})]}),s==null?void 0:s()]})},Fa=["SYSTEM_DM_AGENT_PAUSED","SYSTEM_DM_AGENT_RESUMED"],$a={SYSTEM_DM_AGENT_PAUSED:"DM Agent has left the conversation",SYSTEM_DM_AGENT_RESUMED:"DM Agent has rejoined the conversation"},Ba=["SYSTEM_AGE_SAFETY_BLOCKED"],Ua={SYSTEM_AGE_SAFETY_BLOCKED:"This user isn’t able to reply because they don’t meet our age safety guidelines."},Ae="age safety guidelines.",Va="https://linktr.ee/s/about/contact",At=e=>Fa.includes(e),Ga=e=>Ba.includes(e),Ha=e=>{var a;const s=(a=e.metadata)==null?void 0:a.custom_type;if(At(s))return{kind:"dm-agent",type:s};if(Ga(s))return{kind:"age-safety",type:s};const n=e.dm_agent_system_type;if(At(n))return{kind:"dm-agent",type:n}},Ya=e=>{const s=e.indexOf(Ae);if(s===-1)return e;const n=s+Ae.length;return t.jsxs(t.Fragment,{children:[e.slice(0,s),t.jsx("a",{href:Va,target:"_blank",rel:"noopener noreferrer",className:"mes-age-safety-system-message__emphasis font-medium text-inherit underline",children:Ae}),e.slice(n)]})},qa=e=>{var a,r;const s=e.message.hide_date===!0,n=Ha(e.message);if((n==null?void 0:n.kind)==="dm-agent"){const i=((a=e.message.text)==null?void 0:a.trim())||$a[n.type];return t.jsxs("div",{className:"str-chat__message--system","data-testid":"message-system",children:[t.jsxs("div",{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)]","data-testid":"dm-agent-system-message","data-dm-agent-system-type":n.type,children:[t.jsx(N.SparkleIcon,{size:16,weight:"regular","aria-hidden":!0,className:"mes-dm-agent-system-message__sparkle shrink-0"}),t.jsx("p",{className:"mes-dm-agent-system-message__text m-0 text-center text-[14px] font-normal leading-5 tracking-[0.21px]",children:i})]}),!s&&t.jsx(_.MessageTimestamp,{message:e.message})]})}if((n==null?void 0:n.kind)==="age-safety"){const i=((r=e.message.text)==null?void 0:r.trim())||Ua[n.type];return t.jsxs("div",{className:"str-chat__message--system","data-testid":"message-system",children:[t.jsxs("div",{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)]","data-testid":"age-safety-system-message","data-age-safety-system-type":n.type,children:[t.jsx(N.ProhibitIcon,{size:24,weight:"duotone","aria-hidden":!0,className:"mes-age-safety-system-message__icon shrink-0 text-[color:var(--text-warning-on-warning,#894b00)]","data-testid":"age-safety-system-message-icon"}),t.jsx("div",{className:"mes-age-safety-system-message__content min-w-0 flex-[1_0_0]",children:t.jsx("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:Ya(i)})})]}),!s&&t.jsx(_.MessageTimestamp,{message:e.message})]})}return t.jsxs("div",{className:"str-chat__message--system","data-testid":"message-system",children:[t.jsxs("div",{className:"str-chat__message--system__text",children:[t.jsx("div",{className:"str-chat__message--system__line"}),t.jsx("p",{children:e.message.text}),t.jsx("div",{className:"str-chat__message--system__line"})]}),!s&&t.jsx(_.MessageTimestamp,{message:e.message})]})},xs=m.createContext(!1),Me=({cx:e,index:s})=>t.jsx("circle",{cx:e,cy:"6.15",r:"3.9",fill:"#A0A0A0",children:t.jsx("animateTransform",{attributeName:"transform",type:"translate",values:"0 0; 0 -2.25; 0 0;",dur:"900ms",begin:`${120*s}ms`,repeatCount:"indefinite"})}),Wa=new Set([_.AIStates.Thinking,_.AIStates.Generating,_.AIStates.ExternalSources]),Xa=({threadList:e})=>{var g,w;const{channel:s,channelConfig:n,thread:a}=_.useChannelStateContext(),{client:r}=_.useChatContext(),{typing:i={}}=_.useTypingContext(),{aiState:o}=_.useAIState(s),l=m.useContext(xs);if(!e&&l&&Wa.has(o)){const p=Ka(s,(g=r.user)==null?void 0:g.id);return t.jsx(Mt,{avatarId:(p==null?void 0:p.id)??"ai-agent",avatarName:(p==null?void 0:p.name)??(p==null?void 0:p.id)??"Agent",avatarImage:p==null?void 0:p.image,testId:"typing-indicator-ai"})}if((n==null?void 0:n.typing_events)===!1)return null;const h=e?[]:Object.values(i).filter(({parent_id:p,user:b})=>{var v;return(b==null?void 0:b.id)!==((v=r.user)==null?void 0:v.id)&&!p}),x=e?Object.values(i).filter(({parent_id:p,user:b})=>{var v;return(b==null?void 0:b.id)!==((v=r.user)==null?void 0:v.id)&&p===(a==null?void 0:a.id)}):[],u=e?x:h;if(!u.length)return null;const f=(w=u[0])==null?void 0:w.user,c=f!=null&&f.id&&s.state.members[f.id]?s.state.members[f.id].user:void 0;return t.jsx(Mt,{avatarId:(f==null?void 0:f.id)??(c==null?void 0:c.id)??"typing-user",avatarName:(f==null?void 0:f.name)??(c==null?void 0:c.name)??(f==null?void 0:f.id)??"Typing user",avatarImage:(f==null?void 0:f.image)??(c==null?void 0:c.image),testId:"typing-indicator"})},Mt=({avatarId:e,avatarName:s,avatarImage:n,testId:a})=>t.jsx("div",{className:"str-chat__li str-chat__li--single str-chat__typing-indicator !static","data-testid":a,style:{marginBottom:"var(--messaging-channel-input-spacer-height, 80px)"},children:t.jsxs("div",{className:"str-chat__message str-chat__message-simple str-chat__message--regular str-chat__message--received str-chat__message--other str-chat__message--has-text",children:[t.jsx(se,{className:"str-chat__avatar str-chat__message-sender-avatar",id:e,name:s,image:n??void 0,size:24,shape:"circle"}),t.jsx("div",{className:"str-chat__message-inner mx-0",children:t.jsx("div",{className:"str-chat__message-bubble-wrapper",children:t.jsx("div",{className:"str-chat__message-bubble",children:t.jsx("div",{className:"str-chat__message-text min-h-11 flex items-center",children:t.jsx("div",{className:"str-chat__message-text-inner str-chat__message-simple-text-inner",children:t.jsxs("svg",{"aria-hidden":"true",className:"block overflow-visible",viewBox:"0 0 32 12.3",width:"32",height:"13",overflow:"visible",children:[t.jsx(Me,{cx:"4",index:0}),t.jsx(Me,{cx:"16",index:1}),t.jsx(Me,{cx:"28",index:2})]})})})})})})]})});function Ka(e,s){var a;const n=((a=e==null?void 0:e.state)==null?void 0:a.members)??{};for(const r of Object.values(n)){const i=r==null?void 0:r.user;if(i&&i.id!==s)return i}}const gs=()=>null,Ja=({className:e,message:s})=>t.jsxs("div",{className:C("flex items-center justify-center h-full",e),children:[t.jsxs("svg",{viewBox:"0 0 100 100",className:"size-8 fill-pebble",stroke:"none",children:[t.jsx("circle",{cx:"6",cy:"50",r:"6",children:t.jsx("animateTransform",{attributeName:"transform",dur:"1s",type:"translate",values:"0 15 ; 0 -15; 0 15",repeatCount:"indefinite",begin:"0.1"})}),t.jsx("circle",{cx:"30",cy:"50",r:"6",children:t.jsx("animateTransform",{attributeName:"transform",dur:"1s",type:"translate",values:"0 10 ; 0 -10; 0 10",repeatCount:"indefinite",begin:"0.2"})}),t.jsx("circle",{cx:"54",cy:"50",r:"6",children:t.jsx("animateTransform",{attributeName:"transform",dur:"1s",type:"translate",values:"0 5 ; 0 -5; 0 5",repeatCount:"indefinite",begin:"0.3"})})]}),s&&t.jsx("span",{className:"text-stone",children:s})]}),ye=m.memo(()=>t.jsx("div",{className:"messaging-loading-state flex items-center justify-center h-full",children:t.jsxs("div",{className:"flex items-center",children:[t.jsx(Ja,{className:"w-6 h-6"}),t.jsx("span",{className:"text-sm text-stone",children:"Loading messages"})]})}));ye.displayName="LoadingState";const le="size-10 rounded-full hover:bg-[#E5E4E1] flex items-center justify-center transition-colors duration-150 focus-ring",Rt="Replies instantly with AI assistant",Za=({onBack:e,showBackButton:s,showStarButton:n=!1,dmAgentEnabled:a=!1,onLeaveConversation:r,onBlockParticipant:i,showDeleteConversation:o=!0,showBlockParticipant:l=!0,showReportParticipant:d=!0,onDeleteConversationClick:h,onBlockParticipantClick:x,onReportParticipantClick:u,customChannelActions:f,renderChannelActions:c,showChannelInfo:g=!0,onParticipantNameClick:w,renderHeaderTitleBadges:p})=>{var z,E,D,A,O;const{channel:b}=_.useChannelStateContext(),v=m.useMemo(()=>{var T,B;const y=(T=b._client)==null?void 0:T.userID;return y?Object.values(((B=b.state)==null?void 0:B.members)||{}).find($=>{var H;return((H=$.user)==null?void 0:H.id)&&$.user.id!==y}):void 0},[(z=b._client)==null?void 0:z.userID,(E=b.state)==null?void 0:E.members]),S=$e(v==null?void 0:v.user),R=(D=v==null?void 0:v.user)==null?void 0:D.image,k=Pt(b),L=p==null?void 0:p({channel:b,participant:v}),F=async()=>{try{k?await b.unpin():await b.pin()}catch(y){console.error("[CustomChannelHeader] Failed to update pinned status:",y)}};return t.jsxs("div",{className:"@container",children:[t.jsxs("div",{className:"grid grid-cols-[1fr_auto_1fr] w-full items-center @lg:hidden px-6 py-3",children:[t.jsx("div",{className:"flex items-center gap-2",children:s&&t.jsx("button",{className:C(le,"messaging-channel-view-back-button-mobile bg-[#F1F0EE]"),onClick:e||(()=>{}),type:"button","aria-label":"Back to conversations",children:t.jsx(N.ArrowLeftIcon,{className:"size-5 text-black/90"})})}),t.jsxs("div",{className:"flex flex-col gap-1 items-center",children:[t.jsx(se,{id:((A=v==null?void 0:v.user)==null?void 0:A.id)||b.id||"unknown",name:S,image:R,starred:n&&k,dmAgentEnabled:a,size:48}),w?t.jsxs("button",{type:"button",onClick:w,"aria-label":`View details for ${S}`,className:"flex max-w-full items-center gap-0.5 rounded text-center text-xs font-medium text-black/90 transition-opacity hover:opacity-70",children:[t.jsx("span",{className:"min-w-0 truncate",children:S}),L&&t.jsx("span",{className:"shrink-0",children:L}),t.jsx(N.CaretRightIcon,{className:"size-3 shrink-0",weight:"bold"})]}):t.jsxs("p",{className:"flex max-w-full items-center justify-center gap-1 text-center text-xs font-medium text-black/90",children:[t.jsx("span",{className:"min-w-0 truncate",children:S}),L&&t.jsx("span",{className:"shrink-0",children:L})]}),a&&t.jsxs("div",{className:"flex items-center gap-1 text-[10px] leading-3 text-black/55",children:[t.jsx(N.SparkleIcon,{className:"size-3 shrink-0 text-black/55"}),t.jsx("span",{children:Rt})]})]}),t.jsxs("div",{className:"flex justify-end items-center gap-2",children:[n&&t.jsx("button",{className:le,onClick:F,type:"button","aria-label":k?"Unstar conversation":"Star conversation",children:t.jsx(N.StarIcon,{className:C("size-5",{"text-yellow-600":k,"text-black/90":!k}),weight:k?"duotone":"regular"})}),g&&(c!==void 0?c:t.jsx(kt,{channel:b,participant:v,showDeleteConversation:o,showBlockParticipant:l,showReportParticipant:d,onLeaveConversation:r,onBlockParticipant:i,onDeleteConversationClick:h,onBlockParticipantClick:x,onReportParticipantClick:u,customChannelActions:f,triggerClassName:C(le,"bg-[#F1F0EE]")}))]})]}),t.jsxs("div",{className:"px-6 py-3 hidden @lg:flex items-center justify-between gap-3 min-h-12 border-b border-b-black/[0.08]",children:[t.jsxs("div",{className:"flex items-center gap-4 min-w-0",children:[s&&e&&t.jsx("button",{className:C(le,"messaging-channel-view-back-button-desktop"),type:"button",onClick:e,"aria-label":"Back to conversations",children:t.jsx(N.ArrowLeftIcon,{className:"size-5 text-black/90"})}),t.jsx(se,{id:((O=v==null?void 0:v.user)==null?void 0:O.id)||b.id||"unknown",name:S,image:R,starred:n&&k,dmAgentEnabled:a,size:48}),t.jsxs("div",{className:"min-w-0",children:[w?t.jsxs("button",{type:"button",onClick:w,"aria-label":`View details for ${S}`,className:"flex min-w-0 max-w-full items-center gap-1 rounded font-medium text-black/90 transition-opacity hover:opacity-70",children:[t.jsx("span",{className:"min-w-0 truncate",children:S}),L&&t.jsx("span",{className:"shrink-0",children:L}),t.jsx(N.CaretRightIcon,{className:"size-4 shrink-0",weight:"bold"})]}):t.jsxs("h1",{className:"flex min-w-0 items-center gap-1 font-medium text-black/90",children:[t.jsx("span",{className:"min-w-0 truncate",children:S}),L&&t.jsx("span",{className:"shrink-0",children:L})]}),a&&t.jsxs("div",{className:"mt-0.5 flex items-center gap-1 text-[10px] leading-3 text-black/55",children:[t.jsx(N.SparkleIcon,{className:"size-3 shrink-0 text-black/55"}),t.jsx("span",{className:"truncate",children:Rt})]})]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[n&&t.jsx("button",{className:le,onClick:F,type:"button","aria-label":k?"Unstar conversation":"Star conversation",children:t.jsx(N.StarIcon,{className:C("size-6",{"text-yellow-600":k,"text-black/90":!k}),weight:k?"duotone":"regular"})}),g&&(c!==void 0?c:t.jsx(kt,{channel:b,participant:v,showDeleteConversation:o,showBlockParticipant:l,showReportParticipant:d,onLeaveConversation:r,onBlockParticipant:i,onDeleteConversationClick:h,onBlockParticipantClick:x,onReportParticipantClick:u,customChannelActions:f,triggerClassName:le}))]})]})]})},Qa=({onBack:e,showBackButton:s,renderMessageInputActions:n,renderMessageInputFooter:a,renderConversationFooter:r,onLeaveConversation:i,onBlockParticipant:o,showDeleteConversation:l=!0,onDeleteConversationClick:d,onBlockParticipantClick:h,onReportParticipantClick:x,showBlockParticipant:u=!0,showReportParticipant:f=!0,composerDisabled:c=!1,composerDisabledReason:g,showStarButton:w=!1,chatbotVotingEnabled:p=!1,renderChannelBanner:b,renderHeaderTitleBadges:v,customChannelActions:S,renderChannelActions:R,renderMessage:k,dmAgentEnabled:L=!1,viewerLanguage:F,showChannelInfo:z=!0,onParticipantNameClick:E,composerInput:D})=>{var H,J,K,q,j,M;const{channel:A}=_.useChannelStateContext(),O=m.useMemo(()=>{var W,U;const V=(W=A._client)==null?void 0:W.userID;return V?Object.values(((U=A.state)==null?void 0:U.members)||{}).find(X=>{var Y;return((Y=X.user)==null?void 0:Y.id)&&X.user.id!==V}):void 0},[(H=A._client)==null?void 0:H.userID,(J=A.state)==null?void 0:J.members]),y=m.useMemo(()=>{var W,U;const V=(W=A._client)==null?void 0:W.userID;return V?Object.values(((U=A.state)==null?void 0:U.members)||{}).find(X=>{var Y;return((Y=X.user)==null?void 0:Y.id)===V}):void 0},[(K=A._client)==null?void 0:K.userID,(q=A.state)==null?void 0:q.members]),I=((j=y==null?void 0:y.user)==null?void 0:j.is_account)??(y==null?void 0:y.is_account),T=((M=O==null?void 0:O.user)==null?void 0:M.is_account)??(O==null?void 0:O.is_account),B=L&&I===!1&&T===!0,$=m.useCallback(V=>{const{message:G}=_.useMessageContext("ChannelView"),W=t.jsx(Ia,{...V,chatbotVotingEnabled:p,viewerLanguage:F});return!k||!G?W:k(W,G)},[p,k,F]);return t.jsx(t.Fragment,{children:t.jsx(_.WithComponents,{overrides:{Message:$,MessageActions:Aa},children:t.jsxs(_.Window,{children:[t.jsx("div",{children:t.jsx(Za,{onBack:e,showBackButton:s,showChannelInfo:z,showStarButton:w,dmAgentEnabled:B,onLeaveConversation:i,onBlockParticipant:o,showDeleteConversation:l,showBlockParticipant:u,showReportParticipant:f,onDeleteConversationClick:d,onBlockParticipantClick:h,onReportParticipantClick:x,customChannelActions:S,renderChannelActions:R,onParticipantNameClick:E,renderHeaderTitleBadges:v})},"lt-channel-header"),b?t.jsx(m.Fragment,{children:b()},"lt-channel-banner"):null,t.jsx("div",{className:"flex-1 overflow-hidden relative",children:t.jsx(_.MessageList,{hideDeletedMessages:!0,hideNewMessageSeparator:!1})},"lt-channel-message-list"),r?t.jsx(m.Fragment,{children:r(A)},"lt-channel-conversation-footer"):null,t.jsx(Oa,{...n&&{renderActions:()=>n==null?void 0:n(A)},renderFooter:()=>a==null?void 0:a(A),disabled:c,disabledReason:g,composerInput:D},"lt-channel-message-input")]})})})},nt=m.memo(({channel:e,onBack:s,showBackButton:n=!1,renderMessageInputActions:a,renderMessageInputFooter:r,renderConversationFooter:i,onLeaveConversation:o,onBlockParticipant:l,className:d,CustomChannelEmptyState:h=gs,showDeleteConversation:x=!0,onDeleteConversationClick:u,onBlockParticipantClick:f,onReportParticipantClick:c,showBlockParticipant:g=!0,showReportParticipant:w=!0,composerDisabled:p=!1,composerDisabledReason:b,dmAgentEnabled:v,messageMetadata:S,onMessageSent:R,showStarButton:k=!1,chatbotVotingEnabled:L=!1,renderChannelBanner:F,renderHeaderTitleBadges:z,customChannelActions:E,renderChannelActions:D,renderMessage:A,onMessageLinkClick:O,sendButton:y,attachmentPreviewList:I,viewerLanguage:T,showChannelInfo:B=!0,onParticipantNameClick:$,composerInput:H})=>{const J=m.useCallback(async(q,j,M)=>{var Y;const V=((Y=e.data)==null?void 0:Y.chatbot_paused)===!0,G=v&&!V,W={...j,...G&&{silent:!0},...S&&{metadata:{...j.metadata??{},...S}}},U={...M,...G&&{skip_push:!0}},X=await e.sendMessage(W,U);return R==null||R(X),X},[e,v,S,R]),K=m.useRef(null);return m.useEffect(()=>{if(!O)return;const q=K.current;if(!q)return;const j=M=>{const V=M.target,G=V==null?void 0:V.closest("a[href]"),W=G==null?void 0:G.getAttribute("href");if(!W)return;const U=G==null?void 0:G.closest("[data-message-id]"),X=U==null?void 0:U.getAttribute("data-message-id"),Y=X?e.state.messages.find(be=>be.id===X):void 0;O(W,Y)};return q.addEventListener("click",j),()=>q.removeEventListener("click",j)},[O,e]),t.jsx("div",{ref:K,className:C("messaging-channel-view h-full flex flex-col",d),children:t.jsx(xs.Provider,{value:v??!1,children:t.jsx(_.Channel,{channel:e,MessageSystem:qa,EmptyStateIndicator:h,LoadingIndicator:ye,DateSeparator:Ts,TypingIndicator:Xa,doSendMessageRequest:J,...y?{SendButton:y}:{},...I?{AttachmentPreviewList:I}:{},children:t.jsx(Qa,{onBack:s,showBackButton:n,renderMessageInputActions:a,renderMessageInputFooter:r,renderConversationFooter:i,onLeaveConversation:o,onBlockParticipant:l,CustomChannelEmptyState:h,showDeleteConversation:x,onDeleteConversationClick:u,onBlockParticipantClick:f,onReportParticipantClick:c,showBlockParticipant:g,showReportParticipant:w,composerDisabled:p,composerDisabledReason:b,showStarButton:k,dmAgentEnabled:v,chatbotVotingEnabled:L,renderChannelBanner:F,renderHeaderTitleBadges:z,customChannelActions:E,renderChannelActions:D,renderMessage:A,viewerLanguage:T,showChannelInfo:B,onParticipantNameClick:$,composerInput:H})})})})});nt.displayName="ChannelView";const he=m.memo(({message:e,onBack:s})=>t.jsx("div",{className:"messaging-error-state flex items-center justify-center h-full p-8",children:t.jsxs("div",{className:"text-center max-w-sm",children:[t.jsx("div",{className:"w-24 h-24 bg-danger-alt/20 rounded-full flex items-center justify-center mx-auto mb-6",children:t.jsx("span",{className:"text-4xl",children:"⚠️"})}),t.jsx("h2",{className:"font-semibold text-charcoal mb-2",children:"Oops!"}),t.jsx("p",{className:"text-stone text-sm mb-6",children:e}),s&&t.jsx("button",{type:"button",onClick:s,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",children:"Go Back"})]})}));he.displayName="ErrorState";const er=({capabilities:e={},renderMessageInputActions:s,renderConversationFooter:n,onChannelSelect:a,onExitConversation:r,initialParticipantFilter:i,initialParticipantData:o,CustomChannelEmptyState:l,onBlockParticipantClick:d,onReportParticipantClick:h,dmAgentEnabled:x,onMessageSent:u,chatbotVotingEnabled:f=!1,viewerLanguage:c,renderHeaderTitleBadges:g,renderChannelBanner:w,customChannelActions:p,renderChannelActions:b,onParticipantNameClick:v,renderMessage:S,onMessageLinkClick:R,showChannelInfo:k,composerInput:L})=>{const{client:F,isConnected:z,isLoading:E,error:D,refreshConnection:A,service:O,debug:y}=Dt(),[I,T]=m.useState(null),[B,$]=m.useState(null),[H,J]=m.useState(!1),{showDeleteConversation:K=!0}=e,q=m.useRef(o);q.current=o;const j=m.useRef(a);j.current=a;const M=m.useRef(null),V=m.useRef(null);m.useEffect(()=>{V.current=I},[I]),m.useEffect(()=>{if(!F||!z)return;const U=F.userID;if(!U)return;const X=`${U}::${i}`;if(M.current===X)return;M.current=X;const Y=()=>{M.current===X&&(M.current=null)};(async()=>{var ve,ue;try{y&&console.log("[MessagingShell] Loading initial conversation with:",i);const Z=await F.queryChannels({type:"messaging",members:{$eq:[U,i]}},{},{limit:1});if(Z.length>0){T(Z[0]),$(null),(ve=j.current)==null||ve.call(j,Z[0]),y&&console.log("[MessagingShell] Initial conversation loaded:",Z[0].id);return}const ne=q.current;if(!ne||!O){Y(),$("No conversation found with this account"),y&&console.log("[MessagingShell] No conversation found for:",i);return}try{const te=await O.startChannelWithParticipant({id:ne.id,name:ne.name,phone:ne.phone});T(te),$(null),(ue=j.current)==null||ue.call(j,te),y&&console.log("[MessagingShell] Channel created and loaded:",te.id)}catch(te){console.error("[MessagingShell] Failed to create conversation:",te),Y(),$("Failed to create conversation")}}catch(Z){console.error("[MessagingShell] Failed to load initial conversation:",Z),Y(),V.current||$("Failed to load conversation")}})()},[i,F,z,O,y]);const G=m.useRef(r);G.current=r;const W=m.useCallback(()=>{var U;T(null),J(!0),(U=G.current)==null||U.call(G)},[]);return E?t.jsx(ye,{}):D?t.jsx(he,{message:D,onBack:A}):!z||!F?t.jsx(he,{message:"Not connected to messaging service",onBack:A}):B?t.jsx(he,{message:B}):H&&!I?t.jsx(he,{message:"Conversation ended"}):I?t.jsx("div",{className:"messaging-shell h-full bg-background-primary overflow-hidden",children:t.jsx("div",{className:"flex h-full min-h-0 flex-col",children:t.jsx(nt,{channel:I,renderMessageInputActions:s,renderConversationFooter:n,renderChannelBanner:w,onLeaveConversation:W,onBlockParticipant:W,CustomChannelEmptyState:l,showDeleteConversation:K,onBlockParticipantClick:d,onReportParticipantClick:h,dmAgentEnabled:x,onMessageSent:u,chatbotVotingEnabled:f,viewerLanguage:c,renderHeaderTitleBadges:g,customChannelActions:p,renderChannelActions:b,onParticipantNameClick:v,renderMessage:S,onMessageLinkClick:R,showChannelInfo:k,composerInput:L},I.id)})}):t.jsx(ye,{})};function tr(e){const s=e.state.pending_messages;if(s!=null&&s.length)for(const n of s)e.state.addMessageSorted(n.message)}const ps=m.createContext({selectedChannel:void 0,onChannelSelect:()=>{},debug:!1,renderMessagePreview:void 0,viewerLanguage:void 0}),sr=ps.Provider,nr=()=>m.useContext(ps),ar=(e,s)=>{const n=new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate())),r=new Date(Date.UTC(s.getUTCFullYear(),s.getUTCMonth(),s.getUTCDate())).getTime()-n.getTime();return Math.floor(r/(1e3*60*60*24))},bs=e=>{const s=new Date;if(Math.floor((s.getTime()-e.getTime())/1e3)<60)return"Just now";const a=ar(e,s);return a===0?e.toLocaleTimeString([],{hour:"numeric",minute:"2-digit",hour12:!0}):a===1?"Yesterday":a<7?`${a}d`:a<28?`${Math.floor(a/7)}w`:e.toLocaleDateString("en-US",{month:"numeric",day:"numeric",year:"2-digit"})},vs=m.memo(({channel:e,unread:s})=>{var L,F,z;const{selectedChannel:n,onChannelSelect:a,debug:r,renderMessagePreview:i,viewerLanguage:o}=nr(),l=(n==null?void 0:n.id)===(e==null?void 0:e.id),d=()=>{e&&a(e)},h=E=>{const D=E.key==="Enter"||E.key===" ",A=E.repeat;!D||A||(E.preventDefault(),d())},u=Object.values(((L=e==null?void 0:e.state)==null?void 0:L.members)||{}).find(E=>{var D,A;return((D=E.user)==null?void 0:D.id)&&E.user.id!==((A=e==null?void 0:e._client)==null?void 0:A.userID)}),f=$e(u==null?void 0:u.user),c=(F=u==null?void 0:u.user)==null?void 0:F.image,g=(()=>{var D;const E=(D=e==null?void 0:e.state)==null?void 0:D.messages;if(E!=null&&E.length){for(let A=E.length-1;A>=0;A--)if(E[A].type!=="system")return E[A]}})(),p=(()=>{var I,T,B,$;const E=Be({message:g,viewerLanguage:o});if(((I=g==null?void 0:g.metadata)==null?void 0:I.custom_type)==="MESSAGE_TIP")return E?`💵 ${E}`:"💵 Sent a tip";if(((T=g==null?void 0:g.metadata)==null?void 0:T.custom_type)==="MESSAGE_PAID")return E?`💰 ${E}`:"💰 Sent a message";if(((B=g==null?void 0:g.metadata)==null?void 0:B.custom_type)==="MESSAGE_ATTACHMENT")return E?`📎 ${E}`:"📎 Sent an attachment";if(E)return E;const y=($=g==null?void 0:g.attachments)==null?void 0:$[0];return y?y.og_scrape_url?y.og_scrape_url:y.type==="image"?"📷 Sent an image":y.type==="video"?"🎥 Sent a video":y.type==="audio"?"🎵 Sent audio":y.type==="file"?"📎 Sent a file":"📎 Sent an attachment":"No messages yet"})(),b=g!=null&&g.created_at?bs(new Date(g.created_at)):"",v=g?we(g):!1,S=i?i(g,p):`${v?"✨ ":""}${p}`,R=Pt(e),k=s??0;return r&&console.log("📺 [ChannelList] 📋 CHANNEL PREVIEW RENDER",{channelId:e==null?void 0:e.id,isSelected:l,participantName:f,unreadCount:k,hasTimestamp:!!b}),t.jsx("div",{role:"button",tabIndex:0,onClick:d,onKeyDown:h,className:C("group w-full px-4 py-3 transition-colors text-left max-w-full overflow-hidden focus-ring rounded-[12px] [&+&]:mt-2",{"bg-black/[0.04]":l,"hover:bg-black/[0.02]":!l}),children:t.jsxs("div",{className:"flex items-start gap-4",children:[t.jsx(se,{id:((z=u==null?void 0:u.user)==null?void 0:z.id)||e.id||"unknown",name:f,image:c,size:48,starred:R}),t.jsxs("div",{className:"flex-1 min-w-0 flex flex-col gap-1",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsxs("h3",{className:C("text-sm font-medium truncate text-[#191918]"),children:[R&&t.jsx("span",{className:"sr-only",children:"Starred conversation. "}),f]}),b&&t.jsx("span",{className:"text-xs text-[#717070] flex-shrink-0",children:b})]}),t.jsxs("div",{className:"flex items-center justify-between gap-2 min-w-0",children:[t.jsx("p",{className:"text-sm text-[#717070] flex-1 line-clamp-1",children:S}),k>0&&t.jsx("span",{className:"bg-[#7f22fe] text-white text-[10px] rounded-full h-4 flex items-center justify-center p-1 min-w-4 text-center flex-shrink-0",children:k>99?"99+":k})]})]})]})})});vs.displayName="CustomChannelPreview";const rr={last_message_at:-1},js=m.memo(({onChannelSelect:e,selectedChannel:s,filters:n,allowNewMessagesFromUnfilteredChannels:a=!1,channelRenderFilterFn:r,sort:i=rr,className:o,customEmptyStateIndicator:l,renderMessagePreview:d,viewerLanguage:h})=>{const x=m.useRef(0);x.current++;const{debug:u=!1}=Fe(),f=m.useCallback(g=>{for(const w of g)tr(w);return r?r(g):g},[r]);u&&console.log("📺 [ChannelList] 🔄 RENDER START",{renderCount:x.current,selectedChannelId:s==null?void 0:s.id,filters:n});const c=m.useMemo(()=>({selectedChannel:s,onChannelSelect:e,debug:u,renderMessagePreview:d,viewerLanguage:h}),[s,e,u,d,h]);return t.jsx("div",{className:C("messaging-channel-list h-full flex flex-col min-w-0 overflow-hidden",o),children:t.jsx("div",{className:"flex-1 overflow-hidden min-w-0",children:t.jsx(sr,{value:c,children:t.jsx(_.ChannelList,{filters:n,sort:i,options:{limit:30},allowNewMessagesFromUnfilteredChannels:a,channelRenderFilterFn:f,Paginator:_.InfiniteScroll,Preview:vs,EmptyStateIndicator:l},`${JSON.stringify(n)}:${JSON.stringify(i)}`)})})})});js.displayName="ChannelList";const ws=({question:e,onClick:s,loading:n=!1,className:a})=>t.jsx("button",{type:"button",onClick:s,disabled:n,style:{backgroundColor:"#E6E5E3"},className:C("w-full text-center p-4 rounded-xl text-charcoal font-medium transition-colors focus-ring",{"hover:brightness-95 active:brightness-90":!n,"opacity-50 cursor-not-allowed":n},a),children:e}),ir=({faqs:e,onFaqClick:s,loadingFaqId:n,headerText:a,className:r,avatarImage:i,avatarName:o})=>{const l=e.filter(d=>d.enabled).sort((d,h)=>(d.order??0)-(h.order??0));return l.length===0?null:t.jsx("div",{className:r,children:t.jsxs("div",{className:"flex gap-3 items-end",children:[(i||o)&&t.jsx("div",{className:"flex-none",children:t.jsx(se,{id:o||"account",name:o||"Account",image:i,size:24,shape:"circle"})}),t.jsxs("div",{className:"flex-1 flex flex-col gap-3 rounded-lg p-4",style:{backgroundColor:"#F1F0EE"},children:[a&&t.jsx("p",{className:"text-md text-charcoal mb-4",children:a}),l.map(d=>t.jsx(ws,{question:d.question,onClick:()=>s(d.id),loading:n===d.id},d.id))]})]})})};exports.ActionButton=ce;exports.AttachmentThumbnail=Ve;exports.Avatar=se;exports.ChannelEmptyState=gs;exports.ChannelList=js;exports.ChannelView=nt;exports.CustomMessageProvider=Kn;exports.FaqList=ir;exports.FaqListItem=ws;exports.LinkAttachment=ze;exports.LockedAttachment=Pe;exports.MediaMessage=tn;exports.MessageAttachment=de;exports.MessageVoteButtons=us;exports.MessagingProvider=ys;exports.MessagingShell=er;exports.bubbleGroupPositionFromStream=qt;exports.buildCompactMetaLabel=Kt;exports.formatFileSize=Wt;exports.formatRelativeTime=bs;exports.getFileExtensionLabel=Xt;exports.getMessageDisplayText=Be;exports.getSourceType=ee;exports.isLinkAttachment=Ye;exports.isUuidLike=zt;exports.normalizeLanguageCode=Ft;exports.renderTypeIcon=re;exports.resolveLinkAttachment=Ce;exports.resolveMediaFromMessage=ke;exports.resolveParticipantDisplayName=$e;exports.useComposerLocked=Da;exports.useCustomMessage=cs;exports.useMessageVote=Ot;exports.useMessaging=Dt;
|
|
2
|
-
//# sourceMappingURL=index-CSSe9eu7.cjs.map
|