"use strict";const e=2,t=4,s=10,o=11,r=12,i=14,n=20,a=23,u=26,p=27,c=29,l=34;class h{constructor(e=0,t=0){this.high=e,this.low=t}equal(e){return null!==e&&this.low===e.low&&this.high===e.high}toString(){var e=Number(this.high).toString(16);let t=Number(this.low).toString(16);if(t.length<8){let e=8-t.length;for(;e;)t="0"+t,e--}return e+t}}const g={TEST:{CHINA:{DEFAULT:"wss://wss-dev.tim.qq.com"},OVERSEA:{DEFAULT:"wss://wss-dev.tim.qq.com"},SINGAPORE:{DEFAULT:"wss://wsssgp-dev.im.qcloud.com"},KOREA:{DEFAULT:"wss://wsskr-dev.im.qcloud.com"},GERMANY:{DEFAULT:"wss://wssger-dev.im.qcloud.com"},IND:{DEFAULT:"wss://wssind-dev.im.qcloud.com"},JPN:{DEFAULT:"wss://wssjpn-dev.im.qcloud.com"},USA:{DEFAULT:"wss://wssusa-dev.im.qcloud.com"},INDONESIA:{DEFAULT:"wss://wssidn-dev.im.qcloud.com"}},PRODUCTION:{CHINA:{DEFAULT:"wss://wss.im.qcloud.com",BACKUP:"wss://wss.tim.qq.com",STAT:"https://events.im.qcloud.com",ANYCAST:"wss://162.14.13.203"},OVERSEA:{DEFAULT:"wss://wss.im.qcloud.com",BACKUP:"wss://wss.my-imcloud.com",STAT:"https://api.my-imcloud.com"},SINGAPORE:{DEFAULT:"wss://wsssgp.im.qcloud.com",BACKUP:"wss://wsssgp.my-imcloud.com",STAT:"https://apisgp.my-imcloud.com",ANYCAST:"wss://162.14.19.159"},KOREA:{DEFAULT:"wss://wsskr.im.qcloud.com",BACKUP:"wss://wsskr.my-imcloud.com",STAT:"https://apikr.my-imcloud.com",ANYCAST:"wss://162.14.13.104"},GERMANY:{DEFAULT:"wss://wssger.im.qcloud.com",BACKUP:"wss://wssger.my-imcloud.com",STAT:"https://apiger.my-imcloud.com",ANYCAST:"wss://162.14.3.17"},IND:{DEFAULT:"wss://wssind.my-imcloud.com",BACKUP:"wss://wssind.im.qcloud.com",STAT:"https://apiind.my-imcloud.com",ANYCAST:"wss://162.14.18.188"},JPN:{DEFAULT:"wss://wssjpn.im.qcloud.com",BACKUP:"wss://wssjpn.my-imcloud.com",STAT:"https://apijpn.my-imcloud.com"},USA:{DEFAULT:"wss://wssusa.im.qcloud.com",BACKUP:"wss://wssusa.my-imcloud.com",STAT:"https://apiusa.my-imcloud.com",ANYCAST:"wss://162.14.10.42"},INDONESIA:{DEFAULT:"wss://wssidn.im.qcloud.com",BACKUP:"wss://wssidn.my-imcloud.com",STAT:"https://apiidn.my-imcloud.com",ANYCAST:"wss://43.129.34.169"}}},m={ANDROID:2,IOS:3,MAC:4,WEB:7,WX_MP:8,QQ_MP:9,TT_MP:10,BAIDU_MP:11,ALI_MP:12,IPAD:13,UNI_NATIVE_APP:15},d="CHINA",_={HOST:{CURRENT:{DEFAULT:"wss://wss.im.qcloud.com",STAT:"https://events.im.qcloud.com"},setCurrent(e=d){this.CURRENT=g.PRODUCTION[e]}},NAME:{OPEN_IM:"openim",OPEN_IM_MSG_EXT:"openim_msg_ext_http_svc",GRP:"group_open_http_svc",GRP_AV:"group_open_avchatroom_http_svc",GRP_COMMUNITY:"million_group_open_http_svc",GRP_ATTR:"group_open_attr_http_svc",FD:"sns",PROFILE:"profile",RECENT_CONTACT:"recentcontact",PIC:"openpic",BIG_GRP_NO_AUTH:"group_open_http_noauth_svc",BIG_GRP_POLLING:"group_open_long_polling_http_svc",BIG_GRP_POLLING_NO_AUTH:"group_open_long_polling_http_noauth_svc",IM_OPEN_STAT:"imopenstat",WEB_IM:"webim",IM_COS_SIGN:"im_cos_sign_svr",CUSTOM_UPLOAD:"im_cos_msg",HEARTBEAT:"heartbeat",IM_OPEN_PUSH:"im_open_push",IM_OPEN_STATUS:"im_open_status",IM_LONG_MSG:"im_long_msg",IM_CONFIG_MANAGER:"im_sdk_config_mgr",STAT_SERVICE:"StatSvc",OVERLOAD_PUSH:"OverLoadPush",IM_MSG_AUDIT_MGR:"im_msg_audit_mgr",TUIROOM_SVR:"tui_room_svr",IM_OPEN_TRANSLATE:"im_open_translate",IM_OPEN_SPEECH:"im_open_speech",MSG_SEARCH:"message_search",FOLLOW:"follow"}},f={SEARCH_MSG:new h(0,Math.pow(2,0)).toString(),SEARCH_GRP_SNS:new h(0,Math.pow(2,1)).toString(),AV_HISTORY_MSG:new h(0,Math.pow(2,2)).toString(),GRP_COMMUNITY:new h(0,Math.pow(2,3)).toString(),MSG_TO_SPECIFIED_GRP_MBR:new h(0,Math.pow(2,4)).toString(),AV_MBR_LIST:new h(0,Math.pow(2,6)).toString(),USER_STATUS:new h(0,Math.pow(2,7)).toString(),CONV_MARK:new h(0,Math.pow(2,9)).toString(),CONV_GROUP:new h(0,Math.pow(2,10)).toString(),AV_BAN_MBR:new h(0,Math.pow(2,11)).toString(),MSG_EXT:new h(0,Math.pow(2,13)).toString(),GRP_COUNTER:new h(0,Math.pow(2,15)).toString(),PLUGIN_TRANSLATE:new h(Math.pow(2,6)).toString(),PLUGIN_VOICE_TO_TEXT:new h(Math.pow(2,7)).toString(),PLUGIN_CS:new h(Math.pow(2,8)).toString(),PLUGIN_PUSH:new h(Math.pow(2,9)).toString(),PLUGIN_BOT:new h(Math.pow(2,10)).toString(),MSG_REACTION:new h(Math.pow(2,16)).toString()},M="group_profile",I="group_member_profile",L=(_.HOST.setCurrent(d),"undefined"!=typeof wx&&"function"==typeof wx.getSystemInfoSync&&Boolean(wx.getSystemInfoSync().fontSizeSetting)),D=(L&&wx.createGamePortal,"undefined"!=typeof qq&&"function"==typeof qq.getSystemInfoSync&&Boolean(qq.getSystemInfoSync().fontSizeSetting)),y="undefined"!=typeof tt&&"function"==typeof tt.getSystemInfoSync&&Boolean(tt.getSystemInfoSync().fontSizeSetting),G="undefined"!=typeof swan&&"function"==typeof swan.getSystemInfoSync&&Boolean(swan.getSystemInfoSync().fontSizeSetting),C="undefined"!=typeof my&&"function"==typeof my.getSystemInfoSync&&Boolean(my.getSystemInfoSync().fontSizeSetting),b="undefined"!=typeof jd&&"function"==typeof jd.getSystemInfoSync,T="undefined"!=typeof uni&&"undefined"==typeof window&&"function"==typeof uni.requireNativePlugin,A=L||D||y||G||C||T||b,S=("undefined"!=typeof uni||"undefined"!=typeof window)&&!A,v=(D?qq:y?tt:G?swan:C?my:L?wx:T?uni:b&&jd,S&&window&&window.navigator&&window.navigator.userAgent||""),R=/(micromessenger|webbrowser)/i.test(v),P=/AppleWebKit\/([\d.]+)/i.exec(v),$=(P&&parseFloat(P.pop()),function(){let e="WEB";return R?e="WEB":D?e="QQ_MP":y?e="TT_MP":G?e="BAIDU_MP":C?e="ALI_MP":L?e="WX_MP":T&&(e="UNI_NATIVE_APP"),m[e]}()),E=(!function(){var e=v.match(/OS (\d+)_/i);e&&e[1]&&e[1]}(),function(){var e,t,s=v.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);s&&(e=s[1]&&parseFloat(s[1]),t=s[2]&&parseFloat(s[2]),e&&t&&parseFloat(s[1]+"."+s[2]))}(),function(){var e=v.match(/Chrome\/(\d+)/);e&&e[1]&&parseFloat(e[1])}(),/MSIE/.test(v)||-1{const s=o.find(e=>e.key===t);s?s.value!==e&&(s.value=e,r=!0):(o.push({key:t,value:e}),r=!0)}),r}function Be(e){return ve(e)?[]:e.filter(e=>!0===e.isModified)}function Ke(e){return ve(e)?[]:e.filter(e=>!1===e.isModified)}const Je=e=>e===ue,We=({type:e,groupID:t})=>e===pe||(""+t).startsWith(Te)&&!(""+t).includes(Ae),ze=e=>(""+e).startsWith(Te)&&(""+e).includes(Ae);function Xe(e){return e.split(Ae)[0]}function Ye(){return!E&&!A}function Qe(t,s){if(t){let e=t;return s&&(t.startsWith("http://")?e=t.replace(/^http:\/\/[^/]+/,s):t.startsWith("https://")&&(e=t.replace(/^https:\/\/[^/]+/,s))),e}}function Ze(e,t=!0,s=!0){var o=Date.now();return t?s?o-e+" ms":Math.round((o-e)/1e3)+" s":s?o-e:Math.round((o-e)/1e3)}let et=0;function st(){return Ye()?"%c Chat %c":"Chat"}function ot(){const e=function(){const e=new Date;return e.setTime(De()),e}();return e.toLocaleTimeString("en-US",{hour12:!1})+"."+function(e){let t;switch(e.toString().length){case 1:t="00"+e;break;case 2:t="0"+e;break;default:t=e}return t}(e.getMilliseconds())}const rt={arguments2String(s){let o="";if(1===s.length)o=s[0];else for(let e=0,t=s.length;e{this._sentFlag=!0,this._eventStatModule&&this._eventStatModule.pushIn(this)},0)}}setError(e){if(!(e instanceof Error))return rt.w(this._n+".setError value not instanceof Error, please check!"),this;if(this._sentFlag)return this;let t=!0;if(t=this._netMonitorModule?this._netMonitorModule.isOnline():t)e.code&&this.setCode(e.code),e.message&&this.setMoreMessage(e.message);else{const e=At;this.setCode(e)}return this.setLevel("error"),this}setCode(e){return qe(e)||this._sentFlag||("ECONNABORTED"===e&&(this.code=103),Ee(e)?this.code=e:rt.w(this._n+".setCode value not a number, please check!",e,typeof e)),this}setMessage(e){return qe(e)||this._sentFlag||(Ee(e)&&(this.message=e.toString()),we(e)&&(this.message=e)),this}setCostTime(e){return this.costTime=e,this}setLevel(e){return qe(e)||this._sentFlag||(this.level=Kt[e]),this}setMoreMessage(e){return ve(this.moreMessage)?this.moreMessage=""+e:this.moreMessage+=" "+e,this}setNetworkType(e){return qe(e)?rt.w(this._n+".setNetworkType value is undefined, please check!"):(e=Jt[e.toLowerCase()],qe(e)||(this.networkType=e)),this}getStartTs(){return this._startts}setUIPlatform(e){return this.uiPlatform=e,this}setExtension(e){return this.extension=e,this}setEventType(e){return this.eventType=e,this}}const Xt="send_group_msg",Yt="get_joined_group_list",Qt="get_group_self_member_info",Zt="create_group",es="destroy_group",ts="modify_group_base_info",ss="apply_join_group",os="apply_join_group_noauth",rs="quit_group",is="get_group_public_info",ns="change_group_owner",as="handle_apply_join_group",us="handle_invite_join_permission_group",ps="handle_invite_join_group",cs="group_msg_recall",ls="msg_read_report",hs="group_msg_get",gs="get_group_msg_receipt",ms="group_msg_receipt",ds="get_group_msg_receipt_detail",_s="get_pendency",fs="deletemsg",Ms="get_msg",Is="get_msg_noauth",Ls="get_online_member_num",Ds="delete_group_ramble_msg_by_seq",ys="modify_group_msg",Gs="set_group_attr",Cs="modify_group_attr",bs="delete_group_attr",Ts="clear_group_attr",As="get_group_attr",Ss="group_set_key_values",vs="group_get_key_values",Rs="batch_get_group_notify",Ps="update_group_counter",$s="get_group_counter",Es="get_group_member_info",ws="get_members",Us="get_specified_group_member_info",Ns="add_group_member",qs="delete_group_member",ks="ban_group_member",Os="modify_group_member_info",Fs="modify_user_info",xs="unSend",Vs="success",Hs="notStart",js="resolved",Bs="rejected";class Ks{constructor(e){this.type=F,this.content={text:e.text||""}}setText(e){this.content.text=e}sendable(){return 0!==this.content.text.length}}class Js{constructor(e,t){this._imageMemoryURL="",this._fileDownloadProxy=t,A?this.createImageDataASURLInWXMiniApp(e.file):this.createImageDataASURLInWeb(e.file),this._initImageInfoModel(),this.type=x,this._percent=0,this.content={imageFormat:e.imageFormat||ye.UNKNOWN,uuid:e.uuid,imageInfoArray:[]},this.initImageInfoArray(e.imageInfoArray),this._autoFixUrl()}_initImageInfoModel(){const t=this;this._ImageInfoModel=function(e){this.instanceID=xe(9999999),this.sizeType=e.type||0,this.type=0,this.size=e.size||0,this.width=e.width||0,this.height=e.height||0,this.imageUrl=e.imageUrl||e.url||"",this.url=Qe(e.url||t._imageMemoryURL,t._fileDownloadProxy)},this._ImageInfoModel.prototype={setSizeType(e){this.sizeType=e},setType(e){this.type=e},setImageUrl(e){e&&(this.imageUrl=e)},getImageUrl(){return this.imageUrl}}}initImageInfoArray(e){let t=0,s=null,o;for(;t<=2;)o=qe(e)||qe(e[t])?{type:0,size:0,width:0,height:0,url:""}:e[t],(s=new this._ImageInfoModel(o)).setSizeType(t+1),s.setType(t),this.addImageInfo(s),t++;this.updateAccessSideImageInfoArray()}updateImageInfoArray(t){var s=this.content.imageInfoArray.length;let o;for(let e=0;e{switch(e){case"remarkInfo":break;case"groupProfile":this.content.groupProfile={},this._initGroupProfile(t[e]);break;case"operatorInfo":break;case"memberInfoList":case"msgMemberInfo":this._updateMemberList(t[e]);break;case"memberExtraInfo":case"onlineMemberInfo":break;case"memberNum":this.content[e]=t[e],this.content.memberCount=t[e];break;case"newGroupProfile":this.content.newGroupProfile={},this._initNewGroupProfile(t[e]);break;default:this.content[e]=t[e]}}),this.content.userIDList||(this.content.userIDList=[this.content.operatorID])}_initGroupProfile(t){var s=Object.keys(t);for(let e=0;e{e.forEach(e=>{t.userID===e.userID&&Object.assign(t,e)})})}_initNewGroupProfile(t){var s=Object.keys(t);for(let e=0;e{switch(e){case"memberInfoList":break;case"remarkInfo":this.content.handleMessage=t[e];break;case"groupProfile":this.content.groupProfile={},this._initGroupProfile(t[e]);break;default:this.content[e]=t[e]}})}_initGroupProfile(t){var s=Object.keys(t);for(let e=0;e{!e.imageUrl&&e.url&&(e.imageUrl=e.url,e.sizeType=e.type,1===e.type?e.type=0:3===e.type&&(e.type=1))}):e===B?!t.remoteVideoUrl&&t.videoUrl&&(t.remoteVideoUrl=t.videoUrl):e===V?!t.remoteAudioUrl&&t.url&&(t.remoteAudioUrl=t.url):e===H&&!t.fileUrl&&t.url&&(t.fileUrl=t.url,t.url=void 0)}_updateRichMediaDownloadUrl(e,t,s){s&&(e===x?t.imageInfoArray.forEach(e=>{e.url=Qe(e.url,s)}):e===B?(t.videoUrl=Qe(t.videoUrl,s),t.snapshotUrl=Qe(t.thumbUrl,s),t.snapshotHeight=t.thumbHeight,t.snapshotWidth=t.thumbWidth):e===V?t.url=Qe(t.url,s):e===H&&(t.fileUrl=Qe(t.fileUrl,s)))}}var io=class{constructor(e,t){if(this.type=X,this.content={downloadKey:"",pbDownloadKey:"",messageList:[],title:"",abstractList:[],compatibleText:"",version:0,layersOverLimit:!1},e.downloadKey){const{downloadKey:t,pbDownloadKey:s,title:o,abstractList:r,compatibleText:i,version:n}=e;this.content.downloadKey=t,this.content.pbDownloadKey=s,this.content.title=o,this.content.abstractList=r,this.content.compatibleText=i,this.content.version=n||0}else if(ve(e.messageList))1===e.layersOverLimit&&(this.content.layersOverLimit=!0);else{const{messageList:a,title:u,abstractList:h,compatibleText:l,version:g}=e,p=[];a.forEach(e=>{ve(e)||(e=new ro(e,t),p.push(e))}),this.content.messageList=p,this.content.title=u,this.content.abstractList=h,this.content.compatibleText=l,this.content.version=g||0}}sendable(){return!ve(this.content.messageList)||!ve(this.content.downloadKey)}};const no={1:Y,2:Q,3:Z,4:ee};class ao{constructor(e){this.ID="",this.conversationID=e.conversationID||null,this.conversationType=e.conversationType||te,this.conversationSubType=e.conversationSubType,this.time=e.time||Math.ceil(Date.now()/1e3),this.sequence=e.sequence||0,this.clientSequence=e.clientSequence||e.sequence||0,this.random=e.random||0===e.random?e.random:xe(),this.priority=this._computePriority(e.priority),this.nick=e.nick||"",this.avatar=e.avatar||"",this.isPeerRead=!1,this.nameCard="",this.hasRiskContent=function(e){let t=e&&1{e!==Le?(this._groupAtInfoList.push({groupAtAllFlag:0,groupAtUserID:e}),this.atUserList.push(e)):(this._groupAtInfoList.push({groupAtAllFlag:1}),this.atUserList.push(Le))}),Ne(e.groupAtInfo)&&e.groupAtInfo.forEach(e=>{0===e.groupAtAllFlag?this.atUserList.push(e.groupAtUserID):1===e.groupAtAllFlag&&this.atUserList.push(Le)})}getGroupAtInfoList(){return this._groupAtInfoList}_initProxy(){this._elements[0]&&(this.payload=this._elements[0].content,this.type=this._elements[0].type)}reInitialize(e){e&&(this.status=this.from?Vs:xs,this.from||(this.from=e)),this._initFlow(e),this._initSequence(e),this._concatConversationID(e),this.generateMessageID()}isSendable(){return 0!==this._elements.length&&(!0===this._relayFlag||"function"==typeof this._elements[0].sendable&&this._elements[0].sendable())}_initTo(e){this.conversationType===se&&(this.to=e.groupID)}_initSequence(e){0===this.clientSequence&&e&&(this.clientSequence=function(o){if(!o)return!1;if(void 0===Ve[o]){const r=new Date;let e=("3"+r.getHours()).slice(-2),t=("0"+r.getMinutes()).slice(-2),s=("0"+r.getSeconds()).slice(-2);Ve[o]=parseInt([e,t,s,"0001"].join("")),e=null,t=null,s=null,rt.l("autoIncrementIndex start index:"+Ve[o])}return Ve[o]++}(e)),0===this.sequence&&this.conversationType===te&&(this.sequence=this.clientSequence)}generateMessageID(){this.from===re&&(this.senderTinyID="144115198244471703"),this.ID=`${this.senderTinyID}-${this.clientTime}-`+this.random}_initFlow(e){""!==e&&(e===this.from?(this.flow="out",this.isRead=!0):this.flow="in")}_concatConversationID(e){var t=this["to"],s=this.conversationType;s!==re?(e=s===te?e===this.from?t:this.from:this.to,this.conversationID=e?""+s+e:null):this.conversationID=re}isElement(e){return e instanceof Ks||e instanceof Js||e instanceof Ws||e instanceof zs||e instanceof eo||e instanceof so||e instanceof Ys||e instanceof Zs||e instanceof to||e instanceof oo||e instanceof io}setElement(t,s){if(this.isElement(t))return this._elements=[t],void this._initProxy();var o=e=>{if(e.type&&e.content)switch(e.type){case F:this.setTextElement(e.content);break;case x:this.setImageElement(e.content,s);break;case V:this.setAudioElement(e.content,s);break;case H:this.setFileElement(e.content,s);break;case B:this.setVideoElement(e.content,s);break;case z:this.setCustomElement(e.content);break;case K:this.setLocationElement(e.content);break;case J:this.setGroupTipElement(e.content);break;case W:this.setGroupSystemNoticeElement(e.content);break;case j:this.setFaceElement(e.content);break;case X:this.setMergerElement(e.content,s)}};if(Ne(t))for(let e=0;e{e.reason=t})}var{nick:s,avatar:o}=t,s=(we(s)&&(this.nick=s),we(o)&&(this.avatar=o),new Ys(e));this._elements.push(s)}setGroupSystemNoticeElement(e){e=new Zs(e);this._elements.push(e)}setFaceElement(e){e=new Ws(e);this._elements.push(e)}setMergerElement(e,t){e=new io(e,t);this._elements.push(e)}setIsRead(e){this.isRead=e}setRelayFlag(e){this._relayFlag=e}_computePriority(e){if(qe(e))return Q;if(we(e)&&-1!==Object.values(no).indexOf(e))return e;if(Ee(e)){e=""+e;if(-1!==Object.keys(no).indexOf(e))return no[e]}return Q}setNickAndAvatar(e){var{nick:e,avatar:t}=e;we(e)&&(this.nick=e),we(t)&&(this.avatar=t)}setNameCard(e){we(e)&&(this.nameCard=e)}initC2CReadReceiptInfo(e){this.conversationType===te&&!0===this.needReadReceipt&&(this.readReceiptInfo.isPeerRead=1===e)}}class uo{constructor(e){this._grpM=e,this._n="GroupTipsHandler",this._cachedGroupTipsMap=new Map,this._checkCountMap=new Map,this.MAX_CHECK_COUNT=4,this._getTopicPendingMap=new Map}onCheckTimer(e){e%1==0&&0{let s=this._checkCountMap.get(t);var o=this._grpM.hasLocalGroup(t);rt.l(this._n+`._checkCachedGroupTips groupID:${t} hasLocalGroup:${o} checkCount:`+s),o?(this._notifyCachedGroupTips(t),this._checkCountMap.delete(t),this._grpM.deleteUnjoinedAVChatRoom(t)):s>=this.MAX_CHECK_COUNT?(this._deleteCachedGroupTips(t),this._checkCountMap.delete(t)):(s++,this._checkCountMap.set(t,s))})}onNewGroupTips(e){rt.d(this._n+".onReceiveGroupTips count:"+e.dataList.length);var{eventDataList:e,result:t,AVChatRoomMessageList:s}=this.newGroupTipsStoredAndSummary(e);0{this._getTopicPendingMap.delete(l)}))}var p=this._grpM.hasLocalGroup(h);if(p||!this._grpM.isUnjoinedAVChatRoom(h))if(p||M)if(this._grpM.isMessageFromOrToAVChatroom(h))r.event=i,_.push(r);else if(r.currentUser=this._grpM.getMyUserID(),r.conversationType=se,(n=new ao(r)).setElement({type:J,content:{...r.elements,groupProfile:r.groupProfile}}),n.isSystemMessage=!1,1!==I){const g=this._grpM.get(o),{conversationID:c,sequence:L}=n;if(6===i)n._onlineOnlyFlag=!0,u.push(n);else if(!g.pushIntoNoticeResult(u,n))continue;if(!(this._grpM.isMessageFromCommunityOfTopic(f,l)||6===i&&g.getLocalConversation(c))){6!==i&&this._qualityStat(n);p=g.isRemoteRead({conversationID:c,sequence:L});if(qe(d[c])){let e=0;"in"===n.flow&&(n._isExcludedFromUnreadCount||n._onlineOnlyFlag||p||(e=1)),d[c]=a.push({conversationID:c,unreadCount:e,type:qe(t)?n.conversationType:t,subType:n.conversationSubType,lastMessage:n._isExcludedFromLastMessage?"":n})-1}else{const r=d[c];a[r].type=n.conversationType,a[r].subType=n.conversationSubType,a[r].lastMessage=n._isExcludedFromLastMessage?"":n,"in"===n.flow&&(n._isExcludedFromUnreadCount||n._onlineOnlyFlag||p||a[r].unreadCount++)}}}else this._qualityStat(n);else this._cacheGroupTipsAndProbe({groupID:h,event:i,item:r})}return{eventDataList:a,result:u,AVChatRoomMessageList:_}}_qualityStat(e){this._grpM.get(u).addMessageSequence({key:Ht,message:e})}handleMessageList(e){e.forEach(e=>{switch(e.payload.operationType){case 1:this._onNewMemberComeIn(e);break;case 2:this._onMemberQuit(e);break;case 3:this._onMemberKickedOut(e);break;case 4:this._onMemberSetAdmin(e);break;case 5:this._onMemberCancelledAdmin(e);break;case 6:this._onGroupProfileModified(e);break;case 7:this._onMemberInfoModified(e);break;case 8:this._onTopicProfileUpdated(e);break;default:rt.w(this._n+".handleMessageList unknown operationType:"+e.payload.operationType)}})}_onNewMemberComeIn(e){const{memberNum:t,groupProfile:{groupID:s}}=e.payload,o=this._grpM.getLocalGroupProfile(s);o&&Ee(t)&&o.memberCount!==t&&(o.memberCount=t,this._updateConversationGroupProfile(o))}_onMemberQuit(e){const{memberNum:t,groupProfile:{groupID:s}}=e.payload,o=this._grpM.getLocalGroupProfile(s);o&&Ee(t)&&o.memberCount!==t&&(o.memberCount=t,this._updateConversationGroupProfile(o)),this._grpM.getGroupMemberHandler().deleteLocalGroupMembers(s,e.payload.userIDList)}_onMemberKickedOut(e){const{memberNum:t,groupProfile:{groupID:s}}=e.payload,o=this._grpM.getLocalGroupProfile(s);o&&Ee(t)&&o.memberCount!==t&&(o.memberCount=t,this._updateConversationGroupProfile(o)),this._grpM.getGroupMemberHandler().deleteLocalGroupMembers(s,e.payload.userIDList)}_updateConversationGroupProfile(e){this._grpM.get(o).updateConversationGroupProfile([e])}_onMemberSetAdmin(e){const s=e.payload.groupProfile.groupID,t=e.payload.userIDList,o=this._grpM.getGroupMemberHandler();t.forEach(e=>{const t=o.getLocalGroupMemberInfo(s,e);t&&t.updateRole(le)})}_onMemberCancelledAdmin(e){const s=e.payload.groupProfile.groupID,t=e.payload.userIDList,o=this._grpM.getGroupMemberHandler();t.forEach(e=>{const t=o.getLocalGroupMemberInfo(s,e);t&&t.updateRole(he)})}_onGroupProfileModified(e){const{newGroupProfile:t,groupProfile:s}=e.payload,o=s["groupID"],r=this._grpM.getLocalGroupProfile(o);Object.keys(t).forEach(e=>{switch(e){case"ownerID":this._ownerChanged(r,t);break;case"groupName":r.name=t[e];break;default:r[e]=t[e]}});e=!r.isSupportTopic;this._grpM.emitGroupListUpdate(!0,e)}_ownerChanged({groupID:e},t){const s=this._grpM.getLocalGroupProfile(e),o=this._grpM.getMyUserID();if(o===t.ownerID){s.updateGroup({selfInfo:{role:ce}});const t=this._grpM.getGroupMemberHandler(),r=t.getLocalGroupMemberInfo(e,o),i=this._grpM.getLocalGroupProfile(e).ownerID,n=t.getLocalGroupMemberInfo(e,i);r&&r.updateRole(ce),n&&n.updateRole(he)}}_onMemberInfoModified(e){const{to:t,payload:{groupProfile:s,memberList:o}}=e,r=s.groupID,i=(ze(t)&&this._updateTopicMuteTime(e),this._grpM.getGroupMemberHandler());o.forEach(e=>{const t=i.getLocalGroupMemberInfo(r,e.userID);t&&Ee(e.muteTime)&&t.updateMuteUntil(e.muteTime)})}_updateTopicMuteTime(e){const{to:t,payload:{groupProfile:o,memberList:r=[]}}=e,i=this._grpM.get(s),n=o["groupID"],a=i.getLocalTopic(n,t);if(a){let t=!1;for(let e=0;e{this.onNewGroupTips(e)}),this._deleteCachedGroupTips(e),rt.l(this._n+`._notifyCachedGroupTips groupID:${e} count:`+t.length)}_cacheGroupTipsAndProbe(e){const{groupID:s,event:t,item:o}=e;this._cacheGroupTips(s,{event:t,dataList:[o]}),this._grpM.getGroupSimplifiedInfo(s).then(e=>{var t=e["type"];t===ue?this._grpM.hasLocalGroup(s)?this._notifyCachedGroupTips(s):this._grpM.setUnjoinedAVChatRoom(s):(this._grpM.updateGroupMap([e]),this._notifyCachedGroupTips(s))}),this._checkCountMap.has(s)||this._checkCountMap.set(s,0),rt.l(this._n+"._cacheGroupTipsAndProbe groupID:"+s)}reset(){this._cachedGroupTipsMap.clear(),this._checkCountMap.clear(),this._getTopicPendingMap.clear()}}class po{constructor(e){this._grpM=e,this._n="CommonGroupHandler",this.tempConversationList=null,this._cachedGroupMessageMap=new Map,this._checkCountMap=new Map,this.MAX_CHECK_COUNT=4,this.PAGING_GRP_COUNT_LIMIT=200,this._getTopicPendingMap=new Map,this._pagingStatus=Hs,this._pagingGetCostList=[],e.getInnerEmitterInstance().on(Vt.A2KEY_AND_TINYID_UPDATED,this.syncGroupList,this)}onCheckTimer(e){e%1==0&&0{let s=this._checkCountMap.get(t);var o=this._grpM.hasLocalGroup(t);rt.l(this._n+`._checkCachedGroupMessage groupID:${t} hasLocalGroup:${o} checkCount:`+s),o?(this._notifyCachedGroupMessage(t),this._checkCountMap.delete(t),this._grpM.deleteUnjoinedAVChatRoom(t)):s>=this.MAX_CHECK_COUNT?(this._deleteCachedGroupMessage(t),this._checkCountMap.delete(t)):(s++,this._checkCountMap.set(t,s))})}handleUpdateGroupLastMessage(n){var a,u,e=this._n+".handleUpdateGroupLastMessage";if(0!==this._grpM.getGroupMap().size){let s,o,r,i=!1;for(let e=0,t=n.length;ee.sequence-t.sequence),this._grpM.get(o)),f=this._grpM.get(t);for(let i=0;i{this._getTopicPendingMap.delete(m)}))}var L=this._grpM.hasLocalGroup(o);if(L||!this._grpM.isUnjoinedAVChatRoom(o))if(L||I)if(this._grpM.isMessageFromOrToAVChatroom(o))n.event=e,_.push(n);else if(n.currentUser=this._grpM.getMyUserID(),n.conversationType=se,n.isSystemMessage=!!n.isSystemMessage,(u=new ao(n)).setElement(n.elements,M),1!==D){let e=1===a[i].isModified;if(c.isMessageSentByCurrentInstance(u)?u.isModified=e:e=!1,1===n.onlineOnlyFlag)u._onlineOnlyFlag=!0,c.isMessageSentByCurrentInstance(u)||h.push(u);else{if(this._grpM.isMessageFromCommunityOfTopic(g,m)){h.push(u);continue}if(u.from===this._grpM.getMyUserID()){const t=c.getLatestMessageSentByMe(u.conversationID);if(t){const{nick:s,avatar:o}=t;s===u.nick&&o===u.avatar||(c.modifyMessageSentByMe({conversationID:n,latestNick:u.nick,latestAvatar:u.avatar}),f.mockOnNickAvatarModified(u.nick,u.avatar))}}if(!c.pushIntoMessageList(h,u,e))continue;this._qualityStat(d,u);const{conversationID:n,sequence:t}=u,s=c.isRemoteRead({conversationID:n,sequence:t});if(qe(l[n])){let e=0;"in"===u.flow&&(u._isExcludedFromUnreadCount||s||(e=1)),l[n]=p.push({conversationID:n,unreadCount:e,type:qe(r)?u.conversationType:r,subType:u.conversationSubType,lastMessage:u._isExcludedFromLastMessage?"":u})-1}else{const t=l[n];p[t].type=qe(r)?u.conversationType:r,p[t].subType=u.conversationSubType,p[t].lastMessage=u._isExcludedFromLastMessage?"":u,"in"===u.flow&&(u._isExcludedFromUnreadCount||s||p[t].unreadCount++)}}}else this._qualityStat(d,u);else this._cacheGroupMessageAndProbe({groupID:o,event:e,item:n})}return{conversationOptionsList:p,messageList:h,AVChatRoomMessageList:_}}_qualityStat(e,t){const s=this._grpM.get(u);s.addMessageSequence({key:Ht,message:t}),e&&0{const t=e.elements["revokedInfos"],n=e["revokerInfo"];qe(t)||t.forEach(e=>{var t=ve(e.topicID)?"GROUP"+e.groupID:"GROUP"+e.topicID,s=a.getLocalConversation(t),o=e.revokerInfo&&e.revokerInfo.revoker||n&&n.revoker,r=n&&n.reason||"";let i;if(Je(s.type))i={conversationID:t,sequence:e.sequence,ID:`${e.tinyID}-${e.clientTime}-`+e.random};else{const u=a.revoke(t,e.sequence,e.random);u?i=u:(i={conversationID:t,sequence:e.sequence},e.tinyID&&e.clientTime&&e.random&&(i.ID=`${e.tinyID}-${e.clientTime}-`+e.random),e.time&&(i.time=e.time))}i&&(i.revoker=o,i.revokeReason=r,i.revokerInfo={userID:o,nick:"",avatar:""},u.push(i))})}),0!==u.length&&(a.onMessageRevoked(u),a.updateRevokerInfo(u).then(e=>{this._grpM.emitOuterEvent(Et,e)}))}_groupListTreeShaking(s){const o=new Map([...this._grpM.getGroupMap()]);for(let e=0,t=s.length;e{o.delete(e)}),this._grpM.getGroupMap().forEach((e,t)=>{e.isSupportTopic&&o.delete(t)});var r=[...o.keys()];for(let e=0,t=r.length;e{var e=function(e){if(Ne(e)&&0!==e.length){let t=0;return e.forEach(e=>{t+=e}),(t/e.length).toFixed(0)}}(this._pagingGetCostList),t=function(e){if(Ne(e)&&0!==e.length){let t=0;return e.forEach(e=>{t+=e}),t.toFixed(0)}}(this._pagingGetCostList),t=(this._pagingGetCostList.length=0,this._pagingStatus=js,this._groupListTreeShaking(o),this._grpM.updateGroupMap(o),`count:${this._grpM.getLocalGroupList().length} sum:${t} avg:`+e);return rt.l(r+" ok. "+t),i.setMessage(t).end(),this.tempConversationList&&(this.handleUpdateGroupLastMessage(this.tempConversationList),this.tempConversationList=null),this._grpM.emitGroupListUpdate(!0,!0),it({groupList:this._grpM.getLocalGroupList()})}).catch(e=>(this._pagingStatus=Bs,i.setError(e).end(),rt.e(r+" failed. error:",e),xt(e)))}getGroupList(){const t=this._n+".getGroupList";if(rt.l(t+" pagingStatus:"+this._pagingStatus),this._pagingStatus===Bs||this._pagingStatus===Hs)return this.syncGroupList().then(()=>{var e=this._grpM.getLocalGroupList();return it({groupList:e,isSyncCompleted:this.isPagingGetCompleted()})}).catch(e=>(rt.e(t+" failed. error:",e),xt(e)));var e=this._grpM.getLocalGroupList();return rt.l(t+". returned group count:"+e.length),Ft({groupList:e,isSyncCompleted:this.isPagingGetCompleted()})}isPagingGetCompleted(){return this._pagingStatus===js}_pagingGetGroupList(e){const o=this._n+"._pagingGetGroupList";let{isCommunityRelay:r=!1,limit:i,offset:n,groupBaseInfoFilter:a,groupList:u}=e;const p=Date.now();return this._grpM.req({proto:Yt,data:{type:r?pe:void 0,memberAccount:this._grpM.getMyUserID(),limit:i,offset:n,responseFilter:{groupBaseInfoFilter:a,selfInfoFilter:["Role","JoinTime","MsgFlag","MsgSeq"]}}}).then(e=>{var{groups:e=[],totalCount:t}=e.data,e=(u.push(...e),this._handleGroupAtInfoWithoutTopic(r,e),n+i),s=!(e10018===e.code?(rt.w(this.logPrefix+" response size exceeds the limit, request count:"+i),i=50,this._pagingGetGroupList({limit:i,offset:n,groupBaseInfoFilter:a,groupList:u,isCommunityRelay:r})):r?(11e3===e.code&&rt.l(o+" ok. community unavailable"),Ft({groupList:u})):xt(e))}_pagingGetGroupListWithTopic(e){const o=this._n+"._pagingGetGroupListWithTopic";let{limit:r,offset:i,groupBaseInfoFilter:n,groupList:a}=e;const u=Date.now();return this._grpM.req({proto:Yt,data:{type:pe,memberAccount:this._grpM.getMyUserID(),limit:r,offset:i,responseFilter:{groupBaseInfoFilter:n,selfInfoFilter:["Role","JoinTime","MsgFlag","MsgSeq"]},isSupportTopic:1}}).then(e=>{var{groups:e=[],totalCount:t}=e.data,e=(a.push(...e),i+r),s=!(e!0===e.isSupportTopic);return it({groupList:t})}).catch(e=>10018===e.code?(rt.w(this.logPrefix+" response size exceeds the limit, request count:"+r),r=50,this._pagingGetGroupListWithTopic({limit:r,offset:i,groupBaseInfoFilter:n,groupList:a})):xt(e))}_cacheGroupMessage(e,t){this._cachedGroupMessageMap.has(e)||this._cachedGroupMessageMap.set(e,[]),this._cachedGroupMessageMap.get(e).push(t)}_deleteCachedGroupMessage(e){this._cachedGroupMessageMap.has(e)&&this._cachedGroupMessageMap.delete(e)}_notifyCachedGroupMessage(e){const t=this._cachedGroupMessageMap.get(e)||[];t.forEach(e=>{this.onNewGroupMessage(e)}),this._deleteCachedGroupMessage(e),rt.l(this._n+`._notifyCachedGroupMessage groupID:${e} count:`+t.length)}_cacheGroupMessageAndProbe(e){const{groupID:s,event:t,item:o}=e;this._cacheGroupMessage(s,{event:t,dataList:[o]}),this._grpM.getGroupSimplifiedInfo(s).then(e=>{var t=e["type"];t===ue?this._grpM.hasLocalGroup(s)?this._notifyCachedGroupMessage(s):this._grpM.setUnjoinedAVChatRoom(s):(this._grpM.updateGroupMap([e]),this._notifyCachedGroupMessage(s))}),this._checkCountMap.has(s)||this._checkCountMap.set(s,0),rt.l(this._n+"._cacheGroupMessageAndProbe groupID:"+s)}_handleGroupAtInfoWithoutTopic(e,t){e&&0!==t.length&&t.forEach(e=>{const{groupID:t,groupAtInfoList:s}=e,r=[];qe(s)||(s.forEach(e=>{r.push({...e,groupID:t})}),this._grpM.get(o).onNewGroupAtTips({dataList:r}))})}setPagingGroupCount(e){qe(e)||(this.PAGING_GRP_COUNT_LIMIT=parseInt(e,10))}reset(){this.PAGING_GRP_COUNT_LIMIT=200,this._cachedGroupMessageMap.clear(),this._checkCountMap.clear(),this._getTopicPendingMap.clear(),this._pagingStatus=Hs,this._pagingGetCostList=[]}}const co=1,lo=2,ho=3,go=4,mo=5;class _o{constructor(e){this._grpM=e,this._n="GroupAttributesHandler",this._groupAttributesMap=new Map,this._groupAttributesCopy={},this.CACHE_EXPIRE_TIME=3e4,this._grpM.getInnerEmitterInstance().on(Vt.CLOUD_CONFIG_UPDATED,this._onCloudConfigUpdated,this)}_onCloudConfigUpdated(){var e=this._grpM.getCloudConfig("grp_attr_cache_time");qe(e)||(this.CACHE_EXPIRE_TIME=Number(e))}updateLocalMainSequenceOnReconnected(){this._groupAttributesMap.forEach(e=>{e.localMainSequence=0})}isGroupAttributesUpdatedNotice(e){var{to:e,elements:{newGroupProfile:t}}=e,s=!qe(t)&&!ve(t.groupAttributeOption);return s&&this._onGroupAttributesUpdated({groupID:e,groupAttributeOption:t.groupAttributeOption}),s}_onGroupAttributesUpdated(e){const{groupID:t,groupAttributeOption:s}=e,{mainSequence:o,isWithChangedAttributeInfo:r,groupAttributeList:i=[],operationType:n}=s;if(rt.l(this._n+".onGroupAttributesUpdated. "+`groupID:${t} isWithChangedAttributeInfo:${r} operationType:`+n),!qe(n)){this._groupAttributesCopy=this._getCachedAttributes({groupID:t});e=this._getLocalGroupAttributes(t)["localMainSequence"],e=o-e;if(0!=e){if(1===r&&1==e)return this._refreshCachedGroupAttributes({groupID:t,remoteMainSequence:o,groupAttributeList:i,operationType:n}),void this._emitGroupAttributesUpdated(t);if(this._hasLocalGroupAttributes(t)){const e=this._getLocalGroupAttributes(t)["avChatRoomKey"];this._getGroupAttributes({groupID:t,avChatRoomKey:e}).then(()=>{this._emitGroupAttributesUpdated(t)})}}}}initGroupAttributesCache(e){var{groupID:e,avChatRoomKey:t}=e;this._groupAttributesMap.set(e,{lastUpdateTime:0,localMainSequence:0,remoteMainSequence:0,attributes:new Map,avChatRoomKey:t}),rt.l(this._n+`.initGroupAttributesCache groupID:${e} avChatRoomKey:`+t)}initGroupAttributes(e){const{groupID:r,groupAttributes:i}=e,{remoteMainSequence:t,avChatRoomKey:s}=this._getLocalGroupAttributes(r),n=new zt("initGroupAttributes");return n.setMessage(`groupID:${r} avChatRoomKey:${s} mainSequence:`+t),this._grpM.req({proto:Gs,data:{groupID:r,avChatRoomKey:s,mainSequence:t,groupAttributeList:this._transformGroupAttributes(i)}}).then(e=>{rt.l(this._n+".initGroupAttributes ok. groupID:"+r);const{mainSequence:t,groupAttributeList:s}=e.data,o=[...s];return o.forEach(e=>{e.value=i[e.key]}),this._groupAttributesCopy=this._getCachedAttributes({groupID:r}),this._refreshCachedGroupAttributes({groupID:r,remoteMainSequence:t,groupAttributeList:o,operationType:co}),this._emitGroupAttributesUpdated(r),n.end(),it({groupAttributes:i})}).catch(e=>(n.setError(e).end(),xt(e)))}setGroupAttributes(e){const r=this._n+".setGroupAttributes",{groupID:i,groupAttributes:n}=e,{remoteMainSequence:t,avChatRoomKey:s,attributes:o}=this._getLocalGroupAttributes(i),a=this._transformGroupAttributes(n),u=(a.forEach(e=>{var t=e["key"];e.sequence=0,o.has(t)&&(e.sequence=o.get(t).sequence)}),new zt("setGroupAttributes"));return u.setMessage(`groupID:${i} groupAttributes:`+JSON.stringify(n)),rt.l(r+`. groupID:${i} mainSequence:`+t),this._grpM.req({proto:Cs,data:{groupID:i,avChatRoomKey:s,mainSequence:t,groupAttributeList:a}}).then(e=>{rt.l(r+" ok.");const{mainSequence:t,groupAttributeList:s}=e.data,o=[...s];return o.forEach(e=>{e.value=n[e.key]}),this._groupAttributesCopy=this._getCachedAttributes({groupID:i}),this._refreshCachedGroupAttributes({groupID:i,remoteMainSequence:t,groupAttributeList:o,operationType:lo}),this._emitGroupAttributesUpdated(i),u.end(),it({groupAttributes:n})}).catch(e=>(u.setError(e).end(),xt(e)))}deleteGroupAttributes(h){const{groupID:t,keyList:e=[]}=h,{remoteMainSequence:s,avChatRoomKey:l,attributes:o}=this._getLocalGroupAttributes(t);let r=[...o.keys()],i=Ts,n=ho;const a={groupID:t,avChatRoomKey:l,mainSequence:s},u=[],p=(0{let t=0;o.has(e)&&(t=o.get(e).sequence,r.push(e)),u.push({key:e,sequence:t})}),a.groupAttributeList=u),new zt("deleteGroupAttributes"));return p.setMessage(`groupID:${t} mainSequence:${s} keyList:${e} proto:`+i),this._grpM.req({proto:i,data:a}).then(e=>{rt.l(this._n+".deleteGroupAttributes ok. groupID:"+t);e=e.data.mainSequence;return this._groupAttributesCopy=this._getCachedAttributes({groupID:t}),this._refreshCachedGroupAttributes({groupID:t,remoteMainSequence:e,groupAttributeList:u,operationType:n}),this._emitGroupAttributesUpdated(t),p.end(),it({keyList:r})}).catch(e=>(p.setError(e).end(),xt(e)))}getGroupAttributes(t){const s=this._n+".getGroupAttributes",o=t["groupID"],{avChatRoomKey:e,lastUpdateTime:r,localMainSequence:i,remoteMainSequence:n}=this._getLocalGroupAttributes(o),a=new zt("getGroupAttributes");if(a.setMessage(`groupID:${o} localMainSequence:${i} remoteMainSequence:${n} keyList:`+t.keyList),Date.now()-r>=this.CACHE_EXPIRE_TIME||i{a.setMoreMessage("get attributes from remote. count:"+e.length).end(),rt.l(s+" from remote. groupID:"+o);e=this._getCachedAttributes(t);return it({groupAttributes:e})}).catch(e=>(a.setError(e).end(),xt(e)));a.setMoreMessage("get attributes from cache").end(),rt.l(s+" from cache. groupID:"+o);var u=this._getCachedAttributes(t);return Ft({groupAttributes:u})}_getGroupAttributes(o){let e=0;return qe(o.avChatRoomKey)||(e=1),this._grpM.req({proto:As,data:{...o,groupType:e}}).then(e=>{rt.l(this._n+"._getGroupAttributes ok. groupID:"+o.groupID);var{mainSequence:e,groupAttributeList:t}=e.data,s=[...t];return qe(e)||this._refreshCachedGroupAttributes({groupID:o.groupID,remoteMainSequence:e,groupAttributeList:s,operationType:mo}),t}).catch(e=>xt(e))}_refreshCachedGroupAttributes(e){var{groupID:t,remoteMainSequence:s,groupAttributeList:o,operationType:r}=e;if(this._hasLocalGroupAttributes(t)){const e=this._getLocalGroupAttributes(t),i=e["localMainSequence"];if(r===mo||s-i==1)e.remoteMainSequence=s,e.localMainSequence=s,e.lastUpdateTime=Date.now(),this._updateCachedAttributes({groupAttributes:e,groupAttributeList:o,operationType:r});else{if(i===s)return;e.remoteMainSequence=s}this._groupAttributesMap.set(t,e);o=`operationType:${r} localMainSequence:${i} remoteMainSequence:`+s;rt.l(this._n+"._refreshCachedGroupAttributes. "+o)}}_getCachedAttributes(t){const{groupID:e,keyList:s=[]}=t,o={};if(this._hasLocalGroupAttributes(e)){const t=this._getLocalGroupAttributes(e)["attributes"];if(0{t.has(e)&&(o[e]=t.get(e).value)});else for(const e of t.keys())o[e]=t.get(e).value}return o}_updateCachedAttributes(e){const{groupAttributes:o,groupAttributeList:t,operationType:s}=e;s!==ho?s!==go?(s===co&&o.attributes.clear(),t.forEach(e=>{var{key:e,value:t,sequence:s}=e;o.attributes.set(e,{value:t,sequence:s})})):t.forEach(e=>{o.attributes.delete(e.key)}):o.attributes.clear()}_hasLocalGroupAttributes(e){return this._groupAttributesMap.has(e)}_getLocalGroupAttributes(e){return this._hasLocalGroupAttributes(e)||this.initGroupAttributesCache({groupID:e}),this._groupAttributesMap.get(e)}_transformGroupAttributes(t){const s=[];return Object.keys(t).forEach(e=>{s.push({key:e,value:t[e]})}),s}_emitGroupAttributesUpdated(e){var t=this._getCachedAttributes({groupID:e}),{updatedKeyList:s,deletedKeyList:o}=this._computeAttrChangedInfo(t);rt.l(`${this._n}._emitGroupAttributesUpdated update:${s.length}, delete:`+o.length),0===s.length&&0===o.length||this._grpM.emitOuterEvent(Ut,{groupID:e,groupAttributes:t,updatedKeyList:s,deletedKeyList:o})}_computeAttrChangedInfo(t){const s=[],o=[];return Object.keys(t).forEach(e=>{t[e]!==this._groupAttributesCopy[e]&&s.push(e)}),Object.keys(this._groupAttributesCopy).forEach(e=>{qe(t[e])&&o.push(e)}),this._groupAttributesCopy={},{updatedKeyList:s,deletedKeyList:o}}deleteLocalGroupAttributes(e){this._hasLocalGroupAttributes(e)&&this._groupAttributesMap.delete(e)}reset(){this._groupAttributesMap.clear(),this._groupAttributesCopy={},this.CACHE_EXPIRE_TIME=3e4}}const fo="Set",Mo="Increase",Io="Decrease";class Lo{constructor(e){this._grpM=e,this._n="GroupCountersHandler",this._groupCountersMap=new Map,this.EXPIRE_TIME=3e4,this._grpM.getInnerEmitterInstance().on(Vt.CLOUD_CONFIG_UPDATED,this._onCloudConfigUpdated,this)}_onCloudConfigUpdated(){var e=this._grpM.getCloudConfig("grp_counter_expire_time");qe(e)||(this.EXPIRE_TIME=Number(e))}isGroupCountersNotice(e){var{to:e,elements:{groupCounterInfo:t}}=e;let s=!1;return ve(t)||(this._onGroupCountersUpdated({groupID:e,groupCounterInfo:t}),s=!0),s}_onGroupCountersUpdated(e){const{groupID:r,groupCounterInfo:t}=e;t.forEach(e=>{const{type:t,groupCounterSeq:s,counterList:o=[]}=e;0!==t&&2!==t||(this._updateLocalGroupCounters({groupID:r,groupCounterSeq:s,counterList:o}),o.forEach(e=>{this._grpM.emitOuterEvent(Nt,{groupID:r,key:e.key,value:e.value})})),1===t&&this._deleteLocalGroupCounters({groupID:r,groupCounterSeq:s,counterList:o})}),rt.l(this._n+"._onGroupCountersUpdated groupID:"+r)}initGroupCountersCache(e){var{groupID:e,avChatRoomKey:t}=e;this._groupCountersMap.set(e,{lastUpdateTime:0,groupCounterSeq:0,counters:new Map,avChatRoomKey:t}),rt.l(this._n+`.initGroupCountersCache groupID:${e} avChatRoomKey:`+t)}setGroupCounters(e){if(!this._grpM.canIUse(f.GRP_COUNTER))return this._grpM.cannotUseCommercialAbility("setGroupCounters");const t=this._n+".setGroupCounters",{groupID:s,counters:o}=e,r=this._convertObjectToList(o),i=this._getLocalGroupCounters(s)["avChatRoomKey"],n=`groupID:${s} count:`+r.length,a=new zt("setGroupCounters");return a.setMessage(n),rt.l(t+". "+n),this._updateGroupCounters({groupID:s,counterList:r,avChatRoomKey:i,mode:fo}).then(e=>(a.end(),rt.l(t+" ok."),it({counters:e}))).catch(e=>(a.setError(e).end(),rt.e(t+" failed. error:",e),xt(e)))}increaseGroupCounter(e){var t="increaseGroupCounter";if(!this._grpM.canIUse(f.GRP_COUNTER))return this._grpM.cannotUseCommercialAbility(t);const s=this._n+"."+t,{groupID:o,key:r,value:i}=e,n=this._getLocalGroupCounters(o)["avChatRoomKey"],a=`groupID:${o} key:${r} value:`+i,u=new zt(t);return u.setMessage(a),rt.l(s+". "+a),this._updateGroupCounters({groupID:o,counterList:[{key:r,value:i}],avChatRoomKey:n,mode:Mo}).then(e=>(u.end(),rt.l(s+" ok."),it({counters:e}))).catch(e=>(u.setError(e).end(),rt.e(s+" failed. error:",e),xt(e)))}decreaseGroupCounter(e){var t="decreaseGroupCounter";if(!this._grpM.canIUse(f.GRP_COUNTER))return this._grpM.cannotUseCommercialAbility(t);const s=this._n+"."+t,{groupID:o,key:r,value:i}=e,n=this._getLocalGroupCounters(o)["avChatRoomKey"],a=`groupID:${o} key:${r} value:`+i,u=new zt(t);return u.setMessage(a),rt.l(s+". "+a),this._updateGroupCounters({groupID:o,counterList:[{key:r,value:i}],avChatRoomKey:n,mode:Io}).then(e=>(u.end(),rt.l(s+" ok."),it({counters:e}))).catch(e=>(u.setError(e).end(),rt.e(s+" failed. error:",e),xt(e)))}getGroupCounters(e){if(!this._grpM.canIUse(f.GRP_COUNTER))return this._grpM.cannotUseCommercialAbility("getGroupCounters");const t=this._n+".getGroupCounters",{groupID:s,keyList:o=[]}=e,{avChatRoomKey:r,lastUpdateTime:i}=this._getLocalGroupCounters(s),n=new zt("getGroupCounters");if(n.setMessage("groupID:"+s),Date.now()-i>=this.EXPIRE_TIME)return this._getRemoteGroupCounters({groupID:s,avChatRoomKey:r}).then(e=>{n.setMoreMessage("from remote. count:"+e.length).end(),rt.l(t+" from remote. groupID:"+s);e=this._getLocalCounters(s,o);return it({counters:e})}).catch(e=>(n.setError(e).end(),xt(e)));n.setMoreMessage("from cache").end(),rt.l(t+" from cache. groupID:"+s);e=this._getLocalCounters(s,o);return Ft({counters:e})}_getRemoteGroupCounters(s){return this._grpM.req({proto:$s,data:{...s}}).then(e=>{var{counterList:e=[],groupCounterSeq:t}=e.data;return this._updateLocalGroupCounters({groupID:s.groupID,counterList:e,groupCounterSeq:t}),rt.l(this._n+"._getRemoteGroupCounters ok. groupID:"+s.groupID),e}).catch(e=>xt(e))}_convertObjectToList(t){const s=[];return Object.keys(t).forEach(e=>{s.push({key:e,value:t[e]})}),s}_updateGroupCounters(e){const o=this._n+"._updateGroupCounters",{groupID:t,avChatRoomKey:s,mode:r}=e;return rt.l(o+`. groupID:${t} avChatRoomKey:${s} mode:`+r),this._grpM.req({proto:Ps,data:{...e}}).then(e=>{rt.l(o+" ok.");const{counterList:t=[]}=e.data,s={};return t.forEach(e=>{var{key:e,value:t}=e;s[e]=t}),s}).catch(e=>xt(e))}_hasLocalGroupCounters(e){return this._groupCountersMap.has(e)}_getLocalGroupCounters(e){return this._hasLocalGroupCounters(e)||this.initGroupCountersCache({groupID:e}),this._groupCountersMap.get(e)}_updateLocalGroupCounters(s){const{groupID:e,counterList:t=[],groupCounterSeq:o}=s;if(this._hasLocalGroupCounters(e)){const{counters:s,avChatRoomKey:r,groupCounterSeq:i}=this._getLocalGroupCounters(e);0{var{key:e,value:t}=e;s.set(e,t)}),this._groupCountersMap.set(e,{lastUpdateTime:Date.now(),groupCounterSeq:o,counters:s,avChatRoomKey:r}))}}_deleteLocalGroupCounters(t){const{groupID:e,counterList:s=[],groupCounterSeq:o}=t;if(this._hasLocalGroupCounters(e)){const{counters:t,avChatRoomKey:r}=this._getLocalGroupCounters(e);s.forEach(e=>{t.delete(e.key)}),this._groupCountersMap.set(e,{lastUpdateTime:Date.now(),groupCounterSeq:o,counters:t,avChatRoomKey:r})}}_getLocalCounters(e,t){const s={};if(!this._hasLocalGroupCounters(e))return s;const o=this._getLocalGroupCounters(e)["counters"];if(0{o.has(e)&&(s[e]=o.get(e))});else for(const r of o.keys())s[r]=o.get(r);return s}reset(){this._groupCountersMap.clear(),this.EXPIRE_TIME=3e4}}class Do{constructor(e){var{manager:e,groupID:t,onInit:s,onSuccess:o,onFail:r}=e;this._n="Polling",this._manager=e,this._grpM=e._grpM,this._onInit=s,this._onSuccess=o,this._onFail=r,this._groupID=t,this._timeoutID=-1,this._isRunning=!1,this._proto=Ms}start(){var e=this._grpM.isLoggedIn();e||(this._proto=Is),rt.l(`${this._n}.start pollingInterval:${this._manager.getPollingInterval()} isLoggedIn:`+e),this._isRunning=!0,this._request()}isRunning(){return this._isRunning}_request(){var e=this._onInit(this._groupID);this._grpM.req({proto:this._proto,data:e}).then(e=>{this._onSuccess(this._groupID,e),this.isRunning()&&(clearTimeout(this._timeoutID),this._timeoutID=setTimeout(this._request.bind(this),this._manager.getPollingInterval()))}).catch(e=>{this._onFail(this._groupID,e),this.isRunning()&&(clearTimeout(this._timeoutID),this._timeoutID=setTimeout(this._request.bind(this),this._manager.MAX_POLLING_INTERVAL))})}stop(){rt.l(this._n+".stop"),0{e.userID===this.selfInfo.userID&&Fe(this.selfInfo,e,["sequence"])})}updateSelfInfo({nameCard:e,joinTime:t,role:s,messageRemindType:o,readedSequence:r,excludedUnreadSequenceList:i}){e={nameCard:e,joinTime:t,role:s,messageRemindType:o,readedSequence:r,excludedUnreadSequenceList:i};Fe(this.selfInfo,{...e},[],["",null,void 0,0,NaN])}setSelfNameCard(e){this.selfInfo.nameCard=e}}const To={3:!0,4:!0,5:!0,6:!0,17:!0,20:!0,21:!0};class Ao{constructor(e){this._grpM=e,this._n="AVChatRoomHandler",this._joinedGroupMap=new Map,this._pollingRequestInfoMap=new Map,this._pollingInstanceMap=new Map,this.sequencesLinkedList=new Go(200),this.messageIDLinkedList=new Go(100),this._reportMessageStackedCount=0,this._onlineMemberCountMap=new Map,this.DEFAULT_EXPIRE_TIME=60,this.DEFAULT_POLLING_INTERVAL=300,this.MAX_POLLING_INTERVAL=2e3,this._pollingInterval=this.DEFAULT_POLLING_INTERVAL,this.DEFAULT_POLLING_NO_MESSAGE_COUNT=20,this.DEFAULT_POLLING_INTERVAL_PLUS=2e3,this._pollingNoMessageCount=0,this._startBroadcastSeq=1,this._broadcastMessageIDMap=new Map,this.DEFAULT_POLLING_SIMPLIFIED_MSG=0}hasJoinedAVChatRoom(){return 0this._startBroadcastSeq&&(this._startBroadcastSeq=n),Ne(r)&&0{e.to=e.groupID}),this.onMessage(r,e)):(this._pollingNoMessageCount+=1,this._pollingNoMessageCount===this.DEFAULT_POLLING_NO_MESSAGE_COUNT&&(this._pollingInterval=this.DEFAULT_POLLING_INTERVAL+this.DEFAULT_POLLING_INTERVAL_PLUS)),this._onBroadcastMessage(a))}_handleFailure(e,t){}onMessage(n,a){if(Ne(n)&&0!==n.length){let t=this._n+".onMessage",s=(a&&(t+=" groupID:"+a),0!==this._pollingNoMessageCount&&(this._pollingNoMessageCount=0,this._pollingInterval=this.DEFAULT_POLLING_INTERVAL),null);const h=[],g=this._get(o),c=this._get(u),m=n.length;1e.sequence-t.sequence);var p=this._get(r).isUnlimitedAVChatRoom();let i=!1;if(rt.getLevel()<=0){const a=n.map(e=>e.sequence);rt.l(`${t} count:${a.length} sequenceList:`+a),a.length=0}for(let e=0;e{var{tinyID:e,clientTime:t,random:s,sequence:o}=e,e={conversationID:""+se+r,ID:e+`-${t}-`+s,revoker:i.revoker,revokeReason:i.reason||"",revokerInfo:{userID:i.revoker,nick:"",avatar:""},sequence:o};n.push(e)}),0!==n.length&&this._get(o).updateRevokerInfo(n).then(e=>{this._grpM.emitOuterEvent(Et,e)})}isBroadcastOrNormal(e){return 3===e||17===e}isGroupTip(e){return 4===e||6===e}isGroupSystemNotice(e){return 5===e}restoreGroupTipElements(e={}){const{operatorInfo:t={},operatorID:s,userIDList:o=[],operationType:r}=e;Ee(e.groupJoinType)||1!==r&&2!==r||(e.groupJoinType=2===r?0:1);var{userID:i=s,avatar:n="",nick:a=""}=t,i=(e.operatorInfo={userID:i,avatar:n,nick:a},o.map(e=>({userID:e})));return e.memberInfoList=e.memberInfoList||i,e}restoreMessageFromSimplified(s){const e=s["event"];if(this.isBroadcastOrNormal(e)&&(s.cloudCustomData=s.cloudCustomData||"",s.elements=s.elements.map(e=>{var t;return e.type===z&&({content:t={}}=e,e.content={data:"",description:"",extension:"",...t}),e})),(this.isGroupTip(e)||this.isGroupSystemNotice(e))&&(s.from=s.from||"@TIM#SYSTEM"),this.isGroupTip(e)){s.elements=this.restoreGroupTipElements(s.elements);const{elements:e={}}=s,{operationType:t,operatorInfo:r={}}=e;if(1===t){const s=[{userID:r.userID}];e.memberInfoList=e.memberInfoList||s}}if(this.isGroupSystemNotice(e)){let{memberInfoList:e,operatorInfo:t={}}=s.elements;e=e||t,s.elements.memberInfoList={userID:s.elements.operatorID,avatar:"",nick:"",...e},s.elements={authentication:"",remarkInfo:"",messageKey:1e3*s.time,...s.elements};var o=Object.keys(s.elements).filter(e=>"operatorInfo"!==e).reduce((e,t)=>({...e,[t]:s.elements[t]}),{});s.elements=o}return s}_onGroupDismissed(e){rt.l(this._n+"._onGroupDismissed groupID:"+e),this._grpM.deleteLocalGroupAndConversation(e),this.reset(e)}_checkMessageStacked(e){var t="MessageStacked",e=e.length;100<=e&&(this._grpM.outputWarning(t,e),this._reportMessageStackedCount<5)&&(new zt(t).setMessage(`count:${e} groupID:`+[...this._joinedGroupMap.keys()]).setLevel("warning").end(),this._reportMessageStackedCount+=1)}_isMessageSentByCurrentInstance(e){return!!this._get(o).isMessageSentByCurrentInstance(e)}packMessage(e,t){e.currentUser=this._grpM.getMyUserID(),e.conversationType=5===t?re:se,e.isSystemMessage=!!e.isSystemMessage;const s=new ao(e),o=this.packElements(e,t);return s.setElement(o,this._grpM.getFileDownloadProxy()),s}packElements(e,t){return 4===t||6===t?(this._updateMemberCountByGroupTips(e),{type:J,content:{...e.elements,groupProfile:e.groupProfile}}):5===t?{type:W,content:{...e.elements,groupProfile:{...e.groupProfile,groupID:e.groupID}}}:e.elements}packConversationOption(t){const s=new Map;for(let e=0;e{var{longPollingKey:e,group:t}=o,s=t.groupID;return this._joinedGroupMap.set(s,t),this._grpM.updateGroupMap([t]),this._grpM.deleteUnjoinedAVChatRoom(s),this._grpM.emitGroupListUpdate(!0,!1),qe(e)?Ft({status:Ce,group:t}):Promise.resolve()})}startRunLoop(r){return this.handleJoinResult(r).then(()=>{var{longPollingKey:e,group:t,startSeq:s=0}=r,o=t.groupID;return this._pollingRequestInfoMap.set(o,{key:e,startSeq:s}),this.start(o),this._grpM.isLoggedIn()?Ft({status:Ce,group:t}):Ft({status:Ce})})}_preCheck(){if(this._get(r).isUnlimitedAVChatRoom())return Promise.resolve();if(!this.hasJoinedAVChatRoom())return Promise.resolve();var[e,t]=this._joinedGroupMap.entries().next().value;if(this._grpM.isLoggedIn()){if(t.selfInfo.role!==ce&&t.ownerID!==this._grpM.getMyUserID())return this._grpM.quitGroup(e);this._grpM.deleteLocalGroupAndConversation(e)}else this._grpM.deleteLocalGroupAndConversation(e);return this.reset(e),Promise.resolve()}joinWithoutAuth(e){const s=e["groupID"],r=this._n+".joinWithoutAuth",n=new zt("joinWithoutAuth");return this._grpM.req({proto:os,data:e}).then(({data:{longPollingKey:e}})=>{if(n.setMessage(`groupID:${s} longPollingKey:`+e).end(!0),qe(e))return xt({code:It});rt.l(r+" ok. groupID:"+s),this._get(o).setCompleted(""+se+s);var t=new bo({groupID:s});return this.startRunLoop({group:t,longPollingKey:e}),it({status:Ce})}).catch(e=>(rt.e(r+` failed. groupID:${s} error:`,e),n.setError(e).setMessage("groupID:"+s).end(!0),xt(e))).finally(()=>{this._grpM.get(i).reportAtOnce()})}getGroupOnlineMemberCount(e){const t=this._onlineMemberCountMap.get(e)||{},s=Date.now();return ve(t)||s-t.lastSyncTime>1e3*t.expireTime&&1e4it({memberCount:e.memberCount})).catch(e=>xt(e))):Ft({memberCount:t.memberCount})}_getGroupOnlineMemberCount(r){const i=this._n+"._getGroupOnlineMemberCount",t=new zt("_getGroupOnlineMemberCount");return this._grpM.reqOnlineCount(r).then(e=>{const t=this._onlineMemberCountMap.get(r)||{},{memberCount:s=0,expireTime:o=this.DEFAULT_EXPIRE_TIME}=e.data;rt.l(i+` ok. groupID:${r} memberCount:${s} expireTime:`+o);e=Date.now();return ve(t)&&(t.lastReqTime=e),this._onlineMemberCountMap.set(r,Object.assign(t,{lastSyncTime:e,latestUpdateTime:e,memberCount:s,expireTime:o})),{memberCount:s}}).catch(e=>(rt.w(i+" failed. error:",e),t.setCode(e.code).setMessage(`groupID:${r} error:`+JSON.stringify(e)).end(),Promise.reject(e)))}_get(e){return this._grpM.get(e)}setPollingInterval(e){qe(e)||(Ee(e)?this._pollingInterval=this.DEFAULT_POLLING_INTERVAL=e:this._pollingInterval=this.DEFAULT_POLLING_INTERVAL=parseInt(e,10))}setPollingIntervalPlus(e){qe(e)||(Ee(e)?this.DEFAULT_POLLING_INTERVAL_PLUS=e:this.DEFAULT_POLLING_INTERVAL_PLUS=parseInt(e,10))}setPollingNoMessageCount(e){qe(e)||(Ee(e)?this.DEFAULT_POLLING_NO_MESSAGE_COUNT=e:this.DEFAULT_POLLING_NO_MESSAGE_COUNT=parseInt(e,10))}setPollingSimplifiedMessage(e){qe(e)||"0"!==e&&"1"!==e||(this.DEFAULT_POLLING_SIMPLIFIED_MSG=parseInt(e,10))}getPollingInterval(){return this._pollingInterval}onAVChatRoomMemberBanned(e){e=e.payload.groupProfile.groupID;rt.l(this._n+".onAVChatRoomMemberBanned groupID:"+e),this._grpM.deleteLocalGroupAndConversation(e),this.reset(e)}restartPolling(){rt.l(this._n+".restartPolling count:"+this._pollingInstanceMap.size);for(const e of this._pollingInstanceMap.values())e.stop(),e.start()}getPollingTimerID(e){if(!this._pollingInstanceMap.has(e))return-1;var t=this._pollingInstanceMap.get(e).getPollingTimerID();return rt.l(this._n+`.getPollingTimerID groupID:${e} timerID:`+t),t}reset(e){if(e){rt.l(this._n+".reset groupID:"+e);const t=this._pollingInstanceMap.get(e);t&&t.stop(),this._pollingInstanceMap.delete(e),this._joinedGroupMap.delete(e),this._pollingRequestInfoMap.delete(e),this._onlineMemberCountMap.delete(e)}else{rt.l(this._n+".reset all");for(const e of this._pollingInstanceMap.values())e.stop();this._pollingInstanceMap.clear(),this._joinedGroupMap.clear(),this._pollingRequestInfoMap.clear(),this._onlineMemberCountMap.clear(),this._broadcastMessageIDMap.clear()}this.sequencesLinkedList.reset(),this.messageIDLinkedList.reset(),this._reportMessageStackedCount=0,this._pollingInterval=this.DEFAULT_POLLING_INTERVAL=300,this.DEFAULT_POLLING_NO_MESSAGE_COUNT=20,this.DEFAULT_POLLING_INTERVAL_PLUS=2e3,this._pollingNoMessageCount=0}}class So{constructor(e){this.userID="",this.avatar="",this.nick="",this.role="",this.joinTime="",this.lastSendMsgTime="",this.nameCard="",this.muteUntil=0,this.memberCustomField=[],this.isOnline="Online"===e.onlineStatus,this._initMember(e)}_initMember(e){this.updateMember(e)}updateMember(e){var t=[null,void 0,"",0,NaN];e.memberCustomField&&je(this.memberCustomField,e.memberCustomField),Fe(this,e,["memberCustomField","marks","onlineStatus"],t)}updateRole(e){["Owner","Admin","Member"].indexOf(e)<0||(this.role=e)}updateMuteUntil(e){qe(e)||(this.muteUntil=Math.floor((Date.now()+1e3*e)/1e3))}updateNameCard(e){qe(e)||(this.nameCard=e)}updateMemberCustomField(e){e&&je(this.memberCustomField,e)}}class vo{constructor(e){this._grpM=e,this._n="GroupMemberHandler",this.groupMemberListMap=new Map,this.DEFAULT_MEMBER_INFO_FILTER=["Role","JoinTime","NameCard","ShutUpUntil","OnlineStatus"],this._grpM.getInnerEmitterInstance().on(Vt.PROFILE_UPDATED,this._onProfileUpdated,this)}_onProfileUpdated({data:t}){for(let e=0;e{e.has(s.userID)&&e.get(s.userID).updateMember({nick:s.nick,avatar:s.avatar})})}}deleteGroupMemberList(e){this.groupMemberListMap.delete(e)}getGroupMemberList({groupID:r,role:e,offset:s=0,count:o=15,filter:l}){const i=this._n+".getGroupMemberList",n=this._grpM.hasLocalGroup(r);if(rt.l(i+` groupID:${r} role:${e} offset:${s} count:${o} hasLocalGroup:`+n),!n)return Ft({memberList:[],offset:0});if(this._grpM.getLocalGroupProfile(r).type===ue){if(this._grpM.canIUse(f.AV_MBR_LIST))return this._getAVChatRoomMemberList({groupID:r,offset:s,filter:l});this._grpM.outputWarning("LiveOnlineMember")}let a;e!==le&&e!==ce&&e!==he||(a=e);const g=new zt("getGroupMemberList");let u=0;const p={groupID:r,limit:100(qe(o)||(u=ve(o)?0:o),Ne(e)&&0!==e.length?(this._grpM.hasLocalGroup(r)&&(this._grpM.getLocalGroupProfile(r).memberNum=s),h=this._updateLocalGroupMemberMap(r,e),this._grpM.get(t).getUserProfile({userIDList:e.map(e=>e.userID),tagList:[Ge.NICK,Ge.AVATAR]})):(u=0,Promise.resolve([])))).then(e=>{const t=e["data"];if(!Ne(t)||0===t.length)return Ft({memberList:[],offset:u});e=t.map(e=>({userID:e.userID,nick:e.nick,avatar:e.avatar}));return this._updateLocalGroupMemberMap(r,e),h.length(g.setError(e).end(),rt.e(i+" failed. error:",e),xt(e)))}_getAVChatRoomMemberList({groupID:o,offset:e,filter:t}){const r=this._n+"._getAVChatRoomMemberList",i=new zt("_getAVChatRoomMemberList");return i.setMessage(`groupID:${o} offset:${e} filter:`+t),this._grpM.req({proto:ws,data:{groupID:o,offset:e,filter:t}}).then(e=>{const{memberList:t=[],offset:s=0}=e.data;i.end(),rt.l(r+` ok. member count:${t.length}, next request timestamp:`+s);e=t.map(e=>({...e,onlineStatus:"Online"})),e=this._updateLocalGroupMemberMap(o,e);return it({memberList:e,offset:s})}).catch(e=>(i.setError(e).end(),rt.e(r+" failed. error:",e),xt(e)))}getGroupMemberProfile(e){var s="getGroupMemberProfile",o=this._n+"."+s;let r="groupID:"+e.groupID;5{const s=e.data["members"];return Ne(s)&&0!==s.length?(this._updateLocalGroupMemberMap(i,s),this._grpM.get(t).getUserProfile({userIDList:s.map(({userID:e})=>e),tagList:[Ge.NICK,Ge.AVATAR]})):Ft([])}).then(e=>{e=e.data.map(({userID:e,nick:t,avatar:s})=>({userID:e,nick:t,avatar:s})),this._updateLocalGroupMemberMap(i,e),e=n.filter(e=>this.hasLocalGroupMember(i,e)).map(e=>this.getLocalGroupMemberInfo(i,e));return u.end(),it({memberList:e})})}addGroupMember(i){const n=this._n+".addGroupMember",e=i["groupID"],a=this._grpM.getLocalGroupProfile(e),t=a["type"],u=new zt("addGroupMember");if(u.setMessage(`groupID:${e} groupType:`+t),Je(t)){const i=new nt({code:Mt});return u.setError(i).end(),xt(i)}return i.userIDList=i.userIDList.map(e=>({userID:e})),rt.l(n+" groupID:"+e),this._grpM.req({proto:Ns,data:i}).then(({data:{members:e}})=>{rt.l(n+" ok");var t=e.filter(e=>1===e.result).map(e=>e.userID),s=e.filter(e=>0===e.result).map(e=>e.userID),o=e.filter(e=>2===e.result).map(e=>e.userID),e=e.filter(e=>4===e.result).map(e=>e.userID),r=`groupID:${i.groupID}, successUserIDList:${t}, failureUserIDList:${s}, existedUserIDList:${o}, overLimitUserIDList:`+e;return u.setMoreMessage(r).end(),0===t.length?it({successUserIDList:t,failureUserIDList:s,existedUserIDList:o,overLimitUserIDList:e}):(a.memberCount+=t.length,this._updateConversationGroupProfile(a),it({successUserIDList:t,failureUserIDList:s,existedUserIDList:o,overLimitUserIDList:e,group:a}))}).catch(e=>(u.setError(e).end(),rt.e(n+" failed. error:",e),xt(e)))}deleteGroupMember(e){const t=this._n+".deleteGroupMember",{groupID:s,userIDList:o}=e,r=this._grpM.getLocalGroupProfile(s);if(qe(r))return xt({code:ht});if(Je(r.type))return this._grpM.canIUse(f.AV_BAN_MBR)?this._banAVChatRoomMember(e):this._grpM.cannotUseCommercialAbility("deleteGroupMember");var i=`groupID:${s} `+(5(n.end(),rt.l(t+" ok"),--r.memberCount,this._updateConversationGroupProfile(r),this.deleteLocalGroupMembers(s,o),it({group:r,userIDList:o}))).catch(e=>(n.setError(e).end(),rt.e(t+" failed. error:",e),xt(e)))}_updateConversationGroupProfile(e){this._grpM.get(o).updateConversationGroupProfile([e])}_banAVChatRoomMember(e){const t=this._n+"._banAVChatRoomMember",{groupID:s,userIDList:o}=e,r=`groupID:${s} `+(5(i.end(),rt.l(t+" ok"),this.deleteLocalGroupMembers(s,o),it({group:n,userIDList:o}))).catch(e=>(i.setError(e).end(),rt.e(t+" failed. error:",e),xt(e)))}setGroupMemberMuteTime(e){const{groupID:s,userID:t,muteTime:o}=e,r=this._n+".setGroupMemberMuteTime";if(t===this._grpM.getMyUserID())return xt({code:Ct});e=`groupID:${s} userID:${t} muteTime:`+o;rt.l(r+" "+e);const i=new zt("setGroupMemberMuteTime");return i.setMessage(e),this.modifyGroupMemberInfo({groupID:s,userID:t,muteTime:o}).then(e=>{i.end(),rt.l(r+" ok");var t=this._grpM.getLocalGroupProfile(s);return it({group:t,member:e})}).catch(e=>(i.setError(e).end(),rt.e(r+" failed. error:",e),xt(e)))}setGroupMemberRole(e){const t=this._n+".setGroupMemberRole",{groupID:s,userID:o,role:r}=e,i=`groupID:${s} userID:${o} role:`+r,n=this._grpM.getLocalGroupProfile(s);if(!n||n.type===ie||n.type===ue)return xt({code:Dt});if(n&&n.selfInfo.role!==ce)return xt({code:Lt});const a=[le,he];if(We({groupID:s})&&a.push(ge),a.indexOf(r)<0)return xt({code:yt});if(o===this._grpM.getMyUserID())return xt({code:Gt});const u=new zt("setGroupMemberRole");return u.setMessage(i),rt.l(t+" "+i),this.modifyGroupMemberInfo({groupID:s,userID:o,role:r}).then(e=>(u.end(),rt.l(t+" ok"),it({group:n,member:e}))).catch(e=>(u.setError(e).end(),rt.e(t+" failed. error:",e),xt(e)))}_filterProfanity(e,t){const s=this._grpM.get(c);if(!s)return!0;var{isAllowedToSend:o,modifiedText:r}=s.filterText(t[e],I);return!0===o&&(t[e]=r,!0)}setGroupMemberNameCard(e){const t="setGroupMemberNameCard",s=this._n+"."+t;if(e.nameCard&&!1===this._filterProfanity("nameCard",e))return xt({code:Rt});const{groupID:o,userID:r=this._grpM.getMyUserID(),nameCard:i}=e,n=`groupID:${o} userID:${r} nameCard:`+i;rt.l(s+" "+n);e=this._grpM.getLocalGroupProfile(o);if(e&&Je(e.type)){const e=Tt;return xt({code:e,message:this._grpM.getErrorMessage(e,t)})}const a=new zt(t);return a.setMessage(n),this.modifyGroupMemberInfo({groupID:o,userID:r,nameCard:i}).then(e=>{rt.l(s+" ok"),a.end();const t=this._grpM.getLocalGroupProfile(o);return r===this._grpM.getMyUserID()&&t&&t.setSelfNameCard(i),it({group:t,member:e})}).catch(e=>(a.setError(e).end(),rt.e(s+" failed. error:",e),xt(e)))}setGroupMemberCustomField(e){const t="setGroupMemberCustomField",s=this._n+"."+t,{groupID:o,userID:r=this._grpM.getMyUserID(),memberCustomField:i}=e,n=`groupID:${o} userID:${r} memberCustomField:`+JSON.stringify(i);rt.l(s+" "+n);e=this._grpM.getLocalGroupProfile(o);if(e&&Je(e.type)){const e=Tt;return xt({code:e,message:this._grpM.getErrorMessage(e,t)})}const a=new zt(t);return a.setMessage(n),this.modifyGroupMemberInfo({groupID:o,userID:r,memberCustomField:i}).then(e=>{a.end(),rt.l(s+" ok");var t=this._grpM.getLocalGroupProfile(o);return it({group:t,member:e})}).catch(e=>(a.setError(e).end(),rt.e(s+" failed. error:",e),xt(e)))}modifyGroupMemberInfo(t){let{groupID:s,userID:o}=t,e=void 0;return ze(s)&&(s=Xe(e=s)),this._grpM.req({proto:Os,data:{...t,groupID:s,topicID:e}}).then(()=>{if(this.hasLocalGroupMember(s,o)){const e=this.getLocalGroupMemberInfo(s,o);return qe(t.muteTime)||e.updateMuteUntil(t.muteTime),qe(t.role)||e.updateRole(t.role),qe(t.nameCard)||e.updateNameCard(t.nameCard),qe(t.memberCustomField)||e.updateMemberCustomField(t.memberCustomField),e}const e=this._grpM.getLocalGroupProfile(s);if(e&&!Je(e.type))return this.getGroupMemberProfile({groupID:s,userIDList:[o]}).then(({data:{memberList:[e]}})=>e)})}markGroupMemberList(h){const r=this._n+".markGroupMemberList",{groupID:e,markType:t,enableMark:s,userIDList:i=[]}=h,o=`groupID:${e} markType:${t} enableMark:${s} userIDList count:`+i.length;rt.l(r+" "+o);let n=2;const a=[];!0===s&&(n=1);let u=[...i];500{a.push({userID:e,markType:[t]})}),u=null;const p=new zt("markGroupMemberList");return p.setMessage(o),this._grpM.req({proto:Fs,data:{groupID:e,operationType:n,memberList:a}}).then(e=>{const{memberList:t=[]}=e.data,s=[],o=[];t.length===i.length?s.push(...i):(t.forEach(e=>{s.push(e.userID)}),i.forEach(e=>{s.includes(e)||o.push(e)}));e=`success count:${s.length} fail count:`+o.length;return p.setMessage(e).end(),rt.l(r+" ok. "+e),it({successUserIDList:s,failureUserIDList:o})}).catch(e=>(p.setError(e).end(),rt.e(r+" failed. error:",e),xt(e)))}_getGroupMemberProfileAdvance(e){return this._grpM.req({proto:Us,data:{...e,memberInfoFilter:e.memberInfoFilter||this.DEFAULT_MEMBER_INFO_FILTER}})}_updateLocalGroupMemberMap(t,e){return Ne(e)&&0!==e.length?e.map(e=>(this.hasLocalGroupMember(t,e.userID)?this.getLocalGroupMemberInfo(t,e.userID).updateMember(e):this.setLocalGroupMember(t,new So(e)),this.getLocalGroupMemberInfo(t,e.userID))):[]}deleteLocalGroupMembers(e,t){const s=this.groupMemberListMap.get(e);s&&t.forEach(e=>{s.delete(e)})}getLocalGroupMemberInfo(e,t){return this.groupMemberListMap.has(e)?this.groupMemberListMap.get(e).get(t):null}setLocalGroupMember(e,t){this.groupMemberListMap.has(e)?this.groupMemberListMap.get(e).set(t.userID,t):(t=(new Map).set(t.userID,t),this.groupMemberListMap.set(e,t))}getLocalGroupMemberList(e){return this.groupMemberListMap.get(e)}hasLocalGroupMember(e,t){return this.groupMemberListMap.has(e)&&this.groupMemberListMap.get(e).has(t)}hasLocalGroupMemberMap(e){return this.groupMemberListMap.has(e)}reset(){this.groupMemberListMap.clear()}}const Ro=1,Po=15;class $o{constructor(e){this._grpM=e,this._n="GroupSystemNoticeHandler",this.pendencyMap=new Map}onNewGroupSystemNotice(e){var{dataList:e,isSyncingEnded:t,isInstantMessage:s}=e,{eventDataList:e,result:r}=(rt.d(this._n+".onReceiveSystemNotice count:"+e.length),this.newSystemNoticeStoredAndSummary({notifiesList:e,isInstantMessage:s}));0{e.forEach(e=>{this.pendencyMap.set(`${e.from}_${e.groupID}_`+e.to,e)});const t=this._grpM.get(o).getLocalMessageList(re),i=[];t.forEach(e=>{const{operatorID:t,operationType:s,groupProfile:o}=e.payload;if(s===Ro){const s=`${t}_${o.groupID}_`+o.to,r=this.pendencyMap.get(s);r&&Ee(r.handled)&&0!==r.handled&&i.push(e)}}),this.deleteGroupSystemNotice({messageList:i})})}deleteGroupSystemNotice(e){const s=this._n+".deleteGroupSystemNotice";return Ne(e.messageList)&&0!==e.messageList.length?(rt.l(s+" "+e.messageList.map(e=>e.ID)),this._grpM.req({proto:fs,data:{messageListToDelete:e.messageList.map(e=>({from:re,messageSeq:e.clientSequence,messageRandom:e.random}))}}).then(()=>{rt.l(s+" ok");const t=this._grpM.get(o);return e.messageList.forEach(e=>{t.deleteLocalMessage(e)}),it()}).catch(e=>(rt.e(s+" error:",e),xt(e)))):Ft()}_getPendencyList(e={}){var{type:e,startTime:t=0,limit:s=20}=e;return this._grpM.req({proto:_s,data:{type:e,startTime:t,limit:s,handleAccount:this._grpM.getMyUserID()}}).then(e=>{const t=e.data.pendencyList;return 0!==e.data.nextStartTime?this._getPendencyList({startTime:e.data.nextStartTime}).then(e=>[...t,...e]):t})}getGroupApplicationList(){return this._getPendencyList().then(t=>this._getPendencyList({type:pe}).then(e=>(t.push(...e),this._handlePendencyResult(t))).catch(e=>this._handlePendencyResult(t)))}_handlePendencyResult(e){const t=[];return e.forEach(e=>{this.pendencyMap.set(`${e.from}_${e.groupID}_`+e.to,e),0===e.handled&&t.push({applicant:e.from,applicantNick:e.fromUserNickName,groupName:e.groupName,groupID:e.groupID,authentication:e.authentication,messageKey:e.time,applicationType:e.applicationType,userID:e.userID,note:e.note})}),Ft({applicationList:t})}_onReceivedGroupSystemNotice({result:e,isInstantMessage:t}){t&&e.forEach(e=>{switch(e.payload.operationType){case 1:break;case 2:this._onApplyGroupRequestAgreed(e);break;case 3:break;case 4:this._onMemberKicked(e);break;case 5:this._onGroupDismissed(e);break;case 6:break;case 7:this._onInviteGroup(e);break;case 8:this._onQuitGroup(e);break;case 9:this._onSetManager(e);break;case 10:this._onDeleteManager(e);break;case 11:case 12:case 15:break;case 20:this._onMessageRemindTypeSynced(e);break;case 21:this._grpM.onAVChatRoomMemberBanned(e)}})}_onApplyGroupRequestAgreed(e){e=e.payload.groupProfile.groupID;this._grpM.hasLocalGroup(e)||this._grpM.getGroupProfile({groupID:e}).then(({data:{group:e}})=>{e&&(this._grpM.updateGroupMap([e]),e=!e.isSupportTopic,this._grpM.emitGroupListUpdate(!0,e))})}_onMemberKicked(e){e=e.payload.groupProfile.groupID;this._grpM.hasLocalGroup(e)&&this._grpM.deleteLocalGroupAndConversation(e)}_onGroupDismissed(e){e=e.payload.groupProfile.groupID;this._grpM.hasLocalGroup(e)&&this._grpM.deleteLocalGroupAndConversation(e);const t=this._grpM["_AVChatRoomHandler"];t&&t.checkJoinedAVChatRoomByID(e)&&t.reset(e)}_onInviteGroup(e){e=e.payload.groupProfile.groupID;this._grpM.hasLocalGroup(e)||this._grpM.getGroupProfile({groupID:e}).then(({data:{group:e}})=>{e&&(this._grpM.updateGroupMap([e]),this._grpM.emitGroupListUpdate())})}_onQuitGroup(e){e=e.payload.groupProfile.groupID;this._grpM.hasLocalGroup(e)&&this._grpM.deleteLocalGroupAndConversation(e)}_onSetManager(e){const{to:t,groupID:s}=e.payload.groupProfile,o=this._grpM.getGroupMemberHandler().getLocalGroupMemberInfo(s,t);o&&o.updateRole(le)}_onDeleteManager(e){const{to:t,groupID:s}=e.payload.groupProfile,o=this._grpM.getGroupMemberHandler().getLocalGroupMemberInfo(s,t);o&&o.updateRole(he)}_onMessageRemindTypeSynced(e){var t=e.payload.groupProfile["groupID"],e=e.payload.messageRemindType;this._grpM.get(o).onGroupMessageRemindTypeUpdated({groupID:t,messageRemindType:e})}_handleTopicSystemNotice(e){const{groupProfile:{groupID:t,topicID:o},elements:{operationType:r,topicIDList:i,messageRemindType:n}}=e,a=this._grpM.get(s);17===r?a.onTopicCreated({groupID:t,topicID:o}):18===r?a.onTopicDeleted({groupID:t,topicIDList:i}):20===r&&a.onTopicMessageRemindTypeUpdated({groupID:t,topicID:o,messageRemindType:n})}reset(){this.pendencyMap.clear()}}class Eo extends class{constructor(e){this._m=e,this._n=""}isLoggedIn(){return this._m.get(r).isLoggedIn()}isOversea(){return this._m.get(r).isOversea()}isPrivateNetWork(){return this._m.get(r).isPrivateNetWork()}getFileDownloadProxy(){return this._m.get(r).getFileDownloadProxy()}getMyUserID(){return this._m.get(r).getUserID()}getMyTinyID(){return this._m.get(r).getTinyID()}getSDKAppID(){return this._m.get(r).getSDKAppID()}isIntl(){return this._m.get(r).isIntl()}isUsingChatCore(){return this._m.get(r).isUsingChatCore()}isDevMode(){return this._m.get(r).isDevMode()}get(e){return this._m.get(e)}getPlatform(){return $}getCloudConfig(e){return this._m.get(a).getCloudConfig(e)}emitOuterEvent(e,t){this._m.getOuterEmitterInstance().emit(e,t)}emitInnerEvent(e,t){this._m.getInnerEmitterInstance().emit(e,t)}getInnerEmitterInstance(){return this._m.getInnerEmitterInstance()}generateTjgID(e){return this._m.get(r).getTinyID()+"-"+e.random}req(e){return this._m.get(n).req(e)}canIUse(e){return this._m.get(p).canIUse(e)}getErrorMessage(e,t,s){return this._m.getErrorMessage(e,t,s)}outputWarning(e,t,s){e=this.getErrorMessage(e,t,s);e&&rt.w(e)}cannotUseCommercialAbility(e){var t=vt;return xt({code:t,message:this.getErrorMessage(t,e)})}}{constructor(e){super(e),this._n="GroupModule",this._commonGroupHandler=new po(this),this._groupAttributesHandler=new _o(this),this._groupCountersHandler=new Lo(this),this._AVChatRoomHandler=new Ao(this),this._groupTipsHandler=new uo(this),this._groupSystemNoticeHandler=new $o(this),this._groupMemberHandler=new vo(this),this.groupMap=new Map,this._unjoinedAVChatRoomList=new Map,this._receiptDetailCompleteMap=new Map,this._onlineMemberCountMap=new Map,this._timeoutIDs=[],this.getInnerEmitterInstance().on(Vt.CLOUD_CONFIG_UPDATED,this._onCloudConfigUpdated,this)}_onCloudConfigUpdated(){var e=this.getCloudConfig("polling_interval"),t=this.getCloudConfig("polling_interval_plus"),s=this.getCloudConfig("polling_no_msg_count"),o=this.getCloudConfig("polling_simplified_msg"),r=this.getCloudConfig("paging_grp_count");rt.l(this._n+`._onCloudConfigUpdated pollingInterval:${e} pollingIntervalPlus:${t} pollingNoMessageCount:${s} pollingSimplifiedMessage:${o} pagingGroupCount:`+r),this._AVChatRoomHandler.setPollingInterval(e),this._AVChatRoomHandler.setPollingIntervalPlus(t),this._AVChatRoomHandler.setPollingNoMessageCount(s),this._AVChatRoomHandler.setPollingSimplifiedMessage(o),this._commonGroupHandler.setPagingGroupCount(r)}onCheckTimer(e){this.isLoggedIn()&&(this._commonGroupHandler.onCheckTimer(e),this._groupTipsHandler.onCheckTimer(e))}guardForAVChatRoom(t){if(t.conversationType!==se)return Ft();{const s=ze(t.to)?Xe(t.to):t.to;return this.hasLocalGroup(s)?Ft():this.getGroupProfile({groupID:s}).then(e=>{e=e.data.group.type;if(rt.l(`${this._n}.guardForAVChatRoom. groupID:${s} type:`+e),e!==ue)return Ft();{const e=at;return xt(new nt({code:e,message:this.getErrorMessage(e,t.from,s),data:{message:t}}))}})}}checkJoinedAVChatRoomByID(e){return this._AVChatRoomHandler.checkJoinedAVChatRoomByID(e)}onNewGroupMessage(e){this._commonGroupHandler.onNewGroupMessage(e)}updateNextMessageSeq(e){if(Ne(e)){const o=this.get(s);e.forEach(e=>{var t=e.conversationID.replace(se,"");ze(t)&&o.updateLastMessage(t,e.lastMessage),this.groupMap.has(t)&&(this.groupMap.get(t).nextMessageSeq=e.lastMessage.sequence+1)})}}onNewGroupTips(e){this._groupTipsHandler.onNewGroupTips(e)}onGroupMessageRevoked(e){this._commonGroupHandler.onGroupMessageRevoked(e)}onNewGroupSystemNotice(e){this._groupSystemNoticeHandler.onNewGroupSystemNotice(e)}onGroupMessageReadNotice(e){e.dataList.forEach(i=>{const e=i.elements["groupMessageReadNotice"];if(!qe(e)){const i=this.get(o);e.forEach(e=>{var{groupID:e,topicID:t,lastMessageSeq:s}=e;rt.d(this._n+`.onGroupMessageReadNotice groupID:${e} lastMessageSeq:`+s);let o=""+se+e,r=!0;ve(t)||(o=""+se+t,r=!1),i.updateIsReadAfterReadReport({conversationID:o,lastMessageSeq:s}),i.updateUnreadCount(o,r),i.clearGroupAtInfoList(o,r)})}})}onReadReceiptList(e){rt.d(this._n+".onReadReceiptList options:",JSON.stringify(e)),e.dataList.forEach(e=>{const{groupProfile:t,elements:s}=e,r=t["groupID"],i=this.get(o),n=s["readReceiptList"];i.updateReadReceiptInfo({groupID:r,readReceiptList:n})})}onGroupMessageModified(e){rt.d(this._n+".onGroupMessageModified options:",JSON.stringify(e));const t=this.get(o);e.dataList.forEach(e=>{t.onMessageModified({...e,conversationType:se,to:e.topicID||e.groupID})})}deleteGroupSystemNotice(e){this._groupSystemNoticeHandler.deleteGroupSystemNotice(e)}initGroupMap(e){this.groupMap.set(e.groupID,new bo(e))}clearGroupMap(){this.groupMap.clear()}deleteGroup(e){this.groupMap.delete(e)}updateGroupMap(e){const t=this.get(o);let s;e.forEach(e=>{s=e.groupID,this.groupMap.has(s)?this.groupMap.get(s).updateGroup(e):(this.groupMap.set(s,new bo(e)),t.deleteGroupRoamingMessageInfo(s))});var r=this.getMyUserID();for(const[,o]of this.groupMap)o.selfInfo.userID=r,"Owner"===o.selfInfo.role&&(o.ownerID=r)}getGroupMap(){return this.groupMap}getLocalGroupList(){return[...this.groupMap.values()]}getLocalGroupProfile(e){return this.groupMap.get(e)}sortLocalGroupList(){const e=[...this.groupMap].filter(([,e])=>!ve(e.lastMessage));e.sort((e,t)=>t[1].lastMessage.lastTime-e[1].lastMessage.lastTime),this.groupMap=new Map([...e])}updateGroupLastMessage(e){this._commonGroupHandler.handleUpdateGroupLastMessage(e)}emitGroupListUpdate(e=!0,t=!0){var s=this.getLocalGroupList();if(e&&this.emitOuterEvent(wt),t){const e=JSON.parse(JSON.stringify(s));this.get(o).updateConversationGroupProfile(e)}}getMyNameCardByGroupID(e){e=this.getLocalGroupProfile(e);return e?e.selfInfo.nameCard:""}isPagingGetCompleted(){return this._commonGroupHandler.isPagingGetCompleted()}getMessageRemindType(e){!Ne(e)||0===e.length||0!==(e=e.filter(e=>!Je(this.getLocalGroupProfile(e).type))).length&&(rt.l(this._n+".getMessageRemindType groupIDList:"+e),this.getGroupProfileAdvance({groupIDList:e,responseFilter:{memberInfoFilter:["MsgFlag"]}}).then(e=>{const t=e.data["successGroupList"],s=this.get(o);t.forEach(e=>{s.onGroupMessageRemindTypeUpdated({groupID:e.groupID,messageRemindType:Ne(e.members)?e.members[0].messageRemindType:""})})}))}getGroupList(){return this._commonGroupHandler.getGroupList()}syncCommunityWithTopic(){return this._commonGroupHandler.syncGroupList(!0)}getGroupProfile(t){const r=this._n+".getGroupProfile",i=new zt("getGroupProfile"),{groupID:n,groupCustomFieldFilter:e}=t;rt.l(r+" groupID:"+n);var s={groupIDList:[n],responseFilter:{groupBaseInfoFilter:["Type","Name","Introduction","Notification","FaceUrl","Owner_Account","CreateTime","InfoSeq","LastInfoTime","LastMsgTime","MemberNum","MaxMemberNum","ApplyJoinOption","NextMsgSeq","ShutUpAllMember","InviteJoinOption"],groupCustomFieldFilter:e,memberInfoFilter:["Role","JoinTime","MsgSeq","MsgFlag","NameCard"]}};return this.getGroupProfileAdvance(s).then(({data:{successGroupList:e,failureGroupList:t}})=>{if(rt.l(r+" ok"),0(i.setError(e).setMessage("groupID:"+t.groupID).end(),rt.e(r+" failed. error:",e),xt(e)))}getGroupProfileAdvance(e){const t=this._n+".getGroupProfileAdvance",s=e["groupIDList"],o=(Ne(s)&&50{(We({groupID:e})?r:o).push(e)}),[]);if(0{const t=[],s=[];return e.forEach(e=>{t.push(...e.successGroupList),s.push(...e.failureGroupList)}),it({successGroupList:t,failureGroupList:s})}).catch(e=>(rt.e(t+" failed. error:",e),xt(e)))}_getGroupProfileAdvance(t){const{relayFlag:s=!1,...o}=t;return this.req({proto:Qt,data:o}).then(e=>{rt.l(this._n+"._getGroupProfileAdvance ok. options:",o);const t=e.data["groups"];return{successGroupList:t.filter(e=>qe(e.errorCode)||0===e.errorCode),failureGroupList:t.filter(e=>e.errorCode&&0!==e.errorCode).map(e=>new nt({code:e.errorCode,message:e.errorInfo,data:{groupID:e.groupID}}))}}).catch(e=>s&&We({groupID:t.groupIDList[0]})?{successGroupList:[],failureGroupList:[]}:xt(e))}createGroup(u){const s=[ne,ie,ae,ue,pe],p=this._n+".createGroup",{type:o,groupID:r}=u;if(u.name&&!1===this._filterProfanity("name",u))return xt({code:Rt});if(u.introduction&&!1===this._filterProfanity("introduction",u))return xt({code:Rt});if(u.notification&&!1===this._filterProfanity("notification",u))return xt({code:Rt});if(!s.includes(o))return xt({code:pt});if(!We({type:o})){if(!ve(r)&&We({groupID:r}))return xt({code:lt});u.isSupportTopic=void 0}if(Je(o)&&!qe(u.memberList)&&0{const{groupID:o,overLimitUserIDList:r=[]}=s.data;l=o,g=r;s=`groupType:${u.type} groupID:${o} overLimitUserIDList:`+r;if(h.setMessage(s).end(),rt.l(p+" ok. "+s),u.type===ue)return this.getGroupProfile({groupID:o});if(u.type===pe&&1===u.isSupportTopic)return this.getGroupProfile({groupID:o});ve(u.memberList)||ve(r)||(u.memberList=u.memberList.filter(e=>-1===r.indexOf(e.userID))),this.updateGroupMap([{...u,groupID:o}]);const i=this.get(e);let n="",a=0;u.type===pe?(n=this.isIntl()?"Create Community":"创建社群",a=1):n=this.isIntl()?"Create Group":"创建群组";s=this.get(t).getMyNick(),s=i.createCustomMessage({to:o,conversationType:se,payload:{data:JSON.stringify({businessID:"group_create",content:n,cmd:a,opUser:s||this.getMyUserID(),version:4})}});return i.sendMessageInstance(s),this.emitGroupListUpdate(),this.getGroupProfile({groupID:o})}).then(e=>{const t=e.data["group"],{nameCard:s,joinTime:o}=t.selfInfo;return t.updateSelfInfo({nameCard:s,joinTime:o,messageRemindType:Me,role:ce}),it({group:t,overLimitUserIDList:g})}).catch(e=>{if(h.setMessage("groupType:"+u.type).setError(e).end(),10010!==e.code&&10007!==e.code)return rt.e(p+" failed. error:",e),xt(e);{this._silentlyGetGroupProfile(e.code,l),this.updateGroupMap([{...u,groupID:l}]);const t=this.getLocalGroupProfile(l);return t.selfInfo.role=ce,it({group:t,overLimitUserIDList:g})}})}dismissGroup(e){const t=this._n+".dismissGroup",s="groupID:"+e;if(this.hasLocalGroup(e)&&this.getLocalGroupProfile(e).type===ie)return xt(new nt({code:dt}));const o=new zt("dismissGroup");return o.setMessage(s),rt.l(t+" "+s),this.req({proto:es,data:{groupID:e}}).then(()=>(o.end(),rt.l(t+" ok"),this.deleteLocalGroupAndConversation(e),this.checkJoinedAVChatRoomByID(e)&&this._AVChatRoomHandler.reset(e),this._groupAttributesHandler.deleteLocalGroupAttributes(e),it({groupID:e}))).catch(e=>(o.setError(e).end(),rt.e(t+" failed. error:",e),xt(e)))}updateGroupProfile(e){const t=this._n+".updateGroupProfile";if(this.hasLocalGroup(e.groupID)){const s=this.getLocalGroupProfile(e.groupID).type;this._canIUseJoinOption(s)||qe(e.joinOption)||(rt.w(t+" joinOption is unavailable for Work/Meeting/AVChatRoom"),e.joinOption=void 0)}if(qe(e.muteAllMembers)||(e.muteAllMembers?e.muteAllMembers="On":e.muteAllMembers="Off"),e.name&&!1===this._filterProfanity("name",e))return xt({code:Rt});if(e.introduction&&!1===this._filterProfanity("introduction",e))return xt({code:Rt});if(e.notification&&!1===this._filterProfanity("notification",e))return xt({code:Rt});const s=new zt("updateGroupProfile");return s.setMessage(JSON.stringify(e)),rt.l(t+" groupID:"+e.groupID),this.req({proto:ts,data:e}).then(()=>(s.end(),rt.l(t+" ok"),this.hasLocalGroup(e.groupID)&&this.groupMap.get(e.groupID).updateGroup(e),it({group:this.groupMap.get(e.groupID)}))).catch(e=>(s.setError(e).end(),rt.l(t+" failed. error:",e),xt(e)))}_filterProfanity(e,t){const s=this.get(c);if(!s)return!0;var{isAllowedToSend:o,modifiedText:r}=s.filterText(t[e],M);return!0===o&&(t[e]=r,!0)}joinGroup(t){const{groupID:s,type:o}=t,r=this._n+".joinGroup";if(o===ie)return xt({code:ct});if(this.deleteUnjoinedAVChatRoom(s),this.hasLocalGroup(s)){if(!this.isLoggedIn())return Ft({status:Ie});const o=new zt("applyJoinGroup");return this.getGroupProfile({groupID:s}).then(()=>(o.setMessage(`groupID:${s} joinedStatus:`+Ie).end(),Ft({status:Ie}))).catch(e=>(o.setMessage(`groupID:${s} unjoined`).end(),rt.w(r+` ${s} was unjoined, now join!`),this.groupMap.delete(s),this.applyJoinGroup(t)))}return rt.l(r+" groupID:"+s),this.isLoggedIn()?this.applyJoinGroup(t):this._AVChatRoomHandler.joinWithoutAuth(t)}applyJoinGroup(e){const a=this._n+".applyJoinGroup",{groupID:u,applyMessage:t}=e;if(!ve(t)&&!1===this._filterProfanity("applyMessage",e))return xt({code:Rt});const p=new zt("applyJoinGroup"),s={...e},h=this.canIUse(f.AV_HISTORY_MSG);return h&&(s.historyMessageFlag=1),this.get(o).deleteTopicRoamingMessageInfo(u),this.req({proto:ss,data:s}).then(({data:{joinedStatus:e,longPollingKey:t,startSeq:s,avChatRoomFlag:o,avChatRoomKey:r,messageList:i}})=>{var n=`groupID:${u} joinedStatus:${e} longPollingKey:${t} startSeq:${s} avChatRoomFlag:${o} canGetAVChatRoomHistoryMessage:${h}, history message count:`+(ve(i)?0:i.length);switch(p.setMessage(n).end(),rt.l(a+" ok. "+n),e){case be:return it({status:be});case Ce:return this.getGroupProfile({groupID:u}).then(({data:{group:e}})=>this._handleJoinResult({group:e,avChatRoomFlag:o,longPollingKey:t,startSeq:s,avChatRoomKey:r,messageList:i})).catch(e=>{if(10010!==e.code&&10007!==e.code)return rt.e(a+" failed. error:",e),xt(e);{this._silentlyGetGroupProfile(e.code,u);const a=new bo({groupID:u});return this.updateGroupMap([a]),this._handleJoinResult({group:a,avChatRoomFlag:o,longPollingKey:t,startSeq:s,avChatRoomKey:r,messageList:i})}});default:{const e=new nt({code:ft});return rt.e(a+" failed. error:",e),xt(e)}}}).catch(e=>(p.setMessage("groupID:"+u).setError(e).end(),rt.e(a+" failed. error:",e),xt(e)))}_handleJoinResult(e){const{group:t,avChatRoomFlag:s,longPollingKey:r,startSeq:i,avChatRoomKey:n,messageList:a}=e,u=t["groupID"];if(1!==s)return this.emitGroupListUpdate(!0,!1),it({status:Ce,group:t});{let e;return this.get(o).setCompleted(""+se+u),this._groupAttributesHandler.initGroupAttributesCache({groupID:u,avChatRoomKey:n}),this._groupCountersHandler.initGroupCountersCache({groupID:u,avChatRoomKey:n}),(e=qe(r)?this._AVChatRoomHandler.handleJoinResult({group:t}):this._AVChatRoomHandler.startRunLoop({group:t,longPollingKey:r,startSeq:i})).then(()=>{this._onAVChatRoomHistoryMessage(a,u)}),e}}quitGroup(e){const t=this._n+".quitGroup",s="groupID:"+e,o=(rt.l(t+" "+s),this.checkJoinedAVChatRoomByID(e));if(!o&&!this.hasLocalGroup(e))return xt({code:_t});if(o&&!this.isLoggedIn())return rt.l(t+" anonymously ok. "+s),this.deleteLocalGroupAndConversation(e),this._AVChatRoomHandler.reset(e),Ft({groupID:e});const r=new zt("quitGroup");return r.setMessage(s),this.req({proto:rs,data:{groupID:e}}).then(()=>(r.end(),rt.l(t+" ok"),this.deleteLocalGroupAndConversation(e),o&&this._AVChatRoomHandler.reset(e),this._groupAttributesHandler.deleteLocalGroupAttributes(e),it({groupID:e}))).catch(e=>(r.setError(e).end(),rt.e(t+" failed. error:",e),xt(e)))}searchGroupByID(e){const t=this._n+".searchGroupByID",s={groupIDList:[e]},o=new zt("searchGroupByID");return o.setMessage("groupID:"+e),rt.l(t+" groupID:"+e),this.req({proto:is,data:s}).then(({data:{groupProfile:e}})=>{if(0!==e[0].errorCode)throw new nt({code:e[0].errorCode,message:e[0].errorInfo});return o.end(),rt.l(t+" ok"),it({group:new bo(e[0])})}).catch(e=>(o.setError(e).end(),rt.w(t+" failed. error:",e),xt(e)))}changeGroupOwner(o){const r=this._n+".changeGroupOwner";if(this.hasLocalGroup(o.groupID)&&this.getLocalGroupProfile(o.groupID).type===ue)return xt({code:gt});if(o.newOwnerID===this.getMyUserID())return xt({code:mt});const i=new zt("changeGroupOwner");return i.setMessage(`groupID:${o.groupID} newOwnerID:`+o.newOwnerID),rt.l(r+" groupID:"+o.groupID),this.req({proto:ns,data:o}).then(()=>{i.end(),rt.l(r+" ok");var{groupID:e,newOwnerID:t}=o;this.groupMap.get(e).ownerID=t;const s=this._groupMemberHandler.getLocalGroupMemberList(e);if(s instanceof Map){const o=s.get(this.getMyUserID()),r=(qe(o)||(o.updateRole("Member"),this.groupMap.get(e).selfInfo.role="Member"),s.get(t));qe(r)||r.updateRole("Owner")}return this.emitGroupListUpdate(!0,!1),it({group:this.groupMap.get(e)})}).catch(e=>(i.setError(e).end(),rt.e(r+" failed. error:",e),xt(e)))}getGroupApplicationList(){return this._groupSystemNoticeHandler.getGroupApplicationList()}handleGroupApplication(e){const t=this._n+".handleGroupApplication",{handleAction:h,handleMessage:l,message:s,application:o}=e;let r,i,n,a,u,g=(s?(r=s.payload.operatorID,i=s.payload.groupProfile.groupID,n=s.payload.authentication,a=s.payload.messageKey):o&&(r=o.applicant,i=o.groupID,n=o.authentication,a=o.messageKey),as);o&&2===o.applicationType&&(g=us,u=o.userID);const p=new zt("handleGroupApplication");return p.setMessage("groupID:"+i),rt.l(t+" groupID:"+i),this.req({proto:g,data:{handleAction:h,handleMessage:l,applicant:r,invitee:u,groupID:i,authentication:n,messageKey:a}}).then(()=>(p.end(),rt.l(t+" ok"),s&&this._groupSystemNoticeHandler.deleteGroupSystemNotice({messageList:[e.message]}),it({group:this.getLocalGroupProfile(i)}))).catch(e=>(p.setError(e).end(),rt.e(t+" failed. error",e),xt(e)))}handleGroupInvitation(e){const t=this._n+".handleGroupInvitation",{groupProfile:{groupID:s},authentication:o,messageKey:r,operatorID:i}=e.message.payload,n=e["handleAction"],a=new zt("handleGroupInvitation");return a.setMessage(`groupID:${s} inviter:${i} handleAction:`+n),rt.l(t+` groupID:${s} inviter:${i} handleAction:`+n),this.req({proto:ps,data:{...e,inviter:i,groupID:s,authentication:o,messageKey:r}}).then(()=>(a.end(),rt.l(t+" ok"),this._groupSystemNoticeHandler.deleteGroupSystemNotice({messageList:[e.message]}),it({group:this.getLocalGroupProfile(s)}))).catch(e=>(a.setError(e).end(),rt.e(t+" failed. error",e),xt(e)))}getGroupOnlineMemberCount(t){const s=this._n+".getGroupOnlineMemberCount",e=this._AVChatRoomHandler.checkJoinedAVChatRoomByID(t),o=this.hasLocalGroup(t);if(rt.l(s+` groupID:${t} isAVChatRoom:${e} has:`+o),e)return this._AVChatRoomHandler.getGroupOnlineMemberCount(t);if(!o)return Ft({memberCount:0});var r=Date.now();if(this._onlineMemberCountMap.has(t)){const s=this._onlineMemberCountMap.get(t);if(r-s.lastReqTime<=6e4)return Ft({memberCount:s.memberCount});s.lastReqTime=r}return this.requestOnlineCount(t).then(e=>{var{memberCount:e=0}=e.data;return this._onlineMemberCountMap.set(t,{lastReqTime:Date.now(),memberCount:e}),rt.l(s+` ok. groupID:${t} memberCount:`+e),Ft({memberCount:e})}).catch(e=>(rt.w(s+" failed. error:",e),Promise.reject(e)))}requestOnlineCount(e){return this.req({proto:Ls,data:{groupID:e}})}hasLocalGroup(e){return this.groupMap.has(e)}deleteLocalGroupAndConversation(e){const t=this.checkJoinedAVChatRoomByID(e);if(rt.l(this._n+".deleteLocalGroupAndConversation isJoinedAVChatRoom:"+t),t&&this.get(o).deleteLocalConversation(""+se+e),We({groupID:e})){const t=this.getLocalGroupProfile(e);t&&!0===t.isSupportTopic&&this.get(s).deleteTopicListInCommunity(e)}this._deleteLocalGroup(e),this._onlineMemberCountMap.delete(e),this.emitGroupListUpdate(!0,!1)}_deleteLocalGroup(e){this.groupMap.delete(e),this._groupMemberHandler.deleteGroupMemberList(e)}sendMessage(e,t){if(Ne(e._receiverList)&&0(g=e,rt.l(u+` groupID:${h} startSequence:`+g),this.req({proto:hs,data:{groupID:h,count:21,sequence:g,topicID:c}}))).then(e=>{var{messageList:t,complete:s,invisibleSequenceList:r=[]}=e.data;let{nextSequence:i=0}=e.data;qe(t)?rt.l(u+` ok. complete:${s} nextSequence:${i} but messageList is undefined!`):rt.l(u+` ok. complete:${s} nextSequence:${i} count:`+t.length),l.setMessage(`groupID:${h} topicID:${c} startSequence:${g} complete:${s} nextSequence:`+i).end();const n=this.get(o);let a=[];return ve(t)?1<=i&&n.updateRoamingMessageSequence(p,i):(n.updateRoamingMessageSequence(p,i),a=n.onRoamingMessage(t,p),n.updateIsRead(p),n.patchConversationLastMessage(p)),(2===s||i<1)&&(n.setCompleted(p),i=""),rt.l(u+` nextReqID:${i}, stored message count:${a.length}, invisible sequence count:`+r.length),{nextReqID:i+"",storedMessageList:a}}).catch(e=>(l.setError(e).setMessage(`groupID:${h} topicID:${c} startSequence:`+g).end(),rt.w(u+" failed. error:",e),xt(e)))}_getGroupIDOfMessage(e){return e.conversationID.replace(se,"")}getReadReceiptList(s){const o=this._n+".getReadReceiptList",e=this._getGroupIDOfMessage(s[0]),t=this.getMyUserID(),r=s.filter(e=>e.from===t&&!0===e.needReadReceipt).map(e=>({sequence:e.sequence}));if(rt.l(o+` groupID:${e} sequenceList:`+JSON.stringify(r)),0===r.length)return Ft({messageList:s});const i=new zt("getReadReceiptList");return i.setMessage("groupID:"+e),this.req({proto:gs,data:{groupID:e,sequenceList:r}}).then(e=>{i.end(),rt.l(o+" ok");const t=e.data["readReceiptList"];return Ne(t)&&t.forEach(t=>{s.forEach(e=>{0===t.code&&t.sequence===e.sequence&&(e.readReceiptInfo.readCount=t.readCount,e.readReceiptInfo.unreadCount=t.unreadCount)})}),it({messageList:s})}).catch(e=>(i.setError(e).end(),rt.w(o+" failed. error:",e),xt(e)))}sendReadReceipt(e){const t=this._n+".sendReadReceipt",s=this._getGroupIDOfMessage(e[0]),o=new zt("sendReadReceipt"),r=(o.setMessage("groupID:"+s),this.getMyUserID()),i=e.filter(e=>e.from!==r&&!0===e.needReadReceipt).map(e=>({sequence:e.sequence}));return 0===i.length?xt({code:ut}):(rt.l(t+". sequenceList:"+JSON.stringify(i)),this.req({proto:ms,data:{groupID:s,sequenceList:i}}).then(e=>(o.end(),rt.l(t+" ok"),it())).catch(e=>(o.setError(e).end(),rt.w(t+" failed. error:",e),xt(e))))}getReadReceiptDetail(h){const{message:e,filter:t,cursor:s,count:o}=h,r=this._getGroupIDOfMessage(e),i=e.ID,l=e.sequence,n=this._n+".getReadReceiptDetail",g=this._receiptDetailCompleteMap.get(i)||!1,a=0!==t&&1!==t?0:t,c=we(s)?s:"",m=!Ee(o)||o<=0||100<=o?100:o,d=`groupID:${r} sequence:${l} cursor:${c} filter:${a} completeFlag:`+g,u=(rt.l(n+" "+d),{cursor:"",isCompleted:!1,messageID:i,unreadUserIDList:[],readUserIDList:[]}),p=new zt("getReadReceiptDetail");return p.setMessage(d),this.req({proto:ds,data:{groupID:r,sequence:l,flag:a,cursor:c,count:m}}).then(e=>{p.end();const{cursor:t,isCompleted:s,unreadUserIDList:o,readUserIDList:r}=e.data;return u.cursor=t,1===s&&(u.isCompleted=!0,this._receiptDetailCompleteMap.set(i,!0)),0===a?u.readUserIDList=r.map(e=>e.userID):1===a&&(u.unreadUserIDList=o.map(e=>e.userID)),rt.l(n+" ok"),it(u)}).catch(e=>(p.setError(e).end(),rt.w(n+" failed. error:",e),xt(e)))}getRoamingMessagesHopping(r){const i=this._n+".getRoamingMessagesHopping";let{groupID:t,count:s,sequence:n,direction:a}=r,e=n;if(qe(n)){if(1===a)return Ft({messageList:[],isCompleted:!0,nextMessageSeq:""});if(this.hasLocalGroup(t)){const r=this.getLocalGroupProfile(t)["nextMessageSeq"];e=1{var{messageList:e,complete:t}=e.data,s=`complete:${t} count:`+(e?e.length:0);if(rt.l(i+" ok. "+s),h.setMessage(p+" "+s).end(),2===t||ve(e)){const r=this._computeResult();return it(r)}s=""+se+r.groupID,t=this.get(o).onRoamingMessage(e,s,!1),s=this._computeResult({direction:a,sequence:n,remoteMessageList:e,processedMessageList:t});return it(s)}).catch(e=>(h.setError(e).setMessage(`groupID:${t} sequence:${n} count:`+s).end(),rt.w(i+" failed. error:",e),xt(e)))}_computeResult(e){const t={messageList:[],isCompleted:!1,nextMessageSeq:""};if(qe(e))return t.isCompleted=!0,t;const{direction:s,sequence:o,remoteMessageList:r=[],processedMessageList:i=[]}=e,n=r.length;return 1===s?(t.nextMessageSeq=r[0].sequence+1,i.forEach(e=>{e.sequence>=o&&t.messageList.push(e)}),0===t.messageList.length&&r[0].sequence{a.end(),rt.l(n+" ok.");const e=this.get(o);e.updateIsReadAfterReadReport({conversationID:r,lastMessageSeq:i});let t=!0;if(!qe(p)){t=!1;const r=this.get(s).getLocalTopic(u,p);r&&r.updateSelfInfo({readedSequence:i})}return e.updateUnreadCount(r,t),it()}).catch(e=>(a.setError(e).end(),rt.l(n+" failed. error:",e),xt(e)))}_computeLastSequence(e){var{groupID:e,topicID:t,sequence:s}=e;return 0(ve(e)?rt.w(t+` ${n}, empty successGroupList`):(r=e[0].nextMessageSeq-1,i=n+`, ${r} from remote`,rt.l(t+" "+i)),s.setMessage(i).end(),r)).catch(e=>(s.setError(e).setMessage(n).end(),rt.w(t+" failed. error:",e),xt(e)))}isMessageFromOrToAVChatroom(e){return this._AVChatRoomHandler.checkJoinedAVChatRoomByID(e)}hasJoinedAVChatRoom(){return this._AVChatRoomHandler.hasJoinedAVChatRoom()}getJoinedAVChatRoom(){return this._AVChatRoomHandler.getJoinedAVChatRoom()}isOnlineMessage(e,t){return!(!this._canIUseOnlineOnlyFlag(e)||!t||!0!==t.onlineUserOnly)}_canIUseOnlineOnlyFlag(e){const t=this.getJoinedAVChatRoom();return!t||!t.includes(e.to)||e.conversationType!==se}_onAVChatRoomHistoryMessage(e,t){if(!ve(e)){rt.l(this._n+`._onAVChatRoomHistoryMessage groupID:${t} count:`+e.length);const s=[];e.forEach(e=>{s.push({...e,isHistoryMessage:1})}),this.onAVChatRoomMessage(s,t)}}onAVChatRoomMessage(e,t=""){this._AVChatRoomHandler.onMessage(e,t)}onAVChatRoomMemberBanned(e){this._AVChatRoomHandler.onAVChatRoomMemberBanned(e)}getGroupSimplifiedInfo(t){const s=new zt("getGroupSimplifiedInfo"),e={groupIDList:[t],responseFilter:{groupBaseInfoFilter:["Type","Name"]}};return this.getGroupProfileAdvance(e).then(({data:{successGroupList:e}})=>(s.setMessage(`groupID:${t} type:`+e[0].type).end(),e[0])).catch(e=>{s.setError(e).setMessage("groupID:"+t).end()})}setUnjoinedAVChatRoom(e){this._unjoinedAVChatRoomList.set(e,1)}deleteUnjoinedAVChatRoom(e){this._unjoinedAVChatRoomList.has(e)&&this._unjoinedAVChatRoomList.delete(e)}isUnjoinedAVChatRoom(e){return this._unjoinedAVChatRoomList.has(e)}isGroupAttributesUpdatedNotice(e){return this._groupAttributesHandler.isGroupAttributesUpdatedNotice(e)}updateLocalMainSequenceOnReconnected(){this._groupAttributesHandler.updateLocalMainSequenceOnReconnected()}initGroupAttributes(e){return this._groupAttributesHandler.initGroupAttributes(e)}setGroupAttributes(e){return this._groupAttributesHandler.setGroupAttributes(e)}deleteGroupAttributes(e){return this._groupAttributesHandler.deleteGroupAttributes(e)}getGroupAttributes(e){return this._groupAttributesHandler.getGroupAttributes(e)}isMessageFromTopic(e,t){return 2===e&&!ve(t)}isMessageFromCommunityOfTopic(e,t){return 2===e&&ve(t)}getMessageExtensions(e,t){return rt.l(this._n+".getMessageExtensions startSequence:"+t),this.req({proto:vs,data:{groupID:e.to,messageSequence:e.sequence,startSequence:t}})}modifyMessageExtensions(e,t,s=1){return rt.l(this._n+".modifyMessageExtensions operateType:"+s),this.req({proto:Ss,data:{groupID:e.to,messageSequence:e.sequence,extensionList:t,operateType:s}})}_genNotifyReqList(s){const o=[];for(let e=0,t=s.length;e{var{type:t,isSupportTopic:s}=this.getLocalGroupProfile(e);return this.hasLocalGroup(e)&&!Je(t)&&!s});let o="filteredGroupIDList.length:"+t.length;t.length<=10&&(o="filteredGroupIDList:"+JSON.stringify(t)),rt.l(s+" "+o),0!==t.length&&this.req({proto:Rs,data:{notifyReqList:this._genNotifyReqList(e)}}).then(o=>{const e=o.data["notifyRspList"],r=[];if(Ne(e)){const o={dataList:[]};e.forEach(e=>{var{nextRevokedTime:t,groupID:s}=e;o.dataList.push({elements:{revokedInfos:this._genRevokedInfos(e)}}),0!==t?(this._setGroupLastRevokedTime(s,t),r.push(s)):this._setGroupLastRevokedTime(s,1e3*De())}),this.onGroupMessageRevoked(o)}0{rt.e(s+" failed. error:",e)})}_genRevokedInfos(e){const{notifyList:t,groupID:s}=e,o=[];return Ne(t)&&t.forEach(e=>{o.push({groupID:s,sequence:e.sequence,random:e.random,revokerInfo:{...e.revokerInfo}})}),o}_getGroupLastRevokedTime(e){return this.hasLocalGroup(e)?this.getLocalGroupProfile(e)._lastRevokedTime:0}_setGroupLastRevokedTime(e,t){this.hasLocalGroup(e)&&(this.getLocalGroupProfile(e)._lastRevokedTime=t)}isGroupCountersNotice(e){return this._groupCountersHandler.isGroupCountersNotice(e)}setGroupCounters(e){return this._groupCountersHandler.setGroupCounters(e)}increaseGroupCounter(e){return this._groupCountersHandler.increaseGroupCounter(e)}decreaseGroupCounter(e){return this._groupCountersHandler.decreaseGroupCounter(e)}getGroupCounters(e){return this._groupCountersHandler.getGroupCounters(e)}getGroupMemberHandler(){return this._groupMemberHandler}getGroupMemberList(e){return this._groupMemberHandler.getGroupMemberList(e)}getGroupMemberProfile(e){return this._groupMemberHandler.getGroupMemberProfile(e)}addGroupMember(e){return this._groupMemberHandler.addGroupMember(e)}deleteGroupMember(e){return this._groupMemberHandler.deleteGroupMember(e)}setGroupMemberMuteTime(e){return this._groupMemberHandler.setGroupMemberMuteTime(e)}setGroupMemberRole(e){return this._groupMemberHandler.setGroupMemberRole(e)}setGroupMemberNameCard(e){return this._groupMemberHandler.setGroupMemberNameCard(e)}setGroupMemberCustomField(e){return this._groupMemberHandler.setGroupMemberCustomField(e)}markGroupMemberList(e){return this._groupMemberHandler.markGroupMemberList(e)}modifyGroupMemberInfo(e){return this._groupMemberHandler.modifyGroupMemberInfo(e)}restartPolling(){this._AVChatRoomHandler.restartPolling()}getPollingTimerID(e){if(!e)return-1;var t=this.getLocalGroupProfile(e);return t&&Je(t.type)?this._AVChatRoomHandler.getPollingTimerID(e):-1}_canIUseJoinOption(e){return e===ne||We({type:e})}_silentlyGetGroupProfile(e,t){var s=setTimeout(this.getGroupProfile.bind(this,{groupID:t}),3e3);this._timeoutIDs.push(s),rt.l(this._n+`._silentlyGetGroupProfile errorCode:${e} groupID:${t} timeoutIDs:`+this._timeoutIDs)}_clearTimeoutIDs(){this._timeoutIDs.forEach(e=>{clearTimeout(e)}),this._timeoutIDs=[]}reset(){this.groupMap.clear(),this._unjoinedAVChatRoomList.clear(),this._receiptDetailCompleteMap.clear(),this._onlineMemberCountMap.clear(),this._commonGroupHandler.reset(),this._groupSystemNoticeHandler.reset(),this._groupTipsHandler.reset(),this._groupAttributesHandler.reset(),this._groupCountersHandler.reset(),this._AVChatRoomHandler.reset(),this._groupMemberHandler.reset(),this._clearTimeoutIDs()}}export{Eo as default};