@linktr.ee/messaging-react 3.5.0-rc-1782792813 → 3.5.0-rc-1782793221
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-BnGeMt4f.js → Card-49AvU29H.js} +2 -2
- package/dist/{Card-BnGeMt4f.js.map → Card-49AvU29H.js.map} +1 -1
- package/dist/{Card-DpCwDviq.cjs → Card-Cse19FAO.cjs} +2 -2
- package/dist/{Card-DpCwDviq.cjs.map → Card-Cse19FAO.cjs.map} +1 -1
- package/dist/{Card-qrDaFHtJ.cjs → Card-DBIVUdM5.cjs} +2 -2
- package/dist/{Card-qrDaFHtJ.cjs.map → Card-DBIVUdM5.cjs.map} +1 -1
- package/dist/{Card-BWWBaNKF.js → Card-DS8zNUkL.js} +2 -2
- package/dist/{Card-BWWBaNKF.js.map → Card-DS8zNUkL.js.map} +1 -1
- package/dist/{Card-Bj4YaHav.cjs → Card-DgPx-6aq.cjs} +2 -2
- package/dist/{Card-Bj4YaHav.cjs.map → Card-DgPx-6aq.cjs.map} +1 -1
- package/dist/{Card-DkXzpFLA.js → Card-q0zqEbga.js} +3 -3
- package/dist/{Card-DkXzpFLA.js.map → Card-q0zqEbga.js.map} +1 -1
- package/dist/{LockedThumbnail-DhXEk-NX.cjs → LockedThumbnail-BFgw9F0g.cjs} +2 -2
- package/dist/{LockedThumbnail-DhXEk-NX.cjs.map → LockedThumbnail-BFgw9F0g.cjs.map} +1 -1
- package/dist/{LockedThumbnail-DJR--PAi.js → LockedThumbnail-CRBDhB49.js} +2 -2
- package/dist/{LockedThumbnail-DJR--PAi.js.map → LockedThumbnail-CRBDhB49.js.map} +1 -1
- package/dist/index-BcmwckcI.cjs +2 -0
- package/dist/index-BcmwckcI.cjs.map +1 -0
- package/dist/{index-ubCRSgQk.js → index-DxzkXLSW.js} +1150 -1172
- package/dist/index-DxzkXLSW.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +0 -12
- package/dist/index.js +1 -1
- package/package.json +2 -2
- package/src/components/ChannelList/ChannelList.stories.tsx +37 -0
- package/src/components/ChannelList/CustomChannelPreview.stories.tsx +0 -110
- package/src/components/ChannelList/CustomChannelPreview.test.tsx +8 -58
- package/src/components/ChannelList/CustomChannelPreview.tsx +12 -7
- package/src/components/ChannelView.stories.tsx +7 -38
- package/src/components/ChannelView.test.tsx +27 -44
- package/src/components/ChannelView.tsx +6 -4
- package/src/hooks/useChannelStar.ts +6 -9
- package/src/stream-custom-data.ts +1 -16
- package/dist/index-DzOA7Yu8.cjs +0 -2
- package/dist/index-DzOA7Yu8.cjs.map +0 -1
- package/dist/index-ubCRSgQk.js.map +0 -1
- package/src/components/ParticipantBadges.tsx +0 -42
|
@@ -32,7 +32,6 @@ import CustomTypingIndicator from './CustomTypingIndicator'
|
|
|
32
32
|
import { DmAgentEnabledContext } from './CustomTypingIndicator/DmAgentContext'
|
|
33
33
|
import { ChannelEmptyState } from './MessagingShell/ChannelEmptyState'
|
|
34
34
|
import { LoadingState } from './MessagingShell/LoadingState'
|
|
35
|
-
import { ParticipantBadges } from './ParticipantBadges'
|
|
36
35
|
|
|
37
36
|
const ICON_BTN_CLASS =
|
|
38
37
|
'size-10 rounded-full hover:bg-[#E5E4E1] flex items-center justify-center transition-colors duration-150 focus-ring'
|
|
@@ -105,7 +104,6 @@ const CustomChannelHeader: React.FC<{
|
|
|
105
104
|
const participantTitle = (
|
|
106
105
|
<>
|
|
107
106
|
<span className="min-w-0 truncate">{participantName}</span>
|
|
108
|
-
<ParticipantBadges channel={channel} participant={participant} />
|
|
109
107
|
{headerTitleBadges && (
|
|
110
108
|
<span className="shrink-0">{headerTitleBadges}</span>
|
|
111
109
|
)}
|
|
@@ -163,6 +161,7 @@ const CustomChannelHeader: React.FC<{
|
|
|
163
161
|
id={participant?.user?.id || channel.id || 'unknown'}
|
|
164
162
|
name={participantName}
|
|
165
163
|
image={participantImage}
|
|
164
|
+
starred={showStarButton && isStarred}
|
|
166
165
|
dmAgentEnabled={dmAgentEnabled}
|
|
167
166
|
size={48}
|
|
168
167
|
/>
|
|
@@ -183,6 +182,7 @@ const CustomChannelHeader: React.FC<{
|
|
|
183
182
|
id={participant?.user?.id || channel.id || 'unknown'}
|
|
184
183
|
name={participantName}
|
|
185
184
|
image={participantImage}
|
|
185
|
+
starred={showStarButton && isStarred}
|
|
186
186
|
dmAgentEnabled={dmAgentEnabled}
|
|
187
187
|
size={48}
|
|
188
188
|
/>
|
|
@@ -271,6 +271,7 @@ const CustomChannelHeader: React.FC<{
|
|
|
271
271
|
id={participant?.user?.id || channel.id || 'unknown'}
|
|
272
272
|
name={participantName}
|
|
273
273
|
image={participantImage}
|
|
274
|
+
starred={showStarButton && isStarred}
|
|
274
275
|
dmAgentEnabled={dmAgentEnabled}
|
|
275
276
|
size={48}
|
|
276
277
|
/>
|
|
@@ -295,6 +296,7 @@ const CustomChannelHeader: React.FC<{
|
|
|
295
296
|
id={participant?.user?.id || channel.id || 'unknown'}
|
|
296
297
|
name={participantName}
|
|
297
298
|
image={participantImage}
|
|
299
|
+
starred={showStarButton && isStarred}
|
|
298
300
|
dmAgentEnabled={dmAgentEnabled}
|
|
299
301
|
size={48}
|
|
300
302
|
/>
|
|
@@ -446,10 +448,10 @@ const ChannelViewInner: React.FC<{
|
|
|
446
448
|
}, [channel._client?.userID, channel.state?.members])
|
|
447
449
|
|
|
448
450
|
const currentUserIsAccount =
|
|
449
|
-
currentMember?.user?.is_account ??
|
|
451
|
+
(currentMember?.user as { is_account?: boolean } | undefined)?.is_account ??
|
|
450
452
|
(currentMember as { is_account?: boolean } | undefined)?.is_account
|
|
451
453
|
const participantIsAccount =
|
|
452
|
-
participant?.user?.is_account ??
|
|
454
|
+
(participant?.user as { is_account?: boolean } | undefined)?.is_account ??
|
|
453
455
|
(participant as { is_account?: boolean } | undefined)?.is_account
|
|
454
456
|
|
|
455
457
|
const showDmAgentHeader =
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useEffect, useState } from 'react'
|
|
2
|
-
import
|
|
2
|
+
import { Channel, Event } from 'stream-chat'
|
|
3
3
|
|
|
4
4
|
export const useChannelStar = (channel?: Channel) => {
|
|
5
5
|
const [isChannelStarred, setIsChannelStarred] = useState(
|
|
@@ -15,18 +15,15 @@ export const useChannelStar = (channel?: Channel) => {
|
|
|
15
15
|
setIsChannelStarred(!!channel.state.membership?.pinned_at)
|
|
16
16
|
|
|
17
17
|
const handleMemberUpdate = (event: Event) => {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
if (!currentUserId || memberUserId !== currentUserId) return
|
|
22
|
-
|
|
23
|
-
setIsChannelStarred(!!event.member?.pinned_at)
|
|
18
|
+
setIsChannelStarred(
|
|
19
|
+
event?.member ? !!event.member.pinned_at : !!channel.state.membership?.pinned_at
|
|
20
|
+
)
|
|
24
21
|
}
|
|
25
22
|
|
|
26
|
-
|
|
23
|
+
channel.on('member.updated', handleMemberUpdate)
|
|
27
24
|
|
|
28
25
|
return () => {
|
|
29
|
-
|
|
26
|
+
channel.off('member.updated', handleMemberUpdate)
|
|
30
27
|
}
|
|
31
28
|
}, [channel])
|
|
32
29
|
|
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
* Stream Chat custom data type augmentation.
|
|
3
3
|
*
|
|
4
4
|
* This file extends Stream Chat's type system by augmenting their empty
|
|
5
|
-
* CustomMessageData
|
|
6
|
-
* interfaces with our custom properties.
|
|
5
|
+
* CustomMessageData and CustomChannelData interfaces with our custom properties.
|
|
7
6
|
*
|
|
8
7
|
* @see https://getstream.io/chat/docs/sdk/react/guides/typescript_and_custom_data_types/
|
|
9
8
|
*
|
|
@@ -99,14 +98,6 @@ declare module 'stream-chat' {
|
|
|
99
98
|
chatbot_paused?: boolean
|
|
100
99
|
}
|
|
101
100
|
|
|
102
|
-
interface CustomMemberData {
|
|
103
|
-
/**
|
|
104
|
-
* Whether the member should be identified as a customer in participant UI.
|
|
105
|
-
* Stored on the channel member so it is scoped to this conversation.
|
|
106
|
-
*/
|
|
107
|
-
customer?: boolean
|
|
108
|
-
}
|
|
109
|
-
|
|
110
101
|
interface CustomMessageData {
|
|
111
102
|
/**
|
|
112
103
|
* When true, hides the date timestamp in system messages.
|
|
@@ -124,10 +115,4 @@ declare module 'stream-chat' {
|
|
|
124
115
|
*/
|
|
125
116
|
dm_agent_system_type?: DmAgentSystemType
|
|
126
117
|
}
|
|
127
|
-
|
|
128
|
-
interface CustomUserData {
|
|
129
|
-
is_account?: boolean
|
|
130
|
-
is_follower?: boolean
|
|
131
|
-
username?: string
|
|
132
|
-
}
|
|
133
118
|
}
|
package/dist/index-DzOA7Yu8.cjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";const e=require("react/jsx-runtime"),m=require("react"),ms=require("@linktr.ee/messaging-core"),Te=require("stream-chat"),_=require("stream-chat-react"),w=require("@phosphor-icons/react"),C=require("classnames"),Le=require("stream-chat-react/experimental"),kt=m.createContext({service:null,client:null,isConnected:!1,isLoading:!1,error:null,capabilities:{},refreshConnection:async()=>{},debug:!1}),De=()=>m.useContext(kt),hs=({children:t,user:s,serviceConfig:n,apiKey:a,capabilities:r={},debug:i=!1})=>{var A,T;const o=m.useCallback((k,...M)=>{i&&console.log(`🔥 [MessagingProvider] ${k}`,...M)},[i]);o("🔄 RENDER START",{userId:s==null?void 0:s.id,apiKey:(a==null?void 0:a.substring(0,8))+"...",serviceConfig:!!n,capabilities:Object.keys(r)});const[l,d]=m.useState(null),[h,f]=m.useState(null),[u,x]=m.useState(!1),[c,g]=m.useState(!1),[N,j]=m.useState(null),p=m.useRef(!1),b=m.useRef(null),R=m.useRef(n);R.current=n;const I=m.useRef(i);I.current=i;const E=m.useRef({userId:s==null?void 0:s.id,apiKey:a,serviceConfig:n,capabilities:r}),O=m.useRef(0);O.current++,o("📊 RENDER INFO",{renderCount:O.current,currentProps:{userId:s==null?void 0:s.id,apiKey:(a==null?void 0:a.substring(0,8))+"..."},propChanges:{userChanged:E.current.userId!==(s==null?void 0:s.id),apiKeyChanged:E.current.apiKey!==a,serviceConfigChanged:E.current.serviceConfig!==n,capabilitiesChanged:E.current.capabilities!==r}}),E.current={userId:s==null?void 0:s.id,apiKey:a,serviceConfig:n,capabilities:r};const D=m.useRef(null);a&&((A=D.current)==null?void 0:A.apiKey)!==a&&(D.current={apiKey:a,client:new Te.StreamChat(a)});const y=a?((T=D.current)==null?void 0:T.client)??null:null;m.useEffect(()=>{const k=O.current,M=R.current;if(!a||!y||!M){o("⚠️ SERVICE INIT SKIPPED",{renderCount:k,reason:"Missing apiKey, client, or serviceConfig"});return}o("🚀 CREATING SERVICE",{renderCount:k,apiKey:(a==null?void 0:a.substring(0,8))+"..."});const F=new ms.StreamChatService({...M,apiKey:a,debug:I.current,client:y});b.current=F,d(F),o("✅ SERVICE SET",{renderCount:k,serviceInstance:!!F})},[a,y]);const z=m.useRef(null);m.useEffect(()=>{var M,F;if(o("🔗 USER CONNECTION EFFECT TRIGGERED",{hasService:!!l,hasUser:!!s,userId:s==null?void 0:s.id,isConnecting:p.current,isConnected:u,dependencies:{service:!!l,userId:s==null?void 0:s.id}}),!l||!s){o("⚠️ USER CONNECTION SKIPPED","Missing service or user");return}if(p.current){o("⚠️ USER CONNECTION SKIPPED","Already connecting");return}if(((M=z.current)==null?void 0:M.serviceId)===l&&((F=z.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}),p.current=!0,g(!0),j(null);try{o("📞 CALLING SERVICE.CONNECTUSER",{userId:s.id});const $=await l.connectUser(s);f($),x(!0),z.current={serviceId:l,userId:s.id},o("✅ USER CONNECTION SUCCESS",{userId:s.id,clientId:$.userID})}catch($){const V=$ instanceof Error?$.message:"Connection failed";j(V),o("❌ USER CONNECTION ERROR",{userId:s.id,error:V})}finally{g(!1),p.current=!1,o("🔄 USER CONNECTION FINISHED",{userId:s.id,isConnected:u})}})()},[l,s,o,u]),m.useEffect(()=>{const k=y;return()=>{var M;k&&(z.current=null,(M=b.current)==null||M.disconnectUser().catch(console.error))}},[y]);const L=m.useCallback(async()=>{if(o("🔄 REFRESH CONNECTION CALLED",{hasService:!!l,hasUser:!!s}),!l||!s){o("⚠️ REFRESH CONNECTION SKIPPED","Missing service or user");return}o("🚀 STARTING CONNECTION REFRESH",{userId:s.id}),g(!0);try{o("🔌 DISCONNECTING FOR REFRESH"),await l.disconnectUser(),o("📞 RECONNECTING FOR REFRESH");const k=await l.connectUser(s);f(k),x(!0),j(null),o("✅ CONNECTION REFRESH SUCCESS",{userId:s.id})}catch(k){const M=k instanceof Error?k.message:"Refresh failed";j(M),o("❌ CONNECTION REFRESH ERROR",{userId:s.id,error:M})}finally{g(!1),o("🔄 CONNECTION REFRESH FINISHED",{userId:s.id})}},[l,s,o]),P=m.useMemo(()=>(o("💫 CONTEXT VALUE MEMOIZATION",{hasService:!!l,hasClient:!!h,isConnected:u,isLoading:c,hasError:!!N,capabilitiesKeys:Object.keys(r)}),{service:l,client:h,isConnected:u,isLoading:c,error:N,capabilities:r,refreshConnection:L,debug:i}),[l,h,u,c,N,r,L,i,o]);return o("🔄 RENDER END",{renderCount:O.current,willRenderChat:!!y,contextValueReady:!!P}),e.jsx(kt.Provider,{value:P,children:y?e.jsx(_.Chat,{client:y,customClasses:{channelList:"str-chat__channel-list str-chat__channel-list-react bg-transparent lg:border-r-2 border-r-0 border-[#0000000A]"},children:t}):t})},St=()=>De(),It=t=>{var a,r;const[s,n]=m.useState(!!((r=(a=t==null?void 0:t.state)==null?void 0:a.membership)!=null&&r.pinned_at));return m.useEffect(()=>{var l;if(!t){n(!1);return}n(!!((l=t.state.membership)!=null&&l.pinned_at));const i=d=>{var u,x,c,g,N;const h=(u=t._client)==null?void 0:u.userID,f=((x=d.member)==null?void 0:x.user_id)??((g=(c=d.member)==null?void 0:c.user)==null?void 0:g.id);!h||f!==h||n(!!((N=d.member)!=null&&N.pinned_at))},o=t.on("member.updated",i);return()=>{o.unsubscribe()}},[t]),s},xs=/^[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 Et(t){return xs.test(t.trim())}function jt(t,s){const n=t==null?void 0:t.trim();return!n||s&&n===s?!1:!Et(n)}function Pe(t){return jt(t==null?void 0:t.name,t==null?void 0:t.id)?t.name.trim():jt(t==null?void 0:t.username,t==null?void 0:t.id)?t.username.trim():"Unknown member"}const wt=["🍎","🍌","🍇","🍊","🍓","🥥","🍒","🥭","🍉","🍋","🥝","🫒","🍈"];function fs(t){let s=0;for(let n=0;n<t.length;n++){const a=t.charCodeAt(n);s=(s<<5)-s+a,s=s&s}return Math.abs(s)}function gs(t){const n=fs(t)%wt.length;return wt[n]}const Q=({id:t,image:s,size:n=40,className:a,starred:r=!1,shape:i="squircle",dmAgentEnabled:o=!1})=>{const l=gs(t),h=n<32?"text-xs":n<56?"text-sm":n<120?"text-lg":"text-4xl",f=n>=40?2:1,u=i==="circle"?{borderRadius:"50%"}:{borderRadius:"1rem"},x=e.jsx("div",{className:"h-full w-full overflow-hidden",style:u,children:s?e.jsx("img",{src:s,alt:"",className:"h-full w-full object-cover"}):e.jsx("div",{"aria-hidden":"true",className:C("avatar-fallback flex h-full w-full items-center justify-center bg-[#E6E5E3] font-semibold select-none transition-colors",h),children:l})});return e.jsxs("div",{className:C("relative flex-shrink-0 !bg-transparent",a),style:{"--str-chat__avatar-size":`${n}px`,width:`${n}px`,height:`${n}px`},children:[r&&e.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:e.jsx(w.StarIcon,{className:"size-3 text-yellow-600",weight:"duotone"})}),e.jsx("div",{"data-testid":"avatar-ring",className:C("h-full w-full","bg-transparent"),style:{...u,...o&&{borderWidth:`${f}px`,borderStyle:"solid",borderColor:"var(--AI-Gradient, #7F22FE)",boxShadow:"inset 0 1px 2px 0 rgba(255, 255, 255, 0.5)"}},children:x})]})},bs="https://linktr.ee/s/about/trust-center/report",ps=({channel:t,participant:s,showBlockParticipant:n=!0,enabled:a=!0,onLeaveConversation:r,onBlockParticipant:i,onDeleteConversationClick:o,onBlockParticipantClick:l,onReportParticipantClick:d,onActionComplete:h,logLabel:f="useChannelModerationActions"})=>{var A;const{service:u,debug:x}=De(),c=(A=s==null?void 0:s.user)==null?void 0:A.id,g=!!(a&&n&&u&&c),[N,j]=m.useState(!1),[p,b]=m.useState(null),[R,I]=m.useState(!1),[E,O]=m.useState(!1),D=g&&((p==null?void 0:p.participantId)!==c||(p==null?void 0:p.service)!==u);return m.useEffect(()=>{if(!g||!u||!c){j(!1),b(null);return}let T=!1;return(async()=>{try{const k=await u.getBlockedUsers();if(T)return;j(k.some(M=>M.blocked_user_id===c))}catch(k){T||console.error(`[${f}] Failed to check blocked status:`,k)}finally{T||b({participantId:c,service:u})}})(),()=>{T=!0}},[g,u,c,f]),{isParticipantBlocked:N,isCheckingBlockedStatus:D,isLeaving:R,isUpdatingBlockStatus:E,handleLeaveConversation:async()=>{var T;if(!R){o==null||o(),x&&console.log(`[${f}] Leave conversation`,t.cid),I(!0);try{const k=((T=t._client)==null?void 0:T.userID)??null;await t.hide(k,!1),r&&await r(t),h==null||h()}catch(k){console.error(`[${f}] Failed to leave conversation`,k)}finally{I(!1)}}},handleBlockUser:async()=>{var T,k,M;if(!(E||!u)){l==null||l(),x&&console.log(`[${f}] Block member`,(T=s==null?void 0:s.user)==null?void 0:T.id),O(!0);try{await u.blockUser((k=s==null?void 0:s.user)==null?void 0:k.id),i&&await i((M=s==null?void 0:s.user)==null?void 0:M.id),h==null||h()}catch(F){console.error(`[${f}] Failed to block member`,F)}finally{O(!1)}}},handleUnblockUser:async()=>{var T,k,M;if(!(E||!u)){l==null||l(),x&&console.log(`[${f}] Unblock member`,(T=s==null?void 0:s.user)==null?void 0:T.id),O(!0);try{await u.unBlockUser((k=s==null?void 0:s.user)==null?void 0:k.id),i&&await i((M=s==null?void 0:s.user)==null?void 0:M.id),h==null||h()}catch(F){console.error(`[${f}] Failed to unblock member`,F)}finally{O(!1)}}},handleReportUser:()=>{d==null||d(),h==null||h(),window.open(bs,"_blank","noopener,noreferrer")}}},re=({variant:t="default",className:s,children:n,...a})=>{const r=t==="danger";return e.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})},Nt=({channel:t,participant:s,showDeleteConversation:n=!0,showBlockParticipant:a=!0,showReportParticipant:r=!0,onLeaveConversation:i,onBlockParticipant:o,onDeleteConversationClick:l,onBlockParticipantClick:d,onReportParticipantClick:h,customChannelActions:f,triggerClassName:u})=>{const[x,c]=m.useState(!1),g=m.useRef(null),N=m.useId(),j=m.useCallback(()=>c(!1),[]),{isParticipantBlocked:p,isCheckingBlockedStatus:b,isLeaving:R,isUpdatingBlockStatus:I,handleLeaveConversation:E,handleBlockUser:O,handleUnblockUser:D,handleReportUser:y}=ps({channel:t,participant:s,showBlockParticipant:a,enabled:x,onLeaveConversation:i,onBlockParticipant:o,onDeleteConversationClick:l,onBlockParticipantClick:d,onReportParticipantClick:h,onActionComplete:j,logLabel:"ChannelActionsMenu"});return m.useEffect(()=>{if(!x)return;const L=A=>{g.current&&!g.current.contains(A.target)&&c(!1)},P=A=>{A.key==="Escape"&&c(!1)};return document.addEventListener("mousedown",L),document.addEventListener("keydown",P),()=>{document.removeEventListener("mousedown",L),document.removeEventListener("keydown",P)}},[x]),!s||!(n||a||r||!!f)?null:e.jsxs("div",{ref:g,className:"relative",children:[e.jsxs("button",{className:u,type:"button","aria-haspopup":"true","aria-expanded":x,"aria-controls":x?N:void 0,onClick:()=>c(L=>!L),children:[e.jsx(w.DotsThreeIcon,{className:"size-5 text-black/90"}),e.jsx("span",{className:"sr-only",children:"More options"})]}),x&&e.jsx("div",{id:N,"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:e.jsxs("ul",{className:"flex flex-col gap-1",children:[n&&e.jsx("li",{children:e.jsxs(re,{onClick:E,disabled:R,"aria-busy":R,children:[R?e.jsx(w.SpinnerGapIcon,{className:"h-5 w-5 animate-spin"}):e.jsx(w.SignOutIcon,{className:"h-5 w-5"}),e.jsx("span",{children:"Delete Conversation"})]})}),a&&e.jsx("li",{children:b?e.jsxs(re,{disabled:!0,"aria-busy":!0,children:[e.jsx(w.SpinnerGapIcon,{className:"h-5 w-5 animate-spin"}),e.jsx("span",{children:"Block"})]}):p?e.jsxs(re,{onClick:D,disabled:I,"aria-busy":I,children:[I?e.jsx(w.SpinnerGapIcon,{className:"h-5 w-5 animate-spin"}):e.jsx(w.ProhibitInsetIcon,{className:"h-5 w-5"}),e.jsx("span",{children:"Unblock"})]}):e.jsxs(re,{onClick:O,disabled:I,"aria-busy":I,children:[I?e.jsx(w.SpinnerGapIcon,{className:"h-5 w-5 animate-spin"}):e.jsx(w.ProhibitInsetIcon,{className:"h-5 w-5"}),e.jsx("span",{children:"Block"})]})}),r&&e.jsx("li",{children:e.jsxs(re,{variant:"danger",onClick:y,children:[e.jsx(w.FlagIcon,{className:"h-5 w-5"}),e.jsx("span",{children:"Report"})]})}),f]})})]})},vs=t=>e.jsx(_.DateSeparator,{...t,position:"center"}),Me="vote_up",Re="vote_down";function js(t){return t!=null&&t.length?t.some(s=>s.type===Re)?"down":t.some(s=>s.type===Me)?"up":null:null}function Tt(t){const{channel:s}=_.useChannelStateContext(),{client:n}=_.useChatContext("useMessageVote"),a=m.useMemo(()=>js(t.own_reactions),[t.own_reactions]),r=m.useCallback(async()=>{if(n!=null&&n.userID)try{a==="up"?await s.deleteReaction(t.id,Me):await s.sendReaction(t.id,{type:Me},{enforce_unique:!0,skip_push:!0})}catch{}},[s,n==null?void 0:n.userID,t.id,a]),i=m.useCallback(async()=>{if(n!=null&&n.userID)try{a==="down"?await s.deleteReaction(t.id,Re):await s.sendReaction(t.id,{type:Re},{enforce_unique:!0,skip_push:!0})}catch{}},[s,n==null?void 0:n.userID,t.id,a]);return{selected:a,voteUp:r,voteDown:i}}function Mt(t){return(t==null?void 0:t.trim().toLowerCase().split(/[-_]/)[0])||void 0}function ze({message:t,viewerLanguage:s}){var r;const n=t==null?void 0:t.text,a=Mt(s);return a?((r=t==null?void 0:t.i18n)==null?void 0:r[`${a}_text`])??n:n}const ws=m.lazy(()=>Promise.resolve().then(()=>require("./Card-qrDaFHtJ.cjs"))),Ns=m.lazy(()=>Promise.resolve().then(()=>require("./Card-DpCwDviq.cjs"))),_s=m.lazy(()=>Promise.resolve().then(()=>require("./Card-Bj4YaHav.cjs"))),Oe=()=>e.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}),ys=t=>e.jsx(m.Suspense,{fallback:e.jsx(Oe,{}),children:e.jsx(ws,{...t})}),Rt=t=>e.jsx(m.Suspense,{fallback:e.jsx(Oe,{}),children:e.jsx(Ns,{...t})}),At=t=>e.jsx(m.Suspense,{fallback:e.jsx(Oe,{}),children:e.jsx(_s,{...t})}),Cs=Rt,ks=At,Ae={Composer:ys,Sent:Rt,Received:At,Creator:Cs,Visitor:ks},Ss=[[/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 te(t){return t.startsWith("video/")?"video":t.startsWith("audio/")?"audio":t.startsWith("image/")?"image":"document"}function Lt(t){const s=Ss.find(([n])=>n.test(t));return s?s[1]:"generic"}const Is={video:w.VideoCameraIcon,audio:w.SpeakerHighIcon,image:w.ImageIcon,document:w.FileIcon},Es={pdf:w.FilePdfIcon,doc:w.FileDocIcon,xls:w.FileXlsIcon,csv:w.FileCsvIcon,ppt:w.FilePptIcon,zip:w.FileZipIcon,text:w.FileTextIcon,markdown:w.FileMdIcon,generic:w.FileIcon};function Ts(t){const s=te(t);return s!=="document"?Is[s]:Es[Lt(t)]}function ne(t,s){return m.createElement(Ts(t),s)}const Ms=t=>{var s,n;return"touches"in t?((s=t.touches[0])==null?void 0:s.clientX)??((n=t.changedTouches[0])==null?void 0:n.clientX)??0:t.clientX},Rs=({source:t,mimeType:s,poster:n,autoPlay:a=!1,playing:r,loop:i=!1,controls:o=!0,showProgress:l=!1,muted:d=!1,onContainerClick:h})=>{const f=te(s),u=m.useRef(null),x=m.useRef(null),c=m.useRef(null),g=m.useRef(r),[N,j]=m.useState(a),[p,b]=m.useState(0),[R,I]=m.useState(!1),[E,O]=m.useState(!1),[D,y]=m.useState(!1),[z,L]=m.useState(!1),[P,A]=m.useState(!0),[T,k]=m.useState(null),M=m.useCallback(()=>{y(!1),j(!0)},[]),F=m.useCallback(v=>{const S=x.current;if(!S)return 0;const U=S.getBoundingClientRect();return Math.max(0,Math.min(1,(Ms(v)-U.left)/U.width))},[]),$=m.useCallback(v=>{const S=u.current;S&&S.duration&&(S.currentTime=v*S.duration)},[]),V=v=>{v.stopPropagation(),I(!0);const S=F(v);b(S),$(S)};m.useEffect(()=>{r!==void 0&&r!==g.current&&(g.current=r,j(r))},[r]),m.useEffect(()=>{if(!N){c.current!==null&&(cancelAnimationFrame(c.current),c.current=null);return}const v=()=>{const S=u.current;S&&S.duration&&!R&&b(S.currentTime/S.duration),c.current=requestAnimationFrame(v)};return c.current=requestAnimationFrame(v),()=>{c.current!==null&&cancelAnimationFrame(c.current)}},[N,R]),m.useEffect(()=>{const v=u.current;v&&(N?v.play().catch(S=>{j(!1),y(!0)}):v.pause())},[N]),m.useEffect(()=>{if(!R)return;const v=U=>b(F(U)),S=U=>{I(!1),$(F(U))};return window.addEventListener("mousemove",v),window.addEventListener("mouseup",S),window.addEventListener("touchmove",v,{passive:!0}),window.addEventListener("touchend",S),()=>{window.removeEventListener("mousemove",v),window.removeEventListener("mouseup",S),window.removeEventListener("touchmove",v),window.removeEventListener("touchend",S)}},[R,F,$]);const J=T?{aspectRatio:String(T)}:void 0,W=T?"":" aspect-video",G=Math.round(p*100);return e.jsxs("div",{role:"button",tabIndex:0,className:`relative cursor-pointer overflow-hidden bg-black ${W}`,style:J,onClick:v=>{if(h){h(v);return}D||o&&j(S=>!S)},onKeyDown:v=>{if(!(v.key!=="Enter"&&v.key!==" ")){if(v.preventDefault(),h){h(v);return}D||o&&j(S=>!S)}},children:[n&&(f==="audio"||P)&&e.jsx("img",{src:n,alt:"",className:"absolute inset-0 h-full w-full object-cover"}),!n&&(f==="audio"||P)&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:ne(s,{className:"size-12 text-black/20",weight:"regular"})}),e.jsx("div",{className:"absolute inset-0",children:f==="audio"?e.jsx("audio",{ref:u,src:t,loop:i,muted:d,style:{width:"100%",height:"100%"},onLoadStart:()=>L(!0),onCanPlay:()=>{L(!1),A(!1)},onWaiting:()=>L(!0),onPlay:()=>y(!1),onEnded:()=>{i||(j(!1),b(0))},children:e.jsx("track",{kind:"captions"})}):e.jsx("video",{ref:u,src:t,loop:i,muted:d,playsInline:!0,style:{width:"100%",height:"100%"},onLoadStart:()=>L(!0),onCanPlay:()=>{L(!1),A(!1)},onWaiting:()=>L(!0),onPlay:()=>y(!1),onLoadedMetadata:()=>{const v=u.current;v instanceof HTMLVideoElement&&v.videoWidth&&v.videoHeight&&k(v.videoWidth/v.videoHeight)},onEnded:()=>{i||(j(!1),b(0))},children:e.jsx("track",{kind:"captions"})})}),z&&!D&&e.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center",children:e.jsx(w.CircleNotchIcon,{className:"size-8 animate-spin text-white/80",weight:"bold"})}),D&&!o&&e.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:v=>{v.stopPropagation(),M()},onKeyDown:v=>{v.key!=="Enter"&&v.key!==" "||(v.preventDefault(),v.stopPropagation(),M())},children:e.jsx("span",{className:"flex size-16 items-center justify-center rounded-full bg-white/20 text-white backdrop-blur-sm",children:e.jsx(w.PlayIcon,{className:"size-9 translate-x-0.5",weight:"fill"})})}),l&&!o&&e.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:e.jsx("div",{role:"slider","aria-label":"Playback position","aria-valuenow":G,"aria-valuemin":0,"aria-valuemax":100,tabIndex:0,ref:x,className:"relative flex h-4 w-full cursor-pointer items-center",onMouseDown:V,onTouchStart:V,onClick:v=>v.stopPropagation(),onKeyDown:v=>{v.key==="ArrowRight"&&$(Math.min(1,p+.05)),v.key==="ArrowLeft"&&$(Math.max(0,p-.05))},children:e.jsx("div",{className:"w-full overflow-hidden rounded-full bg-white/30 h-1",children:e.jsx("div",{className:"h-full rounded-full bg-white",style:{width:`${G}%`}})})})}),o&&e.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:[e.jsx("button",{type:"button",onClick:v=>{v.stopPropagation(),j(S=>!S)},className:"shrink-0 text-white","aria-label":N?"Pause":"Play",children:N?e.jsx(w.PauseIcon,{className:"size-5",weight:"fill"}):e.jsx(w.PlayIcon,{className:"size-5 translate-x-px",weight:"fill"})}),e.jsxs("div",{role:"slider","aria-label":"Playback position","aria-valuenow":G,"aria-valuemin":0,"aria-valuemax":100,tabIndex:0,ref:x,className:"relative flex h-4 w-full cursor-pointer items-center",onMouseDown:V,onTouchStart:V,onClick:v=>v.stopPropagation(),onMouseEnter:()=>O(!0),onMouseLeave:()=>O(!1),onKeyDown:v=>{v.key==="ArrowRight"&&$(Math.min(1,p+.05)),v.key==="ArrowLeft"&&$(Math.max(0,p-.05))},children:[e.jsx("div",{className:`w-full overflow-hidden rounded-full bg-white/30 transition-all duration-200 ${E||R?"h-1.5":"h-1"}`,children:e.jsx("div",{className:"h-full rounded-full bg-white",style:{width:`${G}%`}})}),e.jsx("div",{className:`absolute size-3 -translate-x-1/2 rounded-full bg-white shadow transition-[opacity,transform] duration-200 ${E||R?"scale-100 opacity-100":"scale-0 opacity-0"}`,style:{left:`${G}%`}})]})]})]})},_t=t=>t==="dark"?"size-12 text-white/20":"size-12 text-black/20",As=t=>t==="dark"?"aspect-video overflow-hidden bg-white/10":"aspect-video overflow-hidden bg-black/5",Fe=({mimeType:t,sourceUrl:s,thumbnailUrl:n,title:a,variant:r,mediaPlayerProps:i,containedImage:o=!1})=>{const l=te(t),[d,h]=m.useState(!1);return s&&(l==="video"||l==="audio")?e.jsx(Rs,{source:s,mimeType:t,poster:n,controls:!0,...i}):s&&l==="image"?o?e.jsx("div",{className:"relative aspect-video overflow-hidden bg-black/5",children:e.jsx("img",{src:s,alt:a??"",className:`absolute inset-0 h-full w-full object-contain transition-opacity duration-300 ${d?"opacity-100":"opacity-0"}`,draggable:!1,onLoad:()=>h(!0)})}):e.jsx("img",{src:s,alt:a??"",className:"block w-full",draggable:!1}):s&&l==="document"?n?o?e.jsx("div",{className:"relative aspect-video overflow-hidden bg-black/5",children:e.jsx("img",{src:n,alt:a??"",className:`absolute inset-0 h-full w-full object-contain transition-opacity duration-300 ${d?"opacity-100":"opacity-0"}`,draggable:!1,onLoad:()=>h(!0)})}):e.jsx("img",{src:n,alt:"",className:"block w-full",draggable:!1}):e.jsx("div",{className:`flex aspect-video w-full items-center justify-center ${r==="dark"?"bg-white/10":"bg-black/5"}`,children:ne(t,{className:_t(r),weight:"regular"})}):n?e.jsx("div",{className:`relative ${As(r)}`,children:e.jsx("img",{src:n,alt:a??"",draggable:!1,className:"absolute inset-0 h-full w-full object-cover"})}):e.jsx("div",{className:`flex aspect-video w-full items-center justify-center ${r==="dark"?"bg-white/10":"bg-black/5"}`,children:ne(t,{className:_t(r),weight:"regular"})})},Dt=({variant:t,thumbnail:s,title:n,placeholderTitle:a="Attachment title",mimeType:r,detail:i,statusBadge:o,action:l,topLeft:d,topRight:h,rootRef:f,"data-testid":u})=>{const x=t==="dark",c=x?n??a:n??"",g=x&&!n;return e.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)]",x?"bg-[#121110]":"bg-white"),children:[d?e.jsx("div",{className:"pointer-events-auto absolute left-3 top-3 z-50",children:d}):null,h?e.jsx("div",{className:"pointer-events-auto absolute right-3 top-3 z-50",children:h}):null,s,e.jsxs("div",{className:"px-4 pb-3 pt-3",children:[c.trim()!==""&&e.jsx("p",{className:C("mb-0.5 truncate text-base font-medium",{"text-black":!x,"text-white/30":x&&g,"text-white":x&&!g}),children:c}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[ne(r,{className:C("size-5 shrink-0",x?"text-white/55":"text-black/55"),weight:"regular"}),i!=null&&i!==""&&e.jsx("span",{className:C("text-xs font-medium",x?"text-white/55":"text-black/55"),children:i}),o]}),l]})]})};function Pt(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function $e(t){return`w-[280px] select-none overflow-hidden rounded-[24px] ${t?"bg-[#121110]":"bg-[#F3F3F1]"} shadow-[0_0_0_1px_rgba(0,0,0,0.04),0_4px_8px_rgba(0,0,0,0.06)]`}function Ls(t){return t?"bg-white/10":"bg-black/5"}function Ds(t){return t?"text-white":"text-black"}function Ps(t){return t?"text-white/55":"text-black/55"}function zs(t){return t?"text-white/40":"text-black/40"}function Os(t){return t?"text-white/20":"text-black/20"}const Be=({attachment:t,isMyMessage:s})=>{const{title:n,text:a,image_url:r,og_scrape_url:i,title_link:o}=t,l=i??o,d=typeof l=="string"&&l.trim()!==""?l:void 0,h=e.jsxs(m.Fragment,{children:[e.jsx("div",{className:"p-2",children:r?e.jsx("img",{src:r,alt:n??"",className:"aspect-video w-full rounded-[20px] object-cover"}):e.jsx("div",{className:`aspect-video w-full rounded-[20px] ${Ls(s)} flex items-center justify-center`,children:e.jsx(w.LinkIcon,{className:`size-12 ${Os(s)}`})})}),e.jsxs("div",{className:"px-3 pb-3",children:[n&&e.jsx("p",{className:`truncate text-[14px] font-medium leading-5 ${Ds(s)}`,children:n}),a&&e.jsx("p",{className:`truncate text-[12px] leading-4 ${Ps(s)}`,children:a}),d&&e.jsx("p",{className:`mt-1 truncate text-[12px] leading-4 ${zs(s)}`,children:d})]})]});return d?e.jsx("a",{href:d,target:"_blank",rel:"noopener noreferrer",className:"block no-underline",children:h}):e.jsx("div",{className:"block",children:h})};function Ue(t){return t.type==="link"||!!t.og_scrape_url&&!t.asset_url}function Ne(t){var s;return(s=t.attachments)==null?void 0:s.find(Ue)}async function Fs(t,s){let n;try{n=s??new URL(t).pathname.split("/").pop()??"download"}catch{n=s??"download"}const a=await fetch(t,{mode:"cors"});if(!a.ok)throw new Error(`HTTP ${a.status}`);const r=await a.blob(),i=URL.createObjectURL(r),o=document.createElement("a");o.href=i,o.download=n,o.style.display="none",document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(i)}const $s=({url:t,filename:s})=>{const[n,a]=m.useState(!1),r=i=>{i.stopPropagation();const o=window.open("","_blank","noopener,noreferrer");a(!0),Fs(t,s).then(()=>{o==null||o.close()}).catch(()=>{o&&(o.location.href=t)}).finally(()=>a(!1))};return e.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?e.jsx(w.CircleNotchIcon,{className:"size-4 animate-spin text-white",weight:"bold"}):e.jsxs(m.Fragment,{children:[e.jsx(w.DownloadSimpleIcon,{className:"size-4 text-white",weight:"bold"}),"Download"]})})};function _e(t){var u,x,c,g;const s=(u=t.attachments)==null?void 0:u.find(N=>N.type==="video"&&N.asset_url),n=(x=t.attachments)==null?void 0:x.find(N=>N.type==="image"&&N.image_url),a=(c=t.attachments)==null?void 0:c.find(N=>N.type==="audio"&&N.asset_url),r=(g=t.attachments)==null?void 0:g.find(N=>N.type==="file"&&N.asset_url),i=s??n??a??r,o=(s==null?void 0:s.asset_url)??(n==null?void 0:n.image_url)??(a==null?void 0:a.asset_url)??(r==null?void 0:r.asset_url);if(!o)return null;const l=(i==null?void 0:i.mime_type)??((i==null?void 0:i.type)==="image"?"image/jpeg":(i==null?void 0:i.type)==="video"?"video/mp4":(i==null?void 0:i.type)==="audio"?"audio/mpeg":"application/octet-stream"),d=i==null?void 0:i.title,h=i==null?void 0:i.file_size,f=s==null?void 0:s.thumb_url;return{resolvedUrl:o,resolvedType:l,title:d,fileSize:h,thumbnailUrl:f}}const zt=({resolvedUrl:t,resolvedType:s,title:n,fileSize:a,thumbnailUrl:r})=>{const i=a!==void 0?Pt(a):void 0;return e.jsx(Dt,{variant:"dark",title:n,placeholderTitle:"",mimeType:s,detail:i,thumbnail:e.jsx(Fe,{mimeType:s,sourceUrl:t,thumbnailUrl:r,title:n,variant:"dark"})})},Ot=({resolvedUrl:t,resolvedType:s,title:n,fileSize:a,thumbnailUrl:r})=>{const i=te(s),o=a!==void 0?Pt(a):void 0;return e.jsx(Dt,{variant:"light",title:n,mimeType:s,detail:o,thumbnail:e.jsx(Fe,{mimeType:s,sourceUrl:t,thumbnailUrl:r,title:n,variant:"light",containedImage:i==="image"||i==="document"}),action:e.jsx($s,{url:t,filename:n})})},Bs=({message:t,isMyMessage:s=!1})=>{const n=Ne(t),a=_e(t);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 e.jsxs("div",{className:r,"data-dd-privacy":"mask",children:[!s&&t.user&&e.jsx(Q,{className:"str-chat__avatar str-chat__message-sender-avatar",id:t.user.id,image:t.user.image,name:t.user.name??t.user.id}),e.jsx("div",{className:"str-chat__message-inner",style:{marginInlineEnd:0,marginInlineStart:0},children:e.jsx("div",{className:"str-chat__message-bubble-wrapper",children:e.jsx("div",{className:"str-chat__message-bubble",style:{padding:0,borderRadius:0,overflow:"visible",background:"transparent"},children:n?e.jsx("div",{className:$e(s),children:e.jsx(Be,{attachment:n,isMyMessage:s})}):s?e.jsx(zt,{...a}):e.jsx(Ot,{...a})})})})]})},Us=({message:t})=>{const s=Ne(t);if(s)return e.jsx("div",{className:$e(!0),"data-dd-privacy":"mask",children:e.jsx(Be,{attachment:s,isMyMessage:!0})});const n=_e(t);return n?e.jsx("div",{style:{display:"contents"},"data-dd-privacy":"mask",children:e.jsx(zt,{...n})}):null},Vs=({message:t})=>{const s=Ne(t);if(s)return e.jsx("div",{className:$e(!1),"data-dd-privacy":"mask",children:e.jsx(Be,{attachment:s,isMyMessage:!1})});const n=_e(t);return n?e.jsx("div",{style:{display:"contents"},"data-dd-privacy":"mask",children:e.jsx(Ot,{...n})}):null},Gs=Object.assign(Bs,{Creator:Us,Visitor:Vs}),Hs={isUnlocking:()=>!1},Ys={LockedAttachment:Hs},Ft=m.createContext({}),qs=Ft.Provider;function $t(t){return m.useContext(Ft)[t]??Ys[t]}const Xs=({size:t=15})=>e.jsx("svg",{width:t,height:t,viewBox:"0 0 15 15",fill:"none","aria-hidden":"true",children:e.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})}),Ws=t=>{var s;return((s=t.metadata)==null?void 0:s.custom_type)==="MESSAGE_TIP"},Ks=t=>{var s;return((s=t.metadata)==null?void 0:s.custom_type)==="MESSAGE_PAID"},pe=t=>{var s;return((s=t.metadata)==null?void 0:s.custom_type)==="MESSAGE_CHATBOT"},Js=t=>{var s;return((s=t.metadata)==null?void 0:s.custom_type)==="MESSAGE_ATTACHMENT"},Bt=t=>Ws(t)||Ks(t),Zs=t=>{var s;return Bt(t)&&!((s=t.text)!=null&&s.trim())},ke=({message:t,standalone:s=!1,isMyMessage:n=!1,hasAttachment:a=!1})=>{var u;const r=Bt(t),i=pe(t);if(!r&&!i)return null;if(r){const x=(u=t.metadata)==null?void 0:u.amount_text;if(!x)return null;const c=s?"message-tip-standalone":"message-tag message-tag--tip",g=s?`${x} tip`:`Delivered with ${x} tip`;return e.jsxs("div",{className:c,children:[e.jsx(w.GiftIcon,{size:s?14:12}),e.jsx("span",{children:g})]})}const o=n&&a,l=o?"Sent with AI":"Sent by AI Assistant",d=["message-chatbot-indicator",n?"message-chatbot-indicator--sender":"message-chatbot-indicator--receiver",o?"message-chatbot-indicator--attachment":"message-chatbot-indicator--text"].join(" "),h=e.jsx("span",{className:"message-chatbot-indicator__label",children:l}),f=e.jsx("span",{className:"message-chatbot-indicator__icon",children:e.jsx(Xs,{size:o?12:15})});return e.jsx("div",{className:d,"data-testid":"message-chatbot-indicator",children:n&&!o?e.jsxs(e.Fragment,{children:[h,f]}):e.jsxs(e.Fragment,{children:[f,h]})})},Ut=({selected:t,onVoteUp:s,onVoteDown:n})=>e.jsxs("div",{className:"message-vote-buttons",children:[e.jsx("button",{type:"button",className:C("message-vote-button focus-ring",{"message-vote-button--selected":t==="up"}),onClick:s,"aria-label":"Good response","aria-pressed":t==="up","data-tooltip":"Good response",children:e.jsx(w.ThumbsUpIcon,{size:16,weight:t==="up"?"fill":"regular"})}),e.jsx("button",{type:"button",className:C("message-vote-button focus-ring",{"message-vote-button--selected":t==="down"}),onClick:n,"aria-label":"Bad response","aria-pressed":t==="down","data-tooltip":"Bad response",children:e.jsx(w.ThumbsDownIcon,{size:16,weight:t==="down"?"fill":"regular"})})]}),Qs=t=>{var at,rt,it,ot,lt,ct,dt,ut,mt,ht,xt,ft,gt,bt;const{additionalMessageInputProps:s,chatbotVotingEnabled:n,editing:a,endOfGroup:r,firstOfGroup:i,groupedByUser:o,handleAction:l,handleOpenThread:d,handleRetry:h,highlighted:f,isMessageAIGenerated:u,isMyMessage:x,message:c,renderText:g,threadList:N,viewerLanguage:j}=t,{client:p}=_.useChatContext("CustomMessage"),{channel:b}=_.useChannelStateContext("CustomMessage"),{isUnlocking:R,onUnlockClick:I,onFetchSource:E,onDownloadClick:O}=$t("LockedAttachment"),[D,y]=m.useState(!1),z=_.useMessageReminder(c.id),{selected:L,voteUp:P,voteDown:A}=Tt(c),{Attachment:T=_.Attachment,EditMessageModal:k=_.EditMessageModal,MessageActions:M,MessageBlocked:F=_.MessageBlocked,MessageBouncePrompt:$=_.MessageBouncePrompt,MessageDeleted:V=_.MessageDeleted,MessageIsThreadReplyInChannelButtonIndicator:J=_.MessageIsThreadReplyInChannelButtonIndicator,MessageRepliesCountButton:W=_.MessageRepliesCountButton,ReminderNotification:G=_.ReminderNotification,StreamedMessageText:v=_.StreamedMessageText,PinIndicator:S}=_.useComponentContext("CustomMessage"),U=_.messageHasAttachments(c),H=_.messageHasReactions(c),Y=m.useMemo(()=>u==null?void 0:u(c),[u,c]),B=m.useMemo(()=>{const de=c.attachments??[],ge=c.shared_location?[c.shared_location,...de]:de;if(!pe(c))return ge;const pt=ge.filter(vt=>!("type"in vt)||!Ue(vt));return pt.length===ge.length?ge:pt},[c]),q=m.useMemo(()=>{const de=ze({message:c,viewerLanguage:j});return de===c.text?c:{...c,text:de}},[c,j]);if(_.isDateSeparatorMessage(c))return null;if(c.deleted_at||c.type==="deleted")return e.jsx(V,{message:c});if(_.isMessageBlocked(c))return e.jsx(F,{});const X=!N&&!!c.reply_count,ie=!N&&c.show_in_channel&&c.parent_id,oe=c.status==="failed"&&((at=c.error)==null?void 0:at.status)!==403,le=_.isMessageBounced(c);let K;oe?K=()=>h(c):le&&(K=()=>y(!0));const Z=x(),se=C("str-chat__message str-chat__message-simple",`str-chat__message--${c.type}`,`str-chat__message--${c.status}`,Z?"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":U,"str-chat__message--highlighted":f,"str-chat__message--pinned pinned-message":c.pinned,"str-chat__message--with-reactions":H,"str-chat__message-send-can-be-retried":(c==null?void 0:c.status)==="failed"&&((rt=c==null?void 0:c.error)==null?void 0:rt.status)!==403,"str-chat__message-with-thread-link":X||ie,"str-chat__virtual-message__wrapper--end":r,"str-chat__virtual-message__wrapper--first":i,"str-chat__virtual-message__wrapper--group":o}),et=c.poll_id&&p.polls.fromState(c.poll_id),tt=Zs(c),ce=pe(c),st=Js(c),Ce=!!(B!=null&&B.length&&!c.quoted_message),nt=ce&&Z&&Ce;return e.jsxs(e.Fragment,{children:[a&&e.jsx(k,{additionalMessageInputProps:s}),D&&e.jsx(_.MessageBounceModal,{MessageBouncePrompt:$,onClose:()=>y(!1),open:D}),e.jsxs("div",{className:se,"data-message-id":c.id,"data-dd-privacy":"mask",children:[S&&e.jsx(S,{}),!!z&&e.jsx(G,{reminder:z}),c.user&&e.jsx(Q,{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:ce}),e.jsx("div",{className:C("str-chat__message-inner",{"str-chat__simple-message--error-failed":oe||le}),"data-testid":"message-inner",onClick:K,onKeyDown:K,role:K?"button":void 0,tabIndex:K?0:void 0,style:{marginInlineEnd:0,marginInlineStart:0},children:st?e.jsxs("div",{className:"str-chat__message-bubble-wrapper",children:[Z?e.jsxs("div",{className:"flex items-center gap-2",children:[M&&e.jsx(M,{}),e.jsx(Ae.Sent,{title:(it=c.metadata)==null?void 0:it.attachment_title,mimeType:(ot=c.metadata)==null?void 0:ot.attachment_mime_type,thumbnailUrl:(lt=c.metadata)==null?void 0:lt.attachment_thumbnail,amountText:(ct=c.metadata)==null?void 0:ct.amount_text,detail:(dt=c.metadata)==null?void 0:dt.attachment_detail,paymentStatus:(ut=c.metadata)==null?void 0:ut.payment_status,onPreviewClick:()=>I==null?void 0:I(c,b),onFetchSource:async()=>await(E==null?void 0:E(c,b))})]}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ae.Received,{title:(mt=c.metadata)==null?void 0:mt.attachment_title,mimeType:(ht=c.metadata)==null?void 0:ht.attachment_mime_type,thumbnailUrl:(xt=c.metadata)==null?void 0:xt.attachment_thumbnail,amountText:(ft=c.metadata)==null?void 0:ft.amount_text,detail:(gt=c.metadata)==null?void 0:gt.attachment_detail,paymentStatus:(bt=c.metadata)==null?void 0:bt.payment_status,isUnlocking:R(c.id),onUnlockClick:()=>I==null?void 0:I(c,b),onFetchSource:async()=>await(E==null?void 0:E(c,b)),onDownloadClick:()=>O==null?void 0:O(c,b)}),M&&e.jsx(M,{})]}),c.text&&e.jsx("div",{className:"str-chat__message-bubble",children:e.jsx(_.MessageText,{message:q,renderText:g})})]}):tt?e.jsx(ke,{message:c,standalone:!0}):e.jsx("div",{className:"str-chat__message-bubble-wrapper",children:e.jsxs("div",{className:"str-chat__message-bubble",children:[ce&&!nt&&e.jsx(ke,{message:c,hasAttachment:Ce,isMyMessage:Z}),et&&e.jsx(_.Poll,{poll:et}),B!=null&&B.length&&!c.quoted_message?e.jsx(T,{actionHandler:l,attachments:B}):null,Y?e.jsx(v,{message:q,renderText:g}):e.jsx(_.MessageText,{message:q,renderText:g}),e.jsx(_.MessageErrorIcon,{})]})})}),!st&&!tt&&e.jsxs("div",{className:"str-chat__message-footer",children:[(!ce||nt)&&e.jsx(ke,{message:c,hasAttachment:Ce,isMyMessage:Z}),n&&ce&&e.jsx(Ut,{selected:L,onVoteUp:P,onVoteDown:A})]}),X&&e.jsx(W,{onClick:d,reply_count:c.reply_count}),ie&&e.jsx(J,{})]},c.id)]})},en=m.memo(Qs,(t,s)=>t.chatbotVotingEnabled!==s.chatbotVotingEnabled||t.viewerLanguage!==s.viewerLanguage?!1:_.areMessageUIPropsEqual(t,s)),tn=t=>{const s=_.useMessageContext("CustomMessage");return e.jsx(en,{...s,...t})},sn=()=>{var n;const{handleDelete:t,message:s}=_.useMessageContext("CustomMessageActions");return((n=s.metadata)==null?void 0:n.payment_status)==="paid"?null:e.jsx(Le.DefaultDropdownActionButton,{onClick:t,"aria-label":"Delete",title:"Delete",className:"bg-marble rounded-full p-2 hover:bg-sand transition-all",children:e.jsx(w.TrashSimpleIcon,{size:16,weight:"light","aria-hidden":!0})})},nn=()=>{const{handleFlag:t}=_.useMessageContext("CustomMessageActions");return e.jsx(Le.DefaultDropdownActionButton,{onClick:t,"aria-label":"Report",title:"Report",className:"bg-marble rounded-full p-2 hover:bg-sand transition-all",children:e.jsx(w.FlagIcon,{size:16,weight:"light","aria-hidden":!0})})},an=()=>{var s;const{message:t}=_.useMessageContext("CustomMessageActions");return((s=t.metadata)==null?void 0:s.custom_type)!=="MESSAGE_ATTACHMENT"?null:e.jsx(Le.MessageActions,{messageActionSet:[{Component:sn,placement:"quick",type:"delete"},{Component:nn,placement:"quick",type:"flag"}]})},rn=({link:t,onDismiss:s})=>{const{og_scrape_url:n,title:a,image_url:r}=t,i=o=>{o.preventDefault(),s(n)};return e.jsxs("a",{href:n,target:"_blank",rel:"noopener noreferrer",className:"relative block w-full rounded-[24px] bg-[#121110] p-2 no-underline transition-opacity hover:opacity-90",children:[r&&e.jsx("img",{src:r,alt:a||"",className:"h-[180px] w-full rounded-[20px] object-cover"}),e.jsx("button",{type:"button",onClick:i,className:"absolute right-4 top-4 flex size-6 items-center justify-center rounded-full border border-white/40 bg-white/70 backdrop-blur-2xl focus-ring","aria-label":"Close link preview",children:e.jsx(w.XIcon,{className:"size-4 text-black/90"})}),e.jsxs("div",{className:"p-2",children:[a&&e.jsx("div",{className:"truncate text-[14px] font-medium leading-5 text-white",children:a}),e.jsx("div",{className:"truncate text-[12px] leading-4 text-white/55",children:n})]})]})},on=t=>({linkPreviews:Array.from(t.previews.values()).filter(s=>Te.LinkPreviewsManager.previewIsLoaded(s)||Te.LinkPreviewsManager.previewIsLoading(s))}),ln=()=>{const{linkPreviewsManager:t}=_.useMessageComposer(),{linkPreviews:s}=_.useStateStore(t.state,on),n=r=>{t.dismissPreview(r)};return s.length>0?e.jsx("div",{className:"flex flex-col items-stretch w-full gap-2 mb-4",children:s.map(r=>e.jsx(rn,{link:r,onDismiss:n},r.og_scrape_url))}):null},Ve=m.createContext(!1),cn=()=>m.useContext(Ve),dn=({sendMessage:t,disabled:s,...n})=>e.jsx("button",{...n,type:"button","aria-label":"Send",disabled:s,onClick:t,children:e.jsx(w.ArrowUpIcon,{weight:"bold",className:"size-4"})}),un=()=>{const t=m.useContext(Ve),{handleSubmit:s}=_.useMessageInputContext(),n=_.useMessageComposerHasSendableData(),a=t||!n,{SendButton:r=dn,AttachmentPreviewList:i=_.AttachmentPreviewList}=_.useComponentContext("CustomMessageInput");return e.jsxs("div",{className:"central-container flex flex-col gap-2 min-w-0 w-full p-2 bg-white rounded-[1.5rem] shadow-[0_4px_16px_0_rgba(0,0,0,0.08),0_1px_2px_0_rgba(0,0,0,0.04),0_0_0_1px_rgba(0,0,0,0.04)]","data-dd-privacy":"mask",children:[e.jsx(_.QuotedMessagePreview,{}),e.jsx(ln,{}),e.jsx(i,{}),e.jsxs("div",{className:"flex",children:[e.jsx("div",{className:"w-full ml-2 mr-4 self-center leading-[0]",children:e.jsx(_.TextareaComposer,{"aria-disabled":t||void 0,className:"w-full resize-none outline-none leading-5 placeholder:text-black/30 text-sm",autoFocus:!t,maxRows:4,readOnly:t,tabIndex:t?-1:void 0})}),e.jsx(r,{sendMessage:s,"aria-label":"Send",className:"str-chat__send-button mt-auto flex justify-center items-center flex-shrink-0 rounded-full size-8 bg-[#121110] disabled:bg-[#F1F0EE] disabled:text-black/20 text-white focus-ring","data-testid":"send-button",disabled:a,type:"button"})]})]})},mn=({renderActions:t,renderFooter:s,disabled:n=!1,disabledReason:a,composerInput:r})=>{var l;const{channel:i}=_.useChannelStateContext(),o=((l=i==null?void 0:i.data)==null?void 0:l.frozen)===!0;return n?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"messaging-composer-locked-panel flex w-full flex-col items-center justify-center gap-3 px-6 py-4",children:a?e.jsx("p",{className:"max-w-[345px] text-center text-xs font-normal leading-[1.3] tracking-[0.12px] text-black/40",children:a}):null}),s==null?void 0:s()]}):e.jsxs("div",{className:"flex flex-col gap-4 p-4",children:[e.jsxs("div",{inert:o?"":void 0,"aria-disabled":o||void 0,className:"message-input flex items-end gap-4 aria-disabled:opacity-40",children:[t&&e.jsx("div",{className:"flex h-12 shrink-0 items-center justify-center",children:t()}),e.jsx(Ve.Provider,{value:o,children:e.jsx(_.MessageInput,{Input:r??un})})]}),s==null?void 0:s()]})},hn=["SYSTEM_DM_AGENT_PAUSED","SYSTEM_DM_AGENT_RESUMED"],xn={SYSTEM_DM_AGENT_PAUSED:"DM Agent has left the conversation",SYSTEM_DM_AGENT_RESUMED:"DM Agent has rejoined the conversation"},fn=["SYSTEM_AGE_SAFETY_BLOCKED"],gn={SYSTEM_AGE_SAFETY_BLOCKED:"This user isn’t able to reply because they don’t meet our age safety guidelines."},Se="age safety guidelines.",bn="https://linktr.ee/s/about/contact",yt=t=>hn.includes(t),pn=t=>fn.includes(t),vn=t=>{var a;const s=(a=t.metadata)==null?void 0:a.custom_type;if(yt(s))return{kind:"dm-agent",type:s};if(pn(s))return{kind:"age-safety",type:s};const n=t.dm_agent_system_type;if(yt(n))return{kind:"dm-agent",type:n}},jn=t=>{const s=t.indexOf(Se);if(s===-1)return t;const n=s+Se.length;return e.jsxs(e.Fragment,{children:[t.slice(0,s),e.jsx("a",{href:bn,target:"_blank",rel:"noopener noreferrer",className:"mes-age-safety-system-message__emphasis font-medium text-inherit underline",children:Se}),t.slice(n)]})},wn=t=>{var a,r;const s=t.message.hide_date===!0,n=vn(t.message);if((n==null?void 0:n.kind)==="dm-agent"){const i=((a=t.message.text)==null?void 0:a.trim())||xn[n.type];return e.jsxs("div",{className:"str-chat__message--system","data-testid":"message-system",children:[e.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:[e.jsx(w.SparkleIcon,{size:16,weight:"regular","aria-hidden":!0,className:"mes-dm-agent-system-message__sparkle shrink-0"}),e.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&&e.jsx(_.MessageTimestamp,{message:t.message})]})}if((n==null?void 0:n.kind)==="age-safety"){const i=((r=t.message.text)==null?void 0:r.trim())||gn[n.type];return e.jsxs("div",{className:"str-chat__message--system","data-testid":"message-system",children:[e.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:[e.jsx(w.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"}),e.jsx("div",{className:"mes-age-safety-system-message__content min-w-0 flex-[1_0_0]",children:e.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:jn(i)})})]}),!s&&e.jsx(_.MessageTimestamp,{message:t.message})]})}return e.jsxs("div",{className:"str-chat__message--system","data-testid":"message-system",children:[e.jsxs("div",{className:"str-chat__message--system__text",children:[e.jsx("div",{className:"str-chat__message--system__line"}),e.jsx("p",{children:t.message.text}),e.jsx("div",{className:"str-chat__message--system__line"})]}),!s&&e.jsx(_.MessageTimestamp,{message:t.message})]})},Vt=m.createContext(!1),Ie=({cx:t,index:s})=>e.jsx("circle",{cx:t,cy:"6.15",r:"3.9",fill:"#A0A0A0",children:e.jsx("animateTransform",{attributeName:"transform",type:"translate",values:"0 0; 0 -2.25; 0 0;",dur:"900ms",begin:`${120*s}ms`,repeatCount:"indefinite"})}),Nn=new Set([_.AIStates.Thinking,_.AIStates.Generating,_.AIStates.ExternalSources]),_n=({threadList:t})=>{var g,N;const{channel:s,channelConfig:n,thread:a}=_.useChannelStateContext(),{client:r}=_.useChatContext(),{typing:i={}}=_.useTypingContext(),{aiState:o}=_.useAIState(s),l=m.useContext(Vt);if(!t&&l&&Nn.has(o)){const j=yn(s,(g=r.user)==null?void 0:g.id);return e.jsx(Ct,{avatarId:(j==null?void 0:j.id)??"ai-agent",avatarName:(j==null?void 0:j.name)??(j==null?void 0:j.id)??"Agent",avatarImage:j==null?void 0:j.image,testId:"typing-indicator-ai"})}if((n==null?void 0:n.typing_events)===!1)return null;const h=t?[]:Object.values(i).filter(({parent_id:j,user:p})=>{var b;return(p==null?void 0:p.id)!==((b=r.user)==null?void 0:b.id)&&!j}),f=t?Object.values(i).filter(({parent_id:j,user:p})=>{var b;return(p==null?void 0:p.id)!==((b=r.user)==null?void 0:b.id)&&j===(a==null?void 0:a.id)}):[],u=t?f:h;if(!u.length)return null;const x=(N=u[0])==null?void 0:N.user,c=x!=null&&x.id&&s.state.members[x.id]?s.state.members[x.id].user:void 0;return e.jsx(Ct,{avatarId:(x==null?void 0:x.id)??(c==null?void 0:c.id)??"typing-user",avatarName:(x==null?void 0:x.name)??(c==null?void 0:c.name)??(x==null?void 0:x.id)??"Typing user",avatarImage:(x==null?void 0:x.image)??(c==null?void 0:c.image),testId:"typing-indicator"})},Ct=({avatarId:t,avatarName:s,avatarImage:n,testId:a})=>e.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:e.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:[e.jsx(Q,{className:"str-chat__avatar str-chat__message-sender-avatar",id:t,name:s,image:n??void 0,size:24,shape:"circle"}),e.jsx("div",{className:"str-chat__message-inner mx-0",children:e.jsx("div",{className:"str-chat__message-bubble-wrapper",children:e.jsx("div",{className:"str-chat__message-bubble",children:e.jsx("div",{className:"str-chat__message-text min-h-11 flex items-center",children:e.jsx("div",{className:"str-chat__message-text-inner str-chat__message-simple-text-inner",children:e.jsxs("svg",{"aria-hidden":"true",className:"block overflow-visible",viewBox:"0 0 32 12.3",width:"32",height:"13",overflow:"visible",children:[e.jsx(Ie,{cx:"4",index:0}),e.jsx(Ie,{cx:"16",index:1}),e.jsx(Ie,{cx:"28",index:2})]})})})})})})]})});function yn(t,s){var a;const n=((a=t==null?void 0:t.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 Gt=()=>null,Cn=({className:t,message:s})=>e.jsxs("div",{className:C("flex items-center justify-center h-full",t),children:[e.jsxs("svg",{viewBox:"0 0 100 100",className:"size-8 fill-pebble",stroke:"none",children:[e.jsx("circle",{cx:"6",cy:"50",r:"6",children:e.jsx("animateTransform",{attributeName:"transform",dur:"1s",type:"translate",values:"0 15 ; 0 -15; 0 15",repeatCount:"indefinite",begin:"0.1"})}),e.jsx("circle",{cx:"30",cy:"50",r:"6",children:e.jsx("animateTransform",{attributeName:"transform",dur:"1s",type:"translate",values:"0 10 ; 0 -10; 0 10",repeatCount:"indefinite",begin:"0.2"})}),e.jsx("circle",{cx:"54",cy:"50",r:"6",children:e.jsx("animateTransform",{attributeName:"transform",dur:"1s",type:"translate",values:"0 5 ; 0 -5; 0 5",repeatCount:"indefinite",begin:"0.3"})})]}),s&&e.jsx("span",{className:"text-stone",children:s})]}),ve=m.memo(()=>e.jsx("div",{className:"messaging-loading-state flex items-center justify-center h-full",children:e.jsxs("div",{className:"flex items-center",children:[e.jsx(Cn,{className:"w-6 h-6"}),e.jsx("span",{className:"text-sm text-stone",children:"Loading messages"})]})}));ve.displayName="LoadingState";const Ht=({channel:t,participant:s})=>{const n=(s==null?void 0:s.customer)===!0,a=It(t);return!n&&!a?null:e.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1",children:[n&&e.jsx("span",{role:"img","aria-label":"Customer",className:"inline-flex size-4 items-center justify-center rounded-full bg-[#22C55E] text-white",children:e.jsx(w.CurrencyDollarIcon,{"aria-hidden":"true",className:"size-3",weight:"bold"})}),a&&e.jsx("span",{role:"img","aria-label":"Starred conversation",className:"inline-flex size-4 items-center justify-center rounded-full bg-[#F6C343] text-white",children:e.jsx(w.StarIcon,{"aria-hidden":"true",className:"size-3",weight:"fill"})})]})},ae="size-10 rounded-full hover:bg-[#E5E4E1] flex items-center justify-center transition-colors duration-150 focus-ring",be="Replies instantly with AI assistant",kn=({onBack:t,showBackButton:s,showStarButton:n=!1,dmAgentEnabled:a=!1,onLeaveConversation:r,onBlockParticipant:i,showDeleteConversation:o=!0,showBlockParticipant:l=!0,showReportParticipant:d=!0,onDeleteConversationClick:h,onBlockParticipantClick:f,onReportParticipantClick:u,customChannelActions:x,renderChannelActions:c,showChannelInfo:g=!0,onParticipantNameClick:N,renderHeaderTitleBadges:j})=>{var P,A,T,k,M,F,$;const{channel:p}=_.useChannelStateContext(),b=m.useMemo(()=>{var W,G;const V=(W=p._client)==null?void 0:W.userID;return V?Object.values(((G=p.state)==null?void 0:G.members)||{}).find(v=>{var S;return((S=v.user)==null?void 0:S.id)&&v.user.id!==V}):void 0},[(P=p._client)==null?void 0:P.userID,(A=p.state)==null?void 0:A.members]),R=Pe(b==null?void 0:b.user),I=(T=b==null?void 0:b.user)==null?void 0:T.image,E=It(p),O=j==null?void 0:j({channel:p,participant:b}),D="flex max-w-full flex-col items-center gap-1 rounded-[12px] px-1 py-0.5 text-center text-xs font-medium text-black/90",y="flex min-w-0 max-w-full items-center gap-4 rounded-[12px] px-1 py-0.5 text-left text-black/90",z=e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"min-w-0 truncate",children:R}),e.jsx(Ht,{channel:p,participant:b}),O&&e.jsx("span",{className:"shrink-0",children:O})]}),L=async()=>{try{E?await p.unpin():await p.pin()}catch(V){console.error("[CustomChannelHeader] Failed to update pinned status:",V)}};return e.jsxs("div",{className:"@container",children:[e.jsxs("div",{className:"grid grid-cols-[1fr_auto_1fr] w-full items-center @lg:hidden px-6 py-3",children:[e.jsx("div",{className:"flex items-center gap-2",children:s&&e.jsx("button",{className:C(ae,"messaging-channel-view-back-button-mobile bg-[#F1F0EE]"),onClick:t||(()=>{}),type:"button","aria-label":"Back to conversations",children:e.jsx(w.ArrowLeftIcon,{className:"size-5 text-black/90"})})}),e.jsx("div",{className:"flex flex-col gap-1 items-center","data-dd-privacy":"mask",children:N?e.jsxs("button",{type:"button",onClick:N,"aria-label":`View details for ${R}`,className:C(D,"appearance-none border-0 bg-transparent transition-opacity hover:opacity-70 focus-ring focus-visible:outline-none"),children:[e.jsx(Q,{id:((k=b==null?void 0:b.user)==null?void 0:k.id)||p.id||"unknown",name:R,image:I,dmAgentEnabled:a,size:48}),e.jsxs("span",{className:"flex max-w-full items-center gap-0.5",children:[z,e.jsx(w.CaretRightIcon,{className:"size-3 shrink-0",weight:"bold"})]}),a&&e.jsxs("div",{className:"flex items-center gap-1 text-[10px] leading-3 text-black/55",children:[e.jsx(w.SparkleIcon,{className:"size-3 shrink-0 text-black/55"}),e.jsx("span",{children:be})]})]}):e.jsxs("div",{className:D,children:[e.jsx(Q,{id:((M=b==null?void 0:b.user)==null?void 0:M.id)||p.id||"unknown",name:R,image:I,dmAgentEnabled:a,size:48}),e.jsxs("p",{className:"flex max-w-full items-center justify-center gap-0.5",children:[z,e.jsx(w.CaretRightIcon,{className:"invisible size-3 shrink-0",weight:"bold"})]}),a&&e.jsxs("div",{className:"flex items-center gap-1 text-[10px] leading-3 text-black/55",children:[e.jsx(w.SparkleIcon,{className:"size-3 shrink-0 text-black/55"}),e.jsx("span",{children:be})]})]})}),e.jsxs("div",{className:"flex justify-end items-center gap-2",children:[n&&e.jsx("button",{className:ae,onClick:L,type:"button","aria-label":E?"Unstar conversation":"Star conversation",children:e.jsx(w.StarIcon,{className:C("size-5",{"text-yellow-600":E,"text-black/90":!E}),weight:E?"duotone":"regular"})}),g&&(c!==void 0?c:e.jsx(Nt,{channel:p,participant:b,showDeleteConversation:o,showBlockParticipant:l,showReportParticipant:d,onLeaveConversation:r,onBlockParticipant:i,onDeleteConversationClick:h,onBlockParticipantClick:f,onReportParticipantClick:u,customChannelActions:x,triggerClassName:C(ae,"bg-[#F1F0EE]")}))]})]}),e.jsxs("div",{className:"px-6 py-3 hidden @lg:flex items-center justify-between gap-3 min-h-12 border-b border-b-black/[0.08]",children:[e.jsxs("div",{className:"flex items-center gap-4 min-w-0","data-dd-privacy":"mask",children:[s&&t&&e.jsx("button",{className:C(ae,"messaging-channel-view-back-button-desktop"),type:"button",onClick:t,"aria-label":"Back to conversations",children:e.jsx(w.ArrowLeftIcon,{className:"size-5 text-black/90"})}),N?e.jsxs("button",{type:"button",onClick:N,"aria-label":`View details for ${R}`,className:C(y,"appearance-none border-0 bg-transparent transition-opacity hover:opacity-70 focus-ring focus-visible:outline-none"),children:[e.jsx(Q,{id:((F=b==null?void 0:b.user)==null?void 0:F.id)||p.id||"unknown",name:R,image:I,dmAgentEnabled:a,size:48}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("h1",{className:"flex min-w-0 items-center gap-1 font-medium text-black/90",children:[z,e.jsx(w.CaretRightIcon,{className:"size-4 shrink-0",weight:"bold"})]}),a&&e.jsxs("div",{className:"mt-0.5 flex items-center gap-1 text-[10px] leading-3 text-black/55",children:[e.jsx(w.SparkleIcon,{className:"size-3 shrink-0 text-black/55"}),e.jsx("span",{className:"truncate",children:be})]})]})]}):e.jsxs("div",{className:y,children:[e.jsx(Q,{id:(($=b==null?void 0:b.user)==null?void 0:$.id)||p.id||"unknown",name:R,image:I,dmAgentEnabled:a,size:48}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("h1",{className:"flex min-w-0 items-center gap-1 font-medium text-black/90",children:[z,e.jsx(w.CaretRightIcon,{className:"invisible size-4 shrink-0",weight:"bold"})]}),a&&e.jsxs("div",{className:"mt-0.5 flex items-center gap-1 text-[10px] leading-3 text-black/55",children:[e.jsx(w.SparkleIcon,{className:"size-3 shrink-0 text-black/55"}),e.jsx("span",{className:"truncate",children:be})]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[n&&e.jsx("button",{className:ae,onClick:L,type:"button","aria-label":E?"Unstar conversation":"Star conversation",children:e.jsx(w.StarIcon,{className:C("size-6",{"text-yellow-600":E,"text-black/90":!E}),weight:E?"duotone":"regular"})}),g&&(c!==void 0?c:e.jsx(Nt,{channel:p,participant:b,showDeleteConversation:o,showBlockParticipant:l,showReportParticipant:d,onLeaveConversation:r,onBlockParticipant:i,onDeleteConversationClick:h,onBlockParticipantClick:f,onReportParticipantClick:u,customChannelActions:x,triggerClassName:ae}))]})]})]})},Sn=({onBack:t,showBackButton:s,renderMessageInputActions:n,renderMessageInputFooter:a,renderConversationFooter:r,onLeaveConversation:i,onBlockParticipant:o,showDeleteConversation:l=!0,onDeleteConversationClick:d,onBlockParticipantClick:h,onReportParticipantClick:f,showBlockParticipant:u=!0,showReportParticipant:x=!0,composerDisabled:c=!1,composerDisabledReason:g,showStarButton:N=!1,chatbotVotingEnabled:j=!1,renderChannelBanner:p,renderHeaderTitleBadges:b,customChannelActions:R,renderChannelActions:I,renderMessage:E,dmAgentEnabled:O=!1,viewerLanguage:D,showChannelInfo:y=!0,onParticipantNameClick:z,composerInput:L})=>{var V,J,W,G,v,S;const{channel:P}=_.useChannelStateContext(),A=m.useMemo(()=>{var Y,B;const U=(Y=P._client)==null?void 0:Y.userID;return U?Object.values(((B=P.state)==null?void 0:B.members)||{}).find(q=>{var X;return((X=q.user)==null?void 0:X.id)&&q.user.id!==U}):void 0},[(V=P._client)==null?void 0:V.userID,(J=P.state)==null?void 0:J.members]),T=m.useMemo(()=>{var Y,B;const U=(Y=P._client)==null?void 0:Y.userID;return U?Object.values(((B=P.state)==null?void 0:B.members)||{}).find(q=>{var X;return((X=q.user)==null?void 0:X.id)===U}):void 0},[(W=P._client)==null?void 0:W.userID,(G=P.state)==null?void 0:G.members]),k=((v=T==null?void 0:T.user)==null?void 0:v.is_account)??(T==null?void 0:T.is_account),M=((S=A==null?void 0:A.user)==null?void 0:S.is_account)??(A==null?void 0:A.is_account),F=O&&k===!1&&M===!0,$=m.useCallback(U=>{const{message:H}=_.useMessageContext("ChannelView"),Y=e.jsx(tn,{...U,chatbotVotingEnabled:j,viewerLanguage:D});return!E||!H?Y:E(Y,H)},[j,E,D]);return e.jsx(e.Fragment,{children:e.jsx(_.WithComponents,{overrides:{Message:$,MessageActions:an},children:e.jsxs(_.Window,{children:[e.jsx("div",{children:e.jsx(kn,{onBack:t,showBackButton:s,showChannelInfo:y,showStarButton:N,dmAgentEnabled:F,onLeaveConversation:i,onBlockParticipant:o,showDeleteConversation:l,showBlockParticipant:u,showReportParticipant:x,onDeleteConversationClick:d,onBlockParticipantClick:h,onReportParticipantClick:f,customChannelActions:R,renderChannelActions:I,onParticipantNameClick:z,renderHeaderTitleBadges:b})},"lt-channel-header"),p?e.jsx(m.Fragment,{children:p()},"lt-channel-banner"):null,e.jsx("div",{className:"flex-1 overflow-hidden relative",children:e.jsx(_.MessageList,{hideDeletedMessages:!0,hideNewMessageSeparator:!1})},"lt-channel-message-list"),r?e.jsx(m.Fragment,{children:r(P)},"lt-channel-conversation-footer"):null,e.jsx(mn,{...n&&{renderActions:()=>n==null?void 0:n(P)},renderFooter:()=>a==null?void 0:a(P),disabled:c,disabledReason:g,composerInput:L},"lt-channel-message-input")]})})})},Ge=m.memo(({channel:t,onBack:s,showBackButton:n=!1,renderMessageInputActions:a,renderMessageInputFooter:r,renderConversationFooter:i,onLeaveConversation:o,onBlockParticipant:l,className:d,CustomChannelEmptyState:h=Gt,showDeleteConversation:f=!0,onDeleteConversationClick:u,onBlockParticipantClick:x,onReportParticipantClick:c,showBlockParticipant:g=!0,showReportParticipant:N=!0,composerDisabled:j=!1,composerDisabledReason:p,dmAgentEnabled:b,messageMetadata:R,onMessageSent:I,showStarButton:E=!1,chatbotVotingEnabled:O=!1,renderChannelBanner:D,renderHeaderTitleBadges:y,customChannelActions:z,renderChannelActions:L,renderMessage:P,onMessageLinkClick:A,sendButton:T,attachmentPreviewList:k,viewerLanguage:M,showChannelInfo:F=!0,onParticipantNameClick:$,composerInput:V})=>{const J=m.useCallback(async(G,v,S)=>{var X;const U=((X=t.data)==null?void 0:X.chatbot_paused)===!0,H=b&&!U,Y={...v,...H&&{silent:!0},...R&&{metadata:{...v.metadata??{},...R}}},B={...S,...H&&{skip_push:!0}},q=await t.sendMessage(Y,B);return I==null||I(q),q},[t,b,R,I]),W=m.useRef(null);return m.useEffect(()=>{if(!A)return;const G=W.current;if(!G)return;const v=S=>{const U=S.target,H=U==null?void 0:U.closest("a[href]"),Y=H==null?void 0:H.getAttribute("href");if(!Y)return;const B=H==null?void 0:H.closest("[data-message-id]"),q=B==null?void 0:B.getAttribute("data-message-id"),X=q?t.state.messages.find(ie=>ie.id===q):void 0;A(Y,X)};return G.addEventListener("click",v),()=>G.removeEventListener("click",v)},[A,t]),e.jsx("div",{ref:W,className:C("messaging-channel-view h-full flex flex-col",d),children:e.jsx(Vt.Provider,{value:b??!1,children:e.jsx(_.Channel,{channel:t,MessageSystem:wn,EmptyStateIndicator:h,LoadingIndicator:ve,DateSeparator:vs,TypingIndicator:_n,doSendMessageRequest:J,...T?{SendButton:T}:{},...k?{AttachmentPreviewList:k}:{},children:e.jsx(Sn,{onBack:s,showBackButton:n,renderMessageInputActions:a,renderMessageInputFooter:r,renderConversationFooter:i,onLeaveConversation:o,onBlockParticipant:l,CustomChannelEmptyState:h,showDeleteConversation:f,onDeleteConversationClick:u,onBlockParticipantClick:x,onReportParticipantClick:c,showBlockParticipant:g,showReportParticipant:N,composerDisabled:j,composerDisabledReason:p,showStarButton:E,dmAgentEnabled:b,chatbotVotingEnabled:O,renderChannelBanner:D,renderHeaderTitleBadges:y,customChannelActions:z,renderChannelActions:L,renderMessage:P,viewerLanguage:M,showChannelInfo:F,onParticipantNameClick:$,composerInput:V})})})})});Ge.displayName="ChannelView";const ue=m.memo(({message:t,onBack:s})=>e.jsx("div",{className:"messaging-error-state flex items-center justify-center h-full p-8",children:e.jsxs("div",{className:"text-center max-w-sm",children:[e.jsx("div",{className:"w-24 h-24 bg-danger-alt/20 rounded-full flex items-center justify-center mx-auto mb-6",children:e.jsx("span",{className:"text-4xl",children:"⚠️"})}),e.jsx("h2",{className:"font-semibold text-charcoal mb-2",children:"Oops!"}),e.jsx("p",{className:"text-stone text-sm mb-6",children:t}),s&&e.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"})]})}));ue.displayName="ErrorState";const In=({capabilities:t={},renderMessageInputActions:s,renderConversationFooter:n,onChannelSelect:a,onExitConversation:r,initialParticipantFilter:i,initialParticipantData:o,CustomChannelEmptyState:l,onBlockParticipantClick:d,onReportParticipantClick:h,dmAgentEnabled:f,onMessageSent:u,chatbotVotingEnabled:x=!1,viewerLanguage:c,renderHeaderTitleBadges:g,renderChannelBanner:N,customChannelActions:j,renderChannelActions:p,onParticipantNameClick:b,renderMessage:R,onMessageLinkClick:I,showChannelInfo:E,composerInput:O})=>{const{client:D,isConnected:y,isLoading:z,error:L,refreshConnection:P,service:A,debug:T}=St(),[k,M]=m.useState(null),[F,$]=m.useState(null),[V,J]=m.useState(!1),{showDeleteConversation:W=!0}=t,G=m.useRef(o);G.current=o;const v=m.useRef(a);v.current=a;const S=m.useRef(null),U=m.useRef(null);m.useEffect(()=>{U.current=k},[k]),m.useEffect(()=>{if(!D||!y)return;const B=D.userID;if(!B)return;const q=`${B}::${i}`;if(S.current===q)return;S.current=q;const X=()=>{S.current===q&&(S.current=null)};(async()=>{var oe,le;try{T&&console.log("[MessagingShell] Loading initial conversation with:",i);const K=await D.queryChannels({type:"messaging",members:{$eq:[B,i]}},{},{limit:1});if(K.length>0){M(K[0]),$(null),(oe=v.current)==null||oe.call(v,K[0]),T&&console.log("[MessagingShell] Initial conversation loaded:",K[0].id);return}const Z=G.current;if(!Z||!A){X(),$("No conversation found with this account"),T&&console.log("[MessagingShell] No conversation found for:",i);return}try{const se=await A.startChannelWithParticipant({id:Z.id,name:Z.name,phone:Z.phone});M(se),$(null),(le=v.current)==null||le.call(v,se),T&&console.log("[MessagingShell] Channel created and loaded:",se.id)}catch(se){console.error("[MessagingShell] Failed to create conversation:",se),X(),$("Failed to create conversation")}}catch(K){console.error("[MessagingShell] Failed to load initial conversation:",K),X(),U.current||$("Failed to load conversation")}})()},[i,D,y,A,T]);const H=m.useRef(r);H.current=r;const Y=m.useCallback(()=>{var B;M(null),J(!0),(B=H.current)==null||B.call(H)},[]);return z?e.jsx(ve,{}):L?e.jsx(ue,{message:L,onBack:P}):!y||!D?e.jsx(ue,{message:"Not connected to messaging service",onBack:P}):F?e.jsx(ue,{message:F}):V&&!k?e.jsx(ue,{message:"Conversation ended"}):k?e.jsx("div",{className:"messaging-shell h-full bg-background-primary overflow-hidden",children:e.jsx("div",{className:"flex h-full min-h-0 flex-col",children:e.jsx(Ge,{channel:k,renderMessageInputActions:s,renderConversationFooter:n,renderChannelBanner:N,onLeaveConversation:Y,onBlockParticipant:Y,CustomChannelEmptyState:l,showDeleteConversation:W,onBlockParticipantClick:d,onReportParticipantClick:h,dmAgentEnabled:f,onMessageSent:u,chatbotVotingEnabled:x,viewerLanguage:c,renderHeaderTitleBadges:g,customChannelActions:j,renderChannelActions:p,onParticipantNameClick:b,renderMessage:R,onMessageLinkClick:I,showChannelInfo:E,composerInput:O},k.id)})}):e.jsx(ve,{})};function En(t){const s=t.state.pending_messages;if(s!=null&&s.length)for(const n of s)t.state.addMessageSorted(n.message)}const Yt=m.createContext({selectedChannel:void 0,onChannelSelect:()=>{},debug:!1,renderMessagePreview:void 0,viewerLanguage:void 0}),Tn=Yt.Provider,Mn=()=>m.useContext(Yt),Rn=(t,s)=>{const n=new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate())),r=new Date(Date.UTC(s.getUTCFullYear(),s.getUTCMonth(),s.getUTCDate())).getTime()-n.getTime();return Math.floor(r/(1e3*60*60*24))},qt=t=>{const s=new Date;if(Math.floor((s.getTime()-t.getTime())/1e3)<60)return"Just now";const a=Rn(t,s);return a===0?t.toLocaleTimeString([],{hour:"numeric",minute:"2-digit",hour12:!0}):a===1?"Yesterday":a<7?`${a}d`:a<28?`${Math.floor(a/7)}w`:t.toLocaleDateString("en-US",{month:"numeric",day:"numeric",year:"2-digit"})},Xt=m.memo(({channel:t,unread:s})=>{var E,O,D;const{selectedChannel:n,onChannelSelect:a,debug:r,renderMessagePreview:i,viewerLanguage:o}=Mn(),l=(n==null?void 0:n.id)===(t==null?void 0:t.id),d=()=>{t&&a(t)},h=y=>{const z=y.key==="Enter"||y.key===" ",L=y.repeat;!z||L||(y.preventDefault(),d())},u=Object.values(((E=t==null?void 0:t.state)==null?void 0:E.members)||{}).find(y=>{var z,L;return((z=y.user)==null?void 0:z.id)&&y.user.id!==((L=t==null?void 0:t._client)==null?void 0:L.userID)}),x=Pe(u==null?void 0:u.user),c=(O=u==null?void 0:u.user)==null?void 0:O.image,g=(()=>{var z;const y=(z=t==null?void 0:t.state)==null?void 0:z.messages;if(y!=null&&y.length){for(let L=y.length-1;L>=0;L--)if(y[L].type!=="system")return y[L]}})(),j=(()=>{var T,k,M,F;const y=ze({message:g,viewerLanguage:o});if(((T=g==null?void 0:g.metadata)==null?void 0:T.custom_type)==="MESSAGE_TIP")return y?`💵 ${y}`:"💵 Sent a tip";if(((k=g==null?void 0:g.metadata)==null?void 0:k.custom_type)==="MESSAGE_PAID")return y?`💰 ${y}`:"💰 Sent a message";if(((M=g==null?void 0:g.metadata)==null?void 0:M.custom_type)==="MESSAGE_ATTACHMENT")return y?`📎 ${y}`:"📎 Sent an attachment";if(y)return y;const A=(F=g==null?void 0:g.attachments)==null?void 0:F[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"})(),p=g!=null&&g.created_at?qt(new Date(g.created_at)):"",b=g?pe(g):!1,R=i?i(g,j):`${b?"✨ ":""}${j}`,I=s??0;return r&&console.log("📺 [ChannelList] 📋 CHANNEL PREVIEW RENDER",{channelId:t==null?void 0:t.id,isSelected:l,participantName:x,unreadCount:I,hasTimestamp:!!p}),e.jsx("div",{role:"button",tabIndex:0,onClick:d,onKeyDown:h,className:C("group w-full px-4 py-3 transition-colors text-left max-w-full overflow-hidden focus-ring rounded-[12px] [&+&]:mt-2",{"bg-black/[0.04]":l,"hover:bg-black/[0.02]":!l}),"data-dd-privacy":"mask",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx(Q,{id:((D=u==null?void 0:u.user)==null?void 0:D.id)||t.id||"unknown",name:x,image:c,size:48}),e.jsxs("div",{className:"flex-1 min-w-0 flex flex-col gap-1",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("h3",{className:"flex min-w-0 items-center gap-1 text-sm font-medium text-[#191918]",children:[e.jsx("span",{className:"min-w-0 truncate",children:x}),e.jsx(Ht,{channel:t,participant:u})]}),p&&e.jsx("span",{className:"text-xs text-[#717070] flex-shrink-0",children:p})]}),e.jsxs("div",{className:"flex items-center justify-between gap-2 min-w-0",children:[e.jsx("p",{className:"text-sm text-[#717070] flex-1 line-clamp-1",children:R}),I>0&&e.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:I>99?"99+":I})]})]})]})})});Xt.displayName="CustomChannelPreview";const An={last_message_at:-1},Wt=m.memo(({onChannelSelect:t,selectedChannel:s,filters:n,allowNewMessagesFromUnfilteredChannels:a=!1,channelRenderFilterFn:r,sort:i=An,className:o,customEmptyStateIndicator:l,channelPreview:d,renderMessagePreview:h,viewerLanguage:f})=>{const u=m.useRef(0);u.current++;const{debug:x=!1}=De(),c=m.useCallback(N=>{for(const j of N)En(j);return r?r(N):N},[r]);x&&console.log("📺 [ChannelList] 🔄 RENDER START",{renderCount:u.current,selectedChannelId:s==null?void 0:s.id,filters:n});const g=m.useMemo(()=>({selectedChannel:s,onChannelSelect:t,debug:x,renderMessagePreview:h,viewerLanguage:f}),[s,t,x,h,f]);return e.jsx("div",{className:C("messaging-channel-list h-full flex flex-col min-w-0 overflow-hidden",o),children:e.jsx("div",{className:"flex-1 overflow-hidden min-w-0",children:e.jsx(Tn,{value:g,children:e.jsx(_.ChannelList,{filters:n,sort:i,options:{limit:30},allowNewMessagesFromUnfilteredChannels:a,channelRenderFilterFn:c,Paginator:_.InfiniteScroll,Preview:d??Xt,EmptyStateIndicator:l},`${JSON.stringify(n)}:${JSON.stringify(i)}`)})})})});Wt.displayName="ChannelList";const Ln=/^([a-z][a-z0-9+.-]*):/i,Dn=new Set(["http","https","mailto","tel","sms"]);function He(t){if(typeof t!="string")return;const s=t.trim();if(s==="")return;const n=Ln.exec(s);if(n){const a=n[1].toLowerCase();return Dn.has(a)?s:void 0}return s.startsWith("//")||s.startsWith("/")?s:`https://${s}`}const Pn={dark:"bg-white text-[#121110] hover:bg-white/90",light:"bg-[#121110] text-white hover:bg-[#2a2928]"},zn=({variant:t,cta:s})=>{const n=C("mt-2 inline-flex h-10 w-full items-center justify-center rounded-full px-4 text-sm font-medium leading-none transition-colors",Pn[t]),a=He(s.href);return a?e.jsx("a",{href:a,target:"_blank",rel:"noopener noreferrer",onClick:r=>{var i;r.stopPropagation(),(i=s.onClick)==null||i.call(s)},className:`${n} no-underline`,children:s.label}):e.jsx("button",{type:"button",onClick:r=>{var i;r.stopPropagation(),(i=s.onClick)==null||i.call(s)},className:n,children:s.label})},On={dark:"text-white",light:"text-black/90"},Fn="text-white/30",$n={dark:"text-white/55",light:"text-black/55"},Ye=({variant:t,title:s,placeholderTitle:n,description:a,url:r,appIcon:i,cta:o,trailingAction:l})=>{const d=t==="dark",h=s??(d?n:void 0)??"",f=h.trim()!=="",u=a!=null&&a.trim()!=="",x=typeof r=="string"?r.trim():"",c=x!=="",g=o!=null;if(!f&&!u&&!c&&!g)return null;const j=C("truncate text-base font-medium leading-6",d&&!s?Fn:On[t]),p=C("truncate text-xs leading-4",$n[t]);return e.jsxs("div",{className:"px-4 py-3",children:[e.jsxs("div",{className:"flex items-end gap-3",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-2",children:[e.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[f&&e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[i?e.jsx("span",{className:"shrink-0",children:i}):null,e.jsx("p",{className:C("min-w-0",j),children:h})]}),u&&e.jsx("p",{className:p,children:a})]}),!g&&c&&e.jsx("p",{className:p,children:x})]}),l&&e.jsx("div",{className:"shrink-0",children:l})]}),o&&e.jsx(zn,{variant:t,cta:o})]})},Bn=C("relative block w-[280px] select-none overflow-hidden rounded-md","border border-black/[0.08]","shadow-[0_1px_2px_rgba(0,0,0,0.04),0_8px_32px_rgba(0,0,0,0.1)]"),je=({variant:t,children:s,href:n,onClick:a,ariaLabel:r,rootRef:i,topRight:o,bgClassName:l,"data-testid":d})=>{const h=n!=null||a!=null,f=C(Bn,l??(t==="dark"?"bg-[#121110]":"bg-white"),h?"cursor-pointer no-underline focus-ring":null),u=o?e.jsx("div",{className:"pointer-events-auto absolute right-3 top-3 z-10",children:o}):null;return n?e.jsxs("a",{ref:i,href:n,target:"_blank",rel:"noopener noreferrer",onClick:a,"data-testid":d,className:f,children:[s,u]}):a?e.jsxs("button",{ref:i,type:"button",onClick:a,"aria-label":r,"data-testid":d,className:C(f,"text-left"),children:[s,u]}):e.jsxs("div",{ref:i,"data-testid":d,className:f,children:[s,u]})},Un={dark:"bg-white/10",light:"bg-black/5"},Vn={dark:"size-16 text-white/25",light:"size-16 text-black/25"},ye=(t,s)=>!!s&&!!t&&te(t)==="audio",Kt=(t,s)=>{if(!s||!t)return!1;const n=te(t);return n==="video"||n==="audio"},qe="bg-[#F2F3F4]",we=({variant:t,thumbnailUrl:s,sourceUrl:n,title:a,mimeType:r="image/*",topLeft:i,topRight:o})=>{const l=te(r),d=!!n&&l==="video";return ye(r,n)?e.jsx("div",{className:"p-3",children:e.jsx("audio",{src:n,controls:!0,preload:"metadata",className:"block w-full",children:e.jsx("track",{kind:"captions"})})}):e.jsxs("div",{className:C("relative h-[180px] w-full overflow-hidden",d&&"bg-black"),children:[d?e.jsx("video",{src:n,poster:s,controls:!0,playsInline:!0,preload:"metadata",className:"absolute inset-0 h-full w-full object-contain",children:e.jsx("track",{kind:"captions"})}):s?e.jsx("img",{src:s,alt:a??"",draggable:!1,className:"absolute inset-0 h-full w-full object-cover"}):e.jsx("div",{className:C("flex h-full w-full items-center justify-center",Un[t]),children:ne(r,{className:Vn[t],weight:"regular"})}),i?e.jsx("div",{className:"pointer-events-auto absolute left-3 top-3 z-10",children:i}):null,o?e.jsx("div",{className:"pointer-events-auto absolute right-3 top-3 z-10",children:o}):null]})},Gn=({title:t,placeholderTitle:s,description:n,url:a,mimeType:r,thumbnailUrl:i,sourceUrl:o,layout:l="featured",appIcon:d,cta:h,onDismiss:f,onEditClick:u})=>{const x=l==="classic",c=ye(r,o),g=f?e.jsx("button",{type:"button",onClick:f,"aria-label":"Dismiss attachment",className:"flex size-6 items-center justify-center rounded-full bg-[#121110] text-white",children:e.jsx(w.XIcon,{className:"size-3",weight:"bold"})}):void 0,N=u?e.jsx("button",{type:"button",onClick:u,"aria-label":"Edit attachment",className:"flex size-10 items-center justify-center rounded-full bg-white/10 text-white hover:bg-white/15",children:e.jsx(w.PencilSimpleIcon,{className:"size-5",weight:"regular"})}):void 0;return c?e.jsx(je,{variant:"dark",bgClassName:qe,children:e.jsxs("div",{className:"flex items-center gap-2 pr-3",children:[e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx(we,{variant:"dark",sourceUrl:o,title:t,mimeType:r})}),g&&e.jsx("div",{className:"shrink-0",children:g})]})}):e.jsxs(je,{variant:"dark",topRight:x?g:void 0,children:[!x&&e.jsx(we,{variant:"dark",thumbnailUrl:i,sourceUrl:o,title:t,mimeType:r,topRight:g}),e.jsx(Ye,{variant:"dark",title:t,placeholderTitle:s,description:n,url:a,appIcon:d,cta:h,trailingAction:N})]})},Hn=({title:t,description:s,url:n,mimeType:a,thumbnailUrl:r,sourceUrl:i,layout:o="featured",appIcon:l,cta:d,onClick:h})=>{const f=Kt(a,i),u=He(n),x=d==null&&u!=null&&!f?u:void 0,c=d==null&&!f?h:void 0,g=ye(a,i)?qe:void 0,N=d&&h?{...d,onClick:()=>{var j;h(),(j=d.onClick)==null||j.call(d)}}:d;return e.jsxs(je,{variant:"light",href:x,onClick:c,ariaLabel:t??"Open attachment preview",bgClassName:g,"data-testid":"link-attachment",children:[o==="featured"&&e.jsx(we,{variant:"light",thumbnailUrl:r,sourceUrl:i,title:t,mimeType:a}),e.jsx(Ye,{variant:"light",title:t,description:s,url:n,appIcon:l,cta:N})]})},Yn=({title:t,placeholderTitle:s,description:n,url:a,mimeType:r,thumbnailUrl:i,sourceUrl:o,layout:l="featured",appIcon:d,cta:h,onClick:f})=>{const u=Kt(r,o),x=He(a),c=h==null&&x!=null&&!u?x:void 0,g=h==null&&!u&&c!=null?f:void 0;return e.jsxs(je,{variant:"dark",href:c,onClick:g,bgClassName:ye(r,o)?qe:void 0,children:[l==="featured"&&e.jsx(we,{variant:"dark",thumbnailUrl:i,sourceUrl:o,title:t,mimeType:r}),e.jsx(Ye,{variant:"dark",title:t,placeholderTitle:s,description:n,url:a,appIcon:d,cta:h})]})},qn={Composer:Gn,Sent:Yn,Received:Hn},Xn={dark:"bg-[#121110]",light:"bg-[#e9eaed]"},Wn={dark:"text-white",light:"text-[#080707]"},Kn={dark:"border-white/[0.08]",light:"border-black/[0.08]"},Jn=t=>t==="dark"?"sender":"receiver",Zn={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]"}},me=({variant:t,text:s,bordered:n=!0,groupPosition:a="single",className:r,children:i,"data-testid":o})=>{const l=s!=null&&s!=="",d=Zn[Jn(t)][a];return e.jsxs("div",{"data-testid":o,"data-group-position":a,className:C("relative w-[280px] overflow-hidden px-2 py-2",d,Xn[t],Wn[t],n&&"border",n&&Kn[t],r),children:[i,l?e.jsx("p",{className:C("whitespace-pre-wrap break-words leading-snug","pt-2","px-2"),children:s}):null]})},he=({onClick:t,variant:s="overlay",ariaLabel:n="Dismiss attachment"})=>e.jsx("button",{type:"button",onClick:a=>{a.stopPropagation(),t()},"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:e.jsx(w.XIcon,{className:"size-3",weight:"bold"})}),xe=t=>t==="received"?"light":"dark",Qn=({firstOfGroup:t,endOfGroup:s,groupedByUser:n})=>!n||t&&s?"single":t?"first":s?"end":"middle",ea=({src:t,mimeType:s,filename:n,items:a})=>a&&a.length>0?a:t?[{src:t,mimeType:s,filename:n}]:[],ta=({item:t,preload:s,trailingAction:n})=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("audio",{src:t.src,controls:!0,preload:t.preload??s,className:"block min-w-0 flex-1",children:t.mimeType?e.jsx("source",{src:t.src,type:t.mimeType}):null}),n??null]}),Xe=({state:t,src:s,mimeType:n,filename:a,items:r,text:i,groupPosition:o,preload:l,onDismiss:d})=>{const h=xe(t),f=t==="composer"&&!!d,u=ea({src:s,mimeType:n,filename:a,items:r});if(u.length===0)return null;const x=l??(u.length>1?"none":"metadata");return e.jsx(me,{variant:h,text:i,groupPosition:o,"data-testid":"audio-attachment",children:e.jsx("div",{className:"flex flex-col gap-2",children:u.map((c,g)=>e.jsx(ta,{item:c,preload:x,trailingAction:f&&g===0?e.jsx(he,{onClick:d,variant:"inline"}):void 0},`${c.src}-${g}`))})})},sa=t=>e.jsx(Xe,{...t,state:"composer"}),na=t=>e.jsx(Xe,{...t,state:"sent"}),aa=t=>e.jsx(Xe,{...t,state:"received"}),ra={Composer:sa,Sent:na,Received:aa};function Jt(t){return!Number.isFinite(t)||t<0?"":t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:t<1024*1024*1024?`${(t/(1024*1024)).toFixed(2)} MB`:`${(t/(1024*1024*1024)).toFixed(2)} GB`}const ia={pdf:"PDF",doc:"DOC",xls:"XLS",csv:"CSV",ppt:"PPT",zip:"ZIP",text:"TXT",markdown:"MD"};function Zt(t,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(!t)return;if(te(t)==="document"){const r=Lt(t),i=ia[r];if(i)return i;if(t==="application/octet-stream")return}const a=t.split("/")[1];if(!(!a||a==="*"))return a.toUpperCase()}function Qt(t,s,n){const a=Zt(t,s),r=typeof n=="number"&&n>0?Jt(n):void 0;return[a,r].filter(Boolean).join(" · ")||void 0}function ee(t){try{const n=new URL(t).pathname.split("/").pop();return n&&n.length>0?decodeURIComponent(n):"download"}catch{return"download"}}const oa={dark:"text-white/55",light:"text-black/65"},la={dark:"bg-white/10",light:"bg-black/5"},ca={dark:"text-white/85",light:"text-black/85"},es=({variant:t,filename:s,title:n,mimeType:a="application/octet-stream",fileSize:r,onActivate:i,activateLabel:o,trailingAction:l})=>{const d=n??s??"File",h=Qt(a,s,r),f=e.jsx("div",{className:C("flex size-10 shrink-0 items-center justify-center rounded-sm",la[t]),"aria-hidden":!0,children:ne(a,{className:C("size-6",ca[t]),weight:"regular"})}),u=e.jsxs("div",{className:"flex min-w-0 flex-1 flex-col text-left",children:[e.jsx("p",{className:"truncate font-medium leading-snug",children:d}),h?e.jsx("p",{className:C("truncate text-xs leading-4",oa[t]),children:h}):null]}),x=i?e.jsxs("button",{type:"button",onClick:i,"aria-label":o,className:C("flex min-w-0 flex-1 items-center gap-3 rounded-sm text-left transition-colors",t==="dark"?"hover:bg-white/[0.04]":"hover:bg-black/[0.04]"),children:[f,u]}):e.jsxs(e.Fragment,{children:[f,u]});return e.jsxs("div",{className:"flex items-center gap-3 px-3 py-2",children:[x,l?e.jsx("div",{className:"shrink-0",children:l}):null]})};async function ts(t,s){const n=s??ee(t);try{const a=await fetch(t,{mode:"cors"});if(!a.ok)throw new Error(`HTTP ${a.status}`);const r=await a.blob(),i=URL.createObjectURL(r),o=document.createElement("a");o.href=i,o.download=n,o.style.display="none",document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(i)}catch{if(!window.open(t,"_blank","noopener,noreferrer")){const r=document.createElement("a");r.href=t,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 da=({src:t,filename:s,fileSize:n,mimeType:a,title:r,items:i})=>i&&i.length>0?i:t?[{src:t,filename:s,fileSize:n,mimeType:a,title:r}]:[],ua=({variant:t,item:s,index:n,onActivate:a,trailingAction:r})=>{const i=s.filename??ee(s.src);return e.jsx(es,{variant:t,filename:i,title:s.title,mimeType:s.mimeType??"application/octet-stream",fileSize:s.fileSize,onActivate:()=>a(n),activateLabel:`Download ${i}`,trailingAction:r})},We=({state:t,src:s,filename:n,fileSize:a,mimeType:r,title:i,items:o,text:l,groupPosition:d,onClick:h,onDismiss:f})=>{const u=xe(t),x=t==="composer"&&!!f,c=da({src:s,filename:n,fileSize:a,mimeType:r,title:i,items:o}),g=j=>{if((h==null?void 0:h(j))===!1)return;const p=c[j];if(!p)return;const b=p.filename??ee(p.src);ts(p.src,b)};if(c.length===0)return null;const N=e.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:e.jsx(w.DownloadSimpleIcon,{className:"size-5",weight:"bold"})});return e.jsx(me,{variant:u,text:l,groupPosition:d,"data-testid":"file-attachment",children:e.jsx("div",{className:"flex flex-col gap-2",children:c.map((j,p)=>{const b=x&&p===0?e.jsx(he,{onClick:f,variant:"inline"}):N;return e.jsx(ua,{variant:u,item:j,index:p,onActivate:g,trailingAction:b},`${j.src}-${p}`)})})})},ma=t=>e.jsx(We,{...t,state:"composer"}),ha=t=>e.jsx(We,{...t,state:"sent"}),xa=t=>e.jsx(We,{...t,state:"received"}),fa={Composer:ma,Sent:ha,Received:xa},Ke=({onPrev:t,onNext:s,prevLabel:n="Previous",nextLabel:a="Next"})=>e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:t,"aria-label":n,className:"mes-media-viewer__nav mes-media-viewer__nav--prev",children:e.jsx(w.CaretLeftIcon,{size:20,weight:"bold","aria-hidden":!0})}),e.jsx("button",{type:"button",onClick:s,"aria-label":a,className:"mes-media-viewer__nav mes-media-viewer__nav--next",children:e.jsx(w.CaretRightIcon,{size:20,weight:"bold","aria-hidden":!0})})]}),ss=({url:t,filename:s,variant:n="pill",label:a="Download",iconOnly:r,tone:i="dark",onTriggered:o})=>{const[l,d]=m.useState(!1),h=m.useCallback(c=>{c.stopPropagation(),!l&&(d(!0),ts(t,s).catch(()=>{}).finally(()=>{d(!1),o==null||o()}))},[l,t,s,o]),f=r??n!=="pill",x={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 e.jsx("button",{type:"button",onClick:h,disabled:l,"aria-label":a,className:C("flex size-8 shrink-0 items-center justify-center rounded-full transition-colors disabled:opacity-70",c[i]),children:l?e.jsx(w.CircleNotchIcon,{className:"size-4 animate-spin",weight:"bold","aria-hidden":!0}):e.jsx(w.DownloadSimpleIcon,{className:"size-5 shrink-0",weight:"bold","aria-hidden":!0})})}return n==="viewer"?e.jsx("button",{type:"button",onClick:h,disabled:l,"aria-label":a,className:"mes-media-viewer__action",children:l?e.jsx(w.CircleNotchIcon,{size:20,weight:"bold","aria-hidden":!0}):e.jsx(w.DownloadSimpleIcon,{size:20,weight:"bold","aria-hidden":!0})}):e.jsxs("button",{type:"button",onClick:h,disabled:l,"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:[l?e.jsx(w.CircleNotchIcon,{className:"size-4 animate-spin",weight:"bold","aria-hidden":!0}):e.jsx(w.DownloadSimpleIcon,{...x,"aria-hidden":!0}),f?null:a]})},Ee=(t,s,n)=>Math.min(Math.max(t,s),n),Je=({length:t,initialIndex:s,open:n})=>{const a=Ee(s,0,Math.max(t-1,0)),[r,i]=m.useState(a);m.useEffect(()=>{n&&i(Ee(s,0,Math.max(t-1,0)))},[n,s,t]),m.useEffect(()=>{i(d=>Ee(d,0,Math.max(t-1,0)))},[t]);const o=m.useCallback(()=>{t<=1||i(d=>d<=0?t-1:d-1)},[t]),l=m.useCallback(()=>{t<=1||i(d=>d>=t-1?0:d+1)},[t]);return m.useEffect(()=>{if(!n||t<=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"?o():l())};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[n,t,o,l]),{index:r,prev:o,next:l}},Ze=({open:t,onClose:s,ariaLabel:n,counter:a,actions:r,children:i,"data-testid":o})=>{const l=m.useRef(null),d=m.useRef(null);m.useEffect(()=>{var x;const u=l.current;if(u){if(t){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(x=d.current)==null||x.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")}},[t]);const h=()=>{s()},f=u=>{u.target===l.current&&s()};return e.jsxs("dialog",{ref:l,className:"mes-media-viewer","aria-label":n??"Attachment viewer","data-testid":o,onClose:h,onClick:f,children:[e.jsxs("div",{className:"mes-media-viewer__chrome",children:[a?e.jsx("span",{className:"mes-media-viewer__counter",children:a}):null,e.jsxs("div",{className:"mes-media-viewer__actions",children:[r,e.jsx("button",{ref:d,type:"button",onClick:s,"aria-label":"Close viewer",className:"mes-media-viewer__action",children:e.jsx(w.XIcon,{size:20,weight:"bold","aria-hidden":!0})})]})]}),e.jsx("div",{className:"mes-media-viewer__body",children:i})]})},ns=({open:t,items:s,initialIndex:n=0,onClose:a})=>{const{index:r,prev:i,next:o}=Je({length:s.length,initialIndex:n,open:t}),l=s[r],d=m.useMemo(()=>(l==null?void 0:l.filename)??(l?ee(l.src):"image"),[l]);return l?e.jsxs(Ze,{open:t,onClose:a,ariaLabel:d,counter:s.length>1?`${r+1} / ${s.length}`:void 0,actions:e.jsx(ss,{url:l.src,filename:d,variant:"viewer",label:`Download ${d}`}),"data-testid":"image-viewer",children:[e.jsx("img",{src:l.src,alt:l.alt??d,draggable:!1,loading:"eager",decoding:"async",className:"mes-media-viewer__image"},`${r}:${l.src}`),s.length>1?e.jsx(Ke,{onPrev:i,onNext:o,prevLabel:"Previous image",nextLabel:"Next image"}):null]}):null},ga="relative block size-full overflow-hidden bg-black/5 outline-none focus-visible:ring-2 focus-visible:ring-white/80 focus-visible:ring-offset-2 focus-visible:ring-offset-black",as=({tiles:t,onTileActivate:s,maxVisible:n=4,className:a})=>{const r=t.length;if(r===0)return null;const i=t.slice(0,Math.min(r,n)),o=r-i.length,l=(d,h,f)=>{const u=C(ga,"h-full w-full");return s?e.jsxs("button",{type:"button",onClick:()=>s(h),"aria-label":d.ariaLabel??`Open media ${h+1}`,className:C(u,"cursor-zoom-in"),children:[d.content,f]},h):e.jsxs("div",{className:u,children:[d.content,f]},h)};return i.length===1?e.jsx("div",{className:C("aspect-square w-full",a),children:l(i[0],0)}):i.length===2?e.jsx("div",{className:C("grid aspect-[16/9] w-full grid-cols-2 gap-0.5",a),children:i.map((d,h)=>l(d,h))}):i.length===3?e.jsxs("div",{className:C("grid aspect-[4/3] w-full grid-cols-2 grid-rows-2 gap-0.5",a),children:[e.jsx("div",{className:"row-span-2",children:l(i[0],0)}),l(i[1],1),l(i[2],2)]}):e.jsx("div",{className:C("grid aspect-[4/3] w-full grid-cols-2 grid-rows-2 gap-0.5",a),children:i.map((d,h)=>{const f=o>0&&h===i.length-1;return l(d,h,f?e.jsxs("div",{className:"absolute inset-0 flex items-center justify-center bg-black/55 text-2xl font-semibold text-white",children:["+",o]}):null)})})},fe=t=>{const[s,n]=m.useState(!1),[a,r]=m.useState(0),i=m.useCallback(l=>{(t==null?void 0:t(l))!==!1&&(r(l),n(!0))},[t]),o=m.useCallback(()=>n(!1),[]);return{viewerOpen:s,viewerIndex:a,handleActivate:i,closeViewer:o}},ba=(t,s,n,a)=>({ariaLabel:`Open image ${s+1} of ${n}`,content:e.jsx("img",{src:t.src,alt:t.alt??"",width:t.width,height:t.height,draggable:!1,loading:t.loading??a,decoding:"async",className:"absolute inset-0 size-full rounded-md object-cover"})}),pa=({src:t,alt:s,items:n})=>n&&n.length>0?n:t?[{src:t,alt:s}]:[],rs=(t,s)=>t.map((n,a)=>({src:n.src,alt:n.alt,filename:s&&t.length===1?s:s?`${s} (${a+1})`:void 0})),va=({src:t,alt:s,filename:n,loading:a="lazy",onClick:r,onDismiss:i})=>{const{viewerOpen:o,viewerIndex:l,handleActivate:d,closeViewer:h}=fe(r);return e.jsxs("div",{className:"relative w-fit",children:[e.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:e.jsx("img",{src:t,alt:s??"",draggable:!1,loading:a,decoding:"async",className:"size-full object-cover"})}),i?e.jsx("div",{className:"absolute right-2 top-2 z-10",children:e.jsx(he,{onClick:i})}):null,e.jsx(ns,{open:o,items:rs([{src:t,alt:s}],n),initialIndex:l,onClose:h})]})},is=({state:t,src:s,alt:n,filename:a,items:r,text:i,groupPosition:o,loading:l="lazy",onClick:d})=>{const h=pa({src:s,alt:n,items:r}),f=xe(t),{viewerOpen:u,viewerIndex:x,handleActivate:c,closeViewer:g}=fe(d);if(h.length===0)return null;const N=h.map((j,p)=>ba(j,p,h.length,l));return e.jsxs(me,{variant:f,text:i,groupPosition:o,"data-testid":"image-attachment",children:[e.jsx("div",{className:"relative",children:e.jsx(as,{tiles:N,onTileActivate:c})}),e.jsx(ns,{open:u,items:rs(h,a),initialIndex:x,onClose:g})]})},ja=t=>e.jsx(va,{...t}),wa=t=>e.jsx(is,{...t,state:"sent"}),Na=t=>e.jsx(is,{...t,state:"received"}),_a={Composer:ja,Sent:wa,Received:Na},ya=({open:t,items:s,initialIndex:n=0,onClose:a})=>{const{index:r,prev:i,next:o}=Je({length:s.length,initialIndex:n,open:t}),l=s[r],d=m.useMemo(()=>(l==null?void 0:l.filename)??(l?ee(l.src):"document"),[l]),h=m.useMemo(()=>l?Ca(l.src):void 0,[l]);return!l||!h?null:e.jsxs(Ze,{open:t,onClose:a,ariaLabel:d,counter:s.length>1?`${r+1} / ${s.length}`:void 0,"data-testid":"pdf-viewer",children:[e.jsx("iframe",{src:h,title:d,className:"mes-media-viewer__iframe",sandbox:"allow-scripts allow-forms allow-popups allow-downloads"},`${r}:${l.src}`),s.length>1?e.jsx(Ke,{onPrev:i,onNext:o,prevLabel:"Previous document",nextLabel:"Next document"}):null]})},Ca=t=>{const s=t.indexOf("#"),n=s===-1?t:t.slice(0,s),a=s===-1?"":t.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()}`},ka=({src:t,filename:s,fileSize:n,title:a,items:r})=>r&&r.length>0?r:t?[{src:t,filename:s,fileSize:n,title:a}]:[],Sa=({variant:t,item:s,index:n,onActivate:a,trailingAction:r})=>{const i=s.filename??ee(s.src);return e.jsx(es,{variant:t,filename:i,title:s.title,mimeType:"application/pdf",fileSize:s.fileSize,onActivate:()=>a(n),activateLabel:`Open ${i}`,trailingAction:r})},Qe=({state:t,src:s,filename:n,fileSize:a,title:r,items:i,text:o,groupPosition:l,onClick:d,onDismiss:h})=>{const f=xe(t),u=ka({src:s,filename:n,fileSize:a,title:r,items:i}),{viewerOpen:x,viewerIndex:c,handleActivate:g,closeViewer:N}=fe(d),j=t==="composer"&&!!h;if(u.length===0)return null;const p=u.map(b=>({src:b.src,filename:b.filename??ee(b.src)}));return e.jsxs(me,{variant:f,text:o,groupPosition:l,"data-testid":"pdf-attachment",children:[e.jsx("div",{className:"flex flex-col gap-2",children:u.map((b,R)=>{const I=b.filename??ee(b.src),E=j&&R===0?e.jsx(he,{onClick:h,variant:"inline"}):t==="composer"?void 0:e.jsx(ss,{url:b.src,filename:I,variant:"inline",label:`Download ${I}`,tone:f});return e.jsx(Sa,{variant:f,item:b,index:R,onActivate:g,trailingAction:E},`${b.src}-${R}`)})}),e.jsx(ya,{open:x,items:p,initialIndex:c,onClose:N})]})},Ia=t=>e.jsx(Qe,{...t,state:"composer"}),Ea=t=>e.jsx(Qe,{...t,state:"sent"}),Ta=t=>e.jsx(Qe,{...t,state:"received"}),Ma={Composer:Ia,Sent:Ea,Received:Ta},os=({open:t,items:s,initialIndex:n=0,onClose:a})=>{const{index:r,prev:i,next:o}=Je({length:s.length,initialIndex:n,open:t}),l=s[r],d=m.useMemo(()=>(l==null?void 0:l.filename)??(l?ee(l.src):"video"),[l]);return l?e.jsxs(Ze,{open:t,onClose:a,ariaLabel:d,counter:s.length>1?`${r+1} / ${s.length}`:void 0,"data-testid":"video-viewer",children:[e.jsx("video",{src:l.src,poster:l.poster,controls:!0,autoPlay:!0,muted:!0,playsInline:!0,preload:l.preload??"metadata",className:"mes-media-viewer__video",children:l.mimeType?e.jsx("source",{src:l.src,type:l.mimeType}):null},`${r}:${l.src}`),s.length>1?e.jsx(Ke,{onPrev:i,onNext:o,prevLabel:"Previous video",nextLabel:"Next video"}):null]}):null},Ra=()=>e.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center",children:e.jsx("span",{className:"flex size-12 items-center justify-center rounded-full bg-black/55 text-white backdrop-blur",children:e.jsx(w.PlayIcon,{className:"size-6",weight:"fill","aria-hidden":!0})})}),ls=({item:t,index:s})=>e.jsxs("div",{className:"absolute inset-0 size-full bg-[#0d0d0d]",children:[t.poster?e.jsx("img",{src:t.poster,alt:`Video ${s+1} thumbnail`,draggable:!1,loading:"lazy",decoding:"async",className:"absolute inset-0 size-full rounded-md object-cover"}):e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsx(w.VideoCameraIcon,{className:"size-16 rounded-md text-white/30",weight:"regular","aria-hidden":!0})}),e.jsx(Ra,{})]}),Aa=(t,s,n)=>({ariaLabel:`Play video ${s+1} of ${n}`,content:e.jsx(ls,{item:t,index:s})}),La=({src:t,poster:s,mimeType:n,preload:a,items:r})=>r&&r.length>0?a?r.map(i=>({...i,preload:i.preload??a})):r:t?[{src:t,poster:s,mimeType:n,preload:a}]:[],cs=(t,s)=>t.map((n,a)=>({src:n.src,poster:n.poster,mimeType:n.mimeType,preload:n.preload,filename:s&&t.length===1?s:s?`${s} (${a+1})`:void 0})),Da=({src:t,poster:s,mimeType:n,filename:a,preload:r,onClick:i,onDismiss:o})=>{const{viewerOpen:l,viewerIndex:d,handleActivate:h,closeViewer:f}=fe(i);return e.jsxs("div",{className:"relative w-fit",children:[e.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:e.jsx(ls,{item:{src:t,poster:s,mimeType:n},index:0})}),o?e.jsx("div",{className:"absolute right-2 top-2 z-10",children:e.jsx(he,{onClick:o})}):null,e.jsx(os,{open:l,items:cs([{src:t,poster:s,mimeType:n,preload:r}],a),initialIndex:d,onClose:f})]})},ds=({state:t,src:s,poster:n,mimeType:a,filename:r,items:i,text:o,groupPosition:l,preload:d,onClick:h})=>{const f=La({src:s,poster:n,mimeType:a,preload:d,items:i}),u=xe(t),{viewerOpen:x,viewerIndex:c,handleActivate:g,closeViewer:N}=fe(h);if(f.length===0)return null;const j=f.map((p,b)=>Aa(p,b,f.length));return e.jsxs(me,{variant:u,text:o,groupPosition:l,"data-testid":"video-attachment",children:[e.jsx("div",{className:"relative",children:e.jsx(as,{tiles:j,onTileActivate:g,className:"overflow-hidden rounded-md"})}),e.jsx(os,{open:x,items:cs(f,r),initialIndex:c,onClose:N})]})},Pa=t=>e.jsx(Da,{...t}),za=t=>e.jsx(ds,{...t,state:"sent"}),Oa=t=>e.jsx(ds,{...t,state:"received"}),Fa={Composer:Pa,Sent:za,Received:Oa},$a={Image:_a,Video:Fa,Audio:ra,Pdf:Ma,File:fa},us=({question:t,onClick:s,loading:n=!1,className:a})=>e.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:t}),Ba=({faqs:t,onFaqClick:s,loadingFaqId:n,headerText:a,className:r,avatarImage:i,avatarName:o})=>{const l=t.filter(d=>d.enabled).sort((d,h)=>(d.order??0)-(h.order??0));return l.length===0?null:e.jsx("div",{className:r,children:e.jsxs("div",{className:"flex gap-3 items-end",children:[(i||o)&&e.jsx("div",{className:"flex-none",children:e.jsx(Q,{id:o||"account",name:o||"Account",image:i,size:24,shape:"circle"})}),e.jsxs("div",{className:"flex-1 flex flex-col gap-3 rounded-lg p-4",style:{backgroundColor:"#F1F0EE"},children:[a&&e.jsx("p",{className:"text-md text-charcoal mb-4",children:a}),l.map(d=>e.jsx(us,{question:d.question,onClick:()=>s(d.id),loading:n===d.id},d.id))]})]})})};exports.ActionButton=re;exports.AttachmentThumbnail=Fe;exports.Avatar=Q;exports.ChannelEmptyState=Gt;exports.ChannelList=Wt;exports.ChannelView=Ge;exports.CustomMessageProvider=qs;exports.FaqList=Ba;exports.FaqListItem=us;exports.LinkAttachment=qn;exports.LockedAttachment=Ae;exports.MediaMessage=Gs;exports.MessageAttachment=$a;exports.MessageVoteButtons=Ut;exports.MessagingProvider=hs;exports.MessagingShell=In;exports.bubbleGroupPositionFromStream=Qn;exports.buildCompactMetaLabel=Qt;exports.formatFileSize=Jt;exports.formatRelativeTime=qt;exports.getFileExtensionLabel=Zt;exports.getMessageDisplayText=ze;exports.getSourceType=te;exports.isLinkAttachment=Ue;exports.isUuidLike=Et;exports.normalizeLanguageCode=Mt;exports.renderTypeIcon=ne;exports.resolveLinkAttachment=Ne;exports.resolveMediaFromMessage=_e;exports.resolveParticipantDisplayName=Pe;exports.useComposerLocked=cn;exports.useCustomMessage=$t;exports.useMessageVote=Tt;exports.useMessaging=St;
|
|
2
|
-
//# sourceMappingURL=index-DzOA7Yu8.cjs.map
|