@linktr.ee/messaging-react 3.25.0-rc-1785443162 → 3.25.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.
- package/dist/{Card-Cd0uC7M9.js → Card-DdmdgPiC.js} +2 -2
- package/dist/{Card-Cd0uC7M9.js.map → Card-DdmdgPiC.js.map} +1 -1
- package/dist/{Card-B1Rliu1L.cjs → Card-ZqURr2Xg.cjs} +2 -2
- package/dist/{Card-B1Rliu1L.cjs.map → Card-ZqURr2Xg.cjs.map} +1 -1
- package/dist/{index-Hlj3mc6w.js → index-CitR7B66.js} +120 -120
- package/dist/{index-Hlj3mc6w.js.map → index-CitR7B66.js.map} +1 -1
- package/dist/{index-CWpDkA50.cjs → index-QulHlER7.cjs} +3 -3
- package/dist/{index-CWpDkA50.cjs.map → index-QulHlER7.cjs.map} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/package.json +2 -2
- package/src/components/LinkAttachment/LinkAttachment.test.tsx +21 -20
- package/src/components/LinkAttachment/components/_shared/useChinPalette.ts +9 -10
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"use strict";const r=require("react/jsx-runtime"),g=require("react"),kr=require("@linktr.ee/messaging-core"),tt=require("stream-chat"),N=require("stream-chat-react"),S=require("classnames"),M=require("@phosphor-icons/react"),se=require("@linktr.ee/messaging-taxonomy"),yn=require("stream-chat-react/experimental"),Qs=g.createContext({service:null,client:null,isConnected:!1,isLoading:!1,error:null,capabilities:{},refreshConnection:async()=>{},debug:!1}),_n=()=>g.useContext(Qs),Mr=({children:e,user:t,serviceConfig:n,apiKey:s,capabilities:a={},debug:i=!1,client:o})=>{var T,R;const l=g.useCallback((A,...$)=>{i&&console.log(`🔥 [MessagingProvider] ${A}`,...$)},[i]);l("🔄 RENDER START",{userId:t==null?void 0:t.id,apiKey:(s==null?void 0:s.substring(0,8))+"...",serviceConfig:!!n,capabilities:Object.keys(a)});const[c,f]=g.useState(null),[m,u]=g.useState(null),[h,d]=g.useState(!1),[v,y]=g.useState(!1),[x,p]=g.useState(null),b=g.useRef(!1),w=g.useRef(null),C=g.useRef(n);C.current=n;const I=g.useRef(i);I.current=i;const F=g.useRef({userId:t==null?void 0:t.id,apiKey:s,serviceConfig:n,capabilities:a}),P=g.useRef(0);P.current++,l("📊 RENDER INFO",{renderCount:P.current,currentProps:{userId:t==null?void 0:t.id,apiKey:(s==null?void 0:s.substring(0,8))+"..."},propChanges:{userChanged:F.current.userId!==(t==null?void 0:t.id),apiKeyChanged:F.current.apiKey!==s,serviceConfigChanged:F.current.serviceConfig!==n,capabilitiesChanged:F.current.capabilities!==a}}),F.current={userId:t==null?void 0:t.id,apiKey:s,serviceConfig:n,capabilities:a};const B=g.useRef(null);!o&&s&&((T=B.current)==null?void 0:T.apiKey)!==s&&(B.current={apiKey:s,client:new tt.StreamChat(s)});const H=o||(s?((R=B.current)==null?void 0:R.client)??null:null);g.useEffect(()=>{const A=P.current,$=C.current;if(o){w.current=null,f(null),u(null),d(!1),p(null),y(!1);return}if(!s||!H||!$){l("⚠️ SERVICE INIT SKIPPED",{renderCount:A,reason:"Missing apiKey, client, or serviceConfig"});return}l("🚀 CREATING SERVICE",{renderCount:A,apiKey:(s==null?void 0:s.substring(0,8))+"..."});const V=new kr.StreamChatService({...$,apiKey:s,debug:I.current,client:H});w.current=V,f(V),l("✅ SERVICE SET",{renderCount:A,serviceInstance:!!V})},[s,H,o]);const z=g.useRef(null);g.useEffect(()=>{var $,V;if(l("🔗 USER CONNECTION EFFECT TRIGGERED",{hasService:!!c,hasUser:!!t,userId:t==null?void 0:t.id,isConnecting:b.current,isConnected:h,dependencies:{service:!!c,userId:t==null?void 0:t.id}}),o)return;if(!c||!t){l("⚠️ USER CONNECTION SKIPPED","Missing service or user");return}if(b.current){l("⚠️ USER CONNECTION SKIPPED","Already connecting");return}if((($=z.current)==null?void 0:$.serviceId)===c&&((V=z.current)==null?void 0:V.userId)===t.id){l("⚠️ USER CONNECTION SKIPPED","Already connected this user with this service");return}(async()=>{l("🚀 STARTING USER CONNECTION",{userId:t.id}),b.current=!0,y(!0),p(null);try{l("📞 CALLING SERVICE.CONNECTUSER",{userId:t.id});const q=await c.connectUser(t);u(q),d(!0),z.current={serviceId:c,userId:t.id},l("✅ USER CONNECTION SUCCESS",{userId:t.id,clientId:q.userID})}catch(q){const W=q instanceof Error?q.message:"Connection failed";p(W),l("❌ USER CONNECTION ERROR",{userId:t.id,error:W})}finally{y(!1),b.current=!1,l("🔄 USER CONNECTION FINISHED",{userId:t.id,isConnected:h})}})()},[c,t,l,h,o]),g.useEffect(()=>{const A=H;return()=>{var $;A&&(z.current=null,($=w.current)==null||$.disconnectUser().catch(console.error))}},[H]);const E=g.useCallback(async()=>{if(l("🔄 REFRESH CONNECTION CALLED",{hasService:!!c,hasUser:!!t}),!o){if(!c||!t){l("⚠️ REFRESH CONNECTION SKIPPED","Missing service or user");return}l("🚀 STARTING CONNECTION REFRESH",{userId:t.id}),y(!0);try{l("🔌 DISCONNECTING FOR REFRESH"),await c.disconnectUser(),l("📞 RECONNECTING FOR REFRESH");const A=await c.connectUser(t);u(A),d(!0),p(null),l("✅ CONNECTION REFRESH SUCCESS",{userId:t.id})}catch(A){const $=A instanceof Error?A.message:"Refresh failed";p($),l("❌ CONNECTION REFRESH ERROR",{userId:t.id,error:$})}finally{y(!1),l("🔄 CONNECTION REFRESH FINISHED",{userId:t.id})}}},[c,t,l,o]),D=g.useMemo(()=>(l("💫 CONTEXT VALUE MEMOIZATION",{hasService:!!c,hasClient:!!m,isConnected:h,isLoading:v,hasError:!!x,capabilitiesKeys:Object.keys(a)}),{service:o?null:c,client:o??m,isConnected:o?!0:h,isLoading:o?!1:v,error:o?null:x,capabilities:a,refreshConnection:E,debug:i}),[c,m,o,h,v,x,a,E,i,l]);return l("🔄 RENDER END",{renderCount:P.current,willRenderChat:!!H,contextValueReady:!!D}),r.jsx(Qs.Provider,{value:D,children:H?r.jsx(N.Chat,{client:H,customClasses:{channelList:"str-chat__channel-list str-chat__channel-list-react bg-transparent lg:border-r-2 border-r-0 border-[#0000000A]"},children:e}):e})},ea=()=>_n(),ta=e=>{var s,a;const[t,n]=g.useState(!!((a=(s=e==null?void 0:e.state)==null?void 0:s.membership)!=null&&a.pinned_at));return g.useEffect(()=>{var o;if(!e){n(!1);return}n(!!((o=e.state.membership)!=null&&o.pinned_at));const i=l=>{var c;n(l!=null&&l.member?!!l.member.pinned_at:!!((c=e.state.membership)!=null&&c.pinned_at))};return e.on("member.updated",i),()=>{e.off("member.updated",i)}},[e]),t};function wn(e,t,n){const s=Object.values(e||{});if(se.isOfficialChannel(n)){const a=s.find(i=>{var o;return((o=i.user)==null?void 0:o.id)===se.OFFICIAL_SENDER_USER_ID});if(a)return a}return s.find(a=>{var i;return((i=a.user)==null?void 0:i.id)&&a.user.id!==t})}const Cr=/^[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 na(e){return Cr.test(e.trim())}function gs(e,t){const n=e==null?void 0:e.trim();return!n||t&&n===t||t&&n===`Follower ${t}`?!1:!na(n)}function jn(e){return gs(e==null?void 0:e.name,e==null?void 0:e.id)?e.name.trim():gs(e==null?void 0:e.username,e==null?void 0:e.id)?e.username.trim():"Unknown member"}const xs=[{emoji:"🍎",bgColor:"#FFD1DD"},{emoji:"🍌",bgColor:"#FFF1C9"},{emoji:"🍇",bgColor:"#E6D9FF"},{emoji:"🍊",bgColor:"#D6F4FF"},{emoji:"🍓",bgColor:"#FFE0AE"},{emoji:"🥥",bgColor:"#F7E7D8"},{emoji:"🍒",bgColor:"#DFF4D8"},{emoji:"🥭",bgColor:"#FFD8C2"},{emoji:"🍉",bgColor:"#D6EBFF"},{emoji:"🍋",bgColor:"#CAEEB5"},{emoji:"🥝",bgColor:"#FFE7C7"},{emoji:"🫒",bgColor:"#F6E3B4"},{emoji:"🍈",bgColor:"#D9F7E1"}];function Sr(e){let t=0;for(let n=0;n<e.length;n++){const s=e.charCodeAt(n);t=(t<<5)-t+s,t=t&t}return Math.abs(t)}function sa(e){return xs[Sr(e)%xs.length]}function Er(e){return sa(e).emoji}function Tr(e){return sa(e).bgColor}const ke=({id:e,image:t,size:n=40,className:s,starred:a=!1,shape:i="squircle",dmAgentEnabled:o=!1})=>{const l=Er(e),c=Tr(e),f=.45,u=n<32?Math.round(n*f):n<56?14:n<120?18:36,h=n>=40?2:1,d=i==="circle"?{borderRadius:"50%"}:{borderRadius:"1rem"},v=r.jsx("div",{className:"h-full w-full overflow-hidden",style:d,children:t?r.jsx("img",{src:t,alt:"",className:"h-full w-full object-cover"}):r.jsx("div",{"aria-hidden":"true",className:S("avatar-fallback flex h-full w-full items-center justify-center font-semibold select-none transition-colors"),style:{fontSize:u,lineHeight:1},children:l})});return r.jsxs("div",{className:S("relative flex-shrink-0",s),style:{"--str-chat__avatar-size":`${n}px`,width:`${n}px`,height:`${n}px`,backgroundColor:t?void 0:c,...d},children:[a&&r.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:r.jsx(M.StarIcon,{className:"size-3 text-yellow-600",weight:"duotone"})}),r.jsx("div",{"data-testid":"avatar-ring",className:S("h-full w-full","bg-transparent"),style:{...d,...o&&{borderWidth:`${h}px`,borderStyle:"solid",borderColor:"var(--AI-Gradient, #7F22FE)",boxShadow:"inset 0 1px 2px 0 rgba(255, 255, 255, 0.5)"}},children:v})]})},Ir="https://linktr.ee/s/about/trust-center/report",Rr=({channel:e,participant:t,showBlockParticipant:n=!0,enabled:s=!0,onLeaveConversation:a,onBlockParticipant:i,onDeleteConversationClick:o,onBlockParticipantClick:l,onReportParticipantClick:c,onActionComplete:f,logLabel:m="useChannelModerationActions"})=>{var D;const{service:u,debug:h}=_n(),d=(D=t==null?void 0:t.user)==null?void 0:D.id,v=!!(s&&n&&u&&d),[y,x]=g.useState(!1),[p,b]=g.useState(null),[w,C]=g.useState(!1),[I,F]=g.useState(!1),P=v&&((p==null?void 0:p.participantId)!==d||(p==null?void 0:p.service)!==u);return g.useEffect(()=>{if(!v||!u||!d){x(!1),b(null);return}let T=!1;return(async()=>{try{const R=await u.getBlockedUsers();if(T)return;x(R.some(A=>A.blocked_user_id===d))}catch(R){T||console.error(`[${m}] Failed to check blocked status:`,R)}finally{T||b({participantId:d,service:u})}})(),()=>{T=!0}},[v,u,d,m]),{isParticipantBlocked:y,isCheckingBlockedStatus:P,isLeaving:w,isUpdatingBlockStatus:I,handleLeaveConversation:async()=>{var T;if(!w){o==null||o(),h&&console.log(`[${m}] Leave conversation`,e.cid),C(!0);try{const R=((T=e._client)==null?void 0:T.userID)??null;await e.hide(R,!1),a&&await a(e),f==null||f()}catch(R){console.error(`[${m}] Failed to leave conversation`,R)}finally{C(!1)}}},handleBlockUser:async()=>{var T,R,A;if(!(I||!u)){l==null||l(),h&&console.log(`[${m}] Block member`,(T=t==null?void 0:t.user)==null?void 0:T.id),F(!0);try{await u.blockUser((R=t==null?void 0:t.user)==null?void 0:R.id),i&&await i((A=t==null?void 0:t.user)==null?void 0:A.id),f==null||f()}catch($){console.error(`[${m}] Failed to block member`,$)}finally{F(!1)}}},handleUnblockUser:async()=>{var T,R,A;if(!(I||!u)){l==null||l(),h&&console.log(`[${m}] Unblock member`,(T=t==null?void 0:t.user)==null?void 0:T.id),F(!0);try{await u.unBlockUser((R=t==null?void 0:t.user)==null?void 0:R.id),i&&await i((A=t==null?void 0:t.user)==null?void 0:A.id),f==null||f()}catch($){console.error(`[${m}] Failed to unblock member`,$)}finally{F(!1)}}},handleReportUser:()=>{c==null||c(),f==null||f(),window.open(Ir,"_blank","noopener,noreferrer")}}},Ie=({variant:e="default",className:t,children:n,...s})=>{const a=e==="danger";return r.jsx("button",{type:"button",className:S("flex w-full items-center gap-3 rounded-lg px-4 py-3 text-left text-sm transition-colors focus-ring disabled:cursor-not-allowed disabled:opacity-60",a?"text-danger hover:bg-danger/50":"text-charcoal hover:bg-sand",t),...s,children:n})},Lr=({channel:e,participant:t,showDeleteConversation:n=!0,showBlockParticipant:s=!0,showReportParticipant:a=!0,onLeaveConversation:i,onBlockParticipant:o,onDeleteConversationClick:l,onBlockParticipantClick:c,onReportParticipantClick:f,customChannelActions:m,triggerClassName:u})=>{const[h,d]=g.useState(!1),v=g.useRef(null),y=g.useId(),x=g.useCallback(()=>d(!1),[]),{isParticipantBlocked:p,isCheckingBlockedStatus:b,isLeaving:w,isUpdatingBlockStatus:C,handleLeaveConversation:I,handleBlockUser:F,handleUnblockUser:P,handleReportUser:B}=Rr({channel:e,participant:t,showBlockParticipant:s,enabled:h,onLeaveConversation:i,onBlockParticipant:o,onDeleteConversationClick:l,onBlockParticipantClick:c,onReportParticipantClick:f,onActionComplete:x,logLabel:"ChannelActionsMenu"});return g.useEffect(()=>{if(!h)return;const z=D=>{v.current&&!v.current.contains(D.target)&&d(!1)},E=D=>{D.key==="Escape"&&d(!1)};return document.addEventListener("mousedown",z),document.addEventListener("keydown",E),()=>{document.removeEventListener("mousedown",z),document.removeEventListener("keydown",E)}},[h]),!t||!(n||s||a||!!m)?null:r.jsxs("div",{ref:v,className:"relative",children:[r.jsxs("button",{className:u,type:"button","aria-haspopup":"true","aria-expanded":h,"aria-controls":h?y:void 0,onClick:()=>d(z=>!z),children:[r.jsx(M.DotsThreeIcon,{className:"size-5 text-black/90"}),r.jsx("span",{className:"sr-only",children:"More options"})]}),h&&r.jsx("div",{id:y,"aria-label":"Conversation options",className:S("absolute right-0 top-full z-50 mt-2 w-56 overflow-hidden","rounded-lg border border-sand bg-white p-1 shadow-max-elevation-light"),children:r.jsxs("ul",{className:"flex flex-col gap-1",children:[n&&r.jsx("li",{children:r.jsxs(Ie,{onClick:I,disabled:w,"aria-busy":w,children:[w?r.jsx(M.SpinnerGapIcon,{className:"h-5 w-5 animate-spin"}):r.jsx(M.SignOutIcon,{className:"h-5 w-5"}),r.jsx("span",{children:"Delete Conversation"})]})}),s&&r.jsx("li",{children:b?r.jsxs(Ie,{disabled:!0,"aria-busy":!0,children:[r.jsx(M.SpinnerGapIcon,{className:"h-5 w-5 animate-spin"}),r.jsx("span",{children:"Block"})]}):p?r.jsxs(Ie,{onClick:P,disabled:C,"aria-busy":C,children:[C?r.jsx(M.SpinnerGapIcon,{className:"h-5 w-5 animate-spin"}):r.jsx(M.ProhibitInsetIcon,{className:"h-5 w-5"}),r.jsx("span",{children:"Unblock"})]}):r.jsxs(Ie,{onClick:F,disabled:C,"aria-busy":C,children:[C?r.jsx(M.SpinnerGapIcon,{className:"h-5 w-5 animate-spin"}):r.jsx(M.ProhibitInsetIcon,{className:"h-5 w-5"}),r.jsx("span",{children:"Block"})]})}),a&&r.jsx("li",{children:r.jsxs(Ie,{variant:"danger",onClick:B,children:[r.jsx(M.FlagIcon,{className:"h-5 w-5"}),r.jsx("span",{children:"Report"})]})}),m]})})]})},It="flex size-10 flex-shrink-0 items-center justify-center rounded-full bg-white/65 shadow-[0px_4px_8px_0px_rgba(0,0,0,0.06),0px_0px_0px_1px_rgba(0,0,0,0.04)] backdrop-blur-[40px] transition-filter duration-150 hover:brightness-95 aria-expanded:brightness-95 focus-ring",Ar="CUSTOMER_PAID",zr=e=>typeof e=="string"&&e.trim().replace(/[\s-]+/g,"_").toUpperCase()===Ar,$r=({className:e,onBack:t,showBackButton:n,showStarButton:s=!1,onLeaveConversation:a,onBlockParticipant:i,showDeleteConversation:o=!0,showBlockParticipant:l=!0,showReportParticipant:c=!0,onDeleteConversationClick:f,onBlockParticipantClick:m,onReportParticipantClick:u,customChannelActions:h,renderChannelActions:d,showChannelInfo:v=!0,onParticipantNameClick:y})=>{var E,D,T,R;const{channel:x}=N.useChannelStateContext(),{client:p}=N.useChatContext(),b=g.useMemo(()=>{var A;return wn((A=x.state)==null?void 0:A.members,p==null?void 0:p.userID,x.type)},[(E=x.state)==null?void 0:E.members,p==null?void 0:p.userID,x.type]),w=jn(b==null?void 0:b.user),C=(D=b==null?void 0:b.user)==null?void 0:D.image,I=ta(x),F=zr((T=x.data)==null?void 0:T.customer_tag)&&(b==null?void 0:b.is_follower)===!0,P=s&&I,B=F||P||!!y,H=async()=>{try{I?await x.unpin():await x.pin()}catch(A){console.error("[ChannelHeaderRedesign] Failed to update pinned status:",A)}},z=r.jsxs(r.Fragment,{children:[r.jsx(ke,{id:((R=b==null?void 0:b.user)==null?void 0:R.id)||x.id||"unknown",name:w,image:C,shape:"circle",size:48,className:"-mb-2"}),r.jsx("span",{className:S("relative z-10 flex max-w-full flex-col items-center justify-center rounded-full border border-white/10 bg-white/65 py-1.5 shadow-[0px_0px_0px_0px_rgba(0,0,0,0.04),0px_1px_2px_0px_rgba(0,0,0,0.04),0px_8px_32px_0px_rgba(0,0,0,0.1)] backdrop-blur-[2px] transition-filter duration-150 group-hover:brightness-95",B?"pl-3 pr-2":"px-3"),children:r.jsxs("span",{className:"flex max-w-full items-center justify-center",children:[r.jsx("span",{className:"min-w-0 truncate text-sm font-bold leading-[1.43] tracking-[0.28px] text-black/90",children:w}),B&&r.jsxs("span",{className:"ml-2 flex gap-1",children:[F&&r.jsx("span",{"aria-label":"Paid customer",className:"flex size-4 shrink-0 items-center justify-center rounded-full bg-[#34C759] text-white",children:r.jsx(M.CurrencyDollarIcon,{className:"size-2.5",weight:"bold"})}),P&&r.jsx("span",{"aria-label":"Starred conversation",className:"flex size-4 shrink-0 items-center justify-center rounded-full bg-[#FFD60A] text-white",children:r.jsx(M.StarIcon,{className:"size-2.5",weight:"fill"})}),y&&r.jsx(M.CaretRightIcon,{"aria-hidden":"true",className:"size-4 shrink-0 text-black/65",weight:"bold"})]})]})})]});return r.jsx("div",{className:S("@container bg-[linear-gradient(180deg,#FBFAF9_0%,rgba(251,250,249,0.92)_58%,rgba(251,250,249,0)_100%)]",e),children:r.jsxs("div",{className:"grid min-h-[100px] grid-cols-[minmax(40px,1fr)_auto_minmax(40px,1fr)] items-start pb-2 pt-5 @lg:min-h-[104px] @lg:pt-6",children:[r.jsx("div",{className:"flex items-start",children:n&&r.jsx("button",{className:S(It,"messaging-channel-view-back-button-mobile messaging-channel-view-back-button-desktop"),onClick:t||(()=>{}),type:"button","aria-label":"Back to conversations",children:r.jsx(M.ArrowLeftIcon,{className:"size-5 text-black/90"})})}),r.jsx("div",{className:"flex min-w-0 justify-center","data-dd-privacy":"mask",children:y?r.jsx("button",{type:"button",onClick:y,"aria-label":`View details for ${w}`,className:"group flex min-w-0 max-w-full appearance-none flex-col items-center border-0 bg-transparent px-2 focus-ring focus-visible:outline-none",children:z}):r.jsx("div",{className:"flex min-w-0 max-w-full flex-col items-center px-2",children:z})}),r.jsxs("div",{className:"flex items-start justify-end gap-2",children:[s&&r.jsx("button",{className:It,onClick:H,type:"button","aria-pressed":I,"aria-label":I?"Unstar conversation":"Star conversation",children:r.jsx(M.StarIcon,{className:S("size-5",{"text-[#FFD60A]":I,"text-black/90":!I}),weight:I?"fill":"regular"})}),v&&(d!==void 0?d:r.jsx(Lr,{channel:x,participant:b,showDeleteConversation:o,showBlockParticipant:l,showReportParticipant:c,onLeaveConversation:a,onBlockParticipant:i,onDeleteConversationClick:f,onBlockParticipantClick:m,onReportParticipantClick:u,customChannelActions:h,triggerClassName:It}))]})]})})},Pr=e=>r.jsx(N.DateSeparator,{...e,position:"center"}),on="vote_up",ln="vote_down";function Dr(e){return e!=null&&e.length?e.some(t=>t.type===ln)?"down":e.some(t=>t.type===on)?"up":null:null}function aa(e){const{channel:t}=N.useChannelStateContext(),{client:n}=N.useChatContext("useMessageVote"),s=g.useMemo(()=>Dr(e.own_reactions),[e.own_reactions]),a=g.useCallback(async()=>{if(n!=null&&n.userID)try{s==="up"?await t.deleteReaction(e.id,on):await t.sendReaction(e.id,{type:on},{enforce_unique:!0,skip_push:!0})}catch{}},[t,n==null?void 0:n.userID,e.id,s]),i=g.useCallback(async()=>{if(n!=null&&n.userID)try{s==="down"?await t.deleteReaction(e.id,ln):await t.sendReaction(e.id,{type:ln},{enforce_unique:!0,skip_push:!0})}catch{}},[t,n==null?void 0:n.userID,e.id,s]);return{selected:s,voteUp:a,voteDown:i}}function ra(e){return(e==null?void 0:e.trim().toLowerCase().split(/[-_]/)[0])||void 0}function Nn({message:e,viewerLanguage:t}){var a;const n=e==null?void 0:e.text,s=ra(t);return s?((a=e==null?void 0:e.i18n)==null?void 0:a[`${s}_text`])??n:n}const Or=["linktr.ee"],ps="messaging-attachment-v1_0";function Fr(e){try{return new URL(e).hostname.toLowerCase()}catch{return null}}function Br(e){return Or.some(t=>e===t||e.endsWith(`.${t}`))}function be(e){const t=e==null?void 0:e.trim();if(!t)return;const n=Fr(t);if(!n||!Br(n))return t;const s=new URL(t);return s.searchParams.get("io")==="true"&&s.searchParams.get("size")===ps?t:(s.searchParams.set("io","true"),s.searchParams.set("size",ps),s.toString())}const Ur=[[/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 ue(e){return e.startsWith("video/")?"video":e.startsWith("audio/")?"audio":e.startsWith("image/")?"image":"document"}function ia(e){const t=Ur.find(([n])=>n.test(e));return t?t[1]:"generic"}const Hr={video:M.VideoCameraIcon,audio:M.SpeakerHighIcon,image:M.ImageIcon,document:M.FileIcon},Vr={pdf:M.FilePdfIcon,doc:M.FileDocIcon,xls:M.FileXlsIcon,csv:M.FileCsvIcon,ppt:M.FilePptIcon,zip:M.FileZipIcon,text:M.FileTextIcon,markdown:M.FileMdIcon,generic:M.FileIcon};function Gr(e){const t=ue(e);return t!=="document"?Hr[t]:Vr[ia(e)]}function Ne(e,t){return g.createElement(Gr(e),t)}const qr=e=>{var t,n;return"touches"in e?((t=e.touches[0])==null?void 0:t.clientX)??((n=e.changedTouches[0])==null?void 0:n.clientX)??0:e.clientX},Yr=({source:e,mimeType:t,poster:n,autoPlay:s=!1,playing:a,loop:i=!1,controls:o=!0,showProgress:l=!1,muted:c=!1,onContainerClick:f})=>{const m=ue(t),u=g.useRef(null),h=g.useRef(null),d=g.useRef(null),v=g.useRef(a),[y,x]=g.useState(s),[p,b]=g.useState(0),[w,C]=g.useState(!1),[I,F]=g.useState(!1),[P,B]=g.useState(!1),[H,z]=g.useState(!1),[E,D]=g.useState(!0),[T,R]=g.useState(null),A=g.useCallback(()=>{B(!1),x(!0)},[]),$=g.useCallback(k=>{const O=h.current;if(!O)return 0;const X=O.getBoundingClientRect();return Math.max(0,Math.min(1,(qr(k)-X.left)/X.width))},[]),V=g.useCallback(k=>{const O=u.current;O&&O.duration&&(O.currentTime=k*O.duration)},[]),q=k=>{k.stopPropagation(),C(!0);const O=$(k);b(O),V(O)};g.useEffect(()=>{a!==void 0&&a!==v.current&&(v.current=a,x(a))},[a]),g.useEffect(()=>{if(!y){d.current!==null&&(cancelAnimationFrame(d.current),d.current=null);return}const k=()=>{const O=u.current;O&&O.duration&&!w&&b(O.currentTime/O.duration),d.current=requestAnimationFrame(k)};return d.current=requestAnimationFrame(k),()=>{d.current!==null&&cancelAnimationFrame(d.current)}},[y,w]),g.useEffect(()=>{const k=u.current;k&&(y?k.play().catch(O=>{x(!1),B(!0)}):k.pause())},[y]),g.useEffect(()=>{if(!w)return;const k=X=>b($(X)),O=X=>{C(!1),V($(X))};return window.addEventListener("mousemove",k),window.addEventListener("mouseup",O),window.addEventListener("touchmove",k,{passive:!0}),window.addEventListener("touchend",O),()=>{window.removeEventListener("mousemove",k),window.removeEventListener("mouseup",O),window.removeEventListener("touchmove",k),window.removeEventListener("touchend",O)}},[w,$,V]);const W=T?{aspectRatio:String(T)}:void 0,ae=T?"":" aspect-video",Q=Math.round(p*100);return r.jsxs("div",{role:"button",tabIndex:0,className:`relative cursor-pointer overflow-hidden bg-black ${ae}`,style:W,onClick:k=>{if(f){f(k);return}P||o&&x(O=>!O)},onKeyDown:k=>{if(!(k.key!=="Enter"&&k.key!==" ")){if(k.preventDefault(),f){f(k);return}P||o&&x(O=>!O)}},children:[n&&(m==="audio"||E)&&r.jsx("img",{src:n,alt:"",className:"absolute inset-0 h-full w-full object-cover"}),!n&&(m==="audio"||E)&&r.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:Ne(t,{className:"size-12 text-black/20",weight:"regular"})}),r.jsx("div",{className:"absolute inset-0",children:m==="audio"?r.jsx("audio",{ref:u,src:e,loop:i,muted:c,style:{width:"100%",height:"100%"},onLoadStart:()=>z(!0),onCanPlay:()=>{z(!1),D(!1)},onWaiting:()=>z(!0),onPlay:()=>B(!1),onEnded:()=>{i||(x(!1),b(0))},children:r.jsx("track",{kind:"captions"})}):r.jsx("video",{ref:u,src:e,loop:i,muted:c,playsInline:!0,style:{width:"100%",height:"100%"},onLoadStart:()=>z(!0),onCanPlay:()=>{z(!1),D(!1)},onWaiting:()=>z(!0),onPlay:()=>B(!1),onLoadedMetadata:()=>{const k=u.current;k instanceof HTMLVideoElement&&k.videoWidth&&k.videoHeight&&R(k.videoWidth/k.videoHeight)},onEnded:()=>{i||(x(!1),b(0))},children:r.jsx("track",{kind:"captions"})})}),H&&!P&&r.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center",children:r.jsx(M.CircleNotchIcon,{className:"size-8 animate-spin text-white/80",weight:"bold"})}),P&&!o&&r.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:k=>{k.stopPropagation(),A()},onKeyDown:k=>{k.key!=="Enter"&&k.key!==" "||(k.preventDefault(),k.stopPropagation(),A())},children:r.jsx("span",{className:"flex size-16 items-center justify-center rounded-full bg-white/20 text-white backdrop-blur-sm",children:r.jsx(M.PlayIcon,{className:"size-9 translate-x-0.5",weight:"fill"})})}),l&&!o&&r.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:r.jsx("div",{role:"slider","aria-label":"Playback position","aria-valuenow":Q,"aria-valuemin":0,"aria-valuemax":100,tabIndex:0,ref:h,className:"relative flex h-4 w-full cursor-pointer items-center",onMouseDown:q,onTouchStart:q,onClick:k=>k.stopPropagation(),onKeyDown:k=>{k.key==="ArrowRight"&&V(Math.min(1,p+.05)),k.key==="ArrowLeft"&&V(Math.max(0,p-.05))},children:r.jsx("div",{className:"w-full overflow-hidden rounded-full bg-white/30 h-1",children:r.jsx("div",{className:"h-full rounded-full bg-white",style:{width:`${Q}%`}})})})}),o&&r.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:[r.jsx("button",{type:"button",onClick:k=>{k.stopPropagation(),x(O=>!O)},className:"shrink-0 text-white","aria-label":y?"Pause":"Play",children:y?r.jsx(M.PauseIcon,{className:"size-5",weight:"fill"}):r.jsx(M.PlayIcon,{className:"size-5 translate-x-px",weight:"fill"})}),r.jsxs("div",{role:"slider","aria-label":"Playback position","aria-valuenow":Q,"aria-valuemin":0,"aria-valuemax":100,tabIndex:0,ref:h,className:"relative flex h-4 w-full cursor-pointer items-center",onMouseDown:q,onTouchStart:q,onClick:k=>k.stopPropagation(),onMouseEnter:()=>F(!0),onMouseLeave:()=>F(!1),onKeyDown:k=>{k.key==="ArrowRight"&&V(Math.min(1,p+.05)),k.key==="ArrowLeft"&&V(Math.max(0,p-.05))},children:[r.jsx("div",{className:`w-full overflow-hidden rounded-full bg-white/30 transition-all duration-200 ${I||w?"h-1.5":"h-1"}`,children:r.jsx("div",{className:"h-full rounded-full bg-white",style:{width:`${Q}%`}})}),r.jsx("div",{className:`absolute size-3 -translate-x-1/2 rounded-full bg-white shadow transition-[opacity,transform] duration-200 ${I||w?"scale-100 opacity-100":"scale-0 opacity-0"}`,style:{left:`${Q}%`}})]})]})]})},bs=e=>e==="dark"?"size-12 text-white/20":"size-12 text-black/20",Xr=e=>e==="dark"?"aspect-video overflow-hidden bg-white/10":"aspect-video overflow-hidden bg-black/5",kn=({mimeType:e,sourceUrl:t,thumbnailUrl:n,title:s,variant:a,mediaPlayerProps:i,containedImage:o=!1})=>{const l=ue(e),[c,f]=g.useState(!1),m=be(t),u=be(n);return t&&(l==="video"||l==="audio")?r.jsx(Yr,{source:t,mimeType:e,poster:u,controls:!0,...i}):t&&l==="image"?o?r.jsx("div",{className:"relative aspect-video overflow-hidden bg-black/5",children:r.jsx("img",{src:m??t,alt:s??"",className:`absolute inset-0 h-full w-full object-contain transition-opacity duration-300 ${c?"opacity-100":"opacity-0"}`,draggable:!1,onLoad:()=>f(!0)})}):r.jsx("img",{src:m??t,alt:s??"",className:"block w-full",draggable:!1}):t&&l==="document"?n?o?r.jsx("div",{className:"relative aspect-video overflow-hidden bg-black/5",children:r.jsx("img",{src:u??n,alt:s??"",className:`absolute inset-0 h-full w-full object-contain transition-opacity duration-300 ${c?"opacity-100":"opacity-0"}`,draggable:!1,onLoad:()=>f(!0)})}):r.jsx("img",{src:u??n,alt:"",className:"block w-full",draggable:!1}):r.jsx("div",{className:`flex aspect-video w-full items-center justify-center ${a==="dark"?"bg-white/10":"bg-black/5"}`,children:Ne(e,{className:bs(a),weight:"regular"})}):n?r.jsx("div",{className:`relative ${Xr(a)}`,children:r.jsx("img",{src:u??n,alt:s??"",draggable:!1,className:"absolute inset-0 h-full w-full object-cover"})}):r.jsx("div",{className:`flex aspect-video w-full items-center justify-center ${a==="dark"?"bg-white/10":"bg-black/5"}`,children:Ne(e,{className:bs(a),weight:"regular"})})},oa=({variant:e,thumbnail:t,title:n,placeholderTitle:s="Attachment title",mimeType:a,detail:i,statusBadge:o,action:l,topLeft:c,topRight:f,rootRef:m,"data-testid":u})=>{const h=e==="dark",d=h?n??s:n??"",v=h&&!n;return r.jsxs("div",{ref:m,"data-testid":u,className:S("relative w-[280px] select-none overflow-hidden rounded-[24px] shadow-[0_0_0_1px_rgba(0,0,0,0.04),0_4px_8px_rgba(0,0,0,0.06)]",h?"bg-[#1e2330]":"bg-white"),children:[c?r.jsx("div",{className:"pointer-events-auto absolute left-3 top-3 z-50",children:c}):null,f?r.jsx("div",{className:"pointer-events-auto absolute right-3 top-3 z-50",children:f}):null,t,r.jsxs("div",{className:"px-4 pb-3 pt-3",children:[d.trim()!==""&&r.jsx("p",{className:S("mb-0.5 truncate text-base font-medium",{"text-black":!h,"text-white/30":h&&v,"text-white":h&&!v}),children:d}),r.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[Ne(a,{className:S("size-5 shrink-0",h?"text-white/55":"text-black/55"),weight:"regular"}),i!=null&&i!==""&&r.jsx("span",{className:S("text-xs font-medium",h?"text-white/55":"text-black/55"),children:i}),o]}),l]})]})};function la(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function Mn(e){return`w-[280px] select-none overflow-hidden rounded-[24px] ${e?"bg-[#1e2330]":"bg-[#F3F3F1]"} shadow-[0_0_0_1px_rgba(0,0,0,0.04),0_4px_8px_rgba(0,0,0,0.06)]`}function Wr(e){return e?"bg-white/10":"bg-black/5"}function Zr(e){return e?"text-white":"text-black"}function Kr(e){return e?"text-white/55":"text-black/55"}function Jr(e){return e?"text-white/40":"text-black/40"}function Qr(e){return e?"text-white/20":"text-black/20"}const Cn=({attachment:e,isMyMessage:t})=>{const{title:n,text:s,image_url:a,og_scrape_url:i,title_link:o}=e,l=i??o,c=typeof l=="string"&&l.trim()!==""?l:void 0,f=r.jsxs(g.Fragment,{children:[r.jsx("div",{className:"p-2",children:a?r.jsx("img",{src:be(a)??a,alt:n??"",className:"aspect-video w-full rounded-[20px] object-cover"}):r.jsx("div",{className:`aspect-video w-full rounded-[20px] ${Wr(t)} flex items-center justify-center`,children:r.jsx(M.LinkIcon,{className:`size-12 ${Qr(t)}`})})}),r.jsxs("div",{className:"px-3 pb-3",children:[n&&r.jsx("p",{className:`truncate text-[14px] font-medium leading-5 ${Zr(t)}`,children:n}),s&&r.jsx("p",{className:`truncate text-[12px] leading-4 ${Kr(t)}`,children:s}),c&&r.jsx("p",{className:`mt-1 truncate text-[12px] leading-4 ${Jr(t)}`,children:c})]})]});return c?r.jsx("a",{href:c,target:"_blank",rel:"noopener noreferrer",className:"block no-underline",children:f}):r.jsx("div",{className:"block",children:f})};function Sn(e){return e.type==="link"||!!e.og_scrape_url&&!e.asset_url}function gt(e){var t;return(t=e.attachments)==null?void 0:t.find(Sn)}async function ei(e,t){let n;try{n=t??new URL(e).pathname.split("/").pop()??"download"}catch{n=t??"download"}const s=await fetch(e,{mode:"cors"});if(!s.ok)throw new Error(`HTTP ${s.status}`);const a=await s.blob(),i=URL.createObjectURL(a),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 ti=({url:e,filename:t})=>{const[n,s]=g.useState(!1),a=i=>{i.stopPropagation();const o=window.open("","_blank","noopener,noreferrer");s(!0),ei(e,t).then(()=>{o==null||o.close()}).catch(()=>{o&&(o.location.href=e)}).finally(()=>s(!1))};return r.jsx("button",{type:"button",onClick:a,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?r.jsx(M.CircleNotchIcon,{className:"size-4 animate-spin text-white",weight:"bold"}):r.jsxs(g.Fragment,{children:[r.jsx(M.DownloadSimpleIcon,{className:"size-4 text-white",weight:"bold"}),"Download"]})})};function xt(e){var u,h,d,v;const t=(u=e.attachments)==null?void 0:u.find(y=>y.type==="video"&&y.asset_url),n=(h=e.attachments)==null?void 0:h.find(y=>y.type==="image"&&y.image_url),s=(d=e.attachments)==null?void 0:d.find(y=>y.type==="audio"&&y.asset_url),a=(v=e.attachments)==null?void 0:v.find(y=>y.type==="file"&&y.asset_url),i=t??n??s??a,o=(t==null?void 0:t.asset_url)??(n==null?void 0:n.image_url)??(s==null?void 0:s.asset_url)??(a==null?void 0:a.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"),c=i==null?void 0:i.title,f=i==null?void 0:i.file_size,m=t==null?void 0:t.thumb_url;return{resolvedUrl:o,resolvedType:l,title:c,fileSize:f,thumbnailUrl:m}}const ca=({resolvedUrl:e,resolvedType:t,title:n,fileSize:s,thumbnailUrl:a})=>{const i=s!==void 0?la(s):void 0;return r.jsx(oa,{variant:"dark",title:n,placeholderTitle:"",mimeType:t,detail:i,thumbnail:r.jsx(kn,{mimeType:t,sourceUrl:e,thumbnailUrl:a,title:n,variant:"dark"})})},da=({resolvedUrl:e,resolvedType:t,title:n,fileSize:s,thumbnailUrl:a})=>{const i=ue(t),o=s!==void 0?la(s):void 0;return r.jsx(oa,{variant:"light",title:n,mimeType:t,detail:o,thumbnail:r.jsx(kn,{mimeType:t,sourceUrl:e,thumbnailUrl:a,title:n,variant:"light",containedImage:i==="image"||i==="document"}),action:r.jsx(ti,{url:e,filename:n})})},ni=({message:e,isMyMessage:t=!1})=>{const n=gt(e),s=xt(e);if(!n&&!s)return null;const a=t?"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 r.jsxs("div",{className:a,"data-dd-privacy":"mask",children:[!t&&e.user&&r.jsx(ke,{className:"str-chat__avatar str-chat__message-sender-avatar",id:e.user.id,image:e.user.image,name:e.user.name??e.user.id}),r.jsx("div",{className:"str-chat__message-inner",style:{marginInlineEnd:0,marginInlineStart:0},children:r.jsx("div",{className:"str-chat__message-bubble-wrapper",children:r.jsx("div",{className:"str-chat__message-bubble","data-attachment-bubble":"true",style:{padding:0,borderRadius:0,overflow:"visible",background:"transparent"},children:n?r.jsx("div",{className:Mn(t),children:r.jsx(Cn,{attachment:n,isMyMessage:t})}):t?r.jsx(ca,{...s}):r.jsx(da,{...s})})})})]})},si=({message:e})=>{const t=gt(e);if(t)return r.jsx("div",{className:Mn(!0),"data-dd-privacy":"mask",children:r.jsx(Cn,{attachment:t,isMyMessage:!0})});const n=xt(e);return n?r.jsx("div",{style:{display:"contents"},"data-dd-privacy":"mask",children:r.jsx(ca,{...n})}):null},ai=({message:e})=>{const t=gt(e);if(t)return r.jsx("div",{className:Mn(!1),"data-dd-privacy":"mask",children:r.jsx(Cn,{attachment:t,isMyMessage:!1})});const n=xt(e);return n?r.jsx("div",{style:{display:"contents"},"data-dd-privacy":"mask",children:r.jsx(da,{...n})}):null},ri=Object.assign(ni,{Creator:si,Visitor:ai}),ii={dark:"bg-[#1e2330]",light:"bg-[#f2f1ef]"},oi={dark:"text-white",light:"text-[#000000]"},li={dark:"border-white/[0.08]",light:"border-black/[0.08]"},ci=e=>e==="dark"?"sender":"receiver",di={sender:{single:"rounded-tl-[18px] rounded-tr-[18px] rounded-bl-[18px] rounded-br-[18px]",first:"rounded-tl-[18px] rounded-tr-[18px] rounded-bl-[18px] rounded-br-[4px]",middle:"rounded-tl-[18px] rounded-tr-[4px] rounded-bl-[18px] rounded-br-[4px]",end:"rounded-tl-[18px] rounded-tr-[4px] rounded-bl-[18px] rounded-br-[18px]"},receiver:{single:"rounded-tl-[18px] rounded-tr-[18px] rounded-bl-[18px] rounded-br-[18px]",first:"rounded-tl-[18px] rounded-tr-[18px] rounded-bl-[4px] rounded-br-[18px]",middle:"rounded-tl-[4px] rounded-tr-[18px] rounded-bl-[4px] rounded-br-[18px]",end:"rounded-tl-[4px] rounded-tr-[18px] rounded-bl-[18px] rounded-br-[18px]"}},He=({variant:e,text:t,bordered:n=!0,groupPosition:s="single",widthClassName:a="w-[280px]",paddingClassName:i="px-2 py-2",radiusClassName:o,className:l,children:c,"data-testid":f})=>{const m=t!=null&&t!=="",u=o??di[ci(e)][s];return r.jsxs("div",{"data-testid":f,"data-group-position":s,className:S("relative",a,"overflow-hidden",i,m&&"pb-0",u,ii[e],oi[e],n&&"border",n&&li[e],l),children:[c,m?r.jsx("p",{className:S("whitespace-pre-wrap break-words leading-snug","pb-2 pt-2","px-2"),children:t}):null]})},Ve=({onClick:e,variant:t="overlay",ariaLabel:n="Dismiss attachment"})=>r.jsx("button",{type:"button",onClick:s=>{s.stopPropagation(),e()},"aria-label":n,className:S("flex size-6 items-center justify-center rounded-full text-white",t==="overlay"?"bg-[#121110]/85 backdrop-blur":"bg-white/15 hover:bg-white/25"),children:r.jsx(M.XIcon,{className:"size-3",weight:"bold"})}),Ge=e=>e==="received"?"light":"dark",ua=({firstOfGroup:e,endOfGroup:t,groupedByUser:n})=>!n||e&&t?"single":e?"first":t?"end":"middle",ui=({src:e,mimeType:t,filename:n,items:s})=>s&&s.length>0?s:e?[{src:e,mimeType:t,filename:n}]:[],fi=({item:e,preload:t,trailingAction:n})=>r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("audio",{src:e.src,controls:!0,preload:e.preload??t,className:"block min-w-0 flex-1",children:e.mimeType?r.jsx("source",{src:e.src,type:e.mimeType}):null}),n??null]}),En=({state:e,src:t,mimeType:n,filename:s,items:a,text:i,groupPosition:o,preload:l,onDismiss:c})=>{const f=Ge(e),m=e==="composer"&&!!c,u=ui({src:t,mimeType:n,filename:s,items:a});if(u.length===0)return null;const h=l??(u.length>1?"none":"metadata");return r.jsx(He,{variant:f,text:i,groupPosition:o,"data-testid":"audio-attachment",children:r.jsx("div",{className:"flex flex-col gap-2",children:u.map((d,v)=>r.jsx(fi,{item:d,preload:h,trailingAction:m&&v===0?r.jsx(Ve,{onClick:c,variant:"inline"}):void 0},`${d.src}-${v}`))})})},mi=e=>r.jsx(En,{...e,state:"composer"}),hi=e=>r.jsx(En,{...e,state:"sent"}),gi=e=>r.jsx(En,{...e,state:"received"}),xi={Composer:mi,Sent:hi,Received:gi};function fa(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 pi={pdf:"PDF",doc:"DOC",xls:"XLS",csv:"CSV",ppt:"PPT",zip:"ZIP",text:"TXT",markdown:"MD"};function ma(e,t){if(t){const a=t.lastIndexOf(".");if(a>0&&a<t.length-1){const i=t.slice(a+1);if(i&&i.length<=5)return i.toUpperCase()}}if(!e)return;if(ue(e)==="document"){const a=ia(e),i=pi[a];if(i)return i;if(e==="application/octet-stream")return}const s=e.split("/")[1];if(!(!s||s==="*"))return s.toUpperCase()}function ha(e,t,n){const s=ma(e,t),a=typeof n=="number"&&n>0?fa(n):void 0;return[s,a].filter(Boolean).join(" · ")||void 0}function de(e){try{const n=new URL(e).pathname.split("/").pop();return n&&n.length>0?decodeURIComponent(n):"download"}catch{return"download"}}const bi={dark:"text-white/55",light:"text-black/65"},vi={dark:"bg-white/10",light:"bg-black/5"},yi={dark:"text-white/85",light:"text-black/85"},ga=({variant:e,filename:t,title:n,mimeType:s="application/octet-stream",fileSize:a,onActivate:i,activateLabel:o,trailingAction:l})=>{const c=n??t??"File",f=ha(s,t,a),m=r.jsx("div",{className:S("flex size-10 shrink-0 items-center justify-center rounded-sm",vi[e]),"aria-hidden":!0,children:Ne(s,{className:S("size-6",yi[e]),weight:"regular"})}),u=r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col text-left",children:[r.jsx("p",{className:"truncate font-medium leading-snug",children:c}),f?r.jsx("p",{className:S("truncate text-xs leading-4",bi[e]),children:f}):null]}),h=i?r.jsxs("button",{type:"button",onClick:i,"aria-label":o,className:S("flex min-w-0 flex-1 items-center gap-3 rounded-sm text-left transition-colors",e==="dark"?"hover:bg-white/[0.04]":"hover:bg-black/[0.04]"),children:[m,u]}):r.jsxs(r.Fragment,{children:[m,u]});return r.jsxs("div",{className:"flex items-center gap-3 px-3 py-2",children:[h,l?r.jsx("div",{className:"shrink-0",children:l}):null]})};async function xa(e,t){const n=t??de(e);try{const s=await fetch(e,{mode:"cors"});if(!s.ok)throw new Error(`HTTP ${s.status}`);const a=await s.blob(),i=URL.createObjectURL(a),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 a=document.createElement("a");a.href=e,a.download=n,a.target="_blank",a.rel="noopener noreferrer",a.style.display="none",document.body.appendChild(a),a.click(),document.body.removeChild(a)}}}const _i=({src:e,filename:t,fileSize:n,mimeType:s,title:a,items:i})=>i&&i.length>0?i:e?[{src:e,filename:t,fileSize:n,mimeType:s,title:a}]:[],wi=({variant:e,item:t,index:n,onActivate:s,trailingAction:a})=>{const i=t.filename??de(t.src);return r.jsx(ga,{variant:e,filename:i,title:t.title,mimeType:t.mimeType??"application/octet-stream",fileSize:t.fileSize,onActivate:()=>s(n),activateLabel:`Download ${i}`,trailingAction:a})},Tn=({state:e,src:t,filename:n,fileSize:s,mimeType:a,title:i,items:o,text:l,groupPosition:c,onClick:f,onDismiss:m})=>{const u=Ge(e),h=e==="composer"&&!!m,d=_i({src:t,filename:n,fileSize:s,mimeType:a,title:i,items:o}),v=x=>{if((f==null?void 0:f(x))===!1)return;const p=d[x];if(!p)return;const b=p.filename??de(p.src);xa(p.src,b)};if(d.length===0)return null;const y=r.jsx("span",{className:S("flex size-8 items-center justify-center rounded-full",u==="dark"?"text-white/70":"text-black/70"),"aria-hidden":!0,children:r.jsx(M.DownloadSimpleIcon,{className:"size-5",weight:"bold"})});return r.jsx(He,{variant:u,text:l,groupPosition:c,"data-testid":"file-attachment",children:r.jsx("div",{className:"flex flex-col gap-2",children:d.map((x,p)=>{const b=h&&p===0?r.jsx(Ve,{onClick:m,variant:"inline"}):y;return r.jsx(wi,{variant:u,item:x,index:p,onActivate:v,trailingAction:b},`${x.src}-${p}`)})})})},ji=e=>r.jsx(Tn,{...e,state:"composer"}),Ni=e=>r.jsx(Tn,{...e,state:"sent"}),ki=e=>r.jsx(Tn,{...e,state:"received"}),Mi={Composer:ji,Sent:Ni,Received:ki},In=({onPrev:e,onNext:t,prevLabel:n="Previous",nextLabel:s="Next"})=>r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button",onClick:e,"aria-label":n,className:"mes-media-viewer__nav mes-media-viewer__nav--prev",children:r.jsx(M.CaretLeftIcon,{size:20,weight:"bold","aria-hidden":!0})}),r.jsx("button",{type:"button",onClick:t,"aria-label":s,className:"mes-media-viewer__nav mes-media-viewer__nav--next",children:r.jsx(M.CaretRightIcon,{size:20,weight:"bold","aria-hidden":!0})})]}),pa=({url:e,filename:t,variant:n="pill",label:s="Download",iconOnly:a,tone:i="dark",onTriggered:o})=>{const[l,c]=g.useState(!1),f=g.useCallback(d=>{d.stopPropagation(),!l&&(c(!0),xa(e,t).catch(()=>{}).finally(()=>{c(!1),o==null||o()}))},[l,e,t,o]),m=a??n!=="pill",h={className:S(n==="pill"?"size-4":"size-5","shrink-0"),weight:"bold"};if(n==="inline"){const d={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 r.jsx("button",{type:"button",onClick:f,disabled:l,"aria-label":s,className:S("flex size-8 shrink-0 items-center justify-center rounded-full transition-colors disabled:opacity-70",d[i]),children:l?r.jsx(M.CircleNotchIcon,{className:"size-4 animate-spin",weight:"bold","aria-hidden":!0}):r.jsx(M.DownloadSimpleIcon,{className:"size-5 shrink-0",weight:"bold","aria-hidden":!0})})}return n==="viewer"?r.jsx("button",{type:"button",onClick:f,disabled:l,"aria-label":s,className:"mes-media-viewer__action",children:l?r.jsx(M.CircleNotchIcon,{size:20,weight:"bold","aria-hidden":!0}):r.jsx(M.DownloadSimpleIcon,{size:20,weight:"bold","aria-hidden":!0})}):r.jsxs("button",{type:"button",onClick:f,disabled:l,"aria-label":m?s:void 0,className:S("mt-3 inline-flex h-10 w-full items-center justify-center gap-2 rounded-full px-4 text-sm font-medium leading-none transition-colors disabled:opacity-70",i==="dark"?"bg-[#121110] text-white hover:bg-[#2a2928]":"bg-white text-[#121110] hover:bg-white/90"),children:[l?r.jsx(M.CircleNotchIcon,{className:"size-4 animate-spin",weight:"bold","aria-hidden":!0}):r.jsx(M.DownloadSimpleIcon,{...h,"aria-hidden":!0}),m?null:s]})},Rt=(e,t,n)=>Math.min(Math.max(e,t),n),Rn=({length:e,initialIndex:t,open:n})=>{const s=Rt(t,0,Math.max(e-1,0)),[a,i]=g.useState(s);g.useEffect(()=>{n&&i(Rt(t,0,Math.max(e-1,0)))},[n,t,e]),g.useEffect(()=>{i(c=>Rt(c,0,Math.max(e-1,0)))},[e]);const o=g.useCallback(()=>{e<=1||i(c=>c<=0?e-1:c-1)},[e]),l=g.useCallback(()=>{e<=1||i(c=>c>=e-1?0:c+1)},[e]);return g.useEffect(()=>{if(!n||e<=1)return;const c=f=>{if(f.key!=="ArrowLeft"&&f.key!=="ArrowRight")return;const m=document.activeElement;m&&(m.tagName==="VIDEO"||m.tagName==="AUDIO")||(f.preventDefault(),f.key==="ArrowLeft"?o():l())};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[n,e,o,l]),{index:a,prev:o,next:l}},Ln=({open:e,onClose:t,ariaLabel:n,counter:s,actions:a,children:i,"data-testid":o})=>{const l=g.useRef(null),c=g.useRef(null);g.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 d=typeof document<"u"?document.activeElement:null;return(h=c.current)==null||h.focus(),()=>{if(u.open)if(typeof u.close=="function")try{u.close()}catch{u.removeAttribute("open")}else u.removeAttribute("open");d&&document.body.contains(d)&&d.focus()}}if(u.open)if(typeof u.close=="function")try{u.close()}catch{u.removeAttribute("open")}else u.removeAttribute("open")}},[e]);const f=()=>{t()},m=u=>{u.target===l.current&&t()};return r.jsxs("dialog",{ref:l,className:"mes-media-viewer","aria-label":n??"Attachment viewer","data-testid":o,onClose:f,onClick:m,children:[r.jsxs("div",{className:"mes-media-viewer__chrome",children:[s?r.jsx("span",{className:"mes-media-viewer__counter",children:s}):null,r.jsxs("div",{className:"mes-media-viewer__actions",children:[a,r.jsx("button",{ref:c,type:"button",onClick:t,"aria-label":"Close viewer",className:"mes-media-viewer__action",children:r.jsx(M.XIcon,{size:20,weight:"bold","aria-hidden":!0})})]})]}),r.jsx("div",{className:"mes-media-viewer__body",children:i})]})},ba=({open:e,items:t,initialIndex:n=0,onClose:s})=>{const{index:a,prev:i,next:o}=Rn({length:t.length,initialIndex:n,open:e}),l=t[a],c=g.useMemo(()=>(l==null?void 0:l.filename)??(l?de(l.src):"image"),[l]);return l?r.jsxs(Ln,{open:e,onClose:s,ariaLabel:c,counter:t.length>1?`${a+1} / ${t.length}`:void 0,actions:r.jsx(pa,{url:l.src,filename:c,variant:"viewer",label:`Download ${c}`}),"data-testid":"image-viewer",children:[e?r.jsx("img",{src:l.src,alt:l.alt??c,draggable:!1,loading:"eager",decoding:"async",className:"mes-media-viewer__image"},`${a}:${l.src}`):null,t.length>1?r.jsx(In,{onPrev:i,onNext:o,prevLabel:"Previous image",nextLabel:"Next image"}):null]}):null},Ci="relative block size-full overflow-hidden bg-black/5 outline-none after:pointer-events-none after:absolute after:inset-0 after:rounded-[inherit] focus-visible:after:ring-2 focus-visible:after:ring-inset focus-visible:after:ring-white/80 focus-visible:after:ring-offset-2 focus-visible:after:ring-offset-black",Si={1:["rounded-[18px]"],2:["rounded-l-[18px]","rounded-r-[18px]"],3:["rounded-l-[18px]","rounded-tr-[18px]","rounded-br-[18px]"],4:["rounded-tl-[18px]","rounded-tr-[18px]","rounded-bl-[18px]","rounded-br-[18px]"]},Ei="--mes-single-width-cap",Ti="[--mes-single-width-cap:309px] sm:[--mes-single-width-cap:326px]",Ii=436,va=({tiles:e,onTileActivate:t,maxVisible:n=4,singleAspectRatio:s,className:a})=>{const i=e.length;if(i===0)return null;const o=e.slice(0,Math.min(i,n)),l=i-o.length,c=(m,u,h)=>{var v;const d=S(Ci,"h-full w-full",(v=Si[o.length])==null?void 0:v[u]);return t?r.jsxs("button",{type:"button",onClick:()=>t(u),"aria-label":m.ariaLabel??`Open media ${u+1}`,className:S(d,"cursor-zoom-in"),children:[m.content,h]},u):r.jsxs("div",{className:d,children:[m.content,h]},u)};let f;return s&&(f={aspectRatio:s,width:`min(var(${Ei}), ${Math.round(Ii*s*100)/100}px)`,maxWidth:"100%"}),o.length===1?r.jsx("div",{className:S(s?Ti:"aspect-square w-full",a),style:f,children:c(o[0],0)}):o.length===2?r.jsx("div",{className:S("grid aspect-[16/9] w-full grid-cols-2 gap-0.5",a),children:o.map((m,u)=>c(m,u))}):o.length===3?r.jsxs("div",{className:S("grid aspect-[4/3] w-full grid-cols-2 grid-rows-2 gap-0.5",a),children:[r.jsx("div",{className:"row-span-2",children:c(o[0],0)}),c(o[1],1),c(o[2],2)]}):r.jsx("div",{className:S("grid aspect-[379/286] w-full grid-cols-2 grid-rows-2 gap-0.5",a),children:o.map((m,u)=>{const h=l>0&&u===o.length-1;return c(m,u,h?r.jsxs("div",{className:"absolute inset-0 flex items-center justify-center bg-black/55 text-2xl font-semibold text-white",children:["+",l]}):null)})})},qe=e=>{const[t,n]=g.useState(!1),[s,a]=g.useState(0),i=g.useCallback(l=>{(e==null?void 0:e(l))!==!1&&(a(l),n(!0))},[e]),o=g.useCallback(()=>n(!1),[]);return{viewerOpen:t,viewerIndex:s,handleActivate:i,closeViewer:o}},Ri=({item:e,index:t,totalCount:n,fallbackLoading:s,imgRef:a,onLoad:i})=>({ariaLabel:`Open image ${t+1} of ${n}`,content:r.jsx("img",{ref:a,src:be(e.src)??e.src,alt:e.alt??"",width:e.width,height:e.height,draggable:!1,loading:e.loading??s,decoding:"async",onLoad:i,className:"absolute inset-0 size-full object-cover"})}),Li=({src:e,alt:t,items:n})=>n&&n.length>0?n:e?[{src:e,alt:t}]:[],ya=(e,t)=>e.map((n,s)=>({src:n.src,alt:n.alt,filename:t&&e.length===1?t:t?`${t} (${s+1})`:void 0})),Ai=({src:e,alt:t,filename:n,loading:s="lazy",onClick:a,onDismiss:i})=>{const{viewerOpen:o,viewerIndex:l,handleActivate:c,closeViewer:f}=qe(a);return r.jsxs("div",{className:"relative w-fit",children:[r.jsx("button",{type:"button",onClick:()=>c(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:r.jsx("img",{src:be(e)??e,alt:t??"",draggable:!1,loading:s,decoding:"async",className:"size-full object-cover"})}),i?r.jsx("div",{className:"absolute right-2 top-2 z-10",children:r.jsx(Ve,{onClick:i})}):null,r.jsx(ba,{open:o,items:ya([{src:e,alt:t}],n),initialIndex:l,onClose:f})]})},zi=326/246,$i=e=>{const t=e==null?void 0:e.src,[n,s]=g.useState(),a=g.useCallback(c=>{if(!c||c.naturalWidth<=0||c.naturalHeight<=0||t===void 0)return;const f=c.naturalWidth/c.naturalHeight;s(m=>m&&m.src===t&&m.ratio===f?m:{src:t,ratio:f})},[t]),i=g.useCallback(c=>a(c.currentTarget),[a]),o=e!=null&&e.width&&(e!=null&&e.height)?e.width/e.height:void 0,l=n&&n.src===t?n.ratio:void 0;return{ratio:o??l??zi,imgRef:a,onLoad:i}},_a=({state:e,src:t,alt:n,filename:s,items:a,text:i,groupPosition:o,loading:l="lazy",onClick:c})=>{const f=Li({src:t,alt:n,items:a}),m=Ge(e),{viewerOpen:u,viewerIndex:h,handleActivate:d,closeViewer:v}=qe(c),y=f.length===1,x=$i(y?f[0]:void 0);if(f.length===0)return null;const p=f.map((b,w)=>Ri({item:b,index:w,totalCount:f.length,fallbackLoading:l,imgRef:y?x.imgRef:void 0,onLoad:y?x.onLoad:void 0}));return r.jsxs(He,{variant:m,text:i,groupPosition:o,bordered:!1,widthClassName:y?"w-fit max-w-[313px] sm:max-w-[330px]":"w-[383px] max-w-full",paddingClassName:"p-0.5",radiusClassName:"rounded-[20px]","data-testid":"image-attachment",children:[r.jsx("div",{className:"relative",children:r.jsx(va,{tiles:p,onTileActivate:d,singleAspectRatio:y?x.ratio:void 0})}),r.jsx(ba,{open:u,items:ya(f,s),initialIndex:h,onClose:v})]})},Pi=e=>r.jsx(Ai,{...e}),Di=e=>r.jsx(_a,{...e,state:"sent"}),Oi=e=>r.jsx(_a,{...e,state:"received"}),Fi={Composer:Pi,Sent:Di,Received:Oi},Bi=({open:e,items:t,initialIndex:n=0,onClose:s})=>{const{index:a,prev:i,next:o}=Rn({length:t.length,initialIndex:n,open:e}),l=t[a],c=g.useMemo(()=>(l==null?void 0:l.filename)??(l?de(l.src):"document"),[l]),f=g.useMemo(()=>l?Ui(l.src):void 0,[l]);return!l||!f?null:r.jsxs(Ln,{open:e,onClose:s,ariaLabel:c,counter:t.length>1?`${a+1} / ${t.length}`:void 0,"data-testid":"pdf-viewer",children:[r.jsx("iframe",{src:f,title:c,className:"mes-media-viewer__iframe",sandbox:"allow-scripts allow-forms allow-popups allow-downloads"},`${a}:${l.src}`),t.length>1?r.jsx(In,{onPrev:i,onNext:o,prevLabel:"Previous document",nextLabel:"Next document"}):null]})},Ui=e=>{const t=e.indexOf("#"),n=t===-1?e:e.slice(0,t),s=t===-1?"":e.slice(t+1),a=new URLSearchParams(s);return a.has("toolbar")||a.set("toolbar","0"),a.has("navpanes")||a.set("navpanes","0"),`${n}#${a.toString()}`},Hi=({src:e,filename:t,fileSize:n,title:s,items:a})=>a&&a.length>0?a:e?[{src:e,filename:t,fileSize:n,title:s}]:[],Vi=({variant:e,item:t,index:n,onActivate:s,trailingAction:a})=>{const i=t.filename??de(t.src);return r.jsx(ga,{variant:e,filename:i,title:t.title,mimeType:"application/pdf",fileSize:t.fileSize,onActivate:()=>s(n),activateLabel:`Open ${i}`,trailingAction:a})},An=({state:e,src:t,filename:n,fileSize:s,title:a,items:i,text:o,groupPosition:l,onClick:c,onDismiss:f})=>{const m=Ge(e),u=Hi({src:t,filename:n,fileSize:s,title:a,items:i}),{viewerOpen:h,viewerIndex:d,handleActivate:v,closeViewer:y}=qe(c),x=e==="composer"&&!!f;if(u.length===0)return null;const p=u.map(b=>({src:b.src,filename:b.filename??de(b.src)}));return r.jsxs(He,{variant:m,text:o,groupPosition:l,"data-testid":"pdf-attachment",children:[r.jsx("div",{className:"flex flex-col gap-2",children:u.map((b,w)=>{const C=b.filename??de(b.src),I=x&&w===0?r.jsx(Ve,{onClick:f,variant:"inline"}):e==="composer"?void 0:r.jsx(pa,{url:b.src,filename:C,variant:"inline",label:`Download ${C}`,tone:m});return r.jsx(Vi,{variant:m,item:b,index:w,onActivate:v,trailingAction:I},`${b.src}-${w}`)})}),r.jsx(Bi,{open:h,items:p,initialIndex:d,onClose:y})]})},Gi=e=>r.jsx(An,{...e,state:"composer"}),qi=e=>r.jsx(An,{...e,state:"sent"}),Yi=e=>r.jsx(An,{...e,state:"received"}),Xi={Composer:Gi,Sent:qi,Received:Yi},wa=({open:e,items:t,initialIndex:n=0,onClose:s})=>{const{index:a,prev:i,next:o}=Rn({length:t.length,initialIndex:n,open:e}),l=t[a],c=g.useMemo(()=>(l==null?void 0:l.filename)??(l?de(l.src):"video"),[l]);return l?r.jsxs(Ln,{open:e,onClose:s,ariaLabel:c,counter:t.length>1?`${a+1} / ${t.length}`:void 0,"data-testid":"video-viewer",children:[r.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?r.jsx("source",{src:l.src,type:l.mimeType}):null},`${a}:${l.src}`),t.length>1?r.jsx(In,{onPrev:i,onNext:o,prevLabel:"Previous video",nextLabel:"Next video"}):null]}):null},Wi=()=>r.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center",children:r.jsx("span",{className:"flex size-12 items-center justify-center rounded-full bg-black/55 text-white backdrop-blur",children:r.jsx(M.PlayIcon,{className:"size-6",weight:"fill","aria-hidden":!0})})}),ja=({item:e,index:t})=>r.jsxs("div",{className:"absolute inset-0 size-full bg-[#0d0d0d]",children:[e.poster?r.jsx("img",{src:e.poster,alt:`Video ${t+1} thumbnail`,draggable:!1,loading:"lazy",decoding:"async",className:"absolute inset-0 size-full object-cover"}):r.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:r.jsx(M.VideoCameraIcon,{className:"size-16 text-white/30",weight:"regular","aria-hidden":!0})}),r.jsx(Wi,{})]}),Zi=(e,t,n)=>({ariaLabel:`Play video ${t+1} of ${n}`,content:r.jsx(ja,{item:e,index:t})}),Ki=({src:e,poster:t,mimeType:n,preload:s,items:a})=>a&&a.length>0?s?a.map(i=>({...i,preload:i.preload??s})):a:e?[{src:e,poster:t,mimeType:n,preload:s}]:[],Na=(e,t)=>e.map((n,s)=>({src:n.src,poster:n.poster,mimeType:n.mimeType,preload:n.preload,filename:t&&e.length===1?t:t?`${t} (${s+1})`:void 0})),Ji=({src:e,poster:t,mimeType:n,filename:s,preload:a,onClick:i,onDismiss:o})=>{const{viewerOpen:l,viewerIndex:c,handleActivate:f,closeViewer:m}=qe(i);return r.jsxs("div",{className:"relative w-fit",children:[r.jsx("button",{type:"button",onClick:()=>f(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:r.jsx(ja,{item:{src:e,poster:t,mimeType:n},index:0})}),o?r.jsx("div",{className:"absolute right-2 top-2 z-10",children:r.jsx(Ve,{onClick:o})}):null,r.jsx(wa,{open:l,items:Na([{src:e,poster:t,mimeType:n,preload:a}],s),initialIndex:c,onClose:m})]})},ka=({state:e,src:t,poster:n,mimeType:s,filename:a,items:i,text:o,groupPosition:l,preload:c,onClick:f})=>{const m=Ki({src:t,poster:n,mimeType:s,preload:c,items:i}),u=Ge(e),{viewerOpen:h,viewerIndex:d,handleActivate:v,closeViewer:y}=qe(f);if(m.length===0)return null;const x=m.map((p,b)=>Zi(p,b,m.length));return r.jsxs(He,{variant:u,text:o,groupPosition:l,"data-testid":"video-attachment",children:[r.jsx("div",{className:"relative",children:r.jsx(va,{tiles:x,onTileActivate:v})}),r.jsx(wa,{open:h,items:Na(m,a),initialIndex:d,onClose:y})]})},Qi=e=>r.jsx(Ji,{...e}),eo=e=>r.jsx(ka,{...e,state:"sent"}),to=e=>r.jsx(ka,{...e,state:"received"}),no={Composer:Qi,Sent:eo,Received:to},Re={Image:Fi,Video:no,Audio:xi,Pdf:Xi,File:Mi},so={isUnlocking:()=>!1},ao={LockedAttachment:so},Ma=g.createContext({}),ro=Ma.Provider;function Ca(e){return g.useContext(Ma)[e]??ao[e]}const io=g.lazy(()=>Promise.resolve().then(()=>require("./Card-415OfRhw.cjs"))),oo=g.lazy(()=>Promise.resolve().then(()=>require("./Card-B1Rliu1L.cjs"))),lo=()=>r.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}),Oe=e=>r.jsx(g.Suspense,{fallback:r.jsx(lo,{}),children:e.contentType==="text"?r.jsx(io,{...e}):r.jsx(oo,{...e})}),co=({size:e=15})=>r.jsx("svg",{width:e,height:e,viewBox:"0 0 15 15",fill:"none","aria-hidden":"true",children:r.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})}),uo=e=>{var t;return((t=e.metadata)==null?void 0:t.custom_type)===se.MESSAGE_CUSTOM_TYPE.TIP},Sa=e=>{var t;return((t=e.metadata)==null?void 0:t.custom_type)===se.MESSAGE_CUSTOM_TYPE.PAID},nt=e=>{var t;return((t=e.metadata)==null?void 0:t.custom_type)===se.MESSAGE_CUSTOM_TYPE.CHATBOT},zn=e=>{var t;return((t=e.metadata)==null?void 0:t.custom_type)===se.MESSAGE_CUSTOM_TYPE.ATTACHMENT},fo=e=>{var t;return zn(e)&&((t=e.metadata)==null?void 0:t.attachment_content_type)==="text"},mo=e=>{var t;return zn(e)&&((t=e.metadata)==null?void 0:t.attachment_content_type)!=="text"},Ea=e=>uo(e)||Sa(e),ho=e=>{var t;return Ea(e)&&!((t=e.text)!=null&&t.trim())},Lt=({message:e,standalone:t=!1,isMyMessage:n=!1,hasAttachment:s=!1})=>{var u;const a=Ea(e),i=nt(e);if(!a&&!i)return null;if(a){const h=(u=e.metadata)==null?void 0:u.amount_text;if(!h)return null;const d=t?"message-tip-standalone":"message-tag message-tag--tip",v=Sa(e)?"message":"tip",y=t?`${h} ${v}`:`Delivered with ${h} ${v}`;return r.jsxs("div",{className:d,children:[r.jsx(M.GiftIcon,{size:t?14:12}),r.jsx("span",{children:y})]})}const o=n&&s,l=o?"Sent with AI":"Sent by AI Assistant",c=["message-chatbot-indicator",n?"message-chatbot-indicator--sender":"message-chatbot-indicator--receiver",o?"message-chatbot-indicator--attachment":"message-chatbot-indicator--text"].join(" "),f=r.jsx("span",{className:"message-chatbot-indicator__label",children:l}),m=r.jsx("span",{className:"message-chatbot-indicator__icon",children:r.jsx(co,{size:o?12:15})});return r.jsx("div",{className:c,"data-testid":"message-chatbot-indicator",children:n&&!o?r.jsxs(r.Fragment,{children:[f,m]}):r.jsxs(r.Fragment,{children:[m,f]})})},Ta=({selected:e,onVoteUp:t,onVoteDown:n})=>r.jsxs("div",{className:"message-vote-buttons",children:[r.jsx("button",{type:"button",className:S("message-vote-button focus-ring",{"message-vote-button--selected":e==="up"}),onClick:t,"aria-label":"Good response","aria-pressed":e==="up","data-tooltip":"Good response",children:r.jsx(M.ThumbsUpIcon,{size:16,weight:e==="up"?"fill":"regular"})}),r.jsx("button",{type:"button",className:S("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:r.jsx(M.ThumbsDownIcon,{size:16,weight:e==="down"?"fill":"regular"})})]}),$n=()=>{const{message:e}=N.useMessageContext("SentMessageDeliveryStatus"),{messages:t}=N.useChannelStateContext("SentMessageDeliveryStatus"),n=(()=>{if(t)for(let s=t.length-1;s>=0;s-=1){const a=t[s];if(!(a.type==="system"||a.type==="ephemeral"||a.type==="deleted"))return a.id}})();return e.id===n},At=()=>$n()?r.jsxs(r.Fragment,{children:[r.jsx(M.ChecksIcon,{weight:"bold","aria-hidden":"true"}),r.jsx("span",{"data-testid":"sent-message-delivery-status",children:"Delivered"})]}):null,go=()=>$n()?r.jsxs(r.Fragment,{children:[r.jsx(M.CircleNotchIcon,{className:"sent-message-status__spinner animate-spin",weight:"bold","aria-hidden":"true"}),r.jsx("span",{"data-testid":"sent-message-sending-status",children:"Sending"})]}):null,xo=({broadcastId:e,broadcastName:t,onBroadcastClick:n})=>{const s=t||"Broadcast",a=r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"sent-message-broadcast-badge","aria-hidden":"true",children:r.jsx(M.MegaphoneIcon,{weight:"fill"})}),r.jsx("span",{className:"sent-message-broadcast-name","data-testid":"sent-message-broadcast-status",children:s})]});return n?r.jsx("button",{type:"button",className:"sent-message-broadcast-link","aria-label":`View broadcast ${s}`,onClick:()=>n({id:e,...t?{name:t}:{}}),children:a}):a},po=()=>r.jsxs("span",{className:"str-chat__message-status sent-message-status--failed",children:[r.jsx(M.WarningCircleIcon,{weight:"bold","aria-hidden":"true"}),r.jsx("span",{"data-testid":"sent-message-failed-status",children:"Failed to send"})]}),bo=({onBroadcastClick:e})=>{var m,u;const{isMyMessage:t,message:n,threadList:s}=N.useMessageContext("SentMessageDeliveryStatus"),a=t(),i=$n();if(s)return null;if(n.status==="failed"&&a&&n.type!=="error")return r.jsx(po,{});if(!a)return null;const o=(m=n.metadata)==null?void 0:m.broadcast_id,l=(u=n.metadata)==null?void 0:u.broadcast_name,c=n.status!=="sending"&&n.status!=="failed"&&o?r.jsx(xo,{broadcastId:o,broadcastName:l,onBroadcastClick:e}):null,f=r.jsx(N.MessageStatus,{MessageSentStatus:At,MessageDeliveredStatus:At,MessageReadStatus:At,MessageSendingStatus:go});return c?r.jsxs("span",{className:"sent-message-status-row",children:[f,i&&r.jsx("span",{className:"sent-message-broadcast-separator","aria-hidden":"true",children:"•"}),c]}):f},vo=/^([a-z][a-z0-9+.-]*):/i,yo=new Set(["http","https","mailto","tel","sms"]);function Pn(e){if(typeof e!="string")return;const t=e.trim();if(t==="")return;const n=vo.exec(t);if(n){const s=n[1].toLowerCase();return yo.has(s)?t:void 0}return t.startsWith("//")||t.startsWith("/")?t:`https://${t}`}const _o={dark:"bg-white text-[#121110] hover:bg-white/90",light:"bg-[#121110] text-white hover:bg-[#2a2928]"},wo=({variant:e,cta:t})=>{const n=S("mt-2 inline-flex h-10 w-full items-center justify-center rounded-full px-4 text-sm font-medium leading-none transition-colors",_o[e]),s=Pn(t.href);return s?r.jsx("a",{href:s,target:"_blank",rel:"noopener noreferrer",onClick:a=>{var i;a.stopPropagation(),(i=t.onClick)==null||i.call(t)},className:`${n} no-underline`,children:t.label}):r.jsx("button",{type:"button",onClick:a=>{var i;a.stopPropagation(),(i=t.onClick)==null||i.call(t)},className:n,children:t.label})},jo={dark:"text-white",light:"text-black/90"},No="text-white/30",ko={dark:"text-white/55",light:"text-black/55"},Mo={dark:"bg-white/25",light:"bg-black/15"},Dn=({variant:e,chinTextColor:t,title:n,placeholderTitle:s,description:a,url:i,appIcon:o,cta:l,trailingAction:c,isLoading:f=!1})=>{const m=e==="dark",u=n??(m?s:void 0)??"",h=u.trim()!=="",d=a!=null&&a.trim()!=="",v=typeof i=="string"?i.trim():"",y=v!=="",x=l!=null;if(!f&&!h&&!d&&!y&&!x)return null;const p=m&&!n,b=S("line-clamp-2 text-[14px] font-medium leading-5 tracking-[0.28px]",t==null&&(p?No:jo[e])),w=S("truncate text-[12px] leading-4 tracking-[0.24px]",t==null&&ko[e]);if(f){const I=S("animate-pulse rounded",Mo[e]);return r.jsx("div",{className:"shrink-0 px-4 py-3",children:r.jsxs("div",{className:"flex min-w-0 flex-col gap-[2px]",children:[r.jsx("div",{className:S("h-5 w-3/4",I),"aria-hidden":!0}),r.jsx("div",{className:S("h-4 w-1/2",I),"aria-hidden":!0})]})})}const C=t?{color:t}:void 0;return r.jsxs("div",{className:"shrink-0 px-4 py-3",children:[r.jsxs("div",{className:"flex items-end gap-3",children:[r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-[2px]",children:[h&&r.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[o?r.jsx("span",{className:"shrink-0",children:o}):null,r.jsx("p",{className:S("min-w-0",b),style:C,children:u})]}),d&&r.jsx("p",{className:w,style:C,children:a}),!x&&y&&r.jsx("p",{className:w,style:C,children:v})]}),c&&r.jsx("div",{className:"shrink-0",children:c})]}),l&&r.jsx(wo,{variant:e,cta:l})]})},Co="Loading link preview",So=S("relative w-[290px] select-none overflow-hidden","rounded-[20px]"),Eo="flex h-[250px] flex-col",st=({variant:e,children:t,href:n,onClick:s,ariaLabel:a,rootRef:i,topRight:o,bgClassName:l,accentStyle:c,fixedHeight:f=!1,busy:m=!1,"data-testid":u})=>{const h=n!=null||s!=null,d=S(So,f?Eo:"block",l??(e==="dark"?"bg-[#1e2330]":"bg-[#f1f0ee]"),h?"cursor-pointer no-underline focus-ring":null),v=m?{role:"status","aria-busy":!0,"aria-label":Co}:void 0,y=o?r.jsx("div",{className:"pointer-events-auto absolute right-3 top-3 z-10",children:o}):null;return n?r.jsxs("a",{ref:i,href:n,target:"_blank",rel:"noopener noreferrer",onClick:s,"data-testid":u,className:d,style:c,...v,children:[t,y]}):s?r.jsxs("button",{ref:i,type:"button",onClick:s,"aria-label":a,"data-testid":u,className:S(d,"text-left"),style:c,...v,children:[t,y]}):r.jsxs("div",{ref:i,"data-testid":u,className:d,style:c,...v,children:[t,y]})},vs={dark:"bg-white/10",light:"bg-black/5"},To={dark:"size-16 text-white/25",light:"size-16 text-black/25"},Ye=(e,t)=>!!t&&!!e&&ue(e)==="audio",On=(e,t)=>{if(!t||!e)return!1;const n=ue(e);return n==="video"||n==="audio"},Io="#F2F3F4",Fn="bg-[#F2F3F4]",at=({variant:e,thumbnailUrl:t,sourceUrl:n,title:s,mimeType:a="image/*",topLeft:i,topRight:o,isLoading:l=!1,onImageError:c})=>{const f=ue(a),m=!!n&&f==="video",u=be(t);return!l&&Ye(a,n)?r.jsx("div",{className:"p-3",children:r.jsx("audio",{src:n,controls:!0,preload:"metadata",className:"block w-full",children:r.jsx("track",{kind:"captions"})})}):r.jsxs("div",{className:S("relative min-h-0 w-full flex-1 overflow-hidden",m&&"bg-black"),children:[l?r.jsx("div",{className:S("h-full w-full animate-pulse",vs[e]),"aria-hidden":!0}):m?r.jsxs(r.Fragment,{children:[r.jsx("video",{src:n,poster:u,controls:!0,playsInline:!0,preload:"metadata",className:"absolute inset-0 h-full w-full object-contain",children:r.jsx("track",{kind:"captions"})}),u&&c?r.jsx("img",{src:u,alt:"","aria-hidden":!0,onError:c,className:"hidden"}):null]}):t?r.jsx("img",{src:u??t,alt:s??"",draggable:!1,loading:"lazy",decoding:"async",onError:c,className:"absolute inset-0 h-full w-full object-cover"}):r.jsx("div",{className:S("flex h-full w-full items-center justify-center",vs[e]),children:Ne(a,{className:To[e],weight:"regular"})}),i?r.jsx("div",{className:"pointer-events-auto absolute left-3 top-3 z-10",children:i}):null,o?r.jsx("div",{className:"pointer-events-auto absolute right-3 top-3 z-10",children:o}):null]})},Ia=(e,t)=>{if(typeof e=="number"){if(t===3)return{mode:"rgb",r:(e>>8&15|e>>4&240)/255,g:(e>>4&15|e&240)/255,b:(e&15|e<<4&240)/255};if(t===4)return{mode:"rgb",r:(e>>12&15|e>>8&240)/255,g:(e>>8&15|e>>4&240)/255,b:(e>>4&15|e&240)/255,alpha:(e&15|e<<4&240)/255};if(t===6)return{mode:"rgb",r:(e>>16&255)/255,g:(e>>8&255)/255,b:(e&255)/255};if(t===8)return{mode:"rgb",r:(e>>24&255)/255,g:(e>>16&255)/255,b:(e>>8&255)/255,alpha:(e&255)/255}}},Ro={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},Lo=e=>Ia(Ro[e.toLowerCase()],6),Ao=/^#?([0-9a-f]{8}|[0-9a-f]{6}|[0-9a-f]{4}|[0-9a-f]{3})$/i,zo=e=>{let t;return(t=e.match(Ao))?Ia(parseInt(t[1],16),t[1].length):void 0},pe="([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)",Be=`${pe}%`,Bn=`(?:${pe}%|${pe})`,$o=`(?:${pe}(deg|grad|rad|turn)|${pe})`,Ae="\\s*,\\s*",Po=new RegExp(`^rgba?\\(\\s*${pe}${Ae}${pe}${Ae}${pe}\\s*(?:,\\s*${Bn}\\s*)?\\)$`),Do=new RegExp(`^rgba?\\(\\s*${Be}${Ae}${Be}${Ae}${Be}\\s*(?:,\\s*${Bn}\\s*)?\\)$`),Oo=e=>{let t={mode:"rgb"},n;if(n=e.match(Po))n[1]!==void 0&&(t.r=n[1]/255),n[2]!==void 0&&(t.g=n[2]/255),n[3]!==void 0&&(t.b=n[3]/255);else if(n=e.match(Do))n[1]!==void 0&&(t.r=n[1]/100),n[2]!==void 0&&(t.g=n[2]/100),n[3]!==void 0&&(t.b=n[3]/100);else return;return n[4]!==void 0?t.alpha=Math.max(0,Math.min(1,n[4]/100)):n[5]!==void 0&&(t.alpha=Math.max(0,Math.min(1,+n[5]))),t},rt=(e,t)=>e===void 0?void 0:typeof e!="object"?Xo(e):e.mode!==void 0?e:t?{...e,mode:t}:void 0,ce=(e="rgb")=>t=>(t=rt(t,e))!==void 0?t.mode===e?t:le[t.mode][e]?le[t.mode][e](t):e==="rgb"?le[t.mode].rgb(t):le.rgb[e](le[t.mode].rgb(t)):void 0,le={},Ra={},it=[],La={},Fo=e=>e,G=e=>(le[e.mode]={...le[e.mode],...e.toMode},Object.keys(e.fromMode||{}).forEach(t=>{le[t]||(le[t]={}),le[t][e.mode]=e.fromMode[t]}),e.ranges||(e.ranges={}),e.difference||(e.difference={}),e.channels.forEach(t=>{if(e.ranges[t]===void 0&&(e.ranges[t]=[0,1]),!e.interpolate[t])throw new Error(`Missing interpolator for: ${t}`);typeof e.interpolate[t]=="function"&&(e.interpolate[t]={use:e.interpolate[t]}),e.interpolate[t].fixup||(e.interpolate[t].fixup=Fo)}),Ra[e.mode]=e,(e.parse||[]).forEach(t=>{Bo(t,e.mode)}),ce(e.mode)),pt=e=>Ra[e],Bo=(e,t)=>{if(typeof e=="string"){if(!t)throw new Error("'mode' required when 'parser' is a string");La[e]=t}else typeof e=="function"&&it.indexOf(e)<0&&it.push(e)},cn=/[^\x00-\x7F]|[a-zA-Z_]/,Uo=/[^\x00-\x7F]|[-\w]/,_={Function:"function",Ident:"ident",Number:"number",Percentage:"percentage",ParenClose:")",None:"none",Hue:"hue",Alpha:"alpha"};let L=0;function Qe(e){let t=e[L],n=e[L+1];return t==="-"||t==="+"?/\d/.test(n)||n==="."&&/\d/.test(e[L+2]):t==="."?/\d/.test(n):/\d/.test(t)}function dn(e){if(L>=e.length)return!1;let t=e[L];if(cn.test(t))return!0;if(t==="-"){if(e.length-L<2)return!1;let n=e[L+1];return!!(n==="-"||cn.test(n))}return!1}const Ho={deg:1,rad:180/Math.PI,grad:9/10,turn:360};function De(e){let t="";if((e[L]==="-"||e[L]==="+")&&(t+=e[L++]),t+=et(e),e[L]==="."&&/\d/.test(e[L+1])&&(t+=e[L++]+et(e)),(e[L]==="e"||e[L]==="E")&&((e[L+1]==="-"||e[L+1]==="+")&&/\d/.test(e[L+2])?t+=e[L++]+e[L++]+et(e):/\d/.test(e[L+1])&&(t+=e[L++]+et(e))),dn(e)){let n=ot(e);return n==="deg"||n==="rad"||n==="turn"||n==="grad"?{type:_.Hue,value:t*Ho[n]}:void 0}return e[L]==="%"?(L++,{type:_.Percentage,value:+t}):{type:_.Number,value:+t}}function et(e){let t="";for(;/\d/.test(e[L]);)t+=e[L++];return t}function ot(e){let t="";for(;L<e.length&&Uo.test(e[L]);)t+=e[L++];return t}function Vo(e){let t=ot(e);return e[L]==="("?(L++,{type:_.Function,value:t}):t==="none"?{type:_.None,value:void 0}:{type:_.Ident,value:t}}function Go(e=""){let t=e.trim(),n=[],s;for(L=0;L<t.length;){if(s=t[L++],s===`
|
|
1
|
+
"use strict";const r=require("react/jsx-runtime"),g=require("react"),kr=require("@linktr.ee/messaging-core"),tt=require("stream-chat"),N=require("stream-chat-react"),S=require("classnames"),M=require("@phosphor-icons/react"),se=require("@linktr.ee/messaging-taxonomy"),yn=require("stream-chat-react/experimental"),Qs=g.createContext({service:null,client:null,isConnected:!1,isLoading:!1,error:null,capabilities:{},refreshConnection:async()=>{},debug:!1}),_n=()=>g.useContext(Qs),Mr=({children:e,user:t,serviceConfig:n,apiKey:s,capabilities:a={},debug:i=!1,client:o})=>{var T,R;const l=g.useCallback((A,...$)=>{i&&console.log(`🔥 [MessagingProvider] ${A}`,...$)},[i]);l("🔄 RENDER START",{userId:t==null?void 0:t.id,apiKey:(s==null?void 0:s.substring(0,8))+"...",serviceConfig:!!n,capabilities:Object.keys(a)});const[c,f]=g.useState(null),[m,u]=g.useState(null),[h,d]=g.useState(!1),[v,y]=g.useState(!1),[x,p]=g.useState(null),b=g.useRef(!1),w=g.useRef(null),C=g.useRef(n);C.current=n;const I=g.useRef(i);I.current=i;const F=g.useRef({userId:t==null?void 0:t.id,apiKey:s,serviceConfig:n,capabilities:a}),P=g.useRef(0);P.current++,l("📊 RENDER INFO",{renderCount:P.current,currentProps:{userId:t==null?void 0:t.id,apiKey:(s==null?void 0:s.substring(0,8))+"..."},propChanges:{userChanged:F.current.userId!==(t==null?void 0:t.id),apiKeyChanged:F.current.apiKey!==s,serviceConfigChanged:F.current.serviceConfig!==n,capabilitiesChanged:F.current.capabilities!==a}}),F.current={userId:t==null?void 0:t.id,apiKey:s,serviceConfig:n,capabilities:a};const B=g.useRef(null);!o&&s&&((T=B.current)==null?void 0:T.apiKey)!==s&&(B.current={apiKey:s,client:new tt.StreamChat(s)});const H=o||(s?((R=B.current)==null?void 0:R.client)??null:null);g.useEffect(()=>{const A=P.current,$=C.current;if(o){w.current=null,f(null),u(null),d(!1),p(null),y(!1);return}if(!s||!H||!$){l("⚠️ SERVICE INIT SKIPPED",{renderCount:A,reason:"Missing apiKey, client, or serviceConfig"});return}l("🚀 CREATING SERVICE",{renderCount:A,apiKey:(s==null?void 0:s.substring(0,8))+"..."});const V=new kr.StreamChatService({...$,apiKey:s,debug:I.current,client:H});w.current=V,f(V),l("✅ SERVICE SET",{renderCount:A,serviceInstance:!!V})},[s,H,o]);const z=g.useRef(null);g.useEffect(()=>{var $,V;if(l("🔗 USER CONNECTION EFFECT TRIGGERED",{hasService:!!c,hasUser:!!t,userId:t==null?void 0:t.id,isConnecting:b.current,isConnected:h,dependencies:{service:!!c,userId:t==null?void 0:t.id}}),o)return;if(!c||!t){l("⚠️ USER CONNECTION SKIPPED","Missing service or user");return}if(b.current){l("⚠️ USER CONNECTION SKIPPED","Already connecting");return}if((($=z.current)==null?void 0:$.serviceId)===c&&((V=z.current)==null?void 0:V.userId)===t.id){l("⚠️ USER CONNECTION SKIPPED","Already connected this user with this service");return}(async()=>{l("🚀 STARTING USER CONNECTION",{userId:t.id}),b.current=!0,y(!0),p(null);try{l("📞 CALLING SERVICE.CONNECTUSER",{userId:t.id});const q=await c.connectUser(t);u(q),d(!0),z.current={serviceId:c,userId:t.id},l("✅ USER CONNECTION SUCCESS",{userId:t.id,clientId:q.userID})}catch(q){const W=q instanceof Error?q.message:"Connection failed";p(W),l("❌ USER CONNECTION ERROR",{userId:t.id,error:W})}finally{y(!1),b.current=!1,l("🔄 USER CONNECTION FINISHED",{userId:t.id,isConnected:h})}})()},[c,t,l,h,o]),g.useEffect(()=>{const A=H;return()=>{var $;A&&(z.current=null,($=w.current)==null||$.disconnectUser().catch(console.error))}},[H]);const E=g.useCallback(async()=>{if(l("🔄 REFRESH CONNECTION CALLED",{hasService:!!c,hasUser:!!t}),!o){if(!c||!t){l("⚠️ REFRESH CONNECTION SKIPPED","Missing service or user");return}l("🚀 STARTING CONNECTION REFRESH",{userId:t.id}),y(!0);try{l("🔌 DISCONNECTING FOR REFRESH"),await c.disconnectUser(),l("📞 RECONNECTING FOR REFRESH");const A=await c.connectUser(t);u(A),d(!0),p(null),l("✅ CONNECTION REFRESH SUCCESS",{userId:t.id})}catch(A){const $=A instanceof Error?A.message:"Refresh failed";p($),l("❌ CONNECTION REFRESH ERROR",{userId:t.id,error:$})}finally{y(!1),l("🔄 CONNECTION REFRESH FINISHED",{userId:t.id})}}},[c,t,l,o]),D=g.useMemo(()=>(l("💫 CONTEXT VALUE MEMOIZATION",{hasService:!!c,hasClient:!!m,isConnected:h,isLoading:v,hasError:!!x,capabilitiesKeys:Object.keys(a)}),{service:o?null:c,client:o??m,isConnected:o?!0:h,isLoading:o?!1:v,error:o?null:x,capabilities:a,refreshConnection:E,debug:i}),[c,m,o,h,v,x,a,E,i,l]);return l("🔄 RENDER END",{renderCount:P.current,willRenderChat:!!H,contextValueReady:!!D}),r.jsx(Qs.Provider,{value:D,children:H?r.jsx(N.Chat,{client:H,customClasses:{channelList:"str-chat__channel-list str-chat__channel-list-react bg-transparent lg:border-r-2 border-r-0 border-[#0000000A]"},children:e}):e})},ea=()=>_n(),ta=e=>{var s,a;const[t,n]=g.useState(!!((a=(s=e==null?void 0:e.state)==null?void 0:s.membership)!=null&&a.pinned_at));return g.useEffect(()=>{var o;if(!e){n(!1);return}n(!!((o=e.state.membership)!=null&&o.pinned_at));const i=l=>{var c;n(l!=null&&l.member?!!l.member.pinned_at:!!((c=e.state.membership)!=null&&c.pinned_at))};return e.on("member.updated",i),()=>{e.off("member.updated",i)}},[e]),t};function wn(e,t,n){const s=Object.values(e||{});if(se.isOfficialChannel(n)){const a=s.find(i=>{var o;return((o=i.user)==null?void 0:o.id)===se.OFFICIAL_SENDER_USER_ID});if(a)return a}return s.find(a=>{var i;return((i=a.user)==null?void 0:i.id)&&a.user.id!==t})}const Cr=/^[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 na(e){return Cr.test(e.trim())}function gs(e,t){const n=e==null?void 0:e.trim();return!n||t&&n===t||t&&n===`Follower ${t}`?!1:!na(n)}function jn(e){return gs(e==null?void 0:e.name,e==null?void 0:e.id)?e.name.trim():gs(e==null?void 0:e.username,e==null?void 0:e.id)?e.username.trim():"Unknown member"}const xs=[{emoji:"🍎",bgColor:"#FFD1DD"},{emoji:"🍌",bgColor:"#FFF1C9"},{emoji:"🍇",bgColor:"#E6D9FF"},{emoji:"🍊",bgColor:"#D6F4FF"},{emoji:"🍓",bgColor:"#FFE0AE"},{emoji:"🥥",bgColor:"#F7E7D8"},{emoji:"🍒",bgColor:"#DFF4D8"},{emoji:"🥭",bgColor:"#FFD8C2"},{emoji:"🍉",bgColor:"#D6EBFF"},{emoji:"🍋",bgColor:"#CAEEB5"},{emoji:"🥝",bgColor:"#FFE7C7"},{emoji:"🫒",bgColor:"#F6E3B4"},{emoji:"🍈",bgColor:"#D9F7E1"}];function Sr(e){let t=0;for(let n=0;n<e.length;n++){const s=e.charCodeAt(n);t=(t<<5)-t+s,t=t&t}return Math.abs(t)}function sa(e){return xs[Sr(e)%xs.length]}function Er(e){return sa(e).emoji}function Tr(e){return sa(e).bgColor}const ke=({id:e,image:t,size:n=40,className:s,starred:a=!1,shape:i="squircle",dmAgentEnabled:o=!1})=>{const l=Er(e),c=Tr(e),f=.45,u=n<32?Math.round(n*f):n<56?14:n<120?18:36,h=n>=40?2:1,d=i==="circle"?{borderRadius:"50%"}:{borderRadius:"1rem"},v=r.jsx("div",{className:"h-full w-full overflow-hidden",style:d,children:t?r.jsx("img",{src:t,alt:"",className:"h-full w-full object-cover"}):r.jsx("div",{"aria-hidden":"true",className:S("avatar-fallback flex h-full w-full items-center justify-center font-semibold select-none transition-colors"),style:{fontSize:u,lineHeight:1},children:l})});return r.jsxs("div",{className:S("relative flex-shrink-0",s),style:{"--str-chat__avatar-size":`${n}px`,width:`${n}px`,height:`${n}px`,backgroundColor:t?void 0:c,...d},children:[a&&r.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:r.jsx(M.StarIcon,{className:"size-3 text-yellow-600",weight:"duotone"})}),r.jsx("div",{"data-testid":"avatar-ring",className:S("h-full w-full","bg-transparent"),style:{...d,...o&&{borderWidth:`${h}px`,borderStyle:"solid",borderColor:"var(--AI-Gradient, #7F22FE)",boxShadow:"inset 0 1px 2px 0 rgba(255, 255, 255, 0.5)"}},children:v})]})},Ir="https://linktr.ee/s/about/trust-center/report",Rr=({channel:e,participant:t,showBlockParticipant:n=!0,enabled:s=!0,onLeaveConversation:a,onBlockParticipant:i,onDeleteConversationClick:o,onBlockParticipantClick:l,onReportParticipantClick:c,onActionComplete:f,logLabel:m="useChannelModerationActions"})=>{var D;const{service:u,debug:h}=_n(),d=(D=t==null?void 0:t.user)==null?void 0:D.id,v=!!(s&&n&&u&&d),[y,x]=g.useState(!1),[p,b]=g.useState(null),[w,C]=g.useState(!1),[I,F]=g.useState(!1),P=v&&((p==null?void 0:p.participantId)!==d||(p==null?void 0:p.service)!==u);return g.useEffect(()=>{if(!v||!u||!d){x(!1),b(null);return}let T=!1;return(async()=>{try{const R=await u.getBlockedUsers();if(T)return;x(R.some(A=>A.blocked_user_id===d))}catch(R){T||console.error(`[${m}] Failed to check blocked status:`,R)}finally{T||b({participantId:d,service:u})}})(),()=>{T=!0}},[v,u,d,m]),{isParticipantBlocked:y,isCheckingBlockedStatus:P,isLeaving:w,isUpdatingBlockStatus:I,handleLeaveConversation:async()=>{var T;if(!w){o==null||o(),h&&console.log(`[${m}] Leave conversation`,e.cid),C(!0);try{const R=((T=e._client)==null?void 0:T.userID)??null;await e.hide(R,!1),a&&await a(e),f==null||f()}catch(R){console.error(`[${m}] Failed to leave conversation`,R)}finally{C(!1)}}},handleBlockUser:async()=>{var T,R,A;if(!(I||!u)){l==null||l(),h&&console.log(`[${m}] Block member`,(T=t==null?void 0:t.user)==null?void 0:T.id),F(!0);try{await u.blockUser((R=t==null?void 0:t.user)==null?void 0:R.id),i&&await i((A=t==null?void 0:t.user)==null?void 0:A.id),f==null||f()}catch($){console.error(`[${m}] Failed to block member`,$)}finally{F(!1)}}},handleUnblockUser:async()=>{var T,R,A;if(!(I||!u)){l==null||l(),h&&console.log(`[${m}] Unblock member`,(T=t==null?void 0:t.user)==null?void 0:T.id),F(!0);try{await u.unBlockUser((R=t==null?void 0:t.user)==null?void 0:R.id),i&&await i((A=t==null?void 0:t.user)==null?void 0:A.id),f==null||f()}catch($){console.error(`[${m}] Failed to unblock member`,$)}finally{F(!1)}}},handleReportUser:()=>{c==null||c(),f==null||f(),window.open(Ir,"_blank","noopener,noreferrer")}}},Ie=({variant:e="default",className:t,children:n,...s})=>{const a=e==="danger";return r.jsx("button",{type:"button",className:S("flex w-full items-center gap-3 rounded-lg px-4 py-3 text-left text-sm transition-colors focus-ring disabled:cursor-not-allowed disabled:opacity-60",a?"text-danger hover:bg-danger/50":"text-charcoal hover:bg-sand",t),...s,children:n})},Lr=({channel:e,participant:t,showDeleteConversation:n=!0,showBlockParticipant:s=!0,showReportParticipant:a=!0,onLeaveConversation:i,onBlockParticipant:o,onDeleteConversationClick:l,onBlockParticipantClick:c,onReportParticipantClick:f,customChannelActions:m,triggerClassName:u})=>{const[h,d]=g.useState(!1),v=g.useRef(null),y=g.useId(),x=g.useCallback(()=>d(!1),[]),{isParticipantBlocked:p,isCheckingBlockedStatus:b,isLeaving:w,isUpdatingBlockStatus:C,handleLeaveConversation:I,handleBlockUser:F,handleUnblockUser:P,handleReportUser:B}=Rr({channel:e,participant:t,showBlockParticipant:s,enabled:h,onLeaveConversation:i,onBlockParticipant:o,onDeleteConversationClick:l,onBlockParticipantClick:c,onReportParticipantClick:f,onActionComplete:x,logLabel:"ChannelActionsMenu"});return g.useEffect(()=>{if(!h)return;const z=D=>{v.current&&!v.current.contains(D.target)&&d(!1)},E=D=>{D.key==="Escape"&&d(!1)};return document.addEventListener("mousedown",z),document.addEventListener("keydown",E),()=>{document.removeEventListener("mousedown",z),document.removeEventListener("keydown",E)}},[h]),!t||!(n||s||a||!!m)?null:r.jsxs("div",{ref:v,className:"relative",children:[r.jsxs("button",{className:u,type:"button","aria-haspopup":"true","aria-expanded":h,"aria-controls":h?y:void 0,onClick:()=>d(z=>!z),children:[r.jsx(M.DotsThreeIcon,{className:"size-5 text-black/90"}),r.jsx("span",{className:"sr-only",children:"More options"})]}),h&&r.jsx("div",{id:y,"aria-label":"Conversation options",className:S("absolute right-0 top-full z-50 mt-2 w-56 overflow-hidden","rounded-lg border border-sand bg-white p-1 shadow-max-elevation-light"),children:r.jsxs("ul",{className:"flex flex-col gap-1",children:[n&&r.jsx("li",{children:r.jsxs(Ie,{onClick:I,disabled:w,"aria-busy":w,children:[w?r.jsx(M.SpinnerGapIcon,{className:"h-5 w-5 animate-spin"}):r.jsx(M.SignOutIcon,{className:"h-5 w-5"}),r.jsx("span",{children:"Delete Conversation"})]})}),s&&r.jsx("li",{children:b?r.jsxs(Ie,{disabled:!0,"aria-busy":!0,children:[r.jsx(M.SpinnerGapIcon,{className:"h-5 w-5 animate-spin"}),r.jsx("span",{children:"Block"})]}):p?r.jsxs(Ie,{onClick:P,disabled:C,"aria-busy":C,children:[C?r.jsx(M.SpinnerGapIcon,{className:"h-5 w-5 animate-spin"}):r.jsx(M.ProhibitInsetIcon,{className:"h-5 w-5"}),r.jsx("span",{children:"Unblock"})]}):r.jsxs(Ie,{onClick:F,disabled:C,"aria-busy":C,children:[C?r.jsx(M.SpinnerGapIcon,{className:"h-5 w-5 animate-spin"}):r.jsx(M.ProhibitInsetIcon,{className:"h-5 w-5"}),r.jsx("span",{children:"Block"})]})}),a&&r.jsx("li",{children:r.jsxs(Ie,{variant:"danger",onClick:B,children:[r.jsx(M.FlagIcon,{className:"h-5 w-5"}),r.jsx("span",{children:"Report"})]})}),m]})})]})},It="flex size-10 flex-shrink-0 items-center justify-center rounded-full bg-white/65 shadow-[0px_4px_8px_0px_rgba(0,0,0,0.06),0px_0px_0px_1px_rgba(0,0,0,0.04)] backdrop-blur-[40px] transition-filter duration-150 hover:brightness-95 aria-expanded:brightness-95 focus-ring",Ar="CUSTOMER_PAID",zr=e=>typeof e=="string"&&e.trim().replace(/[\s-]+/g,"_").toUpperCase()===Ar,$r=({className:e,onBack:t,showBackButton:n,showStarButton:s=!1,onLeaveConversation:a,onBlockParticipant:i,showDeleteConversation:o=!0,showBlockParticipant:l=!0,showReportParticipant:c=!0,onDeleteConversationClick:f,onBlockParticipantClick:m,onReportParticipantClick:u,customChannelActions:h,renderChannelActions:d,showChannelInfo:v=!0,onParticipantNameClick:y})=>{var E,D,T,R;const{channel:x}=N.useChannelStateContext(),{client:p}=N.useChatContext(),b=g.useMemo(()=>{var A;return wn((A=x.state)==null?void 0:A.members,p==null?void 0:p.userID,x.type)},[(E=x.state)==null?void 0:E.members,p==null?void 0:p.userID,x.type]),w=jn(b==null?void 0:b.user),C=(D=b==null?void 0:b.user)==null?void 0:D.image,I=ta(x),F=zr((T=x.data)==null?void 0:T.customer_tag)&&(b==null?void 0:b.is_follower)===!0,P=s&&I,B=F||P||!!y,H=async()=>{try{I?await x.unpin():await x.pin()}catch(A){console.error("[ChannelHeaderRedesign] Failed to update pinned status:",A)}},z=r.jsxs(r.Fragment,{children:[r.jsx(ke,{id:((R=b==null?void 0:b.user)==null?void 0:R.id)||x.id||"unknown",name:w,image:C,shape:"circle",size:48,className:"-mb-2"}),r.jsx("span",{className:S("relative z-10 flex max-w-full flex-col items-center justify-center rounded-full border border-white/10 bg-white/65 py-1.5 shadow-[0px_0px_0px_0px_rgba(0,0,0,0.04),0px_1px_2px_0px_rgba(0,0,0,0.04),0px_8px_32px_0px_rgba(0,0,0,0.1)] backdrop-blur-[2px] transition-filter duration-150 group-hover:brightness-95",B?"pl-3 pr-2":"px-3"),children:r.jsxs("span",{className:"flex max-w-full items-center justify-center",children:[r.jsx("span",{className:"min-w-0 truncate text-sm font-bold leading-[1.43] tracking-[0.28px] text-black/90",children:w}),B&&r.jsxs("span",{className:"ml-2 flex gap-1",children:[F&&r.jsx("span",{"aria-label":"Paid customer",className:"flex size-4 shrink-0 items-center justify-center rounded-full bg-[#34C759] text-white",children:r.jsx(M.CurrencyDollarIcon,{className:"size-2.5",weight:"bold"})}),P&&r.jsx("span",{"aria-label":"Starred conversation",className:"flex size-4 shrink-0 items-center justify-center rounded-full bg-[#FFD60A] text-white",children:r.jsx(M.StarIcon,{className:"size-2.5",weight:"fill"})}),y&&r.jsx(M.CaretRightIcon,{"aria-hidden":"true",className:"size-4 shrink-0 text-black/65",weight:"bold"})]})]})})]});return r.jsx("div",{className:S("@container bg-[linear-gradient(180deg,#FBFAF9_0%,rgba(251,250,249,0.92)_58%,rgba(251,250,249,0)_100%)]",e),children:r.jsxs("div",{className:"grid min-h-[100px] grid-cols-[minmax(40px,1fr)_auto_minmax(40px,1fr)] items-start pb-2 pt-5 @lg:min-h-[104px] @lg:pt-6",children:[r.jsx("div",{className:"flex items-start",children:n&&r.jsx("button",{className:S(It,"messaging-channel-view-back-button-mobile messaging-channel-view-back-button-desktop"),onClick:t||(()=>{}),type:"button","aria-label":"Back to conversations",children:r.jsx(M.ArrowLeftIcon,{className:"size-5 text-black/90"})})}),r.jsx("div",{className:"flex min-w-0 justify-center","data-dd-privacy":"mask",children:y?r.jsx("button",{type:"button",onClick:y,"aria-label":`View details for ${w}`,className:"group flex min-w-0 max-w-full appearance-none flex-col items-center border-0 bg-transparent px-2 focus-ring focus-visible:outline-none",children:z}):r.jsx("div",{className:"flex min-w-0 max-w-full flex-col items-center px-2",children:z})}),r.jsxs("div",{className:"flex items-start justify-end gap-2",children:[s&&r.jsx("button",{className:It,onClick:H,type:"button","aria-pressed":I,"aria-label":I?"Unstar conversation":"Star conversation",children:r.jsx(M.StarIcon,{className:S("size-5",{"text-[#FFD60A]":I,"text-black/90":!I}),weight:I?"fill":"regular"})}),v&&(d!==void 0?d:r.jsx(Lr,{channel:x,participant:b,showDeleteConversation:o,showBlockParticipant:l,showReportParticipant:c,onLeaveConversation:a,onBlockParticipant:i,onDeleteConversationClick:f,onBlockParticipantClick:m,onReportParticipantClick:u,customChannelActions:h,triggerClassName:It}))]})]})})},Pr=e=>r.jsx(N.DateSeparator,{...e,position:"center"}),on="vote_up",ln="vote_down";function Dr(e){return e!=null&&e.length?e.some(t=>t.type===ln)?"down":e.some(t=>t.type===on)?"up":null:null}function aa(e){const{channel:t}=N.useChannelStateContext(),{client:n}=N.useChatContext("useMessageVote"),s=g.useMemo(()=>Dr(e.own_reactions),[e.own_reactions]),a=g.useCallback(async()=>{if(n!=null&&n.userID)try{s==="up"?await t.deleteReaction(e.id,on):await t.sendReaction(e.id,{type:on},{enforce_unique:!0,skip_push:!0})}catch{}},[t,n==null?void 0:n.userID,e.id,s]),i=g.useCallback(async()=>{if(n!=null&&n.userID)try{s==="down"?await t.deleteReaction(e.id,ln):await t.sendReaction(e.id,{type:ln},{enforce_unique:!0,skip_push:!0})}catch{}},[t,n==null?void 0:n.userID,e.id,s]);return{selected:s,voteUp:a,voteDown:i}}function ra(e){return(e==null?void 0:e.trim().toLowerCase().split(/[-_]/)[0])||void 0}function Nn({message:e,viewerLanguage:t}){var a;const n=e==null?void 0:e.text,s=ra(t);return s?((a=e==null?void 0:e.i18n)==null?void 0:a[`${s}_text`])??n:n}const Or=["linktr.ee"],ps="messaging-attachment-v1_0";function Fr(e){try{return new URL(e).hostname.toLowerCase()}catch{return null}}function Br(e){return Or.some(t=>e===t||e.endsWith(`.${t}`))}function be(e){const t=e==null?void 0:e.trim();if(!t)return;const n=Fr(t);if(!n||!Br(n))return t;const s=new URL(t);return s.searchParams.get("io")==="true"&&s.searchParams.get("size")===ps?t:(s.searchParams.set("io","true"),s.searchParams.set("size",ps),s.toString())}const Ur=[[/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 ue(e){return e.startsWith("video/")?"video":e.startsWith("audio/")?"audio":e.startsWith("image/")?"image":"document"}function ia(e){const t=Ur.find(([n])=>n.test(e));return t?t[1]:"generic"}const Hr={video:M.VideoCameraIcon,audio:M.SpeakerHighIcon,image:M.ImageIcon,document:M.FileIcon},Vr={pdf:M.FilePdfIcon,doc:M.FileDocIcon,xls:M.FileXlsIcon,csv:M.FileCsvIcon,ppt:M.FilePptIcon,zip:M.FileZipIcon,text:M.FileTextIcon,markdown:M.FileMdIcon,generic:M.FileIcon};function Gr(e){const t=ue(e);return t!=="document"?Hr[t]:Vr[ia(e)]}function Ne(e,t){return g.createElement(Gr(e),t)}const qr=e=>{var t,n;return"touches"in e?((t=e.touches[0])==null?void 0:t.clientX)??((n=e.changedTouches[0])==null?void 0:n.clientX)??0:e.clientX},Yr=({source:e,mimeType:t,poster:n,autoPlay:s=!1,playing:a,loop:i=!1,controls:o=!0,showProgress:l=!1,muted:c=!1,onContainerClick:f})=>{const m=ue(t),u=g.useRef(null),h=g.useRef(null),d=g.useRef(null),v=g.useRef(a),[y,x]=g.useState(s),[p,b]=g.useState(0),[w,C]=g.useState(!1),[I,F]=g.useState(!1),[P,B]=g.useState(!1),[H,z]=g.useState(!1),[E,D]=g.useState(!0),[T,R]=g.useState(null),A=g.useCallback(()=>{B(!1),x(!0)},[]),$=g.useCallback(k=>{const O=h.current;if(!O)return 0;const X=O.getBoundingClientRect();return Math.max(0,Math.min(1,(qr(k)-X.left)/X.width))},[]),V=g.useCallback(k=>{const O=u.current;O&&O.duration&&(O.currentTime=k*O.duration)},[]),q=k=>{k.stopPropagation(),C(!0);const O=$(k);b(O),V(O)};g.useEffect(()=>{a!==void 0&&a!==v.current&&(v.current=a,x(a))},[a]),g.useEffect(()=>{if(!y){d.current!==null&&(cancelAnimationFrame(d.current),d.current=null);return}const k=()=>{const O=u.current;O&&O.duration&&!w&&b(O.currentTime/O.duration),d.current=requestAnimationFrame(k)};return d.current=requestAnimationFrame(k),()=>{d.current!==null&&cancelAnimationFrame(d.current)}},[y,w]),g.useEffect(()=>{const k=u.current;k&&(y?k.play().catch(O=>{x(!1),B(!0)}):k.pause())},[y]),g.useEffect(()=>{if(!w)return;const k=X=>b($(X)),O=X=>{C(!1),V($(X))};return window.addEventListener("mousemove",k),window.addEventListener("mouseup",O),window.addEventListener("touchmove",k,{passive:!0}),window.addEventListener("touchend",O),()=>{window.removeEventListener("mousemove",k),window.removeEventListener("mouseup",O),window.removeEventListener("touchmove",k),window.removeEventListener("touchend",O)}},[w,$,V]);const W=T?{aspectRatio:String(T)}:void 0,ae=T?"":" aspect-video",Q=Math.round(p*100);return r.jsxs("div",{role:"button",tabIndex:0,className:`relative cursor-pointer overflow-hidden bg-black ${ae}`,style:W,onClick:k=>{if(f){f(k);return}P||o&&x(O=>!O)},onKeyDown:k=>{if(!(k.key!=="Enter"&&k.key!==" ")){if(k.preventDefault(),f){f(k);return}P||o&&x(O=>!O)}},children:[n&&(m==="audio"||E)&&r.jsx("img",{src:n,alt:"",className:"absolute inset-0 h-full w-full object-cover"}),!n&&(m==="audio"||E)&&r.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:Ne(t,{className:"size-12 text-black/20",weight:"regular"})}),r.jsx("div",{className:"absolute inset-0",children:m==="audio"?r.jsx("audio",{ref:u,src:e,loop:i,muted:c,style:{width:"100%",height:"100%"},onLoadStart:()=>z(!0),onCanPlay:()=>{z(!1),D(!1)},onWaiting:()=>z(!0),onPlay:()=>B(!1),onEnded:()=>{i||(x(!1),b(0))},children:r.jsx("track",{kind:"captions"})}):r.jsx("video",{ref:u,src:e,loop:i,muted:c,playsInline:!0,style:{width:"100%",height:"100%"},onLoadStart:()=>z(!0),onCanPlay:()=>{z(!1),D(!1)},onWaiting:()=>z(!0),onPlay:()=>B(!1),onLoadedMetadata:()=>{const k=u.current;k instanceof HTMLVideoElement&&k.videoWidth&&k.videoHeight&&R(k.videoWidth/k.videoHeight)},onEnded:()=>{i||(x(!1),b(0))},children:r.jsx("track",{kind:"captions"})})}),H&&!P&&r.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center",children:r.jsx(M.CircleNotchIcon,{className:"size-8 animate-spin text-white/80",weight:"bold"})}),P&&!o&&r.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:k=>{k.stopPropagation(),A()},onKeyDown:k=>{k.key!=="Enter"&&k.key!==" "||(k.preventDefault(),k.stopPropagation(),A())},children:r.jsx("span",{className:"flex size-16 items-center justify-center rounded-full bg-white/20 text-white backdrop-blur-sm",children:r.jsx(M.PlayIcon,{className:"size-9 translate-x-0.5",weight:"fill"})})}),l&&!o&&r.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:r.jsx("div",{role:"slider","aria-label":"Playback position","aria-valuenow":Q,"aria-valuemin":0,"aria-valuemax":100,tabIndex:0,ref:h,className:"relative flex h-4 w-full cursor-pointer items-center",onMouseDown:q,onTouchStart:q,onClick:k=>k.stopPropagation(),onKeyDown:k=>{k.key==="ArrowRight"&&V(Math.min(1,p+.05)),k.key==="ArrowLeft"&&V(Math.max(0,p-.05))},children:r.jsx("div",{className:"w-full overflow-hidden rounded-full bg-white/30 h-1",children:r.jsx("div",{className:"h-full rounded-full bg-white",style:{width:`${Q}%`}})})})}),o&&r.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:[r.jsx("button",{type:"button",onClick:k=>{k.stopPropagation(),x(O=>!O)},className:"shrink-0 text-white","aria-label":y?"Pause":"Play",children:y?r.jsx(M.PauseIcon,{className:"size-5",weight:"fill"}):r.jsx(M.PlayIcon,{className:"size-5 translate-x-px",weight:"fill"})}),r.jsxs("div",{role:"slider","aria-label":"Playback position","aria-valuenow":Q,"aria-valuemin":0,"aria-valuemax":100,tabIndex:0,ref:h,className:"relative flex h-4 w-full cursor-pointer items-center",onMouseDown:q,onTouchStart:q,onClick:k=>k.stopPropagation(),onMouseEnter:()=>F(!0),onMouseLeave:()=>F(!1),onKeyDown:k=>{k.key==="ArrowRight"&&V(Math.min(1,p+.05)),k.key==="ArrowLeft"&&V(Math.max(0,p-.05))},children:[r.jsx("div",{className:`w-full overflow-hidden rounded-full bg-white/30 transition-all duration-200 ${I||w?"h-1.5":"h-1"}`,children:r.jsx("div",{className:"h-full rounded-full bg-white",style:{width:`${Q}%`}})}),r.jsx("div",{className:`absolute size-3 -translate-x-1/2 rounded-full bg-white shadow transition-[opacity,transform] duration-200 ${I||w?"scale-100 opacity-100":"scale-0 opacity-0"}`,style:{left:`${Q}%`}})]})]})]})},bs=e=>e==="dark"?"size-12 text-white/20":"size-12 text-black/20",Xr=e=>e==="dark"?"aspect-video overflow-hidden bg-white/10":"aspect-video overflow-hidden bg-black/5",kn=({mimeType:e,sourceUrl:t,thumbnailUrl:n,title:s,variant:a,mediaPlayerProps:i,containedImage:o=!1})=>{const l=ue(e),[c,f]=g.useState(!1),m=be(t),u=be(n);return t&&(l==="video"||l==="audio")?r.jsx(Yr,{source:t,mimeType:e,poster:u,controls:!0,...i}):t&&l==="image"?o?r.jsx("div",{className:"relative aspect-video overflow-hidden bg-black/5",children:r.jsx("img",{src:m??t,alt:s??"",className:`absolute inset-0 h-full w-full object-contain transition-opacity duration-300 ${c?"opacity-100":"opacity-0"}`,draggable:!1,onLoad:()=>f(!0)})}):r.jsx("img",{src:m??t,alt:s??"",className:"block w-full",draggable:!1}):t&&l==="document"?n?o?r.jsx("div",{className:"relative aspect-video overflow-hidden bg-black/5",children:r.jsx("img",{src:u??n,alt:s??"",className:`absolute inset-0 h-full w-full object-contain transition-opacity duration-300 ${c?"opacity-100":"opacity-0"}`,draggable:!1,onLoad:()=>f(!0)})}):r.jsx("img",{src:u??n,alt:"",className:"block w-full",draggable:!1}):r.jsx("div",{className:`flex aspect-video w-full items-center justify-center ${a==="dark"?"bg-white/10":"bg-black/5"}`,children:Ne(e,{className:bs(a),weight:"regular"})}):n?r.jsx("div",{className:`relative ${Xr(a)}`,children:r.jsx("img",{src:u??n,alt:s??"",draggable:!1,className:"absolute inset-0 h-full w-full object-cover"})}):r.jsx("div",{className:`flex aspect-video w-full items-center justify-center ${a==="dark"?"bg-white/10":"bg-black/5"}`,children:Ne(e,{className:bs(a),weight:"regular"})})},oa=({variant:e,thumbnail:t,title:n,placeholderTitle:s="Attachment title",mimeType:a,detail:i,statusBadge:o,action:l,topLeft:c,topRight:f,rootRef:m,"data-testid":u})=>{const h=e==="dark",d=h?n??s:n??"",v=h&&!n;return r.jsxs("div",{ref:m,"data-testid":u,className:S("relative w-[280px] select-none overflow-hidden rounded-[24px] shadow-[0_0_0_1px_rgba(0,0,0,0.04),0_4px_8px_rgba(0,0,0,0.06)]",h?"bg-[#1e2330]":"bg-white"),children:[c?r.jsx("div",{className:"pointer-events-auto absolute left-3 top-3 z-50",children:c}):null,f?r.jsx("div",{className:"pointer-events-auto absolute right-3 top-3 z-50",children:f}):null,t,r.jsxs("div",{className:"px-4 pb-3 pt-3",children:[d.trim()!==""&&r.jsx("p",{className:S("mb-0.5 truncate text-base font-medium",{"text-black":!h,"text-white/30":h&&v,"text-white":h&&!v}),children:d}),r.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[Ne(a,{className:S("size-5 shrink-0",h?"text-white/55":"text-black/55"),weight:"regular"}),i!=null&&i!==""&&r.jsx("span",{className:S("text-xs font-medium",h?"text-white/55":"text-black/55"),children:i}),o]}),l]})]})};function la(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function Mn(e){return`w-[280px] select-none overflow-hidden rounded-[24px] ${e?"bg-[#1e2330]":"bg-[#F3F3F1]"} shadow-[0_0_0_1px_rgba(0,0,0,0.04),0_4px_8px_rgba(0,0,0,0.06)]`}function Wr(e){return e?"bg-white/10":"bg-black/5"}function Zr(e){return e?"text-white":"text-black"}function Kr(e){return e?"text-white/55":"text-black/55"}function Jr(e){return e?"text-white/40":"text-black/40"}function Qr(e){return e?"text-white/20":"text-black/20"}const Cn=({attachment:e,isMyMessage:t})=>{const{title:n,text:s,image_url:a,og_scrape_url:i,title_link:o}=e,l=i??o,c=typeof l=="string"&&l.trim()!==""?l:void 0,f=r.jsxs(g.Fragment,{children:[r.jsx("div",{className:"p-2",children:a?r.jsx("img",{src:be(a)??a,alt:n??"",className:"aspect-video w-full rounded-[20px] object-cover"}):r.jsx("div",{className:`aspect-video w-full rounded-[20px] ${Wr(t)} flex items-center justify-center`,children:r.jsx(M.LinkIcon,{className:`size-12 ${Qr(t)}`})})}),r.jsxs("div",{className:"px-3 pb-3",children:[n&&r.jsx("p",{className:`truncate text-[14px] font-medium leading-5 ${Zr(t)}`,children:n}),s&&r.jsx("p",{className:`truncate text-[12px] leading-4 ${Kr(t)}`,children:s}),c&&r.jsx("p",{className:`mt-1 truncate text-[12px] leading-4 ${Jr(t)}`,children:c})]})]});return c?r.jsx("a",{href:c,target:"_blank",rel:"noopener noreferrer",className:"block no-underline",children:f}):r.jsx("div",{className:"block",children:f})};function Sn(e){return e.type==="link"||!!e.og_scrape_url&&!e.asset_url}function gt(e){var t;return(t=e.attachments)==null?void 0:t.find(Sn)}async function ei(e,t){let n;try{n=t??new URL(e).pathname.split("/").pop()??"download"}catch{n=t??"download"}const s=await fetch(e,{mode:"cors"});if(!s.ok)throw new Error(`HTTP ${s.status}`);const a=await s.blob(),i=URL.createObjectURL(a),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 ti=({url:e,filename:t})=>{const[n,s]=g.useState(!1),a=i=>{i.stopPropagation();const o=window.open("","_blank","noopener,noreferrer");s(!0),ei(e,t).then(()=>{o==null||o.close()}).catch(()=>{o&&(o.location.href=e)}).finally(()=>s(!1))};return r.jsx("button",{type:"button",onClick:a,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?r.jsx(M.CircleNotchIcon,{className:"size-4 animate-spin text-white",weight:"bold"}):r.jsxs(g.Fragment,{children:[r.jsx(M.DownloadSimpleIcon,{className:"size-4 text-white",weight:"bold"}),"Download"]})})};function xt(e){var u,h,d,v;const t=(u=e.attachments)==null?void 0:u.find(y=>y.type==="video"&&y.asset_url),n=(h=e.attachments)==null?void 0:h.find(y=>y.type==="image"&&y.image_url),s=(d=e.attachments)==null?void 0:d.find(y=>y.type==="audio"&&y.asset_url),a=(v=e.attachments)==null?void 0:v.find(y=>y.type==="file"&&y.asset_url),i=t??n??s??a,o=(t==null?void 0:t.asset_url)??(n==null?void 0:n.image_url)??(s==null?void 0:s.asset_url)??(a==null?void 0:a.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"),c=i==null?void 0:i.title,f=i==null?void 0:i.file_size,m=t==null?void 0:t.thumb_url;return{resolvedUrl:o,resolvedType:l,title:c,fileSize:f,thumbnailUrl:m}}const ca=({resolvedUrl:e,resolvedType:t,title:n,fileSize:s,thumbnailUrl:a})=>{const i=s!==void 0?la(s):void 0;return r.jsx(oa,{variant:"dark",title:n,placeholderTitle:"",mimeType:t,detail:i,thumbnail:r.jsx(kn,{mimeType:t,sourceUrl:e,thumbnailUrl:a,title:n,variant:"dark"})})},da=({resolvedUrl:e,resolvedType:t,title:n,fileSize:s,thumbnailUrl:a})=>{const i=ue(t),o=s!==void 0?la(s):void 0;return r.jsx(oa,{variant:"light",title:n,mimeType:t,detail:o,thumbnail:r.jsx(kn,{mimeType:t,sourceUrl:e,thumbnailUrl:a,title:n,variant:"light",containedImage:i==="image"||i==="document"}),action:r.jsx(ti,{url:e,filename:n})})},ni=({message:e,isMyMessage:t=!1})=>{const n=gt(e),s=xt(e);if(!n&&!s)return null;const a=t?"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 r.jsxs("div",{className:a,"data-dd-privacy":"mask",children:[!t&&e.user&&r.jsx(ke,{className:"str-chat__avatar str-chat__message-sender-avatar",id:e.user.id,image:e.user.image,name:e.user.name??e.user.id}),r.jsx("div",{className:"str-chat__message-inner",style:{marginInlineEnd:0,marginInlineStart:0},children:r.jsx("div",{className:"str-chat__message-bubble-wrapper",children:r.jsx("div",{className:"str-chat__message-bubble","data-attachment-bubble":"true",style:{padding:0,borderRadius:0,overflow:"visible",background:"transparent"},children:n?r.jsx("div",{className:Mn(t),children:r.jsx(Cn,{attachment:n,isMyMessage:t})}):t?r.jsx(ca,{...s}):r.jsx(da,{...s})})})})]})},si=({message:e})=>{const t=gt(e);if(t)return r.jsx("div",{className:Mn(!0),"data-dd-privacy":"mask",children:r.jsx(Cn,{attachment:t,isMyMessage:!0})});const n=xt(e);return n?r.jsx("div",{style:{display:"contents"},"data-dd-privacy":"mask",children:r.jsx(ca,{...n})}):null},ai=({message:e})=>{const t=gt(e);if(t)return r.jsx("div",{className:Mn(!1),"data-dd-privacy":"mask",children:r.jsx(Cn,{attachment:t,isMyMessage:!1})});const n=xt(e);return n?r.jsx("div",{style:{display:"contents"},"data-dd-privacy":"mask",children:r.jsx(da,{...n})}):null},ri=Object.assign(ni,{Creator:si,Visitor:ai}),ii={dark:"bg-[#1e2330]",light:"bg-[#f2f1ef]"},oi={dark:"text-white",light:"text-[#000000]"},li={dark:"border-white/[0.08]",light:"border-black/[0.08]"},ci=e=>e==="dark"?"sender":"receiver",di={sender:{single:"rounded-tl-[18px] rounded-tr-[18px] rounded-bl-[18px] rounded-br-[18px]",first:"rounded-tl-[18px] rounded-tr-[18px] rounded-bl-[18px] rounded-br-[4px]",middle:"rounded-tl-[18px] rounded-tr-[4px] rounded-bl-[18px] rounded-br-[4px]",end:"rounded-tl-[18px] rounded-tr-[4px] rounded-bl-[18px] rounded-br-[18px]"},receiver:{single:"rounded-tl-[18px] rounded-tr-[18px] rounded-bl-[18px] rounded-br-[18px]",first:"rounded-tl-[18px] rounded-tr-[18px] rounded-bl-[4px] rounded-br-[18px]",middle:"rounded-tl-[4px] rounded-tr-[18px] rounded-bl-[4px] rounded-br-[18px]",end:"rounded-tl-[4px] rounded-tr-[18px] rounded-bl-[18px] rounded-br-[18px]"}},He=({variant:e,text:t,bordered:n=!0,groupPosition:s="single",widthClassName:a="w-[280px]",paddingClassName:i="px-2 py-2",radiusClassName:o,className:l,children:c,"data-testid":f})=>{const m=t!=null&&t!=="",u=o??di[ci(e)][s];return r.jsxs("div",{"data-testid":f,"data-group-position":s,className:S("relative",a,"overflow-hidden",i,m&&"pb-0",u,ii[e],oi[e],n&&"border",n&&li[e],l),children:[c,m?r.jsx("p",{className:S("whitespace-pre-wrap break-words leading-snug","pb-2 pt-2","px-2"),children:t}):null]})},Ve=({onClick:e,variant:t="overlay",ariaLabel:n="Dismiss attachment"})=>r.jsx("button",{type:"button",onClick:s=>{s.stopPropagation(),e()},"aria-label":n,className:S("flex size-6 items-center justify-center rounded-full text-white",t==="overlay"?"bg-[#121110]/85 backdrop-blur":"bg-white/15 hover:bg-white/25"),children:r.jsx(M.XIcon,{className:"size-3",weight:"bold"})}),Ge=e=>e==="received"?"light":"dark",ua=({firstOfGroup:e,endOfGroup:t,groupedByUser:n})=>!n||e&&t?"single":e?"first":t?"end":"middle",ui=({src:e,mimeType:t,filename:n,items:s})=>s&&s.length>0?s:e?[{src:e,mimeType:t,filename:n}]:[],fi=({item:e,preload:t,trailingAction:n})=>r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("audio",{src:e.src,controls:!0,preload:e.preload??t,className:"block min-w-0 flex-1",children:e.mimeType?r.jsx("source",{src:e.src,type:e.mimeType}):null}),n??null]}),En=({state:e,src:t,mimeType:n,filename:s,items:a,text:i,groupPosition:o,preload:l,onDismiss:c})=>{const f=Ge(e),m=e==="composer"&&!!c,u=ui({src:t,mimeType:n,filename:s,items:a});if(u.length===0)return null;const h=l??(u.length>1?"none":"metadata");return r.jsx(He,{variant:f,text:i,groupPosition:o,"data-testid":"audio-attachment",children:r.jsx("div",{className:"flex flex-col gap-2",children:u.map((d,v)=>r.jsx(fi,{item:d,preload:h,trailingAction:m&&v===0?r.jsx(Ve,{onClick:c,variant:"inline"}):void 0},`${d.src}-${v}`))})})},mi=e=>r.jsx(En,{...e,state:"composer"}),hi=e=>r.jsx(En,{...e,state:"sent"}),gi=e=>r.jsx(En,{...e,state:"received"}),xi={Composer:mi,Sent:hi,Received:gi};function fa(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 pi={pdf:"PDF",doc:"DOC",xls:"XLS",csv:"CSV",ppt:"PPT",zip:"ZIP",text:"TXT",markdown:"MD"};function ma(e,t){if(t){const a=t.lastIndexOf(".");if(a>0&&a<t.length-1){const i=t.slice(a+1);if(i&&i.length<=5)return i.toUpperCase()}}if(!e)return;if(ue(e)==="document"){const a=ia(e),i=pi[a];if(i)return i;if(e==="application/octet-stream")return}const s=e.split("/")[1];if(!(!s||s==="*"))return s.toUpperCase()}function ha(e,t,n){const s=ma(e,t),a=typeof n=="number"&&n>0?fa(n):void 0;return[s,a].filter(Boolean).join(" · ")||void 0}function de(e){try{const n=new URL(e).pathname.split("/").pop();return n&&n.length>0?decodeURIComponent(n):"download"}catch{return"download"}}const bi={dark:"text-white/55",light:"text-black/65"},vi={dark:"bg-white/10",light:"bg-black/5"},yi={dark:"text-white/85",light:"text-black/85"},ga=({variant:e,filename:t,title:n,mimeType:s="application/octet-stream",fileSize:a,onActivate:i,activateLabel:o,trailingAction:l})=>{const c=n??t??"File",f=ha(s,t,a),m=r.jsx("div",{className:S("flex size-10 shrink-0 items-center justify-center rounded-sm",vi[e]),"aria-hidden":!0,children:Ne(s,{className:S("size-6",yi[e]),weight:"regular"})}),u=r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col text-left",children:[r.jsx("p",{className:"truncate font-medium leading-snug",children:c}),f?r.jsx("p",{className:S("truncate text-xs leading-4",bi[e]),children:f}):null]}),h=i?r.jsxs("button",{type:"button",onClick:i,"aria-label":o,className:S("flex min-w-0 flex-1 items-center gap-3 rounded-sm text-left transition-colors",e==="dark"?"hover:bg-white/[0.04]":"hover:bg-black/[0.04]"),children:[m,u]}):r.jsxs(r.Fragment,{children:[m,u]});return r.jsxs("div",{className:"flex items-center gap-3 px-3 py-2",children:[h,l?r.jsx("div",{className:"shrink-0",children:l}):null]})};async function xa(e,t){const n=t??de(e);try{const s=await fetch(e,{mode:"cors"});if(!s.ok)throw new Error(`HTTP ${s.status}`);const a=await s.blob(),i=URL.createObjectURL(a),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 a=document.createElement("a");a.href=e,a.download=n,a.target="_blank",a.rel="noopener noreferrer",a.style.display="none",document.body.appendChild(a),a.click(),document.body.removeChild(a)}}}const _i=({src:e,filename:t,fileSize:n,mimeType:s,title:a,items:i})=>i&&i.length>0?i:e?[{src:e,filename:t,fileSize:n,mimeType:s,title:a}]:[],wi=({variant:e,item:t,index:n,onActivate:s,trailingAction:a})=>{const i=t.filename??de(t.src);return r.jsx(ga,{variant:e,filename:i,title:t.title,mimeType:t.mimeType??"application/octet-stream",fileSize:t.fileSize,onActivate:()=>s(n),activateLabel:`Download ${i}`,trailingAction:a})},Tn=({state:e,src:t,filename:n,fileSize:s,mimeType:a,title:i,items:o,text:l,groupPosition:c,onClick:f,onDismiss:m})=>{const u=Ge(e),h=e==="composer"&&!!m,d=_i({src:t,filename:n,fileSize:s,mimeType:a,title:i,items:o}),v=x=>{if((f==null?void 0:f(x))===!1)return;const p=d[x];if(!p)return;const b=p.filename??de(p.src);xa(p.src,b)};if(d.length===0)return null;const y=r.jsx("span",{className:S("flex size-8 items-center justify-center rounded-full",u==="dark"?"text-white/70":"text-black/70"),"aria-hidden":!0,children:r.jsx(M.DownloadSimpleIcon,{className:"size-5",weight:"bold"})});return r.jsx(He,{variant:u,text:l,groupPosition:c,"data-testid":"file-attachment",children:r.jsx("div",{className:"flex flex-col gap-2",children:d.map((x,p)=>{const b=h&&p===0?r.jsx(Ve,{onClick:m,variant:"inline"}):y;return r.jsx(wi,{variant:u,item:x,index:p,onActivate:v,trailingAction:b},`${x.src}-${p}`)})})})},ji=e=>r.jsx(Tn,{...e,state:"composer"}),Ni=e=>r.jsx(Tn,{...e,state:"sent"}),ki=e=>r.jsx(Tn,{...e,state:"received"}),Mi={Composer:ji,Sent:Ni,Received:ki},In=({onPrev:e,onNext:t,prevLabel:n="Previous",nextLabel:s="Next"})=>r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button",onClick:e,"aria-label":n,className:"mes-media-viewer__nav mes-media-viewer__nav--prev",children:r.jsx(M.CaretLeftIcon,{size:20,weight:"bold","aria-hidden":!0})}),r.jsx("button",{type:"button",onClick:t,"aria-label":s,className:"mes-media-viewer__nav mes-media-viewer__nav--next",children:r.jsx(M.CaretRightIcon,{size:20,weight:"bold","aria-hidden":!0})})]}),pa=({url:e,filename:t,variant:n="pill",label:s="Download",iconOnly:a,tone:i="dark",onTriggered:o})=>{const[l,c]=g.useState(!1),f=g.useCallback(d=>{d.stopPropagation(),!l&&(c(!0),xa(e,t).catch(()=>{}).finally(()=>{c(!1),o==null||o()}))},[l,e,t,o]),m=a??n!=="pill",h={className:S(n==="pill"?"size-4":"size-5","shrink-0"),weight:"bold"};if(n==="inline"){const d={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 r.jsx("button",{type:"button",onClick:f,disabled:l,"aria-label":s,className:S("flex size-8 shrink-0 items-center justify-center rounded-full transition-colors disabled:opacity-70",d[i]),children:l?r.jsx(M.CircleNotchIcon,{className:"size-4 animate-spin",weight:"bold","aria-hidden":!0}):r.jsx(M.DownloadSimpleIcon,{className:"size-5 shrink-0",weight:"bold","aria-hidden":!0})})}return n==="viewer"?r.jsx("button",{type:"button",onClick:f,disabled:l,"aria-label":s,className:"mes-media-viewer__action",children:l?r.jsx(M.CircleNotchIcon,{size:20,weight:"bold","aria-hidden":!0}):r.jsx(M.DownloadSimpleIcon,{size:20,weight:"bold","aria-hidden":!0})}):r.jsxs("button",{type:"button",onClick:f,disabled:l,"aria-label":m?s:void 0,className:S("mt-3 inline-flex h-10 w-full items-center justify-center gap-2 rounded-full px-4 text-sm font-medium leading-none transition-colors disabled:opacity-70",i==="dark"?"bg-[#121110] text-white hover:bg-[#2a2928]":"bg-white text-[#121110] hover:bg-white/90"),children:[l?r.jsx(M.CircleNotchIcon,{className:"size-4 animate-spin",weight:"bold","aria-hidden":!0}):r.jsx(M.DownloadSimpleIcon,{...h,"aria-hidden":!0}),m?null:s]})},Rt=(e,t,n)=>Math.min(Math.max(e,t),n),Rn=({length:e,initialIndex:t,open:n})=>{const s=Rt(t,0,Math.max(e-1,0)),[a,i]=g.useState(s);g.useEffect(()=>{n&&i(Rt(t,0,Math.max(e-1,0)))},[n,t,e]),g.useEffect(()=>{i(c=>Rt(c,0,Math.max(e-1,0)))},[e]);const o=g.useCallback(()=>{e<=1||i(c=>c<=0?e-1:c-1)},[e]),l=g.useCallback(()=>{e<=1||i(c=>c>=e-1?0:c+1)},[e]);return g.useEffect(()=>{if(!n||e<=1)return;const c=f=>{if(f.key!=="ArrowLeft"&&f.key!=="ArrowRight")return;const m=document.activeElement;m&&(m.tagName==="VIDEO"||m.tagName==="AUDIO")||(f.preventDefault(),f.key==="ArrowLeft"?o():l())};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[n,e,o,l]),{index:a,prev:o,next:l}},Ln=({open:e,onClose:t,ariaLabel:n,counter:s,actions:a,children:i,"data-testid":o})=>{const l=g.useRef(null),c=g.useRef(null);g.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 d=typeof document<"u"?document.activeElement:null;return(h=c.current)==null||h.focus(),()=>{if(u.open)if(typeof u.close=="function")try{u.close()}catch{u.removeAttribute("open")}else u.removeAttribute("open");d&&document.body.contains(d)&&d.focus()}}if(u.open)if(typeof u.close=="function")try{u.close()}catch{u.removeAttribute("open")}else u.removeAttribute("open")}},[e]);const f=()=>{t()},m=u=>{u.target===l.current&&t()};return r.jsxs("dialog",{ref:l,className:"mes-media-viewer","aria-label":n??"Attachment viewer","data-testid":o,onClose:f,onClick:m,children:[r.jsxs("div",{className:"mes-media-viewer__chrome",children:[s?r.jsx("span",{className:"mes-media-viewer__counter",children:s}):null,r.jsxs("div",{className:"mes-media-viewer__actions",children:[a,r.jsx("button",{ref:c,type:"button",onClick:t,"aria-label":"Close viewer",className:"mes-media-viewer__action",children:r.jsx(M.XIcon,{size:20,weight:"bold","aria-hidden":!0})})]})]}),r.jsx("div",{className:"mes-media-viewer__body",children:i})]})},ba=({open:e,items:t,initialIndex:n=0,onClose:s})=>{const{index:a,prev:i,next:o}=Rn({length:t.length,initialIndex:n,open:e}),l=t[a],c=g.useMemo(()=>(l==null?void 0:l.filename)??(l?de(l.src):"image"),[l]);return l?r.jsxs(Ln,{open:e,onClose:s,ariaLabel:c,counter:t.length>1?`${a+1} / ${t.length}`:void 0,actions:r.jsx(pa,{url:l.src,filename:c,variant:"viewer",label:`Download ${c}`}),"data-testid":"image-viewer",children:[e?r.jsx("img",{src:l.src,alt:l.alt??c,draggable:!1,loading:"eager",decoding:"async",className:"mes-media-viewer__image"},`${a}:${l.src}`):null,t.length>1?r.jsx(In,{onPrev:i,onNext:o,prevLabel:"Previous image",nextLabel:"Next image"}):null]}):null},Ci="relative block size-full overflow-hidden bg-black/5 outline-none after:pointer-events-none after:absolute after:inset-0 after:rounded-[inherit] focus-visible:after:ring-2 focus-visible:after:ring-inset focus-visible:after:ring-white/80 focus-visible:after:ring-offset-2 focus-visible:after:ring-offset-black",Si={1:["rounded-[18px]"],2:["rounded-l-[18px]","rounded-r-[18px]"],3:["rounded-l-[18px]","rounded-tr-[18px]","rounded-br-[18px]"],4:["rounded-tl-[18px]","rounded-tr-[18px]","rounded-bl-[18px]","rounded-br-[18px]"]},Ei="--mes-single-width-cap",Ti="[--mes-single-width-cap:309px] sm:[--mes-single-width-cap:326px]",Ii=436,va=({tiles:e,onTileActivate:t,maxVisible:n=4,singleAspectRatio:s,className:a})=>{const i=e.length;if(i===0)return null;const o=e.slice(0,Math.min(i,n)),l=i-o.length,c=(m,u,h)=>{var v;const d=S(Ci,"h-full w-full",(v=Si[o.length])==null?void 0:v[u]);return t?r.jsxs("button",{type:"button",onClick:()=>t(u),"aria-label":m.ariaLabel??`Open media ${u+1}`,className:S(d,"cursor-zoom-in"),children:[m.content,h]},u):r.jsxs("div",{className:d,children:[m.content,h]},u)};let f;return s&&(f={aspectRatio:s,width:`min(var(${Ei}), ${Math.round(Ii*s*100)/100}px)`,maxWidth:"100%"}),o.length===1?r.jsx("div",{className:S(s?Ti:"aspect-square w-full",a),style:f,children:c(o[0],0)}):o.length===2?r.jsx("div",{className:S("grid aspect-[16/9] w-full grid-cols-2 gap-0.5",a),children:o.map((m,u)=>c(m,u))}):o.length===3?r.jsxs("div",{className:S("grid aspect-[4/3] w-full grid-cols-2 grid-rows-2 gap-0.5",a),children:[r.jsx("div",{className:"row-span-2",children:c(o[0],0)}),c(o[1],1),c(o[2],2)]}):r.jsx("div",{className:S("grid aspect-[379/286] w-full grid-cols-2 grid-rows-2 gap-0.5",a),children:o.map((m,u)=>{const h=l>0&&u===o.length-1;return c(m,u,h?r.jsxs("div",{className:"absolute inset-0 flex items-center justify-center bg-black/55 text-2xl font-semibold text-white",children:["+",l]}):null)})})},qe=e=>{const[t,n]=g.useState(!1),[s,a]=g.useState(0),i=g.useCallback(l=>{(e==null?void 0:e(l))!==!1&&(a(l),n(!0))},[e]),o=g.useCallback(()=>n(!1),[]);return{viewerOpen:t,viewerIndex:s,handleActivate:i,closeViewer:o}},Ri=({item:e,index:t,totalCount:n,fallbackLoading:s,imgRef:a,onLoad:i})=>({ariaLabel:`Open image ${t+1} of ${n}`,content:r.jsx("img",{ref:a,src:be(e.src)??e.src,alt:e.alt??"",width:e.width,height:e.height,draggable:!1,loading:e.loading??s,decoding:"async",onLoad:i,className:"absolute inset-0 size-full object-cover"})}),Li=({src:e,alt:t,items:n})=>n&&n.length>0?n:e?[{src:e,alt:t}]:[],ya=(e,t)=>e.map((n,s)=>({src:n.src,alt:n.alt,filename:t&&e.length===1?t:t?`${t} (${s+1})`:void 0})),Ai=({src:e,alt:t,filename:n,loading:s="lazy",onClick:a,onDismiss:i})=>{const{viewerOpen:o,viewerIndex:l,handleActivate:c,closeViewer:f}=qe(a);return r.jsxs("div",{className:"relative w-fit",children:[r.jsx("button",{type:"button",onClick:()=>c(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:r.jsx("img",{src:be(e)??e,alt:t??"",draggable:!1,loading:s,decoding:"async",className:"size-full object-cover"})}),i?r.jsx("div",{className:"absolute right-2 top-2 z-10",children:r.jsx(Ve,{onClick:i})}):null,r.jsx(ba,{open:o,items:ya([{src:e,alt:t}],n),initialIndex:l,onClose:f})]})},zi=326/246,$i=e=>{const t=e==null?void 0:e.src,[n,s]=g.useState(),a=g.useCallback(c=>{if(!c||c.naturalWidth<=0||c.naturalHeight<=0||t===void 0)return;const f=c.naturalWidth/c.naturalHeight;s(m=>m&&m.src===t&&m.ratio===f?m:{src:t,ratio:f})},[t]),i=g.useCallback(c=>a(c.currentTarget),[a]),o=e!=null&&e.width&&(e!=null&&e.height)?e.width/e.height:void 0,l=n&&n.src===t?n.ratio:void 0;return{ratio:o??l??zi,imgRef:a,onLoad:i}},_a=({state:e,src:t,alt:n,filename:s,items:a,text:i,groupPosition:o,loading:l="lazy",onClick:c})=>{const f=Li({src:t,alt:n,items:a}),m=Ge(e),{viewerOpen:u,viewerIndex:h,handleActivate:d,closeViewer:v}=qe(c),y=f.length===1,x=$i(y?f[0]:void 0);if(f.length===0)return null;const p=f.map((b,w)=>Ri({item:b,index:w,totalCount:f.length,fallbackLoading:l,imgRef:y?x.imgRef:void 0,onLoad:y?x.onLoad:void 0}));return r.jsxs(He,{variant:m,text:i,groupPosition:o,bordered:!1,widthClassName:y?"w-fit max-w-[313px] sm:max-w-[330px]":"w-[383px] max-w-full",paddingClassName:"p-0.5",radiusClassName:"rounded-[20px]","data-testid":"image-attachment",children:[r.jsx("div",{className:"relative",children:r.jsx(va,{tiles:p,onTileActivate:d,singleAspectRatio:y?x.ratio:void 0})}),r.jsx(ba,{open:u,items:ya(f,s),initialIndex:h,onClose:v})]})},Pi=e=>r.jsx(Ai,{...e}),Di=e=>r.jsx(_a,{...e,state:"sent"}),Oi=e=>r.jsx(_a,{...e,state:"received"}),Fi={Composer:Pi,Sent:Di,Received:Oi},Bi=({open:e,items:t,initialIndex:n=0,onClose:s})=>{const{index:a,prev:i,next:o}=Rn({length:t.length,initialIndex:n,open:e}),l=t[a],c=g.useMemo(()=>(l==null?void 0:l.filename)??(l?de(l.src):"document"),[l]),f=g.useMemo(()=>l?Ui(l.src):void 0,[l]);return!l||!f?null:r.jsxs(Ln,{open:e,onClose:s,ariaLabel:c,counter:t.length>1?`${a+1} / ${t.length}`:void 0,"data-testid":"pdf-viewer",children:[r.jsx("iframe",{src:f,title:c,className:"mes-media-viewer__iframe",sandbox:"allow-scripts allow-forms allow-popups allow-downloads"},`${a}:${l.src}`),t.length>1?r.jsx(In,{onPrev:i,onNext:o,prevLabel:"Previous document",nextLabel:"Next document"}):null]})},Ui=e=>{const t=e.indexOf("#"),n=t===-1?e:e.slice(0,t),s=t===-1?"":e.slice(t+1),a=new URLSearchParams(s);return a.has("toolbar")||a.set("toolbar","0"),a.has("navpanes")||a.set("navpanes","0"),`${n}#${a.toString()}`},Hi=({src:e,filename:t,fileSize:n,title:s,items:a})=>a&&a.length>0?a:e?[{src:e,filename:t,fileSize:n,title:s}]:[],Vi=({variant:e,item:t,index:n,onActivate:s,trailingAction:a})=>{const i=t.filename??de(t.src);return r.jsx(ga,{variant:e,filename:i,title:t.title,mimeType:"application/pdf",fileSize:t.fileSize,onActivate:()=>s(n),activateLabel:`Open ${i}`,trailingAction:a})},An=({state:e,src:t,filename:n,fileSize:s,title:a,items:i,text:o,groupPosition:l,onClick:c,onDismiss:f})=>{const m=Ge(e),u=Hi({src:t,filename:n,fileSize:s,title:a,items:i}),{viewerOpen:h,viewerIndex:d,handleActivate:v,closeViewer:y}=qe(c),x=e==="composer"&&!!f;if(u.length===0)return null;const p=u.map(b=>({src:b.src,filename:b.filename??de(b.src)}));return r.jsxs(He,{variant:m,text:o,groupPosition:l,"data-testid":"pdf-attachment",children:[r.jsx("div",{className:"flex flex-col gap-2",children:u.map((b,w)=>{const C=b.filename??de(b.src),I=x&&w===0?r.jsx(Ve,{onClick:f,variant:"inline"}):e==="composer"?void 0:r.jsx(pa,{url:b.src,filename:C,variant:"inline",label:`Download ${C}`,tone:m});return r.jsx(Vi,{variant:m,item:b,index:w,onActivate:v,trailingAction:I},`${b.src}-${w}`)})}),r.jsx(Bi,{open:h,items:p,initialIndex:d,onClose:y})]})},Gi=e=>r.jsx(An,{...e,state:"composer"}),qi=e=>r.jsx(An,{...e,state:"sent"}),Yi=e=>r.jsx(An,{...e,state:"received"}),Xi={Composer:Gi,Sent:qi,Received:Yi},wa=({open:e,items:t,initialIndex:n=0,onClose:s})=>{const{index:a,prev:i,next:o}=Rn({length:t.length,initialIndex:n,open:e}),l=t[a],c=g.useMemo(()=>(l==null?void 0:l.filename)??(l?de(l.src):"video"),[l]);return l?r.jsxs(Ln,{open:e,onClose:s,ariaLabel:c,counter:t.length>1?`${a+1} / ${t.length}`:void 0,"data-testid":"video-viewer",children:[r.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?r.jsx("source",{src:l.src,type:l.mimeType}):null},`${a}:${l.src}`),t.length>1?r.jsx(In,{onPrev:i,onNext:o,prevLabel:"Previous video",nextLabel:"Next video"}):null]}):null},Wi=()=>r.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center",children:r.jsx("span",{className:"flex size-12 items-center justify-center rounded-full bg-black/55 text-white backdrop-blur",children:r.jsx(M.PlayIcon,{className:"size-6",weight:"fill","aria-hidden":!0})})}),ja=({item:e,index:t})=>r.jsxs("div",{className:"absolute inset-0 size-full bg-[#0d0d0d]",children:[e.poster?r.jsx("img",{src:e.poster,alt:`Video ${t+1} thumbnail`,draggable:!1,loading:"lazy",decoding:"async",className:"absolute inset-0 size-full object-cover"}):r.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:r.jsx(M.VideoCameraIcon,{className:"size-16 text-white/30",weight:"regular","aria-hidden":!0})}),r.jsx(Wi,{})]}),Zi=(e,t,n)=>({ariaLabel:`Play video ${t+1} of ${n}`,content:r.jsx(ja,{item:e,index:t})}),Ki=({src:e,poster:t,mimeType:n,preload:s,items:a})=>a&&a.length>0?s?a.map(i=>({...i,preload:i.preload??s})):a:e?[{src:e,poster:t,mimeType:n,preload:s}]:[],Na=(e,t)=>e.map((n,s)=>({src:n.src,poster:n.poster,mimeType:n.mimeType,preload:n.preload,filename:t&&e.length===1?t:t?`${t} (${s+1})`:void 0})),Ji=({src:e,poster:t,mimeType:n,filename:s,preload:a,onClick:i,onDismiss:o})=>{const{viewerOpen:l,viewerIndex:c,handleActivate:f,closeViewer:m}=qe(i);return r.jsxs("div",{className:"relative w-fit",children:[r.jsx("button",{type:"button",onClick:()=>f(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:r.jsx(ja,{item:{src:e,poster:t,mimeType:n},index:0})}),o?r.jsx("div",{className:"absolute right-2 top-2 z-10",children:r.jsx(Ve,{onClick:o})}):null,r.jsx(wa,{open:l,items:Na([{src:e,poster:t,mimeType:n,preload:a}],s),initialIndex:c,onClose:m})]})},ka=({state:e,src:t,poster:n,mimeType:s,filename:a,items:i,text:o,groupPosition:l,preload:c,onClick:f})=>{const m=Ki({src:t,poster:n,mimeType:s,preload:c,items:i}),u=Ge(e),{viewerOpen:h,viewerIndex:d,handleActivate:v,closeViewer:y}=qe(f);if(m.length===0)return null;const x=m.map((p,b)=>Zi(p,b,m.length));return r.jsxs(He,{variant:u,text:o,groupPosition:l,"data-testid":"video-attachment",children:[r.jsx("div",{className:"relative",children:r.jsx(va,{tiles:x,onTileActivate:v})}),r.jsx(wa,{open:h,items:Na(m,a),initialIndex:d,onClose:y})]})},Qi=e=>r.jsx(Ji,{...e}),eo=e=>r.jsx(ka,{...e,state:"sent"}),to=e=>r.jsx(ka,{...e,state:"received"}),no={Composer:Qi,Sent:eo,Received:to},Re={Image:Fi,Video:no,Audio:xi,Pdf:Xi,File:Mi},so={isUnlocking:()=>!1},ao={LockedAttachment:so},Ma=g.createContext({}),ro=Ma.Provider;function Ca(e){return g.useContext(Ma)[e]??ao[e]}const io=g.lazy(()=>Promise.resolve().then(()=>require("./Card-415OfRhw.cjs"))),oo=g.lazy(()=>Promise.resolve().then(()=>require("./Card-ZqURr2Xg.cjs"))),lo=()=>r.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}),Oe=e=>r.jsx(g.Suspense,{fallback:r.jsx(lo,{}),children:e.contentType==="text"?r.jsx(io,{...e}):r.jsx(oo,{...e})}),co=({size:e=15})=>r.jsx("svg",{width:e,height:e,viewBox:"0 0 15 15",fill:"none","aria-hidden":"true",children:r.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})}),uo=e=>{var t;return((t=e.metadata)==null?void 0:t.custom_type)===se.MESSAGE_CUSTOM_TYPE.TIP},Sa=e=>{var t;return((t=e.metadata)==null?void 0:t.custom_type)===se.MESSAGE_CUSTOM_TYPE.PAID},nt=e=>{var t;return((t=e.metadata)==null?void 0:t.custom_type)===se.MESSAGE_CUSTOM_TYPE.CHATBOT},zn=e=>{var t;return((t=e.metadata)==null?void 0:t.custom_type)===se.MESSAGE_CUSTOM_TYPE.ATTACHMENT},fo=e=>{var t;return zn(e)&&((t=e.metadata)==null?void 0:t.attachment_content_type)==="text"},mo=e=>{var t;return zn(e)&&((t=e.metadata)==null?void 0:t.attachment_content_type)!=="text"},Ea=e=>uo(e)||Sa(e),ho=e=>{var t;return Ea(e)&&!((t=e.text)!=null&&t.trim())},Lt=({message:e,standalone:t=!1,isMyMessage:n=!1,hasAttachment:s=!1})=>{var u;const a=Ea(e),i=nt(e);if(!a&&!i)return null;if(a){const h=(u=e.metadata)==null?void 0:u.amount_text;if(!h)return null;const d=t?"message-tip-standalone":"message-tag message-tag--tip",v=Sa(e)?"message":"tip",y=t?`${h} ${v}`:`Delivered with ${h} ${v}`;return r.jsxs("div",{className:d,children:[r.jsx(M.GiftIcon,{size:t?14:12}),r.jsx("span",{children:y})]})}const o=n&&s,l=o?"Sent with AI":"Sent by AI Assistant",c=["message-chatbot-indicator",n?"message-chatbot-indicator--sender":"message-chatbot-indicator--receiver",o?"message-chatbot-indicator--attachment":"message-chatbot-indicator--text"].join(" "),f=r.jsx("span",{className:"message-chatbot-indicator__label",children:l}),m=r.jsx("span",{className:"message-chatbot-indicator__icon",children:r.jsx(co,{size:o?12:15})});return r.jsx("div",{className:c,"data-testid":"message-chatbot-indicator",children:n&&!o?r.jsxs(r.Fragment,{children:[f,m]}):r.jsxs(r.Fragment,{children:[m,f]})})},Ta=({selected:e,onVoteUp:t,onVoteDown:n})=>r.jsxs("div",{className:"message-vote-buttons",children:[r.jsx("button",{type:"button",className:S("message-vote-button focus-ring",{"message-vote-button--selected":e==="up"}),onClick:t,"aria-label":"Good response","aria-pressed":e==="up","data-tooltip":"Good response",children:r.jsx(M.ThumbsUpIcon,{size:16,weight:e==="up"?"fill":"regular"})}),r.jsx("button",{type:"button",className:S("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:r.jsx(M.ThumbsDownIcon,{size:16,weight:e==="down"?"fill":"regular"})})]}),$n=()=>{const{message:e}=N.useMessageContext("SentMessageDeliveryStatus"),{messages:t}=N.useChannelStateContext("SentMessageDeliveryStatus"),n=(()=>{if(t)for(let s=t.length-1;s>=0;s-=1){const a=t[s];if(!(a.type==="system"||a.type==="ephemeral"||a.type==="deleted"))return a.id}})();return e.id===n},At=()=>$n()?r.jsxs(r.Fragment,{children:[r.jsx(M.ChecksIcon,{weight:"bold","aria-hidden":"true"}),r.jsx("span",{"data-testid":"sent-message-delivery-status",children:"Delivered"})]}):null,go=()=>$n()?r.jsxs(r.Fragment,{children:[r.jsx(M.CircleNotchIcon,{className:"sent-message-status__spinner animate-spin",weight:"bold","aria-hidden":"true"}),r.jsx("span",{"data-testid":"sent-message-sending-status",children:"Sending"})]}):null,xo=({broadcastId:e,broadcastName:t,onBroadcastClick:n})=>{const s=t||"Broadcast",a=r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"sent-message-broadcast-badge","aria-hidden":"true",children:r.jsx(M.MegaphoneIcon,{weight:"fill"})}),r.jsx("span",{className:"sent-message-broadcast-name","data-testid":"sent-message-broadcast-status",children:s})]});return n?r.jsx("button",{type:"button",className:"sent-message-broadcast-link","aria-label":`View broadcast ${s}`,onClick:()=>n({id:e,...t?{name:t}:{}}),children:a}):a},po=()=>r.jsxs("span",{className:"str-chat__message-status sent-message-status--failed",children:[r.jsx(M.WarningCircleIcon,{weight:"bold","aria-hidden":"true"}),r.jsx("span",{"data-testid":"sent-message-failed-status",children:"Failed to send"})]}),bo=({onBroadcastClick:e})=>{var m,u;const{isMyMessage:t,message:n,threadList:s}=N.useMessageContext("SentMessageDeliveryStatus"),a=t(),i=$n();if(s)return null;if(n.status==="failed"&&a&&n.type!=="error")return r.jsx(po,{});if(!a)return null;const o=(m=n.metadata)==null?void 0:m.broadcast_id,l=(u=n.metadata)==null?void 0:u.broadcast_name,c=n.status!=="sending"&&n.status!=="failed"&&o?r.jsx(xo,{broadcastId:o,broadcastName:l,onBroadcastClick:e}):null,f=r.jsx(N.MessageStatus,{MessageSentStatus:At,MessageDeliveredStatus:At,MessageReadStatus:At,MessageSendingStatus:go});return c?r.jsxs("span",{className:"sent-message-status-row",children:[f,i&&r.jsx("span",{className:"sent-message-broadcast-separator","aria-hidden":"true",children:"•"}),c]}):f},vo=/^([a-z][a-z0-9+.-]*):/i,yo=new Set(["http","https","mailto","tel","sms"]);function Pn(e){if(typeof e!="string")return;const t=e.trim();if(t==="")return;const n=vo.exec(t);if(n){const s=n[1].toLowerCase();return yo.has(s)?t:void 0}return t.startsWith("//")||t.startsWith("/")?t:`https://${t}`}const _o={dark:"bg-white text-[#121110] hover:bg-white/90",light:"bg-[#121110] text-white hover:bg-[#2a2928]"},wo=({variant:e,cta:t})=>{const n=S("mt-2 inline-flex h-10 w-full items-center justify-center rounded-full px-4 text-sm font-medium leading-none transition-colors",_o[e]),s=Pn(t.href);return s?r.jsx("a",{href:s,target:"_blank",rel:"noopener noreferrer",onClick:a=>{var i;a.stopPropagation(),(i=t.onClick)==null||i.call(t)},className:`${n} no-underline`,children:t.label}):r.jsx("button",{type:"button",onClick:a=>{var i;a.stopPropagation(),(i=t.onClick)==null||i.call(t)},className:n,children:t.label})},jo={dark:"text-white",light:"text-black/90"},No="text-white/30",ko={dark:"text-white/55",light:"text-black/55"},Mo={dark:"bg-white/25",light:"bg-black/15"},Dn=({variant:e,chinTextColor:t,title:n,placeholderTitle:s,description:a,url:i,appIcon:o,cta:l,trailingAction:c,isLoading:f=!1})=>{const m=e==="dark",u=n??(m?s:void 0)??"",h=u.trim()!=="",d=a!=null&&a.trim()!=="",v=typeof i=="string"?i.trim():"",y=v!=="",x=l!=null;if(!f&&!h&&!d&&!y&&!x)return null;const p=m&&!n,b=S("line-clamp-2 text-[14px] font-medium leading-5 tracking-[0.28px]",t==null&&(p?No:jo[e])),w=S("truncate text-[12px] leading-4 tracking-[0.24px]",t==null&&ko[e]);if(f){const I=S("animate-pulse rounded",Mo[e]);return r.jsx("div",{className:"shrink-0 px-4 py-3",children:r.jsxs("div",{className:"flex min-w-0 flex-col gap-[2px]",children:[r.jsx("div",{className:S("h-5 w-3/4",I),"aria-hidden":!0}),r.jsx("div",{className:S("h-4 w-1/2",I),"aria-hidden":!0})]})})}const C=t?{color:t}:void 0;return r.jsxs("div",{className:"shrink-0 px-4 py-3",children:[r.jsxs("div",{className:"flex items-end gap-3",children:[r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-[2px]",children:[h&&r.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[o?r.jsx("span",{className:"shrink-0",children:o}):null,r.jsx("p",{className:S("min-w-0",b),style:C,children:u})]}),d&&r.jsx("p",{className:w,style:C,children:a}),!x&&y&&r.jsx("p",{className:w,style:C,children:v})]}),c&&r.jsx("div",{className:"shrink-0",children:c})]}),l&&r.jsx(wo,{variant:e,cta:l})]})},Co="Loading link preview",So=S("relative w-[290px] select-none overflow-hidden","rounded-[20px]"),Eo="flex h-[250px] flex-col",st=({variant:e,children:t,href:n,onClick:s,ariaLabel:a,rootRef:i,topRight:o,bgClassName:l,accentStyle:c,fixedHeight:f=!1,busy:m=!1,"data-testid":u})=>{const h=n!=null||s!=null,d=S(So,f?Eo:"block",l??(e==="dark"?"bg-[#1e2330]":"bg-[#f1f0ee]"),h?"cursor-pointer no-underline focus-ring":null),v=m?{role:"status","aria-busy":!0,"aria-label":Co}:void 0,y=o?r.jsx("div",{className:"pointer-events-auto absolute right-3 top-3 z-10",children:o}):null;return n?r.jsxs("a",{ref:i,href:n,target:"_blank",rel:"noopener noreferrer",onClick:s,"data-testid":u,className:d,style:c,...v,children:[t,y]}):s?r.jsxs("button",{ref:i,type:"button",onClick:s,"aria-label":a,"data-testid":u,className:S(d,"text-left"),style:c,...v,children:[t,y]}):r.jsxs("div",{ref:i,"data-testid":u,className:d,style:c,...v,children:[t,y]})},vs={dark:"bg-white/10",light:"bg-black/5"},To={dark:"size-16 text-white/25",light:"size-16 text-black/25"},Ye=(e,t)=>!!t&&!!e&&ue(e)==="audio",On=(e,t)=>{if(!t||!e)return!1;const n=ue(e);return n==="video"||n==="audio"},Io="#F2F3F4",Fn="bg-[#F2F3F4]",at=({variant:e,thumbnailUrl:t,sourceUrl:n,title:s,mimeType:a="image/*",topLeft:i,topRight:o,isLoading:l=!1,onImageError:c})=>{const f=ue(a),m=!!n&&f==="video",u=be(t);return!l&&Ye(a,n)?r.jsx("div",{className:"p-3",children:r.jsx("audio",{src:n,controls:!0,preload:"metadata",className:"block w-full",children:r.jsx("track",{kind:"captions"})})}):r.jsxs("div",{className:S("relative min-h-0 w-full flex-1 overflow-hidden",m&&"bg-black"),children:[l?r.jsx("div",{className:S("h-full w-full animate-pulse",vs[e]),"aria-hidden":!0}):m?r.jsxs(r.Fragment,{children:[r.jsx("video",{src:n,poster:u,controls:!0,playsInline:!0,preload:"metadata",className:"absolute inset-0 h-full w-full object-contain",children:r.jsx("track",{kind:"captions"})}),u&&c?r.jsx("img",{src:u,alt:"","aria-hidden":!0,onError:c,className:"hidden"}):null]}):t?r.jsx("img",{src:u??t,alt:s??"",draggable:!1,loading:"lazy",decoding:"async",onError:c,className:"absolute inset-0 h-full w-full object-cover"}):r.jsx("div",{className:S("flex h-full w-full items-center justify-center",vs[e]),children:Ne(a,{className:To[e],weight:"regular"})}),i?r.jsx("div",{className:"pointer-events-auto absolute left-3 top-3 z-10",children:i}):null,o?r.jsx("div",{className:"pointer-events-auto absolute right-3 top-3 z-10",children:o}):null]})},Ia=(e,t)=>{if(typeof e=="number"){if(t===3)return{mode:"rgb",r:(e>>8&15|e>>4&240)/255,g:(e>>4&15|e&240)/255,b:(e&15|e<<4&240)/255};if(t===4)return{mode:"rgb",r:(e>>12&15|e>>8&240)/255,g:(e>>8&15|e>>4&240)/255,b:(e>>4&15|e&240)/255,alpha:(e&15|e<<4&240)/255};if(t===6)return{mode:"rgb",r:(e>>16&255)/255,g:(e>>8&255)/255,b:(e&255)/255};if(t===8)return{mode:"rgb",r:(e>>24&255)/255,g:(e>>16&255)/255,b:(e>>8&255)/255,alpha:(e&255)/255}}},Ro={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},Lo=e=>Ia(Ro[e.toLowerCase()],6),Ao=/^#?([0-9a-f]{8}|[0-9a-f]{6}|[0-9a-f]{4}|[0-9a-f]{3})$/i,zo=e=>{let t;return(t=e.match(Ao))?Ia(parseInt(t[1],16),t[1].length):void 0},pe="([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)",Be=`${pe}%`,Bn=`(?:${pe}%|${pe})`,$o=`(?:${pe}(deg|grad|rad|turn)|${pe})`,Ae="\\s*,\\s*",Po=new RegExp(`^rgba?\\(\\s*${pe}${Ae}${pe}${Ae}${pe}\\s*(?:,\\s*${Bn}\\s*)?\\)$`),Do=new RegExp(`^rgba?\\(\\s*${Be}${Ae}${Be}${Ae}${Be}\\s*(?:,\\s*${Bn}\\s*)?\\)$`),Oo=e=>{let t={mode:"rgb"},n;if(n=e.match(Po))n[1]!==void 0&&(t.r=n[1]/255),n[2]!==void 0&&(t.g=n[2]/255),n[3]!==void 0&&(t.b=n[3]/255);else if(n=e.match(Do))n[1]!==void 0&&(t.r=n[1]/100),n[2]!==void 0&&(t.g=n[2]/100),n[3]!==void 0&&(t.b=n[3]/100);else return;return n[4]!==void 0?t.alpha=Math.max(0,Math.min(1,n[4]/100)):n[5]!==void 0&&(t.alpha=Math.max(0,Math.min(1,+n[5]))),t},rt=(e,t)=>e===void 0?void 0:typeof e!="object"?Xo(e):e.mode!==void 0?e:t?{...e,mode:t}:void 0,ce=(e="rgb")=>t=>(t=rt(t,e))!==void 0?t.mode===e?t:le[t.mode][e]?le[t.mode][e](t):e==="rgb"?le[t.mode].rgb(t):le.rgb[e](le[t.mode].rgb(t)):void 0,le={},Ra={},it=[],La={},Fo=e=>e,G=e=>(le[e.mode]={...le[e.mode],...e.toMode},Object.keys(e.fromMode||{}).forEach(t=>{le[t]||(le[t]={}),le[t][e.mode]=e.fromMode[t]}),e.ranges||(e.ranges={}),e.difference||(e.difference={}),e.channels.forEach(t=>{if(e.ranges[t]===void 0&&(e.ranges[t]=[0,1]),!e.interpolate[t])throw new Error(`Missing interpolator for: ${t}`);typeof e.interpolate[t]=="function"&&(e.interpolate[t]={use:e.interpolate[t]}),e.interpolate[t].fixup||(e.interpolate[t].fixup=Fo)}),Ra[e.mode]=e,(e.parse||[]).forEach(t=>{Bo(t,e.mode)}),ce(e.mode)),pt=e=>Ra[e],Bo=(e,t)=>{if(typeof e=="string"){if(!t)throw new Error("'mode' required when 'parser' is a string");La[e]=t}else typeof e=="function"&&it.indexOf(e)<0&&it.push(e)},cn=/[^\x00-\x7F]|[a-zA-Z_]/,Uo=/[^\x00-\x7F]|[-\w]/,_={Function:"function",Ident:"ident",Number:"number",Percentage:"percentage",ParenClose:")",None:"none",Hue:"hue",Alpha:"alpha"};let L=0;function Qe(e){let t=e[L],n=e[L+1];return t==="-"||t==="+"?/\d/.test(n)||n==="."&&/\d/.test(e[L+2]):t==="."?/\d/.test(n):/\d/.test(t)}function dn(e){if(L>=e.length)return!1;let t=e[L];if(cn.test(t))return!0;if(t==="-"){if(e.length-L<2)return!1;let n=e[L+1];return!!(n==="-"||cn.test(n))}return!1}const Ho={deg:1,rad:180/Math.PI,grad:9/10,turn:360};function De(e){let t="";if((e[L]==="-"||e[L]==="+")&&(t+=e[L++]),t+=et(e),e[L]==="."&&/\d/.test(e[L+1])&&(t+=e[L++]+et(e)),(e[L]==="e"||e[L]==="E")&&((e[L+1]==="-"||e[L+1]==="+")&&/\d/.test(e[L+2])?t+=e[L++]+e[L++]+et(e):/\d/.test(e[L+1])&&(t+=e[L++]+et(e))),dn(e)){let n=ot(e);return n==="deg"||n==="rad"||n==="turn"||n==="grad"?{type:_.Hue,value:t*Ho[n]}:void 0}return e[L]==="%"?(L++,{type:_.Percentage,value:+t}):{type:_.Number,value:+t}}function et(e){let t="";for(;/\d/.test(e[L]);)t+=e[L++];return t}function ot(e){let t="";for(;L<e.length&&Uo.test(e[L]);)t+=e[L++];return t}function Vo(e){let t=ot(e);return e[L]==="("?(L++,{type:_.Function,value:t}):t==="none"?{type:_.None,value:void 0}:{type:_.Ident,value:t}}function Go(e=""){let t=e.trim(),n=[],s;for(L=0;L<t.length;){if(s=t[L++],s===`
|
|
2
2
|
`||s===" "||s===" "){for(;L<t.length&&(t[L]===`
|
|
3
3
|
`||t[L]===" "||t[L]===" ");)L++;continue}if(s===",")return;if(s===")"){n.push({type:_.ParenClose});continue}if(s==="+"){if(L--,Qe(t)){n.push(De(t));continue}return}if(s==="-"){if(L--,Qe(t)){n.push(De(t));continue}if(dn(t)){n.push({type:_.Ident,value:ot(t)});continue}return}if(s==="."){if(L--,Qe(t)){n.push(De(t));continue}return}if(s==="/"){for(;L<t.length&&(t[L]===`
|
|
4
|
-
`||t[L]===" "||t[L]===" ");)L++;let a;if(Qe(t)&&(a=De(t),a.type!==_.Hue)){n.push({type:_.Alpha,value:a});continue}if(dn(t)&&ot(t)==="none"){n.push({type:_.Alpha,value:{type:_.None,value:void 0}});continue}return}if(/\d/.test(s)){L--,n.push(De(t));continue}if(cn.test(s)){L--,n.push(Vo(t));continue}return}return n}function qo(e){e._i=0;let t=e[e._i++];if(!t||t.type!==_.Function||t.value!=="color"||(t=e[e._i++],t.type!==_.Ident))return;const n=La[t.value];if(!n)return;const s={mode:n},a=Aa(e,!1);if(!a)return;const i=pt(n).channels;for(let o=0,l,c;o<i.length;o++)l=a[o],c=i[o],l.type!==_.None&&(s[c]=l.type===_.Number?l.value:l.value/100,c==="alpha"&&(s[c]=Math.max(0,Math.min(1,s[c]))));return s}function Aa(e,t){const n=[];let s;for(;e._i<e.length;){if(s=e[e._i++],s.type===_.None||s.type===_.Number||s.type===_.Alpha||s.type===_.Percentage||t&&s.type===_.Hue){n.push(s);continue}if(s.type===_.ParenClose){if(e._i<e.length)return;continue}return}if(!(n.length<3||n.length>4)){if(n.length===4){if(n[3].type!==_.Alpha)return;n[3]=n[3].value}return n.length===3&&n.push({type:_.None,value:void 0}),n.every(a=>a.type!==_.Alpha)?n:void 0}}function Yo(e,t){e._i=0;let n=e[e._i++];if(!n||n.type!==_.Function)return;let s=Aa(e,t);if(s)return s.unshift(n.value),s}const Xo=e=>{if(typeof e!="string")return;const t=Go(e),n=t?Yo(t,!0):void 0;let s,a=0,i=it.length;for(;a<i;)if((s=it[a++](e,n))!==void 0)return s;return t?qo(t):void 0};function Wo(e,t){if(!t||t[0]!=="rgb"&&t[0]!=="rgba")return;const n={mode:"rgb"},[,s,a,i,o]=t;if(!(s.type===_.Hue||a.type===_.Hue||i.type===_.Hue))return s.type!==_.None&&(n.r=s.type===_.Number?s.value/255:s.value/100),a.type!==_.None&&(n.g=a.type===_.Number?a.value/255:a.value/100),i.type!==_.None&&(n.b=i.type===_.Number?i.value/255:i.value/100),o.type!==_.None&&(n.alpha=Math.min(1,Math.max(0,o.type===_.Number?o.value:o.value/100))),n}const Zo=e=>e==="transparent"?{mode:"rgb",r:0,g:0,b:0,alpha:0}:void 0,Ko=(e,t,n)=>e+n*(t-e),Jo=e=>{let t=[];for(let n=0;n<e.length-1;n++){let s=e[n],a=e[n+1];s===void 0&&a===void 0?t.push(void 0):s!==void 0&&a!==void 0?t.push([s,a]):t.push(s!==void 0?[s,s]:[a,a])}return t},Qo=e=>t=>{let n=Jo(t);return s=>{let a=s*n.length,i=s>=1?n.length-1:Math.max(Math.floor(a),0),o=n[i];return o===void 0?void 0:e(o[0],o[1],a-i)}},j=Qo(Ko),J=e=>{let t=!1,n=e.map(s=>s!==void 0?(t=!0,s):1);return t?n:e},ze={mode:"rgb",channels:["r","g","b","alpha"],parse:[Wo,zo,Oo,Lo,Zo,"srgb"],serialize:"srgb",interpolate:{r:j,g:j,b:j,alpha:{use:j,fixup:J}},gamut:!0,white:{r:1,g:1,b:1},black:{r:0,g:0,b:0}},zt=(e=0)=>Math.pow(Math.abs(e),563/256)*Math.sign(e),ys=e=>{let t=zt(e.r),n=zt(e.g),s=zt(e.b),a={mode:"xyz65",x:.5766690429101305*t+.1855582379065463*n+.1882286462349947*s,y:.297344975250536*t+.6273635662554661*n+.0752914584939979*s,z:.0270313613864123*t+.0706888525358272*n+.9913375368376386*s};return e.alpha!==void 0&&(a.alpha=e.alpha),a},$t=e=>Math.pow(Math.abs(e),256/563)*Math.sign(e),_s=({x:e,y:t,z:n,alpha:s})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let a={mode:"a98",r:$t(e*2.0415879038107465-t*.5650069742788597-.3447313507783297*n),g:$t(e*-.9692436362808798+t*1.8759675015077206+.0415550574071756*n),b:$t(e*.0134442806320312-t*.1183623922310184+1.0151749943912058*n)};return s!==void 0&&(a.alpha=s),a},Pt=(e=0)=>{const t=Math.abs(e);return t<=.04045?e/12.92:(Math.sign(e)||1)*Math.pow((t+.055)/1.055,2.4)},$e=({r:e,g:t,b:n,alpha:s})=>{let a={mode:"lrgb",r:Pt(e),g:Pt(t),b:Pt(n)};return s!==void 0&&(a.alpha=s),a},Me=e=>{let{r:t,g:n,b:s,alpha:a}=$e(e),i={mode:"xyz65",x:.4123907992659593*t+.357584339383878*n+.1804807884018343*s,y:.2126390058715102*t+.715168678767756*n+.0721923153607337*s,z:.0193308187155918*t+.119194779794626*n+.9505321522496607*s};return a!==void 0&&(i.alpha=a),i},Dt=(e=0)=>{const t=Math.abs(e);return t>.0031308?(Math.sign(e)||1)*(1.055*Math.pow(t,1/2.4)-.055):e*12.92},Pe=({r:e,g:t,b:n,alpha:s},a="rgb")=>{let i={mode:a,r:Dt(e),g:Dt(t),b:Dt(n)};return s!==void 0&&(i.alpha=s),i},Ce=({x:e,y:t,z:n,alpha:s})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let a=Pe({r:e*3.2409699419045226-t*1.537383177570094-.4986107602930034*n,g:e*-.9692436362808796+t*1.8759675015077204+.0415550574071756*n,b:e*.0556300796969936-t*.2039769588889765+1.0569715142428784*n});return s!==void 0&&(a.alpha=s),a},el={...ze,mode:"a98",parse:["a98-rgb"],serialize:"a98-rgb",fromMode:{rgb:e=>_s(Me(e)),xyz65:_s},toMode:{rgb:e=>Ce(ys(e)),xyz65:ys}},ne=e=>(e=e%360)<0?e+360:e,tl=(e,t)=>e.map((n,s,a)=>{if(n===void 0)return n;let i=ne(n);return s===0||e[s-1]===void 0?i:t(i-ne(a[s-1]))}).reduce((n,s)=>!n.length||s===void 0||n[n.length-1]===void 0?(n.push(s),n):(n.push(s+n[n.length-1]),n),[]),fe=e=>tl(e,t=>Math.abs(t)<=180?t:t-360*Math.sign(t)),te=[-.14861,1.78277,-.29227,-.90649,1.97294,0],nl=Math.PI/180,sl=180/Math.PI;let ws=te[3]*te[4],js=te[1]*te[4],Ns=te[1]*te[2]-te[0]*te[3];const al=({r:e,g:t,b:n,alpha:s})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let a=(Ns*n+e*ws-t*js)/(Ns+ws-js),i=n-a,o=(te[4]*(t-a)-te[2]*i)/te[3],l={mode:"cubehelix",l:a,s:a===0||a===1?void 0:Math.sqrt(i*i+o*o)/(te[4]*a*(1-a))};return l.s&&(l.h=Math.atan2(o,i)*sl-120),s!==void 0&&(l.alpha=s),l},rl=({h:e,s:t,l:n,alpha:s})=>{let a={mode:"rgb"};e=(e===void 0?0:e+120)*nl,n===void 0&&(n=0);let i=t===void 0?0:t*n*(1-n),o=Math.cos(e),l=Math.sin(e);return a.r=n+i*(te[0]*o+te[1]*l),a.g=n+i*(te[2]*o+te[3]*l),a.b=n+i*(te[4]*o+te[5]*l),s!==void 0&&(a.alpha=s),a},bt=(e,t)=>{if(e.h===void 0||t.h===void 0||!e.s||!t.s)return 0;let n=ne(e.h),s=ne(t.h),a=Math.sin((s-n+360)/2*Math.PI/180);return 2*Math.sqrt(e.s*t.s)*a},il=(e,t)=>{if(e.h===void 0||t.h===void 0)return 0;let n=ne(e.h),s=ne(t.h);return Math.abs(s-n)>180?n-(s-360*Math.sign(s-n)):s-n},vt=(e,t)=>{if(e.h===void 0||t.h===void 0||!e.c||!t.c)return 0;let n=ne(e.h),s=ne(t.h),a=Math.sin((s-n+360)/2*Math.PI/180);return 2*Math.sqrt(e.c*t.c)*a},me=e=>{let t=e.reduce((s,a)=>{if(a!==void 0){let i=a*Math.PI/180;s.sin+=Math.sin(i),s.cos+=Math.cos(i)}return s},{sin:0,cos:0}),n=Math.atan2(t.sin,t.cos)*180/Math.PI;return n<0?360+n:n},ol={mode:"cubehelix",channels:["h","s","l","alpha"],parse:["--cubehelix"],serialize:"--cubehelix",ranges:{h:[0,360],s:[0,4.614],l:[0,1]},fromMode:{rgb:al},toMode:{rgb:rl},interpolate:{h:{use:j,fixup:fe},s:j,l:j,alpha:{use:j,fixup:J}},difference:{h:bt},average:{h:me}},ve=({l:e,a:t,b:n,alpha:s},a="lch")=>{t===void 0&&(t=0),n===void 0&&(n=0);let i=Math.sqrt(t*t+n*n),o={mode:a,l:e,c:i};return i&&(o.h=ne(Math.atan2(n,t)*180/Math.PI)),s!==void 0&&(o.alpha=s),o},ye=({l:e,c:t,h:n,alpha:s},a="lab")=>{n===void 0&&(n=0);let i={mode:a,l:e,a:t?t*Math.cos(n/180*Math.PI):0,b:t?t*Math.sin(n/180*Math.PI):0};return s!==void 0&&(i.alpha=s),i},za=Math.pow(29,3)/Math.pow(3,3),$a=Math.pow(6,3)/Math.pow(29,3),Z={X:.3457/.3585,Y:1,Z:(1-.3457-.3585)/.3585},Le={X:.3127/.329,Y:1,Z:(1-.3127-.329)/.329};let Ot=e=>Math.pow(e,3)>$a?Math.pow(e,3):(116*e-16)/za;const Pa=({l:e,a:t,b:n,alpha:s})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let a=(e+16)/116,i=t/500+a,o=a-n/200,l={mode:"xyz65",x:Ot(i)*Le.X,y:Ot(a)*Le.Y,z:Ot(o)*Le.Z};return s!==void 0&&(l.alpha=s),l},yt=e=>Ce(Pa(e)),Ft=e=>e>$a?Math.cbrt(e):(za*e+16)/116,Da=({x:e,y:t,z:n,alpha:s})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let a=Ft(e/Le.X),i=Ft(t/Le.Y),o=Ft(n/Le.Z),l={mode:"lab65",l:116*i-16,a:500*(a-i),b:200*(i-o)};return s!==void 0&&(l.alpha=s),l},_t=e=>{let t=Da(Me(e));return e.r===e.b&&e.b===e.g&&(t.a=t.b=0),t},lt=1,Oa=1,Ue=26/180*Math.PI,ct=Math.cos(Ue),dt=Math.sin(Ue),Fa=100/Math.log(139/100),un=({l:e,c:t,h:n,alpha:s})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let a={mode:"lab65",l:(Math.exp(e*lt/Fa)-1)/.0039},i=(Math.exp(.0435*t*Oa*lt)-1)/.075,o=i*Math.cos(n/180*Math.PI-Ue),l=i*Math.sin(n/180*Math.PI-Ue);return a.a=o*ct-l/.83*dt,a.b=o*dt+l/.83*ct,s!==void 0&&(a.alpha=s),a},fn=({l:e,a:t,b:n,alpha:s})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let a=t*ct+n*dt,i=.83*(n*ct-t*dt),o=Math.sqrt(a*a+i*i),l={mode:"dlch",l:Fa/lt*Math.log(1+.0039*e),c:Math.log(1+.075*o)/(.0435*Oa*lt)};return l.c&&(l.h=ne((Math.atan2(i,a)+Ue)/Math.PI*180)),s!==void 0&&(l.alpha=s),l},ks=e=>un(ve(e,"dlch")),Ms=e=>ye(fn(e),"dlab"),ll={mode:"dlab",parse:["--din99o-lab"],serialize:"--din99o-lab",toMode:{lab65:ks,rgb:e=>yt(ks(e))},fromMode:{lab65:Ms,rgb:e=>Ms(_t(e))},channels:["l","a","b","alpha"],ranges:{l:[0,100],a:[-40.09,45.501],b:[-40.469,44.344]},interpolate:{l:j,a:j,b:j,alpha:{use:j,fixup:J}}},cl={mode:"dlch",parse:["--din99o-lch"],serialize:"--din99o-lch",toMode:{lab65:un,dlab:e=>ye(e,"dlab"),rgb:e=>yt(un(e))},fromMode:{lab65:fn,dlab:e=>ve(e,"dlch"),rgb:e=>fn(_t(e))},channels:["l","c","h","alpha"],ranges:{l:[0,100],c:[0,51.484],h:[0,360]},interpolate:{l:j,c:j,h:{use:j,fixup:fe},alpha:{use:j,fixup:J}},difference:{h:vt},average:{h:me}};function dl({h:e,s:t,i:n,alpha:s}){e=ne(e!==void 0?e:0),t===void 0&&(t=0),n===void 0&&(n=0);let a=Math.abs(e/60%2-1),i;switch(Math.floor(e/60)){case 0:i={r:n*(1+t*(3/(2-a)-1)),g:n*(1+t*(3*(1-a)/(2-a)-1)),b:n*(1-t)};break;case 1:i={r:n*(1+t*(3*(1-a)/(2-a)-1)),g:n*(1+t*(3/(2-a)-1)),b:n*(1-t)};break;case 2:i={r:n*(1-t),g:n*(1+t*(3/(2-a)-1)),b:n*(1+t*(3*(1-a)/(2-a)-1))};break;case 3:i={r:n*(1-t),g:n*(1+t*(3*(1-a)/(2-a)-1)),b:n*(1+t*(3/(2-a)-1))};break;case 4:i={r:n*(1+t*(3*(1-a)/(2-a)-1)),g:n*(1-t),b:n*(1+t*(3/(2-a)-1))};break;case 5:i={r:n*(1+t*(3/(2-a)-1)),g:n*(1-t),b:n*(1+t*(3*(1-a)/(2-a)-1))};break;default:i={r:n*(1-t),g:n*(1-t),b:n*(1-t)}}return i.mode="rgb",s!==void 0&&(i.alpha=s),i}function ul({r:e,g:t,b:n,alpha:s}){e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let a=Math.max(e,t,n),i=Math.min(e,t,n),o={mode:"hsi",s:e+t+n===0?0:1-3*i/(e+t+n),i:(e+t+n)/3};return a-i!==0&&(o.h=(a===e?(t-n)/(a-i)+(t<n)*6:a===t?(n-e)/(a-i)+2:(e-t)/(a-i)+4)*60),s!==void 0&&(o.alpha=s),o}const fl={mode:"hsi",toMode:{rgb:dl},parse:["--hsi"],serialize:"--hsi",fromMode:{rgb:ul},channels:["h","s","i","alpha"],ranges:{h:[0,360]},gamut:"rgb",interpolate:{h:{use:j,fixup:fe},s:j,i:j,alpha:{use:j,fixup:J}},difference:{h:bt},average:{h:me}};function ml({h:e,s:t,l:n,alpha:s}){e=ne(e!==void 0?e:0),t===void 0&&(t=0),n===void 0&&(n=0);let a=n+t*(n<.5?n:1-n),i=a-(a-n)*2*Math.abs(e/60%2-1),o;switch(Math.floor(e/60)){case 0:o={r:a,g:i,b:2*n-a};break;case 1:o={r:i,g:a,b:2*n-a};break;case 2:o={r:2*n-a,g:a,b:i};break;case 3:o={r:2*n-a,g:i,b:a};break;case 4:o={r:i,g:2*n-a,b:a};break;case 5:o={r:a,g:2*n-a,b:i};break;default:o={r:2*n-a,g:2*n-a,b:2*n-a}}return o.mode="rgb",s!==void 0&&(o.alpha=s),o}function hl({r:e,g:t,b:n,alpha:s}){e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let a=Math.max(e,t,n),i=Math.min(e,t,n),o={mode:"hsl",s:a===i?0:(a-i)/(1-Math.abs(a+i-1)),l:.5*(a+i)};return a-i!==0&&(o.h=(a===e?(t-n)/(a-i)+(t<n)*6:a===t?(n-e)/(a-i)+2:(e-t)/(a-i)+4)*60),s!==void 0&&(o.alpha=s),o}const gl=(e,t)=>{switch(t){case"deg":return+e;case"rad":return e/Math.PI*180;case"grad":return e/10*9;case"turn":return e*360}},xl=new RegExp(`^hsla?\\(\\s*${$o}${Ae}${Be}${Ae}${Be}\\s*(?:,\\s*${Bn}\\s*)?\\)$`),pl=e=>{let t=e.match(xl);if(!t)return;let n={mode:"hsl"};return t[3]!==void 0?n.h=+t[3]:t[1]!==void 0&&t[2]!==void 0&&(n.h=gl(t[1],t[2])),t[4]!==void 0&&(n.s=Math.min(Math.max(0,t[4]/100),1)),t[5]!==void 0&&(n.l=Math.min(Math.max(0,t[5]/100),1)),t[6]!==void 0?n.alpha=Math.max(0,Math.min(1,t[6]/100)):t[7]!==void 0&&(n.alpha=Math.max(0,Math.min(1,+t[7]))),n};function bl(e,t){if(!t||t[0]!=="hsl"&&t[0]!=="hsla")return;const n={mode:"hsl"},[,s,a,i,o]=t;if(s.type!==_.None){if(s.type===_.Percentage)return;n.h=s.value}if(a.type!==_.None){if(a.type===_.Hue)return;n.s=a.value/100}if(i.type!==_.None){if(i.type===_.Hue)return;n.l=i.value/100}return o.type!==_.None&&(n.alpha=Math.min(1,Math.max(0,o.type===_.Number?o.value:o.value/100))),n}const Ba={mode:"hsl",toMode:{rgb:ml},fromMode:{rgb:hl},channels:["h","s","l","alpha"],ranges:{h:[0,360]},gamut:"rgb",parse:[bl,pl],serialize:e=>`hsl(${e.h!==void 0?e.h:"none"} ${e.s!==void 0?e.s*100+"%":"none"} ${e.l!==void 0?e.l*100+"%":"none"}${e.alpha<1?` / ${e.alpha}`:""})`,interpolate:{h:{use:j,fixup:fe},s:j,l:j,alpha:{use:j,fixup:J}},difference:{h:bt},average:{h:me}};function Ua({h:e,s:t,v:n,alpha:s}){e=ne(e!==void 0?e:0),t===void 0&&(t=0),n===void 0&&(n=0);let a=Math.abs(e/60%2-1),i;switch(Math.floor(e/60)){case 0:i={r:n,g:n*(1-t*a),b:n*(1-t)};break;case 1:i={r:n*(1-t*a),g:n,b:n*(1-t)};break;case 2:i={r:n*(1-t),g:n,b:n*(1-t*a)};break;case 3:i={r:n*(1-t),g:n*(1-t*a),b:n};break;case 4:i={r:n*(1-t*a),g:n*(1-t),b:n};break;case 5:i={r:n,g:n*(1-t),b:n*(1-t*a)};break;default:i={r:n*(1-t),g:n*(1-t),b:n*(1-t)}}return i.mode="rgb",s!==void 0&&(i.alpha=s),i}function Ha({r:e,g:t,b:n,alpha:s}){e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let a=Math.max(e,t,n),i=Math.min(e,t,n),o={mode:"hsv",s:a===0?0:1-i/a,v:a};return a-i!==0&&(o.h=(a===e?(t-n)/(a-i)+(t<n)*6:a===t?(n-e)/(a-i)+2:(e-t)/(a-i)+4)*60),s!==void 0&&(o.alpha=s),o}const Va={mode:"hsv",toMode:{rgb:Ua},parse:["--hsv"],serialize:"--hsv",fromMode:{rgb:Ha},channels:["h","s","v","alpha"],ranges:{h:[0,360]},gamut:"rgb",interpolate:{h:{use:j,fixup:fe},s:j,v:j,alpha:{use:j,fixup:J}},difference:{h:bt},average:{h:me}};function vl({h:e,w:t,b:n,alpha:s}){if(t===void 0&&(t=0),n===void 0&&(n=0),t+n>1){let a=t+n;t/=a,n/=a}return Ua({h:e,s:n===1?1:1-t/(1-n),v:1-n,alpha:s})}function yl(e){let t=Ha(e);if(t===void 0)return;let n=t.s!==void 0?t.s:0,s=t.v!==void 0?t.v:0,a={mode:"hwb",w:(1-n)*s,b:1-s};return t.h!==void 0&&(a.h=t.h),t.alpha!==void 0&&(a.alpha=t.alpha),a}function _l(e,t){if(!t||t[0]!=="hwb")return;const n={mode:"hwb"},[,s,a,i,o]=t;if(s.type!==_.None){if(s.type===_.Percentage)return;n.h=s.value}if(a.type!==_.None){if(a.type===_.Hue)return;n.w=a.value/100}if(i.type!==_.None){if(i.type===_.Hue)return;n.b=i.value/100}return o.type!==_.None&&(n.alpha=Math.min(1,Math.max(0,o.type===_.Number?o.value:o.value/100))),n}const wl={mode:"hwb",toMode:{rgb:vl},fromMode:{rgb:yl},channels:["h","w","b","alpha"],ranges:{h:[0,360]},gamut:"rgb",parse:[_l],serialize:e=>`hwb(${e.h!==void 0?e.h:"none"} ${e.w!==void 0?e.w*100+"%":"none"} ${e.b!==void 0?e.b*100+"%":"none"}${e.alpha<1?` / ${e.alpha}`:""})`,interpolate:{h:{use:j,fixup:fe},w:j,b:j,alpha:{use:j,fixup:J}},difference:{h:il},average:{h:me}},Ga=203,wt=.1593017578125,qa=78.84375,jt=.8359375,Nt=18.8515625,kt=18.6875;function Bt(e){if(e<0)return 0;const t=Math.pow(e,1/qa);return 1e4*Math.pow(Math.max(0,t-jt)/(Nt-kt*t),1/wt)}function Ut(e){if(e<0)return 0;const t=Math.pow(e/1e4,wt);return Math.pow((jt+Nt*t)/(1+kt*t),qa)}const Ht=e=>Math.max(e/Ga,0),Cs=({i:e,t,p:n,alpha:s})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);const a=Bt(e+.008609037037932761*t+.11102962500302593*n),i=Bt(e-.00860903703793275*t-.11102962500302599*n),o=Bt(e+.5600313357106791*t-.32062717498731885*n),l={mode:"xyz65",x:Ht(2.070152218389422*a-1.3263473389671556*i+.2066510476294051*o),y:Ht(.3647385209748074*a+.680566024947227*i-.0453045459220346*o),z:Ht(-.049747207535812*a-.0492609666966138*i+1.1880659249923042*o)};return s!==void 0&&(l.alpha=s),l},Vt=(e=0)=>Math.max(e*Ga,0),Ss=({x:e,y:t,z:n,alpha:s})=>{const a=Vt(e),i=Vt(t),o=Vt(n),l=Ut(.3592832590121217*a+.6976051147779502*i-.0358915932320289*o),c=Ut(-.1920808463704995*a+1.1004767970374323*i+.0753748658519118*o),f=Ut(.0070797844607477*a+.0748396662186366*i+.8433265453898765*o),m=.5*l+.5*c,u=1.61376953125*l-3.323486328125*c+1.709716796875*f,h=4.378173828125*l-4.24560546875*c-.132568359375*f,d={mode:"itp",i:m,t:u,p:h};return s!==void 0&&(d.alpha=s),d},jl={mode:"itp",channels:["i","t","p","alpha"],parse:["--ictcp"],serialize:"--ictcp",toMode:{xyz65:Cs,rgb:e=>Ce(Cs(e))},fromMode:{xyz65:Ss,rgb:e=>Ss(Me(e))},ranges:{i:[0,.581],t:[-.369,.272],p:[-.164,.331]},interpolate:{i:j,t:j,p:j,alpha:{use:j,fixup:J}}},Nl=134.03437499999998,kl=16295499532821565e-27,Gt=e=>{if(e<0)return 0;let t=Math.pow(e/1e4,wt);return Math.pow((jt+Nt*t)/(1+kt*t),Nl)},qt=(e=0)=>Math.max(e*203,0),Ya=({x:e,y:t,z:n,alpha:s})=>{e=qt(e),t=qt(t),n=qt(n);let a=1.15*e-.15*n,i=.66*t+.34*e,o=Gt(.41478972*a+.579999*i+.014648*n),l=Gt(-.20151*a+1.120649*i+.0531008*n),c=Gt(-.0166008*a+.2648*i+.6684799*n),f=(o+l)/2,m={mode:"jab",j:.44*f/(1-.56*f)-kl,a:3.524*o-4.066708*l+.542708*c,b:.199076*o+1.096799*l-1.295875*c};return s!==void 0&&(m.alpha=s),m},Ml=134.03437499999998,Es=16295499532821565e-27,Yt=e=>{if(e<0)return 0;let t=Math.pow(e,1/Ml);return 1e4*Math.pow((jt-t)/(kt*t-Nt),1/wt)},Xt=e=>e/203,Xa=({j:e,a:t,b:n,alpha:s})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let a=(e+Es)/(.44+.56*(e+Es)),i=Yt(a+.13860504*t+.058047316*n),o=Yt(a-.13860504*t-.058047316*n),l=Yt(a-.096019242*t-.8118919*n),c={mode:"xyz65",x:Xt(1.661373024652174*i-.914523081304348*o+.23136208173913045*l),y:Xt(-.3250758611844533*i+1.571847026732543*o-.21825383453227928*l),z:Xt(-.090982811*i-.31272829*o+1.5227666*l)};return s!==void 0&&(c.alpha=s),c},Wa=e=>{let t=Ya(Me(e));return e.r===e.b&&e.b===e.g&&(t.a=t.b=0),t},Za=e=>Ce(Xa(e)),Cl={mode:"jab",channels:["j","a","b","alpha"],parse:["--jzazbz"],serialize:"--jzazbz",fromMode:{rgb:Wa,xyz65:Ya},toMode:{rgb:Za,xyz65:Xa},ranges:{j:[0,.222],a:[-.109,.129],b:[-.185,.134]},interpolate:{j,a:j,b:j,alpha:{use:j,fixup:J}}},Ts=({j:e,a:t,b:n,alpha:s})=>{t===void 0&&(t=0),n===void 0&&(n=0);let a=Math.sqrt(t*t+n*n),i={mode:"jch",j:e,c:a};return a&&(i.h=ne(Math.atan2(n,t)*180/Math.PI)),s!==void 0&&(i.alpha=s),i},Is=({j:e,c:t,h:n,alpha:s})=>{n===void 0&&(n=0);let a={mode:"jab",j:e,a:t?t*Math.cos(n/180*Math.PI):0,b:t?t*Math.sin(n/180*Math.PI):0};return s!==void 0&&(a.alpha=s),a},Sl={mode:"jch",parse:["--jzczhz"],serialize:"--jzczhz",toMode:{jab:Is,rgb:e=>Za(Is(e))},fromMode:{rgb:e=>Ts(Wa(e)),jab:Ts},channels:["j","c","h","alpha"],ranges:{j:[0,.221],c:[0,.19],h:[0,360]},interpolate:{h:{use:j,fixup:fe},c:j,j,alpha:{use:j,fixup:J}},difference:{h:vt},average:{h:me}},Mt=Math.pow(29,3)/Math.pow(3,3),Un=Math.pow(6,3)/Math.pow(29,3);let Wt=e=>Math.pow(e,3)>Un?Math.pow(e,3):(116*e-16)/Mt;const Hn=({l:e,a:t,b:n,alpha:s})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let a=(e+16)/116,i=t/500+a,o=a-n/200,l={mode:"xyz50",x:Wt(i)*Z.X,y:Wt(a)*Z.Y,z:Wt(o)*Z.Z};return s!==void 0&&(l.alpha=s),l},Xe=({x:e,y:t,z:n,alpha:s})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let a=Pe({r:e*3.1341359569958707-t*1.6173863321612538-.4906619460083532*n,g:e*-.978795502912089+t*1.916254567259524+.03344273116131949*n,b:e*.07195537988411677-t*.2289768264158322+1.405386058324125*n});return s!==void 0&&(a.alpha=s),a},Ka=e=>Xe(Hn(e)),We=e=>{let{r:t,g:n,b:s,alpha:a}=$e(e),i={mode:"xyz50",x:.436065742824811*t+.3851514688337912*n+.14307845442264197*s,y:.22249319175623702*t+.7168870538238823*n+.06061979053616537*s,z:.013923904500943465*t+.09708128566574634*n+.7140993584005155*s};return a!==void 0&&(i.alpha=a),i},Zt=e=>e>Un?Math.cbrt(e):(Mt*e+16)/116,Vn=({x:e,y:t,z:n,alpha:s})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let a=Zt(e/Z.X),i=Zt(t/Z.Y),o=Zt(n/Z.Z),l={mode:"lab",l:116*i-16,a:500*(a-i),b:200*(i-o)};return s!==void 0&&(l.alpha=s),l},Ja=e=>{let t=Vn(We(e));return e.r===e.b&&e.b===e.g&&(t.a=t.b=0),t};function El(e,t){if(!t||t[0]!=="lab")return;const n={mode:"lab"},[,s,a,i,o]=t;if(!(s.type===_.Hue||a.type===_.Hue||i.type===_.Hue))return s.type!==_.None&&(n.l=Math.min(Math.max(0,s.value),100)),a.type!==_.None&&(n.a=a.type===_.Number?a.value:a.value*125/100),i.type!==_.None&&(n.b=i.type===_.Number?i.value:i.value*125/100),o.type!==_.None&&(n.alpha=Math.min(1,Math.max(0,o.type===_.Number?o.value:o.value/100))),n}const Gn={mode:"lab",toMode:{xyz50:Hn,rgb:Ka},fromMode:{xyz50:Vn,rgb:Ja},channels:["l","a","b","alpha"],ranges:{l:[0,100],a:[-125,125],b:[-125,125]},parse:[El],serialize:e=>`lab(${e.l!==void 0?e.l:"none"} ${e.a!==void 0?e.a:"none"} ${e.b!==void 0?e.b:"none"}${e.alpha<1?` / ${e.alpha}`:""})`,interpolate:{l:j,a:j,b:j,alpha:{use:j,fixup:J}}},Tl={...Gn,mode:"lab65",parse:["--lab-d65"],serialize:"--lab-d65",toMode:{xyz65:Pa,rgb:yt},fromMode:{xyz65:Da,rgb:_t},ranges:{l:[0,100],a:[-125,125],b:[-125,125]}};function Il(e,t){if(!t||t[0]!=="lch")return;const n={mode:"lch"},[,s,a,i,o]=t;if(s.type!==_.None){if(s.type===_.Hue)return;n.l=Math.min(Math.max(0,s.value),100)}if(a.type!==_.None&&(n.c=Math.max(0,a.type===_.Number?a.value:a.value*150/100)),i.type!==_.None){if(i.type===_.Percentage)return;n.h=i.value}return o.type!==_.None&&(n.alpha=Math.min(1,Math.max(0,o.type===_.Number?o.value:o.value/100))),n}const qn={mode:"lch",toMode:{lab:ye,rgb:e=>Ka(ye(e))},fromMode:{rgb:e=>ve(Ja(e)),lab:ve},channels:["l","c","h","alpha"],ranges:{l:[0,100],c:[0,150],h:[0,360]},parse:[Il],serialize:e=>`lch(${e.l!==void 0?e.l:"none"} ${e.c!==void 0?e.c:"none"} ${e.h!==void 0?e.h:"none"}${e.alpha<1?` / ${e.alpha}`:""})`,interpolate:{h:{use:j,fixup:fe},c:j,l:j,alpha:{use:j,fixup:J}},difference:{h:vt},average:{h:me}},Rl={...qn,mode:"lch65",parse:["--lch-d65"],serialize:"--lch-d65",toMode:{lab65:e=>ye(e,"lab65"),rgb:e=>yt(ye(e,"lab65"))},fromMode:{rgb:e=>ve(_t(e),"lch65"),lab65:e=>ve(e,"lch65")},ranges:{l:[0,100],c:[0,150],h:[0,360]}},Qa=({l:e,u:t,v:n,alpha:s})=>{t===void 0&&(t=0),n===void 0&&(n=0);let a=Math.sqrt(t*t+n*n),i={mode:"lchuv",l:e,c:a};return a&&(i.h=ne(Math.atan2(n,t)*180/Math.PI)),s!==void 0&&(i.alpha=s),i},er=({l:e,c:t,h:n,alpha:s})=>{n===void 0&&(n=0);let a={mode:"luv",l:e,u:t?t*Math.cos(n/180*Math.PI):0,v:t?t*Math.sin(n/180*Math.PI):0};return s!==void 0&&(a.alpha=s),a},tr=(e,t,n)=>4*e/(e+15*t+3*n),nr=(e,t,n)=>9*t/(e+15*t+3*n),Ll=tr(Z.X,Z.Y,Z.Z),Al=nr(Z.X,Z.Y,Z.Z),zl=e=>e<=Un?Mt*e:116*Math.cbrt(e)-16,mn=({x:e,y:t,z:n,alpha:s})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let a=zl(t/Z.Y),i=tr(e,t,n),o=nr(e,t,n);!isFinite(i)||!isFinite(o)?a=i=o=0:(i=13*a*(i-Ll),o=13*a*(o-Al));let l={mode:"luv",l:a,u:i,v:o};return s!==void 0&&(l.alpha=s),l},$l=(e,t,n)=>4*e/(e+15*t+3*n),Pl=(e,t,n)=>9*t/(e+15*t+3*n),Dl=$l(Z.X,Z.Y,Z.Z),Ol=Pl(Z.X,Z.Y,Z.Z),hn=({l:e,u:t,v:n,alpha:s})=>{if(e===void 0&&(e=0),e===0)return{mode:"xyz50",x:0,y:0,z:0};t===void 0&&(t=0),n===void 0&&(n=0);let a=t/(13*e)+Dl,i=n/(13*e)+Ol,o=Z.Y*(e<=8?e/Mt:Math.pow((e+16)/116,3)),l=o*(9*a)/(4*i),c=o*(12-3*a-20*i)/(4*i),f={mode:"xyz50",x:l,y:o,z:c};return s!==void 0&&(f.alpha=s),f},Fl=e=>Qa(mn(We(e))),Bl=e=>Xe(hn(er(e))),Ul={mode:"lchuv",toMode:{luv:er,rgb:Bl},fromMode:{rgb:Fl,luv:Qa},channels:["l","c","h","alpha"],parse:["--lchuv"],serialize:"--lchuv",ranges:{l:[0,100],c:[0,176.956],h:[0,360]},interpolate:{h:{use:j,fixup:fe},c:j,l:j,alpha:{use:j,fixup:J}},difference:{h:vt},average:{h:me}},Hl={...ze,mode:"lrgb",toMode:{rgb:Pe},fromMode:{rgb:$e},parse:["srgb-linear"],serialize:"srgb-linear"},Vl={mode:"luv",toMode:{xyz50:hn,rgb:e=>Xe(hn(e))},fromMode:{xyz50:mn,rgb:e=>mn(We(e))},channels:["l","u","v","alpha"],parse:["--luv"],serialize:"--luv",ranges:{l:[0,100],u:[-84.936,175.042],v:[-125.882,87.243]},interpolate:{l:j,u:j,v:j,alpha:{use:j,fixup:J}}},sr=({r:e,g:t,b:n,alpha:s})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let a=Math.cbrt(.412221469470763*e+.5363325372617348*t+.0514459932675022*n),i=Math.cbrt(.2119034958178252*e+.6806995506452344*t+.1073969535369406*n),o=Math.cbrt(.0883024591900564*e+.2817188391361215*t+.6299787016738222*n),l={mode:"oklab",l:.210454268309314*a+.7936177747023054*i-.0040720430116193*o,a:1.9779985324311684*a-2.42859224204858*i+.450593709617411*o,b:.0259040424655478*a+.7827717124575296*i-.8086757549230774*o};return s!==void 0&&(l.alpha=s),l},Ct=e=>{let t=sr($e(e));return e.r===e.b&&e.b===e.g&&(t.a=t.b=0),t},Ze=({l:e,a:t,b:n,alpha:s})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let a=Math.pow(e+.3963377773761749*t+.2158037573099136*n,3),i=Math.pow(e-.1055613458156586*t-.0638541728258133*n,3),o=Math.pow(e-.0894841775298119*t-1.2914855480194092*n,3),l={mode:"lrgb",r:4.076741636075957*a-3.3077115392580616*i+.2309699031821044*o,g:-1.2684379732850317*a+2.6097573492876887*i-.3413193760026573*o,b:-.0041960761386756*a-.7034186179359362*i+1.7076146940746117*o};return s!==void 0&&(l.alpha=s),l},St=e=>Pe(Ze(e));function gn(e){const s=1.170873786407767;return .5*(s*e-.206+Math.sqrt((s*e-.206)*(s*e-.206)+4*.03*s*e))}function ut(e){return(e*e+.206*e)/(1.170873786407767*(e+.03))}function Gl(e,t){let n,s,a,i,o,l,c,f;-1.88170328*e-.80936493*t>1?(n=1.19086277,s=1.76576728,a=.59662641,i=.75515197,o=.56771245,l=4.0767416621,c=-3.3077115913,f=.2309699292):1.81444104*e-1.19445276*t>1?(n=.73956515,s=-.45954404,a=.08285427,i=.1254107,o=.14503204,l=-1.2684380046,c=2.6097574011,f=-.3413193965):(n=1.35733652,s=-.00915799,a=-1.1513021,i=-.50559606,o=.00692167,l=-.0041960863,c=-.7034186147,f=1.707614701);let m=n+s*e+a*t+i*e*e+o*e*t,u=.3963377774*e+.2158037573*t,h=-.1055613458*e-.0638541728*t,d=-.0894841775*e-1.291485548*t;{let v=1+m*u,y=1+m*h,x=1+m*d,p=v*v*v,b=y*y*y,w=x*x*x,C=3*u*v*v,I=3*h*y*y,F=3*d*x*x,P=6*u*u*v,B=6*h*h*y,H=6*d*d*x,z=l*p+c*b+f*w,E=l*C+c*I+f*F,D=l*P+c*B+f*H;m=m-z*E/(E*E-.5*z*D)}return m}function Yn(e,t){let n=Gl(e,t),s=Ze({l:1,a:n*e,b:n*t}),a=Math.cbrt(1/Math.max(s.r,s.g,s.b)),i=a*n;return[a,i]}function ql(e,t,n,s,a,i=null){i||(i=Yn(e,t));let o;if((n-a)*i[1]-(i[0]-a)*s<=0)o=i[1]*a/(s*i[0]+i[1]*(a-n));else{o=i[1]*(a-1)/(s*(i[0]-1)+i[1]*(a-n));{let l=n-a,c=s,f=.3963377774*e+.2158037573*t,m=-.1055613458*e-.0638541728*t,u=-.0894841775*e-1.291485548*t,h=l+c*f,d=l+c*m,v=l+c*u;{let y=a*(1-o)+o*n,x=o*s,p=y+x*f,b=y+x*m,w=y+x*u,C=p*p*p,I=b*b*b,F=w*w*w,P=3*h*p*p,B=3*d*b*b,H=3*v*w*w,z=6*h*h*p,E=6*d*d*b,D=6*v*v*w,T=4.0767416621*C-3.3077115913*I+.2309699292*F-1,R=4.0767416621*P-3.3077115913*B+.2309699292*H,A=4.0767416621*z-3.3077115913*E+.2309699292*D,$=R/(R*R-.5*T*A),V=-T*$,q=-1.2684380046*C+2.6097574011*I-.3413193965*F-1,W=-1.2684380046*P+2.6097574011*B-.3413193965*H,ae=-1.2684380046*z+2.6097574011*E-.3413193965*D,Q=W/(W*W-.5*q*ae),k=-q*Q,O=-.0041960863*C-.7034186147*I+1.707614701*F-1,X=-.0041960863*P-.7034186147*B+1.707614701*H,ee=-.0041960863*z-.7034186147*E+1.707614701*D,re=X/(X*X-.5*O*ee),K=-O*re;V=$>=0?V:1e6,k=Q>=0?k:1e6,K=re>=0?K:1e6,o+=Math.min(V,Math.min(k,K))}}}return o}function Xn(e,t,n=null){n||(n=Yn(e,t));let s=n[0],a=n[1];return[a/s,a/(1-s)]}function ar(e,t,n){let s=Yn(t,n),a=ql(t,n,e,1,e,s),i=Xn(t,n,s),o=.11516993+1/(7.4477897+4.1590124*n+t*(-2.19557347+1.75198401*n+t*(-2.13704948-10.02301043*n+t*(-4.24894561+5.38770819*n+4.69891013*t)))),l=.11239642+1/(1.6132032-.68124379*n+t*(.40370612+.90148123*n+t*(-.27087943+.6122399*n+t*(.00299215-.45399568*n-.14661872*t)))),c=a/Math.min(e*i[0],(1-e)*i[1]),f=e*o,m=(1-e)*l,u=.9*c*Math.sqrt(Math.sqrt(1/(1/(f*f*f*f)+1/(m*m*m*m))));return f=e*.4,m=(1-e)*.8,[Math.sqrt(1/(1/(f*f)+1/(m*m))),u,a]}function Rs(e){const t=e.l!==void 0?e.l:0,n=e.a!==void 0?e.a:0,s=e.b!==void 0?e.b:0,a={mode:"okhsl",l:gn(t)};e.alpha!==void 0&&(a.alpha=e.alpha);let i=Math.sqrt(n*n+s*s);if(!i)return a.s=0,a;let[o,l,c]=ar(t,n/i,s/i),f;if(i<l){let m=0,u=.8*o,h=1-u/l;f=(i-m)/(u+h*(i-m))*.8}else{let m=l,u=.2*l*l*1.25*1.25/o,h=1-u/(c-l);f=.8+.2*((i-m)/(u+h*(i-m)))}return f&&(a.s=f,a.h=ne(Math.atan2(s,n)*180/Math.PI)),a}function Ls(e){let t=e.h!==void 0?e.h:0,n=e.s!==void 0?e.s:0,s=e.l!==void 0?e.l:0;const a={mode:"oklab",l:ut(s)};if(e.alpha!==void 0&&(a.alpha=e.alpha),!n||s===1)return a.a=a.b=0,a;let i=Math.cos(t/180*Math.PI),o=Math.sin(t/180*Math.PI),[l,c,f]=ar(a.l,i,o),m,u,h,d;n<.8?(m=1.25*n,u=0,h=.8*l,d=1-h/c):(m=5*(n-.8),u=c,h=.2*c*c*1.25*1.25/l,d=1-h/(f-c));let v=u+m*h/(1-d*m);return a.a=v*i,a.b=v*o,a}const Yl={...Ba,mode:"okhsl",channels:["h","s","l","alpha"],parse:["--okhsl"],serialize:"--okhsl",fromMode:{oklab:Rs,rgb:e=>Rs(Ct(e))},toMode:{oklab:Ls,rgb:e=>St(Ls(e))}};function As(e){let t=e.l!==void 0?e.l:0,n=e.a!==void 0?e.a:0,s=e.b!==void 0?e.b:0,a=Math.sqrt(n*n+s*s),i=a?n/a:1,o=a?s/a:1,[l,c]=Xn(i,o),f=.5,m=1-f/l,u=c/(a+t*c),h=u*t,d=u*a,v=ut(h),y=d*v/h,x=Ze({l:v,a:i*y,b:o*y}),p=Math.cbrt(1/Math.max(x.r,x.g,x.b,0));t=t/p,a=a/p*gn(t)/t,t=gn(t);const b={mode:"okhsv",s:a?(f+c)*d/(c*f+c*m*d):0,v:t?t/h:0};return b.s&&(b.h=ne(Math.atan2(s,n)*180/Math.PI)),e.alpha!==void 0&&(b.alpha=e.alpha),b}function zs(e){const t={mode:"oklab"};e.alpha!==void 0&&(t.alpha=e.alpha);const n=e.h!==void 0?e.h:0,s=e.s!==void 0?e.s:0,a=e.v!==void 0?e.v:0,i=Math.cos(n/180*Math.PI),o=Math.sin(n/180*Math.PI),[l,c]=Xn(i,o),f=.5,m=1-f/l,u=1-s*f/(f+c-c*m*s),h=s*c*f/(f+c-c*m*s),d=ut(u),v=h*d/u,y=Ze({l:d,a:i*v,b:o*v}),x=Math.cbrt(1/Math.max(y.r,y.g,y.b,0)),p=ut(a*u),b=h*p/u;return t.l=p*x,t.a=b*i*x,t.b=b*o*x,t}const Xl={...Va,mode:"okhsv",channels:["h","s","v","alpha"],parse:["--okhsv"],serialize:"--okhsv",fromMode:{oklab:As,rgb:e=>As(Ct(e))},toMode:{oklab:zs,rgb:e=>St(zs(e))}};function Wl(e,t){if(!t||t[0]!=="oklab")return;const n={mode:"oklab"},[,s,a,i,o]=t;if(!(s.type===_.Hue||a.type===_.Hue||i.type===_.Hue))return s.type!==_.None&&(n.l=Math.min(Math.max(0,s.type===_.Number?s.value:s.value/100),1)),a.type!==_.None&&(n.a=a.type===_.Number?a.value:a.value*.4/100),i.type!==_.None&&(n.b=i.type===_.Number?i.value:i.value*.4/100),o.type!==_.None&&(n.alpha=Math.min(1,Math.max(0,o.type===_.Number?o.value:o.value/100))),n}const Zl={...Gn,mode:"oklab",toMode:{lrgb:Ze,rgb:St},fromMode:{lrgb:sr,rgb:Ct},ranges:{l:[0,1],a:[-.4,.4],b:[-.4,.4]},parse:[Wl],serialize:e=>`oklab(${e.l!==void 0?e.l:"none"} ${e.a!==void 0?e.a:"none"} ${e.b!==void 0?e.b:"none"}${e.alpha<1?` / ${e.alpha}`:""})`};function Kl(e,t){if(!t||t[0]!=="oklch")return;const n={mode:"oklch"},[,s,a,i,o]=t;if(s.type!==_.None){if(s.type===_.Hue)return;n.l=Math.min(Math.max(0,s.type===_.Number?s.value:s.value/100),1)}if(a.type!==_.None&&(n.c=Math.max(0,a.type===_.Number?a.value:a.value*.4/100)),i.type!==_.None){if(i.type===_.Percentage)return;n.h=i.value}return o.type!==_.None&&(n.alpha=Math.min(1,Math.max(0,o.type===_.Number?o.value:o.value/100))),n}const Jl={...qn,mode:"oklch",toMode:{oklab:e=>ye(e,"oklab"),rgb:e=>St(ye(e,"oklab"))},fromMode:{rgb:e=>ve(Ct(e),"oklch"),oklab:e=>ve(e,"oklch")},parse:[Kl],serialize:e=>`oklch(${e.l!==void 0?e.l:"none"} ${e.c!==void 0?e.c:"none"} ${e.h!==void 0?e.h:"none"}${e.alpha<1?` / ${e.alpha}`:""})`,ranges:{l:[0,1],c:[0,.4],h:[0,360]}},$s=e=>{let{r:t,g:n,b:s,alpha:a}=$e(e),i={mode:"xyz65",x:.486570948648216*t+.265667693169093*n+.1982172852343625*s,y:.2289745640697487*t+.6917385218365062*n+.079286914093745*s,z:0*t+.0451133818589026*n+1.043944368900976*s};return a!==void 0&&(i.alpha=a),i},Ps=({x:e,y:t,z:n,alpha:s})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let a=Pe({r:e*2.4934969119414263-t*.9313836179191242-.402710784450717*n,g:e*-.8294889695615749+t*1.7626640603183465+.0236246858419436*n,b:e*.0358458302437845-t*.0761723892680418+.9568845240076871*n},"p3");return s!==void 0&&(a.alpha=s),a},Ql={...ze,mode:"p3",parse:["display-p3"],serialize:"display-p3",fromMode:{rgb:e=>Ps(Me(e)),xyz65:Ps},toMode:{rgb:e=>Ce($s(e)),xyz65:$s}},Kt=e=>{let t=Math.abs(e);return t>=1/512?Math.sign(e)*Math.pow(t,1/1.8):16*e},Ds=({x:e,y:t,z:n,alpha:s})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let a={mode:"prophoto",r:Kt(e*1.3457868816471585-t*.2555720873797946-.0511018649755453*n),g:Kt(e*-.5446307051249019+t*1.5082477428451466+.0205274474364214*n),b:Kt(e*0+t*0+1.2119675456389452*n)};return s!==void 0&&(a.alpha=s),a},Jt=(e=0)=>{let t=Math.abs(e);return t>=16/512?Math.sign(e)*Math.pow(t,1.8):e/16},Os=e=>{let t=Jt(e.r),n=Jt(e.g),s=Jt(e.b),a={mode:"xyz50",x:.7977666449006423*t+.1351812974005331*n+.0313477341283922*s,y:.2880748288194013*t+.7118352342418731*n+899369387256e-16*s,z:0*t+0*n+.8251046025104602*s};return e.alpha!==void 0&&(a.alpha=e.alpha),a},ec={...ze,mode:"prophoto",parse:["prophoto-rgb"],serialize:"prophoto-rgb",fromMode:{xyz50:Ds,rgb:e=>Ds(We(e))},toMode:{xyz50:Os,rgb:e=>Xe(Os(e))}},Fs=1.09929682680944,tc=.018053968510807,Qt=e=>{const t=Math.abs(e);return t>tc?(Math.sign(e)||1)*(Fs*Math.pow(t,.45)-(Fs-1)):4.5*e},Bs=({x:e,y:t,z:n,alpha:s})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let a={mode:"rec2020",r:Qt(e*1.7166511879712683-t*.3556707837763925-.2533662813736599*n),g:Qt(e*-.6666843518324893+t*1.6164812366349395+.0157685458139111*n),b:Qt(e*.0176398574453108-t*.0427706132578085+.9421031212354739*n)};return s!==void 0&&(a.alpha=s),a},Us=1.09929682680944,nc=.018053968510807,en=(e=0)=>{let t=Math.abs(e);return t<nc*4.5?e/4.5:(Math.sign(e)||1)*Math.pow((t+Us-1)/Us,1/.45)},Hs=e=>{let t=en(e.r),n=en(e.g),s=en(e.b),a={mode:"xyz65",x:.6369580483012911*t+.1446169035862083*n+.1688809751641721*s,y:.262700212011267*t+.6779980715188708*n+.059301716469862*s,z:0*t+.0280726930490874*n+1.0609850577107909*s};return e.alpha!==void 0&&(a.alpha=e.alpha),a},sc={...ze,mode:"rec2020",fromMode:{xyz65:Bs,rgb:e=>Bs(Me(e))},toMode:{xyz65:Hs,rgb:e=>Ce(Hs(e))},parse:["rec2020"],serialize:"rec2020"},je=.0037930732552754493,rr=Math.cbrt(je),tn=e=>Math.cbrt(e)-rr,ac=e=>{const{r:t,g:n,b:s,alpha:a}=$e(e),i=tn(.3*t+.622*n+.078*s+je),o=tn(.23*t+.692*n+.078*s+je),l=tn(.2434226892454782*t+.2047674442449682*n+.5518098665095535*s+je),c={mode:"xyb",x:(i-o)/2,y:(i+o)/2,b:l-(i+o)/2};return a!==void 0&&(c.alpha=a),c},nn=e=>Math.pow(e+rr,3),rc=({x:e,y:t,b:n,alpha:s})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);const a=nn(e+t)-je,i=nn(t-e)-je,o=nn(n+t)-je,l=Pe({r:11.031566904639861*a-9.866943908131562*i-.16462299650829934*o,g:-3.2541473810744237*a+4.418770377582723*i-.16462299650829934*o,b:-3.6588512867136815*a+2.7129230459360922*i+1.9459282407775895*o});return s!==void 0&&(l.alpha=s),l},ic={mode:"xyb",channels:["x","y","b","alpha"],parse:["--xyb"],serialize:"--xyb",toMode:{rgb:rc},fromMode:{rgb:ac},ranges:{x:[-.0154,.0281],y:[0,.8453],b:[-.2778,.388]},interpolate:{x:j,y:j,b:j,alpha:{use:j,fixup:J}}},oc={mode:"xyz50",parse:["xyz-d50"],serialize:"xyz-d50",toMode:{rgb:Xe,lab:Vn},fromMode:{rgb:We,lab:Hn},channels:["x","y","z","alpha"],ranges:{x:[0,.964],y:[0,.999],z:[0,.825]},interpolate:{x:j,y:j,z:j,alpha:{use:j,fixup:J}}},lc=e=>{let{x:t,y:n,z:s,alpha:a}=e;t===void 0&&(t=0),n===void 0&&(n=0),s===void 0&&(s=0);let i={mode:"xyz50",x:1.0479298208405488*t+.0229467933410191*n-.0501922295431356*s,y:.0296278156881593*t+.990434484573249*n-.0170738250293851*s,z:-.0092430581525912*t+.0150551448965779*n+.7518742899580008*s};return a!==void 0&&(i.alpha=a),i},cc=e=>{let{x:t,y:n,z:s,alpha:a}=e;t===void 0&&(t=0),n===void 0&&(n=0),s===void 0&&(s=0);let i={mode:"xyz65",x:.9554734527042182*t-.0230985368742614*n+.0632593086610217*s,y:-.0283697069632081*t+1.0099954580058226*n+.021041398966943*s,z:.0123140016883199*t-.0205076964334779*n+1.3303659366080753*s};return a!==void 0&&(i.alpha=a),i},dc={mode:"xyz65",toMode:{rgb:Ce,xyz50:lc},fromMode:{rgb:Me,xyz50:cc},ranges:{x:[0,.95],y:[0,1],z:[0,1.088]},channels:["x","y","z","alpha"],parse:["xyz","xyz-d65"],serialize:"xyz-d65",interpolate:{x:j,y:j,z:j,alpha:{use:j,fixup:J}}},uc=({r:e,g:t,b:n,alpha:s})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);const a={mode:"yiq",y:.29889531*e+.58662247*t+.11448223*n,i:.59597799*e-.2741761*t-.32180189*n,q:.21147017*e-.52261711*t+.31114694*n};return s!==void 0&&(a.alpha=s),a},fc=({y:e,i:t,q:n,alpha:s})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);const a={mode:"rgb",r:e+.95608445*t+.6208885*n,g:e-.27137664*t-.6486059*n,b:e-1.10561724*t+1.70250126*n};return s!==void 0&&(a.alpha=s),a},mc={mode:"yiq",toMode:{rgb:fc},fromMode:{rgb:uc},channels:["y","i","q","alpha"],parse:["--yiq"],serialize:"--yiq",ranges:{i:[-.595,.595],q:[-.522,.522]},interpolate:{y:j,i:j,q:j,alpha:{use:j,fixup:J}}},hc=e=>Math.max(0,Math.min(1,e||0)),sn=e=>Math.round(hc(e)*255),gc=ce("rgb"),xc=e=>{if(e===void 0)return;let t=sn(e.r),n=sn(e.g),s=sn(e.b);return"#"+(1<<24|t<<16|n<<8|s).toString(16).slice(1)},pc=e=>xc(gc(e)),ir=ce("rgb"),or=e=>{const t={mode:e.mode,r:Math.max(0,Math.min(e.r!==void 0?e.r:0,1)),g:Math.max(0,Math.min(e.g!==void 0?e.g:0,1)),b:Math.max(0,Math.min(e.b!==void 0?e.b:0,1))};return e.alpha!==void 0&&(t.alpha=e.alpha),t},bc=e=>or(ir(e)),lr=e=>e!==void 0&&(e.r===void 0||e.r>=0&&e.r<=1)&&(e.g===void 0||e.g>=0&&e.g<=1)&&(e.b===void 0||e.b>=0&&e.b<=1);function vc(e){return lr(ir(e))}function cr(e="rgb"){const{gamut:t}=pt(e);if(!t)return s=>!0;const n=ce(typeof t=="string"?t:e);return s=>lr(n(s))}function yc(e="rgb"){const{gamut:t}=pt(e);if(!t)return i=>rt(i);const n=typeof t=="string"?t:e,s=ce(n),a=cr(n);return i=>{const o=rt(i);if(!o)return;const l=s(o);if(a(l))return o;const c=or(l);return o.mode===c.mode?c:ce(o.mode)(c)}}function _c(e,t="lch",n="rgb"){e=rt(e);let s=n==="rgb"?vc:cr(n),a=n==="rgb"?bc:yc(n);if(e===void 0||s(e))return e;let i=ce(e.mode);e=ce(t)(e);let o={...e,c:0};if(!s(o))return i(a(o));let l=0,c=e.c!==void 0?e.c:0,f=pt(t).ranges.c,m=(f[1]-f[0])/Math.pow(2,13),u=o.c;for(;c-l>m;)o.c=l+(c-l)*.5,s(o)?(u=o.c,l=o.c):c=o.c;return i(s(o)?o:{...o,c:u})}function Vs(e){let t=ce("lrgb")(e);return .2126*t.r+.7152*t.g+.0722*t.b}function dr(e,t){let n=Vs(e),s=Vs(t);return(Math.max(n,s)+.05)/(Math.min(n,s)+.05)}G(el);G(ol);G(ll);G(cl);G(fl);G(Ba);G(Va);G(wl);G(jl);G(Cl);G(Sl);G(Gn);G(Tl);G(qn);G(Rl);G(Ul);G(Hl);G(Vl);G(Yl);G(Xl);G(Zl);G(Jl);G(Ql);G(ec);G(sc);G(ze);G(ic);G(oc);G(dc);G(mc);const xn=/^#?(?:[0-9a-f]{3}|[0-9a-f]{6})$/i;function pn(e){const t=e.trim();return t.startsWith("#")?t:`#${t}`}const wc=4.5,jc={dark:"#1e2330",light:"#f1f0ee"},bn="#FFFFFF",vn="#040403";function Gs(e,t){return typeof e!="string"||typeof t!="string"||!xn.test(e.trim())||!xn.test(t.trim())?Number.NaN:dr(pn(e),pn(t))}function Nc(e){const t=Gs(e,vn);if(!Number.isNaN(t))return t>=Gs(e,bn)?vn:bn}const kc={dark:.3,light:.9},Mc={dark:bn,light:vn},Cc=ce("oklch");function Sc(e,t){if(e==null||!xn.test(e.trim()))return;const n=Cc(pn(e));if(!n)return;const s=pc(_c({...n,l:kc[t]},"oklch"));return dr(s,Mc[t])>=wc?s:void 0}function Wn({variant:e,accentColor:t,status:n="ready",layout:s="featured",thumbnailUrl:a,mimeType:i,sourceUrl:o}){const[l,c]=g.useState(!1);g.useEffect(()=>{c(!1)},[a]);const f=g.useCallback(()=>{c(!0)},[]),m=s==="featured"&&!!a&&!l,u=Ye(i,o),h=m&&n==="ready"?Sc(t,e):void 0,d=h??(u?Io:jc[e]);return{thumbnailUrl:l?void 0:a,accentStyle:h?{backgroundColor:h}:void 0,chinTextColor:Nc(d),tailColor:d,isLoading:n==="loading",onImageError:f}}const Ec="flex size-6 items-center justify-center rounded-full bg-[#121110] text-white focus-ring",Tc="relative before:absolute before:-inset-[10px] before:content-['']",Ic=({title:e,placeholderTitle:t,description:n,url:s,mimeType:a,thumbnailUrl:i,sourceUrl:o,layout:l="featured",appIcon:c,cta:f,accentColor:m,status:u="ready",onDismiss:h,onEditClick:d,dismissLabel:v="Dismiss attachment"})=>{const y=l==="classic",x=Ye(a,o),p=Wn({variant:"dark",accentColor:m,status:u,layout:l,thumbnailUrl:i,mimeType:a,sourceUrl:o}),b=h?r.jsx("button",{type:"button",onClick:h,"aria-label":v,className:S(Ec,!x&&Tc),children:r.jsx(M.XIcon,{className:"size-3",weight:"bold"})}):void 0,w=d?r.jsx("button",{type:"button",onClick:d,"aria-label":"Edit attachment",className:"flex size-10 items-center justify-center rounded-full bg-white/10 text-white hover:bg-white/15",children:r.jsx(M.PencilSimpleIcon,{className:"size-5",weight:"regular"})}):void 0;return x&&!p.isLoading?r.jsx(st,{variant:"dark",bgClassName:Fn,children:r.jsxs("div",{className:"flex items-center gap-2 pr-3",children:[r.jsx("div",{className:"min-w-0 flex-1",children:r.jsx(at,{variant:"dark",sourceUrl:o,title:e,mimeType:a})}),b&&r.jsx("div",{className:"shrink-0",children:b})]})}):r.jsxs(st,{variant:"dark",fixedHeight:!y,accentStyle:p.accentStyle,busy:p.isLoading,topRight:y?b:void 0,children:[!y&&r.jsx(at,{variant:"dark",thumbnailUrl:p.thumbnailUrl,sourceUrl:o,title:e,mimeType:a,topRight:b,isLoading:p.isLoading,onImageError:p.onImageError}),r.jsx(Dn,{chinTextColor:p.chinTextColor,variant:"dark",title:e,placeholderTitle:t,description:n,url:s,appIcon:c,cta:f,trailingAction:w,isLoading:p.isLoading})]})},ur=({color:e,side:t,visible:n,children:s})=>n?r.jsxs("div",{className:"relative isolate w-fit",children:[s,r.jsx("span",{"aria-hidden":!0,"data-testid":"link-card-tail",style:{backgroundColor:e},className:S("messaging-link-card-tail",t==="receiver"&&"messaging-link-card-tail--received")})]}):r.jsx(r.Fragment,{children:s}),Rc=({title:e,description:t,url:n,mimeType:s,thumbnailUrl:a,sourceUrl:i,layout:o="featured",appIcon:l,cta:c,accentColor:f,status:m="ready",onClick:u,groupPosition:h="single"})=>{const d=On(s,i),v=Pn(n),y=c==null&&v!=null&&!d?v:void 0,x=c==null&&!d?u:void 0,p=m!=="loading"&&Ye(s,i)?Fn:void 0,b=c&&u?{...c,onClick:()=>{var C;u(),(C=c.onClick)==null||C.call(c)}}:c,w=Wn({variant:"light",accentColor:f,status:m,layout:o,thumbnailUrl:a,mimeType:s,sourceUrl:i});return r.jsx(ur,{color:w.tailColor,side:"receiver",visible:p==null&&(h==="single"||h==="end"),children:r.jsxs(st,{variant:"light",href:y,onClick:x,ariaLabel:e??"Open attachment preview",fixedHeight:o==="featured"&&p==null,accentStyle:w.accentStyle,busy:w.isLoading,bgClassName:p,"data-testid":"link-attachment",children:[o==="featured"&&r.jsx(at,{variant:"light",thumbnailUrl:w.thumbnailUrl,sourceUrl:i,title:e,mimeType:s,isLoading:w.isLoading,onImageError:w.onImageError}),r.jsx(Dn,{chinTextColor:w.chinTextColor,variant:"light",title:e,description:t,url:n,appIcon:l,cta:b,isLoading:w.isLoading})]})})},Lc=({title:e,placeholderTitle:t,description:n,url:s,mimeType:a,thumbnailUrl:i,sourceUrl:o,layout:l="featured",appIcon:c,cta:f,accentColor:m,status:u="ready",onClick:h,groupPosition:d="single"})=>{const v=On(a,o),y=Pn(s),x=f==null&&y!=null&&!v?y:void 0,p=f==null&&!v&&x!=null?h:void 0,b=u!=="loading"&&Ye(a,o),w=Wn({variant:"dark",accentColor:m,status:u,layout:l,thumbnailUrl:i,mimeType:a,sourceUrl:o});return r.jsx(ur,{color:w.tailColor,side:"sender",visible:!b&&(d==="single"||d==="end"),children:r.jsxs(st,{variant:"dark",href:x,onClick:p,fixedHeight:l==="featured"&&!b,accentStyle:w.accentStyle,busy:w.isLoading,bgClassName:b?Fn:void 0,children:[l==="featured"&&r.jsx(at,{variant:"dark",thumbnailUrl:w.thumbnailUrl,sourceUrl:o,title:e,mimeType:a,isLoading:w.isLoading,onImageError:w.onImageError}),r.jsx(Dn,{chinTextColor:w.chinTextColor,variant:"dark",title:e,placeholderTitle:t,description:n,url:s,appIcon:c,cta:f,isLoading:w.isLoading})]})})},ft={Composer:Ic,Sent:Lc,Received:Rc};function U(e){const t=e==null?void 0:e.trim();return t||void 0}function qs(e){return e.trim().replace(/^https?:\/\//i,"").replace(/\/+$/,"").toLowerCase()}function Ac(e,t){if(!(e!=null&&e.trim())||!(t!=null&&t.trim()))return!1;const n=qs(e),s=qs(t);if(n===s)return!0;if(!n.includes(s))return!1;const a=n.split(s).join("");return!/[^\p{P}\p{Z}\p{C}]/u.test(a)}function Ys(e){const t=U(e.og_scrape_url)??U(e.title_link),n=U(e.image_url)??U(e.thumb_url),s=U(e.asset_url),a=U(e.mime_type);return{title:U(e.title),description:U(e.text),url:t,thumbnailUrl:be(n),sourceUrl:s,layout:n||On(a,s)?"featured":"classic",mimeType:a,accentColor:U(e.accent_color),status:"ready"}}function zc(e){var t;return fr(e)?null:e.type==="image"?e.image_url||e.asset_url?"image":null:e.type==="video"&&e.asset_url?"video":e.type==="audio"&&e.asset_url?"audio":e.type==="file"&&e.asset_url?e.mime_type==="application/pdf"?"pdf":(t=e.mime_type)!=null&&t.startsWith("audio/")?"audio":"file":null}function fr(e){const t=U(e.og_scrape_url);return e.type==="link"||!!t&&!e.asset_url}function mr(e){if(!(e!=null&&e.length))return[];const t=[],n=(a,i)=>{const o=t[t.length-1];if((o==null?void 0:o.type)==="media"&&o.kind===a){o.attachments.push(i);return}t.push({type:"media",kind:a,attachments:[i]})},s=a=>{const i=t[t.length-1];if((i==null?void 0:i.type)==="link"){i.attachments.push(a);return}t.push({type:"link",attachments:[a]})};for(const a of e){if(fr(a)){s(a);continue}const i=zc(a);i&&n(i,a)}return t}function $c(e){return e.filter(t=>t.type==="media").length}function Pc(e,t,n){return t<=1?n:e===0?"first":e===t-1?"end":"middle"}function Xs(e){return U(e.image_url)??U(e.asset_url)??""}function Dc(e){switch(e){case"image":return Re.Image;case"video":return Re.Video;case"audio":return Re.Audio;case"pdf":return Re.Pdf;default:return Re.File}}function Oc(e,t){if(t.length>1)switch(e){case"image":return{items:t.map(s=>({src:Xs(s),alt:U(s.title)}))};case"video":return{items:t.map(s=>({src:U(s.asset_url)??"",poster:U(s.thumb_url),mimeType:U(s.mime_type)}))};case"audio":return{items:t.map(s=>({src:U(s.asset_url)??"",mimeType:U(s.mime_type)??"audio/mpeg",filename:U(s.title)}))};case"pdf":return{items:t.map(s=>({src:U(s.asset_url)??"",filename:U(s.title),fileSize:s.file_size}))};case"file":return{items:t.map(s=>({src:U(s.asset_url)??"",filename:U(s.title),fileSize:s.file_size,mimeType:U(s.mime_type)??"application/octet-stream"}))}}const n=t[0];if(!n)return{};switch(e){case"image":return{src:Xs(n),alt:U(n.title)};case"video":return{src:U(n.asset_url)??"",poster:U(n.thumb_url),mimeType:U(n.mime_type)};case"audio":return{src:U(n.asset_url)??"",mimeType:U(n.mime_type)??"audio/mpeg",filename:U(n.title)};case"pdf":return{src:U(n.asset_url)??"",filename:U(n.title),fileSize:n.file_size};case"file":return{src:U(n.asset_url)??"",filename:U(n.title),fileSize:n.file_size,mimeType:U(n.mime_type)??"application/octet-stream"}}}function Fc({groupPosition:e,isMyMessage:t,segment:n}){const s=Dc(n.kind),a={...Oc(n.kind,n.attachments),groupPosition:e};return t?r.jsx(s.Sent,{...a}):r.jsx(s.Received,{...a})}const Bc=({groupPosition:e,isMyMessage:t,message:n,renderText:s})=>{var y;const a=mr(n.attachments);if(a.length===0)return null;const i=$c(a),o=(y=n.text)==null?void 0:y.trim(),l=a.find(x=>x.type==="link"),c=(l==null?void 0:l.type)==="link"?Ys(l.attachments[0]??{}).url:void 0,f=o&&Ac(o,c)?void 0:o;let m=0;const u=[],h=f?"middle":e,d=(x,p,b)=>{const w=t?ft.Sent:ft.Received;u.push(r.jsx(w,{...Ys(x),groupPosition:b?h:"middle"},p))},v=(x,p)=>{const b=Pc(m,i,e);m+=1,u.push(r.jsx(Fc,{groupPosition:b,isMyMessage:t,segment:x},p))};return a.forEach((x,p)=>{const b=p===a.length-1;if(x.type==="link"){x.attachments.forEach((w,C)=>{d(w,`link-${p}-${C}`,b&&C===x.attachments.length-1)});return}v(x,`media-${p}`)}),r.jsxs("div",{className:"str-chat__message-bubble-wrapper",children:[r.jsxs("div",{className:"str-chat__message-bubble","data-attachment-bubble":"true",style:{background:"transparent",borderRadius:0,overflow:"visible",padding:0},children:[u,!f&&r.jsx(N.MessageErrorIcon,{})]}),f?r.jsxs("div",{className:"str-chat__message-bubble",children:[r.jsx(N.MessageText,{message:n,renderText:s}),r.jsx(N.MessageErrorIcon,{})]}):null]})},Uc=e=>{var ss,as,rs,is,os,ls,cs,ds,us,fs;const{additionalMessageInputProps:t,chatbotVotingEnabled:n,editing:s,endOfGroup:a,firstOfGroup:i,groupedByUser:o,handleAction:l,handleOpenThread:c,handleRetry:f,highlighted:m,isMessageAIGenerated:u,isMyMessage:h,message:d,renderText:v,threadList:y,viewerLanguage:x,onBroadcastClick:p}=e,{client:b}=N.useChatContext("CustomMessage"),{channel:w}=N.useChannelStateContext("CustomMessage"),{isUnlocking:C,onUnlockClick:I,onFetchSource:F,onDownloadClick:P}=Ca("LockedAttachment"),[B,H]=g.useState(!1),z=N.useMessageReminder(d.id),{selected:E,voteUp:D,voteDown:T}=aa(d),{Attachment:R=N.Attachment,EditMessageModal:A=N.EditMessageModal,MessageActions:$,MessageBlocked:V=N.MessageBlocked,MessageBouncePrompt:q=N.MessageBouncePrompt,MessageDeleted:W=N.MessageDeleted,MessageIsThreadReplyInChannelButtonIndicator:ae=N.MessageIsThreadReplyInChannelButtonIndicator,MessageRepliesCountButton:Q=N.MessageRepliesCountButton,ReminderNotification:k=N.ReminderNotification,StreamedMessageText:O=N.StreamedMessageText,PinIndicator:X}=N.useComponentContext("CustomMessage"),ee=N.messageHasAttachments(d),re=N.messageHasReactions(d),K=g.useMemo(()=>u==null?void 0:u(d),[u,d]),Y=g.useMemo(()=>{const we=d.attachments??[],Te=d.shared_location?[d.shared_location,...we]:we;if(!nt(d))return Te;const ms=Te.filter(hs=>!("type"in hs)||!Sn(hs));return ms.length===Te.length?Te:ms},[d]),ie=g.useMemo(()=>mr(Y),[Y]),he=g.useMemo(()=>{const we=Nn({message:d,viewerLanguage:x});return we===d.text?d:{...d,text:we}},[d,x]),Ke=ie.length>0,Je=ie.reduce((we,Te)=>we+Te.attachments.length,0)===((Y==null?void 0:Y.length)??0),ge=ua({endOfGroup:a,firstOfGroup:i,groupedByUser:o});if(N.isDateSeparatorMessage(d))return null;if(d.deleted_at||d.type==="deleted")return r.jsx(W,{message:d});if(N.isMessageBlocked(d))return r.jsx(V,{});const _e=!y&&!!d.reply_count,xe=!y&&d.show_in_channel&&d.parent_id,Kn=d.status==="failed"&&((ss=d.error)==null?void 0:ss.status)!==403,Jn=N.isMessageBounced(d);let Se;Kn?Se=()=>f(d):Jn&&(Se=()=>H(!0));const oe=h(),wr=S("str-chat__message str-chat__message-simple",`str-chat__message--${d.type}`,`str-chat__message--${d.status}`,oe?"str-chat__message--me str-chat__message-simple--me":"str-chat__message--other",d.text?"str-chat__message--has-text":"has-no-text",{"str-chat__message--has-attachment":ee,"str-chat__message--highlighted":m,"str-chat__message--pinned pinned-message":d.pinned,"str-chat__message--with-reactions":re,"str-chat__message-send-can-be-retried":(d==null?void 0:d.status)==="failed"&&((as=d==null?void 0:d.error)==null?void 0:as.status)!==403,"str-chat__message-with-thread-link":_e||xe,"str-chat__virtual-message__wrapper--end":a,"str-chat__virtual-message__wrapper--first":i,"str-chat__virtual-message__wrapper--group":o}),Et=d.poll_id&&b.polls.fromState(d.poll_id),Qn=ho(d),Ee=nt(d),jr=zn(d),Tt=!!(Y!=null&&Y.length&&!d.quoted_message),es=Ee&&oe&&Tt,Nr=Ke&&Je&&!d.quoted_message&&!Et&&!K&&!Ee,ts={contentType:"text",amountText:(rs=d.metadata)==null?void 0:rs.amount_text,paymentStatus:(is=d.metadata)==null?void 0:is.payment_status,renderedText:d.text&&r.jsx(N.MessageText,{message:he,renderText:v})},ns={contentType:"media",title:(os=d.metadata)==null?void 0:os.attachment_title,mimeType:(ls=d.metadata)==null?void 0:ls.attachment_mime_type,thumbnailUrl:(cs=d.metadata)==null?void 0:cs.attachment_thumbnail,amountText:(ds=d.metadata)==null?void 0:ds.amount_text,detail:(us=d.metadata)==null?void 0:us.attachment_detail,paymentStatus:(fs=d.metadata)==null?void 0:fs.payment_status,onFetchSource:F?()=>F(d,w):void 0};return r.jsxs(r.Fragment,{children:[s&&r.jsx(A,{additionalMessageInputProps:t}),B&&r.jsx(N.MessageBounceModal,{MessageBouncePrompt:q,onClose:()=>H(!1),open:B}),r.jsxs("div",{className:wr,"data-message-id":d.id,"data-dd-privacy":"mask",children:[X&&r.jsx(X,{}),!!z&&r.jsx(k,{reminder:z}),d.user&&r.jsx(ke,{className:"str-chat__avatar str-chat__message-sender-avatar",id:d.user.id,image:d.user.image,name:d.user.name||d.user.id,size:24,shape:"circle",dmAgentEnabled:Ee}),r.jsx("div",{className:S("str-chat__message-inner",{"str-chat__simple-message--error-failed":Kn||Jn}),"data-testid":"message-inner",onClick:Se,onKeyDown:Se,role:Se?"button":void 0,tabIndex:Se?0:void 0,style:{marginInlineEnd:0,marginInlineStart:0},children:Qn?r.jsx(Lt,{message:d,standalone:!0}):fo(d)?r.jsx("div",{className:"str-chat__message-bubble-wrapper",children:r.jsxs("div",{className:"flex items-center gap-2",children:[oe&&$&&r.jsx($,{}),oe?r.jsx(Oe,{...ts,isMine:!0}):r.jsx(Oe,{...ts,isMine:!1,isUnlocking:C(d.id),onUnlockClick:()=>I==null?void 0:I(d,w)}),!oe&&$&&r.jsx($,{})]})}):mo(d)?r.jsxs("div",{className:"str-chat__message-bubble-wrapper",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[oe&&$&&r.jsx($,{}),oe?r.jsx(Oe,{...ns,isMine:!0,onPreviewClick:()=>I?I(d,w):void 0}):r.jsx(Oe,{...ns,isMine:!1,isUnlocking:C(d.id),onUnlockClick:()=>I?I(d,w):void 0,onDownloadClick:()=>P?P(d,w):void 0}),!oe&&$&&r.jsx($,{})]}),d.text&&r.jsx("div",{className:"str-chat__message-bubble",children:r.jsx(N.MessageText,{message:he,renderText:v})})]}):Nr?r.jsx(Bc,{groupPosition:ge,isMyMessage:oe,message:{...he,attachments:Y,i18n:void 0},renderText:v}):r.jsx("div",{className:"str-chat__message-bubble-wrapper",children:r.jsxs("div",{className:"str-chat__message-bubble",children:[Ee&&!es&&r.jsx(Lt,{message:d,hasAttachment:Tt,isMyMessage:oe}),Et&&r.jsx(N.Poll,{poll:Et}),Y!=null&&Y.length&&!d.quoted_message?r.jsx(R,{actionHandler:l,attachments:Y}):null,K?r.jsx(O,{message:he,renderText:v}):r.jsx(N.MessageText,{message:he,renderText:v}),r.jsx(N.MessageErrorIcon,{})]})})}),!jr&&!Qn&&r.jsxs("div",{className:"str-chat__message-footer",children:[(!Ee||es)&&r.jsx(Lt,{message:d,hasAttachment:Tt,isMyMessage:oe}),n&&Ee&&r.jsx(Ta,{selected:E,onVoteUp:D,onVoteDown:T})]}),r.jsx(bo,{onBroadcastClick:p}),_e&&r.jsx(Q,{onClick:c,reply_count:d.reply_count}),xe&&r.jsx(ae,{})]},d.id)]})},Hc=g.memo(Uc,(e,t)=>e.chatbotVotingEnabled!==t.chatbotVotingEnabled||e.viewerLanguage!==t.viewerLanguage||e.onBroadcastClick!==t.onBroadcastClick?!1:N.areMessageUIPropsEqual(e,t)),Vc=e=>{const t=N.useMessageContext("CustomMessage");return r.jsx(Hc,{...t,...e})},Gc=()=>{var n;const{handleDelete:e,message:t}=N.useMessageContext("CustomMessageActions");return((n=t.metadata)==null?void 0:n.payment_status)==="paid"?null:r.jsx(yn.DefaultDropdownActionButton,{onClick:e,"aria-label":"Delete",title:"Delete",className:"bg-marble rounded-full p-2 hover:bg-sand transition-all",children:r.jsx(M.TrashSimpleIcon,{size:16,weight:"light","aria-hidden":!0})})},qc=()=>{const{handleFlag:e}=N.useMessageContext("CustomMessageActions");return r.jsx(yn.DefaultDropdownActionButton,{onClick:e,"aria-label":"Report",title:"Report",className:"bg-marble rounded-full p-2 hover:bg-sand transition-all",children:r.jsx(M.FlagIcon,{size:16,weight:"light","aria-hidden":!0})})},Yc=()=>{var t;const{message:e}=N.useMessageContext("CustomMessageActions");return((t=e.metadata)==null?void 0:t.custom_type)!==se.MESSAGE_CUSTOM_TYPE.ATTACHMENT?null:r.jsx(yn.MessageActions,{messageActionSet:[{Component:Gc,placement:"quick",type:"delete"},{Component:qc,placement:"quick",type:"flag"}]})},Xc=e=>({linkPreviews:Array.from(e.previews.values()).filter(t=>tt.LinkPreviewsManager.previewIsLoaded(t)||tt.LinkPreviewsManager.previewIsLoading(t))}),Wc=()=>{const{linkPreviewsManager:e}=N.useMessageComposer(),{linkPreviews:t}=N.useStateStore(e.state,Xc),n=a=>{e.dismissPreview(a)};return t.length>0?r.jsx("div",{className:"messaging-link-preview-list flex min-h-0 flex-col items-stretch w-full gap-2 overflow-y-auto overscroll-contain",children:t.map(a=>{const i=tt.LinkPreviewsManager.previewIsLoading(a);return r.jsx("div",{className:"w-full shrink-0",children:r.jsx(ft.Composer,{title:a.title,url:a.og_scrape_url,thumbnailUrl:a.image_url,layout:i||a.image_url?"featured":"classic",status:i?"loading":"ready",onDismiss:()=>n(a.og_scrape_url)})},a.og_scrape_url)})}):null},mt=g.createContext(!1),Zc=200,Kc=()=>g.useContext(mt),Jc=({sendMessage:e,disabled:t,...n})=>r.jsx("button",{...n,type:"button","aria-label":"Send",disabled:t,onPointerDown:s=>s.preventDefault(),onClick:e,children:r.jsx(M.ArrowUpIcon,{weight:"bold",className:"size-4"})}),Ws=()=>{const e=g.useContext(mt),{handleSubmit:t}=N.useMessageInputContext(),n=N.useMessageComposerHasSendableData(),s=e||!n,{SendButton:a=Jc,AttachmentPreviewList:i=N.AttachmentPreviewList}=N.useComponentContext("CustomMessageInput");return r.jsxs("div",{className:"central-container flex min-h-0 flex-col min-w-0 w-full self-stretch bg-white rounded-[1.5rem] shadow-[0_4px_16px_0_rgba(0,0,0,0.08),0_1px_2px_0_rgba(0,0,0,0.04),0_0_0_1px_rgba(0,0,0,0.04)] [&>:not(.messaging-composer-previews):not(.messaging-composer-row)]:p-2","data-dd-privacy":"mask",children:[r.jsxs("div",{className:"messaging-composer-previews empty:hidden flex min-h-0 flex-col gap-2 px-2 pt-2",children:[r.jsx(N.QuotedMessagePreview,{}),r.jsx(Wc,{}),r.jsx(i,{})]}),r.jsxs("div",{className:"messaging-composer-row flex shrink-0 items-start",children:[r.jsx(N.TextareaComposer,{"aria-disabled":e||void 0,containerClassName:"min-w-0 flex-1 leading-[0]",className:"w-full resize-none bg-transparent py-3.5 pl-4 pr-4 outline-none leading-5 placeholder:text-black/30 text-sm",autoFocus:!e,enterKeyHint:"send",maxRows:4,readOnly:e,tabIndex:e?-1:void 0}),r.jsx("div",{className:"mt-auto mb-2 mr-2 shrink-0",children:r.jsx(a,{sendMessage:t,"aria-label":"Send",className:"str-chat__send-button relative flex justify-center items-center rounded-full size-8 bg-[#121110] disabled:bg-[#F1F0EE] disabled:text-black/20 text-white focus-ring before:absolute before:-inset-2 before:content-['']","data-testid":"send-button",disabled:s,type:"button"})})]})]})},Zs=({renderActions:e,renderHeader:t,renderFooter:n,disabled:s=!1,disabledReason:a,composerInput:i})=>{var m;const{channel:o}=N.useChannelStateContext(),l=((m=o==null?void 0:o.data)==null?void 0:m.frozen)===!0,c=!!i,f=g.useRef(null);return g.useEffect(()=>{if(!c)return;const u=f.current,h=u==null?void 0:u.parentElement;if(!u||!h)return;let d=u.offsetHeight;const v=()=>{const x=u.offsetHeight,p=x>d;d=x;const b=Array.from(h.querySelectorAll(".str-chat__list")).find(C=>C.scrollHeight>C.clientHeight)??null,w=b?b.scrollHeight-b.scrollTop-b.clientHeight<Zc:!1;h.style.setProperty("--messaging-composer-height",`${x}px`),p&&w&&b&&(b.scrollTop=b.scrollHeight)};if(v(),typeof ResizeObserver>"u")return;const y=new ResizeObserver(v);return y.observe(u),()=>{y.disconnect(),h.style.removeProperty("--messaging-composer-height")}},[c]),s?c?r.jsxs("div",{ref:f,className:"messaging-composer-chrome messaging-composer-chrome--floating",children:[r.jsxs("div",{className:"messaging-composer-backdrop","aria-hidden":"true",children:[r.jsx("div",{className:"messaging-composer-backdrop-blur"}),r.jsx("div",{className:"messaging-composer-backdrop-blur"}),r.jsx("div",{className:"messaging-composer-backdrop-blur"}),r.jsx("div",{className:"messaging-composer-backdrop-blur"}),r.jsx("div",{className:"messaging-composer-backdrop-blur"}),r.jsx("div",{className:"messaging-composer-backdrop-gradient"})]}),r.jsxs("div",{className:"relative z-10 flex flex-col",children:[t==null?void 0:t(),r.jsx("div",{className:"messaging-composer-locked-panel flex w-full flex-col items-center justify-center gap-3 px-6 py-4",children:a?r.jsx("p",{className:"max-w-[345px] text-center text-xs font-normal leading-[1.3] tracking-[0.12px] text-black/40",children:a}):null}),n==null?void 0:n()]})]}):r.jsxs(r.Fragment,{children:[t==null?void 0:t(),r.jsx("div",{className:"messaging-composer-locked-panel flex w-full flex-col items-center justify-center gap-3 px-6 py-4",children:a?r.jsx("p",{className:"max-w-[345px] text-center text-xs font-normal leading-[1.3] tracking-[0.12px] text-black/40",children:a}):null}),n==null?void 0:n()]}):c?r.jsxs("div",{ref:f,className:"messaging-composer-chrome messaging-composer-chrome--floating",children:[r.jsxs("div",{className:"messaging-composer-backdrop","aria-hidden":"true",children:[r.jsx("div",{className:"messaging-composer-backdrop-blur"}),r.jsx("div",{className:"messaging-composer-backdrop-blur"}),r.jsx("div",{className:"messaging-composer-backdrop-blur"}),r.jsx("div",{className:"messaging-composer-backdrop-blur"}),r.jsx("div",{className:"messaging-composer-backdrop-blur"}),r.jsx("div",{className:"messaging-composer-backdrop-gradient"})]}),r.jsxs("div",{className:"relative z-10 flex min-h-0 flex-col",children:[t==null?void 0:t(),r.jsxs("div",{className:"flex min-h-0 flex-col gap-4 p-4",children:[r.jsxs("div",{inert:l?"":void 0,"aria-disabled":l||void 0,className:"message-input flex min-h-0 items-end gap-4 aria-disabled:opacity-40",children:[e&&r.jsx("div",{className:"flex h-12 shrink-0 items-center justify-center",children:e()}),r.jsx(mt.Provider,{value:l,children:r.jsx(N.MessageInput,{Input:i??Ws})})]}),n==null?void 0:n()]})]})]}):r.jsxs("div",{className:"flex min-h-0 flex-col gap-4 p-4",children:[t==null?void 0:t(),r.jsxs("div",{inert:l?"":void 0,"aria-disabled":l||void 0,className:"message-input flex min-h-0 items-end gap-4 aria-disabled:opacity-40",children:[e&&r.jsx("div",{className:"flex h-12 shrink-0 items-center justify-center",children:e()}),r.jsx(mt.Provider,{value:l,children:r.jsx(N.MessageInput,{Input:Ws})})]}),n==null?void 0:n()]})},Qc={SYSTEM_DM_AGENT_PAUSED:"DM Agent has left the conversation",SYSTEM_DM_AGENT_RESUMED:"DM Agent has rejoined the conversation"},ed=["SYSTEM_AGE_SAFETY_BLOCKED"],td={SYSTEM_AGE_SAFETY_BLOCKED:"This user isn’t able to reply because they don’t meet our age safety guidelines."},an="age safety guidelines.",nd="https://linktr.ee/s/about/contact",sd=e=>ed.includes(e),ad=e=>{var t;return sd((t=e.metadata)==null?void 0:t.custom_type)},rd=e=>{var s;const t=(s=e.metadata)==null?void 0:s.custom_type;if(se.isDmAgentSystemType(t))return{kind:"dm-agent",type:t};if(se.isAgeSafetySystemType(t))return{kind:"age-safety",type:t};const n=e.dm_agent_system_type;if(se.isDmAgentSystemType(n))return{kind:"dm-agent",type:n}},id=e=>{const t=e.indexOf(an);if(t===-1)return e;const n=t+an.length;return r.jsxs(r.Fragment,{children:[e.slice(0,t),r.jsx("a",{href:nd,target:"_blank",rel:"noopener noreferrer",className:"mes-age-safety-system-message__emphasis font-medium text-inherit underline",children:an}),e.slice(n)]})},od=e=>{var s,a;const t=!ad(e.message),n=rd(e.message);if((n==null?void 0:n.kind)==="dm-agent"){const i=((s=e.message.text)==null?void 0:s.trim())||Qc[n.type];return r.jsxs("div",{className:"str-chat__message--system","data-testid":"message-system",children:[r.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:[r.jsx(M.SparkleIcon,{size:16,weight:"regular","aria-hidden":!0,className:"mes-dm-agent-system-message__sparkle shrink-0"}),r.jsx("p",{className:"mes-dm-agent-system-message__text m-0 text-center text-[14px] font-normal leading-5 tracking-[0.21px]",children:i})]}),!t&&r.jsx(N.MessageTimestamp,{message:e.message})]})}if((n==null?void 0:n.kind)==="age-safety"){const i=((a=e.message.text)==null?void 0:a.trim())||td[n.type];return r.jsxs("div",{className:"str-chat__message--system","data-testid":"message-system",children:[r.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:[r.jsx(M.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"}),r.jsx("div",{className:"mes-age-safety-system-message__content min-w-0 flex-[1_0_0]",children:r.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:id(i)})})]}),!t&&r.jsx(N.MessageTimestamp,{message:e.message})]})}return r.jsxs("div",{className:"str-chat__message--system","data-testid":"message-system",children:[r.jsxs("div",{className:"str-chat__message--system__text",children:[r.jsx("div",{className:"str-chat__message--system__line"}),r.jsx("p",{children:e.message.text}),r.jsx("div",{className:"str-chat__message--system__line"})]}),!t&&r.jsx(N.MessageTimestamp,{message:e.message})]})},hr=g.createContext(!1),rn=({cx:e,index:t})=>r.jsx("circle",{cx:e,cy:"6.15",r:"3.9",fill:"#A0A0A0",children:r.jsx("animateTransform",{attributeName:"transform",type:"translate",values:"0 0; 0 -2.25; 0 0;",dur:"900ms",begin:`${120*t}ms`,repeatCount:"indefinite"})}),ld=new Set([N.AIStates.Thinking,N.AIStates.Generating,N.AIStates.ExternalSources]),cd=({threadList:e})=>{var v,y;const{channel:t,channelConfig:n,thread:s}=N.useChannelStateContext(),{client:a}=N.useChatContext(),{typing:i={}}=N.useTypingContext(),{aiState:o}=N.useAIState(t),l=g.useContext(hr);if(!e&&l&&ld.has(o)){const x=dd(t,(v=a.user)==null?void 0:v.id);return r.jsx(Ks,{avatarId:(x==null?void 0:x.id)??"ai-agent",avatarName:(x==null?void 0:x.name)??(x==null?void 0:x.id)??"Agent",avatarImage:x==null?void 0:x.image,testId:"typing-indicator-ai"})}if((n==null?void 0:n.typing_events)===!1)return null;const f=e?[]:Object.values(i).filter(({parent_id:x,user:p})=>{var b;return(p==null?void 0:p.id)!==((b=a.user)==null?void 0:b.id)&&!x}),m=e?Object.values(i).filter(({parent_id:x,user:p})=>{var b;return(p==null?void 0:p.id)!==((b=a.user)==null?void 0:b.id)&&x===(s==null?void 0:s.id)}):[],u=e?m:f;if(!u.length)return null;const h=(y=u[0])==null?void 0:y.user,d=h!=null&&h.id&&t.state.members[h.id]?t.state.members[h.id].user:void 0;return r.jsx(Ks,{avatarId:(h==null?void 0:h.id)??(d==null?void 0:d.id)??"typing-user",avatarName:(h==null?void 0:h.name)??(d==null?void 0:d.name)??(h==null?void 0:h.id)??"Typing user",avatarImage:(h==null?void 0:h.image)??(d==null?void 0:d.image),testId:"typing-indicator"})},Ks=({avatarId:e,avatarName:t,avatarImage:n,testId:s})=>r.jsx("div",{className:"str-chat__li str-chat__li--single str-chat__typing-indicator !static","data-testid":s,style:{marginBottom:"var(--messaging-channel-input-spacer-height, 80px)"},children:r.jsxs("div",{className:"str-chat__message str-chat__message-simple str-chat__message--regular str-chat__message--received str-chat__message--other str-chat__message--has-text",children:[r.jsx(ke,{className:"str-chat__avatar str-chat__message-sender-avatar",id:e,name:t,image:n??void 0,size:24,shape:"circle"}),r.jsx("div",{className:"str-chat__message-inner mx-0",children:r.jsx("div",{className:"str-chat__message-bubble-wrapper",children:r.jsx("div",{className:"str-chat__message-bubble",children:r.jsx("div",{className:"str-chat__message-text min-h-11 flex items-center",children:r.jsx("div",{className:"str-chat__message-text-inner str-chat__message-simple-text-inner",children:r.jsxs("svg",{"aria-hidden":"true",className:"block overflow-visible",viewBox:"0 0 32 12.3",width:"32",height:"13",overflow:"visible",children:[r.jsx(rn,{cx:"4",index:0}),r.jsx(rn,{cx:"16",index:1}),r.jsx(rn,{cx:"28",index:2})]})})})})})})]})});function dd(e,t){var s;const n=((s=e==null?void 0:e.state)==null?void 0:s.members)??{};for(const a of Object.values(n)){const i=a==null?void 0:a.user;if(i&&i.id!==t)return i}}const gr=()=>null,ud=({className:e,message:t})=>r.jsxs("div",{className:S("flex items-center justify-center h-full",e),children:[r.jsxs("svg",{viewBox:"0 0 100 100",className:"size-8 fill-pebble",stroke:"none",children:[r.jsx("circle",{cx:"6",cy:"50",r:"6",children:r.jsx("animateTransform",{attributeName:"transform",dur:"1s",type:"translate",values:"0 15 ; 0 -15; 0 15",repeatCount:"indefinite",begin:"0.1"})}),r.jsx("circle",{cx:"30",cy:"50",r:"6",children:r.jsx("animateTransform",{attributeName:"transform",dur:"1s",type:"translate",values:"0 10 ; 0 -10; 0 10",repeatCount:"indefinite",begin:"0.2"})}),r.jsx("circle",{cx:"54",cy:"50",r:"6",children:r.jsx("animateTransform",{attributeName:"transform",dur:"1s",type:"translate",values:"0 5 ; 0 -5; 0 5",repeatCount:"indefinite",begin:"0.3"})})]}),t&&r.jsx("span",{className:"text-stone",children:t})]}),ht=g.memo(()=>r.jsx("div",{className:"messaging-loading-state flex items-center justify-center h-full",children:r.jsxs("div",{className:"flex items-center",children:[r.jsx(ud,{className:"w-6 h-6"}),r.jsx("span",{className:"text-sm text-stone",children:"Loading messages"})]})}));ht.displayName="LoadingState";const fd=({onBack:e,showBackButton:t,renderMessageInputActions:n,renderMessageInputFooter:s,renderConversationFooter:a,onLeaveConversation:i,onBlockParticipant:o,showDeleteConversation:l=!0,onDeleteConversationClick:c,onBlockParticipantClick:f,onReportParticipantClick:m,showBlockParticipant:u=!0,showReportParticipant:h=!0,composerDisabled:d=!1,composerDisabledReason:v,showStarButton:y=!1,chatbotVotingEnabled:x=!1,renderChannelBanner:p,customChannelActions:b,renderChannelActions:w,renderMessage:C,viewerLanguage:I,showChannelInfo:F=!0,onParticipantNameClick:P,onBroadcastClick:B,composerInput:H})=>{const{channel:z}=N.useChannelStateContext(),E=g.useRef(B);g.useEffect(()=>{E.current=B},[B]);const D=g.useCallback(q=>{var W;(W=E.current)==null||W.call(E,q)},[]),T=B?D:void 0,R=z.state.messages.some(q=>q.type!=="deleted"),A=p?r.jsx(g.Fragment,{children:p()},"lt-channel-banner"):null,$=r.jsx($r,{className:"-mx-[var(--str-chat\\_\\_spacing-2)] px-[var(--str-chat\\_\\_spacing-2)] md:-mx-[min(var(--str-chat\\_\\_spacing-10),4%)] md:px-[min(var(--str-chat\\_\\_spacing-10),4%)]",onBack:e,showBackButton:t,showChannelInfo:F,showStarButton:y,onLeaveConversation:i,onBlockParticipant:o,showDeleteConversation:l,showBlockParticipant:u,showReportParticipant:h,onDeleteConversationClick:c,onBlockParticipantClick:f,onReportParticipantClick:m,customChannelActions:b,renderChannelActions:w,onParticipantNameClick:P}),V=g.useCallback(q=>{const{message:W}=N.useMessageContext("ChannelView"),ae=r.jsx(Vc,{...q,chatbotVotingEnabled:x,viewerLanguage:I,onBroadcastClick:T});return!C||!W?ae:C(ae,W)},[x,T,C,I]);return r.jsx(r.Fragment,{children:r.jsx(N.WithComponents,{overrides:{Message:V,MessageActions:Yc,UnreadMessagesNotification:()=>null,UnreadMessagesSeparator:()=>null},children:r.jsx(N.Window,{children:H?r.jsxs("div",{className:"messaging-channel-layout relative flex min-h-0 flex-1 flex-col",children:[r.jsxs("div",{className:"messaging-channel-message-list messaging-channel-message-list--floating relative min-h-0 flex-1 overflow-hidden",children:[!R&&r.jsx("div",{className:"str-chat__list",children:r.jsxs("div",{className:"str-chat__message-list-scroll",children:[$,A]})}),r.jsx(N.MessageList,{head:R?r.jsxs("div",{className:"sticky top-0 z-10",children:[$,A]}):void 0,hideDeletedMessages:!0,hideNewMessageSeparator:!1})]},"lt-channel-message-list"),r.jsx(Zs,{...n&&{renderActions:()=>n==null?void 0:n(z)},...a&&{renderHeader:()=>a(z)},renderFooter:()=>s==null?void 0:s(z),disabled:d,disabledReason:v,composerInput:H},"lt-channel-message-input")]}):r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex-1 overflow-hidden relative",children:[!R&&r.jsx("div",{className:"str-chat__list",children:r.jsxs("div",{className:"str-chat__message-list-scroll",children:[$,A]})}),r.jsx(N.MessageList,{head:R?r.jsxs("div",{className:"sticky top-0 z-10",children:[$,A]}):void 0,hideDeletedMessages:!0,hideNewMessageSeparator:!1})]},"lt-channel-message-list"),a?r.jsx(g.Fragment,{children:a(z)},"lt-channel-conversation-footer"):null,r.jsx(Zs,{...n&&{renderActions:()=>n==null?void 0:n(z)},renderFooter:()=>s==null?void 0:s(z),disabled:d,disabledReason:v,composerInput:H},"lt-channel-message-input")]})})})})},Zn=g.memo(({channel:e,onBack:t,showBackButton:n=!1,renderMessageInputActions:s,renderMessageInputFooter:a,renderConversationFooter:i,onLeaveConversation:o,onBlockParticipant:l,className:c,CustomChannelEmptyState:f=gr,showDeleteConversation:m=!0,onDeleteConversationClick:u,onBlockParticipantClick:h,onReportParticipantClick:d,showBlockParticipant:v=!0,showReportParticipant:y=!0,composerDisabled:x=!1,composerDisabledReason:p,dmAgentEnabled:b,messageMetadata:w,onMessageSent:C,showStarButton:I=!1,chatbotVotingEnabled:F=!1,renderChannelBanner:P,customChannelActions:B,renderChannelActions:H,renderMessage:z,onMessageLinkClick:E,sendButton:D,attachmentPreviewList:T,viewerLanguage:R,showChannelInfo:A=!0,onParticipantNameClick:$,onBroadcastClick:V,composerInput:q})=>{const W=g.useCallback(async(Q,k,O)=>{var ie;const X=((ie=e.data)==null?void 0:ie.chatbot_paused)===!0,ee=b&&!X,re={...k,...ee&&{silent:!0},...w&&{metadata:{...k.metadata??{},...w}}},K={...O,...ee&&{skip_push:!0}},Y=await e.sendMessage(re,K);return C==null||C(Y),Y},[e,b,w,C]),ae=g.useRef(null);return g.useEffect(()=>{if(!E)return;const Q=ae.current;if(!Q)return;const k=O=>{const X=O.target,ee=X==null?void 0:X.closest("a[href]"),re=ee==null?void 0:ee.getAttribute("href");if(!re)return;const K=ee==null?void 0:ee.closest("[data-message-id]"),Y=K==null?void 0:K.getAttribute("data-message-id"),ie=Y?e.state.messages.find(he=>he.id===Y):void 0;E(re,ie)};return Q.addEventListener("click",k),()=>Q.removeEventListener("click",k)},[E,e]),r.jsx("div",{ref:ae,className:S("messaging-channel-view h-full flex flex-col",c),children:r.jsx(hr.Provider,{value:b??!1,children:r.jsx(N.Channel,{channel:e,MessageSystem:od,EmptyStateIndicator:f,LoadingIndicator:ht,DateSeparator:Pr,TypingIndicator:cd,doSendMessageRequest:W,...D?{SendButton:D}:{},...T?{AttachmentPreviewList:T}:{},children:r.jsx(fd,{onBack:t,showBackButton:n,renderMessageInputActions:s,renderMessageInputFooter:a,renderConversationFooter:i,onLeaveConversation:o,onBlockParticipant:l,CustomChannelEmptyState:f,showDeleteConversation:m,onDeleteConversationClick:u,onBlockParticipantClick:h,onReportParticipantClick:d,showBlockParticipant:v,showReportParticipant:y,composerDisabled:x,composerDisabledReason:p,showStarButton:I,chatbotVotingEnabled:F,renderChannelBanner:P,customChannelActions:B,renderChannelActions:H,renderMessage:z,viewerLanguage:R,showChannelInfo:A,onParticipantNameClick:$,onBroadcastClick:V,composerInput:q})})})})});Zn.displayName="ChannelView";const Fe=g.memo(({message:e,onBack:t})=>r.jsx("div",{className:"messaging-error-state flex items-center justify-center h-full p-8",children:r.jsxs("div",{className:"text-center max-w-sm",children:[r.jsx("div",{className:"w-24 h-24 bg-danger-alt/20 rounded-full flex items-center justify-center mx-auto mb-6",children:r.jsx("span",{className:"text-4xl",children:"⚠️"})}),r.jsx("h2",{className:"font-semibold text-charcoal mb-2",children:"Oops!"}),r.jsx("p",{className:"text-stone text-sm mb-6",children:e}),t&&r.jsx("button",{type:"button",onClick:t,className:"inline-flex items-center gap-2 px-4 py-2 text-sm font-medium text-white bg-[#7f22fe] hover:bg-primary-alt rounded-lg transition-colors focus-ring",children:"Go Back"})]})}));Fe.displayName="ErrorState";const md=({capabilities:e={},renderMessageInputActions:t,renderConversationFooter:n,onChannelSelect:s,onExitConversation:a,initialParticipantFilter:i,initialParticipantData:o,CustomChannelEmptyState:l,onBlockParticipantClick:c,onReportParticipantClick:f,dmAgentEnabled:m,onMessageSent:u,chatbotVotingEnabled:h=!1,viewerLanguage:d,renderChannelBanner:v,customChannelActions:y,renderChannelActions:x,onParticipantNameClick:p,onBroadcastClick:b,renderMessage:w,onMessageLinkClick:C,showChannelInfo:I,composerInput:F})=>{const{client:P,isConnected:B,isLoading:H,error:z,refreshConnection:E,service:D,debug:T}=ea(),[R,A]=g.useState(null),[$,V]=g.useState(null),[q,W]=g.useState(!1),{showDeleteConversation:ae=!0}=e,Q=g.useRef(o);Q.current=o;const k=g.useRef(s);k.current=s;const O=g.useRef(null),X=g.useRef(null);g.useEffect(()=>{X.current=R},[R]),g.useEffect(()=>{if(!P||!B)return;const K=P.userID;if(!K)return;const Y=`${K}::${i}`;if(O.current===Y)return;O.current=Y;const ie=()=>{O.current===Y&&(O.current=null)};(async()=>{var Ke,Je;try{T&&console.log("[MessagingShell] Loading initial conversation with:",i);const ge=await P.queryChannels({type:"messaging",members:{$eq:[K,i]}},{},{limit:1});if(ge.length>0){A(ge[0]),V(null),(Ke=k.current)==null||Ke.call(k,ge[0]),T&&console.log("[MessagingShell] Initial conversation loaded:",ge[0].id);return}const _e=Q.current;if(!_e||!D){ie(),V("No conversation found with this account"),T&&console.log("[MessagingShell] No conversation found for:",i);return}try{const xe=await D.startChannelWithParticipant({id:_e.id,name:_e.name,phone:_e.phone});A(xe),V(null),(Je=k.current)==null||Je.call(k,xe),T&&console.log("[MessagingShell] Channel created and loaded:",xe.id)}catch(xe){console.error("[MessagingShell] Failed to create conversation:",xe),ie(),V("Failed to create conversation")}}catch(ge){console.error("[MessagingShell] Failed to load initial conversation:",ge),ie(),X.current||V("Failed to load conversation")}})()},[i,P,B,D,T]);const ee=g.useRef(a);ee.current=a;const re=g.useCallback(()=>{var K;A(null),W(!0),(K=ee.current)==null||K.call(ee)},[]);return H?r.jsx(ht,{}):z?r.jsx(Fe,{message:z,onBack:E}):!B||!P?r.jsx(Fe,{message:"Not connected to messaging service",onBack:E}):$?r.jsx(Fe,{message:$}):q&&!R?r.jsx(Fe,{message:"Conversation ended"}):R?r.jsx("div",{className:"messaging-shell h-full bg-background-primary overflow-hidden",children:r.jsx("div",{className:"flex h-full min-h-0 flex-col",children:r.jsx(Zn,{channel:R,renderMessageInputActions:t,renderConversationFooter:n,renderChannelBanner:v,onLeaveConversation:re,onBlockParticipant:re,CustomChannelEmptyState:l,showDeleteConversation:ae,onBlockParticipantClick:c,onReportParticipantClick:f,dmAgentEnabled:m,onMessageSent:u,chatbotVotingEnabled:h,viewerLanguage:d,customChannelActions:y,renderChannelActions:x,onParticipantNameClick:p,onBroadcastClick:b,renderMessage:w,onMessageLinkClick:C,showChannelInfo:I,composerInput:F},R.id)})}):r.jsx(ht,{})};function hd(e){const t=e.state.pending_messages;if(t!=null&&t.length)for(const n of t)e.state.addMessageSorted(n.message)}const xr=g.createContext({selectedChannel:void 0,onChannelSelect:()=>{},debug:!1,renderMessagePreview:void 0,channelPreview:void 0,viewerLanguage:void 0}),gd=xr.Provider,xd=()=>g.useContext(xr),pd=(e,t)=>{const n=new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate())),a=new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate())).getTime()-n.getTime();return Math.floor(a/(1e3*60*60*24))},pr=e=>{const t=new Date;if(Math.floor((t.getTime()-e.getTime())/1e3)<60)return"Just now";const s=pd(e,t);return s===0?e.toLocaleTimeString([],{hour:"numeric",minute:"2-digit",hour12:!0}):s===1?"Yesterday":s<7?`${s}d`:s<28?`${Math.floor(s/7)}w`:e.toLocaleDateString(void 0,{day:"numeric",month:"short",year:"2-digit"})},br=g.memo(e=>{var B,H,z;const{channel:t,unread:n}=e,{selectedChannel:s,onChannelSelect:a,debug:i,channelPreview:o,renderMessagePreview:l,viewerLanguage:c}=xd(),{client:f}=N.useChatContext(),m=(s==null?void 0:s.id)===(t==null?void 0:t.id),u=ta(t);if(o){const E=o;return r.jsx(E,{...e,active:m,selectedChannel:s,onChannelSelect:a,viewerLanguage:c})}const h=()=>{t&&a(t)},d=E=>{const D=E.key==="Enter"||E.key===" ",T=E.repeat;!D||T||(E.preventDefault(),h())},v=wn((B=t==null?void 0:t.state)==null?void 0:B.members,f==null?void 0:f.userID,t==null?void 0:t.type),y=jn(v==null?void 0:v.user),x=(H=v==null?void 0:v.user)==null?void 0:H.image,p=(()=>{var D;const E=(D=t==null?void 0:t.state)==null?void 0:D.messages;if(E!=null&&E.length){for(let T=E.length-1;T>=0;T--)if(E[T].type!=="system")return E[T]}})(),w=(()=>{var A;const E=Nn({message:p,viewerLanguage:c}),{custom_type:D,attachment_content_type:T}=(p==null?void 0:p.metadata)||{};if(D===se.MESSAGE_CUSTOM_TYPE.TIP)return E||"Sent a tip";if(D===se.MESSAGE_CUSTOM_TYPE.PAID)return E||"Sent a message";if(D===se.MESSAGE_CUSTOM_TYPE.ATTACHMENT){if(T==="text")return"🔒 Sent a locked message";if(T==="media")return"🔒 Sent a locked attachment"}if(E)return E;const R=(A=p==null?void 0:p.attachments)==null?void 0:A[0];return R?R.og_scrape_url?R.og_scrape_url:R.type==="image"?"📷 Sent an image":R.type==="video"?"🎥 Sent a video":R.type==="audio"?"🎵 Sent audio":R.type==="file"?"📎 Sent a file":"📎 Sent an attachment":"No messages yet"})(),C=p!=null&&p.created_at?pr(new Date(p.created_at)):"",I=p?nt(p):!1,F=l?l(p,w):`${I?"✨ ":""}${w}`,P=n??0;return i&&console.log("📺 [ChannelList] 📋 CHANNEL PREVIEW RENDER",{channelId:t==null?void 0:t.id,isSelected:m,participantName:y,unreadCount:P,hasTimestamp:!!C}),r.jsx("div",{role:"button",tabIndex:0,onClick:h,onKeyDown:d,className:S("group w-full px-4 py-3 transition-colors text-left max-w-full overflow-hidden focus-ring rounded-[12px] [&+&]:mt-2",{"bg-black/[0.04]":m,"hover:bg-black/[0.02]":!m}),"data-dd-privacy":"mask",children:r.jsxs("div",{className:"flex items-start gap-4",children:[r.jsx(ke,{id:((z=v==null?void 0:v.user)==null?void 0:z.id)||t.id||"unknown",name:y,image:x,size:48,starred:u}),r.jsxs("div",{className:"flex-1 min-w-0 flex flex-col gap-1",children:[r.jsxs("div",{className:"flex items-center justify-between gap-2",children:[r.jsxs("h3",{className:S("text-sm font-medium truncate text-[#191918]"),children:[u&&r.jsx("span",{className:"sr-only",children:"Starred conversation. "}),y]}),C&&r.jsx("span",{className:"text-xs text-[#717070] flex-shrink-0",children:C})]}),r.jsxs("div",{className:"flex items-center justify-between gap-2 min-w-0",children:[r.jsx("p",{className:"text-sm text-[#717070] flex-1 line-clamp-1",children:F}),P>0&&r.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:P>99?"99+":P})]})]})]})})});br.displayName="CustomChannelPreview";const bd={last_message_at:-1},vr=g.memo(({onChannelSelect:e,selectedChannel:t,filters:n,allowNewMessagesFromUnfilteredChannels:s=!1,channelRenderFilterFn:a,sort:i=bd,className:o,customEmptyStateIndicator:l,channelListPaginator:c=N.InfiniteScroll,channelPreview:f,renderMessagePreview:m,viewerLanguage:u,lockChannelOrder:h,onMessageNewHandler:d,onMessageNew:v,onChannelVisible:y,onAddedToChannel:x,onChannelUpdated:p})=>{const b=g.useRef(0);b.current++;const{debug:w=!1}=_n(),C=g.useCallback(F=>{for(const P of F)hd(P);return a?a(F):F},[a]);w&&console.log("📺 [ChannelList] 🔄 RENDER START",{renderCount:b.current,selectedChannelId:t==null?void 0:t.id,filters:n});const I=g.useMemo(()=>({selectedChannel:t,onChannelSelect:e,debug:w,channelPreview:f,renderMessagePreview:m,viewerLanguage:u}),[t,e,w,f,m,u]);return r.jsx("div",{className:S("messaging-channel-list h-full flex flex-col min-w-0 overflow-hidden",o),children:r.jsx("div",{className:"flex-1 overflow-hidden min-w-0",children:r.jsx(gd,{value:I,children:r.jsx(N.ChannelList,{filters:n,sort:i,options:{limit:30},allowNewMessagesFromUnfilteredChannels:s,channelRenderFilterFn:C,lockChannelOrder:h,onMessageNewHandler:d,onMessageNew:v,onChannelVisible:y,onAddedToChannel:x,onChannelUpdated:p,Paginator:c,Preview:br,EmptyStateIndicator:l},`${JSON.stringify(n)}:${JSON.stringify(i)}`)})})})});vr.displayName="ChannelList";const Js=`url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='23' fill='none'%3E%3Cpath fill='black' d='M0 0H15C15 10.1934 15.859 15.2345 19.168 21.4893C19.527 22.168 19.039 22.9917 18.274 22.9178C5.176 21.6506 0.32 6.0737 0 0Z'/%3E%3C/svg%3E") no-repeat center / 100% 100%`,vd={sent:"var(--str-chat__own-message-bubble-background-color, #1e2330)",received:"var(--str-chat__message-bubble-background-color, #f1f0ee)"},yd=({variant:e})=>r.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute bottom-0 z-[-1] h-[1.4375rem] w-5",style:{insetInlineEnd:e==="sent"?"calc(-1 * 0.25rem)":void 0,insetInlineStart:e==="received"?"calc(-1 * 0.25rem)":void 0,transform:e==="received"?"scaleX(-1)":void 0,transformOrigin:"center",backgroundColor:vd[e],WebkitMask:Js,mask:Js}}),_d={sent:{backgroundColor:"var(--str-chat__own-message-bubble-background-color, #1e2330)",color:"var(--str-chat__own-message-bubble-color, #fff)"},received:{backgroundColor:"var(--str-chat__message-bubble-background-color, #f1f0ee)",color:"var(--str-chat__message-bubble-color, #000000)"}},yr=({variant:e,text:t,tail:n=!0,header:s,className:a})=>r.jsxs("div",{"data-dd-privacy":"mask",className:S("relative px-4 py-3","text-[0.875rem] leading-[1.3125rem] tracking-[0.14px]",a),style:{..._d[e],borderRadius:"var(--str-chat__message-bubble-border-radius, 1.5rem)",isolation:"isolate"},children:[s!=null&&r.jsx("div",{className:"mb-1 font-medium","data-testid":"message-bubble-header",children:s}),r.jsx("p",{className:"m-0 whitespace-pre-wrap break-words",children:t}),n&&r.jsx(yd,{variant:e})]}),wd=({text:e,tail:t,header:n,className:s})=>r.jsx(yr,{variant:"received",text:e,tail:t,header:n,className:s}),jd=({text:e,tail:t,className:n})=>r.jsx(yr,{variant:"sent",text:e,tail:t,className:n}),Nd={Sent:jd,Received:wd},_r=({question:e,onClick:t,loading:n=!1,className:s})=>r.jsx("button",{type:"button",onClick:t,disabled:n,style:{backgroundColor:"#E6E5E3"},className:S("w-full text-center p-4 rounded-xl text-charcoal font-medium transition-colors focus-ring",{"hover:brightness-95 active:brightness-90":!n,"opacity-50 cursor-not-allowed":n},s),children:e}),kd=({faqs:e,onFaqClick:t,loadingFaqId:n,headerText:s,className:a,avatarImage:i,avatarName:o})=>{const l=se.selectEnabledFaqs(e);return l.length===0?null:r.jsx("div",{className:a,children:r.jsxs("div",{className:"flex gap-3 items-end",children:[(i||o)&&r.jsx("div",{className:"flex-none",children:r.jsx(ke,{id:o||"account",name:o||"Account",image:i,size:24,shape:"circle"})}),r.jsxs("div",{className:"flex-1 flex flex-col gap-3 rounded-lg p-4",style:{backgroundColor:"#F1F0EE"},children:[s&&r.jsx("p",{className:"text-md text-charcoal mb-4",children:s}),l.map(c=>r.jsx(_r,{question:c.question,onClick:()=>t(c.id),loading:n===c.id},c.id))]})]})})};exports.ActionButton=Ie;exports.AttachmentThumbnail=kn;exports.Avatar=ke;exports.ChannelEmptyState=gr;exports.ChannelList=vr;exports.ChannelView=Zn;exports.CustomMessageProvider=ro;exports.FaqList=kd;exports.FaqListItem=_r;exports.LinkAttachment=ft;exports.LockedAttachment=Oe;exports.MediaMessage=ri;exports.MessageAttachment=Re;exports.MessageBubble=Nd;exports.MessageVoteButtons=Ta;exports.MessagingProvider=Mr;exports.MessagingShell=md;exports.bubbleGroupPositionFromStream=ua;exports.buildCompactMetaLabel=ha;exports.formatFileSize=fa;exports.formatRelativeTime=pr;exports.getFileExtensionLabel=ma;exports.getMessageDisplayText=Nn;exports.getSourceType=ue;exports.isLinkAttachment=Sn;exports.isUuidLike=na;exports.normalizeLanguageCode=ra;exports.optimizeMessagingAttachmentUrl=be;exports.renderTypeIcon=Ne;exports.resolveConversationParticipant=wn;exports.resolveLinkAttachment=gt;exports.resolveMediaFromMessage=xt;exports.resolveParticipantDisplayName=jn;exports.useComposerLocked=Kc;exports.useCustomMessage=Ca;exports.useMessageVote=aa;exports.useMessaging=ea;
|
|
5
|
-
//# sourceMappingURL=index-
|
|
4
|
+
`||t[L]===" "||t[L]===" ");)L++;let a;if(Qe(t)&&(a=De(t),a.type!==_.Hue)){n.push({type:_.Alpha,value:a});continue}if(dn(t)&&ot(t)==="none"){n.push({type:_.Alpha,value:{type:_.None,value:void 0}});continue}return}if(/\d/.test(s)){L--,n.push(De(t));continue}if(cn.test(s)){L--,n.push(Vo(t));continue}return}return n}function qo(e){e._i=0;let t=e[e._i++];if(!t||t.type!==_.Function||t.value!=="color"||(t=e[e._i++],t.type!==_.Ident))return;const n=La[t.value];if(!n)return;const s={mode:n},a=Aa(e,!1);if(!a)return;const i=pt(n).channels;for(let o=0,l,c;o<i.length;o++)l=a[o],c=i[o],l.type!==_.None&&(s[c]=l.type===_.Number?l.value:l.value/100,c==="alpha"&&(s[c]=Math.max(0,Math.min(1,s[c]))));return s}function Aa(e,t){const n=[];let s;for(;e._i<e.length;){if(s=e[e._i++],s.type===_.None||s.type===_.Number||s.type===_.Alpha||s.type===_.Percentage||t&&s.type===_.Hue){n.push(s);continue}if(s.type===_.ParenClose){if(e._i<e.length)return;continue}return}if(!(n.length<3||n.length>4)){if(n.length===4){if(n[3].type!==_.Alpha)return;n[3]=n[3].value}return n.length===3&&n.push({type:_.None,value:void 0}),n.every(a=>a.type!==_.Alpha)?n:void 0}}function Yo(e,t){e._i=0;let n=e[e._i++];if(!n||n.type!==_.Function)return;let s=Aa(e,t);if(s)return s.unshift(n.value),s}const Xo=e=>{if(typeof e!="string")return;const t=Go(e),n=t?Yo(t,!0):void 0;let s,a=0,i=it.length;for(;a<i;)if((s=it[a++](e,n))!==void 0)return s;return t?qo(t):void 0};function Wo(e,t){if(!t||t[0]!=="rgb"&&t[0]!=="rgba")return;const n={mode:"rgb"},[,s,a,i,o]=t;if(!(s.type===_.Hue||a.type===_.Hue||i.type===_.Hue))return s.type!==_.None&&(n.r=s.type===_.Number?s.value/255:s.value/100),a.type!==_.None&&(n.g=a.type===_.Number?a.value/255:a.value/100),i.type!==_.None&&(n.b=i.type===_.Number?i.value/255:i.value/100),o.type!==_.None&&(n.alpha=Math.min(1,Math.max(0,o.type===_.Number?o.value:o.value/100))),n}const Zo=e=>e==="transparent"?{mode:"rgb",r:0,g:0,b:0,alpha:0}:void 0,Ko=(e,t,n)=>e+n*(t-e),Jo=e=>{let t=[];for(let n=0;n<e.length-1;n++){let s=e[n],a=e[n+1];s===void 0&&a===void 0?t.push(void 0):s!==void 0&&a!==void 0?t.push([s,a]):t.push(s!==void 0?[s,s]:[a,a])}return t},Qo=e=>t=>{let n=Jo(t);return s=>{let a=s*n.length,i=s>=1?n.length-1:Math.max(Math.floor(a),0),o=n[i];return o===void 0?void 0:e(o[0],o[1],a-i)}},j=Qo(Ko),J=e=>{let t=!1,n=e.map(s=>s!==void 0?(t=!0,s):1);return t?n:e},ze={mode:"rgb",channels:["r","g","b","alpha"],parse:[Wo,zo,Oo,Lo,Zo,"srgb"],serialize:"srgb",interpolate:{r:j,g:j,b:j,alpha:{use:j,fixup:J}},gamut:!0,white:{r:1,g:1,b:1},black:{r:0,g:0,b:0}},zt=(e=0)=>Math.pow(Math.abs(e),563/256)*Math.sign(e),ys=e=>{let t=zt(e.r),n=zt(e.g),s=zt(e.b),a={mode:"xyz65",x:.5766690429101305*t+.1855582379065463*n+.1882286462349947*s,y:.297344975250536*t+.6273635662554661*n+.0752914584939979*s,z:.0270313613864123*t+.0706888525358272*n+.9913375368376386*s};return e.alpha!==void 0&&(a.alpha=e.alpha),a},$t=e=>Math.pow(Math.abs(e),256/563)*Math.sign(e),_s=({x:e,y:t,z:n,alpha:s})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let a={mode:"a98",r:$t(e*2.0415879038107465-t*.5650069742788597-.3447313507783297*n),g:$t(e*-.9692436362808798+t*1.8759675015077206+.0415550574071756*n),b:$t(e*.0134442806320312-t*.1183623922310184+1.0151749943912058*n)};return s!==void 0&&(a.alpha=s),a},Pt=(e=0)=>{const t=Math.abs(e);return t<=.04045?e/12.92:(Math.sign(e)||1)*Math.pow((t+.055)/1.055,2.4)},$e=({r:e,g:t,b:n,alpha:s})=>{let a={mode:"lrgb",r:Pt(e),g:Pt(t),b:Pt(n)};return s!==void 0&&(a.alpha=s),a},Me=e=>{let{r:t,g:n,b:s,alpha:a}=$e(e),i={mode:"xyz65",x:.4123907992659593*t+.357584339383878*n+.1804807884018343*s,y:.2126390058715102*t+.715168678767756*n+.0721923153607337*s,z:.0193308187155918*t+.119194779794626*n+.9505321522496607*s};return a!==void 0&&(i.alpha=a),i},Dt=(e=0)=>{const t=Math.abs(e);return t>.0031308?(Math.sign(e)||1)*(1.055*Math.pow(t,1/2.4)-.055):e*12.92},Pe=({r:e,g:t,b:n,alpha:s},a="rgb")=>{let i={mode:a,r:Dt(e),g:Dt(t),b:Dt(n)};return s!==void 0&&(i.alpha=s),i},Ce=({x:e,y:t,z:n,alpha:s})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let a=Pe({r:e*3.2409699419045226-t*1.537383177570094-.4986107602930034*n,g:e*-.9692436362808796+t*1.8759675015077204+.0415550574071756*n,b:e*.0556300796969936-t*.2039769588889765+1.0569715142428784*n});return s!==void 0&&(a.alpha=s),a},el={...ze,mode:"a98",parse:["a98-rgb"],serialize:"a98-rgb",fromMode:{rgb:e=>_s(Me(e)),xyz65:_s},toMode:{rgb:e=>Ce(ys(e)),xyz65:ys}},ne=e=>(e=e%360)<0?e+360:e,tl=(e,t)=>e.map((n,s,a)=>{if(n===void 0)return n;let i=ne(n);return s===0||e[s-1]===void 0?i:t(i-ne(a[s-1]))}).reduce((n,s)=>!n.length||s===void 0||n[n.length-1]===void 0?(n.push(s),n):(n.push(s+n[n.length-1]),n),[]),fe=e=>tl(e,t=>Math.abs(t)<=180?t:t-360*Math.sign(t)),te=[-.14861,1.78277,-.29227,-.90649,1.97294,0],nl=Math.PI/180,sl=180/Math.PI;let ws=te[3]*te[4],js=te[1]*te[4],Ns=te[1]*te[2]-te[0]*te[3];const al=({r:e,g:t,b:n,alpha:s})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let a=(Ns*n+e*ws-t*js)/(Ns+ws-js),i=n-a,o=(te[4]*(t-a)-te[2]*i)/te[3],l={mode:"cubehelix",l:a,s:a===0||a===1?void 0:Math.sqrt(i*i+o*o)/(te[4]*a*(1-a))};return l.s&&(l.h=Math.atan2(o,i)*sl-120),s!==void 0&&(l.alpha=s),l},rl=({h:e,s:t,l:n,alpha:s})=>{let a={mode:"rgb"};e=(e===void 0?0:e+120)*nl,n===void 0&&(n=0);let i=t===void 0?0:t*n*(1-n),o=Math.cos(e),l=Math.sin(e);return a.r=n+i*(te[0]*o+te[1]*l),a.g=n+i*(te[2]*o+te[3]*l),a.b=n+i*(te[4]*o+te[5]*l),s!==void 0&&(a.alpha=s),a},bt=(e,t)=>{if(e.h===void 0||t.h===void 0||!e.s||!t.s)return 0;let n=ne(e.h),s=ne(t.h),a=Math.sin((s-n+360)/2*Math.PI/180);return 2*Math.sqrt(e.s*t.s)*a},il=(e,t)=>{if(e.h===void 0||t.h===void 0)return 0;let n=ne(e.h),s=ne(t.h);return Math.abs(s-n)>180?n-(s-360*Math.sign(s-n)):s-n},vt=(e,t)=>{if(e.h===void 0||t.h===void 0||!e.c||!t.c)return 0;let n=ne(e.h),s=ne(t.h),a=Math.sin((s-n+360)/2*Math.PI/180);return 2*Math.sqrt(e.c*t.c)*a},me=e=>{let t=e.reduce((s,a)=>{if(a!==void 0){let i=a*Math.PI/180;s.sin+=Math.sin(i),s.cos+=Math.cos(i)}return s},{sin:0,cos:0}),n=Math.atan2(t.sin,t.cos)*180/Math.PI;return n<0?360+n:n},ol={mode:"cubehelix",channels:["h","s","l","alpha"],parse:["--cubehelix"],serialize:"--cubehelix",ranges:{h:[0,360],s:[0,4.614],l:[0,1]},fromMode:{rgb:al},toMode:{rgb:rl},interpolate:{h:{use:j,fixup:fe},s:j,l:j,alpha:{use:j,fixup:J}},difference:{h:bt},average:{h:me}},ve=({l:e,a:t,b:n,alpha:s},a="lch")=>{t===void 0&&(t=0),n===void 0&&(n=0);let i=Math.sqrt(t*t+n*n),o={mode:a,l:e,c:i};return i&&(o.h=ne(Math.atan2(n,t)*180/Math.PI)),s!==void 0&&(o.alpha=s),o},ye=({l:e,c:t,h:n,alpha:s},a="lab")=>{n===void 0&&(n=0);let i={mode:a,l:e,a:t?t*Math.cos(n/180*Math.PI):0,b:t?t*Math.sin(n/180*Math.PI):0};return s!==void 0&&(i.alpha=s),i},za=Math.pow(29,3)/Math.pow(3,3),$a=Math.pow(6,3)/Math.pow(29,3),Z={X:.3457/.3585,Y:1,Z:(1-.3457-.3585)/.3585},Le={X:.3127/.329,Y:1,Z:(1-.3127-.329)/.329};let Ot=e=>Math.pow(e,3)>$a?Math.pow(e,3):(116*e-16)/za;const Pa=({l:e,a:t,b:n,alpha:s})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let a=(e+16)/116,i=t/500+a,o=a-n/200,l={mode:"xyz65",x:Ot(i)*Le.X,y:Ot(a)*Le.Y,z:Ot(o)*Le.Z};return s!==void 0&&(l.alpha=s),l},yt=e=>Ce(Pa(e)),Ft=e=>e>$a?Math.cbrt(e):(za*e+16)/116,Da=({x:e,y:t,z:n,alpha:s})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let a=Ft(e/Le.X),i=Ft(t/Le.Y),o=Ft(n/Le.Z),l={mode:"lab65",l:116*i-16,a:500*(a-i),b:200*(i-o)};return s!==void 0&&(l.alpha=s),l},_t=e=>{let t=Da(Me(e));return e.r===e.b&&e.b===e.g&&(t.a=t.b=0),t},lt=1,Oa=1,Ue=26/180*Math.PI,ct=Math.cos(Ue),dt=Math.sin(Ue),Fa=100/Math.log(139/100),un=({l:e,c:t,h:n,alpha:s})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let a={mode:"lab65",l:(Math.exp(e*lt/Fa)-1)/.0039},i=(Math.exp(.0435*t*Oa*lt)-1)/.075,o=i*Math.cos(n/180*Math.PI-Ue),l=i*Math.sin(n/180*Math.PI-Ue);return a.a=o*ct-l/.83*dt,a.b=o*dt+l/.83*ct,s!==void 0&&(a.alpha=s),a},fn=({l:e,a:t,b:n,alpha:s})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let a=t*ct+n*dt,i=.83*(n*ct-t*dt),o=Math.sqrt(a*a+i*i),l={mode:"dlch",l:Fa/lt*Math.log(1+.0039*e),c:Math.log(1+.075*o)/(.0435*Oa*lt)};return l.c&&(l.h=ne((Math.atan2(i,a)+Ue)/Math.PI*180)),s!==void 0&&(l.alpha=s),l},ks=e=>un(ve(e,"dlch")),Ms=e=>ye(fn(e),"dlab"),ll={mode:"dlab",parse:["--din99o-lab"],serialize:"--din99o-lab",toMode:{lab65:ks,rgb:e=>yt(ks(e))},fromMode:{lab65:Ms,rgb:e=>Ms(_t(e))},channels:["l","a","b","alpha"],ranges:{l:[0,100],a:[-40.09,45.501],b:[-40.469,44.344]},interpolate:{l:j,a:j,b:j,alpha:{use:j,fixup:J}}},cl={mode:"dlch",parse:["--din99o-lch"],serialize:"--din99o-lch",toMode:{lab65:un,dlab:e=>ye(e,"dlab"),rgb:e=>yt(un(e))},fromMode:{lab65:fn,dlab:e=>ve(e,"dlch"),rgb:e=>fn(_t(e))},channels:["l","c","h","alpha"],ranges:{l:[0,100],c:[0,51.484],h:[0,360]},interpolate:{l:j,c:j,h:{use:j,fixup:fe},alpha:{use:j,fixup:J}},difference:{h:vt},average:{h:me}};function dl({h:e,s:t,i:n,alpha:s}){e=ne(e!==void 0?e:0),t===void 0&&(t=0),n===void 0&&(n=0);let a=Math.abs(e/60%2-1),i;switch(Math.floor(e/60)){case 0:i={r:n*(1+t*(3/(2-a)-1)),g:n*(1+t*(3*(1-a)/(2-a)-1)),b:n*(1-t)};break;case 1:i={r:n*(1+t*(3*(1-a)/(2-a)-1)),g:n*(1+t*(3/(2-a)-1)),b:n*(1-t)};break;case 2:i={r:n*(1-t),g:n*(1+t*(3/(2-a)-1)),b:n*(1+t*(3*(1-a)/(2-a)-1))};break;case 3:i={r:n*(1-t),g:n*(1+t*(3*(1-a)/(2-a)-1)),b:n*(1+t*(3/(2-a)-1))};break;case 4:i={r:n*(1+t*(3*(1-a)/(2-a)-1)),g:n*(1-t),b:n*(1+t*(3/(2-a)-1))};break;case 5:i={r:n*(1+t*(3/(2-a)-1)),g:n*(1-t),b:n*(1+t*(3*(1-a)/(2-a)-1))};break;default:i={r:n*(1-t),g:n*(1-t),b:n*(1-t)}}return i.mode="rgb",s!==void 0&&(i.alpha=s),i}function ul({r:e,g:t,b:n,alpha:s}){e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let a=Math.max(e,t,n),i=Math.min(e,t,n),o={mode:"hsi",s:e+t+n===0?0:1-3*i/(e+t+n),i:(e+t+n)/3};return a-i!==0&&(o.h=(a===e?(t-n)/(a-i)+(t<n)*6:a===t?(n-e)/(a-i)+2:(e-t)/(a-i)+4)*60),s!==void 0&&(o.alpha=s),o}const fl={mode:"hsi",toMode:{rgb:dl},parse:["--hsi"],serialize:"--hsi",fromMode:{rgb:ul},channels:["h","s","i","alpha"],ranges:{h:[0,360]},gamut:"rgb",interpolate:{h:{use:j,fixup:fe},s:j,i:j,alpha:{use:j,fixup:J}},difference:{h:bt},average:{h:me}};function ml({h:e,s:t,l:n,alpha:s}){e=ne(e!==void 0?e:0),t===void 0&&(t=0),n===void 0&&(n=0);let a=n+t*(n<.5?n:1-n),i=a-(a-n)*2*Math.abs(e/60%2-1),o;switch(Math.floor(e/60)){case 0:o={r:a,g:i,b:2*n-a};break;case 1:o={r:i,g:a,b:2*n-a};break;case 2:o={r:2*n-a,g:a,b:i};break;case 3:o={r:2*n-a,g:i,b:a};break;case 4:o={r:i,g:2*n-a,b:a};break;case 5:o={r:a,g:2*n-a,b:i};break;default:o={r:2*n-a,g:2*n-a,b:2*n-a}}return o.mode="rgb",s!==void 0&&(o.alpha=s),o}function hl({r:e,g:t,b:n,alpha:s}){e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let a=Math.max(e,t,n),i=Math.min(e,t,n),o={mode:"hsl",s:a===i?0:(a-i)/(1-Math.abs(a+i-1)),l:.5*(a+i)};return a-i!==0&&(o.h=(a===e?(t-n)/(a-i)+(t<n)*6:a===t?(n-e)/(a-i)+2:(e-t)/(a-i)+4)*60),s!==void 0&&(o.alpha=s),o}const gl=(e,t)=>{switch(t){case"deg":return+e;case"rad":return e/Math.PI*180;case"grad":return e/10*9;case"turn":return e*360}},xl=new RegExp(`^hsla?\\(\\s*${$o}${Ae}${Be}${Ae}${Be}\\s*(?:,\\s*${Bn}\\s*)?\\)$`),pl=e=>{let t=e.match(xl);if(!t)return;let n={mode:"hsl"};return t[3]!==void 0?n.h=+t[3]:t[1]!==void 0&&t[2]!==void 0&&(n.h=gl(t[1],t[2])),t[4]!==void 0&&(n.s=Math.min(Math.max(0,t[4]/100),1)),t[5]!==void 0&&(n.l=Math.min(Math.max(0,t[5]/100),1)),t[6]!==void 0?n.alpha=Math.max(0,Math.min(1,t[6]/100)):t[7]!==void 0&&(n.alpha=Math.max(0,Math.min(1,+t[7]))),n};function bl(e,t){if(!t||t[0]!=="hsl"&&t[0]!=="hsla")return;const n={mode:"hsl"},[,s,a,i,o]=t;if(s.type!==_.None){if(s.type===_.Percentage)return;n.h=s.value}if(a.type!==_.None){if(a.type===_.Hue)return;n.s=a.value/100}if(i.type!==_.None){if(i.type===_.Hue)return;n.l=i.value/100}return o.type!==_.None&&(n.alpha=Math.min(1,Math.max(0,o.type===_.Number?o.value:o.value/100))),n}const Ba={mode:"hsl",toMode:{rgb:ml},fromMode:{rgb:hl},channels:["h","s","l","alpha"],ranges:{h:[0,360]},gamut:"rgb",parse:[bl,pl],serialize:e=>`hsl(${e.h!==void 0?e.h:"none"} ${e.s!==void 0?e.s*100+"%":"none"} ${e.l!==void 0?e.l*100+"%":"none"}${e.alpha<1?` / ${e.alpha}`:""})`,interpolate:{h:{use:j,fixup:fe},s:j,l:j,alpha:{use:j,fixup:J}},difference:{h:bt},average:{h:me}};function Ua({h:e,s:t,v:n,alpha:s}){e=ne(e!==void 0?e:0),t===void 0&&(t=0),n===void 0&&(n=0);let a=Math.abs(e/60%2-1),i;switch(Math.floor(e/60)){case 0:i={r:n,g:n*(1-t*a),b:n*(1-t)};break;case 1:i={r:n*(1-t*a),g:n,b:n*(1-t)};break;case 2:i={r:n*(1-t),g:n,b:n*(1-t*a)};break;case 3:i={r:n*(1-t),g:n*(1-t*a),b:n};break;case 4:i={r:n*(1-t*a),g:n*(1-t),b:n};break;case 5:i={r:n,g:n*(1-t),b:n*(1-t*a)};break;default:i={r:n*(1-t),g:n*(1-t),b:n*(1-t)}}return i.mode="rgb",s!==void 0&&(i.alpha=s),i}function Ha({r:e,g:t,b:n,alpha:s}){e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let a=Math.max(e,t,n),i=Math.min(e,t,n),o={mode:"hsv",s:a===0?0:1-i/a,v:a};return a-i!==0&&(o.h=(a===e?(t-n)/(a-i)+(t<n)*6:a===t?(n-e)/(a-i)+2:(e-t)/(a-i)+4)*60),s!==void 0&&(o.alpha=s),o}const Va={mode:"hsv",toMode:{rgb:Ua},parse:["--hsv"],serialize:"--hsv",fromMode:{rgb:Ha},channels:["h","s","v","alpha"],ranges:{h:[0,360]},gamut:"rgb",interpolate:{h:{use:j,fixup:fe},s:j,v:j,alpha:{use:j,fixup:J}},difference:{h:bt},average:{h:me}};function vl({h:e,w:t,b:n,alpha:s}){if(t===void 0&&(t=0),n===void 0&&(n=0),t+n>1){let a=t+n;t/=a,n/=a}return Ua({h:e,s:n===1?1:1-t/(1-n),v:1-n,alpha:s})}function yl(e){let t=Ha(e);if(t===void 0)return;let n=t.s!==void 0?t.s:0,s=t.v!==void 0?t.v:0,a={mode:"hwb",w:(1-n)*s,b:1-s};return t.h!==void 0&&(a.h=t.h),t.alpha!==void 0&&(a.alpha=t.alpha),a}function _l(e,t){if(!t||t[0]!=="hwb")return;const n={mode:"hwb"},[,s,a,i,o]=t;if(s.type!==_.None){if(s.type===_.Percentage)return;n.h=s.value}if(a.type!==_.None){if(a.type===_.Hue)return;n.w=a.value/100}if(i.type!==_.None){if(i.type===_.Hue)return;n.b=i.value/100}return o.type!==_.None&&(n.alpha=Math.min(1,Math.max(0,o.type===_.Number?o.value:o.value/100))),n}const wl={mode:"hwb",toMode:{rgb:vl},fromMode:{rgb:yl},channels:["h","w","b","alpha"],ranges:{h:[0,360]},gamut:"rgb",parse:[_l],serialize:e=>`hwb(${e.h!==void 0?e.h:"none"} ${e.w!==void 0?e.w*100+"%":"none"} ${e.b!==void 0?e.b*100+"%":"none"}${e.alpha<1?` / ${e.alpha}`:""})`,interpolate:{h:{use:j,fixup:fe},w:j,b:j,alpha:{use:j,fixup:J}},difference:{h:il},average:{h:me}},Ga=203,wt=.1593017578125,qa=78.84375,jt=.8359375,Nt=18.8515625,kt=18.6875;function Bt(e){if(e<0)return 0;const t=Math.pow(e,1/qa);return 1e4*Math.pow(Math.max(0,t-jt)/(Nt-kt*t),1/wt)}function Ut(e){if(e<0)return 0;const t=Math.pow(e/1e4,wt);return Math.pow((jt+Nt*t)/(1+kt*t),qa)}const Ht=e=>Math.max(e/Ga,0),Cs=({i:e,t,p:n,alpha:s})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);const a=Bt(e+.008609037037932761*t+.11102962500302593*n),i=Bt(e-.00860903703793275*t-.11102962500302599*n),o=Bt(e+.5600313357106791*t-.32062717498731885*n),l={mode:"xyz65",x:Ht(2.070152218389422*a-1.3263473389671556*i+.2066510476294051*o),y:Ht(.3647385209748074*a+.680566024947227*i-.0453045459220346*o),z:Ht(-.049747207535812*a-.0492609666966138*i+1.1880659249923042*o)};return s!==void 0&&(l.alpha=s),l},Vt=(e=0)=>Math.max(e*Ga,0),Ss=({x:e,y:t,z:n,alpha:s})=>{const a=Vt(e),i=Vt(t),o=Vt(n),l=Ut(.3592832590121217*a+.6976051147779502*i-.0358915932320289*o),c=Ut(-.1920808463704995*a+1.1004767970374323*i+.0753748658519118*o),f=Ut(.0070797844607477*a+.0748396662186366*i+.8433265453898765*o),m=.5*l+.5*c,u=1.61376953125*l-3.323486328125*c+1.709716796875*f,h=4.378173828125*l-4.24560546875*c-.132568359375*f,d={mode:"itp",i:m,t:u,p:h};return s!==void 0&&(d.alpha=s),d},jl={mode:"itp",channels:["i","t","p","alpha"],parse:["--ictcp"],serialize:"--ictcp",toMode:{xyz65:Cs,rgb:e=>Ce(Cs(e))},fromMode:{xyz65:Ss,rgb:e=>Ss(Me(e))},ranges:{i:[0,.581],t:[-.369,.272],p:[-.164,.331]},interpolate:{i:j,t:j,p:j,alpha:{use:j,fixup:J}}},Nl=134.03437499999998,kl=16295499532821565e-27,Gt=e=>{if(e<0)return 0;let t=Math.pow(e/1e4,wt);return Math.pow((jt+Nt*t)/(1+kt*t),Nl)},qt=(e=0)=>Math.max(e*203,0),Ya=({x:e,y:t,z:n,alpha:s})=>{e=qt(e),t=qt(t),n=qt(n);let a=1.15*e-.15*n,i=.66*t+.34*e,o=Gt(.41478972*a+.579999*i+.014648*n),l=Gt(-.20151*a+1.120649*i+.0531008*n),c=Gt(-.0166008*a+.2648*i+.6684799*n),f=(o+l)/2,m={mode:"jab",j:.44*f/(1-.56*f)-kl,a:3.524*o-4.066708*l+.542708*c,b:.199076*o+1.096799*l-1.295875*c};return s!==void 0&&(m.alpha=s),m},Ml=134.03437499999998,Es=16295499532821565e-27,Yt=e=>{if(e<0)return 0;let t=Math.pow(e,1/Ml);return 1e4*Math.pow((jt-t)/(kt*t-Nt),1/wt)},Xt=e=>e/203,Xa=({j:e,a:t,b:n,alpha:s})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let a=(e+Es)/(.44+.56*(e+Es)),i=Yt(a+.13860504*t+.058047316*n),o=Yt(a-.13860504*t-.058047316*n),l=Yt(a-.096019242*t-.8118919*n),c={mode:"xyz65",x:Xt(1.661373024652174*i-.914523081304348*o+.23136208173913045*l),y:Xt(-.3250758611844533*i+1.571847026732543*o-.21825383453227928*l),z:Xt(-.090982811*i-.31272829*o+1.5227666*l)};return s!==void 0&&(c.alpha=s),c},Wa=e=>{let t=Ya(Me(e));return e.r===e.b&&e.b===e.g&&(t.a=t.b=0),t},Za=e=>Ce(Xa(e)),Cl={mode:"jab",channels:["j","a","b","alpha"],parse:["--jzazbz"],serialize:"--jzazbz",fromMode:{rgb:Wa,xyz65:Ya},toMode:{rgb:Za,xyz65:Xa},ranges:{j:[0,.222],a:[-.109,.129],b:[-.185,.134]},interpolate:{j,a:j,b:j,alpha:{use:j,fixup:J}}},Ts=({j:e,a:t,b:n,alpha:s})=>{t===void 0&&(t=0),n===void 0&&(n=0);let a=Math.sqrt(t*t+n*n),i={mode:"jch",j:e,c:a};return a&&(i.h=ne(Math.atan2(n,t)*180/Math.PI)),s!==void 0&&(i.alpha=s),i},Is=({j:e,c:t,h:n,alpha:s})=>{n===void 0&&(n=0);let a={mode:"jab",j:e,a:t?t*Math.cos(n/180*Math.PI):0,b:t?t*Math.sin(n/180*Math.PI):0};return s!==void 0&&(a.alpha=s),a},Sl={mode:"jch",parse:["--jzczhz"],serialize:"--jzczhz",toMode:{jab:Is,rgb:e=>Za(Is(e))},fromMode:{rgb:e=>Ts(Wa(e)),jab:Ts},channels:["j","c","h","alpha"],ranges:{j:[0,.221],c:[0,.19],h:[0,360]},interpolate:{h:{use:j,fixup:fe},c:j,j,alpha:{use:j,fixup:J}},difference:{h:vt},average:{h:me}},Mt=Math.pow(29,3)/Math.pow(3,3),Un=Math.pow(6,3)/Math.pow(29,3);let Wt=e=>Math.pow(e,3)>Un?Math.pow(e,3):(116*e-16)/Mt;const Hn=({l:e,a:t,b:n,alpha:s})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let a=(e+16)/116,i=t/500+a,o=a-n/200,l={mode:"xyz50",x:Wt(i)*Z.X,y:Wt(a)*Z.Y,z:Wt(o)*Z.Z};return s!==void 0&&(l.alpha=s),l},Xe=({x:e,y:t,z:n,alpha:s})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let a=Pe({r:e*3.1341359569958707-t*1.6173863321612538-.4906619460083532*n,g:e*-.978795502912089+t*1.916254567259524+.03344273116131949*n,b:e*.07195537988411677-t*.2289768264158322+1.405386058324125*n});return s!==void 0&&(a.alpha=s),a},Ka=e=>Xe(Hn(e)),We=e=>{let{r:t,g:n,b:s,alpha:a}=$e(e),i={mode:"xyz50",x:.436065742824811*t+.3851514688337912*n+.14307845442264197*s,y:.22249319175623702*t+.7168870538238823*n+.06061979053616537*s,z:.013923904500943465*t+.09708128566574634*n+.7140993584005155*s};return a!==void 0&&(i.alpha=a),i},Zt=e=>e>Un?Math.cbrt(e):(Mt*e+16)/116,Vn=({x:e,y:t,z:n,alpha:s})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let a=Zt(e/Z.X),i=Zt(t/Z.Y),o=Zt(n/Z.Z),l={mode:"lab",l:116*i-16,a:500*(a-i),b:200*(i-o)};return s!==void 0&&(l.alpha=s),l},Ja=e=>{let t=Vn(We(e));return e.r===e.b&&e.b===e.g&&(t.a=t.b=0),t};function El(e,t){if(!t||t[0]!=="lab")return;const n={mode:"lab"},[,s,a,i,o]=t;if(!(s.type===_.Hue||a.type===_.Hue||i.type===_.Hue))return s.type!==_.None&&(n.l=Math.min(Math.max(0,s.value),100)),a.type!==_.None&&(n.a=a.type===_.Number?a.value:a.value*125/100),i.type!==_.None&&(n.b=i.type===_.Number?i.value:i.value*125/100),o.type!==_.None&&(n.alpha=Math.min(1,Math.max(0,o.type===_.Number?o.value:o.value/100))),n}const Gn={mode:"lab",toMode:{xyz50:Hn,rgb:Ka},fromMode:{xyz50:Vn,rgb:Ja},channels:["l","a","b","alpha"],ranges:{l:[0,100],a:[-125,125],b:[-125,125]},parse:[El],serialize:e=>`lab(${e.l!==void 0?e.l:"none"} ${e.a!==void 0?e.a:"none"} ${e.b!==void 0?e.b:"none"}${e.alpha<1?` / ${e.alpha}`:""})`,interpolate:{l:j,a:j,b:j,alpha:{use:j,fixup:J}}},Tl={...Gn,mode:"lab65",parse:["--lab-d65"],serialize:"--lab-d65",toMode:{xyz65:Pa,rgb:yt},fromMode:{xyz65:Da,rgb:_t},ranges:{l:[0,100],a:[-125,125],b:[-125,125]}};function Il(e,t){if(!t||t[0]!=="lch")return;const n={mode:"lch"},[,s,a,i,o]=t;if(s.type!==_.None){if(s.type===_.Hue)return;n.l=Math.min(Math.max(0,s.value),100)}if(a.type!==_.None&&(n.c=Math.max(0,a.type===_.Number?a.value:a.value*150/100)),i.type!==_.None){if(i.type===_.Percentage)return;n.h=i.value}return o.type!==_.None&&(n.alpha=Math.min(1,Math.max(0,o.type===_.Number?o.value:o.value/100))),n}const qn={mode:"lch",toMode:{lab:ye,rgb:e=>Ka(ye(e))},fromMode:{rgb:e=>ve(Ja(e)),lab:ve},channels:["l","c","h","alpha"],ranges:{l:[0,100],c:[0,150],h:[0,360]},parse:[Il],serialize:e=>`lch(${e.l!==void 0?e.l:"none"} ${e.c!==void 0?e.c:"none"} ${e.h!==void 0?e.h:"none"}${e.alpha<1?` / ${e.alpha}`:""})`,interpolate:{h:{use:j,fixup:fe},c:j,l:j,alpha:{use:j,fixup:J}},difference:{h:vt},average:{h:me}},Rl={...qn,mode:"lch65",parse:["--lch-d65"],serialize:"--lch-d65",toMode:{lab65:e=>ye(e,"lab65"),rgb:e=>yt(ye(e,"lab65"))},fromMode:{rgb:e=>ve(_t(e),"lch65"),lab65:e=>ve(e,"lch65")},ranges:{l:[0,100],c:[0,150],h:[0,360]}},Qa=({l:e,u:t,v:n,alpha:s})=>{t===void 0&&(t=0),n===void 0&&(n=0);let a=Math.sqrt(t*t+n*n),i={mode:"lchuv",l:e,c:a};return a&&(i.h=ne(Math.atan2(n,t)*180/Math.PI)),s!==void 0&&(i.alpha=s),i},er=({l:e,c:t,h:n,alpha:s})=>{n===void 0&&(n=0);let a={mode:"luv",l:e,u:t?t*Math.cos(n/180*Math.PI):0,v:t?t*Math.sin(n/180*Math.PI):0};return s!==void 0&&(a.alpha=s),a},tr=(e,t,n)=>4*e/(e+15*t+3*n),nr=(e,t,n)=>9*t/(e+15*t+3*n),Ll=tr(Z.X,Z.Y,Z.Z),Al=nr(Z.X,Z.Y,Z.Z),zl=e=>e<=Un?Mt*e:116*Math.cbrt(e)-16,mn=({x:e,y:t,z:n,alpha:s})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let a=zl(t/Z.Y),i=tr(e,t,n),o=nr(e,t,n);!isFinite(i)||!isFinite(o)?a=i=o=0:(i=13*a*(i-Ll),o=13*a*(o-Al));let l={mode:"luv",l:a,u:i,v:o};return s!==void 0&&(l.alpha=s),l},$l=(e,t,n)=>4*e/(e+15*t+3*n),Pl=(e,t,n)=>9*t/(e+15*t+3*n),Dl=$l(Z.X,Z.Y,Z.Z),Ol=Pl(Z.X,Z.Y,Z.Z),hn=({l:e,u:t,v:n,alpha:s})=>{if(e===void 0&&(e=0),e===0)return{mode:"xyz50",x:0,y:0,z:0};t===void 0&&(t=0),n===void 0&&(n=0);let a=t/(13*e)+Dl,i=n/(13*e)+Ol,o=Z.Y*(e<=8?e/Mt:Math.pow((e+16)/116,3)),l=o*(9*a)/(4*i),c=o*(12-3*a-20*i)/(4*i),f={mode:"xyz50",x:l,y:o,z:c};return s!==void 0&&(f.alpha=s),f},Fl=e=>Qa(mn(We(e))),Bl=e=>Xe(hn(er(e))),Ul={mode:"lchuv",toMode:{luv:er,rgb:Bl},fromMode:{rgb:Fl,luv:Qa},channels:["l","c","h","alpha"],parse:["--lchuv"],serialize:"--lchuv",ranges:{l:[0,100],c:[0,176.956],h:[0,360]},interpolate:{h:{use:j,fixup:fe},c:j,l:j,alpha:{use:j,fixup:J}},difference:{h:vt},average:{h:me}},Hl={...ze,mode:"lrgb",toMode:{rgb:Pe},fromMode:{rgb:$e},parse:["srgb-linear"],serialize:"srgb-linear"},Vl={mode:"luv",toMode:{xyz50:hn,rgb:e=>Xe(hn(e))},fromMode:{xyz50:mn,rgb:e=>mn(We(e))},channels:["l","u","v","alpha"],parse:["--luv"],serialize:"--luv",ranges:{l:[0,100],u:[-84.936,175.042],v:[-125.882,87.243]},interpolate:{l:j,u:j,v:j,alpha:{use:j,fixup:J}}},sr=({r:e,g:t,b:n,alpha:s})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let a=Math.cbrt(.412221469470763*e+.5363325372617348*t+.0514459932675022*n),i=Math.cbrt(.2119034958178252*e+.6806995506452344*t+.1073969535369406*n),o=Math.cbrt(.0883024591900564*e+.2817188391361215*t+.6299787016738222*n),l={mode:"oklab",l:.210454268309314*a+.7936177747023054*i-.0040720430116193*o,a:1.9779985324311684*a-2.42859224204858*i+.450593709617411*o,b:.0259040424655478*a+.7827717124575296*i-.8086757549230774*o};return s!==void 0&&(l.alpha=s),l},Ct=e=>{let t=sr($e(e));return e.r===e.b&&e.b===e.g&&(t.a=t.b=0),t},Ze=({l:e,a:t,b:n,alpha:s})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let a=Math.pow(e+.3963377773761749*t+.2158037573099136*n,3),i=Math.pow(e-.1055613458156586*t-.0638541728258133*n,3),o=Math.pow(e-.0894841775298119*t-1.2914855480194092*n,3),l={mode:"lrgb",r:4.076741636075957*a-3.3077115392580616*i+.2309699031821044*o,g:-1.2684379732850317*a+2.6097573492876887*i-.3413193760026573*o,b:-.0041960761386756*a-.7034186179359362*i+1.7076146940746117*o};return s!==void 0&&(l.alpha=s),l},St=e=>Pe(Ze(e));function gn(e){const s=1.170873786407767;return .5*(s*e-.206+Math.sqrt((s*e-.206)*(s*e-.206)+4*.03*s*e))}function ut(e){return(e*e+.206*e)/(1.170873786407767*(e+.03))}function Gl(e,t){let n,s,a,i,o,l,c,f;-1.88170328*e-.80936493*t>1?(n=1.19086277,s=1.76576728,a=.59662641,i=.75515197,o=.56771245,l=4.0767416621,c=-3.3077115913,f=.2309699292):1.81444104*e-1.19445276*t>1?(n=.73956515,s=-.45954404,a=.08285427,i=.1254107,o=.14503204,l=-1.2684380046,c=2.6097574011,f=-.3413193965):(n=1.35733652,s=-.00915799,a=-1.1513021,i=-.50559606,o=.00692167,l=-.0041960863,c=-.7034186147,f=1.707614701);let m=n+s*e+a*t+i*e*e+o*e*t,u=.3963377774*e+.2158037573*t,h=-.1055613458*e-.0638541728*t,d=-.0894841775*e-1.291485548*t;{let v=1+m*u,y=1+m*h,x=1+m*d,p=v*v*v,b=y*y*y,w=x*x*x,C=3*u*v*v,I=3*h*y*y,F=3*d*x*x,P=6*u*u*v,B=6*h*h*y,H=6*d*d*x,z=l*p+c*b+f*w,E=l*C+c*I+f*F,D=l*P+c*B+f*H;m=m-z*E/(E*E-.5*z*D)}return m}function Yn(e,t){let n=Gl(e,t),s=Ze({l:1,a:n*e,b:n*t}),a=Math.cbrt(1/Math.max(s.r,s.g,s.b)),i=a*n;return[a,i]}function ql(e,t,n,s,a,i=null){i||(i=Yn(e,t));let o;if((n-a)*i[1]-(i[0]-a)*s<=0)o=i[1]*a/(s*i[0]+i[1]*(a-n));else{o=i[1]*(a-1)/(s*(i[0]-1)+i[1]*(a-n));{let l=n-a,c=s,f=.3963377774*e+.2158037573*t,m=-.1055613458*e-.0638541728*t,u=-.0894841775*e-1.291485548*t,h=l+c*f,d=l+c*m,v=l+c*u;{let y=a*(1-o)+o*n,x=o*s,p=y+x*f,b=y+x*m,w=y+x*u,C=p*p*p,I=b*b*b,F=w*w*w,P=3*h*p*p,B=3*d*b*b,H=3*v*w*w,z=6*h*h*p,E=6*d*d*b,D=6*v*v*w,T=4.0767416621*C-3.3077115913*I+.2309699292*F-1,R=4.0767416621*P-3.3077115913*B+.2309699292*H,A=4.0767416621*z-3.3077115913*E+.2309699292*D,$=R/(R*R-.5*T*A),V=-T*$,q=-1.2684380046*C+2.6097574011*I-.3413193965*F-1,W=-1.2684380046*P+2.6097574011*B-.3413193965*H,ae=-1.2684380046*z+2.6097574011*E-.3413193965*D,Q=W/(W*W-.5*q*ae),k=-q*Q,O=-.0041960863*C-.7034186147*I+1.707614701*F-1,X=-.0041960863*P-.7034186147*B+1.707614701*H,ee=-.0041960863*z-.7034186147*E+1.707614701*D,re=X/(X*X-.5*O*ee),K=-O*re;V=$>=0?V:1e6,k=Q>=0?k:1e6,K=re>=0?K:1e6,o+=Math.min(V,Math.min(k,K))}}}return o}function Xn(e,t,n=null){n||(n=Yn(e,t));let s=n[0],a=n[1];return[a/s,a/(1-s)]}function ar(e,t,n){let s=Yn(t,n),a=ql(t,n,e,1,e,s),i=Xn(t,n,s),o=.11516993+1/(7.4477897+4.1590124*n+t*(-2.19557347+1.75198401*n+t*(-2.13704948-10.02301043*n+t*(-4.24894561+5.38770819*n+4.69891013*t)))),l=.11239642+1/(1.6132032-.68124379*n+t*(.40370612+.90148123*n+t*(-.27087943+.6122399*n+t*(.00299215-.45399568*n-.14661872*t)))),c=a/Math.min(e*i[0],(1-e)*i[1]),f=e*o,m=(1-e)*l,u=.9*c*Math.sqrt(Math.sqrt(1/(1/(f*f*f*f)+1/(m*m*m*m))));return f=e*.4,m=(1-e)*.8,[Math.sqrt(1/(1/(f*f)+1/(m*m))),u,a]}function Rs(e){const t=e.l!==void 0?e.l:0,n=e.a!==void 0?e.a:0,s=e.b!==void 0?e.b:0,a={mode:"okhsl",l:gn(t)};e.alpha!==void 0&&(a.alpha=e.alpha);let i=Math.sqrt(n*n+s*s);if(!i)return a.s=0,a;let[o,l,c]=ar(t,n/i,s/i),f;if(i<l){let m=0,u=.8*o,h=1-u/l;f=(i-m)/(u+h*(i-m))*.8}else{let m=l,u=.2*l*l*1.25*1.25/o,h=1-u/(c-l);f=.8+.2*((i-m)/(u+h*(i-m)))}return f&&(a.s=f,a.h=ne(Math.atan2(s,n)*180/Math.PI)),a}function Ls(e){let t=e.h!==void 0?e.h:0,n=e.s!==void 0?e.s:0,s=e.l!==void 0?e.l:0;const a={mode:"oklab",l:ut(s)};if(e.alpha!==void 0&&(a.alpha=e.alpha),!n||s===1)return a.a=a.b=0,a;let i=Math.cos(t/180*Math.PI),o=Math.sin(t/180*Math.PI),[l,c,f]=ar(a.l,i,o),m,u,h,d;n<.8?(m=1.25*n,u=0,h=.8*l,d=1-h/c):(m=5*(n-.8),u=c,h=.2*c*c*1.25*1.25/l,d=1-h/(f-c));let v=u+m*h/(1-d*m);return a.a=v*i,a.b=v*o,a}const Yl={...Ba,mode:"okhsl",channels:["h","s","l","alpha"],parse:["--okhsl"],serialize:"--okhsl",fromMode:{oklab:Rs,rgb:e=>Rs(Ct(e))},toMode:{oklab:Ls,rgb:e=>St(Ls(e))}};function As(e){let t=e.l!==void 0?e.l:0,n=e.a!==void 0?e.a:0,s=e.b!==void 0?e.b:0,a=Math.sqrt(n*n+s*s),i=a?n/a:1,o=a?s/a:1,[l,c]=Xn(i,o),f=.5,m=1-f/l,u=c/(a+t*c),h=u*t,d=u*a,v=ut(h),y=d*v/h,x=Ze({l:v,a:i*y,b:o*y}),p=Math.cbrt(1/Math.max(x.r,x.g,x.b,0));t=t/p,a=a/p*gn(t)/t,t=gn(t);const b={mode:"okhsv",s:a?(f+c)*d/(c*f+c*m*d):0,v:t?t/h:0};return b.s&&(b.h=ne(Math.atan2(s,n)*180/Math.PI)),e.alpha!==void 0&&(b.alpha=e.alpha),b}function zs(e){const t={mode:"oklab"};e.alpha!==void 0&&(t.alpha=e.alpha);const n=e.h!==void 0?e.h:0,s=e.s!==void 0?e.s:0,a=e.v!==void 0?e.v:0,i=Math.cos(n/180*Math.PI),o=Math.sin(n/180*Math.PI),[l,c]=Xn(i,o),f=.5,m=1-f/l,u=1-s*f/(f+c-c*m*s),h=s*c*f/(f+c-c*m*s),d=ut(u),v=h*d/u,y=Ze({l:d,a:i*v,b:o*v}),x=Math.cbrt(1/Math.max(y.r,y.g,y.b,0)),p=ut(a*u),b=h*p/u;return t.l=p*x,t.a=b*i*x,t.b=b*o*x,t}const Xl={...Va,mode:"okhsv",channels:["h","s","v","alpha"],parse:["--okhsv"],serialize:"--okhsv",fromMode:{oklab:As,rgb:e=>As(Ct(e))},toMode:{oklab:zs,rgb:e=>St(zs(e))}};function Wl(e,t){if(!t||t[0]!=="oklab")return;const n={mode:"oklab"},[,s,a,i,o]=t;if(!(s.type===_.Hue||a.type===_.Hue||i.type===_.Hue))return s.type!==_.None&&(n.l=Math.min(Math.max(0,s.type===_.Number?s.value:s.value/100),1)),a.type!==_.None&&(n.a=a.type===_.Number?a.value:a.value*.4/100),i.type!==_.None&&(n.b=i.type===_.Number?i.value:i.value*.4/100),o.type!==_.None&&(n.alpha=Math.min(1,Math.max(0,o.type===_.Number?o.value:o.value/100))),n}const Zl={...Gn,mode:"oklab",toMode:{lrgb:Ze,rgb:St},fromMode:{lrgb:sr,rgb:Ct},ranges:{l:[0,1],a:[-.4,.4],b:[-.4,.4]},parse:[Wl],serialize:e=>`oklab(${e.l!==void 0?e.l:"none"} ${e.a!==void 0?e.a:"none"} ${e.b!==void 0?e.b:"none"}${e.alpha<1?` / ${e.alpha}`:""})`};function Kl(e,t){if(!t||t[0]!=="oklch")return;const n={mode:"oklch"},[,s,a,i,o]=t;if(s.type!==_.None){if(s.type===_.Hue)return;n.l=Math.min(Math.max(0,s.type===_.Number?s.value:s.value/100),1)}if(a.type!==_.None&&(n.c=Math.max(0,a.type===_.Number?a.value:a.value*.4/100)),i.type!==_.None){if(i.type===_.Percentage)return;n.h=i.value}return o.type!==_.None&&(n.alpha=Math.min(1,Math.max(0,o.type===_.Number?o.value:o.value/100))),n}const Jl={...qn,mode:"oklch",toMode:{oklab:e=>ye(e,"oklab"),rgb:e=>St(ye(e,"oklab"))},fromMode:{rgb:e=>ve(Ct(e),"oklch"),oklab:e=>ve(e,"oklch")},parse:[Kl],serialize:e=>`oklch(${e.l!==void 0?e.l:"none"} ${e.c!==void 0?e.c:"none"} ${e.h!==void 0?e.h:"none"}${e.alpha<1?` / ${e.alpha}`:""})`,ranges:{l:[0,1],c:[0,.4],h:[0,360]}},$s=e=>{let{r:t,g:n,b:s,alpha:a}=$e(e),i={mode:"xyz65",x:.486570948648216*t+.265667693169093*n+.1982172852343625*s,y:.2289745640697487*t+.6917385218365062*n+.079286914093745*s,z:0*t+.0451133818589026*n+1.043944368900976*s};return a!==void 0&&(i.alpha=a),i},Ps=({x:e,y:t,z:n,alpha:s})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let a=Pe({r:e*2.4934969119414263-t*.9313836179191242-.402710784450717*n,g:e*-.8294889695615749+t*1.7626640603183465+.0236246858419436*n,b:e*.0358458302437845-t*.0761723892680418+.9568845240076871*n},"p3");return s!==void 0&&(a.alpha=s),a},Ql={...ze,mode:"p3",parse:["display-p3"],serialize:"display-p3",fromMode:{rgb:e=>Ps(Me(e)),xyz65:Ps},toMode:{rgb:e=>Ce($s(e)),xyz65:$s}},Kt=e=>{let t=Math.abs(e);return t>=1/512?Math.sign(e)*Math.pow(t,1/1.8):16*e},Ds=({x:e,y:t,z:n,alpha:s})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let a={mode:"prophoto",r:Kt(e*1.3457868816471585-t*.2555720873797946-.0511018649755453*n),g:Kt(e*-.5446307051249019+t*1.5082477428451466+.0205274474364214*n),b:Kt(e*0+t*0+1.2119675456389452*n)};return s!==void 0&&(a.alpha=s),a},Jt=(e=0)=>{let t=Math.abs(e);return t>=16/512?Math.sign(e)*Math.pow(t,1.8):e/16},Os=e=>{let t=Jt(e.r),n=Jt(e.g),s=Jt(e.b),a={mode:"xyz50",x:.7977666449006423*t+.1351812974005331*n+.0313477341283922*s,y:.2880748288194013*t+.7118352342418731*n+899369387256e-16*s,z:0*t+0*n+.8251046025104602*s};return e.alpha!==void 0&&(a.alpha=e.alpha),a},ec={...ze,mode:"prophoto",parse:["prophoto-rgb"],serialize:"prophoto-rgb",fromMode:{xyz50:Ds,rgb:e=>Ds(We(e))},toMode:{xyz50:Os,rgb:e=>Xe(Os(e))}},Fs=1.09929682680944,tc=.018053968510807,Qt=e=>{const t=Math.abs(e);return t>tc?(Math.sign(e)||1)*(Fs*Math.pow(t,.45)-(Fs-1)):4.5*e},Bs=({x:e,y:t,z:n,alpha:s})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let a={mode:"rec2020",r:Qt(e*1.7166511879712683-t*.3556707837763925-.2533662813736599*n),g:Qt(e*-.6666843518324893+t*1.6164812366349395+.0157685458139111*n),b:Qt(e*.0176398574453108-t*.0427706132578085+.9421031212354739*n)};return s!==void 0&&(a.alpha=s),a},Us=1.09929682680944,nc=.018053968510807,en=(e=0)=>{let t=Math.abs(e);return t<nc*4.5?e/4.5:(Math.sign(e)||1)*Math.pow((t+Us-1)/Us,1/.45)},Hs=e=>{let t=en(e.r),n=en(e.g),s=en(e.b),a={mode:"xyz65",x:.6369580483012911*t+.1446169035862083*n+.1688809751641721*s,y:.262700212011267*t+.6779980715188708*n+.059301716469862*s,z:0*t+.0280726930490874*n+1.0609850577107909*s};return e.alpha!==void 0&&(a.alpha=e.alpha),a},sc={...ze,mode:"rec2020",fromMode:{xyz65:Bs,rgb:e=>Bs(Me(e))},toMode:{xyz65:Hs,rgb:e=>Ce(Hs(e))},parse:["rec2020"],serialize:"rec2020"},je=.0037930732552754493,rr=Math.cbrt(je),tn=e=>Math.cbrt(e)-rr,ac=e=>{const{r:t,g:n,b:s,alpha:a}=$e(e),i=tn(.3*t+.622*n+.078*s+je),o=tn(.23*t+.692*n+.078*s+je),l=tn(.2434226892454782*t+.2047674442449682*n+.5518098665095535*s+je),c={mode:"xyb",x:(i-o)/2,y:(i+o)/2,b:l-(i+o)/2};return a!==void 0&&(c.alpha=a),c},nn=e=>Math.pow(e+rr,3),rc=({x:e,y:t,b:n,alpha:s})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);const a=nn(e+t)-je,i=nn(t-e)-je,o=nn(n+t)-je,l=Pe({r:11.031566904639861*a-9.866943908131562*i-.16462299650829934*o,g:-3.2541473810744237*a+4.418770377582723*i-.16462299650829934*o,b:-3.6588512867136815*a+2.7129230459360922*i+1.9459282407775895*o});return s!==void 0&&(l.alpha=s),l},ic={mode:"xyb",channels:["x","y","b","alpha"],parse:["--xyb"],serialize:"--xyb",toMode:{rgb:rc},fromMode:{rgb:ac},ranges:{x:[-.0154,.0281],y:[0,.8453],b:[-.2778,.388]},interpolate:{x:j,y:j,b:j,alpha:{use:j,fixup:J}}},oc={mode:"xyz50",parse:["xyz-d50"],serialize:"xyz-d50",toMode:{rgb:Xe,lab:Vn},fromMode:{rgb:We,lab:Hn},channels:["x","y","z","alpha"],ranges:{x:[0,.964],y:[0,.999],z:[0,.825]},interpolate:{x:j,y:j,z:j,alpha:{use:j,fixup:J}}},lc=e=>{let{x:t,y:n,z:s,alpha:a}=e;t===void 0&&(t=0),n===void 0&&(n=0),s===void 0&&(s=0);let i={mode:"xyz50",x:1.0479298208405488*t+.0229467933410191*n-.0501922295431356*s,y:.0296278156881593*t+.990434484573249*n-.0170738250293851*s,z:-.0092430581525912*t+.0150551448965779*n+.7518742899580008*s};return a!==void 0&&(i.alpha=a),i},cc=e=>{let{x:t,y:n,z:s,alpha:a}=e;t===void 0&&(t=0),n===void 0&&(n=0),s===void 0&&(s=0);let i={mode:"xyz65",x:.9554734527042182*t-.0230985368742614*n+.0632593086610217*s,y:-.0283697069632081*t+1.0099954580058226*n+.021041398966943*s,z:.0123140016883199*t-.0205076964334779*n+1.3303659366080753*s};return a!==void 0&&(i.alpha=a),i},dc={mode:"xyz65",toMode:{rgb:Ce,xyz50:lc},fromMode:{rgb:Me,xyz50:cc},ranges:{x:[0,.95],y:[0,1],z:[0,1.088]},channels:["x","y","z","alpha"],parse:["xyz","xyz-d65"],serialize:"xyz-d65",interpolate:{x:j,y:j,z:j,alpha:{use:j,fixup:J}}},uc=({r:e,g:t,b:n,alpha:s})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);const a={mode:"yiq",y:.29889531*e+.58662247*t+.11448223*n,i:.59597799*e-.2741761*t-.32180189*n,q:.21147017*e-.52261711*t+.31114694*n};return s!==void 0&&(a.alpha=s),a},fc=({y:e,i:t,q:n,alpha:s})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);const a={mode:"rgb",r:e+.95608445*t+.6208885*n,g:e-.27137664*t-.6486059*n,b:e-1.10561724*t+1.70250126*n};return s!==void 0&&(a.alpha=s),a},mc={mode:"yiq",toMode:{rgb:fc},fromMode:{rgb:uc},channels:["y","i","q","alpha"],parse:["--yiq"],serialize:"--yiq",ranges:{i:[-.595,.595],q:[-.522,.522]},interpolate:{y:j,i:j,q:j,alpha:{use:j,fixup:J}}},hc=e=>Math.max(0,Math.min(1,e||0)),sn=e=>Math.round(hc(e)*255),gc=ce("rgb"),xc=e=>{if(e===void 0)return;let t=sn(e.r),n=sn(e.g),s=sn(e.b);return"#"+(1<<24|t<<16|n<<8|s).toString(16).slice(1)},pc=e=>xc(gc(e)),ir=ce("rgb"),or=e=>{const t={mode:e.mode,r:Math.max(0,Math.min(e.r!==void 0?e.r:0,1)),g:Math.max(0,Math.min(e.g!==void 0?e.g:0,1)),b:Math.max(0,Math.min(e.b!==void 0?e.b:0,1))};return e.alpha!==void 0&&(t.alpha=e.alpha),t},bc=e=>or(ir(e)),lr=e=>e!==void 0&&(e.r===void 0||e.r>=0&&e.r<=1)&&(e.g===void 0||e.g>=0&&e.g<=1)&&(e.b===void 0||e.b>=0&&e.b<=1);function vc(e){return lr(ir(e))}function cr(e="rgb"){const{gamut:t}=pt(e);if(!t)return s=>!0;const n=ce(typeof t=="string"?t:e);return s=>lr(n(s))}function yc(e="rgb"){const{gamut:t}=pt(e);if(!t)return i=>rt(i);const n=typeof t=="string"?t:e,s=ce(n),a=cr(n);return i=>{const o=rt(i);if(!o)return;const l=s(o);if(a(l))return o;const c=or(l);return o.mode===c.mode?c:ce(o.mode)(c)}}function _c(e,t="lch",n="rgb"){e=rt(e);let s=n==="rgb"?vc:cr(n),a=n==="rgb"?bc:yc(n);if(e===void 0||s(e))return e;let i=ce(e.mode);e=ce(t)(e);let o={...e,c:0};if(!s(o))return i(a(o));let l=0,c=e.c!==void 0?e.c:0,f=pt(t).ranges.c,m=(f[1]-f[0])/Math.pow(2,13),u=o.c;for(;c-l>m;)o.c=l+(c-l)*.5,s(o)?(u=o.c,l=o.c):c=o.c;return i(s(o)?o:{...o,c:u})}function Vs(e){let t=ce("lrgb")(e);return .2126*t.r+.7152*t.g+.0722*t.b}function dr(e,t){let n=Vs(e),s=Vs(t);return(Math.max(n,s)+.05)/(Math.min(n,s)+.05)}G(el);G(ol);G(ll);G(cl);G(fl);G(Ba);G(Va);G(wl);G(jl);G(Cl);G(Sl);G(Gn);G(Tl);G(qn);G(Rl);G(Ul);G(Hl);G(Vl);G(Yl);G(Xl);G(Zl);G(Jl);G(Ql);G(ec);G(sc);G(ze);G(ic);G(oc);G(dc);G(mc);const xn=/^#?(?:[0-9a-f]{3}|[0-9a-f]{6})$/i;function pn(e){const t=e.trim();return t.startsWith("#")?t:`#${t}`}const wc=4.5,jc={dark:"#1e2330",light:"#f1f0ee"},bn="#FFFFFF",vn="#040403";function Gs(e,t){return typeof e!="string"||typeof t!="string"||!xn.test(e.trim())||!xn.test(t.trim())?Number.NaN:dr(pn(e),pn(t))}function Nc(e){const t=Gs(e,vn);if(!Number.isNaN(t))return t>=Gs(e,bn)?vn:bn}const kc={dark:.3,light:.9},Mc={dark:bn,light:vn},Cc=ce("oklch");function Sc(e,t){if(e==null||!xn.test(e.trim()))return;const n=Cc(pn(e));if(!n)return;const s=pc(_c({...n,l:kc[t]},"oklch"));return dr(s,Mc[t])>=wc?s:void 0}function Wn({variant:e,accentColor:t,status:n="ready",layout:s="featured",thumbnailUrl:a,mimeType:i,sourceUrl:o}){const[l,c]=g.useState(!1);g.useEffect(()=>{c(!1)},[a]);const f=g.useCallback(()=>{c(!0)},[]),m=Ye(i,o),h=s==="featured"&&!!a&&!m&&!l&&n==="ready"?Sc(t,e):void 0,d=h??(m?Io:jc[e]);return{thumbnailUrl:l?void 0:a,accentStyle:h?{backgroundColor:h}:void 0,chinTextColor:Nc(d),tailColor:d,isLoading:n==="loading",onImageError:f}}const Ec="flex size-6 items-center justify-center rounded-full bg-[#121110] text-white focus-ring",Tc="relative before:absolute before:-inset-[10px] before:content-['']",Ic=({title:e,placeholderTitle:t,description:n,url:s,mimeType:a,thumbnailUrl:i,sourceUrl:o,layout:l="featured",appIcon:c,cta:f,accentColor:m,status:u="ready",onDismiss:h,onEditClick:d,dismissLabel:v="Dismiss attachment"})=>{const y=l==="classic",x=Ye(a,o),p=Wn({variant:"dark",accentColor:m,status:u,layout:l,thumbnailUrl:i,mimeType:a,sourceUrl:o}),b=h?r.jsx("button",{type:"button",onClick:h,"aria-label":v,className:S(Ec,!x&&Tc),children:r.jsx(M.XIcon,{className:"size-3",weight:"bold"})}):void 0,w=d?r.jsx("button",{type:"button",onClick:d,"aria-label":"Edit attachment",className:"flex size-10 items-center justify-center rounded-full bg-white/10 text-white hover:bg-white/15",children:r.jsx(M.PencilSimpleIcon,{className:"size-5",weight:"regular"})}):void 0;return x&&!p.isLoading?r.jsx(st,{variant:"dark",bgClassName:Fn,children:r.jsxs("div",{className:"flex items-center gap-2 pr-3",children:[r.jsx("div",{className:"min-w-0 flex-1",children:r.jsx(at,{variant:"dark",sourceUrl:o,title:e,mimeType:a})}),b&&r.jsx("div",{className:"shrink-0",children:b})]})}):r.jsxs(st,{variant:"dark",fixedHeight:!y,accentStyle:p.accentStyle,busy:p.isLoading,topRight:y?b:void 0,children:[!y&&r.jsx(at,{variant:"dark",thumbnailUrl:p.thumbnailUrl,sourceUrl:o,title:e,mimeType:a,topRight:b,isLoading:p.isLoading,onImageError:p.onImageError}),r.jsx(Dn,{chinTextColor:p.chinTextColor,variant:"dark",title:e,placeholderTitle:t,description:n,url:s,appIcon:c,cta:f,trailingAction:w,isLoading:p.isLoading})]})},ur=({color:e,side:t,visible:n,children:s})=>n?r.jsxs("div",{className:"relative isolate w-fit",children:[s,r.jsx("span",{"aria-hidden":!0,"data-testid":"link-card-tail",style:{backgroundColor:e},className:S("messaging-link-card-tail",t==="receiver"&&"messaging-link-card-tail--received")})]}):r.jsx(r.Fragment,{children:s}),Rc=({title:e,description:t,url:n,mimeType:s,thumbnailUrl:a,sourceUrl:i,layout:o="featured",appIcon:l,cta:c,accentColor:f,status:m="ready",onClick:u,groupPosition:h="single"})=>{const d=On(s,i),v=Pn(n),y=c==null&&v!=null&&!d?v:void 0,x=c==null&&!d?u:void 0,p=m!=="loading"&&Ye(s,i)?Fn:void 0,b=c&&u?{...c,onClick:()=>{var C;u(),(C=c.onClick)==null||C.call(c)}}:c,w=Wn({variant:"light",accentColor:f,status:m,layout:o,thumbnailUrl:a,mimeType:s,sourceUrl:i});return r.jsx(ur,{color:w.tailColor,side:"receiver",visible:p==null&&(h==="single"||h==="end"),children:r.jsxs(st,{variant:"light",href:y,onClick:x,ariaLabel:e??"Open attachment preview",fixedHeight:o==="featured"&&p==null,accentStyle:w.accentStyle,busy:w.isLoading,bgClassName:p,"data-testid":"link-attachment",children:[o==="featured"&&r.jsx(at,{variant:"light",thumbnailUrl:w.thumbnailUrl,sourceUrl:i,title:e,mimeType:s,isLoading:w.isLoading,onImageError:w.onImageError}),r.jsx(Dn,{chinTextColor:w.chinTextColor,variant:"light",title:e,description:t,url:n,appIcon:l,cta:b,isLoading:w.isLoading})]})})},Lc=({title:e,placeholderTitle:t,description:n,url:s,mimeType:a,thumbnailUrl:i,sourceUrl:o,layout:l="featured",appIcon:c,cta:f,accentColor:m,status:u="ready",onClick:h,groupPosition:d="single"})=>{const v=On(a,o),y=Pn(s),x=f==null&&y!=null&&!v?y:void 0,p=f==null&&!v&&x!=null?h:void 0,b=u!=="loading"&&Ye(a,o),w=Wn({variant:"dark",accentColor:m,status:u,layout:l,thumbnailUrl:i,mimeType:a,sourceUrl:o});return r.jsx(ur,{color:w.tailColor,side:"sender",visible:!b&&(d==="single"||d==="end"),children:r.jsxs(st,{variant:"dark",href:x,onClick:p,fixedHeight:l==="featured"&&!b,accentStyle:w.accentStyle,busy:w.isLoading,bgClassName:b?Fn:void 0,children:[l==="featured"&&r.jsx(at,{variant:"dark",thumbnailUrl:w.thumbnailUrl,sourceUrl:o,title:e,mimeType:a,isLoading:w.isLoading,onImageError:w.onImageError}),r.jsx(Dn,{chinTextColor:w.chinTextColor,variant:"dark",title:e,placeholderTitle:t,description:n,url:s,appIcon:c,cta:f,isLoading:w.isLoading})]})})},ft={Composer:Ic,Sent:Lc,Received:Rc};function U(e){const t=e==null?void 0:e.trim();return t||void 0}function qs(e){return e.trim().replace(/^https?:\/\//i,"").replace(/\/+$/,"").toLowerCase()}function Ac(e,t){if(!(e!=null&&e.trim())||!(t!=null&&t.trim()))return!1;const n=qs(e),s=qs(t);if(n===s)return!0;if(!n.includes(s))return!1;const a=n.split(s).join("");return!/[^\p{P}\p{Z}\p{C}]/u.test(a)}function Ys(e){const t=U(e.og_scrape_url)??U(e.title_link),n=U(e.image_url)??U(e.thumb_url),s=U(e.asset_url),a=U(e.mime_type);return{title:U(e.title),description:U(e.text),url:t,thumbnailUrl:be(n),sourceUrl:s,layout:n||On(a,s)?"featured":"classic",mimeType:a,accentColor:U(e.accent_color),status:"ready"}}function zc(e){var t;return fr(e)?null:e.type==="image"?e.image_url||e.asset_url?"image":null:e.type==="video"&&e.asset_url?"video":e.type==="audio"&&e.asset_url?"audio":e.type==="file"&&e.asset_url?e.mime_type==="application/pdf"?"pdf":(t=e.mime_type)!=null&&t.startsWith("audio/")?"audio":"file":null}function fr(e){const t=U(e.og_scrape_url);return e.type==="link"||!!t&&!e.asset_url}function mr(e){if(!(e!=null&&e.length))return[];const t=[],n=(a,i)=>{const o=t[t.length-1];if((o==null?void 0:o.type)==="media"&&o.kind===a){o.attachments.push(i);return}t.push({type:"media",kind:a,attachments:[i]})},s=a=>{const i=t[t.length-1];if((i==null?void 0:i.type)==="link"){i.attachments.push(a);return}t.push({type:"link",attachments:[a]})};for(const a of e){if(fr(a)){s(a);continue}const i=zc(a);i&&n(i,a)}return t}function $c(e){return e.filter(t=>t.type==="media").length}function Pc(e,t,n){return t<=1?n:e===0?"first":e===t-1?"end":"middle"}function Xs(e){return U(e.image_url)??U(e.asset_url)??""}function Dc(e){switch(e){case"image":return Re.Image;case"video":return Re.Video;case"audio":return Re.Audio;case"pdf":return Re.Pdf;default:return Re.File}}function Oc(e,t){if(t.length>1)switch(e){case"image":return{items:t.map(s=>({src:Xs(s),alt:U(s.title)}))};case"video":return{items:t.map(s=>({src:U(s.asset_url)??"",poster:U(s.thumb_url),mimeType:U(s.mime_type)}))};case"audio":return{items:t.map(s=>({src:U(s.asset_url)??"",mimeType:U(s.mime_type)??"audio/mpeg",filename:U(s.title)}))};case"pdf":return{items:t.map(s=>({src:U(s.asset_url)??"",filename:U(s.title),fileSize:s.file_size}))};case"file":return{items:t.map(s=>({src:U(s.asset_url)??"",filename:U(s.title),fileSize:s.file_size,mimeType:U(s.mime_type)??"application/octet-stream"}))}}const n=t[0];if(!n)return{};switch(e){case"image":return{src:Xs(n),alt:U(n.title)};case"video":return{src:U(n.asset_url)??"",poster:U(n.thumb_url),mimeType:U(n.mime_type)};case"audio":return{src:U(n.asset_url)??"",mimeType:U(n.mime_type)??"audio/mpeg",filename:U(n.title)};case"pdf":return{src:U(n.asset_url)??"",filename:U(n.title),fileSize:n.file_size};case"file":return{src:U(n.asset_url)??"",filename:U(n.title),fileSize:n.file_size,mimeType:U(n.mime_type)??"application/octet-stream"}}}function Fc({groupPosition:e,isMyMessage:t,segment:n}){const s=Dc(n.kind),a={...Oc(n.kind,n.attachments),groupPosition:e};return t?r.jsx(s.Sent,{...a}):r.jsx(s.Received,{...a})}const Bc=({groupPosition:e,isMyMessage:t,message:n,renderText:s})=>{var y;const a=mr(n.attachments);if(a.length===0)return null;const i=$c(a),o=(y=n.text)==null?void 0:y.trim(),l=a.find(x=>x.type==="link"),c=(l==null?void 0:l.type)==="link"?Ys(l.attachments[0]??{}).url:void 0,f=o&&Ac(o,c)?void 0:o;let m=0;const u=[],h=f?"middle":e,d=(x,p,b)=>{const w=t?ft.Sent:ft.Received;u.push(r.jsx(w,{...Ys(x),groupPosition:b?h:"middle"},p))},v=(x,p)=>{const b=Pc(m,i,e);m+=1,u.push(r.jsx(Fc,{groupPosition:b,isMyMessage:t,segment:x},p))};return a.forEach((x,p)=>{const b=p===a.length-1;if(x.type==="link"){x.attachments.forEach((w,C)=>{d(w,`link-${p}-${C}`,b&&C===x.attachments.length-1)});return}v(x,`media-${p}`)}),r.jsxs("div",{className:"str-chat__message-bubble-wrapper",children:[r.jsxs("div",{className:"str-chat__message-bubble","data-attachment-bubble":"true",style:{background:"transparent",borderRadius:0,overflow:"visible",padding:0},children:[u,!f&&r.jsx(N.MessageErrorIcon,{})]}),f?r.jsxs("div",{className:"str-chat__message-bubble",children:[r.jsx(N.MessageText,{message:n,renderText:s}),r.jsx(N.MessageErrorIcon,{})]}):null]})},Uc=e=>{var ss,as,rs,is,os,ls,cs,ds,us,fs;const{additionalMessageInputProps:t,chatbotVotingEnabled:n,editing:s,endOfGroup:a,firstOfGroup:i,groupedByUser:o,handleAction:l,handleOpenThread:c,handleRetry:f,highlighted:m,isMessageAIGenerated:u,isMyMessage:h,message:d,renderText:v,threadList:y,viewerLanguage:x,onBroadcastClick:p}=e,{client:b}=N.useChatContext("CustomMessage"),{channel:w}=N.useChannelStateContext("CustomMessage"),{isUnlocking:C,onUnlockClick:I,onFetchSource:F,onDownloadClick:P}=Ca("LockedAttachment"),[B,H]=g.useState(!1),z=N.useMessageReminder(d.id),{selected:E,voteUp:D,voteDown:T}=aa(d),{Attachment:R=N.Attachment,EditMessageModal:A=N.EditMessageModal,MessageActions:$,MessageBlocked:V=N.MessageBlocked,MessageBouncePrompt:q=N.MessageBouncePrompt,MessageDeleted:W=N.MessageDeleted,MessageIsThreadReplyInChannelButtonIndicator:ae=N.MessageIsThreadReplyInChannelButtonIndicator,MessageRepliesCountButton:Q=N.MessageRepliesCountButton,ReminderNotification:k=N.ReminderNotification,StreamedMessageText:O=N.StreamedMessageText,PinIndicator:X}=N.useComponentContext("CustomMessage"),ee=N.messageHasAttachments(d),re=N.messageHasReactions(d),K=g.useMemo(()=>u==null?void 0:u(d),[u,d]),Y=g.useMemo(()=>{const we=d.attachments??[],Te=d.shared_location?[d.shared_location,...we]:we;if(!nt(d))return Te;const ms=Te.filter(hs=>!("type"in hs)||!Sn(hs));return ms.length===Te.length?Te:ms},[d]),ie=g.useMemo(()=>mr(Y),[Y]),he=g.useMemo(()=>{const we=Nn({message:d,viewerLanguage:x});return we===d.text?d:{...d,text:we}},[d,x]),Ke=ie.length>0,Je=ie.reduce((we,Te)=>we+Te.attachments.length,0)===((Y==null?void 0:Y.length)??0),ge=ua({endOfGroup:a,firstOfGroup:i,groupedByUser:o});if(N.isDateSeparatorMessage(d))return null;if(d.deleted_at||d.type==="deleted")return r.jsx(W,{message:d});if(N.isMessageBlocked(d))return r.jsx(V,{});const _e=!y&&!!d.reply_count,xe=!y&&d.show_in_channel&&d.parent_id,Kn=d.status==="failed"&&((ss=d.error)==null?void 0:ss.status)!==403,Jn=N.isMessageBounced(d);let Se;Kn?Se=()=>f(d):Jn&&(Se=()=>H(!0));const oe=h(),wr=S("str-chat__message str-chat__message-simple",`str-chat__message--${d.type}`,`str-chat__message--${d.status}`,oe?"str-chat__message--me str-chat__message-simple--me":"str-chat__message--other",d.text?"str-chat__message--has-text":"has-no-text",{"str-chat__message--has-attachment":ee,"str-chat__message--highlighted":m,"str-chat__message--pinned pinned-message":d.pinned,"str-chat__message--with-reactions":re,"str-chat__message-send-can-be-retried":(d==null?void 0:d.status)==="failed"&&((as=d==null?void 0:d.error)==null?void 0:as.status)!==403,"str-chat__message-with-thread-link":_e||xe,"str-chat__virtual-message__wrapper--end":a,"str-chat__virtual-message__wrapper--first":i,"str-chat__virtual-message__wrapper--group":o}),Et=d.poll_id&&b.polls.fromState(d.poll_id),Qn=ho(d),Ee=nt(d),jr=zn(d),Tt=!!(Y!=null&&Y.length&&!d.quoted_message),es=Ee&&oe&&Tt,Nr=Ke&&Je&&!d.quoted_message&&!Et&&!K&&!Ee,ts={contentType:"text",amountText:(rs=d.metadata)==null?void 0:rs.amount_text,paymentStatus:(is=d.metadata)==null?void 0:is.payment_status,renderedText:d.text&&r.jsx(N.MessageText,{message:he,renderText:v})},ns={contentType:"media",title:(os=d.metadata)==null?void 0:os.attachment_title,mimeType:(ls=d.metadata)==null?void 0:ls.attachment_mime_type,thumbnailUrl:(cs=d.metadata)==null?void 0:cs.attachment_thumbnail,amountText:(ds=d.metadata)==null?void 0:ds.amount_text,detail:(us=d.metadata)==null?void 0:us.attachment_detail,paymentStatus:(fs=d.metadata)==null?void 0:fs.payment_status,onFetchSource:F?()=>F(d,w):void 0};return r.jsxs(r.Fragment,{children:[s&&r.jsx(A,{additionalMessageInputProps:t}),B&&r.jsx(N.MessageBounceModal,{MessageBouncePrompt:q,onClose:()=>H(!1),open:B}),r.jsxs("div",{className:wr,"data-message-id":d.id,"data-dd-privacy":"mask",children:[X&&r.jsx(X,{}),!!z&&r.jsx(k,{reminder:z}),d.user&&r.jsx(ke,{className:"str-chat__avatar str-chat__message-sender-avatar",id:d.user.id,image:d.user.image,name:d.user.name||d.user.id,size:24,shape:"circle",dmAgentEnabled:Ee}),r.jsx("div",{className:S("str-chat__message-inner",{"str-chat__simple-message--error-failed":Kn||Jn}),"data-testid":"message-inner",onClick:Se,onKeyDown:Se,role:Se?"button":void 0,tabIndex:Se?0:void 0,style:{marginInlineEnd:0,marginInlineStart:0},children:Qn?r.jsx(Lt,{message:d,standalone:!0}):fo(d)?r.jsx("div",{className:"str-chat__message-bubble-wrapper",children:r.jsxs("div",{className:"flex items-center gap-2",children:[oe&&$&&r.jsx($,{}),oe?r.jsx(Oe,{...ts,isMine:!0}):r.jsx(Oe,{...ts,isMine:!1,isUnlocking:C(d.id),onUnlockClick:()=>I==null?void 0:I(d,w)}),!oe&&$&&r.jsx($,{})]})}):mo(d)?r.jsxs("div",{className:"str-chat__message-bubble-wrapper",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[oe&&$&&r.jsx($,{}),oe?r.jsx(Oe,{...ns,isMine:!0,onPreviewClick:()=>I?I(d,w):void 0}):r.jsx(Oe,{...ns,isMine:!1,isUnlocking:C(d.id),onUnlockClick:()=>I?I(d,w):void 0,onDownloadClick:()=>P?P(d,w):void 0}),!oe&&$&&r.jsx($,{})]}),d.text&&r.jsx("div",{className:"str-chat__message-bubble",children:r.jsx(N.MessageText,{message:he,renderText:v})})]}):Nr?r.jsx(Bc,{groupPosition:ge,isMyMessage:oe,message:{...he,attachments:Y,i18n:void 0},renderText:v}):r.jsx("div",{className:"str-chat__message-bubble-wrapper",children:r.jsxs("div",{className:"str-chat__message-bubble",children:[Ee&&!es&&r.jsx(Lt,{message:d,hasAttachment:Tt,isMyMessage:oe}),Et&&r.jsx(N.Poll,{poll:Et}),Y!=null&&Y.length&&!d.quoted_message?r.jsx(R,{actionHandler:l,attachments:Y}):null,K?r.jsx(O,{message:he,renderText:v}):r.jsx(N.MessageText,{message:he,renderText:v}),r.jsx(N.MessageErrorIcon,{})]})})}),!jr&&!Qn&&r.jsxs("div",{className:"str-chat__message-footer",children:[(!Ee||es)&&r.jsx(Lt,{message:d,hasAttachment:Tt,isMyMessage:oe}),n&&Ee&&r.jsx(Ta,{selected:E,onVoteUp:D,onVoteDown:T})]}),r.jsx(bo,{onBroadcastClick:p}),_e&&r.jsx(Q,{onClick:c,reply_count:d.reply_count}),xe&&r.jsx(ae,{})]},d.id)]})},Hc=g.memo(Uc,(e,t)=>e.chatbotVotingEnabled!==t.chatbotVotingEnabled||e.viewerLanguage!==t.viewerLanguage||e.onBroadcastClick!==t.onBroadcastClick?!1:N.areMessageUIPropsEqual(e,t)),Vc=e=>{const t=N.useMessageContext("CustomMessage");return r.jsx(Hc,{...t,...e})},Gc=()=>{var n;const{handleDelete:e,message:t}=N.useMessageContext("CustomMessageActions");return((n=t.metadata)==null?void 0:n.payment_status)==="paid"?null:r.jsx(yn.DefaultDropdownActionButton,{onClick:e,"aria-label":"Delete",title:"Delete",className:"bg-marble rounded-full p-2 hover:bg-sand transition-all",children:r.jsx(M.TrashSimpleIcon,{size:16,weight:"light","aria-hidden":!0})})},qc=()=>{const{handleFlag:e}=N.useMessageContext("CustomMessageActions");return r.jsx(yn.DefaultDropdownActionButton,{onClick:e,"aria-label":"Report",title:"Report",className:"bg-marble rounded-full p-2 hover:bg-sand transition-all",children:r.jsx(M.FlagIcon,{size:16,weight:"light","aria-hidden":!0})})},Yc=()=>{var t;const{message:e}=N.useMessageContext("CustomMessageActions");return((t=e.metadata)==null?void 0:t.custom_type)!==se.MESSAGE_CUSTOM_TYPE.ATTACHMENT?null:r.jsx(yn.MessageActions,{messageActionSet:[{Component:Gc,placement:"quick",type:"delete"},{Component:qc,placement:"quick",type:"flag"}]})},Xc=e=>({linkPreviews:Array.from(e.previews.values()).filter(t=>tt.LinkPreviewsManager.previewIsLoaded(t)||tt.LinkPreviewsManager.previewIsLoading(t))}),Wc=()=>{const{linkPreviewsManager:e}=N.useMessageComposer(),{linkPreviews:t}=N.useStateStore(e.state,Xc),n=a=>{e.dismissPreview(a)};return t.length>0?r.jsx("div",{className:"messaging-link-preview-list flex min-h-0 flex-col items-stretch w-full gap-2 overflow-y-auto overscroll-contain",children:t.map(a=>{const i=tt.LinkPreviewsManager.previewIsLoading(a);return r.jsx("div",{className:"w-full shrink-0",children:r.jsx(ft.Composer,{title:a.title,url:a.og_scrape_url,thumbnailUrl:a.image_url,layout:i||a.image_url?"featured":"classic",status:i?"loading":"ready",onDismiss:()=>n(a.og_scrape_url)})},a.og_scrape_url)})}):null},mt=g.createContext(!1),Zc=200,Kc=()=>g.useContext(mt),Jc=({sendMessage:e,disabled:t,...n})=>r.jsx("button",{...n,type:"button","aria-label":"Send",disabled:t,onPointerDown:s=>s.preventDefault(),onClick:e,children:r.jsx(M.ArrowUpIcon,{weight:"bold",className:"size-4"})}),Ws=()=>{const e=g.useContext(mt),{handleSubmit:t}=N.useMessageInputContext(),n=N.useMessageComposerHasSendableData(),s=e||!n,{SendButton:a=Jc,AttachmentPreviewList:i=N.AttachmentPreviewList}=N.useComponentContext("CustomMessageInput");return r.jsxs("div",{className:"central-container flex min-h-0 flex-col min-w-0 w-full self-stretch bg-white rounded-[1.5rem] shadow-[0_4px_16px_0_rgba(0,0,0,0.08),0_1px_2px_0_rgba(0,0,0,0.04),0_0_0_1px_rgba(0,0,0,0.04)] [&>:not(.messaging-composer-previews):not(.messaging-composer-row)]:p-2","data-dd-privacy":"mask",children:[r.jsxs("div",{className:"messaging-composer-previews empty:hidden flex min-h-0 flex-col gap-2 px-2 pt-2",children:[r.jsx(N.QuotedMessagePreview,{}),r.jsx(Wc,{}),r.jsx(i,{})]}),r.jsxs("div",{className:"messaging-composer-row flex shrink-0 items-start",children:[r.jsx(N.TextareaComposer,{"aria-disabled":e||void 0,containerClassName:"min-w-0 flex-1 leading-[0]",className:"w-full resize-none bg-transparent py-3.5 pl-4 pr-4 outline-none leading-5 placeholder:text-black/30 text-sm",autoFocus:!e,enterKeyHint:"send",maxRows:4,readOnly:e,tabIndex:e?-1:void 0}),r.jsx("div",{className:"mt-auto mb-2 mr-2 shrink-0",children:r.jsx(a,{sendMessage:t,"aria-label":"Send",className:"str-chat__send-button relative flex justify-center items-center rounded-full size-8 bg-[#121110] disabled:bg-[#F1F0EE] disabled:text-black/20 text-white focus-ring before:absolute before:-inset-2 before:content-['']","data-testid":"send-button",disabled:s,type:"button"})})]})]})},Zs=({renderActions:e,renderHeader:t,renderFooter:n,disabled:s=!1,disabledReason:a,composerInput:i})=>{var m;const{channel:o}=N.useChannelStateContext(),l=((m=o==null?void 0:o.data)==null?void 0:m.frozen)===!0,c=!!i,f=g.useRef(null);return g.useEffect(()=>{if(!c)return;const u=f.current,h=u==null?void 0:u.parentElement;if(!u||!h)return;let d=u.offsetHeight;const v=()=>{const x=u.offsetHeight,p=x>d;d=x;const b=Array.from(h.querySelectorAll(".str-chat__list")).find(C=>C.scrollHeight>C.clientHeight)??null,w=b?b.scrollHeight-b.scrollTop-b.clientHeight<Zc:!1;h.style.setProperty("--messaging-composer-height",`${x}px`),p&&w&&b&&(b.scrollTop=b.scrollHeight)};if(v(),typeof ResizeObserver>"u")return;const y=new ResizeObserver(v);return y.observe(u),()=>{y.disconnect(),h.style.removeProperty("--messaging-composer-height")}},[c]),s?c?r.jsxs("div",{ref:f,className:"messaging-composer-chrome messaging-composer-chrome--floating",children:[r.jsxs("div",{className:"messaging-composer-backdrop","aria-hidden":"true",children:[r.jsx("div",{className:"messaging-composer-backdrop-blur"}),r.jsx("div",{className:"messaging-composer-backdrop-blur"}),r.jsx("div",{className:"messaging-composer-backdrop-blur"}),r.jsx("div",{className:"messaging-composer-backdrop-blur"}),r.jsx("div",{className:"messaging-composer-backdrop-blur"}),r.jsx("div",{className:"messaging-composer-backdrop-gradient"})]}),r.jsxs("div",{className:"relative z-10 flex flex-col",children:[t==null?void 0:t(),r.jsx("div",{className:"messaging-composer-locked-panel flex w-full flex-col items-center justify-center gap-3 px-6 py-4",children:a?r.jsx("p",{className:"max-w-[345px] text-center text-xs font-normal leading-[1.3] tracking-[0.12px] text-black/40",children:a}):null}),n==null?void 0:n()]})]}):r.jsxs(r.Fragment,{children:[t==null?void 0:t(),r.jsx("div",{className:"messaging-composer-locked-panel flex w-full flex-col items-center justify-center gap-3 px-6 py-4",children:a?r.jsx("p",{className:"max-w-[345px] text-center text-xs font-normal leading-[1.3] tracking-[0.12px] text-black/40",children:a}):null}),n==null?void 0:n()]}):c?r.jsxs("div",{ref:f,className:"messaging-composer-chrome messaging-composer-chrome--floating",children:[r.jsxs("div",{className:"messaging-composer-backdrop","aria-hidden":"true",children:[r.jsx("div",{className:"messaging-composer-backdrop-blur"}),r.jsx("div",{className:"messaging-composer-backdrop-blur"}),r.jsx("div",{className:"messaging-composer-backdrop-blur"}),r.jsx("div",{className:"messaging-composer-backdrop-blur"}),r.jsx("div",{className:"messaging-composer-backdrop-blur"}),r.jsx("div",{className:"messaging-composer-backdrop-gradient"})]}),r.jsxs("div",{className:"relative z-10 flex min-h-0 flex-col",children:[t==null?void 0:t(),r.jsxs("div",{className:"flex min-h-0 flex-col gap-4 p-4",children:[r.jsxs("div",{inert:l?"":void 0,"aria-disabled":l||void 0,className:"message-input flex min-h-0 items-end gap-4 aria-disabled:opacity-40",children:[e&&r.jsx("div",{className:"flex h-12 shrink-0 items-center justify-center",children:e()}),r.jsx(mt.Provider,{value:l,children:r.jsx(N.MessageInput,{Input:i??Ws})})]}),n==null?void 0:n()]})]})]}):r.jsxs("div",{className:"flex min-h-0 flex-col gap-4 p-4",children:[t==null?void 0:t(),r.jsxs("div",{inert:l?"":void 0,"aria-disabled":l||void 0,className:"message-input flex min-h-0 items-end gap-4 aria-disabled:opacity-40",children:[e&&r.jsx("div",{className:"flex h-12 shrink-0 items-center justify-center",children:e()}),r.jsx(mt.Provider,{value:l,children:r.jsx(N.MessageInput,{Input:Ws})})]}),n==null?void 0:n()]})},Qc={SYSTEM_DM_AGENT_PAUSED:"DM Agent has left the conversation",SYSTEM_DM_AGENT_RESUMED:"DM Agent has rejoined the conversation"},ed=["SYSTEM_AGE_SAFETY_BLOCKED"],td={SYSTEM_AGE_SAFETY_BLOCKED:"This user isn’t able to reply because they don’t meet our age safety guidelines."},an="age safety guidelines.",nd="https://linktr.ee/s/about/contact",sd=e=>ed.includes(e),ad=e=>{var t;return sd((t=e.metadata)==null?void 0:t.custom_type)},rd=e=>{var s;const t=(s=e.metadata)==null?void 0:s.custom_type;if(se.isDmAgentSystemType(t))return{kind:"dm-agent",type:t};if(se.isAgeSafetySystemType(t))return{kind:"age-safety",type:t};const n=e.dm_agent_system_type;if(se.isDmAgentSystemType(n))return{kind:"dm-agent",type:n}},id=e=>{const t=e.indexOf(an);if(t===-1)return e;const n=t+an.length;return r.jsxs(r.Fragment,{children:[e.slice(0,t),r.jsx("a",{href:nd,target:"_blank",rel:"noopener noreferrer",className:"mes-age-safety-system-message__emphasis font-medium text-inherit underline",children:an}),e.slice(n)]})},od=e=>{var s,a;const t=!ad(e.message),n=rd(e.message);if((n==null?void 0:n.kind)==="dm-agent"){const i=((s=e.message.text)==null?void 0:s.trim())||Qc[n.type];return r.jsxs("div",{className:"str-chat__message--system","data-testid":"message-system",children:[r.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:[r.jsx(M.SparkleIcon,{size:16,weight:"regular","aria-hidden":!0,className:"mes-dm-agent-system-message__sparkle shrink-0"}),r.jsx("p",{className:"mes-dm-agent-system-message__text m-0 text-center text-[14px] font-normal leading-5 tracking-[0.21px]",children:i})]}),!t&&r.jsx(N.MessageTimestamp,{message:e.message})]})}if((n==null?void 0:n.kind)==="age-safety"){const i=((a=e.message.text)==null?void 0:a.trim())||td[n.type];return r.jsxs("div",{className:"str-chat__message--system","data-testid":"message-system",children:[r.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:[r.jsx(M.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"}),r.jsx("div",{className:"mes-age-safety-system-message__content min-w-0 flex-[1_0_0]",children:r.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:id(i)})})]}),!t&&r.jsx(N.MessageTimestamp,{message:e.message})]})}return r.jsxs("div",{className:"str-chat__message--system","data-testid":"message-system",children:[r.jsxs("div",{className:"str-chat__message--system__text",children:[r.jsx("div",{className:"str-chat__message--system__line"}),r.jsx("p",{children:e.message.text}),r.jsx("div",{className:"str-chat__message--system__line"})]}),!t&&r.jsx(N.MessageTimestamp,{message:e.message})]})},hr=g.createContext(!1),rn=({cx:e,index:t})=>r.jsx("circle",{cx:e,cy:"6.15",r:"3.9",fill:"#A0A0A0",children:r.jsx("animateTransform",{attributeName:"transform",type:"translate",values:"0 0; 0 -2.25; 0 0;",dur:"900ms",begin:`${120*t}ms`,repeatCount:"indefinite"})}),ld=new Set([N.AIStates.Thinking,N.AIStates.Generating,N.AIStates.ExternalSources]),cd=({threadList:e})=>{var v,y;const{channel:t,channelConfig:n,thread:s}=N.useChannelStateContext(),{client:a}=N.useChatContext(),{typing:i={}}=N.useTypingContext(),{aiState:o}=N.useAIState(t),l=g.useContext(hr);if(!e&&l&&ld.has(o)){const x=dd(t,(v=a.user)==null?void 0:v.id);return r.jsx(Ks,{avatarId:(x==null?void 0:x.id)??"ai-agent",avatarName:(x==null?void 0:x.name)??(x==null?void 0:x.id)??"Agent",avatarImage:x==null?void 0:x.image,testId:"typing-indicator-ai"})}if((n==null?void 0:n.typing_events)===!1)return null;const f=e?[]:Object.values(i).filter(({parent_id:x,user:p})=>{var b;return(p==null?void 0:p.id)!==((b=a.user)==null?void 0:b.id)&&!x}),m=e?Object.values(i).filter(({parent_id:x,user:p})=>{var b;return(p==null?void 0:p.id)!==((b=a.user)==null?void 0:b.id)&&x===(s==null?void 0:s.id)}):[],u=e?m:f;if(!u.length)return null;const h=(y=u[0])==null?void 0:y.user,d=h!=null&&h.id&&t.state.members[h.id]?t.state.members[h.id].user:void 0;return r.jsx(Ks,{avatarId:(h==null?void 0:h.id)??(d==null?void 0:d.id)??"typing-user",avatarName:(h==null?void 0:h.name)??(d==null?void 0:d.name)??(h==null?void 0:h.id)??"Typing user",avatarImage:(h==null?void 0:h.image)??(d==null?void 0:d.image),testId:"typing-indicator"})},Ks=({avatarId:e,avatarName:t,avatarImage:n,testId:s})=>r.jsx("div",{className:"str-chat__li str-chat__li--single str-chat__typing-indicator !static","data-testid":s,style:{marginBottom:"var(--messaging-channel-input-spacer-height, 80px)"},children:r.jsxs("div",{className:"str-chat__message str-chat__message-simple str-chat__message--regular str-chat__message--received str-chat__message--other str-chat__message--has-text",children:[r.jsx(ke,{className:"str-chat__avatar str-chat__message-sender-avatar",id:e,name:t,image:n??void 0,size:24,shape:"circle"}),r.jsx("div",{className:"str-chat__message-inner mx-0",children:r.jsx("div",{className:"str-chat__message-bubble-wrapper",children:r.jsx("div",{className:"str-chat__message-bubble",children:r.jsx("div",{className:"str-chat__message-text min-h-11 flex items-center",children:r.jsx("div",{className:"str-chat__message-text-inner str-chat__message-simple-text-inner",children:r.jsxs("svg",{"aria-hidden":"true",className:"block overflow-visible",viewBox:"0 0 32 12.3",width:"32",height:"13",overflow:"visible",children:[r.jsx(rn,{cx:"4",index:0}),r.jsx(rn,{cx:"16",index:1}),r.jsx(rn,{cx:"28",index:2})]})})})})})})]})});function dd(e,t){var s;const n=((s=e==null?void 0:e.state)==null?void 0:s.members)??{};for(const a of Object.values(n)){const i=a==null?void 0:a.user;if(i&&i.id!==t)return i}}const gr=()=>null,ud=({className:e,message:t})=>r.jsxs("div",{className:S("flex items-center justify-center h-full",e),children:[r.jsxs("svg",{viewBox:"0 0 100 100",className:"size-8 fill-pebble",stroke:"none",children:[r.jsx("circle",{cx:"6",cy:"50",r:"6",children:r.jsx("animateTransform",{attributeName:"transform",dur:"1s",type:"translate",values:"0 15 ; 0 -15; 0 15",repeatCount:"indefinite",begin:"0.1"})}),r.jsx("circle",{cx:"30",cy:"50",r:"6",children:r.jsx("animateTransform",{attributeName:"transform",dur:"1s",type:"translate",values:"0 10 ; 0 -10; 0 10",repeatCount:"indefinite",begin:"0.2"})}),r.jsx("circle",{cx:"54",cy:"50",r:"6",children:r.jsx("animateTransform",{attributeName:"transform",dur:"1s",type:"translate",values:"0 5 ; 0 -5; 0 5",repeatCount:"indefinite",begin:"0.3"})})]}),t&&r.jsx("span",{className:"text-stone",children:t})]}),ht=g.memo(()=>r.jsx("div",{className:"messaging-loading-state flex items-center justify-center h-full",children:r.jsxs("div",{className:"flex items-center",children:[r.jsx(ud,{className:"w-6 h-6"}),r.jsx("span",{className:"text-sm text-stone",children:"Loading messages"})]})}));ht.displayName="LoadingState";const fd=({onBack:e,showBackButton:t,renderMessageInputActions:n,renderMessageInputFooter:s,renderConversationFooter:a,onLeaveConversation:i,onBlockParticipant:o,showDeleteConversation:l=!0,onDeleteConversationClick:c,onBlockParticipantClick:f,onReportParticipantClick:m,showBlockParticipant:u=!0,showReportParticipant:h=!0,composerDisabled:d=!1,composerDisabledReason:v,showStarButton:y=!1,chatbotVotingEnabled:x=!1,renderChannelBanner:p,customChannelActions:b,renderChannelActions:w,renderMessage:C,viewerLanguage:I,showChannelInfo:F=!0,onParticipantNameClick:P,onBroadcastClick:B,composerInput:H})=>{const{channel:z}=N.useChannelStateContext(),E=g.useRef(B);g.useEffect(()=>{E.current=B},[B]);const D=g.useCallback(q=>{var W;(W=E.current)==null||W.call(E,q)},[]),T=B?D:void 0,R=z.state.messages.some(q=>q.type!=="deleted"),A=p?r.jsx(g.Fragment,{children:p()},"lt-channel-banner"):null,$=r.jsx($r,{className:"-mx-[var(--str-chat\\_\\_spacing-2)] px-[var(--str-chat\\_\\_spacing-2)] md:-mx-[min(var(--str-chat\\_\\_spacing-10),4%)] md:px-[min(var(--str-chat\\_\\_spacing-10),4%)]",onBack:e,showBackButton:t,showChannelInfo:F,showStarButton:y,onLeaveConversation:i,onBlockParticipant:o,showDeleteConversation:l,showBlockParticipant:u,showReportParticipant:h,onDeleteConversationClick:c,onBlockParticipantClick:f,onReportParticipantClick:m,customChannelActions:b,renderChannelActions:w,onParticipantNameClick:P}),V=g.useCallback(q=>{const{message:W}=N.useMessageContext("ChannelView"),ae=r.jsx(Vc,{...q,chatbotVotingEnabled:x,viewerLanguage:I,onBroadcastClick:T});return!C||!W?ae:C(ae,W)},[x,T,C,I]);return r.jsx(r.Fragment,{children:r.jsx(N.WithComponents,{overrides:{Message:V,MessageActions:Yc,UnreadMessagesNotification:()=>null,UnreadMessagesSeparator:()=>null},children:r.jsx(N.Window,{children:H?r.jsxs("div",{className:"messaging-channel-layout relative flex min-h-0 flex-1 flex-col",children:[r.jsxs("div",{className:"messaging-channel-message-list messaging-channel-message-list--floating relative min-h-0 flex-1 overflow-hidden",children:[!R&&r.jsx("div",{className:"str-chat__list",children:r.jsxs("div",{className:"str-chat__message-list-scroll",children:[$,A]})}),r.jsx(N.MessageList,{head:R?r.jsxs("div",{className:"sticky top-0 z-10",children:[$,A]}):void 0,hideDeletedMessages:!0,hideNewMessageSeparator:!1})]},"lt-channel-message-list"),r.jsx(Zs,{...n&&{renderActions:()=>n==null?void 0:n(z)},...a&&{renderHeader:()=>a(z)},renderFooter:()=>s==null?void 0:s(z),disabled:d,disabledReason:v,composerInput:H},"lt-channel-message-input")]}):r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex-1 overflow-hidden relative",children:[!R&&r.jsx("div",{className:"str-chat__list",children:r.jsxs("div",{className:"str-chat__message-list-scroll",children:[$,A]})}),r.jsx(N.MessageList,{head:R?r.jsxs("div",{className:"sticky top-0 z-10",children:[$,A]}):void 0,hideDeletedMessages:!0,hideNewMessageSeparator:!1})]},"lt-channel-message-list"),a?r.jsx(g.Fragment,{children:a(z)},"lt-channel-conversation-footer"):null,r.jsx(Zs,{...n&&{renderActions:()=>n==null?void 0:n(z)},renderFooter:()=>s==null?void 0:s(z),disabled:d,disabledReason:v,composerInput:H},"lt-channel-message-input")]})})})})},Zn=g.memo(({channel:e,onBack:t,showBackButton:n=!1,renderMessageInputActions:s,renderMessageInputFooter:a,renderConversationFooter:i,onLeaveConversation:o,onBlockParticipant:l,className:c,CustomChannelEmptyState:f=gr,showDeleteConversation:m=!0,onDeleteConversationClick:u,onBlockParticipantClick:h,onReportParticipantClick:d,showBlockParticipant:v=!0,showReportParticipant:y=!0,composerDisabled:x=!1,composerDisabledReason:p,dmAgentEnabled:b,messageMetadata:w,onMessageSent:C,showStarButton:I=!1,chatbotVotingEnabled:F=!1,renderChannelBanner:P,customChannelActions:B,renderChannelActions:H,renderMessage:z,onMessageLinkClick:E,sendButton:D,attachmentPreviewList:T,viewerLanguage:R,showChannelInfo:A=!0,onParticipantNameClick:$,onBroadcastClick:V,composerInput:q})=>{const W=g.useCallback(async(Q,k,O)=>{var ie;const X=((ie=e.data)==null?void 0:ie.chatbot_paused)===!0,ee=b&&!X,re={...k,...ee&&{silent:!0},...w&&{metadata:{...k.metadata??{},...w}}},K={...O,...ee&&{skip_push:!0}},Y=await e.sendMessage(re,K);return C==null||C(Y),Y},[e,b,w,C]),ae=g.useRef(null);return g.useEffect(()=>{if(!E)return;const Q=ae.current;if(!Q)return;const k=O=>{const X=O.target,ee=X==null?void 0:X.closest("a[href]"),re=ee==null?void 0:ee.getAttribute("href");if(!re)return;const K=ee==null?void 0:ee.closest("[data-message-id]"),Y=K==null?void 0:K.getAttribute("data-message-id"),ie=Y?e.state.messages.find(he=>he.id===Y):void 0;E(re,ie)};return Q.addEventListener("click",k),()=>Q.removeEventListener("click",k)},[E,e]),r.jsx("div",{ref:ae,className:S("messaging-channel-view h-full flex flex-col",c),children:r.jsx(hr.Provider,{value:b??!1,children:r.jsx(N.Channel,{channel:e,MessageSystem:od,EmptyStateIndicator:f,LoadingIndicator:ht,DateSeparator:Pr,TypingIndicator:cd,doSendMessageRequest:W,...D?{SendButton:D}:{},...T?{AttachmentPreviewList:T}:{},children:r.jsx(fd,{onBack:t,showBackButton:n,renderMessageInputActions:s,renderMessageInputFooter:a,renderConversationFooter:i,onLeaveConversation:o,onBlockParticipant:l,CustomChannelEmptyState:f,showDeleteConversation:m,onDeleteConversationClick:u,onBlockParticipantClick:h,onReportParticipantClick:d,showBlockParticipant:v,showReportParticipant:y,composerDisabled:x,composerDisabledReason:p,showStarButton:I,chatbotVotingEnabled:F,renderChannelBanner:P,customChannelActions:B,renderChannelActions:H,renderMessage:z,viewerLanguage:R,showChannelInfo:A,onParticipantNameClick:$,onBroadcastClick:V,composerInput:q})})})})});Zn.displayName="ChannelView";const Fe=g.memo(({message:e,onBack:t})=>r.jsx("div",{className:"messaging-error-state flex items-center justify-center h-full p-8",children:r.jsxs("div",{className:"text-center max-w-sm",children:[r.jsx("div",{className:"w-24 h-24 bg-danger-alt/20 rounded-full flex items-center justify-center mx-auto mb-6",children:r.jsx("span",{className:"text-4xl",children:"⚠️"})}),r.jsx("h2",{className:"font-semibold text-charcoal mb-2",children:"Oops!"}),r.jsx("p",{className:"text-stone text-sm mb-6",children:e}),t&&r.jsx("button",{type:"button",onClick:t,className:"inline-flex items-center gap-2 px-4 py-2 text-sm font-medium text-white bg-[#7f22fe] hover:bg-primary-alt rounded-lg transition-colors focus-ring",children:"Go Back"})]})}));Fe.displayName="ErrorState";const md=({capabilities:e={},renderMessageInputActions:t,renderConversationFooter:n,onChannelSelect:s,onExitConversation:a,initialParticipantFilter:i,initialParticipantData:o,CustomChannelEmptyState:l,onBlockParticipantClick:c,onReportParticipantClick:f,dmAgentEnabled:m,onMessageSent:u,chatbotVotingEnabled:h=!1,viewerLanguage:d,renderChannelBanner:v,customChannelActions:y,renderChannelActions:x,onParticipantNameClick:p,onBroadcastClick:b,renderMessage:w,onMessageLinkClick:C,showChannelInfo:I,composerInput:F})=>{const{client:P,isConnected:B,isLoading:H,error:z,refreshConnection:E,service:D,debug:T}=ea(),[R,A]=g.useState(null),[$,V]=g.useState(null),[q,W]=g.useState(!1),{showDeleteConversation:ae=!0}=e,Q=g.useRef(o);Q.current=o;const k=g.useRef(s);k.current=s;const O=g.useRef(null),X=g.useRef(null);g.useEffect(()=>{X.current=R},[R]),g.useEffect(()=>{if(!P||!B)return;const K=P.userID;if(!K)return;const Y=`${K}::${i}`;if(O.current===Y)return;O.current=Y;const ie=()=>{O.current===Y&&(O.current=null)};(async()=>{var Ke,Je;try{T&&console.log("[MessagingShell] Loading initial conversation with:",i);const ge=await P.queryChannels({type:"messaging",members:{$eq:[K,i]}},{},{limit:1});if(ge.length>0){A(ge[0]),V(null),(Ke=k.current)==null||Ke.call(k,ge[0]),T&&console.log("[MessagingShell] Initial conversation loaded:",ge[0].id);return}const _e=Q.current;if(!_e||!D){ie(),V("No conversation found with this account"),T&&console.log("[MessagingShell] No conversation found for:",i);return}try{const xe=await D.startChannelWithParticipant({id:_e.id,name:_e.name,phone:_e.phone});A(xe),V(null),(Je=k.current)==null||Je.call(k,xe),T&&console.log("[MessagingShell] Channel created and loaded:",xe.id)}catch(xe){console.error("[MessagingShell] Failed to create conversation:",xe),ie(),V("Failed to create conversation")}}catch(ge){console.error("[MessagingShell] Failed to load initial conversation:",ge),ie(),X.current||V("Failed to load conversation")}})()},[i,P,B,D,T]);const ee=g.useRef(a);ee.current=a;const re=g.useCallback(()=>{var K;A(null),W(!0),(K=ee.current)==null||K.call(ee)},[]);return H?r.jsx(ht,{}):z?r.jsx(Fe,{message:z,onBack:E}):!B||!P?r.jsx(Fe,{message:"Not connected to messaging service",onBack:E}):$?r.jsx(Fe,{message:$}):q&&!R?r.jsx(Fe,{message:"Conversation ended"}):R?r.jsx("div",{className:"messaging-shell h-full bg-background-primary overflow-hidden",children:r.jsx("div",{className:"flex h-full min-h-0 flex-col",children:r.jsx(Zn,{channel:R,renderMessageInputActions:t,renderConversationFooter:n,renderChannelBanner:v,onLeaveConversation:re,onBlockParticipant:re,CustomChannelEmptyState:l,showDeleteConversation:ae,onBlockParticipantClick:c,onReportParticipantClick:f,dmAgentEnabled:m,onMessageSent:u,chatbotVotingEnabled:h,viewerLanguage:d,customChannelActions:y,renderChannelActions:x,onParticipantNameClick:p,onBroadcastClick:b,renderMessage:w,onMessageLinkClick:C,showChannelInfo:I,composerInput:F},R.id)})}):r.jsx(ht,{})};function hd(e){const t=e.state.pending_messages;if(t!=null&&t.length)for(const n of t)e.state.addMessageSorted(n.message)}const xr=g.createContext({selectedChannel:void 0,onChannelSelect:()=>{},debug:!1,renderMessagePreview:void 0,channelPreview:void 0,viewerLanguage:void 0}),gd=xr.Provider,xd=()=>g.useContext(xr),pd=(e,t)=>{const n=new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate())),a=new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate())).getTime()-n.getTime();return Math.floor(a/(1e3*60*60*24))},pr=e=>{const t=new Date;if(Math.floor((t.getTime()-e.getTime())/1e3)<60)return"Just now";const s=pd(e,t);return s===0?e.toLocaleTimeString([],{hour:"numeric",minute:"2-digit",hour12:!0}):s===1?"Yesterday":s<7?`${s}d`:s<28?`${Math.floor(s/7)}w`:e.toLocaleDateString(void 0,{day:"numeric",month:"short",year:"2-digit"})},br=g.memo(e=>{var B,H,z;const{channel:t,unread:n}=e,{selectedChannel:s,onChannelSelect:a,debug:i,channelPreview:o,renderMessagePreview:l,viewerLanguage:c}=xd(),{client:f}=N.useChatContext(),m=(s==null?void 0:s.id)===(t==null?void 0:t.id),u=ta(t);if(o){const E=o;return r.jsx(E,{...e,active:m,selectedChannel:s,onChannelSelect:a,viewerLanguage:c})}const h=()=>{t&&a(t)},d=E=>{const D=E.key==="Enter"||E.key===" ",T=E.repeat;!D||T||(E.preventDefault(),h())},v=wn((B=t==null?void 0:t.state)==null?void 0:B.members,f==null?void 0:f.userID,t==null?void 0:t.type),y=jn(v==null?void 0:v.user),x=(H=v==null?void 0:v.user)==null?void 0:H.image,p=(()=>{var D;const E=(D=t==null?void 0:t.state)==null?void 0:D.messages;if(E!=null&&E.length){for(let T=E.length-1;T>=0;T--)if(E[T].type!=="system")return E[T]}})(),w=(()=>{var A;const E=Nn({message:p,viewerLanguage:c}),{custom_type:D,attachment_content_type:T}=(p==null?void 0:p.metadata)||{};if(D===se.MESSAGE_CUSTOM_TYPE.TIP)return E||"Sent a tip";if(D===se.MESSAGE_CUSTOM_TYPE.PAID)return E||"Sent a message";if(D===se.MESSAGE_CUSTOM_TYPE.ATTACHMENT){if(T==="text")return"🔒 Sent a locked message";if(T==="media")return"🔒 Sent a locked attachment"}if(E)return E;const R=(A=p==null?void 0:p.attachments)==null?void 0:A[0];return R?R.og_scrape_url?R.og_scrape_url:R.type==="image"?"📷 Sent an image":R.type==="video"?"🎥 Sent a video":R.type==="audio"?"🎵 Sent audio":R.type==="file"?"📎 Sent a file":"📎 Sent an attachment":"No messages yet"})(),C=p!=null&&p.created_at?pr(new Date(p.created_at)):"",I=p?nt(p):!1,F=l?l(p,w):`${I?"✨ ":""}${w}`,P=n??0;return i&&console.log("📺 [ChannelList] 📋 CHANNEL PREVIEW RENDER",{channelId:t==null?void 0:t.id,isSelected:m,participantName:y,unreadCount:P,hasTimestamp:!!C}),r.jsx("div",{role:"button",tabIndex:0,onClick:h,onKeyDown:d,className:S("group w-full px-4 py-3 transition-colors text-left max-w-full overflow-hidden focus-ring rounded-[12px] [&+&]:mt-2",{"bg-black/[0.04]":m,"hover:bg-black/[0.02]":!m}),"data-dd-privacy":"mask",children:r.jsxs("div",{className:"flex items-start gap-4",children:[r.jsx(ke,{id:((z=v==null?void 0:v.user)==null?void 0:z.id)||t.id||"unknown",name:y,image:x,size:48,starred:u}),r.jsxs("div",{className:"flex-1 min-w-0 flex flex-col gap-1",children:[r.jsxs("div",{className:"flex items-center justify-between gap-2",children:[r.jsxs("h3",{className:S("text-sm font-medium truncate text-[#191918]"),children:[u&&r.jsx("span",{className:"sr-only",children:"Starred conversation. "}),y]}),C&&r.jsx("span",{className:"text-xs text-[#717070] flex-shrink-0",children:C})]}),r.jsxs("div",{className:"flex items-center justify-between gap-2 min-w-0",children:[r.jsx("p",{className:"text-sm text-[#717070] flex-1 line-clamp-1",children:F}),P>0&&r.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:P>99?"99+":P})]})]})]})})});br.displayName="CustomChannelPreview";const bd={last_message_at:-1},vr=g.memo(({onChannelSelect:e,selectedChannel:t,filters:n,allowNewMessagesFromUnfilteredChannels:s=!1,channelRenderFilterFn:a,sort:i=bd,className:o,customEmptyStateIndicator:l,channelListPaginator:c=N.InfiniteScroll,channelPreview:f,renderMessagePreview:m,viewerLanguage:u,lockChannelOrder:h,onMessageNewHandler:d,onMessageNew:v,onChannelVisible:y,onAddedToChannel:x,onChannelUpdated:p})=>{const b=g.useRef(0);b.current++;const{debug:w=!1}=_n(),C=g.useCallback(F=>{for(const P of F)hd(P);return a?a(F):F},[a]);w&&console.log("📺 [ChannelList] 🔄 RENDER START",{renderCount:b.current,selectedChannelId:t==null?void 0:t.id,filters:n});const I=g.useMemo(()=>({selectedChannel:t,onChannelSelect:e,debug:w,channelPreview:f,renderMessagePreview:m,viewerLanguage:u}),[t,e,w,f,m,u]);return r.jsx("div",{className:S("messaging-channel-list h-full flex flex-col min-w-0 overflow-hidden",o),children:r.jsx("div",{className:"flex-1 overflow-hidden min-w-0",children:r.jsx(gd,{value:I,children:r.jsx(N.ChannelList,{filters:n,sort:i,options:{limit:30},allowNewMessagesFromUnfilteredChannels:s,channelRenderFilterFn:C,lockChannelOrder:h,onMessageNewHandler:d,onMessageNew:v,onChannelVisible:y,onAddedToChannel:x,onChannelUpdated:p,Paginator:c,Preview:br,EmptyStateIndicator:l},`${JSON.stringify(n)}:${JSON.stringify(i)}`)})})})});vr.displayName="ChannelList";const Js=`url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='23' fill='none'%3E%3Cpath fill='black' d='M0 0H15C15 10.1934 15.859 15.2345 19.168 21.4893C19.527 22.168 19.039 22.9917 18.274 22.9178C5.176 21.6506 0.32 6.0737 0 0Z'/%3E%3C/svg%3E") no-repeat center / 100% 100%`,vd={sent:"var(--str-chat__own-message-bubble-background-color, #1e2330)",received:"var(--str-chat__message-bubble-background-color, #f1f0ee)"},yd=({variant:e})=>r.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute bottom-0 z-[-1] h-[1.4375rem] w-5",style:{insetInlineEnd:e==="sent"?"calc(-1 * 0.25rem)":void 0,insetInlineStart:e==="received"?"calc(-1 * 0.25rem)":void 0,transform:e==="received"?"scaleX(-1)":void 0,transformOrigin:"center",backgroundColor:vd[e],WebkitMask:Js,mask:Js}}),_d={sent:{backgroundColor:"var(--str-chat__own-message-bubble-background-color, #1e2330)",color:"var(--str-chat__own-message-bubble-color, #fff)"},received:{backgroundColor:"var(--str-chat__message-bubble-background-color, #f1f0ee)",color:"var(--str-chat__message-bubble-color, #000000)"}},yr=({variant:e,text:t,tail:n=!0,header:s,className:a})=>r.jsxs("div",{"data-dd-privacy":"mask",className:S("relative px-4 py-3","text-[0.875rem] leading-[1.3125rem] tracking-[0.14px]",a),style:{..._d[e],borderRadius:"var(--str-chat__message-bubble-border-radius, 1.5rem)",isolation:"isolate"},children:[s!=null&&r.jsx("div",{className:"mb-1 font-medium","data-testid":"message-bubble-header",children:s}),r.jsx("p",{className:"m-0 whitespace-pre-wrap break-words",children:t}),n&&r.jsx(yd,{variant:e})]}),wd=({text:e,tail:t,header:n,className:s})=>r.jsx(yr,{variant:"received",text:e,tail:t,header:n,className:s}),jd=({text:e,tail:t,className:n})=>r.jsx(yr,{variant:"sent",text:e,tail:t,className:n}),Nd={Sent:jd,Received:wd},_r=({question:e,onClick:t,loading:n=!1,className:s})=>r.jsx("button",{type:"button",onClick:t,disabled:n,style:{backgroundColor:"#E6E5E3"},className:S("w-full text-center p-4 rounded-xl text-charcoal font-medium transition-colors focus-ring",{"hover:brightness-95 active:brightness-90":!n,"opacity-50 cursor-not-allowed":n},s),children:e}),kd=({faqs:e,onFaqClick:t,loadingFaqId:n,headerText:s,className:a,avatarImage:i,avatarName:o})=>{const l=se.selectEnabledFaqs(e);return l.length===0?null:r.jsx("div",{className:a,children:r.jsxs("div",{className:"flex gap-3 items-end",children:[(i||o)&&r.jsx("div",{className:"flex-none",children:r.jsx(ke,{id:o||"account",name:o||"Account",image:i,size:24,shape:"circle"})}),r.jsxs("div",{className:"flex-1 flex flex-col gap-3 rounded-lg p-4",style:{backgroundColor:"#F1F0EE"},children:[s&&r.jsx("p",{className:"text-md text-charcoal mb-4",children:s}),l.map(c=>r.jsx(_r,{question:c.question,onClick:()=>t(c.id),loading:n===c.id},c.id))]})]})})};exports.ActionButton=Ie;exports.AttachmentThumbnail=kn;exports.Avatar=ke;exports.ChannelEmptyState=gr;exports.ChannelList=vr;exports.ChannelView=Zn;exports.CustomMessageProvider=ro;exports.FaqList=kd;exports.FaqListItem=_r;exports.LinkAttachment=ft;exports.LockedAttachment=Oe;exports.MediaMessage=ri;exports.MessageAttachment=Re;exports.MessageBubble=Nd;exports.MessageVoteButtons=Ta;exports.MessagingProvider=Mr;exports.MessagingShell=md;exports.bubbleGroupPositionFromStream=ua;exports.buildCompactMetaLabel=ha;exports.formatFileSize=fa;exports.formatRelativeTime=pr;exports.getFileExtensionLabel=ma;exports.getMessageDisplayText=Nn;exports.getSourceType=ue;exports.isLinkAttachment=Sn;exports.isUuidLike=na;exports.normalizeLanguageCode=ra;exports.optimizeMessagingAttachmentUrl=be;exports.renderTypeIcon=Ne;exports.resolveConversationParticipant=wn;exports.resolveLinkAttachment=gt;exports.resolveMediaFromMessage=xt;exports.resolveParticipantDisplayName=jn;exports.useComposerLocked=Kc;exports.useCustomMessage=Ca;exports.useMessageVote=aa;exports.useMessaging=ea;
|
|
5
|
+
//# sourceMappingURL=index-QulHlER7.cjs.map
|