@linktr.ee/messaging-react 4.6.0 → 4.6.1-rc-1788362229

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/index.cjs CHANGED
@@ -1,3 +1,3 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./rolldown-runtime-BocRIvOZ.cjs"),t=require("./AttachmentCard-BbsjzdLJ.cjs");let n=require("react");n=e.t(n,1);let r=require("@linktr.ee/messaging-core"),i=require("stream-chat"),a=require("stream-chat-react"),o=require("react/jsx-runtime"),s=require("@linktr.ee/messaging-taxonomy"),c=require("classnames");c=e.t(c,1);let l=require("@phosphor-icons/react"),u=require("stream-chat-react/experimental");var d={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)},f=e=>({debug:e?.debug??d.debug,info:e?.info??d.info,warn:e?.warn??d.warn,error:e?.error??d.error}),p=(0,n.createContext)(d),m=({logger:e,children:t})=>{let r=(0,n.useMemo)(()=>f(e),[e]);return(0,o.jsx)(p.Provider,{value:r,children:t})},h=()=>(0,n.useContext)(p),g=(0,n.createContext)({service:null,client:null,isConnected:!1,isLoading:!1,error:null,capabilities:{},refreshConnection:async()=>{},debug:!1}),_=()=>(0,n.useContext)(g),v=({children:e,user:t,serviceConfig:s,apiKey:c,capabilities:l={},debug:u=!1,client:d,logger:p})=>{let h=(0,n.useCallback)((e,...t)=>{u&&console.log(`🔥 [MessagingProvider] ${e}`,...t)},[u]);h(`🔄 RENDER START`,{userId:t?.id,apiKey:c?.substring(0,8)+`...`,serviceConfig:!!s,capabilities:Object.keys(l)});let[_,v]=(0,n.useState)(null),[y,b]=(0,n.useState)(null),[x,S]=(0,n.useState)(!1),[C,w]=(0,n.useState)(!1),[T,E]=(0,n.useState)(null),D=(0,n.useRef)(!1),O=(0,n.useRef)(null),k=(0,n.useRef)(s);k.current=s;let A=(0,n.useRef)(u);A.current=u;let j=(0,n.useRef)(p);j.current=p;let M=(0,n.useRef)({userId:t?.id,apiKey:c,serviceConfig:s,capabilities:l}),N=(0,n.useRef)(0);N.current++,h(`📊 RENDER INFO`,{renderCount:N.current,currentProps:{userId:t?.id,apiKey:c?.substring(0,8)+`...`},propChanges:{userChanged:M.current.userId!==t?.id,apiKeyChanged:M.current.apiKey!==c,serviceConfigChanged:M.current.serviceConfig!==s,capabilitiesChanged:M.current.capabilities!==l}}),M.current={userId:t?.id,apiKey:c,serviceConfig:s,capabilities:l};let P=(0,n.useRef)(null);!d&&c&&P.current?.apiKey!==c&&(P.current={apiKey:c,client:new i.StreamChat(c)});let F=d||(c?P.current?.client??null:null);(0,n.useEffect)(()=>{let e=N.current,t=k.current;if(d){O.current=null,v(null),b(null),S(!1),E(null),w(!1);return}if(!c||!F||!t){h(`⚠️ SERVICE INIT SKIPPED`,{renderCount:e,reason:`Missing apiKey, client, or serviceConfig`});return}h(`🚀 CREATING SERVICE`,{renderCount:e,apiKey:c?.substring(0,8)+`...`});let n=new r.StreamChatService({...t,apiKey:c,debug:A.current,client:F,...t.logger||!j.current?{}:{logger:f(j.current)}});O.current=n,v(n),h(`✅ SERVICE SET`,{renderCount:e,serviceInstance:!!n})},[c,F,d]);let I=(0,n.useRef)(null);(0,n.useEffect)(()=>{if(h(`🔗 USER CONNECTION EFFECT TRIGGERED`,{hasService:!!_,hasUser:!!t,userId:t?.id,isConnecting:D.current,isConnected:x,dependencies:{service:!!_,userId:t?.id}}),!d){if(!_||!t){h(`⚠️ USER CONNECTION SKIPPED`,`Missing service or user`);return}if(D.current){h(`⚠️ USER CONNECTION SKIPPED`,`Already connecting`);return}if(I.current?.serviceId===_&&I.current?.userId===t.id){h(`⚠️ USER CONNECTION SKIPPED`,`Already connected this user with this service`);return}(async()=>{h(`🚀 STARTING USER CONNECTION`,{userId:t.id}),D.current=!0,w(!0),E(null);try{h(`📞 CALLING SERVICE.CONNECTUSER`,{userId:t.id});let e=await _.connectUser(t);b(e),S(!0),I.current={serviceId:_,userId:t.id},h(`✅ USER CONNECTION SUCCESS`,{userId:t.id,clientId:e.userID})}catch(e){let n=e instanceof Error?e.message:`Connection failed`;E(n),h(`❌ USER CONNECTION ERROR`,{userId:t.id,error:n})}finally{w(!1),D.current=!1,h(`🔄 USER CONNECTION FINISHED`,{userId:t.id,isConnected:x})}})()}},[_,t,h,x,d]),(0,n.useEffect)(()=>{let e=F;return()=>{e&&(I.current=null,O.current?.disconnectUser().catch(console.error))}},[F]);let L=(0,n.useCallback)(async()=>{if(h(`🔄 REFRESH CONNECTION CALLED`,{hasService:!!_,hasUser:!!t}),!d){if(!_||!t){h(`⚠️ REFRESH CONNECTION SKIPPED`,`Missing service or user`);return}h(`🚀 STARTING CONNECTION REFRESH`,{userId:t.id}),w(!0);try{h(`🔌 DISCONNECTING FOR REFRESH`),await _.disconnectUser(),h(`📞 RECONNECTING FOR REFRESH`);let e=await _.connectUser(t);b(e),S(!0),E(null),h(`✅ CONNECTION REFRESH SUCCESS`,{userId:t.id})}catch(e){let n=e instanceof Error?e.message:`Refresh failed`;E(n),h(`❌ CONNECTION REFRESH ERROR`,{userId:t.id,error:n})}finally{w(!1),h(`🔄 CONNECTION REFRESH FINISHED`,{userId:t.id})}}},[_,t,h,d]),R=n.default.useMemo(()=>(h(`💫 CONTEXT VALUE MEMOIZATION`,{hasService:!!_,hasClient:!!y,isConnected:x,isLoading:C,hasError:!!T,capabilitiesKeys:Object.keys(l)}),{service:d?null:_,client:d??y,isConnected:d?!0:x,isLoading:!d&&C,error:d?null:T,capabilities:l,refreshConnection:L,debug:u}),[_,y,d,x,C,T,l,L,u,h]);return h(`🔄 RENDER END`,{renderCount:N.current,willRenderChat:!!F,contextValueReady:!!R}),(0,o.jsx)(m,{logger:p,children:(0,o.jsx)(g.Provider,{value:R,children:F?(0,o.jsx)(a.Chat,{client:F,customClasses:{channelList:`str-chat__channel-list str-chat__channel-list-react bg-transparent lg:border-r-2 border-r-0 border-[#0000000A]`},children:e}):e})})},y=()=>_(),b=e=>{let[t,r]=(0,n.useState)(!!e?.state?.membership?.pinned_at);return(0,n.useEffect)(()=>{if(!e){r(!1);return}r(!!e.state.membership?.pinned_at);let t=t=>{r(t?.member?!!t.member.pinned_at:!!e.state.membership?.pinned_at)};return e.on(`member.updated`,t),()=>{e.off(`member.updated`,t)}},[e]),t};function x(e,t,n){let r=Object.values(e||{});if((0,s.isOfficialChannel)(n)){let e=r.find(e=>e.user?.id===s.OFFICIAL_SENDER_USER_ID);if(e)return e}return r.find(e=>e.user?.id&&e.user.id!==t)}var S=/^[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 C(e){return S.test(e.trim())}function w(e,t){let n=e?.trim();return!n||t&&n===t||t&&n===`Follower ${t}`?!1:!C(n)}function T(e){return w(e?.name,e?.id)?e.name.trim():w(e?.username,e?.id)?e.username.trim():`Unknown member`}var E=[{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 D(e){let t=0;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);t=(t<<5)-t+r,t&=t}return Math.abs(t)}function O(e){return E[D(e)%E.length]}function k(e){return O(e).emoji}function A(e){return O(e).bgColor}var j=({id:e,image:t,size:n=40,className:r,starred:i=!1,shape:a=`squircle`,dmAgentEnabled:s=!1})=>{let u=k(e),d=A(e),f=n<32?Math.round(n*.45):n<56?14:n<120?18:36,p=n>=40?2:1,m=a===`circle`?{borderRadius:`50%`}:{borderRadius:`1rem`},h=(0,o.jsx)(`div`,{"data-testid":`avatar-inner`,className:`h-full w-full overflow-hidden`,style:m,children:t?(0,o.jsx)(`img`,{src:t,alt:``,className:`h-full w-full object-cover`}):(0,o.jsx)(`div`,{"aria-hidden":`true`,"data-testid":`avatar-fallback`,className:(0,c.default)(`avatar-fallback flex h-full w-full items-center justify-center font-semibold select-none transition-colors`),style:{fontSize:f,lineHeight:1},children:u})});return(0,o.jsxs)(`div`,{"data-testid":`avatar`,className:(0,c.default)(`relative flex-shrink-0`,r),style:{"--str-chat__avatar-size":`${n}px`,width:`${n}px`,height:`${n}px`,backgroundColor:t?void 0:d,...m},children:[i&&(0,o.jsx)(`div`,{"aria-hidden":`true`,"data-testid":`avatar-star`,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:(0,o.jsx)(l.StarIcon,{className:`size-3 text-yellow-600`,weight:`duotone`})}),(0,o.jsx)(`div`,{"data-testid":`avatar-ring`,className:(0,c.default)(`h-full w-full`,`bg-transparent`),style:{...m,...s&&{borderWidth:`${p}px`,borderStyle:`solid`,borderColor:`var(--AI-Gradient, #7F22FE)`,boxShadow:`inset 0 1px 2px 0 rgba(255, 255, 255, 0.5)`}},children:h})]})},M=`https://linktr.ee/s/about/trust-center/report`,N=({channel:e,participant:t,showBlockParticipant:r=!0,enabled:i=!0,onLeaveConversation:a,onBlockParticipant:o,onDeleteConversationClick:s,onBlockParticipantClick:c,onReportParticipantClick:l,onActionComplete:u,logLabel:d=`useChannelModerationActions`})=>{let{service:f,debug:p}=_(),m=t?.user?.id,h=!!(i&&r&&f&&m),[g,v]=(0,n.useState)(!1),[y,b]=(0,n.useState)(null),[x,S]=(0,n.useState)(!1),[C,w]=(0,n.useState)(!1),T=h&&(y?.participantId!==m||y?.service!==f);return(0,n.useEffect)(()=>{if(!h||!f||!m){v(!1),b(null);return}let e=!1;return(async()=>{try{let t=await f.getBlockedUsers();if(e)return;v(t.some(e=>e.blocked_user_id===m))}catch(t){e||console.error(`[${d}] Failed to check blocked status:`,t)}finally{e||b({participantId:m,service:f})}})(),()=>{e=!0}},[h,f,m,d]),{isParticipantBlocked:g,isCheckingBlockedStatus:T,isLeaving:x,isUpdatingBlockStatus:C,handleLeaveConversation:async()=>{if(!x){s?.(),p&&console.log(`[${d}] Leave conversation`,e.cid),S(!0);try{let t=e._client?.userID??null;await e.hide(t,!1),a&&await a(e),u?.()}catch(e){console.error(`[${d}] Failed to leave conversation`,e)}finally{S(!1)}}},handleBlockUser:async()=>{if(!(C||!f)){c?.(),p&&console.log(`[${d}] Block member`,t?.user?.id),w(!0);try{await f.blockUser(t?.user?.id),o&&await o(t?.user?.id),u?.()}catch(e){console.error(`[${d}] Failed to block member`,e)}finally{w(!1)}}},handleUnblockUser:async()=>{if(!(C||!f)){c?.(),p&&console.log(`[${d}] Unblock member`,t?.user?.id),w(!0);try{await f.unBlockUser(t?.user?.id),o&&await o(t?.user?.id),u?.()}catch(e){console.error(`[${d}] Failed to unblock member`,e)}finally{w(!1)}}},handleReportUser:()=>{l?.(),u?.(),window.open(M,`_blank`,`noopener,noreferrer`)}}},P=({variant:e=`default`,className:t,children:n,...r})=>(0,o.jsx)(`button`,{type:`button`,className:(0,c.default)(`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`,e===`danger`?`text-danger hover:bg-danger/50`:`text-charcoal hover:bg-sand`,t),...r,children:n}),F=({channel:e,participant:t,showDeleteConversation:r=!0,showBlockParticipant:i=!0,showReportParticipant:a=!0,onLeaveConversation:s,onBlockParticipant:u,onDeleteConversationClick:d,onBlockParticipantClick:f,onReportParticipantClick:p,customChannelActions:m,triggerClassName:h})=>{let[g,_]=(0,n.useState)(!1),v=(0,n.useRef)(null),y=(0,n.useId)(),{isParticipantBlocked:b,isCheckingBlockedStatus:x,isLeaving:S,isUpdatingBlockStatus:C,handleLeaveConversation:w,handleBlockUser:T,handleUnblockUser:E,handleReportUser:D}=N({channel:e,participant:t,showBlockParticipant:i,enabled:g,onLeaveConversation:s,onBlockParticipant:u,onDeleteConversationClick:d,onBlockParticipantClick:f,onReportParticipantClick:p,onActionComplete:(0,n.useCallback)(()=>_(!1),[]),logLabel:`ChannelActionsMenu`});return(0,n.useEffect)(()=>{if(!g)return;let e=e=>{v.current&&!v.current.contains(e.target)&&_(!1)},t=e=>{e.key===`Escape`&&_(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[g]),!t||!(r||i||a||m)?null:(0,o.jsxs)(`div`,{ref:v,className:`relative`,children:[(0,o.jsxs)(`button`,{className:h,type:`button`,"aria-haspopup":`true`,"aria-expanded":g,"aria-controls":g?y:void 0,onClick:()=>_(e=>!e),children:[(0,o.jsx)(l.DotsThreeIcon,{className:`size-5 text-black/90`}),(0,o.jsx)(`span`,{className:`sr-only`,children:`More options`})]}),g&&(0,o.jsx)(`div`,{id:y,"aria-label":`Conversation options`,className:(0,c.default)(`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:(0,o.jsxs)(`ul`,{className:`flex flex-col gap-1`,children:[r&&(0,o.jsx)(`li`,{children:(0,o.jsxs)(P,{onClick:w,disabled:S,"aria-busy":S,children:[S?(0,o.jsx)(l.SpinnerGapIcon,{className:`h-5 w-5 animate-spin`}):(0,o.jsx)(l.SignOutIcon,{className:`h-5 w-5`}),(0,o.jsx)(`span`,{children:`Delete Conversation`})]})}),i&&(0,o.jsx)(`li`,{children:x?(0,o.jsxs)(P,{disabled:!0,"aria-busy":!0,children:[(0,o.jsx)(l.SpinnerGapIcon,{className:`h-5 w-5 animate-spin`}),(0,o.jsx)(`span`,{children:`Block`})]}):b?(0,o.jsxs)(P,{onClick:E,disabled:C,"aria-busy":C,children:[C?(0,o.jsx)(l.SpinnerGapIcon,{className:`h-5 w-5 animate-spin`}):(0,o.jsx)(l.ProhibitInsetIcon,{className:`h-5 w-5`}),(0,o.jsx)(`span`,{children:`Unblock`})]}):(0,o.jsxs)(P,{onClick:T,disabled:C,"aria-busy":C,children:[C?(0,o.jsx)(l.SpinnerGapIcon,{className:`h-5 w-5 animate-spin`}):(0,o.jsx)(l.ProhibitInsetIcon,{className:`h-5 w-5`}),(0,o.jsx)(`span`,{children:`Block`})]})}),a&&(0,o.jsx)(`li`,{children:(0,o.jsxs)(P,{variant:`danger`,onClick:D,children:[(0,o.jsx)(l.FlagIcon,{className:`h-5 w-5`}),(0,o.jsx)(`span`,{children:`Report`})]})}),m]})})]})},I=`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`,L=`CUSTOMER_PAID`,R=e=>typeof e==`string`&&e.trim().replace(/[\s-]+/g,`_`).toUpperCase()===L,ee=({className:e,onBack:t,showBackButton:r,showStarButton:i=!1,onLeaveConversation:s,onBlockParticipant:u,showDeleteConversation:d=!0,showBlockParticipant:f=!0,showReportParticipant:p=!0,onDeleteConversationClick:m,onBlockParticipantClick:h,onReportParticipantClick:g,customChannelActions:_,renderChannelActions:v,showChannelInfo:y=!0,onParticipantNameClick:S})=>{let{channel:C}=(0,a.useChannelStateContext)(),{client:w}=(0,a.useChatContext)(),E=n.default.useMemo(()=>x(C.state?.members,w?.userID,C.type),[C.state?.members,w?.userID,C.type]),D=T(E?.user),O=E?.user?.image,k=b(C),A=R(C.data?.customer_tag)&&E?.is_follower===!0,M=A||k||!!S,N=async()=>{try{k?await C.unpin():await C.pin()}catch(e){console.error(`[ChannelHeaderRedesign] Failed to update pinned status:`,e)}},P=(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(j,{id:E?.user?.id||C.id||`unknown`,name:D,image:O,shape:`circle`,size:48,className:`-mb-2`}),(0,o.jsx)(`span`,{className:(0,c.default)(`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`,M?`pl-3 pr-2`:`px-3`),children:(0,o.jsxs)(`span`,{className:`flex max-w-full items-center justify-center`,children:[(0,o.jsx)(`span`,{className:`min-w-0 truncate text-sm font-bold leading-[1.43] tracking-[0.28px] text-black/90`,children:D}),M&&(0,o.jsxs)(`span`,{className:`ml-2 flex gap-1`,children:[A&&(0,o.jsx)(`span`,{"aria-label":`Paid customer`,className:`flex size-4 shrink-0 items-center justify-center rounded-full bg-[#34C759] text-white`,children:(0,o.jsx)(l.CurrencyDollarIcon,{className:`size-2.5`,weight:`bold`})}),k&&(0,o.jsx)(`span`,{className:`messaging-header-star-badge flex overflow-hidden`,children:(0,o.jsx)(`span`,{"aria-label":`Starred conversation`,className:`flex size-4 shrink-0 items-center justify-center rounded-full bg-[#FFD60A] text-white`,children:(0,o.jsx)(l.StarIcon,{className:`size-2.5`,weight:`fill`})})}),S&&(0,o.jsx)(l.CaretRightIcon,{"aria-hidden":`true`,className:`size-4 shrink-0 text-black/65`,weight:`bold`})]})]})})]});return(0,o.jsx)(`div`,{className:(0,c.default)(`@container bg-[linear-gradient(180deg,#FBFAF9_0%,rgba(251,250,249,0.92)_58%,rgba(251,250,249,0)_100%)]`,e),children:(0,o.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:[(0,o.jsx)(`div`,{className:`flex items-start`,children:r&&(0,o.jsx)(`button`,{className:(0,c.default)(I,`messaging-channel-view-back-button-mobile messaging-channel-view-back-button-desktop`),onClick:t||(()=>{}),type:`button`,"aria-label":`Back to conversations`,children:(0,o.jsx)(l.ArrowLeftIcon,{className:`size-5 text-black/90`})})}),(0,o.jsx)(`div`,{className:`flex min-w-0 justify-center`,"data-dd-privacy":`mask`,children:S?(0,o.jsx)(`button`,{type:`button`,onClick:S,"aria-label":`View details for ${D}`,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:P}):(0,o.jsx)(`div`,{className:`flex min-w-0 max-w-full flex-col items-center px-2`,children:P})}),(0,o.jsxs)(`div`,{className:`flex items-start justify-end gap-2`,children:[i&&(0,o.jsx)(`button`,{className:I,onClick:N,type:`button`,"aria-pressed":k,"aria-label":k?`Unstar conversation`:`Star conversation`,children:(0,o.jsx)(l.StarIcon,{className:(0,c.default)(`size-5`,{"text-[#FFD60A]":k,"text-black/90":!k}),weight:k?`fill`:`regular`})}),y&&(v===void 0?(0,o.jsx)(F,{channel:C,participant:E,showDeleteConversation:d,showBlockParticipant:f,showReportParticipant:p,onLeaveConversation:s,onBlockParticipant:u,onDeleteConversationClick:m,onBlockParticipantClick:h,onReportParticipantClick:g,customChannelActions:_,triggerClassName:I}):v)]})]})})},te=e=>(0,o.jsx)(a.DateSeparator,{...e,position:`center`});function z(e){return e?.trim().toLowerCase().split(/[-_]/)[0]||void 0}function B({message:e,viewerLanguage:t}){let n=e?.text,r=z(t);return r?e?.i18n?.[`${r}_text`]??n:n}var V=/^([a-z][a-z0-9+.-]*):/i,ne=new Set([`http`,`https`,`mailto`,`tel`,`sms`]);function H(e){if(typeof e!=`string`)return;let t=e.trim();if(t===``)return;let n=V.exec(t);if(n){let e=n[1].toLowerCase();return ne.has(e)?t:void 0}return t.startsWith(`//`)||t.startsWith(`/`)?t:`https://${t}`}var re={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`}},ie=({variant:e,cta:t,fullWidth:n=!0,standalone:r=!1})=>{let i=t.variant??`primary`,a=(0,c.default)(`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`,!r&&`mt-2`,re[e][i]),s=n?t.label:(0,o.jsx)(`span`,{className:`min-w-0 truncate`,children:t.label}),l=H(t.href);return l?(0,o.jsx)(`a`,{href:l,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>{e.stopPropagation(),t.onClick?.()},className:`${a} no-underline`,children:s}):(0,o.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),t.onClick?.()},className:a,children:s})},U={dark:`text-white`,light:`text-black/90`},W=`text-white/30`,ae={dark:`text-white/55`,light:`text-black/55`},oe={dark:`bg-white/25`,light:`bg-black/15`},G=({variant:e,ctaSurface:t,chinTextColor:n,title:r,placeholderTitle:i,description:a,descriptionLines:s=1,url:l,appIcon:u,cta:d,trailingAction:f,isLoading:p=!1})=>{let m=e===`dark`,h=r??(m?i:void 0)??``,g=h.trim()!==``,_=a!=null&&a.trim()!==``,v=typeof l==`string`?l.trim():``,y=v!==``,b=d!=null;if(!p&&!g&&!_&&!y&&!b)return null;let x=(0,c.default)(`line-clamp-2 text-[14px] font-medium leading-5 tracking-[0.28px]`,n==null&&(m&&!r?W:U[e])),S=(0,c.default)(`truncate text-[12px] leading-4 tracking-[0.24px]`,n==null&&ae[e]),C=(0,c.default)(`text-[12px] leading-4 tracking-[0.24px]`,s<=1&&`truncate`,n==null&&ae[e]);if(p){let t=(0,c.default)(`animate-pulse rounded`,oe[e]);return(0,o.jsx)(`div`,{className:`shrink-0 px-4 py-3`,children:(0,o.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-[2px]`,children:[(0,o.jsx)(`div`,{"data-testid":`card-body-skeleton-bar`,className:(0,c.default)(`h-5 w-3/4`,t),"aria-hidden":!0}),(0,o.jsx)(`div`,{"data-testid":`card-body-skeleton-bar`,className:(0,c.default)(`h-4 w-1/2`,t),"aria-hidden":!0})]})})}let w=n?{color:n}:void 0,T=s>1?{...w,display:`-webkit-box`,WebkitBoxOrient:`vertical`,WebkitLineClamp:s,overflow:`hidden`}:w;return(0,o.jsxs)(`div`,{className:`shrink-0 px-4 py-3`,children:[(0,o.jsxs)(`div`,{className:`flex items-end gap-3`,children:[(0,o.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[g&&(0,o.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[u?(0,o.jsx)(`span`,{className:`shrink-0`,children:u}):null,(0,o.jsx)(`p`,{className:(0,c.default)(`min-w-0`,x),style:w,children:h})]}),_&&(0,o.jsx)(`p`,{className:C,style:T,children:a}),!b&&y&&(0,o.jsx)(`p`,{className:S,style:w,"data-testid":`link-attachment-url`,children:v})]}),f&&(0,o.jsx)(`div`,{className:`shrink-0`,children:f})]}),d&&(0,o.jsx)(ie,{variant:t??e,cta:d})]})},se=`Loading link preview`,ce=(0,c.default)(`relative w-[var(--lt-msg-card-width,290px)] max-w-full select-none overflow-hidden`,`rounded-[20px]`),K=`flex h-[250px] flex-col`,q=({variant:e,children:t,href:n,onClick:r,ariaLabel:i,rootRef:a,topRight:s,bgClassName:l,accentHex:u,fixedHeight:d=!1,busy:f=!1,"data-testid":p=`link-card`})=>{let m=(0,c.default)(`messaging-link-card`,ce,d?K:`block`,l??(e===`dark`?`bg-[#1e2330]`:`bg-[#f1f0ee]`),n!=null||r!=null?`cursor-pointer no-underline focus-ring`:null),h=f?{role:`status`,"aria-busy":!0,"aria-label":se}:void 0,g=u?{"--accent":u}:void 0,_=s?(0,o.jsx)(`div`,{"data-testid":`card-shell-top-right`,className:`pointer-events-auto absolute right-3 top-3 z-10`,children:s}):null;return n?(0,o.jsxs)(`a`,{ref:a,href:n,target:`_blank`,rel:`noopener noreferrer`,onClick:r,"data-testid":p,"data-variant":e,className:m,style:g,...h,children:[t,_]}):r?(0,o.jsxs)(`button`,{ref:a,type:`button`,onClick:r,"aria-label":i,"data-testid":p,"data-variant":e,className:(0,c.default)(m,`text-left`),style:g,...h,children:[t,_]}):(0,o.jsxs)(`div`,{ref:a,"data-testid":p,"data-variant":e,className:m,style:g,...h,children:[t,_]})},J={dark:`bg-white/10`,light:`bg-black/5`},le={dark:`size-16 text-white/25`,light:`size-16 text-black/25`},Y=(e,n)=>!!n&&!!e&&t.i(e)===`audio`,ue=(e,n)=>{if(!n||!e)return!1;let r=t.i(e);return r===`video`||r===`audio`},de=`bg-[#F2F3F4]`,X=({variant:e,thumbnailUrl:n,sourceUrl:r,title:i,mimeType:a=`image/*`,topLeft:s,topRight:l,isLoading:u=!1,onImageError:d})=>{let f=t.i(a),p=!!r&&f===`video`,m=t.s(n);return!u&&Y(a,r)?(0,o.jsx)(`div`,{className:`p-3`,children:(0,o.jsx)(`audio`,{...t.a,"data-testid":`card-thumbnail-audio`,src:r,controls:!0,preload:`metadata`,className:`block w-full`,children:(0,o.jsx)(`track`,{kind:`captions`})})}):(0,o.jsxs)(`div`,{"data-testid":`card-thumbnail-hero`,className:(0,c.default)(`relative min-h-0 w-full flex-1 overflow-hidden`,p&&`bg-black`),children:[u?(0,o.jsx)(`div`,{"data-testid":`card-thumbnail-skeleton`,className:(0,c.default)(`h-full w-full animate-pulse`,J[e]),"aria-hidden":!0}):p?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`video`,{"data-testid":`card-thumbnail-video`,src:r,poster:m,controls:!0,playsInline:!0,preload:`metadata`,className:`absolute inset-0 h-full w-full object-contain`,children:(0,o.jsx)(`track`,{kind:`captions`})}),m&&d?(0,o.jsx)(`img`,{src:m,alt:``,"aria-hidden":!0,onError:d,className:`hidden`}):null]}):n?(0,o.jsx)(`img`,{src:m??n,alt:i??``,draggable:!1,loading:`lazy`,decoding:`async`,onError:d,className:`absolute inset-0 h-full w-full object-cover`}):(0,o.jsx)(`div`,{"data-testid":`card-thumbnail-placeholder`,className:(0,c.default)(`flex h-full w-full items-center justify-center`,J[e]),children:t.n(a,{className:le[e],weight:`regular`})}),s?(0,o.jsx)(`div`,{"data-testid":`card-thumbnail-top-left`,className:`pointer-events-auto absolute left-3 top-3 z-10`,children:s}):null,l?(0,o.jsx)(`div`,{"data-testid":`card-thumbnail-top-right`,className:`pointer-events-auto absolute right-3 top-3 z-10`,children:l}):null]})},Z=/^#?(?:[0-9a-f]{3}|[0-9a-f]{6})$/i;function fe(e){let t=e.trim();return t.startsWith(`#`)?t:`#${t}`}var pe=`#FFFFFF`,me=`#040403`,he={dark:pe,light:me};function ge({variant:e,accentColor:t,status:r=`ready`,layout:i=`featured`,thumbnailUrl:a,mimeType:o,sourceUrl:s}){let[c,l]=n.default.useState(!1);n.default.useEffect(()=>{l(!1)},[a]);let u=n.default.useCallback(()=>{l(!0)},[]),d=Y(o,s),f=i===`featured`&&a&&!d&&!c&&r===`ready`&&t!=null&&Z.test(t.trim())?fe(t):void 0,p=d?me:he[e];return{thumbnailUrl:c?void 0:a,accentHex:f,chinTextColor:p,surface:d?`light`:e,isLoading:r===`loading`,onImageError:u}}var _e=`flex size-6 items-center justify-center rounded-full bg-[#121110] text-white transition-colors duration-150 hover:bg-[#2a2928] focus-ring`,ve=`relative before:absolute before:-inset-[10px] before:content-['']`,ye=({title:e,placeholderTitle:t,description:n,descriptionLines:r,url:i,mimeType:a,thumbnailUrl:s,sourceUrl:u,layout:d=`featured`,appIcon:f,cta:p,accentColor:m,status:h=`ready`,onDismiss:g,onEditClick:_,dismissLabel:v=`Dismiss attachment`})=>{let y=d===`classic`,b=Y(a,u),x=ge({variant:`dark`,accentColor:m,status:h,layout:d,thumbnailUrl:s,mimeType:a,sourceUrl:u}),S=g?(0,o.jsx)(`button`,{type:`button`,onClick:g,"aria-label":v,className:(0,c.default)(_e,!b&&ve),children:(0,o.jsx)(l.XIcon,{className:`size-3`,weight:`bold`})}):void 0,C=_?(0,o.jsx)(`button`,{type:`button`,onClick:_,"aria-label":`Edit attachment`,className:`flex size-10 items-center justify-center rounded-full bg-white/10 text-white hover:bg-white/15`,children:(0,o.jsx)(l.PencilSimpleIcon,{className:`size-5`,weight:`regular`})}):void 0;return b&&!x.isLoading?(0,o.jsx)(q,{variant:`dark`,bgClassName:de,children:(0,o.jsxs)(`div`,{className:`flex items-center gap-2 pr-3`,children:[(0,o.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,o.jsx)(X,{variant:`dark`,sourceUrl:u,title:e,mimeType:a})}),S&&(0,o.jsx)(`div`,{className:`shrink-0`,children:S})]})}):(0,o.jsxs)(q,{variant:`dark`,fixedHeight:!y,accentHex:x.accentHex,busy:x.isLoading,topRight:y?S:void 0,children:[!y&&(0,o.jsx)(X,{variant:`dark`,thumbnailUrl:x.thumbnailUrl,sourceUrl:u,title:e,mimeType:a,topRight:S,isLoading:x.isLoading,onImageError:x.onImageError}),(0,o.jsx)(G,{chinTextColor:x.chinTextColor,variant:`dark`,ctaSurface:x.surface,title:e,placeholderTitle:t,description:n,descriptionLines:r,url:i,appIcon:f,cta:p,trailingAction:C,isLoading:x.isLoading})]})},be=({accentHex:e,side:t,visible:n,children:r})=>n?(0,o.jsxs)(`div`,{className:`relative isolate w-fit`,children:[r,(0,o.jsx)(`span`,{"aria-hidden":!0,"data-testid":`link-card-tail`,"data-variant":t===`sender`?`dark`:`light`,style:e?{"--accent":e}:void 0,className:(0,c.default)(`messaging-link-card-tail`,t===`receiver`&&`messaging-link-card-tail--received`)})]}):(0,o.jsx)(o.Fragment,{children:r}),xe={Composer:ye,Sent:({title:e,placeholderTitle:t,description:n,descriptionLines:r,url:i,mimeType:a,thumbnailUrl:s,sourceUrl:c,layout:l=`featured`,appIcon:u,cta:d,accentColor:f,status:p=`ready`,onClick:m,groupPosition:h=`single`})=>{let g=ue(a,c),_=H(i),v=d==null&&_!=null&&!g?_:void 0,y=d==null&&!g&&v!=null?m:void 0,b=p!==`loading`&&Y(a,c),x=ge({variant:`dark`,accentColor:f,status:p,layout:l,thumbnailUrl:s,mimeType:a,sourceUrl:c});return(0,o.jsx)(be,{accentHex:x.accentHex,side:`sender`,visible:!b&&(h===`single`||h===`end`),children:(0,o.jsxs)(q,{variant:`dark`,href:v,onClick:y,fixedHeight:l===`featured`&&!b,accentHex:x.accentHex,busy:x.isLoading,bgClassName:b?de:void 0,children:[l===`featured`&&(0,o.jsx)(X,{variant:`dark`,thumbnailUrl:x.thumbnailUrl,sourceUrl:c,title:e,mimeType:a,isLoading:x.isLoading,onImageError:x.onImageError}),(0,o.jsx)(G,{chinTextColor:x.chinTextColor,variant:`dark`,ctaSurface:x.surface,title:e,placeholderTitle:t,description:n,descriptionLines:r,url:i,appIcon:u,cta:d,isLoading:x.isLoading})]})})},Received:({title:e,description:t,descriptionLines:n,url:r,mimeType:i,thumbnailUrl:a,sourceUrl:s,layout:c=`featured`,appIcon:l,cta:u,accentColor:d,status:f=`ready`,onClick:p,groupPosition:m=`single`})=>{let h=ue(i,s),g=H(r),_=u==null&&g!=null&&!h?g:void 0,v=u==null&&!h?p:void 0,y=f!==`loading`&&Y(i,s)?de:void 0,b=u&&p?{...u,onClick:()=>{p(),u.onClick?.()}}:u,x=ge({variant:`light`,accentColor:d,status:f,layout:c,thumbnailUrl:a,mimeType:i,sourceUrl:s});return(0,o.jsx)(be,{accentHex:x.accentHex,side:`receiver`,visible:y==null&&(m===`single`||m===`end`),children:(0,o.jsxs)(q,{variant:`light`,href:_,onClick:v,ariaLabel:e??`Open attachment preview`,fixedHeight:c===`featured`&&y==null,accentHex:x.accentHex,busy:x.isLoading,bgClassName:y,"data-testid":`link-attachment`,children:[c===`featured`&&(0,o.jsx)(X,{variant:`light`,thumbnailUrl:x.thumbnailUrl,sourceUrl:s,title:e,mimeType:i,isLoading:x.isLoading,onImageError:x.onImageError}),(0,o.jsx)(G,{chinTextColor:x.chinTextColor,variant:`light`,ctaSurface:x.surface,title:e,description:t,descriptionLines:n,url:r,appIcon:l,cta:b,isLoading:x.isLoading})]})})}};function Se(e){return e.type===`link`||!!e.og_scrape_url?.trim()}var Ce={LockedAttachment:{isUnlocking:()=>!1}},we=(0,n.createContext)({}),Te=we.Provider;function Ee(e){return(0,n.useContext)(we)[e]??Ce[e]}var De=n.default.lazy(()=>Promise.resolve().then(()=>require("./Card-Ds1FMcUj.cjs"))),Oe=n.default.lazy(()=>Promise.resolve().then(()=>require("./Card-BS6Fza2a.cjs"))),ke=()=>(0,o.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}),Ae=e=>(0,o.jsx)(n.Suspense,{fallback:(0,o.jsx)(ke,{}),children:e.contentType===`text`?(0,o.jsx)(De,{...e}):(0,o.jsx)(Oe,{...e})}),je=({size:e=15})=>(0,o.jsx)(`svg`,{width:e,height:e,viewBox:`0 0 15 15`,fill:`none`,"aria-hidden":`true`,children:(0,o.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})}),Me=e=>e.metadata?.custom_type===s.MESSAGE_CUSTOM_TYPE.PAID,Ne=e=>e.metadata?.custom_type===s.MESSAGE_CUSTOM_TYPE.CHATBOT,Pe=e=>e.metadata?.custom_type===s.MESSAGE_CUSTOM_TYPE.ATTACHMENT,Fe=e=>Pe(e)&&e.metadata?.attachment_content_type===`text`,Ie=e=>Pe(e)&&e.metadata?.attachment_content_type!==`text`,Le=e=>Me(e)&&!!e.metadata?.amount_text,Re=({message:e,isMyMessage:t=!1,hasAttachment:n=!1})=>{let r=Me(e),i=Ne(e);if(!r&&!i)return null;if(r){let t=e.metadata?.amount_text;return t?(0,o.jsxs)(`div`,{className:`message-tag--paid inline-flex items-center gap-1 text-[12px] font-medium leading-[2] text-[#016630]`,children:[(0,o.jsx)(l.GiftIcon,{size:12}),(0,o.jsxs)(`span`,{children:[`Delivered with `,t,` message`]})]}):null}let a=t&&n,s=a?`Sent with AI`:`Sent by AI Assistant`,c=a?`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=(0,o.jsx)(`span`,{className:`text-left`,children:s}),d=(0,o.jsx)(`span`,{className:`inline-flex items-center leading-none`,children:(0,o.jsx)(je,{size:a?12:15})});return(0,o.jsx)(`div`,{className:`inline-flex items-center text-[10px] font-normal leading-4 tracking-[0.2px] ${c}`,"data-testid":`message-chatbot-indicator`,children:t&&!a?(0,o.jsxs)(o.Fragment,{children:[u,d]}):(0,o.jsxs)(o.Fragment,{children:[d,u]})})},ze=`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%`,Be={me:`var(--str-chat__own-message-bubble-background-color, #1e2330)`,other:`var(--str-chat__message-bubble-background-color, #f1f0ee)`},Ve=({side:e})=>(0,o.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:Be[e],WebkitMask:ze,mask:ze}}),He=(0,n.createContext)(void 0),Ue=e=>{let t=e.metadata?.outbound_id;return typeof t==`string`?t:void 0},We=(e,t)=>{if(!t||!e?.length)return;let n=new Set,r;for(let i of e){let e=Ue(i);if(!e||n.has(e))continue;n.add(e);let a=t(e);a&&(r??={},r[e]={id:a.id,...a.name===void 0?{}:{name:a.name}})}return r},Ge=(e,t)=>{if(e===t)return!0;if(!e||!t)return!1;let n=Object.keys(e),r=Object.keys(t);return n.length===r.length&&n.every(n=>e[n].id===t[n]?.id&&e[n].name===t[n]?.name)},Ke=(e,t)=>{let r=We(e,t),[i,a]=(0,n.useState)(r);return Ge(i,r)?i:(a(r),r)},qe=e=>e.metadata?.custom_type===s.MESSAGE_CUSTOM_TYPE.TIP,Je=({message:e})=>{let t=e.metadata?.amount_text;return t?(0,o.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:[(0,o.jsx)(`span`,{className:`flex h-5 items-center text-[20px] leading-none`,"aria-hidden":`true`,children:`🎁`}),(0,o.jsxs)(`span`,{className:`text-[14px] font-bold leading-[1.43] tracking-[0.28px] text-[rgba(4,4,3,0.9)]`,children:[t,` tip!`]})]}):null},Ye=()=>{let{message:e}=(0,a.useMessageContext)(`SentMessageDeliveryStatus`),{messages:t}=(0,a.useChannelStateContext)(`SentMessageDeliveryStatus`),n=(()=>{if(t)for(let e=t.length-1;e>=0;--e){let n=t[e];if(n.type!==`system`&&n.type!==`ephemeral`&&n.type!==`deleted`)return n.id}})();return e.id===n},Xe=()=>Ye()?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(l.ChecksIcon,{weight:`bold`,"aria-hidden":`true`}),(0,o.jsx)(`span`,{"data-testid":`sent-message-delivery-status`,children:`Delivered`})]}):null,Ze=()=>Ye()?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(l.CircleNotchIcon,{className:`sent-message-status__spinner animate-spin`,weight:`bold`,"aria-hidden":`true`}),(0,o.jsx)(`span`,{"data-testid":`sent-message-sending-status`,children:`Sending`})]}):null,Qe=({outbound:e,onOutboundClick:t})=>{let n=e.name||`Broadcast`,r=(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`span`,{className:`sent-message-outbound-badge`,"aria-hidden":`true`,children:(0,o.jsx)(l.MegaphoneIcon,{weight:`fill`})}),(0,o.jsx)(`span`,{className:(0,c.default)(`sent-message-outbound-name`,{"underline [text-decoration-skip-ink:auto]":!!t}),"data-testid":`sent-message-outbound-status`,children:n})]});return t?(0,o.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},$e=()=>(0,o.jsxs)(`span`,{className:`str-chat__message-status sent-message-status--failed`,children:[(0,o.jsx)(l.WarningCircleIcon,{weight:`bold`,"aria-hidden":`true`}),(0,o.jsx)(`span`,{"data-testid":`sent-message-failed-status`,children:`Failed to send`})]}),et=({onOutboundClick:e,resolvedOutbound:t})=>{let{isMyMessage:n,message:r,threadList:i}=(0,a.useMessageContext)(`SentMessageDeliveryStatus`),s=n(),c=Ye();if(i)return null;if(r.status===`failed`&&s&&r.type!==`error`)return(0,o.jsx)($e,{});if(!s)return null;let l=r.metadata?.outbound_id,u=r.status!==`sending`&&r.status!==`failed`&&l&&t?(0,o.jsx)(Qe,{outbound:t,onOutboundClick:e}):null,d=Le(r)?null:(0,o.jsx)(a.MessageStatus,{MessageSentStatus:Xe,MessageDeliveredStatus:Xe,MessageReadStatus:Xe,MessageSendingStatus:qe(r)?Xe:Ze});return u?(0,o.jsxs)(`span`,{className:`sent-message-status-row`,children:[d,d&&c&&(0,o.jsx)(`span`,{className:`sent-message-outbound-separator`,"aria-hidden":`true`,children:`•`}),u]}):d},tt={dark:`bg-[#1e2330]`,light:`bg-[#f2f1ef]`},nt={dark:`text-white`,light:`text-[#000000]`},rt={dark:`border-white/[0.08]`,light:`border-black/[0.08]`},it=e=>e===`dark`?`sender`:`receiver`,at={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]`}},ot=({variant:e,text:t,bordered:n=!0,groupPosition:r=`single`,widthClassName:i=`w-[280px]`,paddingClassName:a=`px-2 py-2`,radiusClassName:s,className:l,children:u,"data-testid":d})=>{let f=t!=null&&t!==``,p=s??at[it(e)][r];return(0,o.jsxs)(`div`,{"data-testid":d,"data-group-position":r,className:(0,c.default)(`relative`,i,`overflow-hidden`,a,f&&`pb-0`,p,tt[e],nt[e],n&&`border`,n&&rt[e],l),children:[u,f?(0,o.jsx)(`p`,{className:(0,c.default)(`whitespace-pre-wrap break-words leading-snug hyphens-manual`,`pb-2 pt-2`,`px-2`),children:t}):null]})},st=e=>e===`received`?`light`:`dark`,ct=({firstOfGroup:e,endOfGroup:t,groupedByUser:n})=>!n||e&&t?`single`:e?`first`:t?`end`:`middle`,lt=(e,t)=>`${e}:${t}`;function ut(e){return!Number.isFinite(e)||e<0?``:e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:e<1073741824?`${(e/1048576).toFixed(2)} MB`:`${(e/1073741824).toFixed(2)} GB`}var dt={pdf:`PDF`,doc:`DOC`,xls:`XLS`,csv:`CSV`,ppt:`PPT`,zip:`ZIP`,text:`TXT`,markdown:`MD`};function ft(e,n){if(n){let e=n.lastIndexOf(`.`);if(e>0&&e<n.length-1){let t=n.slice(e+1);if(t&&t.length<=5)return t.toUpperCase()}}if(!e)return;if(t.i(e)===`document`){let n=dt[t.r(e)];if(n)return n;if(e===`application/octet-stream`)return}let r=e.split(`/`)[1];if(!(!r||r===`*`))return r.toUpperCase()}function pt(e,t,n){return[ft(e,t),typeof n==`number`&&n>0?ut(n):void 0].filter(Boolean).join(` · `)||void 0}function Q(e){try{let t=new URL(e).pathname.split(`/`).pop();return t&&t.length>0?decodeURIComponent(t):`download`}catch{return`download`}}async function mt(e,t){let n=t??Q(e);try{let t=await fetch(e,{mode:`cors`});if(!t.ok)throw Error(`HTTP ${t.status}`);let r=await t.blob(),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=n,a.style.display=`none`,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(i)}catch{if(!window.open(e,`_blank`,`noopener,noreferrer`)){let t=document.createElement(`a`);t.href=e,t.download=n,t.target=`_blank`,t.rel=`noopener noreferrer`,t.style.display=`none`,document.body.appendChild(t),t.click(),document.body.removeChild(t)}}}var ht=()=>()=>{},gt=()=>!0,_t=()=>!1,vt=()=>(0,n.useSyncExternalStore)(ht,gt,_t),yt=35,bt=Object.freeze(Array(yt).fill(0)),xt=`--:--`,St=e=>(0,a.displayDuration)(Math.floor(e)),Ct=e=>({canPlayRecord:e.canPlayRecord,isPlaying:e.isPlaying,progressPercent:e.progressPercent,secondsElapsed:e.secondsElapsed}),wt=`flex size-8 shrink-0 items-center justify-center rounded-full backdrop-blur-[20px]`,Tt={dark:`bg-white text-black/90 disabled:bg-white/40`,light:`bg-[#040403]/90 text-white disabled:bg-[#040403]/30`},Et={dark:`bg-[#040403]/80 text-white hover:bg-[#040403]`,light:`bg-black/10 text-black/90 hover:bg-black/20`},Dt=(e,t)=>{let[r,i]=n.default.useState();return n.default.useEffect(()=>{if(t!=null||!e)return;let n=document.createElement(`audio`);n.preload=`metadata`;let r=()=>{Number.isFinite(n.duration)&&n.duration>0&&i(n.duration)};return n.addEventListener(`loadedmetadata`,r),n.src=e,()=>{n.removeEventListener(`loadedmetadata`,r),n.removeAttribute(`src`),i(void 0)}},[e,t]),t??r},Ot=e=>vt()?(0,o.jsx)(At,{...e}):(0,o.jsx)(jt,{...e,playback:kt}),kt={playable:!1,showPause:!1,isStarting:!1,progress:0,secondsElapsed:0},At=e=>{let{item:t,requester:r}=e,i=n.default.useRef(null),[s,c]=n.default.useState(!1),l=Dt(t.src,t.durationSeconds),u=(0,a.useAudioPlayer)({durationSeconds:l,mimeType:t.mimeType,requester:r,src:t.src,title:t.filename}),{canPlayRecord:d=!1,isPlaying:f=!1,progressPercent:p=0,secondsElapsed:m=0}=(0,a.useStateStore)(u?.state,Ct)??{},h=()=>{!u||s||(c(!0),u.togglePlay().finally(()=>c(!1)))},g=e=>{let t=i.current;if(!u||!t)return;let n=Math.min(Math.max(Number(e.target.value)/100,0),1),r=t.getBoundingClientRect();u.seek({clientX:r.x+n*r.width,currentTarget:t})};return(0,o.jsx)(jt,{...e,playback:{playable:!!u&&d,showPause:f,isStarting:s,progress:Math.min(Math.max(p,0),100),secondsElapsed:m,durationSeconds:l,trackRef:i,onTogglePlay:h,onSeek:g}})},jt=({item:e,variant:t,trailingAction:r,playback:i})=>{let{isStarting:s,onSeek:u,onTogglePlay:d,playable:f,progress:p,secondsElapsed:m,showPause:h,trackRef:g}=i,_=n.default.useMemo(()=>{let t=e.waveformData;return!t||t.length===0?bt:t.length===yt?t:(0,a.resampleWaveformData)(t,yt)},[e.waveformData]),v=i.durationSeconds??e.durationSeconds,y=v==null?xt:St(v),b=m>0?St(m):y,x=e.filename?` \u2014 ${e.filename}`:``;return(0,o.jsxs)(`div`,{role:`group`,"aria-label":e.filename??`Audio attachment`,className:`flex items-center`,"data-testid":`audio-attachment-row`,children:[(0,o.jsx)(`button`,{type:`button`,onClick:d,disabled:!f,"aria-busy":s||void 0,"aria-label":`${h?`Pause audio`:`Play audio`}${x}`,className:(0,c.default)(wt,Tt[t]),children:h?(0,o.jsx)(l.PauseIcon,{className:`size-3`,weight:`fill`,"aria-hidden":!0}):(0,o.jsx)(l.PlayIcon,{className:`size-3`,weight:`fill`,"aria-hidden":!0})}),(0,o.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2.5 px-3`,children:[(0,o.jsxs)(`div`,{className:(0,c.default)(`mes-audio-wave`,t===`light`&&`mes-audio-wave--light`),children:[(0,o.jsx)(`div`,{ref:g,className:`mes-audio-wave__track`,"aria-hidden":!0,"data-testid":`audio-waveform-track`,children:_.map((e,t)=>(0,o.jsx)(`span`,{"data-testid":`amplitude-bar`,className:(0,c.default)(`mes-audio-wave__bar`,p>t/_.length*100&&`mes-audio-wave__bar--played`),style:{"--mes-audio-wave-bar":`${Math.min(Math.max(e,0),1)*100}%`}},t))}),(0,o.jsx)(`input`,{type:`range`,className:`mes-audio-wave__seek`,min:0,max:100,step:.1,value:p,onChange:u,disabled:!f,"aria-label":`Seek audio${x}`,"aria-valuetext":`${St(m)} of ${y}`})]}),(0,o.jsx)(`span`,{className:`shrink-0 text-xs leading-4 tracking-[0.24px] tabular-nums`,children:b})]}),r?(0,o.jsx)(`button`,{type:`button`,onClick:r.kind===`dismiss`?r.onDismiss:()=>{mt(e.src,e.filename)},"aria-label":r.kind===`dismiss`?`Remove attachment`:`Download audio${x}`,className:(0,c.default)(wt,Et[t]),children:r.kind===`dismiss`?(0,o.jsx)(l.XIcon,{className:`size-3`,weight:`bold`,"aria-hidden":!0}):(0,o.jsx)(l.DownloadSimpleIcon,{className:`size-3`,weight:`bold`,"aria-hidden":!0})}):null]})},Mt=`w-[299px]`,Nt=`py-5 pl-5 pr-3`,Pt=`rounded-[20px]`,Ft=({src:e,mimeType:t,filename:n,durationSeconds:r,waveformData:i,items:a})=>a&&a.length>0?a:e?[{src:e,mimeType:t,filename:n,durationSeconds:r,waveformData:i}]:[],It=({state:e,src:t,mimeType:r,filename:i,items:s,durationSeconds:c,waveformData:l,text:u,groupPosition:d,onDismiss:f})=>{let{message:p,threadList:m}=(0,a.useMessageContext)(),h=n.default.useId(),g=st(e),_=Ft({src:t,mimeType:r,filename:i,durationSeconds:c,waveformData:l,items:s});if(_.length===0)return null;let v=p?.id?`${m?p.parent_id??p.id:``}${p.id}`:h,y=e===`composer`?f?{kind:`dismiss`,onDismiss:f}:void 0:{kind:`download`};return(0,o.jsx)(ot,{variant:g,text:u,groupPosition:d,bordered:!1,widthClassName:Mt,paddingClassName:Nt,radiusClassName:Pt,"data-testid":`audio-attachment`,children:(0,o.jsx)(`div`,{className:`flex flex-col gap-2`,children:_.map((e,t)=>(0,o.jsx)(Ot,{item:e,variant:g,requester:lt(v,t),trailingAction:y},`${e.src}-${t}`))})})},Lt={Composer:e=>(0,o.jsx)(It,{...e,state:`composer`}),Sent:e=>(0,o.jsx)(It,{...e,state:`sent`}),Received:e=>(0,o.jsx)(It,{...e,state:`received`})},Rt={dark:`text-white/55`,light:`text-black/65`},zt={dark:`bg-white/10`,light:`bg-black/5`},Bt={dark:`text-white/85`,light:`text-black/85`},Vt=({variant:e,filename:n,title:r,mimeType:i=`application/octet-stream`,fileSize:a,onActivate:s,activateLabel:l,trailingAction:u})=>{let d=r??n??`File`,f=pt(i,n,a),p=(0,o.jsx)(`div`,{className:(0,c.default)(`flex size-10 shrink-0 items-center justify-center rounded-sm`,zt[e]),"aria-hidden":!0,children:t.n(i,{className:(0,c.default)(`size-6`,Bt[e]),weight:`regular`})}),m=(0,o.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col text-left`,children:[(0,o.jsx)(`p`,{className:`truncate font-medium leading-snug`,children:d}),f?(0,o.jsx)(`p`,{className:(0,c.default)(`truncate text-xs leading-4`,Rt[e]),children:f}):null]}),h=s?(0,o.jsxs)(`button`,{type:`button`,onClick:s,"aria-label":l,className:(0,c.default)(`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:[p,m]}):(0,o.jsxs)(o.Fragment,{children:[p,m]});return(0,o.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-2`,children:[h,u?(0,o.jsx)(`div`,{className:`shrink-0`,children:u}):null]})},Ht=({onClick:e,variant:t=`overlay`,ariaLabel:n=`Dismiss attachment`})=>(0,o.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),e()},"aria-label":n,className:(0,c.default)(`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:(0,o.jsx)(l.XIcon,{className:`size-3`,weight:`bold`})}),Ut=({src:e,filename:t,fileSize:n,mimeType:r,title:i,items:a})=>a&&a.length>0?a:e?[{src:e,filename:t,fileSize:n,mimeType:r,title:i}]:[],Wt=({variant:e,item:t,index:n,onActivate:r,trailingAction:i})=>{let a=t.filename??Q(t.src);return(0,o.jsx)(Vt,{variant:e,filename:a,title:t.title,mimeType:t.mimeType??`application/octet-stream`,fileSize:t.fileSize,onActivate:()=>r(n),activateLabel:`Download ${a}`,trailingAction:i})},Gt=({state:e,src:t,filename:n,fileSize:r,mimeType:i,title:a,items:s,text:u,groupPosition:d,onClick:f,onDismiss:p})=>{let m=st(e),h=e===`composer`&&!!p,g=Ut({src:t,filename:n,fileSize:r,mimeType:i,title:a,items:s}),_=e=>{if(f?.(e)===!1)return;let t=g[e];if(!t)return;let n=t.filename??Q(t.src);mt(t.src,n)};if(g.length===0)return null;let v=(0,o.jsx)(`span`,{className:(0,c.default)(`flex size-8 items-center justify-center rounded-full`,m===`dark`?`text-white/70`:`text-black/70`),"aria-hidden":!0,children:(0,o.jsx)(l.DownloadSimpleIcon,{className:`size-5`,weight:`bold`})});return(0,o.jsx)(ot,{variant:m,text:u,groupPosition:d,"data-testid":`file-attachment`,children:(0,o.jsx)(`div`,{className:`flex flex-col gap-2`,children:g.map((e,t)=>(0,o.jsx)(Wt,{variant:m,item:e,index:t,onActivate:_,trailingAction:h&&t===0?(0,o.jsx)(Ht,{onClick:p,variant:`inline`}):v},`${e.src}-${t}`))})})},Kt={Composer:e=>(0,o.jsx)(Gt,{...e,state:`composer`}),Sent:e=>(0,o.jsx)(Gt,{...e,state:`sent`}),Received:e=>(0,o.jsx)(Gt,{...e,state:`received`})},qt=`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`,Jt=`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`,Yt=({onPrev:e,onNext:t,prevLabel:n=`Previous`,nextLabel:r=`Next`})=>(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`button`,{type:`button`,onClick:e,"aria-label":n,className:`${Jt} left-4`,children:(0,o.jsx)(l.CaretLeftIcon,{size:20,weight:`bold`,"aria-hidden":!0})}),(0,o.jsx)(`button`,{type:`button`,onClick:t,"aria-label":r,className:`${Jt} right-4`,children:(0,o.jsx)(l.CaretRightIcon,{size:20,weight:`bold`,"aria-hidden":!0})})]}),Xt=({url:e,filename:t,variant:r=`pill`,label:i=`Download`,iconOnly:a,tone:s=`dark`,onTriggered:u})=>{let[d,f]=(0,n.useState)(!1),p=(0,n.useCallback)(n=>{n.stopPropagation(),!d&&(f(!0),mt(e,t).catch(()=>{}).finally(()=>{f(!1),u?.()}))},[d,e,t,u]),m=a??r!==`pill`,h={className:(0,c.default)(r===`pill`?`size-4`:`size-5`,`shrink-0`),weight:`bold`};return r===`inline`?(0,o.jsx)(`button`,{type:`button`,onClick:p,disabled:d,"aria-label":i,className:(0,c.default)(`flex size-8 shrink-0 items-center justify-center rounded-full transition-colors disabled:opacity-70`,{dark:`text-white/70 hover:bg-white/[0.08] hover:text-white`,light:`text-black/70 hover:bg-black/[0.08] hover:text-black`}[s]),children:d?(0,o.jsx)(l.CircleNotchIcon,{className:`size-4 animate-spin`,weight:`bold`,"aria-hidden":!0}):(0,o.jsx)(l.DownloadSimpleIcon,{className:`size-5 shrink-0`,weight:`bold`,"aria-hidden":!0})}):r===`viewer`?(0,o.jsx)(`button`,{type:`button`,onClick:p,disabled:d,"aria-label":i,className:qt,children:d?(0,o.jsx)(l.CircleNotchIcon,{size:20,weight:`bold`,"aria-hidden":!0}):(0,o.jsx)(l.DownloadSimpleIcon,{size:20,weight:`bold`,"aria-hidden":!0})}):(0,o.jsxs)(`button`,{type:`button`,onClick:p,disabled:d,"aria-label":m?i:void 0,className:(0,c.default)(`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`,s===`dark`?`bg-[#121110] text-white hover:bg-[#2a2928]`:`bg-white text-[#121110] hover:bg-white/90`),children:[d?(0,o.jsx)(l.CircleNotchIcon,{className:`size-4 animate-spin`,weight:`bold`,"aria-hidden":!0}):(0,o.jsx)(l.DownloadSimpleIcon,{...h,"aria-hidden":!0}),m?null:i]})},Zt=(e,t,n)=>Math.min(Math.max(e,t),n),Qt=({length:e,initialIndex:t,open:r})=>{let i=Zt(t,0,Math.max(e-1,0)),[a,o]=(0,n.useState)(i);(0,n.useEffect)(()=>{r&&o(Zt(t,0,Math.max(e-1,0)))},[r,t,e]),(0,n.useEffect)(()=>{o(t=>Zt(t,0,Math.max(e-1,0)))},[e]);let s=(0,n.useCallback)(()=>{e<=1||o(t=>t<=0?e-1:t-1)},[e]),c=(0,n.useCallback)(()=>{e<=1||o(t=>t>=e-1?0:t+1)},[e]);return(0,n.useEffect)(()=>{if(!r||e<=1)return;let t=e=>{if(e.key!==`ArrowLeft`&&e.key!==`ArrowRight`)return;let t=document.activeElement;t&&(t.tagName===`VIDEO`||t.tagName===`AUDIO`)||(e.preventDefault(),e.key===`ArrowLeft`?s():c())};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[r,e,s,c]),{index:a,prev:s,next:c}},$t=({open:e,onClose:t,ariaLabel:r,counter:i,actions:a,children:s,"data-testid":c})=>{let u=(0,n.useRef)(null),d=(0,n.useRef)(null);return(0,n.useEffect)(()=>{let t=u.current;if(t){if(e){if(!t.open){if(typeof t.showModal==`function`)try{t.showModal()}catch{t.setAttribute(`open`,``)}else t.setAttribute(`open`,``)}let e=typeof document<`u`?document.activeElement:null;return d.current?.focus(),()=>{if(t.open){if(typeof t.close==`function`)try{t.close()}catch{t.removeAttribute(`open`)}else t.removeAttribute(`open`)}e&&document.body.contains(e)&&e.focus()}}if(t.open){if(typeof t.close==`function`)try{t.close()}catch{t.removeAttribute(`open`)}else t.removeAttribute(`open`)}}},[e]),(0,o.jsxs)(`dialog`,{ref:u,className:`mes-media-viewer`,"aria-label":r??`Attachment viewer`,"data-testid":c,onClose:()=>{t()},onClick:e=>{e.target===u.current&&t()},children:[(0,o.jsxs)(`div`,{className:`pointer-events-none absolute inset-x-3 top-3 z-[1] flex items-center justify-between gap-3`,children:[i?(0,o.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:i}):null,(0,o.jsxs)(`div`,{className:`pointer-events-auto ml-auto inline-flex items-center gap-2`,children:[a,(0,o.jsx)(`button`,{ref:d,type:`button`,onClick:t,"aria-label":`Close viewer`,className:qt,children:(0,o.jsx)(l.XIcon,{size:20,weight:`bold`,"aria-hidden":!0})})]})]}),(0,o.jsx)(`div`,{className:`box-border flex h-full w-full items-center justify-center px-6 py-16`,children:s})]})},en=({open:e,items:t,initialIndex:r=0,onClose:i})=>{let{index:a,prev:s,next:c}=Qt({length:t.length,initialIndex:r,open:e}),l=t[a],u=(0,n.useMemo)(()=>l?.filename??(l?Q(l.src):`image`),[l]);return l?(0,o.jsxs)($t,{open:e,onClose:i,ariaLabel:u,counter:t.length>1?`${a+1} / ${t.length}`:void 0,actions:(0,o.jsx)(Xt,{url:l.src,filename:u,variant:`viewer`,label:`Download ${u}`}),"data-testid":`image-viewer`,children:[e?(0,o.jsx)(`img`,{src:l.src,alt:l.alt??u,draggable:!1,decoding:`async`,className:`block h-auto max-h-[calc(100dvh-128px)] w-auto max-w-[min(96vw,1400px)] select-none object-contain`},`${a}:${l.src}`):null,t.length>1?(0,o.jsx)(Yt,{onPrev:s,onNext:c,prevLabel:`Previous image`,nextLabel:`Next image`}):null]}):null},tn=`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`,nn={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]`]},rn=`--mes-single-width-cap`,an=`[--mes-single-width-cap:309px] sm:[--mes-single-width-cap:326px]`,on=436,sn=({tiles:e,onTileActivate:t,maxVisible:n=4,singleAspectRatio:r,className:i})=>{let a=e.length;if(a===0)return null;let s=e.slice(0,Math.min(a,n)),l=a-s.length,u=l>0?(0,o.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:[`+`,l]}):null,d=(e,n,r)=>{let i=(0,c.default)(tn,`h-full w-full`,nn[s.length]?.[n]);return t?(0,o.jsxs)(`button`,{type:`button`,onClick:()=>t(n),"aria-label":e.ariaLabel??`Open media ${n+1}`,className:(0,c.default)(i,e.cursorClassName??`cursor-zoom-in`),children:[e.content,r]},n):(0,o.jsxs)(`div`,{className:i,children:[e.content,r]},n)},f;return r&&(f={aspectRatio:r,width:`min(var(${rn}), ${Math.round(on*r*100)/100}px)`,maxWidth:`100%`}),s.length===1?(0,o.jsx)(`div`,{className:(0,c.default)(r?an:`aspect-square w-full`,i),style:f,children:d(s[0],0,u)}):s.length===2?(0,o.jsx)(`div`,{className:(0,c.default)(`grid aspect-[16/9] w-full grid-cols-2 gap-0.5`,i),children:s.map((e,t)=>d(e,t,t===s.length-1?u:null))}):s.length===3?(0,o.jsxs)(`div`,{className:(0,c.default)(`grid aspect-[4/3] w-full grid-cols-2 grid-rows-2 gap-0.5`,i),children:[(0,o.jsx)(`div`,{className:`row-span-2`,children:d(s[0],0)}),d(s[1],1),d(s[2],2,u)]}):(0,o.jsx)(`div`,{className:(0,c.default)(`grid aspect-[379/286] w-full grid-cols-2 grid-rows-2 gap-0.5`,i),children:s.map((e,t)=>{let n=l>0&&t===s.length-1;return d(e,t,n?u:null)})})},cn=({src:e,suppliedRatio:t,fallbackRatio:r})=>{let[i,a]=n.default.useState(),o=n.default.useCallback(t=>{if(!t||t.naturalWidth<=0||t.naturalHeight<=0||e===void 0)return;let n=t.naturalWidth/t.naturalHeight;a(t=>t&&t.src===e&&t.ratio===n?t:{src:e,ratio:n})},[e]),s=n.default.useCallback(e=>o(e.currentTarget),[o]),c=i&&i.src===e?i.ratio:void 0;return{ratio:t??c??r,imgRef:o,onLoad:s}},ln=e=>{let[t,r]=(0,n.useState)(!1),[i,a]=(0,n.useState)(0);return{viewerOpen:t,viewerIndex:i,handleActivate:(0,n.useCallback)(t=>{e?.(t)!==!1&&(a(t),r(!0))},[e]),closeViewer:(0,n.useCallback)(()=>r(!1),[])}},un=({item:e,index:n,totalCount:r,fallbackLoading:i,imgRef:a,onLoad:s})=>({ariaLabel:`Open image ${n+1} of ${r}`,content:(0,o.jsx)(`img`,{ref:a,src:t.s(e.src)??e.src,alt:e.alt??``,width:e.width,height:e.height,draggable:!1,loading:e.loading??i,decoding:`async`,onLoad:s,className:`absolute inset-0 size-full object-cover`})}),dn=({src:e,alt:t,items:n})=>n&&n.length>0?n:e?[{src:e,alt:t}]:[],fn=(e,t)=>e.map((n,r)=>({src:n.src,alt:n.alt,filename:t&&e.length===1?t:t?`${t} (${r+1})`:void 0})),pn=({src:e,alt:n,filename:r,loading:i=`lazy`,onClick:a,onDismiss:s})=>{let{viewerOpen:c,viewerIndex:l,handleActivate:u,closeViewer:d}=ln(a);return(0,o.jsxs)(`div`,{className:`relative w-fit`,children:[(0,o.jsx)(`button`,{type:`button`,onClick:()=>u(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:(0,o.jsx)(`img`,{src:t.s(e)??e,alt:n??``,draggable:!1,loading:i,decoding:`async`,className:`size-full object-cover`})}),s?(0,o.jsx)(`div`,{className:`absolute right-2 top-2 z-10`,children:(0,o.jsx)(Ht,{onClick:s})}):null,(0,o.jsx)(en,{open:c,items:fn([{src:e,alt:n}],r),initialIndex:l,onClose:d})]})},mn=326/246,hn=({state:e,src:t,alt:n,filename:r,items:i,text:a,groupPosition:s,loading:c=`lazy`,onClick:l})=>{let u=dn({src:t,alt:n,items:i}),d=st(e),{viewerOpen:f,viewerIndex:p,handleActivate:m,closeViewer:h}=ln(l),g=u.length===1,_=g?u[0]:void 0,v=cn({src:_?.src,suppliedRatio:_?.width&&_?.height?_.width/_.height:void 0,fallbackRatio:mn});if(u.length===0)return null;let y=u.map((e,t)=>un({item:e,index:t,totalCount:u.length,fallbackLoading:c,imgRef:g?v.imgRef:void 0,onLoad:g?v.onLoad:void 0}));return(0,o.jsxs)(ot,{variant:d,text:a,groupPosition:s,bordered:!1,widthClassName:g?`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:[(0,o.jsx)(`div`,{className:`relative`,children:(0,o.jsx)(sn,{tiles:y,onTileActivate:m,singleAspectRatio:g?v.ratio:void 0})}),(0,o.jsx)(en,{open:f,items:fn(u,r),initialIndex:p,onClose:h})]})},gn={Composer:e=>(0,o.jsx)(pn,{...e}),Sent:e=>(0,o.jsx)(hn,{...e,state:`sent`}),Received:e=>(0,o.jsx)(hn,{...e,state:`received`})},_n=({open:e,items:t,initialIndex:r=0,onClose:i})=>{let{index:a,prev:s,next:c}=Qt({length:t.length,initialIndex:r,open:e}),l=t[a],u=(0,n.useMemo)(()=>l?.filename??(l?Q(l.src):`document`),[l]),d=(0,n.useMemo)(()=>l?vn(l.src):void 0,[l]);return!l||!d?null:(0,o.jsxs)($t,{open:e,onClose:i,ariaLabel:u,counter:t.length>1?`${a+1} / ${t.length}`:void 0,"data-testid":`pdf-viewer`,children:[(0,o.jsx)(`iframe`,{src:d,title:u,className:`block h-[calc(100dvh-128px)] w-[min(96vw,1400px)] border-0 bg-white`,sandbox:`allow-scripts allow-forms allow-popups allow-downloads`},`${a}:${l.src}`),t.length>1?(0,o.jsx)(Yt,{onPrev:s,onNext:c,prevLabel:`Previous document`,nextLabel:`Next document`}):null]})},vn=e=>{let t=e.indexOf(`#`),n=t===-1?e:e.slice(0,t),r=t===-1?``:e.slice(t+1),i=new URLSearchParams(r);return i.has(`toolbar`)||i.set(`toolbar`,`0`),i.has(`navpanes`)||i.set(`navpanes`,`0`),`${n}#${i.toString()}`},yn=({src:e,filename:t,fileSize:n,title:r,items:i})=>i&&i.length>0?i:e?[{src:e,filename:t,fileSize:n,title:r}]:[],bn=({variant:e,item:t,index:n,onActivate:r,trailingAction:i})=>{let a=t.filename??Q(t.src);return(0,o.jsx)(Vt,{variant:e,filename:a,title:t.title,mimeType:`application/pdf`,fileSize:t.fileSize,onActivate:()=>r(n),activateLabel:`Open ${a}`,trailingAction:i})},xn=({state:e,src:t,filename:n,fileSize:r,title:i,items:a,text:s,groupPosition:c,onClick:l,onDismiss:u})=>{let d=st(e),f=yn({src:t,filename:n,fileSize:r,title:i,items:a}),{viewerOpen:p,viewerIndex:m,handleActivate:h,closeViewer:g}=ln(l),_=e===`composer`&&!!u;if(f.length===0)return null;let v=f.map(e=>({src:e.src,filename:e.filename??Q(e.src)}));return(0,o.jsxs)(ot,{variant:d,text:s,groupPosition:c,"data-testid":`pdf-attachment`,children:[(0,o.jsx)(`div`,{className:`flex flex-col gap-2`,children:f.map((t,n)=>{let r=t.filename??Q(t.src),i=_&&n===0?(0,o.jsx)(Ht,{onClick:u,variant:`inline`}):e===`composer`?void 0:(0,o.jsx)(Xt,{url:t.src,filename:r,variant:`inline`,label:`Download ${r}`,tone:d});return(0,o.jsx)(bn,{variant:d,item:t,index:n,onActivate:h,trailingAction:i},`${t.src}-${n}`)})}),(0,o.jsx)(_n,{open:p,items:v,initialIndex:m,onClose:g})]})},Sn={Composer:e=>(0,o.jsx)(xn,{...e,state:`composer`}),Sent:e=>(0,o.jsx)(xn,{...e,state:`sent`}),Received:e=>(0,o.jsx)(xn,{...e,state:`received`})},Cn=150,wn=({open:e,items:r,initialIndex:i=0,onClose:s})=>{let{index:c,prev:l,next:u}=Qt({length:r.length,initialIndex:i,open:e}),d=(0,n.useRef)(null),f=(0,a.useActiveAudioPlayer)();(0,n.useEffect)(()=>{e&&(f?.pause(),t.o(d.current))},[e,f]);let[p,m]=(0,n.useState)(e);e&&!p&&m(!0),(0,n.useEffect)(()=>{if(e||!p)return;d.current?.pause();let t=window.setTimeout(()=>m(!1),Cn);return()=>window.clearTimeout(t)},[e,p]);let h=r[c],g=(0,n.useMemo)(()=>h?.filename??(h?Q(h.src):`video`),[h]);return h?(0,o.jsxs)($t,{open:e,onClose:s,ariaLabel:g,counter:r.length>1?`${c+1} / ${r.length}`:void 0,"data-testid":`video-viewer`,children:[p?(0,o.jsx)(`video`,{ref:d,"data-testid":`video-viewer-media`,src:h.src,poster:h.poster,controls:!0,autoPlay:!0,muted:!0,playsInline:!0,preload:h.preload??`metadata`,className:`block h-auto max-h-[calc(100dvh-128px)] w-auto max-w-[min(96vw,1400px)] bg-black`,children:h.mimeType?(0,o.jsx)(`source`,{src:h.src,type:h.mimeType}):null},`${c}:${h.src}`):null,r.length>1?(0,o.jsx)(Yt,{onPrev:l,onNext:u,prevLabel:`Previous video`,nextLabel:`Next video`}):null]}):null},Tn=1,En=4/5,Dn=16/9,On=()=>(0,o.jsx)(`div`,{className:`pointer-events-none absolute inset-0 flex items-center justify-center`,children:(0,o.jsx)(`span`,{className:`flex size-12 items-center justify-center rounded-full bg-black/25 text-white backdrop-blur-[20px]`,children:(0,o.jsx)(l.PlayIcon,{className:`size-6`,weight:`fill`,"aria-hidden":!0})})}),kn=e=>{let t=e.indexOf(`#`);if(t===-1)return`${e}#t=0.001`;let n=e.slice(t+1);return/(^|&)t=/.test(n)?e:`${e}&t=0.001`},An=({item:e,index:t,showPlayBadge:n=!0,imgRef:r,onLoad:i})=>(0,o.jsxs)(`div`,{className:`absolute inset-0 size-full bg-[#0d0d0d]`,children:[e.poster?(0,o.jsx)(`img`,{ref:r,src:e.poster,alt:`Video ${t+1} thumbnail`,draggable:!1,loading:`lazy`,decoding:`async`,onLoad:i,className:`absolute inset-0 size-full object-cover`}):e.src&&e.preload!==`none`?(0,o.jsx)(`video`,{src:kn(e.src),muted:!0,playsInline:!0,preload:`metadata`,"aria-label":`Video ${t+1} thumbnail`,className:`absolute inset-0 size-full object-cover`}):(0,o.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center`,children:(0,o.jsx)(l.VideoCameraIcon,{className:`size-16 text-white/30`,weight:`regular`,"aria-hidden":!0})}),n?(0,o.jsx)(On,{}):null]}),jn=({item:e,index:t,totalCount:n,isOverflowTile:r,imgRef:i,onLoad:a})=>({ariaLabel:`Play video ${t+1} of ${n}`,cursorClassName:`cursor-pointer`,content:(0,o.jsx)(An,{item:e,index:t,showPlayBadge:!r,imgRef:i,onLoad:a})}),Mn=({src:e,poster:t,mimeType:n,preload:r,naturalAspectRatio:i,items:a})=>a&&a.length>0?r?a.map(e=>({...e,preload:e.preload??r})):a:e?[{src:e,poster:t,mimeType:n,preload:r,naturalAspectRatio:i}]:[],Nn=(e,t)=>e.map((n,r)=>({src:n.src,poster:n.poster,mimeType:n.mimeType,preload:n.preload,filename:t&&e.length===1?t:t?`${t} (${r+1})`:void 0})),Pn=({src:e,poster:t,mimeType:n,filename:r,preload:i,onClick:a,onDismiss:s})=>{let{viewerOpen:c,viewerIndex:l,handleActivate:u,closeViewer:d}=ln(a);return(0,o.jsxs)(`div`,{className:`relative w-fit`,children:[(0,o.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:(0,o.jsx)(An,{item:{src:e,poster:t,mimeType:n,preload:i},index:0})}),s?(0,o.jsx)(`div`,{className:`absolute right-2 top-2 z-10`,children:(0,o.jsx)(Ht,{onClick:s})}):null,(0,o.jsx)(wn,{open:c,items:Nn([{src:e,poster:t,mimeType:n,preload:i}],r),initialIndex:l,onClose:d})]})},Fn=({state:e,src:t,poster:n,mimeType:r,filename:i,items:a,text:s,groupPosition:c,preload:l,naturalAspectRatio:u,onClick:d})=>{let f=Mn({src:t,poster:n,mimeType:r,preload:l,naturalAspectRatio:u,items:a}),p=st(e),{viewerOpen:m,viewerIndex:h,handleActivate:g,closeViewer:_}=ln(d),v=f.length===1,y=v?f[0]:void 0,b=cn({src:y?.poster,suppliedRatio:y?.naturalAspectRatio,fallbackRatio:Tn});if(f.length===0)return null;let x=f.length>4?3:-1,S=f.map((e,t)=>jn({item:e,index:t,totalCount:f.length,isOverflowTile:t===x,imgRef:v?b.imgRef:void 0,onLoad:v?b.onLoad:void 0})),C=Math.min(Math.max(b.ratio,En),Dn);return(0,o.jsxs)(ot,{variant:p,text:s,groupPosition:c,bordered:!1,widthClassName:v?`w-fit max-w-[313px] sm:max-w-[330px]`:`w-[383px] max-w-full`,paddingClassName:`p-0.5`,radiusClassName:c&&c!==`single`?void 0:`rounded-[20px]`,"data-testid":`video-attachment`,children:[(0,o.jsx)(`div`,{className:`relative`,children:(0,o.jsx)(sn,{tiles:S,onTileActivate:g,singleAspectRatio:v?C:void 0})}),(0,o.jsx)(wn,{open:m,items:Nn(f,i),initialIndex:h,onClose:_})]})},In={Image:gn,Video:{Composer:e=>(0,o.jsx)(Pn,{...e}),Sent:e=>(0,o.jsx)(Fn,{...e,state:`sent`}),Received:e=>(0,o.jsx)(Fn,{...e,state:`received`})},Audio:Lt,Pdf:Sn,File:Kt};function $(e){return e?.trim()||void 0}function Ln(e){let{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 Rn(e){return e.trim().replace(/^https?:\/\//i,``).replace(/\/+$/,``).toLowerCase()}function zn(e,t){if(!e?.trim()||!t?.trim())return!1;let n=Rn(e),r=Rn(t);if(n===r)return!0;if(!n.includes(r))return!1;let i=n.split(r).join(``);return!/[^\p{P}\p{Z}\p{C}]/u.test(i)}function Bn(e){let n=$(e.og_scrape_url)??$(e.title_link),r=$(e.image_url)??$(e.thumb_url),i=$(e.mime_type),a=$(e.asset_url),o=r&&Y(i,a)?void 0:a;return{title:$(e.title),description:$(e.text),url:n,thumbnailUrl:t.s(r),sourceUrl:o,layout:r||ue(i,o)?`featured`:`classic`,mimeType:i,accentColor:$(e.accent_color),status:`ready`}}function Vn(e){return Se(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`:e.mime_type?.startsWith(`audio/`)?`audio`:`file`:null}function Hn(e){if(!e?.length)return[];let t=[],n=(e,n)=>{let r=t[t.length-1];if(r?.type===`media`&&r.kind===e){r.attachments.push(n);return}t.push({type:`media`,kind:e,attachments:[n]})},r=e=>{let n=t[t.length-1];if(n?.type===`link`){n.attachments.push(e);return}t.push({type:`link`,attachments:[e]})};for(let t of e){if(Se(t)){r(t);continue}let e=Vn(t);e&&n(e,t)}return t}function Un(e){return e.filter(e=>e.type===`media`).length}function Wn(e,t,n){return t<=1?n:e===0?`first`:e===t-1?`end`:`middle`}function Gn(e){return $(e.image_url)??$(e.asset_url)??``}function Kn(e){switch(e){case`image`:return In.Image;case`video`:return In.Video;case`audio`:return In.Audio;case`pdf`:return In.Pdf;default:return In.File}}function qn(e,n){switch(e){case`image`:return{src:Gn(n),alt:$(n.title)};case`video`:return{src:$(n.asset_url)??``,poster:t.s(n.thumb_url),mimeType:$(n.mime_type),naturalAspectRatio:Ln(n)};case`audio`:return{src:$(n.asset_url)??``,mimeType:$(n.mime_type)??`audio/mpeg`,filename:$(n.title),durationSeconds:n.duration,waveformData:n.waveform_data};case`pdf`:return{src:$(n.asset_url)??``,filename:$(n.title),fileSize:n.file_size};case`file`:return{src:$(n.asset_url)??``,filename:$(n.title),fileSize:n.file_size,mimeType:$(n.mime_type)??`application/octet-stream`}}}function Jn(e,t){if(t.length>1)return{items:t.map(t=>qn(e,t))};let n=t[0];return n?qn(e,n):{}}function Yn({groupPosition:e,isMyMessage:t,segment:n}){let r=Kn(n.kind),i={...Jn(n.kind,n.attachments),groupPosition:e};return t?(0,o.jsx)(r.Sent,{...i}):(0,o.jsx)(r.Received,{...i})}var Xn=({groupPosition:e,isMyMessage:t,message:n,renderText:r})=>{let i=Hn(n.attachments);if(i.length===0)return null;let s=Un(i),l=n.text?.trim(),u=i.find(e=>e.type===`link`),d=u?.type===`link`?Bn(u.attachments[0]??{}).url:void 0,f=l&&zn(l,d)?void 0:l,p=0,m=[],h=f?`middle`:e,g=e===`single`||e===`end`,_=(e,n,r)=>{let i=t?xe.Sent:xe.Received;m.push((0,o.jsx)(i,{...Bn(e),groupPosition:r?h:`middle`},n))},v=(n,r)=>{let i=Wn(p,s,e);p+=1,m.push((0,o.jsx)(Yn,{groupPosition:i,isMyMessage:t,segment:n},r))};return i.forEach((e,t)=>{let n=t===i.length-1;if(e.type===`link`){e.attachments.forEach((r,i)=>{_(r,`link-${t}-${i}`,n&&i===e.attachments.length-1)});return}v(e,`media-${t}`)}),(0,o.jsxs)(`div`,{className:`str-chat__message-bubble-wrapper`,children:[(0,o.jsxs)(`div`,{className:`str-chat__message-bubble`,"data-attachment-bubble":`true`,"data-testid":`message-attachment-bubble`,style:{background:`transparent`,borderRadius:0,overflow:`visible`,padding:0},children:[(0,o.jsx)(`div`,{"data-testid":`message-attachment-rows`,className:(0,c.default)(`flex flex-col gap-[4px]`,t?`items-end`:`items-start`),children:m}),!f&&(0,o.jsx)(a.MessageErrorIcon,{})]}),f?(0,o.jsxs)(`div`,{"data-testid":`message-caption-bubble`,className:(0,c.default)(`str-chat__message-bubble`,{"relative isolate":g}),children:[(0,o.jsx)(a.MessageText,{message:n,renderText:r}),(0,o.jsx)(a.MessageErrorIcon,{}),g&&(0,o.jsx)(Ve,{side:t?`me`:`other`})]}):null]})},Zn=n.default.memo(e=>{let{additionalMessageInputProps:t,editing:r,endOfGroup:i,firstOfGroup:s,groupStyles:l,groupedByUser:u,handleAction:d,handleOpenThread:f,handleRetry:p,highlighted:m,isMessageAIGenerated:h,isMyMessage:g,message:_,renderText:v,threadList:y,viewerLanguage:b,onOutboundClick:x,resolvedOutbound:S}=e,{client:C}=(0,a.useChatContext)(`CustomMessage`),{channel:w}=(0,a.useChannelStateContext)(`CustomMessage`),{isUnlocking:T,onUnlockClick:E,onFetchSource:D,onDownloadClick:O}=Ee(`LockedAttachment`),[k,A]=(0,n.useState)(!1),M=(0,a.useMessageReminder)(_.id),{Attachment:N=a.Attachment,EditMessageModal:P=a.EditMessageModal,MessageActions:F,MessageBlocked:I=a.MessageBlocked,MessageBouncePrompt:L=a.MessageBouncePrompt,MessageDeleted:R=a.MessageDeleted,MessageIsThreadReplyInChannelButtonIndicator:ee=a.MessageIsThreadReplyInChannelButtonIndicator,MessageRepliesCountButton:te=a.MessageRepliesCountButton,ReminderNotification:z=a.ReminderNotification,StreamedMessageText:V=a.StreamedMessageText,PinIndicator:ne}=(0,a.useComponentContext)(`CustomMessage`),H=(0,a.messageHasAttachments)(_),re=(0,a.messageHasReactions)(_),ie=(0,n.useMemo)(()=>h?.(_),[h,_]),U=(0,n.useMemo)(()=>{let e=_.attachments??[],t=_.shared_location?[_.shared_location,...e]:e;if(!Ne(_))return t;let n=t.filter(e=>!(`type`in e)||!Se(e));return n.length===t.length?t:n},[_]),W=(0,n.useMemo)(()=>(_.attachments??[]).filter(Se),[_]),ae=(0,n.useMemo)(()=>{let e=_.text?.trim();return e?zn(e,W[0]?Bn(W[0]).url:void 0)?void 0:e:void 0},[_,W]),oe=(0,n.useMemo)(()=>Hn(U),[U]),G=(0,n.useMemo)(()=>{let e=B({message:_,viewerLanguage:b});return e===_.text?_:{..._,text:e}},[_,b]),se=oe.length>0,ce=oe.reduce((e,t)=>e+t.attachments.length,0)===(U?.length??0),K=l?.[0]??``,q=K===`top`?`first`:K===`middle`?`middle`:K===`bottom`?`end`:`single`,J=K===`single`||K===`bottom`;if((0,a.isDateSeparatorMessage)(_))return null;if(_.deleted_at||_.type===`deleted`)return(0,o.jsx)(R,{message:_});if((0,a.isMessageBlocked)(_))return(0,o.jsx)(I,{});let le=!y&&!!_.reply_count,Y=!y&&_.show_in_channel&&_.parent_id,ue=_.status===`failed`&&_.error?.status!==403,de=(0,a.isMessageBounced)(_),X;ue?X=()=>p(_):de&&(X=()=>A(!0));let Z=g(),fe=(0,c.default)(`str-chat__message str-chat__message-simple`,`str-chat__message--${_.type}`,`str-chat__message--${_.status}`,Z?`str-chat__message--me str-chat__message-simple--me`:`str-chat__message--other`,_.text?`str-chat__message--has-text`:`has-no-text`,{"str-chat__message--has-attachment":H,"str-chat__message--highlighted":m,"str-chat__message--pinned pinned-message":_.pinned,"str-chat__message--with-reactions":re,"str-chat__message-send-can-be-retried":_?.status===`failed`&&_?.error?.status!==403,"str-chat__message-with-thread-link":le||Y,"str-chat__virtual-message__wrapper--end":i,"str-chat__virtual-message__wrapper--first":s,"str-chat__virtual-message__wrapper--group":u}),pe=_.poll_id&&C.polls.fromState(_.poll_id),me=qe(_),he=Ne(_),ge=Pe(_),_e=!!(U?.length&&!_.quoted_message),ve=he&&Z&&_e,ye=se&&ce&&!_.quoted_message&&!pe&&!ie&&!he,be={contentType:`text`,amountText:_.metadata?.amount_text,paymentStatus:_.metadata?.payment_status,renderedText:_.text&&(0,o.jsx)(a.MessageText,{message:G,renderText:v})},Ce={contentType:`media`,title:_.metadata?.attachment_title,mimeType:_.metadata?.attachment_mime_type,thumbnailUrl:_.metadata?.attachment_thumbnail,amountText:_.metadata?.amount_text,detail:_.metadata?.attachment_detail,paymentStatus:_.metadata?.payment_status,onFetchSource:D?()=>D(_,w):void 0},we=(0,o.jsxs)(`div`,{className:(0,c.default)(`str-chat__message-bubble`,{"relative isolate":J}),children:[(0,o.jsx)(a.MessageText,{message:G,renderText:v}),J&&(0,o.jsx)(Ve,{side:Z?`me`:`other`})]}),Te=W.length>0&&(0,o.jsx)(`div`,{className:(0,c.default)(`flex flex-col gap-[4px]`,Z?`items-end`:`items-start`),children:W.map((e,t)=>{let n=Z?xe.Sent:xe.Received,r=t===W.length-1&&!ae;return(0,o.jsx)(n,{...Bn(e),groupPosition:r?q:`middle`},`locked-link-${t}`)})});return(0,o.jsxs)(o.Fragment,{children:[r&&(0,o.jsx)(P,{additionalMessageInputProps:t}),k&&(0,o.jsx)(a.MessageBounceModal,{MessageBouncePrompt:L,onClose:()=>A(!1),open:k}),(0,o.jsxs)(`div`,{className:fe,"data-message-id":_.id,"data-dd-privacy":`mask`,children:[ne&&(0,o.jsx)(ne,{}),!!M&&(0,o.jsx)(z,{reminder:M}),_.user&&(0,o.jsx)(j,{className:`str-chat__avatar str-chat__message-sender-avatar`,id:_.user.id,image:_.user.image,name:_.user.name||_.user.id,size:24,shape:`circle`,dmAgentEnabled:he}),(0,o.jsx)(`div`,{className:(0,c.default)(`str-chat__message-inner`,{"str-chat__simple-message--error-failed":ue||de}),"data-testid":`message-inner`,onClick:X,onKeyDown:X,role:X?`button`:void 0,tabIndex:X?0:void 0,style:{marginInlineEnd:0,marginInlineStart:0},children:me?(0,o.jsxs)(`div`,{className:`str-chat__message-bubble-wrapper message-tip-wrapper`,children:[(0,o.jsx)(Je,{message:_}),_.text?.trim()&&we]}):Fe(_)?(0,o.jsx)(`div`,{className:`str-chat__message-bubble-wrapper`,children:(0,o.jsxs)(`div`,{className:`flex items-center gap-2`,children:[Z&&F&&(0,o.jsx)(F,{}),Z?(0,o.jsx)(Ae,{...be,isMine:!0}):(0,o.jsx)(Ae,{...be,isMine:!1,isUnlocking:T(_.id),onUnlockClick:()=>E?.(_,w)}),!Z&&F&&(0,o.jsx)(F,{})]})}):Ie(_)?(0,o.jsxs)(`div`,{className:`str-chat__message-bubble-wrapper message-locked-attachment-wrapper`,children:[(0,o.jsxs)(`div`,{className:`flex items-center gap-2`,children:[Z&&F&&(0,o.jsx)(F,{}),Z?(0,o.jsx)(Ae,{...Ce,isMine:!0,onPreviewClick:()=>E?E(_,w):void 0}):(0,o.jsx)(Ae,{...Ce,isMine:!1,isUnlocking:T(_.id),onUnlockClick:()=>E?E(_,w):void 0,onDownloadClick:()=>O?O(_,w):void 0}),!Z&&F&&(0,o.jsx)(F,{})]}),Te,ae&&we]}):ye?(0,o.jsx)(Xn,{groupPosition:q,isMyMessage:Z,message:{...G,attachments:U,i18n:void 0},renderText:v}):(0,o.jsx)(`div`,{className:`str-chat__message-bubble-wrapper`,children:(0,o.jsxs)(`div`,{className:(0,c.default)(`str-chat__message-bubble`,{"relative isolate":J}),children:[he&&!ve&&(0,o.jsx)(Re,{message:_,hasAttachment:_e,isMyMessage:Z}),pe&&(0,o.jsx)(a.Poll,{poll:pe}),U?.length&&!_.quoted_message?(0,o.jsx)(N,{actionHandler:d,attachments:U}):null,ie?(0,o.jsx)(V,{message:G,renderText:v}):(0,o.jsx)(a.MessageText,{message:G,renderText:v}),(0,o.jsx)(a.MessageErrorIcon,{}),J&&(0,o.jsx)(Ve,{side:Z?`me`:`other`})]})})}),!ge&&!me&&(0,o.jsx)(`div`,{className:`str-chat__message-footer`,children:(!he||ve)&&(0,o.jsx)(Re,{message:_,hasAttachment:_e,isMyMessage:Z})}),(0,o.jsx)(et,{onOutboundClick:x,resolvedOutbound:S}),le&&(0,o.jsx)(te,{onClick:f,reply_count:_.reply_count}),Y&&(0,o.jsx)(ee,{})]},_.id)]})},(e,t)=>e.viewerLanguage!==t.viewerLanguage||e.onOutboundClick!==t.onOutboundClick||e.resolvedOutbound?.id!==t.resolvedOutbound?.id||e.resolvedOutbound?.name!==t.resolvedOutbound?.name?!1:(0,a.areMessageUIPropsEqual)(e,t)),Qn=e=>{let t=(0,a.useMessageContext)(`CustomMessage`),r=(0,n.useContext)(He),i=t.message.metadata?.outbound_id,s=typeof i==`string`?r?.[i]:void 0;return(0,o.jsx)(Zn,{...t,...e,resolvedOutbound:s})},$n=()=>{let{handleDelete:e,message:t}=(0,a.useMessageContext)(`CustomMessageActions`);return t.metadata?.payment_status===`paid`?null:(0,o.jsx)(u.DefaultDropdownActionButton,{onClick:e,"aria-label":`Delete`,title:`Delete`,className:`bg-marble rounded-full p-2 hover:bg-sand transition-all`,children:(0,o.jsx)(l.TrashSimpleIcon,{size:16,weight:`light`,"aria-hidden":!0})})},er=()=>{let{handleFlag:e}=(0,a.useMessageContext)(`CustomMessageActions`);return(0,o.jsx)(u.DefaultDropdownActionButton,{onClick:e,"aria-label":`Report`,title:`Report`,className:`bg-marble rounded-full p-2 hover:bg-sand transition-all`,children:(0,o.jsx)(l.FlagIcon,{size:16,weight:`light`,"aria-hidden":!0})})},tr=()=>{let{message:e}=(0,a.useMessageContext)(`CustomMessageActions`);return e.metadata?.custom_type===s.MESSAGE_CUSTOM_TYPE.ATTACHMENT?(0,o.jsx)(u.MessageActions,{messageActionSet:[{Component:$n,placement:`quick`,type:`delete`},{Component:er,placement:`quick`,type:`flag`}]}):null},nr=e=>({linkPreviews:Array.from(e.previews.values()).filter(e=>i.LinkPreviewsManager.previewIsLoaded(e)||i.LinkPreviewsManager.previewIsLoading(e))}),rr=()=>{let{linkPreviewsManager:e}=(0,a.useMessageComposer)(),{linkPreviews:t}=(0,a.useStateStore)(e.state,nr),n=t=>{e.dismissPreview(t)};return t.length>0?(0,o.jsx)(`div`,{"data-testid":`link-preview-list`,className:`messaging-link-preview-list flex flex-col items-stretch w-full gap-2`,children:t.map(e=>{let t=i.LinkPreviewsManager.previewIsLoading(e);return(0,o.jsx)(xe.Composer,{title:e.title,url:e.og_scrape_url,thumbnailUrl:e.image_url,layout:t||e.image_url?`featured`:`classic`,status:t?`loading`:`ready`,onDismiss:()=>n(e.og_scrape_url)},e.og_scrape_url)})}):null},ir=n.default.createContext(!1),ar=200,or=()=>(0,n.useContext)(ir),sr=({sendMessage:e,disabled:t,...n})=>(0,o.jsx)(`button`,{...n,type:`button`,"aria-label":`Send`,disabled:t,onPointerDown:e=>e.preventDefault(),onClick:e,children:(0,o.jsx)(l.ArrowUpIcon,{weight:`bold`,className:`size-4`})}),cr=()=>{let e=(0,n.useContext)(ir),{handleSubmit:t}=(0,a.useMessageInputContext)(),r=(0,a.useMessageComposerHasSendableData)(),i=e||!r,{SendButton:s=sr,AttachmentPreviewList:c=a.AttachmentPreviewList}=(0,a.useComponentContext)(`CustomMessageInput`),l=n.default.useRef(null);return n.default.useEffect(()=>{let e=l.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(()=>{e.contains(document.activeElement)&&(e.scrollTop=e.scrollHeight)});return t.observe(e),()=>t.disconnect()},[]),n.default.useEffect(()=>{let e=l.current;if(!e)return;let t=e=>{Array.from(e.clipboardData?.items??[]).some(e=>e.kind===`file`)||e.stopPropagation()};return e.addEventListener(`paste`,t),()=>e.removeEventListener(`paste`,t)},[]),(0,o.jsxs)(`div`,{ref:l,"data-testid":`composer-card`,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:[(0,o.jsxs)(`div`,{"data-testid":`composer-previews`,className:`messaging-composer-previews empty:hidden flex flex-col gap-2 px-2 pt-2`,children:[(0,o.jsx)(a.QuotedMessagePreview,{}),(0,o.jsx)(rr,{}),(0,o.jsx)(c,{})]}),(0,o.jsxs)(`div`,{"data-testid":`composer-row`,className:`messaging-composer-row flex items-start`,children:[(0,o.jsx)(a.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}),(0,o.jsx)(`div`,{"data-testid":`send-button-wrapper`,className:`sticky bottom-2 mt-auto mb-2 mr-2 shrink-0 pt-2`,children:(0,o.jsx)(s,{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:i,type:`button`})})]})]})},lr=()=>(0,o.jsxs)(`div`,{className:`messaging-composer-backdrop`,"aria-hidden":`true`,children:[(0,o.jsx)(`div`,{className:`messaging-composer-backdrop-blur`}),(0,o.jsx)(`div`,{className:`messaging-composer-backdrop-blur`}),(0,o.jsx)(`div`,{className:`messaging-composer-backdrop-blur`}),(0,o.jsx)(`div`,{className:`messaging-composer-backdrop-blur`}),(0,o.jsx)(`div`,{className:`messaging-composer-backdrop-blur`}),(0,o.jsx)(`div`,{className:`messaging-composer-backdrop-gradient`})]}),ur=({renderActions:e,renderHeader:t,renderFooter:r,disabled:i=!1,disabledReason:s,composerInput:c})=>{let{channel:l}=(0,a.useChannelStateContext)(),u=l?.data?.frozen===!0,d=!!c,f=n.default.useRef(null);return n.default.useEffect(()=>{if(!d)return;let e=f.current,t=e?.parentElement;if(!e||!t)return;let n=e.offsetHeight,r=()=>{let r=e.offsetHeight,i=r>n;n=r;let a=Array.from(t.querySelectorAll(`.str-chat__list`)).find(e=>e.scrollHeight>e.clientHeight)??null,o=a?a.scrollHeight-a.scrollTop-a.clientHeight<ar:!1;t.style.setProperty(`--messaging-composer-height`,`${r}px`),i&&o&&a&&(a.scrollTop=a.scrollHeight)};if(r(),typeof ResizeObserver>`u`)return;let i=new ResizeObserver(r);return i.observe(e),()=>{i.disconnect(),t.style.removeProperty(`--messaging-composer-height`)}},[d]),i?d?(0,o.jsxs)(`div`,{ref:f,"data-testid":`composer-chrome`,className:`messaging-composer-chrome messaging-composer-chrome--floating`,children:[(0,o.jsx)(lr,{}),(0,o.jsxs)(`div`,{className:`relative z-10 flex flex-col`,children:[t?.(),(0,o.jsx)(`div`,{"data-testid":`composer-locked-panel`,className:`messaging-composer-locked-panel flex w-full flex-col items-center justify-center gap-3 px-6 py-4`,children:s?(0,o.jsx)(`p`,{className:`max-w-[345px] text-center text-xs font-normal leading-[1.3] tracking-[0.12px] text-black/40`,children:s}):null}),r?.()]})]}):(0,o.jsxs)(o.Fragment,{children:[t?.(),(0,o.jsx)(`div`,{"data-testid":`composer-locked-panel`,className:`messaging-composer-locked-panel flex w-full flex-col items-center justify-center gap-3 px-6 py-4`,children:s?(0,o.jsx)(`p`,{className:`max-w-[345px] text-center text-xs font-normal leading-[1.3] tracking-[0.12px] text-black/40`,children:s}):null}),r?.()]}):d?(0,o.jsxs)(`div`,{ref:f,"data-testid":`composer-chrome`,className:`messaging-composer-chrome messaging-composer-chrome--floating`,children:[(0,o.jsx)(lr,{}),(0,o.jsxs)(`div`,{className:`relative z-10 flex min-h-0 flex-col`,children:[t?.(),(0,o.jsxs)(`div`,{className:`flex min-h-0 flex-col gap-4 p-3 pb-5 md:p-5`,children:[(0,o.jsxs)(`div`,{inert:u?``:void 0,"aria-disabled":u||void 0,"data-testid":`message-input`,className:`message-input flex min-h-0 items-end gap-4 aria-disabled:opacity-40`,children:[e&&(0,o.jsx)(`div`,{className:`flex h-12 shrink-0 items-center justify-center`,children:e()}),(0,o.jsx)(ir.Provider,{value:u,children:(0,o.jsx)(a.MessageInput,{Input:c??cr})})]}),r?.()]})]})]}):(0,o.jsxs)(`div`,{className:`flex min-h-0 flex-col gap-4 p-4`,children:[t?.(),(0,o.jsxs)(`div`,{inert:u?``:void 0,"aria-disabled":u||void 0,"data-testid":`message-input`,className:`message-input flex min-h-0 items-end gap-4 aria-disabled:opacity-40`,children:[e&&(0,o.jsx)(`div`,{className:`flex h-12 shrink-0 items-center justify-center`,children:e()}),(0,o.jsx)(ir.Provider,{value:u,children:(0,o.jsx)(a.MessageInput,{Input:cr})})]}),r?.()]})},dr={SYSTEM_DM_AGENT_PAUSED:`DM Agent has left the conversation`,SYSTEM_DM_AGENT_RESUMED:`DM Agent has rejoined the conversation`},fr=[`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.`},mr=`age safety guidelines.`,hr=`https://linktr.ee/s/about/contact`,gr=e=>fr.includes(e),_r=e=>gr(e.metadata?.custom_type),vr=e=>{let t=e.metadata?.custom_type;if((0,s.isDmAgentSystemType)(t))return{kind:`dm-agent`,type:t};if((0,s.isAgeSafetySystemType)(t))return{kind:`age-safety`,type:t};let n=e.dm_agent_system_type;if((0,s.isDmAgentSystemType)(n))return{kind:`dm-agent`,type:n}},yr=e=>{let t=e.indexOf(mr);if(t===-1)return e;let n=t+22;return(0,o.jsxs)(o.Fragment,{children:[e.slice(0,t),(0,o.jsx)(`a`,{href:hr,target:`_blank`,rel:`noopener noreferrer`,className:`mes-age-safety-system-message__emphasis font-medium text-inherit underline`,children:mr}),e.slice(n)]})},br=e=>{let t=!_r(e.message),n=vr(e.message);if(n?.kind===`dm-agent`){let r=e.message.text?.trim()||dr[n.type];return(0,o.jsxs)(`div`,{className:`str-chat__message--system`,"data-testid":`message-system`,children:[(0,o.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:[(0,o.jsx)(l.SparkleIcon,{size:16,weight:`regular`,"aria-hidden":!0,className:`mes-dm-agent-system-message__sparkle shrink-0`}),(0,o.jsx)(`p`,{className:`mes-dm-agent-system-message__text m-0 text-center text-[14px] font-normal leading-5 tracking-[0.21px]`,children:r})]}),!t&&(0,o.jsx)(a.MessageTimestamp,{message:e.message})]})}if(n?.kind===`age-safety`){let r=e.message.text?.trim()||pr[n.type];return(0,o.jsxs)(`div`,{className:`str-chat__message--system`,"data-testid":`message-system`,children:[(0,o.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:[(0,o.jsx)(l.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`}),(0,o.jsx)(`div`,{className:`mes-age-safety-system-message__content min-w-0 flex-[1_0_0]`,children:(0,o.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:yr(r)})})]}),!t&&(0,o.jsx)(a.MessageTimestamp,{message:e.message})]})}return(0,o.jsxs)(`div`,{className:`str-chat__message--system`,"data-testid":`message-system`,children:[(0,o.jsxs)(`div`,{className:`str-chat__message--system__text`,children:[(0,o.jsx)(`div`,{className:`str-chat__message--system__line`}),(0,o.jsx)(`p`,{children:e.message.text}),(0,o.jsx)(`div`,{className:`str-chat__message--system__line`})]}),!t&&(0,o.jsx)(a.MessageTimestamp,{message:e.message})]})},xr=(0,n.createContext)(!1),Sr=({cx:e,index:t})=>(0,o.jsx)(`circle`,{cx:e,cy:`6.15`,r:`3.9`,fill:`#A0A0A0`,children:(0,o.jsx)(`animateTransform`,{attributeName:`transform`,type:`translate`,values:`0 0; 0 -2.25; 0 0;`,dur:`900ms`,begin:`${120*t}ms`,repeatCount:`indefinite`})}),Cr=new Set([a.AIStates.Thinking,a.AIStates.Generating,a.AIStates.ExternalSources]),wr=({threadList:e})=>{let{channel:t,channelConfig:r,thread:i}=(0,a.useChannelStateContext)(),{client:s}=(0,a.useChatContext)(),{typing:c={}}=(0,a.useTypingContext)(),{aiState:l}=(0,a.useAIState)(t),u=(0,n.useContext)(xr);if(!e&&u&&Cr.has(l)){let e=Er(t,s.user?.id);return(0,o.jsx)(Tr,{avatarId:e?.id??`ai-agent`,avatarName:e?.name??e?.id??`Agent`,avatarImage:e?.image,testId:`typing-indicator-ai`})}if(r?.typing_events===!1)return null;let d=e?[]:Object.values(c).filter(({parent_id:e,user:t})=>t?.id!==s.user?.id&&!e),f=e?Object.values(c).filter(({parent_id:e,user:t})=>t?.id!==s.user?.id&&e===i?.id):[],p=e?f:d;if(!p.length)return null;let m=p[0]?.user,h=m?.id&&t.state.members[m.id]?t.state.members[m.id].user:void 0;return(0,o.jsx)(Tr,{avatarId:m?.id??h?.id??`typing-user`,avatarName:m?.name??h?.name??m?.id??`Typing user`,avatarImage:m?.image??h?.image,testId:`typing-indicator`})},Tr=({avatarId:e,avatarName:t,avatarImage:n,testId:r})=>(0,o.jsx)(`div`,{className:`str-chat__li str-chat__li--single str-chat__typing-indicator !static`,"data-testid":r,style:{marginBottom:`var(--messaging-channel-input-spacer-height, 80px)`},children:(0,o.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:[(0,o.jsx)(j,{className:`str-chat__avatar str-chat__message-sender-avatar`,id:e,name:t,image:n??void 0,size:24,shape:`circle`}),(0,o.jsx)(`div`,{className:`str-chat__message-inner mx-0`,children:(0,o.jsx)(`div`,{className:`str-chat__message-bubble-wrapper`,children:(0,o.jsxs)(`div`,{className:`str-chat__message-bubble relative isolate`,children:[(0,o.jsx)(`div`,{className:`str-chat__message-text min-h-11 flex items-center`,children:(0,o.jsx)(`div`,{className:`str-chat__message-text-inner str-chat__message-simple-text-inner`,children:(0,o.jsxs)(`svg`,{"aria-hidden":`true`,className:`block overflow-visible`,viewBox:`0 0 32 12.3`,width:`32`,height:`13`,overflow:`visible`,children:[(0,o.jsx)(Sr,{cx:`4`,index:0}),(0,o.jsx)(Sr,{cx:`16`,index:1}),(0,o.jsx)(Sr,{cx:`28`,index:2})]})})}),(0,o.jsx)(Ve,{side:`other`})]})})})]})});function Er(e,t){let n=e?.state?.members??{};for(let e of Object.values(n)){let n=e?.user;if(n&&n.id!==t)return n}}var Dr=()=>null,Or=({className:e,message:t})=>(0,o.jsxs)(`div`,{className:(0,c.default)(`flex items-center justify-center h-full`,e),children:[(0,o.jsxs)(`svg`,{viewBox:`0 0 100 100`,className:`size-8 fill-pebble`,stroke:`none`,children:[(0,o.jsx)(`circle`,{cx:`6`,cy:`50`,r:`6`,children:(0,o.jsx)(`animateTransform`,{attributeName:`transform`,dur:`1s`,type:`translate`,values:`0 15 ; 0 -15; 0 15`,repeatCount:`indefinite`,begin:`0.1`})}),(0,o.jsx)(`circle`,{cx:`30`,cy:`50`,r:`6`,children:(0,o.jsx)(`animateTransform`,{attributeName:`transform`,dur:`1s`,type:`translate`,values:`0 10 ; 0 -10; 0 10`,repeatCount:`indefinite`,begin:`0.2`})}),(0,o.jsx)(`circle`,{cx:`54`,cy:`50`,r:`6`,children:(0,o.jsx)(`animateTransform`,{attributeName:`transform`,dur:`1s`,type:`translate`,values:`0 5 ; 0 -5; 0 5`,repeatCount:`indefinite`,begin:`0.3`})})]}),t&&(0,o.jsx)(`span`,{className:`text-stone`,children:t})]}),kr=n.default.memo(()=>(0,o.jsx)(`div`,{className:`messaging-loading-state flex items-center justify-center h-full`,children:(0,o.jsxs)(`div`,{className:`flex items-center`,children:[(0,o.jsx)(Or,{className:`w-6 h-6`}),(0,o.jsx)(`span`,{className:`text-sm text-stone`,children:`Loading messages`})]})}));kr.displayName=`LoadingState`;var Ar=({onBack:e,showBackButton:t,renderMessageInputActions:r,renderMessageInputFooter:i,renderConversationFooter:s,onLeaveConversation:c,onBlockParticipant:l,showDeleteConversation:u=!0,onDeleteConversationClick:d,onBlockParticipantClick:f,onReportParticipantClick:p,showBlockParticipant:m=!0,showReportParticipant:h=!0,composerDisabled:g=!1,composerDisabledReason:_,showStarButton:v=!1,renderChannelBanner:y,customChannelActions:b,renderChannelActions:x,renderMessage:S,viewerLanguage:C,showChannelInfo:w=!0,onParticipantNameClick:T,onOutboundClick:E,resolveOutbound:D,composerInput:O})=>{let{channel:k,messages:A}=(0,a.useChannelStateContext)(),j=(0,n.useRef)(E);(0,n.useEffect)(()=>{j.current=E},[E]);let M=(0,n.useCallback)(e=>{j.current?.(e)},[]),N=E?M:void 0,P=Ke(A,D),F=k.state.messages.some(e=>e.type!==`deleted`),I=y?(0,o.jsx)(n.default.Fragment,{children:y()},`lt-channel-banner`):null,L=(0,o.jsx)(ee,{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:w,showStarButton:v,onLeaveConversation:c,onBlockParticipant:l,showDeleteConversation:u,showBlockParticipant:m,showReportParticipant:h,onDeleteConversationClick:d,onBlockParticipantClick:f,onReportParticipantClick:p,customChannelActions:b,renderChannelActions:x,onParticipantNameClick:T}),R=(0,n.useCallback)(e=>{let{message:t}=(0,a.useMessageContext)(`ChannelView`),n=(0,o.jsx)(Qn,{...e,viewerLanguage:C,onOutboundClick:N});return!S||!t?n:S(n,t)},[N,S,C]);return(0,o.jsx)(He.Provider,{value:P,children:(0,o.jsx)(a.WithComponents,{overrides:{Message:R,MessageActions:tr,UnreadMessagesNotification:()=>null,UnreadMessagesSeparator:()=>null},children:(0,o.jsx)(a.Window,{children:O?(0,o.jsxs)(`div`,{className:`messaging-channel-layout relative flex min-h-0 flex-1 flex-col`,children:[(0,o.jsxs)(`div`,{className:`messaging-channel-message-list messaging-channel-message-list--floating relative min-h-0 flex-1 overflow-hidden`,children:[!F&&(0,o.jsx)(`div`,{className:`str-chat__list`,children:(0,o.jsxs)(`div`,{className:`str-chat__message-list-scroll`,children:[L,I]})}),(0,o.jsx)(a.MessageList,{head:F?(0,o.jsxs)(`div`,{className:`sticky top-0 z-10`,children:[L,I]}):void 0,hideDeletedMessages:!0,hideNewMessageSeparator:!1})]},`lt-channel-message-list`),(0,o.jsx)(ur,{...r&&{renderActions:()=>r?.(k)},...s&&{renderHeader:()=>s(k)},renderFooter:()=>i?.(k),disabled:g,disabledReason:_,composerInput:O},`lt-channel-message-input`)]}):(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(`div`,{className:`flex-1 overflow-hidden relative`,children:[!F&&(0,o.jsx)(`div`,{className:`str-chat__list`,children:(0,o.jsxs)(`div`,{className:`str-chat__message-list-scroll`,children:[L,I]})}),(0,o.jsx)(a.MessageList,{head:F?(0,o.jsxs)(`div`,{className:`sticky top-0 z-10`,children:[L,I]}):void 0,hideDeletedMessages:!0,hideNewMessageSeparator:!1})]},`lt-channel-message-list`),s?(0,o.jsx)(n.default.Fragment,{children:s(k)},`lt-channel-conversation-footer`):null,(0,o.jsx)(ur,{...r&&{renderActions:()=>r?.(k)},renderFooter:()=>i?.(k),disabled:g,disabledReason:_,composerInput:O},`lt-channel-message-input`)]})})})})},jr=n.default.memo(({channel:e,onBack:t,showBackButton:r=!1,renderMessageInputActions:i,renderMessageInputFooter:l,renderConversationFooter:u,onLeaveConversation:d,onBlockParticipant:f,className:p,CustomChannelEmptyState:m=Dr,showDeleteConversation:h=!0,onDeleteConversationClick:g,onBlockParticipantClick:_,onReportParticipantClick:v,showBlockParticipant:y=!0,showReportParticipant:b=!0,composerDisabled:x=!1,composerDisabledReason:S,dmAgentEnabled:C,messageMetadata:w,onMessageSent:T,showStarButton:E=!1,renderChannelBanner:D,customChannelActions:O,renderChannelActions:k,renderMessage:A,onMessageLinkClick:j,sendButton:M,attachmentPreviewList:N,viewerLanguage:P,showChannelInfo:F=!0,onParticipantNameClick:I,onOutboundClick:L,resolveOutbound:R,composerInput:ee})=>{let z=(0,n.useCallback)(async(t,n,r)=>{let i=e.data?.chatbot_paused===!0,a=C&&!i,o={...n,...a&&{silent:!0},...w&&{metadata:{...n.metadata??{},...w}}},s={...r,...a&&{skip_push:!0}},c=await e.sendMessage(o,s);return T?.(c),c},[e,C,w,T]),B=(0,n.useRef)(null);(0,n.useEffect)(()=>{if(!j)return;let t=B.current;if(!t)return;let n=t=>{let n=t.target?.closest(`a[href]`),r=n?.getAttribute(`href`);if(!r)return;let i=(n?.closest(`[data-message-id]`))?.getAttribute(`data-message-id`);j(r,i?e.state.messages.find(e=>e.id===i):void 0)};return t.addEventListener(`click`,n),()=>t.removeEventListener(`click`,n)},[j,e]);let V=(0,s.isOfficialChannel)(e.type)?{"--lt-msg-card-width":`368px`}:void 0;return(0,o.jsx)(`div`,{ref:B,"data-testid":`channel-view`,className:(0,c.default)(`messaging-channel-view h-full flex flex-col`,p),style:V,children:(0,o.jsx)(xr.Provider,{value:C??!1,children:(0,o.jsx)(a.Channel,{channel:e,MessageSystem:br,EmptyStateIndicator:m,LoadingIndicator:kr,DateSeparator:te,TypingIndicator:wr,doSendMessageRequest:z,...M?{SendButton:M}:{},...N?{AttachmentPreviewList:N}:{},children:(0,o.jsx)(Ar,{onBack:t,showBackButton:r,renderMessageInputActions:i,renderMessageInputFooter:l,renderConversationFooter:u,onLeaveConversation:d,onBlockParticipant:f,CustomChannelEmptyState:m,showDeleteConversation:h,onDeleteConversationClick:g,onBlockParticipantClick:_,onReportParticipantClick:v,showBlockParticipant:y,showReportParticipant:b,composerDisabled:x,composerDisabledReason:S,showStarButton:E,renderChannelBanner:D,customChannelActions:O,renderChannelActions:k,renderMessage:A,viewerLanguage:P,showChannelInfo:F,onParticipantNameClick:I,onOutboundClick:L,resolveOutbound:R,composerInput:ee})})})})});jr.displayName=`ChannelView`;var Mr=n.default.memo(({message:e,onBack:t})=>(0,o.jsx)(`div`,{className:`messaging-error-state flex items-center justify-center h-full p-8`,children:(0,o.jsxs)(`div`,{className:`text-center max-w-sm`,children:[(0,o.jsx)(`div`,{className:`w-24 h-24 bg-danger-alt/20 rounded-full flex items-center justify-center mx-auto mb-6`,children:(0,o.jsx)(`span`,{className:`text-4xl`,children:`⚠️`})}),(0,o.jsx)(`h2`,{className:`font-semibold text-charcoal mb-2`,children:`Oops!`}),(0,o.jsx)(`p`,{className:`text-stone text-sm mb-6`,children:e}),t&&(0,o.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`})]})}));Mr.displayName=`ErrorState`;var Nr=({capabilities:e={},renderMessageInputActions:t,renderConversationFooter:r,onChannelSelect:i,onExitConversation:a,initialParticipantFilter:s,initialParticipantData:c,CustomChannelEmptyState:l,onBlockParticipantClick:u,onReportParticipantClick:d,dmAgentEnabled:f,onMessageSent:p,viewerLanguage:m,renderChannelBanner:h,customChannelActions:g,renderChannelActions:_,onParticipantNameClick:v,onOutboundClick:b,resolveOutbound:x,renderMessage:S,onMessageLinkClick:C,showChannelInfo:w,composerInput:T,attachmentPreviewList:E})=>{let{client:D,isConnected:O,isLoading:k,error:A,refreshConnection:j,service:M,debug:N}=y(),[P,F]=(0,n.useState)(null),[I,L]=(0,n.useState)(null),[R,ee]=(0,n.useState)(!1),{showDeleteConversation:te=!0}=e,z=(0,n.useRef)(c);z.current=c;let B=(0,n.useRef)(i);B.current=i;let V=(0,n.useRef)(null),ne=(0,n.useRef)(null);(0,n.useEffect)(()=>{ne.current=P},[P]),(0,n.useEffect)(()=>{if(!D||!O)return;let e=D.userID;if(!e)return;let t=`${e}::${s}`;if(V.current===t)return;V.current=t;let n=()=>{V.current===t&&(V.current=null)};(async()=>{try{N&&console.log(`[MessagingShell] Loading initial conversation with:`,s);let t=await D.queryChannels({type:`messaging`,members:{$eq:[e,s]}},{},{limit:1});if(t.length>0){F(t[0]),L(null),B.current?.(t[0]),N&&console.log(`[MessagingShell] Initial conversation loaded:`,t[0].id);return}let r=z.current;if(!r||!M){n(),L(`No conversation found with this account`),N&&console.log(`[MessagingShell] No conversation found for:`,s);return}try{let e=await M.startChannelWithParticipant({id:r.id,name:r.name,phone:r.phone});F(e),L(null),B.current?.(e),N&&console.log(`[MessagingShell] Channel created and loaded:`,e.id)}catch(e){console.error(`[MessagingShell] Failed to create conversation:`,e),n(),L(`Failed to create conversation`)}}catch(e){console.error(`[MessagingShell] Failed to load initial conversation:`,e),n(),ne.current||L(`Failed to load conversation`)}})()},[s,D,O,M,N]);let H=(0,n.useRef)(a);H.current=a;let re=(0,n.useCallback)(()=>{F(null),ee(!0),H.current?.()},[]);return k?(0,o.jsx)(kr,{}):A?(0,o.jsx)(Mr,{message:A,onBack:j}):!O||!D?(0,o.jsx)(Mr,{message:`Not connected to messaging service`,onBack:j}):I?(0,o.jsx)(Mr,{message:I}):R&&!P?(0,o.jsx)(Mr,{message:`Conversation ended`}):P?(0,o.jsx)(`div`,{className:`messaging-shell h-full bg-background-primary overflow-hidden`,children:(0,o.jsx)(`div`,{className:`flex h-full min-h-0 flex-col`,children:(0,o.jsx)(jr,{channel:P,renderMessageInputActions:t,renderConversationFooter:r,renderChannelBanner:h,onLeaveConversation:re,onBlockParticipant:re,CustomChannelEmptyState:l,showDeleteConversation:te,onBlockParticipantClick:u,onReportParticipantClick:d,dmAgentEnabled:f,onMessageSent:p,viewerLanguage:m,customChannelActions:g,renderChannelActions:_,onParticipantNameClick:v,onOutboundClick:b,resolveOutbound:x,renderMessage:S,onMessageLinkClick:C,showChannelInfo:w,composerInput:T,attachmentPreviewList:E},P.id)})}):(0,o.jsx)(kr,{})};function Pr(e){let t=e.state.pending_messages;if(t?.length)for(let n of t)e.state.addMessageSorted(n.message)}var Fr=n.default.createContext({selectedChannel:void 0,onChannelSelect:()=>{},debug:!1,renderMessagePreview:void 0,channelPreview:void 0,viewerLanguage:void 0}),Ir=Fr.Provider,Lr=()=>n.default.useContext(Fr),Rr=(e,t)=>{let n=Date.UTC(e.getFullYear(),e.getMonth(),e.getDate()),r=Date.UTC(t.getFullYear(),t.getMonth(),t.getDate());return Math.floor((r-n)/864e5)},zr=e=>{let t=new Date;if(Math.floor((t.getTime()-e.getTime())/1e3)<60)return`Just now`;let n=Rr(e,t);return n===0?e.toLocaleTimeString([],{hour:`numeric`,minute:`2-digit`,hour12:!0}):n===1?`Yesterday`:n<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`})},Br=n.default.memo(e=>{let{channel:t,unread:n}=e,{selectedChannel:r,onChannelSelect:i,debug:l,channelPreview:u,renderMessagePreview:d,viewerLanguage:f}=Lr(),{client:p}=(0,a.useChatContext)(),m=r?.id===t?.id,h=b(t);if(u)return(0,o.jsx)(u,{...e,active:m,selectedChannel:r,onChannelSelect:i,viewerLanguage:f});let g=()=>{t&&i(t)},_=e=>{let t=e.key===`Enter`||e.key===` `,n=e.repeat;!t||n||(e.preventDefault(),g())},v=x(t?.state?.members,p?.userID,t?.type),y=T(v?.user),S=v?.user?.image,C=(()=>{let e=t?.state?.messages;if(e?.length){for(let t=e.length-1;t>=0;t--)if(e[t].type!==`system`)return e[t]}})(),w=(()=>{let e=B({message:C,viewerLanguage:f}),{custom_type:t,attachment_content_type:n}=C?.metadata||{};if(t===s.MESSAGE_CUSTOM_TYPE.TIP)return e||`Sent a tip`;if(t===s.MESSAGE_CUSTOM_TYPE.PAID)return e||`Sent a message`;if(t===s.MESSAGE_CUSTOM_TYPE.ATTACHMENT){if(n===`text`)return`🔒 Sent a locked message`;if(n===`media`)return`🔒 Sent a locked attachment`}if(e)return e;let r=C?.attachments?.[0];return r?r.og_scrape_url?r.og_scrape_url:r.type===`image`?`📷 Sent an image`:r.type===`video`?`🎥 Sent a video`:r.type===`audio`?`🎵 Sent audio`:r.type===`file`?`📎 Sent a file`:`📎 Sent an attachment`:`No messages yet`})(),E=C?.created_at?zr(new Date(C.created_at)):``,D=C?Ne(C):!1,O=d?d(C,w):`${D?`✨ `:``}${w}`,k=n??0;return l&&console.log(`📺 [ChannelList] 📋 CHANNEL PREVIEW RENDER`,{channelId:t?.id,isSelected:m,participantName:y,unreadCount:k,hasTimestamp:!!E}),(0,o.jsx)(`div`,{role:`button`,tabIndex:0,onClick:g,onKeyDown:_,className:(0,c.default)(`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]":m,"hover:bg-black/[0.02]":!m}),"data-dd-privacy":`mask`,children:(0,o.jsxs)(`div`,{className:`flex items-start gap-4`,children:[(0,o.jsx)(j,{id:v?.user?.id||t.id||`unknown`,name:y,image:S,size:48,starred:h}),(0,o.jsxs)(`div`,{className:`flex-1 min-w-0 flex flex-col gap-1`,children:[(0,o.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,o.jsxs)(`h3`,{className:(0,c.default)(`text-sm font-medium truncate text-[#191918]`),children:[h&&(0,o.jsx)(`span`,{className:`sr-only`,children:`Starred conversation. `}),y]}),E&&(0,o.jsx)(`span`,{"data-testid":`channel-preview-timestamp`,className:`text-xs text-[#717070] flex-shrink-0`,children:E})]}),(0,o.jsxs)(`div`,{className:`flex items-center justify-between gap-2 min-w-0`,children:[(0,o.jsx)(`p`,{className:`text-sm text-[#717070] flex-1 line-clamp-1`,children:O}),k>0&&(0,o.jsx)(`span`,{"data-testid":`channel-preview-unread-badge`,className:`bg-[#7f22fe] text-white text-[10px] rounded-full h-4 flex items-center justify-center p-1 min-w-4 text-center flex-shrink-0`,children:k>99?`99+`:k})]})]})]})})});Br.displayName=`CustomChannelPreview`;var Vr={last_message_at:-1},Hr=n.default.memo(({onChannelSelect:e,selectedChannel:t,filters:r,allowNewMessagesFromUnfilteredChannels:i=!1,channelRenderFilterFn:s,sort:l=Vr,className:u,customEmptyStateIndicator:d,channelListPaginator:f=a.InfiniteScroll,channelPreview:p,renderMessagePreview:m,viewerLanguage:h,lockChannelOrder:g,onMessageNewHandler:v,onMessageNew:y,onChannelVisible:b,onAddedToChannel:x,onChannelUpdated:S})=>{let C=n.default.useRef(0);C.current++;let{debug:w=!1}=_(),T=n.default.useCallback(e=>{for(let t of e)Pr(t);return s?s(e):e},[s]);w&&console.log(`📺 [ChannelList] 🔄 RENDER START`,{renderCount:C.current,selectedChannelId:t?.id,filters:r});let E=n.default.useMemo(()=>({selectedChannel:t,onChannelSelect:e,debug:w,channelPreview:p,renderMessagePreview:m,viewerLanguage:h}),[t,e,w,p,m,h]);return(0,o.jsx)(`div`,{className:(0,c.default)(`messaging-channel-list h-full flex flex-col min-w-0 overflow-hidden`,u),children:(0,o.jsx)(`div`,{className:`flex-1 overflow-hidden min-w-0`,children:(0,o.jsx)(Ir,{value:E,children:(0,o.jsx)(a.ChannelList,{filters:r,sort:l,options:{limit:30},allowNewMessagesFromUnfilteredChannels:i,channelRenderFilterFn:T,lockChannelOrder:g,onMessageNewHandler:v,onMessageNew:y,onChannelVisible:b,onAddedToChannel:x,onChannelUpdated:S,Paginator:f,Preview:Br,EmptyStateIndicator:d},`${JSON.stringify(r)}:${JSON.stringify(l)}`)})})})});Hr.displayName=`ChannelList`;var Ur=`line-clamp-2 text-[14px] font-medium leading-5 tracking-[0.02em]`,Wr=`text-[14px] leading-5 tracking-[0.02em]`,Gr=()=>(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`br`,{}),(0,o.jsx)(`span`,{"aria-hidden":!0,className:`block h-1.5`})]}),Kr=e=>e.split(/\r?\n/).map((e,t,r)=>(0,o.jsxs)(n.default.Fragment,{children:[e,t<r.length-1?(0,o.jsx)(Gr,{}):null]},t)),qr=({surface:e,actions:t,layout:n})=>{if(t==null||t.length===0)return null;let r=n===`stacked`;return(0,o.jsx)(`div`,{className:(0,c.default)(`flex gap-2`,r?`mt-4 flex-col`:`min-w-0 max-w-[60%] flex-row flex-wrap justify-end`),children:t.map((t,n)=>(0,o.jsx)(ie,{variant:e,cta:t,fullWidth:r,standalone:!0},`${t.label}-${n}`))})},Jr=({ctaSurface:e,chinTextColor:t,title:n,subtitle:r,subtitleLines:i=3,appIcon:a,actions:s})=>{let l=n!=null&&n.trim()!==``,u=r!=null&&r.trim()!==``,d=s!=null&&s.length>0;if(!l&&!u&&!d)return null;let f={color:t},p=i>1?{...f,display:`-webkit-box`,WebkitBoxOrient:`vertical`,WebkitLineClamp:i,overflow:`hidden`}:f,m=d&&(s?.[0]?.variant??`primary`)===`secondary`,h=(0,o.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-4`,children:[l&&(0,o.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[a?(0,o.jsx)(`span`,{className:`shrink-0`,children:a}):null,(0,o.jsx)(`p`,{className:(0,c.default)(`min-w-0`,Ur),style:f,children:n})]}),u&&(0,o.jsx)(`p`,{className:(0,c.default)(Wr,i<=1&&`truncate`),style:p,children:i>1?Kr(r??``):r})]});return(0,o.jsx)(`div`,{className:`shrink-0 px-4 py-3`,children:m?(0,o.jsxs)(`div`,{"data-testid":`rich-card-chin-row`,className:`flex items-center justify-between gap-3`,children:[h,(0,o.jsx)(qr,{surface:e,actions:s,layout:`row`})]}):(0,o.jsxs)(o.Fragment,{children:[h,(0,o.jsx)(qr,{surface:e,actions:s,layout:`stacked`})]})})},Yr={dark:`bg-white/[0.06]`,light:`bg-black/[0.04]`},Xr={1:[0],2:[-10,10],3:[-13,0,13]},Zr={1:[0],2:[-26,26],3:[-40,0,40]},Qr={1:[0],2:[0,1],3:[1,3,2]},$r={1:[1],2:[1,1],3:[1,1.08,1]},ei=({variant:e,images:r})=>{let[i,a]=n.default.useState({}),s=r.join(`
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./rolldown-runtime-BocRIvOZ.cjs"),t=require("./AttachmentCard-ZpYg622K.cjs");let n=require("react");n=e.t(n,1);let r=require("@linktr.ee/messaging-core"),i=require("stream-chat"),a=require("stream-chat-react"),o=require("react/jsx-runtime"),s=require("@linktr.ee/messaging-taxonomy"),c=require("classnames");c=e.t(c,1);let l=require("@phosphor-icons/react"),u=require("stream-chat-react/experimental");var d={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)},f=e=>({debug:e?.debug??d.debug,info:e?.info??d.info,warn:e?.warn??d.warn,error:e?.error??d.error}),p=(0,n.createContext)(d),m=({logger:e,children:t})=>{let r=(0,n.useMemo)(()=>f(e),[e]);return(0,o.jsx)(p.Provider,{value:r,children:t})},h=()=>(0,n.useContext)(p),g=(0,n.createContext)({service:null,client:null,isConnected:!1,isLoading:!1,error:null,capabilities:{},refreshConnection:async()=>{},debug:!1}),_=()=>(0,n.useContext)(g),v=({children:e,user:t,serviceConfig:s,apiKey:c,capabilities:l={},debug:u=!1,client:d,logger:p})=>{let h=(0,n.useCallback)((e,...t)=>{u&&console.log(`🔥 [MessagingProvider] ${e}`,...t)},[u]);h(`🔄 RENDER START`,{userId:t?.id,apiKey:c?.substring(0,8)+`...`,serviceConfig:!!s,capabilities:Object.keys(l)});let[_,v]=(0,n.useState)(null),[y,b]=(0,n.useState)(null),[x,S]=(0,n.useState)(!1),[C,w]=(0,n.useState)(!1),[T,E]=(0,n.useState)(null),D=(0,n.useRef)(!1),O=(0,n.useRef)(null),k=(0,n.useRef)(s);k.current=s;let A=(0,n.useRef)(u);A.current=u;let j=(0,n.useRef)(p);j.current=p;let M=(0,n.useRef)({userId:t?.id,apiKey:c,serviceConfig:s,capabilities:l}),N=(0,n.useRef)(0);N.current++,h(`📊 RENDER INFO`,{renderCount:N.current,currentProps:{userId:t?.id,apiKey:c?.substring(0,8)+`...`},propChanges:{userChanged:M.current.userId!==t?.id,apiKeyChanged:M.current.apiKey!==c,serviceConfigChanged:M.current.serviceConfig!==s,capabilitiesChanged:M.current.capabilities!==l}}),M.current={userId:t?.id,apiKey:c,serviceConfig:s,capabilities:l};let P=(0,n.useRef)(null);!d&&c&&P.current?.apiKey!==c&&(P.current={apiKey:c,client:new i.StreamChat(c)});let F=d||(c?P.current?.client??null:null);(0,n.useEffect)(()=>{let e=N.current,t=k.current;if(d){O.current=null,v(null),b(null),S(!1),E(null),w(!1);return}if(!c||!F||!t){h(`⚠️ SERVICE INIT SKIPPED`,{renderCount:e,reason:`Missing apiKey, client, or serviceConfig`});return}h(`🚀 CREATING SERVICE`,{renderCount:e,apiKey:c?.substring(0,8)+`...`});let n=new r.StreamChatService({...t,apiKey:c,debug:A.current,client:F,...t.logger||!j.current?{}:{logger:f(j.current)}});O.current=n,v(n),h(`✅ SERVICE SET`,{renderCount:e,serviceInstance:!!n})},[c,F,d]);let I=(0,n.useRef)(null);(0,n.useEffect)(()=>{if(h(`🔗 USER CONNECTION EFFECT TRIGGERED`,{hasService:!!_,hasUser:!!t,userId:t?.id,isConnecting:D.current,isConnected:x,dependencies:{service:!!_,userId:t?.id}}),!d){if(!_||!t){h(`⚠️ USER CONNECTION SKIPPED`,`Missing service or user`);return}if(D.current){h(`⚠️ USER CONNECTION SKIPPED`,`Already connecting`);return}if(I.current?.serviceId===_&&I.current?.userId===t.id){h(`⚠️ USER CONNECTION SKIPPED`,`Already connected this user with this service`);return}(async()=>{h(`🚀 STARTING USER CONNECTION`,{userId:t.id}),D.current=!0,w(!0),E(null);try{h(`📞 CALLING SERVICE.CONNECTUSER`,{userId:t.id});let e=await _.connectUser(t);b(e),S(!0),I.current={serviceId:_,userId:t.id},h(`✅ USER CONNECTION SUCCESS`,{userId:t.id,clientId:e.userID})}catch(e){let n=e instanceof Error?e.message:`Connection failed`;E(n),h(`❌ USER CONNECTION ERROR`,{userId:t.id,error:n})}finally{w(!1),D.current=!1,h(`🔄 USER CONNECTION FINISHED`,{userId:t.id,isConnected:x})}})()}},[_,t,h,x,d]),(0,n.useEffect)(()=>{let e=F;return()=>{e&&(I.current=null,O.current?.disconnectUser().catch(console.error))}},[F]);let L=(0,n.useCallback)(async()=>{if(h(`🔄 REFRESH CONNECTION CALLED`,{hasService:!!_,hasUser:!!t}),!d){if(!_||!t){h(`⚠️ REFRESH CONNECTION SKIPPED`,`Missing service or user`);return}h(`🚀 STARTING CONNECTION REFRESH`,{userId:t.id}),w(!0);try{h(`🔌 DISCONNECTING FOR REFRESH`),await _.disconnectUser(),h(`📞 RECONNECTING FOR REFRESH`);let e=await _.connectUser(t);b(e),S(!0),E(null),h(`✅ CONNECTION REFRESH SUCCESS`,{userId:t.id})}catch(e){let n=e instanceof Error?e.message:`Refresh failed`;E(n),h(`❌ CONNECTION REFRESH ERROR`,{userId:t.id,error:n})}finally{w(!1),h(`🔄 CONNECTION REFRESH FINISHED`,{userId:t.id})}}},[_,t,h,d]),R=n.default.useMemo(()=>(h(`💫 CONTEXT VALUE MEMOIZATION`,{hasService:!!_,hasClient:!!y,isConnected:x,isLoading:C,hasError:!!T,capabilitiesKeys:Object.keys(l)}),{service:d?null:_,client:d??y,isConnected:d?!0:x,isLoading:!d&&C,error:d?null:T,capabilities:l,refreshConnection:L,debug:u}),[_,y,d,x,C,T,l,L,u,h]);return h(`🔄 RENDER END`,{renderCount:N.current,willRenderChat:!!F,contextValueReady:!!R}),(0,o.jsx)(m,{logger:p,children:(0,o.jsx)(g.Provider,{value:R,children:F?(0,o.jsx)(a.Chat,{client:F,customClasses:{channelList:`str-chat__channel-list str-chat__channel-list-react bg-transparent lg:border-r-2 border-r-0 border-[#0000000A]`},children:e}):e})})},y=()=>_(),b=e=>{let[t,r]=(0,n.useState)(!!e?.state?.membership?.pinned_at);return(0,n.useEffect)(()=>{if(!e){r(!1);return}r(!!e.state.membership?.pinned_at);let t=t=>{r(t?.member?!!t.member.pinned_at:!!e.state.membership?.pinned_at)};return e.on(`member.updated`,t),()=>{e.off(`member.updated`,t)}},[e]),t};function x(e,t,n){let r=Object.values(e||{});if((0,s.isOfficialChannel)(n)){let e=r.find(e=>e.user?.id===s.OFFICIAL_SENDER_USER_ID);if(e)return e}return r.find(e=>e.user?.id&&e.user.id!==t)}var S=/^[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 C(e){return S.test(e.trim())}function w(e,t){let n=e?.trim();return!n||t&&n===t||t&&n===`Follower ${t}`?!1:!C(n)}function T(e){return w(e?.name,e?.id)?e.name.trim():w(e?.username,e?.id)?e.username.trim():`Unknown member`}var E=[{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 D(e){let t=0;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);t=(t<<5)-t+r,t&=t}return Math.abs(t)}function O(e){return E[D(e)%E.length]}function k(e){return O(e).emoji}function A(e){return O(e).bgColor}var j=({id:e,image:t,size:n=40,className:r,starred:i=!1,shape:a=`squircle`,dmAgentEnabled:s=!1})=>{let u=k(e),d=A(e),f=n<32?Math.round(n*.45):n<56?14:n<120?18:36,p=n>=40?2:1,m=a===`circle`?{borderRadius:`50%`}:{borderRadius:`1rem`},h=(0,o.jsx)(`div`,{"data-testid":`avatar-inner`,className:`h-full w-full overflow-hidden`,style:m,children:t?(0,o.jsx)(`img`,{src:t,alt:``,className:`h-full w-full object-cover`}):(0,o.jsx)(`div`,{"aria-hidden":`true`,"data-testid":`avatar-fallback`,className:(0,c.default)(`avatar-fallback flex h-full w-full items-center justify-center font-semibold select-none transition-colors`),style:{fontSize:f,lineHeight:1},children:u})});return(0,o.jsxs)(`div`,{"data-testid":`avatar`,className:(0,c.default)(`relative flex-shrink-0`,r),style:{"--str-chat__avatar-size":`${n}px`,width:`${n}px`,height:`${n}px`,backgroundColor:t?void 0:d,...m},children:[i&&(0,o.jsx)(`div`,{"aria-hidden":`true`,"data-testid":`avatar-star`,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:(0,o.jsx)(l.StarIcon,{className:`size-3 text-yellow-600`,weight:`duotone`})}),(0,o.jsx)(`div`,{"data-testid":`avatar-ring`,className:(0,c.default)(`h-full w-full`,`bg-transparent`),style:{...m,...s&&{borderWidth:`${p}px`,borderStyle:`solid`,borderColor:`var(--AI-Gradient, #7F22FE)`,boxShadow:`inset 0 1px 2px 0 rgba(255, 255, 255, 0.5)`}},children:h})]})},M=`https://linktr.ee/s/about/trust-center/report`,N=({channel:e,participant:t,showBlockParticipant:r=!0,enabled:i=!0,onLeaveConversation:a,onBlockParticipant:o,onDeleteConversationClick:s,onBlockParticipantClick:c,onReportParticipantClick:l,onActionComplete:u,logLabel:d=`useChannelModerationActions`})=>{let{service:f,debug:p}=_(),m=t?.user?.id,h=!!(i&&r&&f&&m),[g,v]=(0,n.useState)(!1),[y,b]=(0,n.useState)(null),[x,S]=(0,n.useState)(!1),[C,w]=(0,n.useState)(!1),T=h&&(y?.participantId!==m||y?.service!==f);return(0,n.useEffect)(()=>{if(!h||!f||!m){v(!1),b(null);return}let e=!1;return(async()=>{try{let t=await f.getBlockedUsers();if(e)return;v(t.some(e=>e.blocked_user_id===m))}catch(t){e||console.error(`[${d}] Failed to check blocked status:`,t)}finally{e||b({participantId:m,service:f})}})(),()=>{e=!0}},[h,f,m,d]),{isParticipantBlocked:g,isCheckingBlockedStatus:T,isLeaving:x,isUpdatingBlockStatus:C,handleLeaveConversation:async()=>{if(!x){s?.(),p&&console.log(`[${d}] Leave conversation`,e.cid),S(!0);try{let t=e._client?.userID??null;await e.hide(t,!1),a&&await a(e),u?.()}catch(e){console.error(`[${d}] Failed to leave conversation`,e)}finally{S(!1)}}},handleBlockUser:async()=>{if(!(C||!f)){c?.(),p&&console.log(`[${d}] Block member`,t?.user?.id),w(!0);try{await f.blockUser(t?.user?.id),o&&await o(t?.user?.id),u?.()}catch(e){console.error(`[${d}] Failed to block member`,e)}finally{w(!1)}}},handleUnblockUser:async()=>{if(!(C||!f)){c?.(),p&&console.log(`[${d}] Unblock member`,t?.user?.id),w(!0);try{await f.unBlockUser(t?.user?.id),o&&await o(t?.user?.id),u?.()}catch(e){console.error(`[${d}] Failed to unblock member`,e)}finally{w(!1)}}},handleReportUser:()=>{l?.(),u?.(),window.open(M,`_blank`,`noopener,noreferrer`)}}},P=({variant:e=`default`,className:t,children:n,...r})=>(0,o.jsx)(`button`,{type:`button`,className:(0,c.default)(`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`,e===`danger`?`text-danger hover:bg-danger/50`:`text-charcoal hover:bg-sand`,t),...r,children:n}),F=({channel:e,participant:r,showDeleteConversation:i=!0,showBlockParticipant:a=!0,showReportParticipant:s=!0,onLeaveConversation:u,onBlockParticipant:d,onDeleteConversationClick:f,onBlockParticipantClick:p,onReportParticipantClick:m,customChannelActions:h,triggerClassName:g})=>{let[_,v]=(0,n.useState)(!1),y=(0,n.useRef)(null),b=(0,n.useId)(),{isParticipantBlocked:x,isCheckingBlockedStatus:S,isLeaving:C,isUpdatingBlockStatus:w,handleLeaveConversation:T,handleBlockUser:E,handleUnblockUser:D,handleReportUser:O}=N({channel:e,participant:r,showBlockParticipant:a,enabled:_,onLeaveConversation:u,onBlockParticipant:d,onDeleteConversationClick:f,onBlockParticipantClick:p,onReportParticipantClick:m,onActionComplete:(0,n.useCallback)(()=>v(!1),[]),logLabel:`ChannelActionsMenu`});return(0,n.useEffect)(()=>{if(!_)return;let e=e=>{y.current&&!y.current.contains(e.target)&&v(!1)},t=e=>{e.key===`Escape`&&v(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[_]),!r||!(i||a||s||h)?null:(0,o.jsxs)(`div`,{ref:y,className:`relative`,children:[(0,o.jsxs)(`button`,{className:g,type:`button`,"aria-haspopup":`true`,"aria-expanded":_,"aria-controls":_?b:void 0,onClick:()=>v(e=>!e),children:[(0,o.jsx)(l.DotsThreeIcon,{className:`size-5 text-black/90`}),(0,o.jsx)(`span`,{className:`sr-only`,children:`More options`})]}),_&&(0,o.jsx)(`div`,{id:b,"aria-label":`Conversation options`,className:(0,c.default)(`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:(0,o.jsxs)(`ul`,{className:`flex flex-col gap-1`,children:[i&&(0,o.jsx)(`li`,{children:(0,o.jsxs)(P,{onClick:T,disabled:C,"aria-busy":C,children:[C?(0,o.jsx)(t.c,{size:`md`,icon:l.SpinnerGapIcon,weight:`regular`}):(0,o.jsx)(l.SignOutIcon,{className:`h-5 w-5`}),(0,o.jsx)(`span`,{children:`Delete Conversation`})]})}),a&&(0,o.jsx)(`li`,{children:S?(0,o.jsxs)(P,{disabled:!0,"aria-busy":!0,children:[(0,o.jsx)(t.c,{size:`md`,icon:l.SpinnerGapIcon,weight:`regular`}),(0,o.jsx)(`span`,{children:`Block`})]}):x?(0,o.jsxs)(P,{onClick:D,disabled:w,"aria-busy":w,children:[w?(0,o.jsx)(t.c,{size:`md`,icon:l.SpinnerGapIcon,weight:`regular`}):(0,o.jsx)(l.ProhibitInsetIcon,{className:`h-5 w-5`}),(0,o.jsx)(`span`,{children:`Unblock`})]}):(0,o.jsxs)(P,{onClick:E,disabled:w,"aria-busy":w,children:[w?(0,o.jsx)(t.c,{size:`md`,icon:l.SpinnerGapIcon,weight:`regular`}):(0,o.jsx)(l.ProhibitInsetIcon,{className:`h-5 w-5`}),(0,o.jsx)(`span`,{children:`Block`})]})}),s&&(0,o.jsx)(`li`,{children:(0,o.jsxs)(P,{variant:`danger`,onClick:O,children:[(0,o.jsx)(l.FlagIcon,{className:`h-5 w-5`}),(0,o.jsx)(`span`,{children:`Report`})]})}),h]})})]})},I=`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`,L=`CUSTOMER_PAID`,R=e=>typeof e==`string`&&e.trim().replace(/[\s-]+/g,`_`).toUpperCase()===L,ee=({className:e,onBack:t,showBackButton:r,showStarButton:i=!1,onLeaveConversation:s,onBlockParticipant:u,showDeleteConversation:d=!0,showBlockParticipant:f=!0,showReportParticipant:p=!0,onDeleteConversationClick:m,onBlockParticipantClick:h,onReportParticipantClick:g,customChannelActions:_,renderChannelActions:v,showChannelInfo:y=!0,onParticipantNameClick:S})=>{let{channel:C}=(0,a.useChannelStateContext)(),{client:w}=(0,a.useChatContext)(),E=n.default.useMemo(()=>x(C.state?.members,w?.userID,C.type),[C.state?.members,w?.userID,C.type]),D=T(E?.user),O=E?.user?.image,k=b(C),A=R(C.data?.customer_tag)&&E?.is_follower===!0,M=A||k||!!S,N=async()=>{try{k?await C.unpin():await C.pin()}catch(e){console.error(`[ChannelHeaderRedesign] Failed to update pinned status:`,e)}},P=(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(j,{id:E?.user?.id||C.id||`unknown`,name:D,image:O,shape:`circle`,size:48,className:`-mb-2`}),(0,o.jsx)(`span`,{className:(0,c.default)(`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`,M?`pl-3 pr-2`:`px-3`),children:(0,o.jsxs)(`span`,{className:`flex max-w-full items-center justify-center`,children:[(0,o.jsx)(`span`,{className:`min-w-0 truncate text-sm font-bold leading-[1.43] tracking-[0.28px] text-black/90`,children:D}),M&&(0,o.jsxs)(`span`,{className:`ml-2 flex gap-1`,children:[A&&(0,o.jsx)(`span`,{"aria-label":`Paid customer`,className:`flex size-4 shrink-0 items-center justify-center rounded-full bg-[#34C759] text-white`,children:(0,o.jsx)(l.CurrencyDollarIcon,{className:`size-2.5`,weight:`bold`})}),k&&(0,o.jsx)(`span`,{className:`messaging-header-star-badge flex overflow-hidden`,children:(0,o.jsx)(`span`,{"aria-label":`Starred conversation`,className:`flex size-4 shrink-0 items-center justify-center rounded-full bg-[#FFD60A] text-white`,children:(0,o.jsx)(l.StarIcon,{className:`size-2.5`,weight:`fill`})})}),S&&(0,o.jsx)(l.CaretRightIcon,{"aria-hidden":`true`,className:`size-4 shrink-0 text-black/65`,weight:`bold`})]})]})})]});return(0,o.jsx)(`div`,{className:(0,c.default)(`@container bg-[linear-gradient(180deg,#FBFAF9_0%,rgba(251,250,249,0.92)_58%,rgba(251,250,249,0)_100%)]`,e),children:(0,o.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:[(0,o.jsx)(`div`,{className:`flex items-start`,children:r&&(0,o.jsx)(`button`,{className:(0,c.default)(I,`messaging-channel-view-back-button-mobile messaging-channel-view-back-button-desktop`),onClick:t||(()=>{}),type:`button`,"aria-label":`Back to conversations`,children:(0,o.jsx)(l.ArrowLeftIcon,{className:`size-5 text-black/90`})})}),(0,o.jsx)(`div`,{className:`flex min-w-0 justify-center`,"data-dd-privacy":`mask`,children:S?(0,o.jsx)(`button`,{type:`button`,onClick:S,"aria-label":`View details for ${D}`,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:P}):(0,o.jsx)(`div`,{className:`flex min-w-0 max-w-full flex-col items-center px-2`,children:P})}),(0,o.jsxs)(`div`,{className:`flex items-start justify-end gap-2`,children:[i&&(0,o.jsx)(`button`,{className:I,onClick:N,type:`button`,"aria-pressed":k,"aria-label":k?`Unstar conversation`:`Star conversation`,children:(0,o.jsx)(l.StarIcon,{className:(0,c.default)(`size-5`,{"text-[#FFD60A]":k,"text-black/90":!k}),weight:k?`fill`:`regular`})}),y&&(v===void 0?(0,o.jsx)(F,{channel:C,participant:E,showDeleteConversation:d,showBlockParticipant:f,showReportParticipant:p,onLeaveConversation:s,onBlockParticipant:u,onDeleteConversationClick:m,onBlockParticipantClick:h,onReportParticipantClick:g,customChannelActions:_,triggerClassName:I}):v)]})]})})},te=e=>(0,o.jsx)(a.DateSeparator,{...e,position:`center`});function z(e){return e?.trim().toLowerCase().split(/[-_]/)[0]||void 0}function B({message:e,viewerLanguage:t}){let n=e?.text,r=z(t);return r?e?.i18n?.[`${r}_text`]??n:n}var V=/^([a-z][a-z0-9+.-]*):/i,ne=new Set([`http`,`https`,`mailto`,`tel`,`sms`]);function H(e){if(typeof e!=`string`)return;let t=e.trim();if(t===``)return;let n=V.exec(t);if(n){let e=n[1].toLowerCase();return ne.has(e)?t:void 0}return t.startsWith(`//`)||t.startsWith(`/`)?t:`https://${t}`}var re={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`}},ie=({variant:e,cta:t,fullWidth:n=!0,standalone:r=!1})=>{let i=t.variant??`primary`,a=(0,c.default)(`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`,!r&&`mt-2`,re[e][i]),s=n?t.label:(0,o.jsx)(`span`,{className:`min-w-0 truncate`,children:t.label}),l=H(t.href);return l?(0,o.jsx)(`a`,{href:l,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>{e.stopPropagation(),t.onClick?.()},className:`${a} no-underline`,children:s}):(0,o.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),t.onClick?.()},className:a,children:s})},U={dark:`text-white`,light:`text-black/90`},W=`text-white/30`,ae={dark:`text-white/55`,light:`text-black/55`},oe={dark:`bg-white/25`,light:`bg-black/15`},G=({variant:e,ctaSurface:t,chinTextColor:n,title:r,placeholderTitle:i,description:a,descriptionLines:s=1,url:l,appIcon:u,cta:d,trailingAction:f,isLoading:p=!1})=>{let m=e===`dark`,h=r??(m?i:void 0)??``,g=h.trim()!==``,_=a!=null&&a.trim()!==``,v=typeof l==`string`?l.trim():``,y=v!==``,b=d!=null;if(!p&&!g&&!_&&!y&&!b)return null;let x=(0,c.default)(`line-clamp-2 text-[14px] font-medium leading-5 tracking-[0.28px]`,n==null&&(m&&!r?W:U[e])),S=(0,c.default)(`truncate text-[12px] leading-4 tracking-[0.24px]`,n==null&&ae[e]),C=(0,c.default)(`text-[12px] leading-4 tracking-[0.24px]`,s<=1&&`truncate`,n==null&&ae[e]);if(p){let t=(0,c.default)(`animate-pulse rounded`,oe[e]);return(0,o.jsx)(`div`,{className:`shrink-0 px-4 py-3`,children:(0,o.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-[2px]`,children:[(0,o.jsx)(`div`,{"data-testid":`card-body-skeleton-bar`,className:(0,c.default)(`h-5 w-3/4`,t),"aria-hidden":!0}),(0,o.jsx)(`div`,{"data-testid":`card-body-skeleton-bar`,className:(0,c.default)(`h-4 w-1/2`,t),"aria-hidden":!0})]})})}let w=n?{color:n}:void 0,T=s>1?{...w,display:`-webkit-box`,WebkitBoxOrient:`vertical`,WebkitLineClamp:s,overflow:`hidden`}:w;return(0,o.jsxs)(`div`,{className:`shrink-0 px-4 py-3`,children:[(0,o.jsxs)(`div`,{className:`flex items-end gap-3`,children:[(0,o.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[g&&(0,o.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[u?(0,o.jsx)(`span`,{className:`shrink-0`,children:u}):null,(0,o.jsx)(`p`,{className:(0,c.default)(`min-w-0`,x),style:w,children:h})]}),_&&(0,o.jsx)(`p`,{className:C,style:T,children:a}),!b&&y&&(0,o.jsx)(`p`,{className:S,style:w,"data-testid":`link-attachment-url`,children:v})]}),f&&(0,o.jsx)(`div`,{className:`shrink-0`,children:f})]}),d&&(0,o.jsx)(ie,{variant:t??e,cta:d})]})},se=`Loading link preview`,ce=(0,c.default)(`relative w-[var(--lt-msg-card-width,290px)] max-w-full select-none overflow-hidden`,`rounded-[20px]`),K=`flex h-[250px] flex-col`,q=({variant:e,children:t,href:n,onClick:r,ariaLabel:i,rootRef:a,topRight:s,bgClassName:l,accentHex:u,fixedHeight:d=!1,busy:f=!1,"data-testid":p=`link-card`})=>{let m=(0,c.default)(`messaging-link-card`,ce,d?K:`block`,l??(e===`dark`?`bg-[#1e2330]`:`bg-[#f1f0ee]`),n!=null||r!=null?`cursor-pointer no-underline focus-ring`:null),h=f?{role:`status`,"aria-busy":!0,"aria-label":se}:void 0,g=u?{"--accent":u}:void 0,_=s?(0,o.jsx)(`div`,{"data-testid":`card-shell-top-right`,className:`pointer-events-auto absolute right-3 top-3 z-10`,children:s}):null;return n?(0,o.jsxs)(`a`,{ref:a,href:n,target:`_blank`,rel:`noopener noreferrer`,onClick:r,"data-testid":p,"data-variant":e,className:m,style:g,...h,children:[t,_]}):r?(0,o.jsxs)(`button`,{ref:a,type:`button`,onClick:r,"aria-label":i,"data-testid":p,"data-variant":e,className:(0,c.default)(m,`text-left`),style:g,...h,children:[t,_]}):(0,o.jsxs)(`div`,{ref:a,"data-testid":p,"data-variant":e,className:m,style:g,...h,children:[t,_]})},J={dark:`bg-white/10`,light:`bg-black/5`},le={dark:`size-16 text-white/25`,light:`size-16 text-black/25`},Y=(e,n)=>!!n&&!!e&&t.i(e)===`audio`,ue=(e,n)=>{if(!n||!e)return!1;let r=t.i(e);return r===`video`||r===`audio`},de=`bg-[#F2F3F4]`,X=({variant:e,thumbnailUrl:n,sourceUrl:r,title:i,mimeType:a=`image/*`,topLeft:s,topRight:l,isLoading:u=!1,onImageError:d})=>{let f=t.i(a),p=!!r&&f===`video`,m=t.s(n);return!u&&Y(a,r)?(0,o.jsx)(`div`,{className:`p-3`,children:(0,o.jsx)(`audio`,{...t.a,"data-testid":`card-thumbnail-audio`,src:r,controls:!0,preload:`metadata`,className:`block w-full`,children:(0,o.jsx)(`track`,{kind:`captions`})})}):(0,o.jsxs)(`div`,{"data-testid":`card-thumbnail-hero`,className:(0,c.default)(`relative min-h-0 w-full flex-1 overflow-hidden`,p&&`bg-black`),children:[u?(0,o.jsx)(`div`,{"data-testid":`card-thumbnail-skeleton`,className:(0,c.default)(`h-full w-full animate-pulse`,J[e]),"aria-hidden":!0}):p?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`video`,{"data-testid":`card-thumbnail-video`,src:r,poster:m,controls:!0,playsInline:!0,preload:`metadata`,className:`absolute inset-0 h-full w-full object-contain`,children:(0,o.jsx)(`track`,{kind:`captions`})}),m&&d?(0,o.jsx)(`img`,{src:m,alt:``,"aria-hidden":!0,onError:d,className:`hidden`}):null]}):n?(0,o.jsx)(`img`,{src:m??n,alt:i??``,draggable:!1,loading:`lazy`,decoding:`async`,onError:d,className:`absolute inset-0 h-full w-full object-cover`}):(0,o.jsx)(`div`,{"data-testid":`card-thumbnail-placeholder`,className:(0,c.default)(`flex h-full w-full items-center justify-center`,J[e]),children:t.n(a,{className:le[e],weight:`regular`})}),s?(0,o.jsx)(`div`,{"data-testid":`card-thumbnail-top-left`,className:`pointer-events-auto absolute left-3 top-3 z-10`,children:s}):null,l?(0,o.jsx)(`div`,{"data-testid":`card-thumbnail-top-right`,className:`pointer-events-auto absolute right-3 top-3 z-10`,children:l}):null]})},Z=/^#?(?:[0-9a-f]{3}|[0-9a-f]{6})$/i;function fe(e){let t=e.trim();return t.startsWith(`#`)?t:`#${t}`}var pe=`#FFFFFF`,me=`#040403`,he={dark:pe,light:me};function ge({variant:e,accentColor:t,status:r=`ready`,layout:i=`featured`,thumbnailUrl:a,mimeType:o,sourceUrl:s}){let[c,l]=n.default.useState(!1);n.default.useEffect(()=>{l(!1)},[a]);let u=n.default.useCallback(()=>{l(!0)},[]),d=Y(o,s),f=i===`featured`&&a&&!d&&!c&&r===`ready`&&t!=null&&Z.test(t.trim())?fe(t):void 0,p=d?me:he[e];return{thumbnailUrl:c?void 0:a,accentHex:f,chinTextColor:p,surface:d?`light`:e,isLoading:r===`loading`,onImageError:u}}var _e=`flex size-6 items-center justify-center rounded-full bg-[#121110] text-white transition-colors duration-150 hover:bg-[#2a2928] focus-ring`,ve=`relative before:absolute before:-inset-[10px] before:content-['']`,ye=({title:e,placeholderTitle:t,description:n,descriptionLines:r,url:i,mimeType:a,thumbnailUrl:s,sourceUrl:u,layout:d=`featured`,appIcon:f,cta:p,accentColor:m,status:h=`ready`,onDismiss:g,onEditClick:_,dismissLabel:v=`Dismiss attachment`})=>{let y=d===`classic`,b=Y(a,u),x=ge({variant:`dark`,accentColor:m,status:h,layout:d,thumbnailUrl:s,mimeType:a,sourceUrl:u}),S=g?(0,o.jsx)(`button`,{type:`button`,onClick:g,"aria-label":v,className:(0,c.default)(_e,!b&&ve),children:(0,o.jsx)(l.XIcon,{className:`size-3`,weight:`bold`})}):void 0,C=_?(0,o.jsx)(`button`,{type:`button`,onClick:_,"aria-label":`Edit attachment`,className:`flex size-10 items-center justify-center rounded-full bg-white/10 text-white hover:bg-white/15`,children:(0,o.jsx)(l.PencilSimpleIcon,{className:`size-5`,weight:`regular`})}):void 0;return b&&!x.isLoading?(0,o.jsx)(q,{variant:`dark`,bgClassName:de,children:(0,o.jsxs)(`div`,{className:`flex items-center gap-2 pr-3`,children:[(0,o.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,o.jsx)(X,{variant:`dark`,sourceUrl:u,title:e,mimeType:a})}),S&&(0,o.jsx)(`div`,{className:`shrink-0`,children:S})]})}):(0,o.jsxs)(q,{variant:`dark`,fixedHeight:!y,accentHex:x.accentHex,busy:x.isLoading,topRight:y?S:void 0,children:[!y&&(0,o.jsx)(X,{variant:`dark`,thumbnailUrl:x.thumbnailUrl,sourceUrl:u,title:e,mimeType:a,topRight:S,isLoading:x.isLoading,onImageError:x.onImageError}),(0,o.jsx)(G,{chinTextColor:x.chinTextColor,variant:`dark`,ctaSurface:x.surface,title:e,placeholderTitle:t,description:n,descriptionLines:r,url:i,appIcon:f,cta:p,trailingAction:C,isLoading:x.isLoading})]})},be=({accentHex:e,side:t,visible:n,children:r})=>n?(0,o.jsxs)(`div`,{className:`relative isolate w-fit`,children:[r,(0,o.jsx)(`span`,{"aria-hidden":!0,"data-testid":`link-card-tail`,"data-variant":t===`sender`?`dark`:`light`,style:e?{"--accent":e}:void 0,className:(0,c.default)(`messaging-link-card-tail`,t===`receiver`&&`messaging-link-card-tail--received`)})]}):(0,o.jsx)(o.Fragment,{children:r}),xe={Composer:ye,Sent:({title:e,placeholderTitle:t,description:n,descriptionLines:r,url:i,mimeType:a,thumbnailUrl:s,sourceUrl:c,layout:l=`featured`,appIcon:u,cta:d,accentColor:f,status:p=`ready`,onClick:m,groupPosition:h=`single`})=>{let g=ue(a,c),_=H(i),v=d==null&&_!=null&&!g?_:void 0,y=d==null&&!g&&v!=null?m:void 0,b=p!==`loading`&&Y(a,c),x=ge({variant:`dark`,accentColor:f,status:p,layout:l,thumbnailUrl:s,mimeType:a,sourceUrl:c});return(0,o.jsx)(be,{accentHex:x.accentHex,side:`sender`,visible:!b&&(h===`single`||h===`end`),children:(0,o.jsxs)(q,{variant:`dark`,href:v,onClick:y,fixedHeight:l===`featured`&&!b,accentHex:x.accentHex,busy:x.isLoading,bgClassName:b?de:void 0,children:[l===`featured`&&(0,o.jsx)(X,{variant:`dark`,thumbnailUrl:x.thumbnailUrl,sourceUrl:c,title:e,mimeType:a,isLoading:x.isLoading,onImageError:x.onImageError}),(0,o.jsx)(G,{chinTextColor:x.chinTextColor,variant:`dark`,ctaSurface:x.surface,title:e,placeholderTitle:t,description:n,descriptionLines:r,url:i,appIcon:u,cta:d,isLoading:x.isLoading})]})})},Received:({title:e,description:t,descriptionLines:n,url:r,mimeType:i,thumbnailUrl:a,sourceUrl:s,layout:c=`featured`,appIcon:l,cta:u,accentColor:d,status:f=`ready`,onClick:p,groupPosition:m=`single`})=>{let h=ue(i,s),g=H(r),_=u==null&&g!=null&&!h?g:void 0,v=u==null&&!h?p:void 0,y=f!==`loading`&&Y(i,s)?de:void 0,b=u&&p?{...u,onClick:()=>{p(),u.onClick?.()}}:u,x=ge({variant:`light`,accentColor:d,status:f,layout:c,thumbnailUrl:a,mimeType:i,sourceUrl:s});return(0,o.jsx)(be,{accentHex:x.accentHex,side:`receiver`,visible:y==null&&(m===`single`||m===`end`),children:(0,o.jsxs)(q,{variant:`light`,href:_,onClick:v,ariaLabel:e??`Open attachment preview`,fixedHeight:c===`featured`&&y==null,accentHex:x.accentHex,busy:x.isLoading,bgClassName:y,"data-testid":`link-attachment`,children:[c===`featured`&&(0,o.jsx)(X,{variant:`light`,thumbnailUrl:x.thumbnailUrl,sourceUrl:s,title:e,mimeType:i,isLoading:x.isLoading,onImageError:x.onImageError}),(0,o.jsx)(G,{chinTextColor:x.chinTextColor,variant:`light`,ctaSurface:x.surface,title:e,description:t,descriptionLines:n,url:r,appIcon:l,cta:b,isLoading:x.isLoading})]})})}};function Se(e){return e.type===`link`||!!e.og_scrape_url?.trim()}var Ce={LockedAttachment:{isUnlocking:()=>!1}},we=(0,n.createContext)({}),Te=we.Provider;function Ee(e){return(0,n.useContext)(we)[e]??Ce[e]}var De=n.default.lazy(()=>Promise.resolve().then(()=>require("./Card-Ds1FMcUj.cjs"))),Oe=n.default.lazy(()=>Promise.resolve().then(()=>require("./Card-4irOjGaI.cjs"))),ke=()=>(0,o.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}),Ae=e=>(0,o.jsx)(n.Suspense,{fallback:(0,o.jsx)(ke,{}),children:e.contentType===`text`?(0,o.jsx)(De,{...e}):(0,o.jsx)(Oe,{...e})}),je=({size:e=15})=>(0,o.jsx)(`svg`,{width:e,height:e,viewBox:`0 0 15 15`,fill:`none`,"aria-hidden":`true`,children:(0,o.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})}),Me=e=>e.metadata?.custom_type===s.MESSAGE_CUSTOM_TYPE.PAID,Ne=e=>e.metadata?.custom_type===s.MESSAGE_CUSTOM_TYPE.CHATBOT,Pe=e=>e.metadata?.custom_type===s.MESSAGE_CUSTOM_TYPE.ATTACHMENT,Fe=e=>Pe(e)&&e.metadata?.attachment_content_type===`text`,Ie=e=>Pe(e)&&e.metadata?.attachment_content_type!==`text`,Le=e=>Me(e)&&!!e.metadata?.amount_text,Re=({message:e,isMyMessage:t=!1,hasAttachment:n=!1})=>{let r=Me(e),i=Ne(e);if(!r&&!i)return null;if(r){let t=e.metadata?.amount_text;return t?(0,o.jsxs)(`div`,{className:`message-tag--paid inline-flex items-center gap-1 text-[12px] font-medium leading-[2] text-[#016630]`,children:[(0,o.jsx)(l.GiftIcon,{size:12}),(0,o.jsxs)(`span`,{children:[`Delivered with `,t,` message`]})]}):null}let a=t&&n,s=a?`Sent with AI`:`Sent by AI Assistant`,c=a?`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=(0,o.jsx)(`span`,{className:`text-left`,children:s}),d=(0,o.jsx)(`span`,{className:`inline-flex items-center leading-none`,children:(0,o.jsx)(je,{size:a?12:15})});return(0,o.jsx)(`div`,{className:`inline-flex items-center text-[10px] font-normal leading-4 tracking-[0.2px] ${c}`,"data-testid":`message-chatbot-indicator`,children:t&&!a?(0,o.jsxs)(o.Fragment,{children:[u,d]}):(0,o.jsxs)(o.Fragment,{children:[d,u]})})},ze=`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%`,Be={me:`var(--str-chat__own-message-bubble-background-color, #1e2330)`,other:`var(--str-chat__message-bubble-background-color, #f1f0ee)`},Ve=({side:e})=>(0,o.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:Be[e],WebkitMask:ze,mask:ze}}),He=(0,n.createContext)(void 0),Ue=e=>{let t=e.metadata?.outbound_id;return typeof t==`string`?t:void 0},We=(e,t)=>{if(!t||!e?.length)return;let n=new Set,r;for(let i of e){let e=Ue(i);if(!e||n.has(e))continue;n.add(e);let a=t(e);a&&(r??={},r[e]={id:a.id,...a.name===void 0?{}:{name:a.name}})}return r},Ge=(e,t)=>{if(e===t)return!0;if(!e||!t)return!1;let n=Object.keys(e),r=Object.keys(t);return n.length===r.length&&n.every(n=>e[n].id===t[n]?.id&&e[n].name===t[n]?.name)},Ke=(e,t)=>{let r=We(e,t),[i,a]=(0,n.useState)(r);return Ge(i,r)?i:(a(r),r)},qe=e=>e.metadata?.custom_type===s.MESSAGE_CUSTOM_TYPE.TIP,Je=({message:e})=>{let t=e.metadata?.amount_text;return t?(0,o.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:[(0,o.jsx)(`span`,{className:`flex h-5 items-center text-[20px] leading-none`,"aria-hidden":`true`,children:`🎁`}),(0,o.jsxs)(`span`,{className:`text-[14px] font-bold leading-[1.43] tracking-[0.28px] text-[rgba(4,4,3,0.9)]`,children:[t,` tip!`]})]}):null},Ye=()=>{let{message:e}=(0,a.useMessageContext)(`SentMessageDeliveryStatus`),{messages:t}=(0,a.useChannelStateContext)(`SentMessageDeliveryStatus`),n=(()=>{if(t)for(let e=t.length-1;e>=0;--e){let n=t[e];if(n.type!==`system`&&n.type!==`ephemeral`&&n.type!==`deleted`)return n.id}})();return e.id===n},Xe=()=>Ye()?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(l.ChecksIcon,{weight:`bold`,"aria-hidden":`true`}),(0,o.jsx)(`span`,{"data-testid":`sent-message-delivery-status`,children:`Delivered`})]}):null,Ze=()=>Ye()?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(l.CircleNotchIcon,{className:`sent-message-status__spinner animate-spin`,weight:`bold`,"aria-hidden":`true`}),(0,o.jsx)(`span`,{"data-testid":`sent-message-sending-status`,children:`Sending`})]}):null,Qe=({outbound:e,onOutboundClick:t})=>{let n=e.name||`Broadcast`,r=(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`span`,{className:`sent-message-outbound-badge`,"aria-hidden":`true`,children:(0,o.jsx)(l.MegaphoneIcon,{weight:`fill`})}),(0,o.jsx)(`span`,{className:(0,c.default)(`sent-message-outbound-name`,{"underline [text-decoration-skip-ink:auto]":!!t}),"data-testid":`sent-message-outbound-status`,children:n})]});return t?(0,o.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},$e=()=>(0,o.jsxs)(`span`,{className:`str-chat__message-status sent-message-status--failed`,children:[(0,o.jsx)(l.WarningCircleIcon,{weight:`bold`,"aria-hidden":`true`}),(0,o.jsx)(`span`,{"data-testid":`sent-message-failed-status`,children:`Failed to send`})]}),et=({onOutboundClick:e,resolvedOutbound:t})=>{let{isMyMessage:n,message:r,threadList:i}=(0,a.useMessageContext)(`SentMessageDeliveryStatus`),s=n(),c=Ye();if(i)return null;if(r.status===`failed`&&s&&r.type!==`error`)return(0,o.jsx)($e,{});if(!s)return null;let l=r.metadata?.outbound_id,u=r.status!==`sending`&&r.status!==`failed`&&l&&t?(0,o.jsx)(Qe,{outbound:t,onOutboundClick:e}):null,d=Le(r)?null:(0,o.jsx)(a.MessageStatus,{MessageSentStatus:Xe,MessageDeliveredStatus:Xe,MessageReadStatus:Xe,MessageSendingStatus:qe(r)?Xe:Ze});return u?(0,o.jsxs)(`span`,{className:`sent-message-status-row`,children:[d,d&&c&&(0,o.jsx)(`span`,{className:`sent-message-outbound-separator`,"aria-hidden":`true`,children:`•`}),u]}):d},tt={dark:`bg-[#1e2330]`,light:`bg-[#f2f1ef]`},nt={dark:`text-white`,light:`text-[#000000]`},rt={dark:`border-white/[0.08]`,light:`border-black/[0.08]`},it=e=>e===`dark`?`sender`:`receiver`,at={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]`}},ot=({variant:e,text:t,bordered:n=!0,groupPosition:r=`single`,widthClassName:i=`w-[280px]`,paddingClassName:a=`px-2 py-2`,radiusClassName:s,className:l,children:u,"data-testid":d})=>{let f=t!=null&&t!==``,p=s??at[it(e)][r];return(0,o.jsxs)(`div`,{"data-testid":d,"data-group-position":r,className:(0,c.default)(`relative`,i,`overflow-hidden`,a,f&&`pb-0`,p,tt[e],nt[e],n&&`border`,n&&rt[e],l),children:[u,f?(0,o.jsx)(`p`,{className:(0,c.default)(`whitespace-pre-wrap break-words leading-snug hyphens-manual`,`pb-2 pt-2`,`px-2`),children:t}):null]})},st=e=>e===`received`?`light`:`dark`,ct=({firstOfGroup:e,endOfGroup:t,groupedByUser:n})=>!n||e&&t?`single`:e?`first`:t?`end`:`middle`,lt=(e,t)=>`${e}:${t}`;function ut(e){return!Number.isFinite(e)||e<0?``:e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:e<1073741824?`${(e/1048576).toFixed(2)} MB`:`${(e/1073741824).toFixed(2)} GB`}var dt={pdf:`PDF`,doc:`DOC`,xls:`XLS`,csv:`CSV`,ppt:`PPT`,zip:`ZIP`,text:`TXT`,markdown:`MD`};function ft(e,n){if(n){let e=n.lastIndexOf(`.`);if(e>0&&e<n.length-1){let t=n.slice(e+1);if(t&&t.length<=5)return t.toUpperCase()}}if(!e)return;if(t.i(e)===`document`){let n=dt[t.r(e)];if(n)return n;if(e===`application/octet-stream`)return}let r=e.split(`/`)[1];if(!(!r||r===`*`))return r.toUpperCase()}function pt(e,t,n){return[ft(e,t),typeof n==`number`&&n>0?ut(n):void 0].filter(Boolean).join(` · `)||void 0}function Q(e){try{let t=new URL(e).pathname.split(`/`).pop();return t&&t.length>0?decodeURIComponent(t):`download`}catch{return`download`}}async function mt(e,t){let n=t??Q(e);try{let t=await fetch(e,{mode:`cors`});if(!t.ok)throw Error(`HTTP ${t.status}`);let r=await t.blob(),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=n,a.style.display=`none`,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(i)}catch{if(!window.open(e,`_blank`,`noopener,noreferrer`)){let t=document.createElement(`a`);t.href=e,t.download=n,t.target=`_blank`,t.rel=`noopener noreferrer`,t.style.display=`none`,document.body.appendChild(t),t.click(),document.body.removeChild(t)}}}var ht=()=>()=>{},gt=()=>!0,_t=()=>!1,vt=()=>(0,n.useSyncExternalStore)(ht,gt,_t),yt=35,bt=Object.freeze(Array(yt).fill(0)),xt=`--:--`,St=e=>(0,a.displayDuration)(Math.floor(e)),Ct=e=>({canPlayRecord:e.canPlayRecord,isPlaying:e.isPlaying,progressPercent:e.progressPercent,secondsElapsed:e.secondsElapsed}),wt=`flex size-8 shrink-0 items-center justify-center rounded-full backdrop-blur-[20px]`,Tt={dark:`bg-white text-black/90 disabled:bg-white/40`,light:`bg-[#040403]/90 text-white disabled:bg-[#040403]/30`},Et={dark:`bg-[#040403]/80 text-white hover:bg-[#040403]`,light:`bg-black/10 text-black/90 hover:bg-black/20`},Dt=(e,t)=>{let[r,i]=n.default.useState();return n.default.useEffect(()=>{if(t!=null||!e)return;let n=document.createElement(`audio`);n.preload=`metadata`;let r=()=>{Number.isFinite(n.duration)&&n.duration>0&&i(n.duration)};return n.addEventListener(`loadedmetadata`,r),n.src=e,()=>{n.removeEventListener(`loadedmetadata`,r),n.removeAttribute(`src`),i(void 0)}},[e,t]),t??r},Ot=e=>vt()?(0,o.jsx)(At,{...e}):(0,o.jsx)(jt,{...e,playback:kt}),kt={playable:!1,showPause:!1,isStarting:!1,progress:0,secondsElapsed:0},At=e=>{let{item:t,requester:r}=e,i=n.default.useRef(null),[s,c]=n.default.useState(!1),l=Dt(t.src,t.durationSeconds),u=(0,a.useAudioPlayer)({durationSeconds:l,mimeType:t.mimeType,requester:r,src:t.src,title:t.filename}),{canPlayRecord:d=!1,isPlaying:f=!1,progressPercent:p=0,secondsElapsed:m=0}=(0,a.useStateStore)(u?.state,Ct)??{},h=()=>{!u||s||(c(!0),u.togglePlay().finally(()=>c(!1)))},g=e=>{let t=i.current;if(!u||!t)return;let n=Math.min(Math.max(Number(e.target.value)/100,0),1),r=t.getBoundingClientRect();u.seek({clientX:r.x+n*r.width,currentTarget:t})};return(0,o.jsx)(jt,{...e,playback:{playable:!!u&&d,showPause:f,isStarting:s,progress:Math.min(Math.max(p,0),100),secondsElapsed:m,durationSeconds:l,trackRef:i,onTogglePlay:h,onSeek:g}})},jt=({item:e,variant:t,trailingAction:r,playback:i})=>{let{isStarting:s,onSeek:u,onTogglePlay:d,playable:f,progress:p,secondsElapsed:m,showPause:h,trackRef:g}=i,_=n.default.useMemo(()=>{let t=e.waveformData;return!t||t.length===0?bt:t.length===yt?t:(0,a.resampleWaveformData)(t,yt)},[e.waveformData]),v=i.durationSeconds??e.durationSeconds,y=v==null?xt:St(v),b=m>0?St(m):y,x=e.filename?` \u2014 ${e.filename}`:``;return(0,o.jsxs)(`div`,{role:`group`,"aria-label":e.filename??`Audio attachment`,className:`flex items-center`,"data-testid":`audio-attachment-row`,children:[(0,o.jsx)(`button`,{type:`button`,onClick:d,disabled:!f,"aria-busy":s||void 0,"aria-label":`${h?`Pause audio`:`Play audio`}${x}`,className:(0,c.default)(wt,Tt[t]),children:h?(0,o.jsx)(l.PauseIcon,{className:`size-3`,weight:`fill`,"aria-hidden":!0}):(0,o.jsx)(l.PlayIcon,{className:`size-3`,weight:`fill`,"aria-hidden":!0})}),(0,o.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2.5 px-3`,children:[(0,o.jsxs)(`div`,{className:(0,c.default)(`mes-audio-wave`,t===`light`&&`mes-audio-wave--light`),children:[(0,o.jsx)(`div`,{ref:g,className:`mes-audio-wave__track`,"aria-hidden":!0,"data-testid":`audio-waveform-track`,children:_.map((e,t)=>(0,o.jsx)(`span`,{"data-testid":`amplitude-bar`,className:(0,c.default)(`mes-audio-wave__bar`,p>t/_.length*100&&`mes-audio-wave__bar--played`),style:{"--mes-audio-wave-bar":`${Math.min(Math.max(e,0),1)*100}%`}},t))}),(0,o.jsx)(`input`,{type:`range`,className:`mes-audio-wave__seek`,min:0,max:100,step:.1,value:p,onChange:u,disabled:!f,"aria-label":`Seek audio${x}`,"aria-valuetext":`${St(m)} of ${y}`})]}),(0,o.jsx)(`span`,{className:`shrink-0 text-xs leading-4 tracking-[0.24px] tabular-nums`,children:b})]}),r?(0,o.jsx)(`button`,{type:`button`,onClick:r.kind===`dismiss`?r.onDismiss:()=>{mt(e.src,e.filename)},"aria-label":r.kind===`dismiss`?`Remove attachment`:`Download audio${x}`,className:(0,c.default)(wt,Et[t]),children:r.kind===`dismiss`?(0,o.jsx)(l.XIcon,{className:`size-3`,weight:`bold`,"aria-hidden":!0}):(0,o.jsx)(l.DownloadSimpleIcon,{className:`size-3`,weight:`bold`,"aria-hidden":!0})}):null]})},Mt=`w-[299px]`,Nt=`py-5 pl-5 pr-3`,Pt=`rounded-[20px]`,Ft=({src:e,mimeType:t,filename:n,durationSeconds:r,waveformData:i,items:a})=>a&&a.length>0?a:e?[{src:e,mimeType:t,filename:n,durationSeconds:r,waveformData:i}]:[],It=({state:e,src:t,mimeType:r,filename:i,items:s,durationSeconds:c,waveformData:l,text:u,groupPosition:d,onDismiss:f})=>{let{message:p,threadList:m}=(0,a.useMessageContext)(),h=n.default.useId(),g=st(e),_=Ft({src:t,mimeType:r,filename:i,durationSeconds:c,waveformData:l,items:s});if(_.length===0)return null;let v=p?.id?`${m?p.parent_id??p.id:``}${p.id}`:h,y=e===`composer`?f?{kind:`dismiss`,onDismiss:f}:void 0:{kind:`download`};return(0,o.jsx)(ot,{variant:g,text:u,groupPosition:d,bordered:!1,widthClassName:Mt,paddingClassName:Nt,radiusClassName:Pt,"data-testid":`audio-attachment`,children:(0,o.jsx)(`div`,{className:`flex flex-col gap-2`,children:_.map((e,t)=>(0,o.jsx)(Ot,{item:e,variant:g,requester:lt(v,t),trailingAction:y},`${e.src}-${t}`))})})},Lt={Composer:e=>(0,o.jsx)(It,{...e,state:`composer`}),Sent:e=>(0,o.jsx)(It,{...e,state:`sent`}),Received:e=>(0,o.jsx)(It,{...e,state:`received`})},Rt={dark:`text-white/55`,light:`text-black/65`},zt={dark:`bg-white/10`,light:`bg-black/5`},Bt={dark:`text-white/85`,light:`text-black/85`},Vt=({variant:e,filename:n,title:r,mimeType:i=`application/octet-stream`,fileSize:a,onActivate:s,activateLabel:l,trailingAction:u})=>{let d=r??n??`File`,f=pt(i,n,a),p=(0,o.jsx)(`div`,{className:(0,c.default)(`flex size-10 shrink-0 items-center justify-center rounded-sm`,zt[e]),"aria-hidden":!0,children:t.n(i,{className:(0,c.default)(`size-6`,Bt[e]),weight:`regular`})}),m=(0,o.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col text-left`,children:[(0,o.jsx)(`p`,{className:`truncate font-medium leading-snug`,children:d}),f?(0,o.jsx)(`p`,{className:(0,c.default)(`truncate text-xs leading-4`,Rt[e]),children:f}):null]}),h=s?(0,o.jsxs)(`button`,{type:`button`,onClick:s,"aria-label":l,className:(0,c.default)(`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:[p,m]}):(0,o.jsxs)(o.Fragment,{children:[p,m]});return(0,o.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-2`,children:[h,u?(0,o.jsx)(`div`,{className:`shrink-0`,children:u}):null]})},Ht=({onClick:e,variant:t=`overlay`,ariaLabel:n=`Dismiss attachment`})=>(0,o.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),e()},"aria-label":n,className:(0,c.default)(`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:(0,o.jsx)(l.XIcon,{className:`size-3`,weight:`bold`})}),Ut=({src:e,filename:t,fileSize:n,mimeType:r,title:i,items:a})=>a&&a.length>0?a:e?[{src:e,filename:t,fileSize:n,mimeType:r,title:i}]:[],Wt=({variant:e,item:t,index:n,onActivate:r,trailingAction:i})=>{let a=t.filename??Q(t.src);return(0,o.jsx)(Vt,{variant:e,filename:a,title:t.title,mimeType:t.mimeType??`application/octet-stream`,fileSize:t.fileSize,onActivate:()=>r(n),activateLabel:`Download ${a}`,trailingAction:i})},Gt=({state:e,src:t,filename:n,fileSize:r,mimeType:i,title:a,items:s,text:u,groupPosition:d,onClick:f,onDismiss:p})=>{let m=st(e),h=e===`composer`&&!!p,g=Ut({src:t,filename:n,fileSize:r,mimeType:i,title:a,items:s}),_=e=>{if(f?.(e)===!1)return;let t=g[e];if(!t)return;let n=t.filename??Q(t.src);mt(t.src,n)};if(g.length===0)return null;let v=(0,o.jsx)(`span`,{className:(0,c.default)(`flex size-8 items-center justify-center rounded-full`,m===`dark`?`text-white/70`:`text-black/70`),"aria-hidden":!0,children:(0,o.jsx)(l.DownloadSimpleIcon,{className:`size-5`,weight:`bold`})});return(0,o.jsx)(ot,{variant:m,text:u,groupPosition:d,"data-testid":`file-attachment`,children:(0,o.jsx)(`div`,{className:`flex flex-col gap-2`,children:g.map((e,t)=>(0,o.jsx)(Wt,{variant:m,item:e,index:t,onActivate:_,trailingAction:h&&t===0?(0,o.jsx)(Ht,{onClick:p,variant:`inline`}):v},`${e.src}-${t}`))})})},Kt={Composer:e=>(0,o.jsx)(Gt,{...e,state:`composer`}),Sent:e=>(0,o.jsx)(Gt,{...e,state:`sent`}),Received:e=>(0,o.jsx)(Gt,{...e,state:`received`})},qt=`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`,Jt=`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`,Yt=({onPrev:e,onNext:t,prevLabel:n=`Previous`,nextLabel:r=`Next`})=>(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`button`,{type:`button`,onClick:e,"aria-label":n,className:`${Jt} left-4`,children:(0,o.jsx)(l.CaretLeftIcon,{size:20,weight:`bold`,"aria-hidden":!0})}),(0,o.jsx)(`button`,{type:`button`,onClick:t,"aria-label":r,className:`${Jt} right-4`,children:(0,o.jsx)(l.CaretRightIcon,{size:20,weight:`bold`,"aria-hidden":!0})})]}),Xt=({url:e,filename:r,variant:i=`pill`,label:a=`Download`,iconOnly:s,tone:u=`dark`,onTriggered:d})=>{let[f,p]=(0,n.useState)(!1),m=(0,n.useCallback)(t=>{t.stopPropagation(),!f&&(p(!0),mt(e,r).catch(()=>{}).finally(()=>{p(!1),d?.()}))},[f,e,r,d]),h=s??i!==`pill`,g={className:(0,c.default)(i===`pill`?`size-4`:`size-5`,`shrink-0`),weight:`bold`};return i===`inline`?(0,o.jsx)(`button`,{type:`button`,onClick:m,disabled:f,"aria-label":a,className:(0,c.default)(`flex size-8 shrink-0 items-center justify-center rounded-full transition-colors disabled:opacity-70`,{dark:`text-white/70 hover:bg-white/[0.08] hover:text-white`,light:`text-black/70 hover:bg-black/[0.08] hover:text-black`}[u]),children:f?(0,o.jsx)(t.c,{"aria-hidden":!0}):(0,o.jsx)(l.DownloadSimpleIcon,{className:`size-5 shrink-0`,weight:`bold`,"aria-hidden":!0})}):i===`viewer`?(0,o.jsx)(`button`,{type:`button`,onClick:m,disabled:f,"aria-label":a,className:qt,children:f?(0,o.jsx)(l.CircleNotchIcon,{size:20,weight:`bold`,"aria-hidden":!0}):(0,o.jsx)(l.DownloadSimpleIcon,{size:20,weight:`bold`,"aria-hidden":!0})}):(0,o.jsxs)(`button`,{type:`button`,onClick:m,disabled:f,"aria-label":h?a:void 0,className:(0,c.default)(`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`,u===`dark`?`bg-[#121110] text-white hover:bg-[#2a2928]`:`bg-white text-[#121110] hover:bg-white/90`),children:[f?(0,o.jsx)(t.c,{"aria-hidden":!0}):(0,o.jsx)(l.DownloadSimpleIcon,{...g,"aria-hidden":!0}),h?null:a]})},Zt=(e,t,n)=>Math.min(Math.max(e,t),n),Qt=({length:e,initialIndex:t,open:r})=>{let i=Zt(t,0,Math.max(e-1,0)),[a,o]=(0,n.useState)(i);(0,n.useEffect)(()=>{r&&o(Zt(t,0,Math.max(e-1,0)))},[r,t,e]),(0,n.useEffect)(()=>{o(t=>Zt(t,0,Math.max(e-1,0)))},[e]);let s=(0,n.useCallback)(()=>{e<=1||o(t=>t<=0?e-1:t-1)},[e]),c=(0,n.useCallback)(()=>{e<=1||o(t=>t>=e-1?0:t+1)},[e]);return(0,n.useEffect)(()=>{if(!r||e<=1)return;let t=e=>{if(e.key!==`ArrowLeft`&&e.key!==`ArrowRight`)return;let t=document.activeElement;t&&(t.tagName===`VIDEO`||t.tagName===`AUDIO`)||(e.preventDefault(),e.key===`ArrowLeft`?s():c())};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[r,e,s,c]),{index:a,prev:s,next:c}},$t=({open:e,onClose:t,ariaLabel:r,counter:i,actions:a,children:s,"data-testid":c})=>{let u=(0,n.useRef)(null),d=(0,n.useRef)(null);return(0,n.useEffect)(()=>{let t=u.current;if(t){if(e){if(!t.open){if(typeof t.showModal==`function`)try{t.showModal()}catch{t.setAttribute(`open`,``)}else t.setAttribute(`open`,``)}let e=typeof document<`u`?document.activeElement:null;return d.current?.focus(),()=>{if(t.open){if(typeof t.close==`function`)try{t.close()}catch{t.removeAttribute(`open`)}else t.removeAttribute(`open`)}e&&document.body.contains(e)&&e.focus()}}if(t.open){if(typeof t.close==`function`)try{t.close()}catch{t.removeAttribute(`open`)}else t.removeAttribute(`open`)}}},[e]),(0,o.jsxs)(`dialog`,{ref:u,className:`mes-media-viewer`,"aria-label":r??`Attachment viewer`,"data-testid":c,onClose:()=>{t()},onClick:e=>{e.target===u.current&&t()},children:[(0,o.jsxs)(`div`,{className:`pointer-events-none absolute inset-x-3 top-3 z-[1] flex items-center justify-between gap-3`,children:[i?(0,o.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:i}):null,(0,o.jsxs)(`div`,{className:`pointer-events-auto ml-auto inline-flex items-center gap-2`,children:[a,(0,o.jsx)(`button`,{ref:d,type:`button`,onClick:t,"aria-label":`Close viewer`,className:qt,children:(0,o.jsx)(l.XIcon,{size:20,weight:`bold`,"aria-hidden":!0})})]})]}),(0,o.jsx)(`div`,{className:`box-border flex h-full w-full items-center justify-center px-6 py-16`,children:s})]})},en=({open:e,items:t,initialIndex:r=0,onClose:i})=>{let{index:a,prev:s,next:c}=Qt({length:t.length,initialIndex:r,open:e}),l=t[a],u=(0,n.useMemo)(()=>l?.filename??(l?Q(l.src):`image`),[l]);return l?(0,o.jsxs)($t,{open:e,onClose:i,ariaLabel:u,counter:t.length>1?`${a+1} / ${t.length}`:void 0,actions:(0,o.jsx)(Xt,{url:l.src,filename:u,variant:`viewer`,label:`Download ${u}`}),"data-testid":`image-viewer`,children:[e?(0,o.jsx)(`img`,{src:l.src,alt:l.alt??u,draggable:!1,decoding:`async`,className:`block h-auto max-h-[calc(100dvh-128px)] w-auto max-w-[min(96vw,1400px)] select-none object-contain`},`${a}:${l.src}`):null,t.length>1?(0,o.jsx)(Yt,{onPrev:s,onNext:c,prevLabel:`Previous image`,nextLabel:`Next image`}):null]}):null},tn=`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`,nn={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]`]},rn=`--mes-single-width-cap`,an=`[--mes-single-width-cap:309px] sm:[--mes-single-width-cap:326px]`,on=436,sn=({tiles:e,onTileActivate:t,maxVisible:n=4,singleAspectRatio:r,className:i})=>{let a=e.length;if(a===0)return null;let s=e.slice(0,Math.min(a,n)),l=a-s.length,u=l>0?(0,o.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:[`+`,l]}):null,d=(e,n,r)=>{let i=(0,c.default)(tn,`h-full w-full`,nn[s.length]?.[n]);return t?(0,o.jsxs)(`button`,{type:`button`,onClick:()=>t(n),"aria-label":e.ariaLabel??`Open media ${n+1}`,className:(0,c.default)(i,e.cursorClassName??`cursor-zoom-in`),children:[e.content,r]},n):(0,o.jsxs)(`div`,{className:i,children:[e.content,r]},n)},f;return r&&(f={aspectRatio:r,width:`min(var(${rn}), ${Math.round(on*r*100)/100}px)`,maxWidth:`100%`}),s.length===1?(0,o.jsx)(`div`,{className:(0,c.default)(r?an:`aspect-square w-full`,i),style:f,children:d(s[0],0,u)}):s.length===2?(0,o.jsx)(`div`,{className:(0,c.default)(`grid aspect-[16/9] w-full grid-cols-2 gap-0.5`,i),children:s.map((e,t)=>d(e,t,t===s.length-1?u:null))}):s.length===3?(0,o.jsxs)(`div`,{className:(0,c.default)(`grid aspect-[4/3] w-full grid-cols-2 grid-rows-2 gap-0.5`,i),children:[(0,o.jsx)(`div`,{className:`row-span-2`,children:d(s[0],0)}),d(s[1],1),d(s[2],2,u)]}):(0,o.jsx)(`div`,{className:(0,c.default)(`grid aspect-[379/286] w-full grid-cols-2 grid-rows-2 gap-0.5`,i),children:s.map((e,t)=>{let n=l>0&&t===s.length-1;return d(e,t,n?u:null)})})},cn=({src:e,suppliedRatio:t,fallbackRatio:r})=>{let[i,a]=n.default.useState(),o=n.default.useCallback(t=>{if(!t||t.naturalWidth<=0||t.naturalHeight<=0||e===void 0)return;let n=t.naturalWidth/t.naturalHeight;a(t=>t&&t.src===e&&t.ratio===n?t:{src:e,ratio:n})},[e]),s=n.default.useCallback(e=>o(e.currentTarget),[o]),c=i&&i.src===e?i.ratio:void 0;return{ratio:t??c??r,imgRef:o,onLoad:s}},ln=e=>{let[t,r]=(0,n.useState)(!1),[i,a]=(0,n.useState)(0);return{viewerOpen:t,viewerIndex:i,handleActivate:(0,n.useCallback)(t=>{e?.(t)!==!1&&(a(t),r(!0))},[e]),closeViewer:(0,n.useCallback)(()=>r(!1),[])}},un=({item:e,index:n,totalCount:r,fallbackLoading:i,imgRef:a,onLoad:s})=>({ariaLabel:`Open image ${n+1} of ${r}`,content:(0,o.jsx)(`img`,{ref:a,src:t.s(e.src)??e.src,alt:e.alt??``,width:e.width,height:e.height,draggable:!1,loading:e.loading??i,decoding:`async`,onLoad:s,className:`absolute inset-0 size-full object-cover`})}),dn=({src:e,alt:t,items:n})=>n&&n.length>0?n:e?[{src:e,alt:t}]:[],fn=(e,t)=>e.map((n,r)=>({src:n.src,alt:n.alt,filename:t&&e.length===1?t:t?`${t} (${r+1})`:void 0})),pn=({src:e,alt:n,filename:r,loading:i=`lazy`,onClick:a,onDismiss:s})=>{let{viewerOpen:c,viewerIndex:l,handleActivate:u,closeViewer:d}=ln(a);return(0,o.jsxs)(`div`,{className:`relative w-fit`,children:[(0,o.jsx)(`button`,{type:`button`,onClick:()=>u(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:(0,o.jsx)(`img`,{src:t.s(e)??e,alt:n??``,draggable:!1,loading:i,decoding:`async`,className:`size-full object-cover`})}),s?(0,o.jsx)(`div`,{className:`absolute right-2 top-2 z-10`,children:(0,o.jsx)(Ht,{onClick:s})}):null,(0,o.jsx)(en,{open:c,items:fn([{src:e,alt:n}],r),initialIndex:l,onClose:d})]})},mn=326/246,hn=({state:e,src:t,alt:n,filename:r,items:i,text:a,groupPosition:s,loading:c=`lazy`,onClick:l})=>{let u=dn({src:t,alt:n,items:i}),d=st(e),{viewerOpen:f,viewerIndex:p,handleActivate:m,closeViewer:h}=ln(l),g=u.length===1,_=g?u[0]:void 0,v=cn({src:_?.src,suppliedRatio:_?.width&&_?.height?_.width/_.height:void 0,fallbackRatio:mn});if(u.length===0)return null;let y=u.map((e,t)=>un({item:e,index:t,totalCount:u.length,fallbackLoading:c,imgRef:g?v.imgRef:void 0,onLoad:g?v.onLoad:void 0}));return(0,o.jsxs)(ot,{variant:d,text:a,groupPosition:s,bordered:!1,widthClassName:g?`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:[(0,o.jsx)(`div`,{className:`relative`,children:(0,o.jsx)(sn,{tiles:y,onTileActivate:m,singleAspectRatio:g?v.ratio:void 0})}),(0,o.jsx)(en,{open:f,items:fn(u,r),initialIndex:p,onClose:h})]})},gn={Composer:e=>(0,o.jsx)(pn,{...e}),Sent:e=>(0,o.jsx)(hn,{...e,state:`sent`}),Received:e=>(0,o.jsx)(hn,{...e,state:`received`})},_n=({open:e,items:t,initialIndex:r=0,onClose:i})=>{let{index:a,prev:s,next:c}=Qt({length:t.length,initialIndex:r,open:e}),l=t[a],u=(0,n.useMemo)(()=>l?.filename??(l?Q(l.src):`document`),[l]),d=(0,n.useMemo)(()=>l?vn(l.src):void 0,[l]);return!l||!d?null:(0,o.jsxs)($t,{open:e,onClose:i,ariaLabel:u,counter:t.length>1?`${a+1} / ${t.length}`:void 0,"data-testid":`pdf-viewer`,children:[(0,o.jsx)(`iframe`,{src:d,title:u,className:`block h-[calc(100dvh-128px)] w-[min(96vw,1400px)] border-0 bg-white`,sandbox:`allow-scripts allow-forms allow-popups allow-downloads`},`${a}:${l.src}`),t.length>1?(0,o.jsx)(Yt,{onPrev:s,onNext:c,prevLabel:`Previous document`,nextLabel:`Next document`}):null]})},vn=e=>{let t=e.indexOf(`#`),n=t===-1?e:e.slice(0,t),r=t===-1?``:e.slice(t+1),i=new URLSearchParams(r);return i.has(`toolbar`)||i.set(`toolbar`,`0`),i.has(`navpanes`)||i.set(`navpanes`,`0`),`${n}#${i.toString()}`},yn=({src:e,filename:t,fileSize:n,title:r,items:i})=>i&&i.length>0?i:e?[{src:e,filename:t,fileSize:n,title:r}]:[],bn=({variant:e,item:t,index:n,onActivate:r,trailingAction:i})=>{let a=t.filename??Q(t.src);return(0,o.jsx)(Vt,{variant:e,filename:a,title:t.title,mimeType:`application/pdf`,fileSize:t.fileSize,onActivate:()=>r(n),activateLabel:`Open ${a}`,trailingAction:i})},xn=({state:e,src:t,filename:n,fileSize:r,title:i,items:a,text:s,groupPosition:c,onClick:l,onDismiss:u})=>{let d=st(e),f=yn({src:t,filename:n,fileSize:r,title:i,items:a}),{viewerOpen:p,viewerIndex:m,handleActivate:h,closeViewer:g}=ln(l),_=e===`composer`&&!!u;if(f.length===0)return null;let v=f.map(e=>({src:e.src,filename:e.filename??Q(e.src)}));return(0,o.jsxs)(ot,{variant:d,text:s,groupPosition:c,"data-testid":`pdf-attachment`,children:[(0,o.jsx)(`div`,{className:`flex flex-col gap-2`,children:f.map((t,n)=>{let r=t.filename??Q(t.src),i=_&&n===0?(0,o.jsx)(Ht,{onClick:u,variant:`inline`}):e===`composer`?void 0:(0,o.jsx)(Xt,{url:t.src,filename:r,variant:`inline`,label:`Download ${r}`,tone:d});return(0,o.jsx)(bn,{variant:d,item:t,index:n,onActivate:h,trailingAction:i},`${t.src}-${n}`)})}),(0,o.jsx)(_n,{open:p,items:v,initialIndex:m,onClose:g})]})},Sn={Composer:e=>(0,o.jsx)(xn,{...e,state:`composer`}),Sent:e=>(0,o.jsx)(xn,{...e,state:`sent`}),Received:e=>(0,o.jsx)(xn,{...e,state:`received`})},Cn=150,wn=({open:e,items:r,initialIndex:i=0,onClose:s})=>{let{index:c,prev:l,next:u}=Qt({length:r.length,initialIndex:i,open:e}),d=(0,n.useRef)(null),f=(0,a.useActiveAudioPlayer)();(0,n.useEffect)(()=>{e&&(f?.pause(),t.o(d.current))},[e,f]);let[p,m]=(0,n.useState)(e);e&&!p&&m(!0),(0,n.useEffect)(()=>{if(e||!p)return;d.current?.pause();let t=window.setTimeout(()=>m(!1),Cn);return()=>window.clearTimeout(t)},[e,p]);let h=r[c],g=(0,n.useMemo)(()=>h?.filename??(h?Q(h.src):`video`),[h]);return h?(0,o.jsxs)($t,{open:e,onClose:s,ariaLabel:g,counter:r.length>1?`${c+1} / ${r.length}`:void 0,"data-testid":`video-viewer`,children:[p?(0,o.jsx)(`video`,{ref:d,"data-testid":`video-viewer-media`,src:h.src,poster:h.poster,controls:!0,autoPlay:!0,muted:!0,playsInline:!0,preload:h.preload??`metadata`,className:`block h-auto max-h-[calc(100dvh-128px)] w-auto max-w-[min(96vw,1400px)] bg-black`,children:h.mimeType?(0,o.jsx)(`source`,{src:h.src,type:h.mimeType}):null},`${c}:${h.src}`):null,r.length>1?(0,o.jsx)(Yt,{onPrev:l,onNext:u,prevLabel:`Previous video`,nextLabel:`Next video`}):null]}):null},Tn=1,En=4/5,Dn=16/9,On=()=>(0,o.jsx)(`div`,{className:`pointer-events-none absolute inset-0 flex items-center justify-center`,children:(0,o.jsx)(`span`,{className:`flex size-12 items-center justify-center rounded-full bg-black/25 text-white backdrop-blur-[20px]`,children:(0,o.jsx)(l.PlayIcon,{className:`size-6`,weight:`fill`,"aria-hidden":!0})})}),kn=e=>{let t=e.indexOf(`#`);if(t===-1)return`${e}#t=0.001`;let n=e.slice(t+1);return/(^|&)t=/.test(n)?e:`${e}&t=0.001`},An=({item:e,index:t,showPlayBadge:n=!0,imgRef:r,onLoad:i})=>(0,o.jsxs)(`div`,{className:`absolute inset-0 size-full bg-[#0d0d0d]`,children:[e.poster?(0,o.jsx)(`img`,{ref:r,src:e.poster,alt:`Video ${t+1} thumbnail`,draggable:!1,loading:`lazy`,decoding:`async`,onLoad:i,className:`absolute inset-0 size-full object-cover`}):e.src&&e.preload!==`none`?(0,o.jsx)(`video`,{src:kn(e.src),muted:!0,playsInline:!0,preload:`metadata`,"aria-label":`Video ${t+1} thumbnail`,className:`absolute inset-0 size-full object-cover`}):(0,o.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center`,children:(0,o.jsx)(l.VideoCameraIcon,{className:`size-16 text-white/30`,weight:`regular`,"aria-hidden":!0})}),n?(0,o.jsx)(On,{}):null]}),jn=({item:e,index:t,totalCount:n,isOverflowTile:r,imgRef:i,onLoad:a})=>({ariaLabel:`Play video ${t+1} of ${n}`,cursorClassName:`cursor-pointer`,content:(0,o.jsx)(An,{item:e,index:t,showPlayBadge:!r,imgRef:i,onLoad:a})}),Mn=({src:e,poster:t,mimeType:n,preload:r,naturalAspectRatio:i,items:a})=>a&&a.length>0?r?a.map(e=>({...e,preload:e.preload??r})):a:e?[{src:e,poster:t,mimeType:n,preload:r,naturalAspectRatio:i}]:[],Nn=(e,t)=>e.map((n,r)=>({src:n.src,poster:n.poster,mimeType:n.mimeType,preload:n.preload,filename:t&&e.length===1?t:t?`${t} (${r+1})`:void 0})),Pn=({src:e,poster:t,mimeType:n,filename:r,preload:i,onClick:a,onDismiss:s})=>{let{viewerOpen:c,viewerIndex:l,handleActivate:u,closeViewer:d}=ln(a);return(0,o.jsxs)(`div`,{className:`relative w-fit`,children:[(0,o.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:(0,o.jsx)(An,{item:{src:e,poster:t,mimeType:n,preload:i},index:0})}),s?(0,o.jsx)(`div`,{className:`absolute right-2 top-2 z-10`,children:(0,o.jsx)(Ht,{onClick:s})}):null,(0,o.jsx)(wn,{open:c,items:Nn([{src:e,poster:t,mimeType:n,preload:i}],r),initialIndex:l,onClose:d})]})},Fn=({state:e,src:t,poster:n,mimeType:r,filename:i,items:a,text:s,groupPosition:c,preload:l,naturalAspectRatio:u,onClick:d})=>{let f=Mn({src:t,poster:n,mimeType:r,preload:l,naturalAspectRatio:u,items:a}),p=st(e),{viewerOpen:m,viewerIndex:h,handleActivate:g,closeViewer:_}=ln(d),v=f.length===1,y=v?f[0]:void 0,b=cn({src:y?.poster,suppliedRatio:y?.naturalAspectRatio,fallbackRatio:Tn});if(f.length===0)return null;let x=f.length>4?3:-1,S=f.map((e,t)=>jn({item:e,index:t,totalCount:f.length,isOverflowTile:t===x,imgRef:v?b.imgRef:void 0,onLoad:v?b.onLoad:void 0})),C=Math.min(Math.max(b.ratio,En),Dn);return(0,o.jsxs)(ot,{variant:p,text:s,groupPosition:c,bordered:!1,widthClassName:v?`w-fit max-w-[313px] sm:max-w-[330px]`:`w-[383px] max-w-full`,paddingClassName:`p-0.5`,radiusClassName:c&&c!==`single`?void 0:`rounded-[20px]`,"data-testid":`video-attachment`,children:[(0,o.jsx)(`div`,{className:`relative`,children:(0,o.jsx)(sn,{tiles:S,onTileActivate:g,singleAspectRatio:v?C:void 0})}),(0,o.jsx)(wn,{open:m,items:Nn(f,i),initialIndex:h,onClose:_})]})},In={Image:gn,Video:{Composer:e=>(0,o.jsx)(Pn,{...e}),Sent:e=>(0,o.jsx)(Fn,{...e,state:`sent`}),Received:e=>(0,o.jsx)(Fn,{...e,state:`received`})},Audio:Lt,Pdf:Sn,File:Kt};function $(e){return e?.trim()||void 0}function Ln(e){let{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 Rn(e){return e.trim().replace(/^https?:\/\//i,``).replace(/\/+$/,``).toLowerCase()}function zn(e,t){if(!e?.trim()||!t?.trim())return!1;let n=Rn(e),r=Rn(t);if(n===r)return!0;if(!n.includes(r))return!1;let i=n.split(r).join(``);return!/[^\p{P}\p{Z}\p{C}]/u.test(i)}function Bn(e){let n=$(e.og_scrape_url)??$(e.title_link),r=$(e.image_url)??$(e.thumb_url),i=$(e.mime_type),a=$(e.asset_url),o=r&&Y(i,a)?void 0:a;return{title:$(e.title),description:$(e.text),url:n,thumbnailUrl:t.s(r),sourceUrl:o,layout:r||ue(i,o)?`featured`:`classic`,mimeType:i,accentColor:$(e.accent_color),status:`ready`}}function Vn(e){return Se(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`:e.mime_type?.startsWith(`audio/`)?`audio`:`file`:null}function Hn(e){if(!e?.length)return[];let t=[],n=(e,n)=>{let r=t[t.length-1];if(r?.type===`media`&&r.kind===e){r.attachments.push(n);return}t.push({type:`media`,kind:e,attachments:[n]})},r=e=>{let n=t[t.length-1];if(n?.type===`link`){n.attachments.push(e);return}t.push({type:`link`,attachments:[e]})};for(let t of e){if(Se(t)){r(t);continue}let e=Vn(t);e&&n(e,t)}return t}function Un(e){return e.filter(e=>e.type===`media`).length}function Wn(e,t,n){return t<=1?n:e===0?`first`:e===t-1?`end`:`middle`}function Gn(e){return $(e.image_url)??$(e.asset_url)??``}function Kn(e){switch(e){case`image`:return In.Image;case`video`:return In.Video;case`audio`:return In.Audio;case`pdf`:return In.Pdf;default:return In.File}}function qn(e,n){switch(e){case`image`:return{src:Gn(n),alt:$(n.title)};case`video`:return{src:$(n.asset_url)??``,poster:t.s(n.thumb_url),mimeType:$(n.mime_type),naturalAspectRatio:Ln(n)};case`audio`:return{src:$(n.asset_url)??``,mimeType:$(n.mime_type)??`audio/mpeg`,filename:$(n.title),durationSeconds:n.duration,waveformData:n.waveform_data};case`pdf`:return{src:$(n.asset_url)??``,filename:$(n.title),fileSize:n.file_size};case`file`:return{src:$(n.asset_url)??``,filename:$(n.title),fileSize:n.file_size,mimeType:$(n.mime_type)??`application/octet-stream`}}}function Jn(e,t){if(t.length>1)return{items:t.map(t=>qn(e,t))};let n=t[0];return n?qn(e,n):{}}function Yn({groupPosition:e,isMyMessage:t,segment:n}){let r=Kn(n.kind),i={...Jn(n.kind,n.attachments),groupPosition:e};return t?(0,o.jsx)(r.Sent,{...i}):(0,o.jsx)(r.Received,{...i})}var Xn=({groupPosition:e,isMyMessage:t,message:n,renderText:r})=>{let i=Hn(n.attachments);if(i.length===0)return null;let s=Un(i),l=n.text?.trim(),u=i.find(e=>e.type===`link`),d=u?.type===`link`?Bn(u.attachments[0]??{}).url:void 0,f=l&&zn(l,d)?void 0:l,p=0,m=[],h=f?`middle`:e,g=e===`single`||e===`end`,_=(e,n,r)=>{let i=t?xe.Sent:xe.Received;m.push((0,o.jsx)(i,{...Bn(e),groupPosition:r?h:`middle`},n))},v=(n,r)=>{let i=Wn(p,s,e);p+=1,m.push((0,o.jsx)(Yn,{groupPosition:i,isMyMessage:t,segment:n},r))};return i.forEach((e,t)=>{let n=t===i.length-1;if(e.type===`link`){e.attachments.forEach((r,i)=>{_(r,`link-${t}-${i}`,n&&i===e.attachments.length-1)});return}v(e,`media-${t}`)}),(0,o.jsxs)(`div`,{className:`str-chat__message-bubble-wrapper`,children:[(0,o.jsxs)(`div`,{className:`str-chat__message-bubble`,"data-attachment-bubble":`true`,"data-testid":`message-attachment-bubble`,style:{background:`transparent`,borderRadius:0,overflow:`visible`,padding:0},children:[(0,o.jsx)(`div`,{"data-testid":`message-attachment-rows`,className:(0,c.default)(`flex flex-col gap-[4px]`,t?`items-end`:`items-start`),children:m}),!f&&(0,o.jsx)(a.MessageErrorIcon,{})]}),f?(0,o.jsxs)(`div`,{"data-testid":`message-caption-bubble`,className:(0,c.default)(`str-chat__message-bubble`,{"relative isolate":g}),children:[(0,o.jsx)(a.MessageText,{message:n,renderText:r}),(0,o.jsx)(a.MessageErrorIcon,{}),g&&(0,o.jsx)(Ve,{side:t?`me`:`other`})]}):null]})},Zn=n.default.memo(e=>{let{additionalMessageInputProps:t,editing:r,endOfGroup:i,firstOfGroup:s,groupStyles:l,groupedByUser:u,handleAction:d,handleOpenThread:f,handleRetry:p,highlighted:m,isMessageAIGenerated:h,isMyMessage:g,message:_,renderText:v,threadList:y,viewerLanguage:b,onOutboundClick:x,resolvedOutbound:S}=e,{client:C}=(0,a.useChatContext)(`CustomMessage`),{channel:w}=(0,a.useChannelStateContext)(`CustomMessage`),{isUnlocking:T,onUnlockClick:E,onFetchSource:D,onDownloadClick:O}=Ee(`LockedAttachment`),[k,A]=(0,n.useState)(!1),M=(0,a.useMessageReminder)(_.id),{Attachment:N=a.Attachment,EditMessageModal:P=a.EditMessageModal,MessageActions:F,MessageBlocked:I=a.MessageBlocked,MessageBouncePrompt:L=a.MessageBouncePrompt,MessageDeleted:R=a.MessageDeleted,MessageIsThreadReplyInChannelButtonIndicator:ee=a.MessageIsThreadReplyInChannelButtonIndicator,MessageRepliesCountButton:te=a.MessageRepliesCountButton,ReminderNotification:z=a.ReminderNotification,StreamedMessageText:V=a.StreamedMessageText,PinIndicator:ne}=(0,a.useComponentContext)(`CustomMessage`),H=(0,a.messageHasAttachments)(_),re=(0,a.messageHasReactions)(_),ie=(0,n.useMemo)(()=>h?.(_),[h,_]),U=(0,n.useMemo)(()=>{let e=_.attachments??[],t=_.shared_location?[_.shared_location,...e]:e;if(!Ne(_))return t;let n=t.filter(e=>!(`type`in e)||!Se(e));return n.length===t.length?t:n},[_]),W=(0,n.useMemo)(()=>(_.attachments??[]).filter(Se),[_]),ae=(0,n.useMemo)(()=>{let e=_.text?.trim();return e?zn(e,W[0]?Bn(W[0]).url:void 0)?void 0:e:void 0},[_,W]),oe=(0,n.useMemo)(()=>Hn(U),[U]),G=(0,n.useMemo)(()=>{let e=B({message:_,viewerLanguage:b});return e===_.text?_:{..._,text:e}},[_,b]),se=oe.length>0,ce=oe.reduce((e,t)=>e+t.attachments.length,0)===(U?.length??0),K=l?.[0]??``,q=K===`top`?`first`:K===`middle`?`middle`:K===`bottom`?`end`:`single`,J=K===`single`||K===`bottom`;if((0,a.isDateSeparatorMessage)(_))return null;if(_.deleted_at||_.type===`deleted`)return(0,o.jsx)(R,{message:_});if((0,a.isMessageBlocked)(_))return(0,o.jsx)(I,{});let le=!y&&!!_.reply_count,Y=!y&&_.show_in_channel&&_.parent_id,ue=_.status===`failed`&&_.error?.status!==403,de=(0,a.isMessageBounced)(_),X;ue?X=()=>p(_):de&&(X=()=>A(!0));let Z=g(),fe=(0,c.default)(`str-chat__message str-chat__message-simple`,`str-chat__message--${_.type}`,`str-chat__message--${_.status}`,Z?`str-chat__message--me str-chat__message-simple--me`:`str-chat__message--other`,_.text?`str-chat__message--has-text`:`has-no-text`,{"str-chat__message--has-attachment":H,"str-chat__message--highlighted":m,"str-chat__message--pinned pinned-message":_.pinned,"str-chat__message--with-reactions":re,"str-chat__message-send-can-be-retried":_?.status===`failed`&&_?.error?.status!==403,"str-chat__message-with-thread-link":le||Y,"str-chat__virtual-message__wrapper--end":i,"str-chat__virtual-message__wrapper--first":s,"str-chat__virtual-message__wrapper--group":u}),pe=_.poll_id&&C.polls.fromState(_.poll_id),me=qe(_),he=Ne(_),ge=Pe(_),_e=!!(U?.length&&!_.quoted_message),ve=he&&Z&&_e,ye=se&&ce&&!_.quoted_message&&!pe&&!ie&&!he,be={contentType:`text`,amountText:_.metadata?.amount_text,paymentStatus:_.metadata?.payment_status,renderedText:_.text&&(0,o.jsx)(a.MessageText,{message:G,renderText:v})},Ce={contentType:`media`,title:_.metadata?.attachment_title,mimeType:_.metadata?.attachment_mime_type,thumbnailUrl:_.metadata?.attachment_thumbnail,amountText:_.metadata?.amount_text,detail:_.metadata?.attachment_detail,paymentStatus:_.metadata?.payment_status,onFetchSource:D?()=>D(_,w):void 0},we=(0,o.jsxs)(`div`,{className:(0,c.default)(`str-chat__message-bubble`,{"relative isolate":J}),children:[(0,o.jsx)(a.MessageText,{message:G,renderText:v}),J&&(0,o.jsx)(Ve,{side:Z?`me`:`other`})]}),Te=W.length>0&&(0,o.jsx)(`div`,{className:(0,c.default)(`flex flex-col gap-[4px]`,Z?`items-end`:`items-start`),children:W.map((e,t)=>{let n=Z?xe.Sent:xe.Received,r=t===W.length-1&&!ae;return(0,o.jsx)(n,{...Bn(e),groupPosition:r?q:`middle`},`locked-link-${t}`)})});return(0,o.jsxs)(o.Fragment,{children:[r&&(0,o.jsx)(P,{additionalMessageInputProps:t}),k&&(0,o.jsx)(a.MessageBounceModal,{MessageBouncePrompt:L,onClose:()=>A(!1),open:k}),(0,o.jsxs)(`div`,{className:fe,"data-message-id":_.id,"data-dd-privacy":`mask`,children:[ne&&(0,o.jsx)(ne,{}),!!M&&(0,o.jsx)(z,{reminder:M}),_.user&&(0,o.jsx)(j,{className:`str-chat__avatar str-chat__message-sender-avatar`,id:_.user.id,image:_.user.image,name:_.user.name||_.user.id,size:24,shape:`circle`,dmAgentEnabled:he}),(0,o.jsx)(`div`,{className:(0,c.default)(`str-chat__message-inner`,{"str-chat__simple-message--error-failed":ue||de}),"data-testid":`message-inner`,onClick:X,onKeyDown:X,role:X?`button`:void 0,tabIndex:X?0:void 0,style:{marginInlineEnd:0,marginInlineStart:0},children:me?(0,o.jsxs)(`div`,{className:`str-chat__message-bubble-wrapper message-tip-wrapper`,children:[(0,o.jsx)(Je,{message:_}),_.text?.trim()&&we]}):Fe(_)?(0,o.jsx)(`div`,{className:`str-chat__message-bubble-wrapper`,children:(0,o.jsxs)(`div`,{className:`flex items-center gap-2`,children:[Z&&F&&(0,o.jsx)(F,{}),Z?(0,o.jsx)(Ae,{...be,isMine:!0}):(0,o.jsx)(Ae,{...be,isMine:!1,isUnlocking:T(_.id),onUnlockClick:()=>E?.(_,w)}),!Z&&F&&(0,o.jsx)(F,{})]})}):Ie(_)?(0,o.jsxs)(`div`,{className:`str-chat__message-bubble-wrapper message-locked-attachment-wrapper`,children:[(0,o.jsxs)(`div`,{className:`flex items-center gap-2`,children:[Z&&F&&(0,o.jsx)(F,{}),Z?(0,o.jsx)(Ae,{...Ce,isMine:!0,onPreviewClick:()=>E?E(_,w):void 0}):(0,o.jsx)(Ae,{...Ce,isMine:!1,isUnlocking:T(_.id),onUnlockClick:()=>E?E(_,w):void 0,onDownloadClick:()=>O?O(_,w):void 0}),!Z&&F&&(0,o.jsx)(F,{})]}),Te,ae&&we]}):ye?(0,o.jsx)(Xn,{groupPosition:q,isMyMessage:Z,message:{...G,attachments:U,i18n:void 0},renderText:v}):(0,o.jsx)(`div`,{className:`str-chat__message-bubble-wrapper`,children:(0,o.jsxs)(`div`,{className:(0,c.default)(`str-chat__message-bubble`,{"relative isolate":J}),children:[he&&!ve&&(0,o.jsx)(Re,{message:_,hasAttachment:_e,isMyMessage:Z}),pe&&(0,o.jsx)(a.Poll,{poll:pe}),U?.length&&!_.quoted_message?(0,o.jsx)(N,{actionHandler:d,attachments:U}):null,ie?(0,o.jsx)(V,{message:G,renderText:v}):(0,o.jsx)(a.MessageText,{message:G,renderText:v}),(0,o.jsx)(a.MessageErrorIcon,{}),J&&(0,o.jsx)(Ve,{side:Z?`me`:`other`})]})})}),!ge&&!me&&(0,o.jsx)(`div`,{className:`str-chat__message-footer`,children:(!he||ve)&&(0,o.jsx)(Re,{message:_,hasAttachment:_e,isMyMessage:Z})}),(0,o.jsx)(et,{onOutboundClick:x,resolvedOutbound:S}),le&&(0,o.jsx)(te,{onClick:f,reply_count:_.reply_count}),Y&&(0,o.jsx)(ee,{})]},_.id)]})},(e,t)=>e.viewerLanguage!==t.viewerLanguage||e.onOutboundClick!==t.onOutboundClick||e.resolvedOutbound?.id!==t.resolvedOutbound?.id||e.resolvedOutbound?.name!==t.resolvedOutbound?.name?!1:(0,a.areMessageUIPropsEqual)(e,t)),Qn=e=>{let t=(0,a.useMessageContext)(`CustomMessage`),r=(0,n.useContext)(He),i=t.message.metadata?.outbound_id,s=typeof i==`string`?r?.[i]:void 0;return(0,o.jsx)(Zn,{...t,...e,resolvedOutbound:s})},$n=()=>{let{handleDelete:e,message:t}=(0,a.useMessageContext)(`CustomMessageActions`);return t.metadata?.payment_status===`paid`?null:(0,o.jsx)(u.DefaultDropdownActionButton,{onClick:e,"aria-label":`Delete`,title:`Delete`,className:`bg-marble rounded-full p-2 hover:bg-sand transition-all`,children:(0,o.jsx)(l.TrashSimpleIcon,{size:16,weight:`light`,"aria-hidden":!0})})},er=()=>{let{handleFlag:e}=(0,a.useMessageContext)(`CustomMessageActions`);return(0,o.jsx)(u.DefaultDropdownActionButton,{onClick:e,"aria-label":`Report`,title:`Report`,className:`bg-marble rounded-full p-2 hover:bg-sand transition-all`,children:(0,o.jsx)(l.FlagIcon,{size:16,weight:`light`,"aria-hidden":!0})})},tr=()=>{let{message:e}=(0,a.useMessageContext)(`CustomMessageActions`);return e.metadata?.custom_type===s.MESSAGE_CUSTOM_TYPE.ATTACHMENT?(0,o.jsx)(u.MessageActions,{messageActionSet:[{Component:$n,placement:`quick`,type:`delete`},{Component:er,placement:`quick`,type:`flag`}]}):null},nr=e=>({linkPreviews:Array.from(e.previews.values()).filter(e=>i.LinkPreviewsManager.previewIsLoaded(e)||i.LinkPreviewsManager.previewIsLoading(e))}),rr=()=>{let{linkPreviewsManager:e}=(0,a.useMessageComposer)(),{linkPreviews:t}=(0,a.useStateStore)(e.state,nr),n=t=>{e.dismissPreview(t)};return t.length>0?(0,o.jsx)(`div`,{"data-testid":`link-preview-list`,className:`messaging-link-preview-list flex flex-col items-stretch w-full gap-2`,children:t.map(e=>{let t=i.LinkPreviewsManager.previewIsLoading(e);return(0,o.jsx)(xe.Composer,{title:e.title,url:e.og_scrape_url,thumbnailUrl:e.image_url,layout:t||e.image_url?`featured`:`classic`,status:t?`loading`:`ready`,onDismiss:()=>n(e.og_scrape_url)},e.og_scrape_url)})}):null},ir=n.default.createContext(!1),ar=200,or=()=>(0,n.useContext)(ir),sr=({sendMessage:e,disabled:t,...n})=>(0,o.jsx)(`button`,{...n,type:`button`,"aria-label":`Send`,disabled:t,onPointerDown:e=>e.preventDefault(),onClick:e,children:(0,o.jsx)(l.ArrowUpIcon,{weight:`bold`,className:`size-4`})}),cr=()=>{let e=(0,n.useContext)(ir),{handleSubmit:t}=(0,a.useMessageInputContext)(),r=(0,a.useMessageComposerHasSendableData)(),i=e||!r,{SendButton:s=sr,AttachmentPreviewList:c=a.AttachmentPreviewList}=(0,a.useComponentContext)(`CustomMessageInput`),l=n.default.useRef(null);return n.default.useEffect(()=>{let e=l.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(()=>{e.contains(document.activeElement)&&(e.scrollTop=e.scrollHeight)});return t.observe(e),()=>t.disconnect()},[]),n.default.useEffect(()=>{let e=l.current;if(!e)return;let t=e=>{Array.from(e.clipboardData?.items??[]).some(e=>e.kind===`file`)||e.stopPropagation()};return e.addEventListener(`paste`,t),()=>e.removeEventListener(`paste`,t)},[]),(0,o.jsxs)(`div`,{ref:l,"data-testid":`composer-card`,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:[(0,o.jsxs)(`div`,{"data-testid":`composer-previews`,className:`messaging-composer-previews empty:hidden flex flex-col gap-2 px-2 pt-2`,children:[(0,o.jsx)(a.QuotedMessagePreview,{}),(0,o.jsx)(rr,{}),(0,o.jsx)(c,{})]}),(0,o.jsxs)(`div`,{"data-testid":`composer-row`,className:`messaging-composer-row flex items-start`,children:[(0,o.jsx)(a.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}),(0,o.jsx)(`div`,{"data-testid":`send-button-wrapper`,className:`sticky bottom-2 mt-auto mb-2 mr-2 shrink-0 pt-2`,children:(0,o.jsx)(s,{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:i,type:`button`})})]})]})},lr=()=>(0,o.jsxs)(`div`,{className:`messaging-composer-backdrop`,"aria-hidden":`true`,children:[(0,o.jsx)(`div`,{className:`messaging-composer-backdrop-blur`}),(0,o.jsx)(`div`,{className:`messaging-composer-backdrop-blur`}),(0,o.jsx)(`div`,{className:`messaging-composer-backdrop-blur`}),(0,o.jsx)(`div`,{className:`messaging-composer-backdrop-blur`}),(0,o.jsx)(`div`,{className:`messaging-composer-backdrop-blur`}),(0,o.jsx)(`div`,{className:`messaging-composer-backdrop-gradient`})]}),ur=({renderActions:e,renderHeader:t,renderFooter:r,disabled:i=!1,disabledReason:s,composerInput:c})=>{let{channel:l}=(0,a.useChannelStateContext)(),u=l?.data?.frozen===!0,d=!!c,f=n.default.useRef(null);return n.default.useEffect(()=>{if(!d)return;let e=f.current,t=e?.parentElement;if(!e||!t)return;let n=e.offsetHeight,r=()=>{let r=e.offsetHeight,i=r>n;n=r;let a=Array.from(t.querySelectorAll(`.str-chat__list`)).find(e=>e.scrollHeight>e.clientHeight)??null,o=a?a.scrollHeight-a.scrollTop-a.clientHeight<ar:!1;t.style.setProperty(`--messaging-composer-height`,`${r}px`),i&&o&&a&&(a.scrollTop=a.scrollHeight)};if(r(),typeof ResizeObserver>`u`)return;let i=new ResizeObserver(r);return i.observe(e),()=>{i.disconnect(),t.style.removeProperty(`--messaging-composer-height`)}},[d]),i?d?(0,o.jsxs)(`div`,{ref:f,"data-testid":`composer-chrome`,className:`messaging-composer-chrome messaging-composer-chrome--floating`,children:[(0,o.jsx)(lr,{}),(0,o.jsxs)(`div`,{className:`relative z-10 flex flex-col`,children:[t?.(),(0,o.jsx)(`div`,{"data-testid":`composer-locked-panel`,className:`messaging-composer-locked-panel flex w-full flex-col items-center justify-center gap-3 px-6 py-4`,children:s?(0,o.jsx)(`p`,{className:`max-w-[345px] text-center text-xs font-normal leading-[1.3] tracking-[0.12px] text-black/40`,children:s}):null}),r?.()]})]}):(0,o.jsxs)(o.Fragment,{children:[t?.(),(0,o.jsx)(`div`,{"data-testid":`composer-locked-panel`,className:`messaging-composer-locked-panel flex w-full flex-col items-center justify-center gap-3 px-6 py-4`,children:s?(0,o.jsx)(`p`,{className:`max-w-[345px] text-center text-xs font-normal leading-[1.3] tracking-[0.12px] text-black/40`,children:s}):null}),r?.()]}):d?(0,o.jsxs)(`div`,{ref:f,"data-testid":`composer-chrome`,className:`messaging-composer-chrome messaging-composer-chrome--floating`,children:[(0,o.jsx)(lr,{}),(0,o.jsxs)(`div`,{className:`relative z-10 flex min-h-0 flex-col`,children:[t?.(),(0,o.jsxs)(`div`,{className:`flex min-h-0 flex-col gap-4 p-3 pb-5 md:p-5`,children:[(0,o.jsxs)(`div`,{inert:u?``:void 0,"aria-disabled":u||void 0,"data-testid":`message-input`,className:`message-input flex min-h-0 items-end gap-4 aria-disabled:opacity-40`,children:[e&&(0,o.jsx)(`div`,{className:`flex h-12 shrink-0 items-center justify-center`,children:e()}),(0,o.jsx)(ir.Provider,{value:u,children:(0,o.jsx)(a.MessageInput,{Input:c??cr})})]}),r?.()]})]})]}):(0,o.jsxs)(`div`,{className:`flex min-h-0 flex-col gap-4 p-4`,children:[t?.(),(0,o.jsxs)(`div`,{inert:u?``:void 0,"aria-disabled":u||void 0,"data-testid":`message-input`,className:`message-input flex min-h-0 items-end gap-4 aria-disabled:opacity-40`,children:[e&&(0,o.jsx)(`div`,{className:`flex h-12 shrink-0 items-center justify-center`,children:e()}),(0,o.jsx)(ir.Provider,{value:u,children:(0,o.jsx)(a.MessageInput,{Input:cr})})]}),r?.()]})},dr={SYSTEM_DM_AGENT_PAUSED:`DM Agent has left the conversation`,SYSTEM_DM_AGENT_RESUMED:`DM Agent has rejoined the conversation`},fr=[`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.`},mr=`age safety guidelines.`,hr=`https://linktr.ee/s/about/contact`,gr=e=>fr.includes(e),_r=e=>gr(e.metadata?.custom_type),vr=e=>{let t=e.metadata?.custom_type;if((0,s.isDmAgentSystemType)(t))return{kind:`dm-agent`,type:t};if((0,s.isAgeSafetySystemType)(t))return{kind:`age-safety`,type:t};let n=e.dm_agent_system_type;if((0,s.isDmAgentSystemType)(n))return{kind:`dm-agent`,type:n}},yr=e=>{let t=e.indexOf(mr);if(t===-1)return e;let n=t+22;return(0,o.jsxs)(o.Fragment,{children:[e.slice(0,t),(0,o.jsx)(`a`,{href:hr,target:`_blank`,rel:`noopener noreferrer`,className:`mes-age-safety-system-message__emphasis font-medium text-inherit underline`,children:mr}),e.slice(n)]})},br=e=>{let t=!_r(e.message),n=vr(e.message);if(n?.kind===`dm-agent`){let r=e.message.text?.trim()||dr[n.type];return(0,o.jsxs)(`div`,{className:`str-chat__message--system`,"data-testid":`message-system`,children:[(0,o.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:[(0,o.jsx)(l.SparkleIcon,{size:16,weight:`regular`,"aria-hidden":!0,className:`mes-dm-agent-system-message__sparkle shrink-0`}),(0,o.jsx)(`p`,{className:`mes-dm-agent-system-message__text m-0 text-center text-[14px] font-normal leading-5 tracking-[0.21px]`,children:r})]}),!t&&(0,o.jsx)(a.MessageTimestamp,{message:e.message})]})}if(n?.kind===`age-safety`){let r=e.message.text?.trim()||pr[n.type];return(0,o.jsxs)(`div`,{className:`str-chat__message--system`,"data-testid":`message-system`,children:[(0,o.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:[(0,o.jsx)(l.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`}),(0,o.jsx)(`div`,{className:`mes-age-safety-system-message__content min-w-0 flex-[1_0_0]`,children:(0,o.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:yr(r)})})]}),!t&&(0,o.jsx)(a.MessageTimestamp,{message:e.message})]})}return(0,o.jsxs)(`div`,{className:`str-chat__message--system`,"data-testid":`message-system`,children:[(0,o.jsxs)(`div`,{className:`str-chat__message--system__text`,children:[(0,o.jsx)(`div`,{className:`str-chat__message--system__line`}),(0,o.jsx)(`p`,{children:e.message.text}),(0,o.jsx)(`div`,{className:`str-chat__message--system__line`})]}),!t&&(0,o.jsx)(a.MessageTimestamp,{message:e.message})]})},xr=(0,n.createContext)(!1),Sr=({cx:e,index:t})=>(0,o.jsx)(`circle`,{cx:e,cy:`6.15`,r:`3.9`,fill:`#A0A0A0`,children:(0,o.jsx)(`animateTransform`,{attributeName:`transform`,type:`translate`,values:`0 0; 0 -2.25; 0 0;`,dur:`900ms`,begin:`${120*t}ms`,repeatCount:`indefinite`})}),Cr=new Set([a.AIStates.Thinking,a.AIStates.Generating,a.AIStates.ExternalSources]),wr=({threadList:e})=>{let{channel:t,channelConfig:r,thread:i}=(0,a.useChannelStateContext)(),{client:s}=(0,a.useChatContext)(),{typing:c={}}=(0,a.useTypingContext)(),{aiState:l}=(0,a.useAIState)(t),u=(0,n.useContext)(xr);if(!e&&u&&Cr.has(l)){let e=Er(t,s.user?.id);return(0,o.jsx)(Tr,{avatarId:e?.id??`ai-agent`,avatarName:e?.name??e?.id??`Agent`,avatarImage:e?.image,testId:`typing-indicator-ai`})}if(r?.typing_events===!1)return null;let d=e?[]:Object.values(c).filter(({parent_id:e,user:t})=>t?.id!==s.user?.id&&!e),f=e?Object.values(c).filter(({parent_id:e,user:t})=>t?.id!==s.user?.id&&e===i?.id):[],p=e?f:d;if(!p.length)return null;let m=p[0]?.user,h=m?.id&&t.state.members[m.id]?t.state.members[m.id].user:void 0;return(0,o.jsx)(Tr,{avatarId:m?.id??h?.id??`typing-user`,avatarName:m?.name??h?.name??m?.id??`Typing user`,avatarImage:m?.image??h?.image,testId:`typing-indicator`})},Tr=({avatarId:e,avatarName:t,avatarImage:n,testId:r})=>(0,o.jsx)(`div`,{className:`str-chat__li str-chat__li--single str-chat__typing-indicator !static`,"data-testid":r,style:{marginBottom:`var(--messaging-channel-input-spacer-height, 80px)`},children:(0,o.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:[(0,o.jsx)(j,{className:`str-chat__avatar str-chat__message-sender-avatar`,id:e,name:t,image:n??void 0,size:24,shape:`circle`}),(0,o.jsx)(`div`,{className:`str-chat__message-inner mx-0`,children:(0,o.jsx)(`div`,{className:`str-chat__message-bubble-wrapper`,children:(0,o.jsxs)(`div`,{className:`str-chat__message-bubble relative isolate`,children:[(0,o.jsx)(`div`,{className:`str-chat__message-text min-h-11 flex items-center`,children:(0,o.jsx)(`div`,{className:`str-chat__message-text-inner str-chat__message-simple-text-inner`,children:(0,o.jsxs)(`svg`,{"aria-hidden":`true`,className:`block overflow-visible`,viewBox:`0 0 32 12.3`,width:`32`,height:`13`,overflow:`visible`,children:[(0,o.jsx)(Sr,{cx:`4`,index:0}),(0,o.jsx)(Sr,{cx:`16`,index:1}),(0,o.jsx)(Sr,{cx:`28`,index:2})]})})}),(0,o.jsx)(Ve,{side:`other`})]})})})]})});function Er(e,t){let n=e?.state?.members??{};for(let e of Object.values(n)){let n=e?.user;if(n&&n.id!==t)return n}}var Dr=()=>null,Or=({className:e,message:t})=>(0,o.jsxs)(`div`,{className:(0,c.default)(`flex items-center justify-center h-full`,e),children:[(0,o.jsxs)(`svg`,{viewBox:`0 0 100 100`,className:`size-8 fill-pebble`,stroke:`none`,children:[(0,o.jsx)(`circle`,{cx:`6`,cy:`50`,r:`6`,children:(0,o.jsx)(`animateTransform`,{attributeName:`transform`,dur:`1s`,type:`translate`,values:`0 15 ; 0 -15; 0 15`,repeatCount:`indefinite`,begin:`0.1`})}),(0,o.jsx)(`circle`,{cx:`30`,cy:`50`,r:`6`,children:(0,o.jsx)(`animateTransform`,{attributeName:`transform`,dur:`1s`,type:`translate`,values:`0 10 ; 0 -10; 0 10`,repeatCount:`indefinite`,begin:`0.2`})}),(0,o.jsx)(`circle`,{cx:`54`,cy:`50`,r:`6`,children:(0,o.jsx)(`animateTransform`,{attributeName:`transform`,dur:`1s`,type:`translate`,values:`0 5 ; 0 -5; 0 5`,repeatCount:`indefinite`,begin:`0.3`})})]}),t&&(0,o.jsx)(`span`,{className:`text-stone`,children:t})]}),kr=n.default.memo(()=>(0,o.jsx)(`div`,{className:`messaging-loading-state flex items-center justify-center h-full`,children:(0,o.jsxs)(`div`,{className:`flex items-center`,children:[(0,o.jsx)(Or,{className:`w-6 h-6`}),(0,o.jsx)(`span`,{className:`text-sm text-stone`,children:`Loading messages`})]})}));kr.displayName=`LoadingState`;var Ar=({onBack:e,showBackButton:t,renderMessageInputActions:r,renderMessageInputFooter:i,renderConversationFooter:s,onLeaveConversation:c,onBlockParticipant:l,showDeleteConversation:u=!0,onDeleteConversationClick:d,onBlockParticipantClick:f,onReportParticipantClick:p,showBlockParticipant:m=!0,showReportParticipant:h=!0,composerDisabled:g=!1,composerDisabledReason:_,showStarButton:v=!1,renderChannelBanner:y,customChannelActions:b,renderChannelActions:x,renderMessage:S,viewerLanguage:C,showChannelInfo:w=!0,onParticipantNameClick:T,onOutboundClick:E,resolveOutbound:D,composerInput:O})=>{let{channel:k,messages:A}=(0,a.useChannelStateContext)(),j=(0,n.useRef)(E);(0,n.useEffect)(()=>{j.current=E},[E]);let M=(0,n.useCallback)(e=>{j.current?.(e)},[]),N=E?M:void 0,P=Ke(A,D),F=k.state.messages.some(e=>e.type!==`deleted`),I=y?(0,o.jsx)(n.default.Fragment,{children:y()},`lt-channel-banner`):null,L=(0,o.jsx)(ee,{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:w,showStarButton:v,onLeaveConversation:c,onBlockParticipant:l,showDeleteConversation:u,showBlockParticipant:m,showReportParticipant:h,onDeleteConversationClick:d,onBlockParticipantClick:f,onReportParticipantClick:p,customChannelActions:b,renderChannelActions:x,onParticipantNameClick:T}),R=(0,n.useCallback)(e=>{let{message:t}=(0,a.useMessageContext)(`ChannelView`),n=(0,o.jsx)(Qn,{...e,viewerLanguage:C,onOutboundClick:N});return!S||!t?n:S(n,t)},[N,S,C]);return(0,o.jsx)(He.Provider,{value:P,children:(0,o.jsx)(a.WithComponents,{overrides:{Message:R,MessageActions:tr,UnreadMessagesNotification:()=>null,UnreadMessagesSeparator:()=>null},children:(0,o.jsx)(a.Window,{children:O?(0,o.jsxs)(`div`,{className:`messaging-channel-layout relative flex min-h-0 flex-1 flex-col`,children:[(0,o.jsxs)(`div`,{className:`messaging-channel-message-list messaging-channel-message-list--floating relative min-h-0 flex-1 overflow-hidden`,children:[!F&&(0,o.jsx)(`div`,{className:`str-chat__list`,children:(0,o.jsxs)(`div`,{className:`str-chat__message-list-scroll`,children:[L,I]})}),(0,o.jsx)(a.MessageList,{head:F?(0,o.jsxs)(`div`,{className:`sticky top-0 z-10`,children:[L,I]}):void 0,hideDeletedMessages:!0,hideNewMessageSeparator:!1})]},`lt-channel-message-list`),(0,o.jsx)(ur,{...r&&{renderActions:()=>r?.(k)},...s&&{renderHeader:()=>s(k)},renderFooter:()=>i?.(k),disabled:g,disabledReason:_,composerInput:O},`lt-channel-message-input`)]}):(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(`div`,{className:`flex-1 overflow-hidden relative`,children:[!F&&(0,o.jsx)(`div`,{className:`str-chat__list`,children:(0,o.jsxs)(`div`,{className:`str-chat__message-list-scroll`,children:[L,I]})}),(0,o.jsx)(a.MessageList,{head:F?(0,o.jsxs)(`div`,{className:`sticky top-0 z-10`,children:[L,I]}):void 0,hideDeletedMessages:!0,hideNewMessageSeparator:!1})]},`lt-channel-message-list`),s?(0,o.jsx)(n.default.Fragment,{children:s(k)},`lt-channel-conversation-footer`):null,(0,o.jsx)(ur,{...r&&{renderActions:()=>r?.(k)},renderFooter:()=>i?.(k),disabled:g,disabledReason:_,composerInput:O},`lt-channel-message-input`)]})})})})},jr=n.default.memo(({channel:e,onBack:t,showBackButton:r=!1,renderMessageInputActions:i,renderMessageInputFooter:l,renderConversationFooter:u,onLeaveConversation:d,onBlockParticipant:f,className:p,CustomChannelEmptyState:m=Dr,showDeleteConversation:h=!0,onDeleteConversationClick:g,onBlockParticipantClick:_,onReportParticipantClick:v,showBlockParticipant:y=!0,showReportParticipant:b=!0,composerDisabled:x=!1,composerDisabledReason:S,dmAgentEnabled:C,messageMetadata:w,onMessageSent:T,showStarButton:E=!1,renderChannelBanner:D,customChannelActions:O,renderChannelActions:k,renderMessage:A,onMessageLinkClick:j,sendButton:M,attachmentPreviewList:N,viewerLanguage:P,showChannelInfo:F=!0,onParticipantNameClick:I,onOutboundClick:L,resolveOutbound:R,composerInput:ee})=>{let z=(0,n.useCallback)(async(t,n,r)=>{let i=e.data?.chatbot_paused===!0,a=C&&!i,o={...n,...a&&{silent:!0},...w&&{metadata:{...n.metadata??{},...w}}},s={...r,...a&&{skip_push:!0}},c=await e.sendMessage(o,s);return T?.(c),c},[e,C,w,T]),B=(0,n.useRef)(null);(0,n.useEffect)(()=>{if(!j)return;let t=B.current;if(!t)return;let n=t=>{let n=t.target?.closest(`a[href]`),r=n?.getAttribute(`href`);if(!r)return;let i=(n?.closest(`[data-message-id]`))?.getAttribute(`data-message-id`);j(r,i?e.state.messages.find(e=>e.id===i):void 0)};return t.addEventListener(`click`,n),()=>t.removeEventListener(`click`,n)},[j,e]);let V=(0,s.isOfficialChannel)(e.type)?{"--lt-msg-card-width":`368px`}:void 0;return(0,o.jsx)(`div`,{ref:B,"data-testid":`channel-view`,className:(0,c.default)(`messaging-channel-view h-full flex flex-col`,p),style:V,children:(0,o.jsx)(xr.Provider,{value:C??!1,children:(0,o.jsx)(a.Channel,{channel:e,MessageSystem:br,EmptyStateIndicator:m,LoadingIndicator:kr,DateSeparator:te,TypingIndicator:wr,doSendMessageRequest:z,...M?{SendButton:M}:{},...N?{AttachmentPreviewList:N}:{},children:(0,o.jsx)(Ar,{onBack:t,showBackButton:r,renderMessageInputActions:i,renderMessageInputFooter:l,renderConversationFooter:u,onLeaveConversation:d,onBlockParticipant:f,CustomChannelEmptyState:m,showDeleteConversation:h,onDeleteConversationClick:g,onBlockParticipantClick:_,onReportParticipantClick:v,showBlockParticipant:y,showReportParticipant:b,composerDisabled:x,composerDisabledReason:S,showStarButton:E,renderChannelBanner:D,customChannelActions:O,renderChannelActions:k,renderMessage:A,viewerLanguage:P,showChannelInfo:F,onParticipantNameClick:I,onOutboundClick:L,resolveOutbound:R,composerInput:ee})})})})});jr.displayName=`ChannelView`;var Mr=n.default.memo(({message:e,onBack:t})=>(0,o.jsx)(`div`,{className:`messaging-error-state flex items-center justify-center h-full p-8`,children:(0,o.jsxs)(`div`,{className:`text-center max-w-sm`,children:[(0,o.jsx)(`div`,{className:`w-24 h-24 bg-danger-alt/20 rounded-full flex items-center justify-center mx-auto mb-6`,children:(0,o.jsx)(`span`,{className:`text-4xl`,children:`⚠️`})}),(0,o.jsx)(`h2`,{className:`font-semibold text-charcoal mb-2`,children:`Oops!`}),(0,o.jsx)(`p`,{className:`text-stone text-sm mb-6`,children:e}),t&&(0,o.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`})]})}));Mr.displayName=`ErrorState`;var Nr=({capabilities:e={},renderMessageInputActions:t,renderConversationFooter:r,onChannelSelect:i,onExitConversation:a,initialParticipantFilter:s,initialParticipantData:c,CustomChannelEmptyState:l,onBlockParticipantClick:u,onReportParticipantClick:d,dmAgentEnabled:f,onMessageSent:p,viewerLanguage:m,renderChannelBanner:h,customChannelActions:g,renderChannelActions:_,onParticipantNameClick:v,onOutboundClick:b,resolveOutbound:x,renderMessage:S,onMessageLinkClick:C,showChannelInfo:w,composerInput:T,attachmentPreviewList:E})=>{let{client:D,isConnected:O,isLoading:k,error:A,refreshConnection:j,service:M,debug:N}=y(),[P,F]=(0,n.useState)(null),[I,L]=(0,n.useState)(null),[R,ee]=(0,n.useState)(!1),{showDeleteConversation:te=!0}=e,z=(0,n.useRef)(c);z.current=c;let B=(0,n.useRef)(i);B.current=i;let V=(0,n.useRef)(null),ne=(0,n.useRef)(null);(0,n.useEffect)(()=>{ne.current=P},[P]),(0,n.useEffect)(()=>{if(!D||!O)return;let e=D.userID;if(!e)return;let t=`${e}::${s}`;if(V.current===t)return;V.current=t;let n=()=>{V.current===t&&(V.current=null)};(async()=>{try{N&&console.log(`[MessagingShell] Loading initial conversation with:`,s);let t=await D.queryChannels({type:`messaging`,members:{$eq:[e,s]}},{},{limit:1});if(t.length>0){F(t[0]),L(null),B.current?.(t[0]),N&&console.log(`[MessagingShell] Initial conversation loaded:`,t[0].id);return}let r=z.current;if(!r||!M){n(),L(`No conversation found with this account`),N&&console.log(`[MessagingShell] No conversation found for:`,s);return}try{let e=await M.startChannelWithParticipant({id:r.id,name:r.name,phone:r.phone});F(e),L(null),B.current?.(e),N&&console.log(`[MessagingShell] Channel created and loaded:`,e.id)}catch(e){console.error(`[MessagingShell] Failed to create conversation:`,e),n(),L(`Failed to create conversation`)}}catch(e){console.error(`[MessagingShell] Failed to load initial conversation:`,e),n(),ne.current||L(`Failed to load conversation`)}})()},[s,D,O,M,N]);let H=(0,n.useRef)(a);H.current=a;let re=(0,n.useCallback)(()=>{F(null),ee(!0),H.current?.()},[]);return k?(0,o.jsx)(kr,{}):A?(0,o.jsx)(Mr,{message:A,onBack:j}):!O||!D?(0,o.jsx)(Mr,{message:`Not connected to messaging service`,onBack:j}):I?(0,o.jsx)(Mr,{message:I}):R&&!P?(0,o.jsx)(Mr,{message:`Conversation ended`}):P?(0,o.jsx)(`div`,{className:`messaging-shell h-full bg-background-primary overflow-hidden`,children:(0,o.jsx)(`div`,{className:`flex h-full min-h-0 flex-col`,children:(0,o.jsx)(jr,{channel:P,renderMessageInputActions:t,renderConversationFooter:r,renderChannelBanner:h,onLeaveConversation:re,onBlockParticipant:re,CustomChannelEmptyState:l,showDeleteConversation:te,onBlockParticipantClick:u,onReportParticipantClick:d,dmAgentEnabled:f,onMessageSent:p,viewerLanguage:m,customChannelActions:g,renderChannelActions:_,onParticipantNameClick:v,onOutboundClick:b,resolveOutbound:x,renderMessage:S,onMessageLinkClick:C,showChannelInfo:w,composerInput:T,attachmentPreviewList:E},P.id)})}):(0,o.jsx)(kr,{})};function Pr(e){let t=e.state.pending_messages;if(t?.length)for(let n of t)e.state.addMessageSorted(n.message)}var Fr=n.default.createContext({selectedChannel:void 0,onChannelSelect:()=>{},debug:!1,renderMessagePreview:void 0,channelPreview:void 0,viewerLanguage:void 0}),Ir=Fr.Provider,Lr=()=>n.default.useContext(Fr),Rr=(e,t)=>{let n=Date.UTC(e.getFullYear(),e.getMonth(),e.getDate()),r=Date.UTC(t.getFullYear(),t.getMonth(),t.getDate());return Math.floor((r-n)/864e5)},zr=e=>{let t=new Date;if(Math.floor((t.getTime()-e.getTime())/1e3)<60)return`Just now`;let n=Rr(e,t);return n===0?e.toLocaleTimeString([],{hour:`numeric`,minute:`2-digit`,hour12:!0}):n===1?`Yesterday`:n<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`})},Br=n.default.memo(e=>{let{channel:t,unread:n}=e,{selectedChannel:r,onChannelSelect:i,debug:l,channelPreview:u,renderMessagePreview:d,viewerLanguage:f}=Lr(),{client:p}=(0,a.useChatContext)(),m=r?.id===t?.id,h=b(t);if(u)return(0,o.jsx)(u,{...e,active:m,selectedChannel:r,onChannelSelect:i,viewerLanguage:f});let g=()=>{t&&i(t)},_=e=>{let t=e.key===`Enter`||e.key===` `,n=e.repeat;!t||n||(e.preventDefault(),g())},v=x(t?.state?.members,p?.userID,t?.type),y=T(v?.user),S=v?.user?.image,C=(()=>{let e=t?.state?.messages;if(e?.length){for(let t=e.length-1;t>=0;t--)if(e[t].type!==`system`)return e[t]}})(),w=(()=>{let e=B({message:C,viewerLanguage:f}),{custom_type:t,attachment_content_type:n}=C?.metadata||{};if(t===s.MESSAGE_CUSTOM_TYPE.TIP)return e||`Sent a tip`;if(t===s.MESSAGE_CUSTOM_TYPE.PAID)return e||`Sent a message`;if(t===s.MESSAGE_CUSTOM_TYPE.ATTACHMENT){if(n===`text`)return`🔒 Sent a locked message`;if(n===`media`)return`🔒 Sent a locked attachment`}if(e)return e;let r=C?.attachments?.[0];return r?r.og_scrape_url?r.og_scrape_url:r.type===`image`?`📷 Sent an image`:r.type===`video`?`🎥 Sent a video`:r.type===`audio`?`🎵 Sent audio`:r.type===`file`?`📎 Sent a file`:`📎 Sent an attachment`:`No messages yet`})(),E=C?.created_at?zr(new Date(C.created_at)):``,D=C?Ne(C):!1,O=d?d(C,w):`${D?`✨ `:``}${w}`,k=n??0;return l&&console.log(`📺 [ChannelList] 📋 CHANNEL PREVIEW RENDER`,{channelId:t?.id,isSelected:m,participantName:y,unreadCount:k,hasTimestamp:!!E}),(0,o.jsx)(`div`,{role:`button`,tabIndex:0,onClick:g,onKeyDown:_,className:(0,c.default)(`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]":m,"hover:bg-black/[0.02]":!m}),"data-dd-privacy":`mask`,children:(0,o.jsxs)(`div`,{className:`flex items-start gap-4`,children:[(0,o.jsx)(j,{id:v?.user?.id||t.id||`unknown`,name:y,image:S,size:48,starred:h}),(0,o.jsxs)(`div`,{className:`flex-1 min-w-0 flex flex-col gap-1`,children:[(0,o.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,o.jsxs)(`h3`,{className:(0,c.default)(`text-sm font-medium truncate text-[#191918]`),children:[h&&(0,o.jsx)(`span`,{className:`sr-only`,children:`Starred conversation. `}),y]}),E&&(0,o.jsx)(`span`,{"data-testid":`channel-preview-timestamp`,className:`text-xs text-[#717070] flex-shrink-0`,children:E})]}),(0,o.jsxs)(`div`,{className:`flex items-center justify-between gap-2 min-w-0`,children:[(0,o.jsx)(`p`,{className:`text-sm text-[#717070] flex-1 line-clamp-1`,children:O}),k>0&&(0,o.jsx)(`span`,{"data-testid":`channel-preview-unread-badge`,className:`bg-[#7f22fe] text-white text-[10px] rounded-full h-4 flex items-center justify-center p-1 min-w-4 text-center flex-shrink-0`,children:k>99?`99+`:k})]})]})]})})});Br.displayName=`CustomChannelPreview`;var Vr={last_message_at:-1},Hr=n.default.memo(({onChannelSelect:e,selectedChannel:t,filters:r,allowNewMessagesFromUnfilteredChannels:i=!1,channelRenderFilterFn:s,sort:l=Vr,className:u,customEmptyStateIndicator:d,channelListPaginator:f=a.InfiniteScroll,channelPreview:p,renderMessagePreview:m,viewerLanguage:h,lockChannelOrder:g,onMessageNewHandler:v,onMessageNew:y,onChannelVisible:b,onAddedToChannel:x,onChannelUpdated:S})=>{let C=n.default.useRef(0);C.current++;let{debug:w=!1}=_(),T=n.default.useCallback(e=>{for(let t of e)Pr(t);return s?s(e):e},[s]);w&&console.log(`📺 [ChannelList] 🔄 RENDER START`,{renderCount:C.current,selectedChannelId:t?.id,filters:r});let E=n.default.useMemo(()=>({selectedChannel:t,onChannelSelect:e,debug:w,channelPreview:p,renderMessagePreview:m,viewerLanguage:h}),[t,e,w,p,m,h]);return(0,o.jsx)(`div`,{className:(0,c.default)(`messaging-channel-list h-full flex flex-col min-w-0 overflow-hidden`,u),children:(0,o.jsx)(`div`,{className:`flex-1 overflow-hidden min-w-0`,children:(0,o.jsx)(Ir,{value:E,children:(0,o.jsx)(a.ChannelList,{filters:r,sort:l,options:{limit:30},allowNewMessagesFromUnfilteredChannels:i,channelRenderFilterFn:T,lockChannelOrder:g,onMessageNewHandler:v,onMessageNew:y,onChannelVisible:b,onAddedToChannel:x,onChannelUpdated:S,Paginator:f,Preview:Br,EmptyStateIndicator:d},`${JSON.stringify(r)}:${JSON.stringify(l)}`)})})})});Hr.displayName=`ChannelList`;var Ur=`line-clamp-2 text-[14px] font-medium leading-5 tracking-[0.02em]`,Wr=`text-[14px] leading-5 tracking-[0.02em]`,Gr=()=>(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`br`,{}),(0,o.jsx)(`span`,{"aria-hidden":!0,className:`block h-1.5`})]}),Kr=e=>e.split(/\r?\n/).map((e,t,r)=>(0,o.jsxs)(n.default.Fragment,{children:[e,t<r.length-1?(0,o.jsx)(Gr,{}):null]},t)),qr=({surface:e,actions:t,layout:n})=>{if(t==null||t.length===0)return null;let r=n===`stacked`;return(0,o.jsx)(`div`,{className:(0,c.default)(`flex gap-2`,r?`mt-4 flex-col`:`min-w-0 max-w-[60%] flex-row flex-wrap justify-end`),children:t.map((t,n)=>(0,o.jsx)(ie,{variant:e,cta:t,fullWidth:r,standalone:!0},`${t.label}-${n}`))})},Jr=({ctaSurface:e,chinTextColor:t,title:n,subtitle:r,subtitleLines:i=3,appIcon:a,actions:s})=>{let l=n!=null&&n.trim()!==``,u=r!=null&&r.trim()!==``,d=s!=null&&s.length>0;if(!l&&!u&&!d)return null;let f={color:t},p=i>1?{...f,display:`-webkit-box`,WebkitBoxOrient:`vertical`,WebkitLineClamp:i,overflow:`hidden`}:f,m=d&&(s?.[0]?.variant??`primary`)===`secondary`,h=(0,o.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-4`,children:[l&&(0,o.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[a?(0,o.jsx)(`span`,{className:`shrink-0`,children:a}):null,(0,o.jsx)(`p`,{className:(0,c.default)(`min-w-0`,Ur),style:f,children:n})]}),u&&(0,o.jsx)(`p`,{className:(0,c.default)(Wr,i<=1&&`truncate`),style:p,children:i>1?Kr(r??``):r})]});return(0,o.jsx)(`div`,{className:`shrink-0 px-4 py-3`,children:m?(0,o.jsxs)(`div`,{"data-testid":`rich-card-chin-row`,className:`flex items-center justify-between gap-3`,children:[h,(0,o.jsx)(qr,{surface:e,actions:s,layout:`row`})]}):(0,o.jsxs)(o.Fragment,{children:[h,(0,o.jsx)(qr,{surface:e,actions:s,layout:`stacked`})]})})},Yr={dark:`bg-white/[0.06]`,light:`bg-black/[0.04]`},Xr={1:[0],2:[-10,10],3:[-13,0,13]},Zr={1:[0],2:[-26,26],3:[-40,0,40]},Qr={1:[0],2:[0,1],3:[1,3,2]},$r={1:[1],2:[1,1],3:[1,1.08,1]},ei=({variant:e,images:r})=>{let[i,a]=n.default.useState({}),s=r.join(`
2
2
  `),[l,u]=n.default.useState(s);s!==l&&(u(s),a({}));let d=r.slice(0,3).map((e,t)=>({src:e,index:t})).filter(({index:e})=>!i[e]),f=d.length>=3?3:d.length===2?2:1,p=Xr[f],m=Zr[f],h=Qr[f],g=$r[f];return(0,o.jsx)(`div`,{className:(0,c.default)(`relative flex min-h-0 w-full flex-1 items-center justify-center overflow-hidden`,Yr[e]),children:d.map(({src:e,index:n},r)=>(0,o.jsx)(`img`,{src:t.s(e)??e,alt:``,draggable:!1,loading:`lazy`,decoding:`async`,onError:()=>a(e=>({...e,[n]:!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(${m[r]}px) rotate(${p[r]}deg) scale(${g[r]})`,zIndex:h[r]}},`${e}-${n}`))})},ti=`flex h-[180px] w-full shrink-0 flex-col overflow-hidden`,ni=({variant:e,presentation:t,images:n,title:r,heroUrl:i,onHeroError:a})=>(0,o.jsx)(`div`,{className:ti,children:t===`fan`?(0,o.jsx)(ei,{variant:e,images:n}):(0,o.jsx)(X,{variant:e,thumbnailUrl:i,title:r,mimeType:`image/*`,onImageError:a})}),ri=({variant:e,title:t,subtitle:n,subtitleLines:r,images:i=[],imagePresentation:a,actions:c,appIcon:l,accentColor:u,groupPosition:d=`single`})=>{let f=(0,s.resolveRichCardImagePresentation)({imagePresentation:a,images:i}),p=i.length>0,m=p&&f===`hero`,h=ge({variant:e,accentColor:u,layout:`featured`,thumbnailUrl:m?i[0]:void 0}),g=d===`single`||d===`end`;return(0,o.jsx)(be,{accentHex:h.accentHex,side:e===`dark`?`sender`:`receiver`,visible:g,children:(0,o.jsxs)(q,{variant:e,accentHex:h.accentHex,"data-testid":`rich-card`,children:[p&&(0,o.jsx)(ni,{variant:e,presentation:f,images:i,title:t,heroUrl:m?h.thumbnailUrl:void 0,onHeroError:h.onImageError}),(0,o.jsx)(Jr,{ctaSurface:h.surface,chinTextColor:h.chinTextColor,title:t,subtitle:n,subtitleLines:r,appIcon:l,actions:c})]})})},ii={Sent:e=>(0,o.jsx)(ri,{...e,variant:`dark`}),Received:e=>(0,o.jsx)(ri,{...e,variant:`light`})},ai=`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%`,oi={sent:`var(--str-chat__own-message-bubble-background-color, #1e2330)`,received:`var(--str-chat__message-bubble-background-color, #f1f0ee)`},si=({variant:e})=>(0,o.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.3125rem)`:void 0,insetInlineStart:e===`received`?`calc(-1 * 0.3125rem)`:void 0,transform:e===`received`?`scaleX(-1)`:void 0,transformOrigin:`center`,backgroundColor:oi[e],WebkitMask:ai,mask:ai}}),ci={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)`}},li=({variant:e,text:t,tail:n=!0,header:r,className:i})=>(0,o.jsxs)(`div`,{"data-dd-privacy":`mask`,className:(0,c.default)(`relative px-4 py-3`,`text-[0.875rem] leading-[1.3125rem] tracking-[0.14px]`,i),style:{...ci[e],borderRadius:`var(--str-chat__message-bubble-border-radius, 1.5rem)`,isolation:`isolate`},children:[r!=null&&(0,o.jsx)(`div`,{className:`mb-1 font-medium`,"data-testid":`message-bubble-header`,children:r}),(0,o.jsx)(`p`,{className:`m-0 whitespace-pre-wrap break-words hyphens-manual`,children:t}),n&&(0,o.jsx)(si,{variant:e})]}),ui={Sent:({text:e,tail:t,className:n})=>(0,o.jsx)(li,{variant:`sent`,text:e,tail:t,className:n}),Received:({text:e,tail:t,header:n,className:r})=>(0,o.jsx)(li,{variant:`received`,text:e,tail:t,header:n,className:r})},di=({question:e,onClick:t,loading:n=!1,className:r})=>(0,o.jsx)(`button`,{type:`button`,onClick:t,disabled:n,style:{backgroundColor:`#E6E5E3`},className:(0,c.default)(`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},r),children:e}),fi=({faqs:e,onFaqClick:t,loadingFaqId:n,headerText:r,className:i,avatarImage:a,avatarName:c})=>{let l=(0,s.selectEnabledFaqs)(e);return l.length===0?null:(0,o.jsx)(`div`,{className:i,children:(0,o.jsxs)(`div`,{className:`flex gap-3 items-end`,children:[(a||c)&&(0,o.jsx)(`div`,{className:`flex-none`,children:(0,o.jsx)(j,{id:c||`account`,name:c||`Account`,image:a,size:24,shape:`circle`})}),(0,o.jsxs)(`div`,{className:`flex-1 flex flex-col gap-3 rounded-lg p-4`,style:{backgroundColor:`#F1F0EE`},children:[r&&(0,o.jsx)(`p`,{"data-testid":`faq-list-header`,className:`text-md text-charcoal mb-4`,children:r}),l.map(e=>(0,o.jsx)(di,{question:e.question,onClick:()=>t(e.id),loading:n===e.id},e.id))]})]})})};exports.ActionButton=P,exports.Avatar=j,exports.ChannelEmptyState=Dr,exports.ChannelList=Hr,exports.ChannelView=jr,exports.CustomMessageProvider=Te,exports.FaqList=fi,exports.FaqListItem=di,exports.LinkAttachment=xe,exports.LockedAttachment=Ae,exports.MessageAttachment=In,exports.MessageBubble=ui,exports.MessagingLoggerProvider=m,exports.MessagingProvider=v,exports.MessagingShell=Nr,exports.RichCard=ii,exports.TipMessage=Je,exports.buildCompactMetaLabel=pt,exports.formatFileSize=ut,exports.formatRelativeTime=zr,exports.getFileExtensionLabel=ft,exports.getMessageDisplayText=B,exports.isLinkAttachment=Se,exports.isTipMessage=qe,exports.isUuidLike=C,exports.messageAttachmentGroupPositionFromStream=ct,exports.normalizeLanguageCode=z,exports.optimizeMessagingAttachmentUrl=t.s,exports.resolveConversationParticipant=x,exports.resolveParticipantDisplayName=T,exports.useComposerLocked=or,exports.useCustomMessage=Ee,exports.useMessaging=y,exports.useMessagingLogger=h;
3
3
  //# sourceMappingURL=index.cjs.map