import{__decorate}from"tslib";import{SuperComponent,wxComponent}from"../common/src/index";import config from"../common/config";import props from"./props";const{prefix:prefix}=config,name=`${prefix}-chat-list`;let Chat=class extends SuperComponent{constructor(){super(...arguments),this.options={multipleSlots:!0},this.properties=Object.assign(Object.assign({},props),{virtualList:{type:Boolean,value:!1},fragmentLen:{type:Number,value:8}}),this.data={classPrefix:name,scrollViewTop:0,classes:[],listClasses:[],startIndex:0,endIndex:0},this.observers={data(){const t=this.properties.data.length;this.properties.virtualList&&this.oldDataLen!==t&&(this.oldDataLen=t,this.resetFragments())}},this.methods={setScrollTop(t=0){t===this.data.scrollViewTop&&(t-=1),this.setData({scrollViewTop:t})},scrollToBottom(){this.setScrollTop()},onScroll(t){this.triggerEvent("scroll",t)},handlerScrollToUpper(){!this.properties.reverse&&this.properties.virtualList&&this.addFragment()},handlerScrollToLower(){this.properties.reverse&&this.properties.virtualList&&this.addFragment()},resetFragments(){const t=this.properties.data.length;if(t){const{fragmentLen:e}=this.properties;this.properties.reverse?this.setData({startIndex:0,endIndex:Math.min(t-1,e-1)}):this.setData({startIndex:Math.max(t-e,0),endIndex:Math.max(t-1,0)})}},addFragment(t=4){const e=this.properties.data.length;e&&(this.properties.reverse?this.setData({endIndex:Math.min(e-1,this.data.endIndex+t)}):this.setData({startIndex:Math.max(this.data.startIndex-t,0)}))}},this.lifetimes={created(){this.data.setScrollTop=this.setScrollTop.bind(this),this.data.scrollToBottom=this.scrollToBottom.bind(this)}}}};Chat=__decorate([wxComponent()],Chat);export default Chat;