@linktr.ee/messaging-react 3.32.0 → 3.33.0-rc-1786023903
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-BZ1ULvgX.cjs → Card-CbxXZm7k.cjs} +2 -2
- package/dist/{Card-BZ1ULvgX.cjs.map → Card-CbxXZm7k.cjs.map} +1 -1
- package/dist/{Card-C0e9vL3X.js → Card-D28R0tmP.js} +2 -2
- package/dist/{Card-C0e9vL3X.js.map → Card-D28R0tmP.js.map} +1 -1
- package/dist/index-BrVCdobn.cjs +2 -0
- package/dist/index-BrVCdobn.cjs.map +1 -0
- package/dist/{index-DtTSu6m9.js → index-Czf2XyYL.js} +1226 -1209
- package/dist/index-Czf2XyYL.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +7 -0
- package/dist/index.js +1 -1
- package/package.json +2 -2
- package/src/components/LinkAttachment/LinkAttachment.test.tsx +29 -0
- package/src/components/LinkAttachment/components/Composer/Card.tsx +2 -0
- package/src/components/LinkAttachment/components/Received/Card.tsx +2 -0
- package/src/components/LinkAttachment/components/Sent/Card.tsx +2 -0
- package/src/components/LinkAttachment/components/_shared/CardBody.tsx +28 -1
- package/src/components/LinkAttachment/types.ts +7 -0
- package/dist/index-DWddHoFx.cjs +0 -2
- package/dist/index-DWddHoFx.cjs.map +0 -1
- package/dist/index-DtTSu6m9.js.map +0 -1
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-BrVCdobn.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.MessageBubble=e.MessageBubble;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.optimizeMessagingAttachmentUrl=e.optimizeMessagingAttachmentUrl;exports.resolveConversationParticipant=e.resolveConversationParticipant;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.d.ts
CHANGED
|
@@ -660,6 +660,13 @@ export declare interface LinkAttachmentBaseProps {
|
|
|
660
660
|
placeholderTitle?: string;
|
|
661
661
|
/** Secondary description rendered below the title. */
|
|
662
662
|
description?: string;
|
|
663
|
+
/**
|
|
664
|
+
* Max lines the description renders before truncating with an ellipsis.
|
|
665
|
+
* Defaults to `1` (single-line truncate — the link-preview default). Set
|
|
666
|
+
* higher for cards whose body is prose (e.g. official messages) so it wraps
|
|
667
|
+
* across multiple lines like the mobile card.
|
|
668
|
+
*/
|
|
669
|
+
descriptionLines?: number;
|
|
663
670
|
/**
|
|
664
671
|
* Optional URL displayed at the bottom of the card (e.g. `tr.ee/briemix`).
|
|
665
672
|
* Ignored when `cta` is provided. Also used as the navigation target for
|
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 r, f as g, L as l, h as M, M as c, i as u, j as L, k as h, l as p, m as d, n as v, p as C, q as A, s as k, t as F, u as b, v as P, w as f, x, o as y, y as z, z as B, B as S, D as q, E as D, G as E, H as V, I as w } from "./index-
|
|
1
|
+
import { a as e, b as t, C as i, c as o, d as n, e as m, F as r, f as g, L as l, h as M, M as c, i as u, j as L, k as h, l as p, m as d, n as v, p as C, q as A, s as k, t as F, u as b, v as P, w as f, x, o as y, y as z, z as B, B as S, D as q, E as D, G as E, H as V, I as w } from "./index-Czf2XyYL.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.
|
|
3
|
+
"version": "3.33.0-rc-1786023903",
|
|
4
4
|
"description": "React messaging components built on messaging-core for web applications",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
52
|
"@linktr.ee/component-library": "11.8.6",
|
|
53
|
-
"@linktr.ee/messaging-core": "
|
|
53
|
+
"@linktr.ee/messaging-core": "2.4.0-rc-1786023903",
|
|
54
54
|
"@linktr.ee/messaging-taxonomy": "^0.5.2",
|
|
55
55
|
"@phosphor-icons/react": "^2.1.10"
|
|
56
56
|
},
|
|
@@ -58,6 +58,35 @@ describe('LinkAttachment.Received (link previews)', () => {
|
|
|
58
58
|
expect(ctaOnClick).toHaveBeenCalledTimes(1)
|
|
59
59
|
})
|
|
60
60
|
|
|
61
|
+
it('truncates the description to a single line by default', async () => {
|
|
62
|
+
renderWithProviders(
|
|
63
|
+
<LinkAttachment.Received title="Official" description="A longer body of prose that would wrap onto several lines" />
|
|
64
|
+
)
|
|
65
|
+
const description = await screen.findByText(
|
|
66
|
+
'A longer body of prose that would wrap onto several lines'
|
|
67
|
+
)
|
|
68
|
+
expect(description).toHaveClass('truncate')
|
|
69
|
+
expect(description).not.toHaveStyle({ display: '-webkit-box' })
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
it('clamps the description to descriptionLines lines when greater than 1', async () => {
|
|
73
|
+
renderWithProviders(
|
|
74
|
+
<LinkAttachment.Received
|
|
75
|
+
title="Official"
|
|
76
|
+
description="A longer body of prose that would wrap onto several lines"
|
|
77
|
+
descriptionLines={3}
|
|
78
|
+
/>
|
|
79
|
+
)
|
|
80
|
+
const description = await screen.findByText(
|
|
81
|
+
'A longer body of prose that would wrap onto several lines'
|
|
82
|
+
)
|
|
83
|
+
expect(description).not.toHaveClass('truncate')
|
|
84
|
+
expect(description).toHaveStyle({
|
|
85
|
+
display: '-webkit-box',
|
|
86
|
+
WebkitLineClamp: '3',
|
|
87
|
+
})
|
|
88
|
+
})
|
|
89
|
+
|
|
61
90
|
it('renders the filled (primary) CTA when cta.variant is omitted', async () => {
|
|
62
91
|
renderWithProviders(
|
|
63
92
|
<LinkAttachment.Received
|
|
@@ -52,6 +52,7 @@ const ComposerCard: React.FC<ComposerCardProps> = ({
|
|
|
52
52
|
title,
|
|
53
53
|
placeholderTitle,
|
|
54
54
|
description,
|
|
55
|
+
descriptionLines,
|
|
55
56
|
url,
|
|
56
57
|
mimeType,
|
|
57
58
|
thumbnailUrl,
|
|
@@ -153,6 +154,7 @@ const ComposerCard: React.FC<ComposerCardProps> = ({
|
|
|
153
154
|
title={title}
|
|
154
155
|
placeholderTitle={placeholderTitle}
|
|
155
156
|
description={description}
|
|
157
|
+
descriptionLines={descriptionLines}
|
|
156
158
|
url={url}
|
|
157
159
|
appIcon={appIcon}
|
|
158
160
|
cta={cta}
|
|
@@ -46,6 +46,7 @@ export interface ReceivedCardProps extends LinkAttachmentBaseProps {
|
|
|
46
46
|
const ReceivedCard: React.FC<ReceivedCardProps> = ({
|
|
47
47
|
title,
|
|
48
48
|
description,
|
|
49
|
+
descriptionLines,
|
|
49
50
|
url,
|
|
50
51
|
mimeType,
|
|
51
52
|
thumbnailUrl,
|
|
@@ -145,6 +146,7 @@ const ReceivedCard: React.FC<ReceivedCardProps> = ({
|
|
|
145
146
|
ctaSurface={chin.surface}
|
|
146
147
|
title={title}
|
|
147
148
|
description={description}
|
|
149
|
+
descriptionLines={descriptionLines}
|
|
148
150
|
url={url}
|
|
149
151
|
appIcon={appIcon}
|
|
150
152
|
cta={wrappedCta}
|
|
@@ -46,6 +46,7 @@ const SentCard: React.FC<SentCardProps> = ({
|
|
|
46
46
|
title,
|
|
47
47
|
placeholderTitle,
|
|
48
48
|
description,
|
|
49
|
+
descriptionLines,
|
|
49
50
|
url,
|
|
50
51
|
mimeType,
|
|
51
52
|
thumbnailUrl,
|
|
@@ -127,6 +128,7 @@ const SentCard: React.FC<SentCardProps> = ({
|
|
|
127
128
|
title={title}
|
|
128
129
|
placeholderTitle={placeholderTitle}
|
|
129
130
|
description={description}
|
|
131
|
+
descriptionLines={descriptionLines}
|
|
130
132
|
url={url}
|
|
131
133
|
appIcon={appIcon}
|
|
132
134
|
cta={cta}
|
|
@@ -19,6 +19,13 @@ export interface CardBodyProps {
|
|
|
19
19
|
/** Placeholder shown in the title slot when no title is set (dark variants only). */
|
|
20
20
|
placeholderTitle?: string
|
|
21
21
|
description?: string
|
|
22
|
+
/**
|
|
23
|
+
* Max lines the description renders before truncating with an ellipsis.
|
|
24
|
+
* Defaults to `1` (single-line truncate — the link-preview default). Set
|
|
25
|
+
* higher for cards whose body is prose (e.g. official messages) so it wraps
|
|
26
|
+
* like the mobile card instead of clipping to one line.
|
|
27
|
+
*/
|
|
28
|
+
descriptionLines?: number
|
|
22
29
|
/** Footer URL shown below the description. Ignored when `cta` is set. */
|
|
23
30
|
url?: string
|
|
24
31
|
/**
|
|
@@ -81,6 +88,7 @@ const CardBody: React.FC<CardBodyProps> = ({
|
|
|
81
88
|
title,
|
|
82
89
|
placeholderTitle,
|
|
83
90
|
description,
|
|
91
|
+
descriptionLines = 1,
|
|
84
92
|
url,
|
|
85
93
|
appIcon,
|
|
86
94
|
cta,
|
|
@@ -115,6 +123,15 @@ const CardBody: React.FC<CardBodyProps> = ({
|
|
|
115
123
|
chinTextColor == null && SECONDARY_CLASS_BY_VARIANT[variant]
|
|
116
124
|
)
|
|
117
125
|
|
|
126
|
+
// The description clamps to `descriptionLines` (default 1 = single-line truncate). >1 wraps via a
|
|
127
|
+
// webkit line-clamp so prose bodies (official messages) render multi-line like the mobile card. The
|
|
128
|
+
// URL footer always stays single-line (`secondaryClass`).
|
|
129
|
+
const descriptionClass = classNames(
|
|
130
|
+
'text-[12px] leading-4 tracking-[0.24px]',
|
|
131
|
+
descriptionLines <= 1 && 'truncate',
|
|
132
|
+
chinTextColor == null && SECONDARY_CLASS_BY_VARIANT[variant]
|
|
133
|
+
)
|
|
134
|
+
|
|
118
135
|
if (isLoading) {
|
|
119
136
|
const barClass = classNames(
|
|
120
137
|
'animate-pulse rounded',
|
|
@@ -133,6 +150,16 @@ const CardBody: React.FC<CardBodyProps> = ({
|
|
|
133
150
|
}
|
|
134
151
|
|
|
135
152
|
const chinTextStyle = chinTextColor ? { color: chinTextColor } : undefined
|
|
153
|
+
const descriptionStyle: React.CSSProperties | undefined =
|
|
154
|
+
descriptionLines > 1
|
|
155
|
+
? {
|
|
156
|
+
...chinTextStyle,
|
|
157
|
+
display: '-webkit-box',
|
|
158
|
+
WebkitBoxOrient: 'vertical',
|
|
159
|
+
WebkitLineClamp: descriptionLines,
|
|
160
|
+
overflow: 'hidden',
|
|
161
|
+
}
|
|
162
|
+
: chinTextStyle
|
|
136
163
|
|
|
137
164
|
return (
|
|
138
165
|
<div className="shrink-0 px-4 py-3">
|
|
@@ -151,7 +178,7 @@ const CardBody: React.FC<CardBodyProps> = ({
|
|
|
151
178
|
)}
|
|
152
179
|
|
|
153
180
|
{hasDescription && (
|
|
154
|
-
<p className={
|
|
181
|
+
<p className={descriptionClass} style={descriptionStyle}>
|
|
155
182
|
{description}
|
|
156
183
|
</p>
|
|
157
184
|
)}
|
|
@@ -39,6 +39,13 @@ export interface LinkAttachmentBaseProps {
|
|
|
39
39
|
placeholderTitle?: string
|
|
40
40
|
/** Secondary description rendered below the title. */
|
|
41
41
|
description?: string
|
|
42
|
+
/**
|
|
43
|
+
* Max lines the description renders before truncating with an ellipsis.
|
|
44
|
+
* Defaults to `1` (single-line truncate — the link-preview default). Set
|
|
45
|
+
* higher for cards whose body is prose (e.g. official messages) so it wraps
|
|
46
|
+
* across multiple lines like the mobile card.
|
|
47
|
+
*/
|
|
48
|
+
descriptionLines?: number
|
|
42
49
|
/**
|
|
43
50
|
* Optional URL displayed at the bottom of the card (e.g. `tr.ee/briemix`).
|
|
44
51
|
* Ignored when `cta` is provided. Also used as the navigation target for
|
package/dist/index-DWddHoFx.cjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";const t=require("react/jsx-runtime"),m=require("react"),Os=require("@linktr.ee/messaging-core"),Ce=require("stream-chat"),w=require("stream-chat-react"),C=require("classnames"),N=require("@phosphor-icons/react"),X=require("@linktr.ee/messaging-taxonomy"),He=require("stream-chat-react/experimental"),Vt=m.createContext({service:null,client:null,isConnected:!1,isLoading:!1,error:null,capabilities:{},refreshConnection:async()=>{},debug:!1}),Ge=()=>m.useContext(Vt),Fs=({children:e,user:s,serviceConfig:n,apiKey:a,capabilities:r={},debug:i=!1,client:l})=>{var E,A;const o=m.useCallback((I,...B)=>{i&&console.log(`🔥 [MessagingProvider] ${I}`,...B)},[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[d,h]=m.useState(null),[f,u]=m.useState(null),[g,c]=m.useState(!1),[v,j]=m.useState(!1),[p,x]=m.useState(null),b=m.useRef(!1),_=m.useRef(null),S=m.useRef(n);S.current=n;const R=m.useRef(i);R.current=i;const M=m.useRef({userId:s==null?void 0:s.id,apiKey:a,serviceConfig:n,capabilities:r}),z=m.useRef(0);z.current++,o("📊 RENDER INFO",{renderCount:z.current,currentProps:{userId:s==null?void 0:s.id,apiKey:(a==null?void 0:a.substring(0,8))+"..."},propChanges:{userChanged:M.current.userId!==(s==null?void 0:s.id),apiKeyChanged:M.current.apiKey!==a,serviceConfigChanged:M.current.serviceConfig!==n,capabilitiesChanged:M.current.capabilities!==r}}),M.current={userId:s==null?void 0:s.id,apiKey:a,serviceConfig:n,capabilities:r};const O=m.useRef(null);!l&&a&&((E=O.current)==null?void 0:E.apiKey)!==a&&(O.current={apiKey:a,client:new Ce.StreamChat(a)});const $=l||(a?((A=O.current)==null?void 0:A.client)??null:null);m.useEffect(()=>{const I=z.current,B=S.current;if(l){_.current=null,h(null),u(null),c(!1),x(null),j(!1);return}if(!a||!$||!B){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 F=new Os.StreamChatService({...B,apiKey:a,debug:R.current,client:$});_.current=F,h(F),o("✅ SERVICE SET",{renderCount:I,serviceInstance:!!F})},[a,$,l]);const D=m.useRef(null);m.useEffect(()=>{var B,F;if(o("🔗 USER CONNECTION EFFECT TRIGGERED",{hasService:!!d,hasUser:!!s,userId:s==null?void 0:s.id,isConnecting:b.current,isConnected:g,dependencies:{service:!!d,userId:s==null?void 0:s.id}}),l)return;if(!d||!s){o("⚠️ USER CONNECTION SKIPPED","Missing service or user");return}if(b.current){o("⚠️ USER CONNECTION SKIPPED","Already connecting");return}if(((B=D.current)==null?void 0:B.serviceId)===d&&((F=D.current)==null?void 0:F.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,j(!0),x(null);try{o("📞 CALLING SERVICE.CONNECTUSER",{userId:s.id});const U=await d.connectUser(s);u(U),c(!0),D.current={serviceId:d,userId:s.id},o("✅ USER CONNECTION SUCCESS",{userId:s.id,clientId:U.userID})}catch(U){const q=U instanceof Error?U.message:"Connection failed";x(q),o("❌ USER CONNECTION ERROR",{userId:s.id,error:q})}finally{j(!1),b.current=!1,o("🔄 USER CONNECTION FINISHED",{userId:s.id,isConnected:g})}})()},[d,s,o,g,l]),m.useEffect(()=>{const I=$;return()=>{var B;I&&(D.current=null,(B=_.current)==null||B.disconnectUser().catch(console.error))}},[$]);const k=m.useCallback(async()=>{if(o("🔄 REFRESH CONNECTION CALLED",{hasService:!!d,hasUser:!!s}),!l){if(!d||!s){o("⚠️ REFRESH CONNECTION SKIPPED","Missing service or user");return}o("🚀 STARTING CONNECTION REFRESH",{userId:s.id}),j(!0);try{o("🔌 DISCONNECTING FOR REFRESH"),await d.disconnectUser(),o("📞 RECONNECTING FOR REFRESH");const I=await d.connectUser(s);u(I),c(!0),x(null),o("✅ CONNECTION REFRESH SUCCESS",{userId:s.id})}catch(I){const B=I instanceof Error?I.message:"Refresh failed";x(B),o("❌ CONNECTION REFRESH ERROR",{userId:s.id,error:B})}finally{j(!1),o("🔄 CONNECTION REFRESH FINISHED",{userId:s.id})}}},[d,s,o,l]),P=m.useMemo(()=>(o("💫 CONTEXT VALUE MEMOIZATION",{hasService:!!d,hasClient:!!f,isConnected:g,isLoading:v,hasError:!!p,capabilitiesKeys:Object.keys(r)}),{service:l?null:d,client:l??f,isConnected:l?!0:g,isLoading:l?!1:v,error:l?null:p,capabilities:r,refreshConnection:k,debug:i}),[d,f,l,g,v,p,r,k,i,o]);return o("🔄 RENDER END",{renderCount:z.current,willRenderChat:!!$,contextValueReady:!!P}),t.jsx(Vt.Provider,{value:P,children:$?t.jsx(w.Chat,{client:$,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})},Ht=()=>Ge(),Gt=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 l;if(!e){n(!1);return}n(!!((l=e.state.membership)!=null&&l.pinned_at));const i=o=>{var d;n(o!=null&&o.member?!!o.member.pinned_at:!!((d=e.state.membership)!=null&&d.pinned_at))};return e.on("member.updated",i),()=>{e.off("member.updated",i)}},[e]),s};function Ye(e,s,n){const a=Object.values(e||{});if(X.isOfficialChannel(n)){const r=a.find(i=>{var l;return((l=i.user)==null?void 0:l.id)===X.OFFICIAL_SENDER_USER_ID});if(r)return r}return a.find(r=>{var i;return((i=r.user)==null?void 0:i.id)&&r.user.id!==s})}const zs=/^[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 Yt(e){return zs.test(e.trim())}function Mt(e,s){const n=e==null?void 0:e.trim();return!n||s&&n===s||s&&n===`Follower ${s}`?!1:!Yt(n)}function qe(e){return Mt(e==null?void 0:e.name,e==null?void 0:e.id)?e.name.trim():Mt(e==null?void 0:e.username,e==null?void 0:e.id)?e.username.trim():"Unknown member"}const At=[{emoji:"🍎",bgColor:"#FFD1DD"},{emoji:"🍌",bgColor:"#FFF1C9"},{emoji:"🍇",bgColor:"#E6D9FF"},{emoji:"🍊",bgColor:"#D6F4FF"},{emoji:"🍓",bgColor:"#FFE0AE"},{emoji:"🥥",bgColor:"#F7E7D8"},{emoji:"🍒",bgColor:"#DFF4D8"},{emoji:"🥭",bgColor:"#FFD8C2"},{emoji:"🍉",bgColor:"#D6EBFF"},{emoji:"🍋",bgColor:"#CAEEB5"},{emoji:"🥝",bgColor:"#FFE7C7"},{emoji:"🫒",bgColor:"#F6E3B4"},{emoji:"🍈",bgColor:"#D9F7E1"}];function Bs(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 qt(e){return At[Bs(e)%At.length]}function $s(e){return qt(e).emoji}function Us(e){return qt(e).bgColor}const de=({id:e,image:s,size:n=40,className:a,starred:r=!1,shape:i="squircle",dmAgentEnabled:l=!1})=>{const o=$s(e),d=Us(e),h=.45,u=n<32?Math.round(n*h):n<56?14:n<120?18:36,g=n>=40?2:1,c=i==="circle"?{borderRadius:"50%"}:{borderRadius:"1rem"},v=t.jsx("div",{className:"h-full w-full overflow-hidden",style:c,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 font-semibold select-none transition-colors"),style:{fontSize:u,lineHeight:1},children:o})});return t.jsxs("div",{className:C("relative flex-shrink-0",a),style:{"--str-chat__avatar-size":`${n}px`,width:`${n}px`,height:`${n}px`,backgroundColor:s?void 0:d,...c},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:{...c,...l&&{borderWidth:`${g}px`,borderStyle:"solid",borderColor:"var(--AI-Gradient, #7F22FE)",boxShadow:"inset 0 1px 2px 0 rgba(255, 255, 255, 0.5)"}},children:v})]})},Vs="https://linktr.ee/s/about/trust-center/report",Hs=({channel:e,participant:s,showBlockParticipant:n=!0,enabled:a=!0,onLeaveConversation:r,onBlockParticipant:i,onDeleteConversationClick:l,onBlockParticipantClick:o,onReportParticipantClick:d,onActionComplete:h,logLabel:f="useChannelModerationActions"})=>{var P;const{service:u,debug:g}=Ge(),c=(P=s==null?void 0:s.user)==null?void 0:P.id,v=!!(a&&n&&u&&c),[j,p]=m.useState(!1),[x,b]=m.useState(null),[_,S]=m.useState(!1),[R,M]=m.useState(!1),z=v&&((x==null?void 0:x.participantId)!==c||(x==null?void 0:x.service)!==u);return m.useEffect(()=>{if(!v||!u||!c){p(!1),b(null);return}let E=!1;return(async()=>{try{const A=await u.getBlockedUsers();if(E)return;p(A.some(I=>I.blocked_user_id===c))}catch(A){E||console.error(`[${f}] Failed to check blocked status:`,A)}finally{E||b({participantId:c,service:u})}})(),()=>{E=!0}},[v,u,c,f]),{isParticipantBlocked:j,isCheckingBlockedStatus:z,isLeaving:_,isUpdatingBlockStatus:R,handleLeaveConversation:async()=>{var E;if(!_){l==null||l(),g&&console.log(`[${f}] Leave conversation`,e.cid),S(!0);try{const A=((E=e._client)==null?void 0:E.userID)??null;await e.hide(A,!1),r&&await r(e),h==null||h()}catch(A){console.error(`[${f}] Failed to leave conversation`,A)}finally{S(!1)}}},handleBlockUser:async()=>{var E,A,I;if(!(R||!u)){o==null||o(),g&&console.log(`[${f}] Block member`,(E=s==null?void 0:s.user)==null?void 0:E.id),M(!0);try{await u.blockUser((A=s==null?void 0:s.user)==null?void 0:A.id),i&&await i((I=s==null?void 0:s.user)==null?void 0:I.id),h==null||h()}catch(B){console.error(`[${f}] Failed to block member`,B)}finally{M(!1)}}},handleUnblockUser:async()=>{var E,A,I;if(!(R||!u)){o==null||o(),g&&console.log(`[${f}] Unblock member`,(E=s==null?void 0:s.user)==null?void 0:E.id),M(!0);try{await u.unBlockUser((A=s==null?void 0:s.user)==null?void 0:A.id),i&&await i((I=s==null?void 0:s.user)==null?void 0:I.id),h==null||h()}catch(B){console.error(`[${f}] Failed to unblock member`,B)}finally{M(!1)}}},handleReportUser:()=>{d==null||d(),h==null||h(),window.open(Vs,"_blank","noopener,noreferrer")}}},fe=({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})},Gs=({channel:e,participant:s,showDeleteConversation:n=!0,showBlockParticipant:a=!0,showReportParticipant:r=!0,onLeaveConversation:i,onBlockParticipant:l,onDeleteConversationClick:o,onBlockParticipantClick:d,onReportParticipantClick:h,customChannelActions:f,triggerClassName:u})=>{const[g,c]=m.useState(!1),v=m.useRef(null),j=m.useId(),p=m.useCallback(()=>c(!1),[]),{isParticipantBlocked:x,isCheckingBlockedStatus:b,isLeaving:_,isUpdatingBlockStatus:S,handleLeaveConversation:R,handleBlockUser:M,handleUnblockUser:z,handleReportUser:O}=Hs({channel:e,participant:s,showBlockParticipant:a,enabled:g,onLeaveConversation:i,onBlockParticipant:l,onDeleteConversationClick:o,onBlockParticipantClick:d,onReportParticipantClick:h,onActionComplete:p,logLabel:"ChannelActionsMenu"});return m.useEffect(()=>{if(!g)return;const D=P=>{v.current&&!v.current.contains(P.target)&&c(!1)},k=P=>{P.key==="Escape"&&c(!1)};return document.addEventListener("mousedown",D),document.addEventListener("keydown",k),()=>{document.removeEventListener("mousedown",D),document.removeEventListener("keydown",k)}},[g]),!s||!(n||a||r||!!f)?null:t.jsxs("div",{ref:v,className:"relative",children:[t.jsxs("button",{className:u,type:"button","aria-haspopup":"true","aria-expanded":g,"aria-controls":g?j: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"})]}),g&&t.jsx("div",{id:j,"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(fe,{onClick:R,disabled:_,"aria-busy":_,children:[_?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:b?t.jsxs(fe,{disabled:!0,"aria-busy":!0,children:[t.jsx(N.SpinnerGapIcon,{className:"h-5 w-5 animate-spin"}),t.jsx("span",{children:"Block"})]}):x?t.jsxs(fe,{onClick:z,disabled:S,"aria-busy":S,children:[S?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(fe,{onClick:M,disabled:S,"aria-busy":S,children:[S?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(fe,{variant:"danger",onClick:O,children:[t.jsx(N.FlagIcon,{className:"h-5 w-5"}),t.jsx("span",{children:"Report"})]})}),f]})})]})},Pe="flex size-10 flex-shrink-0 items-center justify-center rounded-full bg-white/65 shadow-[0px_4px_8px_0px_rgba(0,0,0,0.06),0px_0px_0px_1px_rgba(0,0,0,0.04)] backdrop-blur-[40px] transition-filter duration-150 hover:brightness-95 aria-expanded:brightness-95 focus-ring",Ys="CUSTOMER_PAID",qs=e=>typeof e=="string"&&e.trim().replace(/[\s-]+/g,"_").toUpperCase()===Ys,Ws=({className:e,onBack:s,showBackButton:n,showStarButton:a=!1,onLeaveConversation:r,onBlockParticipant:i,showDeleteConversation:l=!0,showBlockParticipant:o=!0,showReportParticipant:d=!0,onDeleteConversationClick:h,onBlockParticipantClick:f,onReportParticipantClick:u,customChannelActions:g,renderChannelActions:c,showChannelInfo:v=!0,onParticipantNameClick:j})=>{var k,P,E,A;const{channel:p}=w.useChannelStateContext(),{client:x}=w.useChatContext(),b=m.useMemo(()=>{var I;return Ye((I=p.state)==null?void 0:I.members,x==null?void 0:x.userID,p.type)},[(k=p.state)==null?void 0:k.members,x==null?void 0:x.userID,p.type]),_=qe(b==null?void 0:b.user),S=(P=b==null?void 0:b.user)==null?void 0:P.image,R=Gt(p),M=qs((E=p.data)==null?void 0:E.customer_tag)&&(b==null?void 0:b.is_follower)===!0,z=a&&R,O=M||z||!!j,$=async()=>{try{R?await p.unpin():await p.pin()}catch(I){console.error("[ChannelHeaderRedesign] Failed to update pinned status:",I)}},D=t.jsxs(t.Fragment,{children:[t.jsx(de,{id:((A=b==null?void 0:b.user)==null?void 0:A.id)||p.id||"unknown",name:_,image:S,shape:"circle",size:48,className:"-mb-2"}),t.jsx("span",{className:C("relative z-10 flex max-w-full flex-col items-center justify-center rounded-full border border-white/10 bg-white/65 py-1.5 shadow-[0px_0px_0px_0px_rgba(0,0,0,0.04),0px_1px_2px_0px_rgba(0,0,0,0.04),0px_8px_32px_0px_rgba(0,0,0,0.1)] backdrop-blur-[2px] transition-filter duration-150 group-hover:brightness-95",O?"pl-3 pr-2":"px-3"),children:t.jsxs("span",{className:"flex max-w-full items-center justify-center",children:[t.jsx("span",{className:"min-w-0 truncate text-sm font-bold leading-[1.43] tracking-[0.28px] text-black/90",children:_}),O&&t.jsxs("span",{className:"ml-2 flex gap-1",children:[M&&t.jsx("span",{"aria-label":"Paid customer",className:"flex size-4 shrink-0 items-center justify-center rounded-full bg-[#34C759] text-white",children:t.jsx(N.CurrencyDollarIcon,{className:"size-2.5",weight:"bold"})}),z&&t.jsx("span",{"aria-label":"Starred conversation",className:"flex size-4 shrink-0 items-center justify-center rounded-full bg-[#FFD60A] text-white",children:t.jsx(N.StarIcon,{className:"size-2.5",weight:"fill"})}),j&&t.jsx(N.CaretRightIcon,{"aria-hidden":"true",className:"size-4 shrink-0 text-black/65",weight:"bold"})]})]})})]});return t.jsx("div",{className:C("@container bg-[linear-gradient(180deg,#FBFAF9_0%,rgba(251,250,249,0.92)_58%,rgba(251,250,249,0)_100%)]",e),children:t.jsxs("div",{className:"grid min-h-[100px] grid-cols-[minmax(40px,1fr)_auto_minmax(40px,1fr)] items-start pb-2 pt-5 @lg:min-h-[104px] @lg:pt-6",children:[t.jsx("div",{className:"flex items-start",children:n&&t.jsx("button",{className:C(Pe,"messaging-channel-view-back-button-mobile messaging-channel-view-back-button-desktop"),onClick:s||(()=>{}),type:"button","aria-label":"Back to conversations",children:t.jsx(N.ArrowLeftIcon,{className:"size-5 text-black/90"})})}),t.jsx("div",{className:"flex min-w-0 justify-center","data-dd-privacy":"mask",children:j?t.jsx("button",{type:"button",onClick:j,"aria-label":`View details for ${_}`,className:"group flex min-w-0 max-w-full appearance-none flex-col items-center border-0 bg-transparent px-2 focus-ring focus-visible:outline-none",children:D}):t.jsx("div",{className:"flex min-w-0 max-w-full flex-col items-center px-2",children:D})}),t.jsxs("div",{className:"flex items-start justify-end gap-2",children:[a&&t.jsx("button",{className:Pe,onClick:$,type:"button","aria-pressed":R,"aria-label":R?"Unstar conversation":"Star conversation",children:t.jsx(N.StarIcon,{className:C("size-5",{"text-[#FFD60A]":R,"text-black/90":!R}),weight:R?"fill":"regular"})}),v&&(c!==void 0?c:t.jsx(Gs,{channel:p,participant:b,showDeleteConversation:l,showBlockParticipant:o,showReportParticipant:d,onLeaveConversation:r,onBlockParticipant:i,onDeleteConversationClick:h,onBlockParticipantClick:f,onReportParticipantClick:u,customChannelActions:g,triggerClassName:Pe}))]})]})})},Xs=e=>t.jsx(w.DateSeparator,{...e,position:"center"}),Ue="vote_up",Ve="vote_down";function Ks(e){return e!=null&&e.length?e.some(s=>s.type===Ve)?"down":e.some(s=>s.type===Ue)?"up":null:null}function Wt(e){const{channel:s}=w.useChannelStateContext(),{client:n}=w.useChatContext("useMessageVote"),a=m.useMemo(()=>Ks(e.own_reactions),[e.own_reactions]),r=m.useCallback(async()=>{if(n!=null&&n.userID)try{a==="up"?await s.deleteReaction(e.id,Ue):await s.sendReaction(e.id,{type:Ue},{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,Ve):await s.sendReaction(e.id,{type:Ve},{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 Xt(e){return(e==null?void 0:e.trim().toLowerCase().split(/[-_]/)[0])||void 0}function We({message:e,viewerLanguage:s}){var r;const n=e==null?void 0:e.text,a=Xt(s);return a?((r=e==null?void 0:e.i18n)==null?void 0:r[`${a}_text`])??n:n}const Zs=["linktr.ee"],Rt="messaging-attachment-v1_0";function Js(e){try{return new URL(e).hostname.toLowerCase()}catch{return null}}function Qs(e){return Zs.some(s=>e===s||e.endsWith(`.${s}`))}function ie(e){const s=e==null?void 0:e.trim();if(!s)return;const n=Js(s);if(!n||!Qs(n))return s;const a=new URL(s);return a.searchParams.get("io")==="true"&&a.searchParams.get("size")===Rt?s:(a.searchParams.set("io","true"),a.searchParams.set("size",Rt),a.toString())}const en=[[/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 se(e){return e.startsWith("video/")?"video":e.startsWith("audio/")?"audio":e.startsWith("image/")?"image":"document"}function Kt(e){const s=en.find(([n])=>n.test(e));return s?s[1]:"generic"}const tn={video:N.VideoCameraIcon,audio:N.SpeakerHighIcon,image:N.ImageIcon,document:N.FileIcon},sn={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 nn(e){const s=se(e);return s!=="document"?tn[s]:sn[Kt(e)]}function ce(e,s){return m.createElement(nn(e),s)}const an=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},rn=({source:e,mimeType:s,poster:n,autoPlay:a=!1,playing:r,loop:i=!1,controls:l=!0,showProgress:o=!1,muted:d=!1,onContainerClick:h})=>{const f=se(s),u=m.useRef(null),g=m.useRef(null),c=m.useRef(null),v=m.useRef(r),[j,p]=m.useState(a),[x,b]=m.useState(0),[_,S]=m.useState(!1),[R,M]=m.useState(!1),[z,O]=m.useState(!1),[$,D]=m.useState(!1),[k,P]=m.useState(!0),[E,A]=m.useState(null),I=m.useCallback(()=>{O(!1),p(!0)},[]),B=m.useCallback(y=>{const T=g.current;if(!T)return 0;const G=T.getBoundingClientRect();return Math.max(0,Math.min(1,(an(y)-G.left)/G.width))},[]),F=m.useCallback(y=>{const T=u.current;T&&T.duration&&(T.currentTime=y*T.duration)},[]),U=y=>{y.stopPropagation(),S(!0);const T=B(y);b(T),F(T)};m.useEffect(()=>{r!==void 0&&r!==v.current&&(v.current=r,p(r))},[r]),m.useEffect(()=>{if(!j){c.current!==null&&(cancelAnimationFrame(c.current),c.current=null);return}const y=()=>{const T=u.current;T&&T.duration&&!_&&b(T.currentTime/T.duration),c.current=requestAnimationFrame(y)};return c.current=requestAnimationFrame(y),()=>{c.current!==null&&cancelAnimationFrame(c.current)}},[j,_]),m.useEffect(()=>{const y=u.current;y&&(j?y.play().catch(T=>{p(!1),O(!0)}):y.pause())},[j]),m.useEffect(()=>{if(!_)return;const y=G=>b(B(G)),T=G=>{S(!1),F(B(G))};return window.addEventListener("mousemove",y),window.addEventListener("mouseup",T),window.addEventListener("touchmove",y,{passive:!0}),window.addEventListener("touchend",T),()=>{window.removeEventListener("mousemove",y),window.removeEventListener("mouseup",T),window.removeEventListener("touchmove",y),window.removeEventListener("touchend",T)}},[_,B,F]);const q=E?{aspectRatio:String(E)}:void 0,Q=E?"":" aspect-video",H=Math.round(x*100);return t.jsxs("div",{role:"button",tabIndex:0,className:`relative cursor-pointer overflow-hidden bg-black ${Q}`,style:q,onClick:y=>{if(h){h(y);return}z||l&&p(T=>!T)},onKeyDown:y=>{if(!(y.key!=="Enter"&&y.key!==" ")){if(y.preventDefault(),h){h(y);return}z||l&&p(T=>!T)}},children:[n&&(f==="audio"||k)&&t.jsx("img",{src:n,alt:"",className:"absolute inset-0 h-full w-full object-cover"}),!n&&(f==="audio"||k)&&t.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:ce(s,{className:"size-12 text-black/20",weight:"regular"})}),t.jsx("div",{className:"absolute inset-0",children:f==="audio"?t.jsx("audio",{ref:u,src:e,loop:i,muted:d,style:{width:"100%",height:"100%"},onLoadStart:()=>D(!0),onCanPlay:()=>{D(!1),P(!1)},onWaiting:()=>D(!0),onPlay:()=>O(!1),onEnded:()=>{i||(p(!1),b(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),P(!1)},onWaiting:()=>D(!0),onPlay:()=>O(!1),onLoadedMetadata:()=>{const y=u.current;y instanceof HTMLVideoElement&&y.videoWidth&&y.videoHeight&&A(y.videoWidth/y.videoHeight)},onEnded:()=>{i||(p(!1),b(0))},children:t.jsx("track",{kind:"captions"})})}),$&&!z&&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"})}),z&&!l&&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:y=>{y.stopPropagation(),I()},onKeyDown:y=>{y.key!=="Enter"&&y.key!==" "||(y.preventDefault(),y.stopPropagation(),I())},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"})})}),o&&!l&&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":H,"aria-valuemin":0,"aria-valuemax":100,tabIndex:0,ref:g,className:"relative flex h-4 w-full cursor-pointer items-center",onMouseDown:U,onTouchStart:U,onClick:y=>y.stopPropagation(),onKeyDown:y=>{y.key==="ArrowRight"&&F(Math.min(1,x+.05)),y.key==="ArrowLeft"&&F(Math.max(0,x-.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:`${H}%`}})})})}),l&&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:y=>{y.stopPropagation(),p(T=>!T)},className:"shrink-0 text-white","aria-label":j?"Pause":"Play",children:j?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":H,"aria-valuemin":0,"aria-valuemax":100,tabIndex:0,ref:g,className:"relative flex h-4 w-full cursor-pointer items-center",onMouseDown:U,onTouchStart:U,onClick:y=>y.stopPropagation(),onMouseEnter:()=>M(!0),onMouseLeave:()=>M(!1),onKeyDown:y=>{y.key==="ArrowRight"&&F(Math.min(1,x+.05)),y.key==="ArrowLeft"&&F(Math.max(0,x-.05))},children:[t.jsx("div",{className:`w-full overflow-hidden rounded-full bg-white/30 transition-all duration-200 ${R||_?"h-1.5":"h-1"}`,children:t.jsx("div",{className:"h-full rounded-full bg-white",style:{width:`${H}%`}})}),t.jsx("div",{className:`absolute size-3 -translate-x-1/2 rounded-full bg-white shadow transition-[opacity,transform] duration-200 ${R||_?"scale-100 opacity-100":"scale-0 opacity-0"}`,style:{left:`${H}%`}})]})]})]})},Lt=e=>e==="dark"?"size-12 text-white/20":"size-12 text-black/20",on=e=>e==="dark"?"aspect-video overflow-hidden bg-white/10":"aspect-video overflow-hidden bg-black/5",Xe=({mimeType:e,sourceUrl:s,thumbnailUrl:n,title:a,variant:r,mediaPlayerProps:i,containedImage:l=!1})=>{const o=se(e),[d,h]=m.useState(!1),f=ie(s),u=ie(n);return s&&(o==="video"||o==="audio")?t.jsx(rn,{source:s,mimeType:e,poster:u,controls:!0,...i}):s&&o==="image"?l?t.jsx("div",{className:"relative aspect-video overflow-hidden bg-black/5",children:t.jsx("img",{src:f??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:f??s,alt:a??"",className:"block w-full",draggable:!1}):s&&o==="document"?n?l?t.jsx("div",{className:"relative aspect-video overflow-hidden bg-black/5",children:t.jsx("img",{src:u??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:u??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:ce(e,{className:Lt(r),weight:"regular"})}):n?t.jsx("div",{className:`relative ${on(r)}`,children:t.jsx("img",{src:u??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:ce(e,{className:Lt(r),weight:"regular"})})},Zt=({variant:e,thumbnail:s,title:n,placeholderTitle:a="Attachment title",mimeType:r,detail:i,statusBadge:l,action:o,topLeft:d,topRight:h,rootRef:f,"data-testid":u})=>{const g=e==="dark",c=g?n??a:n??"",v=g&&!n;return t.jsxs("div",{ref:f,"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)]",g?"bg-[#1e2330]":"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":!g,"text-white/30":g&&v,"text-white":g&&!v}),children:c}),t.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[ce(r,{className:C("size-5 shrink-0",g?"text-white/55":"text-black/55"),weight:"regular"}),i!=null&&i!==""&&t.jsx("span",{className:C("text-xs font-medium",g?"text-white/55":"text-black/55"),children:i}),l]}),o]})]})};function Jt(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function Ke(e){return`w-[280px] select-none overflow-hidden rounded-[24px] ${e?"bg-[#1e2330]":"bg-[#F3F3F1]"} shadow-[0_0_0_1px_rgba(0,0,0,0.04),0_4px_8px_rgba(0,0,0,0.06)]`}function ln(e){return e?"bg-white/10":"bg-black/5"}function cn(e){return e?"text-white":"text-black"}function dn(e){return e?"text-white/55":"text-black/55"}function un(e){return e?"text-white/40":"text-black/40"}function mn(e){return e?"text-white/20":"text-black/20"}const Ze=({attachment:e,isMyMessage:s})=>{const{title:n,text:a,image_url:r,og_scrape_url:i,title_link:l}=e,o=i??l,d=typeof o=="string"&&o.trim()!==""?o:void 0,h=t.jsxs(m.Fragment,{children:[t.jsx("div",{className:"p-2",children:r?t.jsx("img",{src:ie(r)??r,alt:n??"",className:"aspect-video w-full rounded-[20px] object-cover"}):t.jsx("div",{className:`aspect-video w-full rounded-[20px] ${ln(s)} flex items-center justify-center`,children:t.jsx(N.LinkIcon,{className:`size-12 ${mn(s)}`})})}),t.jsxs("div",{className:"px-3 pb-3",children:[n&&t.jsx("p",{className:`truncate text-[14px] font-medium leading-5 ${cn(s)}`,children:n}),a&&t.jsx("p",{className:`truncate text-[12px] leading-4 ${dn(s)}`,children:a}),d&&t.jsx("p",{className:`mt-1 truncate text-[12px] leading-4 ${un(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 Je(e){return e.type==="link"||!!e.og_scrape_url&&!e.asset_url}function Ae(e){var s;return(s=e.attachments)==null?void 0:s.find(Je)}async function hn(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),l=document.createElement("a");l.href=i,l.download=n,l.style.display="none",document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(i)}const fn=({url:e,filename:s})=>{const[n,a]=m.useState(!1),r=i=>{i.stopPropagation();const l=window.open("","_blank","noopener,noreferrer");a(!0),hn(e,s).then(()=>{l==null||l.close()}).catch(()=>{l&&(l.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 Re(e){var u,g,c,v;const s=(u=e.attachments)==null?void 0:u.find(j=>j.type==="video"&&j.asset_url),n=(g=e.attachments)==null?void 0:g.find(j=>j.type==="image"&&j.image_url),a=(c=e.attachments)==null?void 0:c.find(j=>j.type==="audio"&&j.asset_url),r=(v=e.attachments)==null?void 0:v.find(j=>j.type==="file"&&j.asset_url),i=s??n??a??r,l=(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(!l)return null;const o=(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,f=s==null?void 0:s.thumb_url;return{resolvedUrl:l,resolvedType:o,title:d,fileSize:h,thumbnailUrl:f}}const Qt=({resolvedUrl:e,resolvedType:s,title:n,fileSize:a,thumbnailUrl:r})=>{const i=a!==void 0?Jt(a):void 0;return t.jsx(Zt,{variant:"dark",title:n,placeholderTitle:"",mimeType:s,detail:i,thumbnail:t.jsx(Xe,{mimeType:s,sourceUrl:e,thumbnailUrl:r,title:n,variant:"dark"})})},es=({resolvedUrl:e,resolvedType:s,title:n,fileSize:a,thumbnailUrl:r})=>{const i=se(s),l=a!==void 0?Jt(a):void 0;return t.jsx(Zt,{variant:"light",title:n,mimeType:s,detail:l,thumbnail:t.jsx(Xe,{mimeType:s,sourceUrl:e,thumbnailUrl:r,title:n,variant:"light",containedImage:i==="image"||i==="document"}),action:t.jsx(fn,{url:e,filename:n})})},gn=({message:e,isMyMessage:s=!1})=>{const n=Ae(e),a=Re(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,"data-dd-privacy":"mask",children:[!s&&e.user&&t.jsx(de,{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","data-attachment-bubble":"true",style:{padding:0,borderRadius:0,overflow:"visible",background:"transparent"},children:n?t.jsx("div",{className:Ke(s),children:t.jsx(Ze,{attachment:n,isMyMessage:s})}):s?t.jsx(Qt,{...a}):t.jsx(es,{...a})})})})]})},xn=({message:e})=>{const s=Ae(e);if(s)return t.jsx("div",{className:Ke(!0),"data-dd-privacy":"mask",children:t.jsx(Ze,{attachment:s,isMyMessage:!0})});const n=Re(e);return n?t.jsx("div",{style:{display:"contents"},"data-dd-privacy":"mask",children:t.jsx(Qt,{...n})}):null},pn=({message:e})=>{const s=Ae(e);if(s)return t.jsx("div",{className:Ke(!1),"data-dd-privacy":"mask",children:t.jsx(Ze,{attachment:s,isMyMessage:!1})});const n=Re(e);return n?t.jsx("div",{style:{display:"contents"},"data-dd-privacy":"mask",children:t.jsx(es,{...n})}):null},bn=Object.assign(gn,{Creator:xn,Visitor:pn}),vn={dark:"bg-[#1e2330]",light:"bg-[#f2f1ef]"},jn={dark:"text-white",light:"text-[#000000]"},_n={dark:"border-white/[0.08]",light:"border-black/[0.08]"},wn=e=>e==="dark"?"sender":"receiver",yn={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]"}},be=({variant:e,text:s,bordered:n=!0,groupPosition:a="single",widthClassName:r="w-[280px]",paddingClassName:i="px-2 py-2",radiusClassName:l,className:o,children:d,"data-testid":h})=>{const f=s!=null&&s!=="",u=l??yn[wn(e)][a];return t.jsxs("div",{"data-testid":h,"data-group-position":a,className:C("relative",r,"overflow-hidden",i,f&&"pb-0",u,vn[e],jn[e],n&&"border",n&&_n[e],o),children:[d,f?t.jsx("p",{className:C("whitespace-pre-wrap break-words leading-snug","pb-2 pt-2","px-2"),children:s}):null]})},ve=({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"})}),je=e=>e==="received"?"light":"dark",ts=({firstOfGroup:e,endOfGroup:s,groupedByUser:n})=>!n||e&&s?"single":e?"first":s?"end":"middle",Nn=({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:l,preload:o,onDismiss:d})=>{const h=je(e),f=e==="composer"&&!!d,u=Nn({src:s,mimeType:n,filename:a,items:r});if(u.length===0)return null;const g=o??(u.length>1?"none":"metadata");return t.jsx(be,{variant:h,text:i,groupPosition:l,"data-testid":"audio-attachment",children:t.jsx("div",{className:"flex flex-col gap-2",children:u.map((c,v)=>t.jsx(Cn,{item:c,preload:g,trailingAction:f&&v===0?t.jsx(ve,{onClick:d,variant:"inline"}):void 0},`${c.src}-${v}`))})})},Sn=e=>t.jsx(Qe,{...e,state:"composer"}),kn=e=>t.jsx(Qe,{...e,state:"sent"}),En=e=>t.jsx(Qe,{...e,state:"received"}),In={Composer:Sn,Sent:kn,Received:En};function ss(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 Tn={pdf:"PDF",doc:"DOC",xls:"XLS",csv:"CSV",ppt:"PPT",zip:"ZIP",text:"TXT",markdown:"MD"};function ns(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(se(e)==="document"){const r=Kt(e),i=Tn[r];if(i)return i;if(e==="application/octet-stream")return}const a=e.split("/")[1];if(!(!a||a==="*"))return a.toUpperCase()}function as(e,s,n){const a=ns(e,s),r=typeof n=="number"&&n>0?ss(n):void 0;return[a,r].filter(Boolean).join(" · ")||void 0}function te(e){try{const n=new URL(e).pathname.split("/").pop();return n&&n.length>0?decodeURIComponent(n):"download"}catch{return"download"}}const Mn={dark:"text-white/55",light:"text-black/65"},An={dark:"bg-white/10",light:"bg-black/5"},Rn={dark:"text-white/85",light:"text-black/85"},rs=({variant:e,filename:s,title:n,mimeType:a="application/octet-stream",fileSize:r,onActivate:i,activateLabel:l,trailingAction:o})=>{const d=n??s??"File",h=as(a,s,r),f=t.jsx("div",{className:C("flex size-10 shrink-0 items-center justify-center rounded-sm",An[e]),"aria-hidden":!0,children:ce(a,{className:C("size-6",Rn[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",Mn[e]),children:h}):null]}),g=i?t.jsxs("button",{type:"button",onClick:i,"aria-label":l,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:[f,u]}):t.jsxs(t.Fragment,{children:[f,u]});return t.jsxs("div",{className:"flex items-center gap-3 px-3 py-2",children:[g,o?t.jsx("div",{className:"shrink-0",children:o}):null]})};async function is(e,s){const n=s??te(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),l=document.createElement("a");l.href=i,l.download=n,l.style.display="none",document.body.appendChild(l),l.click(),document.body.removeChild(l),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 Ln=({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}]:[],Dn=({variant:e,item:s,index:n,onActivate:a,trailingAction:r})=>{const i=s.filename??te(s.src);return t.jsx(rs,{variant:e,filename:i,title:s.title,mimeType:s.mimeType??"application/octet-stream",fileSize:s.fileSize,onActivate:()=>a(n),activateLabel:`Download ${i}`,trailingAction:r})},et=({state:e,src:s,filename:n,fileSize:a,mimeType:r,title:i,items:l,text:o,groupPosition:d,onClick:h,onDismiss:f})=>{const u=je(e),g=e==="composer"&&!!f,c=Ln({src:s,filename:n,fileSize:a,mimeType:r,title:i,items:l}),v=p=>{if((h==null?void 0:h(p))===!1)return;const x=c[p];if(!x)return;const b=x.filename??te(x.src);is(x.src,b)};if(c.length===0)return null;const j=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(be,{variant:u,text:o,groupPosition:d,"data-testid":"file-attachment",children:t.jsx("div",{className:"flex flex-col gap-2",children:c.map((p,x)=>{const b=g&&x===0?t.jsx(ve,{onClick:f,variant:"inline"}):j;return t.jsx(Dn,{variant:u,item:p,index:x,onActivate:v,trailingAction:b},`${p.src}-${x}`)})})})},Pn=e=>t.jsx(et,{...e,state:"composer"}),On=e=>t.jsx(et,{...e,state:"sent"}),Fn=e=>t.jsx(et,{...e,state:"received"}),zn={Composer:Pn,Sent:On,Received:Fn},tt=({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})})]}),os=({url:e,filename:s,variant:n="pill",label:a="Download",iconOnly:r,tone:i="dark",onTriggered:l})=>{const[o,d]=m.useState(!1),h=m.useCallback(c=>{c.stopPropagation(),!o&&(d(!0),is(e,s).catch(()=>{}).finally(()=>{d(!1),l==null||l()}))},[o,e,s,l]),f=r??n!=="pill",g={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:o,"aria-label":a,className:C("flex size-8 shrink-0 items-center justify-center rounded-full transition-colors disabled:opacity-70",c[i]),children:o?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:o,"aria-label":a,className:"mes-media-viewer__action",children:o?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:o,"aria-label":f?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:[o?t.jsx(N.CircleNotchIcon,{className:"size-4 animate-spin",weight:"bold","aria-hidden":!0}):t.jsx(N.DownloadSimpleIcon,{...g,"aria-hidden":!0}),f?null:a]})},Oe=(e,s,n)=>Math.min(Math.max(e,s),n),st=({length:e,initialIndex:s,open:n})=>{const a=Oe(s,0,Math.max(e-1,0)),[r,i]=m.useState(a);m.useEffect(()=>{n&&i(Oe(s,0,Math.max(e-1,0)))},[n,s,e]),m.useEffect(()=>{i(d=>Oe(d,0,Math.max(e-1,0)))},[e]);const l=m.useCallback(()=>{e<=1||i(d=>d<=0?e-1:d-1)},[e]),o=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 f=document.activeElement;f&&(f.tagName==="VIDEO"||f.tagName==="AUDIO")||(h.preventDefault(),h.key==="ArrowLeft"?l():o())};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[n,e,l,o]),{index:r,prev:l,next:o}},nt=({open:e,onClose:s,ariaLabel:n,counter:a,actions:r,children:i,"data-testid":l})=>{const o=m.useRef(null),d=m.useRef(null);m.useEffect(()=>{var g;const u=o.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(g=d.current)==null||g.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()},f=u=>{u.target===o.current&&s()};return t.jsxs("dialog",{ref:o,className:"mes-media-viewer","aria-label":n??"Attachment viewer","data-testid":l,onClose:h,onClick:f,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})]})},ls=({open:e,items:s,initialIndex:n=0,onClose:a})=>{const{index:r,prev:i,next:l}=st({length:s.length,initialIndex:n,open:e}),o=s[r],d=m.useMemo(()=>(o==null?void 0:o.filename)??(o?te(o.src):"image"),[o]);return o?t.jsxs(nt,{open:e,onClose:a,ariaLabel:d,counter:s.length>1?`${r+1} / ${s.length}`:void 0,actions:t.jsx(os,{url:o.src,filename:d,variant:"viewer",label:`Download ${d}`}),"data-testid":"image-viewer",children:[e?t.jsx("img",{src:o.src,alt:o.alt??d,draggable:!1,loading:"eager",decoding:"async",className:"mes-media-viewer__image"},`${r}:${o.src}`):null,s.length>1?t.jsx(tt,{onPrev:i,onNext:l,prevLabel:"Previous image",nextLabel:"Next image"}):null]}):null},Bn="relative block size-full overflow-hidden bg-black/5 outline-none after:pointer-events-none after:absolute after:inset-0 after:rounded-[inherit] focus-visible:after:ring-2 focus-visible:after:ring-inset focus-visible:after:ring-white/80 focus-visible:after:ring-offset-2 focus-visible:after:ring-offset-black",$n={1:["rounded-[18px]"],2:["rounded-l-[18px]","rounded-r-[18px]"],3:["rounded-l-[18px]","rounded-tr-[18px]","rounded-br-[18px]"],4:["rounded-tl-[18px]","rounded-tr-[18px]","rounded-bl-[18px]","rounded-br-[18px]"]},Un="--mes-single-width-cap",Vn="[--mes-single-width-cap:309px] sm:[--mes-single-width-cap:326px]",Hn=436,cs=({tiles:e,onTileActivate:s,maxVisible:n=4,singleAspectRatio:a,className:r})=>{const i=e.length;if(i===0)return null;const l=e.slice(0,Math.min(i,n)),o=i-l.length,d=(f,u,g)=>{var v;const c=C(Bn,"h-full w-full",(v=$n[l.length])==null?void 0:v[u]);return s?t.jsxs("button",{type:"button",onClick:()=>s(u),"aria-label":f.ariaLabel??`Open media ${u+1}`,className:C(c,"cursor-zoom-in"),children:[f.content,g]},u):t.jsxs("div",{className:c,children:[f.content,g]},u)};let h;return a&&(h={aspectRatio:a,width:`min(var(${Un}), ${Math.round(Hn*a*100)/100}px)`,maxWidth:"100%"}),l.length===1?t.jsx("div",{className:C(a?Vn:"aspect-square w-full",r),style:h,children:d(l[0],0)}):l.length===2?t.jsx("div",{className:C("grid aspect-[16/9] w-full grid-cols-2 gap-0.5",r),children:l.map((f,u)=>d(f,u))}):l.length===3?t.jsxs("div",{className:C("grid aspect-[4/3] w-full grid-cols-2 grid-rows-2 gap-0.5",r),children:[t.jsx("div",{className:"row-span-2",children:d(l[0],0)}),d(l[1],1),d(l[2],2)]}):t.jsx("div",{className:C("grid aspect-[379/286] w-full grid-cols-2 grid-rows-2 gap-0.5",r),children:l.map((f,u)=>{const g=o>0&&u===l.length-1;return d(f,u,g?t.jsxs("div",{className:"absolute inset-0 flex items-center justify-center bg-black/55 text-2xl font-semibold text-white",children:["+",o]}):null)})})},_e=e=>{const[s,n]=m.useState(!1),[a,r]=m.useState(0),i=m.useCallback(o=>{(e==null?void 0:e(o))!==!1&&(r(o),n(!0))},[e]),l=m.useCallback(()=>n(!1),[]);return{viewerOpen:s,viewerIndex:a,handleActivate:i,closeViewer:l}},Gn=({item:e,index:s,totalCount:n,fallbackLoading:a,imgRef:r,onLoad:i})=>({ariaLabel:`Open image ${s+1} of ${n}`,content:t.jsx("img",{ref:r,src:ie(e.src)??e.src,alt:e.alt??"",width:e.width,height:e.height,draggable:!1,loading:e.loading??a,decoding:"async",onLoad:i,className:"absolute inset-0 size-full object-cover"})}),Yn=({src:e,alt:s,items:n})=>n&&n.length>0?n:e?[{src:e,alt:s}]:[],ds=(e,s)=>e.map((n,a)=>({src:n.src,alt:n.alt,filename:s&&e.length===1?s:s?`${s} (${a+1})`:void 0})),qn=({src:e,alt:s,filename:n,loading:a="lazy",onClick:r,onDismiss:i})=>{const{viewerOpen:l,viewerIndex:o,handleActivate:d,closeViewer:h}=_e(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:ie(e)??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(ve,{onClick:i})}):null,t.jsx(ls,{open:l,items:ds([{src:e,alt:s}],n),initialIndex:o,onClose:h})]})},Wn=326/246,Xn=e=>{const s=e==null?void 0:e.src,[n,a]=m.useState(),r=m.useCallback(d=>{if(!d||d.naturalWidth<=0||d.naturalHeight<=0||s===void 0)return;const h=d.naturalWidth/d.naturalHeight;a(f=>f&&f.src===s&&f.ratio===h?f:{src:s,ratio:h})},[s]),i=m.useCallback(d=>r(d.currentTarget),[r]),l=e!=null&&e.width&&(e!=null&&e.height)?e.width/e.height:void 0,o=n&&n.src===s?n.ratio:void 0;return{ratio:l??o??Wn,imgRef:r,onLoad:i}},us=({state:e,src:s,alt:n,filename:a,items:r,text:i,groupPosition:l,loading:o="lazy",onClick:d})=>{const h=Yn({src:s,alt:n,items:r}),f=je(e),{viewerOpen:u,viewerIndex:g,handleActivate:c,closeViewer:v}=_e(d),j=h.length===1,p=Xn(j?h[0]:void 0);if(h.length===0)return null;const x=h.map((b,_)=>Gn({item:b,index:_,totalCount:h.length,fallbackLoading:o,imgRef:j?p.imgRef:void 0,onLoad:j?p.onLoad:void 0}));return t.jsxs(be,{variant:f,text:i,groupPosition:l,bordered:!1,widthClassName:j?"w-fit max-w-[313px] sm:max-w-[330px]":"w-[383px] max-w-full",paddingClassName:"p-0.5",radiusClassName:"rounded-[20px]","data-testid":"image-attachment",children:[t.jsx("div",{className:"relative",children:t.jsx(cs,{tiles:x,onTileActivate:c,singleAspectRatio:j?p.ratio:void 0})}),t.jsx(ls,{open:u,items:ds(h,a),initialIndex:g,onClose:v})]})},Kn=e=>t.jsx(qn,{...e}),Zn=e=>t.jsx(us,{...e,state:"sent"}),Jn=e=>t.jsx(us,{...e,state:"received"}),Qn={Composer:Kn,Sent:Zn,Received:Jn},ea=({open:e,items:s,initialIndex:n=0,onClose:a})=>{const{index:r,prev:i,next:l}=st({length:s.length,initialIndex:n,open:e}),o=s[r],d=m.useMemo(()=>(o==null?void 0:o.filename)??(o?te(o.src):"document"),[o]),h=m.useMemo(()=>o?ta(o.src):void 0,[o]);return!o||!h?null:t.jsxs(nt,{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}:${o.src}`),s.length>1?t.jsx(tt,{onPrev:i,onNext:l,prevLabel:"Previous document",nextLabel:"Next document"}):null]})},ta=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()}`},sa=({src:e,filename:s,fileSize:n,title:a,items:r})=>r&&r.length>0?r:e?[{src:e,filename:s,fileSize:n,title:a}]:[],na=({variant:e,item:s,index:n,onActivate:a,trailingAction:r})=>{const i=s.filename??te(s.src);return t.jsx(rs,{variant:e,filename:i,title:s.title,mimeType:"application/pdf",fileSize:s.fileSize,onActivate:()=>a(n),activateLabel:`Open ${i}`,trailingAction:r})},at=({state:e,src:s,filename:n,fileSize:a,title:r,items:i,text:l,groupPosition:o,onClick:d,onDismiss:h})=>{const f=je(e),u=sa({src:s,filename:n,fileSize:a,title:r,items:i}),{viewerOpen:g,viewerIndex:c,handleActivate:v,closeViewer:j}=_e(d),p=e==="composer"&&!!h;if(u.length===0)return null;const x=u.map(b=>({src:b.src,filename:b.filename??te(b.src)}));return t.jsxs(be,{variant:f,text:l,groupPosition:o,"data-testid":"pdf-attachment",children:[t.jsx("div",{className:"flex flex-col gap-2",children:u.map((b,_)=>{const S=b.filename??te(b.src),R=p&&_===0?t.jsx(ve,{onClick:h,variant:"inline"}):e==="composer"?void 0:t.jsx(os,{url:b.src,filename:S,variant:"inline",label:`Download ${S}`,tone:f});return t.jsx(na,{variant:f,item:b,index:_,onActivate:v,trailingAction:R},`${b.src}-${_}`)})}),t.jsx(ea,{open:g,items:x,initialIndex:c,onClose:j})]})},aa=e=>t.jsx(at,{...e,state:"composer"}),ra=e=>t.jsx(at,{...e,state:"sent"}),ia=e=>t.jsx(at,{...e,state:"received"}),oa={Composer:aa,Sent:ra,Received:ia},ms=({open:e,items:s,initialIndex:n=0,onClose:a})=>{const{index:r,prev:i,next:l}=st({length:s.length,initialIndex:n,open:e}),o=s[r],d=m.useMemo(()=>(o==null?void 0:o.filename)??(o?te(o.src):"video"),[o]);return o?t.jsxs(nt,{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:o.src,poster:o.poster,controls:!0,autoPlay:!0,muted:!0,playsInline:!0,preload:o.preload??"metadata",className:"mes-media-viewer__video",children:o.mimeType?t.jsx("source",{src:o.src,type:o.mimeType}):null},`${r}:${o.src}`),s.length>1?t.jsx(tt,{onPrev:i,onNext:l,prevLabel:"Previous video",nextLabel:"Next video"}):null]}):null},la=()=>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})})}),hs=({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 object-cover"}):t.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:t.jsx(N.VideoCameraIcon,{className:"size-16 text-white/30",weight:"regular","aria-hidden":!0})}),t.jsx(la,{})]}),ca=(e,s,n)=>({ariaLabel:`Play video ${s+1} of ${n}`,content:t.jsx(hs,{item:e,index:s})}),da=({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}]:[],fs=(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})),ua=({src:e,poster:s,mimeType:n,filename:a,preload:r,onClick:i,onDismiss:l})=>{const{viewerOpen:o,viewerIndex:d,handleActivate:h,closeViewer:f}=_e(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(hs,{item:{src:e,poster:s,mimeType:n},index:0})}),l?t.jsx("div",{className:"absolute right-2 top-2 z-10",children:t.jsx(ve,{onClick:l})}):null,t.jsx(ms,{open:o,items:fs([{src:e,poster:s,mimeType:n,preload:r}],a),initialIndex:d,onClose:f})]})},gs=({state:e,src:s,poster:n,mimeType:a,filename:r,items:i,text:l,groupPosition:o,preload:d,onClick:h})=>{const f=da({src:s,poster:n,mimeType:a,preload:d,items:i}),u=je(e),{viewerOpen:g,viewerIndex:c,handleActivate:v,closeViewer:j}=_e(h);if(f.length===0)return null;const p=f.map((x,b)=>ca(x,b,f.length));return t.jsxs(be,{variant:u,text:l,groupPosition:o,"data-testid":"video-attachment",children:[t.jsx("div",{className:"relative",children:t.jsx(cs,{tiles:p,onTileActivate:v})}),t.jsx(ms,{open:g,items:fs(f,r),initialIndex:c,onClose:j})]})},ma=e=>t.jsx(ua,{...e}),ha=e=>t.jsx(gs,{...e,state:"sent"}),fa=e=>t.jsx(gs,{...e,state:"received"}),ga={Composer:ma,Sent:ha,Received:fa},ge={Image:Qn,Video:ga,Audio:In,Pdf:oa,File:zn},xs=m.createContext(void 0),xa=e=>{var n;const s=(n=e.metadata)==null?void 0:n.broadcast_id;return typeof s=="string"?s:void 0},pa=(e,s)=>{if(!s||!(e!=null&&e.length))return;const n=new Set;let a;for(const r of e){const i=xa(r);if(!i||n.has(i))continue;n.add(i);const l=s(i);l&&(a??(a={}),a[i]=l)}return a},ba=(e,s)=>{if(e===s)return!0;if(!e||!s)return!1;const n=Object.keys(e),a=Object.keys(s);return n.length!==a.length?!1:n.every(r=>e[r]===s[r])},va=(e,s)=>{const n=pa(e,s),[a,r]=m.useState(n);return ba(a,n)?a:(r(n),n)},ja={isUnlocking:()=>!1},_a={LockedAttachment:ja},ps=m.createContext({}),wa=ps.Provider;function bs(e){return m.useContext(ps)[e]??_a[e]}const ya=m.lazy(()=>Promise.resolve().then(()=>require("./Card-415OfRhw.cjs"))),Na=m.lazy(()=>Promise.resolve().then(()=>require("./Card-BZ1ULvgX.cjs"))),Ca=()=>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}),xe=e=>t.jsx(m.Suspense,{fallback:t.jsx(Ca,{}),children:e.contentType==="text"?t.jsx(ya,{...e}):t.jsx(Na,{...e})}),Sa=({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})}),ka=e=>{var s;return((s=e.metadata)==null?void 0:s.custom_type)===X.MESSAGE_CUSTOM_TYPE.TIP},vs=e=>{var s;return((s=e.metadata)==null?void 0:s.custom_type)===X.MESSAGE_CUSTOM_TYPE.PAID},Se=e=>{var s;return((s=e.metadata)==null?void 0:s.custom_type)===X.MESSAGE_CUSTOM_TYPE.CHATBOT},rt=e=>{var s;return((s=e.metadata)==null?void 0:s.custom_type)===X.MESSAGE_CUSTOM_TYPE.ATTACHMENT},Ea=e=>{var s;return rt(e)&&((s=e.metadata)==null?void 0:s.attachment_content_type)==="text"},Ia=e=>{var s;return rt(e)&&((s=e.metadata)==null?void 0:s.attachment_content_type)!=="text"},js=e=>ka(e)||vs(e),Ta=e=>{var s;return js(e)&&!((s=e.text)!=null&&s.trim())},Fe=({message:e,standalone:s=!1,isMyMessage:n=!1,hasAttachment:a=!1})=>{var u;const r=js(e),i=Se(e);if(!r&&!i)return null;if(r){const g=(u=e.metadata)==null?void 0:u.amount_text;if(!g)return null;const c=s?"message-tip-standalone":"message-tag message-tag--tip",v=vs(e)?"message":"tip",j=s?`${g} ${v}`:`Delivered with ${g} ${v}`;return t.jsxs("div",{className:c,children:[t.jsx(N.GiftIcon,{size:s?14:12}),t.jsx("span",{children:j})]})}const l=n&&a,o=l?"Sent with AI":"Sent by AI Assistant",d=["message-chatbot-indicator",n?"message-chatbot-indicator--sender":"message-chatbot-indicator--receiver",l?"message-chatbot-indicator--attachment":"message-chatbot-indicator--text"].join(" "),h=t.jsx("span",{className:"message-chatbot-indicator__label",children:o}),f=t.jsx("span",{className:"message-chatbot-indicator__icon",children:t.jsx(Sa,{size:l?12:15})});return t.jsx("div",{className:d,"data-testid":"message-chatbot-indicator",children:n&&!l?t.jsxs(t.Fragment,{children:[h,f]}):t.jsxs(t.Fragment,{children:[f,h]})})},_s=({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"})})]}),it=()=>{const{message:e}=w.useMessageContext("SentMessageDeliveryStatus"),{messages:s}=w.useChannelStateContext("SentMessageDeliveryStatus"),n=(()=>{if(s)for(let a=s.length-1;a>=0;a-=1){const r=s[a];if(!(r.type==="system"||r.type==="ephemeral"||r.type==="deleted"))return r.id}})();return e.id===n},ze=()=>it()?t.jsxs(t.Fragment,{children:[t.jsx(N.ChecksIcon,{weight:"bold","aria-hidden":"true"}),t.jsx("span",{"data-testid":"sent-message-delivery-status",children:"Delivered"})]}):null,Ma=()=>it()?t.jsxs(t.Fragment,{children:[t.jsx(N.CircleNotchIcon,{className:"sent-message-status__spinner animate-spin",weight:"bold","aria-hidden":"true"}),t.jsx("span",{"data-testid":"sent-message-sending-status",children:"Sending"})]}):null,Aa=({broadcastId:e,broadcastName:s,resolvedBroadcastName:n,onBroadcastClick:a})=>{const r=n||s,i=r||"Broadcast",l=t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"sent-message-broadcast-badge","aria-hidden":"true",children:t.jsx(N.MegaphoneIcon,{weight:"fill"})}),t.jsx("span",{className:"sent-message-broadcast-name","data-testid":"sent-message-broadcast-status",children:i})]});return a?t.jsx("button",{type:"button",className:"sent-message-broadcast-link","aria-label":`View broadcast ${i}`,onClick:()=>a({id:e,...r?{name:r}:{}}),children:l}):l},Ra=()=>t.jsxs("span",{className:"str-chat__message-status sent-message-status--failed",children:[t.jsx(N.WarningCircleIcon,{weight:"bold","aria-hidden":"true"}),t.jsx("span",{"data-testid":"sent-message-failed-status",children:"Failed to send"})]}),La=({onBroadcastClick:e,resolvedBroadcastName:s})=>{var u,g;const{isMyMessage:n,message:a,threadList:r}=w.useMessageContext("SentMessageDeliveryStatus"),i=n(),l=it();if(r)return null;if(a.status==="failed"&&i&&a.type!=="error")return t.jsx(Ra,{});if(!i)return null;const o=(u=a.metadata)==null?void 0:u.broadcast_id,d=(g=a.metadata)==null?void 0:g.broadcast_name,h=a.status!=="sending"&&a.status!=="failed"&&o?t.jsx(Aa,{broadcastId:o,broadcastName:d,resolvedBroadcastName:s,onBroadcastClick:e}):null,f=t.jsx(w.MessageStatus,{MessageSentStatus:ze,MessageDeliveredStatus:ze,MessageReadStatus:ze,MessageSendingStatus:Ma});return h?t.jsxs("span",{className:"sent-message-status-row",children:[f,l&&t.jsx("span",{className:"sent-message-broadcast-separator","aria-hidden":"true",children:"•"}),h]}):f},Da=/^([a-z][a-z0-9+.-]*):/i,Pa=new Set(["http","https","mailto","tel","sms"]);function ot(e){if(typeof e!="string")return;const s=e.trim();if(s==="")return;const n=Da.exec(s);if(n){const a=n[1].toLowerCase();return Pa.has(a)?s:void 0}return s.startsWith("//")||s.startsWith("/")?s:`https://${s}`}const Oa={dark:{primary:"bg-white text-[#121110] hover:bg-white/90",secondary:"bg-white/15 text-white hover:bg-white/25"},light:{primary:"bg-[#121110] text-white hover:bg-[#2a2928]",secondary:"bg-black/[0.06] text-[#121110] hover:bg-black/10"}},Fa=({variant:e,cta:s})=>{const n=s.variant??"primary",a=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",Oa[e][n]),r=ot(s.href);return r?t.jsx("a",{href:r,target:"_blank",rel:"noopener noreferrer",onClick:i=>{var l;i.stopPropagation(),(l=s.onClick)==null||l.call(s)},className:`${a} no-underline`,children:s.label}):t.jsx("button",{type:"button",onClick:i=>{var l;i.stopPropagation(),(l=s.onClick)==null||l.call(s)},className:a,children:s.label})},za={dark:"text-white",light:"text-black/90"},Ba="text-white/30",$a={dark:"text-white/55",light:"text-black/55"},Ua={dark:"bg-white/25",light:"bg-black/15"},lt=({variant:e,ctaSurface:s,chinTextColor:n,title:a,placeholderTitle:r,description:i,url:l,appIcon:o,cta:d,trailingAction:h,isLoading:f=!1})=>{const u=e==="dark",g=a??(u?r:void 0)??"",c=g.trim()!=="",v=i!=null&&i.trim()!=="",j=typeof l=="string"?l.trim():"",p=j!=="",x=d!=null;if(!f&&!c&&!v&&!p&&!x)return null;const b=u&&!a,_=C("line-clamp-2 text-[14px] font-medium leading-5 tracking-[0.28px]",n==null&&(b?Ba:za[e])),S=C("truncate text-[12px] leading-4 tracking-[0.24px]",n==null&&$a[e]);if(f){const M=C("animate-pulse rounded",Ua[e]);return t.jsx("div",{className:"shrink-0 px-4 py-3",children:t.jsxs("div",{className:"flex min-w-0 flex-col gap-[2px]",children:[t.jsx("div",{className:C("h-5 w-3/4",M),"aria-hidden":!0}),t.jsx("div",{className:C("h-4 w-1/2",M),"aria-hidden":!0})]})})}const R=n?{color:n}:void 0;return t.jsxs("div",{className:"shrink-0 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-[2px]",children:[c&&t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[o?t.jsx("span",{className:"shrink-0",children:o}):null,t.jsx("p",{className:C("min-w-0",_),style:R,children:g})]}),v&&t.jsx("p",{className:S,style:R,children:i}),!x&&p&&t.jsx("p",{className:S,style:R,children:j})]}),h&&t.jsx("div",{className:"shrink-0",children:h})]}),d&&t.jsx(Fa,{variant:s??e,cta:d})]})},Va="Loading link preview",Ha=C("relative w-[290px] select-none overflow-hidden","rounded-[20px]"),Ga="flex h-[250px] flex-col",ke=({variant:e,children:s,href:n,onClick:a,ariaLabel:r,rootRef:i,topRight:l,bgClassName:o,accentHex:d,fixedHeight:h=!1,busy:f=!1,"data-testid":u})=>{const g=n!=null||a!=null,c=C("messaging-link-card",Ha,h?Ga:"block",o??(e==="dark"?"bg-[#1e2330]":"bg-[#f1f0ee]"),g?"cursor-pointer no-underline focus-ring":null),v=f?{role:"status","aria-busy":!0,"aria-label":Va}:void 0,j=d?{"--accent":d}:void 0,p=l?t.jsx("div",{className:"pointer-events-auto absolute right-3 top-3 z-10",children:l}):null;return n?t.jsxs("a",{ref:i,href:n,target:"_blank",rel:"noopener noreferrer",onClick:a,"data-testid":u,"data-variant":e,className:c,style:j,...v,children:[s,p]}):a?t.jsxs("button",{ref:i,type:"button",onClick:a,"aria-label":r,"data-testid":u,"data-variant":e,className:C(c,"text-left"),style:j,...v,children:[s,p]}):t.jsxs("div",{ref:i,"data-testid":u,"data-variant":e,className:c,style:j,...v,children:[s,p]})},Dt={dark:"bg-white/10",light:"bg-black/5"},Ya={dark:"size-16 text-white/25",light:"size-16 text-black/25"},we=(e,s)=>!!s&&!!e&&se(e)==="audio",ct=(e,s)=>{if(!s||!e)return!1;const n=se(e);return n==="video"||n==="audio"},dt="bg-[#F2F3F4]",Ee=({variant:e,thumbnailUrl:s,sourceUrl:n,title:a,mimeType:r="image/*",topLeft:i,topRight:l,isLoading:o=!1,onImageError:d})=>{const h=se(r),f=!!n&&h==="video",u=ie(s);return!o&&we(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 min-h-0 w-full flex-1 overflow-hidden",f&&"bg-black"),children:[o?t.jsx("div",{className:C("h-full w-full animate-pulse",Dt[e]),"aria-hidden":!0}):f?t.jsxs(t.Fragment,{children:[t.jsx("video",{src:n,poster:u,controls:!0,playsInline:!0,preload:"metadata",className:"absolute inset-0 h-full w-full object-contain",children:t.jsx("track",{kind:"captions"})}),u&&d?t.jsx("img",{src:u,alt:"","aria-hidden":!0,onError:d,className:"hidden"}):null]}):s?t.jsx("img",{src:u??s,alt:a??"",draggable:!1,loading:"lazy",decoding:"async",onError:d,className:"absolute inset-0 h-full w-full object-cover"}):t.jsx("div",{className:C("flex h-full w-full items-center justify-center",Dt[e]),children:ce(r,{className:Ya[e],weight:"regular"})}),i?t.jsx("div",{className:"pointer-events-auto absolute left-3 top-3 z-10",children:i}):null,l?t.jsx("div",{className:"pointer-events-auto absolute right-3 top-3 z-10",children:l}):null]})},qa=/^#?(?:[0-9a-f]{3}|[0-9a-f]{6})$/i;function Wa(e){const s=e.trim();return s.startsWith("#")?s:`#${s}`}const Xa="#FFFFFF",ws="#040403",Ka={dark:Xa,light:ws};function ut({variant:e,accentColor:s,status:n="ready",layout:a="featured",thumbnailUrl:r,mimeType:i,sourceUrl:l}){const[o,d]=m.useState(!1);m.useEffect(()=>{d(!1)},[r]);const h=m.useCallback(()=>{d(!0)},[]),f=we(i,l),c=a==="featured"&&!!r&&!f&&!o&&n==="ready"&&s!=null&&qa.test(s.trim())?Wa(s):void 0,v=f?ws:Ka[e];return{thumbnailUrl:o?void 0:r,accentHex:c,chinTextColor:v,surface:f?"light":e,isLoading:n==="loading",onImageError:h}}const Za="flex size-6 items-center justify-center rounded-full bg-[#121110] text-white focus-ring",Ja="relative before:absolute before:-inset-[10px] before:content-['']",Qa=({title:e,placeholderTitle:s,description:n,url:a,mimeType:r,thumbnailUrl:i,sourceUrl:l,layout:o="featured",appIcon:d,cta:h,accentColor:f,status:u="ready",onDismiss:g,onEditClick:c,dismissLabel:v="Dismiss attachment"})=>{const j=o==="classic",p=we(r,l),x=ut({variant:"dark",accentColor:f,status:u,layout:o,thumbnailUrl:i,mimeType:r,sourceUrl:l}),b=g?t.jsx("button",{type:"button",onClick:g,"aria-label":v,className:C(Za,!p&&Ja),children:t.jsx(N.XIcon,{className:"size-3",weight:"bold"})}):void 0,_=c?t.jsx("button",{type:"button",onClick:c,"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 p&&!x.isLoading?t.jsx(ke,{variant:"dark",bgClassName:dt,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(Ee,{variant:"dark",sourceUrl:l,title:e,mimeType:r})}),b&&t.jsx("div",{className:"shrink-0",children:b})]})}):t.jsxs(ke,{variant:"dark",fixedHeight:!j,accentHex:x.accentHex,busy:x.isLoading,topRight:j?b:void 0,children:[!j&&t.jsx(Ee,{variant:"dark",thumbnailUrl:x.thumbnailUrl,sourceUrl:l,title:e,mimeType:r,topRight:b,isLoading:x.isLoading,onImageError:x.onImageError}),t.jsx(lt,{chinTextColor:x.chinTextColor,variant:"dark",ctaSurface:x.surface,title:e,placeholderTitle:s,description:n,url:a,appIcon:d,cta:h,trailingAction:_,isLoading:x.isLoading})]})},ys=({accentHex:e,side:s,visible:n,children:a})=>{if(!n)return t.jsx(t.Fragment,{children:a});const r=s==="sender"?"dark":"light",i=e?{"--accent":e}:void 0;return t.jsxs("div",{className:"relative isolate w-fit",children:[a,t.jsx("span",{"aria-hidden":!0,"data-testid":"link-card-tail","data-variant":r,style:i,className:C("messaging-link-card-tail",s==="receiver"&&"messaging-link-card-tail--received")})]})},er=({title:e,description:s,url:n,mimeType:a,thumbnailUrl:r,sourceUrl:i,layout:l="featured",appIcon:o,cta:d,accentColor:h,status:f="ready",onClick:u,groupPosition:g="single"})=>{const c=ct(a,i),v=ot(n),j=d==null&&v!=null&&!c?v:void 0,p=d==null&&!c?u:void 0,x=f!=="loading"&&we(a,i)?dt:void 0,b=d&&u?{...d,onClick:()=>{var S;u(),(S=d.onClick)==null||S.call(d)}}:d,_=ut({variant:"light",accentColor:h,status:f,layout:l,thumbnailUrl:r,mimeType:a,sourceUrl:i});return t.jsx(ys,{accentHex:_.accentHex,side:"receiver",visible:x==null&&(g==="single"||g==="end"),children:t.jsxs(ke,{variant:"light",href:j,onClick:p,ariaLabel:e??"Open attachment preview",fixedHeight:l==="featured"&&x==null,accentHex:_.accentHex,busy:_.isLoading,bgClassName:x,"data-testid":"link-attachment",children:[l==="featured"&&t.jsx(Ee,{variant:"light",thumbnailUrl:_.thumbnailUrl,sourceUrl:i,title:e,mimeType:a,isLoading:_.isLoading,onImageError:_.onImageError}),t.jsx(lt,{chinTextColor:_.chinTextColor,variant:"light",ctaSurface:_.surface,title:e,description:s,url:n,appIcon:o,cta:b,isLoading:_.isLoading})]})})},tr=({title:e,placeholderTitle:s,description:n,url:a,mimeType:r,thumbnailUrl:i,sourceUrl:l,layout:o="featured",appIcon:d,cta:h,accentColor:f,status:u="ready",onClick:g,groupPosition:c="single"})=>{const v=ct(r,l),j=ot(a),p=h==null&&j!=null&&!v?j:void 0,x=h==null&&!v&&p!=null?g:void 0,b=u!=="loading"&&we(r,l),_=ut({variant:"dark",accentColor:f,status:u,layout:o,thumbnailUrl:i,mimeType:r,sourceUrl:l});return t.jsx(ys,{accentHex:_.accentHex,side:"sender",visible:!b&&(c==="single"||c==="end"),children:t.jsxs(ke,{variant:"dark",href:p,onClick:x,fixedHeight:o==="featured"&&!b,accentHex:_.accentHex,busy:_.isLoading,bgClassName:b?dt:void 0,children:[o==="featured"&&t.jsx(Ee,{variant:"dark",thumbnailUrl:_.thumbnailUrl,sourceUrl:l,title:e,mimeType:r,isLoading:_.isLoading,onImageError:_.onImageError}),t.jsx(lt,{chinTextColor:_.chinTextColor,variant:"dark",ctaSurface:_.surface,title:e,placeholderTitle:s,description:n,url:a,appIcon:d,cta:h,isLoading:_.isLoading})]})})},Ie={Composer:Qa,Sent:tr,Received:er};function L(e){const s=e==null?void 0:e.trim();return s||void 0}function Pt(e){return e.trim().replace(/^https?:\/\//i,"").replace(/\/+$/,"").toLowerCase()}function sr(e,s){if(!(e!=null&&e.trim())||!(s!=null&&s.trim()))return!1;const n=Pt(e),a=Pt(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 Ot(e){const s=L(e.og_scrape_url)??L(e.title_link),n=L(e.image_url)??L(e.thumb_url),a=L(e.asset_url),r=L(e.mime_type);return{title:L(e.title),description:L(e.text),url:s,thumbnailUrl:ie(n),sourceUrl:a,layout:n||ct(r,a)?"featured":"classic",mimeType:r,accentColor:L(e.accent_color),status:"ready"}}function nr(e){var s;return Ns(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 Ns(e){const s=L(e.og_scrape_url);return e.type==="link"||!!s&&!e.asset_url}function Cs(e){if(!(e!=null&&e.length))return[];const s=[],n=(r,i)=>{const l=s[s.length-1];if((l==null?void 0:l.type)==="media"&&l.kind===r){l.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(Ns(r)){a(r);continue}const i=nr(r);i&&n(i,r)}return s}function ar(e){return e.filter(s=>s.type==="media").length}function rr(e,s,n){return s<=1?n:e===0?"first":e===s-1?"end":"middle"}function Ft(e){return L(e.image_url)??L(e.asset_url)??""}function ir(e){switch(e){case"image":return ge.Image;case"video":return ge.Video;case"audio":return ge.Audio;case"pdf":return ge.Pdf;default:return ge.File}}function or(e,s){if(s.length>1)switch(e){case"image":return{items:s.map(a=>({src:Ft(a),alt:L(a.title)}))};case"video":return{items:s.map(a=>({src:L(a.asset_url)??"",poster:L(a.thumb_url),mimeType:L(a.mime_type)}))};case"audio":return{items:s.map(a=>({src:L(a.asset_url)??"",mimeType:L(a.mime_type)??"audio/mpeg",filename:L(a.title)}))};case"pdf":return{items:s.map(a=>({src:L(a.asset_url)??"",filename:L(a.title),fileSize:a.file_size}))};case"file":return{items:s.map(a=>({src:L(a.asset_url)??"",filename:L(a.title),fileSize:a.file_size,mimeType:L(a.mime_type)??"application/octet-stream"}))}}const n=s[0];if(!n)return{};switch(e){case"image":return{src:Ft(n),alt:L(n.title)};case"video":return{src:L(n.asset_url)??"",poster:L(n.thumb_url),mimeType:L(n.mime_type)};case"audio":return{src:L(n.asset_url)??"",mimeType:L(n.mime_type)??"audio/mpeg",filename:L(n.title)};case"pdf":return{src:L(n.asset_url)??"",filename:L(n.title),fileSize:n.file_size};case"file":return{src:L(n.asset_url)??"",filename:L(n.title),fileSize:n.file_size,mimeType:L(n.mime_type)??"application/octet-stream"}}}function lr({groupPosition:e,isMyMessage:s,segment:n}){const a=ir(n.kind),r={...or(n.kind,n.attachments),groupPosition:e};return s?t.jsx(a.Sent,{...r}):t.jsx(a.Received,{...r})}const cr=({groupPosition:e,isMyMessage:s,message:n,renderText:a})=>{var j;const r=Cs(n.attachments);if(r.length===0)return null;const i=ar(r),l=(j=n.text)==null?void 0:j.trim(),o=r.find(p=>p.type==="link"),d=(o==null?void 0:o.type)==="link"?Ot(o.attachments[0]??{}).url:void 0,h=l&&sr(l,d)?void 0:l;let f=0;const u=[],g=h?"middle":e,c=(p,x,b)=>{const _=s?Ie.Sent:Ie.Received;u.push(t.jsx(_,{...Ot(p),groupPosition:b?g:"middle"},x))},v=(p,x)=>{const b=rr(f,i,e);f+=1,u.push(t.jsx(lr,{groupPosition:b,isMyMessage:s,segment:p},x))};return r.forEach((p,x)=>{const b=x===r.length-1;if(p.type==="link"){p.attachments.forEach((_,S)=>{c(_,`link-${x}-${S}`,b&&S===p.attachments.length-1)});return}v(p,`media-${x}`)}),t.jsxs("div",{className:"str-chat__message-bubble-wrapper",children:[t.jsxs("div",{className:"str-chat__message-bubble","data-attachment-bubble":"true",style:{background:"transparent",borderRadius:0,overflow:"visible",padding:0},children:[u,!h&&t.jsx(w.MessageErrorIcon,{})]}),h?t.jsxs("div",{className:"str-chat__message-bubble",children:[t.jsx(w.MessageText,{message:n,renderText:a}),t.jsx(w.MessageErrorIcon,{})]}):null]})},dr=e=>{var vt,jt,_t,wt,yt,Nt,Ct,St,kt,Et;const{additionalMessageInputProps:s,chatbotVotingEnabled:n,editing:a,endOfGroup:r,firstOfGroup:i,groupedByUser:l,handleAction:o,handleOpenThread:d,handleRetry:h,highlighted:f,isMessageAIGenerated:u,isMyMessage:g,message:c,renderText:v,threadList:j,viewerLanguage:p,onBroadcastClick:x,resolvedBroadcastName:b}=e,{client:_}=w.useChatContext("CustomMessage"),{channel:S}=w.useChannelStateContext("CustomMessage"),{isUnlocking:R,onUnlockClick:M,onFetchSource:z,onDownloadClick:O}=bs("LockedAttachment"),[$,D]=m.useState(!1),k=w.useMessageReminder(c.id),{selected:P,voteUp:E,voteDown:A}=Wt(c),{Attachment:I=w.Attachment,EditMessageModal:B=w.EditMessageModal,MessageActions:F,MessageBlocked:U=w.MessageBlocked,MessageBouncePrompt:q=w.MessageBouncePrompt,MessageDeleted:Q=w.MessageDeleted,MessageIsThreadReplyInChannelButtonIndicator:H=w.MessageIsThreadReplyInChannelButtonIndicator,MessageRepliesCountButton:y=w.MessageRepliesCountButton,ReminderNotification:T=w.ReminderNotification,StreamedMessageText:G=w.StreamedMessageText,PinIndicator:K}=w.useComponentContext("CustomMessage"),Y=w.messageHasAttachments(c),ee=w.messageHasReactions(c),W=m.useMemo(()=>u==null?void 0:u(c),[u,c]),V=m.useMemo(()=>{const le=c.attachments??[],he=c.shared_location?[c.shared_location,...le]:le;if(!Se(c))return he;const It=he.filter(Tt=>!("type"in Tt)||!Je(Tt));return It.length===he.length?he:It},[c]),Z=m.useMemo(()=>Cs(V),[V]),ne=m.useMemo(()=>{const le=We({message:c,viewerLanguage:p});return le===c.text?c:{...c,text:le}},[c,p]),ye=Z.length>0,Ne=Z.reduce((le,he)=>le+he.attachments.length,0)===((V==null?void 0:V.length)??0),ae=ts({endOfGroup:r,firstOfGroup:i,groupedByUser:l});if(w.isDateSeparatorMessage(c))return null;if(c.deleted_at||c.type==="deleted")return t.jsx(Q,{message:c});if(w.isMessageBlocked(c))return t.jsx(U,{});const oe=!j&&!!c.reply_count,re=!j&&c.show_in_channel&&c.parent_id,ht=c.status==="failed"&&((vt=c.error)==null?void 0:vt.status)!==403,ft=w.isMessageBounced(c);let ue;ht?ue=()=>h(c):ft&&(ue=()=>D(!0));const J=g(),Ls=C("str-chat__message str-chat__message-simple",`str-chat__message--${c.type}`,`str-chat__message--${c.status}`,J?"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":Y,"str-chat__message--highlighted":f,"str-chat__message--pinned pinned-message":c.pinned,"str-chat__message--with-reactions":ee,"str-chat__message-send-can-be-retried":(c==null?void 0:c.status)==="failed"&&((jt=c==null?void 0:c.error)==null?void 0:jt.status)!==403,"str-chat__message-with-thread-link":oe||re,"str-chat__virtual-message__wrapper--end":r,"str-chat__virtual-message__wrapper--first":i,"str-chat__virtual-message__wrapper--group":l}),Le=c.poll_id&&_.polls.fromState(c.poll_id),gt=Ta(c),me=Se(c),Ds=rt(c),De=!!(V!=null&&V.length&&!c.quoted_message),xt=me&&J&&De,Ps=ye&&Ne&&!c.quoted_message&&!Le&&!W&&!me,pt={contentType:"text",amountText:(_t=c.metadata)==null?void 0:_t.amount_text,paymentStatus:(wt=c.metadata)==null?void 0:wt.payment_status,renderedText:c.text&&t.jsx(w.MessageText,{message:ne,renderText:v})},bt={contentType:"media",title:(yt=c.metadata)==null?void 0:yt.attachment_title,mimeType:(Nt=c.metadata)==null?void 0:Nt.attachment_mime_type,thumbnailUrl:(Ct=c.metadata)==null?void 0:Ct.attachment_thumbnail,amountText:(St=c.metadata)==null?void 0:St.amount_text,detail:(kt=c.metadata)==null?void 0:kt.attachment_detail,paymentStatus:(Et=c.metadata)==null?void 0:Et.payment_status,onFetchSource:z?()=>z(c,S):void 0};return t.jsxs(t.Fragment,{children:[a&&t.jsx(B,{additionalMessageInputProps:s}),$&&t.jsx(w.MessageBounceModal,{MessageBouncePrompt:q,onClose:()=>D(!1),open:$}),t.jsxs("div",{className:Ls,"data-message-id":c.id,"data-dd-privacy":"mask",children:[K&&t.jsx(K,{}),!!k&&t.jsx(T,{reminder:k}),c.user&&t.jsx(de,{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":ht||ft}),"data-testid":"message-inner",onClick:ue,onKeyDown:ue,role:ue?"button":void 0,tabIndex:ue?0:void 0,style:{marginInlineEnd:0,marginInlineStart:0},children:gt?t.jsx(Fe,{message:c,standalone:!0}):Ea(c)?t.jsx("div",{className:"str-chat__message-bubble-wrapper",children:t.jsxs("div",{className:"flex items-center gap-2",children:[J&&F&&t.jsx(F,{}),J?t.jsx(xe,{...pt,isMine:!0}):t.jsx(xe,{...pt,isMine:!1,isUnlocking:R(c.id),onUnlockClick:()=>M==null?void 0:M(c,S)}),!J&&F&&t.jsx(F,{})]})}):Ia(c)?t.jsxs("div",{className:"str-chat__message-bubble-wrapper",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[J&&F&&t.jsx(F,{}),J?t.jsx(xe,{...bt,isMine:!0,onPreviewClick:()=>M?M(c,S):void 0}):t.jsx(xe,{...bt,isMine:!1,isUnlocking:R(c.id),onUnlockClick:()=>M?M(c,S):void 0,onDownloadClick:()=>O?O(c,S):void 0}),!J&&F&&t.jsx(F,{})]}),c.text&&t.jsx("div",{className:"str-chat__message-bubble",children:t.jsx(w.MessageText,{message:ne,renderText:v})})]}):Ps?t.jsx(cr,{groupPosition:ae,isMyMessage:J,message:{...ne,attachments:V,i18n:void 0},renderText:v}):t.jsx("div",{className:"str-chat__message-bubble-wrapper",children:t.jsxs("div",{className:"str-chat__message-bubble",children:[me&&!xt&&t.jsx(Fe,{message:c,hasAttachment:De,isMyMessage:J}),Le&&t.jsx(w.Poll,{poll:Le}),V!=null&&V.length&&!c.quoted_message?t.jsx(I,{actionHandler:o,attachments:V}):null,W?t.jsx(G,{message:ne,renderText:v}):t.jsx(w.MessageText,{message:ne,renderText:v}),t.jsx(w.MessageErrorIcon,{})]})})}),!Ds&&!gt&&t.jsxs("div",{className:"str-chat__message-footer",children:[(!me||xt)&&t.jsx(Fe,{message:c,hasAttachment:De,isMyMessage:J}),n&&me&&t.jsx(_s,{selected:P,onVoteUp:E,onVoteDown:A})]}),t.jsx(La,{onBroadcastClick:x,resolvedBroadcastName:b}),oe&&t.jsx(y,{onClick:d,reply_count:c.reply_count}),re&&t.jsx(H,{})]},c.id)]})},ur=m.memo(dr,(e,s)=>e.chatbotVotingEnabled!==s.chatbotVotingEnabled||e.viewerLanguage!==s.viewerLanguage||e.onBroadcastClick!==s.onBroadcastClick||e.resolvedBroadcastName!==s.resolvedBroadcastName?!1:w.areMessageUIPropsEqual(e,s)),mr=e=>{var i;const s=w.useMessageContext("CustomMessage"),n=m.useContext(xs),a=(i=s.message.metadata)==null?void 0:i.broadcast_id,r=typeof a=="string"?n==null?void 0:n[a]:void 0;return t.jsx(ur,{...s,...e,resolvedBroadcastName:r})},hr=()=>{var n;const{handleDelete:e,message:s}=w.useMessageContext("CustomMessageActions");return((n=s.metadata)==null?void 0:n.payment_status)==="paid"?null:t.jsx(He.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})})},fr=()=>{const{handleFlag:e}=w.useMessageContext("CustomMessageActions");return t.jsx(He.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})})},gr=()=>{var s;const{message:e}=w.useMessageContext("CustomMessageActions");return((s=e.metadata)==null?void 0:s.custom_type)!==X.MESSAGE_CUSTOM_TYPE.ATTACHMENT?null:t.jsx(He.MessageActions,{messageActionSet:[{Component:hr,placement:"quick",type:"delete"},{Component:fr,placement:"quick",type:"flag"}]})},xr=e=>({linkPreviews:Array.from(e.previews.values()).filter(s=>Ce.LinkPreviewsManager.previewIsLoaded(s)||Ce.LinkPreviewsManager.previewIsLoading(s))}),pr=()=>{const{linkPreviewsManager:e}=w.useMessageComposer(),{linkPreviews:s}=w.useStateStore(e.state,xr),n=r=>{e.dismissPreview(r)};return s.length>0?t.jsx("div",{className:"messaging-link-preview-list flex flex-col items-stretch w-full gap-2",children:s.map(r=>{const i=Ce.LinkPreviewsManager.previewIsLoading(r);return t.jsx(Ie.Composer,{title:r.title,url:r.og_scrape_url,thumbnailUrl:r.image_url,layout:i||r.image_url?"featured":"classic",status:i?"loading":"ready",onDismiss:()=>n(r.og_scrape_url)},r.og_scrape_url)})}):null},Te=m.createContext(!1),br=200,vr=()=>m.useContext(Te),jr=({sendMessage:e,disabled:s,...n})=>t.jsx("button",{...n,type:"button","aria-label":"Send",disabled:s,onPointerDown:a=>a.preventDefault(),onClick:e,children:t.jsx(N.ArrowUpIcon,{weight:"bold",className:"size-4"})}),zt=()=>{const e=m.useContext(Te),{handleSubmit:s}=w.useMessageInputContext(),n=w.useMessageComposerHasSendableData(),a=e||!n,{SendButton:r=jr,AttachmentPreviewList:i=w.AttachmentPreviewList}=w.useComponentContext("CustomMessageInput"),l=m.useRef(null);return m.useEffect(()=>{const o=l.current;if(!o||typeof ResizeObserver>"u")return;const d=new ResizeObserver(()=>{o.contains(document.activeElement)&&(o.scrollTop=o.scrollHeight)});return d.observe(o),()=>d.disconnect()},[]),m.useEffect(()=>{const o=l.current;if(!o)return;const d=h=>{var u;Array.from(((u=h.clipboardData)==null?void 0:u.items)??[]).some(g=>g.kind==="file")||h.stopPropagation()};return o.addEventListener("paste",d),()=>o.removeEventListener("paste",d)},[]),t.jsxs("div",{ref:l,className:"central-container flex flex-col min-w-0 w-full max-h-[calc(var(--messaging-surface-height,100dvh)*0.5)] overflow-y-auto overscroll-contain 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)] [&>:not(.messaging-composer-previews):not(.messaging-composer-row)]:p-2","data-dd-privacy":"mask",children:[t.jsxs("div",{className:"messaging-composer-previews empty:hidden flex flex-col gap-2 px-2 pt-2",children:[t.jsx(w.QuotedMessagePreview,{}),t.jsx(pr,{}),t.jsx(i,{})]}),t.jsxs("div",{className:"messaging-composer-row flex items-start",children:[t.jsx(w.TextareaComposer,{"aria-disabled":e||void 0,containerClassName:"min-w-0 flex-1 leading-[0]",className:"w-full resize-none overflow-hidden bg-transparent py-3.5 pl-4 pr-4 outline-none leading-5 placeholder:text-black/30 text-sm",autoFocus:!e,enterKeyHint:"send",maxRows:1/0,readOnly:e,tabIndex:e?-1:void 0}),t.jsx("div",{className:"sticky bottom-2 mt-auto mb-2 mr-2 shrink-0 pt-2",children:t.jsx(r,{sendMessage:s,"aria-label":"Send",className:"str-chat__send-button relative flex justify-center items-center rounded-full size-8 bg-[#121110] disabled:bg-[#F1F0EE] disabled:text-black/20 text-white focus-ring before:absolute before:-inset-2 before:content-['']","data-testid":"send-button",disabled:a,type:"button"})})]})]})},Bt=({renderActions:e,renderHeader:s,renderFooter:n,disabled:a=!1,disabledReason:r,composerInput:i})=>{var f;const{channel:l}=w.useChannelStateContext(),o=((f=l==null?void 0:l.data)==null?void 0:f.frozen)===!0,d=!!i,h=m.useRef(null);return m.useEffect(()=>{if(!d)return;const u=h.current,g=u==null?void 0:u.parentElement;if(!u||!g)return;let c=u.offsetHeight;const v=()=>{const p=u.offsetHeight,x=p>c;c=p;const b=Array.from(g.querySelectorAll(".str-chat__list")).find(S=>S.scrollHeight>S.clientHeight)??null,_=b?b.scrollHeight-b.scrollTop-b.clientHeight<br:!1;g.style.setProperty("--messaging-composer-height",`${p}px`),x&&_&&b&&(b.scrollTop=b.scrollHeight)};if(v(),typeof ResizeObserver>"u")return;const j=new ResizeObserver(v);return j.observe(u),()=>{j.disconnect(),g.style.removeProperty("--messaging-composer-height")}},[d]),a?d?t.jsxs("div",{ref:h,className:"messaging-composer-chrome messaging-composer-chrome--floating",children:[t.jsxs("div",{className:"messaging-composer-backdrop","aria-hidden":"true",children:[t.jsx("div",{className:"messaging-composer-backdrop-blur"}),t.jsx("div",{className:"messaging-composer-backdrop-blur"}),t.jsx("div",{className:"messaging-composer-backdrop-blur"}),t.jsx("div",{className:"messaging-composer-backdrop-blur"}),t.jsx("div",{className:"messaging-composer-backdrop-blur"}),t.jsx("div",{className:"messaging-composer-backdrop-gradient"})]}),t.jsxs("div",{className:"relative z-10 flex flex-col",children:[s==null?void 0:s(),t.jsx("div",{className:"messaging-composer-locked-panel flex w-full flex-col items-center justify-center gap-3 px-6 py-4",children:r?t.jsx("p",{className:"max-w-[345px] text-center text-xs font-normal leading-[1.3] tracking-[0.12px] text-black/40",children:r}):null}),n==null?void 0:n()]})]}):t.jsxs(t.Fragment,{children:[s==null?void 0:s(),t.jsx("div",{className:"messaging-composer-locked-panel flex w-full flex-col items-center justify-center gap-3 px-6 py-4",children:r?t.jsx("p",{className:"max-w-[345px] text-center text-xs font-normal leading-[1.3] tracking-[0.12px] text-black/40",children:r}):null}),n==null?void 0:n()]}):d?t.jsxs("div",{ref:h,className:"messaging-composer-chrome messaging-composer-chrome--floating",children:[t.jsxs("div",{className:"messaging-composer-backdrop","aria-hidden":"true",children:[t.jsx("div",{className:"messaging-composer-backdrop-blur"}),t.jsx("div",{className:"messaging-composer-backdrop-blur"}),t.jsx("div",{className:"messaging-composer-backdrop-blur"}),t.jsx("div",{className:"messaging-composer-backdrop-blur"}),t.jsx("div",{className:"messaging-composer-backdrop-blur"}),t.jsx("div",{className:"messaging-composer-backdrop-gradient"})]}),t.jsxs("div",{className:"relative z-10 flex min-h-0 flex-col",children:[s==null?void 0:s(),t.jsxs("div",{className:"flex min-h-0 flex-col gap-4 p-4",children:[t.jsxs("div",{inert:o?"":void 0,"aria-disabled":o||void 0,className:"message-input flex min-h-0 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(Te.Provider,{value:o,children:t.jsx(w.MessageInput,{Input:i??zt})})]}),n==null?void 0:n()]})]})]}):t.jsxs("div",{className:"flex min-h-0 flex-col gap-4 p-4",children:[s==null?void 0:s(),t.jsxs("div",{inert:o?"":void 0,"aria-disabled":o||void 0,className:"message-input flex min-h-0 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(Te.Provider,{value:o,children:t.jsx(w.MessageInput,{Input:zt})})]}),n==null?void 0:n()]})},_r={SYSTEM_DM_AGENT_PAUSED:"DM Agent has left the conversation",SYSTEM_DM_AGENT_RESUMED:"DM Agent has rejoined the conversation"},wr=["SYSTEM_AGE_SAFETY_BLOCKED"],yr={SYSTEM_AGE_SAFETY_BLOCKED:"This user isn’t able to reply because they don’t meet our age safety guidelines."},Be="age safety guidelines.",Nr="https://linktr.ee/s/about/contact",Cr=e=>wr.includes(e),Sr=e=>{var s;return Cr((s=e.metadata)==null?void 0:s.custom_type)},kr=e=>{var a;const s=(a=e.metadata)==null?void 0:a.custom_type;if(X.isDmAgentSystemType(s))return{kind:"dm-agent",type:s};if(X.isAgeSafetySystemType(s))return{kind:"age-safety",type:s};const n=e.dm_agent_system_type;if(X.isDmAgentSystemType(n))return{kind:"dm-agent",type:n}},Er=e=>{const s=e.indexOf(Be);if(s===-1)return e;const n=s+Be.length;return t.jsxs(t.Fragment,{children:[e.slice(0,s),t.jsx("a",{href:Nr,target:"_blank",rel:"noopener noreferrer",className:"mes-age-safety-system-message__emphasis font-medium text-inherit underline",children:Be}),e.slice(n)]})},Ir=e=>{var a,r;const s=!Sr(e.message),n=kr(e.message);if((n==null?void 0:n.kind)==="dm-agent"){const i=((a=e.message.text)==null?void 0:a.trim())||_r[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(w.MessageTimestamp,{message:e.message})]})}if((n==null?void 0:n.kind)==="age-safety"){const i=((r=e.message.text)==null?void 0:r.trim())||yr[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:Er(i)})})]}),!s&&t.jsx(w.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(w.MessageTimestamp,{message:e.message})]})},Ss=m.createContext(!1),$e=({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"})}),Tr=new Set([w.AIStates.Thinking,w.AIStates.Generating,w.AIStates.ExternalSources]),Mr=({threadList:e})=>{var v,j;const{channel:s,channelConfig:n,thread:a}=w.useChannelStateContext(),{client:r}=w.useChatContext(),{typing:i={}}=w.useTypingContext(),{aiState:l}=w.useAIState(s),o=m.useContext(Ss);if(!e&&o&&Tr.has(l)){const p=Ar(s,(v=r.user)==null?void 0:v.id);return t.jsx($t,{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:x})=>{var b;return(x==null?void 0:x.id)!==((b=r.user)==null?void 0:b.id)&&!p}),f=e?Object.values(i).filter(({parent_id:p,user:x})=>{var b;return(x==null?void 0:x.id)!==((b=r.user)==null?void 0:b.id)&&p===(a==null?void 0:a.id)}):[],u=e?f:h;if(!u.length)return null;const g=(j=u[0])==null?void 0:j.user,c=g!=null&&g.id&&s.state.members[g.id]?s.state.members[g.id].user:void 0;return t.jsx($t,{avatarId:(g==null?void 0:g.id)??(c==null?void 0:c.id)??"typing-user",avatarName:(g==null?void 0:g.name)??(c==null?void 0:c.name)??(g==null?void 0:g.id)??"Typing user",avatarImage:(g==null?void 0:g.image)??(c==null?void 0:c.image),testId:"typing-indicator"})},$t=({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(de,{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($e,{cx:"4",index:0}),t.jsx($e,{cx:"16",index:1}),t.jsx($e,{cx:"28",index:2})]})})})})})})]})});function Ar(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 ks=()=>null,Rr=({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})]}),Me=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(Rr,{className:"w-6 h-6"}),t.jsx("span",{className:"text-sm text-stone",children:"Loading messages"})]})}));Me.displayName="LoadingState";const Lr=({onBack:e,showBackButton:s,renderMessageInputActions:n,renderMessageInputFooter:a,renderConversationFooter:r,onLeaveConversation:i,onBlockParticipant:l,showDeleteConversation:o=!0,onDeleteConversationClick:d,onBlockParticipantClick:h,onReportParticipantClick:f,showBlockParticipant:u=!0,showReportParticipant:g=!0,composerDisabled:c=!1,composerDisabledReason:v,showStarButton:j=!1,chatbotVotingEnabled:p=!1,renderChannelBanner:x,customChannelActions:b,renderChannelActions:_,renderMessage:S,viewerLanguage:R,showChannelInfo:M=!0,onParticipantNameClick:z,onBroadcastClick:O,resolveBroadcastName:$,composerInput:D})=>{const{channel:k,messages:P}=w.useChannelStateContext(),E=m.useRef(O);m.useEffect(()=>{E.current=O},[O]);const A=m.useCallback(H=>{var y;(y=E.current)==null||y.call(E,H)},[]),I=O?A:void 0,B=va(P,$),F=k.state.messages.some(H=>H.type!=="deleted"),U=x?t.jsx(m.Fragment,{children:x()},"lt-channel-banner"):null,q=t.jsx(Ws,{className:"-mx-[var(--str-chat\\_\\_spacing-2)] px-[var(--str-chat\\_\\_spacing-2)] md:-mx-[min(var(--str-chat\\_\\_spacing-10),4%)] md:px-[min(var(--str-chat\\_\\_spacing-10),4%)]",onBack:e,showBackButton:s,showChannelInfo:M,showStarButton:j,onLeaveConversation:i,onBlockParticipant:l,showDeleteConversation:o,showBlockParticipant:u,showReportParticipant:g,onDeleteConversationClick:d,onBlockParticipantClick:h,onReportParticipantClick:f,customChannelActions:b,renderChannelActions:_,onParticipantNameClick:z}),Q=m.useCallback(H=>{const{message:y}=w.useMessageContext("ChannelView"),T=t.jsx(mr,{...H,chatbotVotingEnabled:p,viewerLanguage:R,onBroadcastClick:I});return!S||!y?T:S(T,y)},[p,I,S,R]);return t.jsx(xs.Provider,{value:B,children:t.jsx(w.WithComponents,{overrides:{Message:Q,MessageActions:gr,UnreadMessagesNotification:()=>null,UnreadMessagesSeparator:()=>null},children:t.jsx(w.Window,{children:D?t.jsxs("div",{className:"messaging-channel-layout relative flex min-h-0 flex-1 flex-col",children:[t.jsxs("div",{className:"messaging-channel-message-list messaging-channel-message-list--floating relative min-h-0 flex-1 overflow-hidden",children:[!F&&t.jsx("div",{className:"str-chat__list",children:t.jsxs("div",{className:"str-chat__message-list-scroll",children:[q,U]})}),t.jsx(w.MessageList,{head:F?t.jsxs("div",{className:"sticky top-0 z-10",children:[q,U]}):void 0,hideDeletedMessages:!0,hideNewMessageSeparator:!1})]},"lt-channel-message-list"),t.jsx(Bt,{...n&&{renderActions:()=>n==null?void 0:n(k)},...r&&{renderHeader:()=>r(k)},renderFooter:()=>a==null?void 0:a(k),disabled:c,disabledReason:v,composerInput:D},"lt-channel-message-input")]}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex-1 overflow-hidden relative",children:[!F&&t.jsx("div",{className:"str-chat__list",children:t.jsxs("div",{className:"str-chat__message-list-scroll",children:[q,U]})}),t.jsx(w.MessageList,{head:F?t.jsxs("div",{className:"sticky top-0 z-10",children:[q,U]}):void 0,hideDeletedMessages:!0,hideNewMessageSeparator:!1})]},"lt-channel-message-list"),r?t.jsx(m.Fragment,{children:r(k)},"lt-channel-conversation-footer"):null,t.jsx(Bt,{...n&&{renderActions:()=>n==null?void 0:n(k)},renderFooter:()=>a==null?void 0:a(k),disabled:c,disabledReason:v,composerInput:D},"lt-channel-message-input")]})})})})},mt=m.memo(({channel:e,onBack:s,showBackButton:n=!1,renderMessageInputActions:a,renderMessageInputFooter:r,renderConversationFooter:i,onLeaveConversation:l,onBlockParticipant:o,className:d,CustomChannelEmptyState:h=ks,showDeleteConversation:f=!0,onDeleteConversationClick:u,onBlockParticipantClick:g,onReportParticipantClick:c,showBlockParticipant:v=!0,showReportParticipant:j=!0,composerDisabled:p=!1,composerDisabledReason:x,dmAgentEnabled:b,messageMetadata:_,onMessageSent:S,showStarButton:R=!1,chatbotVotingEnabled:M=!1,renderChannelBanner:z,customChannelActions:O,renderChannelActions:$,renderMessage:D,onMessageLinkClick:k,sendButton:P,attachmentPreviewList:E,viewerLanguage:A,showChannelInfo:I=!0,onParticipantNameClick:B,onBroadcastClick:F,resolveBroadcastName:U,composerInput:q})=>{const Q=m.useCallback(async(y,T,G)=>{var Z;const K=((Z=e.data)==null?void 0:Z.chatbot_paused)===!0,Y=b&&!K,ee={...T,...Y&&{silent:!0},..._&&{metadata:{...T.metadata??{},..._}}},W={...G,...Y&&{skip_push:!0}},V=await e.sendMessage(ee,W);return S==null||S(V),V},[e,b,_,S]),H=m.useRef(null);return m.useEffect(()=>{if(!k)return;const y=H.current;if(!y)return;const T=G=>{const K=G.target,Y=K==null?void 0:K.closest("a[href]"),ee=Y==null?void 0:Y.getAttribute("href");if(!ee)return;const W=Y==null?void 0:Y.closest("[data-message-id]"),V=W==null?void 0:W.getAttribute("data-message-id"),Z=V?e.state.messages.find(ne=>ne.id===V):void 0;k(ee,Z)};return y.addEventListener("click",T),()=>y.removeEventListener("click",T)},[k,e]),t.jsx("div",{ref:H,className:C("messaging-channel-view h-full flex flex-col",d),children:t.jsx(Ss.Provider,{value:b??!1,children:t.jsx(w.Channel,{channel:e,MessageSystem:Ir,EmptyStateIndicator:h,LoadingIndicator:Me,DateSeparator:Xs,TypingIndicator:Mr,doSendMessageRequest:Q,...P?{SendButton:P}:{},...E?{AttachmentPreviewList:E}:{},children:t.jsx(Lr,{onBack:s,showBackButton:n,renderMessageInputActions:a,renderMessageInputFooter:r,renderConversationFooter:i,onLeaveConversation:l,onBlockParticipant:o,CustomChannelEmptyState:h,showDeleteConversation:f,onDeleteConversationClick:u,onBlockParticipantClick:g,onReportParticipantClick:c,showBlockParticipant:v,showReportParticipant:j,composerDisabled:p,composerDisabledReason:x,showStarButton:R,chatbotVotingEnabled:M,renderChannelBanner:z,customChannelActions:O,renderChannelActions:$,renderMessage:D,viewerLanguage:A,showChannelInfo:I,onParticipantNameClick:B,onBroadcastClick:F,resolveBroadcastName:U,composerInput:q})})})})});mt.displayName="ChannelView";const pe=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"})]})}));pe.displayName="ErrorState";const Dr=({capabilities:e={},renderMessageInputActions:s,renderConversationFooter:n,onChannelSelect:a,onExitConversation:r,initialParticipantFilter:i,initialParticipantData:l,CustomChannelEmptyState:o,onBlockParticipantClick:d,onReportParticipantClick:h,dmAgentEnabled:f,onMessageSent:u,chatbotVotingEnabled:g=!1,viewerLanguage:c,renderChannelBanner:v,customChannelActions:j,renderChannelActions:p,onParticipantNameClick:x,onBroadcastClick:b,resolveBroadcastName:_,renderMessage:S,onMessageLinkClick:R,showChannelInfo:M,composerInput:z})=>{const{client:O,isConnected:$,isLoading:D,error:k,refreshConnection:P,service:E,debug:A}=Ht(),[I,B]=m.useState(null),[F,U]=m.useState(null),[q,Q]=m.useState(!1),{showDeleteConversation:H=!0}=e,y=m.useRef(l);y.current=l;const T=m.useRef(a);T.current=a;const G=m.useRef(null),K=m.useRef(null);m.useEffect(()=>{K.current=I},[I]),m.useEffect(()=>{if(!O||!$)return;const W=O.userID;if(!W)return;const V=`${W}::${i}`;if(G.current===V)return;G.current=V;const Z=()=>{G.current===V&&(G.current=null)};(async()=>{var ye,Ne;try{A&&console.log("[MessagingShell] Loading initial conversation with:",i);const ae=await O.queryChannels({type:"messaging",members:{$eq:[W,i]}},{},{limit:1});if(ae.length>0){B(ae[0]),U(null),(ye=T.current)==null||ye.call(T,ae[0]),A&&console.log("[MessagingShell] Initial conversation loaded:",ae[0].id);return}const oe=y.current;if(!oe||!E){Z(),U("No conversation found with this account"),A&&console.log("[MessagingShell] No conversation found for:",i);return}try{const re=await E.startChannelWithParticipant({id:oe.id,name:oe.name,phone:oe.phone});B(re),U(null),(Ne=T.current)==null||Ne.call(T,re),A&&console.log("[MessagingShell] Channel created and loaded:",re.id)}catch(re){console.error("[MessagingShell] Failed to create conversation:",re),Z(),U("Failed to create conversation")}}catch(ae){console.error("[MessagingShell] Failed to load initial conversation:",ae),Z(),K.current||U("Failed to load conversation")}})()},[i,O,$,E,A]);const Y=m.useRef(r);Y.current=r;const ee=m.useCallback(()=>{var W;B(null),Q(!0),(W=Y.current)==null||W.call(Y)},[]);return D?t.jsx(Me,{}):k?t.jsx(pe,{message:k,onBack:P}):!$||!O?t.jsx(pe,{message:"Not connected to messaging service",onBack:P}):F?t.jsx(pe,{message:F}):q&&!I?t.jsx(pe,{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(mt,{channel:I,renderMessageInputActions:s,renderConversationFooter:n,renderChannelBanner:v,onLeaveConversation:ee,onBlockParticipant:ee,CustomChannelEmptyState:o,showDeleteConversation:H,onBlockParticipantClick:d,onReportParticipantClick:h,dmAgentEnabled:f,onMessageSent:u,chatbotVotingEnabled:g,viewerLanguage:c,customChannelActions:j,renderChannelActions:p,onParticipantNameClick:x,onBroadcastClick:b,resolveBroadcastName:_,renderMessage:S,onMessageLinkClick:R,showChannelInfo:M,composerInput:z},I.id)})}):t.jsx(Me,{})};function Pr(e){const s=e.state.pending_messages;if(s!=null&&s.length)for(const n of s)e.state.addMessageSorted(n.message)}const Es=m.createContext({selectedChannel:void 0,onChannelSelect:()=>{},debug:!1,renderMessagePreview:void 0,channelPreview:void 0,viewerLanguage:void 0}),Or=Es.Provider,Fr=()=>m.useContext(Es),zr=(e,s)=>{const n=Date.UTC(e.getFullYear(),e.getMonth(),e.getDate()),a=Date.UTC(s.getFullYear(),s.getMonth(),s.getDate());return Math.floor((a-n)/(1e3*60*60*24))},Is=e=>{const s=new Date;if(Math.floor((s.getTime()-e.getTime())/1e3)<60)return"Just now";const a=zr(e,s);return a===0?e.toLocaleTimeString([],{hour:"numeric",minute:"2-digit",hour12:!0}):a===1?"Yesterday":a<7?e.toLocaleDateString(void 0,{weekday:"short"}):e.getFullYear()===s.getFullYear()?e.toLocaleDateString(void 0,{month:"short",day:"numeric"}):e.toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"})},Ts=m.memo(e=>{var O,$,D;const{channel:s,unread:n}=e,{selectedChannel:a,onChannelSelect:r,debug:i,channelPreview:l,renderMessagePreview:o,viewerLanguage:d}=Fr(),{client:h}=w.useChatContext(),f=(a==null?void 0:a.id)===(s==null?void 0:s.id),u=Gt(s);if(l){const k=l;return t.jsx(k,{...e,active:f,selectedChannel:a,onChannelSelect:r,viewerLanguage:d})}const g=()=>{s&&r(s)},c=k=>{const P=k.key==="Enter"||k.key===" ",E=k.repeat;!P||E||(k.preventDefault(),g())},v=Ye((O=s==null?void 0:s.state)==null?void 0:O.members,h==null?void 0:h.userID,s==null?void 0:s.type),j=qe(v==null?void 0:v.user),p=($=v==null?void 0:v.user)==null?void 0:$.image,x=(()=>{var P;const k=(P=s==null?void 0:s.state)==null?void 0:P.messages;if(k!=null&&k.length){for(let E=k.length-1;E>=0;E--)if(k[E].type!=="system")return k[E]}})(),_=(()=>{var I;const k=We({message:x,viewerLanguage:d}),{custom_type:P,attachment_content_type:E}=(x==null?void 0:x.metadata)||{};if(P===X.MESSAGE_CUSTOM_TYPE.TIP)return k||"Sent a tip";if(P===X.MESSAGE_CUSTOM_TYPE.PAID)return k||"Sent a message";if(P===X.MESSAGE_CUSTOM_TYPE.ATTACHMENT){if(E==="text")return"🔒 Sent a locked message";if(E==="media")return"🔒 Sent a locked attachment"}if(k)return k;const A=(I=x==null?void 0:x.attachments)==null?void 0:I[0];return A?A.og_scrape_url?A.og_scrape_url:A.type==="image"?"📷 Sent an image":A.type==="video"?"🎥 Sent a video":A.type==="audio"?"🎵 Sent audio":A.type==="file"?"📎 Sent a file":"📎 Sent an attachment":"No messages yet"})(),S=x!=null&&x.created_at?Is(new Date(x.created_at)):"",R=x?Se(x):!1,M=o?o(x,_):`${R?"✨ ":""}${_}`,z=n??0;return i&&console.log("📺 [ChannelList] 📋 CHANNEL PREVIEW RENDER",{channelId:s==null?void 0:s.id,isSelected:f,participantName:j,unreadCount:z,hasTimestamp:!!S}),t.jsx("div",{role:"button",tabIndex:0,onClick:g,onKeyDown:c,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]":f,"hover:bg-black/[0.02]":!f}),"data-dd-privacy":"mask",children:t.jsxs("div",{className:"flex items-start gap-4",children:[t.jsx(de,{id:((D=v==null?void 0:v.user)==null?void 0:D.id)||s.id||"unknown",name:j,image:p,size:48,starred:u}),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:[u&&t.jsx("span",{className:"sr-only",children:"Starred conversation. "}),j]}),S&&t.jsx("span",{className:"text-xs text-[#717070] flex-shrink-0",children:S})]}),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:M}),z>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:z>99?"99+":z})]})]})]})})});Ts.displayName="CustomChannelPreview";const Br={last_message_at:-1},Ms=m.memo(({onChannelSelect:e,selectedChannel:s,filters:n,allowNewMessagesFromUnfilteredChannels:a=!1,channelRenderFilterFn:r,sort:i=Br,className:l,customEmptyStateIndicator:o,channelListPaginator:d=w.InfiniteScroll,channelPreview:h,renderMessagePreview:f,viewerLanguage:u,lockChannelOrder:g,onMessageNewHandler:c,onMessageNew:v,onChannelVisible:j,onAddedToChannel:p,onChannelUpdated:x})=>{const b=m.useRef(0);b.current++;const{debug:_=!1}=Ge(),S=m.useCallback(M=>{for(const z of M)Pr(z);return r?r(M):M},[r]);_&&console.log("📺 [ChannelList] 🔄 RENDER START",{renderCount:b.current,selectedChannelId:s==null?void 0:s.id,filters:n});const R=m.useMemo(()=>({selectedChannel:s,onChannelSelect:e,debug:_,channelPreview:h,renderMessagePreview:f,viewerLanguage:u}),[s,e,_,h,f,u]);return t.jsx("div",{className:C("messaging-channel-list h-full flex flex-col min-w-0 overflow-hidden",l),children:t.jsx("div",{className:"flex-1 overflow-hidden min-w-0",children:t.jsx(Or,{value:R,children:t.jsx(w.ChannelList,{filters:n,sort:i,options:{limit:30},allowNewMessagesFromUnfilteredChannels:a,channelRenderFilterFn:S,lockChannelOrder:g,onMessageNewHandler:c,onMessageNew:v,onChannelVisible:j,onAddedToChannel:p,onChannelUpdated:x,Paginator:d,Preview:Ts,EmptyStateIndicator:o},`${JSON.stringify(n)}:${JSON.stringify(i)}`)})})})});Ms.displayName="ChannelList";const Ut=`url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='23' fill='none'%3E%3Cpath fill='black' d='M0 0H15C15 10.1934 15.859 15.2345 19.168 21.4893C19.527 22.168 19.039 22.9917 18.274 22.9178C5.176 21.6506 0.32 6.0737 0 0Z'/%3E%3C/svg%3E") no-repeat center / 100% 100%`,$r={sent:"var(--str-chat__own-message-bubble-background-color, #1e2330)",received:"var(--str-chat__message-bubble-background-color, #f1f0ee)"},Ur=({variant:e})=>t.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute bottom-0 z-[-1] h-[1.4375rem] w-5",style:{insetInlineEnd:e==="sent"?"calc(-1 * 0.25rem)":void 0,insetInlineStart:e==="received"?"calc(-1 * 0.25rem)":void 0,transform:e==="received"?"scaleX(-1)":void 0,transformOrigin:"center",backgroundColor:$r[e],WebkitMask:Ut,mask:Ut}}),Vr={sent:{backgroundColor:"var(--str-chat__own-message-bubble-background-color, #1e2330)",color:"var(--str-chat__own-message-bubble-color, #fff)"},received:{backgroundColor:"var(--str-chat__message-bubble-background-color, #f1f0ee)",color:"var(--str-chat__message-bubble-color, #000000)"}},As=({variant:e,text:s,tail:n=!0,header:a,className:r})=>t.jsxs("div",{"data-dd-privacy":"mask",className:C("relative px-4 py-3","text-[0.875rem] leading-[1.3125rem] tracking-[0.14px]",r),style:{...Vr[e],borderRadius:"var(--str-chat__message-bubble-border-radius, 1.5rem)",isolation:"isolate"},children:[a!=null&&t.jsx("div",{className:"mb-1 font-medium","data-testid":"message-bubble-header",children:a}),t.jsx("p",{className:"m-0 whitespace-pre-wrap break-words",children:s}),n&&t.jsx(Ur,{variant:e})]}),Hr=({text:e,tail:s,header:n,className:a})=>t.jsx(As,{variant:"received",text:e,tail:s,header:n,className:a}),Gr=({text:e,tail:s,className:n})=>t.jsx(As,{variant:"sent",text:e,tail:s,className:n}),Yr={Sent:Gr,Received:Hr},Rs=({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}),qr=({faqs:e,onFaqClick:s,loadingFaqId:n,headerText:a,className:r,avatarImage:i,avatarName:l})=>{const o=X.selectEnabledFaqs(e);return o.length===0?null:t.jsx("div",{className:r,children:t.jsxs("div",{className:"flex gap-3 items-end",children:[(i||l)&&t.jsx("div",{className:"flex-none",children:t.jsx(de,{id:l||"account",name:l||"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}),o.map(d=>t.jsx(Rs,{question:d.question,onClick:()=>s(d.id),loading:n===d.id},d.id))]})]})})};exports.ActionButton=fe;exports.AttachmentThumbnail=Xe;exports.Avatar=de;exports.ChannelEmptyState=ks;exports.ChannelList=Ms;exports.ChannelView=mt;exports.CustomMessageProvider=wa;exports.FaqList=qr;exports.FaqListItem=Rs;exports.LinkAttachment=Ie;exports.LockedAttachment=xe;exports.MediaMessage=bn;exports.MessageAttachment=ge;exports.MessageBubble=Yr;exports.MessageVoteButtons=_s;exports.MessagingProvider=Fs;exports.MessagingShell=Dr;exports.bubbleGroupPositionFromStream=ts;exports.buildCompactMetaLabel=as;exports.formatFileSize=ss;exports.formatRelativeTime=Is;exports.getFileExtensionLabel=ns;exports.getMessageDisplayText=We;exports.getSourceType=se;exports.isLinkAttachment=Je;exports.isUuidLike=Yt;exports.normalizeLanguageCode=Xt;exports.optimizeMessagingAttachmentUrl=ie;exports.renderTypeIcon=ce;exports.resolveConversationParticipant=Ye;exports.resolveLinkAttachment=Ae;exports.resolveMediaFromMessage=Re;exports.resolveParticipantDisplayName=qe;exports.useComposerLocked=vr;exports.useCustomMessage=bs;exports.useMessageVote=Wt;exports.useMessaging=Ht;
|
|
2
|
-
//# sourceMappingURL=index-DWddHoFx.cjs.map
|