@linktr.ee/messaging-react 3.17.0 → 3.17.1-rc-1785369934

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