@linktr.ee/messaging-react 2.2.2-rc-1779314025 → 2.2.3
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-CAliTKdt.js → Card-BRub_HpW.js} +3 -3
- package/dist/{Card-CAliTKdt.js.map → Card-BRub_HpW.js.map} +1 -1
- package/dist/{Card-Ca5PnHml.js → Card-Ccy5fPho.js} +2 -2
- package/dist/{Card-Ca5PnHml.js.map → Card-Ccy5fPho.js.map} +1 -1
- package/dist/{Card-CRMpOj0f.cjs → Card-CyszwESe.cjs} +2 -2
- package/dist/{Card-CRMpOj0f.cjs.map → Card-CyszwESe.cjs.map} +1 -1
- package/dist/{Card-Dz2v3fXf.js → Card-DOws_Rs6.js} +2 -2
- package/dist/{Card-Dz2v3fXf.js.map → Card-DOws_Rs6.js.map} +1 -1
- package/dist/{Card-vEkarkVD.cjs → Card-DWH_vCQD.cjs} +2 -2
- package/dist/{Card-vEkarkVD.cjs.map → Card-DWH_vCQD.cjs.map} +1 -1
- package/dist/{Card-b41LWND_.cjs → Card-imQIyJzJ.cjs} +2 -2
- package/dist/{Card-b41LWND_.cjs.map → Card-imQIyJzJ.cjs.map} +1 -1
- package/dist/{LockedThumbnail-BGz0NIQh.js → LockedThumbnail-C9eocsRT.js} +2 -2
- package/dist/{LockedThumbnail-BGz0NIQh.js.map → LockedThumbnail-C9eocsRT.js.map} +1 -1
- package/dist/{LockedThumbnail-JuPkpHeX.cjs → LockedThumbnail-D512VE6T.cjs} +2 -2
- package/dist/{LockedThumbnail-JuPkpHeX.cjs.map → LockedThumbnail-D512VE6T.cjs.map} +1 -1
- package/dist/index-IlgylJT2.cjs +2 -0
- package/dist/index-IlgylJT2.cjs.map +1 -0
- package/dist/{index-D55UTfgC.js → index-uxWUZe1M.js} +2 -3
- package/dist/index-uxWUZe1M.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/src/components/CustomMessageInput/CustomMessageInput.test.tsx +1 -0
- package/src/components/CustomMessageInput/index.tsx +0 -5
- package/dist/index-CctUDJSJ.cjs +0 -2
- package/dist/index-CctUDJSJ.cjs.map +0 -1
- package/dist/index-D55UTfgC.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-IlgylJT2.cjs");exports.ActionButton=e.ActionButton;exports.Avatar=e.Avatar;exports.ChannelEmptyState=e.ChannelEmptyState;exports.ChannelList=e.ChannelList;exports.ChannelView=e.ChannelView;exports.CustomMessageProvider=e.CustomMessageProvider;exports.FaqList=e.FaqList;exports.FaqListItem=e.FaqListItem;exports.LinkAttachment=e.LinkAttachment;exports.LockedAttachment=e.LockedAttachment;exports.MediaMessage=e.MediaMessage;exports.MessageAttachment=e.MessageAttachment;exports.MessageVoteButtons=e.MessageVoteButtons;exports.MessagingProvider=e.MessagingProvider;exports.MessagingShell=e.MessagingShell;exports.buildCompactMetaLabel=e.buildCompactMetaLabel;exports.formatFileSize=e.formatFileSize;exports.formatRelativeTime=e.formatRelativeTime;exports.getFileExtensionLabel=e.getFileExtensionLabel;exports.getMessageDisplayText=e.getMessageDisplayText;exports.isLinkAttachment=e.isLinkAttachment;exports.isUuidLike=e.isUuidLike;exports.messageAttachmentGroupPositionFromStream=e.bubbleGroupPositionFromStream;exports.normalizeLanguageCode=e.normalizeLanguageCode;exports.resolveLinkAttachment=e.resolveLinkAttachment;exports.resolveMediaFromMessage=e.resolveMediaFromMessage;exports.resolveParticipantDisplayName=e.resolveParticipantDisplayName;exports.useCustomMessage=e.useCustomMessage;exports.useMessageVote=e.useMessageVote;exports.useMessaging=e.useMessaging;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as e, b as t, C as i, c as n, d as o, e as m, F as g, f as l, L as r, h as M, M as u, i as L, j as c, k as h, l as d, m as p, n as v, o as A, p as C, q as F, s as k, t as b, u as f, v as x, w as y, x as P, y as S, z as q, B as z, D as B } from "./index-
|
|
1
|
+
import { a as e, b as t, C as i, c as n, d as o, e as m, F as g, f as l, L as r, h as M, M as u, i as L, j as c, k as h, l as d, m as p, n as v, o as A, p as C, q as F, s as k, t as b, u as f, v as x, w as y, x as P, y as S, z as q, B as z, D as B } from "./index-uxWUZe1M.js";
|
|
2
2
|
export {
|
|
3
3
|
e as ActionButton,
|
|
4
4
|
t as Avatar,
|
package/package.json
CHANGED
|
@@ -81,6 +81,7 @@ describe('CustomMessageInput', () => {
|
|
|
81
81
|
expect(messageInput).not.toHaveAttribute('aria-disabled')
|
|
82
82
|
expect(messageInput).not.toHaveAttribute('inert')
|
|
83
83
|
expect(screen.getByTestId('stream-message-input')).toBeInTheDocument()
|
|
84
|
+
expect(screen.getByTestId('textarea-composer')).not.toHaveAttribute('autofocus')
|
|
84
85
|
})
|
|
85
86
|
|
|
86
87
|
it('renders the frozen message input when channel is frozen', () => {
|
|
@@ -55,11 +55,6 @@ const CustomMessageInputInner: React.FC = () => {
|
|
|
55
55
|
<TextareaComposer
|
|
56
56
|
aria-disabled={isFrozen || undefined}
|
|
57
57
|
className="w-full resize-none outline-none leading-6"
|
|
58
|
-
// While this might usually be considered an anti-pattern, in most
|
|
59
|
-
// cases, when a message thread is rendered, we want the input to
|
|
60
|
-
// gain focus automatically.
|
|
61
|
-
// eslint-disable-next-line jsx-a11y/no-autofocus
|
|
62
|
-
autoFocus={!isFrozen}
|
|
63
58
|
maxRows={4}
|
|
64
59
|
readOnly={isFrozen}
|
|
65
60
|
tabIndex={isFrozen ? -1 : undefined}
|
package/dist/index-CctUDJSJ.cjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";const e=require("react/jsx-runtime"),_=require("classnames"),d=require("react"),ms=require("@linktr.ee/messaging-core"),C=require("stream-chat-react"),w=require("@phosphor-icons/react"),vt=require("stream-chat"),hs=require("react-dom"),Et=d.createContext({service:null,client:null,isConnected:!1,isLoading:!1,error:null,capabilities:{},refreshConnection:async()=>{},debug:!1}),Ve=()=>d.useContext(Et),xs=({children:t,user:s,serviceConfig:n,apiKey:a,capabilities:r={},debug:i=!1})=>{const l=d.useCallback((k,...T)=>{i&&console.log(`🔥 [MessagingProvider] ${k}`,...T)},[i]);l("🔄 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[c,m]=d.useState(null),[u,f]=d.useState(null),[h,x]=d.useState(!1),[o,g]=d.useState(!1),[v,p]=d.useState(null),N=d.useRef(!1),j=d.useRef({userId:s==null?void 0:s.id,apiKey:a,serviceConfig:n,capabilities:r}),I=d.useRef(0);I.current++,l("📊 RENDER INFO",{renderCount:I.current,currentProps:{userId:s==null?void 0:s.id,apiKey:(a==null?void 0:a.substring(0,8))+"..."},propChanges:{userChanged:j.current.userId!==(s==null?void 0:s.id),apiKeyChanged:j.current.apiKey!==a,serviceConfigChanged:j.current.serviceConfig!==n,capabilitiesChanged:j.current.capabilities!==r}}),j.current={userId:s==null?void 0:s.id,apiKey:a,serviceConfig:n,capabilities:r},d.useEffect(()=>{const k=I.current;if(l("🔧 SERVICE INIT EFFECT TRIGGERED",{renderCount:k,apiKey:!!a,serviceConfig:!!n,dependencies:{apiKey:(a==null?void 0:a.substring(0,8))+"...",serviceConfigRef:n,serviceConfigStable:j.current.serviceConfig===n,apiKeyStable:j.current.apiKey===a}}),!a||!n){l("⚠️ SERVICE INIT SKIPPED",{renderCount:k,reason:"Missing apiKey or serviceConfig"});return}l("🚀 CREATING NEW SERVICE",{renderCount:k,apiKey:(a==null?void 0:a.substring(0,8))+"...",serviceConfigChanged:j.current.serviceConfig!==n});const T=new ms.StreamChatService({...n,apiKey:a,debug:i});return m(T),l("✅ SERVICE SET",{renderCount:k,serviceInstance:!!T}),()=>{l("🧹 SERVICE CLEANUP",{renderCount:k,reason:"Effect cleanup"}),T.disconnectUser().catch(console.error)}},[a,n,i,l]);const S=d.useRef(null);d.useEffect(()=>{var T,A;if(l("🔗 USER CONNECTION EFFECT TRIGGERED",{hasService:!!c,hasUser:!!s,userId:s==null?void 0:s.id,isConnecting:N.current,isConnected:h,dependencies:{service:!!c,userId:s==null?void 0:s.id}}),!c||!s){l("⚠️ USER CONNECTION SKIPPED","Missing service or user");return}if(N.current){l("⚠️ USER CONNECTION SKIPPED","Already connecting");return}if(((T=S.current)==null?void 0:T.serviceId)===c&&((A=S.current)==null?void 0:A.userId)===s.id){l("⚠️ USER CONNECTION SKIPPED","Already connected this user with this service");return}(async()=>{l("🚀 STARTING USER CONNECTION",{userId:s.id}),N.current=!0,g(!0),p(null);try{l("📞 CALLING SERVICE.CONNECTUSER",{userId:s.id});const D=await c.connectUser(s);f(D),x(!0),S.current={serviceId:c,userId:s.id},l("✅ USER CONNECTION SUCCESS",{userId:s.id,clientId:D.userID})}catch(D){const R=D instanceof Error?D.message:"Connection failed";p(R),l("❌ USER CONNECTION ERROR",{userId:s.id,error:R})}finally{g(!1),N.current=!1,l("🔄 USER CONNECTION FINISHED",{userId:s.id,isConnected:h})}})()},[c,s,l,h]),d.useEffect(()=>(l("🔌 CLEANUP EFFECT REGISTERED",{hasService:!!c,isConnected:h}),()=>{c&&h?(l("🧹 CLEANUP EFFECT TRIGGERED","Cleaning up connection on unmount"),S.current=null,c.disconnectUser().catch(console.error)):l("🔇 CLEANUP EFFECT SKIPPED",{hasService:!!c,isConnected:h})}),[c,h,l]);const E=d.useCallback(async()=>{if(l("🔄 REFRESH CONNECTION CALLED",{hasService:!!c,hasUser:!!s}),!c||!s){l("⚠️ REFRESH CONNECTION SKIPPED","Missing service or user");return}l("🚀 STARTING CONNECTION REFRESH",{userId:s.id}),g(!0);try{l("🔌 DISCONNECTING FOR REFRESH"),await c.disconnectUser(),l("📞 RECONNECTING FOR REFRESH");const k=await c.connectUser(s);f(k),x(!0),p(null),l("✅ CONNECTION REFRESH SUCCESS",{userId:s.id})}catch(k){const T=k instanceof Error?k.message:"Refresh failed";p(T),l("❌ CONNECTION REFRESH ERROR",{userId:s.id,error:T})}finally{g(!1),l("🔄 CONNECTION REFRESH FINISHED",{userId:s.id})}},[c,s,l]),y=d.useMemo(()=>(l("💫 CONTEXT VALUE MEMOIZATION",{hasService:!!c,hasClient:!!u,isConnected:h,isLoading:o,hasError:!!v,capabilitiesKeys:Object.keys(r)}),{service:c,client:u,isConnected:h,isLoading:o,error:v,capabilities:r,refreshConnection:E,debug:i}),[c,u,h,o,v,r,E,i,l]);return l("🔄 RENDER END",{renderCount:I.current,willRenderChat:!!(u&&h),contextValueReady:!!y}),e.jsx(Et.Provider,{value:y,children:u&&h?e.jsx(C.Chat,{client:u,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})},It=()=>Ve();function fs(t){const s=t.state.pending_messages;if(s!=null&&s.length)for(const n of s)t.state.addMessageSorted(n.message)}const Mt=d.createContext({selectedChannel:void 0,onChannelSelect:()=>{},debug:!1,renderMessagePreview:void 0,viewerLanguage:void 0}),gs=Mt.Provider,bs=()=>d.useContext(Mt),Tt=t=>{var a,r;const[s,n]=d.useState(!!((r=(a=t==null?void 0:t.state)==null?void 0:a.membership)!=null&&r.pinned_at));return d.useEffect(()=>{var l;if(!t){n(!1);return}n(!!((l=t.state.membership)!=null&&l.pinned_at));const i=c=>{var m;n(c!=null&&c.member?!!c.member.pinned_at:!!((m=t.state.membership)!=null&&m.pinned_at))};return t.on("member.updated",i),()=>{t.off("member.updated",i)}},[t]),s},ps=(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))},At=t=>{const s=new Date;if(Math.floor((s.getTime()-t.getTime())/1e3)<60)return"Just now";const a=ps(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"})};function Rt(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=Rt(s);return a?((r=t==null?void 0:t.i18n)==null?void 0:r[`${a}_text`])??n:n}const vs=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;function Lt(t){return vs.test(t.trim())}function jt(t,s){const n=t==null?void 0:t.trim();return!n||s&&n===s?!1:!Lt(n)}function Se(t){return jt(t==null?void 0:t.name,t==null?void 0:t.id)?t.name.trim():jt(t==null?void 0:t.username,t==null?void 0:t.id)?t.username.trim():"Unknown member"}const wt=["🍎","🍌","🍇","🍊","🍓","🥥","🍒","🥭","🍉","🍋","🥝","🫒","🍈"];function js(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 ws(t){const n=js(t)%wt.length;return wt[n]}const Q=({id:t,image:s,size:n=40,className:a,starred:r=!1,shape:i="squircle",dmAgentEnabled:l=!1})=>{const c=ws(t),u=n<32?"text-xs":n<56?"text-sm":n<120?"text-lg":"text-4xl",f=n>=40?2:1,h=i==="circle"?{borderRadius:"50%"}:{borderRadius:"33%",cornerShape:"superellipse(1.3)"},x=e.jsx("div",{className:"h-full w-full overflow-hidden",style:h,children:s?e.jsx("img",{src:s,alt:"",className:"h-full w-full object-cover"}):e.jsx("div",{"aria-hidden":"true",className:_("avatar-fallback flex h-full w-full items-center justify-center bg-[#E6E5E3] font-semibold select-none transition-colors",u),children:c})});return e.jsxs("div",{className:_("relative flex-shrink-0 !bg-transparent",a),style:{"--str-chat__avatar-size":`${n}px`,width:`${n}px`,height:`${n}px`},children:[r&&e.jsx("div",{"aria-hidden":"true",className:"absolute -left-1.5 -top-1.5 z-10 flex size-5 items-center justify-center rounded-full bg-white shadow-[0_0_0_1px_rgba(0,0,0,0.04),0_4px_8px_rgba(0,0,0,0.06)]",children:e.jsx(w.StarIcon,{className:"size-3 text-yellow-600",weight:"duotone"})}),e.jsx("div",{"data-testid":"avatar-ring",className:_("h-full w-full","bg-transparent"),style:{...h,...l&&{borderWidth:`${f}px`,borderStyle:"solid",borderColor:"var(--AI-Gradient, #7F22FE)",boxShadow:"inset 0 1px 2px 0 rgba(255, 255, 255, 0.5)"}},children:x})]})},ys=({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})}),Cs=t=>{var s;return((s=t.metadata)==null?void 0:s.custom_type)==="MESSAGE_TIP"},Ns=t=>{var s;return((s=t.metadata)==null?void 0:s.custom_type)==="MESSAGE_PAID"},Ce=t=>{var s;return((s=t.metadata)==null?void 0:s.custom_type)==="MESSAGE_CHATBOT"},_s=t=>{var s;return((s=t.metadata)==null?void 0:s.custom_type)==="MESSAGE_ATTACHMENT"},Dt=t=>Cs(t)||Ns(t),ks=t=>{var s;return Dt(t)&&!((s=t.text)!=null&&s.trim())},Re=({message:t,standalone:s=!1,isMyMessage:n=!1,hasAttachment:a=!1})=>{var h;const r=Dt(t),i=Ce(t);if(!r&&!i)return null;if(r){const x=(h=t.metadata)==null?void 0:h.amount_text;if(!x)return null;const o=s?"message-tip-standalone":"message-tag message-tag--tip",g=s?`${x} tip`:`Delivered with ${x} tip`;return e.jsxs("div",{className:o,children:[e.jsx(w.GiftIcon,{size:s?14:12}),e.jsx("span",{children:g})]})}const l=n&&a,c=l?"Sent with AI":"Sent with DM Agent",m=["message-chatbot-indicator",n?"message-chatbot-indicator--sender":"message-chatbot-indicator--receiver",l?"message-chatbot-indicator--attachment":"message-chatbot-indicator--text"].join(" "),u=e.jsx("span",{className:"message-chatbot-indicator__label",children:c}),f=e.jsx("span",{className:"message-chatbot-indicator__icon",children:e.jsx(ys,{size:l?12:15})});return e.jsx("div",{className:m,"data-testid":"message-chatbot-indicator",children:n&&!l?e.jsxs(e.Fragment,{children:[u,f]}):e.jsxs(e.Fragment,{children:[f,u]})})},Ft=d.memo(({channel:t,unread:s})=>{var y,k,T;const{selectedChannel:n,onChannelSelect:a,debug:r,renderMessagePreview:i,viewerLanguage:l}=bs(),c=(n==null?void 0:n.id)===(t==null?void 0:t.id),m=()=>{t&&a(t)},u=A=>{const D=A.key==="Enter"||A.key===" ",R=A.repeat;!D||R||(A.preventDefault(),m())},h=Object.values(((y=t==null?void 0:t.state)==null?void 0:y.members)||{}).find(A=>{var D,R;return((D=A.user)==null?void 0:D.id)&&A.user.id!==((R=t==null?void 0:t._client)==null?void 0:R.userID)}),x=Se(h==null?void 0:h.user),o=(k=h==null?void 0:h.user)==null?void 0:k.image,g=(()=>{var D;const A=(D=t==null?void 0:t.state)==null?void 0:D.messages;if(A!=null&&A.length){for(let R=A.length-1;R>=0;R--)if(A[R].type!=="system")return A[R]}})(),p=(()=>{var F,$;const A=Ue({message:g,viewerLanguage:l});if(A)return A;if(((F=g==null?void 0:g.metadata)==null?void 0:F.custom_type)==="MESSAGE_TIP")return"💵 Sent a tip";const R=($=g==null?void 0:g.attachments)==null?void 0:$[0];return R?R.og_scrape_url?R.og_scrape_url:R.type==="image"?"📷 Sent an image":R.type==="video"?"🎥 Sent a video":R.type==="audio"?"🎵 Sent audio":R.type==="file"?"📎 Sent a file":"📎 Sent an attachment":"No messages yet"})(),N=g!=null&&g.created_at?At(new Date(g.created_at)):"",j=g?Ce(g):!1,I=i?i(g,p):`${j?"✨ ":""}${p}`,S=Tt(t),E=s??0;return r&&console.log("📺 [ChannelList] 📋 CHANNEL PREVIEW RENDER",{channelId:t==null?void 0:t.id,isSelected:c,participantName:x,unreadCount:E,hasTimestamp:!!N}),e.jsx("div",{role:"button",tabIndex:0,onClick:m,onKeyDown:u,className:_("group w-full px-4 py-3 transition-colors text-left max-w-full overflow-hidden focus-ring",{"bg-primary-alt/10 border-l-4 border-l-primary":c,"hover:bg-sand":!c}),children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Q,{id:((T=h==null?void 0:h.user)==null?void 0:T.id)||t.id||"unknown",name:x,image:o,size:44,starred:S,className:"[&_.avatar-fallback]:group-hover:bg-[#eeeeee]"}),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:_("text-sm font-medium truncate",c?"text-primary":"text-charcoal"),children:[S&&e.jsx("span",{className:"sr-only",children:"Starred conversation. "}),x]}),N&&e.jsx("span",{className:"text-xs text-stone flex-shrink-0",children:N})]}),e.jsxs("div",{className:"flex items-center justify-between gap-2 min-w-0",children:[e.jsx("p",{className:"text-xs text-stone flex-1 line-clamp-1",children:I}),E>0&&e.jsx("span",{className:"bg-[#7f22fe] text-white text-xs px-2 py-0.5 rounded-full min-w-[20px] text-center flex-shrink-0",children:E>99?"99+":E})]})]})]})})});Ft.displayName="CustomChannelPreview";const Ss={last_message_at:-1},Ge=d.memo(({onChannelSelect:t,selectedChannel:s,filters:n,allowNewMessagesFromUnfilteredChannels:a=!1,onMessageNew:r,onAddedToChannel:i,channelRenderFilterFn:l,sort:c=Ss,className:m,customEmptyStateIndicator:u,renderMessagePreview:f,viewerLanguage:h})=>{const x=d.useRef(0);x.current++;const{debug:o=!1}=Ve(),g=d.useCallback(p=>{for(const N of p)fs(N);return l?l(p):p},[l]);o&&console.log("📺 [ChannelList] 🔄 RENDER START",{renderCount:x.current,selectedChannelId:s==null?void 0:s.id,filters:n});const v=d.useMemo(()=>({selectedChannel:s,onChannelSelect:t,debug:o,renderMessagePreview:f,viewerLanguage:h}),[s,t,o,f,h]);return e.jsx("div",{className:_("messaging-channel-list h-full flex flex-col min-w-0 overflow-hidden",m),children:e.jsx("div",{className:"flex-1 overflow-hidden min-w-0",children:e.jsx(gs,{value:v,children:e.jsx(C.ChannelList,{filters:n,sort:c,options:{limit:30},allowNewMessagesFromUnfilteredChannels:a,onMessageNew:r,onAddedToChannel:i,channelRenderFilterFn:g,Preview:Ft,EmptyStateIndicator:u},`${JSON.stringify(n)}:${JSON.stringify(c)}`)})})})});Ge.displayName="ChannelList";const ue=({variant:t="default",className:s,children:n,...a})=>{const r=t==="danger";return e.jsx("button",{type:"button",className:_("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})};function Es({label:t,className:s,children:n,...a}){return e.jsxs("button",{type:"button",className:_("inline-flex items-center justify-center rounded-full transition-colors focus-ring p-2",{"cursor-not-allowed opacity-50":a.disabled,"hover:bg-sand":!a.disabled},s),...a,children:[e.jsx("span",{className:"sr-only",children:t}),n]})}function Is({onClick:t}){return e.jsx(Es,{label:"Close",onClick:t,className:"p-1",children:e.jsx(w.XIcon,{className:"h-5 w-5 text-stone",weight:"bold"})})}const Ms=({dialogRef:t,onClose:s,participant:n,participantDisplayName:a,channel:r,followerStatusLabel:i,onLeaveConversation:l,onBlockParticipant:c,showDeleteConversation:m=!0,onDeleteConversationClick:u,onBlockParticipantClick:f,onReportParticipantClick:h,customProfileContent:x,customChannelActions:o})=>{var G,z,V,U;const{service:g,debug:v}=Ve(),[p,N]=d.useState(!1),[j,I]=d.useState(!1),[S,E]=d.useState(!1),y=d.useCallback(async()=>{var L;if(!(!g||!((L=n==null?void 0:n.user)!=null&&L.id)))try{const b=(await g.getBlockedUsers()).some(M=>{var P;return M.blocked_user_id===((P=n==null?void 0:n.user)==null?void 0:P.id)});N(b)}catch(O){console.error("[ChannelInfoDialog] Failed to check blocked status:",O)}},[g,(G=n==null?void 0:n.user)==null?void 0:G.id]);d.useEffect(()=>{y()},[y]);const k=async()=>{var L;if(!j){u==null||u(),v&&console.log("[ChannelInfoDialog] Leave conversation",r.cid),I(!0);try{const O=((L=r._client)==null?void 0:L.userID)??null;await r.hide(O,!1),l&&await l(r),s()}catch(O){console.error("[ChannelInfoDialog] Failed to leave conversation",O)}finally{I(!1)}}},T=async()=>{var L,O,b;if(!(S||!g)){f==null||f(),v&&console.log("[ChannelInfoDialog] Block member",(L=n==null?void 0:n.user)==null?void 0:L.id),E(!0);try{await g.blockUser((O=n==null?void 0:n.user)==null?void 0:O.id),c&&await c((b=n==null?void 0:n.user)==null?void 0:b.id),s()}catch(M){console.error("[ChannelInfoDialog] Failed to block member",M)}finally{E(!1)}}},A=async()=>{var L,O,b;if(!(S||!g)){f==null||f(),v&&console.log("[ChannelInfoDialog] Unblock member",(L=n==null?void 0:n.user)==null?void 0:L.id),E(!0);try{await g.unBlockUser((O=n==null?void 0:n.user)==null?void 0:O.id),c&&await c((b=n==null?void 0:n.user)==null?void 0:b.id),s()}catch(M){console.error("[ChannelInfoDialog] Failed to unblock member",M)}finally{E(!1)}}},D=()=>{h==null||h(),s(),window.open("https://linktr.ee/s/about/trust-center/report","_blank","noopener,noreferrer")};if(!n)return null;const R=a??Se(n.user),F=(z=n.user)==null?void 0:z.image,$=(V=n.user)==null?void 0:V.username,Y=$?`linktr.ee/${$}`:void 0,H=((U=n.user)==null?void 0:U.id)||"unknown";return e.jsx("dialog",{ref:t,className:"mes-dialog group",onClose:s,onClick:L=>{L.target===t.current&&s()},children:e.jsxs("div",{className:"ml-auto flex h-full w-full flex-col bg-white shadow-none transition-shadow duration-200 group-open:shadow-max-elevation-light",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-sand px-4 py-3",children:[e.jsx("h2",{className:"text-base font-semibold text-charcoal",children:"Chat info"}),e.jsx(Is,{onClick:s})]}),e.jsxs("div",{className:"flex-1 px-2 overflow-y-auto w-full",children:[e.jsxs("div",{className:"flex flex-col items-center gap-3 self-stretch px-4 py-2 mt-6 rounded-lg border border-black/[0.04]",style:{backgroundColor:"#FBFAF9"},children:[e.jsxs("div",{className:"flex items-center gap-3 w-full",children:[e.jsx(Q,{id:H,name:R,image:F,size:88,shape:"circle"}),e.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[e.jsx("p",{className:"truncate text-base font-semibold text-charcoal",children:R}),Y&&e.jsx("p",{className:"truncate text-sm text-[#00000055]",children:Y}),i&&!x&&e.jsx("span",{className:"mt-1 rounded-full text-xs font-normal w-fit",style:{padding:"4px 8px",backgroundColor:i==="Subscribed to you"?"#DCFCE7":"#F5F5F4",color:i==="Subscribed to you"?"#008236":"#78716C",lineHeight:"133.333%",letterSpacing:"0.21px"},children:i})]})]}),x&&e.jsx("div",{className:"w-full",children:x})]}),e.jsxs("ul",{className:"flex flex-col gap-2 mt-2",children:[m&&e.jsx("li",{children:e.jsxs(ue,{onClick:k,disabled:j,"aria-busy":j,children:[j?e.jsx(w.SpinnerGapIcon,{className:"h-5 w-5 animate-spin"}):e.jsx(w.SignOutIcon,{className:"h-5 w-5"}),e.jsx("span",{children:"Delete Conversation"})]})}),e.jsx("li",{children:p?e.jsxs(ue,{onClick:A,disabled:S,"aria-busy":S,children:[S?e.jsx(w.SpinnerGapIcon,{className:"h-5 w-5 animate-spin"}):e.jsx(w.ProhibitInsetIcon,{className:"h-5 w-5"}),e.jsx("span",{children:"Unblock"})]}):e.jsxs(ue,{onClick:T,disabled:S,"aria-busy":S,children:[S?e.jsx(w.SpinnerGapIcon,{className:"h-5 w-5 animate-spin"}):e.jsx(w.ProhibitInsetIcon,{className:"h-5 w-5"}),e.jsx("span",{children:"Block"})]})}),e.jsx("li",{children:e.jsxs(ue,{variant:"danger",onClick:D,children:[e.jsx(w.FlagIcon,{className:"h-5 w-5"}),e.jsx("span",{children:"Report"})]})}),o]})]})]})})},Ts=t=>e.jsx(C.DateSeparator,{...t,position:"center"}),Oe="vote_up",Pe="vote_down";function As(t){return t!=null&&t.length?t.some(s=>s.type===Pe)?"down":t.some(s=>s.type===Oe)?"up":null:null}function zt(t){const{channel:s}=C.useChannelStateContext(),{client:n}=C.useChatContext("useMessageVote"),a=d.useMemo(()=>As(t.own_reactions),[t.own_reactions]),r=d.useCallback(async()=>{if(n!=null&&n.userID)try{a==="up"?await s.deleteReaction(t.id,Oe):await s.sendReaction(t.id,{type:Oe},{enforce_unique:!0,skip_push:!0})}catch{}},[s,n==null?void 0:n.userID,t.id,a]),i=d.useCallback(async()=>{if(n!=null&&n.userID)try{a==="down"?await s.deleteReaction(t.id,Pe):await s.sendReaction(t.id,{type:Pe},{enforce_unique:!0,skip_push:!0})}catch{}},[s,n==null?void 0:n.userID,t.id,a]);return{selected:a,voteUp:r,voteDown:i}}const Rs=d.lazy(()=>Promise.resolve().then(()=>require("./Card-b41LWND_.cjs"))),Ls=d.lazy(()=>Promise.resolve().then(()=>require("./Card-CRMpOj0f.cjs"))),Ds=d.lazy(()=>Promise.resolve().then(()=>require("./Card-vEkarkVD.cjs"))),He=()=>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}),Fs=t=>e.jsx(d.Suspense,{fallback:e.jsx(He,{}),children:e.jsx(Rs,{...t})}),Ot=t=>e.jsx(d.Suspense,{fallback:e.jsx(He,{}),children:e.jsx(Ls,{...t})}),Pt=t=>e.jsx(d.Suspense,{fallback:e.jsx(He,{}),children:e.jsx(Ds,{...t})}),zs=Ot,Os=Pt,Be={Composer:Fs,Sent:Ot,Received:Pt,Creator:zs,Visitor:Os},Ps=[[/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 Bt(t){const s=Ps.find(([n])=>n.test(t));return s?s[1]:"generic"}const Bs={video:w.VideoCameraIcon,audio:w.SpeakerHighIcon,image:w.ImageIcon,document:w.FileIcon},$s={pdf:w.FilePdfIcon,doc:w.FileDocIcon,xls:w.FileXlsIcon,csv:w.FileCsvIcon,ppt:w.FilePptIcon,zip:w.FileZipIcon,text:w.FileTextIcon,markdown:w.FileMdIcon,generic:w.FileIcon};function Vs(t){const s=te(t);return s!=="document"?Bs[s]:$s[Bt(t)]}function ie(t,s){return d.createElement(Vs(t),s)}const Us=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},Gs=({source:t,mimeType:s,poster:n,autoPlay:a=!1,playing:r,loop:i=!1,controls:l=!0,showProgress:c=!1,muted:m=!1,onContainerClick:u})=>{const f=te(s),h=d.useRef(null),x=d.useRef(null),o=d.useRef(null),g=d.useRef(r),[v,p]=d.useState(a),[N,j]=d.useState(0),[I,S]=d.useState(!1),[E,y]=d.useState(!1),[k,T]=d.useState(!1),[A,D]=d.useState(!1),[R,F]=d.useState(!0),[$,Y]=d.useState(null),H=d.useCallback(()=>{T(!1),p(!0)},[]),G=d.useCallback(b=>{const M=x.current;if(!M)return 0;const P=M.getBoundingClientRect();return Math.max(0,Math.min(1,(Us(b)-P.left)/P.width))},[]),z=d.useCallback(b=>{const M=h.current;M&&M.duration&&(M.currentTime=b*M.duration)},[]),V=b=>{b.stopPropagation(),S(!0);const M=G(b);j(M),z(M)};d.useEffect(()=>{r!==void 0&&r!==g.current&&(g.current=r,p(r))},[r]),d.useEffect(()=>{if(!v){o.current!==null&&(cancelAnimationFrame(o.current),o.current=null);return}const b=()=>{const M=h.current;M&&M.duration&&!I&&j(M.currentTime/M.duration),o.current=requestAnimationFrame(b)};return o.current=requestAnimationFrame(b),()=>{o.current!==null&&cancelAnimationFrame(o.current)}},[v,I]),d.useEffect(()=>{const b=h.current;b&&(v?b.play().catch(M=>{p(!1),T(!0)}):b.pause())},[v]),d.useEffect(()=>{if(!I)return;const b=P=>j(G(P)),M=P=>{S(!1),z(G(P))};return window.addEventListener("mousemove",b),window.addEventListener("mouseup",M),window.addEventListener("touchmove",b,{passive:!0}),window.addEventListener("touchend",M),()=>{window.removeEventListener("mousemove",b),window.removeEventListener("mouseup",M),window.removeEventListener("touchmove",b),window.removeEventListener("touchend",M)}},[I,G,z]);const U=$?{aspectRatio:String($)}:void 0,L=$?"":" aspect-video",O=Math.round(N*100);return e.jsxs("div",{role:"button",tabIndex:0,className:`relative cursor-pointer overflow-hidden bg-black ${L}`,style:U,onClick:b=>{if(u){u(b);return}k||l&&p(M=>!M)},onKeyDown:b=>{if(!(b.key!=="Enter"&&b.key!==" ")){if(b.preventDefault(),u){u(b);return}k||l&&p(M=>!M)}},children:[n&&(f==="audio"||R)&&e.jsx("img",{src:n,alt:"",className:"absolute inset-0 h-full w-full object-cover"}),!n&&(f==="audio"||R)&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:ie(s,{className:"size-12 text-black/20",weight:"regular"})}),e.jsx("div",{className:"absolute inset-0",children:f==="audio"?e.jsx("audio",{ref:h,src:t,loop:i,muted:m,style:{width:"100%",height:"100%"},onLoadStart:()=>D(!0),onCanPlay:()=>{D(!1),F(!1)},onWaiting:()=>D(!0),onPlay:()=>T(!1),onEnded:()=>{i||(p(!1),j(0))},children:e.jsx("track",{kind:"captions"})}):e.jsx("video",{ref:h,src:t,loop:i,muted:m,playsInline:!0,style:{width:"100%",height:"100%"},onLoadStart:()=>D(!0),onCanPlay:()=>{D(!1),F(!1)},onWaiting:()=>D(!0),onPlay:()=>T(!1),onLoadedMetadata:()=>{const b=h.current;b instanceof HTMLVideoElement&&b.videoWidth&&b.videoHeight&&Y(b.videoWidth/b.videoHeight)},onEnded:()=>{i||(p(!1),j(0))},children:e.jsx("track",{kind:"captions"})})}),A&&!k&&e.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center",children:e.jsx(w.CircleNotchIcon,{className:"size-8 animate-spin text-white/80",weight:"bold"})}),k&&!l&&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:b=>{b.stopPropagation(),H()},onKeyDown:b=>{b.key!=="Enter"&&b.key!==" "||(b.preventDefault(),b.stopPropagation(),H())},children:e.jsx("span",{className:"flex size-16 items-center justify-center rounded-full bg-white/20 text-white backdrop-blur-sm",children:e.jsx(w.PlayIcon,{className:"size-9 translate-x-0.5",weight:"fill"})})}),c&&!l&&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":O,"aria-valuemin":0,"aria-valuemax":100,tabIndex:0,ref:x,className:"relative flex h-4 w-full cursor-pointer items-center",onMouseDown:V,onTouchStart:V,onClick:b=>b.stopPropagation(),onKeyDown:b=>{b.key==="ArrowRight"&&z(Math.min(1,N+.05)),b.key==="ArrowLeft"&&z(Math.max(0,N-.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:`${O}%`}})})})}),l&&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:b=>{b.stopPropagation(),p(M=>!M)},className:"shrink-0 text-white","aria-label":v?"Pause":"Play",children:v?e.jsx(w.PauseIcon,{className:"size-5",weight:"fill"}):e.jsx(w.PlayIcon,{className:"size-5 translate-x-px",weight:"fill"})}),e.jsxs("div",{role:"slider","aria-label":"Playback position","aria-valuenow":O,"aria-valuemin":0,"aria-valuemax":100,tabIndex:0,ref:x,className:"relative flex h-4 w-full cursor-pointer items-center",onMouseDown:V,onTouchStart:V,onClick:b=>b.stopPropagation(),onMouseEnter:()=>y(!0),onMouseLeave:()=>y(!1),onKeyDown:b=>{b.key==="ArrowRight"&&z(Math.min(1,N+.05)),b.key==="ArrowLeft"&&z(Math.max(0,N-.05))},children:[e.jsx("div",{className:`w-full overflow-hidden rounded-full bg-white/30 transition-all duration-200 ${E||I?"h-1.5":"h-1"}`,children:e.jsx("div",{className:"h-full rounded-full bg-white",style:{width:`${O}%`}})}),e.jsx("div",{className:`absolute size-3 -translate-x-1/2 rounded-full bg-white shadow transition-[opacity,transform] duration-200 ${E||I?"scale-100 opacity-100":"scale-0 opacity-0"}`,style:{left:`${O}%`}})]})]})]})},yt=t=>t==="dark"?"size-12 text-white/20":"size-12 text-black/20",Hs=t=>t==="dark"?"aspect-video overflow-hidden bg-white/10":"aspect-video overflow-hidden bg-black/5",Ye=({mimeType:t,sourceUrl:s,thumbnailUrl:n,title:a,variant:r,mediaPlayerProps:i,containedImage:l=!1})=>{const c=te(t),[m,u]=d.useState(!1);return s&&(c==="video"||c==="audio")?e.jsx(Gs,{source:s,mimeType:t,poster:n,controls:!0,...i}):s&&c==="image"?l?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 ${m?"opacity-100":"opacity-0"}`,draggable:!1,onLoad:()=>u(!0)})}):e.jsx("img",{src:s,alt:a??"",className:"block w-full",draggable:!1}):s&&c==="document"?n?l?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 ${m?"opacity-100":"opacity-0"}`,draggable:!1,onLoad:()=>u(!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:ie(t,{className:yt(r),weight:"regular"})}):n?e.jsx("div",{className:`relative ${Hs(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:ie(t,{className:yt(r),weight:"regular"})})},$t=({variant:t,thumbnail:s,title:n,placeholderTitle:a="Attachment title",mimeType:r,detail:i,statusBadge:l,action:c,topLeft:m,topRight:u,rootRef:f,"data-testid":h})=>{const x=t==="dark",o=x?n??a:n??"",g=x&&!n;return e.jsxs("div",{ref:f,"data-testid":h,className:_("relative w-[280px] select-none overflow-hidden rounded-[24px] shadow-[0_0_0_1px_rgba(0,0,0,0.04),0_4px_8px_rgba(0,0,0,0.06)]",x?"bg-[#121110]":"bg-white"),children:[m?e.jsx("div",{className:"pointer-events-auto absolute left-3 top-3 z-50",children:m}):null,u?e.jsx("div",{className:"pointer-events-auto absolute right-3 top-3 z-50",children:u}):null,s,e.jsxs("div",{className:"px-4 pb-3 pt-3",children:[o.trim()!==""&&e.jsx("p",{className:_("mb-0.5 truncate text-base font-medium",{"text-black":!x,"text-white/30":x&&g,"text-white":x&&!g}),children:o}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[ie(r,{className:_("size-5 shrink-0",x?"text-white/55":"text-black/55"),weight:"regular"}),i!=null&&i!==""&&e.jsx("span",{className:_("text-xs font-medium",x?"text-white/55":"text-black/55"),children:i}),l]}),c]})]})};function Vt(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function qe(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 Ys(t){return t?"bg-white/10":"bg-black/5"}function qs(t){return t?"text-white":"text-black"}function Xs(t){return t?"text-white/55":"text-black/55"}function Ws(t){return t?"text-white/40":"text-black/40"}function Zs(t){return t?"text-white/20":"text-black/20"}const Xe=({attachment:t,isMyMessage:s})=>{const{title:n,text:a,image_url:r,og_scrape_url:i,title_link:l}=t,c=i??l,m=typeof c=="string"&&c.trim()!==""?c:void 0,u=e.jsxs(d.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] ${Ys(s)} flex items-center justify-center`,children:e.jsx(w.LinkIcon,{className:`size-12 ${Zs(s)}`})})}),e.jsxs("div",{className:"px-3 pb-3",children:[n&&e.jsx("p",{className:`truncate text-[14px] font-medium leading-5 ${qs(s)}`,children:n}),a&&e.jsx("p",{className:`truncate text-[12px] leading-4 ${Xs(s)}`,children:a}),m&&e.jsx("p",{className:`mt-1 truncate text-[12px] leading-4 ${Ws(s)}`,children:m})]})]});return m?e.jsx("a",{href:m,target:"_blank",rel:"noopener noreferrer",className:"block no-underline",children:u}):e.jsx("div",{className:"block",children:u})};function We(t){return t.type==="link"||!!t.og_scrape_url&&!t.asset_url}function Ee(t){var s;return(s=t.attachments)==null?void 0:s.find(We)}async function Ks(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),l=document.createElement("a");l.href=i,l.download=n,l.style.display="none",document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(i)}const Js=({url:t,filename:s})=>{const[n,a]=d.useState(!1),r=i=>{i.stopPropagation();const l=window.open("","_blank","noopener,noreferrer");a(!0),Ks(t,s).then(()=>{l==null||l.close()}).catch(()=>{l&&(l.location.href=t)}).finally(()=>a(!1))};return e.jsx("button",{type:"button",onClick:r,disabled:n,className:"mt-3 inline-flex h-10 w-full items-center justify-center gap-2 rounded-full bg-[#121110] px-4 text-sm font-medium leading-none text-white hover:bg-[#2a2928] disabled:opacity-70",children:n?e.jsx(w.CircleNotchIcon,{className:"size-4 animate-spin text-white",weight:"bold"}):e.jsxs(d.Fragment,{children:[e.jsx(w.DownloadSimpleIcon,{className:"size-4 text-white",weight:"bold"}),"Download"]})})};function Ie(t){var h,x,o,g;const s=(h=t.attachments)==null?void 0:h.find(v=>v.type==="video"&&v.asset_url),n=(x=t.attachments)==null?void 0:x.find(v=>v.type==="image"&&v.image_url),a=(o=t.attachments)==null?void 0:o.find(v=>v.type==="audio"&&v.asset_url),r=(g=t.attachments)==null?void 0:g.find(v=>v.type==="file"&&v.asset_url),i=s??n??a??r,l=(s==null?void 0:s.asset_url)??(n==null?void 0:n.image_url)??(a==null?void 0:a.asset_url)??(r==null?void 0:r.asset_url);if(!l)return null;const c=(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"),m=i==null?void 0:i.title,u=i==null?void 0:i.file_size,f=s==null?void 0:s.thumb_url;return{resolvedUrl:l,resolvedType:c,title:m,fileSize:u,thumbnailUrl:f}}const Ut=({resolvedUrl:t,resolvedType:s,title:n,fileSize:a,thumbnailUrl:r})=>{const i=a!==void 0?Vt(a):void 0;return e.jsx($t,{variant:"dark",title:n,placeholderTitle:"",mimeType:s,detail:i,thumbnail:e.jsx(Ye,{mimeType:s,sourceUrl:t,thumbnailUrl:r,title:n,variant:"dark"})})},Gt=({resolvedUrl:t,resolvedType:s,title:n,fileSize:a,thumbnailUrl:r})=>{const i=te(s),l=a!==void 0?Vt(a):void 0;return e.jsx($t,{variant:"light",title:n,mimeType:s,detail:l,thumbnail:e.jsx(Ye,{mimeType:s,sourceUrl:t,thumbnailUrl:r,title:n,variant:"light",containedImage:i==="image"||i==="document"}),action:e.jsx(Js,{url:t,filename:n})})},Qs=({message:t,isMyMessage:s=!1})=>{const n=Ee(t),a=Ie(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,children:[!s&&t.user&&e.jsx(Q,{className:"str-chat__avatar str-chat__message-sender-avatar",id:t.user.id,image:t.user.image,name:t.user.name??t.user.id}),e.jsx("div",{className:"str-chat__message-inner",style:{marginInlineEnd:0,marginInlineStart:0},children:e.jsx("div",{className:"str-chat__message-bubble-wrapper",children:e.jsx("div",{className:"str-chat__message-bubble",style:{padding:0,borderRadius:0,overflow:"visible",background:"transparent"},children:n?e.jsx("div",{className:qe(s),children:e.jsx(Xe,{attachment:n,isMyMessage:s})}):s?e.jsx(Ut,{...a}):e.jsx(Gt,{...a})})})})]})},en=({message:t})=>{const s=Ee(t);if(s)return e.jsx("div",{className:qe(!0),children:e.jsx(Xe,{attachment:s,isMyMessage:!0})});const n=Ie(t);return n?e.jsx(Ut,{...n}):null},tn=({message:t})=>{const s=Ee(t);if(s)return e.jsx("div",{className:qe(!1),children:e.jsx(Xe,{attachment:s,isMyMessage:!1})});const n=Ie(t);return n?e.jsx(Gt,{...n}):null},sn=Object.assign(Qs,{Creator:en,Visitor:tn}),nn={isUnlocking:()=>!1},an={LockedAttachment:nn},Ht=d.createContext({}),rn=Ht.Provider;function Yt(t){return d.useContext(Ht)[t]??an[t]}const qt=({selected:t,onVoteUp:s,onVoteDown:n})=>e.jsxs("div",{className:"message-vote-buttons",children:[e.jsx("button",{type:"button",className:_("message-vote-button focus-ring",{"message-vote-button--selected":t==="up"}),onClick:s,"aria-label":"Good response","aria-pressed":t==="up","data-tooltip":"Good response",children:e.jsx(w.ThumbsUpIcon,{size:16,weight:t==="up"?"fill":"regular"})}),e.jsx("button",{type:"button",className:_("message-vote-button focus-ring",{"message-vote-button--selected":t==="down"}),onClick:n,"aria-label":"Bad response","aria-pressed":t==="down","data-tooltip":"Bad response",children:e.jsx(w.ThumbsDownIcon,{size:16,weight:t==="down"?"fill":"regular"})})]}),ln=t=>{var nt,at,rt,it,lt,ot,ct,dt,ut,mt,ht,xt,ft,gt;const{additionalMessageInputProps:s,chatbotVotingEnabled:n,editing:a,endOfGroup:r,firstOfGroup:i,groupedByUser:l,handleAction:c,handleOpenThread:m,handleRetry:u,highlighted:f,isMessageAIGenerated:h,isMyMessage:x,message:o,renderText:g,threadList:v,viewerLanguage:p}=t,{client:N}=C.useChatContext("CustomMessage"),{channel:j}=C.useChannelStateContext("CustomMessage"),{isUnlocking:I,onUnlockClick:S,onFetchSource:E,onDownloadClick:y}=Yt("LockedAttachment"),[k,T]=d.useState(!1),A=C.useMessageReminder(o.id),{selected:D,voteUp:R,voteDown:F}=zt(o),{Attachment:$=C.Attachment,EditMessageModal:Y=C.EditMessageModal,MessageBlocked:H=C.MessageBlocked,MessageBouncePrompt:G=C.MessageBouncePrompt,MessageDeleted:z=C.MessageDeleted,MessageIsThreadReplyInChannelButtonIndicator:V=C.MessageIsThreadReplyInChannelButtonIndicator,MessageRepliesCountButton:U=C.MessageRepliesCountButton,ReminderNotification:L=C.ReminderNotification,StreamedMessageText:O=C.StreamedMessageText,PinIndicator:b}=C.useComponentContext("CustomMessage"),M=C.messageHasAttachments(o),P=C.messageHasReactions(o),q=d.useMemo(()=>h==null?void 0:h(o),[h,o]),X=d.useMemo(()=>{const ce=o.attachments??[],je=o.shared_location?[o.shared_location,...ce]:ce;if(!Ce(o))return je;const bt=je.filter(pt=>!("type"in pt)||!We(pt));return bt.length===je.length?je:bt},[o]),K=d.useMemo(()=>{const ce=Ue({message:o,viewerLanguage:p});return ce===o.text?o:{...o,text:ce}},[o,p]);if(C.isDateSeparatorMessage(o))return null;if(o.deleted_at||o.type==="deleted")return e.jsx(z,{message:o});if(C.isMessageBlocked(o))return e.jsx(H,{});const be=!v&&!!o.reply_count,pe=!v&&o.show_in_channel&&o.parent_id,ae=o.status==="failed"&&((nt=o.error)==null?void 0:nt.status)!==403,J=C.isMessageBounced(o);let se;ae?se=()=>u(o):J&&(se=()=>T(!0));const re=x(),Ae=_("str-chat__message str-chat__message-simple",`str-chat__message--${o.type}`,`str-chat__message--${o.status}`,re?"str-chat__message--me str-chat__message-simple--me":"str-chat__message--other",o.text?"str-chat__message--has-text":"has-no-text",{"str-chat__message--has-attachment":M,"str-chat__message--highlighted":f,"str-chat__message--pinned pinned-message":o.pinned,"str-chat__message--with-reactions":P,"str-chat__message-send-can-be-retried":(o==null?void 0:o.status)==="failed"&&((at=o==null?void 0:o.error)==null?void 0:at.status)!==403,"str-chat__message-with-thread-link":be||pe,"str-chat__virtual-message__wrapper--end":r,"str-chat__virtual-message__wrapper--first":i,"str-chat__virtual-message__wrapper--group":l}),ve=o.poll_id&&N.polls.fromState(o.poll_id),le=ks(o),B=Ce(o),W=_s(o),Z=!!(X!=null&&X.length&&!o.quoted_message),ne=B&&re&&Z;return e.jsxs(e.Fragment,{children:[a&&e.jsx(Y,{additionalMessageInputProps:s}),k&&e.jsx(C.MessageBounceModal,{MessageBouncePrompt:G,onClose:()=>T(!1),open:k}),e.jsxs("div",{className:Ae,children:[b&&e.jsx(b,{}),!!A&&e.jsx(L,{reminder:A}),o.user&&e.jsx(Q,{className:"str-chat__avatar str-chat__message-sender-avatar",id:o.user.id,image:o.user.image,name:o.user.name||o.user.id,size:B?24:28,shape:"circle",dmAgentEnabled:B}),e.jsx("div",{className:_("str-chat__message-inner",{"str-chat__simple-message--error-failed":ae||J}),"data-testid":"message-inner",onClick:se,onKeyDown:se,role:se?"button":void 0,tabIndex:se?0:void 0,style:{marginInlineEnd:0,marginInlineStart:0},children:W?e.jsxs("div",{className:"str-chat__message-bubble-wrapper",children:[re?e.jsx(Be.Sent,{title:(rt=o.metadata)==null?void 0:rt.attachment_title,mimeType:(it=o.metadata)==null?void 0:it.attachment_mime_type,thumbnailUrl:(lt=o.metadata)==null?void 0:lt.attachment_thumbnail,amountText:(ot=o.metadata)==null?void 0:ot.amount_text,detail:(ct=o.metadata)==null?void 0:ct.attachment_detail,paymentStatus:(dt=o.metadata)==null?void 0:dt.payment_status,onPreviewClick:()=>S==null?void 0:S(o,j),onFetchSource:async()=>await(E==null?void 0:E(o,j))}):e.jsx(Be.Received,{title:(ut=o.metadata)==null?void 0:ut.attachment_title,mimeType:(mt=o.metadata)==null?void 0:mt.attachment_mime_type,thumbnailUrl:(ht=o.metadata)==null?void 0:ht.attachment_thumbnail,amountText:(xt=o.metadata)==null?void 0:xt.amount_text,detail:(ft=o.metadata)==null?void 0:ft.attachment_detail,paymentStatus:(gt=o.metadata)==null?void 0:gt.payment_status,isUnlocking:I(o.id),onUnlockClick:()=>S==null?void 0:S(o,j),onFetchSource:async()=>await(E==null?void 0:E(o,j)),onDownloadClick:()=>y==null?void 0:y(o,j)}),o.text&&e.jsx("div",{className:"str-chat__message-bubble",children:e.jsx(C.MessageText,{message:K,renderText:g})})]}):le?e.jsx(Re,{message:o,standalone:!0}):e.jsxs("div",{className:"str-chat__message-bubble-wrapper",children:[e.jsxs("div",{className:"str-chat__message-bubble",children:[B&&!ne&&e.jsx(Re,{message:o,hasAttachment:Z,isMyMessage:re}),ve&&e.jsx(C.Poll,{poll:ve}),X!=null&&X.length&&!o.quoted_message?e.jsx($,{actionHandler:c,attachments:X}):null,q?e.jsx(O,{message:K,renderText:g}):e.jsx(C.MessageText,{message:K,renderText:g}),e.jsx(C.MessageErrorIcon,{})]}),(!B||ne)&&e.jsx(Re,{message:o,hasAttachment:Z,isMyMessage:re}),n&&B&&e.jsx(qt,{selected:D,onVoteUp:R,onVoteDown:F})]})}),be&&e.jsx(U,{onClick:m,reply_count:o.reply_count}),pe&&e.jsx(V,{})]},o.id)]})},on=d.memo(ln,(t,s)=>t.chatbotVotingEnabled!==s.chatbotVotingEnabled||t.viewerLanguage!==s.viewerLanguage?!1:C.areMessageUIPropsEqual(t,s)),cn=t=>{const s=C.useMessageContext("CustomMessage");return e.jsx(on,{...s,...t})},dn=t=>({linkPreviews:Array.from(t.previews.values()).filter(s=>vt.LinkPreviewsManager.previewIsLoaded(s)||vt.LinkPreviewsManager.previewIsLoading(s))}),un=({link:t,onDismiss:s})=>{const{og_scrape_url:n,title:a,image_url:r}=t,i=l=>{l.preventDefault(),s(n)};return e.jsxs("a",{href:n,target:"_blank",rel:"noopener noreferrer",className:"relative w-full block rounded-[24px] bg-[#121110] p-2 no-underline transition-opacity hover:opacity-90",children:[r&&e.jsx("img",{src:r,alt:a||"",className:"h-[148px] w-full rounded-[20px] object-cover"}),e.jsx("button",{type:"button",onClick:i,className:"absolute right-4 top-4 flex size-6 items-center justify-center rounded-full border border-white/40 bg-white/70 backdrop-blur-2xl focus-ring","aria-label":"Close link preview",children:e.jsx(w.XIcon,{className:"size-4 text-black/90"})}),e.jsxs("div",{className:"p-2",children:[a&&e.jsx("div",{className:"text-[14px] font-medium leading-5 text-white",children:a}),e.jsx("div",{className:"text-[12px] leading-4 text-white/55",children:n})]})]})},mn=()=>{const{linkPreviewsManager:t}=C.useMessageComposer(),{linkPreviews:s}=C.useStateStore(t.state,dn),n=r=>{t.dismissPreview(r)};return s.length>0?e.jsx("div",{className:"flex flex-col items-center w-full gap-2 mb-4",children:s.map(r=>e.jsx(un,{link:r,onDismiss:n},r.og_scrape_url))}):null},hn=({sendMessage:t,disabled:s,...n})=>e.jsx("button",{...n,type:"button","aria-label":"Send",disabled:s,onClick:t,children:e.jsx(w.ArrowUpIcon,{weight:"bold",className:"size-4"})}),xn=()=>{var c;const{channel:t}=C.useChannelStateContext(),s=((c=t==null?void 0:t.data)==null?void 0:c.frozen)===!0,{handleSubmit:n}=C.useMessageInputContext(),{SendButton:a}=C.useComponentContext("CustomMessageInput"),r=a??hn,i=C.useMessageComposerHasSendableData(),l=s||!i;return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"left-container",children:e.jsx(C.SimpleAttachmentSelector,{})}),e.jsxs("div",{className:"central-container min-w-0 w-full p-2 bg-white rounded-[1.5rem] shadow-[0_4px_16px_0_rgba(0,0,0,0.08),0_1px_2px_0_rgba(0,0,0,0.04),0_0_0_1px_rgba(0,0,0,0.04)]",children:[e.jsx(C.QuotedMessagePreview,{}),e.jsx(mn,{}),e.jsx(C.AttachmentPreviewList,{}),e.jsxs("div",{className:"flex",children:[e.jsx("div",{className:"w-full ml-2 mr-4 self-center leading-[0]",children:e.jsx(C.TextareaComposer,{"aria-disabled":s||void 0,className:"w-full resize-none outline-none leading-6",autoFocus:!s,maxRows:4,readOnly:s,tabIndex:s?-1:void 0})}),e.jsx(r,{sendMessage:n,"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:l,type:"button"})]})]})]})},fn=({renderActions:t})=>{var a;const{channel:s}=C.useChannelStateContext(),n=((a=s==null?void 0:s.data)==null?void 0:a.frozen)===!0;return e.jsxs("div",{inert:n?"":void 0,"aria-disabled":n||void 0,className:"message-input flex items-center gap-2 p-4 aria-disabled:opacity-40",children:[t==null?void 0:t(),e.jsx(C.MessageInput,{Input:xn})]})},gn=["SYSTEM_DM_AGENT_PAUSED","SYSTEM_DM_AGENT_RESUMED"],bn={SYSTEM_DM_AGENT_PAUSED:"DM Agent has left the conversation",SYSTEM_DM_AGENT_RESUMED:"DM Agent has rejoined the conversation"},pn=["SYSTEM_AGE_SAFETY_BLOCKED"],vn={SYSTEM_AGE_SAFETY_BLOCKED:"This user isn’t able to reply because they don’t meet our age safety guidelines."},Le="age safety guidelines.",jn="https://linktr.ee/s/about/contact",Ct=t=>gn.includes(t),wn=t=>pn.includes(t),yn=t=>{var a;const s=(a=t.metadata)==null?void 0:a.custom_type;if(Ct(s))return{kind:"dm-agent",type:s};if(wn(s))return{kind:"age-safety",type:s};const n=t.dm_agent_system_type;if(Ct(n))return{kind:"dm-agent",type:n}},Cn=t=>{const s=t.indexOf(Le);if(s===-1)return t;const n=s+Le.length;return e.jsxs(e.Fragment,{children:[t.slice(0,s),e.jsx("a",{href:jn,target:"_blank",rel:"noopener noreferrer",className:"mes-age-safety-system-message__emphasis font-medium text-inherit underline",children:Le}),t.slice(n)]})},Nn=t=>{var a,r;const s=t.message.hide_date===!0,n=yn(t.message);if((n==null?void 0:n.kind)==="dm-agent"){const i=((a=t.message.text)==null?void 0:a.trim())||bn[n.type];return e.jsxs("div",{className:"str-chat__message--system","data-testid":"message-system",children:[e.jsxs("div",{className:"mes-dm-agent-system-message mx-auto mb-2 inline-flex w-fit max-w-[min(100%,480px)] items-center justify-center gap-[10px] rounded-[12px] border border-[rgba(0,0,0,0.08)] p-3 text-[rgba(0,0,0,0.55)]","data-testid":"dm-agent-system-message","data-dm-agent-system-type":n.type,children:[e.jsx(w.SparkleIcon,{size:16,weight:"regular","aria-hidden":!0,className:"mes-dm-agent-system-message__sparkle shrink-0"}),e.jsx("p",{className:"mes-dm-agent-system-message__text m-0 text-center text-[14px] font-normal leading-5 tracking-[0.21px]",children:i})]}),!s&&e.jsx(C.MessageTimestamp,{message:t.message})]})}if((n==null?void 0:n.kind)==="age-safety"){const i=((r=t.message.text)==null?void 0:r.trim())||vn[n.type];return e.jsxs("div",{className:"str-chat__message--system","data-testid":"message-system",children:[e.jsxs("div",{className:"mes-age-safety-system-message box-border mx-auto mb-2 flex w-full max-w-[329px] items-start justify-center gap-3 rounded-[12px] border border-[var(--border-secondary,rgba(0,0,0,0.08))] bg-[var(--bg-warning-subtle,#fef3c6)] px-2 py-4 pl-5 text-[color:var(--text-warning-on-warning,#894b00)]","data-testid":"age-safety-system-message","data-age-safety-system-type":n.type,children:[e.jsx(w.ProhibitIcon,{size:24,weight:"duotone","aria-hidden":!0,className:"mes-age-safety-system-message__icon shrink-0 text-[color:var(--text-warning-on-warning,#894b00)]","data-testid":"age-safety-system-message-icon"}),e.jsx("div",{className:"mes-age-safety-system-message__content min-w-0 flex-[1_0_0]",children:e.jsx("p",{className:"m-0 text-balance text-left text-[12px] font-normal leading-4 tracking-[0.21px] text-[color:var(--text-warning-on-warning,#894b00)]",children:Cn(i)})})]}),!s&&e.jsx(C.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(C.MessageTimestamp,{message:t.message})]})},Xt=d.createContext(!1),De=({cx:t,index:s})=>e.jsx("circle",{cx:t,cy:"4",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"})}),_n=new Set([C.AIStates.Thinking,C.AIStates.Generating,C.AIStates.ExternalSources]),kn=({threadList:t})=>{var g,v;const{channel:s,channelConfig:n,thread:a}=C.useChannelStateContext(),{client:r}=C.useChatContext(),{typing:i={}}=C.useTypingContext(),{aiState:l}=C.useAIState(s),c=d.useContext(Xt);if(!t&&c&&_n.has(l)){const p=Sn(s,(g=r.user)==null?void 0:g.id);return e.jsx(Nt,{avatarId:(p==null?void 0:p.id)??"ai-agent",avatarName:(p==null?void 0:p.name)??(p==null?void 0:p.id)??"Agent",avatarImage:p==null?void 0:p.image,testId:"typing-indicator-ai"})}if((n==null?void 0:n.typing_events)===!1)return null;const u=t?[]:Object.values(i).filter(({parent_id:p,user:N})=>{var j;return(N==null?void 0:N.id)!==((j=r.user)==null?void 0:j.id)&&!p}),f=t?Object.values(i).filter(({parent_id:p,user:N})=>{var j;return(N==null?void 0:N.id)!==((j=r.user)==null?void 0:j.id)&&p===(a==null?void 0:a.id)}):[],h=t?f:u;if(!h.length)return null;const x=(v=h[0])==null?void 0:v.user,o=x!=null&&x.id&&s.state.members[x.id]?s.state.members[x.id].user:void 0;return e.jsx(Nt,{avatarId:(x==null?void 0:x.id)??(o==null?void 0:o.id)??"typing-user",avatarName:(x==null?void 0:x.name)??(o==null?void 0:o.name)??(x==null?void 0:x.id)??"Typing user",avatarImage:(x==null?void 0:x.image)??(o==null?void 0:o.image),testId:"typing-indicator"})},Nt=({avatarId:t,avatarName:s,avatarImage:n,testId:a})=>e.jsxs("div",{className:"str-chat__typing-indicator !items-end !bg-transparent","data-testid":a,style:{insetInlineStart:0,insetInlineEnd:"auto"},children:[e.jsx("div",{className:"shrink-0","aria-hidden":"true",children:e.jsx(Q,{id:t,name:s,image:n??void 0,size:24,shape:"circle"})}),e.jsx("div",{className:"px-4 py-3 rounded-lg bg-[#E9EAED] h-12 flex flex-col justify-end",children:e.jsxs("svg",{"aria-hidden":"true",className:"block overflow-visible mb-[0.2rem]",viewBox:"0 0 32 8",width:"32",height:"8",overflow:"visible",children:[e.jsx(De,{cx:"4",index:0}),e.jsx(De,{cx:"16",index:1}),e.jsx(De,{cx:"28",index:2})]})})]});function Sn(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 Wt=()=>null,En=({className:t,message:s})=>e.jsxs("div",{className:_("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})]}),Ne=d.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(En,{className:"w-6 h-6"}),e.jsx("span",{className:"text-sm text-stone",children:"Loading messages"})]})}));Ne.displayName="LoadingState";const oe="size-10 rounded-full bg-[#F1F0EE] hover:bg-[#E5E4E1] flex items-center justify-center transition-colors duration-150 focus-ring",_t="Replies instantly with AI assistant",In=({onBack:t,showBackButton:s,onShowInfo:n,canShowInfo:a,showStarButton:r=!1,dmAgentEnabled:i=!1,getParticipantDisplayName:l})=>{var o,g,v,p,N;const{channel:c}=C.useChannelStateContext(),m=d.useMemo(()=>{var S,E;const j=(S=c._client)==null?void 0:S.userID;return j?Object.values(((E=c.state)==null?void 0:E.members)||{}).find(y=>{var k;return((k=y.user)==null?void 0:k.id)&&y.user.id!==j}):void 0},[(o=c._client)==null?void 0:o.userID,(g=c.state)==null?void 0:g.members]),u=l(m),f=(v=m==null?void 0:m.user)==null?void 0:v.image,h=Tt(c),x=async()=>{try{h?await c.unpin():await c.pin()}catch(j){console.error("[CustomChannelHeader] Failed to update pinned status:",j)}};return e.jsxs("div",{className:"@container",children:[e.jsxs("div",{className:"grid grid-cols-[1fr_auto_1fr] w-full items-center @lg:hidden",children:[e.jsx("div",{className:"flex items-center gap-2",children:s&&e.jsx("button",{className:oe,onClick:t||(()=>{}),type:"button","aria-label":"Back to conversations",children:e.jsx(w.ArrowLeftIcon,{className:"size-5 text-black/90"})})}),e.jsxs("div",{className:"flex flex-col gap-1 items-center",children:[e.jsx(Q,{id:((p=m==null?void 0:m.user)==null?void 0:p.id)||c.id||"unknown",name:u,image:f,starred:r&&h,dmAgentEnabled:i,size:40}),e.jsxs("button",{type:"button",onClick:n,className:"flex items-center gap-0.5 rounded-full bg-black/[0.05] px-3 py-1 text-xs font-medium text-black/90 hover:bg-black/[0.08] transition-colors","aria-label":`View info for ${u}`,children:[u,e.jsx(w.CaretRightIcon,{className:"size-3 shrink-0"})]}),i&&e.jsxs("div",{className:"flex items-center gap-1 text-[10px] leading-3 text-black/55",children:[e.jsx(w.SparkleIcon,{className:"size-3 shrink-0 text-black/55"}),e.jsx("span",{children:_t})]})]}),e.jsxs("div",{className:"flex justify-end items-center gap-2",children:[r&&e.jsx("button",{className:oe,onClick:x,type:"button","aria-label":h?"Unstar conversation":"Star conversation",children:e.jsx(w.StarIcon,{className:_("size-5",{"text-yellow-600":h,"text-black/90":!h}),weight:h?"duotone":"regular"})}),e.jsx("button",{className:oe,onClick:n,type:"button","aria-label":"Show info",children:e.jsx(w.DotsThreeIcon,{className:"size-5 text-black/90"})})]})]}),e.jsxs("div",{className:"hidden @lg:flex items-center justify-between gap-3 min-h-12",children:[e.jsxs("div",{className:"flex items-center gap-4 min-w-0",children:[s&&t&&e.jsx("button",{type:"button",onClick:t,className:oe,"aria-label":"Back to conversations",children:e.jsx(w.ArrowLeftIcon,{className:"size-5 text-black/90"})}),e.jsx(Q,{id:((N=m==null?void 0:m.user)==null?void 0:N.id)||c.id||"unknown",name:u,image:f,starred:r&&h,dmAgentEnabled:i,size:40}),e.jsxs("div",{className:"min-w-0",children:[a?e.jsxs("button",{type:"button",onClick:n,className:"flex items-center gap-1 font-medium text-black/90 truncate hover:text-black/70 transition-colors","aria-label":`View info for ${u}`,children:[e.jsx("span",{className:"truncate",children:u}),e.jsx(w.CaretRightIcon,{className:"size-4 shrink-0"})]}):e.jsx("h1",{className:"font-medium text-black/90 truncate",children:u}),i&&e.jsxs("div",{className:"mt-0.5 flex items-center gap-1 text-[10px] leading-3 text-black/55",children:[e.jsx(w.SparkleIcon,{className:"size-3 shrink-0 text-black/55"}),e.jsx("span",{className:"truncate",children:_t})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[r&&e.jsx("button",{className:oe,onClick:x,type:"button","aria-label":h?"Unstar conversation":"Star conversation",children:e.jsx(w.StarIcon,{className:_("size-5",{"text-yellow-600":h,"text-black/90":!h}),weight:h?"duotone":"regular"})}),a&&n&&e.jsx("button",{className:oe,onClick:n,type:"button","aria-label":"Show info",children:e.jsx(w.DotsThreeIcon,{className:"size-5 text-black/90"})})]})]})]})},Mn=({onBack:t,showBackButton:s,renderMessageInputActions:n,renderConversationFooter:a,onLeaveConversation:r,onBlockParticipant:i,showDeleteConversation:l=!0,onDeleteConversationClick:c,onBlockParticipantClick:m,onReportParticipantClick:u,showStarButton:f=!1,chatbotVotingEnabled:h=!1,renderChannelBanner:x,customProfileContent:o,customChannelActions:g,renderMessage:v,dmAgentEnabled:p=!1,viewerLanguage:N,getParticipantDisplayName:j})=>{var Y,H,G,z,V,U;const{channel:I}=C.useChannelStateContext(),S=d.useRef(null),E=d.useMemo(()=>{var b,M;const L=(b=I._client)==null?void 0:b.userID;return L?Object.values(((M=I.state)==null?void 0:M.members)||{}).find(P=>{var q;return((q=P.user)==null?void 0:q.id)&&P.user.id!==L}):void 0},[(Y=I._client)==null?void 0:Y.userID,(H=I.state)==null?void 0:H.members]),y=d.useMemo(()=>{var b,M;const L=(b=I._client)==null?void 0:b.userID;return L?Object.values(((M=I.state)==null?void 0:M.members)||{}).find(P=>{var q;return((q=P.user)==null?void 0:q.id)===L}):void 0},[(G=I._client)==null?void 0:G.userID,(z=I.state)==null?void 0:z.members]),k=((V=y==null?void 0:y.user)==null?void 0:V.is_account)??(y==null?void 0:y.is_account),T=((U=E==null?void 0:E.user)==null?void 0:U.is_account)??(E==null?void 0:E.is_account),A=p&&k===!1&&T===!0,D=d.useMemo(()=>{const L=I.data??{};if(L.followerStatus)return String(L.followerStatus);if(L.isFollower!==void 0)return L.isFollower?"Subscribed to you":"Not subscribed"},[I.data]),R=d.useCallback(()=>{var L;(L=S.current)==null||L.showModal()},[]),F=d.useCallback(()=>{var L;(L=S.current)==null||L.close()},[]),$=d.useCallback(L=>{const{message:O}=C.useMessageContext("ChannelView"),b=e.jsx(cn,{...L,chatbotVotingEnabled:h,viewerLanguage:N});return!v||!O?b:v(b,O)},[h,v,N]);return e.jsxs(e.Fragment,{children:[e.jsx(C.WithComponents,{overrides:{Message:$},children:e.jsxs(C.Window,{children:[e.jsx("div",{className:"p-4",children:e.jsx(In,{onBack:t,showBackButton:s,onShowInfo:R,canShowInfo:!!E,showStarButton:f,dmAgentEnabled:A,getParticipantDisplayName:j})},"lt-channel-header"),x?e.jsx(d.Fragment,{children:x()},"lt-channel-banner"):null,e.jsx("div",{className:"flex-1 overflow-hidden relative",children:e.jsx(C.MessageList,{hideDeletedMessages:!0,hideNewMessageSeparator:!1,messageActions:void 0})},"lt-channel-message-list"),a?e.jsx(d.Fragment,{children:a(I)},"lt-channel-conversation-footer"):null,e.jsx(fn,{renderActions:()=>n==null?void 0:n(I)},"lt-channel-message-input")]})}),e.jsx(Ms,{dialogRef:S,onClose:F,participant:E,participantDisplayName:j(E),channel:I,followerStatusLabel:D,onLeaveConversation:r,onBlockParticipant:i,showDeleteConversation:l,onDeleteConversationClick:c,onBlockParticipantClick:m,onReportParticipantClick:u,customProfileContent:o,customChannelActions:g})]})},Ze=d.memo(({channel:t,onBack:s,showBackButton:n=!1,renderMessageInputActions:a,renderConversationFooter:r,onLeaveConversation:i,onBlockParticipant:l,className:c,CustomChannelEmptyState:m=Wt,showDeleteConversation:u=!0,onDeleteConversationClick:f,onBlockParticipantClick:h,onReportParticipantClick:x,dmAgentEnabled:o,messageMetadata:g,onMessageSent:v,showStarButton:p=!1,chatbotVotingEnabled:N=!1,renderChannelBanner:j,customProfileContent:I,customChannelActions:S,renderMessage:E,sendButton:y,viewerLanguage:k,getParticipantDisplayName:T})=>{const A=d.useCallback(R=>(T==null?void 0:T(R))??Se(R==null?void 0:R.user),[T]),D=d.useCallback(async(R,F,$)=>{var U;const Y=((U=t.data)==null?void 0:U.chatbot_paused)===!0,H=o&&!Y,G={...F,...H&&{silent:!0},...g&&{metadata:{...F.metadata??{},...g}}},z={...$,...H&&{skip_push:!0}},V=await t.sendMessage(G,z);return v==null||v(V),V},[t,o,g,v]);return e.jsx("div",{className:_("messaging-channel-view h-full flex flex-col",c),children:e.jsx(Xt.Provider,{value:o??!1,children:e.jsx(C.Channel,{channel:t,MessageSystem:Nn,EmptyStateIndicator:m,LoadingIndicator:Ne,DateSeparator:Ts,TypingIndicator:kn,doSendMessageRequest:D,...y?{SendButton:y}:{},children:e.jsx(Mn,{onBack:s,showBackButton:n,renderMessageInputActions:a,renderConversationFooter:r,onLeaveConversation:i,onBlockParticipant:l,CustomChannelEmptyState:m,showDeleteConversation:u,onDeleteConversationClick:f,onBlockParticipantClick:h,onReportParticipantClick:x,showStarButton:p,dmAgentEnabled:o,chatbotVotingEnabled:N,renderChannelBanner:j,customProfileContent:I,customChannelActions:S,renderMessage:E,viewerLanguage:k,getParticipantDisplayName:A})})})})});Ze.displayName="ChannelView";const Tn=({className:t})=>e.jsxs("svg",{width:"140",height:"120",viewBox:"44 -2 144 126",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:t,children:[e.jsxs("g",{clipPath:"url(#clip0_empty_state)",children:[e.jsx("path",{d:"M123.68 82.1932C123.383 103.675 105.839 121 84.2417 121C77.4724 121 71.0986 119.297 65.5327 116.299L52.5873 119.687L53.8036 106.673C48.1776 99.8701 44.7994 91.1453 44.7994 81.6356C44.7994 59.8965 62.4554 42.2754 84.2374 42.2754C89.1328 42.2754 93.8175 43.1633 98.1413 44.789",fill:"#D7D4CE"}),e.jsx("path",{d:"M84.2458 86.0364C82.2851 86.0364 80.6957 84.4501 80.6957 82.4933C80.6957 80.5365 82.2851 78.9502 84.2458 78.9502C86.2065 78.9502 87.7959 80.5365 87.7959 82.4933C87.7959 84.4501 86.2065 86.0364 84.2458 86.0364Z",fill:"white"}),e.jsx("path",{d:"M68.3044 86.0364C66.3437 86.0364 64.7543 84.4501 64.7543 82.4933C64.7543 80.5365 66.3437 78.9502 68.3044 78.9502C70.2651 78.9502 71.8545 80.5365 71.8545 82.4933C71.8545 84.4501 70.2651 86.0364 68.3044 86.0364Z",fill:"white"}),e.jsx("path",{d:"M100.183 86.0364C98.2226 86.0364 96.6332 84.4501 96.6332 82.4933C96.6332 80.5365 98.2226 78.9502 100.183 78.9502C102.144 78.9502 103.733 80.5365 103.733 82.4933C103.733 84.4501 102.144 86.0364 100.183 86.0364Z",fill:"white"}),e.jsxs("g",{filter:"url(#filter0_empty_state)",children:[e.jsx("path",{d:"M171.522 68.7154C177.443 61.4539 181 52.1488 181 42C181 18.8027 162.421 0 139.5 0C116.579 0 98 18.8027 98 42C98 65.1973 116.579 84 139.5 84C146.622 84 153.328 82.1857 159.184 78.9829L172.801 82.5993L171.522 68.7154Z",fill:"white"}),e.jsx("path",{d:"M171.522 68.7154C177.443 61.4539 181 52.1488 181 42C181 18.8027 162.421 0 139.5 0C116.579 0 98 18.8027 98 42C98 65.1973 116.579 84 139.5 84C146.622 84 153.328 82.1857 159.184 78.9829L172.801 82.5993L171.522 68.7154Z",stroke:"#D7D4CE",strokeWidth:"2",strokeMiterlimit:"10"})]}),e.jsx("path",{d:"M139.502 45.5431C137.541 45.5431 135.952 43.9568 135.952 42C135.952 40.0432 137.541 38.4569 139.502 38.4569C141.462 38.4569 143.052 40.0432 143.052 42C143.052 43.9568 141.462 45.5431 139.502 45.5431Z",fill:"#D7D4CE"}),e.jsx("path",{d:"M123.561 45.5431C121.601 45.5431 120.011 43.9568 120.011 42C120.011 40.0432 121.601 38.4569 123.561 38.4569C125.522 38.4569 127.111 40.0432 127.111 42C127.111 43.9568 125.522 45.5431 123.561 45.5431Z",fill:"#D7D4CE"}),e.jsx("path",{d:"M155.439 45.5431C153.478 45.5431 151.889 43.9568 151.889 42C151.889 40.0432 153.478 38.4569 155.439 38.4569C157.4 38.4569 158.989 40.0432 158.989 42C158.989 43.9568 157.4 45.5431 155.439 45.5431Z",fill:"#D7D4CE"})]}),e.jsxs("defs",{children:[e.jsxs("filter",{id:"filter0_empty_state",x:"97",y:"-1",width:"89",height:"90",filterUnits:"userSpaceOnUse",colorInterpolationFilters:"sRGB",children:[e.jsx("feFlood",{floodOpacity:"0",result:"BackgroundImageFix"}),e.jsx("feColorMatrix",{in:"SourceAlpha",type:"matrix",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0",result:"hardAlpha"}),e.jsx("feOffset",{dx:"4",dy:"4"}),e.jsx("feComposite",{in2:"hardAlpha",operator:"out"}),e.jsx("feColorMatrix",{type:"matrix",values:"0 0 0 0 0.8428 0 0 0 0 0.830064 0 0 0 0 0.8095 0 0 0 1 0"}),e.jsx("feBlend",{mode:"normal",in2:"BackgroundImageFix",result:"effect1_dropShadow"}),e.jsx("feBlend",{mode:"normal",in:"SourceGraphic",in2:"effect1_dropShadow",result:"shape"})]}),e.jsx("clipPath",{id:"clip0_empty_state",children:e.jsx("rect",{width:"233",height:"233",fill:"white"})})]})]}),Zt=d.memo(({hasChannels:t,channelsLoaded:s})=>e.jsx("div",{className:"messaging-empty-state flex items-center justify-center h-full p-8 text-balance",children:e.jsxs("div",{className:"flex flex-col items-center max-w-sm text-center",children:[e.jsx(Tn,{}),s&&!t&&e.jsxs("div",{className:"mt-8",children:[e.jsx("h2",{className:"font-medium text-black text-[18px] mb-2",children:"Your inbox is empty"}),e.jsx("p",{className:"text-[#676B5F] text-sm mb-6",children:"Share with your followers to start receiving messages"})]})]})}));Zt.displayName="EmptyState";const ye=d.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"})]})}));ye.displayName="ErrorState";const An=({capabilities:t={},className:s,renderMessageInputActions:n,renderConversationFooter:a,onChannelSelect:r,initialParticipantFilter:i,initialParticipantData:l,CustomChannelEmptyState:c,showChannelList:m=!0,filters:u,channelRenderFilterFn:f,channelListCustomEmptyStateIndicator:h,onDeleteConversationClick:x,onBlockParticipantClick:o,onReportParticipantClick:g,dmAgentEnabled:v,messageMetadata:p,onMessageSent:N,showStarButton:j=!1,chatbotVotingEnabled:I=!1,viewerLanguage:S,renderMessagePreview:E,renderChannelBanner:y,customProfileContent:k,customChannelActions:T,renderMessage:A,sendButton:D})=>{const{service:R,client:F,isConnected:$,isLoading:Y,error:H,refreshConnection:G,debug:z}=It(),[V,U]=d.useState(null),[L,O]=d.useState(!1),[b,M]=d.useState(!1),[P,q]=d.useState(!1),[X,K]=d.useState(null),{showDeleteConversation:be=!0}=t,pe=d.useMemo(()=>{const B=F==null?void 0:F.userID;return{...{type:"messaging",last_message_at:{$exists:!0},...B&&{members:{$in:[B]},hidden:!1}},...u}},[u,F==null?void 0:F.userID]),ae=d.useRef(null),J=d.useCallback(async()=>{if(!F||!$)return;const B=F.userID;if(B)try{z&&console.log("[MessagingShell] Syncing channels for user:",B);const W=await F.queryChannels({type:"messaging",members:{$in:[B]}},{},{limit:100});O(W.length>0),M(!0),ae.current=B,z&&console.log("[MessagingShell] Channels synced successfully:",{channelCount:W.length})}catch(W){console.error("[MessagingShell] Failed to sync channels:",W)}},[F,$,z]);d.useEffect(()=>{if(!F||!$)return;const B=F.userID;B&&ae.current!==B&&J()},[F,$,J]),d.useEffect(()=>{if(!i||!F||!$)return;(async()=>{const W=F.userID;if(W)try{z&&console.log("[MessagingShell] Loading initial conversation with:",i);const Z=await F.queryChannels({type:"messaging",members:{$eq:[W,i]}},{},{limit:1});if(Z.length>0)U(Z[0]),q(!0),K(null),r&&r(Z[0]),z&&console.log("[MessagingShell] Initial conversation loaded:",Z[0].id);else if(l&&R){z&&console.log("[MessagingShell] No conversation found, creating one for:",l);try{const ne=await R.startChannelWithParticipant({id:l.id,name:l.name,phone:l.phone});U(ne),q(!0),K(null),r&&r(ne),z&&console.log("[MessagingShell] Channel created and loaded:",ne.id)}catch(ne){console.error("[MessagingShell] Failed to create conversation:",ne),K("Failed to create conversation")}}else K("No conversation found with this account"),z&&console.log("[MessagingShell] No conversation found for:",i)}catch(Z){console.error("[MessagingShell] Failed to load initial conversation:",Z),K("Failed to load conversation")}})()},[i,l,F,$,R,z,r]);const se=d.useCallback(B=>{U(B),r==null||r(B)},[r]),re=d.useCallback(()=>{P||U(null)},[P]),Ae=d.useCallback(async B=>{z&&console.log("[MessagingShell] Leaving conversation:",B.id),U(null),q(!1),ae.current=null,await J()},[J,z]),ve=d.useCallback(async B=>{z&&console.log("[MessagingShell] Blocking participant:",B),U(null),q(!1),ae.current=null,await J()},[J,z]),le=!!V;return Y?e.jsx("div",{className:_("h-full",s),children:e.jsx(Ne,{})}):H?e.jsx("div",{className:_("h-full",s),children:e.jsx(ye,{message:H,onBack:G})}):!$||!F?e.jsx("div",{className:_("h-full",s),children:e.jsx(ye,{message:"Not connected to messaging service",onBack:G})}):X?e.jsx("div",{className:_("h-full",s),children:e.jsx(ye,{message:X})}):e.jsx("div",{className:_("messaging-shell h-full bg-background-primary overflow-hidden",s),children:e.jsxs("div",{className:"flex h-full min-h-0",children:[e.jsx("div",{className:_("messaging-channel-list-sidebar min-h-0 min-w-0 lg:flex lg:flex-col",{"!hidden":m===!1||P,"hidden lg:flex lg:flex-1 lg:max-w-2xl":m!==!1&&!P&&le,"flex flex-col w-full lg:flex-1 lg:max-w-2xl":m!==!1&&!P&&!le}),children:e.jsx(Ge,{onChannelSelect:se,selectedChannel:V||void 0,filters:pe,channelRenderFilterFn:f,customEmptyStateIndicator:h,renderMessagePreview:E,viewerLanguage:S})}),e.jsx("div",{className:_("messaging-conversation-view flex-1 flex-col min-w-0 min-h-0",{flex:P||le||i,"hidden lg:flex":!P&&!le&&!i}),children:V?e.jsx("div",{className:"flex-1 min-h-0 flex flex-col",children:e.jsx(Ze,{channel:V,onBack:re,showBackButton:!P,renderMessageInputActions:n,renderConversationFooter:a,renderChannelBanner:y,onLeaveConversation:Ae,onBlockParticipant:ve,CustomChannelEmptyState:c,showDeleteConversation:be,onDeleteConversationClick:x,onBlockParticipantClick:o,onReportParticipantClick:g,dmAgentEnabled:v,messageMetadata:p,onMessageSent:N,showStarButton:j,chatbotVotingEnabled:I,viewerLanguage:S,customProfileContent:k,customChannelActions:T,renderMessage:A,sendButton:D},V.id)}):i?e.jsx(Ne,{}):e.jsx(Zt,{hasChannels:L,channelsLoaded:b})})]})})},Rn=/^([a-z][a-z0-9+.-]*):/i,Ln=new Set(["http","https","mailto","tel","sms"]);function Kt(t){if(typeof t!="string")return;const s=t.trim();if(s==="")return;const n=Rn.exec(s);if(n){const a=n[1].toLowerCase();return Ln.has(a)?s:void 0}return s.startsWith("//")||s.startsWith("/")?s:`https://${s}`}const Dn={dark:"bg-white text-[#121110] hover:bg-white/90",light:"bg-[#121110] text-white hover:bg-[#2a2928]"},Fn=({variant:t,cta:s})=>{const n=_("mt-2 inline-flex h-10 w-full items-center justify-center rounded-full px-4 text-sm font-medium leading-none transition-colors",Dn[t]),a=Kt(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})},zn={dark:"text-white",light:"text-black/90"},On="text-white/30",Pn={dark:"text-white/55",light:"text-black/55"},Ke=({variant:t,title:s,placeholderTitle:n,description:a,url:r,appIcon:i,cta:l,trailingAction:c})=>{const m=t==="dark",u=s??(m?n:void 0)??"",f=u.trim()!=="",h=a!=null&&a.trim()!=="",x=typeof r=="string"?r.trim():"",o=x!=="",g=l!=null;if(!f&&!h&&!o&&!g)return null;const p=_("truncate text-base font-medium leading-6",m&&!s?On:zn[t]),N=_("truncate text-xs leading-4",Pn[t]);return e.jsxs("div",{className:"px-4 py-3",children:[e.jsxs("div",{className:"flex items-end gap-3",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-2",children:[e.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[f&&e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[i?e.jsx("span",{className:"shrink-0",children:i}):null,e.jsx("p",{className:_("min-w-0",p),children:u})]}),h&&e.jsx("p",{className:N,children:a})]}),!g&&o&&e.jsx("p",{className:N,children:x})]}),c&&e.jsx("div",{className:"shrink-0",children:c})]}),l&&e.jsx(Fn,{variant:t,cta:l})]})},Bn=_("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)]"),_e=({variant:t,children:s,href:n,onClick:a,ariaLabel:r,rootRef:i,topRight:l,bgClassName:c,"data-testid":m})=>{const u=n!=null||a!=null,f=_(Bn,c??(t==="dark"?"bg-[#121110]":"bg-white"),u?"cursor-pointer no-underline focus-ring":null),h=l?e.jsx("div",{className:"pointer-events-auto absolute right-3 top-3 z-10",children:l}):null;return n?e.jsxs("a",{ref:i,href:n,target:"_blank",rel:"noopener noreferrer",onClick:a,"data-testid":m,className:f,children:[s,h]}):a?e.jsxs("button",{ref:i,type:"button",onClick:a,"aria-label":r,"data-testid":m,className:_(f,"text-left"),children:[s,h]}):e.jsxs("div",{ref:i,"data-testid":m,className:f,children:[s,h]})},$n={dark:"bg-white/10",light:"bg-black/5"},Vn={dark:"size-16 text-white/25",light:"size-16 text-black/25"},Me=(t,s)=>!!s&&!!t&&te(t)==="audio",Un=(t,s)=>{if(!s||!t)return!1;const n=te(t);return n==="video"||n==="audio"},Je="bg-[#F2F3F4]",ke=({variant:t,thumbnailUrl:s,sourceUrl:n,title:a,mimeType:r="image/*",topLeft:i,topRight:l})=>{const c=te(r),m=!!n&&c==="video";return Me(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:_("relative h-[180px] w-full overflow-hidden",m&&"bg-black"),children:[m?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:_("flex h-full w-full items-center justify-center",$n[t]),children:ie(r,{className:Vn[t],weight:"regular"})}),i?e.jsx("div",{className:"pointer-events-auto absolute left-3 top-3 z-10",children:i}):null,l?e.jsx("div",{className:"pointer-events-auto absolute right-3 top-3 z-10",children:l}):null]})},Gn=({title:t,placeholderTitle:s,description:n,url:a,mimeType:r,thumbnailUrl:i,sourceUrl:l,layout:c="featured",appIcon:m,cta:u,onDismiss:f,onEditClick:h})=>{const x=c==="classic",o=Me(r,l),g=f?e.jsx("button",{type:"button",onClick:f,"aria-label":"Dismiss attachment",className:"flex size-6 items-center justify-center rounded-full bg-[#121110] text-white",children:e.jsx(w.XIcon,{className:"size-3",weight:"bold"})}):void 0,v=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(w.PencilSimpleIcon,{className:"size-5",weight:"regular"})}):void 0;return o?e.jsx(_e,{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(ke,{variant:"dark",sourceUrl:l,title:t,mimeType:r})}),g&&e.jsx("div",{className:"shrink-0",children:g})]})}):e.jsxs(_e,{variant:"dark",topRight:x?g:void 0,children:[!x&&e.jsx(ke,{variant:"dark",thumbnailUrl:i,sourceUrl:l,title:t,mimeType:r,topRight:g}),e.jsx(Ke,{variant:"dark",title:t,placeholderTitle:s,description:n,url:a,appIcon:m,cta:u,trailingAction:v})]})},Hn=({title:t,description:s,url:n,mimeType:a,thumbnailUrl:r,sourceUrl:i,layout:l="featured",appIcon:c,cta:m,onClick:u})=>{const f=Un(a,i),h=Kt(n),x=m==null&&h!=null&&!f?h:void 0,o=m==null&&!f?u:void 0,g=Me(a,i)?Je:void 0,v=m&&u?{...m,onClick:()=>{var p;u(),(p=m.onClick)==null||p.call(m)}}:m;return e.jsxs(_e,{variant:"light",href:x,onClick:o,ariaLabel:t??"Open attachment preview",bgClassName:g,"data-testid":"link-attachment",children:[l==="featured"&&e.jsx(ke,{variant:"light",thumbnailUrl:r,sourceUrl:i,title:t,mimeType:a}),e.jsx(Ke,{variant:"light",title:t,description:s,url:n,appIcon:c,cta:v})]})},Yn=({title:t,placeholderTitle:s,description:n,url:a,mimeType:r,thumbnailUrl:i,sourceUrl:l,layout:c="featured",appIcon:m,cta:u})=>e.jsxs(_e,{variant:"dark",bgClassName:Me(r,l)?Je:void 0,children:[c==="featured"&&e.jsx(ke,{variant:"dark",thumbnailUrl:i,sourceUrl:l,title:t,mimeType:r}),e.jsx(Ke,{variant:"dark",title:t,placeholderTitle:s,description:n,url:a,appIcon:m,cta:u})]}),qn={Composer:Gn,Sent:Yn,Received:Hn},Xn={dark:"bg-[#121110]",light:"bg-[#e9eaed]"},Wn={dark:"text-white",light:"text-[#080707]"},Zn={dark:"border-white/[0.08]",light:"border-black/[0.08]"},Kn=t=>t==="dark"?"sender":"receiver",Jn={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":l})=>{const c=s!=null&&s!=="",m=Jn[Kn(t)][a];return e.jsxs("div",{"data-testid":l,"data-group-position":a,className:_("relative w-[280px] overflow-hidden px-2 py-2",m,Xn[t],Wn[t],n&&"border",n&&Zn[t],r),children:[i,c?e.jsx("p",{className:_("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:_("flex size-6 items-center justify-center rounded-full text-white",s==="overlay"?"bg-[#121110]/85 backdrop-blur":"bg-white/15 hover:bg-white/25"),children:e.jsx(w.XIcon,{className:"size-3",weight:"bold"})}),fe=t=>t==="received"?"light":"dark",Qn=({firstOfGroup:t,endOfGroup:s,groupedByUser:n})=>!n||t&&s?"single":t?"first":s?"end":"middle",ea=({src:t,mimeType:s,filename:n,items:a})=>a&&a.length>0?a:t?[{src:t,mimeType:s,filename:n}]:[],ta=({item:t,preload:s,trailingAction:n})=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("audio",{src:t.src,controls:!0,preload:t.preload??s,className:"block min-w-0 flex-1",children:t.mimeType?e.jsx("source",{src:t.src,type:t.mimeType}):null}),n??null]}),Qe=({state:t,src:s,mimeType:n,filename:a,items:r,text:i,groupPosition:l,preload:c,onDismiss:m})=>{const u=fe(t),f=t==="composer"&&!!m,h=ea({src:s,mimeType:n,filename:a,items:r});if(h.length===0)return null;const x=c??(h.length>1?"none":"metadata");return e.jsx(he,{variant:u,text:i,groupPosition:l,"data-testid":"audio-attachment",children:e.jsx("div",{className:"flex flex-col gap-2",children:h.map((o,g)=>e.jsx(ta,{item:o,preload:x,trailingAction:f&&g===0?e.jsx(xe,{onClick:m,variant:"inline"}):void 0},`${o.src}-${g}`))})})},sa=t=>e.jsx(Qe,{...t,state:"composer"}),na=t=>e.jsx(Qe,{...t,state:"sent"}),aa=t=>e.jsx(Qe,{...t,state:"received"}),ra={Composer:sa,Sent:na,Received:aa};function Jt(t){return!Number.isFinite(t)||t<0?"":t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:t<1024*1024*1024?`${(t/(1024*1024)).toFixed(2)} MB`:`${(t/(1024*1024*1024)).toFixed(2)} GB`}const ia={pdf:"PDF",doc:"DOC",xls:"XLS",csv:"CSV",ppt:"PPT",zip:"ZIP",text:"TXT",markdown:"MD"};function Qt(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=Bt(t),i=ia[r];if(i)return i;if(t==="application/octet-stream")return}const a=t.split("/")[1];if(!(!a||a==="*"))return a.toUpperCase()}function es(t,s,n){const a=Qt(t,s),r=typeof n=="number"&&n>0?Jt(n):void 0;return[a,r].filter(Boolean).join(" · ")||void 0}function ee(t){try{const n=new URL(t).pathname.split("/").pop();return n&&n.length>0?decodeURIComponent(n):"download"}catch{return"download"}}const la={dark:"text-white/55",light:"text-black/65"},oa={dark:"bg-white/10",light:"bg-black/5"},ca={dark:"text-white/85",light:"text-black/85"},ts=({variant:t,filename:s,title:n,mimeType:a="application/octet-stream",fileSize:r,onActivate:i,activateLabel:l,trailingAction:c})=>{const m=n??s??"File",u=es(a,s,r),f=e.jsx("div",{className:_("flex size-10 shrink-0 items-center justify-center rounded-sm",oa[t]),"aria-hidden":!0,children:ie(a,{className:_("size-6",ca[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:m}),u?e.jsx("p",{className:_("truncate text-xs leading-4",la[t]),children:u}):null]}),x=i?e.jsxs("button",{type:"button",onClick:i,"aria-label":l,className:_("flex min-w-0 flex-1 items-center gap-3 rounded-sm text-left transition-colors",t==="dark"?"hover:bg-white/[0.04]":"hover:bg-black/[0.04]"),children:[f,h]}):e.jsxs(e.Fragment,{children:[f,h]});return e.jsxs("div",{className:"flex items-center gap-3 px-3 py-2",children:[x,c?e.jsx("div",{className:"shrink-0",children:c}):null]})};async function ss(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),l=document.createElement("a");l.href=i,l.download=n,l.style.display="none",document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(i)}catch{if(!window.open(t,"_blank","noopener,noreferrer")){const r=document.createElement("a");r.href=t,r.download=n,r.target="_blank",r.rel="noopener noreferrer",r.style.display="none",document.body.appendChild(r),r.click(),document.body.removeChild(r)}}}const da=({src:t,filename:s,fileSize:n,mimeType:a,title:r,items:i})=>i&&i.length>0?i:t?[{src:t,filename:s,fileSize:n,mimeType:a,title:r}]:[],ua=({variant:t,item:s,index:n,onActivate:a,trailingAction:r})=>{const i=s.filename??ee(s.src);return e.jsx(ts,{variant:t,filename:i,title:s.title,mimeType:s.mimeType??"application/octet-stream",fileSize:s.fileSize,onActivate:()=>a(n),activateLabel:`Download ${i}`,trailingAction:r})},et=({state:t,src:s,filename:n,fileSize:a,mimeType:r,title:i,items:l,text:c,groupPosition:m,onClick:u,onDismiss:f})=>{const h=fe(t),x=t==="composer"&&!!f,o=da({src:s,filename:n,fileSize:a,mimeType:r,title:i,items:l}),g=p=>{if((u==null?void 0:u(p))===!1)return;const N=o[p];if(!N)return;const j=N.filename??ee(N.src);ss(N.src,j)};if(o.length===0)return null;const v=e.jsx("span",{className:_("flex size-8 items-center justify-center rounded-full",h==="dark"?"text-white/70":"text-black/70"),"aria-hidden":!0,children:e.jsx(w.DownloadSimpleIcon,{className:"size-5",weight:"bold"})});return e.jsx(he,{variant:h,text:c,groupPosition:m,"data-testid":"file-attachment",children:e.jsx("div",{className:"flex flex-col gap-2",children:o.map((p,N)=>{const j=x&&N===0?e.jsx(xe,{onClick:f,variant:"inline"}):v;return e.jsx(ua,{variant:h,item:p,index:N,onActivate:g,trailingAction:j},`${p.src}-${N}`)})})})},ma=t=>e.jsx(et,{...t,state:"composer"}),ha=t=>e.jsx(et,{...t,state:"sent"}),xa=t=>e.jsx(et,{...t,state:"received"}),fa={Composer:ma,Sent:ha,Received:xa},Te=({url:t,filename:s,variant:n="pill",label:a="Download",iconOnly:r,tone:i="dark",onTriggered:l})=>{const[c,m]=d.useState(!1),u=d.useCallback(o=>{o.stopPropagation(),!c&&(m(!0),ss(t,s).catch(()=>{}).finally(()=>{m(!1),l==null||l()}))},[c,t,s,l]),f=r??n!=="pill",x={className:_(n==="pill"?"size-4":"size-5","shrink-0"),weight:"bold"};if(n==="inline"){const o={dark:"text-white/70 hover:bg-white/[0.08] hover:text-white",light:"text-black/70 hover:bg-black/[0.08] hover:text-black"};return e.jsx("button",{type:"button",onClick:u,disabled:c,"aria-label":a,className:_("flex size-8 shrink-0 items-center justify-center rounded-full transition-colors disabled:opacity-70",o[i]),children:c?e.jsx(w.CircleNotchIcon,{className:"size-4 animate-spin",weight:"bold","aria-hidden":!0}):e.jsx(w.DownloadSimpleIcon,{className:"size-5 shrink-0",weight:"bold","aria-hidden":!0})})}return n==="pill"?e.jsxs("button",{type:"button",onClick:u,disabled:c,"aria-label":f?a:void 0,className:_("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:[c?e.jsx(w.CircleNotchIcon,{className:"size-4 animate-spin",weight:"bold","aria-hidden":!0}):e.jsx(w.DownloadSimpleIcon,{...x,"aria-hidden":!0}),f?null:a]}):e.jsx("button",{type:"button",onClick:u,disabled:c,"aria-label":a,className:_("flex size-10 shrink-0 items-center justify-center rounded-full text-white transition-colors disabled:opacity-70",n==="overlay"?"bg-black/55 backdrop-blur hover:bg-black/70":"bg-white/10 hover:bg-white/20"),children:c?e.jsx(w.CircleNotchIcon,{className:"size-5 animate-spin",weight:"bold","aria-hidden":!0}):e.jsx(w.DownloadSimpleIcon,{...x,"aria-hidden":!0})})};let me=0,$e=null;const ga=()=>{typeof document>"u"||(me===0&&($e=document.body.style.overflow,document.body.style.overflow="hidden"),me+=1)},ba=()=>{typeof document>"u"||me!==0&&(me-=1,me===0&&(document.body.style.overflow=$e??"",$e=null))},tt=({open:t,onClose:s,title:n,actions:a,contentClassName:r,children:i,"data-testid":l})=>{const c=d.useRef(null),m=d.useRef(null);return d.useEffect(()=>{if(!t)return;ga();const u=typeof document<"u"?document.activeElement:null,f=m.current??c.current;f==null||f.focus();const h=x=>{x.key==="Escape"&&(x.preventDefault(),s())};return window.addEventListener("keydown",h),()=>{ba(),window.removeEventListener("keydown",h),u&&document.body.contains(u)&&u.focus()}},[t,s]),!t||typeof document>"u"?null:hs.createPortal(e.jsxs("div",{ref:c,role:"dialog","aria-modal":"true","aria-label":n??"Attachment viewer","data-testid":l,tabIndex:-1,className:"fixed inset-0 z-[1000] flex flex-col bg-black/90 outline-none",children:[e.jsxs("div",{className:"pointer-events-none absolute inset-x-0 top-0 z-10 flex items-center gap-3 bg-gradient-to-b from-black/70 to-transparent px-4 py-3 text-white",children:[e.jsx("p",{className:"pointer-events-auto min-w-0 flex-1 truncate text-sm font-medium",children:n}),e.jsxs("div",{className:"pointer-events-auto flex shrink-0 items-center gap-2",children:[a,e.jsx("button",{ref:m,type:"button",onClick:s,"aria-label":"Close viewer",className:"flex size-10 items-center justify-center rounded-full bg-white/10 text-white transition-colors hover:bg-white/20",children:e.jsx(w.XIcon,{className:"size-5",weight:"bold","aria-hidden":!0})})]})]}),e.jsx("div",{className:_("relative z-0 flex h-full w-full flex-1 items-center justify-center overflow-hidden",r),children:i})]}),document.body)},Fe=1,kt=8,we=1.25,ze=(t,s,n)=>Math.min(Math.max(t,s),n),de={scale:1,x:0,y:0},ns=({open:t,items:s,initialIndex:n=0,onClose:a})=>{const r=ze(n,0,Math.max(s.length-1,0)),[i,l]=d.useState(r),[c,m]=d.useState(de),[u,f]=d.useState(!1),h=d.useRef(null),x=d.useRef(null);d.useEffect(()=>{t&&(l(ze(n,0,Math.max(s.length-1,0))),m(de))},[t,n,s.length]),d.useEffect(()=>{m(de)},[i]);const o=d.useCallback(()=>{l(y=>y<=0?s.length-1:y-1)},[s.length]),g=d.useCallback(()=>{l(y=>y>=s.length-1?0:y+1)},[s.length]);d.useEffect(()=>{if(!t)return;const y=k=>{s.length<=1||(k.key==="ArrowRight"?(k.preventDefault(),g()):k.key==="ArrowLeft"&&(k.preventDefault(),o()))};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[t,s.length,o,g]);const v=d.useCallback(y=>{m(k=>{const T=ze(k.scale*y,Fe,kt);return T===Fe?de:{scale:T,x:k.x,y:k.y}})},[]);d.useEffect(()=>{if(!t)return;const y=x.current;if(!y)return;const k=T=>{T.preventDefault();const A=T.deltaY<0?we:1/we;v(A)};return y.addEventListener("wheel",k,{passive:!1}),()=>y.removeEventListener("wheel",k)},[t,v]);const p=d.useCallback(()=>{m(y=>y.scale>1?de:{scale:2,x:y.x,y:y.y})},[]),N=d.useCallback(y=>{c.scale<=1||(y.preventDefault(),f(!0),h.current={x:y.clientX,y:y.clientY,panX:c.x,panY:c.y})},[c.scale,c.x,c.y]);d.useEffect(()=>{if(!u)return;const y=T=>{const A=h.current;A&&m(D=>({scale:D.scale,x:A.panX+(T.clientX-A.x),y:A.panY+(T.clientY-A.y)}))},k=()=>{h.current=null,f(!1)};return window.addEventListener("mousemove",y),window.addEventListener("mouseup",k),()=>{window.removeEventListener("mousemove",y),window.removeEventListener("mouseup",k)}},[u]);const j=s[i],I=d.useMemo(()=>(j==null?void 0:j.filename)??(j?ee(j.src):"image"),[j]),S=d.useMemo(()=>c.scale<=1?"cursor-zoom-in":u?"cursor-grabbing":"cursor-grab",[c.scale,u]);if(!j)return null;const E=s.length>1?` (${i+1} / ${s.length})`:"";return e.jsxs(tt,{open:t,onClose:a,title:`${I}${E}`,actions:e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:()=>v(1/we),disabled:c.scale<=Fe,"aria-label":"Zoom out",className:"flex size-10 items-center justify-center rounded-full bg-white/10 text-white transition-colors hover:bg-white/20 disabled:opacity-40",children:e.jsx(w.MagnifyingGlassMinusIcon,{className:"size-5",weight:"bold","aria-hidden":!0})}),e.jsx("button",{type:"button",onClick:()=>v(we),disabled:c.scale>=kt,"aria-label":"Zoom in",className:"flex size-10 items-center justify-center rounded-full bg-white/10 text-white transition-colors hover:bg-white/20 disabled:opacity-40",children:e.jsx(w.MagnifyingGlassPlusIcon,{className:"size-5",weight:"bold","aria-hidden":!0})}),e.jsx(Te,{url:j.src,filename:I,variant:"overlay",label:`Download ${I}`})]}),"data-testid":"image-viewer",children:[e.jsx("div",{ref:x,role:"presentation",onDoubleClick:p,onMouseDown:N,className:_("relative flex h-full w-full select-none items-center justify-center overflow-hidden",S),children:e.jsx("img",{src:j.src,alt:j.alt??I,draggable:!1,loading:"eager",decoding:"async",style:{transform:`translate3d(${c.x}px, ${c.y}px, 0) scale(${c.scale})`,transition:u?"none":"transform 120ms ease-out"},className:"max-h-full max-w-full object-contain"})}),s.length>1?e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:o,"aria-label":"Previous image",className:"absolute left-4 top-1/2 z-10 flex size-12 -translate-y-1/2 items-center justify-center rounded-full bg-white/10 text-white transition-colors hover:bg-white/20",children:e.jsx(w.CaretLeftIcon,{className:"size-5",weight:"bold","aria-hidden":!0})}),e.jsx("button",{type:"button",onClick:g,"aria-label":"Next image",className:"absolute right-4 top-1/2 z-10 flex size-12 -translate-y-1/2 items-center justify-center rounded-full bg-white/10 text-white transition-colors hover:bg-white/20",children:e.jsx(w.CaretRightIcon,{className:"size-5",weight:"bold","aria-hidden":!0})})]}):null]})},pa="relative block size-full overflow-hidden bg-black/5 outline-none focus-visible:ring-2 focus-visible:ring-white/80 focus-visible:ring-offset-2 focus-visible:ring-offset-black",as=({tiles:t,onTileActivate:s,maxVisible:n=4,className:a})=>{const r=t.length;if(r===0)return null;const i=t.slice(0,Math.min(r,n)),l=r-i.length,c=(m,u,f)=>{const h=_(pa,"h-full w-full");return s?e.jsxs("button",{type:"button",onClick:()=>s(u),"aria-label":m.ariaLabel??`Open media ${u+1}`,className:_(h,"cursor-zoom-in"),children:[m.content,f]},u):e.jsxs("div",{className:h,children:[m.content,f]},u)};return i.length===1?e.jsx("div",{className:_("aspect-square w-full",a),children:c(i[0],0)}):i.length===2?e.jsx("div",{className:_("grid aspect-[16/9] w-full grid-cols-2 gap-0.5",a),children:i.map((m,u)=>c(m,u))}):i.length===3?e.jsxs("div",{className:_("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:c(i[0],0)}),c(i[1],1),c(i[2],2)]}):e.jsx("div",{className:_("grid aspect-[4/3] w-full grid-cols-2 grid-rows-2 gap-0.5",a),children:i.map((m,u)=>{const f=l>0&&u===i.length-1;return c(m,u,f?e.jsxs("div",{className:"absolute inset-0 flex items-center justify-center bg-black/55 text-2xl font-semibold text-white",children:["+",l]}):null)})})},ge=t=>{const[s,n]=d.useState(!1),[a,r]=d.useState(0),i=d.useCallback(c=>{(t==null?void 0:t(c))!==!1&&(r(c),n(!0))},[t]),l=d.useCallback(()=>n(!1),[]);return{viewerOpen:s,viewerIndex:a,handleActivate:i,closeViewer:l}},va=(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"})}),ja=({src:t,alt:s,items:n})=>n&&n.length>0?n:t?[{src:t,alt:s}]:[],rs=(t,s)=>t.map((n,a)=>({src:n.src,alt:n.alt,filename:s&&t.length===1?s:s?`${s} (${a+1})`:void 0})),wa=({src:t,alt:s,filename:n,loading:a="lazy",onClick:r,onDismiss:i})=>{const{viewerOpen:l,viewerIndex:c,handleActivate:m,closeViewer:u}=ge(r);return e.jsxs("div",{className:"relative w-fit",children:[e.jsx("button",{type:"button",onClick:()=>m(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(ns,{open:l,items:rs([{src:t,alt:s}],n),initialIndex:c,onClose:u})]})},is=({state:t,src:s,alt:n,filename:a,items:r,text:i,groupPosition:l,loading:c="lazy",onClick:m})=>{const u=ja({src:s,alt:n,items:r}),f=fe(t),{viewerOpen:h,viewerIndex:x,handleActivate:o,closeViewer:g}=ge(m);if(u.length===0)return null;const v=u.map((p,N)=>va(p,N,u.length,c));return e.jsxs(he,{variant:f,text:i,groupPosition:l,"data-testid":"image-attachment",children:[e.jsx("div",{className:"relative",children:e.jsx(as,{tiles:v,onTileActivate:o})}),e.jsx(ns,{open:h,items:rs(u,a),initialIndex:x,onClose:g})]})},ya=t=>e.jsx(wa,{...t}),Ca=t=>e.jsx(is,{...t,state:"sent"}),Na=t=>e.jsx(is,{...t,state:"received"}),_a={Composer:ya,Sent:Ca,Received:Na},ka=({open:t,src:s,filename:n,onClose:a})=>{const r=d.useMemo(()=>n??ee(s),[n,s]),i=d.useMemo(()=>Sa(s),[s]);return e.jsx(tt,{open:t,onClose:a,title:r,actions:e.jsx(Te,{url:s,filename:r,variant:"overlay",label:`Download ${r}`}),contentClassName:"bg-[#1f1e1d]","data-testid":"pdf-viewer",children:e.jsx("iframe",{src:i,title:r,className:"absolute inset-0 size-full bg-white",sandbox:"allow-scripts allow-forms allow-popups allow-downloads"})})},Sa=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()}`},Ea=({src:t,filename:s,fileSize:n,title:a,items:r})=>r&&r.length>0?r:t?[{src:t,filename:s,fileSize:n,title:a}]:[],Ia=({variant:t,item:s,index:n,onActivate:a,trailingAction:r})=>{const i=s.filename??ee(s.src);return e.jsx(ts,{variant:t,filename:i,title:s.title,mimeType:"application/pdf",fileSize:s.fileSize,onActivate:()=>a(n),activateLabel:`Open ${i}`,trailingAction:r})},st=({state:t,src:s,filename:n,fileSize:a,title:r,items:i,text:l,groupPosition:c,onClick:m,onDismiss:u})=>{const f=fe(t),h=Ea({src:s,filename:n,fileSize:a,title:r,items:i}),{viewerOpen:x,viewerIndex:o,handleActivate:g,closeViewer:v}=ge(m),p=t==="composer"&&!!u;if(h.length===0)return null;const N=Math.min(o,h.length-1),j=h[N],I=j.filename??ee(j.src);return e.jsxs(he,{variant:f,text:l,groupPosition:c,"data-testid":"pdf-attachment",children:[e.jsx("div",{className:"flex flex-col gap-2",children:h.map((S,E)=>{const y=S.filename??ee(S.src),k=p&&E===0?e.jsx(xe,{onClick:u,variant:"inline"}):t==="composer"?void 0:e.jsx(Te,{url:S.src,filename:y,variant:"inline",label:`Download ${y}`,tone:f});return e.jsx(Ia,{variant:f,item:S,index:E,onActivate:g,trailingAction:k},`${S.src}-${E}`)})}),e.jsx(ka,{open:x,src:j.src,filename:I,onClose:v})]})},Ma=t=>e.jsx(st,{...t,state:"composer"}),Ta=t=>e.jsx(st,{...t,state:"sent"}),Aa=t=>e.jsx(st,{...t,state:"received"}),Ra={Composer:Ma,Sent:Ta,Received:Aa},St=(t,s,n)=>Math.min(Math.max(t,s),n),ls=({open:t,items:s,initialIndex:n=0,onClose:a})=>{const r=St(n,0,Math.max(s.length-1,0)),[i,l]=d.useState(r);d.useEffect(()=>{t&&l(St(n,0,Math.max(s.length-1,0)))},[t,n,s.length]);const c=d.useCallback(()=>l(x=>x<=0?s.length-1:x-1),[s.length]),m=d.useCallback(()=>l(x=>x>=s.length-1?0:x+1),[s.length]);d.useEffect(()=>{if(!t||s.length<=1)return;const x=o=>{o.key==="ArrowRight"?(o.preventDefault(),m()):o.key==="ArrowLeft"&&(o.preventDefault(),c())};return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[t,s.length,c,m]);const u=s[i],f=d.useMemo(()=>(u==null?void 0:u.filename)??(u?ee(u.src):"video"),[u]);if(!u)return null;const h=s.length>1?` (${i+1} / ${s.length})`:"";return e.jsxs(tt,{open:t,onClose:a,title:`${f}${h}`,actions:e.jsx(Te,{url:u.src,filename:f,variant:"overlay",label:`Download ${f}`}),"data-testid":"video-viewer",children:[e.jsx("div",{className:"flex h-full w-full items-center justify-center px-6 py-16",children:e.jsx("video",{src:u.src,poster:u.poster,controls:!0,autoPlay:!0,muted:!0,playsInline:!0,preload:u.preload??"metadata",className:"max-h-full max-w-full bg-black",children:u.mimeType?e.jsx("source",{src:u.src,type:u.mimeType}):null},`${i}:${u.src}`)}),s.length>1?e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:c,"aria-label":"Previous video",className:"absolute left-4 top-1/2 z-10 flex size-12 -translate-y-1/2 items-center justify-center rounded-full bg-white/10 text-white transition-colors hover:bg-white/20",children:e.jsx(w.CaretLeftIcon,{className:"size-5",weight:"bold","aria-hidden":!0})}),e.jsx("button",{type:"button",onClick:m,"aria-label":"Next video",className:"absolute right-4 top-1/2 z-10 flex size-12 -translate-y-1/2 items-center justify-center rounded-full bg-white/10 text-white transition-colors hover:bg-white/20",children:e.jsx(w.CaretRightIcon,{className:"size-5",weight:"bold","aria-hidden":!0})})]}):null]})},La=()=>e.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center",children:e.jsx("span",{className:"flex size-12 items-center justify-center rounded-full bg-black/55 text-white backdrop-blur",children:e.jsx(w.PlayIcon,{className:"size-6",weight:"fill","aria-hidden":!0})})}),os=({item:t,index:s})=>e.jsxs("div",{className:"absolute inset-0 size-full bg-[#0d0d0d]",children:[t.poster?e.jsx("img",{src:t.poster,alt:`Video ${s+1} thumbnail`,draggable:!1,loading:"lazy",decoding:"async",className:"absolute inset-0 size-full rounded-md object-cover"}):e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsx(w.VideoCameraIcon,{className:"size-16 rounded-md text-white/30",weight:"regular","aria-hidden":!0})}),e.jsx(La,{})]}),Da=(t,s,n)=>({ariaLabel:`Play video ${s+1} of ${n}`,content:e.jsx(os,{item:t,index:s})}),Fa=({src:t,poster:s,mimeType:n,preload:a,items:r})=>r&&r.length>0?a?r.map(i=>({...i,preload:i.preload??a})):r:t?[{src:t,poster:s,mimeType:n,preload:a}]:[],cs=(t,s)=>t.map((n,a)=>({src:n.src,poster:n.poster,mimeType:n.mimeType,preload:n.preload,filename:s&&t.length===1?s:s?`${s} (${a+1})`:void 0})),za=({src:t,poster:s,mimeType:n,filename:a,preload:r,onClick:i,onDismiss:l})=>{const{viewerOpen:c,viewerIndex:m,handleActivate:u,closeViewer:f}=ge(i);return e.jsxs("div",{className:"relative w-fit",children:[e.jsx("button",{type:"button",onClick:()=>u(0),"aria-label":"Play video",className:"relative block size-[280px] cursor-pointer overflow-hidden rounded-md outline-none focus-visible:ring-2 focus-visible:ring-black/40",children:e.jsx(os,{item:{src:t,poster:s,mimeType:n},index:0})}),l?e.jsx("div",{className:"absolute right-2 top-2 z-10",children:e.jsx(xe,{onClick:l})}):null,e.jsx(ls,{open:c,items:cs([{src:t,poster:s,mimeType:n,preload:r}],a),initialIndex:m,onClose:f})]})},ds=({state:t,src:s,poster:n,mimeType:a,filename:r,items:i,text:l,groupPosition:c,preload:m,onClick:u})=>{const f=Fa({src:s,poster:n,mimeType:a,preload:m,items:i}),h=fe(t),{viewerOpen:x,viewerIndex:o,handleActivate:g,closeViewer:v}=ge(u);if(f.length===0)return null;const p=f.map((N,j)=>Da(N,j,f.length));return e.jsxs(he,{variant:h,text:l,groupPosition:c,"data-testid":"video-attachment",children:[e.jsx("div",{className:"relative",children:e.jsx(as,{tiles:p,onTileActivate:g,className:"overflow-hidden rounded-md"})}),e.jsx(ls,{open:x,items:cs(f,r),initialIndex:o,onClose:v})]})},Oa=t=>e.jsx(za,{...t}),Pa=t=>e.jsx(ds,{...t,state:"sent"}),Ba=t=>e.jsx(ds,{...t,state:"received"}),$a={Composer:Oa,Sent:Pa,Received:Ba},Va={Image:_a,Video:$a,Audio:ra,Pdf:Ra,File:fa},us=({question:t,onClick:s,loading:n=!1,className:a})=>e.jsx("button",{type:"button",onClick:s,disabled:n,style:{backgroundColor:"#E6E5E3"},className:_("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}),Ua=({faqs:t,onFaqClick:s,loadingFaqId:n,headerText:a,className:r,avatarImage:i,avatarName:l})=>{const c=t.filter(m=>m.enabled).sort((m,u)=>(m.order??0)-(u.order??0));return c.length===0?null:e.jsx("div",{className:r,children:e.jsxs("div",{className:"flex gap-3 items-end",children:[(i||l)&&e.jsx("div",{className:"flex-none",children:e.jsx(Q,{id:l||"account",name:l||"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}),c.map(m=>e.jsx(us,{question:m.question,onClick:()=>s(m.id),loading:n===m.id},m.id))]})]})})};exports.ActionButton=ue;exports.AttachmentThumbnail=Ye;exports.Avatar=Q;exports.ChannelEmptyState=Wt;exports.ChannelList=Ge;exports.ChannelView=Ze;exports.CustomMessageProvider=rn;exports.FaqList=Ua;exports.FaqListItem=us;exports.LinkAttachment=qn;exports.LockedAttachment=Be;exports.MediaMessage=sn;exports.MessageAttachment=Va;exports.MessageVoteButtons=qt;exports.MessagingProvider=xs;exports.MessagingShell=An;exports.bubbleGroupPositionFromStream=Qn;exports.buildCompactMetaLabel=es;exports.formatFileSize=Jt;exports.formatRelativeTime=At;exports.getFileExtensionLabel=Qt;exports.getMessageDisplayText=Ue;exports.getSourceType=te;exports.isLinkAttachment=We;exports.isUuidLike=Lt;exports.normalizeLanguageCode=Rt;exports.renderTypeIcon=ie;exports.resolveLinkAttachment=Ee;exports.resolveMediaFromMessage=Ie;exports.resolveParticipantDisplayName=Se;exports.useCustomMessage=Yt;exports.useMessageVote=zt;exports.useMessaging=It;
|
|
2
|
-
//# sourceMappingURL=index-CctUDJSJ.cjs.map
|