@linktr.ee/messaging-react 4.4.0-rc-1787552892 β 4.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AttachmentCard-BqwWgqvi.js +369 -0
- package/dist/AttachmentCard-BqwWgqvi.js.map +1 -0
- package/dist/AttachmentCard-DUrgGRsq.cjs +2 -0
- package/dist/AttachmentCard-DUrgGRsq.cjs.map +1 -0
- package/dist/Card-BIbqWagz.cjs +2 -0
- package/dist/Card-BIbqWagz.cjs.map +1 -0
- package/dist/Card-C7uLQbYz.js +105 -0
- package/dist/Card-C7uLQbYz.js.map +1 -0
- package/dist/Card-Ds1FMcUj.cjs +2 -0
- package/dist/Card-Ds1FMcUj.cjs.map +1 -0
- package/dist/Card-f51K6V7Y.js +498 -0
- package/dist/Card-f51K6V7Y.js.map +1 -0
- package/dist/LoadingDots-BSk_UeS0.cjs +2 -0
- package/dist/LoadingDots-BSk_UeS0.cjs.map +1 -0
- package/dist/LoadingDots-B_WiXBeQ.js +73 -0
- package/dist/LoadingDots-B_WiXBeQ.js.map +1 -0
- package/dist/assets/index.css +2 -1
- package/dist/index.cjs +3 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +3925 -38
- package/dist/index.js.map +1 -1
- package/dist/rolldown-runtime-BocRIvOZ.cjs +1 -0
- package/dist/testing.cjs +2 -2
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.js +106 -118
- package/dist/testing.js.map +1 -1
- package/package.json +5 -5
- package/src/components/MessageAttachment/_shared/MediaStackGrid.test.tsx +28 -0
- package/src/components/MessageAttachment/_shared/MediaStackGrid.tsx +22 -14
- package/dist/Card-Be81K6su.cjs +0 -2
- package/dist/Card-Be81K6su.cjs.map +0 -1
- package/dist/Card-BzvDr-pU.js +0 -112
- package/dist/Card-BzvDr-pU.js.map +0 -1
- package/dist/Card-ChcosZir.js +0 -1034
- package/dist/Card-ChcosZir.js.map +0 -1
- package/dist/Card-KU88ECCR.cjs +0 -2
- package/dist/Card-KU88ECCR.cjs.map +0 -1
- package/dist/PurchaseStatusBadge-BmqAQEV9.cjs +0 -2
- package/dist/PurchaseStatusBadge-BmqAQEV9.cjs.map +0 -1
- package/dist/PurchaseStatusBadge-D1RRsubZ.js +0 -59
- package/dist/PurchaseStatusBadge-D1RRsubZ.js.map +0 -1
- package/dist/index-Dg235rZT.js +0 -5364
- package/dist/index-Dg235rZT.js.map +0 -1
- package/dist/index-WEbnLVHC.cjs +0 -3
- package/dist/index-WEbnLVHC.cjs.map +0 -1
package/dist/index-WEbnLVHC.cjs
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
"use strict";const s=require("react/jsx-runtime"),x=require("react"),zs=require("@linktr.ee/messaging-core"),Ee=require("stream-chat"),w=require("stream-chat-react"),H=require("@linktr.ee/messaging-taxonomy"),y=require("classnames"),C=require("@phosphor-icons/react"),Ve=require("stream-chat-react/experimental"),ge={debug:(e,...t)=>console.log(e,...t),info:(e,...t)=>console.log(e,...t),warn:(e,...t)=>console.warn(e,...t),error:(e,...t)=>console.error(e,...t)},Wt=e=>({debug:(e==null?void 0:e.debug)??ge.debug,info:(e==null?void 0:e.info)??ge.info,warn:(e==null?void 0:e.warn)??ge.warn,error:(e==null?void 0:e.error)??ge.error}),qt=x.createContext(ge),Xt=({logger:e,children:t})=>{const n=x.useMemo(()=>Wt(e),[e]);return s.jsx(qt.Provider,{value:n,children:t})},$s=()=>x.useContext(qt),Kt=x.createContext({service:null,client:null,isConnected:!1,isLoading:!1,error:null,capabilities:{},refreshConnection:async()=>{},debug:!1}),He=()=>x.useContext(Kt),Us=({children:e,user:t,serviceConfig:n,apiKey:a,capabilities:r={},debug:i=!1,client:l,logger:d})=>{var O,$;const c=x.useCallback((B,...D)=>{i&&console.log(`π₯ [MessagingProvider] ${B}`,...D)},[i]);c("π RENDER START",{userId:t==null?void 0:t.id,apiKey:(a==null?void 0:a.substring(0,8))+"...",serviceConfig:!!n,capabilities:Object.keys(r)});const[u,h]=x.useState(null),[m,f]=x.useState(null),[o,v]=x.useState(!1),[_,p]=x.useState(!1),[b,g]=x.useState(null),N=x.useRef(!1),j=x.useRef(null),E=x.useRef(n);E.current=n;const T=x.useRef(i);T.current=i;const A=x.useRef(d);A.current=d;const R=x.useRef({userId:t==null?void 0:t.id,apiKey:a,serviceConfig:n,capabilities:r}),F=x.useRef(0);F.current++,c("π RENDER INFO",{renderCount:F.current,currentProps:{userId:t==null?void 0:t.id,apiKey:(a==null?void 0:a.substring(0,8))+"..."},propChanges:{userChanged:R.current.userId!==(t==null?void 0:t.id),apiKeyChanged:R.current.apiKey!==a,serviceConfigChanged:R.current.serviceConfig!==n,capabilitiesChanged:R.current.capabilities!==r}}),R.current={userId:t==null?void 0:t.id,apiKey:a,serviceConfig:n,capabilities:r};const L=x.useRef(null);!l&&a&&((O=L.current)==null?void 0:O.apiKey)!==a&&(L.current={apiKey:a,client:new Ee.StreamChat(a)});const S=l||(a?(($=L.current)==null?void 0:$.client)??null:null);x.useEffect(()=>{const B=F.current,D=E.current;if(l){j.current=null,h(null),f(null),v(!1),g(null),p(!1);return}if(!a||!S||!D){c("β οΈ SERVICE INIT SKIPPED",{renderCount:B,reason:"Missing apiKey, client, or serviceConfig"});return}c("π CREATING SERVICE",{renderCount:B,apiKey:(a==null?void 0:a.substring(0,8))+"..."});const Y=new zs.StreamChatService({...D,apiKey:a,debug:T.current,client:S,...D.logger||!A.current?{}:{logger:Wt(A.current)}});j.current=Y,h(Y),c("β
SERVICE SET",{renderCount:B,serviceInstance:!!Y})},[a,S,l]);const M=x.useRef(null);x.useEffect(()=>{var D,Y;if(c("π USER CONNECTION EFFECT TRIGGERED",{hasService:!!u,hasUser:!!t,userId:t==null?void 0:t.id,isConnecting:N.current,isConnected:o,dependencies:{service:!!u,userId:t==null?void 0:t.id}}),l)return;if(!u||!t){c("β οΈ USER CONNECTION SKIPPED","Missing service or user");return}if(N.current){c("β οΈ USER CONNECTION SKIPPED","Already connecting");return}if(((D=M.current)==null?void 0:D.serviceId)===u&&((Y=M.current)==null?void 0:Y.userId)===t.id){c("β οΈ USER CONNECTION SKIPPED","Already connected this user with this service");return}(async()=>{c("π STARTING USER CONNECTION",{userId:t.id}),N.current=!0,p(!0),g(null);try{c("π CALLING SERVICE.CONNECTUSER",{userId:t.id});const U=await u.connectUser(t);f(U),v(!0),M.current={serviceId:u,userId:t.id},c("β
USER CONNECTION SUCCESS",{userId:t.id,clientId:U.userID})}catch(U){const W=U instanceof Error?U.message:"Connection failed";g(W),c("β USER CONNECTION ERROR",{userId:t.id,error:W})}finally{p(!1),N.current=!1,c("π USER CONNECTION FINISHED",{userId:t.id,isConnected:o})}})()},[u,t,c,o,l]),x.useEffect(()=>{const B=S;return()=>{var D;B&&(M.current=null,(D=j.current)==null||D.disconnectUser().catch(console.error))}},[S]);const I=x.useCallback(async()=>{if(c("π REFRESH CONNECTION CALLED",{hasService:!!u,hasUser:!!t}),!l){if(!u||!t){c("β οΈ REFRESH CONNECTION SKIPPED","Missing service or user");return}c("π STARTING CONNECTION REFRESH",{userId:t.id}),p(!0);try{c("π DISCONNECTING FOR REFRESH"),await u.disconnectUser(),c("π RECONNECTING FOR REFRESH");const B=await u.connectUser(t);f(B),v(!0),g(null),c("β
CONNECTION REFRESH SUCCESS",{userId:t.id})}catch(B){const D=B instanceof Error?B.message:"Refresh failed";g(D),c("β CONNECTION REFRESH ERROR",{userId:t.id,error:D})}finally{p(!1),c("π CONNECTION REFRESH FINISHED",{userId:t.id})}}},[u,t,c,l]),k=x.useMemo(()=>(c("π« CONTEXT VALUE MEMOIZATION",{hasService:!!u,hasClient:!!m,isConnected:o,isLoading:_,hasError:!!b,capabilitiesKeys:Object.keys(r)}),{service:l?null:u,client:l??m,isConnected:l?!0:o,isLoading:l?!1:_,error:l?null:b,capabilities:r,refreshConnection:I,debug:i}),[u,m,l,o,_,b,r,I,i,c]);return c("π RENDER END",{renderCount:F.current,willRenderChat:!!S,contextValueReady:!!k}),s.jsx(Xt,{logger:d,children:s.jsx(Kt.Provider,{value:k,children:S?s.jsx(w.Chat,{client:S,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})})},Zt=()=>He(),Jt=e=>{var a,r;const[t,n]=x.useState(!!((r=(a=e==null?void 0:e.state)==null?void 0:a.membership)!=null&&r.pinned_at));return x.useEffect(()=>{var l;if(!e){n(!1);return}n(!!((l=e.state.membership)!=null&&l.pinned_at));const i=d=>{var c;n(d!=null&&d.member?!!d.member.pinned_at:!!((c=e.state.membership)!=null&&c.pinned_at))};return e.on("member.updated",i),()=>{e.off("member.updated",i)}},[e]),t};function Ge(e,t,n){const a=Object.values(e||{});if(H.isOfficialChannel(n)){const r=a.find(i=>{var l;return((l=i.user)==null?void 0:l.id)===H.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!==t})}const Vs=/^[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 Qt(e){return Vs.test(e.trim())}function Tt(e,t){const n=e==null?void 0:e.trim();return!n||t&&n===t||t&&n===`Follower ${t}`?!1:!Qt(n)}function Ye(e){return Tt(e==null?void 0:e.name,e==null?void 0:e.id)?e.name.trim():Tt(e==null?void 0:e.username,e==null?void 0:e.id)?e.username.trim():"Unknown member"}const At=[{emoji:"π",bgColor:"#FFD1DD"},{emoji:"π",bgColor:"#FFF1C9"},{emoji:"π",bgColor:"#E6D9FF"},{emoji:"π",bgColor:"#D6F4FF"},{emoji:"π",bgColor:"#FFE0AE"},{emoji:"π₯₯",bgColor:"#F7E7D8"},{emoji:"π",bgColor:"#DFF4D8"},{emoji:"π₯",bgColor:"#FFD8C2"},{emoji:"π",bgColor:"#D6EBFF"},{emoji:"π",bgColor:"#CAEEB5"},{emoji:"π₯",bgColor:"#FFE7C7"},{emoji:"π«",bgColor:"#F6E3B4"},{emoji:"π",bgColor:"#D9F7E1"}];function Hs(e){let t=0;for(let n=0;n<e.length;n++){const a=e.charCodeAt(n);t=(t<<5)-t+a,t=t&t}return Math.abs(t)}function es(e){return At[Hs(e)%At.length]}function Gs(e){return es(e).emoji}function Ys(e){return es(e).bgColor}const he=({id:e,image:t,size:n=40,className:a,starred:r=!1,shape:i="squircle",dmAgentEnabled:l=!1})=>{const d=Gs(e),c=Ys(e),u=.45,m=n<32?Math.round(n*u):n<56?14:n<120?18:36,f=n>=40?2:1,o=i==="circle"?{borderRadius:"50%"}:{borderRadius:"1rem"},v=s.jsx("div",{className:"h-full w-full overflow-hidden",style:o,children:t?s.jsx("img",{src:t,alt:"",className:"h-full w-full object-cover"}):s.jsx("div",{"aria-hidden":"true",className:y("avatar-fallback flex h-full w-full items-center justify-center font-semibold select-none transition-colors"),style:{fontSize:m,lineHeight:1},children:d})});return s.jsxs("div",{className:y("relative flex-shrink-0",a),style:{"--str-chat__avatar-size":`${n}px`,width:`${n}px`,height:`${n}px`,backgroundColor:t?void 0:c,...o},children:[r&&s.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:s.jsx(C.StarIcon,{className:"size-3 text-yellow-600",weight:"duotone"})}),s.jsx("div",{"data-testid":"avatar-ring",className:y("h-full w-full","bg-transparent"),style:{...o,...l&&{borderWidth:`${f}px`,borderStyle:"solid",borderColor:"var(--AI-Gradient, #7F22FE)",boxShadow:"inset 0 1px 2px 0 rgba(255, 255, 255, 0.5)"}},children:v})]})},Ws="https://linktr.ee/s/about/trust-center/report",qs=({channel:e,participant:t,showBlockParticipant:n=!0,enabled:a=!0,onLeaveConversation:r,onBlockParticipant:i,onDeleteConversationClick:l,onBlockParticipantClick:d,onReportParticipantClick:c,onActionComplete:u,logLabel:h="useChannelModerationActions"})=>{var M;const{service:m,debug:f}=He(),o=(M=t==null?void 0:t.user)==null?void 0:M.id,v=!!(a&&n&&m&&o),[_,p]=x.useState(!1),[b,g]=x.useState(null),[N,j]=x.useState(!1),[E,T]=x.useState(!1),A=v&&((b==null?void 0:b.participantId)!==o||(b==null?void 0:b.service)!==m);return x.useEffect(()=>{if(!v||!m||!o){p(!1),g(null);return}let I=!1;return(async()=>{try{const k=await m.getBlockedUsers();if(I)return;p(k.some(O=>O.blocked_user_id===o))}catch(k){I||console.error(`[${h}] Failed to check blocked status:`,k)}finally{I||g({participantId:o,service:m})}})(),()=>{I=!0}},[v,m,o,h]),{isParticipantBlocked:_,isCheckingBlockedStatus:A,isLeaving:N,isUpdatingBlockStatus:E,handleLeaveConversation:async()=>{var I;if(!N){l==null||l(),f&&console.log(`[${h}] Leave conversation`,e.cid),j(!0);try{const k=((I=e._client)==null?void 0:I.userID)??null;await e.hide(k,!1),r&&await r(e),u==null||u()}catch(k){console.error(`[${h}] Failed to leave conversation`,k)}finally{j(!1)}}},handleBlockUser:async()=>{var I,k,O;if(!(E||!m)){d==null||d(),f&&console.log(`[${h}] Block member`,(I=t==null?void 0:t.user)==null?void 0:I.id),T(!0);try{await m.blockUser((k=t==null?void 0:t.user)==null?void 0:k.id),i&&await i((O=t==null?void 0:t.user)==null?void 0:O.id),u==null||u()}catch($){console.error(`[${h}] Failed to block member`,$)}finally{T(!1)}}},handleUnblockUser:async()=>{var I,k,O;if(!(E||!m)){d==null||d(),f&&console.log(`[${h}] Unblock member`,(I=t==null?void 0:t.user)==null?void 0:I.id),T(!0);try{await m.unBlockUser((k=t==null?void 0:t.user)==null?void 0:k.id),i&&await i((O=t==null?void 0:t.user)==null?void 0:O.id),u==null||u()}catch($){console.error(`[${h}] Failed to unblock member`,$)}finally{T(!1)}}},handleReportUser:()=>{c==null||c(),u==null||u(),window.open(Ws,"_blank","noopener,noreferrer")}}},ue=({variant:e="default",className:t,children:n,...a})=>{const r=e==="danger";return s.jsx("button",{type:"button",className:y("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",t),...a,children:n})},Xs=({channel:e,participant:t,showDeleteConversation:n=!0,showBlockParticipant:a=!0,showReportParticipant:r=!0,onLeaveConversation:i,onBlockParticipant:l,onDeleteConversationClick:d,onBlockParticipantClick:c,onReportParticipantClick:u,customChannelActions:h,triggerClassName:m})=>{const[f,o]=x.useState(!1),v=x.useRef(null),_=x.useId(),p=x.useCallback(()=>o(!1),[]),{isParticipantBlocked:b,isCheckingBlockedStatus:g,isLeaving:N,isUpdatingBlockStatus:j,handleLeaveConversation:E,handleBlockUser:T,handleUnblockUser:A,handleReportUser:R}=qs({channel:e,participant:t,showBlockParticipant:a,enabled:f,onLeaveConversation:i,onBlockParticipant:l,onDeleteConversationClick:d,onBlockParticipantClick:c,onReportParticipantClick:u,onActionComplete:p,logLabel:"ChannelActionsMenu"});return x.useEffect(()=>{if(!f)return;const L=M=>{v.current&&!v.current.contains(M.target)&&o(!1)},S=M=>{M.key==="Escape"&&o(!1)};return document.addEventListener("mousedown",L),document.addEventListener("keydown",S),()=>{document.removeEventListener("mousedown",L),document.removeEventListener("keydown",S)}},[f]),!t||!(n||a||r||!!h)?null:s.jsxs("div",{ref:v,className:"relative",children:[s.jsxs("button",{className:m,type:"button","aria-haspopup":"true","aria-expanded":f,"aria-controls":f?_:void 0,onClick:()=>o(L=>!L),children:[s.jsx(C.DotsThreeIcon,{className:"size-5 text-black/90"}),s.jsx("span",{className:"sr-only",children:"More options"})]}),f&&s.jsx("div",{id:_,"aria-label":"Conversation options",className:y("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:s.jsxs("ul",{className:"flex flex-col gap-1",children:[n&&s.jsx("li",{children:s.jsxs(ue,{onClick:E,disabled:N,"aria-busy":N,children:[N?s.jsx(C.SpinnerGapIcon,{className:"h-5 w-5 animate-spin"}):s.jsx(C.SignOutIcon,{className:"h-5 w-5"}),s.jsx("span",{children:"Delete Conversation"})]})}),a&&s.jsx("li",{children:g?s.jsxs(ue,{disabled:!0,"aria-busy":!0,children:[s.jsx(C.SpinnerGapIcon,{className:"h-5 w-5 animate-spin"}),s.jsx("span",{children:"Block"})]}):b?s.jsxs(ue,{onClick:A,disabled:j,"aria-busy":j,children:[j?s.jsx(C.SpinnerGapIcon,{className:"h-5 w-5 animate-spin"}):s.jsx(C.ProhibitInsetIcon,{className:"h-5 w-5"}),s.jsx("span",{children:"Unblock"})]}):s.jsxs(ue,{onClick:T,disabled:j,"aria-busy":j,children:[j?s.jsx(C.SpinnerGapIcon,{className:"h-5 w-5 animate-spin"}):s.jsx(C.ProhibitInsetIcon,{className:"h-5 w-5"}),s.jsx("span",{children:"Block"})]})}),r&&s.jsx("li",{children:s.jsxs(ue,{variant:"danger",onClick:R,children:[s.jsx(C.FlagIcon,{className:"h-5 w-5"}),s.jsx("span",{children:"Report"})]})}),h]})})]})},Fe="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",Ks="CUSTOMER_PAID",Zs=e=>typeof e=="string"&&e.trim().replace(/[\s-]+/g,"_").toUpperCase()===Ks,Js=({className:e,onBack:t,showBackButton:n,showStarButton:a=!1,onLeaveConversation:r,onBlockParticipant:i,showDeleteConversation:l=!0,showBlockParticipant:d=!0,showReportParticipant:c=!0,onDeleteConversationClick:u,onBlockParticipantClick:h,onReportParticipantClick:m,customChannelActions:f,renderChannelActions:o,showChannelInfo:v=!0,onParticipantNameClick:_})=>{var S,M,I,k;const{channel:p}=w.useChannelStateContext(),{client:b}=w.useChatContext(),g=x.useMemo(()=>{var O;return Ge((O=p.state)==null?void 0:O.members,b==null?void 0:b.userID,p.type)},[(S=p.state)==null?void 0:S.members,b==null?void 0:b.userID,p.type]),N=Ye(g==null?void 0:g.user),j=(M=g==null?void 0:g.user)==null?void 0:M.image,E=Jt(p),T=Zs((I=p.data)==null?void 0:I.customer_tag)&&(g==null?void 0:g.is_follower)===!0,A=a&&E,R=T||A||!!_,F=async()=>{try{E?await p.unpin():await p.pin()}catch(O){console.error("[ChannelHeaderRedesign] Failed to update pinned status:",O)}},L=s.jsxs(s.Fragment,{children:[s.jsx(he,{id:((k=g==null?void 0:g.user)==null?void 0:k.id)||p.id||"unknown",name:N,image:j,shape:"circle",size:48,className:"-mb-2"}),s.jsx("span",{className:y("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",R?"pl-3 pr-2":"px-3"),children:s.jsxs("span",{className:"flex max-w-full items-center justify-center",children:[s.jsx("span",{className:"min-w-0 truncate text-sm font-bold leading-[1.43] tracking-[0.28px] text-black/90",children:N}),R&&s.jsxs("span",{className:"ml-2 flex gap-1",children:[T&&s.jsx("span",{"aria-label":"Paid customer",className:"flex size-4 shrink-0 items-center justify-center rounded-full bg-[#34C759] text-white",children:s.jsx(C.CurrencyDollarIcon,{className:"size-2.5",weight:"bold"})}),A&&s.jsx("span",{className:"messaging-header-star-badge flex overflow-hidden",children:s.jsx("span",{"aria-label":"Starred conversation",className:"flex size-4 shrink-0 items-center justify-center rounded-full bg-[#FFD60A] text-white",children:s.jsx(C.StarIcon,{className:"size-2.5",weight:"fill"})})}),_&&s.jsx(C.CaretRightIcon,{"aria-hidden":"true",className:"size-4 shrink-0 text-black/65",weight:"bold"})]})]})})]});return s.jsx("div",{className:y("@container bg-[linear-gradient(180deg,#FBFAF9_0%,rgba(251,250,249,0.92)_58%,rgba(251,250,249,0)_100%)]",e),children:s.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:[s.jsx("div",{className:"flex items-start",children:n&&s.jsx("button",{className:y(Fe,"messaging-channel-view-back-button-mobile messaging-channel-view-back-button-desktop"),onClick:t||(()=>{}),type:"button","aria-label":"Back to conversations",children:s.jsx(C.ArrowLeftIcon,{className:"size-5 text-black/90"})})}),s.jsx("div",{className:"flex min-w-0 justify-center","data-dd-privacy":"mask",children:_?s.jsx("button",{type:"button",onClick:_,"aria-label":`View details for ${N}`,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}):s.jsx("div",{className:"flex min-w-0 max-w-full flex-col items-center px-2",children:L})}),s.jsxs("div",{className:"flex items-start justify-end gap-2",children:[a&&s.jsx("button",{className:Fe,onClick:F,type:"button","aria-pressed":E,"aria-label":E?"Unstar conversation":"Star conversation",children:s.jsx(C.StarIcon,{className:y("size-5",{"text-[#FFD60A]":E,"text-black/90":!E}),weight:E?"fill":"regular"})}),v&&(o!==void 0?o:s.jsx(Xs,{channel:p,participant:g,showDeleteConversation:l,showBlockParticipant:d,showReportParticipant:c,onLeaveConversation:r,onBlockParticipant:i,onDeleteConversationClick:u,onBlockParticipantClick:h,onReportParticipantClick:m,customChannelActions:f,triggerClassName:Fe}))]})]})})},Qs=e=>s.jsx(w.DateSeparator,{...e,position:"center"});function ts(e){return(e==null?void 0:e.trim().toLowerCase().split(/[-_]/)[0])||void 0}function We({message:e,viewerLanguage:t}){var r;const n=e==null?void 0:e.text,a=ts(t);return a?((r=e==null?void 0:e.i18n)==null?void 0:r[`${a}_text`])??n:n}function Le(e){var t;return e.type==="link"||!!((t=e.og_scrape_url)!=null&&t.trim())&&!e.asset_url}const en={isUnlocking:()=>!1},tn={LockedAttachment:en},ss=x.createContext({}),sn=ss.Provider;function ns(e){return x.useContext(ss)[e]??tn[e]}const nn=x.lazy(()=>Promise.resolve().then(()=>require("./Card-Be81K6su.cjs"))),an=x.lazy(()=>Promise.resolve().then(()=>require("./Card-KU88ECCR.cjs"))),rn=()=>s.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=>s.jsx(x.Suspense,{fallback:s.jsx(rn,{}),children:e.contentType==="text"?s.jsx(nn,{...e}):s.jsx(an,{...e})}),on=({size:e=15})=>s.jsx("svg",{width:e,height:e,viewBox:"0 0 15 15",fill:"none","aria-hidden":"true",children:s.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})}),as=e=>{var t;return((t=e.metadata)==null?void 0:t.custom_type)===H.MESSAGE_CUSTOM_TYPE.PAID},Ie=e=>{var t;return((t=e.metadata)==null?void 0:t.custom_type)===H.MESSAGE_CUSTOM_TYPE.CHATBOT},qe=e=>{var t;return((t=e.metadata)==null?void 0:t.custom_type)===H.MESSAGE_CUSTOM_TYPE.ATTACHMENT},ln=e=>{var t;return qe(e)&&((t=e.metadata)==null?void 0:t.attachment_content_type)==="text"},cn=e=>{var t;return qe(e)&&((t=e.metadata)==null?void 0:t.attachment_content_type)!=="text"},dn=e=>{var t;return as(e)&&!!((t=e.metadata)!=null&&t.amount_text)},Mt=({message:e,isMyMessage:t=!1,hasAttachment:n=!1})=>{var m;const a=as(e),r=Ie(e);if(!a&&!r)return null;if(a){const f=(m=e.metadata)==null?void 0:m.amount_text;return f?s.jsxs("div",{className:"message-tag--paid inline-flex items-center gap-1 text-[12px] font-medium leading-[2] text-[#016630]",children:[s.jsx(C.GiftIcon,{size:12}),s.jsxs("span",{children:["Delivered with ",f," message"]})]}):null}const i=t&&n,l=i?"Sent with AI":"Sent by AI Assistant",d="inline-flex items-center text-[10px] font-normal leading-4 tracking-[0.2px]",c=i?"justify-end gap-2 text-black/30":t?"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=s.jsx("span",{className:"text-left",children:l}),h=s.jsx("span",{className:"inline-flex items-center leading-none",children:s.jsx(on,{size:i?12:15})});return s.jsx("div",{className:`${d} ${c}`,"data-testid":"message-chatbot-indicator",children:t&&!i?s.jsxs(s.Fragment,{children:[u,h]}):s.jsxs(s.Fragment,{children:[h,u]})})},Rt=`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%`,un={me:"var(--str-chat__own-message-bubble-background-color, #1e2330)",other:"var(--str-chat__message-bubble-background-color, #f1f0ee)"},Te=({side:e})=>s.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:un[e],WebkitMask:Rt,mask:Rt}}),rs=x.createContext(void 0),mn=e=>{var n;const t=(n=e.metadata)==null?void 0:n.outbound_id;return typeof t=="string"?t:void 0},hn=(e,t)=>{if(!t||!(e!=null&&e.length))return;const n=new Set;let a;for(const r of e){const i=mn(r);if(!i||n.has(i))continue;n.add(i);const l=t(i);l&&(a??(a={}),a[i]={id:l.id,...l.name!==void 0?{name:l.name}:{}})}return a},xn=(e,t)=>{if(e===t)return!0;if(!e||!t)return!1;const n=Object.keys(e),a=Object.keys(t);return n.length!==a.length?!1:n.every(r=>{var i,l;return e[r].id===((i=t[r])==null?void 0:i.id)&&e[r].name===((l=t[r])==null?void 0:l.name)})},fn=(e,t)=>{const n=hn(e,t),[a,r]=x.useState(n);return xn(a,n)?a:(r(n),n)},Xe=e=>{var t;return((t=e.metadata)==null?void 0:t.custom_type)===H.MESSAGE_CUSTOM_TYPE.TIP},is=({message:e})=>{var n;const t=(n=e.metadata)==null?void 0:n.amount_text;return t?s.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:[s.jsx("span",{className:"flex h-5 items-center text-[20px] leading-none","aria-hidden":"true",children:"π"}),s.jsxs("span",{className:"text-[14px] font-bold leading-[1.43] tracking-[0.28px] text-[rgba(4,4,3,0.9)]",children:[t," tip!"]})]}):null},Ke=()=>{const{message:e}=w.useMessageContext("SentMessageDeliveryStatus"),{messages:t}=w.useChannelStateContext("SentMessageDeliveryStatus"),n=(()=>{if(t)for(let a=t.length-1;a>=0;a-=1){const r=t[a];if(!(r.type==="system"||r.type==="ephemeral"||r.type==="deleted"))return r.id}})();return e.id===n},ke=()=>Ke()?s.jsxs(s.Fragment,{children:[s.jsx(C.ChecksIcon,{weight:"bold","aria-hidden":"true"}),s.jsx("span",{"data-testid":"sent-message-delivery-status",children:"Delivered"})]}):null,gn=()=>Ke()?s.jsxs(s.Fragment,{children:[s.jsx(C.CircleNotchIcon,{className:"sent-message-status__spinner animate-spin",weight:"bold","aria-hidden":"true"}),s.jsx("span",{"data-testid":"sent-message-sending-status",children:"Sending"})]}):null,pn=({outbound:e,onOutboundClick:t})=>{const n=e.name||"Broadcast",a=!!t,r=s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"sent-message-outbound-badge","aria-hidden":"true",children:s.jsx(C.MegaphoneIcon,{weight:"fill"})}),s.jsx("span",{className:y("sent-message-outbound-name",{"underline [text-decoration-skip-ink:auto]":a}),"data-testid":"sent-message-outbound-status",children:n})]});return t?s.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:()=>t(e),children:r}):r},bn=()=>s.jsxs("span",{className:"str-chat__message-status sent-message-status--failed",children:[s.jsx(C.WarningCircleIcon,{weight:"bold","aria-hidden":"true"}),s.jsx("span",{"data-testid":"sent-message-failed-status",children:"Failed to send"})]}),vn=({onOutboundClick:e,resolvedOutbound:t})=>{var h;const{isMyMessage:n,message:a,threadList:r}=w.useMessageContext("SentMessageDeliveryStatus"),i=n(),l=Ke();if(r)return null;if(a.status==="failed"&&i&&a.type!=="error")return s.jsx(bn,{});if(!i)return null;const d=(h=a.metadata)==null?void 0:h.outbound_id,c=a.status!=="sending"&&a.status!=="failed"&&d&&t?s.jsx(pn,{outbound:t,onOutboundClick:e}):null,u=dn(a)?null:s.jsx(w.MessageStatus,{MessageSentStatus:ke,MessageDeliveredStatus:ke,MessageReadStatus:ke,MessageSendingStatus:Xe(a)?ke:gn});return c?s.jsxs("span",{className:"sent-message-status-row",children:[u,u&&l&&s.jsx("span",{className:"sent-message-outbound-separator","aria-hidden":"true",children:"β’"}),c]}):u},jn=["linktr.ee"],Lt="messaging-attachment-v1_0";function wn(e){try{return new URL(e).hostname.toLowerCase()}catch{return null}}function _n(e){return jn.some(t=>e===t||e.endsWith(`.${t}`))}function le(e){const t=e==null?void 0:e.trim();if(!t)return;const n=wn(t);if(!n||!_n(n))return t;const a=new URL(t);return a.searchParams.get("io")==="true"&&a.searchParams.get("size")===Lt?t:(a.searchParams.set("io","true"),a.searchParams.set("size",Lt),a.toString())}const Nn=/^([a-z][a-z0-9+.-]*):/i,yn=new Set(["http","https","mailto","tel","sms"]);function Ze(e){if(typeof e!="string")return;const t=e.trim();if(t==="")return;const n=Nn.exec(t);if(n){const a=n[1].toLowerCase();return yn.has(a)?t:void 0}return t.startsWith("//")||t.startsWith("/")?t:`https://${t}`}const Cn={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"}},os=({variant:e,cta:t,fullWidth:n=!0,standalone:a=!1})=>{const r=t.variant??"primary",i=y("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",Cn[e][r]),l=n?t.label:s.jsx("span",{className:"min-w-0 truncate",children:t.label}),d=Ze(t.href);return d?s.jsx("a",{href:d,target:"_blank",rel:"noopener noreferrer",onClick:c=>{var u;c.stopPropagation(),(u=t.onClick)==null||u.call(t)},className:`${i} no-underline`,children:l}):s.jsx("button",{type:"button",onClick:c=>{var u;c.stopPropagation(),(u=t.onClick)==null||u.call(t)},className:i,children:l})},Sn={dark:"text-white",light:"text-black/90"},kn="text-white/30",Ot={dark:"text-white/55",light:"text-black/55"},En={dark:"bg-white/25",light:"bg-black/15"},Je=({variant:e,ctaSurface:t,chinTextColor:n,title:a,placeholderTitle:r,description:i,descriptionLines:l=1,url:d,appIcon:c,cta:u,trailingAction:h,isLoading:m=!1})=>{const f=e==="dark",o=a??(f?r:void 0)??"",v=o.trim()!=="",_=i!=null&&i.trim()!=="",p=typeof d=="string"?d.trim():"",b=p!=="",g=u!=null;if(!m&&!v&&!_&&!b&&!g)return null;const N=f&&!a,j=y("line-clamp-2 text-[14px] font-medium leading-5 tracking-[0.28px]",n==null&&(N?kn:Sn[e])),E=y("truncate text-[12px] leading-4 tracking-[0.24px]",n==null&&Ot[e]),T=y("text-[12px] leading-4 tracking-[0.24px]",l<=1&&"truncate",n==null&&Ot[e]);if(m){const F=y("animate-pulse rounded",En[e]);return s.jsx("div",{className:"shrink-0 px-4 py-3",children:s.jsxs("div",{className:"flex min-w-0 flex-col gap-[2px]",children:[s.jsx("div",{className:y("h-5 w-3/4",F),"aria-hidden":!0}),s.jsx("div",{className:y("h-4 w-1/2",F),"aria-hidden":!0})]})})}const A=n?{color:n}:void 0,R=l>1?{...A,display:"-webkit-box",WebkitBoxOrient:"vertical",WebkitLineClamp:l,overflow:"hidden"}:A;return s.jsxs("div",{className:"shrink-0 px-4 py-3",children:[s.jsxs("div",{className:"flex items-end gap-3",children:[s.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-[2px]",children:[v&&s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[c?s.jsx("span",{className:"shrink-0",children:c}):null,s.jsx("p",{className:y("min-w-0",j),style:A,children:o})]}),_&&s.jsx("p",{className:T,style:R,children:i}),!g&&b&&s.jsx("p",{className:E,style:A,"data-testid":"link-attachment-url",children:p})]}),h&&s.jsx("div",{className:"shrink-0",children:h})]}),u&&s.jsx(os,{variant:t??e,cta:u})]})},In="Loading link preview",Tn=y("relative w-[var(--lt-msg-card-width,290px)] max-w-full select-none overflow-hidden","rounded-[20px]"),An="flex h-[250px] flex-col",ve=({variant:e,children:t,href:n,onClick:a,ariaLabel:r,rootRef:i,topRight:l,bgClassName:d,accentHex:c,fixedHeight:u=!1,busy:h=!1,"data-testid":m})=>{const f=n!=null||a!=null,o=y("messaging-link-card",Tn,u?An:"block",d??(e==="dark"?"bg-[#1e2330]":"bg-[#f1f0ee]"),f?"cursor-pointer no-underline focus-ring":null),v=h?{role:"status","aria-busy":!0,"aria-label":In}:void 0,_=c?{"--accent":c}:void 0,p=l?s.jsx("div",{className:"pointer-events-auto absolute right-3 top-3 z-10",children:l}):null;return n?s.jsxs("a",{ref:i,href:n,target:"_blank",rel:"noopener noreferrer",onClick:a,"data-testid":m,"data-variant":e,className:o,style:_,...v,children:[t,p]}):a?s.jsxs("button",{ref:i,type:"button",onClick:a,"aria-label":r,"data-testid":m,"data-variant":e,className:y(o,"text-left"),style:_,...v,children:[t,p]}):s.jsxs("div",{ref:i,"data-testid":m,"data-variant":e,className:o,style:_,...v,children:[t,p]})},ls="data-mes-native-player",Qe={[ls]:""},Mn=e=>{typeof document>"u"||document.querySelectorAll(`[${ls}]`).forEach(t=>{t!==e&&t.pause()})},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 xe(e){return e.startsWith("video/")?"video":e.startsWith("audio/")?"audio":e.startsWith("image/")?"image":"document"}function cs(e){const t=Rn.find(([n])=>n.test(e));return t?t[1]:"generic"}const Ln={video:C.VideoCameraIcon,audio:C.SpeakerHighIcon,image:C.ImageIcon,document:C.FileIcon},On={pdf:C.FilePdfIcon,doc:C.FileDocIcon,xls:C.FileXlsIcon,csv:C.FileCsvIcon,ppt:C.FilePptIcon,zip:C.FileZipIcon,text:C.FileTextIcon,markdown:C.FileMdIcon,generic:C.FileIcon};function Dn(e){const t=xe(e);return t!=="document"?Ln[t]:On[cs(e)]}function et(e,t){return x.createElement(Dn(e),t)}const Dt={dark:"bg-white/10",light:"bg-black/5"},Pn={dark:"size-16 text-white/25",light:"size-16 text-black/25"},we=(e,t)=>!!t&&!!e&&xe(e)==="audio",tt=(e,t)=>{if(!t||!e)return!1;const n=xe(e);return n==="video"||n==="audio"},st="bg-[#F2F3F4]",je=({variant:e,thumbnailUrl:t,sourceUrl:n,title:a,mimeType:r="image/*",topLeft:i,topRight:l,isLoading:d=!1,onImageError:c})=>{const u=xe(r),h=!!n&&u==="video",m=le(t);return!d&&we(r,n)?s.jsx("div",{className:"p-3",children:s.jsx("audio",{...Qe,src:n,controls:!0,preload:"metadata",className:"block w-full",children:s.jsx("track",{kind:"captions"})})}):s.jsxs("div",{className:y("relative min-h-0 w-full flex-1 overflow-hidden",h&&"bg-black"),children:[d?s.jsx("div",{className:y("h-full w-full animate-pulse",Dt[e]),"aria-hidden":!0}):h?s.jsxs(s.Fragment,{children:[s.jsx("video",{src:n,poster:m,controls:!0,playsInline:!0,preload:"metadata",className:"absolute inset-0 h-full w-full object-contain",children:s.jsx("track",{kind:"captions"})}),m&&c?s.jsx("img",{src:m,alt:"","aria-hidden":!0,onError:c,className:"hidden"}):null]}):t?s.jsx("img",{src:m??t,alt:a??"",draggable:!1,loading:"lazy",decoding:"async",onError:c,className:"absolute inset-0 h-full w-full object-cover"}):s.jsx("div",{className:y("flex h-full w-full items-center justify-center",Dt[e]),children:et(r,{className:Pn[e],weight:"regular"})}),i?s.jsx("div",{className:"pointer-events-auto absolute left-3 top-3 z-10",children:i}):null,l?s.jsx("div",{className:"pointer-events-auto absolute right-3 top-3 z-10",children:l}):null]})},Fn=/^#?(?:[0-9a-f]{3}|[0-9a-f]{6})$/i;function Bn(e){const t=e.trim();return t.startsWith("#")?t:`#${t}`}const zn="#FFFFFF",ds="#040403",$n={dark:zn,light:ds};function Oe({variant:e,accentColor:t,status:n="ready",layout:a="featured",thumbnailUrl:r,mimeType:i,sourceUrl:l}){const[d,c]=x.useState(!1);x.useEffect(()=>{c(!1)},[r]);const u=x.useCallback(()=>{c(!0)},[]),h=we(i,l),o=a==="featured"&&!!r&&!h&&!d&&n==="ready"&&t!=null&&Fn.test(t.trim())?Bn(t):void 0,v=h?ds:$n[e];return{thumbnailUrl:d?void 0:r,accentHex:o,chinTextColor:v,surface:h?"light":e,isLoading:n==="loading",onImageError:u}}const Un="flex size-6 items-center justify-center rounded-full bg-[#121110] text-white focus-ring",Vn="relative before:absolute before:-inset-[10px] before:content-['']",Hn=({title:e,placeholderTitle:t,description:n,descriptionLines:a,url:r,mimeType:i,thumbnailUrl:l,sourceUrl:d,layout:c="featured",appIcon:u,cta:h,accentColor:m,status:f="ready",onDismiss:o,onEditClick:v,dismissLabel:_="Dismiss attachment"})=>{const p=c==="classic",b=we(i,d),g=Oe({variant:"dark",accentColor:m,status:f,layout:c,thumbnailUrl:l,mimeType:i,sourceUrl:d}),N=o?s.jsx("button",{type:"button",onClick:o,"aria-label":_,className:y(Un,!b&&Vn),children:s.jsx(C.XIcon,{className:"size-3",weight:"bold"})}):void 0,j=v?s.jsx("button",{type:"button",onClick:v,"aria-label":"Edit attachment",className:"flex size-10 items-center justify-center rounded-full bg-white/10 text-white hover:bg-white/15",children:s.jsx(C.PencilSimpleIcon,{className:"size-5",weight:"regular"})}):void 0;return b&&!g.isLoading?s.jsx(ve,{variant:"dark",bgClassName:st,children:s.jsxs("div",{className:"flex items-center gap-2 pr-3",children:[s.jsx("div",{className:"min-w-0 flex-1",children:s.jsx(je,{variant:"dark",sourceUrl:d,title:e,mimeType:i})}),N&&s.jsx("div",{className:"shrink-0",children:N})]})}):s.jsxs(ve,{variant:"dark",fixedHeight:!p,accentHex:g.accentHex,busy:g.isLoading,topRight:p?N:void 0,children:[!p&&s.jsx(je,{variant:"dark",thumbnailUrl:g.thumbnailUrl,sourceUrl:d,title:e,mimeType:i,topRight:N,isLoading:g.isLoading,onImageError:g.onImageError}),s.jsx(Je,{chinTextColor:g.chinTextColor,variant:"dark",ctaSurface:g.surface,title:e,placeholderTitle:t,description:n,descriptionLines:a,url:r,appIcon:u,cta:h,trailingAction:j,isLoading:g.isLoading})]})},nt=({accentHex:e,side:t,visible:n,children:a})=>{if(!n)return s.jsx(s.Fragment,{children:a});const r=t==="sender"?"dark":"light",i=e?{"--accent":e}:void 0;return s.jsxs("div",{className:"relative isolate w-fit",children:[a,s.jsx("span",{"aria-hidden":!0,"data-testid":"link-card-tail","data-variant":r,style:i,className:y("messaging-link-card-tail",t==="receiver"&&"messaging-link-card-tail--received")})]})},Gn=({title:e,description:t,descriptionLines:n,url:a,mimeType:r,thumbnailUrl:i,sourceUrl:l,layout:d="featured",appIcon:c,cta:u,accentColor:h,status:m="ready",onClick:f,groupPosition:o="single"})=>{const v=tt(r,l),_=Ze(a),p=u==null&&_!=null&&!v?_:void 0,b=u==null&&!v?f:void 0,g=m!=="loading"&&we(r,l)?st:void 0,N=u&&f?{...u,onClick:()=>{var E;f(),(E=u.onClick)==null||E.call(u)}}:u,j=Oe({variant:"light",accentColor:h,status:m,layout:d,thumbnailUrl:i,mimeType:r,sourceUrl:l});return s.jsx(nt,{accentHex:j.accentHex,side:"receiver",visible:g==null&&(o==="single"||o==="end"),children:s.jsxs(ve,{variant:"light",href:p,onClick:b,ariaLabel:e??"Open attachment preview",fixedHeight:d==="featured"&&g==null,accentHex:j.accentHex,busy:j.isLoading,bgClassName:g,"data-testid":"link-attachment",children:[d==="featured"&&s.jsx(je,{variant:"light",thumbnailUrl:j.thumbnailUrl,sourceUrl:l,title:e,mimeType:r,isLoading:j.isLoading,onImageError:j.onImageError}),s.jsx(Je,{chinTextColor:j.chinTextColor,variant:"light",ctaSurface:j.surface,title:e,description:t,descriptionLines:n,url:a,appIcon:c,cta:N,isLoading:j.isLoading})]})})},Yn=({title:e,placeholderTitle:t,description:n,descriptionLines:a,url:r,mimeType:i,thumbnailUrl:l,sourceUrl:d,layout:c="featured",appIcon:u,cta:h,accentColor:m,status:f="ready",onClick:o,groupPosition:v="single"})=>{const _=tt(i,d),p=Ze(r),b=h==null&&p!=null&&!_?p:void 0,g=h==null&&!_&&b!=null?o:void 0,N=f!=="loading"&&we(i,d),j=Oe({variant:"dark",accentColor:m,status:f,layout:c,thumbnailUrl:l,mimeType:i,sourceUrl:d});return s.jsx(nt,{accentHex:j.accentHex,side:"sender",visible:!N&&(v==="single"||v==="end"),children:s.jsxs(ve,{variant:"dark",href:b,onClick:g,fixedHeight:c==="featured"&&!N,accentHex:j.accentHex,busy:j.isLoading,bgClassName:N?st:void 0,children:[c==="featured"&&s.jsx(je,{variant:"dark",thumbnailUrl:j.thumbnailUrl,sourceUrl:d,title:e,mimeType:i,isLoading:j.isLoading,onImageError:j.onImageError}),s.jsx(Je,{chinTextColor:j.chinTextColor,variant:"dark",ctaSurface:j.surface,title:e,placeholderTitle:t,description:n,descriptionLines:a,url:r,appIcon:u,cta:h,isLoading:j.isLoading})]})})},Ae={Composer:Hn,Sent:Yn,Received:Gn},Wn={dark:"bg-[#1e2330]",light:"bg-[#f2f1ef]"},qn={dark:"text-white",light:"text-[#000000]"},Xn={dark:"border-white/[0.08]",light:"border-black/[0.08]"},Kn=e=>e==="dark"?"sender":"receiver",Zn={sender:{single:"rounded-tl-[18px] rounded-tr-[18px] rounded-bl-[18px] rounded-br-[18px]",first:"rounded-tl-[18px] rounded-tr-[18px] rounded-bl-[18px] rounded-br-[4px]",middle:"rounded-tl-[18px] rounded-tr-[4px] rounded-bl-[18px] rounded-br-[4px]",end:"rounded-tl-[18px] rounded-tr-[4px] rounded-bl-[18px] rounded-br-[18px]"},receiver:{single:"rounded-tl-[18px] rounded-tr-[18px] rounded-bl-[18px] rounded-br-[18px]",first:"rounded-tl-[18px] rounded-tr-[18px] rounded-bl-[4px] rounded-br-[18px]",middle:"rounded-tl-[4px] rounded-tr-[18px] rounded-bl-[4px] rounded-br-[18px]",end:"rounded-tl-[4px] rounded-tr-[18px] rounded-bl-[18px] rounded-br-[18px]"}},_e=({variant:e,text:t,bordered:n=!0,groupPosition:a="single",widthClassName:r="w-[280px]",paddingClassName:i="px-2 py-2",radiusClassName:l,className:d,children:c,"data-testid":u})=>{const h=t!=null&&t!=="",m=l??Zn[Kn(e)][a];return s.jsxs("div",{"data-testid":u,"data-group-position":a,className:y("relative",r,"overflow-hidden",i,h&&"pb-0",m,Wn[e],qn[e],n&&"border",n&&Xn[e],d),children:[c,h?s.jsx("p",{className:y("whitespace-pre-wrap break-words leading-snug hyphens-manual","pb-2 pt-2","px-2"),children:t}):null]})},Ne=({onClick:e,variant:t="overlay",ariaLabel:n="Dismiss attachment"})=>s.jsx("button",{type:"button",onClick:a=>{a.stopPropagation(),e()},"aria-label":n,className:y("flex size-6 items-center justify-center rounded-full text-white",t==="overlay"?"bg-[#121110]/85 backdrop-blur":"bg-white/15 hover:bg-white/25"),children:s.jsx(C.XIcon,{className:"size-3",weight:"bold"})}),ye=e=>e==="received"?"light":"dark",Jn=({firstOfGroup:e,endOfGroup:t,groupedByUser:n})=>!n||e&&t?"single":e?"first":t?"end":"middle",Qn=({src:e,mimeType:t,filename:n,items:a})=>a&&a.length>0?a:e?[{src:e,mimeType:t,filename:n}]:[],ea=({item:e,preload:t,trailingAction:n})=>s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("audio",{...Qe,src:e.src,controls:!0,preload:e.preload??t,className:"block min-w-0 flex-1",children:e.mimeType?s.jsx("source",{src:e.src,type:e.mimeType}):null}),n??null]}),at=({state:e,src:t,mimeType:n,filename:a,items:r,text:i,groupPosition:l,preload:d,onDismiss:c})=>{const u=ye(e),h=e==="composer"&&!!c,m=Qn({src:t,mimeType:n,filename:a,items:r});if(m.length===0)return null;const f=d??(m.length>1?"none":"metadata");return s.jsx(_e,{variant:u,text:i,groupPosition:l,"data-testid":"audio-attachment",children:s.jsx("div",{className:"flex flex-col gap-2",children:m.map((o,v)=>s.jsx(ea,{item:o,preload:f,trailingAction:h&&v===0?s.jsx(Ne,{onClick:c,variant:"inline"}):void 0},`${o.src}-${v}`))})})},ta=e=>s.jsx(at,{...e,state:"composer"}),sa=e=>s.jsx(at,{...e,state:"sent"}),na=e=>s.jsx(at,{...e,state:"received"}),aa={Composer:ta,Sent:sa,Received:na};function us(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 ra={pdf:"PDF",doc:"DOC",xls:"XLS",csv:"CSV",ppt:"PPT",zip:"ZIP",text:"TXT",markdown:"MD"};function ms(e,t){if(t){const r=t.lastIndexOf(".");if(r>0&&r<t.length-1){const i=t.slice(r+1);if(i&&i.length<=5)return i.toUpperCase()}}if(!e)return;if(xe(e)==="document"){const r=cs(e),i=ra[r];if(i)return i;if(e==="application/octet-stream")return}const a=e.split("/")[1];if(!(!a||a==="*"))return a.toUpperCase()}function hs(e,t,n){const a=ms(e,t),r=typeof n=="number"&&n>0?us(n):void 0;return[a,r].filter(Boolean).join(" Β· ")||void 0}function se(e){try{const n=new URL(e).pathname.split("/").pop();return n&&n.length>0?decodeURIComponent(n):"download"}catch{return"download"}}const ia={dark:"text-white/55",light:"text-black/65"},oa={dark:"bg-white/10",light:"bg-black/5"},la={dark:"text-white/85",light:"text-black/85"},xs=({variant:e,filename:t,title:n,mimeType:a="application/octet-stream",fileSize:r,onActivate:i,activateLabel:l,trailingAction:d})=>{const c=n??t??"File",u=hs(a,t,r),h=s.jsx("div",{className:y("flex size-10 shrink-0 items-center justify-center rounded-sm",oa[e]),"aria-hidden":!0,children:et(a,{className:y("size-6",la[e]),weight:"regular"})}),m=s.jsxs("div",{className:"flex min-w-0 flex-1 flex-col text-left",children:[s.jsx("p",{className:"truncate font-medium leading-snug",children:c}),u?s.jsx("p",{className:y("truncate text-xs leading-4",ia[e]),children:u}):null]}),f=i?s.jsxs("button",{type:"button",onClick:i,"aria-label":l,className:y("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:[h,m]}):s.jsxs(s.Fragment,{children:[h,m]});return s.jsxs("div",{className:"flex items-center gap-3 px-3 py-2",children:[f,d?s.jsx("div",{className:"shrink-0",children:d}):null]})};async function fs(e,t){const n=t??se(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 ca=({src:e,filename:t,fileSize:n,mimeType:a,title:r,items:i})=>i&&i.length>0?i:e?[{src:e,filename:t,fileSize:n,mimeType:a,title:r}]:[],da=({variant:e,item:t,index:n,onActivate:a,trailingAction:r})=>{const i=t.filename??se(t.src);return s.jsx(xs,{variant:e,filename:i,title:t.title,mimeType:t.mimeType??"application/octet-stream",fileSize:t.fileSize,onActivate:()=>a(n),activateLabel:`Download ${i}`,trailingAction:r})},rt=({state:e,src:t,filename:n,fileSize:a,mimeType:r,title:i,items:l,text:d,groupPosition:c,onClick:u,onDismiss:h})=>{const m=ye(e),f=e==="composer"&&!!h,o=ca({src:t,filename:n,fileSize:a,mimeType:r,title:i,items:l}),v=p=>{if((u==null?void 0:u(p))===!1)return;const b=o[p];if(!b)return;const g=b.filename??se(b.src);fs(b.src,g)};if(o.length===0)return null;const _=s.jsx("span",{className:y("flex size-8 items-center justify-center rounded-full",m==="dark"?"text-white/70":"text-black/70"),"aria-hidden":!0,children:s.jsx(C.DownloadSimpleIcon,{className:"size-5",weight:"bold"})});return s.jsx(_e,{variant:m,text:d,groupPosition:c,"data-testid":"file-attachment",children:s.jsx("div",{className:"flex flex-col gap-2",children:o.map((p,b)=>{const g=f&&b===0?s.jsx(Ne,{onClick:h,variant:"inline"}):_;return s.jsx(da,{variant:m,item:p,index:b,onActivate:v,trailingAction:g},`${p.src}-${b}`)})})})},ua=e=>s.jsx(rt,{...e,state:"composer"}),ma=e=>s.jsx(rt,{...e,state:"sent"}),ha=e=>s.jsx(rt,{...e,state:"received"}),xa={Composer:ua,Sent:ma,Received:ha},gs="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",Pt="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",it=({onPrev:e,onNext:t,prevLabel:n="Previous",nextLabel:a="Next"})=>s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",onClick:e,"aria-label":n,className:`${Pt} left-4`,children:s.jsx(C.CaretLeftIcon,{size:20,weight:"bold","aria-hidden":!0})}),s.jsx("button",{type:"button",onClick:t,"aria-label":a,className:`${Pt} right-4`,children:s.jsx(C.CaretRightIcon,{size:20,weight:"bold","aria-hidden":!0})})]}),ps=({url:e,filename:t,variant:n="pill",label:a="Download",iconOnly:r,tone:i="dark",onTriggered:l})=>{const[d,c]=x.useState(!1),u=x.useCallback(o=>{o.stopPropagation(),!d&&(c(!0),fs(e,t).catch(()=>{}).finally(()=>{c(!1),l==null||l()}))},[d,e,t,l]),h=r??n!=="pill",f={className:y(n==="pill"?"size-4":"size-5","shrink-0"),weight:"bold"};if(n==="inline"){const o={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 s.jsx("button",{type:"button",onClick:u,disabled:d,"aria-label":a,className:y("flex size-8 shrink-0 items-center justify-center rounded-full transition-colors disabled:opacity-70",o[i]),children:d?s.jsx(C.CircleNotchIcon,{className:"size-4 animate-spin",weight:"bold","aria-hidden":!0}):s.jsx(C.DownloadSimpleIcon,{className:"size-5 shrink-0",weight:"bold","aria-hidden":!0})})}return n==="viewer"?s.jsx("button",{type:"button",onClick:u,disabled:d,"aria-label":a,className:gs,children:d?s.jsx(C.CircleNotchIcon,{size:20,weight:"bold","aria-hidden":!0}):s.jsx(C.DownloadSimpleIcon,{size:20,weight:"bold","aria-hidden":!0})}):s.jsxs("button",{type:"button",onClick:u,disabled:d,"aria-label":h?a:void 0,className:y("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:[d?s.jsx(C.CircleNotchIcon,{className:"size-4 animate-spin",weight:"bold","aria-hidden":!0}):s.jsx(C.DownloadSimpleIcon,{...f,"aria-hidden":!0}),h?null:a]})},Be=(e,t,n)=>Math.min(Math.max(e,t),n),ot=({length:e,initialIndex:t,open:n})=>{const a=Be(t,0,Math.max(e-1,0)),[r,i]=x.useState(a);x.useEffect(()=>{n&&i(Be(t,0,Math.max(e-1,0)))},[n,t,e]),x.useEffect(()=>{i(c=>Be(c,0,Math.max(e-1,0)))},[e]);const l=x.useCallback(()=>{e<=1||i(c=>c<=0?e-1:c-1)},[e]),d=x.useCallback(()=>{e<=1||i(c=>c>=e-1?0:c+1)},[e]);return x.useEffect(()=>{if(!n||e<=1)return;const c=u=>{if(u.key!=="ArrowLeft"&&u.key!=="ArrowRight")return;const h=document.activeElement;h&&(h.tagName==="VIDEO"||h.tagName==="AUDIO")||(u.preventDefault(),u.key==="ArrowLeft"?l():d())};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[n,e,l,d]),{index:r,prev:l,next:d}},lt=({open:e,onClose:t,ariaLabel:n,counter:a,actions:r,children:i,"data-testid":l})=>{const d=x.useRef(null),c=x.useRef(null);x.useEffect(()=>{var f;const m=d.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 o=typeof document<"u"?document.activeElement:null;return(f=c.current)==null||f.focus(),()=>{if(m.open)if(typeof m.close=="function")try{m.close()}catch{m.removeAttribute("open")}else m.removeAttribute("open");o&&document.body.contains(o)&&o.focus()}}if(m.open)if(typeof m.close=="function")try{m.close()}catch{m.removeAttribute("open")}else m.removeAttribute("open")}},[e]);const u=()=>{t()},h=m=>{m.target===d.current&&t()};return s.jsxs("dialog",{ref:d,className:"mes-media-viewer","aria-label":n??"Attachment viewer","data-testid":l,onClose:u,onClick:h,children:[s.jsxs("div",{className:"pointer-events-none absolute inset-x-3 top-3 z-[1] flex items-center justify-between gap-3",children:[a?s.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,s.jsxs("div",{className:"pointer-events-auto ml-auto inline-flex items-center gap-2",children:[r,s.jsx("button",{ref:c,type:"button",onClick:t,"aria-label":"Close viewer",className:gs,children:s.jsx(C.XIcon,{size:20,weight:"bold","aria-hidden":!0})})]})]}),s.jsx("div",{className:"box-border flex h-full w-full items-center justify-center px-6 py-16",children:i})]})},bs=({open:e,items:t,initialIndex:n=0,onClose:a})=>{const{index:r,prev:i,next:l}=ot({length:t.length,initialIndex:n,open:e}),d=t[r],c=x.useMemo(()=>(d==null?void 0:d.filename)??(d?se(d.src):"image"),[d]);return d?s.jsxs(lt,{open:e,onClose:a,ariaLabel:c,counter:t.length>1?`${r+1} / ${t.length}`:void 0,actions:s.jsx(ps,{url:d.src,filename:c,variant:"viewer",label:`Download ${c}`}),"data-testid":"image-viewer",children:[e?s.jsx("img",{src:d.src,alt:d.alt??c,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}:${d.src}`):null,t.length>1?s.jsx(it,{onPrev:i,onNext:l,prevLabel:"Previous image",nextLabel:"Next image"}):null]}):null},Ue=4,fa="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",ga={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]"]},pa="--mes-single-width-cap",ba="[--mes-single-width-cap:309px] sm:[--mes-single-width-cap:326px]",va=436,vs=({tiles:e,onTileActivate:t,maxVisible:n=Ue,singleAspectRatio:a,className:r})=>{const i=e.length;if(i===0)return null;const l=e.slice(0,Math.min(i,n)),d=i-l.length,c=(h,m,f)=>{var v;const o=y(fa,"h-full w-full",(v=ga[l.length])==null?void 0:v[m]);return t?s.jsxs("button",{type:"button",onClick:()=>t(m),"aria-label":h.ariaLabel??`Open media ${m+1}`,className:y(o,h.cursorClassName??"cursor-zoom-in"),children:[h.content,f]},m):s.jsxs("div",{className:o,children:[h.content,f]},m)};let u;return a&&(u={aspectRatio:a,width:`min(var(${pa}), ${Math.round(va*a*100)/100}px)`,maxWidth:"100%"}),l.length===1?s.jsx("div",{className:y(a?ba:"aspect-square w-full",r),style:u,children:c(l[0],0)}):l.length===2?s.jsx("div",{className:y("grid aspect-[16/9] w-full grid-cols-2 gap-0.5",r),children:l.map((h,m)=>c(h,m))}):l.length===3?s.jsxs("div",{className:y("grid aspect-[4/3] w-full grid-cols-2 grid-rows-2 gap-0.5",r),children:[s.jsx("div",{className:"row-span-2",children:c(l[0],0)}),c(l[1],1),c(l[2],2)]}):s.jsx("div",{className:y("grid aspect-[379/286] w-full grid-cols-2 grid-rows-2 gap-0.5",r),children:l.map((h,m)=>{const f=d>0&&m===l.length-1;return c(h,m,f?s.jsxs("div",{"aria-hidden":!0,className:"absolute inset-0 flex items-center justify-center bg-[#040403]/50 text-2xl font-bold leading-[28px] tracking-[-0.24px] text-white",children:["+",d]}):null)})})},js=({src:e,suppliedRatio:t,fallbackRatio:n})=>{const[a,r]=x.useState(),i=x.useCallback(c=>{if(!c||c.naturalWidth<=0||c.naturalHeight<=0||e===void 0)return;const u=c.naturalWidth/c.naturalHeight;r(h=>h&&h.src===e&&h.ratio===u?h:{src:e,ratio:u})},[e]),l=x.useCallback(c=>i(c.currentTarget),[i]),d=a&&a.src===e?a.ratio:void 0;return{ratio:t??d??n,imgRef:i,onLoad:l}},Ce=e=>{const[t,n]=x.useState(!1),[a,r]=x.useState(0),i=x.useCallback(d=>{(e==null?void 0:e(d))!==!1&&(r(d),n(!0))},[e]),l=x.useCallback(()=>n(!1),[]);return{viewerOpen:t,viewerIndex:a,handleActivate:i,closeViewer:l}},ja=({item:e,index:t,totalCount:n,fallbackLoading:a,imgRef:r,onLoad:i})=>({ariaLabel:`Open image ${t+1} of ${n}`,content:s.jsx("img",{ref:r,src:le(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"})}),wa=({src:e,alt:t,items:n})=>n&&n.length>0?n:e?[{src:e,alt:t}]:[],ws=(e,t)=>e.map((n,a)=>({src:n.src,alt:n.alt,filename:t&&e.length===1?t:t?`${t} (${a+1})`:void 0})),_a=({src:e,alt:t,filename:n,loading:a="lazy",onClick:r,onDismiss:i})=>{const{viewerOpen:l,viewerIndex:d,handleActivate:c,closeViewer:u}=Ce(r);return s.jsxs("div",{className:"relative w-fit",children:[s.jsx("button",{type:"button",onClick:()=>c(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:s.jsx("img",{src:le(e)??e,alt:t??"",draggable:!1,loading:a,decoding:"async",className:"size-full object-cover"})}),i?s.jsx("div",{className:"absolute right-2 top-2 z-10",children:s.jsx(Ne,{onClick:i})}):null,s.jsx(bs,{open:l,items:ws([{src:e,alt:t}],n),initialIndex:d,onClose:u})]})},Na=326/246,_s=({state:e,src:t,alt:n,filename:a,items:r,text:i,groupPosition:l,loading:d="lazy",onClick:c})=>{const u=wa({src:t,alt:n,items:r}),h=ye(e),{viewerOpen:m,viewerIndex:f,handleActivate:o,closeViewer:v}=Ce(c),_=u.length===1,p=_?u[0]:void 0,b=js({src:p==null?void 0:p.src,suppliedRatio:p!=null&&p.width&&(p!=null&&p.height)?p.width/p.height:void 0,fallbackRatio:Na});if(u.length===0)return null;const g=u.map((N,j)=>ja({item:N,index:j,totalCount:u.length,fallbackLoading:d,imgRef:_?b.imgRef:void 0,onLoad:_?b.onLoad:void 0}));return s.jsxs(_e,{variant:h,text:i,groupPosition:l,bordered:!1,widthClassName:_?"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:[s.jsx("div",{className:"relative",children:s.jsx(vs,{tiles:g,onTileActivate:o,singleAspectRatio:_?b.ratio:void 0})}),s.jsx(bs,{open:m,items:ws(u,a),initialIndex:f,onClose:v})]})},ya=e=>s.jsx(_a,{...e}),Ca=e=>s.jsx(_s,{...e,state:"sent"}),Sa=e=>s.jsx(_s,{...e,state:"received"}),ka={Composer:ya,Sent:Ca,Received:Sa},Ea=({open:e,items:t,initialIndex:n=0,onClose:a})=>{const{index:r,prev:i,next:l}=ot({length:t.length,initialIndex:n,open:e}),d=t[r],c=x.useMemo(()=>(d==null?void 0:d.filename)??(d?se(d.src):"document"),[d]),u=x.useMemo(()=>d?Ia(d.src):void 0,[d]);return!d||!u?null:s.jsxs(lt,{open:e,onClose:a,ariaLabel:c,counter:t.length>1?`${r+1} / ${t.length}`:void 0,"data-testid":"pdf-viewer",children:[s.jsx("iframe",{src:u,title:c,className:"block h-[calc(100dvh-128px)] w-[min(96vw,1400px)] border-0 bg-white",sandbox:"allow-scripts allow-forms allow-popups allow-downloads"},`${r}:${d.src}`),t.length>1?s.jsx(it,{onPrev:i,onNext:l,prevLabel:"Previous document",nextLabel:"Next document"}):null]})},Ia=e=>{const t=e.indexOf("#"),n=t===-1?e:e.slice(0,t),a=t===-1?"":e.slice(t+1),r=new URLSearchParams(a);return r.has("toolbar")||r.set("toolbar","0"),r.has("navpanes")||r.set("navpanes","0"),`${n}#${r.toString()}`},Ta=({src:e,filename:t,fileSize:n,title:a,items:r})=>r&&r.length>0?r:e?[{src:e,filename:t,fileSize:n,title:a}]:[],Aa=({variant:e,item:t,index:n,onActivate:a,trailingAction:r})=>{const i=t.filename??se(t.src);return s.jsx(xs,{variant:e,filename:i,title:t.title,mimeType:"application/pdf",fileSize:t.fileSize,onActivate:()=>a(n),activateLabel:`Open ${i}`,trailingAction:r})},ct=({state:e,src:t,filename:n,fileSize:a,title:r,items:i,text:l,groupPosition:d,onClick:c,onDismiss:u})=>{const h=ye(e),m=Ta({src:t,filename:n,fileSize:a,title:r,items:i}),{viewerOpen:f,viewerIndex:o,handleActivate:v,closeViewer:_}=Ce(c),p=e==="composer"&&!!u;if(m.length===0)return null;const b=m.map(g=>({src:g.src,filename:g.filename??se(g.src)}));return s.jsxs(_e,{variant:h,text:l,groupPosition:d,"data-testid":"pdf-attachment",children:[s.jsx("div",{className:"flex flex-col gap-2",children:m.map((g,N)=>{const j=g.filename??se(g.src),E=p&&N===0?s.jsx(Ne,{onClick:u,variant:"inline"}):e==="composer"?void 0:s.jsx(ps,{url:g.src,filename:j,variant:"inline",label:`Download ${j}`,tone:h});return s.jsx(Aa,{variant:h,item:g,index:N,onActivate:v,trailingAction:E},`${g.src}-${N}`)})}),s.jsx(Ea,{open:f,items:b,initialIndex:o,onClose:_})]})},Ma=e=>s.jsx(ct,{...e,state:"composer"}),Ra=e=>s.jsx(ct,{...e,state:"sent"}),La=e=>s.jsx(ct,{...e,state:"received"}),Oa={Composer:Ma,Sent:Ra,Received:La},Da=150,Ns=({open:e,items:t,initialIndex:n=0,onClose:a})=>{const{index:r,prev:i,next:l}=ot({length:t.length,initialIndex:n,open:e}),d=x.useRef(null),c=w.useActiveAudioPlayer();x.useEffect(()=>{e&&(c==null||c.pause(),Mn(d.current))},[e,c]);const[u,h]=x.useState(e);e&&!u&&h(!0),x.useEffect(()=>{var v;if(e||!u)return;(v=d.current)==null||v.pause();const o=window.setTimeout(()=>h(!1),Da);return()=>window.clearTimeout(o)},[e,u]);const m=t[r],f=x.useMemo(()=>(m==null?void 0:m.filename)??(m?se(m.src):"video"),[m]);return m?s.jsxs(lt,{open:e,onClose:a,ariaLabel:f,counter:t.length>1?`${r+1} / ${t.length}`:void 0,"data-testid":"video-viewer",children:[u?s.jsx("video",{ref:d,src:m.src,poster:m.poster,controls:!0,autoPlay:!0,muted:!0,playsInline:!0,preload:m.preload??"metadata",className:"block h-auto max-h-[calc(100dvh-128px)] w-auto max-w-[min(96vw,1400px)] bg-black",children:m.mimeType?s.jsx("source",{src:m.src,type:m.mimeType}):null},`${r}:${m.src}`):null,t.length>1?s.jsx(it,{onPrev:i,onNext:l,prevLabel:"Previous video",nextLabel:"Next video"}):null]}):null},Pa=1,Fa=4/5,Ba=16/9,za=()=>s.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center",children:s.jsx("span",{className:"flex size-12 items-center justify-center rounded-full bg-black/25 text-white backdrop-blur-[20px]",children:s.jsx(C.PlayIcon,{className:"size-6",weight:"fill","aria-hidden":!0})})}),ys=({item:e,index:t,showPlayBadge:n=!0,imgRef:a,onLoad:r})=>s.jsxs("div",{className:"absolute inset-0 size-full bg-[#0d0d0d]",children:[e.poster?s.jsx("img",{ref:a,src:e.poster,alt:`Video ${t+1} thumbnail`,draggable:!1,loading:"lazy",decoding:"async",onLoad:r,className:"absolute inset-0 size-full object-cover"}):s.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:s.jsx(C.VideoCameraIcon,{className:"size-16 text-white/30",weight:"regular","aria-hidden":!0})}),n?s.jsx(za,{}):null]}),$a=({item:e,index:t,totalCount:n,isOverflowTile:a,imgRef:r,onLoad:i})=>({ariaLabel:`Play video ${t+1} of ${n}`,cursorClassName:"cursor-pointer",content:s.jsx(ys,{item:e,index:t,showPlayBadge:!a,imgRef:r,onLoad:i})}),Ua=({src:e,poster:t,mimeType:n,preload:a,naturalAspectRatio:r,items:i})=>i&&i.length>0?a?i.map(l=>({...l,preload:l.preload??a})):i:e?[{src:e,poster:t,mimeType:n,preload:a,naturalAspectRatio:r}]:[],Cs=(e,t)=>e.map((n,a)=>({src:n.src,poster:n.poster,mimeType:n.mimeType,preload:n.preload,filename:t&&e.length===1?t:t?`${t} (${a+1})`:void 0})),Va=({src:e,poster:t,mimeType:n,filename:a,preload:r,onClick:i,onDismiss:l})=>{const{viewerOpen:d,viewerIndex:c,handleActivate:u,closeViewer:h}=Ce(i);return s.jsxs("div",{className:"relative w-fit",children:[s.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:s.jsx(ys,{item:{src:e,poster:t,mimeType:n},index:0})}),l?s.jsx("div",{className:"absolute right-2 top-2 z-10",children:s.jsx(Ne,{onClick:l})}):null,s.jsx(Ns,{open:d,items:Cs([{src:e,poster:t,mimeType:n,preload:r}],a),initialIndex:c,onClose:h})]})},Ss=({state:e,src:t,poster:n,mimeType:a,filename:r,items:i,text:l,groupPosition:d,preload:c,naturalAspectRatio:u,onClick:h})=>{const m=Ua({src:t,poster:n,mimeType:a,preload:c,naturalAspectRatio:u,items:i}),f=ye(e),{viewerOpen:o,viewerIndex:v,handleActivate:_,closeViewer:p}=Ce(h),b=m.length===1,g=b?m[0]:void 0,N=js({src:g==null?void 0:g.poster,suppliedRatio:g==null?void 0:g.naturalAspectRatio,fallbackRatio:Pa});if(m.length===0)return null;const j=m.length>Ue?Ue-1:-1,E=m.map((A,R)=>$a({item:A,index:R,totalCount:m.length,isOverflowTile:R===j,imgRef:b?N.imgRef:void 0,onLoad:b?N.onLoad:void 0})),T=Math.min(Math.max(N.ratio,Fa),Ba);return s.jsxs(_e,{variant:f,text:l,groupPosition:d,bordered:!1,widthClassName:b?"w-fit max-w-[313px] sm:max-w-[330px]":"w-[383px] max-w-full",paddingClassName:"p-0.5",radiusClassName:d&&d!=="single"?void 0:"rounded-[20px]","data-testid":"video-attachment",children:[s.jsx("div",{className:"relative",children:s.jsx(vs,{tiles:E,onTileActivate:_,singleAspectRatio:b?T:void 0})}),s.jsx(Ns,{open:o,items:Cs(m,r),initialIndex:v,onClose:p})]})},Ha=e=>s.jsx(Va,{...e}),Ga=e=>s.jsx(Ss,{...e,state:"sent"}),Ya=e=>s.jsx(Ss,{...e,state:"received"}),Wa={Composer:Ha,Sent:Ga,Received:Ya},me={Image:ka,Video:Wa,Audio:aa,Pdf:Oa,File:xa};function z(e){const t=e==null?void 0:e.trim();return t||void 0}function qa(e){const{original_width:t,original_height:n}=e;if(!(typeof t!="number"||typeof n!="number")&&!(!Number.isFinite(t)||!Number.isFinite(n))&&!(t<=0||n<=0))return t/n}function Ft(e){return e.trim().replace(/^https?:\/\//i,"").replace(/\/+$/,"").toLowerCase()}function Xa(e,t){if(!(e!=null&&e.trim())||!(t!=null&&t.trim()))return!1;const n=Ft(e),a=Ft(t);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 Bt(e){const t=z(e.og_scrape_url)??z(e.title_link),n=z(e.image_url)??z(e.thumb_url),a=z(e.asset_url),r=z(e.mime_type);return{title:z(e.title),description:z(e.text),url:t,thumbnailUrl:le(n),sourceUrl:a,layout:n||tt(r,a)?"featured":"classic",mimeType:r,accentColor:z(e.accent_color),status:"ready"}}function Ka(e){var t;return Le(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":(t=e.mime_type)!=null&&t.startsWith("audio/")?"audio":"file":null}function ks(e){if(!(e!=null&&e.length))return[];const t=[],n=(r,i)=>{const l=t[t.length-1];if((l==null?void 0:l.type)==="media"&&l.kind===r){l.attachments.push(i);return}t.push({type:"media",kind:r,attachments:[i]})},a=r=>{const i=t[t.length-1];if((i==null?void 0:i.type)==="link"){i.attachments.push(r);return}t.push({type:"link",attachments:[r]})};for(const r of e){if(Le(r)){a(r);continue}const i=Ka(r);i&&n(i,r)}return t}function Za(e){return e.filter(t=>t.type==="media").length}function Ja(e,t,n){return t<=1?n:e===0?"first":e===t-1?"end":"middle"}function Qa(e){return z(e.image_url)??z(e.asset_url)??""}function er(e){switch(e){case"image":return me.Image;case"video":return me.Video;case"audio":return me.Audio;case"pdf":return me.Pdf;default:return me.File}}function zt(e,t){switch(e){case"image":return{src:Qa(t),alt:z(t.title)};case"video":return{src:z(t.asset_url)??"",poster:le(t.thumb_url),mimeType:z(t.mime_type),naturalAspectRatio:qa(t)};case"audio":return{src:z(t.asset_url)??"",mimeType:z(t.mime_type)??"audio/mpeg",filename:z(t.title)};case"pdf":return{src:z(t.asset_url)??"",filename:z(t.title),fileSize:t.file_size};case"file":return{src:z(t.asset_url)??"",filename:z(t.title),fileSize:t.file_size,mimeType:z(t.mime_type)??"application/octet-stream"}}}function tr(e,t){if(t.length>1)return{items:t.map(a=>zt(e,a))};const n=t[0];return n?zt(e,n):{}}function sr({groupPosition:e,isMyMessage:t,segment:n}){const a=er(n.kind),r={...tr(n.kind,n.attachments),groupPosition:e};return t?s.jsx(a.Sent,{...r}):s.jsx(a.Received,{...r})}const nr=({groupPosition:e,isMyMessage:t,message:n,renderText:a})=>{var p;const r=ks(n.attachments);if(r.length===0)return null;const i=Za(r),l=(p=n.text)==null?void 0:p.trim(),d=r.find(b=>b.type==="link"),c=(d==null?void 0:d.type)==="link"?Bt(d.attachments[0]??{}).url:void 0,u=l&&Xa(l,c)?void 0:l;let h=0;const m=[],f=u?"middle":e,o=e==="single"||e==="end",v=(b,g,N)=>{const j=t?Ae.Sent:Ae.Received;m.push(s.jsx(j,{...Bt(b),groupPosition:N?f:"middle"},g))},_=(b,g)=>{const N=Ja(h,i,e);h+=1,m.push(s.jsx(sr,{groupPosition:N,isMyMessage:t,segment:b},g))};return r.forEach((b,g)=>{const N=g===r.length-1;if(b.type==="link"){b.attachments.forEach((j,E)=>{v(j,`link-${g}-${E}`,N&&E===b.attachments.length-1)});return}_(b,`media-${g}`)}),s.jsxs("div",{className:"str-chat__message-bubble-wrapper",children:[s.jsxs("div",{className:"str-chat__message-bubble","data-attachment-bubble":"true",style:{background:"transparent",borderRadius:0,overflow:"visible",padding:0},children:[m,!u&&s.jsx(w.MessageErrorIcon,{})]}),u?s.jsxs("div",{className:y("str-chat__message-bubble",{"relative isolate":o}),children:[s.jsx(w.MessageText,{message:n,renderText:a}),s.jsx(w.MessageErrorIcon,{}),o&&s.jsx(Te,{side:t?"me":"other"})]}):null]})},ar=e=>{var pt,bt,vt,jt,wt,_t,Nt,yt,Ct,St,kt;const{additionalMessageInputProps:t,editing:n,endOfGroup:a,firstOfGroup:r,groupStyles:i,groupedByUser:l,handleAction:d,handleOpenThread:c,handleRetry:u,highlighted:h,isMessageAIGenerated:m,isMyMessage:f,message:o,renderText:v,threadList:_,viewerLanguage:p,onOutboundClick:b,resolvedOutbound:g}=e,{client:N}=w.useChatContext("CustomMessage"),{channel:j}=w.useChannelStateContext("CustomMessage"),{isUnlocking:E,onUnlockClick:T,onFetchSource:A,onDownloadClick:R}=ns("LockedAttachment"),[F,L]=x.useState(!1),S=w.useMessageReminder(o.id),{Attachment:M=w.Attachment,EditMessageModal:I=w.EditMessageModal,MessageActions:k,MessageBlocked:O=w.MessageBlocked,MessageBouncePrompt:$=w.MessageBouncePrompt,MessageDeleted:B=w.MessageDeleted,MessageIsThreadReplyInChannelButtonIndicator:D=w.MessageIsThreadReplyInChannelButtonIndicator,MessageRepliesCountButton:Y=w.MessageRepliesCountButton,ReminderNotification:U=w.ReminderNotification,StreamedMessageText:W=w.StreamedMessageText,PinIndicator:q}=w.useComponentContext("CustomMessage"),G=w.messageHasAttachments(o),J=w.messageHasReactions(o),K=x.useMemo(()=>m==null?void 0:m(o),[m,o]),P=x.useMemo(()=>{const oe=o.attachments??[],de=o.shared_location?[o.shared_location,...oe]:oe;if(!Ie(o))return de;const Et=de.filter(It=>!("type"in It)||!Le(It));return Et.length===de.length?de:Et},[o]),Q=x.useMemo(()=>ks(P),[P]),V=x.useMemo(()=>{const oe=We({message:o,viewerLanguage:p});return oe===o.text?o:{...o,text:oe}},[o,p]),Z=Q.length>0,ee=Q.reduce((oe,de)=>oe+de.attachments.length,0)===((P==null?void 0:P.length)??0),ne=(i==null?void 0:i[0])??"",Se=ne==="top"?"first":ne==="middle"?"middle":ne==="bottom"?"end":"single",re=ne==="single"||ne==="bottom";if(w.isDateSeparatorMessage(o))return null;if(o.deleted_at||o.type==="deleted")return s.jsx(B,{message:o});if(w.isMessageBlocked(o))return s.jsx(O,{});const te=!_&&!!o.reply_count,ie=!_&&o.show_in_channel&&o.parent_id,ae=o.status==="failed"&&((pt=o.error)==null?void 0:pt.status)!==403,ut=w.isMessageBounced(o);let ce;ae?ce=()=>u(o):ut&&(ce=()=>L(!0));const X=f(),Ps=y("str-chat__message str-chat__message-simple",`str-chat__message--${o.type}`,`str-chat__message--${o.status}`,X?"str-chat__message--me str-chat__message-simple--me":"str-chat__message--other",o.text?"str-chat__message--has-text":"has-no-text",{"str-chat__message--has-attachment":G,"str-chat__message--highlighted":h,"str-chat__message--pinned pinned-message":o.pinned,"str-chat__message--with-reactions":J,"str-chat__message-send-can-be-retried":(o==null?void 0:o.status)==="failed"&&((bt=o==null?void 0:o.error)==null?void 0:bt.status)!==403,"str-chat__message-with-thread-link":te||ie,"str-chat__virtual-message__wrapper--end":a,"str-chat__virtual-message__wrapper--first":r,"str-chat__virtual-message__wrapper--group":l}),De=o.poll_id&&N.polls.fromState(o.poll_id),mt=Xe(o),fe=Ie(o),Fs=qe(o),Pe=!!(P!=null&&P.length&&!o.quoted_message),ht=fe&&X&&Pe,Bs=Z&&ee&&!o.quoted_message&&!De&&!K&&!fe,xt={contentType:"text",amountText:(vt=o.metadata)==null?void 0:vt.amount_text,paymentStatus:(jt=o.metadata)==null?void 0:jt.payment_status,renderedText:o.text&&s.jsx(w.MessageText,{message:V,renderText:v})},ft={contentType:"media",title:(wt=o.metadata)==null?void 0:wt.attachment_title,mimeType:(_t=o.metadata)==null?void 0:_t.attachment_mime_type,thumbnailUrl:(Nt=o.metadata)==null?void 0:Nt.attachment_thumbnail,amountText:(yt=o.metadata)==null?void 0:yt.amount_text,detail:(Ct=o.metadata)==null?void 0:Ct.attachment_detail,paymentStatus:(St=o.metadata)==null?void 0:St.payment_status,onFetchSource:A?()=>A(o,j):void 0},gt=s.jsxs("div",{className:y("str-chat__message-bubble",{"relative isolate":re}),children:[s.jsx(w.MessageText,{message:V,renderText:v}),re&&s.jsx(Te,{side:X?"me":"other"})]});return s.jsxs(s.Fragment,{children:[n&&s.jsx(I,{additionalMessageInputProps:t}),F&&s.jsx(w.MessageBounceModal,{MessageBouncePrompt:$,onClose:()=>L(!1),open:F}),s.jsxs("div",{className:Ps,"data-message-id":o.id,"data-dd-privacy":"mask",children:[q&&s.jsx(q,{}),!!S&&s.jsx(U,{reminder:S}),o.user&&s.jsx(he,{className:"str-chat__avatar str-chat__message-sender-avatar",id:o.user.id,image:o.user.image,name:o.user.name||o.user.id,size:24,shape:"circle",dmAgentEnabled:fe}),s.jsx("div",{className:y("str-chat__message-inner",{"str-chat__simple-message--error-failed":ae||ut}),"data-testid":"message-inner",onClick:ce,onKeyDown:ce,role:ce?"button":void 0,tabIndex:ce?0:void 0,style:{marginInlineEnd:0,marginInlineStart:0},children:mt?s.jsxs("div",{className:"str-chat__message-bubble-wrapper message-tip-wrapper",children:[s.jsx(is,{message:o}),((kt=o.text)==null?void 0:kt.trim())&>]}):ln(o)?s.jsx("div",{className:"str-chat__message-bubble-wrapper",children:s.jsxs("div",{className:"flex items-center gap-2",children:[X&&k&&s.jsx(k,{}),X?s.jsx(pe,{...xt,isMine:!0}):s.jsx(pe,{...xt,isMine:!1,isUnlocking:E(o.id),onUnlockClick:()=>T==null?void 0:T(o,j)}),!X&&k&&s.jsx(k,{})]})}):cn(o)?s.jsxs("div",{className:"str-chat__message-bubble-wrapper message-locked-attachment-wrapper",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[X&&k&&s.jsx(k,{}),X?s.jsx(pe,{...ft,isMine:!0,onPreviewClick:()=>T?T(o,j):void 0}):s.jsx(pe,{...ft,isMine:!1,isUnlocking:E(o.id),onUnlockClick:()=>T?T(o,j):void 0,onDownloadClick:()=>R?R(o,j):void 0}),!X&&k&&s.jsx(k,{})]}),o.text&>]}):Bs?s.jsx(nr,{groupPosition:Se,isMyMessage:X,message:{...V,attachments:P,i18n:void 0},renderText:v}):s.jsx("div",{className:"str-chat__message-bubble-wrapper",children:s.jsxs("div",{className:y("str-chat__message-bubble",{"relative isolate":re}),children:[fe&&!ht&&s.jsx(Mt,{message:o,hasAttachment:Pe,isMyMessage:X}),De&&s.jsx(w.Poll,{poll:De}),P!=null&&P.length&&!o.quoted_message?s.jsx(M,{actionHandler:d,attachments:P}):null,K?s.jsx(W,{message:V,renderText:v}):s.jsx(w.MessageText,{message:V,renderText:v}),s.jsx(w.MessageErrorIcon,{}),re&&s.jsx(Te,{side:X?"me":"other"})]})})}),!Fs&&!mt&&s.jsx("div",{className:"str-chat__message-footer",children:(!fe||ht)&&s.jsx(Mt,{message:o,hasAttachment:Pe,isMyMessage:X})}),s.jsx(vn,{onOutboundClick:b,resolvedOutbound:g}),te&&s.jsx(Y,{onClick:c,reply_count:o.reply_count}),ie&&s.jsx(D,{})]},o.id)]})},rr=x.memo(ar,(e,t)=>{var n,a,r,i;return e.viewerLanguage!==t.viewerLanguage||e.onOutboundClick!==t.onOutboundClick||((n=e.resolvedOutbound)==null?void 0:n.id)!==((a=t.resolvedOutbound)==null?void 0:a.id)||((r=e.resolvedOutbound)==null?void 0:r.name)!==((i=t.resolvedOutbound)==null?void 0:i.name)?!1:w.areMessageUIPropsEqual(e,t)}),ir=e=>{var i;const t=w.useMessageContext("CustomMessage"),n=x.useContext(rs),a=(i=t.message.metadata)==null?void 0:i.outbound_id,r=typeof a=="string"?n==null?void 0:n[a]:void 0;return s.jsx(rr,{...t,...e,resolvedOutbound:r})},or=()=>{var n;const{handleDelete:e,message:t}=w.useMessageContext("CustomMessageActions");return((n=t.metadata)==null?void 0:n.payment_status)==="paid"?null:s.jsx(Ve.DefaultDropdownActionButton,{onClick:e,"aria-label":"Delete",title:"Delete",className:"bg-marble rounded-full p-2 hover:bg-sand transition-all",children:s.jsx(C.TrashSimpleIcon,{size:16,weight:"light","aria-hidden":!0})})},lr=()=>{const{handleFlag:e}=w.useMessageContext("CustomMessageActions");return s.jsx(Ve.DefaultDropdownActionButton,{onClick:e,"aria-label":"Report",title:"Report",className:"bg-marble rounded-full p-2 hover:bg-sand transition-all",children:s.jsx(C.FlagIcon,{size:16,weight:"light","aria-hidden":!0})})},cr=()=>{var t;const{message:e}=w.useMessageContext("CustomMessageActions");return((t=e.metadata)==null?void 0:t.custom_type)!==H.MESSAGE_CUSTOM_TYPE.ATTACHMENT?null:s.jsx(Ve.MessageActions,{messageActionSet:[{Component:or,placement:"quick",type:"delete"},{Component:lr,placement:"quick",type:"flag"}]})},dr=e=>({linkPreviews:Array.from(e.previews.values()).filter(t=>Ee.LinkPreviewsManager.previewIsLoaded(t)||Ee.LinkPreviewsManager.previewIsLoading(t))}),ur=()=>{const{linkPreviewsManager:e}=w.useMessageComposer(),{linkPreviews:t}=w.useStateStore(e.state,dr),n=r=>{e.dismissPreview(r)};return t.length>0?s.jsx("div",{className:"messaging-link-preview-list flex flex-col items-stretch w-full gap-2",children:t.map(r=>{const i=Ee.LinkPreviewsManager.previewIsLoading(r);return s.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},Me=x.createContext(!1),mr=200,hr=()=>x.useContext(Me),xr=({sendMessage:e,disabled:t,...n})=>s.jsx("button",{...n,type:"button","aria-label":"Send",disabled:t,onPointerDown:a=>a.preventDefault(),onClick:e,children:s.jsx(C.ArrowUpIcon,{weight:"bold",className:"size-4"})}),$t=()=>{const e=x.useContext(Me),{handleSubmit:t}=w.useMessageInputContext(),n=w.useMessageComposerHasSendableData(),a=e||!n,{SendButton:r=xr,AttachmentPreviewList:i=w.AttachmentPreviewList}=w.useComponentContext("CustomMessageInput"),l=x.useRef(null);return x.useEffect(()=>{const d=l.current;if(!d||typeof ResizeObserver>"u")return;const c=new ResizeObserver(()=>{d.contains(document.activeElement)&&(d.scrollTop=d.scrollHeight)});return c.observe(d),()=>c.disconnect()},[]),x.useEffect(()=>{const d=l.current;if(!d)return;const c=u=>{var m;Array.from(((m=u.clipboardData)==null?void 0:m.items)??[]).some(f=>f.kind==="file")||u.stopPropagation()};return d.addEventListener("paste",c),()=>d.removeEventListener("paste",c)},[]),s.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:[s.jsxs("div",{className:"messaging-composer-previews empty:hidden flex flex-col gap-2 px-2 pt-2",children:[s.jsx(w.QuotedMessagePreview,{}),s.jsx(ur,{}),s.jsx(i,{})]}),s.jsxs("div",{className:"messaging-composer-row flex items-start",children:[s.jsx(w.TextareaComposer,{"aria-disabled":e||void 0,containerClassName:"min-w-0 flex-1 leading-[0]",className:"w-full resize-none overflow-hidden bg-transparent py-3.5 pl-4 pr-4 outline-none leading-5 placeholder:text-black/30 text-sm",autoFocus:!e,enterKeyHint:"send",maxRows:1/0,readOnly:e,tabIndex:e?-1:void 0}),s.jsx("div",{className:"sticky bottom-2 mt-auto mb-2 mr-2 shrink-0 pt-2",children:s.jsx(r,{sendMessage:t,"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"})})]})]})},Ut=()=>s.jsxs("div",{className:"messaging-composer-backdrop","aria-hidden":"true",children:[s.jsx("div",{className:"messaging-composer-backdrop-blur"}),s.jsx("div",{className:"messaging-composer-backdrop-blur"}),s.jsx("div",{className:"messaging-composer-backdrop-blur"}),s.jsx("div",{className:"messaging-composer-backdrop-blur"}),s.jsx("div",{className:"messaging-composer-backdrop-blur"}),s.jsx("div",{className:"messaging-composer-backdrop-gradient"})]}),Vt=({renderActions:e,renderHeader:t,renderFooter:n,disabled:a=!1,disabledReason:r,composerInput:i})=>{var h;const{channel:l}=w.useChannelStateContext(),d=((h=l==null?void 0:l.data)==null?void 0:h.frozen)===!0,c=!!i,u=x.useRef(null);return x.useEffect(()=>{if(!c)return;const m=u.current,f=m==null?void 0:m.parentElement;if(!m||!f)return;let o=m.offsetHeight;const v=()=>{const p=m.offsetHeight,b=p>o;o=p;const g=Array.from(f.querySelectorAll(".str-chat__list")).find(j=>j.scrollHeight>j.clientHeight)??null,N=g?g.scrollHeight-g.scrollTop-g.clientHeight<mr:!1;f.style.setProperty("--messaging-composer-height",`${p}px`),b&&N&&g&&(g.scrollTop=g.scrollHeight)};if(v(),typeof ResizeObserver>"u")return;const _=new ResizeObserver(v);return _.observe(m),()=>{_.disconnect(),f.style.removeProperty("--messaging-composer-height")}},[c]),a?c?s.jsxs("div",{ref:u,className:"messaging-composer-chrome messaging-composer-chrome--floating",children:[s.jsx(Ut,{}),s.jsxs("div",{className:"relative z-10 flex flex-col",children:[t==null?void 0:t(),s.jsx("div",{className:"messaging-composer-locked-panel flex w-full flex-col items-center justify-center gap-3 px-6 py-4",children:r?s.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()]})]}):s.jsxs(s.Fragment,{children:[t==null?void 0:t(),s.jsx("div",{className:"messaging-composer-locked-panel flex w-full flex-col items-center justify-center gap-3 px-6 py-4",children:r?s.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()]}):c?s.jsxs("div",{ref:u,className:"messaging-composer-chrome messaging-composer-chrome--floating",children:[s.jsx(Ut,{}),s.jsxs("div",{className:"relative z-10 flex min-h-0 flex-col",children:[t==null?void 0:t(),s.jsxs("div",{className:"flex min-h-0 flex-col gap-4 p-3 pb-5 md:p-5",children:[s.jsxs("div",{inert:d?"":void 0,"aria-disabled":d||void 0,className:"message-input flex min-h-0 items-end gap-4 aria-disabled:opacity-40",children:[e&&s.jsx("div",{className:"flex h-12 shrink-0 items-center justify-center",children:e()}),s.jsx(Me.Provider,{value:d,children:s.jsx(w.MessageInput,{Input:i??$t})})]}),n==null?void 0:n()]})]})]}):s.jsxs("div",{className:"flex min-h-0 flex-col gap-4 p-4",children:[t==null?void 0:t(),s.jsxs("div",{inert:d?"":void 0,"aria-disabled":d||void 0,className:"message-input flex min-h-0 items-end gap-4 aria-disabled:opacity-40",children:[e&&s.jsx("div",{className:"flex h-12 shrink-0 items-center justify-center",children:e()}),s.jsx(Me.Provider,{value:d,children:s.jsx(w.MessageInput,{Input:$t})})]}),n==null?void 0:n()]})},fr={SYSTEM_DM_AGENT_PAUSED:"DM Agent has left the conversation",SYSTEM_DM_AGENT_RESUMED:"DM Agent has rejoined the conversation"},gr=["SYSTEM_AGE_SAFETY_BLOCKED"],pr={SYSTEM_AGE_SAFETY_BLOCKED:"This user isnβt able to reply because they donβt meet our age safety guidelines."},ze="age safety guidelines.",br="https://linktr.ee/s/about/contact",vr=e=>gr.includes(e),jr=e=>{var t;return vr((t=e.metadata)==null?void 0:t.custom_type)},wr=e=>{var a;const t=(a=e.metadata)==null?void 0:a.custom_type;if(H.isDmAgentSystemType(t))return{kind:"dm-agent",type:t};if(H.isAgeSafetySystemType(t))return{kind:"age-safety",type:t};const n=e.dm_agent_system_type;if(H.isDmAgentSystemType(n))return{kind:"dm-agent",type:n}},_r=e=>{const t=e.indexOf(ze);if(t===-1)return e;const n=t+ze.length;return s.jsxs(s.Fragment,{children:[e.slice(0,t),s.jsx("a",{href:br,target:"_blank",rel:"noopener noreferrer",className:"mes-age-safety-system-message__emphasis font-medium text-inherit underline",children:ze}),e.slice(n)]})},Nr=e=>{var a,r;const t=!jr(e.message),n=wr(e.message);if((n==null?void 0:n.kind)==="dm-agent"){const i=((a=e.message.text)==null?void 0:a.trim())||fr[n.type];return s.jsxs("div",{className:"str-chat__message--system","data-testid":"message-system",children:[s.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:[s.jsx(C.SparkleIcon,{size:16,weight:"regular","aria-hidden":!0,className:"mes-dm-agent-system-message__sparkle shrink-0"}),s.jsx("p",{className:"mes-dm-agent-system-message__text m-0 text-center text-[14px] font-normal leading-5 tracking-[0.21px]",children:i})]}),!t&&s.jsx(w.MessageTimestamp,{message:e.message})]})}if((n==null?void 0:n.kind)==="age-safety"){const i=((r=e.message.text)==null?void 0:r.trim())||pr[n.type];return s.jsxs("div",{className:"str-chat__message--system","data-testid":"message-system",children:[s.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:[s.jsx(C.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"}),s.jsx("div",{className:"mes-age-safety-system-message__content min-w-0 flex-[1_0_0]",children:s.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:_r(i)})})]}),!t&&s.jsx(w.MessageTimestamp,{message:e.message})]})}return s.jsxs("div",{className:"str-chat__message--system","data-testid":"message-system",children:[s.jsxs("div",{className:"str-chat__message--system__text",children:[s.jsx("div",{className:"str-chat__message--system__line"}),s.jsx("p",{children:e.message.text}),s.jsx("div",{className:"str-chat__message--system__line"})]}),!t&&s.jsx(w.MessageTimestamp,{message:e.message})]})},Es=x.createContext(!1),$e=({cx:e,index:t})=>s.jsx("circle",{cx:e,cy:"6.15",r:"3.9",fill:"#A0A0A0",children:s.jsx("animateTransform",{attributeName:"transform",type:"translate",values:"0 0; 0 -2.25; 0 0;",dur:"900ms",begin:`${120*t}ms`,repeatCount:"indefinite"})}),yr=new Set([w.AIStates.Thinking,w.AIStates.Generating,w.AIStates.ExternalSources]),Cr=({threadList:e})=>{var v,_;const{channel:t,channelConfig:n,thread:a}=w.useChannelStateContext(),{client:r}=w.useChatContext(),{typing:i={}}=w.useTypingContext(),{aiState:l}=w.useAIState(t),d=x.useContext(Es);if(!e&&d&&yr.has(l)){const p=Sr(t,(v=r.user)==null?void 0:v.id);return s.jsx(Ht,{avatarId:(p==null?void 0:p.id)??"ai-agent",avatarName:(p==null?void 0:p.name)??(p==null?void 0:p.id)??"Agent",avatarImage:p==null?void 0:p.image,testId:"typing-indicator-ai"})}if((n==null?void 0:n.typing_events)===!1)return null;const u=e?[]:Object.values(i).filter(({parent_id:p,user:b})=>{var g;return(b==null?void 0:b.id)!==((g=r.user)==null?void 0:g.id)&&!p}),h=e?Object.values(i).filter(({parent_id:p,user:b})=>{var g;return(b==null?void 0:b.id)!==((g=r.user)==null?void 0:g.id)&&p===(a==null?void 0:a.id)}):[],m=e?h:u;if(!m.length)return null;const f=(_=m[0])==null?void 0:_.user,o=f!=null&&f.id&&t.state.members[f.id]?t.state.members[f.id].user:void 0;return s.jsx(Ht,{avatarId:(f==null?void 0:f.id)??(o==null?void 0:o.id)??"typing-user",avatarName:(f==null?void 0:f.name)??(o==null?void 0:o.name)??(f==null?void 0:f.id)??"Typing user",avatarImage:(f==null?void 0:f.image)??(o==null?void 0:o.image),testId:"typing-indicator"})},Ht=({avatarId:e,avatarName:t,avatarImage:n,testId:a})=>s.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:s.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:[s.jsx(he,{className:"str-chat__avatar str-chat__message-sender-avatar",id:e,name:t,image:n??void 0,size:24,shape:"circle"}),s.jsx("div",{className:"str-chat__message-inner mx-0",children:s.jsx("div",{className:"str-chat__message-bubble-wrapper",children:s.jsxs("div",{className:"str-chat__message-bubble relative isolate",children:[s.jsx("div",{className:"str-chat__message-text min-h-11 flex items-center",children:s.jsx("div",{className:"str-chat__message-text-inner str-chat__message-simple-text-inner",children:s.jsxs("svg",{"aria-hidden":"true",className:"block overflow-visible",viewBox:"0 0 32 12.3",width:"32",height:"13",overflow:"visible",children:[s.jsx($e,{cx:"4",index:0}),s.jsx($e,{cx:"16",index:1}),s.jsx($e,{cx:"28",index:2})]})})}),s.jsx(Te,{side:"other"})]})})})]})});function Sr(e,t){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!==t)return i}}const Is=()=>null,kr=({className:e,message:t})=>s.jsxs("div",{className:y("flex items-center justify-center h-full",e),children:[s.jsxs("svg",{viewBox:"0 0 100 100",className:"size-8 fill-pebble",stroke:"none",children:[s.jsx("circle",{cx:"6",cy:"50",r:"6",children:s.jsx("animateTransform",{attributeName:"transform",dur:"1s",type:"translate",values:"0 15 ; 0 -15; 0 15",repeatCount:"indefinite",begin:"0.1"})}),s.jsx("circle",{cx:"30",cy:"50",r:"6",children:s.jsx("animateTransform",{attributeName:"transform",dur:"1s",type:"translate",values:"0 10 ; 0 -10; 0 10",repeatCount:"indefinite",begin:"0.2"})}),s.jsx("circle",{cx:"54",cy:"50",r:"6",children:s.jsx("animateTransform",{attributeName:"transform",dur:"1s",type:"translate",values:"0 5 ; 0 -5; 0 5",repeatCount:"indefinite",begin:"0.3"})})]}),t&&s.jsx("span",{className:"text-stone",children:t})]}),Re=x.memo(()=>s.jsx("div",{className:"messaging-loading-state flex items-center justify-center h-full",children:s.jsxs("div",{className:"flex items-center",children:[s.jsx(kr,{className:"w-6 h-6"}),s.jsx("span",{className:"text-sm text-stone",children:"Loading messages"})]})}));Re.displayName="LoadingState";const Er=({onBack:e,showBackButton:t,renderMessageInputActions:n,renderMessageInputFooter:a,renderConversationFooter:r,onLeaveConversation:i,onBlockParticipant:l,showDeleteConversation:d=!0,onDeleteConversationClick:c,onBlockParticipantClick:u,onReportParticipantClick:h,showBlockParticipant:m=!0,showReportParticipant:f=!0,composerDisabled:o=!1,composerDisabledReason:v,showStarButton:_=!1,renderChannelBanner:p,customChannelActions:b,renderChannelActions:g,renderMessage:N,viewerLanguage:j,showChannelInfo:E=!0,onParticipantNameClick:T,onOutboundClick:A,resolveOutbound:R,composerInput:F})=>{const{channel:L,messages:S}=w.useChannelStateContext(),M=x.useRef(A);x.useEffect(()=>{M.current=A},[A]);const I=x.useCallback(U=>{var W;(W=M.current)==null||W.call(M,U)},[]),k=A?I:void 0,O=fn(S,R),$=L.state.messages.some(U=>U.type!=="deleted"),B=p?s.jsx(x.Fragment,{children:p()},"lt-channel-banner"):null,D=s.jsx(Js,{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:t,showChannelInfo:E,showStarButton:_,onLeaveConversation:i,onBlockParticipant:l,showDeleteConversation:d,showBlockParticipant:m,showReportParticipant:f,onDeleteConversationClick:c,onBlockParticipantClick:u,onReportParticipantClick:h,customChannelActions:b,renderChannelActions:g,onParticipantNameClick:T}),Y=x.useCallback(U=>{const{message:W}=w.useMessageContext("ChannelView"),q=s.jsx(ir,{...U,viewerLanguage:j,onOutboundClick:k});return!N||!W?q:N(q,W)},[k,N,j]);return s.jsx(rs.Provider,{value:O,children:s.jsx(w.WithComponents,{overrides:{Message:Y,MessageActions:cr,UnreadMessagesNotification:()=>null,UnreadMessagesSeparator:()=>null},children:s.jsx(w.Window,{children:F?s.jsxs("div",{className:"messaging-channel-layout relative flex min-h-0 flex-1 flex-col",children:[s.jsxs("div",{className:"messaging-channel-message-list messaging-channel-message-list--floating relative min-h-0 flex-1 overflow-hidden",children:[!$&&s.jsx("div",{className:"str-chat__list",children:s.jsxs("div",{className:"str-chat__message-list-scroll",children:[D,B]})}),s.jsx(w.MessageList,{head:$?s.jsxs("div",{className:"sticky top-0 z-10",children:[D,B]}):void 0,hideDeletedMessages:!0,hideNewMessageSeparator:!1})]},"lt-channel-message-list"),s.jsx(Vt,{...n&&{renderActions:()=>n==null?void 0:n(L)},...r&&{renderHeader:()=>r(L)},renderFooter:()=>a==null?void 0:a(L),disabled:o,disabledReason:v,composerInput:F},"lt-channel-message-input")]}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex-1 overflow-hidden relative",children:[!$&&s.jsx("div",{className:"str-chat__list",children:s.jsxs("div",{className:"str-chat__message-list-scroll",children:[D,B]})}),s.jsx(w.MessageList,{head:$?s.jsxs("div",{className:"sticky top-0 z-10",children:[D,B]}):void 0,hideDeletedMessages:!0,hideNewMessageSeparator:!1})]},"lt-channel-message-list"),r?s.jsx(x.Fragment,{children:r(L)},"lt-channel-conversation-footer"):null,s.jsx(Vt,{...n&&{renderActions:()=>n==null?void 0:n(L)},renderFooter:()=>a==null?void 0:a(L),disabled:o,disabledReason:v,composerInput:F},"lt-channel-message-input")]})})})})},dt=x.memo(({channel:e,onBack:t,showBackButton:n=!1,renderMessageInputActions:a,renderMessageInputFooter:r,renderConversationFooter:i,onLeaveConversation:l,onBlockParticipant:d,className:c,CustomChannelEmptyState:u=Is,showDeleteConversation:h=!0,onDeleteConversationClick:m,onBlockParticipantClick:f,onReportParticipantClick:o,showBlockParticipant:v=!0,showReportParticipant:_=!0,composerDisabled:p=!1,composerDisabledReason:b,dmAgentEnabled:g,messageMetadata:N,onMessageSent:j,showStarButton:E=!1,renderChannelBanner:T,customChannelActions:A,renderChannelActions:R,renderMessage:F,onMessageLinkClick:L,sendButton:S,attachmentPreviewList:M,viewerLanguage:I,showChannelInfo:k=!0,onParticipantNameClick:O,onOutboundClick:$,resolveOutbound:B,composerInput:D})=>{const Y=x.useCallback(async(q,G,J)=>{var ee;const K=((ee=e.data)==null?void 0:ee.chatbot_paused)===!0,P=g&&!K,Q={...G,...P&&{silent:!0},...N&&{metadata:{...G.metadata??{},...N}}},V={...J,...P&&{skip_push:!0}},Z=await e.sendMessage(Q,V);return j==null||j(Z),Z},[e,g,N,j]),U=x.useRef(null);x.useEffect(()=>{if(!L)return;const q=U.current;if(!q)return;const G=J=>{const K=J.target,P=K==null?void 0:K.closest("a[href]"),Q=P==null?void 0:P.getAttribute("href");if(!Q)return;const V=P==null?void 0:P.closest("[data-message-id]"),Z=V==null?void 0:V.getAttribute("data-message-id"),ee=Z?e.state.messages.find(ne=>ne.id===Z):void 0;L(Q,ee)};return q.addEventListener("click",G),()=>q.removeEventListener("click",G)},[L,e]);const W=H.isOfficialChannel(e.type)?{"--lt-msg-card-width":"368px"}:void 0;return s.jsx("div",{ref:U,className:y("messaging-channel-view h-full flex flex-col",c),style:W,children:s.jsx(Es.Provider,{value:g??!1,children:s.jsx(w.Channel,{channel:e,MessageSystem:Nr,EmptyStateIndicator:u,LoadingIndicator:Re,DateSeparator:Qs,TypingIndicator:Cr,doSendMessageRequest:Y,...S?{SendButton:S}:{},...M?{AttachmentPreviewList:M}:{},children:s.jsx(Er,{onBack:t,showBackButton:n,renderMessageInputActions:a,renderMessageInputFooter:r,renderConversationFooter:i,onLeaveConversation:l,onBlockParticipant:d,CustomChannelEmptyState:u,showDeleteConversation:h,onDeleteConversationClick:m,onBlockParticipantClick:f,onReportParticipantClick:o,showBlockParticipant:v,showReportParticipant:_,composerDisabled:p,composerDisabledReason:b,showStarButton:E,renderChannelBanner:T,customChannelActions:A,renderChannelActions:R,renderMessage:F,viewerLanguage:I,showChannelInfo:k,onParticipantNameClick:O,onOutboundClick:$,resolveOutbound:B,composerInput:D})})})})});dt.displayName="ChannelView";const be=x.memo(({message:e,onBack:t})=>s.jsx("div",{className:"messaging-error-state flex items-center justify-center h-full p-8",children:s.jsxs("div",{className:"text-center max-w-sm",children:[s.jsx("div",{className:"w-24 h-24 bg-danger-alt/20 rounded-full flex items-center justify-center mx-auto mb-6",children:s.jsx("span",{className:"text-4xl",children:"β οΈ"})}),s.jsx("h2",{className:"font-semibold text-charcoal mb-2",children:"Oops!"}),s.jsx("p",{className:"text-stone text-sm mb-6",children:e}),t&&s.jsx("button",{type:"button",onClick:t,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 Ir=({capabilities:e={},renderMessageInputActions:t,renderConversationFooter:n,onChannelSelect:a,onExitConversation:r,initialParticipantFilter:i,initialParticipantData:l,CustomChannelEmptyState:d,onBlockParticipantClick:c,onReportParticipantClick:u,dmAgentEnabled:h,onMessageSent:m,viewerLanguage:f,renderChannelBanner:o,customChannelActions:v,renderChannelActions:_,onParticipantNameClick:p,onOutboundClick:b,resolveOutbound:g,renderMessage:N,onMessageLinkClick:j,showChannelInfo:E,composerInput:T,attachmentPreviewList:A})=>{const{client:R,isConnected:F,isLoading:L,error:S,refreshConnection:M,service:I,debug:k}=Zt(),[O,$]=x.useState(null),[B,D]=x.useState(null),[Y,U]=x.useState(!1),{showDeleteConversation:W=!0}=e,q=x.useRef(l);q.current=l;const G=x.useRef(a);G.current=a;const J=x.useRef(null),K=x.useRef(null);x.useEffect(()=>{K.current=O},[O]),x.useEffect(()=>{if(!R||!F)return;const V=R.userID;if(!V)return;const Z=`${V}::${i}`;if(J.current===Z)return;J.current=Z;const ee=()=>{J.current===Z&&(J.current=null)};(async()=>{var Se,re;try{k&&console.log("[MessagingShell] Loading initial conversation with:",i);const te=await R.queryChannels({type:"messaging",members:{$eq:[V,i]}},{},{limit:1});if(te.length>0){$(te[0]),D(null),(Se=G.current)==null||Se.call(G,te[0]),k&&console.log("[MessagingShell] Initial conversation loaded:",te[0].id);return}const ie=q.current;if(!ie||!I){ee(),D("No conversation found with this account"),k&&console.log("[MessagingShell] No conversation found for:",i);return}try{const ae=await I.startChannelWithParticipant({id:ie.id,name:ie.name,phone:ie.phone});$(ae),D(null),(re=G.current)==null||re.call(G,ae),k&&console.log("[MessagingShell] Channel created and loaded:",ae.id)}catch(ae){console.error("[MessagingShell] Failed to create conversation:",ae),ee(),D("Failed to create conversation")}}catch(te){console.error("[MessagingShell] Failed to load initial conversation:",te),ee(),K.current||D("Failed to load conversation")}})()},[i,R,F,I,k]);const P=x.useRef(r);P.current=r;const Q=x.useCallback(()=>{var V;$(null),U(!0),(V=P.current)==null||V.call(P)},[]);return L?s.jsx(Re,{}):S?s.jsx(be,{message:S,onBack:M}):!F||!R?s.jsx(be,{message:"Not connected to messaging service",onBack:M}):B?s.jsx(be,{message:B}):Y&&!O?s.jsx(be,{message:"Conversation ended"}):O?s.jsx("div",{className:"messaging-shell h-full bg-background-primary overflow-hidden",children:s.jsx("div",{className:"flex h-full min-h-0 flex-col",children:s.jsx(dt,{channel:O,renderMessageInputActions:t,renderConversationFooter:n,renderChannelBanner:o,onLeaveConversation:Q,onBlockParticipant:Q,CustomChannelEmptyState:d,showDeleteConversation:W,onBlockParticipantClick:c,onReportParticipantClick:u,dmAgentEnabled:h,onMessageSent:m,viewerLanguage:f,customChannelActions:v,renderChannelActions:_,onParticipantNameClick:p,onOutboundClick:b,resolveOutbound:g,renderMessage:N,onMessageLinkClick:j,showChannelInfo:E,composerInput:T,attachmentPreviewList:A},O.id)})}):s.jsx(Re,{})};function Tr(e){const t=e.state.pending_messages;if(t!=null&&t.length)for(const n of t)e.state.addMessageSorted(n.message)}const Ts=x.createContext({selectedChannel:void 0,onChannelSelect:()=>{},debug:!1,renderMessagePreview:void 0,channelPreview:void 0,viewerLanguage:void 0}),Ar=Ts.Provider,Mr=()=>x.useContext(Ts),Rr=(e,t)=>{const n=Date.UTC(e.getFullYear(),e.getMonth(),e.getDate()),a=Date.UTC(t.getFullYear(),t.getMonth(),t.getDate());return Math.floor((a-n)/(1e3*60*60*24))},As=e=>{const t=new Date;if(Math.floor((t.getTime()-e.getTime())/1e3)<60)return"Just now";const a=Rr(e,t);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()===t.getFullYear()?e.toLocaleDateString(void 0,{month:"short",day:"numeric"}):e.toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"})},Ms=x.memo(e=>{var R,F,L;const{channel:t,unread:n}=e,{selectedChannel:a,onChannelSelect:r,debug:i,channelPreview:l,renderMessagePreview:d,viewerLanguage:c}=Mr(),{client:u}=w.useChatContext(),h=(a==null?void 0:a.id)===(t==null?void 0:t.id),m=Jt(t);if(l){const S=l;return s.jsx(S,{...e,active:h,selectedChannel:a,onChannelSelect:r,viewerLanguage:c})}const f=()=>{t&&r(t)},o=S=>{const M=S.key==="Enter"||S.key===" ",I=S.repeat;!M||I||(S.preventDefault(),f())},v=Ge((R=t==null?void 0:t.state)==null?void 0:R.members,u==null?void 0:u.userID,t==null?void 0:t.type),_=Ye(v==null?void 0:v.user),p=(F=v==null?void 0:v.user)==null?void 0:F.image,b=(()=>{var M;const S=(M=t==null?void 0:t.state)==null?void 0:M.messages;if(S!=null&&S.length){for(let I=S.length-1;I>=0;I--)if(S[I].type!=="system")return S[I]}})(),N=(()=>{var O;const S=We({message:b,viewerLanguage:c}),{custom_type:M,attachment_content_type:I}=(b==null?void 0:b.metadata)||{};if(M===H.MESSAGE_CUSTOM_TYPE.TIP)return S||"Sent a tip";if(M===H.MESSAGE_CUSTOM_TYPE.PAID)return S||"Sent a message";if(M===H.MESSAGE_CUSTOM_TYPE.ATTACHMENT){if(I==="text")return"π Sent a locked message";if(I==="media")return"π Sent a locked attachment"}if(S)return S;const k=(O=b==null?void 0:b.attachments)==null?void 0:O[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"})(),j=b!=null&&b.created_at?As(new Date(b.created_at)):"",E=b?Ie(b):!1,T=d?d(b,N):`${E?"β¨ ":""}${N}`,A=n??0;return i&&console.log("πΊ [ChannelList] π CHANNEL PREVIEW RENDER",{channelId:t==null?void 0:t.id,isSelected:h,participantName:_,unreadCount:A,hasTimestamp:!!j}),s.jsx("div",{role:"button",tabIndex:0,onClick:f,onKeyDown:o,className:y("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]":h,"hover:bg-black/[0.02]":!h}),"data-dd-privacy":"mask",children:s.jsxs("div",{className:"flex items-start gap-4",children:[s.jsx(he,{id:((L=v==null?void 0:v.user)==null?void 0:L.id)||t.id||"unknown",name:_,image:p,size:48,starred:m}),s.jsxs("div",{className:"flex-1 min-w-0 flex flex-col gap-1",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs("h3",{className:y("text-sm font-medium truncate text-[#191918]"),children:[m&&s.jsx("span",{className:"sr-only",children:"Starred conversation. "}),_]}),j&&s.jsx("span",{className:"text-xs text-[#717070] flex-shrink-0",children:j})]}),s.jsxs("div",{className:"flex items-center justify-between gap-2 min-w-0",children:[s.jsx("p",{className:"text-sm text-[#717070] flex-1 line-clamp-1",children:T}),A>0&&s.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:A>99?"99+":A})]})]})]})})});Ms.displayName="CustomChannelPreview";const Lr={last_message_at:-1},Rs=x.memo(({onChannelSelect:e,selectedChannel:t,filters:n,allowNewMessagesFromUnfilteredChannels:a=!1,channelRenderFilterFn:r,sort:i=Lr,className:l,customEmptyStateIndicator:d,channelListPaginator:c=w.InfiniteScroll,channelPreview:u,renderMessagePreview:h,viewerLanguage:m,lockChannelOrder:f,onMessageNewHandler:o,onMessageNew:v,onChannelVisible:_,onAddedToChannel:p,onChannelUpdated:b})=>{const g=x.useRef(0);g.current++;const{debug:N=!1}=He(),j=x.useCallback(T=>{for(const A of T)Tr(A);return r?r(T):T},[r]);N&&console.log("πΊ [ChannelList] π RENDER START",{renderCount:g.current,selectedChannelId:t==null?void 0:t.id,filters:n});const E=x.useMemo(()=>({selectedChannel:t,onChannelSelect:e,debug:N,channelPreview:u,renderMessagePreview:h,viewerLanguage:m}),[t,e,N,u,h,m]);return s.jsx("div",{className:y("messaging-channel-list h-full flex flex-col min-w-0 overflow-hidden",l),children:s.jsx("div",{className:"flex-1 overflow-hidden min-w-0",children:s.jsx(Ar,{value:E,children:s.jsx(w.ChannelList,{filters:n,sort:i,options:{limit:30},allowNewMessagesFromUnfilteredChannels:a,channelRenderFilterFn:j,lockChannelOrder:f,onMessageNewHandler:o,onMessageNew:v,onChannelVisible:_,onAddedToChannel:p,onChannelUpdated:b,Paginator:c,Preview:Ms,EmptyStateIndicator:d},`${JSON.stringify(n)}:${JSON.stringify(i)}`)})})})});Rs.displayName="ChannelList";const Or="line-clamp-2 text-[14px] font-medium leading-5 tracking-[0.28px] [text-wrap:balance]",Dr="text-[12px] leading-4 tracking-[0.24px] [text-wrap:pretty]",Gt=({surface:e,actions:t,layout:n})=>{if(t==null||t.length===0)return null;const a=n==="stacked";return s.jsx("div",{className:y("flex gap-2",a?"mt-3 flex-col":"min-w-0 max-w-[60%] flex-row flex-wrap justify-end"),children:t.map((r,i)=>s.jsx(os,{variant:e,cta:r,fullWidth:a,standalone:!0},`${r.label}-${i}`))})},Pr=({ctaSurface:e,chinTextColor:t,title:n,subtitle:a,subtitleLines:r=3,appIcon:i,actions:l})=>{var v;const d=n!=null&&n.trim()!=="",c=a!=null&&a.trim()!=="",u=l!=null&&l.length>0;if(!d&&!c&&!u)return null;const h={color:t},m=r>1?{...h,display:"-webkit-box",WebkitBoxOrient:"vertical",WebkitLineClamp:r,overflow:"hidden"}:h,f=u&&(((v=l==null?void 0:l[0])==null?void 0:v.variant)??"primary")==="secondary",o=s.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-[2px]",children:[d&&s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[i?s.jsx("span",{className:"shrink-0",children:i}):null,s.jsx("p",{className:y("min-w-0",Or),style:h,children:n})]}),c&&s.jsx("p",{className:y(Dr,r>1&&"whitespace-pre-line",r<=1&&"truncate"),style:m,children:a})]});return s.jsx("div",{className:"shrink-0 px-4 py-3",children:f?s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[o,s.jsx(Gt,{surface:e,actions:l,layout:"row"})]}):s.jsxs(s.Fragment,{children:[o,s.jsx(Gt,{surface:e,actions:l,layout:"stacked"})]})})},Fr={dark:"bg-white/[0.06]",light:"bg-black/[0.04]"},Br={1:[0],2:[-10,10],3:[-13,0,13]},zr={1:[0],2:[-26,26],3:[-40,0,40]},$r={1:[0],2:[0,1],3:[1,3,2]},Ur={1:[1],2:[1,1],3:[1,1.08,1]},Vr=({variant:e,images:t})=>{const[n,a]=x.useState({}),r=t.join(`
|
|
2
|
-
`),[i,l]=x.useState(r);r!==i&&(l(r),a({}));const d=t.slice(0,3).map((o,v)=>({src:o,index:v})).filter(({index:o})=>!n[o]),c=d.length>=3?3:d.length===2?2:1,u=Br[c],h=zr[c],m=$r[c],f=Ur[c];return s.jsx("div",{className:y("relative flex min-h-0 w-full flex-1 items-center justify-center overflow-hidden",Fr[e]),children:d.map(({src:o,index:v},_)=>s.jsx("img",{src:le(o)??o,alt:"",draggable:!1,loading:"lazy",decoding:"async",onError:()=>a(p=>({...p,[v]:!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(${h[_]}px) rotate(${u[_]}deg) scale(${f[_]})`,zIndex:m[_]}},`${o}-${v}`))})},Hr="flex h-[180px] w-full shrink-0 flex-col overflow-hidden",Gr=({variant:e,presentation:t,images:n,title:a,heroUrl:r,onHeroError:i})=>s.jsx("div",{className:Hr,children:t==="fan"?s.jsx(Vr,{variant:e,images:n}):s.jsx(je,{variant:e,thumbnailUrl:r,title:a,mimeType:"image/*",onImageError:i})}),Ls=({variant:e,title:t,subtitle:n,subtitleLines:a,images:r=[],imagePresentation:i,actions:l,appIcon:d,accentColor:c,groupPosition:u="single"})=>{const h=H.resolveRichCardImagePresentation({imagePresentation:i,images:r}),m=r.length>0,f=m&&h==="hero",o=Oe({variant:e,accentColor:c,layout:"featured",thumbnailUrl:f?r[0]:void 0}),v=u==="single"||u==="end";return s.jsx(nt,{accentHex:o.accentHex,side:e==="dark"?"sender":"receiver",visible:v,children:s.jsxs(ve,{variant:e,accentHex:o.accentHex,"data-testid":"rich-card",children:[m&&s.jsx(Gr,{variant:e,presentation:h,images:r,title:t,heroUrl:f?o.thumbnailUrl:void 0,onHeroError:o.onImageError}),s.jsx(Pr,{ctaSurface:o.surface,chinTextColor:o.chinTextColor,title:t,subtitle:n,subtitleLines:a,appIcon:d,actions:l})]})})},Yr=e=>s.jsx(Ls,{...e,variant:"dark"}),Wr=e=>s.jsx(Ls,{...e,variant:"light"}),qr={Sent:Yr,Received:Wr},Yt=`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%`,Xr={sent:"var(--str-chat__own-message-bubble-background-color, #1e2330)",received:"var(--str-chat__message-bubble-background-color, #f1f0ee)"},Kr=({variant:e})=>s.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:Xr[e],WebkitMask:Yt,mask:Yt}}),Zr={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)"}},Os=({variant:e,text:t,tail:n=!0,header:a,className:r})=>s.jsxs("div",{"data-dd-privacy":"mask",className:y("relative px-4 py-3","text-[0.875rem] leading-[1.3125rem] tracking-[0.14px]",r),style:{...Zr[e],borderRadius:"var(--str-chat__message-bubble-border-radius, 1.5rem)",isolation:"isolate"},children:[a!=null&&s.jsx("div",{className:"mb-1 font-medium","data-testid":"message-bubble-header",children:a}),s.jsx("p",{className:"m-0 whitespace-pre-wrap break-words hyphens-manual",children:t}),n&&s.jsx(Kr,{variant:e})]}),Jr=({text:e,tail:t,header:n,className:a})=>s.jsx(Os,{variant:"received",text:e,tail:t,header:n,className:a}),Qr=({text:e,tail:t,className:n})=>s.jsx(Os,{variant:"sent",text:e,tail:t,className:n}),ei={Sent:Qr,Received:Jr},Ds=({question:e,onClick:t,loading:n=!1,className:a})=>s.jsx("button",{type:"button",onClick:t,disabled:n,style:{backgroundColor:"#E6E5E3"},className:y("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}),ti=({faqs:e,onFaqClick:t,loadingFaqId:n,headerText:a,className:r,avatarImage:i,avatarName:l})=>{const d=H.selectEnabledFaqs(e);return d.length===0?null:s.jsx("div",{className:r,children:s.jsxs("div",{className:"flex gap-3 items-end",children:[(i||l)&&s.jsx("div",{className:"flex-none",children:s.jsx(he,{id:l||"account",name:l||"Account",image:i,size:24,shape:"circle"})}),s.jsxs("div",{className:"flex-1 flex flex-col gap-3 rounded-lg p-4",style:{backgroundColor:"#F1F0EE"},children:[a&&s.jsx("p",{className:"text-md text-charcoal mb-4",children:a}),d.map(c=>s.jsx(Ds,{question:c.question,onClick:()=>t(c.id),loading:n===c.id},c.id))]})]})})};exports.ActionButton=ue;exports.Avatar=he;exports.ChannelEmptyState=Is;exports.ChannelList=Rs;exports.ChannelView=dt;exports.CustomMessageProvider=sn;exports.FaqList=ti;exports.FaqListItem=Ds;exports.LinkAttachment=Ae;exports.LockedAttachment=pe;exports.MessageAttachment=me;exports.MessageBubble=ei;exports.MessagingLoggerProvider=Xt;exports.MessagingProvider=Us;exports.MessagingShell=Ir;exports.RichCard=qr;exports.TipMessage=is;exports.bubbleGroupPositionFromStream=Jn;exports.buildCompactMetaLabel=hs;exports.formatFileSize=us;exports.formatRelativeTime=As;exports.getFileExtensionLabel=ms;exports.getMessageDisplayText=We;exports.getSourceType=xe;exports.isLinkAttachment=Le;exports.isTipMessage=Xe;exports.isUuidLike=Qt;exports.nativePlayerProps=Qe;exports.normalizeLanguageCode=ts;exports.optimizeMessagingAttachmentUrl=le;exports.renderTypeIcon=et;exports.resolveConversationParticipant=Ge;exports.resolveParticipantDisplayName=Ye;exports.useComposerLocked=hr;exports.useCustomMessage=ns;exports.useMessaging=Zt;exports.useMessagingLogger=$s;
|
|
3
|
-
//# sourceMappingURL=index-WEbnLVHC.cjs.map
|