@linktr.ee/messaging-react 4.3.1-rc-1787564018 → 4.3.1-rc-1787564868
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{Card-BGMEzK3U.cjs → Card-Bgapr7T9.cjs} +2 -2
- package/dist/{Card-BGMEzK3U.cjs.map → Card-Bgapr7T9.cjs.map} +1 -1
- package/dist/{Card-C-v4hEGd.js → Card-CPjlTEDn.js} +2 -2
- package/dist/{Card-C-v4hEGd.js.map → Card-CPjlTEDn.js.map} +1 -1
- package/dist/assets/index.css +1 -1
- package/dist/{index-B0knLCIZ.js → index-BJ1FkeL1.js} +16 -16
- package/dist/index-BJ1FkeL1.js.map +1 -0
- package/dist/index-BpUohOUq.cjs +3 -0
- package/dist/index-BpUohOUq.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/package.json +2 -2
- package/src/components/LinkAttachment/components/_shared/BubbleTail.test.tsx +1 -3
- package/src/components/LinkAttachment/components/_shared/BubbleTail.tsx +3 -3
- package/src/components/LinkAttachment/components/_shared/CardShell.tsx +10 -10
- package/src/components/MessageBubble/MessageBubble.test.tsx +7 -18
- package/src/components/MessageBubble/components/_shared/BubbleShell.tsx +8 -13
- package/src/components/RichCard/RichCard.stories.tsx +1 -13
- package/src/components/RichCard/RichCardBody.tsx +3 -2
- package/src/styles.css +2 -4
- package/dist/index-8NJc4beJ.cjs +0 -3
- package/dist/index-8NJc4beJ.cjs.map +0 -1
- package/dist/index-B0knLCIZ.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-BpUohOUq.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.MessageAttachment=e.MessageAttachment;exports.MessageBubble=e.MessageBubble;exports.MessagingLoggerProvider=e.MessagingLoggerProvider;exports.MessagingProvider=e.MessagingProvider;exports.MessagingShell=e.MessagingShell;exports.RichCard=e.RichCard;exports.TipMessage=e.TipMessage;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.isTipMessage=e.isTipMessage;exports.isUuidLike=e.isUuidLike;exports.messageAttachmentGroupPositionFromStream=e.bubbleGroupPositionFromStream;exports.normalizeLanguageCode=e.normalizeLanguageCode;exports.optimizeMessagingAttachmentUrl=e.optimizeMessagingAttachmentUrl;exports.resolveConversationParticipant=e.resolveConversationParticipant;exports.resolveParticipantDisplayName=e.resolveParticipantDisplayName;exports.useComposerLocked=e.useComposerLocked;exports.useCustomMessage=e.useCustomMessage;exports.useMessaging=e.useMessaging;exports.useMessagingLogger=e.useMessagingLogger;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as e, a as t, C as i, b as n, c as o, d as g, F as r, e as m, L as l, f as M, M as c, h as L, i as p, j as u, k as h, R as C, T as d, l as v, m as A, n as b, p as k, q as F, s as P, t as T, u as f, v as x, w as y, o as z, x as S, y as q, z as B, B as D, D as E, E as R } from "./index-
|
|
1
|
+
import { A as e, a as t, C as i, b as n, c as o, d as g, F as r, e as m, L as l, f as M, M as c, h as L, i as p, j as u, k as h, R as C, T as d, l as v, m as A, n as b, p as k, q as F, s as P, t as T, u as f, v as x, w as y, o as z, x as S, y as q, z as B, B as D, D as E, E as R } from "./index-BJ1FkeL1.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": "4.3.1-rc-
|
|
3
|
+
"version": "4.3.1-rc-1787564868",
|
|
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
|
"chromatic:local": "yarn storybook:build && chromatic"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@linktr.ee/messaging-core": "2.5.0-rc-
|
|
53
|
+
"@linktr.ee/messaging-core": "2.5.0-rc-1787564868",
|
|
54
54
|
"@linktr.ee/messaging-taxonomy": "^0.10.0",
|
|
55
55
|
"@phosphor-icons/react": "^2.1.10"
|
|
56
56
|
},
|
|
@@ -23,9 +23,7 @@ describe('BubbleTail', () => {
|
|
|
23
23
|
</BubbleTail>
|
|
24
24
|
)
|
|
25
25
|
const tail = screen.getByTestId('link-card-tail')
|
|
26
|
-
expect(tail.parentElement?.className).toBe(
|
|
27
|
-
'relative isolate w-full max-w-[var(--lt-msg-card-width,290px)]'
|
|
28
|
-
)
|
|
26
|
+
expect(tail.parentElement?.className).toBe('relative isolate w-fit')
|
|
29
27
|
expect(tail.getAttribute('aria-hidden')).toBe('true')
|
|
30
28
|
// The tail follows the card so it paints over the card's bottom edge.
|
|
31
29
|
expect(screen.getByText('card').nextElementSibling).toBe(tail)
|
|
@@ -47,9 +47,9 @@ const BubbleTail: React.FC<BubbleTailProps> = ({
|
|
|
47
47
|
|
|
48
48
|
return (
|
|
49
49
|
// `isolate` keeps the tail's negative z-index from escaping behind the
|
|
50
|
-
// thread background
|
|
51
|
-
//
|
|
52
|
-
<div className="relative isolate w-
|
|
50
|
+
// thread background; `w-fit` stops the wrapper from stretching in the
|
|
51
|
+
// composer's flex list.
|
|
52
|
+
<div className="relative isolate w-fit">
|
|
53
53
|
{children}
|
|
54
54
|
<span
|
|
55
55
|
aria-hidden
|
|
@@ -65,25 +65,25 @@ export interface CardShellProps {
|
|
|
65
65
|
export const LOADING_LABEL = 'Loading link preview'
|
|
66
66
|
|
|
67
67
|
const SHELL_CLASS = classNames(
|
|
68
|
-
//
|
|
69
|
-
//
|
|
70
|
-
//
|
|
71
|
-
//
|
|
72
|
-
|
|
68
|
+
// Width is a channel-scoped token: default 290px, but a read-only surface with no
|
|
69
|
+
// composer (the official channel) sets `--lt-msg-card-width` on its root to widen the
|
|
70
|
+
// content column (see ChannelView). Consumers that don't set the var keep 290px.
|
|
71
|
+
// `max-w-full` caps the card to its container so a widened value can never overflow
|
|
72
|
+
// horizontally on a narrow (sub-393px) viewport — it shrinks to fit instead.
|
|
73
|
+
'relative w-[var(--lt-msg-card-width,290px)] max-w-full select-none overflow-hidden',
|
|
73
74
|
// 20px corners — no token exists for it in the component-library preset,
|
|
74
75
|
// whose radius scale is sm .5rem / md 1rem / lg 1.5rem / xl 4rem.
|
|
75
76
|
'rounded-[20px]'
|
|
76
77
|
)
|
|
77
78
|
|
|
78
|
-
// The
|
|
79
|
+
// The 290x250 lock: the chin takes the height its 1-2 line title needs
|
|
79
80
|
// (82px at two lines, 62px at one) and the hero absorbs the remainder.
|
|
80
81
|
const FIXED_HEIGHT_CLASS = 'flex h-[250px] flex-col'
|
|
81
82
|
|
|
82
83
|
/**
|
|
83
|
-
* Outer chrome for every `LinkAttachment.*` card. Matches the 290px
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
* 250px box.
|
|
84
|
+
* Outer chrome for every `LinkAttachment.*` card. Matches the 290px x 250px
|
|
85
|
+
* box, 20px corner radius, and borderless / shadowless treatment of the
|
|
86
|
+
* composer and sent instances in Figma.
|
|
87
87
|
*/
|
|
88
88
|
const CardShell: React.FC<CardShellProps> = ({
|
|
89
89
|
variant,
|
|
@@ -22,15 +22,12 @@ describe('MessageBubble', () => {
|
|
|
22
22
|
const { rerender } = renderWithProviders(
|
|
23
23
|
<MessageBubble.Sent text="tailed" />
|
|
24
24
|
)
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
.closest('.str-chat__message-bubble') as HTMLElement
|
|
25
|
+
// The bubble box wraps the text; its last child is the tail <span>.
|
|
26
|
+
const bubble = screen.getByText('tailed').parentElement as HTMLElement
|
|
28
27
|
expect(bubble.querySelector('span[aria-hidden="true"]')).not.toBeNull()
|
|
29
28
|
|
|
30
29
|
rerender(<MessageBubble.Sent text="tailed" tail={false} />)
|
|
31
|
-
const bubbleNoTail = screen
|
|
32
|
-
.getByText('tailed')
|
|
33
|
-
.closest('.str-chat__message-bubble') as HTMLElement
|
|
30
|
+
const bubbleNoTail = screen.getByText('tailed').parentElement as HTMLElement
|
|
34
31
|
expect(bubbleNoTail.querySelector('span[aria-hidden="true"]')).toBeNull()
|
|
35
32
|
})
|
|
36
33
|
|
|
@@ -50,17 +47,13 @@ describe('MessageBubble', () => {
|
|
|
50
47
|
|
|
51
48
|
it('applies the sent and received surface treatments from theme vars', () => {
|
|
52
49
|
const { rerender } = renderWithProviders(<MessageBubble.Sent text="mine" />)
|
|
53
|
-
const sent = screen
|
|
54
|
-
.getByText('mine')
|
|
55
|
-
.closest('.str-chat__message-bubble') as HTMLElement
|
|
50
|
+
const sent = screen.getByText('mine').parentElement as HTMLElement
|
|
56
51
|
expect(sent.style.backgroundColor).toBe(
|
|
57
52
|
'var(--str-chat__own-message-bubble-background-color, #1e2330)'
|
|
58
53
|
)
|
|
59
54
|
|
|
60
55
|
rerender(<MessageBubble.Received text="theirs" />)
|
|
61
|
-
const received = screen
|
|
62
|
-
.getByText('theirs')
|
|
63
|
-
.closest('.str-chat__message-bubble') as HTMLElement
|
|
56
|
+
const received = screen.getByText('theirs').parentElement as HTMLElement
|
|
64
57
|
expect(received.style.backgroundColor).toBe(
|
|
65
58
|
'var(--str-chat__message-bubble-background-color, #f1f0ee)'
|
|
66
59
|
)
|
|
@@ -68,9 +61,7 @@ describe('MessageBubble', () => {
|
|
|
68
61
|
|
|
69
62
|
it('masks message content from session replay by default', () => {
|
|
70
63
|
renderWithProviders(<MessageBubble.Received header="Brie" text="secret" />)
|
|
71
|
-
const bubble = screen
|
|
72
|
-
.getByText('secret')
|
|
73
|
-
.closest('.str-chat__message-bubble') as HTMLElement
|
|
64
|
+
const bubble = screen.getByText('secret').parentElement as HTMLElement
|
|
74
65
|
expect(bubble.getAttribute('data-dd-privacy')).toBe('mask')
|
|
75
66
|
})
|
|
76
67
|
|
|
@@ -78,9 +69,7 @@ describe('MessageBubble', () => {
|
|
|
78
69
|
renderWithProviders(
|
|
79
70
|
<MessageBubble.Sent text="wide" className="w-fit max-w-[520px]" />
|
|
80
71
|
)
|
|
81
|
-
const bubble = screen
|
|
82
|
-
.getByText('wide')
|
|
83
|
-
.closest('.str-chat__message-bubble') as HTMLElement
|
|
72
|
+
const bubble = screen.getByText('wide').parentElement as HTMLElement
|
|
84
73
|
expect(bubble.classList.contains('w-fit')).toBe(true)
|
|
85
74
|
expect(bubble.className).toContain('max-w-[520px]')
|
|
86
75
|
})
|
|
@@ -67,8 +67,7 @@ const BubbleShell: React.FC<BubbleShellProps> = ({
|
|
|
67
67
|
<div
|
|
68
68
|
data-dd-privacy="mask"
|
|
69
69
|
className={classNames(
|
|
70
|
-
'
|
|
71
|
-
'relative',
|
|
70
|
+
'relative px-4 py-3',
|
|
72
71
|
'text-[0.875rem] leading-[1.3125rem] tracking-[0.14px]',
|
|
73
72
|
className
|
|
74
73
|
)}
|
|
@@ -78,17 +77,13 @@ const BubbleShell: React.FC<BubbleShellProps> = ({
|
|
|
78
77
|
isolation: 'isolate',
|
|
79
78
|
}}
|
|
80
79
|
>
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
{text}
|
|
89
|
-
</p>
|
|
90
|
-
{tail && <BubbleTail variant={variant} />}
|
|
91
|
-
</div>
|
|
80
|
+
{header != null && (
|
|
81
|
+
<div className="mb-1 font-medium" data-testid="message-bubble-header">
|
|
82
|
+
{header}
|
|
83
|
+
</div>
|
|
84
|
+
)}
|
|
85
|
+
<p className="m-0 whitespace-pre-wrap break-words hyphens-manual">{text}</p>
|
|
86
|
+
{tail && <BubbleTail variant={variant} />}
|
|
92
87
|
</div>
|
|
93
88
|
)
|
|
94
89
|
|
|
@@ -95,13 +95,6 @@ const COLLECTION: RichCardBaseProps = {
|
|
|
95
95
|
imagePresentation: 'fan',
|
|
96
96
|
actions: [secondaryLink('View collection', 'tr.ee/briesummer')],
|
|
97
97
|
}
|
|
98
|
-
const NEWLINE_SUBTITLE: RichCardBaseProps = {
|
|
99
|
-
...OFFICIAL_WELCOME,
|
|
100
|
-
title: 'Start every conversation with a personal welcome message!',
|
|
101
|
-
subtitle:
|
|
102
|
-
'👋 Say hello as people arrive\n✨ Spark conversations\n💬 Add automated FAQs',
|
|
103
|
-
subtitleLines: 6,
|
|
104
|
-
}
|
|
105
98
|
|
|
106
99
|
const bothSides = (props: RichCardBaseProps) => (
|
|
107
100
|
<>
|
|
@@ -120,8 +113,7 @@ const bothSides = (props: RichCardBaseProps) => (
|
|
|
120
113
|
* The three real surfaces that converge on `linktree_rich_card`, each shown
|
|
121
114
|
* Received (light) and Sent (dark). They differ only by knobs: the official
|
|
122
115
|
* welcome card is `hero + primary`; a single-link broadcast is `hero +
|
|
123
|
-
* secondary`; a collection is `fan + secondary`.
|
|
124
|
-
* newline-separated subtitle (the onboarding result-card shape).
|
|
116
|
+
* secondary`; a collection is `fan + secondary`.
|
|
125
117
|
*/
|
|
126
118
|
export const Instances: StoryFn = () => (
|
|
127
119
|
<Table>
|
|
@@ -139,10 +131,6 @@ export const Instances: StoryFn = () => (
|
|
|
139
131
|
<RowLabel>Collection — fan · secondary</RowLabel>
|
|
140
132
|
{bothSides(COLLECTION)}
|
|
141
133
|
</tr>
|
|
142
|
-
<tr>
|
|
143
|
-
<RowLabel>Subtitle with newlines</RowLabel>
|
|
144
|
-
{bothSides(NEWLINE_SUBTITLE)}
|
|
145
|
-
</tr>
|
|
146
134
|
</tbody>
|
|
147
135
|
</Table>
|
|
148
136
|
)
|
|
@@ -20,8 +20,9 @@ export interface RichCardBodyProps {
|
|
|
20
20
|
|
|
21
21
|
// body/small from Figma. Title is medium; subtitle is regular. No
|
|
22
22
|
// `text-wrap:balance` — it evened two-line titles by breaking mid-phrase.
|
|
23
|
-
const TITLE_CLASS =
|
|
24
|
-
|
|
23
|
+
const TITLE_CLASS =
|
|
24
|
+
'line-clamp-2 text-[14px] font-medium leading-5 tracking-[0.02em]'
|
|
25
|
+
const SUBTITLE_CLASS = 'text-[14px] leading-5 tracking-[0.02em]'
|
|
25
26
|
|
|
26
27
|
/** `<br>` ignores vertical margin; the spacer is the 6px Figma gap. */
|
|
27
28
|
const LineBreak: React.FC = () => (
|
package/src/styles.css
CHANGED
|
@@ -407,8 +407,7 @@
|
|
|
407
407
|
(MES-1278). Scoped to messages with a single `.str-chat__message-bubble`
|
|
408
408
|
that carries `.str-chat__message-text` — other media still use fixed
|
|
409
409
|
widths and need to go fluid before the same spacing can apply generally. */
|
|
410
|
-
&:has(.str-chat__message-bubble:only-child .str-chat__message-text)
|
|
411
|
-
&:has(.messaging-link-card) {
|
|
410
|
+
&:has(.str-chat__message-bubble:only-child .str-chat__message-text) {
|
|
412
411
|
padding-inline-end: calc(100% / 6);
|
|
413
412
|
}
|
|
414
413
|
}
|
|
@@ -435,8 +434,7 @@
|
|
|
435
434
|
justify-items: end;
|
|
436
435
|
|
|
437
436
|
/* Same open-side reserve as --other (see above). */
|
|
438
|
-
&:has(.str-chat__message-bubble:only-child .str-chat__message-text)
|
|
439
|
-
&:has(.messaging-link-card) {
|
|
437
|
+
&:has(.str-chat__message-bubble:only-child .str-chat__message-text) {
|
|
440
438
|
padding-inline-start: calc(100% / 6);
|
|
441
439
|
}
|
|
442
440
|
}
|
package/dist/index-8NJc4beJ.cjs
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
"use strict";const s=require("react/jsx-runtime"),x=require("react"),Ds=require("@linktr.ee/messaging-core"),Ee=require("stream-chat"),w=require("stream-chat-react"),V=require("@linktr.ee/messaging-taxonomy"),N=require("classnames"),C=require("@phosphor-icons/react"),Ue=require("stream-chat-react/experimental"),ge={debug:(e,...t)=>console.log(e,...t),info:(e,...t)=>console.log(e,...t),warn:(e,...t)=>console.warn(e,...t),error:(e,...t)=>console.error(e,...t)},Gt=e=>({debug:(e==null?void 0:e.debug)??ge.debug,info:(e==null?void 0:e.info)??ge.info,warn:(e==null?void 0:e.warn)??ge.warn,error:(e==null?void 0:e.error)??ge.error}),Yt=x.createContext(ge),Wt=({logger:e,children:t})=>{const n=x.useMemo(()=>Gt(e),[e]);return s.jsx(Yt.Provider,{value:n,children:t})},Fs=()=>x.useContext(Yt),qt=x.createContext({service:null,client:null,isConnected:!1,isLoading:!1,error:null,capabilities:{},refreshConnection:async()=>{},debug:!1}),He=()=>x.useContext(qt),Ps=({children:e,user:t,serviceConfig:n,apiKey:a,capabilities:r={},debug:i=!1,client:c,logger:l})=>{var L,$;const d=x.useCallback((B,...D)=>{i&&console.log(`🔥 [MessagingProvider] ${B}`,...D)},[i]);d("🔄 RENDER START",{userId:t==null?void 0:t.id,apiKey:(a==null?void 0:a.substring(0,8))+"...",serviceConfig:!!n,capabilities:Object.keys(r)});const[u,h]=x.useState(null),[m,f]=x.useState(null),[o,v]=x.useState(!1),[_,p]=x.useState(!1),[b,g]=x.useState(null),y=x.useRef(!1),j=x.useRef(null),E=x.useRef(n);E.current=n;const A=x.useRef(i);A.current=i;const M=x.useRef(l);M.current=l;const O=x.useRef({userId:t==null?void 0:t.id,apiKey:a,serviceConfig:n,capabilities:r}),P=x.useRef(0);P.current++,d("📊 RENDER INFO",{renderCount:P.current,currentProps:{userId:t==null?void 0:t.id,apiKey:(a==null?void 0:a.substring(0,8))+"..."},propChanges:{userChanged:O.current.userId!==(t==null?void 0:t.id),apiKeyChanged:O.current.apiKey!==a,serviceConfigChanged:O.current.serviceConfig!==n,capabilitiesChanged:O.current.capabilities!==r}}),O.current={userId:t==null?void 0:t.id,apiKey:a,serviceConfig:n,capabilities:r};const R=x.useRef(null);!c&&a&&((L=R.current)==null?void 0:L.apiKey)!==a&&(R.current={apiKey:a,client:new Ee.StreamChat(a)});const S=c||(a?(($=R.current)==null?void 0:$.client)??null:null);x.useEffect(()=>{const B=P.current,D=E.current;if(c){j.current=null,h(null),f(null),v(!1),g(null),p(!1);return}if(!a||!S||!D){d("⚠️ SERVICE INIT SKIPPED",{renderCount:B,reason:"Missing apiKey, client, or serviceConfig"});return}d("🚀 CREATING SERVICE",{renderCount:B,apiKey:(a==null?void 0:a.substring(0,8))+"..."});const Y=new Ds.StreamChatService({...D,apiKey:a,debug:A.current,client:S,...D.logger||!M.current?{}:{logger:Gt(M.current)}});j.current=Y,h(Y),d("✅ SERVICE SET",{renderCount:B,serviceInstance:!!Y})},[a,S,c]);const T=x.useRef(null);x.useEffect(()=>{var D,Y;if(d("🔗 USER CONNECTION EFFECT TRIGGERED",{hasService:!!u,hasUser:!!t,userId:t==null?void 0:t.id,isConnecting:y.current,isConnected:o,dependencies:{service:!!u,userId:t==null?void 0:t.id}}),c)return;if(!u||!t){d("⚠️ USER CONNECTION SKIPPED","Missing service or user");return}if(y.current){d("⚠️ USER CONNECTION SKIPPED","Already connecting");return}if(((D=T.current)==null?void 0:D.serviceId)===u&&((Y=T.current)==null?void 0:Y.userId)===t.id){d("⚠️ USER CONNECTION SKIPPED","Already connected this user with this service");return}(async()=>{d("🚀 STARTING USER CONNECTION",{userId:t.id}),y.current=!0,p(!0),g(null);try{d("📞 CALLING SERVICE.CONNECTUSER",{userId:t.id});const U=await u.connectUser(t);f(U),v(!0),T.current={serviceId:u,userId:t.id},d("✅ USER CONNECTION SUCCESS",{userId:t.id,clientId:U.userID})}catch(U){const W=U instanceof Error?U.message:"Connection failed";g(W),d("❌ USER CONNECTION ERROR",{userId:t.id,error:W})}finally{p(!1),y.current=!1,d("🔄 USER CONNECTION FINISHED",{userId:t.id,isConnected:o})}})()},[u,t,d,o,c]),x.useEffect(()=>{const B=S;return()=>{var D;B&&(T.current=null,(D=j.current)==null||D.disconnectUser().catch(console.error))}},[S]);const I=x.useCallback(async()=>{if(d("🔄 REFRESH CONNECTION CALLED",{hasService:!!u,hasUser:!!t}),!c){if(!u||!t){d("⚠️ REFRESH CONNECTION SKIPPED","Missing service or user");return}d("🚀 STARTING CONNECTION REFRESH",{userId:t.id}),p(!0);try{d("🔌 DISCONNECTING FOR REFRESH"),await u.disconnectUser(),d("📞 RECONNECTING FOR REFRESH");const B=await u.connectUser(t);f(B),v(!0),g(null),d("✅ CONNECTION REFRESH SUCCESS",{userId:t.id})}catch(B){const D=B instanceof Error?B.message:"Refresh failed";g(D),d("❌ CONNECTION REFRESH ERROR",{userId:t.id,error:D})}finally{p(!1),d("🔄 CONNECTION REFRESH FINISHED",{userId:t.id})}}},[u,t,d,c]),k=x.useMemo(()=>(d("💫 CONTEXT VALUE MEMOIZATION",{hasService:!!u,hasClient:!!m,isConnected:o,isLoading:_,hasError:!!b,capabilitiesKeys:Object.keys(r)}),{service:c?null:u,client:c??m,isConnected:c?!0:o,isLoading:c?!1:_,error:c?null:b,capabilities:r,refreshConnection:I,debug:i}),[u,m,c,o,_,b,r,I,i,d]);return d("🔄 RENDER END",{renderCount:P.current,willRenderChat:!!S,contextValueReady:!!k}),s.jsx(Wt,{logger:l,children:s.jsx(qt.Provider,{value:k,children:S?s.jsx(w.Chat,{client:S,customClasses:{channelList:"str-chat__channel-list str-chat__channel-list-react bg-transparent lg:border-r-2 border-r-0 border-[#0000000A]"},children:e}):e})})},Xt=()=>He(),Kt=e=>{var a,r;const[t,n]=x.useState(!!((r=(a=e==null?void 0:e.state)==null?void 0:a.membership)!=null&&r.pinned_at));return x.useEffect(()=>{var c;if(!e){n(!1);return}n(!!((c=e.state.membership)!=null&&c.pinned_at));const i=l=>{var d;n(l!=null&&l.member?!!l.member.pinned_at:!!((d=e.state.membership)!=null&&d.pinned_at))};return e.on("member.updated",i),()=>{e.off("member.updated",i)}},[e]),t};function Ve(e,t,n){const a=Object.values(e||{});if(V.isOfficialChannel(n)){const r=a.find(i=>{var c;return((c=i.user)==null?void 0:c.id)===V.OFFICIAL_SENDER_USER_ID});if(r)return r}return a.find(r=>{var i;return((i=r.user)==null?void 0:i.id)&&r.user.id!==t})}const Bs=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;function Zt(e){return Bs.test(e.trim())}function Et(e,t){const n=e==null?void 0:e.trim();return!n||t&&n===t||t&&n===`Follower ${t}`?!1:!Zt(n)}function Ge(e){return Et(e==null?void 0:e.name,e==null?void 0:e.id)?e.name.trim():Et(e==null?void 0:e.username,e==null?void 0:e.id)?e.username.trim():"Unknown member"}const It=[{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 zs(e){let t=0;for(let n=0;n<e.length;n++){const a=e.charCodeAt(n);t=(t<<5)-t+a,t=t&t}return Math.abs(t)}function Jt(e){return It[zs(e)%It.length]}function $s(e){return Jt(e).emoji}function Us(e){return Jt(e).bgColor}const me=({id:e,image:t,size:n=40,className:a,starred:r=!1,shape:i="squircle",dmAgentEnabled:c=!1})=>{const l=$s(e),d=Us(e),u=.45,m=n<32?Math.round(n*u):n<56?14:n<120?18:36,f=n>=40?2:1,o=i==="circle"?{borderRadius:"50%"}:{borderRadius:"1rem"},v=s.jsx("div",{className:"h-full w-full overflow-hidden",style:o,children:t?s.jsx("img",{src:t,alt:"",className:"h-full w-full object-cover"}):s.jsx("div",{"aria-hidden":"true",className:N("avatar-fallback flex h-full w-full items-center justify-center font-semibold select-none transition-colors"),style:{fontSize:m,lineHeight:1},children:l})});return s.jsxs("div",{className:N("relative flex-shrink-0",a),style:{"--str-chat__avatar-size":`${n}px`,width:`${n}px`,height:`${n}px`,backgroundColor:t?void 0:d,...o},children:[r&&s.jsx("div",{"aria-hidden":"true",className:"absolute -left-1.5 -top-1.5 z-10 flex size-5 items-center justify-center rounded-full bg-white shadow-[0_0_0_1px_rgba(0,0,0,0.04),0_4px_8px_rgba(0,0,0,0.06)]",children:s.jsx(C.StarIcon,{className:"size-3 text-yellow-600",weight:"duotone"})}),s.jsx("div",{"data-testid":"avatar-ring",className:N("h-full w-full","bg-transparent"),style:{...o,...c&&{borderWidth:`${f}px`,borderStyle:"solid",borderColor:"var(--AI-Gradient, #7F22FE)",boxShadow:"inset 0 1px 2px 0 rgba(255, 255, 255, 0.5)"}},children:v})]})},Hs="https://linktr.ee/s/about/trust-center/report",Vs=({channel:e,participant:t,showBlockParticipant:n=!0,enabled:a=!0,onLeaveConversation:r,onBlockParticipant:i,onDeleteConversationClick:c,onBlockParticipantClick:l,onReportParticipantClick:d,onActionComplete:u,logLabel:h="useChannelModerationActions"})=>{var T;const{service:m,debug:f}=He(),o=(T=t==null?void 0:t.user)==null?void 0:T.id,v=!!(a&&n&&m&&o),[_,p]=x.useState(!1),[b,g]=x.useState(null),[y,j]=x.useState(!1),[E,A]=x.useState(!1),M=v&&((b==null?void 0:b.participantId)!==o||(b==null?void 0:b.service)!==m);return x.useEffect(()=>{if(!v||!m||!o){p(!1),g(null);return}let I=!1;return(async()=>{try{const k=await m.getBlockedUsers();if(I)return;p(k.some(L=>L.blocked_user_id===o))}catch(k){I||console.error(`[${h}] Failed to check blocked status:`,k)}finally{I||g({participantId:o,service:m})}})(),()=>{I=!0}},[v,m,o,h]),{isParticipantBlocked:_,isCheckingBlockedStatus:M,isLeaving:y,isUpdatingBlockStatus:E,handleLeaveConversation:async()=>{var I;if(!y){c==null||c(),f&&console.log(`[${h}] Leave conversation`,e.cid),j(!0);try{const k=((I=e._client)==null?void 0:I.userID)??null;await e.hide(k,!1),r&&await r(e),u==null||u()}catch(k){console.error(`[${h}] Failed to leave conversation`,k)}finally{j(!1)}}},handleBlockUser:async()=>{var I,k,L;if(!(E||!m)){l==null||l(),f&&console.log(`[${h}] Block member`,(I=t==null?void 0:t.user)==null?void 0:I.id),A(!0);try{await m.blockUser((k=t==null?void 0:t.user)==null?void 0:k.id),i&&await i((L=t==null?void 0:t.user)==null?void 0:L.id),u==null||u()}catch($){console.error(`[${h}] Failed to block member`,$)}finally{A(!1)}}},handleUnblockUser:async()=>{var I,k,L;if(!(E||!m)){l==null||l(),f&&console.log(`[${h}] Unblock member`,(I=t==null?void 0:t.user)==null?void 0:I.id),A(!0);try{await m.unBlockUser((k=t==null?void 0:t.user)==null?void 0:k.id),i&&await i((L=t==null?void 0:t.user)==null?void 0:L.id),u==null||u()}catch($){console.error(`[${h}] Failed to unblock member`,$)}finally{A(!1)}}},handleReportUser:()=>{d==null||d(),u==null||u(),window.open(Hs,"_blank","noopener,noreferrer")}}},de=({variant:e="default",className:t,children:n,...a})=>{const r=e==="danger";return s.jsx("button",{type:"button",className:N("flex w-full items-center gap-3 rounded-lg px-4 py-3 text-left text-sm transition-colors focus-ring disabled:cursor-not-allowed disabled:opacity-60",r?"text-danger hover:bg-danger/50":"text-charcoal hover:bg-sand",t),...a,children:n})},Gs=({channel:e,participant:t,showDeleteConversation:n=!0,showBlockParticipant:a=!0,showReportParticipant:r=!0,onLeaveConversation:i,onBlockParticipant:c,onDeleteConversationClick:l,onBlockParticipantClick:d,onReportParticipantClick:u,customChannelActions:h,triggerClassName:m})=>{const[f,o]=x.useState(!1),v=x.useRef(null),_=x.useId(),p=x.useCallback(()=>o(!1),[]),{isParticipantBlocked:b,isCheckingBlockedStatus:g,isLeaving:y,isUpdatingBlockStatus:j,handleLeaveConversation:E,handleBlockUser:A,handleUnblockUser:M,handleReportUser:O}=Vs({channel:e,participant:t,showBlockParticipant:a,enabled:f,onLeaveConversation:i,onBlockParticipant:c,onDeleteConversationClick:l,onBlockParticipantClick:d,onReportParticipantClick:u,onActionComplete:p,logLabel:"ChannelActionsMenu"});return x.useEffect(()=>{if(!f)return;const R=T=>{v.current&&!v.current.contains(T.target)&&o(!1)},S=T=>{T.key==="Escape"&&o(!1)};return document.addEventListener("mousedown",R),document.addEventListener("keydown",S),()=>{document.removeEventListener("mousedown",R),document.removeEventListener("keydown",S)}},[f]),!t||!(n||a||r||!!h)?null:s.jsxs("div",{ref:v,className:"relative",children:[s.jsxs("button",{className:m,type:"button","aria-haspopup":"true","aria-expanded":f,"aria-controls":f?_:void 0,onClick:()=>o(R=>!R),children:[s.jsx(C.DotsThreeIcon,{className:"size-5 text-black/90"}),s.jsx("span",{className:"sr-only",children:"More options"})]}),f&&s.jsx("div",{id:_,"aria-label":"Conversation options",className:N("absolute right-0 top-full z-50 mt-2 w-56 overflow-hidden","rounded-lg border border-sand bg-white p-1 shadow-max-elevation-light"),children:s.jsxs("ul",{className:"flex flex-col gap-1",children:[n&&s.jsx("li",{children:s.jsxs(de,{onClick:E,disabled:y,"aria-busy":y,children:[y?s.jsx(C.SpinnerGapIcon,{className:"h-5 w-5 animate-spin"}):s.jsx(C.SignOutIcon,{className:"h-5 w-5"}),s.jsx("span",{children:"Delete Conversation"})]})}),a&&s.jsx("li",{children:g?s.jsxs(de,{disabled:!0,"aria-busy":!0,children:[s.jsx(C.SpinnerGapIcon,{className:"h-5 w-5 animate-spin"}),s.jsx("span",{children:"Block"})]}):b?s.jsxs(de,{onClick:M,disabled:j,"aria-busy":j,children:[j?s.jsx(C.SpinnerGapIcon,{className:"h-5 w-5 animate-spin"}):s.jsx(C.ProhibitInsetIcon,{className:"h-5 w-5"}),s.jsx("span",{children:"Unblock"})]}):s.jsxs(de,{onClick:A,disabled:j,"aria-busy":j,children:[j?s.jsx(C.SpinnerGapIcon,{className:"h-5 w-5 animate-spin"}):s.jsx(C.ProhibitInsetIcon,{className:"h-5 w-5"}),s.jsx("span",{children:"Block"})]})}),r&&s.jsx("li",{children:s.jsxs(de,{variant:"danger",onClick:O,children:[s.jsx(C.FlagIcon,{className:"h-5 w-5"}),s.jsx("span",{children:"Report"})]})}),h]})})]})},Pe="flex size-10 flex-shrink-0 items-center justify-center rounded-full bg-white/65 shadow-[0px_4px_8px_0px_rgba(0,0,0,0.06),0px_0px_0px_1px_rgba(0,0,0,0.04)] backdrop-blur-[40px] transition-filter duration-150 hover:brightness-95 aria-expanded:brightness-95 focus-ring",Ys="CUSTOMER_PAID",Ws=e=>typeof e=="string"&&e.trim().replace(/[\s-]+/g,"_").toUpperCase()===Ys,qs=({className:e,onBack:t,showBackButton:n,showStarButton:a=!1,onLeaveConversation:r,onBlockParticipant:i,showDeleteConversation:c=!0,showBlockParticipant:l=!0,showReportParticipant:d=!0,onDeleteConversationClick:u,onBlockParticipantClick:h,onReportParticipantClick:m,customChannelActions:f,renderChannelActions:o,showChannelInfo:v=!0,onParticipantNameClick:_})=>{var S,T,I,k;const{channel:p}=w.useChannelStateContext(),{client:b}=w.useChatContext(),g=x.useMemo(()=>{var L;return Ve((L=p.state)==null?void 0:L.members,b==null?void 0:b.userID,p.type)},[(S=p.state)==null?void 0:S.members,b==null?void 0:b.userID,p.type]),y=Ge(g==null?void 0:g.user),j=(T=g==null?void 0:g.user)==null?void 0:T.image,E=Kt(p),A=Ws((I=p.data)==null?void 0:I.customer_tag)&&(g==null?void 0:g.is_follower)===!0,M=a&&E,O=A||M||!!_,P=async()=>{try{E?await p.unpin():await p.pin()}catch(L){console.error("[ChannelHeaderRedesign] Failed to update pinned status:",L)}},R=s.jsxs(s.Fragment,{children:[s.jsx(me,{id:((k=g==null?void 0:g.user)==null?void 0:k.id)||p.id||"unknown",name:y,image:j,shape:"circle",size:48,className:"-mb-2"}),s.jsx("span",{className:N("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",O?"pl-3 pr-2":"px-3"),children:s.jsxs("span",{className:"flex max-w-full items-center justify-center",children:[s.jsx("span",{className:"min-w-0 truncate text-sm font-bold leading-[1.43] tracking-[0.28px] text-black/90",children:y}),O&&s.jsxs("span",{className:"ml-2 flex gap-1",children:[A&&s.jsx("span",{"aria-label":"Paid customer",className:"flex size-4 shrink-0 items-center justify-center rounded-full bg-[#34C759] text-white",children:s.jsx(C.CurrencyDollarIcon,{className:"size-2.5",weight:"bold"})}),M&&s.jsx("span",{className:"messaging-header-star-badge flex overflow-hidden",children:s.jsx("span",{"aria-label":"Starred conversation",className:"flex size-4 shrink-0 items-center justify-center rounded-full bg-[#FFD60A] text-white",children:s.jsx(C.StarIcon,{className:"size-2.5",weight:"fill"})})}),_&&s.jsx(C.CaretRightIcon,{"aria-hidden":"true",className:"size-4 shrink-0 text-black/65",weight:"bold"})]})]})})]});return s.jsx("div",{className:N("@container bg-[linear-gradient(180deg,#FBFAF9_0%,rgba(251,250,249,0.92)_58%,rgba(251,250,249,0)_100%)]",e),children:s.jsxs("div",{className:"grid min-h-[100px] grid-cols-[minmax(40px,1fr)_auto_minmax(40px,1fr)] items-start pb-2 pt-5 @lg:min-h-[104px] @lg:pt-6",children:[s.jsx("div",{className:"flex items-start",children:n&&s.jsx("button",{className:N(Pe,"messaging-channel-view-back-button-mobile messaging-channel-view-back-button-desktop"),onClick:t||(()=>{}),type:"button","aria-label":"Back to conversations",children:s.jsx(C.ArrowLeftIcon,{className:"size-5 text-black/90"})})}),s.jsx("div",{className:"flex min-w-0 justify-center","data-dd-privacy":"mask",children:_?s.jsx("button",{type:"button",onClick:_,"aria-label":`View details for ${y}`,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:R}):s.jsx("div",{className:"flex min-w-0 max-w-full flex-col items-center px-2",children:R})}),s.jsxs("div",{className:"flex items-start justify-end gap-2",children:[a&&s.jsx("button",{className:Pe,onClick:P,type:"button","aria-pressed":E,"aria-label":E?"Unstar conversation":"Star conversation",children:s.jsx(C.StarIcon,{className:N("size-5",{"text-[#FFD60A]":E,"text-black/90":!E}),weight:E?"fill":"regular"})}),v&&(o!==void 0?o:s.jsx(Gs,{channel:p,participant:g,showDeleteConversation:c,showBlockParticipant:l,showReportParticipant:d,onLeaveConversation:r,onBlockParticipant:i,onDeleteConversationClick:u,onBlockParticipantClick:h,onReportParticipantClick:m,customChannelActions:f,triggerClassName:Pe}))]})]})})},Xs=e=>s.jsx(w.DateSeparator,{...e,position:"center"});function Qt(e){return(e==null?void 0:e.trim().toLowerCase().split(/[-_]/)[0])||void 0}function Ye({message:e,viewerLanguage:t}){var r;const n=e==null?void 0:e.text,a=Qt(t);return a?((r=e==null?void 0:e.i18n)==null?void 0:r[`${a}_text`])??n:n}function Le(e){var t;return e.type==="link"||!!((t=e.og_scrape_url)!=null&&t.trim())&&!e.asset_url}const Ks={isUnlocking:()=>!1},Zs={LockedAttachment:Ks},es=x.createContext({}),Js=es.Provider;function ts(e){return x.useContext(es)[e]??Zs[e]}const Qs=x.lazy(()=>Promise.resolve().then(()=>require("./Card-Be81K6su.cjs"))),en=x.lazy(()=>Promise.resolve().then(()=>require("./Card-BGMEzK3U.cjs"))),tn=()=>s.jsx("div",{className:"w-[280px] min-h-[200px] animate-pulse rounded-md bg-black/[0.06] shadow-[0_0_0_1px_rgba(0,0,0,0.04),0_1px_2px_rgba(0,0,0,0.04),0_8px_32px_rgba(0,0,0,0.1)]","aria-hidden":!0}),pe=e=>s.jsx(x.Suspense,{fallback:s.jsx(tn,{}),children:e.contentType==="text"?s.jsx(Qs,{...e}):s.jsx(en,{...e})}),sn=({size:e=15})=>s.jsx("svg",{width:e,height:e,viewBox:"0 0 15 15",fill:"none","aria-hidden":"true",children:s.jsx("path",{d:"M12.003 9a.985.985 0 0 1-.652.934l-3.223 1.191-1.188 3.226a.995.995 0 0 1-1.867 0l-1.195-3.226L.65 9.937a.995.995 0 0 1 0-1.867l3.227-1.195 1.187-3.226a.995.995 0 0 1 1.868 0l1.195 3.226 3.226 1.187a.99.99 0 0 1 .649.938m3-5.83a.52.52 0 0 1-.344.492l-1.702.63-.627 1.703a.525.525 0 0 1-.986 0l-.63-1.704-1.704-.627a.525.525 0 0 1 0-.986l1.703-.63.627-1.704a.526.526 0 0 1 .986 0l.631 1.703 1.704.627a.52.52 0 0 1 .342.495",fill:"currentColor",fillOpacity:.55})}),ss=e=>{var t;return((t=e.metadata)==null?void 0:t.custom_type)===V.MESSAGE_CUSTOM_TYPE.PAID},Ie=e=>{var t;return((t=e.metadata)==null?void 0:t.custom_type)===V.MESSAGE_CUSTOM_TYPE.CHATBOT},We=e=>{var t;return((t=e.metadata)==null?void 0:t.custom_type)===V.MESSAGE_CUSTOM_TYPE.ATTACHMENT},nn=e=>{var t;return We(e)&&((t=e.metadata)==null?void 0:t.attachment_content_type)==="text"},an=e=>{var t;return We(e)&&((t=e.metadata)==null?void 0:t.attachment_content_type)!=="text"},rn=e=>{var t;return ss(e)&&!!((t=e.metadata)!=null&&t.amount_text)},Tt=({message:e,isMyMessage:t=!1,hasAttachment:n=!1})=>{var m;const a=ss(e),r=Ie(e);if(!a&&!r)return null;if(a){const f=(m=e.metadata)==null?void 0:m.amount_text;return f?s.jsxs("div",{className:"message-tag--paid inline-flex items-center gap-1 text-[12px] font-medium leading-[2] text-[#016630]",children:[s.jsx(C.GiftIcon,{size:12}),s.jsxs("span",{children:["Delivered with ",f," message"]})]}):null}const i=t&&n,c=i?"Sent with AI":"Sent by AI Assistant",l="inline-flex items-center text-[10px] font-normal leading-4 tracking-[0.2px]",d=i?"justify-end gap-2 text-black/30":t?"w-full justify-start gap-1.5 mt-3 px-4 text-white/55":"w-full justify-start gap-1.5 mt-3 px-4 text-black/30",u=s.jsx("span",{className:"text-left",children:c}),h=s.jsx("span",{className:"inline-flex items-center leading-none",children:s.jsx(sn,{size:i?12:15})});return s.jsx("div",{className:`${l} ${d}`,"data-testid":"message-chatbot-indicator",children:t&&!i?s.jsxs(s.Fragment,{children:[u,h]}):s.jsxs(s.Fragment,{children:[h,u]})})},At=`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%`,on={me:"var(--str-chat__own-message-bubble-background-color, #1e2330)",other:"var(--str-chat__message-bubble-background-color, #f1f0ee)"},Te=({side:e})=>s.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute bottom-0 z-[-1] h-[1.4375rem] w-5",style:{insetInlineEnd:e==="me"?"calc(-1 * 0.3125rem)":void 0,insetInlineStart:e==="other"?"calc(-1 * 0.3125rem)":void 0,transform:e==="other"?"scaleX(-1)":void 0,transformOrigin:"center",backgroundColor:on[e],WebkitMask:At,mask:At}}),ns=x.createContext(void 0),ln=e=>{var n;const t=(n=e.metadata)==null?void 0:n.outbound_id;return typeof t=="string"?t:void 0},cn=(e,t)=>{if(!t||!(e!=null&&e.length))return;const n=new Set;let a;for(const r of e){const i=ln(r);if(!i||n.has(i))continue;n.add(i);const c=t(i);c&&(a??(a={}),a[i]={id:c.id,...c.name!==void 0?{name:c.name}:{}})}return a},dn=(e,t)=>{if(e===t)return!0;if(!e||!t)return!1;const n=Object.keys(e),a=Object.keys(t);return n.length!==a.length?!1:n.every(r=>{var i,c;return e[r].id===((i=t[r])==null?void 0:i.id)&&e[r].name===((c=t[r])==null?void 0:c.name)})},un=(e,t)=>{const n=cn(e,t),[a,r]=x.useState(n);return dn(a,n)?a:(r(n),n)},qe=e=>{var t;return((t=e.metadata)==null?void 0:t.custom_type)===V.MESSAGE_CUSTOM_TYPE.TIP},as=({message:e})=>{var n;const t=(n=e.metadata)==null?void 0:n.amount_text;return t?s.jsxs("div",{className:"message-tip-pill inline-flex items-end gap-0.5 max-w-[520px] rounded-[1.5rem] bg-[#43e660] px-4 py-3 text-white",children:[s.jsx("span",{className:"flex h-5 items-center text-[20px] leading-none","aria-hidden":"true",children:"🎁"}),s.jsxs("span",{className:"text-[14px] font-bold leading-[1.43] tracking-[0.28px] text-[rgba(4,4,3,0.9)]",children:[t," tip!"]})]}):null},Xe=()=>{const{message:e}=w.useMessageContext("SentMessageDeliveryStatus"),{messages:t}=w.useChannelStateContext("SentMessageDeliveryStatus"),n=(()=>{if(t)for(let a=t.length-1;a>=0;a-=1){const r=t[a];if(!(r.type==="system"||r.type==="ephemeral"||r.type==="deleted"))return r.id}})();return e.id===n},ke=()=>Xe()?s.jsxs(s.Fragment,{children:[s.jsx(C.ChecksIcon,{weight:"bold","aria-hidden":"true"}),s.jsx("span",{"data-testid":"sent-message-delivery-status",children:"Delivered"})]}):null,mn=()=>Xe()?s.jsxs(s.Fragment,{children:[s.jsx(C.CircleNotchIcon,{className:"sent-message-status__spinner animate-spin",weight:"bold","aria-hidden":"true"}),s.jsx("span",{"data-testid":"sent-message-sending-status",children:"Sending"})]}):null,hn=({outbound:e,onOutboundClick:t})=>{const n=e.name||"Broadcast",a=!!t,r=s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"sent-message-outbound-badge","aria-hidden":"true",children:s.jsx(C.MegaphoneIcon,{weight:"fill"})}),s.jsx("span",{className:N("sent-message-outbound-name",{"underline [text-decoration-skip-ink:auto]":a}),"data-testid":"sent-message-outbound-status",children:n})]});return t?s.jsx("button",{type:"button",className:"inline-flex cursor-pointer items-center gap-1 border-0 bg-transparent p-0 text-inherit [font:inherit]","aria-label":`View broadcast ${n}`,onClick:()=>t(e),children:r}):r},xn=()=>s.jsxs("span",{className:"str-chat__message-status sent-message-status--failed",children:[s.jsx(C.WarningCircleIcon,{weight:"bold","aria-hidden":"true"}),s.jsx("span",{"data-testid":"sent-message-failed-status",children:"Failed to send"})]}),fn=({onOutboundClick:e,resolvedOutbound:t})=>{var h;const{isMyMessage:n,message:a,threadList:r}=w.useMessageContext("SentMessageDeliveryStatus"),i=n(),c=Xe();if(r)return null;if(a.status==="failed"&&i&&a.type!=="error")return s.jsx(xn,{});if(!i)return null;const l=(h=a.metadata)==null?void 0:h.outbound_id,d=a.status!=="sending"&&a.status!=="failed"&&l&&t?s.jsx(hn,{outbound:t,onOutboundClick:e}):null,u=rn(a)?null:s.jsx(w.MessageStatus,{MessageSentStatus:ke,MessageDeliveredStatus:ke,MessageReadStatus:ke,MessageSendingStatus:qe(a)?ke:mn});return d?s.jsxs("span",{className:"sent-message-status-row",children:[u,u&&c&&s.jsx("span",{className:"sent-message-outbound-separator","aria-hidden":"true",children:"•"}),d]}):u},gn=["linktr.ee"],Mt="messaging-attachment-v1_0";function pn(e){try{return new URL(e).hostname.toLowerCase()}catch{return null}}function bn(e){return gn.some(t=>e===t||e.endsWith(`.${t}`))}function he(e){const t=e==null?void 0:e.trim();if(!t)return;const n=pn(t);if(!n||!bn(n))return t;const a=new URL(t);return a.searchParams.get("io")==="true"&&a.searchParams.get("size")===Mt?t:(a.searchParams.set("io","true"),a.searchParams.set("size",Mt),a.toString())}const vn=/^([a-z][a-z0-9+.-]*):/i,jn=new Set(["http","https","mailto","tel","sms"]);function Ke(e){if(typeof e!="string")return;const t=e.trim();if(t==="")return;const n=vn.exec(t);if(n){const a=n[1].toLowerCase();return jn.has(a)?t:void 0}return t.startsWith("//")||t.startsWith("/")?t:`https://${t}`}const wn={dark:{primary:"bg-white text-[#121110] hover:bg-white/90",secondary:"bg-white/15 text-white hover:bg-white/25"},light:{primary:"bg-[#121110] text-white hover:bg-[#2a2928]",secondary:"bg-black/[0.06] text-[#121110] hover:bg-black/10"}},rs=({variant:e,cta:t,fullWidth:n=!0,standalone:a=!1})=>{const r=t.variant??"primary",i=N("inline-flex h-10 items-center justify-center rounded-full px-4 text-sm font-medium leading-none transition-colors",n?"w-full":"min-w-0",!a&&"mt-2",wn[e][r]),c=n?t.label:s.jsx("span",{className:"min-w-0 truncate",children:t.label}),l=Ke(t.href);return l?s.jsx("a",{href:l,target:"_blank",rel:"noopener noreferrer",onClick:d=>{var u;d.stopPropagation(),(u=t.onClick)==null||u.call(t)},className:`${i} no-underline`,children:c}):s.jsx("button",{type:"button",onClick:d=>{var u;d.stopPropagation(),(u=t.onClick)==null||u.call(t)},className:i,children:c})},_n={dark:"text-white",light:"text-black/90"},yn="text-white/30",Rt={dark:"text-white/55",light:"text-black/55"},Nn={dark:"bg-white/25",light:"bg-black/15"},Ze=({variant:e,ctaSurface:t,chinTextColor:n,title:a,placeholderTitle:r,description:i,descriptionLines:c=1,url:l,appIcon:d,cta:u,trailingAction:h,isLoading:m=!1})=>{const f=e==="dark",o=a??(f?r:void 0)??"",v=o.trim()!=="",_=i!=null&&i.trim()!=="",p=typeof l=="string"?l.trim():"",b=p!=="",g=u!=null;if(!m&&!v&&!_&&!b&&!g)return null;const y=f&&!a,j=N("line-clamp-2 text-[14px] font-medium leading-5 tracking-[0.28px]",n==null&&(y?yn:_n[e])),E=N("truncate text-[12px] leading-4 tracking-[0.24px]",n==null&&Rt[e]),A=N("text-[12px] leading-4 tracking-[0.24px]",c<=1&&"truncate",n==null&&Rt[e]);if(m){const P=N("animate-pulse rounded",Nn[e]);return s.jsx("div",{className:"shrink-0 px-4 py-3",children:s.jsxs("div",{className:"flex min-w-0 flex-col gap-[2px]",children:[s.jsx("div",{className:N("h-5 w-3/4",P),"aria-hidden":!0}),s.jsx("div",{className:N("h-4 w-1/2",P),"aria-hidden":!0})]})})}const M=n?{color:n}:void 0,O=c>1?{...M,display:"-webkit-box",WebkitBoxOrient:"vertical",WebkitLineClamp:c,overflow:"hidden"}:M;return s.jsxs("div",{className:"shrink-0 px-4 py-3",children:[s.jsxs("div",{className:"flex items-end gap-3",children:[s.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-[2px]",children:[v&&s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[d?s.jsx("span",{className:"shrink-0",children:d}):null,s.jsx("p",{className:N("min-w-0",j),style:M,children:o})]}),_&&s.jsx("p",{className:A,style:O,children:i}),!g&&b&&s.jsx("p",{className:E,style:M,"data-testid":"link-attachment-url",children:p})]}),h&&s.jsx("div",{className:"shrink-0",children:h})]}),u&&s.jsx(rs,{variant:t??e,cta:u})]})},Cn="Loading link preview",Sn=N("relative max-w-[var(--lt-msg-card-width,290px)] w-full select-none overflow-hidden","rounded-[20px]"),kn="flex h-[250px] flex-col",ve=({variant:e,children:t,href:n,onClick:a,ariaLabel:r,rootRef:i,topRight:c,bgClassName:l,accentHex:d,fixedHeight:u=!1,busy:h=!1,"data-testid":m})=>{const f=n!=null||a!=null,o=N("messaging-link-card",Sn,u?kn:"block",l??(e==="dark"?"bg-[#1e2330]":"bg-[#f1f0ee]"),f?"cursor-pointer no-underline focus-ring":null),v=h?{role:"status","aria-busy":!0,"aria-label":Cn}:void 0,_=d?{"--accent":d}:void 0,p=c?s.jsx("div",{className:"pointer-events-auto absolute right-3 top-3 z-10",children:c}):null;return n?s.jsxs("a",{ref:i,href:n,target:"_blank",rel:"noopener noreferrer",onClick:a,"data-testid":m,"data-variant":e,className:o,style:_,...v,children:[t,p]}):a?s.jsxs("button",{ref:i,type:"button",onClick:a,"aria-label":r,"data-testid":m,"data-variant":e,className:N(o,"text-left"),style:_,...v,children:[t,p]}):s.jsxs("div",{ref:i,"data-testid":m,"data-variant":e,className:o,style:_,...v,children:[t,p]})},En=[[/pdf/,"pdf"],[/wordprocessingml|msword|\.doc/,"doc"],[/spreadsheetml|ms-excel|\.xls/,"xls"],[/csv/,"csv"],[/presentationml|ms-powerpoint|\.ppt/,"ppt"],[/zip|x-rar|x-7z|x-tar|x-gzip/,"zip"],[/plain|rtf/,"text"],[/markdown/,"markdown"]];function xe(e){return e.startsWith("video/")?"video":e.startsWith("audio/")?"audio":e.startsWith("image/")?"image":"document"}function is(e){const t=En.find(([n])=>n.test(e));return t?t[1]:"generic"}const In={video:C.VideoCameraIcon,audio:C.SpeakerHighIcon,image:C.ImageIcon,document:C.FileIcon},Tn={pdf:C.FilePdfIcon,doc:C.FileDocIcon,xls:C.FileXlsIcon,csv:C.FileCsvIcon,ppt:C.FilePptIcon,zip:C.FileZipIcon,text:C.FileTextIcon,markdown:C.FileMdIcon,generic:C.FileIcon};function An(e){const t=xe(e);return t!=="document"?In[t]:Tn[is(e)]}function Je(e,t){return x.createElement(An(e),t)}const Lt={dark:"bg-white/10",light:"bg-black/5"},Mn={dark:"size-16 text-white/25",light:"size-16 text-black/25"},we=(e,t)=>!!t&&!!e&&xe(e)==="audio",Qe=(e,t)=>{if(!t||!e)return!1;const n=xe(e);return n==="video"||n==="audio"},et="bg-[#F2F3F4]",je=({variant:e,thumbnailUrl:t,sourceUrl:n,title:a,mimeType:r="image/*",topLeft:i,topRight:c,isLoading:l=!1,onImageError:d})=>{const u=xe(r),h=!!n&&u==="video",m=he(t);return!l&&we(r,n)?s.jsx("div",{className:"p-3",children:s.jsx("audio",{src:n,controls:!0,preload:"metadata",className:"block w-full",children:s.jsx("track",{kind:"captions"})})}):s.jsxs("div",{className:N("relative min-h-0 w-full flex-1 overflow-hidden",h&&"bg-black"),children:[l?s.jsx("div",{className:N("h-full w-full animate-pulse",Lt[e]),"aria-hidden":!0}):h?s.jsxs(s.Fragment,{children:[s.jsx("video",{src:n,poster:m,controls:!0,playsInline:!0,preload:"metadata",className:"absolute inset-0 h-full w-full object-contain",children:s.jsx("track",{kind:"captions"})}),m&&d?s.jsx("img",{src:m,alt:"","aria-hidden":!0,onError:d,className:"hidden"}):null]}):t?s.jsx("img",{src:m??t,alt:a??"",draggable:!1,loading:"lazy",decoding:"async",onError:d,className:"absolute inset-0 h-full w-full object-cover"}):s.jsx("div",{className:N("flex h-full w-full items-center justify-center",Lt[e]),children:Je(r,{className:Mn[e],weight:"regular"})}),i?s.jsx("div",{className:"pointer-events-auto absolute left-3 top-3 z-10",children:i}):null,c?s.jsx("div",{className:"pointer-events-auto absolute right-3 top-3 z-10",children:c}):null]})},Rn=/^#?(?:[0-9a-f]{3}|[0-9a-f]{6})$/i;function Ln(e){const t=e.trim();return t.startsWith("#")?t:`#${t}`}const On="#FFFFFF",os="#040403",Dn={dark:On,light:os};function Oe({variant:e,accentColor:t,status:n="ready",layout:a="featured",thumbnailUrl:r,mimeType:i,sourceUrl:c}){const[l,d]=x.useState(!1);x.useEffect(()=>{d(!1)},[r]);const u=x.useCallback(()=>{d(!0)},[]),h=we(i,c),o=a==="featured"&&!!r&&!h&&!l&&n==="ready"&&t!=null&&Rn.test(t.trim())?Ln(t):void 0,v=h?os:Dn[e];return{thumbnailUrl:l?void 0:r,accentHex:o,chinTextColor:v,surface:h?"light":e,isLoading:n==="loading",onImageError:u}}const Fn="flex size-6 items-center justify-center rounded-full bg-[#121110] text-white focus-ring",Pn="relative before:absolute before:-inset-[10px] before:content-['']",Bn=({title:e,placeholderTitle:t,description:n,descriptionLines:a,url:r,mimeType:i,thumbnailUrl:c,sourceUrl:l,layout:d="featured",appIcon:u,cta:h,accentColor:m,status:f="ready",onDismiss:o,onEditClick:v,dismissLabel:_="Dismiss attachment"})=>{const p=d==="classic",b=we(i,l),g=Oe({variant:"dark",accentColor:m,status:f,layout:d,thumbnailUrl:c,mimeType:i,sourceUrl:l}),y=o?s.jsx("button",{type:"button",onClick:o,"aria-label":_,className:N(Fn,!b&&Pn),children:s.jsx(C.XIcon,{className:"size-3",weight:"bold"})}):void 0,j=v?s.jsx("button",{type:"button",onClick:v,"aria-label":"Edit attachment",className:"flex size-10 items-center justify-center rounded-full bg-white/10 text-white hover:bg-white/15",children:s.jsx(C.PencilSimpleIcon,{className:"size-5",weight:"regular"})}):void 0;return b&&!g.isLoading?s.jsx(ve,{variant:"dark",bgClassName:et,children:s.jsxs("div",{className:"flex items-center gap-2 pr-3",children:[s.jsx("div",{className:"min-w-0 flex-1",children:s.jsx(je,{variant:"dark",sourceUrl:l,title:e,mimeType:i})}),y&&s.jsx("div",{className:"shrink-0",children:y})]})}):s.jsxs(ve,{variant:"dark",fixedHeight:!p,accentHex:g.accentHex,busy:g.isLoading,topRight:p?y:void 0,children:[!p&&s.jsx(je,{variant:"dark",thumbnailUrl:g.thumbnailUrl,sourceUrl:l,title:e,mimeType:i,topRight:y,isLoading:g.isLoading,onImageError:g.onImageError}),s.jsx(Ze,{chinTextColor:g.chinTextColor,variant:"dark",ctaSurface:g.surface,title:e,placeholderTitle:t,description:n,descriptionLines:a,url:r,appIcon:u,cta:h,trailingAction:j,isLoading:g.isLoading})]})},tt=({accentHex:e,side:t,visible:n,children:a})=>{if(!n)return s.jsx(s.Fragment,{children:a});const r=t==="sender"?"dark":"light",i=e?{"--accent":e}:void 0;return s.jsxs("div",{className:"relative isolate w-full max-w-[var(--lt-msg-card-width,290px)]",children:[a,s.jsx("span",{"aria-hidden":!0,"data-testid":"link-card-tail","data-variant":r,style:i,className:N("messaging-link-card-tail",t==="receiver"&&"messaging-link-card-tail--received")})]})},zn=({title:e,description:t,descriptionLines:n,url:a,mimeType:r,thumbnailUrl:i,sourceUrl:c,layout:l="featured",appIcon:d,cta:u,accentColor:h,status:m="ready",onClick:f,groupPosition:o="single"})=>{const v=Qe(r,c),_=Ke(a),p=u==null&&_!=null&&!v?_:void 0,b=u==null&&!v?f:void 0,g=m!=="loading"&&we(r,c)?et:void 0,y=u&&f?{...u,onClick:()=>{var E;f(),(E=u.onClick)==null||E.call(u)}}:u,j=Oe({variant:"light",accentColor:h,status:m,layout:l,thumbnailUrl:i,mimeType:r,sourceUrl:c});return s.jsx(tt,{accentHex:j.accentHex,side:"receiver",visible:g==null&&(o==="single"||o==="end"),children:s.jsxs(ve,{variant:"light",href:p,onClick:b,ariaLabel:e??"Open attachment preview",fixedHeight:l==="featured"&&g==null,accentHex:j.accentHex,busy:j.isLoading,bgClassName:g,"data-testid":"link-attachment",children:[l==="featured"&&s.jsx(je,{variant:"light",thumbnailUrl:j.thumbnailUrl,sourceUrl:c,title:e,mimeType:r,isLoading:j.isLoading,onImageError:j.onImageError}),s.jsx(Ze,{chinTextColor:j.chinTextColor,variant:"light",ctaSurface:j.surface,title:e,description:t,descriptionLines:n,url:a,appIcon:d,cta:y,isLoading:j.isLoading})]})})},$n=({title:e,placeholderTitle:t,description:n,descriptionLines:a,url:r,mimeType:i,thumbnailUrl:c,sourceUrl:l,layout:d="featured",appIcon:u,cta:h,accentColor:m,status:f="ready",onClick:o,groupPosition:v="single"})=>{const _=Qe(i,l),p=Ke(r),b=h==null&&p!=null&&!_?p:void 0,g=h==null&&!_&&b!=null?o:void 0,y=f!=="loading"&&we(i,l),j=Oe({variant:"dark",accentColor:m,status:f,layout:d,thumbnailUrl:c,mimeType:i,sourceUrl:l});return s.jsx(tt,{accentHex:j.accentHex,side:"sender",visible:!y&&(v==="single"||v==="end"),children:s.jsxs(ve,{variant:"dark",href:b,onClick:g,fixedHeight:d==="featured"&&!y,accentHex:j.accentHex,busy:j.isLoading,bgClassName:y?et:void 0,children:[d==="featured"&&s.jsx(je,{variant:"dark",thumbnailUrl:j.thumbnailUrl,sourceUrl:l,title:e,mimeType:i,isLoading:j.isLoading,onImageError:j.onImageError}),s.jsx(Ze,{chinTextColor:j.chinTextColor,variant:"dark",ctaSurface:j.surface,title:e,placeholderTitle:t,description:n,descriptionLines:a,url:r,appIcon:u,cta:h,isLoading:j.isLoading})]})})},Ae={Composer:Bn,Sent:$n,Received:zn},Un={dark:"bg-[#1e2330]",light:"bg-[#f2f1ef]"},Hn={dark:"text-white",light:"text-[#000000]"},Vn={dark:"border-white/[0.08]",light:"border-black/[0.08]"},Gn=e=>e==="dark"?"sender":"receiver",Yn={sender:{single:"rounded-tl-[18px] rounded-tr-[18px] rounded-bl-[18px] rounded-br-[18px]",first:"rounded-tl-[18px] rounded-tr-[18px] rounded-bl-[18px] rounded-br-[4px]",middle:"rounded-tl-[18px] rounded-tr-[4px] rounded-bl-[18px] rounded-br-[4px]",end:"rounded-tl-[18px] rounded-tr-[4px] rounded-bl-[18px] rounded-br-[18px]"},receiver:{single:"rounded-tl-[18px] rounded-tr-[18px] rounded-bl-[18px] rounded-br-[18px]",first:"rounded-tl-[18px] rounded-tr-[18px] rounded-bl-[4px] rounded-br-[18px]",middle:"rounded-tl-[4px] rounded-tr-[18px] rounded-bl-[4px] rounded-br-[18px]",end:"rounded-tl-[4px] rounded-tr-[18px] rounded-bl-[18px] rounded-br-[18px]"}},_e=({variant:e,text:t,bordered:n=!0,groupPosition:a="single",widthClassName:r="w-[280px]",paddingClassName:i="px-2 py-2",radiusClassName:c,className:l,children:d,"data-testid":u})=>{const h=t!=null&&t!=="",m=c??Yn[Gn(e)][a];return s.jsxs("div",{"data-testid":u,"data-group-position":a,className:N("relative",r,"overflow-hidden",i,h&&"pb-0",m,Un[e],Hn[e],n&&"border",n&&Vn[e],l),children:[d,h?s.jsx("p",{className:N("whitespace-pre-wrap break-words leading-snug hyphens-manual","pb-2 pt-2","px-2"),children:t}):null]})},ye=({onClick:e,variant:t="overlay",ariaLabel:n="Dismiss attachment"})=>s.jsx("button",{type:"button",onClick:a=>{a.stopPropagation(),e()},"aria-label":n,className:N("flex size-6 items-center justify-center rounded-full text-white",t==="overlay"?"bg-[#121110]/85 backdrop-blur":"bg-white/15 hover:bg-white/25"),children:s.jsx(C.XIcon,{className:"size-3",weight:"bold"})}),Ne=e=>e==="received"?"light":"dark",Wn=({firstOfGroup:e,endOfGroup:t,groupedByUser:n})=>!n||e&&t?"single":e?"first":t?"end":"middle",qn=({src:e,mimeType:t,filename:n,items:a})=>a&&a.length>0?a:e?[{src:e,mimeType:t,filename:n}]:[],Xn=({item:e,preload:t,trailingAction:n})=>s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("audio",{src:e.src,controls:!0,preload:e.preload??t,className:"block min-w-0 flex-1",children:e.mimeType?s.jsx("source",{src:e.src,type:e.mimeType}):null}),n??null]}),st=({state:e,src:t,mimeType:n,filename:a,items:r,text:i,groupPosition:c,preload:l,onDismiss:d})=>{const u=Ne(e),h=e==="composer"&&!!d,m=qn({src:t,mimeType:n,filename:a,items:r});if(m.length===0)return null;const f=l??(m.length>1?"none":"metadata");return s.jsx(_e,{variant:u,text:i,groupPosition:c,"data-testid":"audio-attachment",children:s.jsx("div",{className:"flex flex-col gap-2",children:m.map((o,v)=>s.jsx(Xn,{item:o,preload:f,trailingAction:h&&v===0?s.jsx(ye,{onClick:d,variant:"inline"}):void 0},`${o.src}-${v}`))})})},Kn=e=>s.jsx(st,{...e,state:"composer"}),Zn=e=>s.jsx(st,{...e,state:"sent"}),Jn=e=>s.jsx(st,{...e,state:"received"}),Qn={Composer:Kn,Sent:Zn,Received:Jn};function ls(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 ea={pdf:"PDF",doc:"DOC",xls:"XLS",csv:"CSV",ppt:"PPT",zip:"ZIP",text:"TXT",markdown:"MD"};function cs(e,t){if(t){const r=t.lastIndexOf(".");if(r>0&&r<t.length-1){const i=t.slice(r+1);if(i&&i.length<=5)return i.toUpperCase()}}if(!e)return;if(xe(e)==="document"){const r=is(e),i=ea[r];if(i)return i;if(e==="application/octet-stream")return}const a=e.split("/")[1];if(!(!a||a==="*"))return a.toUpperCase()}function ds(e,t,n){const a=cs(e,t),r=typeof n=="number"&&n>0?ls(n):void 0;return[a,r].filter(Boolean).join(" · ")||void 0}function se(e){try{const n=new URL(e).pathname.split("/").pop();return n&&n.length>0?decodeURIComponent(n):"download"}catch{return"download"}}const ta={dark:"text-white/55",light:"text-black/65"},sa={dark:"bg-white/10",light:"bg-black/5"},na={dark:"text-white/85",light:"text-black/85"},us=({variant:e,filename:t,title:n,mimeType:a="application/octet-stream",fileSize:r,onActivate:i,activateLabel:c,trailingAction:l})=>{const d=n??t??"File",u=ds(a,t,r),h=s.jsx("div",{className:N("flex size-10 shrink-0 items-center justify-center rounded-sm",sa[e]),"aria-hidden":!0,children:Je(a,{className:N("size-6",na[e]),weight:"regular"})}),m=s.jsxs("div",{className:"flex min-w-0 flex-1 flex-col text-left",children:[s.jsx("p",{className:"truncate font-medium leading-snug",children:d}),u?s.jsx("p",{className:N("truncate text-xs leading-4",ta[e]),children:u}):null]}),f=i?s.jsxs("button",{type:"button",onClick:i,"aria-label":c,className:N("flex min-w-0 flex-1 items-center gap-3 rounded-sm text-left transition-colors",e==="dark"?"hover:bg-white/[0.04]":"hover:bg-black/[0.04]"),children:[h,m]}):s.jsxs(s.Fragment,{children:[h,m]});return s.jsxs("div",{className:"flex items-center gap-3 px-3 py-2",children:[f,l?s.jsx("div",{className:"shrink-0",children:l}):null]})};async function ms(e,t){const n=t??se(e);try{const a=await fetch(e,{mode:"cors"});if(!a.ok)throw new Error(`HTTP ${a.status}`);const r=await a.blob(),i=URL.createObjectURL(r),c=document.createElement("a");c.href=i,c.download=n,c.style.display="none",document.body.appendChild(c),c.click(),document.body.removeChild(c),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 aa=({src:e,filename:t,fileSize:n,mimeType:a,title:r,items:i})=>i&&i.length>0?i:e?[{src:e,filename:t,fileSize:n,mimeType:a,title:r}]:[],ra=({variant:e,item:t,index:n,onActivate:a,trailingAction:r})=>{const i=t.filename??se(t.src);return s.jsx(us,{variant:e,filename:i,title:t.title,mimeType:t.mimeType??"application/octet-stream",fileSize:t.fileSize,onActivate:()=>a(n),activateLabel:`Download ${i}`,trailingAction:r})},nt=({state:e,src:t,filename:n,fileSize:a,mimeType:r,title:i,items:c,text:l,groupPosition:d,onClick:u,onDismiss:h})=>{const m=Ne(e),f=e==="composer"&&!!h,o=aa({src:t,filename:n,fileSize:a,mimeType:r,title:i,items:c}),v=p=>{if((u==null?void 0:u(p))===!1)return;const b=o[p];if(!b)return;const g=b.filename??se(b.src);ms(b.src,g)};if(o.length===0)return null;const _=s.jsx("span",{className:N("flex size-8 items-center justify-center rounded-full",m==="dark"?"text-white/70":"text-black/70"),"aria-hidden":!0,children:s.jsx(C.DownloadSimpleIcon,{className:"size-5",weight:"bold"})});return s.jsx(_e,{variant:m,text:l,groupPosition:d,"data-testid":"file-attachment",children:s.jsx("div",{className:"flex flex-col gap-2",children:o.map((p,b)=>{const g=f&&b===0?s.jsx(ye,{onClick:h,variant:"inline"}):_;return s.jsx(ra,{variant:m,item:p,index:b,onActivate:v,trailingAction:g},`${p.src}-${b}`)})})})},ia=e=>s.jsx(nt,{...e,state:"composer"}),oa=e=>s.jsx(nt,{...e,state:"sent"}),la=e=>s.jsx(nt,{...e,state:"received"}),ca={Composer:ia,Sent:oa,Received:la},hs="inline-flex size-10 items-center justify-center rounded-full border-0 bg-white/[0.12] p-0 text-white transition-colors duration-150 ease-[ease] hover:bg-white/[0.22] focus-visible:bg-white/[0.22] focus-visible:outline-none disabled:cursor-default disabled:opacity-40",Ot="absolute top-1/2 z-[1] inline-flex size-12 -translate-y-1/2 items-center justify-center rounded-full border-0 bg-white/[0.12] p-0 text-white transition-colors duration-150 ease-[ease] hover:bg-white/[0.22] focus-visible:bg-white/[0.22] focus-visible:outline-none",at=({onPrev:e,onNext:t,prevLabel:n="Previous",nextLabel:a="Next"})=>s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",onClick:e,"aria-label":n,className:`${Ot} left-4`,children:s.jsx(C.CaretLeftIcon,{size:20,weight:"bold","aria-hidden":!0})}),s.jsx("button",{type:"button",onClick:t,"aria-label":a,className:`${Ot} right-4`,children:s.jsx(C.CaretRightIcon,{size:20,weight:"bold","aria-hidden":!0})})]}),xs=({url:e,filename:t,variant:n="pill",label:a="Download",iconOnly:r,tone:i="dark",onTriggered:c})=>{const[l,d]=x.useState(!1),u=x.useCallback(o=>{o.stopPropagation(),!l&&(d(!0),ms(e,t).catch(()=>{}).finally(()=>{d(!1),c==null||c()}))},[l,e,t,c]),h=r??n!=="pill",f={className:N(n==="pill"?"size-4":"size-5","shrink-0"),weight:"bold"};if(n==="inline"){const o={dark:"text-white/70 hover:bg-white/[0.08] hover:text-white",light:"text-black/70 hover:bg-black/[0.08] hover:text-black"};return s.jsx("button",{type:"button",onClick:u,disabled:l,"aria-label":a,className:N("flex size-8 shrink-0 items-center justify-center rounded-full transition-colors disabled:opacity-70",o[i]),children:l?s.jsx(C.CircleNotchIcon,{className:"size-4 animate-spin",weight:"bold","aria-hidden":!0}):s.jsx(C.DownloadSimpleIcon,{className:"size-5 shrink-0",weight:"bold","aria-hidden":!0})})}return n==="viewer"?s.jsx("button",{type:"button",onClick:u,disabled:l,"aria-label":a,className:hs,children:l?s.jsx(C.CircleNotchIcon,{size:20,weight:"bold","aria-hidden":!0}):s.jsx(C.DownloadSimpleIcon,{size:20,weight:"bold","aria-hidden":!0})}):s.jsxs("button",{type:"button",onClick:u,disabled:l,"aria-label":h?a:void 0,className:N("mt-3 inline-flex h-10 w-full items-center justify-center gap-2 rounded-full px-4 text-sm font-medium leading-none transition-colors disabled:opacity-70",i==="dark"?"bg-[#121110] text-white hover:bg-[#2a2928]":"bg-white text-[#121110] hover:bg-white/90"),children:[l?s.jsx(C.CircleNotchIcon,{className:"size-4 animate-spin",weight:"bold","aria-hidden":!0}):s.jsx(C.DownloadSimpleIcon,{...f,"aria-hidden":!0}),h?null:a]})},Be=(e,t,n)=>Math.min(Math.max(e,t),n),rt=({length:e,initialIndex:t,open:n})=>{const a=Be(t,0,Math.max(e-1,0)),[r,i]=x.useState(a);x.useEffect(()=>{n&&i(Be(t,0,Math.max(e-1,0)))},[n,t,e]),x.useEffect(()=>{i(d=>Be(d,0,Math.max(e-1,0)))},[e]);const c=x.useCallback(()=>{e<=1||i(d=>d<=0?e-1:d-1)},[e]),l=x.useCallback(()=>{e<=1||i(d=>d>=e-1?0:d+1)},[e]);return x.useEffect(()=>{if(!n||e<=1)return;const d=u=>{if(u.key!=="ArrowLeft"&&u.key!=="ArrowRight")return;const h=document.activeElement;h&&(h.tagName==="VIDEO"||h.tagName==="AUDIO")||(u.preventDefault(),u.key==="ArrowLeft"?c():l())};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[n,e,c,l]),{index:r,prev:c,next:l}},it=({open:e,onClose:t,ariaLabel:n,counter:a,actions:r,children:i,"data-testid":c})=>{const l=x.useRef(null),d=x.useRef(null);x.useEffect(()=>{var f;const m=l.current;if(m){if(e){if(!m.open)if(typeof m.showModal=="function")try{m.showModal()}catch{m.setAttribute("open","")}else m.setAttribute("open","");const o=typeof document<"u"?document.activeElement:null;return(f=d.current)==null||f.focus(),()=>{if(m.open)if(typeof m.close=="function")try{m.close()}catch{m.removeAttribute("open")}else m.removeAttribute("open");o&&document.body.contains(o)&&o.focus()}}if(m.open)if(typeof m.close=="function")try{m.close()}catch{m.removeAttribute("open")}else m.removeAttribute("open")}},[e]);const u=()=>{t()},h=m=>{m.target===l.current&&t()};return s.jsxs("dialog",{ref:l,className:"mes-media-viewer","aria-label":n??"Attachment viewer","data-testid":c,onClose:u,onClick:h,children:[s.jsxs("div",{className:"pointer-events-none absolute inset-x-3 top-3 z-[1] flex items-center justify-between gap-3",children:[a?s.jsx("span",{className:"pointer-events-auto inline-flex items-center rounded-full bg-white/[0.12] px-3 py-1.5 text-[13px] font-medium leading-none tabular-nums text-white",children:a}):null,s.jsxs("div",{className:"pointer-events-auto ml-auto inline-flex items-center gap-2",children:[r,s.jsx("button",{ref:d,type:"button",onClick:t,"aria-label":"Close viewer",className:hs,children:s.jsx(C.XIcon,{size:20,weight:"bold","aria-hidden":!0})})]})]}),s.jsx("div",{className:"box-border flex h-full w-full items-center justify-center px-6 py-16",children:i})]})},fs=({open:e,items:t,initialIndex:n=0,onClose:a})=>{const{index:r,prev:i,next:c}=rt({length:t.length,initialIndex:n,open:e}),l=t[r],d=x.useMemo(()=>(l==null?void 0:l.filename)??(l?se(l.src):"image"),[l]);return l?s.jsxs(it,{open:e,onClose:a,ariaLabel:d,counter:t.length>1?`${r+1} / ${t.length}`:void 0,actions:s.jsx(xs,{url:l.src,filename:d,variant:"viewer",label:`Download ${d}`}),"data-testid":"image-viewer",children:[e?s.jsx("img",{src:l.src,alt:l.alt??d,draggable:!1,decoding:"async",className:"block h-auto max-h-[calc(100dvh-128px)] w-auto max-w-[min(96vw,1400px)] select-none object-contain"},`${r}:${l.src}`):null,t.length>1?s.jsx(at,{onPrev:i,onNext:c,prevLabel:"Previous image",nextLabel:"Next image"}):null]}):null},da="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",ua={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]"]},ma="--mes-single-width-cap",ha="[--mes-single-width-cap:309px] sm:[--mes-single-width-cap:326px]",xa=436,gs=({tiles:e,onTileActivate:t,maxVisible:n=4,singleAspectRatio:a,className:r})=>{const i=e.length;if(i===0)return null;const c=e.slice(0,Math.min(i,n)),l=i-c.length,d=(h,m,f)=>{var v;const o=N(da,"h-full w-full",(v=ua[c.length])==null?void 0:v[m]);return t?s.jsxs("button",{type:"button",onClick:()=>t(m),"aria-label":h.ariaLabel??`Open media ${m+1}`,className:N(o,"cursor-zoom-in"),children:[h.content,f]},m):s.jsxs("div",{className:o,children:[h.content,f]},m)};let u;return a&&(u={aspectRatio:a,width:`min(var(${ma}), ${Math.round(xa*a*100)/100}px)`,maxWidth:"100%"}),c.length===1?s.jsx("div",{className:N(a?ha:"aspect-square w-full",r),style:u,children:d(c[0],0)}):c.length===2?s.jsx("div",{className:N("grid aspect-[16/9] w-full grid-cols-2 gap-0.5",r),children:c.map((h,m)=>d(h,m))}):c.length===3?s.jsxs("div",{className:N("grid aspect-[4/3] w-full grid-cols-2 grid-rows-2 gap-0.5",r),children:[s.jsx("div",{className:"row-span-2",children:d(c[0],0)}),d(c[1],1),d(c[2],2)]}):s.jsx("div",{className:N("grid aspect-[379/286] w-full grid-cols-2 grid-rows-2 gap-0.5",r),children:c.map((h,m)=>{const f=l>0&&m===c.length-1;return d(h,m,f?s.jsxs("div",{className:"absolute inset-0 flex items-center justify-center bg-black/55 text-2xl font-semibold text-white",children:["+",l]}):null)})})},Ce=e=>{const[t,n]=x.useState(!1),[a,r]=x.useState(0),i=x.useCallback(l=>{(e==null?void 0:e(l))!==!1&&(r(l),n(!0))},[e]),c=x.useCallback(()=>n(!1),[]);return{viewerOpen:t,viewerIndex:a,handleActivate:i,closeViewer:c}},fa=({item:e,index:t,totalCount:n,fallbackLoading:a,imgRef:r,onLoad:i})=>({ariaLabel:`Open image ${t+1} of ${n}`,content:s.jsx("img",{ref:r,src:he(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"})}),ga=({src:e,alt:t,items:n})=>n&&n.length>0?n:e?[{src:e,alt:t}]:[],ps=(e,t)=>e.map((n,a)=>({src:n.src,alt:n.alt,filename:t&&e.length===1?t:t?`${t} (${a+1})`:void 0})),pa=({src:e,alt:t,filename:n,loading:a="lazy",onClick:r,onDismiss:i})=>{const{viewerOpen:c,viewerIndex:l,handleActivate:d,closeViewer:u}=Ce(r);return s.jsxs("div",{className:"relative w-fit",children:[s.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:s.jsx("img",{src:he(e)??e,alt:t??"",draggable:!1,loading:a,decoding:"async",className:"size-full object-cover"})}),i?s.jsx("div",{className:"absolute right-2 top-2 z-10",children:s.jsx(ye,{onClick:i})}):null,s.jsx(fs,{open:c,items:ps([{src:e,alt:t}],n),initialIndex:l,onClose:u})]})},ba=326/246,va=e=>{const t=e==null?void 0:e.src,[n,a]=x.useState(),r=x.useCallback(d=>{if(!d||d.naturalWidth<=0||d.naturalHeight<=0||t===void 0)return;const u=d.naturalWidth/d.naturalHeight;a(h=>h&&h.src===t&&h.ratio===u?h:{src:t,ratio:u})},[t]),i=x.useCallback(d=>r(d.currentTarget),[r]),c=e!=null&&e.width&&(e!=null&&e.height)?e.width/e.height:void 0,l=n&&n.src===t?n.ratio:void 0;return{ratio:c??l??ba,imgRef:r,onLoad:i}},bs=({state:e,src:t,alt:n,filename:a,items:r,text:i,groupPosition:c,loading:l="lazy",onClick:d})=>{const u=ga({src:t,alt:n,items:r}),h=Ne(e),{viewerOpen:m,viewerIndex:f,handleActivate:o,closeViewer:v}=Ce(d),_=u.length===1,p=va(_?u[0]:void 0);if(u.length===0)return null;const b=u.map((g,y)=>fa({item:g,index:y,totalCount:u.length,fallbackLoading:l,imgRef:_?p.imgRef:void 0,onLoad:_?p.onLoad:void 0}));return s.jsxs(_e,{variant:h,text:i,groupPosition:c,bordered:!1,widthClassName:_?"w-fit max-w-[min(100%,313px)] sm:max-w-[min(100%,330px)]":"w-[383px] max-w-full",paddingClassName:"p-0.5",radiusClassName:"rounded-[20px]","data-testid":"image-attachment",children:[s.jsx("div",{className:"relative",children:s.jsx(gs,{tiles:b,onTileActivate:o,singleAspectRatio:_?p.ratio:void 0})}),s.jsx(fs,{open:m,items:ps(u,a),initialIndex:f,onClose:v})]})},ja=e=>s.jsx(pa,{...e}),wa=e=>s.jsx(bs,{...e,state:"sent"}),_a=e=>s.jsx(bs,{...e,state:"received"}),ya={Composer:ja,Sent:wa,Received:_a},Na=({open:e,items:t,initialIndex:n=0,onClose:a})=>{const{index:r,prev:i,next:c}=rt({length:t.length,initialIndex:n,open:e}),l=t[r],d=x.useMemo(()=>(l==null?void 0:l.filename)??(l?se(l.src):"document"),[l]),u=x.useMemo(()=>l?Ca(l.src):void 0,[l]);return!l||!u?null:s.jsxs(it,{open:e,onClose:a,ariaLabel:d,counter:t.length>1?`${r+1} / ${t.length}`:void 0,"data-testid":"pdf-viewer",children:[s.jsx("iframe",{src:u,title:d,className:"block h-[calc(100dvh-128px)] w-[min(96vw,1400px)] border-0 bg-white",sandbox:"allow-scripts allow-forms allow-popups allow-downloads"},`${r}:${l.src}`),t.length>1?s.jsx(at,{onPrev:i,onNext:c,prevLabel:"Previous document",nextLabel:"Next document"}):null]})},Ca=e=>{const t=e.indexOf("#"),n=t===-1?e:e.slice(0,t),a=t===-1?"":e.slice(t+1),r=new URLSearchParams(a);return r.has("toolbar")||r.set("toolbar","0"),r.has("navpanes")||r.set("navpanes","0"),`${n}#${r.toString()}`},Sa=({src:e,filename:t,fileSize:n,title:a,items:r})=>r&&r.length>0?r:e?[{src:e,filename:t,fileSize:n,title:a}]:[],ka=({variant:e,item:t,index:n,onActivate:a,trailingAction:r})=>{const i=t.filename??se(t.src);return s.jsx(us,{variant:e,filename:i,title:t.title,mimeType:"application/pdf",fileSize:t.fileSize,onActivate:()=>a(n),activateLabel:`Open ${i}`,trailingAction:r})},ot=({state:e,src:t,filename:n,fileSize:a,title:r,items:i,text:c,groupPosition:l,onClick:d,onDismiss:u})=>{const h=Ne(e),m=Sa({src:t,filename:n,fileSize:a,title:r,items:i}),{viewerOpen:f,viewerIndex:o,handleActivate:v,closeViewer:_}=Ce(d),p=e==="composer"&&!!u;if(m.length===0)return null;const b=m.map(g=>({src:g.src,filename:g.filename??se(g.src)}));return s.jsxs(_e,{variant:h,text:c,groupPosition:l,"data-testid":"pdf-attachment",children:[s.jsx("div",{className:"flex flex-col gap-2",children:m.map((g,y)=>{const j=g.filename??se(g.src),E=p&&y===0?s.jsx(ye,{onClick:u,variant:"inline"}):e==="composer"?void 0:s.jsx(xs,{url:g.src,filename:j,variant:"inline",label:`Download ${j}`,tone:h});return s.jsx(ka,{variant:h,item:g,index:y,onActivate:v,trailingAction:E},`${g.src}-${y}`)})}),s.jsx(Na,{open:f,items:b,initialIndex:o,onClose:_})]})},Ea=e=>s.jsx(ot,{...e,state:"composer"}),Ia=e=>s.jsx(ot,{...e,state:"sent"}),Ta=e=>s.jsx(ot,{...e,state:"received"}),Aa={Composer:Ea,Sent:Ia,Received:Ta},vs=({open:e,items:t,initialIndex:n=0,onClose:a})=>{const{index:r,prev:i,next:c}=rt({length:t.length,initialIndex:n,open:e}),l=t[r],d=x.useMemo(()=>(l==null?void 0:l.filename)??(l?se(l.src):"video"),[l]);return l?s.jsxs(it,{open:e,onClose:a,ariaLabel:d,counter:t.length>1?`${r+1} / ${t.length}`:void 0,"data-testid":"video-viewer",children:[s.jsx("video",{src:l.src,poster:l.poster,controls:!0,autoPlay:!0,muted:!0,playsInline:!0,preload:l.preload??"metadata",className:"block h-auto max-h-[calc(100dvh-128px)] w-auto max-w-[min(96vw,1400px)] bg-black",children:l.mimeType?s.jsx("source",{src:l.src,type:l.mimeType}):null},`${r}:${l.src}`),t.length>1?s.jsx(at,{onPrev:i,onNext:c,prevLabel:"Previous video",nextLabel:"Next video"}):null]}):null},Ma=()=>s.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center",children:s.jsx("span",{className:"flex size-12 items-center justify-center rounded-full bg-black/55 text-white backdrop-blur",children:s.jsx(C.PlayIcon,{className:"size-6",weight:"fill","aria-hidden":!0})})}),js=({item:e,index:t})=>s.jsxs("div",{className:"absolute inset-0 size-full bg-[#0d0d0d]",children:[e.poster?s.jsx("img",{src:e.poster,alt:`Video ${t+1} thumbnail`,draggable:!1,loading:"lazy",decoding:"async",className:"absolute inset-0 size-full object-cover"}):s.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:s.jsx(C.VideoCameraIcon,{className:"size-16 text-white/30",weight:"regular","aria-hidden":!0})}),s.jsx(Ma,{})]}),Ra=(e,t,n)=>({ariaLabel:`Play video ${t+1} of ${n}`,content:s.jsx(js,{item:e,index:t})}),La=({src:e,poster:t,mimeType:n,preload:a,items:r})=>r&&r.length>0?a?r.map(i=>({...i,preload:i.preload??a})):r:e?[{src:e,poster:t,mimeType:n,preload:a}]:[],ws=(e,t)=>e.map((n,a)=>({src:n.src,poster:n.poster,mimeType:n.mimeType,preload:n.preload,filename:t&&e.length===1?t:t?`${t} (${a+1})`:void 0})),Oa=({src:e,poster:t,mimeType:n,filename:a,preload:r,onClick:i,onDismiss:c})=>{const{viewerOpen:l,viewerIndex:d,handleActivate:u,closeViewer:h}=Ce(i);return s.jsxs("div",{className:"relative w-fit",children:[s.jsx("button",{type:"button",onClick:()=>u(0),"aria-label":"Play video",className:"relative block size-[280px] cursor-pointer overflow-hidden rounded-md outline-none focus-visible:ring-2 focus-visible:ring-black/40",children:s.jsx(js,{item:{src:e,poster:t,mimeType:n},index:0})}),c?s.jsx("div",{className:"absolute right-2 top-2 z-10",children:s.jsx(ye,{onClick:c})}):null,s.jsx(vs,{open:l,items:ws([{src:e,poster:t,mimeType:n,preload:r}],a),initialIndex:d,onClose:h})]})},_s=({state:e,src:t,poster:n,mimeType:a,filename:r,items:i,text:c,groupPosition:l,preload:d,onClick:u})=>{const h=La({src:t,poster:n,mimeType:a,preload:d,items:i}),m=Ne(e),{viewerOpen:f,viewerIndex:o,handleActivate:v,closeViewer:_}=Ce(u);if(h.length===0)return null;const p=h.map((b,g)=>Ra(b,g,h.length));return s.jsxs(_e,{variant:m,text:c,groupPosition:l,"data-testid":"video-attachment",children:[s.jsx("div",{className:"relative",children:s.jsx(gs,{tiles:p,onTileActivate:v})}),s.jsx(vs,{open:f,items:ws(h,r),initialIndex:o,onClose:_})]})},Da=e=>s.jsx(Oa,{...e}),Fa=e=>s.jsx(_s,{...e,state:"sent"}),Pa=e=>s.jsx(_s,{...e,state:"received"}),Ba={Composer:Da,Sent:Fa,Received:Pa},ue={Image:ya,Video:Ba,Audio:Qn,Pdf:Aa,File:ca};function z(e){const t=e==null?void 0:e.trim();return t||void 0}function Dt(e){return e.trim().replace(/^https?:\/\//i,"").replace(/\/+$/,"").toLowerCase()}function za(e,t){if(!(e!=null&&e.trim())||!(t!=null&&t.trim()))return!1;const n=Dt(e),a=Dt(t);if(n===a)return!0;if(!n.includes(a))return!1;const r=n.split(a).join("");return!/[^\p{P}\p{Z}\p{C}]/u.test(r)}function Ft(e){const t=z(e.og_scrape_url)??z(e.title_link),n=z(e.image_url)??z(e.thumb_url),a=z(e.asset_url),r=z(e.mime_type);return{title:z(e.title),description:z(e.text),url:t,thumbnailUrl:he(n),sourceUrl:a,layout:n||Qe(r,a)?"featured":"classic",mimeType:r,accentColor:z(e.accent_color),status:"ready"}}function $a(e){var t;return Le(e)?null:e.type==="image"?e.image_url||e.asset_url?"image":null:e.type==="video"&&e.asset_url?"video":e.type==="audio"&&e.asset_url?"audio":e.type==="file"&&e.asset_url?e.mime_type==="application/pdf"?"pdf":(t=e.mime_type)!=null&&t.startsWith("audio/")?"audio":"file":null}function ys(e){if(!(e!=null&&e.length))return[];const t=[],n=(r,i)=>{const c=t[t.length-1];if((c==null?void 0:c.type)==="media"&&c.kind===r){c.attachments.push(i);return}t.push({type:"media",kind:r,attachments:[i]})},a=r=>{const i=t[t.length-1];if((i==null?void 0:i.type)==="link"){i.attachments.push(r);return}t.push({type:"link",attachments:[r]})};for(const r of e){if(Le(r)){a(r);continue}const i=$a(r);i&&n(i,r)}return t}function Ua(e){return e.filter(t=>t.type==="media").length}function Ha(e,t,n){return t<=1?n:e===0?"first":e===t-1?"end":"middle"}function Va(e){return z(e.image_url)??z(e.asset_url)??""}function Ga(e){switch(e){case"image":return ue.Image;case"video":return ue.Video;case"audio":return ue.Audio;case"pdf":return ue.Pdf;default:return ue.File}}function Pt(e,t){switch(e){case"image":return{src:Va(t),alt:z(t.title)};case"video":return{src:z(t.asset_url)??"",poster:z(t.thumb_url),mimeType:z(t.mime_type)};case"audio":return{src:z(t.asset_url)??"",mimeType:z(t.mime_type)??"audio/mpeg",filename:z(t.title)};case"pdf":return{src:z(t.asset_url)??"",filename:z(t.title),fileSize:t.file_size};case"file":return{src:z(t.asset_url)??"",filename:z(t.title),fileSize:t.file_size,mimeType:z(t.mime_type)??"application/octet-stream"}}}function Ya(e,t){if(t.length>1)return{items:t.map(a=>Pt(e,a))};const n=t[0];return n?Pt(e,n):{}}function Wa({groupPosition:e,isMyMessage:t,segment:n}){const a=Ga(n.kind),r={...Ya(n.kind,n.attachments),groupPosition:e};return t?s.jsx(a.Sent,{...r}):s.jsx(a.Received,{...r})}const qa=({groupPosition:e,isMyMessage:t,message:n,renderText:a})=>{var p;const r=ys(n.attachments);if(r.length===0)return null;const i=Ua(r),c=(p=n.text)==null?void 0:p.trim(),l=r.find(b=>b.type==="link"),d=(l==null?void 0:l.type)==="link"?Ft(l.attachments[0]??{}).url:void 0,u=c&&za(c,d)?void 0:c;let h=0;const m=[],f=u?"middle":e,o=e==="single"||e==="end",v=(b,g,y)=>{const j=t?Ae.Sent:Ae.Received;m.push(s.jsx(j,{...Ft(b),groupPosition:y?f:"middle"},g))},_=(b,g)=>{const y=Ha(h,i,e);h+=1,m.push(s.jsx(Wa,{groupPosition:y,isMyMessage:t,segment:b},g))};return r.forEach((b,g)=>{const y=g===r.length-1;if(b.type==="link"){b.attachments.forEach((j,E)=>{v(j,`link-${g}-${E}`,y&&E===b.attachments.length-1)});return}_(b,`media-${g}`)}),s.jsxs("div",{className:"str-chat__message-bubble-wrapper",children:[s.jsxs("div",{className:"str-chat__message-bubble","data-attachment-bubble":"true",style:{background:"transparent",borderRadius:0,overflow:"visible",padding:0},children:[m,!u&&s.jsx(w.MessageErrorIcon,{})]}),u?s.jsxs("div",{className:N("str-chat__message-bubble",{"relative isolate":o}),children:[s.jsx(w.MessageText,{message:n,renderText:a}),s.jsx(w.MessageErrorIcon,{}),o&&s.jsx(Te,{side:t?"me":"other"})]}):null]})},Xa=e=>{var ft,gt,pt,bt,vt,jt,wt,_t,yt,Nt,Ct;const{additionalMessageInputProps:t,editing:n,endOfGroup:a,firstOfGroup:r,groupStyles:i,groupedByUser:c,handleAction:l,handleOpenThread:d,handleRetry:u,highlighted:h,isMessageAIGenerated:m,isMyMessage:f,message:o,renderText:v,threadList:_,viewerLanguage:p,onOutboundClick:b,resolvedOutbound:g}=e,{client:y}=w.useChatContext("CustomMessage"),{channel:j}=w.useChannelStateContext("CustomMessage"),{isUnlocking:E,onUnlockClick:A,onFetchSource:M,onDownloadClick:O}=ts("LockedAttachment"),[P,R]=x.useState(!1),S=w.useMessageReminder(o.id),{Attachment:T=w.Attachment,EditMessageModal:I=w.EditMessageModal,MessageActions:k,MessageBlocked:L=w.MessageBlocked,MessageBouncePrompt:$=w.MessageBouncePrompt,MessageDeleted:B=w.MessageDeleted,MessageIsThreadReplyInChannelButtonIndicator:D=w.MessageIsThreadReplyInChannelButtonIndicator,MessageRepliesCountButton:Y=w.MessageRepliesCountButton,ReminderNotification:U=w.ReminderNotification,StreamedMessageText:W=w.StreamedMessageText,PinIndicator:q}=w.useComponentContext("CustomMessage"),G=w.messageHasAttachments(o),J=w.messageHasReactions(o),K=x.useMemo(()=>m==null?void 0:m(o),[m,o]),F=x.useMemo(()=>{const oe=o.attachments??[],ce=o.shared_location?[o.shared_location,...oe]:oe;if(!Ie(o))return ce;const St=ce.filter(kt=>!("type"in kt)||!Le(kt));return St.length===ce.length?ce:St},[o]),Q=x.useMemo(()=>ys(F),[F]),H=x.useMemo(()=>{const oe=Ye({message:o,viewerLanguage:p});return oe===o.text?o:{...o,text:oe}},[o,p]),Z=Q.length>0,ee=Q.reduce((oe,ce)=>oe+ce.attachments.length,0)===((F==null?void 0:F.length)??0),ne=(i==null?void 0:i[0])??"",Se=ne==="top"?"first":ne==="middle"?"middle":ne==="bottom"?"end":"single",re=ne==="single"||ne==="bottom";if(w.isDateSeparatorMessage(o))return null;if(o.deleted_at||o.type==="deleted")return s.jsx(B,{message:o});if(w.isMessageBlocked(o))return s.jsx(L,{});const te=!_&&!!o.reply_count,ie=!_&&o.show_in_channel&&o.parent_id,ae=o.status==="failed"&&((ft=o.error)==null?void 0:ft.status)!==403,ct=w.isMessageBounced(o);let le;ae?le=()=>u(o):ct&&(le=()=>R(!0));const X=f(),Rs=N("str-chat__message str-chat__message-simple",`str-chat__message--${o.type}`,`str-chat__message--${o.status}`,X?"str-chat__message--me str-chat__message-simple--me":"str-chat__message--other",o.text?"str-chat__message--has-text":"has-no-text",{"str-chat__message--has-attachment":G,"str-chat__message--highlighted":h,"str-chat__message--pinned pinned-message":o.pinned,"str-chat__message--with-reactions":J,"str-chat__message-send-can-be-retried":(o==null?void 0:o.status)==="failed"&&((gt=o==null?void 0:o.error)==null?void 0:gt.status)!==403,"str-chat__message-with-thread-link":te||ie,"str-chat__virtual-message__wrapper--end":a,"str-chat__virtual-message__wrapper--first":r,"str-chat__virtual-message__wrapper--group":c}),De=o.poll_id&&y.polls.fromState(o.poll_id),dt=qe(o),fe=Ie(o),Ls=We(o),Fe=!!(F!=null&&F.length&&!o.quoted_message),ut=fe&&X&&Fe,Os=Z&&ee&&!o.quoted_message&&!De&&!K&&!fe,mt={contentType:"text",amountText:(pt=o.metadata)==null?void 0:pt.amount_text,paymentStatus:(bt=o.metadata)==null?void 0:bt.payment_status,renderedText:o.text&&s.jsx(w.MessageText,{message:H,renderText:v})},ht={contentType:"media",title:(vt=o.metadata)==null?void 0:vt.attachment_title,mimeType:(jt=o.metadata)==null?void 0:jt.attachment_mime_type,thumbnailUrl:(wt=o.metadata)==null?void 0:wt.attachment_thumbnail,amountText:(_t=o.metadata)==null?void 0:_t.amount_text,detail:(yt=o.metadata)==null?void 0:yt.attachment_detail,paymentStatus:(Nt=o.metadata)==null?void 0:Nt.payment_status,onFetchSource:M?()=>M(o,j):void 0},xt=s.jsxs("div",{className:N("str-chat__message-bubble",{"relative isolate":re}),children:[s.jsx(w.MessageText,{message:H,renderText:v}),re&&s.jsx(Te,{side:X?"me":"other"})]});return s.jsxs(s.Fragment,{children:[n&&s.jsx(I,{additionalMessageInputProps:t}),P&&s.jsx(w.MessageBounceModal,{MessageBouncePrompt:$,onClose:()=>R(!1),open:P}),s.jsxs("div",{className:Rs,"data-message-id":o.id,"data-dd-privacy":"mask",children:[q&&s.jsx(q,{}),!!S&&s.jsx(U,{reminder:S}),o.user&&s.jsx(me,{className:"str-chat__avatar str-chat__message-sender-avatar",id:o.user.id,image:o.user.image,name:o.user.name||o.user.id,size:24,shape:"circle",dmAgentEnabled:fe}),s.jsx("div",{className:N("str-chat__message-inner",{"str-chat__simple-message--error-failed":ae||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?s.jsxs("div",{className:"str-chat__message-bubble-wrapper message-tip-wrapper",children:[s.jsx(as,{message:o}),((Ct=o.text)==null?void 0:Ct.trim())&&xt]}):nn(o)?s.jsx("div",{className:"str-chat__message-bubble-wrapper",children:s.jsxs("div",{className:"flex items-center gap-2",children:[X&&k&&s.jsx(k,{}),X?s.jsx(pe,{...mt,isMine:!0}):s.jsx(pe,{...mt,isMine:!1,isUnlocking:E(o.id),onUnlockClick:()=>A==null?void 0:A(o,j)}),!X&&k&&s.jsx(k,{})]})}):an(o)?s.jsxs("div",{className:"str-chat__message-bubble-wrapper message-locked-attachment-wrapper",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[X&&k&&s.jsx(k,{}),X?s.jsx(pe,{...ht,isMine:!0,onPreviewClick:()=>A?A(o,j):void 0}):s.jsx(pe,{...ht,isMine:!1,isUnlocking:E(o.id),onUnlockClick:()=>A?A(o,j):void 0,onDownloadClick:()=>O?O(o,j):void 0}),!X&&k&&s.jsx(k,{})]}),o.text&&xt]}):Os?s.jsx(qa,{groupPosition:Se,isMyMessage:X,message:{...H,attachments:F,i18n:void 0},renderText:v}):s.jsx("div",{className:"str-chat__message-bubble-wrapper",children:s.jsxs("div",{className:N("str-chat__message-bubble",{"relative isolate":re}),children:[fe&&!ut&&s.jsx(Tt,{message:o,hasAttachment:Fe,isMyMessage:X}),De&&s.jsx(w.Poll,{poll:De}),F!=null&&F.length&&!o.quoted_message?s.jsx(T,{actionHandler:l,attachments:F}):null,K?s.jsx(W,{message:H,renderText:v}):s.jsx(w.MessageText,{message:H,renderText:v}),s.jsx(w.MessageErrorIcon,{}),re&&s.jsx(Te,{side:X?"me":"other"})]})})}),!Ls&&!dt&&s.jsx("div",{className:"str-chat__message-footer",children:(!fe||ut)&&s.jsx(Tt,{message:o,hasAttachment:Fe,isMyMessage:X})}),s.jsx(fn,{onOutboundClick:b,resolvedOutbound:g}),te&&s.jsx(Y,{onClick:d,reply_count:o.reply_count}),ie&&s.jsx(D,{})]},o.id)]})},Ka=x.memo(Xa,(e,t)=>{var n,a,r,i;return e.viewerLanguage!==t.viewerLanguage||e.onOutboundClick!==t.onOutboundClick||((n=e.resolvedOutbound)==null?void 0:n.id)!==((a=t.resolvedOutbound)==null?void 0:a.id)||((r=e.resolvedOutbound)==null?void 0:r.name)!==((i=t.resolvedOutbound)==null?void 0:i.name)?!1:w.areMessageUIPropsEqual(e,t)}),Za=e=>{var i;const t=w.useMessageContext("CustomMessage"),n=x.useContext(ns),a=(i=t.message.metadata)==null?void 0:i.outbound_id,r=typeof a=="string"?n==null?void 0:n[a]:void 0;return s.jsx(Ka,{...t,...e,resolvedOutbound:r})},Ja=()=>{var n;const{handleDelete:e,message:t}=w.useMessageContext("CustomMessageActions");return((n=t.metadata)==null?void 0:n.payment_status)==="paid"?null:s.jsx(Ue.DefaultDropdownActionButton,{onClick:e,"aria-label":"Delete",title:"Delete",className:"bg-marble rounded-full p-2 hover:bg-sand transition-all",children:s.jsx(C.TrashSimpleIcon,{size:16,weight:"light","aria-hidden":!0})})},Qa=()=>{const{handleFlag:e}=w.useMessageContext("CustomMessageActions");return s.jsx(Ue.DefaultDropdownActionButton,{onClick:e,"aria-label":"Report",title:"Report",className:"bg-marble rounded-full p-2 hover:bg-sand transition-all",children:s.jsx(C.FlagIcon,{size:16,weight:"light","aria-hidden":!0})})},er=()=>{var t;const{message:e}=w.useMessageContext("CustomMessageActions");return((t=e.metadata)==null?void 0:t.custom_type)!==V.MESSAGE_CUSTOM_TYPE.ATTACHMENT?null:s.jsx(Ue.MessageActions,{messageActionSet:[{Component:Ja,placement:"quick",type:"delete"},{Component:Qa,placement:"quick",type:"flag"}]})},tr=e=>({linkPreviews:Array.from(e.previews.values()).filter(t=>Ee.LinkPreviewsManager.previewIsLoaded(t)||Ee.LinkPreviewsManager.previewIsLoading(t))}),sr=()=>{const{linkPreviewsManager:e}=w.useMessageComposer(),{linkPreviews:t}=w.useStateStore(e.state,tr),n=r=>{e.dismissPreview(r)};return t.length>0?s.jsx("div",{className:"messaging-link-preview-list flex flex-col items-stretch w-full gap-2",children:t.map(r=>{const i=Ee.LinkPreviewsManager.previewIsLoading(r);return s.jsx(Ae.Composer,{title:r.title,url:r.og_scrape_url,thumbnailUrl:r.image_url,layout:i||r.image_url?"featured":"classic",status:i?"loading":"ready",onDismiss:()=>n(r.og_scrape_url)},r.og_scrape_url)})}):null},Me=x.createContext(!1),nr=200,ar=()=>x.useContext(Me),rr=({sendMessage:e,disabled:t,...n})=>s.jsx("button",{...n,type:"button","aria-label":"Send",disabled:t,onPointerDown:a=>a.preventDefault(),onClick:e,children:s.jsx(C.ArrowUpIcon,{weight:"bold",className:"size-4"})}),Bt=()=>{const e=x.useContext(Me),{handleSubmit:t}=w.useMessageInputContext(),n=w.useMessageComposerHasSendableData(),a=e||!n,{SendButton:r=rr,AttachmentPreviewList:i=w.AttachmentPreviewList}=w.useComponentContext("CustomMessageInput"),c=x.useRef(null);return x.useEffect(()=>{const l=c.current;if(!l||typeof ResizeObserver>"u")return;const d=new ResizeObserver(()=>{l.contains(document.activeElement)&&(l.scrollTop=l.scrollHeight)});return d.observe(l),()=>d.disconnect()},[]),x.useEffect(()=>{const l=c.current;if(!l)return;const d=u=>{var m;Array.from(((m=u.clipboardData)==null?void 0:m.items)??[]).some(f=>f.kind==="file")||u.stopPropagation()};return l.addEventListener("paste",d),()=>l.removeEventListener("paste",d)},[]),s.jsxs("div",{ref:c,className:"central-container flex flex-col min-w-0 w-full max-h-[calc(var(--messaging-surface-height,100dvh)*0.5)] overflow-y-auto overscroll-contain bg-white rounded-[1.5rem] shadow-[0_4px_16px_0_rgba(0,0,0,0.08),0_1px_2px_0_rgba(0,0,0,0.04),0_0_0_1px_rgba(0,0,0,0.04)] [&>:not(.messaging-composer-previews):not(.messaging-composer-row)]:p-2","data-dd-privacy":"mask",children:[s.jsxs("div",{className:"messaging-composer-previews empty:hidden flex flex-col gap-2 px-2 pt-2",children:[s.jsx(w.QuotedMessagePreview,{}),s.jsx(sr,{}),s.jsx(i,{})]}),s.jsxs("div",{className:"messaging-composer-row flex items-start",children:[s.jsx(w.TextareaComposer,{"aria-disabled":e||void 0,containerClassName:"min-w-0 flex-1 leading-[0]",className:"w-full resize-none overflow-hidden bg-transparent py-3.5 pl-4 pr-4 outline-none leading-5 placeholder:text-black/30 text-sm",autoFocus:!e,enterKeyHint:"send",maxRows:1/0,readOnly:e,tabIndex:e?-1:void 0}),s.jsx("div",{className:"sticky bottom-2 mt-auto mb-2 mr-2 shrink-0 pt-2",children:s.jsx(r,{sendMessage:t,"aria-label":"Send",className:"str-chat__send-button relative flex justify-center items-center rounded-full size-8 bg-[#121110] disabled:bg-[#F1F0EE] disabled:text-black/20 text-white focus-ring before:absolute before:-inset-2 before:content-['']","data-testid":"send-button",disabled:a,type:"button"})})]})]})},zt=()=>s.jsxs("div",{className:"messaging-composer-backdrop","aria-hidden":"true",children:[s.jsx("div",{className:"messaging-composer-backdrop-blur"}),s.jsx("div",{className:"messaging-composer-backdrop-blur"}),s.jsx("div",{className:"messaging-composer-backdrop-blur"}),s.jsx("div",{className:"messaging-composer-backdrop-blur"}),s.jsx("div",{className:"messaging-composer-backdrop-blur"}),s.jsx("div",{className:"messaging-composer-backdrop-gradient"})]}),$t=({renderActions:e,renderHeader:t,renderFooter:n,disabled:a=!1,disabledReason:r,composerInput:i})=>{var h;const{channel:c}=w.useChannelStateContext(),l=((h=c==null?void 0:c.data)==null?void 0:h.frozen)===!0,d=!!i,u=x.useRef(null);return x.useEffect(()=>{if(!d)return;const m=u.current,f=m==null?void 0:m.parentElement;if(!m||!f)return;let o=m.offsetHeight;const v=()=>{const p=m.offsetHeight,b=p>o;o=p;const g=Array.from(f.querySelectorAll(".str-chat__list")).find(j=>j.scrollHeight>j.clientHeight)??null,y=g?g.scrollHeight-g.scrollTop-g.clientHeight<nr:!1;f.style.setProperty("--messaging-composer-height",`${p}px`),b&&y&&g&&(g.scrollTop=g.scrollHeight)};if(v(),typeof ResizeObserver>"u")return;const _=new ResizeObserver(v);return _.observe(m),()=>{_.disconnect(),f.style.removeProperty("--messaging-composer-height")}},[d]),a?d?s.jsxs("div",{ref:u,className:"messaging-composer-chrome messaging-composer-chrome--floating",children:[s.jsx(zt,{}),s.jsxs("div",{className:"relative z-10 flex flex-col",children:[t==null?void 0:t(),s.jsx("div",{className:"messaging-composer-locked-panel flex w-full flex-col items-center justify-center gap-3 px-6 py-4",children:r?s.jsx("p",{className:"max-w-[345px] text-center text-xs font-normal leading-[1.3] tracking-[0.12px] text-black/40",children:r}):null}),n==null?void 0:n()]})]}):s.jsxs(s.Fragment,{children:[t==null?void 0:t(),s.jsx("div",{className:"messaging-composer-locked-panel flex w-full flex-col items-center justify-center gap-3 px-6 py-4",children:r?s.jsx("p",{className:"max-w-[345px] text-center text-xs font-normal leading-[1.3] tracking-[0.12px] text-black/40",children:r}):null}),n==null?void 0:n()]}):d?s.jsxs("div",{ref:u,className:"messaging-composer-chrome messaging-composer-chrome--floating",children:[s.jsx(zt,{}),s.jsxs("div",{className:"relative z-10 flex min-h-0 flex-col",children:[t==null?void 0:t(),s.jsxs("div",{className:"flex min-h-0 flex-col gap-4 p-3 pb-5 md:p-5",children:[s.jsxs("div",{inert:l?"":void 0,"aria-disabled":l||void 0,className:"message-input flex min-h-0 items-end gap-4 aria-disabled:opacity-40",children:[e&&s.jsx("div",{className:"flex h-12 shrink-0 items-center justify-center",children:e()}),s.jsx(Me.Provider,{value:l,children:s.jsx(w.MessageInput,{Input:i??Bt})})]}),n==null?void 0:n()]})]})]}):s.jsxs("div",{className:"flex min-h-0 flex-col gap-4 p-4",children:[t==null?void 0:t(),s.jsxs("div",{inert:l?"":void 0,"aria-disabled":l||void 0,className:"message-input flex min-h-0 items-end gap-4 aria-disabled:opacity-40",children:[e&&s.jsx("div",{className:"flex h-12 shrink-0 items-center justify-center",children:e()}),s.jsx(Me.Provider,{value:l,children:s.jsx(w.MessageInput,{Input:Bt})})]}),n==null?void 0:n()]})},ir={SYSTEM_DM_AGENT_PAUSED:"DM Agent has left the conversation",SYSTEM_DM_AGENT_RESUMED:"DM Agent has rejoined the conversation"},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."},ze="age safety guidelines.",cr="https://linktr.ee/s/about/contact",dr=e=>or.includes(e),ur=e=>{var t;return dr((t=e.metadata)==null?void 0:t.custom_type)},mr=e=>{var a;const t=(a=e.metadata)==null?void 0:a.custom_type;if(V.isDmAgentSystemType(t))return{kind:"dm-agent",type:t};if(V.isAgeSafetySystemType(t))return{kind:"age-safety",type:t};const n=e.dm_agent_system_type;if(V.isDmAgentSystemType(n))return{kind:"dm-agent",type:n}},hr=e=>{const t=e.indexOf(ze);if(t===-1)return e;const n=t+ze.length;return s.jsxs(s.Fragment,{children:[e.slice(0,t),s.jsx("a",{href:cr,target:"_blank",rel:"noopener noreferrer",className:"mes-age-safety-system-message__emphasis font-medium text-inherit underline",children:ze}),e.slice(n)]})},xr=e=>{var a,r;const t=!ur(e.message),n=mr(e.message);if((n==null?void 0:n.kind)==="dm-agent"){const i=((a=e.message.text)==null?void 0:a.trim())||ir[n.type];return s.jsxs("div",{className:"str-chat__message--system","data-testid":"message-system",children:[s.jsxs("div",{className:"mes-dm-agent-system-message mx-auto mb-2 inline-flex w-fit max-w-[min(100%,480px)] items-center justify-center gap-[10px] rounded-[12px] border border-[rgba(0,0,0,0.08)] p-3 text-[rgba(0,0,0,0.55)]","data-testid":"dm-agent-system-message","data-dm-agent-system-type":n.type,children:[s.jsx(C.SparkleIcon,{size:16,weight:"regular","aria-hidden":!0,className:"mes-dm-agent-system-message__sparkle shrink-0"}),s.jsx("p",{className:"mes-dm-agent-system-message__text m-0 text-center text-[14px] font-normal leading-5 tracking-[0.21px]",children:i})]}),!t&&s.jsx(w.MessageTimestamp,{message:e.message})]})}if((n==null?void 0:n.kind)==="age-safety"){const i=((r=e.message.text)==null?void 0:r.trim())||lr[n.type];return s.jsxs("div",{className:"str-chat__message--system","data-testid":"message-system",children:[s.jsxs("div",{className:"mes-age-safety-system-message box-border mx-auto mb-2 flex w-full max-w-[329px] items-start justify-center gap-3 rounded-[12px] border border-[var(--border-secondary,rgba(0,0,0,0.08))] bg-[var(--bg-warning-subtle,#fef3c6)] px-2 py-4 pl-5 text-[color:var(--text-warning-on-warning,#894b00)]","data-testid":"age-safety-system-message","data-age-safety-system-type":n.type,children:[s.jsx(C.ProhibitIcon,{size:24,weight:"duotone","aria-hidden":!0,className:"mes-age-safety-system-message__icon shrink-0 text-[color:var(--text-warning-on-warning,#894b00)]","data-testid":"age-safety-system-message-icon"}),s.jsx("div",{className:"mes-age-safety-system-message__content min-w-0 flex-[1_0_0]",children:s.jsx("p",{className:"m-0 text-balance text-left text-[12px] font-normal leading-4 tracking-[0.21px] text-[color:var(--text-warning-on-warning,#894b00)]",children:hr(i)})})]}),!t&&s.jsx(w.MessageTimestamp,{message:e.message})]})}return s.jsxs("div",{className:"str-chat__message--system","data-testid":"message-system",children:[s.jsxs("div",{className:"str-chat__message--system__text",children:[s.jsx("div",{className:"str-chat__message--system__line"}),s.jsx("p",{children:e.message.text}),s.jsx("div",{className:"str-chat__message--system__line"})]}),!t&&s.jsx(w.MessageTimestamp,{message:e.message})]})},Ns=x.createContext(!1),$e=({cx:e,index:t})=>s.jsx("circle",{cx:e,cy:"6.15",r:"3.9",fill:"#A0A0A0",children:s.jsx("animateTransform",{attributeName:"transform",type:"translate",values:"0 0; 0 -2.25; 0 0;",dur:"900ms",begin:`${120*t}ms`,repeatCount:"indefinite"})}),fr=new Set([w.AIStates.Thinking,w.AIStates.Generating,w.AIStates.ExternalSources]),gr=({threadList:e})=>{var v,_;const{channel:t,channelConfig:n,thread:a}=w.useChannelStateContext(),{client:r}=w.useChatContext(),{typing:i={}}=w.useTypingContext(),{aiState:c}=w.useAIState(t),l=x.useContext(Ns);if(!e&&l&&fr.has(c)){const p=pr(t,(v=r.user)==null?void 0:v.id);return s.jsx(Ut,{avatarId:(p==null?void 0:p.id)??"ai-agent",avatarName:(p==null?void 0:p.name)??(p==null?void 0:p.id)??"Agent",avatarImage:p==null?void 0:p.image,testId:"typing-indicator-ai"})}if((n==null?void 0:n.typing_events)===!1)return null;const u=e?[]:Object.values(i).filter(({parent_id:p,user:b})=>{var g;return(b==null?void 0:b.id)!==((g=r.user)==null?void 0:g.id)&&!p}),h=e?Object.values(i).filter(({parent_id:p,user:b})=>{var g;return(b==null?void 0:b.id)!==((g=r.user)==null?void 0:g.id)&&p===(a==null?void 0:a.id)}):[],m=e?h:u;if(!m.length)return null;const f=(_=m[0])==null?void 0:_.user,o=f!=null&&f.id&&t.state.members[f.id]?t.state.members[f.id].user:void 0;return s.jsx(Ut,{avatarId:(f==null?void 0:f.id)??(o==null?void 0:o.id)??"typing-user",avatarName:(f==null?void 0:f.name)??(o==null?void 0:o.name)??(f==null?void 0:f.id)??"Typing user",avatarImage:(f==null?void 0:f.image)??(o==null?void 0:o.image),testId:"typing-indicator"})},Ut=({avatarId:e,avatarName:t,avatarImage:n,testId:a})=>s.jsx("div",{className:"str-chat__li str-chat__li--single str-chat__typing-indicator !static","data-testid":a,style:{marginBottom:"var(--messaging-channel-input-spacer-height, 80px)"},children:s.jsxs("div",{className:"str-chat__message str-chat__message-simple str-chat__message--regular str-chat__message--received str-chat__message--other str-chat__message--has-text",children:[s.jsx(me,{className:"str-chat__avatar str-chat__message-sender-avatar",id:e,name:t,image:n??void 0,size:24,shape:"circle"}),s.jsx("div",{className:"str-chat__message-inner mx-0",children:s.jsx("div",{className:"str-chat__message-bubble-wrapper",children:s.jsxs("div",{className:"str-chat__message-bubble relative isolate",children:[s.jsx("div",{className:"str-chat__message-text min-h-11 flex items-center",children:s.jsx("div",{className:"str-chat__message-text-inner str-chat__message-simple-text-inner",children:s.jsxs("svg",{"aria-hidden":"true",className:"block overflow-visible",viewBox:"0 0 32 12.3",width:"32",height:"13",overflow:"visible",children:[s.jsx($e,{cx:"4",index:0}),s.jsx($e,{cx:"16",index:1}),s.jsx($e,{cx:"28",index:2})]})})}),s.jsx(Te,{side:"other"})]})})})]})});function pr(e,t){var a;const n=((a=e==null?void 0:e.state)==null?void 0:a.members)??{};for(const r of Object.values(n)){const i=r==null?void 0:r.user;if(i&&i.id!==t)return i}}const Cs=()=>null,br=({className:e,message:t})=>s.jsxs("div",{className:N("flex items-center justify-center h-full",e),children:[s.jsxs("svg",{viewBox:"0 0 100 100",className:"size-8 fill-pebble",stroke:"none",children:[s.jsx("circle",{cx:"6",cy:"50",r:"6",children:s.jsx("animateTransform",{attributeName:"transform",dur:"1s",type:"translate",values:"0 15 ; 0 -15; 0 15",repeatCount:"indefinite",begin:"0.1"})}),s.jsx("circle",{cx:"30",cy:"50",r:"6",children:s.jsx("animateTransform",{attributeName:"transform",dur:"1s",type:"translate",values:"0 10 ; 0 -10; 0 10",repeatCount:"indefinite",begin:"0.2"})}),s.jsx("circle",{cx:"54",cy:"50",r:"6",children:s.jsx("animateTransform",{attributeName:"transform",dur:"1s",type:"translate",values:"0 5 ; 0 -5; 0 5",repeatCount:"indefinite",begin:"0.3"})})]}),t&&s.jsx("span",{className:"text-stone",children:t})]}),Re=x.memo(()=>s.jsx("div",{className:"messaging-loading-state flex items-center justify-center h-full",children:s.jsxs("div",{className:"flex items-center",children:[s.jsx(br,{className:"w-6 h-6"}),s.jsx("span",{className:"text-sm text-stone",children:"Loading messages"})]})}));Re.displayName="LoadingState";const vr=({onBack:e,showBackButton:t,renderMessageInputActions:n,renderMessageInputFooter:a,renderConversationFooter:r,onLeaveConversation:i,onBlockParticipant:c,showDeleteConversation:l=!0,onDeleteConversationClick:d,onBlockParticipantClick:u,onReportParticipantClick:h,showBlockParticipant:m=!0,showReportParticipant:f=!0,composerDisabled:o=!1,composerDisabledReason:v,showStarButton:_=!1,renderChannelBanner:p,customChannelActions:b,renderChannelActions:g,renderMessage:y,viewerLanguage:j,showChannelInfo:E=!0,onParticipantNameClick:A,onOutboundClick:M,resolveOutbound:O,composerInput:P})=>{const{channel:R,messages:S}=w.useChannelStateContext(),T=x.useRef(M);x.useEffect(()=>{T.current=M},[M]);const I=x.useCallback(U=>{var W;(W=T.current)==null||W.call(T,U)},[]),k=M?I:void 0,L=un(S,O),$=R.state.messages.some(U=>U.type!=="deleted"),B=p?s.jsx(x.Fragment,{children:p()},"lt-channel-banner"):null,D=s.jsx(qs,{className:"-mx-[var(--str-chat\\_\\_spacing-2)] px-[var(--str-chat\\_\\_spacing-2)] md:-mx-[min(var(--str-chat\\_\\_spacing-10),4%)] md:px-[min(var(--str-chat\\_\\_spacing-10),4%)]",onBack:e,showBackButton:t,showChannelInfo:E,showStarButton:_,onLeaveConversation:i,onBlockParticipant:c,showDeleteConversation:l,showBlockParticipant:m,showReportParticipant:f,onDeleteConversationClick:d,onBlockParticipantClick:u,onReportParticipantClick:h,customChannelActions:b,renderChannelActions:g,onParticipantNameClick:A}),Y=x.useCallback(U=>{const{message:W}=w.useMessageContext("ChannelView"),q=s.jsx(Za,{...U,viewerLanguage:j,onOutboundClick:k});return!y||!W?q:y(q,W)},[k,y,j]);return s.jsx(ns.Provider,{value:L,children:s.jsx(w.WithComponents,{overrides:{Message:Y,MessageActions:er,UnreadMessagesNotification:()=>null,UnreadMessagesSeparator:()=>null},children:s.jsx(w.Window,{children:P?s.jsxs("div",{className:"messaging-channel-layout relative flex min-h-0 flex-1 flex-col",children:[s.jsxs("div",{className:"messaging-channel-message-list messaging-channel-message-list--floating relative min-h-0 flex-1 overflow-hidden",children:[!$&&s.jsx("div",{className:"str-chat__list",children:s.jsxs("div",{className:"str-chat__message-list-scroll",children:[D,B]})}),s.jsx(w.MessageList,{head:$?s.jsxs("div",{className:"sticky top-0 z-10",children:[D,B]}):void 0,hideDeletedMessages:!0,hideNewMessageSeparator:!1})]},"lt-channel-message-list"),s.jsx($t,{...n&&{renderActions:()=>n==null?void 0:n(R)},...r&&{renderHeader:()=>r(R)},renderFooter:()=>a==null?void 0:a(R),disabled:o,disabledReason:v,composerInput:P},"lt-channel-message-input")]}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex-1 overflow-hidden relative",children:[!$&&s.jsx("div",{className:"str-chat__list",children:s.jsxs("div",{className:"str-chat__message-list-scroll",children:[D,B]})}),s.jsx(w.MessageList,{head:$?s.jsxs("div",{className:"sticky top-0 z-10",children:[D,B]}):void 0,hideDeletedMessages:!0,hideNewMessageSeparator:!1})]},"lt-channel-message-list"),r?s.jsx(x.Fragment,{children:r(R)},"lt-channel-conversation-footer"):null,s.jsx($t,{...n&&{renderActions:()=>n==null?void 0:n(R)},renderFooter:()=>a==null?void 0:a(R),disabled:o,disabledReason:v,composerInput:P},"lt-channel-message-input")]})})})})},lt=x.memo(({channel:e,onBack:t,showBackButton:n=!1,renderMessageInputActions:a,renderMessageInputFooter:r,renderConversationFooter:i,onLeaveConversation:c,onBlockParticipant:l,className:d,CustomChannelEmptyState:u=Cs,showDeleteConversation:h=!0,onDeleteConversationClick:m,onBlockParticipantClick:f,onReportParticipantClick:o,showBlockParticipant:v=!0,showReportParticipant:_=!0,composerDisabled:p=!1,composerDisabledReason:b,dmAgentEnabled:g,messageMetadata:y,onMessageSent:j,showStarButton:E=!1,renderChannelBanner:A,customChannelActions:M,renderChannelActions:O,renderMessage:P,onMessageLinkClick:R,sendButton:S,attachmentPreviewList:T,viewerLanguage:I,showChannelInfo:k=!0,onParticipantNameClick:L,onOutboundClick:$,resolveOutbound:B,composerInput:D})=>{const Y=x.useCallback(async(q,G,J)=>{var ee;const K=((ee=e.data)==null?void 0:ee.chatbot_paused)===!0,F=g&&!K,Q={...G,...F&&{silent:!0},...y&&{metadata:{...G.metadata??{},...y}}},H={...J,...F&&{skip_push:!0}},Z=await e.sendMessage(Q,H);return j==null||j(Z),Z},[e,g,y,j]),U=x.useRef(null);x.useEffect(()=>{if(!R)return;const q=U.current;if(!q)return;const G=J=>{const K=J.target,F=K==null?void 0:K.closest("a[href]"),Q=F==null?void 0:F.getAttribute("href");if(!Q)return;const H=F==null?void 0:F.closest("[data-message-id]"),Z=H==null?void 0:H.getAttribute("data-message-id"),ee=Z?e.state.messages.find(ne=>ne.id===Z):void 0;R(Q,ee)};return q.addEventListener("click",G),()=>q.removeEventListener("click",G)},[R,e]);const W=V.isOfficialChannel(e.type)?{"--lt-msg-card-width":"368px"}:void 0;return s.jsx("div",{ref:U,className:N("messaging-channel-view h-full flex flex-col",d),style:W,children:s.jsx(Ns.Provider,{value:g??!1,children:s.jsx(w.Channel,{channel:e,MessageSystem:xr,EmptyStateIndicator:u,LoadingIndicator:Re,DateSeparator:Xs,TypingIndicator:gr,doSendMessageRequest:Y,...S?{SendButton:S}:{},...T?{AttachmentPreviewList:T}:{},children:s.jsx(vr,{onBack:t,showBackButton:n,renderMessageInputActions:a,renderMessageInputFooter:r,renderConversationFooter:i,onLeaveConversation:c,onBlockParticipant:l,CustomChannelEmptyState:u,showDeleteConversation:h,onDeleteConversationClick:m,onBlockParticipantClick:f,onReportParticipantClick:o,showBlockParticipant:v,showReportParticipant:_,composerDisabled:p,composerDisabledReason:b,showStarButton:E,renderChannelBanner:A,customChannelActions:M,renderChannelActions:O,renderMessage:P,viewerLanguage:I,showChannelInfo:k,onParticipantNameClick:L,onOutboundClick:$,resolveOutbound:B,composerInput:D})})})})});lt.displayName="ChannelView";const be=x.memo(({message:e,onBack:t})=>s.jsx("div",{className:"messaging-error-state flex items-center justify-center h-full p-8",children:s.jsxs("div",{className:"text-center max-w-sm",children:[s.jsx("div",{className:"w-24 h-24 bg-danger-alt/20 rounded-full flex items-center justify-center mx-auto mb-6",children:s.jsx("span",{className:"text-4xl",children:"⚠️"})}),s.jsx("h2",{className:"font-semibold text-charcoal mb-2",children:"Oops!"}),s.jsx("p",{className:"text-stone text-sm mb-6",children:e}),t&&s.jsx("button",{type:"button",onClick:t,className:"inline-flex items-center gap-2 px-4 py-2 text-sm font-medium text-white bg-[#7f22fe] hover:bg-primary-alt rounded-lg transition-colors focus-ring",children:"Go Back"})]})}));be.displayName="ErrorState";const jr=({capabilities:e={},renderMessageInputActions:t,renderConversationFooter:n,onChannelSelect:a,onExitConversation:r,initialParticipantFilter:i,initialParticipantData:c,CustomChannelEmptyState:l,onBlockParticipantClick:d,onReportParticipantClick:u,dmAgentEnabled:h,onMessageSent:m,viewerLanguage:f,renderChannelBanner:o,customChannelActions:v,renderChannelActions:_,onParticipantNameClick:p,onOutboundClick:b,resolveOutbound:g,renderMessage:y,onMessageLinkClick:j,showChannelInfo:E,composerInput:A,attachmentPreviewList:M})=>{const{client:O,isConnected:P,isLoading:R,error:S,refreshConnection:T,service:I,debug:k}=Xt(),[L,$]=x.useState(null),[B,D]=x.useState(null),[Y,U]=x.useState(!1),{showDeleteConversation:W=!0}=e,q=x.useRef(c);q.current=c;const G=x.useRef(a);G.current=a;const J=x.useRef(null),K=x.useRef(null);x.useEffect(()=>{K.current=L},[L]),x.useEffect(()=>{if(!O||!P)return;const H=O.userID;if(!H)return;const Z=`${H}::${i}`;if(J.current===Z)return;J.current=Z;const ee=()=>{J.current===Z&&(J.current=null)};(async()=>{var Se,re;try{k&&console.log("[MessagingShell] Loading initial conversation with:",i);const te=await O.queryChannels({type:"messaging",members:{$eq:[H,i]}},{},{limit:1});if(te.length>0){$(te[0]),D(null),(Se=G.current)==null||Se.call(G,te[0]),k&&console.log("[MessagingShell] Initial conversation loaded:",te[0].id);return}const ie=q.current;if(!ie||!I){ee(),D("No conversation found with this account"),k&&console.log("[MessagingShell] No conversation found for:",i);return}try{const ae=await I.startChannelWithParticipant({id:ie.id,name:ie.name,phone:ie.phone});$(ae),D(null),(re=G.current)==null||re.call(G,ae),k&&console.log("[MessagingShell] Channel created and loaded:",ae.id)}catch(ae){console.error("[MessagingShell] Failed to create conversation:",ae),ee(),D("Failed to create conversation")}}catch(te){console.error("[MessagingShell] Failed to load initial conversation:",te),ee(),K.current||D("Failed to load conversation")}})()},[i,O,P,I,k]);const F=x.useRef(r);F.current=r;const Q=x.useCallback(()=>{var H;$(null),U(!0),(H=F.current)==null||H.call(F)},[]);return R?s.jsx(Re,{}):S?s.jsx(be,{message:S,onBack:T}):!P||!O?s.jsx(be,{message:"Not connected to messaging service",onBack:T}):B?s.jsx(be,{message:B}):Y&&!L?s.jsx(be,{message:"Conversation ended"}):L?s.jsx("div",{className:"messaging-shell h-full bg-background-primary overflow-hidden",children:s.jsx("div",{className:"flex h-full min-h-0 flex-col",children:s.jsx(lt,{channel:L,renderMessageInputActions:t,renderConversationFooter:n,renderChannelBanner:o,onLeaveConversation:Q,onBlockParticipant:Q,CustomChannelEmptyState:l,showDeleteConversation:W,onBlockParticipantClick:d,onReportParticipantClick:u,dmAgentEnabled:h,onMessageSent:m,viewerLanguage:f,customChannelActions:v,renderChannelActions:_,onParticipantNameClick:p,onOutboundClick:b,resolveOutbound:g,renderMessage:y,onMessageLinkClick:j,showChannelInfo:E,composerInput:A,attachmentPreviewList:M},L.id)})}):s.jsx(Re,{})};function wr(e){const t=e.state.pending_messages;if(t!=null&&t.length)for(const n of t)e.state.addMessageSorted(n.message)}const Ss=x.createContext({selectedChannel:void 0,onChannelSelect:()=>{},debug:!1,renderMessagePreview:void 0,channelPreview:void 0,viewerLanguage:void 0}),_r=Ss.Provider,yr=()=>x.useContext(Ss),Nr=(e,t)=>{const n=Date.UTC(e.getFullYear(),e.getMonth(),e.getDate()),a=Date.UTC(t.getFullYear(),t.getMonth(),t.getDate());return Math.floor((a-n)/(1e3*60*60*24))},ks=e=>{const t=new Date;if(Math.floor((t.getTime()-e.getTime())/1e3)<60)return"Just now";const a=Nr(e,t);return a===0?e.toLocaleTimeString([],{hour:"numeric",minute:"2-digit",hour12:!0}):a===1?"Yesterday":a<7?e.toLocaleDateString(void 0,{weekday:"short"}):e.getFullYear()===t.getFullYear()?e.toLocaleDateString(void 0,{month:"short",day:"numeric"}):e.toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"})},Es=x.memo(e=>{var O,P,R;const{channel:t,unread:n}=e,{selectedChannel:a,onChannelSelect:r,debug:i,channelPreview:c,renderMessagePreview:l,viewerLanguage:d}=yr(),{client:u}=w.useChatContext(),h=(a==null?void 0:a.id)===(t==null?void 0:t.id),m=Kt(t);if(c){const S=c;return s.jsx(S,{...e,active:h,selectedChannel:a,onChannelSelect:r,viewerLanguage:d})}const f=()=>{t&&r(t)},o=S=>{const T=S.key==="Enter"||S.key===" ",I=S.repeat;!T||I||(S.preventDefault(),f())},v=Ve((O=t==null?void 0:t.state)==null?void 0:O.members,u==null?void 0:u.userID,t==null?void 0:t.type),_=Ge(v==null?void 0:v.user),p=(P=v==null?void 0:v.user)==null?void 0:P.image,b=(()=>{var T;const S=(T=t==null?void 0:t.state)==null?void 0:T.messages;if(S!=null&&S.length){for(let I=S.length-1;I>=0;I--)if(S[I].type!=="system")return S[I]}})(),y=(()=>{var L;const S=Ye({message:b,viewerLanguage:d}),{custom_type:T,attachment_content_type:I}=(b==null?void 0:b.metadata)||{};if(T===V.MESSAGE_CUSTOM_TYPE.TIP)return S||"Sent a tip";if(T===V.MESSAGE_CUSTOM_TYPE.PAID)return S||"Sent a message";if(T===V.MESSAGE_CUSTOM_TYPE.ATTACHMENT){if(I==="text")return"🔒 Sent a locked message";if(I==="media")return"🔒 Sent a locked attachment"}if(S)return S;const k=(L=b==null?void 0:b.attachments)==null?void 0:L[0];return k?k.og_scrape_url?k.og_scrape_url:k.type==="image"?"📷 Sent an image":k.type==="video"?"🎥 Sent a video":k.type==="audio"?"🎵 Sent audio":k.type==="file"?"📎 Sent a file":"📎 Sent an attachment":"No messages yet"})(),j=b!=null&&b.created_at?ks(new Date(b.created_at)):"",E=b?Ie(b):!1,A=l?l(b,y):`${E?"✨ ":""}${y}`,M=n??0;return i&&console.log("📺 [ChannelList] 📋 CHANNEL PREVIEW RENDER",{channelId:t==null?void 0:t.id,isSelected:h,participantName:_,unreadCount:M,hasTimestamp:!!j}),s.jsx("div",{role:"button",tabIndex:0,onClick:f,onKeyDown:o,className:N("group w-full px-4 py-3 transition-colors text-left max-w-full overflow-hidden focus-ring rounded-[12px] [&+&]:mt-2",{"bg-black/[0.04]":h,"hover:bg-black/[0.02]":!h}),"data-dd-privacy":"mask",children:s.jsxs("div",{className:"flex items-start gap-4",children:[s.jsx(me,{id:((R=v==null?void 0:v.user)==null?void 0:R.id)||t.id||"unknown",name:_,image:p,size:48,starred:m}),s.jsxs("div",{className:"flex-1 min-w-0 flex flex-col gap-1",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs("h3",{className:N("text-sm font-medium truncate text-[#191918]"),children:[m&&s.jsx("span",{className:"sr-only",children:"Starred conversation. "}),_]}),j&&s.jsx("span",{className:"text-xs text-[#717070] flex-shrink-0",children:j})]}),s.jsxs("div",{className:"flex items-center justify-between gap-2 min-w-0",children:[s.jsx("p",{className:"text-sm text-[#717070] flex-1 line-clamp-1",children:A}),M>0&&s.jsx("span",{className:"bg-[#7f22fe] text-white text-[10px] rounded-full h-4 flex items-center justify-center p-1 min-w-4 text-center flex-shrink-0",children:M>99?"99+":M})]})]})]})})});Es.displayName="CustomChannelPreview";const Cr={last_message_at:-1},Is=x.memo(({onChannelSelect:e,selectedChannel:t,filters:n,allowNewMessagesFromUnfilteredChannels:a=!1,channelRenderFilterFn:r,sort:i=Cr,className:c,customEmptyStateIndicator:l,channelListPaginator:d=w.InfiniteScroll,channelPreview:u,renderMessagePreview:h,viewerLanguage:m,lockChannelOrder:f,onMessageNewHandler:o,onMessageNew:v,onChannelVisible:_,onAddedToChannel:p,onChannelUpdated:b})=>{const g=x.useRef(0);g.current++;const{debug:y=!1}=He(),j=x.useCallback(A=>{for(const M of A)wr(M);return r?r(A):A},[r]);y&&console.log("📺 [ChannelList] 🔄 RENDER START",{renderCount:g.current,selectedChannelId:t==null?void 0:t.id,filters:n});const E=x.useMemo(()=>({selectedChannel:t,onChannelSelect:e,debug:y,channelPreview:u,renderMessagePreview:h,viewerLanguage:m}),[t,e,y,u,h,m]);return s.jsx("div",{className:N("messaging-channel-list h-full flex flex-col min-w-0 overflow-hidden",c),children:s.jsx("div",{className:"flex-1 overflow-hidden min-w-0",children:s.jsx(_r,{value:E,children:s.jsx(w.ChannelList,{filters:n,sort:i,options:{limit:30},allowNewMessagesFromUnfilteredChannels:a,channelRenderFilterFn:j,lockChannelOrder:f,onMessageNewHandler:o,onMessageNew:v,onChannelVisible:_,onAddedToChannel:p,onChannelUpdated:b,Paginator:d,Preview:Es,EmptyStateIndicator:l},`${JSON.stringify(n)}:${JSON.stringify(i)}`)})})})});Is.displayName="ChannelList";const Sr="line-clamp-2 text-body-small-medium",kr="text-body-small-regular",Er=()=>s.jsxs(s.Fragment,{children:[s.jsx("br",{}),s.jsx("span",{"aria-hidden":!0,className:"block h-1.5"})]}),Ir=e=>e.split(/\r?\n/).map((t,n,a)=>s.jsxs(x.Fragment,{children:[t,n<a.length-1?s.jsx(Er,{}):null]},n)),Ht=({surface:e,actions:t,layout:n})=>{if(t==null||t.length===0)return null;const a=n==="stacked";return s.jsx("div",{className:N("flex gap-2",a?"mt-4 flex-col":"min-w-0 max-w-[60%] flex-row flex-wrap justify-end"),children:t.map((r,i)=>s.jsx(rs,{variant:e,cta:r,fullWidth:a,standalone:!0},`${r.label}-${i}`))})},Tr=({ctaSurface:e,chinTextColor:t,title:n,subtitle:a,subtitleLines:r=3,appIcon:i,actions:c})=>{var v;const l=n!=null&&n.trim()!=="",d=a!=null&&a.trim()!=="",u=c!=null&&c.length>0;if(!l&&!d&&!u)return null;const h={color:t},m=r>1?{...h,display:"-webkit-box",WebkitBoxOrient:"vertical",WebkitLineClamp:r,overflow:"hidden"}:h,f=u&&(((v=c==null?void 0:c[0])==null?void 0:v.variant)??"primary")==="secondary",o=s.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-4",children:[l&&s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[i?s.jsx("span",{className:"shrink-0",children:i}):null,s.jsx("p",{className:N("min-w-0",Sr),style:h,children:n})]}),d&&s.jsx("p",{className:N(kr,r<=1&&"truncate"),style:m,children:r>1?Ir(a??""):a})]});return s.jsx("div",{className:"shrink-0 px-4 py-3",children:f?s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[o,s.jsx(Ht,{surface:e,actions:c,layout:"row"})]}):s.jsxs(s.Fragment,{children:[o,s.jsx(Ht,{surface:e,actions:c,layout:"stacked"})]})})},Ar={dark:"bg-white/[0.06]",light:"bg-black/[0.04]"},Mr={1:[0],2:[-10,10],3:[-13,0,13]},Rr={1:[0],2:[-26,26],3:[-40,0,40]},Lr={1:[0],2:[0,1],3:[1,3,2]},Or={1:[1],2:[1,1],3:[1,1.08,1]},Dr=({variant:e,images:t})=>{const[n,a]=x.useState({}),r=t.join(`
|
|
2
|
-
`),[i,c]=x.useState(r);r!==i&&(c(r),a({}));const l=t.slice(0,3).map((o,v)=>({src:o,index:v})).filter(({index:o})=>!n[o]),d=l.length>=3?3:l.length===2?2:1,u=Mr[d],h=Rr[d],m=Lr[d],f=Or[d];return s.jsx("div",{className:N("relative flex min-h-0 w-full flex-1 items-center justify-center overflow-hidden",Ar[e]),children:l.map(({src:o,index:v},_)=>s.jsx("img",{src:he(o)??o,alt:"",draggable:!1,loading:"lazy",decoding:"async",onError:()=>a(p=>({...p,[v]:!0})),className:"absolute left-1/2 top-1/2 w-[62%] aspect-[3/2] rounded-[12px] bg-[#ffffff] object-cover shadow-md",style:{transform:`translate(-50%, -50%) translateX(${h[_]}px) rotate(${u[_]}deg) scale(${f[_]})`,zIndex:m[_]}},`${o}-${v}`))})},Fr="flex h-[180px] w-full shrink-0 flex-col overflow-hidden",Pr=({variant:e,presentation:t,images:n,title:a,heroUrl:r,onHeroError:i})=>s.jsx("div",{className:Fr,children:t==="fan"?s.jsx(Dr,{variant:e,images:n}):s.jsx(je,{variant:e,thumbnailUrl:r,title:a,mimeType:"image/*",onImageError:i})}),Ts=({variant:e,title:t,subtitle:n,subtitleLines:a,images:r=[],imagePresentation:i,actions:c,appIcon:l,accentColor:d,groupPosition:u="single"})=>{const h=V.resolveRichCardImagePresentation({imagePresentation:i,images:r}),m=r.length>0,f=m&&h==="hero",o=Oe({variant:e,accentColor:d,layout:"featured",thumbnailUrl:f?r[0]:void 0}),v=u==="single"||u==="end";return s.jsx(tt,{accentHex:o.accentHex,side:e==="dark"?"sender":"receiver",visible:v,children:s.jsxs(ve,{variant:e,accentHex:o.accentHex,"data-testid":"rich-card",children:[m&&s.jsx(Pr,{variant:e,presentation:h,images:r,title:t,heroUrl:f?o.thumbnailUrl:void 0,onHeroError:o.onImageError}),s.jsx(Tr,{ctaSurface:o.surface,chinTextColor:o.chinTextColor,title:t,subtitle:n,subtitleLines:a,appIcon:l,actions:c})]})})},Br=e=>s.jsx(Ts,{...e,variant:"dark"}),zr=e=>s.jsx(Ts,{...e,variant:"light"}),$r={Sent:Br,Received:zr},Vt=`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%`,Ur={sent:"var(--str-chat__own-message-bubble-background-color, #1e2330)",received:"var(--str-chat__message-bubble-background-color, #f1f0ee)"},Hr=({variant:e})=>s.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute bottom-0 z-[-1] h-[1.4375rem] w-5",style:{insetInlineEnd:e==="sent"?"calc(-1 * 0.3125rem)":void 0,insetInlineStart:e==="received"?"calc(-1 * 0.3125rem)":void 0,transform:e==="received"?"scaleX(-1)":void 0,transformOrigin:"center",backgroundColor:Ur[e],WebkitMask:Vt,mask:Vt}}),Vr={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)"}},As=({variant:e,text:t,tail:n=!0,header:a,className:r})=>s.jsx("div",{"data-dd-privacy":"mask",className:N("str-chat__message-bubble","relative","text-[0.875rem] leading-[1.3125rem] tracking-[0.14px]",r),style:{...Vr[e],borderRadius:"var(--str-chat__message-bubble-border-radius, 1.5rem)",isolation:"isolate"},children:s.jsxs("div",{className:"str-chat__message-text",children:[a!=null&&s.jsx("div",{className:"mb-1 font-medium","data-testid":"message-bubble-header",children:a}),s.jsx("p",{className:"m-0 whitespace-pre-wrap break-words hyphens-manual",children:t}),n&&s.jsx(Hr,{variant:e})]})}),Gr=({text:e,tail:t,header:n,className:a})=>s.jsx(As,{variant:"received",text:e,tail:t,header:n,className:a}),Yr=({text:e,tail:t,className:n})=>s.jsx(As,{variant:"sent",text:e,tail:t,className:n}),Wr={Sent:Yr,Received:Gr},Ms=({question:e,onClick:t,loading:n=!1,className:a})=>s.jsx("button",{type:"button",onClick:t,disabled:n,style:{backgroundColor:"#E6E5E3"},className:N("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}),qr=({faqs:e,onFaqClick:t,loadingFaqId:n,headerText:a,className:r,avatarImage:i,avatarName:c})=>{const l=V.selectEnabledFaqs(e);return l.length===0?null:s.jsx("div",{className:r,children:s.jsxs("div",{className:"flex gap-3 items-end",children:[(i||c)&&s.jsx("div",{className:"flex-none",children:s.jsx(me,{id:c||"account",name:c||"Account",image:i,size:24,shape:"circle"})}),s.jsxs("div",{className:"flex-1 flex flex-col gap-3 rounded-lg p-4",style:{backgroundColor:"#F1F0EE"},children:[a&&s.jsx("p",{className:"text-md text-charcoal mb-4",children:a}),l.map(d=>s.jsx(Ms,{question:d.question,onClick:()=>t(d.id),loading:n===d.id},d.id))]})]})})};exports.ActionButton=de;exports.Avatar=me;exports.ChannelEmptyState=Cs;exports.ChannelList=Is;exports.ChannelView=lt;exports.CustomMessageProvider=Js;exports.FaqList=qr;exports.FaqListItem=Ms;exports.LinkAttachment=Ae;exports.LockedAttachment=pe;exports.MessageAttachment=ue;exports.MessageBubble=Wr;exports.MessagingLoggerProvider=Wt;exports.MessagingProvider=Ps;exports.MessagingShell=jr;exports.RichCard=$r;exports.TipMessage=as;exports.bubbleGroupPositionFromStream=Wn;exports.buildCompactMetaLabel=ds;exports.formatFileSize=ls;exports.formatRelativeTime=ks;exports.getFileExtensionLabel=cs;exports.getMessageDisplayText=Ye;exports.getSourceType=xe;exports.isLinkAttachment=Le;exports.isTipMessage=qe;exports.isUuidLike=Zt;exports.normalizeLanguageCode=Qt;exports.optimizeMessagingAttachmentUrl=he;exports.renderTypeIcon=Je;exports.resolveConversationParticipant=Ve;exports.resolveParticipantDisplayName=Ge;exports.useComposerLocked=ar;exports.useCustomMessage=ts;exports.useMessaging=Xt;exports.useMessagingLogger=Fs;
|
|
3
|
-
//# sourceMappingURL=index-8NJc4beJ.cjs.map
|