@linktr.ee/messaging-react 3.5.6 → 3.5.7-rc-1783064389
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{Card-DYe76Xh3.cjs → Card-BY5GWs2L.cjs} +2 -2
- package/dist/{Card-DYe76Xh3.cjs.map → Card-BY5GWs2L.cjs.map} +1 -1
- package/dist/{Card-B5lE5A2D.js → Card-CpgkVykU.js} +3 -3
- package/dist/{Card-B5lE5A2D.js.map → Card-CpgkVykU.js.map} +1 -1
- package/dist/{Card-D_N5hclc.cjs → Card-CsQmLvWE.cjs} +2 -2
- package/dist/{Card-D_N5hclc.cjs.map → Card-CsQmLvWE.cjs.map} +1 -1
- package/dist/{Card-rblNjC58.js → Card-CuWniEOV.js} +2 -2
- package/dist/{Card-rblNjC58.js.map → Card-CuWniEOV.js.map} +1 -1
- package/dist/{Card-MBp3Wg6r.js → Card-DQdw5-A_.js} +2 -2
- package/dist/{Card-MBp3Wg6r.js.map → Card-DQdw5-A_.js.map} +1 -1
- package/dist/{Card-CAJnEq1K.cjs → Card-DdUewLf6.cjs} +2 -2
- package/dist/{Card-CAJnEq1K.cjs.map → Card-DdUewLf6.cjs.map} +1 -1
- package/dist/{LockedThumbnail-BqyPPVrO.js → LockedThumbnail-D5hLQ6Kz.js} +2 -2
- package/dist/{LockedThumbnail-BqyPPVrO.js.map → LockedThumbnail-D5hLQ6Kz.js.map} +1 -1
- package/dist/{LockedThumbnail-C7PpVZQ0.cjs → LockedThumbnail-s_LZkGm4.cjs} +2 -2
- package/dist/{LockedThumbnail-C7PpVZQ0.cjs.map → LockedThumbnail-s_LZkGm4.cjs.map} +1 -1
- package/dist/{index-BXzwYXLT.js → index-3vM1UOPb.js} +1738 -1557
- package/dist/index-3vM1UOPb.js.map +1 -0
- package/dist/index-BIJpO0jL.cjs +2 -0
- package/dist/index-BIJpO0jL.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/package.json +2 -2
- package/src/components/ChannelHeaderRedesign.tsx +231 -0
- package/src/components/ChannelView.stories.tsx +65 -11
- package/src/components/ChannelView.test.tsx +30 -12
- package/src/components/ChannelView.tsx +50 -22
- package/dist/index-BXzwYXLT.js.map +0 -1
- package/dist/index-BflWZq0e.cjs +0 -2
- package/dist/index-BflWZq0e.cjs.map +0 -1
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";const e=require("react/jsx-runtime"),u=require("react"),xs=require("@linktr.ee/messaging-core"),Re=require("stream-chat"),y=require("stream-chat-react"),v=require("@phosphor-icons/react"),S=require("classnames"),ze=require("stream-chat-react/experimental"),Et=u.createContext({service:null,client:null,isConnected:!1,isLoading:!1,error:null,capabilities:{},refreshConnection:async()=>{},debug:!1}),Oe=()=>u.useContext(Et),fs=({children:t,user:s,serviceConfig:n,apiKey:a,capabilities:r={},debug:i=!1})=>{var A,k;const o=u.useCallback((I,...M)=>{i&&console.log(`🔥 [MessagingProvider] ${I}`,...M)},[i]);o("🔄 RENDER START",{userId:s==null?void 0:s.id,apiKey:(a==null?void 0:a.substring(0,8))+"...",serviceConfig:!!n,capabilities:Object.keys(r)});const[l,d]=u.useState(null),[m,g]=u.useState(null),[h,f]=u.useState(!1),[c,p]=u.useState(!1),[N,b]=u.useState(null),x=u.useRef(!1),_=u.useRef(null),j=u.useRef(n);j.current=n;const E=u.useRef(i);E.current=i;const L=u.useRef({userId:s==null?void 0:s.id,apiKey:a,serviceConfig:n,capabilities:r}),T=u.useRef(0);T.current++,o("📊 RENDER INFO",{renderCount:T.current,currentProps:{userId:s==null?void 0:s.id,apiKey:(a==null?void 0:a.substring(0,8))+"..."},propChanges:{userChanged:L.current.userId!==(s==null?void 0:s.id),apiKeyChanged:L.current.apiKey!==a,serviceConfigChanged:L.current.serviceConfig!==n,capabilitiesChanged:L.current.capabilities!==r}}),L.current={userId:s==null?void 0:s.id,apiKey:a,serviceConfig:n,capabilities:r};const F=u.useRef(null);a&&((A=F.current)==null?void 0:A.apiKey)!==a&&(F.current={apiKey:a,client:new Re.StreamChat(a)});const D=a?((k=F.current)==null?void 0:k.client)??null:null;u.useEffect(()=>{const I=T.current,M=j.current;if(!a||!D||!M){o("⚠️ SERVICE INIT SKIPPED",{renderCount:I,reason:"Missing apiKey, client, or serviceConfig"});return}o("🚀 CREATING SERVICE",{renderCount:I,apiKey:(a==null?void 0:a.substring(0,8))+"..."});const O=new xs.StreamChatService({...M,apiKey:a,debug:E.current,client:D});_.current=O,d(O),o("✅ SERVICE SET",{renderCount:I,serviceInstance:!!O})},[a,D]);const $=u.useRef(null);u.useEffect(()=>{var M,O;if(o("🔗 USER CONNECTION EFFECT TRIGGERED",{hasService:!!l,hasUser:!!s,userId:s==null?void 0:s.id,isConnecting:x.current,isConnected:h,dependencies:{service:!!l,userId:s==null?void 0:s.id}}),!l||!s){o("⚠️ USER CONNECTION SKIPPED","Missing service or user");return}if(x.current){o("⚠️ USER CONNECTION SKIPPED","Already connecting");return}if(((M=$.current)==null?void 0:M.serviceId)===l&&((O=$.current)==null?void 0:O.userId)===s.id){o("⚠️ USER CONNECTION SKIPPED","Already connected this user with this service");return}(async()=>{o("🚀 STARTING USER CONNECTION",{userId:s.id}),x.current=!0,p(!0),b(null);try{o("📞 CALLING SERVICE.CONNECTUSER",{userId:s.id});const z=await l.connectUser(s);g(z),f(!0),$.current={serviceId:l,userId:s.id},o("✅ USER CONNECTION SUCCESS",{userId:s.id,clientId:z.userID})}catch(z){const U=z instanceof Error?z.message:"Connection failed";b(U),o("❌ USER CONNECTION ERROR",{userId:s.id,error:U})}finally{p(!1),x.current=!1,o("🔄 USER CONNECTION FINISHED",{userId:s.id,isConnected:h})}})()},[l,s,o,h]),u.useEffect(()=>{const I=D;return()=>{var M;I&&($.current=null,(M=_.current)==null||M.disconnectUser().catch(console.error))}},[D]);const P=u.useCallback(async()=>{if(o("🔄 REFRESH CONNECTION CALLED",{hasService:!!l,hasUser:!!s}),!l||!s){o("⚠️ REFRESH CONNECTION SKIPPED","Missing service or user");return}o("🚀 STARTING CONNECTION REFRESH",{userId:s.id}),p(!0);try{o("🔌 DISCONNECTING FOR REFRESH"),await l.disconnectUser(),o("📞 RECONNECTING FOR REFRESH");const I=await l.connectUser(s);g(I),f(!0),b(null),o("✅ CONNECTION REFRESH SUCCESS",{userId:s.id})}catch(I){const M=I instanceof Error?I.message:"Refresh failed";b(M),o("❌ CONNECTION REFRESH ERROR",{userId:s.id,error:M})}finally{p(!1),o("🔄 CONNECTION REFRESH FINISHED",{userId:s.id})}},[l,s,o]),C=u.useMemo(()=>(o("💫 CONTEXT VALUE MEMOIZATION",{hasService:!!l,hasClient:!!m,isConnected:h,isLoading:c,hasError:!!N,capabilitiesKeys:Object.keys(r)}),{service:l,client:m,isConnected:h,isLoading:c,error:N,capabilities:r,refreshConnection:P,debug:i}),[l,m,h,c,N,r,P,i,o]);return o("🔄 RENDER END",{renderCount:T.current,willRenderChat:!!D,contextValueReady:!!C}),e.jsx(Et.Provider,{value:C,children:D?e.jsx(y.Chat,{client:D,customClasses:{channelList:"str-chat__channel-list str-chat__channel-list-react bg-transparent lg:border-r-2 border-r-0 border-[#0000000A]"},children:t}):t})},Tt=()=>Oe(),$e=t=>{var a,r;const[s,n]=u.useState(!!((r=(a=t==null?void 0:t.state)==null?void 0:a.membership)!=null&&r.pinned_at));return u.useEffect(()=>{var o;if(!t){n(!1);return}n(!!((o=t.state.membership)!=null&&o.pinned_at));const i=l=>{var d;n(l!=null&&l.member?!!l.member.pinned_at:!!((d=t.state.membership)!=null&&d.pinned_at))};return t.on("member.updated",i),()=>{t.off("member.updated",i)}},[t]),s},gs="linktree-official",ps="linktree-official-sender";function me(t,s,n){const a=Object.values(t||{});if(n===gs){const r=a.find(i=>{var o;return((o=i.user)==null?void 0:o.id)===ps});if(r)return r}return a.find(r=>{var i;return((i=r.user)==null?void 0:i.id)&&r.user.id!==s})}const bs=/^[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 Mt(t){return bs.test(t.trim())}function yt(t,s){const n=t==null?void 0:t.trim();return!n||s&&n===s?!1:!Mt(n)}function _e(t){return yt(t==null?void 0:t.name,t==null?void 0:t.id)?t.name.trim():yt(t==null?void 0:t.username,t==null?void 0:t.id)?t.username.trim():"Unknown member"}const Ct=[{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 vs(t){let s=0;for(let n=0;n<t.length;n++){const a=t.charCodeAt(n);s=(s<<5)-s+a,s=s&s}return Math.abs(s)}function At(t){return Ct[vs(t)%Ct.length]}function js(t){return At(t).emoji}function ws(t){return At(t).bgColor}const Z=({id:t,image:s,size:n=40,className:a,starred:r=!1,shape:i="squircle",dmAgentEnabled:o=!1})=>{const l=js(t),d=ws(t),m=.45,h=n<32?Math.round(n*m):n<56?14:n<120?18:36,f=n>=40?2:1,c=i==="circle"?{borderRadius:"50%"}:{borderRadius:"1rem"},p=e.jsx("div",{className:"h-full w-full overflow-hidden",style:c,children:s?e.jsx("img",{src:s,alt:"",className:"h-full w-full object-cover"}):e.jsx("div",{"aria-hidden":"true",className:S("avatar-fallback flex h-full w-full items-center justify-center font-semibold select-none transition-colors"),style:{fontSize:h,lineHeight:1},children:l})});return e.jsxs("div",{className:S("relative flex-shrink-0",a),style:{"--str-chat__avatar-size":`${n}px`,width:`${n}px`,height:`${n}px`,backgroundColor:s?void 0:d,...c},children:[r&&e.jsx("div",{"aria-hidden":"true",className:"absolute -left-1.5 -top-1.5 z-10 flex size-5 items-center justify-center rounded-full bg-white shadow-[0_0_0_1px_rgba(0,0,0,0.04),0_4px_8px_rgba(0,0,0,0.06)]",children:e.jsx(v.StarIcon,{className:"size-3 text-yellow-600",weight:"duotone"})}),e.jsx("div",{"data-testid":"avatar-ring",className:S("h-full w-full","bg-transparent"),style:{...c,...o&&{borderWidth:`${f}px`,borderStyle:"solid",borderColor:"var(--AI-Gradient, #7F22FE)",boxShadow:"inset 0 1px 2px 0 rgba(255, 255, 255, 0.5)"}},children:p})]})},Ns="https://linktr.ee/s/about/trust-center/report",_s=({channel:t,participant:s,showBlockParticipant:n=!0,enabled:a=!0,onLeaveConversation:r,onBlockParticipant:i,onDeleteConversationClick:o,onBlockParticipantClick:l,onReportParticipantClick:d,onActionComplete:m,logLabel:g="useChannelModerationActions"})=>{var A;const{service:h,debug:f}=Oe(),c=(A=s==null?void 0:s.user)==null?void 0:A.id,p=!!(a&&n&&h&&c),[N,b]=u.useState(!1),[x,_]=u.useState(null),[j,E]=u.useState(!1),[L,T]=u.useState(!1),F=p&&((x==null?void 0:x.participantId)!==c||(x==null?void 0:x.service)!==h);return u.useEffect(()=>{if(!p||!h||!c){b(!1),_(null);return}let k=!1;return(async()=>{try{const I=await h.getBlockedUsers();if(k)return;b(I.some(M=>M.blocked_user_id===c))}catch(I){k||console.error(`[${g}] Failed to check blocked status:`,I)}finally{k||_({participantId:c,service:h})}})(),()=>{k=!0}},[p,h,c,g]),{isParticipantBlocked:N,isCheckingBlockedStatus:F,isLeaving:j,isUpdatingBlockStatus:L,handleLeaveConversation:async()=>{var k;if(!j){o==null||o(),f&&console.log(`[${g}] Leave conversation`,t.cid),E(!0);try{const I=((k=t._client)==null?void 0:k.userID)??null;await t.hide(I,!1),r&&await r(t),m==null||m()}catch(I){console.error(`[${g}] Failed to leave conversation`,I)}finally{E(!1)}}},handleBlockUser:async()=>{var k,I,M;if(!(L||!h)){l==null||l(),f&&console.log(`[${g}] Block member`,(k=s==null?void 0:s.user)==null?void 0:k.id),T(!0);try{await h.blockUser((I=s==null?void 0:s.user)==null?void 0:I.id),i&&await i((M=s==null?void 0:s.user)==null?void 0:M.id),m==null||m()}catch(O){console.error(`[${g}] Failed to block member`,O)}finally{T(!1)}}},handleUnblockUser:async()=>{var k,I,M;if(!(L||!h)){l==null||l(),f&&console.log(`[${g}] Unblock member`,(k=s==null?void 0:s.user)==null?void 0:k.id),T(!0);try{await h.unBlockUser((I=s==null?void 0:s.user)==null?void 0:I.id),i&&await i((M=s==null?void 0:s.user)==null?void 0:M.id),m==null||m()}catch(O){console.error(`[${g}] Failed to unblock member`,O)}finally{T(!1)}}},handleReportUser:()=>{d==null||d(),m==null||m(),window.open(Ns,"_blank","noopener,noreferrer")}}},re=({variant:t="default",className:s,children:n,...a})=>{const r=t==="danger";return e.jsx("button",{type:"button",className:S("flex w-full items-center gap-3 rounded-lg px-4 py-3 text-left text-sm transition-colors focus-ring disabled:cursor-not-allowed disabled:opacity-60",r?"text-danger hover:bg-danger/50":"text-charcoal hover:bg-sand",s),...a,children:n})},Le=({channel:t,participant:s,showDeleteConversation:n=!0,showBlockParticipant:a=!0,showReportParticipant:r=!0,onLeaveConversation:i,onBlockParticipant:o,onDeleteConversationClick:l,onBlockParticipantClick:d,onReportParticipantClick:m,customChannelActions:g,triggerClassName:h})=>{const[f,c]=u.useState(!1),p=u.useRef(null),N=u.useId(),b=u.useCallback(()=>c(!1),[]),{isParticipantBlocked:x,isCheckingBlockedStatus:_,isLeaving:j,isUpdatingBlockStatus:E,handleLeaveConversation:L,handleBlockUser:T,handleUnblockUser:F,handleReportUser:D}=_s({channel:t,participant:s,showBlockParticipant:a,enabled:f,onLeaveConversation:i,onBlockParticipant:o,onDeleteConversationClick:l,onBlockParticipantClick:d,onReportParticipantClick:m,onActionComplete:b,logLabel:"ChannelActionsMenu"});return u.useEffect(()=>{if(!f)return;const P=A=>{p.current&&!p.current.contains(A.target)&&c(!1)},C=A=>{A.key==="Escape"&&c(!1)};return document.addEventListener("mousedown",P),document.addEventListener("keydown",C),()=>{document.removeEventListener("mousedown",P),document.removeEventListener("keydown",C)}},[f]),!s||!(n||a||r||!!g)?null:e.jsxs("div",{ref:p,className:"relative",children:[e.jsxs("button",{className:h,type:"button","aria-haspopup":"true","aria-expanded":f,"aria-controls":f?N:void 0,onClick:()=>c(P=>!P),children:[e.jsx(v.DotsThreeIcon,{className:"size-5 text-black/90"}),e.jsx("span",{className:"sr-only",children:"More options"})]}),f&&e.jsx("div",{id:N,"aria-label":"Conversation options",className:S("absolute right-0 top-full z-50 mt-2 w-56 overflow-hidden","rounded-lg border border-sand bg-white p-1 shadow-max-elevation-light"),children:e.jsxs("ul",{className:"flex flex-col gap-1",children:[n&&e.jsx("li",{children:e.jsxs(re,{onClick:L,disabled:j,"aria-busy":j,children:[j?e.jsx(v.SpinnerGapIcon,{className:"h-5 w-5 animate-spin"}):e.jsx(v.SignOutIcon,{className:"h-5 w-5"}),e.jsx("span",{children:"Delete Conversation"})]})}),a&&e.jsx("li",{children:_?e.jsxs(re,{disabled:!0,"aria-busy":!0,children:[e.jsx(v.SpinnerGapIcon,{className:"h-5 w-5 animate-spin"}),e.jsx("span",{children:"Block"})]}):x?e.jsxs(re,{onClick:F,disabled:E,"aria-busy":E,children:[E?e.jsx(v.SpinnerGapIcon,{className:"h-5 w-5 animate-spin"}):e.jsx(v.ProhibitInsetIcon,{className:"h-5 w-5"}),e.jsx("span",{children:"Unblock"})]}):e.jsxs(re,{onClick:T,disabled:E,"aria-busy":E,children:[E?e.jsx(v.SpinnerGapIcon,{className:"h-5 w-5 animate-spin"}):e.jsx(v.ProhibitInsetIcon,{className:"h-5 w-5"}),e.jsx("span",{children:"Block"})]})}),r&&e.jsx("li",{children:e.jsxs(re,{variant:"danger",onClick:D,children:[e.jsx(v.FlagIcon,{className:"h-5 w-5"}),e.jsx("span",{children:"Report"})]})}),g]})})]})},Ie="pointer-events-auto flex size-10 flex-shrink-0 items-center justify-center rounded-full bg-white/65 shadow-[0px_4px_8px_0px_rgba(0,0,0,0.06),0px_0px_0px_1px_rgba(0,0,0,0.04)] backdrop-blur-[40px] transition-filter duration-150 hover:brightness-95 aria-expanded:brightness-95 focus-ring",ys="CUSTOMER_PAID",Cs=t=>typeof t=="string"&&t.trim().replace(/[\s-]+/g,"_").toUpperCase()===ys,ks=t=>{const s=t;return[s==null?void 0:s.customerTag,s==null?void 0:s.customer_tag].some(Cs)},Ss=({onBack:t,showBackButton:s,showStarButton:n=!1,dmAgentEnabled:a=!1,onLeaveConversation:r,onBlockParticipant:i,showDeleteConversation:o=!0,showBlockParticipant:l=!0,showReportParticipant:d=!0,onDeleteConversationClick:m,onBlockParticipantClick:g,onReportParticipantClick:h,customChannelActions:f,renderChannelActions:c,showChannelInfo:p=!0,onParticipantNameClick:N,renderHeaderTitleBadges:b})=>{var P,C,A;const{channel:x}=y.useChannelStateContext(),{client:_}=y.useChatContext(),j=u.useMemo(()=>{var k;return me((k=x.state)==null?void 0:k.members,_==null?void 0:_.userID,x.type)},[(P=x.state)==null?void 0:P.members,_==null?void 0:_.userID,x.type]),E=_e(j==null?void 0:j.user),L=(C=j==null?void 0:j.user)==null?void 0:C.image,T=$e(x),F=ks(j),D=b==null?void 0:b({channel:x,participant:j}),$=async()=>{try{T?await x.unpin():await x.pin()}catch(k){console.error("[ChannelHeaderRedesign] Failed to update pinned status:",k)}};return e.jsx("div",{className:"@container pointer-events-none sticky top-0 z-10 w-full bg-[linear-gradient(180deg,#FBFAF9_0%,rgba(251,250,249,0.92)_58%,rgba(251,250,249,0)_100%)]",children:e.jsxs("div",{className:"grid min-h-[100px] grid-cols-[40px_minmax(0,1fr)_40px] items-start pb-2 pt-5 @lg:min-h-[104px] @lg:pt-6",children:[e.jsx("div",{className:"flex items-start",children:s&&e.jsx("button",{className:S(Ie,"messaging-channel-view-back-button-mobile messaging-channel-view-back-button-desktop"),onClick:t||(()=>{}),type:"button","aria-label":"Back to conversations",children:e.jsx(v.ArrowLeftIcon,{className:"size-5 text-black/90"})})}),e.jsx("div",{className:"flex min-w-0 justify-center","data-dd-privacy":"mask",children:e.jsxs("button",{type:"button",onClick:N,"aria-label":`View details for ${E}`,className:"group pointer-events-auto 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:[e.jsx(Z,{id:((A=j==null?void 0:j.user)==null?void 0:A.id)||x.id||"unknown",name:E,image:L,dmAgentEnabled:a,shape:"circle",size:48,className:"-mb-2"}),e.jsxs("span",{className:"relative z-10 inline-flex max-w-full items-center justify-center rounded-full border border-white/10 bg-white/65 py-1.5 pl-3 pr-2 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-colors duration-150 group-hover:bg-white/80",children:[e.jsx("span",{className:"min-w-0 truncate text-sm font-bold leading-[1.43] tracking-[0.28px] text-black/90",children:E}),e.jsxs("div",{className:"ml-2 flex gap-1",children:[F&&e.jsx("span",{"aria-label":"Paid customer",className:"flex size-4 shrink-0 items-center justify-center rounded-full bg-[#34C759] text-white",children:e.jsx(v.CurrencyDollarIcon,{className:"size-2.5",weight:"bold"})}),n&&T&&e.jsx("span",{"aria-label":"Starred conversation",className:"flex size-4 shrink-0 items-center justify-center rounded-full bg-[#FFD60A] text-white",children:e.jsx(v.StarIcon,{className:"size-2.5",weight:"fill"})}),D&&e.jsx("span",{className:"shrink-0",children:D}),e.jsx(v.CaretRightIcon,{"aria-hidden":"true",className:"size-4 shrink-0 text-black/65",weight:"bold"})]})]})]})}),e.jsxs("div",{className:"flex items-start justify-end gap-2",children:[n&&e.jsx("button",{className:Ie,onClick:$,type:"button","aria-pressed":T,"aria-label":T?"Unstar conversation":"Star conversation",children:e.jsx(v.StarIcon,{className:S("size-5",{"text-[#FFD60A]":T,"text-black/90":!T}),weight:T?"fill":"regular"})}),p&&(c!==void 0?c:e.jsx(Le,{channel:x,participant:j,showDeleteConversation:o,showBlockParticipant:l,showReportParticipant:d,onLeaveConversation:r,onBlockParticipant:i,onDeleteConversationClick:m,onBlockParticipantClick:g,onReportParticipantClick:h,customChannelActions:f,triggerClassName:Ie}))]})]})})},Is=t=>e.jsx(y.DateSeparator,{...t,position:"center"}),De="vote_up",Fe="vote_down";function Es(t){return t!=null&&t.length?t.some(s=>s.type===Fe)?"down":t.some(s=>s.type===De)?"up":null:null}function Rt(t){const{channel:s}=y.useChannelStateContext(),{client:n}=y.useChatContext("useMessageVote"),a=u.useMemo(()=>Es(t.own_reactions),[t.own_reactions]),r=u.useCallback(async()=>{if(n!=null&&n.userID)try{a==="up"?await s.deleteReaction(t.id,De):await s.sendReaction(t.id,{type:De},{enforce_unique:!0,skip_push:!0})}catch{}},[s,n==null?void 0:n.userID,t.id,a]),i=u.useCallback(async()=>{if(n!=null&&n.userID)try{a==="down"?await s.deleteReaction(t.id,Fe):await s.sendReaction(t.id,{type:Fe},{enforce_unique:!0,skip_push:!0})}catch{}},[s,n==null?void 0:n.userID,t.id,a]);return{selected:a,voteUp:r,voteDown:i}}function Lt(t){return(t==null?void 0:t.trim().toLowerCase().split(/[-_]/)[0])||void 0}function Ue({message:t,viewerLanguage:s}){var r;const n=t==null?void 0:t.text,a=Lt(s);return a?((r=t==null?void 0:t.i18n)==null?void 0:r[`${a}_text`])??n:n}const Ts=u.lazy(()=>Promise.resolve().then(()=>require("./Card-DdUewLf6.cjs"))),Ms=u.lazy(()=>Promise.resolve().then(()=>require("./Card-CsQmLvWE.cjs"))),As=u.lazy(()=>Promise.resolve().then(()=>require("./Card-BY5GWs2L.cjs"))),Be=()=>e.jsx("div",{className:"w-[280px] min-h-[200px] animate-pulse rounded-md bg-black/[0.06] shadow-[0_0_0_1px_rgba(0,0,0,0.04),0_1px_2px_rgba(0,0,0,0.04),0_8px_32px_rgba(0,0,0,0.1)]","aria-hidden":!0}),Rs=t=>e.jsx(u.Suspense,{fallback:e.jsx(Be,{}),children:e.jsx(Ts,{...t})}),Dt=t=>e.jsx(u.Suspense,{fallback:e.jsx(Be,{}),children:e.jsx(Ms,{...t})}),Ft=t=>e.jsx(u.Suspense,{fallback:e.jsx(Be,{}),children:e.jsx(As,{...t})}),Ls=Dt,Ds=Ft,Pe={Composer:Rs,Sent:Dt,Received:Ft,Creator:Ls,Visitor:Ds},Fs=[[/pdf/,"pdf"],[/wordprocessingml|msword|\.doc/,"doc"],[/spreadsheetml|ms-excel|\.xls/,"xls"],[/csv/,"csv"],[/presentationml|ms-powerpoint|\.ppt/,"ppt"],[/zip|x-rar|x-7z|x-tar|x-gzip/,"zip"],[/plain|rtf/,"text"],[/markdown/,"markdown"]];function te(t){return t.startsWith("video/")?"video":t.startsWith("audio/")?"audio":t.startsWith("image/")?"image":"document"}function Pt(t){const s=Fs.find(([n])=>n.test(t));return s?s[1]:"generic"}const Ps={video:v.VideoCameraIcon,audio:v.SpeakerHighIcon,image:v.ImageIcon,document:v.FileIcon},zs={pdf:v.FilePdfIcon,doc:v.FileDocIcon,xls:v.FileXlsIcon,csv:v.FileCsvIcon,ppt:v.FilePptIcon,zip:v.FileZipIcon,text:v.FileTextIcon,markdown:v.FileMdIcon,generic:v.FileIcon};function Os(t){const s=te(t);return s!=="document"?Ps[s]:zs[Pt(t)]}function ne(t,s){return u.createElement(Os(t),s)}const $s=t=>{var s,n;return"touches"in t?((s=t.touches[0])==null?void 0:s.clientX)??((n=t.changedTouches[0])==null?void 0:n.clientX)??0:t.clientX},Us=({source:t,mimeType:s,poster:n,autoPlay:a=!1,playing:r,loop:i=!1,controls:o=!0,showProgress:l=!1,muted:d=!1,onContainerClick:m})=>{const g=te(s),h=u.useRef(null),f=u.useRef(null),c=u.useRef(null),p=u.useRef(r),[N,b]=u.useState(a),[x,_]=u.useState(0),[j,E]=u.useState(!1),[L,T]=u.useState(!1),[F,D]=u.useState(!1),[$,P]=u.useState(!1),[C,A]=u.useState(!0),[k,I]=u.useState(null),M=u.useCallback(()=>{D(!1),b(!0)},[]),O=u.useCallback(w=>{const R=f.current;if(!R)return 0;const G=R.getBoundingClientRect();return Math.max(0,Math.min(1,($s(w)-G.left)/G.width))},[]),z=u.useCallback(w=>{const R=h.current;R&&R.duration&&(R.currentTime=w*R.duration)},[]),U=w=>{w.stopPropagation(),E(!0);const R=O(w);_(R),z(R)};u.useEffect(()=>{r!==void 0&&r!==p.current&&(p.current=r,b(r))},[r]),u.useEffect(()=>{if(!N){c.current!==null&&(cancelAnimationFrame(c.current),c.current=null);return}const w=()=>{const R=h.current;R&&R.duration&&!j&&_(R.currentTime/R.duration),c.current=requestAnimationFrame(w)};return c.current=requestAnimationFrame(w),()=>{c.current!==null&&cancelAnimationFrame(c.current)}},[N,j]),u.useEffect(()=>{const w=h.current;w&&(N?w.play().catch(R=>{b(!1),D(!0)}):w.pause())},[N]),u.useEffect(()=>{if(!j)return;const w=G=>_(O(G)),R=G=>{E(!1),z(O(G))};return window.addEventListener("mousemove",w),window.addEventListener("mouseup",R),window.addEventListener("touchmove",w,{passive:!0}),window.addEventListener("touchend",R),()=>{window.removeEventListener("mousemove",w),window.removeEventListener("mouseup",R),window.removeEventListener("touchmove",w),window.removeEventListener("touchend",R)}},[j,O,z]);const Y=k?{aspectRatio:String(k)}:void 0,W=k?"":" aspect-video",H=Math.round(x*100);return e.jsxs("div",{role:"button",tabIndex:0,className:`relative cursor-pointer overflow-hidden bg-black ${W}`,style:Y,onClick:w=>{if(m){m(w);return}F||o&&b(R=>!R)},onKeyDown:w=>{if(!(w.key!=="Enter"&&w.key!==" ")){if(w.preventDefault(),m){m(w);return}F||o&&b(R=>!R)}},children:[n&&(g==="audio"||C)&&e.jsx("img",{src:n,alt:"",className:"absolute inset-0 h-full w-full object-cover"}),!n&&(g==="audio"||C)&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:ne(s,{className:"size-12 text-black/20",weight:"regular"})}),e.jsx("div",{className:"absolute inset-0",children:g==="audio"?e.jsx("audio",{ref:h,src:t,loop:i,muted:d,style:{width:"100%",height:"100%"},onLoadStart:()=>P(!0),onCanPlay:()=>{P(!1),A(!1)},onWaiting:()=>P(!0),onPlay:()=>D(!1),onEnded:()=>{i||(b(!1),_(0))},children:e.jsx("track",{kind:"captions"})}):e.jsx("video",{ref:h,src:t,loop:i,muted:d,playsInline:!0,style:{width:"100%",height:"100%"},onLoadStart:()=>P(!0),onCanPlay:()=>{P(!1),A(!1)},onWaiting:()=>P(!0),onPlay:()=>D(!1),onLoadedMetadata:()=>{const w=h.current;w instanceof HTMLVideoElement&&w.videoWidth&&w.videoHeight&&I(w.videoWidth/w.videoHeight)},onEnded:()=>{i||(b(!1),_(0))},children:e.jsx("track",{kind:"captions"})})}),$&&!F&&e.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center",children:e.jsx(v.CircleNotchIcon,{className:"size-8 animate-spin text-white/80",weight:"bold"})}),F&&!o&&e.jsx("div",{className:"absolute inset-0 z-30 flex cursor-pointer items-center justify-center bg-black/35",role:"button",tabIndex:0,"aria-label":"Play preview",onClick:w=>{w.stopPropagation(),M()},onKeyDown:w=>{w.key!=="Enter"&&w.key!==" "||(w.preventDefault(),w.stopPropagation(),M())},children:e.jsx("span",{className:"flex size-16 items-center justify-center rounded-full bg-white/20 text-white backdrop-blur-sm",children:e.jsx(v.PlayIcon,{className:"size-9 translate-x-0.5",weight:"fill"})})}),l&&!o&&e.jsx("div",{className:"absolute inset-x-0 bottom-0 px-3 pb-2.5 pt-6 bg-gradient-to-t from-black/40 to-transparent",children:e.jsx("div",{role:"slider","aria-label":"Playback position","aria-valuenow":H,"aria-valuemin":0,"aria-valuemax":100,tabIndex:0,ref:f,className:"relative flex h-4 w-full cursor-pointer items-center",onMouseDown:U,onTouchStart:U,onClick:w=>w.stopPropagation(),onKeyDown:w=>{w.key==="ArrowRight"&&z(Math.min(1,x+.05)),w.key==="ArrowLeft"&&z(Math.max(0,x-.05))},children:e.jsx("div",{className:"w-full overflow-hidden rounded-full bg-white/30 h-1",children:e.jsx("div",{className:"h-full rounded-full bg-white",style:{width:`${H}%`}})})})}),o&&e.jsxs("div",{className:"absolute inset-x-0 bottom-0 flex items-center gap-2 bg-gradient-to-t from-black/60 to-transparent px-3 pb-2.5 pt-6 transition-all duration-200",children:[e.jsx("button",{type:"button",onClick:w=>{w.stopPropagation(),b(R=>!R)},className:"shrink-0 text-white","aria-label":N?"Pause":"Play",children:N?e.jsx(v.PauseIcon,{className:"size-5",weight:"fill"}):e.jsx(v.PlayIcon,{className:"size-5 translate-x-px",weight:"fill"})}),e.jsxs("div",{role:"slider","aria-label":"Playback position","aria-valuenow":H,"aria-valuemin":0,"aria-valuemax":100,tabIndex:0,ref:f,className:"relative flex h-4 w-full cursor-pointer items-center",onMouseDown:U,onTouchStart:U,onClick:w=>w.stopPropagation(),onMouseEnter:()=>T(!0),onMouseLeave:()=>T(!1),onKeyDown:w=>{w.key==="ArrowRight"&&z(Math.min(1,x+.05)),w.key==="ArrowLeft"&&z(Math.max(0,x-.05))},children:[e.jsx("div",{className:`w-full overflow-hidden rounded-full bg-white/30 transition-all duration-200 ${L||j?"h-1.5":"h-1"}`,children:e.jsx("div",{className:"h-full rounded-full bg-white",style:{width:`${H}%`}})}),e.jsx("div",{className:`absolute size-3 -translate-x-1/2 rounded-full bg-white shadow transition-[opacity,transform] duration-200 ${L||j?"scale-100 opacity-100":"scale-0 opacity-0"}`,style:{left:`${H}%`}})]})]})]})},kt=t=>t==="dark"?"size-12 text-white/20":"size-12 text-black/20",Bs=t=>t==="dark"?"aspect-video overflow-hidden bg-white/10":"aspect-video overflow-hidden bg-black/5",Ve=({mimeType:t,sourceUrl:s,thumbnailUrl:n,title:a,variant:r,mediaPlayerProps:i,containedImage:o=!1})=>{const l=te(t),[d,m]=u.useState(!1);return s&&(l==="video"||l==="audio")?e.jsx(Us,{source:s,mimeType:t,poster:n,controls:!0,...i}):s&&l==="image"?o?e.jsx("div",{className:"relative aspect-video overflow-hidden bg-black/5",children:e.jsx("img",{src:s,alt:a??"",className:`absolute inset-0 h-full w-full object-contain transition-opacity duration-300 ${d?"opacity-100":"opacity-0"}`,draggable:!1,onLoad:()=>m(!0)})}):e.jsx("img",{src:s,alt:a??"",className:"block w-full",draggable:!1}):s&&l==="document"?n?o?e.jsx("div",{className:"relative aspect-video overflow-hidden bg-black/5",children:e.jsx("img",{src:n,alt:a??"",className:`absolute inset-0 h-full w-full object-contain transition-opacity duration-300 ${d?"opacity-100":"opacity-0"}`,draggable:!1,onLoad:()=>m(!0)})}):e.jsx("img",{src:n,alt:"",className:"block w-full",draggable:!1}):e.jsx("div",{className:`flex aspect-video w-full items-center justify-center ${r==="dark"?"bg-white/10":"bg-black/5"}`,children:ne(t,{className:kt(r),weight:"regular"})}):n?e.jsx("div",{className:`relative ${Bs(r)}`,children:e.jsx("img",{src:n,alt:a??"",draggable:!1,className:"absolute inset-0 h-full w-full object-cover"})}):e.jsx("div",{className:`flex aspect-video w-full items-center justify-center ${r==="dark"?"bg-white/10":"bg-black/5"}`,children:ne(t,{className:kt(r),weight:"regular"})})},zt=({variant:t,thumbnail:s,title:n,placeholderTitle:a="Attachment title",mimeType:r,detail:i,statusBadge:o,action:l,topLeft:d,topRight:m,rootRef:g,"data-testid":h})=>{const f=t==="dark",c=f?n??a:n??"",p=f&&!n;return e.jsxs("div",{ref:g,"data-testid":h,className:S("relative w-[280px] select-none overflow-hidden rounded-[24px] shadow-[0_0_0_1px_rgba(0,0,0,0.04),0_4px_8px_rgba(0,0,0,0.06)]",f?"bg-[#121110]":"bg-white"),children:[d?e.jsx("div",{className:"pointer-events-auto absolute left-3 top-3 z-50",children:d}):null,m?e.jsx("div",{className:"pointer-events-auto absolute right-3 top-3 z-50",children:m}):null,s,e.jsxs("div",{className:"px-4 pb-3 pt-3",children:[c.trim()!==""&&e.jsx("p",{className:S("mb-0.5 truncate text-base font-medium",{"text-black":!f,"text-white/30":f&&p,"text-white":f&&!p}),children:c}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[ne(r,{className:S("size-5 shrink-0",f?"text-white/55":"text-black/55"),weight:"regular"}),i!=null&&i!==""&&e.jsx("span",{className:S("text-xs font-medium",f?"text-white/55":"text-black/55"),children:i}),o]}),l]})]})};function Ot(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function Ge(t){return`w-[280px] select-none overflow-hidden rounded-[24px] ${t?"bg-[#121110]":"bg-[#F3F3F1]"} shadow-[0_0_0_1px_rgba(0,0,0,0.04),0_4px_8px_rgba(0,0,0,0.06)]`}function Vs(t){return t?"bg-white/10":"bg-black/5"}function Gs(t){return t?"text-white":"text-black"}function Hs(t){return t?"text-white/55":"text-black/55"}function Ys(t){return t?"text-white/40":"text-black/40"}function qs(t){return t?"text-white/20":"text-black/20"}const He=({attachment:t,isMyMessage:s})=>{const{title:n,text:a,image_url:r,og_scrape_url:i,title_link:o}=t,l=i??o,d=typeof l=="string"&&l.trim()!==""?l:void 0,m=e.jsxs(u.Fragment,{children:[e.jsx("div",{className:"p-2",children:r?e.jsx("img",{src:r,alt:n??"",className:"aspect-video w-full rounded-[20px] object-cover"}):e.jsx("div",{className:`aspect-video w-full rounded-[20px] ${Vs(s)} flex items-center justify-center`,children:e.jsx(v.LinkIcon,{className:`size-12 ${qs(s)}`})})}),e.jsxs("div",{className:"px-3 pb-3",children:[n&&e.jsx("p",{className:`truncate text-[14px] font-medium leading-5 ${Gs(s)}`,children:n}),a&&e.jsx("p",{className:`truncate text-[12px] leading-4 ${Hs(s)}`,children:a}),d&&e.jsx("p",{className:`mt-1 truncate text-[12px] leading-4 ${Ys(s)}`,children:d})]})]});return d?e.jsx("a",{href:d,target:"_blank",rel:"noopener noreferrer",className:"block no-underline",children:m}):e.jsx("div",{className:"block",children:m})};function Ye(t){return t.type==="link"||!!t.og_scrape_url&&!t.asset_url}function ye(t){var s;return(s=t.attachments)==null?void 0:s.find(Ye)}async function Xs(t,s){let n;try{n=s??new URL(t).pathname.split("/").pop()??"download"}catch{n=s??"download"}const a=await fetch(t,{mode:"cors"});if(!a.ok)throw new Error(`HTTP ${a.status}`);const r=await a.blob(),i=URL.createObjectURL(r),o=document.createElement("a");o.href=i,o.download=n,o.style.display="none",document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(i)}const Ws=({url:t,filename:s})=>{const[n,a]=u.useState(!1),r=i=>{i.stopPropagation();const o=window.open("","_blank","noopener,noreferrer");a(!0),Xs(t,s).then(()=>{o==null||o.close()}).catch(()=>{o&&(o.location.href=t)}).finally(()=>a(!1))};return e.jsx("button",{type:"button",onClick:r,disabled:n,className:"mt-3 inline-flex h-10 w-full items-center justify-center gap-2 rounded-full bg-[#121110] px-4 text-sm font-medium leading-none text-white hover:bg-[#2a2928] disabled:opacity-70",children:n?e.jsx(v.CircleNotchIcon,{className:"size-4 animate-spin text-white",weight:"bold"}):e.jsxs(u.Fragment,{children:[e.jsx(v.DownloadSimpleIcon,{className:"size-4 text-white",weight:"bold"}),"Download"]})})};function Ce(t){var h,f,c,p;const s=(h=t.attachments)==null?void 0:h.find(N=>N.type==="video"&&N.asset_url),n=(f=t.attachments)==null?void 0:f.find(N=>N.type==="image"&&N.image_url),a=(c=t.attachments)==null?void 0:c.find(N=>N.type==="audio"&&N.asset_url),r=(p=t.attachments)==null?void 0:p.find(N=>N.type==="file"&&N.asset_url),i=s??n??a??r,o=(s==null?void 0:s.asset_url)??(n==null?void 0:n.image_url)??(a==null?void 0:a.asset_url)??(r==null?void 0:r.asset_url);if(!o)return null;const l=(i==null?void 0:i.mime_type)??((i==null?void 0:i.type)==="image"?"image/jpeg":(i==null?void 0:i.type)==="video"?"video/mp4":(i==null?void 0:i.type)==="audio"?"audio/mpeg":"application/octet-stream"),d=i==null?void 0:i.title,m=i==null?void 0:i.file_size,g=s==null?void 0:s.thumb_url;return{resolvedUrl:o,resolvedType:l,title:d,fileSize:m,thumbnailUrl:g}}const $t=({resolvedUrl:t,resolvedType:s,title:n,fileSize:a,thumbnailUrl:r})=>{const i=a!==void 0?Ot(a):void 0;return e.jsx(zt,{variant:"dark",title:n,placeholderTitle:"",mimeType:s,detail:i,thumbnail:e.jsx(Ve,{mimeType:s,sourceUrl:t,thumbnailUrl:r,title:n,variant:"dark"})})},Ut=({resolvedUrl:t,resolvedType:s,title:n,fileSize:a,thumbnailUrl:r})=>{const i=te(s),o=a!==void 0?Ot(a):void 0;return e.jsx(zt,{variant:"light",title:n,mimeType:s,detail:o,thumbnail:e.jsx(Ve,{mimeType:s,sourceUrl:t,thumbnailUrl:r,title:n,variant:"light",containedImage:i==="image"||i==="document"}),action:e.jsx(Ws,{url:t,filename:n})})},Ks=({message:t,isMyMessage:s=!1})=>{const n=ye(t),a=Ce(t);if(!n&&!a)return null;const r=s?"str-chat__message str-chat__message-simple str-chat__message--me str-chat__message-simple--me":"str-chat__message str-chat__message-simple str-chat__message--other";return e.jsxs("div",{className:r,"data-dd-privacy":"mask",children:[!s&&t.user&&e.jsx(Z,{className:"str-chat__avatar str-chat__message-sender-avatar",id:t.user.id,image:t.user.image,name:t.user.name??t.user.id}),e.jsx("div",{className:"str-chat__message-inner",style:{marginInlineEnd:0,marginInlineStart:0},children:e.jsx("div",{className:"str-chat__message-bubble-wrapper",children:e.jsx("div",{className:"str-chat__message-bubble",style:{padding:0,borderRadius:0,overflow:"visible",background:"transparent"},children:n?e.jsx("div",{className:Ge(s),children:e.jsx(He,{attachment:n,isMyMessage:s})}):s?e.jsx($t,{...a}):e.jsx(Ut,{...a})})})})]})},Js=({message:t})=>{const s=ye(t);if(s)return e.jsx("div",{className:Ge(!0),"data-dd-privacy":"mask",children:e.jsx(He,{attachment:s,isMyMessage:!0})});const n=Ce(t);return n?e.jsx("div",{style:{display:"contents"},"data-dd-privacy":"mask",children:e.jsx($t,{...n})}):null},Zs=({message:t})=>{const s=ye(t);if(s)return e.jsx("div",{className:Ge(!1),"data-dd-privacy":"mask",children:e.jsx(He,{attachment:s,isMyMessage:!1})});const n=Ce(t);return n?e.jsx("div",{style:{display:"contents"},"data-dd-privacy":"mask",children:e.jsx(Ut,{...n})}):null},Qs=Object.assign(Ks,{Creator:Js,Visitor:Zs}),en={isUnlocking:()=>!1},tn={LockedAttachment:en},Bt=u.createContext({}),sn=Bt.Provider;function Vt(t){return u.useContext(Bt)[t]??tn[t]}const nn=({size:t=15})=>e.jsx("svg",{width:t,height:t,viewBox:"0 0 15 15",fill:"none","aria-hidden":"true",children:e.jsx("path",{d:"M12.003 9a.985.985 0 0 1-.652.934l-3.223 1.191-1.188 3.226a.995.995 0 0 1-1.867 0l-1.195-3.226L.65 9.937a.995.995 0 0 1 0-1.867l3.227-1.195 1.187-3.226a.995.995 0 0 1 1.868 0l1.195 3.226 3.226 1.187a.99.99 0 0 1 .649.938m3-5.83a.52.52 0 0 1-.344.492l-1.702.63-.627 1.703a.525.525 0 0 1-.986 0l-.63-1.704-1.704-.627a.525.525 0 0 1 0-.986l1.703-.63.627-1.704a.526.526 0 0 1 .986 0l.631 1.703 1.704.627a.52.52 0 0 1 .342.495",fill:"currentColor",fillOpacity:.55})}),an=t=>{var s;return((s=t.metadata)==null?void 0:s.custom_type)==="MESSAGE_TIP"},rn=t=>{var s;return((s=t.metadata)==null?void 0:s.custom_type)==="MESSAGE_PAID"},ve=t=>{var s;return((s=t.metadata)==null?void 0:s.custom_type)==="MESSAGE_CHATBOT"},on=t=>{var s;return((s=t.metadata)==null?void 0:s.custom_type)==="MESSAGE_ATTACHMENT"},Gt=t=>an(t)||rn(t),ln=t=>{var s;return Gt(t)&&!((s=t.text)!=null&&s.trim())},Ee=({message:t,standalone:s=!1,isMyMessage:n=!1,hasAttachment:a=!1})=>{var h;const r=Gt(t),i=ve(t);if(!r&&!i)return null;if(r){const f=(h=t.metadata)==null?void 0:h.amount_text;if(!f)return null;const c=s?"message-tip-standalone":"message-tag message-tag--tip",p=s?`${f} tip`:`Delivered with ${f} tip`;return e.jsxs("div",{className:c,children:[e.jsx(v.GiftIcon,{size:s?14:12}),e.jsx("span",{children:p})]})}const o=n&&a,l=o?"Sent with AI":"Sent by AI Assistant",d=["message-chatbot-indicator",n?"message-chatbot-indicator--sender":"message-chatbot-indicator--receiver",o?"message-chatbot-indicator--attachment":"message-chatbot-indicator--text"].join(" "),m=e.jsx("span",{className:"message-chatbot-indicator__label",children:l}),g=e.jsx("span",{className:"message-chatbot-indicator__icon",children:e.jsx(nn,{size:o?12:15})});return e.jsx("div",{className:d,"data-testid":"message-chatbot-indicator",children:n&&!o?e.jsxs(e.Fragment,{children:[m,g]}):e.jsxs(e.Fragment,{children:[g,m]})})},Ht=({selected:t,onVoteUp:s,onVoteDown:n})=>e.jsxs("div",{className:"message-vote-buttons",children:[e.jsx("button",{type:"button",className:S("message-vote-button focus-ring",{"message-vote-button--selected":t==="up"}),onClick:s,"aria-label":"Good response","aria-pressed":t==="up","data-tooltip":"Good response",children:e.jsx(v.ThumbsUpIcon,{size:16,weight:t==="up"?"fill":"regular"})}),e.jsx("button",{type:"button",className:S("message-vote-button focus-ring",{"message-vote-button--selected":t==="down"}),onClick:n,"aria-label":"Bad response","aria-pressed":t==="down","data-tooltip":"Bad response",children:e.jsx(v.ThumbsDownIcon,{size:16,weight:t==="down"?"fill":"regular"})})]}),cn=t=>{var lt,ct,dt,ut,mt,ht,xt,ft,gt,pt,bt,vt,jt,wt;const{additionalMessageInputProps:s,chatbotVotingEnabled:n,editing:a,endOfGroup:r,firstOfGroup:i,groupedByUser:o,handleAction:l,handleOpenThread:d,handleRetry:m,highlighted:g,isMessageAIGenerated:h,isMyMessage:f,message:c,renderText:p,threadList:N,viewerLanguage:b}=t,{client:x}=y.useChatContext("CustomMessage"),{channel:_}=y.useChannelStateContext("CustomMessage"),{isUnlocking:j,onUnlockClick:E,onFetchSource:L,onDownloadClick:T}=Vt("LockedAttachment"),[F,D]=u.useState(!1),$=y.useMessageReminder(c.id),{selected:P,voteUp:C,voteDown:A}=Rt(c),{Attachment:k=y.Attachment,EditMessageModal:I=y.EditMessageModal,MessageActions:M,MessageBlocked:O=y.MessageBlocked,MessageBouncePrompt:z=y.MessageBouncePrompt,MessageDeleted:U=y.MessageDeleted,MessageIsThreadReplyInChannelButtonIndicator:Y=y.MessageIsThreadReplyInChannelButtonIndicator,MessageRepliesCountButton:W=y.MessageRepliesCountButton,ReminderNotification:H=y.ReminderNotification,StreamedMessageText:w=y.StreamedMessageText,PinIndicator:R}=y.useComponentContext("CustomMessage"),G=y.messageHasAttachments(c),V=y.messageHasReactions(c),K=u.useMemo(()=>h==null?void 0:h(c),[h,c]),B=u.useMemo(()=>{const de=c.attachments??[],pe=c.shared_location?[c.shared_location,...de]:de;if(!ve(c))return pe;const Nt=pe.filter(_t=>!("type"in _t)||!Ye(_t));return Nt.length===pe.length?pe:Nt},[c]),q=u.useMemo(()=>{const de=Ue({message:c,viewerLanguage:b});return de===c.text?c:{...c,text:de}},[c,b]);if(y.isDateSeparatorMessage(c))return null;if(c.deleted_at||c.type==="deleted")return e.jsx(U,{message:c});if(y.isMessageBlocked(c))return e.jsx(O,{});const J=!N&&!!c.reply_count,ie=!N&&c.show_in_channel&&c.parent_id,oe=c.status==="failed"&&((lt=c.error)==null?void 0:lt.status)!==403,le=y.isMessageBounced(c);let X;oe?X=()=>m(c):le&&(X=()=>D(!0));const Q=f(),se=S("str-chat__message str-chat__message-simple",`str-chat__message--${c.type}`,`str-chat__message--${c.status}`,Q?"str-chat__message--me str-chat__message-simple--me":"str-chat__message--other",c.text?"str-chat__message--has-text":"has-no-text",{"str-chat__message--has-attachment":G,"str-chat__message--highlighted":g,"str-chat__message--pinned pinned-message":c.pinned,"str-chat__message--with-reactions":V,"str-chat__message-send-can-be-retried":(c==null?void 0:c.status)==="failed"&&((ct=c==null?void 0:c.error)==null?void 0:ct.status)!==403,"str-chat__message-with-thread-link":J||ie,"str-chat__virtual-message__wrapper--end":r,"str-chat__virtual-message__wrapper--first":i,"str-chat__virtual-message__wrapper--group":o}),at=c.poll_id&&x.polls.fromState(c.poll_id),rt=ln(c),ce=ve(c),it=on(c),Se=!!(B!=null&&B.length&&!c.quoted_message),ot=ce&&Q&&Se;return e.jsxs(e.Fragment,{children:[a&&e.jsx(I,{additionalMessageInputProps:s}),F&&e.jsx(y.MessageBounceModal,{MessageBouncePrompt:z,onClose:()=>D(!1),open:F}),e.jsxs("div",{className:se,"data-message-id":c.id,"data-dd-privacy":"mask",children:[R&&e.jsx(R,{}),!!$&&e.jsx(H,{reminder:$}),c.user&&e.jsx(Z,{className:"str-chat__avatar str-chat__message-sender-avatar",id:c.user.id,image:c.user.image,name:c.user.name||c.user.id,size:24,shape:"circle",dmAgentEnabled:ce}),e.jsx("div",{className:S("str-chat__message-inner",{"str-chat__simple-message--error-failed":oe||le}),"data-testid":"message-inner",onClick:X,onKeyDown:X,role:X?"button":void 0,tabIndex:X?0:void 0,style:{marginInlineEnd:0,marginInlineStart:0},children:it?e.jsxs("div",{className:"str-chat__message-bubble-wrapper",children:[Q?e.jsxs("div",{className:"flex items-center gap-2",children:[M&&e.jsx(M,{}),e.jsx(Pe.Sent,{title:(dt=c.metadata)==null?void 0:dt.attachment_title,mimeType:(ut=c.metadata)==null?void 0:ut.attachment_mime_type,thumbnailUrl:(mt=c.metadata)==null?void 0:mt.attachment_thumbnail,amountText:(ht=c.metadata)==null?void 0:ht.amount_text,detail:(xt=c.metadata)==null?void 0:xt.attachment_detail,paymentStatus:(ft=c.metadata)==null?void 0:ft.payment_status,onPreviewClick:()=>E==null?void 0:E(c,_),onFetchSource:async()=>await(L==null?void 0:L(c,_))})]}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Pe.Received,{title:(gt=c.metadata)==null?void 0:gt.attachment_title,mimeType:(pt=c.metadata)==null?void 0:pt.attachment_mime_type,thumbnailUrl:(bt=c.metadata)==null?void 0:bt.attachment_thumbnail,amountText:(vt=c.metadata)==null?void 0:vt.amount_text,detail:(jt=c.metadata)==null?void 0:jt.attachment_detail,paymentStatus:(wt=c.metadata)==null?void 0:wt.payment_status,isUnlocking:j(c.id),onUnlockClick:()=>E==null?void 0:E(c,_),onFetchSource:async()=>await(L==null?void 0:L(c,_)),onDownloadClick:()=>T==null?void 0:T(c,_)}),M&&e.jsx(M,{})]}),c.text&&e.jsx("div",{className:"str-chat__message-bubble",children:e.jsx(y.MessageText,{message:q,renderText:p})})]}):rt?e.jsx(Ee,{message:c,standalone:!0}):e.jsx("div",{className:"str-chat__message-bubble-wrapper",children:e.jsxs("div",{className:"str-chat__message-bubble",children:[ce&&!ot&&e.jsx(Ee,{message:c,hasAttachment:Se,isMyMessage:Q}),at&&e.jsx(y.Poll,{poll:at}),B!=null&&B.length&&!c.quoted_message?e.jsx(k,{actionHandler:l,attachments:B}):null,K?e.jsx(w,{message:q,renderText:p}):e.jsx(y.MessageText,{message:q,renderText:p}),e.jsx(y.MessageErrorIcon,{})]})})}),!it&&!rt&&e.jsxs("div",{className:"str-chat__message-footer",children:[(!ce||ot)&&e.jsx(Ee,{message:c,hasAttachment:Se,isMyMessage:Q}),n&&ce&&e.jsx(Ht,{selected:P,onVoteUp:C,onVoteDown:A})]}),J&&e.jsx(W,{onClick:d,reply_count:c.reply_count}),ie&&e.jsx(Y,{})]},c.id)]})},dn=u.memo(cn,(t,s)=>t.chatbotVotingEnabled!==s.chatbotVotingEnabled||t.viewerLanguage!==s.viewerLanguage?!1:y.areMessageUIPropsEqual(t,s)),un=t=>{const s=y.useMessageContext("CustomMessage");return e.jsx(dn,{...s,...t})},mn=()=>{var n;const{handleDelete:t,message:s}=y.useMessageContext("CustomMessageActions");return((n=s.metadata)==null?void 0:n.payment_status)==="paid"?null:e.jsx(ze.DefaultDropdownActionButton,{onClick:t,"aria-label":"Delete",title:"Delete",className:"bg-marble rounded-full p-2 hover:bg-sand transition-all",children:e.jsx(v.TrashSimpleIcon,{size:16,weight:"light","aria-hidden":!0})})},hn=()=>{const{handleFlag:t}=y.useMessageContext("CustomMessageActions");return e.jsx(ze.DefaultDropdownActionButton,{onClick:t,"aria-label":"Report",title:"Report",className:"bg-marble rounded-full p-2 hover:bg-sand transition-all",children:e.jsx(v.FlagIcon,{size:16,weight:"light","aria-hidden":!0})})},xn=()=>{var s;const{message:t}=y.useMessageContext("CustomMessageActions");return((s=t.metadata)==null?void 0:s.custom_type)!=="MESSAGE_ATTACHMENT"?null:e.jsx(ze.MessageActions,{messageActionSet:[{Component:mn,placement:"quick",type:"delete"},{Component:hn,placement:"quick",type:"flag"}]})},fn=({link:t,onDismiss:s})=>{const{og_scrape_url:n,title:a,image_url:r}=t,i=o=>{o.preventDefault(),s(n)};return e.jsxs("a",{href:n,target:"_blank",rel:"noopener noreferrer",className:"relative block w-full rounded-[24px] bg-[#121110] p-2 no-underline transition-opacity hover:opacity-90",children:[r&&e.jsx("img",{src:r,alt:a||"",className:"h-[180px] w-full rounded-[20px] object-cover"}),e.jsx("button",{type:"button",onClick:i,className:"absolute right-4 top-4 flex size-6 items-center justify-center rounded-full border border-white/40 bg-white/70 backdrop-blur-2xl focus-ring","aria-label":"Close link preview",children:e.jsx(v.XIcon,{className:"size-4 text-black/90"})}),e.jsxs("div",{className:"p-2",children:[a&&e.jsx("div",{className:"truncate text-[14px] font-medium leading-5 text-white",children:a}),e.jsx("div",{className:"truncate text-[12px] leading-4 text-white/55",children:n})]})]})},gn=t=>({linkPreviews:Array.from(t.previews.values()).filter(s=>Re.LinkPreviewsManager.previewIsLoaded(s)||Re.LinkPreviewsManager.previewIsLoading(s))}),pn=()=>{const{linkPreviewsManager:t}=y.useMessageComposer(),{linkPreviews:s}=y.useStateStore(t.state,gn),n=r=>{t.dismissPreview(r)};return s.length>0?e.jsx("div",{className:"messaging-link-preview-list flex min-h-0 flex-col items-stretch w-full gap-2 mb-4 overflow-y-auto overscroll-contain",children:s.map(r=>e.jsx("div",{className:"w-full shrink-0",children:e.jsx(fn,{link:r,onDismiss:n})},r.og_scrape_url))}):null},qe=u.createContext(!1),bn=()=>u.useContext(qe),vn=({sendMessage:t,disabled:s,...n})=>e.jsx("button",{...n,type:"button","aria-label":"Send",disabled:s,onClick:t,children:e.jsx(v.ArrowUpIcon,{weight:"bold",className:"size-4"})}),jn=()=>{const t=u.useContext(qe),{handleSubmit:s}=y.useMessageInputContext(),n=y.useMessageComposerHasSendableData(),a=t||!n,{SendButton:r=vn,AttachmentPreviewList:i=y.AttachmentPreviewList}=y.useComponentContext("CustomMessageInput");return e.jsxs("div",{className:"central-container flex min-h-0 flex-col gap-2 min-w-0 w-full self-stretch p-2 bg-white rounded-[1.5rem] shadow-[0_4px_16px_0_rgba(0,0,0,0.08),0_1px_2px_0_rgba(0,0,0,0.04),0_0_0_1px_rgba(0,0,0,0.04)]","data-dd-privacy":"mask",children:[e.jsx(y.QuotedMessagePreview,{}),e.jsx(pn,{}),e.jsx(i,{}),e.jsxs("div",{className:"flex shrink-0",children:[e.jsx("div",{className:"w-full ml-2 mr-4 self-center leading-[0]",children:e.jsx(y.TextareaComposer,{"aria-disabled":t||void 0,className:"w-full resize-none outline-none leading-5 placeholder:text-black/30 text-sm",autoFocus:!t,maxRows:4,readOnly:t,tabIndex:t?-1:void 0})}),e.jsx(r,{sendMessage:s,"aria-label":"Send",className:"str-chat__send-button mt-auto flex justify-center items-center flex-shrink-0 rounded-full size-8 bg-[#121110] disabled:bg-[#F1F0EE] disabled:text-black/20 text-white focus-ring","data-testid":"send-button",disabled:a,type:"button"})]})]})},wn=({renderActions:t,renderFooter:s,disabled:n=!1,disabledReason:a,composerInput:r})=>{var l;const{channel:i}=y.useChannelStateContext(),o=((l=i==null?void 0:i.data)==null?void 0:l.frozen)===!0;return n?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"messaging-composer-locked-panel flex w-full flex-col items-center justify-center gap-3 px-6 py-4",children:a?e.jsx("p",{className:"max-w-[345px] text-center text-xs font-normal leading-[1.3] tracking-[0.12px] text-black/40",children:a}):null}),s==null?void 0:s()]}):e.jsxs("div",{className:"flex min-h-0 flex-col gap-4 p-4",children:[e.jsxs("div",{inert:o?"":void 0,"aria-disabled":o||void 0,className:"message-input flex min-h-0 items-end gap-4 aria-disabled:opacity-40",children:[t&&e.jsx("div",{className:"flex h-12 shrink-0 items-center justify-center",children:t()}),e.jsx(qe.Provider,{value:o,children:e.jsx(y.MessageInput,{Input:r??jn})})]}),s==null?void 0:s()]})},Nn=["SYSTEM_DM_AGENT_PAUSED","SYSTEM_DM_AGENT_RESUMED"],_n={SYSTEM_DM_AGENT_PAUSED:"DM Agent has left the conversation",SYSTEM_DM_AGENT_RESUMED:"DM Agent has rejoined the conversation"},yn=["SYSTEM_AGE_SAFETY_BLOCKED"],Cn={SYSTEM_AGE_SAFETY_BLOCKED:"This user isn’t able to reply because they don’t meet our age safety guidelines."},Te="age safety guidelines.",kn="https://linktr.ee/s/about/contact",St=t=>Nn.includes(t),Sn=t=>yn.includes(t),In=t=>{var a;const s=(a=t.metadata)==null?void 0:a.custom_type;if(St(s))return{kind:"dm-agent",type:s};if(Sn(s))return{kind:"age-safety",type:s};const n=t.dm_agent_system_type;if(St(n))return{kind:"dm-agent",type:n}},En=t=>{const s=t.indexOf(Te);if(s===-1)return t;const n=s+Te.length;return e.jsxs(e.Fragment,{children:[t.slice(0,s),e.jsx("a",{href:kn,target:"_blank",rel:"noopener noreferrer",className:"mes-age-safety-system-message__emphasis font-medium text-inherit underline",children:Te}),t.slice(n)]})},Tn=t=>{var a,r;const s=t.message.hide_date===!0,n=In(t.message);if((n==null?void 0:n.kind)==="dm-agent"){const i=((a=t.message.text)==null?void 0:a.trim())||_n[n.type];return e.jsxs("div",{className:"str-chat__message--system","data-testid":"message-system",children:[e.jsxs("div",{className:"mes-dm-agent-system-message mx-auto mb-2 inline-flex w-fit max-w-[min(100%,480px)] items-center justify-center gap-[10px] rounded-[12px] border border-[rgba(0,0,0,0.08)] p-3 text-[rgba(0,0,0,0.55)]","data-testid":"dm-agent-system-message","data-dm-agent-system-type":n.type,children:[e.jsx(v.SparkleIcon,{size:16,weight:"regular","aria-hidden":!0,className:"mes-dm-agent-system-message__sparkle shrink-0"}),e.jsx("p",{className:"mes-dm-agent-system-message__text m-0 text-center text-[14px] font-normal leading-5 tracking-[0.21px]",children:i})]}),!s&&e.jsx(y.MessageTimestamp,{message:t.message})]})}if((n==null?void 0:n.kind)==="age-safety"){const i=((r=t.message.text)==null?void 0:r.trim())||Cn[n.type];return e.jsxs("div",{className:"str-chat__message--system","data-testid":"message-system",children:[e.jsxs("div",{className:"mes-age-safety-system-message box-border mx-auto mb-2 flex w-full max-w-[329px] items-start justify-center gap-3 rounded-[12px] border border-[var(--border-secondary,rgba(0,0,0,0.08))] bg-[var(--bg-warning-subtle,#fef3c6)] px-2 py-4 pl-5 text-[color:var(--text-warning-on-warning,#894b00)]","data-testid":"age-safety-system-message","data-age-safety-system-type":n.type,children:[e.jsx(v.ProhibitIcon,{size:24,weight:"duotone","aria-hidden":!0,className:"mes-age-safety-system-message__icon shrink-0 text-[color:var(--text-warning-on-warning,#894b00)]","data-testid":"age-safety-system-message-icon"}),e.jsx("div",{className:"mes-age-safety-system-message__content min-w-0 flex-[1_0_0]",children:e.jsx("p",{className:"m-0 text-balance text-left text-[12px] font-normal leading-4 tracking-[0.21px] text-[color:var(--text-warning-on-warning,#894b00)]",children:En(i)})})]}),!s&&e.jsx(y.MessageTimestamp,{message:t.message})]})}return e.jsxs("div",{className:"str-chat__message--system","data-testid":"message-system",children:[e.jsxs("div",{className:"str-chat__message--system__text",children:[e.jsx("div",{className:"str-chat__message--system__line"}),e.jsx("p",{children:t.message.text}),e.jsx("div",{className:"str-chat__message--system__line"})]}),!s&&e.jsx(y.MessageTimestamp,{message:t.message})]})},Yt=u.createContext(!1),Me=({cx:t,index:s})=>e.jsx("circle",{cx:t,cy:"6.15",r:"3.9",fill:"#A0A0A0",children:e.jsx("animateTransform",{attributeName:"transform",type:"translate",values:"0 0; 0 -2.25; 0 0;",dur:"900ms",begin:`${120*s}ms`,repeatCount:"indefinite"})}),Mn=new Set([y.AIStates.Thinking,y.AIStates.Generating,y.AIStates.ExternalSources]),An=({threadList:t})=>{var p,N;const{channel:s,channelConfig:n,thread:a}=y.useChannelStateContext(),{client:r}=y.useChatContext(),{typing:i={}}=y.useTypingContext(),{aiState:o}=y.useAIState(s),l=u.useContext(Yt);if(!t&&l&&Mn.has(o)){const b=Rn(s,(p=r.user)==null?void 0:p.id);return e.jsx(It,{avatarId:(b==null?void 0:b.id)??"ai-agent",avatarName:(b==null?void 0:b.name)??(b==null?void 0:b.id)??"Agent",avatarImage:b==null?void 0:b.image,testId:"typing-indicator-ai"})}if((n==null?void 0:n.typing_events)===!1)return null;const m=t?[]:Object.values(i).filter(({parent_id:b,user:x})=>{var _;return(x==null?void 0:x.id)!==((_=r.user)==null?void 0:_.id)&&!b}),g=t?Object.values(i).filter(({parent_id:b,user:x})=>{var _;return(x==null?void 0:x.id)!==((_=r.user)==null?void 0:_.id)&&b===(a==null?void 0:a.id)}):[],h=t?g:m;if(!h.length)return null;const f=(N=h[0])==null?void 0:N.user,c=f!=null&&f.id&&s.state.members[f.id]?s.state.members[f.id].user:void 0;return e.jsx(It,{avatarId:(f==null?void 0:f.id)??(c==null?void 0:c.id)??"typing-user",avatarName:(f==null?void 0:f.name)??(c==null?void 0:c.name)??(f==null?void 0:f.id)??"Typing user",avatarImage:(f==null?void 0:f.image)??(c==null?void 0:c.image),testId:"typing-indicator"})},It=({avatarId:t,avatarName:s,avatarImage:n,testId:a})=>e.jsx("div",{className:"str-chat__li str-chat__li--single str-chat__typing-indicator !static","data-testid":a,style:{marginBottom:"var(--messaging-channel-input-spacer-height, 80px)"},children:e.jsxs("div",{className:"str-chat__message str-chat__message-simple str-chat__message--regular str-chat__message--received str-chat__message--other str-chat__message--has-text",children:[e.jsx(Z,{className:"str-chat__avatar str-chat__message-sender-avatar",id:t,name:s,image:n??void 0,size:24,shape:"circle"}),e.jsx("div",{className:"str-chat__message-inner mx-0",children:e.jsx("div",{className:"str-chat__message-bubble-wrapper",children:e.jsx("div",{className:"str-chat__message-bubble",children:e.jsx("div",{className:"str-chat__message-text min-h-11 flex items-center",children:e.jsx("div",{className:"str-chat__message-text-inner str-chat__message-simple-text-inner",children:e.jsxs("svg",{"aria-hidden":"true",className:"block overflow-visible",viewBox:"0 0 32 12.3",width:"32",height:"13",overflow:"visible",children:[e.jsx(Me,{cx:"4",index:0}),e.jsx(Me,{cx:"16",index:1}),e.jsx(Me,{cx:"28",index:2})]})})})})})})]})});function Rn(t,s){var a;const n=((a=t==null?void 0:t.state)==null?void 0:a.members)??{};for(const r of Object.values(n)){const i=r==null?void 0:r.user;if(i&&i.id!==s)return i}}const qt=()=>null,Ln=({className:t,message:s})=>e.jsxs("div",{className:S("flex items-center justify-center h-full",t),children:[e.jsxs("svg",{viewBox:"0 0 100 100",className:"size-8 fill-pebble",stroke:"none",children:[e.jsx("circle",{cx:"6",cy:"50",r:"6",children:e.jsx("animateTransform",{attributeName:"transform",dur:"1s",type:"translate",values:"0 15 ; 0 -15; 0 15",repeatCount:"indefinite",begin:"0.1"})}),e.jsx("circle",{cx:"30",cy:"50",r:"6",children:e.jsx("animateTransform",{attributeName:"transform",dur:"1s",type:"translate",values:"0 10 ; 0 -10; 0 10",repeatCount:"indefinite",begin:"0.2"})}),e.jsx("circle",{cx:"54",cy:"50",r:"6",children:e.jsx("animateTransform",{attributeName:"transform",dur:"1s",type:"translate",values:"0 5 ; 0 -5; 0 5",repeatCount:"indefinite",begin:"0.3"})})]}),s&&e.jsx("span",{className:"text-stone",children:s})]}),je=u.memo(()=>e.jsx("div",{className:"messaging-loading-state flex items-center justify-center h-full",children:e.jsxs("div",{className:"flex items-center",children:[e.jsx(Ln,{className:"w-6 h-6"}),e.jsx("span",{className:"text-sm text-stone",children:"Loading messages"})]})}));je.displayName="LoadingState";const ae="size-10 rounded-full hover:bg-[#E5E4E1] flex items-center justify-center transition-colors duration-150 focus-ring",be="Replies instantly with AI assistant",Dn=({onBack:t,showBackButton:s,showStarButton:n=!1,dmAgentEnabled:a=!1,onLeaveConversation:r,onBlockParticipant:i,showDeleteConversation:o=!0,showBlockParticipant:l=!0,showReportParticipant:d=!0,onDeleteConversationClick:m,onBlockParticipantClick:g,onReportParticipantClick:h,customChannelActions:f,renderChannelActions:c,showChannelInfo:p=!0,onParticipantNameClick:N,renderHeaderTitleBadges:b})=>{var A,k,I,M,O,z;const{channel:x}=y.useChannelStateContext(),{client:_}=y.useChatContext(),j=u.useMemo(()=>{var U;return me((U=x.state)==null?void 0:U.members,_==null?void 0:_.userID,x.type)},[(A=x.state)==null?void 0:A.members,_==null?void 0:_.userID,x.type]),E=_e(j==null?void 0:j.user),L=(k=j==null?void 0:j.user)==null?void 0:k.image,T=$e(x),F=b==null?void 0:b({channel:x,participant:j}),D="flex max-w-full flex-col items-center gap-1 rounded-[12px] px-1 py-0.5 text-center text-xs font-medium text-black/90",$="flex min-w-0 max-w-full items-center gap-4 rounded-[12px] px-1 py-0.5 text-left text-black/90",P=e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"min-w-0 truncate",children:E}),F&&e.jsx("span",{className:"shrink-0",children:F})]}),C=async()=>{try{T?await x.unpin():await x.pin()}catch(U){console.error("[CustomChannelHeader] Failed to update pinned status:",U)}};return e.jsxs("div",{className:"@container",children:[e.jsxs("div",{className:"grid grid-cols-[1fr_auto_1fr] w-full items-center @lg:hidden px-6 py-3",children:[e.jsx("div",{className:"flex items-center gap-2",children:s&&e.jsx("button",{className:S(ae,"messaging-channel-view-back-button-mobile bg-[#F1F0EE]"),onClick:t||(()=>{}),type:"button","aria-label":"Back to conversations",children:e.jsx(v.ArrowLeftIcon,{className:"size-5 text-black/90"})})}),e.jsx("div",{className:"flex flex-col gap-1 items-center","data-dd-privacy":"mask",children:N?e.jsxs("button",{type:"button",onClick:N,"aria-label":`View details for ${E}`,className:S(D,"appearance-none border-0 bg-transparent transition-opacity hover:opacity-70 focus-ring focus-visible:outline-none"),children:[e.jsx(Z,{id:((I=j==null?void 0:j.user)==null?void 0:I.id)||x.id||"unknown",name:E,image:L,starred:n&&T,dmAgentEnabled:a,size:48}),e.jsxs("span",{className:"flex max-w-full items-center gap-0.5",children:[P,e.jsx(v.CaretRightIcon,{className:"size-3 shrink-0",weight:"bold"})]}),a&&e.jsxs("div",{className:"flex items-center gap-1 text-[10px] leading-3 text-black/55",children:[e.jsx(v.SparkleIcon,{className:"size-3 shrink-0 text-black/55"}),e.jsx("span",{children:be})]})]}):e.jsxs("div",{className:D,children:[e.jsx(Z,{id:((M=j==null?void 0:j.user)==null?void 0:M.id)||x.id||"unknown",name:E,image:L,starred:n&&T,dmAgentEnabled:a,size:48}),e.jsxs("p",{className:"flex max-w-full items-center justify-center gap-0.5",children:[P,e.jsx(v.CaretRightIcon,{className:"invisible size-3 shrink-0",weight:"bold"})]}),a&&e.jsxs("div",{className:"flex items-center gap-1 text-[10px] leading-3 text-black/55",children:[e.jsx(v.SparkleIcon,{className:"size-3 shrink-0 text-black/55"}),e.jsx("span",{children:be})]})]})}),e.jsxs("div",{className:"flex justify-end items-center gap-2",children:[n&&e.jsx("button",{className:ae,onClick:C,type:"button","aria-label":T?"Unstar conversation":"Star conversation",children:e.jsx(v.StarIcon,{className:S("size-5",{"text-yellow-600":T,"text-black/90":!T}),weight:T?"duotone":"regular"})}),p&&(c!==void 0?c:e.jsx(Le,{channel:x,participant:j,showDeleteConversation:o,showBlockParticipant:l,showReportParticipant:d,onLeaveConversation:r,onBlockParticipant:i,onDeleteConversationClick:m,onBlockParticipantClick:g,onReportParticipantClick:h,customChannelActions:f,triggerClassName:S(ae,"bg-[#F1F0EE]")}))]})]}),e.jsxs("div",{className:"px-6 py-3 hidden @lg:flex items-center justify-between gap-3 min-h-12 border-b border-b-black/[0.08]",children:[e.jsxs("div",{className:"flex items-center gap-4 min-w-0","data-dd-privacy":"mask",children:[s&&t&&e.jsx("button",{className:S(ae,"messaging-channel-view-back-button-desktop"),type:"button",onClick:t,"aria-label":"Back to conversations",children:e.jsx(v.ArrowLeftIcon,{className:"size-5 text-black/90"})}),N?e.jsxs("button",{type:"button",onClick:N,"aria-label":`View details for ${E}`,className:S($,"appearance-none border-0 bg-transparent transition-opacity hover:opacity-70 focus-ring focus-visible:outline-none"),children:[e.jsx(Z,{id:((O=j==null?void 0:j.user)==null?void 0:O.id)||x.id||"unknown",name:E,image:L,starred:n&&T,dmAgentEnabled:a,size:48}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("h1",{className:"flex min-w-0 items-center gap-1 font-medium text-black/90",children:[P,e.jsx(v.CaretRightIcon,{className:"size-4 shrink-0",weight:"bold"})]}),a&&e.jsxs("div",{className:"mt-0.5 flex items-center gap-1 text-[10px] leading-3 text-black/55",children:[e.jsx(v.SparkleIcon,{className:"size-3 shrink-0 text-black/55"}),e.jsx("span",{className:"truncate",children:be})]})]})]}):e.jsxs("div",{className:$,children:[e.jsx(Z,{id:((z=j==null?void 0:j.user)==null?void 0:z.id)||x.id||"unknown",name:E,image:L,starred:n&&T,dmAgentEnabled:a,size:48}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("h1",{className:"flex min-w-0 items-center gap-1 font-medium text-black/90",children:[P,e.jsx(v.CaretRightIcon,{className:"invisible size-4 shrink-0",weight:"bold"})]}),a&&e.jsxs("div",{className:"mt-0.5 flex items-center gap-1 text-[10px] leading-3 text-black/55",children:[e.jsx(v.SparkleIcon,{className:"size-3 shrink-0 text-black/55"}),e.jsx("span",{className:"truncate",children:be})]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[n&&e.jsx("button",{className:ae,onClick:C,type:"button","aria-label":T?"Unstar conversation":"Star conversation",children:e.jsx(v.StarIcon,{className:S("size-6",{"text-yellow-600":T,"text-black/90":!T}),weight:T?"duotone":"regular"})}),p&&(c!==void 0?c:e.jsx(Le,{channel:x,participant:j,showDeleteConversation:o,showBlockParticipant:l,showReportParticipant:d,onLeaveConversation:r,onBlockParticipant:i,onDeleteConversationClick:m,onBlockParticipantClick:g,onReportParticipantClick:h,customChannelActions:f,triggerClassName:ae}))]})]})]})},Fn=({onBack:t,showBackButton:s,renderMessageInputActions:n,renderMessageInputFooter:a,renderConversationFooter:r,onLeaveConversation:i,onBlockParticipant:o,showDeleteConversation:l=!0,onDeleteConversationClick:d,onBlockParticipantClick:m,onReportParticipantClick:g,showBlockParticipant:h=!0,showReportParticipant:f=!0,composerDisabled:c=!1,composerDisabledReason:p,showStarButton:N=!1,chatbotVotingEnabled:b=!1,renderChannelBanner:x,renderHeaderTitleBadges:_,customChannelActions:j,renderChannelActions:E,renderMessage:L,dmAgentEnabled:T=!1,viewerLanguage:F,showChannelInfo:D=!0,onParticipantNameClick:$,composerInput:P})=>{var Y,W,H,w;const{channel:C}=y.useChannelStateContext(),{client:A}=y.useChatContext(),k=u.useMemo(()=>{var R;return me((R=C.state)==null?void 0:R.members,A==null?void 0:A.userID,C.type)},[(Y=C.state)==null?void 0:Y.members,A==null?void 0:A.userID,C.type]),I=u.useMemo(()=>{var V;const R=A==null?void 0:A.userID;return R?Object.values(((V=C.state)==null?void 0:V.members)||{}).find(K=>{var B;return((B=K.user)==null?void 0:B.id)===R}):void 0},[A==null?void 0:A.userID,(W=C.state)==null?void 0:W.members]),M=((H=I==null?void 0:I.user)==null?void 0:H.is_account)??(I==null?void 0:I.is_account),O=((w=k==null?void 0:k.user)==null?void 0:w.is_account)??(k==null?void 0:k.is_account),z=T&&M===!1&&O===!0,U=u.useCallback(R=>{const{message:G}=y.useMessageContext("ChannelView"),V=e.jsx(un,{...R,chatbotVotingEnabled:b,viewerLanguage:F});return!L||!G?V:L(V,G)},[b,L,F]);return e.jsx(e.Fragment,{children:e.jsx(y.WithComponents,{overrides:{Message:U,MessageActions:xn},children:e.jsxs(y.Window,{children:[!$&&e.jsx("div",{children:e.jsx(Dn,{onBack:t,showBackButton:s,showChannelInfo:D,showStarButton:N,dmAgentEnabled:z,onLeaveConversation:i,onBlockParticipant:o,showDeleteConversation:l,showBlockParticipant:h,showReportParticipant:f,onDeleteConversationClick:d,onBlockParticipantClick:m,onReportParticipantClick:g,customChannelActions:j,renderChannelActions:E,renderHeaderTitleBadges:_})},"lt-channel-header"),x?e.jsx(u.Fragment,{children:x()},"lt-channel-banner"):null,e.jsx("div",{className:"flex-1 overflow-hidden relative",children:e.jsx(y.MessageList,{head:$?e.jsx(Ss,{onBack:t,showBackButton:s,showChannelInfo:D,showStarButton:N,dmAgentEnabled:z,onLeaveConversation:i,onBlockParticipant:o,showDeleteConversation:l,showBlockParticipant:h,showReportParticipant:f,onDeleteConversationClick:d,onBlockParticipantClick:m,onReportParticipantClick:g,customChannelActions:j,renderChannelActions:E,onParticipantNameClick:$,renderHeaderTitleBadges:_}):void 0,hideDeletedMessages:!0,hideNewMessageSeparator:!1})},"lt-channel-message-list"),r?e.jsx(u.Fragment,{children:r(C)},"lt-channel-conversation-footer"):null,e.jsx(wn,{...n&&{renderActions:()=>n==null?void 0:n(C)},renderFooter:()=>a==null?void 0:a(C),disabled:c,disabledReason:p,composerInput:P},"lt-channel-message-input")]})})})},Xe=u.memo(({channel:t,onBack:s,showBackButton:n=!1,renderMessageInputActions:a,renderMessageInputFooter:r,renderConversationFooter:i,onLeaveConversation:o,onBlockParticipant:l,className:d,CustomChannelEmptyState:m=qt,showDeleteConversation:g=!0,onDeleteConversationClick:h,onBlockParticipantClick:f,onReportParticipantClick:c,showBlockParticipant:p=!0,showReportParticipant:N=!0,composerDisabled:b=!1,composerDisabledReason:x,dmAgentEnabled:_,messageMetadata:j,onMessageSent:E,showStarButton:L=!1,chatbotVotingEnabled:T=!1,renderChannelBanner:F,renderHeaderTitleBadges:D,customChannelActions:$,renderChannelActions:P,renderMessage:C,onMessageLinkClick:A,sendButton:k,attachmentPreviewList:I,viewerLanguage:M,showChannelInfo:O=!0,onParticipantNameClick:z,composerInput:U})=>{const Y=u.useCallback(async(H,w,R)=>{var J;const G=((J=t.data)==null?void 0:J.chatbot_paused)===!0,V=_&&!G,K={...w,...V&&{silent:!0},...j&&{metadata:{...w.metadata??{},...j}}},B={...R,...V&&{skip_push:!0}},q=await t.sendMessage(K,B);return E==null||E(q),q},[t,_,j,E]),W=u.useRef(null);return u.useEffect(()=>{if(!A)return;const H=W.current;if(!H)return;const w=R=>{const G=R.target,V=G==null?void 0:G.closest("a[href]"),K=V==null?void 0:V.getAttribute("href");if(!K)return;const B=V==null?void 0:V.closest("[data-message-id]"),q=B==null?void 0:B.getAttribute("data-message-id"),J=q?t.state.messages.find(ie=>ie.id===q):void 0;A(K,J)};return H.addEventListener("click",w),()=>H.removeEventListener("click",w)},[A,t]),e.jsx("div",{ref:W,className:S("messaging-channel-view h-full flex flex-col",d),children:e.jsx(Yt.Provider,{value:_??!1,children:e.jsx(y.Channel,{channel:t,MessageSystem:Tn,EmptyStateIndicator:m,LoadingIndicator:je,DateSeparator:Is,TypingIndicator:An,doSendMessageRequest:Y,...k?{SendButton:k}:{},...I?{AttachmentPreviewList:I}:{},children:e.jsx(Fn,{onBack:s,showBackButton:n,renderMessageInputActions:a,renderMessageInputFooter:r,renderConversationFooter:i,onLeaveConversation:o,onBlockParticipant:l,CustomChannelEmptyState:m,showDeleteConversation:g,onDeleteConversationClick:h,onBlockParticipantClick:f,onReportParticipantClick:c,showBlockParticipant:p,showReportParticipant:N,composerDisabled:b,composerDisabledReason:x,showStarButton:L,dmAgentEnabled:_,chatbotVotingEnabled:T,renderChannelBanner:F,renderHeaderTitleBadges:D,customChannelActions:$,renderChannelActions:P,renderMessage:C,viewerLanguage:M,showChannelInfo:O,onParticipantNameClick:z,composerInput:U})})})})});Xe.displayName="ChannelView";const ue=u.memo(({message:t,onBack:s})=>e.jsx("div",{className:"messaging-error-state flex items-center justify-center h-full p-8",children:e.jsxs("div",{className:"text-center max-w-sm",children:[e.jsx("div",{className:"w-24 h-24 bg-danger-alt/20 rounded-full flex items-center justify-center mx-auto mb-6",children:e.jsx("span",{className:"text-4xl",children:"⚠️"})}),e.jsx("h2",{className:"font-semibold text-charcoal mb-2",children:"Oops!"}),e.jsx("p",{className:"text-stone text-sm mb-6",children:t}),s&&e.jsx("button",{type:"button",onClick:s,className:"inline-flex items-center gap-2 px-4 py-2 text-sm font-medium text-white bg-[#7f22fe] hover:bg-primary-alt rounded-lg transition-colors focus-ring",children:"Go Back"})]})}));ue.displayName="ErrorState";const Pn=({capabilities:t={},renderMessageInputActions:s,renderConversationFooter:n,onChannelSelect:a,onExitConversation:r,initialParticipantFilter:i,initialParticipantData:o,CustomChannelEmptyState:l,onBlockParticipantClick:d,onReportParticipantClick:m,dmAgentEnabled:g,onMessageSent:h,chatbotVotingEnabled:f=!1,viewerLanguage:c,renderHeaderTitleBadges:p,renderChannelBanner:N,customChannelActions:b,renderChannelActions:x,onParticipantNameClick:_,renderMessage:j,onMessageLinkClick:E,showChannelInfo:L,composerInput:T})=>{const{client:F,isConnected:D,isLoading:$,error:P,refreshConnection:C,service:A,debug:k}=Tt(),[I,M]=u.useState(null),[O,z]=u.useState(null),[U,Y]=u.useState(!1),{showDeleteConversation:W=!0}=t,H=u.useRef(o);H.current=o;const w=u.useRef(a);w.current=a;const R=u.useRef(null),G=u.useRef(null);u.useEffect(()=>{G.current=I},[I]),u.useEffect(()=>{if(!F||!D)return;const B=F.userID;if(!B)return;const q=`${B}::${i}`;if(R.current===q)return;R.current=q;const J=()=>{R.current===q&&(R.current=null)};(async()=>{var oe,le;try{k&&console.log("[MessagingShell] Loading initial conversation with:",i);const X=await F.queryChannels({type:"messaging",members:{$eq:[B,i]}},{},{limit:1});if(X.length>0){M(X[0]),z(null),(oe=w.current)==null||oe.call(w,X[0]),k&&console.log("[MessagingShell] Initial conversation loaded:",X[0].id);return}const Q=H.current;if(!Q||!A){J(),z("No conversation found with this account"),k&&console.log("[MessagingShell] No conversation found for:",i);return}try{const se=await A.startChannelWithParticipant({id:Q.id,name:Q.name,phone:Q.phone});M(se),z(null),(le=w.current)==null||le.call(w,se),k&&console.log("[MessagingShell] Channel created and loaded:",se.id)}catch(se){console.error("[MessagingShell] Failed to create conversation:",se),J(),z("Failed to create conversation")}}catch(X){console.error("[MessagingShell] Failed to load initial conversation:",X),J(),G.current||z("Failed to load conversation")}})()},[i,F,D,A,k]);const V=u.useRef(r);V.current=r;const K=u.useCallback(()=>{var B;M(null),Y(!0),(B=V.current)==null||B.call(V)},[]);return $?e.jsx(je,{}):P?e.jsx(ue,{message:P,onBack:C}):!D||!F?e.jsx(ue,{message:"Not connected to messaging service",onBack:C}):O?e.jsx(ue,{message:O}):U&&!I?e.jsx(ue,{message:"Conversation ended"}):I?e.jsx("div",{className:"messaging-shell h-full bg-background-primary overflow-hidden",children:e.jsx("div",{className:"flex h-full min-h-0 flex-col",children:e.jsx(Xe,{channel:I,renderMessageInputActions:s,renderConversationFooter:n,renderChannelBanner:N,onLeaveConversation:K,onBlockParticipant:K,CustomChannelEmptyState:l,showDeleteConversation:W,onBlockParticipantClick:d,onReportParticipantClick:m,dmAgentEnabled:g,onMessageSent:h,chatbotVotingEnabled:f,viewerLanguage:c,renderHeaderTitleBadges:p,customChannelActions:b,renderChannelActions:x,onParticipantNameClick:_,renderMessage:j,onMessageLinkClick:E,showChannelInfo:L,composerInput:T},I.id)})}):e.jsx(je,{})};function zn(t){const s=t.state.pending_messages;if(s!=null&&s.length)for(const n of s)t.state.addMessageSorted(n.message)}const Xt=u.createContext({selectedChannel:void 0,onChannelSelect:()=>{},debug:!1,renderMessagePreview:void 0,channelPreview:void 0,viewerLanguage:void 0}),On=Xt.Provider,$n=()=>u.useContext(Xt),Un=(t,s)=>{const n=new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate())),r=new Date(Date.UTC(s.getUTCFullYear(),s.getUTCMonth(),s.getUTCDate())).getTime()-n.getTime();return Math.floor(r/(1e3*60*60*24))},Wt=t=>{const s=new Date;if(Math.floor((s.getTime()-t.getTime())/1e3)<60)return"Just now";const a=Un(t,s);return a===0?t.toLocaleTimeString([],{hour:"numeric",minute:"2-digit",hour12:!0}):a===1?"Yesterday":a<7?`${a}d`:a<28?`${Math.floor(a/7)}w`:t.toLocaleDateString("en-US",{month:"numeric",day:"numeric",year:"2-digit"})},Kt=u.memo(t=>{var D,$,P;const{channel:s,unread:n}=t,{selectedChannel:a,onChannelSelect:r,debug:i,channelPreview:o,renderMessagePreview:l,viewerLanguage:d}=$n(),{client:m}=y.useChatContext(),g=(a==null?void 0:a.id)===(s==null?void 0:s.id),h=$e(s);if(o){const C=o;return e.jsx(C,{...t,active:g,selectedChannel:a,onChannelSelect:r,viewerLanguage:d})}const f=()=>{s&&r(s)},c=C=>{const A=C.key==="Enter"||C.key===" ",k=C.repeat;!A||k||(C.preventDefault(),f())},p=me((D=s==null?void 0:s.state)==null?void 0:D.members,m==null?void 0:m.userID,s==null?void 0:s.type),N=_e(p==null?void 0:p.user),b=($=p==null?void 0:p.user)==null?void 0:$.image,x=(()=>{var A;const C=(A=s==null?void 0:s.state)==null?void 0:A.messages;if(C!=null&&C.length){for(let k=C.length-1;k>=0;k--)if(C[k].type!=="system")return C[k]}})(),j=(()=>{var O,z,U,Y;const C=Ue({message:x,viewerLanguage:d});if(((O=x==null?void 0:x.metadata)==null?void 0:O.custom_type)==="MESSAGE_TIP")return C?`💵 ${C}`:"💵 Sent a tip";if(((z=x==null?void 0:x.metadata)==null?void 0:z.custom_type)==="MESSAGE_PAID")return C?`💰 ${C}`:"💰 Sent a message";if(((U=x==null?void 0:x.metadata)==null?void 0:U.custom_type)==="MESSAGE_ATTACHMENT")return C?`📎 ${C}`:"📎 Sent an attachment";if(C)return C;const M=(Y=x==null?void 0:x.attachments)==null?void 0:Y[0];return M?M.og_scrape_url?M.og_scrape_url:M.type==="image"?"📷 Sent an image":M.type==="video"?"🎥 Sent a video":M.type==="audio"?"🎵 Sent audio":M.type==="file"?"📎 Sent a file":"📎 Sent an attachment":"No messages yet"})(),E=x!=null&&x.created_at?Wt(new Date(x.created_at)):"",L=x?ve(x):!1,T=l?l(x,j):`${L?"✨ ":""}${j}`,F=n??0;return i&&console.log("📺 [ChannelList] 📋 CHANNEL PREVIEW RENDER",{channelId:s==null?void 0:s.id,isSelected:g,participantName:N,unreadCount:F,hasTimestamp:!!E}),e.jsx("div",{role:"button",tabIndex:0,onClick:f,onKeyDown:c,className:S("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]":g,"hover:bg-black/[0.02]":!g}),"data-dd-privacy":"mask",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx(Z,{id:((P=p==null?void 0:p.user)==null?void 0:P.id)||s.id||"unknown",name:N,image:b,size:48,starred:h}),e.jsxs("div",{className:"flex-1 min-w-0 flex flex-col gap-1",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("h3",{className:S("text-sm font-medium truncate text-[#191918]"),children:[h&&e.jsx("span",{className:"sr-only",children:"Starred conversation. "}),N]}),E&&e.jsx("span",{className:"text-xs text-[#717070] flex-shrink-0",children:E})]}),e.jsxs("div",{className:"flex items-center justify-between gap-2 min-w-0",children:[e.jsx("p",{className:"text-sm text-[#717070] flex-1 line-clamp-1",children:T}),F>0&&e.jsx("span",{className:"bg-[#7f22fe] text-white text-[10px] rounded-full h-4 flex items-center justify-center p-1 min-w-4 text-center flex-shrink-0",children:F>99?"99+":F})]})]})]})})});Kt.displayName="CustomChannelPreview";const Bn={last_message_at:-1},Jt=u.memo(({onChannelSelect:t,selectedChannel:s,filters:n,allowNewMessagesFromUnfilteredChannels:a=!1,channelRenderFilterFn:r,sort:i=Bn,className:o,customEmptyStateIndicator:l,channelListPaginator:d=y.InfiniteScroll,channelPreview:m,renderMessagePreview:g,viewerLanguage:h})=>{const f=u.useRef(0);f.current++;const{debug:c=!1}=Oe(),p=u.useCallback(b=>{for(const x of b)zn(x);return r?r(b):b},[r]);c&&console.log("📺 [ChannelList] 🔄 RENDER START",{renderCount:f.current,selectedChannelId:s==null?void 0:s.id,filters:n});const N=u.useMemo(()=>({selectedChannel:s,onChannelSelect:t,debug:c,channelPreview:m,renderMessagePreview:g,viewerLanguage:h}),[s,t,c,m,g,h]);return e.jsx("div",{className:S("messaging-channel-list h-full flex flex-col min-w-0 overflow-hidden",o),children:e.jsx("div",{className:"flex-1 overflow-hidden min-w-0",children:e.jsx(On,{value:N,children:e.jsx(y.ChannelList,{filters:n,sort:i,options:{limit:30},allowNewMessagesFromUnfilteredChannels:a,channelRenderFilterFn:p,Paginator:d,Preview:Kt,EmptyStateIndicator:l},`${JSON.stringify(n)}:${JSON.stringify(i)}`)})})})});Jt.displayName="ChannelList";const Vn=/^([a-z][a-z0-9+.-]*):/i,Gn=new Set(["http","https","mailto","tel","sms"]);function We(t){if(typeof t!="string")return;const s=t.trim();if(s==="")return;const n=Vn.exec(s);if(n){const a=n[1].toLowerCase();return Gn.has(a)?s:void 0}return s.startsWith("//")||s.startsWith("/")?s:`https://${s}`}const Hn={dark:"bg-white text-[#121110] hover:bg-white/90",light:"bg-[#121110] text-white hover:bg-[#2a2928]"},Yn=({variant:t,cta:s})=>{const n=S("mt-2 inline-flex h-10 w-full items-center justify-center rounded-full px-4 text-sm font-medium leading-none transition-colors",Hn[t]),a=We(s.href);return a?e.jsx("a",{href:a,target:"_blank",rel:"noopener noreferrer",onClick:r=>{var i;r.stopPropagation(),(i=s.onClick)==null||i.call(s)},className:`${n} no-underline`,children:s.label}):e.jsx("button",{type:"button",onClick:r=>{var i;r.stopPropagation(),(i=s.onClick)==null||i.call(s)},className:n,children:s.label})},qn={dark:"text-white",light:"text-black/90"},Xn="text-white/30",Wn={dark:"text-white/55",light:"text-black/55"},Ke=({variant:t,title:s,placeholderTitle:n,description:a,url:r,appIcon:i,cta:o,trailingAction:l})=>{const d=t==="dark",m=s??(d?n:void 0)??"",g=m.trim()!=="",h=a!=null&&a.trim()!=="",f=typeof r=="string"?r.trim():"",c=f!=="",p=o!=null;if(!g&&!h&&!c&&!p)return null;const b=S("truncate text-base font-medium leading-6",d&&!s?Xn:qn[t]),x=S("truncate text-xs leading-4",Wn[t]);return e.jsxs("div",{className:"px-4 py-3",children:[e.jsxs("div",{className:"flex items-end gap-3",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-2",children:[e.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[g&&e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[i?e.jsx("span",{className:"shrink-0",children:i}):null,e.jsx("p",{className:S("min-w-0",b),children:m})]}),h&&e.jsx("p",{className:x,children:a})]}),!p&&c&&e.jsx("p",{className:x,children:f})]}),l&&e.jsx("div",{className:"shrink-0",children:l})]}),o&&e.jsx(Yn,{variant:t,cta:o})]})},Kn=S("relative block w-[280px] select-none overflow-hidden rounded-md","border border-black/[0.08]","shadow-[0_1px_2px_rgba(0,0,0,0.04),0_8px_32px_rgba(0,0,0,0.1)]"),we=({variant:t,children:s,href:n,onClick:a,ariaLabel:r,rootRef:i,topRight:o,bgClassName:l,"data-testid":d})=>{const m=n!=null||a!=null,g=S(Kn,l??(t==="dark"?"bg-[#121110]":"bg-white"),m?"cursor-pointer no-underline focus-ring":null),h=o?e.jsx("div",{className:"pointer-events-auto absolute right-3 top-3 z-10",children:o}):null;return n?e.jsxs("a",{ref:i,href:n,target:"_blank",rel:"noopener noreferrer",onClick:a,"data-testid":d,className:g,children:[s,h]}):a?e.jsxs("button",{ref:i,type:"button",onClick:a,"aria-label":r,"data-testid":d,className:S(g,"text-left"),children:[s,h]}):e.jsxs("div",{ref:i,"data-testid":d,className:g,children:[s,h]})},Jn={dark:"bg-white/10",light:"bg-black/5"},Zn={dark:"size-16 text-white/25",light:"size-16 text-black/25"},ke=(t,s)=>!!s&&!!t&&te(t)==="audio",Zt=(t,s)=>{if(!s||!t)return!1;const n=te(t);return n==="video"||n==="audio"},Je="bg-[#F2F3F4]",Ne=({variant:t,thumbnailUrl:s,sourceUrl:n,title:a,mimeType:r="image/*",topLeft:i,topRight:o})=>{const l=te(r),d=!!n&&l==="video";return ke(r,n)?e.jsx("div",{className:"p-3",children:e.jsx("audio",{src:n,controls:!0,preload:"metadata",className:"block w-full",children:e.jsx("track",{kind:"captions"})})}):e.jsxs("div",{className:S("relative h-[180px] w-full overflow-hidden",d&&"bg-black"),children:[d?e.jsx("video",{src:n,poster:s,controls:!0,playsInline:!0,preload:"metadata",className:"absolute inset-0 h-full w-full object-contain",children:e.jsx("track",{kind:"captions"})}):s?e.jsx("img",{src:s,alt:a??"",draggable:!1,className:"absolute inset-0 h-full w-full object-cover"}):e.jsx("div",{className:S("flex h-full w-full items-center justify-center",Jn[t]),children:ne(r,{className:Zn[t],weight:"regular"})}),i?e.jsx("div",{className:"pointer-events-auto absolute left-3 top-3 z-10",children:i}):null,o?e.jsx("div",{className:"pointer-events-auto absolute right-3 top-3 z-10",children:o}):null]})},Qn=({title:t,placeholderTitle:s,description:n,url:a,mimeType:r,thumbnailUrl:i,sourceUrl:o,layout:l="featured",appIcon:d,cta:m,onDismiss:g,onEditClick:h})=>{const f=l==="classic",c=ke(r,o),p=g?e.jsx("button",{type:"button",onClick:g,"aria-label":"Dismiss attachment",className:"flex size-6 items-center justify-center rounded-full bg-[#121110] text-white",children:e.jsx(v.XIcon,{className:"size-3",weight:"bold"})}):void 0,N=h?e.jsx("button",{type:"button",onClick:h,"aria-label":"Edit attachment",className:"flex size-10 items-center justify-center rounded-full bg-white/10 text-white hover:bg-white/15",children:e.jsx(v.PencilSimpleIcon,{className:"size-5",weight:"regular"})}):void 0;return c?e.jsx(we,{variant:"dark",bgClassName:Je,children:e.jsxs("div",{className:"flex items-center gap-2 pr-3",children:[e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx(Ne,{variant:"dark",sourceUrl:o,title:t,mimeType:r})}),p&&e.jsx("div",{className:"shrink-0",children:p})]})}):e.jsxs(we,{variant:"dark",topRight:f?p:void 0,children:[!f&&e.jsx(Ne,{variant:"dark",thumbnailUrl:i,sourceUrl:o,title:t,mimeType:r,topRight:p}),e.jsx(Ke,{variant:"dark",title:t,placeholderTitle:s,description:n,url:a,appIcon:d,cta:m,trailingAction:N})]})},ea=({title:t,description:s,url:n,mimeType:a,thumbnailUrl:r,sourceUrl:i,layout:o="featured",appIcon:l,cta:d,onClick:m})=>{const g=Zt(a,i),h=We(n),f=d==null&&h!=null&&!g?h:void 0,c=d==null&&!g?m:void 0,p=ke(a,i)?Je:void 0,N=d&&m?{...d,onClick:()=>{var b;m(),(b=d.onClick)==null||b.call(d)}}:d;return e.jsxs(we,{variant:"light",href:f,onClick:c,ariaLabel:t??"Open attachment preview",bgClassName:p,"data-testid":"link-attachment",children:[o==="featured"&&e.jsx(Ne,{variant:"light",thumbnailUrl:r,sourceUrl:i,title:t,mimeType:a}),e.jsx(Ke,{variant:"light",title:t,description:s,url:n,appIcon:l,cta:N})]})},ta=({title:t,placeholderTitle:s,description:n,url:a,mimeType:r,thumbnailUrl:i,sourceUrl:o,layout:l="featured",appIcon:d,cta:m,onClick:g})=>{const h=Zt(r,o),f=We(a),c=m==null&&f!=null&&!h?f:void 0,p=m==null&&!h&&c!=null?g:void 0;return e.jsxs(we,{variant:"dark",href:c,onClick:p,bgClassName:ke(r,o)?Je:void 0,children:[l==="featured"&&e.jsx(Ne,{variant:"dark",thumbnailUrl:i,sourceUrl:o,title:t,mimeType:r}),e.jsx(Ke,{variant:"dark",title:t,placeholderTitle:s,description:n,url:a,appIcon:d,cta:m})]})},sa={Composer:Qn,Sent:ta,Received:ea},na={dark:"bg-[#121110]",light:"bg-[#e9eaed]"},aa={dark:"text-white",light:"text-[#080707]"},ra={dark:"border-white/[0.08]",light:"border-black/[0.08]"},ia=t=>t==="dark"?"sender":"receiver",oa={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]"}},he=({variant:t,text:s,bordered:n=!0,groupPosition:a="single",className:r,children:i,"data-testid":o})=>{const l=s!=null&&s!=="",d=oa[ia(t)][a];return e.jsxs("div",{"data-testid":o,"data-group-position":a,className:S("relative w-[280px] overflow-hidden px-2 py-2",d,na[t],aa[t],n&&"border",n&&ra[t],r),children:[i,l?e.jsx("p",{className:S("whitespace-pre-wrap break-words leading-snug","pt-2","px-2"),children:s}):null]})},xe=({onClick:t,variant:s="overlay",ariaLabel:n="Dismiss attachment"})=>e.jsx("button",{type:"button",onClick:a=>{a.stopPropagation(),t()},"aria-label":n,className:S("flex size-6 items-center justify-center rounded-full text-white",s==="overlay"?"bg-[#121110]/85 backdrop-blur":"bg-white/15 hover:bg-white/25"),children:e.jsx(v.XIcon,{className:"size-3",weight:"bold"})}),fe=t=>t==="received"?"light":"dark",la=({firstOfGroup:t,endOfGroup:s,groupedByUser:n})=>!n||t&&s?"single":t?"first":s?"end":"middle",ca=({src:t,mimeType:s,filename:n,items:a})=>a&&a.length>0?a:t?[{src:t,mimeType:s,filename:n}]:[],da=({item:t,preload:s,trailingAction:n})=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("audio",{src:t.src,controls:!0,preload:t.preload??s,className:"block min-w-0 flex-1",children:t.mimeType?e.jsx("source",{src:t.src,type:t.mimeType}):null}),n??null]}),Ze=({state:t,src:s,mimeType:n,filename:a,items:r,text:i,groupPosition:o,preload:l,onDismiss:d})=>{const m=fe(t),g=t==="composer"&&!!d,h=ca({src:s,mimeType:n,filename:a,items:r});if(h.length===0)return null;const f=l??(h.length>1?"none":"metadata");return e.jsx(he,{variant:m,text:i,groupPosition:o,"data-testid":"audio-attachment",children:e.jsx("div",{className:"flex flex-col gap-2",children:h.map((c,p)=>e.jsx(da,{item:c,preload:f,trailingAction:g&&p===0?e.jsx(xe,{onClick:d,variant:"inline"}):void 0},`${c.src}-${p}`))})})},ua=t=>e.jsx(Ze,{...t,state:"composer"}),ma=t=>e.jsx(Ze,{...t,state:"sent"}),ha=t=>e.jsx(Ze,{...t,state:"received"}),xa={Composer:ua,Sent:ma,Received:ha};function Qt(t){return!Number.isFinite(t)||t<0?"":t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:t<1024*1024*1024?`${(t/(1024*1024)).toFixed(2)} MB`:`${(t/(1024*1024*1024)).toFixed(2)} GB`}const fa={pdf:"PDF",doc:"DOC",xls:"XLS",csv:"CSV",ppt:"PPT",zip:"ZIP",text:"TXT",markdown:"MD"};function es(t,s){if(s){const r=s.lastIndexOf(".");if(r>0&&r<s.length-1){const i=s.slice(r+1);if(i&&i.length<=5)return i.toUpperCase()}}if(!t)return;if(te(t)==="document"){const r=Pt(t),i=fa[r];if(i)return i;if(t==="application/octet-stream")return}const a=t.split("/")[1];if(!(!a||a==="*"))return a.toUpperCase()}function ts(t,s,n){const a=es(t,s),r=typeof n=="number"&&n>0?Qt(n):void 0;return[a,r].filter(Boolean).join(" · ")||void 0}function ee(t){try{const n=new URL(t).pathname.split("/").pop();return n&&n.length>0?decodeURIComponent(n):"download"}catch{return"download"}}const ga={dark:"text-white/55",light:"text-black/65"},pa={dark:"bg-white/10",light:"bg-black/5"},ba={dark:"text-white/85",light:"text-black/85"},ss=({variant:t,filename:s,title:n,mimeType:a="application/octet-stream",fileSize:r,onActivate:i,activateLabel:o,trailingAction:l})=>{const d=n??s??"File",m=ts(a,s,r),g=e.jsx("div",{className:S("flex size-10 shrink-0 items-center justify-center rounded-sm",pa[t]),"aria-hidden":!0,children:ne(a,{className:S("size-6",ba[t]),weight:"regular"})}),h=e.jsxs("div",{className:"flex min-w-0 flex-1 flex-col text-left",children:[e.jsx("p",{className:"truncate font-medium leading-snug",children:d}),m?e.jsx("p",{className:S("truncate text-xs leading-4",ga[t]),children:m}):null]}),f=i?e.jsxs("button",{type:"button",onClick:i,"aria-label":o,className:S("flex min-w-0 flex-1 items-center gap-3 rounded-sm text-left transition-colors",t==="dark"?"hover:bg-white/[0.04]":"hover:bg-black/[0.04]"),children:[g,h]}):e.jsxs(e.Fragment,{children:[g,h]});return e.jsxs("div",{className:"flex items-center gap-3 px-3 py-2",children:[f,l?e.jsx("div",{className:"shrink-0",children:l}):null]})};async function ns(t,s){const n=s??ee(t);try{const a=await fetch(t,{mode:"cors"});if(!a.ok)throw new Error(`HTTP ${a.status}`);const r=await a.blob(),i=URL.createObjectURL(r),o=document.createElement("a");o.href=i,o.download=n,o.style.display="none",document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(i)}catch{if(!window.open(t,"_blank","noopener,noreferrer")){const r=document.createElement("a");r.href=t,r.download=n,r.target="_blank",r.rel="noopener noreferrer",r.style.display="none",document.body.appendChild(r),r.click(),document.body.removeChild(r)}}}const va=({src:t,filename:s,fileSize:n,mimeType:a,title:r,items:i})=>i&&i.length>0?i:t?[{src:t,filename:s,fileSize:n,mimeType:a,title:r}]:[],ja=({variant:t,item:s,index:n,onActivate:a,trailingAction:r})=>{const i=s.filename??ee(s.src);return e.jsx(ss,{variant:t,filename:i,title:s.title,mimeType:s.mimeType??"application/octet-stream",fileSize:s.fileSize,onActivate:()=>a(n),activateLabel:`Download ${i}`,trailingAction:r})},Qe=({state:t,src:s,filename:n,fileSize:a,mimeType:r,title:i,items:o,text:l,groupPosition:d,onClick:m,onDismiss:g})=>{const h=fe(t),f=t==="composer"&&!!g,c=va({src:s,filename:n,fileSize:a,mimeType:r,title:i,items:o}),p=b=>{if((m==null?void 0:m(b))===!1)return;const x=c[b];if(!x)return;const _=x.filename??ee(x.src);ns(x.src,_)};if(c.length===0)return null;const N=e.jsx("span",{className:S("flex size-8 items-center justify-center rounded-full",h==="dark"?"text-white/70":"text-black/70"),"aria-hidden":!0,children:e.jsx(v.DownloadSimpleIcon,{className:"size-5",weight:"bold"})});return e.jsx(he,{variant:h,text:l,groupPosition:d,"data-testid":"file-attachment",children:e.jsx("div",{className:"flex flex-col gap-2",children:c.map((b,x)=>{const _=f&&x===0?e.jsx(xe,{onClick:g,variant:"inline"}):N;return e.jsx(ja,{variant:h,item:b,index:x,onActivate:p,trailingAction:_},`${b.src}-${x}`)})})})},wa=t=>e.jsx(Qe,{...t,state:"composer"}),Na=t=>e.jsx(Qe,{...t,state:"sent"}),_a=t=>e.jsx(Qe,{...t,state:"received"}),ya={Composer:wa,Sent:Na,Received:_a},et=({onPrev:t,onNext:s,prevLabel:n="Previous",nextLabel:a="Next"})=>e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:t,"aria-label":n,className:"mes-media-viewer__nav mes-media-viewer__nav--prev",children:e.jsx(v.CaretLeftIcon,{size:20,weight:"bold","aria-hidden":!0})}),e.jsx("button",{type:"button",onClick:s,"aria-label":a,className:"mes-media-viewer__nav mes-media-viewer__nav--next",children:e.jsx(v.CaretRightIcon,{size:20,weight:"bold","aria-hidden":!0})})]}),as=({url:t,filename:s,variant:n="pill",label:a="Download",iconOnly:r,tone:i="dark",onTriggered:o})=>{const[l,d]=u.useState(!1),m=u.useCallback(c=>{c.stopPropagation(),!l&&(d(!0),ns(t,s).catch(()=>{}).finally(()=>{d(!1),o==null||o()}))},[l,t,s,o]),g=r??n!=="pill",f={className:S(n==="pill"?"size-4":"size-5","shrink-0"),weight:"bold"};if(n==="inline"){const c={dark:"text-white/70 hover:bg-white/[0.08] hover:text-white",light:"text-black/70 hover:bg-black/[0.08] hover:text-black"};return e.jsx("button",{type:"button",onClick:m,disabled:l,"aria-label":a,className:S("flex size-8 shrink-0 items-center justify-center rounded-full transition-colors disabled:opacity-70",c[i]),children:l?e.jsx(v.CircleNotchIcon,{className:"size-4 animate-spin",weight:"bold","aria-hidden":!0}):e.jsx(v.DownloadSimpleIcon,{className:"size-5 shrink-0",weight:"bold","aria-hidden":!0})})}return n==="viewer"?e.jsx("button",{type:"button",onClick:m,disabled:l,"aria-label":a,className:"mes-media-viewer__action",children:l?e.jsx(v.CircleNotchIcon,{size:20,weight:"bold","aria-hidden":!0}):e.jsx(v.DownloadSimpleIcon,{size:20,weight:"bold","aria-hidden":!0})}):e.jsxs("button",{type:"button",onClick:m,disabled:l,"aria-label":g?a:void 0,className:S("mt-3 inline-flex h-10 w-full items-center justify-center gap-2 rounded-full px-4 text-sm font-medium leading-none transition-colors disabled:opacity-70",i==="dark"?"bg-[#121110] text-white hover:bg-[#2a2928]":"bg-white text-[#121110] hover:bg-white/90"),children:[l?e.jsx(v.CircleNotchIcon,{className:"size-4 animate-spin",weight:"bold","aria-hidden":!0}):e.jsx(v.DownloadSimpleIcon,{...f,"aria-hidden":!0}),g?null:a]})},Ae=(t,s,n)=>Math.min(Math.max(t,s),n),tt=({length:t,initialIndex:s,open:n})=>{const a=Ae(s,0,Math.max(t-1,0)),[r,i]=u.useState(a);u.useEffect(()=>{n&&i(Ae(s,0,Math.max(t-1,0)))},[n,s,t]),u.useEffect(()=>{i(d=>Ae(d,0,Math.max(t-1,0)))},[t]);const o=u.useCallback(()=>{t<=1||i(d=>d<=0?t-1:d-1)},[t]),l=u.useCallback(()=>{t<=1||i(d=>d>=t-1?0:d+1)},[t]);return u.useEffect(()=>{if(!n||t<=1)return;const d=m=>{if(m.key!=="ArrowLeft"&&m.key!=="ArrowRight")return;const g=document.activeElement;g&&(g.tagName==="VIDEO"||g.tagName==="AUDIO")||(m.preventDefault(),m.key==="ArrowLeft"?o():l())};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[n,t,o,l]),{index:r,prev:o,next:l}},st=({open:t,onClose:s,ariaLabel:n,counter:a,actions:r,children:i,"data-testid":o})=>{const l=u.useRef(null),d=u.useRef(null);u.useEffect(()=>{var f;const h=l.current;if(h){if(t){if(!h.open)if(typeof h.showModal=="function")try{h.showModal()}catch{h.setAttribute("open","")}else h.setAttribute("open","");const c=typeof document<"u"?document.activeElement:null;return(f=d.current)==null||f.focus(),()=>{if(h.open)if(typeof h.close=="function")try{h.close()}catch{h.removeAttribute("open")}else h.removeAttribute("open");c&&document.body.contains(c)&&c.focus()}}if(h.open)if(typeof h.close=="function")try{h.close()}catch{h.removeAttribute("open")}else h.removeAttribute("open")}},[t]);const m=()=>{s()},g=h=>{h.target===l.current&&s()};return e.jsxs("dialog",{ref:l,className:"mes-media-viewer","aria-label":n??"Attachment viewer","data-testid":o,onClose:m,onClick:g,children:[e.jsxs("div",{className:"mes-media-viewer__chrome",children:[a?e.jsx("span",{className:"mes-media-viewer__counter",children:a}):null,e.jsxs("div",{className:"mes-media-viewer__actions",children:[r,e.jsx("button",{ref:d,type:"button",onClick:s,"aria-label":"Close viewer",className:"mes-media-viewer__action",children:e.jsx(v.XIcon,{size:20,weight:"bold","aria-hidden":!0})})]})]}),e.jsx("div",{className:"mes-media-viewer__body",children:i})]})},rs=({open:t,items:s,initialIndex:n=0,onClose:a})=>{const{index:r,prev:i,next:o}=tt({length:s.length,initialIndex:n,open:t}),l=s[r],d=u.useMemo(()=>(l==null?void 0:l.filename)??(l?ee(l.src):"image"),[l]);return l?e.jsxs(st,{open:t,onClose:a,ariaLabel:d,counter:s.length>1?`${r+1} / ${s.length}`:void 0,actions:e.jsx(as,{url:l.src,filename:d,variant:"viewer",label:`Download ${d}`}),"data-testid":"image-viewer",children:[e.jsx("img",{src:l.src,alt:l.alt??d,draggable:!1,loading:"eager",decoding:"async",className:"mes-media-viewer__image"},`${r}:${l.src}`),s.length>1?e.jsx(et,{onPrev:i,onNext:o,prevLabel:"Previous image",nextLabel:"Next image"}):null]}):null},Ca="relative block size-full overflow-hidden bg-black/5 outline-none focus-visible:ring-2 focus-visible:ring-white/80 focus-visible:ring-offset-2 focus-visible:ring-offset-black",is=({tiles:t,onTileActivate:s,maxVisible:n=4,className:a})=>{const r=t.length;if(r===0)return null;const i=t.slice(0,Math.min(r,n)),o=r-i.length,l=(d,m,g)=>{const h=S(Ca,"h-full w-full");return s?e.jsxs("button",{type:"button",onClick:()=>s(m),"aria-label":d.ariaLabel??`Open media ${m+1}`,className:S(h,"cursor-zoom-in"),children:[d.content,g]},m):e.jsxs("div",{className:h,children:[d.content,g]},m)};return i.length===1?e.jsx("div",{className:S("aspect-square w-full",a),children:l(i[0],0)}):i.length===2?e.jsx("div",{className:S("grid aspect-[16/9] w-full grid-cols-2 gap-0.5",a),children:i.map((d,m)=>l(d,m))}):i.length===3?e.jsxs("div",{className:S("grid aspect-[4/3] w-full grid-cols-2 grid-rows-2 gap-0.5",a),children:[e.jsx("div",{className:"row-span-2",children:l(i[0],0)}),l(i[1],1),l(i[2],2)]}):e.jsx("div",{className:S("grid aspect-[4/3] w-full grid-cols-2 grid-rows-2 gap-0.5",a),children:i.map((d,m)=>{const g=o>0&&m===i.length-1;return l(d,m,g?e.jsxs("div",{className:"absolute inset-0 flex items-center justify-center bg-black/55 text-2xl font-semibold text-white",children:["+",o]}):null)})})},ge=t=>{const[s,n]=u.useState(!1),[a,r]=u.useState(0),i=u.useCallback(l=>{(t==null?void 0:t(l))!==!1&&(r(l),n(!0))},[t]),o=u.useCallback(()=>n(!1),[]);return{viewerOpen:s,viewerIndex:a,handleActivate:i,closeViewer:o}},ka=(t,s,n,a)=>({ariaLabel:`Open image ${s+1} of ${n}`,content:e.jsx("img",{src:t.src,alt:t.alt??"",width:t.width,height:t.height,draggable:!1,loading:t.loading??a,decoding:"async",className:"absolute inset-0 size-full rounded-md object-cover"})}),Sa=({src:t,alt:s,items:n})=>n&&n.length>0?n:t?[{src:t,alt:s}]:[],os=(t,s)=>t.map((n,a)=>({src:n.src,alt:n.alt,filename:s&&t.length===1?s:s?`${s} (${a+1})`:void 0})),Ia=({src:t,alt:s,filename:n,loading:a="lazy",onClick:r,onDismiss:i})=>{const{viewerOpen:o,viewerIndex:l,handleActivate:d,closeViewer:m}=ge(r);return e.jsxs("div",{className:"relative w-fit",children:[e.jsx("button",{type:"button",onClick:()=>d(0),"aria-label":"Open image",className:"block size-[280px] cursor-zoom-in overflow-hidden rounded-md outline-none focus-visible:ring-2 focus-visible:ring-black/40",children:e.jsx("img",{src:t,alt:s??"",draggable:!1,loading:a,decoding:"async",className:"size-full object-cover"})}),i?e.jsx("div",{className:"absolute right-2 top-2 z-10",children:e.jsx(xe,{onClick:i})}):null,e.jsx(rs,{open:o,items:os([{src:t,alt:s}],n),initialIndex:l,onClose:m})]})},ls=({state:t,src:s,alt:n,filename:a,items:r,text:i,groupPosition:o,loading:l="lazy",onClick:d})=>{const m=Sa({src:s,alt:n,items:r}),g=fe(t),{viewerOpen:h,viewerIndex:f,handleActivate:c,closeViewer:p}=ge(d);if(m.length===0)return null;const N=m.map((b,x)=>ka(b,x,m.length,l));return e.jsxs(he,{variant:g,text:i,groupPosition:o,"data-testid":"image-attachment",children:[e.jsx("div",{className:"relative",children:e.jsx(is,{tiles:N,onTileActivate:c})}),e.jsx(rs,{open:h,items:os(m,a),initialIndex:f,onClose:p})]})},Ea=t=>e.jsx(Ia,{...t}),Ta=t=>e.jsx(ls,{...t,state:"sent"}),Ma=t=>e.jsx(ls,{...t,state:"received"}),Aa={Composer:Ea,Sent:Ta,Received:Ma},Ra=({open:t,items:s,initialIndex:n=0,onClose:a})=>{const{index:r,prev:i,next:o}=tt({length:s.length,initialIndex:n,open:t}),l=s[r],d=u.useMemo(()=>(l==null?void 0:l.filename)??(l?ee(l.src):"document"),[l]),m=u.useMemo(()=>l?La(l.src):void 0,[l]);return!l||!m?null:e.jsxs(st,{open:t,onClose:a,ariaLabel:d,counter:s.length>1?`${r+1} / ${s.length}`:void 0,"data-testid":"pdf-viewer",children:[e.jsx("iframe",{src:m,title:d,className:"mes-media-viewer__iframe",sandbox:"allow-scripts allow-forms allow-popups allow-downloads"},`${r}:${l.src}`),s.length>1?e.jsx(et,{onPrev:i,onNext:o,prevLabel:"Previous document",nextLabel:"Next document"}):null]})},La=t=>{const s=t.indexOf("#"),n=s===-1?t:t.slice(0,s),a=s===-1?"":t.slice(s+1),r=new URLSearchParams(a);return r.has("toolbar")||r.set("toolbar","0"),r.has("navpanes")||r.set("navpanes","0"),`${n}#${r.toString()}`},Da=({src:t,filename:s,fileSize:n,title:a,items:r})=>r&&r.length>0?r:t?[{src:t,filename:s,fileSize:n,title:a}]:[],Fa=({variant:t,item:s,index:n,onActivate:a,trailingAction:r})=>{const i=s.filename??ee(s.src);return e.jsx(ss,{variant:t,filename:i,title:s.title,mimeType:"application/pdf",fileSize:s.fileSize,onActivate:()=>a(n),activateLabel:`Open ${i}`,trailingAction:r})},nt=({state:t,src:s,filename:n,fileSize:a,title:r,items:i,text:o,groupPosition:l,onClick:d,onDismiss:m})=>{const g=fe(t),h=Da({src:s,filename:n,fileSize:a,title:r,items:i}),{viewerOpen:f,viewerIndex:c,handleActivate:p,closeViewer:N}=ge(d),b=t==="composer"&&!!m;if(h.length===0)return null;const x=h.map(_=>({src:_.src,filename:_.filename??ee(_.src)}));return e.jsxs(he,{variant:g,text:o,groupPosition:l,"data-testid":"pdf-attachment",children:[e.jsx("div",{className:"flex flex-col gap-2",children:h.map((_,j)=>{const E=_.filename??ee(_.src),L=b&&j===0?e.jsx(xe,{onClick:m,variant:"inline"}):t==="composer"?void 0:e.jsx(as,{url:_.src,filename:E,variant:"inline",label:`Download ${E}`,tone:g});return e.jsx(Fa,{variant:g,item:_,index:j,onActivate:p,trailingAction:L},`${_.src}-${j}`)})}),e.jsx(Ra,{open:f,items:x,initialIndex:c,onClose:N})]})},Pa=t=>e.jsx(nt,{...t,state:"composer"}),za=t=>e.jsx(nt,{...t,state:"sent"}),Oa=t=>e.jsx(nt,{...t,state:"received"}),$a={Composer:Pa,Sent:za,Received:Oa},cs=({open:t,items:s,initialIndex:n=0,onClose:a})=>{const{index:r,prev:i,next:o}=tt({length:s.length,initialIndex:n,open:t}),l=s[r],d=u.useMemo(()=>(l==null?void 0:l.filename)??(l?ee(l.src):"video"),[l]);return l?e.jsxs(st,{open:t,onClose:a,ariaLabel:d,counter:s.length>1?`${r+1} / ${s.length}`:void 0,"data-testid":"video-viewer",children:[e.jsx("video",{src:l.src,poster:l.poster,controls:!0,autoPlay:!0,muted:!0,playsInline:!0,preload:l.preload??"metadata",className:"mes-media-viewer__video",children:l.mimeType?e.jsx("source",{src:l.src,type:l.mimeType}):null},`${r}:${l.src}`),s.length>1?e.jsx(et,{onPrev:i,onNext:o,prevLabel:"Previous video",nextLabel:"Next video"}):null]}):null},Ua=()=>e.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center",children:e.jsx("span",{className:"flex size-12 items-center justify-center rounded-full bg-black/55 text-white backdrop-blur",children:e.jsx(v.PlayIcon,{className:"size-6",weight:"fill","aria-hidden":!0})})}),ds=({item:t,index:s})=>e.jsxs("div",{className:"absolute inset-0 size-full bg-[#0d0d0d]",children:[t.poster?e.jsx("img",{src:t.poster,alt:`Video ${s+1} thumbnail`,draggable:!1,loading:"lazy",decoding:"async",className:"absolute inset-0 size-full rounded-md object-cover"}):e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsx(v.VideoCameraIcon,{className:"size-16 rounded-md text-white/30",weight:"regular","aria-hidden":!0})}),e.jsx(Ua,{})]}),Ba=(t,s,n)=>({ariaLabel:`Play video ${s+1} of ${n}`,content:e.jsx(ds,{item:t,index:s})}),Va=({src:t,poster:s,mimeType:n,preload:a,items:r})=>r&&r.length>0?a?r.map(i=>({...i,preload:i.preload??a})):r:t?[{src:t,poster:s,mimeType:n,preload:a}]:[],us=(t,s)=>t.map((n,a)=>({src:n.src,poster:n.poster,mimeType:n.mimeType,preload:n.preload,filename:s&&t.length===1?s:s?`${s} (${a+1})`:void 0})),Ga=({src:t,poster:s,mimeType:n,filename:a,preload:r,onClick:i,onDismiss:o})=>{const{viewerOpen:l,viewerIndex:d,handleActivate:m,closeViewer:g}=ge(i);return e.jsxs("div",{className:"relative w-fit",children:[e.jsx("button",{type:"button",onClick:()=>m(0),"aria-label":"Play video",className:"relative block size-[280px] cursor-pointer overflow-hidden rounded-md outline-none focus-visible:ring-2 focus-visible:ring-black/40",children:e.jsx(ds,{item:{src:t,poster:s,mimeType:n},index:0})}),o?e.jsx("div",{className:"absolute right-2 top-2 z-10",children:e.jsx(xe,{onClick:o})}):null,e.jsx(cs,{open:l,items:us([{src:t,poster:s,mimeType:n,preload:r}],a),initialIndex:d,onClose:g})]})},ms=({state:t,src:s,poster:n,mimeType:a,filename:r,items:i,text:o,groupPosition:l,preload:d,onClick:m})=>{const g=Va({src:s,poster:n,mimeType:a,preload:d,items:i}),h=fe(t),{viewerOpen:f,viewerIndex:c,handleActivate:p,closeViewer:N}=ge(m);if(g.length===0)return null;const b=g.map((x,_)=>Ba(x,_,g.length));return e.jsxs(he,{variant:h,text:o,groupPosition:l,"data-testid":"video-attachment",children:[e.jsx("div",{className:"relative",children:e.jsx(is,{tiles:b,onTileActivate:p,className:"overflow-hidden rounded-md"})}),e.jsx(cs,{open:f,items:us(g,r),initialIndex:c,onClose:N})]})},Ha=t=>e.jsx(Ga,{...t}),Ya=t=>e.jsx(ms,{...t,state:"sent"}),qa=t=>e.jsx(ms,{...t,state:"received"}),Xa={Composer:Ha,Sent:Ya,Received:qa},Wa={Image:Aa,Video:Xa,Audio:xa,Pdf:$a,File:ya},hs=({question:t,onClick:s,loading:n=!1,className:a})=>e.jsx("button",{type:"button",onClick:s,disabled:n,style:{backgroundColor:"#E6E5E3"},className:S("w-full text-center p-4 rounded-xl text-charcoal font-medium transition-colors focus-ring",{"hover:brightness-95 active:brightness-90":!n,"opacity-50 cursor-not-allowed":n},a),children:t}),Ka=({faqs:t,onFaqClick:s,loadingFaqId:n,headerText:a,className:r,avatarImage:i,avatarName:o})=>{const l=t.filter(d=>d.enabled).sort((d,m)=>(d.order??0)-(m.order??0));return l.length===0?null:e.jsx("div",{className:r,children:e.jsxs("div",{className:"flex gap-3 items-end",children:[(i||o)&&e.jsx("div",{className:"flex-none",children:e.jsx(Z,{id:o||"account",name:o||"Account",image:i,size:24,shape:"circle"})}),e.jsxs("div",{className:"flex-1 flex flex-col gap-3 rounded-lg p-4",style:{backgroundColor:"#F1F0EE"},children:[a&&e.jsx("p",{className:"text-md text-charcoal mb-4",children:a}),l.map(d=>e.jsx(hs,{question:d.question,onClick:()=>s(d.id),loading:n===d.id},d.id))]})]})})};exports.ActionButton=re;exports.AttachmentThumbnail=Ve;exports.Avatar=Z;exports.ChannelEmptyState=qt;exports.ChannelList=Jt;exports.ChannelView=Xe;exports.CustomMessageProvider=sn;exports.FaqList=Ka;exports.FaqListItem=hs;exports.LinkAttachment=sa;exports.LockedAttachment=Pe;exports.MediaMessage=Qs;exports.MessageAttachment=Wa;exports.MessageVoteButtons=Ht;exports.MessagingProvider=fs;exports.MessagingShell=Pn;exports.bubbleGroupPositionFromStream=la;exports.buildCompactMetaLabel=ts;exports.formatFileSize=Qt;exports.formatRelativeTime=Wt;exports.getFileExtensionLabel=es;exports.getMessageDisplayText=Ue;exports.getSourceType=te;exports.isLinkAttachment=Ye;exports.isUuidLike=Mt;exports.normalizeLanguageCode=Lt;exports.renderTypeIcon=ne;exports.resolveConversationParticipant=me;exports.resolveLinkAttachment=ye;exports.resolveMediaFromMessage=Ce;exports.resolveParticipantDisplayName=_e;exports.useComposerLocked=bn;exports.useCustomMessage=Vt;exports.useMessageVote=Rt;exports.useMessaging=Tt;
|
|
2
|
+
//# sourceMappingURL=index-BIJpO0jL.cjs.map
|