@linktr.ee/messaging-react 4.1.8-rc-1787282974 → 4.1.8
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-DJ0YiWXB.js → Card-B5YUxWCs.js} +2 -2
- package/dist/{Card-DJ0YiWXB.js.map → Card-B5YUxWCs.js.map} +1 -1
- package/dist/{Card-DOAG1fie.cjs → Card-DjafcNS_.cjs} +2 -2
- package/dist/{Card-DOAG1fie.cjs.map → Card-DjafcNS_.cjs.map} +1 -1
- package/dist/index-Bwjn-YoV.cjs +3 -0
- package/dist/index-Bwjn-YoV.cjs.map +1 -0
- package/dist/{index-B6hhiZHx.js → index-l73T0G4A.js} +403 -403
- package/dist/index-l73T0G4A.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/package.json +2 -2
- package/src/components/AttachmentCard/AttachmentCard.stories.tsx +0 -36
- package/src/components/AttachmentCard/Thumbnail.tsx +2 -2
- package/dist/index-B50WBNpA.cjs +0 -3
- package/dist/index-B50WBNpA.cjs.map +0 -1
- package/dist/index-B6hhiZHx.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-Bwjn-YoV.cjs");exports.ActionButton=e.ActionButton;exports.Avatar=e.Avatar;exports.ChannelEmptyState=e.ChannelEmptyState;exports.ChannelList=e.ChannelList;exports.ChannelView=e.ChannelView;exports.CustomMessageProvider=e.CustomMessageProvider;exports.FaqList=e.FaqList;exports.FaqListItem=e.FaqListItem;exports.LinkAttachment=e.LinkAttachment;exports.LockedAttachment=e.LockedAttachment;exports.MediaMessage=e.MediaMessage;exports.MessageAttachment=e.MessageAttachment;exports.MessageBubble=e.MessageBubble;exports.MessagingProvider=e.MessagingProvider;exports.MessagingShell=e.MessagingShell;exports.RichCard=e.RichCard;exports.TipMessage=e.TipMessage;exports.buildCompactMetaLabel=e.buildCompactMetaLabel;exports.formatFileSize=e.formatFileSize;exports.formatRelativeTime=e.formatRelativeTime;exports.getFileExtensionLabel=e.getFileExtensionLabel;exports.getMessageDisplayText=e.getMessageDisplayText;exports.isLinkAttachment=e.isLinkAttachment;exports.isTipMessage=e.isTipMessage;exports.isUuidLike=e.isUuidLike;exports.messageAttachmentGroupPositionFromStream=e.bubbleGroupPositionFromStream;exports.normalizeLanguageCode=e.normalizeLanguageCode;exports.optimizeMessagingAttachmentUrl=e.optimizeMessagingAttachmentUrl;exports.resolveConversationParticipant=e.resolveConversationParticipant;exports.resolveLinkAttachment=e.resolveLinkAttachment;exports.resolveMediaFromMessage=e.resolveMediaFromMessage;exports.resolveParticipantDisplayName=e.resolveParticipantDisplayName;exports.useComposerLocked=e.useComposerLocked;exports.useCustomMessage=e.useCustomMessage;exports.useMessaging=e.useMessaging;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as e, b as t, C as i, c as n, d as o, e as m, F as r, f as g, L as l, h as M, M as c, i as h, j as p, k as L, l as u, R as d, T as C, m as v, n as A, p as k, q as F, s as b, t as P, u as T, v as f, w as x, x as y, o as z, y as S, z as q, B, D, E, G as R, H as w } from "./index-
|
|
1
|
+
import { a as e, b as t, C as i, c as n, d as o, e as m, F as r, f as g, L as l, h as M, M as c, i as h, j as p, k as L, l as u, R as d, T as C, m as v, n as A, p as k, q as F, s as b, t as P, u as T, v as f, w as x, x as y, o as z, y as S, z as q, B, D, E, G as R, H as w } from "./index-l73T0G4A.js";
|
|
2
2
|
export {
|
|
3
3
|
e as ActionButton,
|
|
4
4
|
t as Avatar,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@linktr.ee/messaging-react",
|
|
3
|
-
"version": "4.1.8
|
|
3
|
+
"version": "4.1.8",
|
|
4
4
|
"description": "React messaging components built on messaging-core for web applications",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"chromatic:local": "yarn storybook:build && chromatic"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@linktr.ee/messaging-core": "2.5.0
|
|
53
|
+
"@linktr.ee/messaging-core": "^2.5.0",
|
|
54
54
|
"@linktr.ee/messaging-taxonomy": "^0.10.0",
|
|
55
55
|
"@phosphor-icons/react": "^2.1.10"
|
|
56
56
|
},
|
|
@@ -149,42 +149,6 @@ export const AllVariants: StoryFn = () => {
|
|
|
149
149
|
),
|
|
150
150
|
},
|
|
151
151
|
},
|
|
152
|
-
{
|
|
153
|
-
label: 'Contained image (dark)',
|
|
154
|
-
props: {
|
|
155
|
-
variant: 'dark',
|
|
156
|
-
title: 'portrait.jpg',
|
|
157
|
-
mimeType: 'image/jpeg',
|
|
158
|
-
detail: '1.8 MB',
|
|
159
|
-
thumbnail: (
|
|
160
|
-
<AttachmentThumbnail
|
|
161
|
-
mimeType="image/jpeg"
|
|
162
|
-
sourceUrl={IMAGE_URL}
|
|
163
|
-
title="portrait"
|
|
164
|
-
variant="dark"
|
|
165
|
-
containedImage
|
|
166
|
-
/>
|
|
167
|
-
),
|
|
168
|
-
},
|
|
169
|
-
},
|
|
170
|
-
{
|
|
171
|
-
label: 'Contained image (light)',
|
|
172
|
-
props: {
|
|
173
|
-
variant: 'light',
|
|
174
|
-
title: 'portrait.jpg',
|
|
175
|
-
mimeType: 'image/jpeg',
|
|
176
|
-
detail: '1.8 MB',
|
|
177
|
-
thumbnail: (
|
|
178
|
-
<AttachmentThumbnail
|
|
179
|
-
mimeType="image/jpeg"
|
|
180
|
-
sourceUrl={IMAGE_URL}
|
|
181
|
-
title="portrait"
|
|
182
|
-
variant="light"
|
|
183
|
-
containedImage
|
|
184
|
-
/>
|
|
185
|
-
),
|
|
186
|
-
},
|
|
187
|
-
},
|
|
188
152
|
{
|
|
189
153
|
label: 'PDF placeholder',
|
|
190
154
|
props: {
|
|
@@ -68,7 +68,7 @@ const AttachmentThumbnail: React.FC<AttachmentThumbnailProps> = ({
|
|
|
68
68
|
if (sourceUrl && sourceType === 'image') {
|
|
69
69
|
if (containedImage) {
|
|
70
70
|
return (
|
|
71
|
-
<div className=
|
|
71
|
+
<div className="relative aspect-video overflow-hidden bg-black/5">
|
|
72
72
|
<img
|
|
73
73
|
src={optimizedSourceUrl ?? sourceUrl}
|
|
74
74
|
alt={title ?? ''}
|
|
@@ -93,7 +93,7 @@ const AttachmentThumbnail: React.FC<AttachmentThumbnailProps> = ({
|
|
|
93
93
|
if (thumbnailUrl) {
|
|
94
94
|
if (containedImage) {
|
|
95
95
|
return (
|
|
96
|
-
<div className=
|
|
96
|
+
<div className="relative aspect-video overflow-hidden bg-black/5">
|
|
97
97
|
<img
|
|
98
98
|
src={optimizedThumbnailUrl ?? thumbnailUrl}
|
|
99
99
|
alt={title ?? ''}
|
package/dist/index-B50WBNpA.cjs
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
"use strict";const t=require("react/jsx-runtime"),h=require("react"),Hs=require("@linktr.ee/messaging-core"),Ie=require("stream-chat"),_=require("stream-chat-react"),W=require("@linktr.ee/messaging-taxonomy"),C=require("classnames"),S=require("@phosphor-icons/react"),Ge=require("stream-chat-react/experimental"),Zt=h.createContext({service:null,client:null,isConnected:!1,isLoading:!1,error:null,capabilities:{},refreshConnection:async()=>{},debug:!1}),Ye=()=>h.useContext(Zt),Vs=({children:e,user:s,serviceConfig:n,apiKey:a,capabilities:r={},debug:i=!1,client:l})=>{var T,k;const o=h.useCallback((E,...P)=>{i&&console.log(`🔥 [MessagingProvider] ${E}`,...P)},[i]);o("🔄 RENDER START",{userId:s==null?void 0:s.id,apiKey:(a==null?void 0:a.substring(0,8))+"...",serviceConfig:!!n,capabilities:Object.keys(r)});const[d,u]=h.useState(null),[f,m]=h.useState(null),[x,c]=h.useState(!1),[p,j]=h.useState(!1),[b,v]=h.useState(null),g=h.useRef(!1),y=h.useRef(null),w=h.useRef(n);w.current=n;const M=h.useRef(i);M.current=i;const A=h.useRef({userId:s==null?void 0:s.id,apiKey:a,serviceConfig:n,capabilities:r}),R=h.useRef(0);R.current++,o("📊 RENDER INFO",{renderCount:R.current,currentProps:{userId:s==null?void 0:s.id,apiKey:(a==null?void 0:a.substring(0,8))+"..."},propChanges:{userChanged:A.current.userId!==(s==null?void 0:s.id),apiKeyChanged:A.current.apiKey!==a,serviceConfigChanged:A.current.serviceConfig!==n,capabilitiesChanged:A.current.capabilities!==r}}),A.current={userId:s==null?void 0:s.id,apiKey:a,serviceConfig:n,capabilities:r};const z=h.useRef(null);!l&&a&&((T=z.current)==null?void 0:T.apiKey)!==a&&(z.current={apiKey:a,client:new Ie.StreamChat(a)});const F=l||(a?((k=z.current)==null?void 0:k.client)??null:null);h.useEffect(()=>{const E=R.current,P=w.current;if(l){y.current=null,u(null),m(null),c(!1),v(null),j(!1);return}if(!a||!F||!P){o("⚠️ SERVICE INIT SKIPPED",{renderCount:E,reason:"Missing apiKey, client, or serviceConfig"});return}o("🚀 CREATING SERVICE",{renderCount:E,apiKey:(a==null?void 0:a.substring(0,8))+"..."});const $=new Hs.StreamChatService({...P,apiKey:a,debug:M.current,client:F});y.current=$,u($),o("✅ SERVICE SET",{renderCount:E,serviceInstance:!!$})},[a,F,l]);const L=h.useRef(null);h.useEffect(()=>{var P,$;if(o("🔗 USER CONNECTION EFFECT TRIGGERED",{hasService:!!d,hasUser:!!s,userId:s==null?void 0:s.id,isConnecting:g.current,isConnected:x,dependencies:{service:!!d,userId:s==null?void 0:s.id}}),l)return;if(!d||!s){o("⚠️ USER CONNECTION SKIPPED","Missing service or user");return}if(g.current){o("⚠️ USER CONNECTION SKIPPED","Already connecting");return}if(((P=L.current)==null?void 0:P.serviceId)===d&&(($=L.current)==null?void 0:$.userId)===s.id){o("⚠️ USER CONNECTION SKIPPED","Already connected this user with this service");return}(async()=>{o("🚀 STARTING USER CONNECTION",{userId:s.id}),g.current=!0,j(!0),v(null);try{o("📞 CALLING SERVICE.CONNECTUSER",{userId:s.id});const U=await d.connectUser(s);m(U),c(!0),L.current={serviceId:d,userId:s.id},o("✅ USER CONNECTION SUCCESS",{userId:s.id,clientId:U.userID})}catch(U){const X=U instanceof Error?U.message:"Connection failed";v(X),o("❌ USER CONNECTION ERROR",{userId:s.id,error:X})}finally{j(!1),g.current=!1,o("🔄 USER CONNECTION FINISHED",{userId:s.id,isConnected:x})}})()},[d,s,o,x,l]),h.useEffect(()=>{const E=F;return()=>{var P;E&&(L.current=null,(P=y.current)==null||P.disconnectUser().catch(console.error))}},[F]);const I=h.useCallback(async()=>{if(o("🔄 REFRESH CONNECTION CALLED",{hasService:!!d,hasUser:!!s}),!l){if(!d||!s){o("⚠️ REFRESH CONNECTION SKIPPED","Missing service or user");return}o("🚀 STARTING CONNECTION REFRESH",{userId:s.id}),j(!0);try{o("🔌 DISCONNECTING FOR REFRESH"),await d.disconnectUser(),o("📞 RECONNECTING FOR REFRESH");const E=await d.connectUser(s);m(E),c(!0),v(null),o("✅ CONNECTION REFRESH SUCCESS",{userId:s.id})}catch(E){const P=E instanceof Error?E.message:"Refresh failed";v(P),o("❌ CONNECTION REFRESH ERROR",{userId:s.id,error:P})}finally{j(!1),o("🔄 CONNECTION REFRESH FINISHED",{userId:s.id})}}},[d,s,o,l]),O=h.useMemo(()=>(o("💫 CONTEXT VALUE MEMOIZATION",{hasService:!!d,hasClient:!!f,isConnected:x,isLoading:p,hasError:!!b,capabilitiesKeys:Object.keys(r)}),{service:l?null:d,client:l??f,isConnected:l?!0:x,isLoading:l?!1:p,error:l?null:b,capabilities:r,refreshConnection:I,debug:i}),[d,f,l,x,p,b,r,I,i,o]);return o("🔄 RENDER END",{renderCount:R.current,willRenderChat:!!F,contextValueReady:!!O}),t.jsx(Zt.Provider,{value:O,children:F?t.jsx(_.Chat,{client:F,customClasses:{channelList:"str-chat__channel-list str-chat__channel-list-react bg-transparent lg:border-r-2 border-r-0 border-[#0000000A]"},children:e}):e})},Jt=()=>Ye(),Qt=e=>{var a,r;const[s,n]=h.useState(!!((r=(a=e==null?void 0:e.state)==null?void 0:a.membership)!=null&&r.pinned_at));return h.useEffect(()=>{var l;if(!e){n(!1);return}n(!!((l=e.state.membership)!=null&&l.pinned_at));const i=o=>{var d;n(o!=null&&o.member?!!o.member.pinned_at:!!((d=e.state.membership)!=null&&d.pinned_at))};return e.on("member.updated",i),()=>{e.off("member.updated",i)}},[e]),s};function We(e,s,n){const a=Object.values(e||{});if(W.isOfficialChannel(n)){const r=a.find(i=>{var l;return((l=i.user)==null?void 0:l.id)===W.OFFICIAL_SENDER_USER_ID});if(r)return r}return a.find(r=>{var i;return((i=r.user)==null?void 0:i.id)&&r.user.id!==s})}const Gs=/^[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 es(e){return Gs.test(e.trim())}function Rt(e,s){const n=e==null?void 0:e.trim();return!n||s&&n===s||s&&n===`Follower ${s}`?!1:!es(n)}function qe(e){return Rt(e==null?void 0:e.name,e==null?void 0:e.id)?e.name.trim():Rt(e==null?void 0:e.username,e==null?void 0:e.id)?e.username.trim():"Unknown member"}const Lt=[{emoji:"🍎",bgColor:"#FFD1DD"},{emoji:"🍌",bgColor:"#FFF1C9"},{emoji:"🍇",bgColor:"#E6D9FF"},{emoji:"🍊",bgColor:"#D6F4FF"},{emoji:"🍓",bgColor:"#FFE0AE"},{emoji:"🥥",bgColor:"#F7E7D8"},{emoji:"🍒",bgColor:"#DFF4D8"},{emoji:"🥭",bgColor:"#FFD8C2"},{emoji:"🍉",bgColor:"#D6EBFF"},{emoji:"🍋",bgColor:"#CAEEB5"},{emoji:"🥝",bgColor:"#FFE7C7"},{emoji:"🫒",bgColor:"#F6E3B4"},{emoji:"🍈",bgColor:"#D9F7E1"}];function Ys(e){let s=0;for(let n=0;n<e.length;n++){const a=e.charCodeAt(n);s=(s<<5)-s+a,s=s&s}return Math.abs(s)}function ts(e){return Lt[Ys(e)%Lt.length]}function Ws(e){return ts(e).emoji}function qs(e){return ts(e).bgColor}const ue=({id:e,image:s,size:n=40,className:a,starred:r=!1,shape:i="squircle",dmAgentEnabled:l=!1})=>{const o=Ws(e),d=qs(e),u=.45,m=n<32?Math.round(n*u):n<56?14:n<120?18:36,x=n>=40?2:1,c=i==="circle"?{borderRadius:"50%"}:{borderRadius:"1rem"},p=t.jsx("div",{className:"h-full w-full overflow-hidden",style:c,children:s?t.jsx("img",{src:s,alt:"",className:"h-full w-full object-cover"}):t.jsx("div",{"aria-hidden":"true",className:C("avatar-fallback flex h-full w-full items-center justify-center font-semibold select-none transition-colors"),style:{fontSize:m,lineHeight:1},children:o})});return t.jsxs("div",{className:C("relative flex-shrink-0",a),style:{"--str-chat__avatar-size":`${n}px`,width:`${n}px`,height:`${n}px`,backgroundColor:s?void 0:d,...c},children:[r&&t.jsx("div",{"aria-hidden":"true",className:"absolute -left-1.5 -top-1.5 z-10 flex size-5 items-center justify-center rounded-full bg-white shadow-[0_0_0_1px_rgba(0,0,0,0.04),0_4px_8px_rgba(0,0,0,0.06)]",children:t.jsx(S.StarIcon,{className:"size-3 text-yellow-600",weight:"duotone"})}),t.jsx("div",{"data-testid":"avatar-ring",className:C("h-full w-full","bg-transparent"),style:{...c,...l&&{borderWidth:`${x}px`,borderStyle:"solid",borderColor:"var(--AI-Gradient, #7F22FE)",boxShadow:"inset 0 1px 2px 0 rgba(255, 255, 255, 0.5)"}},children:p})]})},Xs="https://linktr.ee/s/about/trust-center/report",Ks=({channel:e,participant:s,showBlockParticipant:n=!0,enabled:a=!0,onLeaveConversation:r,onBlockParticipant:i,onDeleteConversationClick:l,onBlockParticipantClick:o,onReportParticipantClick:d,onActionComplete:u,logLabel:f="useChannelModerationActions"})=>{var O;const{service:m,debug:x}=Ye(),c=(O=s==null?void 0:s.user)==null?void 0:O.id,p=!!(a&&n&&m&&c),[j,b]=h.useState(!1),[v,g]=h.useState(null),[y,w]=h.useState(!1),[M,A]=h.useState(!1),R=p&&((v==null?void 0:v.participantId)!==c||(v==null?void 0:v.service)!==m);return h.useEffect(()=>{if(!p||!m||!c){b(!1),g(null);return}let T=!1;return(async()=>{try{const k=await m.getBlockedUsers();if(T)return;b(k.some(E=>E.blocked_user_id===c))}catch(k){T||console.error(`[${f}] Failed to check blocked status:`,k)}finally{T||g({participantId:c,service:m})}})(),()=>{T=!0}},[p,m,c,f]),{isParticipantBlocked:j,isCheckingBlockedStatus:R,isLeaving:y,isUpdatingBlockStatus:M,handleLeaveConversation:async()=>{var T;if(!y){l==null||l(),x&&console.log(`[${f}] Leave conversation`,e.cid),w(!0);try{const k=((T=e._client)==null?void 0:T.userID)??null;await e.hide(k,!1),r&&await r(e),u==null||u()}catch(k){console.error(`[${f}] Failed to leave conversation`,k)}finally{w(!1)}}},handleBlockUser:async()=>{var T,k,E;if(!(M||!m)){o==null||o(),x&&console.log(`[${f}] Block member`,(T=s==null?void 0:s.user)==null?void 0:T.id),A(!0);try{await m.blockUser((k=s==null?void 0:s.user)==null?void 0:k.id),i&&await i((E=s==null?void 0:s.user)==null?void 0:E.id),u==null||u()}catch(P){console.error(`[${f}] Failed to block member`,P)}finally{A(!1)}}},handleUnblockUser:async()=>{var T,k,E;if(!(M||!m)){o==null||o(),x&&console.log(`[${f}] Unblock member`,(T=s==null?void 0:s.user)==null?void 0:T.id),A(!0);try{await m.unBlockUser((k=s==null?void 0:s.user)==null?void 0:k.id),i&&await i((E=s==null?void 0:s.user)==null?void 0:E.id),u==null||u()}catch(P){console.error(`[${f}] Failed to unblock member`,P)}finally{A(!1)}}},handleReportUser:()=>{d==null||d(),u==null||u(),window.open(Xs,"_blank","noopener,noreferrer")}}},fe=({variant:e="default",className:s,children:n,...a})=>{const r=e==="danger";return t.jsx("button",{type:"button",className:C("flex w-full items-center gap-3 rounded-lg px-4 py-3 text-left text-sm transition-colors focus-ring disabled:cursor-not-allowed disabled:opacity-60",r?"text-danger hover:bg-danger/50":"text-charcoal hover:bg-sand",s),...a,children:n})},Zs=({channel:e,participant:s,showDeleteConversation:n=!0,showBlockParticipant:a=!0,showReportParticipant:r=!0,onLeaveConversation:i,onBlockParticipant:l,onDeleteConversationClick:o,onBlockParticipantClick:d,onReportParticipantClick:u,customChannelActions:f,triggerClassName:m})=>{const[x,c]=h.useState(!1),p=h.useRef(null),j=h.useId(),b=h.useCallback(()=>c(!1),[]),{isParticipantBlocked:v,isCheckingBlockedStatus:g,isLeaving:y,isUpdatingBlockStatus:w,handleLeaveConversation:M,handleBlockUser:A,handleUnblockUser:R,handleReportUser:z}=Ks({channel:e,participant:s,showBlockParticipant:a,enabled:x,onLeaveConversation:i,onBlockParticipant:l,onDeleteConversationClick:o,onBlockParticipantClick:d,onReportParticipantClick:u,onActionComplete:b,logLabel:"ChannelActionsMenu"});return h.useEffect(()=>{if(!x)return;const L=O=>{p.current&&!p.current.contains(O.target)&&c(!1)},I=O=>{O.key==="Escape"&&c(!1)};return document.addEventListener("mousedown",L),document.addEventListener("keydown",I),()=>{document.removeEventListener("mousedown",L),document.removeEventListener("keydown",I)}},[x]),!s||!(n||a||r||!!f)?null:t.jsxs("div",{ref:p,className:"relative",children:[t.jsxs("button",{className:m,type:"button","aria-haspopup":"true","aria-expanded":x,"aria-controls":x?j:void 0,onClick:()=>c(L=>!L),children:[t.jsx(S.DotsThreeIcon,{className:"size-5 text-black/90"}),t.jsx("span",{className:"sr-only",children:"More options"})]}),x&&t.jsx("div",{id:j,"aria-label":"Conversation options",className:C("absolute right-0 top-full z-50 mt-2 w-56 overflow-hidden","rounded-lg border border-sand bg-white p-1 shadow-max-elevation-light"),children:t.jsxs("ul",{className:"flex flex-col gap-1",children:[n&&t.jsx("li",{children:t.jsxs(fe,{onClick:M,disabled:y,"aria-busy":y,children:[y?t.jsx(S.SpinnerGapIcon,{className:"h-5 w-5 animate-spin"}):t.jsx(S.SignOutIcon,{className:"h-5 w-5"}),t.jsx("span",{children:"Delete Conversation"})]})}),a&&t.jsx("li",{children:g?t.jsxs(fe,{disabled:!0,"aria-busy":!0,children:[t.jsx(S.SpinnerGapIcon,{className:"h-5 w-5 animate-spin"}),t.jsx("span",{children:"Block"})]}):v?t.jsxs(fe,{onClick:R,disabled:w,"aria-busy":w,children:[w?t.jsx(S.SpinnerGapIcon,{className:"h-5 w-5 animate-spin"}):t.jsx(S.ProhibitInsetIcon,{className:"h-5 w-5"}),t.jsx("span",{children:"Unblock"})]}):t.jsxs(fe,{onClick:A,disabled:w,"aria-busy":w,children:[w?t.jsx(S.SpinnerGapIcon,{className:"h-5 w-5 animate-spin"}):t.jsx(S.ProhibitInsetIcon,{className:"h-5 w-5"}),t.jsx("span",{children:"Block"})]})}),r&&t.jsx("li",{children:t.jsxs(fe,{variant:"danger",onClick:z,children:[t.jsx(S.FlagIcon,{className:"h-5 w-5"}),t.jsx("span",{children:"Report"})]})}),f]})})]})},Be="flex size-10 flex-shrink-0 items-center justify-center rounded-full bg-white/65 shadow-[0px_4px_8px_0px_rgba(0,0,0,0.06),0px_0px_0px_1px_rgba(0,0,0,0.04)] backdrop-blur-[40px] transition-filter duration-150 hover:brightness-95 aria-expanded:brightness-95 focus-ring",Js="CUSTOMER_PAID",Qs=e=>typeof e=="string"&&e.trim().replace(/[\s-]+/g,"_").toUpperCase()===Js,en=({className:e,onBack:s,showBackButton:n,showStarButton:a=!1,onLeaveConversation:r,onBlockParticipant:i,showDeleteConversation:l=!0,showBlockParticipant:o=!0,showReportParticipant:d=!0,onDeleteConversationClick:u,onBlockParticipantClick:f,onReportParticipantClick:m,customChannelActions:x,renderChannelActions:c,showChannelInfo:p=!0,onParticipantNameClick:j})=>{var I,O,T,k;const{channel:b}=_.useChannelStateContext(),{client:v}=_.useChatContext(),g=h.useMemo(()=>{var E;return We((E=b.state)==null?void 0:E.members,v==null?void 0:v.userID,b.type)},[(I=b.state)==null?void 0:I.members,v==null?void 0:v.userID,b.type]),y=qe(g==null?void 0:g.user),w=(O=g==null?void 0:g.user)==null?void 0:O.image,M=Qt(b),A=Qs((T=b.data)==null?void 0:T.customer_tag)&&(g==null?void 0:g.is_follower)===!0,R=a&&M,z=A||R||!!j,F=async()=>{try{M?await b.unpin():await b.pin()}catch(E){console.error("[ChannelHeaderRedesign] Failed to update pinned status:",E)}},L=t.jsxs(t.Fragment,{children:[t.jsx(ue,{id:((k=g==null?void 0:g.user)==null?void 0:k.id)||b.id||"unknown",name:y,image:w,shape:"circle",size:48,className:"-mb-2"}),t.jsx("span",{className:C("relative z-10 flex max-w-full flex-col items-center justify-center rounded-full border border-white/10 bg-white/65 py-1.5 shadow-[0px_0px_0px_0px_rgba(0,0,0,0.04),0px_1px_2px_0px_rgba(0,0,0,0.04),0px_8px_32px_0px_rgba(0,0,0,0.1)] backdrop-blur-[2px] transition-filter duration-150 group-hover:brightness-95",z?"pl-3 pr-2":"px-3"),children:t.jsxs("span",{className:"flex max-w-full items-center justify-center",children:[t.jsx("span",{className:"min-w-0 truncate text-sm font-bold leading-[1.43] tracking-[0.28px] text-black/90",children:y}),z&&t.jsxs("span",{className:"ml-2 flex gap-1",children:[A&&t.jsx("span",{"aria-label":"Paid customer",className:"flex size-4 shrink-0 items-center justify-center rounded-full bg-[#34C759] text-white",children:t.jsx(S.CurrencyDollarIcon,{className:"size-2.5",weight:"bold"})}),R&&t.jsx("span",{className:"messaging-header-star-badge flex overflow-hidden",children:t.jsx("span",{"aria-label":"Starred conversation",className:"flex size-4 shrink-0 items-center justify-center rounded-full bg-[#FFD60A] text-white",children:t.jsx(S.StarIcon,{className:"size-2.5",weight:"fill"})})}),j&&t.jsx(S.CaretRightIcon,{"aria-hidden":"true",className:"size-4 shrink-0 text-black/65",weight:"bold"})]})]})})]});return t.jsx("div",{className:C("@container bg-[linear-gradient(180deg,#FBFAF9_0%,rgba(251,250,249,0.92)_58%,rgba(251,250,249,0)_100%)]",e),children:t.jsxs("div",{className:"grid min-h-[100px] grid-cols-[minmax(40px,1fr)_auto_minmax(40px,1fr)] items-start pb-2 pt-5 @lg:min-h-[104px] @lg:pt-6",children:[t.jsx("div",{className:"flex items-start",children:n&&t.jsx("button",{className:C(Be,"messaging-channel-view-back-button-mobile messaging-channel-view-back-button-desktop"),onClick:s||(()=>{}),type:"button","aria-label":"Back to conversations",children:t.jsx(S.ArrowLeftIcon,{className:"size-5 text-black/90"})})}),t.jsx("div",{className:"flex min-w-0 justify-center","data-dd-privacy":"mask",children:j?t.jsx("button",{type:"button",onClick:j,"aria-label":`View details for ${y}`,className:"group flex min-w-0 max-w-full appearance-none flex-col items-center border-0 bg-transparent px-2 focus-ring focus-visible:outline-none",children:L}):t.jsx("div",{className:"flex min-w-0 max-w-full flex-col items-center px-2",children:L})}),t.jsxs("div",{className:"flex items-start justify-end gap-2",children:[a&&t.jsx("button",{className:Be,onClick:F,type:"button","aria-pressed":M,"aria-label":M?"Unstar conversation":"Star conversation",children:t.jsx(S.StarIcon,{className:C("size-5",{"text-[#FFD60A]":M,"text-black/90":!M}),weight:M?"fill":"regular"})}),p&&(c!==void 0?c:t.jsx(Zs,{channel:b,participant:g,showDeleteConversation:l,showBlockParticipant:o,showReportParticipant:d,onLeaveConversation:r,onBlockParticipant:i,onDeleteConversationClick:u,onBlockParticipantClick:f,onReportParticipantClick:m,customChannelActions:x,triggerClassName:Be}))]})]})})},tn=e=>t.jsx(_.DateSeparator,{...e,position:"center"});function ss(e){return(e==null?void 0:e.trim().toLowerCase().split(/[-_]/)[0])||void 0}function Xe({message:e,viewerLanguage:s}){var r;const n=e==null?void 0:e.text,a=ss(s);return a?((r=e==null?void 0:e.i18n)==null?void 0:r[`${a}_text`])??n:n}const sn=["linktr.ee"],Dt="messaging-attachment-v1_0";function nn(e){try{return new URL(e).hostname.toLowerCase()}catch{return null}}function an(e){return sn.some(s=>e===s||e.endsWith(`.${s}`))}function se(e){const s=e==null?void 0:e.trim();if(!s)return;const n=nn(s);if(!n||!an(n))return s;const a=new URL(s);return a.searchParams.get("io")==="true"&&a.searchParams.get("size")===Dt?s:(a.searchParams.set("io","true"),a.searchParams.set("size",Dt),a.toString())}const rn=[[/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 ae(e){return e.startsWith("video/")?"video":e.startsWith("audio/")?"audio":e.startsWith("image/")?"image":"document"}function ns(e){const s=rn.find(([n])=>n.test(e));return s?s[1]:"generic"}const on={video:S.VideoCameraIcon,audio:S.SpeakerHighIcon,image:S.ImageIcon,document:S.FileIcon},ln={pdf:S.FilePdfIcon,doc:S.FileDocIcon,xls:S.FileXlsIcon,csv:S.FileCsvIcon,ppt:S.FilePptIcon,zip:S.FileZipIcon,text:S.FileTextIcon,markdown:S.FileMdIcon,generic:S.FileIcon};function cn(e){const s=ae(e);return s!=="document"?on[s]:ln[ns(e)]}function de(e,s){return h.createElement(cn(e),s)}const dn=e=>{var s,n;return"touches"in e?((s=e.touches[0])==null?void 0:s.clientX)??((n=e.changedTouches[0])==null?void 0:n.clientX)??0:e.clientX},un=({source:e,mimeType:s,poster:n,autoPlay:a=!1,playing:r,loop:i=!1,controls:l=!0,showProgress:o=!1,muted:d=!1,onContainerClick:u})=>{const f=ae(s),m=h.useRef(null),x=h.useRef(null),c=h.useRef(null),p=h.useRef(r),[j,b]=h.useState(a),[v,g]=h.useState(0),[y,w]=h.useState(!1),[M,A]=h.useState(!1),[R,z]=h.useState(!1),[F,L]=h.useState(!1),[I,O]=h.useState(!0),[T,k]=h.useState(null),E=h.useCallback(()=>{z(!1),b(!0)},[]),P=h.useCallback(N=>{const D=x.current;if(!D)return 0;const G=D.getBoundingClientRect();return Math.max(0,Math.min(1,(dn(N)-G.left)/G.width))},[]),$=h.useCallback(N=>{const D=m.current;D&&D.duration&&(D.currentTime=N*D.duration)},[]),U=N=>{N.stopPropagation(),w(!0);const D=P(N);g(D),$(D)},X=h.useCallback(N=>{N.key==="ArrowRight"&&$(Math.min(1,v+.05)),N.key==="ArrowLeft"&&$(Math.max(0,v-.05))},[$,v]);h.useEffect(()=>{r!==void 0&&r!==p.current&&(p.current=r,b(r))},[r]),h.useEffect(()=>{if(!j){c.current!==null&&(cancelAnimationFrame(c.current),c.current=null);return}const N=()=>{const D=m.current;D&&D.duration&&!y&&g(D.currentTime/D.duration),c.current=requestAnimationFrame(N)};return c.current=requestAnimationFrame(N),()=>{c.current!==null&&cancelAnimationFrame(c.current)}},[j,y]),h.useEffect(()=>{const N=m.current;N&&(j?N.play().catch(D=>{b(!1),z(!0)}):N.pause())},[j]),h.useEffect(()=>{if(!y)return;const N=G=>g(P(G)),D=G=>{w(!1),$(P(G))};return window.addEventListener("mousemove",N),window.addEventListener("mouseup",D),window.addEventListener("touchmove",N,{passive:!0}),window.addEventListener("touchend",D),()=>{window.removeEventListener("mousemove",N),window.removeEventListener("mouseup",D),window.removeEventListener("touchmove",N),window.removeEventListener("touchend",D)}},[y,P,$]);const q=T?{aspectRatio:String(T)}:void 0,K=T?"":" aspect-video",V=Math.round(v*100);return t.jsxs("div",{role:"button",tabIndex:0,className:`relative cursor-pointer overflow-hidden bg-black ${K}`,style:q,onClick:N=>{if(u){u(N);return}R||l&&b(D=>!D)},onKeyDown:N=>{if(!(N.key!=="Enter"&&N.key!==" ")){if(N.preventDefault(),u){u(N);return}R||l&&b(D=>!D)}},children:[n&&(f==="audio"||I)&&t.jsx("img",{src:n,alt:"",className:"absolute inset-0 h-full w-full object-cover"}),!n&&(f==="audio"||I)&&t.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:de(s,{className:"size-12 text-black/20",weight:"regular"})}),t.jsx("div",{className:"absolute inset-0",children:f==="audio"?t.jsx("audio",{ref:m,src:e,loop:i,muted:d,style:{width:"100%",height:"100%"},onLoadStart:()=>L(!0),onCanPlay:()=>{L(!1),O(!1)},onWaiting:()=>L(!0),onPlay:()=>z(!1),onEnded:()=>{i||(b(!1),g(0))},children:t.jsx("track",{kind:"captions"})}):t.jsx("video",{ref:m,src:e,loop:i,muted:d,playsInline:!0,style:{width:"100%",height:"100%"},onLoadStart:()=>L(!0),onCanPlay:()=>{L(!1),O(!1)},onWaiting:()=>L(!0),onPlay:()=>z(!1),onLoadedMetadata:()=>{const N=m.current;N instanceof HTMLVideoElement&&N.videoWidth&&N.videoHeight&&k(N.videoWidth/N.videoHeight)},onEnded:()=>{i||(b(!1),g(0))},children:t.jsx("track",{kind:"captions"})})}),F&&!R&&t.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center",children:t.jsx(S.CircleNotchIcon,{className:"size-8 animate-spin text-white/80",weight:"bold"})}),R&&!l&&t.jsx("div",{className:"absolute inset-0 z-30 flex cursor-pointer items-center justify-center bg-black/35",role:"button",tabIndex:0,"aria-label":"Play preview",onClick:N=>{N.stopPropagation(),E()},onKeyDown:N=>{N.key!=="Enter"&&N.key!==" "||(N.preventDefault(),N.stopPropagation(),E())},children:t.jsx("span",{className:"flex size-16 items-center justify-center rounded-full bg-white/20 text-white backdrop-blur-sm",children:t.jsx(S.PlayIcon,{className:"size-9 translate-x-0.5",weight:"fill"})})}),o&&!l&&t.jsx("div",{className:"absolute inset-x-0 bottom-0 px-3 pb-2.5 pt-6 bg-gradient-to-t from-black/40 to-transparent",children:t.jsx("div",{role:"slider","aria-label":"Playback position","aria-valuenow":V,"aria-valuemin":0,"aria-valuemax":100,tabIndex:0,ref:x,className:"relative flex h-4 w-full cursor-pointer items-center",onMouseDown:U,onTouchStart:U,onClick:N=>N.stopPropagation(),onKeyDown:X,children:t.jsx("div",{className:"w-full overflow-hidden rounded-full bg-white/30 h-1",children:t.jsx("div",{className:"h-full rounded-full bg-white",style:{width:`${V}%`}})})})}),l&&t.jsxs("div",{className:"absolute inset-x-0 bottom-0 flex items-center gap-2 bg-gradient-to-t from-black/60 to-transparent px-3 pb-2.5 pt-6 transition-all duration-200",children:[t.jsx("button",{type:"button",onClick:N=>{N.stopPropagation(),b(D=>!D)},className:"shrink-0 text-white","aria-label":j?"Pause":"Play",children:j?t.jsx(S.PauseIcon,{className:"size-5",weight:"fill"}):t.jsx(S.PlayIcon,{className:"size-5 translate-x-px",weight:"fill"})}),t.jsxs("div",{role:"slider","aria-label":"Playback position","aria-valuenow":V,"aria-valuemin":0,"aria-valuemax":100,tabIndex:0,ref:x,className:"relative flex h-4 w-full cursor-pointer items-center",onMouseDown:U,onTouchStart:U,onClick:N=>N.stopPropagation(),onMouseEnter:()=>A(!0),onMouseLeave:()=>A(!1),onKeyDown:X,children:[t.jsx("div",{className:`w-full overflow-hidden rounded-full bg-white/30 transition-all duration-200 ${M||y?"h-1.5":"h-1"}`,children:t.jsx("div",{className:"h-full rounded-full bg-white",style:{width:`${V}%`}})}),t.jsx("div",{className:`absolute size-3 -translate-x-1/2 rounded-full bg-white shadow transition-[opacity,transform] duration-200 ${M||y?"scale-100 opacity-100":"scale-0 opacity-0"}`,style:{left:`${V}%`}})]})]})]})},Ot=e=>e==="dark"?"size-12 text-white/20":"size-12 text-black/20",$e=e=>e==="dark"?"aspect-video overflow-hidden bg-white/10":"aspect-video overflow-hidden bg-black/5",Ke=({mimeType:e,sourceUrl:s,thumbnailUrl:n,title:a,variant:r,mediaPlayerProps:i,containedImage:l=!1})=>{const o=ae(e),[d,u]=h.useState(!1),f=se(s),m=se(n);return s&&(o==="video"||o==="audio")?t.jsx(un,{source:s,mimeType:e,poster:m,controls:!0,...i}):s&&o==="image"?l?t.jsx("div",{className:`relative ${$e(r)}`,children:t.jsx("img",{src:f??s,alt:a??"",className:`absolute inset-0 h-full w-full object-contain transition-opacity duration-300 ${d?"opacity-100":"opacity-0"}`,draggable:!1,onLoad:()=>u(!0)})}):t.jsx("img",{src:f??s,alt:a??"",className:"block w-full",draggable:!1}):s&&o==="document"?n?l?t.jsx("div",{className:`relative ${$e(r)}`,children:t.jsx("img",{src:m??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:()=>u(!0)})}):t.jsx("img",{src:m??n,alt:"",className:"block w-full",draggable:!1}):t.jsx("div",{className:`flex aspect-video w-full items-center justify-center ${r==="dark"?"bg-white/10":"bg-black/5"}`,children:de(e,{className:Ot(r),weight:"regular"})}):n?t.jsx("div",{className:`relative ${$e(r)}`,children:t.jsx("img",{src:m??n,alt:a??"",draggable:!1,className:"absolute inset-0 h-full w-full object-cover"})}):t.jsx("div",{className:`flex aspect-video w-full items-center justify-center ${r==="dark"?"bg-white/10":"bg-black/5"}`,children:de(e,{className:Ot(r),weight:"regular"})})},as=({variant:e,thumbnail:s,title:n,placeholderTitle:a="Attachment title",mimeType:r,detail:i,statusBadge:l,action:o,topLeft:d,topRight:u,rootRef:f,"data-testid":m})=>{const x=e==="dark",c=x?n??a:n??"",p=x&&!n;return t.jsxs("div",{ref:f,"data-testid":m,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-[#1e2330]":"bg-white"),children:[d?t.jsx("div",{className:"pointer-events-auto absolute left-3 top-3 z-50",children:d}):null,u?t.jsx("div",{className:"pointer-events-auto absolute right-3 top-3 z-50",children:u}):null,s,t.jsxs("div",{className:"px-4 pb-3 pt-3",children:[c.trim()!==""&&t.jsx("p",{className:C("mb-0.5 truncate text-base font-medium",{"text-black":!x,"text-white/30":x&&p,"text-white":x&&!p}),children:c}),t.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[de(r,{className:C("size-5 shrink-0",x?"text-white/55":"text-black/55"),weight:"regular"}),i!=null&&i!==""&&t.jsx("span",{className:C("text-xs font-medium",x?"text-white/55":"text-black/55"),children:i}),l]}),o]})]})};function rs(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function Ze(e){return`w-[280px] select-none overflow-hidden rounded-[24px] ${e?"bg-[#1e2330]":"bg-[#F3F3F1]"} shadow-[0_0_0_1px_rgba(0,0,0,0.04),0_4px_8px_rgba(0,0,0,0.06)]`}function mn(e){return e?"bg-white/10":"bg-black/5"}function hn(e){return e?"text-white":"text-black"}function fn(e){return e?"text-white/55":"text-black/55"}function xn(e){return e?"text-white/40":"text-black/40"}function gn(e){return e?"text-white/20":"text-black/20"}const Je=({attachment:e,isMyMessage:s})=>{const{title:n,text:a,image_url:r,og_scrape_url:i,title_link:l}=e,o=i??l,d=typeof o=="string"&&o.trim()!==""?o:void 0,u=t.jsxs(h.Fragment,{children:[t.jsx("div",{className:"p-2",children:r?t.jsx("img",{src:se(r)??r,alt:n??"",className:"aspect-video w-full rounded-[20px] object-cover"}):t.jsx("div",{className:`aspect-video w-full rounded-[20px] ${mn(s)} flex items-center justify-center`,children:t.jsx(S.LinkIcon,{className:`size-12 ${gn(s)}`})})}),t.jsxs("div",{className:"px-3 pb-3",children:[n&&t.jsx("p",{className:`truncate text-[14px] font-medium leading-5 ${hn(s)}`,children:n}),a&&t.jsx("p",{className:`truncate text-[12px] leading-4 ${fn(s)}`,children:a}),d&&t.jsx("p",{className:`mt-1 truncate text-[12px] leading-4 ${xn(s)}`,children:d})]})]});return d?t.jsx("a",{href:d,target:"_blank",rel:"noopener noreferrer",className:"block no-underline",children:u}):t.jsx("div",{className:"block",children:u})};function we(e){var s;return e.type==="link"||!!((s=e.og_scrape_url)!=null&&s.trim())&&!e.asset_url}function De(e){var s;return(s=e.attachments)==null?void 0:s.find(we)}async function pn(e,s){let n;try{n=s??new URL(e).pathname.split("/").pop()??"download"}catch{n=s??"download"}const a=await fetch(e,{mode:"cors"});if(!a.ok)throw new Error(`HTTP ${a.status}`);const r=await a.blob(),i=URL.createObjectURL(r),l=document.createElement("a");l.href=i,l.download=n,l.style.display="none",document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(i)}const bn=({url:e,filename:s})=>{const[n,a]=h.useState(!1),r=i=>{i.stopPropagation();const l=window.open("","_blank","noopener,noreferrer");a(!0),pn(e,s).then(()=>{l==null||l.close()}).catch(()=>{l&&(l.location.href=e)}).finally(()=>a(!1))};return t.jsx("button",{type:"button",onClick:r,disabled:n,className:"mt-3 inline-flex h-10 w-full items-center justify-center gap-2 rounded-full bg-[#121110] px-4 text-sm font-medium leading-none text-white hover:bg-[#2a2928] disabled:opacity-70",children:n?t.jsx(S.CircleNotchIcon,{className:"size-4 animate-spin text-white",weight:"bold"}):t.jsxs(h.Fragment,{children:[t.jsx(S.DownloadSimpleIcon,{className:"size-4 text-white",weight:"bold"}),"Download"]})})};function Oe(e){var m,x,c,p;const s=(m=e.attachments)==null?void 0:m.find(j=>j.type==="video"&&j.asset_url),n=(x=e.attachments)==null?void 0:x.find(j=>j.type==="image"&&j.image_url),a=(c=e.attachments)==null?void 0:c.find(j=>j.type==="audio"&&j.asset_url),r=(p=e.attachments)==null?void 0:p.find(j=>j.type==="file"&&j.asset_url),i=s??n??a??r,l=(s==null?void 0:s.asset_url)??(n==null?void 0:n.image_url)??(a==null?void 0:a.asset_url)??(r==null?void 0:r.asset_url);if(!l)return null;const o=(i==null?void 0:i.mime_type)??((i==null?void 0:i.type)==="image"?"image/jpeg":(i==null?void 0:i.type)==="video"?"video/mp4":(i==null?void 0:i.type)==="audio"?"audio/mpeg":"application/octet-stream"),d=i==null?void 0:i.title,u=i==null?void 0:i.file_size,f=s==null?void 0:s.thumb_url;return{resolvedUrl:l,resolvedType:o,title:d,fileSize:u,thumbnailUrl:f}}const is=({resolvedUrl:e,resolvedType:s,title:n,fileSize:a,thumbnailUrl:r})=>{const i=a!==void 0?rs(a):void 0;return t.jsx(as,{variant:"dark",title:n,placeholderTitle:"",mimeType:s,detail:i,thumbnail:t.jsx(Ke,{mimeType:s,sourceUrl:e,thumbnailUrl:r,title:n,variant:"dark"})})},os=({resolvedUrl:e,resolvedType:s,title:n,fileSize:a,thumbnailUrl:r})=>{const i=ae(s),l=a!==void 0?rs(a):void 0;return t.jsx(as,{variant:"light",title:n,mimeType:s,detail:l,thumbnail:t.jsx(Ke,{mimeType:s,sourceUrl:e,thumbnailUrl:r,title:n,variant:"light",containedImage:i==="image"||i==="document"}),action:t.jsx(bn,{url:e,filename:n})})},vn=({message:e,isMyMessage:s=!1})=>{const n=De(e),a=Oe(e);if(!n&&!a)return null;const r=s?"str-chat__message str-chat__message-simple str-chat__message--me str-chat__message-simple--me":"str-chat__message str-chat__message-simple str-chat__message--other";return t.jsxs("div",{className:r,"data-dd-privacy":"mask",children:[!s&&e.user&&t.jsx(ue,{className:"str-chat__avatar str-chat__message-sender-avatar",id:e.user.id,image:e.user.image,name:e.user.name??e.user.id}),t.jsx("div",{className:"str-chat__message-inner",style:{marginInlineEnd:0,marginInlineStart:0},children:t.jsx("div",{className:"str-chat__message-bubble-wrapper",children:t.jsx("div",{className:"str-chat__message-bubble","data-attachment-bubble":"true",style:{padding:0,borderRadius:0,overflow:"visible",background:"transparent"},children:n?t.jsx("div",{className:Ze(s),children:t.jsx(Je,{attachment:n,isMyMessage:s})}):s?t.jsx(is,{...a}):t.jsx(os,{...a})})})})]})},jn=({message:e})=>{const s=De(e);if(s)return t.jsx("div",{className:Ze(!0),"data-dd-privacy":"mask",children:t.jsx(Je,{attachment:s,isMyMessage:!0})});const n=Oe(e);return n?t.jsx("div",{style:{display:"contents"},"data-dd-privacy":"mask",children:t.jsx(is,{...n})}):null},wn=({message:e})=>{const s=De(e);if(s)return t.jsx("div",{className:Ze(!1),"data-dd-privacy":"mask",children:t.jsx(Je,{attachment:s,isMyMessage:!1})});const n=Oe(e);return n?t.jsx("div",{style:{display:"contents"},"data-dd-privacy":"mask",children:t.jsx(os,{...n})}):null},_n=Object.assign(vn,{Creator:jn,Visitor:wn}),yn={isUnlocking:()=>!1},Nn={LockedAttachment:yn},ls=h.createContext({}),Cn=ls.Provider;function cs(e){return h.useContext(ls)[e]??Nn[e]}const Sn=h.lazy(()=>Promise.resolve().then(()=>require("./Card-Be81K6su.cjs"))),kn=h.lazy(()=>Promise.resolve().then(()=>require("./Card-DOAG1fie.cjs"))),En=()=>t.jsx("div",{className:"w-[280px] min-h-[200px] animate-pulse rounded-md bg-black/[0.06] shadow-[0_0_0_1px_rgba(0,0,0,0.04),0_1px_2px_rgba(0,0,0,0.04),0_8px_32px_rgba(0,0,0,0.1)]","aria-hidden":!0}),pe=e=>t.jsx(h.Suspense,{fallback:t.jsx(En,{}),children:e.contentType==="text"?t.jsx(Sn,{...e}):t.jsx(kn,{...e})}),In=({size:e=15})=>t.jsx("svg",{width:e,height:e,viewBox:"0 0 15 15",fill:"none","aria-hidden":"true",children:t.jsx("path",{d:"M12.003 9a.985.985 0 0 1-.652.934l-3.223 1.191-1.188 3.226a.995.995 0 0 1-1.867 0l-1.195-3.226L.65 9.937a.995.995 0 0 1 0-1.867l3.227-1.195 1.187-3.226a.995.995 0 0 1 1.868 0l1.195 3.226 3.226 1.187a.99.99 0 0 1 .649.938m3-5.83a.52.52 0 0 1-.344.492l-1.702.63-.627 1.703a.525.525 0 0 1-.986 0l-.63-1.704-1.704-.627a.525.525 0 0 1 0-.986l1.703-.63.627-1.704a.526.526 0 0 1 .986 0l.631 1.703 1.704.627a.52.52 0 0 1 .342.495",fill:"currentColor",fillOpacity:.55})}),ds=e=>{var s;return((s=e.metadata)==null?void 0:s.custom_type)===W.MESSAGE_CUSTOM_TYPE.PAID},Te=e=>{var s;return((s=e.metadata)==null?void 0:s.custom_type)===W.MESSAGE_CUSTOM_TYPE.CHATBOT},Qe=e=>{var s;return((s=e.metadata)==null?void 0:s.custom_type)===W.MESSAGE_CUSTOM_TYPE.ATTACHMENT},Tn=e=>{var s;return Qe(e)&&((s=e.metadata)==null?void 0:s.attachment_content_type)==="text"},Mn=e=>{var s;return Qe(e)&&((s=e.metadata)==null?void 0:s.attachment_content_type)!=="text"},An=e=>{var s;return ds(e)&&!!((s=e.metadata)!=null&&s.amount_text)},Pt=({message:e,isMyMessage:s=!1,hasAttachment:n=!1})=>{var m;const a=ds(e),r=Te(e);if(!a&&!r)return null;if(a){const x=(m=e.metadata)==null?void 0:m.amount_text;return x?t.jsxs("div",{className:"message-tag--paid inline-flex items-center gap-1 text-[12px] font-medium leading-[2] text-[#016630]",children:[t.jsx(S.GiftIcon,{size:12}),t.jsxs("span",{children:["Delivered with ",x," message"]})]}):null}const i=s&&n,l=i?"Sent with AI":"Sent by AI Assistant",o="inline-flex items-center text-[10px] font-normal leading-4 tracking-[0.2px]",d=i?"justify-end gap-2 text-black/30":s?"w-full justify-start gap-1.5 mt-3 px-4 text-white/55":"w-full justify-start gap-1.5 mt-3 px-4 text-black/30",u=t.jsx("span",{className:"text-left",children:l}),f=t.jsx("span",{className:"inline-flex items-center leading-none",children:t.jsx(In,{size:i?12:15})});return t.jsx("div",{className:`${o} ${d}`,"data-testid":"message-chatbot-indicator",children:s&&!i?t.jsxs(t.Fragment,{children:[u,f]}):t.jsxs(t.Fragment,{children:[f,u]})})},Ft=`url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='23' fill='none'%3E%3Cpath fill='black' d='M0 0H15C15 10.1934 15.859 15.2345 19.168 21.4893C19.527 22.168 19.039 22.9917 18.274 22.9178C5.176 21.6506 0.32 6.0737 0 0Z'/%3E%3C/svg%3E") no-repeat center / 100% 100%`,Rn={me:"var(--str-chat__own-message-bubble-background-color, #1e2330)",other:"var(--str-chat__message-bubble-background-color, #f1f0ee)"},Me=({side:e})=>t.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute bottom-0 z-[-1] h-[1.4375rem] w-5",style:{insetInlineEnd:e==="me"?"calc(-1 * 0.3125rem)":void 0,insetInlineStart:e==="other"?"calc(-1 * 0.3125rem)":void 0,transform:e==="other"?"scaleX(-1)":void 0,transformOrigin:"center",backgroundColor:Rn[e],WebkitMask:Ft,mask:Ft}}),us=h.createContext(void 0),Ln=e=>{var n;const s=(n=e.metadata)==null?void 0:n.outbound_id;return typeof s=="string"?s:void 0},Dn=(e,s)=>{if(!s||!(e!=null&&e.length))return;const n=new Set;let a;for(const r of e){const i=Ln(r);if(!i||n.has(i))continue;n.add(i);const l=s(i);l&&(a??(a={}),a[i]={id:l.id,...l.name!==void 0?{name:l.name}:{}})}return a},On=(e,s)=>{if(e===s)return!0;if(!e||!s)return!1;const n=Object.keys(e),a=Object.keys(s);return n.length!==a.length?!1:n.every(r=>{var i,l;return e[r].id===((i=s[r])==null?void 0:i.id)&&e[r].name===((l=s[r])==null?void 0:l.name)})},Pn=(e,s)=>{const n=Dn(e,s),[a,r]=h.useState(n);return On(a,n)?a:(r(n),n)},et=e=>{var s;return((s=e.metadata)==null?void 0:s.custom_type)===W.MESSAGE_CUSTOM_TYPE.TIP},ms=({message:e})=>{var n;const s=(n=e.metadata)==null?void 0:n.amount_text;return s?t.jsxs("div",{className:"message-tip-pill inline-flex items-end gap-0.5 max-w-[520px] rounded-[1.5rem] bg-[#43e660] px-4 py-3 text-white",children:[t.jsx("span",{className:"flex h-5 items-center text-[20px] leading-none","aria-hidden":"true",children:"🎁"}),t.jsxs("span",{className:"text-[14px] font-bold leading-[1.43] tracking-[0.28px] text-[rgba(4,4,3,0.9)]",children:[s," tip!"]})]}):null},tt=()=>{const{message:e}=_.useMessageContext("SentMessageDeliveryStatus"),{messages:s}=_.useChannelStateContext("SentMessageDeliveryStatus"),n=(()=>{if(s)for(let a=s.length-1;a>=0;a-=1){const r=s[a];if(!(r.type==="system"||r.type==="ephemeral"||r.type==="deleted"))return r.id}})();return e.id===n},Ee=()=>tt()?t.jsxs(t.Fragment,{children:[t.jsx(S.ChecksIcon,{weight:"bold","aria-hidden":"true"}),t.jsx("span",{"data-testid":"sent-message-delivery-status",children:"Delivered"})]}):null,Fn=()=>tt()?t.jsxs(t.Fragment,{children:[t.jsx(S.CircleNotchIcon,{className:"sent-message-status__spinner animate-spin",weight:"bold","aria-hidden":"true"}),t.jsx("span",{"data-testid":"sent-message-sending-status",children:"Sending"})]}):null,zn=({outbound:e,onOutboundClick:s})=>{const n=e.name||"Broadcast",a=!!s,r=t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"sent-message-outbound-badge","aria-hidden":"true",children:t.jsx(S.MegaphoneIcon,{weight:"fill"})}),t.jsx("span",{className:C("sent-message-outbound-name",{"underline [text-decoration-skip-ink:auto]":a}),"data-testid":"sent-message-outbound-status",children:n})]});return s?t.jsx("button",{type:"button",className:"inline-flex cursor-pointer items-center gap-1 border-0 bg-transparent p-0 text-inherit [font:inherit]","aria-label":`View broadcast ${n}`,onClick:()=>s(e),children:r}):r},Bn=()=>t.jsxs("span",{className:"str-chat__message-status sent-message-status--failed",children:[t.jsx(S.WarningCircleIcon,{weight:"bold","aria-hidden":"true"}),t.jsx("span",{"data-testid":"sent-message-failed-status",children:"Failed to send"})]}),$n=({onOutboundClick:e,resolvedOutbound:s})=>{var f;const{isMyMessage:n,message:a,threadList:r}=_.useMessageContext("SentMessageDeliveryStatus"),i=n(),l=tt();if(r)return null;if(a.status==="failed"&&i&&a.type!=="error")return t.jsx(Bn,{});if(!i)return null;const o=(f=a.metadata)==null?void 0:f.outbound_id,d=a.status!=="sending"&&a.status!=="failed"&&o&&s?t.jsx(zn,{outbound:s,onOutboundClick:e}):null,u=An(a)?null:t.jsx(_.MessageStatus,{MessageSentStatus:Ee,MessageDeliveredStatus:Ee,MessageReadStatus:Ee,MessageSendingStatus:et(a)?Ee:Fn});return d?t.jsxs("span",{className:"sent-message-status-row",children:[u,u&&l&&t.jsx("span",{className:"sent-message-outbound-separator","aria-hidden":"true",children:"•"}),d]}):u},Un=/^([a-z][a-z0-9+.-]*):/i,Hn=new Set(["http","https","mailto","tel","sms"]);function st(e){if(typeof e!="string")return;const s=e.trim();if(s==="")return;const n=Un.exec(s);if(n){const a=n[1].toLowerCase();return Hn.has(a)?s:void 0}return s.startsWith("//")||s.startsWith("/")?s:`https://${s}`}const Vn={dark:{primary:"bg-white text-[#121110] hover:bg-white/90",secondary:"bg-white/15 text-white hover:bg-white/25"},light:{primary:"bg-[#121110] text-white hover:bg-[#2a2928]",secondary:"bg-black/[0.06] text-[#121110] hover:bg-black/10"}},hs=({variant:e,cta:s,fullWidth:n=!0,standalone:a=!1})=>{const r=s.variant??"primary",i=C("inline-flex h-10 items-center justify-center rounded-full px-4 text-sm font-medium leading-none transition-colors",n?"w-full":"min-w-0",!a&&"mt-2",Vn[e][r]),l=n?s.label:t.jsx("span",{className:"min-w-0 truncate",children:s.label}),o=st(s.href);return o?t.jsx("a",{href:o,target:"_blank",rel:"noopener noreferrer",onClick:d=>{var u;d.stopPropagation(),(u=s.onClick)==null||u.call(s)},className:`${i} no-underline`,children:l}):t.jsx("button",{type:"button",onClick:d=>{var u;d.stopPropagation(),(u=s.onClick)==null||u.call(s)},className:i,children:l})},Gn={dark:"text-white",light:"text-black/90"},Yn="text-white/30",zt={dark:"text-white/55",light:"text-black/55"},Wn={dark:"bg-white/25",light:"bg-black/15"},nt=({variant:e,ctaSurface:s,chinTextColor:n,title:a,placeholderTitle:r,description:i,descriptionLines:l=1,url:o,appIcon:d,cta:u,trailingAction:f,isLoading:m=!1})=>{const x=e==="dark",c=a??(x?r:void 0)??"",p=c.trim()!=="",j=i!=null&&i.trim()!=="",b=typeof o=="string"?o.trim():"",v=b!=="",g=u!=null;if(!m&&!p&&!j&&!v&&!g)return null;const y=x&&!a,w=C("line-clamp-2 text-[14px] font-medium leading-5 tracking-[0.28px]",n==null&&(y?Yn:Gn[e])),M=C("truncate text-[12px] leading-4 tracking-[0.24px]",n==null&&zt[e]),A=C("text-[12px] leading-4 tracking-[0.24px]",l<=1&&"truncate",n==null&&zt[e]);if(m){const F=C("animate-pulse rounded",Wn[e]);return t.jsx("div",{className:"shrink-0 px-4 py-3",children:t.jsxs("div",{className:"flex min-w-0 flex-col gap-[2px]",children:[t.jsx("div",{className:C("h-5 w-3/4",F),"aria-hidden":!0}),t.jsx("div",{className:C("h-4 w-1/2",F),"aria-hidden":!0})]})})}const R=n?{color:n}:void 0,z=l>1?{...R,display:"-webkit-box",WebkitBoxOrient:"vertical",WebkitLineClamp:l,overflow:"hidden"}:R;return t.jsxs("div",{className:"shrink-0 px-4 py-3",children:[t.jsxs("div",{className:"flex items-end gap-3",children:[t.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-[2px]",children:[p&&t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[d?t.jsx("span",{className:"shrink-0",children:d}):null,t.jsx("p",{className:C("min-w-0",w),style:R,children:c})]}),j&&t.jsx("p",{className:A,style:z,children:i}),!g&&v&&t.jsx("p",{className:M,style:R,"data-testid":"link-attachment-url",children:b})]}),f&&t.jsx("div",{className:"shrink-0",children:f})]}),u&&t.jsx(hs,{variant:s??e,cta:u})]})},qn="Loading link preview",Xn=C("relative w-[var(--lt-msg-card-width,290px)] max-w-full select-none overflow-hidden","rounded-[20px]"),Kn="flex h-[250px] flex-col",ve=({variant:e,children:s,href:n,onClick:a,ariaLabel:r,rootRef:i,topRight:l,bgClassName:o,accentHex:d,fixedHeight:u=!1,busy:f=!1,"data-testid":m})=>{const x=n!=null||a!=null,c=C("messaging-link-card",Xn,u?Kn:"block",o??(e==="dark"?"bg-[#1e2330]":"bg-[#f1f0ee]"),x?"cursor-pointer no-underline focus-ring":null),p=f?{role:"status","aria-busy":!0,"aria-label":qn}:void 0,j=d?{"--accent":d}:void 0,b=l?t.jsx("div",{className:"pointer-events-auto absolute right-3 top-3 z-10",children:l}):null;return n?t.jsxs("a",{ref:i,href:n,target:"_blank",rel:"noopener noreferrer",onClick:a,"data-testid":m,"data-variant":e,className:c,style:j,...p,children:[s,b]}):a?t.jsxs("button",{ref:i,type:"button",onClick:a,"aria-label":r,"data-testid":m,"data-variant":e,className:C(c,"text-left"),style:j,...p,children:[s,b]}):t.jsxs("div",{ref:i,"data-testid":m,"data-variant":e,className:c,style:j,...p,children:[s,b]})},Bt={dark:"bg-white/10",light:"bg-black/5"},Zn={dark:"size-16 text-white/25",light:"size-16 text-black/25"},_e=(e,s)=>!!s&&!!e&&ae(e)==="audio",at=(e,s)=>{if(!s||!e)return!1;const n=ae(e);return n==="video"||n==="audio"},rt="bg-[#F2F3F4]",je=({variant:e,thumbnailUrl:s,sourceUrl:n,title:a,mimeType:r="image/*",topLeft:i,topRight:l,isLoading:o=!1,onImageError:d})=>{const u=ae(r),f=!!n&&u==="video",m=se(s);return!o&&_e(r,n)?t.jsx("div",{className:"p-3",children:t.jsx("audio",{src:n,controls:!0,preload:"metadata",className:"block w-full",children:t.jsx("track",{kind:"captions"})})}):t.jsxs("div",{className:C("relative min-h-0 w-full flex-1 overflow-hidden",f&&"bg-black"),children:[o?t.jsx("div",{className:C("h-full w-full animate-pulse",Bt[e]),"aria-hidden":!0}):f?t.jsxs(t.Fragment,{children:[t.jsx("video",{src:n,poster:m,controls:!0,playsInline:!0,preload:"metadata",className:"absolute inset-0 h-full w-full object-contain",children:t.jsx("track",{kind:"captions"})}),m&&d?t.jsx("img",{src:m,alt:"","aria-hidden":!0,onError:d,className:"hidden"}):null]}):s?t.jsx("img",{src:m??s,alt:a??"",draggable:!1,loading:"lazy",decoding:"async",onError:d,className:"absolute inset-0 h-full w-full object-cover"}):t.jsx("div",{className:C("flex h-full w-full items-center justify-center",Bt[e]),children:de(r,{className:Zn[e],weight:"regular"})}),i?t.jsx("div",{className:"pointer-events-auto absolute left-3 top-3 z-10",children:i}):null,l?t.jsx("div",{className:"pointer-events-auto absolute right-3 top-3 z-10",children:l}):null]})},Jn=/^#?(?:[0-9a-f]{3}|[0-9a-f]{6})$/i;function Qn(e){const s=e.trim();return s.startsWith("#")?s:`#${s}`}const ea="#FFFFFF",fs="#040403",ta={dark:ea,light:fs};function Pe({variant:e,accentColor:s,status:n="ready",layout:a="featured",thumbnailUrl:r,mimeType:i,sourceUrl:l}){const[o,d]=h.useState(!1);h.useEffect(()=>{d(!1)},[r]);const u=h.useCallback(()=>{d(!0)},[]),f=_e(i,l),c=a==="featured"&&!!r&&!f&&!o&&n==="ready"&&s!=null&&Jn.test(s.trim())?Qn(s):void 0,p=f?fs:ta[e];return{thumbnailUrl:o?void 0:r,accentHex:c,chinTextColor:p,surface:f?"light":e,isLoading:n==="loading",onImageError:u}}const sa="flex size-6 items-center justify-center rounded-full bg-[#121110] text-white focus-ring",na="relative before:absolute before:-inset-[10px] before:content-['']",aa=({title:e,placeholderTitle:s,description:n,descriptionLines:a,url:r,mimeType:i,thumbnailUrl:l,sourceUrl:o,layout:d="featured",appIcon:u,cta:f,accentColor:m,status:x="ready",onDismiss:c,onEditClick:p,dismissLabel:j="Dismiss attachment"})=>{const b=d==="classic",v=_e(i,o),g=Pe({variant:"dark",accentColor:m,status:x,layout:d,thumbnailUrl:l,mimeType:i,sourceUrl:o}),y=c?t.jsx("button",{type:"button",onClick:c,"aria-label":j,className:C(sa,!v&&na),children:t.jsx(S.XIcon,{className:"size-3",weight:"bold"})}):void 0,w=p?t.jsx("button",{type:"button",onClick:p,"aria-label":"Edit attachment",className:"flex size-10 items-center justify-center rounded-full bg-white/10 text-white hover:bg-white/15",children:t.jsx(S.PencilSimpleIcon,{className:"size-5",weight:"regular"})}):void 0;return v&&!g.isLoading?t.jsx(ve,{variant:"dark",bgClassName:rt,children:t.jsxs("div",{className:"flex items-center gap-2 pr-3",children:[t.jsx("div",{className:"min-w-0 flex-1",children:t.jsx(je,{variant:"dark",sourceUrl:o,title:e,mimeType:i})}),y&&t.jsx("div",{className:"shrink-0",children:y})]})}):t.jsxs(ve,{variant:"dark",fixedHeight:!b,accentHex:g.accentHex,busy:g.isLoading,topRight:b?y:void 0,children:[!b&&t.jsx(je,{variant:"dark",thumbnailUrl:g.thumbnailUrl,sourceUrl:o,title:e,mimeType:i,topRight:y,isLoading:g.isLoading,onImageError:g.onImageError}),t.jsx(nt,{chinTextColor:g.chinTextColor,variant:"dark",ctaSurface:g.surface,title:e,placeholderTitle:s,description:n,descriptionLines:a,url:r,appIcon:u,cta:f,trailingAction:w,isLoading:g.isLoading})]})},it=({accentHex:e,side:s,visible:n,children:a})=>{if(!n)return t.jsx(t.Fragment,{children:a});const r=s==="sender"?"dark":"light",i=e?{"--accent":e}:void 0;return t.jsxs("div",{className:"relative isolate w-fit",children:[a,t.jsx("span",{"aria-hidden":!0,"data-testid":"link-card-tail","data-variant":r,style:i,className:C("messaging-link-card-tail",s==="receiver"&&"messaging-link-card-tail--received")})]})},ra=({title:e,description:s,descriptionLines:n,url:a,mimeType:r,thumbnailUrl:i,sourceUrl:l,layout:o="featured",appIcon:d,cta:u,accentColor:f,status:m="ready",onClick:x,groupPosition:c="single"})=>{const p=at(r,l),j=st(a),b=u==null&&j!=null&&!p?j:void 0,v=u==null&&!p?x:void 0,g=m!=="loading"&&_e(r,l)?rt:void 0,y=u&&x?{...u,onClick:()=>{var M;x(),(M=u.onClick)==null||M.call(u)}}:u,w=Pe({variant:"light",accentColor:f,status:m,layout:o,thumbnailUrl:i,mimeType:r,sourceUrl:l});return t.jsx(it,{accentHex:w.accentHex,side:"receiver",visible:g==null&&(c==="single"||c==="end"),children:t.jsxs(ve,{variant:"light",href:b,onClick:v,ariaLabel:e??"Open attachment preview",fixedHeight:o==="featured"&&g==null,accentHex:w.accentHex,busy:w.isLoading,bgClassName:g,"data-testid":"link-attachment",children:[o==="featured"&&t.jsx(je,{variant:"light",thumbnailUrl:w.thumbnailUrl,sourceUrl:l,title:e,mimeType:r,isLoading:w.isLoading,onImageError:w.onImageError}),t.jsx(nt,{chinTextColor:w.chinTextColor,variant:"light",ctaSurface:w.surface,title:e,description:s,descriptionLines:n,url:a,appIcon:d,cta:y,isLoading:w.isLoading})]})})},ia=({title:e,placeholderTitle:s,description:n,descriptionLines:a,url:r,mimeType:i,thumbnailUrl:l,sourceUrl:o,layout:d="featured",appIcon:u,cta:f,accentColor:m,status:x="ready",onClick:c,groupPosition:p="single"})=>{const j=at(i,o),b=st(r),v=f==null&&b!=null&&!j?b:void 0,g=f==null&&!j&&v!=null?c:void 0,y=x!=="loading"&&_e(i,o),w=Pe({variant:"dark",accentColor:m,status:x,layout:d,thumbnailUrl:l,mimeType:i,sourceUrl:o});return t.jsx(it,{accentHex:w.accentHex,side:"sender",visible:!y&&(p==="single"||p==="end"),children:t.jsxs(ve,{variant:"dark",href:v,onClick:g,fixedHeight:d==="featured"&&!y,accentHex:w.accentHex,busy:w.isLoading,bgClassName:y?rt:void 0,children:[d==="featured"&&t.jsx(je,{variant:"dark",thumbnailUrl:w.thumbnailUrl,sourceUrl:o,title:e,mimeType:i,isLoading:w.isLoading,onImageError:w.onImageError}),t.jsx(nt,{chinTextColor:w.chinTextColor,variant:"dark",ctaSurface:w.surface,title:e,placeholderTitle:s,description:n,descriptionLines:a,url:r,appIcon:u,cta:f,isLoading:w.isLoading})]})})},Ae={Composer:aa,Sent:ia,Received:ra},oa={dark:"bg-[#1e2330]",light:"bg-[#f2f1ef]"},la={dark:"text-white",light:"text-[#000000]"},ca={dark:"border-white/[0.08]",light:"border-black/[0.08]"},da=e=>e==="dark"?"sender":"receiver",ua={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]"}},ye=({variant:e,text:s,bordered:n=!0,groupPosition:a="single",widthClassName:r="w-[280px]",paddingClassName:i="px-2 py-2",radiusClassName:l,className:o,children:d,"data-testid":u})=>{const f=s!=null&&s!=="",m=l??ua[da(e)][a];return t.jsxs("div",{"data-testid":u,"data-group-position":a,className:C("relative",r,"overflow-hidden",i,f&&"pb-0",m,oa[e],la[e],n&&"border",n&&ca[e],o),children:[d,f?t.jsx("p",{className:C("whitespace-pre-wrap break-words leading-snug hyphens-manual","pb-2 pt-2","px-2"),children:s}):null]})},Ne=({onClick:e,variant:s="overlay",ariaLabel:n="Dismiss attachment"})=>t.jsx("button",{type:"button",onClick:a=>{a.stopPropagation(),e()},"aria-label":n,className:C("flex size-6 items-center justify-center rounded-full text-white",s==="overlay"?"bg-[#121110]/85 backdrop-blur":"bg-white/15 hover:bg-white/25"),children:t.jsx(S.XIcon,{className:"size-3",weight:"bold"})}),Ce=e=>e==="received"?"light":"dark",ma=({firstOfGroup:e,endOfGroup:s,groupedByUser:n})=>!n||e&&s?"single":e?"first":s?"end":"middle",ha=({src:e,mimeType:s,filename:n,items:a})=>a&&a.length>0?a:e?[{src:e,mimeType:s,filename:n}]:[],fa=({item:e,preload:s,trailingAction:n})=>t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("audio",{src:e.src,controls:!0,preload:e.preload??s,className:"block min-w-0 flex-1",children:e.mimeType?t.jsx("source",{src:e.src,type:e.mimeType}):null}),n??null]}),ot=({state:e,src:s,mimeType:n,filename:a,items:r,text:i,groupPosition:l,preload:o,onDismiss:d})=>{const u=Ce(e),f=e==="composer"&&!!d,m=ha({src:s,mimeType:n,filename:a,items:r});if(m.length===0)return null;const x=o??(m.length>1?"none":"metadata");return t.jsx(ye,{variant:u,text:i,groupPosition:l,"data-testid":"audio-attachment",children:t.jsx("div",{className:"flex flex-col gap-2",children:m.map((c,p)=>t.jsx(fa,{item:c,preload:x,trailingAction:f&&p===0?t.jsx(Ne,{onClick:d,variant:"inline"}):void 0},`${c.src}-${p}`))})})},xa=e=>t.jsx(ot,{...e,state:"composer"}),ga=e=>t.jsx(ot,{...e,state:"sent"}),pa=e=>t.jsx(ot,{...e,state:"received"}),ba={Composer:xa,Sent:ga,Received:pa};function xs(e){return!Number.isFinite(e)||e<0?"":e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:e<1024*1024*1024?`${(e/(1024*1024)).toFixed(2)} MB`:`${(e/(1024*1024*1024)).toFixed(2)} GB`}const va={pdf:"PDF",doc:"DOC",xls:"XLS",csv:"CSV",ppt:"PPT",zip:"ZIP",text:"TXT",markdown:"MD"};function gs(e,s){if(s){const r=s.lastIndexOf(".");if(r>0&&r<s.length-1){const i=s.slice(r+1);if(i&&i.length<=5)return i.toUpperCase()}}if(!e)return;if(ae(e)==="document"){const r=ns(e),i=va[r];if(i)return i;if(e==="application/octet-stream")return}const a=e.split("/")[1];if(!(!a||a==="*"))return a.toUpperCase()}function ps(e,s,n){const a=gs(e,s),r=typeof n=="number"&&n>0?xs(n):void 0;return[a,r].filter(Boolean).join(" · ")||void 0}function ne(e){try{const n=new URL(e).pathname.split("/").pop();return n&&n.length>0?decodeURIComponent(n):"download"}catch{return"download"}}const ja={dark:"text-white/55",light:"text-black/65"},wa={dark:"bg-white/10",light:"bg-black/5"},_a={dark:"text-white/85",light:"text-black/85"},bs=({variant:e,filename:s,title:n,mimeType:a="application/octet-stream",fileSize:r,onActivate:i,activateLabel:l,trailingAction:o})=>{const d=n??s??"File",u=ps(a,s,r),f=t.jsx("div",{className:C("flex size-10 shrink-0 items-center justify-center rounded-sm",wa[e]),"aria-hidden":!0,children:de(a,{className:C("size-6",_a[e]),weight:"regular"})}),m=t.jsxs("div",{className:"flex min-w-0 flex-1 flex-col text-left",children:[t.jsx("p",{className:"truncate font-medium leading-snug",children:d}),u?t.jsx("p",{className:C("truncate text-xs leading-4",ja[e]),children:u}):null]}),x=i?t.jsxs("button",{type:"button",onClick:i,"aria-label":l,className:C("flex min-w-0 flex-1 items-center gap-3 rounded-sm text-left transition-colors",e==="dark"?"hover:bg-white/[0.04]":"hover:bg-black/[0.04]"),children:[f,m]}):t.jsxs(t.Fragment,{children:[f,m]});return t.jsxs("div",{className:"flex items-center gap-3 px-3 py-2",children:[x,o?t.jsx("div",{className:"shrink-0",children:o}):null]})};async function vs(e,s){const n=s??ne(e);try{const a=await fetch(e,{mode:"cors"});if(!a.ok)throw new Error(`HTTP ${a.status}`);const r=await a.blob(),i=URL.createObjectURL(r),l=document.createElement("a");l.href=i,l.download=n,l.style.display="none",document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(i)}catch{if(!window.open(e,"_blank","noopener,noreferrer")){const r=document.createElement("a");r.href=e,r.download=n,r.target="_blank",r.rel="noopener noreferrer",r.style.display="none",document.body.appendChild(r),r.click(),document.body.removeChild(r)}}}const ya=({src:e,filename:s,fileSize:n,mimeType:a,title:r,items:i})=>i&&i.length>0?i:e?[{src:e,filename:s,fileSize:n,mimeType:a,title:r}]:[],Na=({variant:e,item:s,index:n,onActivate:a,trailingAction:r})=>{const i=s.filename??ne(s.src);return t.jsx(bs,{variant:e,filename:i,title:s.title,mimeType:s.mimeType??"application/octet-stream",fileSize:s.fileSize,onActivate:()=>a(n),activateLabel:`Download ${i}`,trailingAction:r})},lt=({state:e,src:s,filename:n,fileSize:a,mimeType:r,title:i,items:l,text:o,groupPosition:d,onClick:u,onDismiss:f})=>{const m=Ce(e),x=e==="composer"&&!!f,c=ya({src:s,filename:n,fileSize:a,mimeType:r,title:i,items:l}),p=b=>{if((u==null?void 0:u(b))===!1)return;const v=c[b];if(!v)return;const g=v.filename??ne(v.src);vs(v.src,g)};if(c.length===0)return null;const j=t.jsx("span",{className:C("flex size-8 items-center justify-center rounded-full",m==="dark"?"text-white/70":"text-black/70"),"aria-hidden":!0,children:t.jsx(S.DownloadSimpleIcon,{className:"size-5",weight:"bold"})});return t.jsx(ye,{variant:m,text:o,groupPosition:d,"data-testid":"file-attachment",children:t.jsx("div",{className:"flex flex-col gap-2",children:c.map((b,v)=>{const g=x&&v===0?t.jsx(Ne,{onClick:f,variant:"inline"}):j;return t.jsx(Na,{variant:m,item:b,index:v,onActivate:p,trailingAction:g},`${b.src}-${v}`)})})})},Ca=e=>t.jsx(lt,{...e,state:"composer"}),Sa=e=>t.jsx(lt,{...e,state:"sent"}),ka=e=>t.jsx(lt,{...e,state:"received"}),Ea={Composer:Ca,Sent:Sa,Received:ka},js="inline-flex size-10 items-center justify-center rounded-full border-0 bg-white/[0.12] p-0 text-white transition-colors duration-150 ease-[ease] hover:bg-white/[0.22] focus-visible:bg-white/[0.22] focus-visible:outline-none disabled:cursor-default disabled:opacity-40",$t="absolute top-1/2 z-[1] inline-flex size-12 -translate-y-1/2 items-center justify-center rounded-full border-0 bg-white/[0.12] p-0 text-white transition-colors duration-150 ease-[ease] hover:bg-white/[0.22] focus-visible:bg-white/[0.22] focus-visible:outline-none",ct=({onPrev:e,onNext:s,prevLabel:n="Previous",nextLabel:a="Next"})=>t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:e,"aria-label":n,className:`${$t} left-4`,children:t.jsx(S.CaretLeftIcon,{size:20,weight:"bold","aria-hidden":!0})}),t.jsx("button",{type:"button",onClick:s,"aria-label":a,className:`${$t} right-4`,children:t.jsx(S.CaretRightIcon,{size:20,weight:"bold","aria-hidden":!0})})]}),ws=({url:e,filename:s,variant:n="pill",label:a="Download",iconOnly:r,tone:i="dark",onTriggered:l})=>{const[o,d]=h.useState(!1),u=h.useCallback(c=>{c.stopPropagation(),!o&&(d(!0),vs(e,s).catch(()=>{}).finally(()=>{d(!1),l==null||l()}))},[o,e,s,l]),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 t.jsx("button",{type:"button",onClick:u,disabled:o,"aria-label":a,className:C("flex size-8 shrink-0 items-center justify-center rounded-full transition-colors disabled:opacity-70",c[i]),children:o?t.jsx(S.CircleNotchIcon,{className:"size-4 animate-spin",weight:"bold","aria-hidden":!0}):t.jsx(S.DownloadSimpleIcon,{className:"size-5 shrink-0",weight:"bold","aria-hidden":!0})})}return n==="viewer"?t.jsx("button",{type:"button",onClick:u,disabled:o,"aria-label":a,className:js,children:o?t.jsx(S.CircleNotchIcon,{size:20,weight:"bold","aria-hidden":!0}):t.jsx(S.DownloadSimpleIcon,{size:20,weight:"bold","aria-hidden":!0})}):t.jsxs("button",{type:"button",onClick:u,disabled:o,"aria-label":f?a:void 0,className:C("mt-3 inline-flex h-10 w-full items-center justify-center gap-2 rounded-full px-4 text-sm font-medium leading-none transition-colors disabled:opacity-70",i==="dark"?"bg-[#121110] text-white hover:bg-[#2a2928]":"bg-white text-[#121110] hover:bg-white/90"),children:[o?t.jsx(S.CircleNotchIcon,{className:"size-4 animate-spin",weight:"bold","aria-hidden":!0}):t.jsx(S.DownloadSimpleIcon,{...x,"aria-hidden":!0}),f?null:a]})},Ue=(e,s,n)=>Math.min(Math.max(e,s),n),dt=({length:e,initialIndex:s,open:n})=>{const a=Ue(s,0,Math.max(e-1,0)),[r,i]=h.useState(a);h.useEffect(()=>{n&&i(Ue(s,0,Math.max(e-1,0)))},[n,s,e]),h.useEffect(()=>{i(d=>Ue(d,0,Math.max(e-1,0)))},[e]);const l=h.useCallback(()=>{e<=1||i(d=>d<=0?e-1:d-1)},[e]),o=h.useCallback(()=>{e<=1||i(d=>d>=e-1?0:d+1)},[e]);return h.useEffect(()=>{if(!n||e<=1)return;const d=u=>{if(u.key!=="ArrowLeft"&&u.key!=="ArrowRight")return;const f=document.activeElement;f&&(f.tagName==="VIDEO"||f.tagName==="AUDIO")||(u.preventDefault(),u.key==="ArrowLeft"?l():o())};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[n,e,l,o]),{index:r,prev:l,next:o}},ut=({open:e,onClose:s,ariaLabel:n,counter:a,actions:r,children:i,"data-testid":l})=>{const o=h.useRef(null),d=h.useRef(null);h.useEffect(()=>{var x;const m=o.current;if(m){if(e){if(!m.open)if(typeof m.showModal=="function")try{m.showModal()}catch{m.setAttribute("open","")}else m.setAttribute("open","");const c=typeof document<"u"?document.activeElement:null;return(x=d.current)==null||x.focus(),()=>{if(m.open)if(typeof m.close=="function")try{m.close()}catch{m.removeAttribute("open")}else m.removeAttribute("open");c&&document.body.contains(c)&&c.focus()}}if(m.open)if(typeof m.close=="function")try{m.close()}catch{m.removeAttribute("open")}else m.removeAttribute("open")}},[e]);const u=()=>{s()},f=m=>{m.target===o.current&&s()};return t.jsxs("dialog",{ref:o,className:"mes-media-viewer","aria-label":n??"Attachment viewer","data-testid":l,onClose:u,onClick:f,children:[t.jsxs("div",{className:"pointer-events-none absolute inset-x-3 top-3 z-[1] flex items-center justify-between gap-3",children:[a?t.jsx("span",{className:"pointer-events-auto inline-flex items-center rounded-full bg-white/[0.12] px-3 py-1.5 text-[13px] font-medium leading-none tabular-nums text-white",children:a}):null,t.jsxs("div",{className:"pointer-events-auto ml-auto inline-flex items-center gap-2",children:[r,t.jsx("button",{ref:d,type:"button",onClick:s,"aria-label":"Close viewer",className:js,children:t.jsx(S.XIcon,{size:20,weight:"bold","aria-hidden":!0})})]})]}),t.jsx("div",{className:"box-border flex h-full w-full items-center justify-center px-6 py-16",children:i})]})},_s=({open:e,items:s,initialIndex:n=0,onClose:a})=>{const{index:r,prev:i,next:l}=dt({length:s.length,initialIndex:n,open:e}),o=s[r],d=h.useMemo(()=>(o==null?void 0:o.filename)??(o?ne(o.src):"image"),[o]);return o?t.jsxs(ut,{open:e,onClose:a,ariaLabel:d,counter:s.length>1?`${r+1} / ${s.length}`:void 0,actions:t.jsx(ws,{url:o.src,filename:d,variant:"viewer",label:`Download ${d}`}),"data-testid":"image-viewer",children:[e?t.jsx("img",{src:o.src,alt:o.alt??d,draggable:!1,decoding:"async",className:"block h-auto max-h-[calc(100dvh-128px)] w-auto max-w-[min(96vw,1400px)] select-none object-contain"},`${r}:${o.src}`):null,s.length>1?t.jsx(ct,{onPrev:i,onNext:l,prevLabel:"Previous image",nextLabel:"Next image"}):null]}):null},Ia="relative block size-full overflow-hidden bg-black/5 outline-none after:pointer-events-none after:absolute after:inset-0 after:rounded-[inherit] focus-visible:after:ring-2 focus-visible:after:ring-inset focus-visible:after:ring-white/80 focus-visible:after:ring-offset-2 focus-visible:after:ring-offset-black",Ta={1:["rounded-[18px]"],2:["rounded-l-[18px]","rounded-r-[18px]"],3:["rounded-l-[18px]","rounded-tr-[18px]","rounded-br-[18px]"],4:["rounded-tl-[18px]","rounded-tr-[18px]","rounded-bl-[18px]","rounded-br-[18px]"]},Ma="--mes-single-width-cap",Aa="[--mes-single-width-cap:309px] sm:[--mes-single-width-cap:326px]",Ra=436,ys=({tiles:e,onTileActivate:s,maxVisible:n=4,singleAspectRatio:a,className:r})=>{const i=e.length;if(i===0)return null;const l=e.slice(0,Math.min(i,n)),o=i-l.length,d=(f,m,x)=>{var p;const c=C(Ia,"h-full w-full",(p=Ta[l.length])==null?void 0:p[m]);return s?t.jsxs("button",{type:"button",onClick:()=>s(m),"aria-label":f.ariaLabel??`Open media ${m+1}`,className:C(c,"cursor-zoom-in"),children:[f.content,x]},m):t.jsxs("div",{className:c,children:[f.content,x]},m)};let u;return a&&(u={aspectRatio:a,width:`min(var(${Ma}), ${Math.round(Ra*a*100)/100}px)`,maxWidth:"100%"}),l.length===1?t.jsx("div",{className:C(a?Aa:"aspect-square w-full",r),style:u,children:d(l[0],0)}):l.length===2?t.jsx("div",{className:C("grid aspect-[16/9] w-full grid-cols-2 gap-0.5",r),children:l.map((f,m)=>d(f,m))}):l.length===3?t.jsxs("div",{className:C("grid aspect-[4/3] w-full grid-cols-2 grid-rows-2 gap-0.5",r),children:[t.jsx("div",{className:"row-span-2",children:d(l[0],0)}),d(l[1],1),d(l[2],2)]}):t.jsx("div",{className:C("grid aspect-[379/286] w-full grid-cols-2 grid-rows-2 gap-0.5",r),children:l.map((f,m)=>{const x=o>0&&m===l.length-1;return d(f,m,x?t.jsxs("div",{className:"absolute inset-0 flex items-center justify-center bg-black/55 text-2xl font-semibold text-white",children:["+",o]}):null)})})},Se=e=>{const[s,n]=h.useState(!1),[a,r]=h.useState(0),i=h.useCallback(o=>{(e==null?void 0:e(o))!==!1&&(r(o),n(!0))},[e]),l=h.useCallback(()=>n(!1),[]);return{viewerOpen:s,viewerIndex:a,handleActivate:i,closeViewer:l}},La=({item:e,index:s,totalCount:n,fallbackLoading:a,imgRef:r,onLoad:i})=>({ariaLabel:`Open image ${s+1} of ${n}`,content:t.jsx("img",{ref:r,src:se(e.src)??e.src,alt:e.alt??"",width:e.width,height:e.height,draggable:!1,loading:e.loading??a,decoding:"async",onLoad:i,className:"absolute inset-0 size-full object-cover"})}),Da=({src:e,alt:s,items:n})=>n&&n.length>0?n:e?[{src:e,alt:s}]:[],Ns=(e,s)=>e.map((n,a)=>({src:n.src,alt:n.alt,filename:s&&e.length===1?s:s?`${s} (${a+1})`:void 0})),Oa=({src:e,alt:s,filename:n,loading:a="lazy",onClick:r,onDismiss:i})=>{const{viewerOpen:l,viewerIndex:o,handleActivate:d,closeViewer:u}=Se(r);return t.jsxs("div",{className:"relative w-fit",children:[t.jsx("button",{type:"button",onClick:()=>d(0),"aria-label":"Open image",className:"block size-[280px] cursor-zoom-in overflow-hidden rounded-md outline-none focus-visible:ring-2 focus-visible:ring-black/40",children:t.jsx("img",{src:se(e)??e,alt:s??"",draggable:!1,loading:a,decoding:"async",className:"size-full object-cover"})}),i?t.jsx("div",{className:"absolute right-2 top-2 z-10",children:t.jsx(Ne,{onClick:i})}):null,t.jsx(_s,{open:l,items:Ns([{src:e,alt:s}],n),initialIndex:o,onClose:u})]})},Pa=326/246,Fa=e=>{const s=e==null?void 0:e.src,[n,a]=h.useState(),r=h.useCallback(d=>{if(!d||d.naturalWidth<=0||d.naturalHeight<=0||s===void 0)return;const u=d.naturalWidth/d.naturalHeight;a(f=>f&&f.src===s&&f.ratio===u?f:{src:s,ratio:u})},[s]),i=h.useCallback(d=>r(d.currentTarget),[r]),l=e!=null&&e.width&&(e!=null&&e.height)?e.width/e.height:void 0,o=n&&n.src===s?n.ratio:void 0;return{ratio:l??o??Pa,imgRef:r,onLoad:i}},Cs=({state:e,src:s,alt:n,filename:a,items:r,text:i,groupPosition:l,loading:o="lazy",onClick:d})=>{const u=Da({src:s,alt:n,items:r}),f=Ce(e),{viewerOpen:m,viewerIndex:x,handleActivate:c,closeViewer:p}=Se(d),j=u.length===1,b=Fa(j?u[0]:void 0);if(u.length===0)return null;const v=u.map((g,y)=>La({item:g,index:y,totalCount:u.length,fallbackLoading:o,imgRef:j?b.imgRef:void 0,onLoad:j?b.onLoad:void 0}));return t.jsxs(ye,{variant:f,text:i,groupPosition:l,bordered:!1,widthClassName:j?"w-fit max-w-[min(100%,313px)] sm:max-w-[min(100%,330px)]":"w-[383px] max-w-full",paddingClassName:"p-0.5",radiusClassName:"rounded-[20px]","data-testid":"image-attachment",children:[t.jsx("div",{className:"relative",children:t.jsx(ys,{tiles:v,onTileActivate:c,singleAspectRatio:j?b.ratio:void 0})}),t.jsx(_s,{open:m,items:Ns(u,a),initialIndex:x,onClose:p})]})},za=e=>t.jsx(Oa,{...e}),Ba=e=>t.jsx(Cs,{...e,state:"sent"}),$a=e=>t.jsx(Cs,{...e,state:"received"}),Ua={Composer:za,Sent:Ba,Received:$a},Ha=({open:e,items:s,initialIndex:n=0,onClose:a})=>{const{index:r,prev:i,next:l}=dt({length:s.length,initialIndex:n,open:e}),o=s[r],d=h.useMemo(()=>(o==null?void 0:o.filename)??(o?ne(o.src):"document"),[o]),u=h.useMemo(()=>o?Va(o.src):void 0,[o]);return!o||!u?null:t.jsxs(ut,{open:e,onClose:a,ariaLabel:d,counter:s.length>1?`${r+1} / ${s.length}`:void 0,"data-testid":"pdf-viewer",children:[t.jsx("iframe",{src:u,title:d,className:"block h-[calc(100dvh-128px)] w-[min(96vw,1400px)] border-0 bg-white",sandbox:"allow-scripts allow-forms allow-popups allow-downloads"},`${r}:${o.src}`),s.length>1?t.jsx(ct,{onPrev:i,onNext:l,prevLabel:"Previous document",nextLabel:"Next document"}):null]})},Va=e=>{const s=e.indexOf("#"),n=s===-1?e:e.slice(0,s),a=s===-1?"":e.slice(s+1),r=new URLSearchParams(a);return r.has("toolbar")||r.set("toolbar","0"),r.has("navpanes")||r.set("navpanes","0"),`${n}#${r.toString()}`},Ga=({src:e,filename:s,fileSize:n,title:a,items:r})=>r&&r.length>0?r:e?[{src:e,filename:s,fileSize:n,title:a}]:[],Ya=({variant:e,item:s,index:n,onActivate:a,trailingAction:r})=>{const i=s.filename??ne(s.src);return t.jsx(bs,{variant:e,filename:i,title:s.title,mimeType:"application/pdf",fileSize:s.fileSize,onActivate:()=>a(n),activateLabel:`Open ${i}`,trailingAction:r})},mt=({state:e,src:s,filename:n,fileSize:a,title:r,items:i,text:l,groupPosition:o,onClick:d,onDismiss:u})=>{const f=Ce(e),m=Ga({src:s,filename:n,fileSize:a,title:r,items:i}),{viewerOpen:x,viewerIndex:c,handleActivate:p,closeViewer:j}=Se(d),b=e==="composer"&&!!u;if(m.length===0)return null;const v=m.map(g=>({src:g.src,filename:g.filename??ne(g.src)}));return t.jsxs(ye,{variant:f,text:l,groupPosition:o,"data-testid":"pdf-attachment",children:[t.jsx("div",{className:"flex flex-col gap-2",children:m.map((g,y)=>{const w=g.filename??ne(g.src),M=b&&y===0?t.jsx(Ne,{onClick:u,variant:"inline"}):e==="composer"?void 0:t.jsx(ws,{url:g.src,filename:w,variant:"inline",label:`Download ${w}`,tone:f});return t.jsx(Ya,{variant:f,item:g,index:y,onActivate:p,trailingAction:M},`${g.src}-${y}`)})}),t.jsx(Ha,{open:x,items:v,initialIndex:c,onClose:j})]})},Wa=e=>t.jsx(mt,{...e,state:"composer"}),qa=e=>t.jsx(mt,{...e,state:"sent"}),Xa=e=>t.jsx(mt,{...e,state:"received"}),Ka={Composer:Wa,Sent:qa,Received:Xa},Ss=({open:e,items:s,initialIndex:n=0,onClose:a})=>{const{index:r,prev:i,next:l}=dt({length:s.length,initialIndex:n,open:e}),o=s[r],d=h.useMemo(()=>(o==null?void 0:o.filename)??(o?ne(o.src):"video"),[o]);return o?t.jsxs(ut,{open:e,onClose:a,ariaLabel:d,counter:s.length>1?`${r+1} / ${s.length}`:void 0,"data-testid":"video-viewer",children:[t.jsx("video",{src:o.src,poster:o.poster,controls:!0,autoPlay:!0,muted:!0,playsInline:!0,preload:o.preload??"metadata",className:"block h-auto max-h-[calc(100dvh-128px)] w-auto max-w-[min(96vw,1400px)] bg-black",children:o.mimeType?t.jsx("source",{src:o.src,type:o.mimeType}):null},`${r}:${o.src}`),s.length>1?t.jsx(ct,{onPrev:i,onNext:l,prevLabel:"Previous video",nextLabel:"Next video"}):null]}):null},Za=()=>t.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center",children:t.jsx("span",{className:"flex size-12 items-center justify-center rounded-full bg-black/55 text-white backdrop-blur",children:t.jsx(S.PlayIcon,{className:"size-6",weight:"fill","aria-hidden":!0})})}),ks=({item:e,index:s})=>t.jsxs("div",{className:"absolute inset-0 size-full bg-[#0d0d0d]",children:[e.poster?t.jsx("img",{src:e.poster,alt:`Video ${s+1} thumbnail`,draggable:!1,loading:"lazy",decoding:"async",className:"absolute inset-0 size-full object-cover"}):t.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:t.jsx(S.VideoCameraIcon,{className:"size-16 text-white/30",weight:"regular","aria-hidden":!0})}),t.jsx(Za,{})]}),Ja=(e,s,n)=>({ariaLabel:`Play video ${s+1} of ${n}`,content:t.jsx(ks,{item:e,index:s})}),Qa=({src:e,poster:s,mimeType:n,preload:a,items:r})=>r&&r.length>0?a?r.map(i=>({...i,preload:i.preload??a})):r:e?[{src:e,poster:s,mimeType:n,preload:a}]:[],Es=(e,s)=>e.map((n,a)=>({src:n.src,poster:n.poster,mimeType:n.mimeType,preload:n.preload,filename:s&&e.length===1?s:s?`${s} (${a+1})`:void 0})),er=({src:e,poster:s,mimeType:n,filename:a,preload:r,onClick:i,onDismiss:l})=>{const{viewerOpen:o,viewerIndex:d,handleActivate:u,closeViewer:f}=Se(i);return t.jsxs("div",{className:"relative w-fit",children:[t.jsx("button",{type:"button",onClick:()=>u(0),"aria-label":"Play video",className:"relative block size-[280px] cursor-pointer overflow-hidden rounded-md outline-none focus-visible:ring-2 focus-visible:ring-black/40",children:t.jsx(ks,{item:{src:e,poster:s,mimeType:n},index:0})}),l?t.jsx("div",{className:"absolute right-2 top-2 z-10",children:t.jsx(Ne,{onClick:l})}):null,t.jsx(Ss,{open:o,items:Es([{src:e,poster:s,mimeType:n,preload:r}],a),initialIndex:d,onClose:f})]})},Is=({state:e,src:s,poster:n,mimeType:a,filename:r,items:i,text:l,groupPosition:o,preload:d,onClick:u})=>{const f=Qa({src:s,poster:n,mimeType:a,preload:d,items:i}),m=Ce(e),{viewerOpen:x,viewerIndex:c,handleActivate:p,closeViewer:j}=Se(u);if(f.length===0)return null;const b=f.map((v,g)=>Ja(v,g,f.length));return t.jsxs(ye,{variant:m,text:l,groupPosition:o,"data-testid":"video-attachment",children:[t.jsx("div",{className:"relative",children:t.jsx(ys,{tiles:b,onTileActivate:p})}),t.jsx(Ss,{open:x,items:Es(f,r),initialIndex:c,onClose:j})]})},tr=e=>t.jsx(er,{...e}),sr=e=>t.jsx(Is,{...e,state:"sent"}),nr=e=>t.jsx(Is,{...e,state:"received"}),ar={Composer:tr,Sent:sr,Received:nr},xe={Image:Ua,Video:ar,Audio:ba,Pdf:Ka,File:Ea};function H(e){const s=e==null?void 0:e.trim();return s||void 0}function Ut(e){return e.trim().replace(/^https?:\/\//i,"").replace(/\/+$/,"").toLowerCase()}function rr(e,s){if(!(e!=null&&e.trim())||!(s!=null&&s.trim()))return!1;const n=Ut(e),a=Ut(s);if(n===a)return!0;if(!n.includes(a))return!1;const r=n.split(a).join("");return!/[^\p{P}\p{Z}\p{C}]/u.test(r)}function Ht(e){const s=H(e.og_scrape_url)??H(e.title_link),n=H(e.image_url)??H(e.thumb_url),a=H(e.asset_url),r=H(e.mime_type);return{title:H(e.title),description:H(e.text),url:s,thumbnailUrl:se(n),sourceUrl:a,layout:n||at(r,a)?"featured":"classic",mimeType:r,accentColor:H(e.accent_color),status:"ready"}}function ir(e){var s;return we(e)?null:e.type==="image"?e.image_url||e.asset_url?"image":null:e.type==="video"&&e.asset_url?"video":e.type==="audio"&&e.asset_url?"audio":e.type==="file"&&e.asset_url?e.mime_type==="application/pdf"?"pdf":(s=e.mime_type)!=null&&s.startsWith("audio/")?"audio":"file":null}function Ts(e){if(!(e!=null&&e.length))return[];const s=[],n=(r,i)=>{const l=s[s.length-1];if((l==null?void 0:l.type)==="media"&&l.kind===r){l.attachments.push(i);return}s.push({type:"media",kind:r,attachments:[i]})},a=r=>{const i=s[s.length-1];if((i==null?void 0:i.type)==="link"){i.attachments.push(r);return}s.push({type:"link",attachments:[r]})};for(const r of e){if(we(r)){a(r);continue}const i=ir(r);i&&n(i,r)}return s}function or(e){return e.filter(s=>s.type==="media").length}function lr(e,s,n){return s<=1?n:e===0?"first":e===s-1?"end":"middle"}function cr(e){return H(e.image_url)??H(e.asset_url)??""}function dr(e){switch(e){case"image":return xe.Image;case"video":return xe.Video;case"audio":return xe.Audio;case"pdf":return xe.Pdf;default:return xe.File}}function Vt(e,s){switch(e){case"image":return{src:cr(s),alt:H(s.title)};case"video":return{src:H(s.asset_url)??"",poster:H(s.thumb_url),mimeType:H(s.mime_type)};case"audio":return{src:H(s.asset_url)??"",mimeType:H(s.mime_type)??"audio/mpeg",filename:H(s.title)};case"pdf":return{src:H(s.asset_url)??"",filename:H(s.title),fileSize:s.file_size};case"file":return{src:H(s.asset_url)??"",filename:H(s.title),fileSize:s.file_size,mimeType:H(s.mime_type)??"application/octet-stream"}}}function ur(e,s){if(s.length>1)return{items:s.map(a=>Vt(e,a))};const n=s[0];return n?Vt(e,n):{}}function mr({groupPosition:e,isMyMessage:s,segment:n}){const a=dr(n.kind),r={...ur(n.kind,n.attachments),groupPosition:e};return s?t.jsx(a.Sent,{...r}):t.jsx(a.Received,{...r})}const hr=({groupPosition:e,isMyMessage:s,message:n,renderText:a})=>{var b;const r=Ts(n.attachments);if(r.length===0)return null;const i=or(r),l=(b=n.text)==null?void 0:b.trim(),o=r.find(v=>v.type==="link"),d=(o==null?void 0:o.type)==="link"?Ht(o.attachments[0]??{}).url:void 0,u=l&&rr(l,d)?void 0:l;let f=0;const m=[],x=u?"middle":e,c=e==="single"||e==="end",p=(v,g,y)=>{const w=s?Ae.Sent:Ae.Received;m.push(t.jsx(w,{...Ht(v),groupPosition:y?x:"middle"},g))},j=(v,g)=>{const y=lr(f,i,e);f+=1,m.push(t.jsx(mr,{groupPosition:y,isMyMessage:s,segment:v},g))};return r.forEach((v,g)=>{const y=g===r.length-1;if(v.type==="link"){v.attachments.forEach((w,M)=>{p(w,`link-${g}-${M}`,y&&M===v.attachments.length-1)});return}j(v,`media-${g}`)}),t.jsxs("div",{className:"str-chat__message-bubble-wrapper",children:[t.jsxs("div",{className:"str-chat__message-bubble","data-attachment-bubble":"true",style:{background:"transparent",borderRadius:0,overflow:"visible",padding:0},children:[m,!u&&t.jsx(_.MessageErrorIcon,{})]}),u?t.jsxs("div",{className:C("str-chat__message-bubble",{"relative isolate":c}),children:[t.jsx(_.MessageText,{message:n,renderText:a}),t.jsx(_.MessageErrorIcon,{}),c&&t.jsx(Me,{side:s?"me":"other"})]}):null]})},fr=e=>{var jt,wt,_t,yt,Nt,Ct,St,kt,Et,It,Tt;const{additionalMessageInputProps:s,editing:n,endOfGroup:a,firstOfGroup:r,groupStyles:i,groupedByUser:l,handleAction:o,handleOpenThread:d,handleRetry:u,highlighted:f,isMessageAIGenerated:m,isMyMessage:x,message:c,renderText:p,threadList:j,viewerLanguage:b,onOutboundClick:v,resolvedOutbound:g}=e,{client:y}=_.useChatContext("CustomMessage"),{channel:w}=_.useChannelStateContext("CustomMessage"),{isUnlocking:M,onUnlockClick:A,onFetchSource:R,onDownloadClick:z}=cs("LockedAttachment"),[F,L]=h.useState(!1),I=_.useMessageReminder(c.id),{Attachment:O=_.Attachment,EditMessageModal:T=_.EditMessageModal,MessageActions:k,MessageBlocked:E=_.MessageBlocked,MessageBouncePrompt:P=_.MessageBouncePrompt,MessageDeleted:$=_.MessageDeleted,MessageIsThreadReplyInChannelButtonIndicator:U=_.MessageIsThreadReplyInChannelButtonIndicator,MessageRepliesCountButton:X=_.MessageRepliesCountButton,ReminderNotification:q=_.ReminderNotification,StreamedMessageText:K=_.StreamedMessageText,PinIndicator:V}=_.useComponentContext("CustomMessage"),N=_.messageHasAttachments(c),D=_.messageHasReactions(c),G=h.useMemo(()=>m==null?void 0:m(c),[m,c]),B=h.useMemo(()=>{const ce=c.attachments??[],he=c.shared_location?[c.shared_location,...ce]:ce;if(!Te(c))return he;const Mt=he.filter(At=>!("type"in At)||!we(At));return Mt.length===he.length?he:Mt},[c]),Q=h.useMemo(()=>Ts(B),[B]),Y=h.useMemo(()=>{const ce=Xe({message:c,viewerLanguage:b});return ce===c.text?c:{...c,text:ce}},[c,b]),J=Q.length>0,ee=Q.reduce((ce,he)=>ce+he.attachments.length,0)===((B==null?void 0:B.length)??0),re=(i==null?void 0:i[0])??"",ke=re==="top"?"first":re==="middle"?"middle":re==="bottom"?"end":"single",oe=re==="single"||re==="bottom";if(_.isDateSeparatorMessage(c))return null;if(c.deleted_at||c.type==="deleted")return t.jsx($,{message:c});if(_.isMessageBlocked(c))return t.jsx(E,{});const te=!j&&!!c.reply_count,le=!j&&c.show_in_channel&&c.parent_id,ie=c.status==="failed"&&((jt=c.error)==null?void 0:jt.status)!==403,ft=_.isMessageBounced(c);let me;ie?me=()=>u(c):ft&&(me=()=>L(!0));const Z=x(),Bs=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":N,"str-chat__message--highlighted":f,"str-chat__message--pinned pinned-message":c.pinned,"str-chat__message--with-reactions":D,"str-chat__message-send-can-be-retried":(c==null?void 0:c.status)==="failed"&&((wt=c==null?void 0:c.error)==null?void 0:wt.status)!==403,"str-chat__message-with-thread-link":te||le,"str-chat__virtual-message__wrapper--end":a,"str-chat__virtual-message__wrapper--first":r,"str-chat__virtual-message__wrapper--group":l}),Fe=c.poll_id&&y.polls.fromState(c.poll_id),xt=et(c),ge=Te(c),$s=Qe(c),ze=!!(B!=null&&B.length&&!c.quoted_message),gt=ge&&Z&&ze,Us=J&&ee&&!c.quoted_message&&!Fe&&!G&&!ge,pt={contentType:"text",amountText:(_t=c.metadata)==null?void 0:_t.amount_text,paymentStatus:(yt=c.metadata)==null?void 0:yt.payment_status,renderedText:c.text&&t.jsx(_.MessageText,{message:Y,renderText:p})},bt={contentType:"media",title:(Nt=c.metadata)==null?void 0:Nt.attachment_title,mimeType:(Ct=c.metadata)==null?void 0:Ct.attachment_mime_type,thumbnailUrl:(St=c.metadata)==null?void 0:St.attachment_thumbnail,amountText:(kt=c.metadata)==null?void 0:kt.amount_text,detail:(Et=c.metadata)==null?void 0:Et.attachment_detail,paymentStatus:(It=c.metadata)==null?void 0:It.payment_status,onFetchSource:R?()=>R(c,w):void 0},vt=t.jsxs("div",{className:C("str-chat__message-bubble",{"relative isolate":oe}),children:[t.jsx(_.MessageText,{message:Y,renderText:p}),oe&&t.jsx(Me,{side:Z?"me":"other"})]});return t.jsxs(t.Fragment,{children:[n&&t.jsx(T,{additionalMessageInputProps:s}),F&&t.jsx(_.MessageBounceModal,{MessageBouncePrompt:P,onClose:()=>L(!1),open:F}),t.jsxs("div",{className:Bs,"data-message-id":c.id,"data-dd-privacy":"mask",children:[V&&t.jsx(V,{}),!!I&&t.jsx(q,{reminder:I}),c.user&&t.jsx(ue,{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:ge}),t.jsx("div",{className:C("str-chat__message-inner",{"str-chat__simple-message--error-failed":ie||ft}),"data-testid":"message-inner",onClick:me,onKeyDown:me,role:me?"button":void 0,tabIndex:me?0:void 0,style:{marginInlineEnd:0,marginInlineStart:0},children:xt?t.jsxs("div",{className:"str-chat__message-bubble-wrapper message-tip-wrapper",children:[t.jsx(ms,{message:c}),((Tt=c.text)==null?void 0:Tt.trim())&&vt]}):Tn(c)?t.jsx("div",{className:"str-chat__message-bubble-wrapper",children:t.jsxs("div",{className:"flex items-center gap-2",children:[Z&&k&&t.jsx(k,{}),Z?t.jsx(pe,{...pt,isMine:!0}):t.jsx(pe,{...pt,isMine:!1,isUnlocking:M(c.id),onUnlockClick:()=>A==null?void 0:A(c,w)}),!Z&&k&&t.jsx(k,{})]})}):Mn(c)?t.jsxs("div",{className:"str-chat__message-bubble-wrapper message-locked-attachment-wrapper",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[Z&&k&&t.jsx(k,{}),Z?t.jsx(pe,{...bt,isMine:!0,onPreviewClick:()=>A?A(c,w):void 0}):t.jsx(pe,{...bt,isMine:!1,isUnlocking:M(c.id),onUnlockClick:()=>A?A(c,w):void 0,onDownloadClick:()=>z?z(c,w):void 0}),!Z&&k&&t.jsx(k,{})]}),c.text&&vt]}):Us?t.jsx(hr,{groupPosition:ke,isMyMessage:Z,message:{...Y,attachments:B,i18n:void 0},renderText:p}):t.jsx("div",{className:"str-chat__message-bubble-wrapper",children:t.jsxs("div",{className:C("str-chat__message-bubble",{"relative isolate":oe}),children:[ge&&!gt&&t.jsx(Pt,{message:c,hasAttachment:ze,isMyMessage:Z}),Fe&&t.jsx(_.Poll,{poll:Fe}),B!=null&&B.length&&!c.quoted_message?t.jsx(O,{actionHandler:o,attachments:B}):null,G?t.jsx(K,{message:Y,renderText:p}):t.jsx(_.MessageText,{message:Y,renderText:p}),t.jsx(_.MessageErrorIcon,{}),oe&&t.jsx(Me,{side:Z?"me":"other"})]})})}),!$s&&!xt&&t.jsx("div",{className:"str-chat__message-footer",children:(!ge||gt)&&t.jsx(Pt,{message:c,hasAttachment:ze,isMyMessage:Z})}),t.jsx($n,{onOutboundClick:v,resolvedOutbound:g}),te&&t.jsx(X,{onClick:d,reply_count:c.reply_count}),le&&t.jsx(U,{})]},c.id)]})},xr=h.memo(fr,(e,s)=>{var n,a,r,i;return e.viewerLanguage!==s.viewerLanguage||e.onOutboundClick!==s.onOutboundClick||((n=e.resolvedOutbound)==null?void 0:n.id)!==((a=s.resolvedOutbound)==null?void 0:a.id)||((r=e.resolvedOutbound)==null?void 0:r.name)!==((i=s.resolvedOutbound)==null?void 0:i.name)?!1:_.areMessageUIPropsEqual(e,s)}),gr=e=>{var i;const s=_.useMessageContext("CustomMessage"),n=h.useContext(us),a=(i=s.message.metadata)==null?void 0:i.outbound_id,r=typeof a=="string"?n==null?void 0:n[a]:void 0;return t.jsx(xr,{...s,...e,resolvedOutbound:r})},pr=()=>{var n;const{handleDelete:e,message:s}=_.useMessageContext("CustomMessageActions");return((n=s.metadata)==null?void 0:n.payment_status)==="paid"?null:t.jsx(Ge.DefaultDropdownActionButton,{onClick:e,"aria-label":"Delete",title:"Delete",className:"bg-marble rounded-full p-2 hover:bg-sand transition-all",children:t.jsx(S.TrashSimpleIcon,{size:16,weight:"light","aria-hidden":!0})})},br=()=>{const{handleFlag:e}=_.useMessageContext("CustomMessageActions");return t.jsx(Ge.DefaultDropdownActionButton,{onClick:e,"aria-label":"Report",title:"Report",className:"bg-marble rounded-full p-2 hover:bg-sand transition-all",children:t.jsx(S.FlagIcon,{size:16,weight:"light","aria-hidden":!0})})},vr=()=>{var s;const{message:e}=_.useMessageContext("CustomMessageActions");return((s=e.metadata)==null?void 0:s.custom_type)!==W.MESSAGE_CUSTOM_TYPE.ATTACHMENT?null:t.jsx(Ge.MessageActions,{messageActionSet:[{Component:pr,placement:"quick",type:"delete"},{Component:br,placement:"quick",type:"flag"}]})},jr=e=>({linkPreviews:Array.from(e.previews.values()).filter(s=>Ie.LinkPreviewsManager.previewIsLoaded(s)||Ie.LinkPreviewsManager.previewIsLoading(s))}),wr=()=>{const{linkPreviewsManager:e}=_.useMessageComposer(),{linkPreviews:s}=_.useStateStore(e.state,jr),n=r=>{e.dismissPreview(r)};return s.length>0?t.jsx("div",{className:"messaging-link-preview-list flex flex-col items-stretch w-full gap-2",children:s.map(r=>{const i=Ie.LinkPreviewsManager.previewIsLoading(r);return t.jsx(Ae.Composer,{title:r.title,url:r.og_scrape_url,thumbnailUrl:r.image_url,layout:i||r.image_url?"featured":"classic",status:i?"loading":"ready",onDismiss:()=>n(r.og_scrape_url)},r.og_scrape_url)})}):null},Re=h.createContext(!1),_r=200,yr=()=>h.useContext(Re),Nr=({sendMessage:e,disabled:s,...n})=>t.jsx("button",{...n,type:"button","aria-label":"Send",disabled:s,onPointerDown:a=>a.preventDefault(),onClick:e,children:t.jsx(S.ArrowUpIcon,{weight:"bold",className:"size-4"})}),Gt=()=>{const e=h.useContext(Re),{handleSubmit:s}=_.useMessageInputContext(),n=_.useMessageComposerHasSendableData(),a=e||!n,{SendButton:r=Nr,AttachmentPreviewList:i=_.AttachmentPreviewList}=_.useComponentContext("CustomMessageInput"),l=h.useRef(null);return h.useEffect(()=>{const o=l.current;if(!o||typeof ResizeObserver>"u")return;const d=new ResizeObserver(()=>{o.contains(document.activeElement)&&(o.scrollTop=o.scrollHeight)});return d.observe(o),()=>d.disconnect()},[]),h.useEffect(()=>{const o=l.current;if(!o)return;const d=u=>{var m;Array.from(((m=u.clipboardData)==null?void 0:m.items)??[]).some(x=>x.kind==="file")||u.stopPropagation()};return o.addEventListener("paste",d),()=>o.removeEventListener("paste",d)},[]),t.jsxs("div",{ref:l,className:"central-container flex flex-col min-w-0 w-full max-h-[calc(var(--messaging-surface-height,100dvh)*0.5)] overflow-y-auto overscroll-contain bg-white rounded-[1.5rem] shadow-[0_4px_16px_0_rgba(0,0,0,0.08),0_1px_2px_0_rgba(0,0,0,0.04),0_0_0_1px_rgba(0,0,0,0.04)] [&>:not(.messaging-composer-previews):not(.messaging-composer-row)]:p-2","data-dd-privacy":"mask",children:[t.jsxs("div",{className:"messaging-composer-previews empty:hidden flex flex-col gap-2 px-2 pt-2",children:[t.jsx(_.QuotedMessagePreview,{}),t.jsx(wr,{}),t.jsx(i,{})]}),t.jsxs("div",{className:"messaging-composer-row flex items-start",children:[t.jsx(_.TextareaComposer,{"aria-disabled":e||void 0,containerClassName:"min-w-0 flex-1 leading-[0]",className:"w-full resize-none overflow-hidden bg-transparent py-3.5 pl-4 pr-4 outline-none leading-5 placeholder:text-black/30 text-sm",autoFocus:!e,enterKeyHint:"send",maxRows:1/0,readOnly:e,tabIndex:e?-1:void 0}),t.jsx("div",{className:"sticky bottom-2 mt-auto mb-2 mr-2 shrink-0 pt-2",children:t.jsx(r,{sendMessage:s,"aria-label":"Send",className:"str-chat__send-button relative flex justify-center items-center rounded-full size-8 bg-[#121110] disabled:bg-[#F1F0EE] disabled:text-black/20 text-white focus-ring before:absolute before:-inset-2 before:content-['']","data-testid":"send-button",disabled:a,type:"button"})})]})]})},Yt=()=>t.jsxs("div",{className:"messaging-composer-backdrop","aria-hidden":"true",children:[t.jsx("div",{className:"messaging-composer-backdrop-blur"}),t.jsx("div",{className:"messaging-composer-backdrop-blur"}),t.jsx("div",{className:"messaging-composer-backdrop-blur"}),t.jsx("div",{className:"messaging-composer-backdrop-blur"}),t.jsx("div",{className:"messaging-composer-backdrop-blur"}),t.jsx("div",{className:"messaging-composer-backdrop-gradient"})]}),Wt=({renderActions:e,renderHeader:s,renderFooter:n,disabled:a=!1,disabledReason:r,composerInput:i})=>{var f;const{channel:l}=_.useChannelStateContext(),o=((f=l==null?void 0:l.data)==null?void 0:f.frozen)===!0,d=!!i,u=h.useRef(null);return h.useEffect(()=>{if(!d)return;const m=u.current,x=m==null?void 0:m.parentElement;if(!m||!x)return;let c=m.offsetHeight;const p=()=>{const b=m.offsetHeight,v=b>c;c=b;const g=Array.from(x.querySelectorAll(".str-chat__list")).find(w=>w.scrollHeight>w.clientHeight)??null,y=g?g.scrollHeight-g.scrollTop-g.clientHeight<_r:!1;x.style.setProperty("--messaging-composer-height",`${b}px`),v&&y&&g&&(g.scrollTop=g.scrollHeight)};if(p(),typeof ResizeObserver>"u")return;const j=new ResizeObserver(p);return j.observe(m),()=>{j.disconnect(),x.style.removeProperty("--messaging-composer-height")}},[d]),a?d?t.jsxs("div",{ref:u,className:"messaging-composer-chrome messaging-composer-chrome--floating",children:[t.jsx(Yt,{}),t.jsxs("div",{className:"relative z-10 flex flex-col",children:[s==null?void 0:s(),t.jsx("div",{className:"messaging-composer-locked-panel flex w-full flex-col items-center justify-center gap-3 px-6 py-4",children:r?t.jsx("p",{className:"max-w-[345px] text-center text-xs font-normal leading-[1.3] tracking-[0.12px] text-black/40",children:r}):null}),n==null?void 0:n()]})]}):t.jsxs(t.Fragment,{children:[s==null?void 0:s(),t.jsx("div",{className:"messaging-composer-locked-panel flex w-full flex-col items-center justify-center gap-3 px-6 py-4",children:r?t.jsx("p",{className:"max-w-[345px] text-center text-xs font-normal leading-[1.3] tracking-[0.12px] text-black/40",children:r}):null}),n==null?void 0:n()]}):d?t.jsxs("div",{ref:u,className:"messaging-composer-chrome messaging-composer-chrome--floating",children:[t.jsx(Yt,{}),t.jsxs("div",{className:"relative z-10 flex min-h-0 flex-col",children:[s==null?void 0:s(),t.jsxs("div",{className:"flex min-h-0 flex-col gap-4 p-3 pb-5 md:p-5",children:[t.jsxs("div",{inert:o?"":void 0,"aria-disabled":o||void 0,className:"message-input flex min-h-0 items-end gap-4 aria-disabled:opacity-40",children:[e&&t.jsx("div",{className:"flex h-12 shrink-0 items-center justify-center",children:e()}),t.jsx(Re.Provider,{value:o,children:t.jsx(_.MessageInput,{Input:i??Gt})})]}),n==null?void 0:n()]})]})]}):t.jsxs("div",{className:"flex min-h-0 flex-col gap-4 p-4",children:[s==null?void 0:s(),t.jsxs("div",{inert:o?"":void 0,"aria-disabled":o||void 0,className:"message-input flex min-h-0 items-end gap-4 aria-disabled:opacity-40",children:[e&&t.jsx("div",{className:"flex h-12 shrink-0 items-center justify-center",children:e()}),t.jsx(Re.Provider,{value:o,children:t.jsx(_.MessageInput,{Input:Gt})})]}),n==null?void 0:n()]})},Cr={SYSTEM_DM_AGENT_PAUSED:"DM Agent has left the conversation",SYSTEM_DM_AGENT_RESUMED:"DM Agent has rejoined the conversation"},Sr=["SYSTEM_AGE_SAFETY_BLOCKED"],kr={SYSTEM_AGE_SAFETY_BLOCKED:"This user isn’t able to reply because they don’t meet our age safety guidelines."},He="age safety guidelines.",Er="https://linktr.ee/s/about/contact",Ir=e=>Sr.includes(e),Tr=e=>{var s;return Ir((s=e.metadata)==null?void 0:s.custom_type)},Mr=e=>{var a;const s=(a=e.metadata)==null?void 0:a.custom_type;if(W.isDmAgentSystemType(s))return{kind:"dm-agent",type:s};if(W.isAgeSafetySystemType(s))return{kind:"age-safety",type:s};const n=e.dm_agent_system_type;if(W.isDmAgentSystemType(n))return{kind:"dm-agent",type:n}},Ar=e=>{const s=e.indexOf(He);if(s===-1)return e;const n=s+He.length;return t.jsxs(t.Fragment,{children:[e.slice(0,s),t.jsx("a",{href:Er,target:"_blank",rel:"noopener noreferrer",className:"mes-age-safety-system-message__emphasis font-medium text-inherit underline",children:He}),e.slice(n)]})},Rr=e=>{var a,r;const s=!Tr(e.message),n=Mr(e.message);if((n==null?void 0:n.kind)==="dm-agent"){const i=((a=e.message.text)==null?void 0:a.trim())||Cr[n.type];return t.jsxs("div",{className:"str-chat__message--system","data-testid":"message-system",children:[t.jsxs("div",{className:"mes-dm-agent-system-message mx-auto mb-2 inline-flex w-fit max-w-[min(100%,480px)] items-center justify-center gap-[10px] rounded-[12px] border border-[rgba(0,0,0,0.08)] p-3 text-[rgba(0,0,0,0.55)]","data-testid":"dm-agent-system-message","data-dm-agent-system-type":n.type,children:[t.jsx(S.SparkleIcon,{size:16,weight:"regular","aria-hidden":!0,className:"mes-dm-agent-system-message__sparkle shrink-0"}),t.jsx("p",{className:"mes-dm-agent-system-message__text m-0 text-center text-[14px] font-normal leading-5 tracking-[0.21px]",children:i})]}),!s&&t.jsx(_.MessageTimestamp,{message:e.message})]})}if((n==null?void 0:n.kind)==="age-safety"){const i=((r=e.message.text)==null?void 0:r.trim())||kr[n.type];return t.jsxs("div",{className:"str-chat__message--system","data-testid":"message-system",children:[t.jsxs("div",{className:"mes-age-safety-system-message box-border mx-auto mb-2 flex w-full max-w-[329px] items-start justify-center gap-3 rounded-[12px] border border-[var(--border-secondary,rgba(0,0,0,0.08))] bg-[var(--bg-warning-subtle,#fef3c6)] px-2 py-4 pl-5 text-[color:var(--text-warning-on-warning,#894b00)]","data-testid":"age-safety-system-message","data-age-safety-system-type":n.type,children:[t.jsx(S.ProhibitIcon,{size:24,weight:"duotone","aria-hidden":!0,className:"mes-age-safety-system-message__icon shrink-0 text-[color:var(--text-warning-on-warning,#894b00)]","data-testid":"age-safety-system-message-icon"}),t.jsx("div",{className:"mes-age-safety-system-message__content min-w-0 flex-[1_0_0]",children:t.jsx("p",{className:"m-0 text-balance text-left text-[12px] font-normal leading-4 tracking-[0.21px] text-[color:var(--text-warning-on-warning,#894b00)]",children:Ar(i)})})]}),!s&&t.jsx(_.MessageTimestamp,{message:e.message})]})}return t.jsxs("div",{className:"str-chat__message--system","data-testid":"message-system",children:[t.jsxs("div",{className:"str-chat__message--system__text",children:[t.jsx("div",{className:"str-chat__message--system__line"}),t.jsx("p",{children:e.message.text}),t.jsx("div",{className:"str-chat__message--system__line"})]}),!s&&t.jsx(_.MessageTimestamp,{message:e.message})]})},Ms=h.createContext(!1),Ve=({cx:e,index:s})=>t.jsx("circle",{cx:e,cy:"6.15",r:"3.9",fill:"#A0A0A0",children:t.jsx("animateTransform",{attributeName:"transform",type:"translate",values:"0 0; 0 -2.25; 0 0;",dur:"900ms",begin:`${120*s}ms`,repeatCount:"indefinite"})}),Lr=new Set([_.AIStates.Thinking,_.AIStates.Generating,_.AIStates.ExternalSources]),Dr=({threadList:e})=>{var p,j;const{channel:s,channelConfig:n,thread:a}=_.useChannelStateContext(),{client:r}=_.useChatContext(),{typing:i={}}=_.useTypingContext(),{aiState:l}=_.useAIState(s),o=h.useContext(Ms);if(!e&&o&&Lr.has(l)){const b=Or(s,(p=r.user)==null?void 0:p.id);return t.jsx(qt,{avatarId:(b==null?void 0:b.id)??"ai-agent",avatarName:(b==null?void 0:b.name)??(b==null?void 0:b.id)??"Agent",avatarImage:b==null?void 0:b.image,testId:"typing-indicator-ai"})}if((n==null?void 0:n.typing_events)===!1)return null;const u=e?[]:Object.values(i).filter(({parent_id:b,user:v})=>{var g;return(v==null?void 0:v.id)!==((g=r.user)==null?void 0:g.id)&&!b}),f=e?Object.values(i).filter(({parent_id:b,user:v})=>{var g;return(v==null?void 0:v.id)!==((g=r.user)==null?void 0:g.id)&&b===(a==null?void 0:a.id)}):[],m=e?f:u;if(!m.length)return null;const x=(j=m[0])==null?void 0:j.user,c=x!=null&&x.id&&s.state.members[x.id]?s.state.members[x.id].user:void 0;return t.jsx(qt,{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"})},qt=({avatarId:e,avatarName:s,avatarImage:n,testId:a})=>t.jsx("div",{className:"str-chat__li str-chat__li--single str-chat__typing-indicator !static","data-testid":a,style:{marginBottom:"var(--messaging-channel-input-spacer-height, 80px)"},children:t.jsxs("div",{className:"str-chat__message str-chat__message-simple str-chat__message--regular str-chat__message--received str-chat__message--other str-chat__message--has-text",children:[t.jsx(ue,{className:"str-chat__avatar str-chat__message-sender-avatar",id:e,name:s,image:n??void 0,size:24,shape:"circle"}),t.jsx("div",{className:"str-chat__message-inner mx-0",children:t.jsx("div",{className:"str-chat__message-bubble-wrapper",children:t.jsxs("div",{className:"str-chat__message-bubble relative isolate",children:[t.jsx("div",{className:"str-chat__message-text min-h-11 flex items-center",children:t.jsx("div",{className:"str-chat__message-text-inner str-chat__message-simple-text-inner",children:t.jsxs("svg",{"aria-hidden":"true",className:"block overflow-visible",viewBox:"0 0 32 12.3",width:"32",height:"13",overflow:"visible",children:[t.jsx(Ve,{cx:"4",index:0}),t.jsx(Ve,{cx:"16",index:1}),t.jsx(Ve,{cx:"28",index:2})]})})}),t.jsx(Me,{side:"other"})]})})})]})});function Or(e,s){var a;const n=((a=e==null?void 0:e.state)==null?void 0:a.members)??{};for(const r of Object.values(n)){const i=r==null?void 0:r.user;if(i&&i.id!==s)return i}}const As=()=>null,Pr=({className:e,message:s})=>t.jsxs("div",{className:C("flex items-center justify-center h-full",e),children:[t.jsxs("svg",{viewBox:"0 0 100 100",className:"size-8 fill-pebble",stroke:"none",children:[t.jsx("circle",{cx:"6",cy:"50",r:"6",children:t.jsx("animateTransform",{attributeName:"transform",dur:"1s",type:"translate",values:"0 15 ; 0 -15; 0 15",repeatCount:"indefinite",begin:"0.1"})}),t.jsx("circle",{cx:"30",cy:"50",r:"6",children:t.jsx("animateTransform",{attributeName:"transform",dur:"1s",type:"translate",values:"0 10 ; 0 -10; 0 10",repeatCount:"indefinite",begin:"0.2"})}),t.jsx("circle",{cx:"54",cy:"50",r:"6",children:t.jsx("animateTransform",{attributeName:"transform",dur:"1s",type:"translate",values:"0 5 ; 0 -5; 0 5",repeatCount:"indefinite",begin:"0.3"})})]}),s&&t.jsx("span",{className:"text-stone",children:s})]}),Le=h.memo(()=>t.jsx("div",{className:"messaging-loading-state flex items-center justify-center h-full",children:t.jsxs("div",{className:"flex items-center",children:[t.jsx(Pr,{className:"w-6 h-6"}),t.jsx("span",{className:"text-sm text-stone",children:"Loading messages"})]})}));Le.displayName="LoadingState";const Fr=({onBack:e,showBackButton:s,renderMessageInputActions:n,renderMessageInputFooter:a,renderConversationFooter:r,onLeaveConversation:i,onBlockParticipant:l,showDeleteConversation:o=!0,onDeleteConversationClick:d,onBlockParticipantClick:u,onReportParticipantClick:f,showBlockParticipant:m=!0,showReportParticipant:x=!0,composerDisabled:c=!1,composerDisabledReason:p,showStarButton:j=!1,renderChannelBanner:b,customChannelActions:v,renderChannelActions:g,renderMessage:y,viewerLanguage:w,showChannelInfo:M=!0,onParticipantNameClick:A,onOutboundClick:R,resolveOutbound:z,composerInput:F})=>{const{channel:L,messages:I}=_.useChannelStateContext(),O=h.useRef(R);h.useEffect(()=>{O.current=R},[R]);const T=h.useCallback(q=>{var K;(K=O.current)==null||K.call(O,q)},[]),k=R?T:void 0,E=Pn(I,z),P=L.state.messages.some(q=>q.type!=="deleted"),$=b?t.jsx(h.Fragment,{children:b()},"lt-channel-banner"):null,U=t.jsx(en,{className:"-mx-[var(--str-chat\\_\\_spacing-2)] px-[var(--str-chat\\_\\_spacing-2)] md:-mx-[min(var(--str-chat\\_\\_spacing-10),4%)] md:px-[min(var(--str-chat\\_\\_spacing-10),4%)]",onBack:e,showBackButton:s,showChannelInfo:M,showStarButton:j,onLeaveConversation:i,onBlockParticipant:l,showDeleteConversation:o,showBlockParticipant:m,showReportParticipant:x,onDeleteConversationClick:d,onBlockParticipantClick:u,onReportParticipantClick:f,customChannelActions:v,renderChannelActions:g,onParticipantNameClick:A}),X=h.useCallback(q=>{const{message:K}=_.useMessageContext("ChannelView"),V=t.jsx(gr,{...q,viewerLanguage:w,onOutboundClick:k});return!y||!K?V:y(V,K)},[k,y,w]);return t.jsx(us.Provider,{value:E,children:t.jsx(_.WithComponents,{overrides:{Message:X,MessageActions:vr,UnreadMessagesNotification:()=>null,UnreadMessagesSeparator:()=>null},children:t.jsx(_.Window,{children:F?t.jsxs("div",{className:"messaging-channel-layout relative flex min-h-0 flex-1 flex-col",children:[t.jsxs("div",{className:"messaging-channel-message-list messaging-channel-message-list--floating relative min-h-0 flex-1 overflow-hidden",children:[!P&&t.jsx("div",{className:"str-chat__list",children:t.jsxs("div",{className:"str-chat__message-list-scroll",children:[U,$]})}),t.jsx(_.MessageList,{head:P?t.jsxs("div",{className:"sticky top-0 z-10",children:[U,$]}):void 0,hideDeletedMessages:!0,hideNewMessageSeparator:!1})]},"lt-channel-message-list"),t.jsx(Wt,{...n&&{renderActions:()=>n==null?void 0:n(L)},...r&&{renderHeader:()=>r(L)},renderFooter:()=>a==null?void 0:a(L),disabled:c,disabledReason:p,composerInput:F},"lt-channel-message-input")]}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex-1 overflow-hidden relative",children:[!P&&t.jsx("div",{className:"str-chat__list",children:t.jsxs("div",{className:"str-chat__message-list-scroll",children:[U,$]})}),t.jsx(_.MessageList,{head:P?t.jsxs("div",{className:"sticky top-0 z-10",children:[U,$]}):void 0,hideDeletedMessages:!0,hideNewMessageSeparator:!1})]},"lt-channel-message-list"),r?t.jsx(h.Fragment,{children:r(L)},"lt-channel-conversation-footer"):null,t.jsx(Wt,{...n&&{renderActions:()=>n==null?void 0:n(L)},renderFooter:()=>a==null?void 0:a(L),disabled:c,disabledReason:p,composerInput:F},"lt-channel-message-input")]})})})})},ht=h.memo(({channel:e,onBack:s,showBackButton:n=!1,renderMessageInputActions:a,renderMessageInputFooter:r,renderConversationFooter:i,onLeaveConversation:l,onBlockParticipant:o,className:d,CustomChannelEmptyState:u=As,showDeleteConversation:f=!0,onDeleteConversationClick:m,onBlockParticipantClick:x,onReportParticipantClick:c,showBlockParticipant:p=!0,showReportParticipant:j=!0,composerDisabled:b=!1,composerDisabledReason:v,dmAgentEnabled:g,messageMetadata:y,onMessageSent:w,showStarButton:M=!1,renderChannelBanner:A,customChannelActions:R,renderChannelActions:z,renderMessage:F,onMessageLinkClick:L,sendButton:I,attachmentPreviewList:O,viewerLanguage:T,showChannelInfo:k=!0,onParticipantNameClick:E,onOutboundClick:P,resolveOutbound:$,composerInput:U})=>{const X=h.useCallback(async(V,N,D)=>{var ee;const G=((ee=e.data)==null?void 0:ee.chatbot_paused)===!0,B=g&&!G,Q={...N,...B&&{silent:!0},...y&&{metadata:{...N.metadata??{},...y}}},Y={...D,...B&&{skip_push:!0}},J=await e.sendMessage(Q,Y);return w==null||w(J),J},[e,g,y,w]),q=h.useRef(null);h.useEffect(()=>{if(!L)return;const V=q.current;if(!V)return;const N=D=>{const G=D.target,B=G==null?void 0:G.closest("a[href]"),Q=B==null?void 0:B.getAttribute("href");if(!Q)return;const Y=B==null?void 0:B.closest("[data-message-id]"),J=Y==null?void 0:Y.getAttribute("data-message-id"),ee=J?e.state.messages.find(re=>re.id===J):void 0;L(Q,ee)};return V.addEventListener("click",N),()=>V.removeEventListener("click",N)},[L,e]);const K=W.isOfficialChannel(e.type)?{"--lt-msg-card-width":"368px"}:void 0;return t.jsx("div",{ref:q,className:C("messaging-channel-view h-full flex flex-col",d),style:K,children:t.jsx(Ms.Provider,{value:g??!1,children:t.jsx(_.Channel,{channel:e,MessageSystem:Rr,EmptyStateIndicator:u,LoadingIndicator:Le,DateSeparator:tn,TypingIndicator:Dr,doSendMessageRequest:X,...I?{SendButton:I}:{},...O?{AttachmentPreviewList:O}:{},children:t.jsx(Fr,{onBack:s,showBackButton:n,renderMessageInputActions:a,renderMessageInputFooter:r,renderConversationFooter:i,onLeaveConversation:l,onBlockParticipant:o,CustomChannelEmptyState:u,showDeleteConversation:f,onDeleteConversationClick:m,onBlockParticipantClick:x,onReportParticipantClick:c,showBlockParticipant:p,showReportParticipant:j,composerDisabled:b,composerDisabledReason:v,showStarButton:M,renderChannelBanner:A,customChannelActions:R,renderChannelActions:z,renderMessage:F,viewerLanguage:T,showChannelInfo:k,onParticipantNameClick:E,onOutboundClick:P,resolveOutbound:$,composerInput:U})})})})});ht.displayName="ChannelView";const be=h.memo(({message:e,onBack:s})=>t.jsx("div",{className:"messaging-error-state flex items-center justify-center h-full p-8",children:t.jsxs("div",{className:"text-center max-w-sm",children:[t.jsx("div",{className:"w-24 h-24 bg-danger-alt/20 rounded-full flex items-center justify-center mx-auto mb-6",children:t.jsx("span",{className:"text-4xl",children:"⚠️"})}),t.jsx("h2",{className:"font-semibold text-charcoal mb-2",children:"Oops!"}),t.jsx("p",{className:"text-stone text-sm mb-6",children:e}),s&&t.jsx("button",{type:"button",onClick:s,className:"inline-flex items-center gap-2 px-4 py-2 text-sm font-medium text-white bg-[#7f22fe] hover:bg-primary-alt rounded-lg transition-colors focus-ring",children:"Go Back"})]})}));be.displayName="ErrorState";const zr=({capabilities:e={},renderMessageInputActions:s,renderConversationFooter:n,onChannelSelect:a,onExitConversation:r,initialParticipantFilter:i,initialParticipantData:l,CustomChannelEmptyState:o,onBlockParticipantClick:d,onReportParticipantClick:u,dmAgentEnabled:f,onMessageSent:m,viewerLanguage:x,renderChannelBanner:c,customChannelActions:p,renderChannelActions:j,onParticipantNameClick:b,onOutboundClick:v,resolveOutbound:g,renderMessage:y,onMessageLinkClick:w,showChannelInfo:M,composerInput:A,attachmentPreviewList:R})=>{const{client:z,isConnected:F,isLoading:L,error:I,refreshConnection:O,service:T,debug:k}=Jt(),[E,P]=h.useState(null),[$,U]=h.useState(null),[X,q]=h.useState(!1),{showDeleteConversation:K=!0}=e,V=h.useRef(l);V.current=l;const N=h.useRef(a);N.current=a;const D=h.useRef(null),G=h.useRef(null);h.useEffect(()=>{G.current=E},[E]),h.useEffect(()=>{if(!z||!F)return;const Y=z.userID;if(!Y)return;const J=`${Y}::${i}`;if(D.current===J)return;D.current=J;const ee=()=>{D.current===J&&(D.current=null)};(async()=>{var ke,oe;try{k&&console.log("[MessagingShell] Loading initial conversation with:",i);const te=await z.queryChannels({type:"messaging",members:{$eq:[Y,i]}},{},{limit:1});if(te.length>0){P(te[0]),U(null),(ke=N.current)==null||ke.call(N,te[0]),k&&console.log("[MessagingShell] Initial conversation loaded:",te[0].id);return}const le=V.current;if(!le||!T){ee(),U("No conversation found with this account"),k&&console.log("[MessagingShell] No conversation found for:",i);return}try{const ie=await T.startChannelWithParticipant({id:le.id,name:le.name,phone:le.phone});P(ie),U(null),(oe=N.current)==null||oe.call(N,ie),k&&console.log("[MessagingShell] Channel created and loaded:",ie.id)}catch(ie){console.error("[MessagingShell] Failed to create conversation:",ie),ee(),U("Failed to create conversation")}}catch(te){console.error("[MessagingShell] Failed to load initial conversation:",te),ee(),G.current||U("Failed to load conversation")}})()},[i,z,F,T,k]);const B=h.useRef(r);B.current=r;const Q=h.useCallback(()=>{var Y;P(null),q(!0),(Y=B.current)==null||Y.call(B)},[]);return L?t.jsx(Le,{}):I?t.jsx(be,{message:I,onBack:O}):!F||!z?t.jsx(be,{message:"Not connected to messaging service",onBack:O}):$?t.jsx(be,{message:$}):X&&!E?t.jsx(be,{message:"Conversation ended"}):E?t.jsx("div",{className:"messaging-shell h-full bg-background-primary overflow-hidden",children:t.jsx("div",{className:"flex h-full min-h-0 flex-col",children:t.jsx(ht,{channel:E,renderMessageInputActions:s,renderConversationFooter:n,renderChannelBanner:c,onLeaveConversation:Q,onBlockParticipant:Q,CustomChannelEmptyState:o,showDeleteConversation:K,onBlockParticipantClick:d,onReportParticipantClick:u,dmAgentEnabled:f,onMessageSent:m,viewerLanguage:x,customChannelActions:p,renderChannelActions:j,onParticipantNameClick:b,onOutboundClick:v,resolveOutbound:g,renderMessage:y,onMessageLinkClick:w,showChannelInfo:M,composerInput:A,attachmentPreviewList:R},E.id)})}):t.jsx(Le,{})};function Br(e){const s=e.state.pending_messages;if(s!=null&&s.length)for(const n of s)e.state.addMessageSorted(n.message)}const Rs=h.createContext({selectedChannel:void 0,onChannelSelect:()=>{},debug:!1,renderMessagePreview:void 0,channelPreview:void 0,viewerLanguage:void 0}),$r=Rs.Provider,Ur=()=>h.useContext(Rs),Hr=(e,s)=>{const n=Date.UTC(e.getFullYear(),e.getMonth(),e.getDate()),a=Date.UTC(s.getFullYear(),s.getMonth(),s.getDate());return Math.floor((a-n)/(1e3*60*60*24))},Ls=e=>{const s=new Date;if(Math.floor((s.getTime()-e.getTime())/1e3)<60)return"Just now";const a=Hr(e,s);return a===0?e.toLocaleTimeString([],{hour:"numeric",minute:"2-digit",hour12:!0}):a===1?"Yesterday":a<7?e.toLocaleDateString(void 0,{weekday:"short"}):e.getFullYear()===s.getFullYear()?e.toLocaleDateString(void 0,{month:"short",day:"numeric"}):e.toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"})},Ds=h.memo(e=>{var z,F,L;const{channel:s,unread:n}=e,{selectedChannel:a,onChannelSelect:r,debug:i,channelPreview:l,renderMessagePreview:o,viewerLanguage:d}=Ur(),{client:u}=_.useChatContext(),f=(a==null?void 0:a.id)===(s==null?void 0:s.id),m=Qt(s);if(l){const I=l;return t.jsx(I,{...e,active:f,selectedChannel:a,onChannelSelect:r,viewerLanguage:d})}const x=()=>{s&&r(s)},c=I=>{const O=I.key==="Enter"||I.key===" ",T=I.repeat;!O||T||(I.preventDefault(),x())},p=We((z=s==null?void 0:s.state)==null?void 0:z.members,u==null?void 0:u.userID,s==null?void 0:s.type),j=qe(p==null?void 0:p.user),b=(F=p==null?void 0:p.user)==null?void 0:F.image,v=(()=>{var O;const I=(O=s==null?void 0:s.state)==null?void 0:O.messages;if(I!=null&&I.length){for(let T=I.length-1;T>=0;T--)if(I[T].type!=="system")return I[T]}})(),y=(()=>{var E;const I=Xe({message:v,viewerLanguage:d}),{custom_type:O,attachment_content_type:T}=(v==null?void 0:v.metadata)||{};if(O===W.MESSAGE_CUSTOM_TYPE.TIP)return I||"Sent a tip";if(O===W.MESSAGE_CUSTOM_TYPE.PAID)return I||"Sent a message";if(O===W.MESSAGE_CUSTOM_TYPE.ATTACHMENT){if(T==="text")return"🔒 Sent a locked message";if(T==="media")return"🔒 Sent a locked attachment"}if(I)return I;const k=(E=v==null?void 0:v.attachments)==null?void 0:E[0];return k?k.og_scrape_url?k.og_scrape_url:k.type==="image"?"📷 Sent an image":k.type==="video"?"🎥 Sent a video":k.type==="audio"?"🎵 Sent audio":k.type==="file"?"📎 Sent a file":"📎 Sent an attachment":"No messages yet"})(),w=v!=null&&v.created_at?Ls(new Date(v.created_at)):"",M=v?Te(v):!1,A=o?o(v,y):`${M?"✨ ":""}${y}`,R=n??0;return i&&console.log("📺 [ChannelList] 📋 CHANNEL PREVIEW RENDER",{channelId:s==null?void 0:s.id,isSelected:f,participantName:j,unreadCount:R,hasTimestamp:!!w}),t.jsx("div",{role:"button",tabIndex:0,onClick:x,onKeyDown:c,className:C("group w-full px-4 py-3 transition-colors text-left max-w-full overflow-hidden focus-ring rounded-[12px] [&+&]:mt-2",{"bg-black/[0.04]":f,"hover:bg-black/[0.02]":!f}),"data-dd-privacy":"mask",children:t.jsxs("div",{className:"flex items-start gap-4",children:[t.jsx(ue,{id:((L=p==null?void 0:p.user)==null?void 0:L.id)||s.id||"unknown",name:j,image:b,size:48,starred:m}),t.jsxs("div",{className:"flex-1 min-w-0 flex flex-col gap-1",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsxs("h3",{className:C("text-sm font-medium truncate text-[#191918]"),children:[m&&t.jsx("span",{className:"sr-only",children:"Starred conversation. "}),j]}),w&&t.jsx("span",{className:"text-xs text-[#717070] flex-shrink-0",children:w})]}),t.jsxs("div",{className:"flex items-center justify-between gap-2 min-w-0",children:[t.jsx("p",{className:"text-sm text-[#717070] flex-1 line-clamp-1",children:A}),R>0&&t.jsx("span",{className:"bg-[#7f22fe] text-white text-[10px] rounded-full h-4 flex items-center justify-center p-1 min-w-4 text-center flex-shrink-0",children:R>99?"99+":R})]})]})]})})});Ds.displayName="CustomChannelPreview";const Vr={last_message_at:-1},Os=h.memo(({onChannelSelect:e,selectedChannel:s,filters:n,allowNewMessagesFromUnfilteredChannels:a=!1,channelRenderFilterFn:r,sort:i=Vr,className:l,customEmptyStateIndicator:o,channelListPaginator:d=_.InfiniteScroll,channelPreview:u,renderMessagePreview:f,viewerLanguage:m,lockChannelOrder:x,onMessageNewHandler:c,onMessageNew:p,onChannelVisible:j,onAddedToChannel:b,onChannelUpdated:v})=>{const g=h.useRef(0);g.current++;const{debug:y=!1}=Ye(),w=h.useCallback(A=>{for(const R of A)Br(R);return r?r(A):A},[r]);y&&console.log("📺 [ChannelList] 🔄 RENDER START",{renderCount:g.current,selectedChannelId:s==null?void 0:s.id,filters:n});const M=h.useMemo(()=>({selectedChannel:s,onChannelSelect:e,debug:y,channelPreview:u,renderMessagePreview:f,viewerLanguage:m}),[s,e,y,u,f,m]);return t.jsx("div",{className:C("messaging-channel-list h-full flex flex-col min-w-0 overflow-hidden",l),children:t.jsx("div",{className:"flex-1 overflow-hidden min-w-0",children:t.jsx($r,{value:M,children:t.jsx(_.ChannelList,{filters:n,sort:i,options:{limit:30},allowNewMessagesFromUnfilteredChannels:a,channelRenderFilterFn:w,lockChannelOrder:x,onMessageNewHandler:c,onMessageNew:p,onChannelVisible:j,onAddedToChannel:b,onChannelUpdated:v,Paginator:d,Preview:Ds,EmptyStateIndicator:o},`${JSON.stringify(n)}:${JSON.stringify(i)}`)})})})});Os.displayName="ChannelList";const Gr="line-clamp-2 text-[14px] font-medium leading-5 tracking-[0.28px] [text-wrap:balance]",Yr="text-[12px] leading-4 tracking-[0.24px] [text-wrap:pretty]",Xt=({surface:e,actions:s,layout:n})=>{if(s==null||s.length===0)return null;const a=n==="stacked";return t.jsx("div",{className:C("flex gap-2",a?"mt-3 flex-col":"min-w-0 max-w-[60%] flex-row flex-wrap justify-end"),children:s.map((r,i)=>t.jsx(hs,{variant:e,cta:r,fullWidth:a,standalone:!0},`${r.label}-${i}`))})},Wr=({ctaSurface:e,chinTextColor:s,title:n,subtitle:a,subtitleLines:r=3,appIcon:i,actions:l})=>{var p;const o=n!=null&&n.trim()!=="",d=a!=null&&a.trim()!=="",u=l!=null&&l.length>0;if(!o&&!d&&!u)return null;const f={color:s},m=r>1?{...f,display:"-webkit-box",WebkitBoxOrient:"vertical",WebkitLineClamp:r,overflow:"hidden"}:f,x=u&&(((p=l==null?void 0:l[0])==null?void 0:p.variant)??"primary")==="secondary",c=t.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-[2px]",children:[o&&t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[i?t.jsx("span",{className:"shrink-0",children:i}):null,t.jsx("p",{className:C("min-w-0",Gr),style:f,children:n})]}),d&&t.jsx("p",{className:C(Yr,r>1&&"whitespace-pre-line",r<=1&&"truncate"),style:m,children:a})]});return t.jsx("div",{className:"shrink-0 px-4 py-3",children:x?t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[c,t.jsx(Xt,{surface:e,actions:l,layout:"row"})]}):t.jsxs(t.Fragment,{children:[c,t.jsx(Xt,{surface:e,actions:l,layout:"stacked"})]})})},qr={dark:"bg-white/[0.06]",light:"bg-black/[0.04]"},Xr={1:[0],2:[-10,10],3:[-13,0,13]},Kr={1:[0],2:[-26,26],3:[-40,0,40]},Zr={1:[0],2:[0,1],3:[1,3,2]},Jr={1:[1],2:[1,1],3:[1,1.08,1]},Qr=({variant:e,images:s})=>{const[n,a]=h.useState({}),r=s.join(`
|
|
2
|
-
`),[i,l]=h.useState(r);r!==i&&(l(r),a({}));const o=s.slice(0,3).map((c,p)=>({src:c,index:p})).filter(({index:c})=>!n[c]),d=o.length>=3?3:o.length===2?2:1,u=Xr[d],f=Kr[d],m=Zr[d],x=Jr[d];return t.jsx("div",{className:C("relative flex min-h-0 w-full flex-1 items-center justify-center overflow-hidden",qr[e]),children:o.map(({src:c,index:p},j)=>t.jsx("img",{src:se(c)??c,alt:"",draggable:!1,loading:"lazy",decoding:"async",onError:()=>a(b=>({...b,[p]:!0})),className:"absolute left-1/2 top-1/2 w-[62%] aspect-[3/2] rounded-[12px] bg-[#ffffff] object-cover shadow-md",style:{transform:`translate(-50%, -50%) translateX(${f[j]}px) rotate(${u[j]}deg) scale(${x[j]})`,zIndex:m[j]}},`${c}-${p}`))})},ei="flex h-[180px] w-full shrink-0 flex-col overflow-hidden",ti=({variant:e,presentation:s,images:n,title:a,heroUrl:r,onHeroError:i})=>t.jsx("div",{className:ei,children:s==="fan"?t.jsx(Qr,{variant:e,images:n}):t.jsx(je,{variant:e,thumbnailUrl:r,title:a,mimeType:"image/*",onImageError:i})}),Ps=({variant:e,title:s,subtitle:n,subtitleLines:a,images:r=[],imagePresentation:i,actions:l,appIcon:o,accentColor:d,groupPosition:u="single"})=>{const f=W.resolveRichCardImagePresentation({imagePresentation:i,images:r}),m=r.length>0,x=m&&f==="hero",c=Pe({variant:e,accentColor:d,layout:"featured",thumbnailUrl:x?r[0]:void 0}),p=u==="single"||u==="end";return t.jsx(it,{accentHex:c.accentHex,side:e==="dark"?"sender":"receiver",visible:p,children:t.jsxs(ve,{variant:e,accentHex:c.accentHex,"data-testid":"rich-card",children:[m&&t.jsx(ti,{variant:e,presentation:f,images:r,title:s,heroUrl:x?c.thumbnailUrl:void 0,onHeroError:c.onImageError}),t.jsx(Wr,{ctaSurface:c.surface,chinTextColor:c.chinTextColor,title:s,subtitle:n,subtitleLines:a,appIcon:o,actions:l})]})})},si=e=>t.jsx(Ps,{...e,variant:"dark"}),ni=e=>t.jsx(Ps,{...e,variant:"light"}),ai={Sent:si,Received:ni},Kt=`url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='23' fill='none'%3E%3Cpath fill='black' d='M0 0H15C15 10.1934 15.859 15.2345 19.168 21.4893C19.527 22.168 19.039 22.9917 18.274 22.9178C5.176 21.6506 0.32 6.0737 0 0Z'/%3E%3C/svg%3E") no-repeat center / 100% 100%`,ri={sent:"var(--str-chat__own-message-bubble-background-color, #1e2330)",received:"var(--str-chat__message-bubble-background-color, #f1f0ee)"},ii=({variant:e})=>t.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute bottom-0 z-[-1] h-[1.4375rem] w-5",style:{insetInlineEnd:e==="sent"?"calc(-1 * 0.25rem)":void 0,insetInlineStart:e==="received"?"calc(-1 * 0.25rem)":void 0,transform:e==="received"?"scaleX(-1)":void 0,transformOrigin:"center",backgroundColor:ri[e],WebkitMask:Kt,mask:Kt}}),oi={sent:{backgroundColor:"var(--str-chat__own-message-bubble-background-color, #1e2330)",color:"var(--str-chat__own-message-bubble-color, #fff)"},received:{backgroundColor:"var(--str-chat__message-bubble-background-color, #f1f0ee)",color:"var(--str-chat__message-bubble-color, #000000)"}},Fs=({variant:e,text:s,tail:n=!0,header:a,className:r})=>t.jsxs("div",{"data-dd-privacy":"mask",className:C("relative px-4 py-3","text-[0.875rem] leading-[1.3125rem] tracking-[0.14px]",r),style:{...oi[e],borderRadius:"var(--str-chat__message-bubble-border-radius, 1.5rem)",isolation:"isolate"},children:[a!=null&&t.jsx("div",{className:"mb-1 font-medium","data-testid":"message-bubble-header",children:a}),t.jsx("p",{className:"m-0 whitespace-pre-wrap break-words hyphens-manual",children:s}),n&&t.jsx(ii,{variant:e})]}),li=({text:e,tail:s,header:n,className:a})=>t.jsx(Fs,{variant:"received",text:e,tail:s,header:n,className:a}),ci=({text:e,tail:s,className:n})=>t.jsx(Fs,{variant:"sent",text:e,tail:s,className:n}),di={Sent:ci,Received:li},zs=({question:e,onClick:s,loading:n=!1,className:a})=>t.jsx("button",{type:"button",onClick:s,disabled:n,style:{backgroundColor:"#E6E5E3"},className:C("w-full text-center p-4 rounded-xl text-charcoal font-medium transition-colors focus-ring",{"hover:brightness-95 active:brightness-90":!n,"opacity-50 cursor-not-allowed":n},a),children:e}),ui=({faqs:e,onFaqClick:s,loadingFaqId:n,headerText:a,className:r,avatarImage:i,avatarName:l})=>{const o=W.selectEnabledFaqs(e);return o.length===0?null:t.jsx("div",{className:r,children:t.jsxs("div",{className:"flex gap-3 items-end",children:[(i||l)&&t.jsx("div",{className:"flex-none",children:t.jsx(ue,{id:l||"account",name:l||"Account",image:i,size:24,shape:"circle"})}),t.jsxs("div",{className:"flex-1 flex flex-col gap-3 rounded-lg p-4",style:{backgroundColor:"#F1F0EE"},children:[a&&t.jsx("p",{className:"text-md text-charcoal mb-4",children:a}),o.map(d=>t.jsx(zs,{question:d.question,onClick:()=>s(d.id),loading:n===d.id},d.id))]})]})})};exports.ActionButton=fe;exports.AttachmentThumbnail=Ke;exports.Avatar=ue;exports.ChannelEmptyState=As;exports.ChannelList=Os;exports.ChannelView=ht;exports.CustomMessageProvider=Cn;exports.FaqList=ui;exports.FaqListItem=zs;exports.LinkAttachment=Ae;exports.LockedAttachment=pe;exports.MediaMessage=_n;exports.MessageAttachment=xe;exports.MessageBubble=di;exports.MessagingProvider=Vs;exports.MessagingShell=zr;exports.RichCard=ai;exports.TipMessage=ms;exports.bubbleGroupPositionFromStream=ma;exports.buildCompactMetaLabel=ps;exports.formatFileSize=xs;exports.formatRelativeTime=Ls;exports.getFileExtensionLabel=gs;exports.getMessageDisplayText=Xe;exports.getSourceType=ae;exports.isLinkAttachment=we;exports.isTipMessage=et;exports.isUuidLike=es;exports.normalizeLanguageCode=ss;exports.optimizeMessagingAttachmentUrl=se;exports.renderTypeIcon=de;exports.resolveConversationParticipant=We;exports.resolveLinkAttachment=De;exports.resolveMediaFromMessage=Oe;exports.resolveParticipantDisplayName=qe;exports.useComposerLocked=yr;exports.useCustomMessage=cs;exports.useMessaging=Jt;
|
|
3
|
-
//# sourceMappingURL=index-B50WBNpA.cjs.map
|