try{let e=typeof window<`u`?window:typeof global<`u`?global:typeof globalThis<`u`?globalThis:typeof self<`u`?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]=`81846d31-bec5-4e91-9347-f0c29e3b3e92`,e._sentryDebugIdIdentifier=`sentry-dbid-81846d31-bec5-4e91-9347-f0c29e3b3e92`)}catch{}import{o as e}from"./rolldown-runtime-nx40z1zs.js";import{Ag as t,Qm as n,Yh as r,Zm as i,jg as a,ng as o}from"./entry.client-mpghtlrl.js";import{c as s,m as c,o as l,s as u}from"./MessageCanvas-epwsnqhh.js";var d=t(),f=e(a(),1),p=o(),m=4,h=e=>{switch(e){case`image/jpeg`:return`jpg`;case`image/png`:return`png`;case`image/gif`:return`gif`}},g=e=>{let t=(0,d.c)(9),{children:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=[],t[0]=r):r=t[0];let[i,a]=(0,f.useState)(r),o;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(o=e=>{if(e)for(let t of e){let e=new FileReader;e.onload=()=>{let n=e.result,r=n.substring(n.indexOf(`,`)+1),i=h(t.type);if(i){let e={uri:n,data:r,name:t.name,size:t.size,fileType:i};a(t=>t.length>=m||t.find(t=>t.name===e.name)?t:[...t,e])}},e.readAsDataURL(t)}},t[1]=o):o=t[1];let s=o,l;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(l=e=>{a(t=>t.filter(t=>t!==e))},t[2]=l):l=t[2];let u=l,g;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(g=()=>{a([])},t[3]=g):g=t[3];let _=g,v,y;t[4]===i?y=t[5]:(y={images:i,addImagesFromFileList:s,removeImage:u,resetImages:_},t[4]=i,t[5]=y),v=y;let b=v,x;return t[6]!==b||t[7]!==n?(x=(0,p.jsx)(c.Provider,{value:b,children:n}),t[6]=b,t[7]=n,t[8]=x):x=t[8],x},_=e=>{let t=(0,d.c)(6),{conversationId:n,locale:r,children:i}=e,a,o;t[0]!==n||t[1]!==r?(o={conversationId:n,locale:r},t[0]=n,t[1]=r,t[2]=o):o=t[2],a=o;let s=a,c;return t[3]!==s||t[4]!==i?(c=(0,p.jsx)(l.Provider,{value:s,children:i}),t[3]=s,t[4]=i,t[5]=c):c=t[5],c},v=(e,t)=>{e.type===`directmention`&&t.add(e.xuid)},y=(e,t)=>{if(t.add(e.senderXuid),s(e)&&!u(e))for(let n of e.content)v(n,t)},b=(e,t)=>{let n=new Set(t);for(let t of e)y(t,n);return Array.from(n)},x=[`none`,`summary`,`paged-data`,`end-reached`],S=e=>{let t=(0,d.c)(27),{conversation:a,group:o,channel:s}=e,{conversation:c}=i(),[l,u]=(0,f.useState)(!1),p;t[0]===c.mutations.fetchMoreConversationMessages?p=t[1]:(p=c.mutations.fetchMoreConversationMessages.getActiveUserMutation().getOptions(),t[0]=c.mutations.fetchMoreConversationMessages,t[1]=p);let{mutate:m}=r(p),h;t[2]===c.mutations.fetchMoreChannelMessages?h=t[3]:(h=c.mutations.fetchMoreChannelMessages.getActiveUserMutation().getOptions(),t[2]=c.mutations.fetchMoreChannelMessages,t[3]=h);let{mutate:g}=r(h),_=a?x[a.hydrationState]:s?x[s.hydrationState]:`none`,v=a?.conversationId,y=o?.groupId,b=s?.channelId,{trackUserAction:S}=n(),C;t[4]===S?C=t[5]:(C=e=>{S(`ChatInteraction`,{type:`FetchMoreMessages`,wasSuccessful:e},`Press`)},t[4]=S,t[5]=C);let w=C,T;t[6]!==v||t[7]!==m||t[8]!==w||t[9]!==y||t[10]!==b||t[11]!==g?(T=()=>v?(m({conversationId:v},{onSuccess:()=>w(!0),onError:()=>w(!1)}),!0):y&&b?(g({groupId:y,channelId:b},{onSuccess:()=>w(!0),onError:()=>w(!1)}),!0):!1,t[6]=v,t[7]=m,t[8]=w,t[9]=y,t[10]=b,t[11]=g,t[12]=T):T=t[12];let E=T,D;t[13]!==l||t[14]!==_||t[15]!==E?(D=()=>{!l&&(_===`summary`||_===`none`)&&E()&&u(!0)},t[13]=l,t[14]=_,t[15]=E,t[16]=D):D=t[16];let O;t[17]!==l||t[18]!==_||t[19]!==v||t[20]!==y||t[21]!==b||t[22]!==E?(O=[l,u,_,v,y,b,E],t[17]=l,t[18]=_,t[19]=v,t[20]=y,t[21]=b,t[22]=E,t[23]=O):O=t[23],(0,f.useEffect)(D,O);let k;return t[24]!==_||t[25]!==E?(k={hydrationState:_,fetchMoreMessages:E},t[24]=_,t[25]=E,t[26]=k):k=t[26],k};export{g as i,b as n,_ as r,S as t};