import{d as v,l as _,b as I,j as h,o as b,c as S,$ as g,u as m,a as d,bj as y,bl as T,bc as H,n as q}from"./@vue-cb50a1c4.js";import{T as x,I as c,L as k}from"./index-ae60edf9.js";import{_ as w}from"./index.vue_vue_type_script_setup_true_lang-1170722e.js";import{V as j}from"./virtual-list-b1ee24f1.js";import{_ as A,M as z}from"./SystemNotificationItem.vue_vue_type_script_setup_true_lang-9985550a.js";import"./vue-router-7f882520.js";import"./open-im-sdk-wasm-f19f04ec.js";import"./dayjs-4460abc8.js";import"./@amap-aca98dec.js";import"./vue-i18n-90d534a9.js";import"./@intlify-1c0af683.js";import"./pinia-de4079f2.js";import"./axios-7d5a0a64.js";import"./form-data-497f8b5e.js";import"./uuid-a960c1f4.js";import"./date-fns-f56f60e6.js";import"./@babel-7fd5df1e.js";import"./mitt-f7ef348c.js";import"./@vueuse-19adab01.js";import"./livekit-client-ca552de3.js";import"./@livekit-3058dbe8.js";import"./loglevel-e40a507a.js";import"./rxjs-2154ddb2.js";import"./tslib-8dbab242.js";import"./@vuemap-5ebdc63e.js";import"./lodash-es-91418b19.js";import"./index-597402db.js";import"./arrows_left-f963ef62.js";import"./useCurrentMemberRole-f0ed520c.js";import"./chating_message_video_play-2b29053c.js";import"./function-call-5bab1da7.js";import"./useSendMessage-e9c396f5.js";import"./index-2e28d005.js";import"./use-sync-prop-ref-bb7ddd4e.js";import"./data-7f4000cb.js";const N={class:"page_container !bg-white"},B={class:"relative flex-1 overflow-hidden"},C={class:"!absolute top-0 flex h-full w-full items-center justify-center bg-white"},It=v({__name:"index",setup(V){const r=history.state,l=JSON.parse(history.state.jumpMessage),t=_({renderData:[],initLoading:!0,initLockFlag:!1,lastMinSeq:0,jumpMessageIDList:[],topHasMore:!0,topLoading:!1,bottomHasMore:!0,bottomLoading:!1}),i=I(),u=()=>{const o={conversationID:r.conversationID,count:20,startClientMsgID:l.clientMsgID,lastMinSeq:l.seq},s=[c.getAdvancedHistoryMessageList(o),c.getAdvancedHistoryMessageListReverse(o)];Promise.all(s).then(e=>{t.renderData=[...e[0].data.messageList,l,...e[1].data.messageList],t.topHasMore=e[0].data.messageList.length===20,t.bottomHasMore=e[1].data.messageList.length===20,t.lastMinSeq=e[0].data.lastMinSeq,t.jumpMessageIDList=e[0].data.messageList.map(a=>a.clientMsgID),console.log(e[1].data)}).catch(()=>t.initLoading=!1)},f=()=>{if(t.topLoading||!t.topHasMore)return;t.topLoading=!0;const o={conversationID:r.conversationID,userID:"",groupID:"",count:20,startClientMsgID:t.renderData[0].clientMsgID,lastMinSeq:t.lastMinSeq};c.getAdvancedHistoryMessageList(o).then(({data:s})=>{t.renderData=[...s.messageList,...t.renderData],t.topHasMore=s.messageList.length===20,t.lastMinSeq=s.lastMinSeq,setTimeout(()=>p(s.messageList.map(e=>e.clientMsgID),()=>t.topLoading=!1))}).finally(()=>t.topLoading=!1)},M=()=>{if(t.bottomLoading||!t.bottomHasMore)return;t.bottomLoading=!0;const o={conversationID:r.conversationID,userID:"",groupID:"",count:20,startClientMsgID:t.renderData[t.renderData.length-1].clientMsgID,lastMinSeq:t.lastMinSeq};c.getAdvancedHistoryMessageListReverse(o).then(({data:s})=>{t.renderData=[...t.renderData,...s.messageList],t.bottomHasMore=s.messageList.length===20,setTimeout(()=>p(s.messageList.map(e=>e.clientMsgID),()=>t.bottomLoading=!1))}).finally(()=>t.bottomLoading=!1)},L=()=>{if(!i.value||!t.initLoading||t.initLockFlag)return;Array.from(document.querySelectorAll(".need_preload_message")).findIndex(e=>e.clientHeight<2)===-1&&(t.initLockFlag=!0,setTimeout(()=>p(t.jumpMessageIDList,()=>t.initLoading=!1)))},p=(o,s)=>{const e=o.reduce((a,n)=>(typeof a=="string"?i.value.getSize(a)??0:a)+i.value.getSize(n));D(Number(e),s)},D=(o,s)=>{i.value&&(i.value.scrollToOffset(o),q(()=>s()))};return h(()=>{u()}),(o,s)=>{const e=w,a=k;return b(),S("div",N,[g(e,{title:m(r).conversationName},null,8,["title"]),d("div",B,[g(m(j),{ref_key:"vsl",ref:i,class:"my_scrollbar h-full overflow-y-auto","data-key":"clientMsgID",keeps:50,"data-sources":t.renderData,topThreshold:160,bottomThreshold:160,"data-component":n=>m(x).includes(n.contentType)?A:z,"extra-props":n=>({isPreView:!0,isActive:n.clientMsgID===m(l).clientMsgID}),"estimate-size":84,onTotop:f,onTobottom:M,onResized:L},{header:y(()=>[]),_:1},8,["data-sources","data-component","extra-props"]),T(d("div",C,[g(a,{type:"spinner"})],512),[[H,t.initLoading]])])])}}});export{It as default};
