@linktr.ee/messaging-react 3.1.3 → 3.2.0

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.
Files changed (31) hide show
  1. package/dist/{Card-CqeFyk7l.cjs → Card-B5TCecD6.cjs} +2 -2
  2. package/dist/{Card-CqeFyk7l.cjs.map → Card-B5TCecD6.cjs.map} +1 -1
  3. package/dist/{Card-BHF-XfHG.cjs → Card-CO089n1e.cjs} +2 -2
  4. package/dist/{Card-BHF-XfHG.cjs.map → Card-CO089n1e.cjs.map} +1 -1
  5. package/dist/{Card-Ctub3AU9.js → Card-DQYLHbDI.js} +2 -2
  6. package/dist/{Card-Ctub3AU9.js.map → Card-DQYLHbDI.js.map} +1 -1
  7. package/dist/{Card-RHd97_iq.js → Card-DTaHgygz.js} +2 -2
  8. package/dist/{Card-RHd97_iq.js.map → Card-DTaHgygz.js.map} +1 -1
  9. package/dist/{Card-DvoK42pX.cjs → Card-aO1qZWDU.cjs} +2 -2
  10. package/dist/{Card-DvoK42pX.cjs.map → Card-aO1qZWDU.cjs.map} +1 -1
  11. package/dist/{Card-VEde2Hfe.js → Card-bdnjL_4d.js} +3 -3
  12. package/dist/{Card-VEde2Hfe.js.map → Card-bdnjL_4d.js.map} +1 -1
  13. package/dist/{LockedThumbnail-BPMP5yZP.cjs → LockedThumbnail-CWVybsBb.cjs} +2 -2
  14. package/dist/{LockedThumbnail-BPMP5yZP.cjs.map → LockedThumbnail-CWVybsBb.cjs.map} +1 -1
  15. package/dist/{LockedThumbnail-BADzjHNM.js → LockedThumbnail-nsFA3DjA.js} +2 -2
  16. package/dist/{LockedThumbnail-BADzjHNM.js.map → LockedThumbnail-nsFA3DjA.js.map} +1 -1
  17. package/dist/index-BO2VfA-M.cjs +2 -0
  18. package/dist/index-BO2VfA-M.cjs.map +1 -0
  19. package/dist/{index-CnOvDQIp.js → index-DJKFVBkP.js} +839 -834
  20. package/dist/index-DJKFVBkP.js.map +1 -0
  21. package/dist/index.cjs +1 -1
  22. package/dist/index.d.ts +9 -1
  23. package/dist/index.js +1 -1
  24. package/package.json +4 -3
  25. package/src/components/ChannelView.test.tsx +31 -0
  26. package/src/components/ChannelView.tsx +41 -30
  27. package/src/components/MessagingShell/index.tsx +2 -0
  28. package/src/types.ts +10 -0
  29. package/dist/index-BQf4WkPC.cjs +0 -2
  30. package/dist/index-BQf4WkPC.cjs.map +0 -1
  31. package/dist/index-CnOvDQIp.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-BQf4WkPC.cjs");exports.ActionButton=e.ActionButton;exports.Avatar=e.Avatar;exports.ChannelEmptyState=e.ChannelEmptyState;exports.ChannelList=e.ChannelList;exports.ChannelView=e.ChannelView;exports.CustomMessageProvider=e.CustomMessageProvider;exports.FaqList=e.FaqList;exports.FaqListItem=e.FaqListItem;exports.LinkAttachment=e.LinkAttachment;exports.LockedAttachment=e.LockedAttachment;exports.MediaMessage=e.MediaMessage;exports.MessageAttachment=e.MessageAttachment;exports.MessageVoteButtons=e.MessageVoteButtons;exports.MessagingProvider=e.MessagingProvider;exports.MessagingShell=e.MessagingShell;exports.buildCompactMetaLabel=e.buildCompactMetaLabel;exports.formatFileSize=e.formatFileSize;exports.formatRelativeTime=e.formatRelativeTime;exports.getFileExtensionLabel=e.getFileExtensionLabel;exports.getMessageDisplayText=e.getMessageDisplayText;exports.isLinkAttachment=e.isLinkAttachment;exports.isUuidLike=e.isUuidLike;exports.messageAttachmentGroupPositionFromStream=e.bubbleGroupPositionFromStream;exports.normalizeLanguageCode=e.normalizeLanguageCode;exports.resolveLinkAttachment=e.resolveLinkAttachment;exports.resolveMediaFromMessage=e.resolveMediaFromMessage;exports.resolveParticipantDisplayName=e.resolveParticipantDisplayName;exports.useCustomMessage=e.useCustomMessage;exports.useMessageVote=e.useMessageVote;exports.useMessaging=e.useMessaging;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-BO2VfA-M.cjs");exports.ActionButton=e.ActionButton;exports.Avatar=e.Avatar;exports.ChannelEmptyState=e.ChannelEmptyState;exports.ChannelList=e.ChannelList;exports.ChannelView=e.ChannelView;exports.CustomMessageProvider=e.CustomMessageProvider;exports.FaqList=e.FaqList;exports.FaqListItem=e.FaqListItem;exports.LinkAttachment=e.LinkAttachment;exports.LockedAttachment=e.LockedAttachment;exports.MediaMessage=e.MediaMessage;exports.MessageAttachment=e.MessageAttachment;exports.MessageVoteButtons=e.MessageVoteButtons;exports.MessagingProvider=e.MessagingProvider;exports.MessagingShell=e.MessagingShell;exports.buildCompactMetaLabel=e.buildCompactMetaLabel;exports.formatFileSize=e.formatFileSize;exports.formatRelativeTime=e.formatRelativeTime;exports.getFileExtensionLabel=e.getFileExtensionLabel;exports.getMessageDisplayText=e.getMessageDisplayText;exports.isLinkAttachment=e.isLinkAttachment;exports.isUuidLike=e.isUuidLike;exports.messageAttachmentGroupPositionFromStream=e.bubbleGroupPositionFromStream;exports.normalizeLanguageCode=e.normalizeLanguageCode;exports.resolveLinkAttachment=e.resolveLinkAttachment;exports.resolveMediaFromMessage=e.resolveMediaFromMessage;exports.resolveParticipantDisplayName=e.resolveParticipantDisplayName;exports.useCustomMessage=e.useCustomMessage;exports.useMessageVote=e.useMessageVote;exports.useMessaging=e.useMessaging;
2
2
  //# sourceMappingURL=index.cjs.map
package/dist/index.d.ts CHANGED
@@ -148,7 +148,7 @@ export declare const ChannelView: default_2.NamedExoticComponent<ChannelViewProp
148
148
  * Props that MessagingShell passes through to ChannelView.
149
149
  * ChannelViewProps is the source of truth for these props.
150
150
  */
151
- declare type ChannelViewPassthroughProps = Pick<ChannelViewProps, 'renderMessageInputActions' | 'renderConversationFooter' | 'CustomChannelEmptyState' | 'onBlockParticipantClick' | 'onReportParticipantClick' | 'dmAgentEnabled' | 'onMessageSent' | 'chatbotVotingEnabled' | 'viewerLanguage' | 'renderChannelBanner' | 'customChannelActions' | 'renderMessage' | 'onMessageLinkClick'>;
151
+ declare type ChannelViewPassthroughProps = Pick<ChannelViewProps, 'renderMessageInputActions' | 'renderConversationFooter' | 'CustomChannelEmptyState' | 'onBlockParticipantClick' | 'onReportParticipantClick' | 'dmAgentEnabled' | 'onMessageSent' | 'chatbotVotingEnabled' | 'viewerLanguage' | 'renderChannelBanner' | 'customChannelActions' | 'renderMessage' | 'onMessageLinkClick' | 'showChannelInfo'>;
152
152
 
153
153
  /**
154
154
  * ChannelView component props
@@ -248,6 +248,14 @@ export declare interface ChannelViewProps {
248
248
  * and filter by starred/pinned status.
249
249
  */
250
250
  showStarButton?: boolean;
251
+ /**
252
+ * Show the channel info trigger (kebab) in the header, the clickable
253
+ * participant name on desktop, and mount the channel info dialog. Defaults
254
+ * to true. Set false for surfaces that should not expose the participant
255
+ * profile, block/report/delete actions — e.g. anonymous visitor chat,
256
+ * where the visitor has no authenticated identity to act on.
257
+ */
258
+ showChannelInfo?: boolean;
251
259
  /**
252
260
  * Enable thumbs up/down voting on chatbot messages.
253
261
  * When true, vote buttons render below chatbot (DM Agent) messages.
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { a as e, b as t, C as i, c as n, d as o, e as m, F as g, f as l, L as r, h as M, M as u, i as L, j as c, k as h, l as d, m as p, n as v, o as A, p as C, q as F, s as k, t as b, u as f, v as x, w as y, x as P, y as S, z as q, B as z, D as B } from "./index-CnOvDQIp.js";
1
+ import { a as e, b as t, C as i, c as n, d as o, e as m, F as g, f as l, L as r, h as M, M as u, i as L, j as c, k as h, l as d, m as p, n as v, o as A, p as C, q as F, s as k, t as b, u as f, v as x, w as y, x as P, y as S, z as q, B as z, D as B } from "./index-DJKFVBkP.js";
2
2
  export {
3
3
  e as ActionButton,
4
4
  t as Avatar,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@linktr.ee/messaging-react",
3
- "version": "3.1.3",
3
+ "version": "3.2.0",
4
4
  "description": "React messaging components built on messaging-core for web applications",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
@@ -28,8 +28,9 @@
28
28
  "test:ci": "vitest run",
29
29
  "test:ui": "vitest --ui",
30
30
  "test:coverage": "vitest --coverage",
31
- "lint": "eslint . --ext .ts,.tsx",
32
- "lint:fix": "eslint . --ext .ts,.tsx --fix",
31
+ "lint": "../../node_modules/.bin/eslint . --ext .ts,.tsx",
32
+ "lint:fix": "../../node_modules/.bin/eslint . --ext .ts,.tsx --fix",
33
+ "verify": "yarn type-check && yarn lint && yarn test:ci && yarn build",
33
34
  "storybook": "storybook dev -p 6006",
34
35
  "storybook:build": "storybook build"
35
36
  },
@@ -205,6 +205,37 @@ describe('ChannelView', () => {
205
205
  expect(lastDialogProps().followerStatusLabel).toBeUndefined()
206
206
  })
207
207
 
208
+ it('renders the channel info trigger by default', () => {
209
+ const { container } = renderWithProviders(
210
+ <ChannelView channel={createChannel()} />
211
+ )
212
+
213
+ const infoTriggers = container.querySelectorAll(
214
+ 'button[aria-label="Show info"]'
215
+ )
216
+ expect(infoTriggers.length).toBeGreaterThan(0)
217
+ expect(channelInfoDialogProps.length).toBeGreaterThan(0)
218
+ })
219
+
220
+ it('hides the channel info trigger (both desktop and mobile) when showChannelInfo is false', () => {
221
+ const { container } = renderWithProviders(
222
+ <ChannelView channel={createChannel()} showChannelInfo={false} />
223
+ )
224
+
225
+ const infoTriggers = container.querySelectorAll(
226
+ 'button[aria-label="Show info"]'
227
+ )
228
+ expect(infoTriggers.length).toBe(0)
229
+ })
230
+
231
+ it('does not mount ChannelInfoDialog when showChannelInfo is false', () => {
232
+ renderWithProviders(
233
+ <ChannelView channel={createChannel()} showChannelInfo={false} />
234
+ )
235
+
236
+ expect(channelInfoDialogProps.length).toBe(0)
237
+ })
238
+
208
239
  it('passes composer disabled state and reason to the message input', () => {
209
240
  renderWithProviders(
210
241
  <ChannelView
@@ -143,14 +143,16 @@ const CustomChannelHeader: React.FC<{
143
143
  />
144
144
  </button>
145
145
  )}
146
- <button
147
- className={classNames(ICON_BTN_CLASS, 'bg-[#F1F0EE]')}
148
- onClick={onShowInfo}
149
- type="button"
150
- aria-label="Show info"
151
- >
152
- <DotsThreeIcon className="size-5 text-black/90" />
153
- </button>
146
+ {canShowInfo && (
147
+ <button
148
+ className={classNames(ICON_BTN_CLASS, 'bg-[#F1F0EE]')}
149
+ onClick={onShowInfo}
150
+ type="button"
151
+ aria-label="Show info"
152
+ >
153
+ <DotsThreeIcon className="size-5 text-black/90" />
154
+ </button>
155
+ )}
154
156
  </div>
155
157
  </div>
156
158
  <div className="px-6 py-3 hidden @lg:flex items-center justify-between gap-3 min-h-12 border-b border-b-black/[0.08]">
@@ -267,6 +269,7 @@ const ChannelViewInner: React.FC<{
267
269
  ) => React.ReactNode
268
270
  dmAgentEnabled?: boolean
269
271
  viewerLanguage?: string
272
+ showChannelInfo?: boolean
270
273
  }> = ({
271
274
  onBack,
272
275
  showBackButton,
@@ -292,6 +295,7 @@ const ChannelViewInner: React.FC<{
292
295
  renderMessage,
293
296
  dmAgentEnabled = false,
294
297
  viewerLanguage,
298
+ showChannelInfo = true,
295
299
  }) => {
296
300
  const { channel } = useChannelStateContext()
297
301
  const infoDialogRef = useRef<HTMLDialogElement>(null)
@@ -395,7 +399,7 @@ const ChannelViewInner: React.FC<{
395
399
  onBack={onBack}
396
400
  showBackButton={showBackButton}
397
401
  onShowInfo={handleShowInfo}
398
- canShowInfo={Boolean(participant)}
402
+ canShowInfo={showChannelInfo && Boolean(participant)}
399
403
  showStarButton={showStarButton}
400
404
  dmAgentEnabled={showDmAgentHeader}
401
405
  />
@@ -435,27 +439,32 @@ const ChannelViewInner: React.FC<{
435
439
  </Window>
436
440
  </WithComponents>
437
441
 
438
- {/* Channel Info Dialog */}
439
- <ChannelInfoDialog
440
- dialogRef={infoDialogRef}
441
- onClose={handleCloseInfo}
442
- participant={participant}
443
- participantDisplayName={resolveParticipantDisplayName(
444
- participant?.user
445
- )}
446
- channel={channel}
447
- followerStatusLabel={followerStatusLabel}
448
- onLeaveConversation={onLeaveConversation}
449
- onBlockParticipant={onBlockParticipant}
450
- showDeleteConversation={showDeleteConversation}
451
- showBlockParticipant={showBlockParticipant}
452
- showReportParticipant={showReportParticipant}
453
- onDeleteConversationClick={onDeleteConversationClick}
454
- onBlockParticipantClick={onBlockParticipantClick}
455
- onReportParticipantClick={onReportParticipantClick}
456
- customProfileContent={customProfileContent}
457
- customChannelActions={customChannelActions}
458
- />
442
+ {/* Channel Info Dialog — suppressed entirely when showChannelInfo is
443
+ false so restricted surfaces (e.g. anonymous visitor chat) cannot
444
+ surface the participant profile or block/report/delete actions even
445
+ if the dialog were opened programmatically. */}
446
+ {showChannelInfo && (
447
+ <ChannelInfoDialog
448
+ dialogRef={infoDialogRef}
449
+ onClose={handleCloseInfo}
450
+ participant={participant}
451
+ participantDisplayName={resolveParticipantDisplayName(
452
+ participant?.user
453
+ )}
454
+ channel={channel}
455
+ followerStatusLabel={followerStatusLabel}
456
+ onLeaveConversation={onLeaveConversation}
457
+ onBlockParticipant={onBlockParticipant}
458
+ showDeleteConversation={showDeleteConversation}
459
+ showBlockParticipant={showBlockParticipant}
460
+ showReportParticipant={showReportParticipant}
461
+ onDeleteConversationClick={onDeleteConversationClick}
462
+ onBlockParticipantClick={onBlockParticipantClick}
463
+ onReportParticipantClick={onReportParticipantClick}
464
+ customProfileContent={customProfileContent}
465
+ customChannelActions={customChannelActions}
466
+ />
467
+ )}
459
468
  </>
460
469
  )
461
470
  }
@@ -497,6 +506,7 @@ export const ChannelView = React.memo<ChannelViewProps>(
497
506
  sendButton,
498
507
  attachmentPreviewList,
499
508
  viewerLanguage,
509
+ showChannelInfo = true,
500
510
  }) => {
501
511
  // Custom send message handler that:
502
512
  // 1. Applies messageMetadata if provided
@@ -611,6 +621,7 @@ export const ChannelView = React.memo<ChannelViewProps>(
611
621
  customChannelActions={customChannelActions}
612
622
  renderMessage={renderMessage}
613
623
  viewerLanguage={viewerLanguage}
624
+ showChannelInfo={showChannelInfo}
614
625
  />
615
626
  </Channel>
616
627
  </DmAgentEnabledContext.Provider>
@@ -35,6 +35,7 @@ export const MessagingShell: React.FC<MessagingShellProps> = ({
35
35
  customChannelActions,
36
36
  renderMessage,
37
37
  onMessageLinkClick,
38
+ showChannelInfo,
38
39
  }) => {
39
40
  const {
40
41
  client,
@@ -256,6 +257,7 @@ export const MessagingShell: React.FC<MessagingShellProps> = ({
256
257
  customChannelActions={customChannelActions}
257
258
  renderMessage={renderMessage}
258
259
  onMessageLinkClick={onMessageLinkClick}
260
+ showChannelInfo={showChannelInfo}
259
261
  />
260
262
  </div>
261
263
  </div>
package/src/types.ts CHANGED
@@ -207,6 +207,15 @@ export interface ChannelViewProps {
207
207
  */
208
208
  showStarButton?: boolean
209
209
 
210
+ /**
211
+ * Show the channel info trigger (kebab) in the header, the clickable
212
+ * participant name on desktop, and mount the channel info dialog. Defaults
213
+ * to true. Set false for surfaces that should not expose the participant
214
+ * profile, block/report/delete actions — e.g. anonymous visitor chat,
215
+ * where the visitor has no authenticated identity to act on.
216
+ */
217
+ showChannelInfo?: boolean
218
+
210
219
  /**
211
220
  * Enable thumbs up/down voting on chatbot messages.
212
221
  * When true, vote buttons render below chatbot (DM Agent) messages.
@@ -309,6 +318,7 @@ export type ChannelViewPassthroughProps = Pick<
309
318
  | 'customChannelActions'
310
319
  | 'renderMessage'
311
320
  | 'onMessageLinkClick'
321
+ | 'showChannelInfo'
312
322
  >
313
323
 
314
324
  /**
@@ -1,2 +0,0 @@
1
- "use strict";const t=require("react/jsx-runtime"),m=require("react"),ds=require("@linktr.ee/messaging-core"),j=require("stream-chat-react"),v=require("@phosphor-icons/react"),y=require("classnames"),Te=require("stream-chat-react/experimental"),gt=require("stream-chat"),_t=m.createContext({service:null,client:null,isConnected:!1,isLoading:!1,error:null,capabilities:{},refreshConnection:async()=>{},debug:!1}),Ae=()=>m.useContext(_t),us=({children:e,user:s,serviceConfig:n,apiKey:a,capabilities:r={},debug:i=!1})=>{const o=m.useCallback((I,...k)=>{i&&console.log(`🔥 [MessagingProvider] ${I}`,...k)},[i]);o("🔄 RENDER START",{userId:s==null?void 0:s.id,apiKey:(a==null?void 0:a.substring(0,8))+"...",serviceConfig:!!n,capabilities:Object.keys(r)});const[l,d]=m.useState(null),[x,f]=m.useState(null),[u,h]=m.useState(!1),[c,b]=m.useState(!1),[_,p]=m.useState(null),w=m.useRef(!1),N=m.useRef({userId:s==null?void 0:s.id,apiKey:a,serviceConfig:n,capabilities:r}),M=m.useRef(0);M.current++,o("📊 RENDER INFO",{renderCount:M.current,currentProps:{userId:s==null?void 0:s.id,apiKey:(a==null?void 0:a.substring(0,8))+"..."},propChanges:{userChanged:N.current.userId!==(s==null?void 0:s.id),apiKeyChanged:N.current.apiKey!==a,serviceConfigChanged:N.current.serviceConfig!==n,capabilitiesChanged:N.current.capabilities!==r}}),N.current={userId:s==null?void 0:s.id,apiKey:a,serviceConfig:n,capabilities:r},m.useEffect(()=>{const I=M.current;if(o("🔧 SERVICE INIT EFFECT TRIGGERED",{renderCount:I,apiKey:!!a,serviceConfig:!!n,dependencies:{apiKey:(a==null?void 0:a.substring(0,8))+"...",serviceConfigRef:n,serviceConfigStable:N.current.serviceConfig===n,apiKeyStable:N.current.apiKey===a}}),!a||!n){o("⚠️ SERVICE INIT SKIPPED",{renderCount:I,reason:"Missing apiKey or serviceConfig"});return}o("🚀 CREATING NEW SERVICE",{renderCount:I,apiKey:(a==null?void 0:a.substring(0,8))+"...",serviceConfigChanged:N.current.serviceConfig!==n});const k=new ds.StreamChatService({...n,apiKey:a,debug:i});return d(k),o("✅ SERVICE SET",{renderCount:I,serviceInstance:!!k}),()=>{o("🧹 SERVICE CLEANUP",{renderCount:I,reason:"Effect cleanup"}),k.disconnectUser().catch(console.error)}},[a,n,i,o]);const A=m.useRef(null);m.useEffect(()=>{var k,S;if(o("🔗 USER CONNECTION EFFECT TRIGGERED",{hasService:!!l,hasUser:!!s,userId:s==null?void 0:s.id,isConnecting:w.current,isConnected:u,dependencies:{service:!!l,userId:s==null?void 0:s.id}}),!l||!s){o("⚠️ USER CONNECTION SKIPPED","Missing service or user");return}if(w.current){o("⚠️ USER CONNECTION SKIPPED","Already connecting");return}if(((k=A.current)==null?void 0:k.serviceId)===l&&((S=A.current)==null?void 0:S.userId)===s.id){o("⚠️ USER CONNECTION SKIPPED","Already connected this user with this service");return}(async()=>{o("🚀 STARTING USER CONNECTION",{userId:s.id}),w.current=!0,b(!0),p(null);try{o("📞 CALLING SERVICE.CONNECTUSER",{userId:s.id});const E=await l.connectUser(s);f(E),h(!0),A.current={serviceId:l,userId:s.id},o("✅ USER CONNECTION SUCCESS",{userId:s.id,clientId:E.userID})}catch(E){const D=E instanceof Error?E.message:"Connection failed";p(D),o("❌ USER CONNECTION ERROR",{userId:s.id,error:D})}finally{b(!1),w.current=!1,o("🔄 USER CONNECTION FINISHED",{userId:s.id,isConnected:u})}})()},[l,s,o,u]),m.useEffect(()=>(o("🔌 CLEANUP EFFECT REGISTERED",{hasService:!!l,isConnected:u}),()=>{l&&u?(o("🧹 CLEANUP EFFECT TRIGGERED","Cleaning up connection on unmount"),A.current=null,l.disconnectUser().catch(console.error)):o("🔇 CLEANUP EFFECT SKIPPED",{hasService:!!l,isConnected:u})}),[l,u,o]);const T=m.useCallback(async()=>{if(o("🔄 REFRESH CONNECTION CALLED",{hasService:!!l,hasUser:!!s}),!l||!s){o("⚠️ REFRESH CONNECTION SKIPPED","Missing service or user");return}o("🚀 STARTING CONNECTION REFRESH",{userId:s.id}),b(!0);try{o("🔌 DISCONNECTING FOR REFRESH"),await l.disconnectUser(),o("📞 RECONNECTING FOR REFRESH");const I=await l.connectUser(s);f(I),h(!0),p(null),o("✅ CONNECTION REFRESH SUCCESS",{userId:s.id})}catch(I){const k=I instanceof Error?I.message:"Refresh failed";p(k),o("❌ CONNECTION REFRESH ERROR",{userId:s.id,error:k})}finally{b(!1),o("🔄 CONNECTION REFRESH FINISHED",{userId:s.id})}},[l,s,o]),L=m.useMemo(()=>(o("💫 CONTEXT VALUE MEMOIZATION",{hasService:!!l,hasClient:!!x,isConnected:u,isLoading:c,hasError:!!_,capabilitiesKeys:Object.keys(r)}),{service:l,client:x,isConnected:u,isLoading:c,error:_,capabilities:r,refreshConnection:T,debug:i}),[l,x,u,c,_,r,T,i,o]);return o("🔄 RENDER END",{renderCount:M.current,willRenderChat:!!(x&&u),contextValueReady:!!L}),t.jsx(_t.Provider,{value:L,children:x&&u?t.jsx(j.Chat,{client:x,customClasses:{channelList:"str-chat__channel-list str-chat__channel-list-react bg-transparent lg:border-r-2 border-r-0 border-[#0000000A] p-4"},children:e}):e})},Ct=()=>Ae(),yt=e=>{var a,r;const[s,n]=m.useState(!!((r=(a=e==null?void 0:e.state)==null?void 0:a.membership)!=null&&r.pinned_at));return m.useEffect(()=>{var o;if(!e){n(!1);return}n(!!((o=e.state.membership)!=null&&o.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]),s},ms=/^[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 kt(e){return ms.test(e.trim())}function bt(e,s){const n=e==null?void 0:e.trim();return!n||s&&n===s?!1:!kt(n)}function ce(e){return bt(e==null?void 0:e.name,e==null?void 0:e.id)?e.name.trim():bt(e==null?void 0:e.username,e==null?void 0:e.id)?e.username.trim():"Unknown member"}const pt=["🍎","🍌","🍇","🍊","🍓","🥥","🍒","🥭","🍉","🍋","🥝","🫒","🍈"];function xs(e){let s=0;for(let n=0;n<e.length;n++){const a=e.charCodeAt(n);s=(s<<5)-s+a,s=s&s}return Math.abs(s)}function hs(e){const n=xs(e)%pt.length;return pt[n]}const Z=({id:e,image:s,size:n=40,className:a,starred:r=!1,shape:i="squircle",dmAgentEnabled:o=!1})=>{const l=hs(e),x=n<32?"text-xs":n<56?"text-sm":n<120?"text-lg":"text-4xl",f=n>=40?2:1,u=i==="circle"?{borderRadius:"50%"}:{borderRadius:"1rem"},h=t.jsx("div",{className:"h-full w-full overflow-hidden",style:u,children:s?t.jsx("img",{src:s,alt:"",className:"h-full w-full object-cover"}):t.jsx("div",{"aria-hidden":"true",className:y("avatar-fallback flex h-full w-full items-center justify-center bg-[#E6E5E3] font-semibold select-none transition-colors",x),children:l})});return t.jsxs("div",{className:y("relative flex-shrink-0 !bg-transparent",a),style:{"--str-chat__avatar-size":`${n}px`,width:`${n}px`,height:`${n}px`},children:[r&&t.jsx("div",{"aria-hidden":"true",className:"absolute -left-1.5 -top-1.5 z-10 flex size-5 items-center justify-center rounded-full bg-white shadow-[0_0_0_1px_rgba(0,0,0,0.04),0_4px_8px_rgba(0,0,0,0.06)]",children:t.jsx(v.StarIcon,{className:"size-3 text-yellow-600",weight:"duotone"})}),t.jsx("div",{"data-testid":"avatar-ring",className:y("h-full w-full","bg-transparent"),style:{...u,...o&&{borderWidth:`${f}px`,borderStyle:"solid",borderColor:"var(--AI-Gradient, #7F22FE)",boxShadow:"inset 0 1px 2px 0 rgba(255, 255, 255, 0.5)"}},children:h})]})},oe=({variant:e="default",className:s,children:n,...a})=>{const r=e==="danger";return t.jsx("button",{type:"button",className:y("flex w-full items-center gap-3 rounded-lg px-4 py-3 text-left text-sm transition-colors focus-ring disabled:cursor-not-allowed disabled:opacity-60",r?"text-danger hover:bg-danger/50":"text-charcoal hover:bg-sand",s),...a,children:n})};function fs({label:e,className:s,children:n,...a}){return t.jsxs("button",{type:"button",className:y("inline-flex items-center justify-center rounded-full transition-colors focus-ring p-2",{"cursor-not-allowed opacity-50":a.disabled,"hover:bg-sand":!a.disabled},s),...a,children:[t.jsx("span",{className:"sr-only",children:e}),n]})}function gs({onClick:e}){return t.jsx(fs,{label:"Close",onClick:e,className:"p-1",children:t.jsx(v.XIcon,{className:"h-5 w-5 text-stone",weight:"bold"})})}const bs=({dialogRef:e,onClose:s,participant:n,participantDisplayName:a,channel:r,followerStatusLabel:i,onLeaveConversation:o,onBlockParticipant:l,showDeleteConversation:d=!0,showBlockParticipant:x=!0,showReportParticipant:f=!0,onDeleteConversationClick:u,onBlockParticipantClick:h,onReportParticipantClick:c,customProfileContent:b,customChannelActions:_})=>{var $,H,Y,z;const{service:p,debug:w}=Ae(),[N,M]=m.useState(!1),[A,T]=m.useState(!1),[L,I]=m.useState(!1),k=m.useCallback(async()=>{var g;if(!(!x||!p||!((g=n==null?void 0:n.user)!=null&&g.id)))try{const P=(await p.getBlockedUsers()).some(R=>{var q;return R.blocked_user_id===((q=n==null?void 0:n.user)==null?void 0:q.id)});M(P)}catch(C){console.error("[ChannelInfoDialog] Failed to check blocked status:",C)}},[p,($=n==null?void 0:n.user)==null?void 0:$.id,x]);m.useEffect(()=>{k()},[k]);const S=async()=>{var g;if(!A){u==null||u(),w&&console.log("[ChannelInfoDialog] Leave conversation",r.cid),T(!0);try{const C=((g=r._client)==null?void 0:g.userID)??null;await r.hide(C,!1),o&&await o(r),s()}catch(C){console.error("[ChannelInfoDialog] Failed to leave conversation",C)}finally{T(!1)}}},E=async()=>{var g,C,P;if(!(L||!p)){h==null||h(),w&&console.log("[ChannelInfoDialog] Block member",(g=n==null?void 0:n.user)==null?void 0:g.id),I(!0);try{await p.blockUser((C=n==null?void 0:n.user)==null?void 0:C.id),l&&await l((P=n==null?void 0:n.user)==null?void 0:P.id),s()}catch(R){console.error("[ChannelInfoDialog] Failed to block member",R)}finally{I(!1)}}},D=async()=>{var g,C,P;if(!(L||!p)){h==null||h(),w&&console.log("[ChannelInfoDialog] Unblock member",(g=n==null?void 0:n.user)==null?void 0:g.id),I(!0);try{await p.unBlockUser((C=n==null?void 0:n.user)==null?void 0:C.id),l&&await l((P=n==null?void 0:n.user)==null?void 0:P.id),s()}catch(R){console.error("[ChannelInfoDialog] Failed to unblock member",R)}finally{I(!1)}}},V=()=>{c==null||c(),s(),window.open("https://linktr.ee/s/about/trust-center/report","_blank","noopener,noreferrer")};if(!n)return null;const O=a??ce(n.user),W=(H=n.user)==null?void 0:H.image,U=(Y=n.user)==null?void 0:Y.username,G=U?`linktr.ee/${U}`:void 0,F=((z=n.user)==null?void 0:z.id)||"unknown";return t.jsx("dialog",{ref:e,className:"mes-dialog group",onClose:s,onClick:g=>{g.target===e.current&&s()},children:t.jsxs("div",{className:"ml-auto flex h-full w-full flex-col bg-white shadow-none transition-shadow duration-200 group-open:shadow-max-elevation-light",children:[t.jsxs("div",{className:"flex items-center justify-between border-b border-sand px-4 py-3",children:[t.jsx("h2",{className:"text-base font-semibold text-charcoal",children:"Chat info"}),t.jsx(gs,{onClick:s})]}),t.jsxs("div",{className:"flex-1 px-2 overflow-y-auto w-full",children:[t.jsxs("div",{className:"flex flex-col items-center gap-3 self-stretch px-4 py-2 mt-6 rounded-lg border border-black/[0.04]",style:{backgroundColor:"#FBFAF9"},children:[t.jsxs("div",{className:"flex items-center gap-3 w-full",children:[t.jsx(Z,{id:F,name:O,image:W,size:88,shape:"circle"}),t.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[t.jsx("p",{className:"truncate text-base font-semibold text-charcoal",children:O}),G&&t.jsx("p",{className:"truncate text-sm text-[#00000055]",children:G}),i&&!b&&t.jsx("span",{className:"mt-1 rounded-full text-xs font-normal w-fit",style:{padding:"4px 8px",backgroundColor:i==="Subscribed to you"?"#DCFCE7":"#F5F5F4",color:i==="Subscribed to you"?"#008236":"#78716C",lineHeight:"133.333%",letterSpacing:"0.21px"},children:i})]})]}),b&&t.jsx("div",{className:"w-full",children:b})]}),t.jsxs("ul",{className:"flex flex-col gap-2 mt-2",children:[d&&t.jsx("li",{children:t.jsxs(oe,{onClick:S,disabled:A,"aria-busy":A,children:[A?t.jsx(v.SpinnerGapIcon,{className:"h-5 w-5 animate-spin"}):t.jsx(v.SignOutIcon,{className:"h-5 w-5"}),t.jsx("span",{children:"Delete Conversation"})]})}),x&&t.jsx("li",{children:N?t.jsxs(oe,{onClick:D,disabled:L,"aria-busy":L,children:[L?t.jsx(v.SpinnerGapIcon,{className:"h-5 w-5 animate-spin"}):t.jsx(v.ProhibitInsetIcon,{className:"h-5 w-5"}),t.jsx("span",{children:"Unblock"})]}):t.jsxs(oe,{onClick:E,disabled:L,"aria-busy":L,children:[L?t.jsx(v.SpinnerGapIcon,{className:"h-5 w-5 animate-spin"}):t.jsx(v.ProhibitInsetIcon,{className:"h-5 w-5"}),t.jsx("span",{children:"Block"})]})}),f&&t.jsx("li",{children:t.jsxs(oe,{variant:"danger",onClick:V,children:[t.jsx(v.FlagIcon,{className:"h-5 w-5"}),t.jsx("span",{children:"Report"})]})}),_]})]})]})})},ps=e=>t.jsx(j.DateSeparator,{...e,position:"center"}),Se="vote_up",Ee="vote_down";function vs(e){return e!=null&&e.length?e.some(s=>s.type===Ee)?"down":e.some(s=>s.type===Se)?"up":null:null}function St(e){const{channel:s}=j.useChannelStateContext(),{client:n}=j.useChatContext("useMessageVote"),a=m.useMemo(()=>vs(e.own_reactions),[e.own_reactions]),r=m.useCallback(async()=>{if(n!=null&&n.userID)try{a==="up"?await s.deleteReaction(e.id,Se):await s.sendReaction(e.id,{type:Se},{enforce_unique:!0,skip_push:!0})}catch{}},[s,n==null?void 0:n.userID,e.id,a]),i=m.useCallback(async()=>{if(n!=null&&n.userID)try{a==="down"?await s.deleteReaction(e.id,Ee):await s.sendReaction(e.id,{type:Ee},{enforce_unique:!0,skip_push:!0})}catch{}},[s,n==null?void 0:n.userID,e.id,a]);return{selected:a,voteUp:r,voteDown:i}}function Et(e){return(e==null?void 0:e.trim().toLowerCase().split(/[-_]/)[0])||void 0}function Me({message:e,viewerLanguage:s}){var r;const n=e==null?void 0:e.text,a=Et(s);return a?((r=e==null?void 0:e.i18n)==null?void 0:r[`${a}_text`])??n:n}const js=m.lazy(()=>Promise.resolve().then(()=>require("./Card-BHF-XfHG.cjs"))),ws=m.lazy(()=>Promise.resolve().then(()=>require("./Card-DvoK42pX.cjs"))),Ns=m.lazy(()=>Promise.resolve().then(()=>require("./Card-CqeFyk7l.cjs"))),Re=()=>t.jsx("div",{className:"w-[280px] min-h-[200px] animate-pulse rounded-md bg-black/[0.06] shadow-[0_0_0_1px_rgba(0,0,0,0.04),0_1px_2px_rgba(0,0,0,0.04),0_8px_32px_rgba(0,0,0,0.1)]","aria-hidden":!0}),_s=e=>t.jsx(m.Suspense,{fallback:t.jsx(Re,{}),children:t.jsx(js,{...e})}),It=e=>t.jsx(m.Suspense,{fallback:t.jsx(Re,{}),children:t.jsx(ws,{...e})}),Tt=e=>t.jsx(m.Suspense,{fallback:t.jsx(Re,{}),children:t.jsx(Ns,{...e})}),Cs=It,ys=Tt,Ie={Composer:_s,Sent:It,Received:Tt,Creator:Cs,Visitor:ys},ks=[[/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 ee(e){return e.startsWith("video/")?"video":e.startsWith("audio/")?"audio":e.startsWith("image/")?"image":"document"}function At(e){const s=ks.find(([n])=>n.test(e));return s?s[1]:"generic"}const Ss={video:v.VideoCameraIcon,audio:v.SpeakerHighIcon,image:v.ImageIcon,document:v.FileIcon},Es={pdf:v.FilePdfIcon,doc:v.FileDocIcon,xls:v.FileXlsIcon,csv:v.FileCsvIcon,ppt:v.FilePptIcon,zip:v.FileZipIcon,text:v.FileTextIcon,markdown:v.FileMdIcon,generic:v.FileIcon};function Is(e){const s=ee(e);return s!=="document"?Ss[s]:Es[At(e)]}function te(e,s){return m.createElement(Is(e),s)}const Ts=e=>{var s,n;return"touches"in e?((s=e.touches[0])==null?void 0:s.clientX)??((n=e.changedTouches[0])==null?void 0:n.clientX)??0:e.clientX},As=({source:e,mimeType:s,poster:n,autoPlay:a=!1,playing:r,loop:i=!1,controls:o=!0,showProgress:l=!1,muted:d=!1,onContainerClick:x})=>{const f=ee(s),u=m.useRef(null),h=m.useRef(null),c=m.useRef(null),b=m.useRef(r),[_,p]=m.useState(a),[w,N]=m.useState(0),[M,A]=m.useState(!1),[T,L]=m.useState(!1),[I,k]=m.useState(!1),[S,E]=m.useState(!1),[D,V]=m.useState(!0),[O,W]=m.useState(null),U=m.useCallback(()=>{k(!1),p(!0)},[]),G=m.useCallback(g=>{const C=h.current;if(!C)return 0;const P=C.getBoundingClientRect();return Math.max(0,Math.min(1,(Ts(g)-P.left)/P.width))},[]),F=m.useCallback(g=>{const C=u.current;C&&C.duration&&(C.currentTime=g*C.duration)},[]),$=g=>{g.stopPropagation(),A(!0);const C=G(g);N(C),F(C)};m.useEffect(()=>{r!==void 0&&r!==b.current&&(b.current=r,p(r))},[r]),m.useEffect(()=>{if(!_){c.current!==null&&(cancelAnimationFrame(c.current),c.current=null);return}const g=()=>{const C=u.current;C&&C.duration&&!M&&N(C.currentTime/C.duration),c.current=requestAnimationFrame(g)};return c.current=requestAnimationFrame(g),()=>{c.current!==null&&cancelAnimationFrame(c.current)}},[_,M]),m.useEffect(()=>{const g=u.current;g&&(_?g.play().catch(C=>{p(!1),k(!0)}):g.pause())},[_]),m.useEffect(()=>{if(!M)return;const g=P=>N(G(P)),C=P=>{A(!1),F(G(P))};return window.addEventListener("mousemove",g),window.addEventListener("mouseup",C),window.addEventListener("touchmove",g,{passive:!0}),window.addEventListener("touchend",C),()=>{window.removeEventListener("mousemove",g),window.removeEventListener("mouseup",C),window.removeEventListener("touchmove",g),window.removeEventListener("touchend",C)}},[M,G,F]);const H=O?{aspectRatio:String(O)}:void 0,Y=O?"":" aspect-video",z=Math.round(w*100);return t.jsxs("div",{role:"button",tabIndex:0,className:`relative cursor-pointer overflow-hidden bg-black ${Y}`,style:H,onClick:g=>{if(x){x(g);return}I||o&&p(C=>!C)},onKeyDown:g=>{if(!(g.key!=="Enter"&&g.key!==" ")){if(g.preventDefault(),x){x(g);return}I||o&&p(C=>!C)}},children:[n&&(f==="audio"||D)&&t.jsx("img",{src:n,alt:"",className:"absolute inset-0 h-full w-full object-cover"}),!n&&(f==="audio"||D)&&t.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:te(s,{className:"size-12 text-black/20",weight:"regular"})}),t.jsx("div",{className:"absolute inset-0",children:f==="audio"?t.jsx("audio",{ref:u,src:e,loop:i,muted:d,style:{width:"100%",height:"100%"},onLoadStart:()=>E(!0),onCanPlay:()=>{E(!1),V(!1)},onWaiting:()=>E(!0),onPlay:()=>k(!1),onEnded:()=>{i||(p(!1),N(0))},children:t.jsx("track",{kind:"captions"})}):t.jsx("video",{ref:u,src:e,loop:i,muted:d,playsInline:!0,style:{width:"100%",height:"100%"},onLoadStart:()=>E(!0),onCanPlay:()=>{E(!1),V(!1)},onWaiting:()=>E(!0),onPlay:()=>k(!1),onLoadedMetadata:()=>{const g=u.current;g instanceof HTMLVideoElement&&g.videoWidth&&g.videoHeight&&W(g.videoWidth/g.videoHeight)},onEnded:()=>{i||(p(!1),N(0))},children:t.jsx("track",{kind:"captions"})})}),S&&!I&&t.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center",children:t.jsx(v.CircleNotchIcon,{className:"size-8 animate-spin text-white/80",weight:"bold"})}),I&&!o&&t.jsx("div",{className:"absolute inset-0 z-30 flex cursor-pointer items-center justify-center bg-black/35",role:"button",tabIndex:0,"aria-label":"Play preview",onClick:g=>{g.stopPropagation(),U()},onKeyDown:g=>{g.key!=="Enter"&&g.key!==" "||(g.preventDefault(),g.stopPropagation(),U())},children:t.jsx("span",{className:"flex size-16 items-center justify-center rounded-full bg-white/20 text-white backdrop-blur-sm",children:t.jsx(v.PlayIcon,{className:"size-9 translate-x-0.5",weight:"fill"})})}),l&&!o&&t.jsx("div",{className:"absolute inset-x-0 bottom-0 px-3 pb-2.5 pt-6 bg-gradient-to-t from-black/40 to-transparent",children:t.jsx("div",{role:"slider","aria-label":"Playback position","aria-valuenow":z,"aria-valuemin":0,"aria-valuemax":100,tabIndex:0,ref:h,className:"relative flex h-4 w-full cursor-pointer items-center",onMouseDown:$,onTouchStart:$,onClick:g=>g.stopPropagation(),onKeyDown:g=>{g.key==="ArrowRight"&&F(Math.min(1,w+.05)),g.key==="ArrowLeft"&&F(Math.max(0,w-.05))},children:t.jsx("div",{className:"w-full overflow-hidden rounded-full bg-white/30 h-1",children:t.jsx("div",{className:"h-full rounded-full bg-white",style:{width:`${z}%`}})})})}),o&&t.jsxs("div",{className:"absolute inset-x-0 bottom-0 flex items-center gap-2 bg-gradient-to-t from-black/60 to-transparent px-3 pb-2.5 pt-6 transition-all duration-200",children:[t.jsx("button",{type:"button",onClick:g=>{g.stopPropagation(),p(C=>!C)},className:"shrink-0 text-white","aria-label":_?"Pause":"Play",children:_?t.jsx(v.PauseIcon,{className:"size-5",weight:"fill"}):t.jsx(v.PlayIcon,{className:"size-5 translate-x-px",weight:"fill"})}),t.jsxs("div",{role:"slider","aria-label":"Playback position","aria-valuenow":z,"aria-valuemin":0,"aria-valuemax":100,tabIndex:0,ref:h,className:"relative flex h-4 w-full cursor-pointer items-center",onMouseDown:$,onTouchStart:$,onClick:g=>g.stopPropagation(),onMouseEnter:()=>L(!0),onMouseLeave:()=>L(!1),onKeyDown:g=>{g.key==="ArrowRight"&&F(Math.min(1,w+.05)),g.key==="ArrowLeft"&&F(Math.max(0,w-.05))},children:[t.jsx("div",{className:`w-full overflow-hidden rounded-full bg-white/30 transition-all duration-200 ${T||M?"h-1.5":"h-1"}`,children:t.jsx("div",{className:"h-full rounded-full bg-white",style:{width:`${z}%`}})}),t.jsx("div",{className:`absolute size-3 -translate-x-1/2 rounded-full bg-white shadow transition-[opacity,transform] duration-200 ${T||M?"scale-100 opacity-100":"scale-0 opacity-0"}`,style:{left:`${z}%`}})]})]})]})},vt=e=>e==="dark"?"size-12 text-white/20":"size-12 text-black/20",Ms=e=>e==="dark"?"aspect-video overflow-hidden bg-white/10":"aspect-video overflow-hidden bg-black/5",De=({mimeType:e,sourceUrl:s,thumbnailUrl:n,title:a,variant:r,mediaPlayerProps:i,containedImage:o=!1})=>{const l=ee(e),[d,x]=m.useState(!1);return s&&(l==="video"||l==="audio")?t.jsx(As,{source:s,mimeType:e,poster:n,controls:!0,...i}):s&&l==="image"?o?t.jsx("div",{className:"relative aspect-video overflow-hidden bg-black/5",children:t.jsx("img",{src:s,alt:a??"",className:`absolute inset-0 h-full w-full object-contain transition-opacity duration-300 ${d?"opacity-100":"opacity-0"}`,draggable:!1,onLoad:()=>x(!0)})}):t.jsx("img",{src:s,alt:a??"",className:"block w-full",draggable:!1}):s&&l==="document"?n?o?t.jsx("div",{className:"relative aspect-video overflow-hidden bg-black/5",children:t.jsx("img",{src:n,alt:a??"",className:`absolute inset-0 h-full w-full object-contain transition-opacity duration-300 ${d?"opacity-100":"opacity-0"}`,draggable:!1,onLoad:()=>x(!0)})}):t.jsx("img",{src:n,alt:"",className:"block w-full",draggable:!1}):t.jsx("div",{className:`flex aspect-video w-full items-center justify-center ${r==="dark"?"bg-white/10":"bg-black/5"}`,children:te(e,{className:vt(r),weight:"regular"})}):n?t.jsx("div",{className:`relative ${Ms(r)}`,children:t.jsx("img",{src:n,alt:a??"",draggable:!1,className:"absolute inset-0 h-full w-full object-cover"})}):t.jsx("div",{className:`flex aspect-video w-full items-center justify-center ${r==="dark"?"bg-white/10":"bg-black/5"}`,children:te(e,{className:vt(r),weight:"regular"})})},Mt=({variant:e,thumbnail:s,title:n,placeholderTitle:a="Attachment title",mimeType:r,detail:i,statusBadge:o,action:l,topLeft:d,topRight:x,rootRef:f,"data-testid":u})=>{const h=e==="dark",c=h?n??a:n??"",b=h&&!n;return t.jsxs("div",{ref:f,"data-testid":u,className:y("relative w-[280px] select-none overflow-hidden rounded-[24px] shadow-[0_0_0_1px_rgba(0,0,0,0.04),0_4px_8px_rgba(0,0,0,0.06)]",h?"bg-[#121110]":"bg-white"),children:[d?t.jsx("div",{className:"pointer-events-auto absolute left-3 top-3 z-50",children:d}):null,x?t.jsx("div",{className:"pointer-events-auto absolute right-3 top-3 z-50",children:x}):null,s,t.jsxs("div",{className:"px-4 pb-3 pt-3",children:[c.trim()!==""&&t.jsx("p",{className:y("mb-0.5 truncate text-base font-medium",{"text-black":!h,"text-white/30":h&&b,"text-white":h&&!b}),children:c}),t.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[te(r,{className:y("size-5 shrink-0",h?"text-white/55":"text-black/55"),weight:"regular"}),i!=null&&i!==""&&t.jsx("span",{className:y("text-xs font-medium",h?"text-white/55":"text-black/55"),children:i}),o]}),l]})]})};function Rt(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function Le(e){return`w-[280px] select-none overflow-hidden rounded-[24px] ${e?"bg-[#121110]":"bg-[#F3F3F1]"} shadow-[0_0_0_1px_rgba(0,0,0,0.04),0_4px_8px_rgba(0,0,0,0.06)]`}function Rs(e){return e?"bg-white/10":"bg-black/5"}function Ds(e){return e?"text-white":"text-black"}function Ls(e){return e?"text-white/55":"text-black/55"}function Ps(e){return e?"text-white/40":"text-black/40"}function Fs(e){return e?"text-white/20":"text-black/20"}const Pe=({attachment:e,isMyMessage:s})=>{const{title:n,text:a,image_url:r,og_scrape_url:i,title_link:o}=e,l=i??o,d=typeof l=="string"&&l.trim()!==""?l:void 0,x=t.jsxs(m.Fragment,{children:[t.jsx("div",{className:"p-2",children:r?t.jsx("img",{src:r,alt:n??"",className:"aspect-video w-full rounded-[20px] object-cover"}):t.jsx("div",{className:`aspect-video w-full rounded-[20px] ${Rs(s)} flex items-center justify-center`,children:t.jsx(v.LinkIcon,{className:`size-12 ${Fs(s)}`})})}),t.jsxs("div",{className:"px-3 pb-3",children:[n&&t.jsx("p",{className:`truncate text-[14px] font-medium leading-5 ${Ds(s)}`,children:n}),a&&t.jsx("p",{className:`truncate text-[12px] leading-4 ${Ls(s)}`,children:a}),d&&t.jsx("p",{className:`mt-1 truncate text-[12px] leading-4 ${Ps(s)}`,children:d})]})]});return d?t.jsx("a",{href:d,target:"_blank",rel:"noopener noreferrer",className:"block no-underline",children:x}):t.jsx("div",{className:"block",children:x})};function Fe(e){return e.type==="link"||!!e.og_scrape_url&&!e.asset_url}function ve(e){var s;return(s=e.attachments)==null?void 0:s.find(Fe)}async function Os(e,s){let n;try{n=s??new URL(e).pathname.split("/").pop()??"download"}catch{n=s??"download"}const a=await fetch(e,{mode:"cors"});if(!a.ok)throw new Error(`HTTP ${a.status}`);const r=await a.blob(),i=URL.createObjectURL(r),o=document.createElement("a");o.href=i,o.download=n,o.style.display="none",document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(i)}const zs=({url:e,filename:s})=>{const[n,a]=m.useState(!1),r=i=>{i.stopPropagation();const o=window.open("","_blank","noopener,noreferrer");a(!0),Os(e,s).then(()=>{o==null||o.close()}).catch(()=>{o&&(o.location.href=e)}).finally(()=>a(!1))};return t.jsx("button",{type:"button",onClick:r,disabled:n,className:"mt-3 inline-flex h-10 w-full items-center justify-center gap-2 rounded-full bg-[#121110] px-4 text-sm font-medium leading-none text-white hover:bg-[#2a2928] disabled:opacity-70",children:n?t.jsx(v.CircleNotchIcon,{className:"size-4 animate-spin text-white",weight:"bold"}):t.jsxs(m.Fragment,{children:[t.jsx(v.DownloadSimpleIcon,{className:"size-4 text-white",weight:"bold"}),"Download"]})})};function je(e){var u,h,c,b;const s=(u=e.attachments)==null?void 0:u.find(_=>_.type==="video"&&_.asset_url),n=(h=e.attachments)==null?void 0:h.find(_=>_.type==="image"&&_.image_url),a=(c=e.attachments)==null?void 0:c.find(_=>_.type==="audio"&&_.asset_url),r=(b=e.attachments)==null?void 0:b.find(_=>_.type==="file"&&_.asset_url),i=s??n??a??r,o=(s==null?void 0:s.asset_url)??(n==null?void 0:n.image_url)??(a==null?void 0:a.asset_url)??(r==null?void 0:r.asset_url);if(!o)return null;const l=(i==null?void 0:i.mime_type)??((i==null?void 0:i.type)==="image"?"image/jpeg":(i==null?void 0:i.type)==="video"?"video/mp4":(i==null?void 0:i.type)==="audio"?"audio/mpeg":"application/octet-stream"),d=i==null?void 0:i.title,x=i==null?void 0:i.file_size,f=s==null?void 0:s.thumb_url;return{resolvedUrl:o,resolvedType:l,title:d,fileSize:x,thumbnailUrl:f}}const Dt=({resolvedUrl:e,resolvedType:s,title:n,fileSize:a,thumbnailUrl:r})=>{const i=a!==void 0?Rt(a):void 0;return t.jsx(Mt,{variant:"dark",title:n,placeholderTitle:"",mimeType:s,detail:i,thumbnail:t.jsx(De,{mimeType:s,sourceUrl:e,thumbnailUrl:r,title:n,variant:"dark"})})},Lt=({resolvedUrl:e,resolvedType:s,title:n,fileSize:a,thumbnailUrl:r})=>{const i=ee(s),o=a!==void 0?Rt(a):void 0;return t.jsx(Mt,{variant:"light",title:n,mimeType:s,detail:o,thumbnail:t.jsx(De,{mimeType:s,sourceUrl:e,thumbnailUrl:r,title:n,variant:"light",containedImage:i==="image"||i==="document"}),action:t.jsx(zs,{url:e,filename:n})})},$s=({message:e,isMyMessage:s=!1})=>{const n=ve(e),a=je(e);if(!n&&!a)return null;const r=s?"str-chat__message str-chat__message-simple str-chat__message--me str-chat__message-simple--me":"str-chat__message str-chat__message-simple str-chat__message--other";return t.jsxs("div",{className:r,children:[!s&&e.user&&t.jsx(Z,{className:"str-chat__avatar str-chat__message-sender-avatar",id:e.user.id,image:e.user.image,name:e.user.name??e.user.id}),t.jsx("div",{className:"str-chat__message-inner",style:{marginInlineEnd:0,marginInlineStart:0},children:t.jsx("div",{className:"str-chat__message-bubble-wrapper",children:t.jsx("div",{className:"str-chat__message-bubble",style:{padding:0,borderRadius:0,overflow:"visible",background:"transparent"},children:n?t.jsx("div",{className:Le(s),children:t.jsx(Pe,{attachment:n,isMyMessage:s})}):s?t.jsx(Dt,{...a}):t.jsx(Lt,{...a})})})})]})},Bs=({message:e})=>{const s=ve(e);if(s)return t.jsx("div",{className:Le(!0),children:t.jsx(Pe,{attachment:s,isMyMessage:!0})});const n=je(e);return n?t.jsx(Dt,{...n}):null},Vs=({message:e})=>{const s=ve(e);if(s)return t.jsx("div",{className:Le(!1),children:t.jsx(Pe,{attachment:s,isMyMessage:!1})});const n=je(e);return n?t.jsx(Lt,{...n}):null},Us=Object.assign($s,{Creator:Bs,Visitor:Vs}),Gs={isUnlocking:()=>!1},Hs={LockedAttachment:Gs},Pt=m.createContext({}),Ys=Pt.Provider;function Ft(e){return m.useContext(Pt)[e]??Hs[e]}const qs=({size:e=15})=>t.jsx("svg",{width:e,height:e,viewBox:"0 0 15 15",fill:"none","aria-hidden":"true",children:t.jsx("path",{d:"M12.003 9a.985.985 0 0 1-.652.934l-3.223 1.191-1.188 3.226a.995.995 0 0 1-1.867 0l-1.195-3.226L.65 9.937a.995.995 0 0 1 0-1.867l3.227-1.195 1.187-3.226a.995.995 0 0 1 1.868 0l1.195 3.226 3.226 1.187a.99.99 0 0 1 .649.938m3-5.83a.52.52 0 0 1-.344.492l-1.702.63-.627 1.703a.525.525 0 0 1-.986 0l-.63-1.704-1.704-.627a.525.525 0 0 1 0-.986l1.703-.63.627-1.704a.526.526 0 0 1 .986 0l.631 1.703 1.704.627a.52.52 0 0 1 .342.495",fill:"currentColor",fillOpacity:.55})}),Xs=e=>{var s;return((s=e.metadata)==null?void 0:s.custom_type)==="MESSAGE_TIP"},Ws=e=>{var s;return((s=e.metadata)==null?void 0:s.custom_type)==="MESSAGE_PAID"},fe=e=>{var s;return((s=e.metadata)==null?void 0:s.custom_type)==="MESSAGE_CHATBOT"},Ks=e=>{var s;return((s=e.metadata)==null?void 0:s.custom_type)==="MESSAGE_ATTACHMENT"},Ot=e=>Xs(e)||Ws(e),Js=e=>{var s;return Ot(e)&&!((s=e.text)!=null&&s.trim())},_e=({message:e,standalone:s=!1,isMyMessage:n=!1,hasAttachment:a=!1})=>{var u;const r=Ot(e),i=fe(e);if(!r&&!i)return null;if(r){const h=(u=e.metadata)==null?void 0:u.amount_text;if(!h)return null;const c=s?"message-tip-standalone":"message-tag message-tag--tip",b=s?`${h} tip`:`Delivered with ${h} tip`;return t.jsxs("div",{className:c,children:[t.jsx(v.GiftIcon,{size:s?14:12}),t.jsx("span",{children:b})]})}const o=n&&a,l=o?"Sent with AI":"Sent with DM Agent",d=["message-chatbot-indicator",n?"message-chatbot-indicator--sender":"message-chatbot-indicator--receiver",o?"message-chatbot-indicator--attachment":"message-chatbot-indicator--text"].join(" "),x=t.jsx("span",{className:"message-chatbot-indicator__label",children:l}),f=t.jsx("span",{className:"message-chatbot-indicator__icon",children:t.jsx(qs,{size:o?12:15})});return t.jsx("div",{className:d,"data-testid":"message-chatbot-indicator",children:n&&!o?t.jsxs(t.Fragment,{children:[x,f]}):t.jsxs(t.Fragment,{children:[f,x]})})},zt=({selected:e,onVoteUp:s,onVoteDown:n})=>t.jsxs("div",{className:"message-vote-buttons",children:[t.jsx("button",{type:"button",className:y("message-vote-button focus-ring",{"message-vote-button--selected":e==="up"}),onClick:s,"aria-label":"Good response","aria-pressed":e==="up","data-tooltip":"Good response",children:t.jsx(v.ThumbsUpIcon,{size:16,weight:e==="up"?"fill":"regular"})}),t.jsx("button",{type:"button",className:y("message-vote-button focus-ring",{"message-vote-button--selected":e==="down"}),onClick:n,"aria-label":"Bad response","aria-pressed":e==="down","data-tooltip":"Bad response",children:t.jsx(v.ThumbsDownIcon,{size:16,weight:e==="down"?"fill":"regular"})})]}),Zs=e=>{var et,tt,st,nt,at,rt,it,ot,lt,ct,dt,ut,mt,xt;const{additionalMessageInputProps:s,chatbotVotingEnabled:n,editing:a,endOfGroup:r,firstOfGroup:i,groupedByUser:o,handleAction:l,handleOpenThread:d,handleRetry:x,highlighted:f,isMessageAIGenerated:u,isMyMessage:h,message:c,renderText:b,threadList:_,viewerLanguage:p}=e,{client:w}=j.useChatContext("CustomMessage"),{channel:N}=j.useChannelStateContext("CustomMessage"),{isUnlocking:M,onUnlockClick:A,onFetchSource:T,onDownloadClick:L}=Ft("LockedAttachment"),[I,k]=m.useState(!1),S=j.useMessageReminder(c.id),{selected:E,voteUp:D,voteDown:V}=St(c),{Attachment:O=j.Attachment,EditMessageModal:W=j.EditMessageModal,MessageActions:U,MessageBlocked:G=j.MessageBlocked,MessageBouncePrompt:F=j.MessageBouncePrompt,MessageDeleted:$=j.MessageDeleted,MessageIsThreadReplyInChannelButtonIndicator:H=j.MessageIsThreadReplyInChannelButtonIndicator,MessageRepliesCountButton:Y=j.MessageRepliesCountButton,ReminderNotification:z=j.ReminderNotification,StreamedMessageText:g=j.StreamedMessageText,PinIndicator:C}=j.useComponentContext("CustomMessage"),P=j.messageHasAttachments(c),R=j.messageHasReactions(c),q=m.useMemo(()=>u==null?void 0:u(c),[u,c]),B=m.useMemo(()=>{const ie=c.attachments??[],he=c.shared_location?[c.shared_location,...ie]:ie;if(!fe(c))return he;const ht=he.filter(ft=>!("type"in ft)||!Fe(ft));return ht.length===he.length?he:ht},[c]),X=m.useMemo(()=>{const ie=Me({message:c,viewerLanguage:p});return ie===c.text?c:{...c,text:ie}},[c,p]);if(j.isDateSeparatorMessage(c))return null;if(c.deleted_at||c.type==="deleted")return t.jsx($,{message:c});if(j.isMessageBlocked(c))return t.jsx(G,{});const J=!_&&!!c.reply_count,K=!_&&c.show_in_channel&&c.parent_id,Xe=c.status==="failed"&&((et=c.error)==null?void 0:et.status)!==403,We=j.isMessageBounced(c);let se;Xe?se=()=>x(c):We&&(se=()=>k(!0));const ae=h(),cs=y("str-chat__message str-chat__message-simple",`str-chat__message--${c.type}`,`str-chat__message--${c.status}`,ae?"str-chat__message--me str-chat__message-simple--me":"str-chat__message--other",c.text?"str-chat__message--has-text":"has-no-text",{"str-chat__message--has-attachment":P,"str-chat__message--highlighted":f,"str-chat__message--pinned pinned-message":c.pinned,"str-chat__message--with-reactions":R,"str-chat__message-send-can-be-retried":(c==null?void 0:c.status)==="failed"&&((tt=c==null?void 0:c.error)==null?void 0:tt.status)!==403,"str-chat__message-with-thread-link":J||K,"str-chat__virtual-message__wrapper--end":r,"str-chat__virtual-message__wrapper--first":i,"str-chat__virtual-message__wrapper--group":o}),Ke=c.poll_id&&w.polls.fromState(c.poll_id),Je=Js(c),re=fe(c),Ze=Ks(c),Ne=!!(B!=null&&B.length&&!c.quoted_message),Qe=re&&ae&&Ne;return t.jsxs(t.Fragment,{children:[a&&t.jsx(W,{additionalMessageInputProps:s}),I&&t.jsx(j.MessageBounceModal,{MessageBouncePrompt:F,onClose:()=>k(!1),open:I}),t.jsxs("div",{className:cs,"data-message-id":c.id,children:[C&&t.jsx(C,{}),!!S&&t.jsx(z,{reminder:S}),c.user&&t.jsx(Z,{className:"str-chat__avatar str-chat__message-sender-avatar",id:c.user.id,image:c.user.image,name:c.user.name||c.user.id,size:24,shape:"circle",dmAgentEnabled:re}),t.jsx("div",{className:y("str-chat__message-inner",{"str-chat__simple-message--error-failed":Xe||We}),"data-testid":"message-inner",onClick:se,onKeyDown:se,role:se?"button":void 0,tabIndex:se?0:void 0,style:{marginInlineEnd:0,marginInlineStart:0},children:Ze?t.jsxs("div",{className:"str-chat__message-bubble-wrapper",children:[ae?t.jsxs("div",{className:"flex items-center gap-2",children:[U&&t.jsx(U,{}),t.jsx(Ie.Sent,{title:(st=c.metadata)==null?void 0:st.attachment_title,mimeType:(nt=c.metadata)==null?void 0:nt.attachment_mime_type,thumbnailUrl:(at=c.metadata)==null?void 0:at.attachment_thumbnail,amountText:(rt=c.metadata)==null?void 0:rt.amount_text,detail:(it=c.metadata)==null?void 0:it.attachment_detail,paymentStatus:(ot=c.metadata)==null?void 0:ot.payment_status,onPreviewClick:()=>A==null?void 0:A(c,N),onFetchSource:async()=>await(T==null?void 0:T(c,N))})]}):t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Ie.Received,{title:(lt=c.metadata)==null?void 0:lt.attachment_title,mimeType:(ct=c.metadata)==null?void 0:ct.attachment_mime_type,thumbnailUrl:(dt=c.metadata)==null?void 0:dt.attachment_thumbnail,amountText:(ut=c.metadata)==null?void 0:ut.amount_text,detail:(mt=c.metadata)==null?void 0:mt.attachment_detail,paymentStatus:(xt=c.metadata)==null?void 0:xt.payment_status,isUnlocking:M(c.id),onUnlockClick:()=>A==null?void 0:A(c,N),onFetchSource:async()=>await(T==null?void 0:T(c,N)),onDownloadClick:()=>L==null?void 0:L(c,N)}),U&&t.jsx(U,{})]}),c.text&&t.jsx("div",{className:"str-chat__message-bubble",children:t.jsx(j.MessageText,{message:X,renderText:b})})]}):Je?t.jsx(_e,{message:c,standalone:!0}):t.jsx("div",{className:"str-chat__message-bubble-wrapper",children:t.jsxs("div",{className:"str-chat__message-bubble",children:[re&&!Qe&&t.jsx(_e,{message:c,hasAttachment:Ne,isMyMessage:ae}),Ke&&t.jsx(j.Poll,{poll:Ke}),B!=null&&B.length&&!c.quoted_message?t.jsx(O,{actionHandler:l,attachments:B}):null,q?t.jsx(g,{message:X,renderText:b}):t.jsx(j.MessageText,{message:X,renderText:b}),t.jsx(j.MessageErrorIcon,{})]})})}),!Ze&&!Je&&t.jsxs("div",{className:"str-chat__message-footer",children:[(!re||Qe)&&t.jsx(_e,{message:c,hasAttachment:Ne,isMyMessage:ae}),n&&re&&t.jsx(zt,{selected:E,onVoteUp:D,onVoteDown:V})]}),J&&t.jsx(Y,{onClick:d,reply_count:c.reply_count}),K&&t.jsx(H,{})]},c.id)]})},Qs=m.memo(Zs,(e,s)=>e.chatbotVotingEnabled!==s.chatbotVotingEnabled||e.viewerLanguage!==s.viewerLanguage?!1:j.areMessageUIPropsEqual(e,s)),en=e=>{const s=j.useMessageContext("CustomMessage");return t.jsx(Qs,{...s,...e})},tn=()=>{var n;const{handleDelete:e,message:s}=j.useMessageContext("CustomMessageActions");return((n=s.metadata)==null?void 0:n.payment_status)==="paid"?null:t.jsx(Te.DefaultDropdownActionButton,{onClick:e,"aria-label":"Delete",title:"Delete",className:"bg-marble rounded-full p-2 hover:bg-sand transition-all",children:t.jsx(v.TrashSimpleIcon,{size:16,weight:"light","aria-hidden":!0})})},sn=()=>{const{handleFlag:e}=j.useMessageContext("CustomMessageActions");return t.jsx(Te.DefaultDropdownActionButton,{onClick:e,"aria-label":"Report",title:"Report",className:"bg-marble rounded-full p-2 hover:bg-sand transition-all",children:t.jsx(v.FlagIcon,{size:16,weight:"light","aria-hidden":!0})})},nn=()=>{var s;const{message:e}=j.useMessageContext("CustomMessageActions");return((s=e.metadata)==null?void 0:s.custom_type)!=="MESSAGE_ATTACHMENT"?null:t.jsx(Te.MessageActions,{messageActionSet:[{Component:tn,placement:"quick",type:"delete"},{Component:sn,placement:"quick",type:"flag"}]})},an=e=>({linkPreviews:Array.from(e.previews.values()).filter(s=>gt.LinkPreviewsManager.previewIsLoaded(s)||gt.LinkPreviewsManager.previewIsLoading(s))}),rn=({link:e,onDismiss:s})=>{const{og_scrape_url:n,title:a,image_url:r}=e,i=o=>{o.preventDefault(),s(n)};return t.jsxs("a",{href:n,target:"_blank",rel:"noopener noreferrer",className:"relative block w-[280px] max-w-full rounded-[24px] bg-[#121110] p-2 no-underline transition-opacity hover:opacity-90",children:[r&&t.jsx("img",{src:r,alt:a||"",className:"h-[180px] w-full rounded-[20px] object-cover"}),t.jsx("button",{type:"button",onClick:i,className:"absolute right-4 top-4 flex size-6 items-center justify-center rounded-full border border-white/40 bg-white/70 backdrop-blur-2xl focus-ring","aria-label":"Close link preview",children:t.jsx(v.XIcon,{className:"size-4 text-black/90"})}),t.jsxs("div",{className:"p-2",children:[a&&t.jsx("div",{className:"text-[14px] font-medium leading-5 text-white",children:a}),t.jsx("div",{className:"text-[12px] leading-4 text-white/55",children:n})]})]})},on=()=>{const{linkPreviewsManager:e}=j.useMessageComposer(),{linkPreviews:s}=j.useStateStore(e.state,an),n=r=>{e.dismissPreview(r)};return s.length>0?t.jsx("div",{className:"flex flex-col items-center w-full gap-2 mb-4",children:s.map(r=>t.jsx(rn,{link:r,onDismiss:n},r.og_scrape_url))}):null},$t=m.createContext(!1),ln=({sendMessage:e,disabled:s,...n})=>t.jsx("button",{...n,type:"button","aria-label":"Send",disabled:s,onClick:e,children:t.jsx(v.ArrowUpIcon,{weight:"bold",className:"size-4"})}),cn=()=>{const e=m.useContext($t),{handleSubmit:s}=j.useMessageInputContext(),n=j.useMessageComposerHasSendableData(),a=e||!n,{SendButton:r=ln,AttachmentPreviewList:i=j.AttachmentPreviewList}=j.useComponentContext("CustomMessageInput");return t.jsxs("div",{className:"central-container flex flex-col gap-2 min-w-0 w-full p-2 bg-white rounded-[1.5rem] shadow-[0_4px_16px_0_rgba(0,0,0,0.08),0_1px_2px_0_rgba(0,0,0,0.04),0_0_0_1px_rgba(0,0,0,0.04)]",children:[t.jsx(j.QuotedMessagePreview,{}),t.jsx(on,{}),t.jsx(i,{}),t.jsxs("div",{className:"flex",children:[t.jsx("div",{className:"w-full ml-2 mr-4 self-center leading-[0]",children:t.jsx(j.TextareaComposer,{"aria-disabled":e||void 0,className:"w-full resize-none outline-none leading-5 placeholder:text-black/30 text-sm",autoFocus:!e,maxRows:4,readOnly:e,tabIndex:e?-1:void 0})}),t.jsx(r,{sendMessage:s,"aria-label":"Send",className:"str-chat__send-button mt-auto flex justify-center items-center flex-shrink-0 rounded-full size-8 bg-[#121110] disabled:bg-[#F1F0EE] disabled:text-black/20 text-white focus-ring","data-testid":"send-button",disabled:a,type:"button"})]})]})},dn=({renderActions:e,renderFooter:s,disabled:n=!1,disabledReason:a})=>{var o;const{channel:r}=j.useChannelStateContext(),i=((o=r==null?void 0:r.data)==null?void 0:o.frozen)===!0;return n?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"messaging-composer-locked-panel flex w-full flex-col items-center justify-center gap-3 px-6 py-4",children:a?t.jsx("p",{className:"max-w-[345px] text-center text-xs font-normal leading-[1.3] tracking-[0.12px] text-black/40",children:a}):null}),s==null?void 0:s()]}):t.jsxs("div",{className:"flex flex-col gap-4 p-4",children:[t.jsxs("div",{inert:i?"":void 0,"aria-disabled":i||void 0,className:"message-input flex items-end gap-4 aria-disabled:opacity-40",children:[e&&t.jsx("div",{className:"flex h-12 shrink-0 items-center justify-center",children:e()}),t.jsx($t.Provider,{value:i,children:t.jsx(j.MessageInput,{Input:cn})})]}),s==null?void 0:s()]})},un=["SYSTEM_DM_AGENT_PAUSED","SYSTEM_DM_AGENT_RESUMED"],mn={SYSTEM_DM_AGENT_PAUSED:"DM Agent has left the conversation",SYSTEM_DM_AGENT_RESUMED:"DM Agent has rejoined the conversation"},xn=["SYSTEM_AGE_SAFETY_BLOCKED"],hn={SYSTEM_AGE_SAFETY_BLOCKED:"This user isn’t able to reply because they don’t meet our age safety guidelines."},Ce="age safety guidelines.",fn="https://linktr.ee/s/about/contact",jt=e=>un.includes(e),gn=e=>xn.includes(e),bn=e=>{var a;const s=(a=e.metadata)==null?void 0:a.custom_type;if(jt(s))return{kind:"dm-agent",type:s};if(gn(s))return{kind:"age-safety",type:s};const n=e.dm_agent_system_type;if(jt(n))return{kind:"dm-agent",type:n}},pn=e=>{const s=e.indexOf(Ce);if(s===-1)return e;const n=s+Ce.length;return t.jsxs(t.Fragment,{children:[e.slice(0,s),t.jsx("a",{href:fn,target:"_blank",rel:"noopener noreferrer",className:"mes-age-safety-system-message__emphasis font-medium text-inherit underline",children:Ce}),e.slice(n)]})},vn=e=>{var a,r;const s=e.message.hide_date===!0,n=bn(e.message);if((n==null?void 0:n.kind)==="dm-agent"){const i=((a=e.message.text)==null?void 0:a.trim())||mn[n.type];return t.jsxs("div",{className:"str-chat__message--system","data-testid":"message-system",children:[t.jsxs("div",{className:"mes-dm-agent-system-message mx-auto mb-2 inline-flex w-fit max-w-[min(100%,480px)] items-center justify-center gap-[10px] rounded-[12px] border border-[rgba(0,0,0,0.08)] p-3 text-[rgba(0,0,0,0.55)]","data-testid":"dm-agent-system-message","data-dm-agent-system-type":n.type,children:[t.jsx(v.SparkleIcon,{size:16,weight:"regular","aria-hidden":!0,className:"mes-dm-agent-system-message__sparkle shrink-0"}),t.jsx("p",{className:"mes-dm-agent-system-message__text m-0 text-center text-[14px] font-normal leading-5 tracking-[0.21px]",children:i})]}),!s&&t.jsx(j.MessageTimestamp,{message:e.message})]})}if((n==null?void 0:n.kind)==="age-safety"){const i=((r=e.message.text)==null?void 0:r.trim())||hn[n.type];return t.jsxs("div",{className:"str-chat__message--system","data-testid":"message-system",children:[t.jsxs("div",{className:"mes-age-safety-system-message box-border mx-auto mb-2 flex w-full max-w-[329px] items-start justify-center gap-3 rounded-[12px] border border-[var(--border-secondary,rgba(0,0,0,0.08))] bg-[var(--bg-warning-subtle,#fef3c6)] px-2 py-4 pl-5 text-[color:var(--text-warning-on-warning,#894b00)]","data-testid":"age-safety-system-message","data-age-safety-system-type":n.type,children:[t.jsx(v.ProhibitIcon,{size:24,weight:"duotone","aria-hidden":!0,className:"mes-age-safety-system-message__icon shrink-0 text-[color:var(--text-warning-on-warning,#894b00)]","data-testid":"age-safety-system-message-icon"}),t.jsx("div",{className:"mes-age-safety-system-message__content min-w-0 flex-[1_0_0]",children:t.jsx("p",{className:"m-0 text-balance text-left text-[12px] font-normal leading-4 tracking-[0.21px] text-[color:var(--text-warning-on-warning,#894b00)]",children:pn(i)})})]}),!s&&t.jsx(j.MessageTimestamp,{message:e.message})]})}return t.jsxs("div",{className:"str-chat__message--system","data-testid":"message-system",children:[t.jsxs("div",{className:"str-chat__message--system__text",children:[t.jsx("div",{className:"str-chat__message--system__line"}),t.jsx("p",{children:e.message.text}),t.jsx("div",{className:"str-chat__message--system__line"})]}),!s&&t.jsx(j.MessageTimestamp,{message:e.message})]})},Bt=m.createContext(!1),ye=({cx:e,index:s})=>t.jsx("circle",{cx:e,cy:"4",r:"3.9",fill:"#A0A0A0",children:t.jsx("animateTransform",{attributeName:"transform",type:"translate",values:"0 0; 0 -2.25; 0 0;",dur:"900ms",begin:`${120*s}ms`,repeatCount:"indefinite"})}),jn=new Set([j.AIStates.Thinking,j.AIStates.Generating,j.AIStates.ExternalSources]),wn=({threadList:e})=>{var b,_;const{channel:s,channelConfig:n,thread:a}=j.useChannelStateContext(),{client:r}=j.useChatContext(),{typing:i={}}=j.useTypingContext(),{aiState:o}=j.useAIState(s),l=m.useContext(Bt);if(!e&&l&&jn.has(o)){const p=Nn(s,(b=r.user)==null?void 0:b.id);return t.jsx(wt,{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 x=e?[]:Object.values(i).filter(({parent_id:p,user:w})=>{var N;return(w==null?void 0:w.id)!==((N=r.user)==null?void 0:N.id)&&!p}),f=e?Object.values(i).filter(({parent_id:p,user:w})=>{var N;return(w==null?void 0:w.id)!==((N=r.user)==null?void 0:N.id)&&p===(a==null?void 0:a.id)}):[],u=e?f:x;if(!u.length)return null;const h=(_=u[0])==null?void 0:_.user,c=h!=null&&h.id&&s.state.members[h.id]?s.state.members[h.id].user:void 0;return t.jsx(wt,{avatarId:(h==null?void 0:h.id)??(c==null?void 0:c.id)??"typing-user",avatarName:(h==null?void 0:h.name)??(c==null?void 0:c.name)??(h==null?void 0:h.id)??"Typing user",avatarImage:(h==null?void 0:h.image)??(c==null?void 0:c.image),testId:"typing-indicator"})},wt=({avatarId:e,avatarName:s,avatarImage:n,testId:a})=>t.jsxs("div",{className:"str-chat__typing-indicator !items-end !bg-transparent","data-testid":a,style:{insetInlineStart:0,insetInlineEnd:"auto"},children:[t.jsx("div",{className:"shrink-0","aria-hidden":"true",children:t.jsx(Z,{id:e,name:s,image:n??void 0,size:24,shape:"circle"})}),t.jsx("div",{className:"px-4 py-3 rounded-lg bg-[#E9EAED] h-12 flex flex-col justify-end",children:t.jsxs("svg",{"aria-hidden":"true",className:"block overflow-visible mb-[0.2rem]",viewBox:"0 0 32 8",width:"32",height:"8",overflow:"visible",children:[t.jsx(ye,{cx:"4",index:0}),t.jsx(ye,{cx:"16",index:1}),t.jsx(ye,{cx:"28",index:2})]})})]});function Nn(e,s){var a;const n=((a=e==null?void 0:e.state)==null?void 0:a.members)??{};for(const r of Object.values(n)){const i=r==null?void 0:r.user;if(i&&i.id!==s)return i}}const Vt=()=>null,_n=({className:e,message:s})=>t.jsxs("div",{className:y("flex items-center justify-center h-full",e),children:[t.jsxs("svg",{viewBox:"0 0 100 100",className:"size-8 fill-pebble",stroke:"none",children:[t.jsx("circle",{cx:"6",cy:"50",r:"6",children:t.jsx("animateTransform",{attributeName:"transform",dur:"1s",type:"translate",values:"0 15 ; 0 -15; 0 15",repeatCount:"indefinite",begin:"0.1"})}),t.jsx("circle",{cx:"30",cy:"50",r:"6",children:t.jsx("animateTransform",{attributeName:"transform",dur:"1s",type:"translate",values:"0 10 ; 0 -10; 0 10",repeatCount:"indefinite",begin:"0.2"})}),t.jsx("circle",{cx:"54",cy:"50",r:"6",children:t.jsx("animateTransform",{attributeName:"transform",dur:"1s",type:"translate",values:"0 5 ; 0 -5; 0 5",repeatCount:"indefinite",begin:"0.3"})})]}),s&&t.jsx("span",{className:"text-stone",children:s})]}),ge=m.memo(()=>t.jsx("div",{className:"messaging-loading-state flex items-center justify-center h-full",children:t.jsxs("div",{className:"flex items-center",children:[t.jsx(_n,{className:"w-6 h-6"}),t.jsx("span",{className:"text-sm text-stone",children:"Loading messages"})]})}));ge.displayName="LoadingState";const ne="size-10 rounded-full hover:bg-[#E5E4E1] flex items-center justify-center transition-colors duration-150 focus-ring",Nt="Replies instantly with AI assistant",Cn=({onBack:e,showBackButton:s,onShowInfo:n,canShowInfo:a,showStarButton:r=!1,dmAgentEnabled:i=!1})=>{var h,c,b,_,p;const{channel:o}=j.useChannelStateContext(),l=m.useMemo(()=>{var M,A;const w=(M=o._client)==null?void 0:M.userID;return w?Object.values(((A=o.state)==null?void 0:A.members)||{}).find(T=>{var L;return((L=T.user)==null?void 0:L.id)&&T.user.id!==w}):void 0},[(h=o._client)==null?void 0:h.userID,(c=o.state)==null?void 0:c.members]),d=ce(l==null?void 0:l.user),x=(b=l==null?void 0:l.user)==null?void 0:b.image,f=yt(o),u=async()=>{try{f?await o.unpin():await o.pin()}catch(w){console.error("[CustomChannelHeader] Failed to update pinned status:",w)}};return t.jsxs("div",{className:"@container",children:[t.jsxs("div",{className:"grid grid-cols-[1fr_auto_1fr] w-full items-center @lg:hidden px-6 py-3",children:[t.jsx("div",{className:"flex items-center gap-2",children:s&&t.jsx("button",{className:y(ne,"messaging-channel-view-back-button-mobile bg-[#F1F0EE]"),onClick:e||(()=>{}),type:"button","aria-label":"Back to conversations",children:t.jsx(v.ArrowLeftIcon,{className:"size-5 text-black/90"})})}),t.jsxs("div",{className:"flex flex-col gap-1 items-center",children:[t.jsx(Z,{id:((_=l==null?void 0:l.user)==null?void 0:_.id)||o.id||"unknown",name:d,image:x,starred:r&&f,dmAgentEnabled:i,size:48}),t.jsx("p",{className:"text-center text-xs font-medium text-black/90",children:d}),i&&t.jsxs("div",{className:"flex items-center gap-1 text-[10px] leading-3 text-black/55",children:[t.jsx(v.SparkleIcon,{className:"size-3 shrink-0 text-black/55"}),t.jsx("span",{children:Nt})]})]}),t.jsxs("div",{className:"flex justify-end items-center gap-2",children:[r&&t.jsx("button",{className:ne,onClick:u,type:"button","aria-label":f?"Unstar conversation":"Star conversation",children:t.jsx(v.StarIcon,{className:y("size-5",{"text-yellow-600":f,"text-black/90":!f}),weight:f?"duotone":"regular"})}),t.jsx("button",{className:y(ne,"bg-[#F1F0EE]"),onClick:n,type:"button","aria-label":"Show info",children:t.jsx(v.DotsThreeIcon,{className:"size-5 text-black/90"})})]})]}),t.jsxs("div",{className:"px-6 py-3 hidden @lg:flex items-center justify-between gap-3 min-h-12 border-b border-b-black/[0.08]",children:[t.jsxs("div",{className:"flex items-center gap-4 min-w-0",children:[s&&e&&t.jsx("button",{className:y(ne,"messaging-channel-view-back-button-desktop"),type:"button",onClick:e,"aria-label":"Back to conversations",children:t.jsx(v.ArrowLeftIcon,{className:"size-5 text-black/90"})}),t.jsx(Z,{id:((p=l==null?void 0:l.user)==null?void 0:p.id)||o.id||"unknown",name:d,image:x,starred:r&&f,dmAgentEnabled:i,size:48}),t.jsxs("div",{className:"min-w-0",children:[a?t.jsx("button",{type:"button",onClick:n,className:"flex items-center gap-1 font-medium text-black/90 truncate hover:text-black/70 transition-colors","aria-label":`View info for ${d}`,children:t.jsx("span",{className:"truncate",children:d})}):t.jsx("h1",{className:"font-medium text-black/90 truncate",children:d}),i&&t.jsxs("div",{className:"mt-0.5 flex items-center gap-1 text-[10px] leading-3 text-black/55",children:[t.jsx(v.SparkleIcon,{className:"size-3 shrink-0 text-black/55"}),t.jsx("span",{className:"truncate",children:Nt})]})]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[r&&t.jsx("button",{className:ne,onClick:u,type:"button","aria-label":f?"Unstar conversation":"Star conversation",children:t.jsx(v.StarIcon,{className:y("size-6",{"text-yellow-600":f,"text-black/90":!f}),weight:f?"duotone":"regular"})}),a&&n&&t.jsx("button",{className:ne,onClick:n,type:"button","aria-label":"Show info",children:t.jsx(v.DotsThreeIcon,{className:"size-6 text-black/90"})})]})]})]})},yn=({onBack:e,showBackButton:s,renderMessageInputActions:n,renderMessageInputFooter:a,renderConversationFooter:r,onLeaveConversation:i,onBlockParticipant:o,showDeleteConversation:l=!0,onDeleteConversationClick:d,onBlockParticipantClick:x,onReportParticipantClick:f,showBlockParticipant:u=!0,showReportParticipant:h=!0,showFollowerStatus:c=!0,composerDisabled:b=!1,composerDisabledReason:_,showStarButton:p=!1,chatbotVotingEnabled:w=!1,renderChannelBanner:N,customProfileContent:M,customChannelActions:A,renderMessage:T,dmAgentEnabled:L=!1,viewerLanguage:I})=>{var H,Y,z,g,C,P;const{channel:k}=j.useChannelStateContext(),S=m.useRef(null),E=m.useMemo(()=>{var B,X;const R=(B=k._client)==null?void 0:B.userID;return R?Object.values(((X=k.state)==null?void 0:X.members)||{}).find(J=>{var K;return((K=J.user)==null?void 0:K.id)&&J.user.id!==R}):void 0},[(H=k._client)==null?void 0:H.userID,(Y=k.state)==null?void 0:Y.members]),D=m.useMemo(()=>{var B,X;const R=(B=k._client)==null?void 0:B.userID;return R?Object.values(((X=k.state)==null?void 0:X.members)||{}).find(J=>{var K;return((K=J.user)==null?void 0:K.id)===R}):void 0},[(z=k._client)==null?void 0:z.userID,(g=k.state)==null?void 0:g.members]),V=((C=D==null?void 0:D.user)==null?void 0:C.is_account)??(D==null?void 0:D.is_account),O=((P=E==null?void 0:E.user)==null?void 0:P.is_account)??(E==null?void 0:E.is_account),W=L&&V===!1&&O===!0,U=m.useMemo(()=>{if(!c)return;const R=k.data??{};if(R.followerStatus)return String(R.followerStatus);if(R.isFollower!==void 0)return R.isFollower?"Subscribed to you":"Not subscribed"},[k.data,c]),G=m.useCallback(()=>{var R;(R=S.current)==null||R.showModal()},[]),F=m.useCallback(()=>{var R;(R=S.current)==null||R.close()},[]),$=m.useCallback(R=>{const{message:q}=j.useMessageContext("ChannelView"),B=t.jsx(en,{...R,chatbotVotingEnabled:w,viewerLanguage:I});return!T||!q?B:T(B,q)},[w,T,I]);return t.jsxs(t.Fragment,{children:[t.jsx(j.WithComponents,{overrides:{Message:$,MessageActions:nn},children:t.jsxs(j.Window,{children:[t.jsx("div",{children:t.jsx(Cn,{onBack:e,showBackButton:s,onShowInfo:G,canShowInfo:!!E,showStarButton:p,dmAgentEnabled:W})},"lt-channel-header"),N?t.jsx(m.Fragment,{children:N()},"lt-channel-banner"):null,t.jsx("div",{className:"flex-1 overflow-hidden relative",children:t.jsx(j.MessageList,{hideDeletedMessages:!0,hideNewMessageSeparator:!1})},"lt-channel-message-list"),r?t.jsx(m.Fragment,{children:r(k)},"lt-channel-conversation-footer"):null,t.jsx(dn,{...n&&{renderActions:()=>n==null?void 0:n(k)},renderFooter:()=>a==null?void 0:a(k),disabled:b,disabledReason:_},"lt-channel-message-input")]})}),t.jsx(bs,{dialogRef:S,onClose:F,participant:E,participantDisplayName:ce(E==null?void 0:E.user),channel:k,followerStatusLabel:U,onLeaveConversation:i,onBlockParticipant:o,showDeleteConversation:l,showBlockParticipant:u,showReportParticipant:h,onDeleteConversationClick:d,onBlockParticipantClick:x,onReportParticipantClick:f,customProfileContent:M,customChannelActions:A})]})},Oe=m.memo(({channel:e,onBack:s,showBackButton:n=!1,renderMessageInputActions:a,renderMessageInputFooter:r,renderConversationFooter:i,onLeaveConversation:o,onBlockParticipant:l,className:d,CustomChannelEmptyState:x=Vt,showDeleteConversation:f=!0,onDeleteConversationClick:u,onBlockParticipantClick:h,onReportParticipantClick:c,showBlockParticipant:b=!0,showReportParticipant:_=!0,showFollowerStatus:p=!0,composerDisabled:w=!1,composerDisabledReason:N,dmAgentEnabled:M,messageMetadata:A,onMessageSent:T,showStarButton:L=!1,chatbotVotingEnabled:I=!1,renderChannelBanner:k,customProfileContent:S,customChannelActions:E,renderMessage:D,onMessageLinkClick:V,sendButton:O,attachmentPreviewList:W,viewerLanguage:U})=>{const G=m.useCallback(async($,H,Y)=>{var q;const z=((q=e.data)==null?void 0:q.chatbot_paused)===!0,g=M&&!z,C={...H,...g&&{silent:!0},...A&&{metadata:{...H.metadata??{},...A}}},P={...Y,...g&&{skip_push:!0}},R=await e.sendMessage(C,P);return T==null||T(R),R},[e,M,A,T]),F=m.useRef(null);return m.useEffect(()=>{if(!V)return;const $=F.current;if(!$)return;const H=Y=>{const z=Y.target,g=z==null?void 0:z.closest("a[href]"),C=g==null?void 0:g.getAttribute("href");if(!C)return;const P=g==null?void 0:g.closest("[data-message-id]"),R=P==null?void 0:P.getAttribute("data-message-id"),q=R?e.state.messages.find(B=>B.id===R):void 0;V(C,q)};return $.addEventListener("click",H),()=>$.removeEventListener("click",H)},[V,e]),t.jsx("div",{ref:F,className:y("messaging-channel-view h-full flex flex-col",d),children:t.jsx(Bt.Provider,{value:M??!1,children:t.jsx(j.Channel,{channel:e,MessageSystem:vn,EmptyStateIndicator:x,LoadingIndicator:ge,DateSeparator:ps,TypingIndicator:wn,doSendMessageRequest:G,...O?{SendButton:O}:{},...W?{AttachmentPreviewList:W}:{},children:t.jsx(yn,{onBack:s,showBackButton:n,renderMessageInputActions:a,renderMessageInputFooter:r,renderConversationFooter:i,onLeaveConversation:o,onBlockParticipant:l,CustomChannelEmptyState:x,showDeleteConversation:f,onDeleteConversationClick:u,onBlockParticipantClick:h,onReportParticipantClick:c,showBlockParticipant:b,showReportParticipant:_,showFollowerStatus:p,composerDisabled:w,composerDisabledReason:N,showStarButton:L,dmAgentEnabled:M,chatbotVotingEnabled:I,renderChannelBanner:k,customProfileContent:S,customChannelActions:E,renderMessage:D,viewerLanguage:U})})})})});Oe.displayName="ChannelView";const le=m.memo(({message:e,onBack:s})=>t.jsx("div",{className:"messaging-error-state flex items-center justify-center h-full p-8",children:t.jsxs("div",{className:"text-center max-w-sm",children:[t.jsx("div",{className:"w-24 h-24 bg-danger-alt/20 rounded-full flex items-center justify-center mx-auto mb-6",children:t.jsx("span",{className:"text-4xl",children:"⚠️"})}),t.jsx("h2",{className:"font-semibold text-charcoal mb-2",children:"Oops!"}),t.jsx("p",{className:"text-stone text-sm mb-6",children:e}),s&&t.jsx("button",{type:"button",onClick:s,className:"inline-flex items-center gap-2 px-4 py-2 text-sm font-medium text-white bg-[#7f22fe] hover:bg-primary-alt rounded-lg transition-colors focus-ring",children:"Go Back"})]})}));le.displayName="ErrorState";const kn=({capabilities:e={},renderMessageInputActions:s,renderConversationFooter:n,onChannelSelect:a,onExitConversation:r,initialParticipantFilter:i,initialParticipantData:o,CustomChannelEmptyState:l,onBlockParticipantClick:d,onReportParticipantClick:x,dmAgentEnabled:f,onMessageSent:u,chatbotVotingEnabled:h=!1,viewerLanguage:c,renderChannelBanner:b,customChannelActions:_,renderMessage:p,onMessageLinkClick:w})=>{const{client:N,isConnected:M,isLoading:A,error:T,refreshConnection:L,service:I,debug:k}=Ct(),[S,E]=m.useState(null),[D,V]=m.useState(null),[O,W]=m.useState(!1),{showDeleteConversation:U=!0}=e,G=m.useRef(o);G.current=o;const F=m.useRef(a);F.current=a;const $=m.useRef(null),H=m.useRef(null);m.useEffect(()=>{H.current=S},[S]),m.useEffect(()=>{if(!N||!M)return;const g=N.userID;if(!g)return;const C=`${g}::${i}`;if($.current===C)return;$.current=C;const P=()=>{$.current===C&&($.current=null)};(async()=>{var q,B;try{k&&console.log("[MessagingShell] Loading initial conversation with:",i);const X=await N.queryChannels({type:"messaging",members:{$eq:[g,i]}},{},{limit:1});if(X.length>0){E(X[0]),V(null),(q=F.current)==null||q.call(F,X[0]),k&&console.log("[MessagingShell] Initial conversation loaded:",X[0].id);return}const J=G.current;if(!J||!I){P(),V("No conversation found with this account"),k&&console.log("[MessagingShell] No conversation found for:",i);return}try{const K=await I.startChannelWithParticipant({id:J.id,name:J.name,phone:J.phone});E(K),V(null),(B=F.current)==null||B.call(F,K),k&&console.log("[MessagingShell] Channel created and loaded:",K.id)}catch(K){console.error("[MessagingShell] Failed to create conversation:",K),P(),V("Failed to create conversation")}}catch(X){console.error("[MessagingShell] Failed to load initial conversation:",X),P(),H.current||V("Failed to load conversation")}})()},[i,N,M,I,k]);const Y=m.useRef(r);Y.current=r;const z=m.useCallback(()=>{var g;E(null),W(!0),(g=Y.current)==null||g.call(Y)},[]);return A?t.jsx(ge,{}):T?t.jsx(le,{message:T,onBack:L}):!M||!N?t.jsx(le,{message:"Not connected to messaging service",onBack:L}):D?t.jsx(le,{message:D}):O&&!S?t.jsx(le,{message:"Conversation ended"}):S?t.jsx("div",{className:"messaging-shell h-full bg-background-primary overflow-hidden",children:t.jsx("div",{className:"flex h-full min-h-0 flex-col",children:t.jsx(Oe,{channel:S,renderMessageInputActions:s,renderConversationFooter:n,renderChannelBanner:b,onLeaveConversation:z,onBlockParticipant:z,CustomChannelEmptyState:l,showDeleteConversation:U,onBlockParticipantClick:d,onReportParticipantClick:x,dmAgentEnabled:f,onMessageSent:u,chatbotVotingEnabled:h,viewerLanguage:c,customChannelActions:_,renderMessage:p,onMessageLinkClick:w},S.id)})}):t.jsx(ge,{})};function Sn(e){const s=e.state.pending_messages;if(s!=null&&s.length)for(const n of s)e.state.addMessageSorted(n.message)}const Ut=m.createContext({selectedChannel:void 0,onChannelSelect:()=>{},debug:!1,renderMessagePreview:void 0,viewerLanguage:void 0}),En=Ut.Provider,In=()=>m.useContext(Ut),Tn=(e,s)=>{const n=new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate())),r=new Date(Date.UTC(s.getUTCFullYear(),s.getUTCMonth(),s.getUTCDate())).getTime()-n.getTime();return Math.floor(r/(1e3*60*60*24))},Gt=e=>{const s=new Date;if(Math.floor((s.getTime()-e.getTime())/1e3)<60)return"Just now";const a=Tn(e,s);return a===0?e.toLocaleTimeString([],{hour:"numeric",minute:"2-digit",hour12:!0}):a===1?"Yesterday":a<7?`${a}d`:a<28?`${Math.floor(a/7)}w`:e.toLocaleDateString("en-US",{month:"numeric",day:"numeric",year:"2-digit"})},Ht=m.memo(({channel:e,unread:s})=>{var L,I,k;const{selectedChannel:n,onChannelSelect:a,debug:r,renderMessagePreview:i,viewerLanguage:o}=In(),l=(n==null?void 0:n.id)===(e==null?void 0:e.id),d=()=>{e&&a(e)},x=S=>{const E=S.key==="Enter"||S.key===" ",D=S.repeat;!E||D||(S.preventDefault(),d())},u=Object.values(((L=e==null?void 0:e.state)==null?void 0:L.members)||{}).find(S=>{var E,D;return((E=S.user)==null?void 0:E.id)&&S.user.id!==((D=e==null?void 0:e._client)==null?void 0:D.userID)}),h=ce(u==null?void 0:u.user),c=(I=u==null?void 0:u.user)==null?void 0:I.image,b=(()=>{var E;const S=(E=e==null?void 0:e.state)==null?void 0:E.messages;if(S!=null&&S.length){for(let D=S.length-1;D>=0;D--)if(S[D].type!=="system")return S[D]}})(),p=(()=>{var W,U,G,F;const S=Me({message:b,viewerLanguage:o});if(((W=b==null?void 0:b.metadata)==null?void 0:W.custom_type)==="MESSAGE_TIP")return S?`💵 ${S}`:"💵 Sent a tip";if(((U=b==null?void 0:b.metadata)==null?void 0:U.custom_type)==="MESSAGE_PAID")return S?`💰 ${S}`:"💰 Sent a message";if(((G=b==null?void 0:b.metadata)==null?void 0:G.custom_type)==="MESSAGE_ATTACHMENT")return S?`📎 ${S}`:"📎 Sent an attachment";if(S)return S;const O=(F=b==null?void 0:b.attachments)==null?void 0:F[0];return O?O.og_scrape_url?O.og_scrape_url:O.type==="image"?"📷 Sent an image":O.type==="video"?"🎥 Sent a video":O.type==="audio"?"🎵 Sent audio":O.type==="file"?"📎 Sent a file":"📎 Sent an attachment":"No messages yet"})(),w=b!=null&&b.created_at?Gt(new Date(b.created_at)):"",N=b?fe(b):!1,M=i?i(b,p):`${N?"✨ ":""}${p}`,A=yt(e),T=s??0;return r&&console.log("📺 [ChannelList] 📋 CHANNEL PREVIEW RENDER",{channelId:e==null?void 0:e.id,isSelected:l,participantName:h,unreadCount:T,hasTimestamp:!!w}),t.jsx("div",{role:"button",tabIndex:0,onClick:d,onKeyDown:x,className:y("group w-full px-4 py-3 transition-colors text-left max-w-full overflow-hidden focus-ring rounded-[12px] [&+&]:mt-2",{"bg-black/[0.04]":l,"hover:bg-black/[0.02]":!l}),children:t.jsxs("div",{className:"flex items-start gap-4",children:[t.jsx(Z,{id:((k=u==null?void 0:u.user)==null?void 0:k.id)||e.id||"unknown",name:h,image:c,size:48,starred:A}),t.jsxs("div",{className:"flex-1 min-w-0 flex flex-col gap-1",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsxs("h3",{className:y("text-sm font-medium truncate text-[#191918]"),children:[A&&t.jsx("span",{className:"sr-only",children:"Starred conversation. "}),h]}),w&&t.jsx("span",{className:"text-xs text-[#717070] flex-shrink-0",children:w})]}),t.jsxs("div",{className:"flex items-center justify-between gap-2 min-w-0",children:[t.jsx("p",{className:"text-sm text-[#717070] flex-1 line-clamp-1",children:M}),T>0&&t.jsx("span",{className:"bg-[#7f22fe] text-white text-[10px] rounded-full h-4 flex items-center justify-center p-1 min-w-4 text-center flex-shrink-0",children:T>99?"99+":T})]})]})]})})});Ht.displayName="CustomChannelPreview";const An={last_message_at:-1},Yt=m.memo(({onChannelSelect:e,selectedChannel:s,filters:n,allowNewMessagesFromUnfilteredChannels:a=!1,channelRenderFilterFn:r,sort:i=An,className:o,customEmptyStateIndicator:l,renderMessagePreview:d,viewerLanguage:x})=>{const f=m.useRef(0);f.current++;const{debug:u=!1}=Ae(),h=m.useCallback(b=>{for(const _ of b)Sn(_);return r?r(b):b},[r]);u&&console.log("📺 [ChannelList] 🔄 RENDER START",{renderCount:f.current,selectedChannelId:s==null?void 0:s.id,filters:n});const c=m.useMemo(()=>({selectedChannel:s,onChannelSelect:e,debug:u,renderMessagePreview:d,viewerLanguage:x}),[s,e,u,d,x]);return t.jsx("div",{className:y("messaging-channel-list h-full flex flex-col min-w-0 overflow-hidden",o),children:t.jsx("div",{className:"flex-1 overflow-hidden min-w-0",children:t.jsx(En,{value:c,children:t.jsx(j.ChannelList,{filters:n,sort:i,options:{limit:30},allowNewMessagesFromUnfilteredChannels:a,channelRenderFilterFn:h,Preview:Ht,EmptyStateIndicator:l},`${JSON.stringify(n)}:${JSON.stringify(i)}`)})})})});Yt.displayName="ChannelList";const Mn=/^([a-z][a-z0-9+.-]*):/i,Rn=new Set(["http","https","mailto","tel","sms"]);function ze(e){if(typeof e!="string")return;const s=e.trim();if(s==="")return;const n=Mn.exec(s);if(n){const a=n[1].toLowerCase();return Rn.has(a)?s:void 0}return s.startsWith("//")||s.startsWith("/")?s:`https://${s}`}const Dn={dark:"bg-white text-[#121110] hover:bg-white/90",light:"bg-[#121110] text-white hover:bg-[#2a2928]"},Ln=({variant:e,cta:s})=>{const n=y("mt-2 inline-flex h-10 w-full items-center justify-center rounded-full px-4 text-sm font-medium leading-none transition-colors",Dn[e]),a=ze(s.href);return a?t.jsx("a",{href:a,target:"_blank",rel:"noopener noreferrer",onClick:r=>{var i;r.stopPropagation(),(i=s.onClick)==null||i.call(s)},className:`${n} no-underline`,children:s.label}):t.jsx("button",{type:"button",onClick:r=>{var i;r.stopPropagation(),(i=s.onClick)==null||i.call(s)},className:n,children:s.label})},Pn={dark:"text-white",light:"text-black/90"},Fn="text-white/30",On={dark:"text-white/55",light:"text-black/55"},$e=({variant:e,title:s,placeholderTitle:n,description:a,url:r,appIcon:i,cta:o,trailingAction:l})=>{const d=e==="dark",x=s??(d?n:void 0)??"",f=x.trim()!=="",u=a!=null&&a.trim()!=="",h=typeof r=="string"?r.trim():"",c=h!=="",b=o!=null;if(!f&&!u&&!c&&!b)return null;const p=y("truncate text-base font-medium leading-6",d&&!s?Fn:Pn[e]),w=y("truncate text-xs leading-4",On[e]);return t.jsxs("div",{className:"px-4 py-3",children:[t.jsxs("div",{className:"flex items-end gap-3",children:[t.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-2",children:[t.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[f&&t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[i?t.jsx("span",{className:"shrink-0",children:i}):null,t.jsx("p",{className:y("min-w-0",p),children:x})]}),u&&t.jsx("p",{className:w,children:a})]}),!b&&c&&t.jsx("p",{className:w,children:h})]}),l&&t.jsx("div",{className:"shrink-0",children:l})]}),o&&t.jsx(Ln,{variant:e,cta:o})]})},zn=y("relative block w-[280px] select-none overflow-hidden rounded-md","border border-black/[0.08]","shadow-[0_1px_2px_rgba(0,0,0,0.04),0_8px_32px_rgba(0,0,0,0.1)]"),be=({variant:e,children:s,href:n,onClick:a,ariaLabel:r,rootRef:i,topRight:o,bgClassName:l,"data-testid":d})=>{const x=n!=null||a!=null,f=y(zn,l??(e==="dark"?"bg-[#121110]":"bg-white"),x?"cursor-pointer no-underline focus-ring":null),u=o?t.jsx("div",{className:"pointer-events-auto absolute right-3 top-3 z-10",children:o}):null;return n?t.jsxs("a",{ref:i,href:n,target:"_blank",rel:"noopener noreferrer",onClick:a,"data-testid":d,className:f,children:[s,u]}):a?t.jsxs("button",{ref:i,type:"button",onClick:a,"aria-label":r,"data-testid":d,className:y(f,"text-left"),children:[s,u]}):t.jsxs("div",{ref:i,"data-testid":d,className:f,children:[s,u]})},$n={dark:"bg-white/10",light:"bg-black/5"},Bn={dark:"size-16 text-white/25",light:"size-16 text-black/25"},we=(e,s)=>!!s&&!!e&&ee(e)==="audio",qt=(e,s)=>{if(!s||!e)return!1;const n=ee(e);return n==="video"||n==="audio"},Be="bg-[#F2F3F4]",pe=({variant:e,thumbnailUrl:s,sourceUrl:n,title:a,mimeType:r="image/*",topLeft:i,topRight:o})=>{const l=ee(r),d=!!n&&l==="video";return we(r,n)?t.jsx("div",{className:"p-3",children:t.jsx("audio",{src:n,controls:!0,preload:"metadata",className:"block w-full",children:t.jsx("track",{kind:"captions"})})}):t.jsxs("div",{className:y("relative h-[180px] w-full overflow-hidden",d&&"bg-black"),children:[d?t.jsx("video",{src:n,poster:s,controls:!0,playsInline:!0,preload:"metadata",className:"absolute inset-0 h-full w-full object-contain",children:t.jsx("track",{kind:"captions"})}):s?t.jsx("img",{src:s,alt:a??"",draggable:!1,className:"absolute inset-0 h-full w-full object-cover"}):t.jsx("div",{className:y("flex h-full w-full items-center justify-center",$n[e]),children:te(r,{className:Bn[e],weight:"regular"})}),i?t.jsx("div",{className:"pointer-events-auto absolute left-3 top-3 z-10",children:i}):null,o?t.jsx("div",{className:"pointer-events-auto absolute right-3 top-3 z-10",children:o}):null]})},Vn=({title:e,placeholderTitle:s,description:n,url:a,mimeType:r,thumbnailUrl:i,sourceUrl:o,layout:l="featured",appIcon:d,cta:x,onDismiss:f,onEditClick:u})=>{const h=l==="classic",c=we(r,o),b=f?t.jsx("button",{type:"button",onClick:f,"aria-label":"Dismiss attachment",className:"flex size-6 items-center justify-center rounded-full bg-[#121110] text-white",children:t.jsx(v.XIcon,{className:"size-3",weight:"bold"})}):void 0,_=u?t.jsx("button",{type:"button",onClick:u,"aria-label":"Edit attachment",className:"flex size-10 items-center justify-center rounded-full bg-white/10 text-white hover:bg-white/15",children:t.jsx(v.PencilSimpleIcon,{className:"size-5",weight:"regular"})}):void 0;return c?t.jsx(be,{variant:"dark",bgClassName:Be,children:t.jsxs("div",{className:"flex items-center gap-2 pr-3",children:[t.jsx("div",{className:"min-w-0 flex-1",children:t.jsx(pe,{variant:"dark",sourceUrl:o,title:e,mimeType:r})}),b&&t.jsx("div",{className:"shrink-0",children:b})]})}):t.jsxs(be,{variant:"dark",topRight:h?b:void 0,children:[!h&&t.jsx(pe,{variant:"dark",thumbnailUrl:i,sourceUrl:o,title:e,mimeType:r,topRight:b}),t.jsx($e,{variant:"dark",title:e,placeholderTitle:s,description:n,url:a,appIcon:d,cta:x,trailingAction:_})]})},Un=({title:e,description:s,url:n,mimeType:a,thumbnailUrl:r,sourceUrl:i,layout:o="featured",appIcon:l,cta:d,onClick:x})=>{const f=qt(a,i),u=ze(n),h=d==null&&u!=null&&!f?u:void 0,c=d==null&&!f?x:void 0,b=we(a,i)?Be:void 0,_=d&&x?{...d,onClick:()=>{var p;x(),(p=d.onClick)==null||p.call(d)}}:d;return t.jsxs(be,{variant:"light",href:h,onClick:c,ariaLabel:e??"Open attachment preview",bgClassName:b,"data-testid":"link-attachment",children:[o==="featured"&&t.jsx(pe,{variant:"light",thumbnailUrl:r,sourceUrl:i,title:e,mimeType:a}),t.jsx($e,{variant:"light",title:e,description:s,url:n,appIcon:l,cta:_})]})},Gn=({title:e,placeholderTitle:s,description:n,url:a,mimeType:r,thumbnailUrl:i,sourceUrl:o,layout:l="featured",appIcon:d,cta:x,onClick:f})=>{const u=qt(r,o),h=ze(a),c=x==null&&h!=null&&!u?h:void 0,b=x==null&&!u&&c!=null?f:void 0;return t.jsxs(be,{variant:"dark",href:c,onClick:b,bgClassName:we(r,o)?Be:void 0,children:[l==="featured"&&t.jsx(pe,{variant:"dark",thumbnailUrl:i,sourceUrl:o,title:e,mimeType:r}),t.jsx($e,{variant:"dark",title:e,placeholderTitle:s,description:n,url:a,appIcon:d,cta:x})]})},Hn={Composer:Vn,Sent:Gn,Received:Un},Yn={dark:"bg-[#121110]",light:"bg-[#e9eaed]"},qn={dark:"text-white",light:"text-[#080707]"},Xn={dark:"border-white/[0.08]",light:"border-black/[0.08]"},Wn=e=>e==="dark"?"sender":"receiver",Kn={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]"}},de=({variant:e,text:s,bordered:n=!0,groupPosition:a="single",className:r,children:i,"data-testid":o})=>{const l=s!=null&&s!=="",d=Kn[Wn(e)][a];return t.jsxs("div",{"data-testid":o,"data-group-position":a,className:y("relative w-[280px] overflow-hidden px-2 py-2",d,Yn[e],qn[e],n&&"border",n&&Xn[e],r),children:[i,l?t.jsx("p",{className:y("whitespace-pre-wrap break-words leading-snug","pt-2","px-2"),children:s}):null]})},ue=({onClick:e,variant:s="overlay",ariaLabel:n="Dismiss attachment"})=>t.jsx("button",{type:"button",onClick:a=>{a.stopPropagation(),e()},"aria-label":n,className:y("flex size-6 items-center justify-center rounded-full text-white",s==="overlay"?"bg-[#121110]/85 backdrop-blur":"bg-white/15 hover:bg-white/25"),children:t.jsx(v.XIcon,{className:"size-3",weight:"bold"})}),me=e=>e==="received"?"light":"dark",Jn=({firstOfGroup:e,endOfGroup:s,groupedByUser:n})=>!n||e&&s?"single":e?"first":s?"end":"middle",Zn=({src:e,mimeType:s,filename:n,items:a})=>a&&a.length>0?a:e?[{src:e,mimeType:s,filename:n}]:[],Qn=({item:e,preload:s,trailingAction:n})=>t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("audio",{src:e.src,controls:!0,preload:e.preload??s,className:"block min-w-0 flex-1",children:e.mimeType?t.jsx("source",{src:e.src,type:e.mimeType}):null}),n??null]}),Ve=({state:e,src:s,mimeType:n,filename:a,items:r,text:i,groupPosition:o,preload:l,onDismiss:d})=>{const x=me(e),f=e==="composer"&&!!d,u=Zn({src:s,mimeType:n,filename:a,items:r});if(u.length===0)return null;const h=l??(u.length>1?"none":"metadata");return t.jsx(de,{variant:x,text:i,groupPosition:o,"data-testid":"audio-attachment",children:t.jsx("div",{className:"flex flex-col gap-2",children:u.map((c,b)=>t.jsx(Qn,{item:c,preload:h,trailingAction:f&&b===0?t.jsx(ue,{onClick:d,variant:"inline"}):void 0},`${c.src}-${b}`))})})},ea=e=>t.jsx(Ve,{...e,state:"composer"}),ta=e=>t.jsx(Ve,{...e,state:"sent"}),sa=e=>t.jsx(Ve,{...e,state:"received"}),na={Composer:ea,Sent:ta,Received:sa};function Xt(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 aa={pdf:"PDF",doc:"DOC",xls:"XLS",csv:"CSV",ppt:"PPT",zip:"ZIP",text:"TXT",markdown:"MD"};function Wt(e,s){if(s){const r=s.lastIndexOf(".");if(r>0&&r<s.length-1){const i=s.slice(r+1);if(i&&i.length<=5)return i.toUpperCase()}}if(!e)return;if(ee(e)==="document"){const r=At(e),i=aa[r];if(i)return i;if(e==="application/octet-stream")return}const a=e.split("/")[1];if(!(!a||a==="*"))return a.toUpperCase()}function Kt(e,s,n){const a=Wt(e,s),r=typeof n=="number"&&n>0?Xt(n):void 0;return[a,r].filter(Boolean).join(" · ")||void 0}function Q(e){try{const n=new URL(e).pathname.split("/").pop();return n&&n.length>0?decodeURIComponent(n):"download"}catch{return"download"}}const ra={dark:"text-white/55",light:"text-black/65"},ia={dark:"bg-white/10",light:"bg-black/5"},oa={dark:"text-white/85",light:"text-black/85"},Jt=({variant:e,filename:s,title:n,mimeType:a="application/octet-stream",fileSize:r,onActivate:i,activateLabel:o,trailingAction:l})=>{const d=n??s??"File",x=Kt(a,s,r),f=t.jsx("div",{className:y("flex size-10 shrink-0 items-center justify-center rounded-sm",ia[e]),"aria-hidden":!0,children:te(a,{className:y("size-6",oa[e]),weight:"regular"})}),u=t.jsxs("div",{className:"flex min-w-0 flex-1 flex-col text-left",children:[t.jsx("p",{className:"truncate font-medium leading-snug",children:d}),x?t.jsx("p",{className:y("truncate text-xs leading-4",ra[e]),children:x}):null]}),h=i?t.jsxs("button",{type:"button",onClick:i,"aria-label":o,className:y("flex min-w-0 flex-1 items-center gap-3 rounded-sm text-left transition-colors",e==="dark"?"hover:bg-white/[0.04]":"hover:bg-black/[0.04]"),children:[f,u]}):t.jsxs(t.Fragment,{children:[f,u]});return t.jsxs("div",{className:"flex items-center gap-3 px-3 py-2",children:[h,l?t.jsx("div",{className:"shrink-0",children:l}):null]})};async function Zt(e,s){const n=s??Q(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),o=document.createElement("a");o.href=i,o.download=n,o.style.display="none",document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(i)}catch{if(!window.open(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 la=({src:e,filename:s,fileSize:n,mimeType:a,title:r,items:i})=>i&&i.length>0?i:e?[{src:e,filename:s,fileSize:n,mimeType:a,title:r}]:[],ca=({variant:e,item:s,index:n,onActivate:a,trailingAction:r})=>{const i=s.filename??Q(s.src);return t.jsx(Jt,{variant:e,filename:i,title:s.title,mimeType:s.mimeType??"application/octet-stream",fileSize:s.fileSize,onActivate:()=>a(n),activateLabel:`Download ${i}`,trailingAction:r})},Ue=({state:e,src:s,filename:n,fileSize:a,mimeType:r,title:i,items:o,text:l,groupPosition:d,onClick:x,onDismiss:f})=>{const u=me(e),h=e==="composer"&&!!f,c=la({src:s,filename:n,fileSize:a,mimeType:r,title:i,items:o}),b=p=>{if((x==null?void 0:x(p))===!1)return;const w=c[p];if(!w)return;const N=w.filename??Q(w.src);Zt(w.src,N)};if(c.length===0)return null;const _=t.jsx("span",{className:y("flex size-8 items-center justify-center rounded-full",u==="dark"?"text-white/70":"text-black/70"),"aria-hidden":!0,children:t.jsx(v.DownloadSimpleIcon,{className:"size-5",weight:"bold"})});return t.jsx(de,{variant:u,text:l,groupPosition:d,"data-testid":"file-attachment",children:t.jsx("div",{className:"flex flex-col gap-2",children:c.map((p,w)=>{const N=h&&w===0?t.jsx(ue,{onClick:f,variant:"inline"}):_;return t.jsx(ca,{variant:u,item:p,index:w,onActivate:b,trailingAction:N},`${p.src}-${w}`)})})})},da=e=>t.jsx(Ue,{...e,state:"composer"}),ua=e=>t.jsx(Ue,{...e,state:"sent"}),ma=e=>t.jsx(Ue,{...e,state:"received"}),xa={Composer:da,Sent:ua,Received:ma},Ge=({onPrev:e,onNext:s,prevLabel:n="Previous",nextLabel:a="Next"})=>t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:e,"aria-label":n,className:"mes-media-viewer__nav mes-media-viewer__nav--prev",children:t.jsx(v.CaretLeftIcon,{size:20,weight:"bold","aria-hidden":!0})}),t.jsx("button",{type:"button",onClick:s,"aria-label":a,className:"mes-media-viewer__nav mes-media-viewer__nav--next",children:t.jsx(v.CaretRightIcon,{size:20,weight:"bold","aria-hidden":!0})})]}),Qt=({url:e,filename:s,variant:n="pill",label:a="Download",iconOnly:r,tone:i="dark",onTriggered:o})=>{const[l,d]=m.useState(!1),x=m.useCallback(c=>{c.stopPropagation(),!l&&(d(!0),Zt(e,s).catch(()=>{}).finally(()=>{d(!1),o==null||o()}))},[l,e,s,o]),f=r??n!=="pill",h={className:y(n==="pill"?"size-4":"size-5","shrink-0"),weight:"bold"};if(n==="inline"){const c={dark:"text-white/70 hover:bg-white/[0.08] hover:text-white",light:"text-black/70 hover:bg-black/[0.08] hover:text-black"};return t.jsx("button",{type:"button",onClick:x,disabled:l,"aria-label":a,className:y("flex size-8 shrink-0 items-center justify-center rounded-full transition-colors disabled:opacity-70",c[i]),children:l?t.jsx(v.CircleNotchIcon,{className:"size-4 animate-spin",weight:"bold","aria-hidden":!0}):t.jsx(v.DownloadSimpleIcon,{className:"size-5 shrink-0",weight:"bold","aria-hidden":!0})})}return n==="viewer"?t.jsx("button",{type:"button",onClick:x,disabled:l,"aria-label":a,className:"mes-media-viewer__action",children:l?t.jsx(v.CircleNotchIcon,{size:20,weight:"bold","aria-hidden":!0}):t.jsx(v.DownloadSimpleIcon,{size:20,weight:"bold","aria-hidden":!0})}):t.jsxs("button",{type:"button",onClick:x,disabled:l,"aria-label":f?a:void 0,className:y("mt-3 inline-flex h-10 w-full items-center justify-center gap-2 rounded-full px-4 text-sm font-medium leading-none transition-colors disabled:opacity-70",i==="dark"?"bg-[#121110] text-white hover:bg-[#2a2928]":"bg-white text-[#121110] hover:bg-white/90"),children:[l?t.jsx(v.CircleNotchIcon,{className:"size-4 animate-spin",weight:"bold","aria-hidden":!0}):t.jsx(v.DownloadSimpleIcon,{...h,"aria-hidden":!0}),f?null:a]})},ke=(e,s,n)=>Math.min(Math.max(e,s),n),He=({length:e,initialIndex:s,open:n})=>{const a=ke(s,0,Math.max(e-1,0)),[r,i]=m.useState(a);m.useEffect(()=>{n&&i(ke(s,0,Math.max(e-1,0)))},[n,s,e]),m.useEffect(()=>{i(d=>ke(d,0,Math.max(e-1,0)))},[e]);const o=m.useCallback(()=>{e<=1||i(d=>d<=0?e-1:d-1)},[e]),l=m.useCallback(()=>{e<=1||i(d=>d>=e-1?0:d+1)},[e]);return m.useEffect(()=>{if(!n||e<=1)return;const d=x=>{if(x.key!=="ArrowLeft"&&x.key!=="ArrowRight")return;const f=document.activeElement;f&&(f.tagName==="VIDEO"||f.tagName==="AUDIO")||(x.preventDefault(),x.key==="ArrowLeft"?o():l())};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[n,e,o,l]),{index:r,prev:o,next:l}},Ye=({open:e,onClose:s,ariaLabel:n,counter:a,actions:r,children:i,"data-testid":o})=>{const l=m.useRef(null),d=m.useRef(null);m.useEffect(()=>{var h;const u=l.current;if(u){if(e){if(!u.open)if(typeof u.showModal=="function")try{u.showModal()}catch{u.setAttribute("open","")}else u.setAttribute("open","");const c=typeof document<"u"?document.activeElement:null;return(h=d.current)==null||h.focus(),()=>{if(u.open)if(typeof u.close=="function")try{u.close()}catch{u.removeAttribute("open")}else u.removeAttribute("open");c&&document.body.contains(c)&&c.focus()}}if(u.open)if(typeof u.close=="function")try{u.close()}catch{u.removeAttribute("open")}else u.removeAttribute("open")}},[e]);const x=()=>{s()},f=u=>{u.target===l.current&&s()};return t.jsxs("dialog",{ref:l,className:"mes-media-viewer","aria-label":n??"Attachment viewer","data-testid":o,onClose:x,onClick:f,children:[t.jsxs("div",{className:"mes-media-viewer__chrome",children:[a?t.jsx("span",{className:"mes-media-viewer__counter",children:a}):null,t.jsxs("div",{className:"mes-media-viewer__actions",children:[r,t.jsx("button",{ref:d,type:"button",onClick:s,"aria-label":"Close viewer",className:"mes-media-viewer__action",children:t.jsx(v.XIcon,{size:20,weight:"bold","aria-hidden":!0})})]})]}),t.jsx("div",{className:"mes-media-viewer__body",children:i})]})},es=({open:e,items:s,initialIndex:n=0,onClose:a})=>{const{index:r,prev:i,next:o}=He({length:s.length,initialIndex:n,open:e}),l=s[r],d=m.useMemo(()=>(l==null?void 0:l.filename)??(l?Q(l.src):"image"),[l]);return l?t.jsxs(Ye,{open:e,onClose:a,ariaLabel:d,counter:s.length>1?`${r+1} / ${s.length}`:void 0,actions:t.jsx(Qt,{url:l.src,filename:d,variant:"viewer",label:`Download ${d}`}),"data-testid":"image-viewer",children:[t.jsx("img",{src:l.src,alt:l.alt??d,draggable:!1,loading:"eager",decoding:"async",className:"mes-media-viewer__image"},`${r}:${l.src}`),s.length>1?t.jsx(Ge,{onPrev:i,onNext:o,prevLabel:"Previous image",nextLabel:"Next image"}):null]}):null},ha="relative block size-full overflow-hidden bg-black/5 outline-none focus-visible:ring-2 focus-visible:ring-white/80 focus-visible:ring-offset-2 focus-visible:ring-offset-black",ts=({tiles:e,onTileActivate:s,maxVisible:n=4,className:a})=>{const r=e.length;if(r===0)return null;const i=e.slice(0,Math.min(r,n)),o=r-i.length,l=(d,x,f)=>{const u=y(ha,"h-full w-full");return s?t.jsxs("button",{type:"button",onClick:()=>s(x),"aria-label":d.ariaLabel??`Open media ${x+1}`,className:y(u,"cursor-zoom-in"),children:[d.content,f]},x):t.jsxs("div",{className:u,children:[d.content,f]},x)};return i.length===1?t.jsx("div",{className:y("aspect-square w-full",a),children:l(i[0],0)}):i.length===2?t.jsx("div",{className:y("grid aspect-[16/9] w-full grid-cols-2 gap-0.5",a),children:i.map((d,x)=>l(d,x))}):i.length===3?t.jsxs("div",{className:y("grid aspect-[4/3] w-full grid-cols-2 grid-rows-2 gap-0.5",a),children:[t.jsx("div",{className:"row-span-2",children:l(i[0],0)}),l(i[1],1),l(i[2],2)]}):t.jsx("div",{className:y("grid aspect-[4/3] w-full grid-cols-2 grid-rows-2 gap-0.5",a),children:i.map((d,x)=>{const f=o>0&&x===i.length-1;return l(d,x,f?t.jsxs("div",{className:"absolute inset-0 flex items-center justify-center bg-black/55 text-2xl font-semibold text-white",children:["+",o]}):null)})})},xe=e=>{const[s,n]=m.useState(!1),[a,r]=m.useState(0),i=m.useCallback(l=>{(e==null?void 0:e(l))!==!1&&(r(l),n(!0))},[e]),o=m.useCallback(()=>n(!1),[]);return{viewerOpen:s,viewerIndex:a,handleActivate:i,closeViewer:o}},fa=(e,s,n,a)=>({ariaLabel:`Open image ${s+1} of ${n}`,content:t.jsx("img",{src:e.src,alt:e.alt??"",width:e.width,height:e.height,draggable:!1,loading:e.loading??a,decoding:"async",className:"absolute inset-0 size-full rounded-md object-cover"})}),ga=({src:e,alt:s,items:n})=>n&&n.length>0?n:e?[{src:e,alt:s}]:[],ss=(e,s)=>e.map((n,a)=>({src:n.src,alt:n.alt,filename:s&&e.length===1?s:s?`${s} (${a+1})`:void 0})),ba=({src:e,alt:s,filename:n,loading:a="lazy",onClick:r,onDismiss:i})=>{const{viewerOpen:o,viewerIndex:l,handleActivate:d,closeViewer:x}=xe(r);return t.jsxs("div",{className:"relative w-fit",children:[t.jsx("button",{type:"button",onClick:()=>d(0),"aria-label":"Open image",className:"block size-[280px] cursor-zoom-in overflow-hidden rounded-md outline-none focus-visible:ring-2 focus-visible:ring-black/40",children:t.jsx("img",{src:e,alt:s??"",draggable:!1,loading:a,decoding:"async",className:"size-full object-cover"})}),i?t.jsx("div",{className:"absolute right-2 top-2 z-10",children:t.jsx(ue,{onClick:i})}):null,t.jsx(es,{open:o,items:ss([{src:e,alt:s}],n),initialIndex:l,onClose:x})]})},ns=({state:e,src:s,alt:n,filename:a,items:r,text:i,groupPosition:o,loading:l="lazy",onClick:d})=>{const x=ga({src:s,alt:n,items:r}),f=me(e),{viewerOpen:u,viewerIndex:h,handleActivate:c,closeViewer:b}=xe(d);if(x.length===0)return null;const _=x.map((p,w)=>fa(p,w,x.length,l));return t.jsxs(de,{variant:f,text:i,groupPosition:o,"data-testid":"image-attachment",children:[t.jsx("div",{className:"relative",children:t.jsx(ts,{tiles:_,onTileActivate:c})}),t.jsx(es,{open:u,items:ss(x,a),initialIndex:h,onClose:b})]})},pa=e=>t.jsx(ba,{...e}),va=e=>t.jsx(ns,{...e,state:"sent"}),ja=e=>t.jsx(ns,{...e,state:"received"}),wa={Composer:pa,Sent:va,Received:ja},Na=({open:e,items:s,initialIndex:n=0,onClose:a})=>{const{index:r,prev:i,next:o}=He({length:s.length,initialIndex:n,open:e}),l=s[r],d=m.useMemo(()=>(l==null?void 0:l.filename)??(l?Q(l.src):"document"),[l]),x=m.useMemo(()=>l?_a(l.src):void 0,[l]);return!l||!x?null:t.jsxs(Ye,{open:e,onClose:a,ariaLabel:d,counter:s.length>1?`${r+1} / ${s.length}`:void 0,"data-testid":"pdf-viewer",children:[t.jsx("iframe",{src:x,title:d,className:"mes-media-viewer__iframe",sandbox:"allow-scripts allow-forms allow-popups allow-downloads"},`${r}:${l.src}`),s.length>1?t.jsx(Ge,{onPrev:i,onNext:o,prevLabel:"Previous document",nextLabel:"Next document"}):null]})},_a=e=>{const s=e.indexOf("#"),n=s===-1?e:e.slice(0,s),a=s===-1?"":e.slice(s+1),r=new URLSearchParams(a);return r.has("toolbar")||r.set("toolbar","0"),r.has("navpanes")||r.set("navpanes","0"),`${n}#${r.toString()}`},Ca=({src:e,filename:s,fileSize:n,title:a,items:r})=>r&&r.length>0?r:e?[{src:e,filename:s,fileSize:n,title:a}]:[],ya=({variant:e,item:s,index:n,onActivate:a,trailingAction:r})=>{const i=s.filename??Q(s.src);return t.jsx(Jt,{variant:e,filename:i,title:s.title,mimeType:"application/pdf",fileSize:s.fileSize,onActivate:()=>a(n),activateLabel:`Open ${i}`,trailingAction:r})},qe=({state:e,src:s,filename:n,fileSize:a,title:r,items:i,text:o,groupPosition:l,onClick:d,onDismiss:x})=>{const f=me(e),u=Ca({src:s,filename:n,fileSize:a,title:r,items:i}),{viewerOpen:h,viewerIndex:c,handleActivate:b,closeViewer:_}=xe(d),p=e==="composer"&&!!x;if(u.length===0)return null;const w=u.map(N=>({src:N.src,filename:N.filename??Q(N.src)}));return t.jsxs(de,{variant:f,text:o,groupPosition:l,"data-testid":"pdf-attachment",children:[t.jsx("div",{className:"flex flex-col gap-2",children:u.map((N,M)=>{const A=N.filename??Q(N.src),T=p&&M===0?t.jsx(ue,{onClick:x,variant:"inline"}):e==="composer"?void 0:t.jsx(Qt,{url:N.src,filename:A,variant:"inline",label:`Download ${A}`,tone:f});return t.jsx(ya,{variant:f,item:N,index:M,onActivate:b,trailingAction:T},`${N.src}-${M}`)})}),t.jsx(Na,{open:h,items:w,initialIndex:c,onClose:_})]})},ka=e=>t.jsx(qe,{...e,state:"composer"}),Sa=e=>t.jsx(qe,{...e,state:"sent"}),Ea=e=>t.jsx(qe,{...e,state:"received"}),Ia={Composer:ka,Sent:Sa,Received:Ea},as=({open:e,items:s,initialIndex:n=0,onClose:a})=>{const{index:r,prev:i,next:o}=He({length:s.length,initialIndex:n,open:e}),l=s[r],d=m.useMemo(()=>(l==null?void 0:l.filename)??(l?Q(l.src):"video"),[l]);return l?t.jsxs(Ye,{open:e,onClose:a,ariaLabel:d,counter:s.length>1?`${r+1} / ${s.length}`:void 0,"data-testid":"video-viewer",children:[t.jsx("video",{src:l.src,poster:l.poster,controls:!0,autoPlay:!0,muted:!0,playsInline:!0,preload:l.preload??"metadata",className:"mes-media-viewer__video",children:l.mimeType?t.jsx("source",{src:l.src,type:l.mimeType}):null},`${r}:${l.src}`),s.length>1?t.jsx(Ge,{onPrev:i,onNext:o,prevLabel:"Previous video",nextLabel:"Next video"}):null]}):null},Ta=()=>t.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center",children:t.jsx("span",{className:"flex size-12 items-center justify-center rounded-full bg-black/55 text-white backdrop-blur",children:t.jsx(v.PlayIcon,{className:"size-6",weight:"fill","aria-hidden":!0})})}),rs=({item:e,index:s})=>t.jsxs("div",{className:"absolute inset-0 size-full bg-[#0d0d0d]",children:[e.poster?t.jsx("img",{src:e.poster,alt:`Video ${s+1} thumbnail`,draggable:!1,loading:"lazy",decoding:"async",className:"absolute inset-0 size-full rounded-md object-cover"}):t.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:t.jsx(v.VideoCameraIcon,{className:"size-16 rounded-md text-white/30",weight:"regular","aria-hidden":!0})}),t.jsx(Ta,{})]}),Aa=(e,s,n)=>({ariaLabel:`Play video ${s+1} of ${n}`,content:t.jsx(rs,{item:e,index:s})}),Ma=({src:e,poster:s,mimeType:n,preload:a,items:r})=>r&&r.length>0?a?r.map(i=>({...i,preload:i.preload??a})):r:e?[{src:e,poster:s,mimeType:n,preload:a}]:[],is=(e,s)=>e.map((n,a)=>({src:n.src,poster:n.poster,mimeType:n.mimeType,preload:n.preload,filename:s&&e.length===1?s:s?`${s} (${a+1})`:void 0})),Ra=({src:e,poster:s,mimeType:n,filename:a,preload:r,onClick:i,onDismiss:o})=>{const{viewerOpen:l,viewerIndex:d,handleActivate:x,closeViewer:f}=xe(i);return t.jsxs("div",{className:"relative w-fit",children:[t.jsx("button",{type:"button",onClick:()=>x(0),"aria-label":"Play video",className:"relative block size-[280px] cursor-pointer overflow-hidden rounded-md outline-none focus-visible:ring-2 focus-visible:ring-black/40",children:t.jsx(rs,{item:{src:e,poster:s,mimeType:n},index:0})}),o?t.jsx("div",{className:"absolute right-2 top-2 z-10",children:t.jsx(ue,{onClick:o})}):null,t.jsx(as,{open:l,items:is([{src:e,poster:s,mimeType:n,preload:r}],a),initialIndex:d,onClose:f})]})},os=({state:e,src:s,poster:n,mimeType:a,filename:r,items:i,text:o,groupPosition:l,preload:d,onClick:x})=>{const f=Ma({src:s,poster:n,mimeType:a,preload:d,items:i}),u=me(e),{viewerOpen:h,viewerIndex:c,handleActivate:b,closeViewer:_}=xe(x);if(f.length===0)return null;const p=f.map((w,N)=>Aa(w,N,f.length));return t.jsxs(de,{variant:u,text:o,groupPosition:l,"data-testid":"video-attachment",children:[t.jsx("div",{className:"relative",children:t.jsx(ts,{tiles:p,onTileActivate:b,className:"overflow-hidden rounded-md"})}),t.jsx(as,{open:h,items:is(f,r),initialIndex:c,onClose:_})]})},Da=e=>t.jsx(Ra,{...e}),La=e=>t.jsx(os,{...e,state:"sent"}),Pa=e=>t.jsx(os,{...e,state:"received"}),Fa={Composer:Da,Sent:La,Received:Pa},Oa={Image:wa,Video:Fa,Audio:na,Pdf:Ia,File:xa},ls=({question:e,onClick:s,loading:n=!1,className:a})=>t.jsx("button",{type:"button",onClick:s,disabled:n,style:{backgroundColor:"#E6E5E3"},className:y("w-full text-center p-4 rounded-xl text-charcoal font-medium transition-colors focus-ring",{"hover:brightness-95 active:brightness-90":!n,"opacity-50 cursor-not-allowed":n},a),children:e}),za=({faqs:e,onFaqClick:s,loadingFaqId:n,headerText:a,className:r,avatarImage:i,avatarName:o})=>{const l=e.filter(d=>d.enabled).sort((d,x)=>(d.order??0)-(x.order??0));return l.length===0?null:t.jsx("div",{className:r,children:t.jsxs("div",{className:"flex gap-3 items-end",children:[(i||o)&&t.jsx("div",{className:"flex-none",children:t.jsx(Z,{id:o||"account",name:o||"Account",image:i,size:24,shape:"circle"})}),t.jsxs("div",{className:"flex-1 flex flex-col gap-3 rounded-lg p-4",style:{backgroundColor:"#F1F0EE"},children:[a&&t.jsx("p",{className:"text-md text-charcoal mb-4",children:a}),l.map(d=>t.jsx(ls,{question:d.question,onClick:()=>s(d.id),loading:n===d.id},d.id))]})]})})};exports.ActionButton=oe;exports.AttachmentThumbnail=De;exports.Avatar=Z;exports.ChannelEmptyState=Vt;exports.ChannelList=Yt;exports.ChannelView=Oe;exports.CustomMessageProvider=Ys;exports.FaqList=za;exports.FaqListItem=ls;exports.LinkAttachment=Hn;exports.LockedAttachment=Ie;exports.MediaMessage=Us;exports.MessageAttachment=Oa;exports.MessageVoteButtons=zt;exports.MessagingProvider=us;exports.MessagingShell=kn;exports.bubbleGroupPositionFromStream=Jn;exports.buildCompactMetaLabel=Kt;exports.formatFileSize=Xt;exports.formatRelativeTime=Gt;exports.getFileExtensionLabel=Wt;exports.getMessageDisplayText=Me;exports.getSourceType=ee;exports.isLinkAttachment=Fe;exports.isUuidLike=kt;exports.normalizeLanguageCode=Et;exports.renderTypeIcon=te;exports.resolveLinkAttachment=ve;exports.resolveMediaFromMessage=je;exports.resolveParticipantDisplayName=ce;exports.useCustomMessage=Ft;exports.useMessageVote=St;exports.useMessaging=Ct;
2
- //# sourceMappingURL=index-BQf4WkPC.cjs.map