"use strict";const e=require("../../../../../common/vendor.js");require("../../../../adapter-vue.js");const t=require("../../../../../common/assets.js"),o=require("../../../../utils/type-check.js");Math||a();const a=()=>"../../../common/Icon.js",n=e.defineComponent({__name:"index",emits:["scrollToLatestMessage"],setup(a,{expose:n,emit:l}){const u=l,s=e.ref([]),i=e.ref(""),r=e.ref(0),v=e.ref(0),c=e.ref(!1),d=e.ref(!1),f=e.ref(!1),g=e.computed((()=>v.value?`${v.value}${e.Wt.t("TUIChat.条新消息")}`:e.Wt.t("TUIChat.回到最新位置")));function m(e){var t,o;s.value=e||[];const a=null==(o=s.value)?void 0:o[(null==(t=s.value)?void 0:t.length)-1];d.value=!!(a&&(null==a?void 0:a.time)<(null==r?void 0:r.value))}function h(e){Array.isArray(e)&&f.value&&e.forEach((e=>{!e||e.conversationID!==i.value||e.isDeleted||e.isRevoked||function(e){var t,a;return"user_typing_status"===(null==(a=o.JSONToObject(null==(t=e.payload)?void 0:t.data))?void 0:a.businessID)}(e)||(v.value+=1)}))}function p(e){var t;(null==e?void 0:e.conversationID)!==i.value&&T(),i.value=(null==e?void 0:e.conversationID)||"",r.value=(null==(t=null==e?void 0:e.lastMessage)?void 0:t.lastTime)||0}function T(){v.value=0}function C(){void 0!==e.Jt.getData(e.o.CHAT,"messageSource")&&e.Jt.update(e.o.CHAT,"messageSource",void 0),T(),u("scrollToLatestMessage")}return e.watch((()=>[c.value,d.value]),(()=>{f.value=c.value||d.value,f.value||T()}),{immediate:!0}),e.onMounted((()=>{e.Jt.watch(e.o.CHAT,{messageList:m,newMessageList:h}),e.Jt.watch(e.o.CONV,{currentConversation:p})})),e.onUnmounted((()=>{e.Jt.unwatch(e.o.CHAT,{messageList:m,newMessageList:h}),e.Jt.unwatch(e.o.CONV,{currentConversation:p})})),n({judgeScrollOverOneScreen:async function(t){var o,a,n,l,u;if(t.target)try{const{height:s}=await e.T(`#${null==(o=t.target)?void 0:o.id}`,"messageList")||{},i=(null==(a=t.target)?void 0:a.scrollHeight)||(null==(n=t.detail)?void 0:n.scrollHeight);if(i-((null==(l=t.target)?void 0:l.scrollTop)||(null==(u=t.detail)?void 0:u.scrollTop)||0)>2*s)return void(c.value=!0);c.value=!1}catch(s){c.value=!1}},isScrollButtonVisible:f}),(o,a)=>e.e({a:e.unref(f)},e.unref(f)?{b:e.p({width:"10px",height:"10px",file:e.unref(t.doubleArrowIcon)}),c:e.t(e.unref(g)),d:e.o$1(C)}:{})}}),l=e._export_sfc(n,[["__scopeId","data-v-97f4bdd3"]]);wx.createComponent(l);
