diff --git a/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/TRTCCalling/TRTCCalling.js b/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/TRTCCalling/TRTCCalling.js index cafb5a36f9..3c3f3ed9ff 100644 --- a/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/TRTCCalling/TRTCCalling.js +++ b/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/TRTCCalling/TRTCCalling.js @@ -1,9 +1,7 @@ import EventEmitter from './utils/event.js'; import { EVENT, CALL_STATUS, MODE_TYPE, CALL_TYPE } from './common/constants.js'; import formateTime from './utils/formate-time'; -import TSignaling from './node_module/tsignaling-wx'; -import TRTC from './node_module/trtc-wx'; -import TIM from './node_module/tim-wx-sdk'; +import { TSignaling, TRTC, TIM } from './libSrcConfig' import TSignalingClient from './TSignalingClient'; import TRTCCallingDelegate from './TRTCCallingDelegate'; import TRTCCallingInfo from './TRTCCallingInfo'; @@ -27,7 +25,8 @@ class TRTCCalling { this.EVENT = EVENT; this.CALL_TYPE = CALL_TYPE; this._emitter = new EventEmitter(); - this.TRTC = new TRTC(); + this.TRTC = new TRTC(this, { TUIScene: 'TUICalling' }); + wx.TUIScene = 'TUICalling'; if (params.tim) { this.tim = params.tim; } else { @@ -35,6 +34,7 @@ class TRTCCalling { SDKAppID: params.sdkAppID, }); } + if (!wx.$TSignaling) { wx.$TSignaling = new TSignaling({ SDKAppID: params.sdkAppID, tim: this.tim }); } @@ -48,7 +48,8 @@ class TRTCCalling { callStatus: CALL_STATUS.IDLE, // 用户当前的通话状态 soundMode: 'speaker', // 声音模式 听筒/扬声器 active: false, - invitation: { // 接收到的邀请 + invitation: { + // 接收到的邀请 inviteID: '', inviter: '', type: '', @@ -71,6 +72,8 @@ class TRTCCalling { _isGroupCall: false, // 当前通话是否是群通话 _groupID: '', // 群组ID _switchCallModeStatus: true, // 是否可以进行模式切换 + enterRoomStatus: false, // 进入房间状态 + isCallEnd: true, // 通话是否为正常通话结束, true:正常通话结束,false:非正常通话结束 如:cancel、timeout、noResp }; this.data = { ...this.data, ...data }; } @@ -101,9 +104,11 @@ class TRTCCalling { const enableCamera = callType !== CALL_TYPE.VIDEO; this.setPusherAttributesHandler({ enableCamera }); if (enableCamera) { - this.data.invitation.type = this.data.config.type = CALL_TYPE.VIDEO; + this.data.config.type = CALL_TYPE.VIDEO; + this.data.invitation.type = CALL_TYPE.VIDEO; } else { - this.data.invitation.type = this.data.config.type = CALL_TYPE.AUDIO; + this.data.config.type = CALL_TYPE.AUDIO; + this.data.invitation.type = CALL_TYPE.AUDIO; } this.TRTCCallingDelegate.onCallMode({ type: this.data.config.type, message: callModeMessage.data.message }); this.setSwitchCallModeStatus(true); @@ -111,22 +116,40 @@ class TRTCCalling { // 判断是否为音视频切换 judgeSwitchCallMode(inviteData) { - const isSwitchCallMode = (inviteData.switch_to_audio_call - && inviteData.switch_to_audio_call === 'switch_to_audio_call') - || inviteData.data && inviteData.data.cmd === 'switchToAudio' - || inviteData.data && inviteData.data.cmd === 'switchToVideo'; + const isSwitchCallMode = + (inviteData.switch_to_audio_call && inviteData.switch_to_audio_call === 'switch_to_audio_call') || + (inviteData.data && inviteData.data.cmd === 'switchToAudio') || + (inviteData.data && inviteData.data.cmd === 'switchToVideo'); return isSwitchCallMode; } // 新的邀请回调事件 handleNewInvitationReceived(event) { - console.log(TAG_NAME, 'onNewInvitationReceived', `callStatus:${this.data.callStatus === CALL_STATUS.CALLING || this.data.callStatus === CALL_STATUS.CONNECTED}, inviteID:${event.data.inviteID} inviter:${event.data.inviter} inviteeList:${event.data.inviteeList} data:${event.data.data}`); - const { data: { inviter, inviteeList, data, inviteID, groupID } } = event; + console.log( + TAG_NAME, + 'onNewInvitationReceived', + `callStatus:${ + this.data.callStatus === CALL_STATUS.CALLING || this.data.callStatus === CALL_STATUS.CONNECTED + }, inviteID:${event.data.inviteID} inviter:${event.data.inviter} inviteeList:${event.data.inviteeList} data:${ + event.data.data + }`, + ); + const { + data: { inviter, inviteeList, data, inviteID, groupID }, + } = event; const inviteData = JSON.parse(data); // 此处判断inviteeList.length 大于2,用于在非群组下多人通话判断 // userIDs 为同步 native 在使用无 groupID 群聊时的判断依据 - const isGroupCall = !!(groupID || inviteeList.length >= 2 || inviteData.data && inviteData.data.userIDs && inviteData.data.userIDs.length >= 2); + const isGroupCall = !!( + groupID || + inviteeList.length >= 2 || + (inviteData.data && inviteData.data.userIDs && inviteData.data.userIDs.length >= 2) + ); + if (inviteData?.data?.cmd === 'hangup') { + this.TRTCCallingDelegate.onCallEnd(inviter, inviteData.call_end || 0); + return; + } let callEnd = false; // 此处逻辑用于通话结束时发出的invite信令 // 群通话已结束时,room_id 不存在或者 call_end 为 0 @@ -140,8 +163,8 @@ class TRTCCalling { // 判断新的信令是否为结束信令 if (callEnd) { // 群通话中收到最后挂断的邀请信令通知其他成员通话结束 - this.TRTCCallingDelegate.onCallEnd({ userID: inviter, callEnd: isGroupCall ? 0 : inviteData.call_end }); - this._reset(); + // this.TRTCCallingDelegate.onCallEnd({ userID: inviter, callEnd: isGroupCall ? 0 : inviteData.call_end }); + this._reset(isGroupCall ? 0 : inviteData.call_end); return; } @@ -193,6 +216,10 @@ class TRTCCalling { callEnd: 0, }, }; + this.setPusherAttributesHandler({ + enableCamera: this.data.config.type === CALL_TYPE.VIDEO + }) + wx.createLivePusherContext().startPreview(); this.TRTCCallingDelegate.onInvited(newReceiveData); } @@ -203,12 +230,15 @@ class TRTCCalling { return; } const list = [...this.data.groupInviteID]; - this.data.groupInviteID = list.filter(item => item !== inviteID); + this.data.groupInviteID = list.filter((item) => item !== inviteID); } // 发出的邀请收到接受的回调 - handleInviteeAccepted(event) { - console.log(`${TAG_NAME} INVITEE_ACCEPTED inviteID:${event.data.inviteID} invitee:${event.data.invitee} data:`, event.data); + async handleInviteeAccepted(event) { + console.log( + `${TAG_NAME} INVITEE_ACCEPTED inviteID:${event.data.inviteID} invitee:${event.data.invitee} data:`, + event.data, + ); const inviteData = JSON.parse(event.data.data); // 防止取消后,接收到远端接受信令 if (this.data.callStatus === CALL_STATUS.IDLE) { @@ -223,7 +253,10 @@ class TRTCCalling { // 发起人进入通话状态从此处判断 if (event.data.inviter === this._getUserID() && this.data.callStatus === CALL_STATUS.CALLING) { this._setCallStatus(CALL_STATUS.CONNECTED); - this.TRTCCallingDelegate.onUserAccept(event.data.invitee); + this.TRTCCallingDelegate.onUserAccept( + event.data.invitee, + await this.getUserProfile(this.data._unHandledInviteeList.map(item => ({userID: item}))), + ); } this.setInviteIDList(event.data.inviteID); if (this._getGroupCallFlag()) { @@ -234,7 +267,9 @@ class TRTCCalling { // 发出的邀请收到拒绝的回调 handleInviteeRejected(event) { - console.log(`${TAG_NAME} INVITEE_REJECTED inviteID:${event.data.inviteID} invitee:${event.data.invitee} data:${event.data.data}`); + console.log( + `${TAG_NAME} INVITEE_REJECTED inviteID:${event.data.inviteID} invitee:${event.data.invitee} data:${event.data.data}`, + ); // 防止切换音视频对方不可用时,返回数据流向onLineBusy或onReject if (!this.data._isGroupCall && !this.data._switchCallModeStatus) { console.log(`${TAG_NAME}.onInviteeRejected - Audio and video switching is not available`); @@ -246,7 +281,7 @@ class TRTCCalling { } // 判断被呼叫方已经接入,后续拒绝不影响正常通话 if (this.data.callStatus === CALL_STATUS.CONNECTED) { - const userInPlayerListFlag = this.data.playerList.some(item => (item.userID === event.data.invitee)); + const userInPlayerListFlag = this.data.playerList.some((item) => item.userID === event.data.invitee); if (userInPlayerListFlag) { return; } @@ -271,13 +306,13 @@ class TRTCCalling { // 2、已经接受邀请,远端没有用户,发出结束通话事件 const isPlayer = this.data.callStatus === CALL_STATUS.CONNECTED && this.data.playerList.length === 0; if (isCalling || isPlayer) { - this.TRTCCallingDelegate.onCallEnd({ userID: this.data.config.userID, callEnd: 0 }); + // this.TRTCCallingDelegate.onCallEnd({ userID: this.data.config.userID, callEnd: 0 }); this._reset(); } } }); } else { - this.TRTCCallingDelegate.onCallEnd({ userID: this.data.config.userID, callEnd: 0 }); + // this.TRTCCallingDelegate.onCallEnd({ userID: this.data.config.userID, callEnd: 0 }); this._reset(); } } @@ -289,17 +324,26 @@ class TRTCCalling { this._reset(); return; } - console.log(TAG_NAME, 'onInvitationCancelled', `inviteID:${event.data.inviteID} inviter:${event.data.invitee} data:${event.data.data}`); + console.log( + TAG_NAME, + 'onInvitationCancelled', + `inviteID:${event.data.inviteID} inviter:${event.data.invitee} data:${event.data.data}`, + ); this._setCallStatus(CALL_STATUS.IDLE); this.TRTCCallingDelegate.onCancel({ inviteID: event.data.inviteID, invitee: event.data.invitee }); - this.TRTCCallingDelegate.onCallEnd({ userID: this.data.config.userID, callEnd: 0 }); + this.data.isCallEnd = false; + // this.TRTCCallingDelegate.onCallEnd({ userID: this.data.config.userID, callEnd: 0 }); this.setInviteIDList(event.data.inviteID); this._reset(); } // 收到的邀请收到该邀请超时的回调 handleInvitationTimeout(event) { - console.log(TAG_NAME, 'onInvitationTimeout', `data:${JSON.stringify(event)} inviteID:${event.data.inviteID} inviteeList:${event.data.inviteeList}`); + console.log( + TAG_NAME, + 'onInvitationTimeout', + `data:${JSON.stringify(event)} inviteID:${event.data.inviteID} inviteeList:${event.data.inviteeList}`, + ); const { groupID = '', inviteID, inviter, inviteeList, isSelfTimeout } = event.data; // 防止用户已挂断,但接收到超时事件后的,抛出二次超时事件 if (this.data.callStatus === CALL_STATUS.IDLE) { @@ -317,7 +361,8 @@ class TRTCCalling { }); // 若在呼叫中,且全部用户都无应答 if (this.data.callStatus !== CALL_STATUS.CONNECTED) { - this.TRTCCallingDelegate.onCallEnd({ userID: inviter, callEnd: 0 }); + // this.TRTCCallingDelegate.onCallEnd({ userID: inviter, callEnd: 0 }); + this.data.isCallEnd = false; this._reset(); } return; @@ -351,12 +396,14 @@ class TRTCCalling { }); return; } - this.TRTCCallingDelegate.onCallEnd({ userID: inviter, callEnd: 0 }); + this.data.isCallEnd = false; + // this.TRTCCallingDelegate.onCallEnd({ userID: inviter, callEnd: 0 }); this._reset(); } } else { // 1v1通话被邀请方超时 - this.TRTCCallingDelegate.onCallEnd({ userID: inviter, callEnd: 0 }); + // this.TRTCCallingDelegate.onCallEnd({ userID: inviter, callEnd: 0 }); + this.data.isCallEnd = false; this._reset(); } // 用inviteeList进行判断,是为了兼容多人通话 @@ -368,13 +415,16 @@ class TRTCCalling { // SDK Ready 回调 handleSDKReady() { console.log(TAG_NAME, 'TSignaling SDK ready'); + this.TSignalingResolve(); this.TRTCCallingDelegate.onSdkReady({ message: 'SDK ready' }); const promise = this.tim.getMyProfile(); - promise.then((imResponse) => { - this.data.localUser = imResponse.data; - }).catch((imError) => { - console.warn('getMyProfile error:', imError); // 获取个人资料失败的相关信息 - }); + promise + .then((imResponse) => { + this.data.localUser = imResponse.data; + }) + .catch((imError) => { + console.warn('getMyProfile error:', imError); // 获取个人资料失败的相关信息 + }); } // 被踢下线 @@ -404,19 +454,19 @@ class TRTCCalling { // 取消 tsignaling 事件监听 _removeTSignalingEvent() { // 新的邀请回调事件 - wx.$TSignaling.off(TSignaling.EVENT.NEW_INVITATION_RECEIVED); + wx.$TSignaling.off(TSignaling.EVENT.NEW_INVITATION_RECEIVED, this.handleNewInvitationReceived); // 发出的邀请收到接受的回调 - wx.$TSignaling.off(TSignaling.EVENT.INVITEE_ACCEPTED); + wx.$TSignaling.off(TSignaling.EVENT.INVITEE_ACCEPTED, this.handleInviteeAccepted); // 发出的邀请收到拒绝的回调 - wx.$TSignaling.off(TSignaling.EVENT.INVITEE_REJECTED); + wx.$TSignaling.off(TSignaling.EVENT.INVITEE_REJECTED, this.handleInviteeRejected); // 收到的邀请收到该邀请取消的回调 - wx.$TSignaling.off(TSignaling.EVENT.INVITATION_CANCELLED); + wx.$TSignaling.off(TSignaling.EVENT.INVITATION_CANCELLED, this.handleInvitationCancelled); // 收到的邀请收到该邀请超时的回调 - wx.$TSignaling.off(TSignaling.EVENT.INVITATION_TIMEOUT); + wx.$TSignaling.off(TSignaling.EVENT.INVITATION_TIMEOUT, this.handleInvitationTimeout); // SDK Ready 回调 - wx.$TSignaling.off(TSignaling.EVENT.SDK_READY); + wx.$TSignaling.off(TSignaling.EVENT.SDK_READY, this.handleSDKReady); // 被踢下线 - wx.$TSignaling.off(TSignaling.EVENT.KICKED_OUT); + wx.$TSignaling.off(TSignaling.EVENT.KICKED_OUT, this.handleKickedOut); } // 远端用户加入此房间 @@ -440,7 +490,7 @@ class TRTCCalling { console.log(TAG_NAME, 'REMOTE_USER_LEAVE', event, event.data.userID); if (userID) { // this.data.playerList = await this.getUserProfile(playerList) - this.data.playerList = this.data.playerList.filter(item => item.userID !== userID); + this.data.playerList = this.data.playerList.filter((item) => item.userID !== userID); // 群组或多人通话模式下,有用户离开时,远端还有用户,则只下发用户离开事件 if (playerList.length > 0) { this.TRTCCallingDelegate.onUserLeave({ userID, playerList: this.data.playerList }); @@ -594,6 +644,7 @@ class TRTCCalling { // 进入房间 enterRoom(options) { + this._addTRTCEvent(); const { roomID } = options; const config = Object.assign(this.data.config, { roomID, @@ -606,17 +657,25 @@ class TRTCCalling { if (this.data._unHandledInviteeList.length > 0) { this._setUnHandledInviteeList(this.data.config.userID); } + this.data.enterRoomStatus = true; this.data.pusher = this.TRTC.enterRoom(config); this.TRTC.getPusherInstance().start(); // 开始推流 } // 退出房间 - exitRoom() { + exitRoom(callEnd) { + this.TRTC.getPusherInstance().stop(); // 停止推流 const result = this.TRTC.exitRoom(); + if (this.data.isCallEnd) { + this.TRTCCallingDelegate.onCallEnd({ userID: this.data.config.userID, callEnd: callEnd || 0 }); + } this.data.pusher = result.pusher; this.data.playerList = result.playerList; this.data._unHandledInviteeList = []; + this.data.enterRoomStatus = false; + this.data.isCallEnd = true; this.initTRTC(); + this._removeTRTCEvent(); } // 设置 pusher 属性 @@ -630,7 +689,8 @@ class TRTCCalling { const playerList = this.TRTC.setPlayerAttributes(player.streamID, options); console.warn('setPlayerAttributesHandler', playerList); // this.data.playerList = await this.getUserProfile(playerList) - this.data.playerList = playerList.length > 0 ? this._updateUserProfile(this.data.playerList, playerList) : this.data.playerList; + this.data.playerList = + playerList.length > 0 ? this._updateUserProfile(this.data.playerList, playerList) : this.data.playerList; this.TRTCCallingDelegate.onUserUpdate({ pusher: this.data.pusher, playerList: this.data.playerList }); } @@ -688,16 +748,21 @@ class TRTCCalling { wx.$TSignaling.setLogLevel(0); this.data.config.userID = data.userID; this.data.config.userSig = data.userSig; - return wx.$TSignaling.login({ - userID: data.userID, - userSig: data.userSig, - }).then((res) => { - console.log(TAG_NAME, 'login', 'IM login success', res); - this._reset(); - this._addTSignalingEvent(); - this._addTRTCEvent(); - this.initTRTC(); - }); + return new Promise((resolve, reject) => { + wx.$TSignaling + .login({ + userID: data.userID, + userSig: data.userSig, + }) + .then((res) => { + console.log(TAG_NAME, 'login', 'IM login success', res); + this._reset(); + this._addTSignalingEvent(); + this.initTRTC(); + this.TSignalingResolve = resolve + return null; + }); + }) } /** @@ -712,15 +777,17 @@ class TRTCCalling { } } this._reset(); - wx.$TSignaling.logout({ - userID: this.data.config.userID, - userSig: this.data.config.userSig, - }).then((res) => { - console.log(TAG_NAME, 'logout', 'IM logout success'); - this._removeTSignalingEvent(); - this._removeTRTCEvent(); - return res; - }) + wx.$TSignaling + .logout({ + userID: this.data.config.userID, + userSig: this.data.config.userSig, + }) + .then((res) => { + console.log(TAG_NAME, 'logout', 'IM logout success'); + this._removeTSignalingEvent(); + this._removeTRTCEvent(); + return res; + }) .catch((err) => { console.error(TAG_NAME, 'logout', 'IM logout failure'); throw new Error(err); @@ -756,9 +823,9 @@ class TRTCCalling { */ async call(params) { const { userID, type } = params; - // 生成房间号,拼接URL地址 TRTC-wx roomID 超出取值范围1~4294967295 - const roomID = Math.floor(Math.random() * 4294967294 + 1); // 随机生成房间号 - this.enterRoom({ roomID, callType: type }); + // 生成房间号,拼接URL地址 TRTC-wx roomID 超出取值范围1~2147483647 + const roomID = Math.floor(Math.random() * 2147483646 + 1); // 随机生成房间号 + this.enterRoom({ roomID, callType: type });                                                  try { const res = await this.TSignalingClient.invite({ roomID, ...params }); console.log(`${TAG_NAME} call(userID: ${userID}, type: ${type}) success, ${res}`); @@ -791,8 +858,8 @@ class TRTCCalling { */ async groupCall(params) { const { type } = params; - // 生成房间号,拼接URL地址 TRTC-wx roomID 超出取值范围1~4294967295 - const roomID = this.data.roomID || Math.floor(Math.random() * 4294967294 + 1); // 随机生成房间号 + // 生成房间号,拼接URL地址 TRTC-wx roomID 超出取值范围1~2147483647 + const roomID = this.data.roomID || Math.floor(Math.random() * 2147483646 + 1); // 随机生成房间号 this.enterRoom({ roomID, callType: type }); try { let inviterInviteID = [...this.data.invitation.inviteID]; @@ -836,17 +903,33 @@ class TRTCCalling { * 当您作为被邀请方收到 {@link TRTCCallingDelegate#onInvited } 的回调时,可以调用该函数接听来电 */ async accept() { - // 拼接pusherURL进房 - console.log(TAG_NAME, 'accept() inviteID: ', this.data.invitation.inviteID); - if (this.data.callStatus === CALL_STATUS.IDLE) { - throw new Error('The call was cancelled'); - } - if (this.data.callStatus === CALL_STATUS.CALLING) { - this.enterRoom({ roomID: this.data.invitation.roomID, callType: this.data.config.type }); - // 被邀请人进入通话状态 - this._setCallStatus(CALL_STATUS.CONNECTED); - } + return new Promise((resolve,reject)=> { + // 拼接pusherURL进房 + console.log(TAG_NAME, 'accept() inviteID: ', this.data.invitation.inviteID); + if (this.data.callStatus === CALL_STATUS.IDLE) { + throw new Error('The call was cancelled'); + } + if (this.data.callStatus === CALL_STATUS.CALLING) { + if (this.data.config.type === CALL_TYPE.VIDEO) { + wx.createLivePusherContext().stopPreview({ + success: () => { + const timer = setTimeout(async ()=>{ + clearTimeout(timer); + this.handleAccept(resolve,reject); + }, 0) + } + }); + } else { + this.handleAccept(resolve,reject); + } + } + }) + } + async handleAccept(resolve, reject) { + this.enterRoom({ roomID: this.data.invitation.roomID, callType: this.data.config.type }); + // 被邀请人进入通话状态 + this._setCallStatus(CALL_STATUS.CONNECTED); const acceptRes = await this.TSignalingClient.accept({ inviteID: this.data.invitation.inviteID, type: this.data.config.type, @@ -856,13 +939,13 @@ class TRTCCalling { if (this._getGroupCallFlag()) { this._setUnHandledInviteeList(this._getUserID()); } - return { + return resolve({ message: acceptRes.data.message, pusher: this.data.pusher, - }; + }) } console.error(TAG_NAME, 'accept failed', acceptRes); - return acceptRes; + return reject(acceptRes); } /** @@ -902,9 +985,10 @@ class TRTCCalling { inviteIDList: cancelInvite, callType: this.data.invitation.type, }); - this.TRTCCallingDelegate.onCallEnd({ message: cancelRes[0].data.message }); + this.data.isCallEnd = true; + // this.TRTCCallingDelegate.onCallEnd({ message: cancelRes[0].data.message }); } - this.exitRoom(); + // this.exitRoom(); this._reset(); return cancelRes; } @@ -913,7 +997,7 @@ class TRTCCalling { async lastOneHangup(params) { const isGroup = this._getGroupCallFlag(); const res = await this.TSignalingClient.lastOneHangup({ isGroup, groupID: this.data._groupID, ...params }); - this.TRTCCallingDelegate.onCallEnd({ message: res.data.message }); + // this.TRTCCallingDelegate.onCallEnd({ message: res.data.message }); this._reset(); } @@ -926,7 +1010,7 @@ class TRTCCalling { _setUnHandledInviteeList(userID, callback) { // 使用callback防御列表更新时序问题 const list = [...this.data._unHandledInviteeList]; - const unHandleList = list.filter(item => item !== userID); + const unHandleList = list.filter((item) => item !== userID); this.data._unHandledInviteeList = unHandleList; callback && callback(unHandleList); } @@ -963,10 +1047,13 @@ class TRTCCalling { } // 通话结束,重置数据 - _reset() { - console.log(TAG_NAME, ' _reset()'); + _reset(callEnd) { + console.log(TAG_NAME, ' _reset()', this.data.enterRoomStatus); + if (this.data.enterRoomStatus) { + this.exitRoom(callEnd) + } this._setCallStatus(CALL_STATUS.IDLE); - this.data.config.type = 1; + this.data.config.type = CALL_TYPE.AUDIO; // 清空状态 this.initData(); } @@ -1028,6 +1115,7 @@ class TRTCCalling { if (this.data.callStatus !== CALL_STATUS.CONNECTED) { const targetPos = this.data.pusher.frontCamera === 'front' ? 'back' : 'front'; this.setPusherAttributesHandler({ frontCamera: targetPos }); + wx.createLivePusherContext().switchCamera(); } else { this.TRTC.getPusherInstance().switchCamera(); } @@ -1046,8 +1134,8 @@ class TRTCCalling { } /** - * 视频通话切换语音通话 - */ + * 视频通话切换语音通话 + */ async switchAudioCall() { if (this._isGroupCall) { console.warn(`${TAG_NAME}.switchToAudioCall is not applicable to groupCall.`); @@ -1147,7 +1235,7 @@ class TRTCCalling { } const playerList = newUserList.map((item) => { const newItem = item; - const itemProfile = userList.filter(imItem => imItem.userID === item.userID); + const itemProfile = userList.filter((imItem) => imItem.userID === item.userID); newItem.avatar = itemProfile[0] && itemProfile[0].avatar ? itemProfile[0].avatar : ''; newItem.nick = itemProfile[0] && itemProfile[0].nick ? itemProfile[0].nick : ''; return newItem; @@ -1157,47 +1245,42 @@ class TRTCCalling { // 获取用户信息 _getUserProfile(userList) { const promise = this.tim.getUserProfile({ userIDList: userList }); - promise.then((imResponse) => { - console.log('getUserProfile success', imResponse); - console.log(imResponse.data); - this.data.remoteUsers = imResponse.data; - }).catch((imError) => { - console.warn('getUserProfile error:', imError); // 获取其他用户资料失败的相关信息 - }); + promise + .then((imResponse) => { + console.log('getUserProfile success', imResponse); + console.log(imResponse.data); + this.data.remoteUsers = imResponse.data; + }) + .catch((imError) => { + console.warn('getUserProfile error:', imError); // 获取其他用户资料失败的相关信息 + }); } // 获取用户信息 - async getUserProfile(userList) { + async getUserProfile(userList, type = 'array') { if (userList.length === 0) { return []; } - const list = userList.map(item => item.userID); + const list = userList.map((item) => item.userID); const imResponse = await this.tim.getUserProfile({ userIDList: list }); - const newUserList = userList.map((item) => { - const newItem = item; - const itemProfile = imResponse.data.filter(imItem => imItem.userID === item.userID); - newItem.avatar = itemProfile[0] && itemProfile[0].avatar ? itemProfile[0].avatar : ''; - newItem.nick = itemProfile[0] && itemProfile[0].nick ? itemProfile[0].nick : ''; - return newItem; - }); - return newUserList; - } - - // 呼叫用户图像解析不出来的缺省图设置 - _handleErrorImage() { - const { remoteUsers } = this.data; - remoteUsers[0].avatar = './static/avatar2_100.png'; - this.data.remoteUsers = remoteUsers; - } - - // 通话中图像解析不出来的缺省图设置 - _handleConnectErrorImage(e) { - const data = e.target.dataset.value; - this.data.playerList = this.data.playerList.map((item) => { - if (item.userID === data.userID) { - item.avatar = './static/avatar2_100.png'; - } - return item; - }); + let result = null + switch (type) { + case 'array': + result = userList.map((item, index) => { + item.avatar = imResponse.data[index].avatar + item.nick = imResponse.data[index].nick + return item + }); + break + case 'map': + result = {} + userList.forEach((item, index) => { + item.avatar = imResponse.data[index].avatar + item.nick = imResponse.data[index].nick + result[item.userID] = item + }) + break + } + return result } // pusher 的网络状况 @@ -1214,7 +1297,11 @@ class TRTCCalling { _toggleViewSize(e) { const { screen } = e.currentTarget.dataset; console.log('get screen', screen, e); - if (this.data.playerList.length === 1 && screen !== this.data.screen && this.data.invitation.type === CALL_TYPE.VIDEO) { + if ( + this.data.playerList.length === 1 && + screen !== this.data.screen && + this.data.invitation.type === CALL_TYPE.VIDEO + ) { this.data.screen = screen; } return this.data.screen; @@ -1241,4 +1328,3 @@ class TRTCCalling { } export default TRTCCalling; - diff --git a/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/TRTCCalling/TRTCCallingDelegate.js b/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/TRTCCalling/TRTCCallingDelegate.js index c5330e8b57..0d89092033 100644 --- a/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/TRTCCalling/TRTCCallingDelegate.js +++ b/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/TRTCCalling/TRTCCallingDelegate.js @@ -82,9 +82,10 @@ class TRTCCallingDelegate { } // 抛出用户接听 - onUserAccept(userID) { + onUserAccept(userID, userList) { this._emitter.emit(EVENT.USER_ACCEPT, { userID, + userList, }); } diff --git a/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/TRTCCalling/common/constants.js b/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/TRTCCalling/common/constants.js index 787a491f19..5896f085f5 100644 --- a/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/TRTCCalling/common/constants.js +++ b/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/TRTCCalling/common/constants.js @@ -20,13 +20,13 @@ export const EVENT = { HANG_UP: 'HANG_UP', ERROR: 'ERROR', // 组件内部抛出的错误 -}; +} export const CALL_STATUS = { - IDLE: 'idle', - CALLING: 'calling', - CONNECTED: 'connected', -}; + IDLE: 'idle', // 默认 + CALLING: 'calling', //呼叫中/被呼叫中 + CONNECTED: 'connected', //接通中 +} export const ACTION_TYPE = { INVITE: 1, // 邀请方发起邀请 @@ -34,21 +34,21 @@ export const ACTION_TYPE = { ACCEPT_INVITE: 3, // 被邀请方同意邀请 REJECT_INVITE: 4, // 被邀请方拒绝邀请 INVITE_TIMEOUT: 5, // 被邀请方超时未回复 -}; +} export const BUSINESS_ID = { SIGNAL: 1, // 信令 -}; +} export const CALL_TYPE = { AUDIO: 1, VIDEO: 2, -}; +} -export const CMD_TYPE_LIST = ['', 'audioCall', 'videoCall']; +export const CMD_TYPE_LIST = ['', 'audioCall', 'videoCall'] // audio视频切音频;video:音频切视频 export const MODE_TYPE = { AUDIO: 'audio', VIDEO: 'video', -}; +} diff --git a/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/TRTCCalling/libSrcConfig.js b/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/TRTCCalling/libSrcConfig.js new file mode 100644 index 0000000000..29ff3a1466 --- /dev/null +++ b/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/TRTCCalling/libSrcConfig.js @@ -0,0 +1,10 @@ +import TSignaling from './node_module/tsignaling-wx'; +import TRTC from './node_module/trtc-wx' +import TIM from './node_module/tim-wx-sdk'; + + +export { + TSignaling, + TRTC, + TIM +} \ No newline at end of file diff --git a/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/TRTCCalling/node_module/tim-wx-sdk.js b/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/TRTCCalling/node_module/tim-wx-sdk.js index 7e391bda9d..d11227bd4f 100644 --- a/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/TRTCCalling/node_module/tim-wx-sdk.js +++ b/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/TRTCCalling/node_module/tim-wx-sdk.js @@ -1,4033 +1 @@ -!(function (e, t) { - 'object' === typeof exports && 'undefined' !== typeof module ? module.exports = t() : 'function' === typeof define && define.amd ? define(t) : (e = e || self).TIM = t(); -}(this, (() => { - function e(e, t) { - const n = Object.keys(e);if (Object.getOwnPropertySymbols) { - let o = Object.getOwnPropertySymbols(e);t && (o = o.filter((t => Object.getOwnPropertyDescriptor(e, t).enumerable))), n.push.apply(n, o); - } return n; - } function t(t) { - for (let n = 1;n < arguments.length;n++) { - var o = null != arguments[n] ? arguments[n] : {};n % 2 ? e(Object(o), !0).forEach(((e) => { - r(t, e, o[e]); - })) : Object.getOwnPropertyDescriptors ? Object.defineProperties(t, Object.getOwnPropertyDescriptors(o)) : e(Object(o)).forEach(((e) => { - Object.defineProperty(t, e, Object.getOwnPropertyDescriptor(o, e)); - })); - } return t; - } function n(e) { - return (n = 'function' === typeof Symbol && 'symbol' === typeof Symbol.iterator ? function (e) { - return typeof e; - } : function (e) { - return e && 'function' === typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? 'symbol' : typeof e; - })(e); - } function o(e, t) { - if (!(e instanceof t)) throw new TypeError('Cannot call a class as a function'); - } function a(e, t) { - for (let n = 0;n < t.length;n++) { - const o = t[n];o.enumerable = o.enumerable || !1, o.configurable = !0, 'value' in o && (o.writable = !0), Object.defineProperty(e, o.key, o); - } - } function s(e, t, n) { - return t && a(e.prototype, t), n && a(e, n), e; - } function r(e, t, n) { - return t in e ? Object.defineProperty(e, t, { value: n, enumerable: !0, configurable: !0, writable: !0 }) : e[t] = n, e; - } function i(e, t) { - if ('function' !== typeof t && null !== t) throw new TypeError('Super expression must either be null or a function');e.prototype = Object.create(t && t.prototype, { constructor: { value: e, writable: !0, configurable: !0 } }), t && u(e, t); - } function c(e) { - return (c = Object.setPrototypeOf ? Object.getPrototypeOf : function (e) { - return e.__proto__ || Object.getPrototypeOf(e); - })(e); - } function u(e, t) { - return (u = Object.setPrototypeOf || function (e, t) { - return e.__proto__ = t, e; - })(e, t); - } function l() { - if ('undefined' === typeof Reflect || !Reflect.construct) return !1;if (Reflect.construct.sham) return !1;if ('function' === typeof Proxy) return !0;try { - return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], (() => {}))), !0; - } catch (e) { - return !1; - } - } function d(e, t, n) { - return (d = l() ? Reflect.construct : function (e, t, n) { - const o = [null];o.push.apply(o, t);const a = new (Function.bind.apply(e, o));return n && u(a, n.prototype), a; - }).apply(null, arguments); - } function g(e) { - const t = 'function' === typeof Map ? new Map : void 0;return (g = function (e) { - if (null === e || (n = e, -1 === Function.toString.call(n).indexOf('[native code]'))) return e;let n;if ('function' !== typeof e) throw new TypeError('Super expression must either be null or a function');if (void 0 !== t) { - if (t.has(e)) return t.get(e);t.set(e, o); - } function o() { - return d(e, arguments, c(this).constructor); - } return o.prototype = Object.create(e.prototype, { constructor: { value: o, enumerable: !1, writable: !0, configurable: !0 } }), u(o, e); - })(e); - } function p(e, t) { - if (null == e) return {};let n; let o; const a = (function (e, t) { - if (null == e) return {};let n; let o; const a = {}; const s = Object.keys(e);for (o = 0;o < s.length;o++)n = s[o], t.indexOf(n) >= 0 || (a[n] = e[n]);return a; - }(e, t));if (Object.getOwnPropertySymbols) { - const s = Object.getOwnPropertySymbols(e);for (o = 0;o < s.length;o++)n = s[o], t.indexOf(n) >= 0 || Object.prototype.propertyIsEnumerable.call(e, n) && (a[n] = e[n]); - } return a; - } function h(e) { - if (void 0 === e) throw new ReferenceError('this hasn\'t been initialised - super() hasn\'t been called');return e; - } function _(e, t) { - return !t || 'object' !== typeof t && 'function' !== typeof t ? h(e) : t; - } function f(e) { - const t = l();return function () { - let n; const o = c(e);if (t) { - const a = c(this).constructor;n = Reflect.construct(o, arguments, a); - } else n = o.apply(this, arguments);return _(this, n); - }; - } function m(e, t) { - return v(e) || (function (e, t) { - let n = null == e ? null : 'undefined' !== typeof Symbol && e[Symbol.iterator] || e['@@iterator'];if (null == n) return;let o; let a; const s = []; let r = !0; let i = !1;try { - for (n = n.call(e);!(r = (o = n.next()).done) && (s.push(o.value), !t || s.length !== t);r = !0); - } catch (c) { - i = !0, a = c; - } finally { - try { - r || null == n.return || n.return(); - } finally { - if (i) throw a; - } - } return s; - }(e, t)) || I(e, t) || T(); - } function M(e) { - return (function (e) { - if (Array.isArray(e)) return D(e); - }(e)) || y(e) || I(e) || (function () { - throw new TypeError('Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.'); - }()); - } function v(e) { - if (Array.isArray(e)) return e; - } function y(e) { - if ('undefined' !== typeof Symbol && null != e[Symbol.iterator] || null != e['@@iterator']) return Array.from(e); - } function I(e, t) { - if (e) { - if ('string' === typeof e) return D(e, t);let n = Object.prototype.toString.call(e).slice(8, -1);return 'Object' === n && e.constructor && (n = e.constructor.name), 'Map' === n || 'Set' === n ? Array.from(e) : 'Arguments' === n || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n) ? D(e, t) : void 0; - } - } function D(e, t) { - (null == t || t > e.length) && (t = e.length);for (var n = 0, o = new Array(t);n < t;n++)o[n] = e[n];return o; - } function T() { - throw new TypeError('Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.'); - } function S(e, t) { - let n = 'undefined' !== typeof Symbol && e[Symbol.iterator] || e['@@iterator'];if (!n) { - if (Array.isArray(e) || (n = I(e)) || t && e && 'number' === typeof e.length) { - n && (e = n);let o = 0; const a = function () {};return { s: a, n() { - return o >= e.length ? { done: !0 } : { done: !1, value: e[o++] }; - }, e(e) { - throw e; - }, f: a }; - } throw new TypeError('Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.'); - } let s; let r = !0; let i = !1;return { s() { - n = n.call(e); - }, n() { - const e = n.next();return r = e.done, e; - }, e(e) { - i = !0, s = e; - }, f() { - try { - r || null == n.return || n.return(); - } finally { - if (i) throw s; - } - } }; - } const E = { SDK_READY: 'sdkStateReady', SDK_NOT_READY: 'sdkStateNotReady', SDK_DESTROY: 'sdkDestroy', MESSAGE_RECEIVED: 'onMessageReceived', MESSAGE_MODIFIED: 'onMessageModified', MESSAGE_REVOKED: 'onMessageRevoked', MESSAGE_READ_BY_PEER: 'onMessageReadByPeer', CONVERSATION_LIST_UPDATED: 'onConversationListUpdated', GROUP_LIST_UPDATED: 'onGroupListUpdated', GROUP_SYSTEM_NOTICE_RECEIVED: 'receiveGroupSystemNotice', PROFILE_UPDATED: 'onProfileUpdated', BLACKLIST_UPDATED: 'blacklistUpdated', FRIEND_LIST_UPDATED: 'onFriendListUpdated', FRIEND_GROUP_LIST_UPDATED: 'onFriendGroupListUpdated', FRIEND_APPLICATION_LIST_UPDATED: 'onFriendApplicationListUpdated', KICKED_OUT: 'kickedOut', ERROR: 'error', NET_STATE_CHANGE: 'netStateChange', SDK_RELOAD: 'sdkReload' }; const k = { MSG_TEXT: 'TIMTextElem', MSG_IMAGE: 'TIMImageElem', MSG_SOUND: 'TIMSoundElem', MSG_AUDIO: 'TIMSoundElem', MSG_FILE: 'TIMFileElem', MSG_FACE: 'TIMFaceElem', MSG_VIDEO: 'TIMVideoFileElem', MSG_GEO: 'TIMLocationElem', MSG_GRP_TIP: 'TIMGroupTipElem', MSG_GRP_SYS_NOTICE: 'TIMGroupSystemNoticeElem', MSG_CUSTOM: 'TIMCustomElem', MSG_MERGER: 'TIMRelayElem', MSG_PRIORITY_HIGH: 'High', MSG_PRIORITY_NORMAL: 'Normal', MSG_PRIORITY_LOW: 'Low', MSG_PRIORITY_LOWEST: 'Lowest', CONV_C2C: 'C2C', CONV_GROUP: 'GROUP', CONV_SYSTEM: '@TIM#SYSTEM', CONV_AT_ME: 1, CONV_AT_ALL: 2, CONV_AT_ALL_AT_ME: 3, GRP_PRIVATE: 'Private', GRP_WORK: 'Private', GRP_PUBLIC: 'Public', GRP_CHATROOM: 'ChatRoom', GRP_MEETING: 'ChatRoom', GRP_AVCHATROOM: 'AVChatRoom', GRP_MBR_ROLE_OWNER: 'Owner', GRP_MBR_ROLE_ADMIN: 'Admin', GRP_MBR_ROLE_MEMBER: 'Member', GRP_TIP_MBR_JOIN: 1, GRP_TIP_MBR_QUIT: 2, GRP_TIP_MBR_KICKED_OUT: 3, GRP_TIP_MBR_SET_ADMIN: 4, GRP_TIP_MBR_CANCELED_ADMIN: 5, GRP_TIP_GRP_PROFILE_UPDATED: 6, GRP_TIP_MBR_PROFILE_UPDATED: 7, MSG_REMIND_ACPT_AND_NOTE: 'AcceptAndNotify', MSG_REMIND_ACPT_NOT_NOTE: 'AcceptNotNotify', MSG_REMIND_DISCARD: 'Discard', GENDER_UNKNOWN: 'Gender_Type_Unknown', GENDER_FEMALE: 'Gender_Type_Female', GENDER_MALE: 'Gender_Type_Male', KICKED_OUT_MULT_ACCOUNT: 'multipleAccount', KICKED_OUT_MULT_DEVICE: 'multipleDevice', KICKED_OUT_USERSIG_EXPIRED: 'userSigExpired', ALLOW_TYPE_ALLOW_ANY: 'AllowType_Type_AllowAny', ALLOW_TYPE_NEED_CONFIRM: 'AllowType_Type_NeedConfirm', ALLOW_TYPE_DENY_ANY: 'AllowType_Type_DenyAny', FORBID_TYPE_NONE: 'AdminForbid_Type_None', FORBID_TYPE_SEND_OUT: 'AdminForbid_Type_SendOut', JOIN_OPTIONS_FREE_ACCESS: 'FreeAccess', JOIN_OPTIONS_NEED_PERMISSION: 'NeedPermission', JOIN_OPTIONS_DISABLE_APPLY: 'DisableApply', JOIN_STATUS_SUCCESS: 'JoinedSuccess', JOIN_STATUS_ALREADY_IN_GROUP: 'AlreadyInGroup', JOIN_STATUS_WAIT_APPROVAL: 'WaitAdminApproval', GRP_PROFILE_OWNER_ID: 'ownerID', GRP_PROFILE_CREATE_TIME: 'createTime', GRP_PROFILE_LAST_INFO_TIME: 'lastInfoTime', GRP_PROFILE_MEMBER_NUM: 'memberNum', GRP_PROFILE_MAX_MEMBER_NUM: 'maxMemberNum', GRP_PROFILE_JOIN_OPTION: 'joinOption', GRP_PROFILE_INTRODUCTION: 'introduction', GRP_PROFILE_NOTIFICATION: 'notification', GRP_PROFILE_MUTE_ALL_MBRS: 'muteAllMembers', SNS_ADD_TYPE_SINGLE: 'Add_Type_Single', SNS_ADD_TYPE_BOTH: 'Add_Type_Both', SNS_DELETE_TYPE_SINGLE: 'Delete_Type_Single', SNS_DELETE_TYPE_BOTH: 'Delete_Type_Both', SNS_APPLICATION_TYPE_BOTH: 'Pendency_Type_Both', SNS_APPLICATION_SENT_TO_ME: 'Pendency_Type_ComeIn', SNS_APPLICATION_SENT_BY_ME: 'Pendency_Type_SendOut', SNS_APPLICATION_AGREE: 'Response_Action_Agree', SNS_APPLICATION_AGREE_AND_ADD: 'Response_Action_AgreeAndAdd', SNS_CHECK_TYPE_BOTH: 'CheckResult_Type_Both', SNS_CHECK_TYPE_SINGLE: 'CheckResult_Type_Single', SNS_TYPE_NO_RELATION: 'CheckResult_Type_NoRelation', SNS_TYPE_A_WITH_B: 'CheckResult_Type_AWithB', SNS_TYPE_B_WITH_A: 'CheckResult_Type_BWithA', SNS_TYPE_BOTH_WAY: 'CheckResult_Type_BothWay', NET_STATE_CONNECTED: 'connected', NET_STATE_CONNECTING: 'connecting', NET_STATE_DISCONNECTED: 'disconnected', MSG_AT_ALL: '__kImSDK_MesssageAtALL__' }; const C = (function () { - function e() { - o(this, e), this.cache = [], this.options = null; - } return s(e, [{ key: 'use', value(e) { - if ('function' !== typeof e) throw 'middleware must be a function';return this.cache.push(e), this; - } }, { key: 'next', value(e) { - if (this.middlewares && this.middlewares.length > 0) return this.middlewares.shift().call(this, this.options, this.next.bind(this)); - } }, { key: 'run', value(e) { - return this.middlewares = this.cache.map((e => e)), this.options = e, this.next(); - } }]), e; - }()); const N = 'undefined' !== typeof globalThis ? globalThis : 'undefined' !== typeof window ? window : 'undefined' !== typeof global ? global : 'undefined' !== typeof self ? self : {};function A(e, t) { - return e(t = { exports: {} }, t.exports), t.exports; - } const O = A(((e, t) => { - let n; let o; let a; let s; let r; let i; let c; let u; let l; let d; let g; let p; let h; let _; let f; let m; let M; let v;e.exports = (n = 'function' === typeof Promise, o = 'object' === typeof self ? self : N, a = 'undefined' !== typeof Symbol, s = 'undefined' !== typeof Map, r = 'undefined' !== typeof Set, i = 'undefined' !== typeof WeakMap, c = 'undefined' !== typeof WeakSet, u = 'undefined' !== typeof DataView, l = a && void 0 !== Symbol.iterator, d = a && void 0 !== Symbol.toStringTag, g = r && 'function' === typeof Set.prototype.entries, p = s && 'function' === typeof Map.prototype.entries, h = g && Object.getPrototypeOf((new Set).entries()), _ = p && Object.getPrototypeOf((new Map).entries()), f = l && 'function' === typeof Array.prototype[Symbol.iterator], m = f && Object.getPrototypeOf([][Symbol.iterator]()), M = l && 'function' === typeof String.prototype[Symbol.iterator], v = M && Object.getPrototypeOf(''[Symbol.iterator]()), function (e) { - const t = typeof e;if ('object' !== t) return t;if (null === e) return 'null';if (e === o) return 'global';if (Array.isArray(e) && (!1 === d || !(Symbol.toStringTag in e))) return 'Array';if ('object' === typeof window && null !== window) { - if ('object' === typeof window.location && e === window.location) return 'Location';if ('object' === typeof window.document && e === window.document) return 'Document';if ('object' === typeof window.navigator) { - if ('object' === typeof window.navigator.mimeTypes && e === window.navigator.mimeTypes) return 'MimeTypeArray';if ('object' === typeof window.navigator.plugins && e === window.navigator.plugins) return 'PluginArray'; - } if (('function' === typeof window.HTMLElement || 'object' === typeof window.HTMLElement) && e instanceof window.HTMLElement) { - if ('BLOCKQUOTE' === e.tagName) return 'HTMLQuoteElement';if ('TD' === e.tagName) return 'HTMLTableDataCellElement';if ('TH' === e.tagName) return 'HTMLTableHeaderCellElement'; - } - } const a = d && e[Symbol.toStringTag];if ('string' === typeof a) return a;const l = Object.getPrototypeOf(e);return l === RegExp.prototype ? 'RegExp' : l === Date.prototype ? 'Date' : n && l === Promise.prototype ? 'Promise' : r && l === Set.prototype ? 'Set' : s && l === Map.prototype ? 'Map' : c && l === WeakSet.prototype ? 'WeakSet' : i && l === WeakMap.prototype ? 'WeakMap' : u && l === DataView.prototype ? 'DataView' : s && l === _ ? 'Map Iterator' : r && l === h ? 'Set Iterator' : f && l === m ? 'Array Iterator' : M && l === v ? 'String Iterator' : null === l ? 'Object' : Object.prototype.toString.call(e).slice(8, -1); - }); - })); const L = { WEB: 7, WX_MP: 8, QQ_MP: 9, TT_MP: 10, BAIDU_MP: 11, ALI_MP: 12, UNI_NATIVE_APP: 14 }; const R = '1.7.3'; const G = 537048168; const w = 1; const P = 2; const b = 3; const U = { HOST: { CURRENT: { DEFAULT: '', BACKUP: '' }, TEST: { DEFAULT: 'wss://wss-dev.tim.qq.com', BACKUP: 'wss://wss-dev.tim.qq.com' }, PRODUCTION: { DEFAULT: 'wss://wss.im.qcloud.com', BACKUP: 'wss://wss.tim.qq.com' }, OVERSEA_PRODUCTION: { DEFAULT: 'wss://wss.im.qcloud.com', BACKUP: 'wss://wss.im.qcloud.com' }, setCurrent() { - const e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : 2;e === w ? this.CURRENT = this.TEST : e === P ? this.CURRENT = this.PRODUCTION : e === b && (this.CURRENT = this.OVERSEA_PRODUCTION); - } }, NAME: { OPEN_IM: 'openim', GROUP: 'group_open_http_svc', FRIEND: 'sns', PROFILE: 'profile', RECENT_CONTACT: 'recentcontact', PIC: 'openpic', BIG_GROUP_NO_AUTH: 'group_open_http_noauth_svc', BIG_GROUP_LONG_POLLING: 'group_open_long_polling_http_svc', BIG_GROUP_LONG_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_MESSAGE: 'im_long_msg', CLOUD_CONTROL: 'im_sdk_config_mgr' }, CMD: { ACCESS_LAYER: 'accesslayer', LOGIN: 'wslogin', LOGOUT_LONG_POLL: 'longpollinglogout', LOGOUT: 'wslogout', HELLO: 'wshello', PORTRAIT_GET: 'portrait_get_all', PORTRAIT_SET: 'portrait_set', GET_LONG_POLL_ID: 'getlongpollingid', LONG_POLL: 'longpolling', AVCHATROOM_LONG_POLL: 'get_msg', ADD_FRIEND: 'friend_add', UPDATE_FRIEND: 'friend_update', GET_FRIEND_LIST: 'friend_get', GET_FRIEND_PROFILE: 'friend_get_list', DELETE_FRIEND: 'friend_delete', CHECK_FRIEND: 'friend_check', GET_FRIEND_GROUP_LIST: 'group_get', RESPOND_FRIEND_APPLICATION: 'friend_response', GET_FRIEND_APPLICATION_LIST: 'pendency_get', DELETE_FRIEND_APPLICATION: 'pendency_delete', REPORT_FRIEND_APPLICATION: 'pendency_report', GET_GROUP_APPLICATION: 'get_pendency', CREATE_FRIEND_GROUP: 'group_add', DELETE_FRIEND_GROUP: 'group_delete', UPDATE_FRIEND_GROUP: 'group_update', GET_BLACKLIST: 'black_list_get', ADD_BLACKLIST: 'black_list_add', DELETE_BLACKLIST: 'black_list_delete', CREATE_GROUP: 'create_group', GET_JOINED_GROUPS: 'get_joined_group_list', SEND_MESSAGE: 'sendmsg', REVOKE_C2C_MESSAGE: 'msgwithdraw', DELETE_C2C_MESSAGE: 'delete_c2c_msg_ramble', SEND_GROUP_MESSAGE: 'send_group_msg', REVOKE_GROUP_MESSAGE: 'group_msg_recall', DELETE_GROUP_MESSAGE: 'delete_group_ramble_msg_by_seq', GET_GROUP_INFO: 'get_group_info', GET_GROUP_MEMBER_INFO: 'get_specified_group_member_info', GET_GROUP_MEMBER_LIST: 'get_group_member_info', QUIT_GROUP: 'quit_group', CHANGE_GROUP_OWNER: 'change_group_owner', DESTROY_GROUP: 'destroy_group', ADD_GROUP_MEMBER: 'add_group_member', DELETE_GROUP_MEMBER: 'delete_group_member', SEARCH_GROUP_BY_ID: 'get_group_public_info', APPLY_JOIN_GROUP: 'apply_join_group', HANDLE_APPLY_JOIN_GROUP: 'handle_apply_join_group', HANDLE_GROUP_INVITATION: 'handle_invite_join_group', MODIFY_GROUP_INFO: 'modify_group_base_info', MODIFY_GROUP_MEMBER_INFO: 'modify_group_member_info', DELETE_GROUP_SYSTEM_MESSAGE: 'deletemsg', DELETE_GROUP_AT_TIPS: 'deletemsg', GET_CONVERSATION_LIST: 'get', PAGING_GET_CONVERSATION_LIST: 'page_get', DELETE_CONVERSATION: 'delete', GET_MESSAGES: 'getmsg', GET_C2C_ROAM_MESSAGES: 'getroammsg', GET_GROUP_ROAM_MESSAGES: 'group_msg_get', SET_C2C_MESSAGE_READ: 'msgreaded', GET_PEER_READ_TIME: 'get_peer_read_time', SET_GROUP_MESSAGE_READ: 'msg_read_report', FILE_READ_AND_WRITE_AUTHKEY: 'authkey', FILE_UPLOAD: 'pic_up', COS_SIGN: 'cos', COS_PRE_SIG: 'pre_sig', TIM_WEB_REPORT_V2: 'tim_web_report_v2', BIG_DATA_HALLWAY_AUTH_KEY: 'authkey', GET_ONLINE_MEMBER_NUM: 'get_online_member_num', ALIVE: 'alive', MESSAGE_PUSH: 'msg_push', MESSAGE_PUSH_ACK: 'ws_msg_push_ack', STATUS_FORCEOFFLINE: 'stat_forceoffline', DOWNLOAD_MERGER_MESSAGE: 'get_relay_json_msg', UPLOAD_MERGER_MESSAGE: 'save_relay_json_msg', FETCH_CLOUD_CONTROL_CONFIG: 'fetch_config', PUSHED_CLOUD_CONTROL_CONFIG: 'push_configv2' }, CHANNEL: { SOCKET: 1, XHR: 2, AUTO: 0 }, NAME_VERSION: { openim: 'v4', group_open_http_svc: 'v4', sns: 'v4', profile: 'v4', recentcontact: 'v4', openpic: 'v4', group_open_http_noauth_svc: 'v4', group_open_long_polling_http_svc: 'v4', group_open_long_polling_http_noauth_svc: 'v4', imopenstat: 'v4', im_cos_sign_svr: 'v4', im_cos_msg: 'v4', webim: 'v4', im_open_push: 'v4', im_open_status: 'v4' } };U.HOST.setCurrent(P);let F; let q; let V; let K; const x = 'undefined' !== typeof wx && 'function' === typeof wx.getSystemInfoSync && Boolean(wx.getSystemInfoSync().fontSizeSetting); const B = 'undefined' !== typeof qq && 'function' === typeof qq.getSystemInfoSync && Boolean(qq.getSystemInfoSync().fontSizeSetting); const H = 'undefined' !== typeof tt && 'function' === typeof tt.getSystemInfoSync && Boolean(tt.getSystemInfoSync().fontSizeSetting); const j = 'undefined' !== typeof swan && 'function' === typeof swan.getSystemInfoSync && Boolean(swan.getSystemInfoSync().fontSizeSetting); const $ = 'undefined' !== typeof my && 'function' === typeof my.getSystemInfoSync && Boolean(my.getSystemInfoSync().fontSizeSetting); const Y = 'undefined' !== typeof uni && 'undefined' === typeof window; const z = x || B || H || j || $ || Y; const W = ('undefined' !== typeof uni || 'undefined' !== typeof window) && !z; const J = B ? qq : H ? tt : j ? swan : $ ? my : x ? wx : Y ? uni : {}; const X = (F = 'WEB', de ? F = 'WEB' : B ? F = 'QQ_MP' : H ? F = 'TT_MP' : j ? F = 'BAIDU_MP' : $ ? F = 'ALI_MP' : x ? F = 'WX_MP' : Y && (F = 'UNI_NATIVE_APP'), L[F]); const Q = W && window && window.navigator && window.navigator.userAgent || ''; const Z = /AppleWebKit\/([\d.]+)/i.exec(Q); const ee = (Z && parseFloat(Z.pop()), /iPad/i.test(Q)); const te = /iPhone/i.test(Q) && !ee; const ne = /iPod/i.test(Q); const oe = te || ee || ne; const ae = ((q = Q.match(/OS (\d+)_/i)) && q[1] && q[1], /Android/i.test(Q)); const se = (function () { - const e = Q.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);if (!e) return null;const t = e[1] && parseFloat(e[1]); const n = e[2] && parseFloat(e[2]);return t && n ? parseFloat(`${e[1]}.${e[2]}`) : t || null; - }()); const re = (ae && /webkit/i.test(Q), /Firefox/i.test(Q), /Edge/i.test(Q)); const ie = !re && /Chrome/i.test(Q); const ce = ((function () { - const e = Q.match(/Chrome\/(\d+)/);e && e[1] && parseFloat(e[1]); - }()), /MSIE/.test(Q)); const ue = (/MSIE\s8\.0/.test(Q), (function () { - const e = /MSIE\s(\d+)\.\d/.exec(Q); let t = e && parseFloat(e[1]);return !t && /Trident\/7.0/i.test(Q) && /rv:11.0/.test(Q) && (t = 11), t; - }())); const le = (/Safari/i.test(Q), /TBS\/\d+/i.test(Q)); var de = ((function () { - const e = Q.match(/TBS\/(\d+)/i);if (e && e[1])e[1]; - }()), !le && /MQQBrowser\/\d+/i.test(Q), !le && / QQBrowser\/\d+/i.test(Q), /(micromessenger|webbrowser)/i.test(Q)); const ge = /Windows/i.test(Q); const pe = /MAC OS X/i.test(Q); const he = (/MicroMessenger/i.test(Q), 'undefined' !== typeof global ? global : 'undefined' !== typeof self ? self : 'undefined' !== typeof window ? window : {});V = 'undefined' !== typeof console ? console : void 0 !== he && he.console ? he.console : 'undefined' !== typeof window && window.console ? window.console : {};for (var _e = function () {}, fe = ['assert', 'clear', 'count', 'debug', 'dir', 'dirxml', 'error', 'exception', 'group', 'groupCollapsed', 'groupEnd', 'info', 'log', 'markTimeline', 'profile', 'profileEnd', 'table', 'time', 'timeEnd', 'timeStamp', 'trace', 'warn'], me = fe.length;me--;)K = fe[me], console[K] || (V[K] = _e);V.methods = fe;const Me = V; let ve = 0; const ye = function () { - return (new Date).getTime() + ve; - }; const Ie = function () { - ve = 0; - }; let De = 0; const Te = new Map;function Se() { - let e; const t = ((e = new Date).setTime(ye()), e);return `TIM ${t.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; - }(t.getMilliseconds()))}:`; - } const Ee = { arguments2String(e) { - let t;if (1 === e.length)t = Se() + e[0];else { - t = Se();for (let n = 0, o = e.length;n < o;n++)we(e[n]) ? be(e[n]) ? t += xe(e[n]) : t += JSON.stringify(e[n]) : t += e[n], t += ' '; - } return t; - }, debug() { - if (De <= -1) { - const e = this.arguments2String(arguments);Me.debug(e); - } - }, log() { - if (De <= 0) { - const e = this.arguments2String(arguments);Me.log(e); - } - }, info() { - if (De <= 1) { - const e = this.arguments2String(arguments);Me.info(e); - } - }, warn() { - if (De <= 2) { - const e = this.arguments2String(arguments);Me.warn(e); - } - }, error() { - if (De <= 3) { - const e = this.arguments2String(arguments);Me.error(e); - } - }, time(e) { - Te.set(e, Ve.now()); - }, timeEnd(e) { - if (Te.has(e)) { - const t = Ve.now() - Te.get(e);return Te.delete(e), t; - } return Me.warn('未找到对应label: '.concat(e, ', 请在调用 logger.timeEnd 前,调用 logger.time')), 0; - }, setLevel(e) { - e < 4 && Me.log(`${Se()}set level from ${De} to ${e}`), De = e; - }, getLevel() { - return De; - } }; const ke = ['url']; const Ce = function (e) { - return 'file' === Ue(e); - }; const Ne = function (e) { - return null !== e && ('number' === typeof e && !isNaN(e - 0) || 'object' === n(e) && e.constructor === Number); - }; const Ae = function (e) { - return 'string' === typeof e; - }; const Oe = function (e) { - return null !== e && 'object' === n(e); - }; const Le = function (e) { - if ('object' !== n(e) || null === e) return !1;const t = Object.getPrototypeOf(e);if (null === t) return !0;for (var o = t;null !== Object.getPrototypeOf(o);)o = Object.getPrototypeOf(o);return t === o; - }; const Re = function (e) { - return 'function' === typeof Array.isArray ? Array.isArray(e) : 'array' === Ue(e); - }; const Ge = function (e) { - return void 0 === e; - }; var we = function (e) { - return Re(e) || Oe(e); - }; const Pe = function (e) { - return 'function' === typeof e; - }; var be = function (e) { - return e instanceof Error; - }; var Ue = function (e) { - return Object.prototype.toString.call(e).match(/^\[object (.*)\]$/)[1].toLowerCase(); - }; const Fe = function (e) { - if ('string' !== typeof e) return !1;const t = e[0];return !/[^a-zA-Z0-9]/.test(t); - }; let qe = 0;Date.now || (Date.now = function () { - return (new Date).getTime(); - });var Ve = { now() { - 0 === qe && (qe = Date.now() - 1);const e = Date.now() - qe;return e > 4294967295 ? (qe += 4294967295, Date.now() - qe) : e; - }, utc() { - return Math.round(Date.now() / 1e3); - } }; const Ke = function e(t, n, o, a) { - if (!we(t) || !we(n)) return 0;for (var s, r = 0, i = Object.keys(n), c = 0, u = i.length;c < u;c++) if (s = i[c], !(Ge(n[s]) || o && o.includes(s))) if (we(t[s]) && we(n[s]))r += e(t[s], n[s], o, a);else { - if (a && a.includes(n[s])) continue;t[s] !== n[s] && (t[s] = n[s], r += 1); - } return r; - }; var xe = function (e) { - return JSON.stringify(e, ['message', 'code']); - }; const Be = function (e) { - if (0 === e.length) return 0;for (var t = 0, n = 0, o = 'undefined' !== typeof document && void 0 !== document.characterSet ? document.characterSet : 'UTF-8';void 0 !== e[t];)n += e[t++].charCodeAt[t] <= 255 ? 1 : !1 === o ? 3 : 2;return n; - }; const He = function (e) { - const t = e || 99999999;return Math.round(Math.random() * t); - }; const je = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; const $e = je.length; const Ye = function (e, t) { - for (const n in e) if (e[n] === t) return !0;return !1; - }; const ze = {}; const We = function () { - if (z) return 'https:';if (W && 'undefined' === typeof window) return 'https:';let e = window.location.protocol;return ['http:', 'https:'].indexOf(e) < 0 && (e = 'http:'), e; - }; const Je = function (e) { - return -1 === e.indexOf('http://') || -1 === e.indexOf('https://') ? `https://${e}` : e.replace(/https|http/, 'https'); - }; const Xe = function e(t) { - if (0 === Object.getOwnPropertyNames(t).length) return Object.create(null);const o = Array.isArray(t) ? [] : Object.create(null); let a = '';for (const s in t)null !== t[s] ? void 0 !== t[s] ? (a = n(t[s]), ['string', 'number', 'function', 'boolean'].indexOf(a) >= 0 ? o[s] = t[s] : o[s] = e(t[s])) : o[s] = void 0 : o[s] = null;return o; - };function Qe(e, t) { - Re(e) && Re(t) ? t.forEach(((t) => { - const n = t.key; const o = t.value; const a = e.find((e => e.key === n));a ? a.value = o : e.push({ key: n, value: o }); - })) : Ee.warn('updateCustomField target 或 source 不是数组,忽略此次更新。'); - } const Ze = function (e) { - return e === k.GRP_PUBLIC; - }; const et = function (e) { - return e === k.GRP_AVCHATROOM; - }; const nt = function (e) { - return Ae(e) && e === k.CONV_SYSTEM; - };function ot(e, t) { - const n = {};return Object.keys(e).forEach(((o) => { - n[o] = t(e[o], o); - })), n; - } function at() { - function e() { - return (65536 * (1 + Math.random()) | 0).toString(16).substring(1); - } return ''.concat(e() + e()).concat(e()) - .concat(e()) - .concat(e()) - .concat(e()) - .concat(e()) - .concat(e()); - } function st() { - let e = 'unknown';if (pe && (e = 'mac'), ge && (e = 'windows'), oe && (e = 'ios'), ae && (e = 'android'), z) try { - const t = J.getSystemInfoSync().platform;void 0 !== t && (e = t); - } catch (n) {} return e; - } function rt(e) { - const t = e.originUrl; const n = void 0 === t ? void 0 : t; const o = e.originWidth; const a = e.originHeight; const s = e.min; const r = void 0 === s ? 198 : s; const i = parseInt(o); const c = parseInt(a); const u = { url: void 0, width: 0, height: 0 };return (i <= c ? i : c) <= r ? (u.url = n, u.width = i, u.height = c) : (c <= i ? (u.width = Math.ceil(i * r / c), u.height = r) : (u.width = r, u.height = Math.ceil(c * r / i)), u.url = ''.concat(n, 198 === r ? '?imageView2/3/w/198/h/198' : '?imageView2/3/w/720/h/720')), Ge(n) ? p(u, ke) : u; - } function it(e) { - const t = e[2];e[2] = e[1], e[1] = t;for (let n = 0;n < e.length;n++)e[n].setType(n); - } function ct(e) { - const t = e.servcmd;return t.slice(t.indexOf('.') + 1); - } function ut(e, t) { - return Math.round(Number(e) * Math.pow(10, t)) / Math.pow(10, t); - } const lt = Object.prototype.hasOwnProperty;function dt(e) { - if (null == e) return !0;if ('boolean' === typeof e) return !1;if ('number' === typeof e) return 0 === e;if ('string' === typeof e) return 0 === e.length;if ('function' === typeof e) return 0 === e.length;if (Array.isArray(e)) return 0 === e.length;if (e instanceof Error) return '' === e.message;if (Le(e)) { - for (const t in e) if (lt.call(e, t)) return !1;return !0; - } return !('map' !== Ue(e) && !(function (e) { - return 'set' === Ue(e); - }(e)) && !Ce(e)) && 0 === e.size; - } function gt(e, t, n) { - if (void 0 === t) return !0;let o = !0;if ('object' === O(t).toLowerCase())Object.keys(t).forEach(((a) => { - const s = 1 === e.length ? e[0][a] : void 0;o = !!pt(s, t[a], n, a) && o; - }));else if ('array' === O(t).toLowerCase()) for (let a = 0;a < t.length;a++)o = !!pt(e[a], t[a], n, t[a].name) && o;if (o) return o;throw new Error('Params validate failed.'); - } function pt(e, t, n, o) { - if (void 0 === t) return !0;let a = !0;return t.required && dt(e) && (Me.error('TIM ['.concat(n, '] Missing required params: "').concat(o, '".')), a = !1), dt(e) || O(e).toLowerCase() === t.type.toLowerCase() || (Me.error('TIM ['.concat(n, '] Invalid params: type check failed for "').concat(o, '".Expected ') - .concat(t.type, '.')), a = !1), t.validator && !t.validator(e) && (Me.error('TIM ['.concat(n, '] Invalid params: custom validator check failed for params.')), a = !1), a; - } let ht; const _t = { UNSEND: 'unSend', SUCCESS: 'success', FAIL: 'fail' }; const ft = { NOT_START: 'notStart', PENDING: 'pengding', RESOLVED: 'resolved', REJECTED: 'rejected' }; const mt = function (e) { - return !!e && (!!((function (e) { - return Ae(e) && e.slice(0, 3) === k.CONV_C2C; - }(e)) || (function (e) { - return Ae(e) && e.slice(0, 5) === k.CONV_GROUP; - }(e)) || nt(e)) || (console.warn('非法的会话 ID:'.concat(e, '。会话 ID 组成方式:C2C + userID(单聊)GROUP + groupID(群聊)@TIM#SYSTEM(系统通知会话)')), !1)); - }; const Mt = '请参考 https://web.sdk.qcloud.com/im/doc/zh-cn/SDK.html#'; const vt = function (e) { - return e.param ? ''.concat(e.api, ' ').concat(e.param, ' ') - .concat(e.desc, '。') - .concat(Mt) - .concat(e.api) : ''.concat(e.api, ' ').concat(e.desc, '。') - .concat(Mt) - .concat(e.api); - }; const yt = { type: 'String', required: !0 }; const It = { type: 'Array', required: !0 }; const Dt = { type: 'Object', required: !0 }; const Tt = { login: { userID: yt, userSig: yt }, addToBlacklist: { userIDList: It }, on: [{ name: 'eventName', type: 'String', validator(e) { - return 'string' === typeof e && 0 !== e.length || (console.warn(vt({ api: 'on', param: 'eventName', desc: '类型必须为 String,且不能为空' })), !1); - } }, { name: 'handler', type: 'Function', validator(e) { - return 'function' !== typeof e ? (console.warn(vt({ api: 'on', param: 'handler', desc: '参数必须为 Function' })), !1) : ('' === e.name && console.warn('on 接口的 handler 参数推荐使用具名函数。具名函数可以使用 off 接口取消订阅,匿名函数无法取消订阅。'), !0); - } }], once: [{ name: 'eventName', type: 'String', validator(e) { - return 'string' === typeof e && 0 !== e.length || (console.warn(vt({ api: 'once', param: 'eventName', desc: '类型必须为 String,且不能为空' })), !1); - } }, { name: 'handler', type: 'Function', validator(e) { - return 'function' !== typeof e ? (console.warn(vt({ api: 'once', param: 'handler', desc: '参数必须为 Function' })), !1) : ('' === e.name && console.warn('once 接口的 handler 参数推荐使用具名函数。'), !0); - } }], off: [{ name: 'eventName', type: 'String', validator(e) { - return 'string' === typeof e && 0 !== e.length || (console.warn(vt({ api: 'off', param: 'eventName', desc: '类型必须为 String,且不能为空' })), !1); - } }, { name: 'handler', type: 'Function', validator(e) { - return 'function' !== typeof e ? (console.warn(vt({ api: 'off', param: 'handler', desc: '参数必须为 Function' })), !1) : ('' === e.name && console.warn('off 接口无法为匿名函数取消监听事件。'), !0); - } }], sendMessage: [t({ name: 'message' }, Dt)], getMessageList: { conversationID: t(t({}, yt), {}, { validator(e) { - return mt(e); - } }), nextReqMessageID: { type: 'String' }, count: { type: 'Number', validator(e) { - return !(!Ge(e) && !/^[1-9][0-9]*$/.test(e)) || (console.warn(vt({ api: 'getMessageList', param: 'count', desc: '必须为正整数' })), !1); - } } }, setMessageRead: { conversationID: t(t({}, yt), {}, { validator(e) { - return mt(e); - } }) }, getConversationProfile: [t(t({ name: 'conversationID' }, yt), {}, { validator(e) { - return mt(e); - } })], deleteConversation: [t(t({ name: 'conversationID' }, yt), {}, { validator(e) { - return mt(e); - } })], getGroupList: { groupProfileFilter: { type: 'Array' } }, getGroupProfile: { groupID: yt, groupCustomFieldFilter: { type: 'Array' }, memberCustomFieldFilter: { type: 'Array' } }, getGroupProfileAdvance: { groupIDList: It }, createGroup: { name: yt }, joinGroup: { groupID: yt, type: { type: 'String' }, applyMessage: { type: 'String' } }, quitGroup: [t({ name: 'groupID' }, yt)], handleApplication: { message: Dt, handleAction: yt, handleMessage: { type: 'String' } }, changeGroupOwner: { groupID: yt, newOwnerID: yt }, updateGroupProfile: { groupID: yt, muteAllMembers: { type: 'Boolean' } }, dismissGroup: [t({ name: 'groupID' }, yt)], searchGroupByID: [t({ name: 'groupID' }, yt)], getGroupMemberList: { groupID: yt, offset: { type: 'Number' }, count: { type: 'Number' } }, getGroupMemberProfile: { groupID: yt, userIDList: It, memberCustomFieldFilter: { type: 'Array' } }, addGroupMember: { groupID: yt, userIDList: It }, setGroupMemberRole: { groupID: yt, userID: yt, role: yt }, setGroupMemberMuteTime: { groupID: yt, userID: yt, muteTime: { type: 'Number', validator(e) { - return e >= 0; - } } }, setGroupMemberNameCard: { groupID: yt, userID: { type: 'String' }, nameCard: t(t({}, yt), {}, { validator(e) { - return !0 !== /^\s+$/.test(e); - } }) }, setMessageRemindType: { groupID: yt, messageRemindType: yt }, setGroupMemberCustomField: { groupID: yt, userID: { type: 'String' }, memberCustomField: It }, deleteGroupMember: { groupID: yt }, createTextMessage: { to: yt, conversationType: yt, payload: t(t({}, Dt), {}, { validator(e) { - return Le(e) ? Ae(e.text) ? 0 !== e.text.length || (console.warn(vt({ api: 'createTextMessage', desc: '消息内容不能为空' })), !1) : (console.warn(vt({ api: 'createTextMessage', param: 'payload.text', desc: '类型必须为 String' })), !1) : (console.warn(vt({ api: 'createTextMessage', param: 'payload', desc: '类型必须为 plain object' })), !1); - } }) }, createTextAtMessage: { to: yt, conversationType: yt, payload: t(t({}, Dt), {}, { validator(e) { - return Le(e) ? Ae(e.text) ? 0 === e.text.length ? (console.warn(vt({ api: 'createTextAtMessage', desc: '消息内容不能为空' })), !1) : !(e.atUserList && !Re(e.atUserList)) || (console.warn(vt({ api: 'createTextAtMessage', desc: 'payload.atUserList 类型必须为数组' })), !1) : (console.warn(vt({ api: 'createTextAtMessage', param: 'payload.text', desc: '类型必须为 String' })), !1) : (console.warn(vt({ api: 'createTextAtMessage', param: 'payload', desc: '类型必须为 plain object' })), !1); - } }) }, createCustomMessage: { to: yt, conversationType: yt, payload: t(t({}, Dt), {}, { validator(e) { - return Le(e) ? e.data && !Ae(e.data) ? (console.warn(vt({ api: 'createCustomMessage', param: 'payload.data', desc: '类型必须为 String' })), !1) : e.description && !Ae(e.description) ? (console.warn(vt({ api: 'createCustomMessage', param: 'payload.description', desc: '类型必须为 String' })), !1) : !(e.extension && !Ae(e.extension)) || (console.warn(vt({ api: 'createCustomMessage', param: 'payload.extension', desc: '类型必须为 String' })), !1) : (console.warn(vt({ api: 'createCustomMessage', param: 'payload', desc: '类型必须为 plain object' })), !1); - } }) }, createImageMessage: { to: yt, conversationType: yt, payload: t(t({}, Dt), {}, { validator(e) { - if (!Le(e)) return console.warn(vt({ api: 'createImageMessage', param: 'payload', desc: '类型必须为 plain object' })), !1;if (Ge(e.file)) return console.warn(vt({ api: 'createImageMessage', param: 'payload.file', desc: '不能为 undefined' })), !1;if (W) { - if (!(e.file instanceof HTMLInputElement || Ce(e.file))) return Le(e.file) && 'undefined' !== typeof uni ? 0 !== e.file.tempFilePaths.length && 0 !== e.file.tempFiles.length || (console.warn(vt({ api: 'createImageMessage', param: 'payload.file', desc: '您没有选择文件,无法发送' })), !1) : (console.warn(vt({ api: 'createImageMessage', param: 'payload.file', desc: '类型必须是 HTMLInputElement 或 File' })), !1);if (e.file instanceof HTMLInputElement && 0 === e.file.files.length) return console.warn(vt({ api: 'createImageMessage', param: 'payload.file', desc: '您没有选择文件,无法发送' })), !1; - } return !0; - }, onProgress: { type: 'Function', required: !1, validator(e) { - return Ge(e) && console.warn(vt({ api: 'createImageMessage', desc: '没有 onProgress 回调,您将无法获取上传进度' })), !0; - } } }) }, createAudioMessage: { to: yt, conversationType: yt, payload: t(t({}, Dt), {}, { validator(e) { - return !!Le(e) || (console.warn(vt({ api: 'createAudioMessage', param: 'payload', desc: '类型必须为 plain object' })), !1); - } }), onProgress: { type: 'Function', required: !1, validator(e) { - return Ge(e) && console.warn(vt({ api: 'createAudioMessage', desc: '没有 onProgress 回调,您将无法获取上传进度' })), !0; - } } }, createVideoMessage: { to: yt, conversationType: yt, payload: t(t({}, Dt), {}, { validator(e) { - if (!Le(e)) return console.warn(vt({ api: 'createVideoMessage', param: 'payload', desc: '类型必须为 plain object' })), !1;if (Ge(e.file)) return console.warn(vt({ api: 'createVideoMessage', param: 'payload.file', desc: '不能为 undefined' })), !1;if (W) { - if (!(e.file instanceof HTMLInputElement || Ce(e.file))) return Le(e.file) && 'undefined' !== typeof uni ? !!Ce(e.file.tempFile) || (console.warn(vt({ api: 'createVideoMessage', param: 'payload.file', desc: '您没有选择文件,无法发送' })), !1) : (console.warn(vt({ api: 'createVideoMessage', param: 'payload.file', desc: '类型必须是 HTMLInputElement 或 File' })), !1);if (e.file instanceof HTMLInputElement && 0 === e.file.files.length) return console.warn(vt({ api: 'createVideoMessage', param: 'payload.file', desc: '您没有选择文件,无法发送' })), !1; - } return !0; - } }), onProgress: { type: 'Function', required: !1, validator(e) { - return Ge(e) && console.warn(vt({ api: 'createVideoMessage', desc: '没有 onProgress 回调,您将无法获取上传进度' })), !0; - } } }, createFaceMessage: { to: yt, conversationType: yt, payload: t(t({}, Dt), {}, { validator(e) { - return Le(e) ? Ne(e.index) ? !!Ae(e.data) || (console.warn(vt({ api: 'createFaceMessage', param: 'payload.data', desc: '类型必须为 String' })), !1) : (console.warn(vt({ api: 'createFaceMessage', param: 'payload.index', desc: '类型必须为 Number' })), !1) : (console.warn(vt({ api: 'createFaceMessage', param: 'payload', desc: '类型必须为 plain object' })), !1); - } }) }, createFileMessage: { to: yt, conversationType: yt, payload: t(t({}, Dt), {}, { validator(e) { - if (!Le(e)) return console.warn(vt({ api: 'createFileMessage', param: 'payload', desc: '类型必须为 plain object' })), !1;if (Ge(e.file)) return console.warn(vt({ api: 'createFileMessage', param: 'payload.file', desc: '不能为 undefined' })), !1;if (W) { - if (!(e.file instanceof HTMLInputElement || Ce(e.file))) return Le(e.file) && 'undefined' !== typeof uni ? 0 !== e.file.tempFilePaths.length && 0 !== e.file.tempFiles.length || (console.warn(vt({ api: 'createFileMessage', param: 'payload.file', desc: '您没有选择文件,无法发送' })), !1) : (console.warn(vt({ api: 'createFileMessage', param: 'payload.file', desc: '类型必须是 HTMLInputElement 或 File' })), !1);if (e.file instanceof HTMLInputElement && 0 === e.file.files.length) return console.warn(vt({ api: 'createFileMessage', desc: '您没有选择文件,无法发送' })), !1; - } return !0; - } }), onProgress: { type: 'Function', required: !1, validator(e) { - return Ge(e) && console.warn(vt({ api: 'createFileMessage', desc: '没有 onProgress 回调,您将无法获取上传进度' })), !0; - } } }, createMergerMessage: { to: yt, conversationType: yt, payload: t(t({}, Dt), {}, { validator(e) { - if (dt(e.messageList)) return console.warn(vt({ api: 'createMergerMessage', desc: '不能为空数组' })), !1;if (dt(e.compatibleText)) return console.warn(vt({ api: 'createMergerMessage', desc: '类型必须为 String,且不能为空' })), !1;let t = !1;return e.messageList.forEach(((e) => { - e.status === _t.FAIL && (t = !0); - })), !t || (console.warn(vt({ api: 'createMergerMessage', desc: '不支持合并已发送失败的消息' })), !1); - } }) }, revokeMessage: [t(t({ name: 'message' }, Dt), {}, { validator(e) { - return dt(e) ? (console.warn('revokeMessage 请传入消息(Message)实例'), !1) : e.conversationType === k.CONV_SYSTEM ? (console.warn('revokeMessage 不能撤回系统会话消息,只能撤回单聊消息或群消息'), !1) : !0 !== e.isRevoked || (console.warn('revokeMessage 消息已经被撤回,请勿重复操作'), !1); - } })], deleteMessage: [t(t({ name: 'messageList' }, It), {}, { validator(e) { - return !dt(e) || (console.warn(vt({ api: 'deleteMessage', param: 'messageList', desc: '不能为空数组' })), !1); - } })], getUserProfile: { userIDList: { type: 'Array', validator(e) { - return Re(e) ? (0 === e.length && console.warn(vt({ api: 'getUserProfile', param: 'userIDList', desc: '不能为空数组' })), !0) : (console.warn(vt({ api: 'getUserProfile', param: 'userIDList', desc: '必须为数组' })), !1); - } } }, updateMyProfile: { profileCustomField: { type: 'Array', validator(e) { - return !!Ge(e) || (!!Re(e) || (console.warn(vt({ api: 'updateMyProfile', param: 'profileCustomField', desc: '必须为数组' })), !1)); - } } }, addFriend: { to: yt, source: { type: 'String', required: !0, validator(e) { - return !!e && (e.startsWith('AddSource_Type_') ? !(e.replace('AddSource_Type_', '').length > 8) || (console.warn(vt({ api: 'addFriend', desc: '加好友来源字段的关键字长度不得超过8字节' })), !1) : (console.warn(vt({ api: 'addFriend', desc: '加好友来源字段的前缀必须是:AddSource_Type_' })), !1)); - } }, remark: { type: 'String', required: !1, validator(e) { - return !(Ae(e) && e.length > 96) || (console.warn(vt({ api: 'updateFriend', desc: ' 备注长度最长不得超过 96 个字节' })), !1); - } } }, deleteFriend: { userIDList: It }, checkFriend: { userIDList: It }, getFriendProfile: { userIDList: It }, updateFriend: { userID: yt, remark: { type: 'String', required: !1, validator(e) { - return !(Ae(e) && e.length > 96) || (console.warn(vt({ api: 'updateFriend', desc: ' 备注长度最长不得超过 96 个字节' })), !1); - } }, friendCustomField: { type: 'Array', required: !1, validator(e) { - if (e) { - if (!Re(e)) return console.warn(vt({ api: 'updateFriend', param: 'friendCustomField', desc: '必须为数组' })), !1;let t = !0;return e.forEach((e => (Ae(e.key) && -1 !== e.key.indexOf('Tag_SNS_Custom') ? Ae(e.value) ? e.value.length > 8 ? (console.warn(vt({ api: 'updateFriend', desc: '好友自定义字段的关键字长度不得超过8字节' })), t = !1) : void 0 : (console.warn(vt({ api: 'updateFriend', desc: '类型必须为 String' })), t = !1) : (console.warn(vt({ api: 'updateFriend', desc: '好友自定义字段的前缀必须是 Tag_SNS_Custom' })), t = !1)))), t; - } return !0; - } } }, acceptFriendApplication: { userID: yt }, refuseFriendApplication: { userID: yt }, deleteFriendApplication: { userID: yt }, createFriendGroup: { name: yt }, deleteFriendGroup: { name: yt }, addToFriendGroup: { name: yt, userIDList: It }, removeFromFriendGroup: { name: yt, userIDList: It }, renameFriendGroup: { oldName: yt, newName: yt } }; const St = { login: 'login', logout: 'logout', on: 'on', once: 'once', off: 'off', setLogLevel: 'setLogLevel', registerPlugin: 'registerPlugin', destroy: 'destroy', createTextMessage: 'createTextMessage', createTextAtMessage: 'createTextAtMessage', createImageMessage: 'createImageMessage', createAudioMessage: 'createAudioMessage', createVideoMessage: 'createVideoMessage', createCustomMessage: 'createCustomMessage', createFaceMessage: 'createFaceMessage', createFileMessage: 'createFileMessage', createMergerMessage: 'createMergerMessage', downloadMergerMessage: 'downloadMergerMessage', createForwardMessage: 'createForwardMessage', sendMessage: 'sendMessage', resendMessage: 'resendMessage', getMessageList: 'getMessageList', setMessageRead: 'setMessageRead', revokeMessage: 'revokeMessage', deleteMessage: 'deleteMessage', getConversationList: 'getConversationList', getConversationProfile: 'getConversationProfile', deleteConversation: 'deleteConversation', getGroupList: 'getGroupList', getGroupProfile: 'getGroupProfile', createGroup: 'createGroup', joinGroup: 'joinGroup', updateGroupProfile: 'updateGroupProfile', quitGroup: 'quitGroup', dismissGroup: 'dismissGroup', changeGroupOwner: 'changeGroupOwner', searchGroupByID: 'searchGroupByID', setMessageRemindType: 'setMessageRemindType', handleGroupApplication: 'handleGroupApplication', getGroupMemberProfile: 'getGroupMemberProfile', getGroupMemberList: 'getGroupMemberList', addGroupMember: 'addGroupMember', deleteGroupMember: 'deleteGroupMember', setGroupMemberNameCard: 'setGroupMemberNameCard', setGroupMemberMuteTime: 'setGroupMemberMuteTime', setGroupMemberRole: 'setGroupMemberRole', setGroupMemberCustomField: 'setGroupMemberCustomField', getGroupOnlineMemberCount: 'getGroupOnlineMemberCount', getMyProfile: 'getMyProfile', getUserProfile: 'getUserProfile', updateMyProfile: 'updateMyProfile', getBlacklist: 'getBlacklist', addToBlacklist: 'addToBlacklist', removeFromBlacklist: 'removeFromBlacklist', getFriendList: 'getFriendList', addFriend: 'addFriend', deleteFriend: 'deleteFriend', checkFriend: 'checkFriend', updateFriend: 'updateFriend', getFriendProfile: 'getFriendProfile', getFriendApplicationList: 'getFriendApplicationList', refuseFriendApplication: 'refuseFriendApplication', deleteFriendApplication: 'deleteFriendApplication', acceptFriendApplication: 'acceptFriendApplication', setFriendApplicationRead: 'setFriendApplicationRead', getFriendGroupList: 'getFriendGroupList', createFriendGroup: 'createFriendGroup', renameFriendGroup: 'renameFriendGroup', deleteFriendGroup: 'deleteFriendGroup', addToFriendGroup: 'addToFriendGroup', removeFromFriendGroup: 'removeFromFriendGroup', callExperimentalAPI: 'callExperimentalAPI' }; const Et = 'sign'; const kt = 'message'; const Ct = 'user'; const Nt = 'c2c'; const At = 'group'; const Ot = 'sns'; const Lt = 'groupMember'; const Rt = 'conversation'; const Gt = 'context'; const wt = 'storage'; const Pt = 'eventStat'; const bt = 'netMonitor'; const Ut = 'bigDataChannel'; const Ft = 'upload'; const qt = 'plugin'; const Vt = 'syncUnreadMessage'; const Kt = 'session'; const xt = 'channel'; const Bt = 'message_loss_detection'; const Ht = 'cloudControl'; const jt = 'pullGroupMessage'; const $t = 'qualityStat'; const Yt = (function () { - function e(t) { - o(this, e), this._moduleManager = t, this._className = ''; - } return s(e, [{ key: 'isLoggedIn', value() { - return this._moduleManager.getModule(Gt).isLoggedIn(); - } }, { key: 'isOversea', value() { - return this._moduleManager.getModule(Gt).isOversea(); - } }, { key: 'getMyUserID', value() { - return this._moduleManager.getModule(Gt).getUserID(); - } }, { key: 'getModule', value(e) { - return this._moduleManager.getModule(e); - } }, { key: 'getPlatform', value() { - return X; - } }, { key: 'getNetworkType', value() { - return this._moduleManager.getModule(bt).getNetworkType(); - } }, { key: 'probeNetwork', value() { - return this._moduleManager.getModule(bt).probe(); - } }, { key: 'getCloudConfig', value(e) { - return this._moduleManager.getModule(Ht).getCloudConfig(e); - } }, { key: 'emitOuterEvent', value(e, t) { - this._moduleManager.getOuterEmitterInstance().emit(e, t); - } }, { key: 'emitInnerEvent', value(e, t) { - this._moduleManager.getInnerEmitterInstance().emit(e, t); - } }, { key: 'getInnerEmitterInstance', value() { - return this._moduleManager.getInnerEmitterInstance(); - } }, { key: 'generateTjgID', value(e) { - return `${this._moduleManager.getModule(Gt).getTinyID()}-${e.random}`; - } }, { key: 'filterModifiedMessage', value(e) { - if (!dt(e)) { - const t = e.filter((e => !0 === e.isModified));t.length > 0 && this.emitOuterEvent(E.MESSAGE_MODIFIED, t); - } - } }, { key: 'filterUnmodifiedMessage', value(e) { - return dt(e) ? [] : e.filter((e => !1 === e.isModified)); - } }, { key: 'request', value(e) { - return this._moduleManager.getModule(Kt).request(e); - } }]), e; - }()); const zt = 'wslogin'; const Wt = 'wslogout'; const Jt = 'wshello'; const Xt = 'getmsg'; const Qt = 'authkey'; const Zt = 'sendmsg'; const en = 'send_group_msg'; const tn = 'portrait_get_all'; const nn = 'portrait_set'; const on = 'black_list_get'; const an = 'black_list_add'; const sn = 'black_list_delete'; const rn = 'msgwithdraw'; const cn = 'msgreaded'; const un = 'getroammsg'; const ln = 'get_peer_read_time'; const dn = 'delete_c2c_msg_ramble'; const gn = 'page_get'; const pn = 'get'; const hn = 'delete'; const _n = 'deletemsg'; const fn = 'get_joined_group_list'; const mn = 'get_group_info'; const Mn = 'create_group'; const vn = 'destroy_group'; const yn = 'modify_group_base_info'; const In = 'apply_join_group'; const Dn = 'apply_join_group_noauth'; const Tn = 'quit_group'; const Sn = 'get_group_public_info'; const En = 'change_group_owner'; const kn = 'handle_apply_join_group'; const Cn = 'handle_invite_join_group'; const Nn = 'group_msg_recall'; const An = 'msg_read_report'; const On = 'group_msg_get'; const Ln = 'get_pendency'; const Rn = 'deletemsg'; const Gn = 'get_msg'; const wn = 'get_msg_noauth'; const Pn = 'get_online_member_num'; const bn = 'delete_group_ramble_msg_by_seq'; const Un = 'get_group_member_info'; const Fn = 'get_specified_group_member_info'; const qn = 'add_group_member'; const Vn = 'delete_group_member'; const Kn = 'modify_group_member_info'; const xn = 'cos'; const Bn = 'pre_sig'; const Hn = 'tim_web_report_v2'; const jn = 'alive'; const $n = 'msg_push'; const Yn = 'ws_msg_push_ack'; const zn = 'stat_forceoffline'; const Wn = 'save_relay_json_msg'; const Jn = 'get_relay_json_msg'; const Xn = 'fetch_config'; const Qn = 'push_configv2'; const Zn = { NO_SDKAPPID: 2e3, NO_ACCOUNT_TYPE: 2001, NO_IDENTIFIER: 2002, NO_USERSIG: 2003, NO_TINYID: 2022, NO_A2KEY: 2023, USER_NOT_LOGGED_IN: 2024, COS_UNDETECTED: 2040, COS_GET_SIG_FAIL: 2041, MESSAGE_SEND_FAIL: 2100, MESSAGE_LIST_CONSTRUCTOR_NEED_OPTIONS: 2103, MESSAGE_SEND_NEED_MESSAGE_INSTANCE: 2105, MESSAGE_SEND_INVALID_CONVERSATION_TYPE: 2106, MESSAGE_FILE_IS_EMPTY: 2108, MESSAGE_ONPROGRESS_FUNCTION_ERROR: 2109, MESSAGE_REVOKE_FAIL: 2110, MESSAGE_DELETE_FAIL: 2111, MESSAGE_IMAGE_SELECT_FILE_FIRST: 2251, MESSAGE_IMAGE_TYPES_LIMIT: 2252, MESSAGE_IMAGE_SIZE_LIMIT: 2253, MESSAGE_AUDIO_UPLOAD_FAIL: 2300, MESSAGE_AUDIO_SIZE_LIMIT: 2301, MESSAGE_VIDEO_UPLOAD_FAIL: 2350, MESSAGE_VIDEO_SIZE_LIMIT: 2351, MESSAGE_VIDEO_TYPES_LIMIT: 2352, MESSAGE_FILE_UPLOAD_FAIL: 2400, MESSAGE_FILE_SELECT_FILE_FIRST: 2401, MESSAGE_FILE_SIZE_LIMIT: 2402, MESSAGE_FILE_URL_IS_EMPTY: 2403, MESSAGE_MERGER_TYPE_INVALID: 2450, MESSAGE_MERGER_KEY_INVALID: 2451, MESSAGE_MERGER_DOWNLOAD_FAIL: 2452, MESSAGE_FORWARD_TYPE_INVALID: 2453, CONVERSATION_NOT_FOUND: 2500, USER_OR_GROUP_NOT_FOUND: 2501, CONVERSATION_UN_RECORDED_TYPE: 2502, ILLEGAL_GROUP_TYPE: 2600, CANNOT_JOIN_WORK: 2601, CANNOT_CHANGE_OWNER_IN_AVCHATROOM: 2620, CANNOT_CHANGE_OWNER_TO_SELF: 2621, CANNOT_DISMISS_Work: 2622, MEMBER_NOT_IN_GROUP: 2623, JOIN_GROUP_FAIL: 2660, CANNOT_ADD_MEMBER_IN_AVCHATROOM: 2661, CANNOT_JOIN_NON_AVCHATROOM_WITHOUT_LOGIN: 2662, CANNOT_KICK_MEMBER_IN_AVCHATROOM: 2680, NOT_OWNER: 2681, CANNOT_SET_MEMBER_ROLE_IN_WORK_AND_AVCHATROOM: 2682, INVALID_MEMBER_ROLE: 2683, CANNOT_SET_SELF_MEMBER_ROLE: 2684, CANNOT_MUTE_SELF: 2685, NOT_MY_FRIEND: 2700, ALREADY_MY_FRIEND: 2701, FRIEND_GROUP_EXISTED: 2710, FRIEND_GROUP_NOT_EXIST: 2711, FRIEND_APPLICATION_NOT_EXIST: 2716, UPDATE_PROFILE_INVALID_PARAM: 2721, UPDATE_PROFILE_NO_KEY: 2722, ADD_BLACKLIST_INVALID_PARAM: 2740, DEL_BLACKLIST_INVALID_PARAM: 2741, CANNOT_ADD_SELF_TO_BLACKLIST: 2742, ADD_FRIEND_INVALID_PARAM: 2760, NETWORK_ERROR: 2800, NETWORK_TIMEOUT: 2801, NETWORK_BASE_OPTIONS_NO_URL: 2802, NETWORK_UNDEFINED_SERVER_NAME: 2803, NETWORK_PACKAGE_UNDEFINED: 2804, NO_NETWORK: 2805, CONVERTOR_IRREGULAR_PARAMS: 2900, NOTICE_RUNLOOP_UNEXPECTED_CONDITION: 2901, NOTICE_RUNLOOP_OFFSET_LOST: 2902, UNCAUGHT_ERROR: 2903, GET_LONGPOLL_ID_FAILED: 2904, INVALID_OPERATION: 2905, CANNOT_FIND_PROTOCOL: 2997, CANNOT_FIND_MODULE: 2998, SDK_IS_NOT_READY: 2999, LONG_POLL_KICK_OUT: 91101, MESSAGE_A2KEY_EXPIRED: 20002, ACCOUNT_A2KEY_EXPIRED: 70001, LONG_POLL_API_PARAM_ERROR: 90001, HELLO_ANSWER_KICKED_OUT: 1002 }; const eo = '无 SDKAppID'; const to = '无 userID'; const no = '无 userSig'; const oo = '无 tinyID'; const ao = '无 a2key'; const so = '用户未登录'; const ro = '未检测到 COS 上传插件'; const io = '获取 COS 预签名 URL 失败'; const co = '消息发送失败'; const uo = '需要 Message 的实例'; const lo = 'Message.conversationType 只能为 "C2C" 或 "GROUP"'; const go = '无法发送空文件'; const po = '回调函数运行时遇到错误,请检查接入侧代码'; const ho = '消息撤回失败'; const _o = '消息删除失败'; const fo = '请先选择一个图片'; const mo = '只允许上传 jpg png jpeg gif bmp格式的图片'; const Mo = '图片大小超过20M,无法发送'; const vo = '语音上传失败'; const yo = '语音大小大于20M,无法发送'; const Io = '视频上传失败'; const Do = '视频大小超过100M,无法发送'; const To = '只允许上传 mp4 格式的视频'; const So = '文件上传失败'; const Eo = '请先选择一个文件'; const ko = '文件大小超过100M,无法发送 '; const Co = '缺少必要的参数文件 URL'; const No = '非合并消息'; const Ao = '合并消息的 messageKey 无效'; const Oo = '下载合并消息失败'; const Lo = '选择的消息类型(如群提示消息)不可以转发'; const Ro = '没有找到相应的会话,请检查传入参数'; const Go = '没有找到相应的用户或群组,请检查传入参数'; const wo = '未记录的会话类型'; const Po = '非法的群类型,请检查传入参数'; const bo = '不能加入 Work 类型的群组'; const Uo = 'AVChatRoom 类型的群组不能转让群主'; const Fo = '不能把群主转让给自己'; const qo = '不能解散 Work 类型的群组'; const Vo = '用户不在该群组内'; const Ko = '加群失败,请检查传入参数或重试'; const xo = 'AVChatRoom 类型的群不支持邀请群成员'; const Bo = '非 AVChatRoom 类型的群组不允许匿名加群,请先登录后再加群'; const Ho = '不能在 AVChatRoom 类型的群组踢人'; const jo = '你不是群主,只有群主才有权限操作'; const $o = '不能在 Work / AVChatRoom 类型的群中设置群成员身份'; const Yo = '不合法的群成员身份,请检查传入参数'; const zo = '不能设置自己的群成员身份,请检查传入参数'; const Wo = '不能将自己禁言,请检查传入参数'; const Jo = '传入 updateMyProfile 接口的参数无效'; const Xo = 'updateMyProfile 无标配资料字段或自定义资料字段'; const Qo = '传入 addToBlacklist 接口的参数无效'; const Zo = '传入 removeFromBlacklist 接口的参数无效'; const ea = '不能拉黑自己'; const ta = '网络错误'; const na = '请求超时'; const oa = '未连接到网络'; const aa = '无效操作,如调用了未定义或者未实现的方法等'; const sa = '无法找到协议'; const ra = '无法找到模块'; const ia = '接口需要 SDK 处于 ready 状态后才能调用'; const ca = 'upload'; const ua = 'networkRTT'; const la = 'messageE2EDelay'; const da = 'sendMessageC2C'; const ga = 'sendMessageGroup'; const pa = 'sendMessageGroupAV'; const ha = 'sendMessageRichMedia'; const _a = 'cosUpload'; const fa = 'messageReceivedGroup'; const ma = 'messageReceivedGroupAVPush'; const Ma = 'messageReceivedGroupAVPull'; const va = (r(ht = {}, ua, 2), r(ht, la, 3), r(ht, da, 4), r(ht, ga, 5), r(ht, pa, 6), r(ht, ha, 7), r(ht, fa, 8), r(ht, ma, 9), r(ht, Ma, 10), r(ht, _a, 11), ht); const ya = { info: 4, warning: 5, error: 6 }; const Ia = { wifi: 1, '2g': 2, '3g': 3, '4g': 4, '5g': 5, unknown: 6, none: 7, online: 8 }; const Da = (function () { - function e(t) { - o(this, e), this.eventType = 0, this.timestamp = 0, this.networkType = 8, this.code = 0, this.message = '', this.moreMessage = '', this.extension = t, this.costTime = 0, this.duplicate = !1, this.level = 4, this._sentFlag = !1, this._startts = ye(); - } return s(e, [{ key: 'updateTimeStamp', value() { - this.timestamp = ye(); - } }, { key: 'start', value(e) { - return this._startts = e, this; - } }, { key: 'end', value() { - const e = this; const t = arguments.length > 0 && void 0 !== arguments[0] && arguments[0];if (!this._sentFlag) { - const n = ye();this.costTime = n - this._startts, this.setMoreMessage('host:'.concat(st(), ' startts:').concat(this._startts, ' endts:') - .concat(n)), t ? (this._sentFlag = !0, this._eventStatModule && this._eventStatModule.pushIn(this)) : setTimeout((() => { - e._sentFlag = !0, e._eventStatModule && e._eventStatModule.pushIn(e); - }), 0); - } - } }, { key: 'setError', value(e, t, n) { - return e instanceof Error ? (this._sentFlag || (this.setNetworkType(n), t ? (e.code && this.setCode(e.code), e.message && this.setMoreMessage(e.message)) : (this.setCode(Zn.NO_NETWORK), this.setMoreMessage(oa)), this.setLevel('error')), this) : (Ee.warn('SSOLogData.setError value not instanceof Error, please check!'), this); - } }, { key: 'setCode', value(e) { - return Ge(e) || this._sentFlag || ('ECONNABORTED' === e && (this.code = 103), Ne(e) ? this.code = e : Ee.warn('SSOLogData.setCode value not a number, please check!', e, n(e))), this; - } }, { key: 'setMessage', value(e) { - return Ge(e) || this._sentFlag || (Ne(e) && (this.message = e.toString()), Ae(e) && (this.message = e)), this; - } }, { key: 'setLevel', value(e) { - return Ge(e) || this._sentFlag || (this.level = ya[e]), this; - } }, { key: 'setMoreMessage', value(e) { - return dt(this.moreMessage) ? this.moreMessage = ''.concat(e) : this.moreMessage += ' '.concat(e), this; - } }, { key: 'setNetworkType', value(e) { - return Ge(e) || Ge(Ia[e]) ? Ee.warn('SSOLogData.setNetworkType value is undefined, please check!') : this.networkType = Ia[e], this; - } }, { key: 'getStartTs', value() { - return this._startts; - } }], [{ key: 'bindEventStatModule', value(t) { - e.prototype._eventStatModule = t; - } }]), e; - }()); const Ta = 'sdkConstruct'; const Sa = 'sdkReady'; const Ea = 'login'; const ka = 'logout'; const Ca = 'kickedOut'; const Na = 'registerPlugin'; const Aa = 'wsConnect'; const Oa = 'wsOnOpen'; const La = 'wsOnClose'; const Ra = 'wsOnError'; const Ga = 'getCosAuthKey'; const wa = 'getCosPreSigUrl'; const Pa = 'upload'; const ba = 'sendMessage'; const Ua = 'getC2CRoamingMessages'; const Fa = 'getGroupRoamingMessages'; const qa = 'revokeMessage'; const Va = 'deleteMessage'; const Ka = 'setC2CMessageRead'; const xa = 'setGroupMessageRead'; const Ba = 'emptyMessageBody'; const Ha = 'getPeerReadTime'; const ja = 'uploadMergerMessage'; const $a = 'downloadMergerMessage'; const Ya = 'jsonParseError'; const za = 'messageE2EDelayException'; const Wa = 'getConversationList'; const Ja = 'getConversationProfile'; const Xa = 'deleteConversation'; const Qa = 'getConversationListInStorage'; const Za = 'syncConversationList'; const es = 'createGroup'; const ts = 'applyJoinGroup'; const ns = 'quitGroup'; const os = 'searchGroupByID'; const as = 'changeGroupOwner'; const ss = 'handleGroupApplication'; const rs = 'handleGroupInvitation'; const is = 'setMessageRemindType'; const cs = 'dismissGroup'; const us = 'updateGroupProfile'; const ls = 'getGroupList'; const ds = 'getGroupProfile'; const gs = 'getGroupListInStorage'; const ps = 'getGroupLastSequence'; const hs = 'getGroupMissingMessage'; const _s = 'pagingGetGroupList'; const fs = 'getGroupSimplifiedInfo'; const ms = 'joinWithoutAuth'; const Ms = 'getGroupMemberList'; const vs = 'getGroupMemberProfile'; const ys = 'addGroupMember'; const Is = 'deleteGroupMember'; const Ds = 'setGroupMemberMuteTime'; const Ts = 'setGroupMemberNameCard'; const Ss = 'setGroupMemberRole'; const Es = 'setGroupMemberCustomField'; const ks = 'getGroupOnlineMemberCount'; const Cs = 'longPollingAVError'; const Ns = 'messageLoss'; const As = 'messageStacked'; const Os = 'getUserProfile'; const Ls = 'updateMyProfile'; const Rs = 'getBlacklist'; const Gs = 'addToBlacklist'; const ws = 'removeFromBlacklist'; const Ps = 'callbackFunctionError'; const bs = 'fetchCloudControlConfig'; const Us = 'pushedCloudControlConfig'; const Fs = 'error'; const qs = (function () { - function e(t) { - o(this, e), this.type = k.MSG_TEXT, this.content = { text: t.text || '' }; - } return s(e, [{ key: 'setText', value(e) { - this.content.text = e; - } }, { key: 'sendable', value() { - return 0 !== this.content.text.length; - } }]), e; - }()); const Vs = { JSON: { TYPE: { C2C: { NOTICE: 1, COMMON: 9, EVENT: 10 }, GROUP: { COMMON: 3, TIP: 4, SYSTEM: 5, TIP2: 6 }, FRIEND: { NOTICE: 7 }, PROFILE: { NOTICE: 8 } }, SUBTYPE: { C2C: { COMMON: 0, READED: 92, KICKEDOUT: 96 }, GROUP: { COMMON: 0, LOVEMESSAGE: 1, TIP: 2, REDPACKET: 3 } }, OPTIONS: { GROUP: { JOIN: 1, QUIT: 2, KICK: 3, SET_ADMIN: 4, CANCEL_ADMIN: 5, MODIFY_GROUP_INFO: 6, MODIFY_MEMBER_INFO: 7 } } }, PROTOBUF: {}, IMAGE_TYPES: { ORIGIN: 1, LARGE: 2, SMALL: 3 }, IMAGE_FORMAT: { JPG: 1, JPEG: 1, GIF: 2, PNG: 3, BMP: 4, UNKNOWN: 255 } }; const Ks = { NICK: 'Tag_Profile_IM_Nick', GENDER: 'Tag_Profile_IM_Gender', BIRTHDAY: 'Tag_Profile_IM_BirthDay', LOCATION: 'Tag_Profile_IM_Location', SELFSIGNATURE: 'Tag_Profile_IM_SelfSignature', ALLOWTYPE: 'Tag_Profile_IM_AllowType', LANGUAGE: 'Tag_Profile_IM_Language', AVATAR: 'Tag_Profile_IM_Image', MESSAGESETTINGS: 'Tag_Profile_IM_MsgSettings', ADMINFORBIDTYPE: 'Tag_Profile_IM_AdminForbidType', LEVEL: 'Tag_Profile_IM_Level', ROLE: 'Tag_Profile_IM_Role' }; const xs = { UNKNOWN: 'Gender_Type_Unknown', FEMALE: 'Gender_Type_Female', MALE: 'Gender_Type_Male' }; const Bs = { NONE: 'AdminForbid_Type_None', SEND_OUT: 'AdminForbid_Type_SendOut' }; const Hs = { NEED_CONFIRM: 'AllowType_Type_NeedConfirm', ALLOW_ANY: 'AllowType_Type_AllowAny', DENY_ANY: 'AllowType_Type_DenyAny' }; const js = 'JoinedSuccess'; const $s = 'WaitAdminApproval'; const Ys = (function () { - function e(t) { - o(this, e), this._imageMemoryURL = '', z ? this.createImageDataASURLInWXMiniApp(t.file) : this.createImageDataASURLInWeb(t.file), this._initImageInfoModel(), this.type = k.MSG_IMAGE, this._percent = 0, this.content = { imageFormat: t.imageFormat || Vs.IMAGE_FORMAT.UNKNOWN, uuid: t.uuid, imageInfoArray: [] }, this.initImageInfoArray(t.imageInfoArray), this._defaultImage = 'http://imgcache.qq.com/open/qcloud/video/act/webim-images/default.jpg', this._autoFixUrl(); - } return s(e, [{ key: '_initImageInfoModel', value() { - const e = this;this._ImageInfoModel = function (t) { - this.instanceID = He(9999999), this.sizeType = t.type || 0, this.type = 0, this.size = t.size || 0, this.width = t.width || 0, this.height = t.height || 0, this.imageUrl = t.url || '', this.url = t.url || e._imageMemoryURL || e._defaultImage; - }, this._ImageInfoModel.prototype = { setSizeType(e) { - this.sizeType = e; - }, setType(e) { - this.type = e; - }, setImageUrl(e) { - e && (this.imageUrl = e); - }, getImageUrl() { - return this.imageUrl; - } }; - } }, { key: 'initImageInfoArray', value(e) { - for (let t = 0, n = null, o = null;t <= 2;)o = Ge(e) || Ge(e[t]) ? { type: 0, size: 0, width: 0, height: 0, url: '' } : e[t], (n = new this._ImageInfoModel(o)).setSizeType(t + 1), n.setType(t), this.addImageInfo(n), t++;this.updateAccessSideImageInfoArray(); - } }, { key: 'updateImageInfoArray', value(e) { - for (var t, n = this.content.imageInfoArray.length, o = 0;o < n;o++)t = this.content.imageInfoArray[o], e[o].size && (t.size = e[o].size), e[o].url && t.setImageUrl(e[o].url), e[o].width && (t.width = e[o].width), e[o].height && (t.height = e[o].height); - } }, { key: '_autoFixUrl', value() { - for (let e = this.content.imageInfoArray.length, t = '', n = '', o = ['http', 'https'], a = null, s = 0;s < e;s++) this.content.imageInfoArray[s].url && '' !== (a = this.content.imageInfoArray[s]).imageUrl && (n = a.imageUrl.slice(0, a.imageUrl.indexOf('://') + 1), t = a.imageUrl.slice(a.imageUrl.indexOf('://') + 1), o.indexOf(n) < 0 && (n = 'https:'), this.content.imageInfoArray[s].setImageUrl([n, t].join(''))); - } }, { key: 'updatePercent', value(e) { - this._percent = e, this._percent > 1 && (this._percent = 1); - } }, { key: 'updateImageFormat', value(e) { - this.content.imageFormat = Vs.IMAGE_FORMAT[e.toUpperCase()] || Vs.IMAGE_FORMAT.UNKNOWN; - } }, { key: 'createImageDataASURLInWeb', value(e) { - void 0 !== e && e.files.length > 0 && (this._imageMemoryURL = window.URL.createObjectURL(e.files[0])); - } }, { key: 'createImageDataASURLInWXMiniApp', value(e) { - e && e.url && (this._imageMemoryURL = e.url); - } }, { key: 'replaceImageInfo', value(e, t) { - this.content.imageInfoArray[t] instanceof this._ImageInfoModel || (this.content.imageInfoArray[t] = e); - } }, { key: 'addImageInfo', value(e) { - this.content.imageInfoArray.length >= 3 || this.content.imageInfoArray.push(e); - } }, { key: 'updateAccessSideImageInfoArray', value() { - const e = this.content.imageInfoArray; const t = e[0]; const n = t.width; const o = void 0 === n ? 0 : n; const a = t.height; const s = void 0 === a ? 0 : a;0 !== o && 0 !== s && (it(e), Object.assign(e[2], rt({ originWidth: o, originHeight: s, min: 720 }))); - } }, { key: 'sendable', value() { - return 0 !== this.content.imageInfoArray.length && ('' !== this.content.imageInfoArray[0].imageUrl && 0 !== this.content.imageInfoArray[0].size); - } }]), e; - }()); const zs = (function () { - function e(t) { - o(this, e), this.type = k.MSG_FACE, this.content = t || null; - } return s(e, [{ key: 'sendable', value() { - return null !== this.content; - } }]), e; - }()); const Ws = (function () { - function e(t) { - o(this, e), this.type = k.MSG_AUDIO, this._percent = 0, this.content = { downloadFlag: 2, second: t.second, size: t.size, url: t.url, remoteAudioUrl: t.url || '', uuid: t.uuid }; - } return s(e, [{ key: 'updatePercent', value(e) { - this._percent = e, this._percent > 1 && (this._percent = 1); - } }, { key: 'updateAudioUrl', value(e) { - this.content.remoteAudioUrl = e; - } }, { key: 'sendable', value() { - return '' !== this.content.remoteAudioUrl; - } }]), e; - }()); const Js = { from: !0, groupID: !0, groupName: !0, to: !0 }; const Xs = (function () { - function e(t) { - o(this, e), this.type = k.MSG_GRP_TIP, this.content = {}, this._initContent(t); - } return s(e, [{ key: '_initContent', value(e) { - const t = this;Object.keys(e).forEach(((n) => { - switch (n) { - case 'remarkInfo':break;case 'groupProfile':t.content.groupProfile = {}, t._initGroupProfile(e[n]);break;case 'operatorInfo':case 'memberInfoList':break;case 'msgMemberInfo':t.content.memberList = e[n], Object.defineProperty(t.content, 'msgMemberInfo', { get() { - return Ee.warn('!!! 禁言的群提示消息中的 payload.msgMemberInfo 属性即将废弃,请使用 payload.memberList 属性替代。 \n', 'msgMemberInfo 中的 shutupTime 属性对应更改为 memberList 中的 muteTime 属性,表示禁言时长。 \n', '参考:群提示消息 https://web.sdk.qcloud.com/im/doc/zh-cn/Message.html#.GroupTipPayload'), t.content.memberList.map((e => ({ userID: e.userID, shutupTime: e.muteTime }))); - } });break;case 'onlineMemberInfo':break;case 'memberNum':t.content[n] = e[n], t.content.memberCount = e[n];break;default:t.content[n] = e[n]; - } - })), this.content.userIDList || (this.content.userIDList = [this.content.operatorID]); - } }, { key: '_initGroupProfile', value(e) { - for (let t = Object.keys(e), n = 0;n < t.length;n++) { - const o = t[n];Js[o] && (this.content.groupProfile[o] = e[o]); - } - } }]), e; - }()); const Qs = { from: !0, groupID: !0, groupName: !0, to: !0 }; const Zs = (function () { - function e(t) { - o(this, e), this.type = k.MSG_GRP_SYS_NOTICE, this.content = {}, this._initContent(t); - } return s(e, [{ key: '_initContent', value(e) { - const t = this;Object.keys(e).forEach(((n) => { - switch (n) { - case 'memberInfoList':break;case 'remarkInfo':t.content.handleMessage = e[n];break;case 'groupProfile':t.content.groupProfile = {}, t._initGroupProfile(e[n]);break;default:t.content[n] = e[n]; - } - })); - } }, { key: '_initGroupProfile', value(e) { - for (let t = Object.keys(e), n = 0;n < t.length;n++) { - const o = t[n];Qs[o] && ('groupName' === o ? this.content.groupProfile.name = e[o] : this.content.groupProfile[o] = e[o]); - } - } }]), e; - }()); const er = (function () { - function e(t) { - o(this, e), this.type = k.MSG_FILE, this._percent = 0;const n = this._getFileInfo(t);this.content = { downloadFlag: 2, fileUrl: t.url || '', uuid: t.uuid, fileName: n.name || '', fileSize: n.size || 0 }; - } return s(e, [{ key: '_getFileInfo', value(e) { - if (e.fileName && e.fileSize) return { size: e.fileSize, name: e.fileName };if (z) return {};const t = e.file.files[0];return { size: t.size, name: t.name, type: t.type.slice(t.type.lastIndexOf('/') + 1).toLowerCase() }; - } }, { key: 'updatePercent', value(e) { - this._percent = e, this._percent > 1 && (this._percent = 1); - } }, { key: 'updateFileUrl', value(e) { - this.content.fileUrl = e; - } }, { key: 'sendable', value() { - return '' !== this.content.fileUrl && ('' !== this.content.fileName && 0 !== this.content.fileSize); - } }]), e; - }()); const tr = (function () { - function e(t) { - o(this, e), this.type = k.MSG_CUSTOM, this.content = { data: t.data || '', description: t.description || '', extension: t.extension || '' }; - } return s(e, [{ key: 'setData', value(e) { - return this.content.data = e, this; - } }, { key: 'setDescription', value(e) { - return this.content.description = e, this; - } }, { key: 'setExtension', value(e) { - return this.content.extension = e, this; - } }, { key: 'sendable', value() { - return 0 !== this.content.data.length || 0 !== this.content.description.length || 0 !== this.content.extension.length; - } }]), e; - }()); const nr = (function () { - function e(t) { - o(this, e), this.type = k.MSG_VIDEO, this._percent = 0, this.content = { remoteVideoUrl: t.remoteVideoUrl || t.videoUrl || '', videoFormat: t.videoFormat, videoSecond: parseInt(t.videoSecond, 10), videoSize: t.videoSize, videoUrl: t.videoUrl, videoDownloadFlag: 2, videoUUID: t.videoUUID, thumbUUID: t.thumbUUID, thumbFormat: t.thumbFormat, thumbWidth: t.thumbWidth, thumbHeight: t.thumbHeight, thumbSize: t.thumbSize, thumbDownloadFlag: 2, thumbUrl: t.thumbUrl }; - } return s(e, [{ key: 'updatePercent', value(e) { - this._percent = e, this._percent > 1 && (this._percent = 1); - } }, { key: 'updateVideoUrl', value(e) { - e && (this.content.remoteVideoUrl = e); - } }, { key: 'sendable', value() { - return '' !== this.content.remoteVideoUrl; - } }]), e; - }()); const or = function e(t) { - o(this, e), this.type = k.MSG_GEO, this.content = t; - }; const ar = (function () { - function e(t) { - if (o(this, e), this.from = t.from, this.messageSender = t.from, this.time = t.time, this.messageSequence = t.sequence, this.clientSequence = t.clientSequence || t.sequence, this.messageRandom = t.random, this.cloudCustomData = t.cloudCustomData || '', t.ID) this.nick = t.nick || '', this.avatar = t.avatar || '', this.messageBody = [{ type: t.type, payload: t.payload }], t.conversationType.startsWith(k.CONV_C2C) ? this.receiverUserID = t.to : t.conversationType.startsWith(k.CONV_GROUP) && (this.receiverGroupID = t.to), this.messageReceiver = t.to;else { - this.nick = t.nick || '', this.avatar = t.avatar || '', this.messageBody = [];const n = t.elements[0].type; const a = t.elements[0].content;this._patchRichMediaPayload(n, a), n === k.MSG_MERGER ? this.messageBody.push({ type: n, payload: new sr(a).content }) : this.messageBody.push({ type: n, payload: a }), t.groupID && (this.receiverGroupID = t.groupID, this.messageReceiver = t.groupID), t.to && (this.receiverUserID = t.to, this.messageReceiver = t.to); - } - } return s(e, [{ key: '_patchRichMediaPayload', value(e, t) { - e === k.MSG_IMAGE ? t.imageInfoArray.forEach(((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 === k.MSG_VIDEO ? !t.remoteVideoUrl && t.videoUrl && (t.remoteVideoUrl = t.videoUrl) : e === k.MSG_AUDIO ? !t.remoteAudioUrl && t.url && (t.remoteAudioUrl = t.url) : e === k.MSG_FILE && !t.fileUrl && t.url && (t.fileUrl = t.url, t.url = void 0); - } }]), e; - }()); var sr = (function () { - function e(t) { - if (o(this, e), this.type = k.MSG_MERGER, this.content = { downloadKey: '', pbDownloadKey: '', messageList: [], title: '', abstractList: [], compatibleText: '', version: 0, layersOverLimit: !1 }, t.downloadKey) { - const n = t.downloadKey; const a = t.pbDownloadKey; const s = t.title; const r = t.abstractList; const i = t.compatibleText; const c = t.version;this.content.downloadKey = n, this.content.pbDownloadKey = a, this.content.title = s, this.content.abstractList = r, this.content.compatibleText = i, this.content.version = c || 0; - } else if (dt(t.messageList))1 === t.layersOverLimit && (this.content.layersOverLimit = !0);else { - const u = t.messageList; const l = t.title; const d = t.abstractList; const g = t.compatibleText; const p = t.version; const h = [];u.forEach(((e) => { - if (!dt(e)) { - const t = new ar(e);h.push(t); - } - })), this.content.messageList = h, this.content.title = l, this.content.abstractList = d, this.content.compatibleText = g, this.content.version = p || 0; - }Ee.debug('MergerElement.content:', this.content); - } return s(e, [{ key: 'sendable', value() { - return !dt(this.content.messageList) || !dt(this.content.downloadKey); - } }]), e; - }()); const rr = { 1: k.MSG_PRIORITY_HIGH, 2: k.MSG_PRIORITY_NORMAL, 3: k.MSG_PRIORITY_LOW, 4: k.MSG_PRIORITY_LOWEST }; const ir = (function () { - function e(t) { - o(this, e), this.ID = '', this.conversationID = t.conversationID || null, this.conversationType = t.conversationType || k.CONV_C2C, this.conversationSubType = t.conversationSubType, this.time = t.time || Math.ceil(Date.now() / 1e3), this.sequence = t.sequence || 0, this.clientSequence = t.clientSequence || t.sequence || 0, this.random = t.random || 0 === t.random ? t.random : He(), this.priority = this._computePriority(t.priority), this.nick = t.nick || '', this.avatar = t.avatar || '', this.isPeerRead = !1, this.nameCard = '', this._elements = [], this.isPlaceMessage = t.isPlaceMessage || 0, this.isRevoked = 2 === t.isPlaceMessage || 8 === t.msgFlagBits, this.geo = {}, this.from = t.from || null, this.to = t.to || null, this.flow = '', this.isSystemMessage = t.isSystemMessage || !1, this.protocol = t.protocol || 'JSON', this.isResend = !1, this.isRead = !1, this.status = t.status || _t.SUCCESS, this._onlineOnlyFlag = !1, this._groupAtInfoList = [], this._relayFlag = !1, this.atUserList = [], this.cloudCustomData = t.cloudCustomData || '', this.isDeleted = !1, this.isModified = !1, this.reInitialize(t.currentUser), this.extractGroupInfo(t.groupProfile || null), this.handleGroupAtInfo(t); - } return s(e, [{ key: 'elements', get() { - return Ee.warn('!!!Message 实例的 elements 属性即将废弃,请尽快修改。使用 type 和 payload 属性处理单条消息,兼容组合消息使用 _elements 属性!!!'), this._elements; - } }, { key: 'getElements', value() { - return this._elements; - } }, { key: 'extractGroupInfo', value(e) { - if (null !== e) { - Ae(e.nick) && (this.nick = e.nick), Ae(e.avatar) && (this.avatar = e.avatar);const t = e.messageFromAccountExtraInformation;Le(t) && Ae(t.nameCard) && (this.nameCard = t.nameCard); - } - } }, { key: 'handleGroupAtInfo', value(e) { - const t = this;e.payload && e.payload.atUserList && e.payload.atUserList.forEach(((e) => { - e !== k.MSG_AT_ALL ? (t._groupAtInfoList.push({ groupAtAllFlag: 0, groupAtUserID: e }), t.atUserList.push(e)) : (t._groupAtInfoList.push({ groupAtAllFlag: 1 }), t.atUserList.push(k.MSG_AT_ALL)); - })), Re(e.groupAtInfo) && e.groupAtInfo.forEach(((e) => { - 1 === e.groupAtAllFlag ? t.atUserList.push(e.groupAtUserID) : 2 === e.groupAtAllFlag && t.atUserList.push(k.MSG_AT_ALL); - })); - } }, { key: 'getGroupAtInfoList', value() { - return this._groupAtInfoList; - } }, { key: '_initProxy', value() { - this._elements[0] && (this.payload = this._elements[0].content, this.type = this._elements[0].type); - } }, { key: 'reInitialize', value(e) { - e && (this.status = this.from ? _t.SUCCESS : _t.UNSEND, !this.from && (this.from = e)), this._initFlow(e), this._initSequence(e), this._concatConversationID(e), this.generateMessageID(e); - } }, { key: 'isSendable', value() { - return 0 !== this._elements.length && ('function' !== typeof this._elements[0].sendable ? (Ee.warn(''.concat(this._elements[0].type, ' need "boolean : sendable()" method')), !1) : this._elements[0].sendable()); - } }, { key: '_initTo', value(e) { - this.conversationType === k.CONV_GROUP && (this.to = e.groupID); - } }, { key: '_initSequence', value(e) { - 0 === this.clientSequence && e && (this.clientSequence = (function (e) { - if (!e) return Ee.error('autoIncrementIndex(string: key) need key parameter'), !1;if (void 0 === ze[e]) { - const t = new Date; let n = '3'.concat(t.getHours()).slice(-2); let o = '0'.concat(t.getMinutes()).slice(-2); let a = '0'.concat(t.getSeconds()).slice(-2);ze[e] = parseInt([n, o, a, '0001'].join('')), n = null, o = null, a = null, Ee.log('autoIncrementIndex start index:'.concat(ze[e])); - } return ze[e]++; - }(e))), 0 === this.sequence && this.conversationType === k.CONV_C2C && (this.sequence = this.clientSequence); - } }, { key: 'generateMessageID', value(e) { - const t = e === this.from ? 1 : 0; const n = this.sequence > 0 ? this.sequence : this.clientSequence;this.ID = ''.concat(this.conversationID, '-').concat(n, '-') - .concat(this.random, '-') - .concat(t); - } }, { key: '_initFlow', value(e) { - '' !== e && (e === this.from ? (this.flow = 'out', this.isRead = !0) : this.flow = 'in'); - } }, { key: '_concatConversationID', value(e) { - const t = this.to; let n = ''; const o = this.conversationType;o !== k.CONV_SYSTEM ? (n = o === k.CONV_C2C ? e === this.from ? t : this.from : this.to, this.conversationID = ''.concat(o).concat(n)) : this.conversationID = k.CONV_SYSTEM; - } }, { key: 'isElement', value(e) { - return e instanceof qs || e instanceof Ys || e instanceof zs || e instanceof Ws || e instanceof er || e instanceof nr || e instanceof Xs || e instanceof Zs || e instanceof tr || e instanceof or || e instanceof sr; - } }, { key: 'setElement', value(e) { - const t = this;if (this.isElement(e)) return this._elements = [e], void this._initProxy();const n = function (e) { - if (e.type && e.content) switch (e.type) { - case k.MSG_TEXT:t.setTextElement(e.content);break;case k.MSG_IMAGE:t.setImageElement(e.content);break;case k.MSG_AUDIO:t.setAudioElement(e.content);break;case k.MSG_FILE:t.setFileElement(e.content);break;case k.MSG_VIDEO:t.setVideoElement(e.content);break;case k.MSG_CUSTOM:t.setCustomElement(e.content);break;case k.MSG_GEO:t.setGEOElement(e.content);break;case k.MSG_GRP_TIP:t.setGroupTipElement(e.content);break;case k.MSG_GRP_SYS_NOTICE:t.setGroupSystemNoticeElement(e.content);break;case k.MSG_FACE:t.setFaceElement(e.content);break;case k.MSG_MERGER:t.setMergerElement(e.content);break;default:Ee.warn(e.type, e.content, 'no operation......'); - } - };if (Re(e)) for (let o = 0;o < e.length;o++)n(e[o]);else n(e);this._initProxy(); - } }, { key: 'clearElement', value() { - this._elements.length = 0; - } }, { key: 'setTextElement', value(e) { - const t = 'string' === typeof e ? e : e.text; const n = new qs({ text: t });this._elements.push(n); - } }, { key: 'setImageElement', value(e) { - const t = new Ys(e);this._elements.push(t); - } }, { key: 'setAudioElement', value(e) { - const t = new Ws(e);this._elements.push(t); - } }, { key: 'setFileElement', value(e) { - const t = new er(e);this._elements.push(t); - } }, { key: 'setVideoElement', value(e) { - const t = new nr(e);this._elements.push(t); - } }, { key: 'setGEOElement', value(e) { - const t = new or(e);this._elements.push(t); - } }, { key: 'setCustomElement', value(e) { - const t = new tr(e);this._elements.push(t); - } }, { key: 'setGroupTipElement', value(e) { - let t = {}; const n = e.operationType;dt(e.memberInfoList) ? e.operatorInfo && (t = e.operatorInfo) : n !== k.GRP_TIP_MBR_JOIN && n !== k.GRP_TIP_MBR_KICKED_OUT && n !== k.GRP_TIP_MBR_SET_ADMIN && n !== k.GRP_TIP_MBR_CANCELED_ADMIN || (t = e.memberInfoList[0]);const o = t; const a = o.nick; const s = o.avatar;Ae(a) && (this.nick = a), Ae(s) && (this.avatar = s);const r = new Xs(e);this._elements.push(r); - } }, { key: 'setGroupSystemNoticeElement', value(e) { - const t = new Zs(e);this._elements.push(t); - } }, { key: 'setFaceElement', value(e) { - const t = new zs(e);this._elements.push(t); - } }, { key: 'setMergerElement', value(e) { - const t = new sr(e);this._elements.push(t); - } }, { key: 'setIsRead', value(e) { - this.isRead = e; - } }, { key: 'setRelayFlag', value(e) { - this._relayFlag = e; - } }, { key: 'getRelayFlag', value() { - return this._relayFlag; - } }, { key: 'setOnlineOnlyFlag', value(e) { - this._onlineOnlyFlag = e; - } }, { key: 'getOnlineOnlyFlag', value() { - return this._onlineOnlyFlag; - } }, { key: '_computePriority', value(e) { - if (Ge(e)) return k.MSG_PRIORITY_NORMAL;if (Ae(e) && -1 !== Object.values(rr).indexOf(e)) return e;if (Ne(e)) { - const t = `${e}`;if (-1 !== Object.keys(rr).indexOf(t)) return rr[t]; - } return k.MSG_PRIORITY_NORMAL; - } }, { key: 'setNickAndAvatar', value(e) { - const t = e.nick; const n = e.avatar;Ae(t) && (this.nick = t), Ae(n) && (this.avatar = n); - } }]), e; - }()); const cr = function (e) { - return { code: 0, data: e || {} }; - }; const ur = 'https://cloud.tencent.com/document/product/'; const lr = '您可以在即时通信 IM 控制台的【开发辅助工具(https://console.cloud.tencent.com/im-detail/tool-usersig)】页面校验 UserSig。'; const dr = 'UserSig 非法,请使用官网提供的 API 重新生成 UserSig('.concat(ur, '269/32688)。'); const gr = '#.E6.B6.88.E6.81.AF.E5.85.83.E7.B4.A0-timmsgelement'; const pr = { 70001: 'UserSig 已过期,请重新生成。建议 UserSig 有效期设置不小于24小时。', 70002: 'UserSig 长度为0,请检查传入的 UserSig 是否正确。', 70003: dr, 70005: dr, 70009: 'UserSig 验证失败,可能因为生成 UserSig 时混用了其他 SDKAppID 的私钥或密钥导致,请使用对应 SDKAppID 下的私钥或密钥重新生成 UserSig('.concat(ur, '269/32688)。'), 70013: '请求中的 UserID 与生成 UserSig 时使用的 UserID 不匹配。'.concat(lr), 70014: '请求中的 SDKAppID 与生成 UserSig 时使用的 SDKAppID 不匹配。'.concat(lr), 70016: '密钥不存在,UserSig 验证失败,请在即时通信 IM 控制台获取密钥('.concat(ur, '269/32578#.E8.8E.B7.E5.8F.96.E5.AF.86.E9.92.A5)。'), 70020: 'SDKAppID 未找到,请在即时通信 IM 控制台确认应用信息。', 70050: 'UserSig 验证次数过于频繁。请检查 UserSig 是否正确,并于1分钟后重新验证。'.concat(lr), 70051: '帐号被拉入黑名单。', 70052: 'UserSig 已经失效,请重新生成,再次尝试。', 70107: '因安全原因被限制登录,请不要频繁登录。', 70169: '请求的用户帐号不存在。', 70114: ''.concat('服务端内部超时,请稍后重试。'), 70202: ''.concat('服务端内部超时,请稍后重试。'), 70206: '请求中批量数量不合法。', 70402: '参数非法,请检查必填字段是否填充,或者字段的填充是否满足协议要求。', 70403: '请求失败,需要 App 管理员权限。', 70398: '帐号数超限。如需创建多于100个帐号,请将应用升级为专业版,具体操作指引请参见购买指引('.concat(ur, '269/32458)。'), 70500: ''.concat('服务端内部错误,请重试。'), 71e3: '删除帐号失败。仅支持删除体验版帐号,您当前应用为专业版,暂不支持帐号删除。', 20001: '请求包非法。', 20002: 'UserSig 或 A2 失效。', 20003: '消息发送方或接收方 UserID 无效或不存在,请检查 UserID 是否已导入即时通信 IM。', 20004: '网络异常,请重试。', 20005: ''.concat('服务端内部错误,请重试。'), 20006: '触发发送'.concat('单聊消息', '之前回调,App 后台返回禁止下发该消息。'), 20007: '发送'.concat('单聊消息', ',被对方拉黑,禁止发送。消息发送状态默认展示为失败,您可以登录控制台修改该场景下的消息发送状态展示结果,具体操作请参见消息保留设置(').concat(ur, '269/38656)。'), 20009: '消息发送双方互相不是好友,禁止发送(配置'.concat('单聊消息', '校验好友关系才会出现)。'), 20010: '发送'.concat('单聊消息', ',自己不是对方的好友(单向关系),禁止发送。'), 20011: '发送'.concat('单聊消息', ',对方不是自己的好友(单向关系),禁止发送。'), 20012: '发送方被禁言,该条消息被禁止发送。', 20016: '消息撤回超过了时间限制(默认2分钟)。', 20018: '删除漫游内部错误。', 90001: 'JSON 格式解析失败,请检查请求包是否符合 JSON 规范。', 90002: ''.concat('JSON 格式请求包体', '中 MsgBody 不符合消息格式描述,或者 MsgBody 不是 Array 类型,请参考 TIMMsgElement 对象的定义(').concat(ur, '269/2720') - .concat(gr, ')。'), 90003: ''.concat('JSON 格式请求包体', '中缺少 To_Account 字段或者 To_Account 帐号不存在。'), 90005: ''.concat('JSON 格式请求包体', '中缺少 MsgRandom 字段或者 MsgRandom 字段不是 Integer 类型。'), 90006: ''.concat('JSON 格式请求包体', '中缺少 MsgTimeStamp 字段或者 MsgTimeStamp 字段不是 Integer 类型。'), 90007: ''.concat('JSON 格式请求包体', '中 MsgBody 类型不是 Array 类型,请将其修改为 Array 类型。'), 90008: ''.concat('JSON 格式请求包体', '中缺少 From_Account 字段或者 From_Account 帐号不存在。'), 90009: '请求需要 App 管理员权限。', 90010: ''.concat('JSON 格式请求包体', '不符合消息格式描述,请参考 TIMMsgElement 对象的定义(').concat(ur, '269/2720') - .concat(gr, ')。'), 90011: '批量发消息目标帐号超过500,请减少 To_Account 中目标帐号数量。', 90012: 'To_Account 没有注册或不存在,请确认 To_Account 是否导入即时通信 IM 或者是否拼写错误。', 90026: '消息离线存储时间错误(最多不能超过7天)。', 90031: ''.concat('JSON 格式请求包体', '中 SyncOtherMachine 字段不是 Integer 类型。'), 90044: ''.concat('JSON 格式请求包体', '中 MsgLifeTime 字段不是 Integer 类型。'), 90048: '请求的用户帐号不存在。', 90054: '撤回请求中的 MsgKey 不合法。', 90994: ''.concat('服务端内部错误,请重试。'), 90995: ''.concat('服务端内部错误,请重试。'), 91e3: ''.concat('服务端内部错误,请重试。'), 90992: ''.concat('服务端内部错误,请重试。', '如果所有请求都返回该错误码,且 App 配置了第三方回调,请检查 App 服务端是否正常向即时通信 IM 后台服务端返回回调结果。'), 93e3: 'JSON 数据包超长,消息包体请不要超过8k。', 91101: 'Web 端长轮询被踢(Web 端同时在线实例个数超出限制)。', 10002: ''.concat('服务端内部错误,请重试。'), 10003: '请求中的接口名称错误,请核对接口名称并重试。', 10004: '参数非法,请根据错误描述检查请求是否正确。', 10005: '请求包体中携带的帐号数量过多。', 10006: '操作频率限制,请尝试降低调用的频率。', 10007: '操作权限不足,例如 Work '.concat('群组', '中普通成员尝试执行踢人操作,但只有 App 管理员才有权限。'), 10008: '请求非法,可能是请求中携带的签名信息验证不正确,请再次尝试。', 10009: '该群不允许群主主动退出。', 10010: ''.concat('群组', '不存在,或者曾经存在过,但是目前已经被解散。'), 10011: '解析 JSON 包体失败,请检查包体的格式是否符合 JSON 格式。', 10012: '发起操作的 UserID 非法,请检查发起操作的用户 UserID 是否填写正确。', 10013: '被邀请加入的用户已经是群成员。', 10014: '群已满员,无法将请求中的用户加入'.concat('群组', ',如果是批量加人,可以尝试减少加入用户的数量。'), 10015: '找不到指定 ID 的'.concat('群组', '。'), 10016: 'App 后台通过第三方回调拒绝本次操作。', 10017: '因被禁言而不能发送消息,请检查发送者是否被设置禁言。', 10018: '应答包长度超过最大包长(1MB),请求的内容过多,请尝试减少单次请求的数据量。', 10019: '请求的用户帐号不存在。', 10021: ''.concat('群组', ' ID 已被使用,请选择其他的').concat('群组', ' ID。'), 10023: '发消息的频率超限,请延长两次发消息时间的间隔。', 10024: '此邀请或者申请请求已经被处理。', 10025: ''.concat('群组', ' ID 已被使用,并且操作者为群主,可以直接使用。'), 10026: '该 SDKAppID 请求的命令字已被禁用。', 10030: '请求撤回的消息不存在。', 10031: '消息撤回超过了时间限制(默认2分钟)。', 10032: '请求撤回的消息不支持撤回操作。', 10033: ''.concat('群组', '类型不支持消息撤回操作。'), 10034: '该消息类型不支持删除操作。', 10035: '直播群和在线成员广播大群不支持删除消息。', 10036: '直播群创建数量超过了限制,请参考价格说明('.concat(ur, '269/11673)购买预付费套餐“IM直播群”。'), 10037: '单个用户可创建和加入的'.concat('群组', '数量超过了限制,请参考价格说明(').concat(ur, '269/11673)购买或升级预付费套餐“单人可创建与加入') - .concat('群组', '数”。'), 10038: '群成员数量超过限制,请参考价格说明('.concat(ur, '269/11673)购买或升级预付费套餐“扩展群人数上限”。'), 10041: '该应用(SDKAppID)已配置不支持群消息撤回。', 30001: '请求参数错误,请根据错误描述检查请求参数', 30002: 'SDKAppID 不匹配', 30003: '请求的用户帐号不存在', 30004: '请求需要 App 管理员权限', 30005: '关系链字段中包含敏感词', 30006: ''.concat('服务端内部错误,请重试。'), 30007: ''.concat('网络超时,请稍后重试. '), 30008: '并发写导致写冲突,建议使用批量方式', 30009: '后台禁止该用户发起加好友请求', 30010: '自己的好友数已达系统上限', 30011: '分组已达系统上限', 30012: '未决数已达系统上限', 30014: '对方的好友数已达系统上限', 30515: '请求添加好友时,对方在自己的黑名单中,不允许加好友', 30516: '请求添加好友时,对方的加好友验证方式是不允许任何人添加自己为好友', 30525: '请求添加好友时,自己在对方的黑名单中,不允许加好友', 30539: '等待对方同意', 30540: '添加好友请求被安全策略打击,请勿频繁发起添加好友请求', 31704: '与请求删除的帐号之间不存在好友关系', 31707: '删除好友请求被安全策略打击,请勿频繁发起删除好友请求' }; const hr = (function (e) { - i(n, e);const t = f(n);function n(e) { - let a;return o(this, n), (a = t.call(this)).code = e.code, a.message = pr[e.code] || e.message, a.data = e.data || {}, a; - } return n; - }(g(Error))); let _r = null; const fr = function (e) { - _r = e; - }; const mr = function (e) { - return Promise.resolve(cr(e)); - }; const Mr = function (e) { - const t = arguments.length > 1 && void 0 !== arguments[1] && arguments[1];if (e instanceof hr) return t && null !== _r && _r.emit(E.ERROR, e), Promise.reject(e);if (e instanceof Error) { - const n = new hr({ code: Zn.UNCAUGHT_ERROR, message: e.message });return t && null !== _r && _r.emit(E.ERROR, n), Promise.reject(n); - } if (Ge(e) || Ge(e.code) || Ge(e.message))Ee.error('IMPromise.reject 必须指定code(错误码)和message(错误信息)!!!');else { - if (Ne(e.code) && Ae(e.message)) { - const o = new hr(e);return t && null !== _r && _r.emit(E.ERROR, o), Promise.reject(o); - }Ee.error('IMPromise.reject code(错误码)必须为数字,message(错误信息)必须为字符串!!!'); - } - }; const vr = (function (e) { - i(n, e);const t = f(n);function n(e) { - let a;return o(this, n), (a = t.call(this, e))._className = 'C2CModule', a; - } return s(n, [{ key: 'onNewC2CMessage', value(e) { - const t = e.dataList; const n = e.isInstantMessage; const o = e.C2CRemainingUnreadList;Ee.debug(''.concat(this._className, '.onNewC2CMessage count:').concat(t.length, ' isInstantMessage:') - .concat(n));const a = this._newC2CMessageStoredAndSummary({ dataList: t, C2CRemainingUnreadList: o, isInstantMessage: n }); const s = a.conversationOptionsList; const r = a.messageList;(this.filterModifiedMessage(r), s.length > 0) && this.getModule(Rt).onNewMessage({ conversationOptionsList: s, isInstantMessage: n });const i = this.filterUnmodifiedMessage(r);n && i.length > 0 && this.emitOuterEvent(E.MESSAGE_RECEIVED, i), r.length = 0; - } }, { key: '_newC2CMessageStoredAndSummary', value(e) { - for (var t = e.dataList, n = e.C2CRemainingUnreadList, o = e.isInstantMessage, a = null, s = [], r = [], i = {}, c = this.getModule(Ut), u = 0, l = t.length;u < l;u++) { - const d = t[u];d.currentUser = this.getMyUserID(), d.conversationType = k.CONV_C2C, d.isSystemMessage = !!d.isSystemMessage, a = new ir(d), d.elements = c.parseElements(d.elements, d.from), a.setElement(d.elements), a.setNickAndAvatar({ nick: d.nick, avatar: d.avatar });const g = a.conversationID;if (o) { - let p = !1; const h = this.getModule(Rt);if (a.from !== this.getMyUserID()) { - const _ = h.getLatestMessageSentByPeer(g);if (_) { - const f = _.nick; const m = _.avatar;f === a.nick && m === a.avatar || (p = !0); - } - } else { - const M = h.getLatestMessageSentByMe(g);if (M) { - const v = M.nick; const y = M.avatar;v === a.nick && y === a.avatar || h.modifyMessageSentByMe({ conversationID: g, latestNick: a.nick, latestAvatar: a.avatar }); - } - } let I = 1 === t[u].isModified;if (h.isMessageSentByCurrentInstance(a) ? a.isModified = I : I = !1, 0 === d.msgLifeTime)a.setOnlineOnlyFlag(!0), r.push(a);else { - if (!h.pushIntoMessageList(r, a, I)) continue;p && (h.modifyMessageSentByPeer(g), h.updateUserProfileSpecifiedKey({ conversationID: g, nick: a.nick, avatar: a.avatar })); - } this.getModule($t).addMessageDelay({ currentTime: Date.now(), time: a.time }); - } if (0 !== d.msgLifeTime) { - if (!1 === a.getOnlineOnlyFlag()) if (Ge(i[g]))i[g] = s.push({ conversationID: g, unreadCount: 'out' === a.flow ? 0 : 1, type: a.conversationType, subType: a.conversationSubType, lastMessage: a }) - 1;else { - const D = i[g];s[D].type = a.conversationType, s[D].subType = a.conversationSubType, s[D].lastMessage = a, 'in' === a.flow && s[D].unreadCount++; - } - } else a.setOnlineOnlyFlag(!0); - } if (Re(n)) for (let T = function (e, t) { - const o = s.find((t => t.conversationID === 'C2C'.concat(n[e].from)));o ? o.unreadCount += n[e].count : s.push({ conversationID: 'C2C'.concat(n[e].from), unreadCount: n[e].count, type: k.CONV_C2C, lastMsgTime: n[e].lastMsgTime }); - }, S = 0, E = n.length;S < E;S++)T(S);return { conversationOptionsList: s, messageList: r }; - } }, { key: 'onC2CMessageRevoked', value(e) { - const t = this;Ee.debug(''.concat(this._className, '.onC2CMessageRevoked count:').concat(e.dataList.length));const n = this.getModule(Rt); const o = []; let a = null;e.dataList.forEach(((e) => { - if (e.c2cMessageRevokedNotify) { - const s = e.c2cMessageRevokedNotify.revokedInfos;Ge(s) || s.forEach(((e) => { - const s = t.getMyUserID() === e.from ? ''.concat(k.CONV_C2C).concat(e.to) : ''.concat(k.CONV_C2C).concat(e.from);(a = n.revoke(s, e.sequence, e.random)) && o.push(a); - })); - } - })), 0 !== o.length && (n.onMessageRevoked(o), this.emitOuterEvent(E.MESSAGE_REVOKED, o)); - } }, { key: 'onC2CMessageReadReceipt', value(e) { - const t = this;e.dataList.forEach(((e) => { - if (!dt(e.c2cMessageReadReceipt)) { - const n = e.c2cMessageReadReceipt.to;e.c2cMessageReadReceipt.uinPairReadArray.forEach(((e) => { - const o = e.peerReadTime;Ee.debug(''.concat(t._className, '._onC2CMessageReadReceipt to:').concat(n, ' peerReadTime:') - .concat(o));const a = ''.concat(k.CONV_C2C).concat(n); const s = t.getModule(Rt);s.recordPeerReadTime(a, o), s.updateMessageIsPeerReadProperty(a, o); - })); - } - })); - } }, { key: 'onC2CMessageReadNotice', value(e) { - const t = this;e.dataList.forEach(((e) => { - if (!dt(e.c2cMessageReadNotice)) { - const n = t.getModule(Rt);e.c2cMessageReadNotice.uinPairReadArray.forEach(((e) => { - const o = e.from; const a = e.peerReadTime;Ee.debug(''.concat(t._className, '.onC2CMessageReadNotice from:').concat(o, ' lastReadTime:') - .concat(a));const s = ''.concat(k.CONV_C2C).concat(o);n.updateIsReadAfterReadReport({ conversationID: s, lastMessageTime: a }), n.updateUnreadCount(s); - })); - } - })); - } }, { key: 'sendMessage', value(e, t) { - const n = this._createC2CMessagePack(e, t);return this.request(n); - } }, { key: '_createC2CMessagePack', value(e, t) { - let n = null;t && (t.offlinePushInfo && (n = t.offlinePushInfo), !0 === t.onlineUserOnly && (n ? n.disablePush = !0 : n = { disablePush: !0 }));let o = '';return Ae(e.cloudCustomData) && e.cloudCustomData.length > 0 && (o = e.cloudCustomData), { protocolName: Zt, tjgID: this.generateTjgID(e), requestData: { fromAccount: this.getMyUserID(), toAccount: e.to, msgTimeStamp: Math.ceil(Date.now() / 1e3), msgBody: e.getElements(), cloudCustomData: o, msgSeq: e.sequence, msgRandom: e.random, msgLifeTime: this.isOnlineMessage(e, t) ? 0 : void 0, nick: e.nick, avatar: e.avatar, offlinePushInfo: n ? { pushFlag: !0 === n.disablePush ? 1 : 0, title: n.title || '', desc: n.description || '', ext: n.extension || '', apnsInfo: { badgeMode: !0 === n.ignoreIOSBadge ? 1 : 0 }, androidInfo: { OPPOChannelID: n.androidOPPOChannelID || '' } } : void 0 } }; - } }, { key: 'isOnlineMessage', value(e, t) { - return !(!t || !0 !== t.onlineUserOnly); - } }, { key: 'revokeMessage', value(e) { - return this.request({ protocolName: rn, requestData: { msgInfo: { fromAccount: e.from, toAccount: e.to, msgSeq: e.sequence, msgRandom: e.random, msgTimeStamp: e.time } } }); - } }, { key: 'deleteMessage', value(e) { - const t = e.to; const n = e.keyList;return Ee.log(''.concat(this._className, '.deleteMessage toAccount:').concat(t, ' count:') - .concat(n.length)), this.request({ protocolName: dn, requestData: { fromAccount: this.getMyUserID(), to: t, keyList: n } }); - } }, { key: 'setMessageRead', value(e) { - const t = this; const n = e.conversationID; const o = e.lastMessageTime; const a = ''.concat(this._className, '.setMessageRead');Ee.log(''.concat(a, ' conversationID:').concat(n, ' lastMessageTime:') - .concat(o)), Ne(o) || Ee.warn(''.concat(a, ' 请勿修改 Conversation.lastMessage.lastTime,否则可能会导致已读上报结果不准确'));const s = new Da(Ka);return s.setMessage('conversationID:'.concat(n, ' lastMessageTime:').concat(o)), this.request({ protocolName: cn, requestData: { C2CMsgReaded: { cookie: '', C2CMsgReadedItem: [{ toAccount: n.replace('C2C', ''), lastMessageTime: o, receipt: 1 }] } } }).then((() => { - s.setNetworkType(t.getNetworkType()).end(), Ee.log(''.concat(a, ' ok'));const e = t.getModule(Rt);return e.updateIsReadAfterReadReport({ conversationID: n, lastMessageTime: o }), e.updateUnreadCount(n), cr(); - })) - .catch((e => (t.probeNetwork().then(((t) => { - const n = m(t, 2); const o = n[0]; const a = n[1];s.setError(e, o, a).end(); - })), Ee.log(''.concat(a, ' failed. error:'), e), Mr(e)))); - } }, { key: 'getRoamingMessage', value(e) { - const t = this; const n = ''.concat(this._className, '.getRoamingMessage'); const o = e.peerAccount; const a = e.conversationID; const s = e.count; const r = e.lastMessageTime; const i = e.messageKey; const c = 'peerAccount:'.concat(o, ' count:').concat(s || 15, ' lastMessageTime:') - .concat(r || 0, ' messageKey:') - .concat(i);Ee.log(''.concat(n, ' ').concat(c));const u = new Da(Ua);return this.request({ protocolName: un, requestData: { peerAccount: o, count: s || 15, lastMessageTime: r || 0, messageKey: i } }).then(((e) => { - const o = e.data; const s = o.complete; const r = o.messageList; const i = o.messageKey;Ge(r) ? Ee.log(''.concat(n, ' ok. complete:').concat(s, ' but messageList is undefined!')) : Ee.log(''.concat(n, ' ok. complete:').concat(s, ' count:') - .concat(r.length)), u.setNetworkType(t.getNetworkType()).setMessage(''.concat(c, ' complete:').concat(s, ' length:') - .concat(r.length)) - .end();const l = t.getModule(Rt);1 === s && l.setCompleted(a);const d = l.storeRoamingMessage(r, a);l.modifyMessageList(a), l.updateIsRead(a), l.updateRoamingMessageKey(a, i);const g = l.getPeerReadTime(a);if (Ee.log(''.concat(n, ' update isPeerRead property. conversationID:').concat(a, ' peerReadTime:') - .concat(g)), g)l.updateMessageIsPeerReadProperty(a, g);else { - const p = a.replace(k.CONV_C2C, '');t.getRemotePeerReadTime([p]).then((() => { - l.updateMessageIsPeerReadProperty(a, l.getPeerReadTime(a)); - })); - } return d; - })) - .catch((e => (t.probeNetwork().then(((t) => { - const n = m(t, 2); const o = n[0]; const a = n[1];u.setMessage(c).setError(e, o, a) - .end(); - })), Ee.warn(''.concat(n, ' failed. error:'), e), Mr(e)))); - } }, { key: 'getRemotePeerReadTime', value(e) { - const t = this; const n = ''.concat(this._className, '.getRemotePeerReadTime');if (dt(e)) return Ee.warn(''.concat(n, ' userIDList is empty!')), Promise.resolve();const o = new Da(Ha);return Ee.log(''.concat(n, ' userIDList:').concat(e)), this.request({ protocolName: ln, requestData: { userIDList: e } }).then(((a) => { - const s = a.data.peerReadTimeList;Ee.log(''.concat(n, ' ok. peerReadTimeList:').concat(s));for (var r = '', i = t.getModule(Rt), c = 0;c < e.length;c++)r += ''.concat(e[c], '-').concat(s[c], ' '), s[c] > 0 && i.recordPeerReadTime('C2C'.concat(e[c]), s[c]);o.setNetworkType(t.getNetworkType()).setMessage(r) - .end(); - })) - .catch(((e) => { - t.probeNetwork().then(((t) => { - const n = m(t, 2); const a = n[0]; const s = n[1];o.setError(e, a, s).end(); - })), Ee.warn(''.concat(n, ' failed. error:'), e); - })); - } }]), n; - }(Yt)); const yr = (function () { - function e(t) { - o(this, e), this.list = new Map, this._className = 'MessageListHandler', this._latestMessageSentByPeerMap = new Map, this._latestMessageSentByMeMap = new Map, this._groupLocalLastMessageSequenceMap = new Map; - } return s(e, [{ key: 'getLocalOldestMessageByConversationID', value(e) { - if (!e) return null;if (!this.list.has(e)) return null;const t = this.list.get(e).values();return t ? t.next().value : null; - } }, { key: 'pushIn', value(e) { - const t = arguments.length > 1 && void 0 !== arguments[1] && arguments[1]; const n = e.conversationID; const o = e.ID; let a = !0;this.list.has(n) || this.list.set(n, new Map);const s = this.list.get(n).has(o);if (s) { - const r = this.list.get(n).get(o);if (!t || !0 === r.isModified) return a = !1; - } return this.list.get(n).set(o, e), this._setLatestMessageSentByPeer(n, e), this._setLatestMessageSentByMe(n, e), this._setGroupLocalLastMessageSequence(n, e), a; - } }, { key: 'unshift', value(e) { - let t;if (Re(e)) { - if (e.length > 0) { - t = e[0].conversationID;const n = e.length;this._unshiftMultipleMessages(e), this._setGroupLocalLastMessageSequence(t, e[n - 1]); - } - } else t = e.conversationID, this._unshiftSingleMessage(e), this._setGroupLocalLastMessageSequence(t, e);if (t && t.startsWith(k.CONV_C2C)) { - const o = Array.from(this.list.get(t).values()); const a = o.length;if (0 === a) return;for (let s = a - 1;s >= 0;s--) if ('out' === o[s].flow) { - this._setLatestMessageSentByMe(t, o[s]);break; - } for (let r = a - 1;r >= 0;r--) if ('in' === o[r].flow) { - this._setLatestMessageSentByPeer(t, o[r]);break; - } - } - } }, { key: '_unshiftSingleMessage', value(e) { - const t = e.conversationID; const n = e.ID;if (!this.list.has(t)) return this.list.set(t, new Map), void this.list.get(t).set(n, e);const o = Array.from(this.list.get(t));o.unshift([n, e]), this.list.set(t, new Map(o)); - } }, { key: '_unshiftMultipleMessages', value(e) { - for (var t = e.length, n = [], o = e[0].conversationID, a = this.list.has(o) ? Array.from(this.list.get(o)) : [], s = 0;s < t;s++)n.push([e[s].ID, e[s]]);this.list.set(o, new Map(n.concat(a))); - } }, { key: 'remove', value(e) { - const t = e.conversationID; const n = e.ID;this.list.has(t) && this.list.get(t).delete(n); - } }, { key: 'revoke', value(e, t, n) { - if (Ee.debug('revoke message', e, t, n), this.list.has(e)) { - let o; const a = S(this.list.get(e));try { - for (a.s();!(o = a.n()).done;) { - const s = m(o.value, 2)[1];if (s.sequence === t && !s.isRevoked && (Ge(n) || s.random === n)) return s.isRevoked = !0, s; - } - } catch (r) { - a.e(r); - } finally { - a.f(); - } - } return null; - } }, { key: 'removeByConversationID', value(e) { - this.list.has(e) && (this.list.delete(e), this._latestMessageSentByPeerMap.delete(e), this._latestMessageSentByMeMap.delete(e)); - } }, { key: 'updateMessageIsPeerReadProperty', value(e, t) { - const n = [];if (this.list.has(e)) { - let o; const a = S(this.list.get(e));try { - for (a.s();!(o = a.n()).done;) { - const s = m(o.value, 2)[1];s.time <= t && !s.isPeerRead && 'out' === s.flow && (s.isPeerRead = !0, n.push(s)); - } - } catch (r) { - a.e(r); - } finally { - a.f(); - }Ee.log(''.concat(this._className, '.updateMessageIsPeerReadProperty conversationID:').concat(e, ' peerReadTime:') - .concat(t, ' count:') - .concat(n.length)); - } return n; - } }, { key: 'updateMessageIsModifiedProperty', value(e) { - const t = e.conversationID; const n = e.ID;if (this.list.has(t)) { - const o = this.list.get(t).get(n);o && (o.isModified = !0); - } - } }, { key: 'hasLocalMessageList', value(e) { - return this.list.has(e); - } }, { key: 'getLocalMessageList', value(e) { - return this.hasLocalMessageList(e) ? M(this.list.get(e).values()) : []; - } }, { key: 'hasLocalMessage', value(e, t) { - return !!this.hasLocalMessageList(e) && this.list.get(e).has(t); - } }, { key: 'getLocalMessage', value(e, t) { - return this.hasLocalMessage(e, t) ? this.list.get(e).get(t) : null; - } }, { key: '_setLatestMessageSentByPeer', value(e, t) { - e.startsWith(k.CONV_C2C) && 'in' === t.flow && this._latestMessageSentByPeerMap.set(e, t); - } }, { key: '_setLatestMessageSentByMe', value(e, t) { - e.startsWith(k.CONV_C2C) && 'out' === t.flow && this._latestMessageSentByMeMap.set(e, t); - } }, { key: '_setGroupLocalLastMessageSequence', value(e, t) { - e.startsWith(k.CONV_GROUP) && this._groupLocalLastMessageSequenceMap.set(e, t.sequence); - } }, { key: 'getLatestMessageSentByPeer', value(e) { - return this._latestMessageSentByPeerMap.get(e); - } }, { key: 'getLatestMessageSentByMe', value(e) { - return this._latestMessageSentByMeMap.get(e); - } }, { key: 'getGroupLocalLastMessageSequence', value(e) { - return this._groupLocalLastMessageSequenceMap.get(e) || 0; - } }, { key: 'modifyMessageSentByPeer', value(e, t) { - const n = this.list.get(e);if (!dt(n)) { - const o = Array.from(n.values()); const a = o.length;if (0 !== a) { - let s = null; let r = null;t && (r = t);for (var i = 0, c = !1, u = a - 1;u >= 0;u--)'in' === o[u].flow && (null === r ? r = o[u] : ((s = o[u]).nick !== r.nick && (s.setNickAndAvatar({ nick: r.nick }), c = !0), s.avatar !== r.avatar && (s.setNickAndAvatar({ avatar: r.avatar }), c = !0), c && (i += 1)));Ee.log(''.concat(this._className, '.modifyMessageSentByPeer conversationID:').concat(e, ' count:') - .concat(i)); - } - } - } }, { key: 'modifyMessageSentByMe', value(e) { - const t = e.conversationID; const n = e.latestNick; const o = e.latestAvatar; const a = this.list.get(t);if (!dt(a)) { - const s = Array.from(a.values()); const r = s.length;if (0 !== r) { - for (var i = null, c = 0, u = !1, l = r - 1;l >= 0;l--)'out' === s[l].flow && ((i = s[l]).nick !== n && (i.setNickAndAvatar({ nick: n }), u = !0), i.avatar !== o && (i.setNickAndAvatar({ avatar: o }), u = !0), u && (c += 1));Ee.log(''.concat(this._className, '.modifyMessageSentByMe conversationID:').concat(t, ' count:') - .concat(c)); - } - } - } }, { key: 'traversal', value() { - if (0 !== this.list.size && -1 === Ee.getLevel()) { - console.group('conversationID-messageCount');let e; const t = S(this.list);try { - for (t.s();!(e = t.n()).done;) { - const n = m(e.value, 2); const o = n[0]; const a = n[1];console.log(''.concat(o, '-').concat(a.size)); - } - } catch (s) { - t.e(s); - } finally { - t.f(); - }console.groupEnd(); - } - } }, { key: 'reset', value() { - this.list.clear(), this._latestMessageSentByPeerMap.clear(), this._latestMessageSentByMeMap.clear(), this._groupLocalLastMessageSequenceMap.clear(); - } }]), e; - }()); const Ir = { CONTEXT_A2KEY_AND_TINYID_UPDATED: '_a2KeyAndTinyIDUpdated', CLOUD_CONFIG_UPDATED: '_cloudConfigUpdated' };function Dr(e) { - this.mixin(e); - }Dr.mixin = function (e) { - const t = e.prototype || e;t._isReady = !1, t.ready = function (e) { - const t = arguments.length > 1 && void 0 !== arguments[1] && arguments[1];if (e) return this._isReady ? void (t ? e.call(this) : setTimeout(e, 1)) : (this._readyQueue = this._readyQueue || [], void this._readyQueue.push(e)); - }, t.triggerReady = function () { - const e = this;this._isReady = !0, setTimeout((() => { - const t = e._readyQueue;e._readyQueue = [], t && t.length > 0 && t.forEach((function (e) { - e.call(this); - }), e); - }), 1); - }, t.resetReady = function () { - this._isReady = !1, this._readyQueue = []; - }, t.isReady = function () { - return this._isReady; - }; - };const Tr = ['jpg', 'jpeg', 'gif', 'png', 'bmp']; const Sr = ['mp4']; const Er = 1; const kr = 2; const Cr = 3; const Nr = 255; const Ar = (function () { - function e(t) { - const n = this;o(this, e), dt(t) || (this.userID = t.userID || '', this.nick = t.nick || '', this.gender = t.gender || '', this.birthday = t.birthday || 0, this.location = t.location || '', this.selfSignature = t.selfSignature || '', this.allowType = t.allowType || k.ALLOW_TYPE_ALLOW_ANY, this.language = t.language || 0, this.avatar = t.avatar || '', this.messageSettings = t.messageSettings || 0, this.adminForbidType = t.adminForbidType || k.FORBID_TYPE_NONE, this.level = t.level || 0, this.role = t.role || 0, this.lastUpdatedTime = 0, this.profileCustomField = [], dt(t.profileCustomField) || t.profileCustomField.forEach(((e) => { - n.profileCustomField.push({ key: e.key, value: e.value }); - }))); - } return s(e, [{ key: 'validate', value(e) { - let t = !0; let n = '';if (dt(e)) return { valid: !1, tips: 'empty options' };if (e.profileCustomField) for (let o = e.profileCustomField.length, a = null, s = 0;s < o;s++) { - if (a = e.profileCustomField[s], !Ae(a.key) || -1 === a.key.indexOf('Tag_Profile_Custom')) return { valid: !1, tips: '自定义资料字段的前缀必须是 Tag_Profile_Custom' };if (!Ae(a.value)) return { valid: !1, tips: '自定义资料字段的 value 必须是字符串' }; - } for (const r in e) if (Object.prototype.hasOwnProperty.call(e, r)) { - if ('profileCustomField' === r) continue;if (dt(e[r]) && !Ae(e[r]) && !Ne(e[r])) { - n = `key:${r}, invalid value:${e[r]}`, t = !1;continue; - } switch (r) { - case 'nick':Ae(e[r]) || (n = 'nick should be a string', t = !1), Be(e[r]) > 500 && (n = 'nick name limited: must less than or equal to '.concat(500, ' bytes, current size: ').concat(Be(e[r]), ' bytes'), t = !1);break;case 'gender':Ye(xs, e.gender) || (n = `key:gender, invalid value:${e.gender}`, t = !1);break;case 'birthday':Ne(e.birthday) || (n = 'birthday should be a number', t = !1);break;case 'location':Ae(e.location) || (n = 'location should be a string', t = !1);break;case 'selfSignature':Ae(e.selfSignature) || (n = 'selfSignature should be a string', t = !1);break;case 'allowType':Ye(Hs, e.allowType) || (n = `key:allowType, invalid value:${e.allowType}`, t = !1);break;case 'language':Ne(e.language) || (n = 'language should be a number', t = !1);break;case 'avatar':Ae(e.avatar) || (n = 'avatar should be a string', t = !1);break;case 'messageSettings':0 !== e.messageSettings && 1 !== e.messageSettings && (n = 'messageSettings should be 0 or 1', t = !1);break;case 'adminForbidType':Ye(Bs, e.adminForbidType) || (n = `key:adminForbidType, invalid value:${e.adminForbidType}`, t = !1);break;case 'level':Ne(e.level) || (n = 'level should be a number', t = !1);break;case 'role':Ne(e.role) || (n = 'role should be a number', t = !1);break;default:n = `unknown key:${r} ${e[r]}`, t = !1; - } - } return { valid: t, tips: n }; - } }]), e; - }()); const Or = function e(t) { - o(this, e), this.value = t, this.next = null; - }; const Lr = (function () { - function e(t) { - o(this, e), this.MAX_LENGTH = t, this.pTail = null, this.pNodeToDel = null, this.map = new Map, Ee.debug('SinglyLinkedList init MAX_LENGTH:'.concat(this.MAX_LENGTH)); - } return s(e, [{ key: 'set', value(e) { - const t = new Or(e);if (this.map.size < this.MAX_LENGTH)null === this.pTail ? (this.pTail = t, this.pNodeToDel = t) : (this.pTail.next = t, this.pTail = t), this.map.set(e, 1);else { - let n = this.pNodeToDel;this.pNodeToDel = this.pNodeToDel.next, this.map.delete(n.value), n.next = null, n = null, this.pTail.next = t, this.pTail = t, this.map.set(e, 1); - } - } }, { key: 'has', value(e) { - return this.map.has(e); - } }, { key: 'delete', value(e) { - this.has(e) && this.map.delete(e); - } }, { key: 'tail', value() { - return this.pTail; - } }, { key: 'size', value() { - return this.map.size; - } }, { key: 'data', value() { - return Array.from(this.map.keys()); - } }, { key: 'reset', value() { - for (var e;null !== this.pNodeToDel;)e = this.pNodeToDel, this.pNodeToDel = this.pNodeToDel.next, e.next = null, e = null;this.pTail = null, this.map.clear(); - } }]), e; - }()); const Rr = ['groupID', 'name', 'avatar', 'type', 'introduction', 'notification', 'ownerID', 'selfInfo', 'createTime', 'infoSequence', 'lastInfoTime', 'lastMessage', 'nextMessageSeq', 'memberNum', 'maxMemberNum', 'memberList', 'joinOption', 'groupCustomField', 'muteAllMembers']; const Gr = (function () { - function e(t) { - o(this, e), this.groupID = '', this.name = '', this.avatar = '', this.type = '', this.introduction = '', this.notification = '', this.ownerID = '', this.createTime = '', this.infoSequence = '', this.lastInfoTime = '', this.selfInfo = { messageRemindType: '', joinTime: '', nameCard: '', role: '' }, this.lastMessage = { lastTime: '', lastSequence: '', fromAccount: '', messageForShow: '' }, this.nextMessageSeq = '', this.memberNum = '', this.memberCount = '', this.maxMemberNum = '', this.maxMemberCount = '', this.joinOption = '', this.groupCustomField = [], this.muteAllMembers = void 0, this._initGroup(t); - } return s(e, [{ key: 'memberNum', get() { - return Ee.warn('!!!v2.8.0起弃用memberNum,请使用 memberCount'), this.memberCount; - }, set(e) {} }, { key: 'maxMemberNum', get() { - return Ee.warn('!!!v2.8.0起弃用maxMemberNum,请使用 maxMemberCount'), this.maxMemberCount; - }, set(e) {} }, { key: '_initGroup', value(e) { - for (const t in e)Rr.indexOf(t) < 0 || ('selfInfo' !== t ? ('memberNum' === t && (this.memberCount = e[t]), 'maxMemberNum' === t && (this.maxMemberCount = e[t]), this[t] = e[t]) : this.updateSelfInfo(e[t])); - } }, { key: 'updateGroup', value(e) { - const t = JSON.parse(JSON.stringify(e));t.lastMsgTime && (this.lastMessage.lastTime = t.lastMsgTime), Ge(t.muteAllMembers) || ('On' === t.muteAllMembers ? t.muteAllMembers = !0 : t.muteAllMembers = !1), t.groupCustomField && Qe(this.groupCustomField, t.groupCustomField), Ge(t.memberNum) || (this.memberCount = t.memberNum), Ge(t.maxMemberNum) || (this.maxMemberCount = t.maxMemberNum), Ke(this, t, ['members', 'errorCode', 'lastMsgTime', 'groupCustomField', 'memberNum', 'maxMemberNum']); - } }, { key: 'updateSelfInfo', value(e) { - const t = e.nameCard; const n = e.joinTime; const o = e.role; const a = e.messageRemindType;Ke(this.selfInfo, { nameCard: t, joinTime: n, role: o, messageRemindType: a }, [], ['', null, void 0, 0, NaN]); - } }, { key: 'setSelfNameCard', value(e) { - this.selfInfo.nameCard = e; - } }]), e; - }()); const wr = function (e, t) { - if (Ge(t)) return '';switch (e) { - case k.MSG_TEXT:return t.text;case k.MSG_IMAGE:return '[图片]';case k.MSG_GEO:return '[位置]';case k.MSG_AUDIO:return '[语音]';case k.MSG_VIDEO:return '[视频]';case k.MSG_FILE:return '[文件]';case k.MSG_CUSTOM:return '[自定义消息]';case k.MSG_GRP_TIP:return '[群提示消息]';case k.MSG_GRP_SYS_NOTICE:return '[群系统通知]';case k.MSG_FACE:return '[动画表情]';case k.MSG_MERGER:return '[聊天记录]';default:return ''; - } - }; const Pr = function (e) { - return Ge(e) ? { lastTime: 0, lastSequence: 0, fromAccount: 0, messageForShow: '', payload: null, type: '', isRevoked: !1, cloudCustomData: '', onlineOnlyFlag: !1 } : e instanceof ir ? { lastTime: e.time || 0, lastSequence: e.sequence || 0, fromAccount: e.from || '', messageForShow: wr(e.type, e.payload), payload: e.payload || null, type: e.type || null, isRevoked: e.isRevoked || !1, cloudCustomData: e.cloudCustomData || '', onlineOnlyFlag: !!Pe(e.getOnlineOnlyFlag) && e.getOnlineOnlyFlag() } : t(t({}, e), {}, { messageForShow: wr(e.type, e.payload) }); - }; const br = (function () { - function e(t) { - o(this, e), this.conversationID = t.conversationID || '', this.unreadCount = t.unreadCount || 0, this.type = t.type || '', this.lastMessage = Pr(t.lastMessage), t.lastMsgTime && (this.lastMessage.lastTime = t.lastMsgTime), this._isInfoCompleted = !1, this.peerReadTime = t.peerReadTime || 0, this.groupAtInfoList = [], this.remark = '', this._initProfile(t); - } return s(e, [{ key: 'toAccount', get() { - return this.conversationID.replace('C2C', '').replace('GROUP', ''); - } }, { key: 'subType', get() { - return this.groupProfile ? this.groupProfile.type : ''; - } }, { key: '_initProfile', value(e) { - const t = this;Object.keys(e).forEach(((n) => { - switch (n) { - case 'userProfile':t.userProfile = e.userProfile;break;case 'groupProfile':t.groupProfile = e.groupProfile; - } - })), Ge(this.userProfile) && this.type === k.CONV_C2C ? this.userProfile = new Ar({ userID: e.conversationID.replace('C2C', '') }) : Ge(this.groupProfile) && this.type === k.CONV_GROUP && (this.groupProfile = new Gr({ groupID: e.conversationID.replace('GROUP', '') })); - } }, { key: 'updateUnreadCount', value(e, t) { - Ge(e) || (et(this.subType) ? this.unreadCount = 0 : t && this.type === k.CONV_GROUP ? this.unreadCount = e : this.unreadCount = this.unreadCount + e); - } }, { key: 'updateLastMessage', value(e) { - this.lastMessage = Pr(e); - } }, { key: 'updateGroupAtInfoList', value(e) { - let t; let n = (v(t = e.groupAtType) || y(t) || I(t) || T()).slice(0);-1 !== n.indexOf(k.CONV_AT_ME) && -1 !== n.indexOf(k.CONV_AT_ALL) && (n = [k.CONV_AT_ALL_AT_ME]);const o = { from: e.from, groupID: e.groupID, messageSequence: e.sequence, atTypeArray: n, __random: e.__random, __sequence: e.__sequence };this.groupAtInfoList.push(o), Ee.debug('Conversation.updateGroupAtInfoList conversationID:'.concat(this.conversationID), this.groupAtInfoList); - } }, { key: 'clearGroupAtInfoList', value() { - this.groupAtInfoList.length = 0; - } }, { key: 'reduceUnreadCount', value() { - this.unreadCount >= 1 && (this.unreadCount -= 1); - } }, { key: 'isLastMessageRevoked', value(e) { - const t = e.sequence; const n = e.time;return this.type === k.CONV_C2C && t === this.lastMessage.lastSequence && n === this.lastMessage.lastTime || this.type === k.CONV_GROUP && t === this.lastMessage.lastSequence; - } }, { key: 'setLastMessageRevoked', value(e) { - this.lastMessage.isRevoked = e; - } }]), e; - }()); const Ur = (function (e) { - i(a, e);const n = f(a);function a(e) { - let t;return o(this, a), (t = n.call(this, e))._className = 'ConversationModule', Dr.mixin(h(t)), t._messageListHandler = new yr, t.singlyLinkedList = new Lr(100), t._pagingStatus = ft.NOT_START, t._pagingTimeStamp = 0, t._conversationMap = new Map, t._tmpGroupList = [], t._tmpGroupAtTipsList = [], t._peerReadTimeMap = new Map, t._completedMap = new Map, t._roamingMessageKeyMap = new Map, t._initListeners(), t; - } return s(a, [{ key: '_initListeners', value() { - this.getInnerEmitterInstance().on(Ir.CONTEXT_A2KEY_AND_TINYID_UPDATED, this._initLocalConversationList, this); - } }, { key: 'onCheckTimer', value(e) { - e % 60 == 0 && this._messageListHandler.traversal(); - } }, { key: '_initLocalConversationList', value() { - const e = this; const t = new Da(Qa);Ee.log(''.concat(this._className, '._initLocalConversationList.'));let n = ''; const o = this._getStorageConversationList();if (o) { - for (var a = o.length, s = 0;s < a;s++) { - const r = o[s];if (r && r.groupProfile) { - const i = r.groupProfile.type;if (et(i)) continue; - } this._conversationMap.set(o[s].conversationID, new br(o[s])); - } this._emitConversationUpdate(!0, !1), n = 'count:'.concat(a); - } else n = 'count:0';t.setNetworkType(this.getNetworkType()).setMessage(n) - .end(), this.getModule(Nt) || this.triggerReady(), this.ready((() => { - e._tmpGroupList.length > 0 && (e.updateConversationGroupProfile(e._tmpGroupList), e._tmpGroupList.length = 0); - })), this._syncConversationList(); - } }, { key: 'onMessageSent', value(e) { - this._onSendOrReceiveMessage(e.conversationOptionsList, !0); - } }, { key: 'onNewMessage', value(e) { - this._onSendOrReceiveMessage(e.conversationOptionsList, e.isInstantMessage); - } }, { key: '_onSendOrReceiveMessage', value(e) { - const t = this; const n = !(arguments.length > 1 && void 0 !== arguments[1]) || arguments[1];this._isReady ? 0 !== e.length && (this._getC2CPeerReadTime(e), this._updateLocalConversationList(e, !1, n), this._setStorageConversationList(), this._emitConversationUpdate()) : this.ready((() => { - t._onSendOrReceiveMessage(e, n); - })); - } }, { key: 'updateConversationGroupProfile', value(e) { - const t = this;Re(e) && 0 === e.length || (0 !== this._conversationMap.size ? (e.forEach(((e) => { - const n = 'GROUP'.concat(e.groupID);if (t._conversationMap.has(n)) { - const o = t._conversationMap.get(n);o.groupProfile = e, o.lastMessage.lastSequence < e.nextMessageSeq && (o.lastMessage.lastSequence = e.nextMessageSeq - 1), o.subType || (o.subType = e.type); - } - })), this._emitConversationUpdate(!0, !1)) : this._tmpGroupList = e); - } }, { key: '_updateConversationUserProfile', value(e) { - const t = this;e.data.forEach(((e) => { - const n = 'C2C'.concat(e.userID);t._conversationMap.has(n) && (t._conversationMap.get(n).userProfile = e); - })), this._emitConversationUpdate(!0, !1); - } }, { key: 'onMessageRevoked', value(e) { - const t = this;if (0 !== e.length) { - let n = null; let o = !1;e.forEach(((e) => { - (n = t._conversationMap.get(e.conversationID)) && n.isLastMessageRevoked(e) && (o = !0, n.setLastMessageRevoked(!0)); - })), o && this._emitConversationUpdate(!0, !1); - } - } }, { key: 'onMessageDeleted', value(e) { - if (0 !== e.length) { - e.forEach(((e) => { - e.isDeleted = !0; - }));for (var t = e[0].conversationID, n = this._messageListHandler.getLocalMessageList(t), o = {}, a = n.length - 1;a > 0;a--) if (!n[a].isDeleted) { - o = n[a];break; - } const s = this._conversationMap.get(t);if (s) { - let r = !1;s.lastMessage.lastSequence !== o.sequence && s.lastMessage.lastTime !== o.time && (s.updateLastMessage(o), r = !0, Ee.log(''.concat(this._className, '.onMessageDeleted. update conversationID:').concat(t, ' with lastMessage:'), s.lastMessage)), t.startsWith(k.CONV_C2C) && this.updateUnreadCount(t), r && this._emitConversationUpdate(!0, !1); - } - } - } }, { key: 'onNewGroupAtTips', value(e) { - const t = this; const n = e.dataList; let o = null;n.forEach(((e) => { - e.groupAtTips ? o = e.groupAtTips : e.elements && (o = e.elements), o.__random = e.random, o.__sequence = e.clientSequence, t._tmpGroupAtTipsList.push(o); - })), Ee.debug(''.concat(this._className, '.onNewGroupAtTips isReady:').concat(this._isReady), this._tmpGroupAtTipsList), this._isReady && this._handleGroupAtTipsList(); - } }, { key: '_handleGroupAtTipsList', value() { - const e = this;if (0 !== this._tmpGroupAtTipsList.length) { - let t = !1;this._tmpGroupAtTipsList.forEach(((n) => { - const o = n.groupID;if (n.from !== e.getMyUserID()) { - const a = e._conversationMap.get(''.concat(k.CONV_GROUP).concat(o));a && (a.updateGroupAtInfoList(n), t = !0); - } - })), t && this._emitConversationUpdate(!0, !1), this._tmpGroupAtTipsList.length = 0; - } - } }, { key: '_getC2CPeerReadTime', value(e) { - const t = this; const n = [];if (e.forEach(((e) => { - t._conversationMap.has(e.conversationID) || e.type !== k.CONV_C2C || n.push(e.conversationID.replace(k.CONV_C2C, '')); - })), n.length > 0) { - Ee.debug(''.concat(this._className, '._getC2CPeerReadTime userIDList:').concat(n));const o = this.getModule(Nt);o && o.getRemotePeerReadTime(n); - } - } }, { key: '_getStorageConversationList', value() { - return this.getModule(wt).getItem('conversationMap'); - } }, { key: '_setStorageConversationList', value() { - const e = this.getLocalConversationList().slice(0, 20) - .map((e => ({ conversationID: e.conversationID, type: e.type, subType: e.subType, lastMessage: e.lastMessage, groupProfile: e.groupProfile, userProfile: e.userProfile })));this.getModule(wt).setItem('conversationMap', e); - } }, { key: '_emitConversationUpdate', value() { - const e = !(arguments.length > 0 && void 0 !== arguments[0]) || arguments[0]; const t = !(arguments.length > 1 && void 0 !== arguments[1]) || arguments[1]; const n = M(this._conversationMap.values());if (t) { - const o = this.getModule(At);o && o.updateGroupLastMessage(n); - }e && this.emitOuterEvent(E.CONVERSATION_LIST_UPDATED, n); - } }, { key: 'getLocalConversationList', value() { - return M(this._conversationMap.values()); - } }, { key: 'getLocalConversation', value(e) { - return this._conversationMap.get(e); - } }, { key: '_syncConversationList', value() { - const e = this; const t = new Da(Za);return this._pagingStatus === ft.NOT_START && this._conversationMap.clear(), this._pagingGetConversationList().then((n => (e._pagingStatus = ft.RESOLVED, e._setStorageConversationList(), e._handleC2CPeerReadTime(), e.checkAndPatchRemark(), t.setMessage(e._conversationMap.size).setNetworkType(e.getNetworkType()) - .end(), n))) - .catch((n => (e._pagingStatus = ft.REJECTED, t.setMessage(e._pagingTimeStamp), e.probeNetwork().then(((e) => { - const o = m(e, 2); const a = o[0]; const s = o[1];t.setError(n, a, s).end(); - })), Mr(n)))); - } }, { key: '_pagingGetConversationList', value() { - const e = this; const t = ''.concat(this._className, '._pagingGetConversationList');return this._pagingStatus = ft.PENDING, this.request({ protocolName: gn, requestData: { fromAccount: this.getMyUserID(), timeStamp: this._pagingTimeStamp, orderType: 1, messageAssistFlags: 4 } }).then(((n) => { - const o = n.data; const a = o.completeFlag; const s = o.conversations; const r = void 0 === s ? [] : s; const i = o.timeStamp;if (Ee.log(''.concat(t, ' completeFlag:').concat(a, ' count:') - .concat(r.length)), r.length > 0) { - const c = e._getConversationOptions(r);e._updateLocalConversationList(c, !0); - } if (e._isReady)e._emitConversationUpdate();else { - if (!e.isLoggedIn()) return mr();e.triggerReady(); - } return e._pagingTimeStamp = i, 1 !== a ? e._pagingGetConversationList() : (e._handleGroupAtTipsList(), mr()); - })) - .catch(((n) => { - throw e.isLoggedIn() && (e._isReady || (Ee.warn(''.concat(t, ' failed. error:'), n), e.triggerReady())), n; - })); - } }, { key: '_updateLocalConversationList', value(e, t, n) { - let o; const a = Date.now();o = this._getTmpConversationListMapping(e, t, n), this._conversationMap = new Map(this._sortConversationList([].concat(M(o.toBeUpdatedConversationList), M(this._conversationMap)))), t || this._updateUserOrGroupProfile(o.newConversationList), Ee.debug(''.concat(this._className, '._updateLocalConversationList cost ').concat(Date.now() - a, ' ms')); - } }, { key: '_getTmpConversationListMapping', value(e, t, n) { - for (var o = [], a = [], s = this.getModule(At), r = this.getModule(Ot), i = 0, c = e.length;i < c;i++) { - const u = new br(e[i]); const l = u.conversationID;if (this._conversationMap.has(l)) { - const d = this._conversationMap.get(l); const g = ['unreadCount', 'allowType', 'adminForbidType', 'payload'];n || g.push('lastMessage'), Ke(d, u, g, [null, void 0, '', 0, NaN]), d.updateUnreadCount(u.unreadCount, t), n && (d.lastMessage.payload = e[i].lastMessage.payload), e[i].lastMessage && d.lastMessage.cloudCustomData !== e[i].lastMessage.cloudCustomData && (d.lastMessage.cloudCustomData = e[i].lastMessage.cloudCustomData || ''), this._conversationMap.delete(l), o.push([l, d]); - } else { - if (u.type === k.CONV_GROUP && s) { - const p = u.groupProfile.groupID; const h = s.getLocalGroupProfile(p);h && (u.groupProfile = h, u.updateUnreadCount(0)); - } else if (u.type === k.CONV_C2C) { - const _ = l.replace(k.CONV_C2C, '');r && r.isMyFriend(_) && (u.remark = r.getFriendRemark(_)); - }a.push(u), o.push([l, u]); - } - } return { toBeUpdatedConversationList: o, newConversationList: a }; - } }, { key: '_sortConversationList', value(e) { - return e.sort(((e, t) => t[1].lastMessage.lastTime - e[1].lastMessage.lastTime)); - } }, { key: '_updateUserOrGroupProfile', value(e) { - const t = this;if (0 !== e.length) { - const n = []; const o = []; const a = this.getModule(Ct); const s = this.getModule(At);e.forEach(((e) => { - if (e.type === k.CONV_C2C)n.push(e.toAccount);else if (e.type === k.CONV_GROUP) { - const t = e.toAccount;s.hasLocalGroup(t) ? e.groupProfile = s.getLocalGroupProfile(t) : o.push(t); - } - })), Ee.log(''.concat(this._className, '._updateUserOrGroupProfile c2cUserIDList:').concat(n, ' groupIDList:') - .concat(o)), n.length > 0 && a.getUserProfile({ userIDList: n }).then(((e) => { - const n = e.data;Re(n) ? n.forEach(((e) => { - t._conversationMap.get('C2C'.concat(e.userID)).userProfile = e; - })) : t._conversationMap.get('C2C'.concat(n.userID)).userProfile = n; - })), o.length > 0 && s.getGroupProfileAdvance({ groupIDList: o, responseFilter: { groupBaseInfoFilter: ['Type', 'Name', 'FaceUrl'] } }).then(((e) => { - e.data.successGroupList.forEach(((e) => { - const n = 'GROUP'.concat(e.groupID);if (t._conversationMap.has(n)) { - const o = t._conversationMap.get(n);Ke(o.groupProfile, e, [], [null, void 0, '', 0, NaN]), !o.subType && e.type && (o.subType = e.type); - } - })); - })); - } - } }, { key: '_getConversationOptions', value(e) { - const t = []; const n = e.filter(((e) => { - const t = e.lastMsg;return Le(t); - })).map(((e) => { - if (1 === e.type) { - const n = { userID: e.userID, nick: e.c2CNick, avatar: e.c2CImage };return t.push(n), { conversationID: 'C2C'.concat(e.userID), type: 'C2C', lastMessage: { lastTime: e.time, lastSequence: e.sequence, fromAccount: e.lastC2CMsgFromAccount, messageForShow: e.messageShow, type: e.lastMsg.elements[0] ? e.lastMsg.elements[0].type : null, payload: e.lastMsg.elements[0] ? e.lastMsg.elements[0].content : null, cloudCustomData: e.cloudCustomData || '', isRevoked: 8 === e.lastMessageFlag, onlineOnlyFlag: !1 }, userProfile: new Ar(n), peerReadTime: e.c2cPeerReadTime }; - } return { conversationID: 'GROUP'.concat(e.groupID), type: 'GROUP', lastMessage: { lastTime: e.time, lastSequence: e.messageReadSeq + e.unreadCount, fromAccount: e.msgGroupFromAccount, messageForShow: e.messageShow, type: e.lastMsg.elements[0] ? e.lastMsg.elements[0].type : null, payload: e.lastMsg.elements[0] ? e.lastMsg.elements[0].content : null, cloudCustomData: e.cloudCustomData || '', isRevoked: 2 === e.lastMessageFlag, onlineOnlyFlag: !1 }, groupProfile: new Gr({ groupID: e.groupID, name: e.groupNick, avatar: e.groupImage }), unreadCount: e.unreadCount, peerReadTime: 0 }; - }));t.length > 0 && this.getModule(Ct).onConversationsProfileUpdated(t);return n; - } }, { key: 'getLocalMessageList', value(e) { - return this._messageListHandler.getLocalMessageList(e); - } }, { key: 'deleteLocalMessage', value(e) { - e instanceof ir && this._messageListHandler.remove(e); - } }, { key: 'getMessageList', value(e) { - const t = this; const n = e.conversationID; const o = e.nextReqMessageID; let a = e.count; const s = ''.concat(this._className, '.getMessageList'); const r = this.getLocalConversation(n); let i = '';if (r && r.groupProfile && (i = r.groupProfile.type), et(i)) return Ee.log(''.concat(s, ' not available in avchatroom. conversationID:').concat(n)), mr({ messageList: [], nextReqMessageID: '', isCompleted: !0 });(Ge(a) || a > 15) && (a = 15);let c = this._computeLeftCount({ conversationID: n, nextReqMessageID: o });return Ee.log(''.concat(s, ' conversationID:').concat(n, ' leftCount:') - .concat(c, ' count:') - .concat(a, ' nextReqMessageID:') - .concat(o)), this._needGetHistory({ conversationID: n, leftCount: c, count: a }) ? this.getHistoryMessages({ conversationID: n, nextReqMessageID: o, count: 20 }).then((() => (c = t._computeLeftCount({ conversationID: n, nextReqMessageID: o }), cr(t._computeResult({ conversationID: n, nextReqMessageID: o, count: a, leftCount: c }))))) : (Ee.log(''.concat(s, '.getMessageList get message list from memory')), this.modifyMessageList(n), mr(this._computeResult({ conversationID: n, nextReqMessageID: o, count: a, leftCount: c }))); - } }, { key: '_computeLeftCount', value(e) { - const t = e.conversationID; const n = e.nextReqMessageID;return n ? this._messageListHandler.getLocalMessageList(t).findIndex((e => e.ID === n)) : this._getMessageListSize(t); - } }, { key: '_getMessageListSize', value(e) { - return this._messageListHandler.getLocalMessageList(e).length; - } }, { key: '_needGetHistory', value(e) { - const t = e.conversationID; const n = e.leftCount; const o = e.count; const a = this.getLocalConversation(t); let s = '';return a && a.groupProfile && (s = a.groupProfile.type), !nt(t) && !et(s) && (n < o && !this._completedMap.has(t)); - } }, { key: '_computeResult', value(e) { - const t = e.conversationID; const n = e.nextReqMessageID; const o = e.count; const a = e.leftCount; const s = this._computeMessageList({ conversationID: t, nextReqMessageID: n, count: o }); const r = this._computeIsCompleted({ conversationID: t, leftCount: a, count: o }); const i = this._computeNextReqMessageID({ messageList: s, isCompleted: r, conversationID: t }); const c = ''.concat(this._className, '._computeResult. conversationID:').concat(t);return Ee.log(''.concat(c, ' leftCount:').concat(a, ' count:') - .concat(o, ' nextReqMessageID:') - .concat(i, ' isCompleted:') - .concat(r)), { messageList: s, nextReqMessageID: i, isCompleted: r }; - } }, { key: '_computeMessageList', value(e) { - const t = e.conversationID; const n = e.nextReqMessageID; const o = e.count; const a = this._messageListHandler.getLocalMessageList(t); const s = this._computeIndexEnd({ nextReqMessageID: n, messageList: a }); const r = this._computeIndexStart({ indexEnd: s, count: o });return a.slice(r, s); - } }, { key: '_computeNextReqMessageID', value(e) { - const t = e.messageList; const n = e.isCompleted; const o = e.conversationID;if (!n) return 0 === t.length ? '' : t[0].ID;const a = this._messageListHandler.getLocalMessageList(o);return 0 === a.length ? '' : a[0].ID; - } }, { key: '_computeIndexEnd', value(e) { - const t = e.messageList; const n = void 0 === t ? [] : t; const o = e.nextReqMessageID;return o ? n.findIndex((e => e.ID === o)) : n.length; - } }, { key: '_computeIndexStart', value(e) { - const t = e.indexEnd; const n = e.count;return t > n ? t - n : 0; - } }, { key: '_computeIsCompleted', value(e) { - const t = e.conversationID;return !!(e.leftCount <= e.count && this._completedMap.has(t)); - } }, { key: 'getHistoryMessages', value(e) { - const t = e.conversationID; const n = e.nextReqMessageID;if (t === k.CONV_SYSTEM) return mr();e.count ? e.count > 20 && (e.count = 20) : e.count = 15;let o = this._messageListHandler.getLocalOldestMessageByConversationID(t);o || ((o = {}).time = 0, o.sequence = 0, 0 === t.indexOf(k.CONV_C2C) ? (o.to = t.replace(k.CONV_C2C, ''), o.conversationType = k.CONV_C2C) : 0 === t.indexOf(k.CONV_GROUP) && (o.to = t.replace(k.CONV_GROUP, ''), o.conversationType = k.CONV_GROUP));let a = ''; let s = null;switch (o.conversationType) { - case k.CONV_C2C:return a = t.replace(k.CONV_C2C, ''), (s = this.getModule(Nt)) ? s.getRoamingMessage({ conversationID: e.conversationID, peerAccount: a, count: e.count, lastMessageTime: this._roamingMessageKeyMap.has(t) ? o.time : 0, messageKey: this._roamingMessageKeyMap.get(t) }) : Mr({ code: Zn.CANNOT_FIND_MODULE, message: ra });case k.CONV_GROUP:return (s = this.getModule(At)) ? s.getRoamingMessage({ conversationID: e.conversationID, groupID: o.to, count: e.count, sequence: n && !1 === o.getOnlineOnlyFlag() ? o.sequence - 1 : o.sequence }) : Mr({ code: Zn.CANNOT_FIND_MODULE, message: ra });default:return mr(); - } - } }, { key: 'patchConversationLastMessage', value(e) { - const t = this.getLocalConversation(e);if (t) { - const n = t.lastMessage; const o = n.messageForShow; const a = n.payload;if (dt(o) || dt(a)) { - const s = this._messageListHandler.getLocalMessageList(e);if (0 === s.length) return;const r = s[s.length - 1];Ee.log(''.concat(this._className, '.patchConversationLastMessage conversationID:').concat(e, ' payload:'), r.payload), t.updateLastMessage(r); - } - } - } }, { key: 'storeRoamingMessage', value() { - const e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : []; const n = arguments.length > 1 ? arguments[1] : void 0; const o = n.startsWith(k.CONV_C2C) ? k.CONV_C2C : k.CONV_GROUP; let a = null; const s = []; let r = 0; let i = e.length; let c = null; const u = o === k.CONV_GROUP; const l = this.getModule(Ut); let d = function () { - r = u ? e.length - 1 : 0, i = u ? 0 : e.length; - }; let g = function () { - u ? --r : ++r; - }; let p = function () { - return u ? r >= i : r < i; - };for (d();p();g()) if (u && 1 === e[r].sequence && this.setCompleted(n), 1 !== e[r].isPlaceMessage) if ((a = new ir(e[r])).to = e[r].to, a.isSystemMessage = !!e[r].isSystemMessage, a.conversationType = o, 4 === e[r].event ? c = { type: k.MSG_GRP_TIP, content: t(t({}, e[r].elements), {}, { groupProfile: e[r].groupProfile }) } : (e[r].elements = l.parseElements(e[r].elements, e[r].from), c = e[r].elements), u || a.setNickAndAvatar({ nick: e[r].nick, avatar: e[r].avatar }), dt(c)) { - const h = new Da(Ba);h.setMessage('from:'.concat(a.from, ' to:').concat(a.to, ' sequence:') - .concat(a.sequence, ' event:') - .concat(e[r].event)), h.setNetworkType(this.getNetworkType()).setLevel('warning') - .end(); - } else a.setElement(c), a.reInitialize(this.getMyUserID()), s.push(a);return this._messageListHandler.unshift(s), d = g = p = null, s; - } }, { key: 'setMessageRead', value(e) { - const t = e.conversationID; const n = e.messageID; const o = this.getLocalConversation(t);if (Ee.log(''.concat(this._className, '.setMessageRead conversationID:').concat(t, ' unreadCount:') - .concat(o ? o.unreadCount : 0)), !o) return mr();if (o.type !== k.CONV_GROUP || dt(o.groupAtInfoList) || this.deleteGroupAtTips(t), 0 === o.unreadCount) return mr();const a = this._messageListHandler.getLocalMessage(t, n); let s = null;switch (o.type) { - case k.CONV_C2C:return (s = this.getModule(Nt)) ? s.setMessageRead({ conversationID: t, lastMessageTime: a ? a.time : o.lastMessage.lastTime }) : Mr({ code: Zn.CANNOT_FIND_MODULE, message: ra });case k.CONV_GROUP:return (s = this._moduleManager.getModule(At)) ? s.setMessageRead({ conversationID: t, lastMessageSeq: a ? a.sequence : o.lastMessage.lastSequence }) : Mr({ code: Zn.CANNOT_FIND_MODULE, message: ra });case k.CONV_SYSTEM:return o.unreadCount = 0, this._emitConversationUpdate(!0, !1), mr();default:return mr(); - } - } }, { key: 'updateIsReadAfterReadReport', value(e) { - const t = e.conversationID; const n = e.lastMessageSeq; const o = e.lastMessageTime; const a = this._messageListHandler.getLocalMessageList(t);if (0 !== a.length) for (var s, r = a.length - 1;r >= 0;r--) if (s = a[r], !(o && s.time > o || n && s.sequence > n)) { - if ('in' === s.flow && s.isRead) break;s.setIsRead(!0); - } - } }, { key: 'updateUnreadCount', value(e) { - const t = this.getLocalConversation(e); const n = this._messageListHandler.getLocalMessageList(e);if (t) { - const o = t.unreadCount; const a = n.filter((e => !e.isRead && !e.getOnlineOnlyFlag() && !e.isDeleted)).length;o !== a && (t.unreadCount = a, Ee.log(''.concat(this._className, '.updateUnreadCount from ').concat(o, ' to ') - .concat(a, ', conversationID:') - .concat(e)), this._emitConversationUpdate(!0, !1)); - } - } }, { key: 'updateIsRead', value(e) { - const t = this.getLocalConversation(e); const n = this.getLocalMessageList(e);if (t && 0 !== n.length && !nt(t.type)) { - for (var o = [], a = 0, s = n.length;a < s;a++)'in' !== n[a].flow ? 'out' !== n[a].flow || n[a].isRead || n[a].setIsRead(!0) : o.push(n[a]);let r = 0;if (t.type === k.CONV_C2C) { - const i = o.slice(-t.unreadCount).filter((e => e.isRevoked)).length;r = o.length - t.unreadCount - i; - } else r = o.length - t.unreadCount;for (let c = 0;c < r && !o[c].isRead;c++)o[c].setIsRead(!0); - } - } }, { key: 'deleteGroupAtTips', value(e) { - const t = ''.concat(this._className, '.deleteGroupAtTips');Ee.log(''.concat(t));const n = this._conversationMap.get(e);if (!n) return Promise.resolve();const o = n.groupAtInfoList;if (0 === o.length) return Promise.resolve();const a = this.getMyUserID();return this.request({ protocolName: _n, requestData: { messageListToDelete: o.map((e => ({ from: e.from, to: a, messageSeq: e.__sequence, messageRandom: e.__random, groupID: e.groupID }))) } }).then((() => (Ee.log(''.concat(t, ' ok. count:').concat(o.length)), n.clearGroupAtInfoList(), Promise.resolve()))) - .catch((e => (Ee.error(''.concat(t, ' failed. error:'), e), Mr(e)))); - } }, { key: 'appendToMessageList', value(e) { - this._messageListHandler.pushIn(e); - } }, { key: 'setMessageRandom', value(e) { - this.singlyLinkedList.set(e.random); - } }, { key: 'deleteMessageRandom', value(e) { - this.singlyLinkedList.delete(e.random); - } }, { key: 'pushIntoMessageList', value(e, t, n) { - return !(!this._messageListHandler.pushIn(t, n) || this._isMessageFromCurrentInstance(t) && !n) && (e.push(t), !0); - } }, { key: '_isMessageFromCurrentInstance', value(e) { - return this.singlyLinkedList.has(e.random); - } }, { key: 'revoke', value(e, t, n) { - return this._messageListHandler.revoke(e, t, n); - } }, { key: 'getPeerReadTime', value(e) { - return this._peerReadTimeMap.get(e); - } }, { key: 'recordPeerReadTime', value(e, t) { - this._peerReadTimeMap.has(e) ? this._peerReadTimeMap.get(e) < t && this._peerReadTimeMap.set(e, t) : this._peerReadTimeMap.set(e, t); - } }, { key: 'updateMessageIsPeerReadProperty', value(e, t) { - if (e.startsWith(k.CONV_C2C) && t > 0) { - const n = this._messageListHandler.updateMessageIsPeerReadProperty(e, t);n.length > 0 && this.emitOuterEvent(E.MESSAGE_READ_BY_PEER, n); - } - } }, { key: 'updateMessageIsReadProperty', value(e) { - const t = this.getLocalConversation(e); const n = this._messageListHandler.getLocalMessageList(e);if (t && 0 !== n.length && !nt(t.type)) { - for (var o = [], a = 0;a < n.length;a++)'in' !== n[a].flow ? 'out' !== n[a].flow || n[a].isRead || n[a].setIsRead(!0) : o.push(n[a]);let s = 0;if (t.type === k.CONV_C2C) { - const r = o.slice(-t.unreadCount).filter((e => e.isRevoked)).length;s = o.length - t.unreadCount - r; - } else s = o.length - t.unreadCount;for (let i = 0;i < s && !o[i].isRead;i++)o[i].setIsRead(!0); - } - } }, { key: 'updateMessageIsModifiedProperty', value(e) { - this._messageListHandler.updateMessageIsModifiedProperty(e); - } }, { key: 'setCompleted', value(e) { - Ee.log(''.concat(this._className, '.setCompleted. conversationID:').concat(e)), this._completedMap.set(e, !0); - } }, { key: 'updateRoamingMessageKey', value(e, t) { - this._roamingMessageKeyMap.set(e, t); - } }, { key: 'getConversationList', value() { - const e = this; const t = ''.concat(this._className, '.getConversationList');Ee.log(t), this._pagingStatus === ft.REJECTED && (Ee.log(''.concat(t, '. continue to sync conversationList')), this._syncConversationList());const n = new Da(Wa);return this.request({ protocolName: pn, requestData: { fromAccount: this.getMyUserID() } }).then(((o) => { - const a = o.data.conversations; const s = void 0 === a ? [] : a; const r = e._getConversationOptions(s);return e._updateLocalConversationList(r, !0), e._setStorageConversationList(), e._handleC2CPeerReadTime(), n.setMessage('conversation count: '.concat(s.length)).setNetworkType(e.getNetworkType()) - .end(), Ee.log(''.concat(t, ' ok')), mr({ conversationList: e.getLocalConversationList() }); - })) - .catch((o => (e.probeNetwork().then(((e) => { - const t = m(e, 2); const a = t[0]; const s = t[1];n.setError(o, a, s).end(); - })), Ee.error(''.concat(t, ' failed. error:'), o), Mr(o)))); - } }, { key: '_handleC2CPeerReadTime', value() { - let e; const t = S(this._conversationMap);try { - for (t.s();!(e = t.n()).done;) { - const n = m(e.value, 2); const o = n[0]; const a = n[1];a.type === k.CONV_C2C && (Ee.debug(''.concat(this._className, '._handleC2CPeerReadTime conversationID:').concat(o, ' peerReadTime:') - .concat(a.peerReadTime)), this.recordPeerReadTime(o, a.peerReadTime)); - } - } catch (s) { - t.e(s); - } finally { - t.f(); - } - } }, { key: 'getConversationProfile', value(e) { - let t; const n = this;if ((t = this._conversationMap.has(e) ? this._conversationMap.get(e) : new br({ conversationID: e, type: e.slice(0, 3) === k.CONV_C2C ? k.CONV_C2C : k.CONV_GROUP }))._isInfoCompleted || t.type === k.CONV_SYSTEM) return mr({ conversation: t });const o = new Da(Ja); const a = ''.concat(this._className, '.getConversationProfile');return Ee.log(''.concat(a, '. conversationID:').concat(e, ' remark:') - .concat(t.remark, ' lastMessage:'), t.lastMessage), this._updateUserOrGroupProfileCompletely(t).then(((s) => { - o.setNetworkType(n.getNetworkType()).setMessage('conversationID:'.concat(e, ' unreadCount:').concat(s.data.conversation.unreadCount)) - .end();const r = n.getModule(Ot);if (r && t.type === k.CONV_C2C) { - const i = e.replace(k.CONV_C2C, '');if (r.isMyFriend(i)) { - const c = r.getFriendRemark(i);t.remark !== c && (t.remark = c, Ee.log(''.concat(a, '. conversationID:').concat(e, ' patch remark:') - .concat(t.remark))); - } - } return Ee.log(''.concat(a, ' ok. conversationID:').concat(e)), s; - })) - .catch((t => (n.probeNetwork().then(((n) => { - const a = m(n, 2); const s = a[0]; const r = a[1];o.setError(t, s, r).setMessage('conversationID:'.concat(e)) - .end(); - })), Ee.error(''.concat(a, ' failed. error:'), t), Mr(t)))); - } }, { key: '_updateUserOrGroupProfileCompletely', value(e) { - const t = this;return e.type === k.CONV_C2C ? this.getModule(Ct).getUserProfile({ userIDList: [e.toAccount] }) - .then(((n) => { - const o = n.data;return 0 === o.length ? Mr(new hr({ code: Zn.USER_OR_GROUP_NOT_FOUND, message: Go })) : (e.userProfile = o[0], e._isInfoCompleted = !0, t._unshiftConversation(e), mr({ conversation: e })); - })) : this.getModule(At).getGroupProfile({ groupID: e.toAccount }) - .then((n => (e.groupProfile = n.data.group, e._isInfoCompleted = !0, t._unshiftConversation(e), mr({ conversation: e })))); - } }, { key: '_unshiftConversation', value(e) { - e instanceof br && !this._conversationMap.has(e.conversationID) && (this._conversationMap = new Map([[e.conversationID, e]].concat(M(this._conversationMap))), this._setStorageConversationList(), this._emitConversationUpdate(!0, !1)); - } }, { key: 'deleteConversation', value(e) { - const t = this; const n = { fromAccount: this.getMyUserID(), toAccount: void 0, type: void 0 };if (!this._conversationMap.has(e)) { - const o = new hr({ code: Zn.CONVERSATION_NOT_FOUND, message: Ro });return Mr(o); - } switch (this._conversationMap.get(e).type) { - case k.CONV_C2C:n.type = 1, n.toAccount = e.replace(k.CONV_C2C, '');break;case k.CONV_GROUP:n.type = 2, n.toGroupID = e.replace(k.CONV_GROUP, '');break;case k.CONV_SYSTEM:return this.getModule(At).deleteGroupSystemNotice({ messageList: this._messageListHandler.getLocalMessageList(e) }), this.deleteLocalConversation(e), mr({ conversationID: e });default:var a = new hr({ code: Zn.CONVERSATION_UN_RECORDED_TYPE, message: wo });return Mr(a); - } const s = new Da(Xa);s.setMessage('conversationID:'.concat(e));const r = ''.concat(this._className, '.deleteConversation');return Ee.log(''.concat(r, '. conversationID:').concat(e)), this.setMessageRead({ conversationID: e }).then((() => t.request({ protocolName: hn, requestData: n }))) - .then((() => (s.setNetworkType(t.getNetworkType()).end(), Ee.log(''.concat(r, ' ok')), t.deleteLocalConversation(e), mr({ conversationID: e })))) - .catch((e => (t.probeNetwork().then(((t) => { - const n = m(t, 2); const o = n[0]; const a = n[1];s.setError(e, o, a).end(); - })), Ee.error(''.concat(r, ' failed. error:'), e), Mr(e)))); - } }, { key: 'deleteLocalConversation', value(e) { - this._conversationMap.delete(e), this._setStorageConversationList(), this._messageListHandler.removeByConversationID(e), this._completedMap.delete(e), this._emitConversationUpdate(!0, !1); - } }, { key: 'isMessageSentByCurrentInstance', value(e) { - return !(!this._messageListHandler.hasLocalMessage(e.conversationID, e.ID) && !this.singlyLinkedList.has(e.random)); - } }, { key: 'modifyMessageList', value(e) { - if (e.startsWith(k.CONV_C2C)) { - const t = Date.now();this._messageListHandler.modifyMessageSentByPeer(e);const n = this.getModule(Ct).getNickAndAvatarByUserID(this.getMyUserID());this._messageListHandler.modifyMessageSentByMe({ conversationID: e, latestNick: n.nick, latestAvatar: n.avatar }), Ee.log(''.concat(this._className, '.modifyMessageList conversationID:').concat(e, ' cost ') - .concat(Date.now() - t, ' ms')); - } - } }, { key: 'updateUserProfileSpecifiedKey', value(e) { - Ee.log(''.concat(this._className, '.updateUserProfileSpecifiedKey options:'), e);const t = e.conversationID; const n = e.nick; const o = e.avatar;if (this._conversationMap.has(t)) { - const a = this._conversationMap.get(t).userProfile;Ae(n) && a.nick !== n && (a.nick = n), Ae(o) && a.avatar !== o && (a.avatar = o), this._emitConversationUpdate(!0, !1); - } - } }, { key: 'onMyProfileModified', value(e) { - const n = this; const o = this.getLocalConversationList(); const a = Date.now();o.forEach(((o) => { - n.modifyMessageSentByMe(t({ conversationID: o.conversationID }, e)); - })), Ee.log(''.concat(this._className, '.onMyProfileModified. modify all messages sent by me, cost ').concat(Date.now() - a, ' ms')); - } }, { key: 'modifyMessageSentByMe', value(e) { - this._messageListHandler.modifyMessageSentByMe(e); - } }, { key: 'getLatestMessageSentByMe', value(e) { - return this._messageListHandler.getLatestMessageSentByMe(e); - } }, { key: 'modifyMessageSentByPeer', value(e, t) { - this._messageListHandler.modifyMessageSentByPeer(e, t); - } }, { key: 'getLatestMessageSentByPeer', value(e) { - return this._messageListHandler.getLatestMessageSentByPeer(e); - } }, { key: 'pushIntoNoticeResult', value(e, t) { - return !(!this._messageListHandler.pushIn(t) || this.singlyLinkedList.has(t.random)) && (e.push(t), !0); - } }, { key: 'getGroupLocalLastMessageSequence', value(e) { - return this._messageListHandler.getGroupLocalLastMessageSequence(e); - } }, { key: 'checkAndPatchRemark', value() { - if (0 !== this._conversationMap.size) { - const e = this.getModule(Ot);if (e) { - const t = M(this._conversationMap.values()).filter((e => e.type === k.CONV_C2C));if (0 !== t.length) { - let n = !1; let o = 0;t.forEach(((t) => { - const a = t.conversationID.replace(k.CONV_C2C, '');if (e.isMyFriend(a)) { - const s = e.getFriendRemark(a);t.remark !== s && (t.remark = s, o += 1, n = !0); - } - })), Ee.log(''.concat(this._className, '.checkAndPatchRemark. c2c conversation count:').concat(t.length, ', patched count:') - .concat(o)), n && this._emitConversationUpdate(!0, !1); - } - } - } - } }, { key: 'reset', value() { - Ee.log(''.concat(this._className, '.reset')), this._pagingStatus = ft.NOT_START, this._messageListHandler.reset(), this._roamingMessageKeyMap.clear(), this.singlyLinkedList.reset(), this._peerReadTimeMap.clear(), this._completedMap.clear(), this._conversationMap.clear(), this._pagingTimeStamp = 0, this.resetReady(); - } }]), a; - }(Yt)); const Fr = (function () { - function e(t) { - o(this, e), this._groupModule = t, this._className = 'GroupTipsHandler', this._cachedGroupTipsMap = new Map, this._checkCountMap = new Map, this.MAX_CHECK_COUNT = 4; - } return s(e, [{ key: 'onCheckTimer', value(e) { - e % 1 == 0 && this._cachedGroupTipsMap.size > 0 && this._checkCachedGroupTips(); - } }, { key: '_checkCachedGroupTips', value() { - const e = this;this._cachedGroupTipsMap.forEach(((t, n) => { - let o = e._checkCountMap.get(n); const a = e._groupModule.hasLocalGroup(n);Ee.log(''.concat(e._className, '._checkCachedGroupTips groupID:').concat(n, ' hasLocalGroup:') - .concat(a, ' checkCount:') - .concat(o)), a ? (e._notifyCachedGroupTips(n), e._checkCountMap.delete(n), e._groupModule.deleteUnjoinedAVChatRoom(n)) : o >= e.MAX_CHECK_COUNT ? (e._deleteCachedGroupTips(n), e._checkCountMap.delete(n)) : (o++, e._checkCountMap.set(n, o)); - })); - } }, { key: 'onNewGroupTips', value(e) { - Ee.debug(''.concat(this._className, '.onReceiveGroupTips count:').concat(e.dataList.length));const t = this.newGroupTipsStoredAndSummary(e); const n = t.eventDataList; const o = t.result; const a = t.AVChatRoomMessageList;(a.length > 0 && this._groupModule.onAVChatRoomMessage(a), n.length > 0) && (this._groupModule.getModule(Rt).onNewMessage({ conversationOptionsList: n, isInstantMessage: !0 }), this._groupModule.updateNextMessageSeq(n));o.length > 0 && (this._groupModule.emitOuterEvent(E.MESSAGE_RECEIVED, o), this.handleMessageList(o)); - } }, { key: 'newGroupTipsStoredAndSummary', value(e) { - for (var n = e.event, o = e.dataList, a = null, s = [], r = [], i = {}, c = [], u = 0, l = o.length;u < l;u++) { - const d = o[u]; const g = d.groupProfile.groupID; const p = this._groupModule.hasLocalGroup(g);if (p || !this._groupModule.isUnjoinedAVChatRoom(g)) if (p) if (this._groupModule.isMessageFromAVChatroom(g)) { - const h = Xe(d);h.event = n, c.push(h); - } else { - d.currentUser = this._groupModule.getMyUserID(), d.conversationType = k.CONV_GROUP, (a = new ir(d)).setElement({ type: k.MSG_GRP_TIP, content: t(t({}, d.elements), {}, { groupProfile: d.groupProfile }) }), a.isSystemMessage = !1;const _ = this._groupModule.getModule(Rt); const f = a.conversationID;if (6 === n)a.setOnlineOnlyFlag(!0), r.push(a);else if (!_.pushIntoNoticeResult(r, a)) continue;if (6 !== n || !_.getLocalConversation(f)) { - if (6 !== n) this._groupModule.getModule($t).addMessageSequence({ key: fa, message: a });if (Ge(i[f]))i[f] = s.push({ conversationID: f, unreadCount: 'in' === a.flow && a.getOnlineOnlyFlag() ? 0 : 1, type: a.conversationType, subType: a.conversationSubType, lastMessage: a }) - 1;else { - const m = i[f];s[m].type = a.conversationType, s[m].subType = a.conversationSubType, s[m].lastMessage = a, 'in' !== a.flow || a.getOnlineOnlyFlag() || s[m].unreadCount++; - } - } - } else this._cacheGroupTipsAndProbe({ groupID: g, event: n, item: d }); - } return { eventDataList: s, result: r, AVChatRoomMessageList: c }; - } }, { key: 'handleMessageList', value(e) { - const t = this;e.forEach(((e) => { - switch (e.payload.operationType) { - case 1:t._onNewMemberComeIn(e);break;case 2:t._onMemberQuit(e);break;case 3:t._onMemberKickedOut(e);break;case 4:t._onMemberSetAdmin(e);break;case 5:t._onMemberCancelledAdmin(e);break;case 6:t._onGroupProfileModified(e);break;case 7:t._onMemberInfoModified(e);break;default:Ee.warn(''.concat(t._className, '.handleMessageList unknown operationType:').concat(e.payload.operationType)); - } - })); - } }, { key: '_onNewMemberComeIn', value(e) { - const t = e.payload; const n = t.memberNum; const o = t.groupProfile.groupID; const a = this._groupModule.getLocalGroupProfile(o);a && Ne(n) && (a.memberNum = n); - } }, { key: '_onMemberQuit', value(e) { - const t = e.payload; const n = t.memberNum; const o = t.groupProfile.groupID; const a = this._groupModule.getLocalGroupProfile(o);a && Ne(n) && (a.memberNum = n), this._groupModule.deleteLocalGroupMembers(o, e.payload.userIDList); - } }, { key: '_onMemberKickedOut', value(e) { - const t = e.payload; const n = t.memberNum; const o = t.groupProfile.groupID; const a = this._groupModule.getLocalGroupProfile(o);a && Ne(n) && (a.memberNum = n), this._groupModule.deleteLocalGroupMembers(o, e.payload.userIDList); - } }, { key: '_onMemberSetAdmin', value(e) { - const t = e.payload.groupProfile.groupID; const n = e.payload.userIDList; const o = this._groupModule.getModule(Lt);n.forEach(((e) => { - const n = o.getLocalGroupMemberInfo(t, e);n && n.updateRole(k.GRP_MBR_ROLE_ADMIN); - })); - } }, { key: '_onMemberCancelledAdmin', value(e) { - const t = e.payload.groupProfile.groupID; const n = e.payload.userIDList; const o = this._groupModule.getModule(Lt);n.forEach(((e) => { - const n = o.getLocalGroupMemberInfo(t, e);n && n.updateRole(k.GRP_MBR_ROLE_MEMBER); - })); - } }, { key: '_onGroupProfileModified', value(e) { - const t = this; const n = e.payload.newGroupProfile; const o = e.payload.groupProfile.groupID; const a = this._groupModule.getLocalGroupProfile(o);Object.keys(n).forEach(((e) => { - switch (e) { - case 'ownerID':t._ownerChanged(a, n);break;default:a[e] = n[e]; - } - })), this._groupModule.emitGroupListUpdate(!0, !0); - } }, { key: '_ownerChanged', value(e, t) { - const n = e.groupID; const o = this._groupModule.getLocalGroupProfile(n); const a = this.tim.context.identifier;if (a === t.ownerID) { - o.updateGroup({ selfInfo: { role: k.GRP_MBR_ROLE_OWNER } });const s = this._groupModule.getModule(Lt); const r = s.getLocalGroupMemberInfo(n, a); const i = this._groupModule.getLocalGroupProfile(n).ownerID; const c = s.getLocalGroupMemberInfo(n, i);r && r.updateRole(k.GRP_MBR_ROLE_OWNER), c && c.updateRole(k.GRP_MBR_ROLE_MEMBER); - } - } }, { key: '_onMemberInfoModified', value(e) { - const t = e.payload.groupProfile.groupID; const n = this._groupModule.getModule(Lt);e.payload.memberList.forEach(((e) => { - const o = n.getLocalGroupMemberInfo(t, e.userID);o && e.muteTime && o.updateMuteUntil(e.muteTime); - })); - } }, { key: '_cacheGroupTips', value(e, t) { - this._cachedGroupTipsMap.has(e) || this._cachedGroupTipsMap.set(e, []), this._cachedGroupTipsMap.get(e).push(t); - } }, { key: '_deleteCachedGroupTips', value(e) { - this._cachedGroupTipsMap.has(e) && this._cachedGroupTipsMap.delete(e); - } }, { key: '_notifyCachedGroupTips', value(e) { - const t = this; const n = this._cachedGroupTipsMap.get(e) || [];n.forEach(((e) => { - t.onNewGroupTips(e); - })), this._deleteCachedGroupTips(e), Ee.log(''.concat(this._className, '._notifyCachedGroupTips groupID:').concat(e, ' count:') - .concat(n.length)); - } }, { key: '_cacheGroupTipsAndProbe', value(e) { - const t = this; const n = e.groupID; const o = e.event; const a = e.item;this._cacheGroupTips(n, { event: o, dataList: [a] }), this._groupModule.getGroupSimplifiedInfo(n).then(((e) => { - e.type === k.GRP_AVCHATROOM ? t._groupModule.hasLocalGroup(n) ? t._notifyCachedGroupTips(n) : t._groupModule.setUnjoinedAVChatRoom(n) : (t._groupModule.updateGroupMap([e]), t._notifyCachedGroupTips(n)); - })), this._checkCountMap.has(n) || this._checkCountMap.set(n, 0), Ee.log(''.concat(this._className, '._cacheGroupTipsAndProbe groupID:').concat(n)); - } }, { key: 'reset', value() { - this._cachedGroupTipsMap.clear(), this._checkCountMap.clear(); - } }]), e; - }()); const qr = (function () { - function e(t) { - o(this, e), this._groupModule = t, this._className = 'CommonGroupHandler', this.tempConversationList = null, this._cachedGroupMessageMap = new Map, this._checkCountMap = new Map, this.MAX_CHECK_COUNT = 4, t.getInnerEmitterInstance().once(Ir.CONTEXT_A2KEY_AND_TINYID_UPDATED, this._initGroupList, this); - } return s(e, [{ key: 'onCheckTimer', value(e) { - e % 1 == 0 && this._cachedGroupMessageMap.size > 0 && this._checkCachedGroupMessage(); - } }, { key: '_checkCachedGroupMessage', value() { - const e = this;this._cachedGroupMessageMap.forEach(((t, n) => { - let o = e._checkCountMap.get(n); const a = e._groupModule.hasLocalGroup(n);Ee.log(''.concat(e._className, '._checkCachedGroupMessage groupID:').concat(n, ' hasLocalGroup:') - .concat(a, ' checkCount:') - .concat(o)), a ? (e._notifyCachedGroupMessage(n), e._checkCountMap.delete(n), e._groupModule.deleteUnjoinedAVChatRoom(n)) : o >= e.MAX_CHECK_COUNT ? (e._deleteCachedGroupMessage(n), e._checkCountMap.delete(n)) : (o++, e._checkCountMap.set(n, o)); - })); - } }, { key: '_initGroupList', value() { - const e = this;Ee.log(''.concat(this._className, '._initGroupList'));const t = new Da(gs); const n = this._groupModule.getStorageGroupList();if (Re(n) && n.length > 0) { - n.forEach(((t) => { - e._groupModule.initGroupMap(t); - })), this._groupModule.emitGroupListUpdate(!0, !1);const o = this._groupModule.getLocalGroupList().length;t.setNetworkType(this._groupModule.getNetworkType()).setMessage('group count:'.concat(o)) - .end(); - } else t.setNetworkType(this._groupModule.getNetworkType()).setMessage('group count:0') - .end();Ee.log(''.concat(this._className, '._initGroupList ok')), this.getGroupList(); - } }, { key: 'handleUpdateGroupLastMessage', value(e) { - const t = ''.concat(this._className, '.handleUpdateGroupLastMessage');if (Ee.debug(''.concat(t, ' conversation count:').concat(e.length, ', local group count:') - .concat(this._groupModule.getLocalGroupList().length)), 0 !== this._groupModule.getGroupMap().size) { - for (var n, o, a, s = !1, r = 0, i = e.length;r < i;r++)(n = e[r]).type === k.CONV_GROUP && (o = n.conversationID.split(/^GROUP/)[1], (a = this._groupModule.getLocalGroupProfile(o)) && (a.lastMessage = n.lastMessage, s = !0));s && (this._groupModule.sortLocalGroupList(), this._groupModule.emitGroupListUpdate(!0, !1)); - } else this.tempConversationList = e; - } }, { key: 'onNewGroupMessage', value(e) { - Ee.debug(''.concat(this._className, '.onNewGroupMessage count:').concat(e.dataList.length));const t = this._newGroupMessageStoredAndSummary(e); const n = t.conversationOptionsList; const o = t.messageList; const a = t.AVChatRoomMessageList;(a.length > 0 && this._groupModule.onAVChatRoomMessage(a), this._groupModule.filterModifiedMessage(o), n.length > 0) && (this._groupModule.getModule(Rt).onNewMessage({ conversationOptionsList: n, isInstantMessage: !0 }), this._groupModule.updateNextMessageSeq(n));const s = this._groupModule.filterUnmodifiedMessage(o);s.length > 0 && this._groupModule.emitOuterEvent(E.MESSAGE_RECEIVED, s), o.length = 0; - } }, { key: '_newGroupMessageStoredAndSummary', value(e) { - const t = e.dataList; const n = e.event; const o = e.isInstantMessage; let a = null; const s = []; const r = []; const i = []; const c = {}; const u = k.CONV_GROUP; const l = this._groupModule.getModule(Ut); const d = t.length;d > 1 && t.sort(((e, t) => e.sequence - t.sequence));for (let g = 0;g < d;g++) { - const p = t[g]; const h = p.groupProfile.groupID; const _ = this._groupModule.hasLocalGroup(h);if (_ || !this._groupModule.isUnjoinedAVChatRoom(h)) if (_) if (this._groupModule.isMessageFromAVChatroom(h)) { - const f = Xe(p);f.event = n, i.push(f); - } else { - p.currentUser = this._groupModule.getMyUserID(), p.conversationType = u, p.isSystemMessage = !!p.isSystemMessage, a = new ir(p), p.elements = l.parseElements(p.elements, p.from), a.setElement(p.elements);let m = 1 === t[g].isModified; const M = this._groupModule.getModule(Rt);M.isMessageSentByCurrentInstance(a) ? a.isModified = m : m = !1;const v = this._groupModule.getModule($t);if (o && v.addMessageDelay({ currentTime: Date.now(), time: a.time }), 1 === p.onlineOnlyFlag)a.setOnlineOnlyFlag(!0), r.push(a);else { - if (!M.pushIntoMessageList(r, a, m)) continue;v.addMessageSequence({ key: fa, message: a });const y = a.conversationID;if (Ge(c[y]))c[y] = s.push({ conversationID: y, unreadCount: 'out' === a.flow ? 0 : 1, type: a.conversationType, subType: a.conversationSubType, lastMessage: a }) - 1;else { - const I = c[y];s[I].type = a.conversationType, s[I].subType = a.conversationSubType, s[I].lastMessage = a, 'in' === a.flow && s[I].unreadCount++; - } - } - } else this._cacheGroupMessageAndProbe({ groupID: h, event: n, item: p }); - } return { conversationOptionsList: s, messageList: r, AVChatRoomMessageList: i }; - } }, { key: 'onGroupMessageRevoked', value(e) { - Ee.debug(''.concat(this._className, '.onGroupMessageRevoked nums:').concat(e.dataList.length));const t = this._groupModule.getModule(Rt); const n = []; let o = null;e.dataList.forEach(((e) => { - const a = e.elements.revokedInfos;Ge(a) || a.forEach(((e) => { - (o = t.revoke('GROUP'.concat(e.groupID), e.sequence, e.random)) && n.push(o); - })); - })), 0 !== n.length && (t.onMessageRevoked(n), this._groupModule.emitOuterEvent(E.MESSAGE_REVOKED, n)); - } }, { key: '_groupListTreeShaking', value(e) { - for (var t = new Map(M(this._groupModule.getGroupMap())), n = 0, o = e.length;n < o;n++)t.delete(e[n].groupID);this._groupModule.hasJoinedAVChatRoom() && this._groupModule.getJoinedAVChatRoom().forEach(((e) => { - t.delete(e); - }));for (let a = M(t.keys()), s = 0, r = a.length;s < r;s++) this._groupModule.deleteGroup(a[s]); - } }, { key: 'getGroupList', value(e) { - const t = this; const n = ''.concat(this._className, '.getGroupList'); const o = new Da(ls);Ee.log(''.concat(n));const a = { introduction: 'Introduction', notification: 'Notification', createTime: 'CreateTime', ownerID: 'Owner_Account', lastInfoTime: 'LastInfoTime', memberNum: 'MemberNum', maxMemberNum: 'MaxMemberNum', joinOption: 'ApplyJoinOption', muteAllMembers: 'ShutUpAllMember' }; const s = ['Type', 'Name', 'FaceUrl', 'NextMsgSeq', 'LastMsgTime']; const r = [];return e && e.groupProfileFilter && e.groupProfileFilter.forEach(((e) => { - a[e] && s.push(a[e]); - })), this._pagingGetGroupList({ limit: 50, offset: 0, groupBaseInfoFilter: s, groupList: r }).then((() => { - Ee.log(''.concat(n, ' ok. count:').concat(r.length)), t._groupListTreeShaking(r), t._groupModule.updateGroupMap(r);const e = t._groupModule.getLocalGroupList().length;return o.setNetworkType(t._groupModule.getNetworkType()).setMessage('remote count:'.concat(r.length, ', after tree shaking, local count:').concat(e)) - .end(), t.tempConversationList && (Ee.log(''.concat(n, ' update last message with tempConversationList, count:').concat(t.tempConversationList.length)), t.handleUpdateGroupLastMessage({ data: t.tempConversationList }), t.tempConversationList = null), t._groupModule.emitGroupListUpdate(), cr({ groupList: t._groupModule.getLocalGroupList() }); - })) - .catch((e => (t._groupModule.probeNetwork().then(((t) => { - const n = m(t, 2); const a = n[0]; const s = n[1];o.setError(e, a, s).end(); - })), Ee.error(''.concat(n, ' failed. error:'), e), Mr(e)))); - } }, { key: '_pagingGetGroupList', value(e) { - const t = this; const n = ''.concat(this._className, '._pagingGetGroupList'); const o = e.limit; let a = e.offset; const s = e.groupBaseInfoFilter; const r = e.groupList; const i = new Da(_s);return this._groupModule.request({ protocolName: fn, requestData: { memberAccount: this._groupModule.getMyUserID(), limit: o, offset: a, responseFilter: { groupBaseInfoFilter: s, selfInfoFilter: ['Role', 'JoinTime', 'MsgFlag'] } } }).then(((e) => { - const c = e.data; const u = c.groups; const l = c.totalCount;r.push.apply(r, M(u));const d = a + o; const g = !(l > d);return i.setNetworkType(t._groupModule.getNetworkType()).setMessage('offset:'.concat(a, ' totalCount:').concat(l, ' isCompleted:') - .concat(g, ' currentCount:') - .concat(r.length)) - .end(), g ? (Ee.log(''.concat(n, ' ok. totalCount:').concat(l)), cr({ groupList: r })) : (a = d, t._pagingGetGroupList({ limit: o, offset: a, groupBaseInfoFilter: s, groupList: r })); - })) - .catch((e => (t._groupModule.probeNetwork().then(((t) => { - const n = m(t, 2); const o = n[0]; const a = n[1];i.setError(e, o, a).end(); - })), Mr(e)))); - } }, { key: '_cacheGroupMessage', value(e, t) { - this._cachedGroupMessageMap.has(e) || this._cachedGroupMessageMap.set(e, []), this._cachedGroupMessageMap.get(e).push(t); - } }, { key: '_deleteCachedGroupMessage', value(e) { - this._cachedGroupMessageMap.has(e) && this._cachedGroupMessageMap.delete(e); - } }, { key: '_notifyCachedGroupMessage', value(e) { - const t = this; const n = this._cachedGroupMessageMap.get(e) || [];n.forEach(((e) => { - t.onNewGroupMessage(e); - })), this._deleteCachedGroupMessage(e), Ee.log(''.concat(this._className, '._notifyCachedGroupMessage groupID:').concat(e, ' count:') - .concat(n.length)); - } }, { key: '_cacheGroupMessageAndProbe', value(e) { - const t = this; const n = e.groupID; const o = e.event; const a = e.item;this._cacheGroupMessage(n, { event: o, dataList: [a] }), this._groupModule.getGroupSimplifiedInfo(n).then(((e) => { - e.type === k.GRP_AVCHATROOM ? t._groupModule.hasLocalGroup(n) ? t._notifyCachedGroupMessage(n) : t._groupModule.setUnjoinedAVChatRoom(n) : (t._groupModule.updateGroupMap([e]), t._notifyCachedGroupMessage(n)); - })), this._checkCountMap.has(n) || this._checkCountMap.set(n, 0), Ee.log(''.concat(this._className, '._cacheGroupMessageAndProbe groupID:').concat(n)); - } }, { key: 'reset', value() { - this._cachedGroupMessageMap.clear(), this._checkCountMap.clear(), this._groupModule.getInnerEmitterInstance().once(Ir.CONTEXT_A2KEY_AND_TINYID_UPDATED, this._initGroupList, this); - } }]), e; - }()); const Vr = (function () { - function e(t) { - o(this, e);const n = t.groupModule; const a = t.groupID; const s = t.onInit; const r = t.onSuccess; const i = t.onFail;this._groupModule = n, this._className = 'Polling', this._onInit = s, this._onSuccess = r, this._onFail = i, this._groupID = a, this._timeoutID = -1, this._isRunning = !1, this._pollingInterval = 0, this.MAX_POLLING_INTERVAL = 2e3; - } return s(e, [{ key: 'start', value() { - Ee.log(''.concat(this._className, '.start')), this._isRunning = !0, this._request(); - } }, { key: 'isRunning', value() { - return this._isRunning; - } }, { key: '_request', value() { - const e = this; const t = this._onInit(this._groupID); let n = Gn;this._groupModule.isLoggedIn() || (n = wn), this._groupModule.request({ protocolName: n, requestData: t }).then(((t) => { - e._onSuccess(e._groupID, t), e.isRunning() && (clearTimeout(e._timeoutID), e._timeoutID = setTimeout(e._request.bind(e), 0)); - })) - .catch(((t) => { - e._onFail(e._groupID, t), e.isRunning() && (clearTimeout(e._timeoutID), e._timeoutID = setTimeout(e._request.bind(e), e.MAX_POLLING_INTERVAL)); - })); - } }, { key: 'stop', value() { - Ee.log(''.concat(this._className, '.stop')), this._timeoutID > 0 && (clearTimeout(this._timeoutID), this._timeoutID = -1, this._pollingInterval = 0), this._isRunning = !1; - } }]), e; - }()); const Kr = { 3: !0, 4: !0, 5: !0, 6: !0 }; const xr = (function () { - function e(t) { - o(this, e), this._groupModule = t, this._className = 'AVChatRoomHandler', this._joinedGroupMap = new Map, this._pollingRequestInfoMap = new Map, this._pollingInstanceMap = new Map, this.sequencesLinkedList = new Lr(100), this.messageIDLinkedList = new Lr(100), this.receivedMessageCount = 0, this._reportMessageStackedCount = 0, this._onlineMemberCountMap = new Map, this.DEFAULT_EXPIRE_TIME = 60; - } return s(e, [{ key: 'hasJoinedAVChatRoom', value() { - return this._joinedGroupMap.size > 0; - } }, { key: 'checkJoinedAVChatRoomByID', value(e) { - return this._joinedGroupMap.has(e); - } }, { key: 'getJoinedAVChatRoom', value() { - return this._joinedGroupMap.size > 0 ? M(this._joinedGroupMap.keys()) : null; - } }, { key: '_updateRequestData', value(e) { - return t({}, this._pollingRequestInfoMap.get(e)); - } }, { key: '_handleSuccess', value(e, t) { - const n = t.data; const o = n.key; const a = n.nextSeq; const s = n.rspMsgList;if (0 !== n.errorCode) { - const r = this._pollingRequestInfoMap.get(e); const i = new Da(Cs); const c = r ? ''.concat(r.key, '-').concat(r.startSeq) : 'requestInfo is undefined';i.setMessage(''.concat(e, '-').concat(c, '-') - .concat(t.errorInfo)).setCode(t.errorCode) - .setNetworkType(this._groupModule.getNetworkType()) - .end(!0); - } else { - if (!this.checkJoinedAVChatRoomByID(e)) return;Ae(o) && Ne(a) && this._pollingRequestInfoMap.set(e, { key: o, startSeq: a }), Re(s) && s.length > 0 && (s.forEach(((e) => { - e.to = e.groupID; - })), this.onMessage(s)); - } - } }, { key: '_handleFailure', value(e, t) {} }, { key: 'onMessage', value(e) { - if (Re(e) && 0 !== e.length) { - let t = null; const n = []; const o = this._getModule(Rt); const a = e.length;a > 1 && e.sort(((e, t) => e.sequence - t.sequence));for (let s = this._getModule(Gt), r = 0;r < a;r++) if (Kr[e[r].event]) { - this.receivedMessageCount += 1, t = this.packMessage(e[r], e[r].event);const i = 1 === e[r].isModified;if ((s.isUnlimitedAVChatRoom() || !this.sequencesLinkedList.has(t.sequence)) && !this.messageIDLinkedList.has(t.ID)) { - const c = t.conversationID;if (this.receivedMessageCount % 40 == 0 && this._getModule(Bt).detectMessageLoss(c, this.sequencesLinkedList.data()), null !== this.sequencesLinkedList.tail()) { - const u = this.sequencesLinkedList.tail().value; const l = t.sequence - u;l > 1 && l <= 20 ? this._getModule(Bt).onMessageMaybeLost(c, u + 1, l - 1) : l < -1 && l >= -20 && this._getModule(Bt).onMessageMaybeLost(c, t.sequence + 1, Math.abs(l) - 1); - } this.sequencesLinkedList.set(t.sequence), this.messageIDLinkedList.set(t.ID);let d = !1;if (this._isMessageSentByCurrentInstance(t) ? i && (d = !0, t.isModified = i, o.updateMessageIsModifiedProperty(t)) : d = !0, d) { - if (t.conversationType, k.CONV_SYSTEM, t.conversationType !== k.CONV_SYSTEM) { - const g = this._getModule($t); const p = t.conversationID.replace(k.CONV_GROUP, '');this._pollingInstanceMap.has(p) ? g.addMessageSequence({ key: Ma, message: t }) : (t.type !== k.MSG_GRP_TIP && g.addMessageDelay({ currentTime: Date.now(), time: t.time }), g.addMessageSequence({ key: ma, message: t })); - }n.push(t); - } - } - } else Ee.warn(''.concat(this._className, '.onMessage 未处理的 event 类型: ').concat(e[r].event));if (0 !== n.length) { - this._groupModule.filterModifiedMessage(n);const h = this.packConversationOption(n);if (h.length > 0) this._getModule(Rt).onNewMessage({ conversationOptionsList: h, isInstantMessage: !0 });Ee.debug(''.concat(this._className, '.onMessage count:').concat(n.length)), this._checkMessageStacked(n);const _ = this._groupModule.filterUnmodifiedMessage(n);_.length > 0 && this._groupModule.emitOuterEvent(E.MESSAGE_RECEIVED, _), n.length = 0; - } - } - } }, { key: '_checkMessageStacked', value(e) { - const t = e.length;t >= 100 && (Ee.warn(''.concat(this._className, '._checkMessageStacked 直播群消息堆积数:').concat(e.length, '!可能会导致微信小程序渲染时遇到 "Dom limit exceeded" 的错误,建议接入侧此时只渲染最近的10条消息')), this._reportMessageStackedCount < 5 && (new Da(As).setNetworkType(this._groupModule.getNetworkType()) - .setMessage('count:'.concat(t, ' groupID:').concat(M(this._joinedGroupMap.keys()))) - .setLevel('warning') - .end(), this._reportMessageStackedCount += 1)); - } }, { key: '_isMessageSentByCurrentInstance', value(e) { - return !!this._getModule(Rt).isMessageSentByCurrentInstance(e); - } }, { key: 'packMessage', value(e, t) { - e.currentUser = this._groupModule.getMyUserID(), e.conversationType = 5 === t ? k.CONV_SYSTEM : k.CONV_GROUP, e.isSystemMessage = !!e.isSystemMessage;const n = new ir(e); const o = this.packElements(e, t);return n.setElement(o), n; - } }, { key: 'packElements', value(e, n) { - return 4 === n || 6 === n ? (this._updateMemberCountByGroupTips(e), { type: k.MSG_GRP_TIP, content: t(t({}, e.elements), {}, { groupProfile: e.groupProfile }) }) : 5 === n ? { type: k.MSG_GRP_SYS_NOTICE, content: t(t({}, e.elements), {}, { groupProfile: e.groupProfile }) } : this._getModule(Ut).parseElements(e.elements, e.from); - } }, { key: 'packConversationOption', value(e) { - for (var t = new Map, n = 0;n < e.length;n++) { - const o = e[n]; const a = o.conversationID;if (t.has(a)) { - const s = t.get(a);s.lastMessage = o, 'in' === o.flow && s.unreadCount++; - } else t.set(a, { conversationID: o.conversationID, unreadCount: 'out' === o.flow ? 0 : 1, type: o.conversationType, subType: o.conversationSubType, lastMessage: o }); - } return M(t.values()); - } }, { key: '_updateMemberCountByGroupTips', value(e) { - const t = e.groupProfile.groupID; const n = e.elements.onlineMemberInfo; const o = void 0 === n ? void 0 : n;if (!dt(o)) { - const a = o.onlineMemberNum; const s = void 0 === a ? 0 : a; const r = o.expireTime; const i = void 0 === r ? this.DEFAULT_EXPIRE_TIME : r; const c = this._onlineMemberCountMap.get(t) || {}; const u = Date.now();dt(c) ? Object.assign(c, { lastReqTime: 0, lastSyncTime: 0, latestUpdateTime: u, memberCount: s, expireTime: i }) : (c.latestUpdateTime = u, c.memberCount = s), Ee.debug(''.concat(this._className, '._updateMemberCountByGroupTips info:'), c), this._onlineMemberCountMap.set(t, c); - } - } }, { key: 'start', value(e) { - if (this._pollingInstanceMap.has(e)) { - const t = this._pollingInstanceMap.get(e);t.isRunning() || t.start(); - } else { - const n = new Vr({ groupModule: this._groupModule, groupID: e, onInit: this._updateRequestData.bind(this), onSuccess: this._handleSuccess.bind(this), onFail: this._handleFailure.bind(this) });n.start(), this._pollingInstanceMap.set(e, n), Ee.log(''.concat(this._className, '.start groupID:').concat(e)); - } - } }, { key: 'handleJoinResult', value(e) { - const t = this;return this._preCheck().then((() => { - const n = e.longPollingKey; const o = e.group; const a = o.groupID;return t._joinedGroupMap.set(a, o), t._groupModule.updateGroupMap([o]), t._groupModule.deleteUnjoinedAVChatRoom(a), t._groupModule.emitGroupListUpdate(!0, !1), Ge(n) ? mr({ status: js, group: o }) : Promise.resolve(); - })); - } }, { key: 'startRunLoop', value(e) { - const t = this;return this.handleJoinResult(e).then((() => { - const n = e.longPollingKey; const o = e.group; const a = o.groupID;return t._pollingRequestInfoMap.set(a, { key: n, startSeq: 0 }), t.start(a), t._groupModule.isLoggedIn() ? mr({ status: js, group: o }) : mr({ status: js }); - })); - } }, { key: '_preCheck', value() { - if (this._getModule(Gt).isUnlimitedAVChatRoom()) return Promise.resolve();if (!this.hasJoinedAVChatRoom()) return Promise.resolve();const e = m(this._joinedGroupMap.entries().next().value, 2); const t = e[0]; const n = e[1];if (this._groupModule.isLoggedIn()) { - if (!(n.selfInfo.role === k.GRP_MBR_ROLE_OWNER || n.ownerID === this._groupModule.getMyUserID())) return this._groupModule.quitGroup(t);this._groupModule.deleteLocalGroupAndConversation(t); - } else this._groupModule.deleteLocalGroupAndConversation(t);return this.reset(t), Promise.resolve(); - } }, { key: 'joinWithoutAuth', value(e) { - const t = this; const n = e.groupID; const o = ''.concat(this._className, '.joinWithoutAuth'); const a = new Da(ms);return this._groupModule.request({ protocolName: Dn, requestData: e }).then(((e) => { - const s = e.data.longPollingKey;if (a.setNetworkType(t._groupModule.getNetworkType()).setMessage('groupID:'.concat(n, ' longPollingKey:').concat(s)) - .end(!0), Ge(s)) return Mr(new hr({ code: Zn.CANNOT_JOIN_NON_AVCHATROOM_WITHOUT_LOGIN, message: Bo }));Ee.log(''.concat(o, ' ok. groupID:').concat(n)), t._getModule(Rt).setCompleted(''.concat(k.CONV_GROUP).concat(n));const r = new Gr({ groupID: n });return t.startRunLoop({ group: r, longPollingKey: s }), cr({ status: js }); - })) - .catch((e => (Ee.error(''.concat(o, ' failed. groupID:').concat(n, ' error:'), e), t._groupModule.probeNetwork().then(((t) => { - const o = m(t, 2); const s = o[0]; const r = o[1];a.setError(e, s, r).setMessage('groupID:'.concat(n)) - .end(!0); - })), Mr(e)))) - .finally((() => { - t._groupModule.getModule(Pt).reportAtOnce(); - })); - } }, { key: 'getGroupOnlineMemberCount', value(e) { - const t = this._onlineMemberCountMap.get(e) || {}; const n = Date.now();return dt(t) || n - t.lastSyncTime > 1e3 * t.expireTime && n - t.latestUpdateTime > 1e4 && n - t.lastReqTime > 3e3 ? (t.lastReqTime = n, this._onlineMemberCountMap.set(e, t), this._getGroupOnlineMemberCount(e).then((e => cr({ memberCount: e.memberCount }))) - .catch((e => Mr(e)))) : mr({ memberCount: t.memberCount }); - } }, { key: '_getGroupOnlineMemberCount', value(e) { - const t = this; const n = ''.concat(this._className, '._getGroupOnlineMemberCount');return this._groupModule.request({ protocolName: Pn, requestData: { groupID: e } }).then(((o) => { - const a = t._onlineMemberCountMap.get(e) || {}; const s = o.data; const r = s.onlineMemberNum; const i = void 0 === r ? 0 : r; const c = s.expireTime; const u = void 0 === c ? t.DEFAULT_EXPIRE_TIME : c;Ee.log(''.concat(n, ' ok. groupID:').concat(e, ' memberCount:') - .concat(i, ' expireTime:') - .concat(u));const l = Date.now();return dt(a) && (a.lastReqTime = l), t._onlineMemberCountMap.set(e, Object.assign(a, { lastSyncTime: l, latestUpdateTime: l, memberCount: i, expireTime: u })), { memberCount: i }; - })) - .catch((o => (Ee.warn(''.concat(n, ' failed. error:'), o), new Da(ks).setCode(o.code) - .setMessage('groupID:'.concat(e, ' error:').concat(JSON.stringify(o))) - .setNetworkType(t._groupModule.getNetworkType()) - .end(), Promise.reject(o)))); - } }, { key: '_getModule', value(e) { - return this._groupModule.getModule(e); - } }, { key: 'reset', value(e) { - if (e) { - Ee.log(''.concat(this._className, '.reset groupID:').concat(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 { - Ee.log(''.concat(this._className, '.reset all'));let n; const o = S(this._pollingInstanceMap.values());try { - for (o.s();!(n = o.n()).done;) { - n.value.stop(); - } - } catch (a) { - o.e(a); - } finally { - o.f(); - } this._pollingInstanceMap.clear(), this._joinedGroupMap.clear(), this._pollingRequestInfoMap.clear(), this._onlineMemberCountMap.clear(); - } this.sequencesLinkedList.reset(), this.messageIDLinkedList.reset(), this.receivedMessageCount = 0, this._reportMessageStackedCount = 0; - } }]), e; - }()); const Br = 1; const Hr = 15; const jr = (function () { - function e(t) { - o(this, e), this._groupModule = t, this._className = 'GroupSystemNoticeHandler', this.pendencyMap = new Map; - } return s(e, [{ key: 'onNewGroupSystemNotice', value(e) { - const t = e.dataList; const n = e.isSyncingEnded; const o = e.isInstantMessage;Ee.debug(''.concat(this._className, '.onReceiveSystemNotice count:').concat(t.length));const a = this.newSystemNoticeStoredAndSummary({ notifiesList: t, isInstantMessage: o }); const s = a.eventDataList; const r = a.result;s.length > 0 && (this._groupModule.getModule(Rt).onNewMessage({ conversationOptionsList: s, isInstantMessage: o }), this._onReceivedGroupSystemNotice({ result: r, isInstantMessage: o }));o ? r.length > 0 && this._groupModule.emitOuterEvent(E.MESSAGE_RECEIVED, r) : !0 === n && this._clearGroupSystemNotice(); - } }, { key: 'newSystemNoticeStoredAndSummary', value(e) { - const n = e.notifiesList; const o = e.isInstantMessage; let a = null; const s = n.length; let r = 0; const i = []; const c = { conversationID: k.CONV_SYSTEM, unreadCount: 0, type: k.CONV_SYSTEM, subType: null, lastMessage: null };for (r = 0;r < s;r++) { - const u = n[r];if (u.elements.operationType !== Hr)u.currentUser = this._groupModule.getMyUserID(), u.conversationType = k.CONV_SYSTEM, u.conversationID = k.CONV_SYSTEM, (a = new ir(u)).setElement({ type: k.MSG_GRP_SYS_NOTICE, content: t(t({}, u.elements), {}, { groupProfile: u.groupProfile }) }), a.isSystemMessage = !0, (1 === a.sequence && 1 === a.random || 2 === a.sequence && 2 === a.random) && (a.sequence = He(), a.random = He(), a.generateMessageID(u.currentUser), Ee.log(''.concat(this._className, '.newSystemNoticeStoredAndSummary sequence and random maybe duplicated, regenerate. ID:').concat(a.ID))), this._groupModule.getModule(Rt).pushIntoNoticeResult(i, a) && (o ? c.unreadCount++ : a.setIsRead(!0), c.subType = a.conversationSubType); - } return c.lastMessage = i[i.length - 1], { eventDataList: i.length > 0 ? [c] : [], result: i }; - } }, { key: '_clearGroupSystemNotice', value() { - const e = this;this.getPendencyList().then(((t) => { - t.forEach(((t) => { - e.pendencyMap.set(''.concat(t.from, '_').concat(t.groupID, '_') - .concat(t.to), t); - }));const n = e._groupModule.getModule(Rt).getLocalMessageList(k.CONV_SYSTEM); const o = [];n.forEach(((t) => { - const n = t.payload; const a = n.operatorID; const s = n.operationType; const r = n.groupProfile;if (s === Br) { - const i = ''.concat(a, '_').concat(r.groupID, '_') - .concat(r.to); const c = e.pendencyMap.get(i);c && Ne(c.handled) && 0 !== c.handled && o.push(t); - } - })), e.deleteGroupSystemNotice({ messageList: o }); - })); - } }, { key: 'deleteGroupSystemNotice', value(e) { - const t = this; const n = ''.concat(this._className, '.deleteGroupSystemNotice');return Re(e.messageList) && 0 !== e.messageList.length ? (Ee.log(''.concat(n) + e.messageList.map((e => e.ID))), this._groupModule.request({ protocolName: Rn, requestData: { messageListToDelete: e.messageList.map((e => ({ from: k.CONV_SYSTEM, messageSeq: e.clientSequence, messageRandom: e.random }))) } }).then((() => { - Ee.log(''.concat(n, ' ok'));const o = t._groupModule.getModule(Rt);return e.messageList.forEach(((e) => { - o.deleteLocalMessage(e); - })), cr(); - })) - .catch((e => (Ee.error(''.concat(n, ' error:'), e), Mr(e))))) : mr(); - } }, { key: 'getPendencyList', value(e) { - const t = this;return this._groupModule.request({ protocolName: Ln, requestData: { startTime: e && e.startTime ? e.startTime : 0, limit: e && e.limit ? e.limit : 10, handleAccount: this._groupModule.getMyUserID() } }).then(((e) => { - const n = e.data.pendencyList;return 0 !== e.data.nextStartTime ? t.getPendencyList({ startTime: e.data.nextStartTime }).then((e => [].concat(M(n), M(e)))) : n; - })); - } }, { key: '_onReceivedGroupSystemNotice', value(e) { - const t = this; const n = e.result;e.isInstantMessage && n.forEach(((e) => { - switch (e.payload.operationType) { - case 1:break;case 2:t._onApplyGroupRequestAgreed(e);break;case 3:break;case 4:t._onMemberKicked(e);break;case 5:t._onGroupDismissed(e);break;case 6:break;case 7:t._onInviteGroup(e);break;case 8:t._onQuitGroup(e);break;case 9:t._onSetManager(e);break;case 10:t._onDeleteManager(e); - } - })); - } }, { key: '_onApplyGroupRequestAgreed', value(e) { - const t = this; const n = e.payload.groupProfile.groupID;this._groupModule.hasLocalGroup(n) || this._groupModule.getGroupProfile({ groupID: n }).then(((e) => { - const n = e.data.group;n && (t._groupModule.updateGroupMap([n]), t._groupModule.emitGroupListUpdate()); - })); - } }, { key: '_onMemberKicked', value(e) { - const t = e.payload.groupProfile.groupID;this._groupModule.hasLocalGroup(t) && this._groupModule.deleteLocalGroupAndConversation(t); - } }, { key: '_onGroupDismissed', value(e) { - const t = e.payload.groupProfile.groupID;this._groupModule.hasLocalGroup(t) && this._groupModule.deleteLocalGroupAndConversation(t);const n = this._groupModule._AVChatRoomHandler;n && n.checkJoinedAVChatRoomByID(t) && n.reset(t); - } }, { key: '_onInviteGroup', value(e) { - const t = this; const n = e.payload.groupProfile.groupID;this._groupModule.hasLocalGroup(n) || this._groupModule.getGroupProfile({ groupID: n }).then(((e) => { - const n = e.data.group;n && (t._groupModule.updateGroupMap([n]), t._groupModule.emitGroupListUpdate()); - })); - } }, { key: '_onQuitGroup', value(e) { - const t = e.payload.groupProfile.groupID;this._groupModule.hasLocalGroup(t) && this._groupModule.deleteLocalGroupAndConversation(t); - } }, { key: '_onSetManager', value(e) { - const t = e.payload.groupProfile; const n = t.to; const o = t.groupID; const a = this._groupModule.getModule(Lt).getLocalGroupMemberInfo(o, n);a && a.updateRole(k.GRP_MBR_ROLE_ADMIN); - } }, { key: '_onDeleteManager', value(e) { - const t = e.payload.groupProfile; const n = t.to; const o = t.groupID; const a = this._groupModule.getModule(Lt).getLocalGroupMemberInfo(o, n);a && a.updateRole(k.GRP_MBR_ROLE_MEMBER); - } }, { key: 'reset', value() { - this.pendencyMap.clear(); - } }]), e; - }()); const $r = (function (e) { - i(a, e);const n = f(a);function a(e) { - let t;return o(this, a), (t = n.call(this, e))._className = 'GroupModule', t._commonGroupHandler = null, t._AVChatRoomHandler = null, t._groupSystemNoticeHandler = null, t._commonGroupHandler = new qr(h(t)), t._AVChatRoomHandler = new xr(h(t)), t._groupTipsHandler = new Fr(h(t)), t._groupSystemNoticeHandler = new jr(h(t)), t.groupMap = new Map, t._unjoinedAVChatRoomList = new Map, t; - } return s(a, [{ key: 'onCheckTimer', value(e) { - this.isLoggedIn() && (this._commonGroupHandler.onCheckTimer(e), this._groupTipsHandler.onCheckTimer(e)); - } }, { key: 'guardForAVChatRoom', value(e) { - const t = this;if (e.conversationType === k.CONV_GROUP) { - const n = e.to;return this.hasLocalGroup(n) ? mr() : this.getGroupProfile({ groupID: n }).then(((o) => { - const a = o.data.group.type;if (Ee.log(''.concat(t._className, '.guardForAVChatRoom. groupID:').concat(n, ' type:') - .concat(a)), a === k.GRP_AVCHATROOM) { - const s = 'userId:'.concat(e.from, ' 未加入群 groupID:').concat(n, '。发消息前先使用 joinGroup 接口申请加群,详细请参考 https://web.sdk.qcloud.com/im/doc/zh-cn/SDK.html#joinGroup');return Ee.warn(''.concat(t._className, '.guardForAVChatRoom sendMessage not allowed. ').concat(s)), Mr(new hr({ code: Zn.MESSAGE_SEND_FAIL, message: s, data: { message: e } })); - } return mr(); - })); - } return mr(); - } }, { key: 'checkJoinedAVChatRoomByID', value(e) { - return !!this._AVChatRoomHandler && this._AVChatRoomHandler.checkJoinedAVChatRoomByID(e); - } }, { key: 'onNewGroupMessage', value(e) { - this._commonGroupHandler && this._commonGroupHandler.onNewGroupMessage(e); - } }, { key: 'updateNextMessageSeq', value(e) { - const t = this;Re(e) && e.forEach(((e) => { - const n = e.conversationID.replace(k.CONV_GROUP, '');t.groupMap.has(n) && (t.groupMap.get(n).nextMessageSeq = e.lastMessage.sequence + 1); - })); - } }, { key: 'onNewGroupTips', value(e) { - this._groupTipsHandler && this._groupTipsHandler.onNewGroupTips(e); - } }, { key: 'onGroupMessageRevoked', value(e) { - this._commonGroupHandler && this._commonGroupHandler.onGroupMessageRevoked(e); - } }, { key: 'onNewGroupSystemNotice', value(e) { - this._groupSystemNoticeHandler && this._groupSystemNoticeHandler.onNewGroupSystemNotice(e); - } }, { key: 'onGroupMessageReadNotice', value(e) { - const t = this;e.dataList.forEach(((e) => { - const n = e.elements.groupMessageReadNotice;if (!Ge(n)) { - const o = t.getModule(Rt);n.forEach(((e) => { - const n = e.groupID; const a = e.lastMessageSeq;Ee.debug(''.concat(t._className, '.onGroupMessageReadNotice groupID:').concat(n, ' lastMessageSeq:') - .concat(a));const s = ''.concat(k.CONV_GROUP).concat(n);o.updateIsReadAfterReadReport({ conversationID: s, lastMessageSeq: a }), o.updateUnreadCount(s); - })); - } - })); - } }, { key: 'deleteGroupSystemNotice', value(e) { - this._groupSystemNoticeHandler && this._groupSystemNoticeHandler.deleteGroupSystemNotice(e); - } }, { key: 'initGroupMap', value(e) { - this.groupMap.set(e.groupID, new Gr(e)); - } }, { key: 'deleteGroup', value(e) { - this.groupMap.delete(e); - } }, { key: 'updateGroupMap', value(e) { - const t = this;e.forEach(((e) => { - t.groupMap.has(e.groupID) ? t.groupMap.get(e.groupID).updateGroup(e) : t.groupMap.set(e.groupID, new Gr(e)); - })), this._setStorageGroupList(); - } }, { key: 'getStorageGroupList', value() { - return this.getModule(wt).getItem('groupMap'); - } }, { key: '_setStorageGroupList', value() { - const e = this.getLocalGroupList().filter(((e) => { - const t = e.type;return !et(t); - })) - .slice(0, 20) - .map((e => ({ groupID: e.groupID, name: e.name, avatar: e.avatar, type: e.type })));this.getModule(wt).setItem('groupMap', e); - } }, { key: 'getGroupMap', value() { - return this.groupMap; - } }, { key: 'getLocalGroupList', value() { - return M(this.groupMap.values()); - } }, { key: 'getLocalGroupProfile', value(e) { - return this.groupMap.get(e); - } }, { key: 'sortLocalGroupList', value() { - const e = M(this.groupMap).filter(((e) => { - const t = m(e, 2);t[0];return !dt(t[1].lastMessage); - }));e.sort(((e, t) => t[1].lastMessage.lastTime - e[1].lastMessage.lastTime)), this.groupMap = new Map(M(e)); - } }, { key: 'updateGroupLastMessage', value(e) { - this._commonGroupHandler && this._commonGroupHandler.handleUpdateGroupLastMessage(e); - } }, { key: 'emitGroupListUpdate', value() { - const e = !(arguments.length > 0 && void 0 !== arguments[0]) || arguments[0]; const t = !(arguments.length > 1 && void 0 !== arguments[1]) || arguments[1]; const n = this.getLocalGroupList();if (e && this.emitOuterEvent(E.GROUP_LIST_UPDATED, n), t) { - const o = JSON.parse(JSON.stringify(n)); const a = this.getModule(Rt);a.updateConversationGroupProfile(o); - } - } }, { key: 'getGroupList', value(e) { - return this._commonGroupHandler ? this._commonGroupHandler.getGroupList(e) : mr(); - } }, { key: 'getGroupProfile', value(e) { - const t = this; const n = new Da(ds); const o = ''.concat(this._className, '.getGroupProfile'); const a = e.groupID; const s = e.groupCustomFieldFilter;Ee.log(''.concat(o, ' groupID:').concat(a));const r = { groupIDList: [a], responseFilter: { groupBaseInfoFilter: ['Type', 'Name', 'Introduction', 'Notification', 'FaceUrl', 'Owner_Account', 'CreateTime', 'InfoSeq', 'LastInfoTime', 'LastMsgTime', 'MemberNum', 'MaxMemberNum', 'ApplyJoinOption', 'NextMsgSeq', 'ShutUpAllMember'], groupCustomFieldFilter: s } };return this.getGroupProfileAdvance(r).then(((e) => { - let s; const r = e.data; const i = r.successGroupList; const c = r.failureGroupList;return Ee.log(''.concat(o, ' ok')), c.length > 0 ? Mr(c[0]) : (et(i[0].type) && !t.hasLocalGroup(a) ? s = new Gr(i[0]) : (t.updateGroupMap(i), s = t.getLocalGroupProfile(a)), n.setNetworkType(t.getNetworkType()).setMessage('groupID:'.concat(a, ' type:').concat(s.type, ' muteAllMembers:') - .concat(s.muteAllMembers, ' ownerID:') - .concat(s.ownerID)) - .end(), s && s.selfInfo && !s.selfInfo.nameCard ? t.updateSelfInfo(s).then((e => cr({ group: e }))) : cr({ group: s })); - })) - .catch((a => (t.probeNetwork().then(((t) => { - const o = m(t, 2); const s = o[0]; const r = o[1];n.setError(a, s, r).setMessage('groupID:'.concat(e.groupID)) - .end(); - })), Ee.error(''.concat(o, ' failed. error:'), a), Mr(a)))); - } }, { key: 'getGroupProfileAdvance', value(e) { - const t = ''.concat(this._className, '.getGroupProfileAdvance');return Re(e.groupIDList) && e.groupIDList.length > 50 && (Ee.warn(''.concat(t, ' 获取群资料的数量不能超过50个')), e.groupIDList.length = 50), Ee.log(''.concat(t, ' groupIDList:').concat(e.groupIDList)), this.request({ protocolName: mn, requestData: e }).then(((e) => { - Ee.log(''.concat(t, ' ok'));const n = e.data.groups; const o = n.filter((e => Ge(e.errorCode) || 0 === e.errorCode)); const a = n.filter((e => e.errorCode && 0 !== e.errorCode)).map((e => new hr({ code: e.errorCode, message: e.errorInfo, data: { groupID: e.groupID } })));return cr({ successGroupList: o, failureGroupList: a }); - })) - .catch((e => (Ee.error(''.concat(t, ' failed. error:'), e), Mr(e)))); - } }, { key: 'updateSelfInfo', value(e) { - const t = ''.concat(this._className, '.updateSelfInfo'); const n = e.groupID;return Ee.log(''.concat(t, ' groupID:').concat(n)), this.getModule(Lt).getGroupMemberProfile({ groupID: n, userIDList: [this.getMyUserID()] }) - .then(((n) => { - const o = n.data.memberList;return Ee.log(''.concat(t, ' ok')), e && 0 !== o.length && e.updateSelfInfo(o[0]), e; - })); - } }, { key: 'createGroup', value(e) { - const n = this; const o = ''.concat(this._className, '.createGroup');if (!['Public', 'Private', 'ChatRoom', 'AVChatRoom'].includes(e.type)) { - const a = new hr({ code: Zn.ILLEGAL_GROUP_TYPE, message: Po });return Mr(a); - }et(e.type) && !Ge(e.memberList) && e.memberList.length > 0 && (Ee.warn(''.concat(o, ' 创建 AVChatRoom 时不能添加群成员,自动忽略该字段')), e.memberList = void 0), Ze(e.type) || Ge(e.joinOption) || (Ee.warn(''.concat(o, ' 创建 Work/Meeting/AVChatRoom 群时不能设置字段 joinOption,自动忽略该字段')), e.joinOption = void 0);const s = new Da(es);Ee.log(''.concat(o, ' options:'), e);let r = [];return this.request({ protocolName: Mn, requestData: t(t({}, e), {}, { ownerID: this.getMyUserID(), webPushFlag: 1 }) }).then(((a) => { - const i = a.data; const c = i.groupID; const u = i.overLimitUserIDList; const l = void 0 === u ? [] : u;if (r = l, s.setNetworkType(n.getNetworkType()).setMessage('groupType:'.concat(e.type, ' groupID:').concat(c, ' overLimitUserIDList=') - .concat(l)) - .end(), Ee.log(''.concat(o, ' ok groupID:').concat(c, ' overLimitUserIDList:'), l), e.type === k.GRP_AVCHATROOM) return n.getGroupProfile({ groupID: c });dt(e.memberList) || dt(l) || (e.memberList = e.memberList.filter((e => -1 === l.indexOf(e.userID)))), n.updateGroupMap([t(t({}, e), {}, { groupID: c })]);const d = n.getModule(kt); const g = d.createCustomMessage({ to: c, conversationType: k.CONV_GROUP, payload: { data: 'group_create', extension: ''.concat(n.getMyUserID(), '创建群组') } });return d.sendMessageInstance(g), n.emitGroupListUpdate(), n.getGroupProfile({ groupID: c }); - })) - .then(((e) => { - const t = e.data.group; const n = t.selfInfo; const o = n.nameCard; const a = n.joinTime;return t.updateSelfInfo({ nameCard: o, joinTime: a, messageRemindType: k.MSG_REMIND_ACPT_AND_NOTE, role: k.GRP_MBR_ROLE_OWNER }), cr({ group: t, overLimitUserIDList: r }); - })) - .catch((t => (s.setMessage('groupType:'.concat(e.type)), n.probeNetwork().then(((e) => { - const n = m(e, 2); const o = n[0]; const a = n[1];s.setError(t, o, a).end(); - })), Ee.error(''.concat(o, ' failed. error:'), t), Mr(t)))); - } }, { key: 'dismissGroup', value(e) { - const t = this; const n = ''.concat(this._className, '.dismissGroup');if (this.hasLocalGroup(e) && this.getLocalGroupProfile(e).type === k.GRP_WORK) return Mr(new hr({ code: Zn.CANNOT_DISMISS_WORK, message: qo }));const o = new Da(cs);return o.setMessage('groupID:'.concat(e)), Ee.log(''.concat(n, ' groupID:').concat(e)), this.request({ protocolName: vn, requestData: { groupID: e } }).then((() => (o.setNetworkType(t.getNetworkType()).end(), Ee.log(''.concat(n, ' ok')), t.deleteLocalGroupAndConversation(e), t.checkJoinedAVChatRoomByID(e) && t._AVChatRoomHandler.reset(e), cr({ groupID: e })))) - .catch((e => (t.probeNetwork().then(((t) => { - const n = m(t, 2); const a = n[0]; const s = n[1];o.setError(e, a, s).end(); - })), Ee.error(''.concat(n, ' failed. error:'), e), Mr(e)))); - } }, { key: 'updateGroupProfile', value(e) { - const t = this; const n = ''.concat(this._className, '.updateGroupProfile');!this.hasLocalGroup(e.groupID) || Ze(this.getLocalGroupProfile(e.groupID).type) || Ge(e.joinOption) || (Ee.warn(''.concat(n, ' Work/Meeting/AVChatRoom 群不能设置字段 joinOption,自动忽略该字段')), e.joinOption = void 0), Ge(e.muteAllMembers) || (e.muteAllMembers ? e.muteAllMembers = 'On' : e.muteAllMembers = 'Off');const o = new Da(us);return o.setMessage(JSON.stringify(e)), Ee.log(''.concat(n, ' groupID:').concat(e.groupID)), this.request({ protocolName: yn, requestData: e }).then((() => { - (o.setNetworkType(t.getNetworkType()).end(), Ee.log(''.concat(n, ' ok')), t.hasLocalGroup(e.groupID)) && (t.groupMap.get(e.groupID).updateGroup(e), t._setStorageGroupList());return cr({ group: t.groupMap.get(e.groupID) }); - })) - .catch((e => (t.probeNetwork().then(((t) => { - const n = m(t, 2); const a = n[0]; const s = n[1];o.setError(e, a, s).end(); - })), Ee.log(''.concat(n, ' failed. error:'), e), Mr(e)))); - } }, { key: 'joinGroup', value(e) { - const t = this; const n = e.groupID; const o = e.type; const a = ''.concat(this._className, '.joinGroup');if (o === k.GRP_WORK) { - const s = new hr({ code: Zn.CANNOT_JOIN_WORK, message: bo });return Mr(s); - } if (this.deleteUnjoinedAVChatRoom(n), this.hasLocalGroup(n)) { - if (!this.isLoggedIn()) return mr({ status: k.JOIN_STATUS_ALREADY_IN_GROUP });const r = new Da(ts);return this.getGroupProfile({ groupID: n }).then((() => (r.setNetworkType(t.getNetworkType()).setMessage('groupID:'.concat(n, ' joinedStatus:').concat(k.JOIN_STATUS_ALREADY_IN_GROUP)) - .end(), mr({ status: k.JOIN_STATUS_ALREADY_IN_GROUP })))) - .catch((o => (r.setNetworkType(t.getNetworkType()).setMessage('groupID:'.concat(n, ' unjoined')) - .end(), Ee.warn(''.concat(a, ' ').concat(n, ' was unjoined, now join!')), t.groupMap.delete(n), t.applyJoinGroup(e)))); - } return Ee.log(''.concat(a, ' groupID:').concat(n)), this.isLoggedIn() ? this.applyJoinGroup(e) : this._AVChatRoomHandler.joinWithoutAuth(e); - } }, { key: 'applyJoinGroup', value(e) { - const t = this; const n = ''.concat(this._className, '.applyJoinGroup'); const o = e.groupID; const a = new Da(ts);return this.request({ protocolName: In, requestData: e }).then(((e) => { - const s = e.data; const r = s.joinedStatus; const i = s.longPollingKey; const c = s.avChatRoomFlag; const u = 'groupID:'.concat(o, ' joinedStatus:').concat(r, ' longPollingKey:') - .concat(i, ' avChatRoomFlag:') - .concat(c);switch (a.setNetworkType(t.getNetworkType()).setMessage(''.concat(u)) - .end(), Ee.log(''.concat(n, ' ok. ').concat(u)), r) { - case $s:return cr({ status: $s });case js:return t.getGroupProfile({ groupID: o }).then(((e) => { - const n = e.data.group; const a = { status: js, group: n };return 1 === c ? (t.getModule(Rt).setCompleted(''.concat(k.CONV_GROUP).concat(o)), Ge(i) ? t._AVChatRoomHandler.handleJoinResult({ group: n }) : t._AVChatRoomHandler.startRunLoop({ longPollingKey: i, group: n })) : (t.emitGroupListUpdate(!0, !1), cr(a)); - }));default:var l = new hr({ code: Zn.JOIN_GROUP_FAIL, message: Ko });return Ee.error(''.concat(n, ' error:'), l), Mr(l); - } - })) - .catch((o => (a.setMessage('groupID:'.concat(e.groupID)), t.probeNetwork().then(((e) => { - const t = m(e, 2); const n = t[0]; const s = t[1];a.setError(o, n, s).end(); - })), Ee.error(''.concat(n, ' error:'), o), Mr(o)))); - } }, { key: 'quitGroup', value(e) { - const t = this; const n = ''.concat(this._className, '.quitGroup');Ee.log(''.concat(n, ' groupID:').concat(e));const o = this.checkJoinedAVChatRoomByID(e);if (!o && !this.hasLocalGroup(e)) { - const a = new hr({ code: Zn.MEMBER_NOT_IN_GROUP, message: Vo });return Mr(a); - } if (o && !this.isLoggedIn()) return Ee.log(''.concat(n, ' anonymously ok. groupID:').concat(e)), this.deleteLocalGroupAndConversation(e), this._AVChatRoomHandler.reset(e), mr({ groupID: e });const s = new Da(ns);return s.setMessage('groupID:'.concat(e)), this.request({ protocolName: Tn, requestData: { groupID: e } }).then((() => (s.setNetworkType(t.getNetworkType()).end(), Ee.log(''.concat(n, ' ok')), o && t._AVChatRoomHandler.reset(e), t.deleteLocalGroupAndConversation(e), cr({ groupID: e })))) - .catch((e => (t.probeNetwork().then(((t) => { - const n = m(t, 2); const o = n[0]; const a = n[1];s.setError(e, o, a).end(); - })), Ee.error(''.concat(n, ' failed. error:'), e), Mr(e)))); - } }, { key: 'searchGroupByID', value(e) { - const t = this; const n = ''.concat(this._className, '.searchGroupByID'); const o = { groupIDList: [e] }; const a = new Da(os);return a.setMessage('groupID:'.concat(e)), Ee.log(''.concat(n, ' groupID:').concat(e)), this.request({ protocolName: Sn, requestData: o }).then(((e) => { - const o = e.data.groupProfile;if (0 !== o[0].errorCode) throw new hr({ code: o[0].errorCode, message: o[0].errorInfo });return a.setNetworkType(t.getNetworkType()).end(), Ee.log(''.concat(n, ' ok')), cr({ group: new Gr(o[0]) }); - })) - .catch((e => (t.probeNetwork().then(((t) => { - const n = m(t, 2); const o = n[0]; const s = n[1];a.setError(e, o, s).end(); - })), Ee.warn(''.concat(n, ' failed. error:'), e), Mr(e)))); - } }, { key: 'changeGroupOwner', value(e) { - const t = this; const n = ''.concat(this._className, '.changeGroupOwner');if (this.hasLocalGroup(e.groupID) && this.getLocalGroupProfile(e.groupID).type === k.GRP_AVCHATROOM) return Mr(new hr({ code: Zn.CANNOT_CHANGE_OWNER_IN_AVCHATROOM, message: Uo }));if (e.newOwnerID === this.getMyUserID()) return Mr(new hr({ code: Zn.CANNOT_CHANGE_OWNER_TO_SELF, message: Fo }));const o = new Da(as);return o.setMessage('groupID:'.concat(e.groupID, ' newOwnerID:').concat(e.newOwnerID)), Ee.log(''.concat(n, ' groupID:').concat(e.groupID)), this.request({ protocolName: En, requestData: e }).then((() => { - o.setNetworkType(t.getNetworkType()).end(), Ee.log(''.concat(n, ' ok'));const a = e.groupID; const s = e.newOwnerID;t.groupMap.get(a).ownerID = s;const r = t.getModule(Lt).getLocalGroupMemberList(a);if (r instanceof Map) { - const i = r.get(t.getMyUserID());Ge(i) || (i.updateRole('Member'), t.groupMap.get(a).selfInfo.role = 'Member');const c = r.get(s);Ge(c) || c.updateRole('Owner'); - } return t.emitGroupListUpdate(!0, !1), cr({ group: t.groupMap.get(a) }); - })) - .catch((e => (t.probeNetwork().then(((t) => { - const n = m(t, 2); const a = n[0]; const s = n[1];o.setError(e, a, s).end(); - })), Ee.error(''.concat(n, ' failed. error:'), e), Mr(e)))); - } }, { key: 'handleGroupApplication', value(e) { - const n = this; const o = ''.concat(this._className, '.handleGroupApplication'); const a = e.message.payload; const s = a.groupProfile.groupID; const r = a.authentication; const i = a.messageKey; const c = a.operatorID; const u = new Da(ss);return u.setMessage('groupID:'.concat(s)), Ee.log(''.concat(o, ' groupID:').concat(s)), this.request({ protocolName: kn, requestData: t(t({}, e), {}, { applicant: c, groupID: s, authentication: r, messageKey: i }) }).then((() => (u.setNetworkType(n.getNetworkType()).end(), Ee.log(''.concat(o, ' ok')), n._groupSystemNoticeHandler.deleteGroupSystemNotice({ messageList: [e.message] }), cr({ group: n.getLocalGroupProfile(s) })))) - .catch((e => (n.probeNetwork().then(((t) => { - const n = m(t, 2); const o = n[0]; const a = n[1];u.setError(e, o, a).end(); - })), Ee.error(''.concat(o, ' failed. error'), e), Mr(e)))); - } }, { key: 'handleGroupInvitation', value(e) { - const n = this; const o = ''.concat(this._className, '.handleGroupInvitation'); const a = e.message.payload; const s = a.groupProfile.groupID; const r = a.authentication; const i = a.messageKey; const c = a.operatorID; const u = e.handleAction; const l = new Da(rs);return l.setMessage('groupID:'.concat(s, ' inviter:').concat(c, ' handleAction:') - .concat(u)), Ee.log(''.concat(o, ' groupID:').concat(s, ' inviter:') - .concat(c, ' handleAction:') - .concat(u)), this.request({ protocolName: Cn, requestData: t(t({}, e), {}, { inviter: c, groupID: s, authentication: r, messageKey: i }) }).then((() => (l.setNetworkType(n.getNetworkType()).end(), Ee.log(''.concat(o, ' ok')), n._groupSystemNoticeHandler.deleteGroupSystemNotice({ messageList: [e.message] }), cr({ group: n.getLocalGroupProfile(s) })))) - .catch((e => (n.probeNetwork().then(((t) => { - const n = m(t, 2); const o = n[0]; const a = n[1];l.setError(e, o, a).end(); - })), Ee.error(''.concat(o, ' failed. error'), e), Mr(e)))); - } }, { key: 'getGroupOnlineMemberCount', value(e) { - return this._AVChatRoomHandler ? this._AVChatRoomHandler.checkJoinedAVChatRoomByID(e) ? this._AVChatRoomHandler.getGroupOnlineMemberCount(e) : mr({ memberCount: 0 }) : Mr({ code: Zn.CANNOT_FIND_MODULE, message: ra }); - } }, { key: 'hasLocalGroup', value(e) { - return this.groupMap.has(e); - } }, { key: 'deleteLocalGroupAndConversation', value(e) { - this._deleteLocalGroup(e), this.getModule(Rt).deleteLocalConversation('GROUP'.concat(e)), this.emitGroupListUpdate(!0, !1); - } }, { key: '_deleteLocalGroup', value(e) { - this.groupMap.delete(e), this.getModule(Lt).deleteGroupMemberList(e), this._setStorageGroupList(); - } }, { key: 'sendMessage', value(e, t) { - const n = this.createGroupMessagePack(e, t);return this.request(n); - } }, { key: 'createGroupMessagePack', value(e, t) { - let n = null;t && t.offlinePushInfo && (n = t.offlinePushInfo);let o = '';Ae(e.cloudCustomData) && e.cloudCustomData.length > 0 && (o = e.cloudCustomData);const a = e.getGroupAtInfoList();return { protocolName: en, tjgID: this.generateTjgID(e), requestData: { fromAccount: this.getMyUserID(), groupID: e.to, msgBody: e.getElements(), cloudCustomData: o, random: e.random, priority: e.priority, clientSequence: e.clientSequence, groupAtInfo: e.type !== k.MSG_TEXT || dt(a) ? void 0 : a, onlineOnlyFlag: this.isOnlineMessage(e, t) ? 1 : 0, offlinePushInfo: n ? { pushFlag: !0 === n.disablePush ? 1 : 0, title: n.title || '', desc: n.description || '', ext: n.extension || '', apnsInfo: { badgeMode: !0 === n.ignoreIOSBadge ? 1 : 0 }, androidInfo: { OPPOChannelID: n.androidOPPOChannelID || '' } } : void 0 } }; - } }, { key: 'revokeMessage', value(e) { - return this.request({ protocolName: Nn, requestData: { to: e.to, msgSeqList: [{ msgSeq: e.sequence }] } }); - } }, { key: 'deleteMessage', value(e) { - const t = e.to; const n = e.keyList;return Ee.log(''.concat(this._className, '.deleteMessage groupID:').concat(t, ' count:') - .concat(n.length)), this.request({ protocolName: bn, requestData: { groupID: t, deleter: this.getMyUserID(), keyList: n } }); - } }, { key: 'getRoamingMessage', value(e) { - const t = this; const n = ''.concat(this._className, '.getRoamingMessage'); const o = new Da(Fa); let a = 0;return this._computeLastSequence(e).then((n => (a = n, Ee.log(''.concat(t._className, '.getRoamingMessage groupID:').concat(e.groupID, ' lastSequence:') - .concat(a)), t.request({ protocolName: On, requestData: { groupID: e.groupID, count: 21, sequence: a } })))) - .then(((s) => { - const r = s.data; const i = r.messageList; const c = r.complete;Ge(i) ? Ee.log(''.concat(n, ' ok. complete:').concat(c, ' but messageList is undefined!')) : Ee.log(''.concat(n, ' ok. complete:').concat(c, ' count:') - .concat(i.length)), o.setNetworkType(t.getNetworkType()).setMessage('groupID:'.concat(e.groupID, ' lastSequence:').concat(a, ' complete:') - .concat(c, ' count:') - .concat(i ? i.length : 'undefined')) - .end();const u = 'GROUP'.concat(e.groupID); const l = t.getModule(Rt);if (2 === c || dt(i)) return l.setCompleted(u), [];const d = l.storeRoamingMessage(i, u);return l.updateIsRead(u), l.patchConversationLastMessage(u), d; - })) - .catch((s => (t.probeNetwork().then(((t) => { - const n = m(t, 2); const r = n[0]; const i = n[1];o.setError(s, r, i).setMessage('groupID:'.concat(e.groupID, ' lastSequence:').concat(a)) - .end(); - })), Ee.warn(''.concat(n, ' failed. error:'), s), Mr(s)))); - } }, { key: 'setMessageRead', value(e) { - const t = this; const n = e.conversationID; const o = e.lastMessageSeq; const a = ''.concat(this._className, '.setMessageRead');Ee.log(''.concat(a, ' conversationID:').concat(n, ' lastMessageSeq:') - .concat(o)), Ne(o) || Ee.warn(''.concat(a, ' 请勿修改 Conversation.lastMessage.lastSequence,否则可能会导致已读上报结果不准确'));const s = new Da(xa);return s.setMessage(''.concat(n, '-').concat(o)), this.request({ protocolName: An, requestData: { groupID: n.replace('GROUP', ''), messageReadSeq: o } }).then((() => { - s.setNetworkType(t.getNetworkType()).end(), Ee.log(''.concat(a, ' ok.'));const e = t.getModule(Rt);return e.updateIsReadAfterReadReport({ conversationID: n, lastMessageSeq: o }), e.updateUnreadCount(n), cr(); - })) - .catch((e => (t.probeNetwork().then(((t) => { - const n = m(t, 2); const o = n[0]; const a = n[1];s.setError(e, o, a).end(); - })), Ee.log(''.concat(a, ' failed. error:'), e), Mr(e)))); - } }, { key: '_computeLastSequence', value(e) { - return e.sequence > 0 ? Promise.resolve(e.sequence) : this.getGroupLastSequence(e.groupID); - } }, { key: 'getGroupLastSequence', value(e) { - const t = this; const n = ''.concat(this._className, '.getGroupLastSequence'); const o = new Da(ps); let a = 0; let s = '';if (this.hasLocalGroup(e)) { - const r = this.getLocalGroupProfile(e); const i = r.lastMessage;if (i.lastSequence > 0 && !1 === i.onlineOnlyFlag) return a = i.lastSequence, s = 'got lastSequence:'.concat(a, ' from local group profile[lastMessage.lastSequence]. groupID:').concat(e), Ee.log(''.concat(n, ' ').concat(s)), o.setNetworkType(this.getNetworkType()).setMessage(''.concat(s)) - .end(), Promise.resolve(a);if (r.nextMessageSeq > 1) return a = r.nextMessageSeq - 1, s = 'got lastSequence:'.concat(a, ' from local group profile[nextMessageSeq]. groupID:').concat(e), Ee.log(''.concat(n, ' ').concat(s)), o.setNetworkType(this.getNetworkType()).setMessage(''.concat(s)) - .end(), Promise.resolve(a); - } const c = 'GROUP'.concat(e); const u = this.getModule(Rt).getLocalConversation(c);if (u && u.lastMessage.lastSequence && !1 === u.lastMessage.onlineOnlyFlag) return a = u.lastMessage.lastSequence, s = 'got lastSequence:'.concat(a, ' from local conversation profile[lastMessage.lastSequence]. groupID:').concat(e), Ee.log(''.concat(n, ' ').concat(s)), o.setNetworkType(this.getNetworkType()).setMessage(''.concat(s)) - .end(), Promise.resolve(a);const l = { groupIDList: [e], responseFilter: { groupBaseInfoFilter: ['NextMsgSeq'] } };return this.getGroupProfileAdvance(l).then(((r) => { - const i = r.data.successGroupList;return dt(i) ? Ee.log(''.concat(n, ' successGroupList is empty. groupID:').concat(e)) : (a = i[0].nextMessageSeq - 1, s = 'got lastSequence:'.concat(a, ' from getGroupProfileAdvance. groupID:').concat(e), Ee.log(''.concat(n, ' ').concat(s))), o.setNetworkType(t.getNetworkType()).setMessage(''.concat(s)) - .end(), a; - })) - .catch((a => (t.probeNetwork().then(((t) => { - const n = m(t, 2); const s = n[0]; const r = n[1];o.setError(a, s, r).setMessage('get lastSequence failed from getGroupProfileAdvance. groupID:'.concat(e)) - .end(); - })), Ee.warn(''.concat(n, ' failed. error:'), a), Mr(a)))); - } }, { key: 'isMessageFromAVChatroom', value(e) { - return !!this._AVChatRoomHandler && this._AVChatRoomHandler.checkJoinedAVChatRoomByID(e); - } }, { key: 'hasJoinedAVChatRoom', value() { - return this._AVChatRoomHandler ? this._AVChatRoomHandler.hasJoinedAVChatRoom() : 0; - } }, { key: 'getJoinedAVChatRoom', value() { - return this._AVChatRoomHandler ? this._AVChatRoomHandler.getJoinedAVChatRoom() : []; - } }, { key: 'isOnlineMessage', value(e, t) { - return !(!this._canIUseOnlineOnlyFlag(e) || !t || !0 !== t.onlineUserOnly); - } }, { key: '_canIUseOnlineOnlyFlag', value(e) { - const t = this.getJoinedAVChatRoom();return !t || !t.includes(e.to) || e.conversationType !== k.CONV_GROUP; - } }, { key: 'deleteLocalGroupMembers', value(e, t) { - this.getModule(Lt).deleteLocalGroupMembers(e, t); - } }, { key: 'onAVChatRoomMessage', value(e) { - this._AVChatRoomHandler && this._AVChatRoomHandler.onMessage(e); - } }, { key: 'getGroupSimplifiedInfo', value(e) { - const t = this; const n = new Da(fs); const o = { groupIDList: [e], responseFilter: { groupBaseInfoFilter: ['Type', 'Name'] } };return this.getGroupProfileAdvance(o).then(((o) => { - const a = o.data.successGroupList;return n.setNetworkType(t.getNetworkType()).setMessage('groupID:'.concat(e, ' type:').concat(a[0].type)) - .end(), a[0]; - })) - .catch(((o) => { - t.probeNetwork().then(((t) => { - const a = m(t, 2); const s = a[0]; const r = a[1];n.setError(o, s, r).setMessage('groupID:'.concat(e)) - .end(); - })); - })); - } }, { key: 'setUnjoinedAVChatRoom', value(e) { - this._unjoinedAVChatRoomList.set(e, 1); - } }, { key: 'deleteUnjoinedAVChatRoom', value(e) { - this._unjoinedAVChatRoomList.has(e) && this._unjoinedAVChatRoomList.delete(e); - } }, { key: 'isUnjoinedAVChatRoom', value(e) { - return this._unjoinedAVChatRoomList.has(e); - } }, { key: 'reset', value() { - this.groupMap.clear(), this._unjoinedAVChatRoomList.clear(), this._commonGroupHandler.reset(), this._groupSystemNoticeHandler.reset(), this._groupTipsHandler.reset(), this._AVChatRoomHandler && this._AVChatRoomHandler.reset(); - } }]), a; - }(Yt)); const Yr = (function () { - function e(t) { - o(this, e), this.userID = '', this.avatar = '', this.nick = '', this.role = '', this.joinTime = '', this.lastSendMsgTime = '', this.nameCard = '', this.muteUntil = 0, this.memberCustomField = [], this._initMember(t); - } return s(e, [{ key: '_initMember', value(e) { - this.updateMember(e); - } }, { key: 'updateMember', value(e) { - const t = [null, void 0, '', 0, NaN];e.memberCustomField && Qe(this.memberCustomField, e.memberCustomField), Ke(this, e, ['memberCustomField'], t); - } }, { key: 'updateRole', value(e) { - ['Owner', 'Admin', 'Member'].indexOf(e) < 0 || (this.role = e); - } }, { key: 'updateMuteUntil', value(e) { - Ge(e) || (this.muteUntil = Math.floor((Date.now() + 1e3 * e) / 1e3)); - } }, { key: 'updateNameCard', value(e) { - Ge(e) || (this.nameCard = e); - } }, { key: 'updateMemberCustomField', value(e) { - e && Qe(this.memberCustomField, e); - } }]), e; - }()); const zr = (function (e) { - i(a, e);const n = f(a);function a(e) { - let t;return o(this, a), (t = n.call(this, e))._className = 'GroupMemberModule', t.groupMemberListMap = new Map, t.getInnerEmitterInstance().on(Ir.PROFILE_UPDATED, t._onProfileUpdated, h(t)), t; - } return s(a, [{ key: '_onProfileUpdated', value(e) { - for (var t = this, n = e.data, o = function (e) { - const o = n[e];t.groupMemberListMap.forEach(((e) => { - e.has(o.userID) && e.get(o.userID).updateMember({ nick: o.nick, avatar: o.avatar }); - })); - }, a = 0;a < n.length;a++)o(a); - } }, { key: 'deleteGroupMemberList', value(e) { - this.groupMemberListMap.delete(e); - } }, { key: 'getGroupMemberList', value(e) { - const t = this; const n = e.groupID; const o = e.offset; const a = void 0 === o ? 0 : o; const s = e.count; const r = void 0 === s ? 15 : s; const i = ''.concat(this._className, '.getGroupMemberList'); const c = new Da(Ms);Ee.log(''.concat(i, ' groupID:').concat(n, ' offset:') - .concat(a, ' count:') - .concat(r));let u = [];return this.request({ protocolName: Un, requestData: { groupID: n, offset: a, limit: r > 100 ? 100 : r } }).then(((e) => { - const o = e.data; const a = o.members; const s = o.memberNum;if (!Re(a) || 0 === a.length) return Promise.resolve([]);const r = t.getModule(At);return r.hasLocalGroup(n) && (r.getLocalGroupProfile(n).memberNum = s), u = t._updateLocalGroupMemberMap(n, a), t.getModule(Ct).getUserProfile({ userIDList: a.map((e => e.userID)), tagList: [Ks.NICK, Ks.AVATAR] }); - })) - .then(((e) => { - const o = e.data;if (!Re(o) || 0 === o.length) return mr({ memberList: [] });const s = o.map((e => ({ userID: e.userID, nick: e.nick, avatar: e.avatar })));return t._updateLocalGroupMemberMap(n, s), c.setNetworkType(t.getNetworkType()).setMessage('groupID:'.concat(n, ' offset:').concat(a, ' count:') - .concat(r)) - .end(), Ee.log(''.concat(i, ' ok.')), cr({ memberList: u }); - })) - .catch((e => (t.probeNetwork().then(((t) => { - const n = m(t, 2); const o = n[0]; const a = n[1];c.setError(e, o, a).end(); - })), Ee.error(''.concat(i, ' failed. error:'), e), Mr(e)))); - } }, { key: 'getGroupMemberProfile', value(e) { - const n = this; const o = ''.concat(this._className, '.getGroupMemberProfile'); const a = new Da(vs);a.setMessage(e.userIDList.length > 5 ? 'userIDList.length:'.concat(e.userIDList.length) : 'userIDList:'.concat(e.userIDList)), Ee.log(''.concat(o, ' groupID:').concat(e.groupID, ' userIDList:') - .concat(e.userIDList.join(','))), e.userIDList.length > 50 && (e.userIDList = e.userIDList.slice(0, 50));const s = e.groupID; const r = e.userIDList;return this._getGroupMemberProfileAdvance(t(t({}, e), {}, { userIDList: r })).then(((e) => { - const t = e.data.members;return Re(t) && 0 !== t.length ? (n._updateLocalGroupMemberMap(s, t), n.getModule(Ct).getUserProfile({ userIDList: t.map((e => e.userID)), tagList: [Ks.NICK, Ks.AVATAR] })) : mr([]); - })) - .then(((e) => { - const t = e.data.map((e => ({ userID: e.userID, nick: e.nick, avatar: e.avatar })));n._updateLocalGroupMemberMap(s, t);const o = r.filter((e => n.hasLocalGroupMember(s, e))).map((e => n.getLocalGroupMemberInfo(s, e)));return a.setNetworkType(n.getNetworkType()).end(), cr({ memberList: o }); - })); - } }, { key: 'addGroupMember', value(e) { - const t = this; const n = ''.concat(this._className, '.addGroupMember'); const o = e.groupID; const a = this.getModule(At).getLocalGroupProfile(o); const s = a.type; const r = new Da(ys);if (r.setMessage('groupID:'.concat(o, ' groupType:').concat(s)), et(s)) { - const i = new hr({ code: Zn.CANNOT_ADD_MEMBER_IN_AVCHATROOM, message: xo });return r.setCode(Zn.CANNOT_ADD_MEMBER_IN_AVCHATROOM).setError(xo) - .setNetworkType(this.getNetworkType()) - .end(), Mr(i); - } return e.userIDList = e.userIDList.map((e => ({ userID: e }))), Ee.log(''.concat(n, ' groupID:').concat(o)), this.request({ protocolName: qn, requestData: e }).then(((o) => { - const s = o.data.members;Ee.log(''.concat(n, ' ok'));const i = s.filter((e => 1 === e.result)).map((e => e.userID)); const c = s.filter((e => 0 === e.result)).map((e => e.userID)); const u = s.filter((e => 2 === e.result)).map((e => e.userID)); const l = s.filter((e => 4 === e.result)).map((e => e.userID)); const d = 'groupID:'.concat(e.groupID, ', ') + 'successUserIDList:'.concat(i, ', ') + 'failureUserIDList:'.concat(c, ', ') + 'existedUserIDList:'.concat(u, ', ') + 'overLimitUserIDList:'.concat(l);return r.setNetworkType(t.getNetworkType()).setMoreMessage(d) - .end(), 0 === i.length ? cr({ successUserIDList: i, failureUserIDList: c, existedUserIDList: u, overLimitUserIDList: l }) : (a.memberNum += i.length, cr({ successUserIDList: i, failureUserIDList: c, existedUserIDList: u, overLimitUserIDList: l, group: a })); - })) - .catch((e => (t.probeNetwork().then(((t) => { - const n = m(t, 2); const o = n[0]; const a = n[1];r.setError(e, o, a).end(); - })), Ee.error(''.concat(n, ' failed. error:'), e), Mr(e)))); - } }, { key: 'deleteGroupMember', value(e) { - const t = this; const n = ''.concat(this._className, '.deleteGroupMember'); const o = e.groupID; const a = e.userIDList; const s = new Da(Is); const r = 'groupID:'.concat(o, ' ').concat(a.length > 5 ? 'userIDList.length:'.concat(a.length) : 'userIDList:'.concat(a));s.setMessage(r), Ee.log(''.concat(n, ' groupID:').concat(o, ' userIDList:'), a);const i = this.getModule(At).getLocalGroupProfile(o);return et(i.type) ? Mr(new hr({ code: Zn.CANNOT_KICK_MEMBER_IN_AVCHATROOM, message: Ho })) : this.request({ protocolName: Vn, requestData: e }).then((() => (s.setNetworkType(t.getNetworkType()).end(), Ee.log(''.concat(n, ' ok')), i.memberNum--, t.deleteLocalGroupMembers(o, a), cr({ group: i, userIDList: a })))) - .catch((e => (t.probeNetwork().then(((t) => { - const n = m(t, 2); const o = n[0]; const a = n[1];s.setError(e, o, a).end(); - })), Ee.error(''.concat(n, ' failed. error:'), e), Mr(e)))); - } }, { key: 'setGroupMemberMuteTime', value(e) { - const t = this; const n = e.groupID; const o = e.userID; const a = e.muteTime; const s = ''.concat(this._className, '.setGroupMemberMuteTime');if (o === this.getMyUserID()) return Mr(new hr({ code: Zn.CANNOT_MUTE_SELF, message: Wo }));Ee.log(''.concat(s, ' groupID:').concat(n, ' userID:') - .concat(o));const r = new Da(Ds);return r.setMessage('groupID:'.concat(n, ' userID:').concat(o, ' muteTime:') - .concat(a)), this._modifyGroupMemberInfo({ groupID: n, userID: o, muteTime: a }).then(((e) => { - r.setNetworkType(t.getNetworkType()).end(), Ee.log(''.concat(s, ' ok'));const o = t.getModule(At);return cr({ group: o.getLocalGroupProfile(n), member: e }); - })) - .catch((e => (t.probeNetwork().then(((t) => { - const n = m(t, 2); const o = n[0]; const a = n[1];r.setError(e, o, a).end(); - })), Ee.error(''.concat(s, ' failed. error:'), e), Mr(e)))); - } }, { key: 'setGroupMemberRole', value(e) { - const t = this; const n = ''.concat(this._className, '.setGroupMemberRole'); const o = e.groupID; const a = e.userID; const s = e.role; const r = this.getModule(At).getLocalGroupProfile(o);if (r.selfInfo.role !== k.GRP_MBR_ROLE_OWNER) return Mr(new hr({ code: Zn.NOT_OWNER, message: jo }));if ([k.GRP_WORK, k.GRP_AVCHATROOM].includes(r.type)) return Mr(new hr({ code: Zn.CANNOT_SET_MEMBER_ROLE_IN_WORK_AND_AVCHATROOM, message: $o }));if ([k.GRP_MBR_ROLE_ADMIN, k.GRP_MBR_ROLE_MEMBER].indexOf(s) < 0) return Mr(new hr({ code: Zn.INVALID_MEMBER_ROLE, message: Yo }));if (a === this.getMyUserID()) return Mr(new hr({ code: Zn.CANNOT_SET_SELF_MEMBER_ROLE, message: zo }));const i = new Da(Ss);return i.setMessage('groupID:'.concat(o, ' userID:').concat(a, ' role:') - .concat(s)), Ee.log(''.concat(n, ' groupID:').concat(o, ' userID:') - .concat(a)), this._modifyGroupMemberInfo({ groupID: o, userID: a, role: s }).then((e => (i.setNetworkType(t.getNetworkType()).end(), Ee.log(''.concat(n, ' ok')), cr({ group: r, member: e })))) - .catch((e => (t.probeNetwork().then(((t) => { - const n = m(t, 2); const o = n[0]; const a = n[1];i.setError(e, o, a).end(); - })), Ee.error(''.concat(n, ' failed. error:'), e), Mr(e)))); - } }, { key: 'setGroupMemberNameCard', value(e) { - const t = this; const n = ''.concat(this._className, '.setGroupMemberNameCard'); const o = e.groupID; const a = e.userID; const s = void 0 === a ? this.getMyUserID() : a; const r = e.nameCard;Ee.log(''.concat(n, ' groupID:').concat(o, ' userID:') - .concat(s));const i = new Da(Ts);return i.setMessage('groupID:'.concat(o, ' userID:').concat(s, ' nameCard:') - .concat(r)), this._modifyGroupMemberInfo({ groupID: o, userID: s, nameCard: r }).then(((e) => { - Ee.log(''.concat(n, ' ok')), i.setNetworkType(t.getNetworkType()).end();const a = t.getModule(At).getLocalGroupProfile(o);return s === t.getMyUserID() && a && a.setSelfNameCard(r), cr({ group: a, member: e }); - })) - .catch((e => (t.probeNetwork().then(((t) => { - const n = m(t, 2); const o = n[0]; const a = n[1];i.setError(e, o, a).end(); - })), Ee.error(''.concat(n, ' failed. error:'), e), Mr(e)))); - } }, { key: 'setGroupMemberCustomField', value(e) { - const t = this; const n = ''.concat(this._className, '.setGroupMemberCustomField'); const o = e.groupID; const a = e.userID; const s = void 0 === a ? this.getMyUserID() : a; const r = e.memberCustomField;Ee.log(''.concat(n, ' groupID:').concat(o, ' userID:') - .concat(s));const i = new Da(Es);return i.setMessage('groupID:'.concat(o, ' userID:').concat(s, ' memberCustomField:') - .concat(JSON.stringify(r))), this._modifyGroupMemberInfo({ groupID: o, userID: s, memberCustomField: r }).then(((e) => { - i.setNetworkType(t.getNetworkType()).end(), Ee.log(''.concat(n, ' ok'));const a = t.getModule(At).getLocalGroupProfile(o);return cr({ group: a, member: e }); - })) - .catch((e => (t.probeNetwork().then(((t) => { - const n = m(t, 2); const o = n[0]; const a = n[1];i.setError(e, o, a).end(); - })), Ee.error(''.concat(n, ' failed. error:'), e), Mr(e)))); - } }, { key: 'setMessageRemindType', value(e) { - const t = this; const n = ''.concat(this._className, '.setMessageRemindType'); const o = new Da(is);o.setMessage('groupID:'.concat(e.groupID)), Ee.log(''.concat(n, ' groupID:').concat(e.groupID));const a = e.groupID; const s = e.messageRemindType;return this._modifyGroupMemberInfo({ groupID: a, messageRemindType: s, userID: this.getMyUserID() }).then((() => { - o.setNetworkType(t.getNetworkType()).end(), Ee.log(''.concat(n, ' ok. groupID:').concat(e.groupID));const a = t.getModule(At).getLocalGroupProfile(e.groupID);return a && (a.selfInfo.messageRemindType = s), cr({ group: a }); - })) - .catch((e => (t.probeNetwork().then(((t) => { - const n = m(t, 2); const a = n[0]; const s = n[1];o.setError(e, a, s).end(); - })), Ee.error(''.concat(n, ' failed. error:'), e), Mr(e)))); - } }, { key: '_modifyGroupMemberInfo', value(e) { - const t = this; const n = e.groupID; const o = e.userID;return this.request({ protocolName: Kn, requestData: e }).then((() => { - if (t.hasLocalGroupMember(n, o)) { - const a = t.getLocalGroupMemberInfo(n, o);return Ge(e.muteTime) || a.updateMuteUntil(e.muteTime), Ge(e.role) || a.updateRole(e.role), Ge(e.nameCard) || a.updateNameCard(e.nameCard), Ge(e.memberCustomField) || a.updateMemberCustomField(e.memberCustomField), a; - } return t.getGroupMemberProfile({ groupID: n, userIDList: [o] }).then((e => m(e.data.memberList, 1)[0])); - })); - } }, { key: '_getGroupMemberProfileAdvance', value(e) { - return this.request({ protocolName: Fn, requestData: t(t({}, e), {}, { memberInfoFilter: e.memberInfoFilter ? e.memberInfoFilter : ['Role', 'JoinTime', 'NameCard', 'ShutUpUntil'] }) }); - } }, { key: '_updateLocalGroupMemberMap', value(e, t) { - const n = this;return Re(t) && 0 !== t.length ? t.map((t => (n.hasLocalGroupMember(e, t.userID) ? n.getLocalGroupMemberInfo(e, t.userID).updateMember(t) : n.setLocalGroupMember(e, new Yr(t)), n.getLocalGroupMemberInfo(e, t.userID)))) : []; - } }, { key: 'deleteLocalGroupMembers', value(e, t) { - const n = this.groupMemberListMap.get(e);n && t.forEach(((e) => { - n.delete(e); - })); - } }, { key: 'getLocalGroupMemberInfo', value(e, t) { - return this.groupMemberListMap.has(e) ? this.groupMemberListMap.get(e).get(t) : null; - } }, { key: 'setLocalGroupMember', value(e, t) { - if (this.groupMemberListMap.has(e)) this.groupMemberListMap.get(e).set(t.userID, t);else { - const n = (new Map).set(t.userID, t);this.groupMemberListMap.set(e, n); - } - } }, { key: 'getLocalGroupMemberList', value(e) { - return this.groupMemberListMap.get(e); - } }, { key: 'hasLocalGroupMember', value(e, t) { - return this.groupMemberListMap.has(e) && this.groupMemberListMap.get(e).has(t); - } }, { key: 'hasLocalGroupMemberMap', value(e) { - return this.groupMemberListMap.has(e); - } }, { key: 'reset', value() { - this.groupMemberListMap.clear(); - } }]), a; - }(Yt)); const Wr = (function () { - function e(t) { - o(this, e), this._userModule = t, this._className = 'ProfileHandler', this.TAG = 'profile', this.accountProfileMap = new Map, this.expirationTime = 864e5; - } return s(e, [{ key: 'setExpirationTime', value(e) { - this.expirationTime = e; - } }, { key: 'getUserProfile', value(e) { - const t = this; const n = e.userIDList;e.fromAccount = this._userModule.getMyAccount(), n.length > 100 && (Ee.warn(''.concat(this._className, '.getUserProfile 获取用户资料人数不能超过100人')), n.length = 100);for (var o, a = [], s = [], r = 0, i = n.length;r < i;r++)o = n[r], this._userModule.isMyFriend(o) && this._containsAccount(o) ? s.push(this._getProfileFromMap(o)) : a.push(o);if (0 === a.length) return mr(s);e.toAccount = a;const c = e.bFromGetMyProfile || !1; const u = [];e.toAccount.forEach(((e) => { - u.push({ toAccount: e, standardSequence: 0, customSequence: 0 }); - })), e.userItem = u;const l = new Da(Os);return l.setMessage(n.length > 5 ? 'userIDList.length:'.concat(n.length) : 'userIDList:'.concat(n)), this._userModule.request({ protocolName: tn, requestData: e }).then(((e) => { - l.setNetworkType(t._userModule.getNetworkType()).end(), Ee.info(''.concat(t._className, '.getUserProfile ok'));const n = t._handleResponse(e).concat(s);return cr(c ? n[0] : n); - })) - .catch((e => (t._userModule.probeNetwork().then(((t) => { - const n = m(t, 2); const o = n[0]; const a = n[1];l.setError(e, o, a).end(); - })), Ee.error(''.concat(t._className, '.getUserProfile failed. error:'), e), Mr(e)))); - } }, { key: 'getMyProfile', value() { - const e = this._userModule.getMyAccount();if (Ee.log(''.concat(this._className, '.getMyProfile myAccount:').concat(e)), this._fillMap(), this._containsAccount(e)) { - const t = this._getProfileFromMap(e);return Ee.debug(''.concat(this._className, '.getMyProfile from cache, myProfile:') + JSON.stringify(t)), mr(t); - } return this.getUserProfile({ fromAccount: e, userIDList: [e], bFromGetMyProfile: !0 }); - } }, { key: '_handleResponse', value(e) { - for (var t, n, o = Ve.now(), a = e.data.userProfileItem, s = [], r = 0, i = a.length;r < i;r++)'@TLS#NOT_FOUND' !== a[r].to && '' !== a[r].to && (t = a[r].to, n = this._updateMap(t, this._getLatestProfileFromResponse(t, a[r].profileItem)), s.push(n));return Ee.log(''.concat(this._className, '._handleResponse cost ').concat(Ve.now() - o, ' ms')), s; - } }, { key: '_getLatestProfileFromResponse', value(e, t) { - const n = {};if (n.userID = e, n.profileCustomField = [], !dt(t)) for (let o = 0, a = t.length;o < a;o++) if (t[o].tag.indexOf('Tag_Profile_Custom') > -1)n.profileCustomField.push({ key: t[o].tag, value: t[o].value });else switch (t[o].tag) { - case Ks.NICK:n.nick = t[o].value;break;case Ks.GENDER:n.gender = t[o].value;break;case Ks.BIRTHDAY:n.birthday = t[o].value;break;case Ks.LOCATION:n.location = t[o].value;break;case Ks.SELFSIGNATURE:n.selfSignature = t[o].value;break;case Ks.ALLOWTYPE:n.allowType = t[o].value;break;case Ks.LANGUAGE:n.language = t[o].value;break;case Ks.AVATAR:n.avatar = t[o].value;break;case Ks.MESSAGESETTINGS:n.messageSettings = t[o].value;break;case Ks.ADMINFORBIDTYPE:n.adminForbidType = t[o].value;break;case Ks.LEVEL:n.level = t[o].value;break;case Ks.ROLE:n.role = t[o].value;break;default:Ee.warn(''.concat(this._className, '._handleResponse unknown tag:'), t[o].tag, t[o].value); - } return n; - } }, { key: 'updateMyProfile', value(e) { - const t = this; const n = ''.concat(this._className, '.updateMyProfile'); const o = new Da(Ls);o.setMessage(JSON.stringify(e));const a = (new Ar).validate(e);if (!a.valid) return o.setCode(Zn.UPDATE_PROFILE_INVALID_PARAM).setMoreMessage(''.concat(n, ' info:').concat(a.tips)) - .setNetworkType(this._userModule.getNetworkType()) - .end(), Ee.error(''.concat(n, ' info:').concat(a.tips, ',请参考 https://web.sdk.qcloud.com/im/doc/zh-cn/SDK.html#updateMyProfile')), Mr({ code: Zn.UPDATE_PROFILE_INVALID_PARAM, message: Jo });const s = [];for (const r in e)Object.prototype.hasOwnProperty.call(e, r) && ('profileCustomField' === r ? e.profileCustomField.forEach(((e) => { - s.push({ tag: e.key, value: e.value }); - })) : s.push({ tag: Ks[r.toUpperCase()], value: e[r] }));return 0 === s.length ? (o.setCode(Zn.UPDATE_PROFILE_NO_KEY).setMoreMessage(Xo) - .setNetworkType(this._userModule.getNetworkType()) - .end(), Ee.error(''.concat(n, ' info:').concat(Xo, ',请参考 https://web.sdk.qcloud.com/im/doc/zh-cn/SDK.html#updateMyProfile')), Mr({ code: Zn.UPDATE_PROFILE_NO_KEY, message: Xo })) : this._userModule.request({ protocolName: nn, requestData: { fromAccount: this._userModule.getMyAccount(), profileItem: s } }).then(((a) => { - o.setNetworkType(t._userModule.getNetworkType()).end(), Ee.info(''.concat(n, ' ok'));const s = t._updateMap(t._userModule.getMyAccount(), e);return t._userModule.emitOuterEvent(E.PROFILE_UPDATED, [s]), mr(s); - })) - .catch((e => (t._userModule.probeNetwork().then(((t) => { - const n = m(t, 2); const a = n[0]; const s = n[1];o.setError(e, a, s).end(); - })), Ee.error(''.concat(n, ' failed. error:'), e), Mr(e)))); - } }, { key: 'onProfileModified', value(e) { - const t = e.dataList;if (!dt(t)) { - let n; let o; const a = t.length;Ee.info(''.concat(this._className, '.onProfileModified count:').concat(a));for (var s = [], r = this._userModule.getModule(Rt), i = 0;i < a;i++)n = t[i].userID, o = this._updateMap(n, this._getLatestProfileFromResponse(n, t[i].profileList)), s.push(o), n === this._userModule.getMyAccount() && r.onMyProfileModified({ latestNick: o.nick, latestAvatar: o.avatar });this._userModule.emitInnerEvent(Ir.PROFILE_UPDATED, s), this._userModule.emitOuterEvent(E.PROFILE_UPDATED, s); - } - } }, { key: '_fillMap', value() { - if (0 === this.accountProfileMap.size) { - for (let e = this._getCachedProfiles(), t = Date.now(), n = 0, o = e.length;n < o;n++)t - e[n].lastUpdatedTime < this.expirationTime && this.accountProfileMap.set(e[n].userID, e[n]);Ee.log(''.concat(this._className, '._fillMap from cache, map.size:').concat(this.accountProfileMap.size)); - } - } }, { key: '_updateMap', value(e, t) { - let n; const o = Date.now();return this._containsAccount(e) ? (n = this._getProfileFromMap(e), t.profileCustomField && Qe(n.profileCustomField, t.profileCustomField), Ke(n, t, ['profileCustomField']), n.lastUpdatedTime = o) : (n = new Ar(t), (this._userModule.isMyFriend(e) || e === this._userModule.getMyAccount()) && (n.lastUpdatedTime = o, this.accountProfileMap.set(e, n))), this._flushMap(e === this._userModule.getMyAccount()), n; - } }, { key: '_flushMap', value(e) { - const t = M(this.accountProfileMap.values()); const n = this._userModule.getStorageModule();Ee.debug(''.concat(this._className, '._flushMap length:').concat(t.length, ' flushAtOnce:') - .concat(e)), n.setItem(this.TAG, t, e); - } }, { key: '_containsAccount', value(e) { - return this.accountProfileMap.has(e); - } }, { key: '_getProfileFromMap', value(e) { - return this.accountProfileMap.get(e); - } }, { key: '_getCachedProfiles', value() { - const e = this._userModule.getStorageModule().getItem(this.TAG);return dt(e) ? [] : e; - } }, { key: 'onConversationsProfileUpdated', value(e) { - for (var t, n, o, a = [], s = 0, r = e.length;s < r;s++)n = (t = e[s]).userID, this._userModule.isMyFriend(n) || (this._containsAccount(n) ? (o = this._getProfileFromMap(n), Ke(o, t) > 0 && a.push(n)) : a.push(t.userID));0 !== a.length && (Ee.info(''.concat(this._className, '.onConversationsProfileUpdated toAccountList:').concat(a)), this.getUserProfile({ userIDList: a })); - } }, { key: 'getNickAndAvatarByUserID', value(e) { - if (this._containsAccount(e)) { - const t = this._getProfileFromMap(e);return { nick: t.nick, avatar: t.avatar }; - } return { nick: '', avatar: '' }; - } }, { key: 'reset', value() { - this._flushMap(!0), this.accountProfileMap.clear(); - } }]), e; - }()); const Jr = function e(t) { - o(this, e), dt || (this.userID = t.userID || '', this.timeStamp = t.timeStamp || 0); - }; const Xr = (function () { - function e(t) { - o(this, e), this._userModule = t, this._className = 'BlacklistHandler', this._blacklistMap = new Map, this.startIndex = 0, this.maxLimited = 100, this.currentSequence = 0; - } return s(e, [{ key: 'getLocalBlacklist', value() { - return M(this._blacklistMap.keys()); - } }, { key: 'getBlacklist', value() { - const e = this; const t = ''.concat(this._className, '.getBlacklist'); const n = { fromAccount: this._userModule.getMyAccount(), maxLimited: this.maxLimited, startIndex: 0, lastSequence: this.currentSequence }; const o = new Da(Rs);return this._userModule.request({ protocolName: on, requestData: n }).then(((n) => { - const a = n.data; const s = a.blackListItem; const r = a.currentSequence; const i = dt(s) ? 0 : s.length;o.setNetworkType(e._userModule.getNetworkType()).setMessage('blackList count:'.concat(i)) - .end(), Ee.info(''.concat(t, ' ok')), e.currentSequence = r, e._handleResponse(s, !0), e._userModule.emitOuterEvent(E.BLACKLIST_UPDATED, M(e._blacklistMap.keys())); - })) - .catch((n => (e._userModule.probeNetwork().then(((e) => { - const t = m(e, 2); const a = t[0]; const s = t[1];o.setError(n, a, s).end(); - })), Ee.error(''.concat(t, ' failed. error:'), n), Mr(n)))); - } }, { key: 'addBlacklist', value(e) { - const t = this; const n = ''.concat(this._className, '.addBlacklist'); const o = new Da(Gs);if (!Re(e.userIDList)) return o.setCode(Zn.ADD_BLACKLIST_INVALID_PARAM).setMessage(Qo) - .setNetworkType(this._userModule.getNetworkType()) - .end(), Ee.error(''.concat(n, ' options.userIDList 必需是数组')), Mr({ code: Zn.ADD_BLACKLIST_INVALID_PARAM, message: Qo });const a = this._userModule.getMyAccount();return 1 === e.userIDList.length && e.userIDList[0] === a ? (o.setCode(Zn.CANNOT_ADD_SELF_TO_BLACKLIST).setMessage(ea) - .setNetworkType(this._userModule.getNetworkType()) - .end(), Ee.error(''.concat(n, ' 不能把自己拉黑')), Mr({ code: Zn.CANNOT_ADD_SELF_TO_BLACKLIST, message: ea })) : (e.userIDList.includes(a) && (e.userIDList = e.userIDList.filter((e => e !== a)), Ee.warn(''.concat(n, ' 不能把自己拉黑,已过滤'))), e.fromAccount = this._userModule.getMyAccount(), e.toAccount = e.userIDList, this._userModule.request({ protocolName: an, requestData: e }).then((a => (o.setNetworkType(t._userModule.getNetworkType()).setMessage(e.userIDList.length > 5 ? 'userIDList.length:'.concat(e.userIDList.length) : 'userIDList:'.concat(e.userIDList)) - .end(), Ee.info(''.concat(n, ' ok')), t._handleResponse(a.resultItem, !0), cr(M(t._blacklistMap.keys()))))) - .catch((e => (t._userModule.probeNetwork().then(((t) => { - const n = m(t, 2); const a = n[0]; const s = n[1];o.setError(e, a, s).end(); - })), Ee.error(''.concat(n, ' failed. error:'), e), Mr(e))))); - } }, { key: '_handleResponse', value(e, t) { - if (!dt(e)) for (var n, o, a, s = 0, r = e.length;s < r;s++)o = e[s].to, a = e[s].resultCode, (Ge(a) || 0 === a) && (t ? ((n = this._blacklistMap.has(o) ? this._blacklistMap.get(o) : new Jr).userID = o, !dt(e[s].addBlackTimeStamp) && (n.timeStamp = e[s].addBlackTimeStamp), this._blacklistMap.set(o, n)) : this._blacklistMap.has(o) && (n = this._blacklistMap.get(o), this._blacklistMap.delete(o)));Ee.log(''.concat(this._className, '._handleResponse total:').concat(this._blacklistMap.size, ' bAdd:') - .concat(t)); - } }, { key: 'deleteBlacklist', value(e) { - const t = this; const n = ''.concat(this._className, '.deleteBlacklist'); const o = new Da(ws);return Re(e.userIDList) ? (e.fromAccount = this._userModule.getMyAccount(), e.toAccount = e.userIDList, this._userModule.request({ protocolName: sn, requestData: e }).then((a => (o.setNetworkType(t._userModule.getNetworkType()).setMessage(e.userIDList.length > 5 ? 'userIDList.length:'.concat(e.userIDList.length) : 'userIDList:'.concat(e.userIDList)) - .end(), Ee.info(''.concat(n, ' ok')), t._handleResponse(a.data.resultItem, !1), cr(M(t._blacklistMap.keys()))))) - .catch((e => (t._userModule.probeNetwork().then(((t) => { - const n = m(t, 2); const a = n[0]; const s = n[1];o.setError(e, a, s).end(); - })), Ee.error(''.concat(n, ' failed. error:'), e), Mr(e))))) : (o.setCode(Zn.DEL_BLACKLIST_INVALID_PARAM).setMessage(Zo) - .setNetworkType(this._userModule.getNetworkType()) - .end(), Ee.error(''.concat(n, ' options.userIDList 必需是数组')), Mr({ code: Zn.DEL_BLACKLIST_INVALID_PARAM, message: Zo })); - } }, { key: 'onAccountDeleted', value(e) { - for (var t, n = [], o = 0, a = e.length;o < a;o++)t = e[o], this._blacklistMap.has(t) && (this._blacklistMap.delete(t), n.push(t));n.length > 0 && (Ee.log(''.concat(this._className, '.onAccountDeleted count:').concat(n.length, ' userIDList:'), n), this._userModule.emitOuterEvent(E.BLACKLIST_UPDATED, M(this._blacklistMap.keys()))); - } }, { key: 'onAccountAdded', value(e) { - for (var t, n = [], o = 0, a = e.length;o < a;o++)t = e[o], this._blacklistMap.has(t) || (this._blacklistMap.set(t, new Jr({ userID: t })), n.push(t));n.length > 0 && (Ee.log(''.concat(this._className, '.onAccountAdded count:').concat(n.length, ' userIDList:'), n), this._userModule.emitOuterEvent(E.BLACKLIST_UPDATED, M(this._blacklistMap.keys()))); - } }, { key: 'reset', value() { - this._blacklistMap.clear(), this.startIndex = 0, this.maxLimited = 100, this.currentSequence = 0; - } }]), e; - }()); const Qr = (function (e) { - i(n, e);const t = f(n);function n(e) { - let a;return o(this, n), (a = t.call(this, e))._className = 'UserModule', a._profileHandler = new Wr(h(a)), a._blacklistHandler = new Xr(h(a)), a.getInnerEmitterInstance().on(Ir.CONTEXT_A2KEY_AND_TINYID_UPDATED, a.onContextUpdated, h(a)), a; - } return s(n, [{ key: 'onContextUpdated', value(e) { - this._profileHandler.getMyProfile(), this._blacklistHandler.getBlacklist(); - } }, { key: 'onProfileModified', value(e) { - this._profileHandler.onProfileModified(e); - } }, { key: 'onRelationChainModified', value(e) { - const t = e.dataList;if (!dt(t)) { - const n = [];t.forEach(((e) => { - e.blackListDelAccount && n.push.apply(n, M(e.blackListDelAccount)); - })), n.length > 0 && this._blacklistHandler.onAccountDeleted(n);const o = [];t.forEach(((e) => { - e.blackListAddAccount && o.push.apply(o, M(e.blackListAddAccount)); - })), o.length > 0 && this._blacklistHandler.onAccountAdded(o); - } - } }, { key: 'onConversationsProfileUpdated', value(e) { - this._profileHandler.onConversationsProfileUpdated(e); - } }, { key: 'getMyAccount', value() { - return this.getMyUserID(); - } }, { key: 'getMyProfile', value() { - return this._profileHandler.getMyProfile(); - } }, { key: 'getStorageModule', value() { - return this.getModule(wt); - } }, { key: 'isMyFriend', value(e) { - const t = this.getModule(Ot);return !!t && t.isMyFriend(e); - } }, { key: 'getUserProfile', value(e) { - return this._profileHandler.getUserProfile(e); - } }, { key: 'updateMyProfile', value(e) { - return this._profileHandler.updateMyProfile(e); - } }, { key: 'getNickAndAvatarByUserID', value(e) { - return this._profileHandler.getNickAndAvatarByUserID(e); - } }, { key: 'getLocalBlacklist', value() { - const e = this._blacklistHandler.getLocalBlacklist();return mr(e); - } }, { key: 'addBlacklist', value(e) { - return this._blacklistHandler.addBlacklist(e); - } }, { key: 'deleteBlacklist', value(e) { - return this._blacklistHandler.deleteBlacklist(e); - } }, { key: 'reset', value() { - Ee.log(''.concat(this._className, '.reset')), this._profileHandler.reset(), this._blacklistHandler.reset(); - } }]), n; - }(Yt)); const Zr = (function () { - function e(t, n) { - o(this, e), this._moduleManager = t, this._isLoggedIn = !1, this._SDKAppID = n.SDKAppID, this._userID = n.userID || '', this._userSig = n.userSig || '', this._version = '2.12.2', this._a2Key = '', this._tinyID = '', this._contentType = 'json', this._unlimitedAVChatRoom = n.unlimitedAVChatRoom, this._scene = n.scene, this._oversea = n.oversea, this._instanceID = n.instanceID, this._statusInstanceID = 0; - } return s(e, [{ key: 'isLoggedIn', value() { - return this._isLoggedIn; - } }, { key: 'isOversea', value() { - return this._oversea; - } }, { key: 'isUnlimitedAVChatRoom', value() { - return this._unlimitedAVChatRoom; - } }, { key: 'getUserID', value() { - return this._userID; - } }, { key: 'setUserID', value(e) { - this._userID = e; - } }, { key: 'setUserSig', value(e) { - this._userSig = e; - } }, { key: 'getUserSig', value() { - return this._userSig; - } }, { key: 'getSDKAppID', value() { - return this._SDKAppID; - } }, { key: 'getTinyID', value() { - return this._tinyID; - } }, { key: 'setTinyID', value(e) { - this._tinyID = e, this._isLoggedIn = !0; - } }, { key: 'getScene', value() { - return this._scene; - } }, { key: 'getInstanceID', value() { - return this._instanceID; - } }, { key: 'getStatusInstanceID', value() { - return this._statusInstanceID; - } }, { key: 'setStatusInstanceID', value(e) { - this._statusInstanceID = e; - } }, { key: 'getVersion', value() { - return this._version; - } }, { key: 'getA2Key', value() { - return this._a2Key; - } }, { key: 'setA2Key', value(e) { - this._a2Key = e; - } }, { key: 'getContentType', value() { - return this._contentType; - } }, { key: 'reset', value() { - this._isLoggedIn = !1, this._userSig = '', this._a2Key = '', this._tinyID = '', this._statusInstanceID = 0; - } }]), e; - }()); const ei = (function (e) { - i(n, e);const t = f(n);function n(e) { - let a;return o(this, n), (a = t.call(this, e))._className = 'SignModule', a._helloInterval = 120, Dr.mixin(h(a)), a; - } return s(n, [{ key: 'onCheckTimer', value(e) { - this.isLoggedIn() && e % this._helloInterval == 0 && this._hello(); - } }, { key: 'login', value(e) { - if (this.isLoggedIn()) { - const t = '您已经登录账号'.concat(e.userID, '!如需切换账号登录,请先调用 logout 接口登出,再调用 login 接口登录。');return Ee.warn(t), mr({ actionStatus: 'OK', errorCode: 0, errorInfo: t, repeatLogin: !0 }); - }Ee.log(''.concat(this._className, '.login userID:').concat(e.userID));const n = this._checkLoginInfo(e);if (0 !== n.code) return Mr(n);const o = this.getModule(Gt); const a = e.userID; const s = e.userSig;return o.setUserID(a), o.setUserSig(s), this.getModule(Kt).updateProtocolConfig(), this._login(); - } }, { key: '_login', value() { - const e = this; const t = this.getModule(Gt); const n = new Da(Ea);return n.setMessage(''.concat(t.getScene())).setMoreMessage('identifier:'.concat(this.getMyUserID())), this.request({ protocolName: zt }).then(((o) => { - const a = Date.now(); let s = null; const r = o.data; const i = r.a2Key; const c = r.tinyID; const u = r.helloInterval; const l = r.instanceID; const d = r.timeStamp;Ee.log(''.concat(e._className, '.login ok. helloInterval:').concat(u, ' instanceID:') - .concat(l, ' timeStamp:') - .concat(d));const g = 1e3 * d; const p = a - n.getStartTs(); const h = g + parseInt(p / 2) - a; const _ = n.getStartTs() + h;if (n.start(_), (function (e, t) { - ve = t;const n = new Date;n.setTime(e), Ee.info('baseTime from server: '.concat(n, ' offset: ').concat(ve)); - }(g, h)), !c) throw s = new hr({ code: Zn.NO_TINYID, message: oo }), n.setError(s, !0, e.getNetworkType()).end(), s;if (!i) throw s = new hr({ code: Zn.NO_A2KEY, message: ao }), n.setError(s, !0, e.getNetworkType()).end(), s;return n.setNetworkType(e.getNetworkType()).setMoreMessage('helloInterval:'.concat(u, ' instanceID:').concat(l, ' offset:') - .concat(h)) - .end(), t.setA2Key(i), t.setTinyID(c), t.setStatusInstanceID(l), e.getModule(Kt).updateProtocolConfig(), e.emitInnerEvent(Ir.CONTEXT_A2KEY_AND_TINYID_UPDATED), e._helloInterval = u, e.triggerReady(), e._fetchCloudControlConfig(), o; - })) - .catch((t => (e.probeNetwork().then(((e) => { - const o = m(e, 2); const a = o[0]; const s = o[1];n.setError(t, a, s).end(!0); - })), Ee.error(''.concat(e._className, '.login failed. error:'), t), e._moduleManager.onLoginFailed(), Mr(t)))); - } }, { key: 'logout', value() { - const e = this;return this.isLoggedIn() ? (new Da(ka).setNetworkType(this.getNetworkType()) - .setMessage('identifier:'.concat(this.getMyUserID())) - .end(!0), Ee.info(''.concat(this._className, '.logout')), this.request({ protocolName: Wt }).then((() => (e.resetReady(), mr({})))) - .catch((t => (Ee.error(''.concat(e._className, '._logout error:'), t), e.resetReady(), mr({}))))) : Mr({ code: Zn.USER_NOT_LOGGED_IN, message: so }); - } }, { key: '_fetchCloudControlConfig', value() { - this.getModule(Ht).fetchConfig(); - } }, { key: '_hello', value() { - const e = this;this.request({ protocolName: Jt }).catch(((t) => { - Ee.warn(''.concat(e._className, '._hello error:'), t); - })); - } }, { key: '_checkLoginInfo', value(e) { - let t = 0; let n = '';return dt(this.getModule(Gt).getSDKAppID()) ? (t = Zn.NO_SDKAPPID, n = eo) : dt(e.userID) ? (t = Zn.NO_IDENTIFIER, n = to) : dt(e.userSig) && (t = Zn.NO_USERSIG, n = no), { code: t, message: n }; - } }, { key: 'onMultipleAccountKickedOut', value(e) { - const t = this;new Da(Ca).setNetworkType(this.getNetworkType()) - .setMessage('type:'.concat(k.KICKED_OUT_MULT_ACCOUNT, ' newInstanceInfo:').concat(JSON.stringify(e))) - .end(!0), Ee.warn(''.concat(this._className, '.onMultipleAccountKickedOut userID:').concat(this.getMyUserID(), ' newInstanceInfo:'), e), this.logout().then((() => { - t.emitOuterEvent(E.KICKED_OUT, { type: k.KICKED_OUT_MULT_ACCOUNT }), t._moduleManager.reset(); - })); - } }, { key: 'onMultipleDeviceKickedOut', value(e) { - const t = this;new Da(Ca).setNetworkType(this.getNetworkType()) - .setMessage('type:'.concat(k.KICKED_OUT_MULT_DEVICE, ' newInstanceInfo:').concat(JSON.stringify(e))) - .end(!0), Ee.warn(''.concat(this._className, '.onMultipleDeviceKickedOut userID:').concat(this.getMyUserID(), ' newInstanceInfo:'), e), this.logout().then((() => { - t.emitOuterEvent(E.KICKED_OUT, { type: k.KICKED_OUT_MULT_DEVICE }), t._moduleManager.reset(); - })); - } }, { key: 'onUserSigExpired', value() { - new Da(Ca).setNetworkType(this.getNetworkType()) - .setMessage(k.KICKED_OUT_USERSIG_EXPIRED) - .end(!0), Ee.warn(''.concat(this._className, '.onUserSigExpired: userSig 签名过期被踢下线')), 0 !== this.getModule(Gt).getStatusInstanceID() && (this.emitOuterEvent(E.KICKED_OUT, { type: k.KICKED_OUT_USERSIG_EXPIRED }), this._moduleManager.reset()); - } }, { key: 'reset', value() { - Ee.log(''.concat(this._className, '.reset')), this.resetReady(), this._helloInterval = 120; - } }]), n; - }(Yt));function ti() { - return null; - } const ni = (function () { - function e(t) { - o(this, e), this._moduleManager = t, this._className = 'StorageModule', this._storageQueue = new Map, this._errorTolerantHandle(); - } return s(e, [{ key: '_errorTolerantHandle', value() { - z || !Ge(window) && !Ge(window.localStorage) || (this.getItem = ti, this.setItem = ti, this.removeItem = ti, this.clear = ti); - } }, { key: 'onCheckTimer', value(e) { - if (e % 20 == 0) { - if (0 === this._storageQueue.size) return;this._doFlush(); - } - } }, { key: '_doFlush', value() { - try { - let e; const t = S(this._storageQueue);try { - for (t.s();!(e = t.n()).done;) { - const n = m(e.value, 2); const o = n[0]; const a = n[1];this._setStorageSync(this._getKey(o), a); - } - } catch (s) { - t.e(s); - } finally { - t.f(); - } this._storageQueue.clear(); - } catch (r) { - Ee.warn(''.concat(this._className, '._doFlush error:'), r); - } - } }, { key: '_getPrefix', value() { - const e = this._moduleManager.getModule(Gt);return 'TIM_'.concat(e.getSDKAppID(), '_').concat(e.getUserID(), '_'); - } }, { key: '_getKey', value(e) { - return ''.concat(this._getPrefix()).concat(e); - } }, { key: 'getItem', value(e) { - const t = !(arguments.length > 1 && void 0 !== arguments[1]) || arguments[1];try { - const n = t ? this._getKey(e) : e;return this._getStorageSync(n); - } catch (o) { - return Ee.warn(''.concat(this._className, '.getItem error:'), o), {}; - } - } }, { key: 'setItem', value(e, t) { - const n = arguments.length > 2 && void 0 !== arguments[2] && arguments[2]; const o = !(arguments.length > 3 && void 0 !== arguments[3]) || arguments[3];if (n) { - const a = o ? this._getKey(e) : e;this._setStorageSync(a, t); - } else this._storageQueue.set(e, t); - } }, { key: 'clear', value() { - try { - z ? J.clearStorageSync() : localStorage && localStorage.clear(); - } catch (e) { - Ee.warn(''.concat(this._className, '.clear error:'), e); - } - } }, { key: 'removeItem', value(e) { - const t = !(arguments.length > 1 && void 0 !== arguments[1]) || arguments[1];try { - const n = t ? this._getKey(e) : e;this._removeStorageSync(n); - } catch (o) { - Ee.warn(''.concat(this._className, '.removeItem error:'), o); - } - } }, { key: 'getSize', value(e) { - const t = this; const n = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : 'b';try { - const o = { size: 0, limitSize: 5242880, unit: n };if (Object.defineProperty(o, 'leftSize', { enumerable: !0, get() { - return o.limitSize - o.size; - } }), z && (o.limitSize = 1024 * J.getStorageInfoSync().limitSize), e)o.size = JSON.stringify(this.getItem(e)).length + this._getKey(e).length;else if (z) { - const a = J.getStorageInfoSync(); const s = a.keys;s.forEach(((e) => { - o.size += JSON.stringify(t._getStorageSync(e)).length + t._getKey(e).length; - })); - } else if (localStorage) for (const r in localStorage)localStorage.hasOwnProperty(r) && (o.size += localStorage.getItem(r).length + r.length);return this._convertUnit(o); - } catch (i) { - Ee.warn(''.concat(this._className, ' error:'), i); - } - } }, { key: '_convertUnit', value(e) { - const t = {}; const n = e.unit;for (const o in t.unit = n, e)'number' === typeof e[o] && ('kb' === n.toLowerCase() ? t[o] = Math.round(e[o] / 1024) : 'mb' === n.toLowerCase() ? t[o] = Math.round(e[o] / 1024 / 1024) : t[o] = e[o]);return t; - } }, { key: '_setStorageSync', value(e, t) { - z ? $ ? my.setStorageSync({ key: e, data: t }) : J.setStorageSync(e, t) : localStorage && localStorage.setItem(e, JSON.stringify(t)); - } }, { key: '_getStorageSync', value(e) { - return z ? $ ? my.getStorageSync({ key: e }).data : J.getStorageSync(e) : localStorage ? JSON.parse(localStorage.getItem(e)) : {}; - } }, { key: '_removeStorageSync', value(e) { - z ? $ ? my.removeStorageSync({ key: e }) : J.removeStorageSync(e) : localStorage && localStorage.removeItem(e); - } }, { key: 'reset', value() { - Ee.log(''.concat(this._className, '.reset')), this._doFlush(); - } }]), e; - }()); const oi = (function () { - function e(t) { - o(this, e), this._className = 'SSOLogBody', this._report = []; - } return s(e, [{ key: 'pushIn', value(e) { - Ee.debug(''.concat(this._className, '.pushIn'), this._report.length, e), this._report.push(e); - } }, { key: 'backfill', value(e) { - let t;Re(e) && 0 !== e.length && (Ee.debug(''.concat(this._className, '.backfill'), this._report.length, e.length), (t = this._report).unshift.apply(t, M(e))); - } }, { key: 'getLogsNumInMemory', value() { - return this._report.length; - } }, { key: 'isEmpty', value() { - return 0 === this._report.length; - } }, { key: '_reset', value() { - this._report.length = 0, this._report = []; - } }, { key: 'getLogsInMemory', value() { - const e = this._report.slice();return this._reset(), e; - } }]), e; - }()); const ai = function (e) { - const t = e.getModule(Gt);return { SDKType: 10, SDKAppID: t.getSDKAppID(), SDKVersion: t.getVersion(), tinyID: Number(t.getTinyID()), userID: t.getUserID(), platform: e.getPlatform(), instanceID: t.getInstanceID(), traceID: ye() }; - }; const si = (function (e) { - i(a, e);const n = f(a);function a(e) { - let t;o(this, a), (t = n.call(this, e))._className = 'EventStatModule', t.TAG = 'im-ssolog-event', t._reportBody = new oi, t.MIN_THRESHOLD = 20, t.MAX_THRESHOLD = 100, t.WAITING_TIME = 6e4, t.REPORT_LEVEL = [4, 5, 6], t._lastReportTime = Date.now();const s = t.getInnerEmitterInstance();return s.on(Ir.CONTEXT_A2KEY_AND_TINYID_UPDATED, t._onLoginSuccess, h(t)), s.on(Ir.CLOUD_CONFIG_UPDATED, t._onCloudConfigUpdate, h(t)), t; - } return s(a, [{ key: 'reportAtOnce', value() { - Ee.debug(''.concat(this._className, '.reportAtOnce')), this._report(); - } }, { key: '_onLoginSuccess', value() { - const e = this; const t = this.getModule(wt); const n = t.getItem(this.TAG, !1);!dt(n) && Pe(n.forEach) && (Ee.log(''.concat(this._className, '._onLoginSuccess get ssolog in storage, count:').concat(n.length)), n.forEach(((t) => { - e._reportBody.pushIn(t); - })), t.removeItem(this.TAG, !1)); - } }, { key: '_onCloudConfigUpdate', value() { - const e = this.getCloudConfig('report_threshold_event'); const t = this.getCloudConfig('report_waiting_event'); const n = this.getCloudConfig('report_level_event');Ge(e) || (this.MIN_THRESHOLD = Number(e)), Ge(t) || (this.WAITING_TIME = Number(t)), Ge(n) || (this.REPORT_LEVEL = n.split(',').map((e => Number(e)))); - } }, { key: 'pushIn', value(e) { - e instanceof Da && (e.updateTimeStamp(), this._reportBody.pushIn(e), this._reportBody.getLogsNumInMemory() >= this.MIN_THRESHOLD && this._report()); - } }, { key: 'onCheckTimer', value() { - Date.now() < this._lastReportTime + this.WAITING_TIME || this._reportBody.isEmpty() || this._report(); - } }, { key: '_filterLogs', value(e) { - const t = this;return e.filter((e => t.REPORT_LEVEL.includes(e.level))); - } }, { key: '_report', value() { - const e = this;if (!this._reportBody.isEmpty()) { - const n = this._reportBody.getLogsInMemory(); const o = this._filterLogs(n);if (0 !== o.length) { - const a = { header: ai(this), event: o };this.request({ protocolName: Hn, requestData: t({}, a) }).then((() => { - e._lastReportTime = Date.now(); - })) - .catch(((t) => { - Ee.warn(''.concat(e._className, '.report failed. networkType:').concat(e.getNetworkType(), ' error:'), t), e._reportBody.backfill(n), e._reportBody.getLogsNumInMemory() > e.MAX_THRESHOLD && e._flushAtOnce(); - })); - } else this._lastReportTime = Date.now(); - } - } }, { key: '_flushAtOnce', value() { - const e = this.getModule(wt); const t = e.getItem(this.TAG, !1); const n = this._reportBody.getLogsInMemory();if (dt(t))Ee.log(''.concat(this._className, '._flushAtOnce count:').concat(n.length)), e.setItem(this.TAG, n, !0, !1);else { - let o = n.concat(t);o.length > this.MAX_THRESHOLD && (o = o.slice(0, this.MAX_THRESHOLD)), Ee.log(''.concat(this._className, '._flushAtOnce count:').concat(o.length)), e.setItem(this.TAG, o, !0, !1); - } - } }, { key: 'reset', value() { - Ee.log(''.concat(this._className, '.reset')), this._lastReportTime = 0, this._report(); - } }]), a; - }(Yt)); const ri = 'none'; const ii = 'online'; const ci = (function () { - function e(t) { - o(this, e), this._moduleManager = t, this._networkType = '', this._className = 'NetMonitorModule', this.MAX_WAIT_TIME = 3e3; - } return s(e, [{ key: 'start', value() { - const e = this;if (z) { - J.getNetworkType({ success(t) { - e._networkType = t.networkType, t.networkType === ri ? Ee.warn(''.concat(e._className, '.start no network, please check!')) : Ee.info(''.concat(e._className, '.start networkType:').concat(t.networkType)); - } });const t = this._onNetworkStatusChange.bind(this);J.offNetworkStatusChange && (Y || H ? J.offNetworkStatusChange(t) : J.offNetworkStatusChange()), J.onNetworkStatusChange(t); - } else this._networkType = ii; - } }, { key: '_onNetworkStatusChange', value(e) { - e.isConnected ? (Ee.info(''.concat(this._className, '._onNetworkStatusChange previousNetworkType:').concat(this._networkType, ' currentNetworkType:') - .concat(e.networkType)), this._networkType !== e.networkType && this._moduleManager.getModule(xt).reConnect()) : Ee.warn(''.concat(this._className, '._onNetworkStatusChange no network, please check!'));this._networkType = e.networkType; - } }, { key: 'probe', value() { - const e = this;return new Promise(((t, n) => { - if (z)J.getNetworkType({ success(n) { - e._networkType = n.networkType, n.networkType === ri ? (Ee.warn(''.concat(e._className, '.probe no network, please check!')), t([!1, n.networkType])) : (Ee.info(''.concat(e._className, '.probe networkType:').concat(n.networkType)), t([!0, n.networkType])); - } });else if (window && window.fetch)fetch(''.concat(We(), '//web.sdk.qcloud.com/im/assets/speed.xml?random=').concat(Math.random())).then(((e) => { - e.ok ? t([!0, ii]) : t([!1, ri]); - })) - .catch(((e) => { - t([!1, ri]); - }));else { - const o = new XMLHttpRequest; const a = setTimeout((() => { - Ee.warn(''.concat(e._className, '.probe fetch timeout. Probably no network, please check!')), o.abort(), e._networkType = ri, t([!1, ri]); - }), e.MAX_WAIT_TIME);o.onreadystatechange = function () { - 4 === o.readyState && (clearTimeout(a), 200 === o.status || 304 === o.status ? (this._networkType = ii, t([!0, ii])) : (Ee.warn(''.concat(this.className, '.probe fetch status:').concat(o.status, '. Probably no network, please check!')), this._networkType = ri, t([!1, ri]))); - }, o.open('GET', ''.concat(We(), '//web.sdk.qcloud.com/im/assets/speed.xml?random=').concat(Math.random())), o.send(); - } - })); - } }, { key: 'getNetworkType', value() { - return this._networkType; - } }]), e; - }()); const ui = A(((e) => { - const t = Object.prototype.hasOwnProperty; let n = '~';function o() {} function a(e, t, n) { - this.fn = e, this.context = t, this.once = n || !1; - } function s(e, t, o, s, r) { - if ('function' !== typeof o) throw new TypeError('The listener must be a function');const i = new a(o, s || e, r); const c = n ? n + t : t;return e._events[c] ? e._events[c].fn ? e._events[c] = [e._events[c], i] : e._events[c].push(i) : (e._events[c] = i, e._eventsCount++), e; - } function r(e, t) { - 0 == --e._eventsCount ? e._events = new o : delete e._events[t]; - } function i() { - this._events = new o, this._eventsCount = 0; - }Object.create && (o.prototype = Object.create(null), (new o).__proto__ || (n = !1)), i.prototype.eventNames = function () { - let e; let o; const a = [];if (0 === this._eventsCount) return a;for (o in e = this._events)t.call(e, o) && a.push(n ? o.slice(1) : o);return Object.getOwnPropertySymbols ? a.concat(Object.getOwnPropertySymbols(e)) : a; - }, i.prototype.listeners = function (e) { - const t = n ? n + e : e; const o = this._events[t];if (!o) return [];if (o.fn) return [o.fn];for (var a = 0, s = o.length, r = new Array(s);a < s;a++)r[a] = o[a].fn;return r; - }, i.prototype.listenerCount = function (e) { - const t = n ? n + e : e; const o = this._events[t];return o ? o.fn ? 1 : o.length : 0; - }, i.prototype.emit = function (e, t, o, a, s, r) { - const i = n ? n + e : e;if (!this._events[i]) return !1;let c; let u; const l = this._events[i]; const d = arguments.length;if (l.fn) { - switch (l.once && this.removeListener(e, l.fn, void 0, !0), d) { - case 1:return l.fn.call(l.context), !0;case 2:return l.fn.call(l.context, t), !0;case 3:return l.fn.call(l.context, t, o), !0;case 4:return l.fn.call(l.context, t, o, a), !0;case 5:return l.fn.call(l.context, t, o, a, s), !0;case 6:return l.fn.call(l.context, t, o, a, s, r), !0; - } for (u = 1, c = new Array(d - 1);u < d;u++)c[u - 1] = arguments[u];l.fn.apply(l.context, c); - } else { - let g; const p = l.length;for (u = 0;u < p;u++) switch (l[u].once && this.removeListener(e, l[u].fn, void 0, !0), d) { - case 1:l[u].fn.call(l[u].context);break;case 2:l[u].fn.call(l[u].context, t);break;case 3:l[u].fn.call(l[u].context, t, o);break;case 4:l[u].fn.call(l[u].context, t, o, a);break;default:if (!c) for (g = 1, c = new Array(d - 1);g < d;g++)c[g - 1] = arguments[g];l[u].fn.apply(l[u].context, c); - } - } return !0; - }, i.prototype.on = function (e, t, n) { - return s(this, e, t, n, !1); - }, i.prototype.once = function (e, t, n) { - return s(this, e, t, n, !0); - }, i.prototype.removeListener = function (e, t, o, a) { - const s = n ? n + e : e;if (!this._events[s]) return this;if (!t) return r(this, s), this;const i = this._events[s];if (i.fn)i.fn !== t || a && !i.once || o && i.context !== o || r(this, s);else { - for (var c = 0, u = [], l = i.length;c < l;c++)(i[c].fn !== t || a && !i[c].once || o && i[c].context !== o) && u.push(i[c]);u.length ? this._events[s] = 1 === u.length ? u[0] : u : r(this, s); - } return this; - }, i.prototype.removeAllListeners = function (e) { - let t;return e ? (t = n ? n + e : e, this._events[t] && r(this, t)) : (this._events = new o, this._eventsCount = 0), this; - }, i.prototype.off = i.prototype.removeListener, i.prototype.addListener = i.prototype.on, i.prefixed = n, i.EventEmitter = i, e.exports = i; - })); const li = (function (e) { - i(n, e);const t = f(n);function n(e) { - let a;return o(this, n), (a = t.call(this, e))._className = 'BigDataChannelModule', a.FILETYPE = { SOUND: 2106, FILE: 2107, VIDEO: 2113 }, a._bdh_download_server = 'grouptalk.c2c.qq.com', a._BDHBizID = 10001, a._authKey = '', a._expireTime = 0, a.getInnerEmitterInstance().on(Ir.CONTEXT_A2KEY_AND_TINYID_UPDATED, a._getAuthKey, h(a)), a; - } return s(n, [{ key: '_getAuthKey', value() { - const e = this;this.request({ protocolName: Qt }).then(((t) => { - t.data.authKey && (e._authKey = t.data.authKey, e._expireTime = parseInt(t.data.expireTime)); - })); - } }, { key: '_isFromOlderVersion', value(e) { - return !(!e.content || 2 === e.content.downloadFlag); - } }, { key: 'parseElements', value(e, t) { - if (!Re(e) || !t) return [];for (var n = [], o = null, a = 0;a < e.length;a++)o = e[a], this._needParse(o) ? n.push(this._parseElement(o, t)) : n.push(e[a]);return n; - } }, { key: '_needParse', value(e) { - return !e.cloudCustomData && !(!this._isFromOlderVersion(e) || e.type !== k.MSG_AUDIO && e.type !== k.MSG_FILE && e.type !== k.MSG_VIDEO); - } }, { key: '_parseElement', value(e, t) { - switch (e.type) { - case k.MSG_AUDIO:return this._parseAudioElement(e, t);case k.MSG_FILE:return this._parseFileElement(e, t);case k.MSG_VIDEO:return this._parseVideoElement(e, t); - } - } }, { key: '_parseAudioElement', value(e, t) { - return e.content.url = this._genAudioUrl(e.content.uuid, t), e; - } }, { key: '_parseFileElement', value(e, t) { - return e.content.url = this._genFileUrl(e.content.uuid, t, e.content.fileName), e; - } }, { key: '_parseVideoElement', value(e, t) { - return e.content.url = this._genVideoUrl(e.content.uuid, t), e; - } }, { key: '_genAudioUrl', value(e, t) { - if ('' === this._authKey) return Ee.warn(''.concat(this._className, '._genAudioUrl no authKey!')), '';const n = this.getModule(Gt).getSDKAppID();return 'https://'.concat(this._bdh_download_server, '/asn.com/stddownload_common_file?authkey=').concat(this._authKey, '&bid=') - .concat(this._BDHBizID, '&subbid=') - .concat(n, '&fileid=') - .concat(e, '&filetype=') - .concat(this.FILETYPE.SOUND, '&openid=') - .concat(t, '&ver=0'); - } }, { key: '_genFileUrl', value(e, t, n) { - if ('' === this._authKey) return Ee.warn(''.concat(this._className, '._genFileUrl no authKey!')), '';n || (n = ''.concat(Math.floor(1e5 * Math.random()), '-').concat(Date.now()));const o = this.getModule(Gt).getSDKAppID();return 'https://'.concat(this._bdh_download_server, '/asn.com/stddownload_common_file?authkey=').concat(this._authKey, '&bid=') - .concat(this._BDHBizID, '&subbid=') - .concat(o, '&fileid=') - .concat(e, '&filetype=') - .concat(this.FILETYPE.FILE, '&openid=') - .concat(t, '&ver=0&filename=') - .concat(encodeURIComponent(n)); - } }, { key: '_genVideoUrl', value(e, t) { - if ('' === this._authKey) return Ee.warn(''.concat(this._className, '._genVideoUrl no authKey!')), '';const n = this.getModule(Gt).getSDKAppID();return 'https://'.concat(this._bdh_download_server, '/asn.com/stddownload_common_file?authkey=').concat(this._authKey, '&bid=') - .concat(this._BDHBizID, '&subbid=') - .concat(n, '&fileid=') - .concat(e, '&filetype=') - .concat(this.FILETYPE.VIDEO, '&openid=') - .concat(t, '&ver=0'); - } }, { key: 'reset', value() { - Ee.log(''.concat(this._className, '.reset')), this._authKey = '', this.expireTime = 0; - } }]), n; - }(Yt)); const di = (function (e) { - i(a, e);const n = f(a);function a(e) { - let t;return o(this, a), (t = n.call(this, e))._className = 'UploadModule', t.TIMUploadPlugin = null, t.timUploadPlugin = null, t.COSSDK = null, t._cosUploadMethod = null, t.expiredTimeLimit = 600, t.appid = 0, t.bucketName = '', t.ciUrl = '', t.directory = '', t.downloadUrl = '', t.uploadUrl = '', t.region = 'ap-shanghai', t.cos = null, t.cosOptions = { secretId: '', secretKey: '', sessionToken: '', expiredTime: 0 }, t.uploadFileType = '', t.duration = 900, t.tryCount = 0, t.getInnerEmitterInstance().on(Ir.CONTEXT_A2KEY_AND_TINYID_UPDATED, t._init, h(t)), t; - } return s(a, [{ key: '_init', value() { - const e = ''.concat(this._className, '._init'); const t = this.getModule(qt);if (this.TIMUploadPlugin = t.getPlugin('tim-upload-plugin'), this.TIMUploadPlugin) this._initUploaderMethod();else { - const n = z ? 'cos-wx-sdk' : 'cos-js-sdk';this.COSSDK = t.getPlugin(n), this.COSSDK ? (this._getAuthorizationKey(), Ee.warn(''.concat(e, ' v2.9.2起推荐使用 tim-upload-plugin 代替 ').concat(n, ',上传更快更安全。详细请参考 https://web.sdk.qcloud.com/im/doc/zh-cn/SDK.html#registerPlugin'))) : Ee.warn(''.concat(e, ' 没有检测到上传插件,将无法发送图片、音频、视频、文件等类型的消息。详细请参考 https://web.sdk.qcloud.com/im/doc/zh-cn/SDK.html#registerPlugin')); - } - } }, { key: '_getAuthorizationKey', value() { - const e = this; const t = new Da(Ga); const n = Math.ceil(Date.now() / 1e3);this.request({ protocolName: xn, requestData: { duration: this.expiredTimeLimit } }).then(((o) => { - const a = o.data;Ee.log(''.concat(e._className, '._getAuthorizationKey ok. data:'), a);const s = a.expiredTime - n;t.setMessage('requestId:'.concat(a.requestId, ' requestTime:').concat(n, ' expiredTime:') - .concat(a.expiredTime, ' diff:') - .concat(s, 's')).setNetworkType(e.getNetworkType()) - .end(), !z && a.region && (e.region = a.region), e.appid = a.appid, e.bucketName = a.bucketName, e.ciUrl = a.ciUrl, e.directory = a.directory, e.downloadUrl = a.downloadUrl, e.uploadUrl = a.uploadUrl, e.cosOptions = { secretId: a.secretId, secretKey: a.secretKey, sessionToken: a.sessionToken, expiredTime: a.expiredTime }, Ee.log(''.concat(e._className, '._getAuthorizationKey ok. region:').concat(e.region, ' bucketName:') - .concat(e.bucketName)), e._initUploaderMethod(); - })) - .catch(((n) => { - e.probeNetwork().then(((e) => { - const o = m(e, 2); const a = o[0]; const s = o[1];t.setError(n, a, s).end(); - })), Ee.warn(''.concat(e._className, '._getAuthorizationKey failed. error:'), n); - })); - } }, { key: '_getCosPreSigUrl', value(e) { - const t = this; const n = ''.concat(this._className, '._getCosPreSigUrl'); const o = Math.ceil(Date.now() / 1e3); const a = new Da(wa);return this.request({ protocolName: Bn, requestData: { fileType: e.fileType, fileName: e.fileName, uploadMethod: e.uploadMethod, duration: e.duration } }).then(((e) => { - t.tryCount = 0;const s = e.data || {}; const r = s.expiredTime - o;return Ee.log(''.concat(n, ' ok. data:'), s), a.setMessage('requestId:'.concat(s.requestId, ' expiredTime:').concat(s.expiredTime, ' diff:') - .concat(r, 's')).setNetworkType(t.getNetworkType()) - .end(), s; - })) - .catch((o => (-1 === o.code && (o.code = Zn.COS_GET_SIG_FAIL), t.probeNetwork().then(((e) => { - const t = m(e, 2); const n = t[0]; const s = t[1];a.setError(o, n, s).end(); - })), Ee.warn(''.concat(n, ' failed. error:'), o), t.tryCount < 1 ? (t.tryCount++, t._getCosPreSigUrl(e)) : (t.tryCount = 0, Mr({ code: Zn.COS_GET_SIG_FAIL, message: io }))))); - } }, { key: '_initUploaderMethod', value() { - const e = this;if (this.TIMUploadPlugin) return this.timUploadPlugin = new this.TIMUploadPlugin, void (this._cosUploadMethod = function (t, n) { - e.timUploadPlugin.uploadFile(t, n); - });this.appid && (this.cos = z ? new this.COSSDK({ ForcePathStyle: !0, getAuthorization: this._getAuthorization.bind(this) }) : new this.COSSDK({ getAuthorization: this._getAuthorization.bind(this) }), this._cosUploadMethod = z ? function (t, n) { - e.cos.postObject(t, n); - } : function (t, n) { - e.cos.uploadFiles(t, n); - }); - } }, { key: 'onCheckTimer', value(e) { - this.COSSDK && (this.TIMUploadPlugin || this.isLoggedIn() && e % 60 == 0 && Math.ceil(Date.now() / 1e3) >= this.cosOptions.expiredTime - 120 && this._getAuthorizationKey()); - } }, { key: '_getAuthorization', value(e, t) { - t({ TmpSecretId: this.cosOptions.secretId, TmpSecretKey: this.cosOptions.secretKey, XCosSecurityToken: this.cosOptions.sessionToken, ExpiredTime: this.cosOptions.expiredTime }); - } }, { key: 'upload', value(e) { - if (!0 === e.getRelayFlag()) return Promise.resolve();const t = this.getModule($t);switch (e.type) { - case k.MSG_IMAGE:return t.addTotalCount(_a), this._uploadImage(e);case k.MSG_FILE:return t.addTotalCount(_a), this._uploadFile(e);case k.MSG_AUDIO:return t.addTotalCount(_a), this._uploadAudio(e);case k.MSG_VIDEO:return t.addTotalCount(_a), this._uploadVideo(e);default:return Promise.resolve(); - } - } }, { key: '_uploadImage', value(e) { - const n = this.getModule(kt); const o = e.getElements()[0]; const a = n.getMessageOptionByID(e.ID);return this.doUploadImage({ file: a.payload.file, to: a.to, onProgress(e) { - if (o.updatePercent(e), Pe(a.onProgress)) try { - a.onProgress(e); - } catch (t) { - return Mr({ code: Zn.MESSAGE_ONPROGRESS_FUNCTION_ERROR, message: po }); - } - } }).then(((n) => { - const a = n.location; const s = n.fileType; const r = n.fileSize; const i = n.width; const c = n.height; const u = Je(a);o.updateImageFormat(s);const l = rt({ originUrl: u, originWidth: i, originHeight: c, min: 198 }); const d = rt({ originUrl: u, originWidth: i, originHeight: c, min: 720 });return o.updateImageInfoArray([{ size: r, url: u, width: i, height: c }, t({}, d), t({}, l)]), e; - })); - } }, { key: '_uploadFile', value(e) { - const t = this.getModule(kt); const n = e.getElements()[0]; const o = t.getMessageOptionByID(e.ID);return this.doUploadFile({ file: o.payload.file, to: o.to, onProgress(e) { - if (n.updatePercent(e), Pe(o.onProgress)) try { - o.onProgress(e); - } catch (t) { - return Mr({ code: Zn.MESSAGE_ONPROGRESS_FUNCTION_ERROR, message: po }); - } - } }).then(((t) => { - const o = t.location; const a = Je(o);return n.updateFileUrl(a), e; - })); - } }, { key: '_uploadAudio', value(e) { - const t = this.getModule(kt); const n = e.getElements()[0]; const o = t.getMessageOptionByID(e.ID);return this.doUploadAudio({ file: o.payload.file, to: o.to, onProgress(e) { - if (n.updatePercent(e), Pe(o.onProgress)) try { - o.onProgress(e); - } catch (t) { - return Mr({ code: Zn.MESSAGE_ONPROGRESS_FUNCTION_ERROR, message: po }); - } - } }).then(((t) => { - const o = t.location; const a = Je(o);return n.updateAudioUrl(a), e; - })); - } }, { key: '_uploadVideo', value(e) { - const t = this.getModule(kt); const n = e.getElements()[0]; const o = t.getMessageOptionByID(e.ID);return this.doUploadVideo({ file: o.payload.file, to: o.to, onProgress(e) { - if (n.updatePercent(e), Pe(o.onProgress)) try { - o.onProgress(e); - } catch (t) { - return Mr({ code: Zn.MESSAGE_ONPROGRESS_FUNCTION_ERROR, message: po }); - } - } }).then(((t) => { - const o = Je(t.location);return n.updateVideoUrl(o), e; - })); - } }, { key: 'doUploadImage', value(e) { - if (!e.file) return Mr({ code: Zn.MESSAGE_IMAGE_SELECT_FILE_FIRST, message: fo });const t = this._checkImageType(e.file);if (!0 !== t) return t;const n = this._checkImageSize(e.file);if (!0 !== n) return n;let o = null;return this._setUploadFileType(Er), this.uploadByCOS(e).then(((e) => { - return o = e, t = 'https://'.concat(e.location), z ? new Promise(((e, n) => { - J.getImageInfo({ src: t, success(t) { - e({ width: t.width, height: t.height }); - }, fail() { - e({ width: 0, height: 0 }); - } }); - })) : ce && 9 === ue ? Promise.resolve({ width: 0, height: 0 }) : new Promise(((e, n) => { - let o = new Image;o.onload = function () { - e({ width: this.width, height: this.height }), o = null; - }, o.onerror = function () { - e({ width: 0, height: 0 }), o = null; - }, o.src = t; - }));let t; - })) - .then((e => (o.width = e.width, o.height = e.height, Promise.resolve(o)))); - } }, { key: '_checkImageType', value(e) { - let t = '';return t = z ? e.url.slice(e.url.lastIndexOf('.') + 1) : e.files[0].name.slice(e.files[0].name.lastIndexOf('.') + 1), Tr.indexOf(t.toLowerCase()) >= 0 || Mr({ code: Zn.MESSAGE_IMAGE_TYPES_LIMIT, message: mo }); - } }, { key: '_checkImageSize', value(e) { - let t = 0;return 0 === (t = z ? e.size : e.files[0].size) ? Mr({ code: Zn.MESSAGE_FILE_IS_EMPTY, message: ''.concat(go) }) : t < 20971520 || Mr({ code: Zn.MESSAGE_IMAGE_SIZE_LIMIT, message: ''.concat(Mo) }); - } }, { key: 'doUploadFile', value(e) { - let t = null;return e.file ? e.file.files[0].size > 104857600 ? Mr(t = { code: Zn.MESSAGE_FILE_SIZE_LIMIT, message: ko }) : 0 === e.file.files[0].size ? (t = { code: Zn.MESSAGE_FILE_IS_EMPTY, message: ''.concat(go) }, Mr(t)) : (this._setUploadFileType(Nr), this.uploadByCOS(e)) : Mr(t = { code: Zn.MESSAGE_FILE_SELECT_FILE_FIRST, message: Eo }); - } }, { key: 'doUploadVideo', value(e) { - return e.file.videoFile.size > 104857600 ? Mr({ code: Zn.MESSAGE_VIDEO_SIZE_LIMIT, message: ''.concat(Do) }) : 0 === e.file.videoFile.size ? Mr({ code: Zn.MESSAGE_FILE_IS_EMPTY, message: ''.concat(go) }) : -1 === Sr.indexOf(e.file.videoFile.type) ? Mr({ code: Zn.MESSAGE_VIDEO_TYPES_LIMIT, message: ''.concat(To) }) : (this._setUploadFileType(kr), z ? this.handleVideoUpload({ file: e.file.videoFile, onProgress: e.onProgress }) : W ? this.handleVideoUpload(e) : void 0); - } }, { key: 'handleVideoUpload', value(e) { - const t = this;return new Promise(((n, o) => { - t.uploadByCOS(e).then(((e) => { - n(e); - })) - .catch((() => { - t.uploadByCOS(e).then(((e) => { - n(e); - })) - .catch((() => { - o(new hr({ code: Zn.MESSAGE_VIDEO_UPLOAD_FAIL, message: Io })); - })); - })); - })); - } }, { key: 'doUploadAudio', value(e) { - return e.file ? e.file.size > 20971520 ? Mr(new hr({ code: Zn.MESSAGE_AUDIO_SIZE_LIMIT, message: ''.concat(yo) })) : 0 === e.file.size ? Mr(new hr({ code: Zn.MESSAGE_FILE_IS_EMPTY, message: ''.concat(go) })) : (this._setUploadFileType(Cr), this.uploadByCOS(e)) : Mr(new hr({ code: Zn.MESSAGE_AUDIO_UPLOAD_FAIL, message: vo })); - } }, { key: 'uploadByCOS', value(e) { - const t = this; const n = ''.concat(this._className, '.uploadByCOS');if (!Pe(this._cosUploadMethod)) return Ee.warn(''.concat(n, ' 没有检测到上传插件,将无法发送图片、音频、视频、文件等类型的消息。详细请参考 https://web.sdk.qcloud.com/im/doc/zh-cn/SDK.html#registerPlugin')), Mr({ code: Zn.COS_UNDETECTED, message: ro });if (this.timUploadPlugin) return this._uploadWithPreSigUrl(e);const o = new Da(Pa); const a = Date.now(); const s = z ? e.file : e.file.files[0];return new Promise(((r, i) => { - const c = z ? t._createCosOptionsWXMiniApp(e) : t._createCosOptionsWeb(e); const u = t;t._cosUploadMethod(c, ((e, c) => { - const l = Object.create(null);if (c) { - if (e || Re(c.files) && c.files[0].error) { - const d = new hr({ code: Zn.MESSAGE_FILE_UPLOAD_FAIL, message: So });return o.setError(d, !0, t.getNetworkType()).end(), Ee.log(''.concat(n, ' failed. error:'), c.files[0].error), 403 === c.files[0].error.statusCode && (Ee.warn(''.concat(n, ' failed. cos AccessKeyId was invalid, regain auth key!')), t._getAuthorizationKey()), void i(d); - }l.fileName = s.name, l.fileSize = s.size, l.fileType = s.type.slice(s.type.indexOf('/') + 1).toLowerCase(), l.location = z ? c.Location : c.files[0].data.Location;const g = Date.now() - a; const p = u._formatFileSize(s.size); const h = u._formatSpeed(1e3 * s.size / g); const _ = 'size:'.concat(p, ' time:').concat(g, 'ms speed:') - .concat(h);Ee.log(''.concat(n, ' success. name:').concat(s.name, ' ') - .concat(_)), r(l);const f = t.getModule($t);return f.addCost(_a, g), f.addFileSize(_a, s.size), void o.setNetworkType(t.getNetworkType()).setMessage(_) - .end(); - } const m = new hr({ code: Zn.MESSAGE_FILE_UPLOAD_FAIL, message: So });o.setError(m, !0, u.getNetworkType()).end(), Ee.warn(''.concat(n, ' failed. error:'), e), 403 === e.statusCode && (Ee.warn(''.concat(n, ' failed. cos AccessKeyId was invalid, regain auth key!')), t._getAuthorizationKey()), i(m); - })); - })); - } }, { key: '_uploadWithPreSigUrl', value(e) { - const t = this; const n = ''.concat(this._className, '._uploadWithPreSigUrl'); const o = z ? e.file : e.file.files[0];return this._createCosOptionsPreSigUrl(e).then((e => new Promise(((a, s) => { - const r = new Da(Pa);Ee.time(ca), t._cosUploadMethod(e, ((e, i) => { - const c = Object.create(null);if (e || 403 === i.statusCode) { - const u = new hr({ code: Zn.MESSAGE_FILE_UPLOAD_FAIL, message: So });return r.setError(u, !0, t.getNetworkType()).end(), Ee.log(''.concat(n, ' failed, error:'), e), void s(u); - } let l = i.data.location || '';0 !== l.indexOf('https://') && 0 !== l.indexOf('http://') || (l = l.split('//')[1]), c.fileName = o.name, c.fileSize = o.size, c.fileType = o.type.slice(o.type.indexOf('/') + 1).toLowerCase(), c.location = l;const d = Ee.timeEnd(ca); const g = t._formatFileSize(o.size); const p = t._formatSpeed(1e3 * o.size / d); const h = 'size:'.concat(g, ',time:').concat(d, 'ms,speed:') - .concat(p);Ee.log(''.concat(n, ' success name:').concat(o.name, ',') - .concat(h)), r.setNetworkType(t.getNetworkType()).setMessage(h) - .end();const _ = t.getModule($t);_.addCost(_a, d), _.addFileSize(_a, o.size), a(c); - })); - })))); - } }, { key: '_formatFileSize', value(e) { - return e < 1024 ? `${e}B` : e < 1048576 ? `${Math.floor(e / 1024)}KB` : `${Math.floor(e / 1048576)}MB`; - } }, { key: '_formatSpeed', value(e) { - return e <= 1048576 ? `${ut(e / 1024, 1)}KB/s` : `${ut(e / 1048576, 1)}MB/s`; - } }, { key: '_createCosOptionsWeb', value(e) { - const t = this.getMyUserID(); const n = this._genFileName(t, e.to, e.file.files[0].name);return { files: [{ Bucket: ''.concat(this.bucketName, '-').concat(this.appid), Region: this.region, Key: ''.concat(this.directory, '/').concat(n), Body: e.file.files[0] }], SliceSize: 1048576, onProgress(t) { - if ('function' === typeof e.onProgress) try { - e.onProgress(t.percent); - } catch (n) { - Ee.warn('onProgress callback error:', n); - } - }, onFileFinish(e, t, n) {} }; - } }, { key: '_createCosOptionsWXMiniApp', value(e) { - const t = this.getMyUserID(); const n = this._genFileName(t, e.to, e.file.name); const o = e.file.url;return { Bucket: ''.concat(this.bucketName, '-').concat(this.appid), Region: this.region, Key: ''.concat(this.directory, '/').concat(n), FilePath: o, onProgress(t) { - if (Ee.log(JSON.stringify(t)), 'function' === typeof e.onProgress) try { - e.onProgress(t.percent); - } catch (n) { - Ee.warn('onProgress callback error:', n); - } - } }; - } }, { key: '_createCosOptionsPreSigUrl', value(e) { - const t = this; let n = ''; let o = ''; let a = 0;return z ? (n = this._genFileName(e.file.name), o = e.file.url, a = 1) : (n = this._genFileName(''.concat(He(999999))), o = e.file.files[0], a = 0), this._getCosPreSigUrl({ fileType: this.uploadFileType, fileName: n, uploadMethod: a, duration: this.duration }).then(((a) => { - const s = a.uploadUrl; const r = a.downloadUrl;return { url: s, fileType: t.uploadFileType, fileName: n, resources: o, downloadUrl: r, onProgress(t) { - if ('function' === typeof e.onProgress) try { - e.onProgress(t.percent); - } catch (n) { - Ee.warn('onProgress callback error:', n), Ee.error(n); - } - } }; - })); - } }, { key: '_genFileName', value(e) { - return ''.concat(at(), '-').concat(e); - } }, { key: '_setUploadFileType', value(e) { - this.uploadFileType = e; - } }, { key: 'reset', value() { - Ee.log(''.concat(this._className, '.reset')); - } }]), a; - }(Yt)); const gi = ['downloadKey', 'pbDownloadKey', 'messageList']; const pi = (function () { - function e(t) { - o(this, e), this._className = 'MergerMessageHandler', this._messageModule = t; - } return s(e, [{ key: 'uploadMergerMessage', value(e, t) { - const n = this;Ee.debug(''.concat(this._className, '.uploadMergerMessage message:'), e, 'messageBytes:'.concat(t));const o = e.payload.messageList; const a = o.length; const s = new Da(ja);return this._messageModule.request({ protocolName: Wn, requestData: { messageList: o } }).then(((e) => { - Ee.debug(''.concat(n._className, '.uploadMergerMessage ok. response:'), e.data);const o = e.data; const r = o.pbDownloadKey; const i = o.downloadKey; const c = { pbDownloadKey: r, downloadKey: i, messageNumber: a };return s.setNetworkType(n._messageModule.getNetworkType()).setMessage(''.concat(a, '-').concat(t, '-') - .concat(i)) - .end(), c; - })) - .catch(((e) => { - throw Ee.warn(''.concat(n._className, '.uploadMergerMessage failed. error:'), e), n._messageModule.probeNetwork().then(((t) => { - const n = m(t, 2); const o = n[0]; const a = n[1];s.setError(e, o, a).end(); - })), e; - })); - } }, { key: 'downloadMergerMessage', value(e) { - const n = this;Ee.debug(''.concat(this._className, '.downloadMergerMessage message:'), e);const o = e.payload.downloadKey; const a = new Da($a);return a.setMessage('downloadKey:'.concat(o)), this._messageModule.request({ protocolName: Jn, requestData: { downloadKey: o } }).then(((o) => { - if (Ee.debug(''.concat(n._className, '.downloadMergerMessage ok. response:'), o.data), Pe(e.clearElement)) { - const s = e.payload; const r = (s.downloadKey, s.pbDownloadKey, s.messageList, p(s, gi));e.clearElement(), e.setElement({ type: e.type, content: t({ messageList: o.data.messageList }, r) }); - } else { - const i = [];o.data.messageList.forEach(((e) => { - if (!dt(e)) { - const t = new ar(e);i.push(t); - } - })), e.payload.messageList = i, e.payload.downloadKey = '', e.payload.pbDownloadKey = ''; - } return a.setNetworkType(n._messageModule.getNetworkType()).end(), e; - })) - .catch(((e) => { - throw Ee.warn(''.concat(n._className, '.downloadMergerMessage failed. key:').concat(o, ' error:'), e), n._messageModule.probeNetwork().then(((t) => { - const n = m(t, 2); const o = n[0]; const s = n[1];a.setError(e, o, s).end(); - })), e; - })); - } }, { key: 'createMergerMessagePack', value(e, t, n) { - return e.conversationType === k.CONV_C2C ? this._createC2CMergerMessagePack(e, t, n) : this._createGroupMergerMessagePack(e, t, n); - } }, { key: '_createC2CMergerMessagePack', value(e, t, n) { - let o = null;t && (t.offlinePushInfo && (o = t.offlinePushInfo), !0 === t.onlineUserOnly && (o ? o.disablePush = !0 : o = { disablePush: !0 }));let a = '';Ae(e.cloudCustomData) && e.cloudCustomData.length > 0 && (a = e.cloudCustomData);const s = n.pbDownloadKey; const r = n.downloadKey; const i = n.messageNumber; const c = e.payload; const u = c.title; const l = c.abstractList; const d = c.compatibleText; const g = this._messageModule.getModule(Nt);return { protocolName: Zt, tjgID: this._messageModule.generateTjgID(e), requestData: { fromAccount: this._messageModule.getMyUserID(), toAccount: e.to, msgBody: [{ msgType: e.type, msgContent: { pbDownloadKey: s, downloadKey: r, title: u, abstractList: l, compatibleText: d, messageNumber: i } }], cloudCustomData: a, msgSeq: e.sequence, msgRandom: e.random, msgLifeTime: g && g.isOnlineMessage(e, t) ? 0 : void 0, offlinePushInfo: o ? { pushFlag: !0 === o.disablePush ? 1 : 0, title: o.title || '', desc: o.description || '', ext: o.extension || '', apnsInfo: { badgeMode: !0 === o.ignoreIOSBadge ? 1 : 0 }, androidInfo: { OPPOChannelID: o.androidOPPOChannelID || '' } } : void 0 } }; - } }, { key: '_createGroupMergerMessagePack', value(e, t, n) { - let o = null;t && t.offlinePushInfo && (o = t.offlinePushInfo);let a = '';Ae(e.cloudCustomData) && e.cloudCustomData.length > 0 && (a = e.cloudCustomData);const s = n.pbDownloadKey; const r = n.downloadKey; const i = n.messageNumber; const c = e.payload; const u = c.title; const l = c.abstractList; const d = c.compatibleText; const g = this._messageModule.getModule(At);return { protocolName: en, tjgID: this._messageModule.generateTjgID(e), requestData: { fromAccount: this._messageModule.getMyUserID(), groupID: e.to, msgBody: [{ msgType: e.type, msgContent: { pbDownloadKey: s, downloadKey: r, title: u, abstractList: l, compatibleText: d, messageNumber: i } }], random: e.random, priority: e.priority, clientSequence: e.clientSequence, groupAtInfo: void 0, cloudCustomData: a, onlineOnlyFlag: g && g.isOnlineMessage(e, t) ? 1 : 0, offlinePushInfo: o ? { pushFlag: !0 === o.disablePush ? 1 : 0, title: o.title || '', desc: o.description || '', ext: o.extension || '', apnsInfo: { badgeMode: !0 === o.ignoreIOSBadge ? 1 : 0 }, androidInfo: { OPPOChannelID: o.androidOPPOChannelID || '' } } : void 0 } }; - } }]), e; - }()); const hi = { ERR_SVR_COMM_SENSITIVE_TEXT: 80001, ERR_SVR_COMM_BODY_SIZE_LIMIT: 80002, ERR_SVR_MSG_PKG_PARSE_FAILED: 20001, ERR_SVR_MSG_INTERNAL_AUTH_FAILED: 20002, ERR_SVR_MSG_INVALID_ID: 20003, ERR_SVR_MSG_PUSH_DENY: 20006, ERR_SVR_MSG_IN_PEER_BLACKLIST: 20007, ERR_SVR_MSG_BOTH_NOT_FRIEND: 20009, ERR_SVR_MSG_NOT_PEER_FRIEND: 20010, ERR_SVR_MSG_NOT_SELF_FRIEND: 20011, ERR_SVR_MSG_SHUTUP_DENY: 20012, ERR_SVR_GROUP_INVALID_PARAMETERS: 10004, ERR_SVR_GROUP_PERMISSION_DENY: 10007, ERR_SVR_GROUP_NOT_FOUND: 10010, ERR_SVR_GROUP_INVALID_GROUPID: 10015, ERR_SVR_GROUP_REJECT_FROM_THIRDPARTY: 10016, ERR_SVR_GROUP_SHUTUP_DENY: 10017, MESSAGE_SEND_FAIL: 2100 }; const _i = [Zn.MESSAGE_ONPROGRESS_FUNCTION_ERROR, Zn.MESSAGE_IMAGE_SELECT_FILE_FIRST, Zn.MESSAGE_IMAGE_TYPES_LIMIT, Zn.MESSAGE_FILE_IS_EMPTY, Zn.MESSAGE_IMAGE_SIZE_LIMIT, Zn.MESSAGE_FILE_SELECT_FILE_FIRST, Zn.MESSAGE_FILE_SIZE_LIMIT, Zn.MESSAGE_VIDEO_SIZE_LIMIT, Zn.MESSAGE_VIDEO_TYPES_LIMIT, Zn.MESSAGE_AUDIO_UPLOAD_FAIL, Zn.MESSAGE_AUDIO_SIZE_LIMIT, Zn.COS_UNDETECTED];const fi = (function (e) { - i(n, e);const t = f(n);function n(e) { - let a;return o(this, n), (a = t.call(this, e))._className = 'MessageModule', a._messageOptionsMap = new Map, a._mergerMessageHandler = new pi(h(a)), a; - } return s(n, [{ key: 'createTextMessage', value(e) { - const t = this.getMyUserID();e.currentUser = t;const n = new ir(e); const o = 'string' === typeof e.payload ? e.payload : e.payload.text; const a = new qs({ text: o }); const s = this._getNickAndAvatarByUserID(t);return n.setElement(a), n.setNickAndAvatar(s), n; - } }, { key: 'createImageMessage', value(e) { - const t = this.getMyUserID();e.currentUser = t;const n = new ir(e);if (z) { - const o = e.payload.file;if (Ce(o)) return void Ee.warn('小程序环境下调用 createImageMessage 接口时,payload.file 不支持传入 File 对象');const a = o.tempFilePaths[0]; const s = { url: a, name: a.slice(a.lastIndexOf('/') + 1), size: o.tempFiles && o.tempFiles[0].size || 1, type: a.slice(a.lastIndexOf('.') + 1).toLowerCase() };e.payload.file = s; - } else if (W) if (Ce(e.payload.file)) { - const r = e.payload.file;e.payload.file = { files: [r] }; - } else if (Le(e.payload.file) && 'undefined' !== typeof uni) { - const i = e.payload.file.tempFiles[0];e.payload.file = { files: [i] }; - } const c = new Ys({ imageFormat: Vs.IMAGE_FORMAT.UNKNOWN, uuid: this._generateUUID(), file: e.payload.file }); const u = this._getNickAndAvatarByUserID(t);return n.setElement(c), n.setNickAndAvatar(u), this._messageOptionsMap.set(n.ID, e), n; - } }, { key: 'createAudioMessage', value(e) { - if (z) { - const t = e.payload.file;if (z) { - const n = { url: t.tempFilePath, name: t.tempFilePath.slice(t.tempFilePath.lastIndexOf('/') + 1), size: t.fileSize, second: parseInt(t.duration) / 1e3, type: t.tempFilePath.slice(t.tempFilePath.lastIndexOf('.') + 1).toLowerCase() };e.payload.file = n; - } const o = this.getMyUserID();e.currentUser = o;const a = new ir(e); const s = new Ws({ second: Math.floor(t.duration / 1e3), size: t.fileSize, url: t.tempFilePath, uuid: this._generateUUID() }); const r = this._getNickAndAvatarByUserID(o);return a.setElement(s), a.setNickAndAvatar(r), this._messageOptionsMap.set(a.ID, e), a; - }Ee.warn('createAudioMessage 目前只支持小程序环境下发语音消息'); - } }, { key: 'createVideoMessage', value(e) { - const t = this.getMyUserID();e.currentUser = t, e.payload.file.thumbUrl = 'https://web.sdk.qcloud.com/im/assets/images/transparent.png', e.payload.file.thumbSize = 1668;const n = {};if (z) { - if ($) return void Ee.warn('createVideoMessage 不支持在支付宝小程序环境下使用');if (Ce(e.payload.file)) return void Ee.warn('小程序环境下调用 createVideoMessage 接口时,payload.file 不支持传入 File 对象');const o = e.payload.file;n.url = o.tempFilePath, n.name = o.tempFilePath.slice(o.tempFilePath.lastIndexOf('/') + 1), n.size = o.size, n.second = o.duration, n.type = o.tempFilePath.slice(o.tempFilePath.lastIndexOf('.') + 1).toLowerCase(); - } else if (W) { - if (Ce(e.payload.file)) { - const a = e.payload.file;e.payload.file.files = [a]; - } else if (Le(e.payload.file) && 'undefined' !== typeof uni) { - const s = e.payload.file.tempFile;e.payload.file.files = [s]; - } const r = e.payload.file;n.url = window.URL.createObjectURL(r.files[0]), n.name = r.files[0].name, n.size = r.files[0].size, n.second = r.files[0].duration || 0, n.type = r.files[0].type.split('/')[1]; - }e.payload.file.videoFile = n;const i = new ir(e); const c = new nr({ videoFormat: n.type, videoSecond: ut(n.second, 0), videoSize: n.size, remoteVideoUrl: '', videoUrl: n.url, videoUUID: this._generateUUID(), thumbUUID: this._generateUUID(), thumbWidth: e.payload.file.width || 200, thumbHeight: e.payload.file.height || 200, thumbUrl: e.payload.file.thumbUrl, thumbSize: e.payload.file.thumbSize, thumbFormat: e.payload.file.thumbUrl.slice(e.payload.file.thumbUrl.lastIndexOf('.') + 1).toLowerCase() }); const u = this._getNickAndAvatarByUserID(t);return i.setElement(c), i.setNickAndAvatar(u), this._messageOptionsMap.set(i.ID, e), i; - } }, { key: 'createCustomMessage', value(e) { - const t = this.getMyUserID();e.currentUser = t;const n = new ir(e); const o = new tr({ data: e.payload.data, description: e.payload.description, extension: e.payload.extension }); const a = this._getNickAndAvatarByUserID(t);return n.setElement(o), n.setNickAndAvatar(a), n; - } }, { key: 'createFaceMessage', value(e) { - const t = this.getMyUserID();e.currentUser = t;const n = new ir(e); const o = new zs(e.payload); const a = this._getNickAndAvatarByUserID(t);return n.setElement(o), n.setNickAndAvatar(a), n; - } }, { key: 'createMergerMessage', value(e) { - const t = this.getMyUserID();e.currentUser = t;const n = this._getNickAndAvatarByUserID(t); const o = new ir(e); const a = new sr(e.payload);return o.setElement(a), o.setNickAndAvatar(n), o.setRelayFlag(!0), o; - } }, { key: 'createForwardMessage', value(e) { - const t = e.to; const n = e.conversationType; const o = e.priority; const a = e.payload; const s = this.getMyUserID(); const r = this._getNickAndAvatarByUserID(s);if (a.type === k.MSG_GRP_TIP) return Mr(new hr({ code: Zn.MESSAGE_FORWARD_TYPE_INVALID, message: Lo }));const i = { to: t, conversationType: n, conversationID: ''.concat(n).concat(t), priority: o, isPlaceMessage: 0, status: _t.UNSEND, currentUser: s, cloudCustomData: e.cloudCustomData || a.cloudCustomData || '' }; const c = new ir(i);return c.setElement(a.getElements()[0]), c.setNickAndAvatar(r), c.setRelayFlag(!0), c; - } }, { key: 'downloadMergerMessage', value(e) { - return this._mergerMessageHandler.downloadMergerMessage(e); - } }, { key: 'createFileMessage', value(e) { - if (!z) { - if (W) if (Ce(e.payload.file)) { - const t = e.payload.file;e.payload.file = { files: [t] }; - } else if (Le(e.payload.file) && 'undefined' !== typeof uni) { - const n = e.payload.file.tempFiles[0];e.payload.file = { files: [n] }; - } const o = this.getMyUserID();e.currentUser = o;const a = new ir(e); const s = new er({ uuid: this._generateUUID(), file: e.payload.file }); const r = this._getNickAndAvatarByUserID(o);return a.setElement(s), a.setNickAndAvatar(r), this._messageOptionsMap.set(a.ID, e), a; - }Ee.warn('小程序目前不支持选择文件, createFileMessage 接口不可用!'); - } }, { key: '_onCannotFindModule', value() { - return Mr({ code: Zn.CANNOT_FIND_MODULE, message: ra }); - } }, { key: 'sendMessageInstance', value(e, t) { - let n; const o = this; let a = null;switch (e.conversationType) { - case k.CONV_C2C:if (!(a = this.getModule(Nt))) return this._onCannotFindModule();break;case k.CONV_GROUP:if (!(a = this.getModule(At))) return this._onCannotFindModule();break;default:return Mr({ code: Zn.MESSAGE_SEND_INVALID_CONVERSATION_TYPE, message: lo }); - } const s = this.getModule(Ft); const r = this.getModule(At);return s.upload(e).then((() => { - o._getSendMessageSpecifiedKey(e) === ha && o.getModule($t).addSuccessCount(_a);return r.guardForAVChatRoom(e).then((() => { - if (!e.isSendable()) return Mr({ code: Zn.MESSAGE_FILE_URL_IS_EMPTY, message: Co });o._addSendMessageTotalCount(e), n = Date.now();const s = (function (e) { - let t = 'utf-8';W && document && (t = document.charset.toLowerCase());let n; let o; let a = 0;if (o = e.length, 'utf-8' === t || 'utf8' === t) for (let s = 0;s < o;s++)(n = e.codePointAt(s)) <= 127 ? a += 1 : n <= 2047 ? a += 2 : n <= 65535 ? a += 3 : (a += 4, s++);else if ('utf-16' === t || 'utf16' === t) for (let r = 0;r < o;r++)(n = e.codePointAt(r)) <= 65535 ? a += 2 : (a += 4, r++);else a = e.replace(/[^\x00-\xff]/g, 'aa').length;return a; - }(JSON.stringify(e)));return e.type === k.MSG_MERGER && s > 7e3 ? o._mergerMessageHandler.uploadMergerMessage(e, s).then(((n) => { - const a = o._mergerMessageHandler.createMergerMessagePack(e, t, n);return o.request(a); - })) : (o.getModule(Rt).setMessageRandom(e), e.conversationType === k.CONV_C2C || e.conversationType === k.CONV_GROUP ? a.sendMessage(e, t) : void 0); - })) - .then(((s) => { - const r = s.data; const i = r.time; const c = r.sequence;o._addSendMessageSuccessCount(e, n), o._messageOptionsMap.delete(e.ID);const u = o.getModule(Rt);e.status = _t.SUCCESS, e.time = i;let l = !1;if (e.conversationType === k.CONV_GROUP)e.sequence = c, e.generateMessageID(o.getMyUserID());else if (e.conversationType === k.CONV_C2C) { - const d = u.getLatestMessageSentByMe(e.conversationID);if (d) { - const g = d.nick; const p = d.avatar;g === e.nick && p === e.avatar || (l = !0); - } - } return u.appendToMessageList(e), l && u.modifyMessageSentByMe({ conversationID: e.conversationID, latestNick: e.nick, latestAvatar: e.avatar }), a.isOnlineMessage(e, t) ? e.setOnlineOnlyFlag(!0) : u.onMessageSent({ conversationOptionsList: [{ conversationID: e.conversationID, unreadCount: 0, type: e.conversationType, subType: e.conversationSubType, lastMessage: e }] }), e.getRelayFlag() || 'TIMImageElem' !== e.type || it(e.payload.imageInfoArray), cr({ message: e }); - })); - })) - .catch((t => o._onSendMessageFailed(e, t))); - } }, { key: '_onSendMessageFailed', value(e, t) { - e.status = _t.FAIL, this.getModule(Rt).deleteMessageRandom(e), this._addSendMessageFailCountOnUser(e, t);const n = new Da(ba);return n.setMessage('tjg_id:'.concat(this.generateTjgID(e), ' type:').concat(e.type, ' from:') - .concat(e.from, ' to:') - .concat(e.to)), this.probeNetwork().then(((e) => { - const o = m(e, 2); const a = o[0]; const s = o[1];n.setError(t, a, s).end(); - })), Ee.error(''.concat(this._className, '._onSendMessageFailed error:'), t), Mr(new hr({ code: t && t.code ? t.code : Zn.MESSAGE_SEND_FAIL, message: t && t.message ? t.message : co, data: { message: e } })); - } }, { key: '_getSendMessageSpecifiedKey', value(e) { - if ([k.MSG_IMAGE, k.MSG_AUDIO, k.MSG_VIDEO, k.MSG_FILE].includes(e.type)) return ha;if (e.conversationType === k.CONV_C2C) return da;if (e.conversationType === k.CONV_GROUP) { - const t = this.getModule(At).getLocalGroupProfile(e.to);if (!t) return;const n = t.type;return et(n) ? pa : ga; - } - } }, { key: '_addSendMessageTotalCount', value(e) { - const t = this._getSendMessageSpecifiedKey(e);t && this.getModule($t).addTotalCount(t); - } }, { key: '_addSendMessageSuccessCount', value(e, t) { - const n = Math.abs(Date.now() - t); const o = this._getSendMessageSpecifiedKey(e);if (o) { - const a = this.getModule($t);a.addSuccessCount(o), a.addCost(o, n); - } - } }, { key: '_addSendMessageFailCountOnUser', value(e, t) { - let n; let o; const a = t.code; const s = void 0 === a ? -1 : a; const r = this.getModule($t); const i = this._getSendMessageSpecifiedKey(e);i === ha && (n = s, o = !1, _i.includes(n) && (o = !0), o) ? r.addFailedCountOfUserSide(_a) : (function (e) { - let t = !1;return Object.values(hi).includes(e) && (t = !0), (e >= 120001 && e <= 13e4 || e >= 10100 && e <= 10200) && (t = !0), t; - }(s)) && i && r.addFailedCountOfUserSide(i); - } }, { key: 'resendMessage', value(e) { - return e.isResend = !0, e.status = _t.UNSEND, this.sendMessageInstance(e); - } }, { key: 'revokeMessage', value(e) { - const t = this; let n = null;if (e.conversationType === k.CONV_C2C) { - if (!(n = this.getModule(Nt))) return this._onCannotFindModule(); - } else if (e.conversationType === k.CONV_GROUP && !(n = this.getModule(At))) return this._onCannotFindModule();const o = new Da(qa);return o.setMessage('tjg_id:'.concat(this.generateTjgID(e), ' type:').concat(e.type, ' from:') - .concat(e.from, ' to:') - .concat(e.to)), n.revokeMessage(e).then(((n) => { - const a = n.data.recallRetList;if (!dt(a) && 0 !== a[0].retCode) { - const s = new hr({ code: a[0].retCode, message: pr[a[0].retCode] || ho, data: { message: e } });return o.setCode(s.code).setMoreMessage(s.message) - .end(), Mr(s); - } return Ee.info(''.concat(t._className, '.revokeMessage ok. ID:').concat(e.ID)), e.isRevoked = !0, o.end(), t.getModule(Rt).onMessageRevoked([e]), cr({ message: e }); - })) - .catch(((n) => { - t.probeNetwork().then(((e) => { - const t = m(e, 2); const a = t[0]; const s = t[1];o.setError(n, a, s).end(); - }));const a = new hr({ code: n && n.code ? n.code : Zn.MESSAGE_REVOKE_FAIL, message: n && n.message ? n.message : ho, data: { message: e } });return Ee.warn(''.concat(t._className, '.revokeMessage failed. error:'), n), Mr(a); - })); - } }, { key: 'deleteMessage', value(e) { - const t = this; let n = null; const o = e[0]; const a = o.conversationID; let s = ''; let r = []; let i = [];if (o.conversationType === k.CONV_C2C ? (n = this.getModule(Nt), s = a.replace(k.CONV_C2C, ''), e.forEach(((e) => { - e && e.status === _t.SUCCESS && e.conversationID === a && (e.getOnlineOnlyFlag() || r.push(''.concat(e.sequence, '_').concat(e.random, '_') - .concat(e.time)), i.push(e)); - }))) : o.conversationType === k.CONV_GROUP && (n = this.getModule(At), s = a.replace(k.CONV_GROUP, ''), e.forEach(((e) => { - e && e.status === _t.SUCCESS && e.conversationID === a && (e.getOnlineOnlyFlag() || r.push(''.concat(e.sequence)), i.push(e)); - }))), !n) return this._onCannotFindModule();if (0 === r.length) return this._onMessageDeleted(i);r.length > 30 && (r = r.slice(0, 30), i = i.slice(0, 30));const c = new Da(Va);return c.setMessage('to:'.concat(s, ' count:').concat(r.length)), n.deleteMessage({ to: s, keyList: r }).then((e => (c.end(), Ee.info(''.concat(t._className, '.deleteMessage ok')), t._onMessageDeleted(i)))) - .catch(((e) => { - t.probeNetwork().then(((t) => { - const n = m(t, 2); const o = n[0]; const a = n[1];c.setError(e, o, a).end(); - })), Ee.warn(''.concat(t._className, '.deleteMessage failed. error:'), e);const n = new hr({ code: e && e.code ? e.code : Zn.MESSAGE_DELETE_FAIL, message: e && e.message ? e.message : _o });return Mr(n); - })); - } }, { key: '_onMessageDeleted', value(e) { - return this.getModule(Rt).onMessageDeleted(e), mr({ messageList: e }); - } }, { key: '_generateUUID', value() { - const e = this.getModule(Gt);return ''.concat(e.getSDKAppID(), '-').concat(e.getUserID(), '-') - .concat(function () { - for (var e = '', t = 32;t > 0;--t)e += je[Math.floor(Math.random() * $e)];return e; - }()); - } }, { key: 'getMessageOptionByID', value(e) { - return this._messageOptionsMap.get(e); - } }, { key: '_getNickAndAvatarByUserID', value(e) { - return this.getModule(Ct).getNickAndAvatarByUserID(e); - } }, { key: 'reset', value() { - Ee.log(''.concat(this._className, '.reset')), this._messageOptionsMap.clear(); - } }]), n; - }(Yt)); const mi = (function (e) { - i(n, e);const t = f(n);function n(e) { - let a;return o(this, n), (a = t.call(this, e))._className = 'PluginModule', a.plugins = {}, a; - } return s(n, [{ key: 'registerPlugin', value(e) { - const t = this;Object.keys(e).forEach(((n) => { - t.plugins[n] = e[n]; - })), new Da(Na).setMessage('key='.concat(Object.keys(e))) - .end(); - } }, { key: 'getPlugin', value(e) { - return this.plugins[e]; - } }, { key: 'reset', value() { - Ee.log(''.concat(this._className, '.reset')); - } }]), n; - }(Yt)); const Mi = (function (e) { - i(n, e);const t = f(n);function n(e) { - let a;return o(this, n), (a = t.call(this, e))._className = 'SyncUnreadMessageModule', a._cookie = '', a._onlineSyncFlag = !1, a.getInnerEmitterInstance().on(Ir.CONTEXT_A2KEY_AND_TINYID_UPDATED, a._onLoginSuccess, h(a)), a; - } return s(n, [{ key: '_onLoginSuccess', value(e) { - this._startSync({ cookie: this._cookie, syncFlag: 0, isOnlineSync: 0 }); - } }, { key: '_startSync', value(e) { - const t = this; const n = e.cookie; const o = e.syncFlag; const a = e.isOnlineSync;Ee.log(''.concat(this._className, '._startSync cookie:').concat(n, ' syncFlag:') - .concat(o, ' isOnlineSync:') - .concat(a)), this.request({ protocolName: Xt, requestData: { cookie: n, syncFlag: o, isOnlineSync: a } }).then(((e) => { - const n = e.data; const o = n.cookie; const a = n.syncFlag; const s = n.eventArray; const r = n.messageList; const i = n.C2CRemainingUnreadList;if (t._cookie = o, dt(o));else if (0 === a || 1 === a) { - if (s)t.getModule(Kt).onMessage({ head: {}, body: { eventArray: s, isInstantMessage: t._onlineSyncFlag, isSyncingEnded: !1 } });t.getModule(Nt).onNewC2CMessage({ dataList: r, isInstantMessage: !1, C2CRemainingUnreadList: i }), t._startSync({ cookie: o, syncFlag: a, isOnlineSync: 0 }); - } else if (2 === a) { - if (s)t.getModule(Kt).onMessage({ head: {}, body: { eventArray: s, isInstantMessage: t._onlineSyncFlag, isSyncingEnded: !0 } });t.getModule(Nt).onNewC2CMessage({ dataList: r, isInstantMessage: t._onlineSyncFlag, C2CRemainingUnreadList: i }); - } - })) - .catch(((e) => { - Ee.error(''.concat(t._className, '._startSync failed. error:'), e); - })); - } }, { key: 'startOnlineSync', value() { - Ee.log(''.concat(this._className, '.startOnlineSync')), this._onlineSyncFlag = !0, this._startSync({ cookie: this._cookie, syncFlag: 0, isOnlineSync: 1 }); - } }, { key: 'reset', value() { - Ee.log(''.concat(this._className, '.reset')), this._onlineSyncFlag = !1, this._cookie = ''; - } }]), n; - }(Yt)); const vi = { request: { toAccount: 'To_Account', fromAccount: 'From_Account', to: 'To_Account', from: 'From_Account', groupID: 'GroupId', groupAtUserID: 'GroupAt_Account', extension: 'Ext', data: 'Data', description: 'Desc', elements: 'MsgBody', sizeType: 'Type', downloadFlag: 'Download_Flag', thumbUUID: 'ThumbUUID', videoUUID: 'VideoUUID', remoteAudioUrl: 'Url', remoteVideoUrl: 'VideoUrl', videoUrl: '', imageUrl: 'URL', fileUrl: 'Url', uuid: 'UUID', priority: 'MsgPriority', receiverUserID: 'To_Account', receiverGroupID: 'GroupId', messageSender: 'SenderId', messageReceiver: 'ReceiverId', nick: 'From_AccountNick', avatar: 'From_AccountHeadurl', messageNumber: 'MsgNum', pbDownloadKey: 'PbMsgKey', downloadKey: 'JsonMsgKey', applicationType: 'PendencyType', userIDList: 'To_Account', groupNameList: 'GroupName', userID: 'To_Account' }, response: { MsgPriority: 'priority', ThumbUUID: 'thumbUUID', VideoUUID: 'videoUUID', Download_Flag: 'downloadFlag', GroupId: 'groupID', Member_Account: 'userID', MsgList: 'messageList', SyncFlag: 'syncFlag', To_Account: 'to', From_Account: 'from', MsgSeq: 'sequence', MsgRandom: 'random', MsgTime: 'time', MsgTimeStamp: 'time', MsgContent: 'content', MsgBody: 'elements', From_AccountNick: 'nick', From_AccountHeadurl: 'avatar', GroupWithdrawInfoArray: 'revokedInfos', GroupReadInfoArray: 'groupMessageReadNotice', LastReadMsgSeq: 'lastMessageSeq', WithdrawC2cMsgNotify: 'c2cMessageRevokedNotify', C2cWithdrawInfoArray: 'revokedInfos', C2cReadedReceipt: 'c2cMessageReadReceipt', ReadC2cMsgNotify: 'c2cMessageReadNotice', LastReadTime: 'peerReadTime', MsgRand: 'random', MsgType: 'type', MsgShow: 'messageShow', NextMsgSeq: 'nextMessageSeq', FaceUrl: 'avatar', ProfileDataMod: 'profileModify', Profile_Account: 'userID', ValueBytes: 'value', ValueNum: 'value', NoticeSeq: 'noticeSequence', NotifySeq: 'notifySequence', MsgFrom_AccountExtraInfo: 'messageFromAccountExtraInformation', Operator_Account: 'operatorID', OpType: 'operationType', ReportType: 'operationType', UserId: 'userID', User_Account: 'userID', List_Account: 'userIDList', MsgOperatorMemberExtraInfo: 'operatorInfo', MsgMemberExtraInfo: 'memberInfoList', ImageUrl: 'avatar', NickName: 'nick', MsgGroupNewInfo: 'newGroupProfile', MsgAppDefinedData: 'groupCustomField', Owner_Account: 'ownerID', GroupFaceUrl: 'avatar', GroupIntroduction: 'introduction', GroupNotification: 'notification', GroupApplyJoinOption: 'joinOption', MsgKey: 'messageKey', GroupInfo: 'groupProfile', ShutupTime: 'muteTime', Desc: 'description', Ext: 'extension', GroupAt_Account: 'groupAtUserID', MsgNum: 'messageNumber', PbMsgKey: 'pbDownloadKey', JsonMsgKey: 'downloadKey', MsgModifiedFlag: 'isModified', PendencyItem: 'applicationItem', PendencyType: 'applicationType', AddTime: 'time', AddSource: 'source', AddWording: 'wording', ProfileImImage: 'avatar', PendencyAdd: 'friendApplicationAdded', FrienPencydDel_Account: 'friendApplicationDeletedUserIDList' }, ignoreKeyWord: ['C2C', 'ID', 'USP'] };function yi(e, t) { - if ('string' !== typeof e && !Array.isArray(e)) throw new TypeError('Expected the input to be `string | string[]`');t = Object.assign({ pascalCase: !1 }, t);let n;return 0 === (e = Array.isArray(e) ? e.map((e => e.trim())).filter((e => e.length)) - .join('-') : e.trim()).length ? '' : 1 === e.length ? t.pascalCase ? e.toUpperCase() : e.toLowerCase() : (e !== e.toLowerCase() && (e = Ii(e)), e = e.replace(/^[_.\- ]+/, '').toLowerCase() - .replace(/[_.\- ]+(\w|$)/g, ((e, t) => t.toUpperCase())) - .replace(/\d+(\w|$)/g, (e => e.toUpperCase())), n = e, t.pascalCase ? n.charAt(0).toUpperCase() + n.slice(1) : n); - } var Ii = function (e) { - for (let t = !1, n = !1, o = !1, a = 0;a < e.length;a++) { - const s = e[a];t && /[a-zA-Z]/.test(s) && s.toUpperCase() === s ? (e = `${e.slice(0, a)}-${e.slice(a)}`, t = !1, o = n, n = !0, a++) : n && o && /[a-zA-Z]/.test(s) && s.toLowerCase() === s ? (e = `${e.slice(0, a - 1)}-${e.slice(a - 1)}`, o = n, n = !1, t = !0) : (t = s.toLowerCase() === s && s.toUpperCase() !== s, o = n, n = s.toUpperCase() === s && s.toLowerCase() !== s); - } return e; - };function Di(e, t) { - let n = 0;return (function e(t, o) { - if (++n > 100) return n--, t;if (Re(t)) { - const a = t.map((t => (Oe(t) ? e(t, o) : t)));return n--, a; - } if (Oe(t)) { - let s = (r = t, i = function (e, t) { - if (!Fe(t)) return !1;if ((a = t) !== yi(a)) for (let n = 0;n < vi.ignoreKeyWord.length && !t.includes(vi.ignoreKeyWord[n]);n++);let a;return Ge(o[t]) ? (function (e) { - return 'OPPOChannelID' === e ? e : e[0].toUpperCase() + yi(e).slice(1); - }(t)) : o[t]; - }, c = Object.create(null), Object.keys(r).forEach(((e) => { - const t = i(r[e], e);t && (c[t] = r[e]); - })), c);return s = ot(s, ((t, n) => (Re(t) || Oe(t) ? e(t, o) : t))), n--, s; - } let r; let i; let c; - }(e, t)); - } function Ti(e, t) { - if (Re(e)) return e.map((e => (Oe(e) ? Ti(e, t) : e)));if (Oe(e)) { - let n = (o = e, a = function (e, n) { - return Ge(t[n]) ? yi(n) : t[n]; - }, s = {}, Object.keys(o).forEach(((e) => { - s[a(o[e], e)] = o[e]; - })), s);return n = ot(n, (e => (Re(e) || Oe(e) ? Ti(e, t) : e))); - } let o; let a; let s; - } const Si = (function () { - function e(t) { - o(this, e), this._handler = t;const n = t.getURL();this._socket = null, this._id = He(), z ? $ ? (J.connectSocket({ url: n, header: { 'content-type': 'application/json' } }), J.onSocketClose(this._onClose.bind(this)), J.onSocketOpen(this._onOpen.bind(this)), J.onSocketMessage(this._onMessage.bind(this)), J.onSocketError(this._onError.bind(this))) : (this._socket = J.connectSocket({ url: n, header: { 'content-type': 'application/json' }, complete() {} }), this._socket.onClose(this._onClose.bind(this)), this._socket.onOpen(this._onOpen.bind(this)), this._socket.onMessage(this._onMessage.bind(this)), this._socket.onError(this._onError.bind(this))) : W && (this._socket = new WebSocket(n), this._socket.onopen = this._onOpen.bind(this), this._socket.onmessage = this._onMessage.bind(this), this._socket.onclose = this._onClose.bind(this), this._socket.onerror = this._onError.bind(this)); - } return s(e, [{ key: 'getID', value() { - return this._id; - } }, { key: '_onOpen', value() { - this._handler.onOpen({ id: this._id }); - } }, { key: '_onClose', value(e) { - this._handler.onClose({ id: this._id, e }); - } }, { key: '_onMessage', value(e) { - this._handler.onMessage(e); - } }, { key: '_onError', value(e) { - this._handler.onError({ id: this._id, e }); - } }, { key: 'close', value(e) { - if ($) return J.offSocketClose(), J.offSocketMessage(), J.offSocketOpen(), J.offSocketError(), void J.closeSocket();this._socket && (z ? (this._socket.onClose((() => {})), this._socket.onOpen((() => {})), this._socket.onMessage((() => {})), this._socket.onError((() => {}))) : W && (this._socket.onopen = null, this._socket.onmessage = null, this._socket.onclose = null, this._socket.onerror = null), j ? this._socket.close({ code: e }) : this._socket.close(e), this._socket = null); - } }, { key: 'send', value(e) { - $ ? J.sendSocketMessage({ data: e.data, fail() { - e.fail && e.requestID && e.fail(e.requestID); - } }) : this._socket && (z ? this._socket.send({ data: e.data, fail() { - e.fail && e.requestID && e.fail(e.requestID); - } }) : W && this._socket.send(e.data)); - } }]), e; - }()); const Ei = 4e3; const ki = 4001; const Ci = ['keyMap']; const Ni = ['keyMap']; const Ai = 'connected'; const Oi = 'connecting'; const Li = 'disconnected'; const Ri = (function () { - function e(t) { - o(this, e), this._channelModule = t, this._className = 'SocketHandler', this._promiseMap = new Map, this._readyState = Li, this._simpleRequestMap = new Map, this.MAX_SIZE = 100, this._startSequence = He(), this._startTs = 0, this._reConnectFlag = !1, this._nextPingTs = 0, this._reConnectCount = 0, this.MAX_RECONNECT_COUNT = 3, this._socketID = -1, this._random = 0, this._socket = null, this._url = '', this._onOpenTs = 0, this._setOverseaHost(), this._initConnection(); - } return s(e, [{ key: '_setOverseaHost', value() { - this._channelModule.isOversea() && U.HOST.setCurrent(b); - } }, { key: '_initConnection', value() { - '' === this._url ? this._url = U.HOST.CURRENT.DEFAULT : this._url === U.HOST.CURRENT.DEFAULT ? this._url = U.HOST.CURRENT.BACKUP : this._url === U.HOST.CURRENT.BACKUP && (this._url = U.HOST.CURRENT.DEFAULT), this._connect(), this._nextPingTs = 0; - } }, { key: 'onCheckTimer', value(e) { - e % 1 == 0 && this._checkPromiseMap(); - } }, { key: '_checkPromiseMap', value() { - const e = this;0 !== this._promiseMap.size && this._promiseMap.forEach(((t, n) => { - const o = t.reject; const a = t.timestamp;Date.now() - a >= 15e3 && (Ee.log(''.concat(e._className, '._checkPromiseMap request timeout, delete requestID:').concat(n)), e._promiseMap.delete(n), o(new hr({ code: Zn.NETWORK_TIMEOUT, message: na })), e._channelModule.onRequestTimeout(n)); - })); - } }, { key: 'onOpen', value(e) { - this._onOpenTs = Date.now();const t = e.id;this._socketID = t, new Da(Oa).setMessage(n) - .setMessage('socketID:'.concat(t)) - .end();var n = Date.now() - this._startTs;Ee.log(''.concat(this._className, '._onOpen cost ').concat(n, ' ms. socketID:') - .concat(t)), e.id === this._socketID && (this._readyState = Ai, this._reConnectCount = 0, this._resend(), !0 === this._reConnectFlag && (this._channelModule.onReconnected(), this._reConnectFlag = !1), this._channelModule.onOpen()); - } }, { key: 'onClose', value(e) { - const t = new Da(La); const n = e.id; const o = e.e; const a = 'sourceSocketID:'.concat(n, ' currentSocketID:').concat(this._socketID); let s = 0;0 !== this._onOpenTs && (s = Date.now() - this._onOpenTs), t.setMessage(s).setMoreMessage(a) - .setCode(o.code) - .end(), Ee.log(''.concat(this._className, '._onClose code:').concat(o.code, ' reason:') - .concat(o.reason, ' ') - .concat(a)), n === this._socketID && (this._readyState = Li, s < 1e3 ? this._channelModule.onReconnectFailed() : this._channelModule.onClose()); - } }, { key: 'onError', value(e) { - const t = e.id; const n = e.e; const o = 'sourceSocketID:'.concat(t, ' currentSocketID:').concat(this._socketID);new Da(Ra).setMessage(n.errMsg || xe(n)) - .setMoreMessage(o) - .setLevel('error') - .end(), Ee.warn(''.concat(this._className, '._onError'), n, o), t === this._socketID && (this._readyState = '', this._channelModule.onError()); - } }, { key: 'onMessage', value(e) { - let t;try { - t = JSON.parse(e.data); - } catch (u) { - new Da(Ya).setMessage(e.data) - .end(); - } if (t && t.head) { - const n = this._getRequestIDFromHead(t.head); const o = ct(t.head); const a = Ti(t.body, this._getResponseKeyMap(o));if (Ee.debug(''.concat(this._className, '.onMessage ret:').concat(JSON.stringify(a), ' requestID:') - .concat(n, ' has:') - .concat(this._promiseMap.has(n))), this._setNextPingTs(), this._promiseMap.has(n)) { - const s = this._promiseMap.get(n); const r = s.resolve; const i = s.reject; const c = s.timestamp;return this._promiseMap.delete(n), this._calcRTT(c), void (a.errorCode && 0 !== a.errorCode ? (this._channelModule.onErrorCodeNotZero(a), i(new hr({ code: a.errorCode, message: a.errorInfo || '' }))) : r(cr(a))); - } this._channelModule.onMessage({ head: t.head, body: a }); - } - } }, { key: '_calcRTT', value(e) { - const t = Date.now() - e;this._channelModule.getModule($t).addRTT(t); - } }, { key: '_connect', value() { - new Da(Aa).setMessage('url:'.concat(this.getURL())) - .end(), this._startTs = Date.now(), this._socket = new Si(this), this._socketID = this._socket.getID(), this._readyState = Oi; - } }, { key: 'getURL', value() { - const e = this._channelModule.getModule(Gt);return ''.concat(this._url, '/info?sdkappid=').concat(e.getSDKAppID(), '&instanceid=') - .concat(e.getInstanceID(), '&random=') - .concat(this._getRandom()); - } }, { key: '_closeConnection', value(e) { - this._socket && (this._socket.close(e), this._socketID = -1, this._socket = null, this._readyState = Li); - } }, { key: '_resend', value() { - const e = this;if (Ee.log(''.concat(this._className, '._resend reConnectFlag:').concat(this._reConnectFlag), 'promiseMap.size:'.concat(this._promiseMap.size, ' simpleRequestMap.size:').concat(this._simpleRequestMap.size)), this._promiseMap.size > 0 && this._promiseMap.forEach(((t, n) => { - const o = t.uplinkData; const a = t.resolve; const s = t.reject;e._promiseMap.set(n, { resolve: a, reject: s, timestamp: Date.now(), uplinkData: o }), e._execute(n, o); - })), this._simpleRequestMap.size > 0) { - let t; const n = S(this._simpleRequestMap);try { - for (n.s();!(t = n.n()).done;) { - const o = m(t.value, 2); const a = o[0]; const s = o[1];this._execute(a, s); - } - } catch (r) { - n.e(r); - } finally { - n.f(); - } this._simpleRequestMap.clear(); - } - } }, { key: 'send', value(e) { - const t = this;e.head.seq = this._getSequence(), e.head.reqtime = Math.floor(Date.now() / 1e3);e.keyMap;const n = p(e, Ci); const o = this._getRequestIDFromHead(e.head); const a = JSON.stringify(n);return new Promise(((e, s) => { - (t._promiseMap.set(o, { resolve: e, reject: s, timestamp: Date.now(), uplinkData: a }), Ee.debug(''.concat(t._className, '.send uplinkData:').concat(JSON.stringify(n), ' requestID:') - .concat(o, ' readyState:') - .concat(t._readyState)), t._readyState !== Ai) ? t._reConnect() : (t._execute(o, a), t._channelModule.getModule($t).addRequestCount()); - })); - } }, { key: 'simplySend', value(e) { - e.head.seq = this._getSequence(), e.head.reqtime = Math.floor(Date.now() / 1e3);e.keyMap;const t = p(e, Ni); const n = this._getRequestIDFromHead(e.head); const o = JSON.stringify(t);this._readyState !== Ai ? (this._simpleRequestMap.size < this.MAX_SIZE ? this._simpleRequestMap.set(n, o) : Ee.log(''.concat(this._className, '.simplySend. simpleRequestMap is full, drop request!')), this._reConnect()) : this._execute(n, o); - } }, { key: '_execute', value(e, t) { - this._socket.send({ data: t, fail: z ? this._onSendFail.bind(this) : void 0, requestID: e }); - } }, { key: '_onSendFail', value(e) { - Ee.log(''.concat(this._className, '._onSendFail requestID:').concat(e)); - } }, { key: '_getSequence', value() { - let e;if (this._startSequence < 2415919103) return e = this._startSequence, this._startSequence += 1, 2415919103 === this._startSequence && (this._startSequence = He()), e; - } }, { key: '_getRequestIDFromHead', value(e) { - return e.servcmd + e.seq; - } }, { key: '_getResponseKeyMap', value(e) { - const n = this._channelModule.getKeyMap(e);return t(t({}, vi.response), n.response); - } }, { key: '_reConnect', value() { - this._readyState !== Ai && this._readyState !== Oi && this.forcedReconnect(); - } }, { key: 'forcedReconnect', value() { - const e = this;Ee.log(''.concat(this._className, '.forcedReconnect count:').concat(this._reConnectCount, ' readyState:') - .concat(this._readyState)), this._reConnectFlag = !0, this._resetRandom(), this._reConnectCount < this.MAX_RECONNECT_COUNT ? (this._reConnectCount += 1, this._closeConnection(ki), this._initConnection()) : this._channelModule.probeNetwork().then(((t) => { - const n = m(t, 2); const o = n[0];n[1];o ? (Ee.warn(''.concat(e._className, '.forcedReconnect disconnected from wsserver but network is ok, continue...')), e._reConnectCount = 0, e._closeConnection(ki), e._initConnection()) : e._channelModule.onReconnectFailed(); - })); - } }, { key: 'getReconnectFlag', value() { - return this._reConnectFlag; - } }, { key: '_setNextPingTs', value() { - this._nextPingTs = Date.now() + 1e4; - } }, { key: 'getNextPingTs', value() { - return this._nextPingTs; - } }, { key: 'isConnected', value() { - return this._readyState === Ai; - } }, { key: '_getRandom', value() { - return 0 === this._random && (this._random = Math.random()), this._random; - } }, { key: '_resetRandom', value() { - this._random = 0; - } }, { key: 'close', value() { - Ee.log(''.concat(this._className, '.close')), this._closeConnection(Ei), this._promiseMap.clear(), this._startSequence = He(), this._readyState = Li, this._simpleRequestMap.clear(), this._reConnectFlag = !1, this._reConnectCount = 0, this._onOpenTs = 0, this._url = '', this._random = 0; - } }]), e; - }()); const Gi = (function (e) { - i(n, e);const t = f(n);function n(e) { - let a;if (o(this, n), (a = t.call(this, e))._className = 'ChannelModule', a._socketHandler = new Ri(h(a)), a._probing = !1, a._isAppShowing = !0, a._previousState = k.NET_STATE_CONNECTED, z && 'function' === typeof J.onAppShow && 'function' === typeof J.onAppHide) { - const s = a._onAppHide.bind(h(a)); const r = a._onAppShow.bind(h(a));'function' === typeof J.offAppHide && J.offAppHide(s), 'function' === typeof J.offAppShow && J.offAppShow(r), J.onAppHide(s), J.onAppShow(r); - } return a._timerForNotLoggedIn = -1, a._timerForNotLoggedIn = setInterval(a.onCheckTimer.bind(h(a)), 1e3), a._fatalErrorFlag = !1, a; - } return s(n, [{ key: 'onCheckTimer', value(e) { - this._socketHandler && (this.isLoggedIn() ? (this._timerForNotLoggedIn > 0 && (clearInterval(this._timerForNotLoggedIn), this._timerForNotLoggedIn = -1), this._socketHandler.onCheckTimer(e)) : this._socketHandler.onCheckTimer(1), this._checkNextPing()); - } }, { key: 'onErrorCodeNotZero', value(e) { - this.getModule(Kt).onErrorCodeNotZero(e); - } }, { key: 'onMessage', value(e) { - this.getModule(Kt).onMessage(e); - } }, { key: 'send', value(e) { - return this._previousState !== k.NET_STATE_CONNECTED && e.head.servcmd.includes(Hn) ? this._sendLogViaHTTP(e) : this._socketHandler.send(e); - } }, { key: '_sendLogViaHTTP', value(e) { - return new Promise(((t, n) => { - const o = 'https://webim.tim.qq.com/v4/imopenstat/tim_web_report_v2?sdkappid='.concat(e.head.sdkappid, '&reqtime=').concat(Date.now()); const a = JSON.stringify(e.body); const s = 'application/x-www-form-urlencoded;charset=UTF-8';if (z)J.request({ url: o, data: a, method: 'POST', timeout: 3e3, header: { 'content-type': s }, success() { - t(); - }, fail() { - n(new hr({ code: Zn.NETWORK_ERROR, message: ta })); - } });else { - const r = new XMLHttpRequest; const i = setTimeout((() => { - r.abort(), n(new hr({ code: Zn.NETWORK_TIMEOUT, message: na })); - }), 3e3);r.onreadystatechange = function () { - 4 === r.readyState && (clearTimeout(i), 200 === r.status || 304 === r.status ? t() : n(new hr({ code: Zn.NETWORK_ERROR, message: ta }))); - }, r.open('POST', o, !0), r.setRequestHeader('Content-type', s), r.send(a); - } - })); - } }, { key: 'simplySend', value(e) { - return this._socketHandler.simplySend(e); - } }, { key: 'onOpen', value() { - this._ping(); - } }, { key: 'onClose', value() { - this.reConnect(); - } }, { key: 'onError', value() { - Ee.error(''.concat(this._className, '.onError 从v2.11.2起,SDK 支持了 WebSocket,如您未添加相关受信域名,请先添加!升级指引: https://web.sdk.qcloud.com/im/doc/zh-cn/tutorial-02-upgradeguideline.html')); - } }, { key: 'getKeyMap', value(e) { - return this.getModule(Kt).getKeyMap(e); - } }, { key: '_onAppHide', value() { - this._isAppShowing = !1; - } }, { key: '_onAppShow', value() { - this._isAppShowing = !0; - } }, { key: 'onRequestTimeout', value(e) {} }, { key: 'onReconnected', value() { - Ee.log(''.concat(this._className, '.onReconnected')), this.getModule(Kt).onReconnected(), this._emitNetStateChangeEvent(k.NET_STATE_CONNECTED); - } }, { key: 'onReconnectFailed', value() { - Ee.log(''.concat(this._className, '.onReconnectFailed')), this._emitNetStateChangeEvent(k.NET_STATE_DISCONNECTED); - } }, { key: 'reConnect', value() { - if (!this._fatalErrorFlag && this._socketHandler) { - const e = this._socketHandler.getReconnectFlag();if (Ee.log(''.concat(this._className, '.reConnect state:').concat(this._previousState, ' reconnectFlag:') - .concat(e)), this._previousState === k.NET_STATE_CONNECTING && e) return;this._socketHandler.forcedReconnect(), this._emitNetStateChangeEvent(k.NET_STATE_CONNECTING); - } - } }, { key: '_emitNetStateChangeEvent', value(e) { - this._previousState !== e && (this._previousState = e, this.emitOuterEvent(E.NET_STATE_CHANGE, { state: e })); - } }, { key: '_ping', value() { - const e = this;if (!0 !== this._probing) { - this._probing = !0;const t = this.getModule(Kt).getProtocolData({ protocolName: jn });this.send(t).then((() => { - e._probing = !1; - })) - .catch(((t) => { - if (Ee.warn(''.concat(e._className, '._ping failed. error:'), t), e._probing = !1, t && 60002 === t.code) return new Da(Fs).setMessage('code:'.concat(t.code, ' message:').concat(t.message)) - .setNetworkType(e.getModule(bt).getNetworkType()) - .end(), e._fatalErrorFlag = !0, void e.emitOuterEvent(E.NET_STATE_CHANGE, k.NET_STATE_DISCONNECTED);e.probeNetwork().then(((t) => { - const n = m(t, 2); const o = n[0]; const a = n[1];Ee.log(''.concat(e._className, '._ping failed. isAppShowing:').concat(e._isAppShowing, ' online:') - .concat(o, ' networkType:') - .concat(a)), o ? e.reConnect() : e.emitOuterEvent(E.NET_STATE_CHANGE, k.NET_STATE_DISCONNECTED); - })); - })); - } - } }, { key: '_checkNextPing', value() { - this._socketHandler.isConnected() && (Date.now() >= this._socketHandler.getNextPingTs() && this._ping()); - } }, { key: 'dealloc', value() { - this._socketHandler && (this._socketHandler.close(), this._socketHandler = null), this._timerForNotLoggedIn > -1 && clearInterval(this._timerForNotLoggedIn); - } }, { key: 'reset', value() { - Ee.log(''.concat(this._className, '.reset')), this._previousState = k.NET_STATE_CONNECTED, this._probing = !1, this._fatalErrorFlag = !1, this._timerForNotLoggedIn = setInterval(this.onCheckTimer.bind(this), 1e3); - } }]), n; - }(Yt)); const wi = ['a2', 'tinyid']; const Pi = ['a2', 'tinyid']; const bi = (function () { - function e(t) { - o(this, e), this._className = 'ProtocolHandler', this._sessionModule = t, this._configMap = new Map, this._fillConfigMap(); - } return s(e, [{ key: '_fillConfigMap', value() { - this._configMap.clear();const e = this._sessionModule.genCommonHead(); const n = this._sessionModule.genCosSpecifiedHead(); const o = this._sessionModule.genSSOReportHead();this._configMap.set(zt, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.IM_OPEN_STATUS, '.').concat(U.CMD.LOGIN) }), body: { state: 'Online' }, keyMap: { response: { TinyId: 'tinyID', InstId: 'instanceID', HelloInterval: 'helloInterval' } } }; - }(e))), this._configMap.set(Wt, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.IM_OPEN_STATUS, '.').concat(U.CMD.LOGOUT) }), body: {} }; - }(e))), this._configMap.set(Jt, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.IM_OPEN_STATUS, '.').concat(U.CMD.HELLO) }), body: {}, keyMap: { response: { NewInstInfo: 'newInstanceInfo' } } }; - }(e))), this._configMap.set(xn, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.IM_COS_SIGN, '.').concat(U.CMD.COS_SIGN) }), body: { cmd: 'open_im_cos_svc', subCmd: 'get_cos_token', duration: 300, version: 2 }, keyMap: { request: { userSig: 'usersig', subCmd: 'sub_cmd', cmd: 'cmd', duration: 'duration', version: 'version' }, response: { expired_time: 'expiredTime', bucket_name: 'bucketName', session_token: 'sessionToken', tmp_secret_id: 'secretId', tmp_secret_key: 'secretKey' } } }; - }(n))), this._configMap.set(Bn, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.CUSTOM_UPLOAD, '.').concat(U.CMD.COS_PRE_SIG) }), body: { fileType: void 0, fileName: void 0, uploadMethod: 0, duration: 900 }, keyMap: { request: { userSig: 'usersig', fileType: 'file_type', fileName: 'file_name', uploadMethod: 'upload_method' }, response: { expired_time: 'expiredTime', request_id: 'requestId', head_url: 'headUrl', upload_url: 'uploadUrl', download_url: 'downloadUrl', ci_url: 'ciUrl' } } }; - }(n))), this._configMap.set(Xn, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.CLOUD_CONTROL, '.').concat(U.CMD.FETCH_CLOUD_CONTROL_CONFIG) }), body: { SDKAppID: 0, version: 0 }, keyMap: { request: { SDKAppID: 'uint32_sdkappid', version: 'uint64_version' }, response: { int32_error_code: 'errorCode', str_error_message: 'errorMessage', str_json_config: 'cloudControlConfig', uint32_expired_time: 'expiredTime', uint32_sdkappid: 'SDKAppID', uint64_version: 'version' } } }; - }(e))), this._configMap.set(Qn, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.CLOUD_CONTROL, '.').concat(U.CMD.PUSHED_CLOUD_CONTROL_CONFIG) }), body: {}, keyMap: { response: { int32_error_code: 'errorCode', str_error_message: 'errorMessage', str_json_config: 'cloudControlConfig', uint32_expired_time: 'expiredTime', uint32_sdkappid: 'SDKAppID', uint64_version: 'version' } } }; - }(e))), this._configMap.set(Xt, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.OPEN_IM, '.').concat(U.CMD.GET_MESSAGES) }), body: { cookie: '', syncFlag: 0, needAbstract: 1, isOnlineSync: 0 }, keyMap: { request: { fromAccount: 'From_Account', toAccount: 'To_Account', from: 'From_Account', to: 'To_Account', time: 'MsgTimeStamp', sequence: 'MsgSeq', random: 'MsgRandom', elements: 'MsgBody' }, response: { MsgList: 'messageList', SyncFlag: 'syncFlag', To_Account: 'to', From_Account: 'from', ClientSeq: 'clientSequence', MsgSeq: 'sequence', NoticeSeq: 'noticeSequence', NotifySeq: 'notifySequence', MsgRandom: 'random', MsgTimeStamp: 'time', MsgContent: 'content', ToGroupId: 'groupID', MsgKey: 'messageKey', GroupTips: 'groupTips', MsgBody: 'elements', MsgType: 'type', C2CRemainingUnreadCount: 'C2CRemainingUnreadList', C2CPairUnreadCount: 'C2CPairUnreadList' } } }; - }(e))), this._configMap.set(Qt, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.OPEN_IM, '.').concat(U.CMD.BIG_DATA_HALLWAY_AUTH_KEY) }), body: {} }; - }(e))), this._configMap.set(Zt, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.OPEN_IM, '.').concat(U.CMD.SEND_MESSAGE) }), body: { fromAccount: '', toAccount: '', msgTimeStamp: void 0, msgSeq: 0, msgRandom: 0, msgBody: [], cloudCustomData: void 0, nick: '', avatar: '', msgLifeTime: void 0, offlinePushInfo: { pushFlag: 0, title: '', desc: '', ext: '', apnsInfo: { badgeMode: 0 }, androidInfo: { OPPOChannelID: '' } } }, keyMap: { request: { fromAccount: 'From_Account', toAccount: 'To_Account', msgTimeStamp: 'MsgTimeStamp', msgSeq: 'MsgSeq', msgRandom: 'MsgRandom', msgBody: 'MsgBody', count: 'MaxCnt', lastMessageTime: 'LastMsgTime', messageKey: 'MsgKey', peerAccount: 'Peer_Account', data: 'Data', description: 'Desc', extension: 'Ext', type: 'MsgType', content: 'MsgContent', sizeType: 'Type', uuid: 'UUID', url: '', imageUrl: 'URL', fileUrl: 'Url', remoteAudioUrl: 'Url', remoteVideoUrl: 'VideoUrl', thumbUUID: 'ThumbUUID', videoUUID: 'VideoUUID', videoUrl: '', downloadFlag: 'Download_Flag', nick: 'From_AccountNick', avatar: 'From_AccountHeadurl', from: 'From_Account', time: 'MsgTimeStamp', messageRandom: 'MsgRandom', messageSequence: 'MsgSeq', elements: 'MsgBody', clientSequence: 'ClientSeq', payload: 'MsgContent', messageList: 'MsgList', messageNumber: 'MsgNum', abstractList: 'AbstractList', messageBody: 'MsgBody' } } }; - }(e))), this._configMap.set(en, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.GROUP, '.').concat(U.CMD.SEND_GROUP_MESSAGE) }), body: { fromAccount: '', groupID: '', random: 0, clientSequence: 0, priority: '', msgBody: [], cloudCustomData: void 0, onlineOnlyFlag: 0, offlinePushInfo: { pushFlag: 0, title: '', desc: '', ext: '', apnsInfo: { badgeMode: 0 }, androidInfo: { OPPOChannelID: '' } }, groupAtInfo: [] }, keyMap: { request: { to: 'GroupId', extension: 'Ext', data: 'Data', description: 'Desc', random: 'Random', sequence: 'ReqMsgSeq', count: 'ReqMsgNumber', type: 'MsgType', priority: 'MsgPriority', content: 'MsgContent', elements: 'MsgBody', sizeType: 'Type', uuid: 'UUID', url: '', imageUrl: 'URL', fileUrl: 'Url', remoteAudioUrl: 'Url', remoteVideoUrl: 'VideoUrl', thumbUUID: 'ThumbUUID', videoUUID: 'VideoUUID', videoUrl: '', downloadFlag: 'Download_Flag', clientSequence: 'ClientSeq', from: 'From_Account', time: 'MsgTimeStamp', messageRandom: 'MsgRandom', messageSequence: 'MsgSeq', payload: 'MsgContent', messageList: 'MsgList', messageNumber: 'MsgNum', abstractList: 'AbstractList', messageBody: 'MsgBody' }, response: { MsgTime: 'time', MsgSeq: 'sequence' } } }; - }(e))), this._configMap.set(rn, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.OPEN_IM, '.').concat(U.CMD.REVOKE_C2C_MESSAGE) }), body: { msgInfo: { fromAccount: '', toAccount: '', msgTimeStamp: 0, msgSeq: 0, msgRandom: 0 } }, keyMap: { request: { msgInfo: 'MsgInfo', msgTimeStamp: 'MsgTimeStamp', msgSeq: 'MsgSeq', msgRandom: 'MsgRandom' } } }; - }(e))), this._configMap.set(Nn, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.GROUP, '.').concat(U.CMD.REVOKE_GROUP_MESSAGE) }), body: { to: '', msgSeqList: void 0 }, keyMap: { request: { to: 'GroupId', msgSeqList: 'MsgSeqList', msgSeq: 'MsgSeq' } } }; - }(e))), this._configMap.set(un, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.OPEN_IM, '.').concat(U.CMD.GET_C2C_ROAM_MESSAGES) }), body: { peerAccount: '', count: 15, lastMessageTime: 0, messageKey: '', withRecalledMessage: 1 }, keyMap: { request: { messageKey: 'MsgKey', peerAccount: 'Peer_Account', count: 'MaxCnt', lastMessageTime: 'LastMsgTime', withRecalledMessage: 'WithRecalledMsg' } } }; - }(e))), this._configMap.set(On, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.GROUP, '.').concat(U.CMD.GET_GROUP_ROAM_MESSAGES) }), body: { withRecalledMsg: 1, groupID: '', count: 15, sequence: '' }, keyMap: { request: { sequence: 'ReqMsgSeq', count: 'ReqMsgNumber', withRecalledMessage: 'WithRecalledMsg' }, response: { Random: 'random', MsgTime: 'time', MsgSeq: 'sequence', ReqMsgSeq: 'sequence', RspMsgList: 'messageList', IsPlaceMsg: 'isPlaceMessage', IsSystemMsg: 'isSystemMessage', ToGroupId: 'to', EnumFrom_AccountType: 'fromAccountType', EnumTo_AccountType: 'toAccountType', GroupCode: 'groupCode', MsgPriority: 'priority', MsgBody: 'elements', MsgType: 'type', MsgContent: 'content', IsFinished: 'complete', Download_Flag: 'downloadFlag', ClientSeq: 'clientSequence', ThumbUUID: 'thumbUUID', VideoUUID: 'videoUUID' } } }; - }(e))), this._configMap.set(cn, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.OPEN_IM, '.').concat(U.CMD.SET_C2C_MESSAGE_READ) }), body: { C2CMsgReaded: void 0 }, keyMap: { request: { lastMessageTime: 'LastedMsgTime' } } }; - }(e))), this._configMap.set(An, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.GROUP, '.').concat(U.CMD.SET_GROUP_MESSAGE_READ) }), body: { groupID: void 0, messageReadSeq: void 0 }, keyMap: { request: { messageReadSeq: 'MsgReadedSeq' } } }; - }(e))), this._configMap.set(dn, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.OPEN_IM, '.').concat(U.CMD.DELETE_C2C_MESSAGE) }), body: { fromAccount: '', to: '', keyList: void 0 }, keyMap: { request: { keyList: 'MsgKeyList' } } }; - }(e))), this._configMap.set(bn, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.GROUP, '.').concat(U.CMD.DELETE_GROUP_MESSAGE) }), body: { groupID: '', deleter: '', keyList: void 0 }, keyMap: { request: { deleter: 'Deleter_Account', keyList: 'Seqs' } } }; - }(e))), this._configMap.set(ln, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.OPEN_IM, '.').concat(U.CMD.GET_PEER_READ_TIME) }), body: { userIDList: void 0 }, keyMap: { request: { userIDList: 'To_Account' }, response: { ReadTime: 'peerReadTimeList' } } }; - }(e))), this._configMap.set(pn, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.RECENT_CONTACT, '.').concat(U.CMD.GET_CONVERSATION_LIST) }), body: { fromAccount: void 0, count: 0 }, keyMap: { request: {}, response: { SessionItem: 'conversations', ToAccount: 'groupID', To_Account: 'userID', UnreadMsgCount: 'unreadCount', MsgGroupReadedSeq: 'messageReadSeq', C2cPeerReadTime: 'c2cPeerReadTime' } } }; - }(e))), this._configMap.set(gn, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.RECENT_CONTACT, '.').concat(U.CMD.PAGING_GET_CONVERSATION_LIST) }), body: { fromAccount: void 0, timeStamp: void 0, orderType: void 0, messageAssistFlag: 4 }, keyMap: { request: { messageAssistFlag: 'MsgAssistFlags' }, response: { SessionItem: 'conversations', ToAccount: 'groupID', To_Account: 'userID', UnreadMsgCount: 'unreadCount', MsgGroupReadedSeq: 'messageReadSeq', C2cPeerReadTime: 'c2cPeerReadTime', LastMsgFlags: 'lastMessageFlag' } } }; - }(e))), this._configMap.set(hn, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.RECENT_CONTACT, '.').concat(U.CMD.DELETE_CONVERSATION) }), body: { fromAccount: '', toAccount: void 0, type: 1, toGroupID: void 0 }, keyMap: { request: { toGroupID: 'ToGroupid' } } }; - }(e))), this._configMap.set(_n, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.OPEN_IM, '.').concat(U.CMD.DELETE_GROUP_AT_TIPS) }), body: { messageListToDelete: void 0 }, keyMap: { request: { messageListToDelete: 'DelMsgList', messageSeq: 'MsgSeq', messageRandom: 'MsgRandom' } } }; - }(e))), this._configMap.set(tn, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.PROFILE, '.').concat(U.CMD.PORTRAIT_GET) }), body: { fromAccount: '', userItem: [] }, keyMap: { request: { toAccount: 'To_Account', standardSequence: 'StandardSequence', customSequence: 'CustomSequence' } } }; - }(e))), this._configMap.set(nn, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.PROFILE, '.').concat(U.CMD.PORTRAIT_SET) }), body: { fromAccount: '', profileItem: [{ tag: Ks.NICK, value: '' }, { tag: Ks.GENDER, value: '' }, { tag: Ks.ALLOWTYPE, value: '' }, { tag: Ks.AVATAR, value: '' }] }, keyMap: { request: { toAccount: 'To_Account', standardSequence: 'StandardSequence', customSequence: 'CustomSequence' } } }; - }(e))), this._configMap.set(on, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.FRIEND, '.').concat(U.CMD.GET_BLACKLIST) }), body: { fromAccount: '', startIndex: 0, maxLimited: 30, lastSequence: 0 }, keyMap: { response: { CurruentSequence: 'currentSequence' } } }; - }(e))), this._configMap.set(an, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.FRIEND, '.').concat(U.CMD.ADD_BLACKLIST) }), body: { fromAccount: '', toAccount: [] } }; - }(e))), this._configMap.set(sn, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.FRIEND, '.').concat(U.CMD.DELETE_BLACKLIST) }), body: { fromAccount: '', toAccount: [] } }; - }(e))), this._configMap.set(fn, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.GROUP, '.').concat(U.CMD.GET_JOINED_GROUPS) }), body: { memberAccount: '', limit: void 0, offset: void 0, groupType: void 0, responseFilter: { groupBaseInfoFilter: void 0, selfInfoFilter: void 0 } }, keyMap: { request: { memberAccount: 'Member_Account' }, response: { GroupIdList: 'groups', MsgFlag: 'messageRemindType' } } }; - }(e))), this._configMap.set(mn, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.GROUP, '.').concat(U.CMD.GET_GROUP_INFO) }), body: { groupIDList: void 0, responseFilter: { groupBaseInfoFilter: ['Type', 'Name', 'Introduction', 'Notification', 'FaceUrl', 'Owner_Account', 'CreateTime', 'InfoSeq', 'LastInfoTime', 'LastMsgTime', 'MemberNum', 'MaxMemberNum', 'ApplyJoinOption', 'NextMsgSeq', 'ShutUpAllMember'], groupCustomFieldFilter: void 0, memberInfoFilter: void 0, memberCustomFieldFilter: void 0 } }, keyMap: { request: { groupIDList: 'GroupIdList', groupCustomField: 'AppDefinedData', memberCustomField: 'AppMemberDefinedData', groupCustomFieldFilter: 'AppDefinedDataFilter_Group', memberCustomFieldFilter: 'AppDefinedDataFilter_GroupMember' }, response: { GroupIdList: 'groups', MsgFlag: 'messageRemindType', AppDefinedData: 'groupCustomField', AppMemberDefinedData: 'memberCustomField', AppDefinedDataFilter_Group: 'groupCustomFieldFilter', AppDefinedDataFilter_GroupMember: 'memberCustomFieldFilter', InfoSeq: 'infoSequence', MemberList: 'members', GroupInfo: 'groups', ShutUpUntil: 'muteUntil', ShutUpAllMember: 'muteAllMembers', ApplyJoinOption: 'joinOption' } } }; - }(e))), this._configMap.set(Mn, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.GROUP, '.').concat(U.CMD.CREATE_GROUP) }), body: { type: void 0, name: void 0, groupID: void 0, ownerID: void 0, introduction: void 0, notification: void 0, maxMemberNum: void 0, joinOption: void 0, memberList: void 0, groupCustomField: void 0, memberCustomField: void 0, webPushFlag: 1, avatar: 'FaceUrl' }, keyMap: { request: { ownerID: 'Owner_Account', userID: 'Member_Account', avatar: 'FaceUrl', maxMemberNum: 'MaxMemberCount', joinOption: 'ApplyJoinOption', groupCustomField: 'AppDefinedData', memberCustomField: 'AppMemberDefinedData' }, response: { HugeGroupFlag: 'avChatRoomFlag', OverJoinedGroupLimit_Account: 'overLimitUserIDList' } } }; - }(e))), this._configMap.set(vn, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.GROUP, '.').concat(U.CMD.DESTROY_GROUP) }), body: { groupID: void 0 } }; - }(e))), this._configMap.set(yn, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.GROUP, '.').concat(U.CMD.MODIFY_GROUP_INFO) }), body: { groupID: void 0, name: void 0, introduction: void 0, notification: void 0, avatar: void 0, maxMemberNum: void 0, joinOption: void 0, groupCustomField: void 0, muteAllMembers: void 0 }, keyMap: { request: { maxMemberNum: 'MaxMemberCount', groupCustomField: 'AppDefinedData', muteAllMembers: 'ShutUpAllMember', joinOption: 'ApplyJoinOption', avatar: 'FaceUrl' }, response: { AppDefinedData: 'groupCustomField', ShutUpAllMember: 'muteAllMembers', ApplyJoinOption: 'joinOption' } } }; - }(e))), this._configMap.set(In, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.GROUP, '.').concat(U.CMD.APPLY_JOIN_GROUP) }), body: { groupID: void 0, applyMessage: void 0, userDefinedField: void 0, webPushFlag: 1 }, keyMap: { response: { HugeGroupFlag: 'avChatRoomFlag' } } }; - }(e))), this._configMap.set(Dn, (function (e) { - e.a2, e.tinyid;return { head: t(t({}, p(e, wi)), {}, { servcmd: ''.concat(U.NAME.BIG_GROUP_NO_AUTH, '.').concat(U.CMD.APPLY_JOIN_GROUP) }), body: { groupID: void 0, applyMessage: void 0, userDefinedField: void 0, webPushFlag: 1 }, keyMap: { response: { HugeGroupFlag: 'avChatRoomFlag' } } }; - }(e))), this._configMap.set(Tn, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.GROUP, '.').concat(U.CMD.QUIT_GROUP) }), body: { groupID: void 0 } }; - }(e))), this._configMap.set(Sn, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.GROUP, '.').concat(U.CMD.SEARCH_GROUP_BY_ID) }), body: { groupIDList: void 0, responseFilter: { groupBasePublicInfoFilter: ['Type', 'Name', 'Introduction', 'Notification', 'FaceUrl', 'CreateTime', 'Owner_Account', 'LastInfoTime', 'LastMsgTime', 'NextMsgSeq', 'MemberNum', 'MaxMemberNum', 'ApplyJoinOption'] } }, keyMap: { response: { ApplyJoinOption: 'joinOption' } } }; - }(e))), this._configMap.set(En, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.GROUP, '.').concat(U.CMD.CHANGE_GROUP_OWNER) }), body: { groupID: void 0, newOwnerID: void 0 }, keyMap: { request: { newOwnerID: 'NewOwner_Account' } } }; - }(e))), this._configMap.set(kn, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.GROUP, '.').concat(U.CMD.HANDLE_APPLY_JOIN_GROUP) }), body: { groupID: void 0, applicant: void 0, handleAction: void 0, handleMessage: void 0, authentication: void 0, messageKey: void 0, userDefinedField: void 0 }, keyMap: { request: { applicant: 'Applicant_Account', handleAction: 'HandleMsg', handleMessage: 'ApprovalMsg', messageKey: 'MsgKey' } } }; - }(e))), this._configMap.set(Cn, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.GROUP, '.').concat(U.CMD.HANDLE_GROUP_INVITATION) }), body: { groupID: void 0, inviter: void 0, handleAction: void 0, handleMessage: void 0, authentication: void 0, messageKey: void 0, userDefinedField: void 0 }, keyMap: { request: { inviter: 'Inviter_Account', handleAction: 'HandleMsg', handleMessage: 'ApprovalMsg', messageKey: 'MsgKey' } } }; - }(e))), this._configMap.set(Ln, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.GROUP, '.').concat(U.CMD.GET_GROUP_APPLICATION) }), body: { startTime: void 0, limit: void 0, handleAccount: void 0 }, keyMap: { request: { handleAccount: 'Handle_Account' } } }; - }(e))), this._configMap.set(Rn, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.OPEN_IM, '.').concat(U.CMD.DELETE_GROUP_SYSTEM_MESSAGE) }), body: { messageListToDelete: void 0 }, keyMap: { request: { messageListToDelete: 'DelMsgList', messageSeq: 'MsgSeq', messageRandom: 'MsgRandom' } } }; - }(e))), this._configMap.set(Gn, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.BIG_GROUP_LONG_POLLING, '.').concat(U.CMD.AVCHATROOM_LONG_POLL) }), body: { USP: 1, startSeq: 1, holdTime: 90, key: void 0 }, keyMap: { request: { USP: 'USP' }, response: { ToGroupId: 'groupID' } } }; - }(e))), this._configMap.set(wn, (function (e) { - e.a2, e.tinyid;return { head: t(t({}, p(e, Pi)), {}, { servcmd: ''.concat(U.NAME.BIG_GROUP_LONG_POLLING_NO_AUTH, '.').concat(U.CMD.AVCHATROOM_LONG_POLL) }), body: { USP: 1, startSeq: 1, holdTime: 90, key: void 0 }, keyMap: { request: { USP: 'USP' }, response: { ToGroupId: 'groupID' } } }; - }(e))), this._configMap.set(Pn, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.GROUP, '.').concat(U.CMD.GET_ONLINE_MEMBER_NUM) }), body: { groupID: void 0 } }; - }(e))), this._configMap.set(Un, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.GROUP, '.').concat(U.CMD.GET_GROUP_MEMBER_LIST) }), body: { groupID: void 0, limit: 0, offset: 0, memberRoleFilter: void 0, memberInfoFilter: ['Role', 'NameCard', 'ShutUpUntil', 'JoinTime'], memberCustomFieldFilter: void 0 }, keyMap: { request: { memberCustomFieldFilter: 'AppDefinedDataFilter_GroupMember' }, response: { AppMemberDefinedData: 'memberCustomField', AppDefinedDataFilter_GroupMember: 'memberCustomFieldFilter', MemberList: 'members' } } }; - }(e))), this._configMap.set(Fn, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.GROUP, '.').concat(U.CMD.GET_GROUP_MEMBER_INFO) }), body: { groupID: void 0, userIDList: void 0, memberInfoFilter: void 0, memberCustomFieldFilter: void 0 }, keyMap: { request: { userIDList: 'Member_List_Account', memberCustomFieldFilter: 'AppDefinedDataFilter_GroupMember' }, response: { MemberList: 'members', ShutUpUntil: 'muteUntil', AppDefinedDataFilter_GroupMember: 'memberCustomFieldFilter', AppMemberDefinedData: 'memberCustomField' } } }; - }(e))), this._configMap.set(qn, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.GROUP, '.').concat(U.CMD.ADD_GROUP_MEMBER) }), body: { groupID: void 0, silence: void 0, userIDList: void 0 }, keyMap: { request: { userID: 'Member_Account', userIDList: 'MemberList' }, response: { MemberList: 'members' } } }; - }(e))), this._configMap.set(Vn, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.GROUP, '.').concat(U.CMD.DELETE_GROUP_MEMBER) }), body: { groupID: void 0, userIDList: void 0, reason: void 0 }, keyMap: { request: { userIDList: 'MemberToDel_Account' } } }; - }(e))), this._configMap.set(Kn, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.GROUP, '.').concat(U.CMD.MODIFY_GROUP_MEMBER_INFO) }), body: { groupID: void 0, userID: void 0, messageRemindType: void 0, nameCard: void 0, role: void 0, memberCustomField: void 0, muteTime: void 0 }, keyMap: { request: { userID: 'Member_Account', memberCustomField: 'AppMemberDefinedData', muteTime: 'ShutUpTime', messageRemindType: 'MsgFlag' } } }; - }(e))), this._configMap.set(Hn, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.IM_OPEN_STAT, '.').concat(U.CMD.TIM_WEB_REPORT_V2) }), body: { header: {}, event: [], quality: [] }, keyMap: { request: { SDKType: 'sdk_type', SDKVersion: 'sdk_version', deviceType: 'device_type', platform: 'platform', instanceID: 'instance_id', traceID: 'trace_id', SDKAppID: 'sdk_app_id', userID: 'user_id', tinyID: 'tiny_id', extension: 'extension', timestamp: 'timestamp', networkType: 'network_type', eventType: 'event_type', code: 'error_code', message: 'error_message', moreMessage: 'more_message', duplicate: 'duplicate', costTime: 'cost_time', level: 'level', qualityType: 'quality_type', reportIndex: 'report_index', wholePeriod: 'whole_period', totalCount: 'total_count', rttCount: 'success_count_business', successRateOfRequest: 'percent_business', countLessThan1Second: 'success_count_business', percentOfCountLessThan1Second: 'percent_business', countLessThan3Second: 'success_count_platform', percentOfCountLessThan3Second: 'percent_platform', successCountOfBusiness: 'success_count_business', successRateOfBusiness: 'percent_business', successCountOfPlatform: 'success_count_platform', successRateOfPlatform: 'percent_platform', successCountOfMessageReceived: 'success_count_business', successRateOfMessageReceived: 'percent_business', avgRTT: 'average_value', avgDelay: 'average_value', avgValue: 'average_value' } } }; - }(o))), this._configMap.set(jn, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.HEARTBEAT, '.').concat(U.CMD.ALIVE) }), body: {} }; - }(e))), this._configMap.set($n, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.IM_OPEN_PUSH, '.').concat(U.CMD.MESSAGE_PUSH) }), body: {}, keyMap: { response: { C2cMsgArray: 'C2CMessageArray', GroupMsgArray: 'groupMessageArray', GroupTips: 'groupTips', C2cNotifyMsgArray: 'C2CNotifyMessageArray', ClientSeq: 'clientSequence', MsgPriority: 'priority', NoticeSeq: 'noticeSequence', MsgContent: 'content', MsgType: 'type', MsgBody: 'elements', ToGroupId: 'to', Desc: 'description', Ext: 'extension', IsSyncMsg: 'isSyncMessage', Flag: 'needSync', NeedAck: 'needAck', PendencyAdd_Account: 'userID', ProfileImNick: 'nick', PendencyType: 'applicationType' } } }; - }(e))), this._configMap.set(Yn, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.OPEN_IM, '.').concat(U.CMD.MESSAGE_PUSH_ACK) }), body: { sessionData: void 0 }, keyMap: { request: { sessionData: 'SessionData' } } }; - }(e))), this._configMap.set(zn, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.IM_OPEN_STATUS, '.').concat(U.CMD.STATUS_FORCEOFFLINE) }), body: {}, keyMap: { response: { C2cNotifyMsgArray: 'C2CNotifyMessageArray', NoticeSeq: 'noticeSequence', KickoutMsgNotify: 'kickoutMsgNotify', NewInstInfo: 'newInstanceInfo' } } }; - }(e))), this._configMap.set(Jn, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.IM_LONG_MESSAGE, '.').concat(U.CMD.DOWNLOAD_MERGER_MESSAGE) }), body: { downloadKey: '' }, keyMap: { response: { Data: 'data', Desc: 'description', Ext: 'extension', Download_Flag: 'downloadFlag', ThumbUUID: 'thumbUUID', VideoUUID: 'videoUUID' } } }; - }(e))), this._configMap.set(Wn, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.IM_LONG_MESSAGE, '.').concat(U.CMD.UPLOAD_MERGER_MESSAGE) }), body: { messageList: [] }, keyMap: { request: { fromAccount: 'From_Account', toAccount: 'To_Account', msgTimeStamp: 'MsgTimeStamp', msgSeq: 'MsgSeq', msgRandom: 'MsgRandom', msgBody: 'MsgBody', type: 'MsgType', content: 'MsgContent', data: 'Data', description: 'Desc', extension: 'Ext', sizeType: 'Type', uuid: 'UUID', url: '', imageUrl: 'URL', fileUrl: 'Url', remoteAudioUrl: 'Url', remoteVideoUrl: 'VideoUrl', thumbUUID: 'ThumbUUID', videoUUID: 'VideoUUID', videoUrl: '', downloadFlag: 'Download_Flag', from: 'From_Account', time: 'MsgTimeStamp', messageRandom: 'MsgRandom', messageSequence: 'MsgSeq', elements: 'MsgBody', clientSequence: 'ClientSeq', payload: 'MsgContent', messageList: 'MsgList', messageNumber: 'MsgNum', abstractList: 'AbstractList', messageBody: 'MsgBody' } } }; - }(e))); - } }, { key: 'has', value(e) { - return this._configMap.has(e); - } }, { key: 'get', value(e) { - return this._configMap.get(e); - } }, { key: 'update', value() { - this._fillConfigMap(); - } }, { key: 'getKeyMap', value(e) { - return this.has(e) ? this.get(e).keyMap || {} : (Ee.warn(''.concat(this._className, '.getKeyMap unknown protocolName:').concat(e)), {}); - } }, { key: 'getProtocolData', value(e) { - const t = e.protocolName; const n = e.requestData; const o = this.get(t); let a = null;if (n) { - const s = this._simpleDeepCopy(o); const r = s.body; const i = Object.create(null);for (const c in r) if (Object.prototype.hasOwnProperty.call(r, c)) { - if (i[c] = r[c], void 0 === n[c]) continue;i[c] = n[c]; - }s.body = i, a = this._getUplinkData(s); - } else a = this._getUplinkData(o);return a; - } }, { key: '_getUplinkData', value(e) { - const t = this._requestDataCleaner(e); const n = ct(t.head); const o = Di(t.body, this._getRequestKeyMap(n));return t.body = o, t; - } }, { key: '_getRequestKeyMap', value(e) { - const n = this.getKeyMap(e);return t(t({}, vi.request), n.request); - } }, { key: '_requestDataCleaner', value(e) { - const t = Array.isArray(e) ? [] : Object.create(null);for (const o in e)Object.prototype.hasOwnProperty.call(e, o) && Fe(o) && null !== e[o] && void 0 !== e[o] && ('object' !== n(e[o]) ? t[o] = e[o] : t[o] = this._requestDataCleaner.bind(this)(e[o]));return t; - } }, { key: '_simpleDeepCopy', value(e) { - for (var t, n = Object.keys(e), o = {}, a = 0, s = n.length;a < s;a++)t = n[a], Re(e[t]) ? o[t] = Array.from(e[t]) : Oe(e[t]) ? o[t] = this._simpleDeepCopy(e[t]) : o[t] = e[t];return o; - } }]), e; - }()); const Ui = [Yn]; const Fi = (function () { - function e(t) { - o(this, e), this._sessionModule = t, this._className = 'DownlinkHandler', this._eventHandlerMap = new Map, this._eventHandlerMap.set('C2CMessageArray', this._c2cMessageArrayHandler.bind(this)), this._eventHandlerMap.set('groupMessageArray', this._groupMessageArrayHandler.bind(this)), this._eventHandlerMap.set('groupTips', this._groupTipsHandler.bind(this)), this._eventHandlerMap.set('C2CNotifyMessageArray', this._C2CNotifyMessageArrayHandler.bind(this)), this._eventHandlerMap.set('profileModify', this._profileHandler.bind(this)), this._eventHandlerMap.set('friendListMod', this._relationChainHandler.bind(this)), this._keys = M(this._eventHandlerMap.keys()); - } return s(e, [{ key: '_c2cMessageArrayHandler', value(e) { - const t = this._sessionModule.getModule(Nt);if (t) { - if (e.dataList.forEach(((e) => { - if (1 === e.isSyncMessage) { - const t = e.from;e.from = e.to, e.to = t; - } - })), 1 === e.needSync) this._sessionModule.getModule(Vt).startOnlineSync();t.onNewC2CMessage({ dataList: e.dataList, isInstantMessage: !0 }); - } - } }, { key: '_groupMessageArrayHandler', value(e) { - const t = this._sessionModule.getModule(At);t && t.onNewGroupMessage({ event: e.event, dataList: e.dataList, isInstantMessage: !0 }); - } }, { key: '_groupTipsHandler', value(e) { - const t = this._sessionModule.getModule(At);if (t) { - const n = e.event; const o = e.dataList; const a = e.isInstantMessage; const s = void 0 === a || a; const r = e.isSyncingEnded;switch (n) { - case 4:case 6:t.onNewGroupTips({ event: n, dataList: o });break;case 5:o.forEach(((e) => { - Re(e.elements.revokedInfos) ? t.onGroupMessageRevoked({ dataList: o }) : Re(e.elements.groupMessageReadNotice) ? t.onGroupMessageReadNotice({ dataList: o }) : t.onNewGroupSystemNotice({ dataList: o, isInstantMessage: s, isSyncingEnded: r }); - }));break;case 12:this._sessionModule.getModule(Rt).onNewGroupAtTips({ dataList: o });break;default:Ee.log(''.concat(this._className, '._groupTipsHandler unknown event:').concat(n, ' dataList:'), o); - } - } - } }, { key: '_C2CNotifyMessageArrayHandler', value(e) { - const t = this; const n = e.dataList;if (Re(n)) { - const o = this._sessionModule.getModule(Nt);n.forEach(((e) => { - if (Le(e)) if (e.hasOwnProperty('kickoutMsgNotify')) { - const a = e.kickoutMsgNotify; const s = a.kickType; const r = a.newInstanceInfo; const i = void 0 === r ? {} : r;1 === s ? t._sessionModule.onMultipleAccountKickedOut(i) : 2 === s && t._sessionModule.onMultipleDeviceKickedOut(i); - } else e.hasOwnProperty('c2cMessageRevokedNotify') ? o && o.onC2CMessageRevoked({ dataList: n }) : e.hasOwnProperty('c2cMessageReadReceipt') ? o && o.onC2CMessageReadReceipt({ dataList: n }) : e.hasOwnProperty('c2cMessageReadNotice') && o && o.onC2CMessageReadNotice({ dataList: n }); - })); - } - } }, { key: '_profileHandler', value(e) { - this._sessionModule.getModule(Ct).onProfileModified({ dataList: e.dataList });const t = this._sessionModule.getModule(Ot);t && t.onFriendProfileModified({ dataList: e.dataList }); - } }, { key: '_relationChainHandler', value(e) { - this._sessionModule.getModule(Ct).onRelationChainModified({ dataList: e.dataList });const t = this._sessionModule.getModule(Ot);t && t.onRelationChainModified({ dataList: e.dataList }); - } }, { key: '_cloudControlConfigHandler', value(e) { - this._sessionModule.getModule(Ht).onPushedCloudControlConfig(e); - } }, { key: 'onMessage', value(e) { - const t = this; const n = e.head; const o = e.body;if (this._isPushedCloudControlConfig(n)) this._cloudControlConfigHandler(o);else { - const a = o.eventArray; const s = o.isInstantMessage; const r = o.isSyncingEnded; const i = o.needSync;if (Re(a)) for (let c = null, u = null, l = 0, d = 0, g = a.length;d < g;d++) { - l = (c = a[d]).event;const p = Object.keys(c).find((e => -1 !== t._keys.indexOf(e)));p ? (u = c[p], this._eventHandlerMap.get(p)({ event: l, dataList: u, isInstantMessage: s, isSyncingEnded: r, needSync: i })) : Ee.log(''.concat(this._className, '.onMessage unknown eventItem:').concat(c)); - } - } - } }, { key: '_isPushedCloudControlConfig', value(e) { - return e.servcmd && e.servcmd.includes(Qn); - } }]), e; - }()); const qi = (function (e) { - i(n, e);const t = f(n);function n(e) { - let a;return o(this, n), (a = t.call(this, e))._className = 'SessionModule', a._platform = a.getPlatform(), a._protocolHandler = new bi(h(a)), a._messageDispatcher = new Fi(h(a)), a; - } return s(n, [{ key: 'updateProtocolConfig', value() { - this._protocolHandler.update(); - } }, { key: 'request', value(e) { - Ee.debug(''.concat(this._className, '.request options:'), e);const t = e.protocolName; const n = e.tjgID;if (!this._protocolHandler.has(t)) return Ee.warn(''.concat(this._className, '.request unknown protocol:').concat(t)), Mr({ code: Zn.CANNOT_FIND_PROTOCOL, message: sa });const o = this.getProtocolData(e);dt(n) || (o.head.tjgID = n);const a = this.getModule(xt);return Ui.includes(t) ? a.simplySend(o) : a.send(o); - } }, { key: 'getKeyMap', value(e) { - return this._protocolHandler.getKeyMap(e); - } }, { key: 'genCommonHead', value() { - const e = this.getModule(Gt);return { ver: 'v4', platform: this._platform, websdkappid: G, websdkversion: R, a2: e.getA2Key() || void 0, tinyid: e.getTinyID() || void 0, status_instid: e.getStatusInstanceID(), sdkappid: e.getSDKAppID(), contenttype: e.getContentType(), reqtime: 0, identifier: e.getA2Key() ? void 0 : e.getUserID(), usersig: e.getA2Key() ? void 0 : e.getUserSig(), sdkability: 2, tjgID: '' }; - } }, { key: 'genCosSpecifiedHead', value() { - const e = this.getModule(Gt);return { ver: 'v4', platform: this._platform, websdkappid: G, websdkversion: R, sdkappid: e.getSDKAppID(), contenttype: e.getContentType(), reqtime: 0, identifier: e.getUserID(), usersig: e.getUserSig(), status_instid: e.getStatusInstanceID(), sdkability: 2 }; - } }, { key: 'genSSOReportHead', value() { - const e = this.getModule(Gt);return { ver: 'v4', platform: this._platform, websdkappid: G, websdkversion: R, sdkappid: e.getSDKAppID(), contenttype: '', reqtime: 0, identifier: '', usersig: '', status_instid: e.getStatusInstanceID(), sdkability: 2 }; - } }, { key: 'getProtocolData', value(e) { - return this._protocolHandler.getProtocolData(e); - } }, { key: 'onErrorCodeNotZero', value(e) { - const t = e.errorCode;if (t === Zn.HELLO_ANSWER_KICKED_OUT) { - const n = e.kickType; const o = e.newInstanceInfo; const a = void 0 === o ? {} : o;1 === n ? this.onMultipleAccountKickedOut(a) : 2 === n && this.onMultipleDeviceKickedOut(a); - }t !== Zn.MESSAGE_A2KEY_EXPIRED && t !== Zn.ACCOUNT_A2KEY_EXPIRED || (this._onUserSigExpired(), this.getModule(xt).reConnect()); - } }, { key: 'onMessage', value(e) { - const t = e.body; const n = t.needAck; const o = void 0 === n ? 0 : n; const a = t.sessionData;1 === o && this._sendACK(a), this._messageDispatcher.onMessage(e); - } }, { key: 'onReconnected', value() { - const e = this;this.isLoggedIn() && this.request({ protocolName: zt }).then(((t) => { - const n = t.data.instanceID;e.getModule(Gt).setStatusInstanceID(n), e.getModule(jt).startPull(); - })); - } }, { key: 'onMultipleAccountKickedOut', value(e) { - this.getModule(Et).onMultipleAccountKickedOut(e); - } }, { key: 'onMultipleDeviceKickedOut', value(e) { - this.getModule(Et).onMultipleDeviceKickedOut(e); - } }, { key: '_onUserSigExpired', value() { - this.getModule(Et).onUserSigExpired(); - } }, { key: '_sendACK', value(e) { - this.request({ protocolName: Yn, requestData: { sessionData: e } }); - } }]), n; - }(Yt)); const Vi = (function (e) { - i(n, e);const t = f(n);function n(e) { - let a;return o(this, n), (a = t.call(this, e))._className = 'MessageLossDetectionModule', a._maybeLostSequencesMap = new Map, a; - } return s(n, [{ key: 'onMessageMaybeLost', value(e, t, n) { - this._maybeLostSequencesMap.has(e) || this._maybeLostSequencesMap.set(e, []);for (var o = this._maybeLostSequencesMap.get(e), a = 0;a < n;a++)o.push(t + a);Ee.debug(''.concat(this._className, '.onMessageMaybeLost. maybeLostSequences:').concat(o)); - } }, { key: 'detectMessageLoss', value(e, t) { - const n = this._maybeLostSequencesMap.get(e);if (!dt(n) && !dt(t)) { - const o = t.filter((e => -1 !== n.indexOf(e)));if (Ee.debug(''.concat(this._className, '.detectMessageLoss. matchedSequences:').concat(o)), n.length === o.length)Ee.info(''.concat(this._className, '.detectMessageLoss no message loss. conversationID:').concat(e));else { - let a; const s = n.filter((e => -1 === o.indexOf(e))); const r = s.length;r <= 5 ? a = `${e}-${s.join('-')}` : (s.sort(((e, t) => e - t)), a = `${e} start:${s[0]} end:${s[r - 1]} count:${r}`), new Da(Ns).setMessage(a) - .setNetworkType(this.getNetworkType()) - .setLevel('warning') - .end(), Ee.warn(''.concat(this._className, '.detectMessageLoss message loss detected. conversationID:').concat(e, ' lostSequences:') - .concat(s)); - }n.length = 0; - } - } }, { key: 'reset', value() { - Ee.log(''.concat(this._className, '.reset')), this._maybeLostSequencesMap.clear(); - } }]), n; - }(Yt)); const Ki = (function (e) { - i(n, e);const t = f(n);function n(e) { - let a;return o(this, n), (a = t.call(this, e))._className = 'CloudControlModule', a._cloudConfig = new Map, a._expiredTime = 0, a._version = 0, a._isFetching = !1, a; - } return s(n, [{ key: 'getCloudConfig', value(e) { - return Ge(e) ? this._cloudConfig : this._cloudConfig.has(e) ? this._cloudConfig.get(e) : void 0; - } }, { key: '_canFetchConfig', value() { - return this.isLoggedIn() && !this._isFetching && Date.now() >= this._expiredTime; - } }, { key: 'fetchConfig', value() { - const e = this; const t = this._canFetchConfig();if (Ee.log(''.concat(this._className, '.fetchConfig canFetchConfig:').concat(t)), t) { - const n = new Da(bs); const o = this.getModule(Gt).getSDKAppID();this._isFetching = !0, this.request({ protocolName: Xn, requestData: { SDKAppID: o, version: this._version } }).then(((t) => { - e._isFetching = !1, n.setMessage('version:'.concat(e._version, ' newVersion:').concat(t.data.version, ' config:') - .concat(t.data.cloudControlConfig)).setNetworkType(e.getNetworkType()) - .end(), Ee.log(''.concat(e._className, '.fetchConfig ok')), e._parseCloudControlConfig(t.data); - })) - .catch(((t) => { - e._isFetching = !1, e.probeNetwork().then(((e) => { - const o = m(e, 2); const a = o[0]; const s = o[1];n.setError(t, a, s).end(); - })), Ee.log(''.concat(e._className, '.fetchConfig failed. error:'), t), e._setExpiredTimeOnResponseError(12e4); - })); - } - } }, { key: 'onPushedCloudControlConfig', value(e) { - Ee.log(''.concat(this._className, '.onPushedCloudControlConfig')), new Da(Us).setNetworkType(this.getNetworkType()) - .setMessage('newVersion:'.concat(e.version, ' config:').concat(e.cloudControlConfig)) - .end(), this._parseCloudControlConfig(e); - } }, { key: 'onCheckTimer', value(e) { - this._canFetchConfig() && this.fetchConfig(); - } }, { key: '_parseCloudControlConfig', value(e) { - const t = this; const n = ''.concat(this._className, '._parseCloudControlConfig'); const o = e.errorCode; const a = e.errorMessage; const s = e.cloudControlConfig; const r = e.version; const i = e.expiredTime;if (0 === o) { - if (this._version !== r) { - let c = null;try { - c = JSON.parse(s); - } catch (u) { - Ee.error(''.concat(n, ' JSON parse error:').concat(s)); - }c && (this._cloudConfig.clear(), Object.keys(c).forEach(((e) => { - t._cloudConfig.set(e, c[e]); - })), this._version = r, this.emitInnerEvent(Ir.CLOUD_CONFIG_UPDATED)); - } this._expiredTime = Date.now() + 1e3 * i; - } else Ge(o) ? (Ee.log(''.concat(n, ' failed. Invalid message format:'), e), this._setExpiredTimeOnResponseError(36e5)) : (Ee.error(''.concat(n, ' errorCode:').concat(o, ' errorMessage:') - .concat(a)), this._setExpiredTimeOnResponseError(12e4)); - } }, { key: '_setExpiredTimeOnResponseError', value(e) { - this._expiredTime = Date.now() + e; - } }, { key: 'reset', value() { - Ee.log(''.concat(this._className, '.reset')), this._cloudConfig.clear(), this._expiredTime = 0, this._version = 0, this._isFetching = !1; - } }]), n; - }(Yt)); const xi = (function (e) { - i(n, e);const t = f(n);function n(e) { - let a;return o(this, n), (a = t.call(this, e))._className = 'PullGroupMessageModule', a._remoteLastMessageSequenceMap = new Map, a.PULL_LIMIT_COUNT = 15, a; - } return s(n, [{ key: 'startPull', value() { - const e = this; const t = this._getNeedPullConversationList();this._getRemoteLastMessageSequenceList().then((() => { - const n = e.getModule(Rt);t.forEach(((t) => { - const o = t.conversationID; const a = o.replace(k.CONV_GROUP, ''); const s = n.getGroupLocalLastMessageSequence(o); const r = e._remoteLastMessageSequenceMap.get(a) || 0; const i = r - s;Ee.log(''.concat(e._className, '.startPull groupID:').concat(a, ' localLastMessageSequence:') - .concat(s, ' ') + 'remoteLastMessageSequence:'.concat(r, ' diff:').concat(i)), s > 0 && i > 1 && i < 300 && e._pullMissingMessage({ groupID: a, localLastMessageSequence: s, remoteLastMessageSequence: r, diff: i }); - })); - })); - } }, { key: '_getNeedPullConversationList', value() { - return this.getModule(Rt).getLocalConversationList() - .filter((e => e.type === k.CONV_GROUP && e.groupProfile.type !== k.GRP_AVCHATROOM)); - } }, { key: '_getRemoteLastMessageSequenceList', value() { - const e = this;return this.getModule(At).getGroupList() - .then(((t) => { - for (let n = t.data.groupList, o = void 0 === n ? [] : n, a = 0;a < o.length;a++) { - const s = o[a]; const r = s.groupID; const i = s.nextMessageSeq;if (s.type !== k.GRP_AVCHATROOM) { - const c = i - 1;e._remoteLastMessageSequenceMap.set(r, c); - } - } - })); - } }, { key: '_pullMissingMessage', value(e) { - const t = this; const n = e.localLastMessageSequence; const o = e.remoteLastMessageSequence; const a = e.diff;e.count = a > this.PULL_LIMIT_COUNT ? this.PULL_LIMIT_COUNT : a, e.sequence = a > this.PULL_LIMIT_COUNT ? n + this.PULL_LIMIT_COUNT : n + a, this._getGroupMissingMessage(e).then(((s) => { - s.length > 0 && (s[0].sequence + 1 <= o && (e.localLastMessageSequence = n + t.PULL_LIMIT_COUNT, e.diff = a - t.PULL_LIMIT_COUNT, t._pullMissingMessage(e)), t.getModule(At).onNewGroupMessage({ dataList: s, isInstantMessage: !1 })); - })); - } }, { key: '_getGroupMissingMessage', value(e) { - const t = this; const n = new Da(hs);return this.request({ protocolName: On, requestData: { groupID: e.groupID, count: e.count, sequence: e.sequence } }).then(((o) => { - const a = o.data.messageList; const s = void 0 === a ? [] : a;return n.setNetworkType(t.getNetworkType()).setMessage('groupID:'.concat(e.groupID, ' count:').concat(e.count, ' sequence:') - .concat(e.sequence, ' messageList length:') - .concat(s.length)) - .end(), s; - })) - .catch(((e) => { - t.probeNetwork().then(((t) => { - const o = m(t, 2); const a = o[0]; const s = o[1];n.setError(e, a, s).end(); - })); - })); - } }, { key: 'reset', value() { - Ee.log(''.concat(this._className, '.reset')), this._remoteLastMessageSequenceMap.clear(); - } }]), n; - }(Yt)); const Bi = (function () { - function e() { - o(this, e), this._className = 'AvgE2EDelay', this._e2eDelayArray = []; - } return s(e, [{ key: 'addMessageDelay', value(e) { - const t = ut(e.currentTime / 1e3 - e.time, 2);this._e2eDelayArray.push(t); - } }, { key: '_calcAvg', value(e, t) { - if (0 === t) return 0;let n = 0;return e.forEach(((e) => { - n += e; - })), ut(n / t, 1); - } }, { key: '_calcTotalCount', value() { - return this._e2eDelayArray.length; - } }, { key: '_calcCountWithLimit', value(e) { - const t = e.e2eDelayArray; const n = e.min; const o = e.max;return t.filter((e => n < e && e <= o)).length; - } }, { key: '_calcPercent', value(e, t) { - let n = ut(e / t * 100, 2);return n > 100 && (n = 100), n; - } }, { key: '_checkE2EDelayException', value(e, t) { - const n = e.filter((e => e > t));if (n.length > 0) { - const o = n.length; const a = Math.min.apply(Math, M(n)); const s = Math.max.apply(Math, M(n)); const r = this._calcAvg(n, o); const i = ut(o / e.length * 100, 2);new Da(za).setMessage('message e2e delay exception. count:'.concat(o, ' min:').concat(a, ' max:') - .concat(s, ' avg:') - .concat(r, ' percent:') - .concat(i)) - .setLevel('warning') - .end(); - } - } }, { key: 'getStatResult', value() { - const e = this._calcTotalCount();if (0 === e) return null;const t = M(this._e2eDelayArray); const n = this._calcCountWithLimit({ e2eDelayArray: t, min: 0, max: 1 }); const o = this._calcCountWithLimit({ e2eDelayArray: t, min: 1, max: 3 }); const a = this._calcPercent(n, e); const s = this._calcPercent(o, e); const r = this._calcAvg(t, e);return this._checkE2EDelayException(t, 3), this.reset(), { totalCount: e, countLessThan1Second: n, percentOfCountLessThan1Second: a, countLessThan3Second: o, percentOfCountLessThan3Second: s, avgDelay: r }; - } }, { key: 'reset', value() { - this._e2eDelayArray.length = 0; - } }]), e; - }()); const Hi = (function () { - function e() { - o(this, e), this._className = 'AvgRTT', this._requestCount = 0, this._rttArray = []; - } return s(e, [{ key: 'addRequestCount', value() { - this._requestCount += 1; - } }, { key: 'addRTT', value(e) { - this._rttArray.push(e); - } }, { key: '_calcTotalCount', value() { - return this._requestCount; - } }, { key: '_calcRTTCount', value(e) { - return e.length; - } }, { key: '_calcSuccessRateOfRequest', value(e, t) { - if (0 === t) return 0;let n = ut(e / t * 100, 2);return n > 100 && (n = 100), n; - } }, { key: '_calcAvg', value(e, t) { - if (0 === t) return 0;let n = 0;return e.forEach(((e) => { - n += e; - })), parseInt(n / t); - } }, { key: '_calcMax', value() { - return Math.max.apply(Math, M(this._rttArray)); - } }, { key: '_calcMin', value() { - return Math.min.apply(Math, M(this._rttArray)); - } }, { key: 'getStatResult', value() { - const e = this._calcTotalCount(); const t = M(this._rttArray);if (0 === e) return null;const n = this._calcRTTCount(t); const o = this._calcSuccessRateOfRequest(n, e); const a = this._calcAvg(t, n);return Ee.log(''.concat(this._className, '.getStatResult max:').concat(this._calcMax(), ' min:') - .concat(this._calcMin(), ' avg:') - .concat(a)), this.reset(), { totalCount: e, rttCount: n, successRateOfRequest: o, avgRTT: a }; - } }, { key: 'reset', value() { - this._requestCount = 0, this._rttArray.length = 0; - } }]), e; - }()); const ji = (function () { - function e(t) { - const n = this;o(this, e), this._map = new Map, t.forEach(((e) => { - n._map.set(e, { totalCount: 0, successCount: 0, failedCountOfUserSide: 0, costArray: [], fileSizeArray: [] }); - })); - } return s(e, [{ key: 'addTotalCount', value(e) { - return !(Ge(e) || !this._map.has(e)) && (this._map.get(e).totalCount += 1, !0); - } }, { key: 'addSuccessCount', value(e) { - return !(Ge(e) || !this._map.has(e)) && (this._map.get(e).successCount += 1, !0); - } }, { key: 'addFailedCountOfUserSide', value(e) { - return !(Ge(e) || !this._map.has(e)) && (this._map.get(e).failedCountOfUserSide += 1, !0); - } }, { key: 'addCost', value(e, t) { - return !(Ge(e) || !this._map.has(e)) && (this._map.get(e).costArray.push(t), !0); - } }, { key: 'addFileSize', value(e, t) { - return !(Ge(e) || !this._map.has(e)) && (this._map.get(e).fileSizeArray.push(t), !0); - } }, { key: '_calcSuccessRateOfBusiness', value(e) { - if (Ge(e) || !this._map.has(e)) return -1;const t = this._map.get(e); let n = ut(t.successCount / t.totalCount * 100, 2);return n > 100 && (n = 100), n; - } }, { key: '_calcSuccessRateOfPlatform', value(e) { - if (Ge(e) || !this._map.has(e)) return -1;const t = this._map.get(e); let n = this._calcSuccessCountOfPlatform(e) / t.totalCount * 100;return (n = ut(n, 2)) > 100 && (n = 100), n; - } }, { key: '_calcTotalCount', value(e) { - return Ge(e) || !this._map.has(e) ? -1 : this._map.get(e).totalCount; - } }, { key: '_calcSuccessCountOfBusiness', value(e) { - return Ge(e) || !this._map.has(e) ? -1 : this._map.get(e).successCount; - } }, { key: '_calcSuccessCountOfPlatform', value(e) { - if (Ge(e) || !this._map.has(e)) return -1;const t = this._map.get(e);return t.successCount + t.failedCountOfUserSide; - } }, { key: '_calcAvg', value(e) { - return Ge(e) || !this._map.has(e) ? -1 : e === _a ? this._calcAvgSpeed(e) : this._calcAvgCost(e); - } }, { key: '_calcAvgCost', value(e) { - const t = this._map.get(e).costArray.length;if (0 === t) return 0;let n = 0;return this._map.get(e).costArray.forEach(((e) => { - n += e; - })), parseInt(n / t); - } }, { key: '_calcAvgSpeed', value(e) { - let t = 0; let n = 0;return this._map.get(e).costArray.forEach(((e) => { - t += e; - })), this._map.get(e).fileSizeArray.forEach(((e) => { - n += e; - })), parseInt(1e3 * n / t); - } }, { key: 'getStatResult', value(e) { - const t = this._calcTotalCount(e);if (0 === t) return null;const n = this._calcSuccessCountOfBusiness(e); const o = this._calcSuccessRateOfBusiness(e); const a = this._calcSuccessCountOfPlatform(e); const s = this._calcSuccessRateOfPlatform(e); const r = this._calcAvg(e);return this.reset(e), { totalCount: t, successCountOfBusiness: n, successRateOfBusiness: o, successCountOfPlatform: a, successRateOfPlatform: s, avgValue: r }; - } }, { key: 'reset', value(e) { - Ge(e) ? this._map.clear() : this._map.set(e, { totalCount: 0, successCount: 0, failedCountOfUserSide: 0, costArray: [], fileSizeArray: [] }); - } }]), e; - }()); const $i = (function () { - function e(t) { - const n = this;o(this, e), this._lastMap = new Map, this._currentMap = new Map, t.forEach(((e) => { - n._lastMap.set(e, new Map), n._currentMap.set(e, new Map); - })); - } return s(e, [{ key: 'addMessageSequence', value(e) { - const t = e.key; const n = e.message;if (Ge(t) || !this._lastMap.has(t) || !this._currentMap.has(t)) return !1;const o = n.conversationID; const a = n.sequence; const s = o.replace(k.CONV_GROUP, '');if (0 === this._lastMap.get(t).size) this._addCurrentMap(e);else if (this._lastMap.get(t).has(s)) { - const r = this._lastMap.get(t).get(s); const i = r.length - 1;a > r[0] && a < r[i] ? (r.push(a), r.sort(), this._lastMap.get(t).set(s, r)) : this._addCurrentMap(e); - } else this._addCurrentMap(e);return !0; - } }, { key: '_addCurrentMap', value(e) { - const t = e.key; const n = e.message; const o = n.conversationID; const a = n.sequence; const s = o.replace(k.CONV_GROUP, '');this._currentMap.get(t).has(s) || this._currentMap.get(t).set(s, []), this._currentMap.get(t).get(s) - .push(a); - } }, { key: '_copyData', value(e) { - if (!Ge(e)) { - this._lastMap.set(e, new Map);let t; let n = this._lastMap.get(e); const o = S(this._currentMap.get(e));try { - for (o.s();!(t = o.n()).done;) { - const a = m(t.value, 2); const s = a[0]; const r = a[1];n.set(s, r); - } - } catch (i) { - o.e(i); - } finally { - o.f(); - }n = null, this._currentMap.set(e, new Map); - } - } }, { key: 'getStatResult', value(e) { - if (Ge(this._currentMap.get(e)) || Ge(this._lastMap.get(e))) return null;if (0 === this._lastMap.get(e).size) return this._copyData(e), null;let t = 0; let n = 0;if (this._lastMap.get(e).forEach(((e, o) => { - const a = M(e.values()); const s = a.length; const r = a[s - 1] - a[0] + 1;t += r, n += s; - })), 0 === t) return null;let o = ut(n / t * 100, 2);return o > 100 && (o = 100), this._copyData(e), { totalCount: t, successCountOfMessageReceived: n, successRateOfMessageReceived: o }; - } }, { key: 'reset', value() { - this._currentMap.clear(), this._lastMap.clear(); - } }]), e; - }()); const Yi = (function (e) { - i(a, e);const n = f(a);function a(e) { - let t;o(this, a), (t = n.call(this, e))._className = 'QualityStatModule', t.TAG = 'im-ssolog-quality-stat', t.reportIndex = 0, t.wholePeriod = !1, t._qualityItems = [ua, la, da, ga, pa, ha, _a, fa, ma, Ma], t.REPORT_INTERVAL = 120, t._statInfoArr = [], t._avgRTT = new Hi, t._avgE2EDelay = new Bi;const s = [da, ga, pa, ha, _a];t._rateMessageSend = new ji(s);const r = [fa, ma, Ma];t._rateMessageReceived = new $i(r);const i = t.getInnerEmitterInstance();return i.on(Ir.CONTEXT_A2KEY_AND_TINYID_UPDATED, t._onLoginSuccess, h(t)), i.on(Ir.CLOUD_CONFIG_UPDATED, t._onCloudConfigUpdate, h(t)), t; - } return s(a, [{ key: '_onLoginSuccess', value() { - const e = this; const t = this.getModule(wt); const n = t.getItem(this.TAG, !1);!dt(n) && Pe(n.forEach) && (Ee.log(''.concat(this._className, '._onLoginSuccess.get quality stat log in storage, nums=').concat(n.length)), n.forEach(((t) => { - e._statInfoArr.push(t); - })), t.removeItem(this.TAG, !1)); - } }, { key: '_onCloudConfigUpdate', value() { - const e = this.getCloudConfig('report_interval_quality');Ge(e) || (this.REPORT_INTERVAL = Number(e)); - } }, { key: 'onCheckTimer', value(e) { - this.isLoggedIn() && e % this.REPORT_INTERVAL == 0 && (this.wholePeriod = !0, this._report()); - } }, { key: 'addRequestCount', value() { - this._avgRTT.addRequestCount(); - } }, { key: 'addRTT', value(e) { - this._avgRTT.addRTT(e); - } }, { key: 'addMessageDelay', value(e) { - this._avgE2EDelay.addMessageDelay(e); - } }, { key: 'addTotalCount', value(e) { - this._rateMessageSend.addTotalCount(e) || Ee.warn(''.concat(this._className, '.addTotalCount invalid key:'), e); - } }, { key: 'addSuccessCount', value(e) { - this._rateMessageSend.addSuccessCount(e) || Ee.warn(''.concat(this._className, '.addSuccessCount invalid key:'), e); - } }, { key: 'addFailedCountOfUserSide', value(e) { - this._rateMessageSend.addFailedCountOfUserSide(e) || Ee.warn(''.concat(this._className, '.addFailedCountOfUserSide invalid key:'), e); - } }, { key: 'addCost', value(e, t) { - this._rateMessageSend.addCost(e, t) || Ee.warn(''.concat(this._className, '.addCost invalid key or cost:'), e, t); - } }, { key: 'addFileSize', value(e, t) { - this._rateMessageSend.addFileSize(e, t) || Ee.warn(''.concat(this._className, '.addFileSize invalid key or size:'), e, t); - } }, { key: 'addMessageSequence', value(e) { - this._rateMessageReceived.addMessageSequence(e) || Ee.warn(''.concat(this._className, '.addMessageSequence invalid key:'), e.key); - } }, { key: '_getQualityItem', value(e) { - let n = {}; let o = Ia[this.getNetworkType()];Ge(o) && (o = 8);const a = { qualityType: va[e], timestamp: ye(), networkType: o, extension: '' };switch (e) { - case ua:n = this._avgRTT.getStatResult();break;case la:n = this._avgE2EDelay.getStatResult();break;case da:case ga:case pa:case ha:case _a:n = this._rateMessageSend.getStatResult(e);break;case fa:case ma:case Ma:n = this._rateMessageReceived.getStatResult(e); - } return null === n ? null : t(t({}, a), n); - } }, { key: '_report', value(e) { - const t = this; let n = []; let o = null;Ge(e) ? this._qualityItems.forEach(((e) => { - null !== (o = t._getQualityItem(e)) && (o.reportIndex = t.reportIndex, o.wholePeriod = t.wholePeriod, n.push(o)); - })) : null !== (o = this._getQualityItem(e)) && (o.reportIndex = this.reportIndex, o.wholePeriod = this.wholePeriod, n.push(o)), Ee.debug(''.concat(this._className, '._report'), n), this._statInfoArr.length > 0 && (n = n.concat(this._statInfoArr), this._statInfoArr = []), n.length > 0 && this._doReport(n); - } }, { key: '_doReport', value(e) { - const n = this; const o = { header: ai(this), quality: e };this.request({ protocolName: Hn, requestData: t({}, o) }).then((() => { - n.reportIndex++, n.wholePeriod = !1; - })) - .catch(((t) => { - Ee.warn(''.concat(n._className, '._doReport, online:').concat(n.getNetworkType(), ' error:'), t), n._statInfoArr = n._statInfoArr.concat(e), n._flushAtOnce(); - })); - } }, { key: '_flushAtOnce', value() { - const e = this.getModule(wt); const t = e.getItem(this.TAG, !1); const n = this._statInfoArr;if (dt(t))Ee.log(''.concat(this._className, '._flushAtOnce count:').concat(n.length)), e.setItem(this.TAG, n, !0, !1);else { - let o = n.concat(t);o.length > 10 && (o = o.slice(0, 10)), Ee.log(''.concat(this.className, '._flushAtOnce count:').concat(o.length)), e.setItem(this.TAG, o, !0, !1); - } this._statInfoArr = []; - } }, { key: 'reset', value() { - Ee.log(''.concat(this._className, '.reset')), this._report(), this.reportIndex = 0, this.wholePeriod = !1, this._avgRTT.reset(), this._avgE2EDelay.reset(), this._rateMessageSend.reset(), this._rateMessageReceived.reset(); - } }]), a; - }(Yt)); const zi = (function () { - function e(t) { - o(this, e);const n = new Da(Ta);this._className = 'ModuleManager', this._isReady = !1, this._startLoginTs = 0, this._moduleMap = new Map, this._innerEmitter = null, this._outerEmitter = null, this._checkCount = 0, this._checkTimer = -1, this._moduleMap.set(Gt, new Zr(this, t)), this._moduleMap.set(Ht, new Ki(this)), this._moduleMap.set($t, new Yi(this)), this._moduleMap.set(xt, new Gi(this)), this._moduleMap.set(Kt, new qi(this)), this._moduleMap.set(Et, new ei(this)), this._moduleMap.set(kt, new fi(this)), this._moduleMap.set(Ct, new Qr(this)), this._moduleMap.set(Nt, new vr(this)), this._moduleMap.set(Rt, new Ur(this)), this._moduleMap.set(At, new $r(this)), this._moduleMap.set(Lt, new zr(this)), this._moduleMap.set(wt, new ni(this)), this._moduleMap.set(Pt, new si(this)), this._moduleMap.set(bt, new ci(this)), this._moduleMap.set(Ut, new li(this)), this._moduleMap.set(Ft, new di(this)), this._moduleMap.set(qt, new mi(this)), this._moduleMap.set(Vt, new Mi(this)), this._moduleMap.set(Bt, new Vi(this)), this._moduleMap.set(jt, new xi(this));const a = t.instanceID; const s = t.oversea; const r = t.SDKAppID; const i = 'instanceID:'.concat(a, ' oversea:').concat(s, ' host:') - .concat(st(), ' ') + 'inBrowser:'.concat(W, ' inMiniApp:').concat(z, ' SDKAppID:') - .concat(r, ' UserAgent:') - .concat(Q);Da.bindEventStatModule(this._moduleMap.get(Pt)), n.setMessage(''.concat(i)).end(), Ee.info('SDK '.concat(i)), this._readyList = void 0, this._ssoLogForReady = null, this._initReadyList(); - } return s(e, [{ key: '_startTimer', value() { - this._checkTimer < 0 && (this._checkTimer = setInterval(this._onCheckTimer.bind(this), 1e3)); - } }, { key: 'stopTimer', value() { - this._checkTimer > 0 && (clearInterval(this._checkTimer), this._checkTimer = -1, this._checkCount = 0); - } }, { key: '_onCheckTimer', value() { - this._checkCount += 1;let e; const t = S(this._moduleMap);try { - for (t.s();!(e = t.n()).done;) { - const n = m(e.value, 2)[1];n.onCheckTimer && n.onCheckTimer(this._checkCount); - } - } catch (o) { - t.e(o); - } finally { - t.f(); - } - } }, { key: '_initReadyList', value() { - const e = this;this._readyList = [this._moduleMap.get(Et), this._moduleMap.get(Rt)], this._readyList.forEach(((t) => { - t.ready((() => e._onModuleReady())); - })); - } }, { key: '_onModuleReady', value() { - let e = !0;if (this._readyList.forEach(((t) => { - t.isReady() || (e = !1); - })), e && !this._isReady) { - this._isReady = !0, this._outerEmitter.emit(E.SDK_READY);const t = Date.now() - this._startLoginTs;Ee.warn('SDK is ready. cost '.concat(t, ' ms')), this._startLoginTs = Date.now();const n = this._moduleMap.get(bt).getNetworkType(); const o = this._ssoLogForReady.getStartTs() + ve;this._ssoLogForReady.setNetworkType(n).setMessage(t) - .start(o) - .end(); - } - } }, { key: 'login', value() { - 0 === this._startLoginTs && (Ie(), this._startLoginTs = Date.now(), this._startTimer(), this._moduleMap.get(bt).start(), this._ssoLogForReady = new Da(Sa)); - } }, { key: 'onLoginFailed', value() { - this._startLoginTs = 0; - } }, { key: 'getOuterEmitterInstance', value() { - return null === this._outerEmitter && (this._outerEmitter = new ui, fr(this._outerEmitter), this._outerEmitter._emit = this._outerEmitter.emit, this._outerEmitter.emit = function (e, t) { - const n = arguments[0]; const o = [n, { name: arguments[0], data: arguments[1] }];this._outerEmitter._emit.apply(this._outerEmitter, o); - }.bind(this)), this._outerEmitter; - } }, { key: 'getInnerEmitterInstance', value() { - return null === this._innerEmitter && (this._innerEmitter = new ui, this._innerEmitter._emit = this._innerEmitter.emit, this._innerEmitter.emit = function (e, t) { - let n;Le(arguments[1]) && arguments[1].data ? (Ee.warn('inner eventData has data property, please check!'), n = [e, { name: arguments[0], data: arguments[1].data }]) : n = [e, { name: arguments[0], data: arguments[1] }], this._innerEmitter._emit.apply(this._innerEmitter, n); - }.bind(this)), this._innerEmitter; - } }, { key: 'hasModule', value(e) { - return this._moduleMap.has(e); - } }, { key: 'getModule', value(e) { - return this._moduleMap.get(e); - } }, { key: 'isReady', value() { - return this._isReady; - } }, { key: 'onError', value(e) { - Ee.warn('Oops! code:'.concat(e.code, ' message:').concat(e.message)), new Da(Fs).setMessage('code:'.concat(e.code, ' message:').concat(e.message)) - .setNetworkType(this.getModule(bt).getNetworkType()) - .setLevel('error') - .end(), this.getOuterEmitterInstance().emit(E.ERROR, e); - } }, { key: 'reset', value() { - Ee.log(''.concat(this._className, '.reset')), Ie();let e; const t = S(this._moduleMap);try { - for (t.s();!(e = t.n()).done;) { - const n = m(e.value, 2)[1];n.reset && n.reset(); - } - } catch (o) { - t.e(o); - } finally { - t.f(); - } this._startLoginTs = 0, this._initReadyList(), this._isReady = !1, this.stopTimer(), this._outerEmitter.emit(E.SDK_NOT_READY); - } }]), e; - }()); const Wi = (function () { - function e() { - o(this, e), this._funcMap = new Map; - } return s(e, [{ key: 'defense', value(e, t) { - const n = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : void 0;if ('string' !== typeof e) return null;if (0 === e.length) return null;if ('function' !== typeof t) return null;if (this._funcMap.has(e) && this._funcMap.get(e).has(t)) return this._funcMap.get(e).get(t);this._funcMap.has(e) || this._funcMap.set(e, new Map);let o = null;return this._funcMap.get(e).has(t) ? o = this._funcMap.get(e).get(t) : (o = this._pack(e, t, n), this._funcMap.get(e).set(t, o)), o; - } }, { key: 'defenseOnce', value(e, t) { - const n = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : void 0;return 'function' !== typeof t ? null : this._pack(e, t, n); - } }, { key: 'find', value(e, t) { - return 'string' !== typeof e || 0 === e.length || 'function' !== typeof t ? null : this._funcMap.has(e) ? this._funcMap.get(e).has(t) ? this._funcMap.get(e).get(t) : (Ee.log('SafetyCallback.find: 找不到 func —— '.concat(e, '/').concat('' !== t.name ? t.name : '[anonymous]')), null) : (Ee.log('SafetyCallback.find: 找不到 eventName-'.concat(e, ' 对应的 func')), null); - } }, { key: 'delete', value(e, t) { - return 'function' === typeof t && (!!this._funcMap.has(e) && (!!this._funcMap.get(e).has(t) && (this._funcMap.get(e).delete(t), 0 === this._funcMap.get(e).size && this._funcMap.delete(e), !0))); - } }, { key: '_pack', value(e, t, n) { - return function () { - try { - t.apply(n, Array.from(arguments)); - } catch (r) { - const o = Object.values(E).indexOf(e);if (-1 !== o) { - const a = Object.keys(E)[o];Ee.warn('接入侧事件 TIM.EVENT.'.concat(a, ' 对应的回调函数逻辑存在问题,请检查!'), r); - } const s = new Da(Ps);s.setMessage('eventName:'.concat(e)).setMoreMessage(r.message) - .end(); - } - }; - } }]), e; - }()); const Ji = (function () { - function e(t) { - o(this, e);const n = { SDKAppID: t.SDKAppID, unlimitedAVChatRoom: t.unlimitedAVChatRoom || !1, scene: t.scene || '', oversea: t.oversea || !1, instanceID: at() };this._moduleManager = new zi(n), this._safetyCallbackFactory = new Wi; - } return s(e, [{ key: 'isReady', value() { - return this._moduleManager.isReady(); - } }, { key: 'onError', value(e) { - this._moduleManager.onError(e); - } }, { key: 'login', value(e) { - return this._moduleManager.login(), this._moduleManager.getModule(Et).login(e); - } }, { key: 'logout', value() { - const e = this;return this._moduleManager.getModule(Et).logout() - .then((t => (e._moduleManager.reset(), t))); - } }, { key: 'destroy', value() { - const e = this;return this.logout().finally((() => { - e._moduleManager.stopTimer(), e._moduleManager.getModule(xt).dealloc();const t = e._moduleManager.getOuterEmitterInstance(); const n = e._moduleManager.getModule(Gt);t.emit(E.SDK_DESTROY, { SDKAppID: n.getSDKAppID() }); - })); - } }, { key: 'on', value(e, t, n) { - e === E.GROUP_SYSTEM_NOTICE_RECEIVED && Ee.warn('!!!TIM.EVENT.GROUP_SYSTEM_NOTICE_RECEIVED v2.6.0起弃用,为了更好的体验,请在 TIM.EVENT.MESSAGE_RECEIVED 事件回调内接收处理群系统通知,详细请参考:https://web.sdk.qcloud.com/im/doc/zh-cn/Message.html#.GroupSystemNoticePayload'), Ee.debug('on', 'eventName:'.concat(e)), this._moduleManager.getOuterEmitterInstance().on(e, this._safetyCallbackFactory.defense(e, t, n), n); - } }, { key: 'once', value(e, t, n) { - Ee.debug('once', 'eventName:'.concat(e)), this._moduleManager.getOuterEmitterInstance().once(e, this._safetyCallbackFactory.defenseOnce(e, t, n), n || this); - } }, { key: 'off', value(e, t, n, o) { - Ee.debug('off', 'eventName:'.concat(e));const a = this._safetyCallbackFactory.find(e, t);null !== a && (this._moduleManager.getOuterEmitterInstance().off(e, a, n, o), this._safetyCallbackFactory.delete(e, t)); - } }, { key: 'registerPlugin', value(e) { - this._moduleManager.getModule(qt).registerPlugin(e); - } }, { key: 'setLogLevel', value(e) { - if (e <= 0) { - console.log(['', ' ________ ______ __ __ __ __ ________ _______', '| \\| \\| \\ / \\| \\ _ | \\| \\| \\', ' \\$$$$$$$$ \\$$$$$$| $$\\ / $$| $$ / \\ | $$| $$$$$$$$| $$$$$$$\\', ' | $$ | $$ | $$$\\ / $$$| $$/ $\\| $$| $$__ | $$__/ $$', ' | $$ | $$ | $$$$\\ $$$$| $$ $$$\\ $$| $$ \\ | $$ $$', ' | $$ | $$ | $$\\$$ $$ $$| $$ $$\\$$\\$$| $$$$$ | $$$$$$$\\', ' | $$ _| $$_ | $$ \\$$$| $$| $$$$ \\$$$$| $$_____ | $$__/ $$', ' | $$ | $$ \\| $$ \\$ | $$| $$$ \\$$$| $$ \\| $$ $$', ' \\$$ \\$$$$$$ \\$$ \\$$ \\$$ \\$$ \\$$$$$$$$ \\$$$$$$$', '', ''].join('\n')), console.log('%cIM 智能客服,随时随地解决您的问题 →_→ https://cloud.tencent.com/act/event/smarty-service?from=im-doc', 'color:#006eff'), console.log('%c从v2.11.2起,SDK 支持了 WebSocket,小程序需要添加受信域名!升级指引: https://web.sdk.qcloud.com/im/doc/zh-cn/tutorial-02-upgradeguideline.html', 'color:#ff0000');console.log(['', '参考以下文档,会更快解决问题哦!(#^.^#)\n', 'SDK 更新日志: https://cloud.tencent.com/document/product/269/38492\n', 'SDK 接口文档: https://web.sdk.qcloud.com/im/doc/zh-cn/SDK.html\n', '常见问题: https://web.sdk.qcloud.com/im/doc/zh-cn/tutorial-01-faq.html\n', '反馈问题?戳我提 issue: https://github.com/tencentyun/TIMSDK/issues\n', '如果您需要在生产环境关闭上面的日志,请 tim.setLogLevel(1)\n'].join('\n')); - }Ee.setLevel(e); - } }, { key: 'createTextMessage', value(e) { - return this._moduleManager.getModule(kt).createTextMessage(e); - } }, { key: 'createTextAtMessage', value(e) { - return this._moduleManager.getModule(kt).createTextMessage(e); - } }, { key: 'createImageMessage', value(e) { - return this._moduleManager.getModule(kt).createImageMessage(e); - } }, { key: 'createAudioMessage', value(e) { - return this._moduleManager.getModule(kt).createAudioMessage(e); - } }, { key: 'createVideoMessage', value(e) { - return this._moduleManager.getModule(kt).createVideoMessage(e); - } }, { key: 'createCustomMessage', value(e) { - return this._moduleManager.getModule(kt).createCustomMessage(e); - } }, { key: 'createFaceMessage', value(e) { - return this._moduleManager.getModule(kt).createFaceMessage(e); - } }, { key: 'createFileMessage', value(e) { - return this._moduleManager.getModule(kt).createFileMessage(e); - } }, { key: 'createMergerMessage', value(e) { - return this._moduleManager.getModule(kt).createMergerMessage(e); - } }, { key: 'downloadMergerMessage', value(e) { - return e.type !== k.MSG_MERGER ? Mr(new hr({ code: Zn.MESSAGE_MERGER_TYPE_INVALID, message: No })) : dt(e.payload.downloadKey) ? Mr(new hr({ code: Zn.MESSAGE_MERGER_KEY_INVALID, message: Ao })) : this._moduleManager.getModule(kt).downloadMergerMessage(e) - .catch((e => Mr(new hr({ code: Zn.MESSAGE_MERGER_DOWNLOAD_FAIL, message: Oo })))); - } }, { key: 'createForwardMessage', value(e) { - return this._moduleManager.getModule(kt).createForwardMessage(e); - } }, { key: 'sendMessage', value(e, t) { - return e instanceof ir ? this._moduleManager.getModule(kt).sendMessageInstance(e, t) : Mr(new hr({ code: Zn.MESSAGE_SEND_NEED_MESSAGE_INSTANCE, message: uo })); - } }, { key: 'callExperimentalAPI', value(e, t) { - return 'handleGroupInvitation' === e ? this._moduleManager.getModule(At).handleGroupInvitation(t) : Mr(new hr({ code: Zn.INVALID_OPERATION, message: aa })); - } }, { key: 'revokeMessage', value(e) { - return this._moduleManager.getModule(kt).revokeMessage(e); - } }, { key: 'resendMessage', value(e) { - return this._moduleManager.getModule(kt).resendMessage(e); - } }, { key: 'deleteMessage', value(e) { - return this._moduleManager.getModule(kt).deleteMessage(e); - } }, { key: 'getMessageList', value(e) { - return this._moduleManager.getModule(Rt).getMessageList(e); - } }, { key: 'setMessageRead', value(e) { - return this._moduleManager.getModule(Rt).setMessageRead(e); - } }, { key: 'getConversationList', value() { - return this._moduleManager.getModule(Rt).getConversationList(); - } }, { key: 'getConversationProfile', value(e) { - return this._moduleManager.getModule(Rt).getConversationProfile(e); - } }, { key: 'deleteConversation', value(e) { - return this._moduleManager.getModule(Rt).deleteConversation(e); - } }, { key: 'getMyProfile', value() { - return this._moduleManager.getModule(Ct).getMyProfile(); - } }, { key: 'getUserProfile', value(e) { - return this._moduleManager.getModule(Ct).getUserProfile(e); - } }, { key: 'updateMyProfile', value(e) { - return this._moduleManager.getModule(Ct).updateMyProfile(e); - } }, { key: 'getBlacklist', value() { - return this._moduleManager.getModule(Ct).getLocalBlacklist(); - } }, { key: 'addToBlacklist', value(e) { - return this._moduleManager.getModule(Ct).addBlacklist(e); - } }, { key: 'removeFromBlacklist', value(e) { - return this._moduleManager.getModule(Ct).deleteBlacklist(e); - } }, { key: 'getFriendList', value() { - const e = this._moduleManager.getModule(Ot);return e ? e.getLocalFriendList() : Mr({ code: Zn.CANNOT_FIND_MODULE, message: ra }); - } }, { key: 'addFriend', value(e) { - const t = this._moduleManager.getModule(Ot);return t ? t.addFriend(e) : Mr({ code: Zn.CANNOT_FIND_MODULE, message: ra }); - } }, { key: 'deleteFriend', value(e) { - const t = this._moduleManager.getModule(Ot);return t ? t.deleteFriend(e) : Mr({ code: Zn.CANNOT_FIND_MODULE, message: ra }); - } }, { key: 'checkFriend', value(e) { - const t = this._moduleManager.getModule(Ot);return t ? t.checkFriend(e) : Mr({ code: Zn.CANNOT_FIND_MODULE, message: ra }); - } }, { key: 'getFriendProfile', value(e) { - const t = this._moduleManager.getModule(Ot);return t ? t.getFriendProfile(e) : Mr({ code: Zn.CANNOT_FIND_MODULE, message: ra }); - } }, { key: 'updateFriend', value(e) { - const t = this._moduleManager.getModule(Ot);return t ? t.updateFriend(e) : Mr({ code: Zn.CANNOT_FIND_MODULE, message: ra }); - } }, { key: 'getFriendApplicationList', value() { - const e = this._moduleManager.getModule(Ot);return e ? e.getLocalFriendApplicationList() : Mr({ code: Zn.CANNOT_FIND_MODULE, message: ra }); - } }, { key: 'acceptFriendApplication', value(e) { - const t = this._moduleManager.getModule(Ot);return t ? t.acceptFriendApplication(e) : Mr({ code: Zn.CANNOT_FIND_MODULE, message: ra }); - } }, { key: 'refuseFriendApplication', value(e) { - const t = this._moduleManager.getModule(Ot);return t ? t.refuseFriendApplication(e) : Mr({ code: Zn.CANNOT_FIND_MODULE, message: ra }); - } }, { key: 'deleteFriendApplication', value(e) { - const t = this._moduleManager.getModule(Ot);return t ? t.deleteFriendApplication(e) : Mr({ code: Zn.CANNOT_FIND_MODULE, message: ra }); - } }, { key: 'setFriendApplicationRead', value() { - const e = this._moduleManager.getModule(Ot);return e ? e.setFriendApplicationRead() : Mr({ code: Zn.CANNOT_FIND_MODULE, message: ra }); - } }, { key: 'getFriendGroupList', value() { - const e = this._moduleManager.getModule(Ot);return e ? e.getLocalFriendGroupList() : Mr({ code: Zn.CANNOT_FIND_MODULE, message: ra }); - } }, { key: 'createFriendGroup', value(e) { - const t = this._moduleManager.getModule(Ot);return t ? t.createFriendGroup(e) : Mr({ code: Zn.CANNOT_FIND_MODULE, message: ra }); - } }, { key: 'deleteFriendGroup', value(e) { - const t = this._moduleManager.getModule(Ot);return t ? t.deleteFriendGroup(e) : Mr({ code: Zn.CANNOT_FIND_MODULE, message: ra }); - } }, { key: 'addToFriendGroup', value(e) { - const t = this._moduleManager.getModule(Ot);return t ? t.addToFriendGroup(e) : Mr({ code: Zn.CANNOT_FIND_MODULE, message: ra }); - } }, { key: 'removeFromFriendGroup', value(e) { - const t = this._moduleManager.getModule(Ot);return t ? t.removeFromFriendGroup(e) : Mr({ code: Zn.CANNOT_FIND_MODULE, message: ra }); - } }, { key: 'renameFriendGroup', value(e) { - const t = this._moduleManager.getModule(Ot);return t ? t.renameFriendGroup(e) : Mr({ code: Zn.CANNOT_FIND_MODULE, message: ra }); - } }, { key: 'getGroupList', value(e) { - return this._moduleManager.getModule(At).getGroupList(e); - } }, { key: 'getGroupProfile', value(e) { - return this._moduleManager.getModule(At).getGroupProfile(e); - } }, { key: 'createGroup', value(e) { - return this._moduleManager.getModule(At).createGroup(e); - } }, { key: 'dismissGroup', value(e) { - return this._moduleManager.getModule(At).dismissGroup(e); - } }, { key: 'updateGroupProfile', value(e) { - return this._moduleManager.getModule(At).updateGroupProfile(e); - } }, { key: 'joinGroup', value(e) { - return this._moduleManager.getModule(At).joinGroup(e); - } }, { key: 'quitGroup', value(e) { - return this._moduleManager.getModule(At).quitGroup(e); - } }, { key: 'searchGroupByID', value(e) { - return this._moduleManager.getModule(At).searchGroupByID(e); - } }, { key: 'getGroupOnlineMemberCount', value(e) { - return this._moduleManager.getModule(At).getGroupOnlineMemberCount(e); - } }, { key: 'changeGroupOwner', value(e) { - return this._moduleManager.getModule(At).changeGroupOwner(e); - } }, { key: 'handleGroupApplication', value(e) { - return this._moduleManager.getModule(At).handleGroupApplication(e); - } }, { key: 'getGroupMemberList', value(e) { - return this._moduleManager.getModule(Lt).getGroupMemberList(e); - } }, { key: 'getGroupMemberProfile', value(e) { - return this._moduleManager.getModule(Lt).getGroupMemberProfile(e); - } }, { key: 'addGroupMember', value(e) { - return this._moduleManager.getModule(Lt).addGroupMember(e); - } }, { key: 'deleteGroupMember', value(e) { - return this._moduleManager.getModule(Lt).deleteGroupMember(e); - } }, { key: 'setGroupMemberMuteTime', value(e) { - return this._moduleManager.getModule(Lt).setGroupMemberMuteTime(e); - } }, { key: 'setGroupMemberRole', value(e) { - return this._moduleManager.getModule(Lt).setGroupMemberRole(e); - } }, { key: 'setGroupMemberNameCard', value(e) { - return this._moduleManager.getModule(Lt).setGroupMemberNameCard(e); - } }, { key: 'setGroupMemberCustomField', value(e) { - return this._moduleManager.getModule(Lt).setGroupMemberCustomField(e); - } }, { key: 'setMessageRemindType', value(e) { - return this._moduleManager.getModule(Lt).setMessageRemindType(e); - } }]), e; - }()); const Xi = { login: 'login', logout: 'logout', destroy: 'destroy', on: 'on', off: 'off', ready: 'ready', setLogLevel: 'setLogLevel', joinGroup: 'joinGroup', quitGroup: 'quitGroup', registerPlugin: 'registerPlugin', getGroupOnlineMemberCount: 'getGroupOnlineMemberCount' };function Qi(e, t) { - if (e.isReady() || void 0 !== Xi[t]) return !0;const n = new hr({ code: Zn.SDK_IS_NOT_READY, message: ''.concat(t, ' ').concat(ia, ',请参考 https://web.sdk.qcloud.com/im/doc/zh-cn/module-EVENT.html#.SDK_READY') });return e.onError(n), !1; - } const Zi = {}; const ec = {};return ec.create = function (e) { - let n = 0;if (Ne(e.SDKAppID))n = e.SDKAppID;else if (Ee.warn('TIM.create SDKAppID 的类型应该为 Number,请修改!'), n = parseInt(e.SDKAppID), isNaN(n)) return Ee.error('TIM.create failed. 解析 SDKAppID 失败,请检查传参!'), null;if (n && Zi[n]) return Zi[n];Ee.log('TIM.create');const o = new Ji(t(t({}, e), {}, { SDKAppID: n }));o.on(E.SDK_DESTROY, ((e) => { - Zi[e.data.SDKAppID] = null, delete Zi[e.data.SDKAppID]; - }));const a = (function (e) { - const t = Object.create(null);return Object.keys(St).forEach(((n) => { - if (e[n]) { - const o = St[n]; const a = new C;t[o] = function () { - const t = Array.from(arguments);return a.use(((t, o) => (Qi(e, n) ? o() : Mr(new hr({ code: Zn.SDK_IS_NOT_READY, message: ''.concat(n, ' ').concat(ia, '。') }))))).use(((e, t) => { - if (!0 === gt(e, Tt[n], o)) return t(); - })) - .use(((t, o) => e[n].apply(e, t))), a.run(t); - }; - } - })), t; - }(o));return Zi[n] = a, Ee.log('TIM.create ok'), a; - }, ec.TYPES = k, ec.EVENT = E, ec.VERSION = '2.12.2', Ee.log('TIM.VERSION: '.concat(ec.VERSION)), ec; -}))); +'use strict';!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).TIM=t()}(this,(function(){function e(e,t){var o=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),o.push.apply(o,n)}return o}function t(t){for(var o=1;o=0||(a[o]=e[o]);return a}(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,o)&&(a[o]=e[o])}return a}function _(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function h(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return _(e)}function f(e){var t=l();return function(){var o,n=c(e);if(t){var a=c(this).constructor;o=Reflect.construct(n,arguments,a)}else o=n.apply(this,arguments);return h(this,o)}}function m(e,t){return v(e)||function(e,t){var o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==o)return;var n,a,s=[],r=!0,i=!1;try{for(o=o.call(e);!(r=(n=o.next()).done)&&(s.push(n.value),!t||s.length!==t);r=!0);}catch(c){i=!0,a=c}finally{try{r||null==o.return||o.return()}finally{if(i)throw a}}return s}(e,t)||I(e,t)||T()}function M(e){return function(e){if(Array.isArray(e))return E(e)}(e)||y(e)||I(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function v(e){if(Array.isArray(e))return e}function y(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function I(e,t){if(e){if("string"==typeof e)return E(e,t);var o=Object.prototype.toString.call(e).slice(8,-1);return"Object"===o&&e.constructor&&(o=e.constructor.name),"Map"===o||"Set"===o?Array.from(e):"Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)?E(e,t):void 0}}function E(e,t){(null==t||t>e.length)&&(t=e.length);for(var o=0,n=new Array(t);o=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,r=!0,i=!1;return{s:function(){o=o.call(e)},n:function(){var e=o.next();return r=e.done,e},e:function(e){i=!0,s=e},f:function(){try{r||null==o.return||o.return()}finally{if(i)throw s}}}}var S={SDK_READY:"sdkStateReady",SDK_NOT_READY:"sdkStateNotReady",SDK_DESTROY:"sdkDestroy",MESSAGE_RECEIVED:"onMessageReceived",MESSAGE_MODIFIED:"onMessageModified",MESSAGE_REVOKED:"onMessageRevoked",MESSAGE_READ_BY_PEER:"onMessageReadByPeer",MESSAGE_READ_RECEIPT_RECEIVED:"onMessageReadReceiptReceived",CONVERSATION_LIST_UPDATED:"onConversationListUpdated",GROUP_LIST_UPDATED:"onGroupListUpdated",GROUP_SYSTEM_NOTICE_RECEIVED:"receiveGroupSystemNotice",GROUP_ATTRIBUTES_UPDATED:"groupAttributesUpdated",TOPIC_CREATED:"onTopicCreated",TOPIC_DELETED:"onTopicDeleted",TOPIC_UPDATED:"onTopicUpdated",PROFILE_UPDATED:"onProfileUpdated",BLACKLIST_UPDATED:"blacklistUpdated",FRIEND_LIST_UPDATED:"onFriendListUpdated",FRIEND_GROUP_LIST_UPDATED:"onFriendGroupListUpdated",FRIEND_APPLICATION_LIST_UPDATED:"onFriendApplicationListUpdated",KICKED_OUT:"kickedOut",ERROR:"error",NET_STATE_CHANGE:"netStateChange",SDK_RELOAD:"sdkReload"},D={MSG_TEXT:"TIMTextElem",MSG_IMAGE:"TIMImageElem",MSG_SOUND:"TIMSoundElem",MSG_AUDIO:"TIMSoundElem",MSG_FILE:"TIMFileElem",MSG_FACE:"TIMFaceElem",MSG_VIDEO:"TIMVideoFileElem",MSG_GEO:"TIMLocationElem",MSG_LOCATION:"TIMLocationElem",MSG_GRP_TIP:"TIMGroupTipElem",MSG_GRP_SYS_NOTICE:"TIMGroupSystemNoticeElem",MSG_CUSTOM:"TIMCustomElem",MSG_MERGER:"TIMRelayElem",MSG_PRIORITY_HIGH:"High",MSG_PRIORITY_NORMAL:"Normal",MSG_PRIORITY_LOW:"Low",MSG_PRIORITY_LOWEST:"Lowest",CONV_C2C:"C2C",CONV_GROUP:"GROUP",CONV_TOPIC:"TOPIC",CONV_SYSTEM:"@TIM#SYSTEM",CONV_AT_ME:1,CONV_AT_ALL:2,CONV_AT_ALL_AT_ME:3,GRP_PRIVATE:"Private",GRP_WORK:"Private",GRP_PUBLIC:"Public",GRP_CHATROOM:"ChatRoom",GRP_MEETING:"ChatRoom",GRP_AVCHATROOM:"AVChatRoom",GRP_COMMUNITY:"Community",GRP_MBR_ROLE_OWNER:"Owner",GRP_MBR_ROLE_ADMIN:"Admin",GRP_MBR_ROLE_MEMBER:"Member",GRP_MBR_ROLE_CUSTOM:"Custom",GRP_TIP_MBR_JOIN:1,GRP_TIP_MBR_QUIT:2,GRP_TIP_MBR_KICKED_OUT:3,GRP_TIP_MBR_SET_ADMIN:4,GRP_TIP_MBR_CANCELED_ADMIN:5,GRP_TIP_GRP_PROFILE_UPDATED:6,GRP_TIP_MBR_PROFILE_UPDATED:7,MSG_REMIND_ACPT_AND_NOTE:"AcceptAndNotify",MSG_REMIND_ACPT_NOT_NOTE:"AcceptNotNotify",MSG_REMIND_DISCARD:"Discard",GENDER_UNKNOWN:"Gender_Type_Unknown",GENDER_FEMALE:"Gender_Type_Female",GENDER_MALE:"Gender_Type_Male",KICKED_OUT_MULT_ACCOUNT:"multipleAccount",KICKED_OUT_MULT_DEVICE:"multipleDevice",KICKED_OUT_USERSIG_EXPIRED:"userSigExpired",KICKED_OUT_REST_API:"REST_API_Kick",ALLOW_TYPE_ALLOW_ANY:"AllowType_Type_AllowAny",ALLOW_TYPE_NEED_CONFIRM:"AllowType_Type_NeedConfirm",ALLOW_TYPE_DENY_ANY:"AllowType_Type_DenyAny",FORBID_TYPE_NONE:"AdminForbid_Type_None",FORBID_TYPE_SEND_OUT:"AdminForbid_Type_SendOut",JOIN_OPTIONS_FREE_ACCESS:"FreeAccess",JOIN_OPTIONS_NEED_PERMISSION:"NeedPermission",JOIN_OPTIONS_DISABLE_APPLY:"DisableApply",JOIN_STATUS_SUCCESS:"JoinedSuccess",JOIN_STATUS_ALREADY_IN_GROUP:"AlreadyInGroup",JOIN_STATUS_WAIT_APPROVAL:"WaitAdminApproval",GRP_PROFILE_OWNER_ID:"ownerID",GRP_PROFILE_CREATE_TIME:"createTime",GRP_PROFILE_LAST_INFO_TIME:"lastInfoTime",GRP_PROFILE_MEMBER_NUM:"memberNum",GRP_PROFILE_MAX_MEMBER_NUM:"maxMemberNum",GRP_PROFILE_JOIN_OPTION:"joinOption",GRP_PROFILE_INTRODUCTION:"introduction",GRP_PROFILE_NOTIFICATION:"notification",GRP_PROFILE_MUTE_ALL_MBRS:"muteAllMembers",SNS_ADD_TYPE_SINGLE:"Add_Type_Single",SNS_ADD_TYPE_BOTH:"Add_Type_Both",SNS_DELETE_TYPE_SINGLE:"Delete_Type_Single",SNS_DELETE_TYPE_BOTH:"Delete_Type_Both",SNS_APPLICATION_TYPE_BOTH:"Pendency_Type_Both",SNS_APPLICATION_SENT_TO_ME:"Pendency_Type_ComeIn",SNS_APPLICATION_SENT_BY_ME:"Pendency_Type_SendOut",SNS_APPLICATION_AGREE:"Response_Action_Agree",SNS_APPLICATION_AGREE_AND_ADD:"Response_Action_AgreeAndAdd",SNS_CHECK_TYPE_BOTH:"CheckResult_Type_Both",SNS_CHECK_TYPE_SINGLE:"CheckResult_Type_Single",SNS_TYPE_NO_RELATION:"CheckResult_Type_NoRelation",SNS_TYPE_A_WITH_B:"CheckResult_Type_AWithB",SNS_TYPE_B_WITH_A:"CheckResult_Type_BWithA",SNS_TYPE_BOTH_WAY:"CheckResult_Type_BothWay",NET_STATE_CONNECTED:"connected",NET_STATE_CONNECTING:"connecting",NET_STATE_DISCONNECTED:"disconnected",MSG_AT_ALL:"__kImSDK_MesssageAtALL__",READ_ALL_C2C_MSG:"readAllC2CMessage",READ_ALL_GROUP_MSG:"readAllGroupMessage",READ_ALL_MSG:"readAllMessage"},N=function(){function e(){n(this,e),this.cache=[],this.options=null}return s(e,[{key:"use",value:function(e){if("function"!=typeof e)throw"middleware must be a function";return this.cache.push(e),this}},{key:"next",value:function(e){if(this.middlewares&&this.middlewares.length>0)return this.middlewares.shift().call(this,this.options,this.next.bind(this))}},{key:"run",value:function(e){return this.middlewares=this.cache.map((function(e){return e})),this.options=e,this.next()}}]),e}(),A="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function O(e,t){return e(t={exports:{}},t.exports),t.exports}var R=O((function(e,t){var o,n,a,s,r,i,c,u,l,d,p,g,_,h,f,m,M,v;e.exports=(o="function"==typeof Promise,n="object"==typeof self?self:A,a="undefined"!=typeof Symbol,s="undefined"!=typeof Map,r="undefined"!=typeof Set,i="undefined"!=typeof WeakMap,c="undefined"!=typeof WeakSet,u="undefined"!=typeof DataView,l=a&&void 0!==Symbol.iterator,d=a&&void 0!==Symbol.toStringTag,p=r&&"function"==typeof Set.prototype.entries,g=s&&"function"==typeof Map.prototype.entries,_=p&&Object.getPrototypeOf((new Set).entries()),h=g&&Object.getPrototypeOf((new Map).entries()),f=l&&"function"==typeof Array.prototype[Symbol.iterator],m=f&&Object.getPrototypeOf([][Symbol.iterator]()),M=l&&"function"==typeof String.prototype[Symbol.iterator],v=M&&Object.getPrototypeOf(""[Symbol.iterator]()),function(e){var t=typeof e;if("object"!==t)return t;if(null===e)return"null";if(e===n)return"global";if(Array.isArray(e)&&(!1===d||!(Symbol.toStringTag in e)))return"Array";if("object"==typeof window&&null!==window){if("object"==typeof window.location&&e===window.location)return"Location";if("object"==typeof window.document&&e===window.document)return"Document";if("object"==typeof window.navigator){if("object"==typeof window.navigator.mimeTypes&&e===window.navigator.mimeTypes)return"MimeTypeArray";if("object"==typeof window.navigator.plugins&&e===window.navigator.plugins)return"PluginArray"}if(("function"==typeof window.HTMLElement||"object"==typeof window.HTMLElement)&&e instanceof window.HTMLElement){if("BLOCKQUOTE"===e.tagName)return"HTMLQuoteElement";if("TD"===e.tagName)return"HTMLTableDataCellElement";if("TH"===e.tagName)return"HTMLTableHeaderCellElement"}}var a=d&&e[Symbol.toStringTag];if("string"==typeof a)return a;var l=Object.getPrototypeOf(e);return l===RegExp.prototype?"RegExp":l===Date.prototype?"Date":o&&l===Promise.prototype?"Promise":r&&l===Set.prototype?"Set":s&&l===Map.prototype?"Map":c&&l===WeakSet.prototype?"WeakSet":i&&l===WeakMap.prototype?"WeakMap":u&&l===DataView.prototype?"DataView":s&&l===h?"Map Iterator":r&&l===_?"Set Iterator":f&&l===m?"Array Iterator":M&&l===v?"String Iterator":null===l?"Object":Object.prototype.toString.call(e).slice(8,-1)})})),L=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;n(this,e),this.high=t,this.low=o}return s(e,[{key:"equal",value:function(e){return null!==e&&(this.low===e.low&&this.high===e.high)}},{key:"toString",value:function(){var e=Number(this.high).toString(16),t=Number(this.low).toString(16);if(t.length<8)for(var o=8-t.length;o;)t="0"+t,o--;return e+t}}]),e}(),k={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"}},PRODUCTION:{CHINA:{DEFAULT:"wss://wss.im.qcloud.com",BACKUP:"wss://wss.tim.qq.com",STAT:"https://api.im.qcloud.com"},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"},KOREA:{DEFAULT:"wss://wsskr.im.qcloud.com",BACKUP:"wss://wsskr.my-imcloud.com",STAT:"https://apikr.my-imcloud.com"},GERMANY:{DEFAULT:"wss://wssger.im.qcloud.com",BACKUP:"wss://wssger.my-imcloud.com",STAT:"https://apiger.my-imcloud.com"},IND:{DEFAULT:"wss://wssind.im.qcloud.com",BACKUP:"wss://wssind.my-imcloud.com",STAT:"https://apiind.my-imcloud.com"}}},G={WEB:7,WX_MP:8,QQ_MP:9,TT_MP:10,BAIDU_MP:11,ALI_MP:12,UNI_NATIVE_APP:15},P="1.7.3",U=537048168,w="CHINA",b="OVERSEA",F="SINGAPORE",q="KOREA",V="GERMANY",K="IND",H={HOST:{CURRENT:{DEFAULT:"wss://wss.im.qcloud.com",STAT:"https://api.im.qcloud.com"},setCurrent:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:w;this.CURRENT=k.PRODUCTION[e]}},NAME:{OPEN_IM:"openim",GROUP:"group_open_http_svc",GROUP_COMMUNITY:"million_group_open_http_svc",GROUP_ATTR:"group_open_attr_http_svc",FRIEND:"sns",PROFILE:"profile",RECENT_CONTACT:"recentcontact",PIC:"openpic",BIG_GROUP_NO_AUTH:"group_open_http_noauth_svc",BIG_GROUP_LONG_POLLING:"group_open_long_polling_http_svc",BIG_GROUP_LONG_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_MESSAGE:"im_long_msg",IM_CONFIG_MANAGER:"im_sdk_config_mgr",STAT_SERVICE:"StatSvc",OVERLOAD_PUSH:"OverLoadPush"},CMD:{ACCESS_LAYER:"accesslayer",LOGIN:"wslogin",LOGOUT_LONG_POLL:"longpollinglogout",LOGOUT:"wslogout",HELLO:"wshello",PORTRAIT_GET:"portrait_get_all",PORTRAIT_SET:"portrait_set",GET_LONG_POLL_ID:"getlongpollingid",LONG_POLL:"longpolling",AVCHATROOM_LONG_POLL:"get_msg",ADD_FRIEND:"friend_add",UPDATE_FRIEND:"friend_update",GET_FRIEND_LIST:"friend_get",GET_FRIEND_PROFILE:"friend_get_list",DELETE_FRIEND:"friend_delete",CHECK_FRIEND:"friend_check",GET_FRIEND_GROUP_LIST:"group_get",RESPOND_FRIEND_APPLICATION:"friend_response",GET_FRIEND_APPLICATION_LIST:"pendency_get",DELETE_FRIEND_APPLICATION:"pendency_delete",REPORT_FRIEND_APPLICATION:"pendency_report",GET_GROUP_APPLICATION:"get_pendency",CREATE_FRIEND_GROUP:"group_add",DELETE_FRIEND_GROUP:"group_delete",UPDATE_FRIEND_GROUP:"group_update",GET_BLACKLIST:"black_list_get",ADD_BLACKLIST:"black_list_add",DELETE_BLACKLIST:"black_list_delete",CREATE_GROUP:"create_group",GET_JOINED_GROUPS:"get_joined_group_list",SET_GROUP_ATTRIBUTES:"set_group_attr",MODIFY_GROUP_ATTRIBUTES:"modify_group_attr",DELETE_GROUP_ATTRIBUTES:"delete_group_attr",CLEAR_GROUP_ATTRIBUTES:"clear_group_attr",GET_GROUP_ATTRIBUTES:"get_group_attr",SEND_MESSAGE:"sendmsg",REVOKE_C2C_MESSAGE:"msgwithdraw",DELETE_C2C_MESSAGE:"delete_c2c_msg_ramble",MODIFY_C2C_MESSAGE:"modify_c2c_msg",SEND_GROUP_MESSAGE:"send_group_msg",REVOKE_GROUP_MESSAGE:"group_msg_recall",DELETE_GROUP_MESSAGE:"delete_group_ramble_msg_by_seq",MODIFY_GROUP_MESSAGE:"modify_group_msg",GET_GROUP_INFO:"get_group_self_member_info",GET_GROUP_MEMBER_INFO:"get_specified_group_member_info",GET_GROUP_MEMBER_LIST:"get_group_member_info",QUIT_GROUP:"quit_group",CHANGE_GROUP_OWNER:"change_group_owner",DESTROY_GROUP:"destroy_group",ADD_GROUP_MEMBER:"add_group_member",DELETE_GROUP_MEMBER:"delete_group_member",SEARCH_GROUP_BY_ID:"get_group_public_info",APPLY_JOIN_GROUP:"apply_join_group",HANDLE_APPLY_JOIN_GROUP:"handle_apply_join_group",HANDLE_GROUP_INVITATION:"handle_invite_join_group",MODIFY_GROUP_INFO:"modify_group_base_info",MODIFY_GROUP_MEMBER_INFO:"modify_group_member_info",DELETE_GROUP_SYSTEM_MESSAGE:"deletemsg",DELETE_GROUP_AT_TIPS:"deletemsg",GET_CONVERSATION_LIST:"get",PAGING_GET_CONVERSATION_LIST:"page_get",DELETE_CONVERSATION:"delete",PIN_CONVERSATION:"top",GET_MESSAGES:"getmsg",GET_C2C_ROAM_MESSAGES:"getroammsg",SET_C2C_PEER_MUTE_NOTIFICATIONS:"set_c2c_peer_mute_notifications",GET_C2C_PEER_MUTE_NOTIFICATIONS:"get_c2c_peer_mute_notifications",GET_GROUP_ROAM_MESSAGES:"group_msg_get",GET_READ_RECEIPT:"get_group_msg_receipt",GET_READ_RECEIPT_DETAIL:"get_group_msg_receipt_detail",SEND_READ_RECEIPT:"group_msg_receipt",SEND_C2C_READ_RECEIPT:"c2c_msg_read_receipt",SET_C2C_MESSAGE_READ:"msgreaded",GET_PEER_READ_TIME:"get_peer_read_time",SET_GROUP_MESSAGE_READ:"msg_read_report",FILE_READ_AND_WRITE_AUTHKEY:"authkey",FILE_UPLOAD:"pic_up",COS_SIGN:"cos",COS_PRE_SIG:"pre_sig",VIDEO_COVER:"video_cover",TIM_WEB_REPORT_V2:"tim_web_report_v2",BIG_DATA_HALLWAY_AUTH_KEY:"authkey",GET_ONLINE_MEMBER_NUM:"get_online_member_num",ALIVE:"alive",MESSAGE_PUSH:"msg_push",MULTI_MESSAGE_PUSH:"multi_msg_push_ws",MESSAGE_PUSH_ACK:"ws_msg_push_ack",STATUS_FORCE_OFFLINE:"stat_forceoffline",DOWNLOAD_MERGER_MESSAGE:"get_relay_json_msg",UPLOAD_MERGER_MESSAGE:"save_relay_json_msg",FETCH_CLOUD_CONTROL_CONFIG:"fetch_config",PUSHED_CLOUD_CONTROL_CONFIG:"push_configv2",FETCH_COMMERCIAL_CONFIG:"fetch_imsdk_purchase_bitsv2",PUSHED_COMMERCIAL_CONFIG:"push_imsdk_purchase_bitsv2",KICK_OTHER:"KickOther",OVERLOAD_NOTIFY:"notify2",SET_ALL_MESSAGE_READ:"read_all_unread_msg",CREATE_TOPIC:"create_topic",DELETE_TOPIC:"destroy_topic",UPDATE_TOPIC_PROFILE:"modify_topic",GET_TOPIC_LIST:"get_topic"},CHANNEL:{SOCKET:1,XHR:2,AUTO:0},NAME_VERSION:{openim:"v4",group_open_http_svc:"v4",sns:"v4",profile:"v4",recentcontact:"v4",openpic:"v4",group_open_http_noauth_svc:"v4",group_open_long_polling_http_svc:"v4",group_open_long_polling_http_noauth_svc:"v4",imopenstat:"v4",im_cos_sign_svr:"v4",im_cos_msg:"v4",webim:"v4",im_open_push:"v4",im_open_status:"v4"}},B={SEARCH_MSG:new L(0,Math.pow(2,0)).toString(),SEARCH_GRP_SNS:new L(0,Math.pow(2,1)).toString(),AVCHATROOM_HISTORY_MSG:new L(0,Math.pow(2,2)).toString(),GRP_COMMUNITY:new L(0,Math.pow(2,3)).toString(),MSG_TO_SPECIFIED_GRP_MBR:new L(0,Math.pow(2,4)).toString()};H.HOST.setCurrent(w);var x,W,Y,j,$="undefined"!=typeof wx&&"function"==typeof wx.getSystemInfoSync&&Boolean(wx.getSystemInfoSync().fontSizeSetting),z="undefined"!=typeof qq&&"function"==typeof qq.getSystemInfoSync&&Boolean(qq.getSystemInfoSync().fontSizeSetting),J="undefined"!=typeof tt&&"function"==typeof tt.getSystemInfoSync&&Boolean(tt.getSystemInfoSync().fontSizeSetting),X="undefined"!=typeof swan&&"function"==typeof swan.getSystemInfoSync&&Boolean(swan.getSystemInfoSync().fontSizeSetting),Q="undefined"!=typeof my&&"function"==typeof my.getSystemInfoSync&&Boolean(my.getSystemInfoSync().fontSizeSetting),Z="undefined"!=typeof uni&&"undefined"==typeof window,ee="undefined"!=typeof uni,te=$||z||J||X||Q||Z,oe=("undefined"!=typeof uni||"undefined"!=typeof window)&&!te,ne=z?qq:J?tt:X?swan:Q?my:$?wx:Z?uni:{},ae=(x="WEB",ve?x="WEB":z?x="QQ_MP":J?x="TT_MP":X?x="BAIDU_MP":Q?x="ALI_MP":$?x="WX_MP":Z&&(x="UNI_NATIVE_APP"),G[x]),se=oe&&window&&window.navigator&&window.navigator.userAgent||"",re=/AppleWebKit\/([\d.]+)/i.exec(se),ie=(re&&parseFloat(re.pop()),/iPad/i.test(se)),ce=/iPhone/i.test(se)&&!ie,ue=/iPod/i.test(se),le=ce||ie||ue,de=(W=se.match(/OS (\d+)_/i))&&W[1]?W[1]:null,pe=/Android/i.test(se),ge=function(){var e=se.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);if(!e)return null;var t=e[1]&&parseFloat(e[1]),o=e[2]&&parseFloat(e[2]);return t&&o?parseFloat(e[1]+"."+e[2]):t||null}(),_e=(pe&&/webkit/i.test(se),/Firefox/i.test(se),/Edge/i.test(se)),he=!_e&&/Chrome/i.test(se),fe=(function(){var e=se.match(/Chrome\/(\d+)/);e&&e[1]&&parseFloat(e[1])}(),/MSIE/.test(se)||se.indexOf("Trident")>-1&&se.indexOf("rv:11.0")>-1),me=(/MSIE\s8\.0/.test(se),function(){var e=/MSIE\s(\d+)\.\d/.exec(se),t=e&&parseFloat(e[1]);return!t&&/Trident\/7.0/i.test(se)&&/rv:11.0/.test(se)&&(t=11),t}()),Me=(/Safari/i.test(se),/TBS\/\d+/i.test(se)),ve=(function(){var e=se.match(/TBS\/(\d+)/i);if(e&&e[1])e[1]}(),!Me&&/MQQBrowser\/\d+/i.test(se),!Me&&/ QQBrowser\/\d+/i.test(se),/(micromessenger|webbrowser)/i.test(se)),ye=/Windows/i.test(se),Ie=/MAC OS X/i.test(se),Ee=(/MicroMessenger/i.test(se),oe&&"undefined"!=typeof Worker&&!fe),Te=pe||le,Ce="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};Y="undefined"!=typeof console?console:void 0!==Ce&&Ce.console?Ce.console:"undefined"!=typeof window&&window.console?window.console:{};for(var Se=function(){},De=["assert","clear","count","debug","dir","dirxml","error","group","groupCollapsed","groupEnd","info","log","profile","profileEnd","table","time","timeEnd","timeStamp","trace","warn"],Ne=De.length;Ne--;)j=De[Ne],console[j]||(Y[j]=Se);var Ae=Y,Oe=0,Re=function(){return(new Date).getTime()+Oe},Le=function(){Oe=0},ke=function(){return Math.floor(Re()/1e3)},Ge=0,Pe=new Map;function Ue(){var e,t=((e=new Date).setTime(Re()),e);return"TIM "+t.toLocaleTimeString("en-US",{hour12:!1})+"."+function(e){var t;switch(e.toString().length){case 1:t="00"+e;break;case 2:t="0"+e;break;default:t=e}return t}(t.getMilliseconds())+":"}var we={arguments2String:function(e){var t;if(1===e.length)t=Ue()+e[0];else{t=Ue();for(var o=0,n=e.length;o4294967295?(rt+=4294967295,Date.now()-rt):e},utc:function(){return Math.round(Date.now()/1e3)}},ct=function e(t,o,n,a){if(!et(t)||!et(o))return 0;for(var s,r=0,i=Object.keys(o),c=0,u=i.length;c=0?n[s]=t[s]:n[s]=e(t[s])):n[s]=void 0:n[s]=null;return n};function vt(e,t){Qe(e)&&Qe(t)?t.forEach((function(t){var o=t.key,n=t.value,a=e.find((function(e){return e.key===o}));a?a.value=n:e.push({key:o,value:n})})):we.warn("updateCustomField target 或 source 不是数组,忽略此次更新。")}var yt=function(e){return e===D.GRP_PUBLIC},It=function(e){return e===D.GRP_AVCHATROOM},Et=function(e){var t=e.type,o=e.groupID;return t===D.GRP_COMMUNITY||"".concat(o).startsWith(xe)&&!"".concat(o).includes(We)},Tt=function(e){return"".concat(e).startsWith(xe)&&"".concat(e).includes(We)},Ct=function(e){return ze(e)&&e.slice(0,3)===D.CONV_C2C},St=function(e){return ze(e)&&e.slice(0,5)===D.CONV_GROUP},Dt=function(e){return ze(e)&&e===D.CONV_SYSTEM};function Nt(e,t){var o={};return Object.keys(e).forEach((function(n){o[n]=t(e[n],n)})),o}function At(e){return te?new Promise((function(t,o){ne.getImageInfo({src:e,success:function(e){t({width:e.width,height:e.height})},fail:function(){t({width:0,height:0})}})})):fe&&9===me?Promise.resolve({width:0,height:0}):new Promise((function(t,o){var n=new Image;n.onload=function(){t({width:this.width,height:this.height}),n=null},n.onerror=function(){t({width:0,height:0}),n=null},n.src=e}))}function Ot(){function e(){return(65536*(1+Math.random())|0).toString(16).substring(1)}return"".concat(e()+e()).concat(e()).concat(e()).concat(e()).concat(e()).concat(e()).concat(e())}function Rt(){var e="unknown";if(Ie&&(e="mac"),ye&&(e="windows"),le&&(e="ios"),pe&&(e="android"),te)try{var t=ne.getSystemInfoSync().platform;void 0!==t&&(e=t)}catch(o){}return e}function Lt(e){var t=e.originUrl,o=void 0===t?void 0:t,n=e.originWidth,a=e.originHeight,s=e.min,r=void 0===s?198:s,i=parseInt(n),c=parseInt(a),u={url:void 0,width:0,height:0};if((i<=c?i:c)<=r)u.url=o,u.width=i,u.height=c;else{c<=i?(u.width=Math.ceil(i*r/c),u.height=r):(u.width=r,u.height=Math.ceil(c*r/i));var l=o&&o.indexOf("?")>-1?"".concat(o,"&"):"".concat(o,"?");u.url="".concat(l,198===r?"imageView2/3/w/198/h/198":"imageView2/3/w/720/h/720")}return Ze(o)?g(u,Ye):u}function kt(e){var t=e[2];e[2]=e[1],e[1]=t;for(var o=0;o=0}}},setGroupMemberNameCard:{groupID:zt,userID:{type:"String"},nameCard:{type:"String",validator:function(e){return ze(e)?(e.length,!0):(console.warn($t({api:"setGroupMemberNameCard",param:"nameCard",desc:"类型必须为 String"})),!1)}}},setGroupMemberCustomField:{groupID:zt,userID:{type:"String"},memberCustomField:Jt},deleteGroupMember:{groupID:zt},createTextMessage:{to:zt,conversationType:zt,payload:t(t({},Xt),{},{validator:function(e){return Xe(e)?ze(e.text)?0!==e.text.length||(console.warn($t({api:"createTextMessage",desc:"消息内容不能为空"})),!1):(console.warn($t({api:"createTextMessage",param:"payload.text",desc:"类型必须为 String"})),!1):(console.warn($t({api:"createTextMessage",param:"payload",desc:"类型必须为 plain object"})),!1)}})},createTextAtMessage:{to:zt,conversationType:zt,payload:t(t({},Xt),{},{validator:function(e){return Xe(e)?ze(e.text)?0===e.text.length?(console.warn($t({api:"createTextAtMessage",desc:"消息内容不能为空"})),!1):!(e.atUserList&&!Qe(e.atUserList))||(console.warn($t({api:"createTextAtMessage",desc:"payload.atUserList 类型必须为数组"})),!1):(console.warn($t({api:"createTextAtMessage",param:"payload.text",desc:"类型必须为 String"})),!1):(console.warn($t({api:"createTextAtMessage",param:"payload",desc:"类型必须为 plain object"})),!1)}})},createCustomMessage:{to:zt,conversationType:zt,payload:t(t({},Xt),{},{validator:function(e){return Xe(e)?e.data&&!ze(e.data)?(console.warn($t({api:"createCustomMessage",param:"payload.data",desc:"类型必须为 String"})),!1):e.description&&!ze(e.description)?(console.warn($t({api:"createCustomMessage",param:"payload.description",desc:"类型必须为 String"})),!1):!(e.extension&&!ze(e.extension))||(console.warn($t({api:"createCustomMessage",param:"payload.extension",desc:"类型必须为 String"})),!1):(console.warn($t({api:"createCustomMessage",param:"payload",desc:"类型必须为 plain object"})),!1)}})},createImageMessage:{to:zt,conversationType:zt,payload:t(t({},Xt),{},{validator:function(e){if(!Xe(e))return console.warn($t({api:"createImageMessage",param:"payload",desc:"类型必须为 plain object"})),!1;if(Ze(e.file))return console.warn($t({api:"createImageMessage",param:"payload.file",desc:"不能为 undefined"})),!1;if(oe){if(!(e.file instanceof HTMLInputElement||je(e.file)))return Xe(e.file)&&"undefined"!=typeof uni?0!==e.file.tempFilePaths.length&&0!==e.file.tempFiles.length||(console.warn($t({api:"createImageMessage",param:"payload.file",desc:"您没有选择文件,无法发送"})),!1):(console.warn($t({api:"createImageMessage",param:"payload.file",desc:"类型必须是 HTMLInputElement 或 File"})),!1);if(e.file instanceof HTMLInputElement&&0===e.file.files.length)return console.warn($t({api:"createImageMessage",param:"payload.file",desc:"您没有选择文件,无法发送"})),!1}return!0},onProgress:{type:"Function",required:!1,validator:function(e){return Ze(e)&&console.warn($t({api:"createImageMessage",desc:"没有 onProgress 回调,您将无法获取上传进度"})),!0}}})},createAudioMessage:{to:zt,conversationType:zt,payload:t(t({},Xt),{},{validator:function(e){return!!Xe(e)||(console.warn($t({api:"createAudioMessage",param:"payload",desc:"类型必须为 plain object"})),!1)}}),onProgress:{type:"Function",required:!1,validator:function(e){return Ze(e)&&console.warn($t({api:"createAudioMessage",desc:"没有 onProgress 回调,您将无法获取上传进度"})),!0}}},createVideoMessage:{to:zt,conversationType:zt,payload:t(t({},Xt),{},{validator:function(e){if(!Xe(e))return console.warn($t({api:"createVideoMessage",param:"payload",desc:"类型必须为 plain object"})),!1;if(Ze(e.file))return console.warn($t({api:"createVideoMessage",param:"payload.file",desc:"不能为 undefined"})),!1;if(oe){if(!(e.file instanceof HTMLInputElement||je(e.file)))return Xe(e.file)&&"undefined"!=typeof uni?!!je(e.file.tempFile)||(console.warn($t({api:"createVideoMessage",param:"payload.file",desc:"您没有选择文件,无法发送"})),!1):(console.warn($t({api:"createVideoMessage",param:"payload.file",desc:"类型必须是 HTMLInputElement 或 File"})),!1);if(e.file instanceof HTMLInputElement&&0===e.file.files.length)return console.warn($t({api:"createVideoMessage",param:"payload.file",desc:"您没有选择文件,无法发送"})),!1}return!0}}),onProgress:{type:"Function",required:!1,validator:function(e){return Ze(e)&&console.warn($t({api:"createVideoMessage",desc:"没有 onProgress 回调,您将无法获取上传进度"})),!0}}},createFaceMessage:{to:zt,conversationType:zt,payload:t(t({},Xt),{},{validator:function(e){return Xe(e)?$e(e.index)?!!ze(e.data)||(console.warn($t({api:"createFaceMessage",param:"payload.data",desc:"类型必须为 String"})),!1):(console.warn($t({api:"createFaceMessage",param:"payload.index",desc:"类型必须为 Number"})),!1):(console.warn($t({api:"createFaceMessage",param:"payload",desc:"类型必须为 plain object"})),!1)}})},createFileMessage:{to:zt,conversationType:zt,payload:t(t({},Xt),{},{validator:function(e){if(!Xe(e))return console.warn($t({api:"createFileMessage",param:"payload",desc:"类型必须为 plain object"})),!1;if(Ze(e.file))return console.warn($t({api:"createFileMessage",param:"payload.file",desc:"不能为 undefined"})),!1;if(oe){if(!(e.file instanceof HTMLInputElement||je(e.file)))return Xe(e.file)&&"undefined"!=typeof uni?0!==e.file.tempFilePaths.length&&0!==e.file.tempFiles.length||(console.warn($t({api:"createFileMessage",param:"payload.file",desc:"您没有选择文件,无法发送"})),!1):(console.warn($t({api:"createFileMessage",param:"payload.file",desc:"类型必须是 HTMLInputElement 或 File"})),!1);if(e.file instanceof HTMLInputElement&&0===e.file.files.length)return console.warn($t({api:"createFileMessage",desc:"您没有选择文件,无法发送"})),!1}return!0}}),onProgress:{type:"Function",required:!1,validator:function(e){return Ze(e)&&console.warn($t({api:"createFileMessage",desc:"没有 onProgress 回调,您将无法获取上传进度"})),!0}}},createLocationMessage:{to:zt,conversationType:zt,payload:t(t({},Xt),{},{validator:function(e){return Xe(e)?ze(e.description)?$e(e.longitude)?!!$e(e.latitude)||(console.warn($t({api:"createLocationMessage",param:"payload.latitude",desc:"类型必须为 Number"})),!1):(console.warn($t({api:"createLocationMessage",param:"payload.longitude",desc:"类型必须为 Number"})),!1):(console.warn($t({api:"createLocationMessage",param:"payload.description",desc:"类型必须为 String"})),!1):(console.warn($t({api:"createLocationMessage",param:"payload",desc:"类型必须为 plain object"})),!1)}})},createMergerMessage:{to:zt,conversationType:zt,payload:t(t({},Xt),{},{validator:function(e){if(Vt(e.messageList))return console.warn($t({api:"createMergerMessage",desc:"不能为空数组"})),!1;if(Vt(e.compatibleText))return console.warn($t({api:"createMergerMessage",desc:"类型必须为 String,且不能为空"})),!1;var t=!1;return e.messageList.forEach((function(e){e.status===xt.FAIL&&(t=!0)})),!t||(console.warn($t({api:"createMergerMessage",desc:"不支持合并已发送失败的消息"})),!1)}})},revokeMessage:[t(t({name:"message"},Xt),{},{validator:function(e){return Vt(e)?(console.warn($t({api:"revokeMessage",desc:"请传入消息(Message)实例"})),!1):e.conversationType===D.CONV_SYSTEM?(console.warn($t({api:"revokeMessage",desc:"不能撤回系统会话消息,只能撤回单聊消息或群消息"})),!1):!0!==e.isRevoked||(console.warn($t({api:"revokeMessage",desc:"消息已经被撤回,请勿重复操作"})),!1)}})],deleteMessage:[t(t({name:"messageList"},Jt),{},{validator:function(e){return!Vt(e)||(console.warn($t({api:"deleteMessage",param:"messageList",desc:"不能为空数组"})),!1)}})],modifyMessage:[t(t({name:"message"},Xt),{},{validator:function(e){return Vt(e)?(console.warn($t({api:"modifyMessage",desc:"请传入消息(Message)实例"})),!1):e.conversationType===D.CONV_SYSTEM?(console.warn($t({api:"modifyMessage",desc:"不支持修改系统会话消息,只能修改单聊消息或群消息"})),!1):!0===e._onlineOnlyFlag?(console.warn($t({api:"modifyMessage",desc:"不支持修改在线消息"})),!1):-1!==[D.MSG_TEXT,D.MSG_CUSTOM,D.MSG_LOCATION,D.MSG_FACE].indexOf(e.type)||(console.warn($t({api:"modifyMessage",desc:"只支持修改文本消息、自定义消息、地理位置消息和表情消息"})),!1)}})],getUserProfile:{userIDList:{type:"Array",validator:function(e){return Qe(e)?(0===e.length&&console.warn($t({api:"getUserProfile",param:"userIDList",desc:"不能为空数组"})),!0):(console.warn($t({api:"getUserProfile",param:"userIDList",desc:"必须为数组"})),!1)}}},updateMyProfile:{profileCustomField:{type:"Array",validator:function(e){return!!Ze(e)||(!!Qe(e)||(console.warn($t({api:"updateMyProfile",param:"profileCustomField",desc:"必须为数组"})),!1))}}},addFriend:{to:zt,source:{type:"String",required:!0,validator:function(e){return!!e&&(e.startsWith("AddSource_Type_")?!(e.replace("AddSource_Type_","").length>8)||(console.warn($t({api:"addFriend",desc:"加好友来源字段的关键字长度不得超过8字节"})),!1):(console.warn($t({api:"addFriend",desc:"加好友来源字段的前缀必须是:AddSource_Type_"})),!1))}},remark:{type:"String",required:!1,validator:function(e){return!(ze(e)&&e.length>96)||(console.warn($t({api:"updateFriend",desc:" 备注长度最长不得超过 96 个字节"})),!1)}}},deleteFriend:{userIDList:Jt},checkFriend:{userIDList:Jt},getFriendProfile:{userIDList:Jt},updateFriend:{userID:zt,remark:{type:"String",required:!1,validator:function(e){return!(ze(e)&&e.length>96)||(console.warn($t({api:"updateFriend",desc:" 备注长度最长不得超过 96 个字节"})),!1)}},friendCustomField:{type:"Array",required:!1,validator:function(e){if(e){if(!Qe(e))return console.warn($t({api:"updateFriend",param:"friendCustomField",desc:"必须为数组"})),!1;var t=!0;return e.forEach((function(e){return ze(e.key)&&-1!==e.key.indexOf("Tag_SNS_Custom")?ze(e.value)?e.value.length>8?(console.warn($t({api:"updateFriend",desc:"好友自定义字段的关键字长度不得超过8字节"})),t=!1):void 0:(console.warn($t({api:"updateFriend",desc:"类型必须为 String"})),t=!1):(console.warn($t({api:"updateFriend",desc:"好友自定义字段的前缀必须是 Tag_SNS_Custom"})),t=!1)})),t}return!0}}},acceptFriendApplication:{userID:zt},refuseFriendApplication:{userID:zt},deleteFriendApplication:{userID:zt},createFriendGroup:{name:zt},deleteFriendGroup:{name:zt},addToFriendGroup:{name:zt,userIDList:Jt},removeFromFriendGroup:{name:zt,userIDList:Jt},renameFriendGroup:{oldName:zt,newName:zt},sendMessageReadReceipt:[{name:"messageList",type:"Array",validator:function(e){return Qe(e)?0!==e.length||(console.warn($t({api:"sendMessageReadReceipt",param:"messageList",desc:"不能为空数组"})),!1):(console.warn($t({api:"sendMessageReadReceipt",param:"messageList",desc:"必须为数组"})),!1)}}],getMessageReadReceiptList:[{name:"messageList",type:"Array",validator:function(e){return Qe(e)?0!==e.length||(console.warn($t({api:"getMessageReadReceiptList",param:"messageList",desc:"不能为空数组"})),!1):(console.warn($t({api:"getMessageReadReceiptList",param:"messageList",desc:"必须为数组"})),!1)}}],createTopicInCommunity:{groupID:zt,topicName:zt},deleteTopicFromCommunity:{groupID:zt,topicIDList:{type:"Array",validator:function(e){return!e||(!!Qe(e)||(console.warn($t({api:"deleteTopicFromCommunity",param:"topicIDList",desc:"必须为数组"})),!1))}}},updateTopicProfile:{groupID:zt,topicID:zt},getTopicList:{groupID:zt,topicIDList:{type:"Array",validator:function(e){return!e||(!!Qe(e)||(console.warn($t({api:"getTopicList",param:"topicIDList",desc:"必须为数组"})),!1))}}}},Zt={login:"login",logout:"logout",on:"on",once:"once",off:"off",setLogLevel:"setLogLevel",registerPlugin:"registerPlugin",destroy:"destroy",createTextMessage:"createTextMessage",createTextAtMessage:"createTextAtMessage",createImageMessage:"createImageMessage",createAudioMessage:"createAudioMessage",createVideoMessage:"createVideoMessage",createCustomMessage:"createCustomMessage",createFaceMessage:"createFaceMessage",createFileMessage:"createFileMessage",createLocationMessage:"createLocationMessage",createMergerMessage:"createMergerMessage",downloadMergerMessage:"downloadMergerMessage",createForwardMessage:"createForwardMessage",sendMessage:"sendMessage",resendMessage:"resendMessage",revokeMessage:"revokeMessage",deleteMessage:"deleteMessage",modifyMessage:"modifyMessage",sendMessageReadReceipt:"sendMessageReadReceipt",getGroupMessageReadMemberList:"getGroupMessageReadMemberList",getMessageReadReceiptList:"getMessageReadReceiptList",getMessageList:"getMessageList",findMessage:"findMessage",getMessageListHopping:"getMessageListHopping",setMessageRead:"setMessageRead",setAllMessageRead:"setAllMessageRead",getConversationList:"getConversationList",getConversationProfile:"getConversationProfile",deleteConversation:"deleteConversation",pinConversation:"pinConversation",getGroupList:"getGroupList",getGroupProfile:"getGroupProfile",createGroup:"createGroup",joinGroup:"joinGroup",updateGroupProfile:"updateGroupProfile",quitGroup:"quitGroup",dismissGroup:"dismissGroup",changeGroupOwner:"changeGroupOwner",searchGroupByID:"searchGroupByID",setMessageRemindType:"setMessageRemindType",handleGroupApplication:"handleGroupApplication",initGroupAttributes:"initGroupAttributes",setGroupAttributes:"setGroupAttributes",deleteGroupAttributes:"deleteGroupAttributes",getGroupAttributes:"getGroupAttributes",getJoinedCommunityList:"getJoinedCommunityList",createTopicInCommunity:"createTopicInCommunity",deleteTopicFromCommunity:"deleteTopicFromCommunity",updateTopicProfile:"updateTopicProfile",getTopicList:"getTopicList",getGroupMemberProfile:"getGroupMemberProfile",getGroupMemberList:"getGroupMemberList",addGroupMember:"addGroupMember",deleteGroupMember:"deleteGroupMember",setGroupMemberNameCard:"setGroupMemberNameCard",setGroupMemberMuteTime:"setGroupMemberMuteTime",setGroupMemberRole:"setGroupMemberRole",setGroupMemberCustomField:"setGroupMemberCustomField",getGroupOnlineMemberCount:"getGroupOnlineMemberCount",getMyProfile:"getMyProfile",getUserProfile:"getUserProfile",updateMyProfile:"updateMyProfile",getBlacklist:"getBlacklist",addToBlacklist:"addToBlacklist",removeFromBlacklist:"removeFromBlacklist",getFriendList:"getFriendList",addFriend:"addFriend",deleteFriend:"deleteFriend",checkFriend:"checkFriend",updateFriend:"updateFriend",getFriendProfile:"getFriendProfile",getFriendApplicationList:"getFriendApplicationList",refuseFriendApplication:"refuseFriendApplication",deleteFriendApplication:"deleteFriendApplication",acceptFriendApplication:"acceptFriendApplication",setFriendApplicationRead:"setFriendApplicationRead",getFriendGroupList:"getFriendGroupList",createFriendGroup:"createFriendGroup",renameFriendGroup:"renameFriendGroup",deleteFriendGroup:"deleteFriendGroup",addToFriendGroup:"addToFriendGroup",removeFromFriendGroup:"removeFromFriendGroup",callExperimentalAPI:"callExperimentalAPI"},eo="sign",to="message",oo="user",no="c2c",ao="group",so="sns",ro="groupMember",io="Topic",co="conversation",uo="context",lo="storage",po="eventStat",go="netMonitor",_o="bigDataChannel",ho="upload",fo="plugin",mo="syncUnreadMessage",Mo="session",vo="channel",yo="message_loss_detection",Io="cloudControl",Eo="workerTimer",To="pullGroupMessage",Co="qualityStat",So="commercialConfig",Do=function(){function e(t){n(this,e),this._moduleManager=t,this._className=""}return s(e,[{key:"isLoggedIn",value:function(){return this._moduleManager.getModule(uo).isLoggedIn()}},{key:"isOversea",value:function(){return this._moduleManager.getModule(uo).isOversea()}},{key:"isPrivateNetWork",value:function(){return this._moduleManager.getModule(uo).isPrivateNetWork()}},{key:"getMyUserID",value:function(){return this._moduleManager.getModule(uo).getUserID()}},{key:"getMyTinyID",value:function(){return this._moduleManager.getModule(uo).getTinyID()}},{key:"getModule",value:function(e){return this._moduleManager.getModule(e)}},{key:"getPlatform",value:function(){return ae}},{key:"getNetworkType",value:function(){return this._moduleManager.getModule(go).getNetworkType()}},{key:"probeNetwork",value:function(e){return this.isPrivateNetWork()?Promise.resolve([!0,this.getNetworkType()]):this._moduleManager.getModule(go).probe(e)}},{key:"getCloudConfig",value:function(e){return this._moduleManager.getModule(Io).getCloudConfig(e)}},{key:"emitOuterEvent",value:function(e,t){this._moduleManager.getOuterEmitterInstance().emit(e,t)}},{key:"emitInnerEvent",value:function(e,t){this._moduleManager.getInnerEmitterInstance().emit(e,t)}},{key:"getInnerEmitterInstance",value:function(){return this._moduleManager.getInnerEmitterInstance()}},{key:"generateTjgID",value:function(e){return this._moduleManager.getModule(uo).getTinyID()+"-"+e.random}},{key:"filterModifiedMessage",value:function(e){if(!Vt(e)){var t=e.filter((function(e){return!0===e.isModified}));t.length>0&&this.emitOuterEvent(S.MESSAGE_MODIFIED,t)}}},{key:"filterUnmodifiedMessage",value:function(e){return Vt(e)?[]:e.filter((function(e){return!1===e.isModified}))}},{key:"request",value:function(e){return this._moduleManager.getModule(Mo).request(e)}},{key:"canIUse",value:function(e){return this._moduleManager.getModule(So).hasPurchasedFeature(e)}}]),e}(),No="wslogin",Ao="wslogout",Oo="wshello",Ro="KickOther",Lo="getmsg",ko="authkey",Go="sendmsg",Po="send_group_msg",Uo="portrait_get_all",wo="portrait_set",bo="black_list_get",Fo="black_list_add",qo="black_list_delete",Vo="msgwithdraw",Ko="msgreaded",Ho="set_c2c_peer_mute_notifications",Bo="get_c2c_peer_mute_notifications",xo="getroammsg",Wo="get_peer_read_time",Yo="delete_c2c_msg_ramble",jo="modify_c2c_msg",$o="page_get",zo="get",Jo="delete",Xo="top",Qo="deletemsg",Zo="get_joined_group_list",en="get_group_self_member_info",tn="create_group",on="destroy_group",nn="modify_group_base_info",an="apply_join_group",sn="apply_join_group_noauth",rn="quit_group",cn="get_group_public_info",un="change_group_owner",ln="handle_apply_join_group",dn="handle_invite_join_group",pn="group_msg_recall",gn="msg_read_report",_n="read_all_unread_msg",hn="group_msg_get",fn="get_group_msg_receipt",mn="group_msg_receipt",Mn="c2c_msg_read_receipt",vn="get_group_msg_receipt_detail",yn="get_pendency",In="deletemsg",En="get_msg",Tn="get_msg_noauth",Cn="get_online_member_num",Sn="delete_group_ramble_msg_by_seq",Dn="modify_group_msg",Nn="set_group_attr",An="modify_group_attr",On="delete_group_attr",Rn="clear_group_attr",Ln="get_group_attr",kn="get_group_member_info",Gn="get_specified_group_member_info",Pn="add_group_member",Un="delete_group_member",wn="modify_group_member_info",bn="cos",Fn="pre_sig",qn="video_cover",Vn="tim_web_report_v2",Kn="alive",Hn="msg_push",Bn="multi_msg_push_ws",xn="ws_msg_push_ack",Wn="stat_forceoffline",Yn="save_relay_json_msg",jn="get_relay_json_msg",$n="fetch_config",zn="push_configv2",Jn="fetch_imsdk_purchase_bitsv2",Xn="push_imsdk_purchase_bitsv2",Qn="notify2",Zn="create_topic",ea="destroy_topic",ta="modify_topic",oa="get_topic",na={NO_SDKAPPID:2e3,NO_ACCOUNT_TYPE:2001,NO_IDENTIFIER:2002,NO_USERSIG:2003,NO_TINYID:2022,NO_A2KEY:2023,USER_NOT_LOGGED_IN:2024,REPEAT_LOGIN:2025,COS_UNDETECTED:2040,COS_GET_SIG_FAIL:2041,MESSAGE_SEND_FAIL:2100,MESSAGE_LIST_CONSTRUCTOR_NEED_OPTIONS:2103,MESSAGE_SEND_NEED_MESSAGE_INSTANCE:2105,MESSAGE_SEND_INVALID_CONVERSATION_TYPE:2106,MESSAGE_FILE_IS_EMPTY:2108,MESSAGE_ONPROGRESS_FUNCTION_ERROR:2109,MESSAGE_REVOKE_FAIL:2110,MESSAGE_DELETE_FAIL:2111,MESSAGE_UNREAD_ALL_FAIL:2112,MESSAGE_CONTROL_INFO_FAIL:2113,READ_RECEIPT_MESSAGE_LIST_EMPTY:2114,MESSAGE_SEND_GROUP_WITH_TOPIC_FAIL:2115,CANNOT_DELETE_GROUP_SYSTEM_NOTICE:2116,MESSAGE_IMAGE_SELECT_FILE_FIRST:2251,MESSAGE_IMAGE_TYPES_LIMIT:2252,MESSAGE_IMAGE_SIZE_LIMIT:2253,MESSAGE_AUDIO_UPLOAD_FAIL:2300,MESSAGE_AUDIO_SIZE_LIMIT:2301,MESSAGE_VIDEO_UPLOAD_FAIL:2350,MESSAGE_VIDEO_SIZE_LIMIT:2351,MESSAGE_VIDEO_TYPES_LIMIT:2352,MESSAGE_FILE_UPLOAD_FAIL:2400,MESSAGE_FILE_SELECT_FILE_FIRST:2401,MESSAGE_FILE_SIZE_LIMIT:2402,MESSAGE_FILE_URL_IS_EMPTY:2403,MESSAGE_MERGER_TYPE_INVALID:2450,MESSAGE_MERGER_KEY_INVALID:2451,MESSAGE_MERGER_DOWNLOAD_FAIL:2452,MESSAGE_FORWARD_TYPE_INVALID:2453,MESSAGE_AT_TYPE_INVALID:2454,MESSAGE_MODIFY_CONFLICT:2480,MESSAGE_MODIFY_DISABLED_IN_AVCHATROOM:2481,CONVERSATION_NOT_FOUND:2500,USER_OR_GROUP_NOT_FOUND:2501,CONVERSATION_UN_RECORDED_TYPE:2502,ILLEGAL_GROUP_TYPE:2600,CANNOT_JOIN_WORK:2601,ILLEGAL_GROUP_ID:2602,CANNOT_CHANGE_OWNER_IN_AVCHATROOM:2620,CANNOT_CHANGE_OWNER_TO_SELF:2621,CANNOT_DISMISS_Work:2622,MEMBER_NOT_IN_GROUP:2623,CANNOT_USE_GRP_ATTR_NOT_AVCHATROOM:2641,CANNOT_USE_GRP_ATTR_AVCHATROOM_UNJOIN:2642,JOIN_GROUP_FAIL:2660,CANNOT_ADD_MEMBER_IN_AVCHATROOM:2661,CANNOT_JOIN_NON_AVCHATROOM_WITHOUT_LOGIN:2662,CANNOT_KICK_MEMBER_IN_AVCHATROOM:2680,NOT_OWNER:2681,CANNOT_SET_MEMBER_ROLE_IN_WORK_AND_AVCHATROOM:2682,INVALID_MEMBER_ROLE:2683,CANNOT_SET_SELF_MEMBER_ROLE:2684,CANNOT_MUTE_SELF:2685,NOT_MY_FRIEND:2700,ALREADY_MY_FRIEND:2701,FRIEND_GROUP_EXISTED:2710,FRIEND_GROUP_NOT_EXIST:2711,FRIEND_APPLICATION_NOT_EXIST:2716,UPDATE_PROFILE_INVALID_PARAM:2721,UPDATE_PROFILE_NO_KEY:2722,ADD_BLACKLIST_INVALID_PARAM:2740,DEL_BLACKLIST_INVALID_PARAM:2741,CANNOT_ADD_SELF_TO_BLACKLIST:2742,ADD_FRIEND_INVALID_PARAM:2760,NETWORK_ERROR:2800,NETWORK_TIMEOUT:2801,NETWORK_BASE_OPTIONS_NO_URL:2802,NETWORK_UNDEFINED_SERVER_NAME:2803,NETWORK_PACKAGE_UNDEFINED:2804,NO_NETWORK:2805,CONVERTOR_IRREGULAR_PARAMS:2900,NOTICE_RUNLOOP_UNEXPECTED_CONDITION:2901,NOTICE_RUNLOOP_OFFSET_LOST:2902,UNCAUGHT_ERROR:2903,GET_LONGPOLL_ID_FAILED:2904,INVALID_OPERATION:2905,OVER_FREQUENCY_LIMIT:2996,CANNOT_FIND_PROTOCOL:2997,CANNOT_FIND_MODULE:2998,SDK_IS_NOT_READY:2999,LOGGING_IN:3e3,LOGIN_FAILED:3001,KICKED_OUT_MULT_DEVICE:3002,KICKED_OUT_MULT_ACCOUNT:3003,KICKED_OUT_USERSIG_EXPIRED:3004,LOGGED_OUT:3005,KICKED_OUT_REST_API:3006,ILLEGAL_TOPIC_ID:3021,LONG_POLL_KICK_OUT:91101,MESSAGE_A2KEY_EXPIRED:20002,ACCOUNT_A2KEY_EXPIRED:70001,LONG_POLL_API_PARAM_ERROR:90001,HELLO_ANSWER_KICKED_OUT:1002,OPEN_SERVICE_OVERLOAD_ERROR:60022},aa={NO_SDKAPPID:"无 SDKAppID",NO_ACCOUNT_TYPE:"无 accountType",NO_IDENTIFIER:"无 userID",NO_USERSIG:"无 userSig",NO_TINYID:"无 tinyID",NO_A2KEY:"无 a2key",USER_NOT_LOGGED_IN:"用户未登录",REPEAT_LOGIN:"重复登录",COS_UNDETECTED:"未检测到 COS 上传插件",COS_GET_SIG_FAIL:"获取 COS 预签名 URL 失败",MESSAGE_SEND_FAIL:"消息发送失败",MESSAGE_LIST_CONSTRUCTOR_NEED_OPTIONS:"MessageController.constructor() 需要参数 options",MESSAGE_SEND_NEED_MESSAGE_INSTANCE:"需要 Message 的实例",MESSAGE_SEND_INVALID_CONVERSATION_TYPE:'Message.conversationType 只能为 "C2C" 或 "GROUP"',MESSAGE_FILE_IS_EMPTY:"无法发送空文件",MESSAGE_ONPROGRESS_FUNCTION_ERROR:"回调函数运行时遇到错误,请检查接入侧代码",MESSAGE_REVOKE_FAIL:"消息撤回失败",MESSAGE_DELETE_FAIL:"消息删除失败",MESSAGE_UNREAD_ALL_FAIL:"设置所有未读消息为已读处理失败",MESSAGE_CONTROL_INFO_FAIL:"社群不支持消息发送控制选项",READ_RECEIPT_MESSAGE_LIST_EMPTY:"消息列表中没有需要发送已读回执的消息",MESSAGE_SEND_GROUP_WITH_TOPIC_FAIL:"不能在支持话题的群组中发消息,请检查群组 isSupportTopic 属性",CANNOT_DELETE_GROUP_SYSTEM_NOTICE:"不支持删除群系统通知",MESSAGE_IMAGE_SELECT_FILE_FIRST:"请先选择一个图片",MESSAGE_IMAGE_TYPES_LIMIT:"只允许上传 jpg png jpeg gif bmp image webp 格式的图片",MESSAGE_IMAGE_SIZE_LIMIT:"图片大小超过20M,无法发送",MESSAGE_AUDIO_UPLOAD_FAIL:"语音上传失败",MESSAGE_AUDIO_SIZE_LIMIT:"语音大小大于20M,无法发送",MESSAGE_VIDEO_UPLOAD_FAIL:"视频上传失败",MESSAGE_VIDEO_SIZE_LIMIT:"视频大小超过100M,无法发送",MESSAGE_VIDEO_TYPES_LIMIT:"只允许上传 mp4 格式的视频",MESSAGE_FILE_UPLOAD_FAIL:"文件上传失败",MESSAGE_FILE_SELECT_FILE_FIRST:"请先选择一个文件",MESSAGE_FILE_SIZE_LIMIT:"文件大小超过100M,无法发送 ",MESSAGE_FILE_URL_IS_EMPTY:"缺少必要的参数文件 URL",MESSAGE_MERGER_TYPE_INVALID:"非合并消息",MESSAGE_MERGER_KEY_INVALID:"合并消息的 messageKey 无效",MESSAGE_MERGER_DOWNLOAD_FAIL:"下载合并消息失败",MESSAGE_FORWARD_TYPE_INVALID:"选择的消息类型(如群提示消息)不可以转发",MESSAGE_AT_TYPE_INVALID:"社群/话题不支持 @ 所有人",MESSAGE_MODIFY_CONFLICT:"修改消息时发生冲突",MESSAGE_MODIFY_DISABLED_IN_AVCHATROOM:"直播群不支持修改消息",CONVERSATION_NOT_FOUND:"没有找到相应的会话,请检查传入参数",USER_OR_GROUP_NOT_FOUND:"没有找到相应的用户或群组,请检查传入参数",CONVERSATION_UN_RECORDED_TYPE:"未记录的会话类型",ILLEGAL_GROUP_TYPE:"非法的群类型,请检查传入参数",CANNOT_JOIN_WORK:"不能加入 Work 类型的群组",ILLEGAL_GROUP_ID:"群组 ID 非法,非 Community 类型群组不能以 @TGS#_ 为前缀,Community 类型群组必须以 @TGS#_ 为前缀且不能包含 @TOPIC#_ 字符串",CANNOT_CHANGE_OWNER_IN_AVCHATROOM:"AVChatRoom 类型的群组不能转让群主",CANNOT_CHANGE_OWNER_TO_SELF:"不能把群主转让给自己",CANNOT_DISMISS_WORK:"不能解散 Work 类型的群组",MEMBER_NOT_IN_GROUP:"用户不在该群组内",JOIN_GROUP_FAIL:"加群失败,请检查传入参数或重试",CANNOT_ADD_MEMBER_IN_AVCHATROOM:"AVChatRoom 类型的群不支持邀请群成员",CANNOT_JOIN_NON_AVCHATROOM_WITHOUT_LOGIN:"非 AVChatRoom 类型的群组不允许匿名加群,请先登录后再加群",CANNOT_KICK_MEMBER_IN_AVCHATROOM:"不能在 AVChatRoom 类型的群组踢人",NOT_OWNER:"你不是群主,只有群主才有权限操作",CANNOT_SET_MEMBER_ROLE_IN_WORK_AND_AVCHATROOM:"不能在 Work / AVChatRoom 类型的群中设置群成员身份",INVALID_MEMBER_ROLE:"不合法的群成员身份,请检查传入参数",CANNOT_SET_SELF_MEMBER_ROLE:"不能设置自己的群成员身份,请检查传入参数",CANNOT_MUTE_SELF:"不能将自己禁言,请检查传入参数",NOT_MY_FRIEND:"非好友关系",ALREADY_MY_FRIEND:"已经是好友关系",FRIEND_GROUP_EXISTED:"好友分组已存在",FRIEND_GROUP_NOT_EXIST:"好友分组不存在",FRIEND_APPLICATION_NOT_EXIST:"好友申请不存在",UPDATE_PROFILE_INVALID_PARAM:"传入 updateMyProfile 接口的参数无效",UPDATE_PROFILE_NO_KEY:"updateMyProfile 无标配资料字段或自定义资料字段",ADD_BLACKLIST_INVALID_PARAM:"传入 addToBlacklist 接口的参数无效",DEL_BLACKLIST_INVALID_PARAM:"传入 removeFromBlacklist 接口的参数无效",CANNOT_ADD_SELF_TO_BLACKLIST:"不能拉黑自己",ADD_FRIEND_INVALID_PARAM:"传入 addFriend 接口的参数无效",NETWORK_ERROR:"网络错误",NETWORK_TIMEOUT:"请求超时",NETWORK_BASE_OPTIONS_NO_URL:"网络层初始化错误,缺少 URL 参数",NETWORK_UNDEFINED_SERVER_NAME:"打包错误,未定义的 serverName",NETWORK_PACKAGE_UNDEFINED:"未定义的 packageConfig",NO_NETWORK:"未连接到网络",CONVERTOR_IRREGULAR_PARAMS:"不规范的参数名称",NOTICE_RUNLOOP_UNEXPECTED_CONDITION:"意料外的通知条件",NOTICE_RUNLOOP_OFFSET_LOST:"_syncOffset 丢失",GET_LONGPOLL_ID_FAILED:"获取 longpolling id 失败",UNCAUGHT_ERROR:"未经明确定义的错误",INVALID_OPERATION:"无效操作,如调用了未定义或者未实现的方法等",CANNOT_FIND_PROTOCOL:"无法找到协议",CANNOT_FIND_MODULE:"无法找到模块,请参考:https://web.sdk.qcloud.com/im/doc/zh-cn/tutorial-03-sns.html",SDK_IS_NOT_READY:"接口需要 SDK 处于 ready 状态后才能调用",LOGGING_IN:"用户正在登录中",LOGIN_FAILED:"用户登录失败",KICKED_OUT_MULT_DEVICE:"用户多终端登录被踢出",KICKED_OUT_MULT_ACCOUNT:"用户多实例登录被踢出",KICKED_OUT_USERSIG_EXPIRED:"用户 userSig 过期被踢出",LOGGED_OUT:"用户已登出",KICKED_OUT_REST_API:"用户被 REST API - kick 接口: https://cloud.tencent.com/document/product/269/3853 踢出",OVER_FREQUENCY_LIMIT:"超出 SDK 频率控制",LONG_POLL_KICK_OUT:"检测到多个 web 实例登录,消息通道下线",OPEN_SERVICE_OVERLOAD_ERROR:"后台服务正忙,请稍后再试",MESSAGE_A2KEY_EXPIRED:"消息错误码:UserSig 或 A2 失效。",ACCOUNT_A2KEY_EXPIRED:"帐号错误码:UserSig 已过期,请重新生成。建议 UserSig 有效期设置不小于24小时。",LONG_POLL_API_PARAM_ERROR:"longPoll API parameters error",ILLEGAL_TOPIC_ID:"topicID 非法"},sa="networkRTT",ra="messageE2EDelay",ia="sendMessageC2C",ca="sendMessageGroup",ua="sendMessageGroupAV",la="sendMessageRichMedia",da="cosUpload",pa="messageReceivedGroup",ga="messageReceivedGroupAVPush",_a="messageReceivedGroupAVPull",ha=(r(Bt={},sa,2),r(Bt,ra,3),r(Bt,ia,4),r(Bt,ca,5),r(Bt,ua,6),r(Bt,la,7),r(Bt,pa,8),r(Bt,ga,9),r(Bt,_a,10),r(Bt,da,11),Bt),fa={info:4,warning:5,error:6},ma={wifi:1,"2g":2,"3g":3,"4g":4,"5g":5,unknown:6,none:7,online:8},Ma={login:4},va=function(){function e(t){n(this,e),this.eventType=Ma[t]||0,this.timestamp=0,this.networkType=8,this.code=0,this.message="",this.moreMessage="",this.extension=t,this.costTime=0,this.duplicate=!1,this.level=4,this.uiPlatform=void 0,this._sentFlag=!1,this._startts=Re()}return s(e,[{key:"updateTimeStamp",value:function(){this.timestamp=Re()}},{key:"start",value:function(e){return this._startts=e,this}},{key:"end",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(!this._sentFlag){var o=Re();0===this.costTime&&(this.costTime=o-this._startts),this.setMoreMessage("startts:".concat(this._startts," endts:").concat(o)),t?(this._sentFlag=!0,this._eventStatModule&&this._eventStatModule.pushIn(this)):setTimeout((function(){e._sentFlag=!0,e._eventStatModule&&e._eventStatModule.pushIn(e)}),0)}}},{key:"setError",value:function(e,t,o){return e instanceof Error?(this._sentFlag||(this.setNetworkType(o),t?(e.code&&this.setCode(e.code),e.message&&this.setMoreMessage(e.message)):(this.setCode(na.NO_NETWORK),this.setMoreMessage(aa.NO_NETWORK)),this.setLevel("error")),this):(we.warn("SSOLogData.setError value not instanceof Error, please check!"),this)}},{key:"setCode",value:function(e){return Ze(e)||this._sentFlag||("ECONNABORTED"===e&&(this.code=103),$e(e)?this.code=e:we.warn("SSOLogData.setCode value not a number, please check!",e,o(e))),this}},{key:"setMessage",value:function(e){return Ze(e)||this._sentFlag||($e(e)&&(this.message=e.toString()),ze(e)&&(this.message=e)),this}},{key:"setCostTime",value:function(e){return this.costTime=e,this}},{key:"setLevel",value:function(e){return Ze(e)||this._sentFlag||(this.level=fa[e]),this}},{key:"setMoreMessage",value:function(e){return Vt(this.moreMessage)?this.moreMessage="".concat(e):this.moreMessage+=" ".concat(e),this}},{key:"setNetworkType",value:function(e){if(Ze(e))we.warn("SSOLogData.setNetworkType value is undefined, please check!");else{var t=ma[e.toLowerCase()];Ze(t)||(this.networkType=t)}return this}},{key:"getStartTs",value:function(){return this._startts}},{key:"setUIPlatform",value:function(e){this.uiPlatform=e}}],[{key:"bindEventStatModule",value:function(t){e.prototype._eventStatModule=t}}]),e}(),ya={SDK_CONSTRUCT:"sdkConstruct",SDK_READY:"sdkReady",LOGIN:"login",LOGOUT:"logout",KICKED_OUT:"kickedOut",REGISTER_PLUGIN:"registerPlugin",KICK_OTHER:"kickOther",WS_CONNECT:"wsConnect",WS_ON_OPEN:"wsOnOpen",WS_ON_CLOSE:"wsOnClose",WS_ON_ERROR:"wsOnError",NETWORK_CHANGE:"networkChange",GET_COS_AUTH_KEY:"getCosAuthKey",GET_COS_PRE_SIG_URL:"getCosPreSigUrl",GET_SNAPSHOT_INFO:"getSnapshotInfo",UPLOAD:"upload",SEND_MESSAGE:"sendMessage",SEND_MESSAGE_WITH_RECEIPT:"sendMessageWithReceipt",SEND_COMBO_MESSAGE:"sendComboMessage",GET_C2C_ROAMING_MESSAGES:"getC2CRoamingMessages",GET_GROUP_ROAMING_MESSAGES:"getGroupRoamingMessages",GET_C2C_ROAMING_MESSAGES_HOPPING:"getC2CRoamingMessagesHopping",GET_GROUP_ROAMING_MESSAGES_HOPPING:"getGroupRoamingMessagesHopping",GET_READ_RECEIPT:"getReadReceipt",GET_READ_RECEIPT_DETAIL:"getReadReceiptDetail",SEND_READ_RECEIPT:"sendReadReceipt",SEND_C2C_READ_RECEIPT:"sendC2CReadReceipt",REVOKE_MESSAGE:"revokeMessage",DELETE_MESSAGE:"deleteMessage",EDIT_MESSAGE:"modifyMessage",SET_C2C_MESSAGE_READ:"setC2CMessageRead",SET_GROUP_MESSAGE_READ:"setGroupMessageRead",EMPTY_MESSAGE_BODY:"emptyMessageBody",GET_PEER_READ_TIME:"getPeerReadTime",UPLOAD_MERGER_MESSAGE:"uploadMergerMessage",DOWNLOAD_MERGER_MESSAGE:"downloadMergerMessage",JSON_PARSE_ERROR:"jsonParseError",MESSAGE_E2E_DELAY_EXCEPTION:"messageE2EDelayException",GET_CONVERSATION_LIST:"getConversationList",GET_CONVERSATION_PROFILE:"getConversationProfile",DELETE_CONVERSATION:"deleteConversation",PIN_CONVERSATION:"pinConversation",GET_CONVERSATION_LIST_IN_STORAGE:"getConversationListInStorage",SYNC_CONVERSATION_LIST:"syncConversationList",SET_ALL_MESSAGE_READ:"setAllMessageRead",CREATE_GROUP:"createGroup",APPLY_JOIN_GROUP:"applyJoinGroup",QUIT_GROUP:"quitGroup",SEARCH_GROUP_BY_ID:"searchGroupByID",CHANGE_GROUP_OWNER:"changeGroupOwner",HANDLE_GROUP_APPLICATION:"handleGroupApplication",HANDLE_GROUP_INVITATION:"handleGroupInvitation",SET_MESSAGE_REMIND_TYPE:"setMessageRemindType",DISMISS_GROUP:"dismissGroup",UPDATE_GROUP_PROFILE:"updateGroupProfile",GET_GROUP_LIST:"getGroupList",GET_GROUP_PROFILE:"getGroupProfile",GET_GROUP_LIST_IN_STORAGE:"getGroupListInStorage",GET_GROUP_LAST_SEQUENCE:"getGroupLastSequence",GET_GROUP_MISSING_MESSAGE:"getGroupMissingMessage",PAGING_GET_GROUP_LIST:"pagingGetGroupList",PAGING_GET_GROUP_LIST_WITH_TOPIC:"pagingGetGroupListWithTopic",GET_GROUP_SIMPLIFIED_INFO:"getGroupSimplifiedInfo",JOIN_WITHOUT_AUTH:"joinWithoutAuth",INIT_GROUP_ATTRIBUTES:"initGroupAttributes",SET_GROUP_ATTRIBUTES:"setGroupAttributes",DELETE_GROUP_ATTRIBUTES:"deleteGroupAttributes",GET_GROUP_ATTRIBUTES:"getGroupAttributes",GET_GROUP_MEMBER_LIST:"getGroupMemberList",GET_GROUP_MEMBER_PROFILE:"getGroupMemberProfile",ADD_GROUP_MEMBER:"addGroupMember",DELETE_GROUP_MEMBER:"deleteGroupMember",SET_GROUP_MEMBER_MUTE_TIME:"setGroupMemberMuteTime",SET_GROUP_MEMBER_NAME_CARD:"setGroupMemberNameCard",SET_GROUP_MEMBER_ROLE:"setGroupMemberRole",SET_GROUP_MEMBER_CUSTOM_FIELD:"setGroupMemberCustomField",GET_GROUP_ONLINE_MEMBER_COUNT:"getGroupOnlineMemberCount",SYNC_MESSAGE:"syncMessage",LONG_POLLING_AV_ERROR:"longPollingAVError",MESSAGE_LOSS:"messageLoss",MESSAGE_STACKED:"messageStacked",GET_USER_PROFILE:"getUserProfile",UPDATE_MY_PROFILE:"updateMyProfile",GET_BLACKLIST:"getBlacklist",ADD_TO_BLACKLIST:"addToBlacklist",REMOVE_FROM_BLACKLIST:"removeFromBlacklist",ADD_FRIEND:"addFriend",CHECK_FRIEND:"checkFriend",DELETE_FRIEND:"removeFromFriendList",GET_FRIEND_PROFILE:"getFriendProfile",GET_FRIEND_LIST:"getFriendList",UPDATE_FRIEND:"updateFriend",GET_FRIEND_APPLICATION_LIST:"getFriendApplicationList",DELETE_FRIEND_APPLICATION:"deleteFriendApplication",ACCEPT_FRIEND_APPLICATION:"acceptFriendApplication",REFUSE_FRIEND_APPLICATION:"refuseFriendApplication",SET_FRIEND_APPLICATION_READ:"setFriendApplicationRead",CREATE_FRIEND_GROUP:"createFriendGroup",DELETE_FRIEND_GROUP:"deleteFriendGroup",RENAME_FRIEND_GROUP:"renameFriendGroup",ADD_TO_FRIEND_GROUP:"addToFriendGroup",REMOVE_FROM_FRIEND_GROUP:"removeFromFriendGroup",GET_FRIEND_GROUP_LIST:"getFriendGroupList",CREATE_TOPIC:"createTopic",DELETE_TOPIC:"deleteTopic",UPDATE_TOPIC_PROFILE:"updateTopicProfile",GET_TOPIC_LIST:"getTopicList",RELAY_GET_TOPIC_LIST:"relayGetTopicList",GET_TOPIC_LAST_SEQUENCE:"getTopicLastSequence",MP_HIDE_TO_SHOW:"mpHideToShow",CALLBACK_FUNCTION_ERROR:"callbackFunctionError",FETCH_CLOUD_CONTROL_CONFIG:"fetchCloudControlConfig",PUSHED_CLOUD_CONTROL_CONFIG:"pushedCloudControlConfig",FETCH_COMMERCIAL_CONFIG:"fetchCommercialConfig",PUSHED_COMMERCIAL_CONFIG:"pushedCommercialConfig",ERROR:"error",LAST_MESSAGE_NOT_EXIST:"lastMessageNotExist"},Ia=function(){function e(t){n(this,e),this.type=D.MSG_TEXT,this.content={text:t.text||""}}return s(e,[{key:"setText",value:function(e){this.content.text=e}},{key:"sendable",value:function(){return 0!==this.content.text.length}}]),e}(),Ea=function(){function e(t){n(this,e),this._imageMemoryURL="",te?this.createImageDataASURLInWXMiniApp(t.file):this.createImageDataASURLInWeb(t.file),this._initImageInfoModel(),this.type=D.MSG_IMAGE,this._percent=0,this.content={imageFormat:t.imageFormat||be.UNKNOWN,uuid:t.uuid,imageInfoArray:[]},this.initImageInfoArray(t.imageInfoArray),this._defaultImage="http://imgcache.qq.com/open/qcloud/video/act/webim-images/default.jpg",this._autoFixUrl()}return s(e,[{key:"_initImageInfoModel",value:function(){var e=this;this._ImageInfoModel=function(t){this.instanceID=dt(9999999),this.sizeType=t.type||0,this.type=0,this.size=t.size||0,this.width=t.width||0,this.height=t.height||0,this.imageUrl=t.url||"",this.url=t.url||e._imageMemoryURL||e._defaultImage},this._ImageInfoModel.prototype={setSizeType:function(e){this.sizeType=e},setType:function(e){this.type=e},setImageUrl:function(e){e&&(this.imageUrl=e)},getImageUrl:function(){return this.imageUrl}}}},{key:"initImageInfoArray",value:function(e){for(var t=0,o=null,n=null;t<=2;)n=Ze(e)||Ze(e[t])?{type:0,size:0,width:0,height:0,url:""}:e[t],(o=new this._ImageInfoModel(n)).setSizeType(t+1),o.setType(t),this.addImageInfo(o),t++;this.updateAccessSideImageInfoArray()}},{key:"updateImageInfoArray",value:function(e){for(var t,o=this.content.imageInfoArray.length,n=0;n1&&(this._percent=1)}},{key:"updateImageFormat",value:function(e){this.content.imageFormat=be[e.toUpperCase()]||be.UNKNOWN}},{key:"createImageDataASURLInWeb",value:function(e){void 0!==e&&e.files.length>0&&(this._imageMemoryURL=window.URL.createObjectURL(e.files[0]))}},{key:"createImageDataASURLInWXMiniApp",value:function(e){e&&e.url&&(this._imageMemoryURL=e.url)}},{key:"replaceImageInfo",value:function(e,t){this.content.imageInfoArray[t]instanceof this._ImageInfoModel||(this.content.imageInfoArray[t]=e)}},{key:"addImageInfo",value:function(e){this.content.imageInfoArray.length>=3||this.content.imageInfoArray.push(e)}},{key:"updateAccessSideImageInfoArray",value:function(){var e=this.content.imageInfoArray,t=e[0],o=t.width,n=void 0===o?0:o,a=t.height,s=void 0===a?0:a;0!==n&&0!==s&&(kt(e),Object.assign(e[2],Lt({originWidth:n,originHeight:s,min:720})))}},{key:"sendable",value:function(){return 0!==this.content.imageInfoArray.length&&(""!==this.content.imageInfoArray[0].imageUrl&&0!==this.content.imageInfoArray[0].size)}}]),e}(),Ta=function(){function e(t){n(this,e),this.type=D.MSG_FACE,this.content=t||null}return s(e,[{key:"sendable",value:function(){return null!==this.content}}]),e}(),Ca=function(){function e(t){n(this,e),this.type=D.MSG_AUDIO,this._percent=0,this.content={downloadFlag:2,second:t.second,size:t.size,url:t.url,remoteAudioUrl:t.url||"",uuid:t.uuid}}return s(e,[{key:"updatePercent",value:function(e){this._percent=e,this._percent>1&&(this._percent=1)}},{key:"updateAudioUrl",value:function(e){this.content.remoteAudioUrl=e}},{key:"sendable",value:function(){return""!==this.content.remoteAudioUrl}}]),e}(),Sa={from:!0,groupID:!0,groupName:!0,to:!0},Da=function(){function e(t){n(this,e),this.type=D.MSG_GRP_TIP,this.content={},this._initContent(t)}return s(e,[{key:"_initContent",value:function(e){var t=this;Object.keys(e).forEach((function(o){switch(o){case"remarkInfo":break;case"groupProfile":t.content.groupProfile={},t._initGroupProfile(e[o]);break;case"operatorInfo":break;case"memberInfoList":case"msgMemberInfo":t._updateMemberList(e[o]);break;case"onlineMemberInfo":break;case"memberNum":t.content[o]=e[o],t.content.memberCount=e[o];break;case"newGroupProfile":t.content.newGroupProfile={},t._initNewGroupProfile(e[o]);break;default:t.content[o]=e[o]}})),this.content.userIDList||(this.content.userIDList=[this.content.operatorID])}},{key:"_initGroupProfile",value:function(e){for(var t=Object.keys(e),o=0;o1&&(this._percent=1)}},{key:"updateFileUrl",value:function(e){this.content.fileUrl=e}},{key:"sendable",value:function(){return""!==this.content.fileUrl&&(""!==this.content.fileName&&0!==this.content.fileSize)}}]),e}(),Ra=function(){function e(t){n(this,e),this.type=D.MSG_CUSTOM,this.content={data:t.data||"",description:t.description||"",extension:t.extension||""}}return s(e,[{key:"setData",value:function(e){return this.content.data=e,this}},{key:"setDescription",value:function(e){return this.content.description=e,this}},{key:"setExtension",value:function(e){return this.content.extension=e,this}},{key:"sendable",value:function(){return 0!==this.content.data.length||0!==this.content.description.length||0!==this.content.extension.length}}]),e}(),La=function(){function e(t){n(this,e),this.type=D.MSG_VIDEO,this._percent=0,this.content={remoteVideoUrl:t.remoteVideoUrl||t.videoUrl||"",videoFormat:t.videoFormat,videoSecond:parseInt(t.videoSecond,10),videoSize:t.videoSize,videoUrl:t.videoUrl,videoDownloadFlag:2,videoUUID:t.videoUUID,thumbUUID:t.thumbUUID,thumbFormat:t.thumbFormat,thumbWidth:t.thumbWidth,snapshotWidth:t.thumbWidth,thumbHeight:t.thumbHeight,snapshotHeight:t.thumbHeight,thumbSize:t.thumbSize,snapshotSize:t.thumbSize,thumbDownloadFlag:2,thumbUrl:t.thumbUrl,snapshotUrl:t.thumbUrl}}return s(e,[{key:"updatePercent",value:function(e){this._percent=e,this._percent>1&&(this._percent=1)}},{key:"updateVideoUrl",value:function(e){e&&(this.content.remoteVideoUrl=e)}},{key:"updateSnapshotInfo",value:function(e){var t=e.snapshotUrl,o=e.snapshotWidth,n=e.snapshotHeight;Vt(t)||(this.content.thumbUrl=this.content.snapshotUrl=t),Vt(o)||(this.content.thumbWidth=this.content.snapshotWidth=Number(o)),Vt(n)||(this.content.thumbHeight=this.content.snapshotHeight=Number(n))}},{key:"sendable",value:function(){return""!==this.content.remoteVideoUrl}}]),e}(),ka=function(){function e(t){n(this,e),this.type=D.MSG_LOCATION;var o=t.description,a=t.longitude,s=t.latitude;this.content={description:o,longitude:a,latitude:s}}return s(e,[{key:"sendable",value:function(){return!0}}]),e}(),Ga=function(){function e(t){if(n(this,e),this.from=t.from,this.messageSender=t.from,this.time=t.time,this.messageSequence=t.sequence,this.clientSequence=t.clientSequence||t.sequence,this.messageRandom=t.random,this.cloudCustomData=t.cloudCustomData||"",t.ID)this.nick=t.nick||"",this.avatar=t.avatar||"",this.messageBody=[{type:t.type,payload:t.payload}],t.conversationType.startsWith(D.CONV_C2C)?this.receiverUserID=t.to:t.conversationType.startsWith(D.CONV_GROUP)&&(this.receiverGroupID=t.to),this.messageReceiver=t.to;else{this.nick=t.nick||"",this.avatar=t.avatar||"",this.messageBody=[];var o=t.elements[0].type,a=t.elements[0].content;this._patchRichMediaPayload(o,a),o===D.MSG_MERGER?this.messageBody.push({type:o,payload:new Pa(a).content}):this.messageBody.push({type:o,payload:a}),t.groupID&&(this.receiverGroupID=t.groupID,this.messageReceiver=t.groupID),t.to&&(this.receiverUserID=t.to,this.messageReceiver=t.to)}}return s(e,[{key:"_patchRichMediaPayload",value:function(e,t){e===D.MSG_IMAGE?t.imageInfoArray.forEach((function(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===D.MSG_VIDEO?!t.remoteVideoUrl&&t.videoUrl&&(t.remoteVideoUrl=t.videoUrl):e===D.MSG_AUDIO?!t.remoteAudioUrl&&t.url&&(t.remoteAudioUrl=t.url):e===D.MSG_FILE&&!t.fileUrl&&t.url&&(t.fileUrl=t.url,t.url=void 0)}}]),e}(),Pa=function(){function e(t){if(n(this,e),this.type=D.MSG_MERGER,this.content={downloadKey:"",pbDownloadKey:"",messageList:[],title:"",abstractList:[],compatibleText:"",version:0,layersOverLimit:!1},t.downloadKey){var o=t.downloadKey,a=t.pbDownloadKey,s=t.title,r=t.abstractList,i=t.compatibleText,c=t.version;this.content.downloadKey=o,this.content.pbDownloadKey=a,this.content.title=s,this.content.abstractList=r,this.content.compatibleText=i,this.content.version=c||0}else if(Vt(t.messageList))1===t.layersOverLimit&&(this.content.layersOverLimit=!0);else{var u=t.messageList,l=t.title,d=t.abstractList,p=t.compatibleText,g=t.version,_=[];u.forEach((function(e){if(!Vt(e)){var t=new Ga(e);_.push(t)}})),this.content.messageList=_,this.content.title=l,this.content.abstractList=d,this.content.compatibleText=p,this.content.version=g||0}we.debug("MergerElement.content:",this.content)}return s(e,[{key:"sendable",value:function(){return!Vt(this.content.messageList)||!Vt(this.content.downloadKey)}}]),e}(),Ua={1:D.MSG_PRIORITY_HIGH,2:D.MSG_PRIORITY_NORMAL,3:D.MSG_PRIORITY_LOW,4:D.MSG_PRIORITY_LOWEST},wa=function(){function e(t){n(this,e),this.ID="",this.conversationID=t.conversationID||null,this.conversationType=t.conversationType||D.CONV_C2C,this.conversationSubType=t.conversationSubType,this.time=t.time||Math.ceil(Date.now()/1e3),this.sequence=t.sequence||0,this.clientSequence=t.clientSequence||t.sequence||0,this.random=t.random||0===t.random?t.random:dt(),this.priority=this._computePriority(t.priority),this.nick=t.nick||"",this.avatar=t.avatar||"",this.isPeerRead=1===t.isPeerRead||!1,this.nameCard="",this._elements=[],this.isPlaceMessage=t.isPlaceMessage||0,this.isRevoked=2===t.isPlaceMessage||8===t.msgFlagBits,this.from=t.from||null,this.to=t.to||null,this.flow="",this.isSystemMessage=t.isSystemMessage||!1,this.protocol=t.protocol||"JSON",this.isResend=!1,this.isRead=!1,this.status=t.status||xt.SUCCESS,this._onlineOnlyFlag=!1,this._groupAtInfoList=[],this._relayFlag=!1,this.atUserList=[],this.cloudCustomData=t.cloudCustomData||"",this.isDeleted=!1,this.isModified=!1,this._isExcludedFromUnreadCount=!(!t.messageControlInfo||1!==t.messageControlInfo.excludedFromUnreadCount),this._isExcludedFromLastMessage=!(!t.messageControlInfo||1!==t.messageControlInfo.excludedFromLastMessage),this.clientTime=t.clientTime||ke()||0,this.senderTinyID=t.senderTinyID||t.tinyID||"",this.readReceiptInfo=t.readReceiptInfo||{readCount:void 0,unreadCount:void 0},this.needReadReceipt=!0===t.needReadReceipt||1===t.needReadReceipt,this.version=t.messageVersion||0,this.reInitialize(t.currentUser),this.extractGroupInfo(t.groupProfile||null),this.handleGroupAtInfo(t)}return s(e,[{key:"elements",get:function(){return we.warn("!!!Message 实例的 elements 属性即将废弃,请尽快修改。使用 type 和 payload 属性处理单条消息,兼容组合消息使用 _elements 属性!!!"),this._elements}},{key:"getElements",value:function(){return this._elements}},{key:"extractGroupInfo",value:function(e){if(null!==e){ze(e.nick)&&(this.nick=e.nick),ze(e.avatar)&&(this.avatar=e.avatar);var t=e.messageFromAccountExtraInformation;Xe(t)&&ze(t.nameCard)&&(this.nameCard=t.nameCard)}}},{key:"handleGroupAtInfo",value:function(e){var t=this;e.payload&&e.payload.atUserList&&e.payload.atUserList.forEach((function(e){e!==D.MSG_AT_ALL?(t._groupAtInfoList.push({groupAtAllFlag:0,groupAtUserID:e}),t.atUserList.push(e)):(t._groupAtInfoList.push({groupAtAllFlag:1}),t.atUserList.push(D.MSG_AT_ALL))})),Qe(e.groupAtInfo)&&e.groupAtInfo.forEach((function(e){0===e.groupAtAllFlag?t.atUserList.push(e.groupAtUserID):1===e.groupAtAllFlag&&t.atUserList.push(D.MSG_AT_ALL)}))}},{key:"getGroupAtInfoList",value:function(){return this._groupAtInfoList}},{key:"_initProxy",value:function(){this._elements[0]&&(this.payload=this._elements[0].content,this.type=this._elements[0].type)}},{key:"reInitialize",value:function(e){e&&(this.status=this.from?xt.SUCCESS:xt.UNSEND,!this.from&&(this.from=e)),this._initFlow(e),this._initSequence(e),this._concatConversationID(e),this.generateMessageID()}},{key:"isSendable",value:function(){return 0!==this._elements.length&&("function"!=typeof this._elements[0].sendable?(we.warn("".concat(this._elements[0].type,' need "boolean : sendable()" method')),!1):this._elements[0].sendable())}},{key:"_initTo",value:function(e){this.conversationType===D.CONV_GROUP&&(this.to=e.groupID)}},{key:"_initSequence",value:function(e){0===this.clientSequence&&e&&(this.clientSequence=function(e){if(!e)return we.error("autoIncrementIndex(string: key) need key parameter"),!1;if(void 0===ht[e]){var t=new Date,o="3".concat(t.getHours()).slice(-2),n="0".concat(t.getMinutes()).slice(-2),a="0".concat(t.getSeconds()).slice(-2);ht[e]=parseInt([o,n,a,"0001"].join("")),o=null,n=null,a=null,we.log("autoIncrementIndex start index:".concat(ht[e]))}return ht[e]++}(e)),0===this.sequence&&this.conversationType===D.CONV_C2C&&(this.sequence=this.clientSequence)}},{key:"generateMessageID",value:function(){this.from===D.CONV_SYSTEM&&(this.senderTinyID="144115198244471703"),this.ID="".concat(this.senderTinyID,"-").concat(this.clientTime,"-").concat(this.random)}},{key:"_initFlow",value:function(e){""!==e&&(e===this.from?(this.flow="out",this.isRead=!0):this.flow="in")}},{key:"_concatConversationID",value:function(e){var t=this.to,o="",n=this.conversationType;n!==D.CONV_SYSTEM?(o=n===D.CONV_C2C?e===this.from?t:this.from:this.to,this.conversationID="".concat(n).concat(o)):this.conversationID=D.CONV_SYSTEM}},{key:"isElement",value:function(e){return e instanceof Ia||e instanceof Ea||e instanceof Ta||e instanceof Ca||e instanceof Oa||e instanceof La||e instanceof Da||e instanceof Aa||e instanceof Ra||e instanceof ka||e instanceof Pa}},{key:"setElement",value:function(e){var t=this;if(this.isElement(e))return this._elements=[e],void this._initProxy();var o=function(e){if(e.type&&e.content)switch(e.type){case D.MSG_TEXT:t.setTextElement(e.content);break;case D.MSG_IMAGE:t.setImageElement(e.content);break;case D.MSG_AUDIO:t.setAudioElement(e.content);break;case D.MSG_FILE:t.setFileElement(e.content);break;case D.MSG_VIDEO:t.setVideoElement(e.content);break;case D.MSG_CUSTOM:t.setCustomElement(e.content);break;case D.MSG_LOCATION:t.setLocationElement(e.content);break;case D.MSG_GRP_TIP:t.setGroupTipElement(e.content);break;case D.MSG_GRP_SYS_NOTICE:t.setGroupSystemNoticeElement(e.content);break;case D.MSG_FACE:t.setFaceElement(e.content);break;case D.MSG_MERGER:t.setMergerElement(e.content);break;default:we.warn(e.type,e.content,"no operation......")}};if(Qe(e))for(var n=0;n1&&void 0!==arguments[1]&&arguments[1];if(e instanceof Ba)return t&&null!==xa&&xa.emit(S.ERROR,e),Promise.reject(e);if(e instanceof Error){var o=new Ba({code:na.UNCAUGHT_ERROR,message:e.message});return t&&null!==xa&&xa.emit(S.ERROR,o),Promise.reject(o)}if(Ze(e)||Ze(e.code)||Ze(e.message))we.error("IMPromise.reject 必须指定code(错误码)和message(错误信息)!!!");else{if($e(e.code)&&ze(e.message)){var n=new Ba(e);return t&&null!==xa&&xa.emit(S.ERROR,n),Promise.reject(n)}we.error("IMPromise.reject code(错误码)必须为数字,message(错误信息)必须为字符串!!!")}},$a=function(e){i(a,e);var o=f(a);function a(e){var t;return n(this,a),(t=o.call(this,e))._className="C2CModule",t._messageFromUnreadDBMap=new Map,t}return s(a,[{key:"onNewC2CMessage",value:function(e){var t=e.dataList,o=e.isInstantMessage,n=e.C2CRemainingUnreadList,a=e.C2CPairUnreadList;we.debug("".concat(this._className,".onNewC2CMessage count:").concat(t.length," isInstantMessage:").concat(o));var s=this._newC2CMessageStoredAndSummary({dataList:t,C2CRemainingUnreadList:n,C2CPairUnreadList:a,isInstantMessage:o}),r=s.conversationOptionsList,i=s.messageList,c=s.isUnreadC2CMessage;(this.filterModifiedMessage(i),r.length>0)&&this.getModule(co).onNewMessage({conversationOptionsList:r,isInstantMessage:o,isUnreadC2CMessage:c});var u=this.filterUnmodifiedMessage(i);o&&u.length>0&&this.emitOuterEvent(S.MESSAGE_RECEIVED,u),i.length=0}},{key:"_newC2CMessageStoredAndSummary",value:function(e){for(var t=e.dataList,o=e.C2CRemainingUnreadList,n=e.C2CPairUnreadList,a=e.isInstantMessage,s=null,r=[],i=[],c={},u=this.getModule(_o),l=this.getModule(Co),d=!1,p=this.getModule(co),g=0,_=t.length;g<_;g++){var h=t[g];h.currentUser=this.getMyUserID(),h.conversationType=D.CONV_C2C,h.isSystemMessage=!!h.isSystemMessage,(Ze(h.nick)||Ze(h.avatar))&&(d=!0,we.debug("".concat(this._className,"._newC2CMessageStoredAndSummary nick or avatar missing!"))),s=new wa(h),h.elements=u.parseElements(h.elements,h.from),s.setElement(h.elements),s.setNickAndAvatar({nick:h.nick,avatar:h.avatar});var f=s.conversationID;if(a){if(1===this._messageFromUnreadDBMap.get(s.ID))continue;var m=!1;if(s.from!==this.getMyUserID()){var M=p.getLatestMessageSentByPeer(f);if(M){var v=M.nick,y=M.avatar;d?s.setNickAndAvatar({nick:v,avatar:y}):v===s.nick&&y===s.avatar||(m=!0)}}else{var I=p.getLatestMessageSentByMe(f);if(I){var E=I.nick,T=I.avatar;E===s.nick&&T===s.avatar||p.modifyMessageSentByMe({conversationID:f,latestNick:s.nick,latestAvatar:s.avatar})}}var C=1===t[g].isModified;if(p.isMessageSentByCurrentInstance(s)?s.isModified=C:C=!1,0===h.msgLifeTime)s._onlineOnlyFlag=!0,i.push(s);else{if(!p.pushIntoMessageList(i,s,C))continue;m&&(p.modifyMessageSentByPeer({conversationID:f,latestNick:s.nick,latestAvatar:s.avatar}),p.updateUserProfileSpecifiedKey({conversationID:f,nick:s.nick,avatar:s.avatar}))}a&&s.clientTime>0&&l.addMessageDelay(s.clientTime)}else this._messageFromUnreadDBMap.set(s.ID,1);if(0!==h.msgLifeTime){if(!1===s._onlineOnlyFlag){var S=p.getLastMessageTime(f);if($e(S)&&s.time0){O=!0;var o=r.find((function(t){return t.conversationID==="C2C".concat(n[e].from)}));o?o.unreadCount=n[e].unreadCount:r.push({conversationID:"C2C".concat(n[e].from),unreadCount:n[e].unreadCount,type:D.CONV_C2C})}},L=0,k=n.length;L0&&(n=e.cloudCustomData);var a=[];if(Xe(t)&&Xe(t.messageControlInfo)){var s=t.messageControlInfo,r=s.excludedFromUnreadCount,i=s.excludedFromLastMessage;!0===r&&a.push("NoUnread"),!0===i&&a.push("NoLastMsg")}return{protocolName:Go,tjgID:this.generateTjgID(e),requestData:{fromAccount:this.getMyUserID(),toAccount:e.to,msgBody:e.getElements(),cloudCustomData:n,msgSeq:e.sequence,msgRandom:e.random,msgLifeTime:this.isOnlineMessage(e,t)?0:void 0,nick:e.nick,avatar:e.avatar,offlinePushInfo:o?{pushFlag:!0===o.disablePush?1:0,title:o.title||"",desc:o.description||"",ext:o.extension||"",apnsInfo:{badgeMode:!0===o.ignoreIOSBadge?1:0},androidInfo:{OPPOChannelID:o.androidOPPOChannelID||""}}:void 0,messageControlInfo:a,clientTime:e.clientTime,needReadReceipt:!0===e.needReadReceipt?1:0}}}},{key:"isOnlineMessage",value:function(e,t){return!(!t||!0!==t.onlineUserOnly)}},{key:"revokeMessage",value:function(e){return this.request({protocolName:Vo,requestData:{msgInfo:{fromAccount:e.from,toAccount:e.to,msgSeq:e.sequence,msgRandom:e.random,msgTimeStamp:e.time}}})}},{key:"deleteMessage",value:function(e){var t=e.to,o=e.keyList;return we.log("".concat(this._className,".deleteMessage toAccount:").concat(t," count:").concat(o.length)),this.request({protocolName:Yo,requestData:{fromAccount:this.getMyUserID(),to:t,keyList:o}})}},{key:"modifyRemoteMessage",value:function(e){var t=e.from,o=e.to,n=e.version,a=void 0===n?0:n,s=e.sequence,r=e.random,i=e.time,c=e.payload,u=e.type,l=e.cloudCustomData;return this.request({protocolName:jo,requestData:{from:t,to:o,version:a,sequence:s,random:r,time:i,elements:[{type:u,content:c}],cloudCustomData:l}})}},{key:"setMessageRead",value:function(e){var t=this,o=e.conversationID,n=e.lastMessageTime,a="".concat(this._className,".setMessageRead");we.log("".concat(a," conversationID:").concat(o," lastMessageTime:").concat(n)),$e(n)||we.warn("".concat(a," 请勿修改 Conversation.lastMessage.lastTime,否则可能会导致已读上报结果不准确"));var s=new va(ya.SET_C2C_MESSAGE_READ);return s.setMessage("conversationID:".concat(o," lastMessageTime:").concat(n)),this.request({protocolName:Ko,requestData:{C2CMsgReaded:{cookie:"",C2CMsgReadedItem:[{toAccount:o.replace("C2C",""),lastMessageTime:n,receipt:1}]}}}).then((function(){s.setNetworkType(t.getNetworkType()).end(),we.log("".concat(a," ok"));var e=t.getModule(co);return e.updateIsReadAfterReadReport({conversationID:o,lastMessageTime:n}),e.updateUnreadCount(o),ba()})).catch((function(e){return t.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];s.setError(e,n,a).end()})),we.log("".concat(a," failed. error:"),e),ja(e)}))}},{key:"getRoamingMessage",value:function(e){var t=this,o="".concat(this._className,".getRoamingMessage"),n=e.peerAccount,a=e.conversationID,s=e.count,r=e.lastMessageTime,i=e.messageKey,c="peerAccount:".concat(n," count:").concat(s||15," lastMessageTime:").concat(r||0," messageKey:").concat(i);we.log("".concat(o," ").concat(c));var u=new va(ya.GET_C2C_ROAMING_MESSAGES);return this.request({protocolName:xo,requestData:{peerAccount:n,count:s||15,lastMessageTime:r||0,messageKey:i}}).then((function(e){var n=e.data,s=n.complete,r=n.messageList,i=n.messageKey,l=n.lastMessageTime;Ze(r)?we.log("".concat(o," ok. complete:").concat(s," but messageList is undefined!")):we.log("".concat(o," ok. complete:").concat(s," count:").concat(r.length)),u.setNetworkType(t.getNetworkType()).setMessage("".concat(c," complete:").concat(s," length:").concat(r.length)).end();var d=t.getModule(co);1===s&&d.setCompleted(a);var p=d.onRoamingMessage(r,a);d.modifyMessageList(a),d.updateIsRead(a),d.updateRoamingMessageKeyAndTime(a,i,l);var g=d.getPeerReadTime(a);if(we.log("".concat(o," update isPeerRead property. conversationID:").concat(a," peerReadTime:").concat(g)),g)d.updateMessageIsPeerReadProperty(a,g);else{var _=a.replace(D.CONV_C2C,"");t.getRemotePeerReadTime([_]).then((function(){d.updateMessageIsPeerReadProperty(a,d.getPeerReadTime(a))}))}var h="";if(p.length>0)h=p[0].ID;else{var f=d.getLocalOldestMessage(a);f&&(h=f.ID)}return we.log("".concat(o," nextReqID:").concat(h," stored message count:").concat(p.length)),{nextReqID:h,storedMessageList:p}})).catch((function(e){return t.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];u.setMessage(c).setError(e,n,a).end()})),we.warn("".concat(o," failed. error:"),e),ja(e)}))}},{key:"getRoamingMessagesHopping",value:function(e){var t=this,o="".concat(this._className,".getRoamingMessagesHopping"),n=e.peerAccount,a=e.time,s=void 0===a?0:a,r=e.count,i=e.direction,c="peerAccount:".concat(n," count:").concat(r," time:").concat(s," direction:").concat(i);we.log("".concat(o," ").concat(c));var u=new va(ya.GET_C2C_ROAMING_MESSAGES_HOPPING);return this.request({protocolName:xo,requestData:{peerAccount:n,count:r,lastMessageTime:s,direction:i}}).then((function(e){var a=e.data,s=a.complete,r=a.messageList,i=void 0===r?[]:r;we.log("".concat(o," ok. complete:").concat(s," count:").concat(i.length)),u.setNetworkType(t.getNetworkType()).setMessage("".concat(c," complete:").concat(s," length:").concat(i.length)).end();var l="".concat(D.CONV_C2C).concat(n),d=t.getModule(co).onRoamingMessage(i,l,!1);return t._modifyMessageList(l,d),d})).catch((function(e){return t.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];u.setMessage(c).setError(e,n,a).end()})),we.warn("".concat(o," failed. error:"),e),ja(e)}))}},{key:"_modifyMessageList",value:function(e,t){var o=this.getModule(co).getLocalConversation(e);if(o)for(var n=o.userProfile.nick,a=o.userProfile.avatar,s=this.getModule(oo).getNickAndAvatarByUserID(this.getMyUserID()),r=s.nick,i=s.avatar,c=t.length-1;c>=0;c--){var u=t[c];"in"===u.flow&&(u.nick!==n&&u.setNickAndAvatar({nick:n}),u.avatar!==a&&u.setNickAndAvatar({avatar:a})),"out"===u.flow&&(u.nick!==r&&u.setNickAndAvatar({nick:r}),u.avatar!==i&&u.setNickAndAvatar({avatar:i}))}}},{key:"getRemotePeerReadTime",value:function(e){var t=this,o="".concat(this._className,".getRemotePeerReadTime");if(Vt(e))return we.warn("".concat(o," userIDList is empty!")),Promise.resolve();var n=new va(ya.GET_PEER_READ_TIME);return we.log("".concat(o," userIDList:").concat(e)),this.request({protocolName:Wo,requestData:{userIDList:e}}).then((function(a){var s=a.data.peerReadTimeList;we.log("".concat(o," ok. peerReadTimeList:").concat(s));for(var r="",i=t.getModule(co),c=0;c0&&i.recordPeerReadTime("C2C".concat(e[c]),s[c]);n.setNetworkType(t.getNetworkType()).setMessage(r).end()})).catch((function(e){t.probeNetwork().then((function(t){var o=m(t,2),a=o[0],s=o[1];n.setError(e,a,s).end()})),we.warn("".concat(o," failed. error:"),e)}))}},{key:"sendReadReceipt",value:function(e){var t=this,o=e[0].conversationID.replace(D.CONV_C2C,""),n=new va(ya.SEND_C2C_READ_RECEIPT);n.setMessage("peerAccount:".concat(o));var a=this.getMyUserID(),s=e.filter((function(e){return e.from!==a&&!0===e.needReadReceipt})).map((function(e){return{fromAccount:e.from,toAccount:e.to,sequence:e.sequence,random:e.random,time:e.time,clientTime:e.clientTime}}));if(0===s.length)return ja({code:na.READ_RECEIPT_MESSAGE_LIST_EMPTY,message:aa.READ_RECEIPT_MESSAGE_LIST_EMPTY});var r="".concat(this._className,".sendReadReceipt");return we.log("".concat(r,". peerAccount:").concat(o," messageInfoList length:").concat(s.length)),this.request({protocolName:Mn,requestData:{peerAccount:o,messageInfoList:s}}).then((function(e){return n.end(),we.log("".concat(r," ok")),ba()})).catch((function(e){return t.probeNetwork().then((function(t){var o=m(t,2),a=o[0],s=o[1];n.setError(e,a,s).end()})),we.warn("".concat(r," failed. error:"),e),ja(e)}))}},{key:"getReadReceiptList",value:function(e){var t="".concat(this._className,".getReadReceiptList"),o=this.getMyUserID(),n=e.filter((function(e){return e.from===o&&!0===e.needReadReceipt}));return we.log("".concat(t," userID:").concat(o," messageList length:").concat(n.length)),Ya({messageList:n})}},{key:"reset",value:function(){we.log("".concat(this._className,".reset")),this._messageFromUnreadDBMap.clear()}}]),a}(Do),za=function(){function e(){n(this,e),this.list=new Map,this._className="MessageListHandler",this._latestMessageSentByPeerMap=new Map,this._latestMessageSentByMeMap=new Map,this._groupLocalLastMessageSequenceMap=new Map}return s(e,[{key:"getLocalOldestMessageByConversationID",value:function(e){if(!e)return null;if(!this.list.has(e))return null;var t=this.list.get(e).values();return t?t.next().value:null}},{key:"pushIn",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],o=e.conversationID,n=!0;this.list.has(o)||this.list.set(o,new Map);var a=this._getUniqueIDOfMessage(e),s=this.list.get(o).has(a);if(s){var r=this.list.get(o).get(a);if(!t||!0===r.isModified)return n=!1}return this.list.get(o).set(a,e),this._setLatestMessageSentByPeer(o,e),this._setLatestMessageSentByMe(o,e),this._setGroupLocalLastMessageSequence(o,e),n}},{key:"unshift",value:function(e,t){var o;if(Qe(e)){if(e.length>0){o=e[0].conversationID;var n=e.length;this._unshiftMultipleMessages(e,t),this._setGroupLocalLastMessageSequence(o,e[n-1])}}else o=e.conversationID,this._unshiftSingleMessage(e,t),this._setGroupLocalLastMessageSequence(o,e);if(o&&o.startsWith(D.CONV_C2C)){var a=Array.from(this.list.get(o).values()),s=a.length;if(0===s)return;for(var r=s-1;r>=0;r--)if("out"===a[r].flow){this._setLatestMessageSentByMe(o,a[r]);break}for(var i=s-1;i>=0;i--)if("in"===a[i].flow){this._setLatestMessageSentByPeer(o,a[i]);break}}}},{key:"_unshiftSingleMessage",value:function(e,t){var o=e.conversationID,n=this._getUniqueIDOfMessage(e);if(!this.list.has(o))return this.list.set(o,new Map),this.list.get(o).set(n,e),void t.push(e);var a=this.list.get(o),s=Array.from(a);a.has(n)||(s.unshift([n,e]),this.list.set(o,new Map(s)),t.push(e))}},{key:"_unshiftMultipleMessages",value:function(e,t){for(var o=e.length,n=[],a=e[0].conversationID,s=this.list.get(a),r=this.list.has(a)?Array.from(s):[],i=0;i=0;l--)"in"===s[l].flow&&((i=s[l]).nick!==o&&(i.setNickAndAvatar({nick:o}),u=!0),i.avatar!==n&&(i.setNickAndAvatar({avatar:n}),u=!0),u&&(c+=1));we.log("".concat(this._className,".modifyMessageSentByPeer conversationID:").concat(t," count:").concat(c))}}}},{key:"modifyMessageSentByMe",value:function(e){var t=e.conversationID,o=e.latestNick,n=e.latestAvatar,a=this.list.get(t);if(!Vt(a)){var s=Array.from(a.values()),r=s.length;if(0!==r){for(var i=null,c=0,u=!1,l=r-1;l>=0;l--)"out"===s[l].flow&&((i=s[l]).nick!==o&&(i.setNickAndAvatar({nick:o}),u=!0),i.avatar!==n&&(i.setNickAndAvatar({avatar:n}),u=!0),u&&(c+=1));we.log("".concat(this._className,".modifyMessageSentByMe conversationID:").concat(t," count:").concat(c))}}}},{key:"getLocalMessageListHopping",value:function(e){var t=e.conversationID,o=e.sequence,n=e.time,a=e.count,s=e.direction,r=this.getLocalMessageList(t),i=-1;if(t.startsWith(D.CONV_C2C)?i=r.findIndex((function(e){return e.time===n})):t.startsWith(D.CONV_GROUP)&&(i=r.findIndex((function(e){return e.sequence===o}))),-1===i)return[];var c=i+1,u=c>a?c-a:0;return 1===s&&(u=i,c=i+a),r.slice(u,c)}},{key:"getConversationIDList",value:function(e){return M(this.list.keys()).filter((function(t){return t.startsWith(e)}))}},{key:"traversal",value:function(){if(0!==this.list.size&&-1===we.getLevel()){console.group("conversationID-messageCount");var e,t=C(this.list);try{for(t.s();!(e=t.n()).done;){var o=m(e.value,2),n=o[0],a=o[1];console.log("".concat(n,"-").concat(a.size))}}catch(s){t.e(s)}finally{t.f()}console.groupEnd()}}},{key:"onMessageModified",value:function(e,t){if(!this.list.has(e))return{isUpdated:!1,message:null};var o=this._getUniqueIDOfMessage(t),n=this.list.get(e).has(o);if(we.debug("".concat(this._className,".onMessageModified conversationID:").concat(e," uniqueID:").concat(o," has:").concat(n)),n){var a=this.list.get(e).get(o),s=t.messageVersion,r=t.elements,i=t.cloudCustomData;return a.version1&&void 0!==arguments[1]&&arguments[1];if(e)return this._isReady?void(t?e.call(this):setTimeout(e,1)):(this._readyQueue=this._readyQueue||[],void this._readyQueue.push(e))},t.triggerReady=function(){var e=this;this._isReady=!0,setTimeout((function(){var t=e._readyQueue;e._readyQueue=[],t&&t.length>0&&t.forEach((function(e){e.call(this)}),e)}),1)},t.resetReady=function(){this._isReady=!1,this._readyQueue=[]},t.isReady=function(){return this._isReady}};var es=["jpg","jpeg","gif","png","bmp","image","webp"],ts=["mp4"],os=1,ns=2,as=3,ss=255,rs=function(){function e(t){var o=this;n(this,e),Vt(t)||(this.userID=t.userID||"",this.nick=t.nick||"",this.gender=t.gender||"",this.birthday=t.birthday||0,this.location=t.location||"",this.selfSignature=t.selfSignature||"",this.allowType=t.allowType||D.ALLOW_TYPE_ALLOW_ANY,this.language=t.language||0,this.avatar=t.avatar||"",this.messageSettings=t.messageSettings||0,this.adminForbidType=t.adminForbidType||D.FORBID_TYPE_NONE,this.level=t.level||0,this.role=t.role||0,this.lastUpdatedTime=0,this.profileCustomField=[],Vt(t.profileCustomField)||t.profileCustomField.forEach((function(e){o.profileCustomField.push({key:e.key,value:e.value})})))}return s(e,[{key:"validate",value:function(e){var t=!0,o="";if(Vt(e))return{valid:!1,tips:"empty options"};if(e.profileCustomField)for(var n=e.profileCustomField.length,a=null,s=0;s500&&(o="nick name limited: must less than or equal to ".concat(500," bytes, current size: ").concat(lt(e[r])," bytes"),t=!1);break;case"gender":_t(qe,e.gender)||(o="key:gender, invalid value:"+e.gender,t=!1);break;case"birthday":$e(e.birthday)||(o="birthday should be a number",t=!1);break;case"location":ze(e.location)||(o="location should be a string",t=!1);break;case"selfSignature":ze(e.selfSignature)||(o="selfSignature should be a string",t=!1);break;case"allowType":_t(Ke,e.allowType)||(o="key:allowType, invalid value:"+e.allowType,t=!1);break;case"language":$e(e.language)||(o="language should be a number",t=!1);break;case"avatar":ze(e.avatar)||(o="avatar should be a string",t=!1);break;case"messageSettings":0!==e.messageSettings&&1!==e.messageSettings&&(o="messageSettings should be 0 or 1",t=!1);break;case"adminForbidType":_t(Ve,e.adminForbidType)||(o="key:adminForbidType, invalid value:"+e.adminForbidType,t=!1);break;case"level":$e(e.level)||(o="level should be a number",t=!1);break;case"role":$e(e.role)||(o="role should be a number",t=!1);break;default:o="unknown key:"+r+" "+e[r],t=!1}}return{valid:t,tips:o}}}]),e}(),is=s((function e(t){n(this,e),this.value=t,this.next=null})),cs=function(){function e(t){n(this,e),this.MAX_LENGTH=t,this.pTail=null,this.pNodeToDel=null,this.map=new Map,we.debug("SinglyLinkedList init MAX_LENGTH:".concat(this.MAX_LENGTH))}return s(e,[{key:"set",value:function(e){var t=new is(e);if(this.map.size0&&o.members.forEach((function(e){e.userID===t.selfInfo.userID&&ct(t.selfInfo,e,["sequence"])}))}},{key:"updateSelfInfo",value:function(e){var o={nameCard:e.nameCard,joinTime:e.joinTime,role:e.role,messageRemindType:e.messageRemindType,readedSequence:e.readedSequence,excludedUnreadSequenceList:e.excludedUnreadSequenceList};ct(this.selfInfo,t({},o),[],["",null,void 0,0,NaN])}},{key:"setSelfNameCard",value:function(e){this.selfInfo.nameCard=e}}]),e}(),ds=function(e){return Ze(e)?{lastTime:0,lastSequence:0,fromAccount:0,messageForShow:"",payload:null,type:"",isRevoked:!1,cloudCustomData:"",onlineOnlyFlag:!1,nick:"",nameCard:"",version:0,isPeerRead:!1}:e instanceof wa?{lastTime:e.time||0,lastSequence:e.sequence||0,fromAccount:e.from||"",messageForShow:Ft(e.type,e.payload),payload:e.payload||null,type:e.type||null,isRevoked:e.isRevoked||!1,cloudCustomData:e.cloudCustomData||"",onlineOnlyFlag:e._onlineOnlyFlag||!1,nick:e.nick||"",nameCard:e.nameCard||"",version:e.version||0,isPeerRead:e.isPeerRead||!1}:t(t({},e),{},{messageForShow:Ft(e.type,e.payload)})},ps=function(){function e(t){n(this,e),this.conversationID=t.conversationID||"",this.unreadCount=t.unreadCount||0,this.type=t.type||"",this.lastMessage=ds(t.lastMessage),t.lastMsgTime&&(this.lastMessage.lastTime=t.lastMsgTime),this._isInfoCompleted=!1,this.peerReadTime=t.peerReadTime||0,this.groupAtInfoList=[],this.remark="",this.isPinned=t.isPinned||!1,this.messageRemindType="",this._initProfile(t)}return s(e,[{key:"toAccount",get:function(){return this.conversationID.startsWith(D.CONV_C2C)?this.conversationID.replace(D.CONV_C2C,""):this.conversationID.startsWith(D.CONV_GROUP)?this.conversationID.replace(D.CONV_GROUP,""):""}},{key:"subType",get:function(){return this.groupProfile?this.groupProfile.type:""}},{key:"_initProfile",value:function(e){var t=this;Object.keys(e).forEach((function(o){switch(o){case"userProfile":t.userProfile=e.userProfile;break;case"groupProfile":t.groupProfile=e.groupProfile}})),Ze(this.userProfile)&&this.type===D.CONV_C2C?this.userProfile=new rs({userID:e.conversationID.replace("C2C","")}):Ze(this.groupProfile)&&this.type===D.CONV_GROUP&&(this.groupProfile=new ls({groupID:e.conversationID.replace("GROUP","")}))}},{key:"updateUnreadCount",value:function(e){var t=e.nextUnreadCount,o=e.isFromGetConversations,n=e.isUnreadC2CMessage;Ze(t)||(It(this.subType)?this.unreadCount=0:o&&this.type===D.CONV_GROUP||o&&this.type===D.CONV_TOPIC||n&&this.type===D.CONV_C2C?this.unreadCount=t:this.unreadCount=this.unreadCount+t)}},{key:"updateLastMessage",value:function(e){this.lastMessage=ds(e)}},{key:"updateGroupAtInfoList",value:function(e){var t,o=(v(t=e.groupAtType)||y(t)||I(t)||T()).slice(0);-1!==o.indexOf(D.CONV_AT_ME)&&-1!==o.indexOf(D.CONV_AT_ALL)&&(o=[D.CONV_AT_ALL_AT_ME]);var n={from:e.from,groupID:e.groupID,topicID:e.topicID,messageSequence:e.sequence,atTypeArray:o,__random:e.__random,__sequence:e.__sequence};this.groupAtInfoList.push(n),we.debug("Conversation.updateGroupAtInfoList conversationID:".concat(this.conversationID),this.groupAtInfoList)}},{key:"clearGroupAtInfoList",value:function(){this.groupAtInfoList.length=0}},{key:"reduceUnreadCount",value:function(){this.unreadCount>=1&&(this.unreadCount-=1)}},{key:"isLastMessageRevoked",value:function(e){var t=e.sequence,o=e.time;return this.type===D.CONV_C2C&&t===this.lastMessage.lastSequence&&o===this.lastMessage.lastTime||this.type===D.CONV_GROUP&&t===this.lastMessage.lastSequence}},{key:"setLastMessageRevoked",value:function(e){this.lastMessage.isRevoked=e}}]),e}(),gs=function(){function e(t){n(this,e),this._conversationModule=t,this._className="MessageRemindHandler",this._updateSequence=0}return s(e,[{key:"getC2CMessageRemindType",value:function(){var e=this,t="".concat(this._className,".getC2CMessageRemindType");return this._conversationModule.request({protocolName:Bo,updateSequence:this._updateSequence}).then((function(o){we.log("".concat(t," ok"));var n=o.data,a=n.updateSequence,s=n.muteFlagList;e._updateSequence=a,e._patchC2CMessageRemindType(s)})).catch((function(e){we.error("".concat(t," failed. error:"),e)}))}},{key:"_patchC2CMessageRemindType",value:function(e){var t=this,o=0,n="";Qe(e)&&e.length>0&&e.forEach((function(e){var a=e.userID,s=e.muteFlag;0===s?n=D.MSG_REMIND_ACPT_AND_NOTE:1===s?n=D.MSG_REMIND_DISCARD:2===s&&(n=D.MSG_REMIND_ACPT_NOT_NOTE),!0===t._conversationModule.patchMessageRemindType({ID:a,isC2CConversation:!0,messageRemindType:n})&&(o+=1)})),we.log("".concat(this._className,"._patchC2CMessageRemindType count:").concat(o))}},{key:"set",value:function(e){return e.groupID?this._setGroupMessageRemindType(e):Qe(e.userIDList)?this._setC2CMessageRemindType(e):void 0}},{key:"_setGroupMessageRemindType",value:function(e){var t=this,o="".concat(this._className,"._setGroupMessageRemindType"),n=e.groupID,a=e.messageRemindType,s="groupID:".concat(n," messageRemindType:").concat(a),r=new va(ya.SET_MESSAGE_REMIND_TYPE);return r.setMessage(s),this._getModule(ro).modifyGroupMemberInfo({groupID:n,messageRemindType:a,userID:this._conversationModule.getMyUserID()}).then((function(){r.setNetworkType(t._conversationModule.getNetworkType()).end(),we.log("".concat(o," ok. ").concat(s));var e=t._getModule(ao).getLocalGroupProfile(n);if(e&&(e.selfInfo.messageRemindType=a),Tt(n)){var i=t._getModule(io),c=bt(n),u=i.getLocalTopic(c,n);return u&&(u.updateSelfInfo({messageRemindType:a}),t._conversationModule.emitOuterEvent(S.TOPIC_UPDATED,{groupID:n,topic:u})),ba({group:e})}return t._conversationModule.patchMessageRemindType({ID:n,isC2CConversation:!1,messageRemindType:a})&&t._emitConversationUpdate(),ba({group:e})})).catch((function(e){return t._conversationModule.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];r.setError(e,n,a).end()})),we.error("".concat(o," failed. error:"),e),ja(e)}))}},{key:"_setC2CMessageRemindType",value:function(e){var t=this,o="".concat(this._className,"._setC2CMessageRemindType"),n=e.userIDList,a=e.messageRemindType,s=n.slice(0,30),r=0;a===D.MSG_REMIND_DISCARD?r=1:a===D.MSG_REMIND_ACPT_NOT_NOTE&&(r=2);var i="userIDList:".concat(s," messageRemindType:").concat(a),c=new va(ya.SET_MESSAGE_REMIND_TYPE);return c.setMessage(i),this._conversationModule.request({protocolName:Ho,requestData:{userIDList:s,muteFlag:r}}).then((function(e){c.setNetworkType(t._conversationModule.getNetworkType()).end();var n=e.data,r=n.updateSequence,i=n.errorList;t._updateSequence=r;var u=[],l=[];Qe(i)&&i.forEach((function(e){u.push(e.userID),l.push({userID:e.userID,code:e.errorCode})}));var d=s.filter((function(e){return-1===u.indexOf(e)}));we.log("".concat(o," ok. successUserIDList:").concat(d," failureUserIDList:").concat(JSON.stringify(l)));var p=0;return d.forEach((function(e){t._conversationModule.patchMessageRemindType({ID:e,isC2CConversation:!0,messageRemindType:a})&&(p+=1)})),p>=1&&t._emitConversationUpdate(),s.length=u.length=0,Ya({successUserIDList:d.map((function(e){return{userID:e}})),failureUserIDList:l})})).catch((function(e){return t._conversationModule.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];c.setError(e,n,a).end()})),we.error("".concat(o," failed. error:"),e),ja(e)}))}},{key:"_getModule",value:function(e){return this._conversationModule.getModule(e)}},{key:"_emitConversationUpdate",value:function(){this._conversationModule.emitConversationUpdate(!0,!1)}},{key:"setUpdateSequence",value:function(e){this._updateSequence=e}},{key:"reset",value:function(){we.log("".concat(this._className,".reset")),this._updateSequence=0}}]),e}(),_s=function(e){i(a,e);var o=f(a);function a(e){var t;return n(this,a),(t=o.call(this,e))._className="ConversationModule",Za.mixin(_(t)),t._messageListHandler=new za,t._messageRemindHandler=new gs(_(t)),t.singlyLinkedList=new cs(100),t._pagingStatus=Wt.NOT_START,t._pagingTimeStamp=0,t._pagingStartIndex=0,t._pagingPinnedTimeStamp=0,t._pagingPinnedStartIndex=0,t._conversationMap=new Map,t._tmpGroupList=[],t._tmpGroupAtTipsList=[],t._peerReadTimeMap=new Map,t._completedMap=new Map,t._roamingMessageKeyAndTimeMap=new Map,t._roamingMessageSequenceMap=new Map,t._remoteGroupReadSequenceMap=new Map,t._initListeners(),t}return s(a,[{key:"_initListeners",value:function(){var e=this.getInnerEmitterInstance();e.on(Ja,this._initLocalConversationList,this),e.on(Qa,this._onProfileUpdated,this)}},{key:"onCheckTimer",value:function(e){e%60==0&&this._messageListHandler.traversal()}},{key:"_initLocalConversationList",value:function(){var e=this,t=new va(ya.GET_CONVERSATION_LIST_IN_STORAGE);we.log("".concat(this._className,"._initLocalConversationList."));var o="",n=this._getStorageConversationList();if(n){for(var a=n.length,s=0;s0&&(e.updateConversationGroupProfile(e._tmpGroupList),e._tmpGroupList.length=0)})),this.syncConversationList()}},{key:"onMessageSent",value:function(e){this._onSendOrReceiveMessage({conversationOptionsList:e.conversationOptionsList,isInstantMessage:!0})}},{key:"onNewMessage",value:function(e){this._onSendOrReceiveMessage(e)}},{key:"_onSendOrReceiveMessage",value:function(e){var t=this,o=e.conversationOptionsList,n=e.isInstantMessage,a=void 0===n||n,s=e.isUnreadC2CMessage,r=void 0!==s&&s;this._isReady?0!==o.length&&(this._getC2CPeerReadTime(o),this._updateLocalConversationList({conversationOptionsList:o,isInstantMessage:a,isUnreadC2CMessage:r,isFromGetConversations:!1}),this._setStorageConversationList(),o.filter((function(e){return e.type===D.CONV_TOPIC})).length>0||this.emitConversationUpdate()):this.ready((function(){t._onSendOrReceiveMessage(e)}))}},{key:"updateConversationGroupProfile",value:function(e){var t=this;if(!Qe(e)||0!==e.length)if(0!==this._conversationMap.size){var o=!1;e.forEach((function(e){var n="GROUP".concat(e.groupID);if(t._conversationMap.has(n)){o=!0;var a=t._conversationMap.get(n);a.groupProfile=JSON.parse(JSON.stringify(e)),a.lastMessage.lastSequence=0;r--)if(!a[r].isDeleted){s=a[r];break}var i=this._conversationMap.get(n);if(i){var c=!1;i.lastMessage.lastSequence===s.sequence&&i.lastMessage.lastTime===s.time||(Vt(s)&&(s=void 0),i.updateLastMessage(s),i.type!==D.CONV_TOPIC&&(c=!0),we.log("".concat(this._className,".onMessageDeleted. update conversationID:").concat(n," with lastMessage:"),i.lastMessage)),n.startsWith(D.CONV_C2C)&&this.updateUnreadCount(n),c&&this.emitConversationUpdate(!0,!1)}}}},{key:"onMessageModified",value:function(e){var t=e.conversationType,o=e.from,n=e.to,a=e.time,s=e.sequence,r=e.elements,i=e.cloudCustomData,c=e.messageVersion,u=this.getMyUserID(),l="".concat(t).concat(n);n===u&&t===D.CONV_C2C&&(l="".concat(t).concat(o));var d=this._messageListHandler.onMessageModified(l,e),p=d.isUpdated,g=d.message;!0===p&&this.emitOuterEvent(S.MESSAGE_MODIFIED,[g]);var _=this._isTopicConversation(l);if(we.log("".concat(this._className,".onMessageModified isUpdated:").concat(p," isTopicMessage:").concat(_," from:").concat(o," to:").concat(n)),_){this.getModule(io).onMessageModified(e)}else{var h=this._conversationMap.get(l);if(h){var f=h.lastMessage;we.debug("".concat(this._className.onMessageModified," lastMessage:"),JSON.stringify(f),"options:",JSON.stringify(e)),f&&f.lastTime===a&&f.lastSequence===s&&f.version!==c&&(f.type=r[0].type,f.payload=r[0].content,f.messageForShow=Ft(f.type,f.payload),f.cloudCustomData=i,f.version=c,this.emitConversationUpdate(!0,!1))}}return g}},{key:"onNewGroupAtTips",value:function(e){var o=this,n=e.dataList,a=null;n.forEach((function(e){e.groupAtTips?a=e.groupAtTips:e.elements&&(a=t(t({},e.elements),{},{sync:!0})),a.__random=e.random,a.__sequence=e.clientSequence,o._tmpGroupAtTipsList.push(a)})),we.debug("".concat(this._className,".onNewGroupAtTips isReady:").concat(this._isReady),this._tmpGroupAtTipsList),this._isReady&&this._handleGroupAtTipsList()}},{key:"_handleGroupAtTipsList",value:function(){var e=this;if(0!==this._tmpGroupAtTipsList.length){var t=!1;this._tmpGroupAtTipsList.forEach((function(o){var n=o.groupID,a=o.from,s=o.topicID,r=void 0===s?void 0:s,i=o.sync,c=void 0!==i&&i;if(a!==e.getMyUserID())if(Ze(r)){var u=e._conversationMap.get("".concat(D.CONV_GROUP).concat(n));u&&(u.updateGroupAtInfoList(o),t=!0)}else{var l=e._conversationMap.get("".concat(D.CONV_GROUP).concat(r));if(l){l.updateGroupAtInfoList(o);var d=e.getModule(io),p=l.groupAtInfoList;d.onConversationProxy({topicID:r,groupAtInfoList:p})}if(Vt(l)&&c)e.updateTopicConversation([{conversationID:"".concat(D.CONV_GROUP).concat(r),type:D.CONV_TOPIC}]),e._conversationMap.get("".concat(D.CONV_GROUP).concat(r)).updateGroupAtInfoList(o)}})),t&&this.emitConversationUpdate(!0,!1),this._tmpGroupAtTipsList.length=0}}},{key:"_getC2CPeerReadTime",value:function(e){var t=this,o=[];if(e.forEach((function(e){t._conversationMap.has(e.conversationID)||e.type!==D.CONV_C2C||o.push(e.conversationID.replace(D.CONV_C2C,""))})),o.length>0){we.debug("".concat(this._className,"._getC2CPeerReadTime userIDList:").concat(o));var n=this.getModule(no);n&&n.getRemotePeerReadTime(o)}}},{key:"_getStorageConversationList",value:function(){return this.getModule(lo).getItem("conversationMap")}},{key:"_setStorageConversationList",value:function(){var e=this.getLocalConversationList().slice(0,20).map((function(e){return{conversationID:e.conversationID,type:e.type,subType:e.subType,lastMessage:e.lastMessage,groupProfile:e.groupProfile,userProfile:e.userProfile}}));this.getModule(lo).setItem("conversationMap",e)}},{key:"emitConversationUpdate",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],o=this.getLocalConversationList();if(t){var n=this.getModule(ao);n&&n.updateGroupLastMessage(o)}e&&this.emitOuterEvent(S.CONVERSATION_LIST_UPDATED)}},{key:"getLocalConversationList",value:function(){return M(this._conversationMap.values()).filter((function(e){return e.type!==D.CONV_TOPIC}))}},{key:"getLocalConversation",value:function(e){return this._conversationMap.get(e)}},{key:"getLocalOldestMessage",value:function(e){return this._messageListHandler.getLocalOldestMessage(e)}},{key:"syncConversationList",value:function(){var e=this,t=new va(ya.SYNC_CONVERSATION_LIST);return this._pagingStatus===Wt.NOT_START&&this._conversationMap.clear(),this._pagingGetConversationList().then((function(o){return e._pagingStatus=Wt.RESOLVED,e._setStorageConversationList(),e._handleC2CPeerReadTime(),e._patchConversationProperties(),t.setMessage(e._conversationMap.size).setNetworkType(e.getNetworkType()).end(),o})).catch((function(o){return e._pagingStatus=Wt.REJECTED,t.setMessage(e._pagingTimeStamp),e.probeNetwork().then((function(e){var n=m(e,2),a=n[0],s=n[1];t.setError(o,a,s).end()})),ja(o)}))}},{key:"_patchConversationProperties",value:function(){var e=this,t=Date.now(),o=this.checkAndPatchRemark(),n=this._messageRemindHandler.getC2CMessageRemindType(),a=this.getModule(ao).getGroupList();Promise.all([o,n,a]).then((function(){var o=Date.now()-t;we.log("".concat(e._className,"._patchConversationProperties ok. cost ").concat(o," ms")),e.emitConversationUpdate(!0,!1)}))}},{key:"_pagingGetConversationList",value:function(){var e=this,t="".concat(this._className,"._pagingGetConversationList");return we.log("".concat(t," timeStamp:").concat(this._pagingTimeStamp," startIndex:").concat(this._pagingStartIndex)+" pinnedTimeStamp:".concat(this._pagingPinnedTimeStamp," pinnedStartIndex:").concat(this._pagingPinnedStartIndex)),this._pagingStatus=Wt.PENDING,this.request({protocolName:$o,requestData:{fromAccount:this.getMyUserID(),timeStamp:this._pagingTimeStamp,startIndex:this._pagingStartIndex,pinnedTimeStamp:this._pagingPinnedTimeStamp,pinnedStartIndex:this._pagingStartIndex,orderType:1}}).then((function(o){var n=o.data,a=n.completeFlag,s=n.conversations,r=void 0===s?[]:s,i=n.timeStamp,c=n.startIndex,u=n.pinnedTimeStamp,l=n.pinnedStartIndex;if(we.log("".concat(t," ok. completeFlag:").concat(a," count:").concat(r.length," isReady:").concat(e._isReady)),r.length>0){var d=e._getConversationOptions(r);e._updateLocalConversationList({conversationOptionsList:d,isFromGetConversations:!0}),e.isLoggedIn()&&e.emitConversationUpdate()}if(!e._isReady){if(!e.isLoggedIn())return Ya();e.triggerReady()}return e._pagingTimeStamp=i,e._pagingStartIndex=c,e._pagingPinnedTimeStamp=u,e._pagingPinnedStartIndex=l,1!==a?e._pagingGetConversationList():(e._handleGroupAtTipsList(),Ya())})).catch((function(o){throw e.isLoggedIn()&&(e._isReady||(we.warn("".concat(t," failed. error:"),o),e.triggerReady())),o}))}},{key:"_updateLocalConversationList",value:function(e){var t,o=e.isFromGetConversations,n=Date.now();t=this._getTmpConversationListMapping(e),this._conversationMap=new Map(this._sortConversationList([].concat(M(t.toBeUpdatedConversationList),M(this._conversationMap)))),o||this._updateUserOrGroupProfile(t.newConversationList),we.debug("".concat(this._className,"._updateLocalConversationList cost ").concat(Date.now()-n," ms"))}},{key:"_getTmpConversationListMapping",value:function(e){for(var t=e.conversationOptionsList,o=e.isFromGetConversations,n=e.isInstantMessage,a=e.isUnreadC2CMessage,s=void 0!==a&&a,r=[],i=[],c=this.getModule(ao),u=this.getModule(so),l=0,d=t.length;l0&&a.getUserProfile({userIDList:o}).then((function(e){var o=e.data;Qe(o)?o.forEach((function(e){t._conversationMap.get("C2C".concat(e.userID)).userProfile=e})):t._conversationMap.get("C2C".concat(o.userID)).userProfile=o})),n.length>0&&s.getGroupProfileAdvance({groupIDList:n,responseFilter:{groupBaseInfoFilter:["Type","Name","FaceUrl"]}}).then((function(e){e.data.successGroupList.forEach((function(e){var o="GROUP".concat(e.groupID);if(t._conversationMap.has(o)){var n=t._conversationMap.get(o);ct(n.groupProfile,e,[],[null,void 0,"",0,NaN]),!n.subType&&e.type&&(n.subType=e.type)}}))}))}}},{key:"_getConversationOptions",value:function(e){var o=this,n=[],a=e.filter((function(e){var t=e.lastMsg;return Xe(t)})).filter((function(e){var t=e.type,o=e.userID;return 1===t&&"@TLS#NOT_FOUND"!==o&&"@TLS#ERROR"!==o||2===t})),s=this.getMyUserID(),r=a.map((function(e){if(1===e.type){var a={userID:e.userID,nick:e.peerNick,avatar:e.peerAvatar};return n.push(a),{conversationID:"C2C".concat(e.userID),type:"C2C",lastMessage:{lastTime:e.time,lastSequence:e.sequence,fromAccount:e.lastC2CMsgFromAccount,messageForShow:e.messageShow,type:e.lastMsg.elements[0]?e.lastMsg.elements[0].type:null,payload:e.lastMsg.elements[0]?e.lastMsg.elements[0].content:null,cloudCustomData:e.lastMsg.cloudCustomData||"",isRevoked:8===e.lastMessageFlag,onlineOnlyFlag:!1,nick:"",nameCard:"",version:0,isPeerRead:e.lastC2CMsgFromAccount===s&&e.time<=e.c2cPeerReadTime},userProfile:new rs(a),peerReadTime:e.c2cPeerReadTime,isPinned:1===e.isPinned,messageRemindType:""}}return{conversationID:"GROUP".concat(e.groupID),type:"GROUP",lastMessage:t(t({lastTime:e.time,lastSequence:e.messageReadSeq+e.unreadCount,fromAccount:e.msgGroupFromAccount,messageForShow:e.messageShow},o._patchTypeAndPayload(e)),{},{cloudCustomData:e.lastMsg.cloudCustomData||"",isRevoked:2===e.lastMessageFlag,onlineOnlyFlag:!1,nick:e.senderNick||"",nameCard:e.senderNameCard||""}),groupProfile:new ls({groupID:e.groupID,name:e.groupNick,avatar:e.groupImage}),unreadCount:e.unreadCount,peerReadTime:0,isPinned:1===e.isPinned,messageRemindType:"",version:0}}));n.length>0&&this.getModule(oo).onConversationsProfileUpdated(n);return r}},{key:"_patchTypeAndPayload",value:function(e){var o=e.lastMsg,n=o.event,a=void 0===n?void 0:n,s=o.elements,r=void 0===s?[]:s,i=o.groupTips,c=void 0===i?{}:i;if(!Ze(a)&&!Vt(c)){var u=new wa(c);u.setElement({type:D.MSG_GRP_TIP,content:t(t({},c.elements),{},{groupProfile:c.groupProfile})});var l=JSON.parse(JSON.stringify(u.payload));return u=null,{type:D.MSG_GRP_TIP,payload:l}}return{type:r[0]?r[0].type:null,payload:r[0]?r[0].content:null}}},{key:"getLocalMessageList",value:function(e){return this._messageListHandler.getLocalMessageList(e)}},{key:"deleteLocalMessage",value:function(e){e instanceof wa&&this._messageListHandler.remove(e)}},{key:"onConversationDeleted",value:function(e){var t=this;we.log("".concat(this._className,".onConversationDeleted")),Qe(e)&&e.forEach((function(e){var o=e.type,n=e.userID,a=e.groupID,s="";1===o?s="".concat(D.CONV_C2C).concat(n):2===o&&(s="".concat(D.CONV_GROUP).concat(a)),t.deleteLocalConversation(s)}))}},{key:"onConversationPinned",value:function(e){var t=this;if(Qe(e)){var o=!1;e.forEach((function(e){var n,a=e.type,s=e.userID,r=e.groupID;1===a?n=t.getLocalConversation("".concat(D.CONV_C2C).concat(s)):2===a&&(n=t.getLocalConversation("".concat(D.CONV_GROUP).concat(r))),n&&(we.log("".concat(t._className,".onConversationPinned conversationID:").concat(n.conversationID," isPinned:").concat(n.isPinned)),n.isPinned||(n.isPinned=!0,o=!0))})),o&&this._sortConversationListAndEmitEvent()}}},{key:"onConversationUnpinned",value:function(e){var t=this;if(Qe(e)){var o=!1;e.forEach((function(e){var n,a=e.type,s=e.userID,r=e.groupID;1===a?n=t.getLocalConversation("".concat(D.CONV_C2C).concat(s)):2===a&&(n=t.getLocalConversation("".concat(D.CONV_GROUP).concat(r))),n&&(we.log("".concat(t._className,".onConversationUnpinned conversationID:").concat(n.conversationID," isPinned:").concat(n.isPinned)),n.isPinned&&(n.isPinned=!1,o=!0))})),o&&this._sortConversationListAndEmitEvent()}}},{key:"getMessageList",value:function(e){var t=this,o=e.conversationID,n=e.nextReqMessageID,a=e.count,s="".concat(this._className,".getMessageList"),r=this.getLocalConversation(o),i="";if(r&&r.groupProfile&&(i=r.groupProfile.type),It(i))return we.log("".concat(s," not available in avchatroom. conversationID:").concat(o)),Ya({messageList:[],nextReqMessageID:"",isCompleted:!0});(Ze(a)||a>15)&&(a=15),this._isFirstGetTopicMessageWithUnJoined(o,n)&&this.removeConversationMessageCache(o);var c=this._computeRemainingCount({conversationID:o,nextReqMessageID:n}),u=this._completedMap.has(o);if(we.log("".concat(s," conversationID:").concat(o," nextReqMessageID:").concat(n)+" remainingCount:".concat(c," count:").concat(a," isCompleted:").concat(u)),this._needGetHistory({conversationID:o,remainingCount:c,count:a}))return this.getHistoryMessages({conversationID:o,nextReqMessageID:n,count:20}).then((function(e){var n=e.nextReqID,a=e.storedMessageList,r=t._completedMap.has(o),i=a;c>0&&(i=t._messageListHandler.getLocalMessageList(o).slice(0,a.length+c));var u={nextReqMessageID:r?"":n,messageList:i,isCompleted:r};return we.log("".concat(s," ret.nextReqMessageID:").concat(u.nextReqMessageID," ret.isCompleted:").concat(u.isCompleted," ret.length:").concat(i.length)),ba(u)}));this.modifyMessageList(o);var l=this._getMessageListFromMemory({conversationID:o,nextReqMessageID:n,count:a});return Ya(l)}},{key:"_getMessageListFromMemory",value:function(e){var t=e.conversationID,o=e.nextReqMessageID,n=e.count,a="".concat(this._className,"._getMessageListFromMemory"),s=this._messageListHandler.getLocalMessageList(t),r=s.length,i=0,c={isCompleted:!1,nextReqMessageID:"",messageList:[]};return o?(i=s.findIndex((function(e){return e.ID===o})))>n?(c.messageList=s.slice(i-n,i),c.nextReqMessageID=s[i-n].ID):(c.messageList=s.slice(0,i),c.isCompleted=!0):r>n?(i=r-n,c.messageList=s.slice(i,r),c.nextReqMessageID=s[i].ID):(c.messageList=s.slice(0,r),c.isCompleted=!0),we.log("".concat(a," conversationID:").concat(t)+" ret.nextReqMessageID:".concat(c.nextReqMessageID," ret.isCompleted:").concat(c.isCompleted," ret.length:").concat(c.messageList.length)),c}},{key:"getMessageListHopping",value:function(e){var t="".concat(this._className,".getMessageListHopping"),o=e.conversationID,n=e.sequence,a=e.time,s=e.count,r=e.direction,i=void 0===r?0:r;(Ze(s)||s>15)&&(s=15);var c=this._messageListHandler.getLocalMessageListHopping({conversationID:o,sequence:n,time:a,count:s,direction:i});if(!Vt(c)){var u=c.length;if(u===s||o.startsWith(D.CONV_GROUP)&&1===c[0].sequence)return we.log("".concat(t,". conversationID:").concat(o," message from memory:").concat(c.length)),Ya({messageList:c});var l=s-u+1,d=1===i?c.pop():c.shift();return this._getRoamingMessagesHopping({conversationID:o,sequence:d.sequence,time:d.time,count:l,direction:i}).then((function(e){var n,a;(we.log("".concat(t,". conversationID:").concat(o," message from memory:").concat(c.length,", message from remote:").concat(e.length)),1===i)?(n=c).push.apply(n,M(e)):(a=c).unshift.apply(a,M(e));if(o.startsWith(D.CONV_C2C)){var s=[];c.forEach((function(e){s.push([e.ID,e])})),c=M(new Map(s).values())}return ba({messageList:c})}))}return this._getRoamingMessagesHopping({conversationID:o,sequence:n,time:a,count:s,direction:i}).then((function(e){return we.log("".concat(t,". conversationID:").concat(o," message from remote:").concat(e.length)),ba({messageList:e})}))}},{key:"_getRoamingMessagesHopping",value:function(e){var t=e.conversationID,o=e.sequence,n=e.time,a=e.count,s=e.direction;if(t.startsWith(D.CONV_C2C)){var r=this.getModule(no),i=t.replace(D.CONV_C2C,"");return r.getRoamingMessagesHopping({peerAccount:i,time:n,count:a,direction:s})}if(t.startsWith(D.CONV_GROUP)){var c=this.getModule(ao),u=t.replace(D.CONV_GROUP,""),l=o;return 1===s&&(l=o+a-1),c.getRoamingMessagesHopping({groupID:u,sequence:l,count:a}).then((function(e){var t=e.findIndex((function(e){return e.sequence===o}));return 1===s?-1===t?[]:e.slice(t):e}))}}},{key:"_computeRemainingCount",value:function(e){var t=e.conversationID,o=e.nextReqMessageID,n=this._messageListHandler.getLocalMessageList(t),a=n.length;if(!o)return a;var s=0;return Ct(t)?s=n.findIndex((function(e){return e.ID===o})):St(t)&&(s=-1!==o.indexOf("-")?n.findIndex((function(e){return e.ID===o})):n.findIndex((function(e){return e.sequence===o}))),-1===s&&(s=0),s}},{key:"_getMessageListSize",value:function(e){return this._messageListHandler.getLocalMessageList(e).length}},{key:"_needGetHistory",value:function(e){var t=e.conversationID,o=e.remainingCount,n=e.count,a=this.getLocalConversation(t),s="";return a&&a.groupProfile&&(s=a.groupProfile.type),!Dt(t)&&!It(s)&&(!(St(t)&&!this._hasLocalGroup(t)&&!this._isTopicConversation(t))&&(o<=n&&!this._completedMap.has(t)))}},{key:"_isTopicConversation",value:function(e){var t=e.replace(D.CONV_GROUP,"");return Tt(t)}},{key:"getHistoryMessages",value:function(e){var t=e.conversationID,o=e.count;if(t===D.CONV_SYSTEM)return Ya();var n=15;o>20&&(n=20);var a=null;if(Ct(t)){var s=this._roamingMessageKeyAndTimeMap.has(t);return(a=this.getModule(no))?a.getRoamingMessage({conversationID:t,peerAccount:t.replace(D.CONV_C2C,""),count:n,lastMessageTime:s?this._roamingMessageKeyAndTimeMap.get(t).lastMessageTime:0,messageKey:s?this._roamingMessageKeyAndTimeMap.get(t).messageKey:""}):ja({code:na.CANNOT_FIND_MODULE,message:aa.CANNOT_FIND_MODULE})}if(St(t)){if(!(a=this.getModule(ao)))return ja({code:na.CANNOT_FIND_MODULE,message:aa.CANNOT_FIND_MODULE});var r=null;this._conversationMap.has(t)&&(r=this._conversationMap.get(t).lastMessage);var i=0;r&&(i=r.lastSequence);var c=this._roamingMessageSequenceMap.get(t);return a.getRoamingMessage({conversationID:t,groupID:t.replace(D.CONV_GROUP,""),count:n,sequence:c||i})}return Ya()}},{key:"patchConversationLastMessage",value:function(e){var t=this.getLocalConversation(e);if(t){var o=t.lastMessage,n=o.messageForShow,a=o.payload;if(Vt(n)||Vt(a)){var s=this._messageListHandler.getLocalMessageList(e);if(0===s.length)return;var r=s[s.length-1];we.log("".concat(this._className,".patchConversationLastMessage conversationID:").concat(e," payload:"),r.payload),t.updateLastMessage(r)}}}},{key:"onRoamingMessage",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],o=arguments.length>1?arguments[1]:void 0,n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],a=o.startsWith(D.CONV_C2C)?D.CONV_C2C:D.CONV_GROUP,s=null,r=[],i=[],c=0,u=e.length,l=null,d=a===D.CONV_GROUP,p=this.getModule(_o),g=function(){c=d?e.length-1:0,u=d?0:e.length},_=function(){d?--c:++c},h=function(){return d?c>=u:c0&&void 0!==arguments[0]?arguments[0]:{},o="".concat(this._className,".setAllMessageRead");t.scope||(t.scope=D.READ_ALL_MSG),we.log("".concat(o," options:"),t);var n=this._createSetAllMessageReadPack(t);if(0===n.readAllC2CMessage&&0===n.groupMessageReadInfoList.length)return Ya();var a=new va(ya.SET_ALL_MESSAGE_READ);return this.request({protocolName:_n,requestData:n}).then((function(o){var n=o.data,s=e._handleAllMessageRead(n);return a.setMessage("scope:".concat(t.scope," failureGroups:").concat(JSON.stringify(s))).setNetworkType(e.getNetworkType()).end(),Ya()})).catch((function(t){return e.probeNetwork().then((function(e){var o=m(e,2),n=o[0],s=o[1];a.setError(t,n,s).end()})),we.warn("".concat(o," failed. error:"),t),ja({code:t&&t.code?t.code:na.MESSAGE_UNREAD_ALL_FAIL,message:t&&t.message?t.message:aa.MESSAGE_UNREAD_ALL_FAIL})}))}},{key:"_getConversationLastMessageSequence",value:function(e){var t=this._messageListHandler.getLocalLastMessage(e.conversationID),o=e.lastMessage.lastSequence;return t&&o0)if(s.type===D.CONV_C2C&&0===o.readAllC2CMessage){if(n===D.READ_ALL_MSG)o.readAllC2CMessage=1;else if(n===D.READ_ALL_C2C_MSG){o.readAllC2CMessage=1;break}}else if(s.type===D.CONV_GROUP&&(n===D.READ_ALL_GROUP_MSG||n===D.READ_ALL_MSG)){var r=this._getConversationLastMessageSequence(s);o.groupMessageReadInfoList.push({groupID:s.groupProfile.groupID,messageSequence:r})}}}catch(i){a.e(i)}finally{a.f()}return o}},{key:"onPushedAllMessageRead",value:function(e){this._handleAllMessageRead(e)}},{key:"_handleAllMessageRead",value:function(e){var t=e.groupMessageReadInfoList,o=e.readAllC2CMessage,n=this._parseGroupReadInfo(t);return this._updateAllConversationUnreadCount({readAllC2CMessage:o})>=1&&this.emitConversationUpdate(!0,!1),n}},{key:"_parseGroupReadInfo",value:function(e){var t=[];if(e&&e.length)for(var o=0,n=e.length;o=1){if(1===o&&i.type===D.CONV_C2C){var c=this._getConversationLastMessageTime(i);this.updateIsReadAfterReadReport({conversationID:r,lastMessageTime:c})}else if(i.type===D.CONV_GROUP){var u=r.replace(D.CONV_GROUP,"");if(this._remoteGroupReadSequenceMap.has(u)){var l=this._remoteGroupReadSequenceMap.get(u),d=this._getConversationLastMessageSequence(i);this.updateIsReadAfterReadReport({conversationID:r,remoteReadSequence:l}),d>=l&&this._remoteGroupReadSequenceMap.delete(u)}}this.updateUnreadCount(r,!1)&&(n+=1)}}}catch(p){a.e(p)}finally{a.f()}return n}},{key:"isRemoteRead",value:function(e){var t=e.conversationID,o=e.sequence,n=t.replace(D.CONV_GROUP,""),a=!1;if(this._remoteGroupReadSequenceMap.has(n)){var s=this._remoteGroupReadSequenceMap.get(n);o<=s&&(a=!0,we.log("".concat(this._className,".isRemoteRead conversationID:").concat(t," messageSequence:").concat(o," remoteReadSequence:").concat(s))),o>=s+10&&this._remoteGroupReadSequenceMap.delete(n)}return a}},{key:"updateIsReadAfterReadReport",value:function(e){var t=e.conversationID,o=e.lastMessageSeq,n=e.lastMessageTime,a=this._messageListHandler.getLocalMessageList(t);if(0!==a.length)for(var s,r=a.length-1;r>=0;r--)if(s=a[r],!(n&&s.time>n||o&&s.sequence>o)){if("in"===s.flow&&s.isRead)break;s.setIsRead(!0)}}},{key:"updateUnreadCount",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],o=!1,n=this.getLocalConversation(e),a=this._messageListHandler.getLocalMessageList(e);if(n){var s=n.unreadCount,r=a.filter((function(e){return!e.isRead&&!e._onlineOnlyFlag&&!e.isDeleted})).length;if(s!==r&&(n.unreadCount=r,o=!0,we.log("".concat(this._className,".updateUnreadCount from ").concat(s," to ").concat(r,", conversationID:").concat(e)),!0===t&&this.emitConversationUpdate(!0,!1)),o&&n.type===D.CONV_TOPIC){var i=n.unreadCount,c=n.groupAtInfoList,u=this.getModule(io),l=e.replace(D.CONV_GROUP,"");u.onConversationProxy({topicID:l,unreadCount:i,groupAtInfoList:c})}return o}}},{key:"updateReadReceiptInfo",value:function(e){var t=this,o=e.userID,n=void 0===o?void 0:o,a=e.groupID,s=void 0===a?void 0:a,r=e.readReceiptList;if(!Vt(r)){var i=[];if(Ze(n)){if(!Ze(s)){var c="".concat(D.CONV_GROUP).concat(s);r.forEach((function(e){var o=e.tinyID,n=e.clientTime,a=e.random,r=e.readCount,u=e.unreadCount,l="".concat(o,"-").concat(n,"-").concat(a),d=t._messageListHandler.getLocalMessage(c,l),p={groupID:s,messageID:l,readCount:0,unreadCount:0};d&&($e(r)&&(d.readReceiptInfo.readCount=r,p.readCount=r),$e(u)&&(d.readReceiptInfo.unreadCount=u,p.unreadCount=u),i.push(p))}))}}else{var u="".concat(D.CONV_C2C).concat(n);r.forEach((function(e){var o=e.tinyID,a=e.clientTime,s=e.random,r="".concat(o,"-").concat(a,"-").concat(s),c=t._messageListHandler.getLocalMessage(u,r);if(c&&!c.isPeerRead){c.isPeerRead=!0;var l={userID:n,messageID:r,isPeerRead:!0};i.push(l)}}))}i.length>0&&this.emitOuterEvent(S.MESSAGE_READ_RECEIPT_RECEIVED,i)}}},{key:"recomputeGroupUnreadCount",value:function(e){var t=e.conversationID,o=e.count,n=this.getLocalConversation(t);if(n){var a=n.unreadCount,s=a-o;s<0&&(s=0),n.unreadCount=s,we.log("".concat(this._className,".recomputeGroupUnreadCount from ").concat(a," to ").concat(s,", conversationID:").concat(t))}}},{key:"updateIsRead",value:function(e){var t=this.getLocalConversation(e),o=this.getLocalMessageList(e);if(t&&0!==o.length&&!Dt(t.type)){for(var n=[],a=0,s=o.length;a0){var o=this._messageListHandler.updateMessageIsPeerReadProperty(e,t);if(o.length>0&&this.emitOuterEvent(S.MESSAGE_READ_BY_PEER,o),this._conversationMap.has(e)){var n=this._conversationMap.get(e).lastMessage;Vt(n)||n.fromAccount===this.getMyUserID()&&n.lastTime<=t&&!n.isPeerRead&&(n.isPeerRead=!0,this.emitConversationUpdate(!0,!1))}}}},{key:"updateMessageIsModifiedProperty",value:function(e){this._messageListHandler.updateMessageIsModifiedProperty(e)}},{key:"setCompleted",value:function(e){we.log("".concat(this._className,".setCompleted. conversationID:").concat(e)),this._completedMap.set(e,!0)}},{key:"updateRoamingMessageKeyAndTime",value:function(e,t,o){this._roamingMessageKeyAndTimeMap.set(e,{messageKey:t,lastMessageTime:o})}},{key:"updateRoamingMessageSequence",value:function(e,t){this._roamingMessageSequenceMap.set(e,t)}},{key:"getConversationList",value:function(e){var t=this,o="".concat(this._className,".getConversationList"),n="pagingStatus:".concat(this._pagingStatus,", local conversation count:").concat(this._conversationMap.size,", options:").concat(e);if(we.log("".concat(o,". ").concat(n)),this._pagingStatus===Wt.REJECTED){var a=new va(ya.GET_CONVERSATION_LIST);return a.setMessage(n),this.syncConversationList().then((function(){a.setNetworkType(t.getNetworkType()).end();var o=t._getConversationList(e);return ba({conversationList:o})})).catch((function(e){return t.probeNetwork().then((function(t){var o=m(t,2),n=o[0],s=o[1];a.setError(e,n,s).end()})),we.error("".concat(o," failed. error:"),e),ja(e)}))}if(0===this._conversationMap.size){var s=new va(ya.GET_CONVERSATION_LIST);return s.setMessage(n),this.syncConversationList().then((function(){s.setNetworkType(t.getNetworkType()).end();var o=t._getConversationList(e);return ba({conversationList:o})})).catch((function(e){return t.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];s.setError(e,n,a).end()})),we.error("".concat(o," failed. error:"),e),ja(e)}))}var r=this._getConversationList(e);return we.log("".concat(o,". returned conversation count:").concat(r.length)),Ya({conversationList:r})}},{key:"_getConversationList",value:function(e){var t=this;if(Ze(e))return this.getLocalConversationList();if(Qe(e)){var o=[];return e.forEach((function(e){if(t._conversationMap.has(e)){var n=t.getLocalConversation(e);o.push(n)}})),o}}},{key:"_handleC2CPeerReadTime",value:function(){var e,t=C(this._conversationMap);try{for(t.s();!(e=t.n()).done;){var o=m(e.value,2),n=o[0],a=o[1];a.type===D.CONV_C2C&&(we.debug("".concat(this._className,"._handleC2CPeerReadTime conversationID:").concat(n," peerReadTime:").concat(a.peerReadTime)),this.recordPeerReadTime(n,a.peerReadTime))}}catch(s){t.e(s)}finally{t.f()}}},{key:"_hasLocalGroup",value:function(e){return this.getModule(ao).hasLocalGroup(e.replace(D.CONV_GROUP,""))}},{key:"getConversationProfile",value:function(e){var t,o=this;if((t=this._conversationMap.has(e)?this._conversationMap.get(e):new ps({conversationID:e,type:e.slice(0,3)===D.CONV_C2C?D.CONV_C2C:D.CONV_GROUP}))._isInfoCompleted||t.type===D.CONV_SYSTEM)return Ya({conversation:t});if(St(e)&&!this._hasLocalGroup(e))return Ya({conversation:t});var n=new va(ya.GET_CONVERSATION_PROFILE),a="".concat(this._className,".getConversationProfile");return we.log("".concat(a,". conversationID:").concat(e," remark:").concat(t.remark," lastMessage:"),t.lastMessage),this._updateUserOrGroupProfileCompletely(t).then((function(s){n.setNetworkType(o.getNetworkType()).setMessage("conversationID:".concat(e," unreadCount:").concat(s.data.conversation.unreadCount)).end();var r=o.getModule(so);if(r&&t.type===D.CONV_C2C){var i=e.replace(D.CONV_C2C,"");if(r.isMyFriend(i)){var c=r.getFriendRemark(i);t.remark!==c&&(t.remark=c,we.log("".concat(a,". conversationID:").concat(e," patch remark:").concat(t.remark)))}}return we.log("".concat(a," ok. conversationID:").concat(e)),s})).catch((function(t){return o.probeNetwork().then((function(o){var a=m(o,2),s=a[0],r=a[1];n.setError(t,s,r).setMessage("conversationID:".concat(e)).end()})),we.error("".concat(a," failed. error:"),t),ja(t)}))}},{key:"_updateUserOrGroupProfileCompletely",value:function(e){var t=this;return e.type===D.CONV_C2C?this.getModule(oo).getUserProfile({userIDList:[e.toAccount]}).then((function(o){var n=o.data;return 0===n.length?ja(new Ba({code:na.USER_OR_GROUP_NOT_FOUND,message:aa.USER_OR_GROUP_NOT_FOUND})):(e.userProfile=n[0],e._isInfoCompleted=!0,t._unshiftConversation(e),Ya({conversation:e}))})):this.getModule(ao).getGroupProfile({groupID:e.toAccount}).then((function(o){return e.groupProfile=o.data.group,e._isInfoCompleted=!0,t._unshiftConversation(e),Ya({conversation:e})}))}},{key:"_unshiftConversation",value:function(e){e instanceof ps&&!this._conversationMap.has(e.conversationID)&&(this._conversationMap=new Map([[e.conversationID,e]].concat(M(this._conversationMap))),this._setStorageConversationList(),this.emitConversationUpdate(!0,!1))}},{key:"_onProfileUpdated",value:function(e){var t=this;e.data.forEach((function(e){var o=e.userID;if(o===t.getMyUserID())t._onMyProfileModified({latestNick:e.nick,latestAvatar:e.avatar});else{var n=t._conversationMap.get("".concat(D.CONV_C2C).concat(o));n&&(n.userProfile=e)}}))}},{key:"deleteConversation",value:function(e){var t=this,o={fromAccount:this.getMyUserID(),toAccount:void 0,type:void 0,toGroupID:void 0};if(!this._conversationMap.has(e)){var n=new Ba({code:na.CONVERSATION_NOT_FOUND,message:aa.CONVERSATION_NOT_FOUND});return ja(n)}var a=this._conversationMap.get(e).type;if(a===D.CONV_C2C)o.type=1,o.toAccount=e.replace(D.CONV_C2C,"");else{if(a!==D.CONV_GROUP){if(a===D.CONV_SYSTEM)return this.getModule(ao).deleteGroupSystemNotice({messageList:this._messageListHandler.getLocalMessageList(e)}),this.deleteLocalConversation(e),Ya({conversationID:e});var s=new Ba({code:na.CONVERSATION_UN_RECORDED_TYPE,message:aa.CONVERSATION_UN_RECORDED_TYPE});return ja(s)}if(!this._hasLocalGroup(e))return this.deleteLocalConversation(e),Ya({conversationID:e});o.type=2,o.toGroupID=e.replace(D.CONV_GROUP,"")}var r=new va(ya.DELETE_CONVERSATION);r.setMessage("conversationID:".concat(e));var i="".concat(this._className,".deleteConversation");return we.log("".concat(i,". conversationID:").concat(e)),this.setMessageRead({conversationID:e}).then((function(){return t.request({protocolName:Jo,requestData:o})})).then((function(){return r.setNetworkType(t.getNetworkType()).end(),we.log("".concat(i," ok")),t.deleteLocalConversation(e),Ya({conversationID:e})})).catch((function(e){return t.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];r.setError(e,n,a).end()})),we.error("".concat(i," failed. error:"),e),ja(e)}))}},{key:"pinConversation",value:function(e){var t=this,o=e.conversationID,n=e.isPinned;if(!this._conversationMap.has(o))return ja({code:na.CONVERSATION_NOT_FOUND,message:aa.CONVERSATION_NOT_FOUND});var a=this.getLocalConversation(o);if(a.isPinned===n)return Ya({conversationID:o});var s=new va(ya.PIN_CONVERSATION);s.setMessage("conversationID:".concat(o," isPinned:").concat(n));var r="".concat(this._className,".pinConversation");we.log("".concat(r,". conversationID:").concat(o," isPinned:").concat(n));var i=null;return Ct(o)?i={type:1,toAccount:o.replace(D.CONV_C2C,"")}:St(o)&&(i={type:2,groupID:o.replace(D.CONV_GROUP,"")}),this.request({protocolName:Xo,requestData:{fromAccount:this.getMyUserID(),operationType:!0===n?1:2,itemList:[i]}}).then((function(){return s.setNetworkType(t.getNetworkType()).end(),we.log("".concat(r," ok")),a.isPinned!==n&&(a.isPinned=n,t._sortConversationListAndEmitEvent()),ba({conversationID:o})})).catch((function(e){return t.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];s.setError(e,n,a).end()})),we.error("".concat(r," failed. error:"),e),ja(e)}))}},{key:"setMessageRemindType",value:function(e){return this._messageRemindHandler.set(e)}},{key:"patchMessageRemindType",value:function(e){var t=e.ID,o=e.isC2CConversation,n=e.messageRemindType,a=!1,s=this.getLocalConversation(o?"".concat(D.CONV_C2C).concat(t):"".concat(D.CONV_GROUP).concat(t));return s&&s.messageRemindType!==n&&(s.messageRemindType=n,a=!0),a}},{key:"onC2CMessageRemindTypeSynced",value:function(e){var t=this;we.debug("".concat(this._className,".onC2CMessageRemindTypeSynced options:"),e),e.dataList.forEach((function(e){if(!Vt(e.muteNotificationsSync)){var o,n=e.muteNotificationsSync,a=n.to,s=n.updateSequence,r=n.muteFlag;t._messageRemindHandler.setUpdateSequence(s),0===r?o=D.MSG_REMIND_ACPT_AND_NOTE:1===r?o=D.MSG_REMIND_DISCARD:2===r&&(o=D.MSG_REMIND_ACPT_NOT_NOTE);var i=0;t.patchMessageRemindType({ID:a,isC2CConversation:!0,messageRemindType:o})&&(i+=1),we.log("".concat(t._className,".onC2CMessageRemindTypeSynced updateCount:").concat(i)),i>=1&&t.emitConversationUpdate(!0,!1)}}))}},{key:"deleteLocalConversation",value:function(e){var t=this._conversationMap.has(e);we.log("".concat(this._className,".deleteLocalConversation conversationID:").concat(e," has:").concat(t)),t&&(this._conversationMap.delete(e),this._roamingMessageKeyAndTimeMap.has(e)&&this._roamingMessageKeyAndTimeMap.delete(e),this._roamingMessageSequenceMap.has(e)&&this._roamingMessageSequenceMap.delete(e),this._setStorageConversationList(),this._messageListHandler.removeByConversationID(e),this._completedMap.delete(e),this.emitConversationUpdate(!0,!1))}},{key:"isMessageSentByCurrentInstance",value:function(e){return!(!this._messageListHandler.hasLocalMessage(e.conversationID,e.ID)&&!this.singlyLinkedList.has(e.random))}},{key:"modifyMessageList",value:function(e){if(e.startsWith(D.CONV_C2C)&&this._conversationMap.has(e)){var t=this._conversationMap.get(e),o=Date.now();this._messageListHandler.modifyMessageSentByPeer({conversationID:e,latestNick:t.userProfile.nick,latestAvatar:t.userProfile.avatar});var n=this.getModule(oo).getNickAndAvatarByUserID(this.getMyUserID());this._messageListHandler.modifyMessageSentByMe({conversationID:e,latestNick:n.nick,latestAvatar:n.avatar}),we.log("".concat(this._className,".modifyMessageList conversationID:").concat(e," cost ").concat(Date.now()-o," ms"))}}},{key:"updateUserProfileSpecifiedKey",value:function(e){we.log("".concat(this._className,".updateUserProfileSpecifiedKey options:"),e);var t=e.conversationID,o=e.nick,n=e.avatar;if(this._conversationMap.has(t)){var a=this._conversationMap.get(t).userProfile;ze(o)&&a.nick!==o&&(a.nick=o),ze(n)&&a.avatar!==n&&(a.avatar=n),this.emitConversationUpdate(!0,!1)}}},{key:"_onMyProfileModified",value:function(e){var o=this,n=this.getLocalConversationList(),a=Date.now();n.forEach((function(n){o.modifyMessageSentByMe(t({conversationID:n.conversationID},e))})),we.log("".concat(this._className,"._onMyProfileModified. modify all messages sent by me, cost ").concat(Date.now()-a," ms"))}},{key:"modifyMessageSentByMe",value:function(e){this._messageListHandler.modifyMessageSentByMe(e)}},{key:"getLatestMessageSentByMe",value:function(e){return this._messageListHandler.getLatestMessageSentByMe(e)}},{key:"modifyMessageSentByPeer",value:function(e){this._messageListHandler.modifyMessageSentByPeer(e)}},{key:"getLatestMessageSentByPeer",value:function(e){return this._messageListHandler.getLatestMessageSentByPeer(e)}},{key:"pushIntoNoticeResult",value:function(e,t){return!(!this._messageListHandler.pushIn(t)||this.singlyLinkedList.has(t.random))&&(e.push(t),!0)}},{key:"getGroupLocalLastMessageSequence",value:function(e){return this._messageListHandler.getGroupLocalLastMessageSequence(e)}},{key:"checkAndPatchRemark",value:function(){var e=Promise.resolve();if(0===this._conversationMap.size)return e;var t=this.getModule(so);if(!t)return e;var o=M(this._conversationMap.values()).filter((function(e){return e.type===D.CONV_C2C}));if(0===o.length)return e;var n=0;return o.forEach((function(e){var o=e.conversationID.replace(D.CONV_C2C,"");if(t.isMyFriend(o)){var a=t.getFriendRemark(o);e.remark!==a&&(e.remark=a,n+=1)}})),we.log("".concat(this._className,".checkAndPatchRemark. c2c conversation count:").concat(o.length,", patched count:").concat(n)),e}},{key:"updateTopicConversation",value:function(e){this._updateLocalConversationList({conversationOptionsList:e,isFromGetConversations:!0})}},{key:"sendReadReceipt",value:function(e){var t=e[0],o=null;return t.conversationType===D.CONV_C2C?o=this._moduleManager.getModule(no):t.conversationType===D.CONV_GROUP&&(o=this._moduleManager.getModule(ao)),o?o.sendReadReceipt(e):ja({code:na.CANNOT_FIND_MODULE,message:aa.CANNOT_FIND_MODULE})}},{key:"getReadReceiptList",value:function(e){var t=e[0],o=null;return t.conversationType===D.CONV_C2C?o=this._moduleManager.getModule(no):t.conversationType===D.CONV_GROUP&&(o=this._moduleManager.getModule(ao)),o?o.getReadReceiptList(e):ja({code:na.CANNOT_FIND_MODULE,message:aa.CANNOT_FIND_MODULE})}},{key:"getLastMessageTime",value:function(e){var t=this.getLocalConversation(e);return t?t.lastMessage.lastTime:0}},{key:"reset",value:function(){we.log("".concat(this._className,".reset")),this._pagingStatus=Wt.NOT_START,this._messageListHandler.reset(),this._messageRemindHandler.reset(),this._roamingMessageKeyAndTimeMap.clear(),this._roamingMessageSequenceMap.clear(),this.singlyLinkedList.reset(),this._peerReadTimeMap.clear(),this._completedMap.clear(),this._conversationMap.clear(),this._pagingTimeStamp=0,this._pagingStartIndex=0,this._pagingPinnedTimeStamp=0,this._pagingPinnedStartIndex=0,this._remoteGroupReadSequenceMap.clear(),this.resetReady()}}]),a}(Do),hs=function(){function e(t){n(this,e),this._groupModule=t,this._className="GroupTipsHandler",this._cachedGroupTipsMap=new Map,this._checkCountMap=new Map,this.MAX_CHECK_COUNT=4,this._getTopicPendingMap=new Map}return s(e,[{key:"onCheckTimer",value:function(e){e%1==0&&this._cachedGroupTipsMap.size>0&&this._checkCachedGroupTips()}},{key:"_checkCachedGroupTips",value:function(){var e=this;this._cachedGroupTipsMap.forEach((function(t,o){var n=e._checkCountMap.get(o),a=e._groupModule.hasLocalGroup(o);we.log("".concat(e._className,"._checkCachedGroupTips groupID:").concat(o," hasLocalGroup:").concat(a," checkCount:").concat(n)),a?(e._notifyCachedGroupTips(o),e._checkCountMap.delete(o),e._groupModule.deleteUnjoinedAVChatRoom(o)):n>=e.MAX_CHECK_COUNT?(e._deleteCachedGroupTips(o),e._checkCountMap.delete(o)):(n++,e._checkCountMap.set(o,n))}))}},{key:"onNewGroupTips",value:function(e){we.debug("".concat(this._className,".onReceiveGroupTips count:").concat(e.dataList.length));var t=this.newGroupTipsStoredAndSummary(e),o=t.eventDataList,n=t.result,a=t.AVChatRoomMessageList;(a.length>0&&this._groupModule.onAVChatRoomMessage(a),o.length>0)&&(this._groupModule.updateNextMessageSeq(o),this._groupModule.getModule(co).onNewMessage({conversationOptionsList:o,isInstantMessage:!0}));n.length>0&&(this._groupModule.emitOuterEvent(S.MESSAGE_RECEIVED,n),this.handleMessageList(n))}},{key:"newGroupTipsStoredAndSummary",value:function(e){for(var o=this,n=e.event,a=e.dataList,s=null,r=[],i=[],c={},u=[],l=function(e,l){var d=Mt(a[e]),p=d.groupProfile,g=p.groupID,_=p.communityType,h=void 0===_?0:_,f=p.topicID,m=void 0===f?void 0:f,M=void 0,v=2===h&&!Vt(m);if(v){M=D.CONV_TOPIC,d.to=m;var y=o._groupModule.getModule(io);y.hasLocalTopic(g,m)||o._getTopicPendingMap.has(m)||(o._getTopicPendingMap.set(m,1),y.getTopicList({groupID:g,topicIDList:[m]}).finally((function(){o._getTopicPendingMap.delete(m)})))}if(2===h&&Vt(m))return"continue";var I=o._groupModule.hasLocalGroup(g);if(!I&&o._groupModule.isUnjoinedAVChatRoom(g))return"continue";if(!I&&!v)return o._cacheGroupTipsAndProbe({groupID:g,event:n,item:d}),"continue";if(o._groupModule.isMessageFromOrToAVChatroom(g))return d.event=n,u.push(d),"continue";d.currentUser=o._groupModule.getMyUserID(),d.conversationType=D.CONV_GROUP,(s=new wa(d)).setElement({type:D.MSG_GRP_TIP,content:t(t({},d.elements),{},{groupProfile:d.groupProfile})}),s.isSystemMessage=!1;var E=o._groupModule.getModule(co),T=s,C=T.conversationID,S=T.sequence;if(6===n)s._onlineOnlyFlag=!0,i.push(s);else if(!E.pushIntoNoticeResult(i,s))return"continue";if(6===n&&E.getLocalConversation(C))return"continue";6!==n&&o._groupModule.getModule(Co).addMessageSequence({key:pa,message:s});var N=E.isRemoteRead({conversationID:C,sequence:S});if(Ze(c[C])){var A=0;"in"===s.flow&&(s._isExcludedFromUnreadCount||s._onlineOnlyFlag||N||(A=1)),c[C]=r.push({conversationID:C,unreadCount:A,type:Ze(M)?s.conversationType:M,subType:s.conversationSubType,lastMessage:s._isExcludedFromLastMessage?"":s})-1}else{var O=c[C];r[O].type=s.conversationType,r[O].subType=s.conversationSubType,r[O].lastMessage=s._isExcludedFromLastMessage?"":s,"in"===s.flow&&(s._isExcludedFromUnreadCount||s._onlineOnlyFlag||N||r[O].unreadCount++)}},d=0,p=a.length;d=0){c.updateSelfInfo({muteTime:d.muteTime}),u=!0;break}}u&&this._groupModule.emitOuterEvent(S.TOPIC_UPDATED,{groupID:i,topic:c})}}},{key:"_onTopicProfileUpdated",value:function(e){var o=e.payload,n=o.groupProfile.groupID,a=o.newTopicInfo;this._groupModule.getModule(io).onTopicProfileUpdated(t({groupID:n,topicID:e.to},a))}},{key:"_cacheGroupTips",value:function(e,t){this._cachedGroupTipsMap.has(e)||this._cachedGroupTipsMap.set(e,[]),this._cachedGroupTipsMap.get(e).push(t)}},{key:"_deleteCachedGroupTips",value:function(e){this._cachedGroupTipsMap.has(e)&&this._cachedGroupTipsMap.delete(e)}},{key:"_notifyCachedGroupTips",value:function(e){var t=this,o=this._cachedGroupTipsMap.get(e)||[];o.forEach((function(e){t.onNewGroupTips(e)})),this._deleteCachedGroupTips(e),we.log("".concat(this._className,"._notifyCachedGroupTips groupID:").concat(e," count:").concat(o.length))}},{key:"_cacheGroupTipsAndProbe",value:function(e){var t=this,o=e.groupID,n=e.event,a=e.item;this._cacheGroupTips(o,{event:n,dataList:[a]}),this._groupModule.getGroupSimplifiedInfo(o).then((function(e){e.type===D.GRP_AVCHATROOM?t._groupModule.hasLocalGroup(o)?t._notifyCachedGroupTips(o):t._groupModule.setUnjoinedAVChatRoom(o):(t._groupModule.updateGroupMap([e]),t._notifyCachedGroupTips(o))})),this._checkCountMap.has(o)||this._checkCountMap.set(o,0),we.log("".concat(this._className,"._cacheGroupTipsAndProbe groupID:").concat(o))}},{key:"reset",value:function(){this._cachedGroupTipsMap.clear(),this._checkCountMap.clear(),this._getTopicPendingMap.clear()}}]),e}(),fs=function(){function e(t){n(this,e),this._groupModule=t,this._className="CommonGroupHandler",this.tempConversationList=null,this._cachedGroupMessageMap=new Map,this._checkCountMap=new Map,this.MAX_CHECK_COUNT=4,this._getTopicPendingMap=new Map,t.getInnerEmitterInstance().once(Ja,this._initGroupList,this)}return s(e,[{key:"onCheckTimer",value:function(e){e%1==0&&this._cachedGroupMessageMap.size>0&&this._checkCachedGroupMessage()}},{key:"_checkCachedGroupMessage",value:function(){var e=this;this._cachedGroupMessageMap.forEach((function(t,o){var n=e._checkCountMap.get(o),a=e._groupModule.hasLocalGroup(o);we.log("".concat(e._className,"._checkCachedGroupMessage groupID:").concat(o," hasLocalGroup:").concat(a," checkCount:").concat(n)),a?(e._notifyCachedGroupMessage(o),e._checkCountMap.delete(o),e._groupModule.deleteUnjoinedAVChatRoom(o)):n>=e.MAX_CHECK_COUNT?(e._deleteCachedGroupMessage(o),e._checkCountMap.delete(o)):(n++,e._checkCountMap.set(o,n))}))}},{key:"_initGroupList",value:function(){var e=this;we.log("".concat(this._className,"._initGroupList"));var t=new va(ya.GET_GROUP_LIST_IN_STORAGE),o=this._groupModule.getStorageGroupList();if(Qe(o)&&o.length>0){o.forEach((function(t){e._groupModule.initGroupMap(t)})),this._groupModule.emitGroupListUpdate(!0,!1);var n=this._groupModule.getLocalGroupList().length;t.setNetworkType(this._groupModule.getNetworkType()).setMessage("group count:".concat(n)).end()}else t.setNetworkType(this._groupModule.getNetworkType()).setMessage("group count:0").end();we.log("".concat(this._className,"._initGroupList ok"))}},{key:"handleUpdateGroupLastMessage",value:function(e){var t="".concat(this._className,".handleUpdateGroupLastMessage");if(we.debug("".concat(t," conversation count:").concat(e.length,", local group count:").concat(this._groupModule.getLocalGroupList().length)),0!==this._groupModule.getGroupMap().size){for(var o,n,a,s=!1,r=0,i=e.length;r0&&this._groupModule.onAVChatRoomMessage(a),this._groupModule.filterModifiedMessage(n),o.length>0)&&(this._groupModule.updateNextMessageSeq(o),this._groupModule.getModule(co).onNewMessage({conversationOptionsList:o,isInstantMessage:!0}));var s=this._groupModule.filterUnmodifiedMessage(n);s.length>0&&this._groupModule.emitOuterEvent(S.MESSAGE_RECEIVED,s),n.length=0}},{key:"_newGroupMessageStoredAndSummary",value:function(e){var t=this,o=e.dataList,n=e.event,a=e.isInstantMessage,s=null,r=[],i=[],c=[],u={},l=this._groupModule.getModule(_o),d=this._groupModule.getModule(Co),p=o.length;p>1&&o.sort((function(e,t){return e.sequence-t.sequence}));for(var g=function(e){var p=Mt(o[e]),g=p.groupProfile,_=g.groupID,h=g.communityType,f=void 0===h?0:h,m=g.topicID,M=void 0===m?void 0:m,v=void 0,y=2===f&&!Vt(M);if(y){v=D.CONV_TOPIC,p.to=M;var I=t._groupModule.getModule(io);I.hasLocalTopic(_,M)||t._getTopicPendingMap.has(M)||(t._getTopicPendingMap.set(M,1),I.getTopicList({groupID:_,topicIDList:[M]}).finally((function(){t._getTopicPendingMap.delete(M)})))}if(2===f&&Vt(M))return"continue";var E=t._groupModule.hasLocalGroup(_);if(!E&&t._groupModule.isUnjoinedAVChatRoom(_))return"continue";if(!E&&!y)return t._cacheGroupMessageAndProbe({groupID:_,event:n,item:p}),"continue";if(t._groupModule.isMessageFromOrToAVChatroom(_))return p.event=n,c.push(p),"continue";p.currentUser=t._groupModule.getMyUserID(),p.conversationType=D.CONV_GROUP,p.isSystemMessage=!!p.isSystemMessage,s=new wa(p),p.elements=l.parseElements(p.elements,p.from),s.setElement(p.elements);var T=1===o[e].isModified,C=t._groupModule.getModule(co);if(C.isMessageSentByCurrentInstance(s)?s.isModified=T:T=!1,1===p.onlineOnlyFlag)s._onlineOnlyFlag=!0,i.push(s);else{if(!C.pushIntoMessageList(i,s,T))return"continue";d.addMessageSequence({key:pa,message:s}),a&&s.clientTime>0&&d.addMessageDelay(s.clientTime);var S=s,N=S.conversationID,A=S.sequence,O=C.isRemoteRead({conversationID:N,sequence:A});if(Ze(u[N])){var R=0;"in"===s.flow&&(s._isExcludedFromUnreadCount||O||(R=1)),u[N]=r.push({conversationID:N,unreadCount:R,type:Ze(v)?s.conversationType:v,subType:s.conversationSubType,lastMessage:s._isExcludedFromLastMessage?"":s})-1}else{var L=u[N];r[L].type=Ze(v)?s.conversationType:v,r[L].subType=s.conversationSubType,r[L].lastMessage=s._isExcludedFromLastMessage?"":s,"in"===s.flow&&(s._isExcludedFromUnreadCount||O||r[L].unreadCount++)}}},_=0;_g),h="offset:".concat(c," totalCount:").concat(p," isCompleted:").concat(_," ")+"currentCount:".concat(l.length," isCommunityRelay:").concat(a);return d.setNetworkType(t._groupModule.getNetworkType()).setMessage("".concat(h)).end(),a||_?!a&&_?(we.log("".concat(o," start to get community list")),c=0,t._pagingGetGroupList({limit:i,offset:c,groupBaseInfoFilter:u,groupList:l,isCommunityRelay:!0})):a&&!_?(c=g,t._pagingGetGroupList({limit:i,offset:c,groupBaseInfoFilter:u,groupList:l,isCommunityRelay:!0})):(we.log("".concat(o," ok. totalCount:").concat(l.length)),ba({groupList:l})):(c=g,t._pagingGetGroupList({limit:i,offset:c,groupBaseInfoFilter:u,groupList:l}))})).catch((function(e){return 11e3!==e.code&&t._groupModule.probeNetwork().then((function(t){var o=m(t,2),n=o[0],s=o[1];d.setMessage("isCommunityRelay:".concat(a)).setError(e,n,s).end()})),a?(11e3===e.code&&(d=null,we.log("".concat(o," ok. community unavailable"))),Ya({groupList:l})):ja(e)}))}},{key:"_pagingGetGroupListWithTopic",value:function(e){var t=this,o="".concat(this._className,"._pagingGetGroupListWithTopic"),n=e.limit,a=e.offset,s=e.groupBaseInfoFilter,r=e.groupList,i=new va(ya.PAGING_GET_GROUP_LIST_WITH_TOPIC);return this._groupModule.request({protocolName:Zo,requestData:{type:D.GRP_COMMUNITY,memberAccount:this._groupModule.getMyUserID(),limit:n,offset:a,responseFilter:{groupBaseInfoFilter:s,selfInfoFilter:["Role","JoinTime","MsgFlag","MsgSeq"]},isSupportTopic:1}}).then((function(e){var c=e.data,u=c.groups,l=void 0===u?[]:u,d=c.totalCount;r.push.apply(r,M(l));var p=a+n,g=!(d>p),_="offset:".concat(a," totalCount:").concat(d," isCompleted:").concat(g," ")+"currentCount:".concat(r.length);return i.setNetworkType(t._groupModule.getNetworkType()).setMessage("".concat(_)).end(),g?(we.log("".concat(o," ok. totalCount:").concat(r.length)),ba({groupList:r})):(a=p,t._pagingGetGroupListWithTopic({limit:n,offset:a,groupBaseInfoFilter:s,groupList:r}))})).catch((function(e){return t._groupModule.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];i.setError(e,n,a).end()})),ja(e)}))}},{key:"_cacheGroupMessage",value:function(e,t){this._cachedGroupMessageMap.has(e)||this._cachedGroupMessageMap.set(e,[]),this._cachedGroupMessageMap.get(e).push(t)}},{key:"_deleteCachedGroupMessage",value:function(e){this._cachedGroupMessageMap.has(e)&&this._cachedGroupMessageMap.delete(e)}},{key:"_notifyCachedGroupMessage",value:function(e){var t=this,o=this._cachedGroupMessageMap.get(e)||[];o.forEach((function(e){t.onNewGroupMessage(e)})),this._deleteCachedGroupMessage(e),we.log("".concat(this._className,"._notifyCachedGroupMessage groupID:").concat(e," count:").concat(o.length))}},{key:"_cacheGroupMessageAndProbe",value:function(e){var t=this,o=e.groupID,n=e.event,a=e.item;this._cacheGroupMessage(o,{event:n,dataList:[a]}),this._groupModule.getGroupSimplifiedInfo(o).then((function(e){e.type===D.GRP_AVCHATROOM?t._groupModule.hasLocalGroup(o)?t._notifyCachedGroupMessage(o):t._groupModule.setUnjoinedAVChatRoom(o):(t._groupModule.updateGroupMap([e]),t._notifyCachedGroupMessage(o))})),this._checkCountMap.has(o)||this._checkCountMap.set(o,0),we.log("".concat(this._className,"._cacheGroupMessageAndProbe groupID:").concat(o))}},{key:"reset",value:function(){this._cachedGroupMessageMap.clear(),this._checkCountMap.clear(),this._getTopicPendingMap.clear(),this._groupModule.getInnerEmitterInstance().once(Ja,this._initGroupList,this)}}]),e}(),ms={1:"init",2:"modify",3:"clear",4:"delete"},Ms=function(){function e(t){n(this,e),this._groupModule=t,this._className="GroupAttributesHandler",this._groupAttributesMap=new Map,this.CACHE_EXPIRE_TIME=3e4,this._groupModule.getInnerEmitterInstance().on(Xa,this._onCloudConfigUpdated,this)}return s(e,[{key:"_onCloudConfigUpdated",value:function(){var e=this._groupModule.getCloudConfig("grp_attr_cache_time");Ze(e)||(this.CACHE_EXPIRE_TIME=Number(e))}},{key:"updateLocalMainSequenceOnReconnected",value:function(){this._groupAttributesMap.forEach((function(e){e.localMainSequence=0}))}},{key:"onGroupAttributesUpdated",value:function(e){var t=this,o=e.groupID,n=e.groupAttributeOption,a=n.mainSequence,s=n.hasChangedAttributeInfo,r=n.groupAttributeList,i=void 0===r?[]:r,c=n.operationType;if(we.log("".concat(this._className,".onGroupAttributesUpdated. groupID:").concat(o," hasChangedAttributeInfo:").concat(s," operationType:").concat(c)),!Ze(c)){if(1===s){if(4===c){var u=[];i.forEach((function(e){u.push(e.key)})),i=M(u),u=null}return this._refreshCachedGroupAttributes({groupID:o,remoteMainSequence:a,groupAttributeList:i,operationType:ms[c]}),void this._emitGroupAttributesUpdated(o)}if(this._groupAttributesMap.has(o)){var l=this._groupAttributesMap.get(o).avChatRoomKey;this._getGroupAttributes({groupID:o,avChatRoomKey:l}).then((function(){t._emitGroupAttributesUpdated(o)}))}}}},{key:"initGroupAttributesCache",value:function(e){var t=e.groupID,o=e.avChatRoomKey;this._groupAttributesMap.set(t,{lastUpdateTime:0,localMainSequence:0,remoteMainSequence:0,attributes:new Map,avChatRoomKey:o}),we.log("".concat(this._className,".initGroupAttributesCache groupID:").concat(t," avChatRoomKey:").concat(o))}},{key:"initGroupAttributes",value:function(e){var t=this,o=e.groupID,n=e.groupAttributes,a=this._checkCachedGroupAttributes({groupID:o,funcName:"initGroupAttributes"});if(!0!==a)return ja(a);var s=this._groupAttributesMap.get(o),r=s.remoteMainSequence,i=s.avChatRoomKey,c=new va(ya.INIT_GROUP_ATTRIBUTES);return c.setMessage("groupID:".concat(o," mainSequence:").concat(r," groupAttributes:").concat(JSON.stringify(n))),this._groupModule.request({protocolName:Nn,requestData:{groupID:o,avChatRoomKey:i,mainSequence:r,groupAttributeList:this._transformGroupAttributes(n)}}).then((function(e){var a=e.data,s=a.mainSequence,r=M(a.groupAttributeList);return r.forEach((function(e){e.value=n[e.key]})),t._refreshCachedGroupAttributes({groupID:o,remoteMainSequence:s,groupAttributeList:r,operationType:"init"}),c.setNetworkType(t._groupModule.getNetworkType()).end(),we.log("".concat(t._className,".initGroupAttributes ok. groupID:").concat(o)),ba({groupAttributes:n})})).catch((function(e){return t._groupModule.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];c.setError(e,n,a).end()})),ja(e)}))}},{key:"setGroupAttributes",value:function(e){var t=this,o=e.groupID,n=e.groupAttributes,a=this._checkCachedGroupAttributes({groupID:o,funcName:"setGroupAttributes"});if(!0!==a)return ja(a);var s=this._groupAttributesMap.get(o),r=s.remoteMainSequence,i=s.avChatRoomKey,c=s.attributes,u=this._transformGroupAttributes(n);u.forEach((function(e){var t=e.key;e.sequence=0,c.has(t)&&(e.sequence=c.get(t).sequence)}));var l=new va(ya.SET_GROUP_ATTRIBUTES);return l.setMessage("groupID:".concat(o," mainSequence:").concat(r," groupAttributes:").concat(JSON.stringify(n))),this._groupModule.request({protocolName:An,requestData:{groupID:o,avChatRoomKey:i,mainSequence:r,groupAttributeList:u}}).then((function(e){var a=e.data,s=a.mainSequence,r=M(a.groupAttributeList);return r.forEach((function(e){e.value=n[e.key]})),t._refreshCachedGroupAttributes({groupID:o,remoteMainSequence:s,groupAttributeList:r,operationType:"modify"}),l.setNetworkType(t._groupModule.getNetworkType()).end(),we.log("".concat(t._className,".setGroupAttributes ok. groupID:").concat(o)),ba({groupAttributes:n})})).catch((function(e){return t._groupModule.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];l.setError(e,n,a).end()})),ja(e)}))}},{key:"deleteGroupAttributes",value:function(e){var t=this,o=e.groupID,n=e.keyList,a=void 0===n?[]:n,s=this._checkCachedGroupAttributes({groupID:o,funcName:"deleteGroupAttributes"});if(!0!==s)return ja(s);var r=this._groupAttributesMap.get(o),i=r.remoteMainSequence,c=r.avChatRoomKey,u=r.attributes,l=M(u.keys()),d=Rn,p="clear",g={groupID:o,avChatRoomKey:c,mainSequence:i};if(a.length>0){var _=[];l=[],d=On,p="delete",a.forEach((function(e){var t=0;u.has(e)&&(t=u.get(e).sequence,l.push(e)),_.push({key:e,sequence:t})})),g.groupAttributeList=_}var h=new va(ya.DELETE_GROUP_ATTRIBUTES);return h.setMessage("groupID:".concat(o," mainSequence:").concat(i," keyList:").concat(a," protocolName:").concat(d)),this._groupModule.request({protocolName:d,requestData:g}).then((function(e){var n=e.data.mainSequence;return t._refreshCachedGroupAttributes({groupID:o,remoteMainSequence:n,groupAttributeList:a,operationType:p}),h.setNetworkType(t._groupModule.getNetworkType()).end(),we.log("".concat(t._className,".deleteGroupAttributes ok. groupID:").concat(o)),ba({keyList:l})})).catch((function(e){return t._groupModule.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];h.setError(e,n,a).end()})),ja(e)}))}},{key:"getGroupAttributes",value:function(e){var t=this,o=e.groupID,n=this._checkCachedGroupAttributes({groupID:o,funcName:"getGroupAttributes"});if(!0!==n)return ja(n);var a=this._groupAttributesMap.get(o),s=a.avChatRoomKey,r=a.lastUpdateTime,i=a.localMainSequence,c=a.remoteMainSequence,u=new va(ya.GET_GROUP_ATTRIBUTES);if(u.setMessage("groupID:".concat(o," localMainSequence:").concat(i," remoteMainSequence:").concat(c," keyList:").concat(e.keyList)),Date.now()-r>=this.CACHE_EXPIRE_TIME||i0)n.forEach((function(e){s.has(e)&&(a[e]=s.get(e).value)}));else{var r,i=C(s.keys());try{for(i.s();!(r=i.n()).done;){var c=r.value;a[c]=s.get(c).value}}catch(u){i.e(u)}finally{i.f()}}return a}},{key:"_refreshCachedGroupAttributes",value:function(e){var t=e.groupID,o=e.remoteMainSequence,n=e.groupAttributeList,a=e.operationType;if(this._groupAttributesMap.has(t)){var s=this._groupAttributesMap.get(t),r=s.localMainSequence;if("get"===a||o-r==1)s.remoteMainSequence=o,s.localMainSequence=o,s.lastUpdateTime=Date.now(),this._updateCachedAttributes({groupAttributes:s,groupAttributeList:n,operationType:a});else{if(r===o)return;s.remoteMainSequence=o}this._groupAttributesMap.set(t,s);var i="operationType:".concat(a," localMainSequence:").concat(r," remoteMainSequence:").concat(o);we.log("".concat(this._className,"._refreshCachedGroupAttributes. ").concat(i))}}},{key:"_updateCachedAttributes",value:function(e){var t=e.groupAttributes,o=e.groupAttributeList,n=e.operationType;"clear"!==n?"delete"!==n?("init"===n&&t.attributes.clear(),o.forEach((function(e){var o=e.key,n=e.value,a=e.sequence;t.attributes.set(o,{value:n,sequence:a})}))):o.forEach((function(e){t.attributes.delete(e)})):t.attributes.clear()}},{key:"_checkCachedGroupAttributes",value:function(e){var t=e.groupID,o=e.funcName;if(this._groupModule.hasLocalGroup(t)&&this._groupModule.getLocalGroupProfile(t).type!==D.GRP_AVCHATROOM){return we.warn("".concat(this._className,"._checkCachedGroupAttributes. ").concat("非直播群不能使用群属性 API")),new Ba({code:na.CANNOT_USE_GRP_ATTR_NOT_AVCHATROOM,message:"非直播群不能使用群属性 API"})}var n=this._groupAttributesMap.get(t);if(Ze(n)){var a="如果 groupID:".concat(t," 是直播群,使用 ").concat(o," 前先使用 joinGroup 接口申请加入群组,详细请参考 https://web.sdk.qcloud.com/im/doc/zh-cn/SDK.html#joinGroup");return we.warn("".concat(this._className,"._checkCachedGroupAttributes. ").concat(a)),new Ba({code:na.CANNOT_USE_GRP_ATTR_AVCHATROOM_UNJOIN,message:a})}return!0}},{key:"_transformGroupAttributes",value:function(e){var t=[];return Object.keys(e).forEach((function(o){t.push({key:o,value:e[o]})})),t}},{key:"_emitGroupAttributesUpdated",value:function(e){var t=this._getLocalGroupAttributes({groupID:e});this._groupModule.emitOuterEvent(S.GROUP_ATTRIBUTES_UPDATED,{groupID:e,groupAttributes:t})}},{key:"reset",value:function(){this._groupAttributesMap.clear(),this.CACHE_EXPIRE_TIME=3e4}}]),e}(),vs=function(){function e(t){n(this,e);var o=t.manager,a=t.groupID,s=t.onInit,r=t.onSuccess,i=t.onFail;this._className="Polling",this._manager=o,this._groupModule=o._groupModule,this._onInit=s,this._onSuccess=r,this._onFail=i,this._groupID=a,this._timeoutID=-1,this._isRunning=!1,this._protocolName=En}return s(e,[{key:"start",value:function(){var e=this._groupModule.isLoggedIn();e||(this._protocolName=Tn),we.log("".concat(this._className,".start pollingInterval:").concat(this._manager.getPollingInterval()," isLoggedIn:").concat(e)),this._isRunning=!0,this._request()}},{key:"isRunning",value:function(){return this._isRunning}},{key:"_request",value:function(){var e=this,t=this._onInit(this._groupID);this._groupModule.request({protocolName:this._protocolName,requestData:t}).then((function(t){e._onSuccess(e._groupID,t),e.isRunning()&&(clearTimeout(e._timeoutID),e._timeoutID=setTimeout(e._request.bind(e),e._manager.getPollingInterval()))})).catch((function(t){e._onFail(e._groupID,t),e.isRunning()&&(clearTimeout(e._timeoutID),e._timeoutID=setTimeout(e._request.bind(e),e._manager.MAX_POLLING_INTERVAL))}))}},{key:"stop",value:function(){we.log("".concat(this._className,".stop")),this._timeoutID>0&&(clearTimeout(this._timeoutID),this._timeoutID=-1),this._isRunning=!1}}]),e}(),ys={3:!0,4:!0,5:!0,6:!0},Is=function(){function e(t){n(this,e),this._groupModule=t,this._className="AVChatRoomHandler",this._joinedGroupMap=new Map,this._pollingRequestInfoMap=new Map,this._pollingInstanceMap=new Map,this.sequencesLinkedList=new cs(200),this.messageIDLinkedList=new cs(100),this.receivedMessageCount=0,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}return s(e,[{key:"hasJoinedAVChatRoom",value:function(){return this._joinedGroupMap.size>0}},{key:"checkJoinedAVChatRoomByID",value:function(e){return this._joinedGroupMap.has(e)}},{key:"getJoinedAVChatRoom",value:function(){return this._joinedGroupMap.size>0?M(this._joinedGroupMap.keys()):null}},{key:"_updateRequestData",value:function(e){return t({},this._pollingRequestInfoMap.get(e))}},{key:"_handleSuccess",value:function(e,t){var o=t.data,n=o.key,a=o.nextSeq,s=o.rspMsgList;if(0!==o.errorCode){var r=this._pollingRequestInfoMap.get(e),i=new va(ya.LONG_POLLING_AV_ERROR),c=r?"".concat(r.key,"-").concat(r.startSeq):"requestInfo is undefined";i.setMessage("".concat(e,"-").concat(c,"-").concat(t.errorInfo)).setCode(t.errorCode).setNetworkType(this._groupModule.getNetworkType()).end(!0)}else{if(!this.checkJoinedAVChatRoomByID(e))return;ze(n)&&$e(a)&&this._pollingRequestInfoMap.set(e,{key:n,startSeq:a}),Qe(s)&&s.length>0?(s.forEach((function(e){e.to=e.groupID})),this.onMessage(s)):(this._pollingNoMessageCount+=1,this._pollingNoMessageCount===this.DEFAULT_POLLING_NO_MESSAGE_COUNT&&(this._pollingInterval=this.DEFAULT_POLLING_INTERVAL+this.DEFAULT_POLLING_INTERVAL_PLUS))}}},{key:"_handleFailure",value:function(e,t){}},{key:"onMessage",value:function(e){if(Qe(e)&&0!==e.length){0!==this._pollingNoMessageCount&&(this._pollingNoMessageCount=0,this._pollingInterval=this.DEFAULT_POLLING_INTERVAL);var t=null,o=[],n=this._getModule(co),a=this._getModule(Co),s=e.length;s>1&&e.sort((function(e,t){return e.sequence-t.sequence}));for(var r=this._getModule(uo),i=0;i1&&p<=20?this._getModule(yo).onMessageMaybeLost(l,d+1,p-1):p<-1&&p>=-20&&this._getModule(yo).onMessageMaybeLost(l,t.sequence+1,Math.abs(p)-1)}this.sequencesLinkedList.set(t.sequence),this.messageIDLinkedList.set(t.ID);var g=!1;if(this._isMessageSentByCurrentInstance(t)?c&&(g=!0,t.isModified=c,n.updateMessageIsModifiedProperty(t)):g=!0,g){if(t.conversationType===D.CONV_SYSTEM&&5===t.payload.operationType&&this._onGroupDismissed(t.payload.groupProfile.groupID),!u&&t.conversationType!==D.CONV_SYSTEM){var _=t.conversationID.replace(D.CONV_GROUP,"");this._pollingInstanceMap.has(_)?a.addMessageSequence({key:_a,message:t}):(t.type!==D.MSG_GRP_TIP&&t.clientTime>0&&a.addMessageDelay(t.clientTime),a.addMessageSequence({key:ga,message:t}))}o.push(t)}}}else we.warn("".concat(this._className,".onMessage 未处理的 event 类型: ").concat(e[i].event));if(0!==o.length){this._groupModule.filterModifiedMessage(o);var h=this.packConversationOption(o);if(h.length>0)this._getModule(co).onNewMessage({conversationOptionsList:h,isInstantMessage:!0});we.debug("".concat(this._className,".onMessage count:").concat(o.length)),this._checkMessageStacked(o);var f=this._groupModule.filterUnmodifiedMessage(o);f.length>0&&this._groupModule.emitOuterEvent(S.MESSAGE_RECEIVED,f),o.length=0}}}},{key:"_onGroupDismissed",value:function(e){we.log("".concat(this._className,"._onGroupDismissed groupID:").concat(e)),this._groupModule.deleteLocalGroupAndConversation(e),this.reset(e)}},{key:"_checkMessageStacked",value:function(e){var t=e.length;t>=100&&(we.warn("".concat(this._className,"._checkMessageStacked 直播群消息堆积数:").concat(e.length,'!可能会导致微信小程序渲染时遇到 "Dom limit exceeded" 的错误,建议接入侧此时只渲染最近的10条消息')),this._reportMessageStackedCount<5&&(new va(ya.MESSAGE_STACKED).setNetworkType(this._groupModule.getNetworkType()).setMessage("count:".concat(t," groupID:").concat(M(this._joinedGroupMap.keys()))).setLevel("warning").end(),this._reportMessageStackedCount+=1))}},{key:"_isMessageSentByCurrentInstance",value:function(e){return!!this._getModule(co).isMessageSentByCurrentInstance(e)}},{key:"packMessage",value:function(e,t){e.currentUser=this._groupModule.getMyUserID(),e.conversationType=5===t?D.CONV_SYSTEM:D.CONV_GROUP,e.isSystemMessage=!!e.isSystemMessage;var o=new wa(e),n=this.packElements(e,t);return o.setElement(n),o}},{key:"packElements",value:function(e,o){return 4===o||6===o?(this._updateMemberCountByGroupTips(e),this._onGroupAttributesUpdated(e),{type:D.MSG_GRP_TIP,content:t(t({},e.elements),{},{groupProfile:e.groupProfile})}):5===o?{type:D.MSG_GRP_SYS_NOTICE,content:t(t({},e.elements),{},{groupProfile:t(t({},e.groupProfile),{},{groupID:e.groupID})})}:this._getModule(_o).parseElements(e.elements,e.from)}},{key:"packConversationOption",value:function(e){for(var t=new Map,o=0;o1e3*t.expireTime&&o-t.latestUpdateTime>1e4&&o-t.lastReqTime>3e3?(t.lastReqTime=o,this._onlineMemberCountMap.set(e,t),this._getGroupOnlineMemberCount(e).then((function(e){return ba({memberCount:e.memberCount})})).catch((function(e){return ja(e)}))):Ya({memberCount:t.memberCount})}},{key:"_getGroupOnlineMemberCount",value:function(e){var t=this,o="".concat(this._className,"._getGroupOnlineMemberCount");return this._groupModule.request({protocolName:Cn,requestData:{groupID:e}}).then((function(n){var a=t._onlineMemberCountMap.get(e)||{},s=n.data,r=s.onlineMemberNum,i=void 0===r?0:r,c=s.expireTime,u=void 0===c?t.DEFAULT_EXPIRE_TIME:c;we.log("".concat(o," ok. groupID:").concat(e," memberCount:").concat(i," expireTime:").concat(u));var l=Date.now();return Vt(a)&&(a.lastReqTime=l),t._onlineMemberCountMap.set(e,Object.assign(a,{lastSyncTime:l,latestUpdateTime:l,memberCount:i,expireTime:u})),{memberCount:i}})).catch((function(n){return we.warn("".concat(o," failed. error:"),n),new va(ya.GET_GROUP_ONLINE_MEMBER_COUNT).setCode(n.code).setMessage("groupID:".concat(e," error:").concat(JSON.stringify(n))).setNetworkType(t._groupModule.getNetworkType()).end(),Promise.reject(n)}))}},{key:"_onGroupAttributesUpdated",value:function(e){var t=e.groupID,o=e.elements,n=o.operationType,a=o.newGroupProfile;if(6===n){var s=(void 0===a?void 0:a).groupAttributeOption;Vt(s)||this._groupModule.onGroupAttributesUpdated({groupID:t,groupAttributeOption:s})}}},{key:"_getModule",value:function(e){return this._groupModule.getModule(e)}},{key:"setPollingInterval",value:function(e){Ze(e)||($e(e)?this._pollingInterval=this.DEFAULT_POLLING_INTERVAL=e:this._pollingInterval=this.DEFAULT_POLLING_INTERVAL=parseInt(e,10))}},{key:"setPollingIntervalPlus",value:function(e){Ze(e)||($e(e)?this.DEFAULT_POLLING_INTERVAL_PLUS=e:this.DEFAULT_POLLING_INTERVAL_PLUS=parseInt(e,10))}},{key:"setPollingNoMessageCount",value:function(e){Ze(e)||($e(e)?this.DEFAULT_POLLING_NO_MESSAGE_COUNT=e:this.DEFAULT_POLLING_NO_MESSAGE_COUNT=parseInt(e,10))}},{key:"getPollingInterval",value:function(){return this._pollingInterval}},{key:"reset",value:function(e){if(e){we.log("".concat(this._className,".reset groupID:").concat(e));var 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{we.log("".concat(this._className,".reset all"));var o,n=C(this._pollingInstanceMap.values());try{for(n.s();!(o=n.n()).done;){o.value.stop()}}catch(a){n.e(a)}finally{n.f()}this._pollingInstanceMap.clear(),this._joinedGroupMap.clear(),this._pollingRequestInfoMap.clear(),this._onlineMemberCountMap.clear()}this.sequencesLinkedList.reset(),this.messageIDLinkedList.reset(),this.receivedMessageCount=0,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}}]),e}(),Es=1,Ts=15,Cs=function(){function e(t){n(this,e),this._groupModule=t,this._className="GroupSystemNoticeHandler",this.pendencyMap=new Map}return s(e,[{key:"onNewGroupSystemNotice",value:function(e){var t=e.dataList,o=e.isSyncingEnded,n=e.isInstantMessage;we.debug("".concat(this._className,".onReceiveSystemNotice count:").concat(t.length));var a=this.newSystemNoticeStoredAndSummary({notifiesList:t,isInstantMessage:n}),s=a.eventDataList,r=a.result;s.length>0&&(this._groupModule.getModule(co).onNewMessage({conversationOptionsList:s,isInstantMessage:n}),this._onReceivedGroupSystemNotice({result:r,isInstantMessage:n}));n?r.length>0&&this._groupModule.emitOuterEvent(S.MESSAGE_RECEIVED,r):!0===o&&this._clearGroupSystemNotice()}},{key:"newSystemNoticeStoredAndSummary",value:function(e){var o=e.notifiesList,n=e.isInstantMessage,a=null,s=o.length,r=0,i=[],c={conversationID:D.CONV_SYSTEM,unreadCount:0,type:D.CONV_SYSTEM,subType:null,lastMessage:null};for(r=0;r0?[c]:[],result:i}}},{key:"_clearGroupSystemNotice",value:function(){var e=this;this.getPendencyList().then((function(t){t.forEach((function(t){e.pendencyMap.set("".concat(t.from,"_").concat(t.groupID,"_").concat(t.to),t)}));var o=e._groupModule.getModule(co).getLocalMessageList(D.CONV_SYSTEM),n=[];o.forEach((function(t){var o=t.payload,a=o.operatorID,s=o.operationType,r=o.groupProfile;if(s===Es){var i="".concat(a,"_").concat(r.groupID,"_").concat(r.to),c=e.pendencyMap.get(i);c&&$e(c.handled)&&0!==c.handled&&n.push(t)}})),e.deleteGroupSystemNotice({messageList:n})}))}},{key:"deleteGroupSystemNotice",value:function(e){var t=this,o="".concat(this._className,".deleteGroupSystemNotice");return Qe(e.messageList)&&0!==e.messageList.length?(we.log("".concat(o," ")+e.messageList.map((function(e){return e.ID}))),this._groupModule.request({protocolName:In,requestData:{messageListToDelete:e.messageList.map((function(e){return{from:D.CONV_SYSTEM,messageSeq:e.clientSequence,messageRandom:e.random}}))}}).then((function(){we.log("".concat(o," ok"));var n=t._groupModule.getModule(co);return e.messageList.forEach((function(e){n.deleteLocalMessage(e)})),ba()})).catch((function(e){return we.error("".concat(o," error:"),e),ja(e)}))):Ya()}},{key:"getPendencyList",value:function(e){var t=this;return this._groupModule.request({protocolName:yn,requestData:{startTime:e&&e.startTime?e.startTime:0,limit:e&&e.limit?e.limit:10,handleAccount:this._groupModule.getMyUserID()}}).then((function(e){var o=e.data.pendencyList;return 0!==e.data.nextStartTime?t.getPendencyList({startTime:e.data.nextStartTime}).then((function(e){return[].concat(M(o),M(e))})):o}))}},{key:"_onReceivedGroupSystemNotice",value:function(e){var t=this,o=e.result;e.isInstantMessage&&o.forEach((function(e){switch(e.payload.operationType){case 1:break;case 2:t._onApplyGroupRequestAgreed(e);break;case 3:break;case 4:t._onMemberKicked(e);break;case 5:t._onGroupDismissed(e);break;case 6:break;case 7:t._onInviteGroup(e);break;case 8:t._onQuitGroup(e);break;case 9:t._onSetManager(e);break;case 10:t._onDeleteManager(e)}}))}},{key:"_onApplyGroupRequestAgreed",value:function(e){var t=this,o=e.payload.groupProfile.groupID;this._groupModule.hasLocalGroup(o)||this._groupModule.getGroupProfile({groupID:o}).then((function(e){var o=e.data.group;if(o){t._groupModule.updateGroupMap([o]);var n=!o.isSupportTopic;t._groupModule.emitGroupListUpdate(!0,n)}}))}},{key:"_onMemberKicked",value:function(e){var t=e.payload.groupProfile.groupID;this._groupModule.hasLocalGroup(t)&&this._groupModule.deleteLocalGroupAndConversation(t)}},{key:"_onGroupDismissed",value:function(e){var t=e.payload.groupProfile.groupID;this._groupModule.hasLocalGroup(t)&&this._groupModule.deleteLocalGroupAndConversation(t);var o=this._groupModule._AVChatRoomHandler;o&&o.checkJoinedAVChatRoomByID(t)&&o.reset(t)}},{key:"_onInviteGroup",value:function(e){var t=this,o=e.payload.groupProfile.groupID;this._groupModule.hasLocalGroup(o)||this._groupModule.getGroupProfile({groupID:o}).then((function(e){var o=e.data.group;o&&(t._groupModule.updateGroupMap([o]),t._groupModule.emitGroupListUpdate())}))}},{key:"_onQuitGroup",value:function(e){var t=e.payload.groupProfile.groupID;this._groupModule.hasLocalGroup(t)&&this._groupModule.deleteLocalGroupAndConversation(t)}},{key:"_onSetManager",value:function(e){var t=e.payload.groupProfile,o=t.to,n=t.groupID,a=this._groupModule.getModule(ro).getLocalGroupMemberInfo(n,o);a&&a.updateRole(D.GRP_MBR_ROLE_ADMIN)}},{key:"_onDeleteManager",value:function(e){var t=e.payload.groupProfile,o=t.to,n=t.groupID,a=this._groupModule.getModule(ro).getLocalGroupMemberInfo(n,o);a&&a.updateRole(D.GRP_MBR_ROLE_MEMBER)}},{key:"_handleTopicSystemNotice",value:function(e){var t=e.groupProfile,o=t.groupID,n=t.topicID,a=e.elements,s=a.operationType,r=a.topicIDList,i=this._groupModule.getModule(io);17===s?i.onTopicCreated({groupID:o,topicID:n}):18===s&&i.onTopicDeleted({groupID:o,topicIDList:r})}},{key:"reset",value:function(){this.pendencyMap.clear()}}]),e}(),Ss=["relayFlag"],Ds=function(e){i(a,e);var o=f(a);function a(e){var t;return n(this,a),(t=o.call(this,e))._className="GroupModule",t._commonGroupHandler=null,t._AVChatRoomHandler=null,t._groupSystemNoticeHandler=null,t._commonGroupHandler=new fs(_(t)),t._groupAttributesHandler=new Ms(_(t)),t._AVChatRoomHandler=new Is(_(t)),t._groupTipsHandler=new hs(_(t)),t._groupSystemNoticeHandler=new Cs(_(t)),t.groupMap=new Map,t._unjoinedAVChatRoomList=new Map,t._receiptDetailCompleteMap=new Map,t.getInnerEmitterInstance().on(Xa,t._onCloudConfigUpdated,_(t)),t}return s(a,[{key:"_onCloudConfigUpdated",value:function(){var e=this.getCloudConfig("polling_interval"),t=this.getCloudConfig("polling_interval_plus"),o=this.getCloudConfig("polling_no_msg_count");this._AVChatRoomHandler&&(we.log("".concat(this._className,"._onCloudConfigUpdated pollingInterval:").concat(e)+" pollingIntervalPlus:".concat(t," pollingNoMessageCount:").concat(o)),this._AVChatRoomHandler.setPollingInterval(e),this._AVChatRoomHandler.setPollingIntervalPlus(t),this._AVChatRoomHandler.setPollingNoMessageCount(o))}},{key:"onCheckTimer",value:function(e){this.isLoggedIn()&&(this._commonGroupHandler.onCheckTimer(e),this._groupTipsHandler.onCheckTimer(e))}},{key:"guardForAVChatRoom",value:function(e){var t=this;if(e.conversationType===D.CONV_GROUP){var o=Tt(e.to)?bt(e.to):e.to;return this.hasLocalGroup(o)?Ya():this.getGroupProfile({groupID:o}).then((function(n){var a=n.data.group.type;if(we.log("".concat(t._className,".guardForAVChatRoom. groupID:").concat(o," type:").concat(a)),a===D.GRP_AVCHATROOM){var s="userId:".concat(e.from," 未加入群 groupID:").concat(o,"。发消息前先使用 joinGroup 接口申请加群,详细请参考 https://web.sdk.qcloud.com/im/doc/zh-cn/SDK.html#joinGroup");return we.warn("".concat(t._className,".guardForAVChatRoom sendMessage not allowed. ").concat(s)),ja(new Ba({code:na.MESSAGE_SEND_FAIL,message:s,data:{message:e}}))}return Ya()}))}return Ya()}},{key:"checkJoinedAVChatRoomByID",value:function(e){return!!this._AVChatRoomHandler&&this._AVChatRoomHandler.checkJoinedAVChatRoomByID(e)}},{key:"onNewGroupMessage",value:function(e){this._commonGroupHandler&&this._commonGroupHandler.onNewGroupMessage(e)}},{key:"updateNextMessageSeq",value:function(e){var t=this;if(Qe(e)){var o=this.getModule(io);e.forEach((function(e){var n=e.conversationID.replace(D.CONV_GROUP,"");if(Tt(n)){var a=e.lastMessage.sequence+1,s=bt(n),r=o.getLocalTopic(s,n);r&&(r.updateNextMessageSeq(a),r.updateLastMessage(e.lastMessage))}t.groupMap.has(n)&&(t.groupMap.get(n).nextMessageSeq=e.lastMessage.sequence+1)}))}}},{key:"onNewGroupTips",value:function(e){this._groupTipsHandler&&this._groupTipsHandler.onNewGroupTips(e)}},{key:"onGroupMessageRevoked",value:function(e){this._commonGroupHandler&&this._commonGroupHandler.onGroupMessageRevoked(e)}},{key:"onNewGroupSystemNotice",value:function(e){this._groupSystemNoticeHandler&&this._groupSystemNoticeHandler.onNewGroupSystemNotice(e)}},{key:"onGroupMessageReadNotice",value:function(e){var t=this;e.dataList.forEach((function(e){var o=e.elements.groupMessageReadNotice;if(!Ze(o)){var n=t.getModule(co);o.forEach((function(e){var o=e.groupID,a=e.topicID,s=void 0===a?void 0:a,r=e.lastMessageSeq;we.debug("".concat(t._className,".onGroupMessageReadNotice groupID:").concat(o," lastMessageSeq:").concat(r));var i="".concat(D.CONV_GROUP).concat(o),c=!0;Vt(s)||(i="".concat(D.CONV_GROUP).concat(s),c=!1),n.updateIsReadAfterReadReport({conversationID:i,lastMessageSeq:r}),n.updateUnreadCount(i,c)}))}}))}},{key:"onReadReceiptList",value:function(e){var t=this;we.debug("".concat(this._className,".onReadReceiptList options:"),JSON.stringify(e)),e.dataList.forEach((function(e){var o=e.groupProfile,n=e.elements,a=o.groupID,s=t.getModule(co),r=n.readReceiptList;s.updateReadReceiptInfo({groupID:a,readReceiptList:r})}))}},{key:"onGroupMessageModified",value:function(e){we.debug("".concat(this._className,".onGroupMessageModified options:"),JSON.stringify(e));var o=this.getModule(co);e.dataList.forEach((function(e){o.onMessageModified(t(t({},e),{},{conversationType:D.CONV_GROUP,to:e.topicID?e.topicID:e.groupID}))}))}},{key:"deleteGroupSystemNotice",value:function(e){this._groupSystemNoticeHandler&&this._groupSystemNoticeHandler.deleteGroupSystemNotice(e)}},{key:"initGroupMap",value:function(e){this.groupMap.set(e.groupID,new ls(e))}},{key:"deleteGroup",value:function(e){this.groupMap.delete(e)}},{key:"updateGroupMap",value:function(e){var t=this;e.forEach((function(e){t.groupMap.has(e.groupID)?t.groupMap.get(e.groupID).updateGroup(e):t.groupMap.set(e.groupID,new ls(e))}));var o,n=this.getMyUserID(),a=C(this.groupMap);try{for(a.s();!(o=a.n()).done;){m(o.value,2)[1].selfInfo.userID=n}}catch(s){a.e(s)}finally{a.f()}this._setStorageGroupList()}},{key:"getStorageGroupList",value:function(){return this.getModule(lo).getItem("groupMap")}},{key:"_setStorageGroupList",value:function(){var e=this.getLocalGroupList().filter((function(e){var t=e.type;return!It(t)})).filter((function(e){return!e.isSupportTopic})).slice(0,20).map((function(e){return{groupID:e.groupID,name:e.name,avatar:e.avatar,type:e.type}}));this.getModule(lo).setItem("groupMap",e)}},{key:"getGroupMap",value:function(){return this.groupMap}},{key:"getLocalGroupList",value:function(){return M(this.groupMap.values())}},{key:"getLocalGroupProfile",value:function(e){return this.groupMap.get(e)}},{key:"sortLocalGroupList",value:function(){var e=M(this.groupMap).filter((function(e){var t=m(e,2);t[0];return!Vt(t[1].lastMessage)}));e.sort((function(e,t){return t[1].lastMessage.lastTime-e[1].lastMessage.lastTime})),this.groupMap=new Map(M(e))}},{key:"updateGroupLastMessage",value:function(e){this._commonGroupHandler&&this._commonGroupHandler.handleUpdateGroupLastMessage(e)}},{key:"emitGroupListUpdate",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],o=this.getLocalGroupList();if(e&&this.emitOuterEvent(S.GROUP_LIST_UPDATED),t){var n=JSON.parse(JSON.stringify(o)),a=this.getModule(co);a.updateConversationGroupProfile(n)}}},{key:"patchGroupMessageRemindType",value:function(){var e=this.getLocalGroupList(),t=this.getModule(co),o=0;e.forEach((function(e){!0===t.patchMessageRemindType({ID:e.groupID,isC2CConversation:!1,messageRemindType:e.selfInfo.messageRemindType})&&(o+=1)})),we.log("".concat(this._className,".patchGroupMessageRemindType count:").concat(o))}},{key:"recomputeUnreadCount",value:function(){var e=this.getLocalGroupList(),t=this.getModule(co);e.forEach((function(e){var o=e.groupID,n=e.selfInfo,a=n.excludedUnreadSequenceList,s=n.readedSequence;if(Qe(a)){var r=0;a.forEach((function(t){t>=s&&t<=e.nextMessageSeq-1&&(r+=1)})),r>=1&&t.recomputeGroupUnreadCount({conversationID:"".concat(D.CONV_GROUP).concat(o),count:r})}}))}},{key:"getMyNameCardByGroupID",value:function(e){var t=this.getLocalGroupProfile(e);return t?t.selfInfo.nameCard:""}},{key:"getGroupList",value:function(e){return this._commonGroupHandler?this._commonGroupHandler.getGroupList(e):Ya()}},{key:"getGroupProfile",value:function(e){var t=this,o=new va(ya.GET_GROUP_PROFILE),n="".concat(this._className,".getGroupProfile"),a=e.groupID,s=e.groupCustomFieldFilter;we.log("".concat(n," groupID:").concat(a));var r={groupIDList:[a],responseFilter:{groupBaseInfoFilter:["Type","Name","Introduction","Notification","FaceUrl","Owner_Account","CreateTime","InfoSeq","LastInfoTime","LastMsgTime","MemberNum","MaxMemberNum","ApplyJoinOption","NextMsgSeq","ShutUpAllMember"],groupCustomFieldFilter:s,memberInfoFilter:["Role","JoinTime","MsgSeq","MsgFlag","NameCard"]}};return this.getGroupProfileAdvance(r).then((function(e){var s,r=e.data,i=r.successGroupList,c=r.failureGroupList;if(we.log("".concat(n," ok")),c.length>0)return ja(c[0]);(It(i[0].type)&&!t.hasLocalGroup(a)?s=new ls(i[0]):(t.updateGroupMap(i),s=t.getLocalGroupProfile(a)),s.isSupportTopic)||t.getModule(co).updateConversationGroupProfile([s]);return o.setNetworkType(t.getNetworkType()).setMessage("groupID:".concat(a," type:").concat(s.type," muteAllMembers:").concat(s.muteAllMembers," ownerID:").concat(s.ownerID)).end(),ba({group:s})})).catch((function(a){return t.probeNetwork().then((function(t){var n=m(t,2),s=n[0],r=n[1];o.setError(a,s,r).setMessage("groupID:".concat(e.groupID)).end()})),we.error("".concat(n," failed. error:"),a),ja(a)}))}},{key:"getGroupProfileAdvance",value:function(e){var o=this,n="".concat(this._className,".getGroupProfileAdvance"),a=e.groupIDList;Qe(a)&&a.length>50&&(we.warn("".concat(n," 获取群资料的数量不能超过50个")),a.length=50);var s=[],r=[];a.forEach((function(e){Et({groupID:e})?r.push(e):s.push(e)}));var i=[];if(s.length>0){var c=this._getGroupProfileAdvance(t(t({},e),{},{groupIDList:s}));i.push(c)}if(r.length>0){var u=this._getGroupProfileAdvance(t(t({},e),{},{groupIDList:r,relayFlag:s.length>0}));i.push(u)}return Promise.all(i).then((function(e){var t=[],o=[];return e.forEach((function(e){t.push.apply(t,M(e.successGroupList)),o.push.apply(o,M(e.failureGroupList))})),ba({successGroupList:t,failureGroupList:o})})).catch((function(e){return we.error("".concat(o._className,"._getGroupProfileAdvance failed. error:"),e),ja(e)}))}},{key:"_getGroupProfileAdvance",value:function(e){var t=this,o=e.relayFlag,n=void 0!==o&&o,a=g(e,Ss);return this.request({protocolName:en,requestData:a}).then((function(e){we.log("".concat(t._className,"._getGroupProfileAdvance ok."));var o=e.data.groups;return{successGroupList:o.filter((function(e){return Ze(e.errorCode)||0===e.errorCode})),failureGroupList:o.filter((function(e){return e.errorCode&&0!==e.errorCode})).map((function(e){return new Ba({code:e.errorCode,message:e.errorInfo,data:{groupID:e.groupID}})}))}})).catch((function(t){return n&&Et({groupID:e.groupIDList[0]})?{successGroupList:[],failureGroupList:[]}:ja(t)}))}},{key:"createGroup",value:function(e){var o=this,n="".concat(this._className,".createGroup"),a=e.type,s=e.groupID;if(!["Public","Private","ChatRoom","AVChatRoom","Community"].includes(a))return ja({code:na.ILLEGAL_GROUP_TYPE,message:aa.ILLEGAL_GROUP_TYPE});if(!Et({type:a})){if(!Vt(s)&&Et({groupID:s}))return ja({code:na.ILLEGAL_GROUP_ID,message:aa.ILLEGAL_GROUP_ID});e.isSupportTopic=void 0}if(It(a)&&!Ze(e.memberList)&&e.memberList.length>0&&(we.warn("".concat(n," 创建 AVChatRoom 时不能添加群成员,自动忽略该字段")),e.memberList=void 0),yt(a)||Ze(e.joinOption)||(we.warn("".concat(n," 创建 Work/Meeting/AVChatRoom/Community 群时不能设置字段 joinOption,自动忽略该字段")),e.joinOption=void 0),Et({type:a})){if(!Vt(s)&&!Et({groupID:s}))return ja({code:na.ILLEGAL_GROUP_ID,message:aa.ILLEGAL_GROUP_ID});e.isSupportTopic=!0===e.isSupportTopic?1:0}var r=new va(ya.CREATE_GROUP);we.log("".concat(n," options:"),e);var i=[];return this.request({protocolName:tn,requestData:t(t({},e),{},{ownerID:this.getMyUserID(),webPushFlag:1})}).then((function(a){var s=a.data,c=s.groupID,u=s.overLimitUserIDList,l=void 0===u?[]:u;if(i=l,r.setNetworkType(o.getNetworkType()).setMessage("groupType:".concat(e.type," groupID:").concat(c," overLimitUserIDList=").concat(l)).end(),we.log("".concat(n," ok groupID:").concat(c," overLimitUserIDList:"),l),e.type===D.GRP_AVCHATROOM)return o.getGroupProfile({groupID:c});if(e.type===D.GRP_COMMUNITY&&1===e.isSupportTopic)return o.getGroupProfile({groupID:c});Vt(e.memberList)||Vt(l)||(e.memberList=e.memberList.filter((function(e){return-1===l.indexOf(e.userID)}))),o.updateGroupMap([t(t({},e),{},{groupID:c})]);var d=o.getModule(to),p=d.createCustomMessage({to:c,conversationType:D.CONV_GROUP,payload:{data:"group_create",extension:"".concat(o.getMyUserID(),"创建群组")}});return d.sendMessageInstance(p),o.emitGroupListUpdate(),o.getGroupProfile({groupID:c})})).then((function(e){var t=e.data.group,o=t.selfInfo,n=o.nameCard,a=o.joinTime;return t.updateSelfInfo({nameCard:n,joinTime:a,messageRemindType:D.MSG_REMIND_ACPT_AND_NOTE,role:D.GRP_MBR_ROLE_OWNER}),ba({group:t,overLimitUserIDList:i})})).catch((function(t){return r.setMessage("groupType:".concat(e.type)),o.probeNetwork().then((function(e){var o=m(e,2),n=o[0],a=o[1];r.setError(t,n,a).end()})),we.error("".concat(n," failed. error:"),t),ja(t)}))}},{key:"dismissGroup",value:function(e){var t=this,o="".concat(this._className,".dismissGroup");if(this.hasLocalGroup(e)&&this.getLocalGroupProfile(e).type===D.GRP_WORK)return ja(new Ba({code:na.CANNOT_DISMISS_WORK,message:aa.CANNOT_DISMISS_WORK}));var n=new va(ya.DISMISS_GROUP);return n.setMessage("groupID:".concat(e)),we.log("".concat(o," groupID:").concat(e)),this.request({protocolName:on,requestData:{groupID:e}}).then((function(){return n.setNetworkType(t.getNetworkType()).end(),we.log("".concat(o," ok")),t.deleteLocalGroupAndConversation(e),t.checkJoinedAVChatRoomByID(e)&&t._AVChatRoomHandler.reset(e),ba({groupID:e})})).catch((function(e){return t.probeNetwork().then((function(t){var o=m(t,2),a=o[0],s=o[1];n.setError(e,a,s).end()})),we.error("".concat(o," failed. error:"),e),ja(e)}))}},{key:"updateGroupProfile",value:function(e){var t=this,o="".concat(this._className,".updateGroupProfile");!this.hasLocalGroup(e.groupID)||yt(this.getLocalGroupProfile(e.groupID).type)||Ze(e.joinOption)||(we.warn("".concat(o," Work/Meeting/AVChatRoom/Community 群不能设置字段 joinOption,自动忽略该字段")),e.joinOption=void 0),Ze(e.muteAllMembers)||(e.muteAllMembers?e.muteAllMembers="On":e.muteAllMembers="Off");var n=new va(ya.UPDATE_GROUP_PROFILE);return n.setMessage(JSON.stringify(e)),we.log("".concat(o," groupID:").concat(e.groupID)),this.request({protocolName:nn,requestData:e}).then((function(){(n.setNetworkType(t.getNetworkType()).end(),we.log("".concat(o," ok")),t.hasLocalGroup(e.groupID))&&(t.groupMap.get(e.groupID).updateGroup(e),t._setStorageGroupList());return ba({group:t.groupMap.get(e.groupID)})})).catch((function(e){return t.probeNetwork().then((function(t){var o=m(t,2),a=o[0],s=o[1];n.setError(e,a,s).end()})),we.log("".concat(o," failed. error:"),e),ja(e)}))}},{key:"joinGroup",value:function(e){var t=this,o=e.groupID,n=e.type,a="".concat(this._className,".joinGroup");if(n===D.GRP_WORK){var s=new Ba({code:na.CANNOT_JOIN_WORK,message:aa.CANNOT_JOIN_WORK});return ja(s)}if(this.deleteUnjoinedAVChatRoom(o),this.hasLocalGroup(o)){if(!this.isLoggedIn())return Ya({status:D.JOIN_STATUS_ALREADY_IN_GROUP});var r=new va(ya.APPLY_JOIN_GROUP);return this.getGroupProfile({groupID:o}).then((function(){return r.setNetworkType(t.getNetworkType()).setMessage("groupID:".concat(o," joinedStatus:").concat(D.JOIN_STATUS_ALREADY_IN_GROUP)).end(),Ya({status:D.JOIN_STATUS_ALREADY_IN_GROUP})})).catch((function(n){return r.setNetworkType(t.getNetworkType()).setMessage("groupID:".concat(o," unjoined")).end(),we.warn("".concat(a," ").concat(o," was unjoined, now join!")),t.groupMap.delete(o),t.applyJoinGroup(e)}))}return we.log("".concat(a," groupID:").concat(o)),this.isLoggedIn()?this.applyJoinGroup(e):this._AVChatRoomHandler.joinWithoutAuth(e)}},{key:"applyJoinGroup",value:function(e){var o=this,n="".concat(this._className,".applyJoinGroup"),a=e.groupID,s=new va(ya.APPLY_JOIN_GROUP),r=t({},e),i=this.canIUse(B.AVCHATROOM_HISTORY_MSG);return i&&(r.historyMessageFlag=1),this.getModule(co).removeConversationMessageCache("".concat(D.CONV_GROUP).concat(a)),this.request({protocolName:an,requestData:r}).then((function(e){var t=e.data,r=t.joinedStatus,c=t.longPollingKey,u=t.avChatRoomFlag,l=t.avChatRoomKey,d=t.messageList,p="groupID:".concat(a," joinedStatus:").concat(r," longPollingKey:").concat(c)+" avChatRoomFlag:".concat(u," canGetAVChatRoomHistoryMessage:").concat(i,",")+" history message count:".concat(Vt(d)?0:d.length);switch(s.setNetworkType(o.getNetworkType()).setMessage("".concat(p)).end(),we.log("".concat(n," ok. ").concat(p)),r){case Be:return ba({status:Be});case He:return o.getGroupProfile({groupID:a}).then((function(e){var t,n=e.data.group,s={status:He,group:n};return 1===u?(o.getModule(co).setCompleted("".concat(D.CONV_GROUP).concat(a)),o._groupAttributesHandler.initGroupAttributesCache({groupID:a,avChatRoomKey:l}),(t=Ze(c)?o._AVChatRoomHandler.handleJoinResult({group:n}):o._AVChatRoomHandler.startRunLoop({longPollingKey:c,group:n})).then((function(){o._onAVChatRoomHistoryMessage(d)})),t):(o.emitGroupListUpdate(!0,!1),ba(s))}));default:var g=new Ba({code:na.JOIN_GROUP_FAIL,message:aa.JOIN_GROUP_FAIL});return we.error("".concat(n," error:"),g),ja(g)}})).catch((function(t){return s.setMessage("groupID:".concat(e.groupID)),o.probeNetwork().then((function(e){var o=m(e,2),n=o[0],a=o[1];s.setError(t,n,a).end()})),we.error("".concat(n," error:"),t),ja(t)}))}},{key:"quitGroup",value:function(e){var t=this,o="".concat(this._className,".quitGroup");we.log("".concat(o," groupID:").concat(e));var n=this.checkJoinedAVChatRoomByID(e);if(!n&&!this.hasLocalGroup(e)){var a=new Ba({code:na.MEMBER_NOT_IN_GROUP,message:aa.MEMBER_NOT_IN_GROUP});return ja(a)}if(n&&!this.isLoggedIn())return we.log("".concat(o," anonymously ok. groupID:").concat(e)),this.deleteLocalGroupAndConversation(e),this._AVChatRoomHandler.reset(e),Ya({groupID:e});var s=new va(ya.QUIT_GROUP);return s.setMessage("groupID:".concat(e)),this.request({protocolName:rn,requestData:{groupID:e}}).then((function(){return s.setNetworkType(t.getNetworkType()).end(),we.log("".concat(o," ok")),t.deleteLocalGroupAndConversation(e),n&&t._AVChatRoomHandler.reset(e),ba({groupID:e})})).catch((function(e){return t.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];s.setError(e,n,a).end()})),we.error("".concat(o," failed. error:"),e),ja(e)}))}},{key:"searchGroupByID",value:function(e){var t=this,o="".concat(this._className,".searchGroupByID"),n={groupIDList:[e]},a=new va(ya.SEARCH_GROUP_BY_ID);return a.setMessage("groupID:".concat(e)),we.log("".concat(o," groupID:").concat(e)),this.request({protocolName:cn,requestData:n}).then((function(e){var n=e.data.groupProfile;if(0!==n[0].errorCode)throw new Ba({code:n[0].errorCode,message:n[0].errorInfo});return a.setNetworkType(t.getNetworkType()).end(),we.log("".concat(o," ok")),ba({group:new ls(n[0])})})).catch((function(e){return t.probeNetwork().then((function(t){var o=m(t,2),n=o[0],s=o[1];a.setError(e,n,s).end()})),we.warn("".concat(o," failed. error:"),e),ja(e)}))}},{key:"changeGroupOwner",value:function(e){var t=this,o="".concat(this._className,".changeGroupOwner");if(this.hasLocalGroup(e.groupID)&&this.getLocalGroupProfile(e.groupID).type===D.GRP_AVCHATROOM)return ja(new Ba({code:na.CANNOT_CHANGE_OWNER_IN_AVCHATROOM,message:aa.CANNOT_CHANGE_OWNER_IN_AVCHATROOM}));if(e.newOwnerID===this.getMyUserID())return ja(new Ba({code:na.CANNOT_CHANGE_OWNER_TO_SELF,message:aa.CANNOT_CHANGE_OWNER_TO_SELF}));var n=new va(ya.CHANGE_GROUP_OWNER);return n.setMessage("groupID:".concat(e.groupID," newOwnerID:").concat(e.newOwnerID)),we.log("".concat(o," groupID:").concat(e.groupID)),this.request({protocolName:un,requestData:e}).then((function(){n.setNetworkType(t.getNetworkType()).end(),we.log("".concat(o," ok"));var a=e.groupID,s=e.newOwnerID;t.groupMap.get(a).ownerID=s;var r=t.getModule(ro).getLocalGroupMemberList(a);if(r instanceof Map){var i=r.get(t.getMyUserID());Ze(i)||(i.updateRole("Member"),t.groupMap.get(a).selfInfo.role="Member");var c=r.get(s);Ze(c)||c.updateRole("Owner")}return t.emitGroupListUpdate(!0,!1),ba({group:t.groupMap.get(a)})})).catch((function(e){return t.probeNetwork().then((function(t){var o=m(t,2),a=o[0],s=o[1];n.setError(e,a,s).end()})),we.error("".concat(o," failed. error:"),e),ja(e)}))}},{key:"handleGroupApplication",value:function(e){var o=this,n="".concat(this._className,".handleGroupApplication"),a=e.message.payload,s=a.groupProfile.groupID,r=a.authentication,i=a.messageKey,c=a.operatorID,u=new va(ya.HANDLE_GROUP_APPLICATION);return u.setMessage("groupID:".concat(s)),we.log("".concat(n," groupID:").concat(s)),this.request({protocolName:ln,requestData:t(t({},e),{},{applicant:c,groupID:s,authentication:r,messageKey:i})}).then((function(){return u.setNetworkType(o.getNetworkType()).end(),we.log("".concat(n," ok")),o._groupSystemNoticeHandler.deleteGroupSystemNotice({messageList:[e.message]}),ba({group:o.getLocalGroupProfile(s)})})).catch((function(e){return o.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];u.setError(e,n,a).end()})),we.error("".concat(n," failed. error"),e),ja(e)}))}},{key:"handleGroupInvitation",value:function(e){var o=this,n="".concat(this._className,".handleGroupInvitation"),a=e.message.payload,s=a.groupProfile.groupID,r=a.authentication,i=a.messageKey,c=a.operatorID,u=e.handleAction,l=new va(ya.HANDLE_GROUP_INVITATION);return l.setMessage("groupID:".concat(s," inviter:").concat(c," handleAction:").concat(u)),we.log("".concat(n," groupID:").concat(s," inviter:").concat(c," handleAction:").concat(u)),this.request({protocolName:dn,requestData:t(t({},e),{},{inviter:c,groupID:s,authentication:r,messageKey:i})}).then((function(){return l.setNetworkType(o.getNetworkType()).end(),we.log("".concat(n," ok")),o._groupSystemNoticeHandler.deleteGroupSystemNotice({messageList:[e.message]}),ba({group:o.getLocalGroupProfile(s)})})).catch((function(e){return o.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];l.setError(e,n,a).end()})),we.error("".concat(n," failed. error"),e),ja(e)}))}},{key:"getGroupOnlineMemberCount",value:function(e){return this._AVChatRoomHandler?this._AVChatRoomHandler.checkJoinedAVChatRoomByID(e)?this._AVChatRoomHandler.getGroupOnlineMemberCount(e):Ya({memberCount:0}):ja({code:na.CANNOT_FIND_MODULE,message:aa.CANNOT_FIND_MODULE})}},{key:"hasLocalGroup",value:function(e){return this.groupMap.has(e)}},{key:"deleteLocalGroupAndConversation",value:function(e){var t=this.checkJoinedAVChatRoomByID(e);(we.log("".concat(this._className,".deleteLocalGroupAndConversation isJoinedAVChatRoom:").concat(t)),t)&&this.getModule(co).deleteLocalConversation("GROUP".concat(e));this._deleteLocalGroup(e),this.emitGroupListUpdate(!0,!1)}},{key:"_deleteLocalGroup",value:function(e){this.groupMap.delete(e),this.getModule(ro).deleteGroupMemberList(e),this._setStorageGroupList()}},{key:"sendMessage",value:function(e,t){var o=this.createGroupMessagePack(e,t);return this.request(o)}},{key:"createGroupMessagePack",value:function(e,t){var o=null;t&&t.offlinePushInfo&&(o=t.offlinePushInfo);var n="";ze(e.cloudCustomData)&&e.cloudCustomData.length>0&&(n=e.cloudCustomData);var a=[];if(Xe(t)&&Xe(t.messageControlInfo)){var s=t.messageControlInfo,r=s.excludedFromUnreadCount,i=s.excludedFromLastMessage;!0===r&&a.push("NoUnread"),!0===i&&a.push("NoLastMsg")}var c=e.getGroupAtInfoList(),u={fromAccount:this.getMyUserID(),groupID:e.to,msgBody:e.getElements(),cloudCustomData:n,random:e.random,priority:e.priority,clientSequence:e.clientSequence,groupAtInfo:e.type!==D.MSG_TEXT||Vt(c)?void 0:c,onlineOnlyFlag:this.isOnlineMessage(e,t)?1:0,clientTime:e.clientTime,offlinePushInfo:o?{pushFlag:!0===o.disablePush?1:0,title:o.title||"",desc:o.description||"",ext:o.extension||"",apnsInfo:{badgeMode:!0===o.ignoreIOSBadge?1:0},androidInfo:{OPPOChannelID:o.androidOPPOChannelID||""}}:void 0,messageControlInfo:a,needReadReceipt:!0!==e.needReadReceipt||this.isMessageFromOrToAVChatroom(e.to)?0:1};return Tt(e.to)&&(u.groupID=bt(e.to),u.topicID=e.to),{protocolName:Po,tjgID:this.generateTjgID(e),requestData:u}}},{key:"revokeMessage",value:function(e){var t={groupID:e.to,msgSeqList:[{msgSeq:e.sequence}]};return Tt(e.to)&&(t.groupID=bt(e.to),t.topicID=e.to),this.request({protocolName:pn,requestData:t})}},{key:"deleteMessage",value:function(e){var t=e.to,o=e.keyList;we.log("".concat(this._className,".deleteMessage groupID:").concat(t," count:").concat(o.length));var n={groupID:t,deleter:this.getMyUserID(),keyList:o};return Tt(t)&&(n.groupID=bt(t),n.topicID=t),this.request({protocolName:Sn,requestData:n})}},{key:"modifyRemoteMessage",value:function(e){var t=e.to,o=e.sequence,n=e.payload,a=e.type,s=e.version,r=void 0===s?0:s,i=e.cloudCustomData,c=t,u=void 0;return Tt(t)&&(c=bt(t),u=t),this.request({protocolName:Dn,requestData:{groupID:c,topicID:u,sequence:o,version:r,elements:[{type:a,content:n}],cloudCustomData:i}})}},{key:"getRoamingMessage",value:function(e){var t=this,o="".concat(this._className,".getRoamingMessage"),n=e.conversationID,a=e.groupID,s=e.sequence,r=new va(ya.GET_GROUP_ROAMING_MESSAGES),i=0,c=void 0;return Tt(a)&&(a=bt(c=a)),this._computeLastSequence({groupID:a,topicID:c,sequence:s}).then((function(e){return i=e,we.log("".concat(o," groupID:").concat(a," startSequence:").concat(i)),t.request({protocolName:hn,requestData:{groupID:a,count:21,sequence:i,topicID:c}})})).then((function(e){var s=e.data,u=s.messageList,l=s.complete;Ze(u)?we.log("".concat(o," ok. complete:").concat(l," but messageList is undefined!")):we.log("".concat(o," ok. complete:").concat(l," count:").concat(u.length)),r.setNetworkType(t.getNetworkType()).setMessage("groupID:".concat(a," topicID:").concat(c," startSequence:").concat(i," complete:").concat(l," count:").concat(u?u.length:"undefined")).end();var d=t.getModule(co);if(2===l||Vt(u))return d.setCompleted(n),{nextReqID:"",storedMessageList:[]};var p=u[u.length-1].sequence-1;d.updateRoamingMessageSequence(n,p);var g=d.onRoamingMessage(u,n);return d.updateIsRead(n),d.patchConversationLastMessage(n),we.log("".concat(o," nextReqID:").concat(p," stored message count:").concat(g.length)),{nextReqID:p+"",storedMessageList:g}})).catch((function(e){return t.probeNetwork().then((function(t){var o=m(t,2),n=o[0],s=o[1];r.setError(e,n,s).setMessage("groupID:".concat(a," topicID:").concat(c," startSequence:").concat(i)).end()})),we.warn("".concat(o," failed. error:"),e),ja(e)}))}},{key:"_getGroupIDOfMessage",value:function(e){return e.conversationID.replace(D.CONV_GROUP,"")}},{key:"getReadReceiptList",value:function(e){var t=this,o="".concat(this._className,".getReadReceiptList"),n=this._getGroupIDOfMessage(e[0]),a=this.getMyUserID(),s=e.filter((function(e){return e.from===a&&!0===e.needReadReceipt})).map((function(e){return{sequence:e.sequence}}));if(we.log("".concat(o," groupID:").concat(n," sequenceList:").concat(JSON.stringify(s))),0===s.length)return Ya({messageList:e});var r=new va(ya.GET_READ_RECEIPT);return r.setMessage("groupID:".concat(n)),this.request({protocolName:fn,requestData:{groupID:n,sequenceList:s}}).then((function(t){r.end(),we.log("".concat(o," ok"));var n=t.data.readReceiptList;return Qe(n)&&n.forEach((function(t){e.forEach((function(e){0===t.code&&t.sequence===e.sequence&&(e.readReceiptInfo.readCount=t.readCount,e.readReceiptInfo.unreadCount=t.unreadCount)}))})),ba({messageList:e})})).catch((function(e){return t.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];r.setError(e,n,a).end()})),we.warn("".concat(o," failed. error:"),e),ja(e)}))}},{key:"sendReadReceipt",value:function(e){var t=this,o=this._getGroupIDOfMessage(e[0]),n=new va(ya.SEND_READ_RECEIPT);n.setMessage("groupID:".concat(o));var a=this.getMyUserID(),s=e.filter((function(e){return e.from!==a&&!0===e.needReadReceipt})).map((function(e){return{sequence:e.sequence}}));if(0===s.length)return ja({code:na.READ_RECEIPT_MESSAGE_LIST_EMPTY,message:aa.READ_RECEIPT_MESSAGE_LIST_EMPTY});var r="".concat(this._className,".sendReadReceipt");return we.log("".concat(r,". sequenceList:").concat(JSON.stringify(s))),this.request({protocolName:mn,requestData:{groupID:o,sequenceList:s}}).then((function(e){return n.end(),we.log("".concat(r," ok")),ba()})).catch((function(e){return t.probeNetwork().then((function(t){var o=m(t,2),a=o[0],s=o[1];n.setError(e,a,s).end()})),we.warn("".concat(r," failed. error:"),e),ja(e)}))}},{key:"getReadReceiptDetail",value:function(e){var t=this,o=e.message,n=e.filter,a=e.cursor,s=e.count,r=this._getGroupIDOfMessage(o),i=o.ID,c=o.sequence,u="".concat(this._className,".getReadReceiptDetail"),l=this._receiptDetailCompleteMap.get(i)||!1,d=0!==n&&1!==n?0:n,p=ze(a)?a:"",g=!$e(s)||s<=0||s>=100?100:s,_="groupID:".concat(r," sequence:").concat(c," cursor:").concat(p," filter:").concat(d," completeFlag:").concat(l);we.log("".concat(u," ").concat(_));var h={cursor:"",isCompleted:!1,messageID:i,unreadUserIDList:[],readUserIDList:[]},f=new va(ya.GET_READ_RECEIPT_DETAIL);return f.setMessage(_),this.request({protocolName:vn,requestData:{groupID:r,sequence:c,flag:d,cursor:p,count:g}}).then((function(e){f.end();var o=e.data,n=o.cursor,a=o.isCompleted,s=o.unreadUserIDList,r=o.readUserIDList;return h.cursor=n,1===a&&(h.isCompleted=!0,t._receiptDetailCompleteMap.set(i,!0)),0===d?h.readUserIDList=r.map((function(e){return e.userID})):1===d&&(h.unreadUserIDList=s.map((function(e){return e.userID}))),we.log("".concat(u," ok")),ba(h)})).catch((function(e){return t.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];f.setError(e,n,a).end()})),we.warn("".concat(u," failed. error:"),e),ja(e)}))}},{key:"getRoamingMessagesHopping",value:function(e){var t=this,o="".concat(this._className,".getRoamingMessagesHopping"),n=new va(ya.GET_GROUP_ROAMING_MESSAGES_HOPPING),a=e.groupID,s=e.count,r=e.sequence,i=void 0;return Tt(a)&&(a=bt(i=a)),this.request({protocolName:hn,requestData:{groupID:a,count:s,sequence:r,topicID:i}}).then((function(s){var c=s.data,u=c.messageList,l=c.complete,d="groupID:".concat(a," topicID:").concat(i," sequence:").concat(r," complete:").concat(l," count:").concat(u?u.length:0);if(we.log("".concat(o," ok. ").concat(d)),n.setNetworkType(t.getNetworkType()).setMessage("".concat(d)).end(),2===l||Vt(u))return[];var p="".concat(D.CONV_GROUP).concat(e.groupID);return t.getModule(co).onRoamingMessage(u,p,!1)})).catch((function(e){return t.probeNetwork().then((function(t){var o=m(t,2),i=o[0],c=o[1];n.setError(e,i,c).setMessage("groupID:".concat(a," sequence:").concat(r," count:").concat(s)).end()})),we.warn("".concat(o," failed. error:"),e),ja(e)}))}},{key:"setMessageRead",value:function(e){var t=this,o=e.conversationID,n=e.lastMessageSeq,a="".concat(this._className,".setMessageRead");we.log("".concat(a," conversationID:").concat(o," lastMessageSeq:").concat(n)),$e(n)||we.warn("".concat(a," 请勿修改 Conversation.lastMessage.lastSequence,否则可能会导致已读上报结果不准确"));var s=new va(ya.SET_GROUP_MESSAGE_READ);s.setMessage("".concat(o,"-").concat(n));var r=o.replace(D.CONV_GROUP,""),i=void 0;return Tt(r)&&(r=bt(i=r)),this.request({protocolName:gn,requestData:{groupID:r,topicID:i,messageReadSeq:n}}).then((function(){s.setNetworkType(t.getNetworkType()).end(),we.log("".concat(a," ok."));var e=t.getModule(co);e.updateIsReadAfterReadReport({conversationID:o,lastMessageSeq:n});var c=!0;if(!Ze(i)){c=!1;var u=t.getModule(io).getLocalTopic(r,i);u&&u.updateSelfInfo({readedSequence:n})}return e.updateUnreadCount(o,c),ba()})).catch((function(e){return t.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];s.setError(e,n,a).end()})),we.log("".concat(a," failed. error:"),e),ja(e)}))}},{key:"_computeLastSequence",value:function(e){var t=e.groupID,o=e.topicID,n=void 0===o?void 0:o,a=e.sequence;return a>0?Promise.resolve(a):Ze(n)||this.hasLocalGroup(t)?Ze(n)?this.getGroupLastSequence(t):this.getTopicLastSequence({groupID:t,topicID:n}):Promise.resolve(0)}},{key:"getGroupLastSequence",value:function(e){var t=this,o="".concat(this._className,".getGroupLastSequence"),n=new va(ya.GET_GROUP_LAST_SEQUENCE),a=0,s="";if(this.hasLocalGroup(e)){var r=this.getLocalGroupProfile(e),i=r.lastMessage;if(i.lastSequence>0&&!1===i.onlineOnlyFlag)return a=i.lastSequence,s="got lastSequence:".concat(a," from local group profile[lastMessage.lastSequence]. groupID:").concat(e),we.log("".concat(o," ").concat(s)),n.setNetworkType(this.getNetworkType()).setMessage("".concat(s)).end(),Promise.resolve(a);if(r.nextMessageSeq>1)return a=r.nextMessageSeq-1,s="got lastSequence:".concat(a," from local group profile[nextMessageSeq]. groupID:").concat(e),we.log("".concat(o," ").concat(s)),n.setNetworkType(this.getNetworkType()).setMessage("".concat(s)).end(),Promise.resolve(a)}var c="GROUP".concat(e),u=this.getModule(co).getLocalConversation(c);if(u&&u.lastMessage.lastSequence&&!1===u.lastMessage.onlineOnlyFlag)return a=u.lastMessage.lastSequence,s="got lastSequence:".concat(a," from local conversation profile[lastMessage.lastSequence]. groupID:").concat(e),we.log("".concat(o," ").concat(s)),n.setNetworkType(this.getNetworkType()).setMessage("".concat(s)).end(),Promise.resolve(a);var l={groupIDList:[e],responseFilter:{groupBaseInfoFilter:["NextMsgSeq"]}};return this.getGroupProfileAdvance(l).then((function(r){var i=r.data.successGroupList;return Vt(i)?we.log("".concat(o," successGroupList is empty. groupID:").concat(e)):(a=i[0].nextMessageSeq-1,s="got lastSequence:".concat(a," from getGroupProfileAdvance. groupID:").concat(e),we.log("".concat(o," ").concat(s))),n.setNetworkType(t.getNetworkType()).setMessage("".concat(s)).end(),a})).catch((function(a){return t.probeNetwork().then((function(t){var o=m(t,2),s=o[0],r=o[1];n.setError(a,s,r).setMessage("get lastSequence failed from getGroupProfileAdvance. groupID:".concat(e)).end()})),we.warn("".concat(o," failed. error:"),a),ja(a)}))}},{key:"getTopicLastSequence",value:function(e){var t=this,o=e.groupID,n=e.topicID,a="".concat(this._className,".getTopicLastSequence"),s=new va(ya.GET_TOPIC_LAST_SEQUENCE),r=0,i="",c=this.getModule(io);return c.hasLocalTopic(o,n)?(r=c.getLocalTopic(o,n).nextMessageSeq-1,i="get lastSequence:".concat(r," from local topic info[nextMessageSeq]. topicID:").concat(n),we.log("".concat(a," ").concat(i)),s.setNetworkType(this.getNetworkType()).setMessage("".concat(i)).end(),Promise.resolve(r)):c.getTopicList({groupID:o,topicIDList:[n]}).then((function(e){var o=e.data.successTopicList;return Vt(o)?we.log("".concat(a," successTopicList is empty. topicID:").concat(n)):(r=o[0].nextMessageSeq-1,i="get lastSequence:".concat(r," from getTopicList. topicID:").concat(n),we.log("".concat(a," ").concat(i))),s.setNetworkType(t.getNetworkType()).setMessage("".concat(i)).end(),r})).catch((function(e){return t.probeNetwork().then((function(t){var o=m(t,2),a=o[0],r=o[1];s.setError(e,a,r).setMessage("get lastSequence failed from getTopicList. topicID:".concat(n)).end()})),we.warn("".concat(a," failed. error:"),e),ja(e)}))}},{key:"isMessageFromOrToAVChatroom",value:function(e){return!!this._AVChatRoomHandler&&this._AVChatRoomHandler.checkJoinedAVChatRoomByID(e)}},{key:"hasJoinedAVChatRoom",value:function(){return this._AVChatRoomHandler?this._AVChatRoomHandler.hasJoinedAVChatRoom():0}},{key:"getJoinedAVChatRoom",value:function(){return this._AVChatRoomHandler?this._AVChatRoomHandler.getJoinedAVChatRoom():[]}},{key:"isOnlineMessage",value:function(e,t){return!(!this._canIUseOnlineOnlyFlag(e)||!t||!0!==t.onlineUserOnly)}},{key:"_canIUseOnlineOnlyFlag",value:function(e){var t=this.getJoinedAVChatRoom();return!t||!t.includes(e.to)||e.conversationType!==D.CONV_GROUP}},{key:"_onAVChatRoomHistoryMessage",value:function(e){if(!Vt(e)){we.log("".concat(this._className,"._onAVChatRoomHistoryMessage count:").concat(e.length));var o=[];e.forEach((function(e){o.push(t(t({},e),{},{isHistoryMessage:1}))})),this.onAVChatRoomMessage(o)}}},{key:"onAVChatRoomMessage",value:function(e){this._AVChatRoomHandler&&this._AVChatRoomHandler.onMessage(e)}},{key:"getGroupSimplifiedInfo",value:function(e){var t=this,o=new va(ya.GET_GROUP_SIMPLIFIED_INFO),n={groupIDList:[e],responseFilter:{groupBaseInfoFilter:["Type","Name"]}};return this.getGroupProfileAdvance(n).then((function(n){var a=n.data.successGroupList;return o.setNetworkType(t.getNetworkType()).setMessage("groupID:".concat(e," type:").concat(a[0].type)).end(),a[0]})).catch((function(n){t.probeNetwork().then((function(t){var a=m(t,2),s=a[0],r=a[1];o.setError(n,s,r).setMessage("groupID:".concat(e)).end()}))}))}},{key:"setUnjoinedAVChatRoom",value:function(e){this._unjoinedAVChatRoomList.set(e,1)}},{key:"deleteUnjoinedAVChatRoom",value:function(e){this._unjoinedAVChatRoomList.has(e)&&this._unjoinedAVChatRoomList.delete(e)}},{key:"isUnjoinedAVChatRoom",value:function(e){return this._unjoinedAVChatRoomList.has(e)}},{key:"onGroupAttributesUpdated",value:function(e){this._groupAttributesHandler&&this._groupAttributesHandler.onGroupAttributesUpdated(e)}},{key:"updateLocalMainSequenceOnReconnected",value:function(){this._groupAttributesHandler&&this._groupAttributesHandler.updateLocalMainSequenceOnReconnected()}},{key:"initGroupAttributes",value:function(e){return this._groupAttributesHandler.initGroupAttributes(e)}},{key:"setGroupAttributes",value:function(e){return this._groupAttributesHandler.setGroupAttributes(e)}},{key:"deleteGroupAttributes",value:function(e){return this._groupAttributesHandler.deleteGroupAttributes(e)}},{key:"getGroupAttributes",value:function(e){return this._groupAttributesHandler.getGroupAttributes(e)}},{key:"reset",value:function(){this.groupMap.clear(),this._unjoinedAVChatRoomList.clear(),this._receiptDetailCompleteMap.clear(),this._commonGroupHandler.reset(),this._groupSystemNoticeHandler.reset(),this._groupTipsHandler.reset(),this._AVChatRoomHandler&&this._AVChatRoomHandler.reset()}}]),a}(Do),Ns=function(){function e(t){n(this,e),this.userID="",this.avatar="",this.nick="",this.role="",this.joinTime="",this.lastSendMsgTime="",this.nameCard="",this.muteUntil=0,this.memberCustomField=[],this._initMember(t)}return s(e,[{key:"_initMember",value:function(e){this.updateMember(e)}},{key:"updateMember",value:function(e){var t=[null,void 0,"",0,NaN];e.memberCustomField&&vt(this.memberCustomField,e.memberCustomField),ct(this,e,["memberCustomField"],t)}},{key:"updateRole",value:function(e){["Owner","Admin","Member"].indexOf(e)<0||(this.role=e)}},{key:"updateMuteUntil",value:function(e){Ze(e)||(this.muteUntil=Math.floor((Date.now()+1e3*e)/1e3))}},{key:"updateNameCard",value:function(e){Ze(e)||(this.nameCard=e)}},{key:"updateMemberCustomField",value:function(e){e&&vt(this.memberCustomField,e)}}]),e}(),As=function(e){i(a,e);var o=f(a);function a(e){var t;return n(this,a),(t=o.call(this,e))._className="GroupMemberModule",t.groupMemberListMap=new Map,t.getInnerEmitterInstance().on(Qa,t._onProfileUpdated,_(t)),t}return s(a,[{key:"_onProfileUpdated",value:function(e){for(var t=this,o=e.data,n=function(e){var n=o[e];t.groupMemberListMap.forEach((function(e){e.has(n.userID)&&e.get(n.userID).updateMember({nick:n.nick,avatar:n.avatar})}))},a=0;a100?100:r};Et({groupID:o})?d.next="".concat(a):(d.offset=a,l=a+1);var p=[];return this.request({protocolName:kn,requestData:d}).then((function(e){var n=e.data,a=n.members,s=n.memberNum,r=n.next,i=void 0===r?void 0:r;if(Ze(i)||(l=Vt(i)?0:i),!Qe(a)||0===a.length)return l=0,Promise.resolve([]);var c=t.getModule(ao);return c.hasLocalGroup(o)&&(c.getLocalGroupProfile(o).memberNum=s),p=t._updateLocalGroupMemberMap(o,a),t.getModule(oo).getUserProfile({userIDList:a.map((function(e){return e.userID})),tagList:[Fe.NICK,Fe.AVATAR]})})).then((function(e){var n=e.data;if(!Qe(n)||0===n.length)return Ya({memberList:[],offset:l});var a=n.map((function(e){return{userID:e.userID,nick:e.nick,avatar:e.avatar}}));return t._updateLocalGroupMemberMap(o,a),u.setNetworkType(t.getNetworkType()).setMessage("groupID:".concat(o," offset:").concat(l," count:").concat(r)).end(),we.log("".concat(i," ok.")),ba({memberList:p,offset:l})})).catch((function(e){return t.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];u.setError(e,n,a).end()})),we.error("".concat(i," failed. error:"),e),ja(e)}))}},{key:"getGroupMemberProfile",value:function(e){var o=this,n="".concat(this._className,".getGroupMemberProfile"),a=new va(ya.GET_GROUP_MEMBER_PROFILE);a.setMessage(e.userIDList.length>5?"userIDList.length:".concat(e.userIDList.length):"userIDList:".concat(e.userIDList)),we.log("".concat(n," groupID:").concat(e.groupID," userIDList:").concat(e.userIDList.join(","))),e.userIDList.length>50&&(e.userIDList=e.userIDList.slice(0,50));var s=e.groupID,r=e.userIDList;return this._getGroupMemberProfileAdvance(t(t({},e),{},{userIDList:r})).then((function(e){var t=e.data.members;return Qe(t)&&0!==t.length?(o._updateLocalGroupMemberMap(s,t),o.getModule(oo).getUserProfile({userIDList:t.map((function(e){return e.userID})),tagList:[Fe.NICK,Fe.AVATAR]})):Ya([])})).then((function(e){var t=e.data.map((function(e){return{userID:e.userID,nick:e.nick,avatar:e.avatar}}));o._updateLocalGroupMemberMap(s,t);var n=r.filter((function(e){return o.hasLocalGroupMember(s,e)})).map((function(e){return o.getLocalGroupMemberInfo(s,e)}));return a.setNetworkType(o.getNetworkType()).end(),ba({memberList:n})}))}},{key:"addGroupMember",value:function(e){var t=this,o="".concat(this._className,".addGroupMember"),n=e.groupID,a=this.getModule(ao).getLocalGroupProfile(n),s=a.type,r=new va(ya.ADD_GROUP_MEMBER);if(r.setMessage("groupID:".concat(n," groupType:").concat(s)),It(s)){var i=new Ba({code:na.CANNOT_ADD_MEMBER_IN_AVCHATROOM,message:aa.CANNOT_ADD_MEMBER_IN_AVCHATROOM});return r.setCode(na.CANNOT_ADD_MEMBER_IN_AVCHATROOM).setError(aa.CANNOT_ADD_MEMBER_IN_AVCHATROOM).setNetworkType(this.getNetworkType()).end(),ja(i)}return e.userIDList=e.userIDList.map((function(e){return{userID:e}})),we.log("".concat(o," groupID:").concat(n)),this.request({protocolName:Pn,requestData:e}).then((function(n){var s=n.data.members;we.log("".concat(o," ok"));var i=s.filter((function(e){return 1===e.result})).map((function(e){return e.userID})),c=s.filter((function(e){return 0===e.result})).map((function(e){return e.userID})),u=s.filter((function(e){return 2===e.result})).map((function(e){return e.userID})),l=s.filter((function(e){return 4===e.result})).map((function(e){return e.userID})),d="groupID:".concat(e.groupID,", ")+"successUserIDList:".concat(i,", ")+"failureUserIDList:".concat(c,", ")+"existedUserIDList:".concat(u,", ")+"overLimitUserIDList:".concat(l);return r.setNetworkType(t.getNetworkType()).setMoreMessage(d).end(),0===i.length?ba({successUserIDList:i,failureUserIDList:c,existedUserIDList:u,overLimitUserIDList:l}):(a.memberCount+=i.length,t._updateConversationGroupProfile(a),ba({successUserIDList:i,failureUserIDList:c,existedUserIDList:u,overLimitUserIDList:l,group:a}))})).catch((function(e){return t.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];r.setError(e,n,a).end()})),we.error("".concat(o," failed. error:"),e),ja(e)}))}},{key:"deleteGroupMember",value:function(e){var t=this,o="".concat(this._className,".deleteGroupMember"),n=e.groupID,a=e.userIDList,s=new va(ya.DELETE_GROUP_MEMBER),r="groupID:".concat(n," ").concat(a.length>5?"userIDList.length:".concat(a.length):"userIDList:".concat(a));s.setMessage(r),we.log("".concat(o," groupID:").concat(n," userIDList:"),a);var i=this.getModule(ao).getLocalGroupProfile(n);return It(i.type)?ja(new Ba({code:na.CANNOT_KICK_MEMBER_IN_AVCHATROOM,message:aa.CANNOT_KICK_MEMBER_IN_AVCHATROOM})):this.request({protocolName:Un,requestData:e}).then((function(){return s.setNetworkType(t.getNetworkType()).end(),we.log("".concat(o," ok")),i.memberCount-=1,t._updateConversationGroupProfile(i),t.deleteLocalGroupMembers(n,a),ba({group:i,userIDList:a})})).catch((function(e){return t.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];s.setError(e,n,a).end()})),we.error("".concat(o," failed. error:"),e),ja(e)}))}},{key:"_updateConversationGroupProfile",value:function(e){this.getModule(co).updateConversationGroupProfile([e])}},{key:"setGroupMemberMuteTime",value:function(e){var t=this,o=e.groupID,n=e.userID,a=e.muteTime,s="".concat(this._className,".setGroupMemberMuteTime");if(n===this.getMyUserID())return ja(new Ba({code:na.CANNOT_MUTE_SELF,message:aa.CANNOT_MUTE_SELF}));we.log("".concat(s," groupID:").concat(o," userID:").concat(n));var r=new va(ya.SET_GROUP_MEMBER_MUTE_TIME);return r.setMessage("groupID:".concat(o," userID:").concat(n," muteTime:").concat(a)),this.modifyGroupMemberInfo({groupID:o,userID:n,muteTime:a}).then((function(e){r.setNetworkType(t.getNetworkType()).end(),we.log("".concat(s," ok"));var n=t.getModule(ao);return ba({group:n.getLocalGroupProfile(o),member:e})})).catch((function(e){return t.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];r.setError(e,n,a).end()})),we.error("".concat(s," failed. error:"),e),ja(e)}))}},{key:"setGroupMemberRole",value:function(e){var t=this,o="".concat(this._className,".setGroupMemberRole"),n=e.groupID,a=e.userID,s=e.role,r=this.getModule(ao).getLocalGroupProfile(n);if(r.selfInfo.role!==D.GRP_MBR_ROLE_OWNER)return ja({code:na.NOT_OWNER,message:aa.NOT_OWNER});if([D.GRP_WORK,D.GRP_AVCHATROOM].includes(r.type))return ja({code:na.CANNOT_SET_MEMBER_ROLE_IN_WORK_AND_AVCHATROOM,message:aa.CANNOT_SET_MEMBER_ROLE_IN_WORK_AND_AVCHATROOM});var i=[D.GRP_MBR_ROLE_ADMIN,D.GRP_MBR_ROLE_MEMBER];if(Et({groupID:n})&&i.push(D.GRP_MBR_ROLE_CUSTOM),i.indexOf(s)<0)return ja({code:na.INVALID_MEMBER_ROLE,message:aa.INVALID_MEMBER_ROLE});if(a===this.getMyUserID())return ja({code:na.CANNOT_SET_SELF_MEMBER_ROLE,message:aa.CANNOT_SET_SELF_MEMBER_ROLE});var c=new va(ya.SET_GROUP_MEMBER_ROLE);return c.setMessage("groupID:".concat(n," userID:").concat(a," role:").concat(s)),we.log("".concat(o," groupID:").concat(n," userID:").concat(a)),this.modifyGroupMemberInfo({groupID:n,userID:a,role:s}).then((function(e){return c.setNetworkType(t.getNetworkType()).end(),we.log("".concat(o," ok")),ba({group:r,member:e})})).catch((function(e){return t.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];c.setError(e,n,a).end()})),we.error("".concat(o," failed. error:"),e),ja(e)}))}},{key:"setGroupMemberNameCard",value:function(e){var t=this,o="".concat(this._className,".setGroupMemberNameCard"),n=e.groupID,a=e.userID,s=void 0===a?this.getMyUserID():a,r=e.nameCard;we.log("".concat(o," groupID:").concat(n," userID:").concat(s));var i=new va(ya.SET_GROUP_MEMBER_NAME_CARD);return i.setMessage("groupID:".concat(n," userID:").concat(s," nameCard:").concat(r)),this.modifyGroupMemberInfo({groupID:n,userID:s,nameCard:r}).then((function(e){we.log("".concat(o," ok")),i.setNetworkType(t.getNetworkType()).end();var a=t.getModule(ao).getLocalGroupProfile(n);return s===t.getMyUserID()&&a&&a.setSelfNameCard(r),ba({group:a,member:e})})).catch((function(e){return t.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];i.setError(e,n,a).end()})),we.error("".concat(o," failed. error:"),e),ja(e)}))}},{key:"setGroupMemberCustomField",value:function(e){var t=this,o="".concat(this._className,".setGroupMemberCustomField"),n=e.groupID,a=e.userID,s=void 0===a?this.getMyUserID():a,r=e.memberCustomField;we.log("".concat(o," groupID:").concat(n," userID:").concat(s));var i=new va(ya.SET_GROUP_MEMBER_CUSTOM_FIELD);return i.setMessage("groupID:".concat(n," userID:").concat(s," memberCustomField:").concat(JSON.stringify(r))),this.modifyGroupMemberInfo({groupID:n,userID:s,memberCustomField:r}).then((function(e){i.setNetworkType(t.getNetworkType()).end(),we.log("".concat(o," ok"));var a=t.getModule(ao).getLocalGroupProfile(n);return ba({group:a,member:e})})).catch((function(e){return t.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];i.setError(e,n,a).end()})),we.error("".concat(o," failed. error:"),e),ja(e)}))}},{key:"modifyGroupMemberInfo",value:function(e){var o=this,n=e.groupID,a=e.userID,s=void 0;return Tt(n)&&(n=bt(s=n)),this.request({protocolName:wn,requestData:t(t({},e),{},{groupID:n,topicID:s})}).then((function(){if(o.hasLocalGroupMember(n,a)){var t=o.getLocalGroupMemberInfo(n,a);return Ze(e.muteTime)||t.updateMuteUntil(e.muteTime),Ze(e.role)||t.updateRole(e.role),Ze(e.nameCard)||t.updateNameCard(e.nameCard),Ze(e.memberCustomField)||t.updateMemberCustomField(e.memberCustomField),t}return o.getGroupMemberProfile({groupID:n,userIDList:[a]}).then((function(e){return m(e.data.memberList,1)[0]}))}))}},{key:"_getGroupMemberProfileAdvance",value:function(e){return this.request({protocolName:Gn,requestData:t(t({},e),{},{memberInfoFilter:e.memberInfoFilter?e.memberInfoFilter:["Role","JoinTime","NameCard","ShutUpUntil"]})})}},{key:"_updateLocalGroupMemberMap",value:function(e,t){var o=this;return Qe(t)&&0!==t.length?t.map((function(t){return o.hasLocalGroupMember(e,t.userID)?o.getLocalGroupMemberInfo(e,t.userID).updateMember(t):o.setLocalGroupMember(e,new Ns(t)),o.getLocalGroupMemberInfo(e,t.userID)})):[]}},{key:"deleteLocalGroupMembers",value:function(e,t){var o=this.groupMemberListMap.get(e);o&&t.forEach((function(e){o.delete(e)}))}},{key:"getLocalGroupMemberInfo",value:function(e,t){return this.groupMemberListMap.has(e)?this.groupMemberListMap.get(e).get(t):null}},{key:"setLocalGroupMember",value:function(e,t){if(this.groupMemberListMap.has(e))this.groupMemberListMap.get(e).set(t.userID,t);else{var o=(new Map).set(t.userID,t);this.groupMemberListMap.set(e,o)}}},{key:"getLocalGroupMemberList",value:function(e){return this.groupMemberListMap.get(e)}},{key:"hasLocalGroupMember",value:function(e,t){return this.groupMemberListMap.has(e)&&this.groupMemberListMap.get(e).has(t)}},{key:"hasLocalGroupMemberMap",value:function(e){return this.groupMemberListMap.has(e)}},{key:"reset",value:function(){this.groupMemberListMap.clear()}}]),a}(Do),Os=["topicID","topicName","avatar","introduction","notification","unreadCount","muteAllMembers","customData","groupAtInfoList","nextMessageSeq","selfInfo"],Rs=function(e){return Ze(e)?{lastTime:0,lastSequence:0,fromAccount:"",payload:null,type:"",onlineOnlyFlag:!1}:e?{lastTime:e.time||0,lastSequence:e.sequence||0,fromAccount:e.from||"",payload:e.payload||null,type:e.type||"",onlineOnlyFlag:e._onlineOnlyFlag||!1}:void 0},Ls=function(){function e(t){n(this,e),this.topicID="",this.topicName="",this.avatar="",this.introduction="",this.notification="",this.unreadCount=0,this.muteAllMembers=!1,this.customData="",this.groupAtInfoList=[],this.nextMessageSeq=0,this.lastMessage=Rs(t.lastMessage),this.selfInfo={muteTime:0,readedSequence:0,messageRemindType:""},this._initGroupTopic(t)}return s(e,[{key:"_initGroupTopic",value:function(e){for(var t in e)Os.indexOf(t)<0||("selfInfo"===t?this.updateSelfInfo(e[t]):this[t]="muteAllMembers"===t?1===e[t]:e[t])}},{key:"updateUnreadCount",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this.unreadCount=e}},{key:"updateNextMessageSeq",value:function(e){this.nextMessageSeq=e}},{key:"updateLastMessage",value:function(e){this.lastMessage=Rs(e)}},{key:"updateGroupAtInfoList",value:function(e){this.groupAtInfoList=JSON.parse(JSON.stringify(e))}},{key:"updateTopic",value:function(e){Ze(e.selfInfo)||this.updateSelfInfo(e.selfInfo),Ze(e.muteAllMembers)||(this.muteAllMembers=1===e.muteAllMembers),ct(this,e,["groupID","lastMessageTime","selfInfo","muteAllMembers"])}},{key:"updateSelfInfo",value:function(e){ct(this.selfInfo,e,[],[""])}}]),e}(),ks=function(e){i(a,e);var o=f(a);function a(e){var t;return n(this,a),(t=o.call(this,e))._className="TopicModule",t._topicMap=new Map,t._getTopicTimeMap=new Map,t.TOPIC_CACHE_TIME=300,t.TOPIC_LAST_ACTIVE_TIME=3600,t.getInnerEmitterInstance().on(Xa,t._onCloudConfigUpdated,_(t)),t}return s(a,[{key:"_onCloudConfigUpdated",value:function(){var e=this.getCloudConfig("topic_cache_time"),t=this.getCloudConfig("topic_last_active_time");Ze(e)||(this.TOPIC_CACHE_TIME=Number(e)),Ze(t)||(this.TOPIC_LAST_ACTIVE_TIME=Number(t))}},{key:"onTopicCreated",value:function(e){var t=e.groupID;this.resetGetTopicTime(t),this.emitOuterEvent(S.TOPIC_CREATED,e)}},{key:"onTopicDeleted",value:function(e){var t=this,o=e.groupID,n=e.topicIDList;(void 0===n?[]:n).forEach((function(e){t._deleteLocalTopic(o,e)})),this.emitOuterEvent(S.TOPIC_DELETED,e)}},{key:"onTopicProfileUpdated",value:function(e){var t=e.groupID,o=e.topicID,n=this.getLocalTopic(t,o);n&&(n.updateTopic(e),this.emitOuterEvent(S.TOPIC_UPDATED,{groupID:t,topic:n}))}},{key:"onConversationProxy",value:function(e){var t=e.topicID,o=e.unreadCount,n=e.groupAtInfoList,a=bt(t),s=this.getLocalTopic(a,t),r=!1;s&&(Ze(o)||s.unreadCount===o||(s.updateUnreadCount(o),r=!0),Ze(n)||(s.updateGroupAtInfoList(n),r=!0)),r&&this.emitOuterEvent(S.TOPIC_UPDATED,{groupID:a,topic:s})}},{key:"onMessageSent",value:function(e){var t=e.groupID,o=e.topicID,n=e.lastMessage,a=this.getLocalTopic(t,o);a&&(a.nextMessageSeq+=1,a.updateLastMessage(n),this.emitOuterEvent(S.TOPIC_UPDATED,{groupID:t,topic:a}))}},{key:"onMessageModified",value:function(e){var t=e.to,o=e.time,n=e.sequence,a=e.elements,s=e.cloudCustomData,r=e.messageVersion,i=bt(t),c=this.getLocalTopic(i,t);if(c){var u=c.lastMessage;we.debug("".concat(this._className,".onMessageModified topicID:").concat(t," lastMessage:"),JSON.stringify(u),"options:",JSON.stringify(e)),u&&(null===u.payload||u.lastTime===o&&u.lastSequence===n&&u.version!==r)&&(u.type=a[0].type,u.payload=a[0].content,u.messageForShow=Ft(u.type,u.payload),u.cloudCustomData=s,u.version=r,u.lastSequence=n,u.lastTime=o,this.emitOuterEvent(S.TOPIC_UPDATED,{groupID:i,topic:c}))}}},{key:"getJoinedCommunityList",value:function(){return this.getModule(ao).getGroupList({isGroupWithTopicOnly:!0}).then((function(e){var t=e.data.groupList;return ba({groupList:void 0===t?[]:t})})).catch((function(e){return ja(e)}))}},{key:"createTopicInCommunity",value:function(e){var o=this,n="".concat(this._className,".createTopicInCommunity"),a=e.topicID;if(!Ze(a)&&!Tt(a))return ja({code:na.ILLEGAL_TOPIC_ID,message:aa.ILLEGAL_TOPIC_ID});var s=new va(ya.CREATE_TOPIC);return this.request({protocolName:Zn,requestData:t({},e)}).then((function(a){var r=a.data.topicID;return s.setMessage("topicID:".concat(r)).setNetworkType(o.getNetworkType()).end(),we.log("".concat(n," ok")),o._updateTopicMap([t(t({},e),{},{topicID:r})]),ba({topicID:r})})).catch((function(e){return o.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];s.setError(e,n,a).end()})),we.error("".concat(n," failed. error:"),e),ja(e)}))}},{key:"deleteTopicFromCommunity",value:function(e){var t=this,o="".concat(this._className,".deleteTopicFromCommunity"),n=e.groupID,a=e.topicIDList,s=void 0===a?[]:a,r=new va(ya.DELETE_TOPIC);return r.setMessage("groupID:".concat(n," topicIDList:").concat(s)),this.request({protocolName:ea,requestData:{groupID:n,topicIDList:s}}).then((function(e){var o=e.data.resultList,a=void 0===o?[]:o,s=a.filter((function(e){return 0===e.code})).map((function(e){return{topicID:e.topicID}})),i=a.filter((function(e){return 0!==e.code})),c="success count:".concat(s.length,", fail count:").concat(i.length);return r.setMoreMessage("".concat(c)).setNetworkType(t.getNetworkType()).end(),we.log("".concat(c)),s.forEach((function(e){t._deleteLocalTopic(n,e.topicID)})),ba({successTopicList:s,failureTopicList:i})})).catch((function(e){return t.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];r.setError(e,n,a).end()})),we.error("".concat(o," failed. error:"),e),ja(e)}))}},{key:"updateTopicProfile",value:function(e){var o=this,n="".concat(this._className,".updateTopicProfile"),a=new va(ya.UPDATE_TOPIC_PROFILE);return a.setMessage("groupID:".concat(e.groupID," topicID:").concat(e.topicID)),we.log("".concat(n," options:"),e),Ze(e.muteAllMembers)||(e.muteAllMembers=!0===e.muteAllMembers?"On":"Off"),this.request({protocolName:ta,requestData:t({},e)}).then((function(){return a.setNetworkType(o.getNetworkType()).end(),we.log("".concat(n," ok")),o._updateTopicMap([e]),ba({topic:o.getLocalTopic(e.groupID,e.topicID)})})).catch((function(e){return o.probeNetwork().then((function(t){var o=m(t,2),n=o[0],s=o[1];a.setError(e,n,s).end()})),we.error("".concat(n," failed. error:"),e),ja(e)}))}},{key:"getTopicList",value:function(e){var o=this,n="".concat(this._className,".getTopicList"),a=e.groupID,s=e.topicIDList,r=void 0===s?[]:s,i=new va(ya.GET_TOPIC_LIST);if(i.setMessage("groupID:".concat(a)),this._getTopicTimeMap.has(a)){var c=this._getTopicTimeMap.get(a);if(Date.now()-c<1e3*this.TOPIC_CACHE_TIME){var u=this._getLocalTopicList(a,r);return i.setNetworkType(this.getNetworkType()).setMoreMessage("from cache. topicList:".concat(u.length)).end(),we.log("".concat(n," groupID:").concat(a," from cache. topicList:").concat(u.length)),Ya({successTopicList:u,failureTopicList:[]})}}return this.request({protocolName:oa,requestData:{groupID:a,topicIDList:r}}).then((function(e){var s=e.data.topicInfoList,c=[],u=[],l=[];(void 0===s?[]:s).forEach((function(e){var o=e.topic,n=e.selfInfo,a=e.code,s=e.message,r=o.topicID;0===a?(c.push(t(t({},o),{},{selfInfo:n})),u.push(r)):l.push({topicID:r,code:a,message:s})})),o._updateTopicMap(c);var d="successTopicList:".concat(u.length," failureTopicList:").concat(l.length);i.setNetworkType(o.getNetworkType()).setMoreMessage("".concat(d)).end(),we.log("".concat(n," groupID:").concat(a," from remote. ").concat(d)),Vt(r)&&!Vt(u)&&o._getTopicTimeMap.set(a,Date.now());var p=[];return Vt(u)||(p=o._getLocalTopicList(a,u)),ba({successTopicList:p,failureTopicList:l})})).catch((function(e){return o.probeNetwork(e).then((function(t){var o=m(t,2),n=o[0],a=o[1];i.setError(e,n,a).end()})),we.error("".concat(n," failed. error:"),e),ja(e)}))}},{key:"hasLocalTopic",value:function(e,t){return!!this._topicMap.has(e)&&!!this._topicMap.get(e).has(t)}},{key:"getLocalTopic",value:function(e,t){var o=null;return this._topicMap.has(e)&&(o=this._topicMap.get(e).get(t)),o}},{key:"_getLocalTopicList",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],o=this._topicMap.get(e),n=[];return o&&(n=M(o.values())),0===t.length?n:n.filter((function(e){return t.includes(e.topicID)}))}},{key:"_deleteLocalTopic",value:function(e,t){this._topicMap.has(e)&&this._topicMap.get(e).delete(t)}},{key:"_updateTopicMap",value:function(e){var t=this,o=[];(e.forEach((function(e){var n=e.groupID,a=e.topicID,s=null;t._topicMap.has(n)||t._topicMap.set(n,new Map),t._topicMap.get(n).has(a)?(s=t._topicMap.get(n).get(a)).updateTopic(e):(s=new Ls(e),t._topicMap.get(n).set(a,s));var r=s.nextMessageSeq-s.selfInfo.readedSequence-1;o.push({conversationID:"".concat(D.CONV_GROUP).concat(a),type:D.CONV_TOPIC,unreadCount:r>0?r:0})})),o.length>0)&&this.getModule(co).updateTopicConversation(o)}},{key:"resetGetTopicTime",value:function(e){var t=this;Ze(e)?M(this._getTopicTimeMap.keys()).forEach((function(e){t._getTopicTimeMap.set(e,0)})):this._getTopicTimeMap.set(e,0)}},{key:"getTopicListOnReconnected",value:function(){var e=this,t=M(this._topicMap.keys()),o=[];t.forEach((function(t){var n=[];e._getLocalTopicList(t).forEach((function(t){var o=t.lastMessage.lastTime,a=void 0===o?0:o;Date.now()-1e3*a<1e3*e.TOPIC_LAST_ACTIVE_TIME&&n.push(t.topicID)})),n.length>0&&o.push({groupID:t,topicIDList:n})})),we.log("".concat(this._className,".getTopicListOnReconnected. active community count:").concat(o.length)),this._relayGetTopicList(o)}},{key:"_relayGetTopicList",value:function(e){var t=this;if(0!==e.length){var o=e.shift(),n=o.topicIDList.length>5?"topicIDList.length:".concat(o.topicIDList.length):"topicIDList:".concat(o.topicIDList),a=new va(ya.RELAY_GET_TOPIC_LIST);a.setMessage(n),we.log("".concat(this._className,"._relayGetTopicList. ").concat(n)),this.getTopicList(o).then((function(){a.setNetworkType(t.getNetworkType()).end(),t._relayGetTopicList(e)})).catch((function(o){t.probeNetwork().then((function(e){var t=m(e,2),n=t[0],s=t[1];a.setError(o,n,s).end()})),t._relayGetTopicList(e)}))}}},{key:"reset",value:function(){we.log("".concat(this._className,".reset")),this._topicMap.clear(),this._getTopicTimeMap.clear(),this.TOPIC_CACHE_TIME=300,this.TOPIC_LAST_ACTIVE_TIME=3600}}]),a}(Do),Gs=function(){function e(t){n(this,e),this._userModule=t,this._className="ProfileHandler",this.TAG="profile",this.accountProfileMap=new Map,this.expirationTime=864e5}return s(e,[{key:"setExpirationTime",value:function(e){this.expirationTime=e}},{key:"getUserProfile",value:function(e){var t=this,o=e.userIDList;e.fromAccount=this._userModule.getMyAccount(),o.length>100&&(we.warn("".concat(this._className,".getUserProfile 获取用户资料人数不能超过100人")),o.length=100);for(var n,a=[],s=[],r=0,i=o.length;r5?"userIDList.length:".concat(o.length):"userIDList:".concat(o)),this._userModule.request({protocolName:Uo,requestData:e}).then((function(e){l.setNetworkType(t._userModule.getNetworkType()).end(),we.info("".concat(t._className,".getUserProfile ok"));var o=t._handleResponse(e).concat(s);return ba(c?o[0]:o)})).catch((function(e){return t._userModule.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];l.setError(e,n,a).end()})),we.error("".concat(t._className,".getUserProfile failed. error:"),e),ja(e)}))}},{key:"getMyProfile",value:function(){var e=this._userModule.getMyAccount();if(we.log("".concat(this._className,".getMyProfile myAccount:").concat(e)),this._fillMap(),this._containsAccount(e)){var t=this._getProfileFromMap(e);return we.debug("".concat(this._className,".getMyProfile from cache, myProfile:")+JSON.stringify(t)),Ya(t)}return this.getUserProfile({fromAccount:e,userIDList:[e],bFromGetMyProfile:!0})}},{key:"_handleResponse",value:function(e){for(var t,o,n=it.now(),a=e.data.userProfileItem,s=[],r=0,i=a.length;r-1)o.profileCustomField.push({key:t[n].tag,value:t[n].value});else switch(t[n].tag){case Fe.NICK:o.nick=t[n].value;break;case Fe.GENDER:o.gender=t[n].value;break;case Fe.BIRTHDAY:o.birthday=t[n].value;break;case Fe.LOCATION:o.location=t[n].value;break;case Fe.SELFSIGNATURE:o.selfSignature=t[n].value;break;case Fe.ALLOWTYPE:o.allowType=t[n].value;break;case Fe.LANGUAGE:o.language=t[n].value;break;case Fe.AVATAR:o.avatar=t[n].value;break;case Fe.MESSAGESETTINGS:o.messageSettings=t[n].value;break;case Fe.ADMINFORBIDTYPE:o.adminForbidType=t[n].value;break;case Fe.LEVEL:o.level=t[n].value;break;case Fe.ROLE:o.role=t[n].value;break;default:we.warn("".concat(this._className,"._handleResponse unknown tag:"),t[n].tag,t[n].value)}return o}},{key:"updateMyProfile",value:function(e){var t=this,o="".concat(this._className,".updateMyProfile"),n=new va(ya.UPDATE_MY_PROFILE);n.setMessage(JSON.stringify(e));var a=(new rs).validate(e);if(!a.valid)return n.setCode(na.UPDATE_PROFILE_INVALID_PARAM).setMoreMessage("".concat(o," info:").concat(a.tips)).setNetworkType(this._userModule.getNetworkType()).end(),we.error("".concat(o," info:").concat(a.tips,",请参考 https://web.sdk.qcloud.com/im/doc/zh-cn/SDK.html#updateMyProfile")),ja({code:na.UPDATE_PROFILE_INVALID_PARAM,message:aa.UPDATE_PROFILE_INVALID_PARAM});var s=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&("profileCustomField"===r?e.profileCustomField.forEach((function(e){s.push({tag:e.key,value:e.value})})):s.push({tag:Fe[r.toUpperCase()],value:e[r]}));return 0===s.length?(n.setCode(na.UPDATE_PROFILE_NO_KEY).setMoreMessage(aa.UPDATE_PROFILE_NO_KEY).setNetworkType(this._userModule.getNetworkType()).end(),we.error("".concat(o," info:").concat(aa.UPDATE_PROFILE_NO_KEY,",请参考 https://web.sdk.qcloud.com/im/doc/zh-cn/SDK.html#updateMyProfile")),ja({code:na.UPDATE_PROFILE_NO_KEY,message:aa.UPDATE_PROFILE_NO_KEY})):this._userModule.request({protocolName:wo,requestData:{fromAccount:this._userModule.getMyAccount(),profileItem:s}}).then((function(a){n.setNetworkType(t._userModule.getNetworkType()).end(),we.info("".concat(o," ok"));var s=t._updateMap(t._userModule.getMyAccount(),e);return t._userModule.emitOuterEvent(S.PROFILE_UPDATED,[s]),Ya(s)})).catch((function(e){return t._userModule.probeNetwork().then((function(t){var o=m(t,2),a=o[0],s=o[1];n.setError(e,a,s).end()})),we.error("".concat(o," failed. error:"),e),ja(e)}))}},{key:"onProfileModified",value:function(e){var t=e.dataList;if(!Vt(t)){var o,n,a=t.length;we.debug("".concat(this._className,".onProfileModified count:").concat(a," dataList:"),e.dataList);for(var s=[],r=0;r0&&(this._userModule.emitInnerEvent(Qa,s),this._userModule.emitOuterEvent(S.PROFILE_UPDATED,s))}}},{key:"_fillMap",value:function(){if(0===this.accountProfileMap.size){for(var e=this._getCachedProfiles(),t=Date.now(),o=0,n=e.length;o0&&a.push(o)):a.push(t.userID));0!==a.length&&(we.info("".concat(this._className,".onConversationsProfileUpdated toAccountList:").concat(a)),this.getUserProfile({userIDList:a}))}},{key:"getNickAndAvatarByUserID",value:function(e){if(this._containsAccount(e)){var t=this._getProfileFromMap(e);return{nick:t.nick,avatar:t.avatar}}return{nick:"",avatar:""}}},{key:"reset",value:function(){this._flushMap(!0),this.accountProfileMap.clear()}}]),e}(),Ps=s((function e(t){n(this,e),Vt||(this.userID=t.userID||"",this.timeStamp=t.timeStamp||0)})),Us=function(){function e(t){n(this,e),this._userModule=t,this._className="BlacklistHandler",this._blacklistMap=new Map,this.startIndex=0,this.maxLimited=100,this.currentSequence=0}return s(e,[{key:"getLocalBlacklist",value:function(){return M(this._blacklistMap.keys())}},{key:"getBlacklist",value:function(){var e=this,t="".concat(this._className,".getBlacklist"),o={fromAccount:this._userModule.getMyAccount(),maxLimited:this.maxLimited,startIndex:0,lastSequence:this.currentSequence},n=new va(ya.GET_BLACKLIST);return this._userModule.request({protocolName:bo,requestData:o}).then((function(o){var a=o.data,s=a.blackListItem,r=a.currentSequence,i=Vt(s)?0:s.length;n.setNetworkType(e._userModule.getNetworkType()).setMessage("blackList count:".concat(i)).end(),we.info("".concat(t," ok")),e.currentSequence=r,e._handleResponse(s,!0),e._userModule.emitOuterEvent(S.BLACKLIST_UPDATED,M(e._blacklistMap.keys()))})).catch((function(o){return e._userModule.probeNetwork().then((function(e){var t=m(e,2),a=t[0],s=t[1];n.setError(o,a,s).end()})),we.error("".concat(t," failed. error:"),o),ja(o)}))}},{key:"addBlacklist",value:function(e){var t=this,o="".concat(this._className,".addBlacklist"),n=new va(ya.ADD_TO_BLACKLIST);if(!Qe(e.userIDList))return n.setCode(na.ADD_BLACKLIST_INVALID_PARAM).setMessage(aa.ADD_BLACKLIST_INVALID_PARAM).setNetworkType(this._userModule.getNetworkType()).end(),we.error("".concat(o," options.userIDList 必需是数组")),ja({code:na.ADD_BLACKLIST_INVALID_PARAM,message:aa.ADD_BLACKLIST_INVALID_PARAM});var a=this._userModule.getMyAccount();return 1===e.userIDList.length&&e.userIDList[0]===a?(n.setCode(na.CANNOT_ADD_SELF_TO_BLACKLIST).setMessage(aa.CANNOT_ADD_SELF_TO_BLACKLIST).setNetworkType(this._userModule.getNetworkType()).end(),we.error("".concat(o," 不能把自己拉黑")),ja({code:na.CANNOT_ADD_SELF_TO_BLACKLIST,message:aa.CANNOT_ADD_SELF_TO_BLACKLIST})):(e.userIDList.includes(a)&&(e.userIDList=e.userIDList.filter((function(e){return e!==a})),we.warn("".concat(o," 不能把自己拉黑,已过滤"))),e.fromAccount=this._userModule.getMyAccount(),e.toAccount=e.userIDList,this._userModule.request({protocolName:Fo,requestData:e}).then((function(a){return n.setNetworkType(t._userModule.getNetworkType()).setMessage(e.userIDList.length>5?"userIDList.length:".concat(e.userIDList.length):"userIDList:".concat(e.userIDList)).end(),we.info("".concat(o," ok")),t._handleResponse(a.resultItem,!0),ba(M(t._blacklistMap.keys()))})).catch((function(e){return t._userModule.probeNetwork().then((function(t){var o=m(t,2),a=o[0],s=o[1];n.setError(e,a,s).end()})),we.error("".concat(o," failed. error:"),e),ja(e)})))}},{key:"_handleResponse",value:function(e,t){if(!Vt(e))for(var o,n,a,s=0,r=e.length;s5?"userIDList.length:".concat(e.userIDList.length):"userIDList:".concat(e.userIDList)).end(),we.info("".concat(o," ok")),t._handleResponse(a.data.resultItem,!1),ba(M(t._blacklistMap.keys()))})).catch((function(e){return t._userModule.probeNetwork().then((function(t){var o=m(t,2),a=o[0],s=o[1];n.setError(e,a,s).end()})),we.error("".concat(o," failed. error:"),e),ja(e)}))):(n.setCode(na.DEL_BLACKLIST_INVALID_PARAM).setMessage(aa.DEL_BLACKLIST_INVALID_PARAM).setNetworkType(this._userModule.getNetworkType()).end(),we.error("".concat(o," options.userIDList 必需是数组")),ja({code:na.DEL_BLACKLIST_INVALID_PARAM,message:aa.DEL_BLACKLIST_INVALID_PARAM}))}},{key:"onAccountDeleted",value:function(e){for(var t,o=[],n=0,a=e.length;n0&&(we.log("".concat(this._className,".onAccountDeleted count:").concat(o.length," userIDList:"),o),this._userModule.emitOuterEvent(S.BLACKLIST_UPDATED,M(this._blacklistMap.keys())))}},{key:"onAccountAdded",value:function(e){for(var t,o=[],n=0,a=e.length;n0&&(we.log("".concat(this._className,".onAccountAdded count:").concat(o.length," userIDList:"),o),this._userModule.emitOuterEvent(S.BLACKLIST_UPDATED,M(this._blacklistMap.keys())))}},{key:"reset",value:function(){this._blacklistMap.clear(),this.startIndex=0,this.maxLimited=100,this.currentSequence=0}}]),e}(),ws=function(e){i(o,e);var t=f(o);function o(e){var a;return n(this,o),(a=t.call(this,e))._className="UserModule",a._profileHandler=new Gs(_(a)),a._blacklistHandler=new Us(_(a)),a.getInnerEmitterInstance().on(Ja,a.onContextUpdated,_(a)),a}return s(o,[{key:"onContextUpdated",value:function(e){this._profileHandler.getMyProfile(),this._blacklistHandler.getBlacklist()}},{key:"onProfileModified",value:function(e){this._profileHandler.onProfileModified(e)}},{key:"onRelationChainModified",value:function(e){var t=e.dataList;if(!Vt(t)){var o=[];t.forEach((function(e){e.blackListDelAccount&&o.push.apply(o,M(e.blackListDelAccount))})),o.length>0&&this._blacklistHandler.onAccountDeleted(o);var n=[];t.forEach((function(e){e.blackListAddAccount&&n.push.apply(n,M(e.blackListAddAccount))})),n.length>0&&this._blacklistHandler.onAccountAdded(n)}}},{key:"onConversationsProfileUpdated",value:function(e){this._profileHandler.onConversationsProfileUpdated(e)}},{key:"getMyAccount",value:function(){return this.getMyUserID()}},{key:"getMyProfile",value:function(){return this._profileHandler.getMyProfile()}},{key:"getStorageModule",value:function(){return this.getModule(lo)}},{key:"isMyFriend",value:function(e){var t=this.getModule(so);return!!t&&t.isMyFriend(e)}},{key:"getUserProfile",value:function(e){return this._profileHandler.getUserProfile(e)}},{key:"updateMyProfile",value:function(e){return this._profileHandler.updateMyProfile(e)}},{key:"getNickAndAvatarByUserID",value:function(e){return this._profileHandler.getNickAndAvatarByUserID(e)}},{key:"getLocalBlacklist",value:function(){var e=this._blacklistHandler.getLocalBlacklist();return Ya(e)}},{key:"addBlacklist",value:function(e){return this._blacklistHandler.addBlacklist(e)}},{key:"deleteBlacklist",value:function(e){return this._blacklistHandler.deleteBlacklist(e)}},{key:"reset",value:function(){we.log("".concat(this._className,".reset")),this._profileHandler.reset(),this._blacklistHandler.reset()}}]),o}(Do),bs=function(){function e(t,o){n(this,e),this._moduleManager=t,this._isLoggedIn=!1,this._SDKAppID=o.SDKAppID,this._userID=o.userID||"",this._userSig=o.userSig||"",this._version="2.20.1",this._a2Key="",this._tinyID="",this._contentType="json",this._unlimitedAVChatRoom=o.unlimitedAVChatRoom,this._scene=o.scene||"",this._oversea=o.oversea,this._instanceID=o.instanceID,this._statusInstanceID=0,this._isDevMode=o.devMode,this._proxyServer=o.proxyServer}return s(e,[{key:"isLoggedIn",value:function(){return this._isLoggedIn}},{key:"isOversea",value:function(){return this._oversea}},{key:"isPrivateNetWork",value:function(){return this._proxyServer}},{key:"isDevMode",value:function(){return this._isDevMode}},{key:"isSingaporeSite",value:function(){return this._SDKAppID>=2e7&&this._SDKAppID<3e7}},{key:"isKoreaSite",value:function(){return this._SDKAppID>=3e7&&this._SDKAppID<4e7}},{key:"isGermanySite",value:function(){return this._SDKAppID>=4e7&&this._SDKAppID<5e7}},{key:"isIndiaSite",value:function(){return this._SDKAppID>=5e7&&this._SDKAppID<6e7}},{key:"isUnlimitedAVChatRoom",value:function(){return this._unlimitedAVChatRoom}},{key:"getUserID",value:function(){return this._userID}},{key:"setUserID",value:function(e){this._userID=e}},{key:"setUserSig",value:function(e){this._userSig=e}},{key:"getUserSig",value:function(){return this._userSig}},{key:"getSDKAppID",value:function(){return this._SDKAppID}},{key:"getTinyID",value:function(){return this._tinyID}},{key:"setTinyID",value:function(e){this._tinyID=e,this._isLoggedIn=!0}},{key:"getScene",value:function(){return this._isTUIKit()?"tuikit":this._scene}},{key:"getInstanceID",value:function(){return this._instanceID}},{key:"getStatusInstanceID",value:function(){return this._statusInstanceID}},{key:"setStatusInstanceID",value:function(e){this._statusInstanceID=e}},{key:"getVersion",value:function(){return this._version}},{key:"getA2Key",value:function(){return this._a2Key}},{key:"setA2Key",value:function(e){this._a2Key=e}},{key:"getContentType",value:function(){return this._contentType}},{key:"getProxyServer",value:function(){return this._proxyServer}},{key:"_isTUIKit",value:function(){var e=!1,t=!1,o=!1,n=!1,a=[];te&&(a=Object.keys(ne)),oe&&(a=ee?Object.keys(uni):Object.keys(window));for(var s=0,r=a.length;s0){for(var u=0,l=c.length;u0&&void 0!==arguments[0]?arguments[0]:0;if(!this.isLoggedIn())return ja({code:na.USER_NOT_LOGGED_IN,message:aa.USER_NOT_LOGGED_IN});var o=new va(ya.LOGOUT);return o.setNetworkType(this.getNetworkType()).setMessage("identifier:".concat(this.getMyUserID())).end(!0),we.info("".concat(this._className,".logout type:").concat(t)),0===t&&this._moduleManager.setNotReadyReason(na.LOGGED_OUT),this.request({protocolName:Ao,requestData:{type:t}}).then((function(){return e.resetReady(),Ya({})})).catch((function(t){return we.error("".concat(e._className,"._logout error:"),t),e.resetReady(),Ya({})}))}},{key:"_fetchCloudControlConfig",value:function(){this.getModule(Io).fetchConfig()}},{key:"_hello",value:function(){var e=this;this._lastWsHelloTs=Date.now(),this.request({protocolName:Oo}).catch((function(t){we.warn("".concat(e._className,"._hello error:"),t)}))}},{key:"getLastWsHelloTs",value:function(){return this._lastWsHelloTs}},{key:"_checkLoginInfo",value:function(e){var t=0,o="";return Vt(this.getModule(uo).getSDKAppID())?(t=na.NO_SDKAPPID,o=aa.NO_SDKAPPID):Vt(e.userID)?(t=na.NO_IDENTIFIER,o=aa.NO_IDENTIFIER):Vt(e.userSig)&&(t=na.NO_USERSIG,o=aa.NO_USERSIG),{code:t,message:o}}},{key:"onMultipleAccountKickedOut",value:function(e){var t=this;new va(ya.KICKED_OUT).setNetworkType(this.getNetworkType()).setMessage("type:".concat(D.KICKED_OUT_MULT_ACCOUNT," newInstanceInfo:").concat(JSON.stringify(e))).end(!0),we.warn("".concat(this._className,".onMultipleAccountKickedOut userID:").concat(this.getMyUserID()," newInstanceInfo:"),e),this.logout(1).then((function(){t.emitOuterEvent(S.KICKED_OUT,{type:D.KICKED_OUT_MULT_ACCOUNT}),t._moduleManager.setNotReadyReason(na.KICKED_OUT_MULT_ACCOUNT),t._moduleManager.reset()}))}},{key:"onMultipleDeviceKickedOut",value:function(e){var t=this;new va(ya.KICKED_OUT).setNetworkType(this.getNetworkType()).setMessage("type:".concat(D.KICKED_OUT_MULT_DEVICE," newInstanceInfo:").concat(JSON.stringify(e))).end(!0),we.warn("".concat(this._className,".onMultipleDeviceKickedOut userID:").concat(this.getMyUserID()," newInstanceInfo:"),e),this.logout(1).then((function(){t.emitOuterEvent(S.KICKED_OUT,{type:D.KICKED_OUT_MULT_DEVICE}),t._moduleManager.setNotReadyReason(na.KICKED_OUT_MULT_DEVICE),t._moduleManager.reset()}))}},{key:"onUserSigExpired",value:function(){new va(ya.KICKED_OUT).setNetworkType(this.getNetworkType()).setMessage(D.KICKED_OUT_USERSIG_EXPIRED).end(!0),we.warn("".concat(this._className,".onUserSigExpired: userSig 签名过期被踢下线")),0!==this.getModule(uo).getStatusInstanceID()&&(this.emitOuterEvent(S.KICKED_OUT,{type:D.KICKED_OUT_USERSIG_EXPIRED}),this._moduleManager.setNotReadyReason(na.KICKED_OUT_USERSIG_EXPIRED),this._moduleManager.reset())}},{key:"onRestApiKickedOut",value:function(e){(new va(ya.KICKED_OUT).setNetworkType(this.getNetworkType()).setMessage("type:".concat(D.KICKED_OUT_REST_API," newInstanceInfo:").concat(JSON.stringify(e))).end(!0),we.warn("".concat(this._className,".onRestApiKickedOut userID:").concat(this.getMyUserID()," newInstanceInfo:"),e),0!==this.getModule(uo).getStatusInstanceID())&&(this.emitOuterEvent(S.KICKED_OUT,{type:D.KICKED_OUT_REST_API}),this._moduleManager.setNotReadyReason(na.KICKED_OUT_REST_API),this._moduleManager.reset(),this.getModule(vo).onRestApiKickedOut())}},{key:"reset",value:function(){we.log("".concat(this._className,".reset")),this.resetReady(),this._helloInterval=120,this._lastLoginTs=0,this._lastWsHelloTs=0}}]),o}(Do);function qs(){return null}var Vs=function(){function e(t){n(this,e),this._moduleManager=t,this._className="StorageModule",this._storageQueue=new Map,this._errorTolerantHandle()}return s(e,[{key:"_errorTolerantHandle",value:function(){te||!Ze(window)&&!Ze(window.localStorage)||(this.getItem=qs,this.setItem=qs,this.removeItem=qs,this.clear=qs)}},{key:"onCheckTimer",value:function(e){if(e%20==0){if(0===this._storageQueue.size)return;this._doFlush()}}},{key:"_doFlush",value:function(){try{var e,t=C(this._storageQueue);try{for(t.s();!(e=t.n()).done;){var o=m(e.value,2),n=o[0],a=o[1];this._setStorageSync(this._getKey(n),a)}}catch(s){t.e(s)}finally{t.f()}this._storageQueue.clear()}catch(r){we.warn("".concat(this._className,"._doFlush error:"),r)}}},{key:"_getPrefix",value:function(){var e=this._moduleManager.getModule(uo);return"TIM_".concat(e.getSDKAppID(),"_").concat(e.getUserID(),"_")}},{key:"_getKey",value:function(e){return"".concat(this._getPrefix()).concat(e)}},{key:"getItem",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];try{var o=t?this._getKey(e):e;return this.getStorageSync(o)}catch(n){return we.warn("".concat(this._className,".getItem error:"),n),{}}}},{key:"setItem",value:function(e,t){var o=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];if(o){var a=n?this._getKey(e):e;this._setStorageSync(a,t)}else this._storageQueue.set(e,t)}},{key:"clear",value:function(){try{te?ne.clearStorageSync():localStorage&&localStorage.clear()}catch(e){we.warn("".concat(this._className,".clear error:"),e)}}},{key:"removeItem",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];try{var o=t?this._getKey(e):e;this._removeStorageSync(o)}catch(n){we.warn("".concat(this._className,".removeItem error:"),n)}}},{key:"getSize",value:function(e){var t=this,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"b";try{var n={size:0,limitSize:5242880,unit:o};if(Object.defineProperty(n,"leftSize",{enumerable:!0,get:function(){return n.limitSize-n.size}}),te&&(n.limitSize=1024*ne.getStorageInfoSync().limitSize),e)n.size=JSON.stringify(this.getItem(e)).length+this._getKey(e).length;else if(te){var a=ne.getStorageInfoSync(),s=a.keys;s.forEach((function(e){n.size+=JSON.stringify(t.getStorageSync(e)).length+t._getKey(e).length}))}else if(localStorage)for(var r in localStorage)localStorage.hasOwnProperty(r)&&(n.size+=localStorage.getItem(r).length+r.length);return this._convertUnit(n)}catch(i){we.warn("".concat(this._className," error:"),i)}}},{key:"_convertUnit",value:function(e){var t={},o=e.unit;for(var n in t.unit=o,e)"number"==typeof e[n]&&("kb"===o.toLowerCase()?t[n]=Math.round(e[n]/1024):"mb"===o.toLowerCase()?t[n]=Math.round(e[n]/1024/1024):t[n]=e[n]);return t}},{key:"_setStorageSync",value:function(e,t){te?Q?my.setStorageSync({key:e,data:t}):ne.setStorageSync(e,t):localStorage&&localStorage.setItem(e,JSON.stringify(t))}},{key:"getStorageSync",value:function(e){return te?Q?my.getStorageSync({key:e}).data:ne.getStorageSync(e):localStorage?JSON.parse(localStorage.getItem(e)):{}}},{key:"_removeStorageSync",value:function(e){te?Q?my.removeStorageSync({key:e}):ne.removeStorageSync(e):localStorage&&localStorage.removeItem(e)}},{key:"reset",value:function(){we.log("".concat(this._className,".reset")),this._doFlush()}}]),e}(),Ks=function(){function e(t){n(this,e),this._className="SSOLogBody",this._report=[]}return s(e,[{key:"pushIn",value:function(e){we.debug("".concat(this._className,".pushIn"),this._report.length,e),this._report.push(e)}},{key:"backfill",value:function(e){var t;Qe(e)&&0!==e.length&&(we.debug("".concat(this._className,".backfill"),this._report.length,e.length),(t=this._report).unshift.apply(t,M(e)))}},{key:"getLogsNumInMemory",value:function(){return this._report.length}},{key:"isEmpty",value:function(){return 0===this._report.length}},{key:"_reset",value:function(){this._report.length=0,this._report=[]}},{key:"getLogsInMemory",value:function(){var e=this._report.slice();return this._reset(),e}}]),e}(),Hs=function(e){var t=e.getModule(uo);return{SDKType:10,SDKAppID:t.getSDKAppID(),SDKVersion:t.getVersion(),tinyID:Number(t.getTinyID()),userID:t.getUserID(),platform:e.getPlatform(),instanceID:t.getInstanceID(),traceID:Re()}},Bs=function(e){i(a,e);var o=f(a);function a(e){var t;n(this,a),(t=o.call(this,e))._className="EventStatModule",t.TAG="im-ssolog-event",t._reportBody=new Ks,t.MIN_THRESHOLD=20,t.MAX_THRESHOLD=100,t.WAITING_TIME=6e4,t.REPORT_LEVEL=[4,5,6],t.REPORT_SDKAPPID_BLACKLIST=[],t.REPORT_TINYID_WHITELIST=[],t._lastReportTime=Date.now();var s=t.getInnerEmitterInstance();return s.on(Ja,t._onLoginSuccess,_(t)),s.on(Xa,t._onCloudConfigUpdated,_(t)),t}return s(a,[{key:"reportAtOnce",value:function(){we.debug("".concat(this._className,".reportAtOnce")),this._report()}},{key:"_onLoginSuccess",value:function(){var e=this,t=this.getModule(lo),o=t.getItem(this.TAG,!1);!Vt(o)&&ot(o.forEach)&&(we.log("".concat(this._className,"._onLoginSuccess get ssolog in storage, count:").concat(o.length)),o.forEach((function(t){e._reportBody.pushIn(t)})),t.removeItem(this.TAG,!1))}},{key:"_onCloudConfigUpdated",value:function(){var e=this.getCloudConfig("evt_rpt_threshold"),t=this.getCloudConfig("evt_rpt_waiting"),o=this.getCloudConfig("evt_rpt_level"),n=this.getCloudConfig("evt_rpt_sdkappid_bl"),a=this.getCloudConfig("evt_rpt_tinyid_wl");Ze(e)||(this.MIN_THRESHOLD=Number(e)),Ze(t)||(this.WAITING_TIME=Number(t)),Ze(o)||(this.REPORT_LEVEL=o.split(",").map((function(e){return Number(e)}))),Ze(n)||(this.REPORT_SDKAPPID_BLACKLIST=n.split(",").map((function(e){return Number(e)}))),Ze(a)||(this.REPORT_TINYID_WHITELIST=a.split(","))}},{key:"pushIn",value:function(e){e instanceof va&&(e.updateTimeStamp(),this._reportBody.pushIn(e),this._reportBody.getLogsNumInMemory()>=this.MIN_THRESHOLD&&this._report())}},{key:"onCheckTimer",value:function(){Date.now()e.MAX_THRESHOLD&&e._flushAtOnce()}))}else this._lastReportTime=Date.now()}}},{key:"_flushAtOnce",value:function(){var e=this.getModule(lo),t=e.getItem(this.TAG,!1),o=this._reportBody.getLogsInMemory();if(Vt(t))we.log("".concat(this._className,"._flushAtOnce count:").concat(o.length)),e.setItem(this.TAG,o,!0,!1);else{var n=o.concat(t);n.length>this.MAX_THRESHOLD&&(n=n.slice(0,this.MAX_THRESHOLD)),we.log("".concat(this._className,"._flushAtOnce count:").concat(n.length)),e.setItem(this.TAG,n,!0,!1)}}},{key:"reset",value:function(){we.log("".concat(this._className,".reset")),this._lastReportTime=0,this._report(),this.REPORT_SDKAPPID_BLACKLIST=[],this.REPORT_TINYID_WHITELIST=[]}}]),a}(Do),xs="none",Ws="online",Ys=[na.OVER_FREQUENCY_LIMIT,na.OPEN_SERVICE_OVERLOAD_ERROR],js=function(){function e(t){n(this,e),this._moduleManager=t,this._networkType="",this._className="NetMonitorModule",this.MAX_WAIT_TIME=3e3,this._mpNetworkStatusCallback=null,this._webOnlineCallback=null,this._webOfflineCallback=null}return s(e,[{key:"start",value:function(){var e=this;te?(ne.getNetworkType({success:function(t){e._networkType=t.networkType,t.networkType===xs?we.warn("".concat(e._className,".start no network, please check!")):we.info("".concat(e._className,".start networkType:").concat(t.networkType))}}),this._mpNetworkStatusCallback=this._onNetworkStatusChange.bind(this),ne.onNetworkStatusChange(this._mpNetworkStatusCallback)):(this._networkType=Ws,this._webOnlineCallback=this._onWebOnline.bind(this),this._webOfflineCallback=this._onWebOffline.bind(this),window&&(window.addEventListener("online",this._webOnlineCallback),window.addEventListener("offline",this._webOfflineCallback)))}},{key:"_onWebOnline",value:function(){this._onNetworkStatusChange({isConnected:!0,networkType:Ws})}},{key:"_onWebOffline",value:function(){this._onNetworkStatusChange({isConnected:!1,networkType:xs})}},{key:"_onNetworkStatusChange",value:function(e){var t=e.isConnected,o=e.networkType,n=!1;t?(we.info("".concat(this._className,"._onNetworkStatusChange previousNetworkType:").concat(this._networkType," currentNetworkType:").concat(o)),this._networkType!==o&&(n=!0,this._moduleManager.getModule(vo).reConnect(!0))):this._networkType!==o&&(n=!0,we.warn("".concat(this._className,"._onNetworkStatusChange no network, please check!")),this._moduleManager.getModule(vo).offline());n&&(new va(ya.NETWORK_CHANGE).setMessage("isConnected:".concat(t," previousNetworkType:").concat(this._networkType," networkType:").concat(o)).end(),this._networkType=o)}},{key:"probe",value:function(e){var t=this;return!Ze(e)&&Ys.includes(e.code)?Promise.resolve([!0,this._networkType]):new Promise((function(e,o){if(te)ne.getNetworkType({success:function(o){t._networkType=o.networkType,o.networkType===xs?(we.warn("".concat(t._className,".probe no network, please check!")),e([!1,o.networkType])):(we.info("".concat(t._className,".probe networkType:").concat(o.networkType)),e([!0,o.networkType]))}});else if(window&&window.fetch)fetch("".concat(ft(),"//web.sdk.qcloud.com/im/assets/speed.xml?random=").concat(Math.random())).then((function(t){t.ok?e([!0,Ws]):e([!1,xs])})).catch((function(t){e([!1,xs])}));else{var n=new XMLHttpRequest,a=setTimeout((function(){we.warn("".concat(t._className,".probe fetch timeout. Probably no network, please check!")),n.abort(),t._networkType=xs,e([!1,xs])}),t.MAX_WAIT_TIME);n.onreadystatechange=function(){4===n.readyState&&(clearTimeout(a),200===n.status||304===n.status||514===n.status?(this._networkType=Ws,e([!0,Ws])):(we.warn("".concat(this.className,".probe fetch status:").concat(n.status,". Probably no network, please check!")),this._networkType=xs,e([!1,xs])))},n.open("GET","".concat(ft(),"//web.sdk.qcloud.com/im/assets/speed.xml?random=").concat(Math.random())),n.send()}}))}},{key:"getNetworkType",value:function(){return this._networkType}},{key:"reset",value:function(){we.log("".concat(this._className,".reset")),te?null!==this._mpNetworkStatusCallback&&(ne.offNetworkStatusChange&&(Z||J?ne.offNetworkStatusChange(this._mpNetworkStatusCallback):ne.offNetworkStatusChange()),this._mpNetworkStatusCallback=null):window&&(null!==this._webOnlineCallback&&(window.removeEventListener("online",this._webOnlineCallback),this._webOnlineCallback=null),null!==this._onWebOffline&&(window.removeEventListener("offline",this._webOfflineCallback),this._webOfflineCallback=null))}}]),e}(),$s=O((function(e){var t=Object.prototype.hasOwnProperty,o="~";function n(){}function a(e,t,o){this.fn=e,this.context=t,this.once=o||!1}function s(e,t,n,s,r){if("function"!=typeof n)throw new TypeError("The listener must be a function");var i=new a(n,s||e,r),c=o?o+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],i]:e._events[c].push(i):(e._events[c]=i,e._eventsCount++),e}function r(e,t){0==--e._eventsCount?e._events=new n:delete e._events[t]}function i(){this._events=new n,this._eventsCount=0}Object.create&&(n.prototype=Object.create(null),(new n).__proto__||(o=!1)),i.prototype.eventNames=function(){var e,n,a=[];if(0===this._eventsCount)return a;for(n in e=this._events)t.call(e,n)&&a.push(o?n.slice(1):n);return Object.getOwnPropertySymbols?a.concat(Object.getOwnPropertySymbols(e)):a},i.prototype.listeners=function(e){var t=o?o+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var a=0,s=n.length,r=new Array(s);a=this.cosOptions.expiredTime-120&&this._getAuthorizationKey())}},{key:"_getAuthorization",value:function(e,t){t({TmpSecretId:this.cosOptions.secretId,TmpSecretKey:this.cosOptions.secretKey,XCosSecurityToken:this.cosOptions.sessionToken,ExpiredTime:this.cosOptions.expiredTime})}},{key:"upload",value:function(e){if(!0===e.getRelayFlag())return Promise.resolve();var t=this.getModule(Co);switch(e.type){case D.MSG_IMAGE:return t.addTotalCount(da),this._uploadImage(e);case D.MSG_FILE:return t.addTotalCount(da),this._uploadFile(e);case D.MSG_AUDIO:return t.addTotalCount(da),this._uploadAudio(e);case D.MSG_VIDEO:return t.addTotalCount(da),this._uploadVideo(e);default:return Promise.resolve()}}},{key:"_uploadImage",value:function(e){var o=this,n=this.getModule(to),a=e.getElements()[0],s=n.getMessageOption(e.clientSequence);return this.doUploadImage({file:s.payload.file,to:s.to,onProgress:function(e){if(a.updatePercent(e),ot(s.onProgress))try{s.onProgress(e)}catch(t){return ja({code:na.MESSAGE_ONPROGRESS_FUNCTION_ERROR,message:aa.MESSAGE_ONPROGRESS_FUNCTION_ERROR})}}}).then((function(n){var s=n.location,r=n.fileType,i=n.fileSize,c=n.width,u=n.height,l=o.isPrivateNetWork()?s:mt(s);a.updateImageFormat(r);var d=Lt({originUrl:l,originWidth:c,originHeight:u,min:198}),p=Lt({originUrl:l,originWidth:c,originHeight:u,min:720});return a.updateImageInfoArray([{size:i,url:l,width:c,height:u},t({},p),t({},d)]),e}))}},{key:"_uploadFile",value:function(e){var t=this,o=this.getModule(to),n=e.getElements()[0],a=o.getMessageOption(e.clientSequence);return this.doUploadFile({file:a.payload.file,to:a.to,onProgress:function(e){if(n.updatePercent(e),ot(a.onProgress))try{a.onProgress(e)}catch(t){return ja({code:na.MESSAGE_ONPROGRESS_FUNCTION_ERROR,message:aa.MESSAGE_ONPROGRESS_FUNCTION_ERROR})}}}).then((function(o){var a=o.location,s=t.isPrivateNetWork()?a:mt(a);return n.updateFileUrl(s),e}))}},{key:"_uploadAudio",value:function(e){var t=this,o=this.getModule(to),n=e.getElements()[0],a=o.getMessageOption(e.clientSequence);return this.doUploadAudio({file:a.payload.file,to:a.to,onProgress:function(e){if(n.updatePercent(e),ot(a.onProgress))try{a.onProgress(e)}catch(t){return ja({code:na.MESSAGE_ONPROGRESS_FUNCTION_ERROR,message:aa.MESSAGE_ONPROGRESS_FUNCTION_ERROR})}}}).then((function(o){var a=o.location,s=t.isPrivateNetWork()?a:mt(a);return n.updateAudioUrl(s),e}))}},{key:"_uploadVideo",value:function(e){var t=this,o=this.getModule(to),n=e.getElements()[0],a=o.getMessageOption(e.clientSequence);return this.doUploadVideo({file:a.payload.file,to:a.to,onProgress:function(e){if(n.updatePercent(e),ot(a.onProgress))try{a.onProgress(e)}catch(t){return ja({code:na.MESSAGE_ONPROGRESS_FUNCTION_ERROR,message:aa.MESSAGE_ONPROGRESS_FUNCTION_ERROR})}}}).then((function(o){var a=o.location,s=o.snapshotInfo,r=t.isPrivateNetWork()?a:mt(a);return n.updateVideoUrl(r),Vt(s)||n.updateSnapshotInfo(s),e}))}},{key:"doUploadImage",value:function(e){var t=this;if(!e.file)return ja({code:na.MESSAGE_IMAGE_SELECT_FILE_FIRST,message:aa.MESSAGE_IMAGE_SELECT_FILE_FIRST});var o=this._checkImageType(e.file);if(!0!==o)return o;var n=this._checkImageSize(e.file);if(!0!==n)return n;var a=null;return this._setUploadFileType(os),this.uploadByCOS(e).then((function(e){return a=e,t.isPrivateNetWork()?At(e.location):At("https://".concat(e.location))})).then((function(e){return a.width=e.width,a.height=e.height,Promise.resolve(a)}))}},{key:"_checkImageType",value:function(e){var t="";return t=te?e.url.slice(e.url.lastIndexOf(".")+1):e.files[0].name.slice(e.files[0].name.lastIndexOf(".")+1),es.indexOf(t.toLowerCase())>=0||ja({code:na.MESSAGE_IMAGE_TYPES_LIMIT,message:aa.MESSAGE_IMAGE_TYPES_LIMIT})}},{key:"_checkImageSize",value:function(e){var t=0;return 0===(t=te?e.size:e.files[0].size)?ja({code:na.MESSAGE_FILE_IS_EMPTY,message:"".concat(aa.MESSAGE_FILE_IS_EMPTY)}):t<20971520||ja({code:na.MESSAGE_IMAGE_SIZE_LIMIT,message:"".concat(aa.MESSAGE_IMAGE_SIZE_LIMIT)})}},{key:"doUploadFile",value:function(e){var t=null;return e.file?e.file.files[0].size>104857600?ja(t={code:na.MESSAGE_FILE_SIZE_LIMIT,message:aa.MESSAGE_FILE_SIZE_LIMIT}):0===e.file.files[0].size?(t={code:na.MESSAGE_FILE_IS_EMPTY,message:"".concat(aa.MESSAGE_FILE_IS_EMPTY)},ja(t)):(this._setUploadFileType(ss),this.uploadByCOS(e)):ja(t={code:na.MESSAGE_FILE_SELECT_FILE_FIRST,message:aa.MESSAGE_FILE_SELECT_FILE_FIRST})}},{key:"doUploadVideo",value:function(e){return e.file.videoFile.size>104857600?ja({code:na.MESSAGE_VIDEO_SIZE_LIMIT,message:"".concat(aa.MESSAGE_VIDEO_SIZE_LIMIT)}):0===e.file.videoFile.size?ja({code:na.MESSAGE_FILE_IS_EMPTY,message:"".concat(aa.MESSAGE_FILE_IS_EMPTY)}):-1===ts.indexOf(e.file.videoFile.type)?ja({code:na.MESSAGE_VIDEO_TYPES_LIMIT,message:"".concat(aa.MESSAGE_VIDEO_TYPES_LIMIT)}):(this._setUploadFileType(ns),te?this.handleVideoUpload({file:e.file.videoFile,onProgress:e.onProgress}):oe?this.handleVideoUpload(e):void 0)}},{key:"handleVideoUpload",value:function(e){var t=this;return new Promise((function(o,n){t.uploadByCOS(e).then((function(e){o(e)})).catch((function(){t.uploadByCOS(e).then((function(e){o(e)})).catch((function(){n(new Ba({code:na.MESSAGE_VIDEO_UPLOAD_FAIL,message:aa.MESSAGE_VIDEO_UPLOAD_FAIL}))}))}))}))}},{key:"doUploadAudio",value:function(e){return e.file?e.file.size>20971520?ja(new Ba({code:na.MESSAGE_AUDIO_SIZE_LIMIT,message:"".concat(aa.MESSAGE_AUDIO_SIZE_LIMIT)})):0===e.file.size?ja(new Ba({code:na.MESSAGE_FILE_IS_EMPTY,message:"".concat(aa.MESSAGE_FILE_IS_EMPTY)})):(this._setUploadFileType(as),this.uploadByCOS(e)):ja(new Ba({code:na.MESSAGE_AUDIO_UPLOAD_FAIL,message:aa.MESSAGE_AUDIO_UPLOAD_FAIL}))}},{key:"uploadByCOS",value:function(e){var t=this,o="".concat(this._className,".uploadByCOS");if(!ot(this._cosUploadMethod))return we.warn("".concat(o," 没有检测到上传插件,将无法发送图片、音频、视频、文件等类型的消息。详细请参考 https://web.sdk.qcloud.com/im/doc/zh-cn/SDK.html#registerPlugin")),ja({code:na.COS_UNDETECTED,message:aa.COS_UNDETECTED});if(this.timUploadPlugin)return this._uploadWithPreSigUrl(e);var n=new va(ya.UPLOAD),a=Date.now(),s=this._getFile(e);return new Promise((function(r,i){var c=te?t._createCosOptionsWXMiniApp(e):t._createCosOptionsWeb(e),u=t;t._cosUploadMethod(c,(function(e,c){var l=Object.create(null);if(c){if(e||Qe(c.files)&&c.files[0].error){var d=new Ba({code:na.MESSAGE_FILE_UPLOAD_FAIL,message:aa.MESSAGE_FILE_UPLOAD_FAIL});return n.setError(d,!0,t.getNetworkType()).end(),we.log("".concat(o," failed. error:"),c.files[0].error),403===c.files[0].error.statusCode&&(we.warn("".concat(o," failed. cos AccessKeyId was invalid, regain auth key!")),t._getAuthorizationKey()),void i(d)}l.fileName=s.name,l.fileSize=s.size,l.fileType=s.type.slice(s.type.indexOf("/")+1).toLowerCase(),l.location=te?c.Location:c.files[0].data.Location;var p=Date.now()-a,g=u._formatFileSize(s.size),_=u._formatSpeed(1e3*s.size/p),h="size:".concat(g," time:").concat(p,"ms speed:").concat(_);we.log("".concat(o," success. name:").concat(s.name," ").concat(h)),r(l);var f=t.getModule(Co);return f.addCost(da,p),f.addFileSize(da,s.size),void n.setNetworkType(t.getNetworkType()).setMessage(h).end()}var m=new Ba({code:na.MESSAGE_FILE_UPLOAD_FAIL,message:aa.MESSAGE_FILE_UPLOAD_FAIL});n.setError(m,!0,u.getNetworkType()).end(),we.warn("".concat(o," failed. error:"),e),403===e.statusCode&&(we.warn("".concat(o," failed. cos AccessKeyId was invalid, regain auth key!")),t._getAuthorizationKey()),i(m)}))}))}},{key:"_uploadWithPreSigUrl",value:function(e){var t=this,o="".concat(this._className,"._uploadWithPreSigUrl"),n=this._getFile(e);return this._createCosOptionsPreSigUrl(e).then((function(e){return new Promise((function(a,s){var r=new va(ya.UPLOAD),i=e.requestSnapshotUrl,c=void 0===i?void 0:i,u=g(e,Js),l=Date.now();t._cosUploadMethod(u,(function(e,i){var u=Object.create(null);if(e||403===i.statusCode){var d=new Ba({code:na.MESSAGE_FILE_UPLOAD_FAIL,message:aa.MESSAGE_FILE_UPLOAD_FAIL});return r.setError(d,!0,t.getNetworkType()).end(),we.log("".concat(o," failed, error:"),e),void s(d)}var p=i.data.location||"";t.isPrivateNetWork()||0!==p.indexOf("https://")&&0!==p.indexOf("http://")||(p=p.split("//")[1]),u.fileName=n.name,u.fileSize=n.size,u.fileType=n.type.slice(n.type.indexOf("/")+1).toLowerCase(),u.location=p;var g=Date.now()-l,_=t._formatFileSize(n.size),h=t._formatSpeed(1e3*n.size/g),f="size:".concat(_,",time:").concat(g,"ms,speed:").concat(h," res:").concat(JSON.stringify(i.data));we.log("".concat(o," success name:").concat(n.name,",").concat(f)),r.setNetworkType(t.getNetworkType()).setMessage(f).end();var m=t.getModule(Co);if(m.addCost(da,g),m.addFileSize(da,n.size),!Vt(c))return t._getSnapshotInfoByUrl(c).then((function(e){u.snapshotInfo=e,a(u)}));a(u)}))}))}))}},{key:"_getFile",value:function(e){var t=null;return te?t=Z&&Qe(e.file.files)?e.file.files[0]:e.file:oe&&(t=e.file.files[0]),t}},{key:"_formatFileSize",value:function(e){return e<1024?e+"B":e<1048576?Math.floor(e/1024)+"KB":Math.floor(e/1048576)+"MB"}},{key:"_formatSpeed",value:function(e){return e<=1048576?Pt(e/1024,1)+"KB/s":Pt(e/1048576,1)+"MB/s"}},{key:"_createCosOptionsWeb",value:function(e){var t=e.file.files[0].name,o=t.slice(t.lastIndexOf(".")),n=this._genFileName("".concat(dt(999999)).concat(o));return{files:[{Bucket:"".concat(this.bucketName,"-").concat(this.appid),Region:this.region,Key:"".concat(this.directory,"/").concat(n),Body:e.file.files[0]}],SliceSize:1048576,onProgress:function(t){if("function"==typeof e.onProgress)try{e.onProgress(t.percent)}catch(o){we.warn("onProgress callback error:",o)}},onFileFinish:function(e,t,o){}}}},{key:"_createCosOptionsWXMiniApp",value:function(e){var t=this._getFile(e),o=this._genFileName(t.name),n=t.url;return{Bucket:"".concat(this.bucketName,"-").concat(this.appid),Region:this.region,Key:"".concat(this.directory,"/").concat(o),FilePath:n,onProgress:function(t){if(we.log(JSON.stringify(t)),"function"==typeof e.onProgress)try{e.onProgress(t.percent)}catch(o){we.warn("onProgress callback error:",o)}}}}},{key:"_createCosOptionsPreSigUrl",value:function(e){var t=this,o="",n="",a=0;if(te){var s=this._getFile(e);o=this._genFileName(s.name),n=s.url,a=1}else{var r=e.file.files[0].name,i=r.slice(r.lastIndexOf("."));o=this._genFileName("".concat(dt(999999)).concat(i)),n=e.file.files[0],a=0}return this._getCosPreSigUrl({fileType:this.uploadFileType,fileName:o,uploadMethod:a,duration:this.duration}).then((function(a){var s=a.uploadUrl,r=a.downloadUrl,i=a.requestSnapshotUrl,c=void 0===i?void 0:i;return{url:s,fileType:t.uploadFileType,fileName:o,resources:n,downloadUrl:r,requestSnapshotUrl:c,onProgress:function(t){if("function"==typeof e.onProgress)try{e.onProgress(t.percent)}catch(o){we.warn("onProgress callback error:",o),we.error(o)}}}}))}},{key:"_genFileName",value:function(e){return"".concat(Ot(),"-").concat(e)}},{key:"_setUploadFileType",value:function(e){this.uploadFileType=e}},{key:"_getSnapshotInfoByUrl",value:function(e){var t=this,o=new va(ya.GET_SNAPSHOT_INFO);return this.request({protocolName:qn,requestData:{platform:this.getPlatform(),coverName:this._genFileName(dt(99999)),requestSnapshotUrl:e}}).then((function(e){var t=(e.data||{}).snapshotUrl;return o.setMessage("snapshotUrl:".concat(t)).end(),Vt(t)?{}:At(t).then((function(e){return{snapshotUrl:t,snapshotWidth:e.width,snapshotHeight:e.height}}))})).catch((function(e){return we.warn("".concat(t._className,"._getSnapshotInfoByUrl failed. error:"),e),o.setCode(e.errorCode).setMessage(e.errorInfo).end(),{}}))}},{key:"reset",value:function(){we.log("".concat(this._className,".reset"))}}]),a}(Do),Qs=["downloadKey","pbDownloadKey","messageList"],Zs=function(){function e(t){n(this,e),this._className="MergerMessageHandler",this._messageModule=t}return s(e,[{key:"uploadMergerMessage",value:function(e,t){var o=this;we.debug("".concat(this._className,".uploadMergerMessage message:"),e,"messageBytes:".concat(t));var n=e.payload.messageList,a=n.length,s=new va(ya.UPLOAD_MERGER_MESSAGE);return this._messageModule.request({protocolName:Yn,requestData:{messageList:n}}).then((function(e){we.debug("".concat(o._className,".uploadMergerMessage ok. response:"),e.data);var n=e.data,r=n.pbDownloadKey,i=n.downloadKey,c={pbDownloadKey:r,downloadKey:i,messageNumber:a};return s.setNetworkType(o._messageModule.getNetworkType()).setMessage("".concat(a,"-").concat(t,"-").concat(i)).end(),c})).catch((function(e){throw we.warn("".concat(o._className,".uploadMergerMessage failed. error:"),e),o._messageModule.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];s.setError(e,n,a).end()})),e}))}},{key:"downloadMergerMessage",value:function(e){var o=this;we.debug("".concat(this._className,".downloadMergerMessage message:"),e);var n=e.payload.downloadKey,a=new va(ya.DOWNLOAD_MERGER_MESSAGE);return a.setMessage("downloadKey:".concat(n)),this._messageModule.request({protocolName:jn,requestData:{downloadKey:n}}).then((function(n){if(we.debug("".concat(o._className,".downloadMergerMessage ok. response:"),n.data),ot(e.clearElement)){var s=e.payload,r=(s.downloadKey,s.pbDownloadKey,s.messageList,g(s,Qs));e.clearElement(),e.setElement({type:e.type,content:t({messageList:n.data.messageList},r)})}else{var i=[];n.data.messageList.forEach((function(e){if(!Vt(e)){var t=new Ga(e);i.push(t)}})),e.payload.messageList=i,e.payload.downloadKey="",e.payload.pbDownloadKey=""}return a.setNetworkType(o._messageModule.getNetworkType()).end(),e})).catch((function(e){throw we.warn("".concat(o._className,".downloadMergerMessage failed. key:").concat(n," error:"),e),o._messageModule.probeNetwork().then((function(t){var o=m(t,2),n=o[0],s=o[1];a.setError(e,n,s).end()})),e}))}},{key:"createMergerMessagePack",value:function(e,t,o){return e.conversationType===D.CONV_C2C?this._createC2CMergerMessagePack(e,t,o):this._createGroupMergerMessagePack(e,t,o)}},{key:"_createC2CMergerMessagePack",value:function(e,t,o){var n=null;t&&(t.offlinePushInfo&&(n=t.offlinePushInfo),!0===t.onlineUserOnly&&(n?n.disablePush=!0:n={disablePush:!0}));var a="";ze(e.cloudCustomData)&&e.cloudCustomData.length>0&&(a=e.cloudCustomData);var s=o.pbDownloadKey,r=o.downloadKey,i=o.messageNumber,c=e.payload,u=c.title,l=c.abstractList,d=c.compatibleText,p=this._messageModule.getModule(no);return{protocolName:Go,tjgID:this._messageModule.generateTjgID(e),requestData:{fromAccount:this._messageModule.getMyUserID(),toAccount:e.to,msgBody:[{msgType:e.type,msgContent:{pbDownloadKey:s,downloadKey:r,title:u,abstractList:l,compatibleText:d,messageNumber:i}}],cloudCustomData:a,msgSeq:e.sequence,msgRandom:e.random,msgLifeTime:p&&p.isOnlineMessage(e,t)?0:void 0,offlinePushInfo:n?{pushFlag:!0===n.disablePush?1:0,title:n.title||"",desc:n.description||"",ext:n.extension||"",apnsInfo:{badgeMode:!0===n.ignoreIOSBadge?1:0},androidInfo:{OPPOChannelID:n.androidOPPOChannelID||""}}:void 0}}}},{key:"_createGroupMergerMessagePack",value:function(e,t,o){var n=null;t&&t.offlinePushInfo&&(n=t.offlinePushInfo);var a="";ze(e.cloudCustomData)&&e.cloudCustomData.length>0&&(a=e.cloudCustomData);var s=o.pbDownloadKey,r=o.downloadKey,i=o.messageNumber,c=e.payload,u=c.title,l=c.abstractList,d=c.compatibleText,p=this._messageModule.getModule(ao);return{protocolName:Po,tjgID:this._messageModule.generateTjgID(e),requestData:{fromAccount:this._messageModule.getMyUserID(),groupID:e.to,msgBody:[{msgType:e.type,msgContent:{pbDownloadKey:s,downloadKey:r,title:u,abstractList:l,compatibleText:d,messageNumber:i}}],random:e.random,priority:e.priority,clientSequence:e.clientSequence,groupAtInfo:void 0,cloudCustomData:a,onlineOnlyFlag:p&&p.isOnlineMessage(e,t)?1:0,offlinePushInfo:n?{pushFlag:!0===n.disablePush?1:0,title:n.title||"",desc:n.description||"",ext:n.extension||"",apnsInfo:{badgeMode:!0===n.ignoreIOSBadge?1:0},androidInfo:{OPPOChannelID:n.androidOPPOChannelID||""}}:void 0,clientTime:e.clientTime,needReadReceipt:!0!==e.needReadReceipt||p.isMessageFromOrToAVChatroom(e.to)?0:1}}}}]),e}(),er={ERR_SVR_COMM_SENSITIVE_TEXT:80001,ERR_SVR_COMM_BODY_SIZE_LIMIT:80002,OPEN_SERVICE_OVERLOAD_ERROR:60022,ERR_SVR_MSG_PKG_PARSE_FAILED:20001,ERR_SVR_MSG_INTERNAL_AUTH_FAILED:20002,ERR_SVR_MSG_INVALID_ID:20003,ERR_SVR_MSG_PUSH_DENY:20006,ERR_SVR_MSG_IN_PEER_BLACKLIST:20007,ERR_SVR_MSG_BOTH_NOT_FRIEND:20009,ERR_SVR_MSG_NOT_PEER_FRIEND:20010,ERR_SVR_MSG_NOT_SELF_FRIEND:20011,ERR_SVR_MSG_SHUTUP_DENY:20012,ERR_SVR_GROUP_INVALID_PARAMETERS:10004,ERR_SVR_GROUP_PERMISSION_DENY:10007,ERR_SVR_GROUP_NOT_FOUND:10010,ERR_SVR_GROUP_INVALID_GROUPID:10015,ERR_SVR_GROUP_REJECT_FROM_THIRDPARTY:10016,ERR_SVR_GROUP_SHUTUP_DENY:10017,MESSAGE_SEND_FAIL:2100,OVER_FREQUENCY_LIMIT:2996},tr=[na.MESSAGE_ONPROGRESS_FUNCTION_ERROR,na.MESSAGE_IMAGE_SELECT_FILE_FIRST,na.MESSAGE_IMAGE_TYPES_LIMIT,na.MESSAGE_FILE_IS_EMPTY,na.MESSAGE_IMAGE_SIZE_LIMIT,na.MESSAGE_FILE_SELECT_FILE_FIRST,na.MESSAGE_FILE_SIZE_LIMIT,na.MESSAGE_VIDEO_SIZE_LIMIT,na.MESSAGE_VIDEO_TYPES_LIMIT,na.MESSAGE_AUDIO_UPLOAD_FAIL,na.MESSAGE_AUDIO_SIZE_LIMIT,na.COS_UNDETECTED];var or=function(e){i(o,e);var t=f(o);function o(e){var a;return n(this,o),(a=t.call(this,e))._className="MessageModule",a._messageOptionsMap=new Map,a._mergerMessageHandler=new Zs(_(a)),a}return s(o,[{key:"createTextMessage",value:function(e){var t=e.to,o=e.payload.atUserList,n=void 0===o?[]:o;if((Et({groupID:t})||Tt(t))&&n.includes(D.MSG_AT_ALL))return ja({code:na.MESSAGE_AT_TYPE_INVALID,message:aa.MESSAGE_AT_TYPE_INVALID});var a=this.getMyUserID();e.currentUser=a,e.senderTinyID=this.getMyTinyID();var s=new wa(e),r="string"==typeof e.payload?e.payload:e.payload.text,i=new Ia({text:r}),c=this._getNickAndAvatarByUserID(a);return s.setElement(i),s.setNickAndAvatar(c),s.setNameCard(this._getNameCardByGroupID(s)),s}},{key:"createImageMessage",value:function(e){var t=this.getMyUserID();e.currentUser=t,e.senderTinyID=this.getMyTinyID();var o=new wa(e);if(te){var n=e.payload.file;if(je(n))return void we.warn("小程序环境下调用 createImageMessage 接口时,payload.file 不支持传入 File 对象");var a=n.tempFilePaths[0],s={url:a,name:a.slice(a.lastIndexOf("/")+1),size:n.tempFiles&&n.tempFiles[0].size||1,type:a.slice(a.lastIndexOf(".")+1).toLowerCase()};e.payload.file=s}else if(oe)if(je(e.payload.file)){var r=e.payload.file;e.payload.file={files:[r]}}else if(Xe(e.payload.file)&&"undefined"!=typeof uni){var i=e.payload.file.tempFiles[0];e.payload.file={files:[i]}}var c=new Ea({imageFormat:be.UNKNOWN,uuid:this._generateUUID(),file:e.payload.file}),u=this._getNickAndAvatarByUserID(t);return o.setElement(c),o.setNickAndAvatar(u),o.setNameCard(this._getNameCardByGroupID(o)),this._messageOptionsMap.set(o.clientSequence,e),o}},{key:"createAudioMessage",value:function(e){if(te){var t=e.payload.file;if(te){var o={url:t.tempFilePath,name:t.tempFilePath.slice(t.tempFilePath.lastIndexOf("/")+1),size:t.fileSize,second:parseInt(t.duration)/1e3,type:t.tempFilePath.slice(t.tempFilePath.lastIndexOf(".")+1).toLowerCase()};e.payload.file=o}var n=this.getMyUserID();e.currentUser=n,e.senderTinyID=this.getMyTinyID();var a=new wa(e),s=new Ca({second:Math.floor(t.duration/1e3),size:t.fileSize,url:t.tempFilePath,uuid:this._generateUUID()}),r=this._getNickAndAvatarByUserID(n);return a.setElement(s),a.setNickAndAvatar(r),a.setNameCard(this._getNameCardByGroupID(a)),this._messageOptionsMap.set(a.clientSequence,e),a}we.warn("createAudioMessage 目前只支持小程序环境下发语音消息")}},{key:"createVideoMessage",value:function(e){var t=this.getMyUserID();e.currentUser=t,e.senderTinyID=this.getMyTinyID(),e.payload.file.thumbUrl="https://web.sdk.qcloud.com/im/assets/images/transparent.png",e.payload.file.thumbSize=1668;var o={};if(te){if(Q)return void we.warn("createVideoMessage 不支持在支付宝小程序环境下使用");if(je(e.payload.file))return void we.warn("小程序环境下调用 createVideoMessage 接口时,payload.file 不支持传入 File 对象");var n=e.payload.file;o.url=n.tempFilePath,o.name=n.tempFilePath.slice(n.tempFilePath.lastIndexOf("/")+1),o.size=n.size,o.second=n.duration,o.type=n.tempFilePath.slice(n.tempFilePath.lastIndexOf(".")+1).toLowerCase()}else if(oe){if(je(e.payload.file)){var a=e.payload.file;e.payload.file.files=[a]}else if(Xe(e.payload.file)&&"undefined"!=typeof uni){var s=e.payload.file.tempFile;e.payload.file.files=[s]}var r=e.payload.file;o.url=window.URL.createObjectURL(r.files[0]),o.name=r.files[0].name,o.size=r.files[0].size,o.second=r.files[0].duration||0,o.type=r.files[0].type.split("/")[1]}e.payload.file.videoFile=o;var i=new wa(e),c=new La({videoFormat:o.type,videoSecond:Pt(o.second,0),videoSize:o.size,remoteVideoUrl:"",videoUrl:o.url,videoUUID:this._generateUUID(),thumbUUID:this._generateUUID(),thumbWidth:e.payload.file.width||200,thumbHeight:e.payload.file.height||200,thumbUrl:e.payload.file.thumbUrl,thumbSize:e.payload.file.thumbSize,thumbFormat:e.payload.file.thumbUrl.slice(e.payload.file.thumbUrl.lastIndexOf(".")+1).toLowerCase()}),u=this._getNickAndAvatarByUserID(t);return i.setElement(c),i.setNickAndAvatar(u),i.setNameCard(this._getNameCardByGroupID(i)),this._messageOptionsMap.set(i.clientSequence,e),i}},{key:"createCustomMessage",value:function(e){var t=this.getMyUserID();e.currentUser=t,e.senderTinyID=this.getMyTinyID();var o=new wa(e),n=new Ra({data:e.payload.data,description:e.payload.description,extension:e.payload.extension}),a=this._getNickAndAvatarByUserID(t);return o.setElement(n),o.setNickAndAvatar(a),o.setNameCard(this._getNameCardByGroupID(o)),o}},{key:"createFaceMessage",value:function(e){var t=this.getMyUserID();e.currentUser=t,e.senderTinyID=this.getMyTinyID();var o=new wa(e),n=new Ta(e.payload),a=this._getNickAndAvatarByUserID(t);return o.setElement(n),o.setNickAndAvatar(a),o.setNameCard(this._getNameCardByGroupID(o)),o}},{key:"createMergerMessage",value:function(e){var t=this.getMyUserID();e.currentUser=t,e.senderTinyID=this.getMyTinyID();var o=this._getNickAndAvatarByUserID(t),n=new wa(e),a=new Pa(e.payload);return n.setElement(a),n.setNickAndAvatar(o),n.setNameCard(this._getNameCardByGroupID(n)),n.setRelayFlag(!0),n}},{key:"createForwardMessage",value:function(e){var t=e.to,o=e.conversationType,n=e.priority,a=e.payload,s=e.needReadReceipt,r=this.getMyUserID(),i=this._getNickAndAvatarByUserID(r);if(a.type===D.MSG_GRP_TIP)return ja(new Ba({code:na.MESSAGE_FORWARD_TYPE_INVALID,message:aa.MESSAGE_FORWARD_TYPE_INVALID}));var c={to:t,conversationType:o,conversationID:"".concat(o).concat(t),priority:n,isPlaceMessage:0,status:xt.UNSEND,currentUser:r,senderTinyID:this.getMyTinyID(),cloudCustomData:e.cloudCustomData||a.cloudCustomData||"",needReadReceipt:s},u=new wa(c);return u.setElement(a.getElements()[0]),u.setNickAndAvatar(i),u.setNameCard(this._getNameCardByGroupID(a)),u.setRelayFlag(!0),u}},{key:"downloadMergerMessage",value:function(e){return this._mergerMessageHandler.downloadMergerMessage(e)}},{key:"createFileMessage",value:function(e){if(!te||Z){if(oe||Z)if(je(e.payload.file)){var t=e.payload.file;e.payload.file={files:[t]}}else if(Xe(e.payload.file)&&"undefined"!=typeof uni){var o=e.payload.file,n=o.tempFiles,a=o.files,s=null;Qe(n)?s=n[0]:Qe(a)&&(s=a[0]),e.payload.file={files:[s]}}var r=this.getMyUserID();e.currentUser=r,e.senderTinyID=this.getMyTinyID();var i=new wa(e),c=new Oa({uuid:this._generateUUID(),file:e.payload.file}),u=this._getNickAndAvatarByUserID(r);return i.setElement(c),i.setNickAndAvatar(u),i.setNameCard(this._getNameCardByGroupID(i)),this._messageOptionsMap.set(i.clientSequence,e),i}we.warn("小程序目前不支持选择文件, createFileMessage 接口不可用!")}},{key:"createLocationMessage",value:function(e){var t=this.getMyUserID();e.currentUser=t,e.senderTinyID=this.getMyTinyID();var o=new wa(e),n=new ka(e.payload),a=this._getNickAndAvatarByUserID(t);return o.setElement(n),o.setNickAndAvatar(a),o.setNameCard(this._getNameCardByGroupID(o)),o}},{key:"_onCannotFindModule",value:function(){return ja({code:na.CANNOT_FIND_MODULE,message:aa.CANNOT_FIND_MODULE})}},{key:"sendMessageInstance",value:function(e,t){var o,n=this,a=null;switch(e.conversationType){case D.CONV_C2C:if(!(a=this.getModule(no)))return this._onCannotFindModule();break;case D.CONV_GROUP:if(!(a=this.getModule(ao)))return this._onCannotFindModule();if(Et({groupID:e.to})){var s=a.getLocalGroupProfile(e.to);if(s&&s.isSupportTopic)return ja({code:na.MESSAGE_SEND_GROUP_WITH_TOPIC_FAIL,message:aa.MESSAGE_SEND_GROUP_WITH_TOPIC_FAIL});if(!Ze(t)&&!Ze(t.messageControlInfo))return ja({code:na.MESSAGE_CONTROL_INFO_FAIL,message:aa.MESSAGE_CONTROL_INFO_FAIL})}break;default:return ja({code:na.MESSAGE_SEND_INVALID_CONVERSATION_TYPE,message:aa.MESSAGE_SEND_INVALID_CONVERSATION_TYPE})}var r=this.getModule(ho),i=this.getModule(ao);return r.upload(e).then((function(){n._getSendMessageSpecifiedKey(e)===la&&n.getModule(Co).addSuccessCount(da);return i.guardForAVChatRoom(e).then((function(){if(!e.isSendable())return ja({code:na.MESSAGE_FILE_URL_IS_EMPTY,message:aa.MESSAGE_FILE_URL_IS_EMPTY});n._addSendMessageTotalCount(e),o=Date.now();var s=function(e){var t="utf-8";oe&&document&&(t=document.charset.toLowerCase());var o,n,a=0;if(n=e.length,"utf-8"===t||"utf8"===t)for(var s=0;s7e3?n._mergerMessageHandler.uploadMergerMessage(e,s).then((function(o){var a=n._mergerMessageHandler.createMergerMessagePack(e,t,o);return n.request(a)})):(n.getModule(co).setMessageRandom(e),e.conversationType===D.CONV_C2C||e.conversationType===D.CONV_GROUP?a.sendMessage(e,t):void 0)})).then((function(s){var r=s.data,i=r.time,c=r.sequence,u=r.readReceiptCode;$e(u)&&0!==u&&(new va(ya.SEND_MESSAGE_WITH_RECEIPT).setMessage("from:".concat(e.from," to:").concat(e.to," sequence:").concat(c," readReceiptCode:").concat(u)).end(),we.warn("".concat(n._className,".sendMessageInstance readReceiptCode:").concat(u," message:").concat(Ha[u])));n._addSendMessageSuccessCount(e,o),n._messageOptionsMap.delete(e.clientSequence);var l=n.getModule(co);e.status=xt.SUCCESS,e.time=i;var d=!1;if(e.conversationType===D.CONV_GROUP)e.sequence=c;else if(e.conversationType===D.CONV_C2C){var p=l.getLatestMessageSentByMe(e.conversationID);if(p){var g=p.nick,_=p.avatar;g===e.nick&&_===e.avatar||(d=!0)}}if(l.appendToMessageList(e),d&&l.modifyMessageSentByMe({conversationID:e.conversationID,latestNick:e.nick,latestAvatar:e.avatar}),a.isOnlineMessage(e,t))e._onlineOnlyFlag=!0;else{var h=e;Xe(t)&&Xe(t.messageControlInfo)&&(!0===t.messageControlInfo.excludedFromLastMessage&&(e._isExcludedFromLastMessage=!0,h=""),!0===t.messageControlInfo.excludedFromUnreadCount&&(e._isExcludedFromUnreadCount=!0));var f=e.conversationType;if(Tt(e.to))f=D.CONV_TOPIC,n.getModule(io).onMessageSent({groupID:bt(e.to),topicID:e.to,lastMessage:h});l.onMessageSent({conversationOptionsList:[{conversationID:e.conversationID,unreadCount:0,type:f,subType:e.conversationSubType,lastMessage:h}]})}return e.getRelayFlag()||"TIMImageElem"!==e.type||kt(e.payload.imageInfoArray),ba({message:e})}))})).catch((function(t){return n._onSendMessageFailed(e,t)}))}},{key:"_onSendMessageFailed",value:function(e,t){e.status=xt.FAIL,this.getModule(co).deleteMessageRandom(e),this._addSendMessageFailCountOnUser(e,t);var o=new va(ya.SEND_MESSAGE);return o.setMessage("tjg_id:".concat(this.generateTjgID(e)," type:").concat(e.type," from:").concat(e.from," to:").concat(e.to)),this.probeNetwork().then((function(e){var n=m(e,2),a=n[0],s=n[1];o.setError(t,a,s).end()})),we.error("".concat(this._className,"._onSendMessageFailed error:"),t),ja(new Ba({code:t&&t.code?t.code:na.MESSAGE_SEND_FAIL,message:t&&t.message?t.message:aa.MESSAGE_SEND_FAIL,data:{message:e}}))}},{key:"_getSendMessageSpecifiedKey",value:function(e){if([D.MSG_IMAGE,D.MSG_AUDIO,D.MSG_VIDEO,D.MSG_FILE].includes(e.type))return la;if(e.conversationType===D.CONV_C2C)return ia;if(e.conversationType===D.CONV_GROUP){var t=this.getModule(ao).getLocalGroupProfile(e.to);if(!t)return;var o=t.type;return It(o)?ua:ca}}},{key:"_addSendMessageTotalCount",value:function(e){var t=this._getSendMessageSpecifiedKey(e);t&&this.getModule(Co).addTotalCount(t)}},{key:"_addSendMessageSuccessCount",value:function(e,t){var o=Math.abs(Date.now()-t),n=this._getSendMessageSpecifiedKey(e);if(n){var a=this.getModule(Co);a.addSuccessCount(n),a.addCost(n,o)}}},{key:"_addSendMessageFailCountOnUser",value:function(e,t){var o,n,a=t.code,s=void 0===a?-1:a,r=this.getModule(Co),i=this._getSendMessageSpecifiedKey(e);i===la&&(o=s,n=!1,tr.includes(o)&&(n=!0),n)?r.addFailedCountOfUserSide(da):function(e){var t=!1;return Object.values(er).includes(e)&&(t=!0),(e>=120001&&e<=13e4||e>=10100&&e<=10200)&&(t=!0),t}(s)&&i&&r.addFailedCountOfUserSide(i)}},{key:"resendMessage",value:function(e){return e.isResend=!0,e.status=xt.UNSEND,e.random=dt(),e.clientTime=ke(),e.generateMessageID(),this.sendMessageInstance(e)}},{key:"revokeMessage",value:function(e){var t=this,o=null;if(e.conversationType===D.CONV_C2C){if(!(o=this.getModule(no)))return this._onCannotFindModule()}else if(e.conversationType===D.CONV_GROUP&&!(o=this.getModule(ao)))return this._onCannotFindModule();var n=new va(ya.REVOKE_MESSAGE);return n.setMessage("tjg_id:".concat(this.generateTjgID(e)," type:").concat(e.type," from:").concat(e.from," to:").concat(e.to)),o.revokeMessage(e).then((function(o){var a=o.data.recallRetList;if(!Vt(a)&&0!==a[0].retCode){var s=new Ba({code:a[0].retCode,message:Ha[a[0].retCode]||aa.MESSAGE_REVOKE_FAIL,data:{message:e}});return n.setCode(s.code).setMoreMessage(s.message).end(),ja(s)}return we.info("".concat(t._className,".revokeMessage ok. ID:").concat(e.ID)),e.isRevoked=!0,n.end(),t.getModule(co).onMessageRevoked([e]),ba({message:e})})).catch((function(o){t.probeNetwork().then((function(e){var t=m(e,2),a=t[0],s=t[1];n.setError(o,a,s).end()}));var a=new Ba({code:o&&o.code?o.code:na.MESSAGE_REVOKE_FAIL,message:o&&o.message?o.message:aa.MESSAGE_REVOKE_FAIL,data:{message:e}});return we.warn("".concat(t._className,".revokeMessage failed. error:"),o),ja(a)}))}},{key:"deleteMessage",value:function(e){var t=this,o=null,n=e[0],a=n.conversationID,s="",r=[],i=[];if(n.conversationType===D.CONV_C2C)o=this.getModule(no),s=a.replace(D.CONV_C2C,""),e.forEach((function(e){e&&e.status===xt.SUCCESS&&e.conversationID===a&&(e._onlineOnlyFlag||r.push("".concat(e.sequence,"_").concat(e.random,"_").concat(e.time)),i.push(e))}));else if(n.conversationType===D.CONV_GROUP)o=this.getModule(ao),s=a.replace(D.CONV_GROUP,""),e.forEach((function(e){e&&e.status===xt.SUCCESS&&e.conversationID===a&&(e._onlineOnlyFlag||r.push("".concat(e.sequence)),i.push(e))}));else if(n.conversationType===D.CONV_SYSTEM)return ja({code:na.CANNOT_DELETE_GROUP_SYSTEM_NOTICE,message:aa.CANNOT_DELETE_GROUP_SYSTEM_NOTICE});if(!o)return this._onCannotFindModule();if(0===r.length)return this._onMessageDeleted(i);r.length>30&&(r=r.slice(0,30),i=i.slice(0,30));var c=new va(ya.DELETE_MESSAGE);return c.setMessage("to:".concat(s," count:").concat(r.length)),o.deleteMessage({to:s,keyList:r}).then((function(e){return c.end(),we.info("".concat(t._className,".deleteMessage ok")),t._onMessageDeleted(i)})).catch((function(e){t.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];c.setError(e,n,a).end()})),we.warn("".concat(t._className,".deleteMessage failed. error:"),e);var o=new Ba({code:e&&e.code?e.code:na.MESSAGE_DELETE_FAIL,message:e&&e.message?e.message:aa.MESSAGE_DELETE_FAIL});return ja(o)}))}},{key:"_onMessageDeleted",value:function(e){return this.getModule(co).onMessageDeleted(e),Ya({messageList:e})}},{key:"modifyRemoteMessage",value:function(e){var t=this,o=null,n=e.conversationType,a=e.to;if(this.getModule(ao).isMessageFromOrToAVChatroom(a))return ja({code:na.MESSAGE_MODIFY_DISABLED_IN_AVCHATROOM,message:aa.MESSAGE_MODIFY_DISABLED_IN_AVCHATROOM,data:{message:e}});n===D.CONV_C2C?o=this.getModule(no):n===D.CONV_GROUP&&(o=this.getModule(ao));var s=new va(ya.MODIFY_MESSAGE);return s.setMessage("to:".concat(a)),o.modifyRemoteMessage(e).then((function(o){s.end(),we.info("".concat(t._className,".modifyRemoteMessage ok"));var n=t._onModifyRemoteMessageResp(e,o.data);return ba({message:n})})).catch((function(o){if(s.setCode(o.code).setMoreMessage(o.message).end(),we.warn("".concat(t._className,".modifyRemoteMessage failed. error:"),o),20027===o.code){var n=t._onModifyRemoteMessageResp(e,o.data);return ja({code:na.MESSAGE_MODIFY_CONFLICT,message:aa.MESSAGE_MODIFY_CONFLICT,data:{message:n}})}return ja({code:o.code,message:o.message,data:{message:e}})}))}},{key:"_onModifyRemoteMessageResp",value:function(e,t){we.debug("".concat(this._className,"._onModifyRemoteMessageResp options:"),t);var o=e.conversationType,n=e.from,a=e.to,s=e.random,r=e.sequence,i=e.time,c=t.elements,u=t.messageVersion,l=t.cloudCustomData,d=void 0===l?"":l;return this.getModule(co).onMessageModified({conversationType:o,from:n,to:a,time:i,random:s,sequence:r,elements:c,cloudCustomData:d,messageVersion:u})}},{key:"_generateUUID",value:function(){var e=this.getModule(uo);return"".concat(e.getSDKAppID(),"-").concat(e.getUserID(),"-").concat(function(){for(var e="",t=32;t>0;--t)e+=pt[Math.floor(Math.random()*gt)];return e}())}},{key:"getMessageOption",value:function(e){return this._messageOptionsMap.get(e)}},{key:"_getNickAndAvatarByUserID",value:function(e){return this.getModule(oo).getNickAndAvatarByUserID(e)}},{key:"_getNameCardByGroupID",value:function(e){if(e.conversationType===D.CONV_GROUP){var t=this.getModule(ao);if(t)return t.getMyNameCardByGroupID(e.to)}return""}},{key:"reset",value:function(){we.log("".concat(this._className,".reset")),this._messageOptionsMap.clear()}}]),o}(Do),nr=function(e){i(o,e);var t=f(o);function o(e){var a;return n(this,o),(a=t.call(this,e))._className="PluginModule",a.plugins={},a}return s(o,[{key:"registerPlugin",value:function(e){var t=this;Object.keys(e).forEach((function(o){t.plugins[o]=e[o]})),new va(ya.REGISTER_PLUGIN).setMessage("key=".concat(Object.keys(e))).end()}},{key:"getPlugin",value:function(e){return this.plugins[e]}},{key:"reset",value:function(){we.log("".concat(this._className,".reset"))}}]),o}(Do),ar=function(e){i(o,e);var t=f(o);function o(e){var a;return n(this,o),(a=t.call(this,e))._className="SyncUnreadMessageModule",a._cookie="",a._onlineSyncFlag=!1,a.getInnerEmitterInstance().on(Ja,a._onLoginSuccess,_(a)),a}return s(o,[{key:"_onLoginSuccess",value:function(e){this._startSync({cookie:this._cookie,syncFlag:0,isOnlineSync:0})}},{key:"_startSync",value:function(e){var t=this,o=e.cookie,n=e.syncFlag,a=e.isOnlineSync;we.log("".concat(this._className,"._startSync cookie:").concat(o," syncFlag:").concat(n," isOnlineSync:").concat(a)),this.request({protocolName:Lo,requestData:{cookie:o,syncFlag:n,isOnlineSync:a}}).then((function(e){var o=e.data,n=o.cookie,a=o.syncFlag,s=o.eventArray,r=o.messageList,i=o.C2CRemainingUnreadList,c=o.C2CPairUnreadList;if(t._cookie=n,Vt(n));else if(0===a||1===a){if(s)t.getModule(Mo).onMessage({head:{},body:{eventArray:s,isInstantMessage:t._onlineSyncFlag,isSyncingEnded:!1}});t.getModule(no).onNewC2CMessage({dataList:r,isInstantMessage:!1,C2CRemainingUnreadList:i,C2CPairUnreadList:c}),t._startSync({cookie:n,syncFlag:a,isOnlineSync:0})}else if(2===a){if(s)t.getModule(Mo).onMessage({head:{},body:{eventArray:s,isInstantMessage:t._onlineSyncFlag,isSyncingEnded:!0}});t.getModule(no).onNewC2CMessage({dataList:r,isInstantMessage:t._onlineSyncFlag,C2CRemainingUnreadList:i,C2CPairUnreadList:c})}})).catch((function(e){we.error("".concat(t._className,"._startSync failed. error:"),e)}))}},{key:"startOnlineSync",value:function(){we.log("".concat(this._className,".startOnlineSync")),this._onlineSyncFlag=!0,this._startSync({cookie:this._cookie,syncFlag:0,isOnlineSync:1})}},{key:"startSyncOnReconnected",value:function(){we.log("".concat(this._className,".startSyncOnReconnected.")),this._onlineSyncFlag=!0,this._startSync({cookie:this._cookie,syncFlag:0,isOnlineSync:0})}},{key:"reset",value:function(){we.log("".concat(this._className,".reset")),this._onlineSyncFlag=!1,this._cookie=""}}]),o}(Do),sr={request:{toAccount:"To_Account",fromAccount:"From_Account",to:"To_Account",from:"From_Account",groupID:"GroupId",groupAtUserID:"GroupAt_Account",extension:"Ext",data:"Data",description:"Desc",elements:"MsgBody",sizeType:"Type",downloadFlag:"Download_Flag",thumbUUID:"ThumbUUID",videoUUID:"VideoUUID",remoteAudioUrl:"Url",remoteVideoUrl:"VideoUrl",videoUrl:"",imageUrl:"URL",fileUrl:"Url",uuid:"UUID",priority:"MsgPriority",receiverUserID:"To_Account",receiverGroupID:"GroupId",messageSender:"SenderId",messageReceiver:"ReceiverId",nick:"From_AccountNick",avatar:"From_AccountHeadurl",messageNumber:"MsgNum",pbDownloadKey:"PbMsgKey",downloadKey:"JsonMsgKey",applicationType:"PendencyType",userIDList:"To_Account",groupNameList:"GroupName",userID:"To_Account",groupAttributeList:"GroupAttr",mainSequence:"AttrMainSeq",avChatRoomKey:"BytesKey",attributeControl:"AttrControl",sequence:"seq",messageControlInfo:"SendMsgControl",updateSequence:"UpdateSeq",clientTime:"MsgClientTime",sequenceList:"MsgSeqList",topicID:"TopicId",customData:"CustomString",isSupportTopic:"SupportTopic"},response:{MsgPriority:"priority",ThumbUUID:"thumbUUID",VideoUUID:"videoUUID",Download_Flag:"downloadFlag",GroupId:"groupID",Member_Account:"userID",MsgList:"messageList",SyncFlag:"syncFlag",To_Account:"to",From_Account:"from",MsgSeq:"sequence",MsgRandom:"random",MsgTime:"time",MsgTimeStamp:"time",MsgContent:"content",MsgBody:"elements",From_AccountNick:"nick",From_AccountHeadurl:"avatar",GroupWithdrawInfoArray:"revokedInfos",GroupReadInfoArray:"groupMessageReadNotice",LastReadMsgSeq:"lastMessageSeq",WithdrawC2cMsgNotify:"c2cMessageRevokedNotify",C2cWithdrawInfoArray:"revokedInfos",C2cReadedReceipt:"c2cMessageReadReceipt",ReadC2cMsgNotify:"c2cMessageReadNotice",LastReadTime:"peerReadTime",MsgRand:"random",MsgType:"type",MsgShow:"messageShow",NextMsgSeq:"nextMessageSeq",FaceUrl:"avatar",ProfileDataMod:"profileModify",Profile_Account:"userID",ValueBytes:"value",ValueNum:"value",NoticeSeq:"noticeSequence",NotifySeq:"notifySequence",MsgFrom_AccountExtraInfo:"messageFromAccountExtraInformation",Operator_Account:"operatorID",OpType:"operationType",ReportType:"operationType",UserId:"userID",User_Account:"userID",List_Account:"userIDList",MsgOperatorMemberExtraInfo:"operatorInfo",MsgMemberExtraInfo:"memberInfoList",ImageUrl:"avatar",NickName:"nick",MsgGroupNewInfo:"newGroupProfile",MsgAppDefinedData:"groupCustomField",Owner_Account:"ownerID",GroupFaceUrl:"avatar",GroupIntroduction:"introduction",GroupNotification:"notification",GroupApplyJoinOption:"joinOption",MsgKey:"messageKey",GroupInfo:"groupProfile",ShutupTime:"muteTime",Desc:"description",Ext:"extension",GroupAt_Account:"groupAtUserID",MsgNum:"messageNumber",PbMsgKey:"pbDownloadKey",JsonMsgKey:"downloadKey",MsgModifiedFlag:"isModified",PendencyItem:"applicationItem",PendencyType:"applicationType",AddTime:"time",AddSource:"source",AddWording:"wording",ProfileImImage:"avatar",PendencyAdd:"friendApplicationAdded",FrienPencydDel_Account:"friendApplicationDeletedUserIDList",Peer_Account:"userID",GroupAttr:"groupAttributeList",GroupAttrAry:"groupAttributeList",AttrMainSeq:"mainSequence",seq:"sequence",GroupAttrOption:"groupAttributeOption",BytesChangedKeys:"changedKeyList",GroupAttrInfo:"groupAttributeList",GroupAttrSeq:"mainSequence",PushChangedAttrValFlag:"hasChangedAttributeInfo",SubKeySeq:"sequence",Val:"value",MsgGroupFromCardName:"senderNameCard",MsgGroupFromNickName:"senderNick",C2cNick:"peerNick",C2cImage:"peerAvatar",SendMsgControl:"messageControlInfo",NoLastMsg:"excludedFromLastMessage",NoUnread:"excludedFromUnreadCount",UpdateSeq:"updateSequence",MuteNotifications:"muteFlag",MsgClientTime:"clientTime",TinyId:"tinyID",GroupMsgReceiptList:"readReceiptList",ReadNum:"readCount",UnreadNum:"unreadCount",TopicId:"topicID",MillionGroupFlag:"communityType",SupportTopic:"isSupportTopic",MsgTopicNewInfo:"newTopicInfo",ShutupAll:"muteAllMembers",CustomString:"customData",TopicFaceUrl:"avatar",TopicIntroduction:"introduction",TopicNotification:"notification",TopicIdArray:"topicIDList",MsgVersion:"messageVersion",C2cMsgModNotifys:"c2cMessageModified",GroupMsgModNotifys:"groupMessageModified"},ignoreKeyWord:["C2C","ID","USP"]};function rr(e,t){if("string"!=typeof e&&!Array.isArray(e))throw new TypeError("Expected the input to be `string | string[]`");t=Object.assign({pascalCase:!1},t);var o;return 0===(e=Array.isArray(e)?e.map((function(e){return e.trim()})).filter((function(e){return e.length})).join("-"):e.trim()).length?"":1===e.length?t.pascalCase?e.toUpperCase():e.toLowerCase():(e!==e.toLowerCase()&&(e=ir(e)),e=e.replace(/^[_.\- ]+/,"").toLowerCase().replace(/[_.\- ]+(\w|$)/g,(function(e,t){return t.toUpperCase()})).replace(/\d+(\w|$)/g,(function(e){return e.toUpperCase()})),o=e,t.pascalCase?o.charAt(0).toUpperCase()+o.slice(1):o)}var ir=function(e){for(var t=!1,o=!1,n=!1,a=0;a100)return o--,t;if(Qe(t)){var a=t.map((function(t){return Je(t)?e(t,n):t}));return o--,a}if(Je(t)){var s=(r=t,i=function(e,t){if(!st(t))return!1;if((a=t)!==rr(a))for(var o=0;o65535)return lr(240|t>>>18,128|t>>>12&63,128|t>>>6&63,128|63&t)}else t=65533}else t<=57343&&(t=65533);return t<=2047?lr(192|t>>>6,128|63&t):lr(224|t>>>12,128|t>>>6&63,128|63&t)},pr=function(e){for(var t=void 0===e?"":(""+e).replace(/[\x80-\uD7ff\uDC00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]?/g,dr),o=0|t.length,n=new Uint8Array(o),a=0;a0)for(var c=0;c=s&&(we.log("".concat(e._className,"._checkPromiseMap request timeout, delete requestID:").concat(o)),e._promiseMap.delete(o),n(new Ba({code:na.NETWORK_TIMEOUT,message:aa.NETWORK_TIMEOUT})),e._channelModule.onRequestTimeout(o))}))}},{key:"onOpen",value:function(e){if(""!==this._readyState){this._onOpenTs=Date.now();var t=e.id;this._socketID=t;var o=Date.now()-this._startTs;we.log("".concat(this._className,"._onOpen cost ").concat(o," ms. socketID:").concat(t)),new va(ya.WS_ON_OPEN).setMessage(o).setCostTime(o).setMoreMessage("socketID:".concat(t)).end(),e.id===this._socketID&&(this._readyState=vr,this._reConnectCount=0,this._resend(),!0===this._reConnectFlag&&(this._channelModule.onReconnected(),this._reConnectFlag=!1),this._channelModule.onOpen())}}},{key:"onClose",value:function(e){var t=new va(ya.WS_ON_CLOSE),o=e.id,n=e.e,a="sourceSocketID:".concat(o," currentSocketID:").concat(this._socketID," code:").concat(n.code," reason:").concat(n.reason),s=0;0!==this._onOpenTs&&(s=Date.now()-this._onOpenTs),t.setMessage(s).setCostTime(s).setMoreMessage(a).setCode(n.code).end(),we.log("".concat(this._className,"._onClose ").concat(a," onlineTime:").concat(s)),o===this._socketID&&(this._readyState=Ir,s<1e3?this._channelModule.onReconnectFailed():this._channelModule.onClose())}},{key:"onError",value:function(e){var t=e.id,o=e.e,n="sourceSocketID:".concat(t," currentSocketID:").concat(this._socketID);new va(ya.WS_ON_ERROR).setMessage(o.errMsg||ut(o)).setMoreMessage(n).setLevel("error").end(),we.warn("".concat(this._className,"._onError"),o,n),t===this._socketID&&(this._readyState="",this._channelModule.onError())}},{key:"onMessage",value:function(e){var t;try{t=JSON.parse(e.data)}catch(u){new va(ya.JSON_PARSE_ERROR).setMessage(e.data).end()}if(t&&t.head){var o=this._getRequestIDFromHead(t.head),n=Gt(t.head),a=ur(t.body,this._getResponseKeyMap(n));if(we.debug("".concat(this._className,".onMessage ret:").concat(JSON.stringify(a)," requestID:").concat(o," has:").concat(this._promiseMap.has(o))),this._setNextPingTs(),this._promiseMap.has(o)){var s=this._promiseMap.get(o),r=s.resolve,i=s.reject,c=s.timestamp;return this._promiseMap.delete(o),this._calcRTT(c),void(a.errorCode&&0!==a.errorCode?(this._channelModule.onErrorCodeNotZero(a),i(new Ba({code:a.errorCode,message:a.errorInfo||"",data:{elements:a.elements,messageVersion:a.messageVersion,cloudCustomData:a.cloudCustomData}}))):r(ba(a)))}this._channelModule.onMessage({head:t.head,body:a})}}},{key:"_calcRTT",value:function(e){var t=Date.now()-e;this._channelModule.getModule(Co).addRTT(t)}},{key:"_connect",value:function(){this._startTs=Date.now(),this._onOpenTs=0,this._socket=new _r(this),this._socketID=this._socket.getID(),this._readyState=yr,we.log("".concat(this._className,"._connect isWorkerEnabled:").concat(this.getIsWorkerEnabled()," socketID:").concat(this._socketID," url:").concat(this.getURL())),new va(ya.WS_CONNECT).setMessage("socketID:".concat(this._socketID," url:").concat(this.getURL())).end()}},{key:"getURL",value:function(){var e=this._channelModule.getModule(uo);e.isDevMode()&&(this._canIUseBinaryFrame=!1);var t=Rt();(Q||$&&"windows"===t||Z)&&(this._canIUseBinaryFrame=!1);var o=-1;"ios"===t?o=de||-1:"android"===t&&(o=ge||-1);var n=this._channelModule.getPlatform(),a=e.getSDKAppID(),s=e.getInstanceID();return this._canIUseBinaryFrame?"".concat(this._url,"/binfo?sdkappid=").concat(a,"&instanceid=").concat(s,"&random=").concat(this._getRandom(),"&platform=").concat(n,"&host=").concat(t,"&version=").concat(o):"".concat(this._url,"/info?sdkappid=").concat(a,"&instanceid=").concat(s,"&random=").concat(this._getRandom(),"&platform=").concat(n,"&host=").concat(t,"&version=").concat(o)}},{key:"_closeConnection",value:function(e){we.log("".concat(this._className,"._closeConnection socketID:").concat(this._socketID)),this._socket&&(this._socket.close(e),this._socketID=-1,this._socket=null,this._readyState=Ir)}},{key:"_resend",value:function(){var e=this;if(we.log("".concat(this._className,"._resend reConnectFlag:").concat(this._reConnectFlag),"promiseMap.size:".concat(this._promiseMap.size," simpleRequestMap.size:").concat(this._simpleRequestMap.size)),this._promiseMap.size>0&&this._promiseMap.forEach((function(t,o){var n=t.uplinkData,a=t.resolve,s=t.reject;e._promiseMap.set(o,{resolve:a,reject:s,timestamp:Date.now(),uplinkData:n}),e._execute(o,n)})),this._simpleRequestMap.size>0){var t,o=C(this._simpleRequestMap);try{for(o.s();!(t=o.n()).done;){var n=m(t.value,2),a=n[0],s=n[1];this._execute(a,s)}}catch(r){o.e(r)}finally{o.f()}this._simpleRequestMap.clear()}}},{key:"send",value:function(e){var t=this;e.head.seq=this._getSequence(),e.head.reqtime=Math.floor(Date.now()/1e3);e.keyMap;var o=g(e,mr),n=this._getRequestIDFromHead(e.head),a=JSON.stringify(o);return new Promise((function(e,s){(t._promiseMap.set(n,{resolve:e,reject:s,timestamp:Date.now(),uplinkData:a}),we.debug("".concat(t._className,".send uplinkData:").concat(JSON.stringify(o)," requestID:").concat(n," readyState:").concat(t._readyState)),t._readyState!==vr)?t._reConnect():(t._execute(n,a),t._channelModule.getModule(Co).addRequestCount())}))}},{key:"simplySend",value:function(e){e.head.seq=this._getSequence(),e.head.reqtime=Math.floor(Date.now()/1e3);e.keyMap;var t=g(e,Mr),o=this._getRequestIDFromHead(e.head),n=JSON.stringify(t);this._readyState!==vr?(this._simpleRequestMap.size0&&(clearInterval(this._timerForNotLoggedIn),this._timerForNotLoggedIn=-1),this._socketHandler.onCheckTimer(e)):this._socketHandler.onCheckTimer(1),this._checkNextPing())}},{key:"onErrorCodeNotZero",value:function(e){this.getModule(Mo).onErrorCodeNotZero(e)}},{key:"onMessage",value:function(e){this.getModule(Mo).onMessage(e)}},{key:"send",value:function(e){return this._socketHandler?this._previousState!==D.NET_STATE_CONNECTED&&e.head.servcmd.includes(Vn)?(this.reConnect(),this._sendLogViaHTTP(e)):this._socketHandler.send(e):Promise.reject()}},{key:"_sendLogViaHTTP",value:function(e){var t=H.HOST.CURRENT.STAT;return new Promise((function(o,n){var a="".concat(t,"/v4/imopenstat/tim_web_report_v2?sdkappid=").concat(e.head.sdkappid,"&reqtime=").concat(Date.now()),s=JSON.stringify(e.body),r="application/x-www-form-urlencoded;charset=UTF-8";if(te)ne.request({url:a,data:s,method:"POST",timeout:3e3,header:{"content-type":r},success:function(){o()},fail:function(){n(new Ba({code:na.NETWORK_ERROR,message:aa.NETWORK_ERROR}))}});else{var i=new XMLHttpRequest,c=setTimeout((function(){i.abort(),n(new Ba({code:na.NETWORK_TIMEOUT,message:aa.NETWORK_TIMEOUT}))}),3e3);i.onreadystatechange=function(){4===i.readyState&&(clearTimeout(c),200===i.status||304===i.status?o():n(new Ba({code:na.NETWORK_ERROR,message:aa.NETWORK_ERROR})))},i.open("POST",a,!0),i.setRequestHeader("Content-type",r),i.send(s)}}))}},{key:"simplySend",value:function(e){return this._socketHandler?this._socketHandler.simplySend(e):Promise.reject()}},{key:"onOpen",value:function(){this._ping()}},{key:"onClose",value:function(){this._socketHandler&&(this._socketHandler.getReconnectFlag()&&this._emitNetStateChangeEvent(D.NET_STATE_DISCONNECTED));this.reConnect()}},{key:"onError",value:function(){te&&!Z&&we.error("".concat(this._className,".onError 从v2.11.2起,SDK 支持了 WebSocket,如您未添加相关受信域名,请先添加!(如已添加请忽略),升级指引: https://web.sdk.qcloud.com/im/doc/zh-cn/tutorial-02-upgradeguideline.html")),this._emitNetStateChangeEvent(D.NET_STATE_DISCONNECTED)}},{key:"getKeyMap",value:function(e){return this.getModule(Mo).getKeyMap(e)}},{key:"_onAppHide",value:function(){this._isAppShowing=!1}},{key:"_onAppShow",value:function(){this._isAppShowing=!0}},{key:"onRequestTimeout",value:function(e){}},{key:"onReconnected",value:function(){we.log("".concat(this._className,".onReconnected")),this.getModule(Mo).onReconnected(),this._emitNetStateChangeEvent(D.NET_STATE_CONNECTED)}},{key:"onReconnectFailed",value:function(){we.log("".concat(this._className,".onReconnectFailed")),this._emitNetStateChangeEvent(D.NET_STATE_DISCONNECTED)}},{key:"setIsWorkerEnabled",value:function(e){this._socketHandler&&this._socketHandler.setIsWorkerEnabled(!1)}},{key:"offline",value:function(){this._emitNetStateChangeEvent(D.NET_STATE_DISCONNECTED)}},{key:"reConnect",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=!1;this._socketHandler&&(t=this._socketHandler.getReconnectFlag());var o="forcedFlag:".concat(e," fatalErrorFlag:").concat(this._fatalErrorFlag," previousState:").concat(this._previousState," reconnectFlag:").concat(t);if(we.log("".concat(this._className,".reConnect ").concat(o)),!this._fatalErrorFlag&&this._socketHandler){if(!0===e)this._socketHandler.forcedReconnect();else{if(this._previousState===D.NET_STATE_CONNECTING&&t)return;this._socketHandler.forcedReconnect()}this._emitNetStateChangeEvent(D.NET_STATE_CONNECTING)}}},{key:"_emitNetStateChangeEvent",value:function(e){this._previousState!==e&&(we.log("".concat(this._className,"._emitNetStateChangeEvent from ").concat(this._previousState," to ").concat(e)),this._previousState=e,this.emitOuterEvent(S.NET_STATE_CHANGE,{state:e}))}},{key:"_ping",value:function(){var e=this;if(!0!==this._probing){this._probing=!0;var t=this.getModule(Mo).getProtocolData({protocolName:Kn});this.send(t).then((function(){e._probing=!1})).catch((function(t){if(we.warn("".concat(e._className,"._ping failed. error:"),t),e._probing=!1,t&&60002===t.code)return new va(ya.ERROR).setMessage("code:".concat(t.code," message:").concat(t.message)).setNetworkType(e.getModule(go).getNetworkType()).end(),e._fatalErrorFlag=!0,void e._emitNetStateChangeEvent(D.NET_STATE_DISCONNECTED);e.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];we.log("".concat(e._className,"._ping failed. probe network, isAppShowing:").concat(e._isAppShowing," online:").concat(n," networkType:").concat(a)),n?e.reConnect():e._emitNetStateChangeEvent(D.NET_STATE_DISCONNECTED)}))}))}}},{key:"_checkNextPing",value:function(){this._socketHandler&&(this._socketHandler.isConnected()&&Date.now()>=this._socketHandler.getNextPingTs()&&this._ping())}},{key:"dealloc",value:function(){this._socketHandler&&(this._socketHandler.close(),this._socketHandler=null),this._timerForNotLoggedIn>-1&&clearInterval(this._timerForNotLoggedIn)}},{key:"onRestApiKickedOut",value:function(){this._socketHandler&&(this._socketHandler.close(),this.reConnect(!0))}},{key:"reset",value:function(){we.log("".concat(this._className,".reset")),this._previousState=D.NET_STATE_CONNECTED,this._probing=!1,this._fatalErrorFlag=!1,this._timerForNotLoggedIn=setInterval(this.onCheckTimer.bind(this),1e3)}}]),o}(Do),Cr=["a2","tinyid"],Sr=["a2","tinyid"],Dr=function(){function e(t){n(this,e),this._className="ProtocolHandler",this._sessionModule=t,this._configMap=new Map,this._fillConfigMap()}return s(e,[{key:"_fillConfigMap",value:function(){this._configMap.clear();var e=this._sessionModule.genCommonHead(),o=this._sessionModule.genCosSpecifiedHead(),n=this._sessionModule.genSSOReportHead();this._configMap.set(No,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.IM_OPEN_STATUS,".").concat(H.CMD.LOGIN)}),body:{state:"Online"},keyMap:{response:{InstId:"instanceID",HelloInterval:"helloInterval"}}}}(e)),this._configMap.set(Ao,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.IM_OPEN_STATUS,".").concat(H.CMD.LOGOUT)}),body:{type:0},keyMap:{request:{type:"wslogout_type"}}}}(e)),this._configMap.set(Oo,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.IM_OPEN_STATUS,".").concat(H.CMD.HELLO)}),body:{},keyMap:{response:{NewInstInfo:"newInstanceInfo"}}}}(e)),this._configMap.set(Ro,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.STAT_SERVICE,".").concat(H.CMD.KICK_OTHER)}),body:{}}}(e)),this._configMap.set(bn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.IM_COS_SIGN,".").concat(H.CMD.COS_SIGN)}),body:{cmd:"open_im_cos_svc",subCmd:"get_cos_token",duration:300,version:2},keyMap:{request:{userSig:"usersig",subCmd:"sub_cmd",cmd:"cmd",duration:"duration",version:"version"},response:{expired_time:"expiredTime",bucket_name:"bucketName",session_token:"sessionToken",tmp_secret_id:"secretId",tmp_secret_key:"secretKey"}}}}(o)),this._configMap.set(Fn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.CUSTOM_UPLOAD,".").concat(H.CMD.COS_PRE_SIG)}),body:{fileType:void 0,fileName:void 0,uploadMethod:0,duration:900},keyMap:{request:{userSig:"usersig",fileType:"file_type",fileName:"file_name",uploadMethod:"upload_method"},response:{expired_time:"expiredTime",request_id:"requestId",head_url:"headUrl",upload_url:"uploadUrl",download_url:"downloadUrl",ci_url:"ciUrl",snapshot_url:"requestSnapshotUrl"}}}}(o)),this._configMap.set(qn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.CUSTOM_UPLOAD,".").concat(H.CMD.VIDEO_COVER)}),body:{version:1,platform:void 0,coverName:void 0,requestSnapshotUrl:void 0},keyMap:{request:{version:"version",platform:"platform",coverName:"cover_name",requestSnapshotUrl:"snapshot_url"},response:{error_code:"errorCode",error_msg:"errorInfo",download_url:"snapshotUrl"}}}}(o)),this._configMap.set(Jn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.IM_CONFIG_MANAGER,".").concat(H.CMD.FETCH_COMMERCIAL_CONFIG)}),body:{SDKAppID:0},keyMap:{request:{SDKAppID:"uint32_sdkappid"},response:{int32_error_code:"errorCode",str_error_message:"errorMessage",str_purchase_bits:"purchaseBits",uint32_expired_time:"expiredTime"}}}}(e)),this._configMap.set(Xn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.IM_CONFIG_MANAGER,".").concat(H.CMD.PUSHED_COMMERCIAL_CONFIG)}),body:{},keyMap:{response:{int32_error_code:"errorCode",str_error_message:"errorMessage",str_purchase_bits:"purchaseBits",uint32_expired_time:"expiredTime"}}}}(e)),this._configMap.set($n,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.IM_CONFIG_MANAGER,".").concat(H.CMD.FETCH_CLOUD_CONTROL_CONFIG)}),body:{SDKAppID:0,version:0},keyMap:{request:{SDKAppID:"uint32_sdkappid",version:"uint64_version"},response:{int32_error_code:"errorCode",str_error_message:"errorMessage",str_json_config:"cloudControlConfig",uint32_expired_time:"expiredTime",uint32_sdkappid:"SDKAppID",uint64_version:"version"}}}}(e)),this._configMap.set(zn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.IM_CONFIG_MANAGER,".").concat(H.CMD.PUSHED_CLOUD_CONTROL_CONFIG)}),body:{},keyMap:{response:{int32_error_code:"errorCode",str_error_message:"errorMessage",str_json_config:"cloudControlConfig",uint32_expired_time:"expiredTime",uint32_sdkappid:"SDKAppID",uint64_version:"version"}}}}(e)),this._configMap.set(Qn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.OVERLOAD_PUSH,".").concat(H.CMD.OVERLOAD_NOTIFY)}),body:{},keyMap:{response:{OverLoadServCmd:"overloadCommand",DelaySecs:"waitingTime"}}}}(e)),this._configMap.set(Lo,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.OPEN_IM,".").concat(H.CMD.GET_MESSAGES)}),body:{cookie:"",syncFlag:0,needAbstract:1,isOnlineSync:0},keyMap:{request:{fromAccount:"From_Account",toAccount:"To_Account",from:"From_Account",to:"To_Account",time:"MsgTimeStamp",sequence:"MsgSeq",random:"MsgRandom",elements:"MsgBody"},response:{MsgList:"messageList",SyncFlag:"syncFlag",To_Account:"to",From_Account:"from",ClientSeq:"clientSequence",MsgSeq:"sequence",NoticeSeq:"noticeSequence",NotifySeq:"notifySequence",MsgRandom:"random",MsgTimeStamp:"time",MsgContent:"content",ToGroupId:"groupID",MsgKey:"messageKey",GroupTips:"groupTips",MsgBody:"elements",MsgType:"type",C2CRemainingUnreadCount:"C2CRemainingUnreadList",C2CPairUnreadCount:"C2CPairUnreadList"}}}}(e)),this._configMap.set(ko,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.OPEN_IM,".").concat(H.CMD.BIG_DATA_HALLWAY_AUTH_KEY)}),body:{}}}(e)),this._configMap.set(Go,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.OPEN_IM,".").concat(H.CMD.SEND_MESSAGE)}),body:{fromAccount:"",toAccount:"",msgSeq:0,msgRandom:0,msgBody:[],cloudCustomData:void 0,nick:"",avatar:"",msgLifeTime:void 0,offlinePushInfo:{pushFlag:0,title:"",desc:"",ext:"",apnsInfo:{badgeMode:0},androidInfo:{OPPOChannelID:""}},messageControlInfo:void 0,clientTime:void 0,needReadReceipt:0},keyMap:{request:{fromAccount:"From_Account",toAccount:"To_Account",msgTimeStamp:"MsgTimeStamp",msgSeq:"MsgSeq",msgRandom:"MsgRandom",msgBody:"MsgBody",count:"MaxCnt",lastMessageTime:"LastMsgTime",messageKey:"MsgKey",peerAccount:"Peer_Account",data:"Data",description:"Desc",extension:"Ext",type:"MsgType",content:"MsgContent",sizeType:"Type",uuid:"UUID",url:"",imageUrl:"URL",fileUrl:"Url",remoteAudioUrl:"Url",remoteVideoUrl:"VideoUrl",thumbUUID:"ThumbUUID",videoUUID:"VideoUUID",videoUrl:"",downloadFlag:"Download_Flag",nick:"From_AccountNick",avatar:"From_AccountHeadurl",from:"From_Account",time:"MsgTimeStamp",messageRandom:"MsgRandom",messageSequence:"MsgSeq",elements:"MsgBody",clientSequence:"ClientSeq",payload:"MsgContent",messageList:"MsgList",messageNumber:"MsgNum",abstractList:"AbstractList",messageBody:"MsgBody",needReadReceipt:"IsNeedReadReceipt"}}}}(e)),this._configMap.set(Po,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.SEND_GROUP_MESSAGE)}),body:{fromAccount:"",groupID:"",random:0,clientSequence:0,priority:"",msgBody:[],cloudCustomData:void 0,onlineOnlyFlag:0,offlinePushInfo:{pushFlag:0,title:"",desc:"",ext:"",apnsInfo:{badgeMode:0},androidInfo:{OPPOChannelID:""}},groupAtInfo:[],messageControlInfo:void 0,clientTime:void 0,needReadReceipt:0,topicID:void 0},keyMap:{request:{to:"GroupId",extension:"Ext",data:"Data",description:"Desc",random:"Random",sequence:"ReqMsgSeq",count:"ReqMsgNumber",type:"MsgType",priority:"MsgPriority",content:"MsgContent",elements:"MsgBody",sizeType:"Type",uuid:"UUID",url:"",imageUrl:"URL",fileUrl:"Url",remoteAudioUrl:"Url",remoteVideoUrl:"VideoUrl",thumbUUID:"ThumbUUID",videoUUID:"VideoUUID",videoUrl:"",downloadFlag:"Download_Flag",clientSequence:"ClientSeq",from:"From_Account",time:"MsgTimeStamp",messageRandom:"MsgRandom",messageSequence:"MsgSeq",payload:"MsgContent",messageList:"MsgList",messageNumber:"MsgNum",abstractList:"AbstractList",messageBody:"MsgBody",needReadReceipt:"NeedReadReceipt"},response:{MsgTime:"time",MsgSeq:"sequence"}}}}(e)),this._configMap.set(Vo,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.OPEN_IM,".").concat(H.CMD.REVOKE_C2C_MESSAGE)}),body:{msgInfo:{fromAccount:"",toAccount:"",msgTimeStamp:0,msgSeq:0,msgRandom:0}},keyMap:{request:{msgInfo:"MsgInfo",msgTimeStamp:"MsgTimeStamp",msgSeq:"MsgSeq",msgRandom:"MsgRandom"}}}}(e)),this._configMap.set(pn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.REVOKE_GROUP_MESSAGE)}),body:{groupID:"",msgSeqList:void 0,topicID:""},keyMap:{request:{msgSeqList:"MsgSeqList",msgSeq:"MsgSeq"}}}}(e)),this._configMap.set(xo,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.OPEN_IM,".").concat(H.CMD.GET_C2C_ROAM_MESSAGES)}),body:{peerAccount:"",count:15,lastMessageTime:0,messageKey:"",withRecalledMessage:1,direction:0},keyMap:{request:{messageKey:"MsgKey",peerAccount:"Peer_Account",count:"MaxCnt",lastMessageTime:"LastMsgTime",withRecalledMessage:"WithRecalledMsg",direction:"GetDirection"},response:{LastMsgTime:"lastMessageTime",IsNeedReadReceipt:"needReadReceipt"}}}}(e)),this._configMap.set(jo,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.OPEN_IM,".").concat(H.CMD.MODIFY_C2C_MESSAGE)}),body:{from:"",to:"",sequence:0,random:0,time:0,version:0,elements:void 0,cloudCustomData:void 0},keyMap:{request:{sequence:"MsgSeq",random:"MsgRandom",time:"MsgTime",version:"MsgVersion",type:"MsgType",content:"MsgContent"}}}}(e)),this._configMap.set(hn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.GET_GROUP_ROAM_MESSAGES)}),body:{withRecalledMsg:1,groupID:"",count:15,sequence:"",topicID:void 0},keyMap:{request:{sequence:"ReqMsgSeq",count:"ReqMsgNumber",withRecalledMessage:"WithRecalledMsg"},response:{Random:"random",MsgTime:"time",MsgSeq:"sequence",ReqMsgSeq:"sequence",RspMsgList:"messageList",IsPlaceMsg:"isPlaceMessage",IsSystemMsg:"isSystemMessage",ToGroupId:"to",EnumFrom_AccountType:"fromAccountType",EnumTo_AccountType:"toAccountType",GroupCode:"groupCode",MsgPriority:"priority",MsgBody:"elements",MsgType:"type",MsgContent:"content",IsFinished:"complete",Download_Flag:"downloadFlag",ClientSeq:"clientSequence",ThumbUUID:"thumbUUID",VideoUUID:"videoUUID",ToTopicId:"topicID"}}}}(e)),this._configMap.set(Ko,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.OPEN_IM,".").concat(H.CMD.SET_C2C_MESSAGE_READ)}),body:{C2CMsgReaded:void 0},keyMap:{request:{lastMessageTime:"LastedMsgTime"}}}}(e)),this._configMap.set(Ho,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.OPEN_IM,".").concat(H.CMD.SET_C2C_PEER_MUTE_NOTIFICATIONS)}),body:{userIDList:void 0,muteFlag:0},keyMap:{request:{userIDList:"Peer_Account",muteFlag:"Mute_Notifications"}}}}(e)),this._configMap.set(Bo,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.OPEN_IM,".").concat(H.CMD.GET_C2C_PEER_MUTE_NOTIFICATIONS)}),body:{updateSequence:0},keyMap:{response:{MuteNotificationsList:"muteFlagList"}}}}(e)),this._configMap.set(gn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.SET_GROUP_MESSAGE_READ)}),body:{groupID:void 0,messageReadSeq:void 0,topicID:void 0},keyMap:{request:{messageReadSeq:"MsgReadedSeq"}}}}(e)),this._configMap.set(_n,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.OPEN_IM,".").concat(H.CMD.SET_ALL_MESSAGE_READ)}),body:{readAllC2CMessage:0,groupMessageReadInfoList:[]},keyMap:{request:{readAllC2CMessage:"C2CReadAllMsg",groupMessageReadInfoList:"GroupReadInfo",messageSequence:"MsgSeq"},response:{C2CReadAllMsg:"readAllC2CMessage",GroupReadInfoArray:"groupMessageReadInfoList"}}}}(e)),this._configMap.set(Yo,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.OPEN_IM,".").concat(H.CMD.DELETE_C2C_MESSAGE)}),body:{fromAccount:"",to:"",keyList:void 0},keyMap:{request:{keyList:"MsgKeyList"}}}}(e)),this._configMap.set(Sn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.DELETE_GROUP_MESSAGE)}),body:{groupID:"",deleter:"",keyList:void 0,topicID:void 0},keyMap:{request:{deleter:"Deleter_Account",keyList:"Seqs"}}}}(e)),this._configMap.set(Dn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.OPEN_IM,".").concat(H.CMD.MODIFY_GROUP_MESSAGE)}),body:{groupID:"",topicID:void 0,sequence:0,version:0,elements:void 0,cloudCustomData:void 0},keyMap:{request:{sequence:"MsgSeq",version:"MsgVersion",type:"MsgType",content:"MsgContent"}}}}(e)),this._configMap.set(fn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.GET_READ_RECEIPT)}),body:{groupID:"",sequenceList:void 0},keyMap:{request:{sequence:"MsgSeq"}}}}(e)),this._configMap.set(Mn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.OPEN_IM,".").concat(H.CMD.SEND_C2C_READ_RECEIPT)}),body:{peerAccount:"",messageInfoList:void 0},keyMap:{request:{peerAccount:"Peer_Account",messageInfoList:"C2CMsgInfo",fromAccount:"From_Account",toAccount:"To_Account",sequence:"MsgSeq",random:"MsgRandom",time:"MsgTime",clientTime:"MsgClientTime"}}}}(e)),this._configMap.set(mn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.SEND_READ_RECEIPT)}),body:{groupID:"",sequenceList:void 0},keyMap:{request:{sequenceList:"MsgSeqList",sequence:"MsgSeq"}}}}(e)),this._configMap.set(vn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.GET_READ_RECEIPT_DETAIL)}),body:{groupID:"",sequence:void 0,flag:0,cursor:0,count:0},keyMap:{request:{sequence:"MsgSeq",count:"Num"},response:{ReadList:"readUserIDList",Read_Account:"userID",UnreadList:"unreadUserIDList",Unread_Account:"userID",IsFinish:"isCompleted"}}}}(e)),this._configMap.set(Wo,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.OPEN_IM,".").concat(H.CMD.GET_PEER_READ_TIME)}),body:{userIDList:void 0},keyMap:{request:{userIDList:"To_Account"},response:{ReadTime:"peerReadTimeList"}}}}(e)),this._configMap.set(zo,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.RECENT_CONTACT,".").concat(H.CMD.GET_CONVERSATION_LIST)}),body:{fromAccount:void 0,count:0},keyMap:{request:{},response:{SessionItem:"conversations",ToAccount:"groupID",To_Account:"userID",UnreadMsgCount:"unreadCount",MsgGroupReadedSeq:"messageReadSeq",C2cPeerReadTime:"c2cPeerReadTime"}}}}(e)),this._configMap.set($o,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.RECENT_CONTACT,".").concat(H.CMD.PAGING_GET_CONVERSATION_LIST)}),body:{fromAccount:void 0,timeStamp:void 0,startIndex:void 0,pinnedTimeStamp:void 0,pinnedStartIndex:void 0,orderType:void 0,messageAssistFlag:4,assistFlag:15},keyMap:{request:{messageAssistFlag:"MsgAssistFlags",assistFlag:"AssistFlags",pinnedTimeStamp:"TopTimeStamp",pinnedStartIndex:"TopStartIndex"},response:{SessionItem:"conversations",ToAccount:"groupID",To_Account:"userID",UnreadMsgCount:"unreadCount",MsgGroupReadedSeq:"messageReadSeq",C2cPeerReadTime:"c2cPeerReadTime",LastMsgFlags:"lastMessageFlag",TopFlags:"isPinned",TopTimeStamp:"pinnedTimeStamp",TopStartIndex:"pinnedStartIndex"}}}}(e)),this._configMap.set(Jo,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.RECENT_CONTACT,".").concat(H.CMD.DELETE_CONVERSATION)}),body:{fromAccount:"",toAccount:void 0,type:1,toGroupID:void 0,clearHistoryMessage:1},keyMap:{request:{toGroupID:"ToGroupid",clearHistoryMessage:"ClearRamble"}}}}(e)),this._configMap.set(Xo,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.RECENT_CONTACT,".").concat(H.CMD.PIN_CONVERSATION)}),body:{fromAccount:"",operationType:1,itemList:void 0},keyMap:{request:{itemList:"RecentContactItem"}}}}(e)),this._configMap.set(Qo,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.OPEN_IM,".").concat(H.CMD.DELETE_GROUP_AT_TIPS)}),body:{messageListToDelete:void 0},keyMap:{request:{messageListToDelete:"DelMsgList",messageSeq:"MsgSeq",messageRandom:"MsgRandom"}}}}(e)),this._configMap.set(Uo,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.PROFILE,".").concat(H.CMD.PORTRAIT_GET)}),body:{fromAccount:"",userItem:[]},keyMap:{request:{toAccount:"To_Account",standardSequence:"StandardSequence",customSequence:"CustomSequence"}}}}(e)),this._configMap.set(wo,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.PROFILE,".").concat(H.CMD.PORTRAIT_SET)}),body:{fromAccount:"",profileItem:[{tag:Fe.NICK,value:""},{tag:Fe.GENDER,value:""},{tag:Fe.ALLOWTYPE,value:""},{tag:Fe.AVATAR,value:""}]},keyMap:{request:{toAccount:"To_Account",standardSequence:"StandardSequence",customSequence:"CustomSequence"}}}}(e)),this._configMap.set(bo,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.FRIEND,".").concat(H.CMD.GET_BLACKLIST)}),body:{fromAccount:"",startIndex:0,maxLimited:30,lastSequence:0},keyMap:{response:{CurruentSequence:"currentSequence"}}}}(e)),this._configMap.set(Fo,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.FRIEND,".").concat(H.CMD.ADD_BLACKLIST)}),body:{fromAccount:"",toAccount:[]}}}(e)),this._configMap.set(qo,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.FRIEND,".").concat(H.CMD.DELETE_BLACKLIST)}),body:{fromAccount:"",toAccount:[]}}}(e)),this._configMap.set(Zo,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.GET_JOINED_GROUPS)}),body:{memberAccount:"",limit:void 0,offset:void 0,groupType:void 0,responseFilter:{groupBaseInfoFilter:void 0,selfInfoFilter:void 0},isSupportTopic:0},keyMap:{request:{memberAccount:"Member_Account"},response:{GroupIdList:"groups",MsgFlag:"messageRemindType",NoUnreadSeqList:"excludedUnreadSequenceList",MsgSeq:"readedSequence"}}}}(e)),this._configMap.set(en,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.GET_GROUP_INFO)}),body:{groupIDList:void 0,responseFilter:{groupBaseInfoFilter:["Type","Name","Introduction","Notification","FaceUrl","Owner_Account","CreateTime","InfoSeq","LastInfoTime","LastMsgTime","MemberNum","MaxMemberNum","ApplyJoinOption","NextMsgSeq","ShutUpAllMember"],groupCustomFieldFilter:void 0,memberInfoFilter:void 0,memberCustomFieldFilter:void 0}},keyMap:{request:{groupIDList:"GroupIdList",groupCustomField:"AppDefinedData",memberCustomField:"AppMemberDefinedData",groupCustomFieldFilter:"AppDefinedDataFilter_Group",memberCustomFieldFilter:"AppDefinedDataFilter_GroupMember"},response:{GroupIdList:"groups",MsgFlag:"messageRemindType",AppDefinedData:"groupCustomField",AppMemberDefinedData:"memberCustomField",AppDefinedDataFilter_Group:"groupCustomFieldFilter",AppDefinedDataFilter_GroupMember:"memberCustomFieldFilter",InfoSeq:"infoSequence",MemberList:"members",GroupInfo:"groups",ShutUpUntil:"muteUntil",ShutUpAllMember:"muteAllMembers",ApplyJoinOption:"joinOption"}}}}(e)),this._configMap.set(tn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.CREATE_GROUP)}),body:{type:void 0,name:void 0,groupID:void 0,ownerID:void 0,introduction:void 0,notification:void 0,maxMemberNum:void 0,joinOption:void 0,memberList:void 0,groupCustomField:void 0,memberCustomField:void 0,webPushFlag:1,avatar:"",isSupportTopic:void 0},keyMap:{request:{ownerID:"Owner_Account",userID:"Member_Account",avatar:"FaceUrl",maxMemberNum:"MaxMemberCount",joinOption:"ApplyJoinOption",groupCustomField:"AppDefinedData",memberCustomField:"AppMemberDefinedData"},response:{HugeGroupFlag:"avChatRoomFlag",OverJoinedGroupLimit_Account:"overLimitUserIDList"}}}}(e)),this._configMap.set(on,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.DESTROY_GROUP)}),body:{groupID:void 0}}}(e)),this._configMap.set(nn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.MODIFY_GROUP_INFO)}),body:{groupID:void 0,name:void 0,introduction:void 0,notification:void 0,avatar:void 0,maxMemberNum:void 0,joinOption:void 0,groupCustomField:void 0,muteAllMembers:void 0},keyMap:{request:{maxMemberNum:"MaxMemberCount",groupCustomField:"AppDefinedData",muteAllMembers:"ShutUpAllMember",joinOption:"ApplyJoinOption",avatar:"FaceUrl"},response:{AppDefinedData:"groupCustomField",ShutUpAllMember:"muteAllMembers",ApplyJoinOption:"joinOption"}}}}(e)),this._configMap.set(an,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.APPLY_JOIN_GROUP)}),body:{groupID:void 0,applyMessage:void 0,userDefinedField:void 0,webPushFlag:1,historyMessageFlag:void 0},keyMap:{request:{applyMessage:"ApplyMsg",historyMessageFlag:"HugeGroupHistoryMsgFlag"},response:{HugeGroupFlag:"avChatRoomFlag",AVChatRoomKey:"avChatRoomKey",RspMsgList:"messageList",ToGroupId:"to"}}}}(e)),this._configMap.set(sn,function(e){e.a2,e.tinyid;return{head:t(t({},g(e,Cr)),{},{servcmd:"".concat(H.NAME.BIG_GROUP_NO_AUTH,".").concat(H.CMD.APPLY_JOIN_GROUP)}),body:{groupID:void 0,applyMessage:void 0,userDefinedField:void 0,webPushFlag:1},keyMap:{request:{applyMessage:"ApplyMsg"},response:{HugeGroupFlag:"avChatRoomFlag"}}}}(e)),this._configMap.set(rn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.QUIT_GROUP)}),body:{groupID:void 0}}}(e)),this._configMap.set(cn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.SEARCH_GROUP_BY_ID)}),body:{groupIDList:void 0,responseFilter:{groupBasePublicInfoFilter:["Type","Name","Introduction","Notification","FaceUrl","CreateTime","Owner_Account","LastInfoTime","LastMsgTime","NextMsgSeq","MemberNum","MaxMemberNum","ApplyJoinOption"]}},keyMap:{response:{ApplyJoinOption:"joinOption"}}}}(e)),this._configMap.set(un,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.CHANGE_GROUP_OWNER)}),body:{groupID:void 0,newOwnerID:void 0},keyMap:{request:{newOwnerID:"NewOwner_Account"}}}}(e)),this._configMap.set(ln,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.HANDLE_APPLY_JOIN_GROUP)}),body:{groupID:void 0,applicant:void 0,handleAction:void 0,handleMessage:void 0,authentication:void 0,messageKey:void 0,userDefinedField:void 0},keyMap:{request:{applicant:"Applicant_Account",handleAction:"HandleMsg",handleMessage:"ApprovalMsg",messageKey:"MsgKey"}}}}(e)),this._configMap.set(dn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.HANDLE_GROUP_INVITATION)}),body:{groupID:void 0,inviter:void 0,handleAction:void 0,handleMessage:void 0,authentication:void 0,messageKey:void 0,userDefinedField:void 0},keyMap:{request:{inviter:"Inviter_Account",handleAction:"HandleMsg",handleMessage:"ApprovalMsg",messageKey:"MsgKey"}}}}(e)),this._configMap.set(yn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.GET_GROUP_APPLICATION)}),body:{startTime:void 0,limit:void 0,handleAccount:void 0},keyMap:{request:{handleAccount:"Handle_Account"}}}}(e)),this._configMap.set(In,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.OPEN_IM,".").concat(H.CMD.DELETE_GROUP_SYSTEM_MESSAGE)}),body:{messageListToDelete:void 0},keyMap:{request:{messageListToDelete:"DelMsgList",messageSeq:"MsgSeq",messageRandom:"MsgRandom"}}}}(e)),this._configMap.set(En,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.BIG_GROUP_LONG_POLLING,".").concat(H.CMD.AVCHATROOM_LONG_POLL)}),body:{USP:1,startSeq:1,holdTime:90,key:void 0},keyMap:{request:{USP:"USP"},response:{ToGroupId:"groupID"}}}}(e)),this._configMap.set(Tn,function(e){e.a2,e.tinyid;return{head:t(t({},g(e,Sr)),{},{servcmd:"".concat(H.NAME.BIG_GROUP_LONG_POLLING_NO_AUTH,".").concat(H.CMD.AVCHATROOM_LONG_POLL)}),body:{USP:1,startSeq:1,holdTime:90,key:void 0},keyMap:{request:{USP:"USP"},response:{ToGroupId:"groupID"}}}}(e)),this._configMap.set(Cn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.GET_ONLINE_MEMBER_NUM)}),body:{groupID:void 0}}}(e)),this._configMap.set(Nn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.SET_GROUP_ATTRIBUTES)}),body:{groupID:void 0,groupAttributeList:void 0,mainSequence:void 0,avChatRoomKey:void 0,attributeControl:["RaceConflict"]},keyMap:{request:{key:"key",value:"value"}}}}(e)),this._configMap.set(An,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.MODIFY_GROUP_ATTRIBUTES)}),body:{groupID:void 0,groupAttributeList:void 0,mainSequence:void 0,avChatRoomKey:void 0,attributeControl:["RaceConflict"]},keyMap:{request:{key:"key",value:"value"}}}}(e)),this._configMap.set(On,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.DELETE_GROUP_ATTRIBUTES)}),body:{groupID:void 0,groupAttributeList:void 0,mainSequence:void 0,avChatRoomKey:void 0,attributeControl:["RaceConflict"]},keyMap:{request:{key:"key"}}}}(e)),this._configMap.set(Rn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.CLEAR_GROUP_ATTRIBUTES)}),body:{groupID:void 0,mainSequence:void 0,avChatRoomKey:void 0,attributeControl:["RaceConflict"]}}}(e)),this._configMap.set(Ln,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP_ATTR,".").concat(H.CMD.GET_GROUP_ATTRIBUTES)}),body:{groupID:void 0,avChatRoomKey:void 0,groupType:1},keyMap:{request:{avChatRoomKey:"Key",groupType:"GroupType"}}}}(e)),this._configMap.set(Zn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP_COMMUNITY,".").concat(H.CMD.CREATE_TOPIC)}),body:{groupID:void 0,topicName:void 0,avatar:void 0,customData:void 0,topicID:void 0,notification:void 0,introduction:void 0},keyMap:{request:{avatar:"FaceUrl"}}}}(e)),this._configMap.set(ea,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP_COMMUNITY,".").concat(H.CMD.DELETE_TOPIC)}),body:{groupID:void 0,topicIDList:void 0},keyMap:{request:{topicIDList:"TopicIdList"},response:{DestroyResultItem:"resultList",ErrorCode:"code",ErrorInfo:"message"}}}}(e)),this._configMap.set(ta,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP_COMMUNITY,".").concat(H.CMD.UPDATE_TOPIC_PROFILE)}),body:{groupID:void 0,topicID:void 0,avatar:void 0,customData:void 0,notification:void 0,introduction:void 0,muteAllMembers:void 0,topicName:void 0},keyMap:{request:{avatar:"FaceUrl",muteAllMembers:"ShutUpAllMember"}}}}(e)),this._configMap.set(oa,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP_COMMUNITY,".").concat(H.CMD.GET_TOPIC_LIST)}),body:{groupID:void 0,topicIDList:void 0},keyMap:{request:{topicIDList:"TopicIdList"},response:{TopicAndSelfInfo:"topicInfoList",TopicInfo:"topic",GroupID:"groupID",ShutUpTime:"muteTime",ShutUpAllFlag:"muteAllMembers",LastMsgTime:"lastMessageTime",MsgSeq:"readedSequence",MsgFlag:"messageRemindType",ErrorCode:"code",ErrorInfo:"message"}}}}(e)),this._configMap.set(kn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.GET_GROUP_MEMBER_LIST)}),body:{groupID:void 0,limit:0,offset:void 0,next:void 0,memberRoleFilter:void 0,memberInfoFilter:["Role","NameCard","ShutUpUntil","JoinTime"],memberCustomFieldFilter:void 0},keyMap:{request:{memberCustomFieldFilter:"AppDefinedDataFilter_GroupMember"},response:{AppMemberDefinedData:"memberCustomField",AppDefinedDataFilter_GroupMember:"memberCustomFieldFilter",MemberList:"members",ShutUpUntil:"muteUntil"}}}}(e)),this._configMap.set(Gn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.GET_GROUP_MEMBER_INFO)}),body:{groupID:void 0,userIDList:void 0,memberInfoFilter:void 0,memberCustomFieldFilter:void 0},keyMap:{request:{userIDList:"Member_List_Account",memberCustomFieldFilter:"AppDefinedDataFilter_GroupMember"},response:{MemberList:"members",ShutUpUntil:"muteUntil",AppDefinedDataFilter_GroupMember:"memberCustomFieldFilter",AppMemberDefinedData:"memberCustomField"}}}}(e)),this._configMap.set(Pn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.ADD_GROUP_MEMBER)}),body:{groupID:void 0,silence:void 0,userIDList:void 0},keyMap:{request:{userID:"Member_Account",userIDList:"MemberList"},response:{MemberList:"members"}}}}(e)),this._configMap.set(Un,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.DELETE_GROUP_MEMBER)}),body:{groupID:void 0,userIDList:void 0,reason:void 0},keyMap:{request:{userIDList:"MemberToDel_Account"}}}}(e)),this._configMap.set(wn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.MODIFY_GROUP_MEMBER_INFO)}),body:{groupID:void 0,topicID:void 0,userID:void 0,messageRemindType:void 0,nameCard:void 0,role:void 0,memberCustomField:void 0,muteTime:void 0},keyMap:{request:{userID:"Member_Account",memberCustomField:"AppMemberDefinedData",muteTime:"ShutUpTime",messageRemindType:"MsgFlag"}}}}(e)),this._configMap.set(Vn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.IM_OPEN_STAT,".").concat(H.CMD.TIM_WEB_REPORT_V2)}),body:{header:{},event:[],quality:[]},keyMap:{request:{SDKType:"sdk_type",SDKVersion:"sdk_version",deviceType:"device_type",platform:"platform",instanceID:"instance_id",traceID:"trace_id",SDKAppID:"sdk_app_id",userID:"user_id",tinyID:"tiny_id",extension:"extension",timestamp:"timestamp",networkType:"network_type",eventType:"event_type",code:"error_code",message:"error_message",moreMessage:"more_message",duplicate:"duplicate",costTime:"cost_time",level:"level",qualityType:"quality_type",reportIndex:"report_index",wholePeriod:"whole_period",totalCount:"total_count",rttCount:"success_count_business",successRateOfRequest:"percent_business",countLessThan1Second:"success_count_business",percentOfCountLessThan1Second:"percent_business",countLessThan3Second:"success_count_platform",percentOfCountLessThan3Second:"percent_platform",successCountOfBusiness:"success_count_business",successRateOfBusiness:"percent_business",successCountOfPlatform:"success_count_platform",successRateOfPlatform:"percent_platform",successCountOfMessageReceived:"success_count_business",successRateOfMessageReceived:"percent_business",avgRTT:"average_value",avgDelay:"average_value",avgValue:"average_value",uiPlatform:"ui_platform"}}}}(n)),this._configMap.set(Kn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.HEARTBEAT,".").concat(H.CMD.ALIVE)}),body:{}}}(e)),this._configMap.set(Hn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.IM_OPEN_PUSH,".").concat(H.CMD.MESSAGE_PUSH)}),body:{},keyMap:{response:{C2cMsgArray:"C2CMessageArray",GroupMsgArray:"groupMessageArray",GroupTips:"groupTips",C2cNotifyMsgArray:"C2CNotifyMessageArray",C2cMsgInfo:"C2CReadReceiptArray",ClientSeq:"clientSequence",MsgPriority:"priority",NoticeSeq:"noticeSequence",MsgContent:"content",MsgType:"type",MsgBody:"elements",ToGroupId:"to",Desc:"description",Ext:"extension",IsSyncMsg:"isSyncMessage",Flag:"needSync",NeedAck:"needAck",PendencyAdd_Account:"userID",ProfileImNick:"nick",PendencyType:"applicationType",C2CReadAllMsg:"readAllC2CMessage",IsNeedReadReceipt:"needReadReceipt"}}}}(e)),this._configMap.set(Bn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.IM_OPEN_PUSH,".").concat(H.CMD.MULTI_MESSAGE_PUSH)}),body:{},keyMap:{response:{GroupMsgArray:"groupMessageArray",GroupTips:"groupTips",ClientSeq:"clientSequence",MsgPriority:"priority",NoticeSeq:"noticeSequence",MsgContent:"content",MsgType:"type",MsgBody:"elements",ToGroupId:"to",Desc:"description",Ext:"extension",IsSyncMsg:"isSyncMessage",Flag:"needSync",NeedAck:"needAck",PendencyType:"applicationType"}}}}(e)),this._configMap.set(xn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.OPEN_IM,".").concat(H.CMD.MESSAGE_PUSH_ACK)}),body:{sessionData:void 0},keyMap:{request:{sessionData:"SessionData"}}}}(e)),this._configMap.set(Wn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.IM_OPEN_STATUS,".").concat(H.CMD.STATUS_FORCE_OFFLINE)}),body:{},keyMap:{response:{C2cNotifyMsgArray:"C2CNotifyMessageArray",NoticeSeq:"noticeSequence",KickoutMsgNotify:"kickoutMsgNotify",NewInstInfo:"newInstanceInfo"}}}}(e)),this._configMap.set(jn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.IM_LONG_MESSAGE,".").concat(H.CMD.DOWNLOAD_MERGER_MESSAGE)}),body:{downloadKey:""},keyMap:{response:{Data:"data",Desc:"description",Ext:"extension",Download_Flag:"downloadFlag",ThumbUUID:"thumbUUID",VideoUUID:"videoUUID"}}}}(e)),this._configMap.set(Yn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.IM_LONG_MESSAGE,".").concat(H.CMD.UPLOAD_MERGER_MESSAGE)}),body:{messageList:[]},keyMap:{request:{fromAccount:"From_Account",toAccount:"To_Account",msgTimeStamp:"MsgTimeStamp",msgSeq:"MsgSeq",msgRandom:"MsgRandom",msgBody:"MsgBody",type:"MsgType",content:"MsgContent",data:"Data",description:"Desc",extension:"Ext",sizeType:"Type",uuid:"UUID",url:"",imageUrl:"URL",fileUrl:"Url",remoteAudioUrl:"Url",remoteVideoUrl:"VideoUrl",thumbUUID:"ThumbUUID",videoUUID:"VideoUUID",videoUrl:"",downloadFlag:"Download_Flag",from:"From_Account",time:"MsgTimeStamp",messageRandom:"MsgRandom",messageSequence:"MsgSeq",elements:"MsgBody",clientSequence:"ClientSeq",payload:"MsgContent",messageList:"MsgList",messageNumber:"MsgNum",abstractList:"AbstractList",messageBody:"MsgBody"}}}}(e))}},{key:"has",value:function(e){return this._configMap.has(e)}},{key:"get",value:function(e){return this._configMap.get(e)}},{key:"update",value:function(){this._fillConfigMap()}},{key:"getKeyMap",value:function(e){return this.has(e)?this.get(e).keyMap||{}:(we.warn("".concat(this._className,".getKeyMap unknown protocolName:").concat(e)),{})}},{key:"getProtocolData",value:function(e){var t=e.protocolName,o=e.requestData,n=this.get(t),a=null;if(o){var s=this._simpleDeepCopy(n),r=this._updateService(o,s),i=r.body,c=Object.create(null);for(var u in i)if(Object.prototype.hasOwnProperty.call(i,u)){if(c[u]=i[u],void 0===o[u])continue;c[u]=o[u]}r.body=c,a=this._getUplinkData(r)}else a=this._getUplinkData(n);return a}},{key:"_getUplinkData",value:function(e){var t=this._requestDataCleaner(e),o=Gt(t.head),n=cr(t.body,this._getRequestKeyMap(o));return t.body=n,t}},{key:"_updateService",value:function(e,t){var o=Gt(t.head);if(t.head.servcmd.includes(H.NAME.GROUP)){var n=e.type,a=e.groupID,s=void 0===a?void 0:a,r=e.groupIDList,i=void 0===r?[]:r;Ze(s)&&(s=i[0]||""),Et({type:n,groupID:s})&&(t.head.servcmd="".concat(H.NAME.GROUP_COMMUNITY,".").concat(o))}return t}},{key:"_getRequestKeyMap",value:function(e){var o=this.getKeyMap(e);return t(t({},sr.request),o.request)}},{key:"_requestDataCleaner",value:function(e){var t=Array.isArray(e)?[]:Object.create(null);for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&st(n)&&null!==e[n]&&void 0!==e[n]&&("object"!==o(e[n])?t[n]=e[n]:t[n]=this._requestDataCleaner.bind(this)(e[n]));return t}},{key:"_simpleDeepCopy",value:function(e){for(var t,o=Object.keys(e),n={},a=0,s=o.length;a1e3*a)return this._commandRequestInfoMap.set(t,{startTime:Date.now(),requestCount:1}),!1;i+=1,this._commandRequestInfoMap.set(t,{startTime:r,requestCount:i});var c=!1;return i>n&&(c=!0),c}},{key:"_isServerOverload",value:function(e){if(!this._serverOverloadInfoMap.has(e))return!1;var t=this._serverOverloadInfoMap.get(e),o=t.overloadTime,n=t.waitingTime,a=!1;return Date.now()-o<=1e3*n?a=!0:(this._serverOverloadInfoMap.delete(e),a=!1),a}},{key:"onPushedServerOverload",value:function(e){var t=e.overloadCommand,o=e.waitingTime;this._serverOverloadInfoMap.set(t,{overloadTime:Date.now(),waitingTime:o}),we.warn("".concat(this._className,".onPushedServerOverload waitingTime:").concat(o,"s"))}},{key:"reset",value:function(){we.log("".concat(this._className,".reset")),this._updateCommandFrequencyLimitMap(Or),this._commandRequestInfoMap.clear(),this._serverOverloadInfoMap.clear()}}]),o}(Do),Lr=function(e){i(o,e);var t=f(o);function o(e){var a;return n(this,o),(a=t.call(this,e))._className="MessageLossDetectionModule",a._maybeLostSequencesMap=new Map,a._firstRoundRet=[],a}return s(o,[{key:"onMessageMaybeLost",value:function(e,t,o){this._maybeLostSequencesMap.has(e)||this._maybeLostSequencesMap.set(e,[]);for(var n=this._maybeLostSequencesMap.get(e),a=0;a=this._expiredTime}},{key:"fetchConfig",value:function(){var e=this,t=this._canFetchConfig();if(we.log("".concat(this._className,".fetchConfig canFetchConfig:").concat(t)),t){var o=new va(ya.FETCH_CLOUD_CONTROL_CONFIG),n=this.getModule(uo).getSDKAppID();this._isFetching=!0,this.request({protocolName:$n,requestData:{SDKAppID:n,version:this._version}}).then((function(t){e._isFetching=!1,o.setMessage("version:".concat(e._version," newVersion:").concat(t.data.version," config:").concat(t.data.cloudControlConfig)).setNetworkType(e.getNetworkType()).end(),we.log("".concat(e._className,".fetchConfig ok")),e._parseCloudControlConfig(t.data)})).catch((function(t){e._isFetching=!1,e.probeNetwork().then((function(e){var n=m(e,2),a=n[0],s=n[1];o.setError(t,a,s).end()})),we.log("".concat(e._className,".fetchConfig failed. error:"),t),e._setExpiredTimeOnResponseError(12e4)}))}}},{key:"onPushedCloudControlConfig",value:function(e){we.log("".concat(this._className,".onPushedCloudControlConfig")),new va(ya.PUSHED_CLOUD_CONTROL_CONFIG).setNetworkType(this.getNetworkType()).setMessage("newVersion:".concat(e.version," config:").concat(e.cloudControlConfig)).end(),this._parseCloudControlConfig(e)}},{key:"onCheckTimer",value:function(e){this._canFetchConfig()&&this.fetchConfig()}},{key:"_parseCloudControlConfig",value:function(e){var t=this,o="".concat(this._className,"._parseCloudControlConfig"),n=e.errorCode,a=e.errorMessage,s=e.cloudControlConfig,r=e.version,i=e.expiredTime;if(0===n){if(this._version!==r){var c=null;try{c=JSON.parse(s)}catch(u){we.error("".concat(o," JSON parse error:").concat(s))}c&&(this._cloudConfig.clear(),Object.keys(c).forEach((function(e){t._cloudConfig.set(e,c[e])})),this._version=r,this.emitInnerEvent(Xa))}this._expiredTime=Date.now()+1e3*i}else Ze(n)?(we.log("".concat(o," failed. Invalid message format:"),e),this._setExpiredTimeOnResponseError(36e5)):(we.error("".concat(o," errorCode:").concat(n," errorMessage:").concat(a)),this._setExpiredTimeOnResponseError(12e4))}},{key:"_setExpiredTimeOnResponseError",value:function(e){this._expiredTime=Date.now()+e}},{key:"reset",value:function(){we.log("".concat(this._className,".reset")),this._cloudConfig.clear(),this._expiredTime=0,this._version=0,this._isFetching=!1}}]),o}(Do),Gr=function(e){i(o,e);var t=f(o);function o(e){var a;return n(this,o),(a=t.call(this,e))._className="PullGroupMessageModule",a._remoteLastMessageSequenceMap=new Map,a.PULL_LIMIT_COUNT=15,a}return s(o,[{key:"startPull",value:function(){var e=this,t=this._getNeedPullConversationList();this._getRemoteLastMessageSequenceList().then((function(){var o=e.getModule(co);t.forEach((function(t){var n=t.conversationID,a=n.replace(D.CONV_GROUP,""),s=o.getGroupLocalLastMessageSequence(n),r=e._remoteLastMessageSequenceMap.get(a)||0,i=r-s;we.log("".concat(e._className,".startPull groupID:").concat(a," localLastMessageSequence:").concat(s," ")+"remoteLastMessageSequence:".concat(r," diff:").concat(i)),s>0&&i>=1&&i<300&&e._pullMissingMessage({groupID:a,localLastMessageSequence:s,remoteLastMessageSequence:r,diff:i})}))}))}},{key:"_getNeedPullConversationList",value:function(){return this.getModule(co).getLocalConversationList().filter((function(e){return e.type===D.CONV_GROUP&&e.groupProfile.type!==D.GRP_AVCHATROOM}))}},{key:"_getRemoteLastMessageSequenceList",value:function(){var e=this;return this.getModule(ao).getGroupList().then((function(t){for(var o=t.data.groupList,n=void 0===o?[]:o,a=0;athis.PULL_LIMIT_COUNT?this.PULL_LIMIT_COUNT:a,e.sequence=a>this.PULL_LIMIT_COUNT?o+this.PULL_LIMIT_COUNT:o+a,this._getGroupMissingMessage(e).then((function(s){s.length>0&&(s[0].sequence+1<=n&&(e.localLastMessageSequence=o+t.PULL_LIMIT_COUNT,e.diff=a-t.PULL_LIMIT_COUNT,t._pullMissingMessage(e)),t.getModule(ao).onNewGroupMessage({dataList:s,isInstantMessage:!1}))}))}},{key:"_getGroupMissingMessage",value:function(e){var t=this,o=new va(ya.GET_GROUP_MISSING_MESSAGE);return this.request({protocolName:hn,requestData:{groupID:e.groupID,count:e.count,sequence:e.sequence}}).then((function(n){var a=n.data.messageList,s=void 0===a?[]:a;return o.setNetworkType(t.getNetworkType()).setMessage("groupID:".concat(e.groupID," count:").concat(e.count," sequence:").concat(e.sequence," messageList length:").concat(s.length)).end(),s})).catch((function(e){t.probeNetwork().then((function(t){var n=m(t,2),a=n[0],s=n[1];o.setError(e,a,s).end()}))}))}},{key:"reset",value:function(){we.log("".concat(this._className,".reset")),this._remoteLastMessageSequenceMap.clear()}}]),o}(Do),Pr=function(){function e(){n(this,e),this._className="AvgE2EDelay",this._e2eDelayArray=[]}return s(e,[{key:"addMessageDelay",value:function(e){var t=ke()-e;t>=0&&this._e2eDelayArray.push(t)}},{key:"_calcAvg",value:function(e,t){if(0===t)return 0;var o=0;return e.forEach((function(e){o+=e})),Pt(o/t,1)}},{key:"_calcCountWithLimit",value:function(e){var t=e.e2eDelayArray,o=e.min,n=e.max;return t.filter((function(e){return o<=e&&e100&&(o=100),o}},{key:"_checkE2EDelayException",value:function(e,t){var o=e.filter((function(e){return e>t}));if(o.length>0){var n=o.length,a=Math.min.apply(Math,M(o)),s=Math.max.apply(Math,M(o)),r=this._calcAvg(o,n),i=Pt(n/e.length*100,2);if(i>50)new va(ya.MESSAGE_E2E_DELAY_EXCEPTION).setMessage("message e2e delay exception. count:".concat(n," min:").concat(a," max:").concat(s," avg:").concat(r," percent:").concat(i)).setLevel("warning").end()}}},{key:"getStatResult",value:function(){var e=this._e2eDelayArray.length;if(0===e)return null;var t=M(this._e2eDelayArray),o=this._calcCountWithLimit({e2eDelayArray:t,min:0,max:1}),n=this._calcCountWithLimit({e2eDelayArray:t,min:1,max:3}),a=this._calcPercent(o,e),s=this._calcPercent(n,e),r=this._calcAvg(t,e);return this._checkE2EDelayException(t,3),t.length=0,this.reset(),{totalCount:e,countLessThan1Second:o,percentOfCountLessThan1Second:a,countLessThan3Second:n,percentOfCountLessThan3Second:s,avgDelay:r}}},{key:"reset",value:function(){this._e2eDelayArray.length=0}}]),e}(),Ur=function(){function e(){n(this,e),this._className="AvgRTT",this._requestCount=0,this._rttArray=[]}return s(e,[{key:"addRequestCount",value:function(){this._requestCount+=1}},{key:"addRTT",value:function(e){this._rttArray.push(e)}},{key:"_calcTotalCount",value:function(){return this._requestCount}},{key:"_calcRTTCount",value:function(e){return e.length}},{key:"_calcSuccessRateOfRequest",value:function(e,t){if(0===t)return 0;var o=Pt(e/t*100,2);return o>100&&(o=100),o}},{key:"_calcAvg",value:function(e,t){if(0===t)return 0;var o=0;return e.forEach((function(e){o+=e})),parseInt(o/t)}},{key:"_calcMax",value:function(){return Math.max.apply(Math,M(this._rttArray))}},{key:"_calcMin",value:function(){return Math.min.apply(Math,M(this._rttArray))}},{key:"getStatResult",value:function(){var e=this._calcTotalCount(),t=M(this._rttArray);if(0===e)return null;var o=this._calcRTTCount(t),n=this._calcSuccessRateOfRequest(o,e),a=this._calcAvg(t,o);return we.log("".concat(this._className,".getStatResult max:").concat(this._calcMax()," min:").concat(this._calcMin()," avg:").concat(a)),this.reset(),{totalCount:e,rttCount:o,successRateOfRequest:n,avgRTT:a}}},{key:"reset",value:function(){this._requestCount=0,this._rttArray.length=0}}]),e}(),wr=function(){function e(){n(this,e),this._map=new Map}return s(e,[{key:"initMap",value:function(e){var t=this;e.forEach((function(e){t._map.set(e,{totalCount:0,successCount:0,failedCountOfUserSide:0,costArray:[],fileSizeArray:[]})}))}},{key:"addTotalCount",value:function(e){return!(Ze(e)||!this._map.has(e))&&(this._map.get(e).totalCount+=1,!0)}},{key:"addSuccessCount",value:function(e){return!(Ze(e)||!this._map.has(e))&&(this._map.get(e).successCount+=1,!0)}},{key:"addFailedCountOfUserSide",value:function(e){return!(Ze(e)||!this._map.has(e))&&(this._map.get(e).failedCountOfUserSide+=1,!0)}},{key:"addCost",value:function(e,t){return!(Ze(e)||!this._map.has(e))&&(this._map.get(e).costArray.push(t),!0)}},{key:"addFileSize",value:function(e,t){return!(Ze(e)||!this._map.has(e))&&(this._map.get(e).fileSizeArray.push(t),!0)}},{key:"_calcSuccessRateOfBusiness",value:function(e){if(Ze(e)||!this._map.has(e))return-1;var t=this._map.get(e),o=Pt(t.successCount/t.totalCount*100,2);return o>100&&(o=100),o}},{key:"_calcSuccessRateOfPlatform",value:function(e){if(Ze(e)||!this._map.has(e))return-1;var t=this._map.get(e),o=this._calcSuccessCountOfPlatform(e)/t.totalCount*100;return(o=Pt(o,2))>100&&(o=100),o}},{key:"_calcTotalCount",value:function(e){return Ze(e)||!this._map.has(e)?-1:this._map.get(e).totalCount}},{key:"_calcSuccessCountOfBusiness",value:function(e){return Ze(e)||!this._map.has(e)?-1:this._map.get(e).successCount}},{key:"_calcSuccessCountOfPlatform",value:function(e){if(Ze(e)||!this._map.has(e))return-1;var t=this._map.get(e);return t.successCount+t.failedCountOfUserSide}},{key:"_calcAvg",value:function(e){return Ze(e)||!this._map.has(e)?-1:e===da?this._calcAvgSpeed(e):this._calcAvgCost(e)}},{key:"_calcAvgCost",value:function(e){var t=this._map.get(e).costArray.length;if(0===t)return 0;var o=0;return this._map.get(e).costArray.forEach((function(e){o+=e})),parseInt(o/t)}},{key:"_calcAvgSpeed",value:function(e){var t=0,o=0;return this._map.get(e).costArray.forEach((function(e){t+=e})),this._map.get(e).fileSizeArray.forEach((function(e){o+=e})),parseInt(1e3*o/t)}},{key:"getStatResult",value:function(e){var t=this._calcTotalCount(e);if(0===t)return null;var o=this._calcSuccessCountOfBusiness(e),n=this._calcSuccessRateOfBusiness(e),a=this._calcSuccessCountOfPlatform(e),s=this._calcSuccessRateOfPlatform(e),r=this._calcAvg(e);return this.reset(e),{totalCount:t,successCountOfBusiness:o,successRateOfBusiness:n,successCountOfPlatform:a,successRateOfPlatform:s,avgValue:r}}},{key:"reset",value:function(e){Ze(e)?this._map.clear():this._map.set(e,{totalCount:0,successCount:0,failedCountOfUserSide:0,costArray:[],fileSizeArray:[]})}}]),e}(),br=function(){function e(){n(this,e),this._lastMap=new Map,this._currentMap=new Map}return s(e,[{key:"initMap",value:function(e){var t=this;e.forEach((function(e){t._lastMap.set(e,new Map),t._currentMap.set(e,new Map)}))}},{key:"addMessageSequence",value:function(e){var t=e.key,o=e.message;if(Ze(t)||!this._lastMap.has(t)||!this._currentMap.has(t))return!1;var n=o.conversationID,a=o.sequence,s=n.replace(D.CONV_GROUP,"");if(0===this._lastMap.get(t).size)this._addCurrentMap(e);else if(this._lastMap.get(t).has(s)){var r=this._lastMap.get(t).get(s),i=r.length-1;a>r[0]&&a100&&(n=100),this._copyData(e),{totalCount:t,successCountOfMessageReceived:o,successRateOfMessageReceived:n}}},{key:"reset",value:function(){this._currentMap.clear(),this._lastMap.clear()}}]),e}(),Fr=function(e){i(a,e);var o=f(a);function a(e){var t;n(this,a),(t=o.call(this,e))._className="QualityStatModule",t.TAG="im-ssolog-quality-stat",t.reportIndex=0,t.wholePeriod=!1,t._qualityItems=[sa,ra,ia,ca,ua,la,da,pa,ga,_a],t._messageSentItems=[ia,ca,ua,la,da],t._messageReceivedItems=[pa,ga,_a],t.REPORT_INTERVAL=120,t.REPORT_SDKAPPID_BLACKLIST=[],t.REPORT_TINYID_WHITELIST=[],t._statInfoArr=[],t._avgRTT=new Ur,t._avgE2EDelay=new Pr,t._rateMessageSent=new wr,t._rateMessageReceived=new br;var s=t.getInnerEmitterInstance();return s.on(Ja,t._onLoginSuccess,_(t)),s.on(Xa,t._onCloudConfigUpdated,_(t)),t}return s(a,[{key:"_onLoginSuccess",value:function(){var e=this;this._rateMessageSent.initMap(this._messageSentItems),this._rateMessageReceived.initMap(this._messageReceivedItems);var t=this.getModule(lo),o=t.getItem(this.TAG,!1);!Vt(o)&&ot(o.forEach)&&(we.log("".concat(this._className,"._onLoginSuccess.get quality stat log in storage, nums=").concat(o.length)),o.forEach((function(t){e._statInfoArr.push(t)})),t.removeItem(this.TAG,!1))}},{key:"_onCloudConfigUpdated",value:function(){var e=this.getCloudConfig("q_rpt_interval"),t=this.getCloudConfig("q_rpt_sdkappid_bl"),o=this.getCloudConfig("q_rpt_tinyid_wl");Ze(e)||(this.REPORT_INTERVAL=Number(e)),Ze(t)||(this.REPORT_SDKAPPID_BLACKLIST=t.split(",").map((function(e){return Number(e)}))),Ze(o)||(this.REPORT_TINYID_WHITELIST=o.split(","))}},{key:"onCheckTimer",value:function(e){this.isLoggedIn()&&e%this.REPORT_INTERVAL==0&&(this.wholePeriod=!0,this._report())}},{key:"addRequestCount",value:function(){this._avgRTT.addRequestCount()}},{key:"addRTT",value:function(e){this._avgRTT.addRTT(e)}},{key:"addMessageDelay",value:function(e){this._avgE2EDelay.addMessageDelay(e)}},{key:"addTotalCount",value:function(e){this._rateMessageSent.addTotalCount(e)||we.warn("".concat(this._className,".addTotalCount invalid key:"),e)}},{key:"addSuccessCount",value:function(e){this._rateMessageSent.addSuccessCount(e)||we.warn("".concat(this._className,".addSuccessCount invalid key:"),e)}},{key:"addFailedCountOfUserSide",value:function(e){this._rateMessageSent.addFailedCountOfUserSide(e)||we.warn("".concat(this._className,".addFailedCountOfUserSide invalid key:"),e)}},{key:"addCost",value:function(e,t){this._rateMessageSent.addCost(e,t)||we.warn("".concat(this._className,".addCost invalid key or cost:"),e,t)}},{key:"addFileSize",value:function(e,t){this._rateMessageSent.addFileSize(e,t)||we.warn("".concat(this._className,".addFileSize invalid key or size:"),e,t)}},{key:"addMessageSequence",value:function(e){this._rateMessageReceived.addMessageSequence(e)||we.warn("".concat(this._className,".addMessageSequence invalid key:"),e.key)}},{key:"_getQualityItem",value:function(e){var o={},n=ma[this.getNetworkType()];Ze(n)&&(n=8);var a={qualityType:ha[e],timestamp:Re(),networkType:n,extension:""};switch(e){case sa:o=this._avgRTT.getStatResult();break;case ra:o=this._avgE2EDelay.getStatResult();break;case ia:case ca:case ua:case la:case da:o=this._rateMessageSent.getStatResult(e);break;case pa:case ga:case _a:o=this._rateMessageReceived.getStatResult(e)}return null===o?null:t(t({},a),o)}},{key:"_report",value:function(e){var t=this,o=[],n=null;Ze(e)?this._qualityItems.forEach((function(e){null!==(n=t._getQualityItem(e))&&(n.reportIndex=t.reportIndex,n.wholePeriod=t.wholePeriod,o.push(n))})):null!==(n=this._getQualityItem(e))&&(n.reportIndex=this.reportIndex,n.wholePeriod=this.wholePeriod,o.push(n)),we.debug("".concat(this._className,"._report"),o),this._statInfoArr.length>0&&(o=o.concat(this._statInfoArr),this._statInfoArr=[]);var a=this.getModule(uo),s=a.getSDKAppID(),r=a.getTinyID();Ut(this.REPORT_SDKAPPID_BLACKLIST,s)&&!wt(this.REPORT_TINYID_WHITELIST,r)&&(o=[]),o.length>0&&this._doReport(o)}},{key:"_doReport",value:function(e){var o=this,n={header:Hs(this),quality:e};this.request({protocolName:Vn,requestData:t({},n)}).then((function(){o.reportIndex++,o.wholePeriod=!1})).catch((function(t){we.warn("".concat(o._className,"._doReport, online:").concat(o.getNetworkType()," error:"),t),o._statInfoArr=o._statInfoArr.concat(e),o._flushAtOnce()}))}},{key:"_flushAtOnce",value:function(){var e=this.getModule(lo),t=e.getItem(this.TAG,!1),o=this._statInfoArr;if(Vt(t))we.log("".concat(this._className,"._flushAtOnce count:").concat(o.length)),e.setItem(this.TAG,o,!0,!1);else{var n=o.concat(t);n.length>10&&(n=n.slice(0,10)),we.log("".concat(this.className,"._flushAtOnce count:").concat(n.length)),e.setItem(this.TAG,n,!0,!1)}this._statInfoArr=[]}},{key:"reset",value:function(){we.log("".concat(this._className,".reset")),this._report(),this.reportIndex=0,this.wholePeriod=!1,this.REPORT_SDKAPPID_BLACKLIST=[],this.REPORT_TINYID_WHITELIST=[],this._avgRTT.reset(),this._avgE2EDelay.reset(),this._rateMessageSent.reset(),this._rateMessageReceived.reset()}}]),a}(Do),qr=function(e){i(o,e);var t=f(o);function o(e){var a;return n(this,o),(a=t.call(this,e))._className="WorkerTimerModule",a._isWorkerEnabled=!0,a._workerTimer=null,a._init(),a.getInnerEmitterInstance().on(Xa,a._onCloudConfigUpdated,_(a)),a}return s(o,[{key:"isWorkerEnabled",value:function(){return this._isWorkerEnabled&&Ee}},{key:"startWorkerTimer",value:function(){we.log("".concat(this._className,".startWorkerTimer")),this._workerTimer&&this._workerTimer.postMessage("start")}},{key:"stopWorkerTimer",value:function(){we.log("".concat(this._className,".stopWorkerTimer")),this._workerTimer&&this._workerTimer.postMessage("stop")}},{key:"_init",value:function(){if(Ee){var e=URL.createObjectURL(new Blob(['let interval = -1;onmessage = function(event) { if (event.data === "start") { if (interval > 0) { clearInterval(interval); } interval = setInterval(() => { postMessage(""); }, 1000) } else if (event.data === "stop") { clearInterval(interval); interval = -1; }};'],{type:"application/javascript; charset=utf-8"}));this._workerTimer=new Worker(e);var t=this;this._workerTimer.onmessage=function(){t._moduleManager.onCheckTimer()}}}},{key:"_onCloudConfigUpdated",value:function(){var e=this.getCloudConfig("enable_worker");we.log("".concat(this._className,"._onCloudConfigUpdated enableWorker:").concat(e)),"1"===e?!this._isWorkerEnabled&&Ee&&(this._isWorkerEnabled=!0,this.startWorkerTimer(),this._moduleManager.onWorkerTimerEnabled()):this._isWorkerEnabled&&Ee&&(this._isWorkerEnabled=!1,this.stopWorkerTimer(),this._moduleManager.onWorkerTimerDisabled())}},{key:"terminate",value:function(){we.log("".concat(this._className,".terminate")),this._workerTimer&&(this._workerTimer.terminate(),this._workerTimer=null)}},{key:"reset",value:function(){we.log("".concat(this._className,".reset"))}}]),o}(Do),Vr=function(){function e(){n(this,e),this._className="PurchasedFeatureHandler",this._purchasedFeatureMap=new Map}return s(e,[{key:"isValidPurchaseBits",value:function(e){return e&&"string"==typeof e&&e.length>=1&&e.length<=64&&/[01]{1,64}/.test(e)}},{key:"parsePurchaseBits",value:function(e){var t="".concat(this._className,".parsePurchaseBits");if(this.isValidPurchaseBits(e)){this._purchasedFeatureMap.clear();for(var o=Object.values(B),n=null,a=e.length-1,s=0;a>=0;a--,s++)n=s<32?new L(0,Math.pow(2,s)).toString():new L(Math.pow(2,s-32),0).toString(),-1!==o.indexOf(n)&&("1"===e[a]?this._purchasedFeatureMap.set(n,!0):this._purchasedFeatureMap.set(n,!1))}else we.warn("".concat(t," invalid purchase bits:").concat(e))}},{key:"hasPurchasedFeature",value:function(e){return!!this._purchasedFeatureMap.get(e)}},{key:"clear",value:function(){this._purchasedFeatureMap.clear()}}]),e}(),Kr=function(e){i(o,e);var t=f(o);function o(e){var a;return n(this,o),(a=t.call(this,e))._className="CommercialConfigModule",a._expiredTime=0,a._isFetching=!1,a._purchasedFeatureHandler=new Vr,a}return s(o,[{key:"_canFetch",value:function(){return this.isLoggedIn()?!this._isFetching&&Date.now()>=this._expiredTime:(this._expiredTime=Date.now()+2e3,!1)}},{key:"onCheckTimer",value:function(e){this._canFetch()&&this.fetchConfig()}},{key:"fetchConfig",value:function(){var e=this,t=this._canFetch(),o="".concat(this._className,".fetchConfig");if(we.log("".concat(o," canFetch:").concat(t)),t){var n=new va(ya.FETCH_COMMERCIAL_CONFIG);n.setNetworkType(this.getNetworkType());var a=this.getModule(uo).getSDKAppID();this._isFetching=!0,this.request({protocolName:Jn,requestData:{SDKAppID:a}}).then((function(t){n.setMessage("purchaseBits:".concat(t.data.purchaseBits)).end(),we.log("".concat(o," ok.")),e._parseConfig(t.data),e._isFetching=!1})).catch((function(t){e.probeNetwork().then((function(e){var o=m(e,2),a=o[0],s=o[1];n.setError(t,a,s).end()})),e._isFetching=!1}))}}},{key:"onPushedConfig",value:function(e){var t="".concat(this._className,".onPushedConfig");we.log("".concat(t)),new va(ya.PUSHED_COMMERCIAL_CONFIG).setNetworkType(this.getNetworkType()).setMessage("purchaseBits:".concat(e.purchaseBits)).end(),this._parseConfig(e)}},{key:"_parseConfig",value:function(e){var t="".concat(this._className,"._parseConfig"),o=e.errorCode,n=e.errorMessage,a=e.purchaseBits,s=e.expiredTime;0===o?(this._purchasedFeatureHandler.parsePurchaseBits(a),this._expiredTime=Date.now()+1e3*s):Ze(o)?(we.log("".concat(t," failed. Invalid message format:"),e),this._setExpiredTimeOnResponseError(36e5)):(we.error("".concat(t," errorCode:").concat(o," errorMessage:").concat(n)),this._setExpiredTimeOnResponseError(12e4))}},{key:"_setExpiredTimeOnResponseError",value:function(e){this._expiredTime=Date.now()+e}},{key:"hasPurchasedFeature",value:function(e){return this._purchasedFeatureHandler.hasPurchasedFeature(e)}},{key:"reset",value:function(){we.log("".concat(this._className,".reset")),this._expiredTime=0,this._isFetching=!1,this._purchasedFeatureHandler.clear()}}]),o}(Do),Hr=function(){function e(t){n(this,e);var o=new va(ya.SDK_CONSTRUCT);this._className="ModuleManager",this._isReady=!1,this._reason=na.USER_NOT_LOGGED_IN,this._startLoginTs=0,this._moduleMap=new Map,this._innerEmitter=null,this._outerEmitter=null,this._checkCount=0,this._checkTimer=-1,this._moduleMap.set(uo,new bs(this,t)),this._moduleMap.set(So,new Kr(this)),this._moduleMap.set(Io,new kr(this)),this._moduleMap.set(Eo,new qr(this)),this._moduleMap.set(Co,new Fr(this)),this._moduleMap.set(vo,new Tr(this)),this._moduleMap.set(Mo,new Rr(this)),this._moduleMap.set(eo,new Fs(this)),this._moduleMap.set(to,new or(this)),this._moduleMap.set(oo,new ws(this)),this._moduleMap.set(no,new $a(this)),this._moduleMap.set(co,new _s(this)),this._moduleMap.set(ao,new Ds(this)),this._moduleMap.set(ro,new As(this)),this._moduleMap.set(io,new ks(this)),this._moduleMap.set(lo,new Vs(this)),this._moduleMap.set(po,new Bs(this)),this._moduleMap.set(go,new js(this)),this._moduleMap.set(_o,new zs(this)),this._moduleMap.set(ho,new Xs(this)),this._moduleMap.set(fo,new nr(this)),this._moduleMap.set(mo,new ar(this)),this._moduleMap.set(yo,new Lr(this)),this._moduleMap.set(To,new Gr(this)),this._eventThrottleMap=new Map;var a=t.instanceID,s=t.oversea,r=t.SDKAppID,i="instanceID:".concat(a," SDKAppID:").concat(r," host:").concat(Rt()," oversea:").concat(s," inBrowser:").concat(oe," inMiniApp:").concat(te)+" workerAvailable:".concat(Ee," UserAgent:").concat(se);va.bindEventStatModule(this._moduleMap.get(po)),o.setMessage("".concat(i," ").concat(function(){var e="";if(te)try{var t=ne.getSystemInfoSync(),o=t.model,n=t.version,a=t.system,s=t.platform,r=t.SDKVersion;e="model:".concat(o," version:").concat(n," system:").concat(a," platform:").concat(s," SDKVersion:").concat(r)}catch(i){e=""}return e}())).end(),we.info("SDK ".concat(i)),this._readyList=void 0,this._ssoLogForReady=null,this._initReadyList()}return s(e,[{key:"_startTimer",value:function(){var e=this._moduleMap.get(Eo),t=e.isWorkerEnabled();we.log("".concat(this._className,".startTimer isWorkerEnabled:").concat(t," seed:").concat(this._checkTimer)),t?e.startWorkerTimer():this._startMainThreadTimer()}},{key:"_startMainThreadTimer",value:function(){we.log("".concat(this._className,"._startMainThreadTimer")),this._checkTimer<0&&(this._checkTimer=setInterval(this.onCheckTimer.bind(this),1e3))}},{key:"stopTimer",value:function(){var e=this._moduleMap.get(Eo),t=e.isWorkerEnabled();we.log("".concat(this._className,".stopTimer isWorkerEnabled:").concat(t," seed:").concat(this._checkTimer)),t?e.stopWorkerTimer():this._stopMainThreadTimer()}},{key:"_stopMainThreadTimer",value:function(){we.log("".concat(this._className,"._stopMainThreadTimer")),this._checkTimer>0&&(clearInterval(this._checkTimer),this._checkTimer=-1,this._checkCount=0)}},{key:"_stopMainThreadSocket",value:function(){we.log("".concat(this._className,"._stopMainThreadSocket"));var e=this._moduleMap.get(vo);e.setIsWorkerEnabled(!0),e.reConnect()}},{key:"_startMainThreadSocket",value:function(){we.log("".concat(this._className,"._startMainThreadSocket"));var e=this._moduleMap.get(vo);e.setIsWorkerEnabled(!1),e.reConnect()}},{key:"onWorkerTimerEnabled",value:function(){we.log("".concat(this._className,".onWorkerTimerEnabled, disable main thread timer and socket")),this._stopMainThreadTimer(),this._stopMainThreadSocket()}},{key:"onWorkerTimerDisabled",value:function(){we.log("".concat(this._className,".onWorkerTimerDisabled, enable main thread timer and socket")),this._startMainThreadTimer(),this._startMainThreadSocket()}},{key:"onCheckTimer",value:function(){this._checkCount+=1;var e,t=C(this._moduleMap);try{for(t.s();!(e=t.n()).done;){var o=m(e.value,2)[1];o.onCheckTimer&&o.onCheckTimer(this._checkCount)}}catch(n){t.e(n)}finally{t.f()}}},{key:"_initReadyList",value:function(){var e=this;this._readyList=[this._moduleMap.get(eo),this._moduleMap.get(co)],this._readyList.forEach((function(t){t.ready((function(){return e._onModuleReady()}))}))}},{key:"_onModuleReady",value:function(){var e=!0;if(this._readyList.forEach((function(t){t.isReady()||(e=!1)})),e&&!this._isReady){this._isReady=!0,this._outerEmitter.emit(S.SDK_READY);var t=Date.now()-this._startLoginTs;we.warn("SDK is ready. cost ".concat(t," ms")),this._startLoginTs=Date.now();var o=this._moduleMap.get(go).getNetworkType(),n=this._ssoLogForReady.getStartTs()+Oe;this._ssoLogForReady.setNetworkType(o).setMessage(t).start(n).end()}}},{key:"login",value:function(){0===this._startLoginTs&&(Le(),this._startLoginTs=Date.now(),this._startTimer(),this._moduleMap.get(go).start(),this._ssoLogForReady=new va(ya.SDK_READY),this._reason=na.LOGGING_IN)}},{key:"onLoginFailed",value:function(){this._startLoginTs=0}},{key:"getOuterEmitterInstance",value:function(){return null===this._outerEmitter&&(this._outerEmitter=new $s,Wa(this._outerEmitter),this._outerEmitter._emit=this._outerEmitter.emit,this._outerEmitter.emit=function(e,t){var o=this;if(e===S.CONVERSATION_LIST_UPDATED||e===S.FRIEND_LIST_UPDATED||e===S.GROUP_LIST_UPDATED)if(this._eventThrottleMap.has(e)){var n=Date.now(),a=this._eventThrottleMap.get(e);n-a.last<1e3?(a.timeoutID&&clearTimeout(a.timeoutID),a.timeoutID=setTimeout((function(){a.last=n,o._outerEmitter._emit.apply(o._outerEmitter,[e,{name:e,data:o._getEventData(e)}])}),500)):(a.last=n,this._outerEmitter._emit.apply(this._outerEmitter,[e,{name:e,data:this._getEventData(e)}]))}else this._eventThrottleMap.set(e,{last:Date.now(),timeoutID:-1}),this._outerEmitter._emit.apply(this._outerEmitter,[e,{name:e,data:this._getEventData(e)}]);else this._outerEmitter._emit.apply(this._outerEmitter,[e,{name:e,data:arguments[1]}])}.bind(this)),this._outerEmitter}},{key:"_getEventData",value:function(e){return e===S.CONVERSATION_LIST_UPDATED?this._moduleMap.get(co).getLocalConversationList():e===S.FRIEND_LIST_UPDATED?this._moduleMap.get(so).getLocalFriendList(!1):e===S.GROUP_LIST_UPDATED?this._moduleMap.get(ao).getLocalGroupList():void 0}},{key:"getInnerEmitterInstance",value:function(){return null===this._innerEmitter&&(this._innerEmitter=new $s,this._innerEmitter._emit=this._innerEmitter.emit,this._innerEmitter.emit=function(e,t){var o;Xe(arguments[1])&&arguments[1].data?(we.warn("inner eventData has data property, please check!"),o=[e,{name:arguments[0],data:arguments[1].data}]):o=[e,{name:arguments[0],data:arguments[1]}],this._innerEmitter._emit.apply(this._innerEmitter,o)}.bind(this)),this._innerEmitter}},{key:"hasModule",value:function(e){return this._moduleMap.has(e)}},{key:"getModule",value:function(e){return this._moduleMap.get(e)}},{key:"isReady",value:function(){return this._isReady}},{key:"getNotReadyReason",value:function(){return this._reason}},{key:"setNotReadyReason",value:function(e){this._reason=e}},{key:"onError",value:function(e){we.warn("Oops! code:".concat(e.code," message:").concat(e.message)),new va(ya.ERROR).setMessage("code:".concat(e.code," message:").concat(e.message)).setNetworkType(this.getModule(go).getNetworkType()).setLevel("error").end(),this.getOuterEmitterInstance().emit(S.ERROR,e)}},{key:"reset",value:function(){we.log("".concat(this._className,".reset")),Le();var e,t=C(this._moduleMap);try{for(t.s();!(e=t.n()).done;){var o=m(e.value,2)[1];o.reset&&o.reset()}}catch(r){t.e(r)}finally{t.f()}this._startLoginTs=0,this._initReadyList(),this._isReady=!1,this.stopTimer(),this._outerEmitter.emit(S.SDK_NOT_READY);var n,a=C(this._eventThrottleMap);try{for(a.s();!(n=a.n()).done;){var s=m(n.value,2)[1];s.timeoutID&&clearTimeout(s.timeoutID)}}catch(r){a.e(r)}finally{a.f()}this._eventThrottleMap.clear()}}]),e}(),Br=function(){function e(){n(this,e),this._funcMap=new Map}return s(e,[{key:"defense",value:function(e,t){var o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0;if("string"!=typeof e)return null;if(0===e.length)return null;if("function"!=typeof t)return null;if(this._funcMap.has(e)&&this._funcMap.get(e).has(t))return this._funcMap.get(e).get(t);this._funcMap.has(e)||this._funcMap.set(e,new Map);var n=null;return this._funcMap.get(e).has(t)?n=this._funcMap.get(e).get(t):(n=this._pack(e,t,o),this._funcMap.get(e).set(t,n)),n}},{key:"defenseOnce",value:function(e,t){var o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0;return"function"!=typeof t?null:this._pack(e,t,o)}},{key:"find",value:function(e,t){return"string"!=typeof e||0===e.length||"function"!=typeof t?null:this._funcMap.has(e)?this._funcMap.get(e).has(t)?this._funcMap.get(e).get(t):(we.log("SafetyCallback.find: 找不到 func —— ".concat(e,"/").concat(""!==t.name?t.name:"[anonymous]")),null):(we.log("SafetyCallback.find: 找不到 eventName-".concat(e," 对应的 func")),null)}},{key:"delete",value:function(e,t){return"function"==typeof t&&(!!this._funcMap.has(e)&&(!!this._funcMap.get(e).has(t)&&(this._funcMap.get(e).delete(t),0===this._funcMap.get(e).size&&this._funcMap.delete(e),!0)))}},{key:"_pack",value:function(e,t,o){return function(){try{t.apply(o,Array.from(arguments))}catch(r){var n=Object.values(S).indexOf(e);if(-1!==n){var a=Object.keys(S)[n];we.warn("接入侧事件 TIM.EVENT.".concat(a," 对应的回调函数逻辑存在问题,请检查!"),r)}var s=new va(ya.CALLBACK_FUNCTION_ERROR);s.setMessage("eventName:".concat(e)).setMoreMessage(r.message).end()}}}}]),e}(),xr=function(){function e(t){n(this,e);var o={SDKAppID:t.SDKAppID,unlimitedAVChatRoom:t.unlimitedAVChatRoom||!1,scene:t.scene||"",oversea:t.oversea||!1,instanceID:Ot(),devMode:t.devMode||!1,proxyServer:t.proxyServer||void 0};this._moduleManager=new Hr(o),this._safetyCallbackFactory=new Br}return s(e,[{key:"onError",value:function(e){this._moduleManager.onError(e)}},{key:"login",value:function(e){return this._moduleManager.login(),this._moduleManager.getModule(eo).login(e)}},{key:"logout",value:function(){var e=this;return this._moduleManager.getModule(eo).logout().then((function(t){return e._moduleManager.reset(),t}))}},{key:"isReady",value:function(){return this._moduleManager.isReady()}},{key:"getNotReadyReason",value:function(){return this._moduleManager.getNotReadyReason()}},{key:"destroy",value:function(){var e=this;return this.logout().finally((function(){e._moduleManager.stopTimer(),e._moduleManager.getModule(Eo).terminate(),e._moduleManager.getModule(vo).dealloc();var t=e._moduleManager.getOuterEmitterInstance(),o=e._moduleManager.getModule(uo);t.emit(S.SDK_DESTROY,{SDKAppID:o.getSDKAppID()})}))}},{key:"on",value:function(e,t,o){e===S.GROUP_SYSTEM_NOTICE_RECEIVED&&we.warn("!!!TIM.EVENT.GROUP_SYSTEM_NOTICE_RECEIVED v2.6.0起弃用,为了更好的体验,请在 TIM.EVENT.MESSAGE_RECEIVED 事件回调内接收处理群系统通知,详细请参考:https://web.sdk.qcloud.com/im/doc/zh-cn/Message.html#.GroupSystemNoticePayload"),we.debug("on","eventName:".concat(e)),this._moduleManager.getOuterEmitterInstance().on(e,this._safetyCallbackFactory.defense(e,t,o),o)}},{key:"once",value:function(e,t,o){we.debug("once","eventName:".concat(e)),this._moduleManager.getOuterEmitterInstance().once(e,this._safetyCallbackFactory.defenseOnce(e,t,o),o||this)}},{key:"off",value:function(e,t,o,n){we.debug("off","eventName:".concat(e));var a=this._safetyCallbackFactory.find(e,t);null!==a&&(this._moduleManager.getOuterEmitterInstance().off(e,a,o,n),this._safetyCallbackFactory.delete(e,t))}},{key:"registerPlugin",value:function(e){this._moduleManager.getModule(fo).registerPlugin(e)}},{key:"setLogLevel",value:function(e){if(e<=0){console.log([""," ________ ______ __ __ __ __ ________ _______","| \\| \\| \\ / \\| \\ _ | \\| \\| \\"," \\$$$$$$$$ \\$$$$$$| $$\\ / $$| $$ / \\ | $$| $$$$$$$$| $$$$$$$\\"," | $$ | $$ | $$$\\ / $$$| $$/ $\\| $$| $$__ | $$__/ $$"," | $$ | $$ | $$$$\\ $$$$| $$ $$$\\ $$| $$ \\ | $$ $$"," | $$ | $$ | $$\\$$ $$ $$| $$ $$\\$$\\$$| $$$$$ | $$$$$$$\\"," | $$ _| $$_ | $$ \\$$$| $$| $$$$ \\$$$$| $$_____ | $$__/ $$"," | $$ | $$ \\| $$ \\$ | $$| $$$ \\$$$| $$ \\| $$ $$"," \\$$ \\$$$$$$ \\$$ \\$$ \\$$ \\$$ \\$$$$$$$$ \\$$$$$$$","",""].join("\n")),console.log("%cIM 智能客服,随时随地解决您的问题 →_→ https://cloud.tencent.com/act/event/smarty-service?from=im-doc","color:#006eff"),console.log("%c从v2.11.2起,SDK 支持了 WebSocket,小程序需要添加受信域名!升级指引: https://web.sdk.qcloud.com/im/doc/zh-cn/tutorial-02-upgradeguideline.html","color:#ff0000");console.log(["","参考以下文档,会更快解决问题哦!(#^.^#)\n","SDK 更新日志: https://cloud.tencent.com/document/product/269/38492\n","SDK 接口文档: https://web.sdk.qcloud.com/im/doc/zh-cn/SDK.html\n","常见问题: https://web.sdk.qcloud.com/im/doc/zh-cn/tutorial-01-faq.html\n","反馈问题?戳我提 issue: https://github.com/tencentyun/TIMSDK/issues\n","如果您需要在生产环境关闭上面的日志,请 tim.setLogLevel(1)\n"].join("\n"))}we.setLevel(e)}},{key:"createTextMessage",value:function(e){return this._moduleManager.getModule(to).createTextMessage(e)}},{key:"createTextAtMessage",value:function(e){return this._moduleManager.getModule(to).createTextMessage(e)}},{key:"createImageMessage",value:function(e){return this._moduleManager.getModule(to).createImageMessage(e)}},{key:"createAudioMessage",value:function(e){return this._moduleManager.getModule(to).createAudioMessage(e)}},{key:"createVideoMessage",value:function(e){return this._moduleManager.getModule(to).createVideoMessage(e)}},{key:"createCustomMessage",value:function(e){return this._moduleManager.getModule(to).createCustomMessage(e)}},{key:"createFaceMessage",value:function(e){return this._moduleManager.getModule(to).createFaceMessage(e)}},{key:"createFileMessage",value:function(e){return this._moduleManager.getModule(to).createFileMessage(e)}},{key:"createLocationMessage",value:function(e){return this._moduleManager.getModule(to).createLocationMessage(e)}},{key:"createMergerMessage",value:function(e){return this._moduleManager.getModule(to).createMergerMessage(e)}},{key:"downloadMergerMessage",value:function(e){return e.type!==D.MSG_MERGER?ja(new Ba({code:na.MESSAGE_MERGER_TYPE_INVALID,message:aa.MESSAGE_MERGER_TYPE_INVALID})):Vt(e.payload.downloadKey)?ja(new Ba({code:na.MESSAGE_MERGER_KEY_INVALID,message:aa.MESSAGE_MERGER_KEY_INVALID})):this._moduleManager.getModule(to).downloadMergerMessage(e).catch((function(e){return ja(new Ba({code:na.MESSAGE_MERGER_DOWNLOAD_FAIL,message:aa.MESSAGE_MERGER_DOWNLOAD_FAIL}))}))}},{key:"createForwardMessage",value:function(e){return this._moduleManager.getModule(to).createForwardMessage(e)}},{key:"sendMessage",value:function(e,t){return e instanceof wa?this._moduleManager.getModule(to).sendMessageInstance(e,t):ja(new Ba({code:na.MESSAGE_SEND_NEED_MESSAGE_INSTANCE,message:aa.MESSAGE_SEND_NEED_MESSAGE_INSTANCE}))}},{key:"callExperimentalAPI",value:function(e,t){return"handleGroupInvitation"===e?this._moduleManager.getModule(ao).handleGroupInvitation(t):ja(new Ba({code:na.INVALID_OPERATION,message:aa.INVALID_OPERATION}))}},{key:"revokeMessage",value:function(e){return this._moduleManager.getModule(to).revokeMessage(e)}},{key:"resendMessage",value:function(e){return this._moduleManager.getModule(to).resendMessage(e)}},{key:"deleteMessage",value:function(e){return this._moduleManager.getModule(to).deleteMessage(e)}},{key:"modifyMessage",value:function(e){return this._moduleManager.getModule(to).modifyRemoteMessage(e)}},{key:"getMessageList",value:function(e){return this._moduleManager.getModule(co).getMessageList(e)}},{key:"getMessageListHopping",value:function(e){return this._moduleManager.getModule(co).getMessageListHopping(e)}},{key:"sendMessageReadReceipt",value:function(e){return this._moduleManager.getModule(co).sendReadReceipt(e)}},{key:"getMessageReadReceiptList",value:function(e){return this._moduleManager.getModule(co).getReadReceiptList(e)}},{key:"getGroupMessageReadMemberList",value:function(e){return this._moduleManager.getModule(ao).getReadReceiptDetail(e)}},{key:"findMessage",value:function(e){return this._moduleManager.getModule(co).findMessage(e)}},{key:"setMessageRead",value:function(e){return this._moduleManager.getModule(co).setMessageRead(e)}},{key:"getConversationList",value:function(e){return this._moduleManager.getModule(co).getConversationList(e)}},{key:"getConversationProfile",value:function(e){return this._moduleManager.getModule(co).getConversationProfile(e)}},{key:"deleteConversation",value:function(e){return this._moduleManager.getModule(co).deleteConversation(e)}},{key:"pinConversation",value:function(e){return this._moduleManager.getModule(co).pinConversation(e)}},{key:"setAllMessageRead",value:function(e){return this._moduleManager.getModule(co).setAllMessageRead(e)}},{key:"setMessageRemindType",value:function(e){return this._moduleManager.getModule(co).setMessageRemindType(e)}},{key:"getMyProfile",value:function(){return this._moduleManager.getModule(oo).getMyProfile()}},{key:"getUserProfile",value:function(e){return this._moduleManager.getModule(oo).getUserProfile(e)}},{key:"updateMyProfile",value:function(e){return this._moduleManager.getModule(oo).updateMyProfile(e)}},{key:"getBlacklist",value:function(){return this._moduleManager.getModule(oo).getLocalBlacklist()}},{key:"addToBlacklist",value:function(e){return this._moduleManager.getModule(oo).addBlacklist(e)}},{key:"removeFromBlacklist",value:function(e){return this._moduleManager.getModule(oo).deleteBlacklist(e)}},{key:"getFriendList",value:function(){var e=this._moduleManager.getModule(so);return e?e.getLocalFriendList():ja({code:na.CANNOT_FIND_MODULE,message:aa.CANNOT_FIND_MODULE})}},{key:"addFriend",value:function(e){var t=this._moduleManager.getModule(so);return t?t.addFriend(e):ja({code:na.CANNOT_FIND_MODULE,message:aa.CANNOT_FIND_MODULE})}},{key:"deleteFriend",value:function(e){var t=this._moduleManager.getModule(so);return t?t.deleteFriend(e):ja({code:na.CANNOT_FIND_MODULE,message:aa.CANNOT_FIND_MODULE})}},{key:"checkFriend",value:function(e){var t=this._moduleManager.getModule(so);return t?t.checkFriend(e):ja({code:na.CANNOT_FIND_MODULE,message:aa.CANNOT_FIND_MODULE})}},{key:"getFriendProfile",value:function(e){var t=this._moduleManager.getModule(so);return t?t.getFriendProfile(e):ja({code:na.CANNOT_FIND_MODULE,message:aa.CANNOT_FIND_MODULE})}},{key:"updateFriend",value:function(e){var t=this._moduleManager.getModule(so);return t?t.updateFriend(e):ja({code:na.CANNOT_FIND_MODULE,message:aa.CANNOT_FIND_MODULE})}},{key:"getFriendApplicationList",value:function(){var e=this._moduleManager.getModule(so);return e?e.getLocalFriendApplicationList():ja({code:na.CANNOT_FIND_MODULE,message:aa.CANNOT_FIND_MODULE})}},{key:"acceptFriendApplication",value:function(e){var t=this._moduleManager.getModule(so);return t?t.acceptFriendApplication(e):ja({code:na.CANNOT_FIND_MODULE,message:aa.CANNOT_FIND_MODULE})}},{key:"refuseFriendApplication",value:function(e){var t=this._moduleManager.getModule(so);return t?t.refuseFriendApplication(e):ja({code:na.CANNOT_FIND_MODULE,message:aa.CANNOT_FIND_MODULE})}},{key:"deleteFriendApplication",value:function(e){var t=this._moduleManager.getModule(so);return t?t.deleteFriendApplication(e):ja({code:na.CANNOT_FIND_MODULE,message:aa.CANNOT_FIND_MODULE})}},{key:"setFriendApplicationRead",value:function(){var e=this._moduleManager.getModule(so);return e?e.setFriendApplicationRead():ja({code:na.CANNOT_FIND_MODULE,message:aa.CANNOT_FIND_MODULE})}},{key:"getFriendGroupList",value:function(){var e=this._moduleManager.getModule(so);return e?e.getLocalFriendGroupList():ja({code:na.CANNOT_FIND_MODULE,message:aa.CANNOT_FIND_MODULE})}},{key:"createFriendGroup",value:function(e){var t=this._moduleManager.getModule(so);return t?t.createFriendGroup(e):ja({code:na.CANNOT_FIND_MODULE,message:aa.CANNOT_FIND_MODULE})}},{key:"deleteFriendGroup",value:function(e){var t=this._moduleManager.getModule(so);return t?t.deleteFriendGroup(e):ja({code:na.CANNOT_FIND_MODULE,message:aa.CANNOT_FIND_MODULE})}},{key:"addToFriendGroup",value:function(e){var t=this._moduleManager.getModule(so);return t?t.addToFriendGroup(e):ja({code:na.CANNOT_FIND_MODULE,message:aa.CANNOT_FIND_MODULE})}},{key:"removeFromFriendGroup",value:function(e){var t=this._moduleManager.getModule(so);return t?t.removeFromFriendGroup(e):ja({code:na.CANNOT_FIND_MODULE,message:aa.CANNOT_FIND_MODULE})}},{key:"renameFriendGroup",value:function(e){var t=this._moduleManager.getModule(so);return t?t.renameFriendGroup(e):ja({code:na.CANNOT_FIND_MODULE,message:aa.CANNOT_FIND_MODULE})}},{key:"getGroupList",value:function(e){return this._moduleManager.getModule(ao).getGroupList(e)}},{key:"getGroupProfile",value:function(e){return this._moduleManager.getModule(ao).getGroupProfile(e)}},{key:"createGroup",value:function(e){return this._moduleManager.getModule(ao).createGroup(e)}},{key:"dismissGroup",value:function(e){return this._moduleManager.getModule(ao).dismissGroup(e)}},{key:"updateGroupProfile",value:function(e){return this._moduleManager.getModule(ao).updateGroupProfile(e)}},{key:"joinGroup",value:function(e){return this._moduleManager.getModule(ao).joinGroup(e)}},{key:"quitGroup",value:function(e){return this._moduleManager.getModule(ao).quitGroup(e)}},{key:"searchGroupByID",value:function(e){return this._moduleManager.getModule(ao).searchGroupByID(e)}},{key:"getGroupOnlineMemberCount",value:function(e){return this._moduleManager.getModule(ao).getGroupOnlineMemberCount(e)}},{key:"changeGroupOwner",value:function(e){return this._moduleManager.getModule(ao).changeGroupOwner(e)}},{key:"handleGroupApplication",value:function(e){return this._moduleManager.getModule(ao).handleGroupApplication(e)}},{key:"initGroupAttributes",value:function(e){return this._moduleManager.getModule(ao).initGroupAttributes(e)}},{key:"setGroupAttributes",value:function(e){return this._moduleManager.getModule(ao).setGroupAttributes(e)}},{key:"deleteGroupAttributes",value:function(e){return this._moduleManager.getModule(ao).deleteGroupAttributes(e)}},{key:"getGroupAttributes",value:function(e){return this._moduleManager.getModule(ao).getGroupAttributes(e)}},{key:"getGroupMemberList",value:function(e){return this._moduleManager.getModule(ro).getGroupMemberList(e)}},{key:"getGroupMemberProfile",value:function(e){return this._moduleManager.getModule(ro).getGroupMemberProfile(e)}},{key:"addGroupMember",value:function(e){return this._moduleManager.getModule(ro).addGroupMember(e)}},{key:"deleteGroupMember",value:function(e){return this._moduleManager.getModule(ro).deleteGroupMember(e)}},{key:"setGroupMemberMuteTime",value:function(e){return this._moduleManager.getModule(ro).setGroupMemberMuteTime(e)}},{key:"setGroupMemberRole",value:function(e){return this._moduleManager.getModule(ro).setGroupMemberRole(e)}},{key:"setGroupMemberNameCard",value:function(e){return this._moduleManager.getModule(ro).setGroupMemberNameCard(e)}},{key:"setGroupMemberCustomField",value:function(e){return this._moduleManager.getModule(ro).setGroupMemberCustomField(e)}},{key:"getJoinedCommunityList",value:function(){return this._moduleManager.getModule(io).getJoinedCommunityList()}},{key:"createTopicInCommunity",value:function(e){return this._moduleManager.getModule(io).createTopicInCommunity(e)}},{key:"deleteTopicFromCommunity",value:function(e){return this._moduleManager.getModule(io).deleteTopicFromCommunity(e)}},{key:"updateTopicProfile",value:function(e){return this._moduleManager.getModule(io).updateTopicProfile(e)}},{key:"getTopicList",value:function(e){return this._moduleManager.getModule(io).getTopicList(e)}}]),e}(),Wr={login:"login",logout:"logout",destroy:"destroy",on:"on",off:"off",ready:"ready",setLogLevel:"setLogLevel",joinGroup:"joinGroup",quitGroup:"quitGroup",registerPlugin:"registerPlugin",getGroupOnlineMemberCount:"getGroupOnlineMemberCount"};function Yr(e,t){if(e.isReady()||void 0!==Wr[t])return!0;var o=e.getNotReadyReason(),n="";Object.getOwnPropertyNames(na).forEach((function(e){na[e]===o&&(n=aa[e])}));var a={code:o,message:"".concat(n,"导致 sdk not ready。").concat(t," ").concat(aa.SDK_IS_NOT_READY,",请参考 https://web.sdk.qcloud.com/im/doc/zh-cn/module-EVENT.html#.SDK_READY")};return e.onError(a),a}var jr={},$r={};return $r.create=function(e){var o=0;if($e(e.SDKAppID))o=e.SDKAppID;else if(we.warn("TIM.create SDKAppID 的类型应该为 Number,请修改!"),o=parseInt(e.SDKAppID),isNaN(o))return we.error("TIM.create failed. 解析 SDKAppID 失败,请检查传参!"),null;if(o&&jr[o])return jr[o];we.log("TIM.create");var n=new xr(t(t({},e),{},{SDKAppID:o}));n.on(S.SDK_DESTROY,(function(e){jr[e.data.SDKAppID]=null,delete jr[e.data.SDKAppID]}));var a=function(e){var t=Object.create(null);return Object.keys(Zt).forEach((function(o){if(e[o]){var n=Zt[o],a=new N;t[n]=function(){var t=Array.from(arguments);return a.use((function(t,n){var a=Yr(e,o);return!0===a?n():ja(a)})).use((function(e,t){if(!0===Kt(e,Qt[o],n))return t()})).use((function(t,n){return e[o].apply(e,t)})),a.run(t)}}})),t}(n);return jr[o]=a,we.log("TIM.create ok"),a},$r.TYPES=D,$r.EVENT=S,$r.VERSION="2.20.1",we.log("TIM.VERSION: ".concat($r.VERSION)),$r})); diff --git a/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/TRTCCalling/node_module/trtc-wx.js b/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/TRTCCalling/node_module/trtc-wx.js index 3fba0729ee..5d077a63fa 100644 --- a/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/TRTCCalling/node_module/trtc-wx.js +++ b/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/TRTCCalling/node_module/trtc-wx.js @@ -1,331 +1,2 @@ -!(function (e, t) { - 'object' === typeof exports && 'undefined' !== typeof module ? module.exports = t() : 'function' === typeof define && define.amd ? define(t) : (e = 'undefined' !== typeof globalThis ? globalThis : e || self).TRTC = t(); -}(this, (() => { - 'use strict';function e(e, t) { - if (!(e instanceof t)) throw new TypeError('Cannot call a class as a function'); - } function t(e, t) { - for (let r = 0;r < t.length;r++) { - const s = t[r];s.enumerable = s.enumerable || !1, s.configurable = !0, 'value' in s && (s.writable = !0), Object.defineProperty(e, s.key, s); - } - } function r(e, r, s) { - return r && t(e.prototype, r), s && t(e, s), e; - } function s(e, t, r) { - return t in e ? Object.defineProperty(e, t, { value: r, enumerable: !0, configurable: !0, writable: !0 }) : e[t] = r, e; - } function i(e, t) { - const r = Object.keys(e);if (Object.getOwnPropertySymbols) { - let s = Object.getOwnPropertySymbols(e);t && (s = s.filter((t => Object.getOwnPropertyDescriptor(e, t).enumerable))), r.push.apply(r, s); - } return r; - } function a(e) { - for (let t = 1;t < arguments.length;t++) { - var r = null != arguments[t] ? arguments[t] : {};t % 2 ? i(Object(r), !0).forEach(((t) => { - s(e, t, r[t]); - })) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(r)) : i(Object(r)).forEach(((t) => { - Object.defineProperty(e, t, Object.getOwnPropertyDescriptor(r, t)); - })); - } return e; - } function n() { - const e = (new Date).getTime(); const t = new Date(e); let r = t.getHours(); let s = t.getMinutes(); let i = t.getSeconds(); const a = t.getMilliseconds();return r = r < 10 ? '0'.concat(r) : r, s = s < 10 ? '0'.concat(s) : s, i = i < 10 ? '0'.concat(i) : i, ''.concat(r, ':').concat(s, ':') - .concat(i, '.') - .concat(a); - } const o = 'TRTC-WX'; const u = 0; const c = 1; const l = new (function () { - function t() { - e(this, t), this.logLevel = 0; - } return r(t, [{ key: 'setLogLevel', value(e) { - this.logLevel = e; - } }, { key: 'log', value() { - let e;this.logLevel === u && (e = console).log.apply(e, [o, n()].concat(Array.prototype.slice.call(arguments))); - } }, { key: 'warn', value() { - let e;this.logLevel <= c && (e = console).warn.apply(e, [o, n()].concat(Array.prototype.slice.call(arguments))); - } }, { key: 'error', value() { - let e;(e = console).error.apply(e, [o, n()].concat(Array.prototype.slice.call(arguments))); - } }]), t; - }());const h = function (e) { - const t = /[\u4e00-\u9fa5]/;return e.sdkAppID ? void 0 === e.roomID && void 0 === e.strRoomID ? (l.error('未设置 roomID'), !1) : !e.strRoomID && (e.roomID < 1 || e.roomID > 4294967296) ? (l.error('roomID 超出取值范围 1 ~ 4294967295'), !1) : e.strRoomID && t.test(e.strRoomID) ? (l.error('strRoomID 请勿使用中文字符'), !1) : e.userID ? e.userID && t.test(e.userID) ? (l.error('userID 请勿使用中文字符'), !1) : !!e.userSig || (l.error('未设置 userSig'), !1) : (l.error('未设置 userID'), !1) : (l.error('未设置 sdkAppID'), !1); - }; const p = { LOCAL_JOIN: 'LOCAL_JOIN', LOCAL_LEAVE: 'LOCAL_LEAVE', KICKED_OUT: 'KICKED_OUT', REMOTE_USER_JOIN: 'REMOTE_USER_JOIN', REMOTE_USER_LEAVE: 'REMOTE_USER_LEAVE', REMOTE_VIDEO_ADD: 'REMOTE_VIDEO_ADD', REMOTE_VIDEO_REMOVE: 'REMOTE_VIDEO_REMOVE', REMOTE_AUDIO_ADD: 'REMOTE_AUDIO_ADD', REMOTE_AUDIO_REMOVE: 'REMOTE_AUDIO_REMOVE', REMOTE_STATE_UPDATE: 'REMOTE_STATE_UPDATE', LOCAL_NET_STATE_UPDATE: 'LOCAL_NET_STATE_UPDATE', REMOTE_NET_STATE_UPDATE: 'REMOTE_NET_STATE_UPDATE', LOCAL_AUDIO_VOLUME_UPDATE: 'LOCAL_AUDIO_VOLUME_UPDATE', REMOTE_AUDIO_VOLUME_UPDATE: 'REMOTE_AUDIO_VOLUME_UPDATE', VIDEO_FULLSCREEN_UPDATE: 'VIDEO_FULLSCREEN_UPDATE', BGM_PLAY_START: 'BGM_PLAY_START', BGM_PLAY_FAIL: 'BGM_PLAY_FAIL', BGM_PLAY_PROGRESS: 'BGM_PLAY_PROGRESS', BGM_PLAY_COMPLETE: 'BGM_PLAY_COMPLETE', ERROR: 'ERROR', IM_READY: 'IM_READY', IM_MESSAGE_RECEIVED: 'IM_MESSAGE_RECEIVED', IM_NOT_READY: 'IM_NOT_READY', IM_KICKED_OUT: 'IM_KICKED_OUT', IM_ERROR: 'IM_ERROR' }; const m = { url: '', mode: 'RTC', autopush: !1, enableCamera: !1, enableMic: !1, enableAgc: !1, enableAns: !1, enableEarMonitor: !1, enableAutoFocus: !0, enableZoom: !1, minBitrate: 600, maxBitrate: 900, videoWidth: 360, videoHeight: 640, beautyLevel: 0, whitenessLevel: 0, videoOrientation: 'vertical', videoAspect: '9:16', frontCamera: 'front', enableRemoteMirror: !1, localMirror: 'auto', enableBackgroundMute: !1, audioQuality: 'high', audioVolumeType: 'voicecall', audioReverbType: 0, waitingImage: 'https://mc.qcloudimg.com/static/img/daeed8616ac5df256c0591c22a65c4d3/pause_publish.jpg', waitingImageHash: '', beautyStyle: 'smooth', filter: '', netStatus: {} }; const f = { src: '', mode: 'RTC', autoplay: !0, muteAudio: !0, muteVideo: !0, orientation: 'vertical', objectFit: 'fillCrop', enableBackgroundMute: !1, minCache: 1, maxCache: 2, soundMode: 'speaker', enableRecvMessage: !1, autoPauseIfNavigate: !0, autoPauseIfOpenNative: !0, isVisible: !0, _definitionType: 'main', netStatus: {} };(new Date).getTime();function d() { - const e = new Date;return e.setTime((new Date).getTime() + 0), e.toLocaleString(); - } function v(e) { - const t = this; let r = []; let s = [];this.length = function () { - return r.length; - }, this.sent = function () { - return s.length; - }, this.push = function (t) { - r.push(t), r.length > e && r.shift(); - }, this.send = function () { - return s.length || (s = r, r = []), s; - }, this.confirm = function () { - s = [], t.content = ''; - }, this.fail = function () { - r = s.concat(r), t.confirm();const i = 1 + r.length + s.length - e;i > 0 && (s.splice(0, i), r = s.concat(r), t.confirm()); - }; - } const g = new (function () { - function t() { - e(this, t), this.sdkAppId = '', this.userId = '', this.version = '', this.queue = new v(20); - } return r(t, [{ key: 'setConfig', value(e) { - this.sdkAppId = ''.concat(e.sdkAppId), this.userId = ''.concat(e.userId), this.version = ''.concat(e.version); - } }, { key: 'push', value(e) { - this.queue.push(e); - } }, { key: 'log', value(e) { - wx.request({ url: 'https://yun.tim.qq.com/v5/AVQualityReportSvc/C2S?sdkappid=1&cmdtype=jssdk_log', method: 'POST', header: { 'content-type': 'application/json' }, data: { timestamp: d(), sdkAppId: this.sdkAppId, userId: this.userId, version: this.version, log: e } }); - } }, { key: 'send', value() { - const e = this;if (!this.queue.sent()) { - if (!this.queue.length()) return;const t = this.queue.send();this.queue.content = 'string' !== typeof log ? '{"logs":['.concat(t.join(','), ']}') : t.join('\n'), wx.request({ url: 'https://yun.tim.qq.com/v5/AVQualityReportSvc/C2S?sdkappid=1&cmdtype=jssdk_log', method: 'POST', header: { 'content-type': 'application/json' }, data: { timestamp: d(), sdkAppId: this.sdkAppId, userId: this.userId, version: this.version, log: this.queue.content }, success() { - e.queue.confirm(); - }, fail() { - e.queue.fail(); - } }); - } - } }]), t; - }()); const y = (function () { - function t(r, s) { - e(this, t), this.context = wx.createLivePusherContext(s), this.pusherAttributes = {}, Object.assign(this.pusherAttributes, m, r); - } return r(t, [{ key: 'setPusherAttributes', value(e) { - return Object.assign(this.pusherAttributes, e), this.pusherAttributes; - } }, { key: 'start', value(e) { - l.log('[apiLog][pusherStart]'), g.log('pusherStart'), this.context.start(e); - } }, { key: 'stop', value(e) { - l.log('[apiLog][pusherStop]'), g.log('pusherStop'), this.context.stop(e); - } }, { key: 'pause', value(e) { - l.log('[apiLog] pusherPause()'), g.log('pusherPause'), this.context.pause(e); - } }, { key: 'resume', value(e) { - l.log('[apiLog][pusherResume]'), g.log('pusherResume'), this.context.resume(e); - } }, { key: 'switchCamera', value(e) { - return l.log('[apiLog][switchCamera]'), this.pusherAttributes.frontCamera = 'front' === this.pusherAttributes.frontCamera ? 'back' : 'front', this.context.switchCamera(e), this.pusherAttributes; - } }, { key: 'sendMessage', value(e) { - l.log('[apiLog][sendMessage]', e.msg), this.context.sendMessage(e); - } }, { key: 'snapshot', value() { - const e = this;return l.log('[apiLog][pusherSnapshot]'), new Promise(((t, r) => { - e.context.snapshot({ quality: 'raw', complete(e) { - e.tempImagePath ? (wx.saveImageToPhotosAlbum({ filePath: e.tempImagePath, success(r) { - t(e); - }, fail(e) { - l.error('[error] pusher截图失败: ', e), r(new Error('截图失败')); - } }), t(e)) : (l.error('[error] snapShot 回调失败', e), r(new Error('截图失败'))); - } }); - })); - } }, { key: 'toggleTorch', value(e) { - this.context.toggleTorch(e); - } }, { key: 'startDumpAudio', value(e) { - this.context.startDumpAudio(e); - } }, { key: 'stopDumpAudio', value(e) { - this.context.startDumpAudio(e); - } }, { key: 'playBGM', value(e) { - l.log('[apiLog] playBGM() url: ', e.url), this.context.playBGM(e); - } }, { key: 'pauseBGM', value(e) { - l.log('[apiLog] pauseBGM()'), this.context.pauseBGM(e); - } }, { key: 'resumeBGM', value(e) { - l.log('[apiLog] resumeBGM()'), this.context.resumeBGM(e); - } }, { key: 'stopBGM', value(e) { - l.log('[apiLog] stopBGM()'), this.context.stopBGM(e); - } }, { key: 'setBGMVolume', value(e) { - l.log('[apiLog] setBGMVolume() volume:', e.volume), this.context.setBGMVolume(e.volume); - } }, { key: 'setMICVolume', value(e) { - l.log('[apiLog] setMICVolume() volume:', e.volume), this.context.setMICVolume(e.volume); - } }, { key: 'startPreview', value(e) { - l.log('[apiLog] startPreview()'), this.context.startPreview(e); - } }, { key: 'stopPreview', value(e) { - l.log('[apiLog] stopPreview()'), this.context.stopPreview(e); - } }, { key: 'reset', value() { - return console.log('Pusher reset', this.context), this.pusherConfig = {}, this.context && (this.stop({ success() { - console.log('Pusher context.stop()'); - } }), this.context = null), this.pusherAttributes; - } }]), t; - }()); const E = function t(r) { - e(this, t), Object.assign(this, { userID: '', streams: {} }, r); - }; const A = (function () { - function t(r, s) { - e(this, t), this.ctx = s, this.playerAttributes = {}, Object.assign(this.playerAttributes, f, { userID: '', streamType: '', streamID: '', id: '', hasVideo: !1, hasAudio: !1, volume: 0, playerContext: void 0 }, r); - } return r(t, [{ key: 'play', value(e) { - this.getPlayerContext().play(e); - } }, { key: 'stop', value(e) { - this.getPlayerContext().stop(e); - } }, { key: 'mute', value(e) { - this.getPlayerContext().mute(e); - } }, { key: 'pause', value(e) { - this.getPlayerContext().pause(e); - } }, { key: 'resume', value(e) { - this.getPlayerContext().resume(e); - } }, { key: 'requestFullScreen', value(e) { - const t = this;return new Promise(((r, s) => { - t.getPlayerContext().requestFullScreen({ direction: e.direction, success(e) { - r(e); - }, fail(e) { - s(e); - } }); - })); - } }, { key: 'requestExitFullScreen', value() { - const e = this;return new Promise(((t, r) => { - e.getPlayerContext().exitFullScreen({ success(e) { - t(e); - }, fail(e) { - r(e); - } }); - })); - } }, { key: 'snapshot', value(e) { - const t = this;return l.log('[playerSnapshot]', e), new Promise(((e, r) => { - t.getPlayerContext().snapshot({ quality: 'raw', complete(t) { - t.tempImagePath ? (wx.saveImageToPhotosAlbum({ filePath: t.tempImagePath, success(r) { - l.log('save photo is success', r), e(t); - }, fail(e) { - l.error('save photo is fail', e), r(e); - } }), e(t)) : (l.error('snapShot 回调失败', t), r(new Error('截图失败'))); - } }); - })); - } }, { key: 'setPlayerAttributes', value(e) { - Object.assign(this.playerAttributes, e); - } }, { key: 'getPlayerContext', value() { - return this.playerContext || (this.playerContext = wx.createLivePlayerContext(this.playerAttributes.id, this.ctx)), this.playerContext; - } }, { key: 'reset', value() { - this.playerContext && (this.playerContext.stop(), this.playerContext = void 0), Object.assign(this.playerAttributes, f, { userID: '', streamType: '', streamID: '', hasVideo: !1, hasAudio: !1, volume: 0, playerContext: void 0 }); - } }]), t; - }()); const _ = 'UserController'; const I = (function () { - function t(r, s) { - e(this, t), this.ctx = s, this.userMap = new Map, this.userList = [], this.streamList = [], this.emitter = r; - } return r(t, [{ key: 'userEventHandler', value(e) { - const t = e.detail.code; const r = e.detail.message;switch (t) { - case 0:l.log(r, t);break;case 1001:l.log('已经连接推流服务器', t);break;case 1002:l.log('已经与服务器握手完毕,开始推流', t);break;case 1003:l.log('打开摄像头成功', t);break;case 1004:l.log('录屏启动成功', t);break;case 1005:l.log('推流动态调整分辨率', t);break;case 1006:l.log('推流动态调整码率', t);break;case 1007:l.log('首帧画面采集完成', t);break;case 1008:l.log('编码器启动', t);break;case 1018:l.log('进房成功', t), g.log('event enterRoom success '.concat(t)), this.emitter.emit(p.LOCAL_JOIN);break;case 1019:l.log('退出房间', t), r.indexOf('reason[0]') > -1 ? g.log('event exitRoom '.concat(t)) : (g.log('event abnormal exitRoom '.concat(r)), this.emitter.emit(p.KICKED_OUT));break;case 2003:l.log('渲染首帧视频', t);break;case -1301:l.error('打开摄像头失败: ', t), g.log('event start camera failed: '.concat(t)), this.emitter.emit(p.ERROR, { code: t, message: r });break;case -1302:l.error('打开麦克风失败: ', t), g.log('event start microphone failed: '.concat(t)), this.emitter.emit(p.ERROR, { code: t, message: r });break;case -1303:l.error('视频编码失败: ', t), g.log('event video encode failed: '.concat(t)), this.emitter.emit(p.ERROR, { code: t, message: r });break;case -1304:l.error('音频编码失败: ', t), g.log('event audio encode failed: '.concat(t)), this.emitter.emit(p.ERROR, { code: t, message: r });break;case -1307:l.error('推流连接断开: ', t), this.emitter.emit(p.ERROR, { code: t, message: r });break;case -100018:l.error('进房失败: userSig 校验失败,请检查 userSig 是否填写正确', t, r), this.emitter.emit(p.ERROR, { code: t, message: r });break;case 5e3:l.log('小程序被挂起: ', t), g.log('小程序被挂起: 5000');break;case 5001:l.log('小程序悬浮窗被关闭: ', t);break;case 1021:l.log('网络类型发生变化,需要重新进房', t);break;case 2007:l.log('本地视频播放loading: ', t);break;case 2004:l.log('本地视频播放开始: ', t);break;case 1031:case 1032:case 1033:case 1034:this._handleUserEvent(e); - } - } }, { key: '_handleUserEvent', value(e) { - let t; const r = e.detail.code; const s = e.detail.message;if (!e.detail.message || 'string' !== typeof s) return l.warn(_, 'userEventHandler 数据格式错误'), !1;try { - t = JSON.parse(e.detail.message); - } catch (e) { - return l.warn(_, 'userEventHandler 数据格式错误', e), !1; - } switch (this.emitter.emit(p.LOCAL_STATE_UPDATE, e), g.log('event code: '.concat(r, ', data: ').concat(JSON.stringify(t))), r) { - case 1031:this.addUser(t);break;case 1032:this.removeUser(t);break;case 1033:this.updateUserVideo(t);break;case 1034:this.updateUserAudio(t); - } - } }, { key: 'addUser', value(e) { - const t = this;l.log('addUser', e);const r = e.userlist;Array.isArray(r) && r.length > 0 && r.forEach(((e) => { - const r = e.userid; let s = t.getUser(r);s || (s = new E({ userID: r }), t.userList.push({ userID: r })), t.userMap.set(r, s), t.emitter.emit(p.REMOTE_USER_JOIN, { userID: r, userList: t.userList, playerList: t.getPlayerList() }); - })); - } }, { key: 'removeUser', value(e) { - const t = this; const r = e.userlist;Array.isArray(r) && r.length > 0 && r.forEach(((e) => { - const r = e.userid; let s = t.getUser(r);s && s.streams && (t._removeUserAndStream(r), s.streams.main && s.streams.main.reset(), s.streams.aux && s.streams.aux.reset(), t.emitter.emit(p.REMOTE_USER_LEAVE, { userID: r, userList: t.userList, playerList: t.getPlayerList() }), s = void 0, t.userMap.delete(r)); - })); - } }, { key: 'updateUserVideo', value(e) { - const t = this;l.log(_, 'updateUserVideo', e);const r = e.userlist;Array.isArray(r) && r.length > 0 && r.forEach(((e) => { - const r = e.userid; const s = e.streamtype; const i = ''.concat(r, '_').concat(s); const a = i; const n = e.hasvideo; const o = e.playurl; const u = t.getUser(r);if (u) { - let c = u.streams[s];l.log(_, 'updateUserVideo start', u, s, c), c ? (c.setPlayerAttributes({ hasVideo: n }), n || c.playerAttributes.hasAudio || t._removeStream(c)) : (c = new A({ userID: r, streamID: i, hasVideo: n, src: o, streamType: s, id: a }, t.ctx), u.streams[s] = c, t._addStream(c)), 'aux' === s && (n ? (c.objectFit = 'contain', t._addStream(c)) : t._removeStream(c)), t.userList.find(((e) => { - if (e.userID === r) return e['has'.concat(s.replace(/^\S/, (e => e.toUpperCase())), 'Video')] = n, !0; - })), l.log(_, 'updateUserVideo end', u, s, c);const h = n ? p.REMOTE_VIDEO_ADD : p.REMOTE_VIDEO_REMOVE;t.emitter.emit(h, { player: c.playerAttributes, userList: t.userList, playerList: t.getPlayerList() }); - } - })); - } }, { key: 'updateUserAudio', value(e) { - const t = this; const r = e.userlist;Array.isArray(r) && r.length > 0 && r.forEach(((e) => { - const r = e.userid; const s = 'main'; const i = ''.concat(r, '_').concat(s); const a = i; const n = e.hasaudio; const o = e.playurl; const u = t.getUser(r);if (u) { - let c = u.streams.main;c ? (c.setPlayerAttributes({ hasAudio: n }), n || c.playerAttributes.hasVideo || t._removeStream(c)) : (c = new A({ userID: r, streamID: i, hasAudio: n, src: o, streamType: s, id: a }, t.ctx), u.streams.main = c, t._addStream(c)), t.userList.find(((e) => { - if (e.userID === r) return e['has'.concat(s.replace(/^\S/, (e => e.toUpperCase())), 'Audio')] = n, !0; - }));const l = n ? p.REMOTE_AUDIO_ADD : p.REMOTE_AUDIO_REMOVE;t.emitter.emit(l, { player: c.playerAttributes, userList: t.userList, playerList: t.getPlayerList() }); - } - })); - } }, { key: 'getUser', value(e) { - return this.userMap.get(e); - } }, { key: 'getStream', value(e) { - const t = e.userID; const r = e.streamType; const s = this.userMap.get(t);if (s) return s.streams[r]; - } }, { key: 'getUserList', value() { - return this.userList; - } }, { key: 'getStreamList', value() { - return this.streamList; - } }, { key: 'getPlayerList', value() { - for (var e = this.getStreamList(), t = [], r = 0;r < e.length;r++)t.push(e[r].playerAttributes);return t; - } }, { key: 'reset', value() { - return this.streamList.forEach(((e) => { - e.reset(); - })), this.streamList = [], this.userList = [], this.userMap.clear(), { userList: this.userList, streamList: this.streamList }; - } }, { key: '_removeUserAndStream', value(e) { - this.streamList = this.streamList.filter((t => t.playerAttributes.userID !== e && '' !== t.playerAttributes.userID)), this.userList = this.userList.filter((t => t.userID !== e)); - } }, { key: '_addStream', value(e) { - this.streamList.includes(e) || this.streamList.push(e); - } }, { key: '_removeStream', value(e) { - this.streamList = this.streamList.filter((t => t.playerAttributes.userID !== e.playerAttributes.userID || t.playerAttributes.streamType !== e.playerAttributes.streamType)), this.getUser(e.playerAttributes.userID).streams[e.playerAttributes.streamType] = void 0; - } }]), t; - }()); const L = (function () { - function t() { - e(this, t); - } return r(t, [{ key: 'on', value(e, t, r) { - 'function' === typeof t ? (this._stores = this._stores || {}, (this._stores[e] = this._stores[e] || []).push({ cb: t, ctx: r })) : console.error('listener must be a function'); - } }, { key: 'emit', value(e) { - this._stores = this._stores || {};let t; let r = this._stores[e];if (r) { - r = r.slice(0), (t = [].slice.call(arguments, 1))[0] = { eventCode: e, data: t[0] };for (let s = 0, i = r.length;s < i;s++)r[s].cb.apply(r[s].ctx, t); - } - } }, { key: 'off', value(e, t) { - if (this._stores = this._stores || {}, arguments.length) { - const r = this._stores[e];if (r) if (1 !== arguments.length) { - for (let s = 0, i = r.length;s < i;s++) if (r[s].cb === t) { - r.splice(s, 1);break; - } - } else delete this._stores[e]; - } else this._stores = {}; - } }]), t; - }());return (function () { - function t(r, s) { - const i = this;e(this, t), this.ctx = r, this.eventEmitter = new L, this.pusherInstance = null, this.userController = new I(this.eventEmitter, this.ctx), this.EVENT = p, 'test' !== s ? wx.getSystemInfo({ success(e) { - return i.systemInfo = e; - } }) : (g.log = function () {}, l.log = function () {}, l.warn = function () {}); - } return r(t, [{ key: 'on', value(e, t, r) { - l.log('[on] 事件订阅: '.concat(e)), this.eventEmitter.on(e, t, r); - } }, { key: 'off', value(e, t) { - l.log('[off] 取消订阅: '.concat(e)), this.eventEmitter.off(e, t); - } }, { key: 'createPusher', value(e) { - return this.pusherInstance = new y(e, this.ctx), console.log('pusherInstance', this.pusherInstance), this.pusherInstance; - } }, { key: 'getPusherInstance', value() { - return this.pusherInstance; - } }, { key: 'enterRoom', value(e) { - l.log('[apiLog] [enterRoom]', e);const t = (function (e) { - if (!h(e)) return null;e.scene = e.scene && 'rtc' !== e.scene ? e.scene : 'videocall', e.enableBlackStream = e.enableBlackStream || '', e.encsmall = e.encsmall || 0, e.cloudenv = e.cloudenv || 'PRO', e.streamID = e.streamID || '', e.userDefineRecordID = e.userDefineRecordID || '', e.privateMapKey = e.privateMapKey || '', e.pureAudioMode = e.pureAudioMode || '', e.recvMode = e.recvMode || 1;let t = '';return t = e.strRoomID ? '&strroomid='.concat(e.strRoomID) : '&roomid='.concat(e.roomID), 'room://cloud.tencent.com/rtc?sdkappid='.concat(e.sdkAppID).concat(t, '&userid=') - .concat(e.userID, '&usersig=') - .concat(e.userSig, '&appscene=') - .concat(e.scene, '&encsmall=') - .concat(e.encsmall, '&cloudenv=') - .concat(e.cloudenv, '&enableBlackStream=') - .concat(e.enableBlackStream, '&streamid=') - .concat(e.streamID, '&userdefinerecordid=') - .concat(e.userDefineRecordID, '&privatemapkey=') - .concat(e.privateMapKey, '&pureaudiomode=') - .concat(e.pureAudioMode, '&recvmode=') - .concat(e.recvMode); - }(e));return t || this.eventEmitter.emit(p.ERROR, { message: '进房参数错误' }), g.setConfig({ sdkAppId: e.sdkAppID, userId: e.userID, version: 'wechat-mini' }), this.pusherInstance.setPusherAttributes(a(a({}, e), {}, { url: t })), l.warn('[statusLog] [enterRoom]', this.pusherInstance.pusherAttributes), g.log('api-enterRoom'), g.log('pusherConfig: '.concat(JSON.stringify(this.pusherInstance.pusherAttributes))), this.getPusherAttributes(); - } }, { key: 'exitRoom', value() { - g.log('api-exitRoom'), this.userController.reset();const e = Object.assign({ pusher: this.pusherInstance.reset() }, { playerList: this.userController.getPlayerList() });return this.eventEmitter.emit(p.LOCAL_LEAVE), e; - } }, { key: 'getPlayerList', value() { - const e = this.userController.getPlayerList();return l.log('[apiLog][getStreamList]', e), e; - } }, { key: 'setPusherAttributes', value(e) { - return l.log('[apiLog] [setPusherAttributes], ', e), this.pusherInstance.setPusherAttributes(e), l.warn('[statusLog] [setPusherAttributes]', this.pusherInstance.pusherAttributes), g.log('api-setPusherAttributes '.concat(JSON.stringify(e))), this.pusherInstance.pusherAttributes; - } }, { key: 'getPusherAttributes', value() { - return l.log('[apiLog] [getPusherConfig]'), this.pusherInstance.pusherAttributes; - } }, { key: 'setPlayerAttributes', value(e, t) { - l.log('[apiLog] [setPlayerAttributes] id', e, 'options: ', t);const r = this._transformStreamID(e); const s = r.userID; const i = r.streamType; const a = this.userController.getStream({ userID: s, streamType: i });return a ? (a.setPlayerAttributes(t), g.log('api-setPlayerAttributes id: '.concat(e, ' options: ').concat(JSON.stringify(t))), this.getPlayerList()) : this.getPlayerList(); - } }, { key: 'getPlayerInstance', value(e) { - const t = this._transformStreamID(e); const r = t.userID; const s = t.streamType;return l.log('[api][getPlayerInstance] id:', e), this.userController.getStream({ userID: r, streamType: s }); - } }, { key: 'switchStreamType', value(e) { - l.log('[apiLog] [switchStreamType] id: ', e);const t = this._transformStreamID(e); const r = t.userID; const s = t.streamType; const i = this.userController.getStream({ userID: r, streamType: s });return 'main' === i._definitionType ? (i.src = i.src.replace('main', 'small'), i._definitionType = 'small') : (i.src = i.src.replace('small', 'main'), i._definitionType = 'main'), this.getPlayerList(); - } }, { key: 'pusherEventHandler', value(e) { - this.userController.userEventHandler(e); - } }, { key: 'pusherNetStatusHandler', value(e) { - const t = e.detail.info;this.pusherInstance.setPusherAttributes(t), this.eventEmitter.emit(p.LOCAL_NET_STATE_UPDATE, { pusher: this.pusherInstance.pusherAttributes }); - } }, { key: 'pusherErrorHandler', value(e) { - try { - const t = e.detail.errCode; const r = e.detail.errMsg;this.eventEmitter.emit(p.ERROR, { code: t, message: r }); - } catch (t) { - l.error('pusher error data parser exception', e, t); - } - } }, { key: 'pusherBGMStartHandler', value(e) { - this.eventEmitter.emit(p.BGM_PLAY_START); - } }, { key: 'pusherBGMProgressHandler', value(e) { - let t; let r; let s; let i;this.eventEmitter.emit(p.BGM_PLAY_PROGRESS, { progress: null === (t = e.data) || void 0 === t || null === (r = t.detail) || void 0 === r ? void 0 : r.progress, duration: null === (s = e.data) || void 0 === s || null === (i = s.detail) || void 0 === i ? void 0 : i.duration }); - } }, { key: 'pusherBGMCompleteHandler', value(e) { - this.eventEmitter.emit(p.BGM_PLAY_COMPLETE); - } }, { key: 'pusherAudioVolumeNotify', value(e) { - this.pusherInstance.pusherAttributes.volume = e.detail.volume, this.eventEmitter.emit(p.LOCAL_AUDIO_VOLUME_UPDATE, { pusher: this.pusherInstance.pusherAttributes }); - } }, { key: 'playerEventHandler', value(e) { - l.log('[statusLog][playerStateChange]', e), this.eventEmitter.emit(p.REMOTE_STATE_UPDATE, e); - } }, { key: 'playerFullscreenChange', value(e) { - this.eventEmitter.emit(p.VIDEO_FULLSCREEN_UPDATE); - } }, { key: 'playerNetStatus', value(e) { - const t = this._transformStreamID(e.currentTarget.dataset.streamid); const r = t.userID; const s = t.streamType; const i = this.userController.getStream({ userID: r, streamType: s });!i || i.videoWidth === e.detail.info.videoWidth && i.videoHeight === e.detail.info.videoHeight || (i.setPlayerAttributes({ netStatus: e.detail.info }), this.eventEmitter.emit(p.REMOTE_NET_STATE_UPDATE, { playerList: this.userController.getPlayerList() })); - } }, { key: 'playerAudioVolumeNotify', value(e) { - const t = this._transformStreamID(e.currentTarget.dataset.streamid); const r = t.userID; const s = t.streamType; const i = this.userController.getStream({ userID: r, streamType: s }); const a = e.detail.volume;i.setPlayerAttributes({ volume: a }), this.eventEmitter.emit(p.REMOTE_AUDIO_VOLUME_UPDATE, { playerList: this.userController.getPlayerList() }); - } }, { key: '_transformStreamID', value(e) { - const t = e.lastIndexOf('_');return { userID: e.slice(0, t), streamType: e.slice(t + 1) }; - } }]), t; - }()); -}))); -// # sourceMappingURL=trtc-wx.js.map +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).TRTC=t()}(this,(function(){"use strict";function e(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function t(e,t){for(var r=0;r4294967296)?(c.error("roomID 超出取值范围 1 ~ 4294967295"),!1):e.strRoomID&&t.test(e.strRoomID)?(c.error("strRoomID 请勿使用中文字符"),!1):e.userID?e.userID&&t.test(e.userID)?(c.error("userID 请勿使用中文字符"),!1):!!e.userSig||(c.error("未设置 userSig"),!1):(c.error("未设置 userID"),!1):(c.error("未设置 sdkAppID"),!1)},m={LOCAL_JOIN:"LOCAL_JOIN",LOCAL_LEAVE:"LOCAL_LEAVE",KICKED_OUT:"KICKED_OUT",REMOTE_USER_JOIN:"REMOTE_USER_JOIN",REMOTE_USER_LEAVE:"REMOTE_USER_LEAVE",REMOTE_VIDEO_ADD:"REMOTE_VIDEO_ADD",REMOTE_VIDEO_REMOVE:"REMOTE_VIDEO_REMOVE",REMOTE_AUDIO_ADD:"REMOTE_AUDIO_ADD",REMOTE_AUDIO_REMOVE:"REMOTE_AUDIO_REMOVE",REMOTE_STATE_UPDATE:"REMOTE_STATE_UPDATE",LOCAL_NET_STATE_UPDATE:"LOCAL_NET_STATE_UPDATE",REMOTE_NET_STATE_UPDATE:"REMOTE_NET_STATE_UPDATE",LOCAL_AUDIO_VOLUME_UPDATE:"LOCAL_AUDIO_VOLUME_UPDATE",REMOTE_AUDIO_VOLUME_UPDATE:"REMOTE_AUDIO_VOLUME_UPDATE",VIDEO_FULLSCREEN_UPDATE:"VIDEO_FULLSCREEN_UPDATE",BGM_PLAY_START:"BGM_PLAY_START",BGM_PLAY_FAIL:"BGM_PLAY_FAIL",BGM_PLAY_PROGRESS:"BGM_PLAY_PROGRESS",BGM_PLAY_COMPLETE:"BGM_PLAY_COMPLETE",ERROR:"ERROR",IM_READY:"IM_READY",IM_MESSAGE_RECEIVED:"IM_MESSAGE_RECEIVED",IM_NOT_READY:"IM_NOT_READY",IM_KICKED_OUT:"IM_KICKED_OUT",IM_ERROR:"IM_ERROR"},p={url:"",mode:"RTC",autopush:!1,enableCamera:!1,enableMic:!1,enableAgc:!1,enableAns:!1,enableEarMonitor:!1,enableAutoFocus:!0,enableZoom:!1,minBitrate:600,maxBitrate:900,videoWidth:360,videoHeight:640,beautyLevel:0,whitenessLevel:0,videoOrientation:"vertical",videoAspect:"9:16",frontCamera:"front",enableRemoteMirror:!1,localMirror:"auto",enableBackgroundMute:!1,audioQuality:"high",audioVolumeType:"voicecall",audioReverbType:0,waitingImage:"",waitingImageHash:"",beautyStyle:"smooth",filter:"",netStatus:{}},d={src:"",mode:"RTC",autoplay:!0,muteAudio:!0,muteVideo:!0,orientation:"vertical",objectFit:"fillCrop",enableBackgroundMute:!1,minCache:1,maxCache:2,soundMode:"speaker",enableRecvMessage:!1,autoPauseIfNavigate:!0,autoPauseIfOpenNative:!0,isVisible:!0,_definitionType:"main",netStatus:{}};(new Date).getTime();function v(){var e=new Date;return e.setTime((new Date).getTime()+0),e.toLocaleString()}var g=function(e){var t=[];if(e&&e.TUIScene&&t.push(e.TUIScene),e&&"test"===e.env)return"default";if(wx&&wx.TUIScene&&t.push(wx.TUIScene),wx&&"function"==typeof getApp){var r=getApp().globalData;r&&r.TUIScene&&t.push(r.TUIScene)}return wx&&wx.getStorage({key:"TUIScene",success:function(e){t.push(e.data)}}),t[0]||"default"},y=new(function(){function t(){e(this,t),this.sdkAppId="",this.userId="",this.version="",this.common={}}return r(t,[{key:"setConfig",value:function(e){this.sdkAppId="".concat(e.sdkAppId),this.userId="".concat(e.userId),this.version="".concat(e.version),this.common.TUIScene=g(e)}},{key:"log",value:function(e){wx.request({url:"https://yun.tim.qq.com/v5/AVQualityReportSvc/C2S?sdkappid=1&cmdtype=jssdk_log",method:"POST",header:{"content-type":"application/json"},data:{timestamp:v(),sdkAppId:this.sdkAppId,userId:this.userId,version:this.version,log:JSON.stringify(i(i({},e),this.common))}})}}]),t}()),f="enterRoom",E="exitRoom",A="setPusherAttributes",I="setPlayerAttributes",_="init",L="error",D="connectServer",T="startPusher",b="openCamera",O="screenCap",k="pusherResolution",R="pusherCodeRate",P="collectionFirstFrame",S="encoderStart",M="enterRoomSuccess",U="exitRoomSuccess",C="kicked_out",x="renderFirstFrame",w="miniAppHang",V="closeSuspension",B="other",G="update",N="addUser",j="remove_user",F="update_user_video",H="update_user_audio",Y="pusherStart",K="pusherStop",q="pusherPause",J="pusherResume",W=function(){function t(r,s){e(this,t),this.context=wx.createLivePusherContext(s),this.pusherAttributes={},Object.assign(this.pusherAttributes,p,r)}return r(t,[{key:"setPusherAttributes",value:function(e){return Object.assign(this.pusherAttributes,e),this.pusherAttributes}},{key:"start",value:function(e){c.log("[apiLog][pusherStart]"),y.log({name:Y,options:e}),this.context.start(e)}},{key:"stop",value:function(e){c.log("[apiLog][pusherStop]"),y.log({name:K,options:e}),this.context.stop(e)}},{key:"pause",value:function(e){c.log("[apiLog] pusherPause()"),y.log({name:q,options:e}),this.context.pause(e)}},{key:"resume",value:function(e){c.log("[apiLog][pusherResume]"),y.log({name:J,options:e}),this.context.resume(e)}},{key:"switchCamera",value:function(e){return c.log("[apiLog][switchCamera]"),this.pusherAttributes.frontCamera="front"===this.pusherAttributes.frontCamera?"back":"front",this.context.switchCamera(e),this.pusherAttributes}},{key:"sendMessage",value:function(e){c.log("[apiLog][sendMessage]",e.msg),this.context.sendMessage(e)}},{key:"snapshot",value:function(){var e=this;return c.log("[apiLog][pusherSnapshot]"),new Promise((function(t,r){e.context.snapshot({quality:"raw",complete:function(e){e.tempImagePath?(wx.saveImageToPhotosAlbum({filePath:e.tempImagePath,success:function(r){t(e)},fail:function(e){c.error("[error] pusher截图失败: ",e),r(new Error("截图失败"))}}),t(e)):(c.error("[error] snapShot 回调失败",e),r(new Error("截图失败")))}})}))}},{key:"toggleTorch",value:function(e){this.context.toggleTorch(e)}},{key:"startDumpAudio",value:function(e){this.context.startDumpAudio(e)}},{key:"stopDumpAudio",value:function(e){this.context.startDumpAudio(e)}},{key:"playBGM",value:function(e){c.log("[apiLog] playBGM() url: ",e.url),this.context.playBGM(e)}},{key:"pauseBGM",value:function(e){c.log("[apiLog] pauseBGM()"),this.context.pauseBGM(e)}},{key:"resumeBGM",value:function(e){c.log("[apiLog] resumeBGM()"),this.context.resumeBGM(e)}},{key:"stopBGM",value:function(e){c.log("[apiLog] stopBGM()"),this.context.stopBGM(e)}},{key:"setBGMVolume",value:function(e){c.log("[apiLog] setBGMVolume() volume:",e.volume),this.context.setBGMVolume(e.volume)}},{key:"setMICVolume",value:function(e){c.log("[apiLog] setMICVolume() volume:",e.volume),this.context.setMICVolume(e.volume)}},{key:"startPreview",value:function(e){c.log("[apiLog] startPreview()"),this.context.startPreview(e)}},{key:"stopPreview",value:function(e){c.log("[apiLog] stopPreview()"),this.context.stopPreview(e)}},{key:"reset",value:function(){return console.log("Pusher reset",this.context),this.pusherConfig={},this.context&&(this.stop({success:function(){console.log("Pusher context.stop()")}}),this.context=null),this.pusherAttributes}}]),t}(),Q=function t(r){e(this,t),Object.assign(this,{userID:"",streams:{}},r)},X=function(){function t(r,s){e(this,t),this.ctx=s,this.playerAttributes={},Object.assign(this.playerAttributes,d,{userID:"",streamType:"",streamID:"",id:"",hasVideo:!1,hasAudio:!1,volume:0,playerContext:void 0},r)}return r(t,[{key:"play",value:function(e){this.getPlayerContext().play(e)}},{key:"stop",value:function(e){this.getPlayerContext().stop(e)}},{key:"mute",value:function(e){this.getPlayerContext().mute(e)}},{key:"pause",value:function(e){this.getPlayerContext().pause(e)}},{key:"resume",value:function(e){this.getPlayerContext().resume(e)}},{key:"requestFullScreen",value:function(e){var t=this;return new Promise((function(r,s){t.getPlayerContext().requestFullScreen({direction:e.direction,success:function(e){r(e)},fail:function(e){s(e)}})}))}},{key:"requestExitFullScreen",value:function(){var e=this;return new Promise((function(t,r){e.getPlayerContext().exitFullScreen({success:function(e){t(e)},fail:function(e){r(e)}})}))}},{key:"snapshot",value:function(e){var t=this;return c.log("[playerSnapshot]",e),new Promise((function(e,r){t.getPlayerContext().snapshot({quality:"raw",complete:function(t){t.tempImagePath?(wx.saveImageToPhotosAlbum({filePath:t.tempImagePath,success:function(r){c.log("save photo is success",r),e(t)},fail:function(e){c.error("save photo is fail",e),r(e)}}),e(t)):(c.error("snapShot 回调失败",t),r(new Error("截图失败")))}})}))}},{key:"setPlayerAttributes",value:function(e){Object.assign(this.playerAttributes,e)}},{key:"getPlayerContext",value:function(){return this.playerContext||(this.playerContext=wx.createLivePlayerContext(this.playerAttributes.id,this.ctx)),this.playerContext}},{key:"reset",value:function(){this.playerContext&&(this.playerContext.stop(),this.playerContext=void 0),Object.assign(this.playerAttributes,d,{userID:"",streamType:"",streamID:"",hasVideo:!1,hasAudio:!1,volume:0,playerContext:void 0})}}]),t}(),Z="UserController",z=function(){function t(r,s){e(this,t),this.ctx=s,this.userMap=new Map,this.userList=[],this.streamList=[],this.emitter=r}return r(t,[{key:"userEventHandler",value:function(e){var t=e.detail.code,r=e.detail.message,s={name:B,code:t,message:r,data:""};switch(t){case 0:c.log(r,t);break;case 1001:c.log("已经连接推流服务器",t),s.name=D;break;case 1002:c.log("已经与服务器握手完毕,开始推流",t),s.name=T;break;case 1003:c.log("打开摄像头成功",t),s.name=b;break;case 1004:c.log("录屏启动成功",t),s.name=O;break;case 1005:c.log("推流动态调整分辨率",t),s.name=k;break;case 1006:c.log("推流动态调整码率",t),s.name=R;break;case 1007:c.log("首帧画面采集完成",t),s.name=P;break;case 1008:c.log("编码器启动",t),s.name=S;break;case 1018:c.log("进房成功",t),s.name=M,s.data="event enterRoom success",this.emitter.emit(m.LOCAL_JOIN);break;case 1019:c.log("退出房间",t),r.indexOf("reason[0]")>-1?(s.name=U,s.data="event exitRoom success"):(s.name=C,s.data="event abnormal exitRoom",this.emitter.emit(m.KICKED_OUT));break;case 2003:c.log("渲染首帧视频",t),s.name=x;break;case-1301:c.error("打开摄像头失败: ",t),s.name=L,s.data="event start camera failed",this.emitter.emit(m.ERROR,{code:t,message:r});break;case-1302:s.name=L,s.data="event start microphone failed",c.error("打开麦克风失败: ",t),this.emitter.emit(m.ERROR,{code:t,message:r});break;case-1303:c.error("视频编码失败: ",t),s.name=L,s.data="event video encode failed",this.emitter.emit(m.ERROR,{code:t,message:r});break;case-1304:c.error("音频编码失败: ",t),s.name=L,s.data="event audio encode failed",this.emitter.emit(m.ERROR,{code:t,message:r});break;case-1307:c.error("推流连接断开: ",t),s.name=L,s.data="event pusher stream failed",this.emitter.emit(m.ERROR,{code:t,message:r});break;case-100018:c.error("进房失败: userSig 校验失败,请检查 userSig 是否填写正确",t,r),s.name=L,s.data="event userSig is error",this.emitter.emit(m.ERROR,{code:t,message:r});break;case 5e3:c.log("小程序被挂起: ",t),s.name=w,s.data="miniApp is hang";break;case 5001:c.log("小程序悬浮窗被关闭: ",t),s.name=V;break;case 1021:c.log("网络类型发生变化,需要重新进房",t);break;case 2007:c.log("本地视频播放loading: ",t);break;case 2004:c.log("本地视频播放开始: ",t);break;case 1031:case 1032:case 1033:case 1034:this._handleUserEvent(e)}y.log(s)}},{key:"_handleUserEvent",value:function(e){var t,r=e.detail.code,s=e.detail.message;if(!e.detail.message||"string"!=typeof s)return c.warn(Z,"userEventHandler 数据格式错误"),!1;try{t=JSON.parse(e.detail.message)}catch(e){return c.warn(Z,"userEventHandler 数据格式错误",e),!1}switch(this.emitter.emit(m.LOCAL_STATE_UPDATE,e),y.log({name:G,code:r,message:s,data:t}),r){case 1031:this.addUser(t);break;case 1032:this.removeUser(t);break;case 1033:this.updateUserVideo(t);break;case 1034:this.updateUserAudio(t)}}},{key:"addUser",value:function(e){var t=this;c.log("addUser",e);var r=e.userlist;Array.isArray(r)&&r.length>0&&r.forEach((function(e){var r=e.userid,s=t.getUser(r);s||(s=new Q({userID:r}),t.userList.push({userID:r})),t.userMap.set(r,s),t.emitter.emit(m.REMOTE_USER_JOIN,{userID:r,userList:t.userList,playerList:t.getPlayerList()}),y.log({name:N,userID:r,userList:t.userList,playerList:t.getPlayerList()})}))}},{key:"removeUser",value:function(e){var t=this,r=e.userlist;Array.isArray(r)&&r.length>0&&r.forEach((function(e){var r=e.userid,s=t.getUser(r);s&&s.streams&&(t._removeUserAndStream(r),s.streams.main&&s.streams.main.reset(),s.streams.aux&&s.streams.aux.reset(),t.emitter.emit(m.REMOTE_USER_LEAVE,{userID:r,userList:t.userList,playerList:t.getPlayerList()}),y.log({name:j,userID:r,userList:t.userList,playerList:t.getPlayerList()}),s=void 0,t.userMap.delete(r))}))}},{key:"updateUserVideo",value:function(e){var t=this;c.log(Z,"updateUserVideo",e);var r=e.userlist;Array.isArray(r)&&r.length>0&&r.forEach((function(e){var r=e.userid,s=e.streamtype,a="".concat(r,"_").concat(s),i=a,n=e.hasvideo,o=e.playurl,u=t.getUser(r);if(u){var l=u.streams[s];c.log(Z,"updateUserVideo start",u,s,l),l?(l.setPlayerAttributes({hasVideo:n}),n||l.playerAttributes.hasAudio||t._removeStream(l)):(l=new X({userID:r,streamID:a,hasVideo:n,src:o,streamType:s,id:i},t.ctx),u.streams[s]=l,t._addStream(l)),"aux"===s&&(n?(l.objectFit="contain",t._addStream(l)):t._removeStream(l)),t.userList.find((function(e){if(e.userID===r)return e["has".concat(s.replace(/^\S/,(function(e){return e.toUpperCase()})),"Video")]=n,!0})),c.log(Z,"updateUserVideo end",u,s,l);var h=n?m.REMOTE_VIDEO_ADD:m.REMOTE_VIDEO_REMOVE;t.emitter.emit(h,{player:l.playerAttributes,userList:t.userList,playerList:t.getPlayerList()}),y.log({name:F,player:l.playerAttributes,userList:t.userList,playerList:t.getPlayerList()})}}))}},{key:"updateUserAudio",value:function(e){var t=this,r=e.userlist;Array.isArray(r)&&r.length>0&&r.forEach((function(e){var r=e.userid,s="main",a="".concat(r,"_").concat(s),i=a,n=e.hasaudio,o=e.playurl,u=t.getUser(r);if(u){var l=u.streams.main;l?(l.setPlayerAttributes({hasAudio:n}),n||l.playerAttributes.hasVideo||t._removeStream(l)):(l=new X({userID:r,streamID:a,hasAudio:n,src:o,streamType:s,id:i},t.ctx),u.streams.main=l,t._addStream(l)),t.userList.find((function(e){if(e.userID===r)return e["has".concat(s.replace(/^\S/,(function(e){return e.toUpperCase()})),"Audio")]=n,!0}));var c=n?m.REMOTE_AUDIO_ADD:m.REMOTE_AUDIO_REMOVE;t.emitter.emit(c,{player:l.playerAttributes,userList:t.userList,playerList:t.getPlayerList()}),y.log({name:H,player:l.playerAttributes,userList:t.userList,playerList:t.getPlayerList()})}}))}},{key:"getUser",value:function(e){return this.userMap.get(e)}},{key:"getStream",value:function(e){var t=e.userID,r=e.streamType,s=this.userMap.get(t);if(s)return s.streams[r]}},{key:"getUserList",value:function(){return this.userList}},{key:"getStreamList",value:function(){return this.streamList}},{key:"getPlayerList",value:function(){for(var e=this.getStreamList(),t=[],r=0;r (function (t) { - const e = {};function i(n) { - if (e[n]) return e[n].exports;const o = e[n] = { i: n, l: !1, exports: {} };return t[n].call(o.exports, o, o.exports, i), o.l = !0, o.exports; - } return i.m = t, i.c = e, i.d = function (t, e, n) { - i.o(t, e) || Object.defineProperty(t, e, { enumerable: !0, get: n }); - }, i.r = function (t) { - 'undefined' !== typeof Symbol && Symbol.toStringTag && Object.defineProperty(t, Symbol.toStringTag, { value: 'Module' }), Object.defineProperty(t, '__esModule', { value: !0 }); - }, i.t = function (t, e) { - if (1 & e && (t = i(t)), 8 & e) return t;if (4 & e && 'object' === typeof t && t && t.__esModule) return t;const n = Object.create(null);if (i.r(n), Object.defineProperty(n, 'default', { enumerable: !0, value: t }), 2 & e && 'string' !== typeof t) for (const o in t)i.d(n, o, (e => t[e]).bind(null, o));return n; - }, i.n = function (t) { - const e = t && t.__esModule ? function () { - return t.default; - } : function () { - return t; - };return i.d(e, 'a', e), e; - }, i.o = function (t, e) { - return Object.prototype.hasOwnProperty.call(t, e); - }, i.p = '', i(i.s = 5); -}([function (t, e, i) { - 'use strict';i.d(e, 'e', (() => p)), i.d(e, 'g', (() => h)), i.d(e, 'c', (() => g)), i.d(e, 'f', (() => v)), i.d(e, 'b', (() => m)), i.d(e, 'd', (() => T)), i.d(e, 'a', (() => y)), i.d(e, 'h', (() => N));const n = 'undefined' !== typeof window; const o = ('undefined' !== typeof wx && wx.getSystemInfoSync, n && window.navigator && window.navigator.userAgent || ''); const r = /AppleWebKit\/([\d.]+)/i.exec(o); const s = (r && parseFloat(r.pop()), /iPad/i.test(o)); const a = /iPhone/i.test(o) && !s; const u = /iPod/i.test(o); const l = a || s || u; const c = ((function () { - const t = o.match(/OS (\d+)_/i);t && t[1] && t[1]; - }()), /Android/i.test(o)); const d = (function () { - const t = o.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);if (!t) return null;const e = t[1] && parseFloat(t[1]); const i = t[2] && parseFloat(t[2]);return e && i ? parseFloat(`${t[1]}.${t[2]}`) : e || null; - }()); const f = (c && /webkit/i.test(o), /Firefox/i.test(o), /Edge/i.test(o)); const _ = !f && /Chrome/i.test(o); const I = ((function () { - const t = o.match(/Chrome\/(\d+)/);t && t[1] && parseFloat(t[1]); - }()), /MSIE/.test(o), /MSIE\s8\.0/.test(o), (function () { - const t = /MSIE\s(\d+)\.\d/.exec(o);let e = t && parseFloat(t[1]);!e && /Trident\/7.0/i.test(o) && /rv:11.0/.test(o) && (e = 11); - }()), /Safari/i.test(o), /TBS\/\d+/i.test(o));(function () { - const t = o.match(/TBS\/(\d+)/i);if (t && t[1])t[1]; - }()), !I && /MQQBrowser\/\d+/i.test(o), !I && / QQBrowser\/\d+/i.test(o), /(micromessenger|webbrowser)/i.test(o), /Windows/i.test(o), /MAC OS X/i.test(o), /MicroMessenger/i.test(o);i(2), i(1);const p = function (t) { - return 'map' === D(t); - }; const h = function (t) { - return 'set' === D(t); - }; const g = function (t) { - return 'file' === D(t); - }; const v = function (t) { - if ('object' !== typeof t || null === t) return !1;const e = Object.getPrototypeOf(t);if (null === e) return !0;let i = e;for (;null !== Object.getPrototypeOf(i);)i = Object.getPrototypeOf(i);return e === i; - }; const E = function (t) { - return 'function' === typeof Array.isArray ? Array.isArray(t) : 'array' === D(t); - }; const m = function (t) { - return E(t) || (function (t) { - return null !== t && 'object' === typeof t; - }(t)); - }; const T = function (t) { - return t instanceof Error; - }; const D = function (t) { - return Object.prototype.toString.call(t).match(/^\[object (.*)\]$/)[1].toLowerCase(); - };let S = 0;Date.now || (Date.now = function () { - return (new Date).getTime(); - });const y = { now() { - 0 === S && (S = Date.now() - 1);const t = Date.now() - S;return t > 4294967295 ? (S += 4294967295, Date.now() - S) : t; - }, utc() { - return Math.round(Date.now() / 1e3); - } }; const N = function (t) { - return JSON.stringify(t, ['message', 'code']); - }; -}, function (t, e, i) { - 'use strict';i.r(e);const n = i(3); const o = i(0);let r = 0;const s = new Map;function a() { - const t = new Date;return `TSignaling ${t.toLocaleTimeString('en-US', { hour12: !1 })}.${(function (t) { - let e;switch (t.toString().length) { - case 1:e = `00${t}`;break;case 2:e = `0${t}`;break;default:e = t; - } return e; - }(t.getMilliseconds()))}:`; - } const u = { _data: [], _length: 0, _visible: !1, arguments2String(t) { - let e;if (1 === t.length)e = a() + t[0];else { - e = a();for (let i = 0, n = t.length;i < n;i++)Object(o.b)(t[i]) ? Object(o.d)(t[i]) ? e += Object(o.h)(t[i]) : e += JSON.stringify(t[i]) : e += t[i], e += ' '; - } return e; - }, debug() { - if (r <= -1) { - const t = this.arguments2String(arguments);u.record(t, 'debug'), n.a.debug(t); - } - }, log() { - if (r <= 0) { - const t = this.arguments2String(arguments);u.record(t, 'log'), n.a.log(t); - } - }, info() { - if (r <= 1) { - const t = this.arguments2String(arguments);u.record(t, 'info'), n.a.info(t); - } - }, warn() { - if (r <= 2) { - const t = this.arguments2String(arguments);u.record(t, 'warn'), n.a.warn(t); - } - }, error() { - if (r <= 3) { - const t = this.arguments2String(arguments);u.record(t, 'error'), n.a.error(t); - } - }, time(t) { - s.set(t, o.a.now()); - }, timeEnd(t) { - if (s.has(t)) { - const e = o.a.now() - s.get(t);return s.delete(t), e; - } return n.a.warn(`未找到对应label: ${t}, 请在调用 logger.timeEnd 前,调用 logger.time`), 0; - }, setLevel(t) { - t < 4 && n.a.log(`${a()}set level from ${r} to ${t}`), r = t; - }, record(t, e) { - 1100 === u._length && (u._data.splice(0, 100), u._length = 1e3), u._length++, u._data.push(`${t} [${e}] \n`); - }, getLog() { - return u._data; - } };e.default = u; -}, function (t, e, i) { - 'use strict';i.r(e);e.default = { MSG_PRIORITY_HIGH: 'High', MSG_PRIORITY_NORMAL: 'Normal', MSG_PRIORITY_LOW: 'Low', MSG_PRIORITY_LOWEST: 'Lowest', KICKED_OUT_MULT_ACCOUNT: 'multipleAccount', KICKED_OUT_MULT_DEVICE: 'multipleDevice', KICKED_OUT_USERSIG_EXPIRED: 'userSigExpired', NET_STATE_CONNECTED: 'connected', NET_STATE_CONNECTING: 'connecting', NET_STATE_DISCONNECTED: 'disconnected', ENTER_ROOM_SUCCESS: 'JoinedSuccess', ALREADY_IN_ROOM: 'AlreadyInGroup' }; -}, function (t, e, i) { - 'use strict';(function (t) { - let i; let n;i = 'undefined' !== typeof console ? console : void 0 !== t && t.console ? t.console : 'undefined' !== typeof window && window.console ? window.console : {};const o = function () {}; const r = ['assert', 'clear', 'count', 'debug', 'dir', 'dirxml', 'error', 'exception', 'group', 'groupCollapsed', 'groupEnd', 'info', 'log', 'markTimeline', 'profile', 'profileEnd', 'table', 'time', 'timeEnd', 'timeStamp', 'trace', 'warn'];let s = r.length;for (;s--;)n = r[s], console[n] || (i[n] = o);i.methods = r, e.a = i; - }).call(this, i(8)); -}, function (t, e, i) { - 'use strict';Object.defineProperty(e, '__esModule', { value: !0 });e.default = { NEW_INVITATION_RECEIVED: 'ts_new_invitation_received', INVITEE_ACCEPTED: 'ts_invitee_accepted', INVITEE_REJECTED: 'ts_invitee_rejected', INVITATION_CANCELLED: 'ts_invitation_cancelled', INVITATION_TIMEOUT: 'ts_invitation_timeout', SDK_READY: 'ts_im_ready', SDK_NOT_READY: 'ts_im_not_ready', TEXT_MESSAGE_RECEIVED: 'ts_text_message_received', CUSTOM_MESSAGE_RECEIVED: 'ts_custom_message_received', REMOTE_USER_JOIN: 'ts_remote_user_join', REMOTE_USER_LEAVE: 'ts_remote_user_leave', KICKED_OUT: 'ts_kicked_out', NET_STATE_CHANGE: 'ts_net_state_change' }; -}, function (t, e, i) { - 'use strict';const n = this && this.__awaiter || function (t, e, i, n) { - return new (i || (i = Promise))(((o, r) => { - function s(t) { - try { - u(n.next(t)); - } catch (t) { - r(t); - } - } function a(t) { - try { - u(n.throw(t)); - } catch (t) { - r(t); - } - } function u(t) { - let e;t.done ? o(t.value) : (e = t.value, e instanceof i ? e : new i(((t) => { - t(e); - }))).then(s, a); - }u((n = n.apply(t, e || [])).next()); - })); - }; const o = this && this.__generator || function (t, e) { - let i; let n; let o; let r; let s = { label: 0, sent() { - if (1 & o[0]) throw o[1];return o[1]; - }, trys: [], ops: [] };return r = { next: a(0), throw: a(1), return: a(2) }, 'function' === typeof Symbol && (r[Symbol.iterator] = function () { - return this; - }), r;function a(r) { - return function (a) { - return (function (r) { - if (i) throw new TypeError('Generator is already executing.');for (;s;) try { - if (i = 1, n && (o = 2 & r[0] ? n.return : r[0] ? n.throw || ((o = n.return) && o.call(n), 0) : n.next) && !(o = o.call(n, r[1])).done) return o;switch (n = 0, o && (r = [2 & r[0], o.value]), r[0]) { - case 0:case 1:o = r;break;case 4:return s.label++, { value: r[1], done: !1 };case 5:s.label++, n = r[1], r = [0];continue;case 7:r = s.ops.pop(), s.trys.pop();continue;default:if (!(o = s.trys, (o = o.length > 0 && o[o.length - 1]) || 6 !== r[0] && 2 !== r[0])) { - s = 0;continue; - } if (3 === r[0] && (!o || r[1] > o[0] && r[1] < o[3])) { - s.label = r[1];break; - } if (6 === r[0] && s.label < o[1]) { - s.label = o[1], o = r;break; - } if (o && s.label < o[2]) { - s.label = o[2], s.ops.push(r);break; - }o[2] && s.ops.pop(), s.trys.pop();continue; - }r = e.call(t, s); - } catch (t) { - r = [6, t], n = 0; - } finally { - i = o = 0; - } if (5 & r[0]) throw r[1];return { value: r[0] ? r[1] : void 0, done: !0 }; - }([r, a])); - }; - } - }; const r = this && this.__spreadArrays || function () { - for (var t = 0, e = 0, i = arguments.length;e < i;e++)t += arguments[e].length;const n = Array(t); let o = 0;for (e = 0;e < i;e++) for (let r = arguments[e], s = 0, a = r.length;s < a;s++, o++)n[o] = r[s];return n; - };Object.defineProperty(e, '__esModule', { value: !0 });const s = i(6); const a = i(7); const u = i(4); const l = i(2); const c = i(1); const d = i(9); const f = i(10); const _ = i(11); const I = i(12); const p = i(14); const h = i(15).version; const g = (function () { - function t(t) { - if (this._outerEmitter = null, this._safetyCallbackFactory = null, this._tim = null, this._imSDKAppID = 0, this._userID = null, this._groupID = '', this._isHandling = !1, this._inviteInfoMap = new Map, c.default.info(`TSignaling version:${h}`), d.default(t.SDKAppID)) return c.default.error('TSignaling 请传入 SDKAppID !!!'), null;this._outerEmitter = new a.default, this._outerEmitter._emit = this._outerEmitter.emit, this._outerEmitter.emit = function () { - for (var t = [], e = 0;e < arguments.length;e++)t[e] = arguments[e];const i = t[0]; const n = [i, { name: t[0], data: t[1] }];this._outerEmitter._emit.apply(this._outerEmitter, r(n)); - }.bind(this), this._safetyCallbackFactory = new _.default, t.tim ? this._tim = t.tim : this._tim = p.create({ SDKAppID: t.SDKAppID, scene: 'TSignaling' }), this._imSDKAppID = t.SDKAppID, this._tim.on(p.EVENT.SDK_READY, this._onIMReady.bind(this)), this._tim.on(p.EVENT.SDK_NOT_READY, this._onIMNotReady.bind(this)), this._tim.on(p.EVENT.KICKED_OUT, this._onKickedOut.bind(this)), this._tim.on(p.EVENT.NET_STATE_CHANGE, this._onNetStateChange.bind(this)), this._tim.on(p.EVENT.MESSAGE_RECEIVED, this._onMessageReceived.bind(this)); - } return t.prototype.setLogLevel = function (t) { - c.default.setLevel(t), this._tim.setLogLevel(t); - }, t.prototype.login = function (t) { - return n(this, void 0, void 0, (function () { - return o(this, (function (e) { - return c.default.log('TSignaling.login', t), this._userID = t.userID, [2, this._tim.login(t)]; - })); - })); - }, t.prototype.logout = function () { - return n(this, void 0, void 0, (function () { - return o(this, (function (t) { - return c.default.log('TSignaling.logout'), this._userID = '', this._inviteInfoMap.clear(), [2, this._tim.logout()]; - })); - })); - }, t.prototype.on = function (t, e, i) { - c.default.log(`TSignaling.on eventName:${t}`), this._outerEmitter.on(t, this._safetyCallbackFactory.defense(t, e, i), i); - }, t.prototype.off = function (t, e) { - c.default.log(`TSignaling.off eventName:${t}`), this._outerEmitter.off(t, e); - }, t.prototype.joinGroup = function (t) { - return n(this, void 0, void 0, (function () { - return o(this, (function (e) { - return c.default.log(`TSignaling.joinGroup groupID:${t}`), this._groupID = t, [2, this._tim.joinGroup({ groupID: t })]; - })); - })); - }, t.prototype.quitGroup = function (t) { - return n(this, void 0, void 0, (function () { - return o(this, (function (e) { - return c.default.log(`TSignaling.quitGroup groupID:${t}`), [2, this._tim.quitGroup(t)]; - })); - })); - }, t.prototype.sendTextMessage = function (t) { - return n(this, void 0, void 0, (function () { - let e;return o(this, (function (i) { - return e = this._tim.createTextMessage({ to: t.to, conversationType: !0 === t.groupFlag ? p.TYPES.CONV_GROUP : p.TYPES.CONV_C2C, priority: t.priority || p.TYPES.MSG_PRIORITY_NORMAL, payload: { text: t.text } }), [2, this._tim.sendMessage(e)]; - })); - })); - }, t.prototype.sendCustomMessage = function (t) { - return n(this, void 0, void 0, (function () { - let e;return o(this, (function (i) { - return e = this._tim.createCustomMessage({ to: t.to, conversationType: !0 === t.groupFlag ? p.TYPES.CONV_GROUP : p.TYPES.CONV_C2C, priority: t.priority || p.TYPES.MSG_PRIORITY_NORMAL, payload: { data: t.data || '', description: t.description || '', extension: t.extension || '' } }), [2, this._tim.sendMessage(e)]; - })); - })); - }, t.prototype.invite = function (t) { - return n(this, void 0, void 0, (function () { - let e; let i; let n; let r; let a; let u; let l;return o(this, (function (o) { - switch (o.label) { - case 0:return e = I.generate(), c.default.log('TSignaling.invite', t, `inviteID=${e}`), d.default(t) || d.default(t.userID) ? [2, Promise.reject(new f.default({ code: s.ErrorCode.ERR_INVALID_PARAMETERS, message: 'userID is invalid' }))] : (i = t.userID, n = t.data, r = t.timeout, a = t.offlinePushInfo, u = { businessID: s.BusinessID.SIGNAL, inviteID: e, inviter: this._userID, actionType: s.ActionType.INVITE, inviteeList: [i], data: n, timeout: d.default(r) ? 0 : r, groupID: '' }, [4, this._sendCustomMessage(i, u, a)]);case 1:return 0 === (l = o.sent()).code ? (c.default.log('TSignaling.invite ok'), this._inviteInfoMap.set(e, u), this._startTimer(u, !0), [2, { inviteID: e, code: l.code, data: l.data }]) : [2, l]; - } - })); - })); - }, t.prototype.inviteInGroup = function (t) { - return n(this, void 0, void 0, (function () { - let e; let i; let n; let r; let a; let u; let l; let _;return o(this, (function (o) { - switch (o.label) { - case 0:return e = I.generate(), c.default.log('TSignaling.inviteInGroup', t, `inviteID=${e}`), d.default(t) || d.default(t.groupID) ? [2, Promise.reject(new f.default({ code: s.ErrorCode.ERR_INVALID_PARAMETERS, message: 'groupID is invalid' }))] : (i = t.groupID, n = t.inviteeList, r = t.data, a = t.timeout, u = t.offlinePushInfo, l = { businessID: s.BusinessID.SIGNAL, inviteID: e, inviter: this._userID, actionType: s.ActionType.INVITE, inviteeList: n, data: r, timeout: d.default(a) ? 0 : a, groupID: i }, [4, this._sendCustomMessage(i, l, u)]);case 1:return 0 === (_ = o.sent()).code ? (c.default.log('TSignaling.inviteInGroup ok'), this._inviteInfoMap.set(e, l), this._startTimer(l, !0), [2, { inviteID: e, code: _.code, data: _.data }]) : [2, _]; - } - })); - })); - }, t.prototype.cancel = function (t) { - return n(this, void 0, void 0, (function () { - let e; let i; let n; let r; let a; let u; let l; let _; let I;return o(this, (function (o) { - switch (o.label) { - case 0:return c.default.log('TSignaling.cancel', t), d.default(t) || d.default(t.inviteID) || !this._inviteInfoMap.has(t.inviteID) || this._isHandling ? [2, Promise.reject(new f.default({ code: s.ErrorCode.ERR_SDK_SIGNALING_INVALID_INVITE_ID, message: 'inviteID is invalid or invitation has been processed' }))] : (this._isHandling = !0, e = t.inviteID, i = t.data, n = this._inviteInfoMap.get(e), r = n.inviter, a = n.groupID, u = n.inviteeList, r !== this._userID ? [3, 2] : (l = { businessID: s.BusinessID.SIGNAL, inviteID: e, inviter: r, actionType: s.ActionType.CANCEL_INVITE, inviteeList: u, data: i, timeout: 0, groupID: a }, _ = a || u[0], [4, this._sendCustomMessage(_, l)]));case 1:return I = o.sent(), this._isHandling = !1, I && 0 === I.code ? (c.default.log('TSignaling.cancel ok'), this._deleteInviteInfoByID(e), this._inviteID = null, [2, { inviteID: e, code: I.code, data: I.data }]) : [2, I];case 2:return c.default.error(`TSignaling.cancel unmatched inviter=${r} and userID=${this._userID}`), this._isHandling = !1, [2, Promise.reject(new f.default({ code: s.ErrorCode.ERR_SDK_SIGNALING_NO_PERMISSION, message: '信令请求无权限,比如取消非自己发起的邀请,接受或则拒绝非发给自己的邀请' }))]; - } - })); - })); - }, t.prototype.accept = function (t) { - return n(this, void 0, void 0, (function () { - let e; let i; let n; let r; let a; let u; let l; let _;return o(this, (function (o) { - switch (o.label) { - case 0:return c.default.log('TSignaling.accept', t), d.default(t) || d.default(t.inviteID) || !this._inviteInfoMap.has(t.inviteID) || this._isHandling ? [2, Promise.reject(new f.default({ code: s.ErrorCode.ERR_SDK_SIGNALING_INVALID_INVITE_ID, message: 'inviteID is invalid or invitation has been processed' }))] : (this._isHandling = !0, e = t.inviteID, i = t.data, n = this._inviteInfoMap.get(e), r = n.inviter, a = n.groupID, n.inviteeList.includes(this._userID) ? (u = { businessID: s.BusinessID.SIGNAL, inviteID: e, inviter: r, actionType: s.ActionType.ACCEPT_INVITE, inviteeList: [this._userID], data: i, timeout: 0, groupID: a }, l = a || r, [4, this._sendCustomMessage(l, u)]) : [3, 2]);case 1:return _ = o.sent(), this._isHandling = !1, _ && 0 === _.code ? (c.default.log('TSignaling.accept ok'), this._updateLocalInviteInfo(u), [2, { inviteID: e, code: _.code, data: _.data }]) : [2, _];case 2:return c.default.error(`TSignaling.accept inviteeList do not include userID=${this._userID}. inviteID=${e} groupID=${a}`), this._isHandling = !1, [2, Promise.reject(new f.default({ code: s.ErrorCode.ERR_SDK_SIGNALING_INVALID_INVITE_ID, message: 'inviteID is invalid or invitation has been processed' }))]; - } - })); - })); - }, t.prototype.reject = function (t) { - return n(this, void 0, void 0, (function () { - let e; let i; let n; let r; let a; let u; let l; let _;return o(this, (function (o) { - switch (o.label) { - case 0:return c.default.log('TSignaling.reject', t), d.default(t) || d.default(t.inviteID) || !this._inviteInfoMap.has(t.inviteID) || this._isHandling ? [2, Promise.reject(new f.default({ code: s.ErrorCode.ERR_SDK_SIGNALING_INVALID_INVITE_ID, message: 'inviteID is invalid or invitation has been processed' }))] : (this._isHandling = !0, e = t.inviteID, i = t.data, n = this._inviteInfoMap.get(e), r = n.inviter, a = n.groupID, n.inviteeList.includes(this._userID) ? (u = { businessID: s.BusinessID.SIGNAL, inviteID: e, inviter: r, actionType: s.ActionType.REJECT_INVITE, inviteeList: [this._userID], data: i, timeout: 0, groupID: a }, l = a || r, [4, this._sendCustomMessage(l, u)]) : [3, 2]);case 1:return _ = o.sent(), this._isHandling = !1, _ && 0 === _.code ? (c.default.log('TSignaling.reject ok'), this._updateLocalInviteInfo(u), [2, { inviteID: e, code: _.code, data: _.data }]) : [2, _];case 2:return c.default.error(`TSignaling.reject inviteeList do not include userID=${this._userID}. inviteID=${e} groupID=${a}`), this._isHandling = !1, [2, Promise.reject(new f.default({ code: s.ErrorCode.ERR_SDK_SIGNALING_INVALID_INVITE_ID, message: 'inviteID is invalid or invitation has been processed' }))]; - } - })); - })); - }, t.prototype._onIMReady = function (t) { - c.default.log('TSignaling._onIMReady'), this._outerEmitter.emit(u.default.SDK_READY); - }, t.prototype._onIMNotReady = function (t) { - c.default.log('TSignaling.onSdkNotReady'), this._outerEmitter.emit(u.default.SDK_NOT_READY); - }, t.prototype._onKickedOut = function (t) { - c.default.log('TSignaling._onKickedOut'), this._outerEmitter.emit(u.default.KICKED_OUT, t.data); - }, t.prototype._onNetStateChange = function (t) { - c.default.log('TSignaling._onNetStateChange'), this._outerEmitter.emit(u.default.NET_STATE_CHANGE, t.data); - }, t.prototype._onMessageReceived = function (t) { - const e = this; const i = t.data; const n = i.filter((t => t.type === p.TYPES.MSG_TEXT));d.default(n) || this._outerEmitter.emit(u.default.TEXT_MESSAGE_RECEIVED, n);const o = i.filter((t => t.type === p.TYPES.MSG_GRP_TIP && t.payload.operationType === p.TYPES.GRP_TIP_MBR_JOIN));d.default(o) || this._outerEmitter.emit(u.default.REMOTE_USER_JOIN, o);const r = i.filter((t => t.type === p.TYPES.MSG_GRP_TIP && t.payload.operationType === p.TYPES.GRP_TIP_MBR_QUIT));d.default(r) || this._outerEmitter.emit(u.default.REMOTE_USER_LEAVE, r);const a = i.filter((t => t.type === p.TYPES.MSG_CUSTOM)); const l = [];a.forEach(((t) => { - let i; const n = t.payload.data; let o = !0;try { - i = JSON.parse(n); - } catch (t) { - o = !1; - } if (o) { - const r = i.businessID; const a = i.actionType;if (1 === r) switch (a) { - case s.ActionType.INVITE:e._onNewInvitationReceived(i);break;case s.ActionType.REJECT_INVITE:e._onInviteeRejected(i);break;case s.ActionType.ACCEPT_INVITE:e._onInviteeAccepted(i);break;case s.ActionType.CANCEL_INVITE:e._onInvitationCancelled(i);break;case s.ActionType.INVITE_TIMEOUT:e._onInvitationTimeout(i); - } else { - if ('av_call' === r) return !0;c.default.warn(`TSignaling._onMessageReceived unknown businessID=${r}`), l.push(t); - } - } else l.push(t); - })), d.default(l) || this._outerEmitter.emit(u.default.CUSTOM_MESSAGE_RECEIVED, l); - }, t.prototype._hasLocalInviteInfo = function (t, e) { - const i = t.inviteID; const n = t.groupID;if (c.default.log(`TSignaling._hasLocalInviteInfo inviteID=${i} groupID=${n}`), !this._inviteInfoMap.has(i)) return !1;const o = this._inviteInfoMap.get(i).inviteeList;return !n || (e ? o.length > 0 : o.length > 0 && o.includes(this._userID)); - }, t.prototype._startTimer = function (t, e) { - const i = this;void 0 === e && (e = !0);const n = t.timeout;if (c.default.log(`TSignaling._startTimer timeout=${n} isInvitator=${e} timeoutStatus=${0 === n}`), 0 !== n) var o = e ? n + 5 : n, r = 1, s = setInterval((() => { - const n = i._hasLocalInviteInfo(t, e);c.default.log(`TSignaling.setInterval hasInviteInfo=${n}`), r < o && n ? ++r : (n && i._sendTimeoutNotice(t, e), clearInterval(s)); - }), 1e3); - }, t.prototype._sendTimeoutNotice = function (t, e) { - return n(this, void 0, void 0, (function () { - let i; let n; let r; let a; let l; let d; let f; let _;return o(this, (function (o) { - switch (o.label) { - case 0:return i = t.inviteID, n = t.groupID, r = t.inviteeList, a = t.inviter, l = t.data, d = e ? n || r[0] : n || a, c.default.log(`TSignaling._sendTimeoutNotice inviteID=${i} to=${d} isInvitator=${e}`), f = { businessID: s.BusinessID.SIGNAL, inviteID: i, inviter: a, actionType: s.ActionType.INVITE_TIMEOUT, inviteeList: e ? r : [this._userID], data: l, timeout: 0, groupID: n }, [4, this._sendCustomMessage(d, f)];case 1:return (_ = o.sent()) && 0 === _.code && (this._outerEmitter.emit(u.default.INVITATION_TIMEOUT, { inviter: a, inviteID: i, groupID: n, inviteeList: f.inviteeList, isSelfTimeout: !0 }), e ? this._deleteInviteInfoByID(i) : this._updateLocalInviteInfo(f)), [2, _]; - } - })); - })); - }, t.prototype._onNewInvitationReceived = function (e) { - const i = e.inviteID; const n = e.inviter; const o = e.inviteeList; const r = e.groupID; const s = e.data; const a = o.includes(this._userID);c.default.log('TSignaling._onNewInvitationReceived', e, `myselfIncluded=${a}`);const u = JSON.parse(s);r && (0 === u.call_end || d.default(u.room_id) || d.default(u.data.room_id)) ? this._outerEmitter.emit(t.EVENT.NEW_INVITATION_RECEIVED, { inviteID: i, inviter: n, groupID: r, inviteeList: o, data: e.data || '' }) : (r && a || !r) && (this._inviteInfoMap.set(i, e), this._outerEmitter.emit(t.EVENT.NEW_INVITATION_RECEIVED, { inviteID: i, inviter: n, groupID: r, inviteeList: o, data: e.data || '' }), this._startTimer(e, !1)); - }, t.prototype._onInviteeRejected = function (t) { - const e = t.inviteID; const i = t.inviter; const n = t.groupID; const o = this._inviteInfoMap.has(e);c.default.log(`TSignaling._onInviteeRejected inviteID=${e} hasInviteID=${o} inviter=${i} groupID=${n}`), (n && o || !n) && (this._updateLocalInviteInfo(t), this._outerEmitter.emit(u.default.INVITEE_REJECTED, { inviteID: e, inviter: i, groupID: n, invitee: t.inviteeList[0], data: t.data || '' })); - }, t.prototype._onInviteeAccepted = function (t) { - const e = t.inviteID; const i = t.inviter; const n = t.groupID; const o = this._inviteInfoMap.has(e);c.default.log(`TSignaling._onInviteeAccepted inviteID=${e} hasInviteID=${o} inviter=${i} groupID=${n}`), (n && o || !n) && (this._updateLocalInviteInfo(t), this._outerEmitter.emit(u.default.INVITEE_ACCEPTED, { inviteID: e, inviter: i, groupID: n, invitee: t.inviteeList[0], data: t.data || '' })); - }, t.prototype._onInvitationCancelled = function (t) { - const e = t.inviteID; const i = t.inviter; const n = t.groupID; const o = this._inviteInfoMap.has(e);c.default.log(`TSignaling._onInvitationCancelled inviteID=${e} hasInviteID=${o} inviter=${i} groupID=${n}`), (n && o || !n) && (this._deleteInviteInfoByID(e), this._outerEmitter.emit(u.default.INVITATION_CANCELLED, { inviteID: e, inviter: i, groupID: n, data: t.data || '' })); - }, t.prototype._onInvitationTimeout = function (t) { - const e = t.inviteID; const i = t.inviter; const n = t.groupID; const o = this._inviteInfoMap.has(e);c.default.log(`TSignaling._onInvitationTimeout inviteID=${e} hasInviteID=${o} inviter=${i} groupID=${n}`), (n && o || !n) && (this._updateLocalInviteInfo(t), this._outerEmitter.emit(u.default.INVITATION_TIMEOUT, { inviteID: e, inviter: i, groupID: n, inviteeList: t.inviteeList, isSelfTimeout: !1 })); - }, t.prototype._updateLocalInviteInfo = function (t) { - const e = t.inviteID; const i = t.inviter; const n = t.inviteeList; const o = t.groupID;if (c.default.log(`TSignaling._updateLocalInviteInfo inviteID=${e} inviter=${i} groupID=${o}`), o) { - if (this._inviteInfoMap.has(e)) { - const r = n[0]; const s = this._inviteInfoMap.get(e).inviteeList;s.includes(r) && (s.splice(s.indexOf(r), 1), c.default.log(`TSignaling._updateLocalInviteInfo remove ${r} from localInviteeList. ${s.length} invitees left`)), 0 === s.length && this._deleteInviteInfoByID(e); - } - } else this._deleteInviteInfoByID(e); - }, t.prototype._deleteInviteInfoByID = function (t) { - this._inviteInfoMap.has(t) && (c.default.log(`TSignaling._deleteInviteInfoByID remove ${t} from inviteInfoMap.`), this._inviteInfoMap.delete(t)); - }, t.prototype._sendCustomMessage = function (t, e, i) { - return n(this, void 0, void 0, (function () { - let n; let r; let a; let u;return o(this, (function (o) { - return n = e.groupID, r = this._tim.createCustomMessage({ to: t, conversationType: n ? p.TYPES.CONV_GROUP : p.TYPES.CONV_C2C, priority: p.TYPES.MSG_PRIORITY_HIGH, payload: { data: JSON.stringify(e) } }), e.actionType === s.ActionType.INVITE ? (u = { title: (a = i || {}).title || '', description: a.description || '您有一个通话请求', androidOPPOChannelID: a.androidOPPOChannelID || '', extension: this._handleOfflineInfo(e) }, c.default.log(`TSignaling.offlinePushInfo ${JSON.stringify(u)}`), [2, this._tim.sendMessage(r, { offlinePushInfo: u })]) : [2, this._tim.sendMessage(r)]; - })); - })); - }, t.prototype._handleOfflineInfo = function (t) { - const e = { action: t.actionType, call_type: t.groupID ? 2 : 1, room_id: t.data.room_id, call_id: t.inviteID, timeout: t.data.timeout, version: 4, invited_list: t.inviteeList };t.groupID && (e.group_id = t.groupID);const i = { entity: { action: 2, chatType: t.groupID ? 2 : 1, content: JSON.stringify(e), sendTime: parseInt(`${Date.now() / 1e3}`), sender: t.inviter, version: 1 } }; const n = JSON.stringify(i);return c.default.log(`TSignaling._handleOfflineInfo ${n}`), n; - }, t.EVENT = u.default, t.TYPES = l.default, t; - }());e.default = g; -}, function (t, e, i) { - 'use strict';let n; let o; let r;Object.defineProperty(e, '__esModule', { value: !0 }), e.ErrorCode = e.BusinessID = e.ActionType = void 0, (function (t) { - t[t.INVITE = 1] = 'INVITE', t[t.CANCEL_INVITE = 2] = 'CANCEL_INVITE', t[t.ACCEPT_INVITE = 3] = 'ACCEPT_INVITE', t[t.REJECT_INVITE = 4] = 'REJECT_INVITE', t[t.INVITE_TIMEOUT = 5] = 'INVITE_TIMEOUT'; - }(n || (n = {}))), e.ActionType = n, (function (t) { - t[t.SIGNAL = 1] = 'SIGNAL'; - }(o || (o = {}))), e.BusinessID = o, (function (t) { - t[t.ERR_INVALID_PARAMETERS = 6017] = 'ERR_INVALID_PARAMETERS', t[t.ERR_SDK_SIGNALING_INVALID_INVITE_ID = 8010] = 'ERR_SDK_SIGNALING_INVALID_INVITE_ID', t[t.ERR_SDK_SIGNALING_NO_PERMISSION = 8011] = 'ERR_SDK_SIGNALING_NO_PERMISSION'; - }(r || (r = {}))), e.ErrorCode = r; -}, function (t, e, i) { - 'use strict';i.r(e), i.d(e, 'default', (() => s));const n = Function.prototype.apply; const o = new WeakMap;function r(t) { - return o.has(t) || o.set(t, {}), o.get(t); - } class s { - constructor(t = null, e = console) { - const i = r(this);return i._events = new Set, i._callbacks = {}, i._console = e, i._maxListeners = null === t ? null : parseInt(t, 10), this; - }_addCallback(t, e, i, n) { - return this._getCallbacks(t).push({ callback: e, context: i, weight: n }), this._getCallbacks(t).sort((t, e) => t.weight > e.weight), this; - }_getCallbacks(t) { - return r(this)._callbacks[t]; - }_getCallbackIndex(t, e) { - return this._has(t) ? this._getCallbacks(t).findIndex(t => t.callback === e) : null; - }_achieveMaxListener(t) { - return null !== r(this)._maxListeners && r(this)._maxListeners <= this.listenersNumber(t); - }_callbackIsExists(t, e, i) { - const n = this._getCallbackIndex(t, e); const o = -1 !== n ? this._getCallbacks(t)[n] : void 0;return -1 !== n && o && o.context === i; - }_has(t) { - return r(this)._events.has(t); - }on(t, e, i = null, n = 1) { - const o = r(this);if ('function' !== typeof e) throw new TypeError(`${e} is not a function`);return this._has(t) ? (this._achieveMaxListener(t) && o._console.warn(`Max listeners (${o._maxListeners}) for event "${t}" is reached!`), this._callbackIsExists(...arguments) && o._console.warn(`Event "${t}" already has the callback ${e}.`)) : (o._events.add(t), o._callbacks[t] = []), this._addCallback(...arguments), this; - }once(t, e, i = null, o = 1) { - const r = (...o) => (this.off(t, r), n.call(e, i, o));return this.on(t, r, i, o); - }off(t, e = null) { - const i = r(this);let n;return this._has(t) && (null === e ? (i._events.delete(t), i._callbacks[t] = null) : (n = this._getCallbackIndex(t, e), -1 !== n && (i._callbacks[t].splice(n, 1), this.off(...arguments)))), this; - }emit(t, ...e) { - return this._has(t) && this._getCallbacks(t).forEach(t => n.call(t.callback, t.context, e)), this; - }clear() { - const t = r(this);return t._events.clear(), t._callbacks = {}, this; - }listenersNumber(t) { - return this._has(t) ? this._getCallbacks(t).length : null; - } - } -}, function (t, e) { - let i;i = (function () { - return this; - }());try { - i = i || new Function('return this')(); - } catch (t) { - 'object' === typeof window && (i = window); - }t.exports = i; -}, function (t, e, i) { - 'use strict';i.r(e);const n = i(0);const o = Object.prototype.hasOwnProperty;e.default = function (t) { - if (null == t) return !0;if ('boolean' === typeof t) return !1;if ('number' === typeof t) return 0 === t;if ('string' === typeof t) return 0 === t.length;if ('function' === typeof t) return 0 === t.length;if (Array.isArray(t)) return 0 === t.length;if (t instanceof Error) return '' === t.message;if (Object(n.f)(t)) { - for (const e in t) if (o.call(t, e)) return !1;return !0; - } return !!(Object(n.e)(t) || Object(n.g)(t) || Object(n.c)(t)) && 0 === t.size; - }; -}, function (t, e, i) { - 'use strict';i.r(e);class n extends Error { - constructor(t) { - super(), this.code = t.code, this.message = t.message, this.data = t.data || {}; - } - }e.default = n; -}, function (t, e, i) { - 'use strict';i.r(e);const n = i(1); const o = i(4); const r = i.n(o);e.default = class { - constructor() { - this._funcMap = new Map; - }defense(t, e, i) { - if ('string' !== typeof t) return null;if (0 === t.length) return null;if ('function' !== typeof e) return null;if (this._funcMap.has(t) && this._funcMap.get(t).has(e)) return this._funcMap.get(t).get(e);this._funcMap.has(t) || this._funcMap.set(t, new Map);let n = null;return this._funcMap.get(t).has(e) ? n = this._funcMap.get(t).get(e) : (n = this._pack(t, e, i), this._funcMap.get(t).set(e, n)), n; - }defenseOnce(t, e, i) { - return 'function' !== typeof e ? null : this._pack(t, e, i); - }find(t, e) { - return 'string' !== typeof t || 0 === t.length || 'function' !== typeof e ? null : this._funcMap.has(t) ? this._funcMap.get(t).has(e) ? this._funcMap.get(t).get(e) : (n.default.log(`SafetyCallback.find: 找不到 func —— ${t}/${'' !== e.name ? e.name : '[anonymous]'}`), null) : (n.default.log(`SafetyCallback.find: 找不到 eventName-${t} 对应的 func`), null); - }delete(t, e) { - return 'function' === typeof e && (!!this._funcMap.has(t) && (!!this._funcMap.get(t).has(e) && (this._funcMap.get(t).delete(e), 0 === this._funcMap.get(t).size && this._funcMap.delete(t), !0))); - }_pack(t, e, i) { - return function () { - try { - e.apply(i, Array.from(arguments)); - } catch (e) { - const i = Object.values(r.a).indexOf(t); const o = Object.keys(r.a)[i];n.default.error(`接入侧事件 EVENT.${o} 对应的回调函数逻辑存在问题,请检查!`, e); - } - }; - } - }; -}, function (t, e, i) { +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("tim-wx-sdk")):"function"==typeof define&&define.amd?define(["tim-wx-sdk"],e):"object"==typeof exports?exports.TSignaling=e(require("tim-wx-sdk")):t.TSignaling=e(t.TIM)}(window,(function(t){return function(t){var e={};function i(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,i),o.l=!0,o.exports}return i.m=t,i.c=e,i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)i.d(n,o,function(e){return t[e]}.bind(null,o));return n},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=5)}([function(t,e,i){"use strict";i.d(e,"e",(function(){return p})),i.d(e,"g",(function(){return g})),i.d(e,"c",(function(){return h})),i.d(e,"f",(function(){return v})),i.d(e,"b",(function(){return m})),i.d(e,"d",(function(){return T})),i.d(e,"a",(function(){return y})),i.d(e,"h",(function(){return N}));const n="undefined"!=typeof window,o=("undefined"!=typeof wx&&wx.getSystemInfoSync,n&&window.navigator&&window.navigator.userAgent||""),r=/AppleWebKit\/([\d.]+)/i.exec(o),s=(r&&parseFloat(r.pop()),/iPad/i.test(o)),a=/iPhone/i.test(o)&&!s,u=/iPod/i.test(o),l=a||s||u,c=(function(){const t=o.match(/OS (\d+)_/i);t&&t[1]&&t[1]}(),/Android/i.test(o)),d=function(){const t=o.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);if(!t)return null;const e=t[1]&&parseFloat(t[1]),i=t[2]&&parseFloat(t[2]);return e&&i?parseFloat(t[1]+"."+t[2]):e||null}(),f=(c&&/webkit/i.test(o),/Firefox/i.test(o),/Edge/i.test(o)),_=!f&&/Chrome/i.test(o),I=(function(){const t=o.match(/Chrome\/(\d+)/);t&&t[1]&&parseFloat(t[1])}(),/MSIE/.test(o),/MSIE\s8\.0/.test(o),function(){const t=/MSIE\s(\d+)\.\d/.exec(o);let e=t&&parseFloat(t[1]);!e&&/Trident\/7.0/i.test(o)&&/rv:11.0/.test(o)&&(e=11)}(),/Safari/i.test(o),/TBS\/\d+/i.test(o));(function(){const t=o.match(/TBS\/(\d+)/i);if(t&&t[1])t[1]})(),!I&&/MQQBrowser\/\d+/i.test(o),!I&&/ QQBrowser\/\d+/i.test(o),/(micromessenger|webbrowser)/i.test(o),/Windows/i.test(o),/MAC OS X/i.test(o),/MicroMessenger/i.test(o);i(2),i(1);const p=function(t){return"map"===D(t)},g=function(t){return"set"===D(t)},h=function(t){return"file"===D(t)},v=function(t){if("object"!=typeof t||null===t)return!1;const e=Object.getPrototypeOf(t);if(null===e)return!0;let i=e;for(;null!==Object.getPrototypeOf(i);)i=Object.getPrototypeOf(i);return e===i},E=function(t){return"function"==typeof Array.isArray?Array.isArray(t):"array"===D(t)},m=function(t){return E(t)||function(t){return null!==t&&"object"==typeof t}(t)},T=function(t){return t instanceof Error},D=function(t){return Object.prototype.toString.call(t).match(/^\[object (.*)\]$/)[1].toLowerCase()};let S=0;Date.now||(Date.now=function(){return(new Date).getTime()});const y={now:function(){0===S&&(S=Date.now()-1);const t=Date.now()-S;return t>4294967295?(S+=4294967295,Date.now()-S):t},utc:function(){return Math.round(Date.now()/1e3)}},N=function(t){return JSON.stringify(t,["message","code"])}},function(t,e,i){"use strict";i.r(e);var n=i(3),o=i(0);let r=0;const s=new Map;function a(){const t=new Date;return"TSignaling "+t.toLocaleTimeString("en-US",{hour12:!1})+"."+function(t){let e;switch(t.toString().length){case 1:e="00"+t;break;case 2:e="0"+t;break;default:e=t}return e}(t.getMilliseconds())+":"}const u={_data:[],_length:0,_visible:!1,arguments2String(t){let e;if(1===t.length)e=a()+t[0];else{e=a();for(let i=0,n=t.length;i0&&o[o.length-1])||6!==r[0]&&2!==r[0])){s=0;continue}if(3===r[0]&&(!o||r[1]>o[0]&&r[1]t.weight>e.weight),this}_getCallbacks(t){return r(this)._callbacks[t]}_getCallbackIndex(t,e){return this._has(t)?this._getCallbacks(t).findIndex(t=>t.callback===e):null}_achieveMaxListener(t){return null!==r(this)._maxListeners&&r(this)._maxListeners<=this.listenersNumber(t)}_callbackIsExists(t,e,i){const n=this._getCallbackIndex(t,e),o=-1!==n?this._getCallbacks(t)[n]:void 0;return-1!==n&&o&&o.context===i}_has(t){return r(this)._events.has(t)}on(t,e,i=null,n=1){const o=r(this);if("function"!=typeof e)throw new TypeError(e+" is not a function");return this._has(t)?(this._achieveMaxListener(t)&&o._console.warn(`Max listeners (${o._maxListeners}) for event "${t}" is reached!`),this._callbackIsExists(...arguments)&&o._console.warn(`Event "${t}" already has the callback ${e}.`)):(o._events.add(t),o._callbacks[t]=[]),this._addCallback(...arguments),this}once(t,e,i=null,o=1){const r=(...o)=>(this.off(t,r),n.call(e,i,o));return this.on(t,r,i,o)}off(t,e=null){const i=r(this);let n;return this._has(t)&&(null===e?(i._events.delete(t),i._callbacks[t]=null):(n=this._getCallbackIndex(t,e),-1!==n&&(i._callbacks[t].splice(n,1),this.off(...arguments)))),this}emit(t,...e){return this._has(t)&&this._getCallbacks(t).forEach(t=>n.call(t.callback,t.context,e)),this}clear(){const t=r(this);return t._events.clear(),t._callbacks={},this}listenersNumber(t){return this._has(t)?this._getCallbacks(t).length:null}}},function(t,e){var i;i=function(){return this}();try{i=i||new Function("return this")()}catch(t){"object"==typeof window&&(i=window)}t.exports=i},function(t,e,i){"use strict";i.r(e);var n=i(0);const o=Object.prototype.hasOwnProperty;e.default=function(t){if(null==t)return!0;if("boolean"==typeof t)return!1;if("number"==typeof t)return 0===t;if("string"==typeof t)return 0===t.length;if("function"==typeof t)return 0===t.length;if(Array.isArray(t))return 0===t.length;if(t instanceof Error)return""===t.message;if(Object(n.f)(t)){for(const e in t)if(o.call(t,e))return!1;return!0}return!!(Object(n.e)(t)||Object(n.g)(t)||Object(n.c)(t))&&0===t.size}},function(t,e,i){"use strict";i.r(e);class n extends Error{constructor(t){super(),this.code=t.code,this.message=t.message,this.data=t.data||{}}}e.default=n},function(t,e,i){"use strict";i.r(e);var n=i(1),o=i(4),r=i.n(o);e.default=class{constructor(){this._funcMap=new Map}defense(t,e,i){if("string"!=typeof t)return null;if(0===t.length)return null;if("function"!=typeof e)return null;if(this._funcMap.has(t)&&this._funcMap.get(t).has(e))return this._funcMap.get(t).get(e);this._funcMap.has(t)||this._funcMap.set(t,new Map);let n=null;return this._funcMap.get(t).has(e)?n=this._funcMap.get(t).get(e):(n=this._pack(t,e,i),this._funcMap.get(t).set(e,n)),n}defenseOnce(t,e,i){return"function"!=typeof e?null:this._pack(t,e,i)}find(t,e){return"string"!=typeof t||0===t.length||"function"!=typeof e?null:this._funcMap.has(t)?this._funcMap.get(t).has(e)?this._funcMap.get(t).get(e):(n.default.log(`SafetyCallback.find: 找不到 func —— ${t}/${""!==e.name?e.name:"[anonymous]"}`),null):(n.default.log(`SafetyCallback.find: 找不到 eventName-${t} 对应的 func`),null)}delete(t,e){return"function"==typeof e&&(!!this._funcMap.has(t)&&(!!this._funcMap.get(t).has(e)&&(this._funcMap.get(t).delete(e),0===this._funcMap.get(t).size&&this._funcMap.delete(t),!0)))}_pack(t,e,i){return function(){try{e.apply(i,Array.from(arguments))}catch(e){const i=Object.values(r.a).indexOf(t),o=Object.keys(r.a)[i];n.default.error(`接入侧事件 EVENT.${o} 对应的回调函数逻辑存在问题,请检查!`,e)}}}}},function(t,e,i){ /** * UUID.js - RFC-compliant UUID Generator for JavaScript * * @file * @author LiosK - * @version v4.2.8 - * @license Apache License 2.0: Copyright (c) 2010-2021 LiosK + * @version v4.2.5 + * @license Apache License 2.0: Copyright (c) 2010-2020 LiosK */ - let n;n = (function (e) { - 'use strict';function n() { - const t = o._getRandomInt;this.timestamp = 0, this.sequence = t(14), this.node = 1099511627776 * (1 | t(8)) + t(40), this.tick = t(4); - } function o() {} return o.generate = function () { - const t = o._getRandomInt; const e = o._hexAligner;return `${e(t(32), 8)}-${e(t(16), 4)}-${e(16384 | t(12), 4)}-${e(32768 | t(14), 4)}-${e(t(48), 12)}`; - }, o._getRandomInt = function (t) { - if (t < 0 || t > 53) return NaN;const e = 0 | 1073741824 * Math.random();return t > 30 ? e + 1073741824 * (0 | Math.random() * (1 << t - 30)) : e >>> 30 - t; - }, o._hexAligner = function (t, e) { - for (var i = t.toString(16), n = e - i.length, o = '0';n > 0;n >>>= 1, o += o)1 & n && (i = o + i);return i; - }, o.overwrittenUUID = e, (function () { - const t = o._getRandomInt;o.useMathRandom = function () { - o._getRandomInt = t; - };let e = null; let n = t;'undefined' !== typeof window && (e = window.crypto || window.msCrypto) ? e.getRandomValues && 'undefined' !== typeof Uint32Array && (n = function (t) { - if (t < 0 || t > 53) return NaN;let i = new Uint32Array(t > 32 ? 2 : 1);return i = e.getRandomValues(i) || i, t > 32 ? i[0] + 4294967296 * (i[1] >>> 64 - t) : i[0] >>> 32 - t; - }) : (e = i(13)) && e.randomBytes && (n = function (t) { - if (t < 0 || t > 53) return NaN;const i = e.randomBytes(t > 32 ? 8 : 4); const n = i.readUInt32BE(0);return t > 32 ? n + 4294967296 * (i.readUInt32BE(4) >>> 64 - t) : n >>> 32 - t; - }), o._getRandomInt = n; - }()), o.FIELD_NAMES = ['timeLow', 'timeMid', 'timeHiAndVersion', 'clockSeqHiAndReserved', 'clockSeqLow', 'node'], o.FIELD_SIZES = [32, 16, 16, 8, 8, 48], o.genV4 = function () { - const t = o._getRandomInt;return (new o)._init(t(32), t(16), 16384 | t(12), 128 | t(6), t(8), t(48)); - }, o.parse = function (t) { - let e;if (e = /^\s*(urn:uuid:|\{)?([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{2})([0-9a-f]{2})-([0-9a-f]{12})(\})?\s*$/i.exec(t)) { - const i = e[1] || ''; const n = e[8] || '';if (i + n === '' || '{' === i && '}' === n || 'urn:uuid:' === i.toLowerCase() && '' === n) return (new o)._init(parseInt(e[2], 16), parseInt(e[3], 16), parseInt(e[4], 16), parseInt(e[5], 16), parseInt(e[6], 16), parseInt(e[7], 16)); - } return null; - }, o.prototype._init = function () { - const t = o.FIELD_NAMES; const e = o.FIELD_SIZES; const i = o._binAligner; const n = o._hexAligner;this.intFields = new Array(6), this.bitFields = new Array(6), this.hexFields = new Array(6);for (let r = 0;r < 6;r++) { - const s = parseInt(arguments[r] || 0);this.intFields[r] = this.intFields[t[r]] = s, this.bitFields[r] = this.bitFields[t[r]] = i(s, e[r]), this.hexFields[r] = this.hexFields[t[r]] = n(s, e[r] >>> 2); - } return this.version = this.intFields.timeHiAndVersion >>> 12 & 15, this.bitString = this.bitFields.join(''), this.hexNoDelim = this.hexFields.join(''), this.hexString = `${this.hexFields[0]}-${this.hexFields[1]}-${this.hexFields[2]}-${this.hexFields[3]}${this.hexFields[4]}-${this.hexFields[5]}`, this.urn = `urn:uuid:${this.hexString}`, this; - }, o._binAligner = function (t, e) { - for (var i = t.toString(2), n = e - i.length, o = '0';n > 0;n >>>= 1, o += o)1 & n && (i = o + i);return i; - }, o.prototype.toString = function () { - return this.hexString; - }, o.prototype.equals = function (t) { - if (!(t instanceof o)) return !1;for (let e = 0;e < 6;e++) if (this.intFields[e] !== t.intFields[e]) return !1;return !0; - }, o.NIL = (new o)._init(0, 0, 0, 0, 0, 0), o.genV1 = function () { - null == o._state && o.resetState();const t = (new Date).getTime(); const e = o._state;t != e.timestamp ? (t < e.timestamp && e.sequence++, e.timestamp = t, e.tick = o._getRandomInt(4)) : Math.random() < o._tsRatio && e.tick < 9984 ? e.tick += 1 + o._getRandomInt(4) : e.sequence++;const i = o._getTimeFieldValues(e.timestamp); const n = i.low + e.tick; const r = 4095 & i.hi | 4096;e.sequence &= 16383;const s = e.sequence >>> 8 | 128; const a = 255 & e.sequence;return (new o)._init(n, i.mid, r, s, a, e.node); - }, o.resetState = function () { - o._state = new n; - }, o._tsRatio = 1 / 4, o._state = null, o._getTimeFieldValues = function (t) { - const e = t - Date.UTC(1582, 9, 15); const i = e / 4294967296 * 1e4 & 268435455;return { low: 1e4 * (268435455 & e) % 4294967296, mid: 65535 & i, hi: i >>> 16, timestamp: e }; - }, 'object' === typeof t.exports && (t.exports = o), o; - }(n)); -}, function (t, e) {}, function (e, i) { - e.exports = t; -}, function (t) { - t.exports = JSON.parse('{"name":"tsignaling","version":"0.7.0-beta.1","description":"腾讯云 Web 信令 SDK","main":"./src/index.ts","scripts":{"lint":"./node_modules/.bin/eslint ./src","fix":"./node_modules/.bin/eslint --fix ./src","ts2js":"tsc src/index.ts --outDir build/ts2js","doc":"npm run ts2js && npm run doc:clean && npm run doc:build","doc:build":"./node_modules/.bin/jsdoc -c build/jsdoc/jsdoc.json && node ./build/jsdoc/fix-doc.js","doc:clean":"node ./build/jsdoc/clean-doc.js","build:wx":"cross-env NODE_ENV=wx webpack --config webpack.prod.config.js","build:web":"node node_modules/cross-env/src/bin/cross-env.js NODE_ENV=web node_modules/webpack/bin/webpack.js --config webpack.prod.config.js","build:package":"node build/package-bundle.js","prerelease":"npm run build:web && npm run build:wx && npm run build:package && node ./build/copy.js","start:wx":"cross-env NODE_ENV=wx webpack-dev-server --config webpack.config.js","start:web":"node node_modules/cross-env/src/bin/cross-env.js NODE_ENV=web node_modules/webpack-dev-server/bin/webpack-dev-server.js --config webpack.dev.config.js","build_withcopy":"npm run build:web && cp dist/npm/tsignaling-js.js ../TIM-demo-web/node_modules/tsignaling/tsignaling-js.js","build_withcopy:mp":"npm run build:wx && cp dist/npm/tsignaling-wx.js ../TIM-demo-mini/static/component/TRTCCalling/utils/tsignaling-wx.js","changelog":"conventional-changelog -p angular -i CHANGELOG.md -s -r 0 && cp CHANGELOG.md build/jsdoc/tutorials/CHANGELOG.md"},"husky":{"hooks":{"pre-commit":"npm run lint"}},"lint-staged":{"*.{.ts,.tsx}":["eslint","git add"]},"keywords":["腾讯云","即时通信","信令"],"author":"","license":"ISC","devDependencies":{"conventional-changelog-cli":"^2.1.1","cross-env":"^7.0.2","fs-extra":"^9.0.1","html-webpack-plugin":"^4.3.0","ts-loader":"^7.0.5","typescript":"^3.9.9","webpack":"^4.43.0","webpack-cli":"^3.3.11","webpack-dev-server":"^3.11.0"},"dependencies":{"@typescript-eslint/eslint-plugin":"^4.22.1","@typescript-eslint/parser":"^4.22.1","EventEmitter":"^1.0.0","docdash-blue":"^1.1.3","eslint":"^5.16.0","eslint-config-google":"^0.13.0","eslint-plugin-classes":"^0.1.1","jsdoc":"^3.6.4","jsdoc-plugin-typescript":"^2.0.5","pretty":"^2.0.0","replace":"^1.2.0","uuidjs":"^4.2.5"}}'); -}])).default))); +var n;n=function(e){"use strict";function n(){var t=o._getRandomInt;this.timestamp=0,this.sequence=t(14),this.node=1099511627776*(1|t(8))+t(40),this.tick=t(4)}function o(){}return o.generate=function(){var t=o._getRandomInt,e=o._hexAligner;return e(t(32),8)+"-"+e(t(16),4)+"-"+e(16384|t(12),4)+"-"+e(32768|t(14),4)+"-"+e(t(48),12)},o._getRandomInt=function(t){if(t<0||t>53)return NaN;var e=0|1073741824*Math.random();return t>30?e+1073741824*(0|Math.random()*(1<>>30-t},o._hexAligner=function(t,e){for(var i=t.toString(16),n=e-i.length,o="0";n>0;n>>>=1,o+=o)1&n&&(i=o+i);return i},o.overwrittenUUID=e,function(){var t=o._getRandomInt;o.useMathRandom=function(){o._getRandomInt=t};var e=null,n=t;"undefined"!=typeof window&&(e=window.crypto||window.msCrypto)?e.getRandomValues&&"undefined"!=typeof Uint32Array&&(n=function(t){if(t<0||t>53)return NaN;var i=new Uint32Array(t>32?2:1);return i=e.getRandomValues(i)||i,t>32?i[0]+4294967296*(i[1]>>>64-t):i[0]>>>32-t}):(e=i(13))&&e.randomBytes&&(n=function(t){if(t<0||t>53)return NaN;var i=e.randomBytes(t>32?8:4),n=i.readUInt32BE(0);return t>32?n+4294967296*(i.readUInt32BE(4)>>>64-t):n>>>32-t}),o._getRandomInt=n}(),o.FIELD_NAMES=["timeLow","timeMid","timeHiAndVersion","clockSeqHiAndReserved","clockSeqLow","node"],o.FIELD_SIZES=[32,16,16,8,8,48],o.genV4=function(){var t=o._getRandomInt;return(new o)._init(t(32),t(16),16384|t(12),128|t(6),t(8),t(48))},o.parse=function(t){var e;if(e=/^\s*(urn:uuid:|\{)?([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{2})([0-9a-f]{2})-([0-9a-f]{12})(\})?\s*$/i.exec(t)){var i=e[1]||"",n=e[8]||"";if(i+n===""||"{"===i&&"}"===n||"urn:uuid:"===i.toLowerCase()&&""===n)return(new o)._init(parseInt(e[2],16),parseInt(e[3],16),parseInt(e[4],16),parseInt(e[5],16),parseInt(e[6],16),parseInt(e[7],16))}return null},o.prototype._init=function(){var t=o.FIELD_NAMES,e=o.FIELD_SIZES,i=o._binAligner,n=o._hexAligner;this.intFields=new Array(6),this.bitFields=new Array(6),this.hexFields=new Array(6);for(var r=0;r<6;r++){var s=parseInt(arguments[r]||0);this.intFields[r]=this.intFields[t[r]]=s,this.bitFields[r]=this.bitFields[t[r]]=i(s,e[r]),this.hexFields[r]=this.hexFields[t[r]]=n(s,e[r]>>>2)}return this.version=this.intFields.timeHiAndVersion>>>12&15,this.bitString=this.bitFields.join(""),this.hexNoDelim=this.hexFields.join(""),this.hexString=this.hexFields[0]+"-"+this.hexFields[1]+"-"+this.hexFields[2]+"-"+this.hexFields[3]+this.hexFields[4]+"-"+this.hexFields[5],this.urn="urn:uuid:"+this.hexString,this},o._binAligner=function(t,e){for(var i=t.toString(2),n=e-i.length,o="0";n>0;n>>>=1,o+=o)1&n&&(i=o+i);return i},o.prototype.toString=function(){return this.hexString},o.prototype.equals=function(t){if(!(t instanceof o))return!1;for(var e=0;e<6;e++)if(this.intFields[e]!==t.intFields[e])return!1;return!0},o.NIL=(new o)._init(0,0,0,0,0,0),o.genV1=function(){null==o._state&&o.resetState();var t=(new Date).getTime(),e=o._state;t!=e.timestamp?(t>>8|128,a=255&e.sequence;return(new o)._init(n,i.mid,r,s,a,e.node)},o.resetState=function(){o._state=new n},o._tsRatio=1/4,o._state=null,o._getTimeFieldValues=function(t){var e=t-Date.UTC(1582,9,15),i=e/4294967296*1e4&268435455;return{low:1e4*(268435455&e)%4294967296,mid:65535&i,hi:i>>>16,timestamp:e}},"object"==typeof t.exports&&(t.exports=o),o}(n)},function(t,e){},function(e,i){e.exports=t},function(t){t.exports=JSON.parse('{"name":"tsignaling","version":"0.10.0","description":"腾讯云 Web 信令 SDK","main":"./src/index.ts","scripts":{"lint":"./node_modules/.bin/eslint ./src","fix":"./node_modules/.bin/eslint --fix ./src","ts2js":"tsc src/index.ts --outDir build/ts2js","doc":"npm run ts2js && npm run doc:clean && npm run doc:build","doc:build":"./node_modules/.bin/jsdoc -c build/jsdoc/jsdoc.json && node ./build/jsdoc/fix-doc.js","doc:clean":"node ./build/jsdoc/clean-doc.js","build:wx":"cross-env NODE_ENV=wx webpack --config webpack.prod.config.js","build:web":"node node_modules/cross-env/src/bin/cross-env.js NODE_ENV=web node_modules/webpack/bin/webpack.js --config webpack.prod.config.js","build:package":"node build/package-bundle.js","prerelease":"npm run build:web && npm run build:wx && npm run build:package && node ./build/copy.js","start:wx":"cross-env NODE_ENV=wx webpack-dev-server --config webpack.config.js","start:web":"node node_modules/cross-env/src/bin/cross-env.js NODE_ENV=web node_modules/webpack-dev-server/bin/webpack-dev-server.js --config webpack.dev.config.js","build_withcopy":"npm run build:web && cp dist/npm/tsignaling-js.js ../TIM-demo-web/node_modules/tsignaling/tsignaling-js.js","build_withcopy:mp":"npm run build:wx && cp dist/npm/tsignaling-wx.js ../TIM-demo-mini/static/component/TRTCCalling/utils/tsignaling-wx.js","changelog":"cp CHANGELOG.md build/jsdoc/tutorials/CHANGELOG.md"},"husky":{"hooks":{"pre-commit":"npm run lint"}},"lint-staged":{"*.{.ts,.tsx}":["eslint","git add"]},"keywords":["腾讯云","即时通信","信令"],"author":"","license":"ISC","devDependencies":{"conventional-changelog-cli":"^2.1.1","cross-env":"^7.0.2","fs-extra":"^9.0.1","html-webpack-plugin":"^4.3.0","ts-loader":"^7.0.5","typescript":"^3.9.9","webpack":"^4.43.0","webpack-cli":"^3.3.11","webpack-dev-server":"^3.11.0"},"dependencies":{"@typescript-eslint/eslint-plugin":"^4.22.1","@typescript-eslint/parser":"^4.22.1","EventEmitter":"^1.0.0","docdash-blue":"^1.1.3","eslint":"^5.16.0","eslint-config-google":"^0.13.0","eslint-plugin-classes":"^0.1.1","jsdoc":"^3.6.4","jsdoc-plugin-typescript":"^2.0.5","pretty":"^2.0.0","replace":"^1.2.0","uuidjs":"^4.2.5"}}')}]).default})); \ No newline at end of file diff --git a/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/TRTCCalling/utils/event.js b/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/TRTCCalling/utils/event.js index c6dece9bd0..861fb06375 100644 --- a/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/TRTCCalling/utils/event.js +++ b/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/TRTCCalling/utils/event.js @@ -59,4 +59,4 @@ class EventEmitter { } } -module.exports = EventEmitter +export default EventEmitter diff --git a/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/TUICalling.js b/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/TUICalling.js index 9ce35ef0b8..9db56c3381 100644 --- a/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/TUICalling.js +++ b/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/TUICalling.js @@ -1,13 +1,11 @@ import TRTCCalling from './TRTCCalling/TRTCCalling.js'; - const TAG_NAME = 'TUICalling'; // 组件旨在跨终端维护一个通话状态管理机,以事件发布机制驱动上层进行管理,并通过API调用进行状态变更。 // 组件设计思路将UI和状态管理分离。您可以通过修改`component`文件夹下的文件,适配您的业务场景, // 在UI展示上,您可以通过属性的方式,将上层的用户头像,名称等数据传入组件内部,`static`下的icon和默认头像图片, // 只是为了展示基础的效果,您需要根据业务场景进行修改。 -// eslint-disable-next-line no-undef Component({ properties: { config: { @@ -37,8 +35,10 @@ Component({ remoteUsers: [], // 远程用户资料 screen: 'pusher', // 视屏通话中,显示大屏幕的流(只限1v1聊天 soundMode: 'speaker', // 声音模式 听筒/扬声器 + userList: null, //接受邀请的用户信息 }, + methods: { initCall() { // 收起键盘 @@ -62,6 +62,7 @@ Component({ console.log(`${TAG_NAME}, handleUserAccept, event${JSON.stringify(event)}`); this.setData({ callStatus: 'connection', + userList: event.data.userList, }); }, @@ -109,6 +110,9 @@ Component({ // 用户拒绝 handleInviteeReject(event) { console.log(`${TAG_NAME}, handleInviteeReject, event${JSON.stringify(event)}`); + if (this.data.playerList.length===0) { + this.reset(); + } wx.showToast({ title: `${this.handleCallingUser([event.data.invitee])}已拒绝`, }); @@ -116,6 +120,9 @@ Component({ // 用户不在线 handleNoResponse(event) { console.log(`${TAG_NAME}, handleNoResponse, event${JSON.stringify(event)}`); + if (this.data.playerList.length===0) { + this.reset(); + } wx.showToast({ title: `${this.handleCallingUser(event.data.timeoutUserList)}不在线`, }); @@ -123,6 +130,9 @@ Component({ // 用户忙线 handleLineBusy(event) { console.log(`${TAG_NAME}, handleLineBusy, event${JSON.stringify(event)}`); + if (this.data.playerList.length===0) { + this.reset(); + } wx.showToast({ title: `${this.handleCallingUser([event.data.invitee])}忙线中`, }); @@ -130,6 +140,9 @@ Component({ // 用户取消 handleCallingCancel(event) { console.log(`${TAG_NAME}, handleCallingCancel, event${JSON.stringify(event)}`); + if (this.data.playerList.length===0) { + this.reset(); + } wx.showToast({ title: `${this.handleCallingUser([event.data.invitee])}取消通话`, }); @@ -137,6 +150,9 @@ Component({ // 通话超时未应答 handleCallingTimeout(event) { console.log(`${TAG_NAME}, handleCallingTimeout, event${JSON.stringify(event)}`); + if (this.data.playerList.length===0) { + this.reset(); + } wx.showToast({ title: `${this.handleCallingUser(event.data.timeoutUserList)}超时无应答`, }); @@ -183,6 +199,7 @@ Component({ // 切换通话模式 handleCallMode(event) { this.data.config.type = event.data.type; + this.toggleSoundMode(); this.setData({ config: this.data.config, }); @@ -261,6 +278,10 @@ Component({ */ async call(params) { this.initCall(); + if (this.data.callStatus !== 'idle') { + console.warn(`${TAG_NAME}, call callStatus isn't idle`); + return; + } wx.$TRTCCalling.call({ userID: params.userID, type: params.type }).then((res) => { this.data.config.type = params.type; this.getUserProfile([params.userID]); @@ -285,6 +306,10 @@ Component({ */ async groupCall(params) { this.initCall(); + if (this.data.callStatus !== 'idle') { + console.warn(`${TAG_NAME}, groupCall callStatus isn't idle`); + return; + } wx.$TRTCCalling.groupCall({ userIDList: params.userIDList, type: params.type, groupID: params.groupID }).then((res) => { this.data.config.type = params.type; this.getUserProfile(params.userIDList); @@ -301,6 +326,7 @@ Component({ */ async accept() { wx.$TRTCCalling.accept().then((res) => { + console.log('accept', res); this.setData({ pusher: res.pusher, callStatus: 'connection', @@ -348,6 +374,7 @@ Component({ this.setData({ callStatus: 'idle', isSponsor: false, + soundMode: 'speaker', pusher: {}, // TRTC 本地流 playerList: [], // TRTC 远端流 }); @@ -371,6 +398,7 @@ Component({ case 'switchAudioCall': wx.$TRTCCalling.switchAudioCall().then((res) => { this.data.config.type = wx.$TRTCCalling.CALL_TYPE.AUDIO; + this.toggleSoundMode(); this.setData({ config: this.data.config, }); @@ -426,7 +454,8 @@ Component({ break; case 'switchAudioCall': wx.$TRTCCalling.switchAudioCall().then((res) => { - this.data.config.type = 1; + this.data.config.type = wx.$TRTCCalling.CALL_TYPE.AUDIO; + this.toggleSoundMode(); this.setData({ config: this.data.config, }); @@ -453,12 +482,12 @@ Component({ }, // 初始化TRTCCalling async init() { + this._addTSignalingEvent(); try { const res = await wx.$TRTCCalling.login({ userID: this.data.config.userID, userSig: this.data.config.userSig, }); - this._addTSignalingEvent(); return res; } catch (error) { throw new Error('TRTCCalling login failure', error); @@ -488,7 +517,7 @@ Component({ if (!wx.$TRTCCalling) { wx.$TRTCCalling = new TRTCCalling({ sdkAppID: this.data.config.sdkAppID, - tim: this.data.config.tim, + tim: wx.$tim, }); } wx.$TRTCCalling.initData(); diff --git a/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/TUICalling.wxml b/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/TUICalling.wxml index 8fd46f33f7..5141631870 100644 --- a/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/TUICalling.wxml +++ b/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/TUICalling.wxml @@ -8,9 +8,10 @@ remoteUsers="{{remoteUsers}}" bind:callingEvent="handleCallingEvent" > - - \ No newline at end of file + diff --git a/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/component/calling/calling.js b/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/component/calling/calling.js index 035c2fcfbd..e6dcfaa148 100644 --- a/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/component/calling/calling.js +++ b/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/component/calling/calling.js @@ -1,5 +1,4 @@ // components/tui-calling/TUICalling/component/calling.js -// eslint-disable-next-line no-undef Component({ /** * 组件的属性列表 @@ -27,6 +26,25 @@ Component({ }, + /** + * 生命周期方法 + */ + lifetimes: { + created() { + + }, + attached() { + }, + ready() { + wx.createLivePusherContext().startPreview() + }, + detached() { + wx.createLivePusherContext().stopPreview() + }, + error() { + }, + }, + /** * 组件的方法列表 */ diff --git a/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/component/calling/calling.wxml b/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/component/calling/calling.wxml index e733d944f0..847748c88a 100644 --- a/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/component/calling/calling.wxml +++ b/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/component/calling/calling.wxml @@ -1,47 +1,57 @@ - + - - - - + + - - 邀请你视频通话 - 等待对方接受 + + 邀请你视频通话 + 等待对方接受 - + - - - + + + - - 邀请你视频通话 - 等待对方接受 + + 邀请你视频通话 + 等待对方接受 - 切换到语音通话 + 切到语音通话 - - - + + + + + + + + 挂断 + - + @@ -49,52 +59,55 @@ 挂断 - - + + 接听 - + - - - {{remoteUsers[0].nick || remoteUsers[0].userID}} - {{'等待对方接受'}} + + + {{remoteUsers[0].nick || remoteUsers[0].userID}} + {{'等待对方接受'}} - - - + + + - - 邀请你视频通话 - 等待对方接受 + + 邀请你视频通话 + 等待对方接受 - - - + + + + + 挂断 - - + + + + + 接听 - - + + + + + 挂断 - \ No newline at end of file + diff --git a/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/component/calling/calling.wxss b/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/component/calling/calling.wxss index 1474a46975..9f30af3ae9 100644 --- a/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/component/calling/calling.wxss +++ b/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/component/calling/calling.wxss @@ -7,26 +7,36 @@ justify-content: center; align-items: center; } +.button-container { + display: flex; + flex-direction: column; + text-align: center; +} .btn-operate { display: flex; justify-content: space-between; + /* flex-direction: column; + text-align: center; */ + } .btn-operate-item{ display: flex; flex-direction: column; align-items: center; + margin-bottom: 20px; } .btn-operate-item text { - padding: 8px 0; - font-size: 18px; - color: #FFFFFF; + font-size: 14px; + color: #f0e9e9; + padding: 5px; letter-spacing: 0; font-weight: 400; } .call-switch text{ - padding: 0; + padding: 5px; + color: #f0e9e9; font-size: 14px; } @@ -42,13 +52,12 @@ } .call-switch .call-operate { width: 4vh; - height: 4vh; - padding: 2vh 0 4vh; + height: 3vh; } .call-operate image { - width: 4vh; - height: 4vh; + width: 100%; + height: 100%; background: none; } @@ -96,9 +105,18 @@ .invite-calling-header { margin-top:107px; display: flex; - justify-content: space-between; + justify-content: flex-end; padding: 0 16px; - + +} +.btn-container { + display: flex; + align-items: center; + position: relative; +} +.invite-calling-header-left { + position: absolute; + right: 0; } .invite-calling-header-left image { width: 32px; @@ -126,6 +144,7 @@ .invite-calling .btn-operate{ display: flex; justify-content: center; + align-items: center; } @@ -220,4 +239,4 @@ .avatar { background: #dddddd; -} \ No newline at end of file +} diff --git a/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/component/connected/connected.js b/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/component/connected/connected.js index 875cfe2a4a..feb6a09b03 100644 --- a/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/component/connected/connected.js +++ b/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/component/connected/connected.js @@ -1,4 +1,3 @@ -// eslint-disable-next-line no-undef Component({ /** * 组件的属性列表 @@ -19,6 +18,9 @@ Component({ screen: { type: String, }, + userList: { + type: Object, + }, }, /** @@ -124,21 +126,20 @@ Component({ this.triggerEvent('connectedEvent', data); }, handleConnectErrorImage(e) { - const { value, flag } = e.target.dataset; + const { flag, key, index } = e.target.dataset; if (flag === 'pusher') { this.data.pusher.avatar = '../../static/default_avatar.png'; this.setData({ pusher: this.data.pusher, }); } else { - const playerList = this.data.playerList.map((item) => { - if (item.userID === value) { - item.avatar = '../../static/default_avatar.png'; - } - return item; - }); + this.data[key][index].avatar = '../../static/default_avatar.png'; + if(this.data.playerList[index]) { + this.data.playerList[index].avatar = '../../static/default_avatar.png'; + } this.setData({ - playerList, + playerList: this.data.playerList, + [key]: this.data[key] }); } }, diff --git a/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/component/connected/connected.wxml b/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/component/connected/connected.wxml index 86ecda05c9..d97199bb91 100644 --- a/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/component/connected/connected.wxml +++ b/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/component/connected/connected.wxml @@ -1,116 +1,118 @@ - - + + - + {{pusher.nick || pusher.userID}}(自己) - - + + {{item.nick || item.userID}} - - - + + + {{pusher.chatTime}} + + + + + 切到语音通话 + - - + + + + + + 麦克风 - - + + + + + + 挂断 - - + + + + + + 扬声器 - - + + + + + + + 摄像头 - + - - + + + + + + + 挂断 - + diff --git a/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/component/connected/connected.wxss b/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/component/connected/connected.wxss index 348110fa59..d7f0ee2c23 100644 --- a/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/component/connected/connected.wxss +++ b/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/component/connected/connected.wxss @@ -6,83 +6,97 @@ height: 178px; padding: 16px; z-index: 3; - } - .pusher-video { +} + +.pusher-video { position: absolute; width: 100%; height: 100%; /* background-color: #f75c45; */ z-index: 1; - } - .stream-box { +} + +.stream-box { position: relative; float: left; width: 50vw; height: 260px; /* background-color: #f75c45; */ z-index: 3; - } - .handle-btns { +} + +.handle-btns { position: absolute; bottom: 44px; width: 100vw; z-index: 3; display: flex; flex-direction: column; - } - .handle-btns .btn-list { +} + +.handle-btns .btn-list { display: flex; flex-direction: row; justify-content: space-around; align-items: center; - } - - .btn-normal { +} + +.button-container { + display: flex; + flex-direction: column; + text-align: center; +} + +.btn-normal { width: 8vh; height: 8vh; box-sizing: border-box; display: flex; + flex-direction: column; /* background: white; */ justify-content: center; align-items: center; border-radius: 50%; - } - .btn-image{ - width: 8vh; - height: 8vh; +} + +.btn-image { + width: 100%; + height: 100%; background: none; - } - .btn-hangup { +} + +.btn-hangup { width: 8vh; height: 8vh; - background: #f75c45; + /*background: #f75c45;*/ box-sizing: border-box; display: flex; justify-content: center; align-items: center; border-radius: 50%; - } - .btn-hangup>.btn-image { - width: 4vh; - height: 4vh; +} + +.btn-hangup > .btn-image { + width: 100%; + height: 100%; background: none; - } - - .TRTCCalling-call-audio { +} + +.TRTCCalling-call-audio { width: 100%; height: 100%; - } +} - .btn-footer { +.btn-footer { position: relative; - } - - .btn-footer .multi-camera { +} + +.btn-footer .multi-camera { width: 32px; height: 32px; - } - - .btn-footer .camera { +} + +.btn-footer .camera { width: 64px; height: 64px; position: fixed; @@ -91,96 +105,149 @@ display: flex; justify-content: center; align-items: center; - background: rgba(#ffffff, 0.7); - } - .btn-footer .camera .camera-image { + background: rgba(255, 255, 255, 0.7); +} + +.btn-footer .camera .camera-image { width: 32px; height: 32px; - } - +} + .TUICalling-connected-layout { - width: 100%; - height: 100%; + width: 100%; + height: 100%; } -.audio{ - padding-top: 15vh; - background: #ffffff; + +.audio { + padding-top: 15vh; + background: #ffffff; } .pusher-audio { - width: 0; - height: 0; + width: 0; + height: 0; } -.player-audio{ - width: 0; - height: 0; +.player-audio { + width: 0; + height: 0; } .live { - width: 100%; - height: 100%; + width: 100%; + height: 100%; } .other-view { - display: flex; - flex-direction: column; - align-items: center; - font-size: 18px; - letter-spacing: 0; - font-weight: 400; - padding: 16px; + display: flex; + flex-direction: column; + align-items: center; + font-size: 18px; + letter-spacing: 0; + font-weight: 400; + padding: 16px; } .white { - color: #FFFFFF; - padding: 5px; + color: #f0e9e9; + padding: 5px; + font-size: 14px; } .black { - color: #000000; - padding: 5px; + color: #000000; + padding: 5px; } .TRTCCalling-call-audio-box { - display: flex; - flex-wrap: wrap; - justify-content: center; + display: flex; + flex-wrap: wrap; + justify-content: center; } + .mutil-img { - justify-content: flex-start !important; + justify-content: flex-start !important; } .TRTCCalling-call-audio-img { - display: flex; - flex-direction: column; - align-items: center; + display: flex; + flex-direction: column; + align-items: center; } -.TRTCCalling-call-audio-img>image { - width: 25vw; - height: 25vw; - margin: 0 4vw; - border-radius: 4vw; - position: relative; + +.TRTCCalling-call-audio-img > image { + width: 25vw; + height: 25vw; + margin: 0 4vw; + border-radius: 4vw; + position: relative; } -.TRTCCalling-call-audio-img text{ - font-size: 20px; - color: #333333; - letter-spacing: 0; - font-weight: 500; + +.TRTCCalling-call-audio-img text { + font-size: 20px; + color: #333333; + letter-spacing: 0; + font-weight: 500; } .btn-list-item { - flex: 1; - display: flex; - justify-content: center; - padding: 16px 0; + flex: 1; + display: flex; + justify-content: center; + padding: 16px 0; } .btn-image-small { - transform: scale(.7); + transform: scale(.7); } .avatar { - background: #dddddd; -} \ No newline at end of file + background: #dddddd; +} + +.btn-container { + display: flex; + align-items: center; + position: relative; +} + +.invite-calling-header-left { + position: absolute; + right: -88px; +} + +.invite-calling-header-left image { + width: 32px; + height: 32px; +} + +.call-switch .call-operate { + width: 4vh; + height: 3vh; +} + +.call-operate image { + width: 100%; + height: 100%; + background: none; +} + +.call-switch text { + padding: 0; + font-size: 14px; +} + +.btn-operate-item { + display: flex; + flex-direction: column; + align-items: center; +} + +.btn-operate-item text { + padding: 8px 0; + font-size: 18px; + color: #FFFFFF; + letter-spacing: 0; + font-weight: 400; + font-size: 14px; +} diff --git a/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/static/audio-false.png b/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/static/audio-false.png index e962fa9795..f0b99788c7 100644 Binary files a/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/static/audio-false.png and b/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/static/audio-false.png differ diff --git a/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/static/audio-true.png b/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/static/audio-true.png index 909520009d..8a13b6d9c3 100644 Binary files a/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/static/audio-true.png and b/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/static/audio-true.png differ diff --git a/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/static/camera-false.png b/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/static/camera-false.png index 4889104554..2093ad2040 100644 Binary files a/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/static/camera-false.png and b/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/static/camera-false.png differ diff --git a/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/static/camera-true.png b/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/static/camera-true.png index 8502a30fe0..c4c00b0605 100644 Binary files a/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/static/camera-true.png and b/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/static/camera-true.png differ diff --git a/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/static/dialing.png b/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/static/dialing.png new file mode 100644 index 0000000000..c762da9cec Binary files /dev/null and b/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/static/dialing.png differ diff --git a/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/static/hangup.png b/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/static/hangup.png index c548495448..24341516ff 100644 Binary files a/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/static/hangup.png and b/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/static/hangup.png differ diff --git a/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/static/speaker-false.png b/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/static/speaker-false.png index 0357745f01..4042495ae8 100644 Binary files a/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/static/speaker-false.png and b/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/static/speaker-false.png differ diff --git a/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/static/speaker-true.png b/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/static/speaker-true.png index 40b728e3ac..5ec86cab71 100644 Binary files a/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/static/speaker-true.png and b/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/static/speaker-true.png differ diff --git a/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/static/switch_camera.png b/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/static/switch_camera.png new file mode 100644 index 0000000000..6159919670 Binary files /dev/null and b/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/static/switch_camera.png differ diff --git a/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/static/trans.png b/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/static/trans.png index 8c77517bf0..1bbcea7d43 100644 Binary files a/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/static/trans.png and b/MiniProgram/TUIKit/miniprogram/TUI-Calling/components/TUICalling/static/trans.png differ diff --git a/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/TRTCCalling/TRTCCalling.js b/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/TRTCCalling/TRTCCalling.js index cafb5a36f9..3c3f3ed9ff 100644 --- a/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/TRTCCalling/TRTCCalling.js +++ b/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/TRTCCalling/TRTCCalling.js @@ -1,9 +1,7 @@ import EventEmitter from './utils/event.js'; import { EVENT, CALL_STATUS, MODE_TYPE, CALL_TYPE } from './common/constants.js'; import formateTime from './utils/formate-time'; -import TSignaling from './node_module/tsignaling-wx'; -import TRTC from './node_module/trtc-wx'; -import TIM from './node_module/tim-wx-sdk'; +import { TSignaling, TRTC, TIM } from './libSrcConfig' import TSignalingClient from './TSignalingClient'; import TRTCCallingDelegate from './TRTCCallingDelegate'; import TRTCCallingInfo from './TRTCCallingInfo'; @@ -27,7 +25,8 @@ class TRTCCalling { this.EVENT = EVENT; this.CALL_TYPE = CALL_TYPE; this._emitter = new EventEmitter(); - this.TRTC = new TRTC(); + this.TRTC = new TRTC(this, { TUIScene: 'TUICalling' }); + wx.TUIScene = 'TUICalling'; if (params.tim) { this.tim = params.tim; } else { @@ -35,6 +34,7 @@ class TRTCCalling { SDKAppID: params.sdkAppID, }); } + if (!wx.$TSignaling) { wx.$TSignaling = new TSignaling({ SDKAppID: params.sdkAppID, tim: this.tim }); } @@ -48,7 +48,8 @@ class TRTCCalling { callStatus: CALL_STATUS.IDLE, // 用户当前的通话状态 soundMode: 'speaker', // 声音模式 听筒/扬声器 active: false, - invitation: { // 接收到的邀请 + invitation: { + // 接收到的邀请 inviteID: '', inviter: '', type: '', @@ -71,6 +72,8 @@ class TRTCCalling { _isGroupCall: false, // 当前通话是否是群通话 _groupID: '', // 群组ID _switchCallModeStatus: true, // 是否可以进行模式切换 + enterRoomStatus: false, // 进入房间状态 + isCallEnd: true, // 通话是否为正常通话结束, true:正常通话结束,false:非正常通话结束 如:cancel、timeout、noResp }; this.data = { ...this.data, ...data }; } @@ -101,9 +104,11 @@ class TRTCCalling { const enableCamera = callType !== CALL_TYPE.VIDEO; this.setPusherAttributesHandler({ enableCamera }); if (enableCamera) { - this.data.invitation.type = this.data.config.type = CALL_TYPE.VIDEO; + this.data.config.type = CALL_TYPE.VIDEO; + this.data.invitation.type = CALL_TYPE.VIDEO; } else { - this.data.invitation.type = this.data.config.type = CALL_TYPE.AUDIO; + this.data.config.type = CALL_TYPE.AUDIO; + this.data.invitation.type = CALL_TYPE.AUDIO; } this.TRTCCallingDelegate.onCallMode({ type: this.data.config.type, message: callModeMessage.data.message }); this.setSwitchCallModeStatus(true); @@ -111,22 +116,40 @@ class TRTCCalling { // 判断是否为音视频切换 judgeSwitchCallMode(inviteData) { - const isSwitchCallMode = (inviteData.switch_to_audio_call - && inviteData.switch_to_audio_call === 'switch_to_audio_call') - || inviteData.data && inviteData.data.cmd === 'switchToAudio' - || inviteData.data && inviteData.data.cmd === 'switchToVideo'; + const isSwitchCallMode = + (inviteData.switch_to_audio_call && inviteData.switch_to_audio_call === 'switch_to_audio_call') || + (inviteData.data && inviteData.data.cmd === 'switchToAudio') || + (inviteData.data && inviteData.data.cmd === 'switchToVideo'); return isSwitchCallMode; } // 新的邀请回调事件 handleNewInvitationReceived(event) { - console.log(TAG_NAME, 'onNewInvitationReceived', `callStatus:${this.data.callStatus === CALL_STATUS.CALLING || this.data.callStatus === CALL_STATUS.CONNECTED}, inviteID:${event.data.inviteID} inviter:${event.data.inviter} inviteeList:${event.data.inviteeList} data:${event.data.data}`); - const { data: { inviter, inviteeList, data, inviteID, groupID } } = event; + console.log( + TAG_NAME, + 'onNewInvitationReceived', + `callStatus:${ + this.data.callStatus === CALL_STATUS.CALLING || this.data.callStatus === CALL_STATUS.CONNECTED + }, inviteID:${event.data.inviteID} inviter:${event.data.inviter} inviteeList:${event.data.inviteeList} data:${ + event.data.data + }`, + ); + const { + data: { inviter, inviteeList, data, inviteID, groupID }, + } = event; const inviteData = JSON.parse(data); // 此处判断inviteeList.length 大于2,用于在非群组下多人通话判断 // userIDs 为同步 native 在使用无 groupID 群聊时的判断依据 - const isGroupCall = !!(groupID || inviteeList.length >= 2 || inviteData.data && inviteData.data.userIDs && inviteData.data.userIDs.length >= 2); + const isGroupCall = !!( + groupID || + inviteeList.length >= 2 || + (inviteData.data && inviteData.data.userIDs && inviteData.data.userIDs.length >= 2) + ); + if (inviteData?.data?.cmd === 'hangup') { + this.TRTCCallingDelegate.onCallEnd(inviter, inviteData.call_end || 0); + return; + } let callEnd = false; // 此处逻辑用于通话结束时发出的invite信令 // 群通话已结束时,room_id 不存在或者 call_end 为 0 @@ -140,8 +163,8 @@ class TRTCCalling { // 判断新的信令是否为结束信令 if (callEnd) { // 群通话中收到最后挂断的邀请信令通知其他成员通话结束 - this.TRTCCallingDelegate.onCallEnd({ userID: inviter, callEnd: isGroupCall ? 0 : inviteData.call_end }); - this._reset(); + // this.TRTCCallingDelegate.onCallEnd({ userID: inviter, callEnd: isGroupCall ? 0 : inviteData.call_end }); + this._reset(isGroupCall ? 0 : inviteData.call_end); return; } @@ -193,6 +216,10 @@ class TRTCCalling { callEnd: 0, }, }; + this.setPusherAttributesHandler({ + enableCamera: this.data.config.type === CALL_TYPE.VIDEO + }) + wx.createLivePusherContext().startPreview(); this.TRTCCallingDelegate.onInvited(newReceiveData); } @@ -203,12 +230,15 @@ class TRTCCalling { return; } const list = [...this.data.groupInviteID]; - this.data.groupInviteID = list.filter(item => item !== inviteID); + this.data.groupInviteID = list.filter((item) => item !== inviteID); } // 发出的邀请收到接受的回调 - handleInviteeAccepted(event) { - console.log(`${TAG_NAME} INVITEE_ACCEPTED inviteID:${event.data.inviteID} invitee:${event.data.invitee} data:`, event.data); + async handleInviteeAccepted(event) { + console.log( + `${TAG_NAME} INVITEE_ACCEPTED inviteID:${event.data.inviteID} invitee:${event.data.invitee} data:`, + event.data, + ); const inviteData = JSON.parse(event.data.data); // 防止取消后,接收到远端接受信令 if (this.data.callStatus === CALL_STATUS.IDLE) { @@ -223,7 +253,10 @@ class TRTCCalling { // 发起人进入通话状态从此处判断 if (event.data.inviter === this._getUserID() && this.data.callStatus === CALL_STATUS.CALLING) { this._setCallStatus(CALL_STATUS.CONNECTED); - this.TRTCCallingDelegate.onUserAccept(event.data.invitee); + this.TRTCCallingDelegate.onUserAccept( + event.data.invitee, + await this.getUserProfile(this.data._unHandledInviteeList.map(item => ({userID: item}))), + ); } this.setInviteIDList(event.data.inviteID); if (this._getGroupCallFlag()) { @@ -234,7 +267,9 @@ class TRTCCalling { // 发出的邀请收到拒绝的回调 handleInviteeRejected(event) { - console.log(`${TAG_NAME} INVITEE_REJECTED inviteID:${event.data.inviteID} invitee:${event.data.invitee} data:${event.data.data}`); + console.log( + `${TAG_NAME} INVITEE_REJECTED inviteID:${event.data.inviteID} invitee:${event.data.invitee} data:${event.data.data}`, + ); // 防止切换音视频对方不可用时,返回数据流向onLineBusy或onReject if (!this.data._isGroupCall && !this.data._switchCallModeStatus) { console.log(`${TAG_NAME}.onInviteeRejected - Audio and video switching is not available`); @@ -246,7 +281,7 @@ class TRTCCalling { } // 判断被呼叫方已经接入,后续拒绝不影响正常通话 if (this.data.callStatus === CALL_STATUS.CONNECTED) { - const userInPlayerListFlag = this.data.playerList.some(item => (item.userID === event.data.invitee)); + const userInPlayerListFlag = this.data.playerList.some((item) => item.userID === event.data.invitee); if (userInPlayerListFlag) { return; } @@ -271,13 +306,13 @@ class TRTCCalling { // 2、已经接受邀请,远端没有用户,发出结束通话事件 const isPlayer = this.data.callStatus === CALL_STATUS.CONNECTED && this.data.playerList.length === 0; if (isCalling || isPlayer) { - this.TRTCCallingDelegate.onCallEnd({ userID: this.data.config.userID, callEnd: 0 }); + // this.TRTCCallingDelegate.onCallEnd({ userID: this.data.config.userID, callEnd: 0 }); this._reset(); } } }); } else { - this.TRTCCallingDelegate.onCallEnd({ userID: this.data.config.userID, callEnd: 0 }); + // this.TRTCCallingDelegate.onCallEnd({ userID: this.data.config.userID, callEnd: 0 }); this._reset(); } } @@ -289,17 +324,26 @@ class TRTCCalling { this._reset(); return; } - console.log(TAG_NAME, 'onInvitationCancelled', `inviteID:${event.data.inviteID} inviter:${event.data.invitee} data:${event.data.data}`); + console.log( + TAG_NAME, + 'onInvitationCancelled', + `inviteID:${event.data.inviteID} inviter:${event.data.invitee} data:${event.data.data}`, + ); this._setCallStatus(CALL_STATUS.IDLE); this.TRTCCallingDelegate.onCancel({ inviteID: event.data.inviteID, invitee: event.data.invitee }); - this.TRTCCallingDelegate.onCallEnd({ userID: this.data.config.userID, callEnd: 0 }); + this.data.isCallEnd = false; + // this.TRTCCallingDelegate.onCallEnd({ userID: this.data.config.userID, callEnd: 0 }); this.setInviteIDList(event.data.inviteID); this._reset(); } // 收到的邀请收到该邀请超时的回调 handleInvitationTimeout(event) { - console.log(TAG_NAME, 'onInvitationTimeout', `data:${JSON.stringify(event)} inviteID:${event.data.inviteID} inviteeList:${event.data.inviteeList}`); + console.log( + TAG_NAME, + 'onInvitationTimeout', + `data:${JSON.stringify(event)} inviteID:${event.data.inviteID} inviteeList:${event.data.inviteeList}`, + ); const { groupID = '', inviteID, inviter, inviteeList, isSelfTimeout } = event.data; // 防止用户已挂断,但接收到超时事件后的,抛出二次超时事件 if (this.data.callStatus === CALL_STATUS.IDLE) { @@ -317,7 +361,8 @@ class TRTCCalling { }); // 若在呼叫中,且全部用户都无应答 if (this.data.callStatus !== CALL_STATUS.CONNECTED) { - this.TRTCCallingDelegate.onCallEnd({ userID: inviter, callEnd: 0 }); + // this.TRTCCallingDelegate.onCallEnd({ userID: inviter, callEnd: 0 }); + this.data.isCallEnd = false; this._reset(); } return; @@ -351,12 +396,14 @@ class TRTCCalling { }); return; } - this.TRTCCallingDelegate.onCallEnd({ userID: inviter, callEnd: 0 }); + this.data.isCallEnd = false; + // this.TRTCCallingDelegate.onCallEnd({ userID: inviter, callEnd: 0 }); this._reset(); } } else { // 1v1通话被邀请方超时 - this.TRTCCallingDelegate.onCallEnd({ userID: inviter, callEnd: 0 }); + // this.TRTCCallingDelegate.onCallEnd({ userID: inviter, callEnd: 0 }); + this.data.isCallEnd = false; this._reset(); } // 用inviteeList进行判断,是为了兼容多人通话 @@ -368,13 +415,16 @@ class TRTCCalling { // SDK Ready 回调 handleSDKReady() { console.log(TAG_NAME, 'TSignaling SDK ready'); + this.TSignalingResolve(); this.TRTCCallingDelegate.onSdkReady({ message: 'SDK ready' }); const promise = this.tim.getMyProfile(); - promise.then((imResponse) => { - this.data.localUser = imResponse.data; - }).catch((imError) => { - console.warn('getMyProfile error:', imError); // 获取个人资料失败的相关信息 - }); + promise + .then((imResponse) => { + this.data.localUser = imResponse.data; + }) + .catch((imError) => { + console.warn('getMyProfile error:', imError); // 获取个人资料失败的相关信息 + }); } // 被踢下线 @@ -404,19 +454,19 @@ class TRTCCalling { // 取消 tsignaling 事件监听 _removeTSignalingEvent() { // 新的邀请回调事件 - wx.$TSignaling.off(TSignaling.EVENT.NEW_INVITATION_RECEIVED); + wx.$TSignaling.off(TSignaling.EVENT.NEW_INVITATION_RECEIVED, this.handleNewInvitationReceived); // 发出的邀请收到接受的回调 - wx.$TSignaling.off(TSignaling.EVENT.INVITEE_ACCEPTED); + wx.$TSignaling.off(TSignaling.EVENT.INVITEE_ACCEPTED, this.handleInviteeAccepted); // 发出的邀请收到拒绝的回调 - wx.$TSignaling.off(TSignaling.EVENT.INVITEE_REJECTED); + wx.$TSignaling.off(TSignaling.EVENT.INVITEE_REJECTED, this.handleInviteeRejected); // 收到的邀请收到该邀请取消的回调 - wx.$TSignaling.off(TSignaling.EVENT.INVITATION_CANCELLED); + wx.$TSignaling.off(TSignaling.EVENT.INVITATION_CANCELLED, this.handleInvitationCancelled); // 收到的邀请收到该邀请超时的回调 - wx.$TSignaling.off(TSignaling.EVENT.INVITATION_TIMEOUT); + wx.$TSignaling.off(TSignaling.EVENT.INVITATION_TIMEOUT, this.handleInvitationTimeout); // SDK Ready 回调 - wx.$TSignaling.off(TSignaling.EVENT.SDK_READY); + wx.$TSignaling.off(TSignaling.EVENT.SDK_READY, this.handleSDKReady); // 被踢下线 - wx.$TSignaling.off(TSignaling.EVENT.KICKED_OUT); + wx.$TSignaling.off(TSignaling.EVENT.KICKED_OUT, this.handleKickedOut); } // 远端用户加入此房间 @@ -440,7 +490,7 @@ class TRTCCalling { console.log(TAG_NAME, 'REMOTE_USER_LEAVE', event, event.data.userID); if (userID) { // this.data.playerList = await this.getUserProfile(playerList) - this.data.playerList = this.data.playerList.filter(item => item.userID !== userID); + this.data.playerList = this.data.playerList.filter((item) => item.userID !== userID); // 群组或多人通话模式下,有用户离开时,远端还有用户,则只下发用户离开事件 if (playerList.length > 0) { this.TRTCCallingDelegate.onUserLeave({ userID, playerList: this.data.playerList }); @@ -594,6 +644,7 @@ class TRTCCalling { // 进入房间 enterRoom(options) { + this._addTRTCEvent(); const { roomID } = options; const config = Object.assign(this.data.config, { roomID, @@ -606,17 +657,25 @@ class TRTCCalling { if (this.data._unHandledInviteeList.length > 0) { this._setUnHandledInviteeList(this.data.config.userID); } + this.data.enterRoomStatus = true; this.data.pusher = this.TRTC.enterRoom(config); this.TRTC.getPusherInstance().start(); // 开始推流 } // 退出房间 - exitRoom() { + exitRoom(callEnd) { + this.TRTC.getPusherInstance().stop(); // 停止推流 const result = this.TRTC.exitRoom(); + if (this.data.isCallEnd) { + this.TRTCCallingDelegate.onCallEnd({ userID: this.data.config.userID, callEnd: callEnd || 0 }); + } this.data.pusher = result.pusher; this.data.playerList = result.playerList; this.data._unHandledInviteeList = []; + this.data.enterRoomStatus = false; + this.data.isCallEnd = true; this.initTRTC(); + this._removeTRTCEvent(); } // 设置 pusher 属性 @@ -630,7 +689,8 @@ class TRTCCalling { const playerList = this.TRTC.setPlayerAttributes(player.streamID, options); console.warn('setPlayerAttributesHandler', playerList); // this.data.playerList = await this.getUserProfile(playerList) - this.data.playerList = playerList.length > 0 ? this._updateUserProfile(this.data.playerList, playerList) : this.data.playerList; + this.data.playerList = + playerList.length > 0 ? this._updateUserProfile(this.data.playerList, playerList) : this.data.playerList; this.TRTCCallingDelegate.onUserUpdate({ pusher: this.data.pusher, playerList: this.data.playerList }); } @@ -688,16 +748,21 @@ class TRTCCalling { wx.$TSignaling.setLogLevel(0); this.data.config.userID = data.userID; this.data.config.userSig = data.userSig; - return wx.$TSignaling.login({ - userID: data.userID, - userSig: data.userSig, - }).then((res) => { - console.log(TAG_NAME, 'login', 'IM login success', res); - this._reset(); - this._addTSignalingEvent(); - this._addTRTCEvent(); - this.initTRTC(); - }); + return new Promise((resolve, reject) => { + wx.$TSignaling + .login({ + userID: data.userID, + userSig: data.userSig, + }) + .then((res) => { + console.log(TAG_NAME, 'login', 'IM login success', res); + this._reset(); + this._addTSignalingEvent(); + this.initTRTC(); + this.TSignalingResolve = resolve + return null; + }); + }) } /** @@ -712,15 +777,17 @@ class TRTCCalling { } } this._reset(); - wx.$TSignaling.logout({ - userID: this.data.config.userID, - userSig: this.data.config.userSig, - }).then((res) => { - console.log(TAG_NAME, 'logout', 'IM logout success'); - this._removeTSignalingEvent(); - this._removeTRTCEvent(); - return res; - }) + wx.$TSignaling + .logout({ + userID: this.data.config.userID, + userSig: this.data.config.userSig, + }) + .then((res) => { + console.log(TAG_NAME, 'logout', 'IM logout success'); + this._removeTSignalingEvent(); + this._removeTRTCEvent(); + return res; + }) .catch((err) => { console.error(TAG_NAME, 'logout', 'IM logout failure'); throw new Error(err); @@ -756,9 +823,9 @@ class TRTCCalling { */ async call(params) { const { userID, type } = params; - // 生成房间号,拼接URL地址 TRTC-wx roomID 超出取值范围1~4294967295 - const roomID = Math.floor(Math.random() * 4294967294 + 1); // 随机生成房间号 - this.enterRoom({ roomID, callType: type }); + // 生成房间号,拼接URL地址 TRTC-wx roomID 超出取值范围1~2147483647 + const roomID = Math.floor(Math.random() * 2147483646 + 1); // 随机生成房间号 + this.enterRoom({ roomID, callType: type });                                                  try { const res = await this.TSignalingClient.invite({ roomID, ...params }); console.log(`${TAG_NAME} call(userID: ${userID}, type: ${type}) success, ${res}`); @@ -791,8 +858,8 @@ class TRTCCalling { */ async groupCall(params) { const { type } = params; - // 生成房间号,拼接URL地址 TRTC-wx roomID 超出取值范围1~4294967295 - const roomID = this.data.roomID || Math.floor(Math.random() * 4294967294 + 1); // 随机生成房间号 + // 生成房间号,拼接URL地址 TRTC-wx roomID 超出取值范围1~2147483647 + const roomID = this.data.roomID || Math.floor(Math.random() * 2147483646 + 1); // 随机生成房间号 this.enterRoom({ roomID, callType: type }); try { let inviterInviteID = [...this.data.invitation.inviteID]; @@ -836,17 +903,33 @@ class TRTCCalling { * 当您作为被邀请方收到 {@link TRTCCallingDelegate#onInvited } 的回调时,可以调用该函数接听来电 */ async accept() { - // 拼接pusherURL进房 - console.log(TAG_NAME, 'accept() inviteID: ', this.data.invitation.inviteID); - if (this.data.callStatus === CALL_STATUS.IDLE) { - throw new Error('The call was cancelled'); - } - if (this.data.callStatus === CALL_STATUS.CALLING) { - this.enterRoom({ roomID: this.data.invitation.roomID, callType: this.data.config.type }); - // 被邀请人进入通话状态 - this._setCallStatus(CALL_STATUS.CONNECTED); - } + return new Promise((resolve,reject)=> { + // 拼接pusherURL进房 + console.log(TAG_NAME, 'accept() inviteID: ', this.data.invitation.inviteID); + if (this.data.callStatus === CALL_STATUS.IDLE) { + throw new Error('The call was cancelled'); + } + if (this.data.callStatus === CALL_STATUS.CALLING) { + if (this.data.config.type === CALL_TYPE.VIDEO) { + wx.createLivePusherContext().stopPreview({ + success: () => { + const timer = setTimeout(async ()=>{ + clearTimeout(timer); + this.handleAccept(resolve,reject); + }, 0) + } + }); + } else { + this.handleAccept(resolve,reject); + } + } + }) + } + async handleAccept(resolve, reject) { + this.enterRoom({ roomID: this.data.invitation.roomID, callType: this.data.config.type }); + // 被邀请人进入通话状态 + this._setCallStatus(CALL_STATUS.CONNECTED); const acceptRes = await this.TSignalingClient.accept({ inviteID: this.data.invitation.inviteID, type: this.data.config.type, @@ -856,13 +939,13 @@ class TRTCCalling { if (this._getGroupCallFlag()) { this._setUnHandledInviteeList(this._getUserID()); } - return { + return resolve({ message: acceptRes.data.message, pusher: this.data.pusher, - }; + }) } console.error(TAG_NAME, 'accept failed', acceptRes); - return acceptRes; + return reject(acceptRes); } /** @@ -902,9 +985,10 @@ class TRTCCalling { inviteIDList: cancelInvite, callType: this.data.invitation.type, }); - this.TRTCCallingDelegate.onCallEnd({ message: cancelRes[0].data.message }); + this.data.isCallEnd = true; + // this.TRTCCallingDelegate.onCallEnd({ message: cancelRes[0].data.message }); } - this.exitRoom(); + // this.exitRoom(); this._reset(); return cancelRes; } @@ -913,7 +997,7 @@ class TRTCCalling { async lastOneHangup(params) { const isGroup = this._getGroupCallFlag(); const res = await this.TSignalingClient.lastOneHangup({ isGroup, groupID: this.data._groupID, ...params }); - this.TRTCCallingDelegate.onCallEnd({ message: res.data.message }); + // this.TRTCCallingDelegate.onCallEnd({ message: res.data.message }); this._reset(); } @@ -926,7 +1010,7 @@ class TRTCCalling { _setUnHandledInviteeList(userID, callback) { // 使用callback防御列表更新时序问题 const list = [...this.data._unHandledInviteeList]; - const unHandleList = list.filter(item => item !== userID); + const unHandleList = list.filter((item) => item !== userID); this.data._unHandledInviteeList = unHandleList; callback && callback(unHandleList); } @@ -963,10 +1047,13 @@ class TRTCCalling { } // 通话结束,重置数据 - _reset() { - console.log(TAG_NAME, ' _reset()'); + _reset(callEnd) { + console.log(TAG_NAME, ' _reset()', this.data.enterRoomStatus); + if (this.data.enterRoomStatus) { + this.exitRoom(callEnd) + } this._setCallStatus(CALL_STATUS.IDLE); - this.data.config.type = 1; + this.data.config.type = CALL_TYPE.AUDIO; // 清空状态 this.initData(); } @@ -1028,6 +1115,7 @@ class TRTCCalling { if (this.data.callStatus !== CALL_STATUS.CONNECTED) { const targetPos = this.data.pusher.frontCamera === 'front' ? 'back' : 'front'; this.setPusherAttributesHandler({ frontCamera: targetPos }); + wx.createLivePusherContext().switchCamera(); } else { this.TRTC.getPusherInstance().switchCamera(); } @@ -1046,8 +1134,8 @@ class TRTCCalling { } /** - * 视频通话切换语音通话 - */ + * 视频通话切换语音通话 + */ async switchAudioCall() { if (this._isGroupCall) { console.warn(`${TAG_NAME}.switchToAudioCall is not applicable to groupCall.`); @@ -1147,7 +1235,7 @@ class TRTCCalling { } const playerList = newUserList.map((item) => { const newItem = item; - const itemProfile = userList.filter(imItem => imItem.userID === item.userID); + const itemProfile = userList.filter((imItem) => imItem.userID === item.userID); newItem.avatar = itemProfile[0] && itemProfile[0].avatar ? itemProfile[0].avatar : ''; newItem.nick = itemProfile[0] && itemProfile[0].nick ? itemProfile[0].nick : ''; return newItem; @@ -1157,47 +1245,42 @@ class TRTCCalling { // 获取用户信息 _getUserProfile(userList) { const promise = this.tim.getUserProfile({ userIDList: userList }); - promise.then((imResponse) => { - console.log('getUserProfile success', imResponse); - console.log(imResponse.data); - this.data.remoteUsers = imResponse.data; - }).catch((imError) => { - console.warn('getUserProfile error:', imError); // 获取其他用户资料失败的相关信息 - }); + promise + .then((imResponse) => { + console.log('getUserProfile success', imResponse); + console.log(imResponse.data); + this.data.remoteUsers = imResponse.data; + }) + .catch((imError) => { + console.warn('getUserProfile error:', imError); // 获取其他用户资料失败的相关信息 + }); } // 获取用户信息 - async getUserProfile(userList) { + async getUserProfile(userList, type = 'array') { if (userList.length === 0) { return []; } - const list = userList.map(item => item.userID); + const list = userList.map((item) => item.userID); const imResponse = await this.tim.getUserProfile({ userIDList: list }); - const newUserList = userList.map((item) => { - const newItem = item; - const itemProfile = imResponse.data.filter(imItem => imItem.userID === item.userID); - newItem.avatar = itemProfile[0] && itemProfile[0].avatar ? itemProfile[0].avatar : ''; - newItem.nick = itemProfile[0] && itemProfile[0].nick ? itemProfile[0].nick : ''; - return newItem; - }); - return newUserList; - } - - // 呼叫用户图像解析不出来的缺省图设置 - _handleErrorImage() { - const { remoteUsers } = this.data; - remoteUsers[0].avatar = './static/avatar2_100.png'; - this.data.remoteUsers = remoteUsers; - } - - // 通话中图像解析不出来的缺省图设置 - _handleConnectErrorImage(e) { - const data = e.target.dataset.value; - this.data.playerList = this.data.playerList.map((item) => { - if (item.userID === data.userID) { - item.avatar = './static/avatar2_100.png'; - } - return item; - }); + let result = null + switch (type) { + case 'array': + result = userList.map((item, index) => { + item.avatar = imResponse.data[index].avatar + item.nick = imResponse.data[index].nick + return item + }); + break + case 'map': + result = {} + userList.forEach((item, index) => { + item.avatar = imResponse.data[index].avatar + item.nick = imResponse.data[index].nick + result[item.userID] = item + }) + break + } + return result } // pusher 的网络状况 @@ -1214,7 +1297,11 @@ class TRTCCalling { _toggleViewSize(e) { const { screen } = e.currentTarget.dataset; console.log('get screen', screen, e); - if (this.data.playerList.length === 1 && screen !== this.data.screen && this.data.invitation.type === CALL_TYPE.VIDEO) { + if ( + this.data.playerList.length === 1 && + screen !== this.data.screen && + this.data.invitation.type === CALL_TYPE.VIDEO + ) { this.data.screen = screen; } return this.data.screen; @@ -1241,4 +1328,3 @@ class TRTCCalling { } export default TRTCCalling; - diff --git a/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/TRTCCalling/TRTCCallingDelegate.js b/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/TRTCCalling/TRTCCallingDelegate.js index c5330e8b57..0d89092033 100644 --- a/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/TRTCCalling/TRTCCallingDelegate.js +++ b/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/TRTCCalling/TRTCCallingDelegate.js @@ -82,9 +82,10 @@ class TRTCCallingDelegate { } // 抛出用户接听 - onUserAccept(userID) { + onUserAccept(userID, userList) { this._emitter.emit(EVENT.USER_ACCEPT, { userID, + userList, }); } diff --git a/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/TRTCCalling/common/constants.js b/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/TRTCCalling/common/constants.js index 787a491f19..5896f085f5 100644 --- a/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/TRTCCalling/common/constants.js +++ b/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/TRTCCalling/common/constants.js @@ -20,13 +20,13 @@ export const EVENT = { HANG_UP: 'HANG_UP', ERROR: 'ERROR', // 组件内部抛出的错误 -}; +} export const CALL_STATUS = { - IDLE: 'idle', - CALLING: 'calling', - CONNECTED: 'connected', -}; + IDLE: 'idle', // 默认 + CALLING: 'calling', //呼叫中/被呼叫中 + CONNECTED: 'connected', //接通中 +} export const ACTION_TYPE = { INVITE: 1, // 邀请方发起邀请 @@ -34,21 +34,21 @@ export const ACTION_TYPE = { ACCEPT_INVITE: 3, // 被邀请方同意邀请 REJECT_INVITE: 4, // 被邀请方拒绝邀请 INVITE_TIMEOUT: 5, // 被邀请方超时未回复 -}; +} export const BUSINESS_ID = { SIGNAL: 1, // 信令 -}; +} export const CALL_TYPE = { AUDIO: 1, VIDEO: 2, -}; +} -export const CMD_TYPE_LIST = ['', 'audioCall', 'videoCall']; +export const CMD_TYPE_LIST = ['', 'audioCall', 'videoCall'] // audio视频切音频;video:音频切视频 export const MODE_TYPE = { AUDIO: 'audio', VIDEO: 'video', -}; +} diff --git a/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/TRTCCalling/libSrcConfig.js b/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/TRTCCalling/libSrcConfig.js new file mode 100644 index 0000000000..29ff3a1466 --- /dev/null +++ b/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/TRTCCalling/libSrcConfig.js @@ -0,0 +1,10 @@ +import TSignaling from './node_module/tsignaling-wx'; +import TRTC from './node_module/trtc-wx' +import TIM from './node_module/tim-wx-sdk'; + + +export { + TSignaling, + TRTC, + TIM +} \ No newline at end of file diff --git a/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/TRTCCalling/node_module/tim-wx-sdk.js b/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/TRTCCalling/node_module/tim-wx-sdk.js index 7e391bda9d..d11227bd4f 100644 --- a/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/TRTCCalling/node_module/tim-wx-sdk.js +++ b/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/TRTCCalling/node_module/tim-wx-sdk.js @@ -1,4033 +1 @@ -!(function (e, t) { - 'object' === typeof exports && 'undefined' !== typeof module ? module.exports = t() : 'function' === typeof define && define.amd ? define(t) : (e = e || self).TIM = t(); -}(this, (() => { - function e(e, t) { - const n = Object.keys(e);if (Object.getOwnPropertySymbols) { - let o = Object.getOwnPropertySymbols(e);t && (o = o.filter((t => Object.getOwnPropertyDescriptor(e, t).enumerable))), n.push.apply(n, o); - } return n; - } function t(t) { - for (let n = 1;n < arguments.length;n++) { - var o = null != arguments[n] ? arguments[n] : {};n % 2 ? e(Object(o), !0).forEach(((e) => { - r(t, e, o[e]); - })) : Object.getOwnPropertyDescriptors ? Object.defineProperties(t, Object.getOwnPropertyDescriptors(o)) : e(Object(o)).forEach(((e) => { - Object.defineProperty(t, e, Object.getOwnPropertyDescriptor(o, e)); - })); - } return t; - } function n(e) { - return (n = 'function' === typeof Symbol && 'symbol' === typeof Symbol.iterator ? function (e) { - return typeof e; - } : function (e) { - return e && 'function' === typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? 'symbol' : typeof e; - })(e); - } function o(e, t) { - if (!(e instanceof t)) throw new TypeError('Cannot call a class as a function'); - } function a(e, t) { - for (let n = 0;n < t.length;n++) { - const o = t[n];o.enumerable = o.enumerable || !1, o.configurable = !0, 'value' in o && (o.writable = !0), Object.defineProperty(e, o.key, o); - } - } function s(e, t, n) { - return t && a(e.prototype, t), n && a(e, n), e; - } function r(e, t, n) { - return t in e ? Object.defineProperty(e, t, { value: n, enumerable: !0, configurable: !0, writable: !0 }) : e[t] = n, e; - } function i(e, t) { - if ('function' !== typeof t && null !== t) throw new TypeError('Super expression must either be null or a function');e.prototype = Object.create(t && t.prototype, { constructor: { value: e, writable: !0, configurable: !0 } }), t && u(e, t); - } function c(e) { - return (c = Object.setPrototypeOf ? Object.getPrototypeOf : function (e) { - return e.__proto__ || Object.getPrototypeOf(e); - })(e); - } function u(e, t) { - return (u = Object.setPrototypeOf || function (e, t) { - return e.__proto__ = t, e; - })(e, t); - } function l() { - if ('undefined' === typeof Reflect || !Reflect.construct) return !1;if (Reflect.construct.sham) return !1;if ('function' === typeof Proxy) return !0;try { - return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], (() => {}))), !0; - } catch (e) { - return !1; - } - } function d(e, t, n) { - return (d = l() ? Reflect.construct : function (e, t, n) { - const o = [null];o.push.apply(o, t);const a = new (Function.bind.apply(e, o));return n && u(a, n.prototype), a; - }).apply(null, arguments); - } function g(e) { - const t = 'function' === typeof Map ? new Map : void 0;return (g = function (e) { - if (null === e || (n = e, -1 === Function.toString.call(n).indexOf('[native code]'))) return e;let n;if ('function' !== typeof e) throw new TypeError('Super expression must either be null or a function');if (void 0 !== t) { - if (t.has(e)) return t.get(e);t.set(e, o); - } function o() { - return d(e, arguments, c(this).constructor); - } return o.prototype = Object.create(e.prototype, { constructor: { value: o, enumerable: !1, writable: !0, configurable: !0 } }), u(o, e); - })(e); - } function p(e, t) { - if (null == e) return {};let n; let o; const a = (function (e, t) { - if (null == e) return {};let n; let o; const a = {}; const s = Object.keys(e);for (o = 0;o < s.length;o++)n = s[o], t.indexOf(n) >= 0 || (a[n] = e[n]);return a; - }(e, t));if (Object.getOwnPropertySymbols) { - const s = Object.getOwnPropertySymbols(e);for (o = 0;o < s.length;o++)n = s[o], t.indexOf(n) >= 0 || Object.prototype.propertyIsEnumerable.call(e, n) && (a[n] = e[n]); - } return a; - } function h(e) { - if (void 0 === e) throw new ReferenceError('this hasn\'t been initialised - super() hasn\'t been called');return e; - } function _(e, t) { - return !t || 'object' !== typeof t && 'function' !== typeof t ? h(e) : t; - } function f(e) { - const t = l();return function () { - let n; const o = c(e);if (t) { - const a = c(this).constructor;n = Reflect.construct(o, arguments, a); - } else n = o.apply(this, arguments);return _(this, n); - }; - } function m(e, t) { - return v(e) || (function (e, t) { - let n = null == e ? null : 'undefined' !== typeof Symbol && e[Symbol.iterator] || e['@@iterator'];if (null == n) return;let o; let a; const s = []; let r = !0; let i = !1;try { - for (n = n.call(e);!(r = (o = n.next()).done) && (s.push(o.value), !t || s.length !== t);r = !0); - } catch (c) { - i = !0, a = c; - } finally { - try { - r || null == n.return || n.return(); - } finally { - if (i) throw a; - } - } return s; - }(e, t)) || I(e, t) || T(); - } function M(e) { - return (function (e) { - if (Array.isArray(e)) return D(e); - }(e)) || y(e) || I(e) || (function () { - throw new TypeError('Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.'); - }()); - } function v(e) { - if (Array.isArray(e)) return e; - } function y(e) { - if ('undefined' !== typeof Symbol && null != e[Symbol.iterator] || null != e['@@iterator']) return Array.from(e); - } function I(e, t) { - if (e) { - if ('string' === typeof e) return D(e, t);let n = Object.prototype.toString.call(e).slice(8, -1);return 'Object' === n && e.constructor && (n = e.constructor.name), 'Map' === n || 'Set' === n ? Array.from(e) : 'Arguments' === n || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n) ? D(e, t) : void 0; - } - } function D(e, t) { - (null == t || t > e.length) && (t = e.length);for (var n = 0, o = new Array(t);n < t;n++)o[n] = e[n];return o; - } function T() { - throw new TypeError('Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.'); - } function S(e, t) { - let n = 'undefined' !== typeof Symbol && e[Symbol.iterator] || e['@@iterator'];if (!n) { - if (Array.isArray(e) || (n = I(e)) || t && e && 'number' === typeof e.length) { - n && (e = n);let o = 0; const a = function () {};return { s: a, n() { - return o >= e.length ? { done: !0 } : { done: !1, value: e[o++] }; - }, e(e) { - throw e; - }, f: a }; - } throw new TypeError('Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.'); - } let s; let r = !0; let i = !1;return { s() { - n = n.call(e); - }, n() { - const e = n.next();return r = e.done, e; - }, e(e) { - i = !0, s = e; - }, f() { - try { - r || null == n.return || n.return(); - } finally { - if (i) throw s; - } - } }; - } const E = { SDK_READY: 'sdkStateReady', SDK_NOT_READY: 'sdkStateNotReady', SDK_DESTROY: 'sdkDestroy', MESSAGE_RECEIVED: 'onMessageReceived', MESSAGE_MODIFIED: 'onMessageModified', MESSAGE_REVOKED: 'onMessageRevoked', MESSAGE_READ_BY_PEER: 'onMessageReadByPeer', CONVERSATION_LIST_UPDATED: 'onConversationListUpdated', GROUP_LIST_UPDATED: 'onGroupListUpdated', GROUP_SYSTEM_NOTICE_RECEIVED: 'receiveGroupSystemNotice', PROFILE_UPDATED: 'onProfileUpdated', BLACKLIST_UPDATED: 'blacklistUpdated', FRIEND_LIST_UPDATED: 'onFriendListUpdated', FRIEND_GROUP_LIST_UPDATED: 'onFriendGroupListUpdated', FRIEND_APPLICATION_LIST_UPDATED: 'onFriendApplicationListUpdated', KICKED_OUT: 'kickedOut', ERROR: 'error', NET_STATE_CHANGE: 'netStateChange', SDK_RELOAD: 'sdkReload' }; const k = { MSG_TEXT: 'TIMTextElem', MSG_IMAGE: 'TIMImageElem', MSG_SOUND: 'TIMSoundElem', MSG_AUDIO: 'TIMSoundElem', MSG_FILE: 'TIMFileElem', MSG_FACE: 'TIMFaceElem', MSG_VIDEO: 'TIMVideoFileElem', MSG_GEO: 'TIMLocationElem', MSG_GRP_TIP: 'TIMGroupTipElem', MSG_GRP_SYS_NOTICE: 'TIMGroupSystemNoticeElem', MSG_CUSTOM: 'TIMCustomElem', MSG_MERGER: 'TIMRelayElem', MSG_PRIORITY_HIGH: 'High', MSG_PRIORITY_NORMAL: 'Normal', MSG_PRIORITY_LOW: 'Low', MSG_PRIORITY_LOWEST: 'Lowest', CONV_C2C: 'C2C', CONV_GROUP: 'GROUP', CONV_SYSTEM: '@TIM#SYSTEM', CONV_AT_ME: 1, CONV_AT_ALL: 2, CONV_AT_ALL_AT_ME: 3, GRP_PRIVATE: 'Private', GRP_WORK: 'Private', GRP_PUBLIC: 'Public', GRP_CHATROOM: 'ChatRoom', GRP_MEETING: 'ChatRoom', GRP_AVCHATROOM: 'AVChatRoom', GRP_MBR_ROLE_OWNER: 'Owner', GRP_MBR_ROLE_ADMIN: 'Admin', GRP_MBR_ROLE_MEMBER: 'Member', GRP_TIP_MBR_JOIN: 1, GRP_TIP_MBR_QUIT: 2, GRP_TIP_MBR_KICKED_OUT: 3, GRP_TIP_MBR_SET_ADMIN: 4, GRP_TIP_MBR_CANCELED_ADMIN: 5, GRP_TIP_GRP_PROFILE_UPDATED: 6, GRP_TIP_MBR_PROFILE_UPDATED: 7, MSG_REMIND_ACPT_AND_NOTE: 'AcceptAndNotify', MSG_REMIND_ACPT_NOT_NOTE: 'AcceptNotNotify', MSG_REMIND_DISCARD: 'Discard', GENDER_UNKNOWN: 'Gender_Type_Unknown', GENDER_FEMALE: 'Gender_Type_Female', GENDER_MALE: 'Gender_Type_Male', KICKED_OUT_MULT_ACCOUNT: 'multipleAccount', KICKED_OUT_MULT_DEVICE: 'multipleDevice', KICKED_OUT_USERSIG_EXPIRED: 'userSigExpired', ALLOW_TYPE_ALLOW_ANY: 'AllowType_Type_AllowAny', ALLOW_TYPE_NEED_CONFIRM: 'AllowType_Type_NeedConfirm', ALLOW_TYPE_DENY_ANY: 'AllowType_Type_DenyAny', FORBID_TYPE_NONE: 'AdminForbid_Type_None', FORBID_TYPE_SEND_OUT: 'AdminForbid_Type_SendOut', JOIN_OPTIONS_FREE_ACCESS: 'FreeAccess', JOIN_OPTIONS_NEED_PERMISSION: 'NeedPermission', JOIN_OPTIONS_DISABLE_APPLY: 'DisableApply', JOIN_STATUS_SUCCESS: 'JoinedSuccess', JOIN_STATUS_ALREADY_IN_GROUP: 'AlreadyInGroup', JOIN_STATUS_WAIT_APPROVAL: 'WaitAdminApproval', GRP_PROFILE_OWNER_ID: 'ownerID', GRP_PROFILE_CREATE_TIME: 'createTime', GRP_PROFILE_LAST_INFO_TIME: 'lastInfoTime', GRP_PROFILE_MEMBER_NUM: 'memberNum', GRP_PROFILE_MAX_MEMBER_NUM: 'maxMemberNum', GRP_PROFILE_JOIN_OPTION: 'joinOption', GRP_PROFILE_INTRODUCTION: 'introduction', GRP_PROFILE_NOTIFICATION: 'notification', GRP_PROFILE_MUTE_ALL_MBRS: 'muteAllMembers', SNS_ADD_TYPE_SINGLE: 'Add_Type_Single', SNS_ADD_TYPE_BOTH: 'Add_Type_Both', SNS_DELETE_TYPE_SINGLE: 'Delete_Type_Single', SNS_DELETE_TYPE_BOTH: 'Delete_Type_Both', SNS_APPLICATION_TYPE_BOTH: 'Pendency_Type_Both', SNS_APPLICATION_SENT_TO_ME: 'Pendency_Type_ComeIn', SNS_APPLICATION_SENT_BY_ME: 'Pendency_Type_SendOut', SNS_APPLICATION_AGREE: 'Response_Action_Agree', SNS_APPLICATION_AGREE_AND_ADD: 'Response_Action_AgreeAndAdd', SNS_CHECK_TYPE_BOTH: 'CheckResult_Type_Both', SNS_CHECK_TYPE_SINGLE: 'CheckResult_Type_Single', SNS_TYPE_NO_RELATION: 'CheckResult_Type_NoRelation', SNS_TYPE_A_WITH_B: 'CheckResult_Type_AWithB', SNS_TYPE_B_WITH_A: 'CheckResult_Type_BWithA', SNS_TYPE_BOTH_WAY: 'CheckResult_Type_BothWay', NET_STATE_CONNECTED: 'connected', NET_STATE_CONNECTING: 'connecting', NET_STATE_DISCONNECTED: 'disconnected', MSG_AT_ALL: '__kImSDK_MesssageAtALL__' }; const C = (function () { - function e() { - o(this, e), this.cache = [], this.options = null; - } return s(e, [{ key: 'use', value(e) { - if ('function' !== typeof e) throw 'middleware must be a function';return this.cache.push(e), this; - } }, { key: 'next', value(e) { - if (this.middlewares && this.middlewares.length > 0) return this.middlewares.shift().call(this, this.options, this.next.bind(this)); - } }, { key: 'run', value(e) { - return this.middlewares = this.cache.map((e => e)), this.options = e, this.next(); - } }]), e; - }()); const N = 'undefined' !== typeof globalThis ? globalThis : 'undefined' !== typeof window ? window : 'undefined' !== typeof global ? global : 'undefined' !== typeof self ? self : {};function A(e, t) { - return e(t = { exports: {} }, t.exports), t.exports; - } const O = A(((e, t) => { - let n; let o; let a; let s; let r; let i; let c; let u; let l; let d; let g; let p; let h; let _; let f; let m; let M; let v;e.exports = (n = 'function' === typeof Promise, o = 'object' === typeof self ? self : N, a = 'undefined' !== typeof Symbol, s = 'undefined' !== typeof Map, r = 'undefined' !== typeof Set, i = 'undefined' !== typeof WeakMap, c = 'undefined' !== typeof WeakSet, u = 'undefined' !== typeof DataView, l = a && void 0 !== Symbol.iterator, d = a && void 0 !== Symbol.toStringTag, g = r && 'function' === typeof Set.prototype.entries, p = s && 'function' === typeof Map.prototype.entries, h = g && Object.getPrototypeOf((new Set).entries()), _ = p && Object.getPrototypeOf((new Map).entries()), f = l && 'function' === typeof Array.prototype[Symbol.iterator], m = f && Object.getPrototypeOf([][Symbol.iterator]()), M = l && 'function' === typeof String.prototype[Symbol.iterator], v = M && Object.getPrototypeOf(''[Symbol.iterator]()), function (e) { - const t = typeof e;if ('object' !== t) return t;if (null === e) return 'null';if (e === o) return 'global';if (Array.isArray(e) && (!1 === d || !(Symbol.toStringTag in e))) return 'Array';if ('object' === typeof window && null !== window) { - if ('object' === typeof window.location && e === window.location) return 'Location';if ('object' === typeof window.document && e === window.document) return 'Document';if ('object' === typeof window.navigator) { - if ('object' === typeof window.navigator.mimeTypes && e === window.navigator.mimeTypes) return 'MimeTypeArray';if ('object' === typeof window.navigator.plugins && e === window.navigator.plugins) return 'PluginArray'; - } if (('function' === typeof window.HTMLElement || 'object' === typeof window.HTMLElement) && e instanceof window.HTMLElement) { - if ('BLOCKQUOTE' === e.tagName) return 'HTMLQuoteElement';if ('TD' === e.tagName) return 'HTMLTableDataCellElement';if ('TH' === e.tagName) return 'HTMLTableHeaderCellElement'; - } - } const a = d && e[Symbol.toStringTag];if ('string' === typeof a) return a;const l = Object.getPrototypeOf(e);return l === RegExp.prototype ? 'RegExp' : l === Date.prototype ? 'Date' : n && l === Promise.prototype ? 'Promise' : r && l === Set.prototype ? 'Set' : s && l === Map.prototype ? 'Map' : c && l === WeakSet.prototype ? 'WeakSet' : i && l === WeakMap.prototype ? 'WeakMap' : u && l === DataView.prototype ? 'DataView' : s && l === _ ? 'Map Iterator' : r && l === h ? 'Set Iterator' : f && l === m ? 'Array Iterator' : M && l === v ? 'String Iterator' : null === l ? 'Object' : Object.prototype.toString.call(e).slice(8, -1); - }); - })); const L = { WEB: 7, WX_MP: 8, QQ_MP: 9, TT_MP: 10, BAIDU_MP: 11, ALI_MP: 12, UNI_NATIVE_APP: 14 }; const R = '1.7.3'; const G = 537048168; const w = 1; const P = 2; const b = 3; const U = { HOST: { CURRENT: { DEFAULT: '', BACKUP: '' }, TEST: { DEFAULT: 'wss://wss-dev.tim.qq.com', BACKUP: 'wss://wss-dev.tim.qq.com' }, PRODUCTION: { DEFAULT: 'wss://wss.im.qcloud.com', BACKUP: 'wss://wss.tim.qq.com' }, OVERSEA_PRODUCTION: { DEFAULT: 'wss://wss.im.qcloud.com', BACKUP: 'wss://wss.im.qcloud.com' }, setCurrent() { - const e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : 2;e === w ? this.CURRENT = this.TEST : e === P ? this.CURRENT = this.PRODUCTION : e === b && (this.CURRENT = this.OVERSEA_PRODUCTION); - } }, NAME: { OPEN_IM: 'openim', GROUP: 'group_open_http_svc', FRIEND: 'sns', PROFILE: 'profile', RECENT_CONTACT: 'recentcontact', PIC: 'openpic', BIG_GROUP_NO_AUTH: 'group_open_http_noauth_svc', BIG_GROUP_LONG_POLLING: 'group_open_long_polling_http_svc', BIG_GROUP_LONG_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_MESSAGE: 'im_long_msg', CLOUD_CONTROL: 'im_sdk_config_mgr' }, CMD: { ACCESS_LAYER: 'accesslayer', LOGIN: 'wslogin', LOGOUT_LONG_POLL: 'longpollinglogout', LOGOUT: 'wslogout', HELLO: 'wshello', PORTRAIT_GET: 'portrait_get_all', PORTRAIT_SET: 'portrait_set', GET_LONG_POLL_ID: 'getlongpollingid', LONG_POLL: 'longpolling', AVCHATROOM_LONG_POLL: 'get_msg', ADD_FRIEND: 'friend_add', UPDATE_FRIEND: 'friend_update', GET_FRIEND_LIST: 'friend_get', GET_FRIEND_PROFILE: 'friend_get_list', DELETE_FRIEND: 'friend_delete', CHECK_FRIEND: 'friend_check', GET_FRIEND_GROUP_LIST: 'group_get', RESPOND_FRIEND_APPLICATION: 'friend_response', GET_FRIEND_APPLICATION_LIST: 'pendency_get', DELETE_FRIEND_APPLICATION: 'pendency_delete', REPORT_FRIEND_APPLICATION: 'pendency_report', GET_GROUP_APPLICATION: 'get_pendency', CREATE_FRIEND_GROUP: 'group_add', DELETE_FRIEND_GROUP: 'group_delete', UPDATE_FRIEND_GROUP: 'group_update', GET_BLACKLIST: 'black_list_get', ADD_BLACKLIST: 'black_list_add', DELETE_BLACKLIST: 'black_list_delete', CREATE_GROUP: 'create_group', GET_JOINED_GROUPS: 'get_joined_group_list', SEND_MESSAGE: 'sendmsg', REVOKE_C2C_MESSAGE: 'msgwithdraw', DELETE_C2C_MESSAGE: 'delete_c2c_msg_ramble', SEND_GROUP_MESSAGE: 'send_group_msg', REVOKE_GROUP_MESSAGE: 'group_msg_recall', DELETE_GROUP_MESSAGE: 'delete_group_ramble_msg_by_seq', GET_GROUP_INFO: 'get_group_info', GET_GROUP_MEMBER_INFO: 'get_specified_group_member_info', GET_GROUP_MEMBER_LIST: 'get_group_member_info', QUIT_GROUP: 'quit_group', CHANGE_GROUP_OWNER: 'change_group_owner', DESTROY_GROUP: 'destroy_group', ADD_GROUP_MEMBER: 'add_group_member', DELETE_GROUP_MEMBER: 'delete_group_member', SEARCH_GROUP_BY_ID: 'get_group_public_info', APPLY_JOIN_GROUP: 'apply_join_group', HANDLE_APPLY_JOIN_GROUP: 'handle_apply_join_group', HANDLE_GROUP_INVITATION: 'handle_invite_join_group', MODIFY_GROUP_INFO: 'modify_group_base_info', MODIFY_GROUP_MEMBER_INFO: 'modify_group_member_info', DELETE_GROUP_SYSTEM_MESSAGE: 'deletemsg', DELETE_GROUP_AT_TIPS: 'deletemsg', GET_CONVERSATION_LIST: 'get', PAGING_GET_CONVERSATION_LIST: 'page_get', DELETE_CONVERSATION: 'delete', GET_MESSAGES: 'getmsg', GET_C2C_ROAM_MESSAGES: 'getroammsg', GET_GROUP_ROAM_MESSAGES: 'group_msg_get', SET_C2C_MESSAGE_READ: 'msgreaded', GET_PEER_READ_TIME: 'get_peer_read_time', SET_GROUP_MESSAGE_READ: 'msg_read_report', FILE_READ_AND_WRITE_AUTHKEY: 'authkey', FILE_UPLOAD: 'pic_up', COS_SIGN: 'cos', COS_PRE_SIG: 'pre_sig', TIM_WEB_REPORT_V2: 'tim_web_report_v2', BIG_DATA_HALLWAY_AUTH_KEY: 'authkey', GET_ONLINE_MEMBER_NUM: 'get_online_member_num', ALIVE: 'alive', MESSAGE_PUSH: 'msg_push', MESSAGE_PUSH_ACK: 'ws_msg_push_ack', STATUS_FORCEOFFLINE: 'stat_forceoffline', DOWNLOAD_MERGER_MESSAGE: 'get_relay_json_msg', UPLOAD_MERGER_MESSAGE: 'save_relay_json_msg', FETCH_CLOUD_CONTROL_CONFIG: 'fetch_config', PUSHED_CLOUD_CONTROL_CONFIG: 'push_configv2' }, CHANNEL: { SOCKET: 1, XHR: 2, AUTO: 0 }, NAME_VERSION: { openim: 'v4', group_open_http_svc: 'v4', sns: 'v4', profile: 'v4', recentcontact: 'v4', openpic: 'v4', group_open_http_noauth_svc: 'v4', group_open_long_polling_http_svc: 'v4', group_open_long_polling_http_noauth_svc: 'v4', imopenstat: 'v4', im_cos_sign_svr: 'v4', im_cos_msg: 'v4', webim: 'v4', im_open_push: 'v4', im_open_status: 'v4' } };U.HOST.setCurrent(P);let F; let q; let V; let K; const x = 'undefined' !== typeof wx && 'function' === typeof wx.getSystemInfoSync && Boolean(wx.getSystemInfoSync().fontSizeSetting); const B = 'undefined' !== typeof qq && 'function' === typeof qq.getSystemInfoSync && Boolean(qq.getSystemInfoSync().fontSizeSetting); const H = 'undefined' !== typeof tt && 'function' === typeof tt.getSystemInfoSync && Boolean(tt.getSystemInfoSync().fontSizeSetting); const j = 'undefined' !== typeof swan && 'function' === typeof swan.getSystemInfoSync && Boolean(swan.getSystemInfoSync().fontSizeSetting); const $ = 'undefined' !== typeof my && 'function' === typeof my.getSystemInfoSync && Boolean(my.getSystemInfoSync().fontSizeSetting); const Y = 'undefined' !== typeof uni && 'undefined' === typeof window; const z = x || B || H || j || $ || Y; const W = ('undefined' !== typeof uni || 'undefined' !== typeof window) && !z; const J = B ? qq : H ? tt : j ? swan : $ ? my : x ? wx : Y ? uni : {}; const X = (F = 'WEB', de ? F = 'WEB' : B ? F = 'QQ_MP' : H ? F = 'TT_MP' : j ? F = 'BAIDU_MP' : $ ? F = 'ALI_MP' : x ? F = 'WX_MP' : Y && (F = 'UNI_NATIVE_APP'), L[F]); const Q = W && window && window.navigator && window.navigator.userAgent || ''; const Z = /AppleWebKit\/([\d.]+)/i.exec(Q); const ee = (Z && parseFloat(Z.pop()), /iPad/i.test(Q)); const te = /iPhone/i.test(Q) && !ee; const ne = /iPod/i.test(Q); const oe = te || ee || ne; const ae = ((q = Q.match(/OS (\d+)_/i)) && q[1] && q[1], /Android/i.test(Q)); const se = (function () { - const e = Q.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);if (!e) return null;const t = e[1] && parseFloat(e[1]); const n = e[2] && parseFloat(e[2]);return t && n ? parseFloat(`${e[1]}.${e[2]}`) : t || null; - }()); const re = (ae && /webkit/i.test(Q), /Firefox/i.test(Q), /Edge/i.test(Q)); const ie = !re && /Chrome/i.test(Q); const ce = ((function () { - const e = Q.match(/Chrome\/(\d+)/);e && e[1] && parseFloat(e[1]); - }()), /MSIE/.test(Q)); const ue = (/MSIE\s8\.0/.test(Q), (function () { - const e = /MSIE\s(\d+)\.\d/.exec(Q); let t = e && parseFloat(e[1]);return !t && /Trident\/7.0/i.test(Q) && /rv:11.0/.test(Q) && (t = 11), t; - }())); const le = (/Safari/i.test(Q), /TBS\/\d+/i.test(Q)); var de = ((function () { - const e = Q.match(/TBS\/(\d+)/i);if (e && e[1])e[1]; - }()), !le && /MQQBrowser\/\d+/i.test(Q), !le && / QQBrowser\/\d+/i.test(Q), /(micromessenger|webbrowser)/i.test(Q)); const ge = /Windows/i.test(Q); const pe = /MAC OS X/i.test(Q); const he = (/MicroMessenger/i.test(Q), 'undefined' !== typeof global ? global : 'undefined' !== typeof self ? self : 'undefined' !== typeof window ? window : {});V = 'undefined' !== typeof console ? console : void 0 !== he && he.console ? he.console : 'undefined' !== typeof window && window.console ? window.console : {};for (var _e = function () {}, fe = ['assert', 'clear', 'count', 'debug', 'dir', 'dirxml', 'error', 'exception', 'group', 'groupCollapsed', 'groupEnd', 'info', 'log', 'markTimeline', 'profile', 'profileEnd', 'table', 'time', 'timeEnd', 'timeStamp', 'trace', 'warn'], me = fe.length;me--;)K = fe[me], console[K] || (V[K] = _e);V.methods = fe;const Me = V; let ve = 0; const ye = function () { - return (new Date).getTime() + ve; - }; const Ie = function () { - ve = 0; - }; let De = 0; const Te = new Map;function Se() { - let e; const t = ((e = new Date).setTime(ye()), e);return `TIM ${t.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; - }(t.getMilliseconds()))}:`; - } const Ee = { arguments2String(e) { - let t;if (1 === e.length)t = Se() + e[0];else { - t = Se();for (let n = 0, o = e.length;n < o;n++)we(e[n]) ? be(e[n]) ? t += xe(e[n]) : t += JSON.stringify(e[n]) : t += e[n], t += ' '; - } return t; - }, debug() { - if (De <= -1) { - const e = this.arguments2String(arguments);Me.debug(e); - } - }, log() { - if (De <= 0) { - const e = this.arguments2String(arguments);Me.log(e); - } - }, info() { - if (De <= 1) { - const e = this.arguments2String(arguments);Me.info(e); - } - }, warn() { - if (De <= 2) { - const e = this.arguments2String(arguments);Me.warn(e); - } - }, error() { - if (De <= 3) { - const e = this.arguments2String(arguments);Me.error(e); - } - }, time(e) { - Te.set(e, Ve.now()); - }, timeEnd(e) { - if (Te.has(e)) { - const t = Ve.now() - Te.get(e);return Te.delete(e), t; - } return Me.warn('未找到对应label: '.concat(e, ', 请在调用 logger.timeEnd 前,调用 logger.time')), 0; - }, setLevel(e) { - e < 4 && Me.log(`${Se()}set level from ${De} to ${e}`), De = e; - }, getLevel() { - return De; - } }; const ke = ['url']; const Ce = function (e) { - return 'file' === Ue(e); - }; const Ne = function (e) { - return null !== e && ('number' === typeof e && !isNaN(e - 0) || 'object' === n(e) && e.constructor === Number); - }; const Ae = function (e) { - return 'string' === typeof e; - }; const Oe = function (e) { - return null !== e && 'object' === n(e); - }; const Le = function (e) { - if ('object' !== n(e) || null === e) return !1;const t = Object.getPrototypeOf(e);if (null === t) return !0;for (var o = t;null !== Object.getPrototypeOf(o);)o = Object.getPrototypeOf(o);return t === o; - }; const Re = function (e) { - return 'function' === typeof Array.isArray ? Array.isArray(e) : 'array' === Ue(e); - }; const Ge = function (e) { - return void 0 === e; - }; var we = function (e) { - return Re(e) || Oe(e); - }; const Pe = function (e) { - return 'function' === typeof e; - }; var be = function (e) { - return e instanceof Error; - }; var Ue = function (e) { - return Object.prototype.toString.call(e).match(/^\[object (.*)\]$/)[1].toLowerCase(); - }; const Fe = function (e) { - if ('string' !== typeof e) return !1;const t = e[0];return !/[^a-zA-Z0-9]/.test(t); - }; let qe = 0;Date.now || (Date.now = function () { - return (new Date).getTime(); - });var Ve = { now() { - 0 === qe && (qe = Date.now() - 1);const e = Date.now() - qe;return e > 4294967295 ? (qe += 4294967295, Date.now() - qe) : e; - }, utc() { - return Math.round(Date.now() / 1e3); - } }; const Ke = function e(t, n, o, a) { - if (!we(t) || !we(n)) return 0;for (var s, r = 0, i = Object.keys(n), c = 0, u = i.length;c < u;c++) if (s = i[c], !(Ge(n[s]) || o && o.includes(s))) if (we(t[s]) && we(n[s]))r += e(t[s], n[s], o, a);else { - if (a && a.includes(n[s])) continue;t[s] !== n[s] && (t[s] = n[s], r += 1); - } return r; - }; var xe = function (e) { - return JSON.stringify(e, ['message', 'code']); - }; const Be = function (e) { - if (0 === e.length) return 0;for (var t = 0, n = 0, o = 'undefined' !== typeof document && void 0 !== document.characterSet ? document.characterSet : 'UTF-8';void 0 !== e[t];)n += e[t++].charCodeAt[t] <= 255 ? 1 : !1 === o ? 3 : 2;return n; - }; const He = function (e) { - const t = e || 99999999;return Math.round(Math.random() * t); - }; const je = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; const $e = je.length; const Ye = function (e, t) { - for (const n in e) if (e[n] === t) return !0;return !1; - }; const ze = {}; const We = function () { - if (z) return 'https:';if (W && 'undefined' === typeof window) return 'https:';let e = window.location.protocol;return ['http:', 'https:'].indexOf(e) < 0 && (e = 'http:'), e; - }; const Je = function (e) { - return -1 === e.indexOf('http://') || -1 === e.indexOf('https://') ? `https://${e}` : e.replace(/https|http/, 'https'); - }; const Xe = function e(t) { - if (0 === Object.getOwnPropertyNames(t).length) return Object.create(null);const o = Array.isArray(t) ? [] : Object.create(null); let a = '';for (const s in t)null !== t[s] ? void 0 !== t[s] ? (a = n(t[s]), ['string', 'number', 'function', 'boolean'].indexOf(a) >= 0 ? o[s] = t[s] : o[s] = e(t[s])) : o[s] = void 0 : o[s] = null;return o; - };function Qe(e, t) { - Re(e) && Re(t) ? t.forEach(((t) => { - const n = t.key; const o = t.value; const a = e.find((e => e.key === n));a ? a.value = o : e.push({ key: n, value: o }); - })) : Ee.warn('updateCustomField target 或 source 不是数组,忽略此次更新。'); - } const Ze = function (e) { - return e === k.GRP_PUBLIC; - }; const et = function (e) { - return e === k.GRP_AVCHATROOM; - }; const nt = function (e) { - return Ae(e) && e === k.CONV_SYSTEM; - };function ot(e, t) { - const n = {};return Object.keys(e).forEach(((o) => { - n[o] = t(e[o], o); - })), n; - } function at() { - function e() { - return (65536 * (1 + Math.random()) | 0).toString(16).substring(1); - } return ''.concat(e() + e()).concat(e()) - .concat(e()) - .concat(e()) - .concat(e()) - .concat(e()) - .concat(e()); - } function st() { - let e = 'unknown';if (pe && (e = 'mac'), ge && (e = 'windows'), oe && (e = 'ios'), ae && (e = 'android'), z) try { - const t = J.getSystemInfoSync().platform;void 0 !== t && (e = t); - } catch (n) {} return e; - } function rt(e) { - const t = e.originUrl; const n = void 0 === t ? void 0 : t; const o = e.originWidth; const a = e.originHeight; const s = e.min; const r = void 0 === s ? 198 : s; const i = parseInt(o); const c = parseInt(a); const u = { url: void 0, width: 0, height: 0 };return (i <= c ? i : c) <= r ? (u.url = n, u.width = i, u.height = c) : (c <= i ? (u.width = Math.ceil(i * r / c), u.height = r) : (u.width = r, u.height = Math.ceil(c * r / i)), u.url = ''.concat(n, 198 === r ? '?imageView2/3/w/198/h/198' : '?imageView2/3/w/720/h/720')), Ge(n) ? p(u, ke) : u; - } function it(e) { - const t = e[2];e[2] = e[1], e[1] = t;for (let n = 0;n < e.length;n++)e[n].setType(n); - } function ct(e) { - const t = e.servcmd;return t.slice(t.indexOf('.') + 1); - } function ut(e, t) { - return Math.round(Number(e) * Math.pow(10, t)) / Math.pow(10, t); - } const lt = Object.prototype.hasOwnProperty;function dt(e) { - if (null == e) return !0;if ('boolean' === typeof e) return !1;if ('number' === typeof e) return 0 === e;if ('string' === typeof e) return 0 === e.length;if ('function' === typeof e) return 0 === e.length;if (Array.isArray(e)) return 0 === e.length;if (e instanceof Error) return '' === e.message;if (Le(e)) { - for (const t in e) if (lt.call(e, t)) return !1;return !0; - } return !('map' !== Ue(e) && !(function (e) { - return 'set' === Ue(e); - }(e)) && !Ce(e)) && 0 === e.size; - } function gt(e, t, n) { - if (void 0 === t) return !0;let o = !0;if ('object' === O(t).toLowerCase())Object.keys(t).forEach(((a) => { - const s = 1 === e.length ? e[0][a] : void 0;o = !!pt(s, t[a], n, a) && o; - }));else if ('array' === O(t).toLowerCase()) for (let a = 0;a < t.length;a++)o = !!pt(e[a], t[a], n, t[a].name) && o;if (o) return o;throw new Error('Params validate failed.'); - } function pt(e, t, n, o) { - if (void 0 === t) return !0;let a = !0;return t.required && dt(e) && (Me.error('TIM ['.concat(n, '] Missing required params: "').concat(o, '".')), a = !1), dt(e) || O(e).toLowerCase() === t.type.toLowerCase() || (Me.error('TIM ['.concat(n, '] Invalid params: type check failed for "').concat(o, '".Expected ') - .concat(t.type, '.')), a = !1), t.validator && !t.validator(e) && (Me.error('TIM ['.concat(n, '] Invalid params: custom validator check failed for params.')), a = !1), a; - } let ht; const _t = { UNSEND: 'unSend', SUCCESS: 'success', FAIL: 'fail' }; const ft = { NOT_START: 'notStart', PENDING: 'pengding', RESOLVED: 'resolved', REJECTED: 'rejected' }; const mt = function (e) { - return !!e && (!!((function (e) { - return Ae(e) && e.slice(0, 3) === k.CONV_C2C; - }(e)) || (function (e) { - return Ae(e) && e.slice(0, 5) === k.CONV_GROUP; - }(e)) || nt(e)) || (console.warn('非法的会话 ID:'.concat(e, '。会话 ID 组成方式:C2C + userID(单聊)GROUP + groupID(群聊)@TIM#SYSTEM(系统通知会话)')), !1)); - }; const Mt = '请参考 https://web.sdk.qcloud.com/im/doc/zh-cn/SDK.html#'; const vt = function (e) { - return e.param ? ''.concat(e.api, ' ').concat(e.param, ' ') - .concat(e.desc, '。') - .concat(Mt) - .concat(e.api) : ''.concat(e.api, ' ').concat(e.desc, '。') - .concat(Mt) - .concat(e.api); - }; const yt = { type: 'String', required: !0 }; const It = { type: 'Array', required: !0 }; const Dt = { type: 'Object', required: !0 }; const Tt = { login: { userID: yt, userSig: yt }, addToBlacklist: { userIDList: It }, on: [{ name: 'eventName', type: 'String', validator(e) { - return 'string' === typeof e && 0 !== e.length || (console.warn(vt({ api: 'on', param: 'eventName', desc: '类型必须为 String,且不能为空' })), !1); - } }, { name: 'handler', type: 'Function', validator(e) { - return 'function' !== typeof e ? (console.warn(vt({ api: 'on', param: 'handler', desc: '参数必须为 Function' })), !1) : ('' === e.name && console.warn('on 接口的 handler 参数推荐使用具名函数。具名函数可以使用 off 接口取消订阅,匿名函数无法取消订阅。'), !0); - } }], once: [{ name: 'eventName', type: 'String', validator(e) { - return 'string' === typeof e && 0 !== e.length || (console.warn(vt({ api: 'once', param: 'eventName', desc: '类型必须为 String,且不能为空' })), !1); - } }, { name: 'handler', type: 'Function', validator(e) { - return 'function' !== typeof e ? (console.warn(vt({ api: 'once', param: 'handler', desc: '参数必须为 Function' })), !1) : ('' === e.name && console.warn('once 接口的 handler 参数推荐使用具名函数。'), !0); - } }], off: [{ name: 'eventName', type: 'String', validator(e) { - return 'string' === typeof e && 0 !== e.length || (console.warn(vt({ api: 'off', param: 'eventName', desc: '类型必须为 String,且不能为空' })), !1); - } }, { name: 'handler', type: 'Function', validator(e) { - return 'function' !== typeof e ? (console.warn(vt({ api: 'off', param: 'handler', desc: '参数必须为 Function' })), !1) : ('' === e.name && console.warn('off 接口无法为匿名函数取消监听事件。'), !0); - } }], sendMessage: [t({ name: 'message' }, Dt)], getMessageList: { conversationID: t(t({}, yt), {}, { validator(e) { - return mt(e); - } }), nextReqMessageID: { type: 'String' }, count: { type: 'Number', validator(e) { - return !(!Ge(e) && !/^[1-9][0-9]*$/.test(e)) || (console.warn(vt({ api: 'getMessageList', param: 'count', desc: '必须为正整数' })), !1); - } } }, setMessageRead: { conversationID: t(t({}, yt), {}, { validator(e) { - return mt(e); - } }) }, getConversationProfile: [t(t({ name: 'conversationID' }, yt), {}, { validator(e) { - return mt(e); - } })], deleteConversation: [t(t({ name: 'conversationID' }, yt), {}, { validator(e) { - return mt(e); - } })], getGroupList: { groupProfileFilter: { type: 'Array' } }, getGroupProfile: { groupID: yt, groupCustomFieldFilter: { type: 'Array' }, memberCustomFieldFilter: { type: 'Array' } }, getGroupProfileAdvance: { groupIDList: It }, createGroup: { name: yt }, joinGroup: { groupID: yt, type: { type: 'String' }, applyMessage: { type: 'String' } }, quitGroup: [t({ name: 'groupID' }, yt)], handleApplication: { message: Dt, handleAction: yt, handleMessage: { type: 'String' } }, changeGroupOwner: { groupID: yt, newOwnerID: yt }, updateGroupProfile: { groupID: yt, muteAllMembers: { type: 'Boolean' } }, dismissGroup: [t({ name: 'groupID' }, yt)], searchGroupByID: [t({ name: 'groupID' }, yt)], getGroupMemberList: { groupID: yt, offset: { type: 'Number' }, count: { type: 'Number' } }, getGroupMemberProfile: { groupID: yt, userIDList: It, memberCustomFieldFilter: { type: 'Array' } }, addGroupMember: { groupID: yt, userIDList: It }, setGroupMemberRole: { groupID: yt, userID: yt, role: yt }, setGroupMemberMuteTime: { groupID: yt, userID: yt, muteTime: { type: 'Number', validator(e) { - return e >= 0; - } } }, setGroupMemberNameCard: { groupID: yt, userID: { type: 'String' }, nameCard: t(t({}, yt), {}, { validator(e) { - return !0 !== /^\s+$/.test(e); - } }) }, setMessageRemindType: { groupID: yt, messageRemindType: yt }, setGroupMemberCustomField: { groupID: yt, userID: { type: 'String' }, memberCustomField: It }, deleteGroupMember: { groupID: yt }, createTextMessage: { to: yt, conversationType: yt, payload: t(t({}, Dt), {}, { validator(e) { - return Le(e) ? Ae(e.text) ? 0 !== e.text.length || (console.warn(vt({ api: 'createTextMessage', desc: '消息内容不能为空' })), !1) : (console.warn(vt({ api: 'createTextMessage', param: 'payload.text', desc: '类型必须为 String' })), !1) : (console.warn(vt({ api: 'createTextMessage', param: 'payload', desc: '类型必须为 plain object' })), !1); - } }) }, createTextAtMessage: { to: yt, conversationType: yt, payload: t(t({}, Dt), {}, { validator(e) { - return Le(e) ? Ae(e.text) ? 0 === e.text.length ? (console.warn(vt({ api: 'createTextAtMessage', desc: '消息内容不能为空' })), !1) : !(e.atUserList && !Re(e.atUserList)) || (console.warn(vt({ api: 'createTextAtMessage', desc: 'payload.atUserList 类型必须为数组' })), !1) : (console.warn(vt({ api: 'createTextAtMessage', param: 'payload.text', desc: '类型必须为 String' })), !1) : (console.warn(vt({ api: 'createTextAtMessage', param: 'payload', desc: '类型必须为 plain object' })), !1); - } }) }, createCustomMessage: { to: yt, conversationType: yt, payload: t(t({}, Dt), {}, { validator(e) { - return Le(e) ? e.data && !Ae(e.data) ? (console.warn(vt({ api: 'createCustomMessage', param: 'payload.data', desc: '类型必须为 String' })), !1) : e.description && !Ae(e.description) ? (console.warn(vt({ api: 'createCustomMessage', param: 'payload.description', desc: '类型必须为 String' })), !1) : !(e.extension && !Ae(e.extension)) || (console.warn(vt({ api: 'createCustomMessage', param: 'payload.extension', desc: '类型必须为 String' })), !1) : (console.warn(vt({ api: 'createCustomMessage', param: 'payload', desc: '类型必须为 plain object' })), !1); - } }) }, createImageMessage: { to: yt, conversationType: yt, payload: t(t({}, Dt), {}, { validator(e) { - if (!Le(e)) return console.warn(vt({ api: 'createImageMessage', param: 'payload', desc: '类型必须为 plain object' })), !1;if (Ge(e.file)) return console.warn(vt({ api: 'createImageMessage', param: 'payload.file', desc: '不能为 undefined' })), !1;if (W) { - if (!(e.file instanceof HTMLInputElement || Ce(e.file))) return Le(e.file) && 'undefined' !== typeof uni ? 0 !== e.file.tempFilePaths.length && 0 !== e.file.tempFiles.length || (console.warn(vt({ api: 'createImageMessage', param: 'payload.file', desc: '您没有选择文件,无法发送' })), !1) : (console.warn(vt({ api: 'createImageMessage', param: 'payload.file', desc: '类型必须是 HTMLInputElement 或 File' })), !1);if (e.file instanceof HTMLInputElement && 0 === e.file.files.length) return console.warn(vt({ api: 'createImageMessage', param: 'payload.file', desc: '您没有选择文件,无法发送' })), !1; - } return !0; - }, onProgress: { type: 'Function', required: !1, validator(e) { - return Ge(e) && console.warn(vt({ api: 'createImageMessage', desc: '没有 onProgress 回调,您将无法获取上传进度' })), !0; - } } }) }, createAudioMessage: { to: yt, conversationType: yt, payload: t(t({}, Dt), {}, { validator(e) { - return !!Le(e) || (console.warn(vt({ api: 'createAudioMessage', param: 'payload', desc: '类型必须为 plain object' })), !1); - } }), onProgress: { type: 'Function', required: !1, validator(e) { - return Ge(e) && console.warn(vt({ api: 'createAudioMessage', desc: '没有 onProgress 回调,您将无法获取上传进度' })), !0; - } } }, createVideoMessage: { to: yt, conversationType: yt, payload: t(t({}, Dt), {}, { validator(e) { - if (!Le(e)) return console.warn(vt({ api: 'createVideoMessage', param: 'payload', desc: '类型必须为 plain object' })), !1;if (Ge(e.file)) return console.warn(vt({ api: 'createVideoMessage', param: 'payload.file', desc: '不能为 undefined' })), !1;if (W) { - if (!(e.file instanceof HTMLInputElement || Ce(e.file))) return Le(e.file) && 'undefined' !== typeof uni ? !!Ce(e.file.tempFile) || (console.warn(vt({ api: 'createVideoMessage', param: 'payload.file', desc: '您没有选择文件,无法发送' })), !1) : (console.warn(vt({ api: 'createVideoMessage', param: 'payload.file', desc: '类型必须是 HTMLInputElement 或 File' })), !1);if (e.file instanceof HTMLInputElement && 0 === e.file.files.length) return console.warn(vt({ api: 'createVideoMessage', param: 'payload.file', desc: '您没有选择文件,无法发送' })), !1; - } return !0; - } }), onProgress: { type: 'Function', required: !1, validator(e) { - return Ge(e) && console.warn(vt({ api: 'createVideoMessage', desc: '没有 onProgress 回调,您将无法获取上传进度' })), !0; - } } }, createFaceMessage: { to: yt, conversationType: yt, payload: t(t({}, Dt), {}, { validator(e) { - return Le(e) ? Ne(e.index) ? !!Ae(e.data) || (console.warn(vt({ api: 'createFaceMessage', param: 'payload.data', desc: '类型必须为 String' })), !1) : (console.warn(vt({ api: 'createFaceMessage', param: 'payload.index', desc: '类型必须为 Number' })), !1) : (console.warn(vt({ api: 'createFaceMessage', param: 'payload', desc: '类型必须为 plain object' })), !1); - } }) }, createFileMessage: { to: yt, conversationType: yt, payload: t(t({}, Dt), {}, { validator(e) { - if (!Le(e)) return console.warn(vt({ api: 'createFileMessage', param: 'payload', desc: '类型必须为 plain object' })), !1;if (Ge(e.file)) return console.warn(vt({ api: 'createFileMessage', param: 'payload.file', desc: '不能为 undefined' })), !1;if (W) { - if (!(e.file instanceof HTMLInputElement || Ce(e.file))) return Le(e.file) && 'undefined' !== typeof uni ? 0 !== e.file.tempFilePaths.length && 0 !== e.file.tempFiles.length || (console.warn(vt({ api: 'createFileMessage', param: 'payload.file', desc: '您没有选择文件,无法发送' })), !1) : (console.warn(vt({ api: 'createFileMessage', param: 'payload.file', desc: '类型必须是 HTMLInputElement 或 File' })), !1);if (e.file instanceof HTMLInputElement && 0 === e.file.files.length) return console.warn(vt({ api: 'createFileMessage', desc: '您没有选择文件,无法发送' })), !1; - } return !0; - } }), onProgress: { type: 'Function', required: !1, validator(e) { - return Ge(e) && console.warn(vt({ api: 'createFileMessage', desc: '没有 onProgress 回调,您将无法获取上传进度' })), !0; - } } }, createMergerMessage: { to: yt, conversationType: yt, payload: t(t({}, Dt), {}, { validator(e) { - if (dt(e.messageList)) return console.warn(vt({ api: 'createMergerMessage', desc: '不能为空数组' })), !1;if (dt(e.compatibleText)) return console.warn(vt({ api: 'createMergerMessage', desc: '类型必须为 String,且不能为空' })), !1;let t = !1;return e.messageList.forEach(((e) => { - e.status === _t.FAIL && (t = !0); - })), !t || (console.warn(vt({ api: 'createMergerMessage', desc: '不支持合并已发送失败的消息' })), !1); - } }) }, revokeMessage: [t(t({ name: 'message' }, Dt), {}, { validator(e) { - return dt(e) ? (console.warn('revokeMessage 请传入消息(Message)实例'), !1) : e.conversationType === k.CONV_SYSTEM ? (console.warn('revokeMessage 不能撤回系统会话消息,只能撤回单聊消息或群消息'), !1) : !0 !== e.isRevoked || (console.warn('revokeMessage 消息已经被撤回,请勿重复操作'), !1); - } })], deleteMessage: [t(t({ name: 'messageList' }, It), {}, { validator(e) { - return !dt(e) || (console.warn(vt({ api: 'deleteMessage', param: 'messageList', desc: '不能为空数组' })), !1); - } })], getUserProfile: { userIDList: { type: 'Array', validator(e) { - return Re(e) ? (0 === e.length && console.warn(vt({ api: 'getUserProfile', param: 'userIDList', desc: '不能为空数组' })), !0) : (console.warn(vt({ api: 'getUserProfile', param: 'userIDList', desc: '必须为数组' })), !1); - } } }, updateMyProfile: { profileCustomField: { type: 'Array', validator(e) { - return !!Ge(e) || (!!Re(e) || (console.warn(vt({ api: 'updateMyProfile', param: 'profileCustomField', desc: '必须为数组' })), !1)); - } } }, addFriend: { to: yt, source: { type: 'String', required: !0, validator(e) { - return !!e && (e.startsWith('AddSource_Type_') ? !(e.replace('AddSource_Type_', '').length > 8) || (console.warn(vt({ api: 'addFriend', desc: '加好友来源字段的关键字长度不得超过8字节' })), !1) : (console.warn(vt({ api: 'addFriend', desc: '加好友来源字段的前缀必须是:AddSource_Type_' })), !1)); - } }, remark: { type: 'String', required: !1, validator(e) { - return !(Ae(e) && e.length > 96) || (console.warn(vt({ api: 'updateFriend', desc: ' 备注长度最长不得超过 96 个字节' })), !1); - } } }, deleteFriend: { userIDList: It }, checkFriend: { userIDList: It }, getFriendProfile: { userIDList: It }, updateFriend: { userID: yt, remark: { type: 'String', required: !1, validator(e) { - return !(Ae(e) && e.length > 96) || (console.warn(vt({ api: 'updateFriend', desc: ' 备注长度最长不得超过 96 个字节' })), !1); - } }, friendCustomField: { type: 'Array', required: !1, validator(e) { - if (e) { - if (!Re(e)) return console.warn(vt({ api: 'updateFriend', param: 'friendCustomField', desc: '必须为数组' })), !1;let t = !0;return e.forEach((e => (Ae(e.key) && -1 !== e.key.indexOf('Tag_SNS_Custom') ? Ae(e.value) ? e.value.length > 8 ? (console.warn(vt({ api: 'updateFriend', desc: '好友自定义字段的关键字长度不得超过8字节' })), t = !1) : void 0 : (console.warn(vt({ api: 'updateFriend', desc: '类型必须为 String' })), t = !1) : (console.warn(vt({ api: 'updateFriend', desc: '好友自定义字段的前缀必须是 Tag_SNS_Custom' })), t = !1)))), t; - } return !0; - } } }, acceptFriendApplication: { userID: yt }, refuseFriendApplication: { userID: yt }, deleteFriendApplication: { userID: yt }, createFriendGroup: { name: yt }, deleteFriendGroup: { name: yt }, addToFriendGroup: { name: yt, userIDList: It }, removeFromFriendGroup: { name: yt, userIDList: It }, renameFriendGroup: { oldName: yt, newName: yt } }; const St = { login: 'login', logout: 'logout', on: 'on', once: 'once', off: 'off', setLogLevel: 'setLogLevel', registerPlugin: 'registerPlugin', destroy: 'destroy', createTextMessage: 'createTextMessage', createTextAtMessage: 'createTextAtMessage', createImageMessage: 'createImageMessage', createAudioMessage: 'createAudioMessage', createVideoMessage: 'createVideoMessage', createCustomMessage: 'createCustomMessage', createFaceMessage: 'createFaceMessage', createFileMessage: 'createFileMessage', createMergerMessage: 'createMergerMessage', downloadMergerMessage: 'downloadMergerMessage', createForwardMessage: 'createForwardMessage', sendMessage: 'sendMessage', resendMessage: 'resendMessage', getMessageList: 'getMessageList', setMessageRead: 'setMessageRead', revokeMessage: 'revokeMessage', deleteMessage: 'deleteMessage', getConversationList: 'getConversationList', getConversationProfile: 'getConversationProfile', deleteConversation: 'deleteConversation', getGroupList: 'getGroupList', getGroupProfile: 'getGroupProfile', createGroup: 'createGroup', joinGroup: 'joinGroup', updateGroupProfile: 'updateGroupProfile', quitGroup: 'quitGroup', dismissGroup: 'dismissGroup', changeGroupOwner: 'changeGroupOwner', searchGroupByID: 'searchGroupByID', setMessageRemindType: 'setMessageRemindType', handleGroupApplication: 'handleGroupApplication', getGroupMemberProfile: 'getGroupMemberProfile', getGroupMemberList: 'getGroupMemberList', addGroupMember: 'addGroupMember', deleteGroupMember: 'deleteGroupMember', setGroupMemberNameCard: 'setGroupMemberNameCard', setGroupMemberMuteTime: 'setGroupMemberMuteTime', setGroupMemberRole: 'setGroupMemberRole', setGroupMemberCustomField: 'setGroupMemberCustomField', getGroupOnlineMemberCount: 'getGroupOnlineMemberCount', getMyProfile: 'getMyProfile', getUserProfile: 'getUserProfile', updateMyProfile: 'updateMyProfile', getBlacklist: 'getBlacklist', addToBlacklist: 'addToBlacklist', removeFromBlacklist: 'removeFromBlacklist', getFriendList: 'getFriendList', addFriend: 'addFriend', deleteFriend: 'deleteFriend', checkFriend: 'checkFriend', updateFriend: 'updateFriend', getFriendProfile: 'getFriendProfile', getFriendApplicationList: 'getFriendApplicationList', refuseFriendApplication: 'refuseFriendApplication', deleteFriendApplication: 'deleteFriendApplication', acceptFriendApplication: 'acceptFriendApplication', setFriendApplicationRead: 'setFriendApplicationRead', getFriendGroupList: 'getFriendGroupList', createFriendGroup: 'createFriendGroup', renameFriendGroup: 'renameFriendGroup', deleteFriendGroup: 'deleteFriendGroup', addToFriendGroup: 'addToFriendGroup', removeFromFriendGroup: 'removeFromFriendGroup', callExperimentalAPI: 'callExperimentalAPI' }; const Et = 'sign'; const kt = 'message'; const Ct = 'user'; const Nt = 'c2c'; const At = 'group'; const Ot = 'sns'; const Lt = 'groupMember'; const Rt = 'conversation'; const Gt = 'context'; const wt = 'storage'; const Pt = 'eventStat'; const bt = 'netMonitor'; const Ut = 'bigDataChannel'; const Ft = 'upload'; const qt = 'plugin'; const Vt = 'syncUnreadMessage'; const Kt = 'session'; const xt = 'channel'; const Bt = 'message_loss_detection'; const Ht = 'cloudControl'; const jt = 'pullGroupMessage'; const $t = 'qualityStat'; const Yt = (function () { - function e(t) { - o(this, e), this._moduleManager = t, this._className = ''; - } return s(e, [{ key: 'isLoggedIn', value() { - return this._moduleManager.getModule(Gt).isLoggedIn(); - } }, { key: 'isOversea', value() { - return this._moduleManager.getModule(Gt).isOversea(); - } }, { key: 'getMyUserID', value() { - return this._moduleManager.getModule(Gt).getUserID(); - } }, { key: 'getModule', value(e) { - return this._moduleManager.getModule(e); - } }, { key: 'getPlatform', value() { - return X; - } }, { key: 'getNetworkType', value() { - return this._moduleManager.getModule(bt).getNetworkType(); - } }, { key: 'probeNetwork', value() { - return this._moduleManager.getModule(bt).probe(); - } }, { key: 'getCloudConfig', value(e) { - return this._moduleManager.getModule(Ht).getCloudConfig(e); - } }, { key: 'emitOuterEvent', value(e, t) { - this._moduleManager.getOuterEmitterInstance().emit(e, t); - } }, { key: 'emitInnerEvent', value(e, t) { - this._moduleManager.getInnerEmitterInstance().emit(e, t); - } }, { key: 'getInnerEmitterInstance', value() { - return this._moduleManager.getInnerEmitterInstance(); - } }, { key: 'generateTjgID', value(e) { - return `${this._moduleManager.getModule(Gt).getTinyID()}-${e.random}`; - } }, { key: 'filterModifiedMessage', value(e) { - if (!dt(e)) { - const t = e.filter((e => !0 === e.isModified));t.length > 0 && this.emitOuterEvent(E.MESSAGE_MODIFIED, t); - } - } }, { key: 'filterUnmodifiedMessage', value(e) { - return dt(e) ? [] : e.filter((e => !1 === e.isModified)); - } }, { key: 'request', value(e) { - return this._moduleManager.getModule(Kt).request(e); - } }]), e; - }()); const zt = 'wslogin'; const Wt = 'wslogout'; const Jt = 'wshello'; const Xt = 'getmsg'; const Qt = 'authkey'; const Zt = 'sendmsg'; const en = 'send_group_msg'; const tn = 'portrait_get_all'; const nn = 'portrait_set'; const on = 'black_list_get'; const an = 'black_list_add'; const sn = 'black_list_delete'; const rn = 'msgwithdraw'; const cn = 'msgreaded'; const un = 'getroammsg'; const ln = 'get_peer_read_time'; const dn = 'delete_c2c_msg_ramble'; const gn = 'page_get'; const pn = 'get'; const hn = 'delete'; const _n = 'deletemsg'; const fn = 'get_joined_group_list'; const mn = 'get_group_info'; const Mn = 'create_group'; const vn = 'destroy_group'; const yn = 'modify_group_base_info'; const In = 'apply_join_group'; const Dn = 'apply_join_group_noauth'; const Tn = 'quit_group'; const Sn = 'get_group_public_info'; const En = 'change_group_owner'; const kn = 'handle_apply_join_group'; const Cn = 'handle_invite_join_group'; const Nn = 'group_msg_recall'; const An = 'msg_read_report'; const On = 'group_msg_get'; const Ln = 'get_pendency'; const Rn = 'deletemsg'; const Gn = 'get_msg'; const wn = 'get_msg_noauth'; const Pn = 'get_online_member_num'; const bn = 'delete_group_ramble_msg_by_seq'; const Un = 'get_group_member_info'; const Fn = 'get_specified_group_member_info'; const qn = 'add_group_member'; const Vn = 'delete_group_member'; const Kn = 'modify_group_member_info'; const xn = 'cos'; const Bn = 'pre_sig'; const Hn = 'tim_web_report_v2'; const jn = 'alive'; const $n = 'msg_push'; const Yn = 'ws_msg_push_ack'; const zn = 'stat_forceoffline'; const Wn = 'save_relay_json_msg'; const Jn = 'get_relay_json_msg'; const Xn = 'fetch_config'; const Qn = 'push_configv2'; const Zn = { NO_SDKAPPID: 2e3, NO_ACCOUNT_TYPE: 2001, NO_IDENTIFIER: 2002, NO_USERSIG: 2003, NO_TINYID: 2022, NO_A2KEY: 2023, USER_NOT_LOGGED_IN: 2024, COS_UNDETECTED: 2040, COS_GET_SIG_FAIL: 2041, MESSAGE_SEND_FAIL: 2100, MESSAGE_LIST_CONSTRUCTOR_NEED_OPTIONS: 2103, MESSAGE_SEND_NEED_MESSAGE_INSTANCE: 2105, MESSAGE_SEND_INVALID_CONVERSATION_TYPE: 2106, MESSAGE_FILE_IS_EMPTY: 2108, MESSAGE_ONPROGRESS_FUNCTION_ERROR: 2109, MESSAGE_REVOKE_FAIL: 2110, MESSAGE_DELETE_FAIL: 2111, MESSAGE_IMAGE_SELECT_FILE_FIRST: 2251, MESSAGE_IMAGE_TYPES_LIMIT: 2252, MESSAGE_IMAGE_SIZE_LIMIT: 2253, MESSAGE_AUDIO_UPLOAD_FAIL: 2300, MESSAGE_AUDIO_SIZE_LIMIT: 2301, MESSAGE_VIDEO_UPLOAD_FAIL: 2350, MESSAGE_VIDEO_SIZE_LIMIT: 2351, MESSAGE_VIDEO_TYPES_LIMIT: 2352, MESSAGE_FILE_UPLOAD_FAIL: 2400, MESSAGE_FILE_SELECT_FILE_FIRST: 2401, MESSAGE_FILE_SIZE_LIMIT: 2402, MESSAGE_FILE_URL_IS_EMPTY: 2403, MESSAGE_MERGER_TYPE_INVALID: 2450, MESSAGE_MERGER_KEY_INVALID: 2451, MESSAGE_MERGER_DOWNLOAD_FAIL: 2452, MESSAGE_FORWARD_TYPE_INVALID: 2453, CONVERSATION_NOT_FOUND: 2500, USER_OR_GROUP_NOT_FOUND: 2501, CONVERSATION_UN_RECORDED_TYPE: 2502, ILLEGAL_GROUP_TYPE: 2600, CANNOT_JOIN_WORK: 2601, CANNOT_CHANGE_OWNER_IN_AVCHATROOM: 2620, CANNOT_CHANGE_OWNER_TO_SELF: 2621, CANNOT_DISMISS_Work: 2622, MEMBER_NOT_IN_GROUP: 2623, JOIN_GROUP_FAIL: 2660, CANNOT_ADD_MEMBER_IN_AVCHATROOM: 2661, CANNOT_JOIN_NON_AVCHATROOM_WITHOUT_LOGIN: 2662, CANNOT_KICK_MEMBER_IN_AVCHATROOM: 2680, NOT_OWNER: 2681, CANNOT_SET_MEMBER_ROLE_IN_WORK_AND_AVCHATROOM: 2682, INVALID_MEMBER_ROLE: 2683, CANNOT_SET_SELF_MEMBER_ROLE: 2684, CANNOT_MUTE_SELF: 2685, NOT_MY_FRIEND: 2700, ALREADY_MY_FRIEND: 2701, FRIEND_GROUP_EXISTED: 2710, FRIEND_GROUP_NOT_EXIST: 2711, FRIEND_APPLICATION_NOT_EXIST: 2716, UPDATE_PROFILE_INVALID_PARAM: 2721, UPDATE_PROFILE_NO_KEY: 2722, ADD_BLACKLIST_INVALID_PARAM: 2740, DEL_BLACKLIST_INVALID_PARAM: 2741, CANNOT_ADD_SELF_TO_BLACKLIST: 2742, ADD_FRIEND_INVALID_PARAM: 2760, NETWORK_ERROR: 2800, NETWORK_TIMEOUT: 2801, NETWORK_BASE_OPTIONS_NO_URL: 2802, NETWORK_UNDEFINED_SERVER_NAME: 2803, NETWORK_PACKAGE_UNDEFINED: 2804, NO_NETWORK: 2805, CONVERTOR_IRREGULAR_PARAMS: 2900, NOTICE_RUNLOOP_UNEXPECTED_CONDITION: 2901, NOTICE_RUNLOOP_OFFSET_LOST: 2902, UNCAUGHT_ERROR: 2903, GET_LONGPOLL_ID_FAILED: 2904, INVALID_OPERATION: 2905, CANNOT_FIND_PROTOCOL: 2997, CANNOT_FIND_MODULE: 2998, SDK_IS_NOT_READY: 2999, LONG_POLL_KICK_OUT: 91101, MESSAGE_A2KEY_EXPIRED: 20002, ACCOUNT_A2KEY_EXPIRED: 70001, LONG_POLL_API_PARAM_ERROR: 90001, HELLO_ANSWER_KICKED_OUT: 1002 }; const eo = '无 SDKAppID'; const to = '无 userID'; const no = '无 userSig'; const oo = '无 tinyID'; const ao = '无 a2key'; const so = '用户未登录'; const ro = '未检测到 COS 上传插件'; const io = '获取 COS 预签名 URL 失败'; const co = '消息发送失败'; const uo = '需要 Message 的实例'; const lo = 'Message.conversationType 只能为 "C2C" 或 "GROUP"'; const go = '无法发送空文件'; const po = '回调函数运行时遇到错误,请检查接入侧代码'; const ho = '消息撤回失败'; const _o = '消息删除失败'; const fo = '请先选择一个图片'; const mo = '只允许上传 jpg png jpeg gif bmp格式的图片'; const Mo = '图片大小超过20M,无法发送'; const vo = '语音上传失败'; const yo = '语音大小大于20M,无法发送'; const Io = '视频上传失败'; const Do = '视频大小超过100M,无法发送'; const To = '只允许上传 mp4 格式的视频'; const So = '文件上传失败'; const Eo = '请先选择一个文件'; const ko = '文件大小超过100M,无法发送 '; const Co = '缺少必要的参数文件 URL'; const No = '非合并消息'; const Ao = '合并消息的 messageKey 无效'; const Oo = '下载合并消息失败'; const Lo = '选择的消息类型(如群提示消息)不可以转发'; const Ro = '没有找到相应的会话,请检查传入参数'; const Go = '没有找到相应的用户或群组,请检查传入参数'; const wo = '未记录的会话类型'; const Po = '非法的群类型,请检查传入参数'; const bo = '不能加入 Work 类型的群组'; const Uo = 'AVChatRoom 类型的群组不能转让群主'; const Fo = '不能把群主转让给自己'; const qo = '不能解散 Work 类型的群组'; const Vo = '用户不在该群组内'; const Ko = '加群失败,请检查传入参数或重试'; const xo = 'AVChatRoom 类型的群不支持邀请群成员'; const Bo = '非 AVChatRoom 类型的群组不允许匿名加群,请先登录后再加群'; const Ho = '不能在 AVChatRoom 类型的群组踢人'; const jo = '你不是群主,只有群主才有权限操作'; const $o = '不能在 Work / AVChatRoom 类型的群中设置群成员身份'; const Yo = '不合法的群成员身份,请检查传入参数'; const zo = '不能设置自己的群成员身份,请检查传入参数'; const Wo = '不能将自己禁言,请检查传入参数'; const Jo = '传入 updateMyProfile 接口的参数无效'; const Xo = 'updateMyProfile 无标配资料字段或自定义资料字段'; const Qo = '传入 addToBlacklist 接口的参数无效'; const Zo = '传入 removeFromBlacklist 接口的参数无效'; const ea = '不能拉黑自己'; const ta = '网络错误'; const na = '请求超时'; const oa = '未连接到网络'; const aa = '无效操作,如调用了未定义或者未实现的方法等'; const sa = '无法找到协议'; const ra = '无法找到模块'; const ia = '接口需要 SDK 处于 ready 状态后才能调用'; const ca = 'upload'; const ua = 'networkRTT'; const la = 'messageE2EDelay'; const da = 'sendMessageC2C'; const ga = 'sendMessageGroup'; const pa = 'sendMessageGroupAV'; const ha = 'sendMessageRichMedia'; const _a = 'cosUpload'; const fa = 'messageReceivedGroup'; const ma = 'messageReceivedGroupAVPush'; const Ma = 'messageReceivedGroupAVPull'; const va = (r(ht = {}, ua, 2), r(ht, la, 3), r(ht, da, 4), r(ht, ga, 5), r(ht, pa, 6), r(ht, ha, 7), r(ht, fa, 8), r(ht, ma, 9), r(ht, Ma, 10), r(ht, _a, 11), ht); const ya = { info: 4, warning: 5, error: 6 }; const Ia = { wifi: 1, '2g': 2, '3g': 3, '4g': 4, '5g': 5, unknown: 6, none: 7, online: 8 }; const Da = (function () { - function e(t) { - o(this, e), this.eventType = 0, this.timestamp = 0, this.networkType = 8, this.code = 0, this.message = '', this.moreMessage = '', this.extension = t, this.costTime = 0, this.duplicate = !1, this.level = 4, this._sentFlag = !1, this._startts = ye(); - } return s(e, [{ key: 'updateTimeStamp', value() { - this.timestamp = ye(); - } }, { key: 'start', value(e) { - return this._startts = e, this; - } }, { key: 'end', value() { - const e = this; const t = arguments.length > 0 && void 0 !== arguments[0] && arguments[0];if (!this._sentFlag) { - const n = ye();this.costTime = n - this._startts, this.setMoreMessage('host:'.concat(st(), ' startts:').concat(this._startts, ' endts:') - .concat(n)), t ? (this._sentFlag = !0, this._eventStatModule && this._eventStatModule.pushIn(this)) : setTimeout((() => { - e._sentFlag = !0, e._eventStatModule && e._eventStatModule.pushIn(e); - }), 0); - } - } }, { key: 'setError', value(e, t, n) { - return e instanceof Error ? (this._sentFlag || (this.setNetworkType(n), t ? (e.code && this.setCode(e.code), e.message && this.setMoreMessage(e.message)) : (this.setCode(Zn.NO_NETWORK), this.setMoreMessage(oa)), this.setLevel('error')), this) : (Ee.warn('SSOLogData.setError value not instanceof Error, please check!'), this); - } }, { key: 'setCode', value(e) { - return Ge(e) || this._sentFlag || ('ECONNABORTED' === e && (this.code = 103), Ne(e) ? this.code = e : Ee.warn('SSOLogData.setCode value not a number, please check!', e, n(e))), this; - } }, { key: 'setMessage', value(e) { - return Ge(e) || this._sentFlag || (Ne(e) && (this.message = e.toString()), Ae(e) && (this.message = e)), this; - } }, { key: 'setLevel', value(e) { - return Ge(e) || this._sentFlag || (this.level = ya[e]), this; - } }, { key: 'setMoreMessage', value(e) { - return dt(this.moreMessage) ? this.moreMessage = ''.concat(e) : this.moreMessage += ' '.concat(e), this; - } }, { key: 'setNetworkType', value(e) { - return Ge(e) || Ge(Ia[e]) ? Ee.warn('SSOLogData.setNetworkType value is undefined, please check!') : this.networkType = Ia[e], this; - } }, { key: 'getStartTs', value() { - return this._startts; - } }], [{ key: 'bindEventStatModule', value(t) { - e.prototype._eventStatModule = t; - } }]), e; - }()); const Ta = 'sdkConstruct'; const Sa = 'sdkReady'; const Ea = 'login'; const ka = 'logout'; const Ca = 'kickedOut'; const Na = 'registerPlugin'; const Aa = 'wsConnect'; const Oa = 'wsOnOpen'; const La = 'wsOnClose'; const Ra = 'wsOnError'; const Ga = 'getCosAuthKey'; const wa = 'getCosPreSigUrl'; const Pa = 'upload'; const ba = 'sendMessage'; const Ua = 'getC2CRoamingMessages'; const Fa = 'getGroupRoamingMessages'; const qa = 'revokeMessage'; const Va = 'deleteMessage'; const Ka = 'setC2CMessageRead'; const xa = 'setGroupMessageRead'; const Ba = 'emptyMessageBody'; const Ha = 'getPeerReadTime'; const ja = 'uploadMergerMessage'; const $a = 'downloadMergerMessage'; const Ya = 'jsonParseError'; const za = 'messageE2EDelayException'; const Wa = 'getConversationList'; const Ja = 'getConversationProfile'; const Xa = 'deleteConversation'; const Qa = 'getConversationListInStorage'; const Za = 'syncConversationList'; const es = 'createGroup'; const ts = 'applyJoinGroup'; const ns = 'quitGroup'; const os = 'searchGroupByID'; const as = 'changeGroupOwner'; const ss = 'handleGroupApplication'; const rs = 'handleGroupInvitation'; const is = 'setMessageRemindType'; const cs = 'dismissGroup'; const us = 'updateGroupProfile'; const ls = 'getGroupList'; const ds = 'getGroupProfile'; const gs = 'getGroupListInStorage'; const ps = 'getGroupLastSequence'; const hs = 'getGroupMissingMessage'; const _s = 'pagingGetGroupList'; const fs = 'getGroupSimplifiedInfo'; const ms = 'joinWithoutAuth'; const Ms = 'getGroupMemberList'; const vs = 'getGroupMemberProfile'; const ys = 'addGroupMember'; const Is = 'deleteGroupMember'; const Ds = 'setGroupMemberMuteTime'; const Ts = 'setGroupMemberNameCard'; const Ss = 'setGroupMemberRole'; const Es = 'setGroupMemberCustomField'; const ks = 'getGroupOnlineMemberCount'; const Cs = 'longPollingAVError'; const Ns = 'messageLoss'; const As = 'messageStacked'; const Os = 'getUserProfile'; const Ls = 'updateMyProfile'; const Rs = 'getBlacklist'; const Gs = 'addToBlacklist'; const ws = 'removeFromBlacklist'; const Ps = 'callbackFunctionError'; const bs = 'fetchCloudControlConfig'; const Us = 'pushedCloudControlConfig'; const Fs = 'error'; const qs = (function () { - function e(t) { - o(this, e), this.type = k.MSG_TEXT, this.content = { text: t.text || '' }; - } return s(e, [{ key: 'setText', value(e) { - this.content.text = e; - } }, { key: 'sendable', value() { - return 0 !== this.content.text.length; - } }]), e; - }()); const Vs = { JSON: { TYPE: { C2C: { NOTICE: 1, COMMON: 9, EVENT: 10 }, GROUP: { COMMON: 3, TIP: 4, SYSTEM: 5, TIP2: 6 }, FRIEND: { NOTICE: 7 }, PROFILE: { NOTICE: 8 } }, SUBTYPE: { C2C: { COMMON: 0, READED: 92, KICKEDOUT: 96 }, GROUP: { COMMON: 0, LOVEMESSAGE: 1, TIP: 2, REDPACKET: 3 } }, OPTIONS: { GROUP: { JOIN: 1, QUIT: 2, KICK: 3, SET_ADMIN: 4, CANCEL_ADMIN: 5, MODIFY_GROUP_INFO: 6, MODIFY_MEMBER_INFO: 7 } } }, PROTOBUF: {}, IMAGE_TYPES: { ORIGIN: 1, LARGE: 2, SMALL: 3 }, IMAGE_FORMAT: { JPG: 1, JPEG: 1, GIF: 2, PNG: 3, BMP: 4, UNKNOWN: 255 } }; const Ks = { NICK: 'Tag_Profile_IM_Nick', GENDER: 'Tag_Profile_IM_Gender', BIRTHDAY: 'Tag_Profile_IM_BirthDay', LOCATION: 'Tag_Profile_IM_Location', SELFSIGNATURE: 'Tag_Profile_IM_SelfSignature', ALLOWTYPE: 'Tag_Profile_IM_AllowType', LANGUAGE: 'Tag_Profile_IM_Language', AVATAR: 'Tag_Profile_IM_Image', MESSAGESETTINGS: 'Tag_Profile_IM_MsgSettings', ADMINFORBIDTYPE: 'Tag_Profile_IM_AdminForbidType', LEVEL: 'Tag_Profile_IM_Level', ROLE: 'Tag_Profile_IM_Role' }; const xs = { UNKNOWN: 'Gender_Type_Unknown', FEMALE: 'Gender_Type_Female', MALE: 'Gender_Type_Male' }; const Bs = { NONE: 'AdminForbid_Type_None', SEND_OUT: 'AdminForbid_Type_SendOut' }; const Hs = { NEED_CONFIRM: 'AllowType_Type_NeedConfirm', ALLOW_ANY: 'AllowType_Type_AllowAny', DENY_ANY: 'AllowType_Type_DenyAny' }; const js = 'JoinedSuccess'; const $s = 'WaitAdminApproval'; const Ys = (function () { - function e(t) { - o(this, e), this._imageMemoryURL = '', z ? this.createImageDataASURLInWXMiniApp(t.file) : this.createImageDataASURLInWeb(t.file), this._initImageInfoModel(), this.type = k.MSG_IMAGE, this._percent = 0, this.content = { imageFormat: t.imageFormat || Vs.IMAGE_FORMAT.UNKNOWN, uuid: t.uuid, imageInfoArray: [] }, this.initImageInfoArray(t.imageInfoArray), this._defaultImage = 'http://imgcache.qq.com/open/qcloud/video/act/webim-images/default.jpg', this._autoFixUrl(); - } return s(e, [{ key: '_initImageInfoModel', value() { - const e = this;this._ImageInfoModel = function (t) { - this.instanceID = He(9999999), this.sizeType = t.type || 0, this.type = 0, this.size = t.size || 0, this.width = t.width || 0, this.height = t.height || 0, this.imageUrl = t.url || '', this.url = t.url || e._imageMemoryURL || e._defaultImage; - }, this._ImageInfoModel.prototype = { setSizeType(e) { - this.sizeType = e; - }, setType(e) { - this.type = e; - }, setImageUrl(e) { - e && (this.imageUrl = e); - }, getImageUrl() { - return this.imageUrl; - } }; - } }, { key: 'initImageInfoArray', value(e) { - for (let t = 0, n = null, o = null;t <= 2;)o = Ge(e) || Ge(e[t]) ? { type: 0, size: 0, width: 0, height: 0, url: '' } : e[t], (n = new this._ImageInfoModel(o)).setSizeType(t + 1), n.setType(t), this.addImageInfo(n), t++;this.updateAccessSideImageInfoArray(); - } }, { key: 'updateImageInfoArray', value(e) { - for (var t, n = this.content.imageInfoArray.length, o = 0;o < n;o++)t = this.content.imageInfoArray[o], e[o].size && (t.size = e[o].size), e[o].url && t.setImageUrl(e[o].url), e[o].width && (t.width = e[o].width), e[o].height && (t.height = e[o].height); - } }, { key: '_autoFixUrl', value() { - for (let e = this.content.imageInfoArray.length, t = '', n = '', o = ['http', 'https'], a = null, s = 0;s < e;s++) this.content.imageInfoArray[s].url && '' !== (a = this.content.imageInfoArray[s]).imageUrl && (n = a.imageUrl.slice(0, a.imageUrl.indexOf('://') + 1), t = a.imageUrl.slice(a.imageUrl.indexOf('://') + 1), o.indexOf(n) < 0 && (n = 'https:'), this.content.imageInfoArray[s].setImageUrl([n, t].join(''))); - } }, { key: 'updatePercent', value(e) { - this._percent = e, this._percent > 1 && (this._percent = 1); - } }, { key: 'updateImageFormat', value(e) { - this.content.imageFormat = Vs.IMAGE_FORMAT[e.toUpperCase()] || Vs.IMAGE_FORMAT.UNKNOWN; - } }, { key: 'createImageDataASURLInWeb', value(e) { - void 0 !== e && e.files.length > 0 && (this._imageMemoryURL = window.URL.createObjectURL(e.files[0])); - } }, { key: 'createImageDataASURLInWXMiniApp', value(e) { - e && e.url && (this._imageMemoryURL = e.url); - } }, { key: 'replaceImageInfo', value(e, t) { - this.content.imageInfoArray[t] instanceof this._ImageInfoModel || (this.content.imageInfoArray[t] = e); - } }, { key: 'addImageInfo', value(e) { - this.content.imageInfoArray.length >= 3 || this.content.imageInfoArray.push(e); - } }, { key: 'updateAccessSideImageInfoArray', value() { - const e = this.content.imageInfoArray; const t = e[0]; const n = t.width; const o = void 0 === n ? 0 : n; const a = t.height; const s = void 0 === a ? 0 : a;0 !== o && 0 !== s && (it(e), Object.assign(e[2], rt({ originWidth: o, originHeight: s, min: 720 }))); - } }, { key: 'sendable', value() { - return 0 !== this.content.imageInfoArray.length && ('' !== this.content.imageInfoArray[0].imageUrl && 0 !== this.content.imageInfoArray[0].size); - } }]), e; - }()); const zs = (function () { - function e(t) { - o(this, e), this.type = k.MSG_FACE, this.content = t || null; - } return s(e, [{ key: 'sendable', value() { - return null !== this.content; - } }]), e; - }()); const Ws = (function () { - function e(t) { - o(this, e), this.type = k.MSG_AUDIO, this._percent = 0, this.content = { downloadFlag: 2, second: t.second, size: t.size, url: t.url, remoteAudioUrl: t.url || '', uuid: t.uuid }; - } return s(e, [{ key: 'updatePercent', value(e) { - this._percent = e, this._percent > 1 && (this._percent = 1); - } }, { key: 'updateAudioUrl', value(e) { - this.content.remoteAudioUrl = e; - } }, { key: 'sendable', value() { - return '' !== this.content.remoteAudioUrl; - } }]), e; - }()); const Js = { from: !0, groupID: !0, groupName: !0, to: !0 }; const Xs = (function () { - function e(t) { - o(this, e), this.type = k.MSG_GRP_TIP, this.content = {}, this._initContent(t); - } return s(e, [{ key: '_initContent', value(e) { - const t = this;Object.keys(e).forEach(((n) => { - switch (n) { - case 'remarkInfo':break;case 'groupProfile':t.content.groupProfile = {}, t._initGroupProfile(e[n]);break;case 'operatorInfo':case 'memberInfoList':break;case 'msgMemberInfo':t.content.memberList = e[n], Object.defineProperty(t.content, 'msgMemberInfo', { get() { - return Ee.warn('!!! 禁言的群提示消息中的 payload.msgMemberInfo 属性即将废弃,请使用 payload.memberList 属性替代。 \n', 'msgMemberInfo 中的 shutupTime 属性对应更改为 memberList 中的 muteTime 属性,表示禁言时长。 \n', '参考:群提示消息 https://web.sdk.qcloud.com/im/doc/zh-cn/Message.html#.GroupTipPayload'), t.content.memberList.map((e => ({ userID: e.userID, shutupTime: e.muteTime }))); - } });break;case 'onlineMemberInfo':break;case 'memberNum':t.content[n] = e[n], t.content.memberCount = e[n];break;default:t.content[n] = e[n]; - } - })), this.content.userIDList || (this.content.userIDList = [this.content.operatorID]); - } }, { key: '_initGroupProfile', value(e) { - for (let t = Object.keys(e), n = 0;n < t.length;n++) { - const o = t[n];Js[o] && (this.content.groupProfile[o] = e[o]); - } - } }]), e; - }()); const Qs = { from: !0, groupID: !0, groupName: !0, to: !0 }; const Zs = (function () { - function e(t) { - o(this, e), this.type = k.MSG_GRP_SYS_NOTICE, this.content = {}, this._initContent(t); - } return s(e, [{ key: '_initContent', value(e) { - const t = this;Object.keys(e).forEach(((n) => { - switch (n) { - case 'memberInfoList':break;case 'remarkInfo':t.content.handleMessage = e[n];break;case 'groupProfile':t.content.groupProfile = {}, t._initGroupProfile(e[n]);break;default:t.content[n] = e[n]; - } - })); - } }, { key: '_initGroupProfile', value(e) { - for (let t = Object.keys(e), n = 0;n < t.length;n++) { - const o = t[n];Qs[o] && ('groupName' === o ? this.content.groupProfile.name = e[o] : this.content.groupProfile[o] = e[o]); - } - } }]), e; - }()); const er = (function () { - function e(t) { - o(this, e), this.type = k.MSG_FILE, this._percent = 0;const n = this._getFileInfo(t);this.content = { downloadFlag: 2, fileUrl: t.url || '', uuid: t.uuid, fileName: n.name || '', fileSize: n.size || 0 }; - } return s(e, [{ key: '_getFileInfo', value(e) { - if (e.fileName && e.fileSize) return { size: e.fileSize, name: e.fileName };if (z) return {};const t = e.file.files[0];return { size: t.size, name: t.name, type: t.type.slice(t.type.lastIndexOf('/') + 1).toLowerCase() }; - } }, { key: 'updatePercent', value(e) { - this._percent = e, this._percent > 1 && (this._percent = 1); - } }, { key: 'updateFileUrl', value(e) { - this.content.fileUrl = e; - } }, { key: 'sendable', value() { - return '' !== this.content.fileUrl && ('' !== this.content.fileName && 0 !== this.content.fileSize); - } }]), e; - }()); const tr = (function () { - function e(t) { - o(this, e), this.type = k.MSG_CUSTOM, this.content = { data: t.data || '', description: t.description || '', extension: t.extension || '' }; - } return s(e, [{ key: 'setData', value(e) { - return this.content.data = e, this; - } }, { key: 'setDescription', value(e) { - return this.content.description = e, this; - } }, { key: 'setExtension', value(e) { - return this.content.extension = e, this; - } }, { key: 'sendable', value() { - return 0 !== this.content.data.length || 0 !== this.content.description.length || 0 !== this.content.extension.length; - } }]), e; - }()); const nr = (function () { - function e(t) { - o(this, e), this.type = k.MSG_VIDEO, this._percent = 0, this.content = { remoteVideoUrl: t.remoteVideoUrl || t.videoUrl || '', videoFormat: t.videoFormat, videoSecond: parseInt(t.videoSecond, 10), videoSize: t.videoSize, videoUrl: t.videoUrl, videoDownloadFlag: 2, videoUUID: t.videoUUID, thumbUUID: t.thumbUUID, thumbFormat: t.thumbFormat, thumbWidth: t.thumbWidth, thumbHeight: t.thumbHeight, thumbSize: t.thumbSize, thumbDownloadFlag: 2, thumbUrl: t.thumbUrl }; - } return s(e, [{ key: 'updatePercent', value(e) { - this._percent = e, this._percent > 1 && (this._percent = 1); - } }, { key: 'updateVideoUrl', value(e) { - e && (this.content.remoteVideoUrl = e); - } }, { key: 'sendable', value() { - return '' !== this.content.remoteVideoUrl; - } }]), e; - }()); const or = function e(t) { - o(this, e), this.type = k.MSG_GEO, this.content = t; - }; const ar = (function () { - function e(t) { - if (o(this, e), this.from = t.from, this.messageSender = t.from, this.time = t.time, this.messageSequence = t.sequence, this.clientSequence = t.clientSequence || t.sequence, this.messageRandom = t.random, this.cloudCustomData = t.cloudCustomData || '', t.ID) this.nick = t.nick || '', this.avatar = t.avatar || '', this.messageBody = [{ type: t.type, payload: t.payload }], t.conversationType.startsWith(k.CONV_C2C) ? this.receiverUserID = t.to : t.conversationType.startsWith(k.CONV_GROUP) && (this.receiverGroupID = t.to), this.messageReceiver = t.to;else { - this.nick = t.nick || '', this.avatar = t.avatar || '', this.messageBody = [];const n = t.elements[0].type; const a = t.elements[0].content;this._patchRichMediaPayload(n, a), n === k.MSG_MERGER ? this.messageBody.push({ type: n, payload: new sr(a).content }) : this.messageBody.push({ type: n, payload: a }), t.groupID && (this.receiverGroupID = t.groupID, this.messageReceiver = t.groupID), t.to && (this.receiverUserID = t.to, this.messageReceiver = t.to); - } - } return s(e, [{ key: '_patchRichMediaPayload', value(e, t) { - e === k.MSG_IMAGE ? t.imageInfoArray.forEach(((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 === k.MSG_VIDEO ? !t.remoteVideoUrl && t.videoUrl && (t.remoteVideoUrl = t.videoUrl) : e === k.MSG_AUDIO ? !t.remoteAudioUrl && t.url && (t.remoteAudioUrl = t.url) : e === k.MSG_FILE && !t.fileUrl && t.url && (t.fileUrl = t.url, t.url = void 0); - } }]), e; - }()); var sr = (function () { - function e(t) { - if (o(this, e), this.type = k.MSG_MERGER, this.content = { downloadKey: '', pbDownloadKey: '', messageList: [], title: '', abstractList: [], compatibleText: '', version: 0, layersOverLimit: !1 }, t.downloadKey) { - const n = t.downloadKey; const a = t.pbDownloadKey; const s = t.title; const r = t.abstractList; const i = t.compatibleText; const c = t.version;this.content.downloadKey = n, this.content.pbDownloadKey = a, this.content.title = s, this.content.abstractList = r, this.content.compatibleText = i, this.content.version = c || 0; - } else if (dt(t.messageList))1 === t.layersOverLimit && (this.content.layersOverLimit = !0);else { - const u = t.messageList; const l = t.title; const d = t.abstractList; const g = t.compatibleText; const p = t.version; const h = [];u.forEach(((e) => { - if (!dt(e)) { - const t = new ar(e);h.push(t); - } - })), this.content.messageList = h, this.content.title = l, this.content.abstractList = d, this.content.compatibleText = g, this.content.version = p || 0; - }Ee.debug('MergerElement.content:', this.content); - } return s(e, [{ key: 'sendable', value() { - return !dt(this.content.messageList) || !dt(this.content.downloadKey); - } }]), e; - }()); const rr = { 1: k.MSG_PRIORITY_HIGH, 2: k.MSG_PRIORITY_NORMAL, 3: k.MSG_PRIORITY_LOW, 4: k.MSG_PRIORITY_LOWEST }; const ir = (function () { - function e(t) { - o(this, e), this.ID = '', this.conversationID = t.conversationID || null, this.conversationType = t.conversationType || k.CONV_C2C, this.conversationSubType = t.conversationSubType, this.time = t.time || Math.ceil(Date.now() / 1e3), this.sequence = t.sequence || 0, this.clientSequence = t.clientSequence || t.sequence || 0, this.random = t.random || 0 === t.random ? t.random : He(), this.priority = this._computePriority(t.priority), this.nick = t.nick || '', this.avatar = t.avatar || '', this.isPeerRead = !1, this.nameCard = '', this._elements = [], this.isPlaceMessage = t.isPlaceMessage || 0, this.isRevoked = 2 === t.isPlaceMessage || 8 === t.msgFlagBits, this.geo = {}, this.from = t.from || null, this.to = t.to || null, this.flow = '', this.isSystemMessage = t.isSystemMessage || !1, this.protocol = t.protocol || 'JSON', this.isResend = !1, this.isRead = !1, this.status = t.status || _t.SUCCESS, this._onlineOnlyFlag = !1, this._groupAtInfoList = [], this._relayFlag = !1, this.atUserList = [], this.cloudCustomData = t.cloudCustomData || '', this.isDeleted = !1, this.isModified = !1, this.reInitialize(t.currentUser), this.extractGroupInfo(t.groupProfile || null), this.handleGroupAtInfo(t); - } return s(e, [{ key: 'elements', get() { - return Ee.warn('!!!Message 实例的 elements 属性即将废弃,请尽快修改。使用 type 和 payload 属性处理单条消息,兼容组合消息使用 _elements 属性!!!'), this._elements; - } }, { key: 'getElements', value() { - return this._elements; - } }, { key: 'extractGroupInfo', value(e) { - if (null !== e) { - Ae(e.nick) && (this.nick = e.nick), Ae(e.avatar) && (this.avatar = e.avatar);const t = e.messageFromAccountExtraInformation;Le(t) && Ae(t.nameCard) && (this.nameCard = t.nameCard); - } - } }, { key: 'handleGroupAtInfo', value(e) { - const t = this;e.payload && e.payload.atUserList && e.payload.atUserList.forEach(((e) => { - e !== k.MSG_AT_ALL ? (t._groupAtInfoList.push({ groupAtAllFlag: 0, groupAtUserID: e }), t.atUserList.push(e)) : (t._groupAtInfoList.push({ groupAtAllFlag: 1 }), t.atUserList.push(k.MSG_AT_ALL)); - })), Re(e.groupAtInfo) && e.groupAtInfo.forEach(((e) => { - 1 === e.groupAtAllFlag ? t.atUserList.push(e.groupAtUserID) : 2 === e.groupAtAllFlag && t.atUserList.push(k.MSG_AT_ALL); - })); - } }, { key: 'getGroupAtInfoList', value() { - return this._groupAtInfoList; - } }, { key: '_initProxy', value() { - this._elements[0] && (this.payload = this._elements[0].content, this.type = this._elements[0].type); - } }, { key: 'reInitialize', value(e) { - e && (this.status = this.from ? _t.SUCCESS : _t.UNSEND, !this.from && (this.from = e)), this._initFlow(e), this._initSequence(e), this._concatConversationID(e), this.generateMessageID(e); - } }, { key: 'isSendable', value() { - return 0 !== this._elements.length && ('function' !== typeof this._elements[0].sendable ? (Ee.warn(''.concat(this._elements[0].type, ' need "boolean : sendable()" method')), !1) : this._elements[0].sendable()); - } }, { key: '_initTo', value(e) { - this.conversationType === k.CONV_GROUP && (this.to = e.groupID); - } }, { key: '_initSequence', value(e) { - 0 === this.clientSequence && e && (this.clientSequence = (function (e) { - if (!e) return Ee.error('autoIncrementIndex(string: key) need key parameter'), !1;if (void 0 === ze[e]) { - const t = new Date; let n = '3'.concat(t.getHours()).slice(-2); let o = '0'.concat(t.getMinutes()).slice(-2); let a = '0'.concat(t.getSeconds()).slice(-2);ze[e] = parseInt([n, o, a, '0001'].join('')), n = null, o = null, a = null, Ee.log('autoIncrementIndex start index:'.concat(ze[e])); - } return ze[e]++; - }(e))), 0 === this.sequence && this.conversationType === k.CONV_C2C && (this.sequence = this.clientSequence); - } }, { key: 'generateMessageID', value(e) { - const t = e === this.from ? 1 : 0; const n = this.sequence > 0 ? this.sequence : this.clientSequence;this.ID = ''.concat(this.conversationID, '-').concat(n, '-') - .concat(this.random, '-') - .concat(t); - } }, { key: '_initFlow', value(e) { - '' !== e && (e === this.from ? (this.flow = 'out', this.isRead = !0) : this.flow = 'in'); - } }, { key: '_concatConversationID', value(e) { - const t = this.to; let n = ''; const o = this.conversationType;o !== k.CONV_SYSTEM ? (n = o === k.CONV_C2C ? e === this.from ? t : this.from : this.to, this.conversationID = ''.concat(o).concat(n)) : this.conversationID = k.CONV_SYSTEM; - } }, { key: 'isElement', value(e) { - return e instanceof qs || e instanceof Ys || e instanceof zs || e instanceof Ws || e instanceof er || e instanceof nr || e instanceof Xs || e instanceof Zs || e instanceof tr || e instanceof or || e instanceof sr; - } }, { key: 'setElement', value(e) { - const t = this;if (this.isElement(e)) return this._elements = [e], void this._initProxy();const n = function (e) { - if (e.type && e.content) switch (e.type) { - case k.MSG_TEXT:t.setTextElement(e.content);break;case k.MSG_IMAGE:t.setImageElement(e.content);break;case k.MSG_AUDIO:t.setAudioElement(e.content);break;case k.MSG_FILE:t.setFileElement(e.content);break;case k.MSG_VIDEO:t.setVideoElement(e.content);break;case k.MSG_CUSTOM:t.setCustomElement(e.content);break;case k.MSG_GEO:t.setGEOElement(e.content);break;case k.MSG_GRP_TIP:t.setGroupTipElement(e.content);break;case k.MSG_GRP_SYS_NOTICE:t.setGroupSystemNoticeElement(e.content);break;case k.MSG_FACE:t.setFaceElement(e.content);break;case k.MSG_MERGER:t.setMergerElement(e.content);break;default:Ee.warn(e.type, e.content, 'no operation......'); - } - };if (Re(e)) for (let o = 0;o < e.length;o++)n(e[o]);else n(e);this._initProxy(); - } }, { key: 'clearElement', value() { - this._elements.length = 0; - } }, { key: 'setTextElement', value(e) { - const t = 'string' === typeof e ? e : e.text; const n = new qs({ text: t });this._elements.push(n); - } }, { key: 'setImageElement', value(e) { - const t = new Ys(e);this._elements.push(t); - } }, { key: 'setAudioElement', value(e) { - const t = new Ws(e);this._elements.push(t); - } }, { key: 'setFileElement', value(e) { - const t = new er(e);this._elements.push(t); - } }, { key: 'setVideoElement', value(e) { - const t = new nr(e);this._elements.push(t); - } }, { key: 'setGEOElement', value(e) { - const t = new or(e);this._elements.push(t); - } }, { key: 'setCustomElement', value(e) { - const t = new tr(e);this._elements.push(t); - } }, { key: 'setGroupTipElement', value(e) { - let t = {}; const n = e.operationType;dt(e.memberInfoList) ? e.operatorInfo && (t = e.operatorInfo) : n !== k.GRP_TIP_MBR_JOIN && n !== k.GRP_TIP_MBR_KICKED_OUT && n !== k.GRP_TIP_MBR_SET_ADMIN && n !== k.GRP_TIP_MBR_CANCELED_ADMIN || (t = e.memberInfoList[0]);const o = t; const a = o.nick; const s = o.avatar;Ae(a) && (this.nick = a), Ae(s) && (this.avatar = s);const r = new Xs(e);this._elements.push(r); - } }, { key: 'setGroupSystemNoticeElement', value(e) { - const t = new Zs(e);this._elements.push(t); - } }, { key: 'setFaceElement', value(e) { - const t = new zs(e);this._elements.push(t); - } }, { key: 'setMergerElement', value(e) { - const t = new sr(e);this._elements.push(t); - } }, { key: 'setIsRead', value(e) { - this.isRead = e; - } }, { key: 'setRelayFlag', value(e) { - this._relayFlag = e; - } }, { key: 'getRelayFlag', value() { - return this._relayFlag; - } }, { key: 'setOnlineOnlyFlag', value(e) { - this._onlineOnlyFlag = e; - } }, { key: 'getOnlineOnlyFlag', value() { - return this._onlineOnlyFlag; - } }, { key: '_computePriority', value(e) { - if (Ge(e)) return k.MSG_PRIORITY_NORMAL;if (Ae(e) && -1 !== Object.values(rr).indexOf(e)) return e;if (Ne(e)) { - const t = `${e}`;if (-1 !== Object.keys(rr).indexOf(t)) return rr[t]; - } return k.MSG_PRIORITY_NORMAL; - } }, { key: 'setNickAndAvatar', value(e) { - const t = e.nick; const n = e.avatar;Ae(t) && (this.nick = t), Ae(n) && (this.avatar = n); - } }]), e; - }()); const cr = function (e) { - return { code: 0, data: e || {} }; - }; const ur = 'https://cloud.tencent.com/document/product/'; const lr = '您可以在即时通信 IM 控制台的【开发辅助工具(https://console.cloud.tencent.com/im-detail/tool-usersig)】页面校验 UserSig。'; const dr = 'UserSig 非法,请使用官网提供的 API 重新生成 UserSig('.concat(ur, '269/32688)。'); const gr = '#.E6.B6.88.E6.81.AF.E5.85.83.E7.B4.A0-timmsgelement'; const pr = { 70001: 'UserSig 已过期,请重新生成。建议 UserSig 有效期设置不小于24小时。', 70002: 'UserSig 长度为0,请检查传入的 UserSig 是否正确。', 70003: dr, 70005: dr, 70009: 'UserSig 验证失败,可能因为生成 UserSig 时混用了其他 SDKAppID 的私钥或密钥导致,请使用对应 SDKAppID 下的私钥或密钥重新生成 UserSig('.concat(ur, '269/32688)。'), 70013: '请求中的 UserID 与生成 UserSig 时使用的 UserID 不匹配。'.concat(lr), 70014: '请求中的 SDKAppID 与生成 UserSig 时使用的 SDKAppID 不匹配。'.concat(lr), 70016: '密钥不存在,UserSig 验证失败,请在即时通信 IM 控制台获取密钥('.concat(ur, '269/32578#.E8.8E.B7.E5.8F.96.E5.AF.86.E9.92.A5)。'), 70020: 'SDKAppID 未找到,请在即时通信 IM 控制台确认应用信息。', 70050: 'UserSig 验证次数过于频繁。请检查 UserSig 是否正确,并于1分钟后重新验证。'.concat(lr), 70051: '帐号被拉入黑名单。', 70052: 'UserSig 已经失效,请重新生成,再次尝试。', 70107: '因安全原因被限制登录,请不要频繁登录。', 70169: '请求的用户帐号不存在。', 70114: ''.concat('服务端内部超时,请稍后重试。'), 70202: ''.concat('服务端内部超时,请稍后重试。'), 70206: '请求中批量数量不合法。', 70402: '参数非法,请检查必填字段是否填充,或者字段的填充是否满足协议要求。', 70403: '请求失败,需要 App 管理员权限。', 70398: '帐号数超限。如需创建多于100个帐号,请将应用升级为专业版,具体操作指引请参见购买指引('.concat(ur, '269/32458)。'), 70500: ''.concat('服务端内部错误,请重试。'), 71e3: '删除帐号失败。仅支持删除体验版帐号,您当前应用为专业版,暂不支持帐号删除。', 20001: '请求包非法。', 20002: 'UserSig 或 A2 失效。', 20003: '消息发送方或接收方 UserID 无效或不存在,请检查 UserID 是否已导入即时通信 IM。', 20004: '网络异常,请重试。', 20005: ''.concat('服务端内部错误,请重试。'), 20006: '触发发送'.concat('单聊消息', '之前回调,App 后台返回禁止下发该消息。'), 20007: '发送'.concat('单聊消息', ',被对方拉黑,禁止发送。消息发送状态默认展示为失败,您可以登录控制台修改该场景下的消息发送状态展示结果,具体操作请参见消息保留设置(').concat(ur, '269/38656)。'), 20009: '消息发送双方互相不是好友,禁止发送(配置'.concat('单聊消息', '校验好友关系才会出现)。'), 20010: '发送'.concat('单聊消息', ',自己不是对方的好友(单向关系),禁止发送。'), 20011: '发送'.concat('单聊消息', ',对方不是自己的好友(单向关系),禁止发送。'), 20012: '发送方被禁言,该条消息被禁止发送。', 20016: '消息撤回超过了时间限制(默认2分钟)。', 20018: '删除漫游内部错误。', 90001: 'JSON 格式解析失败,请检查请求包是否符合 JSON 规范。', 90002: ''.concat('JSON 格式请求包体', '中 MsgBody 不符合消息格式描述,或者 MsgBody 不是 Array 类型,请参考 TIMMsgElement 对象的定义(').concat(ur, '269/2720') - .concat(gr, ')。'), 90003: ''.concat('JSON 格式请求包体', '中缺少 To_Account 字段或者 To_Account 帐号不存在。'), 90005: ''.concat('JSON 格式请求包体', '中缺少 MsgRandom 字段或者 MsgRandom 字段不是 Integer 类型。'), 90006: ''.concat('JSON 格式请求包体', '中缺少 MsgTimeStamp 字段或者 MsgTimeStamp 字段不是 Integer 类型。'), 90007: ''.concat('JSON 格式请求包体', '中 MsgBody 类型不是 Array 类型,请将其修改为 Array 类型。'), 90008: ''.concat('JSON 格式请求包体', '中缺少 From_Account 字段或者 From_Account 帐号不存在。'), 90009: '请求需要 App 管理员权限。', 90010: ''.concat('JSON 格式请求包体', '不符合消息格式描述,请参考 TIMMsgElement 对象的定义(').concat(ur, '269/2720') - .concat(gr, ')。'), 90011: '批量发消息目标帐号超过500,请减少 To_Account 中目标帐号数量。', 90012: 'To_Account 没有注册或不存在,请确认 To_Account 是否导入即时通信 IM 或者是否拼写错误。', 90026: '消息离线存储时间错误(最多不能超过7天)。', 90031: ''.concat('JSON 格式请求包体', '中 SyncOtherMachine 字段不是 Integer 类型。'), 90044: ''.concat('JSON 格式请求包体', '中 MsgLifeTime 字段不是 Integer 类型。'), 90048: '请求的用户帐号不存在。', 90054: '撤回请求中的 MsgKey 不合法。', 90994: ''.concat('服务端内部错误,请重试。'), 90995: ''.concat('服务端内部错误,请重试。'), 91e3: ''.concat('服务端内部错误,请重试。'), 90992: ''.concat('服务端内部错误,请重试。', '如果所有请求都返回该错误码,且 App 配置了第三方回调,请检查 App 服务端是否正常向即时通信 IM 后台服务端返回回调结果。'), 93e3: 'JSON 数据包超长,消息包体请不要超过8k。', 91101: 'Web 端长轮询被踢(Web 端同时在线实例个数超出限制)。', 10002: ''.concat('服务端内部错误,请重试。'), 10003: '请求中的接口名称错误,请核对接口名称并重试。', 10004: '参数非法,请根据错误描述检查请求是否正确。', 10005: '请求包体中携带的帐号数量过多。', 10006: '操作频率限制,请尝试降低调用的频率。', 10007: '操作权限不足,例如 Work '.concat('群组', '中普通成员尝试执行踢人操作,但只有 App 管理员才有权限。'), 10008: '请求非法,可能是请求中携带的签名信息验证不正确,请再次尝试。', 10009: '该群不允许群主主动退出。', 10010: ''.concat('群组', '不存在,或者曾经存在过,但是目前已经被解散。'), 10011: '解析 JSON 包体失败,请检查包体的格式是否符合 JSON 格式。', 10012: '发起操作的 UserID 非法,请检查发起操作的用户 UserID 是否填写正确。', 10013: '被邀请加入的用户已经是群成员。', 10014: '群已满员,无法将请求中的用户加入'.concat('群组', ',如果是批量加人,可以尝试减少加入用户的数量。'), 10015: '找不到指定 ID 的'.concat('群组', '。'), 10016: 'App 后台通过第三方回调拒绝本次操作。', 10017: '因被禁言而不能发送消息,请检查发送者是否被设置禁言。', 10018: '应答包长度超过最大包长(1MB),请求的内容过多,请尝试减少单次请求的数据量。', 10019: '请求的用户帐号不存在。', 10021: ''.concat('群组', ' ID 已被使用,请选择其他的').concat('群组', ' ID。'), 10023: '发消息的频率超限,请延长两次发消息时间的间隔。', 10024: '此邀请或者申请请求已经被处理。', 10025: ''.concat('群组', ' ID 已被使用,并且操作者为群主,可以直接使用。'), 10026: '该 SDKAppID 请求的命令字已被禁用。', 10030: '请求撤回的消息不存在。', 10031: '消息撤回超过了时间限制(默认2分钟)。', 10032: '请求撤回的消息不支持撤回操作。', 10033: ''.concat('群组', '类型不支持消息撤回操作。'), 10034: '该消息类型不支持删除操作。', 10035: '直播群和在线成员广播大群不支持删除消息。', 10036: '直播群创建数量超过了限制,请参考价格说明('.concat(ur, '269/11673)购买预付费套餐“IM直播群”。'), 10037: '单个用户可创建和加入的'.concat('群组', '数量超过了限制,请参考价格说明(').concat(ur, '269/11673)购买或升级预付费套餐“单人可创建与加入') - .concat('群组', '数”。'), 10038: '群成员数量超过限制,请参考价格说明('.concat(ur, '269/11673)购买或升级预付费套餐“扩展群人数上限”。'), 10041: '该应用(SDKAppID)已配置不支持群消息撤回。', 30001: '请求参数错误,请根据错误描述检查请求参数', 30002: 'SDKAppID 不匹配', 30003: '请求的用户帐号不存在', 30004: '请求需要 App 管理员权限', 30005: '关系链字段中包含敏感词', 30006: ''.concat('服务端内部错误,请重试。'), 30007: ''.concat('网络超时,请稍后重试. '), 30008: '并发写导致写冲突,建议使用批量方式', 30009: '后台禁止该用户发起加好友请求', 30010: '自己的好友数已达系统上限', 30011: '分组已达系统上限', 30012: '未决数已达系统上限', 30014: '对方的好友数已达系统上限', 30515: '请求添加好友时,对方在自己的黑名单中,不允许加好友', 30516: '请求添加好友时,对方的加好友验证方式是不允许任何人添加自己为好友', 30525: '请求添加好友时,自己在对方的黑名单中,不允许加好友', 30539: '等待对方同意', 30540: '添加好友请求被安全策略打击,请勿频繁发起添加好友请求', 31704: '与请求删除的帐号之间不存在好友关系', 31707: '删除好友请求被安全策略打击,请勿频繁发起删除好友请求' }; const hr = (function (e) { - i(n, e);const t = f(n);function n(e) { - let a;return o(this, n), (a = t.call(this)).code = e.code, a.message = pr[e.code] || e.message, a.data = e.data || {}, a; - } return n; - }(g(Error))); let _r = null; const fr = function (e) { - _r = e; - }; const mr = function (e) { - return Promise.resolve(cr(e)); - }; const Mr = function (e) { - const t = arguments.length > 1 && void 0 !== arguments[1] && arguments[1];if (e instanceof hr) return t && null !== _r && _r.emit(E.ERROR, e), Promise.reject(e);if (e instanceof Error) { - const n = new hr({ code: Zn.UNCAUGHT_ERROR, message: e.message });return t && null !== _r && _r.emit(E.ERROR, n), Promise.reject(n); - } if (Ge(e) || Ge(e.code) || Ge(e.message))Ee.error('IMPromise.reject 必须指定code(错误码)和message(错误信息)!!!');else { - if (Ne(e.code) && Ae(e.message)) { - const o = new hr(e);return t && null !== _r && _r.emit(E.ERROR, o), Promise.reject(o); - }Ee.error('IMPromise.reject code(错误码)必须为数字,message(错误信息)必须为字符串!!!'); - } - }; const vr = (function (e) { - i(n, e);const t = f(n);function n(e) { - let a;return o(this, n), (a = t.call(this, e))._className = 'C2CModule', a; - } return s(n, [{ key: 'onNewC2CMessage', value(e) { - const t = e.dataList; const n = e.isInstantMessage; const o = e.C2CRemainingUnreadList;Ee.debug(''.concat(this._className, '.onNewC2CMessage count:').concat(t.length, ' isInstantMessage:') - .concat(n));const a = this._newC2CMessageStoredAndSummary({ dataList: t, C2CRemainingUnreadList: o, isInstantMessage: n }); const s = a.conversationOptionsList; const r = a.messageList;(this.filterModifiedMessage(r), s.length > 0) && this.getModule(Rt).onNewMessage({ conversationOptionsList: s, isInstantMessage: n });const i = this.filterUnmodifiedMessage(r);n && i.length > 0 && this.emitOuterEvent(E.MESSAGE_RECEIVED, i), r.length = 0; - } }, { key: '_newC2CMessageStoredAndSummary', value(e) { - for (var t = e.dataList, n = e.C2CRemainingUnreadList, o = e.isInstantMessage, a = null, s = [], r = [], i = {}, c = this.getModule(Ut), u = 0, l = t.length;u < l;u++) { - const d = t[u];d.currentUser = this.getMyUserID(), d.conversationType = k.CONV_C2C, d.isSystemMessage = !!d.isSystemMessage, a = new ir(d), d.elements = c.parseElements(d.elements, d.from), a.setElement(d.elements), a.setNickAndAvatar({ nick: d.nick, avatar: d.avatar });const g = a.conversationID;if (o) { - let p = !1; const h = this.getModule(Rt);if (a.from !== this.getMyUserID()) { - const _ = h.getLatestMessageSentByPeer(g);if (_) { - const f = _.nick; const m = _.avatar;f === a.nick && m === a.avatar || (p = !0); - } - } else { - const M = h.getLatestMessageSentByMe(g);if (M) { - const v = M.nick; const y = M.avatar;v === a.nick && y === a.avatar || h.modifyMessageSentByMe({ conversationID: g, latestNick: a.nick, latestAvatar: a.avatar }); - } - } let I = 1 === t[u].isModified;if (h.isMessageSentByCurrentInstance(a) ? a.isModified = I : I = !1, 0 === d.msgLifeTime)a.setOnlineOnlyFlag(!0), r.push(a);else { - if (!h.pushIntoMessageList(r, a, I)) continue;p && (h.modifyMessageSentByPeer(g), h.updateUserProfileSpecifiedKey({ conversationID: g, nick: a.nick, avatar: a.avatar })); - } this.getModule($t).addMessageDelay({ currentTime: Date.now(), time: a.time }); - } if (0 !== d.msgLifeTime) { - if (!1 === a.getOnlineOnlyFlag()) if (Ge(i[g]))i[g] = s.push({ conversationID: g, unreadCount: 'out' === a.flow ? 0 : 1, type: a.conversationType, subType: a.conversationSubType, lastMessage: a }) - 1;else { - const D = i[g];s[D].type = a.conversationType, s[D].subType = a.conversationSubType, s[D].lastMessage = a, 'in' === a.flow && s[D].unreadCount++; - } - } else a.setOnlineOnlyFlag(!0); - } if (Re(n)) for (let T = function (e, t) { - const o = s.find((t => t.conversationID === 'C2C'.concat(n[e].from)));o ? o.unreadCount += n[e].count : s.push({ conversationID: 'C2C'.concat(n[e].from), unreadCount: n[e].count, type: k.CONV_C2C, lastMsgTime: n[e].lastMsgTime }); - }, S = 0, E = n.length;S < E;S++)T(S);return { conversationOptionsList: s, messageList: r }; - } }, { key: 'onC2CMessageRevoked', value(e) { - const t = this;Ee.debug(''.concat(this._className, '.onC2CMessageRevoked count:').concat(e.dataList.length));const n = this.getModule(Rt); const o = []; let a = null;e.dataList.forEach(((e) => { - if (e.c2cMessageRevokedNotify) { - const s = e.c2cMessageRevokedNotify.revokedInfos;Ge(s) || s.forEach(((e) => { - const s = t.getMyUserID() === e.from ? ''.concat(k.CONV_C2C).concat(e.to) : ''.concat(k.CONV_C2C).concat(e.from);(a = n.revoke(s, e.sequence, e.random)) && o.push(a); - })); - } - })), 0 !== o.length && (n.onMessageRevoked(o), this.emitOuterEvent(E.MESSAGE_REVOKED, o)); - } }, { key: 'onC2CMessageReadReceipt', value(e) { - const t = this;e.dataList.forEach(((e) => { - if (!dt(e.c2cMessageReadReceipt)) { - const n = e.c2cMessageReadReceipt.to;e.c2cMessageReadReceipt.uinPairReadArray.forEach(((e) => { - const o = e.peerReadTime;Ee.debug(''.concat(t._className, '._onC2CMessageReadReceipt to:').concat(n, ' peerReadTime:') - .concat(o));const a = ''.concat(k.CONV_C2C).concat(n); const s = t.getModule(Rt);s.recordPeerReadTime(a, o), s.updateMessageIsPeerReadProperty(a, o); - })); - } - })); - } }, { key: 'onC2CMessageReadNotice', value(e) { - const t = this;e.dataList.forEach(((e) => { - if (!dt(e.c2cMessageReadNotice)) { - const n = t.getModule(Rt);e.c2cMessageReadNotice.uinPairReadArray.forEach(((e) => { - const o = e.from; const a = e.peerReadTime;Ee.debug(''.concat(t._className, '.onC2CMessageReadNotice from:').concat(o, ' lastReadTime:') - .concat(a));const s = ''.concat(k.CONV_C2C).concat(o);n.updateIsReadAfterReadReport({ conversationID: s, lastMessageTime: a }), n.updateUnreadCount(s); - })); - } - })); - } }, { key: 'sendMessage', value(e, t) { - const n = this._createC2CMessagePack(e, t);return this.request(n); - } }, { key: '_createC2CMessagePack', value(e, t) { - let n = null;t && (t.offlinePushInfo && (n = t.offlinePushInfo), !0 === t.onlineUserOnly && (n ? n.disablePush = !0 : n = { disablePush: !0 }));let o = '';return Ae(e.cloudCustomData) && e.cloudCustomData.length > 0 && (o = e.cloudCustomData), { protocolName: Zt, tjgID: this.generateTjgID(e), requestData: { fromAccount: this.getMyUserID(), toAccount: e.to, msgTimeStamp: Math.ceil(Date.now() / 1e3), msgBody: e.getElements(), cloudCustomData: o, msgSeq: e.sequence, msgRandom: e.random, msgLifeTime: this.isOnlineMessage(e, t) ? 0 : void 0, nick: e.nick, avatar: e.avatar, offlinePushInfo: n ? { pushFlag: !0 === n.disablePush ? 1 : 0, title: n.title || '', desc: n.description || '', ext: n.extension || '', apnsInfo: { badgeMode: !0 === n.ignoreIOSBadge ? 1 : 0 }, androidInfo: { OPPOChannelID: n.androidOPPOChannelID || '' } } : void 0 } }; - } }, { key: 'isOnlineMessage', value(e, t) { - return !(!t || !0 !== t.onlineUserOnly); - } }, { key: 'revokeMessage', value(e) { - return this.request({ protocolName: rn, requestData: { msgInfo: { fromAccount: e.from, toAccount: e.to, msgSeq: e.sequence, msgRandom: e.random, msgTimeStamp: e.time } } }); - } }, { key: 'deleteMessage', value(e) { - const t = e.to; const n = e.keyList;return Ee.log(''.concat(this._className, '.deleteMessage toAccount:').concat(t, ' count:') - .concat(n.length)), this.request({ protocolName: dn, requestData: { fromAccount: this.getMyUserID(), to: t, keyList: n } }); - } }, { key: 'setMessageRead', value(e) { - const t = this; const n = e.conversationID; const o = e.lastMessageTime; const a = ''.concat(this._className, '.setMessageRead');Ee.log(''.concat(a, ' conversationID:').concat(n, ' lastMessageTime:') - .concat(o)), Ne(o) || Ee.warn(''.concat(a, ' 请勿修改 Conversation.lastMessage.lastTime,否则可能会导致已读上报结果不准确'));const s = new Da(Ka);return s.setMessage('conversationID:'.concat(n, ' lastMessageTime:').concat(o)), this.request({ protocolName: cn, requestData: { C2CMsgReaded: { cookie: '', C2CMsgReadedItem: [{ toAccount: n.replace('C2C', ''), lastMessageTime: o, receipt: 1 }] } } }).then((() => { - s.setNetworkType(t.getNetworkType()).end(), Ee.log(''.concat(a, ' ok'));const e = t.getModule(Rt);return e.updateIsReadAfterReadReport({ conversationID: n, lastMessageTime: o }), e.updateUnreadCount(n), cr(); - })) - .catch((e => (t.probeNetwork().then(((t) => { - const n = m(t, 2); const o = n[0]; const a = n[1];s.setError(e, o, a).end(); - })), Ee.log(''.concat(a, ' failed. error:'), e), Mr(e)))); - } }, { key: 'getRoamingMessage', value(e) { - const t = this; const n = ''.concat(this._className, '.getRoamingMessage'); const o = e.peerAccount; const a = e.conversationID; const s = e.count; const r = e.lastMessageTime; const i = e.messageKey; const c = 'peerAccount:'.concat(o, ' count:').concat(s || 15, ' lastMessageTime:') - .concat(r || 0, ' messageKey:') - .concat(i);Ee.log(''.concat(n, ' ').concat(c));const u = new Da(Ua);return this.request({ protocolName: un, requestData: { peerAccount: o, count: s || 15, lastMessageTime: r || 0, messageKey: i } }).then(((e) => { - const o = e.data; const s = o.complete; const r = o.messageList; const i = o.messageKey;Ge(r) ? Ee.log(''.concat(n, ' ok. complete:').concat(s, ' but messageList is undefined!')) : Ee.log(''.concat(n, ' ok. complete:').concat(s, ' count:') - .concat(r.length)), u.setNetworkType(t.getNetworkType()).setMessage(''.concat(c, ' complete:').concat(s, ' length:') - .concat(r.length)) - .end();const l = t.getModule(Rt);1 === s && l.setCompleted(a);const d = l.storeRoamingMessage(r, a);l.modifyMessageList(a), l.updateIsRead(a), l.updateRoamingMessageKey(a, i);const g = l.getPeerReadTime(a);if (Ee.log(''.concat(n, ' update isPeerRead property. conversationID:').concat(a, ' peerReadTime:') - .concat(g)), g)l.updateMessageIsPeerReadProperty(a, g);else { - const p = a.replace(k.CONV_C2C, '');t.getRemotePeerReadTime([p]).then((() => { - l.updateMessageIsPeerReadProperty(a, l.getPeerReadTime(a)); - })); - } return d; - })) - .catch((e => (t.probeNetwork().then(((t) => { - const n = m(t, 2); const o = n[0]; const a = n[1];u.setMessage(c).setError(e, o, a) - .end(); - })), Ee.warn(''.concat(n, ' failed. error:'), e), Mr(e)))); - } }, { key: 'getRemotePeerReadTime', value(e) { - const t = this; const n = ''.concat(this._className, '.getRemotePeerReadTime');if (dt(e)) return Ee.warn(''.concat(n, ' userIDList is empty!')), Promise.resolve();const o = new Da(Ha);return Ee.log(''.concat(n, ' userIDList:').concat(e)), this.request({ protocolName: ln, requestData: { userIDList: e } }).then(((a) => { - const s = a.data.peerReadTimeList;Ee.log(''.concat(n, ' ok. peerReadTimeList:').concat(s));for (var r = '', i = t.getModule(Rt), c = 0;c < e.length;c++)r += ''.concat(e[c], '-').concat(s[c], ' '), s[c] > 0 && i.recordPeerReadTime('C2C'.concat(e[c]), s[c]);o.setNetworkType(t.getNetworkType()).setMessage(r) - .end(); - })) - .catch(((e) => { - t.probeNetwork().then(((t) => { - const n = m(t, 2); const a = n[0]; const s = n[1];o.setError(e, a, s).end(); - })), Ee.warn(''.concat(n, ' failed. error:'), e); - })); - } }]), n; - }(Yt)); const yr = (function () { - function e(t) { - o(this, e), this.list = new Map, this._className = 'MessageListHandler', this._latestMessageSentByPeerMap = new Map, this._latestMessageSentByMeMap = new Map, this._groupLocalLastMessageSequenceMap = new Map; - } return s(e, [{ key: 'getLocalOldestMessageByConversationID', value(e) { - if (!e) return null;if (!this.list.has(e)) return null;const t = this.list.get(e).values();return t ? t.next().value : null; - } }, { key: 'pushIn', value(e) { - const t = arguments.length > 1 && void 0 !== arguments[1] && arguments[1]; const n = e.conversationID; const o = e.ID; let a = !0;this.list.has(n) || this.list.set(n, new Map);const s = this.list.get(n).has(o);if (s) { - const r = this.list.get(n).get(o);if (!t || !0 === r.isModified) return a = !1; - } return this.list.get(n).set(o, e), this._setLatestMessageSentByPeer(n, e), this._setLatestMessageSentByMe(n, e), this._setGroupLocalLastMessageSequence(n, e), a; - } }, { key: 'unshift', value(e) { - let t;if (Re(e)) { - if (e.length > 0) { - t = e[0].conversationID;const n = e.length;this._unshiftMultipleMessages(e), this._setGroupLocalLastMessageSequence(t, e[n - 1]); - } - } else t = e.conversationID, this._unshiftSingleMessage(e), this._setGroupLocalLastMessageSequence(t, e);if (t && t.startsWith(k.CONV_C2C)) { - const o = Array.from(this.list.get(t).values()); const a = o.length;if (0 === a) return;for (let s = a - 1;s >= 0;s--) if ('out' === o[s].flow) { - this._setLatestMessageSentByMe(t, o[s]);break; - } for (let r = a - 1;r >= 0;r--) if ('in' === o[r].flow) { - this._setLatestMessageSentByPeer(t, o[r]);break; - } - } - } }, { key: '_unshiftSingleMessage', value(e) { - const t = e.conversationID; const n = e.ID;if (!this.list.has(t)) return this.list.set(t, new Map), void this.list.get(t).set(n, e);const o = Array.from(this.list.get(t));o.unshift([n, e]), this.list.set(t, new Map(o)); - } }, { key: '_unshiftMultipleMessages', value(e) { - for (var t = e.length, n = [], o = e[0].conversationID, a = this.list.has(o) ? Array.from(this.list.get(o)) : [], s = 0;s < t;s++)n.push([e[s].ID, e[s]]);this.list.set(o, new Map(n.concat(a))); - } }, { key: 'remove', value(e) { - const t = e.conversationID; const n = e.ID;this.list.has(t) && this.list.get(t).delete(n); - } }, { key: 'revoke', value(e, t, n) { - if (Ee.debug('revoke message', e, t, n), this.list.has(e)) { - let o; const a = S(this.list.get(e));try { - for (a.s();!(o = a.n()).done;) { - const s = m(o.value, 2)[1];if (s.sequence === t && !s.isRevoked && (Ge(n) || s.random === n)) return s.isRevoked = !0, s; - } - } catch (r) { - a.e(r); - } finally { - a.f(); - } - } return null; - } }, { key: 'removeByConversationID', value(e) { - this.list.has(e) && (this.list.delete(e), this._latestMessageSentByPeerMap.delete(e), this._latestMessageSentByMeMap.delete(e)); - } }, { key: 'updateMessageIsPeerReadProperty', value(e, t) { - const n = [];if (this.list.has(e)) { - let o; const a = S(this.list.get(e));try { - for (a.s();!(o = a.n()).done;) { - const s = m(o.value, 2)[1];s.time <= t && !s.isPeerRead && 'out' === s.flow && (s.isPeerRead = !0, n.push(s)); - } - } catch (r) { - a.e(r); - } finally { - a.f(); - }Ee.log(''.concat(this._className, '.updateMessageIsPeerReadProperty conversationID:').concat(e, ' peerReadTime:') - .concat(t, ' count:') - .concat(n.length)); - } return n; - } }, { key: 'updateMessageIsModifiedProperty', value(e) { - const t = e.conversationID; const n = e.ID;if (this.list.has(t)) { - const o = this.list.get(t).get(n);o && (o.isModified = !0); - } - } }, { key: 'hasLocalMessageList', value(e) { - return this.list.has(e); - } }, { key: 'getLocalMessageList', value(e) { - return this.hasLocalMessageList(e) ? M(this.list.get(e).values()) : []; - } }, { key: 'hasLocalMessage', value(e, t) { - return !!this.hasLocalMessageList(e) && this.list.get(e).has(t); - } }, { key: 'getLocalMessage', value(e, t) { - return this.hasLocalMessage(e, t) ? this.list.get(e).get(t) : null; - } }, { key: '_setLatestMessageSentByPeer', value(e, t) { - e.startsWith(k.CONV_C2C) && 'in' === t.flow && this._latestMessageSentByPeerMap.set(e, t); - } }, { key: '_setLatestMessageSentByMe', value(e, t) { - e.startsWith(k.CONV_C2C) && 'out' === t.flow && this._latestMessageSentByMeMap.set(e, t); - } }, { key: '_setGroupLocalLastMessageSequence', value(e, t) { - e.startsWith(k.CONV_GROUP) && this._groupLocalLastMessageSequenceMap.set(e, t.sequence); - } }, { key: 'getLatestMessageSentByPeer', value(e) { - return this._latestMessageSentByPeerMap.get(e); - } }, { key: 'getLatestMessageSentByMe', value(e) { - return this._latestMessageSentByMeMap.get(e); - } }, { key: 'getGroupLocalLastMessageSequence', value(e) { - return this._groupLocalLastMessageSequenceMap.get(e) || 0; - } }, { key: 'modifyMessageSentByPeer', value(e, t) { - const n = this.list.get(e);if (!dt(n)) { - const o = Array.from(n.values()); const a = o.length;if (0 !== a) { - let s = null; let r = null;t && (r = t);for (var i = 0, c = !1, u = a - 1;u >= 0;u--)'in' === o[u].flow && (null === r ? r = o[u] : ((s = o[u]).nick !== r.nick && (s.setNickAndAvatar({ nick: r.nick }), c = !0), s.avatar !== r.avatar && (s.setNickAndAvatar({ avatar: r.avatar }), c = !0), c && (i += 1)));Ee.log(''.concat(this._className, '.modifyMessageSentByPeer conversationID:').concat(e, ' count:') - .concat(i)); - } - } - } }, { key: 'modifyMessageSentByMe', value(e) { - const t = e.conversationID; const n = e.latestNick; const o = e.latestAvatar; const a = this.list.get(t);if (!dt(a)) { - const s = Array.from(a.values()); const r = s.length;if (0 !== r) { - for (var i = null, c = 0, u = !1, l = r - 1;l >= 0;l--)'out' === s[l].flow && ((i = s[l]).nick !== n && (i.setNickAndAvatar({ nick: n }), u = !0), i.avatar !== o && (i.setNickAndAvatar({ avatar: o }), u = !0), u && (c += 1));Ee.log(''.concat(this._className, '.modifyMessageSentByMe conversationID:').concat(t, ' count:') - .concat(c)); - } - } - } }, { key: 'traversal', value() { - if (0 !== this.list.size && -1 === Ee.getLevel()) { - console.group('conversationID-messageCount');let e; const t = S(this.list);try { - for (t.s();!(e = t.n()).done;) { - const n = m(e.value, 2); const o = n[0]; const a = n[1];console.log(''.concat(o, '-').concat(a.size)); - } - } catch (s) { - t.e(s); - } finally { - t.f(); - }console.groupEnd(); - } - } }, { key: 'reset', value() { - this.list.clear(), this._latestMessageSentByPeerMap.clear(), this._latestMessageSentByMeMap.clear(), this._groupLocalLastMessageSequenceMap.clear(); - } }]), e; - }()); const Ir = { CONTEXT_A2KEY_AND_TINYID_UPDATED: '_a2KeyAndTinyIDUpdated', CLOUD_CONFIG_UPDATED: '_cloudConfigUpdated' };function Dr(e) { - this.mixin(e); - }Dr.mixin = function (e) { - const t = e.prototype || e;t._isReady = !1, t.ready = function (e) { - const t = arguments.length > 1 && void 0 !== arguments[1] && arguments[1];if (e) return this._isReady ? void (t ? e.call(this) : setTimeout(e, 1)) : (this._readyQueue = this._readyQueue || [], void this._readyQueue.push(e)); - }, t.triggerReady = function () { - const e = this;this._isReady = !0, setTimeout((() => { - const t = e._readyQueue;e._readyQueue = [], t && t.length > 0 && t.forEach((function (e) { - e.call(this); - }), e); - }), 1); - }, t.resetReady = function () { - this._isReady = !1, this._readyQueue = []; - }, t.isReady = function () { - return this._isReady; - }; - };const Tr = ['jpg', 'jpeg', 'gif', 'png', 'bmp']; const Sr = ['mp4']; const Er = 1; const kr = 2; const Cr = 3; const Nr = 255; const Ar = (function () { - function e(t) { - const n = this;o(this, e), dt(t) || (this.userID = t.userID || '', this.nick = t.nick || '', this.gender = t.gender || '', this.birthday = t.birthday || 0, this.location = t.location || '', this.selfSignature = t.selfSignature || '', this.allowType = t.allowType || k.ALLOW_TYPE_ALLOW_ANY, this.language = t.language || 0, this.avatar = t.avatar || '', this.messageSettings = t.messageSettings || 0, this.adminForbidType = t.adminForbidType || k.FORBID_TYPE_NONE, this.level = t.level || 0, this.role = t.role || 0, this.lastUpdatedTime = 0, this.profileCustomField = [], dt(t.profileCustomField) || t.profileCustomField.forEach(((e) => { - n.profileCustomField.push({ key: e.key, value: e.value }); - }))); - } return s(e, [{ key: 'validate', value(e) { - let t = !0; let n = '';if (dt(e)) return { valid: !1, tips: 'empty options' };if (e.profileCustomField) for (let o = e.profileCustomField.length, a = null, s = 0;s < o;s++) { - if (a = e.profileCustomField[s], !Ae(a.key) || -1 === a.key.indexOf('Tag_Profile_Custom')) return { valid: !1, tips: '自定义资料字段的前缀必须是 Tag_Profile_Custom' };if (!Ae(a.value)) return { valid: !1, tips: '自定义资料字段的 value 必须是字符串' }; - } for (const r in e) if (Object.prototype.hasOwnProperty.call(e, r)) { - if ('profileCustomField' === r) continue;if (dt(e[r]) && !Ae(e[r]) && !Ne(e[r])) { - n = `key:${r}, invalid value:${e[r]}`, t = !1;continue; - } switch (r) { - case 'nick':Ae(e[r]) || (n = 'nick should be a string', t = !1), Be(e[r]) > 500 && (n = 'nick name limited: must less than or equal to '.concat(500, ' bytes, current size: ').concat(Be(e[r]), ' bytes'), t = !1);break;case 'gender':Ye(xs, e.gender) || (n = `key:gender, invalid value:${e.gender}`, t = !1);break;case 'birthday':Ne(e.birthday) || (n = 'birthday should be a number', t = !1);break;case 'location':Ae(e.location) || (n = 'location should be a string', t = !1);break;case 'selfSignature':Ae(e.selfSignature) || (n = 'selfSignature should be a string', t = !1);break;case 'allowType':Ye(Hs, e.allowType) || (n = `key:allowType, invalid value:${e.allowType}`, t = !1);break;case 'language':Ne(e.language) || (n = 'language should be a number', t = !1);break;case 'avatar':Ae(e.avatar) || (n = 'avatar should be a string', t = !1);break;case 'messageSettings':0 !== e.messageSettings && 1 !== e.messageSettings && (n = 'messageSettings should be 0 or 1', t = !1);break;case 'adminForbidType':Ye(Bs, e.adminForbidType) || (n = `key:adminForbidType, invalid value:${e.adminForbidType}`, t = !1);break;case 'level':Ne(e.level) || (n = 'level should be a number', t = !1);break;case 'role':Ne(e.role) || (n = 'role should be a number', t = !1);break;default:n = `unknown key:${r} ${e[r]}`, t = !1; - } - } return { valid: t, tips: n }; - } }]), e; - }()); const Or = function e(t) { - o(this, e), this.value = t, this.next = null; - }; const Lr = (function () { - function e(t) { - o(this, e), this.MAX_LENGTH = t, this.pTail = null, this.pNodeToDel = null, this.map = new Map, Ee.debug('SinglyLinkedList init MAX_LENGTH:'.concat(this.MAX_LENGTH)); - } return s(e, [{ key: 'set', value(e) { - const t = new Or(e);if (this.map.size < this.MAX_LENGTH)null === this.pTail ? (this.pTail = t, this.pNodeToDel = t) : (this.pTail.next = t, this.pTail = t), this.map.set(e, 1);else { - let n = this.pNodeToDel;this.pNodeToDel = this.pNodeToDel.next, this.map.delete(n.value), n.next = null, n = null, this.pTail.next = t, this.pTail = t, this.map.set(e, 1); - } - } }, { key: 'has', value(e) { - return this.map.has(e); - } }, { key: 'delete', value(e) { - this.has(e) && this.map.delete(e); - } }, { key: 'tail', value() { - return this.pTail; - } }, { key: 'size', value() { - return this.map.size; - } }, { key: 'data', value() { - return Array.from(this.map.keys()); - } }, { key: 'reset', value() { - for (var e;null !== this.pNodeToDel;)e = this.pNodeToDel, this.pNodeToDel = this.pNodeToDel.next, e.next = null, e = null;this.pTail = null, this.map.clear(); - } }]), e; - }()); const Rr = ['groupID', 'name', 'avatar', 'type', 'introduction', 'notification', 'ownerID', 'selfInfo', 'createTime', 'infoSequence', 'lastInfoTime', 'lastMessage', 'nextMessageSeq', 'memberNum', 'maxMemberNum', 'memberList', 'joinOption', 'groupCustomField', 'muteAllMembers']; const Gr = (function () { - function e(t) { - o(this, e), this.groupID = '', this.name = '', this.avatar = '', this.type = '', this.introduction = '', this.notification = '', this.ownerID = '', this.createTime = '', this.infoSequence = '', this.lastInfoTime = '', this.selfInfo = { messageRemindType: '', joinTime: '', nameCard: '', role: '' }, this.lastMessage = { lastTime: '', lastSequence: '', fromAccount: '', messageForShow: '' }, this.nextMessageSeq = '', this.memberNum = '', this.memberCount = '', this.maxMemberNum = '', this.maxMemberCount = '', this.joinOption = '', this.groupCustomField = [], this.muteAllMembers = void 0, this._initGroup(t); - } return s(e, [{ key: 'memberNum', get() { - return Ee.warn('!!!v2.8.0起弃用memberNum,请使用 memberCount'), this.memberCount; - }, set(e) {} }, { key: 'maxMemberNum', get() { - return Ee.warn('!!!v2.8.0起弃用maxMemberNum,请使用 maxMemberCount'), this.maxMemberCount; - }, set(e) {} }, { key: '_initGroup', value(e) { - for (const t in e)Rr.indexOf(t) < 0 || ('selfInfo' !== t ? ('memberNum' === t && (this.memberCount = e[t]), 'maxMemberNum' === t && (this.maxMemberCount = e[t]), this[t] = e[t]) : this.updateSelfInfo(e[t])); - } }, { key: 'updateGroup', value(e) { - const t = JSON.parse(JSON.stringify(e));t.lastMsgTime && (this.lastMessage.lastTime = t.lastMsgTime), Ge(t.muteAllMembers) || ('On' === t.muteAllMembers ? t.muteAllMembers = !0 : t.muteAllMembers = !1), t.groupCustomField && Qe(this.groupCustomField, t.groupCustomField), Ge(t.memberNum) || (this.memberCount = t.memberNum), Ge(t.maxMemberNum) || (this.maxMemberCount = t.maxMemberNum), Ke(this, t, ['members', 'errorCode', 'lastMsgTime', 'groupCustomField', 'memberNum', 'maxMemberNum']); - } }, { key: 'updateSelfInfo', value(e) { - const t = e.nameCard; const n = e.joinTime; const o = e.role; const a = e.messageRemindType;Ke(this.selfInfo, { nameCard: t, joinTime: n, role: o, messageRemindType: a }, [], ['', null, void 0, 0, NaN]); - } }, { key: 'setSelfNameCard', value(e) { - this.selfInfo.nameCard = e; - } }]), e; - }()); const wr = function (e, t) { - if (Ge(t)) return '';switch (e) { - case k.MSG_TEXT:return t.text;case k.MSG_IMAGE:return '[图片]';case k.MSG_GEO:return '[位置]';case k.MSG_AUDIO:return '[语音]';case k.MSG_VIDEO:return '[视频]';case k.MSG_FILE:return '[文件]';case k.MSG_CUSTOM:return '[自定义消息]';case k.MSG_GRP_TIP:return '[群提示消息]';case k.MSG_GRP_SYS_NOTICE:return '[群系统通知]';case k.MSG_FACE:return '[动画表情]';case k.MSG_MERGER:return '[聊天记录]';default:return ''; - } - }; const Pr = function (e) { - return Ge(e) ? { lastTime: 0, lastSequence: 0, fromAccount: 0, messageForShow: '', payload: null, type: '', isRevoked: !1, cloudCustomData: '', onlineOnlyFlag: !1 } : e instanceof ir ? { lastTime: e.time || 0, lastSequence: e.sequence || 0, fromAccount: e.from || '', messageForShow: wr(e.type, e.payload), payload: e.payload || null, type: e.type || null, isRevoked: e.isRevoked || !1, cloudCustomData: e.cloudCustomData || '', onlineOnlyFlag: !!Pe(e.getOnlineOnlyFlag) && e.getOnlineOnlyFlag() } : t(t({}, e), {}, { messageForShow: wr(e.type, e.payload) }); - }; const br = (function () { - function e(t) { - o(this, e), this.conversationID = t.conversationID || '', this.unreadCount = t.unreadCount || 0, this.type = t.type || '', this.lastMessage = Pr(t.lastMessage), t.lastMsgTime && (this.lastMessage.lastTime = t.lastMsgTime), this._isInfoCompleted = !1, this.peerReadTime = t.peerReadTime || 0, this.groupAtInfoList = [], this.remark = '', this._initProfile(t); - } return s(e, [{ key: 'toAccount', get() { - return this.conversationID.replace('C2C', '').replace('GROUP', ''); - } }, { key: 'subType', get() { - return this.groupProfile ? this.groupProfile.type : ''; - } }, { key: '_initProfile', value(e) { - const t = this;Object.keys(e).forEach(((n) => { - switch (n) { - case 'userProfile':t.userProfile = e.userProfile;break;case 'groupProfile':t.groupProfile = e.groupProfile; - } - })), Ge(this.userProfile) && this.type === k.CONV_C2C ? this.userProfile = new Ar({ userID: e.conversationID.replace('C2C', '') }) : Ge(this.groupProfile) && this.type === k.CONV_GROUP && (this.groupProfile = new Gr({ groupID: e.conversationID.replace('GROUP', '') })); - } }, { key: 'updateUnreadCount', value(e, t) { - Ge(e) || (et(this.subType) ? this.unreadCount = 0 : t && this.type === k.CONV_GROUP ? this.unreadCount = e : this.unreadCount = this.unreadCount + e); - } }, { key: 'updateLastMessage', value(e) { - this.lastMessage = Pr(e); - } }, { key: 'updateGroupAtInfoList', value(e) { - let t; let n = (v(t = e.groupAtType) || y(t) || I(t) || T()).slice(0);-1 !== n.indexOf(k.CONV_AT_ME) && -1 !== n.indexOf(k.CONV_AT_ALL) && (n = [k.CONV_AT_ALL_AT_ME]);const o = { from: e.from, groupID: e.groupID, messageSequence: e.sequence, atTypeArray: n, __random: e.__random, __sequence: e.__sequence };this.groupAtInfoList.push(o), Ee.debug('Conversation.updateGroupAtInfoList conversationID:'.concat(this.conversationID), this.groupAtInfoList); - } }, { key: 'clearGroupAtInfoList', value() { - this.groupAtInfoList.length = 0; - } }, { key: 'reduceUnreadCount', value() { - this.unreadCount >= 1 && (this.unreadCount -= 1); - } }, { key: 'isLastMessageRevoked', value(e) { - const t = e.sequence; const n = e.time;return this.type === k.CONV_C2C && t === this.lastMessage.lastSequence && n === this.lastMessage.lastTime || this.type === k.CONV_GROUP && t === this.lastMessage.lastSequence; - } }, { key: 'setLastMessageRevoked', value(e) { - this.lastMessage.isRevoked = e; - } }]), e; - }()); const Ur = (function (e) { - i(a, e);const n = f(a);function a(e) { - let t;return o(this, a), (t = n.call(this, e))._className = 'ConversationModule', Dr.mixin(h(t)), t._messageListHandler = new yr, t.singlyLinkedList = new Lr(100), t._pagingStatus = ft.NOT_START, t._pagingTimeStamp = 0, t._conversationMap = new Map, t._tmpGroupList = [], t._tmpGroupAtTipsList = [], t._peerReadTimeMap = new Map, t._completedMap = new Map, t._roamingMessageKeyMap = new Map, t._initListeners(), t; - } return s(a, [{ key: '_initListeners', value() { - this.getInnerEmitterInstance().on(Ir.CONTEXT_A2KEY_AND_TINYID_UPDATED, this._initLocalConversationList, this); - } }, { key: 'onCheckTimer', value(e) { - e % 60 == 0 && this._messageListHandler.traversal(); - } }, { key: '_initLocalConversationList', value() { - const e = this; const t = new Da(Qa);Ee.log(''.concat(this._className, '._initLocalConversationList.'));let n = ''; const o = this._getStorageConversationList();if (o) { - for (var a = o.length, s = 0;s < a;s++) { - const r = o[s];if (r && r.groupProfile) { - const i = r.groupProfile.type;if (et(i)) continue; - } this._conversationMap.set(o[s].conversationID, new br(o[s])); - } this._emitConversationUpdate(!0, !1), n = 'count:'.concat(a); - } else n = 'count:0';t.setNetworkType(this.getNetworkType()).setMessage(n) - .end(), this.getModule(Nt) || this.triggerReady(), this.ready((() => { - e._tmpGroupList.length > 0 && (e.updateConversationGroupProfile(e._tmpGroupList), e._tmpGroupList.length = 0); - })), this._syncConversationList(); - } }, { key: 'onMessageSent', value(e) { - this._onSendOrReceiveMessage(e.conversationOptionsList, !0); - } }, { key: 'onNewMessage', value(e) { - this._onSendOrReceiveMessage(e.conversationOptionsList, e.isInstantMessage); - } }, { key: '_onSendOrReceiveMessage', value(e) { - const t = this; const n = !(arguments.length > 1 && void 0 !== arguments[1]) || arguments[1];this._isReady ? 0 !== e.length && (this._getC2CPeerReadTime(e), this._updateLocalConversationList(e, !1, n), this._setStorageConversationList(), this._emitConversationUpdate()) : this.ready((() => { - t._onSendOrReceiveMessage(e, n); - })); - } }, { key: 'updateConversationGroupProfile', value(e) { - const t = this;Re(e) && 0 === e.length || (0 !== this._conversationMap.size ? (e.forEach(((e) => { - const n = 'GROUP'.concat(e.groupID);if (t._conversationMap.has(n)) { - const o = t._conversationMap.get(n);o.groupProfile = e, o.lastMessage.lastSequence < e.nextMessageSeq && (o.lastMessage.lastSequence = e.nextMessageSeq - 1), o.subType || (o.subType = e.type); - } - })), this._emitConversationUpdate(!0, !1)) : this._tmpGroupList = e); - } }, { key: '_updateConversationUserProfile', value(e) { - const t = this;e.data.forEach(((e) => { - const n = 'C2C'.concat(e.userID);t._conversationMap.has(n) && (t._conversationMap.get(n).userProfile = e); - })), this._emitConversationUpdate(!0, !1); - } }, { key: 'onMessageRevoked', value(e) { - const t = this;if (0 !== e.length) { - let n = null; let o = !1;e.forEach(((e) => { - (n = t._conversationMap.get(e.conversationID)) && n.isLastMessageRevoked(e) && (o = !0, n.setLastMessageRevoked(!0)); - })), o && this._emitConversationUpdate(!0, !1); - } - } }, { key: 'onMessageDeleted', value(e) { - if (0 !== e.length) { - e.forEach(((e) => { - e.isDeleted = !0; - }));for (var t = e[0].conversationID, n = this._messageListHandler.getLocalMessageList(t), o = {}, a = n.length - 1;a > 0;a--) if (!n[a].isDeleted) { - o = n[a];break; - } const s = this._conversationMap.get(t);if (s) { - let r = !1;s.lastMessage.lastSequence !== o.sequence && s.lastMessage.lastTime !== o.time && (s.updateLastMessage(o), r = !0, Ee.log(''.concat(this._className, '.onMessageDeleted. update conversationID:').concat(t, ' with lastMessage:'), s.lastMessage)), t.startsWith(k.CONV_C2C) && this.updateUnreadCount(t), r && this._emitConversationUpdate(!0, !1); - } - } - } }, { key: 'onNewGroupAtTips', value(e) { - const t = this; const n = e.dataList; let o = null;n.forEach(((e) => { - e.groupAtTips ? o = e.groupAtTips : e.elements && (o = e.elements), o.__random = e.random, o.__sequence = e.clientSequence, t._tmpGroupAtTipsList.push(o); - })), Ee.debug(''.concat(this._className, '.onNewGroupAtTips isReady:').concat(this._isReady), this._tmpGroupAtTipsList), this._isReady && this._handleGroupAtTipsList(); - } }, { key: '_handleGroupAtTipsList', value() { - const e = this;if (0 !== this._tmpGroupAtTipsList.length) { - let t = !1;this._tmpGroupAtTipsList.forEach(((n) => { - const o = n.groupID;if (n.from !== e.getMyUserID()) { - const a = e._conversationMap.get(''.concat(k.CONV_GROUP).concat(o));a && (a.updateGroupAtInfoList(n), t = !0); - } - })), t && this._emitConversationUpdate(!0, !1), this._tmpGroupAtTipsList.length = 0; - } - } }, { key: '_getC2CPeerReadTime', value(e) { - const t = this; const n = [];if (e.forEach(((e) => { - t._conversationMap.has(e.conversationID) || e.type !== k.CONV_C2C || n.push(e.conversationID.replace(k.CONV_C2C, '')); - })), n.length > 0) { - Ee.debug(''.concat(this._className, '._getC2CPeerReadTime userIDList:').concat(n));const o = this.getModule(Nt);o && o.getRemotePeerReadTime(n); - } - } }, { key: '_getStorageConversationList', value() { - return this.getModule(wt).getItem('conversationMap'); - } }, { key: '_setStorageConversationList', value() { - const e = this.getLocalConversationList().slice(0, 20) - .map((e => ({ conversationID: e.conversationID, type: e.type, subType: e.subType, lastMessage: e.lastMessage, groupProfile: e.groupProfile, userProfile: e.userProfile })));this.getModule(wt).setItem('conversationMap', e); - } }, { key: '_emitConversationUpdate', value() { - const e = !(arguments.length > 0 && void 0 !== arguments[0]) || arguments[0]; const t = !(arguments.length > 1 && void 0 !== arguments[1]) || arguments[1]; const n = M(this._conversationMap.values());if (t) { - const o = this.getModule(At);o && o.updateGroupLastMessage(n); - }e && this.emitOuterEvent(E.CONVERSATION_LIST_UPDATED, n); - } }, { key: 'getLocalConversationList', value() { - return M(this._conversationMap.values()); - } }, { key: 'getLocalConversation', value(e) { - return this._conversationMap.get(e); - } }, { key: '_syncConversationList', value() { - const e = this; const t = new Da(Za);return this._pagingStatus === ft.NOT_START && this._conversationMap.clear(), this._pagingGetConversationList().then((n => (e._pagingStatus = ft.RESOLVED, e._setStorageConversationList(), e._handleC2CPeerReadTime(), e.checkAndPatchRemark(), t.setMessage(e._conversationMap.size).setNetworkType(e.getNetworkType()) - .end(), n))) - .catch((n => (e._pagingStatus = ft.REJECTED, t.setMessage(e._pagingTimeStamp), e.probeNetwork().then(((e) => { - const o = m(e, 2); const a = o[0]; const s = o[1];t.setError(n, a, s).end(); - })), Mr(n)))); - } }, { key: '_pagingGetConversationList', value() { - const e = this; const t = ''.concat(this._className, '._pagingGetConversationList');return this._pagingStatus = ft.PENDING, this.request({ protocolName: gn, requestData: { fromAccount: this.getMyUserID(), timeStamp: this._pagingTimeStamp, orderType: 1, messageAssistFlags: 4 } }).then(((n) => { - const o = n.data; const a = o.completeFlag; const s = o.conversations; const r = void 0 === s ? [] : s; const i = o.timeStamp;if (Ee.log(''.concat(t, ' completeFlag:').concat(a, ' count:') - .concat(r.length)), r.length > 0) { - const c = e._getConversationOptions(r);e._updateLocalConversationList(c, !0); - } if (e._isReady)e._emitConversationUpdate();else { - if (!e.isLoggedIn()) return mr();e.triggerReady(); - } return e._pagingTimeStamp = i, 1 !== a ? e._pagingGetConversationList() : (e._handleGroupAtTipsList(), mr()); - })) - .catch(((n) => { - throw e.isLoggedIn() && (e._isReady || (Ee.warn(''.concat(t, ' failed. error:'), n), e.triggerReady())), n; - })); - } }, { key: '_updateLocalConversationList', value(e, t, n) { - let o; const a = Date.now();o = this._getTmpConversationListMapping(e, t, n), this._conversationMap = new Map(this._sortConversationList([].concat(M(o.toBeUpdatedConversationList), M(this._conversationMap)))), t || this._updateUserOrGroupProfile(o.newConversationList), Ee.debug(''.concat(this._className, '._updateLocalConversationList cost ').concat(Date.now() - a, ' ms')); - } }, { key: '_getTmpConversationListMapping', value(e, t, n) { - for (var o = [], a = [], s = this.getModule(At), r = this.getModule(Ot), i = 0, c = e.length;i < c;i++) { - const u = new br(e[i]); const l = u.conversationID;if (this._conversationMap.has(l)) { - const d = this._conversationMap.get(l); const g = ['unreadCount', 'allowType', 'adminForbidType', 'payload'];n || g.push('lastMessage'), Ke(d, u, g, [null, void 0, '', 0, NaN]), d.updateUnreadCount(u.unreadCount, t), n && (d.lastMessage.payload = e[i].lastMessage.payload), e[i].lastMessage && d.lastMessage.cloudCustomData !== e[i].lastMessage.cloudCustomData && (d.lastMessage.cloudCustomData = e[i].lastMessage.cloudCustomData || ''), this._conversationMap.delete(l), o.push([l, d]); - } else { - if (u.type === k.CONV_GROUP && s) { - const p = u.groupProfile.groupID; const h = s.getLocalGroupProfile(p);h && (u.groupProfile = h, u.updateUnreadCount(0)); - } else if (u.type === k.CONV_C2C) { - const _ = l.replace(k.CONV_C2C, '');r && r.isMyFriend(_) && (u.remark = r.getFriendRemark(_)); - }a.push(u), o.push([l, u]); - } - } return { toBeUpdatedConversationList: o, newConversationList: a }; - } }, { key: '_sortConversationList', value(e) { - return e.sort(((e, t) => t[1].lastMessage.lastTime - e[1].lastMessage.lastTime)); - } }, { key: '_updateUserOrGroupProfile', value(e) { - const t = this;if (0 !== e.length) { - const n = []; const o = []; const a = this.getModule(Ct); const s = this.getModule(At);e.forEach(((e) => { - if (e.type === k.CONV_C2C)n.push(e.toAccount);else if (e.type === k.CONV_GROUP) { - const t = e.toAccount;s.hasLocalGroup(t) ? e.groupProfile = s.getLocalGroupProfile(t) : o.push(t); - } - })), Ee.log(''.concat(this._className, '._updateUserOrGroupProfile c2cUserIDList:').concat(n, ' groupIDList:') - .concat(o)), n.length > 0 && a.getUserProfile({ userIDList: n }).then(((e) => { - const n = e.data;Re(n) ? n.forEach(((e) => { - t._conversationMap.get('C2C'.concat(e.userID)).userProfile = e; - })) : t._conversationMap.get('C2C'.concat(n.userID)).userProfile = n; - })), o.length > 0 && s.getGroupProfileAdvance({ groupIDList: o, responseFilter: { groupBaseInfoFilter: ['Type', 'Name', 'FaceUrl'] } }).then(((e) => { - e.data.successGroupList.forEach(((e) => { - const n = 'GROUP'.concat(e.groupID);if (t._conversationMap.has(n)) { - const o = t._conversationMap.get(n);Ke(o.groupProfile, e, [], [null, void 0, '', 0, NaN]), !o.subType && e.type && (o.subType = e.type); - } - })); - })); - } - } }, { key: '_getConversationOptions', value(e) { - const t = []; const n = e.filter(((e) => { - const t = e.lastMsg;return Le(t); - })).map(((e) => { - if (1 === e.type) { - const n = { userID: e.userID, nick: e.c2CNick, avatar: e.c2CImage };return t.push(n), { conversationID: 'C2C'.concat(e.userID), type: 'C2C', lastMessage: { lastTime: e.time, lastSequence: e.sequence, fromAccount: e.lastC2CMsgFromAccount, messageForShow: e.messageShow, type: e.lastMsg.elements[0] ? e.lastMsg.elements[0].type : null, payload: e.lastMsg.elements[0] ? e.lastMsg.elements[0].content : null, cloudCustomData: e.cloudCustomData || '', isRevoked: 8 === e.lastMessageFlag, onlineOnlyFlag: !1 }, userProfile: new Ar(n), peerReadTime: e.c2cPeerReadTime }; - } return { conversationID: 'GROUP'.concat(e.groupID), type: 'GROUP', lastMessage: { lastTime: e.time, lastSequence: e.messageReadSeq + e.unreadCount, fromAccount: e.msgGroupFromAccount, messageForShow: e.messageShow, type: e.lastMsg.elements[0] ? e.lastMsg.elements[0].type : null, payload: e.lastMsg.elements[0] ? e.lastMsg.elements[0].content : null, cloudCustomData: e.cloudCustomData || '', isRevoked: 2 === e.lastMessageFlag, onlineOnlyFlag: !1 }, groupProfile: new Gr({ groupID: e.groupID, name: e.groupNick, avatar: e.groupImage }), unreadCount: e.unreadCount, peerReadTime: 0 }; - }));t.length > 0 && this.getModule(Ct).onConversationsProfileUpdated(t);return n; - } }, { key: 'getLocalMessageList', value(e) { - return this._messageListHandler.getLocalMessageList(e); - } }, { key: 'deleteLocalMessage', value(e) { - e instanceof ir && this._messageListHandler.remove(e); - } }, { key: 'getMessageList', value(e) { - const t = this; const n = e.conversationID; const o = e.nextReqMessageID; let a = e.count; const s = ''.concat(this._className, '.getMessageList'); const r = this.getLocalConversation(n); let i = '';if (r && r.groupProfile && (i = r.groupProfile.type), et(i)) return Ee.log(''.concat(s, ' not available in avchatroom. conversationID:').concat(n)), mr({ messageList: [], nextReqMessageID: '', isCompleted: !0 });(Ge(a) || a > 15) && (a = 15);let c = this._computeLeftCount({ conversationID: n, nextReqMessageID: o });return Ee.log(''.concat(s, ' conversationID:').concat(n, ' leftCount:') - .concat(c, ' count:') - .concat(a, ' nextReqMessageID:') - .concat(o)), this._needGetHistory({ conversationID: n, leftCount: c, count: a }) ? this.getHistoryMessages({ conversationID: n, nextReqMessageID: o, count: 20 }).then((() => (c = t._computeLeftCount({ conversationID: n, nextReqMessageID: o }), cr(t._computeResult({ conversationID: n, nextReqMessageID: o, count: a, leftCount: c }))))) : (Ee.log(''.concat(s, '.getMessageList get message list from memory')), this.modifyMessageList(n), mr(this._computeResult({ conversationID: n, nextReqMessageID: o, count: a, leftCount: c }))); - } }, { key: '_computeLeftCount', value(e) { - const t = e.conversationID; const n = e.nextReqMessageID;return n ? this._messageListHandler.getLocalMessageList(t).findIndex((e => e.ID === n)) : this._getMessageListSize(t); - } }, { key: '_getMessageListSize', value(e) { - return this._messageListHandler.getLocalMessageList(e).length; - } }, { key: '_needGetHistory', value(e) { - const t = e.conversationID; const n = e.leftCount; const o = e.count; const a = this.getLocalConversation(t); let s = '';return a && a.groupProfile && (s = a.groupProfile.type), !nt(t) && !et(s) && (n < o && !this._completedMap.has(t)); - } }, { key: '_computeResult', value(e) { - const t = e.conversationID; const n = e.nextReqMessageID; const o = e.count; const a = e.leftCount; const s = this._computeMessageList({ conversationID: t, nextReqMessageID: n, count: o }); const r = this._computeIsCompleted({ conversationID: t, leftCount: a, count: o }); const i = this._computeNextReqMessageID({ messageList: s, isCompleted: r, conversationID: t }); const c = ''.concat(this._className, '._computeResult. conversationID:').concat(t);return Ee.log(''.concat(c, ' leftCount:').concat(a, ' count:') - .concat(o, ' nextReqMessageID:') - .concat(i, ' isCompleted:') - .concat(r)), { messageList: s, nextReqMessageID: i, isCompleted: r }; - } }, { key: '_computeMessageList', value(e) { - const t = e.conversationID; const n = e.nextReqMessageID; const o = e.count; const a = this._messageListHandler.getLocalMessageList(t); const s = this._computeIndexEnd({ nextReqMessageID: n, messageList: a }); const r = this._computeIndexStart({ indexEnd: s, count: o });return a.slice(r, s); - } }, { key: '_computeNextReqMessageID', value(e) { - const t = e.messageList; const n = e.isCompleted; const o = e.conversationID;if (!n) return 0 === t.length ? '' : t[0].ID;const a = this._messageListHandler.getLocalMessageList(o);return 0 === a.length ? '' : a[0].ID; - } }, { key: '_computeIndexEnd', value(e) { - const t = e.messageList; const n = void 0 === t ? [] : t; const o = e.nextReqMessageID;return o ? n.findIndex((e => e.ID === o)) : n.length; - } }, { key: '_computeIndexStart', value(e) { - const t = e.indexEnd; const n = e.count;return t > n ? t - n : 0; - } }, { key: '_computeIsCompleted', value(e) { - const t = e.conversationID;return !!(e.leftCount <= e.count && this._completedMap.has(t)); - } }, { key: 'getHistoryMessages', value(e) { - const t = e.conversationID; const n = e.nextReqMessageID;if (t === k.CONV_SYSTEM) return mr();e.count ? e.count > 20 && (e.count = 20) : e.count = 15;let o = this._messageListHandler.getLocalOldestMessageByConversationID(t);o || ((o = {}).time = 0, o.sequence = 0, 0 === t.indexOf(k.CONV_C2C) ? (o.to = t.replace(k.CONV_C2C, ''), o.conversationType = k.CONV_C2C) : 0 === t.indexOf(k.CONV_GROUP) && (o.to = t.replace(k.CONV_GROUP, ''), o.conversationType = k.CONV_GROUP));let a = ''; let s = null;switch (o.conversationType) { - case k.CONV_C2C:return a = t.replace(k.CONV_C2C, ''), (s = this.getModule(Nt)) ? s.getRoamingMessage({ conversationID: e.conversationID, peerAccount: a, count: e.count, lastMessageTime: this._roamingMessageKeyMap.has(t) ? o.time : 0, messageKey: this._roamingMessageKeyMap.get(t) }) : Mr({ code: Zn.CANNOT_FIND_MODULE, message: ra });case k.CONV_GROUP:return (s = this.getModule(At)) ? s.getRoamingMessage({ conversationID: e.conversationID, groupID: o.to, count: e.count, sequence: n && !1 === o.getOnlineOnlyFlag() ? o.sequence - 1 : o.sequence }) : Mr({ code: Zn.CANNOT_FIND_MODULE, message: ra });default:return mr(); - } - } }, { key: 'patchConversationLastMessage', value(e) { - const t = this.getLocalConversation(e);if (t) { - const n = t.lastMessage; const o = n.messageForShow; const a = n.payload;if (dt(o) || dt(a)) { - const s = this._messageListHandler.getLocalMessageList(e);if (0 === s.length) return;const r = s[s.length - 1];Ee.log(''.concat(this._className, '.patchConversationLastMessage conversationID:').concat(e, ' payload:'), r.payload), t.updateLastMessage(r); - } - } - } }, { key: 'storeRoamingMessage', value() { - const e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : []; const n = arguments.length > 1 ? arguments[1] : void 0; const o = n.startsWith(k.CONV_C2C) ? k.CONV_C2C : k.CONV_GROUP; let a = null; const s = []; let r = 0; let i = e.length; let c = null; const u = o === k.CONV_GROUP; const l = this.getModule(Ut); let d = function () { - r = u ? e.length - 1 : 0, i = u ? 0 : e.length; - }; let g = function () { - u ? --r : ++r; - }; let p = function () { - return u ? r >= i : r < i; - };for (d();p();g()) if (u && 1 === e[r].sequence && this.setCompleted(n), 1 !== e[r].isPlaceMessage) if ((a = new ir(e[r])).to = e[r].to, a.isSystemMessage = !!e[r].isSystemMessage, a.conversationType = o, 4 === e[r].event ? c = { type: k.MSG_GRP_TIP, content: t(t({}, e[r].elements), {}, { groupProfile: e[r].groupProfile }) } : (e[r].elements = l.parseElements(e[r].elements, e[r].from), c = e[r].elements), u || a.setNickAndAvatar({ nick: e[r].nick, avatar: e[r].avatar }), dt(c)) { - const h = new Da(Ba);h.setMessage('from:'.concat(a.from, ' to:').concat(a.to, ' sequence:') - .concat(a.sequence, ' event:') - .concat(e[r].event)), h.setNetworkType(this.getNetworkType()).setLevel('warning') - .end(); - } else a.setElement(c), a.reInitialize(this.getMyUserID()), s.push(a);return this._messageListHandler.unshift(s), d = g = p = null, s; - } }, { key: 'setMessageRead', value(e) { - const t = e.conversationID; const n = e.messageID; const o = this.getLocalConversation(t);if (Ee.log(''.concat(this._className, '.setMessageRead conversationID:').concat(t, ' unreadCount:') - .concat(o ? o.unreadCount : 0)), !o) return mr();if (o.type !== k.CONV_GROUP || dt(o.groupAtInfoList) || this.deleteGroupAtTips(t), 0 === o.unreadCount) return mr();const a = this._messageListHandler.getLocalMessage(t, n); let s = null;switch (o.type) { - case k.CONV_C2C:return (s = this.getModule(Nt)) ? s.setMessageRead({ conversationID: t, lastMessageTime: a ? a.time : o.lastMessage.lastTime }) : Mr({ code: Zn.CANNOT_FIND_MODULE, message: ra });case k.CONV_GROUP:return (s = this._moduleManager.getModule(At)) ? s.setMessageRead({ conversationID: t, lastMessageSeq: a ? a.sequence : o.lastMessage.lastSequence }) : Mr({ code: Zn.CANNOT_FIND_MODULE, message: ra });case k.CONV_SYSTEM:return o.unreadCount = 0, this._emitConversationUpdate(!0, !1), mr();default:return mr(); - } - } }, { key: 'updateIsReadAfterReadReport', value(e) { - const t = e.conversationID; const n = e.lastMessageSeq; const o = e.lastMessageTime; const a = this._messageListHandler.getLocalMessageList(t);if (0 !== a.length) for (var s, r = a.length - 1;r >= 0;r--) if (s = a[r], !(o && s.time > o || n && s.sequence > n)) { - if ('in' === s.flow && s.isRead) break;s.setIsRead(!0); - } - } }, { key: 'updateUnreadCount', value(e) { - const t = this.getLocalConversation(e); const n = this._messageListHandler.getLocalMessageList(e);if (t) { - const o = t.unreadCount; const a = n.filter((e => !e.isRead && !e.getOnlineOnlyFlag() && !e.isDeleted)).length;o !== a && (t.unreadCount = a, Ee.log(''.concat(this._className, '.updateUnreadCount from ').concat(o, ' to ') - .concat(a, ', conversationID:') - .concat(e)), this._emitConversationUpdate(!0, !1)); - } - } }, { key: 'updateIsRead', value(e) { - const t = this.getLocalConversation(e); const n = this.getLocalMessageList(e);if (t && 0 !== n.length && !nt(t.type)) { - for (var o = [], a = 0, s = n.length;a < s;a++)'in' !== n[a].flow ? 'out' !== n[a].flow || n[a].isRead || n[a].setIsRead(!0) : o.push(n[a]);let r = 0;if (t.type === k.CONV_C2C) { - const i = o.slice(-t.unreadCount).filter((e => e.isRevoked)).length;r = o.length - t.unreadCount - i; - } else r = o.length - t.unreadCount;for (let c = 0;c < r && !o[c].isRead;c++)o[c].setIsRead(!0); - } - } }, { key: 'deleteGroupAtTips', value(e) { - const t = ''.concat(this._className, '.deleteGroupAtTips');Ee.log(''.concat(t));const n = this._conversationMap.get(e);if (!n) return Promise.resolve();const o = n.groupAtInfoList;if (0 === o.length) return Promise.resolve();const a = this.getMyUserID();return this.request({ protocolName: _n, requestData: { messageListToDelete: o.map((e => ({ from: e.from, to: a, messageSeq: e.__sequence, messageRandom: e.__random, groupID: e.groupID }))) } }).then((() => (Ee.log(''.concat(t, ' ok. count:').concat(o.length)), n.clearGroupAtInfoList(), Promise.resolve()))) - .catch((e => (Ee.error(''.concat(t, ' failed. error:'), e), Mr(e)))); - } }, { key: 'appendToMessageList', value(e) { - this._messageListHandler.pushIn(e); - } }, { key: 'setMessageRandom', value(e) { - this.singlyLinkedList.set(e.random); - } }, { key: 'deleteMessageRandom', value(e) { - this.singlyLinkedList.delete(e.random); - } }, { key: 'pushIntoMessageList', value(e, t, n) { - return !(!this._messageListHandler.pushIn(t, n) || this._isMessageFromCurrentInstance(t) && !n) && (e.push(t), !0); - } }, { key: '_isMessageFromCurrentInstance', value(e) { - return this.singlyLinkedList.has(e.random); - } }, { key: 'revoke', value(e, t, n) { - return this._messageListHandler.revoke(e, t, n); - } }, { key: 'getPeerReadTime', value(e) { - return this._peerReadTimeMap.get(e); - } }, { key: 'recordPeerReadTime', value(e, t) { - this._peerReadTimeMap.has(e) ? this._peerReadTimeMap.get(e) < t && this._peerReadTimeMap.set(e, t) : this._peerReadTimeMap.set(e, t); - } }, { key: 'updateMessageIsPeerReadProperty', value(e, t) { - if (e.startsWith(k.CONV_C2C) && t > 0) { - const n = this._messageListHandler.updateMessageIsPeerReadProperty(e, t);n.length > 0 && this.emitOuterEvent(E.MESSAGE_READ_BY_PEER, n); - } - } }, { key: 'updateMessageIsReadProperty', value(e) { - const t = this.getLocalConversation(e); const n = this._messageListHandler.getLocalMessageList(e);if (t && 0 !== n.length && !nt(t.type)) { - for (var o = [], a = 0;a < n.length;a++)'in' !== n[a].flow ? 'out' !== n[a].flow || n[a].isRead || n[a].setIsRead(!0) : o.push(n[a]);let s = 0;if (t.type === k.CONV_C2C) { - const r = o.slice(-t.unreadCount).filter((e => e.isRevoked)).length;s = o.length - t.unreadCount - r; - } else s = o.length - t.unreadCount;for (let i = 0;i < s && !o[i].isRead;i++)o[i].setIsRead(!0); - } - } }, { key: 'updateMessageIsModifiedProperty', value(e) { - this._messageListHandler.updateMessageIsModifiedProperty(e); - } }, { key: 'setCompleted', value(e) { - Ee.log(''.concat(this._className, '.setCompleted. conversationID:').concat(e)), this._completedMap.set(e, !0); - } }, { key: 'updateRoamingMessageKey', value(e, t) { - this._roamingMessageKeyMap.set(e, t); - } }, { key: 'getConversationList', value() { - const e = this; const t = ''.concat(this._className, '.getConversationList');Ee.log(t), this._pagingStatus === ft.REJECTED && (Ee.log(''.concat(t, '. continue to sync conversationList')), this._syncConversationList());const n = new Da(Wa);return this.request({ protocolName: pn, requestData: { fromAccount: this.getMyUserID() } }).then(((o) => { - const a = o.data.conversations; const s = void 0 === a ? [] : a; const r = e._getConversationOptions(s);return e._updateLocalConversationList(r, !0), e._setStorageConversationList(), e._handleC2CPeerReadTime(), n.setMessage('conversation count: '.concat(s.length)).setNetworkType(e.getNetworkType()) - .end(), Ee.log(''.concat(t, ' ok')), mr({ conversationList: e.getLocalConversationList() }); - })) - .catch((o => (e.probeNetwork().then(((e) => { - const t = m(e, 2); const a = t[0]; const s = t[1];n.setError(o, a, s).end(); - })), Ee.error(''.concat(t, ' failed. error:'), o), Mr(o)))); - } }, { key: '_handleC2CPeerReadTime', value() { - let e; const t = S(this._conversationMap);try { - for (t.s();!(e = t.n()).done;) { - const n = m(e.value, 2); const o = n[0]; const a = n[1];a.type === k.CONV_C2C && (Ee.debug(''.concat(this._className, '._handleC2CPeerReadTime conversationID:').concat(o, ' peerReadTime:') - .concat(a.peerReadTime)), this.recordPeerReadTime(o, a.peerReadTime)); - } - } catch (s) { - t.e(s); - } finally { - t.f(); - } - } }, { key: 'getConversationProfile', value(e) { - let t; const n = this;if ((t = this._conversationMap.has(e) ? this._conversationMap.get(e) : new br({ conversationID: e, type: e.slice(0, 3) === k.CONV_C2C ? k.CONV_C2C : k.CONV_GROUP }))._isInfoCompleted || t.type === k.CONV_SYSTEM) return mr({ conversation: t });const o = new Da(Ja); const a = ''.concat(this._className, '.getConversationProfile');return Ee.log(''.concat(a, '. conversationID:').concat(e, ' remark:') - .concat(t.remark, ' lastMessage:'), t.lastMessage), this._updateUserOrGroupProfileCompletely(t).then(((s) => { - o.setNetworkType(n.getNetworkType()).setMessage('conversationID:'.concat(e, ' unreadCount:').concat(s.data.conversation.unreadCount)) - .end();const r = n.getModule(Ot);if (r && t.type === k.CONV_C2C) { - const i = e.replace(k.CONV_C2C, '');if (r.isMyFriend(i)) { - const c = r.getFriendRemark(i);t.remark !== c && (t.remark = c, Ee.log(''.concat(a, '. conversationID:').concat(e, ' patch remark:') - .concat(t.remark))); - } - } return Ee.log(''.concat(a, ' ok. conversationID:').concat(e)), s; - })) - .catch((t => (n.probeNetwork().then(((n) => { - const a = m(n, 2); const s = a[0]; const r = a[1];o.setError(t, s, r).setMessage('conversationID:'.concat(e)) - .end(); - })), Ee.error(''.concat(a, ' failed. error:'), t), Mr(t)))); - } }, { key: '_updateUserOrGroupProfileCompletely', value(e) { - const t = this;return e.type === k.CONV_C2C ? this.getModule(Ct).getUserProfile({ userIDList: [e.toAccount] }) - .then(((n) => { - const o = n.data;return 0 === o.length ? Mr(new hr({ code: Zn.USER_OR_GROUP_NOT_FOUND, message: Go })) : (e.userProfile = o[0], e._isInfoCompleted = !0, t._unshiftConversation(e), mr({ conversation: e })); - })) : this.getModule(At).getGroupProfile({ groupID: e.toAccount }) - .then((n => (e.groupProfile = n.data.group, e._isInfoCompleted = !0, t._unshiftConversation(e), mr({ conversation: e })))); - } }, { key: '_unshiftConversation', value(e) { - e instanceof br && !this._conversationMap.has(e.conversationID) && (this._conversationMap = new Map([[e.conversationID, e]].concat(M(this._conversationMap))), this._setStorageConversationList(), this._emitConversationUpdate(!0, !1)); - } }, { key: 'deleteConversation', value(e) { - const t = this; const n = { fromAccount: this.getMyUserID(), toAccount: void 0, type: void 0 };if (!this._conversationMap.has(e)) { - const o = new hr({ code: Zn.CONVERSATION_NOT_FOUND, message: Ro });return Mr(o); - } switch (this._conversationMap.get(e).type) { - case k.CONV_C2C:n.type = 1, n.toAccount = e.replace(k.CONV_C2C, '');break;case k.CONV_GROUP:n.type = 2, n.toGroupID = e.replace(k.CONV_GROUP, '');break;case k.CONV_SYSTEM:return this.getModule(At).deleteGroupSystemNotice({ messageList: this._messageListHandler.getLocalMessageList(e) }), this.deleteLocalConversation(e), mr({ conversationID: e });default:var a = new hr({ code: Zn.CONVERSATION_UN_RECORDED_TYPE, message: wo });return Mr(a); - } const s = new Da(Xa);s.setMessage('conversationID:'.concat(e));const r = ''.concat(this._className, '.deleteConversation');return Ee.log(''.concat(r, '. conversationID:').concat(e)), this.setMessageRead({ conversationID: e }).then((() => t.request({ protocolName: hn, requestData: n }))) - .then((() => (s.setNetworkType(t.getNetworkType()).end(), Ee.log(''.concat(r, ' ok')), t.deleteLocalConversation(e), mr({ conversationID: e })))) - .catch((e => (t.probeNetwork().then(((t) => { - const n = m(t, 2); const o = n[0]; const a = n[1];s.setError(e, o, a).end(); - })), Ee.error(''.concat(r, ' failed. error:'), e), Mr(e)))); - } }, { key: 'deleteLocalConversation', value(e) { - this._conversationMap.delete(e), this._setStorageConversationList(), this._messageListHandler.removeByConversationID(e), this._completedMap.delete(e), this._emitConversationUpdate(!0, !1); - } }, { key: 'isMessageSentByCurrentInstance', value(e) { - return !(!this._messageListHandler.hasLocalMessage(e.conversationID, e.ID) && !this.singlyLinkedList.has(e.random)); - } }, { key: 'modifyMessageList', value(e) { - if (e.startsWith(k.CONV_C2C)) { - const t = Date.now();this._messageListHandler.modifyMessageSentByPeer(e);const n = this.getModule(Ct).getNickAndAvatarByUserID(this.getMyUserID());this._messageListHandler.modifyMessageSentByMe({ conversationID: e, latestNick: n.nick, latestAvatar: n.avatar }), Ee.log(''.concat(this._className, '.modifyMessageList conversationID:').concat(e, ' cost ') - .concat(Date.now() - t, ' ms')); - } - } }, { key: 'updateUserProfileSpecifiedKey', value(e) { - Ee.log(''.concat(this._className, '.updateUserProfileSpecifiedKey options:'), e);const t = e.conversationID; const n = e.nick; const o = e.avatar;if (this._conversationMap.has(t)) { - const a = this._conversationMap.get(t).userProfile;Ae(n) && a.nick !== n && (a.nick = n), Ae(o) && a.avatar !== o && (a.avatar = o), this._emitConversationUpdate(!0, !1); - } - } }, { key: 'onMyProfileModified', value(e) { - const n = this; const o = this.getLocalConversationList(); const a = Date.now();o.forEach(((o) => { - n.modifyMessageSentByMe(t({ conversationID: o.conversationID }, e)); - })), Ee.log(''.concat(this._className, '.onMyProfileModified. modify all messages sent by me, cost ').concat(Date.now() - a, ' ms')); - } }, { key: 'modifyMessageSentByMe', value(e) { - this._messageListHandler.modifyMessageSentByMe(e); - } }, { key: 'getLatestMessageSentByMe', value(e) { - return this._messageListHandler.getLatestMessageSentByMe(e); - } }, { key: 'modifyMessageSentByPeer', value(e, t) { - this._messageListHandler.modifyMessageSentByPeer(e, t); - } }, { key: 'getLatestMessageSentByPeer', value(e) { - return this._messageListHandler.getLatestMessageSentByPeer(e); - } }, { key: 'pushIntoNoticeResult', value(e, t) { - return !(!this._messageListHandler.pushIn(t) || this.singlyLinkedList.has(t.random)) && (e.push(t), !0); - } }, { key: 'getGroupLocalLastMessageSequence', value(e) { - return this._messageListHandler.getGroupLocalLastMessageSequence(e); - } }, { key: 'checkAndPatchRemark', value() { - if (0 !== this._conversationMap.size) { - const e = this.getModule(Ot);if (e) { - const t = M(this._conversationMap.values()).filter((e => e.type === k.CONV_C2C));if (0 !== t.length) { - let n = !1; let o = 0;t.forEach(((t) => { - const a = t.conversationID.replace(k.CONV_C2C, '');if (e.isMyFriend(a)) { - const s = e.getFriendRemark(a);t.remark !== s && (t.remark = s, o += 1, n = !0); - } - })), Ee.log(''.concat(this._className, '.checkAndPatchRemark. c2c conversation count:').concat(t.length, ', patched count:') - .concat(o)), n && this._emitConversationUpdate(!0, !1); - } - } - } - } }, { key: 'reset', value() { - Ee.log(''.concat(this._className, '.reset')), this._pagingStatus = ft.NOT_START, this._messageListHandler.reset(), this._roamingMessageKeyMap.clear(), this.singlyLinkedList.reset(), this._peerReadTimeMap.clear(), this._completedMap.clear(), this._conversationMap.clear(), this._pagingTimeStamp = 0, this.resetReady(); - } }]), a; - }(Yt)); const Fr = (function () { - function e(t) { - o(this, e), this._groupModule = t, this._className = 'GroupTipsHandler', this._cachedGroupTipsMap = new Map, this._checkCountMap = new Map, this.MAX_CHECK_COUNT = 4; - } return s(e, [{ key: 'onCheckTimer', value(e) { - e % 1 == 0 && this._cachedGroupTipsMap.size > 0 && this._checkCachedGroupTips(); - } }, { key: '_checkCachedGroupTips', value() { - const e = this;this._cachedGroupTipsMap.forEach(((t, n) => { - let o = e._checkCountMap.get(n); const a = e._groupModule.hasLocalGroup(n);Ee.log(''.concat(e._className, '._checkCachedGroupTips groupID:').concat(n, ' hasLocalGroup:') - .concat(a, ' checkCount:') - .concat(o)), a ? (e._notifyCachedGroupTips(n), e._checkCountMap.delete(n), e._groupModule.deleteUnjoinedAVChatRoom(n)) : o >= e.MAX_CHECK_COUNT ? (e._deleteCachedGroupTips(n), e._checkCountMap.delete(n)) : (o++, e._checkCountMap.set(n, o)); - })); - } }, { key: 'onNewGroupTips', value(e) { - Ee.debug(''.concat(this._className, '.onReceiveGroupTips count:').concat(e.dataList.length));const t = this.newGroupTipsStoredAndSummary(e); const n = t.eventDataList; const o = t.result; const a = t.AVChatRoomMessageList;(a.length > 0 && this._groupModule.onAVChatRoomMessage(a), n.length > 0) && (this._groupModule.getModule(Rt).onNewMessage({ conversationOptionsList: n, isInstantMessage: !0 }), this._groupModule.updateNextMessageSeq(n));o.length > 0 && (this._groupModule.emitOuterEvent(E.MESSAGE_RECEIVED, o), this.handleMessageList(o)); - } }, { key: 'newGroupTipsStoredAndSummary', value(e) { - for (var n = e.event, o = e.dataList, a = null, s = [], r = [], i = {}, c = [], u = 0, l = o.length;u < l;u++) { - const d = o[u]; const g = d.groupProfile.groupID; const p = this._groupModule.hasLocalGroup(g);if (p || !this._groupModule.isUnjoinedAVChatRoom(g)) if (p) if (this._groupModule.isMessageFromAVChatroom(g)) { - const h = Xe(d);h.event = n, c.push(h); - } else { - d.currentUser = this._groupModule.getMyUserID(), d.conversationType = k.CONV_GROUP, (a = new ir(d)).setElement({ type: k.MSG_GRP_TIP, content: t(t({}, d.elements), {}, { groupProfile: d.groupProfile }) }), a.isSystemMessage = !1;const _ = this._groupModule.getModule(Rt); const f = a.conversationID;if (6 === n)a.setOnlineOnlyFlag(!0), r.push(a);else if (!_.pushIntoNoticeResult(r, a)) continue;if (6 !== n || !_.getLocalConversation(f)) { - if (6 !== n) this._groupModule.getModule($t).addMessageSequence({ key: fa, message: a });if (Ge(i[f]))i[f] = s.push({ conversationID: f, unreadCount: 'in' === a.flow && a.getOnlineOnlyFlag() ? 0 : 1, type: a.conversationType, subType: a.conversationSubType, lastMessage: a }) - 1;else { - const m = i[f];s[m].type = a.conversationType, s[m].subType = a.conversationSubType, s[m].lastMessage = a, 'in' !== a.flow || a.getOnlineOnlyFlag() || s[m].unreadCount++; - } - } - } else this._cacheGroupTipsAndProbe({ groupID: g, event: n, item: d }); - } return { eventDataList: s, result: r, AVChatRoomMessageList: c }; - } }, { key: 'handleMessageList', value(e) { - const t = this;e.forEach(((e) => { - switch (e.payload.operationType) { - case 1:t._onNewMemberComeIn(e);break;case 2:t._onMemberQuit(e);break;case 3:t._onMemberKickedOut(e);break;case 4:t._onMemberSetAdmin(e);break;case 5:t._onMemberCancelledAdmin(e);break;case 6:t._onGroupProfileModified(e);break;case 7:t._onMemberInfoModified(e);break;default:Ee.warn(''.concat(t._className, '.handleMessageList unknown operationType:').concat(e.payload.operationType)); - } - })); - } }, { key: '_onNewMemberComeIn', value(e) { - const t = e.payload; const n = t.memberNum; const o = t.groupProfile.groupID; const a = this._groupModule.getLocalGroupProfile(o);a && Ne(n) && (a.memberNum = n); - } }, { key: '_onMemberQuit', value(e) { - const t = e.payload; const n = t.memberNum; const o = t.groupProfile.groupID; const a = this._groupModule.getLocalGroupProfile(o);a && Ne(n) && (a.memberNum = n), this._groupModule.deleteLocalGroupMembers(o, e.payload.userIDList); - } }, { key: '_onMemberKickedOut', value(e) { - const t = e.payload; const n = t.memberNum; const o = t.groupProfile.groupID; const a = this._groupModule.getLocalGroupProfile(o);a && Ne(n) && (a.memberNum = n), this._groupModule.deleteLocalGroupMembers(o, e.payload.userIDList); - } }, { key: '_onMemberSetAdmin', value(e) { - const t = e.payload.groupProfile.groupID; const n = e.payload.userIDList; const o = this._groupModule.getModule(Lt);n.forEach(((e) => { - const n = o.getLocalGroupMemberInfo(t, e);n && n.updateRole(k.GRP_MBR_ROLE_ADMIN); - })); - } }, { key: '_onMemberCancelledAdmin', value(e) { - const t = e.payload.groupProfile.groupID; const n = e.payload.userIDList; const o = this._groupModule.getModule(Lt);n.forEach(((e) => { - const n = o.getLocalGroupMemberInfo(t, e);n && n.updateRole(k.GRP_MBR_ROLE_MEMBER); - })); - } }, { key: '_onGroupProfileModified', value(e) { - const t = this; const n = e.payload.newGroupProfile; const o = e.payload.groupProfile.groupID; const a = this._groupModule.getLocalGroupProfile(o);Object.keys(n).forEach(((e) => { - switch (e) { - case 'ownerID':t._ownerChanged(a, n);break;default:a[e] = n[e]; - } - })), this._groupModule.emitGroupListUpdate(!0, !0); - } }, { key: '_ownerChanged', value(e, t) { - const n = e.groupID; const o = this._groupModule.getLocalGroupProfile(n); const a = this.tim.context.identifier;if (a === t.ownerID) { - o.updateGroup({ selfInfo: { role: k.GRP_MBR_ROLE_OWNER } });const s = this._groupModule.getModule(Lt); const r = s.getLocalGroupMemberInfo(n, a); const i = this._groupModule.getLocalGroupProfile(n).ownerID; const c = s.getLocalGroupMemberInfo(n, i);r && r.updateRole(k.GRP_MBR_ROLE_OWNER), c && c.updateRole(k.GRP_MBR_ROLE_MEMBER); - } - } }, { key: '_onMemberInfoModified', value(e) { - const t = e.payload.groupProfile.groupID; const n = this._groupModule.getModule(Lt);e.payload.memberList.forEach(((e) => { - const o = n.getLocalGroupMemberInfo(t, e.userID);o && e.muteTime && o.updateMuteUntil(e.muteTime); - })); - } }, { key: '_cacheGroupTips', value(e, t) { - this._cachedGroupTipsMap.has(e) || this._cachedGroupTipsMap.set(e, []), this._cachedGroupTipsMap.get(e).push(t); - } }, { key: '_deleteCachedGroupTips', value(e) { - this._cachedGroupTipsMap.has(e) && this._cachedGroupTipsMap.delete(e); - } }, { key: '_notifyCachedGroupTips', value(e) { - const t = this; const n = this._cachedGroupTipsMap.get(e) || [];n.forEach(((e) => { - t.onNewGroupTips(e); - })), this._deleteCachedGroupTips(e), Ee.log(''.concat(this._className, '._notifyCachedGroupTips groupID:').concat(e, ' count:') - .concat(n.length)); - } }, { key: '_cacheGroupTipsAndProbe', value(e) { - const t = this; const n = e.groupID; const o = e.event; const a = e.item;this._cacheGroupTips(n, { event: o, dataList: [a] }), this._groupModule.getGroupSimplifiedInfo(n).then(((e) => { - e.type === k.GRP_AVCHATROOM ? t._groupModule.hasLocalGroup(n) ? t._notifyCachedGroupTips(n) : t._groupModule.setUnjoinedAVChatRoom(n) : (t._groupModule.updateGroupMap([e]), t._notifyCachedGroupTips(n)); - })), this._checkCountMap.has(n) || this._checkCountMap.set(n, 0), Ee.log(''.concat(this._className, '._cacheGroupTipsAndProbe groupID:').concat(n)); - } }, { key: 'reset', value() { - this._cachedGroupTipsMap.clear(), this._checkCountMap.clear(); - } }]), e; - }()); const qr = (function () { - function e(t) { - o(this, e), this._groupModule = t, this._className = 'CommonGroupHandler', this.tempConversationList = null, this._cachedGroupMessageMap = new Map, this._checkCountMap = new Map, this.MAX_CHECK_COUNT = 4, t.getInnerEmitterInstance().once(Ir.CONTEXT_A2KEY_AND_TINYID_UPDATED, this._initGroupList, this); - } return s(e, [{ key: 'onCheckTimer', value(e) { - e % 1 == 0 && this._cachedGroupMessageMap.size > 0 && this._checkCachedGroupMessage(); - } }, { key: '_checkCachedGroupMessage', value() { - const e = this;this._cachedGroupMessageMap.forEach(((t, n) => { - let o = e._checkCountMap.get(n); const a = e._groupModule.hasLocalGroup(n);Ee.log(''.concat(e._className, '._checkCachedGroupMessage groupID:').concat(n, ' hasLocalGroup:') - .concat(a, ' checkCount:') - .concat(o)), a ? (e._notifyCachedGroupMessage(n), e._checkCountMap.delete(n), e._groupModule.deleteUnjoinedAVChatRoom(n)) : o >= e.MAX_CHECK_COUNT ? (e._deleteCachedGroupMessage(n), e._checkCountMap.delete(n)) : (o++, e._checkCountMap.set(n, o)); - })); - } }, { key: '_initGroupList', value() { - const e = this;Ee.log(''.concat(this._className, '._initGroupList'));const t = new Da(gs); const n = this._groupModule.getStorageGroupList();if (Re(n) && n.length > 0) { - n.forEach(((t) => { - e._groupModule.initGroupMap(t); - })), this._groupModule.emitGroupListUpdate(!0, !1);const o = this._groupModule.getLocalGroupList().length;t.setNetworkType(this._groupModule.getNetworkType()).setMessage('group count:'.concat(o)) - .end(); - } else t.setNetworkType(this._groupModule.getNetworkType()).setMessage('group count:0') - .end();Ee.log(''.concat(this._className, '._initGroupList ok')), this.getGroupList(); - } }, { key: 'handleUpdateGroupLastMessage', value(e) { - const t = ''.concat(this._className, '.handleUpdateGroupLastMessage');if (Ee.debug(''.concat(t, ' conversation count:').concat(e.length, ', local group count:') - .concat(this._groupModule.getLocalGroupList().length)), 0 !== this._groupModule.getGroupMap().size) { - for (var n, o, a, s = !1, r = 0, i = e.length;r < i;r++)(n = e[r]).type === k.CONV_GROUP && (o = n.conversationID.split(/^GROUP/)[1], (a = this._groupModule.getLocalGroupProfile(o)) && (a.lastMessage = n.lastMessage, s = !0));s && (this._groupModule.sortLocalGroupList(), this._groupModule.emitGroupListUpdate(!0, !1)); - } else this.tempConversationList = e; - } }, { key: 'onNewGroupMessage', value(e) { - Ee.debug(''.concat(this._className, '.onNewGroupMessage count:').concat(e.dataList.length));const t = this._newGroupMessageStoredAndSummary(e); const n = t.conversationOptionsList; const o = t.messageList; const a = t.AVChatRoomMessageList;(a.length > 0 && this._groupModule.onAVChatRoomMessage(a), this._groupModule.filterModifiedMessage(o), n.length > 0) && (this._groupModule.getModule(Rt).onNewMessage({ conversationOptionsList: n, isInstantMessage: !0 }), this._groupModule.updateNextMessageSeq(n));const s = this._groupModule.filterUnmodifiedMessage(o);s.length > 0 && this._groupModule.emitOuterEvent(E.MESSAGE_RECEIVED, s), o.length = 0; - } }, { key: '_newGroupMessageStoredAndSummary', value(e) { - const t = e.dataList; const n = e.event; const o = e.isInstantMessage; let a = null; const s = []; const r = []; const i = []; const c = {}; const u = k.CONV_GROUP; const l = this._groupModule.getModule(Ut); const d = t.length;d > 1 && t.sort(((e, t) => e.sequence - t.sequence));for (let g = 0;g < d;g++) { - const p = t[g]; const h = p.groupProfile.groupID; const _ = this._groupModule.hasLocalGroup(h);if (_ || !this._groupModule.isUnjoinedAVChatRoom(h)) if (_) if (this._groupModule.isMessageFromAVChatroom(h)) { - const f = Xe(p);f.event = n, i.push(f); - } else { - p.currentUser = this._groupModule.getMyUserID(), p.conversationType = u, p.isSystemMessage = !!p.isSystemMessage, a = new ir(p), p.elements = l.parseElements(p.elements, p.from), a.setElement(p.elements);let m = 1 === t[g].isModified; const M = this._groupModule.getModule(Rt);M.isMessageSentByCurrentInstance(a) ? a.isModified = m : m = !1;const v = this._groupModule.getModule($t);if (o && v.addMessageDelay({ currentTime: Date.now(), time: a.time }), 1 === p.onlineOnlyFlag)a.setOnlineOnlyFlag(!0), r.push(a);else { - if (!M.pushIntoMessageList(r, a, m)) continue;v.addMessageSequence({ key: fa, message: a });const y = a.conversationID;if (Ge(c[y]))c[y] = s.push({ conversationID: y, unreadCount: 'out' === a.flow ? 0 : 1, type: a.conversationType, subType: a.conversationSubType, lastMessage: a }) - 1;else { - const I = c[y];s[I].type = a.conversationType, s[I].subType = a.conversationSubType, s[I].lastMessage = a, 'in' === a.flow && s[I].unreadCount++; - } - } - } else this._cacheGroupMessageAndProbe({ groupID: h, event: n, item: p }); - } return { conversationOptionsList: s, messageList: r, AVChatRoomMessageList: i }; - } }, { key: 'onGroupMessageRevoked', value(e) { - Ee.debug(''.concat(this._className, '.onGroupMessageRevoked nums:').concat(e.dataList.length));const t = this._groupModule.getModule(Rt); const n = []; let o = null;e.dataList.forEach(((e) => { - const a = e.elements.revokedInfos;Ge(a) || a.forEach(((e) => { - (o = t.revoke('GROUP'.concat(e.groupID), e.sequence, e.random)) && n.push(o); - })); - })), 0 !== n.length && (t.onMessageRevoked(n), this._groupModule.emitOuterEvent(E.MESSAGE_REVOKED, n)); - } }, { key: '_groupListTreeShaking', value(e) { - for (var t = new Map(M(this._groupModule.getGroupMap())), n = 0, o = e.length;n < o;n++)t.delete(e[n].groupID);this._groupModule.hasJoinedAVChatRoom() && this._groupModule.getJoinedAVChatRoom().forEach(((e) => { - t.delete(e); - }));for (let a = M(t.keys()), s = 0, r = a.length;s < r;s++) this._groupModule.deleteGroup(a[s]); - } }, { key: 'getGroupList', value(e) { - const t = this; const n = ''.concat(this._className, '.getGroupList'); const o = new Da(ls);Ee.log(''.concat(n));const a = { introduction: 'Introduction', notification: 'Notification', createTime: 'CreateTime', ownerID: 'Owner_Account', lastInfoTime: 'LastInfoTime', memberNum: 'MemberNum', maxMemberNum: 'MaxMemberNum', joinOption: 'ApplyJoinOption', muteAllMembers: 'ShutUpAllMember' }; const s = ['Type', 'Name', 'FaceUrl', 'NextMsgSeq', 'LastMsgTime']; const r = [];return e && e.groupProfileFilter && e.groupProfileFilter.forEach(((e) => { - a[e] && s.push(a[e]); - })), this._pagingGetGroupList({ limit: 50, offset: 0, groupBaseInfoFilter: s, groupList: r }).then((() => { - Ee.log(''.concat(n, ' ok. count:').concat(r.length)), t._groupListTreeShaking(r), t._groupModule.updateGroupMap(r);const e = t._groupModule.getLocalGroupList().length;return o.setNetworkType(t._groupModule.getNetworkType()).setMessage('remote count:'.concat(r.length, ', after tree shaking, local count:').concat(e)) - .end(), t.tempConversationList && (Ee.log(''.concat(n, ' update last message with tempConversationList, count:').concat(t.tempConversationList.length)), t.handleUpdateGroupLastMessage({ data: t.tempConversationList }), t.tempConversationList = null), t._groupModule.emitGroupListUpdate(), cr({ groupList: t._groupModule.getLocalGroupList() }); - })) - .catch((e => (t._groupModule.probeNetwork().then(((t) => { - const n = m(t, 2); const a = n[0]; const s = n[1];o.setError(e, a, s).end(); - })), Ee.error(''.concat(n, ' failed. error:'), e), Mr(e)))); - } }, { key: '_pagingGetGroupList', value(e) { - const t = this; const n = ''.concat(this._className, '._pagingGetGroupList'); const o = e.limit; let a = e.offset; const s = e.groupBaseInfoFilter; const r = e.groupList; const i = new Da(_s);return this._groupModule.request({ protocolName: fn, requestData: { memberAccount: this._groupModule.getMyUserID(), limit: o, offset: a, responseFilter: { groupBaseInfoFilter: s, selfInfoFilter: ['Role', 'JoinTime', 'MsgFlag'] } } }).then(((e) => { - const c = e.data; const u = c.groups; const l = c.totalCount;r.push.apply(r, M(u));const d = a + o; const g = !(l > d);return i.setNetworkType(t._groupModule.getNetworkType()).setMessage('offset:'.concat(a, ' totalCount:').concat(l, ' isCompleted:') - .concat(g, ' currentCount:') - .concat(r.length)) - .end(), g ? (Ee.log(''.concat(n, ' ok. totalCount:').concat(l)), cr({ groupList: r })) : (a = d, t._pagingGetGroupList({ limit: o, offset: a, groupBaseInfoFilter: s, groupList: r })); - })) - .catch((e => (t._groupModule.probeNetwork().then(((t) => { - const n = m(t, 2); const o = n[0]; const a = n[1];i.setError(e, o, a).end(); - })), Mr(e)))); - } }, { key: '_cacheGroupMessage', value(e, t) { - this._cachedGroupMessageMap.has(e) || this._cachedGroupMessageMap.set(e, []), this._cachedGroupMessageMap.get(e).push(t); - } }, { key: '_deleteCachedGroupMessage', value(e) { - this._cachedGroupMessageMap.has(e) && this._cachedGroupMessageMap.delete(e); - } }, { key: '_notifyCachedGroupMessage', value(e) { - const t = this; const n = this._cachedGroupMessageMap.get(e) || [];n.forEach(((e) => { - t.onNewGroupMessage(e); - })), this._deleteCachedGroupMessage(e), Ee.log(''.concat(this._className, '._notifyCachedGroupMessage groupID:').concat(e, ' count:') - .concat(n.length)); - } }, { key: '_cacheGroupMessageAndProbe', value(e) { - const t = this; const n = e.groupID; const o = e.event; const a = e.item;this._cacheGroupMessage(n, { event: o, dataList: [a] }), this._groupModule.getGroupSimplifiedInfo(n).then(((e) => { - e.type === k.GRP_AVCHATROOM ? t._groupModule.hasLocalGroup(n) ? t._notifyCachedGroupMessage(n) : t._groupModule.setUnjoinedAVChatRoom(n) : (t._groupModule.updateGroupMap([e]), t._notifyCachedGroupMessage(n)); - })), this._checkCountMap.has(n) || this._checkCountMap.set(n, 0), Ee.log(''.concat(this._className, '._cacheGroupMessageAndProbe groupID:').concat(n)); - } }, { key: 'reset', value() { - this._cachedGroupMessageMap.clear(), this._checkCountMap.clear(), this._groupModule.getInnerEmitterInstance().once(Ir.CONTEXT_A2KEY_AND_TINYID_UPDATED, this._initGroupList, this); - } }]), e; - }()); const Vr = (function () { - function e(t) { - o(this, e);const n = t.groupModule; const a = t.groupID; const s = t.onInit; const r = t.onSuccess; const i = t.onFail;this._groupModule = n, this._className = 'Polling', this._onInit = s, this._onSuccess = r, this._onFail = i, this._groupID = a, this._timeoutID = -1, this._isRunning = !1, this._pollingInterval = 0, this.MAX_POLLING_INTERVAL = 2e3; - } return s(e, [{ key: 'start', value() { - Ee.log(''.concat(this._className, '.start')), this._isRunning = !0, this._request(); - } }, { key: 'isRunning', value() { - return this._isRunning; - } }, { key: '_request', value() { - const e = this; const t = this._onInit(this._groupID); let n = Gn;this._groupModule.isLoggedIn() || (n = wn), this._groupModule.request({ protocolName: n, requestData: t }).then(((t) => { - e._onSuccess(e._groupID, t), e.isRunning() && (clearTimeout(e._timeoutID), e._timeoutID = setTimeout(e._request.bind(e), 0)); - })) - .catch(((t) => { - e._onFail(e._groupID, t), e.isRunning() && (clearTimeout(e._timeoutID), e._timeoutID = setTimeout(e._request.bind(e), e.MAX_POLLING_INTERVAL)); - })); - } }, { key: 'stop', value() { - Ee.log(''.concat(this._className, '.stop')), this._timeoutID > 0 && (clearTimeout(this._timeoutID), this._timeoutID = -1, this._pollingInterval = 0), this._isRunning = !1; - } }]), e; - }()); const Kr = { 3: !0, 4: !0, 5: !0, 6: !0 }; const xr = (function () { - function e(t) { - o(this, e), this._groupModule = t, this._className = 'AVChatRoomHandler', this._joinedGroupMap = new Map, this._pollingRequestInfoMap = new Map, this._pollingInstanceMap = new Map, this.sequencesLinkedList = new Lr(100), this.messageIDLinkedList = new Lr(100), this.receivedMessageCount = 0, this._reportMessageStackedCount = 0, this._onlineMemberCountMap = new Map, this.DEFAULT_EXPIRE_TIME = 60; - } return s(e, [{ key: 'hasJoinedAVChatRoom', value() { - return this._joinedGroupMap.size > 0; - } }, { key: 'checkJoinedAVChatRoomByID', value(e) { - return this._joinedGroupMap.has(e); - } }, { key: 'getJoinedAVChatRoom', value() { - return this._joinedGroupMap.size > 0 ? M(this._joinedGroupMap.keys()) : null; - } }, { key: '_updateRequestData', value(e) { - return t({}, this._pollingRequestInfoMap.get(e)); - } }, { key: '_handleSuccess', value(e, t) { - const n = t.data; const o = n.key; const a = n.nextSeq; const s = n.rspMsgList;if (0 !== n.errorCode) { - const r = this._pollingRequestInfoMap.get(e); const i = new Da(Cs); const c = r ? ''.concat(r.key, '-').concat(r.startSeq) : 'requestInfo is undefined';i.setMessage(''.concat(e, '-').concat(c, '-') - .concat(t.errorInfo)).setCode(t.errorCode) - .setNetworkType(this._groupModule.getNetworkType()) - .end(!0); - } else { - if (!this.checkJoinedAVChatRoomByID(e)) return;Ae(o) && Ne(a) && this._pollingRequestInfoMap.set(e, { key: o, startSeq: a }), Re(s) && s.length > 0 && (s.forEach(((e) => { - e.to = e.groupID; - })), this.onMessage(s)); - } - } }, { key: '_handleFailure', value(e, t) {} }, { key: 'onMessage', value(e) { - if (Re(e) && 0 !== e.length) { - let t = null; const n = []; const o = this._getModule(Rt); const a = e.length;a > 1 && e.sort(((e, t) => e.sequence - t.sequence));for (let s = this._getModule(Gt), r = 0;r < a;r++) if (Kr[e[r].event]) { - this.receivedMessageCount += 1, t = this.packMessage(e[r], e[r].event);const i = 1 === e[r].isModified;if ((s.isUnlimitedAVChatRoom() || !this.sequencesLinkedList.has(t.sequence)) && !this.messageIDLinkedList.has(t.ID)) { - const c = t.conversationID;if (this.receivedMessageCount % 40 == 0 && this._getModule(Bt).detectMessageLoss(c, this.sequencesLinkedList.data()), null !== this.sequencesLinkedList.tail()) { - const u = this.sequencesLinkedList.tail().value; const l = t.sequence - u;l > 1 && l <= 20 ? this._getModule(Bt).onMessageMaybeLost(c, u + 1, l - 1) : l < -1 && l >= -20 && this._getModule(Bt).onMessageMaybeLost(c, t.sequence + 1, Math.abs(l) - 1); - } this.sequencesLinkedList.set(t.sequence), this.messageIDLinkedList.set(t.ID);let d = !1;if (this._isMessageSentByCurrentInstance(t) ? i && (d = !0, t.isModified = i, o.updateMessageIsModifiedProperty(t)) : d = !0, d) { - if (t.conversationType, k.CONV_SYSTEM, t.conversationType !== k.CONV_SYSTEM) { - const g = this._getModule($t); const p = t.conversationID.replace(k.CONV_GROUP, '');this._pollingInstanceMap.has(p) ? g.addMessageSequence({ key: Ma, message: t }) : (t.type !== k.MSG_GRP_TIP && g.addMessageDelay({ currentTime: Date.now(), time: t.time }), g.addMessageSequence({ key: ma, message: t })); - }n.push(t); - } - } - } else Ee.warn(''.concat(this._className, '.onMessage 未处理的 event 类型: ').concat(e[r].event));if (0 !== n.length) { - this._groupModule.filterModifiedMessage(n);const h = this.packConversationOption(n);if (h.length > 0) this._getModule(Rt).onNewMessage({ conversationOptionsList: h, isInstantMessage: !0 });Ee.debug(''.concat(this._className, '.onMessage count:').concat(n.length)), this._checkMessageStacked(n);const _ = this._groupModule.filterUnmodifiedMessage(n);_.length > 0 && this._groupModule.emitOuterEvent(E.MESSAGE_RECEIVED, _), n.length = 0; - } - } - } }, { key: '_checkMessageStacked', value(e) { - const t = e.length;t >= 100 && (Ee.warn(''.concat(this._className, '._checkMessageStacked 直播群消息堆积数:').concat(e.length, '!可能会导致微信小程序渲染时遇到 "Dom limit exceeded" 的错误,建议接入侧此时只渲染最近的10条消息')), this._reportMessageStackedCount < 5 && (new Da(As).setNetworkType(this._groupModule.getNetworkType()) - .setMessage('count:'.concat(t, ' groupID:').concat(M(this._joinedGroupMap.keys()))) - .setLevel('warning') - .end(), this._reportMessageStackedCount += 1)); - } }, { key: '_isMessageSentByCurrentInstance', value(e) { - return !!this._getModule(Rt).isMessageSentByCurrentInstance(e); - } }, { key: 'packMessage', value(e, t) { - e.currentUser = this._groupModule.getMyUserID(), e.conversationType = 5 === t ? k.CONV_SYSTEM : k.CONV_GROUP, e.isSystemMessage = !!e.isSystemMessage;const n = new ir(e); const o = this.packElements(e, t);return n.setElement(o), n; - } }, { key: 'packElements', value(e, n) { - return 4 === n || 6 === n ? (this._updateMemberCountByGroupTips(e), { type: k.MSG_GRP_TIP, content: t(t({}, e.elements), {}, { groupProfile: e.groupProfile }) }) : 5 === n ? { type: k.MSG_GRP_SYS_NOTICE, content: t(t({}, e.elements), {}, { groupProfile: e.groupProfile }) } : this._getModule(Ut).parseElements(e.elements, e.from); - } }, { key: 'packConversationOption', value(e) { - for (var t = new Map, n = 0;n < e.length;n++) { - const o = e[n]; const a = o.conversationID;if (t.has(a)) { - const s = t.get(a);s.lastMessage = o, 'in' === o.flow && s.unreadCount++; - } else t.set(a, { conversationID: o.conversationID, unreadCount: 'out' === o.flow ? 0 : 1, type: o.conversationType, subType: o.conversationSubType, lastMessage: o }); - } return M(t.values()); - } }, { key: '_updateMemberCountByGroupTips', value(e) { - const t = e.groupProfile.groupID; const n = e.elements.onlineMemberInfo; const o = void 0 === n ? void 0 : n;if (!dt(o)) { - const a = o.onlineMemberNum; const s = void 0 === a ? 0 : a; const r = o.expireTime; const i = void 0 === r ? this.DEFAULT_EXPIRE_TIME : r; const c = this._onlineMemberCountMap.get(t) || {}; const u = Date.now();dt(c) ? Object.assign(c, { lastReqTime: 0, lastSyncTime: 0, latestUpdateTime: u, memberCount: s, expireTime: i }) : (c.latestUpdateTime = u, c.memberCount = s), Ee.debug(''.concat(this._className, '._updateMemberCountByGroupTips info:'), c), this._onlineMemberCountMap.set(t, c); - } - } }, { key: 'start', value(e) { - if (this._pollingInstanceMap.has(e)) { - const t = this._pollingInstanceMap.get(e);t.isRunning() || t.start(); - } else { - const n = new Vr({ groupModule: this._groupModule, groupID: e, onInit: this._updateRequestData.bind(this), onSuccess: this._handleSuccess.bind(this), onFail: this._handleFailure.bind(this) });n.start(), this._pollingInstanceMap.set(e, n), Ee.log(''.concat(this._className, '.start groupID:').concat(e)); - } - } }, { key: 'handleJoinResult', value(e) { - const t = this;return this._preCheck().then((() => { - const n = e.longPollingKey; const o = e.group; const a = o.groupID;return t._joinedGroupMap.set(a, o), t._groupModule.updateGroupMap([o]), t._groupModule.deleteUnjoinedAVChatRoom(a), t._groupModule.emitGroupListUpdate(!0, !1), Ge(n) ? mr({ status: js, group: o }) : Promise.resolve(); - })); - } }, { key: 'startRunLoop', value(e) { - const t = this;return this.handleJoinResult(e).then((() => { - const n = e.longPollingKey; const o = e.group; const a = o.groupID;return t._pollingRequestInfoMap.set(a, { key: n, startSeq: 0 }), t.start(a), t._groupModule.isLoggedIn() ? mr({ status: js, group: o }) : mr({ status: js }); - })); - } }, { key: '_preCheck', value() { - if (this._getModule(Gt).isUnlimitedAVChatRoom()) return Promise.resolve();if (!this.hasJoinedAVChatRoom()) return Promise.resolve();const e = m(this._joinedGroupMap.entries().next().value, 2); const t = e[0]; const n = e[1];if (this._groupModule.isLoggedIn()) { - if (!(n.selfInfo.role === k.GRP_MBR_ROLE_OWNER || n.ownerID === this._groupModule.getMyUserID())) return this._groupModule.quitGroup(t);this._groupModule.deleteLocalGroupAndConversation(t); - } else this._groupModule.deleteLocalGroupAndConversation(t);return this.reset(t), Promise.resolve(); - } }, { key: 'joinWithoutAuth', value(e) { - const t = this; const n = e.groupID; const o = ''.concat(this._className, '.joinWithoutAuth'); const a = new Da(ms);return this._groupModule.request({ protocolName: Dn, requestData: e }).then(((e) => { - const s = e.data.longPollingKey;if (a.setNetworkType(t._groupModule.getNetworkType()).setMessage('groupID:'.concat(n, ' longPollingKey:').concat(s)) - .end(!0), Ge(s)) return Mr(new hr({ code: Zn.CANNOT_JOIN_NON_AVCHATROOM_WITHOUT_LOGIN, message: Bo }));Ee.log(''.concat(o, ' ok. groupID:').concat(n)), t._getModule(Rt).setCompleted(''.concat(k.CONV_GROUP).concat(n));const r = new Gr({ groupID: n });return t.startRunLoop({ group: r, longPollingKey: s }), cr({ status: js }); - })) - .catch((e => (Ee.error(''.concat(o, ' failed. groupID:').concat(n, ' error:'), e), t._groupModule.probeNetwork().then(((t) => { - const o = m(t, 2); const s = o[0]; const r = o[1];a.setError(e, s, r).setMessage('groupID:'.concat(n)) - .end(!0); - })), Mr(e)))) - .finally((() => { - t._groupModule.getModule(Pt).reportAtOnce(); - })); - } }, { key: 'getGroupOnlineMemberCount', value(e) { - const t = this._onlineMemberCountMap.get(e) || {}; const n = Date.now();return dt(t) || n - t.lastSyncTime > 1e3 * t.expireTime && n - t.latestUpdateTime > 1e4 && n - t.lastReqTime > 3e3 ? (t.lastReqTime = n, this._onlineMemberCountMap.set(e, t), this._getGroupOnlineMemberCount(e).then((e => cr({ memberCount: e.memberCount }))) - .catch((e => Mr(e)))) : mr({ memberCount: t.memberCount }); - } }, { key: '_getGroupOnlineMemberCount', value(e) { - const t = this; const n = ''.concat(this._className, '._getGroupOnlineMemberCount');return this._groupModule.request({ protocolName: Pn, requestData: { groupID: e } }).then(((o) => { - const a = t._onlineMemberCountMap.get(e) || {}; const s = o.data; const r = s.onlineMemberNum; const i = void 0 === r ? 0 : r; const c = s.expireTime; const u = void 0 === c ? t.DEFAULT_EXPIRE_TIME : c;Ee.log(''.concat(n, ' ok. groupID:').concat(e, ' memberCount:') - .concat(i, ' expireTime:') - .concat(u));const l = Date.now();return dt(a) && (a.lastReqTime = l), t._onlineMemberCountMap.set(e, Object.assign(a, { lastSyncTime: l, latestUpdateTime: l, memberCount: i, expireTime: u })), { memberCount: i }; - })) - .catch((o => (Ee.warn(''.concat(n, ' failed. error:'), o), new Da(ks).setCode(o.code) - .setMessage('groupID:'.concat(e, ' error:').concat(JSON.stringify(o))) - .setNetworkType(t._groupModule.getNetworkType()) - .end(), Promise.reject(o)))); - } }, { key: '_getModule', value(e) { - return this._groupModule.getModule(e); - } }, { key: 'reset', value(e) { - if (e) { - Ee.log(''.concat(this._className, '.reset groupID:').concat(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 { - Ee.log(''.concat(this._className, '.reset all'));let n; const o = S(this._pollingInstanceMap.values());try { - for (o.s();!(n = o.n()).done;) { - n.value.stop(); - } - } catch (a) { - o.e(a); - } finally { - o.f(); - } this._pollingInstanceMap.clear(), this._joinedGroupMap.clear(), this._pollingRequestInfoMap.clear(), this._onlineMemberCountMap.clear(); - } this.sequencesLinkedList.reset(), this.messageIDLinkedList.reset(), this.receivedMessageCount = 0, this._reportMessageStackedCount = 0; - } }]), e; - }()); const Br = 1; const Hr = 15; const jr = (function () { - function e(t) { - o(this, e), this._groupModule = t, this._className = 'GroupSystemNoticeHandler', this.pendencyMap = new Map; - } return s(e, [{ key: 'onNewGroupSystemNotice', value(e) { - const t = e.dataList; const n = e.isSyncingEnded; const o = e.isInstantMessage;Ee.debug(''.concat(this._className, '.onReceiveSystemNotice count:').concat(t.length));const a = this.newSystemNoticeStoredAndSummary({ notifiesList: t, isInstantMessage: o }); const s = a.eventDataList; const r = a.result;s.length > 0 && (this._groupModule.getModule(Rt).onNewMessage({ conversationOptionsList: s, isInstantMessage: o }), this._onReceivedGroupSystemNotice({ result: r, isInstantMessage: o }));o ? r.length > 0 && this._groupModule.emitOuterEvent(E.MESSAGE_RECEIVED, r) : !0 === n && this._clearGroupSystemNotice(); - } }, { key: 'newSystemNoticeStoredAndSummary', value(e) { - const n = e.notifiesList; const o = e.isInstantMessage; let a = null; const s = n.length; let r = 0; const i = []; const c = { conversationID: k.CONV_SYSTEM, unreadCount: 0, type: k.CONV_SYSTEM, subType: null, lastMessage: null };for (r = 0;r < s;r++) { - const u = n[r];if (u.elements.operationType !== Hr)u.currentUser = this._groupModule.getMyUserID(), u.conversationType = k.CONV_SYSTEM, u.conversationID = k.CONV_SYSTEM, (a = new ir(u)).setElement({ type: k.MSG_GRP_SYS_NOTICE, content: t(t({}, u.elements), {}, { groupProfile: u.groupProfile }) }), a.isSystemMessage = !0, (1 === a.sequence && 1 === a.random || 2 === a.sequence && 2 === a.random) && (a.sequence = He(), a.random = He(), a.generateMessageID(u.currentUser), Ee.log(''.concat(this._className, '.newSystemNoticeStoredAndSummary sequence and random maybe duplicated, regenerate. ID:').concat(a.ID))), this._groupModule.getModule(Rt).pushIntoNoticeResult(i, a) && (o ? c.unreadCount++ : a.setIsRead(!0), c.subType = a.conversationSubType); - } return c.lastMessage = i[i.length - 1], { eventDataList: i.length > 0 ? [c] : [], result: i }; - } }, { key: '_clearGroupSystemNotice', value() { - const e = this;this.getPendencyList().then(((t) => { - t.forEach(((t) => { - e.pendencyMap.set(''.concat(t.from, '_').concat(t.groupID, '_') - .concat(t.to), t); - }));const n = e._groupModule.getModule(Rt).getLocalMessageList(k.CONV_SYSTEM); const o = [];n.forEach(((t) => { - const n = t.payload; const a = n.operatorID; const s = n.operationType; const r = n.groupProfile;if (s === Br) { - const i = ''.concat(a, '_').concat(r.groupID, '_') - .concat(r.to); const c = e.pendencyMap.get(i);c && Ne(c.handled) && 0 !== c.handled && o.push(t); - } - })), e.deleteGroupSystemNotice({ messageList: o }); - })); - } }, { key: 'deleteGroupSystemNotice', value(e) { - const t = this; const n = ''.concat(this._className, '.deleteGroupSystemNotice');return Re(e.messageList) && 0 !== e.messageList.length ? (Ee.log(''.concat(n) + e.messageList.map((e => e.ID))), this._groupModule.request({ protocolName: Rn, requestData: { messageListToDelete: e.messageList.map((e => ({ from: k.CONV_SYSTEM, messageSeq: e.clientSequence, messageRandom: e.random }))) } }).then((() => { - Ee.log(''.concat(n, ' ok'));const o = t._groupModule.getModule(Rt);return e.messageList.forEach(((e) => { - o.deleteLocalMessage(e); - })), cr(); - })) - .catch((e => (Ee.error(''.concat(n, ' error:'), e), Mr(e))))) : mr(); - } }, { key: 'getPendencyList', value(e) { - const t = this;return this._groupModule.request({ protocolName: Ln, requestData: { startTime: e && e.startTime ? e.startTime : 0, limit: e && e.limit ? e.limit : 10, handleAccount: this._groupModule.getMyUserID() } }).then(((e) => { - const n = e.data.pendencyList;return 0 !== e.data.nextStartTime ? t.getPendencyList({ startTime: e.data.nextStartTime }).then((e => [].concat(M(n), M(e)))) : n; - })); - } }, { key: '_onReceivedGroupSystemNotice', value(e) { - const t = this; const n = e.result;e.isInstantMessage && n.forEach(((e) => { - switch (e.payload.operationType) { - case 1:break;case 2:t._onApplyGroupRequestAgreed(e);break;case 3:break;case 4:t._onMemberKicked(e);break;case 5:t._onGroupDismissed(e);break;case 6:break;case 7:t._onInviteGroup(e);break;case 8:t._onQuitGroup(e);break;case 9:t._onSetManager(e);break;case 10:t._onDeleteManager(e); - } - })); - } }, { key: '_onApplyGroupRequestAgreed', value(e) { - const t = this; const n = e.payload.groupProfile.groupID;this._groupModule.hasLocalGroup(n) || this._groupModule.getGroupProfile({ groupID: n }).then(((e) => { - const n = e.data.group;n && (t._groupModule.updateGroupMap([n]), t._groupModule.emitGroupListUpdate()); - })); - } }, { key: '_onMemberKicked', value(e) { - const t = e.payload.groupProfile.groupID;this._groupModule.hasLocalGroup(t) && this._groupModule.deleteLocalGroupAndConversation(t); - } }, { key: '_onGroupDismissed', value(e) { - const t = e.payload.groupProfile.groupID;this._groupModule.hasLocalGroup(t) && this._groupModule.deleteLocalGroupAndConversation(t);const n = this._groupModule._AVChatRoomHandler;n && n.checkJoinedAVChatRoomByID(t) && n.reset(t); - } }, { key: '_onInviteGroup', value(e) { - const t = this; const n = e.payload.groupProfile.groupID;this._groupModule.hasLocalGroup(n) || this._groupModule.getGroupProfile({ groupID: n }).then(((e) => { - const n = e.data.group;n && (t._groupModule.updateGroupMap([n]), t._groupModule.emitGroupListUpdate()); - })); - } }, { key: '_onQuitGroup', value(e) { - const t = e.payload.groupProfile.groupID;this._groupModule.hasLocalGroup(t) && this._groupModule.deleteLocalGroupAndConversation(t); - } }, { key: '_onSetManager', value(e) { - const t = e.payload.groupProfile; const n = t.to; const o = t.groupID; const a = this._groupModule.getModule(Lt).getLocalGroupMemberInfo(o, n);a && a.updateRole(k.GRP_MBR_ROLE_ADMIN); - } }, { key: '_onDeleteManager', value(e) { - const t = e.payload.groupProfile; const n = t.to; const o = t.groupID; const a = this._groupModule.getModule(Lt).getLocalGroupMemberInfo(o, n);a && a.updateRole(k.GRP_MBR_ROLE_MEMBER); - } }, { key: 'reset', value() { - this.pendencyMap.clear(); - } }]), e; - }()); const $r = (function (e) { - i(a, e);const n = f(a);function a(e) { - let t;return o(this, a), (t = n.call(this, e))._className = 'GroupModule', t._commonGroupHandler = null, t._AVChatRoomHandler = null, t._groupSystemNoticeHandler = null, t._commonGroupHandler = new qr(h(t)), t._AVChatRoomHandler = new xr(h(t)), t._groupTipsHandler = new Fr(h(t)), t._groupSystemNoticeHandler = new jr(h(t)), t.groupMap = new Map, t._unjoinedAVChatRoomList = new Map, t; - } return s(a, [{ key: 'onCheckTimer', value(e) { - this.isLoggedIn() && (this._commonGroupHandler.onCheckTimer(e), this._groupTipsHandler.onCheckTimer(e)); - } }, { key: 'guardForAVChatRoom', value(e) { - const t = this;if (e.conversationType === k.CONV_GROUP) { - const n = e.to;return this.hasLocalGroup(n) ? mr() : this.getGroupProfile({ groupID: n }).then(((o) => { - const a = o.data.group.type;if (Ee.log(''.concat(t._className, '.guardForAVChatRoom. groupID:').concat(n, ' type:') - .concat(a)), a === k.GRP_AVCHATROOM) { - const s = 'userId:'.concat(e.from, ' 未加入群 groupID:').concat(n, '。发消息前先使用 joinGroup 接口申请加群,详细请参考 https://web.sdk.qcloud.com/im/doc/zh-cn/SDK.html#joinGroup');return Ee.warn(''.concat(t._className, '.guardForAVChatRoom sendMessage not allowed. ').concat(s)), Mr(new hr({ code: Zn.MESSAGE_SEND_FAIL, message: s, data: { message: e } })); - } return mr(); - })); - } return mr(); - } }, { key: 'checkJoinedAVChatRoomByID', value(e) { - return !!this._AVChatRoomHandler && this._AVChatRoomHandler.checkJoinedAVChatRoomByID(e); - } }, { key: 'onNewGroupMessage', value(e) { - this._commonGroupHandler && this._commonGroupHandler.onNewGroupMessage(e); - } }, { key: 'updateNextMessageSeq', value(e) { - const t = this;Re(e) && e.forEach(((e) => { - const n = e.conversationID.replace(k.CONV_GROUP, '');t.groupMap.has(n) && (t.groupMap.get(n).nextMessageSeq = e.lastMessage.sequence + 1); - })); - } }, { key: 'onNewGroupTips', value(e) { - this._groupTipsHandler && this._groupTipsHandler.onNewGroupTips(e); - } }, { key: 'onGroupMessageRevoked', value(e) { - this._commonGroupHandler && this._commonGroupHandler.onGroupMessageRevoked(e); - } }, { key: 'onNewGroupSystemNotice', value(e) { - this._groupSystemNoticeHandler && this._groupSystemNoticeHandler.onNewGroupSystemNotice(e); - } }, { key: 'onGroupMessageReadNotice', value(e) { - const t = this;e.dataList.forEach(((e) => { - const n = e.elements.groupMessageReadNotice;if (!Ge(n)) { - const o = t.getModule(Rt);n.forEach(((e) => { - const n = e.groupID; const a = e.lastMessageSeq;Ee.debug(''.concat(t._className, '.onGroupMessageReadNotice groupID:').concat(n, ' lastMessageSeq:') - .concat(a));const s = ''.concat(k.CONV_GROUP).concat(n);o.updateIsReadAfterReadReport({ conversationID: s, lastMessageSeq: a }), o.updateUnreadCount(s); - })); - } - })); - } }, { key: 'deleteGroupSystemNotice', value(e) { - this._groupSystemNoticeHandler && this._groupSystemNoticeHandler.deleteGroupSystemNotice(e); - } }, { key: 'initGroupMap', value(e) { - this.groupMap.set(e.groupID, new Gr(e)); - } }, { key: 'deleteGroup', value(e) { - this.groupMap.delete(e); - } }, { key: 'updateGroupMap', value(e) { - const t = this;e.forEach(((e) => { - t.groupMap.has(e.groupID) ? t.groupMap.get(e.groupID).updateGroup(e) : t.groupMap.set(e.groupID, new Gr(e)); - })), this._setStorageGroupList(); - } }, { key: 'getStorageGroupList', value() { - return this.getModule(wt).getItem('groupMap'); - } }, { key: '_setStorageGroupList', value() { - const e = this.getLocalGroupList().filter(((e) => { - const t = e.type;return !et(t); - })) - .slice(0, 20) - .map((e => ({ groupID: e.groupID, name: e.name, avatar: e.avatar, type: e.type })));this.getModule(wt).setItem('groupMap', e); - } }, { key: 'getGroupMap', value() { - return this.groupMap; - } }, { key: 'getLocalGroupList', value() { - return M(this.groupMap.values()); - } }, { key: 'getLocalGroupProfile', value(e) { - return this.groupMap.get(e); - } }, { key: 'sortLocalGroupList', value() { - const e = M(this.groupMap).filter(((e) => { - const t = m(e, 2);t[0];return !dt(t[1].lastMessage); - }));e.sort(((e, t) => t[1].lastMessage.lastTime - e[1].lastMessage.lastTime)), this.groupMap = new Map(M(e)); - } }, { key: 'updateGroupLastMessage', value(e) { - this._commonGroupHandler && this._commonGroupHandler.handleUpdateGroupLastMessage(e); - } }, { key: 'emitGroupListUpdate', value() { - const e = !(arguments.length > 0 && void 0 !== arguments[0]) || arguments[0]; const t = !(arguments.length > 1 && void 0 !== arguments[1]) || arguments[1]; const n = this.getLocalGroupList();if (e && this.emitOuterEvent(E.GROUP_LIST_UPDATED, n), t) { - const o = JSON.parse(JSON.stringify(n)); const a = this.getModule(Rt);a.updateConversationGroupProfile(o); - } - } }, { key: 'getGroupList', value(e) { - return this._commonGroupHandler ? this._commonGroupHandler.getGroupList(e) : mr(); - } }, { key: 'getGroupProfile', value(e) { - const t = this; const n = new Da(ds); const o = ''.concat(this._className, '.getGroupProfile'); const a = e.groupID; const s = e.groupCustomFieldFilter;Ee.log(''.concat(o, ' groupID:').concat(a));const r = { groupIDList: [a], responseFilter: { groupBaseInfoFilter: ['Type', 'Name', 'Introduction', 'Notification', 'FaceUrl', 'Owner_Account', 'CreateTime', 'InfoSeq', 'LastInfoTime', 'LastMsgTime', 'MemberNum', 'MaxMemberNum', 'ApplyJoinOption', 'NextMsgSeq', 'ShutUpAllMember'], groupCustomFieldFilter: s } };return this.getGroupProfileAdvance(r).then(((e) => { - let s; const r = e.data; const i = r.successGroupList; const c = r.failureGroupList;return Ee.log(''.concat(o, ' ok')), c.length > 0 ? Mr(c[0]) : (et(i[0].type) && !t.hasLocalGroup(a) ? s = new Gr(i[0]) : (t.updateGroupMap(i), s = t.getLocalGroupProfile(a)), n.setNetworkType(t.getNetworkType()).setMessage('groupID:'.concat(a, ' type:').concat(s.type, ' muteAllMembers:') - .concat(s.muteAllMembers, ' ownerID:') - .concat(s.ownerID)) - .end(), s && s.selfInfo && !s.selfInfo.nameCard ? t.updateSelfInfo(s).then((e => cr({ group: e }))) : cr({ group: s })); - })) - .catch((a => (t.probeNetwork().then(((t) => { - const o = m(t, 2); const s = o[0]; const r = o[1];n.setError(a, s, r).setMessage('groupID:'.concat(e.groupID)) - .end(); - })), Ee.error(''.concat(o, ' failed. error:'), a), Mr(a)))); - } }, { key: 'getGroupProfileAdvance', value(e) { - const t = ''.concat(this._className, '.getGroupProfileAdvance');return Re(e.groupIDList) && e.groupIDList.length > 50 && (Ee.warn(''.concat(t, ' 获取群资料的数量不能超过50个')), e.groupIDList.length = 50), Ee.log(''.concat(t, ' groupIDList:').concat(e.groupIDList)), this.request({ protocolName: mn, requestData: e }).then(((e) => { - Ee.log(''.concat(t, ' ok'));const n = e.data.groups; const o = n.filter((e => Ge(e.errorCode) || 0 === e.errorCode)); const a = n.filter((e => e.errorCode && 0 !== e.errorCode)).map((e => new hr({ code: e.errorCode, message: e.errorInfo, data: { groupID: e.groupID } })));return cr({ successGroupList: o, failureGroupList: a }); - })) - .catch((e => (Ee.error(''.concat(t, ' failed. error:'), e), Mr(e)))); - } }, { key: 'updateSelfInfo', value(e) { - const t = ''.concat(this._className, '.updateSelfInfo'); const n = e.groupID;return Ee.log(''.concat(t, ' groupID:').concat(n)), this.getModule(Lt).getGroupMemberProfile({ groupID: n, userIDList: [this.getMyUserID()] }) - .then(((n) => { - const o = n.data.memberList;return Ee.log(''.concat(t, ' ok')), e && 0 !== o.length && e.updateSelfInfo(o[0]), e; - })); - } }, { key: 'createGroup', value(e) { - const n = this; const o = ''.concat(this._className, '.createGroup');if (!['Public', 'Private', 'ChatRoom', 'AVChatRoom'].includes(e.type)) { - const a = new hr({ code: Zn.ILLEGAL_GROUP_TYPE, message: Po });return Mr(a); - }et(e.type) && !Ge(e.memberList) && e.memberList.length > 0 && (Ee.warn(''.concat(o, ' 创建 AVChatRoom 时不能添加群成员,自动忽略该字段')), e.memberList = void 0), Ze(e.type) || Ge(e.joinOption) || (Ee.warn(''.concat(o, ' 创建 Work/Meeting/AVChatRoom 群时不能设置字段 joinOption,自动忽略该字段')), e.joinOption = void 0);const s = new Da(es);Ee.log(''.concat(o, ' options:'), e);let r = [];return this.request({ protocolName: Mn, requestData: t(t({}, e), {}, { ownerID: this.getMyUserID(), webPushFlag: 1 }) }).then(((a) => { - const i = a.data; const c = i.groupID; const u = i.overLimitUserIDList; const l = void 0 === u ? [] : u;if (r = l, s.setNetworkType(n.getNetworkType()).setMessage('groupType:'.concat(e.type, ' groupID:').concat(c, ' overLimitUserIDList=') - .concat(l)) - .end(), Ee.log(''.concat(o, ' ok groupID:').concat(c, ' overLimitUserIDList:'), l), e.type === k.GRP_AVCHATROOM) return n.getGroupProfile({ groupID: c });dt(e.memberList) || dt(l) || (e.memberList = e.memberList.filter((e => -1 === l.indexOf(e.userID)))), n.updateGroupMap([t(t({}, e), {}, { groupID: c })]);const d = n.getModule(kt); const g = d.createCustomMessage({ to: c, conversationType: k.CONV_GROUP, payload: { data: 'group_create', extension: ''.concat(n.getMyUserID(), '创建群组') } });return d.sendMessageInstance(g), n.emitGroupListUpdate(), n.getGroupProfile({ groupID: c }); - })) - .then(((e) => { - const t = e.data.group; const n = t.selfInfo; const o = n.nameCard; const a = n.joinTime;return t.updateSelfInfo({ nameCard: o, joinTime: a, messageRemindType: k.MSG_REMIND_ACPT_AND_NOTE, role: k.GRP_MBR_ROLE_OWNER }), cr({ group: t, overLimitUserIDList: r }); - })) - .catch((t => (s.setMessage('groupType:'.concat(e.type)), n.probeNetwork().then(((e) => { - const n = m(e, 2); const o = n[0]; const a = n[1];s.setError(t, o, a).end(); - })), Ee.error(''.concat(o, ' failed. error:'), t), Mr(t)))); - } }, { key: 'dismissGroup', value(e) { - const t = this; const n = ''.concat(this._className, '.dismissGroup');if (this.hasLocalGroup(e) && this.getLocalGroupProfile(e).type === k.GRP_WORK) return Mr(new hr({ code: Zn.CANNOT_DISMISS_WORK, message: qo }));const o = new Da(cs);return o.setMessage('groupID:'.concat(e)), Ee.log(''.concat(n, ' groupID:').concat(e)), this.request({ protocolName: vn, requestData: { groupID: e } }).then((() => (o.setNetworkType(t.getNetworkType()).end(), Ee.log(''.concat(n, ' ok')), t.deleteLocalGroupAndConversation(e), t.checkJoinedAVChatRoomByID(e) && t._AVChatRoomHandler.reset(e), cr({ groupID: e })))) - .catch((e => (t.probeNetwork().then(((t) => { - const n = m(t, 2); const a = n[0]; const s = n[1];o.setError(e, a, s).end(); - })), Ee.error(''.concat(n, ' failed. error:'), e), Mr(e)))); - } }, { key: 'updateGroupProfile', value(e) { - const t = this; const n = ''.concat(this._className, '.updateGroupProfile');!this.hasLocalGroup(e.groupID) || Ze(this.getLocalGroupProfile(e.groupID).type) || Ge(e.joinOption) || (Ee.warn(''.concat(n, ' Work/Meeting/AVChatRoom 群不能设置字段 joinOption,自动忽略该字段')), e.joinOption = void 0), Ge(e.muteAllMembers) || (e.muteAllMembers ? e.muteAllMembers = 'On' : e.muteAllMembers = 'Off');const o = new Da(us);return o.setMessage(JSON.stringify(e)), Ee.log(''.concat(n, ' groupID:').concat(e.groupID)), this.request({ protocolName: yn, requestData: e }).then((() => { - (o.setNetworkType(t.getNetworkType()).end(), Ee.log(''.concat(n, ' ok')), t.hasLocalGroup(e.groupID)) && (t.groupMap.get(e.groupID).updateGroup(e), t._setStorageGroupList());return cr({ group: t.groupMap.get(e.groupID) }); - })) - .catch((e => (t.probeNetwork().then(((t) => { - const n = m(t, 2); const a = n[0]; const s = n[1];o.setError(e, a, s).end(); - })), Ee.log(''.concat(n, ' failed. error:'), e), Mr(e)))); - } }, { key: 'joinGroup', value(e) { - const t = this; const n = e.groupID; const o = e.type; const a = ''.concat(this._className, '.joinGroup');if (o === k.GRP_WORK) { - const s = new hr({ code: Zn.CANNOT_JOIN_WORK, message: bo });return Mr(s); - } if (this.deleteUnjoinedAVChatRoom(n), this.hasLocalGroup(n)) { - if (!this.isLoggedIn()) return mr({ status: k.JOIN_STATUS_ALREADY_IN_GROUP });const r = new Da(ts);return this.getGroupProfile({ groupID: n }).then((() => (r.setNetworkType(t.getNetworkType()).setMessage('groupID:'.concat(n, ' joinedStatus:').concat(k.JOIN_STATUS_ALREADY_IN_GROUP)) - .end(), mr({ status: k.JOIN_STATUS_ALREADY_IN_GROUP })))) - .catch((o => (r.setNetworkType(t.getNetworkType()).setMessage('groupID:'.concat(n, ' unjoined')) - .end(), Ee.warn(''.concat(a, ' ').concat(n, ' was unjoined, now join!')), t.groupMap.delete(n), t.applyJoinGroup(e)))); - } return Ee.log(''.concat(a, ' groupID:').concat(n)), this.isLoggedIn() ? this.applyJoinGroup(e) : this._AVChatRoomHandler.joinWithoutAuth(e); - } }, { key: 'applyJoinGroup', value(e) { - const t = this; const n = ''.concat(this._className, '.applyJoinGroup'); const o = e.groupID; const a = new Da(ts);return this.request({ protocolName: In, requestData: e }).then(((e) => { - const s = e.data; const r = s.joinedStatus; const i = s.longPollingKey; const c = s.avChatRoomFlag; const u = 'groupID:'.concat(o, ' joinedStatus:').concat(r, ' longPollingKey:') - .concat(i, ' avChatRoomFlag:') - .concat(c);switch (a.setNetworkType(t.getNetworkType()).setMessage(''.concat(u)) - .end(), Ee.log(''.concat(n, ' ok. ').concat(u)), r) { - case $s:return cr({ status: $s });case js:return t.getGroupProfile({ groupID: o }).then(((e) => { - const n = e.data.group; const a = { status: js, group: n };return 1 === c ? (t.getModule(Rt).setCompleted(''.concat(k.CONV_GROUP).concat(o)), Ge(i) ? t._AVChatRoomHandler.handleJoinResult({ group: n }) : t._AVChatRoomHandler.startRunLoop({ longPollingKey: i, group: n })) : (t.emitGroupListUpdate(!0, !1), cr(a)); - }));default:var l = new hr({ code: Zn.JOIN_GROUP_FAIL, message: Ko });return Ee.error(''.concat(n, ' error:'), l), Mr(l); - } - })) - .catch((o => (a.setMessage('groupID:'.concat(e.groupID)), t.probeNetwork().then(((e) => { - const t = m(e, 2); const n = t[0]; const s = t[1];a.setError(o, n, s).end(); - })), Ee.error(''.concat(n, ' error:'), o), Mr(o)))); - } }, { key: 'quitGroup', value(e) { - const t = this; const n = ''.concat(this._className, '.quitGroup');Ee.log(''.concat(n, ' groupID:').concat(e));const o = this.checkJoinedAVChatRoomByID(e);if (!o && !this.hasLocalGroup(e)) { - const a = new hr({ code: Zn.MEMBER_NOT_IN_GROUP, message: Vo });return Mr(a); - } if (o && !this.isLoggedIn()) return Ee.log(''.concat(n, ' anonymously ok. groupID:').concat(e)), this.deleteLocalGroupAndConversation(e), this._AVChatRoomHandler.reset(e), mr({ groupID: e });const s = new Da(ns);return s.setMessage('groupID:'.concat(e)), this.request({ protocolName: Tn, requestData: { groupID: e } }).then((() => (s.setNetworkType(t.getNetworkType()).end(), Ee.log(''.concat(n, ' ok')), o && t._AVChatRoomHandler.reset(e), t.deleteLocalGroupAndConversation(e), cr({ groupID: e })))) - .catch((e => (t.probeNetwork().then(((t) => { - const n = m(t, 2); const o = n[0]; const a = n[1];s.setError(e, o, a).end(); - })), Ee.error(''.concat(n, ' failed. error:'), e), Mr(e)))); - } }, { key: 'searchGroupByID', value(e) { - const t = this; const n = ''.concat(this._className, '.searchGroupByID'); const o = { groupIDList: [e] }; const a = new Da(os);return a.setMessage('groupID:'.concat(e)), Ee.log(''.concat(n, ' groupID:').concat(e)), this.request({ protocolName: Sn, requestData: o }).then(((e) => { - const o = e.data.groupProfile;if (0 !== o[0].errorCode) throw new hr({ code: o[0].errorCode, message: o[0].errorInfo });return a.setNetworkType(t.getNetworkType()).end(), Ee.log(''.concat(n, ' ok')), cr({ group: new Gr(o[0]) }); - })) - .catch((e => (t.probeNetwork().then(((t) => { - const n = m(t, 2); const o = n[0]; const s = n[1];a.setError(e, o, s).end(); - })), Ee.warn(''.concat(n, ' failed. error:'), e), Mr(e)))); - } }, { key: 'changeGroupOwner', value(e) { - const t = this; const n = ''.concat(this._className, '.changeGroupOwner');if (this.hasLocalGroup(e.groupID) && this.getLocalGroupProfile(e.groupID).type === k.GRP_AVCHATROOM) return Mr(new hr({ code: Zn.CANNOT_CHANGE_OWNER_IN_AVCHATROOM, message: Uo }));if (e.newOwnerID === this.getMyUserID()) return Mr(new hr({ code: Zn.CANNOT_CHANGE_OWNER_TO_SELF, message: Fo }));const o = new Da(as);return o.setMessage('groupID:'.concat(e.groupID, ' newOwnerID:').concat(e.newOwnerID)), Ee.log(''.concat(n, ' groupID:').concat(e.groupID)), this.request({ protocolName: En, requestData: e }).then((() => { - o.setNetworkType(t.getNetworkType()).end(), Ee.log(''.concat(n, ' ok'));const a = e.groupID; const s = e.newOwnerID;t.groupMap.get(a).ownerID = s;const r = t.getModule(Lt).getLocalGroupMemberList(a);if (r instanceof Map) { - const i = r.get(t.getMyUserID());Ge(i) || (i.updateRole('Member'), t.groupMap.get(a).selfInfo.role = 'Member');const c = r.get(s);Ge(c) || c.updateRole('Owner'); - } return t.emitGroupListUpdate(!0, !1), cr({ group: t.groupMap.get(a) }); - })) - .catch((e => (t.probeNetwork().then(((t) => { - const n = m(t, 2); const a = n[0]; const s = n[1];o.setError(e, a, s).end(); - })), Ee.error(''.concat(n, ' failed. error:'), e), Mr(e)))); - } }, { key: 'handleGroupApplication', value(e) { - const n = this; const o = ''.concat(this._className, '.handleGroupApplication'); const a = e.message.payload; const s = a.groupProfile.groupID; const r = a.authentication; const i = a.messageKey; const c = a.operatorID; const u = new Da(ss);return u.setMessage('groupID:'.concat(s)), Ee.log(''.concat(o, ' groupID:').concat(s)), this.request({ protocolName: kn, requestData: t(t({}, e), {}, { applicant: c, groupID: s, authentication: r, messageKey: i }) }).then((() => (u.setNetworkType(n.getNetworkType()).end(), Ee.log(''.concat(o, ' ok')), n._groupSystemNoticeHandler.deleteGroupSystemNotice({ messageList: [e.message] }), cr({ group: n.getLocalGroupProfile(s) })))) - .catch((e => (n.probeNetwork().then(((t) => { - const n = m(t, 2); const o = n[0]; const a = n[1];u.setError(e, o, a).end(); - })), Ee.error(''.concat(o, ' failed. error'), e), Mr(e)))); - } }, { key: 'handleGroupInvitation', value(e) { - const n = this; const o = ''.concat(this._className, '.handleGroupInvitation'); const a = e.message.payload; const s = a.groupProfile.groupID; const r = a.authentication; const i = a.messageKey; const c = a.operatorID; const u = e.handleAction; const l = new Da(rs);return l.setMessage('groupID:'.concat(s, ' inviter:').concat(c, ' handleAction:') - .concat(u)), Ee.log(''.concat(o, ' groupID:').concat(s, ' inviter:') - .concat(c, ' handleAction:') - .concat(u)), this.request({ protocolName: Cn, requestData: t(t({}, e), {}, { inviter: c, groupID: s, authentication: r, messageKey: i }) }).then((() => (l.setNetworkType(n.getNetworkType()).end(), Ee.log(''.concat(o, ' ok')), n._groupSystemNoticeHandler.deleteGroupSystemNotice({ messageList: [e.message] }), cr({ group: n.getLocalGroupProfile(s) })))) - .catch((e => (n.probeNetwork().then(((t) => { - const n = m(t, 2); const o = n[0]; const a = n[1];l.setError(e, o, a).end(); - })), Ee.error(''.concat(o, ' failed. error'), e), Mr(e)))); - } }, { key: 'getGroupOnlineMemberCount', value(e) { - return this._AVChatRoomHandler ? this._AVChatRoomHandler.checkJoinedAVChatRoomByID(e) ? this._AVChatRoomHandler.getGroupOnlineMemberCount(e) : mr({ memberCount: 0 }) : Mr({ code: Zn.CANNOT_FIND_MODULE, message: ra }); - } }, { key: 'hasLocalGroup', value(e) { - return this.groupMap.has(e); - } }, { key: 'deleteLocalGroupAndConversation', value(e) { - this._deleteLocalGroup(e), this.getModule(Rt).deleteLocalConversation('GROUP'.concat(e)), this.emitGroupListUpdate(!0, !1); - } }, { key: '_deleteLocalGroup', value(e) { - this.groupMap.delete(e), this.getModule(Lt).deleteGroupMemberList(e), this._setStorageGroupList(); - } }, { key: 'sendMessage', value(e, t) { - const n = this.createGroupMessagePack(e, t);return this.request(n); - } }, { key: 'createGroupMessagePack', value(e, t) { - let n = null;t && t.offlinePushInfo && (n = t.offlinePushInfo);let o = '';Ae(e.cloudCustomData) && e.cloudCustomData.length > 0 && (o = e.cloudCustomData);const a = e.getGroupAtInfoList();return { protocolName: en, tjgID: this.generateTjgID(e), requestData: { fromAccount: this.getMyUserID(), groupID: e.to, msgBody: e.getElements(), cloudCustomData: o, random: e.random, priority: e.priority, clientSequence: e.clientSequence, groupAtInfo: e.type !== k.MSG_TEXT || dt(a) ? void 0 : a, onlineOnlyFlag: this.isOnlineMessage(e, t) ? 1 : 0, offlinePushInfo: n ? { pushFlag: !0 === n.disablePush ? 1 : 0, title: n.title || '', desc: n.description || '', ext: n.extension || '', apnsInfo: { badgeMode: !0 === n.ignoreIOSBadge ? 1 : 0 }, androidInfo: { OPPOChannelID: n.androidOPPOChannelID || '' } } : void 0 } }; - } }, { key: 'revokeMessage', value(e) { - return this.request({ protocolName: Nn, requestData: { to: e.to, msgSeqList: [{ msgSeq: e.sequence }] } }); - } }, { key: 'deleteMessage', value(e) { - const t = e.to; const n = e.keyList;return Ee.log(''.concat(this._className, '.deleteMessage groupID:').concat(t, ' count:') - .concat(n.length)), this.request({ protocolName: bn, requestData: { groupID: t, deleter: this.getMyUserID(), keyList: n } }); - } }, { key: 'getRoamingMessage', value(e) { - const t = this; const n = ''.concat(this._className, '.getRoamingMessage'); const o = new Da(Fa); let a = 0;return this._computeLastSequence(e).then((n => (a = n, Ee.log(''.concat(t._className, '.getRoamingMessage groupID:').concat(e.groupID, ' lastSequence:') - .concat(a)), t.request({ protocolName: On, requestData: { groupID: e.groupID, count: 21, sequence: a } })))) - .then(((s) => { - const r = s.data; const i = r.messageList; const c = r.complete;Ge(i) ? Ee.log(''.concat(n, ' ok. complete:').concat(c, ' but messageList is undefined!')) : Ee.log(''.concat(n, ' ok. complete:').concat(c, ' count:') - .concat(i.length)), o.setNetworkType(t.getNetworkType()).setMessage('groupID:'.concat(e.groupID, ' lastSequence:').concat(a, ' complete:') - .concat(c, ' count:') - .concat(i ? i.length : 'undefined')) - .end();const u = 'GROUP'.concat(e.groupID); const l = t.getModule(Rt);if (2 === c || dt(i)) return l.setCompleted(u), [];const d = l.storeRoamingMessage(i, u);return l.updateIsRead(u), l.patchConversationLastMessage(u), d; - })) - .catch((s => (t.probeNetwork().then(((t) => { - const n = m(t, 2); const r = n[0]; const i = n[1];o.setError(s, r, i).setMessage('groupID:'.concat(e.groupID, ' lastSequence:').concat(a)) - .end(); - })), Ee.warn(''.concat(n, ' failed. error:'), s), Mr(s)))); - } }, { key: 'setMessageRead', value(e) { - const t = this; const n = e.conversationID; const o = e.lastMessageSeq; const a = ''.concat(this._className, '.setMessageRead');Ee.log(''.concat(a, ' conversationID:').concat(n, ' lastMessageSeq:') - .concat(o)), Ne(o) || Ee.warn(''.concat(a, ' 请勿修改 Conversation.lastMessage.lastSequence,否则可能会导致已读上报结果不准确'));const s = new Da(xa);return s.setMessage(''.concat(n, '-').concat(o)), this.request({ protocolName: An, requestData: { groupID: n.replace('GROUP', ''), messageReadSeq: o } }).then((() => { - s.setNetworkType(t.getNetworkType()).end(), Ee.log(''.concat(a, ' ok.'));const e = t.getModule(Rt);return e.updateIsReadAfterReadReport({ conversationID: n, lastMessageSeq: o }), e.updateUnreadCount(n), cr(); - })) - .catch((e => (t.probeNetwork().then(((t) => { - const n = m(t, 2); const o = n[0]; const a = n[1];s.setError(e, o, a).end(); - })), Ee.log(''.concat(a, ' failed. error:'), e), Mr(e)))); - } }, { key: '_computeLastSequence', value(e) { - return e.sequence > 0 ? Promise.resolve(e.sequence) : this.getGroupLastSequence(e.groupID); - } }, { key: 'getGroupLastSequence', value(e) { - const t = this; const n = ''.concat(this._className, '.getGroupLastSequence'); const o = new Da(ps); let a = 0; let s = '';if (this.hasLocalGroup(e)) { - const r = this.getLocalGroupProfile(e); const i = r.lastMessage;if (i.lastSequence > 0 && !1 === i.onlineOnlyFlag) return a = i.lastSequence, s = 'got lastSequence:'.concat(a, ' from local group profile[lastMessage.lastSequence]. groupID:').concat(e), Ee.log(''.concat(n, ' ').concat(s)), o.setNetworkType(this.getNetworkType()).setMessage(''.concat(s)) - .end(), Promise.resolve(a);if (r.nextMessageSeq > 1) return a = r.nextMessageSeq - 1, s = 'got lastSequence:'.concat(a, ' from local group profile[nextMessageSeq]. groupID:').concat(e), Ee.log(''.concat(n, ' ').concat(s)), o.setNetworkType(this.getNetworkType()).setMessage(''.concat(s)) - .end(), Promise.resolve(a); - } const c = 'GROUP'.concat(e); const u = this.getModule(Rt).getLocalConversation(c);if (u && u.lastMessage.lastSequence && !1 === u.lastMessage.onlineOnlyFlag) return a = u.lastMessage.lastSequence, s = 'got lastSequence:'.concat(a, ' from local conversation profile[lastMessage.lastSequence]. groupID:').concat(e), Ee.log(''.concat(n, ' ').concat(s)), o.setNetworkType(this.getNetworkType()).setMessage(''.concat(s)) - .end(), Promise.resolve(a);const l = { groupIDList: [e], responseFilter: { groupBaseInfoFilter: ['NextMsgSeq'] } };return this.getGroupProfileAdvance(l).then(((r) => { - const i = r.data.successGroupList;return dt(i) ? Ee.log(''.concat(n, ' successGroupList is empty. groupID:').concat(e)) : (a = i[0].nextMessageSeq - 1, s = 'got lastSequence:'.concat(a, ' from getGroupProfileAdvance. groupID:').concat(e), Ee.log(''.concat(n, ' ').concat(s))), o.setNetworkType(t.getNetworkType()).setMessage(''.concat(s)) - .end(), a; - })) - .catch((a => (t.probeNetwork().then(((t) => { - const n = m(t, 2); const s = n[0]; const r = n[1];o.setError(a, s, r).setMessage('get lastSequence failed from getGroupProfileAdvance. groupID:'.concat(e)) - .end(); - })), Ee.warn(''.concat(n, ' failed. error:'), a), Mr(a)))); - } }, { key: 'isMessageFromAVChatroom', value(e) { - return !!this._AVChatRoomHandler && this._AVChatRoomHandler.checkJoinedAVChatRoomByID(e); - } }, { key: 'hasJoinedAVChatRoom', value() { - return this._AVChatRoomHandler ? this._AVChatRoomHandler.hasJoinedAVChatRoom() : 0; - } }, { key: 'getJoinedAVChatRoom', value() { - return this._AVChatRoomHandler ? this._AVChatRoomHandler.getJoinedAVChatRoom() : []; - } }, { key: 'isOnlineMessage', value(e, t) { - return !(!this._canIUseOnlineOnlyFlag(e) || !t || !0 !== t.onlineUserOnly); - } }, { key: '_canIUseOnlineOnlyFlag', value(e) { - const t = this.getJoinedAVChatRoom();return !t || !t.includes(e.to) || e.conversationType !== k.CONV_GROUP; - } }, { key: 'deleteLocalGroupMembers', value(e, t) { - this.getModule(Lt).deleteLocalGroupMembers(e, t); - } }, { key: 'onAVChatRoomMessage', value(e) { - this._AVChatRoomHandler && this._AVChatRoomHandler.onMessage(e); - } }, { key: 'getGroupSimplifiedInfo', value(e) { - const t = this; const n = new Da(fs); const o = { groupIDList: [e], responseFilter: { groupBaseInfoFilter: ['Type', 'Name'] } };return this.getGroupProfileAdvance(o).then(((o) => { - const a = o.data.successGroupList;return n.setNetworkType(t.getNetworkType()).setMessage('groupID:'.concat(e, ' type:').concat(a[0].type)) - .end(), a[0]; - })) - .catch(((o) => { - t.probeNetwork().then(((t) => { - const a = m(t, 2); const s = a[0]; const r = a[1];n.setError(o, s, r).setMessage('groupID:'.concat(e)) - .end(); - })); - })); - } }, { key: 'setUnjoinedAVChatRoom', value(e) { - this._unjoinedAVChatRoomList.set(e, 1); - } }, { key: 'deleteUnjoinedAVChatRoom', value(e) { - this._unjoinedAVChatRoomList.has(e) && this._unjoinedAVChatRoomList.delete(e); - } }, { key: 'isUnjoinedAVChatRoom', value(e) { - return this._unjoinedAVChatRoomList.has(e); - } }, { key: 'reset', value() { - this.groupMap.clear(), this._unjoinedAVChatRoomList.clear(), this._commonGroupHandler.reset(), this._groupSystemNoticeHandler.reset(), this._groupTipsHandler.reset(), this._AVChatRoomHandler && this._AVChatRoomHandler.reset(); - } }]), a; - }(Yt)); const Yr = (function () { - function e(t) { - o(this, e), this.userID = '', this.avatar = '', this.nick = '', this.role = '', this.joinTime = '', this.lastSendMsgTime = '', this.nameCard = '', this.muteUntil = 0, this.memberCustomField = [], this._initMember(t); - } return s(e, [{ key: '_initMember', value(e) { - this.updateMember(e); - } }, { key: 'updateMember', value(e) { - const t = [null, void 0, '', 0, NaN];e.memberCustomField && Qe(this.memberCustomField, e.memberCustomField), Ke(this, e, ['memberCustomField'], t); - } }, { key: 'updateRole', value(e) { - ['Owner', 'Admin', 'Member'].indexOf(e) < 0 || (this.role = e); - } }, { key: 'updateMuteUntil', value(e) { - Ge(e) || (this.muteUntil = Math.floor((Date.now() + 1e3 * e) / 1e3)); - } }, { key: 'updateNameCard', value(e) { - Ge(e) || (this.nameCard = e); - } }, { key: 'updateMemberCustomField', value(e) { - e && Qe(this.memberCustomField, e); - } }]), e; - }()); const zr = (function (e) { - i(a, e);const n = f(a);function a(e) { - let t;return o(this, a), (t = n.call(this, e))._className = 'GroupMemberModule', t.groupMemberListMap = new Map, t.getInnerEmitterInstance().on(Ir.PROFILE_UPDATED, t._onProfileUpdated, h(t)), t; - } return s(a, [{ key: '_onProfileUpdated', value(e) { - for (var t = this, n = e.data, o = function (e) { - const o = n[e];t.groupMemberListMap.forEach(((e) => { - e.has(o.userID) && e.get(o.userID).updateMember({ nick: o.nick, avatar: o.avatar }); - })); - }, a = 0;a < n.length;a++)o(a); - } }, { key: 'deleteGroupMemberList', value(e) { - this.groupMemberListMap.delete(e); - } }, { key: 'getGroupMemberList', value(e) { - const t = this; const n = e.groupID; const o = e.offset; const a = void 0 === o ? 0 : o; const s = e.count; const r = void 0 === s ? 15 : s; const i = ''.concat(this._className, '.getGroupMemberList'); const c = new Da(Ms);Ee.log(''.concat(i, ' groupID:').concat(n, ' offset:') - .concat(a, ' count:') - .concat(r));let u = [];return this.request({ protocolName: Un, requestData: { groupID: n, offset: a, limit: r > 100 ? 100 : r } }).then(((e) => { - const o = e.data; const a = o.members; const s = o.memberNum;if (!Re(a) || 0 === a.length) return Promise.resolve([]);const r = t.getModule(At);return r.hasLocalGroup(n) && (r.getLocalGroupProfile(n).memberNum = s), u = t._updateLocalGroupMemberMap(n, a), t.getModule(Ct).getUserProfile({ userIDList: a.map((e => e.userID)), tagList: [Ks.NICK, Ks.AVATAR] }); - })) - .then(((e) => { - const o = e.data;if (!Re(o) || 0 === o.length) return mr({ memberList: [] });const s = o.map((e => ({ userID: e.userID, nick: e.nick, avatar: e.avatar })));return t._updateLocalGroupMemberMap(n, s), c.setNetworkType(t.getNetworkType()).setMessage('groupID:'.concat(n, ' offset:').concat(a, ' count:') - .concat(r)) - .end(), Ee.log(''.concat(i, ' ok.')), cr({ memberList: u }); - })) - .catch((e => (t.probeNetwork().then(((t) => { - const n = m(t, 2); const o = n[0]; const a = n[1];c.setError(e, o, a).end(); - })), Ee.error(''.concat(i, ' failed. error:'), e), Mr(e)))); - } }, { key: 'getGroupMemberProfile', value(e) { - const n = this; const o = ''.concat(this._className, '.getGroupMemberProfile'); const a = new Da(vs);a.setMessage(e.userIDList.length > 5 ? 'userIDList.length:'.concat(e.userIDList.length) : 'userIDList:'.concat(e.userIDList)), Ee.log(''.concat(o, ' groupID:').concat(e.groupID, ' userIDList:') - .concat(e.userIDList.join(','))), e.userIDList.length > 50 && (e.userIDList = e.userIDList.slice(0, 50));const s = e.groupID; const r = e.userIDList;return this._getGroupMemberProfileAdvance(t(t({}, e), {}, { userIDList: r })).then(((e) => { - const t = e.data.members;return Re(t) && 0 !== t.length ? (n._updateLocalGroupMemberMap(s, t), n.getModule(Ct).getUserProfile({ userIDList: t.map((e => e.userID)), tagList: [Ks.NICK, Ks.AVATAR] })) : mr([]); - })) - .then(((e) => { - const t = e.data.map((e => ({ userID: e.userID, nick: e.nick, avatar: e.avatar })));n._updateLocalGroupMemberMap(s, t);const o = r.filter((e => n.hasLocalGroupMember(s, e))).map((e => n.getLocalGroupMemberInfo(s, e)));return a.setNetworkType(n.getNetworkType()).end(), cr({ memberList: o }); - })); - } }, { key: 'addGroupMember', value(e) { - const t = this; const n = ''.concat(this._className, '.addGroupMember'); const o = e.groupID; const a = this.getModule(At).getLocalGroupProfile(o); const s = a.type; const r = new Da(ys);if (r.setMessage('groupID:'.concat(o, ' groupType:').concat(s)), et(s)) { - const i = new hr({ code: Zn.CANNOT_ADD_MEMBER_IN_AVCHATROOM, message: xo });return r.setCode(Zn.CANNOT_ADD_MEMBER_IN_AVCHATROOM).setError(xo) - .setNetworkType(this.getNetworkType()) - .end(), Mr(i); - } return e.userIDList = e.userIDList.map((e => ({ userID: e }))), Ee.log(''.concat(n, ' groupID:').concat(o)), this.request({ protocolName: qn, requestData: e }).then(((o) => { - const s = o.data.members;Ee.log(''.concat(n, ' ok'));const i = s.filter((e => 1 === e.result)).map((e => e.userID)); const c = s.filter((e => 0 === e.result)).map((e => e.userID)); const u = s.filter((e => 2 === e.result)).map((e => e.userID)); const l = s.filter((e => 4 === e.result)).map((e => e.userID)); const d = 'groupID:'.concat(e.groupID, ', ') + 'successUserIDList:'.concat(i, ', ') + 'failureUserIDList:'.concat(c, ', ') + 'existedUserIDList:'.concat(u, ', ') + 'overLimitUserIDList:'.concat(l);return r.setNetworkType(t.getNetworkType()).setMoreMessage(d) - .end(), 0 === i.length ? cr({ successUserIDList: i, failureUserIDList: c, existedUserIDList: u, overLimitUserIDList: l }) : (a.memberNum += i.length, cr({ successUserIDList: i, failureUserIDList: c, existedUserIDList: u, overLimitUserIDList: l, group: a })); - })) - .catch((e => (t.probeNetwork().then(((t) => { - const n = m(t, 2); const o = n[0]; const a = n[1];r.setError(e, o, a).end(); - })), Ee.error(''.concat(n, ' failed. error:'), e), Mr(e)))); - } }, { key: 'deleteGroupMember', value(e) { - const t = this; const n = ''.concat(this._className, '.deleteGroupMember'); const o = e.groupID; const a = e.userIDList; const s = new Da(Is); const r = 'groupID:'.concat(o, ' ').concat(a.length > 5 ? 'userIDList.length:'.concat(a.length) : 'userIDList:'.concat(a));s.setMessage(r), Ee.log(''.concat(n, ' groupID:').concat(o, ' userIDList:'), a);const i = this.getModule(At).getLocalGroupProfile(o);return et(i.type) ? Mr(new hr({ code: Zn.CANNOT_KICK_MEMBER_IN_AVCHATROOM, message: Ho })) : this.request({ protocolName: Vn, requestData: e }).then((() => (s.setNetworkType(t.getNetworkType()).end(), Ee.log(''.concat(n, ' ok')), i.memberNum--, t.deleteLocalGroupMembers(o, a), cr({ group: i, userIDList: a })))) - .catch((e => (t.probeNetwork().then(((t) => { - const n = m(t, 2); const o = n[0]; const a = n[1];s.setError(e, o, a).end(); - })), Ee.error(''.concat(n, ' failed. error:'), e), Mr(e)))); - } }, { key: 'setGroupMemberMuteTime', value(e) { - const t = this; const n = e.groupID; const o = e.userID; const a = e.muteTime; const s = ''.concat(this._className, '.setGroupMemberMuteTime');if (o === this.getMyUserID()) return Mr(new hr({ code: Zn.CANNOT_MUTE_SELF, message: Wo }));Ee.log(''.concat(s, ' groupID:').concat(n, ' userID:') - .concat(o));const r = new Da(Ds);return r.setMessage('groupID:'.concat(n, ' userID:').concat(o, ' muteTime:') - .concat(a)), this._modifyGroupMemberInfo({ groupID: n, userID: o, muteTime: a }).then(((e) => { - r.setNetworkType(t.getNetworkType()).end(), Ee.log(''.concat(s, ' ok'));const o = t.getModule(At);return cr({ group: o.getLocalGroupProfile(n), member: e }); - })) - .catch((e => (t.probeNetwork().then(((t) => { - const n = m(t, 2); const o = n[0]; const a = n[1];r.setError(e, o, a).end(); - })), Ee.error(''.concat(s, ' failed. error:'), e), Mr(e)))); - } }, { key: 'setGroupMemberRole', value(e) { - const t = this; const n = ''.concat(this._className, '.setGroupMemberRole'); const o = e.groupID; const a = e.userID; const s = e.role; const r = this.getModule(At).getLocalGroupProfile(o);if (r.selfInfo.role !== k.GRP_MBR_ROLE_OWNER) return Mr(new hr({ code: Zn.NOT_OWNER, message: jo }));if ([k.GRP_WORK, k.GRP_AVCHATROOM].includes(r.type)) return Mr(new hr({ code: Zn.CANNOT_SET_MEMBER_ROLE_IN_WORK_AND_AVCHATROOM, message: $o }));if ([k.GRP_MBR_ROLE_ADMIN, k.GRP_MBR_ROLE_MEMBER].indexOf(s) < 0) return Mr(new hr({ code: Zn.INVALID_MEMBER_ROLE, message: Yo }));if (a === this.getMyUserID()) return Mr(new hr({ code: Zn.CANNOT_SET_SELF_MEMBER_ROLE, message: zo }));const i = new Da(Ss);return i.setMessage('groupID:'.concat(o, ' userID:').concat(a, ' role:') - .concat(s)), Ee.log(''.concat(n, ' groupID:').concat(o, ' userID:') - .concat(a)), this._modifyGroupMemberInfo({ groupID: o, userID: a, role: s }).then((e => (i.setNetworkType(t.getNetworkType()).end(), Ee.log(''.concat(n, ' ok')), cr({ group: r, member: e })))) - .catch((e => (t.probeNetwork().then(((t) => { - const n = m(t, 2); const o = n[0]; const a = n[1];i.setError(e, o, a).end(); - })), Ee.error(''.concat(n, ' failed. error:'), e), Mr(e)))); - } }, { key: 'setGroupMemberNameCard', value(e) { - const t = this; const n = ''.concat(this._className, '.setGroupMemberNameCard'); const o = e.groupID; const a = e.userID; const s = void 0 === a ? this.getMyUserID() : a; const r = e.nameCard;Ee.log(''.concat(n, ' groupID:').concat(o, ' userID:') - .concat(s));const i = new Da(Ts);return i.setMessage('groupID:'.concat(o, ' userID:').concat(s, ' nameCard:') - .concat(r)), this._modifyGroupMemberInfo({ groupID: o, userID: s, nameCard: r }).then(((e) => { - Ee.log(''.concat(n, ' ok')), i.setNetworkType(t.getNetworkType()).end();const a = t.getModule(At).getLocalGroupProfile(o);return s === t.getMyUserID() && a && a.setSelfNameCard(r), cr({ group: a, member: e }); - })) - .catch((e => (t.probeNetwork().then(((t) => { - const n = m(t, 2); const o = n[0]; const a = n[1];i.setError(e, o, a).end(); - })), Ee.error(''.concat(n, ' failed. error:'), e), Mr(e)))); - } }, { key: 'setGroupMemberCustomField', value(e) { - const t = this; const n = ''.concat(this._className, '.setGroupMemberCustomField'); const o = e.groupID; const a = e.userID; const s = void 0 === a ? this.getMyUserID() : a; const r = e.memberCustomField;Ee.log(''.concat(n, ' groupID:').concat(o, ' userID:') - .concat(s));const i = new Da(Es);return i.setMessage('groupID:'.concat(o, ' userID:').concat(s, ' memberCustomField:') - .concat(JSON.stringify(r))), this._modifyGroupMemberInfo({ groupID: o, userID: s, memberCustomField: r }).then(((e) => { - i.setNetworkType(t.getNetworkType()).end(), Ee.log(''.concat(n, ' ok'));const a = t.getModule(At).getLocalGroupProfile(o);return cr({ group: a, member: e }); - })) - .catch((e => (t.probeNetwork().then(((t) => { - const n = m(t, 2); const o = n[0]; const a = n[1];i.setError(e, o, a).end(); - })), Ee.error(''.concat(n, ' failed. error:'), e), Mr(e)))); - } }, { key: 'setMessageRemindType', value(e) { - const t = this; const n = ''.concat(this._className, '.setMessageRemindType'); const o = new Da(is);o.setMessage('groupID:'.concat(e.groupID)), Ee.log(''.concat(n, ' groupID:').concat(e.groupID));const a = e.groupID; const s = e.messageRemindType;return this._modifyGroupMemberInfo({ groupID: a, messageRemindType: s, userID: this.getMyUserID() }).then((() => { - o.setNetworkType(t.getNetworkType()).end(), Ee.log(''.concat(n, ' ok. groupID:').concat(e.groupID));const a = t.getModule(At).getLocalGroupProfile(e.groupID);return a && (a.selfInfo.messageRemindType = s), cr({ group: a }); - })) - .catch((e => (t.probeNetwork().then(((t) => { - const n = m(t, 2); const a = n[0]; const s = n[1];o.setError(e, a, s).end(); - })), Ee.error(''.concat(n, ' failed. error:'), e), Mr(e)))); - } }, { key: '_modifyGroupMemberInfo', value(e) { - const t = this; const n = e.groupID; const o = e.userID;return this.request({ protocolName: Kn, requestData: e }).then((() => { - if (t.hasLocalGroupMember(n, o)) { - const a = t.getLocalGroupMemberInfo(n, o);return Ge(e.muteTime) || a.updateMuteUntil(e.muteTime), Ge(e.role) || a.updateRole(e.role), Ge(e.nameCard) || a.updateNameCard(e.nameCard), Ge(e.memberCustomField) || a.updateMemberCustomField(e.memberCustomField), a; - } return t.getGroupMemberProfile({ groupID: n, userIDList: [o] }).then((e => m(e.data.memberList, 1)[0])); - })); - } }, { key: '_getGroupMemberProfileAdvance', value(e) { - return this.request({ protocolName: Fn, requestData: t(t({}, e), {}, { memberInfoFilter: e.memberInfoFilter ? e.memberInfoFilter : ['Role', 'JoinTime', 'NameCard', 'ShutUpUntil'] }) }); - } }, { key: '_updateLocalGroupMemberMap', value(e, t) { - const n = this;return Re(t) && 0 !== t.length ? t.map((t => (n.hasLocalGroupMember(e, t.userID) ? n.getLocalGroupMemberInfo(e, t.userID).updateMember(t) : n.setLocalGroupMember(e, new Yr(t)), n.getLocalGroupMemberInfo(e, t.userID)))) : []; - } }, { key: 'deleteLocalGroupMembers', value(e, t) { - const n = this.groupMemberListMap.get(e);n && t.forEach(((e) => { - n.delete(e); - })); - } }, { key: 'getLocalGroupMemberInfo', value(e, t) { - return this.groupMemberListMap.has(e) ? this.groupMemberListMap.get(e).get(t) : null; - } }, { key: 'setLocalGroupMember', value(e, t) { - if (this.groupMemberListMap.has(e)) this.groupMemberListMap.get(e).set(t.userID, t);else { - const n = (new Map).set(t.userID, t);this.groupMemberListMap.set(e, n); - } - } }, { key: 'getLocalGroupMemberList', value(e) { - return this.groupMemberListMap.get(e); - } }, { key: 'hasLocalGroupMember', value(e, t) { - return this.groupMemberListMap.has(e) && this.groupMemberListMap.get(e).has(t); - } }, { key: 'hasLocalGroupMemberMap', value(e) { - return this.groupMemberListMap.has(e); - } }, { key: 'reset', value() { - this.groupMemberListMap.clear(); - } }]), a; - }(Yt)); const Wr = (function () { - function e(t) { - o(this, e), this._userModule = t, this._className = 'ProfileHandler', this.TAG = 'profile', this.accountProfileMap = new Map, this.expirationTime = 864e5; - } return s(e, [{ key: 'setExpirationTime', value(e) { - this.expirationTime = e; - } }, { key: 'getUserProfile', value(e) { - const t = this; const n = e.userIDList;e.fromAccount = this._userModule.getMyAccount(), n.length > 100 && (Ee.warn(''.concat(this._className, '.getUserProfile 获取用户资料人数不能超过100人')), n.length = 100);for (var o, a = [], s = [], r = 0, i = n.length;r < i;r++)o = n[r], this._userModule.isMyFriend(o) && this._containsAccount(o) ? s.push(this._getProfileFromMap(o)) : a.push(o);if (0 === a.length) return mr(s);e.toAccount = a;const c = e.bFromGetMyProfile || !1; const u = [];e.toAccount.forEach(((e) => { - u.push({ toAccount: e, standardSequence: 0, customSequence: 0 }); - })), e.userItem = u;const l = new Da(Os);return l.setMessage(n.length > 5 ? 'userIDList.length:'.concat(n.length) : 'userIDList:'.concat(n)), this._userModule.request({ protocolName: tn, requestData: e }).then(((e) => { - l.setNetworkType(t._userModule.getNetworkType()).end(), Ee.info(''.concat(t._className, '.getUserProfile ok'));const n = t._handleResponse(e).concat(s);return cr(c ? n[0] : n); - })) - .catch((e => (t._userModule.probeNetwork().then(((t) => { - const n = m(t, 2); const o = n[0]; const a = n[1];l.setError(e, o, a).end(); - })), Ee.error(''.concat(t._className, '.getUserProfile failed. error:'), e), Mr(e)))); - } }, { key: 'getMyProfile', value() { - const e = this._userModule.getMyAccount();if (Ee.log(''.concat(this._className, '.getMyProfile myAccount:').concat(e)), this._fillMap(), this._containsAccount(e)) { - const t = this._getProfileFromMap(e);return Ee.debug(''.concat(this._className, '.getMyProfile from cache, myProfile:') + JSON.stringify(t)), mr(t); - } return this.getUserProfile({ fromAccount: e, userIDList: [e], bFromGetMyProfile: !0 }); - } }, { key: '_handleResponse', value(e) { - for (var t, n, o = Ve.now(), a = e.data.userProfileItem, s = [], r = 0, i = a.length;r < i;r++)'@TLS#NOT_FOUND' !== a[r].to && '' !== a[r].to && (t = a[r].to, n = this._updateMap(t, this._getLatestProfileFromResponse(t, a[r].profileItem)), s.push(n));return Ee.log(''.concat(this._className, '._handleResponse cost ').concat(Ve.now() - o, ' ms')), s; - } }, { key: '_getLatestProfileFromResponse', value(e, t) { - const n = {};if (n.userID = e, n.profileCustomField = [], !dt(t)) for (let o = 0, a = t.length;o < a;o++) if (t[o].tag.indexOf('Tag_Profile_Custom') > -1)n.profileCustomField.push({ key: t[o].tag, value: t[o].value });else switch (t[o].tag) { - case Ks.NICK:n.nick = t[o].value;break;case Ks.GENDER:n.gender = t[o].value;break;case Ks.BIRTHDAY:n.birthday = t[o].value;break;case Ks.LOCATION:n.location = t[o].value;break;case Ks.SELFSIGNATURE:n.selfSignature = t[o].value;break;case Ks.ALLOWTYPE:n.allowType = t[o].value;break;case Ks.LANGUAGE:n.language = t[o].value;break;case Ks.AVATAR:n.avatar = t[o].value;break;case Ks.MESSAGESETTINGS:n.messageSettings = t[o].value;break;case Ks.ADMINFORBIDTYPE:n.adminForbidType = t[o].value;break;case Ks.LEVEL:n.level = t[o].value;break;case Ks.ROLE:n.role = t[o].value;break;default:Ee.warn(''.concat(this._className, '._handleResponse unknown tag:'), t[o].tag, t[o].value); - } return n; - } }, { key: 'updateMyProfile', value(e) { - const t = this; const n = ''.concat(this._className, '.updateMyProfile'); const o = new Da(Ls);o.setMessage(JSON.stringify(e));const a = (new Ar).validate(e);if (!a.valid) return o.setCode(Zn.UPDATE_PROFILE_INVALID_PARAM).setMoreMessage(''.concat(n, ' info:').concat(a.tips)) - .setNetworkType(this._userModule.getNetworkType()) - .end(), Ee.error(''.concat(n, ' info:').concat(a.tips, ',请参考 https://web.sdk.qcloud.com/im/doc/zh-cn/SDK.html#updateMyProfile')), Mr({ code: Zn.UPDATE_PROFILE_INVALID_PARAM, message: Jo });const s = [];for (const r in e)Object.prototype.hasOwnProperty.call(e, r) && ('profileCustomField' === r ? e.profileCustomField.forEach(((e) => { - s.push({ tag: e.key, value: e.value }); - })) : s.push({ tag: Ks[r.toUpperCase()], value: e[r] }));return 0 === s.length ? (o.setCode(Zn.UPDATE_PROFILE_NO_KEY).setMoreMessage(Xo) - .setNetworkType(this._userModule.getNetworkType()) - .end(), Ee.error(''.concat(n, ' info:').concat(Xo, ',请参考 https://web.sdk.qcloud.com/im/doc/zh-cn/SDK.html#updateMyProfile')), Mr({ code: Zn.UPDATE_PROFILE_NO_KEY, message: Xo })) : this._userModule.request({ protocolName: nn, requestData: { fromAccount: this._userModule.getMyAccount(), profileItem: s } }).then(((a) => { - o.setNetworkType(t._userModule.getNetworkType()).end(), Ee.info(''.concat(n, ' ok'));const s = t._updateMap(t._userModule.getMyAccount(), e);return t._userModule.emitOuterEvent(E.PROFILE_UPDATED, [s]), mr(s); - })) - .catch((e => (t._userModule.probeNetwork().then(((t) => { - const n = m(t, 2); const a = n[0]; const s = n[1];o.setError(e, a, s).end(); - })), Ee.error(''.concat(n, ' failed. error:'), e), Mr(e)))); - } }, { key: 'onProfileModified', value(e) { - const t = e.dataList;if (!dt(t)) { - let n; let o; const a = t.length;Ee.info(''.concat(this._className, '.onProfileModified count:').concat(a));for (var s = [], r = this._userModule.getModule(Rt), i = 0;i < a;i++)n = t[i].userID, o = this._updateMap(n, this._getLatestProfileFromResponse(n, t[i].profileList)), s.push(o), n === this._userModule.getMyAccount() && r.onMyProfileModified({ latestNick: o.nick, latestAvatar: o.avatar });this._userModule.emitInnerEvent(Ir.PROFILE_UPDATED, s), this._userModule.emitOuterEvent(E.PROFILE_UPDATED, s); - } - } }, { key: '_fillMap', value() { - if (0 === this.accountProfileMap.size) { - for (let e = this._getCachedProfiles(), t = Date.now(), n = 0, o = e.length;n < o;n++)t - e[n].lastUpdatedTime < this.expirationTime && this.accountProfileMap.set(e[n].userID, e[n]);Ee.log(''.concat(this._className, '._fillMap from cache, map.size:').concat(this.accountProfileMap.size)); - } - } }, { key: '_updateMap', value(e, t) { - let n; const o = Date.now();return this._containsAccount(e) ? (n = this._getProfileFromMap(e), t.profileCustomField && Qe(n.profileCustomField, t.profileCustomField), Ke(n, t, ['profileCustomField']), n.lastUpdatedTime = o) : (n = new Ar(t), (this._userModule.isMyFriend(e) || e === this._userModule.getMyAccount()) && (n.lastUpdatedTime = o, this.accountProfileMap.set(e, n))), this._flushMap(e === this._userModule.getMyAccount()), n; - } }, { key: '_flushMap', value(e) { - const t = M(this.accountProfileMap.values()); const n = this._userModule.getStorageModule();Ee.debug(''.concat(this._className, '._flushMap length:').concat(t.length, ' flushAtOnce:') - .concat(e)), n.setItem(this.TAG, t, e); - } }, { key: '_containsAccount', value(e) { - return this.accountProfileMap.has(e); - } }, { key: '_getProfileFromMap', value(e) { - return this.accountProfileMap.get(e); - } }, { key: '_getCachedProfiles', value() { - const e = this._userModule.getStorageModule().getItem(this.TAG);return dt(e) ? [] : e; - } }, { key: 'onConversationsProfileUpdated', value(e) { - for (var t, n, o, a = [], s = 0, r = e.length;s < r;s++)n = (t = e[s]).userID, this._userModule.isMyFriend(n) || (this._containsAccount(n) ? (o = this._getProfileFromMap(n), Ke(o, t) > 0 && a.push(n)) : a.push(t.userID));0 !== a.length && (Ee.info(''.concat(this._className, '.onConversationsProfileUpdated toAccountList:').concat(a)), this.getUserProfile({ userIDList: a })); - } }, { key: 'getNickAndAvatarByUserID', value(e) { - if (this._containsAccount(e)) { - const t = this._getProfileFromMap(e);return { nick: t.nick, avatar: t.avatar }; - } return { nick: '', avatar: '' }; - } }, { key: 'reset', value() { - this._flushMap(!0), this.accountProfileMap.clear(); - } }]), e; - }()); const Jr = function e(t) { - o(this, e), dt || (this.userID = t.userID || '', this.timeStamp = t.timeStamp || 0); - }; const Xr = (function () { - function e(t) { - o(this, e), this._userModule = t, this._className = 'BlacklistHandler', this._blacklistMap = new Map, this.startIndex = 0, this.maxLimited = 100, this.currentSequence = 0; - } return s(e, [{ key: 'getLocalBlacklist', value() { - return M(this._blacklistMap.keys()); - } }, { key: 'getBlacklist', value() { - const e = this; const t = ''.concat(this._className, '.getBlacklist'); const n = { fromAccount: this._userModule.getMyAccount(), maxLimited: this.maxLimited, startIndex: 0, lastSequence: this.currentSequence }; const o = new Da(Rs);return this._userModule.request({ protocolName: on, requestData: n }).then(((n) => { - const a = n.data; const s = a.blackListItem; const r = a.currentSequence; const i = dt(s) ? 0 : s.length;o.setNetworkType(e._userModule.getNetworkType()).setMessage('blackList count:'.concat(i)) - .end(), Ee.info(''.concat(t, ' ok')), e.currentSequence = r, e._handleResponse(s, !0), e._userModule.emitOuterEvent(E.BLACKLIST_UPDATED, M(e._blacklistMap.keys())); - })) - .catch((n => (e._userModule.probeNetwork().then(((e) => { - const t = m(e, 2); const a = t[0]; const s = t[1];o.setError(n, a, s).end(); - })), Ee.error(''.concat(t, ' failed. error:'), n), Mr(n)))); - } }, { key: 'addBlacklist', value(e) { - const t = this; const n = ''.concat(this._className, '.addBlacklist'); const o = new Da(Gs);if (!Re(e.userIDList)) return o.setCode(Zn.ADD_BLACKLIST_INVALID_PARAM).setMessage(Qo) - .setNetworkType(this._userModule.getNetworkType()) - .end(), Ee.error(''.concat(n, ' options.userIDList 必需是数组')), Mr({ code: Zn.ADD_BLACKLIST_INVALID_PARAM, message: Qo });const a = this._userModule.getMyAccount();return 1 === e.userIDList.length && e.userIDList[0] === a ? (o.setCode(Zn.CANNOT_ADD_SELF_TO_BLACKLIST).setMessage(ea) - .setNetworkType(this._userModule.getNetworkType()) - .end(), Ee.error(''.concat(n, ' 不能把自己拉黑')), Mr({ code: Zn.CANNOT_ADD_SELF_TO_BLACKLIST, message: ea })) : (e.userIDList.includes(a) && (e.userIDList = e.userIDList.filter((e => e !== a)), Ee.warn(''.concat(n, ' 不能把自己拉黑,已过滤'))), e.fromAccount = this._userModule.getMyAccount(), e.toAccount = e.userIDList, this._userModule.request({ protocolName: an, requestData: e }).then((a => (o.setNetworkType(t._userModule.getNetworkType()).setMessage(e.userIDList.length > 5 ? 'userIDList.length:'.concat(e.userIDList.length) : 'userIDList:'.concat(e.userIDList)) - .end(), Ee.info(''.concat(n, ' ok')), t._handleResponse(a.resultItem, !0), cr(M(t._blacklistMap.keys()))))) - .catch((e => (t._userModule.probeNetwork().then(((t) => { - const n = m(t, 2); const a = n[0]; const s = n[1];o.setError(e, a, s).end(); - })), Ee.error(''.concat(n, ' failed. error:'), e), Mr(e))))); - } }, { key: '_handleResponse', value(e, t) { - if (!dt(e)) for (var n, o, a, s = 0, r = e.length;s < r;s++)o = e[s].to, a = e[s].resultCode, (Ge(a) || 0 === a) && (t ? ((n = this._blacklistMap.has(o) ? this._blacklistMap.get(o) : new Jr).userID = o, !dt(e[s].addBlackTimeStamp) && (n.timeStamp = e[s].addBlackTimeStamp), this._blacklistMap.set(o, n)) : this._blacklistMap.has(o) && (n = this._blacklistMap.get(o), this._blacklistMap.delete(o)));Ee.log(''.concat(this._className, '._handleResponse total:').concat(this._blacklistMap.size, ' bAdd:') - .concat(t)); - } }, { key: 'deleteBlacklist', value(e) { - const t = this; const n = ''.concat(this._className, '.deleteBlacklist'); const o = new Da(ws);return Re(e.userIDList) ? (e.fromAccount = this._userModule.getMyAccount(), e.toAccount = e.userIDList, this._userModule.request({ protocolName: sn, requestData: e }).then((a => (o.setNetworkType(t._userModule.getNetworkType()).setMessage(e.userIDList.length > 5 ? 'userIDList.length:'.concat(e.userIDList.length) : 'userIDList:'.concat(e.userIDList)) - .end(), Ee.info(''.concat(n, ' ok')), t._handleResponse(a.data.resultItem, !1), cr(M(t._blacklistMap.keys()))))) - .catch((e => (t._userModule.probeNetwork().then(((t) => { - const n = m(t, 2); const a = n[0]; const s = n[1];o.setError(e, a, s).end(); - })), Ee.error(''.concat(n, ' failed. error:'), e), Mr(e))))) : (o.setCode(Zn.DEL_BLACKLIST_INVALID_PARAM).setMessage(Zo) - .setNetworkType(this._userModule.getNetworkType()) - .end(), Ee.error(''.concat(n, ' options.userIDList 必需是数组')), Mr({ code: Zn.DEL_BLACKLIST_INVALID_PARAM, message: Zo })); - } }, { key: 'onAccountDeleted', value(e) { - for (var t, n = [], o = 0, a = e.length;o < a;o++)t = e[o], this._blacklistMap.has(t) && (this._blacklistMap.delete(t), n.push(t));n.length > 0 && (Ee.log(''.concat(this._className, '.onAccountDeleted count:').concat(n.length, ' userIDList:'), n), this._userModule.emitOuterEvent(E.BLACKLIST_UPDATED, M(this._blacklistMap.keys()))); - } }, { key: 'onAccountAdded', value(e) { - for (var t, n = [], o = 0, a = e.length;o < a;o++)t = e[o], this._blacklistMap.has(t) || (this._blacklistMap.set(t, new Jr({ userID: t })), n.push(t));n.length > 0 && (Ee.log(''.concat(this._className, '.onAccountAdded count:').concat(n.length, ' userIDList:'), n), this._userModule.emitOuterEvent(E.BLACKLIST_UPDATED, M(this._blacklistMap.keys()))); - } }, { key: 'reset', value() { - this._blacklistMap.clear(), this.startIndex = 0, this.maxLimited = 100, this.currentSequence = 0; - } }]), e; - }()); const Qr = (function (e) { - i(n, e);const t = f(n);function n(e) { - let a;return o(this, n), (a = t.call(this, e))._className = 'UserModule', a._profileHandler = new Wr(h(a)), a._blacklistHandler = new Xr(h(a)), a.getInnerEmitterInstance().on(Ir.CONTEXT_A2KEY_AND_TINYID_UPDATED, a.onContextUpdated, h(a)), a; - } return s(n, [{ key: 'onContextUpdated', value(e) { - this._profileHandler.getMyProfile(), this._blacklistHandler.getBlacklist(); - } }, { key: 'onProfileModified', value(e) { - this._profileHandler.onProfileModified(e); - } }, { key: 'onRelationChainModified', value(e) { - const t = e.dataList;if (!dt(t)) { - const n = [];t.forEach(((e) => { - e.blackListDelAccount && n.push.apply(n, M(e.blackListDelAccount)); - })), n.length > 0 && this._blacklistHandler.onAccountDeleted(n);const o = [];t.forEach(((e) => { - e.blackListAddAccount && o.push.apply(o, M(e.blackListAddAccount)); - })), o.length > 0 && this._blacklistHandler.onAccountAdded(o); - } - } }, { key: 'onConversationsProfileUpdated', value(e) { - this._profileHandler.onConversationsProfileUpdated(e); - } }, { key: 'getMyAccount', value() { - return this.getMyUserID(); - } }, { key: 'getMyProfile', value() { - return this._profileHandler.getMyProfile(); - } }, { key: 'getStorageModule', value() { - return this.getModule(wt); - } }, { key: 'isMyFriend', value(e) { - const t = this.getModule(Ot);return !!t && t.isMyFriend(e); - } }, { key: 'getUserProfile', value(e) { - return this._profileHandler.getUserProfile(e); - } }, { key: 'updateMyProfile', value(e) { - return this._profileHandler.updateMyProfile(e); - } }, { key: 'getNickAndAvatarByUserID', value(e) { - return this._profileHandler.getNickAndAvatarByUserID(e); - } }, { key: 'getLocalBlacklist', value() { - const e = this._blacklistHandler.getLocalBlacklist();return mr(e); - } }, { key: 'addBlacklist', value(e) { - return this._blacklistHandler.addBlacklist(e); - } }, { key: 'deleteBlacklist', value(e) { - return this._blacklistHandler.deleteBlacklist(e); - } }, { key: 'reset', value() { - Ee.log(''.concat(this._className, '.reset')), this._profileHandler.reset(), this._blacklistHandler.reset(); - } }]), n; - }(Yt)); const Zr = (function () { - function e(t, n) { - o(this, e), this._moduleManager = t, this._isLoggedIn = !1, this._SDKAppID = n.SDKAppID, this._userID = n.userID || '', this._userSig = n.userSig || '', this._version = '2.12.2', this._a2Key = '', this._tinyID = '', this._contentType = 'json', this._unlimitedAVChatRoom = n.unlimitedAVChatRoom, this._scene = n.scene, this._oversea = n.oversea, this._instanceID = n.instanceID, this._statusInstanceID = 0; - } return s(e, [{ key: 'isLoggedIn', value() { - return this._isLoggedIn; - } }, { key: 'isOversea', value() { - return this._oversea; - } }, { key: 'isUnlimitedAVChatRoom', value() { - return this._unlimitedAVChatRoom; - } }, { key: 'getUserID', value() { - return this._userID; - } }, { key: 'setUserID', value(e) { - this._userID = e; - } }, { key: 'setUserSig', value(e) { - this._userSig = e; - } }, { key: 'getUserSig', value() { - return this._userSig; - } }, { key: 'getSDKAppID', value() { - return this._SDKAppID; - } }, { key: 'getTinyID', value() { - return this._tinyID; - } }, { key: 'setTinyID', value(e) { - this._tinyID = e, this._isLoggedIn = !0; - } }, { key: 'getScene', value() { - return this._scene; - } }, { key: 'getInstanceID', value() { - return this._instanceID; - } }, { key: 'getStatusInstanceID', value() { - return this._statusInstanceID; - } }, { key: 'setStatusInstanceID', value(e) { - this._statusInstanceID = e; - } }, { key: 'getVersion', value() { - return this._version; - } }, { key: 'getA2Key', value() { - return this._a2Key; - } }, { key: 'setA2Key', value(e) { - this._a2Key = e; - } }, { key: 'getContentType', value() { - return this._contentType; - } }, { key: 'reset', value() { - this._isLoggedIn = !1, this._userSig = '', this._a2Key = '', this._tinyID = '', this._statusInstanceID = 0; - } }]), e; - }()); const ei = (function (e) { - i(n, e);const t = f(n);function n(e) { - let a;return o(this, n), (a = t.call(this, e))._className = 'SignModule', a._helloInterval = 120, Dr.mixin(h(a)), a; - } return s(n, [{ key: 'onCheckTimer', value(e) { - this.isLoggedIn() && e % this._helloInterval == 0 && this._hello(); - } }, { key: 'login', value(e) { - if (this.isLoggedIn()) { - const t = '您已经登录账号'.concat(e.userID, '!如需切换账号登录,请先调用 logout 接口登出,再调用 login 接口登录。');return Ee.warn(t), mr({ actionStatus: 'OK', errorCode: 0, errorInfo: t, repeatLogin: !0 }); - }Ee.log(''.concat(this._className, '.login userID:').concat(e.userID));const n = this._checkLoginInfo(e);if (0 !== n.code) return Mr(n);const o = this.getModule(Gt); const a = e.userID; const s = e.userSig;return o.setUserID(a), o.setUserSig(s), this.getModule(Kt).updateProtocolConfig(), this._login(); - } }, { key: '_login', value() { - const e = this; const t = this.getModule(Gt); const n = new Da(Ea);return n.setMessage(''.concat(t.getScene())).setMoreMessage('identifier:'.concat(this.getMyUserID())), this.request({ protocolName: zt }).then(((o) => { - const a = Date.now(); let s = null; const r = o.data; const i = r.a2Key; const c = r.tinyID; const u = r.helloInterval; const l = r.instanceID; const d = r.timeStamp;Ee.log(''.concat(e._className, '.login ok. helloInterval:').concat(u, ' instanceID:') - .concat(l, ' timeStamp:') - .concat(d));const g = 1e3 * d; const p = a - n.getStartTs(); const h = g + parseInt(p / 2) - a; const _ = n.getStartTs() + h;if (n.start(_), (function (e, t) { - ve = t;const n = new Date;n.setTime(e), Ee.info('baseTime from server: '.concat(n, ' offset: ').concat(ve)); - }(g, h)), !c) throw s = new hr({ code: Zn.NO_TINYID, message: oo }), n.setError(s, !0, e.getNetworkType()).end(), s;if (!i) throw s = new hr({ code: Zn.NO_A2KEY, message: ao }), n.setError(s, !0, e.getNetworkType()).end(), s;return n.setNetworkType(e.getNetworkType()).setMoreMessage('helloInterval:'.concat(u, ' instanceID:').concat(l, ' offset:') - .concat(h)) - .end(), t.setA2Key(i), t.setTinyID(c), t.setStatusInstanceID(l), e.getModule(Kt).updateProtocolConfig(), e.emitInnerEvent(Ir.CONTEXT_A2KEY_AND_TINYID_UPDATED), e._helloInterval = u, e.triggerReady(), e._fetchCloudControlConfig(), o; - })) - .catch((t => (e.probeNetwork().then(((e) => { - const o = m(e, 2); const a = o[0]; const s = o[1];n.setError(t, a, s).end(!0); - })), Ee.error(''.concat(e._className, '.login failed. error:'), t), e._moduleManager.onLoginFailed(), Mr(t)))); - } }, { key: 'logout', value() { - const e = this;return this.isLoggedIn() ? (new Da(ka).setNetworkType(this.getNetworkType()) - .setMessage('identifier:'.concat(this.getMyUserID())) - .end(!0), Ee.info(''.concat(this._className, '.logout')), this.request({ protocolName: Wt }).then((() => (e.resetReady(), mr({})))) - .catch((t => (Ee.error(''.concat(e._className, '._logout error:'), t), e.resetReady(), mr({}))))) : Mr({ code: Zn.USER_NOT_LOGGED_IN, message: so }); - } }, { key: '_fetchCloudControlConfig', value() { - this.getModule(Ht).fetchConfig(); - } }, { key: '_hello', value() { - const e = this;this.request({ protocolName: Jt }).catch(((t) => { - Ee.warn(''.concat(e._className, '._hello error:'), t); - })); - } }, { key: '_checkLoginInfo', value(e) { - let t = 0; let n = '';return dt(this.getModule(Gt).getSDKAppID()) ? (t = Zn.NO_SDKAPPID, n = eo) : dt(e.userID) ? (t = Zn.NO_IDENTIFIER, n = to) : dt(e.userSig) && (t = Zn.NO_USERSIG, n = no), { code: t, message: n }; - } }, { key: 'onMultipleAccountKickedOut', value(e) { - const t = this;new Da(Ca).setNetworkType(this.getNetworkType()) - .setMessage('type:'.concat(k.KICKED_OUT_MULT_ACCOUNT, ' newInstanceInfo:').concat(JSON.stringify(e))) - .end(!0), Ee.warn(''.concat(this._className, '.onMultipleAccountKickedOut userID:').concat(this.getMyUserID(), ' newInstanceInfo:'), e), this.logout().then((() => { - t.emitOuterEvent(E.KICKED_OUT, { type: k.KICKED_OUT_MULT_ACCOUNT }), t._moduleManager.reset(); - })); - } }, { key: 'onMultipleDeviceKickedOut', value(e) { - const t = this;new Da(Ca).setNetworkType(this.getNetworkType()) - .setMessage('type:'.concat(k.KICKED_OUT_MULT_DEVICE, ' newInstanceInfo:').concat(JSON.stringify(e))) - .end(!0), Ee.warn(''.concat(this._className, '.onMultipleDeviceKickedOut userID:').concat(this.getMyUserID(), ' newInstanceInfo:'), e), this.logout().then((() => { - t.emitOuterEvent(E.KICKED_OUT, { type: k.KICKED_OUT_MULT_DEVICE }), t._moduleManager.reset(); - })); - } }, { key: 'onUserSigExpired', value() { - new Da(Ca).setNetworkType(this.getNetworkType()) - .setMessage(k.KICKED_OUT_USERSIG_EXPIRED) - .end(!0), Ee.warn(''.concat(this._className, '.onUserSigExpired: userSig 签名过期被踢下线')), 0 !== this.getModule(Gt).getStatusInstanceID() && (this.emitOuterEvent(E.KICKED_OUT, { type: k.KICKED_OUT_USERSIG_EXPIRED }), this._moduleManager.reset()); - } }, { key: 'reset', value() { - Ee.log(''.concat(this._className, '.reset')), this.resetReady(), this._helloInterval = 120; - } }]), n; - }(Yt));function ti() { - return null; - } const ni = (function () { - function e(t) { - o(this, e), this._moduleManager = t, this._className = 'StorageModule', this._storageQueue = new Map, this._errorTolerantHandle(); - } return s(e, [{ key: '_errorTolerantHandle', value() { - z || !Ge(window) && !Ge(window.localStorage) || (this.getItem = ti, this.setItem = ti, this.removeItem = ti, this.clear = ti); - } }, { key: 'onCheckTimer', value(e) { - if (e % 20 == 0) { - if (0 === this._storageQueue.size) return;this._doFlush(); - } - } }, { key: '_doFlush', value() { - try { - let e; const t = S(this._storageQueue);try { - for (t.s();!(e = t.n()).done;) { - const n = m(e.value, 2); const o = n[0]; const a = n[1];this._setStorageSync(this._getKey(o), a); - } - } catch (s) { - t.e(s); - } finally { - t.f(); - } this._storageQueue.clear(); - } catch (r) { - Ee.warn(''.concat(this._className, '._doFlush error:'), r); - } - } }, { key: '_getPrefix', value() { - const e = this._moduleManager.getModule(Gt);return 'TIM_'.concat(e.getSDKAppID(), '_').concat(e.getUserID(), '_'); - } }, { key: '_getKey', value(e) { - return ''.concat(this._getPrefix()).concat(e); - } }, { key: 'getItem', value(e) { - const t = !(arguments.length > 1 && void 0 !== arguments[1]) || arguments[1];try { - const n = t ? this._getKey(e) : e;return this._getStorageSync(n); - } catch (o) { - return Ee.warn(''.concat(this._className, '.getItem error:'), o), {}; - } - } }, { key: 'setItem', value(e, t) { - const n = arguments.length > 2 && void 0 !== arguments[2] && arguments[2]; const o = !(arguments.length > 3 && void 0 !== arguments[3]) || arguments[3];if (n) { - const a = o ? this._getKey(e) : e;this._setStorageSync(a, t); - } else this._storageQueue.set(e, t); - } }, { key: 'clear', value() { - try { - z ? J.clearStorageSync() : localStorage && localStorage.clear(); - } catch (e) { - Ee.warn(''.concat(this._className, '.clear error:'), e); - } - } }, { key: 'removeItem', value(e) { - const t = !(arguments.length > 1 && void 0 !== arguments[1]) || arguments[1];try { - const n = t ? this._getKey(e) : e;this._removeStorageSync(n); - } catch (o) { - Ee.warn(''.concat(this._className, '.removeItem error:'), o); - } - } }, { key: 'getSize', value(e) { - const t = this; const n = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : 'b';try { - const o = { size: 0, limitSize: 5242880, unit: n };if (Object.defineProperty(o, 'leftSize', { enumerable: !0, get() { - return o.limitSize - o.size; - } }), z && (o.limitSize = 1024 * J.getStorageInfoSync().limitSize), e)o.size = JSON.stringify(this.getItem(e)).length + this._getKey(e).length;else if (z) { - const a = J.getStorageInfoSync(); const s = a.keys;s.forEach(((e) => { - o.size += JSON.stringify(t._getStorageSync(e)).length + t._getKey(e).length; - })); - } else if (localStorage) for (const r in localStorage)localStorage.hasOwnProperty(r) && (o.size += localStorage.getItem(r).length + r.length);return this._convertUnit(o); - } catch (i) { - Ee.warn(''.concat(this._className, ' error:'), i); - } - } }, { key: '_convertUnit', value(e) { - const t = {}; const n = e.unit;for (const o in t.unit = n, e)'number' === typeof e[o] && ('kb' === n.toLowerCase() ? t[o] = Math.round(e[o] / 1024) : 'mb' === n.toLowerCase() ? t[o] = Math.round(e[o] / 1024 / 1024) : t[o] = e[o]);return t; - } }, { key: '_setStorageSync', value(e, t) { - z ? $ ? my.setStorageSync({ key: e, data: t }) : J.setStorageSync(e, t) : localStorage && localStorage.setItem(e, JSON.stringify(t)); - } }, { key: '_getStorageSync', value(e) { - return z ? $ ? my.getStorageSync({ key: e }).data : J.getStorageSync(e) : localStorage ? JSON.parse(localStorage.getItem(e)) : {}; - } }, { key: '_removeStorageSync', value(e) { - z ? $ ? my.removeStorageSync({ key: e }) : J.removeStorageSync(e) : localStorage && localStorage.removeItem(e); - } }, { key: 'reset', value() { - Ee.log(''.concat(this._className, '.reset')), this._doFlush(); - } }]), e; - }()); const oi = (function () { - function e(t) { - o(this, e), this._className = 'SSOLogBody', this._report = []; - } return s(e, [{ key: 'pushIn', value(e) { - Ee.debug(''.concat(this._className, '.pushIn'), this._report.length, e), this._report.push(e); - } }, { key: 'backfill', value(e) { - let t;Re(e) && 0 !== e.length && (Ee.debug(''.concat(this._className, '.backfill'), this._report.length, e.length), (t = this._report).unshift.apply(t, M(e))); - } }, { key: 'getLogsNumInMemory', value() { - return this._report.length; - } }, { key: 'isEmpty', value() { - return 0 === this._report.length; - } }, { key: '_reset', value() { - this._report.length = 0, this._report = []; - } }, { key: 'getLogsInMemory', value() { - const e = this._report.slice();return this._reset(), e; - } }]), e; - }()); const ai = function (e) { - const t = e.getModule(Gt);return { SDKType: 10, SDKAppID: t.getSDKAppID(), SDKVersion: t.getVersion(), tinyID: Number(t.getTinyID()), userID: t.getUserID(), platform: e.getPlatform(), instanceID: t.getInstanceID(), traceID: ye() }; - }; const si = (function (e) { - i(a, e);const n = f(a);function a(e) { - let t;o(this, a), (t = n.call(this, e))._className = 'EventStatModule', t.TAG = 'im-ssolog-event', t._reportBody = new oi, t.MIN_THRESHOLD = 20, t.MAX_THRESHOLD = 100, t.WAITING_TIME = 6e4, t.REPORT_LEVEL = [4, 5, 6], t._lastReportTime = Date.now();const s = t.getInnerEmitterInstance();return s.on(Ir.CONTEXT_A2KEY_AND_TINYID_UPDATED, t._onLoginSuccess, h(t)), s.on(Ir.CLOUD_CONFIG_UPDATED, t._onCloudConfigUpdate, h(t)), t; - } return s(a, [{ key: 'reportAtOnce', value() { - Ee.debug(''.concat(this._className, '.reportAtOnce')), this._report(); - } }, { key: '_onLoginSuccess', value() { - const e = this; const t = this.getModule(wt); const n = t.getItem(this.TAG, !1);!dt(n) && Pe(n.forEach) && (Ee.log(''.concat(this._className, '._onLoginSuccess get ssolog in storage, count:').concat(n.length)), n.forEach(((t) => { - e._reportBody.pushIn(t); - })), t.removeItem(this.TAG, !1)); - } }, { key: '_onCloudConfigUpdate', value() { - const e = this.getCloudConfig('report_threshold_event'); const t = this.getCloudConfig('report_waiting_event'); const n = this.getCloudConfig('report_level_event');Ge(e) || (this.MIN_THRESHOLD = Number(e)), Ge(t) || (this.WAITING_TIME = Number(t)), Ge(n) || (this.REPORT_LEVEL = n.split(',').map((e => Number(e)))); - } }, { key: 'pushIn', value(e) { - e instanceof Da && (e.updateTimeStamp(), this._reportBody.pushIn(e), this._reportBody.getLogsNumInMemory() >= this.MIN_THRESHOLD && this._report()); - } }, { key: 'onCheckTimer', value() { - Date.now() < this._lastReportTime + this.WAITING_TIME || this._reportBody.isEmpty() || this._report(); - } }, { key: '_filterLogs', value(e) { - const t = this;return e.filter((e => t.REPORT_LEVEL.includes(e.level))); - } }, { key: '_report', value() { - const e = this;if (!this._reportBody.isEmpty()) { - const n = this._reportBody.getLogsInMemory(); const o = this._filterLogs(n);if (0 !== o.length) { - const a = { header: ai(this), event: o };this.request({ protocolName: Hn, requestData: t({}, a) }).then((() => { - e._lastReportTime = Date.now(); - })) - .catch(((t) => { - Ee.warn(''.concat(e._className, '.report failed. networkType:').concat(e.getNetworkType(), ' error:'), t), e._reportBody.backfill(n), e._reportBody.getLogsNumInMemory() > e.MAX_THRESHOLD && e._flushAtOnce(); - })); - } else this._lastReportTime = Date.now(); - } - } }, { key: '_flushAtOnce', value() { - const e = this.getModule(wt); const t = e.getItem(this.TAG, !1); const n = this._reportBody.getLogsInMemory();if (dt(t))Ee.log(''.concat(this._className, '._flushAtOnce count:').concat(n.length)), e.setItem(this.TAG, n, !0, !1);else { - let o = n.concat(t);o.length > this.MAX_THRESHOLD && (o = o.slice(0, this.MAX_THRESHOLD)), Ee.log(''.concat(this._className, '._flushAtOnce count:').concat(o.length)), e.setItem(this.TAG, o, !0, !1); - } - } }, { key: 'reset', value() { - Ee.log(''.concat(this._className, '.reset')), this._lastReportTime = 0, this._report(); - } }]), a; - }(Yt)); const ri = 'none'; const ii = 'online'; const ci = (function () { - function e(t) { - o(this, e), this._moduleManager = t, this._networkType = '', this._className = 'NetMonitorModule', this.MAX_WAIT_TIME = 3e3; - } return s(e, [{ key: 'start', value() { - const e = this;if (z) { - J.getNetworkType({ success(t) { - e._networkType = t.networkType, t.networkType === ri ? Ee.warn(''.concat(e._className, '.start no network, please check!')) : Ee.info(''.concat(e._className, '.start networkType:').concat(t.networkType)); - } });const t = this._onNetworkStatusChange.bind(this);J.offNetworkStatusChange && (Y || H ? J.offNetworkStatusChange(t) : J.offNetworkStatusChange()), J.onNetworkStatusChange(t); - } else this._networkType = ii; - } }, { key: '_onNetworkStatusChange', value(e) { - e.isConnected ? (Ee.info(''.concat(this._className, '._onNetworkStatusChange previousNetworkType:').concat(this._networkType, ' currentNetworkType:') - .concat(e.networkType)), this._networkType !== e.networkType && this._moduleManager.getModule(xt).reConnect()) : Ee.warn(''.concat(this._className, '._onNetworkStatusChange no network, please check!'));this._networkType = e.networkType; - } }, { key: 'probe', value() { - const e = this;return new Promise(((t, n) => { - if (z)J.getNetworkType({ success(n) { - e._networkType = n.networkType, n.networkType === ri ? (Ee.warn(''.concat(e._className, '.probe no network, please check!')), t([!1, n.networkType])) : (Ee.info(''.concat(e._className, '.probe networkType:').concat(n.networkType)), t([!0, n.networkType])); - } });else if (window && window.fetch)fetch(''.concat(We(), '//web.sdk.qcloud.com/im/assets/speed.xml?random=').concat(Math.random())).then(((e) => { - e.ok ? t([!0, ii]) : t([!1, ri]); - })) - .catch(((e) => { - t([!1, ri]); - }));else { - const o = new XMLHttpRequest; const a = setTimeout((() => { - Ee.warn(''.concat(e._className, '.probe fetch timeout. Probably no network, please check!')), o.abort(), e._networkType = ri, t([!1, ri]); - }), e.MAX_WAIT_TIME);o.onreadystatechange = function () { - 4 === o.readyState && (clearTimeout(a), 200 === o.status || 304 === o.status ? (this._networkType = ii, t([!0, ii])) : (Ee.warn(''.concat(this.className, '.probe fetch status:').concat(o.status, '. Probably no network, please check!')), this._networkType = ri, t([!1, ri]))); - }, o.open('GET', ''.concat(We(), '//web.sdk.qcloud.com/im/assets/speed.xml?random=').concat(Math.random())), o.send(); - } - })); - } }, { key: 'getNetworkType', value() { - return this._networkType; - } }]), e; - }()); const ui = A(((e) => { - const t = Object.prototype.hasOwnProperty; let n = '~';function o() {} function a(e, t, n) { - this.fn = e, this.context = t, this.once = n || !1; - } function s(e, t, o, s, r) { - if ('function' !== typeof o) throw new TypeError('The listener must be a function');const i = new a(o, s || e, r); const c = n ? n + t : t;return e._events[c] ? e._events[c].fn ? e._events[c] = [e._events[c], i] : e._events[c].push(i) : (e._events[c] = i, e._eventsCount++), e; - } function r(e, t) { - 0 == --e._eventsCount ? e._events = new o : delete e._events[t]; - } function i() { - this._events = new o, this._eventsCount = 0; - }Object.create && (o.prototype = Object.create(null), (new o).__proto__ || (n = !1)), i.prototype.eventNames = function () { - let e; let o; const a = [];if (0 === this._eventsCount) return a;for (o in e = this._events)t.call(e, o) && a.push(n ? o.slice(1) : o);return Object.getOwnPropertySymbols ? a.concat(Object.getOwnPropertySymbols(e)) : a; - }, i.prototype.listeners = function (e) { - const t = n ? n + e : e; const o = this._events[t];if (!o) return [];if (o.fn) return [o.fn];for (var a = 0, s = o.length, r = new Array(s);a < s;a++)r[a] = o[a].fn;return r; - }, i.prototype.listenerCount = function (e) { - const t = n ? n + e : e; const o = this._events[t];return o ? o.fn ? 1 : o.length : 0; - }, i.prototype.emit = function (e, t, o, a, s, r) { - const i = n ? n + e : e;if (!this._events[i]) return !1;let c; let u; const l = this._events[i]; const d = arguments.length;if (l.fn) { - switch (l.once && this.removeListener(e, l.fn, void 0, !0), d) { - case 1:return l.fn.call(l.context), !0;case 2:return l.fn.call(l.context, t), !0;case 3:return l.fn.call(l.context, t, o), !0;case 4:return l.fn.call(l.context, t, o, a), !0;case 5:return l.fn.call(l.context, t, o, a, s), !0;case 6:return l.fn.call(l.context, t, o, a, s, r), !0; - } for (u = 1, c = new Array(d - 1);u < d;u++)c[u - 1] = arguments[u];l.fn.apply(l.context, c); - } else { - let g; const p = l.length;for (u = 0;u < p;u++) switch (l[u].once && this.removeListener(e, l[u].fn, void 0, !0), d) { - case 1:l[u].fn.call(l[u].context);break;case 2:l[u].fn.call(l[u].context, t);break;case 3:l[u].fn.call(l[u].context, t, o);break;case 4:l[u].fn.call(l[u].context, t, o, a);break;default:if (!c) for (g = 1, c = new Array(d - 1);g < d;g++)c[g - 1] = arguments[g];l[u].fn.apply(l[u].context, c); - } - } return !0; - }, i.prototype.on = function (e, t, n) { - return s(this, e, t, n, !1); - }, i.prototype.once = function (e, t, n) { - return s(this, e, t, n, !0); - }, i.prototype.removeListener = function (e, t, o, a) { - const s = n ? n + e : e;if (!this._events[s]) return this;if (!t) return r(this, s), this;const i = this._events[s];if (i.fn)i.fn !== t || a && !i.once || o && i.context !== o || r(this, s);else { - for (var c = 0, u = [], l = i.length;c < l;c++)(i[c].fn !== t || a && !i[c].once || o && i[c].context !== o) && u.push(i[c]);u.length ? this._events[s] = 1 === u.length ? u[0] : u : r(this, s); - } return this; - }, i.prototype.removeAllListeners = function (e) { - let t;return e ? (t = n ? n + e : e, this._events[t] && r(this, t)) : (this._events = new o, this._eventsCount = 0), this; - }, i.prototype.off = i.prototype.removeListener, i.prototype.addListener = i.prototype.on, i.prefixed = n, i.EventEmitter = i, e.exports = i; - })); const li = (function (e) { - i(n, e);const t = f(n);function n(e) { - let a;return o(this, n), (a = t.call(this, e))._className = 'BigDataChannelModule', a.FILETYPE = { SOUND: 2106, FILE: 2107, VIDEO: 2113 }, a._bdh_download_server = 'grouptalk.c2c.qq.com', a._BDHBizID = 10001, a._authKey = '', a._expireTime = 0, a.getInnerEmitterInstance().on(Ir.CONTEXT_A2KEY_AND_TINYID_UPDATED, a._getAuthKey, h(a)), a; - } return s(n, [{ key: '_getAuthKey', value() { - const e = this;this.request({ protocolName: Qt }).then(((t) => { - t.data.authKey && (e._authKey = t.data.authKey, e._expireTime = parseInt(t.data.expireTime)); - })); - } }, { key: '_isFromOlderVersion', value(e) { - return !(!e.content || 2 === e.content.downloadFlag); - } }, { key: 'parseElements', value(e, t) { - if (!Re(e) || !t) return [];for (var n = [], o = null, a = 0;a < e.length;a++)o = e[a], this._needParse(o) ? n.push(this._parseElement(o, t)) : n.push(e[a]);return n; - } }, { key: '_needParse', value(e) { - return !e.cloudCustomData && !(!this._isFromOlderVersion(e) || e.type !== k.MSG_AUDIO && e.type !== k.MSG_FILE && e.type !== k.MSG_VIDEO); - } }, { key: '_parseElement', value(e, t) { - switch (e.type) { - case k.MSG_AUDIO:return this._parseAudioElement(e, t);case k.MSG_FILE:return this._parseFileElement(e, t);case k.MSG_VIDEO:return this._parseVideoElement(e, t); - } - } }, { key: '_parseAudioElement', value(e, t) { - return e.content.url = this._genAudioUrl(e.content.uuid, t), e; - } }, { key: '_parseFileElement', value(e, t) { - return e.content.url = this._genFileUrl(e.content.uuid, t, e.content.fileName), e; - } }, { key: '_parseVideoElement', value(e, t) { - return e.content.url = this._genVideoUrl(e.content.uuid, t), e; - } }, { key: '_genAudioUrl', value(e, t) { - if ('' === this._authKey) return Ee.warn(''.concat(this._className, '._genAudioUrl no authKey!')), '';const n = this.getModule(Gt).getSDKAppID();return 'https://'.concat(this._bdh_download_server, '/asn.com/stddownload_common_file?authkey=').concat(this._authKey, '&bid=') - .concat(this._BDHBizID, '&subbid=') - .concat(n, '&fileid=') - .concat(e, '&filetype=') - .concat(this.FILETYPE.SOUND, '&openid=') - .concat(t, '&ver=0'); - } }, { key: '_genFileUrl', value(e, t, n) { - if ('' === this._authKey) return Ee.warn(''.concat(this._className, '._genFileUrl no authKey!')), '';n || (n = ''.concat(Math.floor(1e5 * Math.random()), '-').concat(Date.now()));const o = this.getModule(Gt).getSDKAppID();return 'https://'.concat(this._bdh_download_server, '/asn.com/stddownload_common_file?authkey=').concat(this._authKey, '&bid=') - .concat(this._BDHBizID, '&subbid=') - .concat(o, '&fileid=') - .concat(e, '&filetype=') - .concat(this.FILETYPE.FILE, '&openid=') - .concat(t, '&ver=0&filename=') - .concat(encodeURIComponent(n)); - } }, { key: '_genVideoUrl', value(e, t) { - if ('' === this._authKey) return Ee.warn(''.concat(this._className, '._genVideoUrl no authKey!')), '';const n = this.getModule(Gt).getSDKAppID();return 'https://'.concat(this._bdh_download_server, '/asn.com/stddownload_common_file?authkey=').concat(this._authKey, '&bid=') - .concat(this._BDHBizID, '&subbid=') - .concat(n, '&fileid=') - .concat(e, '&filetype=') - .concat(this.FILETYPE.VIDEO, '&openid=') - .concat(t, '&ver=0'); - } }, { key: 'reset', value() { - Ee.log(''.concat(this._className, '.reset')), this._authKey = '', this.expireTime = 0; - } }]), n; - }(Yt)); const di = (function (e) { - i(a, e);const n = f(a);function a(e) { - let t;return o(this, a), (t = n.call(this, e))._className = 'UploadModule', t.TIMUploadPlugin = null, t.timUploadPlugin = null, t.COSSDK = null, t._cosUploadMethod = null, t.expiredTimeLimit = 600, t.appid = 0, t.bucketName = '', t.ciUrl = '', t.directory = '', t.downloadUrl = '', t.uploadUrl = '', t.region = 'ap-shanghai', t.cos = null, t.cosOptions = { secretId: '', secretKey: '', sessionToken: '', expiredTime: 0 }, t.uploadFileType = '', t.duration = 900, t.tryCount = 0, t.getInnerEmitterInstance().on(Ir.CONTEXT_A2KEY_AND_TINYID_UPDATED, t._init, h(t)), t; - } return s(a, [{ key: '_init', value() { - const e = ''.concat(this._className, '._init'); const t = this.getModule(qt);if (this.TIMUploadPlugin = t.getPlugin('tim-upload-plugin'), this.TIMUploadPlugin) this._initUploaderMethod();else { - const n = z ? 'cos-wx-sdk' : 'cos-js-sdk';this.COSSDK = t.getPlugin(n), this.COSSDK ? (this._getAuthorizationKey(), Ee.warn(''.concat(e, ' v2.9.2起推荐使用 tim-upload-plugin 代替 ').concat(n, ',上传更快更安全。详细请参考 https://web.sdk.qcloud.com/im/doc/zh-cn/SDK.html#registerPlugin'))) : Ee.warn(''.concat(e, ' 没有检测到上传插件,将无法发送图片、音频、视频、文件等类型的消息。详细请参考 https://web.sdk.qcloud.com/im/doc/zh-cn/SDK.html#registerPlugin')); - } - } }, { key: '_getAuthorizationKey', value() { - const e = this; const t = new Da(Ga); const n = Math.ceil(Date.now() / 1e3);this.request({ protocolName: xn, requestData: { duration: this.expiredTimeLimit } }).then(((o) => { - const a = o.data;Ee.log(''.concat(e._className, '._getAuthorizationKey ok. data:'), a);const s = a.expiredTime - n;t.setMessage('requestId:'.concat(a.requestId, ' requestTime:').concat(n, ' expiredTime:') - .concat(a.expiredTime, ' diff:') - .concat(s, 's')).setNetworkType(e.getNetworkType()) - .end(), !z && a.region && (e.region = a.region), e.appid = a.appid, e.bucketName = a.bucketName, e.ciUrl = a.ciUrl, e.directory = a.directory, e.downloadUrl = a.downloadUrl, e.uploadUrl = a.uploadUrl, e.cosOptions = { secretId: a.secretId, secretKey: a.secretKey, sessionToken: a.sessionToken, expiredTime: a.expiredTime }, Ee.log(''.concat(e._className, '._getAuthorizationKey ok. region:').concat(e.region, ' bucketName:') - .concat(e.bucketName)), e._initUploaderMethod(); - })) - .catch(((n) => { - e.probeNetwork().then(((e) => { - const o = m(e, 2); const a = o[0]; const s = o[1];t.setError(n, a, s).end(); - })), Ee.warn(''.concat(e._className, '._getAuthorizationKey failed. error:'), n); - })); - } }, { key: '_getCosPreSigUrl', value(e) { - const t = this; const n = ''.concat(this._className, '._getCosPreSigUrl'); const o = Math.ceil(Date.now() / 1e3); const a = new Da(wa);return this.request({ protocolName: Bn, requestData: { fileType: e.fileType, fileName: e.fileName, uploadMethod: e.uploadMethod, duration: e.duration } }).then(((e) => { - t.tryCount = 0;const s = e.data || {}; const r = s.expiredTime - o;return Ee.log(''.concat(n, ' ok. data:'), s), a.setMessage('requestId:'.concat(s.requestId, ' expiredTime:').concat(s.expiredTime, ' diff:') - .concat(r, 's')).setNetworkType(t.getNetworkType()) - .end(), s; - })) - .catch((o => (-1 === o.code && (o.code = Zn.COS_GET_SIG_FAIL), t.probeNetwork().then(((e) => { - const t = m(e, 2); const n = t[0]; const s = t[1];a.setError(o, n, s).end(); - })), Ee.warn(''.concat(n, ' failed. error:'), o), t.tryCount < 1 ? (t.tryCount++, t._getCosPreSigUrl(e)) : (t.tryCount = 0, Mr({ code: Zn.COS_GET_SIG_FAIL, message: io }))))); - } }, { key: '_initUploaderMethod', value() { - const e = this;if (this.TIMUploadPlugin) return this.timUploadPlugin = new this.TIMUploadPlugin, void (this._cosUploadMethod = function (t, n) { - e.timUploadPlugin.uploadFile(t, n); - });this.appid && (this.cos = z ? new this.COSSDK({ ForcePathStyle: !0, getAuthorization: this._getAuthorization.bind(this) }) : new this.COSSDK({ getAuthorization: this._getAuthorization.bind(this) }), this._cosUploadMethod = z ? function (t, n) { - e.cos.postObject(t, n); - } : function (t, n) { - e.cos.uploadFiles(t, n); - }); - } }, { key: 'onCheckTimer', value(e) { - this.COSSDK && (this.TIMUploadPlugin || this.isLoggedIn() && e % 60 == 0 && Math.ceil(Date.now() / 1e3) >= this.cosOptions.expiredTime - 120 && this._getAuthorizationKey()); - } }, { key: '_getAuthorization', value(e, t) { - t({ TmpSecretId: this.cosOptions.secretId, TmpSecretKey: this.cosOptions.secretKey, XCosSecurityToken: this.cosOptions.sessionToken, ExpiredTime: this.cosOptions.expiredTime }); - } }, { key: 'upload', value(e) { - if (!0 === e.getRelayFlag()) return Promise.resolve();const t = this.getModule($t);switch (e.type) { - case k.MSG_IMAGE:return t.addTotalCount(_a), this._uploadImage(e);case k.MSG_FILE:return t.addTotalCount(_a), this._uploadFile(e);case k.MSG_AUDIO:return t.addTotalCount(_a), this._uploadAudio(e);case k.MSG_VIDEO:return t.addTotalCount(_a), this._uploadVideo(e);default:return Promise.resolve(); - } - } }, { key: '_uploadImage', value(e) { - const n = this.getModule(kt); const o = e.getElements()[0]; const a = n.getMessageOptionByID(e.ID);return this.doUploadImage({ file: a.payload.file, to: a.to, onProgress(e) { - if (o.updatePercent(e), Pe(a.onProgress)) try { - a.onProgress(e); - } catch (t) { - return Mr({ code: Zn.MESSAGE_ONPROGRESS_FUNCTION_ERROR, message: po }); - } - } }).then(((n) => { - const a = n.location; const s = n.fileType; const r = n.fileSize; const i = n.width; const c = n.height; const u = Je(a);o.updateImageFormat(s);const l = rt({ originUrl: u, originWidth: i, originHeight: c, min: 198 }); const d = rt({ originUrl: u, originWidth: i, originHeight: c, min: 720 });return o.updateImageInfoArray([{ size: r, url: u, width: i, height: c }, t({}, d), t({}, l)]), e; - })); - } }, { key: '_uploadFile', value(e) { - const t = this.getModule(kt); const n = e.getElements()[0]; const o = t.getMessageOptionByID(e.ID);return this.doUploadFile({ file: o.payload.file, to: o.to, onProgress(e) { - if (n.updatePercent(e), Pe(o.onProgress)) try { - o.onProgress(e); - } catch (t) { - return Mr({ code: Zn.MESSAGE_ONPROGRESS_FUNCTION_ERROR, message: po }); - } - } }).then(((t) => { - const o = t.location; const a = Je(o);return n.updateFileUrl(a), e; - })); - } }, { key: '_uploadAudio', value(e) { - const t = this.getModule(kt); const n = e.getElements()[0]; const o = t.getMessageOptionByID(e.ID);return this.doUploadAudio({ file: o.payload.file, to: o.to, onProgress(e) { - if (n.updatePercent(e), Pe(o.onProgress)) try { - o.onProgress(e); - } catch (t) { - return Mr({ code: Zn.MESSAGE_ONPROGRESS_FUNCTION_ERROR, message: po }); - } - } }).then(((t) => { - const o = t.location; const a = Je(o);return n.updateAudioUrl(a), e; - })); - } }, { key: '_uploadVideo', value(e) { - const t = this.getModule(kt); const n = e.getElements()[0]; const o = t.getMessageOptionByID(e.ID);return this.doUploadVideo({ file: o.payload.file, to: o.to, onProgress(e) { - if (n.updatePercent(e), Pe(o.onProgress)) try { - o.onProgress(e); - } catch (t) { - return Mr({ code: Zn.MESSAGE_ONPROGRESS_FUNCTION_ERROR, message: po }); - } - } }).then(((t) => { - const o = Je(t.location);return n.updateVideoUrl(o), e; - })); - } }, { key: 'doUploadImage', value(e) { - if (!e.file) return Mr({ code: Zn.MESSAGE_IMAGE_SELECT_FILE_FIRST, message: fo });const t = this._checkImageType(e.file);if (!0 !== t) return t;const n = this._checkImageSize(e.file);if (!0 !== n) return n;let o = null;return this._setUploadFileType(Er), this.uploadByCOS(e).then(((e) => { - return o = e, t = 'https://'.concat(e.location), z ? new Promise(((e, n) => { - J.getImageInfo({ src: t, success(t) { - e({ width: t.width, height: t.height }); - }, fail() { - e({ width: 0, height: 0 }); - } }); - })) : ce && 9 === ue ? Promise.resolve({ width: 0, height: 0 }) : new Promise(((e, n) => { - let o = new Image;o.onload = function () { - e({ width: this.width, height: this.height }), o = null; - }, o.onerror = function () { - e({ width: 0, height: 0 }), o = null; - }, o.src = t; - }));let t; - })) - .then((e => (o.width = e.width, o.height = e.height, Promise.resolve(o)))); - } }, { key: '_checkImageType', value(e) { - let t = '';return t = z ? e.url.slice(e.url.lastIndexOf('.') + 1) : e.files[0].name.slice(e.files[0].name.lastIndexOf('.') + 1), Tr.indexOf(t.toLowerCase()) >= 0 || Mr({ code: Zn.MESSAGE_IMAGE_TYPES_LIMIT, message: mo }); - } }, { key: '_checkImageSize', value(e) { - let t = 0;return 0 === (t = z ? e.size : e.files[0].size) ? Mr({ code: Zn.MESSAGE_FILE_IS_EMPTY, message: ''.concat(go) }) : t < 20971520 || Mr({ code: Zn.MESSAGE_IMAGE_SIZE_LIMIT, message: ''.concat(Mo) }); - } }, { key: 'doUploadFile', value(e) { - let t = null;return e.file ? e.file.files[0].size > 104857600 ? Mr(t = { code: Zn.MESSAGE_FILE_SIZE_LIMIT, message: ko }) : 0 === e.file.files[0].size ? (t = { code: Zn.MESSAGE_FILE_IS_EMPTY, message: ''.concat(go) }, Mr(t)) : (this._setUploadFileType(Nr), this.uploadByCOS(e)) : Mr(t = { code: Zn.MESSAGE_FILE_SELECT_FILE_FIRST, message: Eo }); - } }, { key: 'doUploadVideo', value(e) { - return e.file.videoFile.size > 104857600 ? Mr({ code: Zn.MESSAGE_VIDEO_SIZE_LIMIT, message: ''.concat(Do) }) : 0 === e.file.videoFile.size ? Mr({ code: Zn.MESSAGE_FILE_IS_EMPTY, message: ''.concat(go) }) : -1 === Sr.indexOf(e.file.videoFile.type) ? Mr({ code: Zn.MESSAGE_VIDEO_TYPES_LIMIT, message: ''.concat(To) }) : (this._setUploadFileType(kr), z ? this.handleVideoUpload({ file: e.file.videoFile, onProgress: e.onProgress }) : W ? this.handleVideoUpload(e) : void 0); - } }, { key: 'handleVideoUpload', value(e) { - const t = this;return new Promise(((n, o) => { - t.uploadByCOS(e).then(((e) => { - n(e); - })) - .catch((() => { - t.uploadByCOS(e).then(((e) => { - n(e); - })) - .catch((() => { - o(new hr({ code: Zn.MESSAGE_VIDEO_UPLOAD_FAIL, message: Io })); - })); - })); - })); - } }, { key: 'doUploadAudio', value(e) { - return e.file ? e.file.size > 20971520 ? Mr(new hr({ code: Zn.MESSAGE_AUDIO_SIZE_LIMIT, message: ''.concat(yo) })) : 0 === e.file.size ? Mr(new hr({ code: Zn.MESSAGE_FILE_IS_EMPTY, message: ''.concat(go) })) : (this._setUploadFileType(Cr), this.uploadByCOS(e)) : Mr(new hr({ code: Zn.MESSAGE_AUDIO_UPLOAD_FAIL, message: vo })); - } }, { key: 'uploadByCOS', value(e) { - const t = this; const n = ''.concat(this._className, '.uploadByCOS');if (!Pe(this._cosUploadMethod)) return Ee.warn(''.concat(n, ' 没有检测到上传插件,将无法发送图片、音频、视频、文件等类型的消息。详细请参考 https://web.sdk.qcloud.com/im/doc/zh-cn/SDK.html#registerPlugin')), Mr({ code: Zn.COS_UNDETECTED, message: ro });if (this.timUploadPlugin) return this._uploadWithPreSigUrl(e);const o = new Da(Pa); const a = Date.now(); const s = z ? e.file : e.file.files[0];return new Promise(((r, i) => { - const c = z ? t._createCosOptionsWXMiniApp(e) : t._createCosOptionsWeb(e); const u = t;t._cosUploadMethod(c, ((e, c) => { - const l = Object.create(null);if (c) { - if (e || Re(c.files) && c.files[0].error) { - const d = new hr({ code: Zn.MESSAGE_FILE_UPLOAD_FAIL, message: So });return o.setError(d, !0, t.getNetworkType()).end(), Ee.log(''.concat(n, ' failed. error:'), c.files[0].error), 403 === c.files[0].error.statusCode && (Ee.warn(''.concat(n, ' failed. cos AccessKeyId was invalid, regain auth key!')), t._getAuthorizationKey()), void i(d); - }l.fileName = s.name, l.fileSize = s.size, l.fileType = s.type.slice(s.type.indexOf('/') + 1).toLowerCase(), l.location = z ? c.Location : c.files[0].data.Location;const g = Date.now() - a; const p = u._formatFileSize(s.size); const h = u._formatSpeed(1e3 * s.size / g); const _ = 'size:'.concat(p, ' time:').concat(g, 'ms speed:') - .concat(h);Ee.log(''.concat(n, ' success. name:').concat(s.name, ' ') - .concat(_)), r(l);const f = t.getModule($t);return f.addCost(_a, g), f.addFileSize(_a, s.size), void o.setNetworkType(t.getNetworkType()).setMessage(_) - .end(); - } const m = new hr({ code: Zn.MESSAGE_FILE_UPLOAD_FAIL, message: So });o.setError(m, !0, u.getNetworkType()).end(), Ee.warn(''.concat(n, ' failed. error:'), e), 403 === e.statusCode && (Ee.warn(''.concat(n, ' failed. cos AccessKeyId was invalid, regain auth key!')), t._getAuthorizationKey()), i(m); - })); - })); - } }, { key: '_uploadWithPreSigUrl', value(e) { - const t = this; const n = ''.concat(this._className, '._uploadWithPreSigUrl'); const o = z ? e.file : e.file.files[0];return this._createCosOptionsPreSigUrl(e).then((e => new Promise(((a, s) => { - const r = new Da(Pa);Ee.time(ca), t._cosUploadMethod(e, ((e, i) => { - const c = Object.create(null);if (e || 403 === i.statusCode) { - const u = new hr({ code: Zn.MESSAGE_FILE_UPLOAD_FAIL, message: So });return r.setError(u, !0, t.getNetworkType()).end(), Ee.log(''.concat(n, ' failed, error:'), e), void s(u); - } let l = i.data.location || '';0 !== l.indexOf('https://') && 0 !== l.indexOf('http://') || (l = l.split('//')[1]), c.fileName = o.name, c.fileSize = o.size, c.fileType = o.type.slice(o.type.indexOf('/') + 1).toLowerCase(), c.location = l;const d = Ee.timeEnd(ca); const g = t._formatFileSize(o.size); const p = t._formatSpeed(1e3 * o.size / d); const h = 'size:'.concat(g, ',time:').concat(d, 'ms,speed:') - .concat(p);Ee.log(''.concat(n, ' success name:').concat(o.name, ',') - .concat(h)), r.setNetworkType(t.getNetworkType()).setMessage(h) - .end();const _ = t.getModule($t);_.addCost(_a, d), _.addFileSize(_a, o.size), a(c); - })); - })))); - } }, { key: '_formatFileSize', value(e) { - return e < 1024 ? `${e}B` : e < 1048576 ? `${Math.floor(e / 1024)}KB` : `${Math.floor(e / 1048576)}MB`; - } }, { key: '_formatSpeed', value(e) { - return e <= 1048576 ? `${ut(e / 1024, 1)}KB/s` : `${ut(e / 1048576, 1)}MB/s`; - } }, { key: '_createCosOptionsWeb', value(e) { - const t = this.getMyUserID(); const n = this._genFileName(t, e.to, e.file.files[0].name);return { files: [{ Bucket: ''.concat(this.bucketName, '-').concat(this.appid), Region: this.region, Key: ''.concat(this.directory, '/').concat(n), Body: e.file.files[0] }], SliceSize: 1048576, onProgress(t) { - if ('function' === typeof e.onProgress) try { - e.onProgress(t.percent); - } catch (n) { - Ee.warn('onProgress callback error:', n); - } - }, onFileFinish(e, t, n) {} }; - } }, { key: '_createCosOptionsWXMiniApp', value(e) { - const t = this.getMyUserID(); const n = this._genFileName(t, e.to, e.file.name); const o = e.file.url;return { Bucket: ''.concat(this.bucketName, '-').concat(this.appid), Region: this.region, Key: ''.concat(this.directory, '/').concat(n), FilePath: o, onProgress(t) { - if (Ee.log(JSON.stringify(t)), 'function' === typeof e.onProgress) try { - e.onProgress(t.percent); - } catch (n) { - Ee.warn('onProgress callback error:', n); - } - } }; - } }, { key: '_createCosOptionsPreSigUrl', value(e) { - const t = this; let n = ''; let o = ''; let a = 0;return z ? (n = this._genFileName(e.file.name), o = e.file.url, a = 1) : (n = this._genFileName(''.concat(He(999999))), o = e.file.files[0], a = 0), this._getCosPreSigUrl({ fileType: this.uploadFileType, fileName: n, uploadMethod: a, duration: this.duration }).then(((a) => { - const s = a.uploadUrl; const r = a.downloadUrl;return { url: s, fileType: t.uploadFileType, fileName: n, resources: o, downloadUrl: r, onProgress(t) { - if ('function' === typeof e.onProgress) try { - e.onProgress(t.percent); - } catch (n) { - Ee.warn('onProgress callback error:', n), Ee.error(n); - } - } }; - })); - } }, { key: '_genFileName', value(e) { - return ''.concat(at(), '-').concat(e); - } }, { key: '_setUploadFileType', value(e) { - this.uploadFileType = e; - } }, { key: 'reset', value() { - Ee.log(''.concat(this._className, '.reset')); - } }]), a; - }(Yt)); const gi = ['downloadKey', 'pbDownloadKey', 'messageList']; const pi = (function () { - function e(t) { - o(this, e), this._className = 'MergerMessageHandler', this._messageModule = t; - } return s(e, [{ key: 'uploadMergerMessage', value(e, t) { - const n = this;Ee.debug(''.concat(this._className, '.uploadMergerMessage message:'), e, 'messageBytes:'.concat(t));const o = e.payload.messageList; const a = o.length; const s = new Da(ja);return this._messageModule.request({ protocolName: Wn, requestData: { messageList: o } }).then(((e) => { - Ee.debug(''.concat(n._className, '.uploadMergerMessage ok. response:'), e.data);const o = e.data; const r = o.pbDownloadKey; const i = o.downloadKey; const c = { pbDownloadKey: r, downloadKey: i, messageNumber: a };return s.setNetworkType(n._messageModule.getNetworkType()).setMessage(''.concat(a, '-').concat(t, '-') - .concat(i)) - .end(), c; - })) - .catch(((e) => { - throw Ee.warn(''.concat(n._className, '.uploadMergerMessage failed. error:'), e), n._messageModule.probeNetwork().then(((t) => { - const n = m(t, 2); const o = n[0]; const a = n[1];s.setError(e, o, a).end(); - })), e; - })); - } }, { key: 'downloadMergerMessage', value(e) { - const n = this;Ee.debug(''.concat(this._className, '.downloadMergerMessage message:'), e);const o = e.payload.downloadKey; const a = new Da($a);return a.setMessage('downloadKey:'.concat(o)), this._messageModule.request({ protocolName: Jn, requestData: { downloadKey: o } }).then(((o) => { - if (Ee.debug(''.concat(n._className, '.downloadMergerMessage ok. response:'), o.data), Pe(e.clearElement)) { - const s = e.payload; const r = (s.downloadKey, s.pbDownloadKey, s.messageList, p(s, gi));e.clearElement(), e.setElement({ type: e.type, content: t({ messageList: o.data.messageList }, r) }); - } else { - const i = [];o.data.messageList.forEach(((e) => { - if (!dt(e)) { - const t = new ar(e);i.push(t); - } - })), e.payload.messageList = i, e.payload.downloadKey = '', e.payload.pbDownloadKey = ''; - } return a.setNetworkType(n._messageModule.getNetworkType()).end(), e; - })) - .catch(((e) => { - throw Ee.warn(''.concat(n._className, '.downloadMergerMessage failed. key:').concat(o, ' error:'), e), n._messageModule.probeNetwork().then(((t) => { - const n = m(t, 2); const o = n[0]; const s = n[1];a.setError(e, o, s).end(); - })), e; - })); - } }, { key: 'createMergerMessagePack', value(e, t, n) { - return e.conversationType === k.CONV_C2C ? this._createC2CMergerMessagePack(e, t, n) : this._createGroupMergerMessagePack(e, t, n); - } }, { key: '_createC2CMergerMessagePack', value(e, t, n) { - let o = null;t && (t.offlinePushInfo && (o = t.offlinePushInfo), !0 === t.onlineUserOnly && (o ? o.disablePush = !0 : o = { disablePush: !0 }));let a = '';Ae(e.cloudCustomData) && e.cloudCustomData.length > 0 && (a = e.cloudCustomData);const s = n.pbDownloadKey; const r = n.downloadKey; const i = n.messageNumber; const c = e.payload; const u = c.title; const l = c.abstractList; const d = c.compatibleText; const g = this._messageModule.getModule(Nt);return { protocolName: Zt, tjgID: this._messageModule.generateTjgID(e), requestData: { fromAccount: this._messageModule.getMyUserID(), toAccount: e.to, msgBody: [{ msgType: e.type, msgContent: { pbDownloadKey: s, downloadKey: r, title: u, abstractList: l, compatibleText: d, messageNumber: i } }], cloudCustomData: a, msgSeq: e.sequence, msgRandom: e.random, msgLifeTime: g && g.isOnlineMessage(e, t) ? 0 : void 0, offlinePushInfo: o ? { pushFlag: !0 === o.disablePush ? 1 : 0, title: o.title || '', desc: o.description || '', ext: o.extension || '', apnsInfo: { badgeMode: !0 === o.ignoreIOSBadge ? 1 : 0 }, androidInfo: { OPPOChannelID: o.androidOPPOChannelID || '' } } : void 0 } }; - } }, { key: '_createGroupMergerMessagePack', value(e, t, n) { - let o = null;t && t.offlinePushInfo && (o = t.offlinePushInfo);let a = '';Ae(e.cloudCustomData) && e.cloudCustomData.length > 0 && (a = e.cloudCustomData);const s = n.pbDownloadKey; const r = n.downloadKey; const i = n.messageNumber; const c = e.payload; const u = c.title; const l = c.abstractList; const d = c.compatibleText; const g = this._messageModule.getModule(At);return { protocolName: en, tjgID: this._messageModule.generateTjgID(e), requestData: { fromAccount: this._messageModule.getMyUserID(), groupID: e.to, msgBody: [{ msgType: e.type, msgContent: { pbDownloadKey: s, downloadKey: r, title: u, abstractList: l, compatibleText: d, messageNumber: i } }], random: e.random, priority: e.priority, clientSequence: e.clientSequence, groupAtInfo: void 0, cloudCustomData: a, onlineOnlyFlag: g && g.isOnlineMessage(e, t) ? 1 : 0, offlinePushInfo: o ? { pushFlag: !0 === o.disablePush ? 1 : 0, title: o.title || '', desc: o.description || '', ext: o.extension || '', apnsInfo: { badgeMode: !0 === o.ignoreIOSBadge ? 1 : 0 }, androidInfo: { OPPOChannelID: o.androidOPPOChannelID || '' } } : void 0 } }; - } }]), e; - }()); const hi = { ERR_SVR_COMM_SENSITIVE_TEXT: 80001, ERR_SVR_COMM_BODY_SIZE_LIMIT: 80002, ERR_SVR_MSG_PKG_PARSE_FAILED: 20001, ERR_SVR_MSG_INTERNAL_AUTH_FAILED: 20002, ERR_SVR_MSG_INVALID_ID: 20003, ERR_SVR_MSG_PUSH_DENY: 20006, ERR_SVR_MSG_IN_PEER_BLACKLIST: 20007, ERR_SVR_MSG_BOTH_NOT_FRIEND: 20009, ERR_SVR_MSG_NOT_PEER_FRIEND: 20010, ERR_SVR_MSG_NOT_SELF_FRIEND: 20011, ERR_SVR_MSG_SHUTUP_DENY: 20012, ERR_SVR_GROUP_INVALID_PARAMETERS: 10004, ERR_SVR_GROUP_PERMISSION_DENY: 10007, ERR_SVR_GROUP_NOT_FOUND: 10010, ERR_SVR_GROUP_INVALID_GROUPID: 10015, ERR_SVR_GROUP_REJECT_FROM_THIRDPARTY: 10016, ERR_SVR_GROUP_SHUTUP_DENY: 10017, MESSAGE_SEND_FAIL: 2100 }; const _i = [Zn.MESSAGE_ONPROGRESS_FUNCTION_ERROR, Zn.MESSAGE_IMAGE_SELECT_FILE_FIRST, Zn.MESSAGE_IMAGE_TYPES_LIMIT, Zn.MESSAGE_FILE_IS_EMPTY, Zn.MESSAGE_IMAGE_SIZE_LIMIT, Zn.MESSAGE_FILE_SELECT_FILE_FIRST, Zn.MESSAGE_FILE_SIZE_LIMIT, Zn.MESSAGE_VIDEO_SIZE_LIMIT, Zn.MESSAGE_VIDEO_TYPES_LIMIT, Zn.MESSAGE_AUDIO_UPLOAD_FAIL, Zn.MESSAGE_AUDIO_SIZE_LIMIT, Zn.COS_UNDETECTED];const fi = (function (e) { - i(n, e);const t = f(n);function n(e) { - let a;return o(this, n), (a = t.call(this, e))._className = 'MessageModule', a._messageOptionsMap = new Map, a._mergerMessageHandler = new pi(h(a)), a; - } return s(n, [{ key: 'createTextMessage', value(e) { - const t = this.getMyUserID();e.currentUser = t;const n = new ir(e); const o = 'string' === typeof e.payload ? e.payload : e.payload.text; const a = new qs({ text: o }); const s = this._getNickAndAvatarByUserID(t);return n.setElement(a), n.setNickAndAvatar(s), n; - } }, { key: 'createImageMessage', value(e) { - const t = this.getMyUserID();e.currentUser = t;const n = new ir(e);if (z) { - const o = e.payload.file;if (Ce(o)) return void Ee.warn('小程序环境下调用 createImageMessage 接口时,payload.file 不支持传入 File 对象');const a = o.tempFilePaths[0]; const s = { url: a, name: a.slice(a.lastIndexOf('/') + 1), size: o.tempFiles && o.tempFiles[0].size || 1, type: a.slice(a.lastIndexOf('.') + 1).toLowerCase() };e.payload.file = s; - } else if (W) if (Ce(e.payload.file)) { - const r = e.payload.file;e.payload.file = { files: [r] }; - } else if (Le(e.payload.file) && 'undefined' !== typeof uni) { - const i = e.payload.file.tempFiles[0];e.payload.file = { files: [i] }; - } const c = new Ys({ imageFormat: Vs.IMAGE_FORMAT.UNKNOWN, uuid: this._generateUUID(), file: e.payload.file }); const u = this._getNickAndAvatarByUserID(t);return n.setElement(c), n.setNickAndAvatar(u), this._messageOptionsMap.set(n.ID, e), n; - } }, { key: 'createAudioMessage', value(e) { - if (z) { - const t = e.payload.file;if (z) { - const n = { url: t.tempFilePath, name: t.tempFilePath.slice(t.tempFilePath.lastIndexOf('/') + 1), size: t.fileSize, second: parseInt(t.duration) / 1e3, type: t.tempFilePath.slice(t.tempFilePath.lastIndexOf('.') + 1).toLowerCase() };e.payload.file = n; - } const o = this.getMyUserID();e.currentUser = o;const a = new ir(e); const s = new Ws({ second: Math.floor(t.duration / 1e3), size: t.fileSize, url: t.tempFilePath, uuid: this._generateUUID() }); const r = this._getNickAndAvatarByUserID(o);return a.setElement(s), a.setNickAndAvatar(r), this._messageOptionsMap.set(a.ID, e), a; - }Ee.warn('createAudioMessage 目前只支持小程序环境下发语音消息'); - } }, { key: 'createVideoMessage', value(e) { - const t = this.getMyUserID();e.currentUser = t, e.payload.file.thumbUrl = 'https://web.sdk.qcloud.com/im/assets/images/transparent.png', e.payload.file.thumbSize = 1668;const n = {};if (z) { - if ($) return void Ee.warn('createVideoMessage 不支持在支付宝小程序环境下使用');if (Ce(e.payload.file)) return void Ee.warn('小程序环境下调用 createVideoMessage 接口时,payload.file 不支持传入 File 对象');const o = e.payload.file;n.url = o.tempFilePath, n.name = o.tempFilePath.slice(o.tempFilePath.lastIndexOf('/') + 1), n.size = o.size, n.second = o.duration, n.type = o.tempFilePath.slice(o.tempFilePath.lastIndexOf('.') + 1).toLowerCase(); - } else if (W) { - if (Ce(e.payload.file)) { - const a = e.payload.file;e.payload.file.files = [a]; - } else if (Le(e.payload.file) && 'undefined' !== typeof uni) { - const s = e.payload.file.tempFile;e.payload.file.files = [s]; - } const r = e.payload.file;n.url = window.URL.createObjectURL(r.files[0]), n.name = r.files[0].name, n.size = r.files[0].size, n.second = r.files[0].duration || 0, n.type = r.files[0].type.split('/')[1]; - }e.payload.file.videoFile = n;const i = new ir(e); const c = new nr({ videoFormat: n.type, videoSecond: ut(n.second, 0), videoSize: n.size, remoteVideoUrl: '', videoUrl: n.url, videoUUID: this._generateUUID(), thumbUUID: this._generateUUID(), thumbWidth: e.payload.file.width || 200, thumbHeight: e.payload.file.height || 200, thumbUrl: e.payload.file.thumbUrl, thumbSize: e.payload.file.thumbSize, thumbFormat: e.payload.file.thumbUrl.slice(e.payload.file.thumbUrl.lastIndexOf('.') + 1).toLowerCase() }); const u = this._getNickAndAvatarByUserID(t);return i.setElement(c), i.setNickAndAvatar(u), this._messageOptionsMap.set(i.ID, e), i; - } }, { key: 'createCustomMessage', value(e) { - const t = this.getMyUserID();e.currentUser = t;const n = new ir(e); const o = new tr({ data: e.payload.data, description: e.payload.description, extension: e.payload.extension }); const a = this._getNickAndAvatarByUserID(t);return n.setElement(o), n.setNickAndAvatar(a), n; - } }, { key: 'createFaceMessage', value(e) { - const t = this.getMyUserID();e.currentUser = t;const n = new ir(e); const o = new zs(e.payload); const a = this._getNickAndAvatarByUserID(t);return n.setElement(o), n.setNickAndAvatar(a), n; - } }, { key: 'createMergerMessage', value(e) { - const t = this.getMyUserID();e.currentUser = t;const n = this._getNickAndAvatarByUserID(t); const o = new ir(e); const a = new sr(e.payload);return o.setElement(a), o.setNickAndAvatar(n), o.setRelayFlag(!0), o; - } }, { key: 'createForwardMessage', value(e) { - const t = e.to; const n = e.conversationType; const o = e.priority; const a = e.payload; const s = this.getMyUserID(); const r = this._getNickAndAvatarByUserID(s);if (a.type === k.MSG_GRP_TIP) return Mr(new hr({ code: Zn.MESSAGE_FORWARD_TYPE_INVALID, message: Lo }));const i = { to: t, conversationType: n, conversationID: ''.concat(n).concat(t), priority: o, isPlaceMessage: 0, status: _t.UNSEND, currentUser: s, cloudCustomData: e.cloudCustomData || a.cloudCustomData || '' }; const c = new ir(i);return c.setElement(a.getElements()[0]), c.setNickAndAvatar(r), c.setRelayFlag(!0), c; - } }, { key: 'downloadMergerMessage', value(e) { - return this._mergerMessageHandler.downloadMergerMessage(e); - } }, { key: 'createFileMessage', value(e) { - if (!z) { - if (W) if (Ce(e.payload.file)) { - const t = e.payload.file;e.payload.file = { files: [t] }; - } else if (Le(e.payload.file) && 'undefined' !== typeof uni) { - const n = e.payload.file.tempFiles[0];e.payload.file = { files: [n] }; - } const o = this.getMyUserID();e.currentUser = o;const a = new ir(e); const s = new er({ uuid: this._generateUUID(), file: e.payload.file }); const r = this._getNickAndAvatarByUserID(o);return a.setElement(s), a.setNickAndAvatar(r), this._messageOptionsMap.set(a.ID, e), a; - }Ee.warn('小程序目前不支持选择文件, createFileMessage 接口不可用!'); - } }, { key: '_onCannotFindModule', value() { - return Mr({ code: Zn.CANNOT_FIND_MODULE, message: ra }); - } }, { key: 'sendMessageInstance', value(e, t) { - let n; const o = this; let a = null;switch (e.conversationType) { - case k.CONV_C2C:if (!(a = this.getModule(Nt))) return this._onCannotFindModule();break;case k.CONV_GROUP:if (!(a = this.getModule(At))) return this._onCannotFindModule();break;default:return Mr({ code: Zn.MESSAGE_SEND_INVALID_CONVERSATION_TYPE, message: lo }); - } const s = this.getModule(Ft); const r = this.getModule(At);return s.upload(e).then((() => { - o._getSendMessageSpecifiedKey(e) === ha && o.getModule($t).addSuccessCount(_a);return r.guardForAVChatRoom(e).then((() => { - if (!e.isSendable()) return Mr({ code: Zn.MESSAGE_FILE_URL_IS_EMPTY, message: Co });o._addSendMessageTotalCount(e), n = Date.now();const s = (function (e) { - let t = 'utf-8';W && document && (t = document.charset.toLowerCase());let n; let o; let a = 0;if (o = e.length, 'utf-8' === t || 'utf8' === t) for (let s = 0;s < o;s++)(n = e.codePointAt(s)) <= 127 ? a += 1 : n <= 2047 ? a += 2 : n <= 65535 ? a += 3 : (a += 4, s++);else if ('utf-16' === t || 'utf16' === t) for (let r = 0;r < o;r++)(n = e.codePointAt(r)) <= 65535 ? a += 2 : (a += 4, r++);else a = e.replace(/[^\x00-\xff]/g, 'aa').length;return a; - }(JSON.stringify(e)));return e.type === k.MSG_MERGER && s > 7e3 ? o._mergerMessageHandler.uploadMergerMessage(e, s).then(((n) => { - const a = o._mergerMessageHandler.createMergerMessagePack(e, t, n);return o.request(a); - })) : (o.getModule(Rt).setMessageRandom(e), e.conversationType === k.CONV_C2C || e.conversationType === k.CONV_GROUP ? a.sendMessage(e, t) : void 0); - })) - .then(((s) => { - const r = s.data; const i = r.time; const c = r.sequence;o._addSendMessageSuccessCount(e, n), o._messageOptionsMap.delete(e.ID);const u = o.getModule(Rt);e.status = _t.SUCCESS, e.time = i;let l = !1;if (e.conversationType === k.CONV_GROUP)e.sequence = c, e.generateMessageID(o.getMyUserID());else if (e.conversationType === k.CONV_C2C) { - const d = u.getLatestMessageSentByMe(e.conversationID);if (d) { - const g = d.nick; const p = d.avatar;g === e.nick && p === e.avatar || (l = !0); - } - } return u.appendToMessageList(e), l && u.modifyMessageSentByMe({ conversationID: e.conversationID, latestNick: e.nick, latestAvatar: e.avatar }), a.isOnlineMessage(e, t) ? e.setOnlineOnlyFlag(!0) : u.onMessageSent({ conversationOptionsList: [{ conversationID: e.conversationID, unreadCount: 0, type: e.conversationType, subType: e.conversationSubType, lastMessage: e }] }), e.getRelayFlag() || 'TIMImageElem' !== e.type || it(e.payload.imageInfoArray), cr({ message: e }); - })); - })) - .catch((t => o._onSendMessageFailed(e, t))); - } }, { key: '_onSendMessageFailed', value(e, t) { - e.status = _t.FAIL, this.getModule(Rt).deleteMessageRandom(e), this._addSendMessageFailCountOnUser(e, t);const n = new Da(ba);return n.setMessage('tjg_id:'.concat(this.generateTjgID(e), ' type:').concat(e.type, ' from:') - .concat(e.from, ' to:') - .concat(e.to)), this.probeNetwork().then(((e) => { - const o = m(e, 2); const a = o[0]; const s = o[1];n.setError(t, a, s).end(); - })), Ee.error(''.concat(this._className, '._onSendMessageFailed error:'), t), Mr(new hr({ code: t && t.code ? t.code : Zn.MESSAGE_SEND_FAIL, message: t && t.message ? t.message : co, data: { message: e } })); - } }, { key: '_getSendMessageSpecifiedKey', value(e) { - if ([k.MSG_IMAGE, k.MSG_AUDIO, k.MSG_VIDEO, k.MSG_FILE].includes(e.type)) return ha;if (e.conversationType === k.CONV_C2C) return da;if (e.conversationType === k.CONV_GROUP) { - const t = this.getModule(At).getLocalGroupProfile(e.to);if (!t) return;const n = t.type;return et(n) ? pa : ga; - } - } }, { key: '_addSendMessageTotalCount', value(e) { - const t = this._getSendMessageSpecifiedKey(e);t && this.getModule($t).addTotalCount(t); - } }, { key: '_addSendMessageSuccessCount', value(e, t) { - const n = Math.abs(Date.now() - t); const o = this._getSendMessageSpecifiedKey(e);if (o) { - const a = this.getModule($t);a.addSuccessCount(o), a.addCost(o, n); - } - } }, { key: '_addSendMessageFailCountOnUser', value(e, t) { - let n; let o; const a = t.code; const s = void 0 === a ? -1 : a; const r = this.getModule($t); const i = this._getSendMessageSpecifiedKey(e);i === ha && (n = s, o = !1, _i.includes(n) && (o = !0), o) ? r.addFailedCountOfUserSide(_a) : (function (e) { - let t = !1;return Object.values(hi).includes(e) && (t = !0), (e >= 120001 && e <= 13e4 || e >= 10100 && e <= 10200) && (t = !0), t; - }(s)) && i && r.addFailedCountOfUserSide(i); - } }, { key: 'resendMessage', value(e) { - return e.isResend = !0, e.status = _t.UNSEND, this.sendMessageInstance(e); - } }, { key: 'revokeMessage', value(e) { - const t = this; let n = null;if (e.conversationType === k.CONV_C2C) { - if (!(n = this.getModule(Nt))) return this._onCannotFindModule(); - } else if (e.conversationType === k.CONV_GROUP && !(n = this.getModule(At))) return this._onCannotFindModule();const o = new Da(qa);return o.setMessage('tjg_id:'.concat(this.generateTjgID(e), ' type:').concat(e.type, ' from:') - .concat(e.from, ' to:') - .concat(e.to)), n.revokeMessage(e).then(((n) => { - const a = n.data.recallRetList;if (!dt(a) && 0 !== a[0].retCode) { - const s = new hr({ code: a[0].retCode, message: pr[a[0].retCode] || ho, data: { message: e } });return o.setCode(s.code).setMoreMessage(s.message) - .end(), Mr(s); - } return Ee.info(''.concat(t._className, '.revokeMessage ok. ID:').concat(e.ID)), e.isRevoked = !0, o.end(), t.getModule(Rt).onMessageRevoked([e]), cr({ message: e }); - })) - .catch(((n) => { - t.probeNetwork().then(((e) => { - const t = m(e, 2); const a = t[0]; const s = t[1];o.setError(n, a, s).end(); - }));const a = new hr({ code: n && n.code ? n.code : Zn.MESSAGE_REVOKE_FAIL, message: n && n.message ? n.message : ho, data: { message: e } });return Ee.warn(''.concat(t._className, '.revokeMessage failed. error:'), n), Mr(a); - })); - } }, { key: 'deleteMessage', value(e) { - const t = this; let n = null; const o = e[0]; const a = o.conversationID; let s = ''; let r = []; let i = [];if (o.conversationType === k.CONV_C2C ? (n = this.getModule(Nt), s = a.replace(k.CONV_C2C, ''), e.forEach(((e) => { - e && e.status === _t.SUCCESS && e.conversationID === a && (e.getOnlineOnlyFlag() || r.push(''.concat(e.sequence, '_').concat(e.random, '_') - .concat(e.time)), i.push(e)); - }))) : o.conversationType === k.CONV_GROUP && (n = this.getModule(At), s = a.replace(k.CONV_GROUP, ''), e.forEach(((e) => { - e && e.status === _t.SUCCESS && e.conversationID === a && (e.getOnlineOnlyFlag() || r.push(''.concat(e.sequence)), i.push(e)); - }))), !n) return this._onCannotFindModule();if (0 === r.length) return this._onMessageDeleted(i);r.length > 30 && (r = r.slice(0, 30), i = i.slice(0, 30));const c = new Da(Va);return c.setMessage('to:'.concat(s, ' count:').concat(r.length)), n.deleteMessage({ to: s, keyList: r }).then((e => (c.end(), Ee.info(''.concat(t._className, '.deleteMessage ok')), t._onMessageDeleted(i)))) - .catch(((e) => { - t.probeNetwork().then(((t) => { - const n = m(t, 2); const o = n[0]; const a = n[1];c.setError(e, o, a).end(); - })), Ee.warn(''.concat(t._className, '.deleteMessage failed. error:'), e);const n = new hr({ code: e && e.code ? e.code : Zn.MESSAGE_DELETE_FAIL, message: e && e.message ? e.message : _o });return Mr(n); - })); - } }, { key: '_onMessageDeleted', value(e) { - return this.getModule(Rt).onMessageDeleted(e), mr({ messageList: e }); - } }, { key: '_generateUUID', value() { - const e = this.getModule(Gt);return ''.concat(e.getSDKAppID(), '-').concat(e.getUserID(), '-') - .concat(function () { - for (var e = '', t = 32;t > 0;--t)e += je[Math.floor(Math.random() * $e)];return e; - }()); - } }, { key: 'getMessageOptionByID', value(e) { - return this._messageOptionsMap.get(e); - } }, { key: '_getNickAndAvatarByUserID', value(e) { - return this.getModule(Ct).getNickAndAvatarByUserID(e); - } }, { key: 'reset', value() { - Ee.log(''.concat(this._className, '.reset')), this._messageOptionsMap.clear(); - } }]), n; - }(Yt)); const mi = (function (e) { - i(n, e);const t = f(n);function n(e) { - let a;return o(this, n), (a = t.call(this, e))._className = 'PluginModule', a.plugins = {}, a; - } return s(n, [{ key: 'registerPlugin', value(e) { - const t = this;Object.keys(e).forEach(((n) => { - t.plugins[n] = e[n]; - })), new Da(Na).setMessage('key='.concat(Object.keys(e))) - .end(); - } }, { key: 'getPlugin', value(e) { - return this.plugins[e]; - } }, { key: 'reset', value() { - Ee.log(''.concat(this._className, '.reset')); - } }]), n; - }(Yt)); const Mi = (function (e) { - i(n, e);const t = f(n);function n(e) { - let a;return o(this, n), (a = t.call(this, e))._className = 'SyncUnreadMessageModule', a._cookie = '', a._onlineSyncFlag = !1, a.getInnerEmitterInstance().on(Ir.CONTEXT_A2KEY_AND_TINYID_UPDATED, a._onLoginSuccess, h(a)), a; - } return s(n, [{ key: '_onLoginSuccess', value(e) { - this._startSync({ cookie: this._cookie, syncFlag: 0, isOnlineSync: 0 }); - } }, { key: '_startSync', value(e) { - const t = this; const n = e.cookie; const o = e.syncFlag; const a = e.isOnlineSync;Ee.log(''.concat(this._className, '._startSync cookie:').concat(n, ' syncFlag:') - .concat(o, ' isOnlineSync:') - .concat(a)), this.request({ protocolName: Xt, requestData: { cookie: n, syncFlag: o, isOnlineSync: a } }).then(((e) => { - const n = e.data; const o = n.cookie; const a = n.syncFlag; const s = n.eventArray; const r = n.messageList; const i = n.C2CRemainingUnreadList;if (t._cookie = o, dt(o));else if (0 === a || 1 === a) { - if (s)t.getModule(Kt).onMessage({ head: {}, body: { eventArray: s, isInstantMessage: t._onlineSyncFlag, isSyncingEnded: !1 } });t.getModule(Nt).onNewC2CMessage({ dataList: r, isInstantMessage: !1, C2CRemainingUnreadList: i }), t._startSync({ cookie: o, syncFlag: a, isOnlineSync: 0 }); - } else if (2 === a) { - if (s)t.getModule(Kt).onMessage({ head: {}, body: { eventArray: s, isInstantMessage: t._onlineSyncFlag, isSyncingEnded: !0 } });t.getModule(Nt).onNewC2CMessage({ dataList: r, isInstantMessage: t._onlineSyncFlag, C2CRemainingUnreadList: i }); - } - })) - .catch(((e) => { - Ee.error(''.concat(t._className, '._startSync failed. error:'), e); - })); - } }, { key: 'startOnlineSync', value() { - Ee.log(''.concat(this._className, '.startOnlineSync')), this._onlineSyncFlag = !0, this._startSync({ cookie: this._cookie, syncFlag: 0, isOnlineSync: 1 }); - } }, { key: 'reset', value() { - Ee.log(''.concat(this._className, '.reset')), this._onlineSyncFlag = !1, this._cookie = ''; - } }]), n; - }(Yt)); const vi = { request: { toAccount: 'To_Account', fromAccount: 'From_Account', to: 'To_Account', from: 'From_Account', groupID: 'GroupId', groupAtUserID: 'GroupAt_Account', extension: 'Ext', data: 'Data', description: 'Desc', elements: 'MsgBody', sizeType: 'Type', downloadFlag: 'Download_Flag', thumbUUID: 'ThumbUUID', videoUUID: 'VideoUUID', remoteAudioUrl: 'Url', remoteVideoUrl: 'VideoUrl', videoUrl: '', imageUrl: 'URL', fileUrl: 'Url', uuid: 'UUID', priority: 'MsgPriority', receiverUserID: 'To_Account', receiverGroupID: 'GroupId', messageSender: 'SenderId', messageReceiver: 'ReceiverId', nick: 'From_AccountNick', avatar: 'From_AccountHeadurl', messageNumber: 'MsgNum', pbDownloadKey: 'PbMsgKey', downloadKey: 'JsonMsgKey', applicationType: 'PendencyType', userIDList: 'To_Account', groupNameList: 'GroupName', userID: 'To_Account' }, response: { MsgPriority: 'priority', ThumbUUID: 'thumbUUID', VideoUUID: 'videoUUID', Download_Flag: 'downloadFlag', GroupId: 'groupID', Member_Account: 'userID', MsgList: 'messageList', SyncFlag: 'syncFlag', To_Account: 'to', From_Account: 'from', MsgSeq: 'sequence', MsgRandom: 'random', MsgTime: 'time', MsgTimeStamp: 'time', MsgContent: 'content', MsgBody: 'elements', From_AccountNick: 'nick', From_AccountHeadurl: 'avatar', GroupWithdrawInfoArray: 'revokedInfos', GroupReadInfoArray: 'groupMessageReadNotice', LastReadMsgSeq: 'lastMessageSeq', WithdrawC2cMsgNotify: 'c2cMessageRevokedNotify', C2cWithdrawInfoArray: 'revokedInfos', C2cReadedReceipt: 'c2cMessageReadReceipt', ReadC2cMsgNotify: 'c2cMessageReadNotice', LastReadTime: 'peerReadTime', MsgRand: 'random', MsgType: 'type', MsgShow: 'messageShow', NextMsgSeq: 'nextMessageSeq', FaceUrl: 'avatar', ProfileDataMod: 'profileModify', Profile_Account: 'userID', ValueBytes: 'value', ValueNum: 'value', NoticeSeq: 'noticeSequence', NotifySeq: 'notifySequence', MsgFrom_AccountExtraInfo: 'messageFromAccountExtraInformation', Operator_Account: 'operatorID', OpType: 'operationType', ReportType: 'operationType', UserId: 'userID', User_Account: 'userID', List_Account: 'userIDList', MsgOperatorMemberExtraInfo: 'operatorInfo', MsgMemberExtraInfo: 'memberInfoList', ImageUrl: 'avatar', NickName: 'nick', MsgGroupNewInfo: 'newGroupProfile', MsgAppDefinedData: 'groupCustomField', Owner_Account: 'ownerID', GroupFaceUrl: 'avatar', GroupIntroduction: 'introduction', GroupNotification: 'notification', GroupApplyJoinOption: 'joinOption', MsgKey: 'messageKey', GroupInfo: 'groupProfile', ShutupTime: 'muteTime', Desc: 'description', Ext: 'extension', GroupAt_Account: 'groupAtUserID', MsgNum: 'messageNumber', PbMsgKey: 'pbDownloadKey', JsonMsgKey: 'downloadKey', MsgModifiedFlag: 'isModified', PendencyItem: 'applicationItem', PendencyType: 'applicationType', AddTime: 'time', AddSource: 'source', AddWording: 'wording', ProfileImImage: 'avatar', PendencyAdd: 'friendApplicationAdded', FrienPencydDel_Account: 'friendApplicationDeletedUserIDList' }, ignoreKeyWord: ['C2C', 'ID', 'USP'] };function yi(e, t) { - if ('string' !== typeof e && !Array.isArray(e)) throw new TypeError('Expected the input to be `string | string[]`');t = Object.assign({ pascalCase: !1 }, t);let n;return 0 === (e = Array.isArray(e) ? e.map((e => e.trim())).filter((e => e.length)) - .join('-') : e.trim()).length ? '' : 1 === e.length ? t.pascalCase ? e.toUpperCase() : e.toLowerCase() : (e !== e.toLowerCase() && (e = Ii(e)), e = e.replace(/^[_.\- ]+/, '').toLowerCase() - .replace(/[_.\- ]+(\w|$)/g, ((e, t) => t.toUpperCase())) - .replace(/\d+(\w|$)/g, (e => e.toUpperCase())), n = e, t.pascalCase ? n.charAt(0).toUpperCase() + n.slice(1) : n); - } var Ii = function (e) { - for (let t = !1, n = !1, o = !1, a = 0;a < e.length;a++) { - const s = e[a];t && /[a-zA-Z]/.test(s) && s.toUpperCase() === s ? (e = `${e.slice(0, a)}-${e.slice(a)}`, t = !1, o = n, n = !0, a++) : n && o && /[a-zA-Z]/.test(s) && s.toLowerCase() === s ? (e = `${e.slice(0, a - 1)}-${e.slice(a - 1)}`, o = n, n = !1, t = !0) : (t = s.toLowerCase() === s && s.toUpperCase() !== s, o = n, n = s.toUpperCase() === s && s.toLowerCase() !== s); - } return e; - };function Di(e, t) { - let n = 0;return (function e(t, o) { - if (++n > 100) return n--, t;if (Re(t)) { - const a = t.map((t => (Oe(t) ? e(t, o) : t)));return n--, a; - } if (Oe(t)) { - let s = (r = t, i = function (e, t) { - if (!Fe(t)) return !1;if ((a = t) !== yi(a)) for (let n = 0;n < vi.ignoreKeyWord.length && !t.includes(vi.ignoreKeyWord[n]);n++);let a;return Ge(o[t]) ? (function (e) { - return 'OPPOChannelID' === e ? e : e[0].toUpperCase() + yi(e).slice(1); - }(t)) : o[t]; - }, c = Object.create(null), Object.keys(r).forEach(((e) => { - const t = i(r[e], e);t && (c[t] = r[e]); - })), c);return s = ot(s, ((t, n) => (Re(t) || Oe(t) ? e(t, o) : t))), n--, s; - } let r; let i; let c; - }(e, t)); - } function Ti(e, t) { - if (Re(e)) return e.map((e => (Oe(e) ? Ti(e, t) : e)));if (Oe(e)) { - let n = (o = e, a = function (e, n) { - return Ge(t[n]) ? yi(n) : t[n]; - }, s = {}, Object.keys(o).forEach(((e) => { - s[a(o[e], e)] = o[e]; - })), s);return n = ot(n, (e => (Re(e) || Oe(e) ? Ti(e, t) : e))); - } let o; let a; let s; - } const Si = (function () { - function e(t) { - o(this, e), this._handler = t;const n = t.getURL();this._socket = null, this._id = He(), z ? $ ? (J.connectSocket({ url: n, header: { 'content-type': 'application/json' } }), J.onSocketClose(this._onClose.bind(this)), J.onSocketOpen(this._onOpen.bind(this)), J.onSocketMessage(this._onMessage.bind(this)), J.onSocketError(this._onError.bind(this))) : (this._socket = J.connectSocket({ url: n, header: { 'content-type': 'application/json' }, complete() {} }), this._socket.onClose(this._onClose.bind(this)), this._socket.onOpen(this._onOpen.bind(this)), this._socket.onMessage(this._onMessage.bind(this)), this._socket.onError(this._onError.bind(this))) : W && (this._socket = new WebSocket(n), this._socket.onopen = this._onOpen.bind(this), this._socket.onmessage = this._onMessage.bind(this), this._socket.onclose = this._onClose.bind(this), this._socket.onerror = this._onError.bind(this)); - } return s(e, [{ key: 'getID', value() { - return this._id; - } }, { key: '_onOpen', value() { - this._handler.onOpen({ id: this._id }); - } }, { key: '_onClose', value(e) { - this._handler.onClose({ id: this._id, e }); - } }, { key: '_onMessage', value(e) { - this._handler.onMessage(e); - } }, { key: '_onError', value(e) { - this._handler.onError({ id: this._id, e }); - } }, { key: 'close', value(e) { - if ($) return J.offSocketClose(), J.offSocketMessage(), J.offSocketOpen(), J.offSocketError(), void J.closeSocket();this._socket && (z ? (this._socket.onClose((() => {})), this._socket.onOpen((() => {})), this._socket.onMessage((() => {})), this._socket.onError((() => {}))) : W && (this._socket.onopen = null, this._socket.onmessage = null, this._socket.onclose = null, this._socket.onerror = null), j ? this._socket.close({ code: e }) : this._socket.close(e), this._socket = null); - } }, { key: 'send', value(e) { - $ ? J.sendSocketMessage({ data: e.data, fail() { - e.fail && e.requestID && e.fail(e.requestID); - } }) : this._socket && (z ? this._socket.send({ data: e.data, fail() { - e.fail && e.requestID && e.fail(e.requestID); - } }) : W && this._socket.send(e.data)); - } }]), e; - }()); const Ei = 4e3; const ki = 4001; const Ci = ['keyMap']; const Ni = ['keyMap']; const Ai = 'connected'; const Oi = 'connecting'; const Li = 'disconnected'; const Ri = (function () { - function e(t) { - o(this, e), this._channelModule = t, this._className = 'SocketHandler', this._promiseMap = new Map, this._readyState = Li, this._simpleRequestMap = new Map, this.MAX_SIZE = 100, this._startSequence = He(), this._startTs = 0, this._reConnectFlag = !1, this._nextPingTs = 0, this._reConnectCount = 0, this.MAX_RECONNECT_COUNT = 3, this._socketID = -1, this._random = 0, this._socket = null, this._url = '', this._onOpenTs = 0, this._setOverseaHost(), this._initConnection(); - } return s(e, [{ key: '_setOverseaHost', value() { - this._channelModule.isOversea() && U.HOST.setCurrent(b); - } }, { key: '_initConnection', value() { - '' === this._url ? this._url = U.HOST.CURRENT.DEFAULT : this._url === U.HOST.CURRENT.DEFAULT ? this._url = U.HOST.CURRENT.BACKUP : this._url === U.HOST.CURRENT.BACKUP && (this._url = U.HOST.CURRENT.DEFAULT), this._connect(), this._nextPingTs = 0; - } }, { key: 'onCheckTimer', value(e) { - e % 1 == 0 && this._checkPromiseMap(); - } }, { key: '_checkPromiseMap', value() { - const e = this;0 !== this._promiseMap.size && this._promiseMap.forEach(((t, n) => { - const o = t.reject; const a = t.timestamp;Date.now() - a >= 15e3 && (Ee.log(''.concat(e._className, '._checkPromiseMap request timeout, delete requestID:').concat(n)), e._promiseMap.delete(n), o(new hr({ code: Zn.NETWORK_TIMEOUT, message: na })), e._channelModule.onRequestTimeout(n)); - })); - } }, { key: 'onOpen', value(e) { - this._onOpenTs = Date.now();const t = e.id;this._socketID = t, new Da(Oa).setMessage(n) - .setMessage('socketID:'.concat(t)) - .end();var n = Date.now() - this._startTs;Ee.log(''.concat(this._className, '._onOpen cost ').concat(n, ' ms. socketID:') - .concat(t)), e.id === this._socketID && (this._readyState = Ai, this._reConnectCount = 0, this._resend(), !0 === this._reConnectFlag && (this._channelModule.onReconnected(), this._reConnectFlag = !1), this._channelModule.onOpen()); - } }, { key: 'onClose', value(e) { - const t = new Da(La); const n = e.id; const o = e.e; const a = 'sourceSocketID:'.concat(n, ' currentSocketID:').concat(this._socketID); let s = 0;0 !== this._onOpenTs && (s = Date.now() - this._onOpenTs), t.setMessage(s).setMoreMessage(a) - .setCode(o.code) - .end(), Ee.log(''.concat(this._className, '._onClose code:').concat(o.code, ' reason:') - .concat(o.reason, ' ') - .concat(a)), n === this._socketID && (this._readyState = Li, s < 1e3 ? this._channelModule.onReconnectFailed() : this._channelModule.onClose()); - } }, { key: 'onError', value(e) { - const t = e.id; const n = e.e; const o = 'sourceSocketID:'.concat(t, ' currentSocketID:').concat(this._socketID);new Da(Ra).setMessage(n.errMsg || xe(n)) - .setMoreMessage(o) - .setLevel('error') - .end(), Ee.warn(''.concat(this._className, '._onError'), n, o), t === this._socketID && (this._readyState = '', this._channelModule.onError()); - } }, { key: 'onMessage', value(e) { - let t;try { - t = JSON.parse(e.data); - } catch (u) { - new Da(Ya).setMessage(e.data) - .end(); - } if (t && t.head) { - const n = this._getRequestIDFromHead(t.head); const o = ct(t.head); const a = Ti(t.body, this._getResponseKeyMap(o));if (Ee.debug(''.concat(this._className, '.onMessage ret:').concat(JSON.stringify(a), ' requestID:') - .concat(n, ' has:') - .concat(this._promiseMap.has(n))), this._setNextPingTs(), this._promiseMap.has(n)) { - const s = this._promiseMap.get(n); const r = s.resolve; const i = s.reject; const c = s.timestamp;return this._promiseMap.delete(n), this._calcRTT(c), void (a.errorCode && 0 !== a.errorCode ? (this._channelModule.onErrorCodeNotZero(a), i(new hr({ code: a.errorCode, message: a.errorInfo || '' }))) : r(cr(a))); - } this._channelModule.onMessage({ head: t.head, body: a }); - } - } }, { key: '_calcRTT', value(e) { - const t = Date.now() - e;this._channelModule.getModule($t).addRTT(t); - } }, { key: '_connect', value() { - new Da(Aa).setMessage('url:'.concat(this.getURL())) - .end(), this._startTs = Date.now(), this._socket = new Si(this), this._socketID = this._socket.getID(), this._readyState = Oi; - } }, { key: 'getURL', value() { - const e = this._channelModule.getModule(Gt);return ''.concat(this._url, '/info?sdkappid=').concat(e.getSDKAppID(), '&instanceid=') - .concat(e.getInstanceID(), '&random=') - .concat(this._getRandom()); - } }, { key: '_closeConnection', value(e) { - this._socket && (this._socket.close(e), this._socketID = -1, this._socket = null, this._readyState = Li); - } }, { key: '_resend', value() { - const e = this;if (Ee.log(''.concat(this._className, '._resend reConnectFlag:').concat(this._reConnectFlag), 'promiseMap.size:'.concat(this._promiseMap.size, ' simpleRequestMap.size:').concat(this._simpleRequestMap.size)), this._promiseMap.size > 0 && this._promiseMap.forEach(((t, n) => { - const o = t.uplinkData; const a = t.resolve; const s = t.reject;e._promiseMap.set(n, { resolve: a, reject: s, timestamp: Date.now(), uplinkData: o }), e._execute(n, o); - })), this._simpleRequestMap.size > 0) { - let t; const n = S(this._simpleRequestMap);try { - for (n.s();!(t = n.n()).done;) { - const o = m(t.value, 2); const a = o[0]; const s = o[1];this._execute(a, s); - } - } catch (r) { - n.e(r); - } finally { - n.f(); - } this._simpleRequestMap.clear(); - } - } }, { key: 'send', value(e) { - const t = this;e.head.seq = this._getSequence(), e.head.reqtime = Math.floor(Date.now() / 1e3);e.keyMap;const n = p(e, Ci); const o = this._getRequestIDFromHead(e.head); const a = JSON.stringify(n);return new Promise(((e, s) => { - (t._promiseMap.set(o, { resolve: e, reject: s, timestamp: Date.now(), uplinkData: a }), Ee.debug(''.concat(t._className, '.send uplinkData:').concat(JSON.stringify(n), ' requestID:') - .concat(o, ' readyState:') - .concat(t._readyState)), t._readyState !== Ai) ? t._reConnect() : (t._execute(o, a), t._channelModule.getModule($t).addRequestCount()); - })); - } }, { key: 'simplySend', value(e) { - e.head.seq = this._getSequence(), e.head.reqtime = Math.floor(Date.now() / 1e3);e.keyMap;const t = p(e, Ni); const n = this._getRequestIDFromHead(e.head); const o = JSON.stringify(t);this._readyState !== Ai ? (this._simpleRequestMap.size < this.MAX_SIZE ? this._simpleRequestMap.set(n, o) : Ee.log(''.concat(this._className, '.simplySend. simpleRequestMap is full, drop request!')), this._reConnect()) : this._execute(n, o); - } }, { key: '_execute', value(e, t) { - this._socket.send({ data: t, fail: z ? this._onSendFail.bind(this) : void 0, requestID: e }); - } }, { key: '_onSendFail', value(e) { - Ee.log(''.concat(this._className, '._onSendFail requestID:').concat(e)); - } }, { key: '_getSequence', value() { - let e;if (this._startSequence < 2415919103) return e = this._startSequence, this._startSequence += 1, 2415919103 === this._startSequence && (this._startSequence = He()), e; - } }, { key: '_getRequestIDFromHead', value(e) { - return e.servcmd + e.seq; - } }, { key: '_getResponseKeyMap', value(e) { - const n = this._channelModule.getKeyMap(e);return t(t({}, vi.response), n.response); - } }, { key: '_reConnect', value() { - this._readyState !== Ai && this._readyState !== Oi && this.forcedReconnect(); - } }, { key: 'forcedReconnect', value() { - const e = this;Ee.log(''.concat(this._className, '.forcedReconnect count:').concat(this._reConnectCount, ' readyState:') - .concat(this._readyState)), this._reConnectFlag = !0, this._resetRandom(), this._reConnectCount < this.MAX_RECONNECT_COUNT ? (this._reConnectCount += 1, this._closeConnection(ki), this._initConnection()) : this._channelModule.probeNetwork().then(((t) => { - const n = m(t, 2); const o = n[0];n[1];o ? (Ee.warn(''.concat(e._className, '.forcedReconnect disconnected from wsserver but network is ok, continue...')), e._reConnectCount = 0, e._closeConnection(ki), e._initConnection()) : e._channelModule.onReconnectFailed(); - })); - } }, { key: 'getReconnectFlag', value() { - return this._reConnectFlag; - } }, { key: '_setNextPingTs', value() { - this._nextPingTs = Date.now() + 1e4; - } }, { key: 'getNextPingTs', value() { - return this._nextPingTs; - } }, { key: 'isConnected', value() { - return this._readyState === Ai; - } }, { key: '_getRandom', value() { - return 0 === this._random && (this._random = Math.random()), this._random; - } }, { key: '_resetRandom', value() { - this._random = 0; - } }, { key: 'close', value() { - Ee.log(''.concat(this._className, '.close')), this._closeConnection(Ei), this._promiseMap.clear(), this._startSequence = He(), this._readyState = Li, this._simpleRequestMap.clear(), this._reConnectFlag = !1, this._reConnectCount = 0, this._onOpenTs = 0, this._url = '', this._random = 0; - } }]), e; - }()); const Gi = (function (e) { - i(n, e);const t = f(n);function n(e) { - let a;if (o(this, n), (a = t.call(this, e))._className = 'ChannelModule', a._socketHandler = new Ri(h(a)), a._probing = !1, a._isAppShowing = !0, a._previousState = k.NET_STATE_CONNECTED, z && 'function' === typeof J.onAppShow && 'function' === typeof J.onAppHide) { - const s = a._onAppHide.bind(h(a)); const r = a._onAppShow.bind(h(a));'function' === typeof J.offAppHide && J.offAppHide(s), 'function' === typeof J.offAppShow && J.offAppShow(r), J.onAppHide(s), J.onAppShow(r); - } return a._timerForNotLoggedIn = -1, a._timerForNotLoggedIn = setInterval(a.onCheckTimer.bind(h(a)), 1e3), a._fatalErrorFlag = !1, a; - } return s(n, [{ key: 'onCheckTimer', value(e) { - this._socketHandler && (this.isLoggedIn() ? (this._timerForNotLoggedIn > 0 && (clearInterval(this._timerForNotLoggedIn), this._timerForNotLoggedIn = -1), this._socketHandler.onCheckTimer(e)) : this._socketHandler.onCheckTimer(1), this._checkNextPing()); - } }, { key: 'onErrorCodeNotZero', value(e) { - this.getModule(Kt).onErrorCodeNotZero(e); - } }, { key: 'onMessage', value(e) { - this.getModule(Kt).onMessage(e); - } }, { key: 'send', value(e) { - return this._previousState !== k.NET_STATE_CONNECTED && e.head.servcmd.includes(Hn) ? this._sendLogViaHTTP(e) : this._socketHandler.send(e); - } }, { key: '_sendLogViaHTTP', value(e) { - return new Promise(((t, n) => { - const o = 'https://webim.tim.qq.com/v4/imopenstat/tim_web_report_v2?sdkappid='.concat(e.head.sdkappid, '&reqtime=').concat(Date.now()); const a = JSON.stringify(e.body); const s = 'application/x-www-form-urlencoded;charset=UTF-8';if (z)J.request({ url: o, data: a, method: 'POST', timeout: 3e3, header: { 'content-type': s }, success() { - t(); - }, fail() { - n(new hr({ code: Zn.NETWORK_ERROR, message: ta })); - } });else { - const r = new XMLHttpRequest; const i = setTimeout((() => { - r.abort(), n(new hr({ code: Zn.NETWORK_TIMEOUT, message: na })); - }), 3e3);r.onreadystatechange = function () { - 4 === r.readyState && (clearTimeout(i), 200 === r.status || 304 === r.status ? t() : n(new hr({ code: Zn.NETWORK_ERROR, message: ta }))); - }, r.open('POST', o, !0), r.setRequestHeader('Content-type', s), r.send(a); - } - })); - } }, { key: 'simplySend', value(e) { - return this._socketHandler.simplySend(e); - } }, { key: 'onOpen', value() { - this._ping(); - } }, { key: 'onClose', value() { - this.reConnect(); - } }, { key: 'onError', value() { - Ee.error(''.concat(this._className, '.onError 从v2.11.2起,SDK 支持了 WebSocket,如您未添加相关受信域名,请先添加!升级指引: https://web.sdk.qcloud.com/im/doc/zh-cn/tutorial-02-upgradeguideline.html')); - } }, { key: 'getKeyMap', value(e) { - return this.getModule(Kt).getKeyMap(e); - } }, { key: '_onAppHide', value() { - this._isAppShowing = !1; - } }, { key: '_onAppShow', value() { - this._isAppShowing = !0; - } }, { key: 'onRequestTimeout', value(e) {} }, { key: 'onReconnected', value() { - Ee.log(''.concat(this._className, '.onReconnected')), this.getModule(Kt).onReconnected(), this._emitNetStateChangeEvent(k.NET_STATE_CONNECTED); - } }, { key: 'onReconnectFailed', value() { - Ee.log(''.concat(this._className, '.onReconnectFailed')), this._emitNetStateChangeEvent(k.NET_STATE_DISCONNECTED); - } }, { key: 'reConnect', value() { - if (!this._fatalErrorFlag && this._socketHandler) { - const e = this._socketHandler.getReconnectFlag();if (Ee.log(''.concat(this._className, '.reConnect state:').concat(this._previousState, ' reconnectFlag:') - .concat(e)), this._previousState === k.NET_STATE_CONNECTING && e) return;this._socketHandler.forcedReconnect(), this._emitNetStateChangeEvent(k.NET_STATE_CONNECTING); - } - } }, { key: '_emitNetStateChangeEvent', value(e) { - this._previousState !== e && (this._previousState = e, this.emitOuterEvent(E.NET_STATE_CHANGE, { state: e })); - } }, { key: '_ping', value() { - const e = this;if (!0 !== this._probing) { - this._probing = !0;const t = this.getModule(Kt).getProtocolData({ protocolName: jn });this.send(t).then((() => { - e._probing = !1; - })) - .catch(((t) => { - if (Ee.warn(''.concat(e._className, '._ping failed. error:'), t), e._probing = !1, t && 60002 === t.code) return new Da(Fs).setMessage('code:'.concat(t.code, ' message:').concat(t.message)) - .setNetworkType(e.getModule(bt).getNetworkType()) - .end(), e._fatalErrorFlag = !0, void e.emitOuterEvent(E.NET_STATE_CHANGE, k.NET_STATE_DISCONNECTED);e.probeNetwork().then(((t) => { - const n = m(t, 2); const o = n[0]; const a = n[1];Ee.log(''.concat(e._className, '._ping failed. isAppShowing:').concat(e._isAppShowing, ' online:') - .concat(o, ' networkType:') - .concat(a)), o ? e.reConnect() : e.emitOuterEvent(E.NET_STATE_CHANGE, k.NET_STATE_DISCONNECTED); - })); - })); - } - } }, { key: '_checkNextPing', value() { - this._socketHandler.isConnected() && (Date.now() >= this._socketHandler.getNextPingTs() && this._ping()); - } }, { key: 'dealloc', value() { - this._socketHandler && (this._socketHandler.close(), this._socketHandler = null), this._timerForNotLoggedIn > -1 && clearInterval(this._timerForNotLoggedIn); - } }, { key: 'reset', value() { - Ee.log(''.concat(this._className, '.reset')), this._previousState = k.NET_STATE_CONNECTED, this._probing = !1, this._fatalErrorFlag = !1, this._timerForNotLoggedIn = setInterval(this.onCheckTimer.bind(this), 1e3); - } }]), n; - }(Yt)); const wi = ['a2', 'tinyid']; const Pi = ['a2', 'tinyid']; const bi = (function () { - function e(t) { - o(this, e), this._className = 'ProtocolHandler', this._sessionModule = t, this._configMap = new Map, this._fillConfigMap(); - } return s(e, [{ key: '_fillConfigMap', value() { - this._configMap.clear();const e = this._sessionModule.genCommonHead(); const n = this._sessionModule.genCosSpecifiedHead(); const o = this._sessionModule.genSSOReportHead();this._configMap.set(zt, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.IM_OPEN_STATUS, '.').concat(U.CMD.LOGIN) }), body: { state: 'Online' }, keyMap: { response: { TinyId: 'tinyID', InstId: 'instanceID', HelloInterval: 'helloInterval' } } }; - }(e))), this._configMap.set(Wt, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.IM_OPEN_STATUS, '.').concat(U.CMD.LOGOUT) }), body: {} }; - }(e))), this._configMap.set(Jt, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.IM_OPEN_STATUS, '.').concat(U.CMD.HELLO) }), body: {}, keyMap: { response: { NewInstInfo: 'newInstanceInfo' } } }; - }(e))), this._configMap.set(xn, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.IM_COS_SIGN, '.').concat(U.CMD.COS_SIGN) }), body: { cmd: 'open_im_cos_svc', subCmd: 'get_cos_token', duration: 300, version: 2 }, keyMap: { request: { userSig: 'usersig', subCmd: 'sub_cmd', cmd: 'cmd', duration: 'duration', version: 'version' }, response: { expired_time: 'expiredTime', bucket_name: 'bucketName', session_token: 'sessionToken', tmp_secret_id: 'secretId', tmp_secret_key: 'secretKey' } } }; - }(n))), this._configMap.set(Bn, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.CUSTOM_UPLOAD, '.').concat(U.CMD.COS_PRE_SIG) }), body: { fileType: void 0, fileName: void 0, uploadMethod: 0, duration: 900 }, keyMap: { request: { userSig: 'usersig', fileType: 'file_type', fileName: 'file_name', uploadMethod: 'upload_method' }, response: { expired_time: 'expiredTime', request_id: 'requestId', head_url: 'headUrl', upload_url: 'uploadUrl', download_url: 'downloadUrl', ci_url: 'ciUrl' } } }; - }(n))), this._configMap.set(Xn, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.CLOUD_CONTROL, '.').concat(U.CMD.FETCH_CLOUD_CONTROL_CONFIG) }), body: { SDKAppID: 0, version: 0 }, keyMap: { request: { SDKAppID: 'uint32_sdkappid', version: 'uint64_version' }, response: { int32_error_code: 'errorCode', str_error_message: 'errorMessage', str_json_config: 'cloudControlConfig', uint32_expired_time: 'expiredTime', uint32_sdkappid: 'SDKAppID', uint64_version: 'version' } } }; - }(e))), this._configMap.set(Qn, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.CLOUD_CONTROL, '.').concat(U.CMD.PUSHED_CLOUD_CONTROL_CONFIG) }), body: {}, keyMap: { response: { int32_error_code: 'errorCode', str_error_message: 'errorMessage', str_json_config: 'cloudControlConfig', uint32_expired_time: 'expiredTime', uint32_sdkappid: 'SDKAppID', uint64_version: 'version' } } }; - }(e))), this._configMap.set(Xt, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.OPEN_IM, '.').concat(U.CMD.GET_MESSAGES) }), body: { cookie: '', syncFlag: 0, needAbstract: 1, isOnlineSync: 0 }, keyMap: { request: { fromAccount: 'From_Account', toAccount: 'To_Account', from: 'From_Account', to: 'To_Account', time: 'MsgTimeStamp', sequence: 'MsgSeq', random: 'MsgRandom', elements: 'MsgBody' }, response: { MsgList: 'messageList', SyncFlag: 'syncFlag', To_Account: 'to', From_Account: 'from', ClientSeq: 'clientSequence', MsgSeq: 'sequence', NoticeSeq: 'noticeSequence', NotifySeq: 'notifySequence', MsgRandom: 'random', MsgTimeStamp: 'time', MsgContent: 'content', ToGroupId: 'groupID', MsgKey: 'messageKey', GroupTips: 'groupTips', MsgBody: 'elements', MsgType: 'type', C2CRemainingUnreadCount: 'C2CRemainingUnreadList', C2CPairUnreadCount: 'C2CPairUnreadList' } } }; - }(e))), this._configMap.set(Qt, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.OPEN_IM, '.').concat(U.CMD.BIG_DATA_HALLWAY_AUTH_KEY) }), body: {} }; - }(e))), this._configMap.set(Zt, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.OPEN_IM, '.').concat(U.CMD.SEND_MESSAGE) }), body: { fromAccount: '', toAccount: '', msgTimeStamp: void 0, msgSeq: 0, msgRandom: 0, msgBody: [], cloudCustomData: void 0, nick: '', avatar: '', msgLifeTime: void 0, offlinePushInfo: { pushFlag: 0, title: '', desc: '', ext: '', apnsInfo: { badgeMode: 0 }, androidInfo: { OPPOChannelID: '' } } }, keyMap: { request: { fromAccount: 'From_Account', toAccount: 'To_Account', msgTimeStamp: 'MsgTimeStamp', msgSeq: 'MsgSeq', msgRandom: 'MsgRandom', msgBody: 'MsgBody', count: 'MaxCnt', lastMessageTime: 'LastMsgTime', messageKey: 'MsgKey', peerAccount: 'Peer_Account', data: 'Data', description: 'Desc', extension: 'Ext', type: 'MsgType', content: 'MsgContent', sizeType: 'Type', uuid: 'UUID', url: '', imageUrl: 'URL', fileUrl: 'Url', remoteAudioUrl: 'Url', remoteVideoUrl: 'VideoUrl', thumbUUID: 'ThumbUUID', videoUUID: 'VideoUUID', videoUrl: '', downloadFlag: 'Download_Flag', nick: 'From_AccountNick', avatar: 'From_AccountHeadurl', from: 'From_Account', time: 'MsgTimeStamp', messageRandom: 'MsgRandom', messageSequence: 'MsgSeq', elements: 'MsgBody', clientSequence: 'ClientSeq', payload: 'MsgContent', messageList: 'MsgList', messageNumber: 'MsgNum', abstractList: 'AbstractList', messageBody: 'MsgBody' } } }; - }(e))), this._configMap.set(en, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.GROUP, '.').concat(U.CMD.SEND_GROUP_MESSAGE) }), body: { fromAccount: '', groupID: '', random: 0, clientSequence: 0, priority: '', msgBody: [], cloudCustomData: void 0, onlineOnlyFlag: 0, offlinePushInfo: { pushFlag: 0, title: '', desc: '', ext: '', apnsInfo: { badgeMode: 0 }, androidInfo: { OPPOChannelID: '' } }, groupAtInfo: [] }, keyMap: { request: { to: 'GroupId', extension: 'Ext', data: 'Data', description: 'Desc', random: 'Random', sequence: 'ReqMsgSeq', count: 'ReqMsgNumber', type: 'MsgType', priority: 'MsgPriority', content: 'MsgContent', elements: 'MsgBody', sizeType: 'Type', uuid: 'UUID', url: '', imageUrl: 'URL', fileUrl: 'Url', remoteAudioUrl: 'Url', remoteVideoUrl: 'VideoUrl', thumbUUID: 'ThumbUUID', videoUUID: 'VideoUUID', videoUrl: '', downloadFlag: 'Download_Flag', clientSequence: 'ClientSeq', from: 'From_Account', time: 'MsgTimeStamp', messageRandom: 'MsgRandom', messageSequence: 'MsgSeq', payload: 'MsgContent', messageList: 'MsgList', messageNumber: 'MsgNum', abstractList: 'AbstractList', messageBody: 'MsgBody' }, response: { MsgTime: 'time', MsgSeq: 'sequence' } } }; - }(e))), this._configMap.set(rn, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.OPEN_IM, '.').concat(U.CMD.REVOKE_C2C_MESSAGE) }), body: { msgInfo: { fromAccount: '', toAccount: '', msgTimeStamp: 0, msgSeq: 0, msgRandom: 0 } }, keyMap: { request: { msgInfo: 'MsgInfo', msgTimeStamp: 'MsgTimeStamp', msgSeq: 'MsgSeq', msgRandom: 'MsgRandom' } } }; - }(e))), this._configMap.set(Nn, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.GROUP, '.').concat(U.CMD.REVOKE_GROUP_MESSAGE) }), body: { to: '', msgSeqList: void 0 }, keyMap: { request: { to: 'GroupId', msgSeqList: 'MsgSeqList', msgSeq: 'MsgSeq' } } }; - }(e))), this._configMap.set(un, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.OPEN_IM, '.').concat(U.CMD.GET_C2C_ROAM_MESSAGES) }), body: { peerAccount: '', count: 15, lastMessageTime: 0, messageKey: '', withRecalledMessage: 1 }, keyMap: { request: { messageKey: 'MsgKey', peerAccount: 'Peer_Account', count: 'MaxCnt', lastMessageTime: 'LastMsgTime', withRecalledMessage: 'WithRecalledMsg' } } }; - }(e))), this._configMap.set(On, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.GROUP, '.').concat(U.CMD.GET_GROUP_ROAM_MESSAGES) }), body: { withRecalledMsg: 1, groupID: '', count: 15, sequence: '' }, keyMap: { request: { sequence: 'ReqMsgSeq', count: 'ReqMsgNumber', withRecalledMessage: 'WithRecalledMsg' }, response: { Random: 'random', MsgTime: 'time', MsgSeq: 'sequence', ReqMsgSeq: 'sequence', RspMsgList: 'messageList', IsPlaceMsg: 'isPlaceMessage', IsSystemMsg: 'isSystemMessage', ToGroupId: 'to', EnumFrom_AccountType: 'fromAccountType', EnumTo_AccountType: 'toAccountType', GroupCode: 'groupCode', MsgPriority: 'priority', MsgBody: 'elements', MsgType: 'type', MsgContent: 'content', IsFinished: 'complete', Download_Flag: 'downloadFlag', ClientSeq: 'clientSequence', ThumbUUID: 'thumbUUID', VideoUUID: 'videoUUID' } } }; - }(e))), this._configMap.set(cn, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.OPEN_IM, '.').concat(U.CMD.SET_C2C_MESSAGE_READ) }), body: { C2CMsgReaded: void 0 }, keyMap: { request: { lastMessageTime: 'LastedMsgTime' } } }; - }(e))), this._configMap.set(An, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.GROUP, '.').concat(U.CMD.SET_GROUP_MESSAGE_READ) }), body: { groupID: void 0, messageReadSeq: void 0 }, keyMap: { request: { messageReadSeq: 'MsgReadedSeq' } } }; - }(e))), this._configMap.set(dn, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.OPEN_IM, '.').concat(U.CMD.DELETE_C2C_MESSAGE) }), body: { fromAccount: '', to: '', keyList: void 0 }, keyMap: { request: { keyList: 'MsgKeyList' } } }; - }(e))), this._configMap.set(bn, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.GROUP, '.').concat(U.CMD.DELETE_GROUP_MESSAGE) }), body: { groupID: '', deleter: '', keyList: void 0 }, keyMap: { request: { deleter: 'Deleter_Account', keyList: 'Seqs' } } }; - }(e))), this._configMap.set(ln, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.OPEN_IM, '.').concat(U.CMD.GET_PEER_READ_TIME) }), body: { userIDList: void 0 }, keyMap: { request: { userIDList: 'To_Account' }, response: { ReadTime: 'peerReadTimeList' } } }; - }(e))), this._configMap.set(pn, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.RECENT_CONTACT, '.').concat(U.CMD.GET_CONVERSATION_LIST) }), body: { fromAccount: void 0, count: 0 }, keyMap: { request: {}, response: { SessionItem: 'conversations', ToAccount: 'groupID', To_Account: 'userID', UnreadMsgCount: 'unreadCount', MsgGroupReadedSeq: 'messageReadSeq', C2cPeerReadTime: 'c2cPeerReadTime' } } }; - }(e))), this._configMap.set(gn, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.RECENT_CONTACT, '.').concat(U.CMD.PAGING_GET_CONVERSATION_LIST) }), body: { fromAccount: void 0, timeStamp: void 0, orderType: void 0, messageAssistFlag: 4 }, keyMap: { request: { messageAssistFlag: 'MsgAssistFlags' }, response: { SessionItem: 'conversations', ToAccount: 'groupID', To_Account: 'userID', UnreadMsgCount: 'unreadCount', MsgGroupReadedSeq: 'messageReadSeq', C2cPeerReadTime: 'c2cPeerReadTime', LastMsgFlags: 'lastMessageFlag' } } }; - }(e))), this._configMap.set(hn, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.RECENT_CONTACT, '.').concat(U.CMD.DELETE_CONVERSATION) }), body: { fromAccount: '', toAccount: void 0, type: 1, toGroupID: void 0 }, keyMap: { request: { toGroupID: 'ToGroupid' } } }; - }(e))), this._configMap.set(_n, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.OPEN_IM, '.').concat(U.CMD.DELETE_GROUP_AT_TIPS) }), body: { messageListToDelete: void 0 }, keyMap: { request: { messageListToDelete: 'DelMsgList', messageSeq: 'MsgSeq', messageRandom: 'MsgRandom' } } }; - }(e))), this._configMap.set(tn, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.PROFILE, '.').concat(U.CMD.PORTRAIT_GET) }), body: { fromAccount: '', userItem: [] }, keyMap: { request: { toAccount: 'To_Account', standardSequence: 'StandardSequence', customSequence: 'CustomSequence' } } }; - }(e))), this._configMap.set(nn, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.PROFILE, '.').concat(U.CMD.PORTRAIT_SET) }), body: { fromAccount: '', profileItem: [{ tag: Ks.NICK, value: '' }, { tag: Ks.GENDER, value: '' }, { tag: Ks.ALLOWTYPE, value: '' }, { tag: Ks.AVATAR, value: '' }] }, keyMap: { request: { toAccount: 'To_Account', standardSequence: 'StandardSequence', customSequence: 'CustomSequence' } } }; - }(e))), this._configMap.set(on, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.FRIEND, '.').concat(U.CMD.GET_BLACKLIST) }), body: { fromAccount: '', startIndex: 0, maxLimited: 30, lastSequence: 0 }, keyMap: { response: { CurruentSequence: 'currentSequence' } } }; - }(e))), this._configMap.set(an, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.FRIEND, '.').concat(U.CMD.ADD_BLACKLIST) }), body: { fromAccount: '', toAccount: [] } }; - }(e))), this._configMap.set(sn, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.FRIEND, '.').concat(U.CMD.DELETE_BLACKLIST) }), body: { fromAccount: '', toAccount: [] } }; - }(e))), this._configMap.set(fn, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.GROUP, '.').concat(U.CMD.GET_JOINED_GROUPS) }), body: { memberAccount: '', limit: void 0, offset: void 0, groupType: void 0, responseFilter: { groupBaseInfoFilter: void 0, selfInfoFilter: void 0 } }, keyMap: { request: { memberAccount: 'Member_Account' }, response: { GroupIdList: 'groups', MsgFlag: 'messageRemindType' } } }; - }(e))), this._configMap.set(mn, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.GROUP, '.').concat(U.CMD.GET_GROUP_INFO) }), body: { groupIDList: void 0, responseFilter: { groupBaseInfoFilter: ['Type', 'Name', 'Introduction', 'Notification', 'FaceUrl', 'Owner_Account', 'CreateTime', 'InfoSeq', 'LastInfoTime', 'LastMsgTime', 'MemberNum', 'MaxMemberNum', 'ApplyJoinOption', 'NextMsgSeq', 'ShutUpAllMember'], groupCustomFieldFilter: void 0, memberInfoFilter: void 0, memberCustomFieldFilter: void 0 } }, keyMap: { request: { groupIDList: 'GroupIdList', groupCustomField: 'AppDefinedData', memberCustomField: 'AppMemberDefinedData', groupCustomFieldFilter: 'AppDefinedDataFilter_Group', memberCustomFieldFilter: 'AppDefinedDataFilter_GroupMember' }, response: { GroupIdList: 'groups', MsgFlag: 'messageRemindType', AppDefinedData: 'groupCustomField', AppMemberDefinedData: 'memberCustomField', AppDefinedDataFilter_Group: 'groupCustomFieldFilter', AppDefinedDataFilter_GroupMember: 'memberCustomFieldFilter', InfoSeq: 'infoSequence', MemberList: 'members', GroupInfo: 'groups', ShutUpUntil: 'muteUntil', ShutUpAllMember: 'muteAllMembers', ApplyJoinOption: 'joinOption' } } }; - }(e))), this._configMap.set(Mn, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.GROUP, '.').concat(U.CMD.CREATE_GROUP) }), body: { type: void 0, name: void 0, groupID: void 0, ownerID: void 0, introduction: void 0, notification: void 0, maxMemberNum: void 0, joinOption: void 0, memberList: void 0, groupCustomField: void 0, memberCustomField: void 0, webPushFlag: 1, avatar: 'FaceUrl' }, keyMap: { request: { ownerID: 'Owner_Account', userID: 'Member_Account', avatar: 'FaceUrl', maxMemberNum: 'MaxMemberCount', joinOption: 'ApplyJoinOption', groupCustomField: 'AppDefinedData', memberCustomField: 'AppMemberDefinedData' }, response: { HugeGroupFlag: 'avChatRoomFlag', OverJoinedGroupLimit_Account: 'overLimitUserIDList' } } }; - }(e))), this._configMap.set(vn, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.GROUP, '.').concat(U.CMD.DESTROY_GROUP) }), body: { groupID: void 0 } }; - }(e))), this._configMap.set(yn, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.GROUP, '.').concat(U.CMD.MODIFY_GROUP_INFO) }), body: { groupID: void 0, name: void 0, introduction: void 0, notification: void 0, avatar: void 0, maxMemberNum: void 0, joinOption: void 0, groupCustomField: void 0, muteAllMembers: void 0 }, keyMap: { request: { maxMemberNum: 'MaxMemberCount', groupCustomField: 'AppDefinedData', muteAllMembers: 'ShutUpAllMember', joinOption: 'ApplyJoinOption', avatar: 'FaceUrl' }, response: { AppDefinedData: 'groupCustomField', ShutUpAllMember: 'muteAllMembers', ApplyJoinOption: 'joinOption' } } }; - }(e))), this._configMap.set(In, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.GROUP, '.').concat(U.CMD.APPLY_JOIN_GROUP) }), body: { groupID: void 0, applyMessage: void 0, userDefinedField: void 0, webPushFlag: 1 }, keyMap: { response: { HugeGroupFlag: 'avChatRoomFlag' } } }; - }(e))), this._configMap.set(Dn, (function (e) { - e.a2, e.tinyid;return { head: t(t({}, p(e, wi)), {}, { servcmd: ''.concat(U.NAME.BIG_GROUP_NO_AUTH, '.').concat(U.CMD.APPLY_JOIN_GROUP) }), body: { groupID: void 0, applyMessage: void 0, userDefinedField: void 0, webPushFlag: 1 }, keyMap: { response: { HugeGroupFlag: 'avChatRoomFlag' } } }; - }(e))), this._configMap.set(Tn, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.GROUP, '.').concat(U.CMD.QUIT_GROUP) }), body: { groupID: void 0 } }; - }(e))), this._configMap.set(Sn, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.GROUP, '.').concat(U.CMD.SEARCH_GROUP_BY_ID) }), body: { groupIDList: void 0, responseFilter: { groupBasePublicInfoFilter: ['Type', 'Name', 'Introduction', 'Notification', 'FaceUrl', 'CreateTime', 'Owner_Account', 'LastInfoTime', 'LastMsgTime', 'NextMsgSeq', 'MemberNum', 'MaxMemberNum', 'ApplyJoinOption'] } }, keyMap: { response: { ApplyJoinOption: 'joinOption' } } }; - }(e))), this._configMap.set(En, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.GROUP, '.').concat(U.CMD.CHANGE_GROUP_OWNER) }), body: { groupID: void 0, newOwnerID: void 0 }, keyMap: { request: { newOwnerID: 'NewOwner_Account' } } }; - }(e))), this._configMap.set(kn, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.GROUP, '.').concat(U.CMD.HANDLE_APPLY_JOIN_GROUP) }), body: { groupID: void 0, applicant: void 0, handleAction: void 0, handleMessage: void 0, authentication: void 0, messageKey: void 0, userDefinedField: void 0 }, keyMap: { request: { applicant: 'Applicant_Account', handleAction: 'HandleMsg', handleMessage: 'ApprovalMsg', messageKey: 'MsgKey' } } }; - }(e))), this._configMap.set(Cn, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.GROUP, '.').concat(U.CMD.HANDLE_GROUP_INVITATION) }), body: { groupID: void 0, inviter: void 0, handleAction: void 0, handleMessage: void 0, authentication: void 0, messageKey: void 0, userDefinedField: void 0 }, keyMap: { request: { inviter: 'Inviter_Account', handleAction: 'HandleMsg', handleMessage: 'ApprovalMsg', messageKey: 'MsgKey' } } }; - }(e))), this._configMap.set(Ln, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.GROUP, '.').concat(U.CMD.GET_GROUP_APPLICATION) }), body: { startTime: void 0, limit: void 0, handleAccount: void 0 }, keyMap: { request: { handleAccount: 'Handle_Account' } } }; - }(e))), this._configMap.set(Rn, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.OPEN_IM, '.').concat(U.CMD.DELETE_GROUP_SYSTEM_MESSAGE) }), body: { messageListToDelete: void 0 }, keyMap: { request: { messageListToDelete: 'DelMsgList', messageSeq: 'MsgSeq', messageRandom: 'MsgRandom' } } }; - }(e))), this._configMap.set(Gn, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.BIG_GROUP_LONG_POLLING, '.').concat(U.CMD.AVCHATROOM_LONG_POLL) }), body: { USP: 1, startSeq: 1, holdTime: 90, key: void 0 }, keyMap: { request: { USP: 'USP' }, response: { ToGroupId: 'groupID' } } }; - }(e))), this._configMap.set(wn, (function (e) { - e.a2, e.tinyid;return { head: t(t({}, p(e, Pi)), {}, { servcmd: ''.concat(U.NAME.BIG_GROUP_LONG_POLLING_NO_AUTH, '.').concat(U.CMD.AVCHATROOM_LONG_POLL) }), body: { USP: 1, startSeq: 1, holdTime: 90, key: void 0 }, keyMap: { request: { USP: 'USP' }, response: { ToGroupId: 'groupID' } } }; - }(e))), this._configMap.set(Pn, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.GROUP, '.').concat(U.CMD.GET_ONLINE_MEMBER_NUM) }), body: { groupID: void 0 } }; - }(e))), this._configMap.set(Un, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.GROUP, '.').concat(U.CMD.GET_GROUP_MEMBER_LIST) }), body: { groupID: void 0, limit: 0, offset: 0, memberRoleFilter: void 0, memberInfoFilter: ['Role', 'NameCard', 'ShutUpUntil', 'JoinTime'], memberCustomFieldFilter: void 0 }, keyMap: { request: { memberCustomFieldFilter: 'AppDefinedDataFilter_GroupMember' }, response: { AppMemberDefinedData: 'memberCustomField', AppDefinedDataFilter_GroupMember: 'memberCustomFieldFilter', MemberList: 'members' } } }; - }(e))), this._configMap.set(Fn, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.GROUP, '.').concat(U.CMD.GET_GROUP_MEMBER_INFO) }), body: { groupID: void 0, userIDList: void 0, memberInfoFilter: void 0, memberCustomFieldFilter: void 0 }, keyMap: { request: { userIDList: 'Member_List_Account', memberCustomFieldFilter: 'AppDefinedDataFilter_GroupMember' }, response: { MemberList: 'members', ShutUpUntil: 'muteUntil', AppDefinedDataFilter_GroupMember: 'memberCustomFieldFilter', AppMemberDefinedData: 'memberCustomField' } } }; - }(e))), this._configMap.set(qn, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.GROUP, '.').concat(U.CMD.ADD_GROUP_MEMBER) }), body: { groupID: void 0, silence: void 0, userIDList: void 0 }, keyMap: { request: { userID: 'Member_Account', userIDList: 'MemberList' }, response: { MemberList: 'members' } } }; - }(e))), this._configMap.set(Vn, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.GROUP, '.').concat(U.CMD.DELETE_GROUP_MEMBER) }), body: { groupID: void 0, userIDList: void 0, reason: void 0 }, keyMap: { request: { userIDList: 'MemberToDel_Account' } } }; - }(e))), this._configMap.set(Kn, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.GROUP, '.').concat(U.CMD.MODIFY_GROUP_MEMBER_INFO) }), body: { groupID: void 0, userID: void 0, messageRemindType: void 0, nameCard: void 0, role: void 0, memberCustomField: void 0, muteTime: void 0 }, keyMap: { request: { userID: 'Member_Account', memberCustomField: 'AppMemberDefinedData', muteTime: 'ShutUpTime', messageRemindType: 'MsgFlag' } } }; - }(e))), this._configMap.set(Hn, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.IM_OPEN_STAT, '.').concat(U.CMD.TIM_WEB_REPORT_V2) }), body: { header: {}, event: [], quality: [] }, keyMap: { request: { SDKType: 'sdk_type', SDKVersion: 'sdk_version', deviceType: 'device_type', platform: 'platform', instanceID: 'instance_id', traceID: 'trace_id', SDKAppID: 'sdk_app_id', userID: 'user_id', tinyID: 'tiny_id', extension: 'extension', timestamp: 'timestamp', networkType: 'network_type', eventType: 'event_type', code: 'error_code', message: 'error_message', moreMessage: 'more_message', duplicate: 'duplicate', costTime: 'cost_time', level: 'level', qualityType: 'quality_type', reportIndex: 'report_index', wholePeriod: 'whole_period', totalCount: 'total_count', rttCount: 'success_count_business', successRateOfRequest: 'percent_business', countLessThan1Second: 'success_count_business', percentOfCountLessThan1Second: 'percent_business', countLessThan3Second: 'success_count_platform', percentOfCountLessThan3Second: 'percent_platform', successCountOfBusiness: 'success_count_business', successRateOfBusiness: 'percent_business', successCountOfPlatform: 'success_count_platform', successRateOfPlatform: 'percent_platform', successCountOfMessageReceived: 'success_count_business', successRateOfMessageReceived: 'percent_business', avgRTT: 'average_value', avgDelay: 'average_value', avgValue: 'average_value' } } }; - }(o))), this._configMap.set(jn, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.HEARTBEAT, '.').concat(U.CMD.ALIVE) }), body: {} }; - }(e))), this._configMap.set($n, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.IM_OPEN_PUSH, '.').concat(U.CMD.MESSAGE_PUSH) }), body: {}, keyMap: { response: { C2cMsgArray: 'C2CMessageArray', GroupMsgArray: 'groupMessageArray', GroupTips: 'groupTips', C2cNotifyMsgArray: 'C2CNotifyMessageArray', ClientSeq: 'clientSequence', MsgPriority: 'priority', NoticeSeq: 'noticeSequence', MsgContent: 'content', MsgType: 'type', MsgBody: 'elements', ToGroupId: 'to', Desc: 'description', Ext: 'extension', IsSyncMsg: 'isSyncMessage', Flag: 'needSync', NeedAck: 'needAck', PendencyAdd_Account: 'userID', ProfileImNick: 'nick', PendencyType: 'applicationType' } } }; - }(e))), this._configMap.set(Yn, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.OPEN_IM, '.').concat(U.CMD.MESSAGE_PUSH_ACK) }), body: { sessionData: void 0 }, keyMap: { request: { sessionData: 'SessionData' } } }; - }(e))), this._configMap.set(zn, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.IM_OPEN_STATUS, '.').concat(U.CMD.STATUS_FORCEOFFLINE) }), body: {}, keyMap: { response: { C2cNotifyMsgArray: 'C2CNotifyMessageArray', NoticeSeq: 'noticeSequence', KickoutMsgNotify: 'kickoutMsgNotify', NewInstInfo: 'newInstanceInfo' } } }; - }(e))), this._configMap.set(Jn, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.IM_LONG_MESSAGE, '.').concat(U.CMD.DOWNLOAD_MERGER_MESSAGE) }), body: { downloadKey: '' }, keyMap: { response: { Data: 'data', Desc: 'description', Ext: 'extension', Download_Flag: 'downloadFlag', ThumbUUID: 'thumbUUID', VideoUUID: 'videoUUID' } } }; - }(e))), this._configMap.set(Wn, (function (e) { - return { head: t(t({}, e), {}, { servcmd: ''.concat(U.NAME.IM_LONG_MESSAGE, '.').concat(U.CMD.UPLOAD_MERGER_MESSAGE) }), body: { messageList: [] }, keyMap: { request: { fromAccount: 'From_Account', toAccount: 'To_Account', msgTimeStamp: 'MsgTimeStamp', msgSeq: 'MsgSeq', msgRandom: 'MsgRandom', msgBody: 'MsgBody', type: 'MsgType', content: 'MsgContent', data: 'Data', description: 'Desc', extension: 'Ext', sizeType: 'Type', uuid: 'UUID', url: '', imageUrl: 'URL', fileUrl: 'Url', remoteAudioUrl: 'Url', remoteVideoUrl: 'VideoUrl', thumbUUID: 'ThumbUUID', videoUUID: 'VideoUUID', videoUrl: '', downloadFlag: 'Download_Flag', from: 'From_Account', time: 'MsgTimeStamp', messageRandom: 'MsgRandom', messageSequence: 'MsgSeq', elements: 'MsgBody', clientSequence: 'ClientSeq', payload: 'MsgContent', messageList: 'MsgList', messageNumber: 'MsgNum', abstractList: 'AbstractList', messageBody: 'MsgBody' } } }; - }(e))); - } }, { key: 'has', value(e) { - return this._configMap.has(e); - } }, { key: 'get', value(e) { - return this._configMap.get(e); - } }, { key: 'update', value() { - this._fillConfigMap(); - } }, { key: 'getKeyMap', value(e) { - return this.has(e) ? this.get(e).keyMap || {} : (Ee.warn(''.concat(this._className, '.getKeyMap unknown protocolName:').concat(e)), {}); - } }, { key: 'getProtocolData', value(e) { - const t = e.protocolName; const n = e.requestData; const o = this.get(t); let a = null;if (n) { - const s = this._simpleDeepCopy(o); const r = s.body; const i = Object.create(null);for (const c in r) if (Object.prototype.hasOwnProperty.call(r, c)) { - if (i[c] = r[c], void 0 === n[c]) continue;i[c] = n[c]; - }s.body = i, a = this._getUplinkData(s); - } else a = this._getUplinkData(o);return a; - } }, { key: '_getUplinkData', value(e) { - const t = this._requestDataCleaner(e); const n = ct(t.head); const o = Di(t.body, this._getRequestKeyMap(n));return t.body = o, t; - } }, { key: '_getRequestKeyMap', value(e) { - const n = this.getKeyMap(e);return t(t({}, vi.request), n.request); - } }, { key: '_requestDataCleaner', value(e) { - const t = Array.isArray(e) ? [] : Object.create(null);for (const o in e)Object.prototype.hasOwnProperty.call(e, o) && Fe(o) && null !== e[o] && void 0 !== e[o] && ('object' !== n(e[o]) ? t[o] = e[o] : t[o] = this._requestDataCleaner.bind(this)(e[o]));return t; - } }, { key: '_simpleDeepCopy', value(e) { - for (var t, n = Object.keys(e), o = {}, a = 0, s = n.length;a < s;a++)t = n[a], Re(e[t]) ? o[t] = Array.from(e[t]) : Oe(e[t]) ? o[t] = this._simpleDeepCopy(e[t]) : o[t] = e[t];return o; - } }]), e; - }()); const Ui = [Yn]; const Fi = (function () { - function e(t) { - o(this, e), this._sessionModule = t, this._className = 'DownlinkHandler', this._eventHandlerMap = new Map, this._eventHandlerMap.set('C2CMessageArray', this._c2cMessageArrayHandler.bind(this)), this._eventHandlerMap.set('groupMessageArray', this._groupMessageArrayHandler.bind(this)), this._eventHandlerMap.set('groupTips', this._groupTipsHandler.bind(this)), this._eventHandlerMap.set('C2CNotifyMessageArray', this._C2CNotifyMessageArrayHandler.bind(this)), this._eventHandlerMap.set('profileModify', this._profileHandler.bind(this)), this._eventHandlerMap.set('friendListMod', this._relationChainHandler.bind(this)), this._keys = M(this._eventHandlerMap.keys()); - } return s(e, [{ key: '_c2cMessageArrayHandler', value(e) { - const t = this._sessionModule.getModule(Nt);if (t) { - if (e.dataList.forEach(((e) => { - if (1 === e.isSyncMessage) { - const t = e.from;e.from = e.to, e.to = t; - } - })), 1 === e.needSync) this._sessionModule.getModule(Vt).startOnlineSync();t.onNewC2CMessage({ dataList: e.dataList, isInstantMessage: !0 }); - } - } }, { key: '_groupMessageArrayHandler', value(e) { - const t = this._sessionModule.getModule(At);t && t.onNewGroupMessage({ event: e.event, dataList: e.dataList, isInstantMessage: !0 }); - } }, { key: '_groupTipsHandler', value(e) { - const t = this._sessionModule.getModule(At);if (t) { - const n = e.event; const o = e.dataList; const a = e.isInstantMessage; const s = void 0 === a || a; const r = e.isSyncingEnded;switch (n) { - case 4:case 6:t.onNewGroupTips({ event: n, dataList: o });break;case 5:o.forEach(((e) => { - Re(e.elements.revokedInfos) ? t.onGroupMessageRevoked({ dataList: o }) : Re(e.elements.groupMessageReadNotice) ? t.onGroupMessageReadNotice({ dataList: o }) : t.onNewGroupSystemNotice({ dataList: o, isInstantMessage: s, isSyncingEnded: r }); - }));break;case 12:this._sessionModule.getModule(Rt).onNewGroupAtTips({ dataList: o });break;default:Ee.log(''.concat(this._className, '._groupTipsHandler unknown event:').concat(n, ' dataList:'), o); - } - } - } }, { key: '_C2CNotifyMessageArrayHandler', value(e) { - const t = this; const n = e.dataList;if (Re(n)) { - const o = this._sessionModule.getModule(Nt);n.forEach(((e) => { - if (Le(e)) if (e.hasOwnProperty('kickoutMsgNotify')) { - const a = e.kickoutMsgNotify; const s = a.kickType; const r = a.newInstanceInfo; const i = void 0 === r ? {} : r;1 === s ? t._sessionModule.onMultipleAccountKickedOut(i) : 2 === s && t._sessionModule.onMultipleDeviceKickedOut(i); - } else e.hasOwnProperty('c2cMessageRevokedNotify') ? o && o.onC2CMessageRevoked({ dataList: n }) : e.hasOwnProperty('c2cMessageReadReceipt') ? o && o.onC2CMessageReadReceipt({ dataList: n }) : e.hasOwnProperty('c2cMessageReadNotice') && o && o.onC2CMessageReadNotice({ dataList: n }); - })); - } - } }, { key: '_profileHandler', value(e) { - this._sessionModule.getModule(Ct).onProfileModified({ dataList: e.dataList });const t = this._sessionModule.getModule(Ot);t && t.onFriendProfileModified({ dataList: e.dataList }); - } }, { key: '_relationChainHandler', value(e) { - this._sessionModule.getModule(Ct).onRelationChainModified({ dataList: e.dataList });const t = this._sessionModule.getModule(Ot);t && t.onRelationChainModified({ dataList: e.dataList }); - } }, { key: '_cloudControlConfigHandler', value(e) { - this._sessionModule.getModule(Ht).onPushedCloudControlConfig(e); - } }, { key: 'onMessage', value(e) { - const t = this; const n = e.head; const o = e.body;if (this._isPushedCloudControlConfig(n)) this._cloudControlConfigHandler(o);else { - const a = o.eventArray; const s = o.isInstantMessage; const r = o.isSyncingEnded; const i = o.needSync;if (Re(a)) for (let c = null, u = null, l = 0, d = 0, g = a.length;d < g;d++) { - l = (c = a[d]).event;const p = Object.keys(c).find((e => -1 !== t._keys.indexOf(e)));p ? (u = c[p], this._eventHandlerMap.get(p)({ event: l, dataList: u, isInstantMessage: s, isSyncingEnded: r, needSync: i })) : Ee.log(''.concat(this._className, '.onMessage unknown eventItem:').concat(c)); - } - } - } }, { key: '_isPushedCloudControlConfig', value(e) { - return e.servcmd && e.servcmd.includes(Qn); - } }]), e; - }()); const qi = (function (e) { - i(n, e);const t = f(n);function n(e) { - let a;return o(this, n), (a = t.call(this, e))._className = 'SessionModule', a._platform = a.getPlatform(), a._protocolHandler = new bi(h(a)), a._messageDispatcher = new Fi(h(a)), a; - } return s(n, [{ key: 'updateProtocolConfig', value() { - this._protocolHandler.update(); - } }, { key: 'request', value(e) { - Ee.debug(''.concat(this._className, '.request options:'), e);const t = e.protocolName; const n = e.tjgID;if (!this._protocolHandler.has(t)) return Ee.warn(''.concat(this._className, '.request unknown protocol:').concat(t)), Mr({ code: Zn.CANNOT_FIND_PROTOCOL, message: sa });const o = this.getProtocolData(e);dt(n) || (o.head.tjgID = n);const a = this.getModule(xt);return Ui.includes(t) ? a.simplySend(o) : a.send(o); - } }, { key: 'getKeyMap', value(e) { - return this._protocolHandler.getKeyMap(e); - } }, { key: 'genCommonHead', value() { - const e = this.getModule(Gt);return { ver: 'v4', platform: this._platform, websdkappid: G, websdkversion: R, a2: e.getA2Key() || void 0, tinyid: e.getTinyID() || void 0, status_instid: e.getStatusInstanceID(), sdkappid: e.getSDKAppID(), contenttype: e.getContentType(), reqtime: 0, identifier: e.getA2Key() ? void 0 : e.getUserID(), usersig: e.getA2Key() ? void 0 : e.getUserSig(), sdkability: 2, tjgID: '' }; - } }, { key: 'genCosSpecifiedHead', value() { - const e = this.getModule(Gt);return { ver: 'v4', platform: this._platform, websdkappid: G, websdkversion: R, sdkappid: e.getSDKAppID(), contenttype: e.getContentType(), reqtime: 0, identifier: e.getUserID(), usersig: e.getUserSig(), status_instid: e.getStatusInstanceID(), sdkability: 2 }; - } }, { key: 'genSSOReportHead', value() { - const e = this.getModule(Gt);return { ver: 'v4', platform: this._platform, websdkappid: G, websdkversion: R, sdkappid: e.getSDKAppID(), contenttype: '', reqtime: 0, identifier: '', usersig: '', status_instid: e.getStatusInstanceID(), sdkability: 2 }; - } }, { key: 'getProtocolData', value(e) { - return this._protocolHandler.getProtocolData(e); - } }, { key: 'onErrorCodeNotZero', value(e) { - const t = e.errorCode;if (t === Zn.HELLO_ANSWER_KICKED_OUT) { - const n = e.kickType; const o = e.newInstanceInfo; const a = void 0 === o ? {} : o;1 === n ? this.onMultipleAccountKickedOut(a) : 2 === n && this.onMultipleDeviceKickedOut(a); - }t !== Zn.MESSAGE_A2KEY_EXPIRED && t !== Zn.ACCOUNT_A2KEY_EXPIRED || (this._onUserSigExpired(), this.getModule(xt).reConnect()); - } }, { key: 'onMessage', value(e) { - const t = e.body; const n = t.needAck; const o = void 0 === n ? 0 : n; const a = t.sessionData;1 === o && this._sendACK(a), this._messageDispatcher.onMessage(e); - } }, { key: 'onReconnected', value() { - const e = this;this.isLoggedIn() && this.request({ protocolName: zt }).then(((t) => { - const n = t.data.instanceID;e.getModule(Gt).setStatusInstanceID(n), e.getModule(jt).startPull(); - })); - } }, { key: 'onMultipleAccountKickedOut', value(e) { - this.getModule(Et).onMultipleAccountKickedOut(e); - } }, { key: 'onMultipleDeviceKickedOut', value(e) { - this.getModule(Et).onMultipleDeviceKickedOut(e); - } }, { key: '_onUserSigExpired', value() { - this.getModule(Et).onUserSigExpired(); - } }, { key: '_sendACK', value(e) { - this.request({ protocolName: Yn, requestData: { sessionData: e } }); - } }]), n; - }(Yt)); const Vi = (function (e) { - i(n, e);const t = f(n);function n(e) { - let a;return o(this, n), (a = t.call(this, e))._className = 'MessageLossDetectionModule', a._maybeLostSequencesMap = new Map, a; - } return s(n, [{ key: 'onMessageMaybeLost', value(e, t, n) { - this._maybeLostSequencesMap.has(e) || this._maybeLostSequencesMap.set(e, []);for (var o = this._maybeLostSequencesMap.get(e), a = 0;a < n;a++)o.push(t + a);Ee.debug(''.concat(this._className, '.onMessageMaybeLost. maybeLostSequences:').concat(o)); - } }, { key: 'detectMessageLoss', value(e, t) { - const n = this._maybeLostSequencesMap.get(e);if (!dt(n) && !dt(t)) { - const o = t.filter((e => -1 !== n.indexOf(e)));if (Ee.debug(''.concat(this._className, '.detectMessageLoss. matchedSequences:').concat(o)), n.length === o.length)Ee.info(''.concat(this._className, '.detectMessageLoss no message loss. conversationID:').concat(e));else { - let a; const s = n.filter((e => -1 === o.indexOf(e))); const r = s.length;r <= 5 ? a = `${e}-${s.join('-')}` : (s.sort(((e, t) => e - t)), a = `${e} start:${s[0]} end:${s[r - 1]} count:${r}`), new Da(Ns).setMessage(a) - .setNetworkType(this.getNetworkType()) - .setLevel('warning') - .end(), Ee.warn(''.concat(this._className, '.detectMessageLoss message loss detected. conversationID:').concat(e, ' lostSequences:') - .concat(s)); - }n.length = 0; - } - } }, { key: 'reset', value() { - Ee.log(''.concat(this._className, '.reset')), this._maybeLostSequencesMap.clear(); - } }]), n; - }(Yt)); const Ki = (function (e) { - i(n, e);const t = f(n);function n(e) { - let a;return o(this, n), (a = t.call(this, e))._className = 'CloudControlModule', a._cloudConfig = new Map, a._expiredTime = 0, a._version = 0, a._isFetching = !1, a; - } return s(n, [{ key: 'getCloudConfig', value(e) { - return Ge(e) ? this._cloudConfig : this._cloudConfig.has(e) ? this._cloudConfig.get(e) : void 0; - } }, { key: '_canFetchConfig', value() { - return this.isLoggedIn() && !this._isFetching && Date.now() >= this._expiredTime; - } }, { key: 'fetchConfig', value() { - const e = this; const t = this._canFetchConfig();if (Ee.log(''.concat(this._className, '.fetchConfig canFetchConfig:').concat(t)), t) { - const n = new Da(bs); const o = this.getModule(Gt).getSDKAppID();this._isFetching = !0, this.request({ protocolName: Xn, requestData: { SDKAppID: o, version: this._version } }).then(((t) => { - e._isFetching = !1, n.setMessage('version:'.concat(e._version, ' newVersion:').concat(t.data.version, ' config:') - .concat(t.data.cloudControlConfig)).setNetworkType(e.getNetworkType()) - .end(), Ee.log(''.concat(e._className, '.fetchConfig ok')), e._parseCloudControlConfig(t.data); - })) - .catch(((t) => { - e._isFetching = !1, e.probeNetwork().then(((e) => { - const o = m(e, 2); const a = o[0]; const s = o[1];n.setError(t, a, s).end(); - })), Ee.log(''.concat(e._className, '.fetchConfig failed. error:'), t), e._setExpiredTimeOnResponseError(12e4); - })); - } - } }, { key: 'onPushedCloudControlConfig', value(e) { - Ee.log(''.concat(this._className, '.onPushedCloudControlConfig')), new Da(Us).setNetworkType(this.getNetworkType()) - .setMessage('newVersion:'.concat(e.version, ' config:').concat(e.cloudControlConfig)) - .end(), this._parseCloudControlConfig(e); - } }, { key: 'onCheckTimer', value(e) { - this._canFetchConfig() && this.fetchConfig(); - } }, { key: '_parseCloudControlConfig', value(e) { - const t = this; const n = ''.concat(this._className, '._parseCloudControlConfig'); const o = e.errorCode; const a = e.errorMessage; const s = e.cloudControlConfig; const r = e.version; const i = e.expiredTime;if (0 === o) { - if (this._version !== r) { - let c = null;try { - c = JSON.parse(s); - } catch (u) { - Ee.error(''.concat(n, ' JSON parse error:').concat(s)); - }c && (this._cloudConfig.clear(), Object.keys(c).forEach(((e) => { - t._cloudConfig.set(e, c[e]); - })), this._version = r, this.emitInnerEvent(Ir.CLOUD_CONFIG_UPDATED)); - } this._expiredTime = Date.now() + 1e3 * i; - } else Ge(o) ? (Ee.log(''.concat(n, ' failed. Invalid message format:'), e), this._setExpiredTimeOnResponseError(36e5)) : (Ee.error(''.concat(n, ' errorCode:').concat(o, ' errorMessage:') - .concat(a)), this._setExpiredTimeOnResponseError(12e4)); - } }, { key: '_setExpiredTimeOnResponseError', value(e) { - this._expiredTime = Date.now() + e; - } }, { key: 'reset', value() { - Ee.log(''.concat(this._className, '.reset')), this._cloudConfig.clear(), this._expiredTime = 0, this._version = 0, this._isFetching = !1; - } }]), n; - }(Yt)); const xi = (function (e) { - i(n, e);const t = f(n);function n(e) { - let a;return o(this, n), (a = t.call(this, e))._className = 'PullGroupMessageModule', a._remoteLastMessageSequenceMap = new Map, a.PULL_LIMIT_COUNT = 15, a; - } return s(n, [{ key: 'startPull', value() { - const e = this; const t = this._getNeedPullConversationList();this._getRemoteLastMessageSequenceList().then((() => { - const n = e.getModule(Rt);t.forEach(((t) => { - const o = t.conversationID; const a = o.replace(k.CONV_GROUP, ''); const s = n.getGroupLocalLastMessageSequence(o); const r = e._remoteLastMessageSequenceMap.get(a) || 0; const i = r - s;Ee.log(''.concat(e._className, '.startPull groupID:').concat(a, ' localLastMessageSequence:') - .concat(s, ' ') + 'remoteLastMessageSequence:'.concat(r, ' diff:').concat(i)), s > 0 && i > 1 && i < 300 && e._pullMissingMessage({ groupID: a, localLastMessageSequence: s, remoteLastMessageSequence: r, diff: i }); - })); - })); - } }, { key: '_getNeedPullConversationList', value() { - return this.getModule(Rt).getLocalConversationList() - .filter((e => e.type === k.CONV_GROUP && e.groupProfile.type !== k.GRP_AVCHATROOM)); - } }, { key: '_getRemoteLastMessageSequenceList', value() { - const e = this;return this.getModule(At).getGroupList() - .then(((t) => { - for (let n = t.data.groupList, o = void 0 === n ? [] : n, a = 0;a < o.length;a++) { - const s = o[a]; const r = s.groupID; const i = s.nextMessageSeq;if (s.type !== k.GRP_AVCHATROOM) { - const c = i - 1;e._remoteLastMessageSequenceMap.set(r, c); - } - } - })); - } }, { key: '_pullMissingMessage', value(e) { - const t = this; const n = e.localLastMessageSequence; const o = e.remoteLastMessageSequence; const a = e.diff;e.count = a > this.PULL_LIMIT_COUNT ? this.PULL_LIMIT_COUNT : a, e.sequence = a > this.PULL_LIMIT_COUNT ? n + this.PULL_LIMIT_COUNT : n + a, this._getGroupMissingMessage(e).then(((s) => { - s.length > 0 && (s[0].sequence + 1 <= o && (e.localLastMessageSequence = n + t.PULL_LIMIT_COUNT, e.diff = a - t.PULL_LIMIT_COUNT, t._pullMissingMessage(e)), t.getModule(At).onNewGroupMessage({ dataList: s, isInstantMessage: !1 })); - })); - } }, { key: '_getGroupMissingMessage', value(e) { - const t = this; const n = new Da(hs);return this.request({ protocolName: On, requestData: { groupID: e.groupID, count: e.count, sequence: e.sequence } }).then(((o) => { - const a = o.data.messageList; const s = void 0 === a ? [] : a;return n.setNetworkType(t.getNetworkType()).setMessage('groupID:'.concat(e.groupID, ' count:').concat(e.count, ' sequence:') - .concat(e.sequence, ' messageList length:') - .concat(s.length)) - .end(), s; - })) - .catch(((e) => { - t.probeNetwork().then(((t) => { - const o = m(t, 2); const a = o[0]; const s = o[1];n.setError(e, a, s).end(); - })); - })); - } }, { key: 'reset', value() { - Ee.log(''.concat(this._className, '.reset')), this._remoteLastMessageSequenceMap.clear(); - } }]), n; - }(Yt)); const Bi = (function () { - function e() { - o(this, e), this._className = 'AvgE2EDelay', this._e2eDelayArray = []; - } return s(e, [{ key: 'addMessageDelay', value(e) { - const t = ut(e.currentTime / 1e3 - e.time, 2);this._e2eDelayArray.push(t); - } }, { key: '_calcAvg', value(e, t) { - if (0 === t) return 0;let n = 0;return e.forEach(((e) => { - n += e; - })), ut(n / t, 1); - } }, { key: '_calcTotalCount', value() { - return this._e2eDelayArray.length; - } }, { key: '_calcCountWithLimit', value(e) { - const t = e.e2eDelayArray; const n = e.min; const o = e.max;return t.filter((e => n < e && e <= o)).length; - } }, { key: '_calcPercent', value(e, t) { - let n = ut(e / t * 100, 2);return n > 100 && (n = 100), n; - } }, { key: '_checkE2EDelayException', value(e, t) { - const n = e.filter((e => e > t));if (n.length > 0) { - const o = n.length; const a = Math.min.apply(Math, M(n)); const s = Math.max.apply(Math, M(n)); const r = this._calcAvg(n, o); const i = ut(o / e.length * 100, 2);new Da(za).setMessage('message e2e delay exception. count:'.concat(o, ' min:').concat(a, ' max:') - .concat(s, ' avg:') - .concat(r, ' percent:') - .concat(i)) - .setLevel('warning') - .end(); - } - } }, { key: 'getStatResult', value() { - const e = this._calcTotalCount();if (0 === e) return null;const t = M(this._e2eDelayArray); const n = this._calcCountWithLimit({ e2eDelayArray: t, min: 0, max: 1 }); const o = this._calcCountWithLimit({ e2eDelayArray: t, min: 1, max: 3 }); const a = this._calcPercent(n, e); const s = this._calcPercent(o, e); const r = this._calcAvg(t, e);return this._checkE2EDelayException(t, 3), this.reset(), { totalCount: e, countLessThan1Second: n, percentOfCountLessThan1Second: a, countLessThan3Second: o, percentOfCountLessThan3Second: s, avgDelay: r }; - } }, { key: 'reset', value() { - this._e2eDelayArray.length = 0; - } }]), e; - }()); const Hi = (function () { - function e() { - o(this, e), this._className = 'AvgRTT', this._requestCount = 0, this._rttArray = []; - } return s(e, [{ key: 'addRequestCount', value() { - this._requestCount += 1; - } }, { key: 'addRTT', value(e) { - this._rttArray.push(e); - } }, { key: '_calcTotalCount', value() { - return this._requestCount; - } }, { key: '_calcRTTCount', value(e) { - return e.length; - } }, { key: '_calcSuccessRateOfRequest', value(e, t) { - if (0 === t) return 0;let n = ut(e / t * 100, 2);return n > 100 && (n = 100), n; - } }, { key: '_calcAvg', value(e, t) { - if (0 === t) return 0;let n = 0;return e.forEach(((e) => { - n += e; - })), parseInt(n / t); - } }, { key: '_calcMax', value() { - return Math.max.apply(Math, M(this._rttArray)); - } }, { key: '_calcMin', value() { - return Math.min.apply(Math, M(this._rttArray)); - } }, { key: 'getStatResult', value() { - const e = this._calcTotalCount(); const t = M(this._rttArray);if (0 === e) return null;const n = this._calcRTTCount(t); const o = this._calcSuccessRateOfRequest(n, e); const a = this._calcAvg(t, n);return Ee.log(''.concat(this._className, '.getStatResult max:').concat(this._calcMax(), ' min:') - .concat(this._calcMin(), ' avg:') - .concat(a)), this.reset(), { totalCount: e, rttCount: n, successRateOfRequest: o, avgRTT: a }; - } }, { key: 'reset', value() { - this._requestCount = 0, this._rttArray.length = 0; - } }]), e; - }()); const ji = (function () { - function e(t) { - const n = this;o(this, e), this._map = new Map, t.forEach(((e) => { - n._map.set(e, { totalCount: 0, successCount: 0, failedCountOfUserSide: 0, costArray: [], fileSizeArray: [] }); - })); - } return s(e, [{ key: 'addTotalCount', value(e) { - return !(Ge(e) || !this._map.has(e)) && (this._map.get(e).totalCount += 1, !0); - } }, { key: 'addSuccessCount', value(e) { - return !(Ge(e) || !this._map.has(e)) && (this._map.get(e).successCount += 1, !0); - } }, { key: 'addFailedCountOfUserSide', value(e) { - return !(Ge(e) || !this._map.has(e)) && (this._map.get(e).failedCountOfUserSide += 1, !0); - } }, { key: 'addCost', value(e, t) { - return !(Ge(e) || !this._map.has(e)) && (this._map.get(e).costArray.push(t), !0); - } }, { key: 'addFileSize', value(e, t) { - return !(Ge(e) || !this._map.has(e)) && (this._map.get(e).fileSizeArray.push(t), !0); - } }, { key: '_calcSuccessRateOfBusiness', value(e) { - if (Ge(e) || !this._map.has(e)) return -1;const t = this._map.get(e); let n = ut(t.successCount / t.totalCount * 100, 2);return n > 100 && (n = 100), n; - } }, { key: '_calcSuccessRateOfPlatform', value(e) { - if (Ge(e) || !this._map.has(e)) return -1;const t = this._map.get(e); let n = this._calcSuccessCountOfPlatform(e) / t.totalCount * 100;return (n = ut(n, 2)) > 100 && (n = 100), n; - } }, { key: '_calcTotalCount', value(e) { - return Ge(e) || !this._map.has(e) ? -1 : this._map.get(e).totalCount; - } }, { key: '_calcSuccessCountOfBusiness', value(e) { - return Ge(e) || !this._map.has(e) ? -1 : this._map.get(e).successCount; - } }, { key: '_calcSuccessCountOfPlatform', value(e) { - if (Ge(e) || !this._map.has(e)) return -1;const t = this._map.get(e);return t.successCount + t.failedCountOfUserSide; - } }, { key: '_calcAvg', value(e) { - return Ge(e) || !this._map.has(e) ? -1 : e === _a ? this._calcAvgSpeed(e) : this._calcAvgCost(e); - } }, { key: '_calcAvgCost', value(e) { - const t = this._map.get(e).costArray.length;if (0 === t) return 0;let n = 0;return this._map.get(e).costArray.forEach(((e) => { - n += e; - })), parseInt(n / t); - } }, { key: '_calcAvgSpeed', value(e) { - let t = 0; let n = 0;return this._map.get(e).costArray.forEach(((e) => { - t += e; - })), this._map.get(e).fileSizeArray.forEach(((e) => { - n += e; - })), parseInt(1e3 * n / t); - } }, { key: 'getStatResult', value(e) { - const t = this._calcTotalCount(e);if (0 === t) return null;const n = this._calcSuccessCountOfBusiness(e); const o = this._calcSuccessRateOfBusiness(e); const a = this._calcSuccessCountOfPlatform(e); const s = this._calcSuccessRateOfPlatform(e); const r = this._calcAvg(e);return this.reset(e), { totalCount: t, successCountOfBusiness: n, successRateOfBusiness: o, successCountOfPlatform: a, successRateOfPlatform: s, avgValue: r }; - } }, { key: 'reset', value(e) { - Ge(e) ? this._map.clear() : this._map.set(e, { totalCount: 0, successCount: 0, failedCountOfUserSide: 0, costArray: [], fileSizeArray: [] }); - } }]), e; - }()); const $i = (function () { - function e(t) { - const n = this;o(this, e), this._lastMap = new Map, this._currentMap = new Map, t.forEach(((e) => { - n._lastMap.set(e, new Map), n._currentMap.set(e, new Map); - })); - } return s(e, [{ key: 'addMessageSequence', value(e) { - const t = e.key; const n = e.message;if (Ge(t) || !this._lastMap.has(t) || !this._currentMap.has(t)) return !1;const o = n.conversationID; const a = n.sequence; const s = o.replace(k.CONV_GROUP, '');if (0 === this._lastMap.get(t).size) this._addCurrentMap(e);else if (this._lastMap.get(t).has(s)) { - const r = this._lastMap.get(t).get(s); const i = r.length - 1;a > r[0] && a < r[i] ? (r.push(a), r.sort(), this._lastMap.get(t).set(s, r)) : this._addCurrentMap(e); - } else this._addCurrentMap(e);return !0; - } }, { key: '_addCurrentMap', value(e) { - const t = e.key; const n = e.message; const o = n.conversationID; const a = n.sequence; const s = o.replace(k.CONV_GROUP, '');this._currentMap.get(t).has(s) || this._currentMap.get(t).set(s, []), this._currentMap.get(t).get(s) - .push(a); - } }, { key: '_copyData', value(e) { - if (!Ge(e)) { - this._lastMap.set(e, new Map);let t; let n = this._lastMap.get(e); const o = S(this._currentMap.get(e));try { - for (o.s();!(t = o.n()).done;) { - const a = m(t.value, 2); const s = a[0]; const r = a[1];n.set(s, r); - } - } catch (i) { - o.e(i); - } finally { - o.f(); - }n = null, this._currentMap.set(e, new Map); - } - } }, { key: 'getStatResult', value(e) { - if (Ge(this._currentMap.get(e)) || Ge(this._lastMap.get(e))) return null;if (0 === this._lastMap.get(e).size) return this._copyData(e), null;let t = 0; let n = 0;if (this._lastMap.get(e).forEach(((e, o) => { - const a = M(e.values()); const s = a.length; const r = a[s - 1] - a[0] + 1;t += r, n += s; - })), 0 === t) return null;let o = ut(n / t * 100, 2);return o > 100 && (o = 100), this._copyData(e), { totalCount: t, successCountOfMessageReceived: n, successRateOfMessageReceived: o }; - } }, { key: 'reset', value() { - this._currentMap.clear(), this._lastMap.clear(); - } }]), e; - }()); const Yi = (function (e) { - i(a, e);const n = f(a);function a(e) { - let t;o(this, a), (t = n.call(this, e))._className = 'QualityStatModule', t.TAG = 'im-ssolog-quality-stat', t.reportIndex = 0, t.wholePeriod = !1, t._qualityItems = [ua, la, da, ga, pa, ha, _a, fa, ma, Ma], t.REPORT_INTERVAL = 120, t._statInfoArr = [], t._avgRTT = new Hi, t._avgE2EDelay = new Bi;const s = [da, ga, pa, ha, _a];t._rateMessageSend = new ji(s);const r = [fa, ma, Ma];t._rateMessageReceived = new $i(r);const i = t.getInnerEmitterInstance();return i.on(Ir.CONTEXT_A2KEY_AND_TINYID_UPDATED, t._onLoginSuccess, h(t)), i.on(Ir.CLOUD_CONFIG_UPDATED, t._onCloudConfigUpdate, h(t)), t; - } return s(a, [{ key: '_onLoginSuccess', value() { - const e = this; const t = this.getModule(wt); const n = t.getItem(this.TAG, !1);!dt(n) && Pe(n.forEach) && (Ee.log(''.concat(this._className, '._onLoginSuccess.get quality stat log in storage, nums=').concat(n.length)), n.forEach(((t) => { - e._statInfoArr.push(t); - })), t.removeItem(this.TAG, !1)); - } }, { key: '_onCloudConfigUpdate', value() { - const e = this.getCloudConfig('report_interval_quality');Ge(e) || (this.REPORT_INTERVAL = Number(e)); - } }, { key: 'onCheckTimer', value(e) { - this.isLoggedIn() && e % this.REPORT_INTERVAL == 0 && (this.wholePeriod = !0, this._report()); - } }, { key: 'addRequestCount', value() { - this._avgRTT.addRequestCount(); - } }, { key: 'addRTT', value(e) { - this._avgRTT.addRTT(e); - } }, { key: 'addMessageDelay', value(e) { - this._avgE2EDelay.addMessageDelay(e); - } }, { key: 'addTotalCount', value(e) { - this._rateMessageSend.addTotalCount(e) || Ee.warn(''.concat(this._className, '.addTotalCount invalid key:'), e); - } }, { key: 'addSuccessCount', value(e) { - this._rateMessageSend.addSuccessCount(e) || Ee.warn(''.concat(this._className, '.addSuccessCount invalid key:'), e); - } }, { key: 'addFailedCountOfUserSide', value(e) { - this._rateMessageSend.addFailedCountOfUserSide(e) || Ee.warn(''.concat(this._className, '.addFailedCountOfUserSide invalid key:'), e); - } }, { key: 'addCost', value(e, t) { - this._rateMessageSend.addCost(e, t) || Ee.warn(''.concat(this._className, '.addCost invalid key or cost:'), e, t); - } }, { key: 'addFileSize', value(e, t) { - this._rateMessageSend.addFileSize(e, t) || Ee.warn(''.concat(this._className, '.addFileSize invalid key or size:'), e, t); - } }, { key: 'addMessageSequence', value(e) { - this._rateMessageReceived.addMessageSequence(e) || Ee.warn(''.concat(this._className, '.addMessageSequence invalid key:'), e.key); - } }, { key: '_getQualityItem', value(e) { - let n = {}; let o = Ia[this.getNetworkType()];Ge(o) && (o = 8);const a = { qualityType: va[e], timestamp: ye(), networkType: o, extension: '' };switch (e) { - case ua:n = this._avgRTT.getStatResult();break;case la:n = this._avgE2EDelay.getStatResult();break;case da:case ga:case pa:case ha:case _a:n = this._rateMessageSend.getStatResult(e);break;case fa:case ma:case Ma:n = this._rateMessageReceived.getStatResult(e); - } return null === n ? null : t(t({}, a), n); - } }, { key: '_report', value(e) { - const t = this; let n = []; let o = null;Ge(e) ? this._qualityItems.forEach(((e) => { - null !== (o = t._getQualityItem(e)) && (o.reportIndex = t.reportIndex, o.wholePeriod = t.wholePeriod, n.push(o)); - })) : null !== (o = this._getQualityItem(e)) && (o.reportIndex = this.reportIndex, o.wholePeriod = this.wholePeriod, n.push(o)), Ee.debug(''.concat(this._className, '._report'), n), this._statInfoArr.length > 0 && (n = n.concat(this._statInfoArr), this._statInfoArr = []), n.length > 0 && this._doReport(n); - } }, { key: '_doReport', value(e) { - const n = this; const o = { header: ai(this), quality: e };this.request({ protocolName: Hn, requestData: t({}, o) }).then((() => { - n.reportIndex++, n.wholePeriod = !1; - })) - .catch(((t) => { - Ee.warn(''.concat(n._className, '._doReport, online:').concat(n.getNetworkType(), ' error:'), t), n._statInfoArr = n._statInfoArr.concat(e), n._flushAtOnce(); - })); - } }, { key: '_flushAtOnce', value() { - const e = this.getModule(wt); const t = e.getItem(this.TAG, !1); const n = this._statInfoArr;if (dt(t))Ee.log(''.concat(this._className, '._flushAtOnce count:').concat(n.length)), e.setItem(this.TAG, n, !0, !1);else { - let o = n.concat(t);o.length > 10 && (o = o.slice(0, 10)), Ee.log(''.concat(this.className, '._flushAtOnce count:').concat(o.length)), e.setItem(this.TAG, o, !0, !1); - } this._statInfoArr = []; - } }, { key: 'reset', value() { - Ee.log(''.concat(this._className, '.reset')), this._report(), this.reportIndex = 0, this.wholePeriod = !1, this._avgRTT.reset(), this._avgE2EDelay.reset(), this._rateMessageSend.reset(), this._rateMessageReceived.reset(); - } }]), a; - }(Yt)); const zi = (function () { - function e(t) { - o(this, e);const n = new Da(Ta);this._className = 'ModuleManager', this._isReady = !1, this._startLoginTs = 0, this._moduleMap = new Map, this._innerEmitter = null, this._outerEmitter = null, this._checkCount = 0, this._checkTimer = -1, this._moduleMap.set(Gt, new Zr(this, t)), this._moduleMap.set(Ht, new Ki(this)), this._moduleMap.set($t, new Yi(this)), this._moduleMap.set(xt, new Gi(this)), this._moduleMap.set(Kt, new qi(this)), this._moduleMap.set(Et, new ei(this)), this._moduleMap.set(kt, new fi(this)), this._moduleMap.set(Ct, new Qr(this)), this._moduleMap.set(Nt, new vr(this)), this._moduleMap.set(Rt, new Ur(this)), this._moduleMap.set(At, new $r(this)), this._moduleMap.set(Lt, new zr(this)), this._moduleMap.set(wt, new ni(this)), this._moduleMap.set(Pt, new si(this)), this._moduleMap.set(bt, new ci(this)), this._moduleMap.set(Ut, new li(this)), this._moduleMap.set(Ft, new di(this)), this._moduleMap.set(qt, new mi(this)), this._moduleMap.set(Vt, new Mi(this)), this._moduleMap.set(Bt, new Vi(this)), this._moduleMap.set(jt, new xi(this));const a = t.instanceID; const s = t.oversea; const r = t.SDKAppID; const i = 'instanceID:'.concat(a, ' oversea:').concat(s, ' host:') - .concat(st(), ' ') + 'inBrowser:'.concat(W, ' inMiniApp:').concat(z, ' SDKAppID:') - .concat(r, ' UserAgent:') - .concat(Q);Da.bindEventStatModule(this._moduleMap.get(Pt)), n.setMessage(''.concat(i)).end(), Ee.info('SDK '.concat(i)), this._readyList = void 0, this._ssoLogForReady = null, this._initReadyList(); - } return s(e, [{ key: '_startTimer', value() { - this._checkTimer < 0 && (this._checkTimer = setInterval(this._onCheckTimer.bind(this), 1e3)); - } }, { key: 'stopTimer', value() { - this._checkTimer > 0 && (clearInterval(this._checkTimer), this._checkTimer = -1, this._checkCount = 0); - } }, { key: '_onCheckTimer', value() { - this._checkCount += 1;let e; const t = S(this._moduleMap);try { - for (t.s();!(e = t.n()).done;) { - const n = m(e.value, 2)[1];n.onCheckTimer && n.onCheckTimer(this._checkCount); - } - } catch (o) { - t.e(o); - } finally { - t.f(); - } - } }, { key: '_initReadyList', value() { - const e = this;this._readyList = [this._moduleMap.get(Et), this._moduleMap.get(Rt)], this._readyList.forEach(((t) => { - t.ready((() => e._onModuleReady())); - })); - } }, { key: '_onModuleReady', value() { - let e = !0;if (this._readyList.forEach(((t) => { - t.isReady() || (e = !1); - })), e && !this._isReady) { - this._isReady = !0, this._outerEmitter.emit(E.SDK_READY);const t = Date.now() - this._startLoginTs;Ee.warn('SDK is ready. cost '.concat(t, ' ms')), this._startLoginTs = Date.now();const n = this._moduleMap.get(bt).getNetworkType(); const o = this._ssoLogForReady.getStartTs() + ve;this._ssoLogForReady.setNetworkType(n).setMessage(t) - .start(o) - .end(); - } - } }, { key: 'login', value() { - 0 === this._startLoginTs && (Ie(), this._startLoginTs = Date.now(), this._startTimer(), this._moduleMap.get(bt).start(), this._ssoLogForReady = new Da(Sa)); - } }, { key: 'onLoginFailed', value() { - this._startLoginTs = 0; - } }, { key: 'getOuterEmitterInstance', value() { - return null === this._outerEmitter && (this._outerEmitter = new ui, fr(this._outerEmitter), this._outerEmitter._emit = this._outerEmitter.emit, this._outerEmitter.emit = function (e, t) { - const n = arguments[0]; const o = [n, { name: arguments[0], data: arguments[1] }];this._outerEmitter._emit.apply(this._outerEmitter, o); - }.bind(this)), this._outerEmitter; - } }, { key: 'getInnerEmitterInstance', value() { - return null === this._innerEmitter && (this._innerEmitter = new ui, this._innerEmitter._emit = this._innerEmitter.emit, this._innerEmitter.emit = function (e, t) { - let n;Le(arguments[1]) && arguments[1].data ? (Ee.warn('inner eventData has data property, please check!'), n = [e, { name: arguments[0], data: arguments[1].data }]) : n = [e, { name: arguments[0], data: arguments[1] }], this._innerEmitter._emit.apply(this._innerEmitter, n); - }.bind(this)), this._innerEmitter; - } }, { key: 'hasModule', value(e) { - return this._moduleMap.has(e); - } }, { key: 'getModule', value(e) { - return this._moduleMap.get(e); - } }, { key: 'isReady', value() { - return this._isReady; - } }, { key: 'onError', value(e) { - Ee.warn('Oops! code:'.concat(e.code, ' message:').concat(e.message)), new Da(Fs).setMessage('code:'.concat(e.code, ' message:').concat(e.message)) - .setNetworkType(this.getModule(bt).getNetworkType()) - .setLevel('error') - .end(), this.getOuterEmitterInstance().emit(E.ERROR, e); - } }, { key: 'reset', value() { - Ee.log(''.concat(this._className, '.reset')), Ie();let e; const t = S(this._moduleMap);try { - for (t.s();!(e = t.n()).done;) { - const n = m(e.value, 2)[1];n.reset && n.reset(); - } - } catch (o) { - t.e(o); - } finally { - t.f(); - } this._startLoginTs = 0, this._initReadyList(), this._isReady = !1, this.stopTimer(), this._outerEmitter.emit(E.SDK_NOT_READY); - } }]), e; - }()); const Wi = (function () { - function e() { - o(this, e), this._funcMap = new Map; - } return s(e, [{ key: 'defense', value(e, t) { - const n = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : void 0;if ('string' !== typeof e) return null;if (0 === e.length) return null;if ('function' !== typeof t) return null;if (this._funcMap.has(e) && this._funcMap.get(e).has(t)) return this._funcMap.get(e).get(t);this._funcMap.has(e) || this._funcMap.set(e, new Map);let o = null;return this._funcMap.get(e).has(t) ? o = this._funcMap.get(e).get(t) : (o = this._pack(e, t, n), this._funcMap.get(e).set(t, o)), o; - } }, { key: 'defenseOnce', value(e, t) { - const n = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : void 0;return 'function' !== typeof t ? null : this._pack(e, t, n); - } }, { key: 'find', value(e, t) { - return 'string' !== typeof e || 0 === e.length || 'function' !== typeof t ? null : this._funcMap.has(e) ? this._funcMap.get(e).has(t) ? this._funcMap.get(e).get(t) : (Ee.log('SafetyCallback.find: 找不到 func —— '.concat(e, '/').concat('' !== t.name ? t.name : '[anonymous]')), null) : (Ee.log('SafetyCallback.find: 找不到 eventName-'.concat(e, ' 对应的 func')), null); - } }, { key: 'delete', value(e, t) { - return 'function' === typeof t && (!!this._funcMap.has(e) && (!!this._funcMap.get(e).has(t) && (this._funcMap.get(e).delete(t), 0 === this._funcMap.get(e).size && this._funcMap.delete(e), !0))); - } }, { key: '_pack', value(e, t, n) { - return function () { - try { - t.apply(n, Array.from(arguments)); - } catch (r) { - const o = Object.values(E).indexOf(e);if (-1 !== o) { - const a = Object.keys(E)[o];Ee.warn('接入侧事件 TIM.EVENT.'.concat(a, ' 对应的回调函数逻辑存在问题,请检查!'), r); - } const s = new Da(Ps);s.setMessage('eventName:'.concat(e)).setMoreMessage(r.message) - .end(); - } - }; - } }]), e; - }()); const Ji = (function () { - function e(t) { - o(this, e);const n = { SDKAppID: t.SDKAppID, unlimitedAVChatRoom: t.unlimitedAVChatRoom || !1, scene: t.scene || '', oversea: t.oversea || !1, instanceID: at() };this._moduleManager = new zi(n), this._safetyCallbackFactory = new Wi; - } return s(e, [{ key: 'isReady', value() { - return this._moduleManager.isReady(); - } }, { key: 'onError', value(e) { - this._moduleManager.onError(e); - } }, { key: 'login', value(e) { - return this._moduleManager.login(), this._moduleManager.getModule(Et).login(e); - } }, { key: 'logout', value() { - const e = this;return this._moduleManager.getModule(Et).logout() - .then((t => (e._moduleManager.reset(), t))); - } }, { key: 'destroy', value() { - const e = this;return this.logout().finally((() => { - e._moduleManager.stopTimer(), e._moduleManager.getModule(xt).dealloc();const t = e._moduleManager.getOuterEmitterInstance(); const n = e._moduleManager.getModule(Gt);t.emit(E.SDK_DESTROY, { SDKAppID: n.getSDKAppID() }); - })); - } }, { key: 'on', value(e, t, n) { - e === E.GROUP_SYSTEM_NOTICE_RECEIVED && Ee.warn('!!!TIM.EVENT.GROUP_SYSTEM_NOTICE_RECEIVED v2.6.0起弃用,为了更好的体验,请在 TIM.EVENT.MESSAGE_RECEIVED 事件回调内接收处理群系统通知,详细请参考:https://web.sdk.qcloud.com/im/doc/zh-cn/Message.html#.GroupSystemNoticePayload'), Ee.debug('on', 'eventName:'.concat(e)), this._moduleManager.getOuterEmitterInstance().on(e, this._safetyCallbackFactory.defense(e, t, n), n); - } }, { key: 'once', value(e, t, n) { - Ee.debug('once', 'eventName:'.concat(e)), this._moduleManager.getOuterEmitterInstance().once(e, this._safetyCallbackFactory.defenseOnce(e, t, n), n || this); - } }, { key: 'off', value(e, t, n, o) { - Ee.debug('off', 'eventName:'.concat(e));const a = this._safetyCallbackFactory.find(e, t);null !== a && (this._moduleManager.getOuterEmitterInstance().off(e, a, n, o), this._safetyCallbackFactory.delete(e, t)); - } }, { key: 'registerPlugin', value(e) { - this._moduleManager.getModule(qt).registerPlugin(e); - } }, { key: 'setLogLevel', value(e) { - if (e <= 0) { - console.log(['', ' ________ ______ __ __ __ __ ________ _______', '| \\| \\| \\ / \\| \\ _ | \\| \\| \\', ' \\$$$$$$$$ \\$$$$$$| $$\\ / $$| $$ / \\ | $$| $$$$$$$$| $$$$$$$\\', ' | $$ | $$ | $$$\\ / $$$| $$/ $\\| $$| $$__ | $$__/ $$', ' | $$ | $$ | $$$$\\ $$$$| $$ $$$\\ $$| $$ \\ | $$ $$', ' | $$ | $$ | $$\\$$ $$ $$| $$ $$\\$$\\$$| $$$$$ | $$$$$$$\\', ' | $$ _| $$_ | $$ \\$$$| $$| $$$$ \\$$$$| $$_____ | $$__/ $$', ' | $$ | $$ \\| $$ \\$ | $$| $$$ \\$$$| $$ \\| $$ $$', ' \\$$ \\$$$$$$ \\$$ \\$$ \\$$ \\$$ \\$$$$$$$$ \\$$$$$$$', '', ''].join('\n')), console.log('%cIM 智能客服,随时随地解决您的问题 →_→ https://cloud.tencent.com/act/event/smarty-service?from=im-doc', 'color:#006eff'), console.log('%c从v2.11.2起,SDK 支持了 WebSocket,小程序需要添加受信域名!升级指引: https://web.sdk.qcloud.com/im/doc/zh-cn/tutorial-02-upgradeguideline.html', 'color:#ff0000');console.log(['', '参考以下文档,会更快解决问题哦!(#^.^#)\n', 'SDK 更新日志: https://cloud.tencent.com/document/product/269/38492\n', 'SDK 接口文档: https://web.sdk.qcloud.com/im/doc/zh-cn/SDK.html\n', '常见问题: https://web.sdk.qcloud.com/im/doc/zh-cn/tutorial-01-faq.html\n', '反馈问题?戳我提 issue: https://github.com/tencentyun/TIMSDK/issues\n', '如果您需要在生产环境关闭上面的日志,请 tim.setLogLevel(1)\n'].join('\n')); - }Ee.setLevel(e); - } }, { key: 'createTextMessage', value(e) { - return this._moduleManager.getModule(kt).createTextMessage(e); - } }, { key: 'createTextAtMessage', value(e) { - return this._moduleManager.getModule(kt).createTextMessage(e); - } }, { key: 'createImageMessage', value(e) { - return this._moduleManager.getModule(kt).createImageMessage(e); - } }, { key: 'createAudioMessage', value(e) { - return this._moduleManager.getModule(kt).createAudioMessage(e); - } }, { key: 'createVideoMessage', value(e) { - return this._moduleManager.getModule(kt).createVideoMessage(e); - } }, { key: 'createCustomMessage', value(e) { - return this._moduleManager.getModule(kt).createCustomMessage(e); - } }, { key: 'createFaceMessage', value(e) { - return this._moduleManager.getModule(kt).createFaceMessage(e); - } }, { key: 'createFileMessage', value(e) { - return this._moduleManager.getModule(kt).createFileMessage(e); - } }, { key: 'createMergerMessage', value(e) { - return this._moduleManager.getModule(kt).createMergerMessage(e); - } }, { key: 'downloadMergerMessage', value(e) { - return e.type !== k.MSG_MERGER ? Mr(new hr({ code: Zn.MESSAGE_MERGER_TYPE_INVALID, message: No })) : dt(e.payload.downloadKey) ? Mr(new hr({ code: Zn.MESSAGE_MERGER_KEY_INVALID, message: Ao })) : this._moduleManager.getModule(kt).downloadMergerMessage(e) - .catch((e => Mr(new hr({ code: Zn.MESSAGE_MERGER_DOWNLOAD_FAIL, message: Oo })))); - } }, { key: 'createForwardMessage', value(e) { - return this._moduleManager.getModule(kt).createForwardMessage(e); - } }, { key: 'sendMessage', value(e, t) { - return e instanceof ir ? this._moduleManager.getModule(kt).sendMessageInstance(e, t) : Mr(new hr({ code: Zn.MESSAGE_SEND_NEED_MESSAGE_INSTANCE, message: uo })); - } }, { key: 'callExperimentalAPI', value(e, t) { - return 'handleGroupInvitation' === e ? this._moduleManager.getModule(At).handleGroupInvitation(t) : Mr(new hr({ code: Zn.INVALID_OPERATION, message: aa })); - } }, { key: 'revokeMessage', value(e) { - return this._moduleManager.getModule(kt).revokeMessage(e); - } }, { key: 'resendMessage', value(e) { - return this._moduleManager.getModule(kt).resendMessage(e); - } }, { key: 'deleteMessage', value(e) { - return this._moduleManager.getModule(kt).deleteMessage(e); - } }, { key: 'getMessageList', value(e) { - return this._moduleManager.getModule(Rt).getMessageList(e); - } }, { key: 'setMessageRead', value(e) { - return this._moduleManager.getModule(Rt).setMessageRead(e); - } }, { key: 'getConversationList', value() { - return this._moduleManager.getModule(Rt).getConversationList(); - } }, { key: 'getConversationProfile', value(e) { - return this._moduleManager.getModule(Rt).getConversationProfile(e); - } }, { key: 'deleteConversation', value(e) { - return this._moduleManager.getModule(Rt).deleteConversation(e); - } }, { key: 'getMyProfile', value() { - return this._moduleManager.getModule(Ct).getMyProfile(); - } }, { key: 'getUserProfile', value(e) { - return this._moduleManager.getModule(Ct).getUserProfile(e); - } }, { key: 'updateMyProfile', value(e) { - return this._moduleManager.getModule(Ct).updateMyProfile(e); - } }, { key: 'getBlacklist', value() { - return this._moduleManager.getModule(Ct).getLocalBlacklist(); - } }, { key: 'addToBlacklist', value(e) { - return this._moduleManager.getModule(Ct).addBlacklist(e); - } }, { key: 'removeFromBlacklist', value(e) { - return this._moduleManager.getModule(Ct).deleteBlacklist(e); - } }, { key: 'getFriendList', value() { - const e = this._moduleManager.getModule(Ot);return e ? e.getLocalFriendList() : Mr({ code: Zn.CANNOT_FIND_MODULE, message: ra }); - } }, { key: 'addFriend', value(e) { - const t = this._moduleManager.getModule(Ot);return t ? t.addFriend(e) : Mr({ code: Zn.CANNOT_FIND_MODULE, message: ra }); - } }, { key: 'deleteFriend', value(e) { - const t = this._moduleManager.getModule(Ot);return t ? t.deleteFriend(e) : Mr({ code: Zn.CANNOT_FIND_MODULE, message: ra }); - } }, { key: 'checkFriend', value(e) { - const t = this._moduleManager.getModule(Ot);return t ? t.checkFriend(e) : Mr({ code: Zn.CANNOT_FIND_MODULE, message: ra }); - } }, { key: 'getFriendProfile', value(e) { - const t = this._moduleManager.getModule(Ot);return t ? t.getFriendProfile(e) : Mr({ code: Zn.CANNOT_FIND_MODULE, message: ra }); - } }, { key: 'updateFriend', value(e) { - const t = this._moduleManager.getModule(Ot);return t ? t.updateFriend(e) : Mr({ code: Zn.CANNOT_FIND_MODULE, message: ra }); - } }, { key: 'getFriendApplicationList', value() { - const e = this._moduleManager.getModule(Ot);return e ? e.getLocalFriendApplicationList() : Mr({ code: Zn.CANNOT_FIND_MODULE, message: ra }); - } }, { key: 'acceptFriendApplication', value(e) { - const t = this._moduleManager.getModule(Ot);return t ? t.acceptFriendApplication(e) : Mr({ code: Zn.CANNOT_FIND_MODULE, message: ra }); - } }, { key: 'refuseFriendApplication', value(e) { - const t = this._moduleManager.getModule(Ot);return t ? t.refuseFriendApplication(e) : Mr({ code: Zn.CANNOT_FIND_MODULE, message: ra }); - } }, { key: 'deleteFriendApplication', value(e) { - const t = this._moduleManager.getModule(Ot);return t ? t.deleteFriendApplication(e) : Mr({ code: Zn.CANNOT_FIND_MODULE, message: ra }); - } }, { key: 'setFriendApplicationRead', value() { - const e = this._moduleManager.getModule(Ot);return e ? e.setFriendApplicationRead() : Mr({ code: Zn.CANNOT_FIND_MODULE, message: ra }); - } }, { key: 'getFriendGroupList', value() { - const e = this._moduleManager.getModule(Ot);return e ? e.getLocalFriendGroupList() : Mr({ code: Zn.CANNOT_FIND_MODULE, message: ra }); - } }, { key: 'createFriendGroup', value(e) { - const t = this._moduleManager.getModule(Ot);return t ? t.createFriendGroup(e) : Mr({ code: Zn.CANNOT_FIND_MODULE, message: ra }); - } }, { key: 'deleteFriendGroup', value(e) { - const t = this._moduleManager.getModule(Ot);return t ? t.deleteFriendGroup(e) : Mr({ code: Zn.CANNOT_FIND_MODULE, message: ra }); - } }, { key: 'addToFriendGroup', value(e) { - const t = this._moduleManager.getModule(Ot);return t ? t.addToFriendGroup(e) : Mr({ code: Zn.CANNOT_FIND_MODULE, message: ra }); - } }, { key: 'removeFromFriendGroup', value(e) { - const t = this._moduleManager.getModule(Ot);return t ? t.removeFromFriendGroup(e) : Mr({ code: Zn.CANNOT_FIND_MODULE, message: ra }); - } }, { key: 'renameFriendGroup', value(e) { - const t = this._moduleManager.getModule(Ot);return t ? t.renameFriendGroup(e) : Mr({ code: Zn.CANNOT_FIND_MODULE, message: ra }); - } }, { key: 'getGroupList', value(e) { - return this._moduleManager.getModule(At).getGroupList(e); - } }, { key: 'getGroupProfile', value(e) { - return this._moduleManager.getModule(At).getGroupProfile(e); - } }, { key: 'createGroup', value(e) { - return this._moduleManager.getModule(At).createGroup(e); - } }, { key: 'dismissGroup', value(e) { - return this._moduleManager.getModule(At).dismissGroup(e); - } }, { key: 'updateGroupProfile', value(e) { - return this._moduleManager.getModule(At).updateGroupProfile(e); - } }, { key: 'joinGroup', value(e) { - return this._moduleManager.getModule(At).joinGroup(e); - } }, { key: 'quitGroup', value(e) { - return this._moduleManager.getModule(At).quitGroup(e); - } }, { key: 'searchGroupByID', value(e) { - return this._moduleManager.getModule(At).searchGroupByID(e); - } }, { key: 'getGroupOnlineMemberCount', value(e) { - return this._moduleManager.getModule(At).getGroupOnlineMemberCount(e); - } }, { key: 'changeGroupOwner', value(e) { - return this._moduleManager.getModule(At).changeGroupOwner(e); - } }, { key: 'handleGroupApplication', value(e) { - return this._moduleManager.getModule(At).handleGroupApplication(e); - } }, { key: 'getGroupMemberList', value(e) { - return this._moduleManager.getModule(Lt).getGroupMemberList(e); - } }, { key: 'getGroupMemberProfile', value(e) { - return this._moduleManager.getModule(Lt).getGroupMemberProfile(e); - } }, { key: 'addGroupMember', value(e) { - return this._moduleManager.getModule(Lt).addGroupMember(e); - } }, { key: 'deleteGroupMember', value(e) { - return this._moduleManager.getModule(Lt).deleteGroupMember(e); - } }, { key: 'setGroupMemberMuteTime', value(e) { - return this._moduleManager.getModule(Lt).setGroupMemberMuteTime(e); - } }, { key: 'setGroupMemberRole', value(e) { - return this._moduleManager.getModule(Lt).setGroupMemberRole(e); - } }, { key: 'setGroupMemberNameCard', value(e) { - return this._moduleManager.getModule(Lt).setGroupMemberNameCard(e); - } }, { key: 'setGroupMemberCustomField', value(e) { - return this._moduleManager.getModule(Lt).setGroupMemberCustomField(e); - } }, { key: 'setMessageRemindType', value(e) { - return this._moduleManager.getModule(Lt).setMessageRemindType(e); - } }]), e; - }()); const Xi = { login: 'login', logout: 'logout', destroy: 'destroy', on: 'on', off: 'off', ready: 'ready', setLogLevel: 'setLogLevel', joinGroup: 'joinGroup', quitGroup: 'quitGroup', registerPlugin: 'registerPlugin', getGroupOnlineMemberCount: 'getGroupOnlineMemberCount' };function Qi(e, t) { - if (e.isReady() || void 0 !== Xi[t]) return !0;const n = new hr({ code: Zn.SDK_IS_NOT_READY, message: ''.concat(t, ' ').concat(ia, ',请参考 https://web.sdk.qcloud.com/im/doc/zh-cn/module-EVENT.html#.SDK_READY') });return e.onError(n), !1; - } const Zi = {}; const ec = {};return ec.create = function (e) { - let n = 0;if (Ne(e.SDKAppID))n = e.SDKAppID;else if (Ee.warn('TIM.create SDKAppID 的类型应该为 Number,请修改!'), n = parseInt(e.SDKAppID), isNaN(n)) return Ee.error('TIM.create failed. 解析 SDKAppID 失败,请检查传参!'), null;if (n && Zi[n]) return Zi[n];Ee.log('TIM.create');const o = new Ji(t(t({}, e), {}, { SDKAppID: n }));o.on(E.SDK_DESTROY, ((e) => { - Zi[e.data.SDKAppID] = null, delete Zi[e.data.SDKAppID]; - }));const a = (function (e) { - const t = Object.create(null);return Object.keys(St).forEach(((n) => { - if (e[n]) { - const o = St[n]; const a = new C;t[o] = function () { - const t = Array.from(arguments);return a.use(((t, o) => (Qi(e, n) ? o() : Mr(new hr({ code: Zn.SDK_IS_NOT_READY, message: ''.concat(n, ' ').concat(ia, '。') }))))).use(((e, t) => { - if (!0 === gt(e, Tt[n], o)) return t(); - })) - .use(((t, o) => e[n].apply(e, t))), a.run(t); - }; - } - })), t; - }(o));return Zi[n] = a, Ee.log('TIM.create ok'), a; - }, ec.TYPES = k, ec.EVENT = E, ec.VERSION = '2.12.2', Ee.log('TIM.VERSION: '.concat(ec.VERSION)), ec; -}))); +'use strict';!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).TIM=t()}(this,(function(){function e(e,t){var o=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),o.push.apply(o,n)}return o}function t(t){for(var o=1;o=0||(a[o]=e[o]);return a}(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,o)&&(a[o]=e[o])}return a}function _(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function h(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return _(e)}function f(e){var t=l();return function(){var o,n=c(e);if(t){var a=c(this).constructor;o=Reflect.construct(n,arguments,a)}else o=n.apply(this,arguments);return h(this,o)}}function m(e,t){return v(e)||function(e,t){var o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==o)return;var n,a,s=[],r=!0,i=!1;try{for(o=o.call(e);!(r=(n=o.next()).done)&&(s.push(n.value),!t||s.length!==t);r=!0);}catch(c){i=!0,a=c}finally{try{r||null==o.return||o.return()}finally{if(i)throw a}}return s}(e,t)||I(e,t)||T()}function M(e){return function(e){if(Array.isArray(e))return E(e)}(e)||y(e)||I(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function v(e){if(Array.isArray(e))return e}function y(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function I(e,t){if(e){if("string"==typeof e)return E(e,t);var o=Object.prototype.toString.call(e).slice(8,-1);return"Object"===o&&e.constructor&&(o=e.constructor.name),"Map"===o||"Set"===o?Array.from(e):"Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)?E(e,t):void 0}}function E(e,t){(null==t||t>e.length)&&(t=e.length);for(var o=0,n=new Array(t);o=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,r=!0,i=!1;return{s:function(){o=o.call(e)},n:function(){var e=o.next();return r=e.done,e},e:function(e){i=!0,s=e},f:function(){try{r||null==o.return||o.return()}finally{if(i)throw s}}}}var S={SDK_READY:"sdkStateReady",SDK_NOT_READY:"sdkStateNotReady",SDK_DESTROY:"sdkDestroy",MESSAGE_RECEIVED:"onMessageReceived",MESSAGE_MODIFIED:"onMessageModified",MESSAGE_REVOKED:"onMessageRevoked",MESSAGE_READ_BY_PEER:"onMessageReadByPeer",MESSAGE_READ_RECEIPT_RECEIVED:"onMessageReadReceiptReceived",CONVERSATION_LIST_UPDATED:"onConversationListUpdated",GROUP_LIST_UPDATED:"onGroupListUpdated",GROUP_SYSTEM_NOTICE_RECEIVED:"receiveGroupSystemNotice",GROUP_ATTRIBUTES_UPDATED:"groupAttributesUpdated",TOPIC_CREATED:"onTopicCreated",TOPIC_DELETED:"onTopicDeleted",TOPIC_UPDATED:"onTopicUpdated",PROFILE_UPDATED:"onProfileUpdated",BLACKLIST_UPDATED:"blacklistUpdated",FRIEND_LIST_UPDATED:"onFriendListUpdated",FRIEND_GROUP_LIST_UPDATED:"onFriendGroupListUpdated",FRIEND_APPLICATION_LIST_UPDATED:"onFriendApplicationListUpdated",KICKED_OUT:"kickedOut",ERROR:"error",NET_STATE_CHANGE:"netStateChange",SDK_RELOAD:"sdkReload"},D={MSG_TEXT:"TIMTextElem",MSG_IMAGE:"TIMImageElem",MSG_SOUND:"TIMSoundElem",MSG_AUDIO:"TIMSoundElem",MSG_FILE:"TIMFileElem",MSG_FACE:"TIMFaceElem",MSG_VIDEO:"TIMVideoFileElem",MSG_GEO:"TIMLocationElem",MSG_LOCATION:"TIMLocationElem",MSG_GRP_TIP:"TIMGroupTipElem",MSG_GRP_SYS_NOTICE:"TIMGroupSystemNoticeElem",MSG_CUSTOM:"TIMCustomElem",MSG_MERGER:"TIMRelayElem",MSG_PRIORITY_HIGH:"High",MSG_PRIORITY_NORMAL:"Normal",MSG_PRIORITY_LOW:"Low",MSG_PRIORITY_LOWEST:"Lowest",CONV_C2C:"C2C",CONV_GROUP:"GROUP",CONV_TOPIC:"TOPIC",CONV_SYSTEM:"@TIM#SYSTEM",CONV_AT_ME:1,CONV_AT_ALL:2,CONV_AT_ALL_AT_ME:3,GRP_PRIVATE:"Private",GRP_WORK:"Private",GRP_PUBLIC:"Public",GRP_CHATROOM:"ChatRoom",GRP_MEETING:"ChatRoom",GRP_AVCHATROOM:"AVChatRoom",GRP_COMMUNITY:"Community",GRP_MBR_ROLE_OWNER:"Owner",GRP_MBR_ROLE_ADMIN:"Admin",GRP_MBR_ROLE_MEMBER:"Member",GRP_MBR_ROLE_CUSTOM:"Custom",GRP_TIP_MBR_JOIN:1,GRP_TIP_MBR_QUIT:2,GRP_TIP_MBR_KICKED_OUT:3,GRP_TIP_MBR_SET_ADMIN:4,GRP_TIP_MBR_CANCELED_ADMIN:5,GRP_TIP_GRP_PROFILE_UPDATED:6,GRP_TIP_MBR_PROFILE_UPDATED:7,MSG_REMIND_ACPT_AND_NOTE:"AcceptAndNotify",MSG_REMIND_ACPT_NOT_NOTE:"AcceptNotNotify",MSG_REMIND_DISCARD:"Discard",GENDER_UNKNOWN:"Gender_Type_Unknown",GENDER_FEMALE:"Gender_Type_Female",GENDER_MALE:"Gender_Type_Male",KICKED_OUT_MULT_ACCOUNT:"multipleAccount",KICKED_OUT_MULT_DEVICE:"multipleDevice",KICKED_OUT_USERSIG_EXPIRED:"userSigExpired",KICKED_OUT_REST_API:"REST_API_Kick",ALLOW_TYPE_ALLOW_ANY:"AllowType_Type_AllowAny",ALLOW_TYPE_NEED_CONFIRM:"AllowType_Type_NeedConfirm",ALLOW_TYPE_DENY_ANY:"AllowType_Type_DenyAny",FORBID_TYPE_NONE:"AdminForbid_Type_None",FORBID_TYPE_SEND_OUT:"AdminForbid_Type_SendOut",JOIN_OPTIONS_FREE_ACCESS:"FreeAccess",JOIN_OPTIONS_NEED_PERMISSION:"NeedPermission",JOIN_OPTIONS_DISABLE_APPLY:"DisableApply",JOIN_STATUS_SUCCESS:"JoinedSuccess",JOIN_STATUS_ALREADY_IN_GROUP:"AlreadyInGroup",JOIN_STATUS_WAIT_APPROVAL:"WaitAdminApproval",GRP_PROFILE_OWNER_ID:"ownerID",GRP_PROFILE_CREATE_TIME:"createTime",GRP_PROFILE_LAST_INFO_TIME:"lastInfoTime",GRP_PROFILE_MEMBER_NUM:"memberNum",GRP_PROFILE_MAX_MEMBER_NUM:"maxMemberNum",GRP_PROFILE_JOIN_OPTION:"joinOption",GRP_PROFILE_INTRODUCTION:"introduction",GRP_PROFILE_NOTIFICATION:"notification",GRP_PROFILE_MUTE_ALL_MBRS:"muteAllMembers",SNS_ADD_TYPE_SINGLE:"Add_Type_Single",SNS_ADD_TYPE_BOTH:"Add_Type_Both",SNS_DELETE_TYPE_SINGLE:"Delete_Type_Single",SNS_DELETE_TYPE_BOTH:"Delete_Type_Both",SNS_APPLICATION_TYPE_BOTH:"Pendency_Type_Both",SNS_APPLICATION_SENT_TO_ME:"Pendency_Type_ComeIn",SNS_APPLICATION_SENT_BY_ME:"Pendency_Type_SendOut",SNS_APPLICATION_AGREE:"Response_Action_Agree",SNS_APPLICATION_AGREE_AND_ADD:"Response_Action_AgreeAndAdd",SNS_CHECK_TYPE_BOTH:"CheckResult_Type_Both",SNS_CHECK_TYPE_SINGLE:"CheckResult_Type_Single",SNS_TYPE_NO_RELATION:"CheckResult_Type_NoRelation",SNS_TYPE_A_WITH_B:"CheckResult_Type_AWithB",SNS_TYPE_B_WITH_A:"CheckResult_Type_BWithA",SNS_TYPE_BOTH_WAY:"CheckResult_Type_BothWay",NET_STATE_CONNECTED:"connected",NET_STATE_CONNECTING:"connecting",NET_STATE_DISCONNECTED:"disconnected",MSG_AT_ALL:"__kImSDK_MesssageAtALL__",READ_ALL_C2C_MSG:"readAllC2CMessage",READ_ALL_GROUP_MSG:"readAllGroupMessage",READ_ALL_MSG:"readAllMessage"},N=function(){function e(){n(this,e),this.cache=[],this.options=null}return s(e,[{key:"use",value:function(e){if("function"!=typeof e)throw"middleware must be a function";return this.cache.push(e),this}},{key:"next",value:function(e){if(this.middlewares&&this.middlewares.length>0)return this.middlewares.shift().call(this,this.options,this.next.bind(this))}},{key:"run",value:function(e){return this.middlewares=this.cache.map((function(e){return e})),this.options=e,this.next()}}]),e}(),A="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function O(e,t){return e(t={exports:{}},t.exports),t.exports}var R=O((function(e,t){var o,n,a,s,r,i,c,u,l,d,p,g,_,h,f,m,M,v;e.exports=(o="function"==typeof Promise,n="object"==typeof self?self:A,a="undefined"!=typeof Symbol,s="undefined"!=typeof Map,r="undefined"!=typeof Set,i="undefined"!=typeof WeakMap,c="undefined"!=typeof WeakSet,u="undefined"!=typeof DataView,l=a&&void 0!==Symbol.iterator,d=a&&void 0!==Symbol.toStringTag,p=r&&"function"==typeof Set.prototype.entries,g=s&&"function"==typeof Map.prototype.entries,_=p&&Object.getPrototypeOf((new Set).entries()),h=g&&Object.getPrototypeOf((new Map).entries()),f=l&&"function"==typeof Array.prototype[Symbol.iterator],m=f&&Object.getPrototypeOf([][Symbol.iterator]()),M=l&&"function"==typeof String.prototype[Symbol.iterator],v=M&&Object.getPrototypeOf(""[Symbol.iterator]()),function(e){var t=typeof e;if("object"!==t)return t;if(null===e)return"null";if(e===n)return"global";if(Array.isArray(e)&&(!1===d||!(Symbol.toStringTag in e)))return"Array";if("object"==typeof window&&null!==window){if("object"==typeof window.location&&e===window.location)return"Location";if("object"==typeof window.document&&e===window.document)return"Document";if("object"==typeof window.navigator){if("object"==typeof window.navigator.mimeTypes&&e===window.navigator.mimeTypes)return"MimeTypeArray";if("object"==typeof window.navigator.plugins&&e===window.navigator.plugins)return"PluginArray"}if(("function"==typeof window.HTMLElement||"object"==typeof window.HTMLElement)&&e instanceof window.HTMLElement){if("BLOCKQUOTE"===e.tagName)return"HTMLQuoteElement";if("TD"===e.tagName)return"HTMLTableDataCellElement";if("TH"===e.tagName)return"HTMLTableHeaderCellElement"}}var a=d&&e[Symbol.toStringTag];if("string"==typeof a)return a;var l=Object.getPrototypeOf(e);return l===RegExp.prototype?"RegExp":l===Date.prototype?"Date":o&&l===Promise.prototype?"Promise":r&&l===Set.prototype?"Set":s&&l===Map.prototype?"Map":c&&l===WeakSet.prototype?"WeakSet":i&&l===WeakMap.prototype?"WeakMap":u&&l===DataView.prototype?"DataView":s&&l===h?"Map Iterator":r&&l===_?"Set Iterator":f&&l===m?"Array Iterator":M&&l===v?"String Iterator":null===l?"Object":Object.prototype.toString.call(e).slice(8,-1)})})),L=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;n(this,e),this.high=t,this.low=o}return s(e,[{key:"equal",value:function(e){return null!==e&&(this.low===e.low&&this.high===e.high)}},{key:"toString",value:function(){var e=Number(this.high).toString(16),t=Number(this.low).toString(16);if(t.length<8)for(var o=8-t.length;o;)t="0"+t,o--;return e+t}}]),e}(),k={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"}},PRODUCTION:{CHINA:{DEFAULT:"wss://wss.im.qcloud.com",BACKUP:"wss://wss.tim.qq.com",STAT:"https://api.im.qcloud.com"},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"},KOREA:{DEFAULT:"wss://wsskr.im.qcloud.com",BACKUP:"wss://wsskr.my-imcloud.com",STAT:"https://apikr.my-imcloud.com"},GERMANY:{DEFAULT:"wss://wssger.im.qcloud.com",BACKUP:"wss://wssger.my-imcloud.com",STAT:"https://apiger.my-imcloud.com"},IND:{DEFAULT:"wss://wssind.im.qcloud.com",BACKUP:"wss://wssind.my-imcloud.com",STAT:"https://apiind.my-imcloud.com"}}},G={WEB:7,WX_MP:8,QQ_MP:9,TT_MP:10,BAIDU_MP:11,ALI_MP:12,UNI_NATIVE_APP:15},P="1.7.3",U=537048168,w="CHINA",b="OVERSEA",F="SINGAPORE",q="KOREA",V="GERMANY",K="IND",H={HOST:{CURRENT:{DEFAULT:"wss://wss.im.qcloud.com",STAT:"https://api.im.qcloud.com"},setCurrent:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:w;this.CURRENT=k.PRODUCTION[e]}},NAME:{OPEN_IM:"openim",GROUP:"group_open_http_svc",GROUP_COMMUNITY:"million_group_open_http_svc",GROUP_ATTR:"group_open_attr_http_svc",FRIEND:"sns",PROFILE:"profile",RECENT_CONTACT:"recentcontact",PIC:"openpic",BIG_GROUP_NO_AUTH:"group_open_http_noauth_svc",BIG_GROUP_LONG_POLLING:"group_open_long_polling_http_svc",BIG_GROUP_LONG_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_MESSAGE:"im_long_msg",IM_CONFIG_MANAGER:"im_sdk_config_mgr",STAT_SERVICE:"StatSvc",OVERLOAD_PUSH:"OverLoadPush"},CMD:{ACCESS_LAYER:"accesslayer",LOGIN:"wslogin",LOGOUT_LONG_POLL:"longpollinglogout",LOGOUT:"wslogout",HELLO:"wshello",PORTRAIT_GET:"portrait_get_all",PORTRAIT_SET:"portrait_set",GET_LONG_POLL_ID:"getlongpollingid",LONG_POLL:"longpolling",AVCHATROOM_LONG_POLL:"get_msg",ADD_FRIEND:"friend_add",UPDATE_FRIEND:"friend_update",GET_FRIEND_LIST:"friend_get",GET_FRIEND_PROFILE:"friend_get_list",DELETE_FRIEND:"friend_delete",CHECK_FRIEND:"friend_check",GET_FRIEND_GROUP_LIST:"group_get",RESPOND_FRIEND_APPLICATION:"friend_response",GET_FRIEND_APPLICATION_LIST:"pendency_get",DELETE_FRIEND_APPLICATION:"pendency_delete",REPORT_FRIEND_APPLICATION:"pendency_report",GET_GROUP_APPLICATION:"get_pendency",CREATE_FRIEND_GROUP:"group_add",DELETE_FRIEND_GROUP:"group_delete",UPDATE_FRIEND_GROUP:"group_update",GET_BLACKLIST:"black_list_get",ADD_BLACKLIST:"black_list_add",DELETE_BLACKLIST:"black_list_delete",CREATE_GROUP:"create_group",GET_JOINED_GROUPS:"get_joined_group_list",SET_GROUP_ATTRIBUTES:"set_group_attr",MODIFY_GROUP_ATTRIBUTES:"modify_group_attr",DELETE_GROUP_ATTRIBUTES:"delete_group_attr",CLEAR_GROUP_ATTRIBUTES:"clear_group_attr",GET_GROUP_ATTRIBUTES:"get_group_attr",SEND_MESSAGE:"sendmsg",REVOKE_C2C_MESSAGE:"msgwithdraw",DELETE_C2C_MESSAGE:"delete_c2c_msg_ramble",MODIFY_C2C_MESSAGE:"modify_c2c_msg",SEND_GROUP_MESSAGE:"send_group_msg",REVOKE_GROUP_MESSAGE:"group_msg_recall",DELETE_GROUP_MESSAGE:"delete_group_ramble_msg_by_seq",MODIFY_GROUP_MESSAGE:"modify_group_msg",GET_GROUP_INFO:"get_group_self_member_info",GET_GROUP_MEMBER_INFO:"get_specified_group_member_info",GET_GROUP_MEMBER_LIST:"get_group_member_info",QUIT_GROUP:"quit_group",CHANGE_GROUP_OWNER:"change_group_owner",DESTROY_GROUP:"destroy_group",ADD_GROUP_MEMBER:"add_group_member",DELETE_GROUP_MEMBER:"delete_group_member",SEARCH_GROUP_BY_ID:"get_group_public_info",APPLY_JOIN_GROUP:"apply_join_group",HANDLE_APPLY_JOIN_GROUP:"handle_apply_join_group",HANDLE_GROUP_INVITATION:"handle_invite_join_group",MODIFY_GROUP_INFO:"modify_group_base_info",MODIFY_GROUP_MEMBER_INFO:"modify_group_member_info",DELETE_GROUP_SYSTEM_MESSAGE:"deletemsg",DELETE_GROUP_AT_TIPS:"deletemsg",GET_CONVERSATION_LIST:"get",PAGING_GET_CONVERSATION_LIST:"page_get",DELETE_CONVERSATION:"delete",PIN_CONVERSATION:"top",GET_MESSAGES:"getmsg",GET_C2C_ROAM_MESSAGES:"getroammsg",SET_C2C_PEER_MUTE_NOTIFICATIONS:"set_c2c_peer_mute_notifications",GET_C2C_PEER_MUTE_NOTIFICATIONS:"get_c2c_peer_mute_notifications",GET_GROUP_ROAM_MESSAGES:"group_msg_get",GET_READ_RECEIPT:"get_group_msg_receipt",GET_READ_RECEIPT_DETAIL:"get_group_msg_receipt_detail",SEND_READ_RECEIPT:"group_msg_receipt",SEND_C2C_READ_RECEIPT:"c2c_msg_read_receipt",SET_C2C_MESSAGE_READ:"msgreaded",GET_PEER_READ_TIME:"get_peer_read_time",SET_GROUP_MESSAGE_READ:"msg_read_report",FILE_READ_AND_WRITE_AUTHKEY:"authkey",FILE_UPLOAD:"pic_up",COS_SIGN:"cos",COS_PRE_SIG:"pre_sig",VIDEO_COVER:"video_cover",TIM_WEB_REPORT_V2:"tim_web_report_v2",BIG_DATA_HALLWAY_AUTH_KEY:"authkey",GET_ONLINE_MEMBER_NUM:"get_online_member_num",ALIVE:"alive",MESSAGE_PUSH:"msg_push",MULTI_MESSAGE_PUSH:"multi_msg_push_ws",MESSAGE_PUSH_ACK:"ws_msg_push_ack",STATUS_FORCE_OFFLINE:"stat_forceoffline",DOWNLOAD_MERGER_MESSAGE:"get_relay_json_msg",UPLOAD_MERGER_MESSAGE:"save_relay_json_msg",FETCH_CLOUD_CONTROL_CONFIG:"fetch_config",PUSHED_CLOUD_CONTROL_CONFIG:"push_configv2",FETCH_COMMERCIAL_CONFIG:"fetch_imsdk_purchase_bitsv2",PUSHED_COMMERCIAL_CONFIG:"push_imsdk_purchase_bitsv2",KICK_OTHER:"KickOther",OVERLOAD_NOTIFY:"notify2",SET_ALL_MESSAGE_READ:"read_all_unread_msg",CREATE_TOPIC:"create_topic",DELETE_TOPIC:"destroy_topic",UPDATE_TOPIC_PROFILE:"modify_topic",GET_TOPIC_LIST:"get_topic"},CHANNEL:{SOCKET:1,XHR:2,AUTO:0},NAME_VERSION:{openim:"v4",group_open_http_svc:"v4",sns:"v4",profile:"v4",recentcontact:"v4",openpic:"v4",group_open_http_noauth_svc:"v4",group_open_long_polling_http_svc:"v4",group_open_long_polling_http_noauth_svc:"v4",imopenstat:"v4",im_cos_sign_svr:"v4",im_cos_msg:"v4",webim:"v4",im_open_push:"v4",im_open_status:"v4"}},B={SEARCH_MSG:new L(0,Math.pow(2,0)).toString(),SEARCH_GRP_SNS:new L(0,Math.pow(2,1)).toString(),AVCHATROOM_HISTORY_MSG:new L(0,Math.pow(2,2)).toString(),GRP_COMMUNITY:new L(0,Math.pow(2,3)).toString(),MSG_TO_SPECIFIED_GRP_MBR:new L(0,Math.pow(2,4)).toString()};H.HOST.setCurrent(w);var x,W,Y,j,$="undefined"!=typeof wx&&"function"==typeof wx.getSystemInfoSync&&Boolean(wx.getSystemInfoSync().fontSizeSetting),z="undefined"!=typeof qq&&"function"==typeof qq.getSystemInfoSync&&Boolean(qq.getSystemInfoSync().fontSizeSetting),J="undefined"!=typeof tt&&"function"==typeof tt.getSystemInfoSync&&Boolean(tt.getSystemInfoSync().fontSizeSetting),X="undefined"!=typeof swan&&"function"==typeof swan.getSystemInfoSync&&Boolean(swan.getSystemInfoSync().fontSizeSetting),Q="undefined"!=typeof my&&"function"==typeof my.getSystemInfoSync&&Boolean(my.getSystemInfoSync().fontSizeSetting),Z="undefined"!=typeof uni&&"undefined"==typeof window,ee="undefined"!=typeof uni,te=$||z||J||X||Q||Z,oe=("undefined"!=typeof uni||"undefined"!=typeof window)&&!te,ne=z?qq:J?tt:X?swan:Q?my:$?wx:Z?uni:{},ae=(x="WEB",ve?x="WEB":z?x="QQ_MP":J?x="TT_MP":X?x="BAIDU_MP":Q?x="ALI_MP":$?x="WX_MP":Z&&(x="UNI_NATIVE_APP"),G[x]),se=oe&&window&&window.navigator&&window.navigator.userAgent||"",re=/AppleWebKit\/([\d.]+)/i.exec(se),ie=(re&&parseFloat(re.pop()),/iPad/i.test(se)),ce=/iPhone/i.test(se)&&!ie,ue=/iPod/i.test(se),le=ce||ie||ue,de=(W=se.match(/OS (\d+)_/i))&&W[1]?W[1]:null,pe=/Android/i.test(se),ge=function(){var e=se.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);if(!e)return null;var t=e[1]&&parseFloat(e[1]),o=e[2]&&parseFloat(e[2]);return t&&o?parseFloat(e[1]+"."+e[2]):t||null}(),_e=(pe&&/webkit/i.test(se),/Firefox/i.test(se),/Edge/i.test(se)),he=!_e&&/Chrome/i.test(se),fe=(function(){var e=se.match(/Chrome\/(\d+)/);e&&e[1]&&parseFloat(e[1])}(),/MSIE/.test(se)||se.indexOf("Trident")>-1&&se.indexOf("rv:11.0")>-1),me=(/MSIE\s8\.0/.test(se),function(){var e=/MSIE\s(\d+)\.\d/.exec(se),t=e&&parseFloat(e[1]);return!t&&/Trident\/7.0/i.test(se)&&/rv:11.0/.test(se)&&(t=11),t}()),Me=(/Safari/i.test(se),/TBS\/\d+/i.test(se)),ve=(function(){var e=se.match(/TBS\/(\d+)/i);if(e&&e[1])e[1]}(),!Me&&/MQQBrowser\/\d+/i.test(se),!Me&&/ QQBrowser\/\d+/i.test(se),/(micromessenger|webbrowser)/i.test(se)),ye=/Windows/i.test(se),Ie=/MAC OS X/i.test(se),Ee=(/MicroMessenger/i.test(se),oe&&"undefined"!=typeof Worker&&!fe),Te=pe||le,Ce="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};Y="undefined"!=typeof console?console:void 0!==Ce&&Ce.console?Ce.console:"undefined"!=typeof window&&window.console?window.console:{};for(var Se=function(){},De=["assert","clear","count","debug","dir","dirxml","error","group","groupCollapsed","groupEnd","info","log","profile","profileEnd","table","time","timeEnd","timeStamp","trace","warn"],Ne=De.length;Ne--;)j=De[Ne],console[j]||(Y[j]=Se);var Ae=Y,Oe=0,Re=function(){return(new Date).getTime()+Oe},Le=function(){Oe=0},ke=function(){return Math.floor(Re()/1e3)},Ge=0,Pe=new Map;function Ue(){var e,t=((e=new Date).setTime(Re()),e);return"TIM "+t.toLocaleTimeString("en-US",{hour12:!1})+"."+function(e){var t;switch(e.toString().length){case 1:t="00"+e;break;case 2:t="0"+e;break;default:t=e}return t}(t.getMilliseconds())+":"}var we={arguments2String:function(e){var t;if(1===e.length)t=Ue()+e[0];else{t=Ue();for(var o=0,n=e.length;o4294967295?(rt+=4294967295,Date.now()-rt):e},utc:function(){return Math.round(Date.now()/1e3)}},ct=function e(t,o,n,a){if(!et(t)||!et(o))return 0;for(var s,r=0,i=Object.keys(o),c=0,u=i.length;c=0?n[s]=t[s]:n[s]=e(t[s])):n[s]=void 0:n[s]=null;return n};function vt(e,t){Qe(e)&&Qe(t)?t.forEach((function(t){var o=t.key,n=t.value,a=e.find((function(e){return e.key===o}));a?a.value=n:e.push({key:o,value:n})})):we.warn("updateCustomField target 或 source 不是数组,忽略此次更新。")}var yt=function(e){return e===D.GRP_PUBLIC},It=function(e){return e===D.GRP_AVCHATROOM},Et=function(e){var t=e.type,o=e.groupID;return t===D.GRP_COMMUNITY||"".concat(o).startsWith(xe)&&!"".concat(o).includes(We)},Tt=function(e){return"".concat(e).startsWith(xe)&&"".concat(e).includes(We)},Ct=function(e){return ze(e)&&e.slice(0,3)===D.CONV_C2C},St=function(e){return ze(e)&&e.slice(0,5)===D.CONV_GROUP},Dt=function(e){return ze(e)&&e===D.CONV_SYSTEM};function Nt(e,t){var o={};return Object.keys(e).forEach((function(n){o[n]=t(e[n],n)})),o}function At(e){return te?new Promise((function(t,o){ne.getImageInfo({src:e,success:function(e){t({width:e.width,height:e.height})},fail:function(){t({width:0,height:0})}})})):fe&&9===me?Promise.resolve({width:0,height:0}):new Promise((function(t,o){var n=new Image;n.onload=function(){t({width:this.width,height:this.height}),n=null},n.onerror=function(){t({width:0,height:0}),n=null},n.src=e}))}function Ot(){function e(){return(65536*(1+Math.random())|0).toString(16).substring(1)}return"".concat(e()+e()).concat(e()).concat(e()).concat(e()).concat(e()).concat(e()).concat(e())}function Rt(){var e="unknown";if(Ie&&(e="mac"),ye&&(e="windows"),le&&(e="ios"),pe&&(e="android"),te)try{var t=ne.getSystemInfoSync().platform;void 0!==t&&(e=t)}catch(o){}return e}function Lt(e){var t=e.originUrl,o=void 0===t?void 0:t,n=e.originWidth,a=e.originHeight,s=e.min,r=void 0===s?198:s,i=parseInt(n),c=parseInt(a),u={url:void 0,width:0,height:0};if((i<=c?i:c)<=r)u.url=o,u.width=i,u.height=c;else{c<=i?(u.width=Math.ceil(i*r/c),u.height=r):(u.width=r,u.height=Math.ceil(c*r/i));var l=o&&o.indexOf("?")>-1?"".concat(o,"&"):"".concat(o,"?");u.url="".concat(l,198===r?"imageView2/3/w/198/h/198":"imageView2/3/w/720/h/720")}return Ze(o)?g(u,Ye):u}function kt(e){var t=e[2];e[2]=e[1],e[1]=t;for(var o=0;o=0}}},setGroupMemberNameCard:{groupID:zt,userID:{type:"String"},nameCard:{type:"String",validator:function(e){return ze(e)?(e.length,!0):(console.warn($t({api:"setGroupMemberNameCard",param:"nameCard",desc:"类型必须为 String"})),!1)}}},setGroupMemberCustomField:{groupID:zt,userID:{type:"String"},memberCustomField:Jt},deleteGroupMember:{groupID:zt},createTextMessage:{to:zt,conversationType:zt,payload:t(t({},Xt),{},{validator:function(e){return Xe(e)?ze(e.text)?0!==e.text.length||(console.warn($t({api:"createTextMessage",desc:"消息内容不能为空"})),!1):(console.warn($t({api:"createTextMessage",param:"payload.text",desc:"类型必须为 String"})),!1):(console.warn($t({api:"createTextMessage",param:"payload",desc:"类型必须为 plain object"})),!1)}})},createTextAtMessage:{to:zt,conversationType:zt,payload:t(t({},Xt),{},{validator:function(e){return Xe(e)?ze(e.text)?0===e.text.length?(console.warn($t({api:"createTextAtMessage",desc:"消息内容不能为空"})),!1):!(e.atUserList&&!Qe(e.atUserList))||(console.warn($t({api:"createTextAtMessage",desc:"payload.atUserList 类型必须为数组"})),!1):(console.warn($t({api:"createTextAtMessage",param:"payload.text",desc:"类型必须为 String"})),!1):(console.warn($t({api:"createTextAtMessage",param:"payload",desc:"类型必须为 plain object"})),!1)}})},createCustomMessage:{to:zt,conversationType:zt,payload:t(t({},Xt),{},{validator:function(e){return Xe(e)?e.data&&!ze(e.data)?(console.warn($t({api:"createCustomMessage",param:"payload.data",desc:"类型必须为 String"})),!1):e.description&&!ze(e.description)?(console.warn($t({api:"createCustomMessage",param:"payload.description",desc:"类型必须为 String"})),!1):!(e.extension&&!ze(e.extension))||(console.warn($t({api:"createCustomMessage",param:"payload.extension",desc:"类型必须为 String"})),!1):(console.warn($t({api:"createCustomMessage",param:"payload",desc:"类型必须为 plain object"})),!1)}})},createImageMessage:{to:zt,conversationType:zt,payload:t(t({},Xt),{},{validator:function(e){if(!Xe(e))return console.warn($t({api:"createImageMessage",param:"payload",desc:"类型必须为 plain object"})),!1;if(Ze(e.file))return console.warn($t({api:"createImageMessage",param:"payload.file",desc:"不能为 undefined"})),!1;if(oe){if(!(e.file instanceof HTMLInputElement||je(e.file)))return Xe(e.file)&&"undefined"!=typeof uni?0!==e.file.tempFilePaths.length&&0!==e.file.tempFiles.length||(console.warn($t({api:"createImageMessage",param:"payload.file",desc:"您没有选择文件,无法发送"})),!1):(console.warn($t({api:"createImageMessage",param:"payload.file",desc:"类型必须是 HTMLInputElement 或 File"})),!1);if(e.file instanceof HTMLInputElement&&0===e.file.files.length)return console.warn($t({api:"createImageMessage",param:"payload.file",desc:"您没有选择文件,无法发送"})),!1}return!0},onProgress:{type:"Function",required:!1,validator:function(e){return Ze(e)&&console.warn($t({api:"createImageMessage",desc:"没有 onProgress 回调,您将无法获取上传进度"})),!0}}})},createAudioMessage:{to:zt,conversationType:zt,payload:t(t({},Xt),{},{validator:function(e){return!!Xe(e)||(console.warn($t({api:"createAudioMessage",param:"payload",desc:"类型必须为 plain object"})),!1)}}),onProgress:{type:"Function",required:!1,validator:function(e){return Ze(e)&&console.warn($t({api:"createAudioMessage",desc:"没有 onProgress 回调,您将无法获取上传进度"})),!0}}},createVideoMessage:{to:zt,conversationType:zt,payload:t(t({},Xt),{},{validator:function(e){if(!Xe(e))return console.warn($t({api:"createVideoMessage",param:"payload",desc:"类型必须为 plain object"})),!1;if(Ze(e.file))return console.warn($t({api:"createVideoMessage",param:"payload.file",desc:"不能为 undefined"})),!1;if(oe){if(!(e.file instanceof HTMLInputElement||je(e.file)))return Xe(e.file)&&"undefined"!=typeof uni?!!je(e.file.tempFile)||(console.warn($t({api:"createVideoMessage",param:"payload.file",desc:"您没有选择文件,无法发送"})),!1):(console.warn($t({api:"createVideoMessage",param:"payload.file",desc:"类型必须是 HTMLInputElement 或 File"})),!1);if(e.file instanceof HTMLInputElement&&0===e.file.files.length)return console.warn($t({api:"createVideoMessage",param:"payload.file",desc:"您没有选择文件,无法发送"})),!1}return!0}}),onProgress:{type:"Function",required:!1,validator:function(e){return Ze(e)&&console.warn($t({api:"createVideoMessage",desc:"没有 onProgress 回调,您将无法获取上传进度"})),!0}}},createFaceMessage:{to:zt,conversationType:zt,payload:t(t({},Xt),{},{validator:function(e){return Xe(e)?$e(e.index)?!!ze(e.data)||(console.warn($t({api:"createFaceMessage",param:"payload.data",desc:"类型必须为 String"})),!1):(console.warn($t({api:"createFaceMessage",param:"payload.index",desc:"类型必须为 Number"})),!1):(console.warn($t({api:"createFaceMessage",param:"payload",desc:"类型必须为 plain object"})),!1)}})},createFileMessage:{to:zt,conversationType:zt,payload:t(t({},Xt),{},{validator:function(e){if(!Xe(e))return console.warn($t({api:"createFileMessage",param:"payload",desc:"类型必须为 plain object"})),!1;if(Ze(e.file))return console.warn($t({api:"createFileMessage",param:"payload.file",desc:"不能为 undefined"})),!1;if(oe){if(!(e.file instanceof HTMLInputElement||je(e.file)))return Xe(e.file)&&"undefined"!=typeof uni?0!==e.file.tempFilePaths.length&&0!==e.file.tempFiles.length||(console.warn($t({api:"createFileMessage",param:"payload.file",desc:"您没有选择文件,无法发送"})),!1):(console.warn($t({api:"createFileMessage",param:"payload.file",desc:"类型必须是 HTMLInputElement 或 File"})),!1);if(e.file instanceof HTMLInputElement&&0===e.file.files.length)return console.warn($t({api:"createFileMessage",desc:"您没有选择文件,无法发送"})),!1}return!0}}),onProgress:{type:"Function",required:!1,validator:function(e){return Ze(e)&&console.warn($t({api:"createFileMessage",desc:"没有 onProgress 回调,您将无法获取上传进度"})),!0}}},createLocationMessage:{to:zt,conversationType:zt,payload:t(t({},Xt),{},{validator:function(e){return Xe(e)?ze(e.description)?$e(e.longitude)?!!$e(e.latitude)||(console.warn($t({api:"createLocationMessage",param:"payload.latitude",desc:"类型必须为 Number"})),!1):(console.warn($t({api:"createLocationMessage",param:"payload.longitude",desc:"类型必须为 Number"})),!1):(console.warn($t({api:"createLocationMessage",param:"payload.description",desc:"类型必须为 String"})),!1):(console.warn($t({api:"createLocationMessage",param:"payload",desc:"类型必须为 plain object"})),!1)}})},createMergerMessage:{to:zt,conversationType:zt,payload:t(t({},Xt),{},{validator:function(e){if(Vt(e.messageList))return console.warn($t({api:"createMergerMessage",desc:"不能为空数组"})),!1;if(Vt(e.compatibleText))return console.warn($t({api:"createMergerMessage",desc:"类型必须为 String,且不能为空"})),!1;var t=!1;return e.messageList.forEach((function(e){e.status===xt.FAIL&&(t=!0)})),!t||(console.warn($t({api:"createMergerMessage",desc:"不支持合并已发送失败的消息"})),!1)}})},revokeMessage:[t(t({name:"message"},Xt),{},{validator:function(e){return Vt(e)?(console.warn($t({api:"revokeMessage",desc:"请传入消息(Message)实例"})),!1):e.conversationType===D.CONV_SYSTEM?(console.warn($t({api:"revokeMessage",desc:"不能撤回系统会话消息,只能撤回单聊消息或群消息"})),!1):!0!==e.isRevoked||(console.warn($t({api:"revokeMessage",desc:"消息已经被撤回,请勿重复操作"})),!1)}})],deleteMessage:[t(t({name:"messageList"},Jt),{},{validator:function(e){return!Vt(e)||(console.warn($t({api:"deleteMessage",param:"messageList",desc:"不能为空数组"})),!1)}})],modifyMessage:[t(t({name:"message"},Xt),{},{validator:function(e){return Vt(e)?(console.warn($t({api:"modifyMessage",desc:"请传入消息(Message)实例"})),!1):e.conversationType===D.CONV_SYSTEM?(console.warn($t({api:"modifyMessage",desc:"不支持修改系统会话消息,只能修改单聊消息或群消息"})),!1):!0===e._onlineOnlyFlag?(console.warn($t({api:"modifyMessage",desc:"不支持修改在线消息"})),!1):-1!==[D.MSG_TEXT,D.MSG_CUSTOM,D.MSG_LOCATION,D.MSG_FACE].indexOf(e.type)||(console.warn($t({api:"modifyMessage",desc:"只支持修改文本消息、自定义消息、地理位置消息和表情消息"})),!1)}})],getUserProfile:{userIDList:{type:"Array",validator:function(e){return Qe(e)?(0===e.length&&console.warn($t({api:"getUserProfile",param:"userIDList",desc:"不能为空数组"})),!0):(console.warn($t({api:"getUserProfile",param:"userIDList",desc:"必须为数组"})),!1)}}},updateMyProfile:{profileCustomField:{type:"Array",validator:function(e){return!!Ze(e)||(!!Qe(e)||(console.warn($t({api:"updateMyProfile",param:"profileCustomField",desc:"必须为数组"})),!1))}}},addFriend:{to:zt,source:{type:"String",required:!0,validator:function(e){return!!e&&(e.startsWith("AddSource_Type_")?!(e.replace("AddSource_Type_","").length>8)||(console.warn($t({api:"addFriend",desc:"加好友来源字段的关键字长度不得超过8字节"})),!1):(console.warn($t({api:"addFriend",desc:"加好友来源字段的前缀必须是:AddSource_Type_"})),!1))}},remark:{type:"String",required:!1,validator:function(e){return!(ze(e)&&e.length>96)||(console.warn($t({api:"updateFriend",desc:" 备注长度最长不得超过 96 个字节"})),!1)}}},deleteFriend:{userIDList:Jt},checkFriend:{userIDList:Jt},getFriendProfile:{userIDList:Jt},updateFriend:{userID:zt,remark:{type:"String",required:!1,validator:function(e){return!(ze(e)&&e.length>96)||(console.warn($t({api:"updateFriend",desc:" 备注长度最长不得超过 96 个字节"})),!1)}},friendCustomField:{type:"Array",required:!1,validator:function(e){if(e){if(!Qe(e))return console.warn($t({api:"updateFriend",param:"friendCustomField",desc:"必须为数组"})),!1;var t=!0;return e.forEach((function(e){return ze(e.key)&&-1!==e.key.indexOf("Tag_SNS_Custom")?ze(e.value)?e.value.length>8?(console.warn($t({api:"updateFriend",desc:"好友自定义字段的关键字长度不得超过8字节"})),t=!1):void 0:(console.warn($t({api:"updateFriend",desc:"类型必须为 String"})),t=!1):(console.warn($t({api:"updateFriend",desc:"好友自定义字段的前缀必须是 Tag_SNS_Custom"})),t=!1)})),t}return!0}}},acceptFriendApplication:{userID:zt},refuseFriendApplication:{userID:zt},deleteFriendApplication:{userID:zt},createFriendGroup:{name:zt},deleteFriendGroup:{name:zt},addToFriendGroup:{name:zt,userIDList:Jt},removeFromFriendGroup:{name:zt,userIDList:Jt},renameFriendGroup:{oldName:zt,newName:zt},sendMessageReadReceipt:[{name:"messageList",type:"Array",validator:function(e){return Qe(e)?0!==e.length||(console.warn($t({api:"sendMessageReadReceipt",param:"messageList",desc:"不能为空数组"})),!1):(console.warn($t({api:"sendMessageReadReceipt",param:"messageList",desc:"必须为数组"})),!1)}}],getMessageReadReceiptList:[{name:"messageList",type:"Array",validator:function(e){return Qe(e)?0!==e.length||(console.warn($t({api:"getMessageReadReceiptList",param:"messageList",desc:"不能为空数组"})),!1):(console.warn($t({api:"getMessageReadReceiptList",param:"messageList",desc:"必须为数组"})),!1)}}],createTopicInCommunity:{groupID:zt,topicName:zt},deleteTopicFromCommunity:{groupID:zt,topicIDList:{type:"Array",validator:function(e){return!e||(!!Qe(e)||(console.warn($t({api:"deleteTopicFromCommunity",param:"topicIDList",desc:"必须为数组"})),!1))}}},updateTopicProfile:{groupID:zt,topicID:zt},getTopicList:{groupID:zt,topicIDList:{type:"Array",validator:function(e){return!e||(!!Qe(e)||(console.warn($t({api:"getTopicList",param:"topicIDList",desc:"必须为数组"})),!1))}}}},Zt={login:"login",logout:"logout",on:"on",once:"once",off:"off",setLogLevel:"setLogLevel",registerPlugin:"registerPlugin",destroy:"destroy",createTextMessage:"createTextMessage",createTextAtMessage:"createTextAtMessage",createImageMessage:"createImageMessage",createAudioMessage:"createAudioMessage",createVideoMessage:"createVideoMessage",createCustomMessage:"createCustomMessage",createFaceMessage:"createFaceMessage",createFileMessage:"createFileMessage",createLocationMessage:"createLocationMessage",createMergerMessage:"createMergerMessage",downloadMergerMessage:"downloadMergerMessage",createForwardMessage:"createForwardMessage",sendMessage:"sendMessage",resendMessage:"resendMessage",revokeMessage:"revokeMessage",deleteMessage:"deleteMessage",modifyMessage:"modifyMessage",sendMessageReadReceipt:"sendMessageReadReceipt",getGroupMessageReadMemberList:"getGroupMessageReadMemberList",getMessageReadReceiptList:"getMessageReadReceiptList",getMessageList:"getMessageList",findMessage:"findMessage",getMessageListHopping:"getMessageListHopping",setMessageRead:"setMessageRead",setAllMessageRead:"setAllMessageRead",getConversationList:"getConversationList",getConversationProfile:"getConversationProfile",deleteConversation:"deleteConversation",pinConversation:"pinConversation",getGroupList:"getGroupList",getGroupProfile:"getGroupProfile",createGroup:"createGroup",joinGroup:"joinGroup",updateGroupProfile:"updateGroupProfile",quitGroup:"quitGroup",dismissGroup:"dismissGroup",changeGroupOwner:"changeGroupOwner",searchGroupByID:"searchGroupByID",setMessageRemindType:"setMessageRemindType",handleGroupApplication:"handleGroupApplication",initGroupAttributes:"initGroupAttributes",setGroupAttributes:"setGroupAttributes",deleteGroupAttributes:"deleteGroupAttributes",getGroupAttributes:"getGroupAttributes",getJoinedCommunityList:"getJoinedCommunityList",createTopicInCommunity:"createTopicInCommunity",deleteTopicFromCommunity:"deleteTopicFromCommunity",updateTopicProfile:"updateTopicProfile",getTopicList:"getTopicList",getGroupMemberProfile:"getGroupMemberProfile",getGroupMemberList:"getGroupMemberList",addGroupMember:"addGroupMember",deleteGroupMember:"deleteGroupMember",setGroupMemberNameCard:"setGroupMemberNameCard",setGroupMemberMuteTime:"setGroupMemberMuteTime",setGroupMemberRole:"setGroupMemberRole",setGroupMemberCustomField:"setGroupMemberCustomField",getGroupOnlineMemberCount:"getGroupOnlineMemberCount",getMyProfile:"getMyProfile",getUserProfile:"getUserProfile",updateMyProfile:"updateMyProfile",getBlacklist:"getBlacklist",addToBlacklist:"addToBlacklist",removeFromBlacklist:"removeFromBlacklist",getFriendList:"getFriendList",addFriend:"addFriend",deleteFriend:"deleteFriend",checkFriend:"checkFriend",updateFriend:"updateFriend",getFriendProfile:"getFriendProfile",getFriendApplicationList:"getFriendApplicationList",refuseFriendApplication:"refuseFriendApplication",deleteFriendApplication:"deleteFriendApplication",acceptFriendApplication:"acceptFriendApplication",setFriendApplicationRead:"setFriendApplicationRead",getFriendGroupList:"getFriendGroupList",createFriendGroup:"createFriendGroup",renameFriendGroup:"renameFriendGroup",deleteFriendGroup:"deleteFriendGroup",addToFriendGroup:"addToFriendGroup",removeFromFriendGroup:"removeFromFriendGroup",callExperimentalAPI:"callExperimentalAPI"},eo="sign",to="message",oo="user",no="c2c",ao="group",so="sns",ro="groupMember",io="Topic",co="conversation",uo="context",lo="storage",po="eventStat",go="netMonitor",_o="bigDataChannel",ho="upload",fo="plugin",mo="syncUnreadMessage",Mo="session",vo="channel",yo="message_loss_detection",Io="cloudControl",Eo="workerTimer",To="pullGroupMessage",Co="qualityStat",So="commercialConfig",Do=function(){function e(t){n(this,e),this._moduleManager=t,this._className=""}return s(e,[{key:"isLoggedIn",value:function(){return this._moduleManager.getModule(uo).isLoggedIn()}},{key:"isOversea",value:function(){return this._moduleManager.getModule(uo).isOversea()}},{key:"isPrivateNetWork",value:function(){return this._moduleManager.getModule(uo).isPrivateNetWork()}},{key:"getMyUserID",value:function(){return this._moduleManager.getModule(uo).getUserID()}},{key:"getMyTinyID",value:function(){return this._moduleManager.getModule(uo).getTinyID()}},{key:"getModule",value:function(e){return this._moduleManager.getModule(e)}},{key:"getPlatform",value:function(){return ae}},{key:"getNetworkType",value:function(){return this._moduleManager.getModule(go).getNetworkType()}},{key:"probeNetwork",value:function(e){return this.isPrivateNetWork()?Promise.resolve([!0,this.getNetworkType()]):this._moduleManager.getModule(go).probe(e)}},{key:"getCloudConfig",value:function(e){return this._moduleManager.getModule(Io).getCloudConfig(e)}},{key:"emitOuterEvent",value:function(e,t){this._moduleManager.getOuterEmitterInstance().emit(e,t)}},{key:"emitInnerEvent",value:function(e,t){this._moduleManager.getInnerEmitterInstance().emit(e,t)}},{key:"getInnerEmitterInstance",value:function(){return this._moduleManager.getInnerEmitterInstance()}},{key:"generateTjgID",value:function(e){return this._moduleManager.getModule(uo).getTinyID()+"-"+e.random}},{key:"filterModifiedMessage",value:function(e){if(!Vt(e)){var t=e.filter((function(e){return!0===e.isModified}));t.length>0&&this.emitOuterEvent(S.MESSAGE_MODIFIED,t)}}},{key:"filterUnmodifiedMessage",value:function(e){return Vt(e)?[]:e.filter((function(e){return!1===e.isModified}))}},{key:"request",value:function(e){return this._moduleManager.getModule(Mo).request(e)}},{key:"canIUse",value:function(e){return this._moduleManager.getModule(So).hasPurchasedFeature(e)}}]),e}(),No="wslogin",Ao="wslogout",Oo="wshello",Ro="KickOther",Lo="getmsg",ko="authkey",Go="sendmsg",Po="send_group_msg",Uo="portrait_get_all",wo="portrait_set",bo="black_list_get",Fo="black_list_add",qo="black_list_delete",Vo="msgwithdraw",Ko="msgreaded",Ho="set_c2c_peer_mute_notifications",Bo="get_c2c_peer_mute_notifications",xo="getroammsg",Wo="get_peer_read_time",Yo="delete_c2c_msg_ramble",jo="modify_c2c_msg",$o="page_get",zo="get",Jo="delete",Xo="top",Qo="deletemsg",Zo="get_joined_group_list",en="get_group_self_member_info",tn="create_group",on="destroy_group",nn="modify_group_base_info",an="apply_join_group",sn="apply_join_group_noauth",rn="quit_group",cn="get_group_public_info",un="change_group_owner",ln="handle_apply_join_group",dn="handle_invite_join_group",pn="group_msg_recall",gn="msg_read_report",_n="read_all_unread_msg",hn="group_msg_get",fn="get_group_msg_receipt",mn="group_msg_receipt",Mn="c2c_msg_read_receipt",vn="get_group_msg_receipt_detail",yn="get_pendency",In="deletemsg",En="get_msg",Tn="get_msg_noauth",Cn="get_online_member_num",Sn="delete_group_ramble_msg_by_seq",Dn="modify_group_msg",Nn="set_group_attr",An="modify_group_attr",On="delete_group_attr",Rn="clear_group_attr",Ln="get_group_attr",kn="get_group_member_info",Gn="get_specified_group_member_info",Pn="add_group_member",Un="delete_group_member",wn="modify_group_member_info",bn="cos",Fn="pre_sig",qn="video_cover",Vn="tim_web_report_v2",Kn="alive",Hn="msg_push",Bn="multi_msg_push_ws",xn="ws_msg_push_ack",Wn="stat_forceoffline",Yn="save_relay_json_msg",jn="get_relay_json_msg",$n="fetch_config",zn="push_configv2",Jn="fetch_imsdk_purchase_bitsv2",Xn="push_imsdk_purchase_bitsv2",Qn="notify2",Zn="create_topic",ea="destroy_topic",ta="modify_topic",oa="get_topic",na={NO_SDKAPPID:2e3,NO_ACCOUNT_TYPE:2001,NO_IDENTIFIER:2002,NO_USERSIG:2003,NO_TINYID:2022,NO_A2KEY:2023,USER_NOT_LOGGED_IN:2024,REPEAT_LOGIN:2025,COS_UNDETECTED:2040,COS_GET_SIG_FAIL:2041,MESSAGE_SEND_FAIL:2100,MESSAGE_LIST_CONSTRUCTOR_NEED_OPTIONS:2103,MESSAGE_SEND_NEED_MESSAGE_INSTANCE:2105,MESSAGE_SEND_INVALID_CONVERSATION_TYPE:2106,MESSAGE_FILE_IS_EMPTY:2108,MESSAGE_ONPROGRESS_FUNCTION_ERROR:2109,MESSAGE_REVOKE_FAIL:2110,MESSAGE_DELETE_FAIL:2111,MESSAGE_UNREAD_ALL_FAIL:2112,MESSAGE_CONTROL_INFO_FAIL:2113,READ_RECEIPT_MESSAGE_LIST_EMPTY:2114,MESSAGE_SEND_GROUP_WITH_TOPIC_FAIL:2115,CANNOT_DELETE_GROUP_SYSTEM_NOTICE:2116,MESSAGE_IMAGE_SELECT_FILE_FIRST:2251,MESSAGE_IMAGE_TYPES_LIMIT:2252,MESSAGE_IMAGE_SIZE_LIMIT:2253,MESSAGE_AUDIO_UPLOAD_FAIL:2300,MESSAGE_AUDIO_SIZE_LIMIT:2301,MESSAGE_VIDEO_UPLOAD_FAIL:2350,MESSAGE_VIDEO_SIZE_LIMIT:2351,MESSAGE_VIDEO_TYPES_LIMIT:2352,MESSAGE_FILE_UPLOAD_FAIL:2400,MESSAGE_FILE_SELECT_FILE_FIRST:2401,MESSAGE_FILE_SIZE_LIMIT:2402,MESSAGE_FILE_URL_IS_EMPTY:2403,MESSAGE_MERGER_TYPE_INVALID:2450,MESSAGE_MERGER_KEY_INVALID:2451,MESSAGE_MERGER_DOWNLOAD_FAIL:2452,MESSAGE_FORWARD_TYPE_INVALID:2453,MESSAGE_AT_TYPE_INVALID:2454,MESSAGE_MODIFY_CONFLICT:2480,MESSAGE_MODIFY_DISABLED_IN_AVCHATROOM:2481,CONVERSATION_NOT_FOUND:2500,USER_OR_GROUP_NOT_FOUND:2501,CONVERSATION_UN_RECORDED_TYPE:2502,ILLEGAL_GROUP_TYPE:2600,CANNOT_JOIN_WORK:2601,ILLEGAL_GROUP_ID:2602,CANNOT_CHANGE_OWNER_IN_AVCHATROOM:2620,CANNOT_CHANGE_OWNER_TO_SELF:2621,CANNOT_DISMISS_Work:2622,MEMBER_NOT_IN_GROUP:2623,CANNOT_USE_GRP_ATTR_NOT_AVCHATROOM:2641,CANNOT_USE_GRP_ATTR_AVCHATROOM_UNJOIN:2642,JOIN_GROUP_FAIL:2660,CANNOT_ADD_MEMBER_IN_AVCHATROOM:2661,CANNOT_JOIN_NON_AVCHATROOM_WITHOUT_LOGIN:2662,CANNOT_KICK_MEMBER_IN_AVCHATROOM:2680,NOT_OWNER:2681,CANNOT_SET_MEMBER_ROLE_IN_WORK_AND_AVCHATROOM:2682,INVALID_MEMBER_ROLE:2683,CANNOT_SET_SELF_MEMBER_ROLE:2684,CANNOT_MUTE_SELF:2685,NOT_MY_FRIEND:2700,ALREADY_MY_FRIEND:2701,FRIEND_GROUP_EXISTED:2710,FRIEND_GROUP_NOT_EXIST:2711,FRIEND_APPLICATION_NOT_EXIST:2716,UPDATE_PROFILE_INVALID_PARAM:2721,UPDATE_PROFILE_NO_KEY:2722,ADD_BLACKLIST_INVALID_PARAM:2740,DEL_BLACKLIST_INVALID_PARAM:2741,CANNOT_ADD_SELF_TO_BLACKLIST:2742,ADD_FRIEND_INVALID_PARAM:2760,NETWORK_ERROR:2800,NETWORK_TIMEOUT:2801,NETWORK_BASE_OPTIONS_NO_URL:2802,NETWORK_UNDEFINED_SERVER_NAME:2803,NETWORK_PACKAGE_UNDEFINED:2804,NO_NETWORK:2805,CONVERTOR_IRREGULAR_PARAMS:2900,NOTICE_RUNLOOP_UNEXPECTED_CONDITION:2901,NOTICE_RUNLOOP_OFFSET_LOST:2902,UNCAUGHT_ERROR:2903,GET_LONGPOLL_ID_FAILED:2904,INVALID_OPERATION:2905,OVER_FREQUENCY_LIMIT:2996,CANNOT_FIND_PROTOCOL:2997,CANNOT_FIND_MODULE:2998,SDK_IS_NOT_READY:2999,LOGGING_IN:3e3,LOGIN_FAILED:3001,KICKED_OUT_MULT_DEVICE:3002,KICKED_OUT_MULT_ACCOUNT:3003,KICKED_OUT_USERSIG_EXPIRED:3004,LOGGED_OUT:3005,KICKED_OUT_REST_API:3006,ILLEGAL_TOPIC_ID:3021,LONG_POLL_KICK_OUT:91101,MESSAGE_A2KEY_EXPIRED:20002,ACCOUNT_A2KEY_EXPIRED:70001,LONG_POLL_API_PARAM_ERROR:90001,HELLO_ANSWER_KICKED_OUT:1002,OPEN_SERVICE_OVERLOAD_ERROR:60022},aa={NO_SDKAPPID:"无 SDKAppID",NO_ACCOUNT_TYPE:"无 accountType",NO_IDENTIFIER:"无 userID",NO_USERSIG:"无 userSig",NO_TINYID:"无 tinyID",NO_A2KEY:"无 a2key",USER_NOT_LOGGED_IN:"用户未登录",REPEAT_LOGIN:"重复登录",COS_UNDETECTED:"未检测到 COS 上传插件",COS_GET_SIG_FAIL:"获取 COS 预签名 URL 失败",MESSAGE_SEND_FAIL:"消息发送失败",MESSAGE_LIST_CONSTRUCTOR_NEED_OPTIONS:"MessageController.constructor() 需要参数 options",MESSAGE_SEND_NEED_MESSAGE_INSTANCE:"需要 Message 的实例",MESSAGE_SEND_INVALID_CONVERSATION_TYPE:'Message.conversationType 只能为 "C2C" 或 "GROUP"',MESSAGE_FILE_IS_EMPTY:"无法发送空文件",MESSAGE_ONPROGRESS_FUNCTION_ERROR:"回调函数运行时遇到错误,请检查接入侧代码",MESSAGE_REVOKE_FAIL:"消息撤回失败",MESSAGE_DELETE_FAIL:"消息删除失败",MESSAGE_UNREAD_ALL_FAIL:"设置所有未读消息为已读处理失败",MESSAGE_CONTROL_INFO_FAIL:"社群不支持消息发送控制选项",READ_RECEIPT_MESSAGE_LIST_EMPTY:"消息列表中没有需要发送已读回执的消息",MESSAGE_SEND_GROUP_WITH_TOPIC_FAIL:"不能在支持话题的群组中发消息,请检查群组 isSupportTopic 属性",CANNOT_DELETE_GROUP_SYSTEM_NOTICE:"不支持删除群系统通知",MESSAGE_IMAGE_SELECT_FILE_FIRST:"请先选择一个图片",MESSAGE_IMAGE_TYPES_LIMIT:"只允许上传 jpg png jpeg gif bmp image webp 格式的图片",MESSAGE_IMAGE_SIZE_LIMIT:"图片大小超过20M,无法发送",MESSAGE_AUDIO_UPLOAD_FAIL:"语音上传失败",MESSAGE_AUDIO_SIZE_LIMIT:"语音大小大于20M,无法发送",MESSAGE_VIDEO_UPLOAD_FAIL:"视频上传失败",MESSAGE_VIDEO_SIZE_LIMIT:"视频大小超过100M,无法发送",MESSAGE_VIDEO_TYPES_LIMIT:"只允许上传 mp4 格式的视频",MESSAGE_FILE_UPLOAD_FAIL:"文件上传失败",MESSAGE_FILE_SELECT_FILE_FIRST:"请先选择一个文件",MESSAGE_FILE_SIZE_LIMIT:"文件大小超过100M,无法发送 ",MESSAGE_FILE_URL_IS_EMPTY:"缺少必要的参数文件 URL",MESSAGE_MERGER_TYPE_INVALID:"非合并消息",MESSAGE_MERGER_KEY_INVALID:"合并消息的 messageKey 无效",MESSAGE_MERGER_DOWNLOAD_FAIL:"下载合并消息失败",MESSAGE_FORWARD_TYPE_INVALID:"选择的消息类型(如群提示消息)不可以转发",MESSAGE_AT_TYPE_INVALID:"社群/话题不支持 @ 所有人",MESSAGE_MODIFY_CONFLICT:"修改消息时发生冲突",MESSAGE_MODIFY_DISABLED_IN_AVCHATROOM:"直播群不支持修改消息",CONVERSATION_NOT_FOUND:"没有找到相应的会话,请检查传入参数",USER_OR_GROUP_NOT_FOUND:"没有找到相应的用户或群组,请检查传入参数",CONVERSATION_UN_RECORDED_TYPE:"未记录的会话类型",ILLEGAL_GROUP_TYPE:"非法的群类型,请检查传入参数",CANNOT_JOIN_WORK:"不能加入 Work 类型的群组",ILLEGAL_GROUP_ID:"群组 ID 非法,非 Community 类型群组不能以 @TGS#_ 为前缀,Community 类型群组必须以 @TGS#_ 为前缀且不能包含 @TOPIC#_ 字符串",CANNOT_CHANGE_OWNER_IN_AVCHATROOM:"AVChatRoom 类型的群组不能转让群主",CANNOT_CHANGE_OWNER_TO_SELF:"不能把群主转让给自己",CANNOT_DISMISS_WORK:"不能解散 Work 类型的群组",MEMBER_NOT_IN_GROUP:"用户不在该群组内",JOIN_GROUP_FAIL:"加群失败,请检查传入参数或重试",CANNOT_ADD_MEMBER_IN_AVCHATROOM:"AVChatRoom 类型的群不支持邀请群成员",CANNOT_JOIN_NON_AVCHATROOM_WITHOUT_LOGIN:"非 AVChatRoom 类型的群组不允许匿名加群,请先登录后再加群",CANNOT_KICK_MEMBER_IN_AVCHATROOM:"不能在 AVChatRoom 类型的群组踢人",NOT_OWNER:"你不是群主,只有群主才有权限操作",CANNOT_SET_MEMBER_ROLE_IN_WORK_AND_AVCHATROOM:"不能在 Work / AVChatRoom 类型的群中设置群成员身份",INVALID_MEMBER_ROLE:"不合法的群成员身份,请检查传入参数",CANNOT_SET_SELF_MEMBER_ROLE:"不能设置自己的群成员身份,请检查传入参数",CANNOT_MUTE_SELF:"不能将自己禁言,请检查传入参数",NOT_MY_FRIEND:"非好友关系",ALREADY_MY_FRIEND:"已经是好友关系",FRIEND_GROUP_EXISTED:"好友分组已存在",FRIEND_GROUP_NOT_EXIST:"好友分组不存在",FRIEND_APPLICATION_NOT_EXIST:"好友申请不存在",UPDATE_PROFILE_INVALID_PARAM:"传入 updateMyProfile 接口的参数无效",UPDATE_PROFILE_NO_KEY:"updateMyProfile 无标配资料字段或自定义资料字段",ADD_BLACKLIST_INVALID_PARAM:"传入 addToBlacklist 接口的参数无效",DEL_BLACKLIST_INVALID_PARAM:"传入 removeFromBlacklist 接口的参数无效",CANNOT_ADD_SELF_TO_BLACKLIST:"不能拉黑自己",ADD_FRIEND_INVALID_PARAM:"传入 addFriend 接口的参数无效",NETWORK_ERROR:"网络错误",NETWORK_TIMEOUT:"请求超时",NETWORK_BASE_OPTIONS_NO_URL:"网络层初始化错误,缺少 URL 参数",NETWORK_UNDEFINED_SERVER_NAME:"打包错误,未定义的 serverName",NETWORK_PACKAGE_UNDEFINED:"未定义的 packageConfig",NO_NETWORK:"未连接到网络",CONVERTOR_IRREGULAR_PARAMS:"不规范的参数名称",NOTICE_RUNLOOP_UNEXPECTED_CONDITION:"意料外的通知条件",NOTICE_RUNLOOP_OFFSET_LOST:"_syncOffset 丢失",GET_LONGPOLL_ID_FAILED:"获取 longpolling id 失败",UNCAUGHT_ERROR:"未经明确定义的错误",INVALID_OPERATION:"无效操作,如调用了未定义或者未实现的方法等",CANNOT_FIND_PROTOCOL:"无法找到协议",CANNOT_FIND_MODULE:"无法找到模块,请参考:https://web.sdk.qcloud.com/im/doc/zh-cn/tutorial-03-sns.html",SDK_IS_NOT_READY:"接口需要 SDK 处于 ready 状态后才能调用",LOGGING_IN:"用户正在登录中",LOGIN_FAILED:"用户登录失败",KICKED_OUT_MULT_DEVICE:"用户多终端登录被踢出",KICKED_OUT_MULT_ACCOUNT:"用户多实例登录被踢出",KICKED_OUT_USERSIG_EXPIRED:"用户 userSig 过期被踢出",LOGGED_OUT:"用户已登出",KICKED_OUT_REST_API:"用户被 REST API - kick 接口: https://cloud.tencent.com/document/product/269/3853 踢出",OVER_FREQUENCY_LIMIT:"超出 SDK 频率控制",LONG_POLL_KICK_OUT:"检测到多个 web 实例登录,消息通道下线",OPEN_SERVICE_OVERLOAD_ERROR:"后台服务正忙,请稍后再试",MESSAGE_A2KEY_EXPIRED:"消息错误码:UserSig 或 A2 失效。",ACCOUNT_A2KEY_EXPIRED:"帐号错误码:UserSig 已过期,请重新生成。建议 UserSig 有效期设置不小于24小时。",LONG_POLL_API_PARAM_ERROR:"longPoll API parameters error",ILLEGAL_TOPIC_ID:"topicID 非法"},sa="networkRTT",ra="messageE2EDelay",ia="sendMessageC2C",ca="sendMessageGroup",ua="sendMessageGroupAV",la="sendMessageRichMedia",da="cosUpload",pa="messageReceivedGroup",ga="messageReceivedGroupAVPush",_a="messageReceivedGroupAVPull",ha=(r(Bt={},sa,2),r(Bt,ra,3),r(Bt,ia,4),r(Bt,ca,5),r(Bt,ua,6),r(Bt,la,7),r(Bt,pa,8),r(Bt,ga,9),r(Bt,_a,10),r(Bt,da,11),Bt),fa={info:4,warning:5,error:6},ma={wifi:1,"2g":2,"3g":3,"4g":4,"5g":5,unknown:6,none:7,online:8},Ma={login:4},va=function(){function e(t){n(this,e),this.eventType=Ma[t]||0,this.timestamp=0,this.networkType=8,this.code=0,this.message="",this.moreMessage="",this.extension=t,this.costTime=0,this.duplicate=!1,this.level=4,this.uiPlatform=void 0,this._sentFlag=!1,this._startts=Re()}return s(e,[{key:"updateTimeStamp",value:function(){this.timestamp=Re()}},{key:"start",value:function(e){return this._startts=e,this}},{key:"end",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(!this._sentFlag){var o=Re();0===this.costTime&&(this.costTime=o-this._startts),this.setMoreMessage("startts:".concat(this._startts," endts:").concat(o)),t?(this._sentFlag=!0,this._eventStatModule&&this._eventStatModule.pushIn(this)):setTimeout((function(){e._sentFlag=!0,e._eventStatModule&&e._eventStatModule.pushIn(e)}),0)}}},{key:"setError",value:function(e,t,o){return e instanceof Error?(this._sentFlag||(this.setNetworkType(o),t?(e.code&&this.setCode(e.code),e.message&&this.setMoreMessage(e.message)):(this.setCode(na.NO_NETWORK),this.setMoreMessage(aa.NO_NETWORK)),this.setLevel("error")),this):(we.warn("SSOLogData.setError value not instanceof Error, please check!"),this)}},{key:"setCode",value:function(e){return Ze(e)||this._sentFlag||("ECONNABORTED"===e&&(this.code=103),$e(e)?this.code=e:we.warn("SSOLogData.setCode value not a number, please check!",e,o(e))),this}},{key:"setMessage",value:function(e){return Ze(e)||this._sentFlag||($e(e)&&(this.message=e.toString()),ze(e)&&(this.message=e)),this}},{key:"setCostTime",value:function(e){return this.costTime=e,this}},{key:"setLevel",value:function(e){return Ze(e)||this._sentFlag||(this.level=fa[e]),this}},{key:"setMoreMessage",value:function(e){return Vt(this.moreMessage)?this.moreMessage="".concat(e):this.moreMessage+=" ".concat(e),this}},{key:"setNetworkType",value:function(e){if(Ze(e))we.warn("SSOLogData.setNetworkType value is undefined, please check!");else{var t=ma[e.toLowerCase()];Ze(t)||(this.networkType=t)}return this}},{key:"getStartTs",value:function(){return this._startts}},{key:"setUIPlatform",value:function(e){this.uiPlatform=e}}],[{key:"bindEventStatModule",value:function(t){e.prototype._eventStatModule=t}}]),e}(),ya={SDK_CONSTRUCT:"sdkConstruct",SDK_READY:"sdkReady",LOGIN:"login",LOGOUT:"logout",KICKED_OUT:"kickedOut",REGISTER_PLUGIN:"registerPlugin",KICK_OTHER:"kickOther",WS_CONNECT:"wsConnect",WS_ON_OPEN:"wsOnOpen",WS_ON_CLOSE:"wsOnClose",WS_ON_ERROR:"wsOnError",NETWORK_CHANGE:"networkChange",GET_COS_AUTH_KEY:"getCosAuthKey",GET_COS_PRE_SIG_URL:"getCosPreSigUrl",GET_SNAPSHOT_INFO:"getSnapshotInfo",UPLOAD:"upload",SEND_MESSAGE:"sendMessage",SEND_MESSAGE_WITH_RECEIPT:"sendMessageWithReceipt",SEND_COMBO_MESSAGE:"sendComboMessage",GET_C2C_ROAMING_MESSAGES:"getC2CRoamingMessages",GET_GROUP_ROAMING_MESSAGES:"getGroupRoamingMessages",GET_C2C_ROAMING_MESSAGES_HOPPING:"getC2CRoamingMessagesHopping",GET_GROUP_ROAMING_MESSAGES_HOPPING:"getGroupRoamingMessagesHopping",GET_READ_RECEIPT:"getReadReceipt",GET_READ_RECEIPT_DETAIL:"getReadReceiptDetail",SEND_READ_RECEIPT:"sendReadReceipt",SEND_C2C_READ_RECEIPT:"sendC2CReadReceipt",REVOKE_MESSAGE:"revokeMessage",DELETE_MESSAGE:"deleteMessage",EDIT_MESSAGE:"modifyMessage",SET_C2C_MESSAGE_READ:"setC2CMessageRead",SET_GROUP_MESSAGE_READ:"setGroupMessageRead",EMPTY_MESSAGE_BODY:"emptyMessageBody",GET_PEER_READ_TIME:"getPeerReadTime",UPLOAD_MERGER_MESSAGE:"uploadMergerMessage",DOWNLOAD_MERGER_MESSAGE:"downloadMergerMessage",JSON_PARSE_ERROR:"jsonParseError",MESSAGE_E2E_DELAY_EXCEPTION:"messageE2EDelayException",GET_CONVERSATION_LIST:"getConversationList",GET_CONVERSATION_PROFILE:"getConversationProfile",DELETE_CONVERSATION:"deleteConversation",PIN_CONVERSATION:"pinConversation",GET_CONVERSATION_LIST_IN_STORAGE:"getConversationListInStorage",SYNC_CONVERSATION_LIST:"syncConversationList",SET_ALL_MESSAGE_READ:"setAllMessageRead",CREATE_GROUP:"createGroup",APPLY_JOIN_GROUP:"applyJoinGroup",QUIT_GROUP:"quitGroup",SEARCH_GROUP_BY_ID:"searchGroupByID",CHANGE_GROUP_OWNER:"changeGroupOwner",HANDLE_GROUP_APPLICATION:"handleGroupApplication",HANDLE_GROUP_INVITATION:"handleGroupInvitation",SET_MESSAGE_REMIND_TYPE:"setMessageRemindType",DISMISS_GROUP:"dismissGroup",UPDATE_GROUP_PROFILE:"updateGroupProfile",GET_GROUP_LIST:"getGroupList",GET_GROUP_PROFILE:"getGroupProfile",GET_GROUP_LIST_IN_STORAGE:"getGroupListInStorage",GET_GROUP_LAST_SEQUENCE:"getGroupLastSequence",GET_GROUP_MISSING_MESSAGE:"getGroupMissingMessage",PAGING_GET_GROUP_LIST:"pagingGetGroupList",PAGING_GET_GROUP_LIST_WITH_TOPIC:"pagingGetGroupListWithTopic",GET_GROUP_SIMPLIFIED_INFO:"getGroupSimplifiedInfo",JOIN_WITHOUT_AUTH:"joinWithoutAuth",INIT_GROUP_ATTRIBUTES:"initGroupAttributes",SET_GROUP_ATTRIBUTES:"setGroupAttributes",DELETE_GROUP_ATTRIBUTES:"deleteGroupAttributes",GET_GROUP_ATTRIBUTES:"getGroupAttributes",GET_GROUP_MEMBER_LIST:"getGroupMemberList",GET_GROUP_MEMBER_PROFILE:"getGroupMemberProfile",ADD_GROUP_MEMBER:"addGroupMember",DELETE_GROUP_MEMBER:"deleteGroupMember",SET_GROUP_MEMBER_MUTE_TIME:"setGroupMemberMuteTime",SET_GROUP_MEMBER_NAME_CARD:"setGroupMemberNameCard",SET_GROUP_MEMBER_ROLE:"setGroupMemberRole",SET_GROUP_MEMBER_CUSTOM_FIELD:"setGroupMemberCustomField",GET_GROUP_ONLINE_MEMBER_COUNT:"getGroupOnlineMemberCount",SYNC_MESSAGE:"syncMessage",LONG_POLLING_AV_ERROR:"longPollingAVError",MESSAGE_LOSS:"messageLoss",MESSAGE_STACKED:"messageStacked",GET_USER_PROFILE:"getUserProfile",UPDATE_MY_PROFILE:"updateMyProfile",GET_BLACKLIST:"getBlacklist",ADD_TO_BLACKLIST:"addToBlacklist",REMOVE_FROM_BLACKLIST:"removeFromBlacklist",ADD_FRIEND:"addFriend",CHECK_FRIEND:"checkFriend",DELETE_FRIEND:"removeFromFriendList",GET_FRIEND_PROFILE:"getFriendProfile",GET_FRIEND_LIST:"getFriendList",UPDATE_FRIEND:"updateFriend",GET_FRIEND_APPLICATION_LIST:"getFriendApplicationList",DELETE_FRIEND_APPLICATION:"deleteFriendApplication",ACCEPT_FRIEND_APPLICATION:"acceptFriendApplication",REFUSE_FRIEND_APPLICATION:"refuseFriendApplication",SET_FRIEND_APPLICATION_READ:"setFriendApplicationRead",CREATE_FRIEND_GROUP:"createFriendGroup",DELETE_FRIEND_GROUP:"deleteFriendGroup",RENAME_FRIEND_GROUP:"renameFriendGroup",ADD_TO_FRIEND_GROUP:"addToFriendGroup",REMOVE_FROM_FRIEND_GROUP:"removeFromFriendGroup",GET_FRIEND_GROUP_LIST:"getFriendGroupList",CREATE_TOPIC:"createTopic",DELETE_TOPIC:"deleteTopic",UPDATE_TOPIC_PROFILE:"updateTopicProfile",GET_TOPIC_LIST:"getTopicList",RELAY_GET_TOPIC_LIST:"relayGetTopicList",GET_TOPIC_LAST_SEQUENCE:"getTopicLastSequence",MP_HIDE_TO_SHOW:"mpHideToShow",CALLBACK_FUNCTION_ERROR:"callbackFunctionError",FETCH_CLOUD_CONTROL_CONFIG:"fetchCloudControlConfig",PUSHED_CLOUD_CONTROL_CONFIG:"pushedCloudControlConfig",FETCH_COMMERCIAL_CONFIG:"fetchCommercialConfig",PUSHED_COMMERCIAL_CONFIG:"pushedCommercialConfig",ERROR:"error",LAST_MESSAGE_NOT_EXIST:"lastMessageNotExist"},Ia=function(){function e(t){n(this,e),this.type=D.MSG_TEXT,this.content={text:t.text||""}}return s(e,[{key:"setText",value:function(e){this.content.text=e}},{key:"sendable",value:function(){return 0!==this.content.text.length}}]),e}(),Ea=function(){function e(t){n(this,e),this._imageMemoryURL="",te?this.createImageDataASURLInWXMiniApp(t.file):this.createImageDataASURLInWeb(t.file),this._initImageInfoModel(),this.type=D.MSG_IMAGE,this._percent=0,this.content={imageFormat:t.imageFormat||be.UNKNOWN,uuid:t.uuid,imageInfoArray:[]},this.initImageInfoArray(t.imageInfoArray),this._defaultImage="http://imgcache.qq.com/open/qcloud/video/act/webim-images/default.jpg",this._autoFixUrl()}return s(e,[{key:"_initImageInfoModel",value:function(){var e=this;this._ImageInfoModel=function(t){this.instanceID=dt(9999999),this.sizeType=t.type||0,this.type=0,this.size=t.size||0,this.width=t.width||0,this.height=t.height||0,this.imageUrl=t.url||"",this.url=t.url||e._imageMemoryURL||e._defaultImage},this._ImageInfoModel.prototype={setSizeType:function(e){this.sizeType=e},setType:function(e){this.type=e},setImageUrl:function(e){e&&(this.imageUrl=e)},getImageUrl:function(){return this.imageUrl}}}},{key:"initImageInfoArray",value:function(e){for(var t=0,o=null,n=null;t<=2;)n=Ze(e)||Ze(e[t])?{type:0,size:0,width:0,height:0,url:""}:e[t],(o=new this._ImageInfoModel(n)).setSizeType(t+1),o.setType(t),this.addImageInfo(o),t++;this.updateAccessSideImageInfoArray()}},{key:"updateImageInfoArray",value:function(e){for(var t,o=this.content.imageInfoArray.length,n=0;n1&&(this._percent=1)}},{key:"updateImageFormat",value:function(e){this.content.imageFormat=be[e.toUpperCase()]||be.UNKNOWN}},{key:"createImageDataASURLInWeb",value:function(e){void 0!==e&&e.files.length>0&&(this._imageMemoryURL=window.URL.createObjectURL(e.files[0]))}},{key:"createImageDataASURLInWXMiniApp",value:function(e){e&&e.url&&(this._imageMemoryURL=e.url)}},{key:"replaceImageInfo",value:function(e,t){this.content.imageInfoArray[t]instanceof this._ImageInfoModel||(this.content.imageInfoArray[t]=e)}},{key:"addImageInfo",value:function(e){this.content.imageInfoArray.length>=3||this.content.imageInfoArray.push(e)}},{key:"updateAccessSideImageInfoArray",value:function(){var e=this.content.imageInfoArray,t=e[0],o=t.width,n=void 0===o?0:o,a=t.height,s=void 0===a?0:a;0!==n&&0!==s&&(kt(e),Object.assign(e[2],Lt({originWidth:n,originHeight:s,min:720})))}},{key:"sendable",value:function(){return 0!==this.content.imageInfoArray.length&&(""!==this.content.imageInfoArray[0].imageUrl&&0!==this.content.imageInfoArray[0].size)}}]),e}(),Ta=function(){function e(t){n(this,e),this.type=D.MSG_FACE,this.content=t||null}return s(e,[{key:"sendable",value:function(){return null!==this.content}}]),e}(),Ca=function(){function e(t){n(this,e),this.type=D.MSG_AUDIO,this._percent=0,this.content={downloadFlag:2,second:t.second,size:t.size,url:t.url,remoteAudioUrl:t.url||"",uuid:t.uuid}}return s(e,[{key:"updatePercent",value:function(e){this._percent=e,this._percent>1&&(this._percent=1)}},{key:"updateAudioUrl",value:function(e){this.content.remoteAudioUrl=e}},{key:"sendable",value:function(){return""!==this.content.remoteAudioUrl}}]),e}(),Sa={from:!0,groupID:!0,groupName:!0,to:!0},Da=function(){function e(t){n(this,e),this.type=D.MSG_GRP_TIP,this.content={},this._initContent(t)}return s(e,[{key:"_initContent",value:function(e){var t=this;Object.keys(e).forEach((function(o){switch(o){case"remarkInfo":break;case"groupProfile":t.content.groupProfile={},t._initGroupProfile(e[o]);break;case"operatorInfo":break;case"memberInfoList":case"msgMemberInfo":t._updateMemberList(e[o]);break;case"onlineMemberInfo":break;case"memberNum":t.content[o]=e[o],t.content.memberCount=e[o];break;case"newGroupProfile":t.content.newGroupProfile={},t._initNewGroupProfile(e[o]);break;default:t.content[o]=e[o]}})),this.content.userIDList||(this.content.userIDList=[this.content.operatorID])}},{key:"_initGroupProfile",value:function(e){for(var t=Object.keys(e),o=0;o1&&(this._percent=1)}},{key:"updateFileUrl",value:function(e){this.content.fileUrl=e}},{key:"sendable",value:function(){return""!==this.content.fileUrl&&(""!==this.content.fileName&&0!==this.content.fileSize)}}]),e}(),Ra=function(){function e(t){n(this,e),this.type=D.MSG_CUSTOM,this.content={data:t.data||"",description:t.description||"",extension:t.extension||""}}return s(e,[{key:"setData",value:function(e){return this.content.data=e,this}},{key:"setDescription",value:function(e){return this.content.description=e,this}},{key:"setExtension",value:function(e){return this.content.extension=e,this}},{key:"sendable",value:function(){return 0!==this.content.data.length||0!==this.content.description.length||0!==this.content.extension.length}}]),e}(),La=function(){function e(t){n(this,e),this.type=D.MSG_VIDEO,this._percent=0,this.content={remoteVideoUrl:t.remoteVideoUrl||t.videoUrl||"",videoFormat:t.videoFormat,videoSecond:parseInt(t.videoSecond,10),videoSize:t.videoSize,videoUrl:t.videoUrl,videoDownloadFlag:2,videoUUID:t.videoUUID,thumbUUID:t.thumbUUID,thumbFormat:t.thumbFormat,thumbWidth:t.thumbWidth,snapshotWidth:t.thumbWidth,thumbHeight:t.thumbHeight,snapshotHeight:t.thumbHeight,thumbSize:t.thumbSize,snapshotSize:t.thumbSize,thumbDownloadFlag:2,thumbUrl:t.thumbUrl,snapshotUrl:t.thumbUrl}}return s(e,[{key:"updatePercent",value:function(e){this._percent=e,this._percent>1&&(this._percent=1)}},{key:"updateVideoUrl",value:function(e){e&&(this.content.remoteVideoUrl=e)}},{key:"updateSnapshotInfo",value:function(e){var t=e.snapshotUrl,o=e.snapshotWidth,n=e.snapshotHeight;Vt(t)||(this.content.thumbUrl=this.content.snapshotUrl=t),Vt(o)||(this.content.thumbWidth=this.content.snapshotWidth=Number(o)),Vt(n)||(this.content.thumbHeight=this.content.snapshotHeight=Number(n))}},{key:"sendable",value:function(){return""!==this.content.remoteVideoUrl}}]),e}(),ka=function(){function e(t){n(this,e),this.type=D.MSG_LOCATION;var o=t.description,a=t.longitude,s=t.latitude;this.content={description:o,longitude:a,latitude:s}}return s(e,[{key:"sendable",value:function(){return!0}}]),e}(),Ga=function(){function e(t){if(n(this,e),this.from=t.from,this.messageSender=t.from,this.time=t.time,this.messageSequence=t.sequence,this.clientSequence=t.clientSequence||t.sequence,this.messageRandom=t.random,this.cloudCustomData=t.cloudCustomData||"",t.ID)this.nick=t.nick||"",this.avatar=t.avatar||"",this.messageBody=[{type:t.type,payload:t.payload}],t.conversationType.startsWith(D.CONV_C2C)?this.receiverUserID=t.to:t.conversationType.startsWith(D.CONV_GROUP)&&(this.receiverGroupID=t.to),this.messageReceiver=t.to;else{this.nick=t.nick||"",this.avatar=t.avatar||"",this.messageBody=[];var o=t.elements[0].type,a=t.elements[0].content;this._patchRichMediaPayload(o,a),o===D.MSG_MERGER?this.messageBody.push({type:o,payload:new Pa(a).content}):this.messageBody.push({type:o,payload:a}),t.groupID&&(this.receiverGroupID=t.groupID,this.messageReceiver=t.groupID),t.to&&(this.receiverUserID=t.to,this.messageReceiver=t.to)}}return s(e,[{key:"_patchRichMediaPayload",value:function(e,t){e===D.MSG_IMAGE?t.imageInfoArray.forEach((function(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===D.MSG_VIDEO?!t.remoteVideoUrl&&t.videoUrl&&(t.remoteVideoUrl=t.videoUrl):e===D.MSG_AUDIO?!t.remoteAudioUrl&&t.url&&(t.remoteAudioUrl=t.url):e===D.MSG_FILE&&!t.fileUrl&&t.url&&(t.fileUrl=t.url,t.url=void 0)}}]),e}(),Pa=function(){function e(t){if(n(this,e),this.type=D.MSG_MERGER,this.content={downloadKey:"",pbDownloadKey:"",messageList:[],title:"",abstractList:[],compatibleText:"",version:0,layersOverLimit:!1},t.downloadKey){var o=t.downloadKey,a=t.pbDownloadKey,s=t.title,r=t.abstractList,i=t.compatibleText,c=t.version;this.content.downloadKey=o,this.content.pbDownloadKey=a,this.content.title=s,this.content.abstractList=r,this.content.compatibleText=i,this.content.version=c||0}else if(Vt(t.messageList))1===t.layersOverLimit&&(this.content.layersOverLimit=!0);else{var u=t.messageList,l=t.title,d=t.abstractList,p=t.compatibleText,g=t.version,_=[];u.forEach((function(e){if(!Vt(e)){var t=new Ga(e);_.push(t)}})),this.content.messageList=_,this.content.title=l,this.content.abstractList=d,this.content.compatibleText=p,this.content.version=g||0}we.debug("MergerElement.content:",this.content)}return s(e,[{key:"sendable",value:function(){return!Vt(this.content.messageList)||!Vt(this.content.downloadKey)}}]),e}(),Ua={1:D.MSG_PRIORITY_HIGH,2:D.MSG_PRIORITY_NORMAL,3:D.MSG_PRIORITY_LOW,4:D.MSG_PRIORITY_LOWEST},wa=function(){function e(t){n(this,e),this.ID="",this.conversationID=t.conversationID||null,this.conversationType=t.conversationType||D.CONV_C2C,this.conversationSubType=t.conversationSubType,this.time=t.time||Math.ceil(Date.now()/1e3),this.sequence=t.sequence||0,this.clientSequence=t.clientSequence||t.sequence||0,this.random=t.random||0===t.random?t.random:dt(),this.priority=this._computePriority(t.priority),this.nick=t.nick||"",this.avatar=t.avatar||"",this.isPeerRead=1===t.isPeerRead||!1,this.nameCard="",this._elements=[],this.isPlaceMessage=t.isPlaceMessage||0,this.isRevoked=2===t.isPlaceMessage||8===t.msgFlagBits,this.from=t.from||null,this.to=t.to||null,this.flow="",this.isSystemMessage=t.isSystemMessage||!1,this.protocol=t.protocol||"JSON",this.isResend=!1,this.isRead=!1,this.status=t.status||xt.SUCCESS,this._onlineOnlyFlag=!1,this._groupAtInfoList=[],this._relayFlag=!1,this.atUserList=[],this.cloudCustomData=t.cloudCustomData||"",this.isDeleted=!1,this.isModified=!1,this._isExcludedFromUnreadCount=!(!t.messageControlInfo||1!==t.messageControlInfo.excludedFromUnreadCount),this._isExcludedFromLastMessage=!(!t.messageControlInfo||1!==t.messageControlInfo.excludedFromLastMessage),this.clientTime=t.clientTime||ke()||0,this.senderTinyID=t.senderTinyID||t.tinyID||"",this.readReceiptInfo=t.readReceiptInfo||{readCount:void 0,unreadCount:void 0},this.needReadReceipt=!0===t.needReadReceipt||1===t.needReadReceipt,this.version=t.messageVersion||0,this.reInitialize(t.currentUser),this.extractGroupInfo(t.groupProfile||null),this.handleGroupAtInfo(t)}return s(e,[{key:"elements",get:function(){return we.warn("!!!Message 实例的 elements 属性即将废弃,请尽快修改。使用 type 和 payload 属性处理单条消息,兼容组合消息使用 _elements 属性!!!"),this._elements}},{key:"getElements",value:function(){return this._elements}},{key:"extractGroupInfo",value:function(e){if(null!==e){ze(e.nick)&&(this.nick=e.nick),ze(e.avatar)&&(this.avatar=e.avatar);var t=e.messageFromAccountExtraInformation;Xe(t)&&ze(t.nameCard)&&(this.nameCard=t.nameCard)}}},{key:"handleGroupAtInfo",value:function(e){var t=this;e.payload&&e.payload.atUserList&&e.payload.atUserList.forEach((function(e){e!==D.MSG_AT_ALL?(t._groupAtInfoList.push({groupAtAllFlag:0,groupAtUserID:e}),t.atUserList.push(e)):(t._groupAtInfoList.push({groupAtAllFlag:1}),t.atUserList.push(D.MSG_AT_ALL))})),Qe(e.groupAtInfo)&&e.groupAtInfo.forEach((function(e){0===e.groupAtAllFlag?t.atUserList.push(e.groupAtUserID):1===e.groupAtAllFlag&&t.atUserList.push(D.MSG_AT_ALL)}))}},{key:"getGroupAtInfoList",value:function(){return this._groupAtInfoList}},{key:"_initProxy",value:function(){this._elements[0]&&(this.payload=this._elements[0].content,this.type=this._elements[0].type)}},{key:"reInitialize",value:function(e){e&&(this.status=this.from?xt.SUCCESS:xt.UNSEND,!this.from&&(this.from=e)),this._initFlow(e),this._initSequence(e),this._concatConversationID(e),this.generateMessageID()}},{key:"isSendable",value:function(){return 0!==this._elements.length&&("function"!=typeof this._elements[0].sendable?(we.warn("".concat(this._elements[0].type,' need "boolean : sendable()" method')),!1):this._elements[0].sendable())}},{key:"_initTo",value:function(e){this.conversationType===D.CONV_GROUP&&(this.to=e.groupID)}},{key:"_initSequence",value:function(e){0===this.clientSequence&&e&&(this.clientSequence=function(e){if(!e)return we.error("autoIncrementIndex(string: key) need key parameter"),!1;if(void 0===ht[e]){var t=new Date,o="3".concat(t.getHours()).slice(-2),n="0".concat(t.getMinutes()).slice(-2),a="0".concat(t.getSeconds()).slice(-2);ht[e]=parseInt([o,n,a,"0001"].join("")),o=null,n=null,a=null,we.log("autoIncrementIndex start index:".concat(ht[e]))}return ht[e]++}(e)),0===this.sequence&&this.conversationType===D.CONV_C2C&&(this.sequence=this.clientSequence)}},{key:"generateMessageID",value:function(){this.from===D.CONV_SYSTEM&&(this.senderTinyID="144115198244471703"),this.ID="".concat(this.senderTinyID,"-").concat(this.clientTime,"-").concat(this.random)}},{key:"_initFlow",value:function(e){""!==e&&(e===this.from?(this.flow="out",this.isRead=!0):this.flow="in")}},{key:"_concatConversationID",value:function(e){var t=this.to,o="",n=this.conversationType;n!==D.CONV_SYSTEM?(o=n===D.CONV_C2C?e===this.from?t:this.from:this.to,this.conversationID="".concat(n).concat(o)):this.conversationID=D.CONV_SYSTEM}},{key:"isElement",value:function(e){return e instanceof Ia||e instanceof Ea||e instanceof Ta||e instanceof Ca||e instanceof Oa||e instanceof La||e instanceof Da||e instanceof Aa||e instanceof Ra||e instanceof ka||e instanceof Pa}},{key:"setElement",value:function(e){var t=this;if(this.isElement(e))return this._elements=[e],void this._initProxy();var o=function(e){if(e.type&&e.content)switch(e.type){case D.MSG_TEXT:t.setTextElement(e.content);break;case D.MSG_IMAGE:t.setImageElement(e.content);break;case D.MSG_AUDIO:t.setAudioElement(e.content);break;case D.MSG_FILE:t.setFileElement(e.content);break;case D.MSG_VIDEO:t.setVideoElement(e.content);break;case D.MSG_CUSTOM:t.setCustomElement(e.content);break;case D.MSG_LOCATION:t.setLocationElement(e.content);break;case D.MSG_GRP_TIP:t.setGroupTipElement(e.content);break;case D.MSG_GRP_SYS_NOTICE:t.setGroupSystemNoticeElement(e.content);break;case D.MSG_FACE:t.setFaceElement(e.content);break;case D.MSG_MERGER:t.setMergerElement(e.content);break;default:we.warn(e.type,e.content,"no operation......")}};if(Qe(e))for(var n=0;n1&&void 0!==arguments[1]&&arguments[1];if(e instanceof Ba)return t&&null!==xa&&xa.emit(S.ERROR,e),Promise.reject(e);if(e instanceof Error){var o=new Ba({code:na.UNCAUGHT_ERROR,message:e.message});return t&&null!==xa&&xa.emit(S.ERROR,o),Promise.reject(o)}if(Ze(e)||Ze(e.code)||Ze(e.message))we.error("IMPromise.reject 必须指定code(错误码)和message(错误信息)!!!");else{if($e(e.code)&&ze(e.message)){var n=new Ba(e);return t&&null!==xa&&xa.emit(S.ERROR,n),Promise.reject(n)}we.error("IMPromise.reject code(错误码)必须为数字,message(错误信息)必须为字符串!!!")}},$a=function(e){i(a,e);var o=f(a);function a(e){var t;return n(this,a),(t=o.call(this,e))._className="C2CModule",t._messageFromUnreadDBMap=new Map,t}return s(a,[{key:"onNewC2CMessage",value:function(e){var t=e.dataList,o=e.isInstantMessage,n=e.C2CRemainingUnreadList,a=e.C2CPairUnreadList;we.debug("".concat(this._className,".onNewC2CMessage count:").concat(t.length," isInstantMessage:").concat(o));var s=this._newC2CMessageStoredAndSummary({dataList:t,C2CRemainingUnreadList:n,C2CPairUnreadList:a,isInstantMessage:o}),r=s.conversationOptionsList,i=s.messageList,c=s.isUnreadC2CMessage;(this.filterModifiedMessage(i),r.length>0)&&this.getModule(co).onNewMessage({conversationOptionsList:r,isInstantMessage:o,isUnreadC2CMessage:c});var u=this.filterUnmodifiedMessage(i);o&&u.length>0&&this.emitOuterEvent(S.MESSAGE_RECEIVED,u),i.length=0}},{key:"_newC2CMessageStoredAndSummary",value:function(e){for(var t=e.dataList,o=e.C2CRemainingUnreadList,n=e.C2CPairUnreadList,a=e.isInstantMessage,s=null,r=[],i=[],c={},u=this.getModule(_o),l=this.getModule(Co),d=!1,p=this.getModule(co),g=0,_=t.length;g<_;g++){var h=t[g];h.currentUser=this.getMyUserID(),h.conversationType=D.CONV_C2C,h.isSystemMessage=!!h.isSystemMessage,(Ze(h.nick)||Ze(h.avatar))&&(d=!0,we.debug("".concat(this._className,"._newC2CMessageStoredAndSummary nick or avatar missing!"))),s=new wa(h),h.elements=u.parseElements(h.elements,h.from),s.setElement(h.elements),s.setNickAndAvatar({nick:h.nick,avatar:h.avatar});var f=s.conversationID;if(a){if(1===this._messageFromUnreadDBMap.get(s.ID))continue;var m=!1;if(s.from!==this.getMyUserID()){var M=p.getLatestMessageSentByPeer(f);if(M){var v=M.nick,y=M.avatar;d?s.setNickAndAvatar({nick:v,avatar:y}):v===s.nick&&y===s.avatar||(m=!0)}}else{var I=p.getLatestMessageSentByMe(f);if(I){var E=I.nick,T=I.avatar;E===s.nick&&T===s.avatar||p.modifyMessageSentByMe({conversationID:f,latestNick:s.nick,latestAvatar:s.avatar})}}var C=1===t[g].isModified;if(p.isMessageSentByCurrentInstance(s)?s.isModified=C:C=!1,0===h.msgLifeTime)s._onlineOnlyFlag=!0,i.push(s);else{if(!p.pushIntoMessageList(i,s,C))continue;m&&(p.modifyMessageSentByPeer({conversationID:f,latestNick:s.nick,latestAvatar:s.avatar}),p.updateUserProfileSpecifiedKey({conversationID:f,nick:s.nick,avatar:s.avatar}))}a&&s.clientTime>0&&l.addMessageDelay(s.clientTime)}else this._messageFromUnreadDBMap.set(s.ID,1);if(0!==h.msgLifeTime){if(!1===s._onlineOnlyFlag){var S=p.getLastMessageTime(f);if($e(S)&&s.time0){O=!0;var o=r.find((function(t){return t.conversationID==="C2C".concat(n[e].from)}));o?o.unreadCount=n[e].unreadCount:r.push({conversationID:"C2C".concat(n[e].from),unreadCount:n[e].unreadCount,type:D.CONV_C2C})}},L=0,k=n.length;L0&&(n=e.cloudCustomData);var a=[];if(Xe(t)&&Xe(t.messageControlInfo)){var s=t.messageControlInfo,r=s.excludedFromUnreadCount,i=s.excludedFromLastMessage;!0===r&&a.push("NoUnread"),!0===i&&a.push("NoLastMsg")}return{protocolName:Go,tjgID:this.generateTjgID(e),requestData:{fromAccount:this.getMyUserID(),toAccount:e.to,msgBody:e.getElements(),cloudCustomData:n,msgSeq:e.sequence,msgRandom:e.random,msgLifeTime:this.isOnlineMessage(e,t)?0:void 0,nick:e.nick,avatar:e.avatar,offlinePushInfo:o?{pushFlag:!0===o.disablePush?1:0,title:o.title||"",desc:o.description||"",ext:o.extension||"",apnsInfo:{badgeMode:!0===o.ignoreIOSBadge?1:0},androidInfo:{OPPOChannelID:o.androidOPPOChannelID||""}}:void 0,messageControlInfo:a,clientTime:e.clientTime,needReadReceipt:!0===e.needReadReceipt?1:0}}}},{key:"isOnlineMessage",value:function(e,t){return!(!t||!0!==t.onlineUserOnly)}},{key:"revokeMessage",value:function(e){return this.request({protocolName:Vo,requestData:{msgInfo:{fromAccount:e.from,toAccount:e.to,msgSeq:e.sequence,msgRandom:e.random,msgTimeStamp:e.time}}})}},{key:"deleteMessage",value:function(e){var t=e.to,o=e.keyList;return we.log("".concat(this._className,".deleteMessage toAccount:").concat(t," count:").concat(o.length)),this.request({protocolName:Yo,requestData:{fromAccount:this.getMyUserID(),to:t,keyList:o}})}},{key:"modifyRemoteMessage",value:function(e){var t=e.from,o=e.to,n=e.version,a=void 0===n?0:n,s=e.sequence,r=e.random,i=e.time,c=e.payload,u=e.type,l=e.cloudCustomData;return this.request({protocolName:jo,requestData:{from:t,to:o,version:a,sequence:s,random:r,time:i,elements:[{type:u,content:c}],cloudCustomData:l}})}},{key:"setMessageRead",value:function(e){var t=this,o=e.conversationID,n=e.lastMessageTime,a="".concat(this._className,".setMessageRead");we.log("".concat(a," conversationID:").concat(o," lastMessageTime:").concat(n)),$e(n)||we.warn("".concat(a," 请勿修改 Conversation.lastMessage.lastTime,否则可能会导致已读上报结果不准确"));var s=new va(ya.SET_C2C_MESSAGE_READ);return s.setMessage("conversationID:".concat(o," lastMessageTime:").concat(n)),this.request({protocolName:Ko,requestData:{C2CMsgReaded:{cookie:"",C2CMsgReadedItem:[{toAccount:o.replace("C2C",""),lastMessageTime:n,receipt:1}]}}}).then((function(){s.setNetworkType(t.getNetworkType()).end(),we.log("".concat(a," ok"));var e=t.getModule(co);return e.updateIsReadAfterReadReport({conversationID:o,lastMessageTime:n}),e.updateUnreadCount(o),ba()})).catch((function(e){return t.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];s.setError(e,n,a).end()})),we.log("".concat(a," failed. error:"),e),ja(e)}))}},{key:"getRoamingMessage",value:function(e){var t=this,o="".concat(this._className,".getRoamingMessage"),n=e.peerAccount,a=e.conversationID,s=e.count,r=e.lastMessageTime,i=e.messageKey,c="peerAccount:".concat(n," count:").concat(s||15," lastMessageTime:").concat(r||0," messageKey:").concat(i);we.log("".concat(o," ").concat(c));var u=new va(ya.GET_C2C_ROAMING_MESSAGES);return this.request({protocolName:xo,requestData:{peerAccount:n,count:s||15,lastMessageTime:r||0,messageKey:i}}).then((function(e){var n=e.data,s=n.complete,r=n.messageList,i=n.messageKey,l=n.lastMessageTime;Ze(r)?we.log("".concat(o," ok. complete:").concat(s," but messageList is undefined!")):we.log("".concat(o," ok. complete:").concat(s," count:").concat(r.length)),u.setNetworkType(t.getNetworkType()).setMessage("".concat(c," complete:").concat(s," length:").concat(r.length)).end();var d=t.getModule(co);1===s&&d.setCompleted(a);var p=d.onRoamingMessage(r,a);d.modifyMessageList(a),d.updateIsRead(a),d.updateRoamingMessageKeyAndTime(a,i,l);var g=d.getPeerReadTime(a);if(we.log("".concat(o," update isPeerRead property. conversationID:").concat(a," peerReadTime:").concat(g)),g)d.updateMessageIsPeerReadProperty(a,g);else{var _=a.replace(D.CONV_C2C,"");t.getRemotePeerReadTime([_]).then((function(){d.updateMessageIsPeerReadProperty(a,d.getPeerReadTime(a))}))}var h="";if(p.length>0)h=p[0].ID;else{var f=d.getLocalOldestMessage(a);f&&(h=f.ID)}return we.log("".concat(o," nextReqID:").concat(h," stored message count:").concat(p.length)),{nextReqID:h,storedMessageList:p}})).catch((function(e){return t.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];u.setMessage(c).setError(e,n,a).end()})),we.warn("".concat(o," failed. error:"),e),ja(e)}))}},{key:"getRoamingMessagesHopping",value:function(e){var t=this,o="".concat(this._className,".getRoamingMessagesHopping"),n=e.peerAccount,a=e.time,s=void 0===a?0:a,r=e.count,i=e.direction,c="peerAccount:".concat(n," count:").concat(r," time:").concat(s," direction:").concat(i);we.log("".concat(o," ").concat(c));var u=new va(ya.GET_C2C_ROAMING_MESSAGES_HOPPING);return this.request({protocolName:xo,requestData:{peerAccount:n,count:r,lastMessageTime:s,direction:i}}).then((function(e){var a=e.data,s=a.complete,r=a.messageList,i=void 0===r?[]:r;we.log("".concat(o," ok. complete:").concat(s," count:").concat(i.length)),u.setNetworkType(t.getNetworkType()).setMessage("".concat(c," complete:").concat(s," length:").concat(i.length)).end();var l="".concat(D.CONV_C2C).concat(n),d=t.getModule(co).onRoamingMessage(i,l,!1);return t._modifyMessageList(l,d),d})).catch((function(e){return t.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];u.setMessage(c).setError(e,n,a).end()})),we.warn("".concat(o," failed. error:"),e),ja(e)}))}},{key:"_modifyMessageList",value:function(e,t){var o=this.getModule(co).getLocalConversation(e);if(o)for(var n=o.userProfile.nick,a=o.userProfile.avatar,s=this.getModule(oo).getNickAndAvatarByUserID(this.getMyUserID()),r=s.nick,i=s.avatar,c=t.length-1;c>=0;c--){var u=t[c];"in"===u.flow&&(u.nick!==n&&u.setNickAndAvatar({nick:n}),u.avatar!==a&&u.setNickAndAvatar({avatar:a})),"out"===u.flow&&(u.nick!==r&&u.setNickAndAvatar({nick:r}),u.avatar!==i&&u.setNickAndAvatar({avatar:i}))}}},{key:"getRemotePeerReadTime",value:function(e){var t=this,o="".concat(this._className,".getRemotePeerReadTime");if(Vt(e))return we.warn("".concat(o," userIDList is empty!")),Promise.resolve();var n=new va(ya.GET_PEER_READ_TIME);return we.log("".concat(o," userIDList:").concat(e)),this.request({protocolName:Wo,requestData:{userIDList:e}}).then((function(a){var s=a.data.peerReadTimeList;we.log("".concat(o," ok. peerReadTimeList:").concat(s));for(var r="",i=t.getModule(co),c=0;c0&&i.recordPeerReadTime("C2C".concat(e[c]),s[c]);n.setNetworkType(t.getNetworkType()).setMessage(r).end()})).catch((function(e){t.probeNetwork().then((function(t){var o=m(t,2),a=o[0],s=o[1];n.setError(e,a,s).end()})),we.warn("".concat(o," failed. error:"),e)}))}},{key:"sendReadReceipt",value:function(e){var t=this,o=e[0].conversationID.replace(D.CONV_C2C,""),n=new va(ya.SEND_C2C_READ_RECEIPT);n.setMessage("peerAccount:".concat(o));var a=this.getMyUserID(),s=e.filter((function(e){return e.from!==a&&!0===e.needReadReceipt})).map((function(e){return{fromAccount:e.from,toAccount:e.to,sequence:e.sequence,random:e.random,time:e.time,clientTime:e.clientTime}}));if(0===s.length)return ja({code:na.READ_RECEIPT_MESSAGE_LIST_EMPTY,message:aa.READ_RECEIPT_MESSAGE_LIST_EMPTY});var r="".concat(this._className,".sendReadReceipt");return we.log("".concat(r,". peerAccount:").concat(o," messageInfoList length:").concat(s.length)),this.request({protocolName:Mn,requestData:{peerAccount:o,messageInfoList:s}}).then((function(e){return n.end(),we.log("".concat(r," ok")),ba()})).catch((function(e){return t.probeNetwork().then((function(t){var o=m(t,2),a=o[0],s=o[1];n.setError(e,a,s).end()})),we.warn("".concat(r," failed. error:"),e),ja(e)}))}},{key:"getReadReceiptList",value:function(e){var t="".concat(this._className,".getReadReceiptList"),o=this.getMyUserID(),n=e.filter((function(e){return e.from===o&&!0===e.needReadReceipt}));return we.log("".concat(t," userID:").concat(o," messageList length:").concat(n.length)),Ya({messageList:n})}},{key:"reset",value:function(){we.log("".concat(this._className,".reset")),this._messageFromUnreadDBMap.clear()}}]),a}(Do),za=function(){function e(){n(this,e),this.list=new Map,this._className="MessageListHandler",this._latestMessageSentByPeerMap=new Map,this._latestMessageSentByMeMap=new Map,this._groupLocalLastMessageSequenceMap=new Map}return s(e,[{key:"getLocalOldestMessageByConversationID",value:function(e){if(!e)return null;if(!this.list.has(e))return null;var t=this.list.get(e).values();return t?t.next().value:null}},{key:"pushIn",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],o=e.conversationID,n=!0;this.list.has(o)||this.list.set(o,new Map);var a=this._getUniqueIDOfMessage(e),s=this.list.get(o).has(a);if(s){var r=this.list.get(o).get(a);if(!t||!0===r.isModified)return n=!1}return this.list.get(o).set(a,e),this._setLatestMessageSentByPeer(o,e),this._setLatestMessageSentByMe(o,e),this._setGroupLocalLastMessageSequence(o,e),n}},{key:"unshift",value:function(e,t){var o;if(Qe(e)){if(e.length>0){o=e[0].conversationID;var n=e.length;this._unshiftMultipleMessages(e,t),this._setGroupLocalLastMessageSequence(o,e[n-1])}}else o=e.conversationID,this._unshiftSingleMessage(e,t),this._setGroupLocalLastMessageSequence(o,e);if(o&&o.startsWith(D.CONV_C2C)){var a=Array.from(this.list.get(o).values()),s=a.length;if(0===s)return;for(var r=s-1;r>=0;r--)if("out"===a[r].flow){this._setLatestMessageSentByMe(o,a[r]);break}for(var i=s-1;i>=0;i--)if("in"===a[i].flow){this._setLatestMessageSentByPeer(o,a[i]);break}}}},{key:"_unshiftSingleMessage",value:function(e,t){var o=e.conversationID,n=this._getUniqueIDOfMessage(e);if(!this.list.has(o))return this.list.set(o,new Map),this.list.get(o).set(n,e),void t.push(e);var a=this.list.get(o),s=Array.from(a);a.has(n)||(s.unshift([n,e]),this.list.set(o,new Map(s)),t.push(e))}},{key:"_unshiftMultipleMessages",value:function(e,t){for(var o=e.length,n=[],a=e[0].conversationID,s=this.list.get(a),r=this.list.has(a)?Array.from(s):[],i=0;i=0;l--)"in"===s[l].flow&&((i=s[l]).nick!==o&&(i.setNickAndAvatar({nick:o}),u=!0),i.avatar!==n&&(i.setNickAndAvatar({avatar:n}),u=!0),u&&(c+=1));we.log("".concat(this._className,".modifyMessageSentByPeer conversationID:").concat(t," count:").concat(c))}}}},{key:"modifyMessageSentByMe",value:function(e){var t=e.conversationID,o=e.latestNick,n=e.latestAvatar,a=this.list.get(t);if(!Vt(a)){var s=Array.from(a.values()),r=s.length;if(0!==r){for(var i=null,c=0,u=!1,l=r-1;l>=0;l--)"out"===s[l].flow&&((i=s[l]).nick!==o&&(i.setNickAndAvatar({nick:o}),u=!0),i.avatar!==n&&(i.setNickAndAvatar({avatar:n}),u=!0),u&&(c+=1));we.log("".concat(this._className,".modifyMessageSentByMe conversationID:").concat(t," count:").concat(c))}}}},{key:"getLocalMessageListHopping",value:function(e){var t=e.conversationID,o=e.sequence,n=e.time,a=e.count,s=e.direction,r=this.getLocalMessageList(t),i=-1;if(t.startsWith(D.CONV_C2C)?i=r.findIndex((function(e){return e.time===n})):t.startsWith(D.CONV_GROUP)&&(i=r.findIndex((function(e){return e.sequence===o}))),-1===i)return[];var c=i+1,u=c>a?c-a:0;return 1===s&&(u=i,c=i+a),r.slice(u,c)}},{key:"getConversationIDList",value:function(e){return M(this.list.keys()).filter((function(t){return t.startsWith(e)}))}},{key:"traversal",value:function(){if(0!==this.list.size&&-1===we.getLevel()){console.group("conversationID-messageCount");var e,t=C(this.list);try{for(t.s();!(e=t.n()).done;){var o=m(e.value,2),n=o[0],a=o[1];console.log("".concat(n,"-").concat(a.size))}}catch(s){t.e(s)}finally{t.f()}console.groupEnd()}}},{key:"onMessageModified",value:function(e,t){if(!this.list.has(e))return{isUpdated:!1,message:null};var o=this._getUniqueIDOfMessage(t),n=this.list.get(e).has(o);if(we.debug("".concat(this._className,".onMessageModified conversationID:").concat(e," uniqueID:").concat(o," has:").concat(n)),n){var a=this.list.get(e).get(o),s=t.messageVersion,r=t.elements,i=t.cloudCustomData;return a.version1&&void 0!==arguments[1]&&arguments[1];if(e)return this._isReady?void(t?e.call(this):setTimeout(e,1)):(this._readyQueue=this._readyQueue||[],void this._readyQueue.push(e))},t.triggerReady=function(){var e=this;this._isReady=!0,setTimeout((function(){var t=e._readyQueue;e._readyQueue=[],t&&t.length>0&&t.forEach((function(e){e.call(this)}),e)}),1)},t.resetReady=function(){this._isReady=!1,this._readyQueue=[]},t.isReady=function(){return this._isReady}};var es=["jpg","jpeg","gif","png","bmp","image","webp"],ts=["mp4"],os=1,ns=2,as=3,ss=255,rs=function(){function e(t){var o=this;n(this,e),Vt(t)||(this.userID=t.userID||"",this.nick=t.nick||"",this.gender=t.gender||"",this.birthday=t.birthday||0,this.location=t.location||"",this.selfSignature=t.selfSignature||"",this.allowType=t.allowType||D.ALLOW_TYPE_ALLOW_ANY,this.language=t.language||0,this.avatar=t.avatar||"",this.messageSettings=t.messageSettings||0,this.adminForbidType=t.adminForbidType||D.FORBID_TYPE_NONE,this.level=t.level||0,this.role=t.role||0,this.lastUpdatedTime=0,this.profileCustomField=[],Vt(t.profileCustomField)||t.profileCustomField.forEach((function(e){o.profileCustomField.push({key:e.key,value:e.value})})))}return s(e,[{key:"validate",value:function(e){var t=!0,o="";if(Vt(e))return{valid:!1,tips:"empty options"};if(e.profileCustomField)for(var n=e.profileCustomField.length,a=null,s=0;s500&&(o="nick name limited: must less than or equal to ".concat(500," bytes, current size: ").concat(lt(e[r])," bytes"),t=!1);break;case"gender":_t(qe,e.gender)||(o="key:gender, invalid value:"+e.gender,t=!1);break;case"birthday":$e(e.birthday)||(o="birthday should be a number",t=!1);break;case"location":ze(e.location)||(o="location should be a string",t=!1);break;case"selfSignature":ze(e.selfSignature)||(o="selfSignature should be a string",t=!1);break;case"allowType":_t(Ke,e.allowType)||(o="key:allowType, invalid value:"+e.allowType,t=!1);break;case"language":$e(e.language)||(o="language should be a number",t=!1);break;case"avatar":ze(e.avatar)||(o="avatar should be a string",t=!1);break;case"messageSettings":0!==e.messageSettings&&1!==e.messageSettings&&(o="messageSettings should be 0 or 1",t=!1);break;case"adminForbidType":_t(Ve,e.adminForbidType)||(o="key:adminForbidType, invalid value:"+e.adminForbidType,t=!1);break;case"level":$e(e.level)||(o="level should be a number",t=!1);break;case"role":$e(e.role)||(o="role should be a number",t=!1);break;default:o="unknown key:"+r+" "+e[r],t=!1}}return{valid:t,tips:o}}}]),e}(),is=s((function e(t){n(this,e),this.value=t,this.next=null})),cs=function(){function e(t){n(this,e),this.MAX_LENGTH=t,this.pTail=null,this.pNodeToDel=null,this.map=new Map,we.debug("SinglyLinkedList init MAX_LENGTH:".concat(this.MAX_LENGTH))}return s(e,[{key:"set",value:function(e){var t=new is(e);if(this.map.size0&&o.members.forEach((function(e){e.userID===t.selfInfo.userID&&ct(t.selfInfo,e,["sequence"])}))}},{key:"updateSelfInfo",value:function(e){var o={nameCard:e.nameCard,joinTime:e.joinTime,role:e.role,messageRemindType:e.messageRemindType,readedSequence:e.readedSequence,excludedUnreadSequenceList:e.excludedUnreadSequenceList};ct(this.selfInfo,t({},o),[],["",null,void 0,0,NaN])}},{key:"setSelfNameCard",value:function(e){this.selfInfo.nameCard=e}}]),e}(),ds=function(e){return Ze(e)?{lastTime:0,lastSequence:0,fromAccount:0,messageForShow:"",payload:null,type:"",isRevoked:!1,cloudCustomData:"",onlineOnlyFlag:!1,nick:"",nameCard:"",version:0,isPeerRead:!1}:e instanceof wa?{lastTime:e.time||0,lastSequence:e.sequence||0,fromAccount:e.from||"",messageForShow:Ft(e.type,e.payload),payload:e.payload||null,type:e.type||null,isRevoked:e.isRevoked||!1,cloudCustomData:e.cloudCustomData||"",onlineOnlyFlag:e._onlineOnlyFlag||!1,nick:e.nick||"",nameCard:e.nameCard||"",version:e.version||0,isPeerRead:e.isPeerRead||!1}:t(t({},e),{},{messageForShow:Ft(e.type,e.payload)})},ps=function(){function e(t){n(this,e),this.conversationID=t.conversationID||"",this.unreadCount=t.unreadCount||0,this.type=t.type||"",this.lastMessage=ds(t.lastMessage),t.lastMsgTime&&(this.lastMessage.lastTime=t.lastMsgTime),this._isInfoCompleted=!1,this.peerReadTime=t.peerReadTime||0,this.groupAtInfoList=[],this.remark="",this.isPinned=t.isPinned||!1,this.messageRemindType="",this._initProfile(t)}return s(e,[{key:"toAccount",get:function(){return this.conversationID.startsWith(D.CONV_C2C)?this.conversationID.replace(D.CONV_C2C,""):this.conversationID.startsWith(D.CONV_GROUP)?this.conversationID.replace(D.CONV_GROUP,""):""}},{key:"subType",get:function(){return this.groupProfile?this.groupProfile.type:""}},{key:"_initProfile",value:function(e){var t=this;Object.keys(e).forEach((function(o){switch(o){case"userProfile":t.userProfile=e.userProfile;break;case"groupProfile":t.groupProfile=e.groupProfile}})),Ze(this.userProfile)&&this.type===D.CONV_C2C?this.userProfile=new rs({userID:e.conversationID.replace("C2C","")}):Ze(this.groupProfile)&&this.type===D.CONV_GROUP&&(this.groupProfile=new ls({groupID:e.conversationID.replace("GROUP","")}))}},{key:"updateUnreadCount",value:function(e){var t=e.nextUnreadCount,o=e.isFromGetConversations,n=e.isUnreadC2CMessage;Ze(t)||(It(this.subType)?this.unreadCount=0:o&&this.type===D.CONV_GROUP||o&&this.type===D.CONV_TOPIC||n&&this.type===D.CONV_C2C?this.unreadCount=t:this.unreadCount=this.unreadCount+t)}},{key:"updateLastMessage",value:function(e){this.lastMessage=ds(e)}},{key:"updateGroupAtInfoList",value:function(e){var t,o=(v(t=e.groupAtType)||y(t)||I(t)||T()).slice(0);-1!==o.indexOf(D.CONV_AT_ME)&&-1!==o.indexOf(D.CONV_AT_ALL)&&(o=[D.CONV_AT_ALL_AT_ME]);var n={from:e.from,groupID:e.groupID,topicID:e.topicID,messageSequence:e.sequence,atTypeArray:o,__random:e.__random,__sequence:e.__sequence};this.groupAtInfoList.push(n),we.debug("Conversation.updateGroupAtInfoList conversationID:".concat(this.conversationID),this.groupAtInfoList)}},{key:"clearGroupAtInfoList",value:function(){this.groupAtInfoList.length=0}},{key:"reduceUnreadCount",value:function(){this.unreadCount>=1&&(this.unreadCount-=1)}},{key:"isLastMessageRevoked",value:function(e){var t=e.sequence,o=e.time;return this.type===D.CONV_C2C&&t===this.lastMessage.lastSequence&&o===this.lastMessage.lastTime||this.type===D.CONV_GROUP&&t===this.lastMessage.lastSequence}},{key:"setLastMessageRevoked",value:function(e){this.lastMessage.isRevoked=e}}]),e}(),gs=function(){function e(t){n(this,e),this._conversationModule=t,this._className="MessageRemindHandler",this._updateSequence=0}return s(e,[{key:"getC2CMessageRemindType",value:function(){var e=this,t="".concat(this._className,".getC2CMessageRemindType");return this._conversationModule.request({protocolName:Bo,updateSequence:this._updateSequence}).then((function(o){we.log("".concat(t," ok"));var n=o.data,a=n.updateSequence,s=n.muteFlagList;e._updateSequence=a,e._patchC2CMessageRemindType(s)})).catch((function(e){we.error("".concat(t," failed. error:"),e)}))}},{key:"_patchC2CMessageRemindType",value:function(e){var t=this,o=0,n="";Qe(e)&&e.length>0&&e.forEach((function(e){var a=e.userID,s=e.muteFlag;0===s?n=D.MSG_REMIND_ACPT_AND_NOTE:1===s?n=D.MSG_REMIND_DISCARD:2===s&&(n=D.MSG_REMIND_ACPT_NOT_NOTE),!0===t._conversationModule.patchMessageRemindType({ID:a,isC2CConversation:!0,messageRemindType:n})&&(o+=1)})),we.log("".concat(this._className,"._patchC2CMessageRemindType count:").concat(o))}},{key:"set",value:function(e){return e.groupID?this._setGroupMessageRemindType(e):Qe(e.userIDList)?this._setC2CMessageRemindType(e):void 0}},{key:"_setGroupMessageRemindType",value:function(e){var t=this,o="".concat(this._className,"._setGroupMessageRemindType"),n=e.groupID,a=e.messageRemindType,s="groupID:".concat(n," messageRemindType:").concat(a),r=new va(ya.SET_MESSAGE_REMIND_TYPE);return r.setMessage(s),this._getModule(ro).modifyGroupMemberInfo({groupID:n,messageRemindType:a,userID:this._conversationModule.getMyUserID()}).then((function(){r.setNetworkType(t._conversationModule.getNetworkType()).end(),we.log("".concat(o," ok. ").concat(s));var e=t._getModule(ao).getLocalGroupProfile(n);if(e&&(e.selfInfo.messageRemindType=a),Tt(n)){var i=t._getModule(io),c=bt(n),u=i.getLocalTopic(c,n);return u&&(u.updateSelfInfo({messageRemindType:a}),t._conversationModule.emitOuterEvent(S.TOPIC_UPDATED,{groupID:n,topic:u})),ba({group:e})}return t._conversationModule.patchMessageRemindType({ID:n,isC2CConversation:!1,messageRemindType:a})&&t._emitConversationUpdate(),ba({group:e})})).catch((function(e){return t._conversationModule.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];r.setError(e,n,a).end()})),we.error("".concat(o," failed. error:"),e),ja(e)}))}},{key:"_setC2CMessageRemindType",value:function(e){var t=this,o="".concat(this._className,"._setC2CMessageRemindType"),n=e.userIDList,a=e.messageRemindType,s=n.slice(0,30),r=0;a===D.MSG_REMIND_DISCARD?r=1:a===D.MSG_REMIND_ACPT_NOT_NOTE&&(r=2);var i="userIDList:".concat(s," messageRemindType:").concat(a),c=new va(ya.SET_MESSAGE_REMIND_TYPE);return c.setMessage(i),this._conversationModule.request({protocolName:Ho,requestData:{userIDList:s,muteFlag:r}}).then((function(e){c.setNetworkType(t._conversationModule.getNetworkType()).end();var n=e.data,r=n.updateSequence,i=n.errorList;t._updateSequence=r;var u=[],l=[];Qe(i)&&i.forEach((function(e){u.push(e.userID),l.push({userID:e.userID,code:e.errorCode})}));var d=s.filter((function(e){return-1===u.indexOf(e)}));we.log("".concat(o," ok. successUserIDList:").concat(d," failureUserIDList:").concat(JSON.stringify(l)));var p=0;return d.forEach((function(e){t._conversationModule.patchMessageRemindType({ID:e,isC2CConversation:!0,messageRemindType:a})&&(p+=1)})),p>=1&&t._emitConversationUpdate(),s.length=u.length=0,Ya({successUserIDList:d.map((function(e){return{userID:e}})),failureUserIDList:l})})).catch((function(e){return t._conversationModule.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];c.setError(e,n,a).end()})),we.error("".concat(o," failed. error:"),e),ja(e)}))}},{key:"_getModule",value:function(e){return this._conversationModule.getModule(e)}},{key:"_emitConversationUpdate",value:function(){this._conversationModule.emitConversationUpdate(!0,!1)}},{key:"setUpdateSequence",value:function(e){this._updateSequence=e}},{key:"reset",value:function(){we.log("".concat(this._className,".reset")),this._updateSequence=0}}]),e}(),_s=function(e){i(a,e);var o=f(a);function a(e){var t;return n(this,a),(t=o.call(this,e))._className="ConversationModule",Za.mixin(_(t)),t._messageListHandler=new za,t._messageRemindHandler=new gs(_(t)),t.singlyLinkedList=new cs(100),t._pagingStatus=Wt.NOT_START,t._pagingTimeStamp=0,t._pagingStartIndex=0,t._pagingPinnedTimeStamp=0,t._pagingPinnedStartIndex=0,t._conversationMap=new Map,t._tmpGroupList=[],t._tmpGroupAtTipsList=[],t._peerReadTimeMap=new Map,t._completedMap=new Map,t._roamingMessageKeyAndTimeMap=new Map,t._roamingMessageSequenceMap=new Map,t._remoteGroupReadSequenceMap=new Map,t._initListeners(),t}return s(a,[{key:"_initListeners",value:function(){var e=this.getInnerEmitterInstance();e.on(Ja,this._initLocalConversationList,this),e.on(Qa,this._onProfileUpdated,this)}},{key:"onCheckTimer",value:function(e){e%60==0&&this._messageListHandler.traversal()}},{key:"_initLocalConversationList",value:function(){var e=this,t=new va(ya.GET_CONVERSATION_LIST_IN_STORAGE);we.log("".concat(this._className,"._initLocalConversationList."));var o="",n=this._getStorageConversationList();if(n){for(var a=n.length,s=0;s0&&(e.updateConversationGroupProfile(e._tmpGroupList),e._tmpGroupList.length=0)})),this.syncConversationList()}},{key:"onMessageSent",value:function(e){this._onSendOrReceiveMessage({conversationOptionsList:e.conversationOptionsList,isInstantMessage:!0})}},{key:"onNewMessage",value:function(e){this._onSendOrReceiveMessage(e)}},{key:"_onSendOrReceiveMessage",value:function(e){var t=this,o=e.conversationOptionsList,n=e.isInstantMessage,a=void 0===n||n,s=e.isUnreadC2CMessage,r=void 0!==s&&s;this._isReady?0!==o.length&&(this._getC2CPeerReadTime(o),this._updateLocalConversationList({conversationOptionsList:o,isInstantMessage:a,isUnreadC2CMessage:r,isFromGetConversations:!1}),this._setStorageConversationList(),o.filter((function(e){return e.type===D.CONV_TOPIC})).length>0||this.emitConversationUpdate()):this.ready((function(){t._onSendOrReceiveMessage(e)}))}},{key:"updateConversationGroupProfile",value:function(e){var t=this;if(!Qe(e)||0!==e.length)if(0!==this._conversationMap.size){var o=!1;e.forEach((function(e){var n="GROUP".concat(e.groupID);if(t._conversationMap.has(n)){o=!0;var a=t._conversationMap.get(n);a.groupProfile=JSON.parse(JSON.stringify(e)),a.lastMessage.lastSequence=0;r--)if(!a[r].isDeleted){s=a[r];break}var i=this._conversationMap.get(n);if(i){var c=!1;i.lastMessage.lastSequence===s.sequence&&i.lastMessage.lastTime===s.time||(Vt(s)&&(s=void 0),i.updateLastMessage(s),i.type!==D.CONV_TOPIC&&(c=!0),we.log("".concat(this._className,".onMessageDeleted. update conversationID:").concat(n," with lastMessage:"),i.lastMessage)),n.startsWith(D.CONV_C2C)&&this.updateUnreadCount(n),c&&this.emitConversationUpdate(!0,!1)}}}},{key:"onMessageModified",value:function(e){var t=e.conversationType,o=e.from,n=e.to,a=e.time,s=e.sequence,r=e.elements,i=e.cloudCustomData,c=e.messageVersion,u=this.getMyUserID(),l="".concat(t).concat(n);n===u&&t===D.CONV_C2C&&(l="".concat(t).concat(o));var d=this._messageListHandler.onMessageModified(l,e),p=d.isUpdated,g=d.message;!0===p&&this.emitOuterEvent(S.MESSAGE_MODIFIED,[g]);var _=this._isTopicConversation(l);if(we.log("".concat(this._className,".onMessageModified isUpdated:").concat(p," isTopicMessage:").concat(_," from:").concat(o," to:").concat(n)),_){this.getModule(io).onMessageModified(e)}else{var h=this._conversationMap.get(l);if(h){var f=h.lastMessage;we.debug("".concat(this._className.onMessageModified," lastMessage:"),JSON.stringify(f),"options:",JSON.stringify(e)),f&&f.lastTime===a&&f.lastSequence===s&&f.version!==c&&(f.type=r[0].type,f.payload=r[0].content,f.messageForShow=Ft(f.type,f.payload),f.cloudCustomData=i,f.version=c,this.emitConversationUpdate(!0,!1))}}return g}},{key:"onNewGroupAtTips",value:function(e){var o=this,n=e.dataList,a=null;n.forEach((function(e){e.groupAtTips?a=e.groupAtTips:e.elements&&(a=t(t({},e.elements),{},{sync:!0})),a.__random=e.random,a.__sequence=e.clientSequence,o._tmpGroupAtTipsList.push(a)})),we.debug("".concat(this._className,".onNewGroupAtTips isReady:").concat(this._isReady),this._tmpGroupAtTipsList),this._isReady&&this._handleGroupAtTipsList()}},{key:"_handleGroupAtTipsList",value:function(){var e=this;if(0!==this._tmpGroupAtTipsList.length){var t=!1;this._tmpGroupAtTipsList.forEach((function(o){var n=o.groupID,a=o.from,s=o.topicID,r=void 0===s?void 0:s,i=o.sync,c=void 0!==i&&i;if(a!==e.getMyUserID())if(Ze(r)){var u=e._conversationMap.get("".concat(D.CONV_GROUP).concat(n));u&&(u.updateGroupAtInfoList(o),t=!0)}else{var l=e._conversationMap.get("".concat(D.CONV_GROUP).concat(r));if(l){l.updateGroupAtInfoList(o);var d=e.getModule(io),p=l.groupAtInfoList;d.onConversationProxy({topicID:r,groupAtInfoList:p})}if(Vt(l)&&c)e.updateTopicConversation([{conversationID:"".concat(D.CONV_GROUP).concat(r),type:D.CONV_TOPIC}]),e._conversationMap.get("".concat(D.CONV_GROUP).concat(r)).updateGroupAtInfoList(o)}})),t&&this.emitConversationUpdate(!0,!1),this._tmpGroupAtTipsList.length=0}}},{key:"_getC2CPeerReadTime",value:function(e){var t=this,o=[];if(e.forEach((function(e){t._conversationMap.has(e.conversationID)||e.type!==D.CONV_C2C||o.push(e.conversationID.replace(D.CONV_C2C,""))})),o.length>0){we.debug("".concat(this._className,"._getC2CPeerReadTime userIDList:").concat(o));var n=this.getModule(no);n&&n.getRemotePeerReadTime(o)}}},{key:"_getStorageConversationList",value:function(){return this.getModule(lo).getItem("conversationMap")}},{key:"_setStorageConversationList",value:function(){var e=this.getLocalConversationList().slice(0,20).map((function(e){return{conversationID:e.conversationID,type:e.type,subType:e.subType,lastMessage:e.lastMessage,groupProfile:e.groupProfile,userProfile:e.userProfile}}));this.getModule(lo).setItem("conversationMap",e)}},{key:"emitConversationUpdate",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],o=this.getLocalConversationList();if(t){var n=this.getModule(ao);n&&n.updateGroupLastMessage(o)}e&&this.emitOuterEvent(S.CONVERSATION_LIST_UPDATED)}},{key:"getLocalConversationList",value:function(){return M(this._conversationMap.values()).filter((function(e){return e.type!==D.CONV_TOPIC}))}},{key:"getLocalConversation",value:function(e){return this._conversationMap.get(e)}},{key:"getLocalOldestMessage",value:function(e){return this._messageListHandler.getLocalOldestMessage(e)}},{key:"syncConversationList",value:function(){var e=this,t=new va(ya.SYNC_CONVERSATION_LIST);return this._pagingStatus===Wt.NOT_START&&this._conversationMap.clear(),this._pagingGetConversationList().then((function(o){return e._pagingStatus=Wt.RESOLVED,e._setStorageConversationList(),e._handleC2CPeerReadTime(),e._patchConversationProperties(),t.setMessage(e._conversationMap.size).setNetworkType(e.getNetworkType()).end(),o})).catch((function(o){return e._pagingStatus=Wt.REJECTED,t.setMessage(e._pagingTimeStamp),e.probeNetwork().then((function(e){var n=m(e,2),a=n[0],s=n[1];t.setError(o,a,s).end()})),ja(o)}))}},{key:"_patchConversationProperties",value:function(){var e=this,t=Date.now(),o=this.checkAndPatchRemark(),n=this._messageRemindHandler.getC2CMessageRemindType(),a=this.getModule(ao).getGroupList();Promise.all([o,n,a]).then((function(){var o=Date.now()-t;we.log("".concat(e._className,"._patchConversationProperties ok. cost ").concat(o," ms")),e.emitConversationUpdate(!0,!1)}))}},{key:"_pagingGetConversationList",value:function(){var e=this,t="".concat(this._className,"._pagingGetConversationList");return we.log("".concat(t," timeStamp:").concat(this._pagingTimeStamp," startIndex:").concat(this._pagingStartIndex)+" pinnedTimeStamp:".concat(this._pagingPinnedTimeStamp," pinnedStartIndex:").concat(this._pagingPinnedStartIndex)),this._pagingStatus=Wt.PENDING,this.request({protocolName:$o,requestData:{fromAccount:this.getMyUserID(),timeStamp:this._pagingTimeStamp,startIndex:this._pagingStartIndex,pinnedTimeStamp:this._pagingPinnedTimeStamp,pinnedStartIndex:this._pagingStartIndex,orderType:1}}).then((function(o){var n=o.data,a=n.completeFlag,s=n.conversations,r=void 0===s?[]:s,i=n.timeStamp,c=n.startIndex,u=n.pinnedTimeStamp,l=n.pinnedStartIndex;if(we.log("".concat(t," ok. completeFlag:").concat(a," count:").concat(r.length," isReady:").concat(e._isReady)),r.length>0){var d=e._getConversationOptions(r);e._updateLocalConversationList({conversationOptionsList:d,isFromGetConversations:!0}),e.isLoggedIn()&&e.emitConversationUpdate()}if(!e._isReady){if(!e.isLoggedIn())return Ya();e.triggerReady()}return e._pagingTimeStamp=i,e._pagingStartIndex=c,e._pagingPinnedTimeStamp=u,e._pagingPinnedStartIndex=l,1!==a?e._pagingGetConversationList():(e._handleGroupAtTipsList(),Ya())})).catch((function(o){throw e.isLoggedIn()&&(e._isReady||(we.warn("".concat(t," failed. error:"),o),e.triggerReady())),o}))}},{key:"_updateLocalConversationList",value:function(e){var t,o=e.isFromGetConversations,n=Date.now();t=this._getTmpConversationListMapping(e),this._conversationMap=new Map(this._sortConversationList([].concat(M(t.toBeUpdatedConversationList),M(this._conversationMap)))),o||this._updateUserOrGroupProfile(t.newConversationList),we.debug("".concat(this._className,"._updateLocalConversationList cost ").concat(Date.now()-n," ms"))}},{key:"_getTmpConversationListMapping",value:function(e){for(var t=e.conversationOptionsList,o=e.isFromGetConversations,n=e.isInstantMessage,a=e.isUnreadC2CMessage,s=void 0!==a&&a,r=[],i=[],c=this.getModule(ao),u=this.getModule(so),l=0,d=t.length;l0&&a.getUserProfile({userIDList:o}).then((function(e){var o=e.data;Qe(o)?o.forEach((function(e){t._conversationMap.get("C2C".concat(e.userID)).userProfile=e})):t._conversationMap.get("C2C".concat(o.userID)).userProfile=o})),n.length>0&&s.getGroupProfileAdvance({groupIDList:n,responseFilter:{groupBaseInfoFilter:["Type","Name","FaceUrl"]}}).then((function(e){e.data.successGroupList.forEach((function(e){var o="GROUP".concat(e.groupID);if(t._conversationMap.has(o)){var n=t._conversationMap.get(o);ct(n.groupProfile,e,[],[null,void 0,"",0,NaN]),!n.subType&&e.type&&(n.subType=e.type)}}))}))}}},{key:"_getConversationOptions",value:function(e){var o=this,n=[],a=e.filter((function(e){var t=e.lastMsg;return Xe(t)})).filter((function(e){var t=e.type,o=e.userID;return 1===t&&"@TLS#NOT_FOUND"!==o&&"@TLS#ERROR"!==o||2===t})),s=this.getMyUserID(),r=a.map((function(e){if(1===e.type){var a={userID:e.userID,nick:e.peerNick,avatar:e.peerAvatar};return n.push(a),{conversationID:"C2C".concat(e.userID),type:"C2C",lastMessage:{lastTime:e.time,lastSequence:e.sequence,fromAccount:e.lastC2CMsgFromAccount,messageForShow:e.messageShow,type:e.lastMsg.elements[0]?e.lastMsg.elements[0].type:null,payload:e.lastMsg.elements[0]?e.lastMsg.elements[0].content:null,cloudCustomData:e.lastMsg.cloudCustomData||"",isRevoked:8===e.lastMessageFlag,onlineOnlyFlag:!1,nick:"",nameCard:"",version:0,isPeerRead:e.lastC2CMsgFromAccount===s&&e.time<=e.c2cPeerReadTime},userProfile:new rs(a),peerReadTime:e.c2cPeerReadTime,isPinned:1===e.isPinned,messageRemindType:""}}return{conversationID:"GROUP".concat(e.groupID),type:"GROUP",lastMessage:t(t({lastTime:e.time,lastSequence:e.messageReadSeq+e.unreadCount,fromAccount:e.msgGroupFromAccount,messageForShow:e.messageShow},o._patchTypeAndPayload(e)),{},{cloudCustomData:e.lastMsg.cloudCustomData||"",isRevoked:2===e.lastMessageFlag,onlineOnlyFlag:!1,nick:e.senderNick||"",nameCard:e.senderNameCard||""}),groupProfile:new ls({groupID:e.groupID,name:e.groupNick,avatar:e.groupImage}),unreadCount:e.unreadCount,peerReadTime:0,isPinned:1===e.isPinned,messageRemindType:"",version:0}}));n.length>0&&this.getModule(oo).onConversationsProfileUpdated(n);return r}},{key:"_patchTypeAndPayload",value:function(e){var o=e.lastMsg,n=o.event,a=void 0===n?void 0:n,s=o.elements,r=void 0===s?[]:s,i=o.groupTips,c=void 0===i?{}:i;if(!Ze(a)&&!Vt(c)){var u=new wa(c);u.setElement({type:D.MSG_GRP_TIP,content:t(t({},c.elements),{},{groupProfile:c.groupProfile})});var l=JSON.parse(JSON.stringify(u.payload));return u=null,{type:D.MSG_GRP_TIP,payload:l}}return{type:r[0]?r[0].type:null,payload:r[0]?r[0].content:null}}},{key:"getLocalMessageList",value:function(e){return this._messageListHandler.getLocalMessageList(e)}},{key:"deleteLocalMessage",value:function(e){e instanceof wa&&this._messageListHandler.remove(e)}},{key:"onConversationDeleted",value:function(e){var t=this;we.log("".concat(this._className,".onConversationDeleted")),Qe(e)&&e.forEach((function(e){var o=e.type,n=e.userID,a=e.groupID,s="";1===o?s="".concat(D.CONV_C2C).concat(n):2===o&&(s="".concat(D.CONV_GROUP).concat(a)),t.deleteLocalConversation(s)}))}},{key:"onConversationPinned",value:function(e){var t=this;if(Qe(e)){var o=!1;e.forEach((function(e){var n,a=e.type,s=e.userID,r=e.groupID;1===a?n=t.getLocalConversation("".concat(D.CONV_C2C).concat(s)):2===a&&(n=t.getLocalConversation("".concat(D.CONV_GROUP).concat(r))),n&&(we.log("".concat(t._className,".onConversationPinned conversationID:").concat(n.conversationID," isPinned:").concat(n.isPinned)),n.isPinned||(n.isPinned=!0,o=!0))})),o&&this._sortConversationListAndEmitEvent()}}},{key:"onConversationUnpinned",value:function(e){var t=this;if(Qe(e)){var o=!1;e.forEach((function(e){var n,a=e.type,s=e.userID,r=e.groupID;1===a?n=t.getLocalConversation("".concat(D.CONV_C2C).concat(s)):2===a&&(n=t.getLocalConversation("".concat(D.CONV_GROUP).concat(r))),n&&(we.log("".concat(t._className,".onConversationUnpinned conversationID:").concat(n.conversationID," isPinned:").concat(n.isPinned)),n.isPinned&&(n.isPinned=!1,o=!0))})),o&&this._sortConversationListAndEmitEvent()}}},{key:"getMessageList",value:function(e){var t=this,o=e.conversationID,n=e.nextReqMessageID,a=e.count,s="".concat(this._className,".getMessageList"),r=this.getLocalConversation(o),i="";if(r&&r.groupProfile&&(i=r.groupProfile.type),It(i))return we.log("".concat(s," not available in avchatroom. conversationID:").concat(o)),Ya({messageList:[],nextReqMessageID:"",isCompleted:!0});(Ze(a)||a>15)&&(a=15),this._isFirstGetTopicMessageWithUnJoined(o,n)&&this.removeConversationMessageCache(o);var c=this._computeRemainingCount({conversationID:o,nextReqMessageID:n}),u=this._completedMap.has(o);if(we.log("".concat(s," conversationID:").concat(o," nextReqMessageID:").concat(n)+" remainingCount:".concat(c," count:").concat(a," isCompleted:").concat(u)),this._needGetHistory({conversationID:o,remainingCount:c,count:a}))return this.getHistoryMessages({conversationID:o,nextReqMessageID:n,count:20}).then((function(e){var n=e.nextReqID,a=e.storedMessageList,r=t._completedMap.has(o),i=a;c>0&&(i=t._messageListHandler.getLocalMessageList(o).slice(0,a.length+c));var u={nextReqMessageID:r?"":n,messageList:i,isCompleted:r};return we.log("".concat(s," ret.nextReqMessageID:").concat(u.nextReqMessageID," ret.isCompleted:").concat(u.isCompleted," ret.length:").concat(i.length)),ba(u)}));this.modifyMessageList(o);var l=this._getMessageListFromMemory({conversationID:o,nextReqMessageID:n,count:a});return Ya(l)}},{key:"_getMessageListFromMemory",value:function(e){var t=e.conversationID,o=e.nextReqMessageID,n=e.count,a="".concat(this._className,"._getMessageListFromMemory"),s=this._messageListHandler.getLocalMessageList(t),r=s.length,i=0,c={isCompleted:!1,nextReqMessageID:"",messageList:[]};return o?(i=s.findIndex((function(e){return e.ID===o})))>n?(c.messageList=s.slice(i-n,i),c.nextReqMessageID=s[i-n].ID):(c.messageList=s.slice(0,i),c.isCompleted=!0):r>n?(i=r-n,c.messageList=s.slice(i,r),c.nextReqMessageID=s[i].ID):(c.messageList=s.slice(0,r),c.isCompleted=!0),we.log("".concat(a," conversationID:").concat(t)+" ret.nextReqMessageID:".concat(c.nextReqMessageID," ret.isCompleted:").concat(c.isCompleted," ret.length:").concat(c.messageList.length)),c}},{key:"getMessageListHopping",value:function(e){var t="".concat(this._className,".getMessageListHopping"),o=e.conversationID,n=e.sequence,a=e.time,s=e.count,r=e.direction,i=void 0===r?0:r;(Ze(s)||s>15)&&(s=15);var c=this._messageListHandler.getLocalMessageListHopping({conversationID:o,sequence:n,time:a,count:s,direction:i});if(!Vt(c)){var u=c.length;if(u===s||o.startsWith(D.CONV_GROUP)&&1===c[0].sequence)return we.log("".concat(t,". conversationID:").concat(o," message from memory:").concat(c.length)),Ya({messageList:c});var l=s-u+1,d=1===i?c.pop():c.shift();return this._getRoamingMessagesHopping({conversationID:o,sequence:d.sequence,time:d.time,count:l,direction:i}).then((function(e){var n,a;(we.log("".concat(t,". conversationID:").concat(o," message from memory:").concat(c.length,", message from remote:").concat(e.length)),1===i)?(n=c).push.apply(n,M(e)):(a=c).unshift.apply(a,M(e));if(o.startsWith(D.CONV_C2C)){var s=[];c.forEach((function(e){s.push([e.ID,e])})),c=M(new Map(s).values())}return ba({messageList:c})}))}return this._getRoamingMessagesHopping({conversationID:o,sequence:n,time:a,count:s,direction:i}).then((function(e){return we.log("".concat(t,". conversationID:").concat(o," message from remote:").concat(e.length)),ba({messageList:e})}))}},{key:"_getRoamingMessagesHopping",value:function(e){var t=e.conversationID,o=e.sequence,n=e.time,a=e.count,s=e.direction;if(t.startsWith(D.CONV_C2C)){var r=this.getModule(no),i=t.replace(D.CONV_C2C,"");return r.getRoamingMessagesHopping({peerAccount:i,time:n,count:a,direction:s})}if(t.startsWith(D.CONV_GROUP)){var c=this.getModule(ao),u=t.replace(D.CONV_GROUP,""),l=o;return 1===s&&(l=o+a-1),c.getRoamingMessagesHopping({groupID:u,sequence:l,count:a}).then((function(e){var t=e.findIndex((function(e){return e.sequence===o}));return 1===s?-1===t?[]:e.slice(t):e}))}}},{key:"_computeRemainingCount",value:function(e){var t=e.conversationID,o=e.nextReqMessageID,n=this._messageListHandler.getLocalMessageList(t),a=n.length;if(!o)return a;var s=0;return Ct(t)?s=n.findIndex((function(e){return e.ID===o})):St(t)&&(s=-1!==o.indexOf("-")?n.findIndex((function(e){return e.ID===o})):n.findIndex((function(e){return e.sequence===o}))),-1===s&&(s=0),s}},{key:"_getMessageListSize",value:function(e){return this._messageListHandler.getLocalMessageList(e).length}},{key:"_needGetHistory",value:function(e){var t=e.conversationID,o=e.remainingCount,n=e.count,a=this.getLocalConversation(t),s="";return a&&a.groupProfile&&(s=a.groupProfile.type),!Dt(t)&&!It(s)&&(!(St(t)&&!this._hasLocalGroup(t)&&!this._isTopicConversation(t))&&(o<=n&&!this._completedMap.has(t)))}},{key:"_isTopicConversation",value:function(e){var t=e.replace(D.CONV_GROUP,"");return Tt(t)}},{key:"getHistoryMessages",value:function(e){var t=e.conversationID,o=e.count;if(t===D.CONV_SYSTEM)return Ya();var n=15;o>20&&(n=20);var a=null;if(Ct(t)){var s=this._roamingMessageKeyAndTimeMap.has(t);return(a=this.getModule(no))?a.getRoamingMessage({conversationID:t,peerAccount:t.replace(D.CONV_C2C,""),count:n,lastMessageTime:s?this._roamingMessageKeyAndTimeMap.get(t).lastMessageTime:0,messageKey:s?this._roamingMessageKeyAndTimeMap.get(t).messageKey:""}):ja({code:na.CANNOT_FIND_MODULE,message:aa.CANNOT_FIND_MODULE})}if(St(t)){if(!(a=this.getModule(ao)))return ja({code:na.CANNOT_FIND_MODULE,message:aa.CANNOT_FIND_MODULE});var r=null;this._conversationMap.has(t)&&(r=this._conversationMap.get(t).lastMessage);var i=0;r&&(i=r.lastSequence);var c=this._roamingMessageSequenceMap.get(t);return a.getRoamingMessage({conversationID:t,groupID:t.replace(D.CONV_GROUP,""),count:n,sequence:c||i})}return Ya()}},{key:"patchConversationLastMessage",value:function(e){var t=this.getLocalConversation(e);if(t){var o=t.lastMessage,n=o.messageForShow,a=o.payload;if(Vt(n)||Vt(a)){var s=this._messageListHandler.getLocalMessageList(e);if(0===s.length)return;var r=s[s.length-1];we.log("".concat(this._className,".patchConversationLastMessage conversationID:").concat(e," payload:"),r.payload),t.updateLastMessage(r)}}}},{key:"onRoamingMessage",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],o=arguments.length>1?arguments[1]:void 0,n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],a=o.startsWith(D.CONV_C2C)?D.CONV_C2C:D.CONV_GROUP,s=null,r=[],i=[],c=0,u=e.length,l=null,d=a===D.CONV_GROUP,p=this.getModule(_o),g=function(){c=d?e.length-1:0,u=d?0:e.length},_=function(){d?--c:++c},h=function(){return d?c>=u:c0&&void 0!==arguments[0]?arguments[0]:{},o="".concat(this._className,".setAllMessageRead");t.scope||(t.scope=D.READ_ALL_MSG),we.log("".concat(o," options:"),t);var n=this._createSetAllMessageReadPack(t);if(0===n.readAllC2CMessage&&0===n.groupMessageReadInfoList.length)return Ya();var a=new va(ya.SET_ALL_MESSAGE_READ);return this.request({protocolName:_n,requestData:n}).then((function(o){var n=o.data,s=e._handleAllMessageRead(n);return a.setMessage("scope:".concat(t.scope," failureGroups:").concat(JSON.stringify(s))).setNetworkType(e.getNetworkType()).end(),Ya()})).catch((function(t){return e.probeNetwork().then((function(e){var o=m(e,2),n=o[0],s=o[1];a.setError(t,n,s).end()})),we.warn("".concat(o," failed. error:"),t),ja({code:t&&t.code?t.code:na.MESSAGE_UNREAD_ALL_FAIL,message:t&&t.message?t.message:aa.MESSAGE_UNREAD_ALL_FAIL})}))}},{key:"_getConversationLastMessageSequence",value:function(e){var t=this._messageListHandler.getLocalLastMessage(e.conversationID),o=e.lastMessage.lastSequence;return t&&o0)if(s.type===D.CONV_C2C&&0===o.readAllC2CMessage){if(n===D.READ_ALL_MSG)o.readAllC2CMessage=1;else if(n===D.READ_ALL_C2C_MSG){o.readAllC2CMessage=1;break}}else if(s.type===D.CONV_GROUP&&(n===D.READ_ALL_GROUP_MSG||n===D.READ_ALL_MSG)){var r=this._getConversationLastMessageSequence(s);o.groupMessageReadInfoList.push({groupID:s.groupProfile.groupID,messageSequence:r})}}}catch(i){a.e(i)}finally{a.f()}return o}},{key:"onPushedAllMessageRead",value:function(e){this._handleAllMessageRead(e)}},{key:"_handleAllMessageRead",value:function(e){var t=e.groupMessageReadInfoList,o=e.readAllC2CMessage,n=this._parseGroupReadInfo(t);return this._updateAllConversationUnreadCount({readAllC2CMessage:o})>=1&&this.emitConversationUpdate(!0,!1),n}},{key:"_parseGroupReadInfo",value:function(e){var t=[];if(e&&e.length)for(var o=0,n=e.length;o=1){if(1===o&&i.type===D.CONV_C2C){var c=this._getConversationLastMessageTime(i);this.updateIsReadAfterReadReport({conversationID:r,lastMessageTime:c})}else if(i.type===D.CONV_GROUP){var u=r.replace(D.CONV_GROUP,"");if(this._remoteGroupReadSequenceMap.has(u)){var l=this._remoteGroupReadSequenceMap.get(u),d=this._getConversationLastMessageSequence(i);this.updateIsReadAfterReadReport({conversationID:r,remoteReadSequence:l}),d>=l&&this._remoteGroupReadSequenceMap.delete(u)}}this.updateUnreadCount(r,!1)&&(n+=1)}}}catch(p){a.e(p)}finally{a.f()}return n}},{key:"isRemoteRead",value:function(e){var t=e.conversationID,o=e.sequence,n=t.replace(D.CONV_GROUP,""),a=!1;if(this._remoteGroupReadSequenceMap.has(n)){var s=this._remoteGroupReadSequenceMap.get(n);o<=s&&(a=!0,we.log("".concat(this._className,".isRemoteRead conversationID:").concat(t," messageSequence:").concat(o," remoteReadSequence:").concat(s))),o>=s+10&&this._remoteGroupReadSequenceMap.delete(n)}return a}},{key:"updateIsReadAfterReadReport",value:function(e){var t=e.conversationID,o=e.lastMessageSeq,n=e.lastMessageTime,a=this._messageListHandler.getLocalMessageList(t);if(0!==a.length)for(var s,r=a.length-1;r>=0;r--)if(s=a[r],!(n&&s.time>n||o&&s.sequence>o)){if("in"===s.flow&&s.isRead)break;s.setIsRead(!0)}}},{key:"updateUnreadCount",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],o=!1,n=this.getLocalConversation(e),a=this._messageListHandler.getLocalMessageList(e);if(n){var s=n.unreadCount,r=a.filter((function(e){return!e.isRead&&!e._onlineOnlyFlag&&!e.isDeleted})).length;if(s!==r&&(n.unreadCount=r,o=!0,we.log("".concat(this._className,".updateUnreadCount from ").concat(s," to ").concat(r,", conversationID:").concat(e)),!0===t&&this.emitConversationUpdate(!0,!1)),o&&n.type===D.CONV_TOPIC){var i=n.unreadCount,c=n.groupAtInfoList,u=this.getModule(io),l=e.replace(D.CONV_GROUP,"");u.onConversationProxy({topicID:l,unreadCount:i,groupAtInfoList:c})}return o}}},{key:"updateReadReceiptInfo",value:function(e){var t=this,o=e.userID,n=void 0===o?void 0:o,a=e.groupID,s=void 0===a?void 0:a,r=e.readReceiptList;if(!Vt(r)){var i=[];if(Ze(n)){if(!Ze(s)){var c="".concat(D.CONV_GROUP).concat(s);r.forEach((function(e){var o=e.tinyID,n=e.clientTime,a=e.random,r=e.readCount,u=e.unreadCount,l="".concat(o,"-").concat(n,"-").concat(a),d=t._messageListHandler.getLocalMessage(c,l),p={groupID:s,messageID:l,readCount:0,unreadCount:0};d&&($e(r)&&(d.readReceiptInfo.readCount=r,p.readCount=r),$e(u)&&(d.readReceiptInfo.unreadCount=u,p.unreadCount=u),i.push(p))}))}}else{var u="".concat(D.CONV_C2C).concat(n);r.forEach((function(e){var o=e.tinyID,a=e.clientTime,s=e.random,r="".concat(o,"-").concat(a,"-").concat(s),c=t._messageListHandler.getLocalMessage(u,r);if(c&&!c.isPeerRead){c.isPeerRead=!0;var l={userID:n,messageID:r,isPeerRead:!0};i.push(l)}}))}i.length>0&&this.emitOuterEvent(S.MESSAGE_READ_RECEIPT_RECEIVED,i)}}},{key:"recomputeGroupUnreadCount",value:function(e){var t=e.conversationID,o=e.count,n=this.getLocalConversation(t);if(n){var a=n.unreadCount,s=a-o;s<0&&(s=0),n.unreadCount=s,we.log("".concat(this._className,".recomputeGroupUnreadCount from ").concat(a," to ").concat(s,", conversationID:").concat(t))}}},{key:"updateIsRead",value:function(e){var t=this.getLocalConversation(e),o=this.getLocalMessageList(e);if(t&&0!==o.length&&!Dt(t.type)){for(var n=[],a=0,s=o.length;a0){var o=this._messageListHandler.updateMessageIsPeerReadProperty(e,t);if(o.length>0&&this.emitOuterEvent(S.MESSAGE_READ_BY_PEER,o),this._conversationMap.has(e)){var n=this._conversationMap.get(e).lastMessage;Vt(n)||n.fromAccount===this.getMyUserID()&&n.lastTime<=t&&!n.isPeerRead&&(n.isPeerRead=!0,this.emitConversationUpdate(!0,!1))}}}},{key:"updateMessageIsModifiedProperty",value:function(e){this._messageListHandler.updateMessageIsModifiedProperty(e)}},{key:"setCompleted",value:function(e){we.log("".concat(this._className,".setCompleted. conversationID:").concat(e)),this._completedMap.set(e,!0)}},{key:"updateRoamingMessageKeyAndTime",value:function(e,t,o){this._roamingMessageKeyAndTimeMap.set(e,{messageKey:t,lastMessageTime:o})}},{key:"updateRoamingMessageSequence",value:function(e,t){this._roamingMessageSequenceMap.set(e,t)}},{key:"getConversationList",value:function(e){var t=this,o="".concat(this._className,".getConversationList"),n="pagingStatus:".concat(this._pagingStatus,", local conversation count:").concat(this._conversationMap.size,", options:").concat(e);if(we.log("".concat(o,". ").concat(n)),this._pagingStatus===Wt.REJECTED){var a=new va(ya.GET_CONVERSATION_LIST);return a.setMessage(n),this.syncConversationList().then((function(){a.setNetworkType(t.getNetworkType()).end();var o=t._getConversationList(e);return ba({conversationList:o})})).catch((function(e){return t.probeNetwork().then((function(t){var o=m(t,2),n=o[0],s=o[1];a.setError(e,n,s).end()})),we.error("".concat(o," failed. error:"),e),ja(e)}))}if(0===this._conversationMap.size){var s=new va(ya.GET_CONVERSATION_LIST);return s.setMessage(n),this.syncConversationList().then((function(){s.setNetworkType(t.getNetworkType()).end();var o=t._getConversationList(e);return ba({conversationList:o})})).catch((function(e){return t.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];s.setError(e,n,a).end()})),we.error("".concat(o," failed. error:"),e),ja(e)}))}var r=this._getConversationList(e);return we.log("".concat(o,". returned conversation count:").concat(r.length)),Ya({conversationList:r})}},{key:"_getConversationList",value:function(e){var t=this;if(Ze(e))return this.getLocalConversationList();if(Qe(e)){var o=[];return e.forEach((function(e){if(t._conversationMap.has(e)){var n=t.getLocalConversation(e);o.push(n)}})),o}}},{key:"_handleC2CPeerReadTime",value:function(){var e,t=C(this._conversationMap);try{for(t.s();!(e=t.n()).done;){var o=m(e.value,2),n=o[0],a=o[1];a.type===D.CONV_C2C&&(we.debug("".concat(this._className,"._handleC2CPeerReadTime conversationID:").concat(n," peerReadTime:").concat(a.peerReadTime)),this.recordPeerReadTime(n,a.peerReadTime))}}catch(s){t.e(s)}finally{t.f()}}},{key:"_hasLocalGroup",value:function(e){return this.getModule(ao).hasLocalGroup(e.replace(D.CONV_GROUP,""))}},{key:"getConversationProfile",value:function(e){var t,o=this;if((t=this._conversationMap.has(e)?this._conversationMap.get(e):new ps({conversationID:e,type:e.slice(0,3)===D.CONV_C2C?D.CONV_C2C:D.CONV_GROUP}))._isInfoCompleted||t.type===D.CONV_SYSTEM)return Ya({conversation:t});if(St(e)&&!this._hasLocalGroup(e))return Ya({conversation:t});var n=new va(ya.GET_CONVERSATION_PROFILE),a="".concat(this._className,".getConversationProfile");return we.log("".concat(a,". conversationID:").concat(e," remark:").concat(t.remark," lastMessage:"),t.lastMessage),this._updateUserOrGroupProfileCompletely(t).then((function(s){n.setNetworkType(o.getNetworkType()).setMessage("conversationID:".concat(e," unreadCount:").concat(s.data.conversation.unreadCount)).end();var r=o.getModule(so);if(r&&t.type===D.CONV_C2C){var i=e.replace(D.CONV_C2C,"");if(r.isMyFriend(i)){var c=r.getFriendRemark(i);t.remark!==c&&(t.remark=c,we.log("".concat(a,". conversationID:").concat(e," patch remark:").concat(t.remark)))}}return we.log("".concat(a," ok. conversationID:").concat(e)),s})).catch((function(t){return o.probeNetwork().then((function(o){var a=m(o,2),s=a[0],r=a[1];n.setError(t,s,r).setMessage("conversationID:".concat(e)).end()})),we.error("".concat(a," failed. error:"),t),ja(t)}))}},{key:"_updateUserOrGroupProfileCompletely",value:function(e){var t=this;return e.type===D.CONV_C2C?this.getModule(oo).getUserProfile({userIDList:[e.toAccount]}).then((function(o){var n=o.data;return 0===n.length?ja(new Ba({code:na.USER_OR_GROUP_NOT_FOUND,message:aa.USER_OR_GROUP_NOT_FOUND})):(e.userProfile=n[0],e._isInfoCompleted=!0,t._unshiftConversation(e),Ya({conversation:e}))})):this.getModule(ao).getGroupProfile({groupID:e.toAccount}).then((function(o){return e.groupProfile=o.data.group,e._isInfoCompleted=!0,t._unshiftConversation(e),Ya({conversation:e})}))}},{key:"_unshiftConversation",value:function(e){e instanceof ps&&!this._conversationMap.has(e.conversationID)&&(this._conversationMap=new Map([[e.conversationID,e]].concat(M(this._conversationMap))),this._setStorageConversationList(),this.emitConversationUpdate(!0,!1))}},{key:"_onProfileUpdated",value:function(e){var t=this;e.data.forEach((function(e){var o=e.userID;if(o===t.getMyUserID())t._onMyProfileModified({latestNick:e.nick,latestAvatar:e.avatar});else{var n=t._conversationMap.get("".concat(D.CONV_C2C).concat(o));n&&(n.userProfile=e)}}))}},{key:"deleteConversation",value:function(e){var t=this,o={fromAccount:this.getMyUserID(),toAccount:void 0,type:void 0,toGroupID:void 0};if(!this._conversationMap.has(e)){var n=new Ba({code:na.CONVERSATION_NOT_FOUND,message:aa.CONVERSATION_NOT_FOUND});return ja(n)}var a=this._conversationMap.get(e).type;if(a===D.CONV_C2C)o.type=1,o.toAccount=e.replace(D.CONV_C2C,"");else{if(a!==D.CONV_GROUP){if(a===D.CONV_SYSTEM)return this.getModule(ao).deleteGroupSystemNotice({messageList:this._messageListHandler.getLocalMessageList(e)}),this.deleteLocalConversation(e),Ya({conversationID:e});var s=new Ba({code:na.CONVERSATION_UN_RECORDED_TYPE,message:aa.CONVERSATION_UN_RECORDED_TYPE});return ja(s)}if(!this._hasLocalGroup(e))return this.deleteLocalConversation(e),Ya({conversationID:e});o.type=2,o.toGroupID=e.replace(D.CONV_GROUP,"")}var r=new va(ya.DELETE_CONVERSATION);r.setMessage("conversationID:".concat(e));var i="".concat(this._className,".deleteConversation");return we.log("".concat(i,". conversationID:").concat(e)),this.setMessageRead({conversationID:e}).then((function(){return t.request({protocolName:Jo,requestData:o})})).then((function(){return r.setNetworkType(t.getNetworkType()).end(),we.log("".concat(i," ok")),t.deleteLocalConversation(e),Ya({conversationID:e})})).catch((function(e){return t.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];r.setError(e,n,a).end()})),we.error("".concat(i," failed. error:"),e),ja(e)}))}},{key:"pinConversation",value:function(e){var t=this,o=e.conversationID,n=e.isPinned;if(!this._conversationMap.has(o))return ja({code:na.CONVERSATION_NOT_FOUND,message:aa.CONVERSATION_NOT_FOUND});var a=this.getLocalConversation(o);if(a.isPinned===n)return Ya({conversationID:o});var s=new va(ya.PIN_CONVERSATION);s.setMessage("conversationID:".concat(o," isPinned:").concat(n));var r="".concat(this._className,".pinConversation");we.log("".concat(r,". conversationID:").concat(o," isPinned:").concat(n));var i=null;return Ct(o)?i={type:1,toAccount:o.replace(D.CONV_C2C,"")}:St(o)&&(i={type:2,groupID:o.replace(D.CONV_GROUP,"")}),this.request({protocolName:Xo,requestData:{fromAccount:this.getMyUserID(),operationType:!0===n?1:2,itemList:[i]}}).then((function(){return s.setNetworkType(t.getNetworkType()).end(),we.log("".concat(r," ok")),a.isPinned!==n&&(a.isPinned=n,t._sortConversationListAndEmitEvent()),ba({conversationID:o})})).catch((function(e){return t.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];s.setError(e,n,a).end()})),we.error("".concat(r," failed. error:"),e),ja(e)}))}},{key:"setMessageRemindType",value:function(e){return this._messageRemindHandler.set(e)}},{key:"patchMessageRemindType",value:function(e){var t=e.ID,o=e.isC2CConversation,n=e.messageRemindType,a=!1,s=this.getLocalConversation(o?"".concat(D.CONV_C2C).concat(t):"".concat(D.CONV_GROUP).concat(t));return s&&s.messageRemindType!==n&&(s.messageRemindType=n,a=!0),a}},{key:"onC2CMessageRemindTypeSynced",value:function(e){var t=this;we.debug("".concat(this._className,".onC2CMessageRemindTypeSynced options:"),e),e.dataList.forEach((function(e){if(!Vt(e.muteNotificationsSync)){var o,n=e.muteNotificationsSync,a=n.to,s=n.updateSequence,r=n.muteFlag;t._messageRemindHandler.setUpdateSequence(s),0===r?o=D.MSG_REMIND_ACPT_AND_NOTE:1===r?o=D.MSG_REMIND_DISCARD:2===r&&(o=D.MSG_REMIND_ACPT_NOT_NOTE);var i=0;t.patchMessageRemindType({ID:a,isC2CConversation:!0,messageRemindType:o})&&(i+=1),we.log("".concat(t._className,".onC2CMessageRemindTypeSynced updateCount:").concat(i)),i>=1&&t.emitConversationUpdate(!0,!1)}}))}},{key:"deleteLocalConversation",value:function(e){var t=this._conversationMap.has(e);we.log("".concat(this._className,".deleteLocalConversation conversationID:").concat(e," has:").concat(t)),t&&(this._conversationMap.delete(e),this._roamingMessageKeyAndTimeMap.has(e)&&this._roamingMessageKeyAndTimeMap.delete(e),this._roamingMessageSequenceMap.has(e)&&this._roamingMessageSequenceMap.delete(e),this._setStorageConversationList(),this._messageListHandler.removeByConversationID(e),this._completedMap.delete(e),this.emitConversationUpdate(!0,!1))}},{key:"isMessageSentByCurrentInstance",value:function(e){return!(!this._messageListHandler.hasLocalMessage(e.conversationID,e.ID)&&!this.singlyLinkedList.has(e.random))}},{key:"modifyMessageList",value:function(e){if(e.startsWith(D.CONV_C2C)&&this._conversationMap.has(e)){var t=this._conversationMap.get(e),o=Date.now();this._messageListHandler.modifyMessageSentByPeer({conversationID:e,latestNick:t.userProfile.nick,latestAvatar:t.userProfile.avatar});var n=this.getModule(oo).getNickAndAvatarByUserID(this.getMyUserID());this._messageListHandler.modifyMessageSentByMe({conversationID:e,latestNick:n.nick,latestAvatar:n.avatar}),we.log("".concat(this._className,".modifyMessageList conversationID:").concat(e," cost ").concat(Date.now()-o," ms"))}}},{key:"updateUserProfileSpecifiedKey",value:function(e){we.log("".concat(this._className,".updateUserProfileSpecifiedKey options:"),e);var t=e.conversationID,o=e.nick,n=e.avatar;if(this._conversationMap.has(t)){var a=this._conversationMap.get(t).userProfile;ze(o)&&a.nick!==o&&(a.nick=o),ze(n)&&a.avatar!==n&&(a.avatar=n),this.emitConversationUpdate(!0,!1)}}},{key:"_onMyProfileModified",value:function(e){var o=this,n=this.getLocalConversationList(),a=Date.now();n.forEach((function(n){o.modifyMessageSentByMe(t({conversationID:n.conversationID},e))})),we.log("".concat(this._className,"._onMyProfileModified. modify all messages sent by me, cost ").concat(Date.now()-a," ms"))}},{key:"modifyMessageSentByMe",value:function(e){this._messageListHandler.modifyMessageSentByMe(e)}},{key:"getLatestMessageSentByMe",value:function(e){return this._messageListHandler.getLatestMessageSentByMe(e)}},{key:"modifyMessageSentByPeer",value:function(e){this._messageListHandler.modifyMessageSentByPeer(e)}},{key:"getLatestMessageSentByPeer",value:function(e){return this._messageListHandler.getLatestMessageSentByPeer(e)}},{key:"pushIntoNoticeResult",value:function(e,t){return!(!this._messageListHandler.pushIn(t)||this.singlyLinkedList.has(t.random))&&(e.push(t),!0)}},{key:"getGroupLocalLastMessageSequence",value:function(e){return this._messageListHandler.getGroupLocalLastMessageSequence(e)}},{key:"checkAndPatchRemark",value:function(){var e=Promise.resolve();if(0===this._conversationMap.size)return e;var t=this.getModule(so);if(!t)return e;var o=M(this._conversationMap.values()).filter((function(e){return e.type===D.CONV_C2C}));if(0===o.length)return e;var n=0;return o.forEach((function(e){var o=e.conversationID.replace(D.CONV_C2C,"");if(t.isMyFriend(o)){var a=t.getFriendRemark(o);e.remark!==a&&(e.remark=a,n+=1)}})),we.log("".concat(this._className,".checkAndPatchRemark. c2c conversation count:").concat(o.length,", patched count:").concat(n)),e}},{key:"updateTopicConversation",value:function(e){this._updateLocalConversationList({conversationOptionsList:e,isFromGetConversations:!0})}},{key:"sendReadReceipt",value:function(e){var t=e[0],o=null;return t.conversationType===D.CONV_C2C?o=this._moduleManager.getModule(no):t.conversationType===D.CONV_GROUP&&(o=this._moduleManager.getModule(ao)),o?o.sendReadReceipt(e):ja({code:na.CANNOT_FIND_MODULE,message:aa.CANNOT_FIND_MODULE})}},{key:"getReadReceiptList",value:function(e){var t=e[0],o=null;return t.conversationType===D.CONV_C2C?o=this._moduleManager.getModule(no):t.conversationType===D.CONV_GROUP&&(o=this._moduleManager.getModule(ao)),o?o.getReadReceiptList(e):ja({code:na.CANNOT_FIND_MODULE,message:aa.CANNOT_FIND_MODULE})}},{key:"getLastMessageTime",value:function(e){var t=this.getLocalConversation(e);return t?t.lastMessage.lastTime:0}},{key:"reset",value:function(){we.log("".concat(this._className,".reset")),this._pagingStatus=Wt.NOT_START,this._messageListHandler.reset(),this._messageRemindHandler.reset(),this._roamingMessageKeyAndTimeMap.clear(),this._roamingMessageSequenceMap.clear(),this.singlyLinkedList.reset(),this._peerReadTimeMap.clear(),this._completedMap.clear(),this._conversationMap.clear(),this._pagingTimeStamp=0,this._pagingStartIndex=0,this._pagingPinnedTimeStamp=0,this._pagingPinnedStartIndex=0,this._remoteGroupReadSequenceMap.clear(),this.resetReady()}}]),a}(Do),hs=function(){function e(t){n(this,e),this._groupModule=t,this._className="GroupTipsHandler",this._cachedGroupTipsMap=new Map,this._checkCountMap=new Map,this.MAX_CHECK_COUNT=4,this._getTopicPendingMap=new Map}return s(e,[{key:"onCheckTimer",value:function(e){e%1==0&&this._cachedGroupTipsMap.size>0&&this._checkCachedGroupTips()}},{key:"_checkCachedGroupTips",value:function(){var e=this;this._cachedGroupTipsMap.forEach((function(t,o){var n=e._checkCountMap.get(o),a=e._groupModule.hasLocalGroup(o);we.log("".concat(e._className,"._checkCachedGroupTips groupID:").concat(o," hasLocalGroup:").concat(a," checkCount:").concat(n)),a?(e._notifyCachedGroupTips(o),e._checkCountMap.delete(o),e._groupModule.deleteUnjoinedAVChatRoom(o)):n>=e.MAX_CHECK_COUNT?(e._deleteCachedGroupTips(o),e._checkCountMap.delete(o)):(n++,e._checkCountMap.set(o,n))}))}},{key:"onNewGroupTips",value:function(e){we.debug("".concat(this._className,".onReceiveGroupTips count:").concat(e.dataList.length));var t=this.newGroupTipsStoredAndSummary(e),o=t.eventDataList,n=t.result,a=t.AVChatRoomMessageList;(a.length>0&&this._groupModule.onAVChatRoomMessage(a),o.length>0)&&(this._groupModule.updateNextMessageSeq(o),this._groupModule.getModule(co).onNewMessage({conversationOptionsList:o,isInstantMessage:!0}));n.length>0&&(this._groupModule.emitOuterEvent(S.MESSAGE_RECEIVED,n),this.handleMessageList(n))}},{key:"newGroupTipsStoredAndSummary",value:function(e){for(var o=this,n=e.event,a=e.dataList,s=null,r=[],i=[],c={},u=[],l=function(e,l){var d=Mt(a[e]),p=d.groupProfile,g=p.groupID,_=p.communityType,h=void 0===_?0:_,f=p.topicID,m=void 0===f?void 0:f,M=void 0,v=2===h&&!Vt(m);if(v){M=D.CONV_TOPIC,d.to=m;var y=o._groupModule.getModule(io);y.hasLocalTopic(g,m)||o._getTopicPendingMap.has(m)||(o._getTopicPendingMap.set(m,1),y.getTopicList({groupID:g,topicIDList:[m]}).finally((function(){o._getTopicPendingMap.delete(m)})))}if(2===h&&Vt(m))return"continue";var I=o._groupModule.hasLocalGroup(g);if(!I&&o._groupModule.isUnjoinedAVChatRoom(g))return"continue";if(!I&&!v)return o._cacheGroupTipsAndProbe({groupID:g,event:n,item:d}),"continue";if(o._groupModule.isMessageFromOrToAVChatroom(g))return d.event=n,u.push(d),"continue";d.currentUser=o._groupModule.getMyUserID(),d.conversationType=D.CONV_GROUP,(s=new wa(d)).setElement({type:D.MSG_GRP_TIP,content:t(t({},d.elements),{},{groupProfile:d.groupProfile})}),s.isSystemMessage=!1;var E=o._groupModule.getModule(co),T=s,C=T.conversationID,S=T.sequence;if(6===n)s._onlineOnlyFlag=!0,i.push(s);else if(!E.pushIntoNoticeResult(i,s))return"continue";if(6===n&&E.getLocalConversation(C))return"continue";6!==n&&o._groupModule.getModule(Co).addMessageSequence({key:pa,message:s});var N=E.isRemoteRead({conversationID:C,sequence:S});if(Ze(c[C])){var A=0;"in"===s.flow&&(s._isExcludedFromUnreadCount||s._onlineOnlyFlag||N||(A=1)),c[C]=r.push({conversationID:C,unreadCount:A,type:Ze(M)?s.conversationType:M,subType:s.conversationSubType,lastMessage:s._isExcludedFromLastMessage?"":s})-1}else{var O=c[C];r[O].type=s.conversationType,r[O].subType=s.conversationSubType,r[O].lastMessage=s._isExcludedFromLastMessage?"":s,"in"===s.flow&&(s._isExcludedFromUnreadCount||s._onlineOnlyFlag||N||r[O].unreadCount++)}},d=0,p=a.length;d=0){c.updateSelfInfo({muteTime:d.muteTime}),u=!0;break}}u&&this._groupModule.emitOuterEvent(S.TOPIC_UPDATED,{groupID:i,topic:c})}}},{key:"_onTopicProfileUpdated",value:function(e){var o=e.payload,n=o.groupProfile.groupID,a=o.newTopicInfo;this._groupModule.getModule(io).onTopicProfileUpdated(t({groupID:n,topicID:e.to},a))}},{key:"_cacheGroupTips",value:function(e,t){this._cachedGroupTipsMap.has(e)||this._cachedGroupTipsMap.set(e,[]),this._cachedGroupTipsMap.get(e).push(t)}},{key:"_deleteCachedGroupTips",value:function(e){this._cachedGroupTipsMap.has(e)&&this._cachedGroupTipsMap.delete(e)}},{key:"_notifyCachedGroupTips",value:function(e){var t=this,o=this._cachedGroupTipsMap.get(e)||[];o.forEach((function(e){t.onNewGroupTips(e)})),this._deleteCachedGroupTips(e),we.log("".concat(this._className,"._notifyCachedGroupTips groupID:").concat(e," count:").concat(o.length))}},{key:"_cacheGroupTipsAndProbe",value:function(e){var t=this,o=e.groupID,n=e.event,a=e.item;this._cacheGroupTips(o,{event:n,dataList:[a]}),this._groupModule.getGroupSimplifiedInfo(o).then((function(e){e.type===D.GRP_AVCHATROOM?t._groupModule.hasLocalGroup(o)?t._notifyCachedGroupTips(o):t._groupModule.setUnjoinedAVChatRoom(o):(t._groupModule.updateGroupMap([e]),t._notifyCachedGroupTips(o))})),this._checkCountMap.has(o)||this._checkCountMap.set(o,0),we.log("".concat(this._className,"._cacheGroupTipsAndProbe groupID:").concat(o))}},{key:"reset",value:function(){this._cachedGroupTipsMap.clear(),this._checkCountMap.clear(),this._getTopicPendingMap.clear()}}]),e}(),fs=function(){function e(t){n(this,e),this._groupModule=t,this._className="CommonGroupHandler",this.tempConversationList=null,this._cachedGroupMessageMap=new Map,this._checkCountMap=new Map,this.MAX_CHECK_COUNT=4,this._getTopicPendingMap=new Map,t.getInnerEmitterInstance().once(Ja,this._initGroupList,this)}return s(e,[{key:"onCheckTimer",value:function(e){e%1==0&&this._cachedGroupMessageMap.size>0&&this._checkCachedGroupMessage()}},{key:"_checkCachedGroupMessage",value:function(){var e=this;this._cachedGroupMessageMap.forEach((function(t,o){var n=e._checkCountMap.get(o),a=e._groupModule.hasLocalGroup(o);we.log("".concat(e._className,"._checkCachedGroupMessage groupID:").concat(o," hasLocalGroup:").concat(a," checkCount:").concat(n)),a?(e._notifyCachedGroupMessage(o),e._checkCountMap.delete(o),e._groupModule.deleteUnjoinedAVChatRoom(o)):n>=e.MAX_CHECK_COUNT?(e._deleteCachedGroupMessage(o),e._checkCountMap.delete(o)):(n++,e._checkCountMap.set(o,n))}))}},{key:"_initGroupList",value:function(){var e=this;we.log("".concat(this._className,"._initGroupList"));var t=new va(ya.GET_GROUP_LIST_IN_STORAGE),o=this._groupModule.getStorageGroupList();if(Qe(o)&&o.length>0){o.forEach((function(t){e._groupModule.initGroupMap(t)})),this._groupModule.emitGroupListUpdate(!0,!1);var n=this._groupModule.getLocalGroupList().length;t.setNetworkType(this._groupModule.getNetworkType()).setMessage("group count:".concat(n)).end()}else t.setNetworkType(this._groupModule.getNetworkType()).setMessage("group count:0").end();we.log("".concat(this._className,"._initGroupList ok"))}},{key:"handleUpdateGroupLastMessage",value:function(e){var t="".concat(this._className,".handleUpdateGroupLastMessage");if(we.debug("".concat(t," conversation count:").concat(e.length,", local group count:").concat(this._groupModule.getLocalGroupList().length)),0!==this._groupModule.getGroupMap().size){for(var o,n,a,s=!1,r=0,i=e.length;r0&&this._groupModule.onAVChatRoomMessage(a),this._groupModule.filterModifiedMessage(n),o.length>0)&&(this._groupModule.updateNextMessageSeq(o),this._groupModule.getModule(co).onNewMessage({conversationOptionsList:o,isInstantMessage:!0}));var s=this._groupModule.filterUnmodifiedMessage(n);s.length>0&&this._groupModule.emitOuterEvent(S.MESSAGE_RECEIVED,s),n.length=0}},{key:"_newGroupMessageStoredAndSummary",value:function(e){var t=this,o=e.dataList,n=e.event,a=e.isInstantMessage,s=null,r=[],i=[],c=[],u={},l=this._groupModule.getModule(_o),d=this._groupModule.getModule(Co),p=o.length;p>1&&o.sort((function(e,t){return e.sequence-t.sequence}));for(var g=function(e){var p=Mt(o[e]),g=p.groupProfile,_=g.groupID,h=g.communityType,f=void 0===h?0:h,m=g.topicID,M=void 0===m?void 0:m,v=void 0,y=2===f&&!Vt(M);if(y){v=D.CONV_TOPIC,p.to=M;var I=t._groupModule.getModule(io);I.hasLocalTopic(_,M)||t._getTopicPendingMap.has(M)||(t._getTopicPendingMap.set(M,1),I.getTopicList({groupID:_,topicIDList:[M]}).finally((function(){t._getTopicPendingMap.delete(M)})))}if(2===f&&Vt(M))return"continue";var E=t._groupModule.hasLocalGroup(_);if(!E&&t._groupModule.isUnjoinedAVChatRoom(_))return"continue";if(!E&&!y)return t._cacheGroupMessageAndProbe({groupID:_,event:n,item:p}),"continue";if(t._groupModule.isMessageFromOrToAVChatroom(_))return p.event=n,c.push(p),"continue";p.currentUser=t._groupModule.getMyUserID(),p.conversationType=D.CONV_GROUP,p.isSystemMessage=!!p.isSystemMessage,s=new wa(p),p.elements=l.parseElements(p.elements,p.from),s.setElement(p.elements);var T=1===o[e].isModified,C=t._groupModule.getModule(co);if(C.isMessageSentByCurrentInstance(s)?s.isModified=T:T=!1,1===p.onlineOnlyFlag)s._onlineOnlyFlag=!0,i.push(s);else{if(!C.pushIntoMessageList(i,s,T))return"continue";d.addMessageSequence({key:pa,message:s}),a&&s.clientTime>0&&d.addMessageDelay(s.clientTime);var S=s,N=S.conversationID,A=S.sequence,O=C.isRemoteRead({conversationID:N,sequence:A});if(Ze(u[N])){var R=0;"in"===s.flow&&(s._isExcludedFromUnreadCount||O||(R=1)),u[N]=r.push({conversationID:N,unreadCount:R,type:Ze(v)?s.conversationType:v,subType:s.conversationSubType,lastMessage:s._isExcludedFromLastMessage?"":s})-1}else{var L=u[N];r[L].type=Ze(v)?s.conversationType:v,r[L].subType=s.conversationSubType,r[L].lastMessage=s._isExcludedFromLastMessage?"":s,"in"===s.flow&&(s._isExcludedFromUnreadCount||O||r[L].unreadCount++)}}},_=0;_g),h="offset:".concat(c," totalCount:").concat(p," isCompleted:").concat(_," ")+"currentCount:".concat(l.length," isCommunityRelay:").concat(a);return d.setNetworkType(t._groupModule.getNetworkType()).setMessage("".concat(h)).end(),a||_?!a&&_?(we.log("".concat(o," start to get community list")),c=0,t._pagingGetGroupList({limit:i,offset:c,groupBaseInfoFilter:u,groupList:l,isCommunityRelay:!0})):a&&!_?(c=g,t._pagingGetGroupList({limit:i,offset:c,groupBaseInfoFilter:u,groupList:l,isCommunityRelay:!0})):(we.log("".concat(o," ok. totalCount:").concat(l.length)),ba({groupList:l})):(c=g,t._pagingGetGroupList({limit:i,offset:c,groupBaseInfoFilter:u,groupList:l}))})).catch((function(e){return 11e3!==e.code&&t._groupModule.probeNetwork().then((function(t){var o=m(t,2),n=o[0],s=o[1];d.setMessage("isCommunityRelay:".concat(a)).setError(e,n,s).end()})),a?(11e3===e.code&&(d=null,we.log("".concat(o," ok. community unavailable"))),Ya({groupList:l})):ja(e)}))}},{key:"_pagingGetGroupListWithTopic",value:function(e){var t=this,o="".concat(this._className,"._pagingGetGroupListWithTopic"),n=e.limit,a=e.offset,s=e.groupBaseInfoFilter,r=e.groupList,i=new va(ya.PAGING_GET_GROUP_LIST_WITH_TOPIC);return this._groupModule.request({protocolName:Zo,requestData:{type:D.GRP_COMMUNITY,memberAccount:this._groupModule.getMyUserID(),limit:n,offset:a,responseFilter:{groupBaseInfoFilter:s,selfInfoFilter:["Role","JoinTime","MsgFlag","MsgSeq"]},isSupportTopic:1}}).then((function(e){var c=e.data,u=c.groups,l=void 0===u?[]:u,d=c.totalCount;r.push.apply(r,M(l));var p=a+n,g=!(d>p),_="offset:".concat(a," totalCount:").concat(d," isCompleted:").concat(g," ")+"currentCount:".concat(r.length);return i.setNetworkType(t._groupModule.getNetworkType()).setMessage("".concat(_)).end(),g?(we.log("".concat(o," ok. totalCount:").concat(r.length)),ba({groupList:r})):(a=p,t._pagingGetGroupListWithTopic({limit:n,offset:a,groupBaseInfoFilter:s,groupList:r}))})).catch((function(e){return t._groupModule.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];i.setError(e,n,a).end()})),ja(e)}))}},{key:"_cacheGroupMessage",value:function(e,t){this._cachedGroupMessageMap.has(e)||this._cachedGroupMessageMap.set(e,[]),this._cachedGroupMessageMap.get(e).push(t)}},{key:"_deleteCachedGroupMessage",value:function(e){this._cachedGroupMessageMap.has(e)&&this._cachedGroupMessageMap.delete(e)}},{key:"_notifyCachedGroupMessage",value:function(e){var t=this,o=this._cachedGroupMessageMap.get(e)||[];o.forEach((function(e){t.onNewGroupMessage(e)})),this._deleteCachedGroupMessage(e),we.log("".concat(this._className,"._notifyCachedGroupMessage groupID:").concat(e," count:").concat(o.length))}},{key:"_cacheGroupMessageAndProbe",value:function(e){var t=this,o=e.groupID,n=e.event,a=e.item;this._cacheGroupMessage(o,{event:n,dataList:[a]}),this._groupModule.getGroupSimplifiedInfo(o).then((function(e){e.type===D.GRP_AVCHATROOM?t._groupModule.hasLocalGroup(o)?t._notifyCachedGroupMessage(o):t._groupModule.setUnjoinedAVChatRoom(o):(t._groupModule.updateGroupMap([e]),t._notifyCachedGroupMessage(o))})),this._checkCountMap.has(o)||this._checkCountMap.set(o,0),we.log("".concat(this._className,"._cacheGroupMessageAndProbe groupID:").concat(o))}},{key:"reset",value:function(){this._cachedGroupMessageMap.clear(),this._checkCountMap.clear(),this._getTopicPendingMap.clear(),this._groupModule.getInnerEmitterInstance().once(Ja,this._initGroupList,this)}}]),e}(),ms={1:"init",2:"modify",3:"clear",4:"delete"},Ms=function(){function e(t){n(this,e),this._groupModule=t,this._className="GroupAttributesHandler",this._groupAttributesMap=new Map,this.CACHE_EXPIRE_TIME=3e4,this._groupModule.getInnerEmitterInstance().on(Xa,this._onCloudConfigUpdated,this)}return s(e,[{key:"_onCloudConfigUpdated",value:function(){var e=this._groupModule.getCloudConfig("grp_attr_cache_time");Ze(e)||(this.CACHE_EXPIRE_TIME=Number(e))}},{key:"updateLocalMainSequenceOnReconnected",value:function(){this._groupAttributesMap.forEach((function(e){e.localMainSequence=0}))}},{key:"onGroupAttributesUpdated",value:function(e){var t=this,o=e.groupID,n=e.groupAttributeOption,a=n.mainSequence,s=n.hasChangedAttributeInfo,r=n.groupAttributeList,i=void 0===r?[]:r,c=n.operationType;if(we.log("".concat(this._className,".onGroupAttributesUpdated. groupID:").concat(o," hasChangedAttributeInfo:").concat(s," operationType:").concat(c)),!Ze(c)){if(1===s){if(4===c){var u=[];i.forEach((function(e){u.push(e.key)})),i=M(u),u=null}return this._refreshCachedGroupAttributes({groupID:o,remoteMainSequence:a,groupAttributeList:i,operationType:ms[c]}),void this._emitGroupAttributesUpdated(o)}if(this._groupAttributesMap.has(o)){var l=this._groupAttributesMap.get(o).avChatRoomKey;this._getGroupAttributes({groupID:o,avChatRoomKey:l}).then((function(){t._emitGroupAttributesUpdated(o)}))}}}},{key:"initGroupAttributesCache",value:function(e){var t=e.groupID,o=e.avChatRoomKey;this._groupAttributesMap.set(t,{lastUpdateTime:0,localMainSequence:0,remoteMainSequence:0,attributes:new Map,avChatRoomKey:o}),we.log("".concat(this._className,".initGroupAttributesCache groupID:").concat(t," avChatRoomKey:").concat(o))}},{key:"initGroupAttributes",value:function(e){var t=this,o=e.groupID,n=e.groupAttributes,a=this._checkCachedGroupAttributes({groupID:o,funcName:"initGroupAttributes"});if(!0!==a)return ja(a);var s=this._groupAttributesMap.get(o),r=s.remoteMainSequence,i=s.avChatRoomKey,c=new va(ya.INIT_GROUP_ATTRIBUTES);return c.setMessage("groupID:".concat(o," mainSequence:").concat(r," groupAttributes:").concat(JSON.stringify(n))),this._groupModule.request({protocolName:Nn,requestData:{groupID:o,avChatRoomKey:i,mainSequence:r,groupAttributeList:this._transformGroupAttributes(n)}}).then((function(e){var a=e.data,s=a.mainSequence,r=M(a.groupAttributeList);return r.forEach((function(e){e.value=n[e.key]})),t._refreshCachedGroupAttributes({groupID:o,remoteMainSequence:s,groupAttributeList:r,operationType:"init"}),c.setNetworkType(t._groupModule.getNetworkType()).end(),we.log("".concat(t._className,".initGroupAttributes ok. groupID:").concat(o)),ba({groupAttributes:n})})).catch((function(e){return t._groupModule.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];c.setError(e,n,a).end()})),ja(e)}))}},{key:"setGroupAttributes",value:function(e){var t=this,o=e.groupID,n=e.groupAttributes,a=this._checkCachedGroupAttributes({groupID:o,funcName:"setGroupAttributes"});if(!0!==a)return ja(a);var s=this._groupAttributesMap.get(o),r=s.remoteMainSequence,i=s.avChatRoomKey,c=s.attributes,u=this._transformGroupAttributes(n);u.forEach((function(e){var t=e.key;e.sequence=0,c.has(t)&&(e.sequence=c.get(t).sequence)}));var l=new va(ya.SET_GROUP_ATTRIBUTES);return l.setMessage("groupID:".concat(o," mainSequence:").concat(r," groupAttributes:").concat(JSON.stringify(n))),this._groupModule.request({protocolName:An,requestData:{groupID:o,avChatRoomKey:i,mainSequence:r,groupAttributeList:u}}).then((function(e){var a=e.data,s=a.mainSequence,r=M(a.groupAttributeList);return r.forEach((function(e){e.value=n[e.key]})),t._refreshCachedGroupAttributes({groupID:o,remoteMainSequence:s,groupAttributeList:r,operationType:"modify"}),l.setNetworkType(t._groupModule.getNetworkType()).end(),we.log("".concat(t._className,".setGroupAttributes ok. groupID:").concat(o)),ba({groupAttributes:n})})).catch((function(e){return t._groupModule.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];l.setError(e,n,a).end()})),ja(e)}))}},{key:"deleteGroupAttributes",value:function(e){var t=this,o=e.groupID,n=e.keyList,a=void 0===n?[]:n,s=this._checkCachedGroupAttributes({groupID:o,funcName:"deleteGroupAttributes"});if(!0!==s)return ja(s);var r=this._groupAttributesMap.get(o),i=r.remoteMainSequence,c=r.avChatRoomKey,u=r.attributes,l=M(u.keys()),d=Rn,p="clear",g={groupID:o,avChatRoomKey:c,mainSequence:i};if(a.length>0){var _=[];l=[],d=On,p="delete",a.forEach((function(e){var t=0;u.has(e)&&(t=u.get(e).sequence,l.push(e)),_.push({key:e,sequence:t})})),g.groupAttributeList=_}var h=new va(ya.DELETE_GROUP_ATTRIBUTES);return h.setMessage("groupID:".concat(o," mainSequence:").concat(i," keyList:").concat(a," protocolName:").concat(d)),this._groupModule.request({protocolName:d,requestData:g}).then((function(e){var n=e.data.mainSequence;return t._refreshCachedGroupAttributes({groupID:o,remoteMainSequence:n,groupAttributeList:a,operationType:p}),h.setNetworkType(t._groupModule.getNetworkType()).end(),we.log("".concat(t._className,".deleteGroupAttributes ok. groupID:").concat(o)),ba({keyList:l})})).catch((function(e){return t._groupModule.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];h.setError(e,n,a).end()})),ja(e)}))}},{key:"getGroupAttributes",value:function(e){var t=this,o=e.groupID,n=this._checkCachedGroupAttributes({groupID:o,funcName:"getGroupAttributes"});if(!0!==n)return ja(n);var a=this._groupAttributesMap.get(o),s=a.avChatRoomKey,r=a.lastUpdateTime,i=a.localMainSequence,c=a.remoteMainSequence,u=new va(ya.GET_GROUP_ATTRIBUTES);if(u.setMessage("groupID:".concat(o," localMainSequence:").concat(i," remoteMainSequence:").concat(c," keyList:").concat(e.keyList)),Date.now()-r>=this.CACHE_EXPIRE_TIME||i0)n.forEach((function(e){s.has(e)&&(a[e]=s.get(e).value)}));else{var r,i=C(s.keys());try{for(i.s();!(r=i.n()).done;){var c=r.value;a[c]=s.get(c).value}}catch(u){i.e(u)}finally{i.f()}}return a}},{key:"_refreshCachedGroupAttributes",value:function(e){var t=e.groupID,o=e.remoteMainSequence,n=e.groupAttributeList,a=e.operationType;if(this._groupAttributesMap.has(t)){var s=this._groupAttributesMap.get(t),r=s.localMainSequence;if("get"===a||o-r==1)s.remoteMainSequence=o,s.localMainSequence=o,s.lastUpdateTime=Date.now(),this._updateCachedAttributes({groupAttributes:s,groupAttributeList:n,operationType:a});else{if(r===o)return;s.remoteMainSequence=o}this._groupAttributesMap.set(t,s);var i="operationType:".concat(a," localMainSequence:").concat(r," remoteMainSequence:").concat(o);we.log("".concat(this._className,"._refreshCachedGroupAttributes. ").concat(i))}}},{key:"_updateCachedAttributes",value:function(e){var t=e.groupAttributes,o=e.groupAttributeList,n=e.operationType;"clear"!==n?"delete"!==n?("init"===n&&t.attributes.clear(),o.forEach((function(e){var o=e.key,n=e.value,a=e.sequence;t.attributes.set(o,{value:n,sequence:a})}))):o.forEach((function(e){t.attributes.delete(e)})):t.attributes.clear()}},{key:"_checkCachedGroupAttributes",value:function(e){var t=e.groupID,o=e.funcName;if(this._groupModule.hasLocalGroup(t)&&this._groupModule.getLocalGroupProfile(t).type!==D.GRP_AVCHATROOM){return we.warn("".concat(this._className,"._checkCachedGroupAttributes. ").concat("非直播群不能使用群属性 API")),new Ba({code:na.CANNOT_USE_GRP_ATTR_NOT_AVCHATROOM,message:"非直播群不能使用群属性 API"})}var n=this._groupAttributesMap.get(t);if(Ze(n)){var a="如果 groupID:".concat(t," 是直播群,使用 ").concat(o," 前先使用 joinGroup 接口申请加入群组,详细请参考 https://web.sdk.qcloud.com/im/doc/zh-cn/SDK.html#joinGroup");return we.warn("".concat(this._className,"._checkCachedGroupAttributes. ").concat(a)),new Ba({code:na.CANNOT_USE_GRP_ATTR_AVCHATROOM_UNJOIN,message:a})}return!0}},{key:"_transformGroupAttributes",value:function(e){var t=[];return Object.keys(e).forEach((function(o){t.push({key:o,value:e[o]})})),t}},{key:"_emitGroupAttributesUpdated",value:function(e){var t=this._getLocalGroupAttributes({groupID:e});this._groupModule.emitOuterEvent(S.GROUP_ATTRIBUTES_UPDATED,{groupID:e,groupAttributes:t})}},{key:"reset",value:function(){this._groupAttributesMap.clear(),this.CACHE_EXPIRE_TIME=3e4}}]),e}(),vs=function(){function e(t){n(this,e);var o=t.manager,a=t.groupID,s=t.onInit,r=t.onSuccess,i=t.onFail;this._className="Polling",this._manager=o,this._groupModule=o._groupModule,this._onInit=s,this._onSuccess=r,this._onFail=i,this._groupID=a,this._timeoutID=-1,this._isRunning=!1,this._protocolName=En}return s(e,[{key:"start",value:function(){var e=this._groupModule.isLoggedIn();e||(this._protocolName=Tn),we.log("".concat(this._className,".start pollingInterval:").concat(this._manager.getPollingInterval()," isLoggedIn:").concat(e)),this._isRunning=!0,this._request()}},{key:"isRunning",value:function(){return this._isRunning}},{key:"_request",value:function(){var e=this,t=this._onInit(this._groupID);this._groupModule.request({protocolName:this._protocolName,requestData:t}).then((function(t){e._onSuccess(e._groupID,t),e.isRunning()&&(clearTimeout(e._timeoutID),e._timeoutID=setTimeout(e._request.bind(e),e._manager.getPollingInterval()))})).catch((function(t){e._onFail(e._groupID,t),e.isRunning()&&(clearTimeout(e._timeoutID),e._timeoutID=setTimeout(e._request.bind(e),e._manager.MAX_POLLING_INTERVAL))}))}},{key:"stop",value:function(){we.log("".concat(this._className,".stop")),this._timeoutID>0&&(clearTimeout(this._timeoutID),this._timeoutID=-1),this._isRunning=!1}}]),e}(),ys={3:!0,4:!0,5:!0,6:!0},Is=function(){function e(t){n(this,e),this._groupModule=t,this._className="AVChatRoomHandler",this._joinedGroupMap=new Map,this._pollingRequestInfoMap=new Map,this._pollingInstanceMap=new Map,this.sequencesLinkedList=new cs(200),this.messageIDLinkedList=new cs(100),this.receivedMessageCount=0,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}return s(e,[{key:"hasJoinedAVChatRoom",value:function(){return this._joinedGroupMap.size>0}},{key:"checkJoinedAVChatRoomByID",value:function(e){return this._joinedGroupMap.has(e)}},{key:"getJoinedAVChatRoom",value:function(){return this._joinedGroupMap.size>0?M(this._joinedGroupMap.keys()):null}},{key:"_updateRequestData",value:function(e){return t({},this._pollingRequestInfoMap.get(e))}},{key:"_handleSuccess",value:function(e,t){var o=t.data,n=o.key,a=o.nextSeq,s=o.rspMsgList;if(0!==o.errorCode){var r=this._pollingRequestInfoMap.get(e),i=new va(ya.LONG_POLLING_AV_ERROR),c=r?"".concat(r.key,"-").concat(r.startSeq):"requestInfo is undefined";i.setMessage("".concat(e,"-").concat(c,"-").concat(t.errorInfo)).setCode(t.errorCode).setNetworkType(this._groupModule.getNetworkType()).end(!0)}else{if(!this.checkJoinedAVChatRoomByID(e))return;ze(n)&&$e(a)&&this._pollingRequestInfoMap.set(e,{key:n,startSeq:a}),Qe(s)&&s.length>0?(s.forEach((function(e){e.to=e.groupID})),this.onMessage(s)):(this._pollingNoMessageCount+=1,this._pollingNoMessageCount===this.DEFAULT_POLLING_NO_MESSAGE_COUNT&&(this._pollingInterval=this.DEFAULT_POLLING_INTERVAL+this.DEFAULT_POLLING_INTERVAL_PLUS))}}},{key:"_handleFailure",value:function(e,t){}},{key:"onMessage",value:function(e){if(Qe(e)&&0!==e.length){0!==this._pollingNoMessageCount&&(this._pollingNoMessageCount=0,this._pollingInterval=this.DEFAULT_POLLING_INTERVAL);var t=null,o=[],n=this._getModule(co),a=this._getModule(Co),s=e.length;s>1&&e.sort((function(e,t){return e.sequence-t.sequence}));for(var r=this._getModule(uo),i=0;i1&&p<=20?this._getModule(yo).onMessageMaybeLost(l,d+1,p-1):p<-1&&p>=-20&&this._getModule(yo).onMessageMaybeLost(l,t.sequence+1,Math.abs(p)-1)}this.sequencesLinkedList.set(t.sequence),this.messageIDLinkedList.set(t.ID);var g=!1;if(this._isMessageSentByCurrentInstance(t)?c&&(g=!0,t.isModified=c,n.updateMessageIsModifiedProperty(t)):g=!0,g){if(t.conversationType===D.CONV_SYSTEM&&5===t.payload.operationType&&this._onGroupDismissed(t.payload.groupProfile.groupID),!u&&t.conversationType!==D.CONV_SYSTEM){var _=t.conversationID.replace(D.CONV_GROUP,"");this._pollingInstanceMap.has(_)?a.addMessageSequence({key:_a,message:t}):(t.type!==D.MSG_GRP_TIP&&t.clientTime>0&&a.addMessageDelay(t.clientTime),a.addMessageSequence({key:ga,message:t}))}o.push(t)}}}else we.warn("".concat(this._className,".onMessage 未处理的 event 类型: ").concat(e[i].event));if(0!==o.length){this._groupModule.filterModifiedMessage(o);var h=this.packConversationOption(o);if(h.length>0)this._getModule(co).onNewMessage({conversationOptionsList:h,isInstantMessage:!0});we.debug("".concat(this._className,".onMessage count:").concat(o.length)),this._checkMessageStacked(o);var f=this._groupModule.filterUnmodifiedMessage(o);f.length>0&&this._groupModule.emitOuterEvent(S.MESSAGE_RECEIVED,f),o.length=0}}}},{key:"_onGroupDismissed",value:function(e){we.log("".concat(this._className,"._onGroupDismissed groupID:").concat(e)),this._groupModule.deleteLocalGroupAndConversation(e),this.reset(e)}},{key:"_checkMessageStacked",value:function(e){var t=e.length;t>=100&&(we.warn("".concat(this._className,"._checkMessageStacked 直播群消息堆积数:").concat(e.length,'!可能会导致微信小程序渲染时遇到 "Dom limit exceeded" 的错误,建议接入侧此时只渲染最近的10条消息')),this._reportMessageStackedCount<5&&(new va(ya.MESSAGE_STACKED).setNetworkType(this._groupModule.getNetworkType()).setMessage("count:".concat(t," groupID:").concat(M(this._joinedGroupMap.keys()))).setLevel("warning").end(),this._reportMessageStackedCount+=1))}},{key:"_isMessageSentByCurrentInstance",value:function(e){return!!this._getModule(co).isMessageSentByCurrentInstance(e)}},{key:"packMessage",value:function(e,t){e.currentUser=this._groupModule.getMyUserID(),e.conversationType=5===t?D.CONV_SYSTEM:D.CONV_GROUP,e.isSystemMessage=!!e.isSystemMessage;var o=new wa(e),n=this.packElements(e,t);return o.setElement(n),o}},{key:"packElements",value:function(e,o){return 4===o||6===o?(this._updateMemberCountByGroupTips(e),this._onGroupAttributesUpdated(e),{type:D.MSG_GRP_TIP,content:t(t({},e.elements),{},{groupProfile:e.groupProfile})}):5===o?{type:D.MSG_GRP_SYS_NOTICE,content:t(t({},e.elements),{},{groupProfile:t(t({},e.groupProfile),{},{groupID:e.groupID})})}:this._getModule(_o).parseElements(e.elements,e.from)}},{key:"packConversationOption",value:function(e){for(var t=new Map,o=0;o1e3*t.expireTime&&o-t.latestUpdateTime>1e4&&o-t.lastReqTime>3e3?(t.lastReqTime=o,this._onlineMemberCountMap.set(e,t),this._getGroupOnlineMemberCount(e).then((function(e){return ba({memberCount:e.memberCount})})).catch((function(e){return ja(e)}))):Ya({memberCount:t.memberCount})}},{key:"_getGroupOnlineMemberCount",value:function(e){var t=this,o="".concat(this._className,"._getGroupOnlineMemberCount");return this._groupModule.request({protocolName:Cn,requestData:{groupID:e}}).then((function(n){var a=t._onlineMemberCountMap.get(e)||{},s=n.data,r=s.onlineMemberNum,i=void 0===r?0:r,c=s.expireTime,u=void 0===c?t.DEFAULT_EXPIRE_TIME:c;we.log("".concat(o," ok. groupID:").concat(e," memberCount:").concat(i," expireTime:").concat(u));var l=Date.now();return Vt(a)&&(a.lastReqTime=l),t._onlineMemberCountMap.set(e,Object.assign(a,{lastSyncTime:l,latestUpdateTime:l,memberCount:i,expireTime:u})),{memberCount:i}})).catch((function(n){return we.warn("".concat(o," failed. error:"),n),new va(ya.GET_GROUP_ONLINE_MEMBER_COUNT).setCode(n.code).setMessage("groupID:".concat(e," error:").concat(JSON.stringify(n))).setNetworkType(t._groupModule.getNetworkType()).end(),Promise.reject(n)}))}},{key:"_onGroupAttributesUpdated",value:function(e){var t=e.groupID,o=e.elements,n=o.operationType,a=o.newGroupProfile;if(6===n){var s=(void 0===a?void 0:a).groupAttributeOption;Vt(s)||this._groupModule.onGroupAttributesUpdated({groupID:t,groupAttributeOption:s})}}},{key:"_getModule",value:function(e){return this._groupModule.getModule(e)}},{key:"setPollingInterval",value:function(e){Ze(e)||($e(e)?this._pollingInterval=this.DEFAULT_POLLING_INTERVAL=e:this._pollingInterval=this.DEFAULT_POLLING_INTERVAL=parseInt(e,10))}},{key:"setPollingIntervalPlus",value:function(e){Ze(e)||($e(e)?this.DEFAULT_POLLING_INTERVAL_PLUS=e:this.DEFAULT_POLLING_INTERVAL_PLUS=parseInt(e,10))}},{key:"setPollingNoMessageCount",value:function(e){Ze(e)||($e(e)?this.DEFAULT_POLLING_NO_MESSAGE_COUNT=e:this.DEFAULT_POLLING_NO_MESSAGE_COUNT=parseInt(e,10))}},{key:"getPollingInterval",value:function(){return this._pollingInterval}},{key:"reset",value:function(e){if(e){we.log("".concat(this._className,".reset groupID:").concat(e));var 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{we.log("".concat(this._className,".reset all"));var o,n=C(this._pollingInstanceMap.values());try{for(n.s();!(o=n.n()).done;){o.value.stop()}}catch(a){n.e(a)}finally{n.f()}this._pollingInstanceMap.clear(),this._joinedGroupMap.clear(),this._pollingRequestInfoMap.clear(),this._onlineMemberCountMap.clear()}this.sequencesLinkedList.reset(),this.messageIDLinkedList.reset(),this.receivedMessageCount=0,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}}]),e}(),Es=1,Ts=15,Cs=function(){function e(t){n(this,e),this._groupModule=t,this._className="GroupSystemNoticeHandler",this.pendencyMap=new Map}return s(e,[{key:"onNewGroupSystemNotice",value:function(e){var t=e.dataList,o=e.isSyncingEnded,n=e.isInstantMessage;we.debug("".concat(this._className,".onReceiveSystemNotice count:").concat(t.length));var a=this.newSystemNoticeStoredAndSummary({notifiesList:t,isInstantMessage:n}),s=a.eventDataList,r=a.result;s.length>0&&(this._groupModule.getModule(co).onNewMessage({conversationOptionsList:s,isInstantMessage:n}),this._onReceivedGroupSystemNotice({result:r,isInstantMessage:n}));n?r.length>0&&this._groupModule.emitOuterEvent(S.MESSAGE_RECEIVED,r):!0===o&&this._clearGroupSystemNotice()}},{key:"newSystemNoticeStoredAndSummary",value:function(e){var o=e.notifiesList,n=e.isInstantMessage,a=null,s=o.length,r=0,i=[],c={conversationID:D.CONV_SYSTEM,unreadCount:0,type:D.CONV_SYSTEM,subType:null,lastMessage:null};for(r=0;r0?[c]:[],result:i}}},{key:"_clearGroupSystemNotice",value:function(){var e=this;this.getPendencyList().then((function(t){t.forEach((function(t){e.pendencyMap.set("".concat(t.from,"_").concat(t.groupID,"_").concat(t.to),t)}));var o=e._groupModule.getModule(co).getLocalMessageList(D.CONV_SYSTEM),n=[];o.forEach((function(t){var o=t.payload,a=o.operatorID,s=o.operationType,r=o.groupProfile;if(s===Es){var i="".concat(a,"_").concat(r.groupID,"_").concat(r.to),c=e.pendencyMap.get(i);c&&$e(c.handled)&&0!==c.handled&&n.push(t)}})),e.deleteGroupSystemNotice({messageList:n})}))}},{key:"deleteGroupSystemNotice",value:function(e){var t=this,o="".concat(this._className,".deleteGroupSystemNotice");return Qe(e.messageList)&&0!==e.messageList.length?(we.log("".concat(o," ")+e.messageList.map((function(e){return e.ID}))),this._groupModule.request({protocolName:In,requestData:{messageListToDelete:e.messageList.map((function(e){return{from:D.CONV_SYSTEM,messageSeq:e.clientSequence,messageRandom:e.random}}))}}).then((function(){we.log("".concat(o," ok"));var n=t._groupModule.getModule(co);return e.messageList.forEach((function(e){n.deleteLocalMessage(e)})),ba()})).catch((function(e){return we.error("".concat(o," error:"),e),ja(e)}))):Ya()}},{key:"getPendencyList",value:function(e){var t=this;return this._groupModule.request({protocolName:yn,requestData:{startTime:e&&e.startTime?e.startTime:0,limit:e&&e.limit?e.limit:10,handleAccount:this._groupModule.getMyUserID()}}).then((function(e){var o=e.data.pendencyList;return 0!==e.data.nextStartTime?t.getPendencyList({startTime:e.data.nextStartTime}).then((function(e){return[].concat(M(o),M(e))})):o}))}},{key:"_onReceivedGroupSystemNotice",value:function(e){var t=this,o=e.result;e.isInstantMessage&&o.forEach((function(e){switch(e.payload.operationType){case 1:break;case 2:t._onApplyGroupRequestAgreed(e);break;case 3:break;case 4:t._onMemberKicked(e);break;case 5:t._onGroupDismissed(e);break;case 6:break;case 7:t._onInviteGroup(e);break;case 8:t._onQuitGroup(e);break;case 9:t._onSetManager(e);break;case 10:t._onDeleteManager(e)}}))}},{key:"_onApplyGroupRequestAgreed",value:function(e){var t=this,o=e.payload.groupProfile.groupID;this._groupModule.hasLocalGroup(o)||this._groupModule.getGroupProfile({groupID:o}).then((function(e){var o=e.data.group;if(o){t._groupModule.updateGroupMap([o]);var n=!o.isSupportTopic;t._groupModule.emitGroupListUpdate(!0,n)}}))}},{key:"_onMemberKicked",value:function(e){var t=e.payload.groupProfile.groupID;this._groupModule.hasLocalGroup(t)&&this._groupModule.deleteLocalGroupAndConversation(t)}},{key:"_onGroupDismissed",value:function(e){var t=e.payload.groupProfile.groupID;this._groupModule.hasLocalGroup(t)&&this._groupModule.deleteLocalGroupAndConversation(t);var o=this._groupModule._AVChatRoomHandler;o&&o.checkJoinedAVChatRoomByID(t)&&o.reset(t)}},{key:"_onInviteGroup",value:function(e){var t=this,o=e.payload.groupProfile.groupID;this._groupModule.hasLocalGroup(o)||this._groupModule.getGroupProfile({groupID:o}).then((function(e){var o=e.data.group;o&&(t._groupModule.updateGroupMap([o]),t._groupModule.emitGroupListUpdate())}))}},{key:"_onQuitGroup",value:function(e){var t=e.payload.groupProfile.groupID;this._groupModule.hasLocalGroup(t)&&this._groupModule.deleteLocalGroupAndConversation(t)}},{key:"_onSetManager",value:function(e){var t=e.payload.groupProfile,o=t.to,n=t.groupID,a=this._groupModule.getModule(ro).getLocalGroupMemberInfo(n,o);a&&a.updateRole(D.GRP_MBR_ROLE_ADMIN)}},{key:"_onDeleteManager",value:function(e){var t=e.payload.groupProfile,o=t.to,n=t.groupID,a=this._groupModule.getModule(ro).getLocalGroupMemberInfo(n,o);a&&a.updateRole(D.GRP_MBR_ROLE_MEMBER)}},{key:"_handleTopicSystemNotice",value:function(e){var t=e.groupProfile,o=t.groupID,n=t.topicID,a=e.elements,s=a.operationType,r=a.topicIDList,i=this._groupModule.getModule(io);17===s?i.onTopicCreated({groupID:o,topicID:n}):18===s&&i.onTopicDeleted({groupID:o,topicIDList:r})}},{key:"reset",value:function(){this.pendencyMap.clear()}}]),e}(),Ss=["relayFlag"],Ds=function(e){i(a,e);var o=f(a);function a(e){var t;return n(this,a),(t=o.call(this,e))._className="GroupModule",t._commonGroupHandler=null,t._AVChatRoomHandler=null,t._groupSystemNoticeHandler=null,t._commonGroupHandler=new fs(_(t)),t._groupAttributesHandler=new Ms(_(t)),t._AVChatRoomHandler=new Is(_(t)),t._groupTipsHandler=new hs(_(t)),t._groupSystemNoticeHandler=new Cs(_(t)),t.groupMap=new Map,t._unjoinedAVChatRoomList=new Map,t._receiptDetailCompleteMap=new Map,t.getInnerEmitterInstance().on(Xa,t._onCloudConfigUpdated,_(t)),t}return s(a,[{key:"_onCloudConfigUpdated",value:function(){var e=this.getCloudConfig("polling_interval"),t=this.getCloudConfig("polling_interval_plus"),o=this.getCloudConfig("polling_no_msg_count");this._AVChatRoomHandler&&(we.log("".concat(this._className,"._onCloudConfigUpdated pollingInterval:").concat(e)+" pollingIntervalPlus:".concat(t," pollingNoMessageCount:").concat(o)),this._AVChatRoomHandler.setPollingInterval(e),this._AVChatRoomHandler.setPollingIntervalPlus(t),this._AVChatRoomHandler.setPollingNoMessageCount(o))}},{key:"onCheckTimer",value:function(e){this.isLoggedIn()&&(this._commonGroupHandler.onCheckTimer(e),this._groupTipsHandler.onCheckTimer(e))}},{key:"guardForAVChatRoom",value:function(e){var t=this;if(e.conversationType===D.CONV_GROUP){var o=Tt(e.to)?bt(e.to):e.to;return this.hasLocalGroup(o)?Ya():this.getGroupProfile({groupID:o}).then((function(n){var a=n.data.group.type;if(we.log("".concat(t._className,".guardForAVChatRoom. groupID:").concat(o," type:").concat(a)),a===D.GRP_AVCHATROOM){var s="userId:".concat(e.from," 未加入群 groupID:").concat(o,"。发消息前先使用 joinGroup 接口申请加群,详细请参考 https://web.sdk.qcloud.com/im/doc/zh-cn/SDK.html#joinGroup");return we.warn("".concat(t._className,".guardForAVChatRoom sendMessage not allowed. ").concat(s)),ja(new Ba({code:na.MESSAGE_SEND_FAIL,message:s,data:{message:e}}))}return Ya()}))}return Ya()}},{key:"checkJoinedAVChatRoomByID",value:function(e){return!!this._AVChatRoomHandler&&this._AVChatRoomHandler.checkJoinedAVChatRoomByID(e)}},{key:"onNewGroupMessage",value:function(e){this._commonGroupHandler&&this._commonGroupHandler.onNewGroupMessage(e)}},{key:"updateNextMessageSeq",value:function(e){var t=this;if(Qe(e)){var o=this.getModule(io);e.forEach((function(e){var n=e.conversationID.replace(D.CONV_GROUP,"");if(Tt(n)){var a=e.lastMessage.sequence+1,s=bt(n),r=o.getLocalTopic(s,n);r&&(r.updateNextMessageSeq(a),r.updateLastMessage(e.lastMessage))}t.groupMap.has(n)&&(t.groupMap.get(n).nextMessageSeq=e.lastMessage.sequence+1)}))}}},{key:"onNewGroupTips",value:function(e){this._groupTipsHandler&&this._groupTipsHandler.onNewGroupTips(e)}},{key:"onGroupMessageRevoked",value:function(e){this._commonGroupHandler&&this._commonGroupHandler.onGroupMessageRevoked(e)}},{key:"onNewGroupSystemNotice",value:function(e){this._groupSystemNoticeHandler&&this._groupSystemNoticeHandler.onNewGroupSystemNotice(e)}},{key:"onGroupMessageReadNotice",value:function(e){var t=this;e.dataList.forEach((function(e){var o=e.elements.groupMessageReadNotice;if(!Ze(o)){var n=t.getModule(co);o.forEach((function(e){var o=e.groupID,a=e.topicID,s=void 0===a?void 0:a,r=e.lastMessageSeq;we.debug("".concat(t._className,".onGroupMessageReadNotice groupID:").concat(o," lastMessageSeq:").concat(r));var i="".concat(D.CONV_GROUP).concat(o),c=!0;Vt(s)||(i="".concat(D.CONV_GROUP).concat(s),c=!1),n.updateIsReadAfterReadReport({conversationID:i,lastMessageSeq:r}),n.updateUnreadCount(i,c)}))}}))}},{key:"onReadReceiptList",value:function(e){var t=this;we.debug("".concat(this._className,".onReadReceiptList options:"),JSON.stringify(e)),e.dataList.forEach((function(e){var o=e.groupProfile,n=e.elements,a=o.groupID,s=t.getModule(co),r=n.readReceiptList;s.updateReadReceiptInfo({groupID:a,readReceiptList:r})}))}},{key:"onGroupMessageModified",value:function(e){we.debug("".concat(this._className,".onGroupMessageModified options:"),JSON.stringify(e));var o=this.getModule(co);e.dataList.forEach((function(e){o.onMessageModified(t(t({},e),{},{conversationType:D.CONV_GROUP,to:e.topicID?e.topicID:e.groupID}))}))}},{key:"deleteGroupSystemNotice",value:function(e){this._groupSystemNoticeHandler&&this._groupSystemNoticeHandler.deleteGroupSystemNotice(e)}},{key:"initGroupMap",value:function(e){this.groupMap.set(e.groupID,new ls(e))}},{key:"deleteGroup",value:function(e){this.groupMap.delete(e)}},{key:"updateGroupMap",value:function(e){var t=this;e.forEach((function(e){t.groupMap.has(e.groupID)?t.groupMap.get(e.groupID).updateGroup(e):t.groupMap.set(e.groupID,new ls(e))}));var o,n=this.getMyUserID(),a=C(this.groupMap);try{for(a.s();!(o=a.n()).done;){m(o.value,2)[1].selfInfo.userID=n}}catch(s){a.e(s)}finally{a.f()}this._setStorageGroupList()}},{key:"getStorageGroupList",value:function(){return this.getModule(lo).getItem("groupMap")}},{key:"_setStorageGroupList",value:function(){var e=this.getLocalGroupList().filter((function(e){var t=e.type;return!It(t)})).filter((function(e){return!e.isSupportTopic})).slice(0,20).map((function(e){return{groupID:e.groupID,name:e.name,avatar:e.avatar,type:e.type}}));this.getModule(lo).setItem("groupMap",e)}},{key:"getGroupMap",value:function(){return this.groupMap}},{key:"getLocalGroupList",value:function(){return M(this.groupMap.values())}},{key:"getLocalGroupProfile",value:function(e){return this.groupMap.get(e)}},{key:"sortLocalGroupList",value:function(){var e=M(this.groupMap).filter((function(e){var t=m(e,2);t[0];return!Vt(t[1].lastMessage)}));e.sort((function(e,t){return t[1].lastMessage.lastTime-e[1].lastMessage.lastTime})),this.groupMap=new Map(M(e))}},{key:"updateGroupLastMessage",value:function(e){this._commonGroupHandler&&this._commonGroupHandler.handleUpdateGroupLastMessage(e)}},{key:"emitGroupListUpdate",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],o=this.getLocalGroupList();if(e&&this.emitOuterEvent(S.GROUP_LIST_UPDATED),t){var n=JSON.parse(JSON.stringify(o)),a=this.getModule(co);a.updateConversationGroupProfile(n)}}},{key:"patchGroupMessageRemindType",value:function(){var e=this.getLocalGroupList(),t=this.getModule(co),o=0;e.forEach((function(e){!0===t.patchMessageRemindType({ID:e.groupID,isC2CConversation:!1,messageRemindType:e.selfInfo.messageRemindType})&&(o+=1)})),we.log("".concat(this._className,".patchGroupMessageRemindType count:").concat(o))}},{key:"recomputeUnreadCount",value:function(){var e=this.getLocalGroupList(),t=this.getModule(co);e.forEach((function(e){var o=e.groupID,n=e.selfInfo,a=n.excludedUnreadSequenceList,s=n.readedSequence;if(Qe(a)){var r=0;a.forEach((function(t){t>=s&&t<=e.nextMessageSeq-1&&(r+=1)})),r>=1&&t.recomputeGroupUnreadCount({conversationID:"".concat(D.CONV_GROUP).concat(o),count:r})}}))}},{key:"getMyNameCardByGroupID",value:function(e){var t=this.getLocalGroupProfile(e);return t?t.selfInfo.nameCard:""}},{key:"getGroupList",value:function(e){return this._commonGroupHandler?this._commonGroupHandler.getGroupList(e):Ya()}},{key:"getGroupProfile",value:function(e){var t=this,o=new va(ya.GET_GROUP_PROFILE),n="".concat(this._className,".getGroupProfile"),a=e.groupID,s=e.groupCustomFieldFilter;we.log("".concat(n," groupID:").concat(a));var r={groupIDList:[a],responseFilter:{groupBaseInfoFilter:["Type","Name","Introduction","Notification","FaceUrl","Owner_Account","CreateTime","InfoSeq","LastInfoTime","LastMsgTime","MemberNum","MaxMemberNum","ApplyJoinOption","NextMsgSeq","ShutUpAllMember"],groupCustomFieldFilter:s,memberInfoFilter:["Role","JoinTime","MsgSeq","MsgFlag","NameCard"]}};return this.getGroupProfileAdvance(r).then((function(e){var s,r=e.data,i=r.successGroupList,c=r.failureGroupList;if(we.log("".concat(n," ok")),c.length>0)return ja(c[0]);(It(i[0].type)&&!t.hasLocalGroup(a)?s=new ls(i[0]):(t.updateGroupMap(i),s=t.getLocalGroupProfile(a)),s.isSupportTopic)||t.getModule(co).updateConversationGroupProfile([s]);return o.setNetworkType(t.getNetworkType()).setMessage("groupID:".concat(a," type:").concat(s.type," muteAllMembers:").concat(s.muteAllMembers," ownerID:").concat(s.ownerID)).end(),ba({group:s})})).catch((function(a){return t.probeNetwork().then((function(t){var n=m(t,2),s=n[0],r=n[1];o.setError(a,s,r).setMessage("groupID:".concat(e.groupID)).end()})),we.error("".concat(n," failed. error:"),a),ja(a)}))}},{key:"getGroupProfileAdvance",value:function(e){var o=this,n="".concat(this._className,".getGroupProfileAdvance"),a=e.groupIDList;Qe(a)&&a.length>50&&(we.warn("".concat(n," 获取群资料的数量不能超过50个")),a.length=50);var s=[],r=[];a.forEach((function(e){Et({groupID:e})?r.push(e):s.push(e)}));var i=[];if(s.length>0){var c=this._getGroupProfileAdvance(t(t({},e),{},{groupIDList:s}));i.push(c)}if(r.length>0){var u=this._getGroupProfileAdvance(t(t({},e),{},{groupIDList:r,relayFlag:s.length>0}));i.push(u)}return Promise.all(i).then((function(e){var t=[],o=[];return e.forEach((function(e){t.push.apply(t,M(e.successGroupList)),o.push.apply(o,M(e.failureGroupList))})),ba({successGroupList:t,failureGroupList:o})})).catch((function(e){return we.error("".concat(o._className,"._getGroupProfileAdvance failed. error:"),e),ja(e)}))}},{key:"_getGroupProfileAdvance",value:function(e){var t=this,o=e.relayFlag,n=void 0!==o&&o,a=g(e,Ss);return this.request({protocolName:en,requestData:a}).then((function(e){we.log("".concat(t._className,"._getGroupProfileAdvance ok."));var o=e.data.groups;return{successGroupList:o.filter((function(e){return Ze(e.errorCode)||0===e.errorCode})),failureGroupList:o.filter((function(e){return e.errorCode&&0!==e.errorCode})).map((function(e){return new Ba({code:e.errorCode,message:e.errorInfo,data:{groupID:e.groupID}})}))}})).catch((function(t){return n&&Et({groupID:e.groupIDList[0]})?{successGroupList:[],failureGroupList:[]}:ja(t)}))}},{key:"createGroup",value:function(e){var o=this,n="".concat(this._className,".createGroup"),a=e.type,s=e.groupID;if(!["Public","Private","ChatRoom","AVChatRoom","Community"].includes(a))return ja({code:na.ILLEGAL_GROUP_TYPE,message:aa.ILLEGAL_GROUP_TYPE});if(!Et({type:a})){if(!Vt(s)&&Et({groupID:s}))return ja({code:na.ILLEGAL_GROUP_ID,message:aa.ILLEGAL_GROUP_ID});e.isSupportTopic=void 0}if(It(a)&&!Ze(e.memberList)&&e.memberList.length>0&&(we.warn("".concat(n," 创建 AVChatRoom 时不能添加群成员,自动忽略该字段")),e.memberList=void 0),yt(a)||Ze(e.joinOption)||(we.warn("".concat(n," 创建 Work/Meeting/AVChatRoom/Community 群时不能设置字段 joinOption,自动忽略该字段")),e.joinOption=void 0),Et({type:a})){if(!Vt(s)&&!Et({groupID:s}))return ja({code:na.ILLEGAL_GROUP_ID,message:aa.ILLEGAL_GROUP_ID});e.isSupportTopic=!0===e.isSupportTopic?1:0}var r=new va(ya.CREATE_GROUP);we.log("".concat(n," options:"),e);var i=[];return this.request({protocolName:tn,requestData:t(t({},e),{},{ownerID:this.getMyUserID(),webPushFlag:1})}).then((function(a){var s=a.data,c=s.groupID,u=s.overLimitUserIDList,l=void 0===u?[]:u;if(i=l,r.setNetworkType(o.getNetworkType()).setMessage("groupType:".concat(e.type," groupID:").concat(c," overLimitUserIDList=").concat(l)).end(),we.log("".concat(n," ok groupID:").concat(c," overLimitUserIDList:"),l),e.type===D.GRP_AVCHATROOM)return o.getGroupProfile({groupID:c});if(e.type===D.GRP_COMMUNITY&&1===e.isSupportTopic)return o.getGroupProfile({groupID:c});Vt(e.memberList)||Vt(l)||(e.memberList=e.memberList.filter((function(e){return-1===l.indexOf(e.userID)}))),o.updateGroupMap([t(t({},e),{},{groupID:c})]);var d=o.getModule(to),p=d.createCustomMessage({to:c,conversationType:D.CONV_GROUP,payload:{data:"group_create",extension:"".concat(o.getMyUserID(),"创建群组")}});return d.sendMessageInstance(p),o.emitGroupListUpdate(),o.getGroupProfile({groupID:c})})).then((function(e){var t=e.data.group,o=t.selfInfo,n=o.nameCard,a=o.joinTime;return t.updateSelfInfo({nameCard:n,joinTime:a,messageRemindType:D.MSG_REMIND_ACPT_AND_NOTE,role:D.GRP_MBR_ROLE_OWNER}),ba({group:t,overLimitUserIDList:i})})).catch((function(t){return r.setMessage("groupType:".concat(e.type)),o.probeNetwork().then((function(e){var o=m(e,2),n=o[0],a=o[1];r.setError(t,n,a).end()})),we.error("".concat(n," failed. error:"),t),ja(t)}))}},{key:"dismissGroup",value:function(e){var t=this,o="".concat(this._className,".dismissGroup");if(this.hasLocalGroup(e)&&this.getLocalGroupProfile(e).type===D.GRP_WORK)return ja(new Ba({code:na.CANNOT_DISMISS_WORK,message:aa.CANNOT_DISMISS_WORK}));var n=new va(ya.DISMISS_GROUP);return n.setMessage("groupID:".concat(e)),we.log("".concat(o," groupID:").concat(e)),this.request({protocolName:on,requestData:{groupID:e}}).then((function(){return n.setNetworkType(t.getNetworkType()).end(),we.log("".concat(o," ok")),t.deleteLocalGroupAndConversation(e),t.checkJoinedAVChatRoomByID(e)&&t._AVChatRoomHandler.reset(e),ba({groupID:e})})).catch((function(e){return t.probeNetwork().then((function(t){var o=m(t,2),a=o[0],s=o[1];n.setError(e,a,s).end()})),we.error("".concat(o," failed. error:"),e),ja(e)}))}},{key:"updateGroupProfile",value:function(e){var t=this,o="".concat(this._className,".updateGroupProfile");!this.hasLocalGroup(e.groupID)||yt(this.getLocalGroupProfile(e.groupID).type)||Ze(e.joinOption)||(we.warn("".concat(o," Work/Meeting/AVChatRoom/Community 群不能设置字段 joinOption,自动忽略该字段")),e.joinOption=void 0),Ze(e.muteAllMembers)||(e.muteAllMembers?e.muteAllMembers="On":e.muteAllMembers="Off");var n=new va(ya.UPDATE_GROUP_PROFILE);return n.setMessage(JSON.stringify(e)),we.log("".concat(o," groupID:").concat(e.groupID)),this.request({protocolName:nn,requestData:e}).then((function(){(n.setNetworkType(t.getNetworkType()).end(),we.log("".concat(o," ok")),t.hasLocalGroup(e.groupID))&&(t.groupMap.get(e.groupID).updateGroup(e),t._setStorageGroupList());return ba({group:t.groupMap.get(e.groupID)})})).catch((function(e){return t.probeNetwork().then((function(t){var o=m(t,2),a=o[0],s=o[1];n.setError(e,a,s).end()})),we.log("".concat(o," failed. error:"),e),ja(e)}))}},{key:"joinGroup",value:function(e){var t=this,o=e.groupID,n=e.type,a="".concat(this._className,".joinGroup");if(n===D.GRP_WORK){var s=new Ba({code:na.CANNOT_JOIN_WORK,message:aa.CANNOT_JOIN_WORK});return ja(s)}if(this.deleteUnjoinedAVChatRoom(o),this.hasLocalGroup(o)){if(!this.isLoggedIn())return Ya({status:D.JOIN_STATUS_ALREADY_IN_GROUP});var r=new va(ya.APPLY_JOIN_GROUP);return this.getGroupProfile({groupID:o}).then((function(){return r.setNetworkType(t.getNetworkType()).setMessage("groupID:".concat(o," joinedStatus:").concat(D.JOIN_STATUS_ALREADY_IN_GROUP)).end(),Ya({status:D.JOIN_STATUS_ALREADY_IN_GROUP})})).catch((function(n){return r.setNetworkType(t.getNetworkType()).setMessage("groupID:".concat(o," unjoined")).end(),we.warn("".concat(a," ").concat(o," was unjoined, now join!")),t.groupMap.delete(o),t.applyJoinGroup(e)}))}return we.log("".concat(a," groupID:").concat(o)),this.isLoggedIn()?this.applyJoinGroup(e):this._AVChatRoomHandler.joinWithoutAuth(e)}},{key:"applyJoinGroup",value:function(e){var o=this,n="".concat(this._className,".applyJoinGroup"),a=e.groupID,s=new va(ya.APPLY_JOIN_GROUP),r=t({},e),i=this.canIUse(B.AVCHATROOM_HISTORY_MSG);return i&&(r.historyMessageFlag=1),this.getModule(co).removeConversationMessageCache("".concat(D.CONV_GROUP).concat(a)),this.request({protocolName:an,requestData:r}).then((function(e){var t=e.data,r=t.joinedStatus,c=t.longPollingKey,u=t.avChatRoomFlag,l=t.avChatRoomKey,d=t.messageList,p="groupID:".concat(a," joinedStatus:").concat(r," longPollingKey:").concat(c)+" avChatRoomFlag:".concat(u," canGetAVChatRoomHistoryMessage:").concat(i,",")+" history message count:".concat(Vt(d)?0:d.length);switch(s.setNetworkType(o.getNetworkType()).setMessage("".concat(p)).end(),we.log("".concat(n," ok. ").concat(p)),r){case Be:return ba({status:Be});case He:return o.getGroupProfile({groupID:a}).then((function(e){var t,n=e.data.group,s={status:He,group:n};return 1===u?(o.getModule(co).setCompleted("".concat(D.CONV_GROUP).concat(a)),o._groupAttributesHandler.initGroupAttributesCache({groupID:a,avChatRoomKey:l}),(t=Ze(c)?o._AVChatRoomHandler.handleJoinResult({group:n}):o._AVChatRoomHandler.startRunLoop({longPollingKey:c,group:n})).then((function(){o._onAVChatRoomHistoryMessage(d)})),t):(o.emitGroupListUpdate(!0,!1),ba(s))}));default:var g=new Ba({code:na.JOIN_GROUP_FAIL,message:aa.JOIN_GROUP_FAIL});return we.error("".concat(n," error:"),g),ja(g)}})).catch((function(t){return s.setMessage("groupID:".concat(e.groupID)),o.probeNetwork().then((function(e){var o=m(e,2),n=o[0],a=o[1];s.setError(t,n,a).end()})),we.error("".concat(n," error:"),t),ja(t)}))}},{key:"quitGroup",value:function(e){var t=this,o="".concat(this._className,".quitGroup");we.log("".concat(o," groupID:").concat(e));var n=this.checkJoinedAVChatRoomByID(e);if(!n&&!this.hasLocalGroup(e)){var a=new Ba({code:na.MEMBER_NOT_IN_GROUP,message:aa.MEMBER_NOT_IN_GROUP});return ja(a)}if(n&&!this.isLoggedIn())return we.log("".concat(o," anonymously ok. groupID:").concat(e)),this.deleteLocalGroupAndConversation(e),this._AVChatRoomHandler.reset(e),Ya({groupID:e});var s=new va(ya.QUIT_GROUP);return s.setMessage("groupID:".concat(e)),this.request({protocolName:rn,requestData:{groupID:e}}).then((function(){return s.setNetworkType(t.getNetworkType()).end(),we.log("".concat(o," ok")),t.deleteLocalGroupAndConversation(e),n&&t._AVChatRoomHandler.reset(e),ba({groupID:e})})).catch((function(e){return t.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];s.setError(e,n,a).end()})),we.error("".concat(o," failed. error:"),e),ja(e)}))}},{key:"searchGroupByID",value:function(e){var t=this,o="".concat(this._className,".searchGroupByID"),n={groupIDList:[e]},a=new va(ya.SEARCH_GROUP_BY_ID);return a.setMessage("groupID:".concat(e)),we.log("".concat(o," groupID:").concat(e)),this.request({protocolName:cn,requestData:n}).then((function(e){var n=e.data.groupProfile;if(0!==n[0].errorCode)throw new Ba({code:n[0].errorCode,message:n[0].errorInfo});return a.setNetworkType(t.getNetworkType()).end(),we.log("".concat(o," ok")),ba({group:new ls(n[0])})})).catch((function(e){return t.probeNetwork().then((function(t){var o=m(t,2),n=o[0],s=o[1];a.setError(e,n,s).end()})),we.warn("".concat(o," failed. error:"),e),ja(e)}))}},{key:"changeGroupOwner",value:function(e){var t=this,o="".concat(this._className,".changeGroupOwner");if(this.hasLocalGroup(e.groupID)&&this.getLocalGroupProfile(e.groupID).type===D.GRP_AVCHATROOM)return ja(new Ba({code:na.CANNOT_CHANGE_OWNER_IN_AVCHATROOM,message:aa.CANNOT_CHANGE_OWNER_IN_AVCHATROOM}));if(e.newOwnerID===this.getMyUserID())return ja(new Ba({code:na.CANNOT_CHANGE_OWNER_TO_SELF,message:aa.CANNOT_CHANGE_OWNER_TO_SELF}));var n=new va(ya.CHANGE_GROUP_OWNER);return n.setMessage("groupID:".concat(e.groupID," newOwnerID:").concat(e.newOwnerID)),we.log("".concat(o," groupID:").concat(e.groupID)),this.request({protocolName:un,requestData:e}).then((function(){n.setNetworkType(t.getNetworkType()).end(),we.log("".concat(o," ok"));var a=e.groupID,s=e.newOwnerID;t.groupMap.get(a).ownerID=s;var r=t.getModule(ro).getLocalGroupMemberList(a);if(r instanceof Map){var i=r.get(t.getMyUserID());Ze(i)||(i.updateRole("Member"),t.groupMap.get(a).selfInfo.role="Member");var c=r.get(s);Ze(c)||c.updateRole("Owner")}return t.emitGroupListUpdate(!0,!1),ba({group:t.groupMap.get(a)})})).catch((function(e){return t.probeNetwork().then((function(t){var o=m(t,2),a=o[0],s=o[1];n.setError(e,a,s).end()})),we.error("".concat(o," failed. error:"),e),ja(e)}))}},{key:"handleGroupApplication",value:function(e){var o=this,n="".concat(this._className,".handleGroupApplication"),a=e.message.payload,s=a.groupProfile.groupID,r=a.authentication,i=a.messageKey,c=a.operatorID,u=new va(ya.HANDLE_GROUP_APPLICATION);return u.setMessage("groupID:".concat(s)),we.log("".concat(n," groupID:").concat(s)),this.request({protocolName:ln,requestData:t(t({},e),{},{applicant:c,groupID:s,authentication:r,messageKey:i})}).then((function(){return u.setNetworkType(o.getNetworkType()).end(),we.log("".concat(n," ok")),o._groupSystemNoticeHandler.deleteGroupSystemNotice({messageList:[e.message]}),ba({group:o.getLocalGroupProfile(s)})})).catch((function(e){return o.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];u.setError(e,n,a).end()})),we.error("".concat(n," failed. error"),e),ja(e)}))}},{key:"handleGroupInvitation",value:function(e){var o=this,n="".concat(this._className,".handleGroupInvitation"),a=e.message.payload,s=a.groupProfile.groupID,r=a.authentication,i=a.messageKey,c=a.operatorID,u=e.handleAction,l=new va(ya.HANDLE_GROUP_INVITATION);return l.setMessage("groupID:".concat(s," inviter:").concat(c," handleAction:").concat(u)),we.log("".concat(n," groupID:").concat(s," inviter:").concat(c," handleAction:").concat(u)),this.request({protocolName:dn,requestData:t(t({},e),{},{inviter:c,groupID:s,authentication:r,messageKey:i})}).then((function(){return l.setNetworkType(o.getNetworkType()).end(),we.log("".concat(n," ok")),o._groupSystemNoticeHandler.deleteGroupSystemNotice({messageList:[e.message]}),ba({group:o.getLocalGroupProfile(s)})})).catch((function(e){return o.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];l.setError(e,n,a).end()})),we.error("".concat(n," failed. error"),e),ja(e)}))}},{key:"getGroupOnlineMemberCount",value:function(e){return this._AVChatRoomHandler?this._AVChatRoomHandler.checkJoinedAVChatRoomByID(e)?this._AVChatRoomHandler.getGroupOnlineMemberCount(e):Ya({memberCount:0}):ja({code:na.CANNOT_FIND_MODULE,message:aa.CANNOT_FIND_MODULE})}},{key:"hasLocalGroup",value:function(e){return this.groupMap.has(e)}},{key:"deleteLocalGroupAndConversation",value:function(e){var t=this.checkJoinedAVChatRoomByID(e);(we.log("".concat(this._className,".deleteLocalGroupAndConversation isJoinedAVChatRoom:").concat(t)),t)&&this.getModule(co).deleteLocalConversation("GROUP".concat(e));this._deleteLocalGroup(e),this.emitGroupListUpdate(!0,!1)}},{key:"_deleteLocalGroup",value:function(e){this.groupMap.delete(e),this.getModule(ro).deleteGroupMemberList(e),this._setStorageGroupList()}},{key:"sendMessage",value:function(e,t){var o=this.createGroupMessagePack(e,t);return this.request(o)}},{key:"createGroupMessagePack",value:function(e,t){var o=null;t&&t.offlinePushInfo&&(o=t.offlinePushInfo);var n="";ze(e.cloudCustomData)&&e.cloudCustomData.length>0&&(n=e.cloudCustomData);var a=[];if(Xe(t)&&Xe(t.messageControlInfo)){var s=t.messageControlInfo,r=s.excludedFromUnreadCount,i=s.excludedFromLastMessage;!0===r&&a.push("NoUnread"),!0===i&&a.push("NoLastMsg")}var c=e.getGroupAtInfoList(),u={fromAccount:this.getMyUserID(),groupID:e.to,msgBody:e.getElements(),cloudCustomData:n,random:e.random,priority:e.priority,clientSequence:e.clientSequence,groupAtInfo:e.type!==D.MSG_TEXT||Vt(c)?void 0:c,onlineOnlyFlag:this.isOnlineMessage(e,t)?1:0,clientTime:e.clientTime,offlinePushInfo:o?{pushFlag:!0===o.disablePush?1:0,title:o.title||"",desc:o.description||"",ext:o.extension||"",apnsInfo:{badgeMode:!0===o.ignoreIOSBadge?1:0},androidInfo:{OPPOChannelID:o.androidOPPOChannelID||""}}:void 0,messageControlInfo:a,needReadReceipt:!0!==e.needReadReceipt||this.isMessageFromOrToAVChatroom(e.to)?0:1};return Tt(e.to)&&(u.groupID=bt(e.to),u.topicID=e.to),{protocolName:Po,tjgID:this.generateTjgID(e),requestData:u}}},{key:"revokeMessage",value:function(e){var t={groupID:e.to,msgSeqList:[{msgSeq:e.sequence}]};return Tt(e.to)&&(t.groupID=bt(e.to),t.topicID=e.to),this.request({protocolName:pn,requestData:t})}},{key:"deleteMessage",value:function(e){var t=e.to,o=e.keyList;we.log("".concat(this._className,".deleteMessage groupID:").concat(t," count:").concat(o.length));var n={groupID:t,deleter:this.getMyUserID(),keyList:o};return Tt(t)&&(n.groupID=bt(t),n.topicID=t),this.request({protocolName:Sn,requestData:n})}},{key:"modifyRemoteMessage",value:function(e){var t=e.to,o=e.sequence,n=e.payload,a=e.type,s=e.version,r=void 0===s?0:s,i=e.cloudCustomData,c=t,u=void 0;return Tt(t)&&(c=bt(t),u=t),this.request({protocolName:Dn,requestData:{groupID:c,topicID:u,sequence:o,version:r,elements:[{type:a,content:n}],cloudCustomData:i}})}},{key:"getRoamingMessage",value:function(e){var t=this,o="".concat(this._className,".getRoamingMessage"),n=e.conversationID,a=e.groupID,s=e.sequence,r=new va(ya.GET_GROUP_ROAMING_MESSAGES),i=0,c=void 0;return Tt(a)&&(a=bt(c=a)),this._computeLastSequence({groupID:a,topicID:c,sequence:s}).then((function(e){return i=e,we.log("".concat(o," groupID:").concat(a," startSequence:").concat(i)),t.request({protocolName:hn,requestData:{groupID:a,count:21,sequence:i,topicID:c}})})).then((function(e){var s=e.data,u=s.messageList,l=s.complete;Ze(u)?we.log("".concat(o," ok. complete:").concat(l," but messageList is undefined!")):we.log("".concat(o," ok. complete:").concat(l," count:").concat(u.length)),r.setNetworkType(t.getNetworkType()).setMessage("groupID:".concat(a," topicID:").concat(c," startSequence:").concat(i," complete:").concat(l," count:").concat(u?u.length:"undefined")).end();var d=t.getModule(co);if(2===l||Vt(u))return d.setCompleted(n),{nextReqID:"",storedMessageList:[]};var p=u[u.length-1].sequence-1;d.updateRoamingMessageSequence(n,p);var g=d.onRoamingMessage(u,n);return d.updateIsRead(n),d.patchConversationLastMessage(n),we.log("".concat(o," nextReqID:").concat(p," stored message count:").concat(g.length)),{nextReqID:p+"",storedMessageList:g}})).catch((function(e){return t.probeNetwork().then((function(t){var o=m(t,2),n=o[0],s=o[1];r.setError(e,n,s).setMessage("groupID:".concat(a," topicID:").concat(c," startSequence:").concat(i)).end()})),we.warn("".concat(o," failed. error:"),e),ja(e)}))}},{key:"_getGroupIDOfMessage",value:function(e){return e.conversationID.replace(D.CONV_GROUP,"")}},{key:"getReadReceiptList",value:function(e){var t=this,o="".concat(this._className,".getReadReceiptList"),n=this._getGroupIDOfMessage(e[0]),a=this.getMyUserID(),s=e.filter((function(e){return e.from===a&&!0===e.needReadReceipt})).map((function(e){return{sequence:e.sequence}}));if(we.log("".concat(o," groupID:").concat(n," sequenceList:").concat(JSON.stringify(s))),0===s.length)return Ya({messageList:e});var r=new va(ya.GET_READ_RECEIPT);return r.setMessage("groupID:".concat(n)),this.request({protocolName:fn,requestData:{groupID:n,sequenceList:s}}).then((function(t){r.end(),we.log("".concat(o," ok"));var n=t.data.readReceiptList;return Qe(n)&&n.forEach((function(t){e.forEach((function(e){0===t.code&&t.sequence===e.sequence&&(e.readReceiptInfo.readCount=t.readCount,e.readReceiptInfo.unreadCount=t.unreadCount)}))})),ba({messageList:e})})).catch((function(e){return t.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];r.setError(e,n,a).end()})),we.warn("".concat(o," failed. error:"),e),ja(e)}))}},{key:"sendReadReceipt",value:function(e){var t=this,o=this._getGroupIDOfMessage(e[0]),n=new va(ya.SEND_READ_RECEIPT);n.setMessage("groupID:".concat(o));var a=this.getMyUserID(),s=e.filter((function(e){return e.from!==a&&!0===e.needReadReceipt})).map((function(e){return{sequence:e.sequence}}));if(0===s.length)return ja({code:na.READ_RECEIPT_MESSAGE_LIST_EMPTY,message:aa.READ_RECEIPT_MESSAGE_LIST_EMPTY});var r="".concat(this._className,".sendReadReceipt");return we.log("".concat(r,". sequenceList:").concat(JSON.stringify(s))),this.request({protocolName:mn,requestData:{groupID:o,sequenceList:s}}).then((function(e){return n.end(),we.log("".concat(r," ok")),ba()})).catch((function(e){return t.probeNetwork().then((function(t){var o=m(t,2),a=o[0],s=o[1];n.setError(e,a,s).end()})),we.warn("".concat(r," failed. error:"),e),ja(e)}))}},{key:"getReadReceiptDetail",value:function(e){var t=this,o=e.message,n=e.filter,a=e.cursor,s=e.count,r=this._getGroupIDOfMessage(o),i=o.ID,c=o.sequence,u="".concat(this._className,".getReadReceiptDetail"),l=this._receiptDetailCompleteMap.get(i)||!1,d=0!==n&&1!==n?0:n,p=ze(a)?a:"",g=!$e(s)||s<=0||s>=100?100:s,_="groupID:".concat(r," sequence:").concat(c," cursor:").concat(p," filter:").concat(d," completeFlag:").concat(l);we.log("".concat(u," ").concat(_));var h={cursor:"",isCompleted:!1,messageID:i,unreadUserIDList:[],readUserIDList:[]},f=new va(ya.GET_READ_RECEIPT_DETAIL);return f.setMessage(_),this.request({protocolName:vn,requestData:{groupID:r,sequence:c,flag:d,cursor:p,count:g}}).then((function(e){f.end();var o=e.data,n=o.cursor,a=o.isCompleted,s=o.unreadUserIDList,r=o.readUserIDList;return h.cursor=n,1===a&&(h.isCompleted=!0,t._receiptDetailCompleteMap.set(i,!0)),0===d?h.readUserIDList=r.map((function(e){return e.userID})):1===d&&(h.unreadUserIDList=s.map((function(e){return e.userID}))),we.log("".concat(u," ok")),ba(h)})).catch((function(e){return t.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];f.setError(e,n,a).end()})),we.warn("".concat(u," failed. error:"),e),ja(e)}))}},{key:"getRoamingMessagesHopping",value:function(e){var t=this,o="".concat(this._className,".getRoamingMessagesHopping"),n=new va(ya.GET_GROUP_ROAMING_MESSAGES_HOPPING),a=e.groupID,s=e.count,r=e.sequence,i=void 0;return Tt(a)&&(a=bt(i=a)),this.request({protocolName:hn,requestData:{groupID:a,count:s,sequence:r,topicID:i}}).then((function(s){var c=s.data,u=c.messageList,l=c.complete,d="groupID:".concat(a," topicID:").concat(i," sequence:").concat(r," complete:").concat(l," count:").concat(u?u.length:0);if(we.log("".concat(o," ok. ").concat(d)),n.setNetworkType(t.getNetworkType()).setMessage("".concat(d)).end(),2===l||Vt(u))return[];var p="".concat(D.CONV_GROUP).concat(e.groupID);return t.getModule(co).onRoamingMessage(u,p,!1)})).catch((function(e){return t.probeNetwork().then((function(t){var o=m(t,2),i=o[0],c=o[1];n.setError(e,i,c).setMessage("groupID:".concat(a," sequence:").concat(r," count:").concat(s)).end()})),we.warn("".concat(o," failed. error:"),e),ja(e)}))}},{key:"setMessageRead",value:function(e){var t=this,o=e.conversationID,n=e.lastMessageSeq,a="".concat(this._className,".setMessageRead");we.log("".concat(a," conversationID:").concat(o," lastMessageSeq:").concat(n)),$e(n)||we.warn("".concat(a," 请勿修改 Conversation.lastMessage.lastSequence,否则可能会导致已读上报结果不准确"));var s=new va(ya.SET_GROUP_MESSAGE_READ);s.setMessage("".concat(o,"-").concat(n));var r=o.replace(D.CONV_GROUP,""),i=void 0;return Tt(r)&&(r=bt(i=r)),this.request({protocolName:gn,requestData:{groupID:r,topicID:i,messageReadSeq:n}}).then((function(){s.setNetworkType(t.getNetworkType()).end(),we.log("".concat(a," ok."));var e=t.getModule(co);e.updateIsReadAfterReadReport({conversationID:o,lastMessageSeq:n});var c=!0;if(!Ze(i)){c=!1;var u=t.getModule(io).getLocalTopic(r,i);u&&u.updateSelfInfo({readedSequence:n})}return e.updateUnreadCount(o,c),ba()})).catch((function(e){return t.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];s.setError(e,n,a).end()})),we.log("".concat(a," failed. error:"),e),ja(e)}))}},{key:"_computeLastSequence",value:function(e){var t=e.groupID,o=e.topicID,n=void 0===o?void 0:o,a=e.sequence;return a>0?Promise.resolve(a):Ze(n)||this.hasLocalGroup(t)?Ze(n)?this.getGroupLastSequence(t):this.getTopicLastSequence({groupID:t,topicID:n}):Promise.resolve(0)}},{key:"getGroupLastSequence",value:function(e){var t=this,o="".concat(this._className,".getGroupLastSequence"),n=new va(ya.GET_GROUP_LAST_SEQUENCE),a=0,s="";if(this.hasLocalGroup(e)){var r=this.getLocalGroupProfile(e),i=r.lastMessage;if(i.lastSequence>0&&!1===i.onlineOnlyFlag)return a=i.lastSequence,s="got lastSequence:".concat(a," from local group profile[lastMessage.lastSequence]. groupID:").concat(e),we.log("".concat(o," ").concat(s)),n.setNetworkType(this.getNetworkType()).setMessage("".concat(s)).end(),Promise.resolve(a);if(r.nextMessageSeq>1)return a=r.nextMessageSeq-1,s="got lastSequence:".concat(a," from local group profile[nextMessageSeq]. groupID:").concat(e),we.log("".concat(o," ").concat(s)),n.setNetworkType(this.getNetworkType()).setMessage("".concat(s)).end(),Promise.resolve(a)}var c="GROUP".concat(e),u=this.getModule(co).getLocalConversation(c);if(u&&u.lastMessage.lastSequence&&!1===u.lastMessage.onlineOnlyFlag)return a=u.lastMessage.lastSequence,s="got lastSequence:".concat(a," from local conversation profile[lastMessage.lastSequence]. groupID:").concat(e),we.log("".concat(o," ").concat(s)),n.setNetworkType(this.getNetworkType()).setMessage("".concat(s)).end(),Promise.resolve(a);var l={groupIDList:[e],responseFilter:{groupBaseInfoFilter:["NextMsgSeq"]}};return this.getGroupProfileAdvance(l).then((function(r){var i=r.data.successGroupList;return Vt(i)?we.log("".concat(o," successGroupList is empty. groupID:").concat(e)):(a=i[0].nextMessageSeq-1,s="got lastSequence:".concat(a," from getGroupProfileAdvance. groupID:").concat(e),we.log("".concat(o," ").concat(s))),n.setNetworkType(t.getNetworkType()).setMessage("".concat(s)).end(),a})).catch((function(a){return t.probeNetwork().then((function(t){var o=m(t,2),s=o[0],r=o[1];n.setError(a,s,r).setMessage("get lastSequence failed from getGroupProfileAdvance. groupID:".concat(e)).end()})),we.warn("".concat(o," failed. error:"),a),ja(a)}))}},{key:"getTopicLastSequence",value:function(e){var t=this,o=e.groupID,n=e.topicID,a="".concat(this._className,".getTopicLastSequence"),s=new va(ya.GET_TOPIC_LAST_SEQUENCE),r=0,i="",c=this.getModule(io);return c.hasLocalTopic(o,n)?(r=c.getLocalTopic(o,n).nextMessageSeq-1,i="get lastSequence:".concat(r," from local topic info[nextMessageSeq]. topicID:").concat(n),we.log("".concat(a," ").concat(i)),s.setNetworkType(this.getNetworkType()).setMessage("".concat(i)).end(),Promise.resolve(r)):c.getTopicList({groupID:o,topicIDList:[n]}).then((function(e){var o=e.data.successTopicList;return Vt(o)?we.log("".concat(a," successTopicList is empty. topicID:").concat(n)):(r=o[0].nextMessageSeq-1,i="get lastSequence:".concat(r," from getTopicList. topicID:").concat(n),we.log("".concat(a," ").concat(i))),s.setNetworkType(t.getNetworkType()).setMessage("".concat(i)).end(),r})).catch((function(e){return t.probeNetwork().then((function(t){var o=m(t,2),a=o[0],r=o[1];s.setError(e,a,r).setMessage("get lastSequence failed from getTopicList. topicID:".concat(n)).end()})),we.warn("".concat(a," failed. error:"),e),ja(e)}))}},{key:"isMessageFromOrToAVChatroom",value:function(e){return!!this._AVChatRoomHandler&&this._AVChatRoomHandler.checkJoinedAVChatRoomByID(e)}},{key:"hasJoinedAVChatRoom",value:function(){return this._AVChatRoomHandler?this._AVChatRoomHandler.hasJoinedAVChatRoom():0}},{key:"getJoinedAVChatRoom",value:function(){return this._AVChatRoomHandler?this._AVChatRoomHandler.getJoinedAVChatRoom():[]}},{key:"isOnlineMessage",value:function(e,t){return!(!this._canIUseOnlineOnlyFlag(e)||!t||!0!==t.onlineUserOnly)}},{key:"_canIUseOnlineOnlyFlag",value:function(e){var t=this.getJoinedAVChatRoom();return!t||!t.includes(e.to)||e.conversationType!==D.CONV_GROUP}},{key:"_onAVChatRoomHistoryMessage",value:function(e){if(!Vt(e)){we.log("".concat(this._className,"._onAVChatRoomHistoryMessage count:").concat(e.length));var o=[];e.forEach((function(e){o.push(t(t({},e),{},{isHistoryMessage:1}))})),this.onAVChatRoomMessage(o)}}},{key:"onAVChatRoomMessage",value:function(e){this._AVChatRoomHandler&&this._AVChatRoomHandler.onMessage(e)}},{key:"getGroupSimplifiedInfo",value:function(e){var t=this,o=new va(ya.GET_GROUP_SIMPLIFIED_INFO),n={groupIDList:[e],responseFilter:{groupBaseInfoFilter:["Type","Name"]}};return this.getGroupProfileAdvance(n).then((function(n){var a=n.data.successGroupList;return o.setNetworkType(t.getNetworkType()).setMessage("groupID:".concat(e," type:").concat(a[0].type)).end(),a[0]})).catch((function(n){t.probeNetwork().then((function(t){var a=m(t,2),s=a[0],r=a[1];o.setError(n,s,r).setMessage("groupID:".concat(e)).end()}))}))}},{key:"setUnjoinedAVChatRoom",value:function(e){this._unjoinedAVChatRoomList.set(e,1)}},{key:"deleteUnjoinedAVChatRoom",value:function(e){this._unjoinedAVChatRoomList.has(e)&&this._unjoinedAVChatRoomList.delete(e)}},{key:"isUnjoinedAVChatRoom",value:function(e){return this._unjoinedAVChatRoomList.has(e)}},{key:"onGroupAttributesUpdated",value:function(e){this._groupAttributesHandler&&this._groupAttributesHandler.onGroupAttributesUpdated(e)}},{key:"updateLocalMainSequenceOnReconnected",value:function(){this._groupAttributesHandler&&this._groupAttributesHandler.updateLocalMainSequenceOnReconnected()}},{key:"initGroupAttributes",value:function(e){return this._groupAttributesHandler.initGroupAttributes(e)}},{key:"setGroupAttributes",value:function(e){return this._groupAttributesHandler.setGroupAttributes(e)}},{key:"deleteGroupAttributes",value:function(e){return this._groupAttributesHandler.deleteGroupAttributes(e)}},{key:"getGroupAttributes",value:function(e){return this._groupAttributesHandler.getGroupAttributes(e)}},{key:"reset",value:function(){this.groupMap.clear(),this._unjoinedAVChatRoomList.clear(),this._receiptDetailCompleteMap.clear(),this._commonGroupHandler.reset(),this._groupSystemNoticeHandler.reset(),this._groupTipsHandler.reset(),this._AVChatRoomHandler&&this._AVChatRoomHandler.reset()}}]),a}(Do),Ns=function(){function e(t){n(this,e),this.userID="",this.avatar="",this.nick="",this.role="",this.joinTime="",this.lastSendMsgTime="",this.nameCard="",this.muteUntil=0,this.memberCustomField=[],this._initMember(t)}return s(e,[{key:"_initMember",value:function(e){this.updateMember(e)}},{key:"updateMember",value:function(e){var t=[null,void 0,"",0,NaN];e.memberCustomField&&vt(this.memberCustomField,e.memberCustomField),ct(this,e,["memberCustomField"],t)}},{key:"updateRole",value:function(e){["Owner","Admin","Member"].indexOf(e)<0||(this.role=e)}},{key:"updateMuteUntil",value:function(e){Ze(e)||(this.muteUntil=Math.floor((Date.now()+1e3*e)/1e3))}},{key:"updateNameCard",value:function(e){Ze(e)||(this.nameCard=e)}},{key:"updateMemberCustomField",value:function(e){e&&vt(this.memberCustomField,e)}}]),e}(),As=function(e){i(a,e);var o=f(a);function a(e){var t;return n(this,a),(t=o.call(this,e))._className="GroupMemberModule",t.groupMemberListMap=new Map,t.getInnerEmitterInstance().on(Qa,t._onProfileUpdated,_(t)),t}return s(a,[{key:"_onProfileUpdated",value:function(e){for(var t=this,o=e.data,n=function(e){var n=o[e];t.groupMemberListMap.forEach((function(e){e.has(n.userID)&&e.get(n.userID).updateMember({nick:n.nick,avatar:n.avatar})}))},a=0;a100?100:r};Et({groupID:o})?d.next="".concat(a):(d.offset=a,l=a+1);var p=[];return this.request({protocolName:kn,requestData:d}).then((function(e){var n=e.data,a=n.members,s=n.memberNum,r=n.next,i=void 0===r?void 0:r;if(Ze(i)||(l=Vt(i)?0:i),!Qe(a)||0===a.length)return l=0,Promise.resolve([]);var c=t.getModule(ao);return c.hasLocalGroup(o)&&(c.getLocalGroupProfile(o).memberNum=s),p=t._updateLocalGroupMemberMap(o,a),t.getModule(oo).getUserProfile({userIDList:a.map((function(e){return e.userID})),tagList:[Fe.NICK,Fe.AVATAR]})})).then((function(e){var n=e.data;if(!Qe(n)||0===n.length)return Ya({memberList:[],offset:l});var a=n.map((function(e){return{userID:e.userID,nick:e.nick,avatar:e.avatar}}));return t._updateLocalGroupMemberMap(o,a),u.setNetworkType(t.getNetworkType()).setMessage("groupID:".concat(o," offset:").concat(l," count:").concat(r)).end(),we.log("".concat(i," ok.")),ba({memberList:p,offset:l})})).catch((function(e){return t.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];u.setError(e,n,a).end()})),we.error("".concat(i," failed. error:"),e),ja(e)}))}},{key:"getGroupMemberProfile",value:function(e){var o=this,n="".concat(this._className,".getGroupMemberProfile"),a=new va(ya.GET_GROUP_MEMBER_PROFILE);a.setMessage(e.userIDList.length>5?"userIDList.length:".concat(e.userIDList.length):"userIDList:".concat(e.userIDList)),we.log("".concat(n," groupID:").concat(e.groupID," userIDList:").concat(e.userIDList.join(","))),e.userIDList.length>50&&(e.userIDList=e.userIDList.slice(0,50));var s=e.groupID,r=e.userIDList;return this._getGroupMemberProfileAdvance(t(t({},e),{},{userIDList:r})).then((function(e){var t=e.data.members;return Qe(t)&&0!==t.length?(o._updateLocalGroupMemberMap(s,t),o.getModule(oo).getUserProfile({userIDList:t.map((function(e){return e.userID})),tagList:[Fe.NICK,Fe.AVATAR]})):Ya([])})).then((function(e){var t=e.data.map((function(e){return{userID:e.userID,nick:e.nick,avatar:e.avatar}}));o._updateLocalGroupMemberMap(s,t);var n=r.filter((function(e){return o.hasLocalGroupMember(s,e)})).map((function(e){return o.getLocalGroupMemberInfo(s,e)}));return a.setNetworkType(o.getNetworkType()).end(),ba({memberList:n})}))}},{key:"addGroupMember",value:function(e){var t=this,o="".concat(this._className,".addGroupMember"),n=e.groupID,a=this.getModule(ao).getLocalGroupProfile(n),s=a.type,r=new va(ya.ADD_GROUP_MEMBER);if(r.setMessage("groupID:".concat(n," groupType:").concat(s)),It(s)){var i=new Ba({code:na.CANNOT_ADD_MEMBER_IN_AVCHATROOM,message:aa.CANNOT_ADD_MEMBER_IN_AVCHATROOM});return r.setCode(na.CANNOT_ADD_MEMBER_IN_AVCHATROOM).setError(aa.CANNOT_ADD_MEMBER_IN_AVCHATROOM).setNetworkType(this.getNetworkType()).end(),ja(i)}return e.userIDList=e.userIDList.map((function(e){return{userID:e}})),we.log("".concat(o," groupID:").concat(n)),this.request({protocolName:Pn,requestData:e}).then((function(n){var s=n.data.members;we.log("".concat(o," ok"));var i=s.filter((function(e){return 1===e.result})).map((function(e){return e.userID})),c=s.filter((function(e){return 0===e.result})).map((function(e){return e.userID})),u=s.filter((function(e){return 2===e.result})).map((function(e){return e.userID})),l=s.filter((function(e){return 4===e.result})).map((function(e){return e.userID})),d="groupID:".concat(e.groupID,", ")+"successUserIDList:".concat(i,", ")+"failureUserIDList:".concat(c,", ")+"existedUserIDList:".concat(u,", ")+"overLimitUserIDList:".concat(l);return r.setNetworkType(t.getNetworkType()).setMoreMessage(d).end(),0===i.length?ba({successUserIDList:i,failureUserIDList:c,existedUserIDList:u,overLimitUserIDList:l}):(a.memberCount+=i.length,t._updateConversationGroupProfile(a),ba({successUserIDList:i,failureUserIDList:c,existedUserIDList:u,overLimitUserIDList:l,group:a}))})).catch((function(e){return t.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];r.setError(e,n,a).end()})),we.error("".concat(o," failed. error:"),e),ja(e)}))}},{key:"deleteGroupMember",value:function(e){var t=this,o="".concat(this._className,".deleteGroupMember"),n=e.groupID,a=e.userIDList,s=new va(ya.DELETE_GROUP_MEMBER),r="groupID:".concat(n," ").concat(a.length>5?"userIDList.length:".concat(a.length):"userIDList:".concat(a));s.setMessage(r),we.log("".concat(o," groupID:").concat(n," userIDList:"),a);var i=this.getModule(ao).getLocalGroupProfile(n);return It(i.type)?ja(new Ba({code:na.CANNOT_KICK_MEMBER_IN_AVCHATROOM,message:aa.CANNOT_KICK_MEMBER_IN_AVCHATROOM})):this.request({protocolName:Un,requestData:e}).then((function(){return s.setNetworkType(t.getNetworkType()).end(),we.log("".concat(o," ok")),i.memberCount-=1,t._updateConversationGroupProfile(i),t.deleteLocalGroupMembers(n,a),ba({group:i,userIDList:a})})).catch((function(e){return t.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];s.setError(e,n,a).end()})),we.error("".concat(o," failed. error:"),e),ja(e)}))}},{key:"_updateConversationGroupProfile",value:function(e){this.getModule(co).updateConversationGroupProfile([e])}},{key:"setGroupMemberMuteTime",value:function(e){var t=this,o=e.groupID,n=e.userID,a=e.muteTime,s="".concat(this._className,".setGroupMemberMuteTime");if(n===this.getMyUserID())return ja(new Ba({code:na.CANNOT_MUTE_SELF,message:aa.CANNOT_MUTE_SELF}));we.log("".concat(s," groupID:").concat(o," userID:").concat(n));var r=new va(ya.SET_GROUP_MEMBER_MUTE_TIME);return r.setMessage("groupID:".concat(o," userID:").concat(n," muteTime:").concat(a)),this.modifyGroupMemberInfo({groupID:o,userID:n,muteTime:a}).then((function(e){r.setNetworkType(t.getNetworkType()).end(),we.log("".concat(s," ok"));var n=t.getModule(ao);return ba({group:n.getLocalGroupProfile(o),member:e})})).catch((function(e){return t.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];r.setError(e,n,a).end()})),we.error("".concat(s," failed. error:"),e),ja(e)}))}},{key:"setGroupMemberRole",value:function(e){var t=this,o="".concat(this._className,".setGroupMemberRole"),n=e.groupID,a=e.userID,s=e.role,r=this.getModule(ao).getLocalGroupProfile(n);if(r.selfInfo.role!==D.GRP_MBR_ROLE_OWNER)return ja({code:na.NOT_OWNER,message:aa.NOT_OWNER});if([D.GRP_WORK,D.GRP_AVCHATROOM].includes(r.type))return ja({code:na.CANNOT_SET_MEMBER_ROLE_IN_WORK_AND_AVCHATROOM,message:aa.CANNOT_SET_MEMBER_ROLE_IN_WORK_AND_AVCHATROOM});var i=[D.GRP_MBR_ROLE_ADMIN,D.GRP_MBR_ROLE_MEMBER];if(Et({groupID:n})&&i.push(D.GRP_MBR_ROLE_CUSTOM),i.indexOf(s)<0)return ja({code:na.INVALID_MEMBER_ROLE,message:aa.INVALID_MEMBER_ROLE});if(a===this.getMyUserID())return ja({code:na.CANNOT_SET_SELF_MEMBER_ROLE,message:aa.CANNOT_SET_SELF_MEMBER_ROLE});var c=new va(ya.SET_GROUP_MEMBER_ROLE);return c.setMessage("groupID:".concat(n," userID:").concat(a," role:").concat(s)),we.log("".concat(o," groupID:").concat(n," userID:").concat(a)),this.modifyGroupMemberInfo({groupID:n,userID:a,role:s}).then((function(e){return c.setNetworkType(t.getNetworkType()).end(),we.log("".concat(o," ok")),ba({group:r,member:e})})).catch((function(e){return t.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];c.setError(e,n,a).end()})),we.error("".concat(o," failed. error:"),e),ja(e)}))}},{key:"setGroupMemberNameCard",value:function(e){var t=this,o="".concat(this._className,".setGroupMemberNameCard"),n=e.groupID,a=e.userID,s=void 0===a?this.getMyUserID():a,r=e.nameCard;we.log("".concat(o," groupID:").concat(n," userID:").concat(s));var i=new va(ya.SET_GROUP_MEMBER_NAME_CARD);return i.setMessage("groupID:".concat(n," userID:").concat(s," nameCard:").concat(r)),this.modifyGroupMemberInfo({groupID:n,userID:s,nameCard:r}).then((function(e){we.log("".concat(o," ok")),i.setNetworkType(t.getNetworkType()).end();var a=t.getModule(ao).getLocalGroupProfile(n);return s===t.getMyUserID()&&a&&a.setSelfNameCard(r),ba({group:a,member:e})})).catch((function(e){return t.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];i.setError(e,n,a).end()})),we.error("".concat(o," failed. error:"),e),ja(e)}))}},{key:"setGroupMemberCustomField",value:function(e){var t=this,o="".concat(this._className,".setGroupMemberCustomField"),n=e.groupID,a=e.userID,s=void 0===a?this.getMyUserID():a,r=e.memberCustomField;we.log("".concat(o," groupID:").concat(n," userID:").concat(s));var i=new va(ya.SET_GROUP_MEMBER_CUSTOM_FIELD);return i.setMessage("groupID:".concat(n," userID:").concat(s," memberCustomField:").concat(JSON.stringify(r))),this.modifyGroupMemberInfo({groupID:n,userID:s,memberCustomField:r}).then((function(e){i.setNetworkType(t.getNetworkType()).end(),we.log("".concat(o," ok"));var a=t.getModule(ao).getLocalGroupProfile(n);return ba({group:a,member:e})})).catch((function(e){return t.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];i.setError(e,n,a).end()})),we.error("".concat(o," failed. error:"),e),ja(e)}))}},{key:"modifyGroupMemberInfo",value:function(e){var o=this,n=e.groupID,a=e.userID,s=void 0;return Tt(n)&&(n=bt(s=n)),this.request({protocolName:wn,requestData:t(t({},e),{},{groupID:n,topicID:s})}).then((function(){if(o.hasLocalGroupMember(n,a)){var t=o.getLocalGroupMemberInfo(n,a);return Ze(e.muteTime)||t.updateMuteUntil(e.muteTime),Ze(e.role)||t.updateRole(e.role),Ze(e.nameCard)||t.updateNameCard(e.nameCard),Ze(e.memberCustomField)||t.updateMemberCustomField(e.memberCustomField),t}return o.getGroupMemberProfile({groupID:n,userIDList:[a]}).then((function(e){return m(e.data.memberList,1)[0]}))}))}},{key:"_getGroupMemberProfileAdvance",value:function(e){return this.request({protocolName:Gn,requestData:t(t({},e),{},{memberInfoFilter:e.memberInfoFilter?e.memberInfoFilter:["Role","JoinTime","NameCard","ShutUpUntil"]})})}},{key:"_updateLocalGroupMemberMap",value:function(e,t){var o=this;return Qe(t)&&0!==t.length?t.map((function(t){return o.hasLocalGroupMember(e,t.userID)?o.getLocalGroupMemberInfo(e,t.userID).updateMember(t):o.setLocalGroupMember(e,new Ns(t)),o.getLocalGroupMemberInfo(e,t.userID)})):[]}},{key:"deleteLocalGroupMembers",value:function(e,t){var o=this.groupMemberListMap.get(e);o&&t.forEach((function(e){o.delete(e)}))}},{key:"getLocalGroupMemberInfo",value:function(e,t){return this.groupMemberListMap.has(e)?this.groupMemberListMap.get(e).get(t):null}},{key:"setLocalGroupMember",value:function(e,t){if(this.groupMemberListMap.has(e))this.groupMemberListMap.get(e).set(t.userID,t);else{var o=(new Map).set(t.userID,t);this.groupMemberListMap.set(e,o)}}},{key:"getLocalGroupMemberList",value:function(e){return this.groupMemberListMap.get(e)}},{key:"hasLocalGroupMember",value:function(e,t){return this.groupMemberListMap.has(e)&&this.groupMemberListMap.get(e).has(t)}},{key:"hasLocalGroupMemberMap",value:function(e){return this.groupMemberListMap.has(e)}},{key:"reset",value:function(){this.groupMemberListMap.clear()}}]),a}(Do),Os=["topicID","topicName","avatar","introduction","notification","unreadCount","muteAllMembers","customData","groupAtInfoList","nextMessageSeq","selfInfo"],Rs=function(e){return Ze(e)?{lastTime:0,lastSequence:0,fromAccount:"",payload:null,type:"",onlineOnlyFlag:!1}:e?{lastTime:e.time||0,lastSequence:e.sequence||0,fromAccount:e.from||"",payload:e.payload||null,type:e.type||"",onlineOnlyFlag:e._onlineOnlyFlag||!1}:void 0},Ls=function(){function e(t){n(this,e),this.topicID="",this.topicName="",this.avatar="",this.introduction="",this.notification="",this.unreadCount=0,this.muteAllMembers=!1,this.customData="",this.groupAtInfoList=[],this.nextMessageSeq=0,this.lastMessage=Rs(t.lastMessage),this.selfInfo={muteTime:0,readedSequence:0,messageRemindType:""},this._initGroupTopic(t)}return s(e,[{key:"_initGroupTopic",value:function(e){for(var t in e)Os.indexOf(t)<0||("selfInfo"===t?this.updateSelfInfo(e[t]):this[t]="muteAllMembers"===t?1===e[t]:e[t])}},{key:"updateUnreadCount",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this.unreadCount=e}},{key:"updateNextMessageSeq",value:function(e){this.nextMessageSeq=e}},{key:"updateLastMessage",value:function(e){this.lastMessage=Rs(e)}},{key:"updateGroupAtInfoList",value:function(e){this.groupAtInfoList=JSON.parse(JSON.stringify(e))}},{key:"updateTopic",value:function(e){Ze(e.selfInfo)||this.updateSelfInfo(e.selfInfo),Ze(e.muteAllMembers)||(this.muteAllMembers=1===e.muteAllMembers),ct(this,e,["groupID","lastMessageTime","selfInfo","muteAllMembers"])}},{key:"updateSelfInfo",value:function(e){ct(this.selfInfo,e,[],[""])}}]),e}(),ks=function(e){i(a,e);var o=f(a);function a(e){var t;return n(this,a),(t=o.call(this,e))._className="TopicModule",t._topicMap=new Map,t._getTopicTimeMap=new Map,t.TOPIC_CACHE_TIME=300,t.TOPIC_LAST_ACTIVE_TIME=3600,t.getInnerEmitterInstance().on(Xa,t._onCloudConfigUpdated,_(t)),t}return s(a,[{key:"_onCloudConfigUpdated",value:function(){var e=this.getCloudConfig("topic_cache_time"),t=this.getCloudConfig("topic_last_active_time");Ze(e)||(this.TOPIC_CACHE_TIME=Number(e)),Ze(t)||(this.TOPIC_LAST_ACTIVE_TIME=Number(t))}},{key:"onTopicCreated",value:function(e){var t=e.groupID;this.resetGetTopicTime(t),this.emitOuterEvent(S.TOPIC_CREATED,e)}},{key:"onTopicDeleted",value:function(e){var t=this,o=e.groupID,n=e.topicIDList;(void 0===n?[]:n).forEach((function(e){t._deleteLocalTopic(o,e)})),this.emitOuterEvent(S.TOPIC_DELETED,e)}},{key:"onTopicProfileUpdated",value:function(e){var t=e.groupID,o=e.topicID,n=this.getLocalTopic(t,o);n&&(n.updateTopic(e),this.emitOuterEvent(S.TOPIC_UPDATED,{groupID:t,topic:n}))}},{key:"onConversationProxy",value:function(e){var t=e.topicID,o=e.unreadCount,n=e.groupAtInfoList,a=bt(t),s=this.getLocalTopic(a,t),r=!1;s&&(Ze(o)||s.unreadCount===o||(s.updateUnreadCount(o),r=!0),Ze(n)||(s.updateGroupAtInfoList(n),r=!0)),r&&this.emitOuterEvent(S.TOPIC_UPDATED,{groupID:a,topic:s})}},{key:"onMessageSent",value:function(e){var t=e.groupID,o=e.topicID,n=e.lastMessage,a=this.getLocalTopic(t,o);a&&(a.nextMessageSeq+=1,a.updateLastMessage(n),this.emitOuterEvent(S.TOPIC_UPDATED,{groupID:t,topic:a}))}},{key:"onMessageModified",value:function(e){var t=e.to,o=e.time,n=e.sequence,a=e.elements,s=e.cloudCustomData,r=e.messageVersion,i=bt(t),c=this.getLocalTopic(i,t);if(c){var u=c.lastMessage;we.debug("".concat(this._className,".onMessageModified topicID:").concat(t," lastMessage:"),JSON.stringify(u),"options:",JSON.stringify(e)),u&&(null===u.payload||u.lastTime===o&&u.lastSequence===n&&u.version!==r)&&(u.type=a[0].type,u.payload=a[0].content,u.messageForShow=Ft(u.type,u.payload),u.cloudCustomData=s,u.version=r,u.lastSequence=n,u.lastTime=o,this.emitOuterEvent(S.TOPIC_UPDATED,{groupID:i,topic:c}))}}},{key:"getJoinedCommunityList",value:function(){return this.getModule(ao).getGroupList({isGroupWithTopicOnly:!0}).then((function(e){var t=e.data.groupList;return ba({groupList:void 0===t?[]:t})})).catch((function(e){return ja(e)}))}},{key:"createTopicInCommunity",value:function(e){var o=this,n="".concat(this._className,".createTopicInCommunity"),a=e.topicID;if(!Ze(a)&&!Tt(a))return ja({code:na.ILLEGAL_TOPIC_ID,message:aa.ILLEGAL_TOPIC_ID});var s=new va(ya.CREATE_TOPIC);return this.request({protocolName:Zn,requestData:t({},e)}).then((function(a){var r=a.data.topicID;return s.setMessage("topicID:".concat(r)).setNetworkType(o.getNetworkType()).end(),we.log("".concat(n," ok")),o._updateTopicMap([t(t({},e),{},{topicID:r})]),ba({topicID:r})})).catch((function(e){return o.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];s.setError(e,n,a).end()})),we.error("".concat(n," failed. error:"),e),ja(e)}))}},{key:"deleteTopicFromCommunity",value:function(e){var t=this,o="".concat(this._className,".deleteTopicFromCommunity"),n=e.groupID,a=e.topicIDList,s=void 0===a?[]:a,r=new va(ya.DELETE_TOPIC);return r.setMessage("groupID:".concat(n," topicIDList:").concat(s)),this.request({protocolName:ea,requestData:{groupID:n,topicIDList:s}}).then((function(e){var o=e.data.resultList,a=void 0===o?[]:o,s=a.filter((function(e){return 0===e.code})).map((function(e){return{topicID:e.topicID}})),i=a.filter((function(e){return 0!==e.code})),c="success count:".concat(s.length,", fail count:").concat(i.length);return r.setMoreMessage("".concat(c)).setNetworkType(t.getNetworkType()).end(),we.log("".concat(c)),s.forEach((function(e){t._deleteLocalTopic(n,e.topicID)})),ba({successTopicList:s,failureTopicList:i})})).catch((function(e){return t.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];r.setError(e,n,a).end()})),we.error("".concat(o," failed. error:"),e),ja(e)}))}},{key:"updateTopicProfile",value:function(e){var o=this,n="".concat(this._className,".updateTopicProfile"),a=new va(ya.UPDATE_TOPIC_PROFILE);return a.setMessage("groupID:".concat(e.groupID," topicID:").concat(e.topicID)),we.log("".concat(n," options:"),e),Ze(e.muteAllMembers)||(e.muteAllMembers=!0===e.muteAllMembers?"On":"Off"),this.request({protocolName:ta,requestData:t({},e)}).then((function(){return a.setNetworkType(o.getNetworkType()).end(),we.log("".concat(n," ok")),o._updateTopicMap([e]),ba({topic:o.getLocalTopic(e.groupID,e.topicID)})})).catch((function(e){return o.probeNetwork().then((function(t){var o=m(t,2),n=o[0],s=o[1];a.setError(e,n,s).end()})),we.error("".concat(n," failed. error:"),e),ja(e)}))}},{key:"getTopicList",value:function(e){var o=this,n="".concat(this._className,".getTopicList"),a=e.groupID,s=e.topicIDList,r=void 0===s?[]:s,i=new va(ya.GET_TOPIC_LIST);if(i.setMessage("groupID:".concat(a)),this._getTopicTimeMap.has(a)){var c=this._getTopicTimeMap.get(a);if(Date.now()-c<1e3*this.TOPIC_CACHE_TIME){var u=this._getLocalTopicList(a,r);return i.setNetworkType(this.getNetworkType()).setMoreMessage("from cache. topicList:".concat(u.length)).end(),we.log("".concat(n," groupID:").concat(a," from cache. topicList:").concat(u.length)),Ya({successTopicList:u,failureTopicList:[]})}}return this.request({protocolName:oa,requestData:{groupID:a,topicIDList:r}}).then((function(e){var s=e.data.topicInfoList,c=[],u=[],l=[];(void 0===s?[]:s).forEach((function(e){var o=e.topic,n=e.selfInfo,a=e.code,s=e.message,r=o.topicID;0===a?(c.push(t(t({},o),{},{selfInfo:n})),u.push(r)):l.push({topicID:r,code:a,message:s})})),o._updateTopicMap(c);var d="successTopicList:".concat(u.length," failureTopicList:").concat(l.length);i.setNetworkType(o.getNetworkType()).setMoreMessage("".concat(d)).end(),we.log("".concat(n," groupID:").concat(a," from remote. ").concat(d)),Vt(r)&&!Vt(u)&&o._getTopicTimeMap.set(a,Date.now());var p=[];return Vt(u)||(p=o._getLocalTopicList(a,u)),ba({successTopicList:p,failureTopicList:l})})).catch((function(e){return o.probeNetwork(e).then((function(t){var o=m(t,2),n=o[0],a=o[1];i.setError(e,n,a).end()})),we.error("".concat(n," failed. error:"),e),ja(e)}))}},{key:"hasLocalTopic",value:function(e,t){return!!this._topicMap.has(e)&&!!this._topicMap.get(e).has(t)}},{key:"getLocalTopic",value:function(e,t){var o=null;return this._topicMap.has(e)&&(o=this._topicMap.get(e).get(t)),o}},{key:"_getLocalTopicList",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],o=this._topicMap.get(e),n=[];return o&&(n=M(o.values())),0===t.length?n:n.filter((function(e){return t.includes(e.topicID)}))}},{key:"_deleteLocalTopic",value:function(e,t){this._topicMap.has(e)&&this._topicMap.get(e).delete(t)}},{key:"_updateTopicMap",value:function(e){var t=this,o=[];(e.forEach((function(e){var n=e.groupID,a=e.topicID,s=null;t._topicMap.has(n)||t._topicMap.set(n,new Map),t._topicMap.get(n).has(a)?(s=t._topicMap.get(n).get(a)).updateTopic(e):(s=new Ls(e),t._topicMap.get(n).set(a,s));var r=s.nextMessageSeq-s.selfInfo.readedSequence-1;o.push({conversationID:"".concat(D.CONV_GROUP).concat(a),type:D.CONV_TOPIC,unreadCount:r>0?r:0})})),o.length>0)&&this.getModule(co).updateTopicConversation(o)}},{key:"resetGetTopicTime",value:function(e){var t=this;Ze(e)?M(this._getTopicTimeMap.keys()).forEach((function(e){t._getTopicTimeMap.set(e,0)})):this._getTopicTimeMap.set(e,0)}},{key:"getTopicListOnReconnected",value:function(){var e=this,t=M(this._topicMap.keys()),o=[];t.forEach((function(t){var n=[];e._getLocalTopicList(t).forEach((function(t){var o=t.lastMessage.lastTime,a=void 0===o?0:o;Date.now()-1e3*a<1e3*e.TOPIC_LAST_ACTIVE_TIME&&n.push(t.topicID)})),n.length>0&&o.push({groupID:t,topicIDList:n})})),we.log("".concat(this._className,".getTopicListOnReconnected. active community count:").concat(o.length)),this._relayGetTopicList(o)}},{key:"_relayGetTopicList",value:function(e){var t=this;if(0!==e.length){var o=e.shift(),n=o.topicIDList.length>5?"topicIDList.length:".concat(o.topicIDList.length):"topicIDList:".concat(o.topicIDList),a=new va(ya.RELAY_GET_TOPIC_LIST);a.setMessage(n),we.log("".concat(this._className,"._relayGetTopicList. ").concat(n)),this.getTopicList(o).then((function(){a.setNetworkType(t.getNetworkType()).end(),t._relayGetTopicList(e)})).catch((function(o){t.probeNetwork().then((function(e){var t=m(e,2),n=t[0],s=t[1];a.setError(o,n,s).end()})),t._relayGetTopicList(e)}))}}},{key:"reset",value:function(){we.log("".concat(this._className,".reset")),this._topicMap.clear(),this._getTopicTimeMap.clear(),this.TOPIC_CACHE_TIME=300,this.TOPIC_LAST_ACTIVE_TIME=3600}}]),a}(Do),Gs=function(){function e(t){n(this,e),this._userModule=t,this._className="ProfileHandler",this.TAG="profile",this.accountProfileMap=new Map,this.expirationTime=864e5}return s(e,[{key:"setExpirationTime",value:function(e){this.expirationTime=e}},{key:"getUserProfile",value:function(e){var t=this,o=e.userIDList;e.fromAccount=this._userModule.getMyAccount(),o.length>100&&(we.warn("".concat(this._className,".getUserProfile 获取用户资料人数不能超过100人")),o.length=100);for(var n,a=[],s=[],r=0,i=o.length;r5?"userIDList.length:".concat(o.length):"userIDList:".concat(o)),this._userModule.request({protocolName:Uo,requestData:e}).then((function(e){l.setNetworkType(t._userModule.getNetworkType()).end(),we.info("".concat(t._className,".getUserProfile ok"));var o=t._handleResponse(e).concat(s);return ba(c?o[0]:o)})).catch((function(e){return t._userModule.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];l.setError(e,n,a).end()})),we.error("".concat(t._className,".getUserProfile failed. error:"),e),ja(e)}))}},{key:"getMyProfile",value:function(){var e=this._userModule.getMyAccount();if(we.log("".concat(this._className,".getMyProfile myAccount:").concat(e)),this._fillMap(),this._containsAccount(e)){var t=this._getProfileFromMap(e);return we.debug("".concat(this._className,".getMyProfile from cache, myProfile:")+JSON.stringify(t)),Ya(t)}return this.getUserProfile({fromAccount:e,userIDList:[e],bFromGetMyProfile:!0})}},{key:"_handleResponse",value:function(e){for(var t,o,n=it.now(),a=e.data.userProfileItem,s=[],r=0,i=a.length;r-1)o.profileCustomField.push({key:t[n].tag,value:t[n].value});else switch(t[n].tag){case Fe.NICK:o.nick=t[n].value;break;case Fe.GENDER:o.gender=t[n].value;break;case Fe.BIRTHDAY:o.birthday=t[n].value;break;case Fe.LOCATION:o.location=t[n].value;break;case Fe.SELFSIGNATURE:o.selfSignature=t[n].value;break;case Fe.ALLOWTYPE:o.allowType=t[n].value;break;case Fe.LANGUAGE:o.language=t[n].value;break;case Fe.AVATAR:o.avatar=t[n].value;break;case Fe.MESSAGESETTINGS:o.messageSettings=t[n].value;break;case Fe.ADMINFORBIDTYPE:o.adminForbidType=t[n].value;break;case Fe.LEVEL:o.level=t[n].value;break;case Fe.ROLE:o.role=t[n].value;break;default:we.warn("".concat(this._className,"._handleResponse unknown tag:"),t[n].tag,t[n].value)}return o}},{key:"updateMyProfile",value:function(e){var t=this,o="".concat(this._className,".updateMyProfile"),n=new va(ya.UPDATE_MY_PROFILE);n.setMessage(JSON.stringify(e));var a=(new rs).validate(e);if(!a.valid)return n.setCode(na.UPDATE_PROFILE_INVALID_PARAM).setMoreMessage("".concat(o," info:").concat(a.tips)).setNetworkType(this._userModule.getNetworkType()).end(),we.error("".concat(o," info:").concat(a.tips,",请参考 https://web.sdk.qcloud.com/im/doc/zh-cn/SDK.html#updateMyProfile")),ja({code:na.UPDATE_PROFILE_INVALID_PARAM,message:aa.UPDATE_PROFILE_INVALID_PARAM});var s=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&("profileCustomField"===r?e.profileCustomField.forEach((function(e){s.push({tag:e.key,value:e.value})})):s.push({tag:Fe[r.toUpperCase()],value:e[r]}));return 0===s.length?(n.setCode(na.UPDATE_PROFILE_NO_KEY).setMoreMessage(aa.UPDATE_PROFILE_NO_KEY).setNetworkType(this._userModule.getNetworkType()).end(),we.error("".concat(o," info:").concat(aa.UPDATE_PROFILE_NO_KEY,",请参考 https://web.sdk.qcloud.com/im/doc/zh-cn/SDK.html#updateMyProfile")),ja({code:na.UPDATE_PROFILE_NO_KEY,message:aa.UPDATE_PROFILE_NO_KEY})):this._userModule.request({protocolName:wo,requestData:{fromAccount:this._userModule.getMyAccount(),profileItem:s}}).then((function(a){n.setNetworkType(t._userModule.getNetworkType()).end(),we.info("".concat(o," ok"));var s=t._updateMap(t._userModule.getMyAccount(),e);return t._userModule.emitOuterEvent(S.PROFILE_UPDATED,[s]),Ya(s)})).catch((function(e){return t._userModule.probeNetwork().then((function(t){var o=m(t,2),a=o[0],s=o[1];n.setError(e,a,s).end()})),we.error("".concat(o," failed. error:"),e),ja(e)}))}},{key:"onProfileModified",value:function(e){var t=e.dataList;if(!Vt(t)){var o,n,a=t.length;we.debug("".concat(this._className,".onProfileModified count:").concat(a," dataList:"),e.dataList);for(var s=[],r=0;r0&&(this._userModule.emitInnerEvent(Qa,s),this._userModule.emitOuterEvent(S.PROFILE_UPDATED,s))}}},{key:"_fillMap",value:function(){if(0===this.accountProfileMap.size){for(var e=this._getCachedProfiles(),t=Date.now(),o=0,n=e.length;o0&&a.push(o)):a.push(t.userID));0!==a.length&&(we.info("".concat(this._className,".onConversationsProfileUpdated toAccountList:").concat(a)),this.getUserProfile({userIDList:a}))}},{key:"getNickAndAvatarByUserID",value:function(e){if(this._containsAccount(e)){var t=this._getProfileFromMap(e);return{nick:t.nick,avatar:t.avatar}}return{nick:"",avatar:""}}},{key:"reset",value:function(){this._flushMap(!0),this.accountProfileMap.clear()}}]),e}(),Ps=s((function e(t){n(this,e),Vt||(this.userID=t.userID||"",this.timeStamp=t.timeStamp||0)})),Us=function(){function e(t){n(this,e),this._userModule=t,this._className="BlacklistHandler",this._blacklistMap=new Map,this.startIndex=0,this.maxLimited=100,this.currentSequence=0}return s(e,[{key:"getLocalBlacklist",value:function(){return M(this._blacklistMap.keys())}},{key:"getBlacklist",value:function(){var e=this,t="".concat(this._className,".getBlacklist"),o={fromAccount:this._userModule.getMyAccount(),maxLimited:this.maxLimited,startIndex:0,lastSequence:this.currentSequence},n=new va(ya.GET_BLACKLIST);return this._userModule.request({protocolName:bo,requestData:o}).then((function(o){var a=o.data,s=a.blackListItem,r=a.currentSequence,i=Vt(s)?0:s.length;n.setNetworkType(e._userModule.getNetworkType()).setMessage("blackList count:".concat(i)).end(),we.info("".concat(t," ok")),e.currentSequence=r,e._handleResponse(s,!0),e._userModule.emitOuterEvent(S.BLACKLIST_UPDATED,M(e._blacklistMap.keys()))})).catch((function(o){return e._userModule.probeNetwork().then((function(e){var t=m(e,2),a=t[0],s=t[1];n.setError(o,a,s).end()})),we.error("".concat(t," failed. error:"),o),ja(o)}))}},{key:"addBlacklist",value:function(e){var t=this,o="".concat(this._className,".addBlacklist"),n=new va(ya.ADD_TO_BLACKLIST);if(!Qe(e.userIDList))return n.setCode(na.ADD_BLACKLIST_INVALID_PARAM).setMessage(aa.ADD_BLACKLIST_INVALID_PARAM).setNetworkType(this._userModule.getNetworkType()).end(),we.error("".concat(o," options.userIDList 必需是数组")),ja({code:na.ADD_BLACKLIST_INVALID_PARAM,message:aa.ADD_BLACKLIST_INVALID_PARAM});var a=this._userModule.getMyAccount();return 1===e.userIDList.length&&e.userIDList[0]===a?(n.setCode(na.CANNOT_ADD_SELF_TO_BLACKLIST).setMessage(aa.CANNOT_ADD_SELF_TO_BLACKLIST).setNetworkType(this._userModule.getNetworkType()).end(),we.error("".concat(o," 不能把自己拉黑")),ja({code:na.CANNOT_ADD_SELF_TO_BLACKLIST,message:aa.CANNOT_ADD_SELF_TO_BLACKLIST})):(e.userIDList.includes(a)&&(e.userIDList=e.userIDList.filter((function(e){return e!==a})),we.warn("".concat(o," 不能把自己拉黑,已过滤"))),e.fromAccount=this._userModule.getMyAccount(),e.toAccount=e.userIDList,this._userModule.request({protocolName:Fo,requestData:e}).then((function(a){return n.setNetworkType(t._userModule.getNetworkType()).setMessage(e.userIDList.length>5?"userIDList.length:".concat(e.userIDList.length):"userIDList:".concat(e.userIDList)).end(),we.info("".concat(o," ok")),t._handleResponse(a.resultItem,!0),ba(M(t._blacklistMap.keys()))})).catch((function(e){return t._userModule.probeNetwork().then((function(t){var o=m(t,2),a=o[0],s=o[1];n.setError(e,a,s).end()})),we.error("".concat(o," failed. error:"),e),ja(e)})))}},{key:"_handleResponse",value:function(e,t){if(!Vt(e))for(var o,n,a,s=0,r=e.length;s5?"userIDList.length:".concat(e.userIDList.length):"userIDList:".concat(e.userIDList)).end(),we.info("".concat(o," ok")),t._handleResponse(a.data.resultItem,!1),ba(M(t._blacklistMap.keys()))})).catch((function(e){return t._userModule.probeNetwork().then((function(t){var o=m(t,2),a=o[0],s=o[1];n.setError(e,a,s).end()})),we.error("".concat(o," failed. error:"),e),ja(e)}))):(n.setCode(na.DEL_BLACKLIST_INVALID_PARAM).setMessage(aa.DEL_BLACKLIST_INVALID_PARAM).setNetworkType(this._userModule.getNetworkType()).end(),we.error("".concat(o," options.userIDList 必需是数组")),ja({code:na.DEL_BLACKLIST_INVALID_PARAM,message:aa.DEL_BLACKLIST_INVALID_PARAM}))}},{key:"onAccountDeleted",value:function(e){for(var t,o=[],n=0,a=e.length;n0&&(we.log("".concat(this._className,".onAccountDeleted count:").concat(o.length," userIDList:"),o),this._userModule.emitOuterEvent(S.BLACKLIST_UPDATED,M(this._blacklistMap.keys())))}},{key:"onAccountAdded",value:function(e){for(var t,o=[],n=0,a=e.length;n0&&(we.log("".concat(this._className,".onAccountAdded count:").concat(o.length," userIDList:"),o),this._userModule.emitOuterEvent(S.BLACKLIST_UPDATED,M(this._blacklistMap.keys())))}},{key:"reset",value:function(){this._blacklistMap.clear(),this.startIndex=0,this.maxLimited=100,this.currentSequence=0}}]),e}(),ws=function(e){i(o,e);var t=f(o);function o(e){var a;return n(this,o),(a=t.call(this,e))._className="UserModule",a._profileHandler=new Gs(_(a)),a._blacklistHandler=new Us(_(a)),a.getInnerEmitterInstance().on(Ja,a.onContextUpdated,_(a)),a}return s(o,[{key:"onContextUpdated",value:function(e){this._profileHandler.getMyProfile(),this._blacklistHandler.getBlacklist()}},{key:"onProfileModified",value:function(e){this._profileHandler.onProfileModified(e)}},{key:"onRelationChainModified",value:function(e){var t=e.dataList;if(!Vt(t)){var o=[];t.forEach((function(e){e.blackListDelAccount&&o.push.apply(o,M(e.blackListDelAccount))})),o.length>0&&this._blacklistHandler.onAccountDeleted(o);var n=[];t.forEach((function(e){e.blackListAddAccount&&n.push.apply(n,M(e.blackListAddAccount))})),n.length>0&&this._blacklistHandler.onAccountAdded(n)}}},{key:"onConversationsProfileUpdated",value:function(e){this._profileHandler.onConversationsProfileUpdated(e)}},{key:"getMyAccount",value:function(){return this.getMyUserID()}},{key:"getMyProfile",value:function(){return this._profileHandler.getMyProfile()}},{key:"getStorageModule",value:function(){return this.getModule(lo)}},{key:"isMyFriend",value:function(e){var t=this.getModule(so);return!!t&&t.isMyFriend(e)}},{key:"getUserProfile",value:function(e){return this._profileHandler.getUserProfile(e)}},{key:"updateMyProfile",value:function(e){return this._profileHandler.updateMyProfile(e)}},{key:"getNickAndAvatarByUserID",value:function(e){return this._profileHandler.getNickAndAvatarByUserID(e)}},{key:"getLocalBlacklist",value:function(){var e=this._blacklistHandler.getLocalBlacklist();return Ya(e)}},{key:"addBlacklist",value:function(e){return this._blacklistHandler.addBlacklist(e)}},{key:"deleteBlacklist",value:function(e){return this._blacklistHandler.deleteBlacklist(e)}},{key:"reset",value:function(){we.log("".concat(this._className,".reset")),this._profileHandler.reset(),this._blacklistHandler.reset()}}]),o}(Do),bs=function(){function e(t,o){n(this,e),this._moduleManager=t,this._isLoggedIn=!1,this._SDKAppID=o.SDKAppID,this._userID=o.userID||"",this._userSig=o.userSig||"",this._version="2.20.1",this._a2Key="",this._tinyID="",this._contentType="json",this._unlimitedAVChatRoom=o.unlimitedAVChatRoom,this._scene=o.scene||"",this._oversea=o.oversea,this._instanceID=o.instanceID,this._statusInstanceID=0,this._isDevMode=o.devMode,this._proxyServer=o.proxyServer}return s(e,[{key:"isLoggedIn",value:function(){return this._isLoggedIn}},{key:"isOversea",value:function(){return this._oversea}},{key:"isPrivateNetWork",value:function(){return this._proxyServer}},{key:"isDevMode",value:function(){return this._isDevMode}},{key:"isSingaporeSite",value:function(){return this._SDKAppID>=2e7&&this._SDKAppID<3e7}},{key:"isKoreaSite",value:function(){return this._SDKAppID>=3e7&&this._SDKAppID<4e7}},{key:"isGermanySite",value:function(){return this._SDKAppID>=4e7&&this._SDKAppID<5e7}},{key:"isIndiaSite",value:function(){return this._SDKAppID>=5e7&&this._SDKAppID<6e7}},{key:"isUnlimitedAVChatRoom",value:function(){return this._unlimitedAVChatRoom}},{key:"getUserID",value:function(){return this._userID}},{key:"setUserID",value:function(e){this._userID=e}},{key:"setUserSig",value:function(e){this._userSig=e}},{key:"getUserSig",value:function(){return this._userSig}},{key:"getSDKAppID",value:function(){return this._SDKAppID}},{key:"getTinyID",value:function(){return this._tinyID}},{key:"setTinyID",value:function(e){this._tinyID=e,this._isLoggedIn=!0}},{key:"getScene",value:function(){return this._isTUIKit()?"tuikit":this._scene}},{key:"getInstanceID",value:function(){return this._instanceID}},{key:"getStatusInstanceID",value:function(){return this._statusInstanceID}},{key:"setStatusInstanceID",value:function(e){this._statusInstanceID=e}},{key:"getVersion",value:function(){return this._version}},{key:"getA2Key",value:function(){return this._a2Key}},{key:"setA2Key",value:function(e){this._a2Key=e}},{key:"getContentType",value:function(){return this._contentType}},{key:"getProxyServer",value:function(){return this._proxyServer}},{key:"_isTUIKit",value:function(){var e=!1,t=!1,o=!1,n=!1,a=[];te&&(a=Object.keys(ne)),oe&&(a=ee?Object.keys(uni):Object.keys(window));for(var s=0,r=a.length;s0){for(var u=0,l=c.length;u0&&void 0!==arguments[0]?arguments[0]:0;if(!this.isLoggedIn())return ja({code:na.USER_NOT_LOGGED_IN,message:aa.USER_NOT_LOGGED_IN});var o=new va(ya.LOGOUT);return o.setNetworkType(this.getNetworkType()).setMessage("identifier:".concat(this.getMyUserID())).end(!0),we.info("".concat(this._className,".logout type:").concat(t)),0===t&&this._moduleManager.setNotReadyReason(na.LOGGED_OUT),this.request({protocolName:Ao,requestData:{type:t}}).then((function(){return e.resetReady(),Ya({})})).catch((function(t){return we.error("".concat(e._className,"._logout error:"),t),e.resetReady(),Ya({})}))}},{key:"_fetchCloudControlConfig",value:function(){this.getModule(Io).fetchConfig()}},{key:"_hello",value:function(){var e=this;this._lastWsHelloTs=Date.now(),this.request({protocolName:Oo}).catch((function(t){we.warn("".concat(e._className,"._hello error:"),t)}))}},{key:"getLastWsHelloTs",value:function(){return this._lastWsHelloTs}},{key:"_checkLoginInfo",value:function(e){var t=0,o="";return Vt(this.getModule(uo).getSDKAppID())?(t=na.NO_SDKAPPID,o=aa.NO_SDKAPPID):Vt(e.userID)?(t=na.NO_IDENTIFIER,o=aa.NO_IDENTIFIER):Vt(e.userSig)&&(t=na.NO_USERSIG,o=aa.NO_USERSIG),{code:t,message:o}}},{key:"onMultipleAccountKickedOut",value:function(e){var t=this;new va(ya.KICKED_OUT).setNetworkType(this.getNetworkType()).setMessage("type:".concat(D.KICKED_OUT_MULT_ACCOUNT," newInstanceInfo:").concat(JSON.stringify(e))).end(!0),we.warn("".concat(this._className,".onMultipleAccountKickedOut userID:").concat(this.getMyUserID()," newInstanceInfo:"),e),this.logout(1).then((function(){t.emitOuterEvent(S.KICKED_OUT,{type:D.KICKED_OUT_MULT_ACCOUNT}),t._moduleManager.setNotReadyReason(na.KICKED_OUT_MULT_ACCOUNT),t._moduleManager.reset()}))}},{key:"onMultipleDeviceKickedOut",value:function(e){var t=this;new va(ya.KICKED_OUT).setNetworkType(this.getNetworkType()).setMessage("type:".concat(D.KICKED_OUT_MULT_DEVICE," newInstanceInfo:").concat(JSON.stringify(e))).end(!0),we.warn("".concat(this._className,".onMultipleDeviceKickedOut userID:").concat(this.getMyUserID()," newInstanceInfo:"),e),this.logout(1).then((function(){t.emitOuterEvent(S.KICKED_OUT,{type:D.KICKED_OUT_MULT_DEVICE}),t._moduleManager.setNotReadyReason(na.KICKED_OUT_MULT_DEVICE),t._moduleManager.reset()}))}},{key:"onUserSigExpired",value:function(){new va(ya.KICKED_OUT).setNetworkType(this.getNetworkType()).setMessage(D.KICKED_OUT_USERSIG_EXPIRED).end(!0),we.warn("".concat(this._className,".onUserSigExpired: userSig 签名过期被踢下线")),0!==this.getModule(uo).getStatusInstanceID()&&(this.emitOuterEvent(S.KICKED_OUT,{type:D.KICKED_OUT_USERSIG_EXPIRED}),this._moduleManager.setNotReadyReason(na.KICKED_OUT_USERSIG_EXPIRED),this._moduleManager.reset())}},{key:"onRestApiKickedOut",value:function(e){(new va(ya.KICKED_OUT).setNetworkType(this.getNetworkType()).setMessage("type:".concat(D.KICKED_OUT_REST_API," newInstanceInfo:").concat(JSON.stringify(e))).end(!0),we.warn("".concat(this._className,".onRestApiKickedOut userID:").concat(this.getMyUserID()," newInstanceInfo:"),e),0!==this.getModule(uo).getStatusInstanceID())&&(this.emitOuterEvent(S.KICKED_OUT,{type:D.KICKED_OUT_REST_API}),this._moduleManager.setNotReadyReason(na.KICKED_OUT_REST_API),this._moduleManager.reset(),this.getModule(vo).onRestApiKickedOut())}},{key:"reset",value:function(){we.log("".concat(this._className,".reset")),this.resetReady(),this._helloInterval=120,this._lastLoginTs=0,this._lastWsHelloTs=0}}]),o}(Do);function qs(){return null}var Vs=function(){function e(t){n(this,e),this._moduleManager=t,this._className="StorageModule",this._storageQueue=new Map,this._errorTolerantHandle()}return s(e,[{key:"_errorTolerantHandle",value:function(){te||!Ze(window)&&!Ze(window.localStorage)||(this.getItem=qs,this.setItem=qs,this.removeItem=qs,this.clear=qs)}},{key:"onCheckTimer",value:function(e){if(e%20==0){if(0===this._storageQueue.size)return;this._doFlush()}}},{key:"_doFlush",value:function(){try{var e,t=C(this._storageQueue);try{for(t.s();!(e=t.n()).done;){var o=m(e.value,2),n=o[0],a=o[1];this._setStorageSync(this._getKey(n),a)}}catch(s){t.e(s)}finally{t.f()}this._storageQueue.clear()}catch(r){we.warn("".concat(this._className,"._doFlush error:"),r)}}},{key:"_getPrefix",value:function(){var e=this._moduleManager.getModule(uo);return"TIM_".concat(e.getSDKAppID(),"_").concat(e.getUserID(),"_")}},{key:"_getKey",value:function(e){return"".concat(this._getPrefix()).concat(e)}},{key:"getItem",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];try{var o=t?this._getKey(e):e;return this.getStorageSync(o)}catch(n){return we.warn("".concat(this._className,".getItem error:"),n),{}}}},{key:"setItem",value:function(e,t){var o=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];if(o){var a=n?this._getKey(e):e;this._setStorageSync(a,t)}else this._storageQueue.set(e,t)}},{key:"clear",value:function(){try{te?ne.clearStorageSync():localStorage&&localStorage.clear()}catch(e){we.warn("".concat(this._className,".clear error:"),e)}}},{key:"removeItem",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];try{var o=t?this._getKey(e):e;this._removeStorageSync(o)}catch(n){we.warn("".concat(this._className,".removeItem error:"),n)}}},{key:"getSize",value:function(e){var t=this,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"b";try{var n={size:0,limitSize:5242880,unit:o};if(Object.defineProperty(n,"leftSize",{enumerable:!0,get:function(){return n.limitSize-n.size}}),te&&(n.limitSize=1024*ne.getStorageInfoSync().limitSize),e)n.size=JSON.stringify(this.getItem(e)).length+this._getKey(e).length;else if(te){var a=ne.getStorageInfoSync(),s=a.keys;s.forEach((function(e){n.size+=JSON.stringify(t.getStorageSync(e)).length+t._getKey(e).length}))}else if(localStorage)for(var r in localStorage)localStorage.hasOwnProperty(r)&&(n.size+=localStorage.getItem(r).length+r.length);return this._convertUnit(n)}catch(i){we.warn("".concat(this._className," error:"),i)}}},{key:"_convertUnit",value:function(e){var t={},o=e.unit;for(var n in t.unit=o,e)"number"==typeof e[n]&&("kb"===o.toLowerCase()?t[n]=Math.round(e[n]/1024):"mb"===o.toLowerCase()?t[n]=Math.round(e[n]/1024/1024):t[n]=e[n]);return t}},{key:"_setStorageSync",value:function(e,t){te?Q?my.setStorageSync({key:e,data:t}):ne.setStorageSync(e,t):localStorage&&localStorage.setItem(e,JSON.stringify(t))}},{key:"getStorageSync",value:function(e){return te?Q?my.getStorageSync({key:e}).data:ne.getStorageSync(e):localStorage?JSON.parse(localStorage.getItem(e)):{}}},{key:"_removeStorageSync",value:function(e){te?Q?my.removeStorageSync({key:e}):ne.removeStorageSync(e):localStorage&&localStorage.removeItem(e)}},{key:"reset",value:function(){we.log("".concat(this._className,".reset")),this._doFlush()}}]),e}(),Ks=function(){function e(t){n(this,e),this._className="SSOLogBody",this._report=[]}return s(e,[{key:"pushIn",value:function(e){we.debug("".concat(this._className,".pushIn"),this._report.length,e),this._report.push(e)}},{key:"backfill",value:function(e){var t;Qe(e)&&0!==e.length&&(we.debug("".concat(this._className,".backfill"),this._report.length,e.length),(t=this._report).unshift.apply(t,M(e)))}},{key:"getLogsNumInMemory",value:function(){return this._report.length}},{key:"isEmpty",value:function(){return 0===this._report.length}},{key:"_reset",value:function(){this._report.length=0,this._report=[]}},{key:"getLogsInMemory",value:function(){var e=this._report.slice();return this._reset(),e}}]),e}(),Hs=function(e){var t=e.getModule(uo);return{SDKType:10,SDKAppID:t.getSDKAppID(),SDKVersion:t.getVersion(),tinyID:Number(t.getTinyID()),userID:t.getUserID(),platform:e.getPlatform(),instanceID:t.getInstanceID(),traceID:Re()}},Bs=function(e){i(a,e);var o=f(a);function a(e){var t;n(this,a),(t=o.call(this,e))._className="EventStatModule",t.TAG="im-ssolog-event",t._reportBody=new Ks,t.MIN_THRESHOLD=20,t.MAX_THRESHOLD=100,t.WAITING_TIME=6e4,t.REPORT_LEVEL=[4,5,6],t.REPORT_SDKAPPID_BLACKLIST=[],t.REPORT_TINYID_WHITELIST=[],t._lastReportTime=Date.now();var s=t.getInnerEmitterInstance();return s.on(Ja,t._onLoginSuccess,_(t)),s.on(Xa,t._onCloudConfigUpdated,_(t)),t}return s(a,[{key:"reportAtOnce",value:function(){we.debug("".concat(this._className,".reportAtOnce")),this._report()}},{key:"_onLoginSuccess",value:function(){var e=this,t=this.getModule(lo),o=t.getItem(this.TAG,!1);!Vt(o)&&ot(o.forEach)&&(we.log("".concat(this._className,"._onLoginSuccess get ssolog in storage, count:").concat(o.length)),o.forEach((function(t){e._reportBody.pushIn(t)})),t.removeItem(this.TAG,!1))}},{key:"_onCloudConfigUpdated",value:function(){var e=this.getCloudConfig("evt_rpt_threshold"),t=this.getCloudConfig("evt_rpt_waiting"),o=this.getCloudConfig("evt_rpt_level"),n=this.getCloudConfig("evt_rpt_sdkappid_bl"),a=this.getCloudConfig("evt_rpt_tinyid_wl");Ze(e)||(this.MIN_THRESHOLD=Number(e)),Ze(t)||(this.WAITING_TIME=Number(t)),Ze(o)||(this.REPORT_LEVEL=o.split(",").map((function(e){return Number(e)}))),Ze(n)||(this.REPORT_SDKAPPID_BLACKLIST=n.split(",").map((function(e){return Number(e)}))),Ze(a)||(this.REPORT_TINYID_WHITELIST=a.split(","))}},{key:"pushIn",value:function(e){e instanceof va&&(e.updateTimeStamp(),this._reportBody.pushIn(e),this._reportBody.getLogsNumInMemory()>=this.MIN_THRESHOLD&&this._report())}},{key:"onCheckTimer",value:function(){Date.now()e.MAX_THRESHOLD&&e._flushAtOnce()}))}else this._lastReportTime=Date.now()}}},{key:"_flushAtOnce",value:function(){var e=this.getModule(lo),t=e.getItem(this.TAG,!1),o=this._reportBody.getLogsInMemory();if(Vt(t))we.log("".concat(this._className,"._flushAtOnce count:").concat(o.length)),e.setItem(this.TAG,o,!0,!1);else{var n=o.concat(t);n.length>this.MAX_THRESHOLD&&(n=n.slice(0,this.MAX_THRESHOLD)),we.log("".concat(this._className,"._flushAtOnce count:").concat(n.length)),e.setItem(this.TAG,n,!0,!1)}}},{key:"reset",value:function(){we.log("".concat(this._className,".reset")),this._lastReportTime=0,this._report(),this.REPORT_SDKAPPID_BLACKLIST=[],this.REPORT_TINYID_WHITELIST=[]}}]),a}(Do),xs="none",Ws="online",Ys=[na.OVER_FREQUENCY_LIMIT,na.OPEN_SERVICE_OVERLOAD_ERROR],js=function(){function e(t){n(this,e),this._moduleManager=t,this._networkType="",this._className="NetMonitorModule",this.MAX_WAIT_TIME=3e3,this._mpNetworkStatusCallback=null,this._webOnlineCallback=null,this._webOfflineCallback=null}return s(e,[{key:"start",value:function(){var e=this;te?(ne.getNetworkType({success:function(t){e._networkType=t.networkType,t.networkType===xs?we.warn("".concat(e._className,".start no network, please check!")):we.info("".concat(e._className,".start networkType:").concat(t.networkType))}}),this._mpNetworkStatusCallback=this._onNetworkStatusChange.bind(this),ne.onNetworkStatusChange(this._mpNetworkStatusCallback)):(this._networkType=Ws,this._webOnlineCallback=this._onWebOnline.bind(this),this._webOfflineCallback=this._onWebOffline.bind(this),window&&(window.addEventListener("online",this._webOnlineCallback),window.addEventListener("offline",this._webOfflineCallback)))}},{key:"_onWebOnline",value:function(){this._onNetworkStatusChange({isConnected:!0,networkType:Ws})}},{key:"_onWebOffline",value:function(){this._onNetworkStatusChange({isConnected:!1,networkType:xs})}},{key:"_onNetworkStatusChange",value:function(e){var t=e.isConnected,o=e.networkType,n=!1;t?(we.info("".concat(this._className,"._onNetworkStatusChange previousNetworkType:").concat(this._networkType," currentNetworkType:").concat(o)),this._networkType!==o&&(n=!0,this._moduleManager.getModule(vo).reConnect(!0))):this._networkType!==o&&(n=!0,we.warn("".concat(this._className,"._onNetworkStatusChange no network, please check!")),this._moduleManager.getModule(vo).offline());n&&(new va(ya.NETWORK_CHANGE).setMessage("isConnected:".concat(t," previousNetworkType:").concat(this._networkType," networkType:").concat(o)).end(),this._networkType=o)}},{key:"probe",value:function(e){var t=this;return!Ze(e)&&Ys.includes(e.code)?Promise.resolve([!0,this._networkType]):new Promise((function(e,o){if(te)ne.getNetworkType({success:function(o){t._networkType=o.networkType,o.networkType===xs?(we.warn("".concat(t._className,".probe no network, please check!")),e([!1,o.networkType])):(we.info("".concat(t._className,".probe networkType:").concat(o.networkType)),e([!0,o.networkType]))}});else if(window&&window.fetch)fetch("".concat(ft(),"//web.sdk.qcloud.com/im/assets/speed.xml?random=").concat(Math.random())).then((function(t){t.ok?e([!0,Ws]):e([!1,xs])})).catch((function(t){e([!1,xs])}));else{var n=new XMLHttpRequest,a=setTimeout((function(){we.warn("".concat(t._className,".probe fetch timeout. Probably no network, please check!")),n.abort(),t._networkType=xs,e([!1,xs])}),t.MAX_WAIT_TIME);n.onreadystatechange=function(){4===n.readyState&&(clearTimeout(a),200===n.status||304===n.status||514===n.status?(this._networkType=Ws,e([!0,Ws])):(we.warn("".concat(this.className,".probe fetch status:").concat(n.status,". Probably no network, please check!")),this._networkType=xs,e([!1,xs])))},n.open("GET","".concat(ft(),"//web.sdk.qcloud.com/im/assets/speed.xml?random=").concat(Math.random())),n.send()}}))}},{key:"getNetworkType",value:function(){return this._networkType}},{key:"reset",value:function(){we.log("".concat(this._className,".reset")),te?null!==this._mpNetworkStatusCallback&&(ne.offNetworkStatusChange&&(Z||J?ne.offNetworkStatusChange(this._mpNetworkStatusCallback):ne.offNetworkStatusChange()),this._mpNetworkStatusCallback=null):window&&(null!==this._webOnlineCallback&&(window.removeEventListener("online",this._webOnlineCallback),this._webOnlineCallback=null),null!==this._onWebOffline&&(window.removeEventListener("offline",this._webOfflineCallback),this._webOfflineCallback=null))}}]),e}(),$s=O((function(e){var t=Object.prototype.hasOwnProperty,o="~";function n(){}function a(e,t,o){this.fn=e,this.context=t,this.once=o||!1}function s(e,t,n,s,r){if("function"!=typeof n)throw new TypeError("The listener must be a function");var i=new a(n,s||e,r),c=o?o+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],i]:e._events[c].push(i):(e._events[c]=i,e._eventsCount++),e}function r(e,t){0==--e._eventsCount?e._events=new n:delete e._events[t]}function i(){this._events=new n,this._eventsCount=0}Object.create&&(n.prototype=Object.create(null),(new n).__proto__||(o=!1)),i.prototype.eventNames=function(){var e,n,a=[];if(0===this._eventsCount)return a;for(n in e=this._events)t.call(e,n)&&a.push(o?n.slice(1):n);return Object.getOwnPropertySymbols?a.concat(Object.getOwnPropertySymbols(e)):a},i.prototype.listeners=function(e){var t=o?o+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var a=0,s=n.length,r=new Array(s);a=this.cosOptions.expiredTime-120&&this._getAuthorizationKey())}},{key:"_getAuthorization",value:function(e,t){t({TmpSecretId:this.cosOptions.secretId,TmpSecretKey:this.cosOptions.secretKey,XCosSecurityToken:this.cosOptions.sessionToken,ExpiredTime:this.cosOptions.expiredTime})}},{key:"upload",value:function(e){if(!0===e.getRelayFlag())return Promise.resolve();var t=this.getModule(Co);switch(e.type){case D.MSG_IMAGE:return t.addTotalCount(da),this._uploadImage(e);case D.MSG_FILE:return t.addTotalCount(da),this._uploadFile(e);case D.MSG_AUDIO:return t.addTotalCount(da),this._uploadAudio(e);case D.MSG_VIDEO:return t.addTotalCount(da),this._uploadVideo(e);default:return Promise.resolve()}}},{key:"_uploadImage",value:function(e){var o=this,n=this.getModule(to),a=e.getElements()[0],s=n.getMessageOption(e.clientSequence);return this.doUploadImage({file:s.payload.file,to:s.to,onProgress:function(e){if(a.updatePercent(e),ot(s.onProgress))try{s.onProgress(e)}catch(t){return ja({code:na.MESSAGE_ONPROGRESS_FUNCTION_ERROR,message:aa.MESSAGE_ONPROGRESS_FUNCTION_ERROR})}}}).then((function(n){var s=n.location,r=n.fileType,i=n.fileSize,c=n.width,u=n.height,l=o.isPrivateNetWork()?s:mt(s);a.updateImageFormat(r);var d=Lt({originUrl:l,originWidth:c,originHeight:u,min:198}),p=Lt({originUrl:l,originWidth:c,originHeight:u,min:720});return a.updateImageInfoArray([{size:i,url:l,width:c,height:u},t({},p),t({},d)]),e}))}},{key:"_uploadFile",value:function(e){var t=this,o=this.getModule(to),n=e.getElements()[0],a=o.getMessageOption(e.clientSequence);return this.doUploadFile({file:a.payload.file,to:a.to,onProgress:function(e){if(n.updatePercent(e),ot(a.onProgress))try{a.onProgress(e)}catch(t){return ja({code:na.MESSAGE_ONPROGRESS_FUNCTION_ERROR,message:aa.MESSAGE_ONPROGRESS_FUNCTION_ERROR})}}}).then((function(o){var a=o.location,s=t.isPrivateNetWork()?a:mt(a);return n.updateFileUrl(s),e}))}},{key:"_uploadAudio",value:function(e){var t=this,o=this.getModule(to),n=e.getElements()[0],a=o.getMessageOption(e.clientSequence);return this.doUploadAudio({file:a.payload.file,to:a.to,onProgress:function(e){if(n.updatePercent(e),ot(a.onProgress))try{a.onProgress(e)}catch(t){return ja({code:na.MESSAGE_ONPROGRESS_FUNCTION_ERROR,message:aa.MESSAGE_ONPROGRESS_FUNCTION_ERROR})}}}).then((function(o){var a=o.location,s=t.isPrivateNetWork()?a:mt(a);return n.updateAudioUrl(s),e}))}},{key:"_uploadVideo",value:function(e){var t=this,o=this.getModule(to),n=e.getElements()[0],a=o.getMessageOption(e.clientSequence);return this.doUploadVideo({file:a.payload.file,to:a.to,onProgress:function(e){if(n.updatePercent(e),ot(a.onProgress))try{a.onProgress(e)}catch(t){return ja({code:na.MESSAGE_ONPROGRESS_FUNCTION_ERROR,message:aa.MESSAGE_ONPROGRESS_FUNCTION_ERROR})}}}).then((function(o){var a=o.location,s=o.snapshotInfo,r=t.isPrivateNetWork()?a:mt(a);return n.updateVideoUrl(r),Vt(s)||n.updateSnapshotInfo(s),e}))}},{key:"doUploadImage",value:function(e){var t=this;if(!e.file)return ja({code:na.MESSAGE_IMAGE_SELECT_FILE_FIRST,message:aa.MESSAGE_IMAGE_SELECT_FILE_FIRST});var o=this._checkImageType(e.file);if(!0!==o)return o;var n=this._checkImageSize(e.file);if(!0!==n)return n;var a=null;return this._setUploadFileType(os),this.uploadByCOS(e).then((function(e){return a=e,t.isPrivateNetWork()?At(e.location):At("https://".concat(e.location))})).then((function(e){return a.width=e.width,a.height=e.height,Promise.resolve(a)}))}},{key:"_checkImageType",value:function(e){var t="";return t=te?e.url.slice(e.url.lastIndexOf(".")+1):e.files[0].name.slice(e.files[0].name.lastIndexOf(".")+1),es.indexOf(t.toLowerCase())>=0||ja({code:na.MESSAGE_IMAGE_TYPES_LIMIT,message:aa.MESSAGE_IMAGE_TYPES_LIMIT})}},{key:"_checkImageSize",value:function(e){var t=0;return 0===(t=te?e.size:e.files[0].size)?ja({code:na.MESSAGE_FILE_IS_EMPTY,message:"".concat(aa.MESSAGE_FILE_IS_EMPTY)}):t<20971520||ja({code:na.MESSAGE_IMAGE_SIZE_LIMIT,message:"".concat(aa.MESSAGE_IMAGE_SIZE_LIMIT)})}},{key:"doUploadFile",value:function(e){var t=null;return e.file?e.file.files[0].size>104857600?ja(t={code:na.MESSAGE_FILE_SIZE_LIMIT,message:aa.MESSAGE_FILE_SIZE_LIMIT}):0===e.file.files[0].size?(t={code:na.MESSAGE_FILE_IS_EMPTY,message:"".concat(aa.MESSAGE_FILE_IS_EMPTY)},ja(t)):(this._setUploadFileType(ss),this.uploadByCOS(e)):ja(t={code:na.MESSAGE_FILE_SELECT_FILE_FIRST,message:aa.MESSAGE_FILE_SELECT_FILE_FIRST})}},{key:"doUploadVideo",value:function(e){return e.file.videoFile.size>104857600?ja({code:na.MESSAGE_VIDEO_SIZE_LIMIT,message:"".concat(aa.MESSAGE_VIDEO_SIZE_LIMIT)}):0===e.file.videoFile.size?ja({code:na.MESSAGE_FILE_IS_EMPTY,message:"".concat(aa.MESSAGE_FILE_IS_EMPTY)}):-1===ts.indexOf(e.file.videoFile.type)?ja({code:na.MESSAGE_VIDEO_TYPES_LIMIT,message:"".concat(aa.MESSAGE_VIDEO_TYPES_LIMIT)}):(this._setUploadFileType(ns),te?this.handleVideoUpload({file:e.file.videoFile,onProgress:e.onProgress}):oe?this.handleVideoUpload(e):void 0)}},{key:"handleVideoUpload",value:function(e){var t=this;return new Promise((function(o,n){t.uploadByCOS(e).then((function(e){o(e)})).catch((function(){t.uploadByCOS(e).then((function(e){o(e)})).catch((function(){n(new Ba({code:na.MESSAGE_VIDEO_UPLOAD_FAIL,message:aa.MESSAGE_VIDEO_UPLOAD_FAIL}))}))}))}))}},{key:"doUploadAudio",value:function(e){return e.file?e.file.size>20971520?ja(new Ba({code:na.MESSAGE_AUDIO_SIZE_LIMIT,message:"".concat(aa.MESSAGE_AUDIO_SIZE_LIMIT)})):0===e.file.size?ja(new Ba({code:na.MESSAGE_FILE_IS_EMPTY,message:"".concat(aa.MESSAGE_FILE_IS_EMPTY)})):(this._setUploadFileType(as),this.uploadByCOS(e)):ja(new Ba({code:na.MESSAGE_AUDIO_UPLOAD_FAIL,message:aa.MESSAGE_AUDIO_UPLOAD_FAIL}))}},{key:"uploadByCOS",value:function(e){var t=this,o="".concat(this._className,".uploadByCOS");if(!ot(this._cosUploadMethod))return we.warn("".concat(o," 没有检测到上传插件,将无法发送图片、音频、视频、文件等类型的消息。详细请参考 https://web.sdk.qcloud.com/im/doc/zh-cn/SDK.html#registerPlugin")),ja({code:na.COS_UNDETECTED,message:aa.COS_UNDETECTED});if(this.timUploadPlugin)return this._uploadWithPreSigUrl(e);var n=new va(ya.UPLOAD),a=Date.now(),s=this._getFile(e);return new Promise((function(r,i){var c=te?t._createCosOptionsWXMiniApp(e):t._createCosOptionsWeb(e),u=t;t._cosUploadMethod(c,(function(e,c){var l=Object.create(null);if(c){if(e||Qe(c.files)&&c.files[0].error){var d=new Ba({code:na.MESSAGE_FILE_UPLOAD_FAIL,message:aa.MESSAGE_FILE_UPLOAD_FAIL});return n.setError(d,!0,t.getNetworkType()).end(),we.log("".concat(o," failed. error:"),c.files[0].error),403===c.files[0].error.statusCode&&(we.warn("".concat(o," failed. cos AccessKeyId was invalid, regain auth key!")),t._getAuthorizationKey()),void i(d)}l.fileName=s.name,l.fileSize=s.size,l.fileType=s.type.slice(s.type.indexOf("/")+1).toLowerCase(),l.location=te?c.Location:c.files[0].data.Location;var p=Date.now()-a,g=u._formatFileSize(s.size),_=u._formatSpeed(1e3*s.size/p),h="size:".concat(g," time:").concat(p,"ms speed:").concat(_);we.log("".concat(o," success. name:").concat(s.name," ").concat(h)),r(l);var f=t.getModule(Co);return f.addCost(da,p),f.addFileSize(da,s.size),void n.setNetworkType(t.getNetworkType()).setMessage(h).end()}var m=new Ba({code:na.MESSAGE_FILE_UPLOAD_FAIL,message:aa.MESSAGE_FILE_UPLOAD_FAIL});n.setError(m,!0,u.getNetworkType()).end(),we.warn("".concat(o," failed. error:"),e),403===e.statusCode&&(we.warn("".concat(o," failed. cos AccessKeyId was invalid, regain auth key!")),t._getAuthorizationKey()),i(m)}))}))}},{key:"_uploadWithPreSigUrl",value:function(e){var t=this,o="".concat(this._className,"._uploadWithPreSigUrl"),n=this._getFile(e);return this._createCosOptionsPreSigUrl(e).then((function(e){return new Promise((function(a,s){var r=new va(ya.UPLOAD),i=e.requestSnapshotUrl,c=void 0===i?void 0:i,u=g(e,Js),l=Date.now();t._cosUploadMethod(u,(function(e,i){var u=Object.create(null);if(e||403===i.statusCode){var d=new Ba({code:na.MESSAGE_FILE_UPLOAD_FAIL,message:aa.MESSAGE_FILE_UPLOAD_FAIL});return r.setError(d,!0,t.getNetworkType()).end(),we.log("".concat(o," failed, error:"),e),void s(d)}var p=i.data.location||"";t.isPrivateNetWork()||0!==p.indexOf("https://")&&0!==p.indexOf("http://")||(p=p.split("//")[1]),u.fileName=n.name,u.fileSize=n.size,u.fileType=n.type.slice(n.type.indexOf("/")+1).toLowerCase(),u.location=p;var g=Date.now()-l,_=t._formatFileSize(n.size),h=t._formatSpeed(1e3*n.size/g),f="size:".concat(_,",time:").concat(g,"ms,speed:").concat(h," res:").concat(JSON.stringify(i.data));we.log("".concat(o," success name:").concat(n.name,",").concat(f)),r.setNetworkType(t.getNetworkType()).setMessage(f).end();var m=t.getModule(Co);if(m.addCost(da,g),m.addFileSize(da,n.size),!Vt(c))return t._getSnapshotInfoByUrl(c).then((function(e){u.snapshotInfo=e,a(u)}));a(u)}))}))}))}},{key:"_getFile",value:function(e){var t=null;return te?t=Z&&Qe(e.file.files)?e.file.files[0]:e.file:oe&&(t=e.file.files[0]),t}},{key:"_formatFileSize",value:function(e){return e<1024?e+"B":e<1048576?Math.floor(e/1024)+"KB":Math.floor(e/1048576)+"MB"}},{key:"_formatSpeed",value:function(e){return e<=1048576?Pt(e/1024,1)+"KB/s":Pt(e/1048576,1)+"MB/s"}},{key:"_createCosOptionsWeb",value:function(e){var t=e.file.files[0].name,o=t.slice(t.lastIndexOf(".")),n=this._genFileName("".concat(dt(999999)).concat(o));return{files:[{Bucket:"".concat(this.bucketName,"-").concat(this.appid),Region:this.region,Key:"".concat(this.directory,"/").concat(n),Body:e.file.files[0]}],SliceSize:1048576,onProgress:function(t){if("function"==typeof e.onProgress)try{e.onProgress(t.percent)}catch(o){we.warn("onProgress callback error:",o)}},onFileFinish:function(e,t,o){}}}},{key:"_createCosOptionsWXMiniApp",value:function(e){var t=this._getFile(e),o=this._genFileName(t.name),n=t.url;return{Bucket:"".concat(this.bucketName,"-").concat(this.appid),Region:this.region,Key:"".concat(this.directory,"/").concat(o),FilePath:n,onProgress:function(t){if(we.log(JSON.stringify(t)),"function"==typeof e.onProgress)try{e.onProgress(t.percent)}catch(o){we.warn("onProgress callback error:",o)}}}}},{key:"_createCosOptionsPreSigUrl",value:function(e){var t=this,o="",n="",a=0;if(te){var s=this._getFile(e);o=this._genFileName(s.name),n=s.url,a=1}else{var r=e.file.files[0].name,i=r.slice(r.lastIndexOf("."));o=this._genFileName("".concat(dt(999999)).concat(i)),n=e.file.files[0],a=0}return this._getCosPreSigUrl({fileType:this.uploadFileType,fileName:o,uploadMethod:a,duration:this.duration}).then((function(a){var s=a.uploadUrl,r=a.downloadUrl,i=a.requestSnapshotUrl,c=void 0===i?void 0:i;return{url:s,fileType:t.uploadFileType,fileName:o,resources:n,downloadUrl:r,requestSnapshotUrl:c,onProgress:function(t){if("function"==typeof e.onProgress)try{e.onProgress(t.percent)}catch(o){we.warn("onProgress callback error:",o),we.error(o)}}}}))}},{key:"_genFileName",value:function(e){return"".concat(Ot(),"-").concat(e)}},{key:"_setUploadFileType",value:function(e){this.uploadFileType=e}},{key:"_getSnapshotInfoByUrl",value:function(e){var t=this,o=new va(ya.GET_SNAPSHOT_INFO);return this.request({protocolName:qn,requestData:{platform:this.getPlatform(),coverName:this._genFileName(dt(99999)),requestSnapshotUrl:e}}).then((function(e){var t=(e.data||{}).snapshotUrl;return o.setMessage("snapshotUrl:".concat(t)).end(),Vt(t)?{}:At(t).then((function(e){return{snapshotUrl:t,snapshotWidth:e.width,snapshotHeight:e.height}}))})).catch((function(e){return we.warn("".concat(t._className,"._getSnapshotInfoByUrl failed. error:"),e),o.setCode(e.errorCode).setMessage(e.errorInfo).end(),{}}))}},{key:"reset",value:function(){we.log("".concat(this._className,".reset"))}}]),a}(Do),Qs=["downloadKey","pbDownloadKey","messageList"],Zs=function(){function e(t){n(this,e),this._className="MergerMessageHandler",this._messageModule=t}return s(e,[{key:"uploadMergerMessage",value:function(e,t){var o=this;we.debug("".concat(this._className,".uploadMergerMessage message:"),e,"messageBytes:".concat(t));var n=e.payload.messageList,a=n.length,s=new va(ya.UPLOAD_MERGER_MESSAGE);return this._messageModule.request({protocolName:Yn,requestData:{messageList:n}}).then((function(e){we.debug("".concat(o._className,".uploadMergerMessage ok. response:"),e.data);var n=e.data,r=n.pbDownloadKey,i=n.downloadKey,c={pbDownloadKey:r,downloadKey:i,messageNumber:a};return s.setNetworkType(o._messageModule.getNetworkType()).setMessage("".concat(a,"-").concat(t,"-").concat(i)).end(),c})).catch((function(e){throw we.warn("".concat(o._className,".uploadMergerMessage failed. error:"),e),o._messageModule.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];s.setError(e,n,a).end()})),e}))}},{key:"downloadMergerMessage",value:function(e){var o=this;we.debug("".concat(this._className,".downloadMergerMessage message:"),e);var n=e.payload.downloadKey,a=new va(ya.DOWNLOAD_MERGER_MESSAGE);return a.setMessage("downloadKey:".concat(n)),this._messageModule.request({protocolName:jn,requestData:{downloadKey:n}}).then((function(n){if(we.debug("".concat(o._className,".downloadMergerMessage ok. response:"),n.data),ot(e.clearElement)){var s=e.payload,r=(s.downloadKey,s.pbDownloadKey,s.messageList,g(s,Qs));e.clearElement(),e.setElement({type:e.type,content:t({messageList:n.data.messageList},r)})}else{var i=[];n.data.messageList.forEach((function(e){if(!Vt(e)){var t=new Ga(e);i.push(t)}})),e.payload.messageList=i,e.payload.downloadKey="",e.payload.pbDownloadKey=""}return a.setNetworkType(o._messageModule.getNetworkType()).end(),e})).catch((function(e){throw we.warn("".concat(o._className,".downloadMergerMessage failed. key:").concat(n," error:"),e),o._messageModule.probeNetwork().then((function(t){var o=m(t,2),n=o[0],s=o[1];a.setError(e,n,s).end()})),e}))}},{key:"createMergerMessagePack",value:function(e,t,o){return e.conversationType===D.CONV_C2C?this._createC2CMergerMessagePack(e,t,o):this._createGroupMergerMessagePack(e,t,o)}},{key:"_createC2CMergerMessagePack",value:function(e,t,o){var n=null;t&&(t.offlinePushInfo&&(n=t.offlinePushInfo),!0===t.onlineUserOnly&&(n?n.disablePush=!0:n={disablePush:!0}));var a="";ze(e.cloudCustomData)&&e.cloudCustomData.length>0&&(a=e.cloudCustomData);var s=o.pbDownloadKey,r=o.downloadKey,i=o.messageNumber,c=e.payload,u=c.title,l=c.abstractList,d=c.compatibleText,p=this._messageModule.getModule(no);return{protocolName:Go,tjgID:this._messageModule.generateTjgID(e),requestData:{fromAccount:this._messageModule.getMyUserID(),toAccount:e.to,msgBody:[{msgType:e.type,msgContent:{pbDownloadKey:s,downloadKey:r,title:u,abstractList:l,compatibleText:d,messageNumber:i}}],cloudCustomData:a,msgSeq:e.sequence,msgRandom:e.random,msgLifeTime:p&&p.isOnlineMessage(e,t)?0:void 0,offlinePushInfo:n?{pushFlag:!0===n.disablePush?1:0,title:n.title||"",desc:n.description||"",ext:n.extension||"",apnsInfo:{badgeMode:!0===n.ignoreIOSBadge?1:0},androidInfo:{OPPOChannelID:n.androidOPPOChannelID||""}}:void 0}}}},{key:"_createGroupMergerMessagePack",value:function(e,t,o){var n=null;t&&t.offlinePushInfo&&(n=t.offlinePushInfo);var a="";ze(e.cloudCustomData)&&e.cloudCustomData.length>0&&(a=e.cloudCustomData);var s=o.pbDownloadKey,r=o.downloadKey,i=o.messageNumber,c=e.payload,u=c.title,l=c.abstractList,d=c.compatibleText,p=this._messageModule.getModule(ao);return{protocolName:Po,tjgID:this._messageModule.generateTjgID(e),requestData:{fromAccount:this._messageModule.getMyUserID(),groupID:e.to,msgBody:[{msgType:e.type,msgContent:{pbDownloadKey:s,downloadKey:r,title:u,abstractList:l,compatibleText:d,messageNumber:i}}],random:e.random,priority:e.priority,clientSequence:e.clientSequence,groupAtInfo:void 0,cloudCustomData:a,onlineOnlyFlag:p&&p.isOnlineMessage(e,t)?1:0,offlinePushInfo:n?{pushFlag:!0===n.disablePush?1:0,title:n.title||"",desc:n.description||"",ext:n.extension||"",apnsInfo:{badgeMode:!0===n.ignoreIOSBadge?1:0},androidInfo:{OPPOChannelID:n.androidOPPOChannelID||""}}:void 0,clientTime:e.clientTime,needReadReceipt:!0!==e.needReadReceipt||p.isMessageFromOrToAVChatroom(e.to)?0:1}}}}]),e}(),er={ERR_SVR_COMM_SENSITIVE_TEXT:80001,ERR_SVR_COMM_BODY_SIZE_LIMIT:80002,OPEN_SERVICE_OVERLOAD_ERROR:60022,ERR_SVR_MSG_PKG_PARSE_FAILED:20001,ERR_SVR_MSG_INTERNAL_AUTH_FAILED:20002,ERR_SVR_MSG_INVALID_ID:20003,ERR_SVR_MSG_PUSH_DENY:20006,ERR_SVR_MSG_IN_PEER_BLACKLIST:20007,ERR_SVR_MSG_BOTH_NOT_FRIEND:20009,ERR_SVR_MSG_NOT_PEER_FRIEND:20010,ERR_SVR_MSG_NOT_SELF_FRIEND:20011,ERR_SVR_MSG_SHUTUP_DENY:20012,ERR_SVR_GROUP_INVALID_PARAMETERS:10004,ERR_SVR_GROUP_PERMISSION_DENY:10007,ERR_SVR_GROUP_NOT_FOUND:10010,ERR_SVR_GROUP_INVALID_GROUPID:10015,ERR_SVR_GROUP_REJECT_FROM_THIRDPARTY:10016,ERR_SVR_GROUP_SHUTUP_DENY:10017,MESSAGE_SEND_FAIL:2100,OVER_FREQUENCY_LIMIT:2996},tr=[na.MESSAGE_ONPROGRESS_FUNCTION_ERROR,na.MESSAGE_IMAGE_SELECT_FILE_FIRST,na.MESSAGE_IMAGE_TYPES_LIMIT,na.MESSAGE_FILE_IS_EMPTY,na.MESSAGE_IMAGE_SIZE_LIMIT,na.MESSAGE_FILE_SELECT_FILE_FIRST,na.MESSAGE_FILE_SIZE_LIMIT,na.MESSAGE_VIDEO_SIZE_LIMIT,na.MESSAGE_VIDEO_TYPES_LIMIT,na.MESSAGE_AUDIO_UPLOAD_FAIL,na.MESSAGE_AUDIO_SIZE_LIMIT,na.COS_UNDETECTED];var or=function(e){i(o,e);var t=f(o);function o(e){var a;return n(this,o),(a=t.call(this,e))._className="MessageModule",a._messageOptionsMap=new Map,a._mergerMessageHandler=new Zs(_(a)),a}return s(o,[{key:"createTextMessage",value:function(e){var t=e.to,o=e.payload.atUserList,n=void 0===o?[]:o;if((Et({groupID:t})||Tt(t))&&n.includes(D.MSG_AT_ALL))return ja({code:na.MESSAGE_AT_TYPE_INVALID,message:aa.MESSAGE_AT_TYPE_INVALID});var a=this.getMyUserID();e.currentUser=a,e.senderTinyID=this.getMyTinyID();var s=new wa(e),r="string"==typeof e.payload?e.payload:e.payload.text,i=new Ia({text:r}),c=this._getNickAndAvatarByUserID(a);return s.setElement(i),s.setNickAndAvatar(c),s.setNameCard(this._getNameCardByGroupID(s)),s}},{key:"createImageMessage",value:function(e){var t=this.getMyUserID();e.currentUser=t,e.senderTinyID=this.getMyTinyID();var o=new wa(e);if(te){var n=e.payload.file;if(je(n))return void we.warn("小程序环境下调用 createImageMessage 接口时,payload.file 不支持传入 File 对象");var a=n.tempFilePaths[0],s={url:a,name:a.slice(a.lastIndexOf("/")+1),size:n.tempFiles&&n.tempFiles[0].size||1,type:a.slice(a.lastIndexOf(".")+1).toLowerCase()};e.payload.file=s}else if(oe)if(je(e.payload.file)){var r=e.payload.file;e.payload.file={files:[r]}}else if(Xe(e.payload.file)&&"undefined"!=typeof uni){var i=e.payload.file.tempFiles[0];e.payload.file={files:[i]}}var c=new Ea({imageFormat:be.UNKNOWN,uuid:this._generateUUID(),file:e.payload.file}),u=this._getNickAndAvatarByUserID(t);return o.setElement(c),o.setNickAndAvatar(u),o.setNameCard(this._getNameCardByGroupID(o)),this._messageOptionsMap.set(o.clientSequence,e),o}},{key:"createAudioMessage",value:function(e){if(te){var t=e.payload.file;if(te){var o={url:t.tempFilePath,name:t.tempFilePath.slice(t.tempFilePath.lastIndexOf("/")+1),size:t.fileSize,second:parseInt(t.duration)/1e3,type:t.tempFilePath.slice(t.tempFilePath.lastIndexOf(".")+1).toLowerCase()};e.payload.file=o}var n=this.getMyUserID();e.currentUser=n,e.senderTinyID=this.getMyTinyID();var a=new wa(e),s=new Ca({second:Math.floor(t.duration/1e3),size:t.fileSize,url:t.tempFilePath,uuid:this._generateUUID()}),r=this._getNickAndAvatarByUserID(n);return a.setElement(s),a.setNickAndAvatar(r),a.setNameCard(this._getNameCardByGroupID(a)),this._messageOptionsMap.set(a.clientSequence,e),a}we.warn("createAudioMessage 目前只支持小程序环境下发语音消息")}},{key:"createVideoMessage",value:function(e){var t=this.getMyUserID();e.currentUser=t,e.senderTinyID=this.getMyTinyID(),e.payload.file.thumbUrl="https://web.sdk.qcloud.com/im/assets/images/transparent.png",e.payload.file.thumbSize=1668;var o={};if(te){if(Q)return void we.warn("createVideoMessage 不支持在支付宝小程序环境下使用");if(je(e.payload.file))return void we.warn("小程序环境下调用 createVideoMessage 接口时,payload.file 不支持传入 File 对象");var n=e.payload.file;o.url=n.tempFilePath,o.name=n.tempFilePath.slice(n.tempFilePath.lastIndexOf("/")+1),o.size=n.size,o.second=n.duration,o.type=n.tempFilePath.slice(n.tempFilePath.lastIndexOf(".")+1).toLowerCase()}else if(oe){if(je(e.payload.file)){var a=e.payload.file;e.payload.file.files=[a]}else if(Xe(e.payload.file)&&"undefined"!=typeof uni){var s=e.payload.file.tempFile;e.payload.file.files=[s]}var r=e.payload.file;o.url=window.URL.createObjectURL(r.files[0]),o.name=r.files[0].name,o.size=r.files[0].size,o.second=r.files[0].duration||0,o.type=r.files[0].type.split("/")[1]}e.payload.file.videoFile=o;var i=new wa(e),c=new La({videoFormat:o.type,videoSecond:Pt(o.second,0),videoSize:o.size,remoteVideoUrl:"",videoUrl:o.url,videoUUID:this._generateUUID(),thumbUUID:this._generateUUID(),thumbWidth:e.payload.file.width||200,thumbHeight:e.payload.file.height||200,thumbUrl:e.payload.file.thumbUrl,thumbSize:e.payload.file.thumbSize,thumbFormat:e.payload.file.thumbUrl.slice(e.payload.file.thumbUrl.lastIndexOf(".")+1).toLowerCase()}),u=this._getNickAndAvatarByUserID(t);return i.setElement(c),i.setNickAndAvatar(u),i.setNameCard(this._getNameCardByGroupID(i)),this._messageOptionsMap.set(i.clientSequence,e),i}},{key:"createCustomMessage",value:function(e){var t=this.getMyUserID();e.currentUser=t,e.senderTinyID=this.getMyTinyID();var o=new wa(e),n=new Ra({data:e.payload.data,description:e.payload.description,extension:e.payload.extension}),a=this._getNickAndAvatarByUserID(t);return o.setElement(n),o.setNickAndAvatar(a),o.setNameCard(this._getNameCardByGroupID(o)),o}},{key:"createFaceMessage",value:function(e){var t=this.getMyUserID();e.currentUser=t,e.senderTinyID=this.getMyTinyID();var o=new wa(e),n=new Ta(e.payload),a=this._getNickAndAvatarByUserID(t);return o.setElement(n),o.setNickAndAvatar(a),o.setNameCard(this._getNameCardByGroupID(o)),o}},{key:"createMergerMessage",value:function(e){var t=this.getMyUserID();e.currentUser=t,e.senderTinyID=this.getMyTinyID();var o=this._getNickAndAvatarByUserID(t),n=new wa(e),a=new Pa(e.payload);return n.setElement(a),n.setNickAndAvatar(o),n.setNameCard(this._getNameCardByGroupID(n)),n.setRelayFlag(!0),n}},{key:"createForwardMessage",value:function(e){var t=e.to,o=e.conversationType,n=e.priority,a=e.payload,s=e.needReadReceipt,r=this.getMyUserID(),i=this._getNickAndAvatarByUserID(r);if(a.type===D.MSG_GRP_TIP)return ja(new Ba({code:na.MESSAGE_FORWARD_TYPE_INVALID,message:aa.MESSAGE_FORWARD_TYPE_INVALID}));var c={to:t,conversationType:o,conversationID:"".concat(o).concat(t),priority:n,isPlaceMessage:0,status:xt.UNSEND,currentUser:r,senderTinyID:this.getMyTinyID(),cloudCustomData:e.cloudCustomData||a.cloudCustomData||"",needReadReceipt:s},u=new wa(c);return u.setElement(a.getElements()[0]),u.setNickAndAvatar(i),u.setNameCard(this._getNameCardByGroupID(a)),u.setRelayFlag(!0),u}},{key:"downloadMergerMessage",value:function(e){return this._mergerMessageHandler.downloadMergerMessage(e)}},{key:"createFileMessage",value:function(e){if(!te||Z){if(oe||Z)if(je(e.payload.file)){var t=e.payload.file;e.payload.file={files:[t]}}else if(Xe(e.payload.file)&&"undefined"!=typeof uni){var o=e.payload.file,n=o.tempFiles,a=o.files,s=null;Qe(n)?s=n[0]:Qe(a)&&(s=a[0]),e.payload.file={files:[s]}}var r=this.getMyUserID();e.currentUser=r,e.senderTinyID=this.getMyTinyID();var i=new wa(e),c=new Oa({uuid:this._generateUUID(),file:e.payload.file}),u=this._getNickAndAvatarByUserID(r);return i.setElement(c),i.setNickAndAvatar(u),i.setNameCard(this._getNameCardByGroupID(i)),this._messageOptionsMap.set(i.clientSequence,e),i}we.warn("小程序目前不支持选择文件, createFileMessage 接口不可用!")}},{key:"createLocationMessage",value:function(e){var t=this.getMyUserID();e.currentUser=t,e.senderTinyID=this.getMyTinyID();var o=new wa(e),n=new ka(e.payload),a=this._getNickAndAvatarByUserID(t);return o.setElement(n),o.setNickAndAvatar(a),o.setNameCard(this._getNameCardByGroupID(o)),o}},{key:"_onCannotFindModule",value:function(){return ja({code:na.CANNOT_FIND_MODULE,message:aa.CANNOT_FIND_MODULE})}},{key:"sendMessageInstance",value:function(e,t){var o,n=this,a=null;switch(e.conversationType){case D.CONV_C2C:if(!(a=this.getModule(no)))return this._onCannotFindModule();break;case D.CONV_GROUP:if(!(a=this.getModule(ao)))return this._onCannotFindModule();if(Et({groupID:e.to})){var s=a.getLocalGroupProfile(e.to);if(s&&s.isSupportTopic)return ja({code:na.MESSAGE_SEND_GROUP_WITH_TOPIC_FAIL,message:aa.MESSAGE_SEND_GROUP_WITH_TOPIC_FAIL});if(!Ze(t)&&!Ze(t.messageControlInfo))return ja({code:na.MESSAGE_CONTROL_INFO_FAIL,message:aa.MESSAGE_CONTROL_INFO_FAIL})}break;default:return ja({code:na.MESSAGE_SEND_INVALID_CONVERSATION_TYPE,message:aa.MESSAGE_SEND_INVALID_CONVERSATION_TYPE})}var r=this.getModule(ho),i=this.getModule(ao);return r.upload(e).then((function(){n._getSendMessageSpecifiedKey(e)===la&&n.getModule(Co).addSuccessCount(da);return i.guardForAVChatRoom(e).then((function(){if(!e.isSendable())return ja({code:na.MESSAGE_FILE_URL_IS_EMPTY,message:aa.MESSAGE_FILE_URL_IS_EMPTY});n._addSendMessageTotalCount(e),o=Date.now();var s=function(e){var t="utf-8";oe&&document&&(t=document.charset.toLowerCase());var o,n,a=0;if(n=e.length,"utf-8"===t||"utf8"===t)for(var s=0;s7e3?n._mergerMessageHandler.uploadMergerMessage(e,s).then((function(o){var a=n._mergerMessageHandler.createMergerMessagePack(e,t,o);return n.request(a)})):(n.getModule(co).setMessageRandom(e),e.conversationType===D.CONV_C2C||e.conversationType===D.CONV_GROUP?a.sendMessage(e,t):void 0)})).then((function(s){var r=s.data,i=r.time,c=r.sequence,u=r.readReceiptCode;$e(u)&&0!==u&&(new va(ya.SEND_MESSAGE_WITH_RECEIPT).setMessage("from:".concat(e.from," to:").concat(e.to," sequence:").concat(c," readReceiptCode:").concat(u)).end(),we.warn("".concat(n._className,".sendMessageInstance readReceiptCode:").concat(u," message:").concat(Ha[u])));n._addSendMessageSuccessCount(e,o),n._messageOptionsMap.delete(e.clientSequence);var l=n.getModule(co);e.status=xt.SUCCESS,e.time=i;var d=!1;if(e.conversationType===D.CONV_GROUP)e.sequence=c;else if(e.conversationType===D.CONV_C2C){var p=l.getLatestMessageSentByMe(e.conversationID);if(p){var g=p.nick,_=p.avatar;g===e.nick&&_===e.avatar||(d=!0)}}if(l.appendToMessageList(e),d&&l.modifyMessageSentByMe({conversationID:e.conversationID,latestNick:e.nick,latestAvatar:e.avatar}),a.isOnlineMessage(e,t))e._onlineOnlyFlag=!0;else{var h=e;Xe(t)&&Xe(t.messageControlInfo)&&(!0===t.messageControlInfo.excludedFromLastMessage&&(e._isExcludedFromLastMessage=!0,h=""),!0===t.messageControlInfo.excludedFromUnreadCount&&(e._isExcludedFromUnreadCount=!0));var f=e.conversationType;if(Tt(e.to))f=D.CONV_TOPIC,n.getModule(io).onMessageSent({groupID:bt(e.to),topicID:e.to,lastMessage:h});l.onMessageSent({conversationOptionsList:[{conversationID:e.conversationID,unreadCount:0,type:f,subType:e.conversationSubType,lastMessage:h}]})}return e.getRelayFlag()||"TIMImageElem"!==e.type||kt(e.payload.imageInfoArray),ba({message:e})}))})).catch((function(t){return n._onSendMessageFailed(e,t)}))}},{key:"_onSendMessageFailed",value:function(e,t){e.status=xt.FAIL,this.getModule(co).deleteMessageRandom(e),this._addSendMessageFailCountOnUser(e,t);var o=new va(ya.SEND_MESSAGE);return o.setMessage("tjg_id:".concat(this.generateTjgID(e)," type:").concat(e.type," from:").concat(e.from," to:").concat(e.to)),this.probeNetwork().then((function(e){var n=m(e,2),a=n[0],s=n[1];o.setError(t,a,s).end()})),we.error("".concat(this._className,"._onSendMessageFailed error:"),t),ja(new Ba({code:t&&t.code?t.code:na.MESSAGE_SEND_FAIL,message:t&&t.message?t.message:aa.MESSAGE_SEND_FAIL,data:{message:e}}))}},{key:"_getSendMessageSpecifiedKey",value:function(e){if([D.MSG_IMAGE,D.MSG_AUDIO,D.MSG_VIDEO,D.MSG_FILE].includes(e.type))return la;if(e.conversationType===D.CONV_C2C)return ia;if(e.conversationType===D.CONV_GROUP){var t=this.getModule(ao).getLocalGroupProfile(e.to);if(!t)return;var o=t.type;return It(o)?ua:ca}}},{key:"_addSendMessageTotalCount",value:function(e){var t=this._getSendMessageSpecifiedKey(e);t&&this.getModule(Co).addTotalCount(t)}},{key:"_addSendMessageSuccessCount",value:function(e,t){var o=Math.abs(Date.now()-t),n=this._getSendMessageSpecifiedKey(e);if(n){var a=this.getModule(Co);a.addSuccessCount(n),a.addCost(n,o)}}},{key:"_addSendMessageFailCountOnUser",value:function(e,t){var o,n,a=t.code,s=void 0===a?-1:a,r=this.getModule(Co),i=this._getSendMessageSpecifiedKey(e);i===la&&(o=s,n=!1,tr.includes(o)&&(n=!0),n)?r.addFailedCountOfUserSide(da):function(e){var t=!1;return Object.values(er).includes(e)&&(t=!0),(e>=120001&&e<=13e4||e>=10100&&e<=10200)&&(t=!0),t}(s)&&i&&r.addFailedCountOfUserSide(i)}},{key:"resendMessage",value:function(e){return e.isResend=!0,e.status=xt.UNSEND,e.random=dt(),e.clientTime=ke(),e.generateMessageID(),this.sendMessageInstance(e)}},{key:"revokeMessage",value:function(e){var t=this,o=null;if(e.conversationType===D.CONV_C2C){if(!(o=this.getModule(no)))return this._onCannotFindModule()}else if(e.conversationType===D.CONV_GROUP&&!(o=this.getModule(ao)))return this._onCannotFindModule();var n=new va(ya.REVOKE_MESSAGE);return n.setMessage("tjg_id:".concat(this.generateTjgID(e)," type:").concat(e.type," from:").concat(e.from," to:").concat(e.to)),o.revokeMessage(e).then((function(o){var a=o.data.recallRetList;if(!Vt(a)&&0!==a[0].retCode){var s=new Ba({code:a[0].retCode,message:Ha[a[0].retCode]||aa.MESSAGE_REVOKE_FAIL,data:{message:e}});return n.setCode(s.code).setMoreMessage(s.message).end(),ja(s)}return we.info("".concat(t._className,".revokeMessage ok. ID:").concat(e.ID)),e.isRevoked=!0,n.end(),t.getModule(co).onMessageRevoked([e]),ba({message:e})})).catch((function(o){t.probeNetwork().then((function(e){var t=m(e,2),a=t[0],s=t[1];n.setError(o,a,s).end()}));var a=new Ba({code:o&&o.code?o.code:na.MESSAGE_REVOKE_FAIL,message:o&&o.message?o.message:aa.MESSAGE_REVOKE_FAIL,data:{message:e}});return we.warn("".concat(t._className,".revokeMessage failed. error:"),o),ja(a)}))}},{key:"deleteMessage",value:function(e){var t=this,o=null,n=e[0],a=n.conversationID,s="",r=[],i=[];if(n.conversationType===D.CONV_C2C)o=this.getModule(no),s=a.replace(D.CONV_C2C,""),e.forEach((function(e){e&&e.status===xt.SUCCESS&&e.conversationID===a&&(e._onlineOnlyFlag||r.push("".concat(e.sequence,"_").concat(e.random,"_").concat(e.time)),i.push(e))}));else if(n.conversationType===D.CONV_GROUP)o=this.getModule(ao),s=a.replace(D.CONV_GROUP,""),e.forEach((function(e){e&&e.status===xt.SUCCESS&&e.conversationID===a&&(e._onlineOnlyFlag||r.push("".concat(e.sequence)),i.push(e))}));else if(n.conversationType===D.CONV_SYSTEM)return ja({code:na.CANNOT_DELETE_GROUP_SYSTEM_NOTICE,message:aa.CANNOT_DELETE_GROUP_SYSTEM_NOTICE});if(!o)return this._onCannotFindModule();if(0===r.length)return this._onMessageDeleted(i);r.length>30&&(r=r.slice(0,30),i=i.slice(0,30));var c=new va(ya.DELETE_MESSAGE);return c.setMessage("to:".concat(s," count:").concat(r.length)),o.deleteMessage({to:s,keyList:r}).then((function(e){return c.end(),we.info("".concat(t._className,".deleteMessage ok")),t._onMessageDeleted(i)})).catch((function(e){t.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];c.setError(e,n,a).end()})),we.warn("".concat(t._className,".deleteMessage failed. error:"),e);var o=new Ba({code:e&&e.code?e.code:na.MESSAGE_DELETE_FAIL,message:e&&e.message?e.message:aa.MESSAGE_DELETE_FAIL});return ja(o)}))}},{key:"_onMessageDeleted",value:function(e){return this.getModule(co).onMessageDeleted(e),Ya({messageList:e})}},{key:"modifyRemoteMessage",value:function(e){var t=this,o=null,n=e.conversationType,a=e.to;if(this.getModule(ao).isMessageFromOrToAVChatroom(a))return ja({code:na.MESSAGE_MODIFY_DISABLED_IN_AVCHATROOM,message:aa.MESSAGE_MODIFY_DISABLED_IN_AVCHATROOM,data:{message:e}});n===D.CONV_C2C?o=this.getModule(no):n===D.CONV_GROUP&&(o=this.getModule(ao));var s=new va(ya.MODIFY_MESSAGE);return s.setMessage("to:".concat(a)),o.modifyRemoteMessage(e).then((function(o){s.end(),we.info("".concat(t._className,".modifyRemoteMessage ok"));var n=t._onModifyRemoteMessageResp(e,o.data);return ba({message:n})})).catch((function(o){if(s.setCode(o.code).setMoreMessage(o.message).end(),we.warn("".concat(t._className,".modifyRemoteMessage failed. error:"),o),20027===o.code){var n=t._onModifyRemoteMessageResp(e,o.data);return ja({code:na.MESSAGE_MODIFY_CONFLICT,message:aa.MESSAGE_MODIFY_CONFLICT,data:{message:n}})}return ja({code:o.code,message:o.message,data:{message:e}})}))}},{key:"_onModifyRemoteMessageResp",value:function(e,t){we.debug("".concat(this._className,"._onModifyRemoteMessageResp options:"),t);var o=e.conversationType,n=e.from,a=e.to,s=e.random,r=e.sequence,i=e.time,c=t.elements,u=t.messageVersion,l=t.cloudCustomData,d=void 0===l?"":l;return this.getModule(co).onMessageModified({conversationType:o,from:n,to:a,time:i,random:s,sequence:r,elements:c,cloudCustomData:d,messageVersion:u})}},{key:"_generateUUID",value:function(){var e=this.getModule(uo);return"".concat(e.getSDKAppID(),"-").concat(e.getUserID(),"-").concat(function(){for(var e="",t=32;t>0;--t)e+=pt[Math.floor(Math.random()*gt)];return e}())}},{key:"getMessageOption",value:function(e){return this._messageOptionsMap.get(e)}},{key:"_getNickAndAvatarByUserID",value:function(e){return this.getModule(oo).getNickAndAvatarByUserID(e)}},{key:"_getNameCardByGroupID",value:function(e){if(e.conversationType===D.CONV_GROUP){var t=this.getModule(ao);if(t)return t.getMyNameCardByGroupID(e.to)}return""}},{key:"reset",value:function(){we.log("".concat(this._className,".reset")),this._messageOptionsMap.clear()}}]),o}(Do),nr=function(e){i(o,e);var t=f(o);function o(e){var a;return n(this,o),(a=t.call(this,e))._className="PluginModule",a.plugins={},a}return s(o,[{key:"registerPlugin",value:function(e){var t=this;Object.keys(e).forEach((function(o){t.plugins[o]=e[o]})),new va(ya.REGISTER_PLUGIN).setMessage("key=".concat(Object.keys(e))).end()}},{key:"getPlugin",value:function(e){return this.plugins[e]}},{key:"reset",value:function(){we.log("".concat(this._className,".reset"))}}]),o}(Do),ar=function(e){i(o,e);var t=f(o);function o(e){var a;return n(this,o),(a=t.call(this,e))._className="SyncUnreadMessageModule",a._cookie="",a._onlineSyncFlag=!1,a.getInnerEmitterInstance().on(Ja,a._onLoginSuccess,_(a)),a}return s(o,[{key:"_onLoginSuccess",value:function(e){this._startSync({cookie:this._cookie,syncFlag:0,isOnlineSync:0})}},{key:"_startSync",value:function(e){var t=this,o=e.cookie,n=e.syncFlag,a=e.isOnlineSync;we.log("".concat(this._className,"._startSync cookie:").concat(o," syncFlag:").concat(n," isOnlineSync:").concat(a)),this.request({protocolName:Lo,requestData:{cookie:o,syncFlag:n,isOnlineSync:a}}).then((function(e){var o=e.data,n=o.cookie,a=o.syncFlag,s=o.eventArray,r=o.messageList,i=o.C2CRemainingUnreadList,c=o.C2CPairUnreadList;if(t._cookie=n,Vt(n));else if(0===a||1===a){if(s)t.getModule(Mo).onMessage({head:{},body:{eventArray:s,isInstantMessage:t._onlineSyncFlag,isSyncingEnded:!1}});t.getModule(no).onNewC2CMessage({dataList:r,isInstantMessage:!1,C2CRemainingUnreadList:i,C2CPairUnreadList:c}),t._startSync({cookie:n,syncFlag:a,isOnlineSync:0})}else if(2===a){if(s)t.getModule(Mo).onMessage({head:{},body:{eventArray:s,isInstantMessage:t._onlineSyncFlag,isSyncingEnded:!0}});t.getModule(no).onNewC2CMessage({dataList:r,isInstantMessage:t._onlineSyncFlag,C2CRemainingUnreadList:i,C2CPairUnreadList:c})}})).catch((function(e){we.error("".concat(t._className,"._startSync failed. error:"),e)}))}},{key:"startOnlineSync",value:function(){we.log("".concat(this._className,".startOnlineSync")),this._onlineSyncFlag=!0,this._startSync({cookie:this._cookie,syncFlag:0,isOnlineSync:1})}},{key:"startSyncOnReconnected",value:function(){we.log("".concat(this._className,".startSyncOnReconnected.")),this._onlineSyncFlag=!0,this._startSync({cookie:this._cookie,syncFlag:0,isOnlineSync:0})}},{key:"reset",value:function(){we.log("".concat(this._className,".reset")),this._onlineSyncFlag=!1,this._cookie=""}}]),o}(Do),sr={request:{toAccount:"To_Account",fromAccount:"From_Account",to:"To_Account",from:"From_Account",groupID:"GroupId",groupAtUserID:"GroupAt_Account",extension:"Ext",data:"Data",description:"Desc",elements:"MsgBody",sizeType:"Type",downloadFlag:"Download_Flag",thumbUUID:"ThumbUUID",videoUUID:"VideoUUID",remoteAudioUrl:"Url",remoteVideoUrl:"VideoUrl",videoUrl:"",imageUrl:"URL",fileUrl:"Url",uuid:"UUID",priority:"MsgPriority",receiverUserID:"To_Account",receiverGroupID:"GroupId",messageSender:"SenderId",messageReceiver:"ReceiverId",nick:"From_AccountNick",avatar:"From_AccountHeadurl",messageNumber:"MsgNum",pbDownloadKey:"PbMsgKey",downloadKey:"JsonMsgKey",applicationType:"PendencyType",userIDList:"To_Account",groupNameList:"GroupName",userID:"To_Account",groupAttributeList:"GroupAttr",mainSequence:"AttrMainSeq",avChatRoomKey:"BytesKey",attributeControl:"AttrControl",sequence:"seq",messageControlInfo:"SendMsgControl",updateSequence:"UpdateSeq",clientTime:"MsgClientTime",sequenceList:"MsgSeqList",topicID:"TopicId",customData:"CustomString",isSupportTopic:"SupportTopic"},response:{MsgPriority:"priority",ThumbUUID:"thumbUUID",VideoUUID:"videoUUID",Download_Flag:"downloadFlag",GroupId:"groupID",Member_Account:"userID",MsgList:"messageList",SyncFlag:"syncFlag",To_Account:"to",From_Account:"from",MsgSeq:"sequence",MsgRandom:"random",MsgTime:"time",MsgTimeStamp:"time",MsgContent:"content",MsgBody:"elements",From_AccountNick:"nick",From_AccountHeadurl:"avatar",GroupWithdrawInfoArray:"revokedInfos",GroupReadInfoArray:"groupMessageReadNotice",LastReadMsgSeq:"lastMessageSeq",WithdrawC2cMsgNotify:"c2cMessageRevokedNotify",C2cWithdrawInfoArray:"revokedInfos",C2cReadedReceipt:"c2cMessageReadReceipt",ReadC2cMsgNotify:"c2cMessageReadNotice",LastReadTime:"peerReadTime",MsgRand:"random",MsgType:"type",MsgShow:"messageShow",NextMsgSeq:"nextMessageSeq",FaceUrl:"avatar",ProfileDataMod:"profileModify",Profile_Account:"userID",ValueBytes:"value",ValueNum:"value",NoticeSeq:"noticeSequence",NotifySeq:"notifySequence",MsgFrom_AccountExtraInfo:"messageFromAccountExtraInformation",Operator_Account:"operatorID",OpType:"operationType",ReportType:"operationType",UserId:"userID",User_Account:"userID",List_Account:"userIDList",MsgOperatorMemberExtraInfo:"operatorInfo",MsgMemberExtraInfo:"memberInfoList",ImageUrl:"avatar",NickName:"nick",MsgGroupNewInfo:"newGroupProfile",MsgAppDefinedData:"groupCustomField",Owner_Account:"ownerID",GroupFaceUrl:"avatar",GroupIntroduction:"introduction",GroupNotification:"notification",GroupApplyJoinOption:"joinOption",MsgKey:"messageKey",GroupInfo:"groupProfile",ShutupTime:"muteTime",Desc:"description",Ext:"extension",GroupAt_Account:"groupAtUserID",MsgNum:"messageNumber",PbMsgKey:"pbDownloadKey",JsonMsgKey:"downloadKey",MsgModifiedFlag:"isModified",PendencyItem:"applicationItem",PendencyType:"applicationType",AddTime:"time",AddSource:"source",AddWording:"wording",ProfileImImage:"avatar",PendencyAdd:"friendApplicationAdded",FrienPencydDel_Account:"friendApplicationDeletedUserIDList",Peer_Account:"userID",GroupAttr:"groupAttributeList",GroupAttrAry:"groupAttributeList",AttrMainSeq:"mainSequence",seq:"sequence",GroupAttrOption:"groupAttributeOption",BytesChangedKeys:"changedKeyList",GroupAttrInfo:"groupAttributeList",GroupAttrSeq:"mainSequence",PushChangedAttrValFlag:"hasChangedAttributeInfo",SubKeySeq:"sequence",Val:"value",MsgGroupFromCardName:"senderNameCard",MsgGroupFromNickName:"senderNick",C2cNick:"peerNick",C2cImage:"peerAvatar",SendMsgControl:"messageControlInfo",NoLastMsg:"excludedFromLastMessage",NoUnread:"excludedFromUnreadCount",UpdateSeq:"updateSequence",MuteNotifications:"muteFlag",MsgClientTime:"clientTime",TinyId:"tinyID",GroupMsgReceiptList:"readReceiptList",ReadNum:"readCount",UnreadNum:"unreadCount",TopicId:"topicID",MillionGroupFlag:"communityType",SupportTopic:"isSupportTopic",MsgTopicNewInfo:"newTopicInfo",ShutupAll:"muteAllMembers",CustomString:"customData",TopicFaceUrl:"avatar",TopicIntroduction:"introduction",TopicNotification:"notification",TopicIdArray:"topicIDList",MsgVersion:"messageVersion",C2cMsgModNotifys:"c2cMessageModified",GroupMsgModNotifys:"groupMessageModified"},ignoreKeyWord:["C2C","ID","USP"]};function rr(e,t){if("string"!=typeof e&&!Array.isArray(e))throw new TypeError("Expected the input to be `string | string[]`");t=Object.assign({pascalCase:!1},t);var o;return 0===(e=Array.isArray(e)?e.map((function(e){return e.trim()})).filter((function(e){return e.length})).join("-"):e.trim()).length?"":1===e.length?t.pascalCase?e.toUpperCase():e.toLowerCase():(e!==e.toLowerCase()&&(e=ir(e)),e=e.replace(/^[_.\- ]+/,"").toLowerCase().replace(/[_.\- ]+(\w|$)/g,(function(e,t){return t.toUpperCase()})).replace(/\d+(\w|$)/g,(function(e){return e.toUpperCase()})),o=e,t.pascalCase?o.charAt(0).toUpperCase()+o.slice(1):o)}var ir=function(e){for(var t=!1,o=!1,n=!1,a=0;a100)return o--,t;if(Qe(t)){var a=t.map((function(t){return Je(t)?e(t,n):t}));return o--,a}if(Je(t)){var s=(r=t,i=function(e,t){if(!st(t))return!1;if((a=t)!==rr(a))for(var o=0;o65535)return lr(240|t>>>18,128|t>>>12&63,128|t>>>6&63,128|63&t)}else t=65533}else t<=57343&&(t=65533);return t<=2047?lr(192|t>>>6,128|63&t):lr(224|t>>>12,128|t>>>6&63,128|63&t)},pr=function(e){for(var t=void 0===e?"":(""+e).replace(/[\x80-\uD7ff\uDC00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]?/g,dr),o=0|t.length,n=new Uint8Array(o),a=0;a0)for(var c=0;c=s&&(we.log("".concat(e._className,"._checkPromiseMap request timeout, delete requestID:").concat(o)),e._promiseMap.delete(o),n(new Ba({code:na.NETWORK_TIMEOUT,message:aa.NETWORK_TIMEOUT})),e._channelModule.onRequestTimeout(o))}))}},{key:"onOpen",value:function(e){if(""!==this._readyState){this._onOpenTs=Date.now();var t=e.id;this._socketID=t;var o=Date.now()-this._startTs;we.log("".concat(this._className,"._onOpen cost ").concat(o," ms. socketID:").concat(t)),new va(ya.WS_ON_OPEN).setMessage(o).setCostTime(o).setMoreMessage("socketID:".concat(t)).end(),e.id===this._socketID&&(this._readyState=vr,this._reConnectCount=0,this._resend(),!0===this._reConnectFlag&&(this._channelModule.onReconnected(),this._reConnectFlag=!1),this._channelModule.onOpen())}}},{key:"onClose",value:function(e){var t=new va(ya.WS_ON_CLOSE),o=e.id,n=e.e,a="sourceSocketID:".concat(o," currentSocketID:").concat(this._socketID," code:").concat(n.code," reason:").concat(n.reason),s=0;0!==this._onOpenTs&&(s=Date.now()-this._onOpenTs),t.setMessage(s).setCostTime(s).setMoreMessage(a).setCode(n.code).end(),we.log("".concat(this._className,"._onClose ").concat(a," onlineTime:").concat(s)),o===this._socketID&&(this._readyState=Ir,s<1e3?this._channelModule.onReconnectFailed():this._channelModule.onClose())}},{key:"onError",value:function(e){var t=e.id,o=e.e,n="sourceSocketID:".concat(t," currentSocketID:").concat(this._socketID);new va(ya.WS_ON_ERROR).setMessage(o.errMsg||ut(o)).setMoreMessage(n).setLevel("error").end(),we.warn("".concat(this._className,"._onError"),o,n),t===this._socketID&&(this._readyState="",this._channelModule.onError())}},{key:"onMessage",value:function(e){var t;try{t=JSON.parse(e.data)}catch(u){new va(ya.JSON_PARSE_ERROR).setMessage(e.data).end()}if(t&&t.head){var o=this._getRequestIDFromHead(t.head),n=Gt(t.head),a=ur(t.body,this._getResponseKeyMap(n));if(we.debug("".concat(this._className,".onMessage ret:").concat(JSON.stringify(a)," requestID:").concat(o," has:").concat(this._promiseMap.has(o))),this._setNextPingTs(),this._promiseMap.has(o)){var s=this._promiseMap.get(o),r=s.resolve,i=s.reject,c=s.timestamp;return this._promiseMap.delete(o),this._calcRTT(c),void(a.errorCode&&0!==a.errorCode?(this._channelModule.onErrorCodeNotZero(a),i(new Ba({code:a.errorCode,message:a.errorInfo||"",data:{elements:a.elements,messageVersion:a.messageVersion,cloudCustomData:a.cloudCustomData}}))):r(ba(a)))}this._channelModule.onMessage({head:t.head,body:a})}}},{key:"_calcRTT",value:function(e){var t=Date.now()-e;this._channelModule.getModule(Co).addRTT(t)}},{key:"_connect",value:function(){this._startTs=Date.now(),this._onOpenTs=0,this._socket=new _r(this),this._socketID=this._socket.getID(),this._readyState=yr,we.log("".concat(this._className,"._connect isWorkerEnabled:").concat(this.getIsWorkerEnabled()," socketID:").concat(this._socketID," url:").concat(this.getURL())),new va(ya.WS_CONNECT).setMessage("socketID:".concat(this._socketID," url:").concat(this.getURL())).end()}},{key:"getURL",value:function(){var e=this._channelModule.getModule(uo);e.isDevMode()&&(this._canIUseBinaryFrame=!1);var t=Rt();(Q||$&&"windows"===t||Z)&&(this._canIUseBinaryFrame=!1);var o=-1;"ios"===t?o=de||-1:"android"===t&&(o=ge||-1);var n=this._channelModule.getPlatform(),a=e.getSDKAppID(),s=e.getInstanceID();return this._canIUseBinaryFrame?"".concat(this._url,"/binfo?sdkappid=").concat(a,"&instanceid=").concat(s,"&random=").concat(this._getRandom(),"&platform=").concat(n,"&host=").concat(t,"&version=").concat(o):"".concat(this._url,"/info?sdkappid=").concat(a,"&instanceid=").concat(s,"&random=").concat(this._getRandom(),"&platform=").concat(n,"&host=").concat(t,"&version=").concat(o)}},{key:"_closeConnection",value:function(e){we.log("".concat(this._className,"._closeConnection socketID:").concat(this._socketID)),this._socket&&(this._socket.close(e),this._socketID=-1,this._socket=null,this._readyState=Ir)}},{key:"_resend",value:function(){var e=this;if(we.log("".concat(this._className,"._resend reConnectFlag:").concat(this._reConnectFlag),"promiseMap.size:".concat(this._promiseMap.size," simpleRequestMap.size:").concat(this._simpleRequestMap.size)),this._promiseMap.size>0&&this._promiseMap.forEach((function(t,o){var n=t.uplinkData,a=t.resolve,s=t.reject;e._promiseMap.set(o,{resolve:a,reject:s,timestamp:Date.now(),uplinkData:n}),e._execute(o,n)})),this._simpleRequestMap.size>0){var t,o=C(this._simpleRequestMap);try{for(o.s();!(t=o.n()).done;){var n=m(t.value,2),a=n[0],s=n[1];this._execute(a,s)}}catch(r){o.e(r)}finally{o.f()}this._simpleRequestMap.clear()}}},{key:"send",value:function(e){var t=this;e.head.seq=this._getSequence(),e.head.reqtime=Math.floor(Date.now()/1e3);e.keyMap;var o=g(e,mr),n=this._getRequestIDFromHead(e.head),a=JSON.stringify(o);return new Promise((function(e,s){(t._promiseMap.set(n,{resolve:e,reject:s,timestamp:Date.now(),uplinkData:a}),we.debug("".concat(t._className,".send uplinkData:").concat(JSON.stringify(o)," requestID:").concat(n," readyState:").concat(t._readyState)),t._readyState!==vr)?t._reConnect():(t._execute(n,a),t._channelModule.getModule(Co).addRequestCount())}))}},{key:"simplySend",value:function(e){e.head.seq=this._getSequence(),e.head.reqtime=Math.floor(Date.now()/1e3);e.keyMap;var t=g(e,Mr),o=this._getRequestIDFromHead(e.head),n=JSON.stringify(t);this._readyState!==vr?(this._simpleRequestMap.size0&&(clearInterval(this._timerForNotLoggedIn),this._timerForNotLoggedIn=-1),this._socketHandler.onCheckTimer(e)):this._socketHandler.onCheckTimer(1),this._checkNextPing())}},{key:"onErrorCodeNotZero",value:function(e){this.getModule(Mo).onErrorCodeNotZero(e)}},{key:"onMessage",value:function(e){this.getModule(Mo).onMessage(e)}},{key:"send",value:function(e){return this._socketHandler?this._previousState!==D.NET_STATE_CONNECTED&&e.head.servcmd.includes(Vn)?(this.reConnect(),this._sendLogViaHTTP(e)):this._socketHandler.send(e):Promise.reject()}},{key:"_sendLogViaHTTP",value:function(e){var t=H.HOST.CURRENT.STAT;return new Promise((function(o,n){var a="".concat(t,"/v4/imopenstat/tim_web_report_v2?sdkappid=").concat(e.head.sdkappid,"&reqtime=").concat(Date.now()),s=JSON.stringify(e.body),r="application/x-www-form-urlencoded;charset=UTF-8";if(te)ne.request({url:a,data:s,method:"POST",timeout:3e3,header:{"content-type":r},success:function(){o()},fail:function(){n(new Ba({code:na.NETWORK_ERROR,message:aa.NETWORK_ERROR}))}});else{var i=new XMLHttpRequest,c=setTimeout((function(){i.abort(),n(new Ba({code:na.NETWORK_TIMEOUT,message:aa.NETWORK_TIMEOUT}))}),3e3);i.onreadystatechange=function(){4===i.readyState&&(clearTimeout(c),200===i.status||304===i.status?o():n(new Ba({code:na.NETWORK_ERROR,message:aa.NETWORK_ERROR})))},i.open("POST",a,!0),i.setRequestHeader("Content-type",r),i.send(s)}}))}},{key:"simplySend",value:function(e){return this._socketHandler?this._socketHandler.simplySend(e):Promise.reject()}},{key:"onOpen",value:function(){this._ping()}},{key:"onClose",value:function(){this._socketHandler&&(this._socketHandler.getReconnectFlag()&&this._emitNetStateChangeEvent(D.NET_STATE_DISCONNECTED));this.reConnect()}},{key:"onError",value:function(){te&&!Z&&we.error("".concat(this._className,".onError 从v2.11.2起,SDK 支持了 WebSocket,如您未添加相关受信域名,请先添加!(如已添加请忽略),升级指引: https://web.sdk.qcloud.com/im/doc/zh-cn/tutorial-02-upgradeguideline.html")),this._emitNetStateChangeEvent(D.NET_STATE_DISCONNECTED)}},{key:"getKeyMap",value:function(e){return this.getModule(Mo).getKeyMap(e)}},{key:"_onAppHide",value:function(){this._isAppShowing=!1}},{key:"_onAppShow",value:function(){this._isAppShowing=!0}},{key:"onRequestTimeout",value:function(e){}},{key:"onReconnected",value:function(){we.log("".concat(this._className,".onReconnected")),this.getModule(Mo).onReconnected(),this._emitNetStateChangeEvent(D.NET_STATE_CONNECTED)}},{key:"onReconnectFailed",value:function(){we.log("".concat(this._className,".onReconnectFailed")),this._emitNetStateChangeEvent(D.NET_STATE_DISCONNECTED)}},{key:"setIsWorkerEnabled",value:function(e){this._socketHandler&&this._socketHandler.setIsWorkerEnabled(!1)}},{key:"offline",value:function(){this._emitNetStateChangeEvent(D.NET_STATE_DISCONNECTED)}},{key:"reConnect",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=!1;this._socketHandler&&(t=this._socketHandler.getReconnectFlag());var o="forcedFlag:".concat(e," fatalErrorFlag:").concat(this._fatalErrorFlag," previousState:").concat(this._previousState," reconnectFlag:").concat(t);if(we.log("".concat(this._className,".reConnect ").concat(o)),!this._fatalErrorFlag&&this._socketHandler){if(!0===e)this._socketHandler.forcedReconnect();else{if(this._previousState===D.NET_STATE_CONNECTING&&t)return;this._socketHandler.forcedReconnect()}this._emitNetStateChangeEvent(D.NET_STATE_CONNECTING)}}},{key:"_emitNetStateChangeEvent",value:function(e){this._previousState!==e&&(we.log("".concat(this._className,"._emitNetStateChangeEvent from ").concat(this._previousState," to ").concat(e)),this._previousState=e,this.emitOuterEvent(S.NET_STATE_CHANGE,{state:e}))}},{key:"_ping",value:function(){var e=this;if(!0!==this._probing){this._probing=!0;var t=this.getModule(Mo).getProtocolData({protocolName:Kn});this.send(t).then((function(){e._probing=!1})).catch((function(t){if(we.warn("".concat(e._className,"._ping failed. error:"),t),e._probing=!1,t&&60002===t.code)return new va(ya.ERROR).setMessage("code:".concat(t.code," message:").concat(t.message)).setNetworkType(e.getModule(go).getNetworkType()).end(),e._fatalErrorFlag=!0,void e._emitNetStateChangeEvent(D.NET_STATE_DISCONNECTED);e.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];we.log("".concat(e._className,"._ping failed. probe network, isAppShowing:").concat(e._isAppShowing," online:").concat(n," networkType:").concat(a)),n?e.reConnect():e._emitNetStateChangeEvent(D.NET_STATE_DISCONNECTED)}))}))}}},{key:"_checkNextPing",value:function(){this._socketHandler&&(this._socketHandler.isConnected()&&Date.now()>=this._socketHandler.getNextPingTs()&&this._ping())}},{key:"dealloc",value:function(){this._socketHandler&&(this._socketHandler.close(),this._socketHandler=null),this._timerForNotLoggedIn>-1&&clearInterval(this._timerForNotLoggedIn)}},{key:"onRestApiKickedOut",value:function(){this._socketHandler&&(this._socketHandler.close(),this.reConnect(!0))}},{key:"reset",value:function(){we.log("".concat(this._className,".reset")),this._previousState=D.NET_STATE_CONNECTED,this._probing=!1,this._fatalErrorFlag=!1,this._timerForNotLoggedIn=setInterval(this.onCheckTimer.bind(this),1e3)}}]),o}(Do),Cr=["a2","tinyid"],Sr=["a2","tinyid"],Dr=function(){function e(t){n(this,e),this._className="ProtocolHandler",this._sessionModule=t,this._configMap=new Map,this._fillConfigMap()}return s(e,[{key:"_fillConfigMap",value:function(){this._configMap.clear();var e=this._sessionModule.genCommonHead(),o=this._sessionModule.genCosSpecifiedHead(),n=this._sessionModule.genSSOReportHead();this._configMap.set(No,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.IM_OPEN_STATUS,".").concat(H.CMD.LOGIN)}),body:{state:"Online"},keyMap:{response:{InstId:"instanceID",HelloInterval:"helloInterval"}}}}(e)),this._configMap.set(Ao,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.IM_OPEN_STATUS,".").concat(H.CMD.LOGOUT)}),body:{type:0},keyMap:{request:{type:"wslogout_type"}}}}(e)),this._configMap.set(Oo,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.IM_OPEN_STATUS,".").concat(H.CMD.HELLO)}),body:{},keyMap:{response:{NewInstInfo:"newInstanceInfo"}}}}(e)),this._configMap.set(Ro,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.STAT_SERVICE,".").concat(H.CMD.KICK_OTHER)}),body:{}}}(e)),this._configMap.set(bn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.IM_COS_SIGN,".").concat(H.CMD.COS_SIGN)}),body:{cmd:"open_im_cos_svc",subCmd:"get_cos_token",duration:300,version:2},keyMap:{request:{userSig:"usersig",subCmd:"sub_cmd",cmd:"cmd",duration:"duration",version:"version"},response:{expired_time:"expiredTime",bucket_name:"bucketName",session_token:"sessionToken",tmp_secret_id:"secretId",tmp_secret_key:"secretKey"}}}}(o)),this._configMap.set(Fn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.CUSTOM_UPLOAD,".").concat(H.CMD.COS_PRE_SIG)}),body:{fileType:void 0,fileName:void 0,uploadMethod:0,duration:900},keyMap:{request:{userSig:"usersig",fileType:"file_type",fileName:"file_name",uploadMethod:"upload_method"},response:{expired_time:"expiredTime",request_id:"requestId",head_url:"headUrl",upload_url:"uploadUrl",download_url:"downloadUrl",ci_url:"ciUrl",snapshot_url:"requestSnapshotUrl"}}}}(o)),this._configMap.set(qn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.CUSTOM_UPLOAD,".").concat(H.CMD.VIDEO_COVER)}),body:{version:1,platform:void 0,coverName:void 0,requestSnapshotUrl:void 0},keyMap:{request:{version:"version",platform:"platform",coverName:"cover_name",requestSnapshotUrl:"snapshot_url"},response:{error_code:"errorCode",error_msg:"errorInfo",download_url:"snapshotUrl"}}}}(o)),this._configMap.set(Jn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.IM_CONFIG_MANAGER,".").concat(H.CMD.FETCH_COMMERCIAL_CONFIG)}),body:{SDKAppID:0},keyMap:{request:{SDKAppID:"uint32_sdkappid"},response:{int32_error_code:"errorCode",str_error_message:"errorMessage",str_purchase_bits:"purchaseBits",uint32_expired_time:"expiredTime"}}}}(e)),this._configMap.set(Xn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.IM_CONFIG_MANAGER,".").concat(H.CMD.PUSHED_COMMERCIAL_CONFIG)}),body:{},keyMap:{response:{int32_error_code:"errorCode",str_error_message:"errorMessage",str_purchase_bits:"purchaseBits",uint32_expired_time:"expiredTime"}}}}(e)),this._configMap.set($n,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.IM_CONFIG_MANAGER,".").concat(H.CMD.FETCH_CLOUD_CONTROL_CONFIG)}),body:{SDKAppID:0,version:0},keyMap:{request:{SDKAppID:"uint32_sdkappid",version:"uint64_version"},response:{int32_error_code:"errorCode",str_error_message:"errorMessage",str_json_config:"cloudControlConfig",uint32_expired_time:"expiredTime",uint32_sdkappid:"SDKAppID",uint64_version:"version"}}}}(e)),this._configMap.set(zn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.IM_CONFIG_MANAGER,".").concat(H.CMD.PUSHED_CLOUD_CONTROL_CONFIG)}),body:{},keyMap:{response:{int32_error_code:"errorCode",str_error_message:"errorMessage",str_json_config:"cloudControlConfig",uint32_expired_time:"expiredTime",uint32_sdkappid:"SDKAppID",uint64_version:"version"}}}}(e)),this._configMap.set(Qn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.OVERLOAD_PUSH,".").concat(H.CMD.OVERLOAD_NOTIFY)}),body:{},keyMap:{response:{OverLoadServCmd:"overloadCommand",DelaySecs:"waitingTime"}}}}(e)),this._configMap.set(Lo,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.OPEN_IM,".").concat(H.CMD.GET_MESSAGES)}),body:{cookie:"",syncFlag:0,needAbstract:1,isOnlineSync:0},keyMap:{request:{fromAccount:"From_Account",toAccount:"To_Account",from:"From_Account",to:"To_Account",time:"MsgTimeStamp",sequence:"MsgSeq",random:"MsgRandom",elements:"MsgBody"},response:{MsgList:"messageList",SyncFlag:"syncFlag",To_Account:"to",From_Account:"from",ClientSeq:"clientSequence",MsgSeq:"sequence",NoticeSeq:"noticeSequence",NotifySeq:"notifySequence",MsgRandom:"random",MsgTimeStamp:"time",MsgContent:"content",ToGroupId:"groupID",MsgKey:"messageKey",GroupTips:"groupTips",MsgBody:"elements",MsgType:"type",C2CRemainingUnreadCount:"C2CRemainingUnreadList",C2CPairUnreadCount:"C2CPairUnreadList"}}}}(e)),this._configMap.set(ko,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.OPEN_IM,".").concat(H.CMD.BIG_DATA_HALLWAY_AUTH_KEY)}),body:{}}}(e)),this._configMap.set(Go,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.OPEN_IM,".").concat(H.CMD.SEND_MESSAGE)}),body:{fromAccount:"",toAccount:"",msgSeq:0,msgRandom:0,msgBody:[],cloudCustomData:void 0,nick:"",avatar:"",msgLifeTime:void 0,offlinePushInfo:{pushFlag:0,title:"",desc:"",ext:"",apnsInfo:{badgeMode:0},androidInfo:{OPPOChannelID:""}},messageControlInfo:void 0,clientTime:void 0,needReadReceipt:0},keyMap:{request:{fromAccount:"From_Account",toAccount:"To_Account",msgTimeStamp:"MsgTimeStamp",msgSeq:"MsgSeq",msgRandom:"MsgRandom",msgBody:"MsgBody",count:"MaxCnt",lastMessageTime:"LastMsgTime",messageKey:"MsgKey",peerAccount:"Peer_Account",data:"Data",description:"Desc",extension:"Ext",type:"MsgType",content:"MsgContent",sizeType:"Type",uuid:"UUID",url:"",imageUrl:"URL",fileUrl:"Url",remoteAudioUrl:"Url",remoteVideoUrl:"VideoUrl",thumbUUID:"ThumbUUID",videoUUID:"VideoUUID",videoUrl:"",downloadFlag:"Download_Flag",nick:"From_AccountNick",avatar:"From_AccountHeadurl",from:"From_Account",time:"MsgTimeStamp",messageRandom:"MsgRandom",messageSequence:"MsgSeq",elements:"MsgBody",clientSequence:"ClientSeq",payload:"MsgContent",messageList:"MsgList",messageNumber:"MsgNum",abstractList:"AbstractList",messageBody:"MsgBody",needReadReceipt:"IsNeedReadReceipt"}}}}(e)),this._configMap.set(Po,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.SEND_GROUP_MESSAGE)}),body:{fromAccount:"",groupID:"",random:0,clientSequence:0,priority:"",msgBody:[],cloudCustomData:void 0,onlineOnlyFlag:0,offlinePushInfo:{pushFlag:0,title:"",desc:"",ext:"",apnsInfo:{badgeMode:0},androidInfo:{OPPOChannelID:""}},groupAtInfo:[],messageControlInfo:void 0,clientTime:void 0,needReadReceipt:0,topicID:void 0},keyMap:{request:{to:"GroupId",extension:"Ext",data:"Data",description:"Desc",random:"Random",sequence:"ReqMsgSeq",count:"ReqMsgNumber",type:"MsgType",priority:"MsgPriority",content:"MsgContent",elements:"MsgBody",sizeType:"Type",uuid:"UUID",url:"",imageUrl:"URL",fileUrl:"Url",remoteAudioUrl:"Url",remoteVideoUrl:"VideoUrl",thumbUUID:"ThumbUUID",videoUUID:"VideoUUID",videoUrl:"",downloadFlag:"Download_Flag",clientSequence:"ClientSeq",from:"From_Account",time:"MsgTimeStamp",messageRandom:"MsgRandom",messageSequence:"MsgSeq",payload:"MsgContent",messageList:"MsgList",messageNumber:"MsgNum",abstractList:"AbstractList",messageBody:"MsgBody",needReadReceipt:"NeedReadReceipt"},response:{MsgTime:"time",MsgSeq:"sequence"}}}}(e)),this._configMap.set(Vo,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.OPEN_IM,".").concat(H.CMD.REVOKE_C2C_MESSAGE)}),body:{msgInfo:{fromAccount:"",toAccount:"",msgTimeStamp:0,msgSeq:0,msgRandom:0}},keyMap:{request:{msgInfo:"MsgInfo",msgTimeStamp:"MsgTimeStamp",msgSeq:"MsgSeq",msgRandom:"MsgRandom"}}}}(e)),this._configMap.set(pn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.REVOKE_GROUP_MESSAGE)}),body:{groupID:"",msgSeqList:void 0,topicID:""},keyMap:{request:{msgSeqList:"MsgSeqList",msgSeq:"MsgSeq"}}}}(e)),this._configMap.set(xo,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.OPEN_IM,".").concat(H.CMD.GET_C2C_ROAM_MESSAGES)}),body:{peerAccount:"",count:15,lastMessageTime:0,messageKey:"",withRecalledMessage:1,direction:0},keyMap:{request:{messageKey:"MsgKey",peerAccount:"Peer_Account",count:"MaxCnt",lastMessageTime:"LastMsgTime",withRecalledMessage:"WithRecalledMsg",direction:"GetDirection"},response:{LastMsgTime:"lastMessageTime",IsNeedReadReceipt:"needReadReceipt"}}}}(e)),this._configMap.set(jo,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.OPEN_IM,".").concat(H.CMD.MODIFY_C2C_MESSAGE)}),body:{from:"",to:"",sequence:0,random:0,time:0,version:0,elements:void 0,cloudCustomData:void 0},keyMap:{request:{sequence:"MsgSeq",random:"MsgRandom",time:"MsgTime",version:"MsgVersion",type:"MsgType",content:"MsgContent"}}}}(e)),this._configMap.set(hn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.GET_GROUP_ROAM_MESSAGES)}),body:{withRecalledMsg:1,groupID:"",count:15,sequence:"",topicID:void 0},keyMap:{request:{sequence:"ReqMsgSeq",count:"ReqMsgNumber",withRecalledMessage:"WithRecalledMsg"},response:{Random:"random",MsgTime:"time",MsgSeq:"sequence",ReqMsgSeq:"sequence",RspMsgList:"messageList",IsPlaceMsg:"isPlaceMessage",IsSystemMsg:"isSystemMessage",ToGroupId:"to",EnumFrom_AccountType:"fromAccountType",EnumTo_AccountType:"toAccountType",GroupCode:"groupCode",MsgPriority:"priority",MsgBody:"elements",MsgType:"type",MsgContent:"content",IsFinished:"complete",Download_Flag:"downloadFlag",ClientSeq:"clientSequence",ThumbUUID:"thumbUUID",VideoUUID:"videoUUID",ToTopicId:"topicID"}}}}(e)),this._configMap.set(Ko,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.OPEN_IM,".").concat(H.CMD.SET_C2C_MESSAGE_READ)}),body:{C2CMsgReaded:void 0},keyMap:{request:{lastMessageTime:"LastedMsgTime"}}}}(e)),this._configMap.set(Ho,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.OPEN_IM,".").concat(H.CMD.SET_C2C_PEER_MUTE_NOTIFICATIONS)}),body:{userIDList:void 0,muteFlag:0},keyMap:{request:{userIDList:"Peer_Account",muteFlag:"Mute_Notifications"}}}}(e)),this._configMap.set(Bo,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.OPEN_IM,".").concat(H.CMD.GET_C2C_PEER_MUTE_NOTIFICATIONS)}),body:{updateSequence:0},keyMap:{response:{MuteNotificationsList:"muteFlagList"}}}}(e)),this._configMap.set(gn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.SET_GROUP_MESSAGE_READ)}),body:{groupID:void 0,messageReadSeq:void 0,topicID:void 0},keyMap:{request:{messageReadSeq:"MsgReadedSeq"}}}}(e)),this._configMap.set(_n,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.OPEN_IM,".").concat(H.CMD.SET_ALL_MESSAGE_READ)}),body:{readAllC2CMessage:0,groupMessageReadInfoList:[]},keyMap:{request:{readAllC2CMessage:"C2CReadAllMsg",groupMessageReadInfoList:"GroupReadInfo",messageSequence:"MsgSeq"},response:{C2CReadAllMsg:"readAllC2CMessage",GroupReadInfoArray:"groupMessageReadInfoList"}}}}(e)),this._configMap.set(Yo,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.OPEN_IM,".").concat(H.CMD.DELETE_C2C_MESSAGE)}),body:{fromAccount:"",to:"",keyList:void 0},keyMap:{request:{keyList:"MsgKeyList"}}}}(e)),this._configMap.set(Sn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.DELETE_GROUP_MESSAGE)}),body:{groupID:"",deleter:"",keyList:void 0,topicID:void 0},keyMap:{request:{deleter:"Deleter_Account",keyList:"Seqs"}}}}(e)),this._configMap.set(Dn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.OPEN_IM,".").concat(H.CMD.MODIFY_GROUP_MESSAGE)}),body:{groupID:"",topicID:void 0,sequence:0,version:0,elements:void 0,cloudCustomData:void 0},keyMap:{request:{sequence:"MsgSeq",version:"MsgVersion",type:"MsgType",content:"MsgContent"}}}}(e)),this._configMap.set(fn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.GET_READ_RECEIPT)}),body:{groupID:"",sequenceList:void 0},keyMap:{request:{sequence:"MsgSeq"}}}}(e)),this._configMap.set(Mn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.OPEN_IM,".").concat(H.CMD.SEND_C2C_READ_RECEIPT)}),body:{peerAccount:"",messageInfoList:void 0},keyMap:{request:{peerAccount:"Peer_Account",messageInfoList:"C2CMsgInfo",fromAccount:"From_Account",toAccount:"To_Account",sequence:"MsgSeq",random:"MsgRandom",time:"MsgTime",clientTime:"MsgClientTime"}}}}(e)),this._configMap.set(mn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.SEND_READ_RECEIPT)}),body:{groupID:"",sequenceList:void 0},keyMap:{request:{sequenceList:"MsgSeqList",sequence:"MsgSeq"}}}}(e)),this._configMap.set(vn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.GET_READ_RECEIPT_DETAIL)}),body:{groupID:"",sequence:void 0,flag:0,cursor:0,count:0},keyMap:{request:{sequence:"MsgSeq",count:"Num"},response:{ReadList:"readUserIDList",Read_Account:"userID",UnreadList:"unreadUserIDList",Unread_Account:"userID",IsFinish:"isCompleted"}}}}(e)),this._configMap.set(Wo,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.OPEN_IM,".").concat(H.CMD.GET_PEER_READ_TIME)}),body:{userIDList:void 0},keyMap:{request:{userIDList:"To_Account"},response:{ReadTime:"peerReadTimeList"}}}}(e)),this._configMap.set(zo,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.RECENT_CONTACT,".").concat(H.CMD.GET_CONVERSATION_LIST)}),body:{fromAccount:void 0,count:0},keyMap:{request:{},response:{SessionItem:"conversations",ToAccount:"groupID",To_Account:"userID",UnreadMsgCount:"unreadCount",MsgGroupReadedSeq:"messageReadSeq",C2cPeerReadTime:"c2cPeerReadTime"}}}}(e)),this._configMap.set($o,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.RECENT_CONTACT,".").concat(H.CMD.PAGING_GET_CONVERSATION_LIST)}),body:{fromAccount:void 0,timeStamp:void 0,startIndex:void 0,pinnedTimeStamp:void 0,pinnedStartIndex:void 0,orderType:void 0,messageAssistFlag:4,assistFlag:15},keyMap:{request:{messageAssistFlag:"MsgAssistFlags",assistFlag:"AssistFlags",pinnedTimeStamp:"TopTimeStamp",pinnedStartIndex:"TopStartIndex"},response:{SessionItem:"conversations",ToAccount:"groupID",To_Account:"userID",UnreadMsgCount:"unreadCount",MsgGroupReadedSeq:"messageReadSeq",C2cPeerReadTime:"c2cPeerReadTime",LastMsgFlags:"lastMessageFlag",TopFlags:"isPinned",TopTimeStamp:"pinnedTimeStamp",TopStartIndex:"pinnedStartIndex"}}}}(e)),this._configMap.set(Jo,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.RECENT_CONTACT,".").concat(H.CMD.DELETE_CONVERSATION)}),body:{fromAccount:"",toAccount:void 0,type:1,toGroupID:void 0,clearHistoryMessage:1},keyMap:{request:{toGroupID:"ToGroupid",clearHistoryMessage:"ClearRamble"}}}}(e)),this._configMap.set(Xo,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.RECENT_CONTACT,".").concat(H.CMD.PIN_CONVERSATION)}),body:{fromAccount:"",operationType:1,itemList:void 0},keyMap:{request:{itemList:"RecentContactItem"}}}}(e)),this._configMap.set(Qo,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.OPEN_IM,".").concat(H.CMD.DELETE_GROUP_AT_TIPS)}),body:{messageListToDelete:void 0},keyMap:{request:{messageListToDelete:"DelMsgList",messageSeq:"MsgSeq",messageRandom:"MsgRandom"}}}}(e)),this._configMap.set(Uo,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.PROFILE,".").concat(H.CMD.PORTRAIT_GET)}),body:{fromAccount:"",userItem:[]},keyMap:{request:{toAccount:"To_Account",standardSequence:"StandardSequence",customSequence:"CustomSequence"}}}}(e)),this._configMap.set(wo,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.PROFILE,".").concat(H.CMD.PORTRAIT_SET)}),body:{fromAccount:"",profileItem:[{tag:Fe.NICK,value:""},{tag:Fe.GENDER,value:""},{tag:Fe.ALLOWTYPE,value:""},{tag:Fe.AVATAR,value:""}]},keyMap:{request:{toAccount:"To_Account",standardSequence:"StandardSequence",customSequence:"CustomSequence"}}}}(e)),this._configMap.set(bo,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.FRIEND,".").concat(H.CMD.GET_BLACKLIST)}),body:{fromAccount:"",startIndex:0,maxLimited:30,lastSequence:0},keyMap:{response:{CurruentSequence:"currentSequence"}}}}(e)),this._configMap.set(Fo,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.FRIEND,".").concat(H.CMD.ADD_BLACKLIST)}),body:{fromAccount:"",toAccount:[]}}}(e)),this._configMap.set(qo,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.FRIEND,".").concat(H.CMD.DELETE_BLACKLIST)}),body:{fromAccount:"",toAccount:[]}}}(e)),this._configMap.set(Zo,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.GET_JOINED_GROUPS)}),body:{memberAccount:"",limit:void 0,offset:void 0,groupType:void 0,responseFilter:{groupBaseInfoFilter:void 0,selfInfoFilter:void 0},isSupportTopic:0},keyMap:{request:{memberAccount:"Member_Account"},response:{GroupIdList:"groups",MsgFlag:"messageRemindType",NoUnreadSeqList:"excludedUnreadSequenceList",MsgSeq:"readedSequence"}}}}(e)),this._configMap.set(en,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.GET_GROUP_INFO)}),body:{groupIDList:void 0,responseFilter:{groupBaseInfoFilter:["Type","Name","Introduction","Notification","FaceUrl","Owner_Account","CreateTime","InfoSeq","LastInfoTime","LastMsgTime","MemberNum","MaxMemberNum","ApplyJoinOption","NextMsgSeq","ShutUpAllMember"],groupCustomFieldFilter:void 0,memberInfoFilter:void 0,memberCustomFieldFilter:void 0}},keyMap:{request:{groupIDList:"GroupIdList",groupCustomField:"AppDefinedData",memberCustomField:"AppMemberDefinedData",groupCustomFieldFilter:"AppDefinedDataFilter_Group",memberCustomFieldFilter:"AppDefinedDataFilter_GroupMember"},response:{GroupIdList:"groups",MsgFlag:"messageRemindType",AppDefinedData:"groupCustomField",AppMemberDefinedData:"memberCustomField",AppDefinedDataFilter_Group:"groupCustomFieldFilter",AppDefinedDataFilter_GroupMember:"memberCustomFieldFilter",InfoSeq:"infoSequence",MemberList:"members",GroupInfo:"groups",ShutUpUntil:"muteUntil",ShutUpAllMember:"muteAllMembers",ApplyJoinOption:"joinOption"}}}}(e)),this._configMap.set(tn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.CREATE_GROUP)}),body:{type:void 0,name:void 0,groupID:void 0,ownerID:void 0,introduction:void 0,notification:void 0,maxMemberNum:void 0,joinOption:void 0,memberList:void 0,groupCustomField:void 0,memberCustomField:void 0,webPushFlag:1,avatar:"",isSupportTopic:void 0},keyMap:{request:{ownerID:"Owner_Account",userID:"Member_Account",avatar:"FaceUrl",maxMemberNum:"MaxMemberCount",joinOption:"ApplyJoinOption",groupCustomField:"AppDefinedData",memberCustomField:"AppMemberDefinedData"},response:{HugeGroupFlag:"avChatRoomFlag",OverJoinedGroupLimit_Account:"overLimitUserIDList"}}}}(e)),this._configMap.set(on,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.DESTROY_GROUP)}),body:{groupID:void 0}}}(e)),this._configMap.set(nn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.MODIFY_GROUP_INFO)}),body:{groupID:void 0,name:void 0,introduction:void 0,notification:void 0,avatar:void 0,maxMemberNum:void 0,joinOption:void 0,groupCustomField:void 0,muteAllMembers:void 0},keyMap:{request:{maxMemberNum:"MaxMemberCount",groupCustomField:"AppDefinedData",muteAllMembers:"ShutUpAllMember",joinOption:"ApplyJoinOption",avatar:"FaceUrl"},response:{AppDefinedData:"groupCustomField",ShutUpAllMember:"muteAllMembers",ApplyJoinOption:"joinOption"}}}}(e)),this._configMap.set(an,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.APPLY_JOIN_GROUP)}),body:{groupID:void 0,applyMessage:void 0,userDefinedField:void 0,webPushFlag:1,historyMessageFlag:void 0},keyMap:{request:{applyMessage:"ApplyMsg",historyMessageFlag:"HugeGroupHistoryMsgFlag"},response:{HugeGroupFlag:"avChatRoomFlag",AVChatRoomKey:"avChatRoomKey",RspMsgList:"messageList",ToGroupId:"to"}}}}(e)),this._configMap.set(sn,function(e){e.a2,e.tinyid;return{head:t(t({},g(e,Cr)),{},{servcmd:"".concat(H.NAME.BIG_GROUP_NO_AUTH,".").concat(H.CMD.APPLY_JOIN_GROUP)}),body:{groupID:void 0,applyMessage:void 0,userDefinedField:void 0,webPushFlag:1},keyMap:{request:{applyMessage:"ApplyMsg"},response:{HugeGroupFlag:"avChatRoomFlag"}}}}(e)),this._configMap.set(rn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.QUIT_GROUP)}),body:{groupID:void 0}}}(e)),this._configMap.set(cn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.SEARCH_GROUP_BY_ID)}),body:{groupIDList:void 0,responseFilter:{groupBasePublicInfoFilter:["Type","Name","Introduction","Notification","FaceUrl","CreateTime","Owner_Account","LastInfoTime","LastMsgTime","NextMsgSeq","MemberNum","MaxMemberNum","ApplyJoinOption"]}},keyMap:{response:{ApplyJoinOption:"joinOption"}}}}(e)),this._configMap.set(un,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.CHANGE_GROUP_OWNER)}),body:{groupID:void 0,newOwnerID:void 0},keyMap:{request:{newOwnerID:"NewOwner_Account"}}}}(e)),this._configMap.set(ln,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.HANDLE_APPLY_JOIN_GROUP)}),body:{groupID:void 0,applicant:void 0,handleAction:void 0,handleMessage:void 0,authentication:void 0,messageKey:void 0,userDefinedField:void 0},keyMap:{request:{applicant:"Applicant_Account",handleAction:"HandleMsg",handleMessage:"ApprovalMsg",messageKey:"MsgKey"}}}}(e)),this._configMap.set(dn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.HANDLE_GROUP_INVITATION)}),body:{groupID:void 0,inviter:void 0,handleAction:void 0,handleMessage:void 0,authentication:void 0,messageKey:void 0,userDefinedField:void 0},keyMap:{request:{inviter:"Inviter_Account",handleAction:"HandleMsg",handleMessage:"ApprovalMsg",messageKey:"MsgKey"}}}}(e)),this._configMap.set(yn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.GET_GROUP_APPLICATION)}),body:{startTime:void 0,limit:void 0,handleAccount:void 0},keyMap:{request:{handleAccount:"Handle_Account"}}}}(e)),this._configMap.set(In,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.OPEN_IM,".").concat(H.CMD.DELETE_GROUP_SYSTEM_MESSAGE)}),body:{messageListToDelete:void 0},keyMap:{request:{messageListToDelete:"DelMsgList",messageSeq:"MsgSeq",messageRandom:"MsgRandom"}}}}(e)),this._configMap.set(En,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.BIG_GROUP_LONG_POLLING,".").concat(H.CMD.AVCHATROOM_LONG_POLL)}),body:{USP:1,startSeq:1,holdTime:90,key:void 0},keyMap:{request:{USP:"USP"},response:{ToGroupId:"groupID"}}}}(e)),this._configMap.set(Tn,function(e){e.a2,e.tinyid;return{head:t(t({},g(e,Sr)),{},{servcmd:"".concat(H.NAME.BIG_GROUP_LONG_POLLING_NO_AUTH,".").concat(H.CMD.AVCHATROOM_LONG_POLL)}),body:{USP:1,startSeq:1,holdTime:90,key:void 0},keyMap:{request:{USP:"USP"},response:{ToGroupId:"groupID"}}}}(e)),this._configMap.set(Cn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.GET_ONLINE_MEMBER_NUM)}),body:{groupID:void 0}}}(e)),this._configMap.set(Nn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.SET_GROUP_ATTRIBUTES)}),body:{groupID:void 0,groupAttributeList:void 0,mainSequence:void 0,avChatRoomKey:void 0,attributeControl:["RaceConflict"]},keyMap:{request:{key:"key",value:"value"}}}}(e)),this._configMap.set(An,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.MODIFY_GROUP_ATTRIBUTES)}),body:{groupID:void 0,groupAttributeList:void 0,mainSequence:void 0,avChatRoomKey:void 0,attributeControl:["RaceConflict"]},keyMap:{request:{key:"key",value:"value"}}}}(e)),this._configMap.set(On,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.DELETE_GROUP_ATTRIBUTES)}),body:{groupID:void 0,groupAttributeList:void 0,mainSequence:void 0,avChatRoomKey:void 0,attributeControl:["RaceConflict"]},keyMap:{request:{key:"key"}}}}(e)),this._configMap.set(Rn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.CLEAR_GROUP_ATTRIBUTES)}),body:{groupID:void 0,mainSequence:void 0,avChatRoomKey:void 0,attributeControl:["RaceConflict"]}}}(e)),this._configMap.set(Ln,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP_ATTR,".").concat(H.CMD.GET_GROUP_ATTRIBUTES)}),body:{groupID:void 0,avChatRoomKey:void 0,groupType:1},keyMap:{request:{avChatRoomKey:"Key",groupType:"GroupType"}}}}(e)),this._configMap.set(Zn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP_COMMUNITY,".").concat(H.CMD.CREATE_TOPIC)}),body:{groupID:void 0,topicName:void 0,avatar:void 0,customData:void 0,topicID:void 0,notification:void 0,introduction:void 0},keyMap:{request:{avatar:"FaceUrl"}}}}(e)),this._configMap.set(ea,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP_COMMUNITY,".").concat(H.CMD.DELETE_TOPIC)}),body:{groupID:void 0,topicIDList:void 0},keyMap:{request:{topicIDList:"TopicIdList"},response:{DestroyResultItem:"resultList",ErrorCode:"code",ErrorInfo:"message"}}}}(e)),this._configMap.set(ta,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP_COMMUNITY,".").concat(H.CMD.UPDATE_TOPIC_PROFILE)}),body:{groupID:void 0,topicID:void 0,avatar:void 0,customData:void 0,notification:void 0,introduction:void 0,muteAllMembers:void 0,topicName:void 0},keyMap:{request:{avatar:"FaceUrl",muteAllMembers:"ShutUpAllMember"}}}}(e)),this._configMap.set(oa,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP_COMMUNITY,".").concat(H.CMD.GET_TOPIC_LIST)}),body:{groupID:void 0,topicIDList:void 0},keyMap:{request:{topicIDList:"TopicIdList"},response:{TopicAndSelfInfo:"topicInfoList",TopicInfo:"topic",GroupID:"groupID",ShutUpTime:"muteTime",ShutUpAllFlag:"muteAllMembers",LastMsgTime:"lastMessageTime",MsgSeq:"readedSequence",MsgFlag:"messageRemindType",ErrorCode:"code",ErrorInfo:"message"}}}}(e)),this._configMap.set(kn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.GET_GROUP_MEMBER_LIST)}),body:{groupID:void 0,limit:0,offset:void 0,next:void 0,memberRoleFilter:void 0,memberInfoFilter:["Role","NameCard","ShutUpUntil","JoinTime"],memberCustomFieldFilter:void 0},keyMap:{request:{memberCustomFieldFilter:"AppDefinedDataFilter_GroupMember"},response:{AppMemberDefinedData:"memberCustomField",AppDefinedDataFilter_GroupMember:"memberCustomFieldFilter",MemberList:"members",ShutUpUntil:"muteUntil"}}}}(e)),this._configMap.set(Gn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.GET_GROUP_MEMBER_INFO)}),body:{groupID:void 0,userIDList:void 0,memberInfoFilter:void 0,memberCustomFieldFilter:void 0},keyMap:{request:{userIDList:"Member_List_Account",memberCustomFieldFilter:"AppDefinedDataFilter_GroupMember"},response:{MemberList:"members",ShutUpUntil:"muteUntil",AppDefinedDataFilter_GroupMember:"memberCustomFieldFilter",AppMemberDefinedData:"memberCustomField"}}}}(e)),this._configMap.set(Pn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.ADD_GROUP_MEMBER)}),body:{groupID:void 0,silence:void 0,userIDList:void 0},keyMap:{request:{userID:"Member_Account",userIDList:"MemberList"},response:{MemberList:"members"}}}}(e)),this._configMap.set(Un,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.DELETE_GROUP_MEMBER)}),body:{groupID:void 0,userIDList:void 0,reason:void 0},keyMap:{request:{userIDList:"MemberToDel_Account"}}}}(e)),this._configMap.set(wn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.MODIFY_GROUP_MEMBER_INFO)}),body:{groupID:void 0,topicID:void 0,userID:void 0,messageRemindType:void 0,nameCard:void 0,role:void 0,memberCustomField:void 0,muteTime:void 0},keyMap:{request:{userID:"Member_Account",memberCustomField:"AppMemberDefinedData",muteTime:"ShutUpTime",messageRemindType:"MsgFlag"}}}}(e)),this._configMap.set(Vn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.IM_OPEN_STAT,".").concat(H.CMD.TIM_WEB_REPORT_V2)}),body:{header:{},event:[],quality:[]},keyMap:{request:{SDKType:"sdk_type",SDKVersion:"sdk_version",deviceType:"device_type",platform:"platform",instanceID:"instance_id",traceID:"trace_id",SDKAppID:"sdk_app_id",userID:"user_id",tinyID:"tiny_id",extension:"extension",timestamp:"timestamp",networkType:"network_type",eventType:"event_type",code:"error_code",message:"error_message",moreMessage:"more_message",duplicate:"duplicate",costTime:"cost_time",level:"level",qualityType:"quality_type",reportIndex:"report_index",wholePeriod:"whole_period",totalCount:"total_count",rttCount:"success_count_business",successRateOfRequest:"percent_business",countLessThan1Second:"success_count_business",percentOfCountLessThan1Second:"percent_business",countLessThan3Second:"success_count_platform",percentOfCountLessThan3Second:"percent_platform",successCountOfBusiness:"success_count_business",successRateOfBusiness:"percent_business",successCountOfPlatform:"success_count_platform",successRateOfPlatform:"percent_platform",successCountOfMessageReceived:"success_count_business",successRateOfMessageReceived:"percent_business",avgRTT:"average_value",avgDelay:"average_value",avgValue:"average_value",uiPlatform:"ui_platform"}}}}(n)),this._configMap.set(Kn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.HEARTBEAT,".").concat(H.CMD.ALIVE)}),body:{}}}(e)),this._configMap.set(Hn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.IM_OPEN_PUSH,".").concat(H.CMD.MESSAGE_PUSH)}),body:{},keyMap:{response:{C2cMsgArray:"C2CMessageArray",GroupMsgArray:"groupMessageArray",GroupTips:"groupTips",C2cNotifyMsgArray:"C2CNotifyMessageArray",C2cMsgInfo:"C2CReadReceiptArray",ClientSeq:"clientSequence",MsgPriority:"priority",NoticeSeq:"noticeSequence",MsgContent:"content",MsgType:"type",MsgBody:"elements",ToGroupId:"to",Desc:"description",Ext:"extension",IsSyncMsg:"isSyncMessage",Flag:"needSync",NeedAck:"needAck",PendencyAdd_Account:"userID",ProfileImNick:"nick",PendencyType:"applicationType",C2CReadAllMsg:"readAllC2CMessage",IsNeedReadReceipt:"needReadReceipt"}}}}(e)),this._configMap.set(Bn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.IM_OPEN_PUSH,".").concat(H.CMD.MULTI_MESSAGE_PUSH)}),body:{},keyMap:{response:{GroupMsgArray:"groupMessageArray",GroupTips:"groupTips",ClientSeq:"clientSequence",MsgPriority:"priority",NoticeSeq:"noticeSequence",MsgContent:"content",MsgType:"type",MsgBody:"elements",ToGroupId:"to",Desc:"description",Ext:"extension",IsSyncMsg:"isSyncMessage",Flag:"needSync",NeedAck:"needAck",PendencyType:"applicationType"}}}}(e)),this._configMap.set(xn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.OPEN_IM,".").concat(H.CMD.MESSAGE_PUSH_ACK)}),body:{sessionData:void 0},keyMap:{request:{sessionData:"SessionData"}}}}(e)),this._configMap.set(Wn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.IM_OPEN_STATUS,".").concat(H.CMD.STATUS_FORCE_OFFLINE)}),body:{},keyMap:{response:{C2cNotifyMsgArray:"C2CNotifyMessageArray",NoticeSeq:"noticeSequence",KickoutMsgNotify:"kickoutMsgNotify",NewInstInfo:"newInstanceInfo"}}}}(e)),this._configMap.set(jn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.IM_LONG_MESSAGE,".").concat(H.CMD.DOWNLOAD_MERGER_MESSAGE)}),body:{downloadKey:""},keyMap:{response:{Data:"data",Desc:"description",Ext:"extension",Download_Flag:"downloadFlag",ThumbUUID:"thumbUUID",VideoUUID:"videoUUID"}}}}(e)),this._configMap.set(Yn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.IM_LONG_MESSAGE,".").concat(H.CMD.UPLOAD_MERGER_MESSAGE)}),body:{messageList:[]},keyMap:{request:{fromAccount:"From_Account",toAccount:"To_Account",msgTimeStamp:"MsgTimeStamp",msgSeq:"MsgSeq",msgRandom:"MsgRandom",msgBody:"MsgBody",type:"MsgType",content:"MsgContent",data:"Data",description:"Desc",extension:"Ext",sizeType:"Type",uuid:"UUID",url:"",imageUrl:"URL",fileUrl:"Url",remoteAudioUrl:"Url",remoteVideoUrl:"VideoUrl",thumbUUID:"ThumbUUID",videoUUID:"VideoUUID",videoUrl:"",downloadFlag:"Download_Flag",from:"From_Account",time:"MsgTimeStamp",messageRandom:"MsgRandom",messageSequence:"MsgSeq",elements:"MsgBody",clientSequence:"ClientSeq",payload:"MsgContent",messageList:"MsgList",messageNumber:"MsgNum",abstractList:"AbstractList",messageBody:"MsgBody"}}}}(e))}},{key:"has",value:function(e){return this._configMap.has(e)}},{key:"get",value:function(e){return this._configMap.get(e)}},{key:"update",value:function(){this._fillConfigMap()}},{key:"getKeyMap",value:function(e){return this.has(e)?this.get(e).keyMap||{}:(we.warn("".concat(this._className,".getKeyMap unknown protocolName:").concat(e)),{})}},{key:"getProtocolData",value:function(e){var t=e.protocolName,o=e.requestData,n=this.get(t),a=null;if(o){var s=this._simpleDeepCopy(n),r=this._updateService(o,s),i=r.body,c=Object.create(null);for(var u in i)if(Object.prototype.hasOwnProperty.call(i,u)){if(c[u]=i[u],void 0===o[u])continue;c[u]=o[u]}r.body=c,a=this._getUplinkData(r)}else a=this._getUplinkData(n);return a}},{key:"_getUplinkData",value:function(e){var t=this._requestDataCleaner(e),o=Gt(t.head),n=cr(t.body,this._getRequestKeyMap(o));return t.body=n,t}},{key:"_updateService",value:function(e,t){var o=Gt(t.head);if(t.head.servcmd.includes(H.NAME.GROUP)){var n=e.type,a=e.groupID,s=void 0===a?void 0:a,r=e.groupIDList,i=void 0===r?[]:r;Ze(s)&&(s=i[0]||""),Et({type:n,groupID:s})&&(t.head.servcmd="".concat(H.NAME.GROUP_COMMUNITY,".").concat(o))}return t}},{key:"_getRequestKeyMap",value:function(e){var o=this.getKeyMap(e);return t(t({},sr.request),o.request)}},{key:"_requestDataCleaner",value:function(e){var t=Array.isArray(e)?[]:Object.create(null);for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&st(n)&&null!==e[n]&&void 0!==e[n]&&("object"!==o(e[n])?t[n]=e[n]:t[n]=this._requestDataCleaner.bind(this)(e[n]));return t}},{key:"_simpleDeepCopy",value:function(e){for(var t,o=Object.keys(e),n={},a=0,s=o.length;a1e3*a)return this._commandRequestInfoMap.set(t,{startTime:Date.now(),requestCount:1}),!1;i+=1,this._commandRequestInfoMap.set(t,{startTime:r,requestCount:i});var c=!1;return i>n&&(c=!0),c}},{key:"_isServerOverload",value:function(e){if(!this._serverOverloadInfoMap.has(e))return!1;var t=this._serverOverloadInfoMap.get(e),o=t.overloadTime,n=t.waitingTime,a=!1;return Date.now()-o<=1e3*n?a=!0:(this._serverOverloadInfoMap.delete(e),a=!1),a}},{key:"onPushedServerOverload",value:function(e){var t=e.overloadCommand,o=e.waitingTime;this._serverOverloadInfoMap.set(t,{overloadTime:Date.now(),waitingTime:o}),we.warn("".concat(this._className,".onPushedServerOverload waitingTime:").concat(o,"s"))}},{key:"reset",value:function(){we.log("".concat(this._className,".reset")),this._updateCommandFrequencyLimitMap(Or),this._commandRequestInfoMap.clear(),this._serverOverloadInfoMap.clear()}}]),o}(Do),Lr=function(e){i(o,e);var t=f(o);function o(e){var a;return n(this,o),(a=t.call(this,e))._className="MessageLossDetectionModule",a._maybeLostSequencesMap=new Map,a._firstRoundRet=[],a}return s(o,[{key:"onMessageMaybeLost",value:function(e,t,o){this._maybeLostSequencesMap.has(e)||this._maybeLostSequencesMap.set(e,[]);for(var n=this._maybeLostSequencesMap.get(e),a=0;a=this._expiredTime}},{key:"fetchConfig",value:function(){var e=this,t=this._canFetchConfig();if(we.log("".concat(this._className,".fetchConfig canFetchConfig:").concat(t)),t){var o=new va(ya.FETCH_CLOUD_CONTROL_CONFIG),n=this.getModule(uo).getSDKAppID();this._isFetching=!0,this.request({protocolName:$n,requestData:{SDKAppID:n,version:this._version}}).then((function(t){e._isFetching=!1,o.setMessage("version:".concat(e._version," newVersion:").concat(t.data.version," config:").concat(t.data.cloudControlConfig)).setNetworkType(e.getNetworkType()).end(),we.log("".concat(e._className,".fetchConfig ok")),e._parseCloudControlConfig(t.data)})).catch((function(t){e._isFetching=!1,e.probeNetwork().then((function(e){var n=m(e,2),a=n[0],s=n[1];o.setError(t,a,s).end()})),we.log("".concat(e._className,".fetchConfig failed. error:"),t),e._setExpiredTimeOnResponseError(12e4)}))}}},{key:"onPushedCloudControlConfig",value:function(e){we.log("".concat(this._className,".onPushedCloudControlConfig")),new va(ya.PUSHED_CLOUD_CONTROL_CONFIG).setNetworkType(this.getNetworkType()).setMessage("newVersion:".concat(e.version," config:").concat(e.cloudControlConfig)).end(),this._parseCloudControlConfig(e)}},{key:"onCheckTimer",value:function(e){this._canFetchConfig()&&this.fetchConfig()}},{key:"_parseCloudControlConfig",value:function(e){var t=this,o="".concat(this._className,"._parseCloudControlConfig"),n=e.errorCode,a=e.errorMessage,s=e.cloudControlConfig,r=e.version,i=e.expiredTime;if(0===n){if(this._version!==r){var c=null;try{c=JSON.parse(s)}catch(u){we.error("".concat(o," JSON parse error:").concat(s))}c&&(this._cloudConfig.clear(),Object.keys(c).forEach((function(e){t._cloudConfig.set(e,c[e])})),this._version=r,this.emitInnerEvent(Xa))}this._expiredTime=Date.now()+1e3*i}else Ze(n)?(we.log("".concat(o," failed. Invalid message format:"),e),this._setExpiredTimeOnResponseError(36e5)):(we.error("".concat(o," errorCode:").concat(n," errorMessage:").concat(a)),this._setExpiredTimeOnResponseError(12e4))}},{key:"_setExpiredTimeOnResponseError",value:function(e){this._expiredTime=Date.now()+e}},{key:"reset",value:function(){we.log("".concat(this._className,".reset")),this._cloudConfig.clear(),this._expiredTime=0,this._version=0,this._isFetching=!1}}]),o}(Do),Gr=function(e){i(o,e);var t=f(o);function o(e){var a;return n(this,o),(a=t.call(this,e))._className="PullGroupMessageModule",a._remoteLastMessageSequenceMap=new Map,a.PULL_LIMIT_COUNT=15,a}return s(o,[{key:"startPull",value:function(){var e=this,t=this._getNeedPullConversationList();this._getRemoteLastMessageSequenceList().then((function(){var o=e.getModule(co);t.forEach((function(t){var n=t.conversationID,a=n.replace(D.CONV_GROUP,""),s=o.getGroupLocalLastMessageSequence(n),r=e._remoteLastMessageSequenceMap.get(a)||0,i=r-s;we.log("".concat(e._className,".startPull groupID:").concat(a," localLastMessageSequence:").concat(s," ")+"remoteLastMessageSequence:".concat(r," diff:").concat(i)),s>0&&i>=1&&i<300&&e._pullMissingMessage({groupID:a,localLastMessageSequence:s,remoteLastMessageSequence:r,diff:i})}))}))}},{key:"_getNeedPullConversationList",value:function(){return this.getModule(co).getLocalConversationList().filter((function(e){return e.type===D.CONV_GROUP&&e.groupProfile.type!==D.GRP_AVCHATROOM}))}},{key:"_getRemoteLastMessageSequenceList",value:function(){var e=this;return this.getModule(ao).getGroupList().then((function(t){for(var o=t.data.groupList,n=void 0===o?[]:o,a=0;athis.PULL_LIMIT_COUNT?this.PULL_LIMIT_COUNT:a,e.sequence=a>this.PULL_LIMIT_COUNT?o+this.PULL_LIMIT_COUNT:o+a,this._getGroupMissingMessage(e).then((function(s){s.length>0&&(s[0].sequence+1<=n&&(e.localLastMessageSequence=o+t.PULL_LIMIT_COUNT,e.diff=a-t.PULL_LIMIT_COUNT,t._pullMissingMessage(e)),t.getModule(ao).onNewGroupMessage({dataList:s,isInstantMessage:!1}))}))}},{key:"_getGroupMissingMessage",value:function(e){var t=this,o=new va(ya.GET_GROUP_MISSING_MESSAGE);return this.request({protocolName:hn,requestData:{groupID:e.groupID,count:e.count,sequence:e.sequence}}).then((function(n){var a=n.data.messageList,s=void 0===a?[]:a;return o.setNetworkType(t.getNetworkType()).setMessage("groupID:".concat(e.groupID," count:").concat(e.count," sequence:").concat(e.sequence," messageList length:").concat(s.length)).end(),s})).catch((function(e){t.probeNetwork().then((function(t){var n=m(t,2),a=n[0],s=n[1];o.setError(e,a,s).end()}))}))}},{key:"reset",value:function(){we.log("".concat(this._className,".reset")),this._remoteLastMessageSequenceMap.clear()}}]),o}(Do),Pr=function(){function e(){n(this,e),this._className="AvgE2EDelay",this._e2eDelayArray=[]}return s(e,[{key:"addMessageDelay",value:function(e){var t=ke()-e;t>=0&&this._e2eDelayArray.push(t)}},{key:"_calcAvg",value:function(e,t){if(0===t)return 0;var o=0;return e.forEach((function(e){o+=e})),Pt(o/t,1)}},{key:"_calcCountWithLimit",value:function(e){var t=e.e2eDelayArray,o=e.min,n=e.max;return t.filter((function(e){return o<=e&&e100&&(o=100),o}},{key:"_checkE2EDelayException",value:function(e,t){var o=e.filter((function(e){return e>t}));if(o.length>0){var n=o.length,a=Math.min.apply(Math,M(o)),s=Math.max.apply(Math,M(o)),r=this._calcAvg(o,n),i=Pt(n/e.length*100,2);if(i>50)new va(ya.MESSAGE_E2E_DELAY_EXCEPTION).setMessage("message e2e delay exception. count:".concat(n," min:").concat(a," max:").concat(s," avg:").concat(r," percent:").concat(i)).setLevel("warning").end()}}},{key:"getStatResult",value:function(){var e=this._e2eDelayArray.length;if(0===e)return null;var t=M(this._e2eDelayArray),o=this._calcCountWithLimit({e2eDelayArray:t,min:0,max:1}),n=this._calcCountWithLimit({e2eDelayArray:t,min:1,max:3}),a=this._calcPercent(o,e),s=this._calcPercent(n,e),r=this._calcAvg(t,e);return this._checkE2EDelayException(t,3),t.length=0,this.reset(),{totalCount:e,countLessThan1Second:o,percentOfCountLessThan1Second:a,countLessThan3Second:n,percentOfCountLessThan3Second:s,avgDelay:r}}},{key:"reset",value:function(){this._e2eDelayArray.length=0}}]),e}(),Ur=function(){function e(){n(this,e),this._className="AvgRTT",this._requestCount=0,this._rttArray=[]}return s(e,[{key:"addRequestCount",value:function(){this._requestCount+=1}},{key:"addRTT",value:function(e){this._rttArray.push(e)}},{key:"_calcTotalCount",value:function(){return this._requestCount}},{key:"_calcRTTCount",value:function(e){return e.length}},{key:"_calcSuccessRateOfRequest",value:function(e,t){if(0===t)return 0;var o=Pt(e/t*100,2);return o>100&&(o=100),o}},{key:"_calcAvg",value:function(e,t){if(0===t)return 0;var o=0;return e.forEach((function(e){o+=e})),parseInt(o/t)}},{key:"_calcMax",value:function(){return Math.max.apply(Math,M(this._rttArray))}},{key:"_calcMin",value:function(){return Math.min.apply(Math,M(this._rttArray))}},{key:"getStatResult",value:function(){var e=this._calcTotalCount(),t=M(this._rttArray);if(0===e)return null;var o=this._calcRTTCount(t),n=this._calcSuccessRateOfRequest(o,e),a=this._calcAvg(t,o);return we.log("".concat(this._className,".getStatResult max:").concat(this._calcMax()," min:").concat(this._calcMin()," avg:").concat(a)),this.reset(),{totalCount:e,rttCount:o,successRateOfRequest:n,avgRTT:a}}},{key:"reset",value:function(){this._requestCount=0,this._rttArray.length=0}}]),e}(),wr=function(){function e(){n(this,e),this._map=new Map}return s(e,[{key:"initMap",value:function(e){var t=this;e.forEach((function(e){t._map.set(e,{totalCount:0,successCount:0,failedCountOfUserSide:0,costArray:[],fileSizeArray:[]})}))}},{key:"addTotalCount",value:function(e){return!(Ze(e)||!this._map.has(e))&&(this._map.get(e).totalCount+=1,!0)}},{key:"addSuccessCount",value:function(e){return!(Ze(e)||!this._map.has(e))&&(this._map.get(e).successCount+=1,!0)}},{key:"addFailedCountOfUserSide",value:function(e){return!(Ze(e)||!this._map.has(e))&&(this._map.get(e).failedCountOfUserSide+=1,!0)}},{key:"addCost",value:function(e,t){return!(Ze(e)||!this._map.has(e))&&(this._map.get(e).costArray.push(t),!0)}},{key:"addFileSize",value:function(e,t){return!(Ze(e)||!this._map.has(e))&&(this._map.get(e).fileSizeArray.push(t),!0)}},{key:"_calcSuccessRateOfBusiness",value:function(e){if(Ze(e)||!this._map.has(e))return-1;var t=this._map.get(e),o=Pt(t.successCount/t.totalCount*100,2);return o>100&&(o=100),o}},{key:"_calcSuccessRateOfPlatform",value:function(e){if(Ze(e)||!this._map.has(e))return-1;var t=this._map.get(e),o=this._calcSuccessCountOfPlatform(e)/t.totalCount*100;return(o=Pt(o,2))>100&&(o=100),o}},{key:"_calcTotalCount",value:function(e){return Ze(e)||!this._map.has(e)?-1:this._map.get(e).totalCount}},{key:"_calcSuccessCountOfBusiness",value:function(e){return Ze(e)||!this._map.has(e)?-1:this._map.get(e).successCount}},{key:"_calcSuccessCountOfPlatform",value:function(e){if(Ze(e)||!this._map.has(e))return-1;var t=this._map.get(e);return t.successCount+t.failedCountOfUserSide}},{key:"_calcAvg",value:function(e){return Ze(e)||!this._map.has(e)?-1:e===da?this._calcAvgSpeed(e):this._calcAvgCost(e)}},{key:"_calcAvgCost",value:function(e){var t=this._map.get(e).costArray.length;if(0===t)return 0;var o=0;return this._map.get(e).costArray.forEach((function(e){o+=e})),parseInt(o/t)}},{key:"_calcAvgSpeed",value:function(e){var t=0,o=0;return this._map.get(e).costArray.forEach((function(e){t+=e})),this._map.get(e).fileSizeArray.forEach((function(e){o+=e})),parseInt(1e3*o/t)}},{key:"getStatResult",value:function(e){var t=this._calcTotalCount(e);if(0===t)return null;var o=this._calcSuccessCountOfBusiness(e),n=this._calcSuccessRateOfBusiness(e),a=this._calcSuccessCountOfPlatform(e),s=this._calcSuccessRateOfPlatform(e),r=this._calcAvg(e);return this.reset(e),{totalCount:t,successCountOfBusiness:o,successRateOfBusiness:n,successCountOfPlatform:a,successRateOfPlatform:s,avgValue:r}}},{key:"reset",value:function(e){Ze(e)?this._map.clear():this._map.set(e,{totalCount:0,successCount:0,failedCountOfUserSide:0,costArray:[],fileSizeArray:[]})}}]),e}(),br=function(){function e(){n(this,e),this._lastMap=new Map,this._currentMap=new Map}return s(e,[{key:"initMap",value:function(e){var t=this;e.forEach((function(e){t._lastMap.set(e,new Map),t._currentMap.set(e,new Map)}))}},{key:"addMessageSequence",value:function(e){var t=e.key,o=e.message;if(Ze(t)||!this._lastMap.has(t)||!this._currentMap.has(t))return!1;var n=o.conversationID,a=o.sequence,s=n.replace(D.CONV_GROUP,"");if(0===this._lastMap.get(t).size)this._addCurrentMap(e);else if(this._lastMap.get(t).has(s)){var r=this._lastMap.get(t).get(s),i=r.length-1;a>r[0]&&a100&&(n=100),this._copyData(e),{totalCount:t,successCountOfMessageReceived:o,successRateOfMessageReceived:n}}},{key:"reset",value:function(){this._currentMap.clear(),this._lastMap.clear()}}]),e}(),Fr=function(e){i(a,e);var o=f(a);function a(e){var t;n(this,a),(t=o.call(this,e))._className="QualityStatModule",t.TAG="im-ssolog-quality-stat",t.reportIndex=0,t.wholePeriod=!1,t._qualityItems=[sa,ra,ia,ca,ua,la,da,pa,ga,_a],t._messageSentItems=[ia,ca,ua,la,da],t._messageReceivedItems=[pa,ga,_a],t.REPORT_INTERVAL=120,t.REPORT_SDKAPPID_BLACKLIST=[],t.REPORT_TINYID_WHITELIST=[],t._statInfoArr=[],t._avgRTT=new Ur,t._avgE2EDelay=new Pr,t._rateMessageSent=new wr,t._rateMessageReceived=new br;var s=t.getInnerEmitterInstance();return s.on(Ja,t._onLoginSuccess,_(t)),s.on(Xa,t._onCloudConfigUpdated,_(t)),t}return s(a,[{key:"_onLoginSuccess",value:function(){var e=this;this._rateMessageSent.initMap(this._messageSentItems),this._rateMessageReceived.initMap(this._messageReceivedItems);var t=this.getModule(lo),o=t.getItem(this.TAG,!1);!Vt(o)&&ot(o.forEach)&&(we.log("".concat(this._className,"._onLoginSuccess.get quality stat log in storage, nums=").concat(o.length)),o.forEach((function(t){e._statInfoArr.push(t)})),t.removeItem(this.TAG,!1))}},{key:"_onCloudConfigUpdated",value:function(){var e=this.getCloudConfig("q_rpt_interval"),t=this.getCloudConfig("q_rpt_sdkappid_bl"),o=this.getCloudConfig("q_rpt_tinyid_wl");Ze(e)||(this.REPORT_INTERVAL=Number(e)),Ze(t)||(this.REPORT_SDKAPPID_BLACKLIST=t.split(",").map((function(e){return Number(e)}))),Ze(o)||(this.REPORT_TINYID_WHITELIST=o.split(","))}},{key:"onCheckTimer",value:function(e){this.isLoggedIn()&&e%this.REPORT_INTERVAL==0&&(this.wholePeriod=!0,this._report())}},{key:"addRequestCount",value:function(){this._avgRTT.addRequestCount()}},{key:"addRTT",value:function(e){this._avgRTT.addRTT(e)}},{key:"addMessageDelay",value:function(e){this._avgE2EDelay.addMessageDelay(e)}},{key:"addTotalCount",value:function(e){this._rateMessageSent.addTotalCount(e)||we.warn("".concat(this._className,".addTotalCount invalid key:"),e)}},{key:"addSuccessCount",value:function(e){this._rateMessageSent.addSuccessCount(e)||we.warn("".concat(this._className,".addSuccessCount invalid key:"),e)}},{key:"addFailedCountOfUserSide",value:function(e){this._rateMessageSent.addFailedCountOfUserSide(e)||we.warn("".concat(this._className,".addFailedCountOfUserSide invalid key:"),e)}},{key:"addCost",value:function(e,t){this._rateMessageSent.addCost(e,t)||we.warn("".concat(this._className,".addCost invalid key or cost:"),e,t)}},{key:"addFileSize",value:function(e,t){this._rateMessageSent.addFileSize(e,t)||we.warn("".concat(this._className,".addFileSize invalid key or size:"),e,t)}},{key:"addMessageSequence",value:function(e){this._rateMessageReceived.addMessageSequence(e)||we.warn("".concat(this._className,".addMessageSequence invalid key:"),e.key)}},{key:"_getQualityItem",value:function(e){var o={},n=ma[this.getNetworkType()];Ze(n)&&(n=8);var a={qualityType:ha[e],timestamp:Re(),networkType:n,extension:""};switch(e){case sa:o=this._avgRTT.getStatResult();break;case ra:o=this._avgE2EDelay.getStatResult();break;case ia:case ca:case ua:case la:case da:o=this._rateMessageSent.getStatResult(e);break;case pa:case ga:case _a:o=this._rateMessageReceived.getStatResult(e)}return null===o?null:t(t({},a),o)}},{key:"_report",value:function(e){var t=this,o=[],n=null;Ze(e)?this._qualityItems.forEach((function(e){null!==(n=t._getQualityItem(e))&&(n.reportIndex=t.reportIndex,n.wholePeriod=t.wholePeriod,o.push(n))})):null!==(n=this._getQualityItem(e))&&(n.reportIndex=this.reportIndex,n.wholePeriod=this.wholePeriod,o.push(n)),we.debug("".concat(this._className,"._report"),o),this._statInfoArr.length>0&&(o=o.concat(this._statInfoArr),this._statInfoArr=[]);var a=this.getModule(uo),s=a.getSDKAppID(),r=a.getTinyID();Ut(this.REPORT_SDKAPPID_BLACKLIST,s)&&!wt(this.REPORT_TINYID_WHITELIST,r)&&(o=[]),o.length>0&&this._doReport(o)}},{key:"_doReport",value:function(e){var o=this,n={header:Hs(this),quality:e};this.request({protocolName:Vn,requestData:t({},n)}).then((function(){o.reportIndex++,o.wholePeriod=!1})).catch((function(t){we.warn("".concat(o._className,"._doReport, online:").concat(o.getNetworkType()," error:"),t),o._statInfoArr=o._statInfoArr.concat(e),o._flushAtOnce()}))}},{key:"_flushAtOnce",value:function(){var e=this.getModule(lo),t=e.getItem(this.TAG,!1),o=this._statInfoArr;if(Vt(t))we.log("".concat(this._className,"._flushAtOnce count:").concat(o.length)),e.setItem(this.TAG,o,!0,!1);else{var n=o.concat(t);n.length>10&&(n=n.slice(0,10)),we.log("".concat(this.className,"._flushAtOnce count:").concat(n.length)),e.setItem(this.TAG,n,!0,!1)}this._statInfoArr=[]}},{key:"reset",value:function(){we.log("".concat(this._className,".reset")),this._report(),this.reportIndex=0,this.wholePeriod=!1,this.REPORT_SDKAPPID_BLACKLIST=[],this.REPORT_TINYID_WHITELIST=[],this._avgRTT.reset(),this._avgE2EDelay.reset(),this._rateMessageSent.reset(),this._rateMessageReceived.reset()}}]),a}(Do),qr=function(e){i(o,e);var t=f(o);function o(e){var a;return n(this,o),(a=t.call(this,e))._className="WorkerTimerModule",a._isWorkerEnabled=!0,a._workerTimer=null,a._init(),a.getInnerEmitterInstance().on(Xa,a._onCloudConfigUpdated,_(a)),a}return s(o,[{key:"isWorkerEnabled",value:function(){return this._isWorkerEnabled&&Ee}},{key:"startWorkerTimer",value:function(){we.log("".concat(this._className,".startWorkerTimer")),this._workerTimer&&this._workerTimer.postMessage("start")}},{key:"stopWorkerTimer",value:function(){we.log("".concat(this._className,".stopWorkerTimer")),this._workerTimer&&this._workerTimer.postMessage("stop")}},{key:"_init",value:function(){if(Ee){var e=URL.createObjectURL(new Blob(['let interval = -1;onmessage = function(event) { if (event.data === "start") { if (interval > 0) { clearInterval(interval); } interval = setInterval(() => { postMessage(""); }, 1000) } else if (event.data === "stop") { clearInterval(interval); interval = -1; }};'],{type:"application/javascript; charset=utf-8"}));this._workerTimer=new Worker(e);var t=this;this._workerTimer.onmessage=function(){t._moduleManager.onCheckTimer()}}}},{key:"_onCloudConfigUpdated",value:function(){var e=this.getCloudConfig("enable_worker");we.log("".concat(this._className,"._onCloudConfigUpdated enableWorker:").concat(e)),"1"===e?!this._isWorkerEnabled&&Ee&&(this._isWorkerEnabled=!0,this.startWorkerTimer(),this._moduleManager.onWorkerTimerEnabled()):this._isWorkerEnabled&&Ee&&(this._isWorkerEnabled=!1,this.stopWorkerTimer(),this._moduleManager.onWorkerTimerDisabled())}},{key:"terminate",value:function(){we.log("".concat(this._className,".terminate")),this._workerTimer&&(this._workerTimer.terminate(),this._workerTimer=null)}},{key:"reset",value:function(){we.log("".concat(this._className,".reset"))}}]),o}(Do),Vr=function(){function e(){n(this,e),this._className="PurchasedFeatureHandler",this._purchasedFeatureMap=new Map}return s(e,[{key:"isValidPurchaseBits",value:function(e){return e&&"string"==typeof e&&e.length>=1&&e.length<=64&&/[01]{1,64}/.test(e)}},{key:"parsePurchaseBits",value:function(e){var t="".concat(this._className,".parsePurchaseBits");if(this.isValidPurchaseBits(e)){this._purchasedFeatureMap.clear();for(var o=Object.values(B),n=null,a=e.length-1,s=0;a>=0;a--,s++)n=s<32?new L(0,Math.pow(2,s)).toString():new L(Math.pow(2,s-32),0).toString(),-1!==o.indexOf(n)&&("1"===e[a]?this._purchasedFeatureMap.set(n,!0):this._purchasedFeatureMap.set(n,!1))}else we.warn("".concat(t," invalid purchase bits:").concat(e))}},{key:"hasPurchasedFeature",value:function(e){return!!this._purchasedFeatureMap.get(e)}},{key:"clear",value:function(){this._purchasedFeatureMap.clear()}}]),e}(),Kr=function(e){i(o,e);var t=f(o);function o(e){var a;return n(this,o),(a=t.call(this,e))._className="CommercialConfigModule",a._expiredTime=0,a._isFetching=!1,a._purchasedFeatureHandler=new Vr,a}return s(o,[{key:"_canFetch",value:function(){return this.isLoggedIn()?!this._isFetching&&Date.now()>=this._expiredTime:(this._expiredTime=Date.now()+2e3,!1)}},{key:"onCheckTimer",value:function(e){this._canFetch()&&this.fetchConfig()}},{key:"fetchConfig",value:function(){var e=this,t=this._canFetch(),o="".concat(this._className,".fetchConfig");if(we.log("".concat(o," canFetch:").concat(t)),t){var n=new va(ya.FETCH_COMMERCIAL_CONFIG);n.setNetworkType(this.getNetworkType());var a=this.getModule(uo).getSDKAppID();this._isFetching=!0,this.request({protocolName:Jn,requestData:{SDKAppID:a}}).then((function(t){n.setMessage("purchaseBits:".concat(t.data.purchaseBits)).end(),we.log("".concat(o," ok.")),e._parseConfig(t.data),e._isFetching=!1})).catch((function(t){e.probeNetwork().then((function(e){var o=m(e,2),a=o[0],s=o[1];n.setError(t,a,s).end()})),e._isFetching=!1}))}}},{key:"onPushedConfig",value:function(e){var t="".concat(this._className,".onPushedConfig");we.log("".concat(t)),new va(ya.PUSHED_COMMERCIAL_CONFIG).setNetworkType(this.getNetworkType()).setMessage("purchaseBits:".concat(e.purchaseBits)).end(),this._parseConfig(e)}},{key:"_parseConfig",value:function(e){var t="".concat(this._className,"._parseConfig"),o=e.errorCode,n=e.errorMessage,a=e.purchaseBits,s=e.expiredTime;0===o?(this._purchasedFeatureHandler.parsePurchaseBits(a),this._expiredTime=Date.now()+1e3*s):Ze(o)?(we.log("".concat(t," failed. Invalid message format:"),e),this._setExpiredTimeOnResponseError(36e5)):(we.error("".concat(t," errorCode:").concat(o," errorMessage:").concat(n)),this._setExpiredTimeOnResponseError(12e4))}},{key:"_setExpiredTimeOnResponseError",value:function(e){this._expiredTime=Date.now()+e}},{key:"hasPurchasedFeature",value:function(e){return this._purchasedFeatureHandler.hasPurchasedFeature(e)}},{key:"reset",value:function(){we.log("".concat(this._className,".reset")),this._expiredTime=0,this._isFetching=!1,this._purchasedFeatureHandler.clear()}}]),o}(Do),Hr=function(){function e(t){n(this,e);var o=new va(ya.SDK_CONSTRUCT);this._className="ModuleManager",this._isReady=!1,this._reason=na.USER_NOT_LOGGED_IN,this._startLoginTs=0,this._moduleMap=new Map,this._innerEmitter=null,this._outerEmitter=null,this._checkCount=0,this._checkTimer=-1,this._moduleMap.set(uo,new bs(this,t)),this._moduleMap.set(So,new Kr(this)),this._moduleMap.set(Io,new kr(this)),this._moduleMap.set(Eo,new qr(this)),this._moduleMap.set(Co,new Fr(this)),this._moduleMap.set(vo,new Tr(this)),this._moduleMap.set(Mo,new Rr(this)),this._moduleMap.set(eo,new Fs(this)),this._moduleMap.set(to,new or(this)),this._moduleMap.set(oo,new ws(this)),this._moduleMap.set(no,new $a(this)),this._moduleMap.set(co,new _s(this)),this._moduleMap.set(ao,new Ds(this)),this._moduleMap.set(ro,new As(this)),this._moduleMap.set(io,new ks(this)),this._moduleMap.set(lo,new Vs(this)),this._moduleMap.set(po,new Bs(this)),this._moduleMap.set(go,new js(this)),this._moduleMap.set(_o,new zs(this)),this._moduleMap.set(ho,new Xs(this)),this._moduleMap.set(fo,new nr(this)),this._moduleMap.set(mo,new ar(this)),this._moduleMap.set(yo,new Lr(this)),this._moduleMap.set(To,new Gr(this)),this._eventThrottleMap=new Map;var a=t.instanceID,s=t.oversea,r=t.SDKAppID,i="instanceID:".concat(a," SDKAppID:").concat(r," host:").concat(Rt()," oversea:").concat(s," inBrowser:").concat(oe," inMiniApp:").concat(te)+" workerAvailable:".concat(Ee," UserAgent:").concat(se);va.bindEventStatModule(this._moduleMap.get(po)),o.setMessage("".concat(i," ").concat(function(){var e="";if(te)try{var t=ne.getSystemInfoSync(),o=t.model,n=t.version,a=t.system,s=t.platform,r=t.SDKVersion;e="model:".concat(o," version:").concat(n," system:").concat(a," platform:").concat(s," SDKVersion:").concat(r)}catch(i){e=""}return e}())).end(),we.info("SDK ".concat(i)),this._readyList=void 0,this._ssoLogForReady=null,this._initReadyList()}return s(e,[{key:"_startTimer",value:function(){var e=this._moduleMap.get(Eo),t=e.isWorkerEnabled();we.log("".concat(this._className,".startTimer isWorkerEnabled:").concat(t," seed:").concat(this._checkTimer)),t?e.startWorkerTimer():this._startMainThreadTimer()}},{key:"_startMainThreadTimer",value:function(){we.log("".concat(this._className,"._startMainThreadTimer")),this._checkTimer<0&&(this._checkTimer=setInterval(this.onCheckTimer.bind(this),1e3))}},{key:"stopTimer",value:function(){var e=this._moduleMap.get(Eo),t=e.isWorkerEnabled();we.log("".concat(this._className,".stopTimer isWorkerEnabled:").concat(t," seed:").concat(this._checkTimer)),t?e.stopWorkerTimer():this._stopMainThreadTimer()}},{key:"_stopMainThreadTimer",value:function(){we.log("".concat(this._className,"._stopMainThreadTimer")),this._checkTimer>0&&(clearInterval(this._checkTimer),this._checkTimer=-1,this._checkCount=0)}},{key:"_stopMainThreadSocket",value:function(){we.log("".concat(this._className,"._stopMainThreadSocket"));var e=this._moduleMap.get(vo);e.setIsWorkerEnabled(!0),e.reConnect()}},{key:"_startMainThreadSocket",value:function(){we.log("".concat(this._className,"._startMainThreadSocket"));var e=this._moduleMap.get(vo);e.setIsWorkerEnabled(!1),e.reConnect()}},{key:"onWorkerTimerEnabled",value:function(){we.log("".concat(this._className,".onWorkerTimerEnabled, disable main thread timer and socket")),this._stopMainThreadTimer(),this._stopMainThreadSocket()}},{key:"onWorkerTimerDisabled",value:function(){we.log("".concat(this._className,".onWorkerTimerDisabled, enable main thread timer and socket")),this._startMainThreadTimer(),this._startMainThreadSocket()}},{key:"onCheckTimer",value:function(){this._checkCount+=1;var e,t=C(this._moduleMap);try{for(t.s();!(e=t.n()).done;){var o=m(e.value,2)[1];o.onCheckTimer&&o.onCheckTimer(this._checkCount)}}catch(n){t.e(n)}finally{t.f()}}},{key:"_initReadyList",value:function(){var e=this;this._readyList=[this._moduleMap.get(eo),this._moduleMap.get(co)],this._readyList.forEach((function(t){t.ready((function(){return e._onModuleReady()}))}))}},{key:"_onModuleReady",value:function(){var e=!0;if(this._readyList.forEach((function(t){t.isReady()||(e=!1)})),e&&!this._isReady){this._isReady=!0,this._outerEmitter.emit(S.SDK_READY);var t=Date.now()-this._startLoginTs;we.warn("SDK is ready. cost ".concat(t," ms")),this._startLoginTs=Date.now();var o=this._moduleMap.get(go).getNetworkType(),n=this._ssoLogForReady.getStartTs()+Oe;this._ssoLogForReady.setNetworkType(o).setMessage(t).start(n).end()}}},{key:"login",value:function(){0===this._startLoginTs&&(Le(),this._startLoginTs=Date.now(),this._startTimer(),this._moduleMap.get(go).start(),this._ssoLogForReady=new va(ya.SDK_READY),this._reason=na.LOGGING_IN)}},{key:"onLoginFailed",value:function(){this._startLoginTs=0}},{key:"getOuterEmitterInstance",value:function(){return null===this._outerEmitter&&(this._outerEmitter=new $s,Wa(this._outerEmitter),this._outerEmitter._emit=this._outerEmitter.emit,this._outerEmitter.emit=function(e,t){var o=this;if(e===S.CONVERSATION_LIST_UPDATED||e===S.FRIEND_LIST_UPDATED||e===S.GROUP_LIST_UPDATED)if(this._eventThrottleMap.has(e)){var n=Date.now(),a=this._eventThrottleMap.get(e);n-a.last<1e3?(a.timeoutID&&clearTimeout(a.timeoutID),a.timeoutID=setTimeout((function(){a.last=n,o._outerEmitter._emit.apply(o._outerEmitter,[e,{name:e,data:o._getEventData(e)}])}),500)):(a.last=n,this._outerEmitter._emit.apply(this._outerEmitter,[e,{name:e,data:this._getEventData(e)}]))}else this._eventThrottleMap.set(e,{last:Date.now(),timeoutID:-1}),this._outerEmitter._emit.apply(this._outerEmitter,[e,{name:e,data:this._getEventData(e)}]);else this._outerEmitter._emit.apply(this._outerEmitter,[e,{name:e,data:arguments[1]}])}.bind(this)),this._outerEmitter}},{key:"_getEventData",value:function(e){return e===S.CONVERSATION_LIST_UPDATED?this._moduleMap.get(co).getLocalConversationList():e===S.FRIEND_LIST_UPDATED?this._moduleMap.get(so).getLocalFriendList(!1):e===S.GROUP_LIST_UPDATED?this._moduleMap.get(ao).getLocalGroupList():void 0}},{key:"getInnerEmitterInstance",value:function(){return null===this._innerEmitter&&(this._innerEmitter=new $s,this._innerEmitter._emit=this._innerEmitter.emit,this._innerEmitter.emit=function(e,t){var o;Xe(arguments[1])&&arguments[1].data?(we.warn("inner eventData has data property, please check!"),o=[e,{name:arguments[0],data:arguments[1].data}]):o=[e,{name:arguments[0],data:arguments[1]}],this._innerEmitter._emit.apply(this._innerEmitter,o)}.bind(this)),this._innerEmitter}},{key:"hasModule",value:function(e){return this._moduleMap.has(e)}},{key:"getModule",value:function(e){return this._moduleMap.get(e)}},{key:"isReady",value:function(){return this._isReady}},{key:"getNotReadyReason",value:function(){return this._reason}},{key:"setNotReadyReason",value:function(e){this._reason=e}},{key:"onError",value:function(e){we.warn("Oops! code:".concat(e.code," message:").concat(e.message)),new va(ya.ERROR).setMessage("code:".concat(e.code," message:").concat(e.message)).setNetworkType(this.getModule(go).getNetworkType()).setLevel("error").end(),this.getOuterEmitterInstance().emit(S.ERROR,e)}},{key:"reset",value:function(){we.log("".concat(this._className,".reset")),Le();var e,t=C(this._moduleMap);try{for(t.s();!(e=t.n()).done;){var o=m(e.value,2)[1];o.reset&&o.reset()}}catch(r){t.e(r)}finally{t.f()}this._startLoginTs=0,this._initReadyList(),this._isReady=!1,this.stopTimer(),this._outerEmitter.emit(S.SDK_NOT_READY);var n,a=C(this._eventThrottleMap);try{for(a.s();!(n=a.n()).done;){var s=m(n.value,2)[1];s.timeoutID&&clearTimeout(s.timeoutID)}}catch(r){a.e(r)}finally{a.f()}this._eventThrottleMap.clear()}}]),e}(),Br=function(){function e(){n(this,e),this._funcMap=new Map}return s(e,[{key:"defense",value:function(e,t){var o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0;if("string"!=typeof e)return null;if(0===e.length)return null;if("function"!=typeof t)return null;if(this._funcMap.has(e)&&this._funcMap.get(e).has(t))return this._funcMap.get(e).get(t);this._funcMap.has(e)||this._funcMap.set(e,new Map);var n=null;return this._funcMap.get(e).has(t)?n=this._funcMap.get(e).get(t):(n=this._pack(e,t,o),this._funcMap.get(e).set(t,n)),n}},{key:"defenseOnce",value:function(e,t){var o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0;return"function"!=typeof t?null:this._pack(e,t,o)}},{key:"find",value:function(e,t){return"string"!=typeof e||0===e.length||"function"!=typeof t?null:this._funcMap.has(e)?this._funcMap.get(e).has(t)?this._funcMap.get(e).get(t):(we.log("SafetyCallback.find: 找不到 func —— ".concat(e,"/").concat(""!==t.name?t.name:"[anonymous]")),null):(we.log("SafetyCallback.find: 找不到 eventName-".concat(e," 对应的 func")),null)}},{key:"delete",value:function(e,t){return"function"==typeof t&&(!!this._funcMap.has(e)&&(!!this._funcMap.get(e).has(t)&&(this._funcMap.get(e).delete(t),0===this._funcMap.get(e).size&&this._funcMap.delete(e),!0)))}},{key:"_pack",value:function(e,t,o){return function(){try{t.apply(o,Array.from(arguments))}catch(r){var n=Object.values(S).indexOf(e);if(-1!==n){var a=Object.keys(S)[n];we.warn("接入侧事件 TIM.EVENT.".concat(a," 对应的回调函数逻辑存在问题,请检查!"),r)}var s=new va(ya.CALLBACK_FUNCTION_ERROR);s.setMessage("eventName:".concat(e)).setMoreMessage(r.message).end()}}}}]),e}(),xr=function(){function e(t){n(this,e);var o={SDKAppID:t.SDKAppID,unlimitedAVChatRoom:t.unlimitedAVChatRoom||!1,scene:t.scene||"",oversea:t.oversea||!1,instanceID:Ot(),devMode:t.devMode||!1,proxyServer:t.proxyServer||void 0};this._moduleManager=new Hr(o),this._safetyCallbackFactory=new Br}return s(e,[{key:"onError",value:function(e){this._moduleManager.onError(e)}},{key:"login",value:function(e){return this._moduleManager.login(),this._moduleManager.getModule(eo).login(e)}},{key:"logout",value:function(){var e=this;return this._moduleManager.getModule(eo).logout().then((function(t){return e._moduleManager.reset(),t}))}},{key:"isReady",value:function(){return this._moduleManager.isReady()}},{key:"getNotReadyReason",value:function(){return this._moduleManager.getNotReadyReason()}},{key:"destroy",value:function(){var e=this;return this.logout().finally((function(){e._moduleManager.stopTimer(),e._moduleManager.getModule(Eo).terminate(),e._moduleManager.getModule(vo).dealloc();var t=e._moduleManager.getOuterEmitterInstance(),o=e._moduleManager.getModule(uo);t.emit(S.SDK_DESTROY,{SDKAppID:o.getSDKAppID()})}))}},{key:"on",value:function(e,t,o){e===S.GROUP_SYSTEM_NOTICE_RECEIVED&&we.warn("!!!TIM.EVENT.GROUP_SYSTEM_NOTICE_RECEIVED v2.6.0起弃用,为了更好的体验,请在 TIM.EVENT.MESSAGE_RECEIVED 事件回调内接收处理群系统通知,详细请参考:https://web.sdk.qcloud.com/im/doc/zh-cn/Message.html#.GroupSystemNoticePayload"),we.debug("on","eventName:".concat(e)),this._moduleManager.getOuterEmitterInstance().on(e,this._safetyCallbackFactory.defense(e,t,o),o)}},{key:"once",value:function(e,t,o){we.debug("once","eventName:".concat(e)),this._moduleManager.getOuterEmitterInstance().once(e,this._safetyCallbackFactory.defenseOnce(e,t,o),o||this)}},{key:"off",value:function(e,t,o,n){we.debug("off","eventName:".concat(e));var a=this._safetyCallbackFactory.find(e,t);null!==a&&(this._moduleManager.getOuterEmitterInstance().off(e,a,o,n),this._safetyCallbackFactory.delete(e,t))}},{key:"registerPlugin",value:function(e){this._moduleManager.getModule(fo).registerPlugin(e)}},{key:"setLogLevel",value:function(e){if(e<=0){console.log([""," ________ ______ __ __ __ __ ________ _______","| \\| \\| \\ / \\| \\ _ | \\| \\| \\"," \\$$$$$$$$ \\$$$$$$| $$\\ / $$| $$ / \\ | $$| $$$$$$$$| $$$$$$$\\"," | $$ | $$ | $$$\\ / $$$| $$/ $\\| $$| $$__ | $$__/ $$"," | $$ | $$ | $$$$\\ $$$$| $$ $$$\\ $$| $$ \\ | $$ $$"," | $$ | $$ | $$\\$$ $$ $$| $$ $$\\$$\\$$| $$$$$ | $$$$$$$\\"," | $$ _| $$_ | $$ \\$$$| $$| $$$$ \\$$$$| $$_____ | $$__/ $$"," | $$ | $$ \\| $$ \\$ | $$| $$$ \\$$$| $$ \\| $$ $$"," \\$$ \\$$$$$$ \\$$ \\$$ \\$$ \\$$ \\$$$$$$$$ \\$$$$$$$","",""].join("\n")),console.log("%cIM 智能客服,随时随地解决您的问题 →_→ https://cloud.tencent.com/act/event/smarty-service?from=im-doc","color:#006eff"),console.log("%c从v2.11.2起,SDK 支持了 WebSocket,小程序需要添加受信域名!升级指引: https://web.sdk.qcloud.com/im/doc/zh-cn/tutorial-02-upgradeguideline.html","color:#ff0000");console.log(["","参考以下文档,会更快解决问题哦!(#^.^#)\n","SDK 更新日志: https://cloud.tencent.com/document/product/269/38492\n","SDK 接口文档: https://web.sdk.qcloud.com/im/doc/zh-cn/SDK.html\n","常见问题: https://web.sdk.qcloud.com/im/doc/zh-cn/tutorial-01-faq.html\n","反馈问题?戳我提 issue: https://github.com/tencentyun/TIMSDK/issues\n","如果您需要在生产环境关闭上面的日志,请 tim.setLogLevel(1)\n"].join("\n"))}we.setLevel(e)}},{key:"createTextMessage",value:function(e){return this._moduleManager.getModule(to).createTextMessage(e)}},{key:"createTextAtMessage",value:function(e){return this._moduleManager.getModule(to).createTextMessage(e)}},{key:"createImageMessage",value:function(e){return this._moduleManager.getModule(to).createImageMessage(e)}},{key:"createAudioMessage",value:function(e){return this._moduleManager.getModule(to).createAudioMessage(e)}},{key:"createVideoMessage",value:function(e){return this._moduleManager.getModule(to).createVideoMessage(e)}},{key:"createCustomMessage",value:function(e){return this._moduleManager.getModule(to).createCustomMessage(e)}},{key:"createFaceMessage",value:function(e){return this._moduleManager.getModule(to).createFaceMessage(e)}},{key:"createFileMessage",value:function(e){return this._moduleManager.getModule(to).createFileMessage(e)}},{key:"createLocationMessage",value:function(e){return this._moduleManager.getModule(to).createLocationMessage(e)}},{key:"createMergerMessage",value:function(e){return this._moduleManager.getModule(to).createMergerMessage(e)}},{key:"downloadMergerMessage",value:function(e){return e.type!==D.MSG_MERGER?ja(new Ba({code:na.MESSAGE_MERGER_TYPE_INVALID,message:aa.MESSAGE_MERGER_TYPE_INVALID})):Vt(e.payload.downloadKey)?ja(new Ba({code:na.MESSAGE_MERGER_KEY_INVALID,message:aa.MESSAGE_MERGER_KEY_INVALID})):this._moduleManager.getModule(to).downloadMergerMessage(e).catch((function(e){return ja(new Ba({code:na.MESSAGE_MERGER_DOWNLOAD_FAIL,message:aa.MESSAGE_MERGER_DOWNLOAD_FAIL}))}))}},{key:"createForwardMessage",value:function(e){return this._moduleManager.getModule(to).createForwardMessage(e)}},{key:"sendMessage",value:function(e,t){return e instanceof wa?this._moduleManager.getModule(to).sendMessageInstance(e,t):ja(new Ba({code:na.MESSAGE_SEND_NEED_MESSAGE_INSTANCE,message:aa.MESSAGE_SEND_NEED_MESSAGE_INSTANCE}))}},{key:"callExperimentalAPI",value:function(e,t){return"handleGroupInvitation"===e?this._moduleManager.getModule(ao).handleGroupInvitation(t):ja(new Ba({code:na.INVALID_OPERATION,message:aa.INVALID_OPERATION}))}},{key:"revokeMessage",value:function(e){return this._moduleManager.getModule(to).revokeMessage(e)}},{key:"resendMessage",value:function(e){return this._moduleManager.getModule(to).resendMessage(e)}},{key:"deleteMessage",value:function(e){return this._moduleManager.getModule(to).deleteMessage(e)}},{key:"modifyMessage",value:function(e){return this._moduleManager.getModule(to).modifyRemoteMessage(e)}},{key:"getMessageList",value:function(e){return this._moduleManager.getModule(co).getMessageList(e)}},{key:"getMessageListHopping",value:function(e){return this._moduleManager.getModule(co).getMessageListHopping(e)}},{key:"sendMessageReadReceipt",value:function(e){return this._moduleManager.getModule(co).sendReadReceipt(e)}},{key:"getMessageReadReceiptList",value:function(e){return this._moduleManager.getModule(co).getReadReceiptList(e)}},{key:"getGroupMessageReadMemberList",value:function(e){return this._moduleManager.getModule(ao).getReadReceiptDetail(e)}},{key:"findMessage",value:function(e){return this._moduleManager.getModule(co).findMessage(e)}},{key:"setMessageRead",value:function(e){return this._moduleManager.getModule(co).setMessageRead(e)}},{key:"getConversationList",value:function(e){return this._moduleManager.getModule(co).getConversationList(e)}},{key:"getConversationProfile",value:function(e){return this._moduleManager.getModule(co).getConversationProfile(e)}},{key:"deleteConversation",value:function(e){return this._moduleManager.getModule(co).deleteConversation(e)}},{key:"pinConversation",value:function(e){return this._moduleManager.getModule(co).pinConversation(e)}},{key:"setAllMessageRead",value:function(e){return this._moduleManager.getModule(co).setAllMessageRead(e)}},{key:"setMessageRemindType",value:function(e){return this._moduleManager.getModule(co).setMessageRemindType(e)}},{key:"getMyProfile",value:function(){return this._moduleManager.getModule(oo).getMyProfile()}},{key:"getUserProfile",value:function(e){return this._moduleManager.getModule(oo).getUserProfile(e)}},{key:"updateMyProfile",value:function(e){return this._moduleManager.getModule(oo).updateMyProfile(e)}},{key:"getBlacklist",value:function(){return this._moduleManager.getModule(oo).getLocalBlacklist()}},{key:"addToBlacklist",value:function(e){return this._moduleManager.getModule(oo).addBlacklist(e)}},{key:"removeFromBlacklist",value:function(e){return this._moduleManager.getModule(oo).deleteBlacklist(e)}},{key:"getFriendList",value:function(){var e=this._moduleManager.getModule(so);return e?e.getLocalFriendList():ja({code:na.CANNOT_FIND_MODULE,message:aa.CANNOT_FIND_MODULE})}},{key:"addFriend",value:function(e){var t=this._moduleManager.getModule(so);return t?t.addFriend(e):ja({code:na.CANNOT_FIND_MODULE,message:aa.CANNOT_FIND_MODULE})}},{key:"deleteFriend",value:function(e){var t=this._moduleManager.getModule(so);return t?t.deleteFriend(e):ja({code:na.CANNOT_FIND_MODULE,message:aa.CANNOT_FIND_MODULE})}},{key:"checkFriend",value:function(e){var t=this._moduleManager.getModule(so);return t?t.checkFriend(e):ja({code:na.CANNOT_FIND_MODULE,message:aa.CANNOT_FIND_MODULE})}},{key:"getFriendProfile",value:function(e){var t=this._moduleManager.getModule(so);return t?t.getFriendProfile(e):ja({code:na.CANNOT_FIND_MODULE,message:aa.CANNOT_FIND_MODULE})}},{key:"updateFriend",value:function(e){var t=this._moduleManager.getModule(so);return t?t.updateFriend(e):ja({code:na.CANNOT_FIND_MODULE,message:aa.CANNOT_FIND_MODULE})}},{key:"getFriendApplicationList",value:function(){var e=this._moduleManager.getModule(so);return e?e.getLocalFriendApplicationList():ja({code:na.CANNOT_FIND_MODULE,message:aa.CANNOT_FIND_MODULE})}},{key:"acceptFriendApplication",value:function(e){var t=this._moduleManager.getModule(so);return t?t.acceptFriendApplication(e):ja({code:na.CANNOT_FIND_MODULE,message:aa.CANNOT_FIND_MODULE})}},{key:"refuseFriendApplication",value:function(e){var t=this._moduleManager.getModule(so);return t?t.refuseFriendApplication(e):ja({code:na.CANNOT_FIND_MODULE,message:aa.CANNOT_FIND_MODULE})}},{key:"deleteFriendApplication",value:function(e){var t=this._moduleManager.getModule(so);return t?t.deleteFriendApplication(e):ja({code:na.CANNOT_FIND_MODULE,message:aa.CANNOT_FIND_MODULE})}},{key:"setFriendApplicationRead",value:function(){var e=this._moduleManager.getModule(so);return e?e.setFriendApplicationRead():ja({code:na.CANNOT_FIND_MODULE,message:aa.CANNOT_FIND_MODULE})}},{key:"getFriendGroupList",value:function(){var e=this._moduleManager.getModule(so);return e?e.getLocalFriendGroupList():ja({code:na.CANNOT_FIND_MODULE,message:aa.CANNOT_FIND_MODULE})}},{key:"createFriendGroup",value:function(e){var t=this._moduleManager.getModule(so);return t?t.createFriendGroup(e):ja({code:na.CANNOT_FIND_MODULE,message:aa.CANNOT_FIND_MODULE})}},{key:"deleteFriendGroup",value:function(e){var t=this._moduleManager.getModule(so);return t?t.deleteFriendGroup(e):ja({code:na.CANNOT_FIND_MODULE,message:aa.CANNOT_FIND_MODULE})}},{key:"addToFriendGroup",value:function(e){var t=this._moduleManager.getModule(so);return t?t.addToFriendGroup(e):ja({code:na.CANNOT_FIND_MODULE,message:aa.CANNOT_FIND_MODULE})}},{key:"removeFromFriendGroup",value:function(e){var t=this._moduleManager.getModule(so);return t?t.removeFromFriendGroup(e):ja({code:na.CANNOT_FIND_MODULE,message:aa.CANNOT_FIND_MODULE})}},{key:"renameFriendGroup",value:function(e){var t=this._moduleManager.getModule(so);return t?t.renameFriendGroup(e):ja({code:na.CANNOT_FIND_MODULE,message:aa.CANNOT_FIND_MODULE})}},{key:"getGroupList",value:function(e){return this._moduleManager.getModule(ao).getGroupList(e)}},{key:"getGroupProfile",value:function(e){return this._moduleManager.getModule(ao).getGroupProfile(e)}},{key:"createGroup",value:function(e){return this._moduleManager.getModule(ao).createGroup(e)}},{key:"dismissGroup",value:function(e){return this._moduleManager.getModule(ao).dismissGroup(e)}},{key:"updateGroupProfile",value:function(e){return this._moduleManager.getModule(ao).updateGroupProfile(e)}},{key:"joinGroup",value:function(e){return this._moduleManager.getModule(ao).joinGroup(e)}},{key:"quitGroup",value:function(e){return this._moduleManager.getModule(ao).quitGroup(e)}},{key:"searchGroupByID",value:function(e){return this._moduleManager.getModule(ao).searchGroupByID(e)}},{key:"getGroupOnlineMemberCount",value:function(e){return this._moduleManager.getModule(ao).getGroupOnlineMemberCount(e)}},{key:"changeGroupOwner",value:function(e){return this._moduleManager.getModule(ao).changeGroupOwner(e)}},{key:"handleGroupApplication",value:function(e){return this._moduleManager.getModule(ao).handleGroupApplication(e)}},{key:"initGroupAttributes",value:function(e){return this._moduleManager.getModule(ao).initGroupAttributes(e)}},{key:"setGroupAttributes",value:function(e){return this._moduleManager.getModule(ao).setGroupAttributes(e)}},{key:"deleteGroupAttributes",value:function(e){return this._moduleManager.getModule(ao).deleteGroupAttributes(e)}},{key:"getGroupAttributes",value:function(e){return this._moduleManager.getModule(ao).getGroupAttributes(e)}},{key:"getGroupMemberList",value:function(e){return this._moduleManager.getModule(ro).getGroupMemberList(e)}},{key:"getGroupMemberProfile",value:function(e){return this._moduleManager.getModule(ro).getGroupMemberProfile(e)}},{key:"addGroupMember",value:function(e){return this._moduleManager.getModule(ro).addGroupMember(e)}},{key:"deleteGroupMember",value:function(e){return this._moduleManager.getModule(ro).deleteGroupMember(e)}},{key:"setGroupMemberMuteTime",value:function(e){return this._moduleManager.getModule(ro).setGroupMemberMuteTime(e)}},{key:"setGroupMemberRole",value:function(e){return this._moduleManager.getModule(ro).setGroupMemberRole(e)}},{key:"setGroupMemberNameCard",value:function(e){return this._moduleManager.getModule(ro).setGroupMemberNameCard(e)}},{key:"setGroupMemberCustomField",value:function(e){return this._moduleManager.getModule(ro).setGroupMemberCustomField(e)}},{key:"getJoinedCommunityList",value:function(){return this._moduleManager.getModule(io).getJoinedCommunityList()}},{key:"createTopicInCommunity",value:function(e){return this._moduleManager.getModule(io).createTopicInCommunity(e)}},{key:"deleteTopicFromCommunity",value:function(e){return this._moduleManager.getModule(io).deleteTopicFromCommunity(e)}},{key:"updateTopicProfile",value:function(e){return this._moduleManager.getModule(io).updateTopicProfile(e)}},{key:"getTopicList",value:function(e){return this._moduleManager.getModule(io).getTopicList(e)}}]),e}(),Wr={login:"login",logout:"logout",destroy:"destroy",on:"on",off:"off",ready:"ready",setLogLevel:"setLogLevel",joinGroup:"joinGroup",quitGroup:"quitGroup",registerPlugin:"registerPlugin",getGroupOnlineMemberCount:"getGroupOnlineMemberCount"};function Yr(e,t){if(e.isReady()||void 0!==Wr[t])return!0;var o=e.getNotReadyReason(),n="";Object.getOwnPropertyNames(na).forEach((function(e){na[e]===o&&(n=aa[e])}));var a={code:o,message:"".concat(n,"导致 sdk not ready。").concat(t," ").concat(aa.SDK_IS_NOT_READY,",请参考 https://web.sdk.qcloud.com/im/doc/zh-cn/module-EVENT.html#.SDK_READY")};return e.onError(a),a}var jr={},$r={};return $r.create=function(e){var o=0;if($e(e.SDKAppID))o=e.SDKAppID;else if(we.warn("TIM.create SDKAppID 的类型应该为 Number,请修改!"),o=parseInt(e.SDKAppID),isNaN(o))return we.error("TIM.create failed. 解析 SDKAppID 失败,请检查传参!"),null;if(o&&jr[o])return jr[o];we.log("TIM.create");var n=new xr(t(t({},e),{},{SDKAppID:o}));n.on(S.SDK_DESTROY,(function(e){jr[e.data.SDKAppID]=null,delete jr[e.data.SDKAppID]}));var a=function(e){var t=Object.create(null);return Object.keys(Zt).forEach((function(o){if(e[o]){var n=Zt[o],a=new N;t[n]=function(){var t=Array.from(arguments);return a.use((function(t,n){var a=Yr(e,o);return!0===a?n():ja(a)})).use((function(e,t){if(!0===Kt(e,Qt[o],n))return t()})).use((function(t,n){return e[o].apply(e,t)})),a.run(t)}}})),t}(n);return jr[o]=a,we.log("TIM.create ok"),a},$r.TYPES=D,$r.EVENT=S,$r.VERSION="2.20.1",we.log("TIM.VERSION: ".concat($r.VERSION)),$r})); diff --git a/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/TRTCCalling/node_module/trtc-wx.js b/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/TRTCCalling/node_module/trtc-wx.js index 3fba0729ee..5d077a63fa 100644 --- a/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/TRTCCalling/node_module/trtc-wx.js +++ b/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/TRTCCalling/node_module/trtc-wx.js @@ -1,331 +1,2 @@ -!(function (e, t) { - 'object' === typeof exports && 'undefined' !== typeof module ? module.exports = t() : 'function' === typeof define && define.amd ? define(t) : (e = 'undefined' !== typeof globalThis ? globalThis : e || self).TRTC = t(); -}(this, (() => { - 'use strict';function e(e, t) { - if (!(e instanceof t)) throw new TypeError('Cannot call a class as a function'); - } function t(e, t) { - for (let r = 0;r < t.length;r++) { - const s = t[r];s.enumerable = s.enumerable || !1, s.configurable = !0, 'value' in s && (s.writable = !0), Object.defineProperty(e, s.key, s); - } - } function r(e, r, s) { - return r && t(e.prototype, r), s && t(e, s), e; - } function s(e, t, r) { - return t in e ? Object.defineProperty(e, t, { value: r, enumerable: !0, configurable: !0, writable: !0 }) : e[t] = r, e; - } function i(e, t) { - const r = Object.keys(e);if (Object.getOwnPropertySymbols) { - let s = Object.getOwnPropertySymbols(e);t && (s = s.filter((t => Object.getOwnPropertyDescriptor(e, t).enumerable))), r.push.apply(r, s); - } return r; - } function a(e) { - for (let t = 1;t < arguments.length;t++) { - var r = null != arguments[t] ? arguments[t] : {};t % 2 ? i(Object(r), !0).forEach(((t) => { - s(e, t, r[t]); - })) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(r)) : i(Object(r)).forEach(((t) => { - Object.defineProperty(e, t, Object.getOwnPropertyDescriptor(r, t)); - })); - } return e; - } function n() { - const e = (new Date).getTime(); const t = new Date(e); let r = t.getHours(); let s = t.getMinutes(); let i = t.getSeconds(); const a = t.getMilliseconds();return r = r < 10 ? '0'.concat(r) : r, s = s < 10 ? '0'.concat(s) : s, i = i < 10 ? '0'.concat(i) : i, ''.concat(r, ':').concat(s, ':') - .concat(i, '.') - .concat(a); - } const o = 'TRTC-WX'; const u = 0; const c = 1; const l = new (function () { - function t() { - e(this, t), this.logLevel = 0; - } return r(t, [{ key: 'setLogLevel', value(e) { - this.logLevel = e; - } }, { key: 'log', value() { - let e;this.logLevel === u && (e = console).log.apply(e, [o, n()].concat(Array.prototype.slice.call(arguments))); - } }, { key: 'warn', value() { - let e;this.logLevel <= c && (e = console).warn.apply(e, [o, n()].concat(Array.prototype.slice.call(arguments))); - } }, { key: 'error', value() { - let e;(e = console).error.apply(e, [o, n()].concat(Array.prototype.slice.call(arguments))); - } }]), t; - }());const h = function (e) { - const t = /[\u4e00-\u9fa5]/;return e.sdkAppID ? void 0 === e.roomID && void 0 === e.strRoomID ? (l.error('未设置 roomID'), !1) : !e.strRoomID && (e.roomID < 1 || e.roomID > 4294967296) ? (l.error('roomID 超出取值范围 1 ~ 4294967295'), !1) : e.strRoomID && t.test(e.strRoomID) ? (l.error('strRoomID 请勿使用中文字符'), !1) : e.userID ? e.userID && t.test(e.userID) ? (l.error('userID 请勿使用中文字符'), !1) : !!e.userSig || (l.error('未设置 userSig'), !1) : (l.error('未设置 userID'), !1) : (l.error('未设置 sdkAppID'), !1); - }; const p = { LOCAL_JOIN: 'LOCAL_JOIN', LOCAL_LEAVE: 'LOCAL_LEAVE', KICKED_OUT: 'KICKED_OUT', REMOTE_USER_JOIN: 'REMOTE_USER_JOIN', REMOTE_USER_LEAVE: 'REMOTE_USER_LEAVE', REMOTE_VIDEO_ADD: 'REMOTE_VIDEO_ADD', REMOTE_VIDEO_REMOVE: 'REMOTE_VIDEO_REMOVE', REMOTE_AUDIO_ADD: 'REMOTE_AUDIO_ADD', REMOTE_AUDIO_REMOVE: 'REMOTE_AUDIO_REMOVE', REMOTE_STATE_UPDATE: 'REMOTE_STATE_UPDATE', LOCAL_NET_STATE_UPDATE: 'LOCAL_NET_STATE_UPDATE', REMOTE_NET_STATE_UPDATE: 'REMOTE_NET_STATE_UPDATE', LOCAL_AUDIO_VOLUME_UPDATE: 'LOCAL_AUDIO_VOLUME_UPDATE', REMOTE_AUDIO_VOLUME_UPDATE: 'REMOTE_AUDIO_VOLUME_UPDATE', VIDEO_FULLSCREEN_UPDATE: 'VIDEO_FULLSCREEN_UPDATE', BGM_PLAY_START: 'BGM_PLAY_START', BGM_PLAY_FAIL: 'BGM_PLAY_FAIL', BGM_PLAY_PROGRESS: 'BGM_PLAY_PROGRESS', BGM_PLAY_COMPLETE: 'BGM_PLAY_COMPLETE', ERROR: 'ERROR', IM_READY: 'IM_READY', IM_MESSAGE_RECEIVED: 'IM_MESSAGE_RECEIVED', IM_NOT_READY: 'IM_NOT_READY', IM_KICKED_OUT: 'IM_KICKED_OUT', IM_ERROR: 'IM_ERROR' }; const m = { url: '', mode: 'RTC', autopush: !1, enableCamera: !1, enableMic: !1, enableAgc: !1, enableAns: !1, enableEarMonitor: !1, enableAutoFocus: !0, enableZoom: !1, minBitrate: 600, maxBitrate: 900, videoWidth: 360, videoHeight: 640, beautyLevel: 0, whitenessLevel: 0, videoOrientation: 'vertical', videoAspect: '9:16', frontCamera: 'front', enableRemoteMirror: !1, localMirror: 'auto', enableBackgroundMute: !1, audioQuality: 'high', audioVolumeType: 'voicecall', audioReverbType: 0, waitingImage: 'https://mc.qcloudimg.com/static/img/daeed8616ac5df256c0591c22a65c4d3/pause_publish.jpg', waitingImageHash: '', beautyStyle: 'smooth', filter: '', netStatus: {} }; const f = { src: '', mode: 'RTC', autoplay: !0, muteAudio: !0, muteVideo: !0, orientation: 'vertical', objectFit: 'fillCrop', enableBackgroundMute: !1, minCache: 1, maxCache: 2, soundMode: 'speaker', enableRecvMessage: !1, autoPauseIfNavigate: !0, autoPauseIfOpenNative: !0, isVisible: !0, _definitionType: 'main', netStatus: {} };(new Date).getTime();function d() { - const e = new Date;return e.setTime((new Date).getTime() + 0), e.toLocaleString(); - } function v(e) { - const t = this; let r = []; let s = [];this.length = function () { - return r.length; - }, this.sent = function () { - return s.length; - }, this.push = function (t) { - r.push(t), r.length > e && r.shift(); - }, this.send = function () { - return s.length || (s = r, r = []), s; - }, this.confirm = function () { - s = [], t.content = ''; - }, this.fail = function () { - r = s.concat(r), t.confirm();const i = 1 + r.length + s.length - e;i > 0 && (s.splice(0, i), r = s.concat(r), t.confirm()); - }; - } const g = new (function () { - function t() { - e(this, t), this.sdkAppId = '', this.userId = '', this.version = '', this.queue = new v(20); - } return r(t, [{ key: 'setConfig', value(e) { - this.sdkAppId = ''.concat(e.sdkAppId), this.userId = ''.concat(e.userId), this.version = ''.concat(e.version); - } }, { key: 'push', value(e) { - this.queue.push(e); - } }, { key: 'log', value(e) { - wx.request({ url: 'https://yun.tim.qq.com/v5/AVQualityReportSvc/C2S?sdkappid=1&cmdtype=jssdk_log', method: 'POST', header: { 'content-type': 'application/json' }, data: { timestamp: d(), sdkAppId: this.sdkAppId, userId: this.userId, version: this.version, log: e } }); - } }, { key: 'send', value() { - const e = this;if (!this.queue.sent()) { - if (!this.queue.length()) return;const t = this.queue.send();this.queue.content = 'string' !== typeof log ? '{"logs":['.concat(t.join(','), ']}') : t.join('\n'), wx.request({ url: 'https://yun.tim.qq.com/v5/AVQualityReportSvc/C2S?sdkappid=1&cmdtype=jssdk_log', method: 'POST', header: { 'content-type': 'application/json' }, data: { timestamp: d(), sdkAppId: this.sdkAppId, userId: this.userId, version: this.version, log: this.queue.content }, success() { - e.queue.confirm(); - }, fail() { - e.queue.fail(); - } }); - } - } }]), t; - }()); const y = (function () { - function t(r, s) { - e(this, t), this.context = wx.createLivePusherContext(s), this.pusherAttributes = {}, Object.assign(this.pusherAttributes, m, r); - } return r(t, [{ key: 'setPusherAttributes', value(e) { - return Object.assign(this.pusherAttributes, e), this.pusherAttributes; - } }, { key: 'start', value(e) { - l.log('[apiLog][pusherStart]'), g.log('pusherStart'), this.context.start(e); - } }, { key: 'stop', value(e) { - l.log('[apiLog][pusherStop]'), g.log('pusherStop'), this.context.stop(e); - } }, { key: 'pause', value(e) { - l.log('[apiLog] pusherPause()'), g.log('pusherPause'), this.context.pause(e); - } }, { key: 'resume', value(e) { - l.log('[apiLog][pusherResume]'), g.log('pusherResume'), this.context.resume(e); - } }, { key: 'switchCamera', value(e) { - return l.log('[apiLog][switchCamera]'), this.pusherAttributes.frontCamera = 'front' === this.pusherAttributes.frontCamera ? 'back' : 'front', this.context.switchCamera(e), this.pusherAttributes; - } }, { key: 'sendMessage', value(e) { - l.log('[apiLog][sendMessage]', e.msg), this.context.sendMessage(e); - } }, { key: 'snapshot', value() { - const e = this;return l.log('[apiLog][pusherSnapshot]'), new Promise(((t, r) => { - e.context.snapshot({ quality: 'raw', complete(e) { - e.tempImagePath ? (wx.saveImageToPhotosAlbum({ filePath: e.tempImagePath, success(r) { - t(e); - }, fail(e) { - l.error('[error] pusher截图失败: ', e), r(new Error('截图失败')); - } }), t(e)) : (l.error('[error] snapShot 回调失败', e), r(new Error('截图失败'))); - } }); - })); - } }, { key: 'toggleTorch', value(e) { - this.context.toggleTorch(e); - } }, { key: 'startDumpAudio', value(e) { - this.context.startDumpAudio(e); - } }, { key: 'stopDumpAudio', value(e) { - this.context.startDumpAudio(e); - } }, { key: 'playBGM', value(e) { - l.log('[apiLog] playBGM() url: ', e.url), this.context.playBGM(e); - } }, { key: 'pauseBGM', value(e) { - l.log('[apiLog] pauseBGM()'), this.context.pauseBGM(e); - } }, { key: 'resumeBGM', value(e) { - l.log('[apiLog] resumeBGM()'), this.context.resumeBGM(e); - } }, { key: 'stopBGM', value(e) { - l.log('[apiLog] stopBGM()'), this.context.stopBGM(e); - } }, { key: 'setBGMVolume', value(e) { - l.log('[apiLog] setBGMVolume() volume:', e.volume), this.context.setBGMVolume(e.volume); - } }, { key: 'setMICVolume', value(e) { - l.log('[apiLog] setMICVolume() volume:', e.volume), this.context.setMICVolume(e.volume); - } }, { key: 'startPreview', value(e) { - l.log('[apiLog] startPreview()'), this.context.startPreview(e); - } }, { key: 'stopPreview', value(e) { - l.log('[apiLog] stopPreview()'), this.context.stopPreview(e); - } }, { key: 'reset', value() { - return console.log('Pusher reset', this.context), this.pusherConfig = {}, this.context && (this.stop({ success() { - console.log('Pusher context.stop()'); - } }), this.context = null), this.pusherAttributes; - } }]), t; - }()); const E = function t(r) { - e(this, t), Object.assign(this, { userID: '', streams: {} }, r); - }; const A = (function () { - function t(r, s) { - e(this, t), this.ctx = s, this.playerAttributes = {}, Object.assign(this.playerAttributes, f, { userID: '', streamType: '', streamID: '', id: '', hasVideo: !1, hasAudio: !1, volume: 0, playerContext: void 0 }, r); - } return r(t, [{ key: 'play', value(e) { - this.getPlayerContext().play(e); - } }, { key: 'stop', value(e) { - this.getPlayerContext().stop(e); - } }, { key: 'mute', value(e) { - this.getPlayerContext().mute(e); - } }, { key: 'pause', value(e) { - this.getPlayerContext().pause(e); - } }, { key: 'resume', value(e) { - this.getPlayerContext().resume(e); - } }, { key: 'requestFullScreen', value(e) { - const t = this;return new Promise(((r, s) => { - t.getPlayerContext().requestFullScreen({ direction: e.direction, success(e) { - r(e); - }, fail(e) { - s(e); - } }); - })); - } }, { key: 'requestExitFullScreen', value() { - const e = this;return new Promise(((t, r) => { - e.getPlayerContext().exitFullScreen({ success(e) { - t(e); - }, fail(e) { - r(e); - } }); - })); - } }, { key: 'snapshot', value(e) { - const t = this;return l.log('[playerSnapshot]', e), new Promise(((e, r) => { - t.getPlayerContext().snapshot({ quality: 'raw', complete(t) { - t.tempImagePath ? (wx.saveImageToPhotosAlbum({ filePath: t.tempImagePath, success(r) { - l.log('save photo is success', r), e(t); - }, fail(e) { - l.error('save photo is fail', e), r(e); - } }), e(t)) : (l.error('snapShot 回调失败', t), r(new Error('截图失败'))); - } }); - })); - } }, { key: 'setPlayerAttributes', value(e) { - Object.assign(this.playerAttributes, e); - } }, { key: 'getPlayerContext', value() { - return this.playerContext || (this.playerContext = wx.createLivePlayerContext(this.playerAttributes.id, this.ctx)), this.playerContext; - } }, { key: 'reset', value() { - this.playerContext && (this.playerContext.stop(), this.playerContext = void 0), Object.assign(this.playerAttributes, f, { userID: '', streamType: '', streamID: '', hasVideo: !1, hasAudio: !1, volume: 0, playerContext: void 0 }); - } }]), t; - }()); const _ = 'UserController'; const I = (function () { - function t(r, s) { - e(this, t), this.ctx = s, this.userMap = new Map, this.userList = [], this.streamList = [], this.emitter = r; - } return r(t, [{ key: 'userEventHandler', value(e) { - const t = e.detail.code; const r = e.detail.message;switch (t) { - case 0:l.log(r, t);break;case 1001:l.log('已经连接推流服务器', t);break;case 1002:l.log('已经与服务器握手完毕,开始推流', t);break;case 1003:l.log('打开摄像头成功', t);break;case 1004:l.log('录屏启动成功', t);break;case 1005:l.log('推流动态调整分辨率', t);break;case 1006:l.log('推流动态调整码率', t);break;case 1007:l.log('首帧画面采集完成', t);break;case 1008:l.log('编码器启动', t);break;case 1018:l.log('进房成功', t), g.log('event enterRoom success '.concat(t)), this.emitter.emit(p.LOCAL_JOIN);break;case 1019:l.log('退出房间', t), r.indexOf('reason[0]') > -1 ? g.log('event exitRoom '.concat(t)) : (g.log('event abnormal exitRoom '.concat(r)), this.emitter.emit(p.KICKED_OUT));break;case 2003:l.log('渲染首帧视频', t);break;case -1301:l.error('打开摄像头失败: ', t), g.log('event start camera failed: '.concat(t)), this.emitter.emit(p.ERROR, { code: t, message: r });break;case -1302:l.error('打开麦克风失败: ', t), g.log('event start microphone failed: '.concat(t)), this.emitter.emit(p.ERROR, { code: t, message: r });break;case -1303:l.error('视频编码失败: ', t), g.log('event video encode failed: '.concat(t)), this.emitter.emit(p.ERROR, { code: t, message: r });break;case -1304:l.error('音频编码失败: ', t), g.log('event audio encode failed: '.concat(t)), this.emitter.emit(p.ERROR, { code: t, message: r });break;case -1307:l.error('推流连接断开: ', t), this.emitter.emit(p.ERROR, { code: t, message: r });break;case -100018:l.error('进房失败: userSig 校验失败,请检查 userSig 是否填写正确', t, r), this.emitter.emit(p.ERROR, { code: t, message: r });break;case 5e3:l.log('小程序被挂起: ', t), g.log('小程序被挂起: 5000');break;case 5001:l.log('小程序悬浮窗被关闭: ', t);break;case 1021:l.log('网络类型发生变化,需要重新进房', t);break;case 2007:l.log('本地视频播放loading: ', t);break;case 2004:l.log('本地视频播放开始: ', t);break;case 1031:case 1032:case 1033:case 1034:this._handleUserEvent(e); - } - } }, { key: '_handleUserEvent', value(e) { - let t; const r = e.detail.code; const s = e.detail.message;if (!e.detail.message || 'string' !== typeof s) return l.warn(_, 'userEventHandler 数据格式错误'), !1;try { - t = JSON.parse(e.detail.message); - } catch (e) { - return l.warn(_, 'userEventHandler 数据格式错误', e), !1; - } switch (this.emitter.emit(p.LOCAL_STATE_UPDATE, e), g.log('event code: '.concat(r, ', data: ').concat(JSON.stringify(t))), r) { - case 1031:this.addUser(t);break;case 1032:this.removeUser(t);break;case 1033:this.updateUserVideo(t);break;case 1034:this.updateUserAudio(t); - } - } }, { key: 'addUser', value(e) { - const t = this;l.log('addUser', e);const r = e.userlist;Array.isArray(r) && r.length > 0 && r.forEach(((e) => { - const r = e.userid; let s = t.getUser(r);s || (s = new E({ userID: r }), t.userList.push({ userID: r })), t.userMap.set(r, s), t.emitter.emit(p.REMOTE_USER_JOIN, { userID: r, userList: t.userList, playerList: t.getPlayerList() }); - })); - } }, { key: 'removeUser', value(e) { - const t = this; const r = e.userlist;Array.isArray(r) && r.length > 0 && r.forEach(((e) => { - const r = e.userid; let s = t.getUser(r);s && s.streams && (t._removeUserAndStream(r), s.streams.main && s.streams.main.reset(), s.streams.aux && s.streams.aux.reset(), t.emitter.emit(p.REMOTE_USER_LEAVE, { userID: r, userList: t.userList, playerList: t.getPlayerList() }), s = void 0, t.userMap.delete(r)); - })); - } }, { key: 'updateUserVideo', value(e) { - const t = this;l.log(_, 'updateUserVideo', e);const r = e.userlist;Array.isArray(r) && r.length > 0 && r.forEach(((e) => { - const r = e.userid; const s = e.streamtype; const i = ''.concat(r, '_').concat(s); const a = i; const n = e.hasvideo; const o = e.playurl; const u = t.getUser(r);if (u) { - let c = u.streams[s];l.log(_, 'updateUserVideo start', u, s, c), c ? (c.setPlayerAttributes({ hasVideo: n }), n || c.playerAttributes.hasAudio || t._removeStream(c)) : (c = new A({ userID: r, streamID: i, hasVideo: n, src: o, streamType: s, id: a }, t.ctx), u.streams[s] = c, t._addStream(c)), 'aux' === s && (n ? (c.objectFit = 'contain', t._addStream(c)) : t._removeStream(c)), t.userList.find(((e) => { - if (e.userID === r) return e['has'.concat(s.replace(/^\S/, (e => e.toUpperCase())), 'Video')] = n, !0; - })), l.log(_, 'updateUserVideo end', u, s, c);const h = n ? p.REMOTE_VIDEO_ADD : p.REMOTE_VIDEO_REMOVE;t.emitter.emit(h, { player: c.playerAttributes, userList: t.userList, playerList: t.getPlayerList() }); - } - })); - } }, { key: 'updateUserAudio', value(e) { - const t = this; const r = e.userlist;Array.isArray(r) && r.length > 0 && r.forEach(((e) => { - const r = e.userid; const s = 'main'; const i = ''.concat(r, '_').concat(s); const a = i; const n = e.hasaudio; const o = e.playurl; const u = t.getUser(r);if (u) { - let c = u.streams.main;c ? (c.setPlayerAttributes({ hasAudio: n }), n || c.playerAttributes.hasVideo || t._removeStream(c)) : (c = new A({ userID: r, streamID: i, hasAudio: n, src: o, streamType: s, id: a }, t.ctx), u.streams.main = c, t._addStream(c)), t.userList.find(((e) => { - if (e.userID === r) return e['has'.concat(s.replace(/^\S/, (e => e.toUpperCase())), 'Audio')] = n, !0; - }));const l = n ? p.REMOTE_AUDIO_ADD : p.REMOTE_AUDIO_REMOVE;t.emitter.emit(l, { player: c.playerAttributes, userList: t.userList, playerList: t.getPlayerList() }); - } - })); - } }, { key: 'getUser', value(e) { - return this.userMap.get(e); - } }, { key: 'getStream', value(e) { - const t = e.userID; const r = e.streamType; const s = this.userMap.get(t);if (s) return s.streams[r]; - } }, { key: 'getUserList', value() { - return this.userList; - } }, { key: 'getStreamList', value() { - return this.streamList; - } }, { key: 'getPlayerList', value() { - for (var e = this.getStreamList(), t = [], r = 0;r < e.length;r++)t.push(e[r].playerAttributes);return t; - } }, { key: 'reset', value() { - return this.streamList.forEach(((e) => { - e.reset(); - })), this.streamList = [], this.userList = [], this.userMap.clear(), { userList: this.userList, streamList: this.streamList }; - } }, { key: '_removeUserAndStream', value(e) { - this.streamList = this.streamList.filter((t => t.playerAttributes.userID !== e && '' !== t.playerAttributes.userID)), this.userList = this.userList.filter((t => t.userID !== e)); - } }, { key: '_addStream', value(e) { - this.streamList.includes(e) || this.streamList.push(e); - } }, { key: '_removeStream', value(e) { - this.streamList = this.streamList.filter((t => t.playerAttributes.userID !== e.playerAttributes.userID || t.playerAttributes.streamType !== e.playerAttributes.streamType)), this.getUser(e.playerAttributes.userID).streams[e.playerAttributes.streamType] = void 0; - } }]), t; - }()); const L = (function () { - function t() { - e(this, t); - } return r(t, [{ key: 'on', value(e, t, r) { - 'function' === typeof t ? (this._stores = this._stores || {}, (this._stores[e] = this._stores[e] || []).push({ cb: t, ctx: r })) : console.error('listener must be a function'); - } }, { key: 'emit', value(e) { - this._stores = this._stores || {};let t; let r = this._stores[e];if (r) { - r = r.slice(0), (t = [].slice.call(arguments, 1))[0] = { eventCode: e, data: t[0] };for (let s = 0, i = r.length;s < i;s++)r[s].cb.apply(r[s].ctx, t); - } - } }, { key: 'off', value(e, t) { - if (this._stores = this._stores || {}, arguments.length) { - const r = this._stores[e];if (r) if (1 !== arguments.length) { - for (let s = 0, i = r.length;s < i;s++) if (r[s].cb === t) { - r.splice(s, 1);break; - } - } else delete this._stores[e]; - } else this._stores = {}; - } }]), t; - }());return (function () { - function t(r, s) { - const i = this;e(this, t), this.ctx = r, this.eventEmitter = new L, this.pusherInstance = null, this.userController = new I(this.eventEmitter, this.ctx), this.EVENT = p, 'test' !== s ? wx.getSystemInfo({ success(e) { - return i.systemInfo = e; - } }) : (g.log = function () {}, l.log = function () {}, l.warn = function () {}); - } return r(t, [{ key: 'on', value(e, t, r) { - l.log('[on] 事件订阅: '.concat(e)), this.eventEmitter.on(e, t, r); - } }, { key: 'off', value(e, t) { - l.log('[off] 取消订阅: '.concat(e)), this.eventEmitter.off(e, t); - } }, { key: 'createPusher', value(e) { - return this.pusherInstance = new y(e, this.ctx), console.log('pusherInstance', this.pusherInstance), this.pusherInstance; - } }, { key: 'getPusherInstance', value() { - return this.pusherInstance; - } }, { key: 'enterRoom', value(e) { - l.log('[apiLog] [enterRoom]', e);const t = (function (e) { - if (!h(e)) return null;e.scene = e.scene && 'rtc' !== e.scene ? e.scene : 'videocall', e.enableBlackStream = e.enableBlackStream || '', e.encsmall = e.encsmall || 0, e.cloudenv = e.cloudenv || 'PRO', e.streamID = e.streamID || '', e.userDefineRecordID = e.userDefineRecordID || '', e.privateMapKey = e.privateMapKey || '', e.pureAudioMode = e.pureAudioMode || '', e.recvMode = e.recvMode || 1;let t = '';return t = e.strRoomID ? '&strroomid='.concat(e.strRoomID) : '&roomid='.concat(e.roomID), 'room://cloud.tencent.com/rtc?sdkappid='.concat(e.sdkAppID).concat(t, '&userid=') - .concat(e.userID, '&usersig=') - .concat(e.userSig, '&appscene=') - .concat(e.scene, '&encsmall=') - .concat(e.encsmall, '&cloudenv=') - .concat(e.cloudenv, '&enableBlackStream=') - .concat(e.enableBlackStream, '&streamid=') - .concat(e.streamID, '&userdefinerecordid=') - .concat(e.userDefineRecordID, '&privatemapkey=') - .concat(e.privateMapKey, '&pureaudiomode=') - .concat(e.pureAudioMode, '&recvmode=') - .concat(e.recvMode); - }(e));return t || this.eventEmitter.emit(p.ERROR, { message: '进房参数错误' }), g.setConfig({ sdkAppId: e.sdkAppID, userId: e.userID, version: 'wechat-mini' }), this.pusherInstance.setPusherAttributes(a(a({}, e), {}, { url: t })), l.warn('[statusLog] [enterRoom]', this.pusherInstance.pusherAttributes), g.log('api-enterRoom'), g.log('pusherConfig: '.concat(JSON.stringify(this.pusherInstance.pusherAttributes))), this.getPusherAttributes(); - } }, { key: 'exitRoom', value() { - g.log('api-exitRoom'), this.userController.reset();const e = Object.assign({ pusher: this.pusherInstance.reset() }, { playerList: this.userController.getPlayerList() });return this.eventEmitter.emit(p.LOCAL_LEAVE), e; - } }, { key: 'getPlayerList', value() { - const e = this.userController.getPlayerList();return l.log('[apiLog][getStreamList]', e), e; - } }, { key: 'setPusherAttributes', value(e) { - return l.log('[apiLog] [setPusherAttributes], ', e), this.pusherInstance.setPusherAttributes(e), l.warn('[statusLog] [setPusherAttributes]', this.pusherInstance.pusherAttributes), g.log('api-setPusherAttributes '.concat(JSON.stringify(e))), this.pusherInstance.pusherAttributes; - } }, { key: 'getPusherAttributes', value() { - return l.log('[apiLog] [getPusherConfig]'), this.pusherInstance.pusherAttributes; - } }, { key: 'setPlayerAttributes', value(e, t) { - l.log('[apiLog] [setPlayerAttributes] id', e, 'options: ', t);const r = this._transformStreamID(e); const s = r.userID; const i = r.streamType; const a = this.userController.getStream({ userID: s, streamType: i });return a ? (a.setPlayerAttributes(t), g.log('api-setPlayerAttributes id: '.concat(e, ' options: ').concat(JSON.stringify(t))), this.getPlayerList()) : this.getPlayerList(); - } }, { key: 'getPlayerInstance', value(e) { - const t = this._transformStreamID(e); const r = t.userID; const s = t.streamType;return l.log('[api][getPlayerInstance] id:', e), this.userController.getStream({ userID: r, streamType: s }); - } }, { key: 'switchStreamType', value(e) { - l.log('[apiLog] [switchStreamType] id: ', e);const t = this._transformStreamID(e); const r = t.userID; const s = t.streamType; const i = this.userController.getStream({ userID: r, streamType: s });return 'main' === i._definitionType ? (i.src = i.src.replace('main', 'small'), i._definitionType = 'small') : (i.src = i.src.replace('small', 'main'), i._definitionType = 'main'), this.getPlayerList(); - } }, { key: 'pusherEventHandler', value(e) { - this.userController.userEventHandler(e); - } }, { key: 'pusherNetStatusHandler', value(e) { - const t = e.detail.info;this.pusherInstance.setPusherAttributes(t), this.eventEmitter.emit(p.LOCAL_NET_STATE_UPDATE, { pusher: this.pusherInstance.pusherAttributes }); - } }, { key: 'pusherErrorHandler', value(e) { - try { - const t = e.detail.errCode; const r = e.detail.errMsg;this.eventEmitter.emit(p.ERROR, { code: t, message: r }); - } catch (t) { - l.error('pusher error data parser exception', e, t); - } - } }, { key: 'pusherBGMStartHandler', value(e) { - this.eventEmitter.emit(p.BGM_PLAY_START); - } }, { key: 'pusherBGMProgressHandler', value(e) { - let t; let r; let s; let i;this.eventEmitter.emit(p.BGM_PLAY_PROGRESS, { progress: null === (t = e.data) || void 0 === t || null === (r = t.detail) || void 0 === r ? void 0 : r.progress, duration: null === (s = e.data) || void 0 === s || null === (i = s.detail) || void 0 === i ? void 0 : i.duration }); - } }, { key: 'pusherBGMCompleteHandler', value(e) { - this.eventEmitter.emit(p.BGM_PLAY_COMPLETE); - } }, { key: 'pusherAudioVolumeNotify', value(e) { - this.pusherInstance.pusherAttributes.volume = e.detail.volume, this.eventEmitter.emit(p.LOCAL_AUDIO_VOLUME_UPDATE, { pusher: this.pusherInstance.pusherAttributes }); - } }, { key: 'playerEventHandler', value(e) { - l.log('[statusLog][playerStateChange]', e), this.eventEmitter.emit(p.REMOTE_STATE_UPDATE, e); - } }, { key: 'playerFullscreenChange', value(e) { - this.eventEmitter.emit(p.VIDEO_FULLSCREEN_UPDATE); - } }, { key: 'playerNetStatus', value(e) { - const t = this._transformStreamID(e.currentTarget.dataset.streamid); const r = t.userID; const s = t.streamType; const i = this.userController.getStream({ userID: r, streamType: s });!i || i.videoWidth === e.detail.info.videoWidth && i.videoHeight === e.detail.info.videoHeight || (i.setPlayerAttributes({ netStatus: e.detail.info }), this.eventEmitter.emit(p.REMOTE_NET_STATE_UPDATE, { playerList: this.userController.getPlayerList() })); - } }, { key: 'playerAudioVolumeNotify', value(e) { - const t = this._transformStreamID(e.currentTarget.dataset.streamid); const r = t.userID; const s = t.streamType; const i = this.userController.getStream({ userID: r, streamType: s }); const a = e.detail.volume;i.setPlayerAttributes({ volume: a }), this.eventEmitter.emit(p.REMOTE_AUDIO_VOLUME_UPDATE, { playerList: this.userController.getPlayerList() }); - } }, { key: '_transformStreamID', value(e) { - const t = e.lastIndexOf('_');return { userID: e.slice(0, t), streamType: e.slice(t + 1) }; - } }]), t; - }()); -}))); -// # sourceMappingURL=trtc-wx.js.map +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).TRTC=t()}(this,(function(){"use strict";function e(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function t(e,t){for(var r=0;r4294967296)?(c.error("roomID 超出取值范围 1 ~ 4294967295"),!1):e.strRoomID&&t.test(e.strRoomID)?(c.error("strRoomID 请勿使用中文字符"),!1):e.userID?e.userID&&t.test(e.userID)?(c.error("userID 请勿使用中文字符"),!1):!!e.userSig||(c.error("未设置 userSig"),!1):(c.error("未设置 userID"),!1):(c.error("未设置 sdkAppID"),!1)},m={LOCAL_JOIN:"LOCAL_JOIN",LOCAL_LEAVE:"LOCAL_LEAVE",KICKED_OUT:"KICKED_OUT",REMOTE_USER_JOIN:"REMOTE_USER_JOIN",REMOTE_USER_LEAVE:"REMOTE_USER_LEAVE",REMOTE_VIDEO_ADD:"REMOTE_VIDEO_ADD",REMOTE_VIDEO_REMOVE:"REMOTE_VIDEO_REMOVE",REMOTE_AUDIO_ADD:"REMOTE_AUDIO_ADD",REMOTE_AUDIO_REMOVE:"REMOTE_AUDIO_REMOVE",REMOTE_STATE_UPDATE:"REMOTE_STATE_UPDATE",LOCAL_NET_STATE_UPDATE:"LOCAL_NET_STATE_UPDATE",REMOTE_NET_STATE_UPDATE:"REMOTE_NET_STATE_UPDATE",LOCAL_AUDIO_VOLUME_UPDATE:"LOCAL_AUDIO_VOLUME_UPDATE",REMOTE_AUDIO_VOLUME_UPDATE:"REMOTE_AUDIO_VOLUME_UPDATE",VIDEO_FULLSCREEN_UPDATE:"VIDEO_FULLSCREEN_UPDATE",BGM_PLAY_START:"BGM_PLAY_START",BGM_PLAY_FAIL:"BGM_PLAY_FAIL",BGM_PLAY_PROGRESS:"BGM_PLAY_PROGRESS",BGM_PLAY_COMPLETE:"BGM_PLAY_COMPLETE",ERROR:"ERROR",IM_READY:"IM_READY",IM_MESSAGE_RECEIVED:"IM_MESSAGE_RECEIVED",IM_NOT_READY:"IM_NOT_READY",IM_KICKED_OUT:"IM_KICKED_OUT",IM_ERROR:"IM_ERROR"},p={url:"",mode:"RTC",autopush:!1,enableCamera:!1,enableMic:!1,enableAgc:!1,enableAns:!1,enableEarMonitor:!1,enableAutoFocus:!0,enableZoom:!1,minBitrate:600,maxBitrate:900,videoWidth:360,videoHeight:640,beautyLevel:0,whitenessLevel:0,videoOrientation:"vertical",videoAspect:"9:16",frontCamera:"front",enableRemoteMirror:!1,localMirror:"auto",enableBackgroundMute:!1,audioQuality:"high",audioVolumeType:"voicecall",audioReverbType:0,waitingImage:"",waitingImageHash:"",beautyStyle:"smooth",filter:"",netStatus:{}},d={src:"",mode:"RTC",autoplay:!0,muteAudio:!0,muteVideo:!0,orientation:"vertical",objectFit:"fillCrop",enableBackgroundMute:!1,minCache:1,maxCache:2,soundMode:"speaker",enableRecvMessage:!1,autoPauseIfNavigate:!0,autoPauseIfOpenNative:!0,isVisible:!0,_definitionType:"main",netStatus:{}};(new Date).getTime();function v(){var e=new Date;return e.setTime((new Date).getTime()+0),e.toLocaleString()}var g=function(e){var t=[];if(e&&e.TUIScene&&t.push(e.TUIScene),e&&"test"===e.env)return"default";if(wx&&wx.TUIScene&&t.push(wx.TUIScene),wx&&"function"==typeof getApp){var r=getApp().globalData;r&&r.TUIScene&&t.push(r.TUIScene)}return wx&&wx.getStorage({key:"TUIScene",success:function(e){t.push(e.data)}}),t[0]||"default"},y=new(function(){function t(){e(this,t),this.sdkAppId="",this.userId="",this.version="",this.common={}}return r(t,[{key:"setConfig",value:function(e){this.sdkAppId="".concat(e.sdkAppId),this.userId="".concat(e.userId),this.version="".concat(e.version),this.common.TUIScene=g(e)}},{key:"log",value:function(e){wx.request({url:"https://yun.tim.qq.com/v5/AVQualityReportSvc/C2S?sdkappid=1&cmdtype=jssdk_log",method:"POST",header:{"content-type":"application/json"},data:{timestamp:v(),sdkAppId:this.sdkAppId,userId:this.userId,version:this.version,log:JSON.stringify(i(i({},e),this.common))}})}}]),t}()),f="enterRoom",E="exitRoom",A="setPusherAttributes",I="setPlayerAttributes",_="init",L="error",D="connectServer",T="startPusher",b="openCamera",O="screenCap",k="pusherResolution",R="pusherCodeRate",P="collectionFirstFrame",S="encoderStart",M="enterRoomSuccess",U="exitRoomSuccess",C="kicked_out",x="renderFirstFrame",w="miniAppHang",V="closeSuspension",B="other",G="update",N="addUser",j="remove_user",F="update_user_video",H="update_user_audio",Y="pusherStart",K="pusherStop",q="pusherPause",J="pusherResume",W=function(){function t(r,s){e(this,t),this.context=wx.createLivePusherContext(s),this.pusherAttributes={},Object.assign(this.pusherAttributes,p,r)}return r(t,[{key:"setPusherAttributes",value:function(e){return Object.assign(this.pusherAttributes,e),this.pusherAttributes}},{key:"start",value:function(e){c.log("[apiLog][pusherStart]"),y.log({name:Y,options:e}),this.context.start(e)}},{key:"stop",value:function(e){c.log("[apiLog][pusherStop]"),y.log({name:K,options:e}),this.context.stop(e)}},{key:"pause",value:function(e){c.log("[apiLog] pusherPause()"),y.log({name:q,options:e}),this.context.pause(e)}},{key:"resume",value:function(e){c.log("[apiLog][pusherResume]"),y.log({name:J,options:e}),this.context.resume(e)}},{key:"switchCamera",value:function(e){return c.log("[apiLog][switchCamera]"),this.pusherAttributes.frontCamera="front"===this.pusherAttributes.frontCamera?"back":"front",this.context.switchCamera(e),this.pusherAttributes}},{key:"sendMessage",value:function(e){c.log("[apiLog][sendMessage]",e.msg),this.context.sendMessage(e)}},{key:"snapshot",value:function(){var e=this;return c.log("[apiLog][pusherSnapshot]"),new Promise((function(t,r){e.context.snapshot({quality:"raw",complete:function(e){e.tempImagePath?(wx.saveImageToPhotosAlbum({filePath:e.tempImagePath,success:function(r){t(e)},fail:function(e){c.error("[error] pusher截图失败: ",e),r(new Error("截图失败"))}}),t(e)):(c.error("[error] snapShot 回调失败",e),r(new Error("截图失败")))}})}))}},{key:"toggleTorch",value:function(e){this.context.toggleTorch(e)}},{key:"startDumpAudio",value:function(e){this.context.startDumpAudio(e)}},{key:"stopDumpAudio",value:function(e){this.context.startDumpAudio(e)}},{key:"playBGM",value:function(e){c.log("[apiLog] playBGM() url: ",e.url),this.context.playBGM(e)}},{key:"pauseBGM",value:function(e){c.log("[apiLog] pauseBGM()"),this.context.pauseBGM(e)}},{key:"resumeBGM",value:function(e){c.log("[apiLog] resumeBGM()"),this.context.resumeBGM(e)}},{key:"stopBGM",value:function(e){c.log("[apiLog] stopBGM()"),this.context.stopBGM(e)}},{key:"setBGMVolume",value:function(e){c.log("[apiLog] setBGMVolume() volume:",e.volume),this.context.setBGMVolume(e.volume)}},{key:"setMICVolume",value:function(e){c.log("[apiLog] setMICVolume() volume:",e.volume),this.context.setMICVolume(e.volume)}},{key:"startPreview",value:function(e){c.log("[apiLog] startPreview()"),this.context.startPreview(e)}},{key:"stopPreview",value:function(e){c.log("[apiLog] stopPreview()"),this.context.stopPreview(e)}},{key:"reset",value:function(){return console.log("Pusher reset",this.context),this.pusherConfig={},this.context&&(this.stop({success:function(){console.log("Pusher context.stop()")}}),this.context=null),this.pusherAttributes}}]),t}(),Q=function t(r){e(this,t),Object.assign(this,{userID:"",streams:{}},r)},X=function(){function t(r,s){e(this,t),this.ctx=s,this.playerAttributes={},Object.assign(this.playerAttributes,d,{userID:"",streamType:"",streamID:"",id:"",hasVideo:!1,hasAudio:!1,volume:0,playerContext:void 0},r)}return r(t,[{key:"play",value:function(e){this.getPlayerContext().play(e)}},{key:"stop",value:function(e){this.getPlayerContext().stop(e)}},{key:"mute",value:function(e){this.getPlayerContext().mute(e)}},{key:"pause",value:function(e){this.getPlayerContext().pause(e)}},{key:"resume",value:function(e){this.getPlayerContext().resume(e)}},{key:"requestFullScreen",value:function(e){var t=this;return new Promise((function(r,s){t.getPlayerContext().requestFullScreen({direction:e.direction,success:function(e){r(e)},fail:function(e){s(e)}})}))}},{key:"requestExitFullScreen",value:function(){var e=this;return new Promise((function(t,r){e.getPlayerContext().exitFullScreen({success:function(e){t(e)},fail:function(e){r(e)}})}))}},{key:"snapshot",value:function(e){var t=this;return c.log("[playerSnapshot]",e),new Promise((function(e,r){t.getPlayerContext().snapshot({quality:"raw",complete:function(t){t.tempImagePath?(wx.saveImageToPhotosAlbum({filePath:t.tempImagePath,success:function(r){c.log("save photo is success",r),e(t)},fail:function(e){c.error("save photo is fail",e),r(e)}}),e(t)):(c.error("snapShot 回调失败",t),r(new Error("截图失败")))}})}))}},{key:"setPlayerAttributes",value:function(e){Object.assign(this.playerAttributes,e)}},{key:"getPlayerContext",value:function(){return this.playerContext||(this.playerContext=wx.createLivePlayerContext(this.playerAttributes.id,this.ctx)),this.playerContext}},{key:"reset",value:function(){this.playerContext&&(this.playerContext.stop(),this.playerContext=void 0),Object.assign(this.playerAttributes,d,{userID:"",streamType:"",streamID:"",hasVideo:!1,hasAudio:!1,volume:0,playerContext:void 0})}}]),t}(),Z="UserController",z=function(){function t(r,s){e(this,t),this.ctx=s,this.userMap=new Map,this.userList=[],this.streamList=[],this.emitter=r}return r(t,[{key:"userEventHandler",value:function(e){var t=e.detail.code,r=e.detail.message,s={name:B,code:t,message:r,data:""};switch(t){case 0:c.log(r,t);break;case 1001:c.log("已经连接推流服务器",t),s.name=D;break;case 1002:c.log("已经与服务器握手完毕,开始推流",t),s.name=T;break;case 1003:c.log("打开摄像头成功",t),s.name=b;break;case 1004:c.log("录屏启动成功",t),s.name=O;break;case 1005:c.log("推流动态调整分辨率",t),s.name=k;break;case 1006:c.log("推流动态调整码率",t),s.name=R;break;case 1007:c.log("首帧画面采集完成",t),s.name=P;break;case 1008:c.log("编码器启动",t),s.name=S;break;case 1018:c.log("进房成功",t),s.name=M,s.data="event enterRoom success",this.emitter.emit(m.LOCAL_JOIN);break;case 1019:c.log("退出房间",t),r.indexOf("reason[0]")>-1?(s.name=U,s.data="event exitRoom success"):(s.name=C,s.data="event abnormal exitRoom",this.emitter.emit(m.KICKED_OUT));break;case 2003:c.log("渲染首帧视频",t),s.name=x;break;case-1301:c.error("打开摄像头失败: ",t),s.name=L,s.data="event start camera failed",this.emitter.emit(m.ERROR,{code:t,message:r});break;case-1302:s.name=L,s.data="event start microphone failed",c.error("打开麦克风失败: ",t),this.emitter.emit(m.ERROR,{code:t,message:r});break;case-1303:c.error("视频编码失败: ",t),s.name=L,s.data="event video encode failed",this.emitter.emit(m.ERROR,{code:t,message:r});break;case-1304:c.error("音频编码失败: ",t),s.name=L,s.data="event audio encode failed",this.emitter.emit(m.ERROR,{code:t,message:r});break;case-1307:c.error("推流连接断开: ",t),s.name=L,s.data="event pusher stream failed",this.emitter.emit(m.ERROR,{code:t,message:r});break;case-100018:c.error("进房失败: userSig 校验失败,请检查 userSig 是否填写正确",t,r),s.name=L,s.data="event userSig is error",this.emitter.emit(m.ERROR,{code:t,message:r});break;case 5e3:c.log("小程序被挂起: ",t),s.name=w,s.data="miniApp is hang";break;case 5001:c.log("小程序悬浮窗被关闭: ",t),s.name=V;break;case 1021:c.log("网络类型发生变化,需要重新进房",t);break;case 2007:c.log("本地视频播放loading: ",t);break;case 2004:c.log("本地视频播放开始: ",t);break;case 1031:case 1032:case 1033:case 1034:this._handleUserEvent(e)}y.log(s)}},{key:"_handleUserEvent",value:function(e){var t,r=e.detail.code,s=e.detail.message;if(!e.detail.message||"string"!=typeof s)return c.warn(Z,"userEventHandler 数据格式错误"),!1;try{t=JSON.parse(e.detail.message)}catch(e){return c.warn(Z,"userEventHandler 数据格式错误",e),!1}switch(this.emitter.emit(m.LOCAL_STATE_UPDATE,e),y.log({name:G,code:r,message:s,data:t}),r){case 1031:this.addUser(t);break;case 1032:this.removeUser(t);break;case 1033:this.updateUserVideo(t);break;case 1034:this.updateUserAudio(t)}}},{key:"addUser",value:function(e){var t=this;c.log("addUser",e);var r=e.userlist;Array.isArray(r)&&r.length>0&&r.forEach((function(e){var r=e.userid,s=t.getUser(r);s||(s=new Q({userID:r}),t.userList.push({userID:r})),t.userMap.set(r,s),t.emitter.emit(m.REMOTE_USER_JOIN,{userID:r,userList:t.userList,playerList:t.getPlayerList()}),y.log({name:N,userID:r,userList:t.userList,playerList:t.getPlayerList()})}))}},{key:"removeUser",value:function(e){var t=this,r=e.userlist;Array.isArray(r)&&r.length>0&&r.forEach((function(e){var r=e.userid,s=t.getUser(r);s&&s.streams&&(t._removeUserAndStream(r),s.streams.main&&s.streams.main.reset(),s.streams.aux&&s.streams.aux.reset(),t.emitter.emit(m.REMOTE_USER_LEAVE,{userID:r,userList:t.userList,playerList:t.getPlayerList()}),y.log({name:j,userID:r,userList:t.userList,playerList:t.getPlayerList()}),s=void 0,t.userMap.delete(r))}))}},{key:"updateUserVideo",value:function(e){var t=this;c.log(Z,"updateUserVideo",e);var r=e.userlist;Array.isArray(r)&&r.length>0&&r.forEach((function(e){var r=e.userid,s=e.streamtype,a="".concat(r,"_").concat(s),i=a,n=e.hasvideo,o=e.playurl,u=t.getUser(r);if(u){var l=u.streams[s];c.log(Z,"updateUserVideo start",u,s,l),l?(l.setPlayerAttributes({hasVideo:n}),n||l.playerAttributes.hasAudio||t._removeStream(l)):(l=new X({userID:r,streamID:a,hasVideo:n,src:o,streamType:s,id:i},t.ctx),u.streams[s]=l,t._addStream(l)),"aux"===s&&(n?(l.objectFit="contain",t._addStream(l)):t._removeStream(l)),t.userList.find((function(e){if(e.userID===r)return e["has".concat(s.replace(/^\S/,(function(e){return e.toUpperCase()})),"Video")]=n,!0})),c.log(Z,"updateUserVideo end",u,s,l);var h=n?m.REMOTE_VIDEO_ADD:m.REMOTE_VIDEO_REMOVE;t.emitter.emit(h,{player:l.playerAttributes,userList:t.userList,playerList:t.getPlayerList()}),y.log({name:F,player:l.playerAttributes,userList:t.userList,playerList:t.getPlayerList()})}}))}},{key:"updateUserAudio",value:function(e){var t=this,r=e.userlist;Array.isArray(r)&&r.length>0&&r.forEach((function(e){var r=e.userid,s="main",a="".concat(r,"_").concat(s),i=a,n=e.hasaudio,o=e.playurl,u=t.getUser(r);if(u){var l=u.streams.main;l?(l.setPlayerAttributes({hasAudio:n}),n||l.playerAttributes.hasVideo||t._removeStream(l)):(l=new X({userID:r,streamID:a,hasAudio:n,src:o,streamType:s,id:i},t.ctx),u.streams.main=l,t._addStream(l)),t.userList.find((function(e){if(e.userID===r)return e["has".concat(s.replace(/^\S/,(function(e){return e.toUpperCase()})),"Audio")]=n,!0}));var c=n?m.REMOTE_AUDIO_ADD:m.REMOTE_AUDIO_REMOVE;t.emitter.emit(c,{player:l.playerAttributes,userList:t.userList,playerList:t.getPlayerList()}),y.log({name:H,player:l.playerAttributes,userList:t.userList,playerList:t.getPlayerList()})}}))}},{key:"getUser",value:function(e){return this.userMap.get(e)}},{key:"getStream",value:function(e){var t=e.userID,r=e.streamType,s=this.userMap.get(t);if(s)return s.streams[r]}},{key:"getUserList",value:function(){return this.userList}},{key:"getStreamList",value:function(){return this.streamList}},{key:"getPlayerList",value:function(){for(var e=this.getStreamList(),t=[],r=0;r (function (t) { - const e = {};function i(n) { - if (e[n]) return e[n].exports;const o = e[n] = { i: n, l: !1, exports: {} };return t[n].call(o.exports, o, o.exports, i), o.l = !0, o.exports; - } return i.m = t, i.c = e, i.d = function (t, e, n) { - i.o(t, e) || Object.defineProperty(t, e, { enumerable: !0, get: n }); - }, i.r = function (t) { - 'undefined' !== typeof Symbol && Symbol.toStringTag && Object.defineProperty(t, Symbol.toStringTag, { value: 'Module' }), Object.defineProperty(t, '__esModule', { value: !0 }); - }, i.t = function (t, e) { - if (1 & e && (t = i(t)), 8 & e) return t;if (4 & e && 'object' === typeof t && t && t.__esModule) return t;const n = Object.create(null);if (i.r(n), Object.defineProperty(n, 'default', { enumerable: !0, value: t }), 2 & e && 'string' !== typeof t) for (const o in t)i.d(n, o, (e => t[e]).bind(null, o));return n; - }, i.n = function (t) { - const e = t && t.__esModule ? function () { - return t.default; - } : function () { - return t; - };return i.d(e, 'a', e), e; - }, i.o = function (t, e) { - return Object.prototype.hasOwnProperty.call(t, e); - }, i.p = '', i(i.s = 5); -}([function (t, e, i) { - 'use strict';i.d(e, 'e', (() => p)), i.d(e, 'g', (() => h)), i.d(e, 'c', (() => g)), i.d(e, 'f', (() => v)), i.d(e, 'b', (() => m)), i.d(e, 'd', (() => T)), i.d(e, 'a', (() => y)), i.d(e, 'h', (() => N));const n = 'undefined' !== typeof window; const o = ('undefined' !== typeof wx && wx.getSystemInfoSync, n && window.navigator && window.navigator.userAgent || ''); const r = /AppleWebKit\/([\d.]+)/i.exec(o); const s = (r && parseFloat(r.pop()), /iPad/i.test(o)); const a = /iPhone/i.test(o) && !s; const u = /iPod/i.test(o); const l = a || s || u; const c = ((function () { - const t = o.match(/OS (\d+)_/i);t && t[1] && t[1]; - }()), /Android/i.test(o)); const d = (function () { - const t = o.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);if (!t) return null;const e = t[1] && parseFloat(t[1]); const i = t[2] && parseFloat(t[2]);return e && i ? parseFloat(`${t[1]}.${t[2]}`) : e || null; - }()); const f = (c && /webkit/i.test(o), /Firefox/i.test(o), /Edge/i.test(o)); const _ = !f && /Chrome/i.test(o); const I = ((function () { - const t = o.match(/Chrome\/(\d+)/);t && t[1] && parseFloat(t[1]); - }()), /MSIE/.test(o), /MSIE\s8\.0/.test(o), (function () { - const t = /MSIE\s(\d+)\.\d/.exec(o);let e = t && parseFloat(t[1]);!e && /Trident\/7.0/i.test(o) && /rv:11.0/.test(o) && (e = 11); - }()), /Safari/i.test(o), /TBS\/\d+/i.test(o));(function () { - const t = o.match(/TBS\/(\d+)/i);if (t && t[1])t[1]; - }()), !I && /MQQBrowser\/\d+/i.test(o), !I && / QQBrowser\/\d+/i.test(o), /(micromessenger|webbrowser)/i.test(o), /Windows/i.test(o), /MAC OS X/i.test(o), /MicroMessenger/i.test(o);i(2), i(1);const p = function (t) { - return 'map' === D(t); - }; const h = function (t) { - return 'set' === D(t); - }; const g = function (t) { - return 'file' === D(t); - }; const v = function (t) { - if ('object' !== typeof t || null === t) return !1;const e = Object.getPrototypeOf(t);if (null === e) return !0;let i = e;for (;null !== Object.getPrototypeOf(i);)i = Object.getPrototypeOf(i);return e === i; - }; const E = function (t) { - return 'function' === typeof Array.isArray ? Array.isArray(t) : 'array' === D(t); - }; const m = function (t) { - return E(t) || (function (t) { - return null !== t && 'object' === typeof t; - }(t)); - }; const T = function (t) { - return t instanceof Error; - }; const D = function (t) { - return Object.prototype.toString.call(t).match(/^\[object (.*)\]$/)[1].toLowerCase(); - };let S = 0;Date.now || (Date.now = function () { - return (new Date).getTime(); - });const y = { now() { - 0 === S && (S = Date.now() - 1);const t = Date.now() - S;return t > 4294967295 ? (S += 4294967295, Date.now() - S) : t; - }, utc() { - return Math.round(Date.now() / 1e3); - } }; const N = function (t) { - return JSON.stringify(t, ['message', 'code']); - }; -}, function (t, e, i) { - 'use strict';i.r(e);const n = i(3); const o = i(0);let r = 0;const s = new Map;function a() { - const t = new Date;return `TSignaling ${t.toLocaleTimeString('en-US', { hour12: !1 })}.${(function (t) { - let e;switch (t.toString().length) { - case 1:e = `00${t}`;break;case 2:e = `0${t}`;break;default:e = t; - } return e; - }(t.getMilliseconds()))}:`; - } const u = { _data: [], _length: 0, _visible: !1, arguments2String(t) { - let e;if (1 === t.length)e = a() + t[0];else { - e = a();for (let i = 0, n = t.length;i < n;i++)Object(o.b)(t[i]) ? Object(o.d)(t[i]) ? e += Object(o.h)(t[i]) : e += JSON.stringify(t[i]) : e += t[i], e += ' '; - } return e; - }, debug() { - if (r <= -1) { - const t = this.arguments2String(arguments);u.record(t, 'debug'), n.a.debug(t); - } - }, log() { - if (r <= 0) { - const t = this.arguments2String(arguments);u.record(t, 'log'), n.a.log(t); - } - }, info() { - if (r <= 1) { - const t = this.arguments2String(arguments);u.record(t, 'info'), n.a.info(t); - } - }, warn() { - if (r <= 2) { - const t = this.arguments2String(arguments);u.record(t, 'warn'), n.a.warn(t); - } - }, error() { - if (r <= 3) { - const t = this.arguments2String(arguments);u.record(t, 'error'), n.a.error(t); - } - }, time(t) { - s.set(t, o.a.now()); - }, timeEnd(t) { - if (s.has(t)) { - const e = o.a.now() - s.get(t);return s.delete(t), e; - } return n.a.warn(`未找到对应label: ${t}, 请在调用 logger.timeEnd 前,调用 logger.time`), 0; - }, setLevel(t) { - t < 4 && n.a.log(`${a()}set level from ${r} to ${t}`), r = t; - }, record(t, e) { - 1100 === u._length && (u._data.splice(0, 100), u._length = 1e3), u._length++, u._data.push(`${t} [${e}] \n`); - }, getLog() { - return u._data; - } };e.default = u; -}, function (t, e, i) { - 'use strict';i.r(e);e.default = { MSG_PRIORITY_HIGH: 'High', MSG_PRIORITY_NORMAL: 'Normal', MSG_PRIORITY_LOW: 'Low', MSG_PRIORITY_LOWEST: 'Lowest', KICKED_OUT_MULT_ACCOUNT: 'multipleAccount', KICKED_OUT_MULT_DEVICE: 'multipleDevice', KICKED_OUT_USERSIG_EXPIRED: 'userSigExpired', NET_STATE_CONNECTED: 'connected', NET_STATE_CONNECTING: 'connecting', NET_STATE_DISCONNECTED: 'disconnected', ENTER_ROOM_SUCCESS: 'JoinedSuccess', ALREADY_IN_ROOM: 'AlreadyInGroup' }; -}, function (t, e, i) { - 'use strict';(function (t) { - let i; let n;i = 'undefined' !== typeof console ? console : void 0 !== t && t.console ? t.console : 'undefined' !== typeof window && window.console ? window.console : {};const o = function () {}; const r = ['assert', 'clear', 'count', 'debug', 'dir', 'dirxml', 'error', 'exception', 'group', 'groupCollapsed', 'groupEnd', 'info', 'log', 'markTimeline', 'profile', 'profileEnd', 'table', 'time', 'timeEnd', 'timeStamp', 'trace', 'warn'];let s = r.length;for (;s--;)n = r[s], console[n] || (i[n] = o);i.methods = r, e.a = i; - }).call(this, i(8)); -}, function (t, e, i) { - 'use strict';Object.defineProperty(e, '__esModule', { value: !0 });e.default = { NEW_INVITATION_RECEIVED: 'ts_new_invitation_received', INVITEE_ACCEPTED: 'ts_invitee_accepted', INVITEE_REJECTED: 'ts_invitee_rejected', INVITATION_CANCELLED: 'ts_invitation_cancelled', INVITATION_TIMEOUT: 'ts_invitation_timeout', SDK_READY: 'ts_im_ready', SDK_NOT_READY: 'ts_im_not_ready', TEXT_MESSAGE_RECEIVED: 'ts_text_message_received', CUSTOM_MESSAGE_RECEIVED: 'ts_custom_message_received', REMOTE_USER_JOIN: 'ts_remote_user_join', REMOTE_USER_LEAVE: 'ts_remote_user_leave', KICKED_OUT: 'ts_kicked_out', NET_STATE_CHANGE: 'ts_net_state_change' }; -}, function (t, e, i) { - 'use strict';const n = this && this.__awaiter || function (t, e, i, n) { - return new (i || (i = Promise))(((o, r) => { - function s(t) { - try { - u(n.next(t)); - } catch (t) { - r(t); - } - } function a(t) { - try { - u(n.throw(t)); - } catch (t) { - r(t); - } - } function u(t) { - let e;t.done ? o(t.value) : (e = t.value, e instanceof i ? e : new i(((t) => { - t(e); - }))).then(s, a); - }u((n = n.apply(t, e || [])).next()); - })); - }; const o = this && this.__generator || function (t, e) { - let i; let n; let o; let r; let s = { label: 0, sent() { - if (1 & o[0]) throw o[1];return o[1]; - }, trys: [], ops: [] };return r = { next: a(0), throw: a(1), return: a(2) }, 'function' === typeof Symbol && (r[Symbol.iterator] = function () { - return this; - }), r;function a(r) { - return function (a) { - return (function (r) { - if (i) throw new TypeError('Generator is already executing.');for (;s;) try { - if (i = 1, n && (o = 2 & r[0] ? n.return : r[0] ? n.throw || ((o = n.return) && o.call(n), 0) : n.next) && !(o = o.call(n, r[1])).done) return o;switch (n = 0, o && (r = [2 & r[0], o.value]), r[0]) { - case 0:case 1:o = r;break;case 4:return s.label++, { value: r[1], done: !1 };case 5:s.label++, n = r[1], r = [0];continue;case 7:r = s.ops.pop(), s.trys.pop();continue;default:if (!(o = s.trys, (o = o.length > 0 && o[o.length - 1]) || 6 !== r[0] && 2 !== r[0])) { - s = 0;continue; - } if (3 === r[0] && (!o || r[1] > o[0] && r[1] < o[3])) { - s.label = r[1];break; - } if (6 === r[0] && s.label < o[1]) { - s.label = o[1], o = r;break; - } if (o && s.label < o[2]) { - s.label = o[2], s.ops.push(r);break; - }o[2] && s.ops.pop(), s.trys.pop();continue; - }r = e.call(t, s); - } catch (t) { - r = [6, t], n = 0; - } finally { - i = o = 0; - } if (5 & r[0]) throw r[1];return { value: r[0] ? r[1] : void 0, done: !0 }; - }([r, a])); - }; - } - }; const r = this && this.__spreadArrays || function () { - for (var t = 0, e = 0, i = arguments.length;e < i;e++)t += arguments[e].length;const n = Array(t); let o = 0;for (e = 0;e < i;e++) for (let r = arguments[e], s = 0, a = r.length;s < a;s++, o++)n[o] = r[s];return n; - };Object.defineProperty(e, '__esModule', { value: !0 });const s = i(6); const a = i(7); const u = i(4); const l = i(2); const c = i(1); const d = i(9); const f = i(10); const _ = i(11); const I = i(12); const p = i(14); const h = i(15).version; const g = (function () { - function t(t) { - if (this._outerEmitter = null, this._safetyCallbackFactory = null, this._tim = null, this._imSDKAppID = 0, this._userID = null, this._groupID = '', this._isHandling = !1, this._inviteInfoMap = new Map, c.default.info(`TSignaling version:${h}`), d.default(t.SDKAppID)) return c.default.error('TSignaling 请传入 SDKAppID !!!'), null;this._outerEmitter = new a.default, this._outerEmitter._emit = this._outerEmitter.emit, this._outerEmitter.emit = function () { - for (var t = [], e = 0;e < arguments.length;e++)t[e] = arguments[e];const i = t[0]; const n = [i, { name: t[0], data: t[1] }];this._outerEmitter._emit.apply(this._outerEmitter, r(n)); - }.bind(this), this._safetyCallbackFactory = new _.default, t.tim ? this._tim = t.tim : this._tim = p.create({ SDKAppID: t.SDKAppID, scene: 'TSignaling' }), this._imSDKAppID = t.SDKAppID, this._tim.on(p.EVENT.SDK_READY, this._onIMReady.bind(this)), this._tim.on(p.EVENT.SDK_NOT_READY, this._onIMNotReady.bind(this)), this._tim.on(p.EVENT.KICKED_OUT, this._onKickedOut.bind(this)), this._tim.on(p.EVENT.NET_STATE_CHANGE, this._onNetStateChange.bind(this)), this._tim.on(p.EVENT.MESSAGE_RECEIVED, this._onMessageReceived.bind(this)); - } return t.prototype.setLogLevel = function (t) { - c.default.setLevel(t), this._tim.setLogLevel(t); - }, t.prototype.login = function (t) { - return n(this, void 0, void 0, (function () { - return o(this, (function (e) { - return c.default.log('TSignaling.login', t), this._userID = t.userID, [2, this._tim.login(t)]; - })); - })); - }, t.prototype.logout = function () { - return n(this, void 0, void 0, (function () { - return o(this, (function (t) { - return c.default.log('TSignaling.logout'), this._userID = '', this._inviteInfoMap.clear(), [2, this._tim.logout()]; - })); - })); - }, t.prototype.on = function (t, e, i) { - c.default.log(`TSignaling.on eventName:${t}`), this._outerEmitter.on(t, this._safetyCallbackFactory.defense(t, e, i), i); - }, t.prototype.off = function (t, e) { - c.default.log(`TSignaling.off eventName:${t}`), this._outerEmitter.off(t, e); - }, t.prototype.joinGroup = function (t) { - return n(this, void 0, void 0, (function () { - return o(this, (function (e) { - return c.default.log(`TSignaling.joinGroup groupID:${t}`), this._groupID = t, [2, this._tim.joinGroup({ groupID: t })]; - })); - })); - }, t.prototype.quitGroup = function (t) { - return n(this, void 0, void 0, (function () { - return o(this, (function (e) { - return c.default.log(`TSignaling.quitGroup groupID:${t}`), [2, this._tim.quitGroup(t)]; - })); - })); - }, t.prototype.sendTextMessage = function (t) { - return n(this, void 0, void 0, (function () { - let e;return o(this, (function (i) { - return e = this._tim.createTextMessage({ to: t.to, conversationType: !0 === t.groupFlag ? p.TYPES.CONV_GROUP : p.TYPES.CONV_C2C, priority: t.priority || p.TYPES.MSG_PRIORITY_NORMAL, payload: { text: t.text } }), [2, this._tim.sendMessage(e)]; - })); - })); - }, t.prototype.sendCustomMessage = function (t) { - return n(this, void 0, void 0, (function () { - let e;return o(this, (function (i) { - return e = this._tim.createCustomMessage({ to: t.to, conversationType: !0 === t.groupFlag ? p.TYPES.CONV_GROUP : p.TYPES.CONV_C2C, priority: t.priority || p.TYPES.MSG_PRIORITY_NORMAL, payload: { data: t.data || '', description: t.description || '', extension: t.extension || '' } }), [2, this._tim.sendMessage(e)]; - })); - })); - }, t.prototype.invite = function (t) { - return n(this, void 0, void 0, (function () { - let e; let i; let n; let r; let a; let u; let l;return o(this, (function (o) { - switch (o.label) { - case 0:return e = I.generate(), c.default.log('TSignaling.invite', t, `inviteID=${e}`), d.default(t) || d.default(t.userID) ? [2, Promise.reject(new f.default({ code: s.ErrorCode.ERR_INVALID_PARAMETERS, message: 'userID is invalid' }))] : (i = t.userID, n = t.data, r = t.timeout, a = t.offlinePushInfo, u = { businessID: s.BusinessID.SIGNAL, inviteID: e, inviter: this._userID, actionType: s.ActionType.INVITE, inviteeList: [i], data: n, timeout: d.default(r) ? 0 : r, groupID: '' }, [4, this._sendCustomMessage(i, u, a)]);case 1:return 0 === (l = o.sent()).code ? (c.default.log('TSignaling.invite ok'), this._inviteInfoMap.set(e, u), this._startTimer(u, !0), [2, { inviteID: e, code: l.code, data: l.data }]) : [2, l]; - } - })); - })); - }, t.prototype.inviteInGroup = function (t) { - return n(this, void 0, void 0, (function () { - let e; let i; let n; let r; let a; let u; let l; let _;return o(this, (function (o) { - switch (o.label) { - case 0:return e = I.generate(), c.default.log('TSignaling.inviteInGroup', t, `inviteID=${e}`), d.default(t) || d.default(t.groupID) ? [2, Promise.reject(new f.default({ code: s.ErrorCode.ERR_INVALID_PARAMETERS, message: 'groupID is invalid' }))] : (i = t.groupID, n = t.inviteeList, r = t.data, a = t.timeout, u = t.offlinePushInfo, l = { businessID: s.BusinessID.SIGNAL, inviteID: e, inviter: this._userID, actionType: s.ActionType.INVITE, inviteeList: n, data: r, timeout: d.default(a) ? 0 : a, groupID: i }, [4, this._sendCustomMessage(i, l, u)]);case 1:return 0 === (_ = o.sent()).code ? (c.default.log('TSignaling.inviteInGroup ok'), this._inviteInfoMap.set(e, l), this._startTimer(l, !0), [2, { inviteID: e, code: _.code, data: _.data }]) : [2, _]; - } - })); - })); - }, t.prototype.cancel = function (t) { - return n(this, void 0, void 0, (function () { - let e; let i; let n; let r; let a; let u; let l; let _; let I;return o(this, (function (o) { - switch (o.label) { - case 0:return c.default.log('TSignaling.cancel', t), d.default(t) || d.default(t.inviteID) || !this._inviteInfoMap.has(t.inviteID) || this._isHandling ? [2, Promise.reject(new f.default({ code: s.ErrorCode.ERR_SDK_SIGNALING_INVALID_INVITE_ID, message: 'inviteID is invalid or invitation has been processed' }))] : (this._isHandling = !0, e = t.inviteID, i = t.data, n = this._inviteInfoMap.get(e), r = n.inviter, a = n.groupID, u = n.inviteeList, r !== this._userID ? [3, 2] : (l = { businessID: s.BusinessID.SIGNAL, inviteID: e, inviter: r, actionType: s.ActionType.CANCEL_INVITE, inviteeList: u, data: i, timeout: 0, groupID: a }, _ = a || u[0], [4, this._sendCustomMessage(_, l)]));case 1:return I = o.sent(), this._isHandling = !1, I && 0 === I.code ? (c.default.log('TSignaling.cancel ok'), this._deleteInviteInfoByID(e), this._inviteID = null, [2, { inviteID: e, code: I.code, data: I.data }]) : [2, I];case 2:return c.default.error(`TSignaling.cancel unmatched inviter=${r} and userID=${this._userID}`), this._isHandling = !1, [2, Promise.reject(new f.default({ code: s.ErrorCode.ERR_SDK_SIGNALING_NO_PERMISSION, message: '信令请求无权限,比如取消非自己发起的邀请,接受或则拒绝非发给自己的邀请' }))]; - } - })); - })); - }, t.prototype.accept = function (t) { - return n(this, void 0, void 0, (function () { - let e; let i; let n; let r; let a; let u; let l; let _;return o(this, (function (o) { - switch (o.label) { - case 0:return c.default.log('TSignaling.accept', t), d.default(t) || d.default(t.inviteID) || !this._inviteInfoMap.has(t.inviteID) || this._isHandling ? [2, Promise.reject(new f.default({ code: s.ErrorCode.ERR_SDK_SIGNALING_INVALID_INVITE_ID, message: 'inviteID is invalid or invitation has been processed' }))] : (this._isHandling = !0, e = t.inviteID, i = t.data, n = this._inviteInfoMap.get(e), r = n.inviter, a = n.groupID, n.inviteeList.includes(this._userID) ? (u = { businessID: s.BusinessID.SIGNAL, inviteID: e, inviter: r, actionType: s.ActionType.ACCEPT_INVITE, inviteeList: [this._userID], data: i, timeout: 0, groupID: a }, l = a || r, [4, this._sendCustomMessage(l, u)]) : [3, 2]);case 1:return _ = o.sent(), this._isHandling = !1, _ && 0 === _.code ? (c.default.log('TSignaling.accept ok'), this._updateLocalInviteInfo(u), [2, { inviteID: e, code: _.code, data: _.data }]) : [2, _];case 2:return c.default.error(`TSignaling.accept inviteeList do not include userID=${this._userID}. inviteID=${e} groupID=${a}`), this._isHandling = !1, [2, Promise.reject(new f.default({ code: s.ErrorCode.ERR_SDK_SIGNALING_INVALID_INVITE_ID, message: 'inviteID is invalid or invitation has been processed' }))]; - } - })); - })); - }, t.prototype.reject = function (t) { - return n(this, void 0, void 0, (function () { - let e; let i; let n; let r; let a; let u; let l; let _;return o(this, (function (o) { - switch (o.label) { - case 0:return c.default.log('TSignaling.reject', t), d.default(t) || d.default(t.inviteID) || !this._inviteInfoMap.has(t.inviteID) || this._isHandling ? [2, Promise.reject(new f.default({ code: s.ErrorCode.ERR_SDK_SIGNALING_INVALID_INVITE_ID, message: 'inviteID is invalid or invitation has been processed' }))] : (this._isHandling = !0, e = t.inviteID, i = t.data, n = this._inviteInfoMap.get(e), r = n.inviter, a = n.groupID, n.inviteeList.includes(this._userID) ? (u = { businessID: s.BusinessID.SIGNAL, inviteID: e, inviter: r, actionType: s.ActionType.REJECT_INVITE, inviteeList: [this._userID], data: i, timeout: 0, groupID: a }, l = a || r, [4, this._sendCustomMessage(l, u)]) : [3, 2]);case 1:return _ = o.sent(), this._isHandling = !1, _ && 0 === _.code ? (c.default.log('TSignaling.reject ok'), this._updateLocalInviteInfo(u), [2, { inviteID: e, code: _.code, data: _.data }]) : [2, _];case 2:return c.default.error(`TSignaling.reject inviteeList do not include userID=${this._userID}. inviteID=${e} groupID=${a}`), this._isHandling = !1, [2, Promise.reject(new f.default({ code: s.ErrorCode.ERR_SDK_SIGNALING_INVALID_INVITE_ID, message: 'inviteID is invalid or invitation has been processed' }))]; - } - })); - })); - }, t.prototype._onIMReady = function (t) { - c.default.log('TSignaling._onIMReady'), this._outerEmitter.emit(u.default.SDK_READY); - }, t.prototype._onIMNotReady = function (t) { - c.default.log('TSignaling.onSdkNotReady'), this._outerEmitter.emit(u.default.SDK_NOT_READY); - }, t.prototype._onKickedOut = function (t) { - c.default.log('TSignaling._onKickedOut'), this._outerEmitter.emit(u.default.KICKED_OUT, t.data); - }, t.prototype._onNetStateChange = function (t) { - c.default.log('TSignaling._onNetStateChange'), this._outerEmitter.emit(u.default.NET_STATE_CHANGE, t.data); - }, t.prototype._onMessageReceived = function (t) { - const e = this; const i = t.data; const n = i.filter((t => t.type === p.TYPES.MSG_TEXT));d.default(n) || this._outerEmitter.emit(u.default.TEXT_MESSAGE_RECEIVED, n);const o = i.filter((t => t.type === p.TYPES.MSG_GRP_TIP && t.payload.operationType === p.TYPES.GRP_TIP_MBR_JOIN));d.default(o) || this._outerEmitter.emit(u.default.REMOTE_USER_JOIN, o);const r = i.filter((t => t.type === p.TYPES.MSG_GRP_TIP && t.payload.operationType === p.TYPES.GRP_TIP_MBR_QUIT));d.default(r) || this._outerEmitter.emit(u.default.REMOTE_USER_LEAVE, r);const a = i.filter((t => t.type === p.TYPES.MSG_CUSTOM)); const l = [];a.forEach(((t) => { - let i; const n = t.payload.data; let o = !0;try { - i = JSON.parse(n); - } catch (t) { - o = !1; - } if (o) { - const r = i.businessID; const a = i.actionType;if (1 === r) switch (a) { - case s.ActionType.INVITE:e._onNewInvitationReceived(i);break;case s.ActionType.REJECT_INVITE:e._onInviteeRejected(i);break;case s.ActionType.ACCEPT_INVITE:e._onInviteeAccepted(i);break;case s.ActionType.CANCEL_INVITE:e._onInvitationCancelled(i);break;case s.ActionType.INVITE_TIMEOUT:e._onInvitationTimeout(i); - } else { - if ('av_call' === r) return !0;c.default.warn(`TSignaling._onMessageReceived unknown businessID=${r}`), l.push(t); - } - } else l.push(t); - })), d.default(l) || this._outerEmitter.emit(u.default.CUSTOM_MESSAGE_RECEIVED, l); - }, t.prototype._hasLocalInviteInfo = function (t, e) { - const i = t.inviteID; const n = t.groupID;if (c.default.log(`TSignaling._hasLocalInviteInfo inviteID=${i} groupID=${n}`), !this._inviteInfoMap.has(i)) return !1;const o = this._inviteInfoMap.get(i).inviteeList;return !n || (e ? o.length > 0 : o.length > 0 && o.includes(this._userID)); - }, t.prototype._startTimer = function (t, e) { - const i = this;void 0 === e && (e = !0);const n = t.timeout;if (c.default.log(`TSignaling._startTimer timeout=${n} isInvitator=${e} timeoutStatus=${0 === n}`), 0 !== n) var o = e ? n + 5 : n, r = 1, s = setInterval((() => { - const n = i._hasLocalInviteInfo(t, e);c.default.log(`TSignaling.setInterval hasInviteInfo=${n}`), r < o && n ? ++r : (n && i._sendTimeoutNotice(t, e), clearInterval(s)); - }), 1e3); - }, t.prototype._sendTimeoutNotice = function (t, e) { - return n(this, void 0, void 0, (function () { - let i; let n; let r; let a; let l; let d; let f; let _;return o(this, (function (o) { - switch (o.label) { - case 0:return i = t.inviteID, n = t.groupID, r = t.inviteeList, a = t.inviter, l = t.data, d = e ? n || r[0] : n || a, c.default.log(`TSignaling._sendTimeoutNotice inviteID=${i} to=${d} isInvitator=${e}`), f = { businessID: s.BusinessID.SIGNAL, inviteID: i, inviter: a, actionType: s.ActionType.INVITE_TIMEOUT, inviteeList: e ? r : [this._userID], data: l, timeout: 0, groupID: n }, [4, this._sendCustomMessage(d, f)];case 1:return (_ = o.sent()) && 0 === _.code && (this._outerEmitter.emit(u.default.INVITATION_TIMEOUT, { inviter: a, inviteID: i, groupID: n, inviteeList: f.inviteeList, isSelfTimeout: !0 }), e ? this._deleteInviteInfoByID(i) : this._updateLocalInviteInfo(f)), [2, _]; - } - })); - })); - }, t.prototype._onNewInvitationReceived = function (e) { - const i = e.inviteID; const n = e.inviter; const o = e.inviteeList; const r = e.groupID; const s = e.data; const a = o.includes(this._userID);c.default.log('TSignaling._onNewInvitationReceived', e, `myselfIncluded=${a}`);const u = JSON.parse(s);r && (0 === u.call_end || d.default(u.room_id) || d.default(u.data.room_id)) ? this._outerEmitter.emit(t.EVENT.NEW_INVITATION_RECEIVED, { inviteID: i, inviter: n, groupID: r, inviteeList: o, data: e.data || '' }) : (r && a || !r) && (this._inviteInfoMap.set(i, e), this._outerEmitter.emit(t.EVENT.NEW_INVITATION_RECEIVED, { inviteID: i, inviter: n, groupID: r, inviteeList: o, data: e.data || '' }), this._startTimer(e, !1)); - }, t.prototype._onInviteeRejected = function (t) { - const e = t.inviteID; const i = t.inviter; const n = t.groupID; const o = this._inviteInfoMap.has(e);c.default.log(`TSignaling._onInviteeRejected inviteID=${e} hasInviteID=${o} inviter=${i} groupID=${n}`), (n && o || !n) && (this._updateLocalInviteInfo(t), this._outerEmitter.emit(u.default.INVITEE_REJECTED, { inviteID: e, inviter: i, groupID: n, invitee: t.inviteeList[0], data: t.data || '' })); - }, t.prototype._onInviteeAccepted = function (t) { - const e = t.inviteID; const i = t.inviter; const n = t.groupID; const o = this._inviteInfoMap.has(e);c.default.log(`TSignaling._onInviteeAccepted inviteID=${e} hasInviteID=${o} inviter=${i} groupID=${n}`), (n && o || !n) && (this._updateLocalInviteInfo(t), this._outerEmitter.emit(u.default.INVITEE_ACCEPTED, { inviteID: e, inviter: i, groupID: n, invitee: t.inviteeList[0], data: t.data || '' })); - }, t.prototype._onInvitationCancelled = function (t) { - const e = t.inviteID; const i = t.inviter; const n = t.groupID; const o = this._inviteInfoMap.has(e);c.default.log(`TSignaling._onInvitationCancelled inviteID=${e} hasInviteID=${o} inviter=${i} groupID=${n}`), (n && o || !n) && (this._deleteInviteInfoByID(e), this._outerEmitter.emit(u.default.INVITATION_CANCELLED, { inviteID: e, inviter: i, groupID: n, data: t.data || '' })); - }, t.prototype._onInvitationTimeout = function (t) { - const e = t.inviteID; const i = t.inviter; const n = t.groupID; const o = this._inviteInfoMap.has(e);c.default.log(`TSignaling._onInvitationTimeout inviteID=${e} hasInviteID=${o} inviter=${i} groupID=${n}`), (n && o || !n) && (this._updateLocalInviteInfo(t), this._outerEmitter.emit(u.default.INVITATION_TIMEOUT, { inviteID: e, inviter: i, groupID: n, inviteeList: t.inviteeList, isSelfTimeout: !1 })); - }, t.prototype._updateLocalInviteInfo = function (t) { - const e = t.inviteID; const i = t.inviter; const n = t.inviteeList; const o = t.groupID;if (c.default.log(`TSignaling._updateLocalInviteInfo inviteID=${e} inviter=${i} groupID=${o}`), o) { - if (this._inviteInfoMap.has(e)) { - const r = n[0]; const s = this._inviteInfoMap.get(e).inviteeList;s.includes(r) && (s.splice(s.indexOf(r), 1), c.default.log(`TSignaling._updateLocalInviteInfo remove ${r} from localInviteeList. ${s.length} invitees left`)), 0 === s.length && this._deleteInviteInfoByID(e); - } - } else this._deleteInviteInfoByID(e); - }, t.prototype._deleteInviteInfoByID = function (t) { - this._inviteInfoMap.has(t) && (c.default.log(`TSignaling._deleteInviteInfoByID remove ${t} from inviteInfoMap.`), this._inviteInfoMap.delete(t)); - }, t.prototype._sendCustomMessage = function (t, e, i) { - return n(this, void 0, void 0, (function () { - let n; let r; let a; let u;return o(this, (function (o) { - return n = e.groupID, r = this._tim.createCustomMessage({ to: t, conversationType: n ? p.TYPES.CONV_GROUP : p.TYPES.CONV_C2C, priority: p.TYPES.MSG_PRIORITY_HIGH, payload: { data: JSON.stringify(e) } }), e.actionType === s.ActionType.INVITE ? (u = { title: (a = i || {}).title || '', description: a.description || '您有一个通话请求', androidOPPOChannelID: a.androidOPPOChannelID || '', extension: this._handleOfflineInfo(e) }, c.default.log(`TSignaling.offlinePushInfo ${JSON.stringify(u)}`), [2, this._tim.sendMessage(r, { offlinePushInfo: u })]) : [2, this._tim.sendMessage(r)]; - })); - })); - }, t.prototype._handleOfflineInfo = function (t) { - const e = { action: t.actionType, call_type: t.groupID ? 2 : 1, room_id: t.data.room_id, call_id: t.inviteID, timeout: t.data.timeout, version: 4, invited_list: t.inviteeList };t.groupID && (e.group_id = t.groupID);const i = { entity: { action: 2, chatType: t.groupID ? 2 : 1, content: JSON.stringify(e), sendTime: parseInt(`${Date.now() / 1e3}`), sender: t.inviter, version: 1 } }; const n = JSON.stringify(i);return c.default.log(`TSignaling._handleOfflineInfo ${n}`), n; - }, t.EVENT = u.default, t.TYPES = l.default, t; - }());e.default = g; -}, function (t, e, i) { - 'use strict';let n; let o; let r;Object.defineProperty(e, '__esModule', { value: !0 }), e.ErrorCode = e.BusinessID = e.ActionType = void 0, (function (t) { - t[t.INVITE = 1] = 'INVITE', t[t.CANCEL_INVITE = 2] = 'CANCEL_INVITE', t[t.ACCEPT_INVITE = 3] = 'ACCEPT_INVITE', t[t.REJECT_INVITE = 4] = 'REJECT_INVITE', t[t.INVITE_TIMEOUT = 5] = 'INVITE_TIMEOUT'; - }(n || (n = {}))), e.ActionType = n, (function (t) { - t[t.SIGNAL = 1] = 'SIGNAL'; - }(o || (o = {}))), e.BusinessID = o, (function (t) { - t[t.ERR_INVALID_PARAMETERS = 6017] = 'ERR_INVALID_PARAMETERS', t[t.ERR_SDK_SIGNALING_INVALID_INVITE_ID = 8010] = 'ERR_SDK_SIGNALING_INVALID_INVITE_ID', t[t.ERR_SDK_SIGNALING_NO_PERMISSION = 8011] = 'ERR_SDK_SIGNALING_NO_PERMISSION'; - }(r || (r = {}))), e.ErrorCode = r; -}, function (t, e, i) { - 'use strict';i.r(e), i.d(e, 'default', (() => s));const n = Function.prototype.apply; const o = new WeakMap;function r(t) { - return o.has(t) || o.set(t, {}), o.get(t); - } class s { - constructor(t = null, e = console) { - const i = r(this);return i._events = new Set, i._callbacks = {}, i._console = e, i._maxListeners = null === t ? null : parseInt(t, 10), this; - }_addCallback(t, e, i, n) { - return this._getCallbacks(t).push({ callback: e, context: i, weight: n }), this._getCallbacks(t).sort((t, e) => t.weight > e.weight), this; - }_getCallbacks(t) { - return r(this)._callbacks[t]; - }_getCallbackIndex(t, e) { - return this._has(t) ? this._getCallbacks(t).findIndex(t => t.callback === e) : null; - }_achieveMaxListener(t) { - return null !== r(this)._maxListeners && r(this)._maxListeners <= this.listenersNumber(t); - }_callbackIsExists(t, e, i) { - const n = this._getCallbackIndex(t, e); const o = -1 !== n ? this._getCallbacks(t)[n] : void 0;return -1 !== n && o && o.context === i; - }_has(t) { - return r(this)._events.has(t); - }on(t, e, i = null, n = 1) { - const o = r(this);if ('function' !== typeof e) throw new TypeError(`${e} is not a function`);return this._has(t) ? (this._achieveMaxListener(t) && o._console.warn(`Max listeners (${o._maxListeners}) for event "${t}" is reached!`), this._callbackIsExists(...arguments) && o._console.warn(`Event "${t}" already has the callback ${e}.`)) : (o._events.add(t), o._callbacks[t] = []), this._addCallback(...arguments), this; - }once(t, e, i = null, o = 1) { - const r = (...o) => (this.off(t, r), n.call(e, i, o));return this.on(t, r, i, o); - }off(t, e = null) { - const i = r(this);let n;return this._has(t) && (null === e ? (i._events.delete(t), i._callbacks[t] = null) : (n = this._getCallbackIndex(t, e), -1 !== n && (i._callbacks[t].splice(n, 1), this.off(...arguments)))), this; - }emit(t, ...e) { - return this._has(t) && this._getCallbacks(t).forEach(t => n.call(t.callback, t.context, e)), this; - }clear() { - const t = r(this);return t._events.clear(), t._callbacks = {}, this; - }listenersNumber(t) { - return this._has(t) ? this._getCallbacks(t).length : null; - } - } -}, function (t, e) { - let i;i = (function () { - return this; - }());try { - i = i || new Function('return this')(); - } catch (t) { - 'object' === typeof window && (i = window); - }t.exports = i; -}, function (t, e, i) { - 'use strict';i.r(e);const n = i(0);const o = Object.prototype.hasOwnProperty;e.default = function (t) { - if (null == t) return !0;if ('boolean' === typeof t) return !1;if ('number' === typeof t) return 0 === t;if ('string' === typeof t) return 0 === t.length;if ('function' === typeof t) return 0 === t.length;if (Array.isArray(t)) return 0 === t.length;if (t instanceof Error) return '' === t.message;if (Object(n.f)(t)) { - for (const e in t) if (o.call(t, e)) return !1;return !0; - } return !!(Object(n.e)(t) || Object(n.g)(t) || Object(n.c)(t)) && 0 === t.size; - }; -}, function (t, e, i) { - 'use strict';i.r(e);class n extends Error { - constructor(t) { - super(), this.code = t.code, this.message = t.message, this.data = t.data || {}; - } - }e.default = n; -}, function (t, e, i) { - 'use strict';i.r(e);const n = i(1); const o = i(4); const r = i.n(o);e.default = class { - constructor() { - this._funcMap = new Map; - }defense(t, e, i) { - if ('string' !== typeof t) return null;if (0 === t.length) return null;if ('function' !== typeof e) return null;if (this._funcMap.has(t) && this._funcMap.get(t).has(e)) return this._funcMap.get(t).get(e);this._funcMap.has(t) || this._funcMap.set(t, new Map);let n = null;return this._funcMap.get(t).has(e) ? n = this._funcMap.get(t).get(e) : (n = this._pack(t, e, i), this._funcMap.get(t).set(e, n)), n; - }defenseOnce(t, e, i) { - return 'function' !== typeof e ? null : this._pack(t, e, i); - }find(t, e) { - return 'string' !== typeof t || 0 === t.length || 'function' !== typeof e ? null : this._funcMap.has(t) ? this._funcMap.get(t).has(e) ? this._funcMap.get(t).get(e) : (n.default.log(`SafetyCallback.find: 找不到 func —— ${t}/${'' !== e.name ? e.name : '[anonymous]'}`), null) : (n.default.log(`SafetyCallback.find: 找不到 eventName-${t} 对应的 func`), null); - }delete(t, e) { - return 'function' === typeof e && (!!this._funcMap.has(t) && (!!this._funcMap.get(t).has(e) && (this._funcMap.get(t).delete(e), 0 === this._funcMap.get(t).size && this._funcMap.delete(t), !0))); - }_pack(t, e, i) { - return function () { - try { - e.apply(i, Array.from(arguments)); - } catch (e) { - const i = Object.values(r.a).indexOf(t); const o = Object.keys(r.a)[i];n.default.error(`接入侧事件 EVENT.${o} 对应的回调函数逻辑存在问题,请检查!`, e); - } - }; - } - }; -}, function (t, e, i) { +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("tim-wx-sdk")):"function"==typeof define&&define.amd?define(["tim-wx-sdk"],e):"object"==typeof exports?exports.TSignaling=e(require("tim-wx-sdk")):t.TSignaling=e(t.TIM)}(window,(function(t){return function(t){var e={};function i(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,i),o.l=!0,o.exports}return i.m=t,i.c=e,i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)i.d(n,o,function(e){return t[e]}.bind(null,o));return n},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=5)}([function(t,e,i){"use strict";i.d(e,"e",(function(){return p})),i.d(e,"g",(function(){return g})),i.d(e,"c",(function(){return h})),i.d(e,"f",(function(){return v})),i.d(e,"b",(function(){return m})),i.d(e,"d",(function(){return T})),i.d(e,"a",(function(){return y})),i.d(e,"h",(function(){return N}));const n="undefined"!=typeof window,o=("undefined"!=typeof wx&&wx.getSystemInfoSync,n&&window.navigator&&window.navigator.userAgent||""),r=/AppleWebKit\/([\d.]+)/i.exec(o),s=(r&&parseFloat(r.pop()),/iPad/i.test(o)),a=/iPhone/i.test(o)&&!s,u=/iPod/i.test(o),l=a||s||u,c=(function(){const t=o.match(/OS (\d+)_/i);t&&t[1]&&t[1]}(),/Android/i.test(o)),d=function(){const t=o.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);if(!t)return null;const e=t[1]&&parseFloat(t[1]),i=t[2]&&parseFloat(t[2]);return e&&i?parseFloat(t[1]+"."+t[2]):e||null}(),f=(c&&/webkit/i.test(o),/Firefox/i.test(o),/Edge/i.test(o)),_=!f&&/Chrome/i.test(o),I=(function(){const t=o.match(/Chrome\/(\d+)/);t&&t[1]&&parseFloat(t[1])}(),/MSIE/.test(o),/MSIE\s8\.0/.test(o),function(){const t=/MSIE\s(\d+)\.\d/.exec(o);let e=t&&parseFloat(t[1]);!e&&/Trident\/7.0/i.test(o)&&/rv:11.0/.test(o)&&(e=11)}(),/Safari/i.test(o),/TBS\/\d+/i.test(o));(function(){const t=o.match(/TBS\/(\d+)/i);if(t&&t[1])t[1]})(),!I&&/MQQBrowser\/\d+/i.test(o),!I&&/ QQBrowser\/\d+/i.test(o),/(micromessenger|webbrowser)/i.test(o),/Windows/i.test(o),/MAC OS X/i.test(o),/MicroMessenger/i.test(o);i(2),i(1);const p=function(t){return"map"===D(t)},g=function(t){return"set"===D(t)},h=function(t){return"file"===D(t)},v=function(t){if("object"!=typeof t||null===t)return!1;const e=Object.getPrototypeOf(t);if(null===e)return!0;let i=e;for(;null!==Object.getPrototypeOf(i);)i=Object.getPrototypeOf(i);return e===i},E=function(t){return"function"==typeof Array.isArray?Array.isArray(t):"array"===D(t)},m=function(t){return E(t)||function(t){return null!==t&&"object"==typeof t}(t)},T=function(t){return t instanceof Error},D=function(t){return Object.prototype.toString.call(t).match(/^\[object (.*)\]$/)[1].toLowerCase()};let S=0;Date.now||(Date.now=function(){return(new Date).getTime()});const y={now:function(){0===S&&(S=Date.now()-1);const t=Date.now()-S;return t>4294967295?(S+=4294967295,Date.now()-S):t},utc:function(){return Math.round(Date.now()/1e3)}},N=function(t){return JSON.stringify(t,["message","code"])}},function(t,e,i){"use strict";i.r(e);var n=i(3),o=i(0);let r=0;const s=new Map;function a(){const t=new Date;return"TSignaling "+t.toLocaleTimeString("en-US",{hour12:!1})+"."+function(t){let e;switch(t.toString().length){case 1:e="00"+t;break;case 2:e="0"+t;break;default:e=t}return e}(t.getMilliseconds())+":"}const u={_data:[],_length:0,_visible:!1,arguments2String(t){let e;if(1===t.length)e=a()+t[0];else{e=a();for(let i=0,n=t.length;i0&&o[o.length-1])||6!==r[0]&&2!==r[0])){s=0;continue}if(3===r[0]&&(!o||r[1]>o[0]&&r[1]t.weight>e.weight),this}_getCallbacks(t){return r(this)._callbacks[t]}_getCallbackIndex(t,e){return this._has(t)?this._getCallbacks(t).findIndex(t=>t.callback===e):null}_achieveMaxListener(t){return null!==r(this)._maxListeners&&r(this)._maxListeners<=this.listenersNumber(t)}_callbackIsExists(t,e,i){const n=this._getCallbackIndex(t,e),o=-1!==n?this._getCallbacks(t)[n]:void 0;return-1!==n&&o&&o.context===i}_has(t){return r(this)._events.has(t)}on(t,e,i=null,n=1){const o=r(this);if("function"!=typeof e)throw new TypeError(e+" is not a function");return this._has(t)?(this._achieveMaxListener(t)&&o._console.warn(`Max listeners (${o._maxListeners}) for event "${t}" is reached!`),this._callbackIsExists(...arguments)&&o._console.warn(`Event "${t}" already has the callback ${e}.`)):(o._events.add(t),o._callbacks[t]=[]),this._addCallback(...arguments),this}once(t,e,i=null,o=1){const r=(...o)=>(this.off(t,r),n.call(e,i,o));return this.on(t,r,i,o)}off(t,e=null){const i=r(this);let n;return this._has(t)&&(null===e?(i._events.delete(t),i._callbacks[t]=null):(n=this._getCallbackIndex(t,e),-1!==n&&(i._callbacks[t].splice(n,1),this.off(...arguments)))),this}emit(t,...e){return this._has(t)&&this._getCallbacks(t).forEach(t=>n.call(t.callback,t.context,e)),this}clear(){const t=r(this);return t._events.clear(),t._callbacks={},this}listenersNumber(t){return this._has(t)?this._getCallbacks(t).length:null}}},function(t,e){var i;i=function(){return this}();try{i=i||new Function("return this")()}catch(t){"object"==typeof window&&(i=window)}t.exports=i},function(t,e,i){"use strict";i.r(e);var n=i(0);const o=Object.prototype.hasOwnProperty;e.default=function(t){if(null==t)return!0;if("boolean"==typeof t)return!1;if("number"==typeof t)return 0===t;if("string"==typeof t)return 0===t.length;if("function"==typeof t)return 0===t.length;if(Array.isArray(t))return 0===t.length;if(t instanceof Error)return""===t.message;if(Object(n.f)(t)){for(const e in t)if(o.call(t,e))return!1;return!0}return!!(Object(n.e)(t)||Object(n.g)(t)||Object(n.c)(t))&&0===t.size}},function(t,e,i){"use strict";i.r(e);class n extends Error{constructor(t){super(),this.code=t.code,this.message=t.message,this.data=t.data||{}}}e.default=n},function(t,e,i){"use strict";i.r(e);var n=i(1),o=i(4),r=i.n(o);e.default=class{constructor(){this._funcMap=new Map}defense(t,e,i){if("string"!=typeof t)return null;if(0===t.length)return null;if("function"!=typeof e)return null;if(this._funcMap.has(t)&&this._funcMap.get(t).has(e))return this._funcMap.get(t).get(e);this._funcMap.has(t)||this._funcMap.set(t,new Map);let n=null;return this._funcMap.get(t).has(e)?n=this._funcMap.get(t).get(e):(n=this._pack(t,e,i),this._funcMap.get(t).set(e,n)),n}defenseOnce(t,e,i){return"function"!=typeof e?null:this._pack(t,e,i)}find(t,e){return"string"!=typeof t||0===t.length||"function"!=typeof e?null:this._funcMap.has(t)?this._funcMap.get(t).has(e)?this._funcMap.get(t).get(e):(n.default.log(`SafetyCallback.find: 找不到 func —— ${t}/${""!==e.name?e.name:"[anonymous]"}`),null):(n.default.log(`SafetyCallback.find: 找不到 eventName-${t} 对应的 func`),null)}delete(t,e){return"function"==typeof e&&(!!this._funcMap.has(t)&&(!!this._funcMap.get(t).has(e)&&(this._funcMap.get(t).delete(e),0===this._funcMap.get(t).size&&this._funcMap.delete(t),!0)))}_pack(t,e,i){return function(){try{e.apply(i,Array.from(arguments))}catch(e){const i=Object.values(r.a).indexOf(t),o=Object.keys(r.a)[i];n.default.error(`接入侧事件 EVENT.${o} 对应的回调函数逻辑存在问题,请检查!`,e)}}}}},function(t,e,i){ /** * UUID.js - RFC-compliant UUID Generator for JavaScript * * @file * @author LiosK - * @version v4.2.8 - * @license Apache License 2.0: Copyright (c) 2010-2021 LiosK + * @version v4.2.5 + * @license Apache License 2.0: Copyright (c) 2010-2020 LiosK */ - let n;n = (function (e) { - 'use strict';function n() { - const t = o._getRandomInt;this.timestamp = 0, this.sequence = t(14), this.node = 1099511627776 * (1 | t(8)) + t(40), this.tick = t(4); - } function o() {} return o.generate = function () { - const t = o._getRandomInt; const e = o._hexAligner;return `${e(t(32), 8)}-${e(t(16), 4)}-${e(16384 | t(12), 4)}-${e(32768 | t(14), 4)}-${e(t(48), 12)}`; - }, o._getRandomInt = function (t) { - if (t < 0 || t > 53) return NaN;const e = 0 | 1073741824 * Math.random();return t > 30 ? e + 1073741824 * (0 | Math.random() * (1 << t - 30)) : e >>> 30 - t; - }, o._hexAligner = function (t, e) { - for (var i = t.toString(16), n = e - i.length, o = '0';n > 0;n >>>= 1, o += o)1 & n && (i = o + i);return i; - }, o.overwrittenUUID = e, (function () { - const t = o._getRandomInt;o.useMathRandom = function () { - o._getRandomInt = t; - };let e = null; let n = t;'undefined' !== typeof window && (e = window.crypto || window.msCrypto) ? e.getRandomValues && 'undefined' !== typeof Uint32Array && (n = function (t) { - if (t < 0 || t > 53) return NaN;let i = new Uint32Array(t > 32 ? 2 : 1);return i = e.getRandomValues(i) || i, t > 32 ? i[0] + 4294967296 * (i[1] >>> 64 - t) : i[0] >>> 32 - t; - }) : (e = i(13)) && e.randomBytes && (n = function (t) { - if (t < 0 || t > 53) return NaN;const i = e.randomBytes(t > 32 ? 8 : 4); const n = i.readUInt32BE(0);return t > 32 ? n + 4294967296 * (i.readUInt32BE(4) >>> 64 - t) : n >>> 32 - t; - }), o._getRandomInt = n; - }()), o.FIELD_NAMES = ['timeLow', 'timeMid', 'timeHiAndVersion', 'clockSeqHiAndReserved', 'clockSeqLow', 'node'], o.FIELD_SIZES = [32, 16, 16, 8, 8, 48], o.genV4 = function () { - const t = o._getRandomInt;return (new o)._init(t(32), t(16), 16384 | t(12), 128 | t(6), t(8), t(48)); - }, o.parse = function (t) { - let e;if (e = /^\s*(urn:uuid:|\{)?([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{2})([0-9a-f]{2})-([0-9a-f]{12})(\})?\s*$/i.exec(t)) { - const i = e[1] || ''; const n = e[8] || '';if (i + n === '' || '{' === i && '}' === n || 'urn:uuid:' === i.toLowerCase() && '' === n) return (new o)._init(parseInt(e[2], 16), parseInt(e[3], 16), parseInt(e[4], 16), parseInt(e[5], 16), parseInt(e[6], 16), parseInt(e[7], 16)); - } return null; - }, o.prototype._init = function () { - const t = o.FIELD_NAMES; const e = o.FIELD_SIZES; const i = o._binAligner; const n = o._hexAligner;this.intFields = new Array(6), this.bitFields = new Array(6), this.hexFields = new Array(6);for (let r = 0;r < 6;r++) { - const s = parseInt(arguments[r] || 0);this.intFields[r] = this.intFields[t[r]] = s, this.bitFields[r] = this.bitFields[t[r]] = i(s, e[r]), this.hexFields[r] = this.hexFields[t[r]] = n(s, e[r] >>> 2); - } return this.version = this.intFields.timeHiAndVersion >>> 12 & 15, this.bitString = this.bitFields.join(''), this.hexNoDelim = this.hexFields.join(''), this.hexString = `${this.hexFields[0]}-${this.hexFields[1]}-${this.hexFields[2]}-${this.hexFields[3]}${this.hexFields[4]}-${this.hexFields[5]}`, this.urn = `urn:uuid:${this.hexString}`, this; - }, o._binAligner = function (t, e) { - for (var i = t.toString(2), n = e - i.length, o = '0';n > 0;n >>>= 1, o += o)1 & n && (i = o + i);return i; - }, o.prototype.toString = function () { - return this.hexString; - }, o.prototype.equals = function (t) { - if (!(t instanceof o)) return !1;for (let e = 0;e < 6;e++) if (this.intFields[e] !== t.intFields[e]) return !1;return !0; - }, o.NIL = (new o)._init(0, 0, 0, 0, 0, 0), o.genV1 = function () { - null == o._state && o.resetState();const t = (new Date).getTime(); const e = o._state;t != e.timestamp ? (t < e.timestamp && e.sequence++, e.timestamp = t, e.tick = o._getRandomInt(4)) : Math.random() < o._tsRatio && e.tick < 9984 ? e.tick += 1 + o._getRandomInt(4) : e.sequence++;const i = o._getTimeFieldValues(e.timestamp); const n = i.low + e.tick; const r = 4095 & i.hi | 4096;e.sequence &= 16383;const s = e.sequence >>> 8 | 128; const a = 255 & e.sequence;return (new o)._init(n, i.mid, r, s, a, e.node); - }, o.resetState = function () { - o._state = new n; - }, o._tsRatio = 1 / 4, o._state = null, o._getTimeFieldValues = function (t) { - const e = t - Date.UTC(1582, 9, 15); const i = e / 4294967296 * 1e4 & 268435455;return { low: 1e4 * (268435455 & e) % 4294967296, mid: 65535 & i, hi: i >>> 16, timestamp: e }; - }, 'object' === typeof t.exports && (t.exports = o), o; - }(n)); -}, function (t, e) {}, function (e, i) { - e.exports = t; -}, function (t) { - t.exports = JSON.parse('{"name":"tsignaling","version":"0.7.0-beta.1","description":"腾讯云 Web 信令 SDK","main":"./src/index.ts","scripts":{"lint":"./node_modules/.bin/eslint ./src","fix":"./node_modules/.bin/eslint --fix ./src","ts2js":"tsc src/index.ts --outDir build/ts2js","doc":"npm run ts2js && npm run doc:clean && npm run doc:build","doc:build":"./node_modules/.bin/jsdoc -c build/jsdoc/jsdoc.json && node ./build/jsdoc/fix-doc.js","doc:clean":"node ./build/jsdoc/clean-doc.js","build:wx":"cross-env NODE_ENV=wx webpack --config webpack.prod.config.js","build:web":"node node_modules/cross-env/src/bin/cross-env.js NODE_ENV=web node_modules/webpack/bin/webpack.js --config webpack.prod.config.js","build:package":"node build/package-bundle.js","prerelease":"npm run build:web && npm run build:wx && npm run build:package && node ./build/copy.js","start:wx":"cross-env NODE_ENV=wx webpack-dev-server --config webpack.config.js","start:web":"node node_modules/cross-env/src/bin/cross-env.js NODE_ENV=web node_modules/webpack-dev-server/bin/webpack-dev-server.js --config webpack.dev.config.js","build_withcopy":"npm run build:web && cp dist/npm/tsignaling-js.js ../TIM-demo-web/node_modules/tsignaling/tsignaling-js.js","build_withcopy:mp":"npm run build:wx && cp dist/npm/tsignaling-wx.js ../TIM-demo-mini/static/component/TRTCCalling/utils/tsignaling-wx.js","changelog":"conventional-changelog -p angular -i CHANGELOG.md -s -r 0 && cp CHANGELOG.md build/jsdoc/tutorials/CHANGELOG.md"},"husky":{"hooks":{"pre-commit":"npm run lint"}},"lint-staged":{"*.{.ts,.tsx}":["eslint","git add"]},"keywords":["腾讯云","即时通信","信令"],"author":"","license":"ISC","devDependencies":{"conventional-changelog-cli":"^2.1.1","cross-env":"^7.0.2","fs-extra":"^9.0.1","html-webpack-plugin":"^4.3.0","ts-loader":"^7.0.5","typescript":"^3.9.9","webpack":"^4.43.0","webpack-cli":"^3.3.11","webpack-dev-server":"^3.11.0"},"dependencies":{"@typescript-eslint/eslint-plugin":"^4.22.1","@typescript-eslint/parser":"^4.22.1","EventEmitter":"^1.0.0","docdash-blue":"^1.1.3","eslint":"^5.16.0","eslint-config-google":"^0.13.0","eslint-plugin-classes":"^0.1.1","jsdoc":"^3.6.4","jsdoc-plugin-typescript":"^2.0.5","pretty":"^2.0.0","replace":"^1.2.0","uuidjs":"^4.2.5"}}'); -}])).default))); +var n;n=function(e){"use strict";function n(){var t=o._getRandomInt;this.timestamp=0,this.sequence=t(14),this.node=1099511627776*(1|t(8))+t(40),this.tick=t(4)}function o(){}return o.generate=function(){var t=o._getRandomInt,e=o._hexAligner;return e(t(32),8)+"-"+e(t(16),4)+"-"+e(16384|t(12),4)+"-"+e(32768|t(14),4)+"-"+e(t(48),12)},o._getRandomInt=function(t){if(t<0||t>53)return NaN;var e=0|1073741824*Math.random();return t>30?e+1073741824*(0|Math.random()*(1<>>30-t},o._hexAligner=function(t,e){for(var i=t.toString(16),n=e-i.length,o="0";n>0;n>>>=1,o+=o)1&n&&(i=o+i);return i},o.overwrittenUUID=e,function(){var t=o._getRandomInt;o.useMathRandom=function(){o._getRandomInt=t};var e=null,n=t;"undefined"!=typeof window&&(e=window.crypto||window.msCrypto)?e.getRandomValues&&"undefined"!=typeof Uint32Array&&(n=function(t){if(t<0||t>53)return NaN;var i=new Uint32Array(t>32?2:1);return i=e.getRandomValues(i)||i,t>32?i[0]+4294967296*(i[1]>>>64-t):i[0]>>>32-t}):(e=i(13))&&e.randomBytes&&(n=function(t){if(t<0||t>53)return NaN;var i=e.randomBytes(t>32?8:4),n=i.readUInt32BE(0);return t>32?n+4294967296*(i.readUInt32BE(4)>>>64-t):n>>>32-t}),o._getRandomInt=n}(),o.FIELD_NAMES=["timeLow","timeMid","timeHiAndVersion","clockSeqHiAndReserved","clockSeqLow","node"],o.FIELD_SIZES=[32,16,16,8,8,48],o.genV4=function(){var t=o._getRandomInt;return(new o)._init(t(32),t(16),16384|t(12),128|t(6),t(8),t(48))},o.parse=function(t){var e;if(e=/^\s*(urn:uuid:|\{)?([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{2})([0-9a-f]{2})-([0-9a-f]{12})(\})?\s*$/i.exec(t)){var i=e[1]||"",n=e[8]||"";if(i+n===""||"{"===i&&"}"===n||"urn:uuid:"===i.toLowerCase()&&""===n)return(new o)._init(parseInt(e[2],16),parseInt(e[3],16),parseInt(e[4],16),parseInt(e[5],16),parseInt(e[6],16),parseInt(e[7],16))}return null},o.prototype._init=function(){var t=o.FIELD_NAMES,e=o.FIELD_SIZES,i=o._binAligner,n=o._hexAligner;this.intFields=new Array(6),this.bitFields=new Array(6),this.hexFields=new Array(6);for(var r=0;r<6;r++){var s=parseInt(arguments[r]||0);this.intFields[r]=this.intFields[t[r]]=s,this.bitFields[r]=this.bitFields[t[r]]=i(s,e[r]),this.hexFields[r]=this.hexFields[t[r]]=n(s,e[r]>>>2)}return this.version=this.intFields.timeHiAndVersion>>>12&15,this.bitString=this.bitFields.join(""),this.hexNoDelim=this.hexFields.join(""),this.hexString=this.hexFields[0]+"-"+this.hexFields[1]+"-"+this.hexFields[2]+"-"+this.hexFields[3]+this.hexFields[4]+"-"+this.hexFields[5],this.urn="urn:uuid:"+this.hexString,this},o._binAligner=function(t,e){for(var i=t.toString(2),n=e-i.length,o="0";n>0;n>>>=1,o+=o)1&n&&(i=o+i);return i},o.prototype.toString=function(){return this.hexString},o.prototype.equals=function(t){if(!(t instanceof o))return!1;for(var e=0;e<6;e++)if(this.intFields[e]!==t.intFields[e])return!1;return!0},o.NIL=(new o)._init(0,0,0,0,0,0),o.genV1=function(){null==o._state&&o.resetState();var t=(new Date).getTime(),e=o._state;t!=e.timestamp?(t>>8|128,a=255&e.sequence;return(new o)._init(n,i.mid,r,s,a,e.node)},o.resetState=function(){o._state=new n},o._tsRatio=1/4,o._state=null,o._getTimeFieldValues=function(t){var e=t-Date.UTC(1582,9,15),i=e/4294967296*1e4&268435455;return{low:1e4*(268435455&e)%4294967296,mid:65535&i,hi:i>>>16,timestamp:e}},"object"==typeof t.exports&&(t.exports=o),o}(n)},function(t,e){},function(e,i){e.exports=t},function(t){t.exports=JSON.parse('{"name":"tsignaling","version":"0.10.0","description":"腾讯云 Web 信令 SDK","main":"./src/index.ts","scripts":{"lint":"./node_modules/.bin/eslint ./src","fix":"./node_modules/.bin/eslint --fix ./src","ts2js":"tsc src/index.ts --outDir build/ts2js","doc":"npm run ts2js && npm run doc:clean && npm run doc:build","doc:build":"./node_modules/.bin/jsdoc -c build/jsdoc/jsdoc.json && node ./build/jsdoc/fix-doc.js","doc:clean":"node ./build/jsdoc/clean-doc.js","build:wx":"cross-env NODE_ENV=wx webpack --config webpack.prod.config.js","build:web":"node node_modules/cross-env/src/bin/cross-env.js NODE_ENV=web node_modules/webpack/bin/webpack.js --config webpack.prod.config.js","build:package":"node build/package-bundle.js","prerelease":"npm run build:web && npm run build:wx && npm run build:package && node ./build/copy.js","start:wx":"cross-env NODE_ENV=wx webpack-dev-server --config webpack.config.js","start:web":"node node_modules/cross-env/src/bin/cross-env.js NODE_ENV=web node_modules/webpack-dev-server/bin/webpack-dev-server.js --config webpack.dev.config.js","build_withcopy":"npm run build:web && cp dist/npm/tsignaling-js.js ../TIM-demo-web/node_modules/tsignaling/tsignaling-js.js","build_withcopy:mp":"npm run build:wx && cp dist/npm/tsignaling-wx.js ../TIM-demo-mini/static/component/TRTCCalling/utils/tsignaling-wx.js","changelog":"cp CHANGELOG.md build/jsdoc/tutorials/CHANGELOG.md"},"husky":{"hooks":{"pre-commit":"npm run lint"}},"lint-staged":{"*.{.ts,.tsx}":["eslint","git add"]},"keywords":["腾讯云","即时通信","信令"],"author":"","license":"ISC","devDependencies":{"conventional-changelog-cli":"^2.1.1","cross-env":"^7.0.2","fs-extra":"^9.0.1","html-webpack-plugin":"^4.3.0","ts-loader":"^7.0.5","typescript":"^3.9.9","webpack":"^4.43.0","webpack-cli":"^3.3.11","webpack-dev-server":"^3.11.0"},"dependencies":{"@typescript-eslint/eslint-plugin":"^4.22.1","@typescript-eslint/parser":"^4.22.1","EventEmitter":"^1.0.0","docdash-blue":"^1.1.3","eslint":"^5.16.0","eslint-config-google":"^0.13.0","eslint-plugin-classes":"^0.1.1","jsdoc":"^3.6.4","jsdoc-plugin-typescript":"^2.0.5","pretty":"^2.0.0","replace":"^1.2.0","uuidjs":"^4.2.5"}}')}]).default})); \ No newline at end of file diff --git a/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/TRTCCalling/utils/event.js b/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/TRTCCalling/utils/event.js index c6dece9bd0..861fb06375 100644 --- a/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/TRTCCalling/utils/event.js +++ b/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/TRTCCalling/utils/event.js @@ -59,4 +59,4 @@ class EventEmitter { } } -module.exports = EventEmitter +export default EventEmitter diff --git a/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/TUICalling.js b/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/TUICalling.js index 9ce35ef0b8..9db56c3381 100644 --- a/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/TUICalling.js +++ b/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/TUICalling.js @@ -1,13 +1,11 @@ import TRTCCalling from './TRTCCalling/TRTCCalling.js'; - const TAG_NAME = 'TUICalling'; // 组件旨在跨终端维护一个通话状态管理机,以事件发布机制驱动上层进行管理,并通过API调用进行状态变更。 // 组件设计思路将UI和状态管理分离。您可以通过修改`component`文件夹下的文件,适配您的业务场景, // 在UI展示上,您可以通过属性的方式,将上层的用户头像,名称等数据传入组件内部,`static`下的icon和默认头像图片, // 只是为了展示基础的效果,您需要根据业务场景进行修改。 -// eslint-disable-next-line no-undef Component({ properties: { config: { @@ -37,8 +35,10 @@ Component({ remoteUsers: [], // 远程用户资料 screen: 'pusher', // 视屏通话中,显示大屏幕的流(只限1v1聊天 soundMode: 'speaker', // 声音模式 听筒/扬声器 + userList: null, //接受邀请的用户信息 }, + methods: { initCall() { // 收起键盘 @@ -62,6 +62,7 @@ Component({ console.log(`${TAG_NAME}, handleUserAccept, event${JSON.stringify(event)}`); this.setData({ callStatus: 'connection', + userList: event.data.userList, }); }, @@ -109,6 +110,9 @@ Component({ // 用户拒绝 handleInviteeReject(event) { console.log(`${TAG_NAME}, handleInviteeReject, event${JSON.stringify(event)}`); + if (this.data.playerList.length===0) { + this.reset(); + } wx.showToast({ title: `${this.handleCallingUser([event.data.invitee])}已拒绝`, }); @@ -116,6 +120,9 @@ Component({ // 用户不在线 handleNoResponse(event) { console.log(`${TAG_NAME}, handleNoResponse, event${JSON.stringify(event)}`); + if (this.data.playerList.length===0) { + this.reset(); + } wx.showToast({ title: `${this.handleCallingUser(event.data.timeoutUserList)}不在线`, }); @@ -123,6 +130,9 @@ Component({ // 用户忙线 handleLineBusy(event) { console.log(`${TAG_NAME}, handleLineBusy, event${JSON.stringify(event)}`); + if (this.data.playerList.length===0) { + this.reset(); + } wx.showToast({ title: `${this.handleCallingUser([event.data.invitee])}忙线中`, }); @@ -130,6 +140,9 @@ Component({ // 用户取消 handleCallingCancel(event) { console.log(`${TAG_NAME}, handleCallingCancel, event${JSON.stringify(event)}`); + if (this.data.playerList.length===0) { + this.reset(); + } wx.showToast({ title: `${this.handleCallingUser([event.data.invitee])}取消通话`, }); @@ -137,6 +150,9 @@ Component({ // 通话超时未应答 handleCallingTimeout(event) { console.log(`${TAG_NAME}, handleCallingTimeout, event${JSON.stringify(event)}`); + if (this.data.playerList.length===0) { + this.reset(); + } wx.showToast({ title: `${this.handleCallingUser(event.data.timeoutUserList)}超时无应答`, }); @@ -183,6 +199,7 @@ Component({ // 切换通话模式 handleCallMode(event) { this.data.config.type = event.data.type; + this.toggleSoundMode(); this.setData({ config: this.data.config, }); @@ -261,6 +278,10 @@ Component({ */ async call(params) { this.initCall(); + if (this.data.callStatus !== 'idle') { + console.warn(`${TAG_NAME}, call callStatus isn't idle`); + return; + } wx.$TRTCCalling.call({ userID: params.userID, type: params.type }).then((res) => { this.data.config.type = params.type; this.getUserProfile([params.userID]); @@ -285,6 +306,10 @@ Component({ */ async groupCall(params) { this.initCall(); + if (this.data.callStatus !== 'idle') { + console.warn(`${TAG_NAME}, groupCall callStatus isn't idle`); + return; + } wx.$TRTCCalling.groupCall({ userIDList: params.userIDList, type: params.type, groupID: params.groupID }).then((res) => { this.data.config.type = params.type; this.getUserProfile(params.userIDList); @@ -301,6 +326,7 @@ Component({ */ async accept() { wx.$TRTCCalling.accept().then((res) => { + console.log('accept', res); this.setData({ pusher: res.pusher, callStatus: 'connection', @@ -348,6 +374,7 @@ Component({ this.setData({ callStatus: 'idle', isSponsor: false, + soundMode: 'speaker', pusher: {}, // TRTC 本地流 playerList: [], // TRTC 远端流 }); @@ -371,6 +398,7 @@ Component({ case 'switchAudioCall': wx.$TRTCCalling.switchAudioCall().then((res) => { this.data.config.type = wx.$TRTCCalling.CALL_TYPE.AUDIO; + this.toggleSoundMode(); this.setData({ config: this.data.config, }); @@ -426,7 +454,8 @@ Component({ break; case 'switchAudioCall': wx.$TRTCCalling.switchAudioCall().then((res) => { - this.data.config.type = 1; + this.data.config.type = wx.$TRTCCalling.CALL_TYPE.AUDIO; + this.toggleSoundMode(); this.setData({ config: this.data.config, }); @@ -453,12 +482,12 @@ Component({ }, // 初始化TRTCCalling async init() { + this._addTSignalingEvent(); try { const res = await wx.$TRTCCalling.login({ userID: this.data.config.userID, userSig: this.data.config.userSig, }); - this._addTSignalingEvent(); return res; } catch (error) { throw new Error('TRTCCalling login failure', error); @@ -488,7 +517,7 @@ Component({ if (!wx.$TRTCCalling) { wx.$TRTCCalling = new TRTCCalling({ sdkAppID: this.data.config.sdkAppID, - tim: this.data.config.tim, + tim: wx.$tim, }); } wx.$TRTCCalling.initData(); diff --git a/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/TUICalling.wxml b/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/TUICalling.wxml index 8fd46f33f7..5141631870 100644 --- a/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/TUICalling.wxml +++ b/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/TUICalling.wxml @@ -8,9 +8,10 @@ remoteUsers="{{remoteUsers}}" bind:callingEvent="handleCallingEvent" > - - \ No newline at end of file + diff --git a/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/component/calling/calling.js b/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/component/calling/calling.js index 035c2fcfbd..e6dcfaa148 100644 --- a/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/component/calling/calling.js +++ b/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/component/calling/calling.js @@ -1,5 +1,4 @@ // components/tui-calling/TUICalling/component/calling.js -// eslint-disable-next-line no-undef Component({ /** * 组件的属性列表 @@ -27,6 +26,25 @@ Component({ }, + /** + * 生命周期方法 + */ + lifetimes: { + created() { + + }, + attached() { + }, + ready() { + wx.createLivePusherContext().startPreview() + }, + detached() { + wx.createLivePusherContext().stopPreview() + }, + error() { + }, + }, + /** * 组件的方法列表 */ diff --git a/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/component/calling/calling.wxml b/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/component/calling/calling.wxml index e733d944f0..847748c88a 100644 --- a/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/component/calling/calling.wxml +++ b/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/component/calling/calling.wxml @@ -1,47 +1,57 @@ - + - - - - + + - - 邀请你视频通话 - 等待对方接受 + + 邀请你视频通话 + 等待对方接受 - + - - - + + + - - 邀请你视频通话 - 等待对方接受 + + 邀请你视频通话 + 等待对方接受 - 切换到语音通话 + 切到语音通话 - - - + + + + + + + + 挂断 + - + @@ -49,52 +59,55 @@ 挂断 - - + + 接听 - + - - - {{remoteUsers[0].nick || remoteUsers[0].userID}} - {{'等待对方接受'}} + + + {{remoteUsers[0].nick || remoteUsers[0].userID}} + {{'等待对方接受'}} - - - + + + - - 邀请你视频通话 - 等待对方接受 + + 邀请你视频通话 + 等待对方接受 - - - + + + + + 挂断 - - + + + + + 接听 - - + + + + + 挂断 - \ No newline at end of file + diff --git a/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/component/calling/calling.wxss b/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/component/calling/calling.wxss index 1474a46975..9f30af3ae9 100644 --- a/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/component/calling/calling.wxss +++ b/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/component/calling/calling.wxss @@ -7,26 +7,36 @@ justify-content: center; align-items: center; } +.button-container { + display: flex; + flex-direction: column; + text-align: center; +} .btn-operate { display: flex; justify-content: space-between; + /* flex-direction: column; + text-align: center; */ + } .btn-operate-item{ display: flex; flex-direction: column; align-items: center; + margin-bottom: 20px; } .btn-operate-item text { - padding: 8px 0; - font-size: 18px; - color: #FFFFFF; + font-size: 14px; + color: #f0e9e9; + padding: 5px; letter-spacing: 0; font-weight: 400; } .call-switch text{ - padding: 0; + padding: 5px; + color: #f0e9e9; font-size: 14px; } @@ -42,13 +52,12 @@ } .call-switch .call-operate { width: 4vh; - height: 4vh; - padding: 2vh 0 4vh; + height: 3vh; } .call-operate image { - width: 4vh; - height: 4vh; + width: 100%; + height: 100%; background: none; } @@ -96,9 +105,18 @@ .invite-calling-header { margin-top:107px; display: flex; - justify-content: space-between; + justify-content: flex-end; padding: 0 16px; - + +} +.btn-container { + display: flex; + align-items: center; + position: relative; +} +.invite-calling-header-left { + position: absolute; + right: 0; } .invite-calling-header-left image { width: 32px; @@ -126,6 +144,7 @@ .invite-calling .btn-operate{ display: flex; justify-content: center; + align-items: center; } @@ -220,4 +239,4 @@ .avatar { background: #dddddd; -} \ No newline at end of file +} diff --git a/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/component/connected/connected.js b/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/component/connected/connected.js index 875cfe2a4a..feb6a09b03 100644 --- a/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/component/connected/connected.js +++ b/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/component/connected/connected.js @@ -1,4 +1,3 @@ -// eslint-disable-next-line no-undef Component({ /** * 组件的属性列表 @@ -19,6 +18,9 @@ Component({ screen: { type: String, }, + userList: { + type: Object, + }, }, /** @@ -124,21 +126,20 @@ Component({ this.triggerEvent('connectedEvent', data); }, handleConnectErrorImage(e) { - const { value, flag } = e.target.dataset; + const { flag, key, index } = e.target.dataset; if (flag === 'pusher') { this.data.pusher.avatar = '../../static/default_avatar.png'; this.setData({ pusher: this.data.pusher, }); } else { - const playerList = this.data.playerList.map((item) => { - if (item.userID === value) { - item.avatar = '../../static/default_avatar.png'; - } - return item; - }); + this.data[key][index].avatar = '../../static/default_avatar.png'; + if(this.data.playerList[index]) { + this.data.playerList[index].avatar = '../../static/default_avatar.png'; + } this.setData({ - playerList, + playerList: this.data.playerList, + [key]: this.data[key] }); } }, diff --git a/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/component/connected/connected.wxml b/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/component/connected/connected.wxml index 86ecda05c9..d97199bb91 100644 --- a/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/component/connected/connected.wxml +++ b/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/component/connected/connected.wxml @@ -1,116 +1,118 @@ - - + + - + {{pusher.nick || pusher.userID}}(自己) - - + + {{item.nick || item.userID}} - - - + + + {{pusher.chatTime}} + + + + + 切到语音通话 + - - + + + + + + 麦克风 - - + + + + + + 挂断 - - + + + + + + 扬声器 - - + + + + + + + 摄像头 - + - - + + + + + + + 挂断 - + diff --git a/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/component/connected/connected.wxss b/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/component/connected/connected.wxss index 348110fa59..d7f0ee2c23 100644 --- a/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/component/connected/connected.wxss +++ b/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/component/connected/connected.wxss @@ -6,83 +6,97 @@ height: 178px; padding: 16px; z-index: 3; - } - .pusher-video { +} + +.pusher-video { position: absolute; width: 100%; height: 100%; /* background-color: #f75c45; */ z-index: 1; - } - .stream-box { +} + +.stream-box { position: relative; float: left; width: 50vw; height: 260px; /* background-color: #f75c45; */ z-index: 3; - } - .handle-btns { +} + +.handle-btns { position: absolute; bottom: 44px; width: 100vw; z-index: 3; display: flex; flex-direction: column; - } - .handle-btns .btn-list { +} + +.handle-btns .btn-list { display: flex; flex-direction: row; justify-content: space-around; align-items: center; - } - - .btn-normal { +} + +.button-container { + display: flex; + flex-direction: column; + text-align: center; +} + +.btn-normal { width: 8vh; height: 8vh; box-sizing: border-box; display: flex; + flex-direction: column; /* background: white; */ justify-content: center; align-items: center; border-radius: 50%; - } - .btn-image{ - width: 8vh; - height: 8vh; +} + +.btn-image { + width: 100%; + height: 100%; background: none; - } - .btn-hangup { +} + +.btn-hangup { width: 8vh; height: 8vh; - background: #f75c45; + /*background: #f75c45;*/ box-sizing: border-box; display: flex; justify-content: center; align-items: center; border-radius: 50%; - } - .btn-hangup>.btn-image { - width: 4vh; - height: 4vh; +} + +.btn-hangup > .btn-image { + width: 100%; + height: 100%; background: none; - } - - .TRTCCalling-call-audio { +} + +.TRTCCalling-call-audio { width: 100%; height: 100%; - } +} - .btn-footer { +.btn-footer { position: relative; - } - - .btn-footer .multi-camera { +} + +.btn-footer .multi-camera { width: 32px; height: 32px; - } - - .btn-footer .camera { +} + +.btn-footer .camera { width: 64px; height: 64px; position: fixed; @@ -91,96 +105,149 @@ display: flex; justify-content: center; align-items: center; - background: rgba(#ffffff, 0.7); - } - .btn-footer .camera .camera-image { + background: rgba(255, 255, 255, 0.7); +} + +.btn-footer .camera .camera-image { width: 32px; height: 32px; - } - +} + .TUICalling-connected-layout { - width: 100%; - height: 100%; + width: 100%; + height: 100%; } -.audio{ - padding-top: 15vh; - background: #ffffff; + +.audio { + padding-top: 15vh; + background: #ffffff; } .pusher-audio { - width: 0; - height: 0; + width: 0; + height: 0; } -.player-audio{ - width: 0; - height: 0; +.player-audio { + width: 0; + height: 0; } .live { - width: 100%; - height: 100%; + width: 100%; + height: 100%; } .other-view { - display: flex; - flex-direction: column; - align-items: center; - font-size: 18px; - letter-spacing: 0; - font-weight: 400; - padding: 16px; + display: flex; + flex-direction: column; + align-items: center; + font-size: 18px; + letter-spacing: 0; + font-weight: 400; + padding: 16px; } .white { - color: #FFFFFF; - padding: 5px; + color: #f0e9e9; + padding: 5px; + font-size: 14px; } .black { - color: #000000; - padding: 5px; + color: #000000; + padding: 5px; } .TRTCCalling-call-audio-box { - display: flex; - flex-wrap: wrap; - justify-content: center; + display: flex; + flex-wrap: wrap; + justify-content: center; } + .mutil-img { - justify-content: flex-start !important; + justify-content: flex-start !important; } .TRTCCalling-call-audio-img { - display: flex; - flex-direction: column; - align-items: center; + display: flex; + flex-direction: column; + align-items: center; } -.TRTCCalling-call-audio-img>image { - width: 25vw; - height: 25vw; - margin: 0 4vw; - border-radius: 4vw; - position: relative; + +.TRTCCalling-call-audio-img > image { + width: 25vw; + height: 25vw; + margin: 0 4vw; + border-radius: 4vw; + position: relative; } -.TRTCCalling-call-audio-img text{ - font-size: 20px; - color: #333333; - letter-spacing: 0; - font-weight: 500; + +.TRTCCalling-call-audio-img text { + font-size: 20px; + color: #333333; + letter-spacing: 0; + font-weight: 500; } .btn-list-item { - flex: 1; - display: flex; - justify-content: center; - padding: 16px 0; + flex: 1; + display: flex; + justify-content: center; + padding: 16px 0; } .btn-image-small { - transform: scale(.7); + transform: scale(.7); } .avatar { - background: #dddddd; -} \ No newline at end of file + background: #dddddd; +} + +.btn-container { + display: flex; + align-items: center; + position: relative; +} + +.invite-calling-header-left { + position: absolute; + right: -88px; +} + +.invite-calling-header-left image { + width: 32px; + height: 32px; +} + +.call-switch .call-operate { + width: 4vh; + height: 3vh; +} + +.call-operate image { + width: 100%; + height: 100%; + background: none; +} + +.call-switch text { + padding: 0; + font-size: 14px; +} + +.btn-operate-item { + display: flex; + flex-direction: column; + align-items: center; +} + +.btn-operate-item text { + padding: 8px 0; + font-size: 18px; + color: #FFFFFF; + letter-spacing: 0; + font-weight: 400; + font-size: 14px; +} diff --git a/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/static/audio-false.png b/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/static/audio-false.png index e962fa9795..f0b99788c7 100644 Binary files a/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/static/audio-false.png and b/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/static/audio-false.png differ diff --git a/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/static/audio-true.png b/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/static/audio-true.png index 909520009d..8a13b6d9c3 100644 Binary files a/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/static/audio-true.png and b/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/static/audio-true.png differ diff --git a/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/static/camera-false.png b/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/static/camera-false.png index 4889104554..2093ad2040 100644 Binary files a/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/static/camera-false.png and b/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/static/camera-false.png differ diff --git a/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/static/camera-true.png b/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/static/camera-true.png index 8502a30fe0..c4c00b0605 100644 Binary files a/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/static/camera-true.png and b/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/static/camera-true.png differ diff --git a/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/static/dialing.png b/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/static/dialing.png new file mode 100644 index 0000000000..c762da9cec Binary files /dev/null and b/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/static/dialing.png differ diff --git a/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/static/hangup.png b/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/static/hangup.png index c548495448..24341516ff 100644 Binary files a/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/static/hangup.png and b/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/static/hangup.png differ diff --git a/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/static/speaker-false.png b/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/static/speaker-false.png index 0357745f01..4042495ae8 100644 Binary files a/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/static/speaker-false.png and b/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/static/speaker-false.png differ diff --git a/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/static/speaker-true.png b/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/static/speaker-true.png index 40b728e3ac..5ec86cab71 100644 Binary files a/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/static/speaker-true.png and b/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/static/speaker-true.png differ diff --git a/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/static/switch_camera.png b/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/static/switch_camera.png new file mode 100644 index 0000000000..6159919670 Binary files /dev/null and b/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/static/switch_camera.png differ diff --git a/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/static/trans.png b/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/static/trans.png index 8c77517bf0..1bbcea7d43 100644 Binary files a/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/static/trans.png and b/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/components/TUICalling/static/trans.png differ diff --git a/MiniProgram/TUIKit/miniprogram/components/TUICalling/TRTCCalling/TRTCCalling.js b/MiniProgram/TUIKit/miniprogram/components/TUICalling/TRTCCalling/TRTCCalling.js index cafb5a36f9..3c3f3ed9ff 100644 --- a/MiniProgram/TUIKit/miniprogram/components/TUICalling/TRTCCalling/TRTCCalling.js +++ b/MiniProgram/TUIKit/miniprogram/components/TUICalling/TRTCCalling/TRTCCalling.js @@ -1,9 +1,7 @@ import EventEmitter from './utils/event.js'; import { EVENT, CALL_STATUS, MODE_TYPE, CALL_TYPE } from './common/constants.js'; import formateTime from './utils/formate-time'; -import TSignaling from './node_module/tsignaling-wx'; -import TRTC from './node_module/trtc-wx'; -import TIM from './node_module/tim-wx-sdk'; +import { TSignaling, TRTC, TIM } from './libSrcConfig' import TSignalingClient from './TSignalingClient'; import TRTCCallingDelegate from './TRTCCallingDelegate'; import TRTCCallingInfo from './TRTCCallingInfo'; @@ -27,7 +25,8 @@ class TRTCCalling { this.EVENT = EVENT; this.CALL_TYPE = CALL_TYPE; this._emitter = new EventEmitter(); - this.TRTC = new TRTC(); + this.TRTC = new TRTC(this, { TUIScene: 'TUICalling' }); + wx.TUIScene = 'TUICalling'; if (params.tim) { this.tim = params.tim; } else { @@ -35,6 +34,7 @@ class TRTCCalling { SDKAppID: params.sdkAppID, }); } + if (!wx.$TSignaling) { wx.$TSignaling = new TSignaling({ SDKAppID: params.sdkAppID, tim: this.tim }); } @@ -48,7 +48,8 @@ class TRTCCalling { callStatus: CALL_STATUS.IDLE, // 用户当前的通话状态 soundMode: 'speaker', // 声音模式 听筒/扬声器 active: false, - invitation: { // 接收到的邀请 + invitation: { + // 接收到的邀请 inviteID: '', inviter: '', type: '', @@ -71,6 +72,8 @@ class TRTCCalling { _isGroupCall: false, // 当前通话是否是群通话 _groupID: '', // 群组ID _switchCallModeStatus: true, // 是否可以进行模式切换 + enterRoomStatus: false, // 进入房间状态 + isCallEnd: true, // 通话是否为正常通话结束, true:正常通话结束,false:非正常通话结束 如:cancel、timeout、noResp }; this.data = { ...this.data, ...data }; } @@ -101,9 +104,11 @@ class TRTCCalling { const enableCamera = callType !== CALL_TYPE.VIDEO; this.setPusherAttributesHandler({ enableCamera }); if (enableCamera) { - this.data.invitation.type = this.data.config.type = CALL_TYPE.VIDEO; + this.data.config.type = CALL_TYPE.VIDEO; + this.data.invitation.type = CALL_TYPE.VIDEO; } else { - this.data.invitation.type = this.data.config.type = CALL_TYPE.AUDIO; + this.data.config.type = CALL_TYPE.AUDIO; + this.data.invitation.type = CALL_TYPE.AUDIO; } this.TRTCCallingDelegate.onCallMode({ type: this.data.config.type, message: callModeMessage.data.message }); this.setSwitchCallModeStatus(true); @@ -111,22 +116,40 @@ class TRTCCalling { // 判断是否为音视频切换 judgeSwitchCallMode(inviteData) { - const isSwitchCallMode = (inviteData.switch_to_audio_call - && inviteData.switch_to_audio_call === 'switch_to_audio_call') - || inviteData.data && inviteData.data.cmd === 'switchToAudio' - || inviteData.data && inviteData.data.cmd === 'switchToVideo'; + const isSwitchCallMode = + (inviteData.switch_to_audio_call && inviteData.switch_to_audio_call === 'switch_to_audio_call') || + (inviteData.data && inviteData.data.cmd === 'switchToAudio') || + (inviteData.data && inviteData.data.cmd === 'switchToVideo'); return isSwitchCallMode; } // 新的邀请回调事件 handleNewInvitationReceived(event) { - console.log(TAG_NAME, 'onNewInvitationReceived', `callStatus:${this.data.callStatus === CALL_STATUS.CALLING || this.data.callStatus === CALL_STATUS.CONNECTED}, inviteID:${event.data.inviteID} inviter:${event.data.inviter} inviteeList:${event.data.inviteeList} data:${event.data.data}`); - const { data: { inviter, inviteeList, data, inviteID, groupID } } = event; + console.log( + TAG_NAME, + 'onNewInvitationReceived', + `callStatus:${ + this.data.callStatus === CALL_STATUS.CALLING || this.data.callStatus === CALL_STATUS.CONNECTED + }, inviteID:${event.data.inviteID} inviter:${event.data.inviter} inviteeList:${event.data.inviteeList} data:${ + event.data.data + }`, + ); + const { + data: { inviter, inviteeList, data, inviteID, groupID }, + } = event; const inviteData = JSON.parse(data); // 此处判断inviteeList.length 大于2,用于在非群组下多人通话判断 // userIDs 为同步 native 在使用无 groupID 群聊时的判断依据 - const isGroupCall = !!(groupID || inviteeList.length >= 2 || inviteData.data && inviteData.data.userIDs && inviteData.data.userIDs.length >= 2); + const isGroupCall = !!( + groupID || + inviteeList.length >= 2 || + (inviteData.data && inviteData.data.userIDs && inviteData.data.userIDs.length >= 2) + ); + if (inviteData?.data?.cmd === 'hangup') { + this.TRTCCallingDelegate.onCallEnd(inviter, inviteData.call_end || 0); + return; + } let callEnd = false; // 此处逻辑用于通话结束时发出的invite信令 // 群通话已结束时,room_id 不存在或者 call_end 为 0 @@ -140,8 +163,8 @@ class TRTCCalling { // 判断新的信令是否为结束信令 if (callEnd) { // 群通话中收到最后挂断的邀请信令通知其他成员通话结束 - this.TRTCCallingDelegate.onCallEnd({ userID: inviter, callEnd: isGroupCall ? 0 : inviteData.call_end }); - this._reset(); + // this.TRTCCallingDelegate.onCallEnd({ userID: inviter, callEnd: isGroupCall ? 0 : inviteData.call_end }); + this._reset(isGroupCall ? 0 : inviteData.call_end); return; } @@ -193,6 +216,10 @@ class TRTCCalling { callEnd: 0, }, }; + this.setPusherAttributesHandler({ + enableCamera: this.data.config.type === CALL_TYPE.VIDEO + }) + wx.createLivePusherContext().startPreview(); this.TRTCCallingDelegate.onInvited(newReceiveData); } @@ -203,12 +230,15 @@ class TRTCCalling { return; } const list = [...this.data.groupInviteID]; - this.data.groupInviteID = list.filter(item => item !== inviteID); + this.data.groupInviteID = list.filter((item) => item !== inviteID); } // 发出的邀请收到接受的回调 - handleInviteeAccepted(event) { - console.log(`${TAG_NAME} INVITEE_ACCEPTED inviteID:${event.data.inviteID} invitee:${event.data.invitee} data:`, event.data); + async handleInviteeAccepted(event) { + console.log( + `${TAG_NAME} INVITEE_ACCEPTED inviteID:${event.data.inviteID} invitee:${event.data.invitee} data:`, + event.data, + ); const inviteData = JSON.parse(event.data.data); // 防止取消后,接收到远端接受信令 if (this.data.callStatus === CALL_STATUS.IDLE) { @@ -223,7 +253,10 @@ class TRTCCalling { // 发起人进入通话状态从此处判断 if (event.data.inviter === this._getUserID() && this.data.callStatus === CALL_STATUS.CALLING) { this._setCallStatus(CALL_STATUS.CONNECTED); - this.TRTCCallingDelegate.onUserAccept(event.data.invitee); + this.TRTCCallingDelegate.onUserAccept( + event.data.invitee, + await this.getUserProfile(this.data._unHandledInviteeList.map(item => ({userID: item}))), + ); } this.setInviteIDList(event.data.inviteID); if (this._getGroupCallFlag()) { @@ -234,7 +267,9 @@ class TRTCCalling { // 发出的邀请收到拒绝的回调 handleInviteeRejected(event) { - console.log(`${TAG_NAME} INVITEE_REJECTED inviteID:${event.data.inviteID} invitee:${event.data.invitee} data:${event.data.data}`); + console.log( + `${TAG_NAME} INVITEE_REJECTED inviteID:${event.data.inviteID} invitee:${event.data.invitee} data:${event.data.data}`, + ); // 防止切换音视频对方不可用时,返回数据流向onLineBusy或onReject if (!this.data._isGroupCall && !this.data._switchCallModeStatus) { console.log(`${TAG_NAME}.onInviteeRejected - Audio and video switching is not available`); @@ -246,7 +281,7 @@ class TRTCCalling { } // 判断被呼叫方已经接入,后续拒绝不影响正常通话 if (this.data.callStatus === CALL_STATUS.CONNECTED) { - const userInPlayerListFlag = this.data.playerList.some(item => (item.userID === event.data.invitee)); + const userInPlayerListFlag = this.data.playerList.some((item) => item.userID === event.data.invitee); if (userInPlayerListFlag) { return; } @@ -271,13 +306,13 @@ class TRTCCalling { // 2、已经接受邀请,远端没有用户,发出结束通话事件 const isPlayer = this.data.callStatus === CALL_STATUS.CONNECTED && this.data.playerList.length === 0; if (isCalling || isPlayer) { - this.TRTCCallingDelegate.onCallEnd({ userID: this.data.config.userID, callEnd: 0 }); + // this.TRTCCallingDelegate.onCallEnd({ userID: this.data.config.userID, callEnd: 0 }); this._reset(); } } }); } else { - this.TRTCCallingDelegate.onCallEnd({ userID: this.data.config.userID, callEnd: 0 }); + // this.TRTCCallingDelegate.onCallEnd({ userID: this.data.config.userID, callEnd: 0 }); this._reset(); } } @@ -289,17 +324,26 @@ class TRTCCalling { this._reset(); return; } - console.log(TAG_NAME, 'onInvitationCancelled', `inviteID:${event.data.inviteID} inviter:${event.data.invitee} data:${event.data.data}`); + console.log( + TAG_NAME, + 'onInvitationCancelled', + `inviteID:${event.data.inviteID} inviter:${event.data.invitee} data:${event.data.data}`, + ); this._setCallStatus(CALL_STATUS.IDLE); this.TRTCCallingDelegate.onCancel({ inviteID: event.data.inviteID, invitee: event.data.invitee }); - this.TRTCCallingDelegate.onCallEnd({ userID: this.data.config.userID, callEnd: 0 }); + this.data.isCallEnd = false; + // this.TRTCCallingDelegate.onCallEnd({ userID: this.data.config.userID, callEnd: 0 }); this.setInviteIDList(event.data.inviteID); this._reset(); } // 收到的邀请收到该邀请超时的回调 handleInvitationTimeout(event) { - console.log(TAG_NAME, 'onInvitationTimeout', `data:${JSON.stringify(event)} inviteID:${event.data.inviteID} inviteeList:${event.data.inviteeList}`); + console.log( + TAG_NAME, + 'onInvitationTimeout', + `data:${JSON.stringify(event)} inviteID:${event.data.inviteID} inviteeList:${event.data.inviteeList}`, + ); const { groupID = '', inviteID, inviter, inviteeList, isSelfTimeout } = event.data; // 防止用户已挂断,但接收到超时事件后的,抛出二次超时事件 if (this.data.callStatus === CALL_STATUS.IDLE) { @@ -317,7 +361,8 @@ class TRTCCalling { }); // 若在呼叫中,且全部用户都无应答 if (this.data.callStatus !== CALL_STATUS.CONNECTED) { - this.TRTCCallingDelegate.onCallEnd({ userID: inviter, callEnd: 0 }); + // this.TRTCCallingDelegate.onCallEnd({ userID: inviter, callEnd: 0 }); + this.data.isCallEnd = false; this._reset(); } return; @@ -351,12 +396,14 @@ class TRTCCalling { }); return; } - this.TRTCCallingDelegate.onCallEnd({ userID: inviter, callEnd: 0 }); + this.data.isCallEnd = false; + // this.TRTCCallingDelegate.onCallEnd({ userID: inviter, callEnd: 0 }); this._reset(); } } else { // 1v1通话被邀请方超时 - this.TRTCCallingDelegate.onCallEnd({ userID: inviter, callEnd: 0 }); + // this.TRTCCallingDelegate.onCallEnd({ userID: inviter, callEnd: 0 }); + this.data.isCallEnd = false; this._reset(); } // 用inviteeList进行判断,是为了兼容多人通话 @@ -368,13 +415,16 @@ class TRTCCalling { // SDK Ready 回调 handleSDKReady() { console.log(TAG_NAME, 'TSignaling SDK ready'); + this.TSignalingResolve(); this.TRTCCallingDelegate.onSdkReady({ message: 'SDK ready' }); const promise = this.tim.getMyProfile(); - promise.then((imResponse) => { - this.data.localUser = imResponse.data; - }).catch((imError) => { - console.warn('getMyProfile error:', imError); // 获取个人资料失败的相关信息 - }); + promise + .then((imResponse) => { + this.data.localUser = imResponse.data; + }) + .catch((imError) => { + console.warn('getMyProfile error:', imError); // 获取个人资料失败的相关信息 + }); } // 被踢下线 @@ -404,19 +454,19 @@ class TRTCCalling { // 取消 tsignaling 事件监听 _removeTSignalingEvent() { // 新的邀请回调事件 - wx.$TSignaling.off(TSignaling.EVENT.NEW_INVITATION_RECEIVED); + wx.$TSignaling.off(TSignaling.EVENT.NEW_INVITATION_RECEIVED, this.handleNewInvitationReceived); // 发出的邀请收到接受的回调 - wx.$TSignaling.off(TSignaling.EVENT.INVITEE_ACCEPTED); + wx.$TSignaling.off(TSignaling.EVENT.INVITEE_ACCEPTED, this.handleInviteeAccepted); // 发出的邀请收到拒绝的回调 - wx.$TSignaling.off(TSignaling.EVENT.INVITEE_REJECTED); + wx.$TSignaling.off(TSignaling.EVENT.INVITEE_REJECTED, this.handleInviteeRejected); // 收到的邀请收到该邀请取消的回调 - wx.$TSignaling.off(TSignaling.EVENT.INVITATION_CANCELLED); + wx.$TSignaling.off(TSignaling.EVENT.INVITATION_CANCELLED, this.handleInvitationCancelled); // 收到的邀请收到该邀请超时的回调 - wx.$TSignaling.off(TSignaling.EVENT.INVITATION_TIMEOUT); + wx.$TSignaling.off(TSignaling.EVENT.INVITATION_TIMEOUT, this.handleInvitationTimeout); // SDK Ready 回调 - wx.$TSignaling.off(TSignaling.EVENT.SDK_READY); + wx.$TSignaling.off(TSignaling.EVENT.SDK_READY, this.handleSDKReady); // 被踢下线 - wx.$TSignaling.off(TSignaling.EVENT.KICKED_OUT); + wx.$TSignaling.off(TSignaling.EVENT.KICKED_OUT, this.handleKickedOut); } // 远端用户加入此房间 @@ -440,7 +490,7 @@ class TRTCCalling { console.log(TAG_NAME, 'REMOTE_USER_LEAVE', event, event.data.userID); if (userID) { // this.data.playerList = await this.getUserProfile(playerList) - this.data.playerList = this.data.playerList.filter(item => item.userID !== userID); + this.data.playerList = this.data.playerList.filter((item) => item.userID !== userID); // 群组或多人通话模式下,有用户离开时,远端还有用户,则只下发用户离开事件 if (playerList.length > 0) { this.TRTCCallingDelegate.onUserLeave({ userID, playerList: this.data.playerList }); @@ -594,6 +644,7 @@ class TRTCCalling { // 进入房间 enterRoom(options) { + this._addTRTCEvent(); const { roomID } = options; const config = Object.assign(this.data.config, { roomID, @@ -606,17 +657,25 @@ class TRTCCalling { if (this.data._unHandledInviteeList.length > 0) { this._setUnHandledInviteeList(this.data.config.userID); } + this.data.enterRoomStatus = true; this.data.pusher = this.TRTC.enterRoom(config); this.TRTC.getPusherInstance().start(); // 开始推流 } // 退出房间 - exitRoom() { + exitRoom(callEnd) { + this.TRTC.getPusherInstance().stop(); // 停止推流 const result = this.TRTC.exitRoom(); + if (this.data.isCallEnd) { + this.TRTCCallingDelegate.onCallEnd({ userID: this.data.config.userID, callEnd: callEnd || 0 }); + } this.data.pusher = result.pusher; this.data.playerList = result.playerList; this.data._unHandledInviteeList = []; + this.data.enterRoomStatus = false; + this.data.isCallEnd = true; this.initTRTC(); + this._removeTRTCEvent(); } // 设置 pusher 属性 @@ -630,7 +689,8 @@ class TRTCCalling { const playerList = this.TRTC.setPlayerAttributes(player.streamID, options); console.warn('setPlayerAttributesHandler', playerList); // this.data.playerList = await this.getUserProfile(playerList) - this.data.playerList = playerList.length > 0 ? this._updateUserProfile(this.data.playerList, playerList) : this.data.playerList; + this.data.playerList = + playerList.length > 0 ? this._updateUserProfile(this.data.playerList, playerList) : this.data.playerList; this.TRTCCallingDelegate.onUserUpdate({ pusher: this.data.pusher, playerList: this.data.playerList }); } @@ -688,16 +748,21 @@ class TRTCCalling { wx.$TSignaling.setLogLevel(0); this.data.config.userID = data.userID; this.data.config.userSig = data.userSig; - return wx.$TSignaling.login({ - userID: data.userID, - userSig: data.userSig, - }).then((res) => { - console.log(TAG_NAME, 'login', 'IM login success', res); - this._reset(); - this._addTSignalingEvent(); - this._addTRTCEvent(); - this.initTRTC(); - }); + return new Promise((resolve, reject) => { + wx.$TSignaling + .login({ + userID: data.userID, + userSig: data.userSig, + }) + .then((res) => { + console.log(TAG_NAME, 'login', 'IM login success', res); + this._reset(); + this._addTSignalingEvent(); + this.initTRTC(); + this.TSignalingResolve = resolve + return null; + }); + }) } /** @@ -712,15 +777,17 @@ class TRTCCalling { } } this._reset(); - wx.$TSignaling.logout({ - userID: this.data.config.userID, - userSig: this.data.config.userSig, - }).then((res) => { - console.log(TAG_NAME, 'logout', 'IM logout success'); - this._removeTSignalingEvent(); - this._removeTRTCEvent(); - return res; - }) + wx.$TSignaling + .logout({ + userID: this.data.config.userID, + userSig: this.data.config.userSig, + }) + .then((res) => { + console.log(TAG_NAME, 'logout', 'IM logout success'); + this._removeTSignalingEvent(); + this._removeTRTCEvent(); + return res; + }) .catch((err) => { console.error(TAG_NAME, 'logout', 'IM logout failure'); throw new Error(err); @@ -756,9 +823,9 @@ class TRTCCalling { */ async call(params) { const { userID, type } = params; - // 生成房间号,拼接URL地址 TRTC-wx roomID 超出取值范围1~4294967295 - const roomID = Math.floor(Math.random() * 4294967294 + 1); // 随机生成房间号 - this.enterRoom({ roomID, callType: type }); + // 生成房间号,拼接URL地址 TRTC-wx roomID 超出取值范围1~2147483647 + const roomID = Math.floor(Math.random() * 2147483646 + 1); // 随机生成房间号 + this.enterRoom({ roomID, callType: type });                                                  try { const res = await this.TSignalingClient.invite({ roomID, ...params }); console.log(`${TAG_NAME} call(userID: ${userID}, type: ${type}) success, ${res}`); @@ -791,8 +858,8 @@ class TRTCCalling { */ async groupCall(params) { const { type } = params; - // 生成房间号,拼接URL地址 TRTC-wx roomID 超出取值范围1~4294967295 - const roomID = this.data.roomID || Math.floor(Math.random() * 4294967294 + 1); // 随机生成房间号 + // 生成房间号,拼接URL地址 TRTC-wx roomID 超出取值范围1~2147483647 + const roomID = this.data.roomID || Math.floor(Math.random() * 2147483646 + 1); // 随机生成房间号 this.enterRoom({ roomID, callType: type }); try { let inviterInviteID = [...this.data.invitation.inviteID]; @@ -836,17 +903,33 @@ class TRTCCalling { * 当您作为被邀请方收到 {@link TRTCCallingDelegate#onInvited } 的回调时,可以调用该函数接听来电 */ async accept() { - // 拼接pusherURL进房 - console.log(TAG_NAME, 'accept() inviteID: ', this.data.invitation.inviteID); - if (this.data.callStatus === CALL_STATUS.IDLE) { - throw new Error('The call was cancelled'); - } - if (this.data.callStatus === CALL_STATUS.CALLING) { - this.enterRoom({ roomID: this.data.invitation.roomID, callType: this.data.config.type }); - // 被邀请人进入通话状态 - this._setCallStatus(CALL_STATUS.CONNECTED); - } + return new Promise((resolve,reject)=> { + // 拼接pusherURL进房 + console.log(TAG_NAME, 'accept() inviteID: ', this.data.invitation.inviteID); + if (this.data.callStatus === CALL_STATUS.IDLE) { + throw new Error('The call was cancelled'); + } + if (this.data.callStatus === CALL_STATUS.CALLING) { + if (this.data.config.type === CALL_TYPE.VIDEO) { + wx.createLivePusherContext().stopPreview({ + success: () => { + const timer = setTimeout(async ()=>{ + clearTimeout(timer); + this.handleAccept(resolve,reject); + }, 0) + } + }); + } else { + this.handleAccept(resolve,reject); + } + } + }) + } + async handleAccept(resolve, reject) { + this.enterRoom({ roomID: this.data.invitation.roomID, callType: this.data.config.type }); + // 被邀请人进入通话状态 + this._setCallStatus(CALL_STATUS.CONNECTED); const acceptRes = await this.TSignalingClient.accept({ inviteID: this.data.invitation.inviteID, type: this.data.config.type, @@ -856,13 +939,13 @@ class TRTCCalling { if (this._getGroupCallFlag()) { this._setUnHandledInviteeList(this._getUserID()); } - return { + return resolve({ message: acceptRes.data.message, pusher: this.data.pusher, - }; + }) } console.error(TAG_NAME, 'accept failed', acceptRes); - return acceptRes; + return reject(acceptRes); } /** @@ -902,9 +985,10 @@ class TRTCCalling { inviteIDList: cancelInvite, callType: this.data.invitation.type, }); - this.TRTCCallingDelegate.onCallEnd({ message: cancelRes[0].data.message }); + this.data.isCallEnd = true; + // this.TRTCCallingDelegate.onCallEnd({ message: cancelRes[0].data.message }); } - this.exitRoom(); + // this.exitRoom(); this._reset(); return cancelRes; } @@ -913,7 +997,7 @@ class TRTCCalling { async lastOneHangup(params) { const isGroup = this._getGroupCallFlag(); const res = await this.TSignalingClient.lastOneHangup({ isGroup, groupID: this.data._groupID, ...params }); - this.TRTCCallingDelegate.onCallEnd({ message: res.data.message }); + // this.TRTCCallingDelegate.onCallEnd({ message: res.data.message }); this._reset(); } @@ -926,7 +1010,7 @@ class TRTCCalling { _setUnHandledInviteeList(userID, callback) { // 使用callback防御列表更新时序问题 const list = [...this.data._unHandledInviteeList]; - const unHandleList = list.filter(item => item !== userID); + const unHandleList = list.filter((item) => item !== userID); this.data._unHandledInviteeList = unHandleList; callback && callback(unHandleList); } @@ -963,10 +1047,13 @@ class TRTCCalling { } // 通话结束,重置数据 - _reset() { - console.log(TAG_NAME, ' _reset()'); + _reset(callEnd) { + console.log(TAG_NAME, ' _reset()', this.data.enterRoomStatus); + if (this.data.enterRoomStatus) { + this.exitRoom(callEnd) + } this._setCallStatus(CALL_STATUS.IDLE); - this.data.config.type = 1; + this.data.config.type = CALL_TYPE.AUDIO; // 清空状态 this.initData(); } @@ -1028,6 +1115,7 @@ class TRTCCalling { if (this.data.callStatus !== CALL_STATUS.CONNECTED) { const targetPos = this.data.pusher.frontCamera === 'front' ? 'back' : 'front'; this.setPusherAttributesHandler({ frontCamera: targetPos }); + wx.createLivePusherContext().switchCamera(); } else { this.TRTC.getPusherInstance().switchCamera(); } @@ -1046,8 +1134,8 @@ class TRTCCalling { } /** - * 视频通话切换语音通话 - */ + * 视频通话切换语音通话 + */ async switchAudioCall() { if (this._isGroupCall) { console.warn(`${TAG_NAME}.switchToAudioCall is not applicable to groupCall.`); @@ -1147,7 +1235,7 @@ class TRTCCalling { } const playerList = newUserList.map((item) => { const newItem = item; - const itemProfile = userList.filter(imItem => imItem.userID === item.userID); + const itemProfile = userList.filter((imItem) => imItem.userID === item.userID); newItem.avatar = itemProfile[0] && itemProfile[0].avatar ? itemProfile[0].avatar : ''; newItem.nick = itemProfile[0] && itemProfile[0].nick ? itemProfile[0].nick : ''; return newItem; @@ -1157,47 +1245,42 @@ class TRTCCalling { // 获取用户信息 _getUserProfile(userList) { const promise = this.tim.getUserProfile({ userIDList: userList }); - promise.then((imResponse) => { - console.log('getUserProfile success', imResponse); - console.log(imResponse.data); - this.data.remoteUsers = imResponse.data; - }).catch((imError) => { - console.warn('getUserProfile error:', imError); // 获取其他用户资料失败的相关信息 - }); + promise + .then((imResponse) => { + console.log('getUserProfile success', imResponse); + console.log(imResponse.data); + this.data.remoteUsers = imResponse.data; + }) + .catch((imError) => { + console.warn('getUserProfile error:', imError); // 获取其他用户资料失败的相关信息 + }); } // 获取用户信息 - async getUserProfile(userList) { + async getUserProfile(userList, type = 'array') { if (userList.length === 0) { return []; } - const list = userList.map(item => item.userID); + const list = userList.map((item) => item.userID); const imResponse = await this.tim.getUserProfile({ userIDList: list }); - const newUserList = userList.map((item) => { - const newItem = item; - const itemProfile = imResponse.data.filter(imItem => imItem.userID === item.userID); - newItem.avatar = itemProfile[0] && itemProfile[0].avatar ? itemProfile[0].avatar : ''; - newItem.nick = itemProfile[0] && itemProfile[0].nick ? itemProfile[0].nick : ''; - return newItem; - }); - return newUserList; - } - - // 呼叫用户图像解析不出来的缺省图设置 - _handleErrorImage() { - const { remoteUsers } = this.data; - remoteUsers[0].avatar = './static/avatar2_100.png'; - this.data.remoteUsers = remoteUsers; - } - - // 通话中图像解析不出来的缺省图设置 - _handleConnectErrorImage(e) { - const data = e.target.dataset.value; - this.data.playerList = this.data.playerList.map((item) => { - if (item.userID === data.userID) { - item.avatar = './static/avatar2_100.png'; - } - return item; - }); + let result = null + switch (type) { + case 'array': + result = userList.map((item, index) => { + item.avatar = imResponse.data[index].avatar + item.nick = imResponse.data[index].nick + return item + }); + break + case 'map': + result = {} + userList.forEach((item, index) => { + item.avatar = imResponse.data[index].avatar + item.nick = imResponse.data[index].nick + result[item.userID] = item + }) + break + } + return result } // pusher 的网络状况 @@ -1214,7 +1297,11 @@ class TRTCCalling { _toggleViewSize(e) { const { screen } = e.currentTarget.dataset; console.log('get screen', screen, e); - if (this.data.playerList.length === 1 && screen !== this.data.screen && this.data.invitation.type === CALL_TYPE.VIDEO) { + if ( + this.data.playerList.length === 1 && + screen !== this.data.screen && + this.data.invitation.type === CALL_TYPE.VIDEO + ) { this.data.screen = screen; } return this.data.screen; @@ -1241,4 +1328,3 @@ class TRTCCalling { } export default TRTCCalling; - diff --git a/MiniProgram/TUIKit/miniprogram/components/TUICalling/TRTCCalling/TRTCCallingDelegate.js b/MiniProgram/TUIKit/miniprogram/components/TUICalling/TRTCCalling/TRTCCallingDelegate.js index c5330e8b57..0d89092033 100644 --- a/MiniProgram/TUIKit/miniprogram/components/TUICalling/TRTCCalling/TRTCCallingDelegate.js +++ b/MiniProgram/TUIKit/miniprogram/components/TUICalling/TRTCCalling/TRTCCallingDelegate.js @@ -82,9 +82,10 @@ class TRTCCallingDelegate { } // 抛出用户接听 - onUserAccept(userID) { + onUserAccept(userID, userList) { this._emitter.emit(EVENT.USER_ACCEPT, { userID, + userList, }); } diff --git a/MiniProgram/TUIKit/miniprogram/components/TUICalling/TRTCCalling/common/constants.js b/MiniProgram/TUIKit/miniprogram/components/TUICalling/TRTCCalling/common/constants.js index 787a491f19..5896f085f5 100644 --- a/MiniProgram/TUIKit/miniprogram/components/TUICalling/TRTCCalling/common/constants.js +++ b/MiniProgram/TUIKit/miniprogram/components/TUICalling/TRTCCalling/common/constants.js @@ -20,13 +20,13 @@ export const EVENT = { HANG_UP: 'HANG_UP', ERROR: 'ERROR', // 组件内部抛出的错误 -}; +} export const CALL_STATUS = { - IDLE: 'idle', - CALLING: 'calling', - CONNECTED: 'connected', -}; + IDLE: 'idle', // 默认 + CALLING: 'calling', //呼叫中/被呼叫中 + CONNECTED: 'connected', //接通中 +} export const ACTION_TYPE = { INVITE: 1, // 邀请方发起邀请 @@ -34,21 +34,21 @@ export const ACTION_TYPE = { ACCEPT_INVITE: 3, // 被邀请方同意邀请 REJECT_INVITE: 4, // 被邀请方拒绝邀请 INVITE_TIMEOUT: 5, // 被邀请方超时未回复 -}; +} export const BUSINESS_ID = { SIGNAL: 1, // 信令 -}; +} export const CALL_TYPE = { AUDIO: 1, VIDEO: 2, -}; +} -export const CMD_TYPE_LIST = ['', 'audioCall', 'videoCall']; +export const CMD_TYPE_LIST = ['', 'audioCall', 'videoCall'] // audio视频切音频;video:音频切视频 export const MODE_TYPE = { AUDIO: 'audio', VIDEO: 'video', -}; +} diff --git a/MiniProgram/TUIKit/miniprogram/components/TUICalling/TRTCCalling/libSrcConfig.js b/MiniProgram/TUIKit/miniprogram/components/TUICalling/TRTCCalling/libSrcConfig.js new file mode 100644 index 0000000000..29ff3a1466 --- /dev/null +++ b/MiniProgram/TUIKit/miniprogram/components/TUICalling/TRTCCalling/libSrcConfig.js @@ -0,0 +1,10 @@ +import TSignaling from './node_module/tsignaling-wx'; +import TRTC from './node_module/trtc-wx' +import TIM from './node_module/tim-wx-sdk'; + + +export { + TSignaling, + TRTC, + TIM +} \ No newline at end of file diff --git a/MiniProgram/TUIKit/miniprogram/components/TUICalling/TRTCCalling/node_module/tim-wx-sdk.js b/MiniProgram/TUIKit/miniprogram/components/TUICalling/TRTCCalling/node_module/tim-wx-sdk.js index 6d62367aa4..d11227bd4f 100644 --- a/MiniProgram/TUIKit/miniprogram/components/TUICalling/TRTCCalling/node_module/tim-wx-sdk.js +++ b/MiniProgram/TUIKit/miniprogram/components/TUICalling/TRTCCalling/node_module/tim-wx-sdk.js @@ -1,4678 +1 @@ -'use strict';!(function (e, t) { - 'object' === typeof exports && 'undefined' !== typeof module ? module.exports = t() : 'function' === typeof define && define.amd ? define(t) : (e = e || self).TIM = t(); -}(this, (() => { - function e(t) { - return (e = 'function' === typeof Symbol && 'symbol' === typeof Symbol.iterator ? function (e) { - return typeof e; - } : function (e) { - return e && 'function' === typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? 'symbol' : typeof e; - })(t); - } function t(e, t) { - if (!(e instanceof t)) throw new TypeError('Cannot call a class as a function'); - } function n(e, t) { - for (let n = 0;n < t.length;n++) { - const o = t[n];o.enumerable = o.enumerable || !1, o.configurable = !0, 'value' in o && (o.writable = !0), Object.defineProperty(e, o.key, o); - } - } function o(e, t, o) { - return t && n(e.prototype, t), o && n(e, o), e; - } function a(e, t, n) { - return t in e ? Object.defineProperty(e, t, { value: n, enumerable: !0, configurable: !0, writable: !0 }) : e[t] = n, e; - } function s(e, t) { - const n = Object.keys(e);if (Object.getOwnPropertySymbols) { - let o = Object.getOwnPropertySymbols(e);t && (o = o.filter((t => Object.getOwnPropertyDescriptor(e, t).enumerable))), n.push.apply(n, o); - } return n; - } function r(e) { - for (let t = 1;t < arguments.length;t++) { - var n = null != arguments[t] ? arguments[t] : {};t % 2 ? s(Object(n), !0).forEach(((t) => { - a(e, t, n[t]); - })) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(n)) : s(Object(n)).forEach(((t) => { - Object.defineProperty(e, t, Object.getOwnPropertyDescriptor(n, t)); - })); - } return e; - } function i(e, t) { - if ('function' !== typeof t && null !== t) throw new TypeError('Super expression must either be null or a function');e.prototype = Object.create(t && t.prototype, { constructor: { value: e, writable: !0, configurable: !0 } }), t && u(e, t); - } function c(e) { - return (c = Object.setPrototypeOf ? Object.getPrototypeOf : function (e) { - return e.__proto__ || Object.getPrototypeOf(e); - })(e); - } function u(e, t) { - return (u = Object.setPrototypeOf || function (e, t) { - return e.__proto__ = t, e; - })(e, t); - } function l() { - if ('undefined' === typeof Reflect || !Reflect.construct) return !1;if (Reflect.construct.sham) return !1;if ('function' === typeof Proxy) return !0;try { - return Date.prototype.toString.call(Reflect.construct(Date, [], (() => {}))), !0; - } catch (e) { - return !1; - } - } function d(e, t, n) { - return (d = l() ? Reflect.construct : function (e, t, n) { - const o = [null];o.push.apply(o, t);const a = new (Function.bind.apply(e, o));return n && u(a, n.prototype), a; - }).apply(null, arguments); - } function p(e) { - const t = 'function' === typeof Map ? new Map : void 0;return (p = function (e) { - if (null === e || (n = e, -1 === Function.toString.call(n).indexOf('[native code]'))) return e;let n;if ('function' !== typeof e) throw new TypeError('Super expression must either be null or a function');if (void 0 !== t) { - if (t.has(e)) return t.get(e);t.set(e, o); - } function o() { - return d(e, arguments, c(this).constructor); - } return o.prototype = Object.create(e.prototype, { constructor: { value: o, enumerable: !1, writable: !0, configurable: !0 } }), u(o, e); - })(e); - } function g(e, t) { - if (null == e) return {};let n; let o; const a = (function (e, t) { - if (null == e) return {};let n; let o; const a = {}; const s = Object.keys(e);for (o = 0;o < s.length;o++)n = s[o], t.indexOf(n) >= 0 || (a[n] = e[n]);return a; - }(e, t));if (Object.getOwnPropertySymbols) { - const s = Object.getOwnPropertySymbols(e);for (o = 0;o < s.length;o++)n = s[o], t.indexOf(n) >= 0 || Object.prototype.propertyIsEnumerable.call(e, n) && (a[n] = e[n]); - } return a; - } function h(e) { - if (void 0 === e) throw new ReferenceError('this hasn\'t been initialised - super() hasn\'t been called');return e; - } function _(e, t) { - return !t || 'object' !== typeof t && 'function' !== typeof t ? h(e) : t; - } function f(e) { - const t = l();return function () { - let n; const o = c(e);if (t) { - const a = c(this).constructor;n = Reflect.construct(o, arguments, a); - } else n = o.apply(this, arguments);return _(this, n); - }; - } function m(e, t) { - return v(e) || (function (e, t) { - if ('undefined' === typeof Symbol || !(Symbol.iterator in Object(e))) return;const n = []; let o = !0; let a = !1; let s = void 0;try { - for (var r, i = e[Symbol.iterator]();!(o = (r = i.next()).done) && (n.push(r.value), !t || n.length !== t);o = !0); - } catch (c) { - a = !0, s = c; - } finally { - try { - o || null == i.return || i.return(); - } finally { - if (a) throw s; - } - } return n; - }(e, t)) || I(e, t) || T(); - } function M(e) { - return (function (e) { - if (Array.isArray(e)) return C(e); - }(e)) || y(e) || I(e) || (function () { - throw new TypeError('Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.'); - }()); - } function v(e) { - if (Array.isArray(e)) return e; - } function y(e) { - if ('undefined' !== typeof Symbol && Symbol.iterator in Object(e)) return Array.from(e); - } function I(e, t) { - if (e) { - if ('string' === typeof e) return C(e, t);let n = Object.prototype.toString.call(e).slice(8, -1);return 'Object' === n && e.constructor && (n = e.constructor.name), 'Map' === n || 'Set' === n ? Array.from(e) : 'Arguments' === n || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n) ? C(e, t) : void 0; - } - } function C(e, t) { - (null == t || t > e.length) && (t = e.length);for (var n = 0, o = new Array(t);n < t;n++)o[n] = e[n];return o; - } function T() { - throw new TypeError('Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.'); - } function S(e, t) { - let n;if ('undefined' === typeof Symbol || null == e[Symbol.iterator]) { - if (Array.isArray(e) || (n = I(e)) || t && e && 'number' === typeof e.length) { - n && (e = n);let o = 0; const a = function () {};return { s: a, n() { - return o >= e.length ? { done: !0 } : { done: !1, value: e[o++] }; - }, e(e) { - throw e; - }, f: a }; - } throw new TypeError('Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.'); - } let s; let r = !0; let i = !1;return { s() { - n = e[Symbol.iterator](); - }, n() { - const e = n.next();return r = e.done, e; - }, e(e) { - i = !0, s = e; - }, f() { - try { - r || null == n.return || n.return(); - } finally { - if (i) throw s; - } - } }; - } const D = { SDK_READY: 'sdkStateReady', SDK_NOT_READY: 'sdkStateNotReady', SDK_DESTROY: 'sdkDestroy', MESSAGE_RECEIVED: 'onMessageReceived', MESSAGE_MODIFIED: 'onMessageModified', MESSAGE_REVOKED: 'onMessageRevoked', MESSAGE_READ_BY_PEER: 'onMessageReadByPeer', CONVERSATION_LIST_UPDATED: 'onConversationListUpdated', GROUP_LIST_UPDATED: 'onGroupListUpdated', GROUP_SYSTEM_NOTICE_RECEIVED: 'receiveGroupSystemNotice', GROUP_ATTRIBUTES_UPDATED: 'groupAttributesUpdated', PROFILE_UPDATED: 'onProfileUpdated', BLACKLIST_UPDATED: 'blacklistUpdated', FRIEND_LIST_UPDATED: 'onFriendListUpdated', FRIEND_GROUP_LIST_UPDATED: 'onFriendGroupListUpdated', FRIEND_APPLICATION_LIST_UPDATED: 'onFriendApplicationListUpdated', KICKED_OUT: 'kickedOut', ERROR: 'error', NET_STATE_CHANGE: 'netStateChange', SDK_RELOAD: 'sdkReload' }; const k = { MSG_TEXT: 'TIMTextElem', MSG_IMAGE: 'TIMImageElem', MSG_SOUND: 'TIMSoundElem', MSG_AUDIO: 'TIMSoundElem', MSG_FILE: 'TIMFileElem', MSG_FACE: 'TIMFaceElem', MSG_VIDEO: 'TIMVideoFileElem', MSG_GEO: 'TIMLocationElem', MSG_LOCATION: 'TIMLocationElem', MSG_GRP_TIP: 'TIMGroupTipElem', MSG_GRP_SYS_NOTICE: 'TIMGroupSystemNoticeElem', MSG_CUSTOM: 'TIMCustomElem', MSG_MERGER: 'TIMRelayElem', MSG_PRIORITY_HIGH: 'High', MSG_PRIORITY_NORMAL: 'Normal', MSG_PRIORITY_LOW: 'Low', MSG_PRIORITY_LOWEST: 'Lowest', CONV_C2C: 'C2C', CONV_GROUP: 'GROUP', CONV_SYSTEM: '@TIM#SYSTEM', CONV_AT_ME: 1, CONV_AT_ALL: 2, CONV_AT_ALL_AT_ME: 3, GRP_PRIVATE: 'Private', GRP_WORK: 'Private', GRP_PUBLIC: 'Public', GRP_CHATROOM: 'ChatRoom', GRP_MEETING: 'ChatRoom', GRP_AVCHATROOM: 'AVChatRoom', GRP_MBR_ROLE_OWNER: 'Owner', GRP_MBR_ROLE_ADMIN: 'Admin', GRP_MBR_ROLE_MEMBER: 'Member', GRP_TIP_MBR_JOIN: 1, GRP_TIP_MBR_QUIT: 2, GRP_TIP_MBR_KICKED_OUT: 3, GRP_TIP_MBR_SET_ADMIN: 4, GRP_TIP_MBR_CANCELED_ADMIN: 5, GRP_TIP_GRP_PROFILE_UPDATED: 6, GRP_TIP_MBR_PROFILE_UPDATED: 7, MSG_REMIND_ACPT_AND_NOTE: 'AcceptAndNotify', MSG_REMIND_ACPT_NOT_NOTE: 'AcceptNotNotify', MSG_REMIND_DISCARD: 'Discard', GENDER_UNKNOWN: 'Gender_Type_Unknown', GENDER_FEMALE: 'Gender_Type_Female', GENDER_MALE: 'Gender_Type_Male', KICKED_OUT_MULT_ACCOUNT: 'multipleAccount', KICKED_OUT_MULT_DEVICE: 'multipleDevice', KICKED_OUT_USERSIG_EXPIRED: 'userSigExpired', ALLOW_TYPE_ALLOW_ANY: 'AllowType_Type_AllowAny', ALLOW_TYPE_NEED_CONFIRM: 'AllowType_Type_NeedConfirm', ALLOW_TYPE_DENY_ANY: 'AllowType_Type_DenyAny', FORBID_TYPE_NONE: 'AdminForbid_Type_None', FORBID_TYPE_SEND_OUT: 'AdminForbid_Type_SendOut', JOIN_OPTIONS_FREE_ACCESS: 'FreeAccess', JOIN_OPTIONS_NEED_PERMISSION: 'NeedPermission', JOIN_OPTIONS_DISABLE_APPLY: 'DisableApply', JOIN_STATUS_SUCCESS: 'JoinedSuccess', JOIN_STATUS_ALREADY_IN_GROUP: 'AlreadyInGroup', JOIN_STATUS_WAIT_APPROVAL: 'WaitAdminApproval', GRP_PROFILE_OWNER_ID: 'ownerID', GRP_PROFILE_CREATE_TIME: 'createTime', GRP_PROFILE_LAST_INFO_TIME: 'lastInfoTime', GRP_PROFILE_MEMBER_NUM: 'memberNum', GRP_PROFILE_MAX_MEMBER_NUM: 'maxMemberNum', GRP_PROFILE_JOIN_OPTION: 'joinOption', GRP_PROFILE_INTRODUCTION: 'introduction', GRP_PROFILE_NOTIFICATION: 'notification', GRP_PROFILE_MUTE_ALL_MBRS: 'muteAllMembers', SNS_ADD_TYPE_SINGLE: 'Add_Type_Single', SNS_ADD_TYPE_BOTH: 'Add_Type_Both', SNS_DELETE_TYPE_SINGLE: 'Delete_Type_Single', SNS_DELETE_TYPE_BOTH: 'Delete_Type_Both', SNS_APPLICATION_TYPE_BOTH: 'Pendency_Type_Both', SNS_APPLICATION_SENT_TO_ME: 'Pendency_Type_ComeIn', SNS_APPLICATION_SENT_BY_ME: 'Pendency_Type_SendOut', SNS_APPLICATION_AGREE: 'Response_Action_Agree', SNS_APPLICATION_AGREE_AND_ADD: 'Response_Action_AgreeAndAdd', SNS_CHECK_TYPE_BOTH: 'CheckResult_Type_Both', SNS_CHECK_TYPE_SINGLE: 'CheckResult_Type_Single', SNS_TYPE_NO_RELATION: 'CheckResult_Type_NoRelation', SNS_TYPE_A_WITH_B: 'CheckResult_Type_AWithB', SNS_TYPE_B_WITH_A: 'CheckResult_Type_BWithA', SNS_TYPE_BOTH_WAY: 'CheckResult_Type_BothWay', NET_STATE_CONNECTED: 'connected', NET_STATE_CONNECTING: 'connecting', NET_STATE_DISCONNECTED: 'disconnected', MSG_AT_ALL: '__kImSDK_MesssageAtALL__', READ_ALL_C2C_MSG: 'readAllC2CMessage', READ_ALL_GROUP_MSG: 'readAllGroupMessage', READ_ALL_MSG: 'readAllMessage' }; const E = (function () { - function e() { - t(this, e), this.cache = [], this.options = null; - } return o(e, [{ key: 'use', value(e) { - if ('function' !== typeof e) throw 'middleware must be a function';return this.cache.push(e), this; - } }, { key: 'next', value(e) { - if (this.middlewares && this.middlewares.length > 0) return this.middlewares.shift().call(this, this.options, this.next.bind(this)); - } }, { key: 'run', value(e) { - return this.middlewares = this.cache.map((e => e)), this.options = e, this.next(); - } }]), e; - }()); const A = 'undefined' !== typeof globalThis ? globalThis : 'undefined' !== typeof window ? window : 'undefined' !== typeof global ? global : 'undefined' !== typeof self ? self : {};function N(e, t) { - return e(t = { exports: {} }, t.exports), t.exports; - } const L = N(((e, t) => { - let n; let o; let a; let s; let r; let i; let c; let u; let l; let d; let p; let g; let h; let _; let f; let m; let M; let v;e.exports = (n = 'function' === typeof Promise, o = 'object' === typeof self ? self : A, a = 'undefined' !== typeof Symbol, s = 'undefined' !== typeof Map, r = 'undefined' !== typeof Set, i = 'undefined' !== typeof WeakMap, c = 'undefined' !== typeof WeakSet, u = 'undefined' !== typeof DataView, l = a && void 0 !== Symbol.iterator, d = a && void 0 !== Symbol.toStringTag, p = r && 'function' === typeof Set.prototype.entries, g = s && 'function' === typeof Map.prototype.entries, h = p && Object.getPrototypeOf((new Set).entries()), _ = g && Object.getPrototypeOf((new Map).entries()), f = l && 'function' === typeof Array.prototype[Symbol.iterator], m = f && Object.getPrototypeOf([][Symbol.iterator]()), M = l && 'function' === typeof String.prototype[Symbol.iterator], v = M && Object.getPrototypeOf(''[Symbol.iterator]()), function (e) { - const t = typeof e;if ('object' !== t) return t;if (null === e) return 'null';if (e === o) return 'global';if (Array.isArray(e) && (!1 === d || !(Symbol.toStringTag in e))) return 'Array';if ('object' === typeof window && null !== window) { - if ('object' === typeof window.location && e === window.location) return 'Location';if ('object' === typeof window.document && e === window.document) return 'Document';if ('object' === typeof window.navigator) { - if ('object' === typeof window.navigator.mimeTypes && e === window.navigator.mimeTypes) return 'MimeTypeArray';if ('object' === typeof window.navigator.plugins && e === window.navigator.plugins) return 'PluginArray'; - } if (('function' === typeof window.HTMLElement || 'object' === typeof window.HTMLElement) && e instanceof window.HTMLElement) { - if ('BLOCKQUOTE' === e.tagName) return 'HTMLQuoteElement';if ('TD' === e.tagName) return 'HTMLTableDataCellElement';if ('TH' === e.tagName) return 'HTMLTableHeaderCellElement'; - } - } const a = d && e[Symbol.toStringTag];if ('string' === typeof a) return a;const l = Object.getPrototypeOf(e);return l === RegExp.prototype ? 'RegExp' : l === Date.prototype ? 'Date' : n && l === Promise.prototype ? 'Promise' : r && l === Set.prototype ? 'Set' : s && l === Map.prototype ? 'Map' : c && l === WeakSet.prototype ? 'WeakSet' : i && l === WeakMap.prototype ? 'WeakMap' : u && l === DataView.prototype ? 'DataView' : s && l === _ ? 'Map Iterator' : r && l === h ? 'Set Iterator' : f && l === m ? 'Array Iterator' : M && l === v ? 'String Iterator' : null === l ? 'Object' : Object.prototype.toString.call(e).slice(8, -1); - }); - })); const R = (function () { - function e() { - const n = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : 0; const o = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : 0;t(this, e), this.high = n, this.low = o; - } return o(e, [{ key: 'equal', value(e) { - return null !== e && (this.low === e.low && this.high === e.high); - } }, { key: 'toString', value() { - const e = Number(this.high).toString(16); let t = Number(this.low).toString(16);if (t.length < 8) for (let n = 8 - t.length;n;)t = `0${t}`, n--;return e + t; - } }]), e; - }()); const O = { 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' } }, PRODUCTION: { CHINA: { DEFAULT: 'wss://wss.im.qcloud.com', BACKUP: 'wss://wss.tim.qq.com', STAT: 'https://api.im.qcloud.com' }, OVERSEA: { DEFAULT: 'wss://wss.im.qcloud.com', STAT: 'https://api.im.qcloud.com' }, SINGAPORE: { DEFAULT: 'wss://wsssgp.im.qcloud.com', STAT: 'https://apisgp.im.qcloud.com' }, KOREA: { DEFAULT: 'wss://wsskr.im.qcloud.com', STAT: 'https://apiskr.im.qcloud.com' }, GERMANY: { DEFAULT: 'wss://wssger.im.qcloud.com', STAT: 'https://apiger.im.qcloud.com' }, IND: { DEFAULT: 'wss://wssind.im.qcloud.com', STAT: 'https://apiind.im.qcloud.com' } } }; const G = { WEB: 7, WX_MP: 8, QQ_MP: 9, TT_MP: 10, BAIDU_MP: 11, ALI_MP: 12, UNI_NATIVE_APP: 15 }; const w = '1.7.3'; const b = 537048168; const P = 'CHINA'; const U = 'OVERSEA'; const F = 'SINGAPORE'; const q = 'KOREA'; const V = 'GERMANY'; const K = 'IND'; const x = { HOST: { CURRENT: { DEFAULT: 'wss://wss.im.qcloud.com', STAT: 'https://api.im.qcloud.com' }, setCurrent() { - const e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : P;this.CURRENT = O.PRODUCTION[e]; - } }, NAME: { OPEN_IM: 'openim', GROUP: 'group_open_http_svc', GROUP_ATTR: 'group_open_attr_http_svc', FRIEND: 'sns', PROFILE: 'profile', RECENT_CONTACT: 'recentcontact', PIC: 'openpic', BIG_GROUP_NO_AUTH: 'group_open_http_noauth_svc', BIG_GROUP_LONG_POLLING: 'group_open_long_polling_http_svc', BIG_GROUP_LONG_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_MESSAGE: 'im_long_msg', IM_CONFIG_MANAGER: 'im_sdk_config_mgr', STAT_SERVICE: 'StatSvc', OVERLOAD_PUSH: 'OverLoadPush' }, CMD: { ACCESS_LAYER: 'accesslayer', LOGIN: 'wslogin', LOGOUT_LONG_POLL: 'longpollinglogout', LOGOUT: 'wslogout', HELLO: 'wshello', PORTRAIT_GET: 'portrait_get_all', PORTRAIT_SET: 'portrait_set', GET_LONG_POLL_ID: 'getlongpollingid', LONG_POLL: 'longpolling', AVCHATROOM_LONG_POLL: 'get_msg', ADD_FRIEND: 'friend_add', UPDATE_FRIEND: 'friend_update', GET_FRIEND_LIST: 'friend_get', GET_FRIEND_PROFILE: 'friend_get_list', DELETE_FRIEND: 'friend_delete', CHECK_FRIEND: 'friend_check', GET_FRIEND_GROUP_LIST: 'group_get', RESPOND_FRIEND_APPLICATION: 'friend_response', GET_FRIEND_APPLICATION_LIST: 'pendency_get', DELETE_FRIEND_APPLICATION: 'pendency_delete', REPORT_FRIEND_APPLICATION: 'pendency_report', GET_GROUP_APPLICATION: 'get_pendency', CREATE_FRIEND_GROUP: 'group_add', DELETE_FRIEND_GROUP: 'group_delete', UPDATE_FRIEND_GROUP: 'group_update', GET_BLACKLIST: 'black_list_get', ADD_BLACKLIST: 'black_list_add', DELETE_BLACKLIST: 'black_list_delete', CREATE_GROUP: 'create_group', GET_JOINED_GROUPS: 'get_joined_group_list', SET_GROUP_ATTRIBUTES: 'set_group_attr', MODIFY_GROUP_ATTRIBUTES: 'modify_group_attr', DELETE_GROUP_ATTRIBUTES: 'delete_group_attr', CLEAR_GROUP_ATTRIBUTES: 'clear_group_attr', GET_GROUP_ATTRIBUTES: 'get_group_attr', SEND_MESSAGE: 'sendmsg', REVOKE_C2C_MESSAGE: 'msgwithdraw', DELETE_C2C_MESSAGE: 'delete_c2c_msg_ramble', SEND_GROUP_MESSAGE: 'send_group_msg', REVOKE_GROUP_MESSAGE: 'group_msg_recall', DELETE_GROUP_MESSAGE: 'delete_group_ramble_msg_by_seq', GET_GROUP_INFO: 'get_group_self_member_info', GET_GROUP_MEMBER_INFO: 'get_specified_group_member_info', GET_GROUP_MEMBER_LIST: 'get_group_member_info', QUIT_GROUP: 'quit_group', CHANGE_GROUP_OWNER: 'change_group_owner', DESTROY_GROUP: 'destroy_group', ADD_GROUP_MEMBER: 'add_group_member', DELETE_GROUP_MEMBER: 'delete_group_member', SEARCH_GROUP_BY_ID: 'get_group_public_info', APPLY_JOIN_GROUP: 'apply_join_group', HANDLE_APPLY_JOIN_GROUP: 'handle_apply_join_group', HANDLE_GROUP_INVITATION: 'handle_invite_join_group', MODIFY_GROUP_INFO: 'modify_group_base_info', MODIFY_GROUP_MEMBER_INFO: 'modify_group_member_info', DELETE_GROUP_SYSTEM_MESSAGE: 'deletemsg', DELETE_GROUP_AT_TIPS: 'deletemsg', GET_CONVERSATION_LIST: 'get', PAGING_GET_CONVERSATION_LIST: 'page_get', DELETE_CONVERSATION: 'delete', PIN_CONVERSATION: 'top', GET_MESSAGES: 'getmsg', GET_C2C_ROAM_MESSAGES: 'getroammsg', SET_C2C_PEER_MUTE_NOTIFICATIONS: 'set_c2c_peer_mute_notifications', GET_C2C_PEER_MUTE_NOTIFICATIONS: 'get_c2c_peer_mute_notifications', GET_GROUP_ROAM_MESSAGES: 'group_msg_get', SET_C2C_MESSAGE_READ: 'msgreaded', GET_PEER_READ_TIME: 'get_peer_read_time', SET_GROUP_MESSAGE_READ: 'msg_read_report', FILE_READ_AND_WRITE_AUTHKEY: 'authkey', FILE_UPLOAD: 'pic_up', COS_SIGN: 'cos', COS_PRE_SIG: 'pre_sig', TIM_WEB_REPORT_V2: 'tim_web_report_v2', BIG_DATA_HALLWAY_AUTH_KEY: 'authkey', GET_ONLINE_MEMBER_NUM: 'get_online_member_num', ALIVE: 'alive', MESSAGE_PUSH: 'msg_push', MESSAGE_PUSH_ACK: 'ws_msg_push_ack', STATUS_FORCEOFFLINE: 'stat_forceoffline', DOWNLOAD_MERGER_MESSAGE: 'get_relay_json_msg', UPLOAD_MERGER_MESSAGE: 'save_relay_json_msg', FETCH_CLOUD_CONTROL_CONFIG: 'fetch_config', PUSHED_CLOUD_CONTROL_CONFIG: 'push_configv2', FETCH_COMMERCIAL_CONFIG: 'fetch_imsdk_purchase_bitsv2', PUSHED_COMMERCIAL_CONFIG: 'push_imsdk_purchase_bitsv2', KICK_OTHER: 'KickOther', OVERLOAD_NOTIFY: 'notify2', SET_ALL_MESSAGE_READ: 'read_all_unread_msg' }, CHANNEL: { SOCKET: 1, XHR: 2, AUTO: 0 }, NAME_VERSION: { openim: 'v4', group_open_http_svc: 'v4', sns: 'v4', profile: 'v4', recentcontact: 'v4', openpic: 'v4', group_open_http_noauth_svc: 'v4', group_open_long_polling_http_svc: 'v4', group_open_long_polling_http_noauth_svc: 'v4', imopenstat: 'v4', im_cos_sign_svr: 'v4', im_cos_msg: 'v4', webim: 'v4', im_open_push: 'v4', im_open_status: 'v4' } }; const B = { SEARCH_MSG: new R(0, Math.pow(2, 0)).toString(), SEARCH_GRP_SNS: new R(0, Math.pow(2, 1)).toString(), AVCHATROOM_HISTORY_MSG: new R(0, Math.pow(2, 2)).toString(), GRP_COMMUNITY: new R(0, Math.pow(2, 3)).toString(), MSG_TO_SPECIFIED_GRP_MBR: new R(0, Math.pow(2, 4)).toString() };x.HOST.setCurrent(P);let H; let j; let W; let Y; const $ = 'undefined' !== typeof wx && 'function' === typeof wx.getSystemInfoSync && Boolean(wx.getSystemInfoSync().fontSizeSetting); const z = 'undefined' !== typeof qq && 'function' === typeof qq.getSystemInfoSync && Boolean(qq.getSystemInfoSync().fontSizeSetting); const J = 'undefined' !== typeof tt && 'function' === typeof tt.getSystemInfoSync && Boolean(tt.getSystemInfoSync().fontSizeSetting); const X = 'undefined' !== typeof swan && 'function' === typeof swan.getSystemInfoSync && Boolean(swan.getSystemInfoSync().fontSizeSetting); const Q = 'undefined' !== typeof my && 'function' === typeof my.getSystemInfoSync && Boolean(my.getSystemInfoSync().fontSizeSetting); const Z = 'undefined' !== typeof uni && 'undefined' === typeof window; const ee = $ || z || J || X || Q || Z; const te = ('undefined' !== typeof uni || 'undefined' !== typeof window) && !ee; const ne = z ? qq : J ? tt : X ? swan : Q ? my : $ ? wx : Z ? uni : {}; const oe = (H = 'WEB', me ? H = 'WEB' : z ? H = 'QQ_MP' : J ? H = 'TT_MP' : X ? H = 'BAIDU_MP' : Q ? H = 'ALI_MP' : $ ? H = 'WX_MP' : Z && (H = 'UNI_NATIVE_APP'), G[H]); const ae = te && window && window.navigator && window.navigator.userAgent || ''; const se = /AppleWebKit\/([\d.]+)/i.exec(ae); const re = (se && parseFloat(se.pop()), /iPad/i.test(ae)); const ie = /iPhone/i.test(ae) && !re; const ce = /iPod/i.test(ae); const ue = ie || re || ce; const le = ((j = ae.match(/OS (\d+)_/i)) && j[1] && j[1], /Android/i.test(ae)); const de = (function () { - const e = ae.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);if (!e) return null;const t = e[1] && parseFloat(e[1]); const n = e[2] && parseFloat(e[2]);return t && n ? parseFloat(`${e[1]}.${e[2]}`) : t || null; - }()); const pe = (le && /webkit/i.test(ae), /Firefox/i.test(ae), /Edge/i.test(ae)); const ge = !pe && /Chrome/i.test(ae); const he = ((function () { - const e = ae.match(/Chrome\/(\d+)/);e && e[1] && parseFloat(e[1]); - }()), /MSIE/.test(ae)); const _e = (/MSIE\s8\.0/.test(ae), (function () { - const e = /MSIE\s(\d+)\.\d/.exec(ae); let t = e && parseFloat(e[1]);return !t && /Trident\/7.0/i.test(ae) && /rv:11.0/.test(ae) && (t = 11), t; - }())); const fe = (/Safari/i.test(ae), /TBS\/\d+/i.test(ae)); var me = ((function () { - const e = ae.match(/TBS\/(\d+)/i);if (e && e[1])e[1]; - }()), !fe && /MQQBrowser\/\d+/i.test(ae), !fe && / QQBrowser\/\d+/i.test(ae), /(micromessenger|webbrowser)/i.test(ae)); const Me = /Windows/i.test(ae); const ve = /MAC OS X/i.test(ae); const ye = (/MicroMessenger/i.test(ae), te && 'undefined' !== typeof Worker); const Ie = 'undefined' !== typeof global ? global : 'undefined' !== typeof self ? self : 'undefined' !== typeof window ? window : {};W = 'undefined' !== typeof console ? console : void 0 !== Ie && Ie.console ? Ie.console : 'undefined' !== typeof window && window.console ? window.console : {};for (var Ce = function () {}, Te = ['assert', 'clear', 'count', 'debug', 'dir', 'dirxml', 'error', 'exception', 'group', 'groupCollapsed', 'groupEnd', 'info', 'log', 'markTimeline', 'profile', 'profileEnd', 'table', 'time', 'timeEnd', 'timeStamp', 'trace', 'warn'], Se = Te.length;Se--;)Y = Te[Se], console[Y] || (W[Y] = Ce);W.methods = Te;const De = W; let ke = 0; const Ee = function () { - return (new Date).getTime() + ke; - }; const Ae = function () { - ke = 0; - }; let Ne = 0; const Le = new Map;function Re() { - let e; const t = ((e = new Date).setTime(Ee()), e);return `TIM ${t.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; - }(t.getMilliseconds()))}:`; - } const Oe = { arguments2String(e) { - let t;if (1 === e.length)t = Re() + e[0];else { - t = Re();for (let n = 0, o = e.length;n < o;n++)Ve(e[n]) ? xe(e[n]) ? t += $e(e[n]) : t += JSON.stringify(e[n]) : t += e[n], t += ' '; - } return t; - }, debug() { - if (Ne <= -1) { - const e = this.arguments2String(arguments);De.debug(e); - } - }, log() { - if (Ne <= 0) { - const e = this.arguments2String(arguments);De.log(e); - } - }, info() { - if (Ne <= 1) { - const e = this.arguments2String(arguments);De.info(e); - } - }, warn() { - if (Ne <= 2) { - const e = this.arguments2String(arguments);De.warn(e); - } - }, error() { - if (Ne <= 3) { - const e = this.arguments2String(arguments);De.error(e); - } - }, time(e) { - Le.set(e, We.now()); - }, timeEnd(e) { - if (Le.has(e)) { - const t = We.now() - Le.get(e);return Le.delete(e), t; - } return De.warn('未找到对应label: '.concat(e, ', 请在调用 logger.timeEnd 前,调用 logger.time')), 0; - }, setLevel(e) { - e < 4 && De.log(`${Re()}set level from ${Ne} to ${e}`), Ne = e; - }, getLevel() { - return Ne; - } }; const Ge = function (e) { - return 'file' === Be(e); - }; const we = function (t) { - return null !== t && ('number' === typeof t && !isNaN(t - 0) || 'object' === e(t) && t.constructor === Number); - }; const be = function (e) { - return 'string' === typeof e; - }; const Pe = function (t) { - return null !== t && 'object' === e(t); - }; const Ue = function (t) { - if ('object' !== e(t) || null === t) return !1;const n = Object.getPrototypeOf(t);if (null === n) return !0;for (var o = n;null !== Object.getPrototypeOf(o);)o = Object.getPrototypeOf(o);return n === o; - }; const Fe = function (e) { - return 'function' === typeof Array.isArray ? Array.isArray(e) : 'array' === Be(e); - }; const qe = function (e) { - return void 0 === e; - }; var Ve = function (e) { - return Fe(e) || Pe(e); - }; const Ke = function (e) { - return 'function' === typeof e; - }; var xe = function (e) { - return e instanceof Error; - }; var Be = function (e) { - return Object.prototype.toString.call(e).match(/^\[object (.*)\]$/)[1].toLowerCase(); - }; const He = function (e) { - if ('string' !== typeof e) return !1;const t = e[0];return !/[^a-zA-Z0-9]/.test(t); - }; let je = 0;Date.now || (Date.now = function () { - return (new Date).getTime(); - });var We = { now() { - 0 === je && (je = Date.now() - 1);const e = Date.now() - je;return e > 4294967295 ? (je += 4294967295, Date.now() - je) : e; - }, utc() { - return Math.round(Date.now() / 1e3); - } }; const Ye = function e(t, n, o, a) { - if (!Ve(t) || !Ve(n)) return 0;for (var s, r = 0, i = Object.keys(n), c = 0, u = i.length;c < u;c++) if (s = i[c], !(qe(n[s]) || o && o.includes(s))) if (Ve(t[s]) && Ve(n[s]))r += e(t[s], n[s], o, a);else { - if (a && a.includes(n[s])) continue;t[s] !== n[s] && (t[s] = n[s], r += 1); - } return r; - }; var $e = function (e) { - return JSON.stringify(e, ['message', 'code']); - }; const ze = function (e) { - if (0 === e.length) return 0;for (var t = 0, n = 0, o = 'undefined' !== typeof document && void 0 !== document.characterSet ? document.characterSet : 'UTF-8';void 0 !== e[t];)n += e[t++].charCodeAt[t] <= 255 ? 1 : !1 === o ? 3 : 2;return n; - }; const Je = function (e) { - const t = e || 99999999;return Math.round(Math.random() * t); - }; const Xe = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; const Qe = Xe.length; const Ze = function (e, t) { - for (const n in e) if (e[n] === t) return !0;return !1; - }; const et = {}; const nt = function () { - if (ee) return 'https:';if (te && 'undefined' === typeof window) return 'https:';let e = window.location.protocol;return ['http:', 'https:'].indexOf(e) < 0 && (e = 'http:'), e; - }; const ot = function (e) { - return -1 === e.indexOf('http://') || -1 === e.indexOf('https://') ? `https://${e}` : e.replace(/https|http/, 'https'); - }; const at = function t(n) { - if (0 === Object.getOwnPropertyNames(n).length) return Object.create(null);const o = Array.isArray(n) ? [] : Object.create(null); let a = '';for (const s in n)null !== n[s] ? void 0 !== n[s] ? (a = e(n[s]), ['string', 'number', 'function', 'boolean'].indexOf(a) >= 0 ? o[s] = n[s] : o[s] = t(n[s])) : o[s] = void 0 : o[s] = null;return o; - };function st(e, t) { - Fe(e) && Fe(t) ? t.forEach(((t) => { - const n = t.key; const o = t.value; const a = e.find((e => e.key === n));a ? a.value = o : e.push({ key: n, value: o }); - })) : Oe.warn('updateCustomField target 或 source 不是数组,忽略此次更新。'); - } const rt = function (e) { - return e === k.GRP_PUBLIC; - }; const it = function (e) { - return e === k.GRP_AVCHATROOM; - }; const ct = function (e) { - return be(e) && e.slice(0, 3) === k.CONV_C2C; - }; const ut = function (e) { - return be(e) && e.slice(0, 5) === k.CONV_GROUP; - }; const lt = function (e) { - return be(e) && e === k.CONV_SYSTEM; - };function dt(e, t) { - const n = {};return Object.keys(e).forEach(((o) => { - n[o] = t(e[o], o); - })), n; - } function pt() { - function e() { - return (65536 * (1 + Math.random()) | 0).toString(16).substring(1); - } return ''.concat(e() + e()).concat(e()) - .concat(e()) - .concat(e()) - .concat(e()) - .concat(e()) - .concat(e()); - } function gt() { - let e = 'unknown';if (ve && (e = 'mac'), Me && (e = 'windows'), ue && (e = 'ios'), le && (e = 'android'), ee) try { - const t = ne.getSystemInfoSync().platform;void 0 !== t && (e = t); - } catch (n) {} return e; - } function ht(e) { - const t = e.originUrl; const n = void 0 === t ? void 0 : t; const o = e.originWidth; const a = e.originHeight; const s = e.min; const r = void 0 === s ? 198 : s; const i = parseInt(o); const c = parseInt(a); const u = { url: void 0, width: 0, height: 0 };if ((i <= c ? i : c) <= r)u.url = n, u.width = i, u.height = c;else { - c <= i ? (u.width = Math.ceil(i * r / c), u.height = r) : (u.width = r, u.height = Math.ceil(c * r / i));const l = n && n.indexOf('?') > -1 ? ''.concat(n, '&') : ''.concat(n, '?');u.url = ''.concat(l, 198 === r ? 'imageView2/3/w/198/h/198' : 'imageView2/3/w/720/h/720'); - } return qe(n) ? g(u, ['url']) : u; - } function _t(e) { - const t = e[2];e[2] = e[1], e[1] = t;for (let n = 0;n < e.length;n++)e[n].setType(n); - } function ft(e) { - const t = e.servcmd;return t.slice(t.indexOf('.') + 1); - } function mt(e, t) { - return Math.round(Number(e) * Math.pow(10, t)) / Math.pow(10, t); - } function Mt(e, t) { - return e.includes(t); - } function vt(e, t) { - return e.includes(t); - } const yt = Object.prototype.hasOwnProperty;function It(e) { - if (null == e) return !0;if ('boolean' === typeof e) return !1;if ('number' === typeof e) return 0 === e;if ('string' === typeof e) return 0 === e.length;if ('function' === typeof e) return 0 === e.length;if (Array.isArray(e)) return 0 === e.length;if (e instanceof Error) return '' === e.message;if (Ue(e)) { - for (const t in e) if (yt.call(e, t)) return !1;return !0; - } return !('map' !== Be(e) && !(function (e) { - return 'set' === Be(e); - }(e)) && !Ge(e)) && 0 === e.size; - } function Ct(e, t, n) { - if (void 0 === t) return !0;let o = !0;if ('object' === L(t).toLowerCase())Object.keys(t).forEach(((a) => { - const s = 1 === e.length ? e[0][a] : void 0;o = !!Tt(s, t[a], n, a) && o; - }));else if ('array' === L(t).toLowerCase()) for (let a = 0;a < t.length;a++)o = !!Tt(e[a], t[a], n, t[a].name) && o;if (o) return o;throw new Error('Params validate failed.'); - } function Tt(e, t, n, o) { - if (void 0 === t) return !0;let a = !0;return t.required && It(e) && (De.error('TIM ['.concat(n, '] Missing required params: "').concat(o, '".')), a = !1), It(e) || L(e).toLowerCase() === t.type.toLowerCase() || (De.error('TIM ['.concat(n, '] Invalid params: type check failed for "').concat(o, '".Expected ') - .concat(t.type, '.')), a = !1), t.validator && !t.validator(e) && (De.error('TIM ['.concat(n, '] Invalid params: custom validator check failed for params.')), a = !1), a; - } let St; const Dt = { UNSEND: 'unSend', SUCCESS: 'success', FAIL: 'fail' }; const kt = { NOT_START: 'notStart', PENDING: 'pengding', RESOLVED: 'resolved', REJECTED: 'rejected' }; const Et = function (e) { - return !!e && (!!(ct(e) || ut(e) || lt(e)) || (console.warn('非法的会话 ID:'.concat(e, '。会话 ID 组成方式:C2C + userID(单聊)GROUP + groupID(群聊)@TIM#SYSTEM(系统通知会话)')), !1)); - }; const At = '请参考 https://web.sdk.qcloud.com/im/doc/zh-cn/SDK.html#'; const Nt = function (e) { - return e.param ? ''.concat(e.api, ' ').concat(e.param, ' ') - .concat(e.desc, '。') - .concat(At) - .concat(e.api) : ''.concat(e.api, ' ').concat(e.desc, '。') - .concat(At) - .concat(e.api); - }; const Lt = { type: 'String', required: !0 }; const Rt = { type: 'Array', required: !0 }; const Ot = { type: 'Object', required: !0 }; const Gt = { login: { userID: Lt, userSig: Lt }, addToBlacklist: { userIDList: Rt }, on: [{ name: 'eventName', type: 'String', validator(e) { - return 'string' === typeof e && 0 !== e.length || (console.warn(Nt({ api: 'on', param: 'eventName', desc: '类型必须为 String,且不能为空' })), !1); - } }, { name: 'handler', type: 'Function', validator(e) { - return 'function' !== typeof e ? (console.warn(Nt({ api: 'on', param: 'handler', desc: '参数必须为 Function' })), !1) : ('' === e.name && console.warn('on 接口的 handler 参数推荐使用具名函数。具名函数可以使用 off 接口取消订阅,匿名函数无法取消订阅。'), !0); - } }], once: [{ name: 'eventName', type: 'String', validator(e) { - return 'string' === typeof e && 0 !== e.length || (console.warn(Nt({ api: 'once', param: 'eventName', desc: '类型必须为 String,且不能为空' })), !1); - } }, { name: 'handler', type: 'Function', validator(e) { - return 'function' !== typeof e ? (console.warn(Nt({ api: 'once', param: 'handler', desc: '参数必须为 Function' })), !1) : ('' === e.name && console.warn('once 接口的 handler 参数推荐使用具名函数。'), !0); - } }], off: [{ name: 'eventName', type: 'String', validator(e) { - return 'string' === typeof e && 0 !== e.length || (console.warn(Nt({ api: 'off', param: 'eventName', desc: '类型必须为 String,且不能为空' })), !1); - } }, { name: 'handler', type: 'Function', validator(e) { - return 'function' !== typeof e ? (console.warn(Nt({ api: 'off', param: 'handler', desc: '参数必须为 Function' })), !1) : ('' === e.name && console.warn('off 接口无法为匿名函数取消监听事件。'), !0); - } }], sendMessage: [r({ name: 'message' }, Ot)], getMessageList: { conversationID: r(r({}, Lt), {}, { validator(e) { - return Et(e); - } }), nextReqMessageID: { type: 'String' }, count: { type: 'Number', validator(e) { - return !(!qe(e) && !/^[1-9][0-9]*$/.test(e)) || (console.warn(Nt({ api: 'getMessageList', param: 'count', desc: '必须为正整数' })), !1); - } } }, setMessageRead: { conversationID: r(r({}, Lt), {}, { validator(e) { - return Et(e); - } }) }, setAllMessageRead: { scope: { type: 'String', required: !1, validator(e) { - return !e || -1 !== [k.READ_ALL_C2C_MSG, k.READ_ALL_GROUP_MSG, k.READ_ALL_MSG].indexOf(e) || (console.warn(Nt({ api: 'setAllMessageRead', param: 'scope', desc: '取值必须为 TIM.TYPES.READ_ALL_C2C_MSG, TIM.TYPES.READ_ALL_GROUP_MSG 或 TIM.TYPES.READ_ALL_MSG' })), !1); - } } }, getConversationProfile: [r(r({ name: 'conversationID' }, Lt), {}, { validator(e) { - return Et(e); - } })], deleteConversation: [r(r({ name: 'conversationID' }, Lt), {}, { validator(e) { - return Et(e); - } })], pinConversation: { conversationID: r(r({}, Lt), {}, { validator(e) { - return Et(e); - } }), isPinned: r({}, { type: 'Boolean', required: !0 }) }, getConversationList: [{ name: 'options', type: 'Array', validator(e) { - return !!qe(e) || (0 !== e.length || (console.warn(Nt({ api: 'getConversationList', desc: '获取指定会话时不能传入空数组' })), !1)); - } }], getGroupList: { groupProfileFilter: { type: 'Array' } }, getGroupProfile: { groupID: Lt, groupCustomFieldFilter: { type: 'Array' }, memberCustomFieldFilter: { type: 'Array' } }, getGroupProfileAdvance: { groupIDList: Rt }, createGroup: { name: Lt }, joinGroup: { groupID: Lt, type: { type: 'String' }, applyMessage: { type: 'String' } }, quitGroup: [r({ name: 'groupID' }, Lt)], handleApplication: { message: Ot, handleAction: Lt, handleMessage: { type: 'String' } }, changeGroupOwner: { groupID: Lt, newOwnerID: Lt }, updateGroupProfile: { groupID: Lt, muteAllMembers: { type: 'Boolean' } }, dismissGroup: [r({ name: 'groupID' }, Lt)], searchGroupByID: [r({ name: 'groupID' }, Lt)], initGroupAttributes: { groupID: Lt, groupAttributes: r(r({}, Ot), {}, { validator(e) { - let t = !0;return Object.keys(e).forEach(((n) => { - if (!be(e[n])) return console.warn(Nt({ api: 'initGroupAttributes', desc: '群属性 value 必须是字符串' })), t = !1; - })), t; - } }) }, setGroupAttributes: { groupID: Lt, groupAttributes: r(r({}, Ot), {}, { validator(e) { - let t = !0;return Object.keys(e).forEach(((n) => { - if (!be(e[n])) return console.warn(Nt({ api: 'setGroupAttributes', desc: '群属性 value 必须是字符串' })), t = !1; - })), t; - } }) }, deleteGroupAttributes: { groupID: Lt, keyList: { type: 'Array', validator(e) { - if (qe(e)) return console.warn(Nt({ api: 'deleteGroupAttributes', desc: '缺少必填参数:keyList' })), !1;if (!Fe(e)) return !1;if (!It(e)) { - let t = !0;return e.forEach(((e) => { - if (!be(e)) return console.warn(Nt({ api: 'deleteGroupAttributes', desc: '群属性 key 必须是字符串' })), t = !1; - })), t; - } return !0; - } } }, getGroupAttributes: { groupID: Lt, keyList: { type: 'Array', validator(e) { - if (qe(e)) return console.warn(Nt({ api: 'getGroupAttributes', desc: '缺少必填参数:keyList' })), !1;if (!Fe(e)) return !1;if (!It(e)) { - let t = !0;return e.forEach(((e) => { - if (!be(e)) return console.warn(Nt({ api: 'getGroupAttributes', desc: '群属性 key 必须是字符串' })), t = !1; - })), t; - } return !0; - } } }, getGroupMemberList: { groupID: Lt, offset: { type: 'Number' }, count: { type: 'Number' } }, getGroupMemberProfile: { groupID: Lt, userIDList: Rt, memberCustomFieldFilter: { type: 'Array' } }, addGroupMember: { groupID: Lt, userIDList: Rt }, setGroupMemberRole: { groupID: Lt, userID: Lt, role: Lt }, setGroupMemberMuteTime: { groupID: Lt, userID: Lt, muteTime: { type: 'Number', validator(e) { - return e >= 0; - } } }, setGroupMemberNameCard: { groupID: Lt, userID: { type: 'String' }, nameCard: { type: 'String', validator(e) { - return be(e) ? (e.length, !0) : (console.warn(Nt({ api: 'setGroupMemberNameCard', param: 'nameCard', desc: '类型必须为 String' })), !1); - } } }, setGroupMemberCustomField: { groupID: Lt, userID: { type: 'String' }, memberCustomField: Rt }, deleteGroupMember: { groupID: Lt }, createTextMessage: { to: Lt, conversationType: Lt, payload: r(r({}, Ot), {}, { validator(e) { - return Ue(e) ? be(e.text) ? 0 !== e.text.length || (console.warn(Nt({ api: 'createTextMessage', desc: '消息内容不能为空' })), !1) : (console.warn(Nt({ api: 'createTextMessage', param: 'payload.text', desc: '类型必须为 String' })), !1) : (console.warn(Nt({ api: 'createTextMessage', param: 'payload', desc: '类型必须为 plain object' })), !1); - } }) }, createTextAtMessage: { to: Lt, conversationType: Lt, payload: r(r({}, Ot), {}, { validator(e) { - return Ue(e) ? be(e.text) ? 0 === e.text.length ? (console.warn(Nt({ api: 'createTextAtMessage', desc: '消息内容不能为空' })), !1) : !(e.atUserList && !Fe(e.atUserList)) || (console.warn(Nt({ api: 'createTextAtMessage', desc: 'payload.atUserList 类型必须为数组' })), !1) : (console.warn(Nt({ api: 'createTextAtMessage', param: 'payload.text', desc: '类型必须为 String' })), !1) : (console.warn(Nt({ api: 'createTextAtMessage', param: 'payload', desc: '类型必须为 plain object' })), !1); - } }) }, createCustomMessage: { to: Lt, conversationType: Lt, payload: r(r({}, Ot), {}, { validator(e) { - return Ue(e) ? e.data && !be(e.data) ? (console.warn(Nt({ api: 'createCustomMessage', param: 'payload.data', desc: '类型必须为 String' })), !1) : e.description && !be(e.description) ? (console.warn(Nt({ api: 'createCustomMessage', param: 'payload.description', desc: '类型必须为 String' })), !1) : !(e.extension && !be(e.extension)) || (console.warn(Nt({ api: 'createCustomMessage', param: 'payload.extension', desc: '类型必须为 String' })), !1) : (console.warn(Nt({ api: 'createCustomMessage', param: 'payload', desc: '类型必须为 plain object' })), !1); - } }) }, createImageMessage: { to: Lt, conversationType: Lt, payload: r(r({}, Ot), {}, { validator(e) { - if (!Ue(e)) return console.warn(Nt({ api: 'createImageMessage', param: 'payload', desc: '类型必须为 plain object' })), !1;if (qe(e.file)) return console.warn(Nt({ api: 'createImageMessage', param: 'payload.file', desc: '不能为 undefined' })), !1;if (te) { - if (!(e.file instanceof HTMLInputElement || Ge(e.file))) return Ue(e.file) && 'undefined' !== typeof uni ? 0 !== e.file.tempFilePaths.length && 0 !== e.file.tempFiles.length || (console.warn(Nt({ api: 'createImageMessage', param: 'payload.file', desc: '您没有选择文件,无法发送' })), !1) : (console.warn(Nt({ api: 'createImageMessage', param: 'payload.file', desc: '类型必须是 HTMLInputElement 或 File' })), !1);if (e.file instanceof HTMLInputElement && 0 === e.file.files.length) return console.warn(Nt({ api: 'createImageMessage', param: 'payload.file', desc: '您没有选择文件,无法发送' })), !1; - } return !0; - }, onProgress: { type: 'Function', required: !1, validator(e) { - return qe(e) && console.warn(Nt({ api: 'createImageMessage', desc: '没有 onProgress 回调,您将无法获取上传进度' })), !0; - } } }) }, createAudioMessage: { to: Lt, conversationType: Lt, payload: r(r({}, Ot), {}, { validator(e) { - return !!Ue(e) || (console.warn(Nt({ api: 'createAudioMessage', param: 'payload', desc: '类型必须为 plain object' })), !1); - } }), onProgress: { type: 'Function', required: !1, validator(e) { - return qe(e) && console.warn(Nt({ api: 'createAudioMessage', desc: '没有 onProgress 回调,您将无法获取上传进度' })), !0; - } } }, createVideoMessage: { to: Lt, conversationType: Lt, payload: r(r({}, Ot), {}, { validator(e) { - if (!Ue(e)) return console.warn(Nt({ api: 'createVideoMessage', param: 'payload', desc: '类型必须为 plain object' })), !1;if (qe(e.file)) return console.warn(Nt({ api: 'createVideoMessage', param: 'payload.file', desc: '不能为 undefined' })), !1;if (te) { - if (!(e.file instanceof HTMLInputElement || Ge(e.file))) return Ue(e.file) && 'undefined' !== typeof uni ? !!Ge(e.file.tempFile) || (console.warn(Nt({ api: 'createVideoMessage', param: 'payload.file', desc: '您没有选择文件,无法发送' })), !1) : (console.warn(Nt({ api: 'createVideoMessage', param: 'payload.file', desc: '类型必须是 HTMLInputElement 或 File' })), !1);if (e.file instanceof HTMLInputElement && 0 === e.file.files.length) return console.warn(Nt({ api: 'createVideoMessage', param: 'payload.file', desc: '您没有选择文件,无法发送' })), !1; - } return !0; - } }), onProgress: { type: 'Function', required: !1, validator(e) { - return qe(e) && console.warn(Nt({ api: 'createVideoMessage', desc: '没有 onProgress 回调,您将无法获取上传进度' })), !0; - } } }, createFaceMessage: { to: Lt, conversationType: Lt, payload: r(r({}, Ot), {}, { validator(e) { - return Ue(e) ? we(e.index) ? !!be(e.data) || (console.warn(Nt({ api: 'createFaceMessage', param: 'payload.data', desc: '类型必须为 String' })), !1) : (console.warn(Nt({ api: 'createFaceMessage', param: 'payload.index', desc: '类型必须为 Number' })), !1) : (console.warn(Nt({ api: 'createFaceMessage', param: 'payload', desc: '类型必须为 plain object' })), !1); - } }) }, createFileMessage: { to: Lt, conversationType: Lt, payload: r(r({}, Ot), {}, { validator(e) { - if (!Ue(e)) return console.warn(Nt({ api: 'createFileMessage', param: 'payload', desc: '类型必须为 plain object' })), !1;if (qe(e.file)) return console.warn(Nt({ api: 'createFileMessage', param: 'payload.file', desc: '不能为 undefined' })), !1;if (te) { - if (!(e.file instanceof HTMLInputElement || Ge(e.file))) return Ue(e.file) && 'undefined' !== typeof uni ? 0 !== e.file.tempFilePaths.length && 0 !== e.file.tempFiles.length || (console.warn(Nt({ api: 'createFileMessage', param: 'payload.file', desc: '您没有选择文件,无法发送' })), !1) : (console.warn(Nt({ api: 'createFileMessage', param: 'payload.file', desc: '类型必须是 HTMLInputElement 或 File' })), !1);if (e.file instanceof HTMLInputElement && 0 === e.file.files.length) return console.warn(Nt({ api: 'createFileMessage', desc: '您没有选择文件,无法发送' })), !1; - } return !0; - } }), onProgress: { type: 'Function', required: !1, validator(e) { - return qe(e) && console.warn(Nt({ api: 'createFileMessage', desc: '没有 onProgress 回调,您将无法获取上传进度' })), !0; - } } }, createLocationMessage: { to: Lt, conversationType: Lt, payload: r(r({}, Ot), {}, { validator(e) { - return Ue(e) ? be(e.description) ? we(e.longitude) ? !!we(e.latitude) || (console.warn(Nt({ api: 'createLocationMessage', param: 'payload.latitude', desc: '类型必须为 Number' })), !1) : (console.warn(Nt({ api: 'createLocationMessage', param: 'payload.longitude', desc: '类型必须为 Number' })), !1) : (console.warn(Nt({ api: 'createLocationMessage', param: 'payload.description', desc: '类型必须为 String' })), !1) : (console.warn(Nt({ api: 'createLocationMessage', param: 'payload', desc: '类型必须为 plain object' })), !1); - } }) }, createMergerMessage: { to: Lt, conversationType: Lt, payload: r(r({}, Ot), {}, { validator(e) { - if (It(e.messageList)) return console.warn(Nt({ api: 'createMergerMessage', desc: '不能为空数组' })), !1;if (It(e.compatibleText)) return console.warn(Nt({ api: 'createMergerMessage', desc: '类型必须为 String,且不能为空' })), !1;let t = !1;return e.messageList.forEach(((e) => { - e.status === Dt.FAIL && (t = !0); - })), !t || (console.warn(Nt({ api: 'createMergerMessage', desc: '不支持合并已发送失败的消息' })), !1); - } }) }, revokeMessage: [r(r({ name: 'message' }, Ot), {}, { validator(e) { - return It(e) ? (console.warn('revokeMessage 请传入消息(Message)实例'), !1) : e.conversationType === k.CONV_SYSTEM ? (console.warn('revokeMessage 不能撤回系统会话消息,只能撤回单聊消息或群消息'), !1) : !0 !== e.isRevoked || (console.warn('revokeMessage 消息已经被撤回,请勿重复操作'), !1); - } })], deleteMessage: [r(r({ name: 'messageList' }, Rt), {}, { validator(e) { - return !It(e) || (console.warn(Nt({ api: 'deleteMessage', param: 'messageList', desc: '不能为空数组' })), !1); - } })], getUserProfile: { userIDList: { type: 'Array', validator(e) { - return Fe(e) ? (0 === e.length && console.warn(Nt({ api: 'getUserProfile', param: 'userIDList', desc: '不能为空数组' })), !0) : (console.warn(Nt({ api: 'getUserProfile', param: 'userIDList', desc: '必须为数组' })), !1); - } } }, updateMyProfile: { profileCustomField: { type: 'Array', validator(e) { - return !!qe(e) || (!!Fe(e) || (console.warn(Nt({ api: 'updateMyProfile', param: 'profileCustomField', desc: '必须为数组' })), !1)); - } } }, addFriend: { to: Lt, source: { type: 'String', required: !0, validator(e) { - return !!e && (e.startsWith('AddSource_Type_') ? !(e.replace('AddSource_Type_', '').length > 8) || (console.warn(Nt({ api: 'addFriend', desc: '加好友来源字段的关键字长度不得超过8字节' })), !1) : (console.warn(Nt({ api: 'addFriend', desc: '加好友来源字段的前缀必须是:AddSource_Type_' })), !1)); - } }, remark: { type: 'String', required: !1, validator(e) { - return !(be(e) && e.length > 96) || (console.warn(Nt({ api: 'updateFriend', desc: ' 备注长度最长不得超过 96 个字节' })), !1); - } } }, deleteFriend: { userIDList: Rt }, checkFriend: { userIDList: Rt }, getFriendProfile: { userIDList: Rt }, updateFriend: { userID: Lt, remark: { type: 'String', required: !1, validator(e) { - return !(be(e) && e.length > 96) || (console.warn(Nt({ api: 'updateFriend', desc: ' 备注长度最长不得超过 96 个字节' })), !1); - } }, friendCustomField: { type: 'Array', required: !1, validator(e) { - if (e) { - if (!Fe(e)) return console.warn(Nt({ api: 'updateFriend', param: 'friendCustomField', desc: '必须为数组' })), !1;let t = !0;return e.forEach((e => (be(e.key) && -1 !== e.key.indexOf('Tag_SNS_Custom') ? be(e.value) ? e.value.length > 8 ? (console.warn(Nt({ api: 'updateFriend', desc: '好友自定义字段的关键字长度不得超过8字节' })), t = !1) : void 0 : (console.warn(Nt({ api: 'updateFriend', desc: '类型必须为 String' })), t = !1) : (console.warn(Nt({ api: 'updateFriend', desc: '好友自定义字段的前缀必须是 Tag_SNS_Custom' })), t = !1)))), t; - } return !0; - } } }, acceptFriendApplication: { userID: Lt }, refuseFriendApplication: { userID: Lt }, deleteFriendApplication: { userID: Lt }, createFriendGroup: { name: Lt }, deleteFriendGroup: { name: Lt }, addToFriendGroup: { name: Lt, userIDList: Rt }, removeFromFriendGroup: { name: Lt, userIDList: Rt }, renameFriendGroup: { oldName: Lt, newName: Lt } }; const wt = { login: 'login', logout: 'logout', on: 'on', once: 'once', off: 'off', setLogLevel: 'setLogLevel', registerPlugin: 'registerPlugin', destroy: 'destroy', createTextMessage: 'createTextMessage', createTextAtMessage: 'createTextAtMessage', createImageMessage: 'createImageMessage', createAudioMessage: 'createAudioMessage', createVideoMessage: 'createVideoMessage', createCustomMessage: 'createCustomMessage', createFaceMessage: 'createFaceMessage', createFileMessage: 'createFileMessage', createLocationMessage: 'createLocationMessage', createMergerMessage: 'createMergerMessage', downloadMergerMessage: 'downloadMergerMessage', createForwardMessage: 'createForwardMessage', sendMessage: 'sendMessage', resendMessage: 'resendMessage', revokeMessage: 'revokeMessage', deleteMessage: 'deleteMessage', getMessageList: 'getMessageList', setMessageRead: 'setMessageRead', setAllMessageRead: 'setAllMessageRead', getConversationList: 'getConversationList', getConversationProfile: 'getConversationProfile', deleteConversation: 'deleteConversation', pinConversation: 'pinConversation', getGroupList: 'getGroupList', getGroupProfile: 'getGroupProfile', createGroup: 'createGroup', joinGroup: 'joinGroup', updateGroupProfile: 'updateGroupProfile', quitGroup: 'quitGroup', dismissGroup: 'dismissGroup', changeGroupOwner: 'changeGroupOwner', searchGroupByID: 'searchGroupByID', setMessageRemindType: 'setMessageRemindType', handleGroupApplication: 'handleGroupApplication', initGroupAttributes: 'initGroupAttributes', setGroupAttributes: 'setGroupAttributes', deleteGroupAttributes: 'deleteGroupAttributes', getGroupAttributes: 'getGroupAttributes', getGroupMemberProfile: 'getGroupMemberProfile', getGroupMemberList: 'getGroupMemberList', addGroupMember: 'addGroupMember', deleteGroupMember: 'deleteGroupMember', setGroupMemberNameCard: 'setGroupMemberNameCard', setGroupMemberMuteTime: 'setGroupMemberMuteTime', setGroupMemberRole: 'setGroupMemberRole', setGroupMemberCustomField: 'setGroupMemberCustomField', getGroupOnlineMemberCount: 'getGroupOnlineMemberCount', getMyProfile: 'getMyProfile', getUserProfile: 'getUserProfile', updateMyProfile: 'updateMyProfile', getBlacklist: 'getBlacklist', addToBlacklist: 'addToBlacklist', removeFromBlacklist: 'removeFromBlacklist', getFriendList: 'getFriendList', addFriend: 'addFriend', deleteFriend: 'deleteFriend', checkFriend: 'checkFriend', updateFriend: 'updateFriend', getFriendProfile: 'getFriendProfile', getFriendApplicationList: 'getFriendApplicationList', refuseFriendApplication: 'refuseFriendApplication', deleteFriendApplication: 'deleteFriendApplication', acceptFriendApplication: 'acceptFriendApplication', setFriendApplicationRead: 'setFriendApplicationRead', getFriendGroupList: 'getFriendGroupList', createFriendGroup: 'createFriendGroup', renameFriendGroup: 'renameFriendGroup', deleteFriendGroup: 'deleteFriendGroup', addToFriendGroup: 'addToFriendGroup', removeFromFriendGroup: 'removeFromFriendGroup', callExperimentalAPI: 'callExperimentalAPI' }; const bt = 'sign'; const Pt = 'message'; const Ut = 'user'; const Ft = 'c2c'; const qt = 'group'; const Vt = 'sns'; const Kt = 'groupMember'; const xt = 'conversation'; const Bt = 'context'; const Ht = 'storage'; const jt = 'eventStat'; const Wt = 'netMonitor'; const Yt = 'bigDataChannel'; const $t = 'upload'; const zt = 'plugin'; const Jt = 'syncUnreadMessage'; const Xt = 'session'; const Qt = 'channel'; const Zt = 'message_loss_detection'; const en = 'cloudControl'; const tn = 'worker'; const nn = 'pullGroupMessage'; const on = 'qualityStat'; const an = 'commercialConfig'; const sn = (function () { - function e(n) { - t(this, e), this._moduleManager = n, this._className = ''; - } return o(e, [{ key: 'isLoggedIn', value() { - return this._moduleManager.getModule(Bt).isLoggedIn(); - } }, { key: 'isOversea', value() { - return this._moduleManager.getModule(Bt).isOversea(); - } }, { key: 'getMyUserID', value() { - return this._moduleManager.getModule(Bt).getUserID(); - } }, { key: 'getModule', value(e) { - return this._moduleManager.getModule(e); - } }, { key: 'getPlatform', value() { - return oe; - } }, { key: 'getNetworkType', value() { - return this._moduleManager.getModule(Wt).getNetworkType(); - } }, { key: 'probeNetwork', value() { - return this._moduleManager.getModule(Wt).probe(); - } }, { key: 'getCloudConfig', value(e) { - return this._moduleManager.getModule(en).getCloudConfig(e); - } }, { key: 'emitOuterEvent', value(e, t) { - this._moduleManager.getOuterEmitterInstance().emit(e, t); - } }, { key: 'emitInnerEvent', value(e, t) { - this._moduleManager.getInnerEmitterInstance().emit(e, t); - } }, { key: 'getInnerEmitterInstance', value() { - return this._moduleManager.getInnerEmitterInstance(); - } }, { key: 'generateTjgID', value(e) { - return `${this._moduleManager.getModule(Bt).getTinyID()}-${e.random}`; - } }, { key: 'filterModifiedMessage', value(e) { - if (!It(e)) { - const t = e.filter((e => !0 === e.isModified));t.length > 0 && this.emitOuterEvent(D.MESSAGE_MODIFIED, t); - } - } }, { key: 'filterUnmodifiedMessage', value(e) { - return It(e) ? [] : e.filter((e => !1 === e.isModified)); - } }, { key: 'request', value(e) { - return this._moduleManager.getModule(Xt).request(e); - } }, { key: 'canIUse', value(e) { - return this._moduleManager.getModule(an).hasPurchasedFeature(e); - } }]), e; - }()); const rn = 'wslogin'; const cn = 'wslogout'; const un = 'wshello'; const ln = 'KickOther'; const dn = 'getmsg'; const pn = 'authkey'; const gn = 'sendmsg'; const hn = 'send_group_msg'; const _n = 'portrait_get_all'; const fn = 'portrait_set'; const mn = 'black_list_get'; const Mn = 'black_list_add'; const vn = 'black_list_delete'; const yn = 'msgwithdraw'; const In = 'msgreaded'; const Cn = 'set_c2c_peer_mute_notifications'; const Tn = 'get_c2c_peer_mute_notifications'; const Sn = 'getroammsg'; const Dn = 'get_peer_read_time'; const kn = 'delete_c2c_msg_ramble'; const En = 'page_get'; const An = 'get'; const Nn = 'delete'; const Ln = 'top'; const Rn = 'deletemsg'; const On = 'get_joined_group_list'; const Gn = 'get_group_self_member_info'; const wn = 'create_group'; const bn = 'destroy_group'; const Pn = 'modify_group_base_info'; const Un = 'apply_join_group'; const Fn = 'apply_join_group_noauth'; const qn = 'quit_group'; const Vn = 'get_group_public_info'; const Kn = 'change_group_owner'; const xn = 'handle_apply_join_group'; const Bn = 'handle_invite_join_group'; const Hn = 'group_msg_recall'; const jn = 'msg_read_report'; const Wn = 'read_all_unread_msg'; const Yn = 'group_msg_get'; const $n = 'get_pendency'; const zn = 'deletemsg'; const Jn = 'get_msg'; const Xn = 'get_msg_noauth'; const Qn = 'get_online_member_num'; const Zn = 'delete_group_ramble_msg_by_seq'; const eo = 'set_group_attr'; const to = 'modify_group_attr'; const no = 'delete_group_attr'; const oo = 'clear_group_attr'; const ao = 'get_group_attr'; const so = 'get_group_member_info'; const ro = 'get_specified_group_member_info'; const io = 'add_group_member'; const co = 'delete_group_member'; const uo = 'modify_group_member_info'; const lo = 'cos'; const po = 'pre_sig'; const go = 'tim_web_report_v2'; const ho = 'alive'; const _o = 'msg_push'; const fo = 'ws_msg_push_ack'; const mo = 'stat_forceoffline'; const Mo = 'save_relay_json_msg'; const vo = 'get_relay_json_msg'; const yo = 'fetch_config'; const Io = 'push_configv2'; const Co = 'fetch_imsdk_purchase_bitsv2'; const To = 'push_imsdk_purchase_bitsv2'; const So = 'notify2'; const Do = { NO_SDKAPPID: 2e3, NO_ACCOUNT_TYPE: 2001, NO_IDENTIFIER: 2002, NO_USERSIG: 2003, NO_TINYID: 2022, NO_A2KEY: 2023, USER_NOT_LOGGED_IN: 2024, REPEAT_LOGIN: 2025, COS_UNDETECTED: 2040, COS_GET_SIG_FAIL: 2041, MESSAGE_SEND_FAIL: 2100, MESSAGE_LIST_CONSTRUCTOR_NEED_OPTIONS: 2103, MESSAGE_SEND_NEED_MESSAGE_INSTANCE: 2105, MESSAGE_SEND_INVALID_CONVERSATION_TYPE: 2106, MESSAGE_FILE_IS_EMPTY: 2108, MESSAGE_ONPROGRESS_FUNCTION_ERROR: 2109, MESSAGE_REVOKE_FAIL: 2110, MESSAGE_DELETE_FAIL: 2111, MESSAGE_UNREAD_ALL_FAIL: 2112, MESSAGE_IMAGE_SELECT_FILE_FIRST: 2251, MESSAGE_IMAGE_TYPES_LIMIT: 2252, MESSAGE_IMAGE_SIZE_LIMIT: 2253, MESSAGE_AUDIO_UPLOAD_FAIL: 2300, MESSAGE_AUDIO_SIZE_LIMIT: 2301, MESSAGE_VIDEO_UPLOAD_FAIL: 2350, MESSAGE_VIDEO_SIZE_LIMIT: 2351, MESSAGE_VIDEO_TYPES_LIMIT: 2352, MESSAGE_FILE_UPLOAD_FAIL: 2400, MESSAGE_FILE_SELECT_FILE_FIRST: 2401, MESSAGE_FILE_SIZE_LIMIT: 2402, MESSAGE_FILE_URL_IS_EMPTY: 2403, MESSAGE_MERGER_TYPE_INVALID: 2450, MESSAGE_MERGER_KEY_INVALID: 2451, MESSAGE_MERGER_DOWNLOAD_FAIL: 2452, MESSAGE_FORWARD_TYPE_INVALID: 2453, CONVERSATION_NOT_FOUND: 2500, USER_OR_GROUP_NOT_FOUND: 2501, CONVERSATION_UN_RECORDED_TYPE: 2502, ILLEGAL_GROUP_TYPE: 2600, CANNOT_JOIN_WORK: 2601, CANNOT_CHANGE_OWNER_IN_AVCHATROOM: 2620, CANNOT_CHANGE_OWNER_TO_SELF: 2621, CANNOT_DISMISS_Work: 2622, MEMBER_NOT_IN_GROUP: 2623, CANNOT_USE_GRP_ATTR_NOT_AVCHATROOM: 2641, CANNOT_USE_GRP_ATTR_AVCHATROOM_UNJOIN: 2642, JOIN_GROUP_FAIL: 2660, CANNOT_ADD_MEMBER_IN_AVCHATROOM: 2661, CANNOT_JOIN_NON_AVCHATROOM_WITHOUT_LOGIN: 2662, CANNOT_KICK_MEMBER_IN_AVCHATROOM: 2680, NOT_OWNER: 2681, CANNOT_SET_MEMBER_ROLE_IN_WORK_AND_AVCHATROOM: 2682, INVALID_MEMBER_ROLE: 2683, CANNOT_SET_SELF_MEMBER_ROLE: 2684, CANNOT_MUTE_SELF: 2685, NOT_MY_FRIEND: 2700, ALREADY_MY_FRIEND: 2701, FRIEND_GROUP_EXISTED: 2710, FRIEND_GROUP_NOT_EXIST: 2711, FRIEND_APPLICATION_NOT_EXIST: 2716, UPDATE_PROFILE_INVALID_PARAM: 2721, UPDATE_PROFILE_NO_KEY: 2722, ADD_BLACKLIST_INVALID_PARAM: 2740, DEL_BLACKLIST_INVALID_PARAM: 2741, CANNOT_ADD_SELF_TO_BLACKLIST: 2742, ADD_FRIEND_INVALID_PARAM: 2760, NETWORK_ERROR: 2800, NETWORK_TIMEOUT: 2801, NETWORK_BASE_OPTIONS_NO_URL: 2802, NETWORK_UNDEFINED_SERVER_NAME: 2803, NETWORK_PACKAGE_UNDEFINED: 2804, NO_NETWORK: 2805, CONVERTOR_IRREGULAR_PARAMS: 2900, NOTICE_RUNLOOP_UNEXPECTED_CONDITION: 2901, NOTICE_RUNLOOP_OFFSET_LOST: 2902, UNCAUGHT_ERROR: 2903, GET_LONGPOLL_ID_FAILED: 2904, INVALID_OPERATION: 2905, OVER_FREQUENCY_LIMIT: 2996, CANNOT_FIND_PROTOCOL: 2997, CANNOT_FIND_MODULE: 2998, SDK_IS_NOT_READY: 2999, LONG_POLL_KICK_OUT: 91101, MESSAGE_A2KEY_EXPIRED: 20002, ACCOUNT_A2KEY_EXPIRED: 70001, LONG_POLL_API_PARAM_ERROR: 90001, HELLO_ANSWER_KICKED_OUT: 1002, OPEN_SERVICE_OVERLOAD_ERROR: 60022 }; const ko = '无 SDKAppID'; const Eo = '无 userID'; const Ao = '无 userSig'; const No = '无 tinyID'; const Lo = '无 a2key'; const Ro = '用户未登录'; const Oo = '重复登录'; const Go = '未检测到 COS 上传插件'; const wo = '获取 COS 预签名 URL 失败'; const bo = '消息发送失败'; const Po = '需要 Message 的实例'; const Uo = 'Message.conversationType 只能为 "C2C" 或 "GROUP"'; const Fo = '无法发送空文件'; const qo = '回调函数运行时遇到错误,请检查接入侧代码'; const Vo = '消息撤回失败'; const Ko = '消息删除失败'; const xo = '设置所有未读消息为已读处理失败'; const Bo = '请先选择一个图片'; const Ho = '只允许上传 jpg png jpeg gif bmp image 格式的图片'; const jo = '图片大小超过20M,无法发送'; const Wo = '语音上传失败'; const Yo = '语音大小大于20M,无法发送'; const $o = '视频上传失败'; const zo = '视频大小超过100M,无法发送'; const Jo = '只允许上传 mp4 格式的视频'; const Xo = '文件上传失败'; const Qo = '请先选择一个文件'; const Zo = '文件大小超过100M,无法发送 '; const ea = '缺少必要的参数文件 URL'; const ta = '非合并消息'; const na = '合并消息的 messageKey 无效'; const oa = '下载合并消息失败'; const aa = '选择的消息类型(如群提示消息)不可以转发'; const sa = '没有找到相应的会话,请检查传入参数'; const ra = '没有找到相应的用户或群组,请检查传入参数'; const ia = '未记录的会话类型'; const ca = '非法的群类型,请检查传入参数'; const ua = '不能加入 Work 类型的群组'; const la = 'AVChatRoom 类型的群组不能转让群主'; const da = '不能把群主转让给自己'; const pa = '不能解散 Work 类型的群组'; const ga = '用户不在该群组内'; const ha = '加群失败,请检查传入参数或重试'; const _a = 'AVChatRoom 类型的群不支持邀请群成员'; const fa = '非 AVChatRoom 类型的群组不允许匿名加群,请先登录后再加群'; const ma = '不能在 AVChatRoom 类型的群组踢人'; const Ma = '你不是群主,只有群主才有权限操作'; const va = '不能在 Work / AVChatRoom 类型的群中设置群成员身份'; const ya = '不合法的群成员身份,请检查传入参数'; const Ia = '不能设置自己的群成员身份,请检查传入参数'; const Ca = '不能将自己禁言,请检查传入参数'; const Ta = '传入 updateMyProfile 接口的参数无效'; const Sa = 'updateMyProfile 无标配资料字段或自定义资料字段'; const Da = '传入 addToBlacklist 接口的参数无效'; const ka = '传入 removeFromBlacklist 接口的参数无效'; const Ea = '不能拉黑自己'; const Aa = '网络错误'; const Na = '请求超时'; const La = '未连接到网络'; const Ra = '无效操作,如调用了未定义或者未实现的方法等'; const Oa = '无法找到协议'; const Ga = '无法找到模块'; const wa = '接口需要 SDK 处于 ready 状态后才能调用'; const ba = '超出 SDK 频率控制'; const Pa = '后台服务正忙,请稍后再试'; const Ua = 'networkRTT'; const Fa = 'messageE2EDelay'; const qa = 'sendMessageC2C'; const Va = 'sendMessageGroup'; const Ka = 'sendMessageGroupAV'; const xa = 'sendMessageRichMedia'; const Ba = 'cosUpload'; const Ha = 'messageReceivedGroup'; const ja = 'messageReceivedGroupAVPush'; const Wa = 'messageReceivedGroupAVPull'; const Ya = (a(St = {}, Ua, 2), a(St, Fa, 3), a(St, qa, 4), a(St, Va, 5), a(St, Ka, 6), a(St, xa, 7), a(St, Ha, 8), a(St, ja, 9), a(St, Wa, 10), a(St, Ba, 11), St); const $a = { info: 4, warning: 5, error: 6 }; const za = { wifi: 1, '2g': 2, '3g': 3, '4g': 4, '5g': 5, unknown: 6, none: 7, online: 8 }; const Ja = { login: 4 }; const Xa = (function () { - function n(e) { - t(this, n), this.eventType = Ja[e] || 0, this.timestamp = 0, this.networkType = 8, this.code = 0, this.message = '', this.moreMessage = '', this.extension = e, this.costTime = 0, this.duplicate = !1, this.level = 4, this._sentFlag = !1, this._startts = Ee(); - } return o(n, [{ key: 'updateTimeStamp', value() { - this.timestamp = Ee(); - } }, { key: 'start', value(e) { - return this._startts = e, this; - } }, { key: 'end', value() { - const e = this; const t = arguments.length > 0 && void 0 !== arguments[0] && arguments[0];if (!this._sentFlag) { - const n = Ee();0 === this.costTime && (this.costTime = n - this._startts), this.setMoreMessage('startts:'.concat(this._startts, ' endts:').concat(n)), t ? (this._sentFlag = !0, this._eventStatModule && this._eventStatModule.pushIn(this)) : setTimeout((() => { - e._sentFlag = !0, e._eventStatModule && e._eventStatModule.pushIn(e); - }), 0); - } - } }, { key: 'setError', value(e, t, n) { - return e instanceof Error ? (this._sentFlag || (this.setNetworkType(n), t ? (e.code && this.setCode(e.code), e.message && this.setMoreMessage(e.message)) : (this.setCode(Do.NO_NETWORK), this.setMoreMessage(La)), this.setLevel('error')), this) : (Oe.warn('SSOLogData.setError value not instanceof Error, please check!'), this); - } }, { key: 'setCode', value(t) { - return qe(t) || this._sentFlag || ('ECONNABORTED' === t && (this.code = 103), we(t) ? this.code = t : Oe.warn('SSOLogData.setCode value not a number, please check!', t, e(t))), this; - } }, { key: 'setMessage', value(e) { - return qe(e) || this._sentFlag || (we(e) && (this.message = e.toString()), be(e) && (this.message = e)), this; - } }, { key: 'setCostTime', value(e) { - return this.costTime = e, this; - } }, { key: 'setLevel', value(e) { - return qe(e) || this._sentFlag || (this.level = $a[e]), this; - } }, { key: 'setMoreMessage', value(e) { - return It(this.moreMessage) ? this.moreMessage = ''.concat(e) : this.moreMessage += ' '.concat(e), this; - } }, { key: 'setNetworkType', value(e) { - if (qe(e))Oe.warn('SSOLogData.setNetworkType value is undefined, please check!');else { - const t = za[e.toLowerCase()];qe(t) || (this.networkType = t); - } return this; - } }, { key: 'getStartTs', value() { - return this._startts; - } }], [{ key: 'bindEventStatModule', value(e) { - n.prototype._eventStatModule = e; - } }]), n; - }()); const Qa = 'sdkConstruct'; const Za = 'sdkReady'; const es = 'login'; const ts = 'logout'; const ns = 'kickedOut'; const os = 'registerPlugin'; const as = 'kickOther'; const ss = 'wsConnect'; const rs = 'wsOnOpen'; const is = 'wsOnClose'; const cs = 'wsOnError'; const us = 'networkChange'; const ls = 'getCosAuthKey'; const ds = 'getCosPreSigUrl'; const ps = 'upload'; const gs = 'sendMessage'; const hs = 'getC2CRoamingMessages'; const _s = 'getGroupRoamingMessages'; const fs = 'revokeMessage'; const ms = 'deleteMessage'; const Ms = 'setC2CMessageRead'; const vs = 'setGroupMessageRead'; const ys = 'emptyMessageBody'; const Is = 'getPeerReadTime'; const Cs = 'uploadMergerMessage'; const Ts = 'downloadMergerMessage'; const Ss = 'jsonParseError'; const Ds = 'messageE2EDelayException'; const ks = 'getConversationList'; const Es = 'getConversationProfile'; const As = 'deleteConversation'; const Ns = 'pinConversation'; const Ls = 'getConversationListInStorage'; const Rs = 'syncConversationList'; const Os = 'setAllMessageRead'; const Gs = 'createGroup'; const ws = 'applyJoinGroup'; const bs = 'quitGroup'; const Ps = 'searchGroupByID'; const Us = 'changeGroupOwner'; const Fs = 'handleGroupApplication'; const qs = 'handleGroupInvitation'; const Vs = 'setMessageRemindType'; const Ks = 'dismissGroup'; const xs = 'updateGroupProfile'; const Bs = 'getGroupList'; const Hs = 'getGroupProfile'; const js = 'getGroupListInStorage'; const Ws = 'getGroupLastSequence'; const Ys = 'getGroupMissingMessage'; const $s = 'pagingGetGroupList'; const zs = 'getGroupSimplifiedInfo'; const Js = 'joinWithoutAuth'; const Xs = 'initGroupAttributes'; const Qs = 'setGroupAttributes'; const Zs = 'deleteGroupAttributes'; const er = 'getGroupAttributes'; const tr = 'getGroupMemberList'; const nr = 'getGroupMemberProfile'; const or = 'addGroupMember'; const ar = 'deleteGroupMember'; const sr = 'setGroupMemberMuteTime'; const rr = 'setGroupMemberNameCard'; const ir = 'setGroupMemberRole'; const cr = 'setGroupMemberCustomField'; const ur = 'getGroupOnlineMemberCount'; const lr = 'longPollingAVError'; const dr = 'messageLoss'; const pr = 'messageStacked'; const gr = 'getUserProfile'; const hr = 'updateMyProfile'; const _r = 'getBlacklist'; const fr = 'addToBlacklist'; const mr = 'removeFromBlacklist'; const Mr = 'callbackFunctionError'; const vr = 'fetchCloudControlConfig'; const yr = 'pushedCloudControlConfig'; const Ir = 'fetchCommercialConfig'; const Cr = 'pushedCommercialConfig'; const Tr = 'error'; const Sr = 'lastMessageNotExist'; const Dr = (function () { - function e(n) { - t(this, e), this.type = k.MSG_TEXT, this.content = { text: n.text || '' }; - } return o(e, [{ key: 'setText', value(e) { - this.content.text = e; - } }, { key: 'sendable', value() { - return 0 !== this.content.text.length; - } }]), e; - }()); const kr = { JSON: { TYPE: { C2C: { NOTICE: 1, COMMON: 9, EVENT: 10 }, GROUP: { COMMON: 3, TIP: 4, SYSTEM: 5, TIP2: 6 }, FRIEND: { NOTICE: 7 }, PROFILE: { NOTICE: 8 } }, SUBTYPE: { C2C: { COMMON: 0, READED: 92, KICKEDOUT: 96 }, GROUP: { COMMON: 0, LOVEMESSAGE: 1, TIP: 2, REDPACKET: 3 } }, OPTIONS: { GROUP: { JOIN: 1, QUIT: 2, KICK: 3, SET_ADMIN: 4, CANCEL_ADMIN: 5, MODIFY_GROUP_INFO: 6, MODIFY_MEMBER_INFO: 7 } } }, PROTOBUF: {}, IMAGE_TYPES: { ORIGIN: 1, LARGE: 2, SMALL: 3 }, IMAGE_FORMAT: { JPG: 1, JPEG: 1, GIF: 2, PNG: 3, BMP: 4, UNKNOWN: 255 } }; const Er = { NICK: 'Tag_Profile_IM_Nick', GENDER: 'Tag_Profile_IM_Gender', BIRTHDAY: 'Tag_Profile_IM_BirthDay', LOCATION: 'Tag_Profile_IM_Location', SELFSIGNATURE: 'Tag_Profile_IM_SelfSignature', ALLOWTYPE: 'Tag_Profile_IM_AllowType', LANGUAGE: 'Tag_Profile_IM_Language', AVATAR: 'Tag_Profile_IM_Image', MESSAGESETTINGS: 'Tag_Profile_IM_MsgSettings', ADMINFORBIDTYPE: 'Tag_Profile_IM_AdminForbidType', LEVEL: 'Tag_Profile_IM_Level', ROLE: 'Tag_Profile_IM_Role' }; const Ar = { UNKNOWN: 'Gender_Type_Unknown', FEMALE: 'Gender_Type_Female', MALE: 'Gender_Type_Male' }; const Nr = { NONE: 'AdminForbid_Type_None', SEND_OUT: 'AdminForbid_Type_SendOut' }; const Lr = { NEED_CONFIRM: 'AllowType_Type_NeedConfirm', ALLOW_ANY: 'AllowType_Type_AllowAny', DENY_ANY: 'AllowType_Type_DenyAny' }; const Rr = 'JoinedSuccess'; const Or = 'WaitAdminApproval'; const Gr = (function () { - function e(n) { - t(this, e), this._imageMemoryURL = '', ee ? this.createImageDataASURLInWXMiniApp(n.file) : this.createImageDataASURLInWeb(n.file), this._initImageInfoModel(), this.type = k.MSG_IMAGE, this._percent = 0, this.content = { imageFormat: n.imageFormat || kr.IMAGE_FORMAT.UNKNOWN, uuid: n.uuid, imageInfoArray: [] }, this.initImageInfoArray(n.imageInfoArray), this._defaultImage = 'http://imgcache.qq.com/open/qcloud/video/act/webim-images/default.jpg', this._autoFixUrl(); - } return o(e, [{ key: '_initImageInfoModel', value() { - const e = this;this._ImageInfoModel = function (t) { - this.instanceID = Je(9999999), this.sizeType = t.type || 0, this.type = 0, this.size = t.size || 0, this.width = t.width || 0, this.height = t.height || 0, this.imageUrl = t.url || '', this.url = t.url || e._imageMemoryURL || e._defaultImage; - }, this._ImageInfoModel.prototype = { setSizeType(e) { - this.sizeType = e; - }, setType(e) { - this.type = e; - }, setImageUrl(e) { - e && (this.imageUrl = e); - }, getImageUrl() { - return this.imageUrl; - } }; - } }, { key: 'initImageInfoArray', value(e) { - for (let t = 0, n = null, o = null;t <= 2;)o = qe(e) || qe(e[t]) ? { type: 0, size: 0, width: 0, height: 0, url: '' } : e[t], (n = new this._ImageInfoModel(o)).setSizeType(t + 1), n.setType(t), this.addImageInfo(n), t++;this.updateAccessSideImageInfoArray(); - } }, { key: 'updateImageInfoArray', value(e) { - for (var t, n = this.content.imageInfoArray.length, o = 0;o < n;o++)t = this.content.imageInfoArray[o], e[o].size && (t.size = e[o].size), e[o].url && t.setImageUrl(e[o].url), e[o].width && (t.width = e[o].width), e[o].height && (t.height = e[o].height); - } }, { key: '_autoFixUrl', value() { - for (let e = this.content.imageInfoArray.length, t = '', n = '', o = ['http', 'https'], a = null, s = 0;s < e;s++) this.content.imageInfoArray[s].url && '' !== (a = this.content.imageInfoArray[s]).imageUrl && (n = a.imageUrl.slice(0, a.imageUrl.indexOf('://') + 1), t = a.imageUrl.slice(a.imageUrl.indexOf('://') + 1), o.indexOf(n) < 0 && (n = 'https:'), this.content.imageInfoArray[s].setImageUrl([n, t].join(''))); - } }, { key: 'updatePercent', value(e) { - this._percent = e, this._percent > 1 && (this._percent = 1); - } }, { key: 'updateImageFormat', value(e) { - this.content.imageFormat = kr.IMAGE_FORMAT[e.toUpperCase()] || kr.IMAGE_FORMAT.UNKNOWN; - } }, { key: 'createImageDataASURLInWeb', value(e) { - void 0 !== e && e.files.length > 0 && (this._imageMemoryURL = window.URL.createObjectURL(e.files[0])); - } }, { key: 'createImageDataASURLInWXMiniApp', value(e) { - e && e.url && (this._imageMemoryURL = e.url); - } }, { key: 'replaceImageInfo', value(e, t) { - this.content.imageInfoArray[t] instanceof this._ImageInfoModel || (this.content.imageInfoArray[t] = e); - } }, { key: 'addImageInfo', value(e) { - this.content.imageInfoArray.length >= 3 || this.content.imageInfoArray.push(e); - } }, { key: 'updateAccessSideImageInfoArray', value() { - const e = this.content.imageInfoArray; const t = e[0]; const n = t.width; const o = void 0 === n ? 0 : n; const a = t.height; const s = void 0 === a ? 0 : a;0 !== o && 0 !== s && (_t(e), Object.assign(e[2], ht({ originWidth: o, originHeight: s, min: 720 }))); - } }, { key: 'sendable', value() { - return 0 !== this.content.imageInfoArray.length && ('' !== this.content.imageInfoArray[0].imageUrl && 0 !== this.content.imageInfoArray[0].size); - } }]), e; - }()); const wr = (function () { - function e(n) { - t(this, e), this.type = k.MSG_FACE, this.content = n || null; - } return o(e, [{ key: 'sendable', value() { - return null !== this.content; - } }]), e; - }()); const br = (function () { - function e(n) { - t(this, e), this.type = k.MSG_AUDIO, this._percent = 0, this.content = { downloadFlag: 2, second: n.second, size: n.size, url: n.url, remoteAudioUrl: n.url || '', uuid: n.uuid }; - } return o(e, [{ key: 'updatePercent', value(e) { - this._percent = e, this._percent > 1 && (this._percent = 1); - } }, { key: 'updateAudioUrl', value(e) { - this.content.remoteAudioUrl = e; - } }, { key: 'sendable', value() { - return '' !== this.content.remoteAudioUrl; - } }]), e; - }()); const Pr = { from: !0, groupID: !0, groupName: !0, to: !0 }; const Ur = (function () { - function e(n) { - t(this, e), this.type = k.MSG_GRP_TIP, this.content = {}, this._initContent(n); - } return o(e, [{ key: '_initContent', value(e) { - const t = this;Object.keys(e).forEach(((n) => { - switch (n) { - case 'remarkInfo':break;case 'groupProfile':t.content.groupProfile = {}, t._initGroupProfile(e[n]);break;case 'operatorInfo':case 'memberInfoList':break;case 'msgMemberInfo':t.content.memberList = e[n], Object.defineProperty(t.content, 'msgMemberInfo', { get() { - return Oe.warn('!!! 禁言的群提示消息中的 payload.msgMemberInfo 属性即将废弃,请使用 payload.memberList 属性替代。 \n', 'msgMemberInfo 中的 shutupTime 属性对应更改为 memberList 中的 muteTime 属性,表示禁言时长。 \n', '参考:群提示消息 https://web.sdk.qcloud.com/im/doc/zh-cn/Message.html#.GroupTipPayload'), t.content.memberList.map((e => ({ userID: e.userID, shutupTime: e.muteTime }))); - } });break;case 'onlineMemberInfo':break;case 'memberNum':t.content[n] = e[n], t.content.memberCount = e[n];break;default:t.content[n] = e[n]; - } - })), this.content.userIDList || (this.content.userIDList = [this.content.operatorID]); - } }, { key: '_initGroupProfile', value(e) { - for (let t = Object.keys(e), n = 0;n < t.length;n++) { - const o = t[n];Pr[o] && (this.content.groupProfile[o] = e[o]); - } - } }]), e; - }()); const Fr = { from: !0, groupID: !0, groupName: !0, to: !0 }; const qr = (function () { - function e(n) { - t(this, e), this.type = k.MSG_GRP_SYS_NOTICE, this.content = {}, this._initContent(n); - } return o(e, [{ key: '_initContent', value(e) { - const t = this;Object.keys(e).forEach(((n) => { - switch (n) { - case 'memberInfoList':break;case 'remarkInfo':t.content.handleMessage = e[n];break;case 'groupProfile':t.content.groupProfile = {}, t._initGroupProfile(e[n]);break;default:t.content[n] = e[n]; - } - })); - } }, { key: '_initGroupProfile', value(e) { - for (let t = Object.keys(e), n = 0;n < t.length;n++) { - const o = t[n];Fr[o] && ('groupName' === o ? this.content.groupProfile.name = e[o] : this.content.groupProfile[o] = e[o]); - } - } }]), e; - }()); const Vr = (function () { - function e(n) { - t(this, e), this.type = k.MSG_FILE, this._percent = 0;const o = this._getFileInfo(n);this.content = { downloadFlag: 2, fileUrl: n.url || '', uuid: n.uuid, fileName: o.name || '', fileSize: o.size || 0 }; - } return o(e, [{ key: '_getFileInfo', value(e) { - if (!qe(e.fileName) && !qe(e.fileSize)) return { size: e.fileSize, name: e.fileName };const t = e.file.files[0];if (Z) { - if (t.path && -1 !== t.path.indexOf('.')) { - const n = t.path.slice(t.path.lastIndexOf('.') + 1).toLowerCase();t.type = n, t.name || (t.name = ''.concat(Je(999999), '.').concat(n)); - }t.name || (t.type = '', t.name = t.path.slice(t.path.lastIndexOf('/') + 1).toLowerCase()), t.suffix && (t.type = t.suffix), t.url || (t.url = t.path); - } return { size: t.size, name: t.name }; - } }, { key: 'updatePercent', value(e) { - this._percent = e, this._percent > 1 && (this._percent = 1); - } }, { key: 'updateFileUrl', value(e) { - this.content.fileUrl = e; - } }, { key: 'sendable', value() { - return '' !== this.content.fileUrl && ('' !== this.content.fileName && 0 !== this.content.fileSize); - } }]), e; - }()); const Kr = (function () { - function e(n) { - t(this, e), this.type = k.MSG_CUSTOM, this.content = { data: n.data || '', description: n.description || '', extension: n.extension || '' }; - } return o(e, [{ key: 'setData', value(e) { - return this.content.data = e, this; - } }, { key: 'setDescription', value(e) { - return this.content.description = e, this; - } }, { key: 'setExtension', value(e) { - return this.content.extension = e, this; - } }, { key: 'sendable', value() { - return 0 !== this.content.data.length || 0 !== this.content.description.length || 0 !== this.content.extension.length; - } }]), e; - }()); const xr = (function () { - function e(n) { - t(this, e), this.type = k.MSG_VIDEO, this._percent = 0, this.content = { remoteVideoUrl: n.remoteVideoUrl || n.videoUrl || '', videoFormat: n.videoFormat, videoSecond: parseInt(n.videoSecond, 10), videoSize: n.videoSize, videoUrl: n.videoUrl, videoDownloadFlag: 2, videoUUID: n.videoUUID, thumbUUID: n.thumbUUID, thumbFormat: n.thumbFormat, thumbWidth: n.thumbWidth, thumbHeight: n.thumbHeight, thumbSize: n.thumbSize, thumbDownloadFlag: 2, thumbUrl: n.thumbUrl }; - } return o(e, [{ key: 'updatePercent', value(e) { - this._percent = e, this._percent > 1 && (this._percent = 1); - } }, { key: 'updateVideoUrl', value(e) { - e && (this.content.remoteVideoUrl = e); - } }, { key: 'sendable', value() { - return '' !== this.content.remoteVideoUrl; - } }]), e; - }()); const Br = (function () { - function e(n) { - t(this, e), this.type = k.MSG_LOCATION;const o = n.description; const a = n.longitude; const s = n.latitude;this.content = { description: o, longitude: a, latitude: s }; - } return o(e, [{ key: 'sendable', value() { - return !0; - } }]), e; - }()); const Hr = (function () { - function e(n) { - if (t(this, e), this.from = n.from, this.messageSender = n.from, this.time = n.time, this.messageSequence = n.sequence, this.clientSequence = n.clientSequence || n.sequence, this.messageRandom = n.random, this.cloudCustomData = n.cloudCustomData || '', n.ID) this.nick = n.nick || '', this.avatar = n.avatar || '', this.messageBody = [{ type: n.type, payload: n.payload }], n.conversationType.startsWith(k.CONV_C2C) ? this.receiverUserID = n.to : n.conversationType.startsWith(k.CONV_GROUP) && (this.receiverGroupID = n.to), this.messageReceiver = n.to;else { - this.nick = n.nick || '', this.avatar = n.avatar || '', this.messageBody = [];const o = n.elements[0].type; const a = n.elements[0].content;this._patchRichMediaPayload(o, a), o === k.MSG_MERGER ? this.messageBody.push({ type: o, payload: new jr(a).content }) : this.messageBody.push({ type: o, payload: a }), n.groupID && (this.receiverGroupID = n.groupID, this.messageReceiver = n.groupID), n.to && (this.receiverUserID = n.to, this.messageReceiver = n.to); - } - } return o(e, [{ key: '_patchRichMediaPayload', value(e, t) { - e === k.MSG_IMAGE ? t.imageInfoArray.forEach(((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 === k.MSG_VIDEO ? !t.remoteVideoUrl && t.videoUrl && (t.remoteVideoUrl = t.videoUrl) : e === k.MSG_AUDIO ? !t.remoteAudioUrl && t.url && (t.remoteAudioUrl = t.url) : e === k.MSG_FILE && !t.fileUrl && t.url && (t.fileUrl = t.url, t.url = void 0); - } }]), e; - }()); var jr = (function () { - function e(n) { - if (t(this, e), this.type = k.MSG_MERGER, this.content = { downloadKey: '', pbDownloadKey: '', messageList: [], title: '', abstractList: [], compatibleText: '', version: 0, layersOverLimit: !1 }, n.downloadKey) { - const o = n.downloadKey; const a = n.pbDownloadKey; const s = n.title; const r = n.abstractList; const i = n.compatibleText; const c = n.version;this.content.downloadKey = o, this.content.pbDownloadKey = a, this.content.title = s, this.content.abstractList = r, this.content.compatibleText = i, this.content.version = c || 0; - } else if (It(n.messageList))1 === n.layersOverLimit && (this.content.layersOverLimit = !0);else { - const u = n.messageList; const l = n.title; const d = n.abstractList; const p = n.compatibleText; const g = n.version; const h = [];u.forEach(((e) => { - if (!It(e)) { - const t = new Hr(e);h.push(t); - } - })), this.content.messageList = h, this.content.title = l, this.content.abstractList = d, this.content.compatibleText = p, this.content.version = g || 0; - }Oe.debug('MergerElement.content:', this.content); - } return o(e, [{ key: 'sendable', value() { - return !It(this.content.messageList) || !It(this.content.downloadKey); - } }]), e; - }()); const Wr = { 1: k.MSG_PRIORITY_HIGH, 2: k.MSG_PRIORITY_NORMAL, 3: k.MSG_PRIORITY_LOW, 4: k.MSG_PRIORITY_LOWEST }; const Yr = (function () { - function e(n) { - t(this, e), this.ID = '', this.conversationID = n.conversationID || null, this.conversationType = n.conversationType || k.CONV_C2C, this.conversationSubType = n.conversationSubType, this.time = n.time || Math.ceil(Date.now() / 1e3), this.sequence = n.sequence || 0, this.clientSequence = n.clientSequence || n.sequence || 0, this.random = n.random || 0 === n.random ? n.random : Je(), this.priority = this._computePriority(n.priority), this.nick = n.nick || '', this.avatar = n.avatar || '', this.isPeerRead = !1, this.nameCard = '', this._elements = [], this.isPlaceMessage = n.isPlaceMessage || 0, this.isRevoked = 2 === n.isPlaceMessage || 8 === n.msgFlagBits, this.from = n.from || null, this.to = n.to || null, this.flow = '', this.isSystemMessage = n.isSystemMessage || !1, this.protocol = n.protocol || 'JSON', this.isResend = !1, this.isRead = !1, this.status = n.status || Dt.SUCCESS, this._onlineOnlyFlag = !1, this._groupAtInfoList = [], this._relayFlag = !1, this.atUserList = [], this.cloudCustomData = n.cloudCustomData || '', this.isDeleted = !1, this.isModified = !1, this._isExcludedFromUnreadCount = !(!n.messageControlInfo || 1 !== n.messageControlInfo.excludedFromUnreadCount), this._isExcludedFromLastMessage = !(!n.messageControlInfo || 1 !== n.messageControlInfo.excludedFromLastMessage), this.reInitialize(n.currentUser), this.extractGroupInfo(n.groupProfile || null), this.handleGroupAtInfo(n); - } return o(e, [{ key: 'getElements', value() { - return this._elements; - } }, { key: 'extractGroupInfo', value(e) { - if (null !== e) { - be(e.nick) && (this.nick = e.nick), be(e.avatar) && (this.avatar = e.avatar);const t = e.messageFromAccountExtraInformation;Ue(t) && be(t.nameCard) && (this.nameCard = t.nameCard); - } - } }, { key: 'handleGroupAtInfo', value(e) { - const t = this;e.payload && e.payload.atUserList && e.payload.atUserList.forEach(((e) => { - e !== k.MSG_AT_ALL ? (t._groupAtInfoList.push({ groupAtAllFlag: 0, groupAtUserID: e }), t.atUserList.push(e)) : (t._groupAtInfoList.push({ groupAtAllFlag: 1 }), t.atUserList.push(k.MSG_AT_ALL)); - })), Fe(e.groupAtInfo) && e.groupAtInfo.forEach(((e) => { - 0 === e.groupAtAllFlag ? t.atUserList.push(e.groupAtUserID) : 1 === e.groupAtAllFlag && t.atUserList.push(k.MSG_AT_ALL); - })); - } }, { key: 'getGroupAtInfoList', value() { - return this._groupAtInfoList; - } }, { key: '_initProxy', value() { - this._elements[0] && (this.payload = this._elements[0].content, this.type = this._elements[0].type); - } }, { key: 'reInitialize', value(e) { - e && (this.status = this.from ? Dt.SUCCESS : Dt.UNSEND, !this.from && (this.from = e)), this._initFlow(e), this._initSequence(e), this._concatConversationID(e), this.generateMessageID(e); - } }, { key: 'isSendable', value() { - return 0 !== this._elements.length && ('function' !== typeof this._elements[0].sendable ? (Oe.warn(''.concat(this._elements[0].type, ' need "boolean : sendable()" method')), !1) : this._elements[0].sendable()); - } }, { key: '_initTo', value(e) { - this.conversationType === k.CONV_GROUP && (this.to = e.groupID); - } }, { key: '_initSequence', value(e) { - 0 === this.clientSequence && e && (this.clientSequence = (function (e) { - if (!e) return Oe.error('autoIncrementIndex(string: key) need key parameter'), !1;if (void 0 === et[e]) { - const t = new Date; let n = '3'.concat(t.getHours()).slice(-2); let o = '0'.concat(t.getMinutes()).slice(-2); let a = '0'.concat(t.getSeconds()).slice(-2);et[e] = parseInt([n, o, a, '0001'].join('')), n = null, o = null, a = null, Oe.log('autoIncrementIndex start index:'.concat(et[e])); - } return et[e]++; - }(e))), 0 === this.sequence && this.conversationType === k.CONV_C2C && (this.sequence = this.clientSequence); - } }, { key: 'generateMessageID', value(e) { - const t = e === this.from ? 1 : 0; const n = this.sequence > 0 ? this.sequence : this.clientSequence;this.ID = ''.concat(this.conversationID, '-').concat(n, '-') - .concat(this.random, '-') - .concat(t); - } }, { key: '_initFlow', value(e) { - '' !== e && (e === this.from ? (this.flow = 'out', this.isRead = !0) : this.flow = 'in'); - } }, { key: '_concatConversationID', value(e) { - const t = this.to; let n = ''; const o = this.conversationType;o !== k.CONV_SYSTEM ? (n = o === k.CONV_C2C ? e === this.from ? t : this.from : this.to, this.conversationID = ''.concat(o).concat(n)) : this.conversationID = k.CONV_SYSTEM; - } }, { key: 'isElement', value(e) { - return e instanceof Dr || e instanceof Gr || e instanceof wr || e instanceof br || e instanceof Vr || e instanceof xr || e instanceof Ur || e instanceof qr || e instanceof Kr || e instanceof Br || e instanceof jr; - } }, { key: 'setElement', value(e) { - const t = this;if (this.isElement(e)) return this._elements = [e], void this._initProxy();const n = function (e) { - if (e.type && e.content) switch (e.type) { - case k.MSG_TEXT:t.setTextElement(e.content);break;case k.MSG_IMAGE:t.setImageElement(e.content);break;case k.MSG_AUDIO:t.setAudioElement(e.content);break;case k.MSG_FILE:t.setFileElement(e.content);break;case k.MSG_VIDEO:t.setVideoElement(e.content);break;case k.MSG_CUSTOM:t.setCustomElement(e.content);break;case k.MSG_LOCATION:t.setLocationElement(e.content);break;case k.MSG_GRP_TIP:t.setGroupTipElement(e.content);break;case k.MSG_GRP_SYS_NOTICE:t.setGroupSystemNoticeElement(e.content);break;case k.MSG_FACE:t.setFaceElement(e.content);break;case k.MSG_MERGER:t.setMergerElement(e.content);break;default:Oe.warn(e.type, e.content, 'no operation......'); - } - };if (Fe(e)) for (let o = 0;o < e.length;o++)n(e[o]);else n(e);this._initProxy(); - } }, { key: 'clearElement', value() { - this._elements.length = 0; - } }, { key: 'setTextElement', value(e) { - const t = 'string' === typeof e ? e : e.text; const n = new Dr({ text: t });this._elements.push(n); - } }, { key: 'setImageElement', value(e) { - const t = new Gr(e);this._elements.push(t); - } }, { key: 'setAudioElement', value(e) { - const t = new br(e);this._elements.push(t); - } }, { key: 'setFileElement', value(e) { - const t = new Vr(e);this._elements.push(t); - } }, { key: 'setVideoElement', value(e) { - const t = new xr(e);this._elements.push(t); - } }, { key: 'setLocationElement', value(e) { - const t = new Br(e);this._elements.push(t); - } }, { key: 'setCustomElement', value(e) { - const t = new Kr(e);this._elements.push(t); - } }, { key: 'setGroupTipElement', value(e) { - let t = {}; const n = e.operationType;It(e.memberInfoList) ? e.operatorInfo && (t = e.operatorInfo) : n !== k.GRP_TIP_MBR_JOIN && n !== k.GRP_TIP_MBR_KICKED_OUT && n !== k.GRP_TIP_MBR_SET_ADMIN && n !== k.GRP_TIP_MBR_CANCELED_ADMIN || (t = e.memberInfoList[0]);const o = t; const a = o.nick; const s = o.avatar;be(a) && (this.nick = a), be(s) && (this.avatar = s);const r = new Ur(e);this._elements.push(r); - } }, { key: 'setGroupSystemNoticeElement', value(e) { - const t = new qr(e);this._elements.push(t); - } }, { key: 'setFaceElement', value(e) { - const t = new wr(e);this._elements.push(t); - } }, { key: 'setMergerElement', value(e) { - const t = new jr(e);this._elements.push(t); - } }, { key: 'setIsRead', value(e) { - this.isRead = e; - } }, { key: 'setRelayFlag', value(e) { - this._relayFlag = e; - } }, { key: 'getRelayFlag', value() { - return this._relayFlag; - } }, { key: '_computePriority', value(e) { - if (qe(e)) return k.MSG_PRIORITY_NORMAL;if (be(e) && -1 !== Object.values(Wr).indexOf(e)) return e;if (we(e)) { - const t = `${e}`;if (-1 !== Object.keys(Wr).indexOf(t)) return Wr[t]; - } return k.MSG_PRIORITY_NORMAL; - } }, { key: 'setNickAndAvatar', value(e) { - const t = e.nick; const n = e.avatar;be(t) && (this.nick = t), be(n) && (this.avatar = n); - } }, { key: 'setNameCard', value(e) { - be(e) && (this.nameCard = e); - } }, { key: 'elements', get() { - return Oe.warn('!!!Message 实例的 elements 属性即将废弃,请尽快修改。使用 type 和 payload 属性处理单条消息,兼容组合消息使用 _elements 属性!!!'), this._elements; - } }]), e; - }()); const $r = function (e) { - return { code: 0, data: e || {} }; - }; const zr = 'https://cloud.tencent.com/document/product/'; const Jr = '您可以在即时通信 IM 控制台的【开发辅助工具(https://console.cloud.tencent.com/im-detail/tool-usersig)】页面校验 UserSig。'; const Xr = 'UserSig 非法,请使用官网提供的 API 重新生成 UserSig('.concat(zr, '269/32688)。'); const Qr = '#.E6.B6.88.E6.81.AF.E5.85.83.E7.B4.A0-timmsgelement'; const Zr = { 70001: 'UserSig 已过期,请重新生成。建议 UserSig 有效期设置不小于24小时。', 70002: 'UserSig 长度为0,请检查传入的 UserSig 是否正确。', 70003: Xr, 70005: Xr, 70009: 'UserSig 验证失败,可能因为生成 UserSig 时混用了其他 SDKAppID 的私钥或密钥导致,请使用对应 SDKAppID 下的私钥或密钥重新生成 UserSig('.concat(zr, '269/32688)。'), 70013: '请求中的 UserID 与生成 UserSig 时使用的 UserID 不匹配。'.concat(Jr), 70014: '请求中的 SDKAppID 与生成 UserSig 时使用的 SDKAppID 不匹配。'.concat(Jr), 70016: '密钥不存在,UserSig 验证失败,请在即时通信 IM 控制台获取密钥('.concat(zr, '269/32578#.E8.8E.B7.E5.8F.96.E5.AF.86.E9.92.A5)。'), 70020: 'SDKAppID 未找到,请在即时通信 IM 控制台确认应用信息。', 70050: 'UserSig 验证次数过于频繁。请检查 UserSig 是否正确,并于1分钟后重新验证。'.concat(Jr), 70051: '帐号被拉入黑名单。', 70052: 'UserSig 已经失效,请重新生成,再次尝试。', 70107: '因安全原因被限制登录,请不要频繁登录。', 70169: '请求的用户帐号不存在。', 70114: ''.concat('服务端内部超时,请稍后重试。'), 70202: ''.concat('服务端内部超时,请稍后重试。'), 70206: '请求中批量数量不合法。', 70402: '参数非法,请检查必填字段是否填充,或者字段的填充是否满足协议要求。', 70403: '请求失败,需要 App 管理员权限。', 70398: '帐号数超限。如需创建多于100个帐号,请将应用升级为专业版,具体操作指引请参见购买指引('.concat(zr, '269/32458)。'), 70500: ''.concat('服务端内部错误,请重试。'), 71e3: '删除帐号失败。仅支持删除体验版帐号,您当前应用为专业版,暂不支持帐号删除。', 20001: '请求包非法。', 20002: 'UserSig 或 A2 失效。', 20003: '消息发送方或接收方 UserID 无效或不存在,请检查 UserID 是否已导入即时通信 IM。', 20004: '网络异常,请重试。', 20005: ''.concat('服务端内部错误,请重试。'), 20006: '触发发送'.concat('单聊消息', '之前回调,App 后台返回禁止下发该消息。'), 20007: '发送'.concat('单聊消息', ',被对方拉黑,禁止发送。消息发送状态默认展示为失败,您可以登录控制台修改该场景下的消息发送状态展示结果,具体操作请参见消息保留设置(').concat(zr, '269/38656)。'), 20009: '消息发送双方互相不是好友,禁止发送(配置'.concat('单聊消息', '校验好友关系才会出现)。'), 20010: '发送'.concat('单聊消息', ',自己不是对方的好友(单向关系),禁止发送。'), 20011: '发送'.concat('单聊消息', ',对方不是自己的好友(单向关系),禁止发送。'), 20012: '发送方被禁言,该条消息被禁止发送。', 20016: '消息撤回超过了时间限制(默认2分钟)。', 20018: '删除漫游内部错误。', 90001: 'JSON 格式解析失败,请检查请求包是否符合 JSON 规范。', 90002: ''.concat('JSON 格式请求包体', '中 MsgBody 不符合消息格式描述,或者 MsgBody 不是 Array 类型,请参考 TIMMsgElement 对象的定义(').concat(zr, '269/2720') - .concat(Qr, ')。'), 90003: ''.concat('JSON 格式请求包体', '中缺少 To_Account 字段或者 To_Account 帐号不存在。'), 90005: ''.concat('JSON 格式请求包体', '中缺少 MsgRandom 字段或者 MsgRandom 字段不是 Integer 类型。'), 90006: ''.concat('JSON 格式请求包体', '中缺少 MsgTimeStamp 字段或者 MsgTimeStamp 字段不是 Integer 类型。'), 90007: ''.concat('JSON 格式请求包体', '中 MsgBody 类型不是 Array 类型,请将其修改为 Array 类型。'), 90008: ''.concat('JSON 格式请求包体', '中缺少 From_Account 字段或者 From_Account 帐号不存在。'), 90009: '请求需要 App 管理员权限。', 90010: ''.concat('JSON 格式请求包体', '不符合消息格式描述,请参考 TIMMsgElement 对象的定义(').concat(zr, '269/2720') - .concat(Qr, ')。'), 90011: '批量发消息目标帐号超过500,请减少 To_Account 中目标帐号数量。', 90012: 'To_Account 没有注册或不存在,请确认 To_Account 是否导入即时通信 IM 或者是否拼写错误。', 90026: '消息离线存储时间错误(最多不能超过7天)。', 90031: ''.concat('JSON 格式请求包体', '中 SyncOtherMachine 字段不是 Integer 类型。'), 90044: ''.concat('JSON 格式请求包体', '中 MsgLifeTime 字段不是 Integer 类型。'), 90048: '请求的用户帐号不存在。', 90054: '撤回请求中的 MsgKey 不合法。', 90994: ''.concat('服务端内部错误,请重试。'), 90995: ''.concat('服务端内部错误,请重试。'), 91e3: ''.concat('服务端内部错误,请重试。'), 90992: ''.concat('服务端内部错误,请重试。', '如果所有请求都返回该错误码,且 App 配置了第三方回调,请检查 App 服务端是否正常向即时通信 IM 后台服务端返回回调结果。'), 93e3: 'JSON 数据包超长,消息包体请不要超过8k。', 91101: 'Web 端长轮询被踢(Web 端同时在线实例个数超出限制)。', 10002: ''.concat('服务端内部错误,请重试。'), 10003: '请求中的接口名称错误,请核对接口名称并重试。', 10004: '参数非法,请根据错误描述检查请求是否正确。', 10005: '请求包体中携带的帐号数量过多。', 10006: '操作频率限制,请尝试降低调用的频率。', 10007: '操作权限不足,例如 Work '.concat('群组', '中普通成员尝试执行踢人操作,但只有 App 管理员才有权限。'), 10008: '请求非法,可能是请求中携带的签名信息验证不正确,请再次尝试。', 10009: '该群不允许群主主动退出。', 10010: ''.concat('群组', '不存在,或者曾经存在过,但是目前已经被解散。'), 10011: '解析 JSON 包体失败,请检查包体的格式是否符合 JSON 格式。', 10012: '发起操作的 UserID 非法,请检查发起操作的用户 UserID 是否填写正确。', 10013: '被邀请加入的用户已经是群成员。', 10014: '群已满员,无法将请求中的用户加入'.concat('群组', ',如果是批量加人,可以尝试减少加入用户的数量。'), 10015: '找不到指定 ID 的'.concat('群组', '。'), 10016: 'App 后台通过第三方回调拒绝本次操作。', 10017: '因被禁言而不能发送消息,请检查发送者是否被设置禁言。', 10018: '应答包长度超过最大包长(1MB),请求的内容过多,请尝试减少单次请求的数据量。', 10019: '请求的用户帐号不存在。', 10021: ''.concat('群组', ' ID 已被使用,请选择其他的').concat('群组', ' ID。'), 10023: '发消息的频率超限,请延长两次发消息时间的间隔。', 10024: '此邀请或者申请请求已经被处理。', 10025: ''.concat('群组', ' ID 已被使用,并且操作者为群主,可以直接使用。'), 10026: '该 SDKAppID 请求的命令字已被禁用。', 10030: '请求撤回的消息不存在。', 10031: '消息撤回超过了时间限制(默认2分钟)。', 10032: '请求撤回的消息不支持撤回操作。', 10033: ''.concat('群组', '类型不支持消息撤回操作。'), 10034: '该消息类型不支持删除操作。', 10035: '直播群和在线成员广播大群不支持删除消息。', 10036: '直播群创建数量超过了限制,请参考价格说明('.concat(zr, '269/11673)购买预付费套餐“IM直播群”。'), 10037: '单个用户可创建和加入的'.concat('群组', '数量超过了限制,请参考价格说明(').concat(zr, '269/11673)购买或升级预付费套餐“单人可创建与加入') - .concat('群组', '数”。'), 10038: '群成员数量超过限制,请参考价格说明('.concat(zr, '269/11673)购买或升级预付费套餐“扩展群人数上限”。'), 10041: '该应用(SDKAppID)已配置不支持群消息撤回。', 10050: '群属性 key 不存在', 10056: '请在写入群属性前先使用 getGroupAttributes 接口更新本地群属性,避免冲突。', 30001: '请求参数错误,请根据错误描述检查请求参数', 30002: 'SDKAppID 不匹配', 30003: '请求的用户帐号不存在', 30004: '请求需要 App 管理员权限', 30005: '关系链字段中包含敏感词', 30006: ''.concat('服务端内部错误,请重试。'), 30007: ''.concat('网络超时,请稍后重试. '), 30008: '并发写导致写冲突,建议使用批量方式', 30009: '后台禁止该用户发起加好友请求', 30010: '自己的好友数已达系统上限', 30011: '分组已达系统上限', 30012: '未决数已达系统上限', 30014: '对方的好友数已达系统上限', 30515: '请求添加好友时,对方在自己的黑名单中,不允许加好友', 30516: '请求添加好友时,对方的加好友验证方式是不允许任何人添加自己为好友', 30525: '请求添加好友时,自己在对方的黑名单中,不允许加好友', 30539: '等待对方同意', 30540: '添加好友请求被安全策略打击,请勿频繁发起添加好友请求', 31704: '与请求删除的帐号之间不存在好友关系', 31707: '删除好友请求被安全策略打击,请勿频繁发起删除好友请求' }; const ei = (function (e) { - i(o, e);const n = f(o);function o(e) { - let a;return t(this, o), (a = n.call(this)).code = e.code, a.message = Zr[e.code] || e.message, a.data = e.data || {}, a; - } return o; - }(p(Error))); let ti = null; const ni = function (e) { - ti = e; - }; const oi = function (e) { - return Promise.resolve($r(e)); - }; const ai = function (e) { - const t = arguments.length > 1 && void 0 !== arguments[1] && arguments[1];if (e instanceof ei) return t && null !== ti && ti.emit(D.ERROR, e), Promise.reject(e);if (e instanceof Error) { - const n = new ei({ code: Do.UNCAUGHT_ERROR, message: e.message });return t && null !== ti && ti.emit(D.ERROR, n), Promise.reject(n); - } if (qe(e) || qe(e.code) || qe(e.message))Oe.error('IMPromise.reject 必须指定code(错误码)和message(错误信息)!!!');else { - if (we(e.code) && be(e.message)) { - const o = new ei(e);return t && null !== ti && ti.emit(D.ERROR, o), Promise.reject(o); - }Oe.error('IMPromise.reject code(错误码)必须为数字,message(错误信息)必须为字符串!!!'); - } - }; const si = (function (e) { - i(a, e);const n = f(a);function a(e) { - let o;return t(this, a), (o = n.call(this, e))._className = 'C2CModule', o; - } return o(a, [{ key: 'onNewC2CMessage', value(e) { - const t = e.dataList; const n = e.isInstantMessage; const o = e.C2CRemainingUnreadList; const a = e.C2CPairUnreadList;Oe.debug(''.concat(this._className, '.onNewC2CMessage count:').concat(t.length, ' isInstantMessage:') - .concat(n));const s = this._newC2CMessageStoredAndSummary({ dataList: t, C2CRemainingUnreadList: o, C2CPairUnreadList: a, isInstantMessage: n }); const r = s.conversationOptionsList; const i = s.messageList; const c = s.isUnreadC2CMessage;(this.filterModifiedMessage(i), r.length > 0) && this.getModule(xt).onNewMessage({ conversationOptionsList: r, isInstantMessage: n, isUnreadC2CMessage: c });const u = this.filterUnmodifiedMessage(i);n && u.length > 0 && this.emitOuterEvent(D.MESSAGE_RECEIVED, u), i.length = 0; - } }, { key: '_newC2CMessageStoredAndSummary', value(e) { - for (var t = e.dataList, n = e.C2CRemainingUnreadList, o = e.C2CPairUnreadList, a = e.isInstantMessage, s = null, r = [], i = [], c = {}, u = this.getModule(Yt), l = !1, d = 0, p = t.length;d < p;d++) { - const g = t[d];g.currentUser = this.getMyUserID(), g.conversationType = k.CONV_C2C, g.isSystemMessage = !!g.isSystemMessage, (qe(g.nick) || qe(g.avatar)) && (l = !0, Oe.debug(''.concat(this._className, '._newC2CMessageStoredAndSummary nick or avatar missing!'))), s = new Yr(g), g.elements = u.parseElements(g.elements, g.from), s.setElement(g.elements), s.setNickAndAvatar({ nick: g.nick, avatar: g.avatar });const h = s.conversationID;if (a) { - let _ = !1; const f = this.getModule(xt);if (s.from !== this.getMyUserID()) { - const m = f.getLatestMessageSentByPeer(h);if (m) { - const M = m.nick; const v = m.avatar;l ? s.setNickAndAvatar({ nick: M, avatar: v }) : M === s.nick && v === s.avatar || (_ = !0); - } - } else { - const y = f.getLatestMessageSentByMe(h);if (y) { - const I = y.nick; const C = y.avatar;I === s.nick && C === s.avatar || f.modifyMessageSentByMe({ conversationID: h, latestNick: s.nick, latestAvatar: s.avatar }); - } - } let T = 1 === t[d].isModified;if (f.isMessageSentByCurrentInstance(s) ? s.isModified = T : T = !1, 0 === g.msgLifeTime)s._onlineOnlyFlag = !0, i.push(s);else { - if (!f.pushIntoMessageList(i, s, T)) continue;_ && (f.modifyMessageSentByPeer({ conversationID: h, latestNick: s.nick, latestAvatar: s.avatar }), f.updateUserProfileSpecifiedKey({ conversationID: h, nick: s.nick, avatar: s.avatar })); - } this.getModule(on).addMessageDelay({ currentTime: Date.now(), time: s.time }); - } if (0 !== g.msgLifeTime) { - if (!1 === s._onlineOnlyFlag) if (qe(c[h])) { - let S = 0;'in' === s.flow && (s._isExcludedFromUnreadCount || (S = 1)), c[h] = r.push({ conversationID: h, unreadCount: S, type: s.conversationType, subType: s.conversationSubType, lastMessage: s._isExcludedFromLastMessage ? '' : s }) - 1; - } else { - const D = c[h];r[D].type = s.conversationType, r[D].subType = s.conversationSubType, r[D].lastMessage = s._isExcludedFromLastMessage ? '' : s, 'in' === s.flow && (s._isExcludedFromUnreadCount || r[D].unreadCount++); - } - } else s._onlineOnlyFlag = !0; - } let E = !1;if (Fe(o)) for (let A = function (e, t) { - if (o[e].unreadCount > 0) { - E = !0;const n = r.find((t => t.conversationID === 'C2C'.concat(o[e].from)));n ? n.unreadCount = o[e].unreadCount : r.push({ conversationID: 'C2C'.concat(o[e].from), unreadCount: o[e].unreadCount, type: k.CONV_C2C }); - } - }, N = 0, L = o.length;N < L;N++)A(N);if (Fe(n)) for (let R = function (e, t) { - r.find((t => t.conversationID === 'C2C'.concat(n[e].from))) || r.push({ conversationID: 'C2C'.concat(n[e].from), type: k.CONV_C2C, lastMsgTime: n[e].lastMsgTime }); - }, O = 0, G = n.length;O < G;O++)R(O);return { conversationOptionsList: r, messageList: i, isUnreadC2CMessage: E }; - } }, { key: 'onC2CMessageRevoked', value(e) { - const t = this;Oe.debug(''.concat(this._className, '.onC2CMessageRevoked count:').concat(e.dataList.length));const n = this.getModule(xt); const o = []; let a = null;e.dataList.forEach(((e) => { - if (e.c2cMessageRevokedNotify) { - const s = e.c2cMessageRevokedNotify.revokedInfos;qe(s) || s.forEach(((e) => { - const s = t.getMyUserID() === e.from ? ''.concat(k.CONV_C2C).concat(e.to) : ''.concat(k.CONV_C2C).concat(e.from);(a = n.revoke(s, e.sequence, e.random)) && o.push(a); - })); - } - })), 0 !== o.length && (n.onMessageRevoked(o), this.emitOuterEvent(D.MESSAGE_REVOKED, o)); - } }, { key: 'onC2CMessageReadReceipt', value(e) { - const t = this;e.dataList.forEach(((e) => { - if (!It(e.c2cMessageReadReceipt)) { - const n = e.c2cMessageReadReceipt.to;e.c2cMessageReadReceipt.uinPairReadArray.forEach(((e) => { - const o = e.peerReadTime;Oe.debug(''.concat(t._className, '._onC2CMessageReadReceipt to:').concat(n, ' peerReadTime:') - .concat(o));const a = ''.concat(k.CONV_C2C).concat(n); const s = t.getModule(xt);s.recordPeerReadTime(a, o), s.updateMessageIsPeerReadProperty(a, o); - })); - } - })); - } }, { key: 'onC2CMessageReadNotice', value(e) { - const t = this;e.dataList.forEach(((e) => { - if (!It(e.c2cMessageReadNotice)) { - const n = t.getModule(xt);e.c2cMessageReadNotice.uinPairReadArray.forEach(((e) => { - const o = e.from; const a = e.peerReadTime;Oe.debug(''.concat(t._className, '.onC2CMessageReadNotice from:').concat(o, ' lastReadTime:') - .concat(a));const s = ''.concat(k.CONV_C2C).concat(o);n.updateIsReadAfterReadReport({ conversationID: s, lastMessageTime: a }), n.updateUnreadCount(s); - })); - } - })); - } }, { key: 'sendMessage', value(e, t) { - const n = this._createC2CMessagePack(e, t);return this.request(n); - } }, { key: '_createC2CMessagePack', value(e, t) { - let n = null;t && (t.offlinePushInfo && (n = t.offlinePushInfo), !0 === t.onlineUserOnly && (n ? n.disablePush = !0 : n = { disablePush: !0 }));let o = '';be(e.cloudCustomData) && e.cloudCustomData.length > 0 && (o = e.cloudCustomData);const a = [];if (Ue(t) && Ue(t.messageControlInfo)) { - const s = t.messageControlInfo; const r = s.excludedFromUnreadCount; const i = s.excludedFromLastMessage;!0 === r && a.push('NoUnread'), !0 === i && a.push('NoLastMsg'); - } return { protocolName: gn, tjgID: this.generateTjgID(e), requestData: { fromAccount: this.getMyUserID(), toAccount: e.to, msgTimeStamp: Math.ceil(Date.now() / 1e3), msgBody: e.getElements(), cloudCustomData: o, msgSeq: e.sequence, msgRandom: e.random, msgLifeTime: this.isOnlineMessage(e, t) ? 0 : void 0, nick: e.nick, avatar: e.avatar, offlinePushInfo: n ? { pushFlag: !0 === n.disablePush ? 1 : 0, title: n.title || '', desc: n.description || '', ext: n.extension || '', apnsInfo: { badgeMode: !0 === n.ignoreIOSBadge ? 1 : 0 }, androidInfo: { OPPOChannelID: n.androidOPPOChannelID || '' } } : void 0, messageControlInfo: a } }; - } }, { key: 'isOnlineMessage', value(e, t) { - return !(!t || !0 !== t.onlineUserOnly); - } }, { key: 'revokeMessage', value(e) { - return this.request({ protocolName: yn, requestData: { msgInfo: { fromAccount: e.from, toAccount: e.to, msgSeq: e.sequence, msgRandom: e.random, msgTimeStamp: e.time } } }); - } }, { key: 'deleteMessage', value(e) { - const t = e.to; const n = e.keyList;return Oe.log(''.concat(this._className, '.deleteMessage toAccount:').concat(t, ' count:') - .concat(n.length)), this.request({ protocolName: kn, requestData: { fromAccount: this.getMyUserID(), to: t, keyList: n } }); - } }, { key: 'setMessageRead', value(e) { - const t = this; const n = e.conversationID; const o = e.lastMessageTime; const a = ''.concat(this._className, '.setMessageRead');Oe.log(''.concat(a, ' conversationID:').concat(n, ' lastMessageTime:') - .concat(o)), we(o) || Oe.warn(''.concat(a, ' 请勿修改 Conversation.lastMessage.lastTime,否则可能会导致已读上报结果不准确'));const s = new Xa(Ms);return s.setMessage('conversationID:'.concat(n, ' lastMessageTime:').concat(o)), this.request({ protocolName: In, requestData: { C2CMsgReaded: { cookie: '', C2CMsgReadedItem: [{ toAccount: n.replace('C2C', ''), lastMessageTime: o, receipt: 1 }] } } }).then((() => { - s.setNetworkType(t.getNetworkType()).end(), Oe.log(''.concat(a, ' ok'));const e = t.getModule(xt);return e.updateIsReadAfterReadReport({ conversationID: n, lastMessageTime: o }), e.updateUnreadCount(n), $r(); - })) - .catch((e => (t.probeNetwork().then(((t) => { - const n = m(t, 2); const o = n[0]; const a = n[1];s.setError(e, o, a).end(); - })), Oe.log(''.concat(a, ' failed. error:'), e), ai(e)))); - } }, { key: 'getRoamingMessage', value(e) { - const t = this; const n = ''.concat(this._className, '.getRoamingMessage'); const o = e.peerAccount; const a = e.conversationID; const s = e.count; const r = e.lastMessageTime; const i = e.messageKey; const c = 'peerAccount:'.concat(o, ' count:').concat(s || 15, ' lastMessageTime:') - .concat(r || 0, ' messageKey:') - .concat(i);Oe.log(''.concat(n, ' ').concat(c));const u = new Xa(hs);return this.request({ protocolName: Sn, requestData: { peerAccount: o, count: s || 15, lastMessageTime: r || 0, messageKey: i } }).then(((e) => { - const o = e.data; const s = o.complete; const r = o.messageList; const i = o.messageKey; const l = o.lastMessageTime;qe(r) ? Oe.log(''.concat(n, ' ok. complete:').concat(s, ' but messageList is undefined!')) : Oe.log(''.concat(n, ' ok. complete:').concat(s, ' count:') - .concat(r.length)), u.setNetworkType(t.getNetworkType()).setMessage(''.concat(c, ' complete:').concat(s, ' length:') - .concat(r.length)) - .end();const d = t.getModule(xt);1 === s && d.setCompleted(a);const p = d.storeRoamingMessage(r, a);d.modifyMessageList(a), d.updateIsRead(a), d.updateRoamingMessageKeyAndTime(a, i, l);const g = d.getPeerReadTime(a);if (Oe.log(''.concat(n, ' update isPeerRead property. conversationID:').concat(a, ' peerReadTime:') - .concat(g)), g)d.updateMessageIsPeerReadProperty(a, g);else { - const h = a.replace(k.CONV_C2C, '');t.getRemotePeerReadTime([h]).then((() => { - d.updateMessageIsPeerReadProperty(a, d.getPeerReadTime(a)); - })); - } return p; - })) - .catch((e => (t.probeNetwork().then(((t) => { - const n = m(t, 2); const o = n[0]; const a = n[1];u.setMessage(c).setError(e, o, a) - .end(); - })), Oe.warn(''.concat(n, ' failed. error:'), e), ai(e)))); - } }, { key: 'getRemotePeerReadTime', value(e) { - const t = this; const n = ''.concat(this._className, '.getRemotePeerReadTime');if (It(e)) return Oe.warn(''.concat(n, ' userIDList is empty!')), Promise.resolve();const o = new Xa(Is);return Oe.log(''.concat(n, ' userIDList:').concat(e)), this.request({ protocolName: Dn, requestData: { userIDList: e } }).then(((a) => { - const s = a.data.peerReadTimeList;Oe.log(''.concat(n, ' ok. peerReadTimeList:').concat(s));for (var r = '', i = t.getModule(xt), c = 0;c < e.length;c++)r += ''.concat(e[c], '-').concat(s[c], ' '), s[c] > 0 && i.recordPeerReadTime('C2C'.concat(e[c]), s[c]);o.setNetworkType(t.getNetworkType()).setMessage(r) - .end(); - })) - .catch(((e) => { - t.probeNetwork().then(((t) => { - const n = m(t, 2); const a = n[0]; const s = n[1];o.setError(e, a, s).end(); - })), Oe.warn(''.concat(n, ' failed. error:'), e); - })); - } }]), a; - }(sn)); const ri = (function () { - function e(n) { - t(this, e), this.list = new Map, this._className = 'MessageListHandler', this._latestMessageSentByPeerMap = new Map, this._latestMessageSentByMeMap = new Map, this._groupLocalLastMessageSequenceMap = new Map; - } return o(e, [{ key: 'getLocalOldestMessageByConversationID', value(e) { - if (!e) return null;if (!this.list.has(e)) return null;const t = this.list.get(e).values();return t ? t.next().value : null; - } }, { key: 'pushIn', value(e) { - const t = arguments.length > 1 && void 0 !== arguments[1] && arguments[1]; const n = e.conversationID; const o = e.ID; let a = !0;this.list.has(n) || this.list.set(n, new Map);const s = this.list.get(n).has(o);if (s) { - const r = this.list.get(n).get(o);if (!t || !0 === r.isModified) return a = !1; - } return this.list.get(n).set(o, e), this._setLatestMessageSentByPeer(n, e), this._setLatestMessageSentByMe(n, e), this._setGroupLocalLastMessageSequence(n, e), a; - } }, { key: 'unshift', value(e) { - let t;if (Fe(e)) { - if (e.length > 0) { - t = e[0].conversationID;const n = e.length;this._unshiftMultipleMessages(e), this._setGroupLocalLastMessageSequence(t, e[n - 1]); - } - } else t = e.conversationID, this._unshiftSingleMessage(e), this._setGroupLocalLastMessageSequence(t, e);if (t && t.startsWith(k.CONV_C2C)) { - const o = Array.from(this.list.get(t).values()); const a = o.length;if (0 === a) return;for (let s = a - 1;s >= 0;s--) if ('out' === o[s].flow) { - this._setLatestMessageSentByMe(t, o[s]);break; - } for (let r = a - 1;r >= 0;r--) if ('in' === o[r].flow) { - this._setLatestMessageSentByPeer(t, o[r]);break; - } - } - } }, { key: '_unshiftSingleMessage', value(e) { - const t = e.conversationID; const n = e.ID;if (!this.list.has(t)) return this.list.set(t, new Map), void this.list.get(t).set(n, e);const o = Array.from(this.list.get(t));o.unshift([n, e]), this.list.set(t, new Map(o)); - } }, { key: '_unshiftMultipleMessages', value(e) { - for (var t = e.length, n = [], o = e[0].conversationID, a = this.list.has(o) ? Array.from(this.list.get(o)) : [], s = 0;s < t;s++)n.push([e[s].ID, e[s]]);this.list.set(o, new Map(n.concat(a))); - } }, { key: 'remove', value(e) { - const t = e.conversationID; const n = e.ID;this.list.has(t) && this.list.get(t).delete(n); - } }, { key: 'revoke', value(e, t, n) { - if (Oe.debug('revoke message', e, t, n), this.list.has(e)) { - let o; const a = S(this.list.get(e));try { - for (a.s();!(o = a.n()).done;) { - const s = m(o.value, 2)[1];if (s.sequence === t && !s.isRevoked && (qe(n) || s.random === n)) return s.isRevoked = !0, s; - } - } catch (r) { - a.e(r); - } finally { - a.f(); - } - } return null; - } }, { key: 'removeByConversationID', value(e) { - this.list.has(e) && (this.list.delete(e), this._latestMessageSentByPeerMap.delete(e), this._latestMessageSentByMeMap.delete(e)); - } }, { key: 'updateMessageIsPeerReadProperty', value(e, t) { - const n = [];if (this.list.has(e)) { - let o; const a = S(this.list.get(e));try { - for (a.s();!(o = a.n()).done;) { - const s = m(o.value, 2)[1];s.time <= t && !s.isPeerRead && 'out' === s.flow && (s.isPeerRead = !0, n.push(s)); - } - } catch (r) { - a.e(r); - } finally { - a.f(); - }Oe.log(''.concat(this._className, '.updateMessageIsPeerReadProperty conversationID:').concat(e, ' peerReadTime:') - .concat(t, ' count:') - .concat(n.length)); - } return n; - } }, { key: 'updateMessageIsModifiedProperty', value(e) { - const t = e.conversationID; const n = e.ID;if (this.list.has(t)) { - const o = this.list.get(t).get(n);o && (o.isModified = !0); - } - } }, { key: 'hasLocalMessageList', value(e) { - return this.list.has(e); - } }, { key: 'getLocalMessageList', value(e) { - return this.hasLocalMessageList(e) ? M(this.list.get(e).values()) : []; - } }, { key: 'hasLocalMessage', value(e, t) { - return !!this.hasLocalMessageList(e) && this.list.get(e).has(t); - } }, { key: 'getLocalMessage', value(e, t) { - return this.hasLocalMessage(e, t) ? this.list.get(e).get(t) : null; - } }, { key: 'getLocalLastMessage', value(e) { - const t = this.getLocalMessageList(e);return t[t.length - 1]; - } }, { key: '_setLatestMessageSentByPeer', value(e, t) { - e.startsWith(k.CONV_C2C) && 'in' === t.flow && this._latestMessageSentByPeerMap.set(e, t); - } }, { key: '_setLatestMessageSentByMe', value(e, t) { - e.startsWith(k.CONV_C2C) && 'out' === t.flow && this._latestMessageSentByMeMap.set(e, t); - } }, { key: '_setGroupLocalLastMessageSequence', value(e, t) { - e.startsWith(k.CONV_GROUP) && this._groupLocalLastMessageSequenceMap.set(e, t.sequence); - } }, { key: 'getLatestMessageSentByPeer', value(e) { - return this._latestMessageSentByPeerMap.get(e); - } }, { key: 'getLatestMessageSentByMe', value(e) { - return this._latestMessageSentByMeMap.get(e); - } }, { key: 'getGroupLocalLastMessageSequence', value(e) { - return this._groupLocalLastMessageSequenceMap.get(e) || 0; - } }, { key: 'modifyMessageSentByPeer', value(e) { - const t = e.conversationID; const n = e.latestNick; const o = e.latestAvatar; const a = this.list.get(t);if (!It(a)) { - const s = Array.from(a.values()); const r = s.length;if (0 !== r) { - for (var i = null, c = 0, u = !1, l = r - 1;l >= 0;l--)'in' === s[l].flow && ((i = s[l]).nick !== n && (i.setNickAndAvatar({ nick: n }), u = !0), i.avatar !== o && (i.setNickAndAvatar({ avatar: o }), u = !0), u && (c += 1));Oe.log(''.concat(this._className, '.modifyMessageSentByPeer conversationID:').concat(t, ' count:') - .concat(c)); - } - } - } }, { key: 'modifyMessageSentByMe', value(e) { - const t = e.conversationID; const n = e.latestNick; const o = e.latestAvatar; const a = this.list.get(t);if (!It(a)) { - const s = Array.from(a.values()); const r = s.length;if (0 !== r) { - for (var i = null, c = 0, u = !1, l = r - 1;l >= 0;l--)'out' === s[l].flow && ((i = s[l]).nick !== n && (i.setNickAndAvatar({ nick: n }), u = !0), i.avatar !== o && (i.setNickAndAvatar({ avatar: o }), u = !0), u && (c += 1));Oe.log(''.concat(this._className, '.modifyMessageSentByMe conversationID:').concat(t, ' count:') - .concat(c)); - } - } - } }, { key: 'traversal', value() { - if (0 !== this.list.size && -1 === Oe.getLevel()) { - console.group('conversationID-messageCount');let e; const t = S(this.list);try { - for (t.s();!(e = t.n()).done;) { - const n = m(e.value, 2); const o = n[0]; const a = n[1];console.log(''.concat(o, '-').concat(a.size)); - } - } catch (s) { - t.e(s); - } finally { - t.f(); - }console.groupEnd(); - } - } }, { key: 'reset', value() { - this.list.clear(), this._latestMessageSentByPeerMap.clear(), this._latestMessageSentByMeMap.clear(), this._groupLocalLastMessageSequenceMap.clear(); - } }]), e; - }()); const ii = '_a2KeyAndTinyIDUpdated'; const ci = '_cloudConfigUpdated'; const ui = '_profileUpdated';function li(e) { - this.mixin(e); - }li.mixin = function (e) { - const t = e.prototype || e;t._isReady = !1, t.ready = function (e) { - const t = arguments.length > 1 && void 0 !== arguments[1] && arguments[1];if (e) return this._isReady ? void (t ? e.call(this) : setTimeout(e, 1)) : (this._readyQueue = this._readyQueue || [], void this._readyQueue.push(e)); - }, t.triggerReady = function () { - const e = this;this._isReady = !0, setTimeout((() => { - const t = e._readyQueue;e._readyQueue = [], t && t.length > 0 && t.forEach((function (e) { - e.call(this); - }), e); - }), 1); - }, t.resetReady = function () { - this._isReady = !1, this._readyQueue = []; - }, t.isReady = function () { - return this._isReady; - }; - };const di = ['jpg', 'jpeg', 'gif', 'png', 'bmp', 'image']; const pi = ['mp4']; const gi = 1; const hi = 2; const _i = 3; const fi = 255; const mi = (function () { - function e(n) { - const o = this;t(this, e), It(n) || (this.userID = n.userID || '', this.nick = n.nick || '', this.gender = n.gender || '', this.birthday = n.birthday || 0, this.location = n.location || '', this.selfSignature = n.selfSignature || '', this.allowType = n.allowType || k.ALLOW_TYPE_ALLOW_ANY, this.language = n.language || 0, this.avatar = n.avatar || '', this.messageSettings = n.messageSettings || 0, this.adminForbidType = n.adminForbidType || k.FORBID_TYPE_NONE, this.level = n.level || 0, this.role = n.role || 0, this.lastUpdatedTime = 0, this.profileCustomField = [], It(n.profileCustomField) || n.profileCustomField.forEach(((e) => { - o.profileCustomField.push({ key: e.key, value: e.value }); - }))); - } return o(e, [{ key: 'validate', value(e) { - let t = !0; let n = '';if (It(e)) return { valid: !1, tips: 'empty options' };if (e.profileCustomField) for (let o = e.profileCustomField.length, a = null, s = 0;s < o;s++) { - if (a = e.profileCustomField[s], !be(a.key) || -1 === a.key.indexOf('Tag_Profile_Custom')) return { valid: !1, tips: '自定义资料字段的前缀必须是 Tag_Profile_Custom' };if (!be(a.value)) return { valid: !1, tips: '自定义资料字段的 value 必须是字符串' }; - } for (const r in e) if (Object.prototype.hasOwnProperty.call(e, r)) { - if ('profileCustomField' === r) continue;if (It(e[r]) && !be(e[r]) && !we(e[r])) { - n = `key:${r}, invalid value:${e[r]}`, t = !1;continue; - } switch (r) { - case 'nick':be(e[r]) || (n = 'nick should be a string', t = !1), ze(e[r]) > 500 && (n = 'nick name limited: must less than or equal to '.concat(500, ' bytes, current size: ').concat(ze(e[r]), ' bytes'), t = !1);break;case 'gender':Ze(Ar, e.gender) || (n = `key:gender, invalid value:${e.gender}`, t = !1);break;case 'birthday':we(e.birthday) || (n = 'birthday should be a number', t = !1);break;case 'location':be(e.location) || (n = 'location should be a string', t = !1);break;case 'selfSignature':be(e.selfSignature) || (n = 'selfSignature should be a string', t = !1);break;case 'allowType':Ze(Lr, e.allowType) || (n = `key:allowType, invalid value:${e.allowType}`, t = !1);break;case 'language':we(e.language) || (n = 'language should be a number', t = !1);break;case 'avatar':be(e.avatar) || (n = 'avatar should be a string', t = !1);break;case 'messageSettings':0 !== e.messageSettings && 1 !== e.messageSettings && (n = 'messageSettings should be 0 or 1', t = !1);break;case 'adminForbidType':Ze(Nr, e.adminForbidType) || (n = `key:adminForbidType, invalid value:${e.adminForbidType}`, t = !1);break;case 'level':we(e.level) || (n = 'level should be a number', t = !1);break;case 'role':we(e.role) || (n = 'role should be a number', t = !1);break;default:n = `unknown key:${r} ${e[r]}`, t = !1; - } - } return { valid: t, tips: n }; - } }]), e; - }()); const Mi = function e(n) { - t(this, e), this.value = n, this.next = null; - }; const vi = (function () { - function e(n) { - t(this, e), this.MAX_LENGTH = n, this.pTail = null, this.pNodeToDel = null, this.map = new Map, Oe.debug('SinglyLinkedList init MAX_LENGTH:'.concat(this.MAX_LENGTH)); - } return o(e, [{ key: 'set', value(e) { - const t = new Mi(e);if (this.map.size < this.MAX_LENGTH)null === this.pTail ? (this.pTail = t, this.pNodeToDel = t) : (this.pTail.next = t, this.pTail = t), this.map.set(e, 1);else { - let n = this.pNodeToDel;this.pNodeToDel = this.pNodeToDel.next, this.map.delete(n.value), n.next = null, n = null, this.pTail.next = t, this.pTail = t, this.map.set(e, 1); - } - } }, { key: 'has', value(e) { - return this.map.has(e); - } }, { key: 'delete', value(e) { - this.has(e) && this.map.delete(e); - } }, { key: 'tail', value() { - return this.pTail; - } }, { key: 'size', value() { - return this.map.size; - } }, { key: 'data', value() { - return Array.from(this.map.keys()); - } }, { key: 'reset', value() { - for (var e;null !== this.pNodeToDel;)e = this.pNodeToDel, this.pNodeToDel = this.pNodeToDel.next, e.next = null, e = null;this.pTail = null, this.map.clear(); - } }]), e; - }()); const yi = ['groupID', 'name', 'avatar', 'type', 'introduction', 'notification', 'ownerID', 'selfInfo', 'createTime', 'infoSequence', 'lastInfoTime', 'lastMessage', 'nextMessageSeq', 'memberNum', 'maxMemberNum', 'memberList', 'joinOption', 'groupCustomField', 'muteAllMembers']; const Ii = (function () { - function e(n) { - t(this, e), this.groupID = '', this.name = '', this.avatar = '', this.type = '', this.introduction = '', this.notification = '', this.ownerID = '', this.createTime = '', this.infoSequence = '', this.lastInfoTime = '', this.selfInfo = { messageRemindType: '', joinTime: '', nameCard: '', role: '', userID: '', memberCustomField: void 0, readedSequence: 0, excludedUnreadSequenceList: void 0 }, this.lastMessage = { lastTime: '', lastSequence: '', fromAccount: '', messageForShow: '' }, this.nextMessageSeq = '', this.memberNum = '', this.memberCount = '', this.maxMemberNum = '', this.maxMemberCount = '', this.joinOption = '', this.groupCustomField = [], this.muteAllMembers = void 0, this._initGroup(n); - } return o(e, [{ key: '_initGroup', value(e) { - for (const t in e)yi.indexOf(t) < 0 || ('selfInfo' !== t ? ('memberNum' === t && (this.memberCount = e[t]), 'maxMemberNum' === t && (this.maxMemberCount = e[t]), this[t] = e[t]) : this.updateSelfInfo(e[t])); - } }, { key: 'updateGroup', value(e) { - const t = this; const n = JSON.parse(JSON.stringify(e));n.lastMsgTime && (this.lastMessage.lastTime = n.lastMsgTime), qe(n.muteAllMembers) || ('On' === n.muteAllMembers ? n.muteAllMembers = !0 : n.muteAllMembers = !1), n.groupCustomField && st(this.groupCustomField, n.groupCustomField), qe(n.memberNum) || (this.memberCount = n.memberNum), qe(n.maxMemberNum) || (this.maxMemberCount = n.maxMemberNum), Ye(this, n, ['members', 'errorCode', 'lastMsgTime', 'groupCustomField', 'memberNum', 'maxMemberNum']), Fe(n.members) && n.members.length > 0 && n.members.forEach(((e) => { - e.userID === t.selfInfo.userID && Ye(t.selfInfo, e, ['sequence']); - })); - } }, { key: 'updateSelfInfo', value(e) { - const t = e.nameCard; const n = e.joinTime; const o = e.role; const a = e.messageRemindType; const s = e.readedSequence; const r = e.excludedUnreadSequenceList;Ye(this.selfInfo, { nameCard: t, joinTime: n, role: o, messageRemindType: a, readedSequence: s, excludedUnreadSequenceList: r }, [], ['', null, void 0, 0, NaN]); - } }, { key: 'setSelfNameCard', value(e) { - this.selfInfo.nameCard = e; - } }, { key: 'memberNum', set(e) {}, get() { - return Oe.warn('!!!v2.8.0起弃用memberNum,请使用 memberCount'), this.memberCount; - } }, { key: 'maxMemberNum', set(e) {}, get() { - return Oe.warn('!!!v2.8.0起弃用maxMemberNum,请使用 maxMemberCount'), this.maxMemberCount; - } }]), e; - }()); const Ci = function (e, t) { - if (qe(t)) return '';switch (e) { - case k.MSG_TEXT:return t.text;case k.MSG_IMAGE:return '[图片]';case k.MSG_LOCATION:return '[位置]';case k.MSG_AUDIO:return '[语音]';case k.MSG_VIDEO:return '[视频]';case k.MSG_FILE:return '[文件]';case k.MSG_CUSTOM:return '[自定义消息]';case k.MSG_GRP_TIP:return '[群提示消息]';case k.MSG_GRP_SYS_NOTICE:return '[群系统通知]';case k.MSG_FACE:return '[动画表情]';case k.MSG_MERGER:return '[聊天记录]';default:return ''; - } - }; const Ti = function (e) { - return qe(e) ? { lastTime: 0, lastSequence: 0, fromAccount: 0, messageForShow: '', payload: null, type: '', isRevoked: !1, cloudCustomData: '', onlineOnlyFlag: !1, nick: '', nameCard: '' } : e instanceof Yr ? { lastTime: e.time || 0, lastSequence: e.sequence || 0, fromAccount: e.from || '', messageForShow: Ci(e.type, e.payload), payload: e.payload || null, type: e.type || null, isRevoked: e.isRevoked || !1, cloudCustomData: e.cloudCustomData || '', onlineOnlyFlag: e._onlineOnlyFlag || !1, nick: e.nick || '', nameCard: e.nameCard || '' } : r(r({}, e), {}, { messageForShow: Ci(e.type, e.payload) }); - }; const Si = (function () { - function e(n) { - t(this, e), this.conversationID = n.conversationID || '', this.unreadCount = n.unreadCount || 0, this.type = n.type || '', this.lastMessage = Ti(n.lastMessage), n.lastMsgTime && (this.lastMessage.lastTime = n.lastMsgTime), this._isInfoCompleted = !1, this.peerReadTime = n.peerReadTime || 0, this.groupAtInfoList = [], this.remark = '', this.isPinned = n.isPinned || !1, this.messageRemindType = '', this._initProfile(n); - } return o(e, [{ key: '_initProfile', value(e) { - const t = this;Object.keys(e).forEach(((n) => { - switch (n) { - case 'userProfile':t.userProfile = e.userProfile;break;case 'groupProfile':t.groupProfile = e.groupProfile; - } - })), qe(this.userProfile) && this.type === k.CONV_C2C ? this.userProfile = new mi({ userID: e.conversationID.replace('C2C', '') }) : qe(this.groupProfile) && this.type === k.CONV_GROUP && (this.groupProfile = new Ii({ groupID: e.conversationID.replace('GROUP', '') })); - } }, { key: 'updateUnreadCount', value(e) { - const t = e.nextUnreadCount; const n = e.isFromGetConversationList; const o = e.isUnreadC2CMessage;qe(t) || (it(this.subType) ? this.unreadCount = 0 : n && this.type === k.CONV_GROUP || o && this.type === k.CONV_C2C ? this.unreadCount = t : this.unreadCount = this.unreadCount + t); - } }, { key: 'updateLastMessage', value(e) { - this.lastMessage = Ti(e); - } }, { key: 'updateGroupAtInfoList', value(e) { - let t; let n = (v(t = e.groupAtType) || y(t) || I(t) || T()).slice(0);-1 !== n.indexOf(k.CONV_AT_ME) && -1 !== n.indexOf(k.CONV_AT_ALL) && (n = [k.CONV_AT_ALL_AT_ME]);const o = { from: e.from, groupID: e.groupID, messageSequence: e.sequence, atTypeArray: n, __random: e.__random, __sequence: e.__sequence };this.groupAtInfoList.push(o), Oe.debug('Conversation.updateGroupAtInfoList conversationID:'.concat(this.conversationID), this.groupAtInfoList); - } }, { key: 'clearGroupAtInfoList', value() { - this.groupAtInfoList.length = 0; - } }, { key: 'reduceUnreadCount', value() { - this.unreadCount >= 1 && (this.unreadCount -= 1); - } }, { key: 'isLastMessageRevoked', value(e) { - const t = e.sequence; const n = e.time;return this.type === k.CONV_C2C && t === this.lastMessage.lastSequence && n === this.lastMessage.lastTime || this.type === k.CONV_GROUP && t === this.lastMessage.lastSequence; - } }, { key: 'setLastMessageRevoked', value(e) { - this.lastMessage.isRevoked = e; - } }, { key: 'toAccount', get() { - return this.conversationID.startsWith(k.CONV_C2C) ? this.conversationID.replace(k.CONV_C2C, '') : this.conversationID.startsWith(k.CONV_GROUP) ? this.conversationID.replace(k.CONV_GROUP, '') : ''; - } }, { key: 'subType', get() { - return this.groupProfile ? this.groupProfile.type : ''; - } }]), e; - }()); const Di = (function () { - function e(n) { - t(this, e), this._conversationModule = n, this._className = 'MessageRemindHandler', this._updateSequence = 0; - } return o(e, [{ key: 'getC2CMessageRemindType', value() { - const e = this; const t = ''.concat(this._className, '.getC2CMessageRemindType');return this._conversationModule.request({ protocolName: Tn, updateSequence: this._updateSequence }).then(((n) => { - Oe.log(''.concat(t, ' ok'));const o = n.data; const a = o.updateSequence; const s = o.muteFlagList;e._updateSequence = a, e._patchC2CMessageRemindType(s); - })) - .catch(((e) => { - Oe.error(''.concat(t, ' failed. error:'), e); - })); - } }, { key: '_patchC2CMessageRemindType', value(e) { - const t = this; let n = 0; let o = '';Fe(e) && e.length > 0 && e.forEach(((e) => { - const a = e.userID; const s = e.muteFlag;0 === s ? o = k.MSG_REMIND_ACPT_AND_NOTE : 1 === s ? o = k.MSG_REMIND_DISCARD : 2 === s && (o = k.MSG_REMIND_ACPT_NOT_NOTE), !0 === t._conversationModule.patchMessageRemindType({ ID: a, isC2CConversation: !0, messageRemindType: o }) && (n += 1); - })), Oe.log(''.concat(this._className, '._patchC2CMessageRemindType count:').concat(n)); - } }, { key: 'set', value(e) { - return e.groupID ? this._setGroupMessageRemindType(e) : Fe(e.userIDList) ? this._setC2CMessageRemindType(e) : void 0; - } }, { key: '_setGroupMessageRemindType', value(e) { - const t = this; const n = ''.concat(this._className, '._setGroupMessageRemindType'); const o = e.groupID; const a = e.messageRemindType; const s = 'groupID:'.concat(o, ' messageRemindType:').concat(a); const r = new Xa(Vs);return r.setMessage(s), this._getModule(Kt).modifyGroupMemberInfo({ groupID: o, messageRemindType: a, userID: this._conversationModule.getMyUserID() }) - .then((() => { - r.setNetworkType(t._conversationModule.getNetworkType()).end(), Oe.log(''.concat(n, ' ok. ').concat(s));const e = t._getModule(qt).getLocalGroupProfile(o);return e && (e.selfInfo.messageRemindType = a), t._conversationModule.patchMessageRemindType({ ID: o, isC2CConversation: !1, messageRemindType: a }) && t._emitConversationUpdate(), $r({ group: e }); - })) - .catch((e => (t._conversationModule.probeNetwork().then(((t) => { - const n = m(t, 2); const o = n[0]; const a = n[1];r.setError(e, o, a).end(); - })), Oe.error(''.concat(n, ' failed. error:'), e), ai(e)))); - } }, { key: '_setC2CMessageRemindType', value(e) { - const t = this; const n = ''.concat(this._className, '._setC2CMessageRemindType'); const o = e.userIDList; const a = e.messageRemindType; const s = o.slice(0, 30); let r = 0;a === k.MSG_REMIND_DISCARD ? r = 1 : a === k.MSG_REMIND_ACPT_NOT_NOTE && (r = 2);const i = 'userIDList:'.concat(s, ' messageRemindType:').concat(a); const c = new Xa(Vs);return c.setMessage(i), this._conversationModule.request({ protocolName: Cn, requestData: { userIDList: s, muteFlag: r } }).then(((e) => { - c.setNetworkType(t._conversationModule.getNetworkType()).end();const o = e.data; const r = o.updateSequence; const i = o.errorList;t._updateSequence = r;const u = []; const l = [];Fe(i) && i.forEach(((e) => { - u.push(e.userID), l.push({ userID: e.userID, code: e.errorCode }); - }));const d = s.filter((e => -1 === u.indexOf(e)));Oe.log(''.concat(n, ' ok. successUserIDList:').concat(d, ' failureUserIDList:') - .concat(JSON.stringify(l)));let p = 0;return d.forEach(((e) => { - t._conversationModule.patchMessageRemindType({ ID: e, isC2CConversation: !0, messageRemindType: a }) && (p += 1); - })), p >= 1 && t._emitConversationUpdate(), s.length = u.length = 0, oi({ successUserIDList: d.map((e => ({ userID: e }))), failureUserIDList: l }); - })) - .catch((e => (t._conversationModule.probeNetwork().then(((t) => { - const n = m(t, 2); const o = n[0]; const a = n[1];c.setError(e, o, a).end(); - })), Oe.error(''.concat(n, ' failed. error:'), e), ai(e)))); - } }, { key: '_getModule', value(e) { - return this._conversationModule.getModule(e); - } }, { key: '_emitConversationUpdate', value() { - this._conversationModule.emitConversationUpdate(!0, !1); - } }, { key: 'setUpdateSequence', value(e) { - this._updateSequence = e; - } }, { key: 'reset', value() { - Oe.log(''.concat(this._className, '.reset')), this._updateSequence = 0; - } }]), e; - }()); const ki = (function (e) { - i(a, e);const n = f(a);function a(e) { - let o;return t(this, a), (o = n.call(this, e))._className = 'ConversationModule', li.mixin(h(o)), o._messageListHandler = new ri, o._messageRemindHandler = new Di(h(o)), o.singlyLinkedList = new vi(100), o._pagingStatus = kt.NOT_START, o._pagingTimeStamp = 0, o._pagingStartIndex = 0, o._pagingPinnedTimeStamp = 0, o._pagingPinnedStartIndex = 0, o._conversationMap = new Map, o._tmpGroupList = [], o._tmpGroupAtTipsList = [], o._peerReadTimeMap = new Map, o._completedMap = new Map, o._roamingMessageKeyAndTimeMap = new Map, o._remoteGroupReadSequenceMap = new Map, o._initListeners(), o; - } return o(a, [{ key: '_initListeners', value() { - const e = this.getInnerEmitterInstance();e.on(ii, this._initLocalConversationList, this), e.on(ui, this._onProfileUpdated, this); - } }, { key: 'onCheckTimer', value(e) { - e % 60 == 0 && this._messageListHandler.traversal(); - } }, { key: '_initLocalConversationList', value() { - const e = this; const t = new Xa(Ls);Oe.log(''.concat(this._className, '._initLocalConversationList.'));let n = ''; const o = this._getStorageConversationList();if (o) { - for (var a = o.length, s = 0;s < a;s++) { - const r = o[s];if (r) { - if (r.conversationID === ''.concat(k.CONV_C2C, '@TLS#ERROR') || r.conversationID === ''.concat(k.CONV_C2C, '@TLS#NOT_FOUND')) continue;if (r.groupProfile) { - const i = r.groupProfile.type;if (it(i)) continue; - } - } this._conversationMap.set(o[s].conversationID, new Si(o[s])); - } this.emitConversationUpdate(!0, !1), n = 'count:'.concat(a); - } else n = 'count:0';t.setNetworkType(this.getNetworkType()).setMessage(n) - .end(), this.getModule(Ft) || this.triggerReady(), this.ready((() => { - e._tmpGroupList.length > 0 && (e.updateConversationGroupProfile(e._tmpGroupList), e._tmpGroupList.length = 0); - })), this._syncConversationList(); - } }, { key: 'onMessageSent', value(e) { - this._onSendOrReceiveMessage({ conversationOptionsList: e.conversationOptionsList, isInstantMessage: !0 }); - } }, { key: 'onNewMessage', value(e) { - this._onSendOrReceiveMessage(e); - } }, { key: '_onSendOrReceiveMessage', value(e) { - const t = this; const n = e.conversationOptionsList; const o = e.isInstantMessage; const a = void 0 === o || o; const s = e.isUnreadC2CMessage; const r = void 0 !== s && s;this._isReady ? 0 !== n.length && (this._getC2CPeerReadTime(n), this._updateLocalConversationList({ conversationOptionsList: n, isInstantMessage: a, isUnreadC2CMessage: r, isFromGetConversations: !1 }), this._setStorageConversationList(), this.emitConversationUpdate()) : this.ready((() => { - t._onSendOrReceiveMessage(e); - })); - } }, { key: 'updateConversationGroupProfile', value(e) { - const t = this;Fe(e) && 0 === e.length || (0 !== this._conversationMap.size ? (e.forEach(((e) => { - const n = 'GROUP'.concat(e.groupID);if (t._conversationMap.has(n)) { - const o = t._conversationMap.get(n);o.groupProfile = e, o.lastMessage.lastSequence < e.nextMessageSeq && (o.lastMessage.lastSequence = e.nextMessageSeq - 1), o.subType || (o.subType = e.type); - } - })), this.emitConversationUpdate(!0, !1)) : this._tmpGroupList = e); - } }, { key: '_updateConversationUserProfile', value(e) { - const t = this;e.data.forEach(((e) => { - const n = 'C2C'.concat(e.userID);t._conversationMap.has(n) && (t._conversationMap.get(n).userProfile = e); - })), this.emitConversationUpdate(!0, !1); - } }, { key: 'onMessageRevoked', value(e) { - const t = this;if (0 !== e.length) { - let n = null; let o = !1;e.forEach(((e) => { - (n = t._conversationMap.get(e.conversationID)) && n.isLastMessageRevoked(e) && (o = !0, n.setLastMessageRevoked(!0)); - })), o && this.emitConversationUpdate(!0, !1); - } - } }, { key: 'onMessageDeleted', value(e) { - if (0 !== e.length) { - e.forEach(((e) => { - e.isDeleted = !0; - }));for (var t = e[0].conversationID, n = this._messageListHandler.getLocalMessageList(t), o = {}, a = n.length - 1;a >= 0;a--) if (!n[a].isDeleted) { - o = n[a];break; - } const s = this._conversationMap.get(t);if (s) { - let r = !1;s.lastMessage.lastSequence === o.sequence && s.lastMessage.lastTime === o.time || (It(o) && (o = void 0), s.updateLastMessage(o), r = !0, Oe.log(''.concat(this._className, '.onMessageDeleted. update conversationID:').concat(t, ' with lastMessage:'), s.lastMessage)), t.startsWith(k.CONV_C2C) && this.updateUnreadCount(t), r && this.emitConversationUpdate(!0, !1); - } - } - } }, { key: 'onNewGroupAtTips', value(e) { - const t = this; const n = e.dataList; let o = null;n.forEach(((e) => { - e.groupAtTips ? o = e.groupAtTips : e.elements && (o = e.elements), o.__random = e.random, o.__sequence = e.clientSequence, t._tmpGroupAtTipsList.push(o); - })), Oe.debug(''.concat(this._className, '.onNewGroupAtTips isReady:').concat(this._isReady), this._tmpGroupAtTipsList), this._isReady && this._handleGroupAtTipsList(); - } }, { key: '_handleGroupAtTipsList', value() { - const e = this;if (0 !== this._tmpGroupAtTipsList.length) { - let t = !1;this._tmpGroupAtTipsList.forEach(((n) => { - const o = n.groupID;if (n.from !== e.getMyUserID()) { - const a = e._conversationMap.get(''.concat(k.CONV_GROUP).concat(o));a && (a.updateGroupAtInfoList(n), t = !0); - } - })), t && this.emitConversationUpdate(!0, !1), this._tmpGroupAtTipsList.length = 0; - } - } }, { key: '_getC2CPeerReadTime', value(e) { - const t = this; const n = [];if (e.forEach(((e) => { - t._conversationMap.has(e.conversationID) || e.type !== k.CONV_C2C || n.push(e.conversationID.replace(k.CONV_C2C, '')); - })), n.length > 0) { - Oe.debug(''.concat(this._className, '._getC2CPeerReadTime userIDList:').concat(n));const o = this.getModule(Ft);o && o.getRemotePeerReadTime(n); - } - } }, { key: '_getStorageConversationList', value() { - return this.getModule(Ht).getItem('conversationMap'); - } }, { key: '_setStorageConversationList', value() { - const e = this.getLocalConversationList().slice(0, 20) - .map((e => ({ conversationID: e.conversationID, type: e.type, subType: e.subType, lastMessage: e.lastMessage, groupProfile: e.groupProfile, userProfile: e.userProfile })));this.getModule(Ht).setItem('conversationMap', e); - } }, { key: 'emitConversationUpdate', value() { - const e = !(arguments.length > 0 && void 0 !== arguments[0]) || arguments[0]; const t = !(arguments.length > 1 && void 0 !== arguments[1]) || arguments[1]; const n = M(this._conversationMap.values());if (t) { - const o = this.getModule(qt);o && o.updateGroupLastMessage(n); - }e && this.emitOuterEvent(D.CONVERSATION_LIST_UPDATED, n); - } }, { key: 'getLocalConversationList', value() { - return M(this._conversationMap.values()); - } }, { key: 'getLocalConversation', value(e) { - return this._conversationMap.get(e); - } }, { key: '_syncConversationList', value() { - const e = this; const t = new Xa(Rs);return this._pagingStatus === kt.NOT_START && this._conversationMap.clear(), this._pagingGetConversationList().then((n => (e._pagingStatus = kt.RESOLVED, e._setStorageConversationList(), e._handleC2CPeerReadTime(), e._patchConversationProperties(), t.setMessage(e._conversationMap.size).setNetworkType(e.getNetworkType()) - .end(), n))) - .catch((n => (e._pagingStatus = kt.REJECTED, t.setMessage(e._pagingTimeStamp), e.probeNetwork().then(((e) => { - const o = m(e, 2); const a = o[0]; const s = o[1];t.setError(n, a, s).end(); - })), ai(n)))); - } }, { key: '_patchConversationProperties', value() { - const e = this; const t = Date.now(); const n = this.checkAndPatchRemark(); const o = this._messageRemindHandler.getC2CMessageRemindType(); const a = this.getModule(qt).getGroupList();Promise.all([n, o, a]).then((() => { - const n = Date.now() - t;Oe.log(''.concat(e._className, '._patchConversationProperties ok. cost ').concat(n, ' ms')), e.emitConversationUpdate(!0, !1); - })); - } }, { key: '_pagingGetConversationList', value() { - const e = this; const t = ''.concat(this._className, '._pagingGetConversationList');return Oe.log(''.concat(t, ' timeStamp:').concat(this._pagingTimeStamp, ' startIndex:') - .concat(this._pagingStartIndex) + ' pinnedTimeStamp:'.concat(this._pagingPinnedTimeStamp, ' pinnedStartIndex:').concat(this._pagingPinnedStartIndex)), this._pagingStatus = kt.PENDING, this.request({ protocolName: En, requestData: { fromAccount: this.getMyUserID(), timeStamp: this._pagingTimeStamp, startIndex: this._pagingStartIndex, pinnedTimeStamp: this._pagingPinnedTimeStamp, pinnedStartIndex: this._pagingStartIndex, orderType: 1 } }).then(((n) => { - const o = n.data; const a = o.completeFlag; const s = o.conversations; const r = void 0 === s ? [] : s; const i = o.timeStamp; const c = o.startIndex; const u = o.pinnedTimeStamp; const l = o.pinnedStartIndex;if (Oe.log(''.concat(t, ' ok. completeFlag:').concat(a, ' count:') - .concat(r.length, ' isReady:') - .concat(e._isReady)), r.length > 0) { - const d = e._getConversationOptions(r);e._updateLocalConversationList({ conversationOptionsList: d, isFromGetConversations: !0 }), e.isLoggedIn() && e.emitConversationUpdate(); - } if (!e._isReady) { - if (!e.isLoggedIn()) return oi();e.triggerReady(); - } return e._pagingTimeStamp = i, e._pagingStartIndex = c, e._pagingPinnedTimeStamp = u, e._pagingPinnedStartIndex = l, 1 !== a ? e._pagingGetConversationList() : (e._handleGroupAtTipsList(), oi()); - })) - .catch(((n) => { - throw e.isLoggedIn() && (e._isReady || (Oe.warn(''.concat(t, ' failed. error:'), n), e.triggerReady())), n; - })); - } }, { key: '_updateLocalConversationList', value(e) { - let t; const n = e.isFromGetConversations; const o = Date.now();t = this._getTmpConversationListMapping(e), this._conversationMap = new Map(this._sortConversationList([].concat(M(t.toBeUpdatedConversationList), M(this._conversationMap)))), n || this._updateUserOrGroupProfile(t.newConversationList), Oe.debug(''.concat(this._className, '._updateLocalConversationList cost ').concat(Date.now() - o, ' ms')); - } }, { key: '_getTmpConversationListMapping', value(e) { - for (var t = e.conversationOptionsList, n = e.isFromGetConversations, o = e.isInstantMessage, a = e.isUnreadC2CMessage, s = void 0 !== a && a, r = [], i = [], c = this.getModule(qt), u = this.getModule(Vt), l = 0, d = t.length;l < d;l++) { - const p = new Si(t[l]); const g = p.conversationID;if (g !== ''.concat(k.CONV_C2C, '@TLS#ERROR') && g !== ''.concat(k.CONV_C2C, '@TLS#NOT_FOUND')) if (this._conversationMap.has(g)) { - const h = this._conversationMap.get(g); const _ = ['unreadCount', 'allowType', 'adminForbidType', 'payload', 'isPinned'];!1 === o && _.push('lastMessage');const f = t[l].lastMessage; const m = !qe(f);m || this._onLastMessageNotExist(t[l]), qe(o) && m && null === h.lastMessage.payload && (h.lastMessage.payload = f.payload), Ye(h, p, _, [null, void 0, '', 0, NaN]), h.updateUnreadCount({ nextUnreadCount: p.unreadCount, isFromGetConversations: n, isUnreadC2CMessage: s }), o && m && (h.lastMessage.payload = f.payload, h.type === k.CONV_GROUP && (h.lastMessage.nameCard = f.nameCard, h.lastMessage.nick = f.nick)), m && h.lastMessage.cloudCustomData !== f.cloudCustomData && (h.lastMessage.cloudCustomData = f.cloudCustomData || ''), this._conversationMap.delete(g), r.push([g, h]); - } else { - if (p.type === k.CONV_GROUP && c) { - const M = p.groupProfile.groupID; const v = c.getLocalGroupProfile(M);v && (p.groupProfile = v, p.updateUnreadCount({ nextUnreadCount: 0 })); - } else if (p.type === k.CONV_C2C) { - const y = g.replace(k.CONV_C2C, '');u && u.isMyFriend(y) && (p.remark = u.getFriendRemark(y)); - }i.push(p), r.push([g, p]); - } - } return { toBeUpdatedConversationList: r, newConversationList: i }; - } }, { key: '_onLastMessageNotExist', value(e) { - new Xa(Sr).setMessage(''.concat(JSON.stringify(e))) - .setNetworkType(this.getNetworkType()) - .end(); - } }, { key: '_sortConversationList', value(e) { - const t = []; const n = [];return e.forEach(((e) => { - !0 === e[1].isPinned ? t.push(e) : n.push(e); - })), t.sort(((e, t) => t[1].lastMessage.lastTime - e[1].lastMessage.lastTime)).concat(n.sort(((e, t) => t[1].lastMessage.lastTime - e[1].lastMessage.lastTime))); - } }, { key: '_sortConversationListAndEmitEvent', value() { - this._conversationMap = new Map(this._sortConversationList(M(this._conversationMap))), this.emitConversationUpdate(!0, !1); - } }, { key: '_updateUserOrGroupProfile', value(e) { - const t = this;if (0 !== e.length) { - const n = []; const o = []; const a = this.getModule(Ut); const s = this.getModule(qt);e.forEach(((e) => { - if (e.type === k.CONV_C2C)n.push(e.toAccount);else if (e.type === k.CONV_GROUP) { - const t = e.toAccount;s.hasLocalGroup(t) ? e.groupProfile = s.getLocalGroupProfile(t) : o.push(t); - } - })), Oe.log(''.concat(this._className, '._updateUserOrGroupProfile c2cUserIDList:').concat(n, ' groupIDList:') - .concat(o)), n.length > 0 && a.getUserProfile({ userIDList: n }).then(((e) => { - const n = e.data;Fe(n) ? n.forEach(((e) => { - t._conversationMap.get('C2C'.concat(e.userID)).userProfile = e; - })) : t._conversationMap.get('C2C'.concat(n.userID)).userProfile = n; - })), o.length > 0 && s.getGroupProfileAdvance({ groupIDList: o, responseFilter: { groupBaseInfoFilter: ['Type', 'Name', 'FaceUrl'] } }).then(((e) => { - e.data.successGroupList.forEach(((e) => { - const n = 'GROUP'.concat(e.groupID);if (t._conversationMap.has(n)) { - const o = t._conversationMap.get(n);Ye(o.groupProfile, e, [], [null, void 0, '', 0, NaN]), !o.subType && e.type && (o.subType = e.type); - } - })); - })); - } - } }, { key: '_getConversationOptions', value(e) { - const t = []; const n = e.filter(((e) => { - const t = e.lastMsg;return Ue(t); - })).filter(((e) => { - const t = e.type; const n = e.userID;return 1 === t && '@TLS#NOT_FOUND' !== n && '@TLS#ERROR' !== n || 2 === t; - })) - .map(((e) => { - if (1 === e.type) { - const n = { userID: e.userID, nick: e.peerNick, avatar: e.peerAvatar };return t.push(n), { conversationID: 'C2C'.concat(e.userID), type: 'C2C', lastMessage: { lastTime: e.time, lastSequence: e.sequence, fromAccount: e.lastC2CMsgFromAccount, messageForShow: e.messageShow, type: e.lastMsg.elements[0] ? e.lastMsg.elements[0].type : null, payload: e.lastMsg.elements[0] ? e.lastMsg.elements[0].content : null, cloudCustomData: e.cloudCustomData || '', isRevoked: 8 === e.lastMessageFlag, onlineOnlyFlag: !1, nick: '', nameCard: '' }, userProfile: new mi(n), peerReadTime: e.c2cPeerReadTime, isPinned: 1 === e.isPinned, messageRemindType: '' }; - } return { conversationID: 'GROUP'.concat(e.groupID), type: 'GROUP', lastMessage: { lastTime: e.time, lastSequence: e.messageReadSeq + e.unreadCount, fromAccount: e.msgGroupFromAccount, messageForShow: e.messageShow, type: e.lastMsg.elements[0] ? e.lastMsg.elements[0].type : null, payload: e.lastMsg.elements[0] ? e.lastMsg.elements[0].content : null, cloudCustomData: e.cloudCustomData || '', isRevoked: 2 === e.lastMessageFlag, onlineOnlyFlag: !1, nick: e.senderNick || '', nameCard: e.senderNameCard || '' }, groupProfile: new Ii({ groupID: e.groupID, name: e.groupNick, avatar: e.groupImage }), unreadCount: e.unreadCount, peerReadTime: 0, isPinned: 1 === e.isPinned, messageRemindType: '' }; - }));t.length > 0 && this.getModule(Ut).onConversationsProfileUpdated(t);return n; - } }, { key: 'getLocalMessageList', value(e) { - return this._messageListHandler.getLocalMessageList(e); - } }, { key: 'deleteLocalMessage', value(e) { - e instanceof Yr && this._messageListHandler.remove(e); - } }, { key: 'onConversationDeleted', value(e) { - const t = this;Oe.log(''.concat(this._className, '.onConversationDeleted')), Fe(e) && e.forEach(((e) => { - const n = e.type; const o = e.userID; const a = e.groupID; let s = '';1 === n ? s = ''.concat(k.CONV_C2C).concat(o) : 2 === n && (s = ''.concat(k.CONV_GROUP).concat(a)), t.deleteLocalConversation(s); - })); - } }, { key: 'onConversationPinned', value(e) { - const t = this;if (Fe(e)) { - let n = !1;e.forEach(((e) => { - let o; const a = e.type; const s = e.userID; const r = e.groupID;1 === a ? o = t.getLocalConversation(''.concat(k.CONV_C2C).concat(s)) : 2 === a && (o = t.getLocalConversation(''.concat(k.CONV_GROUP).concat(r))), o && (Oe.log(''.concat(t._className, '.onConversationPinned conversationID:').concat(o.conversationID, ' isPinned:') - .concat(o.isPinned)), o.isPinned || (o.isPinned = !0, n = !0)); - })), n && this._sortConversationListAndEmitEvent(); - } - } }, { key: 'onConversationUnpinned', value(e) { - const t = this;if (Fe(e)) { - let n = !1;e.forEach(((e) => { - let o; const a = e.type; const s = e.userID; const r = e.groupID;1 === a ? o = t.getLocalConversation(''.concat(k.CONV_C2C).concat(s)) : 2 === a && (o = t.getLocalConversation(''.concat(k.CONV_GROUP).concat(r))), o && (Oe.log(''.concat(t._className, '.onConversationUnpinned conversationID:').concat(o.conversationID, ' isPinned:') - .concat(o.isPinned)), o.isPinned && (o.isPinned = !1, n = !0)); - })), n && this._sortConversationListAndEmitEvent(); - } - } }, { key: 'getMessageList', value(e) { - const t = this; const n = e.conversationID; const o = e.nextReqMessageID; let a = e.count; const s = ''.concat(this._className, '.getMessageList'); const r = this.getLocalConversation(n); let i = '';if (r && r.groupProfile && (i = r.groupProfile.type), it(i)) return Oe.log(''.concat(s, ' not available in avchatroom. conversationID:').concat(n)), oi({ messageList: [], nextReqMessageID: '', isCompleted: !0 });(qe(a) || a > 15) && (a = 15);let c = this._computeLeftCount({ conversationID: n, nextReqMessageID: o });return Oe.log(''.concat(s, ' conversationID:').concat(n, ' leftCount:') - .concat(c, ' count:') - .concat(a, ' nextReqMessageID:') - .concat(o)), this._needGetHistory({ conversationID: n, leftCount: c, count: a }) ? this.getHistoryMessages({ conversationID: n, nextReqMessageID: o, count: 20 }).then((() => (c = t._computeLeftCount({ conversationID: n, nextReqMessageID: o }), $r(t._computeResult({ conversationID: n, nextReqMessageID: o, count: a, leftCount: c }))))) : (Oe.log(''.concat(s, '.getMessageList get message list from memory')), this.modifyMessageList(n), oi(this._computeResult({ conversationID: n, nextReqMessageID: o, count: a, leftCount: c }))); - } }, { key: '_computeLeftCount', value(e) { - const t = e.conversationID; const n = e.nextReqMessageID;return n ? this._messageListHandler.getLocalMessageList(t).findIndex((e => e.ID === n)) : this._getMessageListSize(t); - } }, { key: '_getMessageListSize', value(e) { - return this._messageListHandler.getLocalMessageList(e).length; - } }, { key: '_needGetHistory', value(e) { - const t = e.conversationID; const n = e.leftCount; const o = e.count; const a = this.getLocalConversation(t); let s = '';return a && a.groupProfile && (s = a.groupProfile.type), !lt(t) && !it(s) && (n < o && !this._completedMap.has(t)); - } }, { key: '_computeResult', value(e) { - const t = e.conversationID; const n = e.nextReqMessageID; const o = e.count; const a = e.leftCount; const s = this._computeMessageList({ conversationID: t, nextReqMessageID: n, count: o }); const r = this._computeIsCompleted({ conversationID: t, leftCount: a, count: o }); const i = this._computeNextReqMessageID({ messageList: s, isCompleted: r, conversationID: t }); const c = ''.concat(this._className, '._computeResult. conversationID:').concat(t);return Oe.log(''.concat(c, ' leftCount:').concat(a, ' count:') - .concat(o, ' nextReqMessageID:') - .concat(i, ' isCompleted:') - .concat(r)), { messageList: s, nextReqMessageID: i, isCompleted: r }; - } }, { key: '_computeMessageList', value(e) { - const t = e.conversationID; const n = e.nextReqMessageID; const o = e.count; const a = this._messageListHandler.getLocalMessageList(t); const s = this._computeIndexEnd({ nextReqMessageID: n, messageList: a }); const r = this._computeIndexStart({ indexEnd: s, count: o });return a.slice(r, s); - } }, { key: '_computeNextReqMessageID', value(e) { - const t = e.messageList; const n = e.isCompleted; const o = e.conversationID;if (!n) return 0 === t.length ? '' : t[0].ID;const a = this._messageListHandler.getLocalMessageList(o);return 0 === a.length ? '' : a[0].ID; - } }, { key: '_computeIndexEnd', value(e) { - const t = e.messageList; const n = void 0 === t ? [] : t; const o = e.nextReqMessageID;return o ? n.findIndex((e => e.ID === o)) : n.length; - } }, { key: '_computeIndexStart', value(e) { - const t = e.indexEnd; const n = e.count;return t > n ? t - n : 0; - } }, { key: '_computeIsCompleted', value(e) { - const t = e.conversationID;return !!(e.leftCount <= e.count && this._completedMap.has(t)); - } }, { key: 'getHistoryMessages', value(e) { - const t = e.conversationID; const n = e.nextReqMessageID;if (t === k.CONV_SYSTEM) return oi();e.count ? e.count > 20 && (e.count = 20) : e.count = 15;let o = this._messageListHandler.getLocalOldestMessageByConversationID(t);o || ((o = {}).time = 0, o.sequence = 0, 0 === t.indexOf(k.CONV_C2C) ? (o.to = t.replace(k.CONV_C2C, ''), o.conversationType = k.CONV_C2C) : 0 === t.indexOf(k.CONV_GROUP) && (o.to = t.replace(k.CONV_GROUP, ''), o.conversationType = k.CONV_GROUP));let a = ''; let s = null; const r = this._roamingMessageKeyAndTimeMap.has(t);switch (o.conversationType) { - case k.CONV_C2C:return a = t.replace(k.CONV_C2C, ''), (s = this.getModule(Ft)) ? s.getRoamingMessage({ conversationID: e.conversationID, peerAccount: a, count: e.count, lastMessageTime: r ? this._roamingMessageKeyAndTimeMap.get(t).lastMessageTime : 0, messageKey: r ? this._roamingMessageKeyAndTimeMap.get(t).messageKey : '' }) : ai({ code: Do.CANNOT_FIND_MODULE, message: Ga });case k.CONV_GROUP:return (s = this.getModule(qt)) ? s.getRoamingMessage({ conversationID: e.conversationID, groupID: o.to, count: e.count, sequence: n && !1 === o._onlineOnlyFlag ? o.sequence - 1 : o.sequence }) : ai({ code: Do.CANNOT_FIND_MODULE, message: Ga });default:return oi(); - } - } }, { key: 'patchConversationLastMessage', value(e) { - const t = this.getLocalConversation(e);if (t) { - const n = t.lastMessage; const o = n.messageForShow; const a = n.payload;if (It(o) || It(a)) { - const s = this._messageListHandler.getLocalMessageList(e);if (0 === s.length) return;const r = s[s.length - 1];Oe.log(''.concat(this._className, '.patchConversationLastMessage conversationID:').concat(e, ' payload:'), r.payload), t.updateLastMessage(r); - } - } - } }, { key: 'storeRoamingMessage', value() { - const e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : []; const t = arguments.length > 1 ? arguments[1] : void 0; const n = t.startsWith(k.CONV_C2C) ? k.CONV_C2C : k.CONV_GROUP; let o = null; const a = []; let s = 0; let i = e.length; let c = null; const u = n === k.CONV_GROUP; const l = this.getModule(Yt); let d = function () { - s = u ? e.length - 1 : 0, i = u ? 0 : e.length; - }; let p = function () { - u ? --s : ++s; - }; let g = function () { - return u ? s >= i : s < i; - };for (d();g();p()) if (u && 1 === e[s].sequence && this.setCompleted(t), 1 !== e[s].isPlaceMessage) if ((o = new Yr(e[s])).to = e[s].to, o.isSystemMessage = !!e[s].isSystemMessage, o.conversationType = n, 4 === e[s].event ? c = { type: k.MSG_GRP_TIP, content: r(r({}, e[s].elements), {}, { groupProfile: e[s].groupProfile }) } : (e[s].elements = l.parseElements(e[s].elements, e[s].from), c = e[s].elements), u || o.setNickAndAvatar({ nick: e[s].nick, avatar: e[s].avatar }), It(c)) { - const h = new Xa(ys);h.setMessage('from:'.concat(o.from, ' to:').concat(o.to, ' sequence:') - .concat(o.sequence, ' event:') - .concat(e[s].event)), h.setNetworkType(this.getNetworkType()).setLevel('warning') - .end(); - } else o.setElement(c), o.reInitialize(this.getMyUserID()), a.push(o);return this._messageListHandler.unshift(a), d = p = g = null, a; - } }, { key: 'setMessageRead', value(e) { - const t = e.conversationID; const n = (e.messageID, this.getLocalConversation(t));if (Oe.log(''.concat(this._className, '.setMessageRead conversationID:').concat(t, ' unreadCount:') - .concat(n ? n.unreadCount : 0)), !n) return oi();if (n.type !== k.CONV_GROUP || It(n.groupAtInfoList) || this.deleteGroupAtTips(t), 0 === n.unreadCount) return oi();const o = this._messageListHandler.getLocalLastMessage(t); let a = n.lastMessage.lastTime;o && a < o.time && (a = o.time);let s = n.lastMessage.lastSequence;o && s < o.sequence && (s = o.sequence);let r = null;switch (n.type) { - case k.CONV_C2C:return (r = this.getModule(Ft)) ? r.setMessageRead({ conversationID: t, lastMessageTime: a }) : ai({ code: Do.CANNOT_FIND_MODULE, message: Ga });case k.CONV_GROUP:return (r = this._moduleManager.getModule(qt)) ? r.setMessageRead({ conversationID: t, lastMessageSeq: s }) : ai({ code: Do.CANNOT_FIND_MODULE, message: Ga });case k.CONV_SYSTEM:return n.unreadCount = 0, this.emitConversationUpdate(!0, !1), oi();default:return oi(); - } - } }, { key: 'setAllMessageRead', value() { - const e = this; const t = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {}; const n = ''.concat(this._className, '.setAllMessageRead');t.scope || (t.scope = k.READ_ALL_MSG), Oe.log(''.concat(n, ' options:'), t);const o = this._createSetAllMessageReadPack(t);if (0 === o.readAllC2CMessage && 0 === o.groupMessageReadInfoList.length) return oi();const a = new Xa(Os);return this.request({ protocolName: Wn, requestData: o }).then(((n) => { - const o = n.data; const s = e._handleAllMessageRead(o);return a.setMessage('scope:'.concat(t.scope, ' failureGroups:').concat(JSON.stringify(s))).setNetworkType(e.getNetworkType()) - .end(), oi(); - })) - .catch((t => (e.probeNetwork().then(((e) => { - const n = m(e, 2); const o = n[0]; const s = n[1];a.setError(t, o, s).end(); - })), Oe.warn(''.concat(n, ' failed. error:'), t), ai({ code: t && t.code ? t.code : Do.MESSAGE_UNREAD_ALL_FAIL, message: t && t.message ? t.message : xo })))); - } }, { key: '_getConversationLastMessageSequence', value(e) { - const t = this._messageListHandler.getLocalLastMessage(e.conversationID); let n = e.lastMessage.lastSequence;return t && n < t.sequence && (n = t.sequence), n; - } }, { key: '_getConversationLastMessageTime', value(e) { - const t = this._messageListHandler.getLocalLastMessage(e.conversationID); let n = e.lastMessage.lastTime;return t && n < t.time && (n = t.time), n; - } }, { key: '_createSetAllMessageReadPack', value(e) { - let t; const n = { readAllC2CMessage: 0, groupMessageReadInfoList: [] }; const o = e.scope; const a = S(this._conversationMap);try { - for (a.s();!(t = a.n()).done;) { - const s = m(t.value, 2)[1];if (s.unreadCount > 0) if (s.type === k.CONV_C2C && 0 === n.readAllC2CMessage) { - if (o === k.READ_ALL_MSG)n.readAllC2CMessage = 1;else if (o === k.READ_ALL_C2C_MSG) { - n.readAllC2CMessage = 1;break; - } - } else if (s.type === k.CONV_GROUP && (o === k.READ_ALL_GROUP_MSG || o === k.READ_ALL_MSG)) { - const r = this._getConversationLastMessageSequence(s);n.groupMessageReadInfoList.push({ groupID: s.groupProfile.groupID, messageSequence: r }); - } - } - } catch (i) { - a.e(i); - } finally { - a.f(); - } return n; - } }, { key: 'onPushedAllMessageRead', value(e) { - this._handleAllMessageRead(e); - } }, { key: '_handleAllMessageRead', value(e) { - const t = e.groupMessageReadInfoList; const n = e.readAllC2CMessage; const o = this._parseGroupReadInfo(t);return this._updateAllConversationUnreadCount({ readAllC2CMessage: n }) >= 1 && this.emitConversationUpdate(!0, !1), o; - } }, { key: '_parseGroupReadInfo', value(e) { - const t = [];if (e && e.length) for (let n = 0, o = e.length;n < o;n++) { - const a = e[n]; const s = a.groupID; const r = a.sequence; const i = a.retCode; const c = a.lastMessageSeq;qe(i) ? this._remoteGroupReadSequenceMap.set(s, c) : (this._remoteGroupReadSequenceMap.set(s, r), 0 !== i && t.push(''.concat(s, '-').concat(r, '-') - .concat(i))); - } return t; - } }, { key: '_updateAllConversationUnreadCount', value(e) { - let t; const n = e.readAllC2CMessage; let o = 0; const a = S(this._conversationMap);try { - for (a.s();!(t = a.n()).done;) { - const s = m(t.value, 2); const r = s[0]; const i = s[1];if (i.unreadCount >= 1) { - if (1 === n && i.type === k.CONV_C2C) { - const c = this._getConversationLastMessageTime(i);this.updateIsReadAfterReadReport({ conversationID: r, lastMessageTime: c }); - } else if (i.type === k.CONV_GROUP) { - const u = r.replace(k.CONV_GROUP, '');if (this._remoteGroupReadSequenceMap.has(u)) { - const l = this._remoteGroupReadSequenceMap.get(u); const d = this._getConversationLastMessageSequence(i);this.updateIsReadAfterReadReport({ conversationID: r, remoteReadSequence: l }), d >= l && this._remoteGroupReadSequenceMap.delete(u); - } - } this.updateUnreadCount(r, !1) && (o += 1); - } - } - } catch (p) { - a.e(p); - } finally { - a.f(); - } return o; - } }, { key: 'isRemoteRead', value(e) { - const t = e.conversationID; const n = e.sequence; const o = t.replace(k.CONV_GROUP, ''); let a = !1;if (this._remoteGroupReadSequenceMap.has(o)) { - const s = this._remoteGroupReadSequenceMap.get(o);n <= s && (a = !0, Oe.log(''.concat(this._className, '.isRemoteRead conversationID:').concat(t, ' messageSequence:') - .concat(n, ' remoteReadSequence:') - .concat(s))), n >= s + 10 && this._remoteGroupReadSequenceMap.delete(o); - } return a; - } }, { key: 'updateIsReadAfterReadReport', value(e) { - const t = e.conversationID; const n = e.lastMessageSeq; const o = e.lastMessageTime; const a = this._messageListHandler.getLocalMessageList(t);if (0 !== a.length) for (var s, r = a.length - 1;r >= 0;r--) if (s = a[r], !(o && s.time > o || n && s.sequence > n)) { - if ('in' === s.flow && s.isRead) break;s.setIsRead(!0); - } - } }, { key: 'updateUnreadCount', value(e) { - const t = !(arguments.length > 1 && void 0 !== arguments[1]) || arguments[1]; let n = !1; const o = this.getLocalConversation(e); const a = this._messageListHandler.getLocalMessageList(e);if (o) { - const s = o.unreadCount; const r = a.filter((e => !e.isRead && !e._onlineOnlyFlag && !e.isDeleted)).length;return s !== r && (o.unreadCount = r, n = !0, Oe.log(''.concat(this._className, '.updateUnreadCount from ').concat(s, ' to ') - .concat(r, ', conversationID:') - .concat(e)), !0 === t && this.emitConversationUpdate(!0, !1)), n; - } - } }, { key: 'recomputeGroupUnreadCount', value(e) { - const t = e.conversationID; const n = e.count; const o = this.getLocalConversation(t);if (o) { - const a = o.unreadCount; let s = a - n;s < 0 && (s = 0), o.unreadCount = s, Oe.log(''.concat(this._className, '.recomputeGroupUnreadCount from ').concat(a, ' to ') - .concat(s, ', conversationID:') - .concat(t)); - } - } }, { key: 'updateIsRead', value(e) { - const t = this.getLocalConversation(e); const n = this.getLocalMessageList(e);if (t && 0 !== n.length && !lt(t.type)) { - for (var o = [], a = 0, s = n.length;a < s;a++)'in' !== n[a].flow ? 'out' !== n[a].flow || n[a].isRead || n[a].setIsRead(!0) : o.push(n[a]);let r = 0;if (t.type === k.CONV_C2C) { - const i = o.slice(-t.unreadCount).filter((e => e.isRevoked)).length;r = o.length - t.unreadCount - i; - } else r = o.length - t.unreadCount;for (let c = 0;c < r && !o[c].isRead;c++)o[c].setIsRead(!0); - } - } }, { key: 'deleteGroupAtTips', value(e) { - const t = ''.concat(this._className, '.deleteGroupAtTips');Oe.log(''.concat(t));const n = this._conversationMap.get(e);if (!n) return Promise.resolve();const o = n.groupAtInfoList;if (0 === o.length) return Promise.resolve();const a = this.getMyUserID();return this.request({ protocolName: Rn, requestData: { messageListToDelete: o.map((e => ({ from: e.from, to: a, messageSeq: e.__sequence, messageRandom: e.__random, groupID: e.groupID }))) } }).then((() => (Oe.log(''.concat(t, ' ok. count:').concat(o.length)), n.clearGroupAtInfoList(), Promise.resolve()))) - .catch((e => (Oe.error(''.concat(t, ' failed. error:'), e), ai(e)))); - } }, { key: 'appendToMessageList', value(e) { - this._messageListHandler.pushIn(e); - } }, { key: 'setMessageRandom', value(e) { - this.singlyLinkedList.set(e.random); - } }, { key: 'deleteMessageRandom', value(e) { - this.singlyLinkedList.delete(e.random); - } }, { key: 'pushIntoMessageList', value(e, t, n) { - return !(!this._messageListHandler.pushIn(t, n) || this._isMessageFromCurrentInstance(t) && !n) && (e.push(t), !0); - } }, { key: '_isMessageFromCurrentInstance', value(e) { - return this.singlyLinkedList.has(e.random); - } }, { key: 'revoke', value(e, t, n) { - return this._messageListHandler.revoke(e, t, n); - } }, { key: 'getPeerReadTime', value(e) { - return this._peerReadTimeMap.get(e); - } }, { key: 'recordPeerReadTime', value(e, t) { - this._peerReadTimeMap.has(e) ? this._peerReadTimeMap.get(e) < t && this._peerReadTimeMap.set(e, t) : this._peerReadTimeMap.set(e, t); - } }, { key: 'updateMessageIsPeerReadProperty', value(e, t) { - if (e.startsWith(k.CONV_C2C) && t > 0) { - const n = this._messageListHandler.updateMessageIsPeerReadProperty(e, t);n.length > 0 && this.emitOuterEvent(D.MESSAGE_READ_BY_PEER, n); - } - } }, { key: 'updateMessageIsModifiedProperty', value(e) { - this._messageListHandler.updateMessageIsModifiedProperty(e); - } }, { key: 'setCompleted', value(e) { - Oe.log(''.concat(this._className, '.setCompleted. conversationID:').concat(e)), this._completedMap.set(e, !0); - } }, { key: 'updateRoamingMessageKeyAndTime', value(e, t, n) { - this._roamingMessageKeyAndTimeMap.set(e, { messageKey: t, lastMessageTime: n }); - } }, { key: 'getConversationList', value(e) { - const t = this; const n = ''.concat(this._className, '.getConversationList'); const o = 'pagingStatus:'.concat(this._pagingStatus, ', local conversation count:').concat(this._conversationMap.size, ', options:') - .concat(e);if (Oe.log(''.concat(n, '. ').concat(o)), this._pagingStatus === kt.REJECTED) { - const a = new Xa(ks);return a.setMessage(o), this._syncConversationList().then((() => { - a.setNetworkType(t.getNetworkType()).end();const n = t._getConversationList(e);return $r({ conversationList: n }); - })) - .catch((e => (t.probeNetwork().then(((t) => { - const n = m(t, 2); const o = n[0]; const s = n[1];a.setError(e, o, s).end(); - })), Oe.error(''.concat(n, ' failed. error:'), e), ai(e)))); - } if (0 === this._conversationMap.size) { - const s = new Xa(ks);return s.setMessage(o), this._syncConversationList().then((() => { - s.setNetworkType(t.getNetworkType()).end();const n = t._getConversationList(e);return $r({ conversationList: n }); - })) - .catch((e => (t.probeNetwork().then(((t) => { - const n = m(t, 2); const o = n[0]; const a = n[1];s.setError(e, o, a).end(); - })), Oe.error(''.concat(n, ' failed. error:'), e), ai(e)))); - } const r = this._getConversationList(e);return Oe.log(''.concat(n, '. returned conversation count:').concat(r.length)), oi({ conversationList: r }); - } }, { key: '_getConversationList', value(e) { - const t = this;if (qe(e)) return this.getLocalConversationList();if (Fe(e)) { - const n = [];return e.forEach(((e) => { - if (t._conversationMap.has(e)) { - const o = t.getLocalConversation(e);n.push(o); - } - })), n; - } - } }, { key: '_handleC2CPeerReadTime', value() { - let e; const t = S(this._conversationMap);try { - for (t.s();!(e = t.n()).done;) { - const n = m(e.value, 2); const o = n[0]; const a = n[1];a.type === k.CONV_C2C && (Oe.debug(''.concat(this._className, '._handleC2CPeerReadTime conversationID:').concat(o, ' peerReadTime:') - .concat(a.peerReadTime)), this.recordPeerReadTime(o, a.peerReadTime)); - } - } catch (s) { - t.e(s); - } finally { - t.f(); - } - } }, { key: 'getConversationProfile', value(e) { - let t; const n = this;if ((t = this._conversationMap.has(e) ? this._conversationMap.get(e) : new Si({ conversationID: e, type: e.slice(0, 3) === k.CONV_C2C ? k.CONV_C2C : k.CONV_GROUP }))._isInfoCompleted || t.type === k.CONV_SYSTEM) return oi({ conversation: t });const o = new Xa(Es); const a = ''.concat(this._className, '.getConversationProfile');return Oe.log(''.concat(a, '. conversationID:').concat(e, ' remark:') - .concat(t.remark, ' lastMessage:'), t.lastMessage), this._updateUserOrGroupProfileCompletely(t).then(((s) => { - o.setNetworkType(n.getNetworkType()).setMessage('conversationID:'.concat(e, ' unreadCount:').concat(s.data.conversation.unreadCount)) - .end();const r = n.getModule(Vt);if (r && t.type === k.CONV_C2C) { - const i = e.replace(k.CONV_C2C, '');if (r.isMyFriend(i)) { - const c = r.getFriendRemark(i);t.remark !== c && (t.remark = c, Oe.log(''.concat(a, '. conversationID:').concat(e, ' patch remark:') - .concat(t.remark))); - } - } return Oe.log(''.concat(a, ' ok. conversationID:').concat(e)), s; - })) - .catch((t => (n.probeNetwork().then(((n) => { - const a = m(n, 2); const s = a[0]; const r = a[1];o.setError(t, s, r).setMessage('conversationID:'.concat(e)) - .end(); - })), Oe.error(''.concat(a, ' failed. error:'), t), ai(t)))); - } }, { key: '_updateUserOrGroupProfileCompletely', value(e) { - const t = this;return e.type === k.CONV_C2C ? this.getModule(Ut).getUserProfile({ userIDList: [e.toAccount] }) - .then(((n) => { - const o = n.data;return 0 === o.length ? ai(new ei({ code: Do.USER_OR_GROUP_NOT_FOUND, message: ra })) : (e.userProfile = o[0], e._isInfoCompleted = !0, t._unshiftConversation(e), oi({ conversation: e })); - })) : this.getModule(qt).getGroupProfile({ groupID: e.toAccount }) - .then((n => (e.groupProfile = n.data.group, e._isInfoCompleted = !0, t._unshiftConversation(e), oi({ conversation: e })))); - } }, { key: '_unshiftConversation', value(e) { - e instanceof Si && !this._conversationMap.has(e.conversationID) && (this._conversationMap = new Map([[e.conversationID, e]].concat(M(this._conversationMap))), this._setStorageConversationList(), this.emitConversationUpdate(!0, !1)); - } }, { key: '_onProfileUpdated', value(e) { - const t = this;e.data.forEach(((e) => { - const n = e.userID;if (n === t.getMyUserID())t._onMyProfileModified({ latestNick: e.nick, latestAvatar: e.avatar });else { - const o = t._conversationMap.get(''.concat(k.CONV_C2C).concat(n));o && (o.userProfile = e); - } - })); - } }, { key: 'deleteConversation', value(e) { - const t = this; const n = { fromAccount: this.getMyUserID(), toAccount: void 0, type: void 0 };if (!this._conversationMap.has(e)) { - const o = new ei({ code: Do.CONVERSATION_NOT_FOUND, message: sa });return ai(o); - } switch (this._conversationMap.get(e).type) { - case k.CONV_C2C:n.type = 1, n.toAccount = e.replace(k.CONV_C2C, '');break;case k.CONV_GROUP:n.type = 2, n.toGroupID = e.replace(k.CONV_GROUP, '');break;case k.CONV_SYSTEM:return this.getModule(qt).deleteGroupSystemNotice({ messageList: this._messageListHandler.getLocalMessageList(e) }), this.deleteLocalConversation(e), oi({ conversationID: e });default:var a = new ei({ code: Do.CONVERSATION_UN_RECORDED_TYPE, message: ia });return ai(a); - } const s = new Xa(As);s.setMessage('conversationID:'.concat(e));const r = ''.concat(this._className, '.deleteConversation');return Oe.log(''.concat(r, '. conversationID:').concat(e)), this.setMessageRead({ conversationID: e }).then((() => t.request({ protocolName: Nn, requestData: n }))) - .then((() => (s.setNetworkType(t.getNetworkType()).end(), Oe.log(''.concat(r, ' ok')), t.deleteLocalConversation(e), oi({ conversationID: e })))) - .catch((e => (t.probeNetwork().then(((t) => { - const n = m(t, 2); const o = n[0]; const a = n[1];s.setError(e, o, a).end(); - })), Oe.error(''.concat(r, ' failed. error:'), e), ai(e)))); - } }, { key: 'pinConversation', value(e) { - const t = this; const n = e.conversationID; const o = e.isPinned;if (!this._conversationMap.has(n)) return ai({ code: Do.CONVERSATION_NOT_FOUND, message: sa });const a = this.getLocalConversation(n);if (a.isPinned === o) return oi({ conversationID: n });const s = new Xa(Ns);s.setMessage('conversationID:'.concat(n, ' isPinned:').concat(o));const r = ''.concat(this._className, '.pinConversation');Oe.log(''.concat(r, '. conversationID:').concat(n, ' isPinned:') - .concat(o));let i = null;return ct(n) ? i = { type: 1, toAccount: n.replace(k.CONV_C2C, '') } : ut(n) && (i = { type: 2, groupID: n.replace(k.CONV_GROUP, '') }), this.request({ protocolName: Ln, requestData: { fromAccount: this.getMyUserID(), operationType: !0 === o ? 1 : 2, itemList: [i] } }).then((() => (s.setNetworkType(t.getNetworkType()).end(), Oe.log(''.concat(r, ' ok')), a.isPinned !== o && (a.isPinned = o, t._sortConversationListAndEmitEvent()), $r({ conversationID: n })))) - .catch((e => (t.probeNetwork().then(((t) => { - const n = m(t, 2); const o = n[0]; const a = n[1];s.setError(e, o, a).end(); - })), Oe.error(''.concat(r, ' failed. error:'), e), ai(e)))); - } }, { key: 'setMessageRemindType', value(e) { - return this._messageRemindHandler.set(e); - } }, { key: 'patchMessageRemindType', value(e) { - const t = e.ID; const n = e.isC2CConversation; const o = e.messageRemindType; let a = !1; const s = this.getLocalConversation(n ? ''.concat(k.CONV_C2C).concat(t) : ''.concat(k.CONV_GROUP).concat(t));return s && s.messageRemindType !== o && (s.messageRemindType = o, a = !0), a; - } }, { key: 'onC2CMessageRemindTypeSynced', value(e) { - const t = this;Oe.debug(''.concat(this._className, '.onC2CMessageRemindTypeSynced options:'), e), e.dataList.forEach(((e) => { - if (!It(e.muteNotificationsSync)) { - let n; const o = e.muteNotificationsSync; const a = o.to; const s = o.updateSequence; const r = o.muteFlag;t._messageRemindHandler.setUpdateSequence(s), 0 === r ? n = k.MSG_REMIND_ACPT_AND_NOTE : 1 === r ? n = k.MSG_REMIND_DISCARD : 2 === r && (n = k.MSG_REMIND_ACPT_NOT_NOTE);let i = 0;t.patchMessageRemindType({ ID: a, isC2CConversation: !0, messageRemindType: n }) && (i += 1), Oe.log(''.concat(t._className, '.onC2CMessageRemindTypeSynced updateCount:').concat(i)), i >= 1 && t.emitConversationUpdate(!0, !1); - } - })); - } }, { key: 'deleteLocalConversation', value(e) { - const t = this._conversationMap.has(e);Oe.log(''.concat(this._className, '.deleteLocalConversation conversationID:').concat(e, ' has:') - .concat(t)), t && (this._conversationMap.delete(e), this._roamingMessageKeyAndTimeMap.delete(e), this._setStorageConversationList(), this._messageListHandler.removeByConversationID(e), this._completedMap.delete(e), this.emitConversationUpdate(!0, !1)); - } }, { key: 'isMessageSentByCurrentInstance', value(e) { - return !(!this._messageListHandler.hasLocalMessage(e.conversationID, e.ID) && !this.singlyLinkedList.has(e.random)); - } }, { key: 'modifyMessageList', value(e) { - if (e.startsWith(k.CONV_C2C) && this._conversationMap.has(e)) { - const t = this._conversationMap.get(e); const n = Date.now();this._messageListHandler.modifyMessageSentByPeer({ conversationID: e, latestNick: t.userProfile.nick, latestAvatar: t.userProfile.avatar });const o = this.getModule(Ut).getNickAndAvatarByUserID(this.getMyUserID());this._messageListHandler.modifyMessageSentByMe({ conversationID: e, latestNick: o.nick, latestAvatar: o.avatar }), Oe.log(''.concat(this._className, '.modifyMessageList conversationID:').concat(e, ' cost ') - .concat(Date.now() - n, ' ms')); - } - } }, { key: 'updateUserProfileSpecifiedKey', value(e) { - Oe.log(''.concat(this._className, '.updateUserProfileSpecifiedKey options:'), e);const t = e.conversationID; const n = e.nick; const o = e.avatar;if (this._conversationMap.has(t)) { - const a = this._conversationMap.get(t).userProfile;be(n) && a.nick !== n && (a.nick = n), be(o) && a.avatar !== o && (a.avatar = o), this.emitConversationUpdate(!0, !1); - } - } }, { key: '_onMyProfileModified', value(e) { - const t = this; const n = this.getLocalConversationList(); const o = Date.now();n.forEach(((n) => { - t.modifyMessageSentByMe(r({ conversationID: n.conversationID }, e)); - })), Oe.log(''.concat(this._className, '._onMyProfileModified. modify all messages sent by me, cost ').concat(Date.now() - o, ' ms')); - } }, { key: 'modifyMessageSentByMe', value(e) { - this._messageListHandler.modifyMessageSentByMe(e); - } }, { key: 'getLatestMessageSentByMe', value(e) { - return this._messageListHandler.getLatestMessageSentByMe(e); - } }, { key: 'modifyMessageSentByPeer', value(e) { - this._messageListHandler.modifyMessageSentByPeer(e); - } }, { key: 'getLatestMessageSentByPeer', value(e) { - return this._messageListHandler.getLatestMessageSentByPeer(e); - } }, { key: 'pushIntoNoticeResult', value(e, t) { - return !(!this._messageListHandler.pushIn(t) || this.singlyLinkedList.has(t.random)) && (e.push(t), !0); - } }, { key: 'getGroupLocalLastMessageSequence', value(e) { - return this._messageListHandler.getGroupLocalLastMessageSequence(e); - } }, { key: 'checkAndPatchRemark', value() { - const e = Promise.resolve();if (0 === this._conversationMap.size) return e;const t = this.getModule(Vt);if (!t) return e;const n = M(this._conversationMap.values()).filter((e => e.type === k.CONV_C2C));if (0 === n.length) return e;let o = 0;return n.forEach(((e) => { - const n = e.conversationID.replace(k.CONV_C2C, '');if (t.isMyFriend(n)) { - const a = t.getFriendRemark(n);e.remark !== a && (e.remark = a, o += 1); - } - })), Oe.log(''.concat(this._className, '.checkAndPatchRemark. c2c conversation count:').concat(n.length, ', patched count:') - .concat(o)), e; - } }, { key: 'reset', value() { - Oe.log(''.concat(this._className, '.reset')), this._pagingStatus = kt.NOT_START, this._messageListHandler.reset(), this._messageRemindHandler.reset(), this._roamingMessageKeyAndTimeMap.clear(), this.singlyLinkedList.reset(), this._peerReadTimeMap.clear(), this._completedMap.clear(), this._conversationMap.clear(), this._pagingTimeStamp = 0, this._pagingStartIndex = 0, this._pagingPinnedTimeStamp = 0, this._pagingPinnedStartIndex = 0, this._remoteGroupReadSequenceMap.clear(), this.resetReady(); - } }]), a; - }(sn)); const Ei = (function () { - function e(n) { - t(this, e), this._groupModule = n, this._className = 'GroupTipsHandler', this._cachedGroupTipsMap = new Map, this._checkCountMap = new Map, this.MAX_CHECK_COUNT = 4; - } return o(e, [{ key: 'onCheckTimer', value(e) { - e % 1 == 0 && this._cachedGroupTipsMap.size > 0 && this._checkCachedGroupTips(); - } }, { key: '_checkCachedGroupTips', value() { - const e = this;this._cachedGroupTipsMap.forEach(((t, n) => { - let o = e._checkCountMap.get(n); const a = e._groupModule.hasLocalGroup(n);Oe.log(''.concat(e._className, '._checkCachedGroupTips groupID:').concat(n, ' hasLocalGroup:') - .concat(a, ' checkCount:') - .concat(o)), a ? (e._notifyCachedGroupTips(n), e._checkCountMap.delete(n), e._groupModule.deleteUnjoinedAVChatRoom(n)) : o >= e.MAX_CHECK_COUNT ? (e._deleteCachedGroupTips(n), e._checkCountMap.delete(n)) : (o++, e._checkCountMap.set(n, o)); - })); - } }, { key: 'onNewGroupTips', value(e) { - Oe.debug(''.concat(this._className, '.onReceiveGroupTips count:').concat(e.dataList.length));const t = this.newGroupTipsStoredAndSummary(e); const n = t.eventDataList; const o = t.result; const a = t.AVChatRoomMessageList;(a.length > 0 && this._groupModule.onAVChatRoomMessage(a), n.length > 0) && (this._groupModule.getModule(xt).onNewMessage({ conversationOptionsList: n, isInstantMessage: !0 }), this._groupModule.updateNextMessageSeq(n));o.length > 0 && (this._groupModule.emitOuterEvent(D.MESSAGE_RECEIVED, o), this.handleMessageList(o)); - } }, { key: 'newGroupTipsStoredAndSummary', value(e) { - for (var t = e.event, n = e.dataList, o = null, a = [], s = [], i = {}, c = [], u = 0, l = n.length;u < l;u++) { - const d = n[u]; const p = d.groupProfile.groupID; const g = this._groupModule.hasLocalGroup(p);if (g || !this._groupModule.isUnjoinedAVChatRoom(p)) if (g) if (this._groupModule.isMessageFromAVChatroom(p)) { - const h = at(d);h.event = t, c.push(h); - } else { - d.currentUser = this._groupModule.getMyUserID(), d.conversationType = k.CONV_GROUP, (o = new Yr(d)).setElement({ type: k.MSG_GRP_TIP, content: r(r({}, d.elements), {}, { groupProfile: d.groupProfile }) }), o.isSystemMessage = !1;const _ = this._groupModule.getModule(xt); const f = o; const m = f.conversationID; const M = f.sequence;if (6 === t)o._onlineOnlyFlag = !0, s.push(o);else if (!_.pushIntoNoticeResult(s, o)) continue;if (6 !== t || !_.getLocalConversation(m)) { - if (6 !== t) this._groupModule.getModule(on).addMessageSequence({ key: Ha, message: o });const v = _.isRemoteRead({ conversationID: m, sequence: M });if (qe(i[m]))i[m] = a.push({ conversationID: m, unreadCount: 'in' !== o.flow || o._onlineOnlyFlag || v ? 0 : 1, type: o.conversationType, subType: o.conversationSubType, lastMessage: o }) - 1;else { - const y = i[m];a[y].type = o.conversationType, a[y].subType = o.conversationSubType, a[y].lastMessage = o, 'in' !== o.flow || o._onlineOnlyFlag || v || a[y].unreadCount++; - } - } - } else this._cacheGroupTipsAndProbe({ groupID: p, event: t, item: d }); - } return { eventDataList: a, result: s, AVChatRoomMessageList: c }; - } }, { key: 'handleMessageList', value(e) { - const t = this;e.forEach(((e) => { - switch (e.payload.operationType) { - case 1:t._onNewMemberComeIn(e);break;case 2:t._onMemberQuit(e);break;case 3:t._onMemberKickedOut(e);break;case 4:t._onMemberSetAdmin(e);break;case 5:t._onMemberCancelledAdmin(e);break;case 6:t._onGroupProfileModified(e);break;case 7:t._onMemberInfoModified(e);break;default:Oe.warn(''.concat(t._className, '.handleMessageList unknown operationType:').concat(e.payload.operationType)); - } - })); - } }, { key: '_onNewMemberComeIn', value(e) { - const t = e.payload; const n = t.memberNum; const o = t.groupProfile.groupID; const a = this._groupModule.getLocalGroupProfile(o);a && we(n) && (a.memberNum = n); - } }, { key: '_onMemberQuit', value(e) { - const t = e.payload; const n = t.memberNum; const o = t.groupProfile.groupID; const a = this._groupModule.getLocalGroupProfile(o);a && we(n) && (a.memberNum = n), this._groupModule.deleteLocalGroupMembers(o, e.payload.userIDList); - } }, { key: '_onMemberKickedOut', value(e) { - const t = e.payload; const n = t.memberNum; const o = t.groupProfile.groupID; const a = this._groupModule.getLocalGroupProfile(o);a && we(n) && (a.memberNum = n), this._groupModule.deleteLocalGroupMembers(o, e.payload.userIDList); - } }, { key: '_onMemberSetAdmin', value(e) { - const t = e.payload.groupProfile.groupID; const n = e.payload.userIDList; const o = this._groupModule.getModule(Kt);n.forEach(((e) => { - const n = o.getLocalGroupMemberInfo(t, e);n && n.updateRole(k.GRP_MBR_ROLE_ADMIN); - })); - } }, { key: '_onMemberCancelledAdmin', value(e) { - const t = e.payload.groupProfile.groupID; const n = e.payload.userIDList; const o = this._groupModule.getModule(Kt);n.forEach(((e) => { - const n = o.getLocalGroupMemberInfo(t, e);n && n.updateRole(k.GRP_MBR_ROLE_MEMBER); - })); - } }, { key: '_onGroupProfileModified', value(e) { - const t = this; const n = e.payload; const o = n.newGroupProfile; const a = n.groupProfile.groupID; const s = this._groupModule.getLocalGroupProfile(a);Object.keys(o).forEach(((e) => { - switch (e) { - case 'ownerID':t._ownerChanged(s, o);break;default:s[e] = o[e]; - } - })), this._groupModule.emitGroupListUpdate(!0, !0); - } }, { key: '_ownerChanged', value(e, t) { - const n = e.groupID; const o = this._groupModule.getLocalGroupProfile(n); const a = this._groupModule.getMyUserID();if (a === t.ownerID) { - o.updateGroup({ selfInfo: { role: k.GRP_MBR_ROLE_OWNER } });const s = this._groupModule.getModule(Kt); const r = s.getLocalGroupMemberInfo(n, a); const i = this._groupModule.getLocalGroupProfile(n).ownerID; const c = s.getLocalGroupMemberInfo(n, i);r && r.updateRole(k.GRP_MBR_ROLE_OWNER), c && c.updateRole(k.GRP_MBR_ROLE_MEMBER); - } - } }, { key: '_onMemberInfoModified', value(e) { - const t = e.payload.groupProfile.groupID; const n = this._groupModule.getModule(Kt);e.payload.memberList.forEach(((e) => { - const o = n.getLocalGroupMemberInfo(t, e.userID);o && e.muteTime && o.updateMuteUntil(e.muteTime); - })); - } }, { key: '_cacheGroupTips', value(e, t) { - this._cachedGroupTipsMap.has(e) || this._cachedGroupTipsMap.set(e, []), this._cachedGroupTipsMap.get(e).push(t); - } }, { key: '_deleteCachedGroupTips', value(e) { - this._cachedGroupTipsMap.has(e) && this._cachedGroupTipsMap.delete(e); - } }, { key: '_notifyCachedGroupTips', value(e) { - const t = this; const n = this._cachedGroupTipsMap.get(e) || [];n.forEach(((e) => { - t.onNewGroupTips(e); - })), this._deleteCachedGroupTips(e), Oe.log(''.concat(this._className, '._notifyCachedGroupTips groupID:').concat(e, ' count:') - .concat(n.length)); - } }, { key: '_cacheGroupTipsAndProbe', value(e) { - const t = this; const n = e.groupID; const o = e.event; const a = e.item;this._cacheGroupTips(n, { event: o, dataList: [a] }), this._groupModule.getGroupSimplifiedInfo(n).then(((e) => { - e.type === k.GRP_AVCHATROOM ? t._groupModule.hasLocalGroup(n) ? t._notifyCachedGroupTips(n) : t._groupModule.setUnjoinedAVChatRoom(n) : (t._groupModule.updateGroupMap([e]), t._notifyCachedGroupTips(n)); - })), this._checkCountMap.has(n) || this._checkCountMap.set(n, 0), Oe.log(''.concat(this._className, '._cacheGroupTipsAndProbe groupID:').concat(n)); - } }, { key: 'reset', value() { - this._cachedGroupTipsMap.clear(), this._checkCountMap.clear(); - } }]), e; - }()); const Ai = (function () { - function e(n) { - t(this, e), this._groupModule = n, this._className = 'CommonGroupHandler', this.tempConversationList = null, this._cachedGroupMessageMap = new Map, this._checkCountMap = new Map, this.MAX_CHECK_COUNT = 4, n.getInnerEmitterInstance().once(ii, this._initGroupList, this); - } return o(e, [{ key: 'onCheckTimer', value(e) { - e % 1 == 0 && this._cachedGroupMessageMap.size > 0 && this._checkCachedGroupMessage(); - } }, { key: '_checkCachedGroupMessage', value() { - const e = this;this._cachedGroupMessageMap.forEach(((t, n) => { - let o = e._checkCountMap.get(n); const a = e._groupModule.hasLocalGroup(n);Oe.log(''.concat(e._className, '._checkCachedGroupMessage groupID:').concat(n, ' hasLocalGroup:') - .concat(a, ' checkCount:') - .concat(o)), a ? (e._notifyCachedGroupMessage(n), e._checkCountMap.delete(n), e._groupModule.deleteUnjoinedAVChatRoom(n)) : o >= e.MAX_CHECK_COUNT ? (e._deleteCachedGroupMessage(n), e._checkCountMap.delete(n)) : (o++, e._checkCountMap.set(n, o)); - })); - } }, { key: '_initGroupList', value() { - const e = this;Oe.log(''.concat(this._className, '._initGroupList'));const t = new Xa(js); const n = this._groupModule.getStorageGroupList();if (Fe(n) && n.length > 0) { - n.forEach(((t) => { - e._groupModule.initGroupMap(t); - })), this._groupModule.emitGroupListUpdate(!0, !1);const o = this._groupModule.getLocalGroupList().length;t.setNetworkType(this._groupModule.getNetworkType()).setMessage('group count:'.concat(o)) - .end(); - } else t.setNetworkType(this._groupModule.getNetworkType()).setMessage('group count:0') - .end();Oe.log(''.concat(this._className, '._initGroupList ok')); - } }, { key: 'handleUpdateGroupLastMessage', value(e) { - const t = ''.concat(this._className, '.handleUpdateGroupLastMessage');if (Oe.debug(''.concat(t, ' conversation count:').concat(e.length, ', local group count:') - .concat(this._groupModule.getLocalGroupList().length)), 0 !== this._groupModule.getGroupMap().size) { - for (var n, o, a, s = !1, r = 0, i = e.length;r < i;r++)(n = e[r]).type === k.CONV_GROUP && (o = n.conversationID.split(/^GROUP/)[1], (a = this._groupModule.getLocalGroupProfile(o)) && (a.lastMessage = n.lastMessage, s = !0));s && (this._groupModule.sortLocalGroupList(), this._groupModule.emitGroupListUpdate(!0, !1)); - } else this.tempConversationList = e; - } }, { key: 'onNewGroupMessage', value(e) { - Oe.debug(''.concat(this._className, '.onNewGroupMessage count:').concat(e.dataList.length));const t = this._newGroupMessageStoredAndSummary(e); const n = t.conversationOptionsList; const o = t.messageList; const a = t.AVChatRoomMessageList;(a.length > 0 && this._groupModule.onAVChatRoomMessage(a), this._groupModule.filterModifiedMessage(o), n.length > 0) && (this._groupModule.getModule(xt).onNewMessage({ conversationOptionsList: n, isInstantMessage: !0 }), this._groupModule.updateNextMessageSeq(n));const s = this._groupModule.filterUnmodifiedMessage(o);s.length > 0 && this._groupModule.emitOuterEvent(D.MESSAGE_RECEIVED, s), o.length = 0; - } }, { key: '_newGroupMessageStoredAndSummary', value(e) { - const t = e.dataList; const n = e.event; const o = e.isInstantMessage; let a = null; const s = []; const r = []; const i = []; const c = {}; const u = k.CONV_GROUP; const l = this._groupModule.getModule(Yt); const d = t.length;d > 1 && t.sort(((e, t) => e.sequence - t.sequence));for (let p = 0;p < d;p++) { - const g = t[p]; const h = g.groupProfile.groupID; const _ = this._groupModule.hasLocalGroup(h);if (_ || !this._groupModule.isUnjoinedAVChatRoom(h)) if (_) if (this._groupModule.isMessageFromAVChatroom(h)) { - const f = at(g);f.event = n, i.push(f); - } else { - g.currentUser = this._groupModule.getMyUserID(), g.conversationType = u, g.isSystemMessage = !!g.isSystemMessage, a = new Yr(g), g.elements = l.parseElements(g.elements, g.from), a.setElement(g.elements);let m = 1 === t[p].isModified; const M = this._groupModule.getModule(xt);M.isMessageSentByCurrentInstance(a) ? a.isModified = m : m = !1;const v = this._groupModule.getModule(on);if (o && v.addMessageDelay({ currentTime: Date.now(), time: a.time }), 1 === g.onlineOnlyFlag)a._onlineOnlyFlag = !0, r.push(a);else { - if (!M.pushIntoMessageList(r, a, m)) continue;v.addMessageSequence({ key: Ha, message: a });const y = a; const I = y.conversationID; const C = y.sequence; const T = M.isRemoteRead({ conversationID: I, sequence: C });if (qe(c[I])) { - let S = 0;'in' === a.flow && (a._isExcludedFromUnreadCount || T || (S = 1)), c[I] = s.push({ conversationID: I, unreadCount: S, type: a.conversationType, subType: a.conversationSubType, lastMessage: a._isExcludedFromLastMessage ? '' : a }) - 1; - } else { - const D = c[I];s[D].type = a.conversationType, s[D].subType = a.conversationSubType, s[D].lastMessage = a._isExcludedFromLastMessage ? '' : a, 'in' === a.flow && (a._isExcludedFromUnreadCount || T || s[D].unreadCount++); - } - } - } else this._cacheGroupMessageAndProbe({ groupID: h, event: n, item: g }); - } return { conversationOptionsList: s, messageList: r, AVChatRoomMessageList: i }; - } }, { key: 'onGroupMessageRevoked', value(e) { - Oe.debug(''.concat(this._className, '.onGroupMessageRevoked nums:').concat(e.dataList.length));const t = this._groupModule.getModule(xt); const n = []; let o = null;e.dataList.forEach(((e) => { - const a = e.elements.revokedInfos;qe(a) || a.forEach(((e) => { - (o = t.revoke('GROUP'.concat(e.groupID), e.sequence, e.random)) && n.push(o); - })); - })), 0 !== n.length && (t.onMessageRevoked(n), this._groupModule.emitOuterEvent(D.MESSAGE_REVOKED, n)); - } }, { key: '_groupListTreeShaking', value(e) { - for (var t = new Map(M(this._groupModule.getGroupMap())), n = 0, o = e.length;n < o;n++)t.delete(e[n].groupID);this._groupModule.hasJoinedAVChatRoom() && this._groupModule.getJoinedAVChatRoom().forEach(((e) => { - t.delete(e); - }));for (let a = M(t.keys()), s = 0, r = a.length;s < r;s++) this._groupModule.deleteGroup(a[s]); - } }, { key: 'getGroupList', value(e) { - const t = this; const n = ''.concat(this._className, '.getGroupList'); const o = new Xa(Bs);Oe.log(''.concat(n));const a = { introduction: 'Introduction', notification: 'Notification', createTime: 'CreateTime', ownerID: 'Owner_Account', lastInfoTime: 'LastInfoTime', memberNum: 'MemberNum', maxMemberNum: 'MaxMemberNum', joinOption: 'ApplyJoinOption', muteAllMembers: 'ShutUpAllMember' }; const s = ['Type', 'Name', 'FaceUrl', 'NextMsgSeq', 'LastMsgTime']; const r = [];return e && e.groupProfileFilter && e.groupProfileFilter.forEach(((e) => { - a[e] && s.push(a[e]); - })), this._pagingGetGroupList({ limit: 50, offset: 0, groupBaseInfoFilter: s, groupList: r }).then((() => { - Oe.log(''.concat(n, ' ok. count:').concat(r.length)), t._groupListTreeShaking(r), t._groupModule.updateGroupMap(r);const e = t._groupModule.getLocalGroupList().length;return o.setNetworkType(t._groupModule.getNetworkType()).setMessage('remote count:'.concat(r.length, ', after tree shaking, local count:').concat(e)) - .end(), t.tempConversationList && (Oe.log(''.concat(n, ' update last message with tempConversationList, count:').concat(t.tempConversationList.length)), t.handleUpdateGroupLastMessage({ data: t.tempConversationList }), t.tempConversationList = null), t._groupModule.emitGroupListUpdate(), t._groupModule.patchGroupMessageRemindType(), t._groupModule.recomputeUnreadCount(), $r({ groupList: t._groupModule.getLocalGroupList() }); - })) - .catch((e => (t._groupModule.probeNetwork().then(((t) => { - const n = m(t, 2); const a = n[0]; const s = n[1];o.setError(e, a, s).end(); - })), Oe.error(''.concat(n, ' failed. error:'), e), ai(e)))); - } }, { key: '_pagingGetGroupList', value(e) { - const t = this; const n = ''.concat(this._className, '._pagingGetGroupList'); const o = e.limit; let a = e.offset; const s = e.groupBaseInfoFilter; const r = e.groupList; const i = new Xa($s);return this._groupModule.request({ protocolName: On, requestData: { memberAccount: this._groupModule.getMyUserID(), limit: o, offset: a, responseFilter: { groupBaseInfoFilter: s, selfInfoFilter: ['Role', 'JoinTime', 'MsgFlag', 'MsgSeq'] } } }).then(((e) => { - const c = e.data; const u = c.groups; const l = c.totalCount;r.push.apply(r, M(u));const d = a + o; const p = !(l > d);return i.setNetworkType(t._groupModule.getNetworkType()).setMessage('offset:'.concat(a, ' totalCount:').concat(l, ' isCompleted:') - .concat(p, ' currentCount:') - .concat(r.length)) - .end(), p ? (Oe.log(''.concat(n, ' ok. totalCount:').concat(l)), $r({ groupList: r })) : (a = d, t._pagingGetGroupList({ limit: o, offset: a, groupBaseInfoFilter: s, groupList: r })); - })) - .catch((e => (t._groupModule.probeNetwork().then(((t) => { - const n = m(t, 2); const o = n[0]; const a = n[1];i.setError(e, o, a).end(); - })), ai(e)))); - } }, { key: '_cacheGroupMessage', value(e, t) { - this._cachedGroupMessageMap.has(e) || this._cachedGroupMessageMap.set(e, []), this._cachedGroupMessageMap.get(e).push(t); - } }, { key: '_deleteCachedGroupMessage', value(e) { - this._cachedGroupMessageMap.has(e) && this._cachedGroupMessageMap.delete(e); - } }, { key: '_notifyCachedGroupMessage', value(e) { - const t = this; const n = this._cachedGroupMessageMap.get(e) || [];n.forEach(((e) => { - t.onNewGroupMessage(e); - })), this._deleteCachedGroupMessage(e), Oe.log(''.concat(this._className, '._notifyCachedGroupMessage groupID:').concat(e, ' count:') - .concat(n.length)); - } }, { key: '_cacheGroupMessageAndProbe', value(e) { - const t = this; const n = e.groupID; const o = e.event; const a = e.item;this._cacheGroupMessage(n, { event: o, dataList: [a] }), this._groupModule.getGroupSimplifiedInfo(n).then(((e) => { - e.type === k.GRP_AVCHATROOM ? t._groupModule.hasLocalGroup(n) ? t._notifyCachedGroupMessage(n) : t._groupModule.setUnjoinedAVChatRoom(n) : (t._groupModule.updateGroupMap([e]), t._notifyCachedGroupMessage(n)); - })), this._checkCountMap.has(n) || this._checkCountMap.set(n, 0), Oe.log(''.concat(this._className, '._cacheGroupMessageAndProbe groupID:').concat(n)); - } }, { key: 'reset', value() { - this._cachedGroupMessageMap.clear(), this._checkCountMap.clear(), this._groupModule.getInnerEmitterInstance().once(ii, this._initGroupList, this); - } }]), e; - }()); const Ni = { 1: 'init', 2: 'modify', 3: 'clear', 4: 'delete' }; const Li = (function () { - function e(n) { - t(this, e), this._groupModule = n, this._className = 'GroupAttributesHandler', this._groupAttributesMap = new Map, this.CACHE_EXPIRE_TIME = 3e4, this._groupModule.getInnerEmitterInstance().on(ci, this._onCloudConfigUpdated, this); - } return o(e, [{ key: '_onCloudConfigUpdated', value() { - const e = this._groupModule.getCloudConfig('grp_attr_cache_time');qe(e) || (this.CACHE_EXPIRE_TIME = Number(e)); - } }, { key: 'updateLocalMainSequenceOnReconnected', value() { - this._groupAttributesMap.forEach(((e) => { - e.localMainSequence = 0; - })); - } }, { key: 'onGroupAttributesUpdated', value(e) { - const t = this; const n = e.groupID; const o = e.groupAttributeOption; const a = o.mainSequence; const s = o.hasChangedAttributeInfo; const r = o.groupAttributeList; let i = void 0 === r ? [] : r; const c = o.operationType;if (Oe.log(''.concat(this._className, '.onGroupAttributesUpdated. hasChangedAttributeInfo:').concat(s, ' operationType:') - .concat(c)), !qe(c)) { - if (1 === s) { - if (4 === c) { - let u = [];i.forEach(((e) => { - u.push(e.key); - })), i = M(u), u = null; - } return this._refreshCachedGroupAttributes({ groupID: n, remoteMainSequence: a, groupAttributeList: i, operationType: Ni[c] }), void this._emitGroupAttributesUpdated(n); - } if (this._groupAttributesMap.has(n)) { - const l = this._groupAttributesMap.get(n).avChatRoomKey;this._getGroupAttributes({ groupID: n, avChatRoomKey: l }).then((() => { - t._emitGroupAttributesUpdated(n); - })); - } - } - } }, { key: 'initGroupAttributesCache', value(e) { - const t = e.groupID; const n = e.avChatRoomKey;this._groupAttributesMap.set(t, { lastUpdateTime: 0, localMainSequence: 0, remoteMainSequence: 0, attributes: new Map, avChatRoomKey: n }), Oe.log(''.concat(this._className, '.initGroupAttributesCache groupID:').concat(t, ' avChatRoomKey:') - .concat(n)); - } }, { key: 'initGroupAttributes', value(e) { - const t = this; const n = e.groupID; const o = e.groupAttributes; const a = this._checkCachedGroupAttributes({ groupID: n, funcName: 'initGroupAttributes' });if (!0 !== a) return ai(a);const s = this._groupAttributesMap.get(n); const r = s.remoteMainSequence; const i = s.avChatRoomKey; const c = new Xa(Xs);return c.setMessage('groupID:'.concat(n, ' mainSequence:').concat(r, ' groupAttributes:') - .concat(JSON.stringify(o))), this._groupModule.request({ protocolName: eo, requestData: { groupID: n, avChatRoomKey: i, mainSequence: r, groupAttributeList: this._transformGroupAttributes(o) } }).then(((e) => { - const a = e.data; const s = a.mainSequence; const r = M(a.groupAttributeList);return r.forEach(((e) => { - e.value = o[e.key]; - })), t._refreshCachedGroupAttributes({ groupID: n, remoteMainSequence: s, groupAttributeList: r, operationType: 'init' }), c.setNetworkType(t._groupModule.getNetworkType()).end(), Oe.log(''.concat(t._className, '.initGroupAttributes ok. groupID:').concat(n)), $r({ groupAttributes: o }); - })) - .catch((e => (t._groupModule.probeNetwork().then(((t) => { - const n = m(t, 2); const o = n[0]; const a = n[1];c.setError(e, o, a).end(); - })), ai(e)))); - } }, { key: 'setGroupAttributes', value(e) { - const t = this; const n = e.groupID; const o = e.groupAttributes; const a = this._checkCachedGroupAttributes({ groupID: n, funcName: 'setGroupAttributes' });if (!0 !== a) return ai(a);const s = this._groupAttributesMap.get(n); const r = s.remoteMainSequence; const i = s.avChatRoomKey; const c = s.attributes; const u = this._transformGroupAttributes(o);u.forEach(((e) => { - const t = e.key;e.sequence = 0, c.has(t) && (e.sequence = c.get(t).sequence); - }));const l = new Xa(Qs);return l.setMessage('groupID:'.concat(n, ' mainSequence:').concat(r, ' groupAttributes:') - .concat(JSON.stringify(o))), this._groupModule.request({ protocolName: to, requestData: { groupID: n, avChatRoomKey: i, mainSequence: r, groupAttributeList: u } }).then(((e) => { - const a = e.data; const s = a.mainSequence; const r = M(a.groupAttributeList);return r.forEach(((e) => { - e.value = o[e.key]; - })), t._refreshCachedGroupAttributes({ groupID: n, remoteMainSequence: s, groupAttributeList: r, operationType: 'modify' }), l.setNetworkType(t._groupModule.getNetworkType()).end(), Oe.log(''.concat(t._className, '.setGroupAttributes ok. groupID:').concat(n)), $r({ groupAttributes: o }); - })) - .catch((e => (t._groupModule.probeNetwork().then(((t) => { - const n = m(t, 2); const o = n[0]; const a = n[1];l.setError(e, o, a).end(); - })), ai(e)))); - } }, { key: 'deleteGroupAttributes', value(e) { - const t = this; const n = e.groupID; const o = e.keyList; const a = void 0 === o ? [] : o; const s = this._checkCachedGroupAttributes({ groupID: n, funcName: 'deleteGroupAttributes' });if (!0 !== s) return ai(s);const r = this._groupAttributesMap.get(n); const i = r.remoteMainSequence; const c = r.avChatRoomKey; const u = r.attributes; let l = M(u.keys()); let d = oo; let p = 'clear'; const g = { groupID: n, avChatRoomKey: c, mainSequence: i };if (a.length > 0) { - const h = [];l = [], d = no, p = 'delete', a.forEach(((e) => { - let t = 0;u.has(e) && (t = u.get(e).sequence, l.push(e)), h.push({ key: e, sequence: t }); - })), g.groupAttributeList = h; - } const _ = new Xa(Zs);return _.setMessage('groupID:'.concat(n, ' mainSequence:').concat(i, ' keyList:') - .concat(a, ' protocolName:') - .concat(d)), this._groupModule.request({ protocolName: d, requestData: g }).then(((e) => { - const o = e.data.mainSequence;return t._refreshCachedGroupAttributes({ groupID: n, remoteMainSequence: o, groupAttributeList: a, operationType: p }), _.setNetworkType(t._groupModule.getNetworkType()).end(), Oe.log(''.concat(t._className, '.deleteGroupAttributes ok. groupID:').concat(n)), $r({ keyList: l }); - })) - .catch((e => (t._groupModule.probeNetwork().then(((t) => { - const n = m(t, 2); const o = n[0]; const a = n[1];_.setError(e, o, a).end(); - })), ai(e)))); - } }, { key: 'getGroupAttributes', value(e) { - const t = this; const n = e.groupID; const o = this._checkCachedGroupAttributes({ groupID: n, funcName: 'getGroupAttributes' });if (!0 !== o) return ai(o);const a = this._groupAttributesMap.get(n); const s = a.avChatRoomKey; const r = a.lastUpdateTime; const i = a.localMainSequence; const c = a.remoteMainSequence; const u = new Xa(er);if (u.setMessage('groupID:'.concat(n, ' localMainSequence:').concat(i, ' remoteMainSequence:') - .concat(c, ' keyList:') - .concat(e.keyList)), Date.now() - r >= this.CACHE_EXPIRE_TIME || i < c) return this._getGroupAttributes({ groupID: n, avChatRoomKey: s }).then(((o) => { - u.setMoreMessage('get attributes from remote. count:'.concat(o.length)).setNetworkType(t._groupModule.getNetworkType()) - .end(), Oe.log(''.concat(t._className, '.getGroupAttributes from remote. groupID:').concat(n));const a = t._getLocalGroupAttributes(e);return $r({ groupAttributes: a }); - })) - .catch((e => (t._groupModule.probeNetwork().then(((t) => { - const n = m(t, 2); const o = n[0]; const a = n[1];u.setError(e, o, a).end(); - })), ai(e))));u.setMoreMessage('get attributes from cache').setNetworkType(this._groupModule.getNetworkType()) - .end(), Oe.log(''.concat(this._className, '.getGroupAttributes from cache. groupID:').concat(n));const l = this._getLocalGroupAttributes(e);return oi({ groupAttributes: l }); - } }, { key: '_getGroupAttributes', value(e) { - const t = this;return this._groupModule.request({ protocolName: ao, requestData: r({}, e) }).then(((n) => { - const o = n.data; const a = o.mainSequence; const s = o.groupAttributeList; const r = M(s);return qe(a) || t._refreshCachedGroupAttributes({ groupID: e.groupID, remoteMainSequence: a, groupAttributeList: r, operationType: 'get' }), Oe.log(''.concat(t._className, '._getGroupAttributes ok. groupID:').concat(e.groupID)), s; - })) - .catch((e => ai(e))); - } }, { key: '_getLocalGroupAttributes', value(e) { - const t = e.groupID; const n = e.keyList; const o = void 0 === n ? [] : n; const a = {};if (!this._groupAttributesMap.has(t)) return a;const s = this._groupAttributesMap.get(t).attributes;if (o.length > 0)o.forEach(((e) => { - s.has(e) && (a[e] = s.get(e).value); - }));else { - let r; const i = S(s.keys());try { - for (i.s();!(r = i.n()).done;) { - const c = r.value;a[c] = s.get(c).value; - } - } catch (u) { - i.e(u); - } finally { - i.f(); - } - } return a; - } }, { key: '_refreshCachedGroupAttributes', value(e) { - const t = e.groupID; const n = e.remoteMainSequence; const o = e.groupAttributeList; const a = e.operationType;if (this._groupAttributesMap.has(t)) { - const s = this._groupAttributesMap.get(t); const r = s.localMainSequence;if ('get' === a || n - r == 1)s.remoteMainSequence = n, s.localMainSequence = n, s.lastUpdateTime = Date.now(), this._updateCachedAttributes({ groupAttributes: s, groupAttributeList: o, operationType: a });else { - if (r === n) return;s.remoteMainSequence = n; - } this._groupAttributesMap.set(t, s);const i = 'operationType:'.concat(a, ' localMainSequence:').concat(r, ' remoteMainSequence:') - .concat(n);Oe.log(''.concat(this._className, '._refreshCachedGroupAttributes. ').concat(i)); - } - } }, { key: '_updateCachedAttributes', value(e) { - const t = e.groupAttributes; const n = e.groupAttributeList; const o = e.operationType;'clear' !== o ? 'delete' !== o ? ('init' === o && t.attributes.clear(), n.forEach(((e) => { - const n = e.key; const o = e.value; const a = e.sequence;t.attributes.set(n, { value: o, sequence: a }); - }))) : n.forEach(((e) => { - t.attributes.delete(e); - })) : t.attributes.clear(); - } }, { key: '_checkCachedGroupAttributes', value(e) { - const t = e.groupID; const n = e.funcName;if (this._groupModule.hasLocalGroup(t) && this._groupModule.getLocalGroupProfile(t).type !== k.GRP_AVCHATROOM) { - return Oe.warn(''.concat(this._className, '._checkCachedGroupAttributes. ').concat('非直播群不能使用群属性 API')), new ei({ code: Do.CANNOT_USE_GRP_ATTR_NOT_AVCHATROOM, message: '非直播群不能使用群属性 API' }); - } const o = this._groupAttributesMap.get(t);if (qe(o)) { - const a = '如果 groupID:'.concat(t, ' 是直播群,使用 ').concat(n, ' 前先使用 joinGroup 接口申请加入群组,详细请参考 https://web.sdk.qcloud.com/im/doc/zh-cn/SDK.html#joinGroup');return Oe.warn(''.concat(this._className, '._checkCachedGroupAttributes. ').concat(a)), new ei({ code: Do.CANNOT_USE_GRP_ATTR_AVCHATROOM_UNJOIN, message: a }); - } return !0; - } }, { key: '_transformGroupAttributes', value(e) { - const t = [];return Object.keys(e).forEach(((n) => { - t.push({ key: n, value: e[n] }); - })), t; - } }, { key: '_emitGroupAttributesUpdated', value(e) { - const t = this._getLocalGroupAttributes({ groupID: e });this._groupModule.emitOuterEvent(D.GROUP_ATTRIBUTES_UPDATED, { groupID: e, groupAttributes: t }); - } }, { key: 'reset', value() { - this._groupAttributesMap.clear(), this.CACHE_EXPIRE_TIME = 3e4; - } }]), e; - }()); const Ri = (function () { - function e(n) { - t(this, e);const o = n.manager; const a = n.groupID; const s = n.onInit; const r = n.onSuccess; const i = n.onFail;this._className = 'Polling', this._manager = o, this._groupModule = o._groupModule, this._onInit = s, this._onSuccess = r, this._onFail = i, this._groupID = a, this._timeoutID = -1, this._isRunning = !1, this._protocolName = Jn; - } return o(e, [{ key: 'start', value() { - const e = this._groupModule.isLoggedIn();e || (this._protocolName = Xn), Oe.log(''.concat(this._className, '.start pollingInterval:').concat(this._manager.getPollingInterval(), ' isLoggedIn:') - .concat(e)), this._isRunning = !0, this._request(); - } }, { key: 'isRunning', value() { - return this._isRunning; - } }, { key: '_request', value() { - const e = this; const t = this._onInit(this._groupID);this._groupModule.request({ protocolName: this._protocolName, requestData: t }).then(((t) => { - e._onSuccess(e._groupID, t), e.isRunning() && (clearTimeout(e._timeoutID), e._timeoutID = setTimeout(e._request.bind(e), e._manager.getPollingInterval())); - })) - .catch(((t) => { - e._onFail(e._groupID, t), e.isRunning() && (clearTimeout(e._timeoutID), e._timeoutID = setTimeout(e._request.bind(e), e._manager.MAX_POLLING_INTERVAL)); - })); - } }, { key: 'stop', value() { - Oe.log(''.concat(this._className, '.stop')), this._timeoutID > 0 && (clearTimeout(this._timeoutID), this._timeoutID = -1), this._isRunning = !1; - } }]), e; - }()); const Oi = { 3: !0, 4: !0, 5: !0, 6: !0 }; const Gi = (function () { - function e(n) { - t(this, e), this._groupModule = n, this._className = 'AVChatRoomHandler', this._joinedGroupMap = new Map, this._pollingRequestInfoMap = new Map, this._pollingInstanceMap = new Map, this.sequencesLinkedList = new vi(100), this.messageIDLinkedList = new vi(100), this.receivedMessageCount = 0, 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; - } return o(e, [{ key: 'hasJoinedAVChatRoom', value() { - return this._joinedGroupMap.size > 0; - } }, { key: 'checkJoinedAVChatRoomByID', value(e) { - return this._joinedGroupMap.has(e); - } }, { key: 'getJoinedAVChatRoom', value() { - return this._joinedGroupMap.size > 0 ? M(this._joinedGroupMap.keys()) : null; - } }, { key: '_updateRequestData', value(e) { - return r({}, this._pollingRequestInfoMap.get(e)); - } }, { key: '_handleSuccess', value(e, t) { - const n = t.data; const o = n.key; const a = n.nextSeq; const s = n.rspMsgList;if (0 !== n.errorCode) { - const r = this._pollingRequestInfoMap.get(e); const i = new Xa(lr); const c = r ? ''.concat(r.key, '-').concat(r.startSeq) : 'requestInfo is undefined';i.setMessage(''.concat(e, '-').concat(c, '-') - .concat(t.errorInfo)).setCode(t.errorCode) - .setNetworkType(this._groupModule.getNetworkType()) - .end(!0); - } else { - if (!this.checkJoinedAVChatRoomByID(e)) return;be(o) && we(a) && this._pollingRequestInfoMap.set(e, { key: o, startSeq: a }), Fe(s) && s.length > 0 && (s.forEach(((e) => { - e.to = e.groupID; - })), this.onMessage(s)); - } - } }, { key: '_handleFailure', value(e, t) {} }, { key: 'onMessage', value(e) { - if (Fe(e) && 0 !== e.length) { - let t = null; const n = []; const o = this._getModule(xt); const a = e.length;a > 1 && e.sort(((e, t) => e.sequence - t.sequence));for (let s = this._getModule(Bt), r = 0;r < a;r++) if (Oi[e[r].event]) { - this.receivedMessageCount += 1, t = this.packMessage(e[r], e[r].event);const i = 1 === e[r].isModified; const c = 1 === e[r].isHistoryMessage;if ((s.isUnlimitedAVChatRoom() || !this.sequencesLinkedList.has(t.sequence)) && !this.messageIDLinkedList.has(t.ID)) { - const u = t.conversationID;if (this.receivedMessageCount % 40 == 0 && this._getModule(Zt).detectMessageLoss(u, this.sequencesLinkedList.data()), null !== this.sequencesLinkedList.tail()) { - const l = this.sequencesLinkedList.tail().value; const d = t.sequence - l;d > 1 && d <= 20 ? this._getModule(Zt).onMessageMaybeLost(u, l + 1, d - 1) : d < -1 && d >= -20 && this._getModule(Zt).onMessageMaybeLost(u, t.sequence + 1, Math.abs(d) - 1); - } this.sequencesLinkedList.set(t.sequence), this.messageIDLinkedList.set(t.ID);let p = !1;if (this._isMessageSentByCurrentInstance(t) ? i && (p = !0, t.isModified = i, o.updateMessageIsModifiedProperty(t)) : p = !0, p) { - if (t.conversationType, k.CONV_SYSTEM, !c && t.conversationType !== k.CONV_SYSTEM) { - const g = this._getModule(on); const h = t.conversationID.replace(k.CONV_GROUP, '');this._pollingInstanceMap.has(h) ? g.addMessageSequence({ key: Wa, message: t }) : (t.type !== k.MSG_GRP_TIP && g.addMessageDelay({ currentTime: Date.now(), time: t.time }), g.addMessageSequence({ key: ja, message: t })); - }n.push(t); - } - } - } else Oe.warn(''.concat(this._className, '.onMessage 未处理的 event 类型: ').concat(e[r].event));if (0 !== n.length) { - this._groupModule.filterModifiedMessage(n);const _ = this.packConversationOption(n);if (_.length > 0) this._getModule(xt).onNewMessage({ conversationOptionsList: _, isInstantMessage: !0 });Oe.debug(''.concat(this._className, '.onMessage count:').concat(n.length)), this._checkMessageStacked(n);const f = this._groupModule.filterUnmodifiedMessage(n);f.length > 0 && this._groupModule.emitOuterEvent(D.MESSAGE_RECEIVED, f), n.length = 0; - } - } - } }, { key: '_checkMessageStacked', value(e) { - const t = e.length;t >= 100 && (Oe.warn(''.concat(this._className, '._checkMessageStacked 直播群消息堆积数:').concat(e.length, '!可能会导致微信小程序渲染时遇到 "Dom limit exceeded" 的错误,建议接入侧此时只渲染最近的10条消息')), this._reportMessageStackedCount < 5 && (new Xa(pr).setNetworkType(this._groupModule.getNetworkType()) - .setMessage('count:'.concat(t, ' groupID:').concat(M(this._joinedGroupMap.keys()))) - .setLevel('warning') - .end(), this._reportMessageStackedCount += 1)); - } }, { key: '_isMessageSentByCurrentInstance', value(e) { - return !!this._getModule(xt).isMessageSentByCurrentInstance(e); - } }, { key: 'packMessage', value(e, t) { - e.currentUser = this._groupModule.getMyUserID(), e.conversationType = 5 === t ? k.CONV_SYSTEM : k.CONV_GROUP, e.isSystemMessage = !!e.isSystemMessage;const n = new Yr(e); const o = this.packElements(e, t);return n.setElement(o), n; - } }, { key: 'packElements', value(e, t) { - return 4 === t || 6 === t ? (this._updateMemberCountByGroupTips(e), this._onGroupAttributesUpdated(e), { type: k.MSG_GRP_TIP, content: r(r({}, e.elements), {}, { groupProfile: e.groupProfile }) }) : 5 === t ? { type: k.MSG_GRP_SYS_NOTICE, content: r(r({}, e.elements), {}, { groupProfile: e.groupProfile }) } : this._getModule(Yt).parseElements(e.elements, e.from); - } }, { key: 'packConversationOption', value(e) { - for (var t = new Map, n = 0;n < e.length;n++) { - const o = e[n]; const a = o.conversationID;if (t.has(a)) { - const s = t.get(a);s.lastMessage = o, 'in' === o.flow && s.unreadCount++; - } else t.set(a, { conversationID: o.conversationID, unreadCount: 'out' === o.flow ? 0 : 1, type: o.conversationType, subType: o.conversationSubType, lastMessage: o }); - } return M(t.values()); - } }, { key: '_updateMemberCountByGroupTips', value(e) { - const t = e.groupProfile.groupID; const n = e.elements.onlineMemberInfo; const o = void 0 === n ? void 0 : n;if (!It(o)) { - const a = o.onlineMemberNum; const s = void 0 === a ? 0 : a; const r = o.expireTime; const i = void 0 === r ? this.DEFAULT_EXPIRE_TIME : r; const c = this._onlineMemberCountMap.get(t) || {}; const u = Date.now();It(c) ? Object.assign(c, { lastReqTime: 0, lastSyncTime: 0, latestUpdateTime: u, memberCount: s, expireTime: i }) : (c.latestUpdateTime = u, c.memberCount = s), Oe.debug(''.concat(this._className, '._updateMemberCountByGroupTips info:'), c), this._onlineMemberCountMap.set(t, c); - } - } }, { key: 'start', value(e) { - if (this._pollingInstanceMap.has(e)) { - const t = this._pollingInstanceMap.get(e);t.isRunning() || t.start(); - } else { - const n = new Ri({ manager: this, groupID: e, onInit: this._updateRequestData.bind(this), onSuccess: this._handleSuccess.bind(this), onFail: this._handleFailure.bind(this) });n.start(), this._pollingInstanceMap.set(e, n), Oe.log(''.concat(this._className, '.start groupID:').concat(e)); - } - } }, { key: 'handleJoinResult', value(e) { - const t = this;return this._preCheck().then((() => { - const n = e.longPollingKey; const o = e.group; const a = o.groupID;return t._joinedGroupMap.set(a, o), t._groupModule.updateGroupMap([o]), t._groupModule.deleteUnjoinedAVChatRoom(a), t._groupModule.emitGroupListUpdate(!0, !1), qe(n) ? oi({ status: Rr, group: o }) : Promise.resolve(); - })); - } }, { key: 'startRunLoop', value(e) { - const t = this;return this.handleJoinResult(e).then((() => { - const n = e.longPollingKey; const o = e.group; const a = o.groupID;return t._pollingRequestInfoMap.set(a, { key: n, startSeq: 0 }), t.start(a), t._groupModule.isLoggedIn() ? oi({ status: Rr, group: o }) : oi({ status: Rr }); - })); - } }, { key: '_preCheck', value() { - if (this._getModule(Bt).isUnlimitedAVChatRoom()) return Promise.resolve();if (!this.hasJoinedAVChatRoom()) return Promise.resolve();const e = m(this._joinedGroupMap.entries().next().value, 2); const t = e[0]; const n = e[1];if (this._groupModule.isLoggedIn()) { - if (!(n.selfInfo.role === k.GRP_MBR_ROLE_OWNER || n.ownerID === this._groupModule.getMyUserID())) return this._groupModule.quitGroup(t);this._groupModule.deleteLocalGroupAndConversation(t); - } else this._groupModule.deleteLocalGroupAndConversation(t);return this.reset(t), Promise.resolve(); - } }, { key: 'joinWithoutAuth', value(e) { - const t = this; const n = e.groupID; const o = ''.concat(this._className, '.joinWithoutAuth'); const a = new Xa(Js);return this._groupModule.request({ protocolName: Fn, requestData: e }).then(((e) => { - const s = e.data.longPollingKey;if (t._groupModule.probeNetwork().then(((e) => { - const t = m(e, 2); const o = (t[0], t[1]);a.setNetworkType(o).setMessage('groupID:'.concat(n, ' longPollingKey:').concat(s)) - .end(!0); - })), qe(s)) return ai(new ei({ code: Do.CANNOT_JOIN_NON_AVCHATROOM_WITHOUT_LOGIN, message: fa }));Oe.log(''.concat(o, ' ok. groupID:').concat(n)), t._getModule(xt).setCompleted(''.concat(k.CONV_GROUP).concat(n));const r = new Ii({ groupID: n });return t.startRunLoop({ group: r, longPollingKey: s }), $r({ status: Rr }); - })) - .catch((e => (Oe.error(''.concat(o, ' failed. groupID:').concat(n, ' error:'), e), t._groupModule.probeNetwork().then(((t) => { - const o = m(t, 2); const s = o[0]; const r = o[1];a.setError(e, s, r).setMessage('groupID:'.concat(n)) - .end(!0); - })), ai(e)))) - .finally((() => { - t._groupModule.getModule(jt).reportAtOnce(); - })); - } }, { key: 'getGroupOnlineMemberCount', value(e) { - const t = this._onlineMemberCountMap.get(e) || {}; const n = Date.now();return It(t) || n - t.lastSyncTime > 1e3 * t.expireTime && n - t.latestUpdateTime > 1e4 && n - t.lastReqTime > 3e3 ? (t.lastReqTime = n, this._onlineMemberCountMap.set(e, t), this._getGroupOnlineMemberCount(e).then((e => $r({ memberCount: e.memberCount }))) - .catch((e => ai(e)))) : oi({ memberCount: t.memberCount }); - } }, { key: '_getGroupOnlineMemberCount', value(e) { - const t = this; const n = ''.concat(this._className, '._getGroupOnlineMemberCount');return this._groupModule.request({ protocolName: Qn, requestData: { groupID: e } }).then(((o) => { - const a = t._onlineMemberCountMap.get(e) || {}; const s = o.data; const r = s.onlineMemberNum; const i = void 0 === r ? 0 : r; const c = s.expireTime; const u = void 0 === c ? t.DEFAULT_EXPIRE_TIME : c;Oe.log(''.concat(n, ' ok. groupID:').concat(e, ' memberCount:') - .concat(i, ' expireTime:') - .concat(u));const l = Date.now();return It(a) && (a.lastReqTime = l), t._onlineMemberCountMap.set(e, Object.assign(a, { lastSyncTime: l, latestUpdateTime: l, memberCount: i, expireTime: u })), { memberCount: i }; - })) - .catch((o => (Oe.warn(''.concat(n, ' failed. error:'), o), new Xa(ur).setCode(o.code) - .setMessage('groupID:'.concat(e, ' error:').concat(JSON.stringify(o))) - .setNetworkType(t._groupModule.getNetworkType()) - .end(), Promise.reject(o)))); - } }, { key: '_onGroupAttributesUpdated', value(e) { - const t = e.groupProfile.groupID; const n = e.elements; const o = n.operationType; const a = n.newGroupProfile;if (6 === o) { - const s = (void 0 === a ? void 0 : a).groupAttributeOption;It(s) || this._groupModule.onGroupAttributesUpdated({ groupID: t, groupAttributeOption: s }); - } - } }, { key: '_getModule', value(e) { - return this._groupModule.getModule(e); - } }, { key: 'setPollingInterval', value(e) { - qe(e) || we(e) || (this._pollingInterval = parseInt(e, 10), Oe.log(''.concat(this._className, '.setPollingInterval value:').concat(this._pollingInterval))); - } }, { key: 'getPollingInterval', value() { - return this._pollingInterval; - } }, { key: 'reset', value(e) { - if (e) { - Oe.log(''.concat(this._className, '.reset groupID:').concat(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 { - Oe.log(''.concat(this._className, '.reset all'));let n; const o = S(this._pollingInstanceMap.values());try { - for (o.s();!(n = o.n()).done;) { - n.value.stop(); - } - } catch (a) { - o.e(a); - } finally { - o.f(); - } this._pollingInstanceMap.clear(), this._joinedGroupMap.clear(), this._pollingRequestInfoMap.clear(), this._onlineMemberCountMap.clear(); - } this.sequencesLinkedList.reset(), this.messageIDLinkedList.reset(), this.receivedMessageCount = 0, this._reportMessageStackedCount = 0, this._pollingInterval = this.DEFAULT_POLLING_INTERVAL; - } }]), e; - }()); const wi = 1; const bi = 15; const Pi = (function () { - function e(n) { - t(this, e), this._groupModule = n, this._className = 'GroupSystemNoticeHandler', this.pendencyMap = new Map; - } return o(e, [{ key: 'onNewGroupSystemNotice', value(e) { - const t = e.dataList; const n = e.isSyncingEnded; const o = e.isInstantMessage;Oe.debug(''.concat(this._className, '.onReceiveSystemNotice count:').concat(t.length));const a = this.newSystemNoticeStoredAndSummary({ notifiesList: t, isInstantMessage: o }); const s = a.eventDataList; const r = a.result;s.length > 0 && (this._groupModule.getModule(xt).onNewMessage({ conversationOptionsList: s, isInstantMessage: o }), this._onReceivedGroupSystemNotice({ result: r, isInstantMessage: o }));o ? r.length > 0 && this._groupModule.emitOuterEvent(D.MESSAGE_RECEIVED, r) : !0 === n && this._clearGroupSystemNotice(); - } }, { key: 'newSystemNoticeStoredAndSummary', value(e) { - const t = e.notifiesList; const n = e.isInstantMessage; let o = null; const a = t.length; let s = 0; const i = []; const c = { conversationID: k.CONV_SYSTEM, unreadCount: 0, type: k.CONV_SYSTEM, subType: null, lastMessage: null };for (s = 0;s < a;s++) { - const u = t[s];if (u.elements.operationType !== bi)u.currentUser = this._groupModule.getMyUserID(), u.conversationType = k.CONV_SYSTEM, u.conversationID = k.CONV_SYSTEM, (o = new Yr(u)).setElement({ type: k.MSG_GRP_SYS_NOTICE, content: r(r({}, u.elements), {}, { groupProfile: u.groupProfile }) }), o.isSystemMessage = !0, (1 === o.sequence && 1 === o.random || 2 === o.sequence && 2 === o.random) && (o.sequence = Je(), o.random = Je(), o.generateMessageID(u.currentUser), Oe.log(''.concat(this._className, '.newSystemNoticeStoredAndSummary sequence and random maybe duplicated, regenerate. ID:').concat(o.ID))), this._groupModule.getModule(xt).pushIntoNoticeResult(i, o) && (n ? c.unreadCount++ : o.setIsRead(!0), c.subType = o.conversationSubType); - } return c.lastMessage = i[i.length - 1], { eventDataList: i.length > 0 ? [c] : [], result: i }; - } }, { key: '_clearGroupSystemNotice', value() { - const e = this;this.getPendencyList().then(((t) => { - t.forEach(((t) => { - e.pendencyMap.set(''.concat(t.from, '_').concat(t.groupID, '_') - .concat(t.to), t); - }));const n = e._groupModule.getModule(xt).getLocalMessageList(k.CONV_SYSTEM); const o = [];n.forEach(((t) => { - const n = t.payload; const a = n.operatorID; const s = n.operationType; const r = n.groupProfile;if (s === wi) { - const i = ''.concat(a, '_').concat(r.groupID, '_') - .concat(r.to); const c = e.pendencyMap.get(i);c && we(c.handled) && 0 !== c.handled && o.push(t); - } - })), e.deleteGroupSystemNotice({ messageList: o }); - })); - } }, { key: 'deleteGroupSystemNotice', value(e) { - const t = this; const n = ''.concat(this._className, '.deleteGroupSystemNotice');return Fe(e.messageList) && 0 !== e.messageList.length ? (Oe.log(''.concat(n) + e.messageList.map((e => e.ID))), this._groupModule.request({ protocolName: zn, requestData: { messageListToDelete: e.messageList.map((e => ({ from: k.CONV_SYSTEM, messageSeq: e.clientSequence, messageRandom: e.random }))) } }).then((() => { - Oe.log(''.concat(n, ' ok'));const o = t._groupModule.getModule(xt);return e.messageList.forEach(((e) => { - o.deleteLocalMessage(e); - })), $r(); - })) - .catch((e => (Oe.error(''.concat(n, ' error:'), e), ai(e))))) : oi(); - } }, { key: 'getPendencyList', value(e) { - const t = this;return this._groupModule.request({ protocolName: $n, requestData: { startTime: e && e.startTime ? e.startTime : 0, limit: e && e.limit ? e.limit : 10, handleAccount: this._groupModule.getMyUserID() } }).then(((e) => { - const n = e.data.pendencyList;return 0 !== e.data.nextStartTime ? t.getPendencyList({ startTime: e.data.nextStartTime }).then((e => [].concat(M(n), M(e)))) : n; - })); - } }, { key: '_onReceivedGroupSystemNotice', value(e) { - const t = this; const n = e.result;e.isInstantMessage && n.forEach(((e) => { - switch (e.payload.operationType) { - case 1:break;case 2:t._onApplyGroupRequestAgreed(e);break;case 3:break;case 4:t._onMemberKicked(e);break;case 5:t._onGroupDismissed(e);break;case 6:break;case 7:t._onInviteGroup(e);break;case 8:t._onQuitGroup(e);break;case 9:t._onSetManager(e);break;case 10:t._onDeleteManager(e); - } - })); - } }, { key: '_onApplyGroupRequestAgreed', value(e) { - const t = this; const n = e.payload.groupProfile.groupID;this._groupModule.hasLocalGroup(n) || this._groupModule.getGroupProfile({ groupID: n }).then(((e) => { - const n = e.data.group;n && (t._groupModule.updateGroupMap([n]), t._groupModule.emitGroupListUpdate()); - })); - } }, { key: '_onMemberKicked', value(e) { - const t = e.payload.groupProfile.groupID;this._groupModule.hasLocalGroup(t) && this._groupModule.deleteLocalGroupAndConversation(t); - } }, { key: '_onGroupDismissed', value(e) { - const t = e.payload.groupProfile.groupID;this._groupModule.hasLocalGroup(t) && this._groupModule.deleteLocalGroupAndConversation(t);const n = this._groupModule._AVChatRoomHandler;n && n.checkJoinedAVChatRoomByID(t) && n.reset(t); - } }, { key: '_onInviteGroup', value(e) { - const t = this; const n = e.payload.groupProfile.groupID;this._groupModule.hasLocalGroup(n) || this._groupModule.getGroupProfile({ groupID: n }).then(((e) => { - const n = e.data.group;n && (t._groupModule.updateGroupMap([n]), t._groupModule.emitGroupListUpdate()); - })); - } }, { key: '_onQuitGroup', value(e) { - const t = e.payload.groupProfile.groupID;this._groupModule.hasLocalGroup(t) && this._groupModule.deleteLocalGroupAndConversation(t); - } }, { key: '_onSetManager', value(e) { - const t = e.payload.groupProfile; const n = t.to; const o = t.groupID; const a = this._groupModule.getModule(Kt).getLocalGroupMemberInfo(o, n);a && a.updateRole(k.GRP_MBR_ROLE_ADMIN); - } }, { key: '_onDeleteManager', value(e) { - const t = e.payload.groupProfile; const n = t.to; const o = t.groupID; const a = this._groupModule.getModule(Kt).getLocalGroupMemberInfo(o, n);a && a.updateRole(k.GRP_MBR_ROLE_MEMBER); - } }, { key: 'reset', value() { - this.pendencyMap.clear(); - } }]), e; - }()); const Ui = (function (e) { - i(a, e);const n = f(a);function a(e) { - let o;return t(this, a), (o = n.call(this, e))._className = 'GroupModule', o._commonGroupHandler = null, o._AVChatRoomHandler = null, o._groupSystemNoticeHandler = null, o._commonGroupHandler = new Ai(h(o)), o._groupAttributesHandler = new Li(h(o)), o._AVChatRoomHandler = new Gi(h(o)), o._groupTipsHandler = new Ei(h(o)), o._groupSystemNoticeHandler = new Pi(h(o)), o.groupMap = new Map, o._unjoinedAVChatRoomList = new Map, o.getInnerEmitterInstance().on(ci, o._onCloudConfigUpdated, h(o)), o; - } return o(a, [{ key: '_onCloudConfigUpdated', value() { - const e = this.getCloudConfig('polling_interval');this._AVChatRoomHandler && this._AVChatRoomHandler.setPollingInterval(e); - } }, { key: 'onCheckTimer', value(e) { - this.isLoggedIn() && (this._commonGroupHandler.onCheckTimer(e), this._groupTipsHandler.onCheckTimer(e)); - } }, { key: 'guardForAVChatRoom', value(e) { - const t = this;if (e.conversationType === k.CONV_GROUP) { - const n = e.to;return this.hasLocalGroup(n) ? oi() : this.getGroupProfile({ groupID: n }).then(((o) => { - const a = o.data.group.type;if (Oe.log(''.concat(t._className, '.guardForAVChatRoom. groupID:').concat(n, ' type:') - .concat(a)), a === k.GRP_AVCHATROOM) { - const s = 'userId:'.concat(e.from, ' 未加入群 groupID:').concat(n, '。发消息前先使用 joinGroup 接口申请加群,详细请参考 https://web.sdk.qcloud.com/im/doc/zh-cn/SDK.html#joinGroup');return Oe.warn(''.concat(t._className, '.guardForAVChatRoom sendMessage not allowed. ').concat(s)), ai(new ei({ code: Do.MESSAGE_SEND_FAIL, message: s, data: { message: e } })); - } return oi(); - })); - } return oi(); - } }, { key: 'checkJoinedAVChatRoomByID', value(e) { - return !!this._AVChatRoomHandler && this._AVChatRoomHandler.checkJoinedAVChatRoomByID(e); - } }, { key: 'onNewGroupMessage', value(e) { - this._commonGroupHandler && this._commonGroupHandler.onNewGroupMessage(e); - } }, { key: 'updateNextMessageSeq', value(e) { - const t = this;Fe(e) && e.forEach(((e) => { - const n = e.conversationID.replace(k.CONV_GROUP, '');t.groupMap.has(n) && (t.groupMap.get(n).nextMessageSeq = e.lastMessage.sequence + 1); - })); - } }, { key: 'onNewGroupTips', value(e) { - this._groupTipsHandler && this._groupTipsHandler.onNewGroupTips(e); - } }, { key: 'onGroupMessageRevoked', value(e) { - this._commonGroupHandler && this._commonGroupHandler.onGroupMessageRevoked(e); - } }, { key: 'onNewGroupSystemNotice', value(e) { - this._groupSystemNoticeHandler && this._groupSystemNoticeHandler.onNewGroupSystemNotice(e); - } }, { key: 'onGroupMessageReadNotice', value(e) { - const t = this;e.dataList.forEach(((e) => { - const n = e.elements.groupMessageReadNotice;if (!qe(n)) { - const o = t.getModule(xt);n.forEach(((e) => { - const n = e.groupID; const a = e.lastMessageSeq;Oe.debug(''.concat(t._className, '.onGroupMessageReadNotice groupID:').concat(n, ' lastMessageSeq:') - .concat(a));const s = ''.concat(k.CONV_GROUP).concat(n);o.updateIsReadAfterReadReport({ conversationID: s, lastMessageSeq: a }), o.updateUnreadCount(s); - })); - } - })); - } }, { key: 'deleteGroupSystemNotice', value(e) { - this._groupSystemNoticeHandler && this._groupSystemNoticeHandler.deleteGroupSystemNotice(e); - } }, { key: 'initGroupMap', value(e) { - this.groupMap.set(e.groupID, new Ii(e)); - } }, { key: 'deleteGroup', value(e) { - this.groupMap.delete(e); - } }, { key: 'updateGroupMap', value(e) { - const t = this;e.forEach(((e) => { - t.groupMap.has(e.groupID) ? t.groupMap.get(e.groupID).updateGroup(e) : t.groupMap.set(e.groupID, new Ii(e)); - }));let n; const o = this.getMyUserID(); const a = S(this.groupMap);try { - for (a.s();!(n = a.n()).done;) { - m(n.value, 2)[1].selfInfo.userID = o; - } - } catch (s) { - a.e(s); - } finally { - a.f(); - } this._setStorageGroupList(); - } }, { key: 'getStorageGroupList', value() { - return this.getModule(Ht).getItem('groupMap'); - } }, { key: '_setStorageGroupList', value() { - const e = this.getLocalGroupList().filter(((e) => { - const t = e.type;return !it(t); - })) - .slice(0, 20) - .map((e => ({ groupID: e.groupID, name: e.name, avatar: e.avatar, type: e.type })));this.getModule(Ht).setItem('groupMap', e); - } }, { key: 'getGroupMap', value() { - return this.groupMap; - } }, { key: 'getLocalGroupList', value() { - return M(this.groupMap.values()); - } }, { key: 'getLocalGroupProfile', value(e) { - return this.groupMap.get(e); - } }, { key: 'sortLocalGroupList', value() { - const e = M(this.groupMap).filter(((e) => { - const t = m(e, 2);t[0];return !It(t[1].lastMessage); - }));e.sort(((e, t) => t[1].lastMessage.lastTime - e[1].lastMessage.lastTime)), this.groupMap = new Map(M(e)); - } }, { key: 'updateGroupLastMessage', value(e) { - this._commonGroupHandler && this._commonGroupHandler.handleUpdateGroupLastMessage(e); - } }, { key: 'emitGroupListUpdate', value() { - const e = !(arguments.length > 0 && void 0 !== arguments[0]) || arguments[0]; const t = !(arguments.length > 1 && void 0 !== arguments[1]) || arguments[1]; const n = this.getLocalGroupList();if (e && this.emitOuterEvent(D.GROUP_LIST_UPDATED, n), t) { - const o = JSON.parse(JSON.stringify(n)); const a = this.getModule(xt);a.updateConversationGroupProfile(o); - } - } }, { key: 'patchGroupMessageRemindType', value() { - const e = this.getLocalGroupList(); const t = this.getModule(xt); let n = 0;e.forEach(((e) => { - !0 === t.patchMessageRemindType({ ID: e.groupID, isC2CConversation: !1, messageRemindType: e.selfInfo.messageRemindType }) && (n += 1); - })), Oe.log(''.concat(this._className, '.patchGroupMessageRemindType count:').concat(n)); - } }, { key: 'recomputeUnreadCount', value() { - const e = this.getLocalGroupList(); const t = this.getModule(xt);e.forEach(((e) => { - const n = e.groupID; const o = e.selfInfo; const a = o.excludedUnreadSequenceList; const s = o.readedSequence;if (Fe(a)) { - let r = 0;a.forEach(((t) => { - t >= s && t <= e.nextMessageSeq - 1 && (r += 1); - })), r >= 1 && t.recomputeGroupUnreadCount({ conversationID: ''.concat(k.CONV_GROUP).concat(n), count: r }); - } - })); - } }, { key: 'getMyNameCardByGroupID', value(e) { - const t = this.getLocalGroupProfile(e);return t ? t.selfInfo.nameCard : ''; - } }, { key: 'getGroupList', value(e) { - return this._commonGroupHandler ? this._commonGroupHandler.getGroupList(e) : oi(); - } }, { key: 'getGroupProfile', value(e) { - const t = this; const n = new Xa(Hs); const o = ''.concat(this._className, '.getGroupProfile'); const a = e.groupID; const s = e.groupCustomFieldFilter;Oe.log(''.concat(o, ' groupID:').concat(a));const r = { groupIDList: [a], responseFilter: { groupBaseInfoFilter: ['Type', 'Name', 'Introduction', 'Notification', 'FaceUrl', 'Owner_Account', 'CreateTime', 'InfoSeq', 'LastInfoTime', 'LastMsgTime', 'MemberNum', 'MaxMemberNum', 'ApplyJoinOption', 'NextMsgSeq', 'ShutUpAllMember'], groupCustomFieldFilter: s, memberInfoFilter: ['Role', 'JoinTime', 'MsgSeq', 'MsgFlag', 'NameCard'] } };return this.getGroupProfileAdvance(r).then(((e) => { - let s; const r = e.data; const i = r.successGroupList; const c = r.failureGroupList;return Oe.log(''.concat(o, ' ok')), c.length > 0 ? ai(c[0]) : (it(i[0].type) && !t.hasLocalGroup(a) ? s = new Ii(i[0]) : (t.updateGroupMap(i), s = t.getLocalGroupProfile(a)), n.setNetworkType(t.getNetworkType()).setMessage('groupID:'.concat(a, ' type:').concat(s.type, ' muteAllMembers:') - .concat(s.muteAllMembers, ' ownerID:') - .concat(s.ownerID)) - .end(), $r({ group: s })); - })) - .catch((a => (t.probeNetwork().then(((t) => { - const o = m(t, 2); const s = o[0]; const r = o[1];n.setError(a, s, r).setMessage('groupID:'.concat(e.groupID)) - .end(); - })), Oe.error(''.concat(o, ' failed. error:'), a), ai(a)))); - } }, { key: 'getGroupProfileAdvance', value(e) { - const t = ''.concat(this._className, '.getGroupProfileAdvance');return Fe(e.groupIDList) && e.groupIDList.length > 50 && (Oe.warn(''.concat(t, ' 获取群资料的数量不能超过50个')), e.groupIDList.length = 50), Oe.log(''.concat(t, ' groupIDList:').concat(e.groupIDList)), this.request({ protocolName: Gn, requestData: e }).then(((e) => { - Oe.log(''.concat(t, ' ok'));const n = e.data.groups; const o = n.filter((e => qe(e.errorCode) || 0 === e.errorCode)); const a = n.filter((e => e.errorCode && 0 !== e.errorCode)).map((e => new ei({ code: e.errorCode, message: e.errorInfo, data: { groupID: e.groupID } })));return $r({ successGroupList: o, failureGroupList: a }); - })) - .catch((e => (Oe.error(''.concat(t, ' failed. error:'), e), ai(e)))); - } }, { key: 'createGroup', value(e) { - const t = this; const n = ''.concat(this._className, '.createGroup');if (!['Public', 'Private', 'ChatRoom', 'AVChatRoom'].includes(e.type)) { - const o = new ei({ code: Do.ILLEGAL_GROUP_TYPE, message: ca });return ai(o); - }it(e.type) && !qe(e.memberList) && e.memberList.length > 0 && (Oe.warn(''.concat(n, ' 创建 AVChatRoom 时不能添加群成员,自动忽略该字段')), e.memberList = void 0), rt(e.type) || qe(e.joinOption) || (Oe.warn(''.concat(n, ' 创建 Work/Meeting/AVChatRoom 群时不能设置字段 joinOption,自动忽略该字段')), e.joinOption = void 0);const a = new Xa(Gs);Oe.log(''.concat(n, ' options:'), e);let s = [];return this.request({ protocolName: wn, requestData: r(r({}, e), {}, { ownerID: this.getMyUserID(), webPushFlag: 1 }) }).then(((o) => { - const i = o.data; const c = i.groupID; const u = i.overLimitUserIDList; const l = void 0 === u ? [] : u;if (s = l, a.setNetworkType(t.getNetworkType()).setMessage('groupType:'.concat(e.type, ' groupID:').concat(c, ' overLimitUserIDList=') - .concat(l)) - .end(), Oe.log(''.concat(n, ' ok groupID:').concat(c, ' overLimitUserIDList:'), l), e.type === k.GRP_AVCHATROOM) return t.getGroupProfile({ groupID: c });It(e.memberList) || It(l) || (e.memberList = e.memberList.filter((e => -1 === l.indexOf(e.userID)))), t.updateGroupMap([r(r({}, e), {}, { groupID: c })]);const d = t.getModule(Pt); const p = d.createCustomMessage({ to: c, conversationType: k.CONV_GROUP, payload: { data: 'group_create', extension: ''.concat(t.getMyUserID(), '创建群组') } });return d.sendMessageInstance(p), t.emitGroupListUpdate(), t.getGroupProfile({ groupID: c }); - })) - .then(((e) => { - const t = e.data.group; const n = t.selfInfo; const o = n.nameCard; const a = n.joinTime;return t.updateSelfInfo({ nameCard: o, joinTime: a, messageRemindType: k.MSG_REMIND_ACPT_AND_NOTE, role: k.GRP_MBR_ROLE_OWNER }), $r({ group: t, overLimitUserIDList: s }); - })) - .catch((o => (a.setMessage('groupType:'.concat(e.type)), t.probeNetwork().then(((e) => { - const t = m(e, 2); const n = t[0]; const s = t[1];a.setError(o, n, s).end(); - })), Oe.error(''.concat(n, ' failed. error:'), o), ai(o)))); - } }, { key: 'dismissGroup', value(e) { - const t = this; const n = ''.concat(this._className, '.dismissGroup');if (this.hasLocalGroup(e) && this.getLocalGroupProfile(e).type === k.GRP_WORK) return ai(new ei({ code: Do.CANNOT_DISMISS_WORK, message: pa }));const o = new Xa(Ks);return o.setMessage('groupID:'.concat(e)), Oe.log(''.concat(n, ' groupID:').concat(e)), this.request({ protocolName: bn, requestData: { groupID: e } }).then((() => (o.setNetworkType(t.getNetworkType()).end(), Oe.log(''.concat(n, ' ok')), t.deleteLocalGroupAndConversation(e), t.checkJoinedAVChatRoomByID(e) && t._AVChatRoomHandler.reset(e), $r({ groupID: e })))) - .catch((e => (t.probeNetwork().then(((t) => { - const n = m(t, 2); const a = n[0]; const s = n[1];o.setError(e, a, s).end(); - })), Oe.error(''.concat(n, ' failed. error:'), e), ai(e)))); - } }, { key: 'updateGroupProfile', value(e) { - const t = this; const n = ''.concat(this._className, '.updateGroupProfile');!this.hasLocalGroup(e.groupID) || rt(this.getLocalGroupProfile(e.groupID).type) || qe(e.joinOption) || (Oe.warn(''.concat(n, ' Work/Meeting/AVChatRoom 群不能设置字段 joinOption,自动忽略该字段')), e.joinOption = void 0), qe(e.muteAllMembers) || (e.muteAllMembers ? e.muteAllMembers = 'On' : e.muteAllMembers = 'Off');const o = new Xa(xs);return o.setMessage(JSON.stringify(e)), Oe.log(''.concat(n, ' groupID:').concat(e.groupID)), this.request({ protocolName: Pn, requestData: e }).then((() => { - (o.setNetworkType(t.getNetworkType()).end(), Oe.log(''.concat(n, ' ok')), t.hasLocalGroup(e.groupID)) && (t.groupMap.get(e.groupID).updateGroup(e), t._setStorageGroupList());return $r({ group: t.groupMap.get(e.groupID) }); - })) - .catch((e => (t.probeNetwork().then(((t) => { - const n = m(t, 2); const a = n[0]; const s = n[1];o.setError(e, a, s).end(); - })), Oe.log(''.concat(n, ' failed. error:'), e), ai(e)))); - } }, { key: 'joinGroup', value(e) { - const t = this; const n = e.groupID; const o = e.type; const a = ''.concat(this._className, '.joinGroup');if (o === k.GRP_WORK) { - const s = new ei({ code: Do.CANNOT_JOIN_WORK, message: ua });return ai(s); - } if (this.deleteUnjoinedAVChatRoom(n), this.hasLocalGroup(n)) { - if (!this.isLoggedIn()) return oi({ status: k.JOIN_STATUS_ALREADY_IN_GROUP });const r = new Xa(ws);return this.getGroupProfile({ groupID: n }).then((() => (r.setNetworkType(t.getNetworkType()).setMessage('groupID:'.concat(n, ' joinedStatus:').concat(k.JOIN_STATUS_ALREADY_IN_GROUP)) - .end(), oi({ status: k.JOIN_STATUS_ALREADY_IN_GROUP })))) - .catch((o => (r.setNetworkType(t.getNetworkType()).setMessage('groupID:'.concat(n, ' unjoined')) - .end(), Oe.warn(''.concat(a, ' ').concat(n, ' was unjoined, now join!')), t.groupMap.delete(n), t.applyJoinGroup(e)))); - } return Oe.log(''.concat(a, ' groupID:').concat(n)), this.isLoggedIn() ? this.applyJoinGroup(e) : this._AVChatRoomHandler.joinWithoutAuth(e); - } }, { key: 'applyJoinGroup', value(e) { - const t = this; const n = ''.concat(this._className, '.applyJoinGroup'); const o = e.groupID; const a = new Xa(ws); const s = r({}, e); const i = this.canIUse(B.AVCHATROOM_HISTORY_MSG);return i && (s.historyMessageFlag = 1), this.request({ protocolName: Un, requestData: s }).then(((e) => { - const s = e.data; const r = s.joinedStatus; const c = s.longPollingKey; const u = s.avChatRoomFlag; const l = s.avChatRoomKey; const d = s.messageList; const p = 'groupID:'.concat(o, ' joinedStatus:').concat(r, ' longPollingKey:') - .concat(c) + ' avChatRoomFlag:'.concat(u, ' canGetAVChatRoomHistoryMessage:').concat(i);switch (a.setNetworkType(t.getNetworkType()).setMessage(''.concat(p)) - .end(), Oe.log(''.concat(n, ' ok. ').concat(p)), r) { - case Or:return $r({ status: Or });case Rr:return t.getGroupProfile({ groupID: o }).then(((e) => { - let n; const a = e.data.group; const s = { status: Rr, group: a };return 1 === u ? (t.getModule(xt).setCompleted(''.concat(k.CONV_GROUP).concat(o)), t._groupAttributesHandler.initGroupAttributesCache({ groupID: o, avChatRoomKey: l }), (n = qe(c) ? t._AVChatRoomHandler.handleJoinResult({ group: a }) : t._AVChatRoomHandler.startRunLoop({ longPollingKey: c, group: a })).then((() => { - t._onAVChatRoomHistoryMessage(d); - })), n) : (t.emitGroupListUpdate(!0, !1), $r(s)); - }));default:var g = new ei({ code: Do.JOIN_GROUP_FAIL, message: ha });return Oe.error(''.concat(n, ' error:'), g), ai(g); - } - })) - .catch((o => (a.setMessage('groupID:'.concat(e.groupID)), t.probeNetwork().then(((e) => { - const t = m(e, 2); const n = t[0]; const s = t[1];a.setError(o, n, s).end(); - })), Oe.error(''.concat(n, ' error:'), o), ai(o)))); - } }, { key: 'quitGroup', value(e) { - const t = this; const n = ''.concat(this._className, '.quitGroup');Oe.log(''.concat(n, ' groupID:').concat(e));const o = this.checkJoinedAVChatRoomByID(e);if (!o && !this.hasLocalGroup(e)) { - const a = new ei({ code: Do.MEMBER_NOT_IN_GROUP, message: ga });return ai(a); - } if (o && !this.isLoggedIn()) return Oe.log(''.concat(n, ' anonymously ok. groupID:').concat(e)), this.deleteLocalGroupAndConversation(e), this._AVChatRoomHandler.reset(e), oi({ groupID: e });const s = new Xa(bs);return s.setMessage('groupID:'.concat(e)), this.request({ protocolName: qn, requestData: { groupID: e } }).then((() => (s.setNetworkType(t.getNetworkType()).end(), Oe.log(''.concat(n, ' ok')), o && t._AVChatRoomHandler.reset(e), t.deleteLocalGroupAndConversation(e), $r({ groupID: e })))) - .catch((e => (t.probeNetwork().then(((t) => { - const n = m(t, 2); const o = n[0]; const a = n[1];s.setError(e, o, a).end(); - })), Oe.error(''.concat(n, ' failed. error:'), e), ai(e)))); - } }, { key: 'searchGroupByID', value(e) { - const t = this; const n = ''.concat(this._className, '.searchGroupByID'); const o = { groupIDList: [e] }; const a = new Xa(Ps);return a.setMessage('groupID:'.concat(e)), Oe.log(''.concat(n, ' groupID:').concat(e)), this.request({ protocolName: Vn, requestData: o }).then(((e) => { - const o = e.data.groupProfile;if (0 !== o[0].errorCode) throw new ei({ code: o[0].errorCode, message: o[0].errorInfo });return a.setNetworkType(t.getNetworkType()).end(), Oe.log(''.concat(n, ' ok')), $r({ group: new Ii(o[0]) }); - })) - .catch((e => (t.probeNetwork().then(((t) => { - const n = m(t, 2); const o = n[0]; const s = n[1];a.setError(e, o, s).end(); - })), Oe.warn(''.concat(n, ' failed. error:'), e), ai(e)))); - } }, { key: 'changeGroupOwner', value(e) { - const t = this; const n = ''.concat(this._className, '.changeGroupOwner');if (this.hasLocalGroup(e.groupID) && this.getLocalGroupProfile(e.groupID).type === k.GRP_AVCHATROOM) return ai(new ei({ code: Do.CANNOT_CHANGE_OWNER_IN_AVCHATROOM, message: la }));if (e.newOwnerID === this.getMyUserID()) return ai(new ei({ code: Do.CANNOT_CHANGE_OWNER_TO_SELF, message: da }));const o = new Xa(Us);return o.setMessage('groupID:'.concat(e.groupID, ' newOwnerID:').concat(e.newOwnerID)), Oe.log(''.concat(n, ' groupID:').concat(e.groupID)), this.request({ protocolName: Kn, requestData: e }).then((() => { - o.setNetworkType(t.getNetworkType()).end(), Oe.log(''.concat(n, ' ok'));const a = e.groupID; const s = e.newOwnerID;t.groupMap.get(a).ownerID = s;const r = t.getModule(Kt).getLocalGroupMemberList(a);if (r instanceof Map) { - const i = r.get(t.getMyUserID());qe(i) || (i.updateRole('Member'), t.groupMap.get(a).selfInfo.role = 'Member');const c = r.get(s);qe(c) || c.updateRole('Owner'); - } return t.emitGroupListUpdate(!0, !1), $r({ group: t.groupMap.get(a) }); - })) - .catch((e => (t.probeNetwork().then(((t) => { - const n = m(t, 2); const a = n[0]; const s = n[1];o.setError(e, a, s).end(); - })), Oe.error(''.concat(n, ' failed. error:'), e), ai(e)))); - } }, { key: 'handleGroupApplication', value(e) { - const t = this; const n = ''.concat(this._className, '.handleGroupApplication'); const o = e.message.payload; const a = o.groupProfile.groupID; const s = o.authentication; const i = o.messageKey; const c = o.operatorID; const u = new Xa(Fs);return u.setMessage('groupID:'.concat(a)), Oe.log(''.concat(n, ' groupID:').concat(a)), this.request({ protocolName: xn, requestData: r(r({}, e), {}, { applicant: c, groupID: a, authentication: s, messageKey: i }) }).then((() => (u.setNetworkType(t.getNetworkType()).end(), Oe.log(''.concat(n, ' ok')), t._groupSystemNoticeHandler.deleteGroupSystemNotice({ messageList: [e.message] }), $r({ group: t.getLocalGroupProfile(a) })))) - .catch((e => (t.probeNetwork().then(((t) => { - const n = m(t, 2); const o = n[0]; const a = n[1];u.setError(e, o, a).end(); - })), Oe.error(''.concat(n, ' failed. error'), e), ai(e)))); - } }, { key: 'handleGroupInvitation', value(e) { - const t = this; const n = ''.concat(this._className, '.handleGroupInvitation'); const o = e.message.payload; const a = o.groupProfile.groupID; const s = o.authentication; const i = o.messageKey; const c = o.operatorID; const u = e.handleAction; const l = new Xa(qs);return l.setMessage('groupID:'.concat(a, ' inviter:').concat(c, ' handleAction:') - .concat(u)), Oe.log(''.concat(n, ' groupID:').concat(a, ' inviter:') - .concat(c, ' handleAction:') - .concat(u)), this.request({ protocolName: Bn, requestData: r(r({}, e), {}, { inviter: c, groupID: a, authentication: s, messageKey: i }) }).then((() => (l.setNetworkType(t.getNetworkType()).end(), Oe.log(''.concat(n, ' ok')), t._groupSystemNoticeHandler.deleteGroupSystemNotice({ messageList: [e.message] }), $r({ group: t.getLocalGroupProfile(a) })))) - .catch((e => (t.probeNetwork().then(((t) => { - const n = m(t, 2); const o = n[0]; const a = n[1];l.setError(e, o, a).end(); - })), Oe.error(''.concat(n, ' failed. error'), e), ai(e)))); - } }, { key: 'getGroupOnlineMemberCount', value(e) { - return this._AVChatRoomHandler ? this._AVChatRoomHandler.checkJoinedAVChatRoomByID(e) ? this._AVChatRoomHandler.getGroupOnlineMemberCount(e) : oi({ memberCount: 0 }) : ai({ code: Do.CANNOT_FIND_MODULE, message: Ga }); - } }, { key: 'hasLocalGroup', value(e) { - return this.groupMap.has(e); - } }, { key: 'deleteLocalGroupAndConversation', value(e) { - this._deleteLocalGroup(e), this.getModule(xt).deleteLocalConversation('GROUP'.concat(e)), this.emitGroupListUpdate(!0, !1); - } }, { key: '_deleteLocalGroup', value(e) { - this.groupMap.delete(e), this.getModule(Kt).deleteGroupMemberList(e), this._setStorageGroupList(); - } }, { key: 'sendMessage', value(e, t) { - const n = this.createGroupMessagePack(e, t);return this.request(n); - } }, { key: 'createGroupMessagePack', value(e, t) { - let n = null;t && t.offlinePushInfo && (n = t.offlinePushInfo);let o = '';be(e.cloudCustomData) && e.cloudCustomData.length > 0 && (o = e.cloudCustomData);const a = [];if (Ue(t) && Ue(t.messageControlInfo)) { - const s = t.messageControlInfo; const r = s.excludedFromUnreadCount; const i = s.excludedFromLastMessage;!0 === r && a.push('NoUnread'), !0 === i && a.push('NoLastMsg'); - } const c = e.getGroupAtInfoList();return { protocolName: hn, tjgID: this.generateTjgID(e), requestData: { fromAccount: this.getMyUserID(), groupID: e.to, msgBody: e.getElements(), cloudCustomData: o, random: e.random, priority: e.priority, clientSequence: e.clientSequence, groupAtInfo: e.type !== k.MSG_TEXT || It(c) ? void 0 : c, onlineOnlyFlag: this.isOnlineMessage(e, t) ? 1 : 0, offlinePushInfo: n ? { pushFlag: !0 === n.disablePush ? 1 : 0, title: n.title || '', desc: n.description || '', ext: n.extension || '', apnsInfo: { badgeMode: !0 === n.ignoreIOSBadge ? 1 : 0 }, androidInfo: { OPPOChannelID: n.androidOPPOChannelID || '' } } : void 0, messageControlInfo: a } }; - } }, { key: 'revokeMessage', value(e) { - return this.request({ protocolName: Hn, requestData: { to: e.to, msgSeqList: [{ msgSeq: e.sequence }] } }); - } }, { key: 'deleteMessage', value(e) { - const t = e.to; const n = e.keyList;return Oe.log(''.concat(this._className, '.deleteMessage groupID:').concat(t, ' count:') - .concat(n.length)), this.request({ protocolName: Zn, requestData: { groupID: t, deleter: this.getMyUserID(), keyList: n } }); - } }, { key: 'getRoamingMessage', value(e) { - const t = this; const n = ''.concat(this._className, '.getRoamingMessage'); const o = new Xa(_s); let a = 0;return this._computeLastSequence(e).then((n => (a = n, Oe.log(''.concat(t._className, '.getRoamingMessage groupID:').concat(e.groupID, ' lastSequence:') - .concat(a)), t.request({ protocolName: Yn, requestData: { groupID: e.groupID, count: 21, sequence: a } })))) - .then(((s) => { - const r = s.data; const i = r.messageList; const c = r.complete;qe(i) ? Oe.log(''.concat(n, ' ok. complete:').concat(c, ' but messageList is undefined!')) : Oe.log(''.concat(n, ' ok. complete:').concat(c, ' count:') - .concat(i.length)), o.setNetworkType(t.getNetworkType()).setMessage('groupID:'.concat(e.groupID, ' lastSequence:').concat(a, ' complete:') - .concat(c, ' count:') - .concat(i ? i.length : 'undefined')) - .end();const u = 'GROUP'.concat(e.groupID); const l = t.getModule(xt);if (2 === c || It(i)) return l.setCompleted(u), [];const d = l.storeRoamingMessage(i, u);return l.updateIsRead(u), l.patchConversationLastMessage(u), d; - })) - .catch((s => (t.probeNetwork().then(((t) => { - const n = m(t, 2); const r = n[0]; const i = n[1];o.setError(s, r, i).setMessage('groupID:'.concat(e.groupID, ' lastSequence:').concat(a)) - .end(); - })), Oe.warn(''.concat(n, ' failed. error:'), s), ai(s)))); - } }, { key: 'setMessageRead', value(e) { - const t = this; const n = e.conversationID; const o = e.lastMessageSeq; const a = ''.concat(this._className, '.setMessageRead');Oe.log(''.concat(a, ' conversationID:').concat(n, ' lastMessageSeq:') - .concat(o)), we(o) || Oe.warn(''.concat(a, ' 请勿修改 Conversation.lastMessage.lastSequence,否则可能会导致已读上报结果不准确'));const s = new Xa(vs);return s.setMessage(''.concat(n, '-').concat(o)), this.request({ protocolName: jn, requestData: { groupID: n.replace('GROUP', ''), messageReadSeq: o } }).then((() => { - s.setNetworkType(t.getNetworkType()).end(), Oe.log(''.concat(a, ' ok.'));const e = t.getModule(xt);return e.updateIsReadAfterReadReport({ conversationID: n, lastMessageSeq: o }), e.updateUnreadCount(n), $r(); - })) - .catch((e => (t.probeNetwork().then(((t) => { - const n = m(t, 2); const o = n[0]; const a = n[1];s.setError(e, o, a).end(); - })), Oe.log(''.concat(a, ' failed. error:'), e), ai(e)))); - } }, { key: '_computeLastSequence', value(e) { - return e.sequence > 0 ? Promise.resolve(e.sequence) : this.getGroupLastSequence(e.groupID); - } }, { key: 'getGroupLastSequence', value(e) { - const t = this; const n = ''.concat(this._className, '.getGroupLastSequence'); const o = new Xa(Ws); let a = 0; let s = '';if (this.hasLocalGroup(e)) { - const r = this.getLocalGroupProfile(e); const i = r.lastMessage;if (i.lastSequence > 0 && !1 === i.onlineOnlyFlag) return a = i.lastSequence, s = 'got lastSequence:'.concat(a, ' from local group profile[lastMessage.lastSequence]. groupID:').concat(e), Oe.log(''.concat(n, ' ').concat(s)), o.setNetworkType(this.getNetworkType()).setMessage(''.concat(s)) - .end(), Promise.resolve(a);if (r.nextMessageSeq > 1) return a = r.nextMessageSeq - 1, s = 'got lastSequence:'.concat(a, ' from local group profile[nextMessageSeq]. groupID:').concat(e), Oe.log(''.concat(n, ' ').concat(s)), o.setNetworkType(this.getNetworkType()).setMessage(''.concat(s)) - .end(), Promise.resolve(a); - } const c = 'GROUP'.concat(e); const u = this.getModule(xt).getLocalConversation(c);if (u && u.lastMessage.lastSequence && !1 === u.lastMessage.onlineOnlyFlag) return a = u.lastMessage.lastSequence, s = 'got lastSequence:'.concat(a, ' from local conversation profile[lastMessage.lastSequence]. groupID:').concat(e), Oe.log(''.concat(n, ' ').concat(s)), o.setNetworkType(this.getNetworkType()).setMessage(''.concat(s)) - .end(), Promise.resolve(a);const l = { groupIDList: [e], responseFilter: { groupBaseInfoFilter: ['NextMsgSeq'] } };return this.getGroupProfileAdvance(l).then(((r) => { - const i = r.data.successGroupList;return It(i) ? Oe.log(''.concat(n, ' successGroupList is empty. groupID:').concat(e)) : (a = i[0].nextMessageSeq - 1, s = 'got lastSequence:'.concat(a, ' from getGroupProfileAdvance. groupID:').concat(e), Oe.log(''.concat(n, ' ').concat(s))), o.setNetworkType(t.getNetworkType()).setMessage(''.concat(s)) - .end(), a; - })) - .catch((a => (t.probeNetwork().then(((t) => { - const n = m(t, 2); const s = n[0]; const r = n[1];o.setError(a, s, r).setMessage('get lastSequence failed from getGroupProfileAdvance. groupID:'.concat(e)) - .end(); - })), Oe.warn(''.concat(n, ' failed. error:'), a), ai(a)))); - } }, { key: 'isMessageFromAVChatroom', value(e) { - return !!this._AVChatRoomHandler && this._AVChatRoomHandler.checkJoinedAVChatRoomByID(e); - } }, { key: 'hasJoinedAVChatRoom', value() { - return this._AVChatRoomHandler ? this._AVChatRoomHandler.hasJoinedAVChatRoom() : 0; - } }, { key: 'getJoinedAVChatRoom', value() { - return this._AVChatRoomHandler ? this._AVChatRoomHandler.getJoinedAVChatRoom() : []; - } }, { key: 'isOnlineMessage', value(e, t) { - return !(!this._canIUseOnlineOnlyFlag(e) || !t || !0 !== t.onlineUserOnly); - } }, { key: '_canIUseOnlineOnlyFlag', value(e) { - const t = this.getJoinedAVChatRoom();return !t || !t.includes(e.to) || e.conversationType !== k.CONV_GROUP; - } }, { key: 'deleteLocalGroupMembers', value(e, t) { - this.getModule(Kt).deleteLocalGroupMembers(e, t); - } }, { key: '_onAVChatRoomHistoryMessage', value(e) { - if (!It(e)) { - Oe.log(''.concat(this._className, '._onAVChatRoomHistoryMessage count:').concat(e.length));const t = [];e.forEach(((e) => { - t.push(r(r({}, e), {}, { isHistoryMessage: 1 })); - })), this.onAVChatRoomMessage(t); - } - } }, { key: 'onAVChatRoomMessage', value(e) { - this._AVChatRoomHandler && this._AVChatRoomHandler.onMessage(e); - } }, { key: 'getGroupSimplifiedInfo', value(e) { - const t = this; const n = new Xa(zs); const o = { groupIDList: [e], responseFilter: { groupBaseInfoFilter: ['Type', 'Name'] } };return this.getGroupProfileAdvance(o).then(((o) => { - const a = o.data.successGroupList;return n.setNetworkType(t.getNetworkType()).setMessage('groupID:'.concat(e, ' type:').concat(a[0].type)) - .end(), a[0]; - })) - .catch(((o) => { - t.probeNetwork().then(((t) => { - const a = m(t, 2); const s = a[0]; const r = a[1];n.setError(o, s, r).setMessage('groupID:'.concat(e)) - .end(); - })); - })); - } }, { key: 'setUnjoinedAVChatRoom', value(e) { - this._unjoinedAVChatRoomList.set(e, 1); - } }, { key: 'deleteUnjoinedAVChatRoom', value(e) { - this._unjoinedAVChatRoomList.has(e) && this._unjoinedAVChatRoomList.delete(e); - } }, { key: 'isUnjoinedAVChatRoom', value(e) { - return this._unjoinedAVChatRoomList.has(e); - } }, { key: 'onGroupAttributesUpdated', value(e) { - this._groupAttributesHandler && this._groupAttributesHandler.onGroupAttributesUpdated(e); - } }, { key: 'updateLocalMainSequenceOnReconnected', value() { - this._groupAttributesHandler && this._groupAttributesHandler.updateLocalMainSequenceOnReconnected(); - } }, { key: 'initGroupAttributes', value(e) { - return this._groupAttributesHandler.initGroupAttributes(e); - } }, { key: 'setGroupAttributes', value(e) { - return this._groupAttributesHandler.setGroupAttributes(e); - } }, { key: 'deleteGroupAttributes', value(e) { - return this._groupAttributesHandler.deleteGroupAttributes(e); - } }, { key: 'getGroupAttributes', value(e) { - return this._groupAttributesHandler.getGroupAttributes(e); - } }, { key: 'reset', value() { - this.groupMap.clear(), this._unjoinedAVChatRoomList.clear(), this._commonGroupHandler.reset(), this._groupSystemNoticeHandler.reset(), this._groupTipsHandler.reset(), this._AVChatRoomHandler && this._AVChatRoomHandler.reset(); - } }]), a; - }(sn)); const Fi = (function () { - function e(n) { - t(this, e), this.userID = '', this.avatar = '', this.nick = '', this.role = '', this.joinTime = '', this.lastSendMsgTime = '', this.nameCard = '', this.muteUntil = 0, this.memberCustomField = [], this._initMember(n); - } return o(e, [{ key: '_initMember', value(e) { - this.updateMember(e); - } }, { key: 'updateMember', value(e) { - const t = [null, void 0, '', 0, NaN];e.memberCustomField && st(this.memberCustomField, e.memberCustomField), Ye(this, e, ['memberCustomField'], t); - } }, { key: 'updateRole', value(e) { - ['Owner', 'Admin', 'Member'].indexOf(e) < 0 || (this.role = e); - } }, { key: 'updateMuteUntil', value(e) { - qe(e) || (this.muteUntil = Math.floor((Date.now() + 1e3 * e) / 1e3)); - } }, { key: 'updateNameCard', value(e) { - qe(e) || (this.nameCard = e); - } }, { key: 'updateMemberCustomField', value(e) { - e && st(this.memberCustomField, e); - } }]), e; - }()); const qi = (function (e) { - i(a, e);const n = f(a);function a(e) { - let o;return t(this, a), (o = n.call(this, e))._className = 'GroupMemberModule', o.groupMemberListMap = new Map, o.getInnerEmitterInstance().on(ui, o._onProfileUpdated, h(o)), o; - } return o(a, [{ key: '_onProfileUpdated', value(e) { - for (var t = this, n = e.data, o = function (e) { - const o = n[e];t.groupMemberListMap.forEach(((e) => { - e.has(o.userID) && e.get(o.userID).updateMember({ nick: o.nick, avatar: o.avatar }); - })); - }, a = 0;a < n.length;a++)o(a); - } }, { key: 'deleteGroupMemberList', value(e) { - this.groupMemberListMap.delete(e); - } }, { key: 'getGroupMemberList', value(e) { - const t = this; const n = e.groupID; const o = e.offset; const a = void 0 === o ? 0 : o; const s = e.count; const r = void 0 === s ? 15 : s; const i = ''.concat(this._className, '.getGroupMemberList'); const c = new Xa(tr);Oe.log(''.concat(i, ' groupID:').concat(n, ' offset:') - .concat(a, ' count:') - .concat(r));let u = [];return this.request({ protocolName: so, requestData: { groupID: n, offset: a, limit: r > 100 ? 100 : r } }).then(((e) => { - const o = e.data; const a = o.members; const s = o.memberNum;if (!Fe(a) || 0 === a.length) return Promise.resolve([]);const r = t.getModule(qt);return r.hasLocalGroup(n) && (r.getLocalGroupProfile(n).memberNum = s), u = t._updateLocalGroupMemberMap(n, a), t.getModule(Ut).getUserProfile({ userIDList: a.map((e => e.userID)), tagList: [Er.NICK, Er.AVATAR] }); - })) - .then(((e) => { - const o = e.data;if (!Fe(o) || 0 === o.length) return oi({ memberList: [] });const s = o.map((e => ({ userID: e.userID, nick: e.nick, avatar: e.avatar })));return t._updateLocalGroupMemberMap(n, s), c.setNetworkType(t.getNetworkType()).setMessage('groupID:'.concat(n, ' offset:').concat(a, ' count:') - .concat(r)) - .end(), Oe.log(''.concat(i, ' ok.')), $r({ memberList: u }); - })) - .catch((e => (t.probeNetwork().then(((t) => { - const n = m(t, 2); const o = n[0]; const a = n[1];c.setError(e, o, a).end(); - })), Oe.error(''.concat(i, ' failed. error:'), e), ai(e)))); - } }, { key: 'getGroupMemberProfile', value(e) { - const t = this; const n = ''.concat(this._className, '.getGroupMemberProfile'); const o = new Xa(nr);o.setMessage(e.userIDList.length > 5 ? 'userIDList.length:'.concat(e.userIDList.length) : 'userIDList:'.concat(e.userIDList)), Oe.log(''.concat(n, ' groupID:').concat(e.groupID, ' userIDList:') - .concat(e.userIDList.join(','))), e.userIDList.length > 50 && (e.userIDList = e.userIDList.slice(0, 50));const a = e.groupID; const s = e.userIDList;return this._getGroupMemberProfileAdvance(r(r({}, e), {}, { userIDList: s })).then(((e) => { - const n = e.data.members;return Fe(n) && 0 !== n.length ? (t._updateLocalGroupMemberMap(a, n), t.getModule(Ut).getUserProfile({ userIDList: n.map((e => e.userID)), tagList: [Er.NICK, Er.AVATAR] })) : oi([]); - })) - .then(((e) => { - const n = e.data.map((e => ({ userID: e.userID, nick: e.nick, avatar: e.avatar })));t._updateLocalGroupMemberMap(a, n);const r = s.filter((e => t.hasLocalGroupMember(a, e))).map((e => t.getLocalGroupMemberInfo(a, e)));return o.setNetworkType(t.getNetworkType()).end(), $r({ memberList: r }); - })); - } }, { key: 'addGroupMember', value(e) { - const t = this; const n = ''.concat(this._className, '.addGroupMember'); const o = e.groupID; const a = this.getModule(qt).getLocalGroupProfile(o); const s = a.type; const r = new Xa(or);if (r.setMessage('groupID:'.concat(o, ' groupType:').concat(s)), it(s)) { - const i = new ei({ code: Do.CANNOT_ADD_MEMBER_IN_AVCHATROOM, message: _a });return r.setCode(Do.CANNOT_ADD_MEMBER_IN_AVCHATROOM).setError(_a) - .setNetworkType(this.getNetworkType()) - .end(), ai(i); - } return e.userIDList = e.userIDList.map((e => ({ userID: e }))), Oe.log(''.concat(n, ' groupID:').concat(o)), this.request({ protocolName: io, requestData: e }).then(((o) => { - const s = o.data.members;Oe.log(''.concat(n, ' ok'));const i = s.filter((e => 1 === e.result)).map((e => e.userID)); const c = s.filter((e => 0 === e.result)).map((e => e.userID)); const u = s.filter((e => 2 === e.result)).map((e => e.userID)); const l = s.filter((e => 4 === e.result)).map((e => e.userID)); const d = 'groupID:'.concat(e.groupID, ', ') + 'successUserIDList:'.concat(i, ', ') + 'failureUserIDList:'.concat(c, ', ') + 'existedUserIDList:'.concat(u, ', ') + 'overLimitUserIDList:'.concat(l);return r.setNetworkType(t.getNetworkType()).setMoreMessage(d) - .end(), 0 === i.length ? $r({ successUserIDList: i, failureUserIDList: c, existedUserIDList: u, overLimitUserIDList: l }) : (a.memberNum += i.length, $r({ successUserIDList: i, failureUserIDList: c, existedUserIDList: u, overLimitUserIDList: l, group: a })); - })) - .catch((e => (t.probeNetwork().then(((t) => { - const n = m(t, 2); const o = n[0]; const a = n[1];r.setError(e, o, a).end(); - })), Oe.error(''.concat(n, ' failed. error:'), e), ai(e)))); - } }, { key: 'deleteGroupMember', value(e) { - const t = this; const n = ''.concat(this._className, '.deleteGroupMember'); const o = e.groupID; const a = e.userIDList; const s = new Xa(ar); const r = 'groupID:'.concat(o, ' ').concat(a.length > 5 ? 'userIDList.length:'.concat(a.length) : 'userIDList:'.concat(a));s.setMessage(r), Oe.log(''.concat(n, ' groupID:').concat(o, ' userIDList:'), a);const i = this.getModule(qt).getLocalGroupProfile(o);return it(i.type) ? ai(new ei({ code: Do.CANNOT_KICK_MEMBER_IN_AVCHATROOM, message: ma })) : this.request({ protocolName: co, requestData: e }).then((() => (s.setNetworkType(t.getNetworkType()).end(), Oe.log(''.concat(n, ' ok')), i.memberNum--, t.deleteLocalGroupMembers(o, a), $r({ group: i, userIDList: a })))) - .catch((e => (t.probeNetwork().then(((t) => { - const n = m(t, 2); const o = n[0]; const a = n[1];s.setError(e, o, a).end(); - })), Oe.error(''.concat(n, ' failed. error:'), e), ai(e)))); - } }, { key: 'setGroupMemberMuteTime', value(e) { - const t = this; const n = e.groupID; const o = e.userID; const a = e.muteTime; const s = ''.concat(this._className, '.setGroupMemberMuteTime');if (o === this.getMyUserID()) return ai(new ei({ code: Do.CANNOT_MUTE_SELF, message: Ca }));Oe.log(''.concat(s, ' groupID:').concat(n, ' userID:') - .concat(o));const r = new Xa(sr);return r.setMessage('groupID:'.concat(n, ' userID:').concat(o, ' muteTime:') - .concat(a)), this.modifyGroupMemberInfo({ groupID: n, userID: o, muteTime: a }).then(((e) => { - r.setNetworkType(t.getNetworkType()).end(), Oe.log(''.concat(s, ' ok'));const o = t.getModule(qt);return $r({ group: o.getLocalGroupProfile(n), member: e }); - })) - .catch((e => (t.probeNetwork().then(((t) => { - const n = m(t, 2); const o = n[0]; const a = n[1];r.setError(e, o, a).end(); - })), Oe.error(''.concat(s, ' failed. error:'), e), ai(e)))); - } }, { key: 'setGroupMemberRole', value(e) { - const t = this; const n = ''.concat(this._className, '.setGroupMemberRole'); const o = e.groupID; const a = e.userID; const s = e.role; const r = this.getModule(qt).getLocalGroupProfile(o);if (r.selfInfo.role !== k.GRP_MBR_ROLE_OWNER) return ai(new ei({ code: Do.NOT_OWNER, message: Ma }));if ([k.GRP_WORK, k.GRP_AVCHATROOM].includes(r.type)) return ai(new ei({ code: Do.CANNOT_SET_MEMBER_ROLE_IN_WORK_AND_AVCHATROOM, message: va }));if ([k.GRP_MBR_ROLE_ADMIN, k.GRP_MBR_ROLE_MEMBER].indexOf(s) < 0) return ai(new ei({ code: Do.INVALID_MEMBER_ROLE, message: ya }));if (a === this.getMyUserID()) return ai(new ei({ code: Do.CANNOT_SET_SELF_MEMBER_ROLE, message: Ia }));const i = new Xa(ir);return i.setMessage('groupID:'.concat(o, ' userID:').concat(a, ' role:') - .concat(s)), Oe.log(''.concat(n, ' groupID:').concat(o, ' userID:') - .concat(a)), this.modifyGroupMemberInfo({ groupID: o, userID: a, role: s }).then((e => (i.setNetworkType(t.getNetworkType()).end(), Oe.log(''.concat(n, ' ok')), $r({ group: r, member: e })))) - .catch((e => (t.probeNetwork().then(((t) => { - const n = m(t, 2); const o = n[0]; const a = n[1];i.setError(e, o, a).end(); - })), Oe.error(''.concat(n, ' failed. error:'), e), ai(e)))); - } }, { key: 'setGroupMemberNameCard', value(e) { - const t = this; const n = ''.concat(this._className, '.setGroupMemberNameCard'); const o = e.groupID; const a = e.userID; const s = void 0 === a ? this.getMyUserID() : a; const r = e.nameCard;Oe.log(''.concat(n, ' groupID:').concat(o, ' userID:') - .concat(s));const i = new Xa(rr);return i.setMessage('groupID:'.concat(o, ' userID:').concat(s, ' nameCard:') - .concat(r)), this.modifyGroupMemberInfo({ groupID: o, userID: s, nameCard: r }).then(((e) => { - Oe.log(''.concat(n, ' ok')), i.setNetworkType(t.getNetworkType()).end();const a = t.getModule(qt).getLocalGroupProfile(o);return s === t.getMyUserID() && a && a.setSelfNameCard(r), $r({ group: a, member: e }); - })) - .catch((e => (t.probeNetwork().then(((t) => { - const n = m(t, 2); const o = n[0]; const a = n[1];i.setError(e, o, a).end(); - })), Oe.error(''.concat(n, ' failed. error:'), e), ai(e)))); - } }, { key: 'setGroupMemberCustomField', value(e) { - const t = this; const n = ''.concat(this._className, '.setGroupMemberCustomField'); const o = e.groupID; const a = e.userID; const s = void 0 === a ? this.getMyUserID() : a; const r = e.memberCustomField;Oe.log(''.concat(n, ' groupID:').concat(o, ' userID:') - .concat(s));const i = new Xa(cr);return i.setMessage('groupID:'.concat(o, ' userID:').concat(s, ' memberCustomField:') - .concat(JSON.stringify(r))), this.modifyGroupMemberInfo({ groupID: o, userID: s, memberCustomField: r }).then(((e) => { - i.setNetworkType(t.getNetworkType()).end(), Oe.log(''.concat(n, ' ok'));const a = t.getModule(qt).getLocalGroupProfile(o);return $r({ group: a, member: e }); - })) - .catch((e => (t.probeNetwork().then(((t) => { - const n = m(t, 2); const o = n[0]; const a = n[1];i.setError(e, o, a).end(); - })), Oe.error(''.concat(n, ' failed. error:'), e), ai(e)))); - } }, { key: 'modifyGroupMemberInfo', value(e) { - const t = this; const n = e.groupID; const o = e.userID;return this.request({ protocolName: uo, requestData: e }).then((() => { - if (t.hasLocalGroupMember(n, o)) { - const a = t.getLocalGroupMemberInfo(n, o);return qe(e.muteTime) || a.updateMuteUntil(e.muteTime), qe(e.role) || a.updateRole(e.role), qe(e.nameCard) || a.updateNameCard(e.nameCard), qe(e.memberCustomField) || a.updateMemberCustomField(e.memberCustomField), a; - } return t.getGroupMemberProfile({ groupID: n, userIDList: [o] }).then((e => m(e.data.memberList, 1)[0])); - })); - } }, { key: '_getGroupMemberProfileAdvance', value(e) { - return this.request({ protocolName: ro, requestData: r(r({}, e), {}, { memberInfoFilter: e.memberInfoFilter ? e.memberInfoFilter : ['Role', 'JoinTime', 'NameCard', 'ShutUpUntil'] }) }); - } }, { key: '_updateLocalGroupMemberMap', value(e, t) { - const n = this;return Fe(t) && 0 !== t.length ? t.map((t => (n.hasLocalGroupMember(e, t.userID) ? n.getLocalGroupMemberInfo(e, t.userID).updateMember(t) : n.setLocalGroupMember(e, new Fi(t)), n.getLocalGroupMemberInfo(e, t.userID)))) : []; - } }, { key: 'deleteLocalGroupMembers', value(e, t) { - const n = this.groupMemberListMap.get(e);n && t.forEach(((e) => { - n.delete(e); - })); - } }, { key: 'getLocalGroupMemberInfo', value(e, t) { - return this.groupMemberListMap.has(e) ? this.groupMemberListMap.get(e).get(t) : null; - } }, { key: 'setLocalGroupMember', value(e, t) { - if (this.groupMemberListMap.has(e)) this.groupMemberListMap.get(e).set(t.userID, t);else { - const n = (new Map).set(t.userID, t);this.groupMemberListMap.set(e, n); - } - } }, { key: 'getLocalGroupMemberList', value(e) { - return this.groupMemberListMap.get(e); - } }, { key: 'hasLocalGroupMember', value(e, t) { - return this.groupMemberListMap.has(e) && this.groupMemberListMap.get(e).has(t); - } }, { key: 'hasLocalGroupMemberMap', value(e) { - return this.groupMemberListMap.has(e); - } }, { key: 'reset', value() { - this.groupMemberListMap.clear(); - } }]), a; - }(sn)); const Vi = (function () { - function e(n) { - t(this, e), this._userModule = n, this._className = 'ProfileHandler', this.TAG = 'profile', this.accountProfileMap = new Map, this.expirationTime = 864e5; - } return o(e, [{ key: 'setExpirationTime', value(e) { - this.expirationTime = e; - } }, { key: 'getUserProfile', value(e) { - const t = this; const n = e.userIDList;e.fromAccount = this._userModule.getMyAccount(), n.length > 100 && (Oe.warn(''.concat(this._className, '.getUserProfile 获取用户资料人数不能超过100人')), n.length = 100);for (var o, a = [], s = [], r = 0, i = n.length;r < i;r++)o = n[r], this._userModule.isMyFriend(o) && this._containsAccount(o) ? s.push(this._getProfileFromMap(o)) : a.push(o);if (0 === a.length) return oi(s);e.toAccount = a;const c = e.bFromGetMyProfile || !1; const u = [];e.toAccount.forEach(((e) => { - u.push({ toAccount: e, standardSequence: 0, customSequence: 0 }); - })), e.userItem = u;const l = new Xa(gr);return l.setMessage(n.length > 5 ? 'userIDList.length:'.concat(n.length) : 'userIDList:'.concat(n)), this._userModule.request({ protocolName: _n, requestData: e }).then(((e) => { - l.setNetworkType(t._userModule.getNetworkType()).end(), Oe.info(''.concat(t._className, '.getUserProfile ok'));const n = t._handleResponse(e).concat(s);return $r(c ? n[0] : n); - })) - .catch((e => (t._userModule.probeNetwork().then(((t) => { - const n = m(t, 2); const o = n[0]; const a = n[1];l.setError(e, o, a).end(); - })), Oe.error(''.concat(t._className, '.getUserProfile failed. error:'), e), ai(e)))); - } }, { key: 'getMyProfile', value() { - const e = this._userModule.getMyAccount();if (Oe.log(''.concat(this._className, '.getMyProfile myAccount:').concat(e)), this._fillMap(), this._containsAccount(e)) { - const t = this._getProfileFromMap(e);return Oe.debug(''.concat(this._className, '.getMyProfile from cache, myProfile:') + JSON.stringify(t)), oi(t); - } return this.getUserProfile({ fromAccount: e, userIDList: [e], bFromGetMyProfile: !0 }); - } }, { key: '_handleResponse', value(e) { - for (var t, n, o = We.now(), a = e.data.userProfileItem, s = [], r = 0, i = a.length;r < i;r++)'@TLS#NOT_FOUND' !== a[r].to && '' !== a[r].to && (t = a[r].to, n = this._updateMap(t, this._getLatestProfileFromResponse(t, a[r].profileItem)), s.push(n));return Oe.log(''.concat(this._className, '._handleResponse cost ').concat(We.now() - o, ' ms')), s; - } }, { key: '_getLatestProfileFromResponse', value(e, t) { - const n = {};if (n.userID = e, n.profileCustomField = [], !It(t)) for (let o = 0, a = t.length;o < a;o++) if (t[o].tag.indexOf('Tag_Profile_Custom') > -1)n.profileCustomField.push({ key: t[o].tag, value: t[o].value });else switch (t[o].tag) { - case Er.NICK:n.nick = t[o].value;break;case Er.GENDER:n.gender = t[o].value;break;case Er.BIRTHDAY:n.birthday = t[o].value;break;case Er.LOCATION:n.location = t[o].value;break;case Er.SELFSIGNATURE:n.selfSignature = t[o].value;break;case Er.ALLOWTYPE:n.allowType = t[o].value;break;case Er.LANGUAGE:n.language = t[o].value;break;case Er.AVATAR:n.avatar = t[o].value;break;case Er.MESSAGESETTINGS:n.messageSettings = t[o].value;break;case Er.ADMINFORBIDTYPE:n.adminForbidType = t[o].value;break;case Er.LEVEL:n.level = t[o].value;break;case Er.ROLE:n.role = t[o].value;break;default:Oe.warn(''.concat(this._className, '._handleResponse unknown tag:'), t[o].tag, t[o].value); - } return n; - } }, { key: 'updateMyProfile', value(e) { - const t = this; const n = ''.concat(this._className, '.updateMyProfile'); const o = new Xa(hr);o.setMessage(JSON.stringify(e));const a = (new mi).validate(e);if (!a.valid) return o.setCode(Do.UPDATE_PROFILE_INVALID_PARAM).setMoreMessage(''.concat(n, ' info:').concat(a.tips)) - .setNetworkType(this._userModule.getNetworkType()) - .end(), Oe.error(''.concat(n, ' info:').concat(a.tips, ',请参考 https://web.sdk.qcloud.com/im/doc/zh-cn/SDK.html#updateMyProfile')), ai({ code: Do.UPDATE_PROFILE_INVALID_PARAM, message: Ta });const s = [];for (const r in e)Object.prototype.hasOwnProperty.call(e, r) && ('profileCustomField' === r ? e.profileCustomField.forEach(((e) => { - s.push({ tag: e.key, value: e.value }); - })) : s.push({ tag: Er[r.toUpperCase()], value: e[r] }));return 0 === s.length ? (o.setCode(Do.UPDATE_PROFILE_NO_KEY).setMoreMessage(Sa) - .setNetworkType(this._userModule.getNetworkType()) - .end(), Oe.error(''.concat(n, ' info:').concat(Sa, ',请参考 https://web.sdk.qcloud.com/im/doc/zh-cn/SDK.html#updateMyProfile')), ai({ code: Do.UPDATE_PROFILE_NO_KEY, message: Sa })) : this._userModule.request({ protocolName: fn, requestData: { fromAccount: this._userModule.getMyAccount(), profileItem: s } }).then(((a) => { - o.setNetworkType(t._userModule.getNetworkType()).end(), Oe.info(''.concat(n, ' ok'));const s = t._updateMap(t._userModule.getMyAccount(), e);return t._userModule.emitOuterEvent(D.PROFILE_UPDATED, [s]), oi(s); - })) - .catch((e => (t._userModule.probeNetwork().then(((t) => { - const n = m(t, 2); const a = n[0]; const s = n[1];o.setError(e, a, s).end(); - })), Oe.error(''.concat(n, ' failed. error:'), e), ai(e)))); - } }, { key: 'onProfileModified', value(e) { - const t = e.dataList;if (!It(t)) { - let n; let o; const a = t.length;Oe.debug(''.concat(this._className, '.onProfileModified count:').concat(a, ' dataList:'), e.dataList);for (var s = [], r = 0;r < a;r++)n = t[r].userID, o = this._updateMap(n, this._getLatestProfileFromResponse(n, t[r].profileList)), s.push(o);s.length > 0 && (this._userModule.emitInnerEvent(ui, s), this._userModule.emitOuterEvent(D.PROFILE_UPDATED, s)); - } - } }, { key: '_fillMap', value() { - if (0 === this.accountProfileMap.size) { - for (let e = this._getCachedProfiles(), t = Date.now(), n = 0, o = e.length;n < o;n++)t - e[n].lastUpdatedTime < this.expirationTime && this.accountProfileMap.set(e[n].userID, e[n]);Oe.log(''.concat(this._className, '._fillMap from cache, map.size:').concat(this.accountProfileMap.size)); - } - } }, { key: '_updateMap', value(e, t) { - let n; const o = Date.now();return this._containsAccount(e) ? (n = this._getProfileFromMap(e), t.profileCustomField && st(n.profileCustomField, t.profileCustomField), Ye(n, t, ['profileCustomField']), n.lastUpdatedTime = o) : (n = new mi(t), (this._userModule.isMyFriend(e) || e === this._userModule.getMyAccount()) && (n.lastUpdatedTime = o, this.accountProfileMap.set(e, n))), this._flushMap(e === this._userModule.getMyAccount()), n; - } }, { key: '_flushMap', value(e) { - const t = M(this.accountProfileMap.values()); const n = this._userModule.getStorageModule();Oe.debug(''.concat(this._className, '._flushMap length:').concat(t.length, ' flushAtOnce:') - .concat(e)), n.setItem(this.TAG, t, e); - } }, { key: '_containsAccount', value(e) { - return this.accountProfileMap.has(e); - } }, { key: '_getProfileFromMap', value(e) { - return this.accountProfileMap.get(e); - } }, { key: '_getCachedProfiles', value() { - const e = this._userModule.getStorageModule().getItem(this.TAG);return It(e) ? [] : e; - } }, { key: 'onConversationsProfileUpdated', value(e) { - for (var t, n, o, a = [], s = 0, r = e.length;s < r;s++)n = (t = e[s]).userID, this._userModule.isMyFriend(n) || (this._containsAccount(n) ? (o = this._getProfileFromMap(n), Ye(o, t) > 0 && a.push(n)) : a.push(t.userID));0 !== a.length && (Oe.info(''.concat(this._className, '.onConversationsProfileUpdated toAccountList:').concat(a)), this.getUserProfile({ userIDList: a })); - } }, { key: 'getNickAndAvatarByUserID', value(e) { - if (this._containsAccount(e)) { - const t = this._getProfileFromMap(e);return { nick: t.nick, avatar: t.avatar }; - } return { nick: '', avatar: '' }; - } }, { key: 'reset', value() { - this._flushMap(!0), this.accountProfileMap.clear(); - } }]), e; - }()); const Ki = function e(n) { - t(this, e), It || (this.userID = n.userID || '', this.timeStamp = n.timeStamp || 0); - }; const xi = (function () { - function e(n) { - t(this, e), this._userModule = n, this._className = 'BlacklistHandler', this._blacklistMap = new Map, this.startIndex = 0, this.maxLimited = 100, this.currentSequence = 0; - } return o(e, [{ key: 'getLocalBlacklist', value() { - return M(this._blacklistMap.keys()); - } }, { key: 'getBlacklist', value() { - const e = this; const t = ''.concat(this._className, '.getBlacklist'); const n = { fromAccount: this._userModule.getMyAccount(), maxLimited: this.maxLimited, startIndex: 0, lastSequence: this.currentSequence }; const o = new Xa(_r);return this._userModule.request({ protocolName: mn, requestData: n }).then(((n) => { - const a = n.data; const s = a.blackListItem; const r = a.currentSequence; const i = It(s) ? 0 : s.length;o.setNetworkType(e._userModule.getNetworkType()).setMessage('blackList count:'.concat(i)) - .end(), Oe.info(''.concat(t, ' ok')), e.currentSequence = r, e._handleResponse(s, !0), e._userModule.emitOuterEvent(D.BLACKLIST_UPDATED, M(e._blacklistMap.keys())); - })) - .catch((n => (e._userModule.probeNetwork().then(((e) => { - const t = m(e, 2); const a = t[0]; const s = t[1];o.setError(n, a, s).end(); - })), Oe.error(''.concat(t, ' failed. error:'), n), ai(n)))); - } }, { key: 'addBlacklist', value(e) { - const t = this; const n = ''.concat(this._className, '.addBlacklist'); const o = new Xa(fr);if (!Fe(e.userIDList)) return o.setCode(Do.ADD_BLACKLIST_INVALID_PARAM).setMessage(Da) - .setNetworkType(this._userModule.getNetworkType()) - .end(), Oe.error(''.concat(n, ' options.userIDList 必需是数组')), ai({ code: Do.ADD_BLACKLIST_INVALID_PARAM, message: Da });const a = this._userModule.getMyAccount();return 1 === e.userIDList.length && e.userIDList[0] === a ? (o.setCode(Do.CANNOT_ADD_SELF_TO_BLACKLIST).setMessage(Ea) - .setNetworkType(this._userModule.getNetworkType()) - .end(), Oe.error(''.concat(n, ' 不能把自己拉黑')), ai({ code: Do.CANNOT_ADD_SELF_TO_BLACKLIST, message: Ea })) : (e.userIDList.includes(a) && (e.userIDList = e.userIDList.filter((e => e !== a)), Oe.warn(''.concat(n, ' 不能把自己拉黑,已过滤'))), e.fromAccount = this._userModule.getMyAccount(), e.toAccount = e.userIDList, this._userModule.request({ protocolName: Mn, requestData: e }).then((a => (o.setNetworkType(t._userModule.getNetworkType()).setMessage(e.userIDList.length > 5 ? 'userIDList.length:'.concat(e.userIDList.length) : 'userIDList:'.concat(e.userIDList)) - .end(), Oe.info(''.concat(n, ' ok')), t._handleResponse(a.resultItem, !0), $r(M(t._blacklistMap.keys()))))) - .catch((e => (t._userModule.probeNetwork().then(((t) => { - const n = m(t, 2); const a = n[0]; const s = n[1];o.setError(e, a, s).end(); - })), Oe.error(''.concat(n, ' failed. error:'), e), ai(e))))); - } }, { key: '_handleResponse', value(e, t) { - if (!It(e)) for (var n, o, a, s = 0, r = e.length;s < r;s++)o = e[s].to, a = e[s].resultCode, (qe(a) || 0 === a) && (t ? ((n = this._blacklistMap.has(o) ? this._blacklistMap.get(o) : new Ki).userID = o, !It(e[s].addBlackTimeStamp) && (n.timeStamp = e[s].addBlackTimeStamp), this._blacklistMap.set(o, n)) : this._blacklistMap.has(o) && (n = this._blacklistMap.get(o), this._blacklistMap.delete(o)));Oe.log(''.concat(this._className, '._handleResponse total:').concat(this._blacklistMap.size, ' bAdd:') - .concat(t)); - } }, { key: 'deleteBlacklist', value(e) { - const t = this; const n = ''.concat(this._className, '.deleteBlacklist'); const o = new Xa(mr);return Fe(e.userIDList) ? (e.fromAccount = this._userModule.getMyAccount(), e.toAccount = e.userIDList, this._userModule.request({ protocolName: vn, requestData: e }).then((a => (o.setNetworkType(t._userModule.getNetworkType()).setMessage(e.userIDList.length > 5 ? 'userIDList.length:'.concat(e.userIDList.length) : 'userIDList:'.concat(e.userIDList)) - .end(), Oe.info(''.concat(n, ' ok')), t._handleResponse(a.data.resultItem, !1), $r(M(t._blacklistMap.keys()))))) - .catch((e => (t._userModule.probeNetwork().then(((t) => { - const n = m(t, 2); const a = n[0]; const s = n[1];o.setError(e, a, s).end(); - })), Oe.error(''.concat(n, ' failed. error:'), e), ai(e))))) : (o.setCode(Do.DEL_BLACKLIST_INVALID_PARAM).setMessage(ka) - .setNetworkType(this._userModule.getNetworkType()) - .end(), Oe.error(''.concat(n, ' options.userIDList 必需是数组')), ai({ code: Do.DEL_BLACKLIST_INVALID_PARAM, message: ka })); - } }, { key: 'onAccountDeleted', value(e) { - for (var t, n = [], o = 0, a = e.length;o < a;o++)t = e[o], this._blacklistMap.has(t) && (this._blacklistMap.delete(t), n.push(t));n.length > 0 && (Oe.log(''.concat(this._className, '.onAccountDeleted count:').concat(n.length, ' userIDList:'), n), this._userModule.emitOuterEvent(D.BLACKLIST_UPDATED, M(this._blacklistMap.keys()))); - } }, { key: 'onAccountAdded', value(e) { - for (var t, n = [], o = 0, a = e.length;o < a;o++)t = e[o], this._blacklistMap.has(t) || (this._blacklistMap.set(t, new Ki({ userID: t })), n.push(t));n.length > 0 && (Oe.log(''.concat(this._className, '.onAccountAdded count:').concat(n.length, ' userIDList:'), n), this._userModule.emitOuterEvent(D.BLACKLIST_UPDATED, M(this._blacklistMap.keys()))); - } }, { key: 'reset', value() { - this._blacklistMap.clear(), this.startIndex = 0, this.maxLimited = 100, this.currentSequence = 0; - } }]), e; - }()); const Bi = (function (e) { - i(a, e);const n = f(a);function a(e) { - let o;return t(this, a), (o = n.call(this, e))._className = 'UserModule', o._profileHandler = new Vi(h(o)), o._blacklistHandler = new xi(h(o)), o.getInnerEmitterInstance().on(ii, o.onContextUpdated, h(o)), o; - } return o(a, [{ key: 'onContextUpdated', value(e) { - this._profileHandler.getMyProfile(), this._blacklistHandler.getBlacklist(); - } }, { key: 'onProfileModified', value(e) { - this._profileHandler.onProfileModified(e); - } }, { key: 'onRelationChainModified', value(e) { - const t = e.dataList;if (!It(t)) { - const n = [];t.forEach(((e) => { - e.blackListDelAccount && n.push.apply(n, M(e.blackListDelAccount)); - })), n.length > 0 && this._blacklistHandler.onAccountDeleted(n);const o = [];t.forEach(((e) => { - e.blackListAddAccount && o.push.apply(o, M(e.blackListAddAccount)); - })), o.length > 0 && this._blacklistHandler.onAccountAdded(o); - } - } }, { key: 'onConversationsProfileUpdated', value(e) { - this._profileHandler.onConversationsProfileUpdated(e); - } }, { key: 'getMyAccount', value() { - return this.getMyUserID(); - } }, { key: 'getMyProfile', value() { - return this._profileHandler.getMyProfile(); - } }, { key: 'getStorageModule', value() { - return this.getModule(Ht); - } }, { key: 'isMyFriend', value(e) { - const t = this.getModule(Vt);return !!t && t.isMyFriend(e); - } }, { key: 'getUserProfile', value(e) { - return this._profileHandler.getUserProfile(e); - } }, { key: 'updateMyProfile', value(e) { - return this._profileHandler.updateMyProfile(e); - } }, { key: 'getNickAndAvatarByUserID', value(e) { - return this._profileHandler.getNickAndAvatarByUserID(e); - } }, { key: 'getLocalBlacklist', value() { - const e = this._blacklistHandler.getLocalBlacklist();return oi(e); - } }, { key: 'addBlacklist', value(e) { - return this._blacklistHandler.addBlacklist(e); - } }, { key: 'deleteBlacklist', value(e) { - return this._blacklistHandler.deleteBlacklist(e); - } }, { key: 'reset', value() { - Oe.log(''.concat(this._className, '.reset')), this._profileHandler.reset(), this._blacklistHandler.reset(); - } }]), a; - }(sn)); const Hi = (function () { - function e(n, o) { - t(this, e), this._moduleManager = n, this._isLoggedIn = !1, this._SDKAppID = o.SDKAppID, this._userID = o.userID || '', this._userSig = o.userSig || '', this._version = '2.16.3', this._a2Key = '', this._tinyID = '', this._contentType = 'json', this._unlimitedAVChatRoom = o.unlimitedAVChatRoom, this._scene = o.scene || '', this._oversea = o.oversea, this._instanceID = o.instanceID, this._statusInstanceID = 0, this._isDevMode = o.devMode, this._proxyServer = o.proxyServer; - } return o(e, [{ key: 'isLoggedIn', value() { - return this._isLoggedIn; - } }, { key: 'isOversea', value() { - return this._oversea; - } }, { key: 'isDevMode', value() { - return this._isDevMode; - } }, { key: 'isSingaporeSite', value() { - return this._SDKAppID >= 2e7 && this._SDKAppID < 3e7; - } }, { key: 'isKoreaSite', value() { - return this._SDKAppID >= 3e7 && this._SDKAppID < 4e7; - } }, { key: 'isGermanySite', value() { - return this._SDKAppID >= 4e7 && this._SDKAppID < 5e7; - } }, { key: 'isIndiaSite', value() { - return this._SDKAppID >= 5e7 && this._SDKAppID < 6e7; - } }, { key: 'isUnlimitedAVChatRoom', value() { - return this._unlimitedAVChatRoom; - } }, { key: 'getUserID', value() { - return this._userID; - } }, { key: 'setUserID', value(e) { - this._userID = e; - } }, { key: 'setUserSig', value(e) { - this._userSig = e; - } }, { key: 'getUserSig', value() { - return this._userSig; - } }, { key: 'getSDKAppID', value() { - return this._SDKAppID; - } }, { key: 'getTinyID', value() { - return this._tinyID; - } }, { key: 'setTinyID', value(e) { - this._tinyID = e, this._isLoggedIn = !0; - } }, { key: 'getScene', value() { - return this._isTUIKit() ? 'tuikit' : this._scene; - } }, { key: 'getInstanceID', value() { - return this._instanceID; - } }, { key: 'getStatusInstanceID', value() { - return this._statusInstanceID; - } }, { key: 'setStatusInstanceID', value(e) { - this._statusInstanceID = e; - } }, { key: 'getVersion', value() { - return this._version; - } }, { key: 'getA2Key', value() { - return this._a2Key; - } }, { key: 'setA2Key', value(e) { - this._a2Key = e; - } }, { key: 'getContentType', value() { - return this._contentType; - } }, { key: 'getProxyServer', value() { - return this._proxyServer; - } }, { key: '_isTUIKit', value() { - let e = !1; let t = !1; let n = !1; let o = !1; let a = [];ee && (a = Object.keys(ne)), te && (a = Object.keys(window));for (let s = 0, r = a.length;s < r;s++) if (a[s].toLowerCase().includes('uikit')) { - e = !0;break; - } if (a = null, ee && Ke(getApp)) { - const i = getApp().globalData;Ue(i) && !0 === i.isTUIKit && (t = !0); - }!0 === this._moduleManager.getModule(Ht).getStorageSync('TIM_'.concat(this._SDKAppID, '_isTUIKit')) && (n = !0);let c = null;if ($ && 'undefined' === typeof uni && __wxConfig && (c = __wxConfig.pages), z && 'undefined' === typeof uni && __qqConfig && (c = __qqConfig.pages), Fe(c) && c.length > 0) { - for (let u = 0, l = c.length;u < l;u++) if (c[u].toLowerCase().includes('tui')) { - o = !0;break; - }c = null; - } return e || t || n || o; - } }, { key: 'reset', value() { - this._isLoggedIn = !1, this._userSig = '', this._a2Key = '', this._tinyID = '', this._statusInstanceID = 0; - } }]), e; - }()); const ji = (function (e) { - i(a, e);const n = f(a);function a(e) { - let o;return t(this, a), (o = n.call(this, e))._className = 'SignModule', o._helloInterval = 120, o._lastLoginTs = 0, o._lastWsHelloTs = 0, li.mixin(h(o)), o; - } return o(a, [{ key: 'onCheckTimer', value(e) { - this.isLoggedIn() && e % this._helloInterval == 0 && this._hello(); - } }, { key: 'login', value(e) { - if (this.isLoggedIn()) { - const t = '您已经登录账号'.concat(e.userID, '!如需切换账号登录,请先调用 logout 接口登出,再调用 login 接口登录。');return Oe.warn(t), oi({ actionStatus: 'OK', errorCode: 0, errorInfo: t, repeatLogin: !0 }); - } if (Date.now() - this._lastLoginTs <= 15e3) return Oe.warn('您正在尝试登录账号'.concat(e.userID, '!请勿重复登录。')), ai({ code: Do.REPEAT_LOGIN, message: Oo });Oe.log(''.concat(this._className, '.login userID:').concat(e.userID));const n = this._checkLoginInfo(e);if (0 !== n.code) return ai(n);const o = this.getModule(Bt); const a = e.userID; const s = e.userSig;return o.setUserID(a), o.setUserSig(s), this.getModule(Xt).updateProtocolConfig(), this._login(); - } }, { key: '_login', value() { - const e = this; const t = this.getModule(Bt); const n = t.getScene(); const o = new Xa(es);return o.setMessage(''.concat(n)).setMoreMessage('identifier:'.concat(this.getMyUserID())), this._lastLoginTs = Date.now(), this.request({ protocolName: rn }).then(((a) => { - e._lastLoginTs = 0;const s = Date.now(); let r = null; const i = a.data; const c = i.a2Key; const u = i.tinyID; const l = i.helloInterval; const d = i.instanceID; const p = i.timeStamp;Oe.log(''.concat(e._className, '.login ok. scene:').concat(n, ' helloInterval:') - .concat(l, ' instanceID:') - .concat(d, ' timeStamp:') - .concat(p));const g = 1e3 * p; const h = s - o.getStartTs(); const _ = g + parseInt(h / 2) - s; const f = o.getStartTs() + _;if (o.start(f), (function (e, t) { - ke = t;const n = new Date;n.setTime(e), Oe.info('baseTime from server: '.concat(n, ' offset: ').concat(ke)); - }(g, _)), !u) throw r = new ei({ code: Do.NO_TINYID, message: No }), o.setError(r, !0, e.getNetworkType()).end(), r;if (!c) throw r = new ei({ code: Do.NO_A2KEY, message: Lo }), o.setError(r, !0, e.getNetworkType()).end(), r;return o.setNetworkType(e.getNetworkType()).setMoreMessage('helloInterval:'.concat(l, ' instanceID:').concat(d, ' offset:') - .concat(_)) - .end(), t.setA2Key(c), t.setTinyID(u), t.setStatusInstanceID(d), e.getModule(Xt).updateProtocolConfig(), e.emitInnerEvent(ii), e._helloInterval = l, e.triggerReady(), e._fetchCloudControlConfig(), a; - })) - .catch((t => (e.probeNetwork().then(((e) => { - const n = m(e, 2); const a = n[0]; const s = n[1];o.setError(t, a, s).end(!0); - })), Oe.error(''.concat(e._className, '.login failed. error:'), t), e._moduleManager.onLoginFailed(), ai(t)))); - } }, { key: 'logout', value() { - const e = this; const t = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : 0;if (!this.isLoggedIn()) return ai({ code: Do.USER_NOT_LOGGED_IN, message: Ro });const n = new Xa(ts);return n.setNetworkType(this.getNetworkType()).setMessage('identifier:'.concat(this.getMyUserID())) - .end(!0), Oe.info(''.concat(this._className, '.logout type:').concat(t)), this.request({ protocolName: cn, requestData: { type: t } }).then((() => (e.resetReady(), oi({})))) - .catch((t => (Oe.error(''.concat(e._className, '._logout error:'), t), e.resetReady(), oi({})))); - } }, { key: '_fetchCloudControlConfig', value() { - this.getModule(en).fetchConfig(); - } }, { key: '_hello', value() { - const e = this;this._lastWsHelloTs = Date.now(), this.request({ protocolName: un }).catch(((t) => { - Oe.warn(''.concat(e._className, '._hello error:'), t); - })); - } }, { key: 'getLastWsHelloTs', value() { - return this._lastWsHelloTs; - } }, { key: '_checkLoginInfo', value(e) { - let t = 0; let n = '';return It(this.getModule(Bt).getSDKAppID()) ? (t = Do.NO_SDKAPPID, n = ko) : It(e.userID) ? (t = Do.NO_IDENTIFIER, n = Eo) : It(e.userSig) && (t = Do.NO_USERSIG, n = Ao), { code: t, message: n }; - } }, { key: 'onMultipleAccountKickedOut', value(e) { - const t = this;new Xa(ns).setNetworkType(this.getNetworkType()) - .setMessage('type:'.concat(k.KICKED_OUT_MULT_ACCOUNT, ' newInstanceInfo:').concat(JSON.stringify(e))) - .end(!0), Oe.warn(''.concat(this._className, '.onMultipleAccountKickedOut userID:').concat(this.getMyUserID(), ' newInstanceInfo:'), e), this.logout(1).then((() => { - t.emitOuterEvent(D.KICKED_OUT, { type: k.KICKED_OUT_MULT_ACCOUNT }), t._moduleManager.reset(); - })); - } }, { key: 'onMultipleDeviceKickedOut', value(e) { - const t = this;new Xa(ns).setNetworkType(this.getNetworkType()) - .setMessage('type:'.concat(k.KICKED_OUT_MULT_DEVICE, ' newInstanceInfo:').concat(JSON.stringify(e))) - .end(!0), Oe.warn(''.concat(this._className, '.onMultipleDeviceKickedOut userID:').concat(this.getMyUserID(), ' newInstanceInfo:'), e), this.logout(1).then((() => { - t.emitOuterEvent(D.KICKED_OUT, { type: k.KICKED_OUT_MULT_DEVICE }), t._moduleManager.reset(); - })); - } }, { key: 'onUserSigExpired', value() { - new Xa(ns).setNetworkType(this.getNetworkType()) - .setMessage(k.KICKED_OUT_USERSIG_EXPIRED) - .end(!0), Oe.warn(''.concat(this._className, '.onUserSigExpired: userSig 签名过期被踢下线')), 0 !== this.getModule(Bt).getStatusInstanceID() && (this.emitOuterEvent(D.KICKED_OUT, { type: k.KICKED_OUT_USERSIG_EXPIRED }), this._moduleManager.reset()); - } }, { key: 'reset', value() { - Oe.log(''.concat(this._className, '.reset')), this.resetReady(), this._helloInterval = 120, this._lastLoginTs = 0, this._lastWsHelloTs = 0; - } }]), a; - }(sn));function Wi() { - return null; - } const Yi = (function () { - function e(n) { - t(this, e), this._moduleManager = n, this._className = 'StorageModule', this._storageQueue = new Map, this._errorTolerantHandle(); - } return o(e, [{ key: '_errorTolerantHandle', value() { - ee || !qe(window) && !qe(window.localStorage) || (this.getItem = Wi, this.setItem = Wi, this.removeItem = Wi, this.clear = Wi); - } }, { key: 'onCheckTimer', value(e) { - if (e % 20 == 0) { - if (0 === this._storageQueue.size) return;this._doFlush(); - } - } }, { key: '_doFlush', value() { - try { - let e; const t = S(this._storageQueue);try { - for (t.s();!(e = t.n()).done;) { - const n = m(e.value, 2); const o = n[0]; const a = n[1];this._setStorageSync(this._getKey(o), a); - } - } catch (s) { - t.e(s); - } finally { - t.f(); - } this._storageQueue.clear(); - } catch (r) { - Oe.warn(''.concat(this._className, '._doFlush error:'), r); - } - } }, { key: '_getPrefix', value() { - const e = this._moduleManager.getModule(Bt);return 'TIM_'.concat(e.getSDKAppID(), '_').concat(e.getUserID(), '_'); - } }, { key: '_getKey', value(e) { - return ''.concat(this._getPrefix()).concat(e); - } }, { key: 'getItem', value(e) { - const t = !(arguments.length > 1 && void 0 !== arguments[1]) || arguments[1];try { - const n = t ? this._getKey(e) : e;return this.getStorageSync(n); - } catch (o) { - return Oe.warn(''.concat(this._className, '.getItem error:'), o), {}; - } - } }, { key: 'setItem', value(e, t) { - const n = arguments.length > 2 && void 0 !== arguments[2] && arguments[2]; const o = !(arguments.length > 3 && void 0 !== arguments[3]) || arguments[3];if (n) { - const a = o ? this._getKey(e) : e;this._setStorageSync(a, t); - } else this._storageQueue.set(e, t); - } }, { key: 'clear', value() { - try { - ee ? ne.clearStorageSync() : localStorage && localStorage.clear(); - } catch (e) { - Oe.warn(''.concat(this._className, '.clear error:'), e); - } - } }, { key: 'removeItem', value(e) { - const t = !(arguments.length > 1 && void 0 !== arguments[1]) || arguments[1];try { - const n = t ? this._getKey(e) : e;this._removeStorageSync(n); - } catch (o) { - Oe.warn(''.concat(this._className, '.removeItem error:'), o); - } - } }, { key: 'getSize', value(e) { - const t = this; const n = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : 'b';try { - const o = { size: 0, limitSize: 5242880, unit: n };if (Object.defineProperty(o, 'leftSize', { enumerable: !0, get() { - return o.limitSize - o.size; - } }), ee && (o.limitSize = 1024 * ne.getStorageInfoSync().limitSize), e)o.size = JSON.stringify(this.getItem(e)).length + this._getKey(e).length;else if (ee) { - const a = ne.getStorageInfoSync(); const s = a.keys;s.forEach(((e) => { - o.size += JSON.stringify(t.getStorageSync(e)).length + t._getKey(e).length; - })); - } else if (localStorage) for (const r in localStorage)localStorage.hasOwnProperty(r) && (o.size += localStorage.getItem(r).length + r.length);return this._convertUnit(o); - } catch (i) { - Oe.warn(''.concat(this._className, ' error:'), i); - } - } }, { key: '_convertUnit', value(e) { - const t = {}; const n = e.unit;for (const o in t.unit = n, e)'number' === typeof e[o] && ('kb' === n.toLowerCase() ? t[o] = Math.round(e[o] / 1024) : 'mb' === n.toLowerCase() ? t[o] = Math.round(e[o] / 1024 / 1024) : t[o] = e[o]);return t; - } }, { key: '_setStorageSync', value(e, t) { - ee ? Q ? my.setStorageSync({ key: e, data: t }) : ne.setStorageSync(e, t) : localStorage && localStorage.setItem(e, JSON.stringify(t)); - } }, { key: 'getStorageSync', value(e) { - return ee ? Q ? my.getStorageSync({ key: e }).data : ne.getStorageSync(e) : localStorage ? JSON.parse(localStorage.getItem(e)) : {}; - } }, { key: '_removeStorageSync', value(e) { - ee ? Q ? my.removeStorageSync({ key: e }) : ne.removeStorageSync(e) : localStorage && localStorage.removeItem(e); - } }, { key: 'reset', value() { - Oe.log(''.concat(this._className, '.reset')), this._doFlush(); - } }]), e; - }()); const $i = (function () { - function e(n) { - t(this, e), this._className = 'SSOLogBody', this._report = []; - } return o(e, [{ key: 'pushIn', value(e) { - Oe.debug(''.concat(this._className, '.pushIn'), this._report.length, e), this._report.push(e); - } }, { key: 'backfill', value(e) { - let t;Fe(e) && 0 !== e.length && (Oe.debug(''.concat(this._className, '.backfill'), this._report.length, e.length), (t = this._report).unshift.apply(t, M(e))); - } }, { key: 'getLogsNumInMemory', value() { - return this._report.length; - } }, { key: 'isEmpty', value() { - return 0 === this._report.length; - } }, { key: '_reset', value() { - this._report.length = 0, this._report = []; - } }, { key: 'getLogsInMemory', value() { - const e = this._report.slice();return this._reset(), e; - } }]), e; - }()); const zi = function (e) { - const t = e.getModule(Bt);return { SDKType: 10, SDKAppID: t.getSDKAppID(), SDKVersion: t.getVersion(), tinyID: Number(t.getTinyID()), userID: t.getUserID(), platform: e.getPlatform(), instanceID: t.getInstanceID(), traceID: Ee() }; - }; const Ji = (function (e) { - i(a, e);const n = f(a);function a(e) { - let o;t(this, a), (o = n.call(this, e))._className = 'EventStatModule', o.TAG = 'im-ssolog-event', o._reportBody = new $i, o.MIN_THRESHOLD = 20, o.MAX_THRESHOLD = 100, o.WAITING_TIME = 6e4, o.REPORT_LEVEL = [4, 5, 6], o.REPORT_SDKAPPID_BLACKLIST = [], o.REPORT_TINYID_WHITELIST = [], o._lastReportTime = Date.now();const s = o.getInnerEmitterInstance();return s.on(ii, o._onLoginSuccess, h(o)), s.on(ci, o._onCloudConfigUpdated, h(o)), o; - } return o(a, [{ key: 'reportAtOnce', value() { - Oe.debug(''.concat(this._className, '.reportAtOnce')), this._report(); - } }, { key: '_onLoginSuccess', value() { - const e = this; const t = this.getModule(Ht); const n = t.getItem(this.TAG, !1);!It(n) && Ke(n.forEach) && (Oe.log(''.concat(this._className, '._onLoginSuccess get ssolog in storage, count:').concat(n.length)), n.forEach(((t) => { - e._reportBody.pushIn(t); - })), t.removeItem(this.TAG, !1)); - } }, { key: '_onCloudConfigUpdated', value() { - const e = this.getCloudConfig('evt_rpt_threshold'); const t = this.getCloudConfig('evt_rpt_waiting'); const n = this.getCloudConfig('evt_rpt_level'); const o = this.getCloudConfig('evt_rpt_sdkappid_bl'); const a = this.getCloudConfig('evt_rpt_tinyid_wl');qe(e) || (this.MIN_THRESHOLD = Number(e)), qe(t) || (this.WAITING_TIME = Number(t)), qe(n) || (this.REPORT_LEVEL = n.split(',').map((e => Number(e)))), qe(o) || (this.REPORT_SDKAPPID_BLACKLIST = o.split(',').map((e => Number(e)))), qe(a) || (this.REPORT_TINYID_WHITELIST = a.split(',')); - } }, { key: 'pushIn', value(e) { - e instanceof Xa && (e.updateTimeStamp(), this._reportBody.pushIn(e), this._reportBody.getLogsNumInMemory() >= this.MIN_THRESHOLD && this._report()); - } }, { key: 'onCheckTimer', value() { - Date.now() < this._lastReportTime + this.WAITING_TIME || this._reportBody.isEmpty() || this._report(); - } }, { key: '_filterLogs', value(e) { - const t = this; const n = this.getModule(Bt); const o = n.getSDKAppID(); const a = n.getTinyID();return Mt(this.REPORT_SDKAPPID_BLACKLIST, o) && !vt(this.REPORT_TINYID_WHITELIST, a) ? [] : e.filter((e => t.REPORT_LEVEL.includes(e.level))); - } }, { key: '_report', value() { - const e = this;if (!this._reportBody.isEmpty()) { - const t = this._reportBody.getLogsInMemory(); const n = this._filterLogs(t);if (0 !== n.length) { - const o = { header: zi(this), event: n };this.request({ protocolName: go, requestData: r({}, o) }).then((() => { - e._lastReportTime = Date.now(); - })) - .catch(((n) => { - Oe.warn(''.concat(e._className, '.report failed. networkType:').concat(e.getNetworkType(), ' error:'), n), e._reportBody.backfill(t), e._reportBody.getLogsNumInMemory() > e.MAX_THRESHOLD && e._flushAtOnce(); - })); - } else this._lastReportTime = Date.now(); - } - } }, { key: '_flushAtOnce', value() { - const e = this.getModule(Ht); const t = e.getItem(this.TAG, !1); const n = this._reportBody.getLogsInMemory();if (It(t))Oe.log(''.concat(this._className, '._flushAtOnce count:').concat(n.length)), e.setItem(this.TAG, n, !0, !1);else { - let o = n.concat(t);o.length > this.MAX_THRESHOLD && (o = o.slice(0, this.MAX_THRESHOLD)), Oe.log(''.concat(this._className, '._flushAtOnce count:').concat(o.length)), e.setItem(this.TAG, o, !0, !1); - } - } }, { key: 'reset', value() { - Oe.log(''.concat(this._className, '.reset')), this._lastReportTime = 0, this._report(), this.REPORT_SDKAPPID_BLACKLIST = [], this.REPORT_TINYID_WHITELIST = []; - } }]), a; - }(sn)); const Xi = 'none'; const Qi = 'online'; const Zi = (function () { - function e(n) { - t(this, e), this._moduleManager = n, this._networkType = '', this._className = 'NetMonitorModule', this.MAX_WAIT_TIME = 3e3, this._mpNetworkStatusCallback = null, this._webOnlineCallback = null, this._webOfflineCallback = null; - } return o(e, [{ key: 'start', value() { - const e = this;ee ? (ne.getNetworkType({ success(t) { - e._networkType = t.networkType, t.networkType === Xi ? Oe.warn(''.concat(e._className, '.start no network, please check!')) : Oe.info(''.concat(e._className, '.start networkType:').concat(t.networkType)); - } }), this._mpNetworkStatusCallback = this._onNetworkStatusChange.bind(this), ne.onNetworkStatusChange(this._mpNetworkStatusCallback)) : (this._networkType = Qi, this._webOnlineCallback = this._onWebOnline.bind(this), this._webOfflineCallback = this._onWebOffline.bind(this), window && (window.addEventListener('online', this._webOnlineCallback), window.addEventListener('offline', this._webOfflineCallback))); - } }, { key: '_onWebOnline', value() { - this._onNetworkStatusChange({ isConnected: !0, networkType: Qi }); - } }, { key: '_onWebOffline', value() { - this._onNetworkStatusChange({ isConnected: !1, networkType: Xi }); - } }, { key: '_onNetworkStatusChange', value(e) { - const t = e.isConnected; const n = e.networkType; let o = !1;t ? (Oe.info(''.concat(this._className, '._onNetworkStatusChange previousNetworkType:').concat(this._networkType, ' currentNetworkType:') - .concat(n)), this._networkType !== n && (o = !0, this._moduleManager.getModule(Qt).reConnect(!0))) : this._networkType !== n && (o = !0, Oe.warn(''.concat(this._className, '._onNetworkStatusChange no network, please check!')));o && (new Xa(us).setMessage('isConnected:'.concat(t, ' previousNetworkType:').concat(this._networkType, ' networkType:') - .concat(n)) - .end(), this._networkType = n); - } }, { key: 'probe', value() { - const e = this;return new Promise(((t, n) => { - if (ee)ne.getNetworkType({ success(n) { - e._networkType = n.networkType, n.networkType === Xi ? (Oe.warn(''.concat(e._className, '.probe no network, please check!')), t([!1, n.networkType])) : (Oe.info(''.concat(e._className, '.probe networkType:').concat(n.networkType)), t([!0, n.networkType])); - } });else if (window && window.fetch)fetch(''.concat(nt(), '//web.sdk.qcloud.com/im/assets/speed.xml?random=').concat(Math.random())).then(((e) => { - e.ok ? t([!0, Qi]) : t([!1, Xi]); - })) - .catch(((e) => { - t([!1, Xi]); - }));else { - const o = new XMLHttpRequest; const a = setTimeout((() => { - Oe.warn(''.concat(e._className, '.probe fetch timeout. Probably no network, please check!')), o.abort(), e._networkType = Xi, t([!1, Xi]); - }), e.MAX_WAIT_TIME);o.onreadystatechange = function () { - 4 === o.readyState && (clearTimeout(a), 200 === o.status || 304 === o.status ? (this._networkType = Qi, t([!0, Qi])) : (Oe.warn(''.concat(this.className, '.probe fetch status:').concat(o.status, '. Probably no network, please check!')), this._networkType = Xi, t([!1, Xi]))); - }, o.open('GET', ''.concat(nt(), '//web.sdk.qcloud.com/im/assets/speed.xml?random=').concat(Math.random())), o.send(); - } - })); - } }, { key: 'getNetworkType', value() { - return this._networkType; - } }, { key: 'reset', value() { - Oe.log(''.concat(this._className, '.reset')), ee ? null !== this._mpNetworkStatusCallback && (ne.offNetworkStatusChange && (Z || J ? ne.offNetworkStatusChange(this._mpNetworkStatusCallback) : ne.offNetworkStatusChange()), this._mpNetworkStatusCallback = null) : window && (null !== this._webOnlineCallback && (window.removeEventListener('online', this._webOnlineCallback), this._webOnlineCallback = null), null !== this._onWebOffline && (window.removeEventListener('offline', this._webOfflineCallback), this._webOfflineCallback = null)); - } }]), e; - }()); const ec = N(((e) => { - const t = Object.prototype.hasOwnProperty; let n = '~';function o() {} function a(e, t, n) { - this.fn = e, this.context = t, this.once = n || !1; - } function s(e, t, o, s, r) { - if ('function' !== typeof o) throw new TypeError('The listener must be a function');const i = new a(o, s || e, r); const c = n ? n + t : t;return e._events[c] ? e._events[c].fn ? e._events[c] = [e._events[c], i] : e._events[c].push(i) : (e._events[c] = i, e._eventsCount++), e; - } function r(e, t) { - 0 == --e._eventsCount ? e._events = new o : delete e._events[t]; - } function i() { - this._events = new o, this._eventsCount = 0; - }Object.create && (o.prototype = Object.create(null), (new o).__proto__ || (n = !1)), i.prototype.eventNames = function () { - let e; let o; const a = [];if (0 === this._eventsCount) return a;for (o in e = this._events)t.call(e, o) && a.push(n ? o.slice(1) : o);return Object.getOwnPropertySymbols ? a.concat(Object.getOwnPropertySymbols(e)) : a; - }, i.prototype.listeners = function (e) { - const t = n ? n + e : e; const o = this._events[t];if (!o) return [];if (o.fn) return [o.fn];for (var a = 0, s = o.length, r = new Array(s);a < s;a++)r[a] = o[a].fn;return r; - }, i.prototype.listenerCount = function (e) { - const t = n ? n + e : e; const o = this._events[t];return o ? o.fn ? 1 : o.length : 0; - }, i.prototype.emit = function (e, t, o, a, s, r) { - const i = n ? n + e : e;if (!this._events[i]) return !1;let c; let u; const l = this._events[i]; const d = arguments.length;if (l.fn) { - switch (l.once && this.removeListener(e, l.fn, void 0, !0), d) { - case 1:return l.fn.call(l.context), !0;case 2:return l.fn.call(l.context, t), !0;case 3:return l.fn.call(l.context, t, o), !0;case 4:return l.fn.call(l.context, t, o, a), !0;case 5:return l.fn.call(l.context, t, o, a, s), !0;case 6:return l.fn.call(l.context, t, o, a, s, r), !0; - } for (u = 1, c = new Array(d - 1);u < d;u++)c[u - 1] = arguments[u];l.fn.apply(l.context, c); - } else { - let p; const g = l.length;for (u = 0;u < g;u++) switch (l[u].once && this.removeListener(e, l[u].fn, void 0, !0), d) { - case 1:l[u].fn.call(l[u].context);break;case 2:l[u].fn.call(l[u].context, t);break;case 3:l[u].fn.call(l[u].context, t, o);break;case 4:l[u].fn.call(l[u].context, t, o, a);break;default:if (!c) for (p = 1, c = new Array(d - 1);p < d;p++)c[p - 1] = arguments[p];l[u].fn.apply(l[u].context, c); - } - } return !0; - }, i.prototype.on = function (e, t, n) { - return s(this, e, t, n, !1); - }, i.prototype.once = function (e, t, n) { - return s(this, e, t, n, !0); - }, i.prototype.removeListener = function (e, t, o, a) { - const s = n ? n + e : e;if (!this._events[s]) return this;if (!t) return r(this, s), this;const i = this._events[s];if (i.fn)i.fn !== t || a && !i.once || o && i.context !== o || r(this, s);else { - for (var c = 0, u = [], l = i.length;c < l;c++)(i[c].fn !== t || a && !i[c].once || o && i[c].context !== o) && u.push(i[c]);u.length ? this._events[s] = 1 === u.length ? u[0] : u : r(this, s); - } return this; - }, i.prototype.removeAllListeners = function (e) { - let t;return e ? (t = n ? n + e : e, this._events[t] && r(this, t)) : (this._events = new o, this._eventsCount = 0), this; - }, i.prototype.off = i.prototype.removeListener, i.prototype.addListener = i.prototype.on, i.prefixed = n, i.EventEmitter = i, e.exports = i; - })); const tc = (function (e) { - i(a, e);const n = f(a);function a(e) { - let o;return t(this, a), (o = n.call(this, e))._className = 'BigDataChannelModule', o.FILETYPE = { SOUND: 2106, FILE: 2107, VIDEO: 2113 }, o._bdh_download_server = 'grouptalk.c2c.qq.com', o._BDHBizID = 10001, o._authKey = '', o._expireTime = 0, o.getInnerEmitterInstance().on(ii, o._getAuthKey, h(o)), o; - } return o(a, [{ key: '_getAuthKey', value() { - const e = this;this.request({ protocolName: pn }).then(((t) => { - t.data.authKey && (e._authKey = t.data.authKey, e._expireTime = parseInt(t.data.expireTime)); - })); - } }, { key: '_isFromOlderVersion', value(e) { - return !(!e.content || 2 === e.content.downloadFlag); - } }, { key: 'parseElements', value(e, t) { - if (!Fe(e) || !t) return [];for (var n = [], o = null, a = 0;a < e.length;a++)o = e[a], this._needParse(o) ? n.push(this._parseElement(o, t)) : n.push(e[a]);return n; - } }, { key: '_needParse', value(e) { - return !e.cloudCustomData && !(!this._isFromOlderVersion(e) || e.type !== k.MSG_AUDIO && e.type !== k.MSG_FILE && e.type !== k.MSG_VIDEO); - } }, { key: '_parseElement', value(e, t) { - switch (e.type) { - case k.MSG_AUDIO:return this._parseAudioElement(e, t);case k.MSG_FILE:return this._parseFileElement(e, t);case k.MSG_VIDEO:return this._parseVideoElement(e, t); - } - } }, { key: '_parseAudioElement', value(e, t) { - return e.content.url = this._genAudioUrl(e.content.uuid, t), e; - } }, { key: '_parseFileElement', value(e, t) { - return e.content.url = this._genFileUrl(e.content.uuid, t, e.content.fileName), e; - } }, { key: '_parseVideoElement', value(e, t) { - return e.content.url = this._genVideoUrl(e.content.uuid, t), e; - } }, { key: '_genAudioUrl', value(e, t) { - if ('' === this._authKey) return Oe.warn(''.concat(this._className, '._genAudioUrl no authKey!')), '';const n = this.getModule(Bt).getSDKAppID();return 'https://'.concat(this._bdh_download_server, '/asn.com/stddownload_common_file?authkey=').concat(this._authKey, '&bid=') - .concat(this._BDHBizID, '&subbid=') - .concat(n, '&fileid=') - .concat(e, '&filetype=') - .concat(this.FILETYPE.SOUND, '&openid=') - .concat(t, '&ver=0'); - } }, { key: '_genFileUrl', value(e, t, n) { - if ('' === this._authKey) return Oe.warn(''.concat(this._className, '._genFileUrl no authKey!')), '';n || (n = ''.concat(Math.floor(1e5 * Math.random()), '-').concat(Date.now()));const o = this.getModule(Bt).getSDKAppID();return 'https://'.concat(this._bdh_download_server, '/asn.com/stddownload_common_file?authkey=').concat(this._authKey, '&bid=') - .concat(this._BDHBizID, '&subbid=') - .concat(o, '&fileid=') - .concat(e, '&filetype=') - .concat(this.FILETYPE.FILE, '&openid=') - .concat(t, '&ver=0&filename=') - .concat(encodeURIComponent(n)); - } }, { key: '_genVideoUrl', value(e, t) { - if ('' === this._authKey) return Oe.warn(''.concat(this._className, '._genVideoUrl no authKey!')), '';const n = this.getModule(Bt).getSDKAppID();return 'https://'.concat(this._bdh_download_server, '/asn.com/stddownload_common_file?authkey=').concat(this._authKey, '&bid=') - .concat(this._BDHBizID, '&subbid=') - .concat(n, '&fileid=') - .concat(e, '&filetype=') - .concat(this.FILETYPE.VIDEO, '&openid=') - .concat(t, '&ver=0'); - } }, { key: 'reset', value() { - Oe.log(''.concat(this._className, '.reset')), this._authKey = '', this.expireTime = 0; - } }]), a; - }(sn)); const nc = (function (e) { - i(a, e);const n = f(a);function a(e) { - let o;return t(this, a), (o = n.call(this, e))._className = 'UploadModule', o.TIMUploadPlugin = null, o.timUploadPlugin = null, o.COSSDK = null, o._cosUploadMethod = null, o.expiredTimeLimit = 600, o.appid = 0, o.bucketName = '', o.ciUrl = '', o.directory = '', o.downloadUrl = '', o.uploadUrl = '', o.region = 'ap-shanghai', o.cos = null, o.cosOptions = { secretId: '', secretKey: '', sessionToken: '', expiredTime: 0 }, o.uploadFileType = '', o.duration = 900, o.tryCount = 0, o.getInnerEmitterInstance().on(ii, o._init, h(o)), o; - } return o(a, [{ key: '_init', value() { - const e = ''.concat(this._className, '._init'); const t = this.getModule(zt);if (this.TIMUploadPlugin = t.getPlugin('tim-upload-plugin'), this.TIMUploadPlugin) this._initUploaderMethod();else { - const n = ee ? 'cos-wx-sdk' : 'cos-js-sdk';this.COSSDK = t.getPlugin(n), this.COSSDK ? (this._getAuthorizationKey(), Oe.warn(''.concat(e, ' v2.9.2起推荐使用 tim-upload-plugin 代替 ').concat(n, ',上传更快更安全。详细请参考 https://web.sdk.qcloud.com/im/doc/zh-cn/SDK.html#registerPlugin'))) : Oe.warn(''.concat(e, ' 没有检测到上传插件,将无法发送图片、音频、视频、文件等类型的消息。详细请参考 https://web.sdk.qcloud.com/im/doc/zh-cn/SDK.html#registerPlugin')); - } - } }, { key: '_getAuthorizationKey', value() { - const e = this; const t = new Xa(ls); const n = Math.ceil(Date.now() / 1e3);this.request({ protocolName: lo, requestData: { duration: this.expiredTimeLimit } }).then(((o) => { - const a = o.data;Oe.log(''.concat(e._className, '._getAuthorizationKey ok. data:'), a);const s = a.expiredTime - n;t.setMessage('requestId:'.concat(a.requestId, ' requestTime:').concat(n, ' expiredTime:') - .concat(a.expiredTime, ' diff:') - .concat(s, 's')).setNetworkType(e.getNetworkType()) - .end(), !ee && a.region && (e.region = a.region), e.appid = a.appid, e.bucketName = a.bucketName, e.ciUrl = a.ciUrl, e.directory = a.directory, e.downloadUrl = a.downloadUrl, e.uploadUrl = a.uploadUrl, e.cosOptions = { secretId: a.secretId, secretKey: a.secretKey, sessionToken: a.sessionToken, expiredTime: a.expiredTime }, Oe.log(''.concat(e._className, '._getAuthorizationKey ok. region:').concat(e.region, ' bucketName:') - .concat(e.bucketName)), e._initUploaderMethod(); - })) - .catch(((n) => { - e.probeNetwork().then(((e) => { - const o = m(e, 2); const a = o[0]; const s = o[1];t.setError(n, a, s).end(); - })), Oe.warn(''.concat(e._className, '._getAuthorizationKey failed. error:'), n); - })); - } }, { key: '_getCosPreSigUrl', value(e) { - const t = this; const n = ''.concat(this._className, '._getCosPreSigUrl'); const o = Math.ceil(Date.now() / 1e3); const a = new Xa(ds);return this.request({ protocolName: po, requestData: { fileType: e.fileType, fileName: e.fileName, uploadMethod: e.uploadMethod, duration: e.duration } }).then(((e) => { - t.tryCount = 0;const s = e.data || {}; const r = s.expiredTime - o;return Oe.log(''.concat(n, ' ok. data:'), s), a.setMessage('requestId:'.concat(s.requestId, ' expiredTime:').concat(s.expiredTime, ' diff:') - .concat(r, 's')).setNetworkType(t.getNetworkType()) - .end(), s; - })) - .catch((o => (-1 === o.code && (o.code = Do.COS_GET_SIG_FAIL), t.probeNetwork().then(((e) => { - const t = m(e, 2); const n = t[0]; const s = t[1];a.setError(o, n, s).end(); - })), Oe.warn(''.concat(n, ' failed. error:'), o), t.tryCount < 1 ? (t.tryCount++, t._getCosPreSigUrl(e)) : (t.tryCount = 0, ai({ code: Do.COS_GET_SIG_FAIL, message: wo }))))); - } }, { key: '_initUploaderMethod', value() { - const e = this;if (this.TIMUploadPlugin) return this.timUploadPlugin = new this.TIMUploadPlugin, void (this._cosUploadMethod = function (t, n) { - e.timUploadPlugin.uploadFile(t, n); - });this.appid && (this.cos = ee ? new this.COSSDK({ ForcePathStyle: !0, getAuthorization: this._getAuthorization.bind(this) }) : new this.COSSDK({ getAuthorization: this._getAuthorization.bind(this) }), this._cosUploadMethod = ee ? function (t, n) { - e.cos.postObject(t, n); - } : function (t, n) { - e.cos.uploadFiles(t, n); - }); - } }, { key: 'onCheckTimer', value(e) { - this.COSSDK && (this.TIMUploadPlugin || this.isLoggedIn() && e % 60 == 0 && Math.ceil(Date.now() / 1e3) >= this.cosOptions.expiredTime - 120 && this._getAuthorizationKey()); - } }, { key: '_getAuthorization', value(e, t) { - t({ TmpSecretId: this.cosOptions.secretId, TmpSecretKey: this.cosOptions.secretKey, XCosSecurityToken: this.cosOptions.sessionToken, ExpiredTime: this.cosOptions.expiredTime }); - } }, { key: 'upload', value(e) { - if (!0 === e.getRelayFlag()) return Promise.resolve();const t = this.getModule(on);switch (e.type) { - case k.MSG_IMAGE:return t.addTotalCount(Ba), this._uploadImage(e);case k.MSG_FILE:return t.addTotalCount(Ba), this._uploadFile(e);case k.MSG_AUDIO:return t.addTotalCount(Ba), this._uploadAudio(e);case k.MSG_VIDEO:return t.addTotalCount(Ba), this._uploadVideo(e);default:return Promise.resolve(); - } - } }, { key: '_uploadImage', value(e) { - const t = this.getModule(Pt); const n = e.getElements()[0]; const o = t.getMessageOptionByID(e.ID);return this.doUploadImage({ file: o.payload.file, to: o.to, onProgress(e) { - if (n.updatePercent(e), Ke(o.onProgress)) try { - o.onProgress(e); - } catch (t) { - return ai({ code: Do.MESSAGE_ONPROGRESS_FUNCTION_ERROR, message: qo }); - } - } }).then(((t) => { - const o = t.location; const a = t.fileType; const s = t.fileSize; const i = t.width; const c = t.height; const u = ot(o);n.updateImageFormat(a);const l = ht({ originUrl: u, originWidth: i, originHeight: c, min: 198 }); const d = ht({ originUrl: u, originWidth: i, originHeight: c, min: 720 });return n.updateImageInfoArray([{ size: s, url: u, width: i, height: c }, r({}, d), r({}, l)]), e; - })); - } }, { key: '_uploadFile', value(e) { - const t = this.getModule(Pt); const n = e.getElements()[0]; const o = t.getMessageOptionByID(e.ID);return this.doUploadFile({ file: o.payload.file, to: o.to, onProgress(e) { - if (n.updatePercent(e), Ke(o.onProgress)) try { - o.onProgress(e); - } catch (t) { - return ai({ code: Do.MESSAGE_ONPROGRESS_FUNCTION_ERROR, message: qo }); - } - } }).then(((t) => { - const o = t.location; const a = ot(o);return n.updateFileUrl(a), e; - })); - } }, { key: '_uploadAudio', value(e) { - const t = this.getModule(Pt); const n = e.getElements()[0]; const o = t.getMessageOptionByID(e.ID);return this.doUploadAudio({ file: o.payload.file, to: o.to, onProgress(e) { - if (n.updatePercent(e), Ke(o.onProgress)) try { - o.onProgress(e); - } catch (t) { - return ai({ code: Do.MESSAGE_ONPROGRESS_FUNCTION_ERROR, message: qo }); - } - } }).then(((t) => { - const o = t.location; const a = ot(o);return n.updateAudioUrl(a), e; - })); - } }, { key: '_uploadVideo', value(e) { - const t = this.getModule(Pt); const n = e.getElements()[0]; const o = t.getMessageOptionByID(e.ID);return this.doUploadVideo({ file: o.payload.file, to: o.to, onProgress(e) { - if (n.updatePercent(e), Ke(o.onProgress)) try { - o.onProgress(e); - } catch (t) { - return ai({ code: Do.MESSAGE_ONPROGRESS_FUNCTION_ERROR, message: qo }); - } - } }).then(((t) => { - const o = ot(t.location);return n.updateVideoUrl(o), e; - })); - } }, { key: 'doUploadImage', value(e) { - if (!e.file) return ai({ code: Do.MESSAGE_IMAGE_SELECT_FILE_FIRST, message: Bo });let t = this._checkImageType(e.file);if (!0 !== t) return t;const n = this._checkImageSize(e.file);if (!0 !== n) return n;let o = null;return this._setUploadFileType(gi), this.uploadByCOS(e).then((e => (o = e, t = 'https://'.concat(e.location), ee ? new Promise(((e, n) => { - ne.getImageInfo({ src: t, success(t) { - e({ width: t.width, height: t.height }); - }, fail() { - e({ width: 0, height: 0 }); - } }); - })) : he && 9 === _e ? Promise.resolve({ width: 0, height: 0 }) : new Promise(((e, n) => { - let o = new Image;o.onload = function () { - e({ width: this.width, height: this.height }), o = null; - }, o.onerror = function () { - e({ width: 0, height: 0 }), o = null; - }, o.src = t; - }))))) - .then((e => (o.width = e.width, o.height = e.height, Promise.resolve(o)))); - } }, { key: '_checkImageType', value(e) { - let t = '';return t = ee ? e.url.slice(e.url.lastIndexOf('.') + 1) : e.files[0].name.slice(e.files[0].name.lastIndexOf('.') + 1), di.indexOf(t.toLowerCase()) >= 0 || ai({ code: Do.MESSAGE_IMAGE_TYPES_LIMIT, message: Ho }); - } }, { key: '_checkImageSize', value(e) { - let t = 0;return 0 === (t = ee ? e.size : e.files[0].size) ? ai({ code: Do.MESSAGE_FILE_IS_EMPTY, message: ''.concat(Fo) }) : t < 20971520 || ai({ code: Do.MESSAGE_IMAGE_SIZE_LIMIT, message: ''.concat(jo) }); - } }, { key: 'doUploadFile', value(e) { - let t = null;return e.file ? e.file.files[0].size > 104857600 ? ai(t = { code: Do.MESSAGE_FILE_SIZE_LIMIT, message: Zo }) : 0 === e.file.files[0].size ? (t = { code: Do.MESSAGE_FILE_IS_EMPTY, message: ''.concat(Fo) }, ai(t)) : (this._setUploadFileType(fi), this.uploadByCOS(e)) : ai(t = { code: Do.MESSAGE_FILE_SELECT_FILE_FIRST, message: Qo }); - } }, { key: 'doUploadVideo', value(e) { - return e.file.videoFile.size > 104857600 ? ai({ code: Do.MESSAGE_VIDEO_SIZE_LIMIT, message: ''.concat(zo) }) : 0 === e.file.videoFile.size ? ai({ code: Do.MESSAGE_FILE_IS_EMPTY, message: ''.concat(Fo) }) : -1 === pi.indexOf(e.file.videoFile.type) ? ai({ code: Do.MESSAGE_VIDEO_TYPES_LIMIT, message: ''.concat(Jo) }) : (this._setUploadFileType(hi), ee ? this.handleVideoUpload({ file: e.file.videoFile, onProgress: e.onProgress }) : te ? this.handleVideoUpload(e) : void 0); - } }, { key: 'handleVideoUpload', value(e) { - const t = this;return new Promise(((n, o) => { - t.uploadByCOS(e).then(((e) => { - n(e); - })) - .catch((() => { - t.uploadByCOS(e).then(((e) => { - n(e); - })) - .catch((() => { - o(new ei({ code: Do.MESSAGE_VIDEO_UPLOAD_FAIL, message: $o })); - })); - })); - })); - } }, { key: 'doUploadAudio', value(e) { - return e.file ? e.file.size > 20971520 ? ai(new ei({ code: Do.MESSAGE_AUDIO_SIZE_LIMIT, message: ''.concat(Yo) })) : 0 === e.file.size ? ai(new ei({ code: Do.MESSAGE_FILE_IS_EMPTY, message: ''.concat(Fo) })) : (this._setUploadFileType(_i), this.uploadByCOS(e)) : ai(new ei({ code: Do.MESSAGE_AUDIO_UPLOAD_FAIL, message: Wo })); - } }, { key: 'uploadByCOS', value(e) { - const t = this; const n = ''.concat(this._className, '.uploadByCOS');if (!Ke(this._cosUploadMethod)) return Oe.warn(''.concat(n, ' 没有检测到上传插件,将无法发送图片、音频、视频、文件等类型的消息。详细请参考 https://web.sdk.qcloud.com/im/doc/zh-cn/SDK.html#registerPlugin')), ai({ code: Do.COS_UNDETECTED, message: Go });if (this.timUploadPlugin) return this._uploadWithPreSigUrl(e);const o = new Xa(ps); const a = Date.now(); const s = this._getFile(e);return new Promise(((r, i) => { - const c = ee ? t._createCosOptionsWXMiniApp(e) : t._createCosOptionsWeb(e); const u = t;t._cosUploadMethod(c, ((e, c) => { - const l = Object.create(null);if (c) { - if (e || Fe(c.files) && c.files[0].error) { - const d = new ei({ code: Do.MESSAGE_FILE_UPLOAD_FAIL, message: Xo });return o.setError(d, !0, t.getNetworkType()).end(), Oe.log(''.concat(n, ' failed. error:'), c.files[0].error), 403 === c.files[0].error.statusCode && (Oe.warn(''.concat(n, ' failed. cos AccessKeyId was invalid, regain auth key!')), t._getAuthorizationKey()), void i(d); - }l.fileName = s.name, l.fileSize = s.size, l.fileType = s.type.slice(s.type.indexOf('/') + 1).toLowerCase(), l.location = ee ? c.Location : c.files[0].data.Location;const p = Date.now() - a; const g = u._formatFileSize(s.size); const h = u._formatSpeed(1e3 * s.size / p); const _ = 'size:'.concat(g, ' time:').concat(p, 'ms speed:') - .concat(h);Oe.log(''.concat(n, ' success. name:').concat(s.name, ' ') - .concat(_)), r(l);const f = t.getModule(on);return f.addCost(Ba, p), f.addFileSize(Ba, s.size), void o.setNetworkType(t.getNetworkType()).setMessage(_) - .end(); - } const m = new ei({ code: Do.MESSAGE_FILE_UPLOAD_FAIL, message: Xo });o.setError(m, !0, u.getNetworkType()).end(), Oe.warn(''.concat(n, ' failed. error:'), e), 403 === e.statusCode && (Oe.warn(''.concat(n, ' failed. cos AccessKeyId was invalid, regain auth key!')), t._getAuthorizationKey()), i(m); - })); - })); - } }, { key: '_uploadWithPreSigUrl', value(e) { - const t = this; const n = ''.concat(this._className, '._uploadWithPreSigUrl'); const o = this._getFile(e);return this._createCosOptionsPreSigUrl(e).then((e => new Promise(((a, s) => { - const r = new Xa(ps); const i = Date.now();t._cosUploadMethod(e, ((e, c) => { - const u = Object.create(null);if (e || 403 === c.statusCode) { - const l = new ei({ code: Do.MESSAGE_FILE_UPLOAD_FAIL, message: Xo });return r.setError(l, !0, t.getNetworkType()).end(), Oe.log(''.concat(n, ' failed, error:'), e), void s(l); - } let d = c.data.location || '';0 !== d.indexOf('https://') && 0 !== d.indexOf('http://') || (d = d.split('//')[1]), u.fileName = o.name, u.fileSize = o.size, u.fileType = o.type.slice(o.type.indexOf('/') + 1).toLowerCase(), u.location = d;const p = Date.now() - i; const g = t._formatFileSize(o.size); const h = t._formatSpeed(1e3 * o.size / p); const _ = 'size:'.concat(g, ',time:').concat(p, 'ms,speed:') - .concat(h, ' res:') - .concat(JSON.stringify(c.data));Oe.log(''.concat(n, ' success name:').concat(o.name, ',') - .concat(_)), r.setNetworkType(t.getNetworkType()).setMessage(_) - .end();const f = t.getModule(on);f.addCost(Ba, p), f.addFileSize(Ba, o.size), a(u); - })); - })))); - } }, { key: '_getFile', value(e) { - let t = null;return ee ? t = Z && Fe(e.file.files) ? e.file.files[0] : e.file : te && (t = e.file.files[0]), t; - } }, { key: '_formatFileSize', value(e) { - return e < 1024 ? `${e}B` : e < 1048576 ? `${Math.floor(e / 1024)}KB` : `${Math.floor(e / 1048576)}MB`; - } }, { key: '_formatSpeed', value(e) { - return e <= 1048576 ? `${mt(e / 1024, 1)}KB/s` : `${mt(e / 1048576, 1)}MB/s`; - } }, { key: '_createCosOptionsWeb', value(e) { - const t = e.file.files[0].name; const n = t.slice(t.lastIndexOf('.')); const o = this._genFileName(''.concat(Je(999999)).concat(n));return { files: [{ Bucket: ''.concat(this.bucketName, '-').concat(this.appid), Region: this.region, Key: ''.concat(this.directory, '/').concat(o), Body: e.file.files[0] }], SliceSize: 1048576, onProgress(t) { - if ('function' === typeof e.onProgress) try { - e.onProgress(t.percent); - } catch (n) { - Oe.warn('onProgress callback error:', n); - } - }, onFileFinish(e, t, n) {} }; - } }, { key: '_createCosOptionsWXMiniApp', value(e) { - const t = this._getFile(e); const n = this._genFileName(t.name); const o = t.url;return { Bucket: ''.concat(this.bucketName, '-').concat(this.appid), Region: this.region, Key: ''.concat(this.directory, '/').concat(n), FilePath: o, onProgress(t) { - if (Oe.log(JSON.stringify(t)), 'function' === typeof e.onProgress) try { - e.onProgress(t.percent); - } catch (n) { - Oe.warn('onProgress callback error:', n); - } - } }; - } }, { key: '_createCosOptionsPreSigUrl', value(e) { - const t = this; let n = ''; let o = ''; let a = 0;if (ee) { - const s = this._getFile(e);n = this._genFileName(s.name), o = s.url, a = 1; - } else { - const r = e.file.files[0].name; const i = r.slice(r.lastIndexOf('.'));n = this._genFileName(''.concat(Je(999999)).concat(i)), o = e.file.files[0], a = 0; - } return this._getCosPreSigUrl({ fileType: this.uploadFileType, fileName: n, uploadMethod: a, duration: this.duration }).then(((a) => { - const s = a.uploadUrl; const r = a.downloadUrl;return { url: s, fileType: t.uploadFileType, fileName: n, resources: o, downloadUrl: r, onProgress(t) { - if ('function' === typeof e.onProgress) try { - e.onProgress(t.percent); - } catch (n) { - Oe.warn('onProgress callback error:', n), Oe.error(n); - } - } }; - })); - } }, { key: '_genFileName', value(e) { - return ''.concat(pt(), '-').concat(e); - } }, { key: '_setUploadFileType', value(e) { - this.uploadFileType = e; - } }, { key: 'reset', value() { - Oe.log(''.concat(this._className, '.reset')); - } }]), a; - }(sn)); const oc = (function () { - function e(n) { - t(this, e), this._className = 'MergerMessageHandler', this._messageModule = n; - } return o(e, [{ key: 'uploadMergerMessage', value(e, t) { - const n = this;Oe.debug(''.concat(this._className, '.uploadMergerMessage message:'), e, 'messageBytes:'.concat(t));const o = e.payload.messageList; const a = o.length; const s = new Xa(Cs);return this._messageModule.request({ protocolName: Mo, requestData: { messageList: o } }).then(((e) => { - Oe.debug(''.concat(n._className, '.uploadMergerMessage ok. response:'), e.data);const o = e.data; const r = o.pbDownloadKey; const i = o.downloadKey; const c = { pbDownloadKey: r, downloadKey: i, messageNumber: a };return s.setNetworkType(n._messageModule.getNetworkType()).setMessage(''.concat(a, '-').concat(t, '-') - .concat(i)) - .end(), c; - })) - .catch(((e) => { - throw Oe.warn(''.concat(n._className, '.uploadMergerMessage failed. error:'), e), n._messageModule.probeNetwork().then(((t) => { - const n = m(t, 2); const o = n[0]; const a = n[1];s.setError(e, o, a).end(); - })), e; - })); - } }, { key: 'downloadMergerMessage', value(e) { - const t = this;Oe.debug(''.concat(this._className, '.downloadMergerMessage message:'), e);const n = e.payload.downloadKey; const o = new Xa(Ts);return o.setMessage('downloadKey:'.concat(n)), this._messageModule.request({ protocolName: vo, requestData: { downloadKey: n } }).then(((n) => { - if (Oe.debug(''.concat(t._className, '.downloadMergerMessage ok. response:'), n.data), Ke(e.clearElement)) { - const a = e.payload; const s = (a.downloadKey, a.pbDownloadKey, a.messageList, g(a, ['downloadKey', 'pbDownloadKey', 'messageList']));e.clearElement(), e.setElement({ type: e.type, content: r({ messageList: n.data.messageList }, s) }); - } else { - const i = [];n.data.messageList.forEach(((e) => { - if (!It(e)) { - const t = new Hr(e);i.push(t); - } - })), e.payload.messageList = i, e.payload.downloadKey = '', e.payload.pbDownloadKey = ''; - } return o.setNetworkType(t._messageModule.getNetworkType()).end(), e; - })) - .catch(((e) => { - throw Oe.warn(''.concat(t._className, '.downloadMergerMessage failed. key:').concat(n, ' error:'), e), t._messageModule.probeNetwork().then(((t) => { - const n = m(t, 2); const a = n[0]; const s = n[1];o.setError(e, a, s).end(); - })), e; - })); - } }, { key: 'createMergerMessagePack', value(e, t, n) { - return e.conversationType === k.CONV_C2C ? this._createC2CMergerMessagePack(e, t, n) : this._createGroupMergerMessagePack(e, t, n); - } }, { key: '_createC2CMergerMessagePack', value(e, t, n) { - let o = null;t && (t.offlinePushInfo && (o = t.offlinePushInfo), !0 === t.onlineUserOnly && (o ? o.disablePush = !0 : o = { disablePush: !0 }));let a = '';be(e.cloudCustomData) && e.cloudCustomData.length > 0 && (a = e.cloudCustomData);const s = n.pbDownloadKey; const r = n.downloadKey; const i = n.messageNumber; const c = e.payload; const u = c.title; const l = c.abstractList; const d = c.compatibleText; const p = this._messageModule.getModule(Ft);return { protocolName: gn, tjgID: this._messageModule.generateTjgID(e), requestData: { fromAccount: this._messageModule.getMyUserID(), toAccount: e.to, msgBody: [{ msgType: e.type, msgContent: { pbDownloadKey: s, downloadKey: r, title: u, abstractList: l, compatibleText: d, messageNumber: i } }], cloudCustomData: a, msgSeq: e.sequence, msgRandom: e.random, msgLifeTime: p && p.isOnlineMessage(e, t) ? 0 : void 0, offlinePushInfo: o ? { pushFlag: !0 === o.disablePush ? 1 : 0, title: o.title || '', desc: o.description || '', ext: o.extension || '', apnsInfo: { badgeMode: !0 === o.ignoreIOSBadge ? 1 : 0 }, androidInfo: { OPPOChannelID: o.androidOPPOChannelID || '' } } : void 0 } }; - } }, { key: '_createGroupMergerMessagePack', value(e, t, n) { - let o = null;t && t.offlinePushInfo && (o = t.offlinePushInfo);let a = '';be(e.cloudCustomData) && e.cloudCustomData.length > 0 && (a = e.cloudCustomData);const s = n.pbDownloadKey; const r = n.downloadKey; const i = n.messageNumber; const c = e.payload; const u = c.title; const l = c.abstractList; const d = c.compatibleText; const p = this._messageModule.getModule(qt);return { protocolName: hn, tjgID: this._messageModule.generateTjgID(e), requestData: { fromAccount: this._messageModule.getMyUserID(), groupID: e.to, msgBody: [{ msgType: e.type, msgContent: { pbDownloadKey: s, downloadKey: r, title: u, abstractList: l, compatibleText: d, messageNumber: i } }], random: e.random, priority: e.priority, clientSequence: e.clientSequence, groupAtInfo: void 0, cloudCustomData: a, onlineOnlyFlag: p && p.isOnlineMessage(e, t) ? 1 : 0, offlinePushInfo: o ? { pushFlag: !0 === o.disablePush ? 1 : 0, title: o.title || '', desc: o.description || '', ext: o.extension || '', apnsInfo: { badgeMode: !0 === o.ignoreIOSBadge ? 1 : 0 }, androidInfo: { OPPOChannelID: o.androidOPPOChannelID || '' } } : void 0 } }; - } }]), e; - }()); const ac = { ERR_SVR_COMM_SENSITIVE_TEXT: 80001, ERR_SVR_COMM_BODY_SIZE_LIMIT: 80002, OPEN_SERVICE_OVERLOAD_ERROR: 60022, ERR_SVR_MSG_PKG_PARSE_FAILED: 20001, ERR_SVR_MSG_INTERNAL_AUTH_FAILED: 20002, ERR_SVR_MSG_INVALID_ID: 20003, ERR_SVR_MSG_PUSH_DENY: 20006, ERR_SVR_MSG_IN_PEER_BLACKLIST: 20007, ERR_SVR_MSG_BOTH_NOT_FRIEND: 20009, ERR_SVR_MSG_NOT_PEER_FRIEND: 20010, ERR_SVR_MSG_NOT_SELF_FRIEND: 20011, ERR_SVR_MSG_SHUTUP_DENY: 20012, ERR_SVR_GROUP_INVALID_PARAMETERS: 10004, ERR_SVR_GROUP_PERMISSION_DENY: 10007, ERR_SVR_GROUP_NOT_FOUND: 10010, ERR_SVR_GROUP_INVALID_GROUPID: 10015, ERR_SVR_GROUP_REJECT_FROM_THIRDPARTY: 10016, ERR_SVR_GROUP_SHUTUP_DENY: 10017, MESSAGE_SEND_FAIL: 2100, OVER_FREQUENCY_LIMIT: 2996 }; const sc = [Do.MESSAGE_ONPROGRESS_FUNCTION_ERROR, Do.MESSAGE_IMAGE_SELECT_FILE_FIRST, Do.MESSAGE_IMAGE_TYPES_LIMIT, Do.MESSAGE_FILE_IS_EMPTY, Do.MESSAGE_IMAGE_SIZE_LIMIT, Do.MESSAGE_FILE_SELECT_FILE_FIRST, Do.MESSAGE_FILE_SIZE_LIMIT, Do.MESSAGE_VIDEO_SIZE_LIMIT, Do.MESSAGE_VIDEO_TYPES_LIMIT, Do.MESSAGE_AUDIO_UPLOAD_FAIL, Do.MESSAGE_AUDIO_SIZE_LIMIT, Do.COS_UNDETECTED];const rc = (function (e) { - i(a, e);const n = f(a);function a(e) { - let o;return t(this, a), (o = n.call(this, e))._className = 'MessageModule', o._messageOptionsMap = new Map, o._mergerMessageHandler = new oc(h(o)), o; - } return o(a, [{ key: 'createTextMessage', value(e) { - const t = this.getMyUserID();e.currentUser = t;const n = new Yr(e); const o = 'string' === typeof e.payload ? e.payload : e.payload.text; const a = new Dr({ text: o }); const s = this._getNickAndAvatarByUserID(t);return n.setElement(a), n.setNickAndAvatar(s), n.setNameCard(this._getNameCardByGroupID(n)), n; - } }, { key: 'createImageMessage', value(e) { - const t = this.getMyUserID();e.currentUser = t;const n = new Yr(e);if (ee) { - const o = e.payload.file;if (Ge(o)) return void Oe.warn('小程序环境下调用 createImageMessage 接口时,payload.file 不支持传入 File 对象');const a = o.tempFilePaths[0]; const s = { url: a, name: a.slice(a.lastIndexOf('/') + 1), size: o.tempFiles && o.tempFiles[0].size || 1, type: a.slice(a.lastIndexOf('.') + 1).toLowerCase() };e.payload.file = s; - } else if (te) if (Ge(e.payload.file)) { - const r = e.payload.file;e.payload.file = { files: [r] }; - } else if (Ue(e.payload.file) && 'undefined' !== typeof uni) { - const i = e.payload.file.tempFiles[0];e.payload.file = { files: [i] }; - } const c = new Gr({ imageFormat: kr.IMAGE_FORMAT.UNKNOWN, uuid: this._generateUUID(), file: e.payload.file }); const u = this._getNickAndAvatarByUserID(t);return n.setElement(c), n.setNickAndAvatar(u), n.setNameCard(this._getNameCardByGroupID(n)), this._messageOptionsMap.set(n.ID, e), n; - } }, { key: 'createAudioMessage', value(e) { - if (ee) { - const t = e.payload.file;if (ee) { - const n = { url: t.tempFilePath, name: t.tempFilePath.slice(t.tempFilePath.lastIndexOf('/') + 1), size: t.fileSize, second: parseInt(t.duration) / 1e3, type: t.tempFilePath.slice(t.tempFilePath.lastIndexOf('.') + 1).toLowerCase() };e.payload.file = n; - } const o = this.getMyUserID();e.currentUser = o;const a = new Yr(e); const s = new br({ second: Math.floor(t.duration / 1e3), size: t.fileSize, url: t.tempFilePath, uuid: this._generateUUID() }); const r = this._getNickAndAvatarByUserID(o);return a.setElement(s), a.setNickAndAvatar(r), a.setNameCard(this._getNameCardByGroupID(a)), this._messageOptionsMap.set(a.ID, e), a; - }Oe.warn('createAudioMessage 目前只支持小程序环境下发语音消息'); - } }, { key: 'createVideoMessage', value(e) { - const t = this.getMyUserID();e.currentUser = t, e.payload.file.thumbUrl = 'https://web.sdk.qcloud.com/im/assets/images/transparent.png', e.payload.file.thumbSize = 1668;const n = {};if (ee) { - if (Q) return void Oe.warn('createVideoMessage 不支持在支付宝小程序环境下使用');if (Ge(e.payload.file)) return void Oe.warn('小程序环境下调用 createVideoMessage 接口时,payload.file 不支持传入 File 对象');const o = e.payload.file;n.url = o.tempFilePath, n.name = o.tempFilePath.slice(o.tempFilePath.lastIndexOf('/') + 1), n.size = o.size, n.second = o.duration, n.type = o.tempFilePath.slice(o.tempFilePath.lastIndexOf('.') + 1).toLowerCase(); - } else if (te) { - if (Ge(e.payload.file)) { - const a = e.payload.file;e.payload.file.files = [a]; - } else if (Ue(e.payload.file) && 'undefined' !== typeof uni) { - const s = e.payload.file.tempFile;e.payload.file.files = [s]; - } const r = e.payload.file;n.url = window.URL.createObjectURL(r.files[0]), n.name = r.files[0].name, n.size = r.files[0].size, n.second = r.files[0].duration || 0, n.type = r.files[0].type.split('/')[1]; - }e.payload.file.videoFile = n;const i = new Yr(e); const c = new xr({ videoFormat: n.type, videoSecond: mt(n.second, 0), videoSize: n.size, remoteVideoUrl: '', videoUrl: n.url, videoUUID: this._generateUUID(), thumbUUID: this._generateUUID(), thumbWidth: e.payload.file.width || 200, thumbHeight: e.payload.file.height || 200, thumbUrl: e.payload.file.thumbUrl, thumbSize: e.payload.file.thumbSize, thumbFormat: e.payload.file.thumbUrl.slice(e.payload.file.thumbUrl.lastIndexOf('.') + 1).toLowerCase() }); const u = this._getNickAndAvatarByUserID(t);return i.setElement(c), i.setNickAndAvatar(u), i.setNameCard(this._getNameCardByGroupID(i)), this._messageOptionsMap.set(i.ID, e), i; - } }, { key: 'createCustomMessage', value(e) { - const t = this.getMyUserID();e.currentUser = t;const n = new Yr(e); const o = new Kr({ data: e.payload.data, description: e.payload.description, extension: e.payload.extension }); const a = this._getNickAndAvatarByUserID(t);return n.setElement(o), n.setNickAndAvatar(a), n.setNameCard(this._getNameCardByGroupID(n)), n; - } }, { key: 'createFaceMessage', value(e) { - const t = this.getMyUserID();e.currentUser = t;const n = new Yr(e); const o = new wr(e.payload); const a = this._getNickAndAvatarByUserID(t);return n.setElement(o), n.setNickAndAvatar(a), n.setNameCard(this._getNameCardByGroupID(n)), n; - } }, { key: 'createMergerMessage', value(e) { - const t = this.getMyUserID();e.currentUser = t;const n = this._getNickAndAvatarByUserID(t); const o = new Yr(e); const a = new jr(e.payload);return o.setElement(a), o.setNickAndAvatar(n), o.setNameCard(this._getNameCardByGroupID(o)), o.setRelayFlag(!0), o; - } }, { key: 'createForwardMessage', value(e) { - const t = e.to; const n = e.conversationType; const o = e.priority; const a = e.payload; const s = this.getMyUserID(); const r = this._getNickAndAvatarByUserID(s);if (a.type === k.MSG_GRP_TIP) return ai(new ei({ code: Do.MESSAGE_FORWARD_TYPE_INVALID, message: aa }));const i = { to: t, conversationType: n, conversationID: ''.concat(n).concat(t), priority: o, isPlaceMessage: 0, status: Dt.UNSEND, currentUser: s, cloudCustomData: e.cloudCustomData || a.cloudCustomData || '' }; const c = new Yr(i);return c.setElement(a.getElements()[0]), c.setNickAndAvatar(r), c.setNameCard(this._getNameCardByGroupID(a)), c.setRelayFlag(!0), c; - } }, { key: 'downloadMergerMessage', value(e) { - return this._mergerMessageHandler.downloadMergerMessage(e); - } }, { key: 'createFileMessage', value(e) { - if (!ee || Z) { - if (te || Z) if (Ge(e.payload.file)) { - const t = e.payload.file;e.payload.file = { files: [t] }; - } else if (Ue(e.payload.file) && 'undefined' !== typeof uni) { - const n = e.payload.file; const o = n.tempFiles; const a = n.files; let s = null;Fe(o) ? s = o[0] : Fe(a) && (s = a[0]), e.payload.file = { files: [s] }; - } const r = this.getMyUserID();e.currentUser = r;const i = new Yr(e); const c = new Vr({ uuid: this._generateUUID(), file: e.payload.file }); const u = this._getNickAndAvatarByUserID(r);return i.setElement(c), i.setNickAndAvatar(u), i.setNameCard(this._getNameCardByGroupID(i)), this._messageOptionsMap.set(i.ID, e), i; - }Oe.warn('小程序目前不支持选择文件, createFileMessage 接口不可用!'); - } }, { key: 'createLocationMessage', value(e) { - const t = this.getMyUserID();e.currentUser = t;const n = new Yr(e); const o = new Br(e.payload); const a = this._getNickAndAvatarByUserID(t);return n.setElement(o), n.setNickAndAvatar(a), n.setNameCard(this._getNameCardByGroupID(n)), this._messageOptionsMap.set(n.ID, e), n; - } }, { key: '_onCannotFindModule', value() { - return ai({ code: Do.CANNOT_FIND_MODULE, message: Ga }); - } }, { key: 'sendMessageInstance', value(e, t) { - let n; const o = this; let a = null;switch (e.conversationType) { - case k.CONV_C2C:if (!(a = this.getModule(Ft))) return this._onCannotFindModule();break;case k.CONV_GROUP:if (!(a = this.getModule(qt))) return this._onCannotFindModule();break;default:return ai({ code: Do.MESSAGE_SEND_INVALID_CONVERSATION_TYPE, message: Uo }); - } const s = this.getModule($t); const r = this.getModule(qt);return s.upload(e).then((() => { - o._getSendMessageSpecifiedKey(e) === xa && o.getModule(on).addSuccessCount(Ba);return r.guardForAVChatRoom(e).then((() => { - if (!e.isSendable()) return ai({ code: Do.MESSAGE_FILE_URL_IS_EMPTY, message: ea });o._addSendMessageTotalCount(e), n = Date.now();const s = (function (e) { - let t = 'utf-8';te && document && (t = document.charset.toLowerCase());let n; let o; let a = 0;if (o = e.length, 'utf-8' === t || 'utf8' === t) for (let s = 0;s < o;s++)(n = e.codePointAt(s)) <= 127 ? a += 1 : n <= 2047 ? a += 2 : n <= 65535 ? a += 3 : (a += 4, s++);else if ('utf-16' === t || 'utf16' === t) for (let r = 0;r < o;r++)(n = e.codePointAt(r)) <= 65535 ? a += 2 : (a += 4, r++);else a = e.replace(/[^\x00-\xff]/g, 'aa').length;return a; - }(JSON.stringify(e)));return e.type === k.MSG_MERGER && s > 7e3 ? o._mergerMessageHandler.uploadMergerMessage(e, s).then(((n) => { - const a = o._mergerMessageHandler.createMergerMessagePack(e, t, n);return o.request(a); - })) : (o.getModule(xt).setMessageRandom(e), e.conversationType === k.CONV_C2C || e.conversationType === k.CONV_GROUP ? a.sendMessage(e, t) : void 0); - })) - .then(((s) => { - const r = s.data; const i = r.time; const c = r.sequence;o._addSendMessageSuccessCount(e, n), o._messageOptionsMap.delete(e.ID);const u = o.getModule(xt);e.status = Dt.SUCCESS, e.time = i;let l = !1;if (e.conversationType === k.CONV_GROUP)e.sequence = c, e.generateMessageID(o.getMyUserID());else if (e.conversationType === k.CONV_C2C) { - const d = u.getLatestMessageSentByMe(e.conversationID);if (d) { - const p = d.nick; const g = d.avatar;p === e.nick && g === e.avatar || (l = !0); - } - } if (u.appendToMessageList(e), l && u.modifyMessageSentByMe({ conversationID: e.conversationID, latestNick: e.nick, latestAvatar: e.avatar }), a.isOnlineMessage(e, t))e._onlineOnlyFlag = !0;else { - let h = e;Ue(t) && Ue(t.messageControlInfo) && (!0 === t.messageControlInfo.excludedFromLastMessage && (e._isExcludedFromLastMessage = !0, h = ''), !0 === t.messageControlInfo.excludedFromUnreadCount && (e._isExcludedFromUnreadCount = !0)), u.onMessageSent({ conversationOptionsList: [{ conversationID: e.conversationID, unreadCount: 0, type: e.conversationType, subType: e.conversationSubType, lastMessage: h }] }); - } return e.getRelayFlag() || 'TIMImageElem' !== e.type || _t(e.payload.imageInfoArray), $r({ message: e }); - })); - })) - .catch((t => o._onSendMessageFailed(e, t))); - } }, { key: '_onSendMessageFailed', value(e, t) { - e.status = Dt.FAIL, this.getModule(xt).deleteMessageRandom(e), this._addSendMessageFailCountOnUser(e, t);const n = new Xa(gs);return n.setMessage('tjg_id:'.concat(this.generateTjgID(e), ' type:').concat(e.type, ' from:') - .concat(e.from, ' to:') - .concat(e.to)), this.probeNetwork().then(((e) => { - const o = m(e, 2); const a = o[0]; const s = o[1];n.setError(t, a, s).end(); - })), Oe.error(''.concat(this._className, '._onSendMessageFailed error:'), t), ai(new ei({ code: t && t.code ? t.code : Do.MESSAGE_SEND_FAIL, message: t && t.message ? t.message : bo, data: { message: e } })); - } }, { key: '_getSendMessageSpecifiedKey', value(e) { - if ([k.MSG_IMAGE, k.MSG_AUDIO, k.MSG_VIDEO, k.MSG_FILE].includes(e.type)) return xa;if (e.conversationType === k.CONV_C2C) return qa;if (e.conversationType === k.CONV_GROUP) { - const t = this.getModule(qt).getLocalGroupProfile(e.to);if (!t) return;const n = t.type;return it(n) ? Ka : Va; - } - } }, { key: '_addSendMessageTotalCount', value(e) { - const t = this._getSendMessageSpecifiedKey(e);t && this.getModule(on).addTotalCount(t); - } }, { key: '_addSendMessageSuccessCount', value(e, t) { - const n = Math.abs(Date.now() - t); const o = this._getSendMessageSpecifiedKey(e);if (o) { - const a = this.getModule(on);a.addSuccessCount(o), a.addCost(o, n); - } - } }, { key: '_addSendMessageFailCountOnUser', value(e, t) { - let n; let o; const a = t.code; const s = void 0 === a ? -1 : a; const r = this.getModule(on); const i = this._getSendMessageSpecifiedKey(e);i === xa && (n = s, o = !1, sc.includes(n) && (o = !0), o) ? r.addFailedCountOfUserSide(Ba) : (function (e) { - let t = !1;return Object.values(ac).includes(e) && (t = !0), (e >= 120001 && e <= 13e4 || e >= 10100 && e <= 10200) && (t = !0), t; - }(s)) && i && r.addFailedCountOfUserSide(i); - } }, { key: 'resendMessage', value(e) { - return e.isResend = !0, e.status = Dt.UNSEND, e.random = Je(), e.generateMessageID(this.getMyUserID()), this.sendMessageInstance(e); - } }, { key: 'revokeMessage', value(e) { - const t = this; let n = null;if (e.conversationType === k.CONV_C2C) { - if (!(n = this.getModule(Ft))) return this._onCannotFindModule(); - } else if (e.conversationType === k.CONV_GROUP && !(n = this.getModule(qt))) return this._onCannotFindModule();const o = new Xa(fs);return o.setMessage('tjg_id:'.concat(this.generateTjgID(e), ' type:').concat(e.type, ' from:') - .concat(e.from, ' to:') - .concat(e.to)), n.revokeMessage(e).then(((n) => { - const a = n.data.recallRetList;if (!It(a) && 0 !== a[0].retCode) { - const s = new ei({ code: a[0].retCode, message: Zr[a[0].retCode] || Vo, data: { message: e } });return o.setCode(s.code).setMoreMessage(s.message) - .end(), ai(s); - } return Oe.info(''.concat(t._className, '.revokeMessage ok. ID:').concat(e.ID)), e.isRevoked = !0, o.end(), t.getModule(xt).onMessageRevoked([e]), $r({ message: e }); - })) - .catch(((n) => { - t.probeNetwork().then(((e) => { - const t = m(e, 2); const a = t[0]; const s = t[1];o.setError(n, a, s).end(); - }));const a = new ei({ code: n && n.code ? n.code : Do.MESSAGE_REVOKE_FAIL, message: n && n.message ? n.message : Vo, data: { message: e } });return Oe.warn(''.concat(t._className, '.revokeMessage failed. error:'), n), ai(a); - })); - } }, { key: 'deleteMessage', value(e) { - const t = this; let n = null; const o = e[0]; const a = o.conversationID; let s = ''; let r = []; let i = [];if (o.conversationType === k.CONV_C2C ? (n = this.getModule(Ft), s = a.replace(k.CONV_C2C, ''), e.forEach(((e) => { - e && e.status === Dt.SUCCESS && e.conversationID === a && (e._onlineOnlyFlag || r.push(''.concat(e.sequence, '_').concat(e.random, '_') - .concat(e.time)), i.push(e)); - }))) : o.conversationType === k.CONV_GROUP && (n = this.getModule(qt), s = a.replace(k.CONV_GROUP, ''), e.forEach(((e) => { - e && e.status === Dt.SUCCESS && e.conversationID === a && (e._onlineOnlyFlag || r.push(''.concat(e.sequence)), i.push(e)); - }))), !n) return this._onCannotFindModule();if (0 === r.length) return this._onMessageDeleted(i);r.length > 30 && (r = r.slice(0, 30), i = i.slice(0, 30));const c = new Xa(ms);return c.setMessage('to:'.concat(s, ' count:').concat(r.length)), n.deleteMessage({ to: s, keyList: r }).then((e => (c.end(), Oe.info(''.concat(t._className, '.deleteMessage ok')), t._onMessageDeleted(i)))) - .catch(((e) => { - t.probeNetwork().then(((t) => { - const n = m(t, 2); const o = n[0]; const a = n[1];c.setError(e, o, a).end(); - })), Oe.warn(''.concat(t._className, '.deleteMessage failed. error:'), e);const n = new ei({ code: e && e.code ? e.code : Do.MESSAGE_DELETE_FAIL, message: e && e.message ? e.message : Ko });return ai(n); - })); - } }, { key: '_onMessageDeleted', value(e) { - return this.getModule(xt).onMessageDeleted(e), oi({ messageList: e }); - } }, { key: '_generateUUID', value() { - const e = this.getModule(Bt);return ''.concat(e.getSDKAppID(), '-').concat(e.getUserID(), '-') - .concat(function () { - for (var e = '', t = 32;t > 0;--t)e += Xe[Math.floor(Math.random() * Qe)];return e; - }()); - } }, { key: 'getMessageOptionByID', value(e) { - return this._messageOptionsMap.get(e); - } }, { key: '_getNickAndAvatarByUserID', value(e) { - return this.getModule(Ut).getNickAndAvatarByUserID(e); - } }, { key: '_getNameCardByGroupID', value(e) { - if (e.conversationType === k.CONV_GROUP) { - const t = this.getModule(qt);if (t) return t.getMyNameCardByGroupID(e.to); - } return ''; - } }, { key: 'reset', value() { - Oe.log(''.concat(this._className, '.reset')), this._messageOptionsMap.clear(); - } }]), a; - }(sn)); const ic = (function (e) { - i(a, e);const n = f(a);function a(e) { - let o;return t(this, a), (o = n.call(this, e))._className = 'PluginModule', o.plugins = {}, o; - } return o(a, [{ key: 'registerPlugin', value(e) { - const t = this;Object.keys(e).forEach(((n) => { - t.plugins[n] = e[n]; - })), new Xa(os).setMessage('key='.concat(Object.keys(e))) - .end(); - } }, { key: 'getPlugin', value(e) { - return this.plugins[e]; - } }, { key: 'reset', value() { - Oe.log(''.concat(this._className, '.reset')); - } }]), a; - }(sn)); const cc = (function (e) { - i(a, e);const n = f(a);function a(e) { - let o;return t(this, a), (o = n.call(this, e))._className = 'SyncUnreadMessageModule', o._cookie = '', o._onlineSyncFlag = !1, o.getInnerEmitterInstance().on(ii, o._onLoginSuccess, h(o)), o; - } return o(a, [{ key: '_onLoginSuccess', value(e) { - this._startSync({ cookie: this._cookie, syncFlag: 0, isOnlineSync: 0 }); - } }, { key: '_startSync', value(e) { - const t = this; const n = e.cookie; const o = e.syncFlag; const a = e.isOnlineSync;Oe.log(''.concat(this._className, '._startSync cookie:').concat(n, ' syncFlag:') - .concat(o, ' isOnlineSync:') - .concat(a)), this.request({ protocolName: dn, requestData: { cookie: n, syncFlag: o, isOnlineSync: a } }).then(((e) => { - const n = e.data; const o = n.cookie; const a = n.syncFlag; const s = n.eventArray; const r = n.messageList; const i = n.C2CRemainingUnreadList; const c = n.C2CPairUnreadList;if (t._cookie = o, It(o));else if (0 === a || 1 === a) { - if (s)t.getModule(Xt).onMessage({ head: {}, body: { eventArray: s, isInstantMessage: t._onlineSyncFlag, isSyncingEnded: !1 } });t.getModule(Ft).onNewC2CMessage({ dataList: r, isInstantMessage: !1, C2CRemainingUnreadList: i, C2CPairUnreadList: c }), t._startSync({ cookie: o, syncFlag: a, isOnlineSync: 0 }); - } else if (2 === a) { - if (s)t.getModule(Xt).onMessage({ head: {}, body: { eventArray: s, isInstantMessage: t._onlineSyncFlag, isSyncingEnded: !0 } });t.getModule(Ft).onNewC2CMessage({ dataList: r, isInstantMessage: t._onlineSyncFlag, C2CRemainingUnreadList: i, C2CPairUnreadList: c }); - } - })) - .catch(((e) => { - Oe.error(''.concat(t._className, '._startSync failed. error:'), e); - })); - } }, { key: 'startOnlineSync', value() { - Oe.log(''.concat(this._className, '.startOnlineSync')), this._onlineSyncFlag = !0, this._startSync({ cookie: this._cookie, syncFlag: 0, isOnlineSync: 1 }); - } }, { key: 'startSyncOnReconnected', value() { - Oe.log(''.concat(this._className, '.startSyncOnReconnected.')), this._onlineSyncFlag = !0, this._startSync({ cookie: this._cookie, syncFlag: 0, isOnlineSync: 0 }); - } }, { key: 'reset', value() { - Oe.log(''.concat(this._className, '.reset')), this._onlineSyncFlag = !1, this._cookie = ''; - } }]), a; - }(sn)); const uc = { request: { toAccount: 'To_Account', fromAccount: 'From_Account', to: 'To_Account', from: 'From_Account', groupID: 'GroupId', groupAtUserID: 'GroupAt_Account', extension: 'Ext', data: 'Data', description: 'Desc', elements: 'MsgBody', sizeType: 'Type', downloadFlag: 'Download_Flag', thumbUUID: 'ThumbUUID', videoUUID: 'VideoUUID', remoteAudioUrl: 'Url', remoteVideoUrl: 'VideoUrl', videoUrl: '', imageUrl: 'URL', fileUrl: 'Url', uuid: 'UUID', priority: 'MsgPriority', receiverUserID: 'To_Account', receiverGroupID: 'GroupId', messageSender: 'SenderId', messageReceiver: 'ReceiverId', nick: 'From_AccountNick', avatar: 'From_AccountHeadurl', messageNumber: 'MsgNum', pbDownloadKey: 'PbMsgKey', downloadKey: 'JsonMsgKey', applicationType: 'PendencyType', userIDList: 'To_Account', groupNameList: 'GroupName', userID: 'To_Account', groupAttributeList: 'GroupAttr', mainSequence: 'AttrMainSeq', avChatRoomKey: 'BytesKey', attributeControl: 'AttrControl', sequence: 'seq', messageControlInfo: 'SendMsgControl', updateSequence: 'UpdateSeq' }, response: { MsgPriority: 'priority', ThumbUUID: 'thumbUUID', VideoUUID: 'videoUUID', Download_Flag: 'downloadFlag', GroupId: 'groupID', Member_Account: 'userID', MsgList: 'messageList', SyncFlag: 'syncFlag', To_Account: 'to', From_Account: 'from', MsgSeq: 'sequence', MsgRandom: 'random', MsgTime: 'time', MsgTimeStamp: 'time', MsgContent: 'content', MsgBody: 'elements', From_AccountNick: 'nick', From_AccountHeadurl: 'avatar', GroupWithdrawInfoArray: 'revokedInfos', GroupReadInfoArray: 'groupMessageReadNotice', LastReadMsgSeq: 'lastMessageSeq', WithdrawC2cMsgNotify: 'c2cMessageRevokedNotify', C2cWithdrawInfoArray: 'revokedInfos', C2cReadedReceipt: 'c2cMessageReadReceipt', ReadC2cMsgNotify: 'c2cMessageReadNotice', LastReadTime: 'peerReadTime', MsgRand: 'random', MsgType: 'type', MsgShow: 'messageShow', NextMsgSeq: 'nextMessageSeq', FaceUrl: 'avatar', ProfileDataMod: 'profileModify', Profile_Account: 'userID', ValueBytes: 'value', ValueNum: 'value', NoticeSeq: 'noticeSequence', NotifySeq: 'notifySequence', MsgFrom_AccountExtraInfo: 'messageFromAccountExtraInformation', Operator_Account: 'operatorID', OpType: 'operationType', ReportType: 'operationType', UserId: 'userID', User_Account: 'userID', List_Account: 'userIDList', MsgOperatorMemberExtraInfo: 'operatorInfo', MsgMemberExtraInfo: 'memberInfoList', ImageUrl: 'avatar', NickName: 'nick', MsgGroupNewInfo: 'newGroupProfile', MsgAppDefinedData: 'groupCustomField', Owner_Account: 'ownerID', GroupFaceUrl: 'avatar', GroupIntroduction: 'introduction', GroupNotification: 'notification', GroupApplyJoinOption: 'joinOption', MsgKey: 'messageKey', GroupInfo: 'groupProfile', ShutupTime: 'muteTime', Desc: 'description', Ext: 'extension', GroupAt_Account: 'groupAtUserID', MsgNum: 'messageNumber', PbMsgKey: 'pbDownloadKey', JsonMsgKey: 'downloadKey', MsgModifiedFlag: 'isModified', PendencyItem: 'applicationItem', PendencyType: 'applicationType', AddTime: 'time', AddSource: 'source', AddWording: 'wording', ProfileImImage: 'avatar', PendencyAdd: 'friendApplicationAdded', FrienPencydDel_Account: 'friendApplicationDeletedUserIDList', Peer_Account: 'userID', GroupAttr: 'groupAttributeList', GroupAttrAry: 'groupAttributeList', AttrMainSeq: 'mainSequence', seq: 'sequence', GroupAttrOption: 'groupAttributeOption', BytesChangedKeys: 'changedKeyList', GroupAttrInfo: 'groupAttributeList', GroupAttrSeq: 'mainSequence', PushChangedAttrValFlag: 'hasChangedAttributeInfo', SubKeySeq: 'sequence', Val: 'value', MsgGroupFromCardName: 'senderNameCard', MsgGroupFromNickName: 'senderNick', C2cNick: 'peerNick', C2cImage: 'peerAvatar', SendMsgControl: 'messageControlInfo', NoLastMsg: 'excludedFromLastMessage', NoUnread: 'excludedFromUnreadCount', UpdateSeq: 'updateSequence', MuteNotifications: 'muteFlag' }, ignoreKeyWord: ['C2C', 'ID', 'USP'] };function lc(e, t) { - if ('string' !== typeof e && !Array.isArray(e)) throw new TypeError('Expected the input to be `string | string[]`');t = Object.assign({ pascalCase: !1 }, t);let n;return 0 === (e = Array.isArray(e) ? e.map((e => e.trim())).filter((e => e.length)) - .join('-') : e.trim()).length ? '' : 1 === e.length ? t.pascalCase ? e.toUpperCase() : e.toLowerCase() : (e !== e.toLowerCase() && (e = dc(e)), e = e.replace(/^[_.\- ]+/, '').toLowerCase() - .replace(/[_.\- ]+(\w|$)/g, ((e, t) => t.toUpperCase())) - .replace(/\d+(\w|$)/g, (e => e.toUpperCase())), n = e, t.pascalCase ? n.charAt(0).toUpperCase() + n.slice(1) : n); - } var dc = function (e) { - for (let t = !1, n = !1, o = !1, a = 0;a < e.length;a++) { - const s = e[a];t && /[a-zA-Z]/.test(s) && s.toUpperCase() === s ? (e = `${e.slice(0, a)}-${e.slice(a)}`, t = !1, o = n, n = !0, a++) : n && o && /[a-zA-Z]/.test(s) && s.toLowerCase() === s ? (e = `${e.slice(0, a - 1)}-${e.slice(a - 1)}`, o = n, n = !1, t = !0) : (t = s.toLowerCase() === s && s.toUpperCase() !== s, o = n, n = s.toUpperCase() === s && s.toLowerCase() !== s); - } return e; - };function pc(e, t) { - let n = 0;return (function e(t, o) { - if (++n > 100) return n--, t;if (Fe(t)) { - const a = t.map((t => (Pe(t) ? e(t, o) : t)));return n--, a; - } if (Pe(t)) { - let s = (r = t, i = function (e, t) { - if (!He(t)) return !1;if ((a = t) !== lc(a)) for (let n = 0;n < uc.ignoreKeyWord.length && !t.includes(uc.ignoreKeyWord[n]);n++);let a;return qe(o[t]) ? (function (e) { - return 'OPPOChannelID' === e ? e : e[0].toUpperCase() + lc(e).slice(1); - }(t)) : o[t]; - }, c = Object.create(null), Object.keys(r).forEach(((e) => { - const t = i(r[e], e);t && (c[t] = r[e]); - })), c);return s = dt(s, ((t, n) => (Fe(t) || Pe(t) ? e(t, o) : t))), n--, s; - } let r; let i; let c; - }(e, t)); - } function gc(e, t) { - if (Fe(e)) return e.map((e => (Pe(e) ? gc(e, t) : e)));if (Pe(e)) { - let n = (o = e, a = function (e, n) { - return qe(t[n]) ? lc(n) : t[n]; - }, s = {}, Object.keys(o).forEach(((e) => { - s[a(o[e], e)] = o[e]; - })), s);return n = dt(n, (e => (Fe(e) || Pe(e) ? gc(e, t) : e))); - } let o; let a; let s; - } const hc = String.fromCharCode; const _c = function (e) { - let t = 0 | e.charCodeAt(0);if (55296 <= t) if (t < 56320) { - const n = 0 | e.charCodeAt(1);if (56320 <= n && n <= 57343) { - if ((t = (t << 10) + n - 56613888 | 0) > 65535) return hc(240 | t >>> 18, 128 | t >>> 12 & 63, 128 | t >>> 6 & 63, 128 | 63 & t); - } else t = 65533; - } else t <= 57343 && (t = 65533);return t <= 2047 ? hc(192 | t >>> 6, 128 | 63 & t) : hc(224 | t >>> 12, 128 | t >>> 6 & 63, 128 | 63 & t); - }; const fc = function (e) { - for (var t = void 0 === e ? '' : (`${e}`).replace(/[\x80-\uD7ff\uDC00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]?/g, _c), n = 0 | t.length, o = new Uint8Array(n), a = 0;a < n;a = a + 1 | 0)o[a] = 0 | t.charCodeAt(a);return o; - }; const mc = function (e) { - for (var t = new Uint8Array(e), n = '', o = 0, a = t.length;o < a;) { - let s = t[o]; let r = 0; let i = 0;if (s <= 127 ? (r = 0, i = 255 & s) : s <= 223 ? (r = 1, i = 31 & s) : s <= 239 ? (r = 2, i = 15 & s) : s <= 244 && (r = 3, i = 7 & s), a - o - r > 0) for (let c = 0;c < r;)i = i << 6 | 63 & (s = t[o + c + 1]), c += 1;else i = 65533, r = a - o;n += String.fromCodePoint(i), o += r + 1; - } return n; - }; const Mc = (function () { - function e(n) { - t(this, e), this._handler = n;const o = n.getURL();this._socket = null, this._id = Je(), ee ? Q ? (ne.connectSocket({ url: o, header: { 'content-type': 'application/json' } }), ne.onSocketClose(this._onClose.bind(this)), ne.onSocketOpen(this._onOpen.bind(this)), ne.onSocketMessage(this._onMessage.bind(this)), ne.onSocketError(this._onError.bind(this))) : (this._socket = ne.connectSocket({ url: o, header: { 'content-type': 'application/json' }, complete() {} }), this._socket.onClose(this._onClose.bind(this)), this._socket.onOpen(this._onOpen.bind(this)), this._socket.onMessage(this._onMessage.bind(this)), this._socket.onError(this._onError.bind(this))) : te && (this._socket = new WebSocket(o), this._socket.binaryType = 'arraybuffer', this._socket.onopen = this._onOpen.bind(this), this._socket.onmessage = this._onMessage.bind(this), this._socket.onclose = this._onClose.bind(this), this._socket.onerror = this._onError.bind(this)); - } return o(e, [{ key: 'getID', value() { - return this._id; - } }, { key: '_onOpen', value() { - this._handler.onOpen({ id: this._id }); - } }, { key: '_onClose', value(e) { - this._handler.onClose({ id: this._id, e }); - } }, { key: '_onMessage', value(e) { - this._handler.onMessage({ data: this._handler.canIUseBinaryFrame() ? mc(e.data) : e.data }); - } }, { key: '_onError', value(e) { - this._handler.onError({ id: this._id, e }); - } }, { key: 'close', value(e) { - if (Q) return ne.offSocketClose(), ne.offSocketMessage(), ne.offSocketOpen(), ne.offSocketError(), void ne.closeSocket();this._socket && (ee ? (this._socket.onClose((() => {})), this._socket.onOpen((() => {})), this._socket.onMessage((() => {})), this._socket.onError((() => {}))) : te && (this._socket.onopen = null, this._socket.onmessage = null, this._socket.onclose = null, this._socket.onerror = null), X ? this._socket.close({ code: e }) : this._socket.close(e), this._socket = null); - } }, { key: 'send', value(e) { - Q ? ne.sendSocketMessage({ data: e.data, fail() { - e.fail && e.requestID && e.fail(e.requestID); - } }) : this._socket && (ee ? this._socket.send({ data: this._handler.canIUseBinaryFrame() ? fc(e.data).buffer : e.data, fail() { - e.fail && e.requestID && e.fail(e.requestID); - } }) : te && this._socket.send(this._handler.canIUseBinaryFrame() ? fc(e.data).buffer : e.data)); - } }]), e; - }()); const vc = 4e3; const yc = 4001; const Ic = 'connected'; const Cc = 'connecting'; const Tc = 'disconnected'; const Sc = (function () { - function e(n) { - t(this, e), this._channelModule = n, this._className = 'SocketHandler', this._promiseMap = new Map, this._readyState = Tc, this._simpleRequestMap = new Map, this.MAX_SIZE = 100, this._startSequence = Je(), this._startTs = 0, this._reConnectFlag = !1, this._nextPingTs = 0, this._reConnectCount = 0, this.MAX_RECONNECT_COUNT = 3, this._socketID = -1, this._random = 0, this._socket = null, this._url = '', this._onOpenTs = 0, this._canIUseBinaryFrame = !0, this._setWebsocketHost(), this._initConnection(); - } return o(e, [{ key: '_setWebsocketHost', value() { - const e = this._channelModule.getModule(Bt); let t = P;this._channelModule.isOversea() && (t = U), e.isSingaporeSite() ? t = F : e.isKoreaSite() ? t = q : e.isGermanySite() ? t = V : e.isIndiaSite() && (t = K), x.HOST.setCurrent(t); - } }, { key: '_initConnection', value() { - qe(x.HOST.CURRENT.BACKUP) || '' === this._url ? this._url = x.HOST.CURRENT.DEFAULT : this._url === x.HOST.CURRENT.DEFAULT ? this._url = x.HOST.CURRENT.BACKUP : this._url === x.HOST.CURRENT.BACKUP && (this._url = x.HOST.CURRENT.DEFAULT);const e = this._channelModule.getModule(Bt).getProxyServer();It(e) || (this._url = e), this._connect(), this._nextPingTs = 0; - } }, { key: 'onCheckTimer', value(e) { - e % 1 == 0 && this._checkPromiseMap(); - } }, { key: '_checkPromiseMap', value() { - const e = this;0 !== this._promiseMap.size && this._promiseMap.forEach(((t, n) => { - const o = t.reject; const a = t.timestamp;Date.now() - a >= 15e3 && (Oe.log(''.concat(e._className, '._checkPromiseMap request timeout, delete requestID:').concat(n)), e._promiseMap.delete(n), o(new ei({ code: Do.NETWORK_TIMEOUT, message: Na })), e._channelModule.onRequestTimeout(n)); - })); - } }, { key: 'onOpen', value(e) { - this._onOpenTs = Date.now();const t = e.id;this._socketID = t;const n = Date.now() - this._startTs;Oe.log(''.concat(this._className, '._onOpen cost ').concat(n, ' ms. socketID:') - .concat(t)), new Xa(rs).setMessage(n) - .setCostTime(n) - .setMoreMessage('socketID:'.concat(t)) - .end(), e.id === this._socketID && (this._readyState = Ic, this._reConnectCount = 0, this._resend(), !0 === this._reConnectFlag && (this._channelModule.onReconnected(), this._reConnectFlag = !1), this._channelModule.onOpen()); - } }, { key: 'onClose', value(e) { - const t = new Xa(is); const n = e.id; const o = e.e; const a = 'sourceSocketID:'.concat(n, ' currentSocketID:').concat(this._socketID, ' code:') - .concat(o.code, ' reason:') - .concat(o.reason); let s = 0;0 !== this._onOpenTs && (s = Date.now() - this._onOpenTs), t.setMessage(s).setCostTime(s) - .setMoreMessage(a) - .setCode(o.code) - .end(), Oe.log(''.concat(this._className, '._onClose ').concat(a, ' onlineTime:') - .concat(s)), n === this._socketID && (this._readyState = Tc, s < 1e3 ? this._channelModule.onReconnectFailed() : this._channelModule.onClose()); - } }, { key: 'onError', value(e) { - const t = e.id; const n = e.e; const o = 'sourceSocketID:'.concat(t, ' currentSocketID:').concat(this._socketID);new Xa(cs).setMessage(n.errMsg || $e(n)) - .setMoreMessage(o) - .setLevel('error') - .end(), Oe.warn(''.concat(this._className, '._onError'), n, o), t === this._socketID && (this._readyState = '', this._channelModule.onError()); - } }, { key: 'onMessage', value(e) { - let t;try { - t = JSON.parse(e.data); - } catch (u) { - new Xa(Ss).setMessage(e.data) - .end(); - } if (t && t.head) { - const n = this._getRequestIDFromHead(t.head); const o = ft(t.head); const a = gc(t.body, this._getResponseKeyMap(o));if (Oe.debug(''.concat(this._className, '.onMessage ret:').concat(JSON.stringify(a), ' requestID:') - .concat(n, ' has:') - .concat(this._promiseMap.has(n))), this._setNextPingTs(), this._promiseMap.has(n)) { - const s = this._promiseMap.get(n); const r = s.resolve; const i = s.reject; const c = s.timestamp;return this._promiseMap.delete(n), this._calcRTT(c), void (a.errorCode && 0 !== a.errorCode ? (this._channelModule.onErrorCodeNotZero(a), i(new ei({ code: a.errorCode, message: a.errorInfo || '' }))) : r($r(a))); - } this._channelModule.onMessage({ head: t.head, body: a }); - } - } }, { key: '_calcRTT', value(e) { - const t = Date.now() - e;this._channelModule.getModule(on).addRTT(t); - } }, { key: '_connect', value() { - this._startTs = Date.now(), this._onOpenTs = 0, this._socket = new Mc(this), this._socketID = this._socket.getID(), this._readyState = Cc, Oe.log(''.concat(this._className, '._connect socketID:').concat(this._socketID, ' url:') - .concat(this.getURL())), new Xa(ss).setMessage('socketID:'.concat(this._socketID, ' url:').concat(this.getURL())) - .end(); - } }, { key: 'getURL', value() { - const e = this._channelModule.getModule(Bt);return e.isDevMode() && (this._canIUseBinaryFrame = !1), (Q || $ && 'windows' === gt() || Z) && (this._canIUseBinaryFrame = !1), this._canIUseBinaryFrame ? ''.concat(this._url, '/binfo?sdkappid=').concat(e.getSDKAppID(), '&instanceid=') - .concat(e.getInstanceID(), '&random=') - .concat(this._getRandom()) : ''.concat(this._url, '/info?sdkappid=').concat(e.getSDKAppID(), '&instanceid=') - .concat(e.getInstanceID(), '&random=') - .concat(this._getRandom()); - } }, { key: '_closeConnection', value(e) { - Oe.log(''.concat(this._className, '._closeConnection')), this._socket && (this._socket.close(e), this._socketID = -1, this._socket = null, this._readyState = Tc); - } }, { key: '_resend', value() { - const e = this;if (Oe.log(''.concat(this._className, '._resend reConnectFlag:').concat(this._reConnectFlag), 'promiseMap.size:'.concat(this._promiseMap.size, ' simpleRequestMap.size:').concat(this._simpleRequestMap.size)), this._promiseMap.size > 0 && this._promiseMap.forEach(((t, n) => { - const o = t.uplinkData; const a = t.resolve; const s = t.reject;e._promiseMap.set(n, { resolve: a, reject: s, timestamp: Date.now(), uplinkData: o }), e._execute(n, o); - })), this._simpleRequestMap.size > 0) { - let t; const n = S(this._simpleRequestMap);try { - for (n.s();!(t = n.n()).done;) { - const o = m(t.value, 2); const a = o[0]; const s = o[1];this._execute(a, s); - } - } catch (r) { - n.e(r); - } finally { - n.f(); - } this._simpleRequestMap.clear(); - } - } }, { key: 'send', value(e) { - const t = this;e.head.seq = this._getSequence(), e.head.reqtime = Math.floor(Date.now() / 1e3);e.keyMap;const n = g(e, ['keyMap']); const o = this._getRequestIDFromHead(e.head); const a = JSON.stringify(n);return new Promise(((e, s) => { - (t._promiseMap.set(o, { resolve: e, reject: s, timestamp: Date.now(), uplinkData: a }), Oe.debug(''.concat(t._className, '.send uplinkData:').concat(JSON.stringify(n), ' requestID:') - .concat(o, ' readyState:') - .concat(t._readyState)), t._readyState !== Ic) ? t._reConnect() : (t._execute(o, a), t._channelModule.getModule(on).addRequestCount()); - })); - } }, { key: 'simplySend', value(e) { - e.head.seq = this._getSequence(), e.head.reqtime = Math.floor(Date.now() / 1e3);e.keyMap;const t = g(e, ['keyMap']); const n = this._getRequestIDFromHead(e.head); const o = JSON.stringify(t);this._readyState !== Ic ? (this._simpleRequestMap.size < this.MAX_SIZE ? this._simpleRequestMap.set(n, o) : Oe.log(''.concat(this._className, '.simplySend. simpleRequestMap is full, drop request!')), this._reConnect()) : this._execute(n, o); - } }, { key: '_execute', value(e, t) { - this._socket.send({ data: t, fail: ee ? this._onSendFail.bind(this) : void 0, requestID: e }); - } }, { key: '_onSendFail', value(e) { - Oe.log(''.concat(this._className, '._onSendFail requestID:').concat(e)); - } }, { key: '_getSequence', value() { - let e;if (this._startSequence < 2415919103) return e = this._startSequence, this._startSequence += 1, 2415919103 === this._startSequence && (this._startSequence = Je()), e; - } }, { key: '_getRequestIDFromHead', value(e) { - return e.servcmd + e.seq; - } }, { key: '_getResponseKeyMap', value(e) { - const t = this._channelModule.getKeyMap(e);return r(r({}, uc.response), t.response); - } }, { key: '_reConnect', value() { - this._readyState !== Ic && this._readyState !== Cc && this.forcedReconnect(); - } }, { key: 'forcedReconnect', value() { - const e = this;Oe.log(''.concat(this._className, '.forcedReconnect count:').concat(this._reConnectCount, ' readyState:') - .concat(this._readyState)), this._reConnectFlag = !0, this._resetRandom(), this._reConnectCount < this.MAX_RECONNECT_COUNT ? (this._reConnectCount += 1, this._closeConnection(yc), this._initConnection()) : (this._reConnectCount = 0, this._channelModule.probeNetwork().then(((t) => { - const n = m(t, 2); const o = n[0];n[1];o ? (Oe.warn(''.concat(e._className, '.forcedReconnect disconnected from wsserver but network is ok, continue...')), e._closeConnection(yc), e._initConnection()) : e._channelModule.onReconnectFailed(); - }))); - } }, { key: 'getReconnectFlag', value() { - return this._reConnectFlag; - } }, { key: '_setNextPingTs', value() { - this._nextPingTs = Date.now() + 1e4; - } }, { key: 'getNextPingTs', value() { - return this._nextPingTs; - } }, { key: 'isConnected', value() { - return this._readyState === Ic; - } }, { key: 'canIUseBinaryFrame', value() { - return this._canIUseBinaryFrame; - } }, { key: '_getRandom', value() { - return 0 === this._random && (this._random = Math.random()), this._random; - } }, { key: '_resetRandom', value() { - this._random = 0; - } }, { key: 'close', value() { - Oe.log(''.concat(this._className, '.close')), this._closeConnection(vc), this._promiseMap.clear(), this._startSequence = Je(), this._readyState = Tc, this._simpleRequestMap.clear(), this._reConnectFlag = !1, this._reConnectCount = 0, this._onOpenTs = 0, this._url = '', this._random = 0, this._canIUseBinaryFrame = !0; - } }]), e; - }()); const Dc = (function (e) { - i(a, e);const n = f(a);function a(e) { - let o;if (t(this, a), (o = n.call(this, e))._className = 'ChannelModule', o._socketHandler = new Sc(h(o)), o._probing = !1, o._isAppShowing = !0, o._previousState = k.NET_STATE_CONNECTED, ee && 'function' === typeof ne.onAppShow && 'function' === typeof ne.onAppHide) { - const s = o._onAppHide.bind(h(o)); const r = o._onAppShow.bind(h(o));'function' === typeof ne.offAppHide && ne.offAppHide(s), 'function' === typeof ne.offAppShow && ne.offAppShow(r), ne.onAppHide(s), ne.onAppShow(r); - } return o._timerForNotLoggedIn = -1, o._timerForNotLoggedIn = setInterval(o.onCheckTimer.bind(h(o)), 1e3), o._fatalErrorFlag = !1, o; - } return o(a, [{ key: 'onCheckTimer', value(e) { - this._socketHandler && (this.isLoggedIn() ? (this._timerForNotLoggedIn > 0 && (clearInterval(this._timerForNotLoggedIn), this._timerForNotLoggedIn = -1), this._socketHandler.onCheckTimer(e)) : this._socketHandler.onCheckTimer(1), this._checkNextPing()); - } }, { key: 'onErrorCodeNotZero', value(e) { - this.getModule(Xt).onErrorCodeNotZero(e); - } }, { key: 'onMessage', value(e) { - this.getModule(Xt).onMessage(e); - } }, { key: 'send', value(e) { - return this._socketHandler ? this._previousState !== k.NET_STATE_CONNECTED && e.head.servcmd.includes(go) ? (this.reConnect(), this._sendLogViaHTTP(e)) : this._socketHandler.send(e) : Promise.reject(); - } }, { key: '_sendLogViaHTTP', value(e) { - const t = x.HOST.CURRENT.STAT;return new Promise(((n, o) => { - const a = ''.concat(t, '/v4/imopenstat/tim_web_report_v2?sdkappid=').concat(e.head.sdkappid, '&reqtime=') - .concat(Date.now()); const s = JSON.stringify(e.body); const r = 'application/x-www-form-urlencoded;charset=UTF-8';if (ee)ne.request({ url: a, data: s, method: 'POST', timeout: 3e3, header: { 'content-type': r }, success() { - n(); - }, fail() { - o(new ei({ code: Do.NETWORK_ERROR, message: Aa })); - } });else { - const i = new XMLHttpRequest; const c = setTimeout((() => { - i.abort(), o(new ei({ code: Do.NETWORK_TIMEOUT, message: Na })); - }), 3e3);i.onreadystatechange = function () { - 4 === i.readyState && (clearTimeout(c), 200 === i.status || 304 === i.status ? n() : o(new ei({ code: Do.NETWORK_ERROR, message: Aa }))); - }, i.open('POST', a, !0), i.setRequestHeader('Content-type', r), i.send(s); - } - })); - } }, { key: 'simplySend', value(e) { - return this._socketHandler ? this._socketHandler.simplySend(e) : Promise.reject(); - } }, { key: 'onOpen', value() { - this._ping(); - } }, { key: 'onClose', value() { - this._socketHandler && (this._socketHandler.getReconnectFlag() && this._emitNetStateChangeEvent(k.NET_STATE_DISCONNECTED));this.reConnect(); - } }, { key: 'onError', value() { - ee && Oe.error(''.concat(this._className, '.onError 从v2.11.2起,SDK 支持了 WebSocket,如您未添加相关受信域名,请先添加!升级指引: https://web.sdk.qcloud.com/im/doc/zh-cn/tutorial-02-upgradeguideline.html')); - } }, { key: 'getKeyMap', value(e) { - return this.getModule(Xt).getKeyMap(e); - } }, { key: '_onAppHide', value() { - this._isAppShowing = !1; - } }, { key: '_onAppShow', value() { - this._isAppShowing = !0; - } }, { key: 'onRequestTimeout', value(e) {} }, { key: 'onReconnected', value() { - Oe.log(''.concat(this._className, '.onReconnected')), this.getModule(Xt).onReconnected(), this._emitNetStateChangeEvent(k.NET_STATE_CONNECTED); - } }, { key: 'onReconnectFailed', value() { - Oe.log(''.concat(this._className, '.onReconnectFailed')), this._emitNetStateChangeEvent(k.NET_STATE_DISCONNECTED); - } }, { key: 'reConnect', value() { - const e = arguments.length > 0 && void 0 !== arguments[0] && arguments[0]; let t = !1;this._socketHandler && (t = this._socketHandler.getReconnectFlag());const n = 'forcedFlag:'.concat(e, ' fatalErrorFlag:').concat(this._fatalErrorFlag, ' previousState:') - .concat(this._previousState, ' reconnectFlag:') - .concat(t);if (Oe.log(''.concat(this._className, '.reConnect ').concat(n)), !this._fatalErrorFlag && this._socketHandler) { - if (!0 === e) this._socketHandler.forcedReconnect();else { - if (this._previousState === k.NET_STATE_CONNECTING && t) return;this._socketHandler.forcedReconnect(); - } this._emitNetStateChangeEvent(k.NET_STATE_CONNECTING); - } - } }, { key: '_emitNetStateChangeEvent', value(e) { - this._previousState !== e && (Oe.log(''.concat(this._className, '._emitNetStateChangeEvent from ').concat(this._previousState, ' to ') - .concat(e)), this._previousState = e, this.emitOuterEvent(D.NET_STATE_CHANGE, { state: e })); - } }, { key: '_ping', value() { - const e = this;if (!0 !== this._probing) { - this._probing = !0;const t = this.getModule(Xt).getProtocolData({ protocolName: ho });this.send(t).then((() => { - e._probing = !1; - })) - .catch(((t) => { - if (Oe.warn(''.concat(e._className, '._ping failed. error:'), t), e._probing = !1, t && 60002 === t.code) return new Xa(Tr).setMessage('code:'.concat(t.code, ' message:').concat(t.message)) - .setNetworkType(e.getModule(Wt).getNetworkType()) - .end(), e._fatalErrorFlag = !0, void e._emitNetStateChangeEvent(k.NET_STATE_DISCONNECTED);e.probeNetwork().then(((t) => { - const n = m(t, 2); const o = n[0]; const a = n[1];Oe.log(''.concat(e._className, '._ping failed. probe network, isAppShowing:').concat(e._isAppShowing, ' online:') - .concat(o, ' networkType:') - .concat(a)), o ? e.reConnect() : e._emitNetStateChangeEvent(k.NET_STATE_DISCONNECTED); - })); - })); - } - } }, { key: '_checkNextPing', value() { - this._socketHandler && (this._socketHandler.isConnected() && Date.now() >= this._socketHandler.getNextPingTs() && this._ping()); - } }, { key: 'dealloc', value() { - this._socketHandler && (this._socketHandler.close(), this._socketHandler = null), this._timerForNotLoggedIn > -1 && clearInterval(this._timerForNotLoggedIn); - } }, { key: 'reset', value() { - Oe.log(''.concat(this._className, '.reset')), this._previousState = k.NET_STATE_CONNECTED, this._probing = !1, this._fatalErrorFlag = !1, this._timerForNotLoggedIn = setInterval(this.onCheckTimer.bind(this), 1e3); - } }]), a; - }(sn)); const kc = (function () { - function n(e) { - t(this, n), this._className = 'ProtocolHandler', this._sessionModule = e, this._configMap = new Map, this._fillConfigMap(); - } return o(n, [{ key: '_fillConfigMap', value() { - this._configMap.clear();const e = this._sessionModule.genCommonHead(); const t = this._sessionModule.genCosSpecifiedHead(); const n = this._sessionModule.genSSOReportHead();this._configMap.set(rn, (function (e) { - return { head: r(r({}, e), {}, { servcmd: ''.concat(x.NAME.IM_OPEN_STATUS, '.').concat(x.CMD.LOGIN) }), body: { state: 'Online' }, keyMap: { response: { TinyId: 'tinyID', InstId: 'instanceID', HelloInterval: 'helloInterval' } } }; - }(e))), this._configMap.set(cn, (function (e) { - return { head: r(r({}, e), {}, { servcmd: ''.concat(x.NAME.IM_OPEN_STATUS, '.').concat(x.CMD.LOGOUT) }), body: { type: 0 }, keyMap: { request: { type: 'wslogout_type' } } }; - }(e))), this._configMap.set(un, (function (e) { - return { head: r(r({}, e), {}, { servcmd: ''.concat(x.NAME.IM_OPEN_STATUS, '.').concat(x.CMD.HELLO) }), body: {}, keyMap: { response: { NewInstInfo: 'newInstanceInfo' } } }; - }(e))), this._configMap.set(ln, (function (e) { - return { head: r(r({}, e), {}, { servcmd: ''.concat(x.NAME.STAT_SERVICE, '.').concat(x.CMD.KICK_OTHER) }), body: {} }; - }(e))), this._configMap.set(lo, (function (e) { - return { head: r(r({}, e), {}, { servcmd: ''.concat(x.NAME.IM_COS_SIGN, '.').concat(x.CMD.COS_SIGN) }), body: { cmd: 'open_im_cos_svc', subCmd: 'get_cos_token', duration: 300, version: 2 }, keyMap: { request: { userSig: 'usersig', subCmd: 'sub_cmd', cmd: 'cmd', duration: 'duration', version: 'version' }, response: { expired_time: 'expiredTime', bucket_name: 'bucketName', session_token: 'sessionToken', tmp_secret_id: 'secretId', tmp_secret_key: 'secretKey' } } }; - }(t))), this._configMap.set(po, (function (e) { - return { head: r(r({}, e), {}, { servcmd: ''.concat(x.NAME.CUSTOM_UPLOAD, '.').concat(x.CMD.COS_PRE_SIG) }), body: { fileType: void 0, fileName: void 0, uploadMethod: 0, duration: 900 }, keyMap: { request: { userSig: 'usersig', fileType: 'file_type', fileName: 'file_name', uploadMethod: 'upload_method' }, response: { expired_time: 'expiredTime', request_id: 'requestId', head_url: 'headUrl', upload_url: 'uploadUrl', download_url: 'downloadUrl', ci_url: 'ciUrl' } } }; - }(t))), this._configMap.set(Co, (function (e) { - return { head: r(r({}, e), {}, { servcmd: ''.concat(x.NAME.IM_CONFIG_MANAGER, '.').concat(x.CMD.FETCH_COMMERCIAL_CONFIG) }), body: { SDKAppID: 0 }, keyMap: { request: { SDKAppID: 'uint32_sdkappid' }, response: { int32_error_code: 'errorCode', str_error_message: 'errorMessage', str_purchase_bits: 'purchaseBits', uint32_expired_time: 'expiredTime' } } }; - }(e))), this._configMap.set(To, (function (e) { - return { head: r(r({}, e), {}, { servcmd: ''.concat(x.NAME.IM_CONFIG_MANAGER, '.').concat(x.CMD.PUSHED_COMMERCIAL_CONFIG) }), body: {}, keyMap: { response: { int32_error_code: 'errorCode', str_error_message: 'errorMessage', str_purchase_bits: 'purchaseBits', uint32_expired_time: 'expiredTime' } } }; - }(e))), this._configMap.set(yo, (function (e) { - return { head: r(r({}, e), {}, { servcmd: ''.concat(x.NAME.IM_CONFIG_MANAGER, '.').concat(x.CMD.FETCH_CLOUD_CONTROL_CONFIG) }), body: { SDKAppID: 0, version: 0 }, keyMap: { request: { SDKAppID: 'uint32_sdkappid', version: 'uint64_version' }, response: { int32_error_code: 'errorCode', str_error_message: 'errorMessage', str_json_config: 'cloudControlConfig', uint32_expired_time: 'expiredTime', uint32_sdkappid: 'SDKAppID', uint64_version: 'version' } } }; - }(e))), this._configMap.set(Io, (function (e) { - return { head: r(r({}, e), {}, { servcmd: ''.concat(x.NAME.IM_CONFIG_MANAGER, '.').concat(x.CMD.PUSHED_CLOUD_CONTROL_CONFIG) }), body: {}, keyMap: { response: { int32_error_code: 'errorCode', str_error_message: 'errorMessage', str_json_config: 'cloudControlConfig', uint32_expired_time: 'expiredTime', uint32_sdkappid: 'SDKAppID', uint64_version: 'version' } } }; - }(e))), this._configMap.set(So, (function (e) { - return { head: r(r({}, e), {}, { servcmd: ''.concat(x.NAME.OVERLOAD_PUSH, '.').concat(x.CMD.OVERLOAD_NOTIFY) }), body: {}, keyMap: { response: { OverLoadServCmd: 'overloadCommand', DelaySecs: 'waitingTime' } } }; - }(e))), this._configMap.set(dn, (function (e) { - return { head: r(r({}, e), {}, { servcmd: ''.concat(x.NAME.OPEN_IM, '.').concat(x.CMD.GET_MESSAGES) }), body: { cookie: '', syncFlag: 0, needAbstract: 1, isOnlineSync: 0 }, keyMap: { request: { fromAccount: 'From_Account', toAccount: 'To_Account', from: 'From_Account', to: 'To_Account', time: 'MsgTimeStamp', sequence: 'MsgSeq', random: 'MsgRandom', elements: 'MsgBody' }, response: { MsgList: 'messageList', SyncFlag: 'syncFlag', To_Account: 'to', From_Account: 'from', ClientSeq: 'clientSequence', MsgSeq: 'sequence', NoticeSeq: 'noticeSequence', NotifySeq: 'notifySequence', MsgRandom: 'random', MsgTimeStamp: 'time', MsgContent: 'content', ToGroupId: 'groupID', MsgKey: 'messageKey', GroupTips: 'groupTips', MsgBody: 'elements', MsgType: 'type', C2CRemainingUnreadCount: 'C2CRemainingUnreadList', C2CPairUnreadCount: 'C2CPairUnreadList' } } }; - }(e))), this._configMap.set(pn, (function (e) { - return { head: r(r({}, e), {}, { servcmd: ''.concat(x.NAME.OPEN_IM, '.').concat(x.CMD.BIG_DATA_HALLWAY_AUTH_KEY) }), body: {} }; - }(e))), this._configMap.set(gn, (function (e) { - return { head: r(r({}, e), {}, { servcmd: ''.concat(x.NAME.OPEN_IM, '.').concat(x.CMD.SEND_MESSAGE) }), body: { fromAccount: '', toAccount: '', msgTimeStamp: void 0, msgSeq: 0, msgRandom: 0, msgBody: [], cloudCustomData: void 0, nick: '', avatar: '', msgLifeTime: void 0, offlinePushInfo: { pushFlag: 0, title: '', desc: '', ext: '', apnsInfo: { badgeMode: 0 }, androidInfo: { OPPOChannelID: '' } }, messageControlInfo: void 0 }, keyMap: { request: { fromAccount: 'From_Account', toAccount: 'To_Account', msgTimeStamp: 'MsgTimeStamp', msgSeq: 'MsgSeq', msgRandom: 'MsgRandom', msgBody: 'MsgBody', count: 'MaxCnt', lastMessageTime: 'LastMsgTime', messageKey: 'MsgKey', peerAccount: 'Peer_Account', data: 'Data', description: 'Desc', extension: 'Ext', type: 'MsgType', content: 'MsgContent', sizeType: 'Type', uuid: 'UUID', url: '', imageUrl: 'URL', fileUrl: 'Url', remoteAudioUrl: 'Url', remoteVideoUrl: 'VideoUrl', thumbUUID: 'ThumbUUID', videoUUID: 'VideoUUID', videoUrl: '', downloadFlag: 'Download_Flag', nick: 'From_AccountNick', avatar: 'From_AccountHeadurl', from: 'From_Account', time: 'MsgTimeStamp', messageRandom: 'MsgRandom', messageSequence: 'MsgSeq', elements: 'MsgBody', clientSequence: 'ClientSeq', payload: 'MsgContent', messageList: 'MsgList', messageNumber: 'MsgNum', abstractList: 'AbstractList', messageBody: 'MsgBody' } } }; - }(e))), this._configMap.set(hn, (function (e) { - return { head: r(r({}, e), {}, { servcmd: ''.concat(x.NAME.GROUP, '.').concat(x.CMD.SEND_GROUP_MESSAGE) }), body: { fromAccount: '', groupID: '', random: 0, clientSequence: 0, priority: '', msgBody: [], cloudCustomData: void 0, onlineOnlyFlag: 0, offlinePushInfo: { pushFlag: 0, title: '', desc: '', ext: '', apnsInfo: { badgeMode: 0 }, androidInfo: { OPPOChannelID: '' } }, groupAtInfo: [], messageControlInfo: void 0 }, keyMap: { request: { to: 'GroupId', extension: 'Ext', data: 'Data', description: 'Desc', random: 'Random', sequence: 'ReqMsgSeq', count: 'ReqMsgNumber', type: 'MsgType', priority: 'MsgPriority', content: 'MsgContent', elements: 'MsgBody', sizeType: 'Type', uuid: 'UUID', url: '', imageUrl: 'URL', fileUrl: 'Url', remoteAudioUrl: 'Url', remoteVideoUrl: 'VideoUrl', thumbUUID: 'ThumbUUID', videoUUID: 'VideoUUID', videoUrl: '', downloadFlag: 'Download_Flag', clientSequence: 'ClientSeq', from: 'From_Account', time: 'MsgTimeStamp', messageRandom: 'MsgRandom', messageSequence: 'MsgSeq', payload: 'MsgContent', messageList: 'MsgList', messageNumber: 'MsgNum', abstractList: 'AbstractList', messageBody: 'MsgBody' }, response: { MsgTime: 'time', MsgSeq: 'sequence' } } }; - }(e))), this._configMap.set(yn, (function (e) { - return { head: r(r({}, e), {}, { servcmd: ''.concat(x.NAME.OPEN_IM, '.').concat(x.CMD.REVOKE_C2C_MESSAGE) }), body: { msgInfo: { fromAccount: '', toAccount: '', msgTimeStamp: 0, msgSeq: 0, msgRandom: 0 } }, keyMap: { request: { msgInfo: 'MsgInfo', msgTimeStamp: 'MsgTimeStamp', msgSeq: 'MsgSeq', msgRandom: 'MsgRandom' } } }; - }(e))), this._configMap.set(Hn, (function (e) { - return { head: r(r({}, e), {}, { servcmd: ''.concat(x.NAME.GROUP, '.').concat(x.CMD.REVOKE_GROUP_MESSAGE) }), body: { to: '', msgSeqList: void 0 }, keyMap: { request: { to: 'GroupId', msgSeqList: 'MsgSeqList', msgSeq: 'MsgSeq' } } }; - }(e))), this._configMap.set(Sn, (function (e) { - return { head: r(r({}, e), {}, { servcmd: ''.concat(x.NAME.OPEN_IM, '.').concat(x.CMD.GET_C2C_ROAM_MESSAGES) }), body: { peerAccount: '', count: 15, lastMessageTime: 0, messageKey: '', withRecalledMessage: 1 }, keyMap: { request: { messageKey: 'MsgKey', peerAccount: 'Peer_Account', count: 'MaxCnt', lastMessageTime: 'LastMsgTime', withRecalledMessage: 'WithRecalledMsg' }, response: { LastMsgTime: 'lastMessageTime' } } }; - }(e))), this._configMap.set(Yn, (function (e) { - return { head: r(r({}, e), {}, { servcmd: ''.concat(x.NAME.GROUP, '.').concat(x.CMD.GET_GROUP_ROAM_MESSAGES) }), body: { withRecalledMsg: 1, groupID: '', count: 15, sequence: '' }, keyMap: { request: { sequence: 'ReqMsgSeq', count: 'ReqMsgNumber', withRecalledMessage: 'WithRecalledMsg' }, response: { Random: 'random', MsgTime: 'time', MsgSeq: 'sequence', ReqMsgSeq: 'sequence', RspMsgList: 'messageList', IsPlaceMsg: 'isPlaceMessage', IsSystemMsg: 'isSystemMessage', ToGroupId: 'to', EnumFrom_AccountType: 'fromAccountType', EnumTo_AccountType: 'toAccountType', GroupCode: 'groupCode', MsgPriority: 'priority', MsgBody: 'elements', MsgType: 'type', MsgContent: 'content', IsFinished: 'complete', Download_Flag: 'downloadFlag', ClientSeq: 'clientSequence', ThumbUUID: 'thumbUUID', VideoUUID: 'videoUUID' } } }; - }(e))), this._configMap.set(In, (function (e) { - return { head: r(r({}, e), {}, { servcmd: ''.concat(x.NAME.OPEN_IM, '.').concat(x.CMD.SET_C2C_MESSAGE_READ) }), body: { C2CMsgReaded: void 0 }, keyMap: { request: { lastMessageTime: 'LastedMsgTime' } } }; - }(e))), this._configMap.set(Cn, (function (e) { - return { head: r(r({}, e), {}, { servcmd: ''.concat(x.NAME.OPEN_IM, '.').concat(x.CMD.SET_C2C_PEER_MUTE_NOTIFICATIONS) }), body: { userIDList: void 0, muteFlag: 0 }, keyMap: { request: { userIDList: 'Peer_Account', muteFlag: 'Mute_Notifications' } } }; - }(e))), this._configMap.set(Tn, (function (e) { - return { head: r(r({}, e), {}, { servcmd: ''.concat(x.NAME.OPEN_IM, '.').concat(x.CMD.GET_C2C_PEER_MUTE_NOTIFICATIONS) }), body: { updateSequence: 0 }, keyMap: { response: { MuteNotificationsList: 'muteFlagList' } } }; - }(e))), this._configMap.set(jn, (function (e) { - return { head: r(r({}, e), {}, { servcmd: ''.concat(x.NAME.GROUP, '.').concat(x.CMD.SET_GROUP_MESSAGE_READ) }), body: { groupID: void 0, messageReadSeq: void 0 }, keyMap: { request: { messageReadSeq: 'MsgReadedSeq' } } }; - }(e))), this._configMap.set(Wn, (function (e) { - return { head: r(r({}, e), {}, { servcmd: ''.concat(x.NAME.OPEN_IM, '.').concat(x.CMD.SET_ALL_MESSAGE_READ) }), body: { readAllC2CMessage: 0, groupMessageReadInfoList: [] }, keyMap: { request: { readAllC2CMessage: 'C2CReadAllMsg', groupMessageReadInfoList: 'GroupReadInfo', messageSequence: 'MsgSeq' }, response: { C2CReadAllMsg: 'readAllC2CMessage', GroupReadInfoArray: 'groupMessageReadInfoList' } } }; - }(e))), this._configMap.set(kn, (function (e) { - return { head: r(r({}, e), {}, { servcmd: ''.concat(x.NAME.OPEN_IM, '.').concat(x.CMD.DELETE_C2C_MESSAGE) }), body: { fromAccount: '', to: '', keyList: void 0 }, keyMap: { request: { keyList: 'MsgKeyList' } } }; - }(e))), this._configMap.set(Zn, (function (e) { - return { head: r(r({}, e), {}, { servcmd: ''.concat(x.NAME.GROUP, '.').concat(x.CMD.DELETE_GROUP_MESSAGE) }), body: { groupID: '', deleter: '', keyList: void 0 }, keyMap: { request: { deleter: 'Deleter_Account', keyList: 'Seqs' } } }; - }(e))), this._configMap.set(Dn, (function (e) { - return { head: r(r({}, e), {}, { servcmd: ''.concat(x.NAME.OPEN_IM, '.').concat(x.CMD.GET_PEER_READ_TIME) }), body: { userIDList: void 0 }, keyMap: { request: { userIDList: 'To_Account' }, response: { ReadTime: 'peerReadTimeList' } } }; - }(e))), this._configMap.set(An, (function (e) { - return { head: r(r({}, e), {}, { servcmd: ''.concat(x.NAME.RECENT_CONTACT, '.').concat(x.CMD.GET_CONVERSATION_LIST) }), body: { fromAccount: void 0, count: 0 }, keyMap: { request: {}, response: { SessionItem: 'conversations', ToAccount: 'groupID', To_Account: 'userID', UnreadMsgCount: 'unreadCount', MsgGroupReadedSeq: 'messageReadSeq', C2cPeerReadTime: 'c2cPeerReadTime' } } }; - }(e))), this._configMap.set(En, (function (e) { - return { head: r(r({}, e), {}, { servcmd: ''.concat(x.NAME.RECENT_CONTACT, '.').concat(x.CMD.PAGING_GET_CONVERSATION_LIST) }), body: { fromAccount: void 0, timeStamp: void 0, startIndex: void 0, pinnedTimeStamp: void 0, pinnedStartIndex: void 0, orderType: void 0, messageAssistFlag: 4, assistFlag: 7 }, keyMap: { request: { messageAssistFlag: 'MsgAssistFlags', assistFlag: 'AssistFlags', pinnedTimeStamp: 'TopTimeStamp', pinnedStartIndex: 'TopStartIndex' }, response: { SessionItem: 'conversations', ToAccount: 'groupID', To_Account: 'userID', UnreadMsgCount: 'unreadCount', MsgGroupReadedSeq: 'messageReadSeq', C2cPeerReadTime: 'c2cPeerReadTime', LastMsgFlags: 'lastMessageFlag', TopFlags: 'isPinned', TopTimeStamp: 'pinnedTimeStamp', TopStartIndex: 'pinnedStartIndex' } } }; - }(e))), this._configMap.set(Nn, (function (e) { - return { head: r(r({}, e), {}, { servcmd: ''.concat(x.NAME.RECENT_CONTACT, '.').concat(x.CMD.DELETE_CONVERSATION) }), body: { fromAccount: '', toAccount: void 0, type: 1, toGroupID: void 0, clearHistoryMessage: 1 }, keyMap: { request: { toGroupID: 'ToGroupid', clearHistoryMessage: 'ClearRamble' } } }; - }(e))), this._configMap.set(Ln, (function (e) { - return { head: r(r({}, e), {}, { servcmd: ''.concat(x.NAME.RECENT_CONTACT, '.').concat(x.CMD.PIN_CONVERSATION) }), body: { fromAccount: '', operationType: 1, itemList: void 0 }, keyMap: { request: { itemList: 'RecentContactItem' } } }; - }(e))), this._configMap.set(Rn, (function (e) { - return { head: r(r({}, e), {}, { servcmd: ''.concat(x.NAME.OPEN_IM, '.').concat(x.CMD.DELETE_GROUP_AT_TIPS) }), body: { messageListToDelete: void 0 }, keyMap: { request: { messageListToDelete: 'DelMsgList', messageSeq: 'MsgSeq', messageRandom: 'MsgRandom' } } }; - }(e))), this._configMap.set(_n, (function (e) { - return { head: r(r({}, e), {}, { servcmd: ''.concat(x.NAME.PROFILE, '.').concat(x.CMD.PORTRAIT_GET) }), body: { fromAccount: '', userItem: [] }, keyMap: { request: { toAccount: 'To_Account', standardSequence: 'StandardSequence', customSequence: 'CustomSequence' } } }; - }(e))), this._configMap.set(fn, (function (e) { - return { head: r(r({}, e), {}, { servcmd: ''.concat(x.NAME.PROFILE, '.').concat(x.CMD.PORTRAIT_SET) }), body: { fromAccount: '', profileItem: [{ tag: Er.NICK, value: '' }, { tag: Er.GENDER, value: '' }, { tag: Er.ALLOWTYPE, value: '' }, { tag: Er.AVATAR, value: '' }] }, keyMap: { request: { toAccount: 'To_Account', standardSequence: 'StandardSequence', customSequence: 'CustomSequence' } } }; - }(e))), this._configMap.set(mn, (function (e) { - return { head: r(r({}, e), {}, { servcmd: ''.concat(x.NAME.FRIEND, '.').concat(x.CMD.GET_BLACKLIST) }), body: { fromAccount: '', startIndex: 0, maxLimited: 30, lastSequence: 0 }, keyMap: { response: { CurruentSequence: 'currentSequence' } } }; - }(e))), this._configMap.set(Mn, (function (e) { - return { head: r(r({}, e), {}, { servcmd: ''.concat(x.NAME.FRIEND, '.').concat(x.CMD.ADD_BLACKLIST) }), body: { fromAccount: '', toAccount: [] } }; - }(e))), this._configMap.set(vn, (function (e) { - return { head: r(r({}, e), {}, { servcmd: ''.concat(x.NAME.FRIEND, '.').concat(x.CMD.DELETE_BLACKLIST) }), body: { fromAccount: '', toAccount: [] } }; - }(e))), this._configMap.set(On, (function (e) { - return { head: r(r({}, e), {}, { servcmd: ''.concat(x.NAME.GROUP, '.').concat(x.CMD.GET_JOINED_GROUPS) }), body: { memberAccount: '', limit: void 0, offset: void 0, groupType: void 0, responseFilter: { groupBaseInfoFilter: void 0, selfInfoFilter: void 0 } }, keyMap: { request: { memberAccount: 'Member_Account' }, response: { GroupIdList: 'groups', MsgFlag: 'messageRemindType', NoUnreadSeqList: 'excludedUnreadSequenceList', MsgSeq: 'readedSequence' } } }; - }(e))), this._configMap.set(Gn, (function (e) { - return { head: r(r({}, e), {}, { servcmd: ''.concat(x.NAME.GROUP, '.').concat(x.CMD.GET_GROUP_INFO) }), body: { groupIDList: void 0, responseFilter: { groupBaseInfoFilter: ['Type', 'Name', 'Introduction', 'Notification', 'FaceUrl', 'Owner_Account', 'CreateTime', 'InfoSeq', 'LastInfoTime', 'LastMsgTime', 'MemberNum', 'MaxMemberNum', 'ApplyJoinOption', 'NextMsgSeq', 'ShutUpAllMember'], groupCustomFieldFilter: void 0, memberInfoFilter: void 0, memberCustomFieldFilter: void 0 } }, keyMap: { request: { groupIDList: 'GroupIdList', groupCustomField: 'AppDefinedData', memberCustomField: 'AppMemberDefinedData', groupCustomFieldFilter: 'AppDefinedDataFilter_Group', memberCustomFieldFilter: 'AppDefinedDataFilter_GroupMember' }, response: { GroupIdList: 'groups', MsgFlag: 'messageRemindType', AppDefinedData: 'groupCustomField', AppMemberDefinedData: 'memberCustomField', AppDefinedDataFilter_Group: 'groupCustomFieldFilter', AppDefinedDataFilter_GroupMember: 'memberCustomFieldFilter', InfoSeq: 'infoSequence', MemberList: 'members', GroupInfo: 'groups', ShutUpUntil: 'muteUntil', ShutUpAllMember: 'muteAllMembers', ApplyJoinOption: 'joinOption' } } }; - }(e))), this._configMap.set(wn, (function (e) { - return { head: r(r({}, e), {}, { servcmd: ''.concat(x.NAME.GROUP, '.').concat(x.CMD.CREATE_GROUP) }), body: { type: void 0, name: void 0, groupID: void 0, ownerID: void 0, introduction: void 0, notification: void 0, maxMemberNum: void 0, joinOption: void 0, memberList: void 0, groupCustomField: void 0, memberCustomField: void 0, webPushFlag: 1, avatar: 'FaceUrl' }, keyMap: { request: { ownerID: 'Owner_Account', userID: 'Member_Account', avatar: 'FaceUrl', maxMemberNum: 'MaxMemberCount', joinOption: 'ApplyJoinOption', groupCustomField: 'AppDefinedData', memberCustomField: 'AppMemberDefinedData' }, response: { HugeGroupFlag: 'avChatRoomFlag', OverJoinedGroupLimit_Account: 'overLimitUserIDList' } } }; - }(e))), this._configMap.set(bn, (function (e) { - return { head: r(r({}, e), {}, { servcmd: ''.concat(x.NAME.GROUP, '.').concat(x.CMD.DESTROY_GROUP) }), body: { groupID: void 0 } }; - }(e))), this._configMap.set(Pn, (function (e) { - return { head: r(r({}, e), {}, { servcmd: ''.concat(x.NAME.GROUP, '.').concat(x.CMD.MODIFY_GROUP_INFO) }), body: { groupID: void 0, name: void 0, introduction: void 0, notification: void 0, avatar: void 0, maxMemberNum: void 0, joinOption: void 0, groupCustomField: void 0, muteAllMembers: void 0 }, keyMap: { request: { maxMemberNum: 'MaxMemberCount', groupCustomField: 'AppDefinedData', muteAllMembers: 'ShutUpAllMember', joinOption: 'ApplyJoinOption', avatar: 'FaceUrl' }, response: { AppDefinedData: 'groupCustomField', ShutUpAllMember: 'muteAllMembers', ApplyJoinOption: 'joinOption' } } }; - }(e))), this._configMap.set(Un, (function (e) { - return { head: r(r({}, e), {}, { servcmd: ''.concat(x.NAME.GROUP, '.').concat(x.CMD.APPLY_JOIN_GROUP) }), body: { groupID: void 0, applyMessage: void 0, userDefinedField: void 0, webPushFlag: 1, historyMessageFlag: void 0 }, keyMap: { request: { applyMessage: 'ApplyMsg', historyMessageFlag: 'HugeGroupHistoryMsgFlag' }, response: { HugeGroupFlag: 'avChatRoomFlag', AVChatRoomKey: 'avChatRoomKey', RspMsgList: 'messageList', ToGroupId: 'to' } } }; - }(e))), this._configMap.set(Fn, (function (e) { - e.a2, e.tinyid;return { head: r(r({}, g(e, ['a2', 'tinyid'])), {}, { servcmd: ''.concat(x.NAME.BIG_GROUP_NO_AUTH, '.').concat(x.CMD.APPLY_JOIN_GROUP) }), body: { groupID: void 0, applyMessage: void 0, userDefinedField: void 0, webPushFlag: 1 }, keyMap: { request: { applyMessage: 'ApplyMsg' }, response: { HugeGroupFlag: 'avChatRoomFlag' } } }; - }(e))), this._configMap.set(qn, (function (e) { - return { head: r(r({}, e), {}, { servcmd: ''.concat(x.NAME.GROUP, '.').concat(x.CMD.QUIT_GROUP) }), body: { groupID: void 0 } }; - }(e))), this._configMap.set(Vn, (function (e) { - return { head: r(r({}, e), {}, { servcmd: ''.concat(x.NAME.GROUP, '.').concat(x.CMD.SEARCH_GROUP_BY_ID) }), body: { groupIDList: void 0, responseFilter: { groupBasePublicInfoFilter: ['Type', 'Name', 'Introduction', 'Notification', 'FaceUrl', 'CreateTime', 'Owner_Account', 'LastInfoTime', 'LastMsgTime', 'NextMsgSeq', 'MemberNum', 'MaxMemberNum', 'ApplyJoinOption'] } }, keyMap: { response: { ApplyJoinOption: 'joinOption' } } }; - }(e))), this._configMap.set(Kn, (function (e) { - return { head: r(r({}, e), {}, { servcmd: ''.concat(x.NAME.GROUP, '.').concat(x.CMD.CHANGE_GROUP_OWNER) }), body: { groupID: void 0, newOwnerID: void 0 }, keyMap: { request: { newOwnerID: 'NewOwner_Account' } } }; - }(e))), this._configMap.set(xn, (function (e) { - return { head: r(r({}, e), {}, { servcmd: ''.concat(x.NAME.GROUP, '.').concat(x.CMD.HANDLE_APPLY_JOIN_GROUP) }), body: { groupID: void 0, applicant: void 0, handleAction: void 0, handleMessage: void 0, authentication: void 0, messageKey: void 0, userDefinedField: void 0 }, keyMap: { request: { applicant: 'Applicant_Account', handleAction: 'HandleMsg', handleMessage: 'ApprovalMsg', messageKey: 'MsgKey' } } }; - }(e))), this._configMap.set(Bn, (function (e) { - return { head: r(r({}, e), {}, { servcmd: ''.concat(x.NAME.GROUP, '.').concat(x.CMD.HANDLE_GROUP_INVITATION) }), body: { groupID: void 0, inviter: void 0, handleAction: void 0, handleMessage: void 0, authentication: void 0, messageKey: void 0, userDefinedField: void 0 }, keyMap: { request: { inviter: 'Inviter_Account', handleAction: 'HandleMsg', handleMessage: 'ApprovalMsg', messageKey: 'MsgKey' } } }; - }(e))), this._configMap.set($n, (function (e) { - return { head: r(r({}, e), {}, { servcmd: ''.concat(x.NAME.GROUP, '.').concat(x.CMD.GET_GROUP_APPLICATION) }), body: { startTime: void 0, limit: void 0, handleAccount: void 0 }, keyMap: { request: { handleAccount: 'Handle_Account' } } }; - }(e))), this._configMap.set(zn, (function (e) { - return { head: r(r({}, e), {}, { servcmd: ''.concat(x.NAME.OPEN_IM, '.').concat(x.CMD.DELETE_GROUP_SYSTEM_MESSAGE) }), body: { messageListToDelete: void 0 }, keyMap: { request: { messageListToDelete: 'DelMsgList', messageSeq: 'MsgSeq', messageRandom: 'MsgRandom' } } }; - }(e))), this._configMap.set(Jn, (function (e) { - return { head: r(r({}, e), {}, { servcmd: ''.concat(x.NAME.BIG_GROUP_LONG_POLLING, '.').concat(x.CMD.AVCHATROOM_LONG_POLL) }), body: { USP: 1, startSeq: 1, holdTime: 90, key: void 0 }, keyMap: { request: { USP: 'USP' }, response: { ToGroupId: 'groupID' } } }; - }(e))), this._configMap.set(Xn, (function (e) { - e.a2, e.tinyid;return { head: r(r({}, g(e, ['a2', 'tinyid'])), {}, { servcmd: ''.concat(x.NAME.BIG_GROUP_LONG_POLLING_NO_AUTH, '.').concat(x.CMD.AVCHATROOM_LONG_POLL) }), body: { USP: 1, startSeq: 1, holdTime: 90, key: void 0 }, keyMap: { request: { USP: 'USP' }, response: { ToGroupId: 'groupID' } } }; - }(e))), this._configMap.set(Qn, (function (e) { - return { head: r(r({}, e), {}, { servcmd: ''.concat(x.NAME.GROUP, '.').concat(x.CMD.GET_ONLINE_MEMBER_NUM) }), body: { groupID: void 0 } }; - }(e))), this._configMap.set(eo, (function (e) { - return { head: r(r({}, e), {}, { servcmd: ''.concat(x.NAME.GROUP, '.').concat(x.CMD.SET_GROUP_ATTRIBUTES) }), body: { groupID: void 0, groupAttributeList: void 0, mainSequence: void 0, avChatRoomKey: void 0, attributeControl: ['RaceConflict'] }, keyMap: { request: { key: 'key', value: 'value' } } }; - }(e))), this._configMap.set(to, (function (e) { - return { head: r(r({}, e), {}, { servcmd: ''.concat(x.NAME.GROUP, '.').concat(x.CMD.MODIFY_GROUP_ATTRIBUTES) }), body: { groupID: void 0, groupAttributeList: void 0, mainSequence: void 0, avChatRoomKey: void 0, attributeControl: ['RaceConflict'] }, keyMap: { request: { key: 'key', value: 'value' } } }; - }(e))), this._configMap.set(no, (function (e) { - return { head: r(r({}, e), {}, { servcmd: ''.concat(x.NAME.GROUP, '.').concat(x.CMD.DELETE_GROUP_ATTRIBUTES) }), body: { groupID: void 0, groupAttributeList: void 0, mainSequence: void 0, avChatRoomKey: void 0, attributeControl: ['RaceConflict'] }, keyMap: { request: { key: 'key' } } }; - }(e))), this._configMap.set(oo, (function (e) { - return { head: r(r({}, e), {}, { servcmd: ''.concat(x.NAME.GROUP, '.').concat(x.CMD.CLEAR_GROUP_ATTRIBUTES) }), body: { groupID: void 0, mainSequence: void 0, avChatRoomKey: void 0, attributeControl: ['RaceConflict'] } }; - }(e))), this._configMap.set(ao, (function (e) { - return { head: r(r({}, e), {}, { servcmd: ''.concat(x.NAME.GROUP_ATTR, '.').concat(x.CMD.GET_GROUP_ATTRIBUTES) }), body: { groupID: void 0, avChatRoomKey: void 0, groupType: 1 }, keyMap: { request: { avChatRoomKey: 'Key', groupType: 'GroupType' } } }; - }(e))), this._configMap.set(so, (function (e) { - return { head: r(r({}, e), {}, { servcmd: ''.concat(x.NAME.GROUP, '.').concat(x.CMD.GET_GROUP_MEMBER_LIST) }), body: { groupID: void 0, limit: 0, offset: 0, memberRoleFilter: void 0, memberInfoFilter: ['Role', 'NameCard', 'ShutUpUntil', 'JoinTime'], memberCustomFieldFilter: void 0 }, keyMap: { request: { memberCustomFieldFilter: 'AppDefinedDataFilter_GroupMember' }, response: { AppMemberDefinedData: 'memberCustomField', AppDefinedDataFilter_GroupMember: 'memberCustomFieldFilter', MemberList: 'members', ShutUpUntil: 'muteUntil' } } }; - }(e))), this._configMap.set(ro, (function (e) { - return { head: r(r({}, e), {}, { servcmd: ''.concat(x.NAME.GROUP, '.').concat(x.CMD.GET_GROUP_MEMBER_INFO) }), body: { groupID: void 0, userIDList: void 0, memberInfoFilter: void 0, memberCustomFieldFilter: void 0 }, keyMap: { request: { userIDList: 'Member_List_Account', memberCustomFieldFilter: 'AppDefinedDataFilter_GroupMember' }, response: { MemberList: 'members', ShutUpUntil: 'muteUntil', AppDefinedDataFilter_GroupMember: 'memberCustomFieldFilter', AppMemberDefinedData: 'memberCustomField' } } }; - }(e))), this._configMap.set(io, (function (e) { - return { head: r(r({}, e), {}, { servcmd: ''.concat(x.NAME.GROUP, '.').concat(x.CMD.ADD_GROUP_MEMBER) }), body: { groupID: void 0, silence: void 0, userIDList: void 0 }, keyMap: { request: { userID: 'Member_Account', userIDList: 'MemberList' }, response: { MemberList: 'members' } } }; - }(e))), this._configMap.set(co, (function (e) { - return { head: r(r({}, e), {}, { servcmd: ''.concat(x.NAME.GROUP, '.').concat(x.CMD.DELETE_GROUP_MEMBER) }), body: { groupID: void 0, userIDList: void 0, reason: void 0 }, keyMap: { request: { userIDList: 'MemberToDel_Account' } } }; - }(e))), this._configMap.set(uo, (function (e) { - return { head: r(r({}, e), {}, { servcmd: ''.concat(x.NAME.GROUP, '.').concat(x.CMD.MODIFY_GROUP_MEMBER_INFO) }), body: { groupID: void 0, userID: void 0, messageRemindType: void 0, nameCard: void 0, role: void 0, memberCustomField: void 0, muteTime: void 0 }, keyMap: { request: { userID: 'Member_Account', memberCustomField: 'AppMemberDefinedData', muteTime: 'ShutUpTime', messageRemindType: 'MsgFlag' } } }; - }(e))), this._configMap.set(go, (function (e) { - return { head: r(r({}, e), {}, { servcmd: ''.concat(x.NAME.IM_OPEN_STAT, '.').concat(x.CMD.TIM_WEB_REPORT_V2) }), body: { header: {}, event: [], quality: [] }, keyMap: { request: { SDKType: 'sdk_type', SDKVersion: 'sdk_version', deviceType: 'device_type', platform: 'platform', instanceID: 'instance_id', traceID: 'trace_id', SDKAppID: 'sdk_app_id', userID: 'user_id', tinyID: 'tiny_id', extension: 'extension', timestamp: 'timestamp', networkType: 'network_type', eventType: 'event_type', code: 'error_code', message: 'error_message', moreMessage: 'more_message', duplicate: 'duplicate', costTime: 'cost_time', level: 'level', qualityType: 'quality_type', reportIndex: 'report_index', wholePeriod: 'whole_period', totalCount: 'total_count', rttCount: 'success_count_business', successRateOfRequest: 'percent_business', countLessThan1Second: 'success_count_business', percentOfCountLessThan1Second: 'percent_business', countLessThan3Second: 'success_count_platform', percentOfCountLessThan3Second: 'percent_platform', successCountOfBusiness: 'success_count_business', successRateOfBusiness: 'percent_business', successCountOfPlatform: 'success_count_platform', successRateOfPlatform: 'percent_platform', successCountOfMessageReceived: 'success_count_business', successRateOfMessageReceived: 'percent_business', avgRTT: 'average_value', avgDelay: 'average_value', avgValue: 'average_value' } } }; - }(n))), this._configMap.set(ho, (function (e) { - return { head: r(r({}, e), {}, { servcmd: ''.concat(x.NAME.HEARTBEAT, '.').concat(x.CMD.ALIVE) }), body: {} }; - }(e))), this._configMap.set(_o, (function (e) { - return { head: r(r({}, e), {}, { servcmd: ''.concat(x.NAME.IM_OPEN_PUSH, '.').concat(x.CMD.MESSAGE_PUSH) }), body: {}, keyMap: { response: { C2cMsgArray: 'C2CMessageArray', GroupMsgArray: 'groupMessageArray', GroupTips: 'groupTips', C2cNotifyMsgArray: 'C2CNotifyMessageArray', ClientSeq: 'clientSequence', MsgPriority: 'priority', NoticeSeq: 'noticeSequence', MsgContent: 'content', MsgType: 'type', MsgBody: 'elements', ToGroupId: 'to', Desc: 'description', Ext: 'extension', IsSyncMsg: 'isSyncMessage', Flag: 'needSync', NeedAck: 'needAck', PendencyAdd_Account: 'userID', ProfileImNick: 'nick', PendencyType: 'applicationType', C2CReadAllMsg: 'readAllC2CMessage' } } }; - }(e))), this._configMap.set(fo, (function (e) { - return { head: r(r({}, e), {}, { servcmd: ''.concat(x.NAME.OPEN_IM, '.').concat(x.CMD.MESSAGE_PUSH_ACK) }), body: { sessionData: void 0 }, keyMap: { request: { sessionData: 'SessionData' } } }; - }(e))), this._configMap.set(mo, (function (e) { - return { head: r(r({}, e), {}, { servcmd: ''.concat(x.NAME.IM_OPEN_STATUS, '.').concat(x.CMD.STATUS_FORCEOFFLINE) }), body: {}, keyMap: { response: { C2cNotifyMsgArray: 'C2CNotifyMessageArray', NoticeSeq: 'noticeSequence', KickoutMsgNotify: 'kickoutMsgNotify', NewInstInfo: 'newInstanceInfo' } } }; - }(e))), this._configMap.set(vo, (function (e) { - return { head: r(r({}, e), {}, { servcmd: ''.concat(x.NAME.IM_LONG_MESSAGE, '.').concat(x.CMD.DOWNLOAD_MERGER_MESSAGE) }), body: { downloadKey: '' }, keyMap: { response: { Data: 'data', Desc: 'description', Ext: 'extension', Download_Flag: 'downloadFlag', ThumbUUID: 'thumbUUID', VideoUUID: 'videoUUID' } } }; - }(e))), this._configMap.set(Mo, (function (e) { - return { head: r(r({}, e), {}, { servcmd: ''.concat(x.NAME.IM_LONG_MESSAGE, '.').concat(x.CMD.UPLOAD_MERGER_MESSAGE) }), body: { messageList: [] }, keyMap: { request: { fromAccount: 'From_Account', toAccount: 'To_Account', msgTimeStamp: 'MsgTimeStamp', msgSeq: 'MsgSeq', msgRandom: 'MsgRandom', msgBody: 'MsgBody', type: 'MsgType', content: 'MsgContent', data: 'Data', description: 'Desc', extension: 'Ext', sizeType: 'Type', uuid: 'UUID', url: '', imageUrl: 'URL', fileUrl: 'Url', remoteAudioUrl: 'Url', remoteVideoUrl: 'VideoUrl', thumbUUID: 'ThumbUUID', videoUUID: 'VideoUUID', videoUrl: '', downloadFlag: 'Download_Flag', from: 'From_Account', time: 'MsgTimeStamp', messageRandom: 'MsgRandom', messageSequence: 'MsgSeq', elements: 'MsgBody', clientSequence: 'ClientSeq', payload: 'MsgContent', messageList: 'MsgList', messageNumber: 'MsgNum', abstractList: 'AbstractList', messageBody: 'MsgBody' } } }; - }(e))); - } }, { key: 'has', value(e) { - return this._configMap.has(e); - } }, { key: 'get', value(e) { - return this._configMap.get(e); - } }, { key: 'update', value() { - this._fillConfigMap(); - } }, { key: 'getKeyMap', value(e) { - return this.has(e) ? this.get(e).keyMap || {} : (Oe.warn(''.concat(this._className, '.getKeyMap unknown protocolName:').concat(e)), {}); - } }, { key: 'getProtocolData', value(e) { - const t = e.protocolName; const n = e.requestData; const o = this.get(t); let a = null;if (n) { - const s = this._simpleDeepCopy(o); const r = s.body; const i = Object.create(null);for (const c in r) if (Object.prototype.hasOwnProperty.call(r, c)) { - if (i[c] = r[c], void 0 === n[c]) continue;i[c] = n[c]; - }s.body = i, a = this._getUplinkData(s); - } else a = this._getUplinkData(o);return a; - } }, { key: '_getUplinkData', value(e) { - const t = this._requestDataCleaner(e); const n = ft(t.head); const o = pc(t.body, this._getRequestKeyMap(n));return t.body = o, t; - } }, { key: '_getRequestKeyMap', value(e) { - const t = this.getKeyMap(e);return r(r({}, uc.request), t.request); - } }, { key: '_requestDataCleaner', value(t) { - const n = Array.isArray(t) ? [] : Object.create(null);for (const o in t)Object.prototype.hasOwnProperty.call(t, o) && He(o) && null !== t[o] && void 0 !== t[o] && ('object' !== e(t[o]) ? n[o] = t[o] : n[o] = this._requestDataCleaner.bind(this)(t[o]));return n; - } }, { key: '_simpleDeepCopy', value(e) { - for (var t, n = Object.keys(e), o = {}, a = 0, s = n.length;a < s;a++)t = n[a], Fe(e[t]) ? o[t] = Array.from(e[t]) : Pe(e[t]) ? o[t] = this._simpleDeepCopy(e[t]) : o[t] = e[t];return o; - } }]), n; - }()); const Ec = [fo]; const Ac = (function () { - function e(n) { - t(this, e), this._sessionModule = n, this._className = 'DownlinkHandler', this._eventHandlerMap = new Map, this._eventHandlerMap.set('C2CMessageArray', this._c2cMessageArrayHandler.bind(this)), this._eventHandlerMap.set('groupMessageArray', this._groupMessageArrayHandler.bind(this)), this._eventHandlerMap.set('groupTips', this._groupTipsHandler.bind(this)), this._eventHandlerMap.set('C2CNotifyMessageArray', this._C2CNotifyMessageArrayHandler.bind(this)), this._eventHandlerMap.set('profileModify', this._profileHandler.bind(this)), this._eventHandlerMap.set('friendListMod', this._relationChainHandler.bind(this)), this._eventHandlerMap.set('recentContactMod', this._recentContactHandler.bind(this)), this._eventHandlerMap.set('readAllC2CMessage', this._allMessageReadHandler.bind(this)), this._keys = M(this._eventHandlerMap.keys()); - } return o(e, [{ key: '_c2cMessageArrayHandler', value(e) { - const t = this._sessionModule.getModule(Ft);if (t) { - if (e.dataList.forEach(((e) => { - if (1 === e.isSyncMessage) { - const t = e.from;e.from = e.to, e.to = t; - } - })), 1 === e.needSync) this._sessionModule.getModule(Jt).startOnlineSync();t.onNewC2CMessage({ dataList: e.dataList, isInstantMessage: !0 }); - } - } }, { key: '_groupMessageArrayHandler', value(e) { - const t = this._sessionModule.getModule(qt);t && t.onNewGroupMessage({ event: e.event, dataList: e.dataList, isInstantMessage: !0 }); - } }, { key: '_groupTipsHandler', value(e) { - const t = this._sessionModule.getModule(qt);if (t) { - const n = e.event; const o = e.dataList; const a = e.isInstantMessage; const s = void 0 === a || a; const r = e.isSyncingEnded;switch (n) { - case 4:case 6:t.onNewGroupTips({ event: n, dataList: o });break;case 5:o.forEach(((e) => { - Fe(e.elements.revokedInfos) ? t.onGroupMessageRevoked({ dataList: o }) : Fe(e.elements.groupMessageReadNotice) ? t.onGroupMessageReadNotice({ dataList: o }) : t.onNewGroupSystemNotice({ dataList: o, isInstantMessage: s, isSyncingEnded: r }); - }));break;case 12:this._sessionModule.getModule(xt).onNewGroupAtTips({ dataList: o });break;default:Oe.log(''.concat(this._className, '._groupTipsHandler unknown event:').concat(n, ' dataList:'), o); - } - } - } }, { key: '_C2CNotifyMessageArrayHandler', value(e) { - const t = this; const n = e.dataList;if (Fe(n)) { - const o = this._sessionModule.getModule(Ft);n.forEach(((e) => { - if (Ue(e)) if (e.hasOwnProperty('kickoutMsgNotify')) { - const a = e.kickoutMsgNotify; const s = a.kickType; const r = a.newInstanceInfo; const i = void 0 === r ? {} : r;1 === s ? t._sessionModule.onMultipleAccountKickedOut(i) : 2 === s && t._sessionModule.onMultipleDeviceKickedOut(i); - } else if (e.hasOwnProperty('c2cMessageRevokedNotify'))o && o.onC2CMessageRevoked({ dataList: n });else if (e.hasOwnProperty('c2cMessageReadReceipt'))o && o.onC2CMessageReadReceipt({ dataList: n });else if (e.hasOwnProperty('c2cMessageReadNotice'))o && o.onC2CMessageReadNotice({ dataList: n });else if (e.hasOwnProperty('muteNotificationsSync')) { - t._sessionModule.getModule(xt).onC2CMessageRemindTypeSynced({ dataList: n }); - } - })); - } - } }, { key: '_profileHandler', value(e) { - this._sessionModule.getModule(Ut).onProfileModified({ dataList: e.dataList });const t = this._sessionModule.getModule(Vt);t && t.onFriendProfileModified({ dataList: e.dataList }); - } }, { key: '_relationChainHandler', value(e) { - this._sessionModule.getModule(Ut).onRelationChainModified({ dataList: e.dataList });const t = this._sessionModule.getModule(Vt);t && t.onRelationChainModified({ dataList: e.dataList }); - } }, { key: '_recentContactHandler', value(e) { - const t = e.dataList;if (Fe(t)) { - const n = this._sessionModule.getModule(xt);n && t.forEach(((e) => { - const t = e.pushType; const o = e.recentContactTopItem; const a = e.recentContactDeleteItem;1 === t ? n.onConversationDeleted(a.recentContactList) : 2 === t ? n.onConversationPinned(o.recentContactList) : 3 === t && n.onConversationUnpinned(o.recentContactList); - })); - } - } }, { key: '_allMessageReadHandler', value(e) { - const t = e.dataList; const n = this._sessionModule.getModule(xt);n && n.onPushedAllMessageRead(t); - } }, { key: 'onMessage', value(e) { - const t = this; const n = e.body;if (this._filterMessageFromIMOpenPush(e)) { - const o = n.eventArray; const a = n.isInstantMessage; const s = n.isSyncingEnded; const r = n.needSync;if (Fe(o)) for (let i = null, c = null, u = 0, l = 0, d = o.length;l < d;l++) { - u = (i = o[l]).event;const p = Object.keys(i).find((e => -1 !== t._keys.indexOf(e)));p ? (c = 14 !== u ? i[p] : { readAllC2CMessage: i[p], groupMessageReadInfoList: i.groupMessageReadNotice || [] }, this._eventHandlerMap.get(p)({ event: u, dataList: c, isInstantMessage: a, isSyncingEnded: s, needSync: r })) : Oe.log(''.concat(this._className, '.onMessage unknown eventItem:').concat(i)); - } - } - } }, { key: '_filterMessageFromIMOpenPush', value(e) { - const t = e.head; const n = e.body; const o = t.servcmd; let a = !1;if (qe(o) || (a = o.includes(x.NAME.IM_CONFIG_MANAGER) || o.includes(x.NAME.OVERLOAD_PUSH) || o.includes(x.NAME.STAT_SERVICE)), !a) return !0;if (o.includes(x.CMD.PUSHED_CLOUD_CONTROL_CONFIG)) this._sessionModule.getModule(en).onPushedCloudControlConfig(n);else if (o.includes(x.CMD.PUSHED_COMMERCIAL_CONFIG)) { - this._sessionModule.getModule(an).onPushedConfig(n); - } else if (o.includes(x.CMD.OVERLOAD_NOTIFY)) this._sessionModule.onPushedServerOverload(n);else if (o.includes(x.CMD.KICK_OTHER)) { - const s = Date.now();this._sessionModule.reLoginOnKickOther();const r = new Xa(as); const i = this._sessionModule.getModule(bt).getLastWsHelloTs(); const c = s - i;r.setMessage('last wshello time:'.concat(i, ' diff:').concat(c, 'ms')).setNetworkType(this._sessionModule.getNetworkType()) - .end(); - } return !1; - } }]), e; - }()); const Nc = [{ cmd: x.CMD.GET_GROUP_INFO, interval: 1, count: 20 }, { cmd: x.CMD.SET_GROUP_ATTRIBUTES, interval: 5, count: 10 }, { cmd: x.CMD.MODIFY_GROUP_ATTRIBUTES, interval: 5, count: 10 }, { cmd: x.CMD.DELETE_GROUP_ATTRIBUTES, interval: 5, count: 10 }, { cmd: x.CMD.CLEAR_GROUP_ATTRIBUTES, interval: 5, count: 10 }, { cmd: x.CMD.GET_GROUP_ATTRIBUTES, interval: 5, count: 20 }, { cmd: x.CMD.SET_ALL_MESSAGE_READ, interval: 1, count: 1 }]; const Lc = (function (e) { - i(a, e);const n = f(a);function a(e) { - let o;return t(this, a), (o = n.call(this, e))._className = 'SessionModule', o._platform = o.getPlatform(), o._protocolHandler = new kc(h(o)), o._messageDispatcher = new Ac(h(o)), o._commandFrequencyLimitMap = new Map, o._commandRequestInfoMap = new Map, o._serverOverloadInfoMap = new Map, o._init(), o.getInnerEmitterInstance().on(ci, o._onCloudConfigUpdated, h(o)), o; - } return o(a, [{ key: '_init', value() { - this._updateCommandFrequencyLimitMap(Nc); - } }, { key: '_onCloudConfigUpdated', value() { - let e = this.getCloudConfig('cmd_frequency_limit');qe(e) || (e = JSON.parse(e), this._updateCommandFrequencyLimitMap(e)); - } }, { key: '_updateCommandFrequencyLimitMap', value(e) { - const t = this;e.forEach(((e) => { - t._commandFrequencyLimitMap.set(e.cmd, { interval: e.interval, count: e.count }); - })); - } }, { key: 'updateProtocolConfig', value() { - this._protocolHandler.update(); - } }, { key: 'request', value(e) { - Oe.debug(''.concat(this._className, '.request options:'), e);const t = e.protocolName; const n = e.tjgID;if (!this._protocolHandler.has(t)) return Oe.warn(''.concat(this._className, '.request unknown protocol:').concat(t)), ai({ code: Do.CANNOT_FIND_PROTOCOL, message: Oa });const o = this.getProtocolData(e); const a = o.head.servcmd;if (this._isFrequencyOverLimit(a)) return ai({ code: Do.OVER_FREQUENCY_LIMIT, message: ba });if (this._isServerOverload(a)) return ai({ code: Do.OPEN_SERVICE_OVERLOAD_ERROR, message: Pa });It(n) || (o.head.tjgID = n);const s = this.getModule(Qt);return Ec.includes(t) ? s.simplySend(o) : s.send(o); - } }, { key: 'getKeyMap', value(e) { - return this._protocolHandler.getKeyMap(e); - } }, { key: 'genCommonHead', value() { - const e = this.getModule(Bt);return { ver: 'v4', platform: this._platform, websdkappid: b, websdkversion: w, a2: e.getA2Key() || void 0, tinyid: e.getTinyID() || void 0, status_instid: e.getStatusInstanceID(), sdkappid: e.getSDKAppID(), contenttype: e.getContentType(), reqtime: 0, identifier: e.getA2Key() ? void 0 : e.getUserID(), usersig: e.getA2Key() ? void 0 : e.getUserSig(), sdkability: 35, tjgID: '' }; - } }, { key: 'genCosSpecifiedHead', value() { - const e = this.getModule(Bt);return { ver: 'v4', platform: this._platform, websdkappid: b, websdkversion: w, sdkappid: e.getSDKAppID(), contenttype: e.getContentType(), reqtime: 0, identifier: e.getUserID(), usersig: e.getUserSig(), status_instid: e.getStatusInstanceID(), sdkability: 35 }; - } }, { key: 'genSSOReportHead', value() { - const e = this.getModule(Bt);return { ver: 'v4', platform: this._platform, websdkappid: b, websdkversion: w, sdkappid: e.getSDKAppID(), contenttype: '', reqtime: 0, identifier: '', usersig: '', status_instid: e.getStatusInstanceID(), sdkability: 35 }; - } }, { key: 'getProtocolData', value(e) { - return this._protocolHandler.getProtocolData(e); - } }, { key: 'onErrorCodeNotZero', value(e) { - const t = e.errorCode;if (t === Do.HELLO_ANSWER_KICKED_OUT) { - const n = e.kickType; const o = e.newInstanceInfo; const a = void 0 === o ? {} : o;1 === n ? this.onMultipleAccountKickedOut(a) : 2 === n && this.onMultipleDeviceKickedOut(a); - }t !== Do.MESSAGE_A2KEY_EXPIRED && t !== Do.ACCOUNT_A2KEY_EXPIRED || (this._onUserSigExpired(), this.getModule(Qt).reConnect()); - } }, { key: 'onMessage', value(e) { - const t = e.body; const n = t.needAck; const o = void 0 === n ? 0 : n; const a = t.sessionData;1 === o && this._sendACK(a), this._messageDispatcher.onMessage(e); - } }, { key: 'onReconnected', value() { - this._reLoginOnReconnected(); - } }, { key: 'reLoginOnKickOther', value() { - Oe.log(''.concat(this._className, '.reLoginOnKickOther.')), this._reLogin(); - } }, { key: '_reLoginOnReconnected', value() { - Oe.log(''.concat(this._className, '._reLoginOnReconnected.')), this._reLogin(); - } }, { key: '_reLogin', value() { - const e = this;this.isLoggedIn() && this.request({ protocolName: rn }).then(((t) => { - const n = t.data.instanceID;e.getModule(Bt).setStatusInstanceID(n), Oe.log(''.concat(e._className, '._reLogin ok. start to sync unread messages.')), e.getModule(Jt).startSyncOnReconnected(), e.getModule(nn).startPull(), e.getModule(qt).updateLocalMainSequenceOnReconnected(); - })); - } }, { key: 'onMultipleAccountKickedOut', value(e) { - this.getModule(bt).onMultipleAccountKickedOut(e); - } }, { key: 'onMultipleDeviceKickedOut', value(e) { - this.getModule(bt).onMultipleDeviceKickedOut(e); - } }, { key: '_onUserSigExpired', value() { - this.getModule(bt).onUserSigExpired(); - } }, { key: '_sendACK', value(e) { - this.request({ protocolName: fo, requestData: { sessionData: e } }); - } }, { key: '_isFrequencyOverLimit', value(e) { - const t = e.split('.')[1];if (!this._commandFrequencyLimitMap.has(t)) return !1;if (!this._commandRequestInfoMap.has(t)) return this._commandRequestInfoMap.set(t, { startTime: Date.now(), requestCount: 1 }), !1;const n = this._commandFrequencyLimitMap.get(t); const o = n.count; const a = n.interval; const s = this._commandRequestInfoMap.get(t); const r = s.startTime; let i = s.requestCount;if (Date.now() - r > 1e3 * a) return this._commandRequestInfoMap.set(t, { startTime: Date.now(), requestCount: 1 }), !1;i += 1, this._commandRequestInfoMap.set(t, { startTime: r, requestCount: i });let c = !1;return i > o && (c = !0), c; - } }, { key: '_isServerOverload', value(e) { - if (!this._serverOverloadInfoMap.has(e)) return !1;const t = this._serverOverloadInfoMap.get(e); const n = t.overloadTime; const o = t.waitingTime; let a = !1;return Date.now() - n <= 1e3 * o ? a = !0 : (this._serverOverloadInfoMap.delete(e), a = !1), a; - } }, { key: 'onPushedServerOverload', value(e) { - const t = e.overloadCommand; const n = e.waitingTime;this._serverOverloadInfoMap.set(t, { overloadTime: Date.now(), waitingTime: n }), Oe.warn(''.concat(this._className, '.onPushedServerOverload waitingTime:').concat(n, 's')); - } }, { key: 'reset', value() { - Oe.log(''.concat(this._className, '.reset')), this._updateCommandFrequencyLimitMap(Nc), this._commandRequestInfoMap.clear(), this._serverOverloadInfoMap.clear(); - } }]), a; - }(sn)); const Rc = (function (e) { - i(a, e);const n = f(a);function a(e) { - let o;return t(this, a), (o = n.call(this, e))._className = 'MessageLossDetectionModule', o._maybeLostSequencesMap = new Map, o; - } return o(a, [{ key: 'onMessageMaybeLost', value(e, t, n) { - this._maybeLostSequencesMap.has(e) || this._maybeLostSequencesMap.set(e, []);for (var o = this._maybeLostSequencesMap.get(e), a = 0;a < n;a++)o.push(t + a);Oe.debug(''.concat(this._className, '.onMessageMaybeLost. maybeLostSequences:').concat(o)); - } }, { key: 'detectMessageLoss', value(e, t) { - const n = this._maybeLostSequencesMap.get(e);if (!It(n) && !It(t)) { - const o = t.filter((e => -1 !== n.indexOf(e)));if (Oe.debug(''.concat(this._className, '.detectMessageLoss. matchedSequences:').concat(o)), n.length === o.length)Oe.info(''.concat(this._className, '.detectMessageLoss no message loss. conversationID:').concat(e));else { - let a; const s = n.filter((e => -1 === o.indexOf(e))); const r = s.length;r <= 5 ? a = `${e}-${s.join('-')}` : (s.sort(((e, t) => e - t)), a = `${e} start:${s[0]} end:${s[r - 1]} count:${r}`), new Xa(dr).setMessage(a) - .setNetworkType(this.getNetworkType()) - .setLevel('warning') - .end(), Oe.warn(''.concat(this._className, '.detectMessageLoss message loss detected. conversationID:').concat(e, ' lostSequences:') - .concat(s)); - }n.length = 0; - } - } }, { key: 'reset', value() { - Oe.log(''.concat(this._className, '.reset')), this._maybeLostSequencesMap.clear(); - } }]), a; - }(sn)); const Oc = (function (e) { - i(a, e);const n = f(a);function a(e) { - let o;return t(this, a), (o = n.call(this, e))._className = 'CloudControlModule', o._cloudConfig = new Map, o._expiredTime = 0, o._version = 0, o._isFetching = !1, o; - } return o(a, [{ key: 'getCloudConfig', value(e) { - return qe(e) ? this._cloudConfig : this._cloudConfig.has(e) ? this._cloudConfig.get(e) : void 0; - } }, { key: '_canFetchConfig', value() { - return this.isLoggedIn() && !this._isFetching && Date.now() >= this._expiredTime; - } }, { key: 'fetchConfig', value() { - const e = this; const t = this._canFetchConfig();if (Oe.log(''.concat(this._className, '.fetchConfig canFetchConfig:').concat(t)), t) { - const n = new Xa(vr); const o = this.getModule(Bt).getSDKAppID();this._isFetching = !0, this.request({ protocolName: yo, requestData: { SDKAppID: o, version: this._version } }).then(((t) => { - e._isFetching = !1, n.setMessage('version:'.concat(e._version, ' newVersion:').concat(t.data.version, ' config:') - .concat(t.data.cloudControlConfig)).setNetworkType(e.getNetworkType()) - .end(), Oe.log(''.concat(e._className, '.fetchConfig ok')), e._parseCloudControlConfig(t.data); - })) - .catch(((t) => { - e._isFetching = !1, e.probeNetwork().then(((e) => { - const o = m(e, 2); const a = o[0]; const s = o[1];n.setError(t, a, s).end(); - })), Oe.log(''.concat(e._className, '.fetchConfig failed. error:'), t), e._setExpiredTimeOnResponseError(12e4); - })); - } - } }, { key: 'onPushedCloudControlConfig', value(e) { - Oe.log(''.concat(this._className, '.onPushedCloudControlConfig')), new Xa(yr).setNetworkType(this.getNetworkType()) - .setMessage('newVersion:'.concat(e.version, ' config:').concat(e.cloudControlConfig)) - .end(), this._parseCloudControlConfig(e); - } }, { key: 'onCheckTimer', value(e) { - this._canFetchConfig() && this.fetchConfig(); - } }, { key: '_parseCloudControlConfig', value(e) { - const t = this; const n = ''.concat(this._className, '._parseCloudControlConfig'); const o = e.errorCode; const a = e.errorMessage; const s = e.cloudControlConfig; const r = e.version; const i = e.expiredTime;if (0 === o) { - if (this._version !== r) { - let c = null;try { - c = JSON.parse(s); - } catch (u) { - Oe.error(''.concat(n, ' JSON parse error:').concat(s)); - }c && (this._cloudConfig.clear(), Object.keys(c).forEach(((e) => { - t._cloudConfig.set(e, c[e]); - })), this._version = r, this.emitInnerEvent(ci)); - } this._expiredTime = Date.now() + 1e3 * i; - } else qe(o) ? (Oe.log(''.concat(n, ' failed. Invalid message format:'), e), this._setExpiredTimeOnResponseError(36e5)) : (Oe.error(''.concat(n, ' errorCode:').concat(o, ' errorMessage:') - .concat(a)), this._setExpiredTimeOnResponseError(12e4)); - } }, { key: '_setExpiredTimeOnResponseError', value(e) { - this._expiredTime = Date.now() + e; - } }, { key: 'reset', value() { - Oe.log(''.concat(this._className, '.reset')), this._cloudConfig.clear(), this._expiredTime = 0, this._version = 0, this._isFetching = !1; - } }]), a; - }(sn)); const Gc = (function (e) { - i(a, e);const n = f(a);function a(e) { - let o;return t(this, a), (o = n.call(this, e))._className = 'PullGroupMessageModule', o._remoteLastMessageSequenceMap = new Map, o.PULL_LIMIT_COUNT = 15, o; - } return o(a, [{ key: 'startPull', value() { - const e = this; const t = this._getNeedPullConversationList();this._getRemoteLastMessageSequenceList().then((() => { - const n = e.getModule(xt);t.forEach(((t) => { - const o = t.conversationID; const a = o.replace(k.CONV_GROUP, ''); const s = n.getGroupLocalLastMessageSequence(o); const r = e._remoteLastMessageSequenceMap.get(a) || 0; const i = r - s;Oe.log(''.concat(e._className, '.startPull groupID:').concat(a, ' localLastMessageSequence:') - .concat(s, ' ') + 'remoteLastMessageSequence:'.concat(r, ' diff:').concat(i)), s > 0 && i >= 1 && i < 300 && e._pullMissingMessage({ groupID: a, localLastMessageSequence: s, remoteLastMessageSequence: r, diff: i }); - })); - })); - } }, { key: '_getNeedPullConversationList', value() { - return this.getModule(xt).getLocalConversationList() - .filter((e => e.type === k.CONV_GROUP && e.groupProfile.type !== k.GRP_AVCHATROOM)); - } }, { key: '_getRemoteLastMessageSequenceList', value() { - const e = this;return this.getModule(qt).getGroupList() - .then(((t) => { - for (let n = t.data.groupList, o = void 0 === n ? [] : n, a = 0;a < o.length;a++) { - const s = o[a]; const r = s.groupID; const i = s.nextMessageSeq;if (s.type !== k.GRP_AVCHATROOM) { - const c = i - 1;e._remoteLastMessageSequenceMap.set(r, c); - } - } - })); - } }, { key: '_pullMissingMessage', value(e) { - const t = this; const n = e.localLastMessageSequence; const o = e.remoteLastMessageSequence; const a = e.diff;e.count = a > this.PULL_LIMIT_COUNT ? this.PULL_LIMIT_COUNT : a, e.sequence = a > this.PULL_LIMIT_COUNT ? n + this.PULL_LIMIT_COUNT : n + a, this._getGroupMissingMessage(e).then(((s) => { - s.length > 0 && (s[0].sequence + 1 <= o && (e.localLastMessageSequence = n + t.PULL_LIMIT_COUNT, e.diff = a - t.PULL_LIMIT_COUNT, t._pullMissingMessage(e)), t.getModule(qt).onNewGroupMessage({ dataList: s, isInstantMessage: !1 })); - })); - } }, { key: '_getGroupMissingMessage', value(e) { - const t = this; const n = new Xa(Ys);return this.request({ protocolName: Yn, requestData: { groupID: e.groupID, count: e.count, sequence: e.sequence } }).then(((o) => { - const a = o.data.messageList; const s = void 0 === a ? [] : a;return n.setNetworkType(t.getNetworkType()).setMessage('groupID:'.concat(e.groupID, ' count:').concat(e.count, ' sequence:') - .concat(e.sequence, ' messageList length:') - .concat(s.length)) - .end(), s; - })) - .catch(((e) => { - t.probeNetwork().then(((t) => { - const o = m(t, 2); const a = o[0]; const s = o[1];n.setError(e, a, s).end(); - })); - })); - } }, { key: 'reset', value() { - Oe.log(''.concat(this._className, '.reset')), this._remoteLastMessageSequenceMap.clear(); - } }]), a; - }(sn)); const wc = (function () { - function e() { - t(this, e), this._className = 'AvgE2EDelay', this._e2eDelayArray = []; - } return o(e, [{ key: 'addMessageDelay', value(e) { - const t = mt(e.currentTime / 1e3 - e.time, 2);this._e2eDelayArray.push(t); - } }, { key: '_calcAvg', value(e, t) { - if (0 === t) return 0;let n = 0;return e.forEach(((e) => { - n += e; - })), mt(n / t, 1); - } }, { key: '_calcTotalCount', value() { - return this._e2eDelayArray.length; - } }, { key: '_calcCountWithLimit', value(e) { - const t = e.e2eDelayArray; const n = e.min; const o = e.max;return t.filter((e => n < e && e <= o)).length; - } }, { key: '_calcPercent', value(e, t) { - let n = mt(e / t * 100, 2);return n > 100 && (n = 100), n; - } }, { key: '_checkE2EDelayException', value(e, t) { - const n = e.filter((e => e > t));if (n.length > 0) { - const o = n.length; const a = Math.min.apply(Math, M(n)); const s = Math.max.apply(Math, M(n)); const r = this._calcAvg(n, o); const i = mt(o / e.length * 100, 2);new Xa(Ds).setMessage('message e2e delay exception. count:'.concat(o, ' min:').concat(a, ' max:') - .concat(s, ' avg:') - .concat(r, ' percent:') - .concat(i)) - .setLevel('warning') - .end(); - } - } }, { key: 'getStatResult', value() { - const e = this._calcTotalCount();if (0 === e) return null;const t = M(this._e2eDelayArray); const n = this._calcCountWithLimit({ e2eDelayArray: t, min: 0, max: 1 }); const o = this._calcCountWithLimit({ e2eDelayArray: t, min: 1, max: 3 }); const a = this._calcPercent(n, e); const s = this._calcPercent(o, e); const r = this._calcAvg(t, e);return this._checkE2EDelayException(t, 3), this.reset(), { totalCount: e, countLessThan1Second: n, percentOfCountLessThan1Second: a, countLessThan3Second: o, percentOfCountLessThan3Second: s, avgDelay: r }; - } }, { key: 'reset', value() { - this._e2eDelayArray.length = 0; - } }]), e; - }()); const bc = (function () { - function e() { - t(this, e), this._className = 'AvgRTT', this._requestCount = 0, this._rttArray = []; - } return o(e, [{ key: 'addRequestCount', value() { - this._requestCount += 1; - } }, { key: 'addRTT', value(e) { - this._rttArray.push(e); - } }, { key: '_calcTotalCount', value() { - return this._requestCount; - } }, { key: '_calcRTTCount', value(e) { - return e.length; - } }, { key: '_calcSuccessRateOfRequest', value(e, t) { - if (0 === t) return 0;let n = mt(e / t * 100, 2);return n > 100 && (n = 100), n; - } }, { key: '_calcAvg', value(e, t) { - if (0 === t) return 0;let n = 0;return e.forEach(((e) => { - n += e; - })), parseInt(n / t); - } }, { key: '_calcMax', value() { - return Math.max.apply(Math, M(this._rttArray)); - } }, { key: '_calcMin', value() { - return Math.min.apply(Math, M(this._rttArray)); - } }, { key: 'getStatResult', value() { - const e = this._calcTotalCount(); const t = M(this._rttArray);if (0 === e) return null;const n = this._calcRTTCount(t); const o = this._calcSuccessRateOfRequest(n, e); const a = this._calcAvg(t, n);return Oe.log(''.concat(this._className, '.getStatResult max:').concat(this._calcMax(), ' min:') - .concat(this._calcMin(), ' avg:') - .concat(a)), this.reset(), { totalCount: e, rttCount: n, successRateOfRequest: o, avgRTT: a }; - } }, { key: 'reset', value() { - this._requestCount = 0, this._rttArray.length = 0; - } }]), e; - }()); const Pc = (function () { - function e() { - t(this, e), this._map = new Map; - } return o(e, [{ key: 'initMap', value(e) { - const t = this;e.forEach(((e) => { - t._map.set(e, { totalCount: 0, successCount: 0, failedCountOfUserSide: 0, costArray: [], fileSizeArray: [] }); - })); - } }, { key: 'addTotalCount', value(e) { - return !(qe(e) || !this._map.has(e)) && (this._map.get(e).totalCount += 1, !0); - } }, { key: 'addSuccessCount', value(e) { - return !(qe(e) || !this._map.has(e)) && (this._map.get(e).successCount += 1, !0); - } }, { key: 'addFailedCountOfUserSide', value(e) { - return !(qe(e) || !this._map.has(e)) && (this._map.get(e).failedCountOfUserSide += 1, !0); - } }, { key: 'addCost', value(e, t) { - return !(qe(e) || !this._map.has(e)) && (this._map.get(e).costArray.push(t), !0); - } }, { key: 'addFileSize', value(e, t) { - return !(qe(e) || !this._map.has(e)) && (this._map.get(e).fileSizeArray.push(t), !0); - } }, { key: '_calcSuccessRateOfBusiness', value(e) { - if (qe(e) || !this._map.has(e)) return -1;const t = this._map.get(e); let n = mt(t.successCount / t.totalCount * 100, 2);return n > 100 && (n = 100), n; - } }, { key: '_calcSuccessRateOfPlatform', value(e) { - if (qe(e) || !this._map.has(e)) return -1;const t = this._map.get(e); let n = this._calcSuccessCountOfPlatform(e) / t.totalCount * 100;return (n = mt(n, 2)) > 100 && (n = 100), n; - } }, { key: '_calcTotalCount', value(e) { - return qe(e) || !this._map.has(e) ? -1 : this._map.get(e).totalCount; - } }, { key: '_calcSuccessCountOfBusiness', value(e) { - return qe(e) || !this._map.has(e) ? -1 : this._map.get(e).successCount; - } }, { key: '_calcSuccessCountOfPlatform', value(e) { - if (qe(e) || !this._map.has(e)) return -1;const t = this._map.get(e);return t.successCount + t.failedCountOfUserSide; - } }, { key: '_calcAvg', value(e) { - return qe(e) || !this._map.has(e) ? -1 : e === Ba ? this._calcAvgSpeed(e) : this._calcAvgCost(e); - } }, { key: '_calcAvgCost', value(e) { - const t = this._map.get(e).costArray.length;if (0 === t) return 0;let n = 0;return this._map.get(e).costArray.forEach(((e) => { - n += e; - })), parseInt(n / t); - } }, { key: '_calcAvgSpeed', value(e) { - let t = 0; let n = 0;return this._map.get(e).costArray.forEach(((e) => { - t += e; - })), this._map.get(e).fileSizeArray.forEach(((e) => { - n += e; - })), parseInt(1e3 * n / t); - } }, { key: 'getStatResult', value(e) { - const t = this._calcTotalCount(e);if (0 === t) return null;const n = this._calcSuccessCountOfBusiness(e); const o = this._calcSuccessRateOfBusiness(e); const a = this._calcSuccessCountOfPlatform(e); const s = this._calcSuccessRateOfPlatform(e); const r = this._calcAvg(e);return this.reset(e), { totalCount: t, successCountOfBusiness: n, successRateOfBusiness: o, successCountOfPlatform: a, successRateOfPlatform: s, avgValue: r }; - } }, { key: 'reset', value(e) { - qe(e) ? this._map.clear() : this._map.set(e, { totalCount: 0, successCount: 0, failedCountOfUserSide: 0, costArray: [], fileSizeArray: [] }); - } }]), e; - }()); const Uc = (function () { - function e() { - t(this, e), this._lastMap = new Map, this._currentMap = new Map; - } return o(e, [{ key: 'initMap', value(e) { - const t = this;e.forEach(((e) => { - t._lastMap.set(e, new Map), t._currentMap.set(e, new Map); - })); - } }, { key: 'addMessageSequence', value(e) { - const t = e.key; const n = e.message;if (qe(t) || !this._lastMap.has(t) || !this._currentMap.has(t)) return !1;const o = n.conversationID; const a = n.sequence; const s = o.replace(k.CONV_GROUP, '');if (0 === this._lastMap.get(t).size) this._addCurrentMap(e);else if (this._lastMap.get(t).has(s)) { - const r = this._lastMap.get(t).get(s); const i = r.length - 1;a > r[0] && a < r[i] ? (r.push(a), r.sort(), this._lastMap.get(t).set(s, r)) : this._addCurrentMap(e); - } else this._addCurrentMap(e);return !0; - } }, { key: '_addCurrentMap', value(e) { - const t = e.key; const n = e.message; const o = n.conversationID; const a = n.sequence; const s = o.replace(k.CONV_GROUP, '');this._currentMap.get(t).has(s) || this._currentMap.get(t).set(s, []), this._currentMap.get(t).get(s) - .push(a); - } }, { key: '_copyData', value(e) { - if (!qe(e)) { - this._lastMap.set(e, new Map);let t; let n = this._lastMap.get(e); const o = S(this._currentMap.get(e));try { - for (o.s();!(t = o.n()).done;) { - const a = m(t.value, 2); const s = a[0]; const r = a[1];n.set(s, r); - } - } catch (i) { - o.e(i); - } finally { - o.f(); - }n = null, this._currentMap.set(e, new Map); - } - } }, { key: 'getStatResult', value(e) { - if (qe(this._currentMap.get(e)) || qe(this._lastMap.get(e))) return null;if (0 === this._lastMap.get(e).size) return this._copyData(e), null;let t = 0; let n = 0;if (this._lastMap.get(e).forEach(((e, o) => { - const a = M(e.values()); const s = a.length; const r = a[s - 1] - a[0] + 1;t += r, n += s; - })), 0 === t) return null;let o = mt(n / t * 100, 2);return o > 100 && (o = 100), this._copyData(e), { totalCount: t, successCountOfMessageReceived: n, successRateOfMessageReceived: o }; - } }, { key: 'reset', value() { - this._currentMap.clear(), this._lastMap.clear(); - } }]), e; - }()); const Fc = (function (e) { - i(a, e);const n = f(a);function a(e) { - let o;t(this, a), (o = n.call(this, e))._className = 'QualityStatModule', o.TAG = 'im-ssolog-quality-stat', o.reportIndex = 0, o.wholePeriod = !1, o._qualityItems = [Ua, Fa, qa, Va, Ka, xa, Ba, Ha, ja, Wa], o._messageSentItems = [qa, Va, Ka, xa, Ba], o._messageReceivedItems = [Ha, ja, Wa], o.REPORT_INTERVAL = 120, o.REPORT_SDKAPPID_BLACKLIST = [], o.REPORT_TINYID_WHITELIST = [], o._statInfoArr = [], o._avgRTT = new bc, o._avgE2EDelay = new wc, o._rateMessageSent = new Pc, o._rateMessageReceived = new Uc;const s = o.getInnerEmitterInstance();return s.on(ii, o._onLoginSuccess, h(o)), s.on(ci, o._onCloudConfigUpdated, h(o)), o; - } return o(a, [{ key: '_onLoginSuccess', value() { - const e = this;this._rateMessageSent.initMap(this._messageSentItems), this._rateMessageReceived.initMap(this._messageReceivedItems);const t = this.getModule(Ht); const n = t.getItem(this.TAG, !1);!It(n) && Ke(n.forEach) && (Oe.log(''.concat(this._className, '._onLoginSuccess.get quality stat log in storage, nums=').concat(n.length)), n.forEach(((t) => { - e._statInfoArr.push(t); - })), t.removeItem(this.TAG, !1)); - } }, { key: '_onCloudConfigUpdated', value() { - const e = this.getCloudConfig('q_rpt_interval'); const t = this.getCloudConfig('q_rpt_sdkappid_bl'); const n = this.getCloudConfig('q_rpt_tinyid_wl');qe(e) || (this.REPORT_INTERVAL = Number(e)), qe(t) || (this.REPORT_SDKAPPID_BLACKLIST = t.split(',').map((e => Number(e)))), qe(n) || (this.REPORT_TINYID_WHITELIST = n.split(',')); - } }, { key: 'onCheckTimer', value(e) { - this.isLoggedIn() && e % this.REPORT_INTERVAL == 0 && (this.wholePeriod = !0, this._report()); - } }, { key: 'addRequestCount', value() { - this._avgRTT.addRequestCount(); - } }, { key: 'addRTT', value(e) { - this._avgRTT.addRTT(e); - } }, { key: 'addMessageDelay', value(e) { - this._avgE2EDelay.addMessageDelay(e); - } }, { key: 'addTotalCount', value(e) { - this._rateMessageSent.addTotalCount(e) || Oe.warn(''.concat(this._className, '.addTotalCount invalid key:'), e); - } }, { key: 'addSuccessCount', value(e) { - this._rateMessageSent.addSuccessCount(e) || Oe.warn(''.concat(this._className, '.addSuccessCount invalid key:'), e); - } }, { key: 'addFailedCountOfUserSide', value(e) { - this._rateMessageSent.addFailedCountOfUserSide(e) || Oe.warn(''.concat(this._className, '.addFailedCountOfUserSide invalid key:'), e); - } }, { key: 'addCost', value(e, t) { - this._rateMessageSent.addCost(e, t) || Oe.warn(''.concat(this._className, '.addCost invalid key or cost:'), e, t); - } }, { key: 'addFileSize', value(e, t) { - this._rateMessageSent.addFileSize(e, t) || Oe.warn(''.concat(this._className, '.addFileSize invalid key or size:'), e, t); - } }, { key: 'addMessageSequence', value(e) { - this._rateMessageReceived.addMessageSequence(e) || Oe.warn(''.concat(this._className, '.addMessageSequence invalid key:'), e.key); - } }, { key: '_getQualityItem', value(e) { - let t = {}; let n = za[this.getNetworkType()];qe(n) && (n = 8);const o = { qualityType: Ya[e], timestamp: Ee(), networkType: n, extension: '' };switch (e) { - case Ua:t = this._avgRTT.getStatResult();break;case Fa:t = this._avgE2EDelay.getStatResult();break;case qa:case Va:case Ka:case xa:case Ba:t = this._rateMessageSent.getStatResult(e);break;case Ha:case ja:case Wa:t = this._rateMessageReceived.getStatResult(e); - } return null === t ? null : r(r({}, o), t); - } }, { key: '_report', value(e) { - const t = this; let n = []; let o = null;qe(e) ? this._qualityItems.forEach(((e) => { - null !== (o = t._getQualityItem(e)) && (o.reportIndex = t.reportIndex, o.wholePeriod = t.wholePeriod, n.push(o)); - })) : null !== (o = this._getQualityItem(e)) && (o.reportIndex = this.reportIndex, o.wholePeriod = this.wholePeriod, n.push(o)), Oe.debug(''.concat(this._className, '._report'), n), this._statInfoArr.length > 0 && (n = n.concat(this._statInfoArr), this._statInfoArr = []);const a = this.getModule(Bt); const s = a.getSDKAppID(); const r = a.getTinyID();Mt(this.REPORT_SDKAPPID_BLACKLIST, s) && !vt(this.REPORT_TINYID_WHITELIST, r) && (n = []), n.length > 0 && this._doReport(n); - } }, { key: '_doReport', value(e) { - const t = this; const n = { header: zi(this), quality: e };this.request({ protocolName: go, requestData: r({}, n) }).then((() => { - t.reportIndex++, t.wholePeriod = !1; - })) - .catch(((n) => { - Oe.warn(''.concat(t._className, '._doReport, online:').concat(t.getNetworkType(), ' error:'), n), t._statInfoArr = t._statInfoArr.concat(e), t._flushAtOnce(); - })); - } }, { key: '_flushAtOnce', value() { - const e = this.getModule(Ht); const t = e.getItem(this.TAG, !1); const n = this._statInfoArr;if (It(t))Oe.log(''.concat(this._className, '._flushAtOnce count:').concat(n.length)), e.setItem(this.TAG, n, !0, !1);else { - let o = n.concat(t);o.length > 10 && (o = o.slice(0, 10)), Oe.log(''.concat(this.className, '._flushAtOnce count:').concat(o.length)), e.setItem(this.TAG, o, !0, !1); - } this._statInfoArr = []; - } }, { key: 'reset', value() { - Oe.log(''.concat(this._className, '.reset')), this._report(), this.reportIndex = 0, this.wholePeriod = !1, this.REPORT_SDKAPPID_BLACKLIST = [], this.REPORT_TINYID_WHITELIST = [], this._avgRTT.reset(), this._avgE2EDelay.reset(), this._rateMessageSent.reset(), this._rateMessageReceived.reset(); - } }]), a; - }(sn)); const qc = (function (e) { - i(a, e);const n = f(a);function a(e) { - let o;return t(this, a), (o = n.call(this, e))._className = 'WorkerModule', o._isWorkerEnabled = !1, o._workerTimer = null, o._init(), o.getInnerEmitterInstance().on(ci, o._onCloudConfigUpdated, h(o)), o; - } return o(a, [{ key: 'isWorkerEnabled', value() { - return this._isWorkerEnabled && ye && this._workerTimer; - } }, { key: 'startWorkerTimer', value() { - Oe.log(''.concat(this._className, '.startWorkerTimer')), this._workerTimer && this._workerTimer.postMessage('start'); - } }, { key: 'stopWorkerTimer', value() { - Oe.log(''.concat(this._className, '.stopWorkerTimer')), this._workerTimer && this._workerTimer.postMessage('stop'); - } }, { key: '_init', value() { - if (ye) { - const e = URL.createObjectURL(new Blob(['let interval = -1;onmessage = function(event) { if (event.data === "start") { if (interval > 0) { clearInterval(interval); } interval = setInterval(() => { postMessage(""); }, 1000) } else if (event.data === "stop") { clearInterval(interval); interval = -1; }};'], { type: 'application/javascript; charset=utf-8' }));this._workerTimer = new Worker(e);const t = this;this._workerTimer.onmessage = function () { - t._moduleManager.onCheckTimer(); - }; - } - } }, { key: '_onCloudConfigUpdated', value() { - '1' === this.getCloudConfig('enable_worker') ? !this._isWorkerEnabled && ye && (this._isWorkerEnabled = !0, this.startWorkerTimer(), this._moduleManager.onWorkerTimerEnabled()) : this._isWorkerEnabled && ye && (this._isWorkerEnabled = !1, this.stopWorkerTimer(), this._moduleManager.onWorkerTimerDisabled()); - } }, { key: 'terminate', value() { - Oe.log(''.concat(this._className, '.terminate')), this._workerTimer && (this._workerTimer.terminate(), this._workerTimer = null); - } }, { key: 'reset', value() { - Oe.log(''.concat(this._className, '.reset')); - } }]), a; - }(sn)); const Vc = (function () { - function e() { - t(this, e), this._className = 'PurchasedFeatureHandler', this._purchasedFeatureMap = new Map; - } return o(e, [{ key: 'isValidPurchaseBits', value(e) { - return e && 'string' === typeof e && e.length >= 1 && e.length <= 64 && /[01]{1,64}/.test(e); - } }, { key: 'parsePurchaseBits', value(e) { - const t = ''.concat(this._className, '.parsePurchaseBits');if (this.isValidPurchaseBits(e)) { - this._purchasedFeatureMap.clear();for (let n = Object.values(B), o = null, a = e.length - 1, s = 0;a >= 0;a--, s++)o = s < 32 ? new R(0, Math.pow(2, s)).toString() : new R(Math.pow(2, s - 32), 0).toString(), -1 !== n.indexOf(o) && ('1' === e[a] ? this._purchasedFeatureMap.set(o, !0) : this._purchasedFeatureMap.set(o, !1)); - } else Oe.warn(''.concat(t, ' invalid purchase bits:').concat(e)); - } }, { key: 'hasPurchasedFeature', value(e) { - return !!this._purchasedFeatureMap.get(e); - } }, { key: 'clear', value() { - this._purchasedFeatureMap.clear(); - } }]), e; - }()); const Kc = (function (e) { - i(a, e);const n = f(a);function a(e) { - let o;return t(this, a), (o = n.call(this, e))._className = 'CommercialConfigModule', o._expiredTime = 0, o._isFetching = !1, o._purchasedFeatureHandler = new Vc, o; - } return o(a, [{ key: '_canFetch', value() { - return this.isLoggedIn() ? !this._isFetching && Date.now() >= this._expiredTime : (this._expiredTime = Date.now() + 2e3, !1); - } }, { key: 'onCheckTimer', value(e) { - this._canFetch() && this.fetchConfig(); - } }, { key: 'fetchConfig', value() { - const e = this; const t = this._canFetch(); const n = ''.concat(this._className, '.fetchConfig');if (Oe.log(''.concat(n, ' canFetch:').concat(t)), t) { - const o = new Xa(Ir);o.setNetworkType(this.getNetworkType());const a = this.getModule(Bt).getSDKAppID();this._isFetching = !0, this.request({ protocolName: Co, requestData: { SDKAppID: a } }).then(((t) => { - o.setMessage('purchaseBits:'.concat(t.data.purchaseBits)).end(), Oe.log(''.concat(n, ' ok.')), e._parseConfig(t.data), e._isFetching = !1; - })) - .catch(((t) => { - e.probeNetwork().then(((e) => { - const n = m(e, 2); const a = n[0]; const s = n[1];o.setError(t, a, s).end(); - })), e._isFetching = !1; - })); - } - } }, { key: 'onPushedConfig', value(e) { - const t = ''.concat(this._className, '.onPushedConfig');Oe.log(''.concat(t)), new Xa(Cr).setNetworkType(this.getNetworkType()) - .setMessage('purchaseBits:'.concat(e.purchaseBits)) - .end(), this._parseConfig(e); - } }, { key: '_parseConfig', value(e) { - const t = ''.concat(this._className, '._parseConfig'); const n = e.errorCode; const o = e.errorMessage; const a = e.purchaseBits; const s = e.expiredTime;0 === n ? (this._purchasedFeatureHandler.parsePurchaseBits(a), this._expiredTime = Date.now() + 1e3 * s) : qe(n) ? (Oe.log(''.concat(t, ' failed. Invalid message format:'), e), this._setExpiredTimeOnResponseError(36e5)) : (Oe.error(''.concat(t, ' errorCode:').concat(n, ' errorMessage:') - .concat(o)), this._setExpiredTimeOnResponseError(12e4)); - } }, { key: '_setExpiredTimeOnResponseError', value(e) { - this._expiredTime = Date.now() + e; - } }, { key: 'hasPurchasedFeature', value(e) { - return this._purchasedFeatureHandler.hasPurchasedFeature(e); - } }, { key: 'reset', value() { - Oe.log(''.concat(this._className, '.reset')), this._expiredTime = 0, this._isFetching = !1, this._purchasedFeatureHandler.clear(); - } }]), a; - }(sn)); const xc = (function () { - function e(n) { - t(this, e);const o = new Xa(Qa);this._className = 'ModuleManager', this._isReady = !1, this._startLoginTs = 0, this._moduleMap = new Map, this._innerEmitter = null, this._outerEmitter = null, this._checkCount = 0, this._checkTimer = -1, this._moduleMap.set(Bt, new Hi(this, n)), this._moduleMap.set(an, new Kc(this)), this._moduleMap.set(en, new Oc(this)), this._moduleMap.set(tn, new qc(this)), this._moduleMap.set(on, new Fc(this)), this._moduleMap.set(Qt, new Dc(this)), this._moduleMap.set(Xt, new Lc(this)), this._moduleMap.set(bt, new ji(this)), this._moduleMap.set(Pt, new rc(this)), this._moduleMap.set(Ut, new Bi(this)), this._moduleMap.set(Ft, new si(this)), this._moduleMap.set(xt, new ki(this)), this._moduleMap.set(qt, new Ui(this)), this._moduleMap.set(Kt, new qi(this)), this._moduleMap.set(Ht, new Yi(this)), this._moduleMap.set(jt, new Ji(this)), this._moduleMap.set(Wt, new Zi(this)), this._moduleMap.set(Yt, new tc(this)), this._moduleMap.set($t, new nc(this)), this._moduleMap.set(zt, new ic(this)), this._moduleMap.set(Jt, new cc(this)), this._moduleMap.set(Zt, new Rc(this)), this._moduleMap.set(nn, new Gc(this));const a = n.instanceID; const s = n.oversea; const r = n.SDKAppID; const i = 'instanceID:'.concat(a, ' SDKAppID:').concat(r, ' host:') - .concat(gt(), ' oversea:') - .concat(s, ' inBrowser:') - .concat(te, ' inMiniApp:') - .concat(ee) + ' workerAvailable:'.concat(ye, ' UserAgent:').concat(ae);Xa.bindEventStatModule(this._moduleMap.get(jt)), o.setMessage(''.concat(i, ' ').concat(function () { - let e = '';if (ee) try { - const t = ne.getSystemInfoSync(); const n = t.model; const o = t.version; const a = t.system; const s = t.platform; const r = t.SDKVersion;e = 'model:'.concat(n, ' version:').concat(o, ' system:') - .concat(a, ' platform:') - .concat(s, ' SDKVersion:') - .concat(r); - } catch (i) { - e = ''; - } return e; - }())).end(), Oe.info('SDK '.concat(i)), this._readyList = void 0, this._ssoLogForReady = null, this._initReadyList(); - } return o(e, [{ key: '_startTimer', value() { - const e = this._moduleMap.get(tn).isWorkerEnabled();Oe.log(''.concat(this._className, '.startTimer isWorkerEnabled:').concat(e, ' seed:') - .concat(this._checkTimer)), e ? this._moduleMap.get(tn).startWorkerTimer() : this._startMainThreadTimer(); - } }, { key: '_startMainThreadTimer', value() { - Oe.log(''.concat(this._className, '._startMainThreadTimer')), this._checkTimer < 0 && (this._checkTimer = setInterval(this.onCheckTimer.bind(this), 1e3)); - } }, { key: 'stopTimer', value() { - const e = this._moduleMap.get(tn).isWorkerEnabled();Oe.log(''.concat(this._className, '.stopTimer isWorkerEnabled:').concat(e, ' seed:') - .concat(this._checkTimer)), e ? this._moduleMap.get(tn).stopWorkerTimer() : this._stopMainThreadTimer(); - } }, { key: '_stopMainThreadTimer', value() { - Oe.log(''.concat(this._className, '._stopMainThreadTimer')), this._checkTimer > 0 && (clearInterval(this._checkTimer), this._checkTimer = -1, this._checkCount = 0); - } }, { key: 'onWorkerTimerEnabled', value() { - Oe.log(''.concat(this._className, '.onWorkerTimerEnabled, disable main thread timer')), this._stopMainThreadTimer(); - } }, { key: 'onWorkerTimerDisabled', value() { - Oe.log(''.concat(this._className, '.onWorkerTimerDisabled, enable main thread timer')), this._startMainThreadTimer(); - } }, { key: 'onCheckTimer', value() { - this._checkCount += 1;let e; const t = S(this._moduleMap);try { - for (t.s();!(e = t.n()).done;) { - const n = m(e.value, 2)[1];n.onCheckTimer && n.onCheckTimer(this._checkCount); - } - } catch (o) { - t.e(o); - } finally { - t.f(); - } - } }, { key: '_initReadyList', value() { - const e = this;this._readyList = [this._moduleMap.get(bt), this._moduleMap.get(xt)], this._readyList.forEach(((t) => { - t.ready((() => e._onModuleReady())); - })); - } }, { key: '_onModuleReady', value() { - let e = !0;if (this._readyList.forEach(((t) => { - t.isReady() || (e = !1); - })), e && !this._isReady) { - this._isReady = !0, this._outerEmitter.emit(D.SDK_READY);const t = Date.now() - this._startLoginTs;Oe.warn('SDK is ready. cost '.concat(t, ' ms')), this._startLoginTs = Date.now();const n = this._moduleMap.get(Wt).getNetworkType(); const o = this._ssoLogForReady.getStartTs() + ke;this._ssoLogForReady.setNetworkType(n).setMessage(t) - .start(o) - .end(); - } - } }, { key: 'login', value() { - 0 === this._startLoginTs && (Ae(), this._startLoginTs = Date.now(), this._startTimer(), this._moduleMap.get(Wt).start(), this._ssoLogForReady = new Xa(Za)); - } }, { key: 'onLoginFailed', value() { - this._startLoginTs = 0; - } }, { key: 'getOuterEmitterInstance', value() { - return null === this._outerEmitter && (this._outerEmitter = new ec, ni(this._outerEmitter), this._outerEmitter._emit = this._outerEmitter.emit, this._outerEmitter.emit = function (e, t) { - const n = arguments[0]; const o = [n, { name: arguments[0], data: arguments[1] }];this._outerEmitter._emit.apply(this._outerEmitter, o); - }.bind(this)), this._outerEmitter; - } }, { key: 'getInnerEmitterInstance', value() { - return null === this._innerEmitter && (this._innerEmitter = new ec, this._innerEmitter._emit = this._innerEmitter.emit, this._innerEmitter.emit = function (e, t) { - let n;Ue(arguments[1]) && arguments[1].data ? (Oe.warn('inner eventData has data property, please check!'), n = [e, { name: arguments[0], data: arguments[1].data }]) : n = [e, { name: arguments[0], data: arguments[1] }], this._innerEmitter._emit.apply(this._innerEmitter, n); - }.bind(this)), this._innerEmitter; - } }, { key: 'hasModule', value(e) { - return this._moduleMap.has(e); - } }, { key: 'getModule', value(e) { - return this._moduleMap.get(e); - } }, { key: 'isReady', value() { - return this._isReady; - } }, { key: 'onError', value(e) { - Oe.warn('Oops! code:'.concat(e.code, ' message:').concat(e.message)), new Xa(Tr).setMessage('code:'.concat(e.code, ' message:').concat(e.message)) - .setNetworkType(this.getModule(Wt).getNetworkType()) - .setLevel('error') - .end(), this.getOuterEmitterInstance().emit(D.ERROR, e); - } }, { key: 'reset', value() { - Oe.log(''.concat(this._className, '.reset')), Ae();let e; const t = S(this._moduleMap);try { - for (t.s();!(e = t.n()).done;) { - const n = m(e.value, 2)[1];n.reset && n.reset(); - } - } catch (o) { - t.e(o); - } finally { - t.f(); - } this._startLoginTs = 0, this._initReadyList(), this._isReady = !1, this.stopTimer(), this._outerEmitter.emit(D.SDK_NOT_READY); - } }]), e; - }()); const Bc = (function () { - function e() { - t(this, e), this._funcMap = new Map; - } return o(e, [{ key: 'defense', value(e, t) { - const n = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : void 0;if ('string' !== typeof e) return null;if (0 === e.length) return null;if ('function' !== typeof t) return null;if (this._funcMap.has(e) && this._funcMap.get(e).has(t)) return this._funcMap.get(e).get(t);this._funcMap.has(e) || this._funcMap.set(e, new Map);let o = null;return this._funcMap.get(e).has(t) ? o = this._funcMap.get(e).get(t) : (o = this._pack(e, t, n), this._funcMap.get(e).set(t, o)), o; - } }, { key: 'defenseOnce', value(e, t) { - const n = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : void 0;return 'function' !== typeof t ? null : this._pack(e, t, n); - } }, { key: 'find', value(e, t) { - return 'string' !== typeof e || 0 === e.length || 'function' !== typeof t ? null : this._funcMap.has(e) ? this._funcMap.get(e).has(t) ? this._funcMap.get(e).get(t) : (Oe.log('SafetyCallback.find: 找不到 func —— '.concat(e, '/').concat('' !== t.name ? t.name : '[anonymous]')), null) : (Oe.log('SafetyCallback.find: 找不到 eventName-'.concat(e, ' 对应的 func')), null); - } }, { key: 'delete', value(e, t) { - return 'function' === typeof t && (!!this._funcMap.has(e) && (!!this._funcMap.get(e).has(t) && (this._funcMap.get(e).delete(t), 0 === this._funcMap.get(e).size && this._funcMap.delete(e), !0))); - } }, { key: '_pack', value(e, t, n) { - return function () { - try { - t.apply(n, Array.from(arguments)); - } catch (r) { - const o = Object.values(D).indexOf(e);if (-1 !== o) { - const a = Object.keys(D)[o];Oe.warn('接入侧事件 TIM.EVENT.'.concat(a, ' 对应的回调函数逻辑存在问题,请检查!'), r); - } const s = new Xa(Mr);s.setMessage('eventName:'.concat(e)).setMoreMessage(r.message) - .end(); - } - }; - } }]), e; - }()); const Hc = (function () { - function e(n) { - t(this, e);const o = { SDKAppID: n.SDKAppID, unlimitedAVChatRoom: n.unlimitedAVChatRoom || !1, scene: n.scene || '', oversea: n.oversea || !1, instanceID: pt(), devMode: n.devMode || !1, proxyServer: n.proxyServer || void 0 };this._moduleManager = new xc(o), this._safetyCallbackFactory = new Bc; - } return o(e, [{ key: 'isReady', value() { - return this._moduleManager.isReady(); - } }, { key: 'onError', value(e) { - this._moduleManager.onError(e); - } }, { key: 'login', value(e) { - return this._moduleManager.login(), this._moduleManager.getModule(bt).login(e); - } }, { key: 'logout', value() { - const e = this;return this._moduleManager.getModule(bt).logout() - .then((t => (e._moduleManager.reset(), t))); - } }, { key: 'destroy', value() { - const e = this;return this.logout().finally((() => { - e._moduleManager.stopTimer(), e._moduleManager.getModule(tn).terminate(), e._moduleManager.getModule(Qt).dealloc();const t = e._moduleManager.getOuterEmitterInstance(); const n = e._moduleManager.getModule(Bt);t.emit(D.SDK_DESTROY, { SDKAppID: n.getSDKAppID() }); - })); - } }, { key: 'on', value(e, t, n) { - e === D.GROUP_SYSTEM_NOTICE_RECEIVED && Oe.warn('!!!TIM.EVENT.GROUP_SYSTEM_NOTICE_RECEIVED v2.6.0起弃用,为了更好的体验,请在 TIM.EVENT.MESSAGE_RECEIVED 事件回调内接收处理群系统通知,详细请参考:https://web.sdk.qcloud.com/im/doc/zh-cn/Message.html#.GroupSystemNoticePayload'), Oe.debug('on', 'eventName:'.concat(e)), this._moduleManager.getOuterEmitterInstance().on(e, this._safetyCallbackFactory.defense(e, t, n), n); - } }, { key: 'once', value(e, t, n) { - Oe.debug('once', 'eventName:'.concat(e)), this._moduleManager.getOuterEmitterInstance().once(e, this._safetyCallbackFactory.defenseOnce(e, t, n), n || this); - } }, { key: 'off', value(e, t, n, o) { - Oe.debug('off', 'eventName:'.concat(e));const a = this._safetyCallbackFactory.find(e, t);null !== a && (this._moduleManager.getOuterEmitterInstance().off(e, a, n, o), this._safetyCallbackFactory.delete(e, t)); - } }, { key: 'registerPlugin', value(e) { - this._moduleManager.getModule(zt).registerPlugin(e); - } }, { key: 'setLogLevel', value(e) { - if (e <= 0) { - console.log(['', ' ________ ______ __ __ __ __ ________ _______', '| \\| \\| \\ / \\| \\ _ | \\| \\| \\', ' \\$$$$$$$$ \\$$$$$$| $$\\ / $$| $$ / \\ | $$| $$$$$$$$| $$$$$$$\\', ' | $$ | $$ | $$$\\ / $$$| $$/ $\\| $$| $$__ | $$__/ $$', ' | $$ | $$ | $$$$\\ $$$$| $$ $$$\\ $$| $$ \\ | $$ $$', ' | $$ | $$ | $$\\$$ $$ $$| $$ $$\\$$\\$$| $$$$$ | $$$$$$$\\', ' | $$ _| $$_ | $$ \\$$$| $$| $$$$ \\$$$$| $$_____ | $$__/ $$', ' | $$ | $$ \\| $$ \\$ | $$| $$$ \\$$$| $$ \\| $$ $$', ' \\$$ \\$$$$$$ \\$$ \\$$ \\$$ \\$$ \\$$$$$$$$ \\$$$$$$$', '', ''].join('\n')), console.log('%cIM 智能客服,随时随地解决您的问题 →_→ https://cloud.tencent.com/act/event/smarty-service?from=im-doc', 'color:#006eff'), console.log('%c从v2.11.2起,SDK 支持了 WebSocket,小程序需要添加受信域名!升级指引: https://web.sdk.qcloud.com/im/doc/zh-cn/tutorial-02-upgradeguideline.html', 'color:#ff0000');console.log(['', '参考以下文档,会更快解决问题哦!(#^.^#)\n', 'SDK 更新日志: https://cloud.tencent.com/document/product/269/38492\n', 'SDK 接口文档: https://web.sdk.qcloud.com/im/doc/zh-cn/SDK.html\n', '常见问题: https://web.sdk.qcloud.com/im/doc/zh-cn/tutorial-01-faq.html\n', '反馈问题?戳我提 issue: https://github.com/tencentyun/TIMSDK/issues\n', '如果您需要在生产环境关闭上面的日志,请 tim.setLogLevel(1)\n'].join('\n')); - }Oe.setLevel(e); - } }, { key: 'createTextMessage', value(e) { - return this._moduleManager.getModule(Pt).createTextMessage(e); - } }, { key: 'createTextAtMessage', value(e) { - return this._moduleManager.getModule(Pt).createTextMessage(e); - } }, { key: 'createImageMessage', value(e) { - return this._moduleManager.getModule(Pt).createImageMessage(e); - } }, { key: 'createAudioMessage', value(e) { - return this._moduleManager.getModule(Pt).createAudioMessage(e); - } }, { key: 'createVideoMessage', value(e) { - return this._moduleManager.getModule(Pt).createVideoMessage(e); - } }, { key: 'createCustomMessage', value(e) { - return this._moduleManager.getModule(Pt).createCustomMessage(e); - } }, { key: 'createFaceMessage', value(e) { - return this._moduleManager.getModule(Pt).createFaceMessage(e); - } }, { key: 'createFileMessage', value(e) { - return this._moduleManager.getModule(Pt).createFileMessage(e); - } }, { key: 'createLocationMessage', value(e) { - return this._moduleManager.getModule(Pt).createLocationMessage(e); - } }, { key: 'createMergerMessage', value(e) { - return this._moduleManager.getModule(Pt).createMergerMessage(e); - } }, { key: 'downloadMergerMessage', value(e) { - return e.type !== k.MSG_MERGER ? ai(new ei({ code: Do.MESSAGE_MERGER_TYPE_INVALID, message: ta })) : It(e.payload.downloadKey) ? ai(new ei({ code: Do.MESSAGE_MERGER_KEY_INVALID, message: na })) : this._moduleManager.getModule(Pt).downloadMergerMessage(e) - .catch((e => ai(new ei({ code: Do.MESSAGE_MERGER_DOWNLOAD_FAIL, message: oa })))); - } }, { key: 'createForwardMessage', value(e) { - return this._moduleManager.getModule(Pt).createForwardMessage(e); - } }, { key: 'sendMessage', value(e, t) { - return e instanceof Yr ? this._moduleManager.getModule(Pt).sendMessageInstance(e, t) : ai(new ei({ code: Do.MESSAGE_SEND_NEED_MESSAGE_INSTANCE, message: Po })); - } }, { key: 'callExperimentalAPI', value(e, t) { - return 'handleGroupInvitation' === e ? this._moduleManager.getModule(qt).handleGroupInvitation(t) : ai(new ei({ code: Do.INVALID_OPERATION, message: Ra })); - } }, { key: 'revokeMessage', value(e) { - return this._moduleManager.getModule(Pt).revokeMessage(e); - } }, { key: 'resendMessage', value(e) { - return this._moduleManager.getModule(Pt).resendMessage(e); - } }, { key: 'deleteMessage', value(e) { - return this._moduleManager.getModule(Pt).deleteMessage(e); - } }, { key: 'getMessageList', value(e) { - return this._moduleManager.getModule(xt).getMessageList(e); - } }, { key: 'setMessageRead', value(e) { - return this._moduleManager.getModule(xt).setMessageRead(e); - } }, { key: 'getConversationList', value(e) { - return this._moduleManager.getModule(xt).getConversationList(e); - } }, { key: 'getConversationProfile', value(e) { - return this._moduleManager.getModule(xt).getConversationProfile(e); - } }, { key: 'deleteConversation', value(e) { - return this._moduleManager.getModule(xt).deleteConversation(e); - } }, { key: 'pinConversation', value(e) { - return this._moduleManager.getModule(xt).pinConversation(e); - } }, { key: 'setAllMessageRead', value(e) { - return this._moduleManager.getModule(xt).setAllMessageRead(e); - } }, { key: 'setMessageRemindType', value(e) { - return this._moduleManager.getModule(xt).setMessageRemindType(e); - } }, { key: 'getMyProfile', value() { - return this._moduleManager.getModule(Ut).getMyProfile(); - } }, { key: 'getUserProfile', value(e) { - return this._moduleManager.getModule(Ut).getUserProfile(e); - } }, { key: 'updateMyProfile', value(e) { - return this._moduleManager.getModule(Ut).updateMyProfile(e); - } }, { key: 'getBlacklist', value() { - return this._moduleManager.getModule(Ut).getLocalBlacklist(); - } }, { key: 'addToBlacklist', value(e) { - return this._moduleManager.getModule(Ut).addBlacklist(e); - } }, { key: 'removeFromBlacklist', value(e) { - return this._moduleManager.getModule(Ut).deleteBlacklist(e); - } }, { key: 'getFriendList', value() { - const e = this._moduleManager.getModule(Vt);return e ? e.getLocalFriendList() : ai({ code: Do.CANNOT_FIND_MODULE, message: Ga }); - } }, { key: 'addFriend', value(e) { - const t = this._moduleManager.getModule(Vt);return t ? t.addFriend(e) : ai({ code: Do.CANNOT_FIND_MODULE, message: Ga }); - } }, { key: 'deleteFriend', value(e) { - const t = this._moduleManager.getModule(Vt);return t ? t.deleteFriend(e) : ai({ code: Do.CANNOT_FIND_MODULE, message: Ga }); - } }, { key: 'checkFriend', value(e) { - const t = this._moduleManager.getModule(Vt);return t ? t.checkFriend(e) : ai({ code: Do.CANNOT_FIND_MODULE, message: Ga }); - } }, { key: 'getFriendProfile', value(e) { - const t = this._moduleManager.getModule(Vt);return t ? t.getFriendProfile(e) : ai({ code: Do.CANNOT_FIND_MODULE, message: Ga }); - } }, { key: 'updateFriend', value(e) { - const t = this._moduleManager.getModule(Vt);return t ? t.updateFriend(e) : ai({ code: Do.CANNOT_FIND_MODULE, message: Ga }); - } }, { key: 'getFriendApplicationList', value() { - const e = this._moduleManager.getModule(Vt);return e ? e.getLocalFriendApplicationList() : ai({ code: Do.CANNOT_FIND_MODULE, message: Ga }); - } }, { key: 'acceptFriendApplication', value(e) { - const t = this._moduleManager.getModule(Vt);return t ? t.acceptFriendApplication(e) : ai({ code: Do.CANNOT_FIND_MODULE, message: Ga }); - } }, { key: 'refuseFriendApplication', value(e) { - const t = this._moduleManager.getModule(Vt);return t ? t.refuseFriendApplication(e) : ai({ code: Do.CANNOT_FIND_MODULE, message: Ga }); - } }, { key: 'deleteFriendApplication', value(e) { - const t = this._moduleManager.getModule(Vt);return t ? t.deleteFriendApplication(e) : ai({ code: Do.CANNOT_FIND_MODULE, message: Ga }); - } }, { key: 'setFriendApplicationRead', value() { - const e = this._moduleManager.getModule(Vt);return e ? e.setFriendApplicationRead() : ai({ code: Do.CANNOT_FIND_MODULE, message: Ga }); - } }, { key: 'getFriendGroupList', value() { - const e = this._moduleManager.getModule(Vt);return e ? e.getLocalFriendGroupList() : ai({ code: Do.CANNOT_FIND_MODULE, message: Ga }); - } }, { key: 'createFriendGroup', value(e) { - const t = this._moduleManager.getModule(Vt);return t ? t.createFriendGroup(e) : ai({ code: Do.CANNOT_FIND_MODULE, message: Ga }); - } }, { key: 'deleteFriendGroup', value(e) { - const t = this._moduleManager.getModule(Vt);return t ? t.deleteFriendGroup(e) : ai({ code: Do.CANNOT_FIND_MODULE, message: Ga }); - } }, { key: 'addToFriendGroup', value(e) { - const t = this._moduleManager.getModule(Vt);return t ? t.addToFriendGroup(e) : ai({ code: Do.CANNOT_FIND_MODULE, message: Ga }); - } }, { key: 'removeFromFriendGroup', value(e) { - const t = this._moduleManager.getModule(Vt);return t ? t.removeFromFriendGroup(e) : ai({ code: Do.CANNOT_FIND_MODULE, message: Ga }); - } }, { key: 'renameFriendGroup', value(e) { - const t = this._moduleManager.getModule(Vt);return t ? t.renameFriendGroup(e) : ai({ code: Do.CANNOT_FIND_MODULE, message: Ga }); - } }, { key: 'getGroupList', value(e) { - return this._moduleManager.getModule(qt).getGroupList(e); - } }, { key: 'getGroupProfile', value(e) { - return this._moduleManager.getModule(qt).getGroupProfile(e); - } }, { key: 'createGroup', value(e) { - return this._moduleManager.getModule(qt).createGroup(e); - } }, { key: 'dismissGroup', value(e) { - return this._moduleManager.getModule(qt).dismissGroup(e); - } }, { key: 'updateGroupProfile', value(e) { - return this._moduleManager.getModule(qt).updateGroupProfile(e); - } }, { key: 'joinGroup', value(e) { - return this._moduleManager.getModule(qt).joinGroup(e); - } }, { key: 'quitGroup', value(e) { - return this._moduleManager.getModule(qt).quitGroup(e); - } }, { key: 'searchGroupByID', value(e) { - return this._moduleManager.getModule(qt).searchGroupByID(e); - } }, { key: 'getGroupOnlineMemberCount', value(e) { - return this._moduleManager.getModule(qt).getGroupOnlineMemberCount(e); - } }, { key: 'changeGroupOwner', value(e) { - return this._moduleManager.getModule(qt).changeGroupOwner(e); - } }, { key: 'handleGroupApplication', value(e) { - return this._moduleManager.getModule(qt).handleGroupApplication(e); - } }, { key: 'initGroupAttributes', value(e) { - return this._moduleManager.getModule(qt).initGroupAttributes(e); - } }, { key: 'setGroupAttributes', value(e) { - return this._moduleManager.getModule(qt).setGroupAttributes(e); - } }, { key: 'deleteGroupAttributes', value(e) { - return this._moduleManager.getModule(qt).deleteGroupAttributes(e); - } }, { key: 'getGroupAttributes', value(e) { - return this._moduleManager.getModule(qt).getGroupAttributes(e); - } }, { key: 'getGroupMemberList', value(e) { - return this._moduleManager.getModule(Kt).getGroupMemberList(e); - } }, { key: 'getGroupMemberProfile', value(e) { - return this._moduleManager.getModule(Kt).getGroupMemberProfile(e); - } }, { key: 'addGroupMember', value(e) { - return this._moduleManager.getModule(Kt).addGroupMember(e); - } }, { key: 'deleteGroupMember', value(e) { - return this._moduleManager.getModule(Kt).deleteGroupMember(e); - } }, { key: 'setGroupMemberMuteTime', value(e) { - return this._moduleManager.getModule(Kt).setGroupMemberMuteTime(e); - } }, { key: 'setGroupMemberRole', value(e) { - return this._moduleManager.getModule(Kt).setGroupMemberRole(e); - } }, { key: 'setGroupMemberNameCard', value(e) { - return this._moduleManager.getModule(Kt).setGroupMemberNameCard(e); - } }, { key: 'setGroupMemberCustomField', value(e) { - return this._moduleManager.getModule(Kt).setGroupMemberCustomField(e); - } }]), e; - }()); const jc = { login: 'login', logout: 'logout', destroy: 'destroy', on: 'on', off: 'off', ready: 'ready', setLogLevel: 'setLogLevel', joinGroup: 'joinGroup', quitGroup: 'quitGroup', registerPlugin: 'registerPlugin', getGroupOnlineMemberCount: 'getGroupOnlineMemberCount' };function Wc(e, t) { - if (e.isReady() || void 0 !== jc[t]) return !0;const n = new ei({ code: Do.SDK_IS_NOT_READY, message: ''.concat(t, ' ').concat(wa, ',请参考 https://web.sdk.qcloud.com/im/doc/zh-cn/module-EVENT.html#.SDK_READY') });return e.onError(n), !1; - } const Yc = {}; const $c = {};return $c.create = function (e) { - let t = 0;if (we(e.SDKAppID))t = e.SDKAppID;else if (Oe.warn('TIM.create SDKAppID 的类型应该为 Number,请修改!'), t = parseInt(e.SDKAppID), isNaN(t)) return Oe.error('TIM.create failed. 解析 SDKAppID 失败,请检查传参!'), null;if (t && Yc[t]) return Yc[t];Oe.log('TIM.create');const n = new Hc(r(r({}, e), {}, { SDKAppID: t }));n.on(D.SDK_DESTROY, ((e) => { - Yc[e.data.SDKAppID] = null, delete Yc[e.data.SDKAppID]; - }));const o = (function (e) { - const t = Object.create(null);return Object.keys(wt).forEach(((n) => { - if (e[n]) { - const o = wt[n]; const a = new E;t[o] = function () { - const t = Array.from(arguments);return a.use(((t, o) => (Wc(e, n) ? o() : ai(new ei({ code: Do.SDK_IS_NOT_READY, message: ''.concat(n, ' ').concat(wa, '。') }))))).use(((e, t) => { - if (!0 === Ct(e, Gt[n], o)) return t(); - })) - .use(((t, o) => e[n].apply(e, t))), a.run(t); - }; - } - })), t; - }(n));return Yc[t] = o, Oe.log('TIM.create ok'), o; - }, $c.TYPES = k, $c.EVENT = D, $c.VERSION = '2.16.3', Oe.log('TIM.VERSION: '.concat($c.VERSION)), $c; -}))); +'use strict';!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).TIM=t()}(this,(function(){function e(e,t){var o=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),o.push.apply(o,n)}return o}function t(t){for(var o=1;o=0||(a[o]=e[o]);return a}(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,o)&&(a[o]=e[o])}return a}function _(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function h(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return _(e)}function f(e){var t=l();return function(){var o,n=c(e);if(t){var a=c(this).constructor;o=Reflect.construct(n,arguments,a)}else o=n.apply(this,arguments);return h(this,o)}}function m(e,t){return v(e)||function(e,t){var o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==o)return;var n,a,s=[],r=!0,i=!1;try{for(o=o.call(e);!(r=(n=o.next()).done)&&(s.push(n.value),!t||s.length!==t);r=!0);}catch(c){i=!0,a=c}finally{try{r||null==o.return||o.return()}finally{if(i)throw a}}return s}(e,t)||I(e,t)||T()}function M(e){return function(e){if(Array.isArray(e))return E(e)}(e)||y(e)||I(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function v(e){if(Array.isArray(e))return e}function y(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function I(e,t){if(e){if("string"==typeof e)return E(e,t);var o=Object.prototype.toString.call(e).slice(8,-1);return"Object"===o&&e.constructor&&(o=e.constructor.name),"Map"===o||"Set"===o?Array.from(e):"Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)?E(e,t):void 0}}function E(e,t){(null==t||t>e.length)&&(t=e.length);for(var o=0,n=new Array(t);o=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,r=!0,i=!1;return{s:function(){o=o.call(e)},n:function(){var e=o.next();return r=e.done,e},e:function(e){i=!0,s=e},f:function(){try{r||null==o.return||o.return()}finally{if(i)throw s}}}}var S={SDK_READY:"sdkStateReady",SDK_NOT_READY:"sdkStateNotReady",SDK_DESTROY:"sdkDestroy",MESSAGE_RECEIVED:"onMessageReceived",MESSAGE_MODIFIED:"onMessageModified",MESSAGE_REVOKED:"onMessageRevoked",MESSAGE_READ_BY_PEER:"onMessageReadByPeer",MESSAGE_READ_RECEIPT_RECEIVED:"onMessageReadReceiptReceived",CONVERSATION_LIST_UPDATED:"onConversationListUpdated",GROUP_LIST_UPDATED:"onGroupListUpdated",GROUP_SYSTEM_NOTICE_RECEIVED:"receiveGroupSystemNotice",GROUP_ATTRIBUTES_UPDATED:"groupAttributesUpdated",TOPIC_CREATED:"onTopicCreated",TOPIC_DELETED:"onTopicDeleted",TOPIC_UPDATED:"onTopicUpdated",PROFILE_UPDATED:"onProfileUpdated",BLACKLIST_UPDATED:"blacklistUpdated",FRIEND_LIST_UPDATED:"onFriendListUpdated",FRIEND_GROUP_LIST_UPDATED:"onFriendGroupListUpdated",FRIEND_APPLICATION_LIST_UPDATED:"onFriendApplicationListUpdated",KICKED_OUT:"kickedOut",ERROR:"error",NET_STATE_CHANGE:"netStateChange",SDK_RELOAD:"sdkReload"},D={MSG_TEXT:"TIMTextElem",MSG_IMAGE:"TIMImageElem",MSG_SOUND:"TIMSoundElem",MSG_AUDIO:"TIMSoundElem",MSG_FILE:"TIMFileElem",MSG_FACE:"TIMFaceElem",MSG_VIDEO:"TIMVideoFileElem",MSG_GEO:"TIMLocationElem",MSG_LOCATION:"TIMLocationElem",MSG_GRP_TIP:"TIMGroupTipElem",MSG_GRP_SYS_NOTICE:"TIMGroupSystemNoticeElem",MSG_CUSTOM:"TIMCustomElem",MSG_MERGER:"TIMRelayElem",MSG_PRIORITY_HIGH:"High",MSG_PRIORITY_NORMAL:"Normal",MSG_PRIORITY_LOW:"Low",MSG_PRIORITY_LOWEST:"Lowest",CONV_C2C:"C2C",CONV_GROUP:"GROUP",CONV_TOPIC:"TOPIC",CONV_SYSTEM:"@TIM#SYSTEM",CONV_AT_ME:1,CONV_AT_ALL:2,CONV_AT_ALL_AT_ME:3,GRP_PRIVATE:"Private",GRP_WORK:"Private",GRP_PUBLIC:"Public",GRP_CHATROOM:"ChatRoom",GRP_MEETING:"ChatRoom",GRP_AVCHATROOM:"AVChatRoom",GRP_COMMUNITY:"Community",GRP_MBR_ROLE_OWNER:"Owner",GRP_MBR_ROLE_ADMIN:"Admin",GRP_MBR_ROLE_MEMBER:"Member",GRP_MBR_ROLE_CUSTOM:"Custom",GRP_TIP_MBR_JOIN:1,GRP_TIP_MBR_QUIT:2,GRP_TIP_MBR_KICKED_OUT:3,GRP_TIP_MBR_SET_ADMIN:4,GRP_TIP_MBR_CANCELED_ADMIN:5,GRP_TIP_GRP_PROFILE_UPDATED:6,GRP_TIP_MBR_PROFILE_UPDATED:7,MSG_REMIND_ACPT_AND_NOTE:"AcceptAndNotify",MSG_REMIND_ACPT_NOT_NOTE:"AcceptNotNotify",MSG_REMIND_DISCARD:"Discard",GENDER_UNKNOWN:"Gender_Type_Unknown",GENDER_FEMALE:"Gender_Type_Female",GENDER_MALE:"Gender_Type_Male",KICKED_OUT_MULT_ACCOUNT:"multipleAccount",KICKED_OUT_MULT_DEVICE:"multipleDevice",KICKED_OUT_USERSIG_EXPIRED:"userSigExpired",KICKED_OUT_REST_API:"REST_API_Kick",ALLOW_TYPE_ALLOW_ANY:"AllowType_Type_AllowAny",ALLOW_TYPE_NEED_CONFIRM:"AllowType_Type_NeedConfirm",ALLOW_TYPE_DENY_ANY:"AllowType_Type_DenyAny",FORBID_TYPE_NONE:"AdminForbid_Type_None",FORBID_TYPE_SEND_OUT:"AdminForbid_Type_SendOut",JOIN_OPTIONS_FREE_ACCESS:"FreeAccess",JOIN_OPTIONS_NEED_PERMISSION:"NeedPermission",JOIN_OPTIONS_DISABLE_APPLY:"DisableApply",JOIN_STATUS_SUCCESS:"JoinedSuccess",JOIN_STATUS_ALREADY_IN_GROUP:"AlreadyInGroup",JOIN_STATUS_WAIT_APPROVAL:"WaitAdminApproval",GRP_PROFILE_OWNER_ID:"ownerID",GRP_PROFILE_CREATE_TIME:"createTime",GRP_PROFILE_LAST_INFO_TIME:"lastInfoTime",GRP_PROFILE_MEMBER_NUM:"memberNum",GRP_PROFILE_MAX_MEMBER_NUM:"maxMemberNum",GRP_PROFILE_JOIN_OPTION:"joinOption",GRP_PROFILE_INTRODUCTION:"introduction",GRP_PROFILE_NOTIFICATION:"notification",GRP_PROFILE_MUTE_ALL_MBRS:"muteAllMembers",SNS_ADD_TYPE_SINGLE:"Add_Type_Single",SNS_ADD_TYPE_BOTH:"Add_Type_Both",SNS_DELETE_TYPE_SINGLE:"Delete_Type_Single",SNS_DELETE_TYPE_BOTH:"Delete_Type_Both",SNS_APPLICATION_TYPE_BOTH:"Pendency_Type_Both",SNS_APPLICATION_SENT_TO_ME:"Pendency_Type_ComeIn",SNS_APPLICATION_SENT_BY_ME:"Pendency_Type_SendOut",SNS_APPLICATION_AGREE:"Response_Action_Agree",SNS_APPLICATION_AGREE_AND_ADD:"Response_Action_AgreeAndAdd",SNS_CHECK_TYPE_BOTH:"CheckResult_Type_Both",SNS_CHECK_TYPE_SINGLE:"CheckResult_Type_Single",SNS_TYPE_NO_RELATION:"CheckResult_Type_NoRelation",SNS_TYPE_A_WITH_B:"CheckResult_Type_AWithB",SNS_TYPE_B_WITH_A:"CheckResult_Type_BWithA",SNS_TYPE_BOTH_WAY:"CheckResult_Type_BothWay",NET_STATE_CONNECTED:"connected",NET_STATE_CONNECTING:"connecting",NET_STATE_DISCONNECTED:"disconnected",MSG_AT_ALL:"__kImSDK_MesssageAtALL__",READ_ALL_C2C_MSG:"readAllC2CMessage",READ_ALL_GROUP_MSG:"readAllGroupMessage",READ_ALL_MSG:"readAllMessage"},N=function(){function e(){n(this,e),this.cache=[],this.options=null}return s(e,[{key:"use",value:function(e){if("function"!=typeof e)throw"middleware must be a function";return this.cache.push(e),this}},{key:"next",value:function(e){if(this.middlewares&&this.middlewares.length>0)return this.middlewares.shift().call(this,this.options,this.next.bind(this))}},{key:"run",value:function(e){return this.middlewares=this.cache.map((function(e){return e})),this.options=e,this.next()}}]),e}(),A="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function O(e,t){return e(t={exports:{}},t.exports),t.exports}var R=O((function(e,t){var o,n,a,s,r,i,c,u,l,d,p,g,_,h,f,m,M,v;e.exports=(o="function"==typeof Promise,n="object"==typeof self?self:A,a="undefined"!=typeof Symbol,s="undefined"!=typeof Map,r="undefined"!=typeof Set,i="undefined"!=typeof WeakMap,c="undefined"!=typeof WeakSet,u="undefined"!=typeof DataView,l=a&&void 0!==Symbol.iterator,d=a&&void 0!==Symbol.toStringTag,p=r&&"function"==typeof Set.prototype.entries,g=s&&"function"==typeof Map.prototype.entries,_=p&&Object.getPrototypeOf((new Set).entries()),h=g&&Object.getPrototypeOf((new Map).entries()),f=l&&"function"==typeof Array.prototype[Symbol.iterator],m=f&&Object.getPrototypeOf([][Symbol.iterator]()),M=l&&"function"==typeof String.prototype[Symbol.iterator],v=M&&Object.getPrototypeOf(""[Symbol.iterator]()),function(e){var t=typeof e;if("object"!==t)return t;if(null===e)return"null";if(e===n)return"global";if(Array.isArray(e)&&(!1===d||!(Symbol.toStringTag in e)))return"Array";if("object"==typeof window&&null!==window){if("object"==typeof window.location&&e===window.location)return"Location";if("object"==typeof window.document&&e===window.document)return"Document";if("object"==typeof window.navigator){if("object"==typeof window.navigator.mimeTypes&&e===window.navigator.mimeTypes)return"MimeTypeArray";if("object"==typeof window.navigator.plugins&&e===window.navigator.plugins)return"PluginArray"}if(("function"==typeof window.HTMLElement||"object"==typeof window.HTMLElement)&&e instanceof window.HTMLElement){if("BLOCKQUOTE"===e.tagName)return"HTMLQuoteElement";if("TD"===e.tagName)return"HTMLTableDataCellElement";if("TH"===e.tagName)return"HTMLTableHeaderCellElement"}}var a=d&&e[Symbol.toStringTag];if("string"==typeof a)return a;var l=Object.getPrototypeOf(e);return l===RegExp.prototype?"RegExp":l===Date.prototype?"Date":o&&l===Promise.prototype?"Promise":r&&l===Set.prototype?"Set":s&&l===Map.prototype?"Map":c&&l===WeakSet.prototype?"WeakSet":i&&l===WeakMap.prototype?"WeakMap":u&&l===DataView.prototype?"DataView":s&&l===h?"Map Iterator":r&&l===_?"Set Iterator":f&&l===m?"Array Iterator":M&&l===v?"String Iterator":null===l?"Object":Object.prototype.toString.call(e).slice(8,-1)})})),L=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;n(this,e),this.high=t,this.low=o}return s(e,[{key:"equal",value:function(e){return null!==e&&(this.low===e.low&&this.high===e.high)}},{key:"toString",value:function(){var e=Number(this.high).toString(16),t=Number(this.low).toString(16);if(t.length<8)for(var o=8-t.length;o;)t="0"+t,o--;return e+t}}]),e}(),k={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"}},PRODUCTION:{CHINA:{DEFAULT:"wss://wss.im.qcloud.com",BACKUP:"wss://wss.tim.qq.com",STAT:"https://api.im.qcloud.com"},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"},KOREA:{DEFAULT:"wss://wsskr.im.qcloud.com",BACKUP:"wss://wsskr.my-imcloud.com",STAT:"https://apikr.my-imcloud.com"},GERMANY:{DEFAULT:"wss://wssger.im.qcloud.com",BACKUP:"wss://wssger.my-imcloud.com",STAT:"https://apiger.my-imcloud.com"},IND:{DEFAULT:"wss://wssind.im.qcloud.com",BACKUP:"wss://wssind.my-imcloud.com",STAT:"https://apiind.my-imcloud.com"}}},G={WEB:7,WX_MP:8,QQ_MP:9,TT_MP:10,BAIDU_MP:11,ALI_MP:12,UNI_NATIVE_APP:15},P="1.7.3",U=537048168,w="CHINA",b="OVERSEA",F="SINGAPORE",q="KOREA",V="GERMANY",K="IND",H={HOST:{CURRENT:{DEFAULT:"wss://wss.im.qcloud.com",STAT:"https://api.im.qcloud.com"},setCurrent:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:w;this.CURRENT=k.PRODUCTION[e]}},NAME:{OPEN_IM:"openim",GROUP:"group_open_http_svc",GROUP_COMMUNITY:"million_group_open_http_svc",GROUP_ATTR:"group_open_attr_http_svc",FRIEND:"sns",PROFILE:"profile",RECENT_CONTACT:"recentcontact",PIC:"openpic",BIG_GROUP_NO_AUTH:"group_open_http_noauth_svc",BIG_GROUP_LONG_POLLING:"group_open_long_polling_http_svc",BIG_GROUP_LONG_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_MESSAGE:"im_long_msg",IM_CONFIG_MANAGER:"im_sdk_config_mgr",STAT_SERVICE:"StatSvc",OVERLOAD_PUSH:"OverLoadPush"},CMD:{ACCESS_LAYER:"accesslayer",LOGIN:"wslogin",LOGOUT_LONG_POLL:"longpollinglogout",LOGOUT:"wslogout",HELLO:"wshello",PORTRAIT_GET:"portrait_get_all",PORTRAIT_SET:"portrait_set",GET_LONG_POLL_ID:"getlongpollingid",LONG_POLL:"longpolling",AVCHATROOM_LONG_POLL:"get_msg",ADD_FRIEND:"friend_add",UPDATE_FRIEND:"friend_update",GET_FRIEND_LIST:"friend_get",GET_FRIEND_PROFILE:"friend_get_list",DELETE_FRIEND:"friend_delete",CHECK_FRIEND:"friend_check",GET_FRIEND_GROUP_LIST:"group_get",RESPOND_FRIEND_APPLICATION:"friend_response",GET_FRIEND_APPLICATION_LIST:"pendency_get",DELETE_FRIEND_APPLICATION:"pendency_delete",REPORT_FRIEND_APPLICATION:"pendency_report",GET_GROUP_APPLICATION:"get_pendency",CREATE_FRIEND_GROUP:"group_add",DELETE_FRIEND_GROUP:"group_delete",UPDATE_FRIEND_GROUP:"group_update",GET_BLACKLIST:"black_list_get",ADD_BLACKLIST:"black_list_add",DELETE_BLACKLIST:"black_list_delete",CREATE_GROUP:"create_group",GET_JOINED_GROUPS:"get_joined_group_list",SET_GROUP_ATTRIBUTES:"set_group_attr",MODIFY_GROUP_ATTRIBUTES:"modify_group_attr",DELETE_GROUP_ATTRIBUTES:"delete_group_attr",CLEAR_GROUP_ATTRIBUTES:"clear_group_attr",GET_GROUP_ATTRIBUTES:"get_group_attr",SEND_MESSAGE:"sendmsg",REVOKE_C2C_MESSAGE:"msgwithdraw",DELETE_C2C_MESSAGE:"delete_c2c_msg_ramble",MODIFY_C2C_MESSAGE:"modify_c2c_msg",SEND_GROUP_MESSAGE:"send_group_msg",REVOKE_GROUP_MESSAGE:"group_msg_recall",DELETE_GROUP_MESSAGE:"delete_group_ramble_msg_by_seq",MODIFY_GROUP_MESSAGE:"modify_group_msg",GET_GROUP_INFO:"get_group_self_member_info",GET_GROUP_MEMBER_INFO:"get_specified_group_member_info",GET_GROUP_MEMBER_LIST:"get_group_member_info",QUIT_GROUP:"quit_group",CHANGE_GROUP_OWNER:"change_group_owner",DESTROY_GROUP:"destroy_group",ADD_GROUP_MEMBER:"add_group_member",DELETE_GROUP_MEMBER:"delete_group_member",SEARCH_GROUP_BY_ID:"get_group_public_info",APPLY_JOIN_GROUP:"apply_join_group",HANDLE_APPLY_JOIN_GROUP:"handle_apply_join_group",HANDLE_GROUP_INVITATION:"handle_invite_join_group",MODIFY_GROUP_INFO:"modify_group_base_info",MODIFY_GROUP_MEMBER_INFO:"modify_group_member_info",DELETE_GROUP_SYSTEM_MESSAGE:"deletemsg",DELETE_GROUP_AT_TIPS:"deletemsg",GET_CONVERSATION_LIST:"get",PAGING_GET_CONVERSATION_LIST:"page_get",DELETE_CONVERSATION:"delete",PIN_CONVERSATION:"top",GET_MESSAGES:"getmsg",GET_C2C_ROAM_MESSAGES:"getroammsg",SET_C2C_PEER_MUTE_NOTIFICATIONS:"set_c2c_peer_mute_notifications",GET_C2C_PEER_MUTE_NOTIFICATIONS:"get_c2c_peer_mute_notifications",GET_GROUP_ROAM_MESSAGES:"group_msg_get",GET_READ_RECEIPT:"get_group_msg_receipt",GET_READ_RECEIPT_DETAIL:"get_group_msg_receipt_detail",SEND_READ_RECEIPT:"group_msg_receipt",SEND_C2C_READ_RECEIPT:"c2c_msg_read_receipt",SET_C2C_MESSAGE_READ:"msgreaded",GET_PEER_READ_TIME:"get_peer_read_time",SET_GROUP_MESSAGE_READ:"msg_read_report",FILE_READ_AND_WRITE_AUTHKEY:"authkey",FILE_UPLOAD:"pic_up",COS_SIGN:"cos",COS_PRE_SIG:"pre_sig",VIDEO_COVER:"video_cover",TIM_WEB_REPORT_V2:"tim_web_report_v2",BIG_DATA_HALLWAY_AUTH_KEY:"authkey",GET_ONLINE_MEMBER_NUM:"get_online_member_num",ALIVE:"alive",MESSAGE_PUSH:"msg_push",MULTI_MESSAGE_PUSH:"multi_msg_push_ws",MESSAGE_PUSH_ACK:"ws_msg_push_ack",STATUS_FORCE_OFFLINE:"stat_forceoffline",DOWNLOAD_MERGER_MESSAGE:"get_relay_json_msg",UPLOAD_MERGER_MESSAGE:"save_relay_json_msg",FETCH_CLOUD_CONTROL_CONFIG:"fetch_config",PUSHED_CLOUD_CONTROL_CONFIG:"push_configv2",FETCH_COMMERCIAL_CONFIG:"fetch_imsdk_purchase_bitsv2",PUSHED_COMMERCIAL_CONFIG:"push_imsdk_purchase_bitsv2",KICK_OTHER:"KickOther",OVERLOAD_NOTIFY:"notify2",SET_ALL_MESSAGE_READ:"read_all_unread_msg",CREATE_TOPIC:"create_topic",DELETE_TOPIC:"destroy_topic",UPDATE_TOPIC_PROFILE:"modify_topic",GET_TOPIC_LIST:"get_topic"},CHANNEL:{SOCKET:1,XHR:2,AUTO:0},NAME_VERSION:{openim:"v4",group_open_http_svc:"v4",sns:"v4",profile:"v4",recentcontact:"v4",openpic:"v4",group_open_http_noauth_svc:"v4",group_open_long_polling_http_svc:"v4",group_open_long_polling_http_noauth_svc:"v4",imopenstat:"v4",im_cos_sign_svr:"v4",im_cos_msg:"v4",webim:"v4",im_open_push:"v4",im_open_status:"v4"}},B={SEARCH_MSG:new L(0,Math.pow(2,0)).toString(),SEARCH_GRP_SNS:new L(0,Math.pow(2,1)).toString(),AVCHATROOM_HISTORY_MSG:new L(0,Math.pow(2,2)).toString(),GRP_COMMUNITY:new L(0,Math.pow(2,3)).toString(),MSG_TO_SPECIFIED_GRP_MBR:new L(0,Math.pow(2,4)).toString()};H.HOST.setCurrent(w);var x,W,Y,j,$="undefined"!=typeof wx&&"function"==typeof wx.getSystemInfoSync&&Boolean(wx.getSystemInfoSync().fontSizeSetting),z="undefined"!=typeof qq&&"function"==typeof qq.getSystemInfoSync&&Boolean(qq.getSystemInfoSync().fontSizeSetting),J="undefined"!=typeof tt&&"function"==typeof tt.getSystemInfoSync&&Boolean(tt.getSystemInfoSync().fontSizeSetting),X="undefined"!=typeof swan&&"function"==typeof swan.getSystemInfoSync&&Boolean(swan.getSystemInfoSync().fontSizeSetting),Q="undefined"!=typeof my&&"function"==typeof my.getSystemInfoSync&&Boolean(my.getSystemInfoSync().fontSizeSetting),Z="undefined"!=typeof uni&&"undefined"==typeof window,ee="undefined"!=typeof uni,te=$||z||J||X||Q||Z,oe=("undefined"!=typeof uni||"undefined"!=typeof window)&&!te,ne=z?qq:J?tt:X?swan:Q?my:$?wx:Z?uni:{},ae=(x="WEB",ve?x="WEB":z?x="QQ_MP":J?x="TT_MP":X?x="BAIDU_MP":Q?x="ALI_MP":$?x="WX_MP":Z&&(x="UNI_NATIVE_APP"),G[x]),se=oe&&window&&window.navigator&&window.navigator.userAgent||"",re=/AppleWebKit\/([\d.]+)/i.exec(se),ie=(re&&parseFloat(re.pop()),/iPad/i.test(se)),ce=/iPhone/i.test(se)&&!ie,ue=/iPod/i.test(se),le=ce||ie||ue,de=(W=se.match(/OS (\d+)_/i))&&W[1]?W[1]:null,pe=/Android/i.test(se),ge=function(){var e=se.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);if(!e)return null;var t=e[1]&&parseFloat(e[1]),o=e[2]&&parseFloat(e[2]);return t&&o?parseFloat(e[1]+"."+e[2]):t||null}(),_e=(pe&&/webkit/i.test(se),/Firefox/i.test(se),/Edge/i.test(se)),he=!_e&&/Chrome/i.test(se),fe=(function(){var e=se.match(/Chrome\/(\d+)/);e&&e[1]&&parseFloat(e[1])}(),/MSIE/.test(se)||se.indexOf("Trident")>-1&&se.indexOf("rv:11.0")>-1),me=(/MSIE\s8\.0/.test(se),function(){var e=/MSIE\s(\d+)\.\d/.exec(se),t=e&&parseFloat(e[1]);return!t&&/Trident\/7.0/i.test(se)&&/rv:11.0/.test(se)&&(t=11),t}()),Me=(/Safari/i.test(se),/TBS\/\d+/i.test(se)),ve=(function(){var e=se.match(/TBS\/(\d+)/i);if(e&&e[1])e[1]}(),!Me&&/MQQBrowser\/\d+/i.test(se),!Me&&/ QQBrowser\/\d+/i.test(se),/(micromessenger|webbrowser)/i.test(se)),ye=/Windows/i.test(se),Ie=/MAC OS X/i.test(se),Ee=(/MicroMessenger/i.test(se),oe&&"undefined"!=typeof Worker&&!fe),Te=pe||le,Ce="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};Y="undefined"!=typeof console?console:void 0!==Ce&&Ce.console?Ce.console:"undefined"!=typeof window&&window.console?window.console:{};for(var Se=function(){},De=["assert","clear","count","debug","dir","dirxml","error","group","groupCollapsed","groupEnd","info","log","profile","profileEnd","table","time","timeEnd","timeStamp","trace","warn"],Ne=De.length;Ne--;)j=De[Ne],console[j]||(Y[j]=Se);var Ae=Y,Oe=0,Re=function(){return(new Date).getTime()+Oe},Le=function(){Oe=0},ke=function(){return Math.floor(Re()/1e3)},Ge=0,Pe=new Map;function Ue(){var e,t=((e=new Date).setTime(Re()),e);return"TIM "+t.toLocaleTimeString("en-US",{hour12:!1})+"."+function(e){var t;switch(e.toString().length){case 1:t="00"+e;break;case 2:t="0"+e;break;default:t=e}return t}(t.getMilliseconds())+":"}var we={arguments2String:function(e){var t;if(1===e.length)t=Ue()+e[0];else{t=Ue();for(var o=0,n=e.length;o4294967295?(rt+=4294967295,Date.now()-rt):e},utc:function(){return Math.round(Date.now()/1e3)}},ct=function e(t,o,n,a){if(!et(t)||!et(o))return 0;for(var s,r=0,i=Object.keys(o),c=0,u=i.length;c=0?n[s]=t[s]:n[s]=e(t[s])):n[s]=void 0:n[s]=null;return n};function vt(e,t){Qe(e)&&Qe(t)?t.forEach((function(t){var o=t.key,n=t.value,a=e.find((function(e){return e.key===o}));a?a.value=n:e.push({key:o,value:n})})):we.warn("updateCustomField target 或 source 不是数组,忽略此次更新。")}var yt=function(e){return e===D.GRP_PUBLIC},It=function(e){return e===D.GRP_AVCHATROOM},Et=function(e){var t=e.type,o=e.groupID;return t===D.GRP_COMMUNITY||"".concat(o).startsWith(xe)&&!"".concat(o).includes(We)},Tt=function(e){return"".concat(e).startsWith(xe)&&"".concat(e).includes(We)},Ct=function(e){return ze(e)&&e.slice(0,3)===D.CONV_C2C},St=function(e){return ze(e)&&e.slice(0,5)===D.CONV_GROUP},Dt=function(e){return ze(e)&&e===D.CONV_SYSTEM};function Nt(e,t){var o={};return Object.keys(e).forEach((function(n){o[n]=t(e[n],n)})),o}function At(e){return te?new Promise((function(t,o){ne.getImageInfo({src:e,success:function(e){t({width:e.width,height:e.height})},fail:function(){t({width:0,height:0})}})})):fe&&9===me?Promise.resolve({width:0,height:0}):new Promise((function(t,o){var n=new Image;n.onload=function(){t({width:this.width,height:this.height}),n=null},n.onerror=function(){t({width:0,height:0}),n=null},n.src=e}))}function Ot(){function e(){return(65536*(1+Math.random())|0).toString(16).substring(1)}return"".concat(e()+e()).concat(e()).concat(e()).concat(e()).concat(e()).concat(e()).concat(e())}function Rt(){var e="unknown";if(Ie&&(e="mac"),ye&&(e="windows"),le&&(e="ios"),pe&&(e="android"),te)try{var t=ne.getSystemInfoSync().platform;void 0!==t&&(e=t)}catch(o){}return e}function Lt(e){var t=e.originUrl,o=void 0===t?void 0:t,n=e.originWidth,a=e.originHeight,s=e.min,r=void 0===s?198:s,i=parseInt(n),c=parseInt(a),u={url:void 0,width:0,height:0};if((i<=c?i:c)<=r)u.url=o,u.width=i,u.height=c;else{c<=i?(u.width=Math.ceil(i*r/c),u.height=r):(u.width=r,u.height=Math.ceil(c*r/i));var l=o&&o.indexOf("?")>-1?"".concat(o,"&"):"".concat(o,"?");u.url="".concat(l,198===r?"imageView2/3/w/198/h/198":"imageView2/3/w/720/h/720")}return Ze(o)?g(u,Ye):u}function kt(e){var t=e[2];e[2]=e[1],e[1]=t;for(var o=0;o=0}}},setGroupMemberNameCard:{groupID:zt,userID:{type:"String"},nameCard:{type:"String",validator:function(e){return ze(e)?(e.length,!0):(console.warn($t({api:"setGroupMemberNameCard",param:"nameCard",desc:"类型必须为 String"})),!1)}}},setGroupMemberCustomField:{groupID:zt,userID:{type:"String"},memberCustomField:Jt},deleteGroupMember:{groupID:zt},createTextMessage:{to:zt,conversationType:zt,payload:t(t({},Xt),{},{validator:function(e){return Xe(e)?ze(e.text)?0!==e.text.length||(console.warn($t({api:"createTextMessage",desc:"消息内容不能为空"})),!1):(console.warn($t({api:"createTextMessage",param:"payload.text",desc:"类型必须为 String"})),!1):(console.warn($t({api:"createTextMessage",param:"payload",desc:"类型必须为 plain object"})),!1)}})},createTextAtMessage:{to:zt,conversationType:zt,payload:t(t({},Xt),{},{validator:function(e){return Xe(e)?ze(e.text)?0===e.text.length?(console.warn($t({api:"createTextAtMessage",desc:"消息内容不能为空"})),!1):!(e.atUserList&&!Qe(e.atUserList))||(console.warn($t({api:"createTextAtMessage",desc:"payload.atUserList 类型必须为数组"})),!1):(console.warn($t({api:"createTextAtMessage",param:"payload.text",desc:"类型必须为 String"})),!1):(console.warn($t({api:"createTextAtMessage",param:"payload",desc:"类型必须为 plain object"})),!1)}})},createCustomMessage:{to:zt,conversationType:zt,payload:t(t({},Xt),{},{validator:function(e){return Xe(e)?e.data&&!ze(e.data)?(console.warn($t({api:"createCustomMessage",param:"payload.data",desc:"类型必须为 String"})),!1):e.description&&!ze(e.description)?(console.warn($t({api:"createCustomMessage",param:"payload.description",desc:"类型必须为 String"})),!1):!(e.extension&&!ze(e.extension))||(console.warn($t({api:"createCustomMessage",param:"payload.extension",desc:"类型必须为 String"})),!1):(console.warn($t({api:"createCustomMessage",param:"payload",desc:"类型必须为 plain object"})),!1)}})},createImageMessage:{to:zt,conversationType:zt,payload:t(t({},Xt),{},{validator:function(e){if(!Xe(e))return console.warn($t({api:"createImageMessage",param:"payload",desc:"类型必须为 plain object"})),!1;if(Ze(e.file))return console.warn($t({api:"createImageMessage",param:"payload.file",desc:"不能为 undefined"})),!1;if(oe){if(!(e.file instanceof HTMLInputElement||je(e.file)))return Xe(e.file)&&"undefined"!=typeof uni?0!==e.file.tempFilePaths.length&&0!==e.file.tempFiles.length||(console.warn($t({api:"createImageMessage",param:"payload.file",desc:"您没有选择文件,无法发送"})),!1):(console.warn($t({api:"createImageMessage",param:"payload.file",desc:"类型必须是 HTMLInputElement 或 File"})),!1);if(e.file instanceof HTMLInputElement&&0===e.file.files.length)return console.warn($t({api:"createImageMessage",param:"payload.file",desc:"您没有选择文件,无法发送"})),!1}return!0},onProgress:{type:"Function",required:!1,validator:function(e){return Ze(e)&&console.warn($t({api:"createImageMessage",desc:"没有 onProgress 回调,您将无法获取上传进度"})),!0}}})},createAudioMessage:{to:zt,conversationType:zt,payload:t(t({},Xt),{},{validator:function(e){return!!Xe(e)||(console.warn($t({api:"createAudioMessage",param:"payload",desc:"类型必须为 plain object"})),!1)}}),onProgress:{type:"Function",required:!1,validator:function(e){return Ze(e)&&console.warn($t({api:"createAudioMessage",desc:"没有 onProgress 回调,您将无法获取上传进度"})),!0}}},createVideoMessage:{to:zt,conversationType:zt,payload:t(t({},Xt),{},{validator:function(e){if(!Xe(e))return console.warn($t({api:"createVideoMessage",param:"payload",desc:"类型必须为 plain object"})),!1;if(Ze(e.file))return console.warn($t({api:"createVideoMessage",param:"payload.file",desc:"不能为 undefined"})),!1;if(oe){if(!(e.file instanceof HTMLInputElement||je(e.file)))return Xe(e.file)&&"undefined"!=typeof uni?!!je(e.file.tempFile)||(console.warn($t({api:"createVideoMessage",param:"payload.file",desc:"您没有选择文件,无法发送"})),!1):(console.warn($t({api:"createVideoMessage",param:"payload.file",desc:"类型必须是 HTMLInputElement 或 File"})),!1);if(e.file instanceof HTMLInputElement&&0===e.file.files.length)return console.warn($t({api:"createVideoMessage",param:"payload.file",desc:"您没有选择文件,无法发送"})),!1}return!0}}),onProgress:{type:"Function",required:!1,validator:function(e){return Ze(e)&&console.warn($t({api:"createVideoMessage",desc:"没有 onProgress 回调,您将无法获取上传进度"})),!0}}},createFaceMessage:{to:zt,conversationType:zt,payload:t(t({},Xt),{},{validator:function(e){return Xe(e)?$e(e.index)?!!ze(e.data)||(console.warn($t({api:"createFaceMessage",param:"payload.data",desc:"类型必须为 String"})),!1):(console.warn($t({api:"createFaceMessage",param:"payload.index",desc:"类型必须为 Number"})),!1):(console.warn($t({api:"createFaceMessage",param:"payload",desc:"类型必须为 plain object"})),!1)}})},createFileMessage:{to:zt,conversationType:zt,payload:t(t({},Xt),{},{validator:function(e){if(!Xe(e))return console.warn($t({api:"createFileMessage",param:"payload",desc:"类型必须为 plain object"})),!1;if(Ze(e.file))return console.warn($t({api:"createFileMessage",param:"payload.file",desc:"不能为 undefined"})),!1;if(oe){if(!(e.file instanceof HTMLInputElement||je(e.file)))return Xe(e.file)&&"undefined"!=typeof uni?0!==e.file.tempFilePaths.length&&0!==e.file.tempFiles.length||(console.warn($t({api:"createFileMessage",param:"payload.file",desc:"您没有选择文件,无法发送"})),!1):(console.warn($t({api:"createFileMessage",param:"payload.file",desc:"类型必须是 HTMLInputElement 或 File"})),!1);if(e.file instanceof HTMLInputElement&&0===e.file.files.length)return console.warn($t({api:"createFileMessage",desc:"您没有选择文件,无法发送"})),!1}return!0}}),onProgress:{type:"Function",required:!1,validator:function(e){return Ze(e)&&console.warn($t({api:"createFileMessage",desc:"没有 onProgress 回调,您将无法获取上传进度"})),!0}}},createLocationMessage:{to:zt,conversationType:zt,payload:t(t({},Xt),{},{validator:function(e){return Xe(e)?ze(e.description)?$e(e.longitude)?!!$e(e.latitude)||(console.warn($t({api:"createLocationMessage",param:"payload.latitude",desc:"类型必须为 Number"})),!1):(console.warn($t({api:"createLocationMessage",param:"payload.longitude",desc:"类型必须为 Number"})),!1):(console.warn($t({api:"createLocationMessage",param:"payload.description",desc:"类型必须为 String"})),!1):(console.warn($t({api:"createLocationMessage",param:"payload",desc:"类型必须为 plain object"})),!1)}})},createMergerMessage:{to:zt,conversationType:zt,payload:t(t({},Xt),{},{validator:function(e){if(Vt(e.messageList))return console.warn($t({api:"createMergerMessage",desc:"不能为空数组"})),!1;if(Vt(e.compatibleText))return console.warn($t({api:"createMergerMessage",desc:"类型必须为 String,且不能为空"})),!1;var t=!1;return e.messageList.forEach((function(e){e.status===xt.FAIL&&(t=!0)})),!t||(console.warn($t({api:"createMergerMessage",desc:"不支持合并已发送失败的消息"})),!1)}})},revokeMessage:[t(t({name:"message"},Xt),{},{validator:function(e){return Vt(e)?(console.warn($t({api:"revokeMessage",desc:"请传入消息(Message)实例"})),!1):e.conversationType===D.CONV_SYSTEM?(console.warn($t({api:"revokeMessage",desc:"不能撤回系统会话消息,只能撤回单聊消息或群消息"})),!1):!0!==e.isRevoked||(console.warn($t({api:"revokeMessage",desc:"消息已经被撤回,请勿重复操作"})),!1)}})],deleteMessage:[t(t({name:"messageList"},Jt),{},{validator:function(e){return!Vt(e)||(console.warn($t({api:"deleteMessage",param:"messageList",desc:"不能为空数组"})),!1)}})],modifyMessage:[t(t({name:"message"},Xt),{},{validator:function(e){return Vt(e)?(console.warn($t({api:"modifyMessage",desc:"请传入消息(Message)实例"})),!1):e.conversationType===D.CONV_SYSTEM?(console.warn($t({api:"modifyMessage",desc:"不支持修改系统会话消息,只能修改单聊消息或群消息"})),!1):!0===e._onlineOnlyFlag?(console.warn($t({api:"modifyMessage",desc:"不支持修改在线消息"})),!1):-1!==[D.MSG_TEXT,D.MSG_CUSTOM,D.MSG_LOCATION,D.MSG_FACE].indexOf(e.type)||(console.warn($t({api:"modifyMessage",desc:"只支持修改文本消息、自定义消息、地理位置消息和表情消息"})),!1)}})],getUserProfile:{userIDList:{type:"Array",validator:function(e){return Qe(e)?(0===e.length&&console.warn($t({api:"getUserProfile",param:"userIDList",desc:"不能为空数组"})),!0):(console.warn($t({api:"getUserProfile",param:"userIDList",desc:"必须为数组"})),!1)}}},updateMyProfile:{profileCustomField:{type:"Array",validator:function(e){return!!Ze(e)||(!!Qe(e)||(console.warn($t({api:"updateMyProfile",param:"profileCustomField",desc:"必须为数组"})),!1))}}},addFriend:{to:zt,source:{type:"String",required:!0,validator:function(e){return!!e&&(e.startsWith("AddSource_Type_")?!(e.replace("AddSource_Type_","").length>8)||(console.warn($t({api:"addFriend",desc:"加好友来源字段的关键字长度不得超过8字节"})),!1):(console.warn($t({api:"addFriend",desc:"加好友来源字段的前缀必须是:AddSource_Type_"})),!1))}},remark:{type:"String",required:!1,validator:function(e){return!(ze(e)&&e.length>96)||(console.warn($t({api:"updateFriend",desc:" 备注长度最长不得超过 96 个字节"})),!1)}}},deleteFriend:{userIDList:Jt},checkFriend:{userIDList:Jt},getFriendProfile:{userIDList:Jt},updateFriend:{userID:zt,remark:{type:"String",required:!1,validator:function(e){return!(ze(e)&&e.length>96)||(console.warn($t({api:"updateFriend",desc:" 备注长度最长不得超过 96 个字节"})),!1)}},friendCustomField:{type:"Array",required:!1,validator:function(e){if(e){if(!Qe(e))return console.warn($t({api:"updateFriend",param:"friendCustomField",desc:"必须为数组"})),!1;var t=!0;return e.forEach((function(e){return ze(e.key)&&-1!==e.key.indexOf("Tag_SNS_Custom")?ze(e.value)?e.value.length>8?(console.warn($t({api:"updateFriend",desc:"好友自定义字段的关键字长度不得超过8字节"})),t=!1):void 0:(console.warn($t({api:"updateFriend",desc:"类型必须为 String"})),t=!1):(console.warn($t({api:"updateFriend",desc:"好友自定义字段的前缀必须是 Tag_SNS_Custom"})),t=!1)})),t}return!0}}},acceptFriendApplication:{userID:zt},refuseFriendApplication:{userID:zt},deleteFriendApplication:{userID:zt},createFriendGroup:{name:zt},deleteFriendGroup:{name:zt},addToFriendGroup:{name:zt,userIDList:Jt},removeFromFriendGroup:{name:zt,userIDList:Jt},renameFriendGroup:{oldName:zt,newName:zt},sendMessageReadReceipt:[{name:"messageList",type:"Array",validator:function(e){return Qe(e)?0!==e.length||(console.warn($t({api:"sendMessageReadReceipt",param:"messageList",desc:"不能为空数组"})),!1):(console.warn($t({api:"sendMessageReadReceipt",param:"messageList",desc:"必须为数组"})),!1)}}],getMessageReadReceiptList:[{name:"messageList",type:"Array",validator:function(e){return Qe(e)?0!==e.length||(console.warn($t({api:"getMessageReadReceiptList",param:"messageList",desc:"不能为空数组"})),!1):(console.warn($t({api:"getMessageReadReceiptList",param:"messageList",desc:"必须为数组"})),!1)}}],createTopicInCommunity:{groupID:zt,topicName:zt},deleteTopicFromCommunity:{groupID:zt,topicIDList:{type:"Array",validator:function(e){return!e||(!!Qe(e)||(console.warn($t({api:"deleteTopicFromCommunity",param:"topicIDList",desc:"必须为数组"})),!1))}}},updateTopicProfile:{groupID:zt,topicID:zt},getTopicList:{groupID:zt,topicIDList:{type:"Array",validator:function(e){return!e||(!!Qe(e)||(console.warn($t({api:"getTopicList",param:"topicIDList",desc:"必须为数组"})),!1))}}}},Zt={login:"login",logout:"logout",on:"on",once:"once",off:"off",setLogLevel:"setLogLevel",registerPlugin:"registerPlugin",destroy:"destroy",createTextMessage:"createTextMessage",createTextAtMessage:"createTextAtMessage",createImageMessage:"createImageMessage",createAudioMessage:"createAudioMessage",createVideoMessage:"createVideoMessage",createCustomMessage:"createCustomMessage",createFaceMessage:"createFaceMessage",createFileMessage:"createFileMessage",createLocationMessage:"createLocationMessage",createMergerMessage:"createMergerMessage",downloadMergerMessage:"downloadMergerMessage",createForwardMessage:"createForwardMessage",sendMessage:"sendMessage",resendMessage:"resendMessage",revokeMessage:"revokeMessage",deleteMessage:"deleteMessage",modifyMessage:"modifyMessage",sendMessageReadReceipt:"sendMessageReadReceipt",getGroupMessageReadMemberList:"getGroupMessageReadMemberList",getMessageReadReceiptList:"getMessageReadReceiptList",getMessageList:"getMessageList",findMessage:"findMessage",getMessageListHopping:"getMessageListHopping",setMessageRead:"setMessageRead",setAllMessageRead:"setAllMessageRead",getConversationList:"getConversationList",getConversationProfile:"getConversationProfile",deleteConversation:"deleteConversation",pinConversation:"pinConversation",getGroupList:"getGroupList",getGroupProfile:"getGroupProfile",createGroup:"createGroup",joinGroup:"joinGroup",updateGroupProfile:"updateGroupProfile",quitGroup:"quitGroup",dismissGroup:"dismissGroup",changeGroupOwner:"changeGroupOwner",searchGroupByID:"searchGroupByID",setMessageRemindType:"setMessageRemindType",handleGroupApplication:"handleGroupApplication",initGroupAttributes:"initGroupAttributes",setGroupAttributes:"setGroupAttributes",deleteGroupAttributes:"deleteGroupAttributes",getGroupAttributes:"getGroupAttributes",getJoinedCommunityList:"getJoinedCommunityList",createTopicInCommunity:"createTopicInCommunity",deleteTopicFromCommunity:"deleteTopicFromCommunity",updateTopicProfile:"updateTopicProfile",getTopicList:"getTopicList",getGroupMemberProfile:"getGroupMemberProfile",getGroupMemberList:"getGroupMemberList",addGroupMember:"addGroupMember",deleteGroupMember:"deleteGroupMember",setGroupMemberNameCard:"setGroupMemberNameCard",setGroupMemberMuteTime:"setGroupMemberMuteTime",setGroupMemberRole:"setGroupMemberRole",setGroupMemberCustomField:"setGroupMemberCustomField",getGroupOnlineMemberCount:"getGroupOnlineMemberCount",getMyProfile:"getMyProfile",getUserProfile:"getUserProfile",updateMyProfile:"updateMyProfile",getBlacklist:"getBlacklist",addToBlacklist:"addToBlacklist",removeFromBlacklist:"removeFromBlacklist",getFriendList:"getFriendList",addFriend:"addFriend",deleteFriend:"deleteFriend",checkFriend:"checkFriend",updateFriend:"updateFriend",getFriendProfile:"getFriendProfile",getFriendApplicationList:"getFriendApplicationList",refuseFriendApplication:"refuseFriendApplication",deleteFriendApplication:"deleteFriendApplication",acceptFriendApplication:"acceptFriendApplication",setFriendApplicationRead:"setFriendApplicationRead",getFriendGroupList:"getFriendGroupList",createFriendGroup:"createFriendGroup",renameFriendGroup:"renameFriendGroup",deleteFriendGroup:"deleteFriendGroup",addToFriendGroup:"addToFriendGroup",removeFromFriendGroup:"removeFromFriendGroup",callExperimentalAPI:"callExperimentalAPI"},eo="sign",to="message",oo="user",no="c2c",ao="group",so="sns",ro="groupMember",io="Topic",co="conversation",uo="context",lo="storage",po="eventStat",go="netMonitor",_o="bigDataChannel",ho="upload",fo="plugin",mo="syncUnreadMessage",Mo="session",vo="channel",yo="message_loss_detection",Io="cloudControl",Eo="workerTimer",To="pullGroupMessage",Co="qualityStat",So="commercialConfig",Do=function(){function e(t){n(this,e),this._moduleManager=t,this._className=""}return s(e,[{key:"isLoggedIn",value:function(){return this._moduleManager.getModule(uo).isLoggedIn()}},{key:"isOversea",value:function(){return this._moduleManager.getModule(uo).isOversea()}},{key:"isPrivateNetWork",value:function(){return this._moduleManager.getModule(uo).isPrivateNetWork()}},{key:"getMyUserID",value:function(){return this._moduleManager.getModule(uo).getUserID()}},{key:"getMyTinyID",value:function(){return this._moduleManager.getModule(uo).getTinyID()}},{key:"getModule",value:function(e){return this._moduleManager.getModule(e)}},{key:"getPlatform",value:function(){return ae}},{key:"getNetworkType",value:function(){return this._moduleManager.getModule(go).getNetworkType()}},{key:"probeNetwork",value:function(e){return this.isPrivateNetWork()?Promise.resolve([!0,this.getNetworkType()]):this._moduleManager.getModule(go).probe(e)}},{key:"getCloudConfig",value:function(e){return this._moduleManager.getModule(Io).getCloudConfig(e)}},{key:"emitOuterEvent",value:function(e,t){this._moduleManager.getOuterEmitterInstance().emit(e,t)}},{key:"emitInnerEvent",value:function(e,t){this._moduleManager.getInnerEmitterInstance().emit(e,t)}},{key:"getInnerEmitterInstance",value:function(){return this._moduleManager.getInnerEmitterInstance()}},{key:"generateTjgID",value:function(e){return this._moduleManager.getModule(uo).getTinyID()+"-"+e.random}},{key:"filterModifiedMessage",value:function(e){if(!Vt(e)){var t=e.filter((function(e){return!0===e.isModified}));t.length>0&&this.emitOuterEvent(S.MESSAGE_MODIFIED,t)}}},{key:"filterUnmodifiedMessage",value:function(e){return Vt(e)?[]:e.filter((function(e){return!1===e.isModified}))}},{key:"request",value:function(e){return this._moduleManager.getModule(Mo).request(e)}},{key:"canIUse",value:function(e){return this._moduleManager.getModule(So).hasPurchasedFeature(e)}}]),e}(),No="wslogin",Ao="wslogout",Oo="wshello",Ro="KickOther",Lo="getmsg",ko="authkey",Go="sendmsg",Po="send_group_msg",Uo="portrait_get_all",wo="portrait_set",bo="black_list_get",Fo="black_list_add",qo="black_list_delete",Vo="msgwithdraw",Ko="msgreaded",Ho="set_c2c_peer_mute_notifications",Bo="get_c2c_peer_mute_notifications",xo="getroammsg",Wo="get_peer_read_time",Yo="delete_c2c_msg_ramble",jo="modify_c2c_msg",$o="page_get",zo="get",Jo="delete",Xo="top",Qo="deletemsg",Zo="get_joined_group_list",en="get_group_self_member_info",tn="create_group",on="destroy_group",nn="modify_group_base_info",an="apply_join_group",sn="apply_join_group_noauth",rn="quit_group",cn="get_group_public_info",un="change_group_owner",ln="handle_apply_join_group",dn="handle_invite_join_group",pn="group_msg_recall",gn="msg_read_report",_n="read_all_unread_msg",hn="group_msg_get",fn="get_group_msg_receipt",mn="group_msg_receipt",Mn="c2c_msg_read_receipt",vn="get_group_msg_receipt_detail",yn="get_pendency",In="deletemsg",En="get_msg",Tn="get_msg_noauth",Cn="get_online_member_num",Sn="delete_group_ramble_msg_by_seq",Dn="modify_group_msg",Nn="set_group_attr",An="modify_group_attr",On="delete_group_attr",Rn="clear_group_attr",Ln="get_group_attr",kn="get_group_member_info",Gn="get_specified_group_member_info",Pn="add_group_member",Un="delete_group_member",wn="modify_group_member_info",bn="cos",Fn="pre_sig",qn="video_cover",Vn="tim_web_report_v2",Kn="alive",Hn="msg_push",Bn="multi_msg_push_ws",xn="ws_msg_push_ack",Wn="stat_forceoffline",Yn="save_relay_json_msg",jn="get_relay_json_msg",$n="fetch_config",zn="push_configv2",Jn="fetch_imsdk_purchase_bitsv2",Xn="push_imsdk_purchase_bitsv2",Qn="notify2",Zn="create_topic",ea="destroy_topic",ta="modify_topic",oa="get_topic",na={NO_SDKAPPID:2e3,NO_ACCOUNT_TYPE:2001,NO_IDENTIFIER:2002,NO_USERSIG:2003,NO_TINYID:2022,NO_A2KEY:2023,USER_NOT_LOGGED_IN:2024,REPEAT_LOGIN:2025,COS_UNDETECTED:2040,COS_GET_SIG_FAIL:2041,MESSAGE_SEND_FAIL:2100,MESSAGE_LIST_CONSTRUCTOR_NEED_OPTIONS:2103,MESSAGE_SEND_NEED_MESSAGE_INSTANCE:2105,MESSAGE_SEND_INVALID_CONVERSATION_TYPE:2106,MESSAGE_FILE_IS_EMPTY:2108,MESSAGE_ONPROGRESS_FUNCTION_ERROR:2109,MESSAGE_REVOKE_FAIL:2110,MESSAGE_DELETE_FAIL:2111,MESSAGE_UNREAD_ALL_FAIL:2112,MESSAGE_CONTROL_INFO_FAIL:2113,READ_RECEIPT_MESSAGE_LIST_EMPTY:2114,MESSAGE_SEND_GROUP_WITH_TOPIC_FAIL:2115,CANNOT_DELETE_GROUP_SYSTEM_NOTICE:2116,MESSAGE_IMAGE_SELECT_FILE_FIRST:2251,MESSAGE_IMAGE_TYPES_LIMIT:2252,MESSAGE_IMAGE_SIZE_LIMIT:2253,MESSAGE_AUDIO_UPLOAD_FAIL:2300,MESSAGE_AUDIO_SIZE_LIMIT:2301,MESSAGE_VIDEO_UPLOAD_FAIL:2350,MESSAGE_VIDEO_SIZE_LIMIT:2351,MESSAGE_VIDEO_TYPES_LIMIT:2352,MESSAGE_FILE_UPLOAD_FAIL:2400,MESSAGE_FILE_SELECT_FILE_FIRST:2401,MESSAGE_FILE_SIZE_LIMIT:2402,MESSAGE_FILE_URL_IS_EMPTY:2403,MESSAGE_MERGER_TYPE_INVALID:2450,MESSAGE_MERGER_KEY_INVALID:2451,MESSAGE_MERGER_DOWNLOAD_FAIL:2452,MESSAGE_FORWARD_TYPE_INVALID:2453,MESSAGE_AT_TYPE_INVALID:2454,MESSAGE_MODIFY_CONFLICT:2480,MESSAGE_MODIFY_DISABLED_IN_AVCHATROOM:2481,CONVERSATION_NOT_FOUND:2500,USER_OR_GROUP_NOT_FOUND:2501,CONVERSATION_UN_RECORDED_TYPE:2502,ILLEGAL_GROUP_TYPE:2600,CANNOT_JOIN_WORK:2601,ILLEGAL_GROUP_ID:2602,CANNOT_CHANGE_OWNER_IN_AVCHATROOM:2620,CANNOT_CHANGE_OWNER_TO_SELF:2621,CANNOT_DISMISS_Work:2622,MEMBER_NOT_IN_GROUP:2623,CANNOT_USE_GRP_ATTR_NOT_AVCHATROOM:2641,CANNOT_USE_GRP_ATTR_AVCHATROOM_UNJOIN:2642,JOIN_GROUP_FAIL:2660,CANNOT_ADD_MEMBER_IN_AVCHATROOM:2661,CANNOT_JOIN_NON_AVCHATROOM_WITHOUT_LOGIN:2662,CANNOT_KICK_MEMBER_IN_AVCHATROOM:2680,NOT_OWNER:2681,CANNOT_SET_MEMBER_ROLE_IN_WORK_AND_AVCHATROOM:2682,INVALID_MEMBER_ROLE:2683,CANNOT_SET_SELF_MEMBER_ROLE:2684,CANNOT_MUTE_SELF:2685,NOT_MY_FRIEND:2700,ALREADY_MY_FRIEND:2701,FRIEND_GROUP_EXISTED:2710,FRIEND_GROUP_NOT_EXIST:2711,FRIEND_APPLICATION_NOT_EXIST:2716,UPDATE_PROFILE_INVALID_PARAM:2721,UPDATE_PROFILE_NO_KEY:2722,ADD_BLACKLIST_INVALID_PARAM:2740,DEL_BLACKLIST_INVALID_PARAM:2741,CANNOT_ADD_SELF_TO_BLACKLIST:2742,ADD_FRIEND_INVALID_PARAM:2760,NETWORK_ERROR:2800,NETWORK_TIMEOUT:2801,NETWORK_BASE_OPTIONS_NO_URL:2802,NETWORK_UNDEFINED_SERVER_NAME:2803,NETWORK_PACKAGE_UNDEFINED:2804,NO_NETWORK:2805,CONVERTOR_IRREGULAR_PARAMS:2900,NOTICE_RUNLOOP_UNEXPECTED_CONDITION:2901,NOTICE_RUNLOOP_OFFSET_LOST:2902,UNCAUGHT_ERROR:2903,GET_LONGPOLL_ID_FAILED:2904,INVALID_OPERATION:2905,OVER_FREQUENCY_LIMIT:2996,CANNOT_FIND_PROTOCOL:2997,CANNOT_FIND_MODULE:2998,SDK_IS_NOT_READY:2999,LOGGING_IN:3e3,LOGIN_FAILED:3001,KICKED_OUT_MULT_DEVICE:3002,KICKED_OUT_MULT_ACCOUNT:3003,KICKED_OUT_USERSIG_EXPIRED:3004,LOGGED_OUT:3005,KICKED_OUT_REST_API:3006,ILLEGAL_TOPIC_ID:3021,LONG_POLL_KICK_OUT:91101,MESSAGE_A2KEY_EXPIRED:20002,ACCOUNT_A2KEY_EXPIRED:70001,LONG_POLL_API_PARAM_ERROR:90001,HELLO_ANSWER_KICKED_OUT:1002,OPEN_SERVICE_OVERLOAD_ERROR:60022},aa={NO_SDKAPPID:"无 SDKAppID",NO_ACCOUNT_TYPE:"无 accountType",NO_IDENTIFIER:"无 userID",NO_USERSIG:"无 userSig",NO_TINYID:"无 tinyID",NO_A2KEY:"无 a2key",USER_NOT_LOGGED_IN:"用户未登录",REPEAT_LOGIN:"重复登录",COS_UNDETECTED:"未检测到 COS 上传插件",COS_GET_SIG_FAIL:"获取 COS 预签名 URL 失败",MESSAGE_SEND_FAIL:"消息发送失败",MESSAGE_LIST_CONSTRUCTOR_NEED_OPTIONS:"MessageController.constructor() 需要参数 options",MESSAGE_SEND_NEED_MESSAGE_INSTANCE:"需要 Message 的实例",MESSAGE_SEND_INVALID_CONVERSATION_TYPE:'Message.conversationType 只能为 "C2C" 或 "GROUP"',MESSAGE_FILE_IS_EMPTY:"无法发送空文件",MESSAGE_ONPROGRESS_FUNCTION_ERROR:"回调函数运行时遇到错误,请检查接入侧代码",MESSAGE_REVOKE_FAIL:"消息撤回失败",MESSAGE_DELETE_FAIL:"消息删除失败",MESSAGE_UNREAD_ALL_FAIL:"设置所有未读消息为已读处理失败",MESSAGE_CONTROL_INFO_FAIL:"社群不支持消息发送控制选项",READ_RECEIPT_MESSAGE_LIST_EMPTY:"消息列表中没有需要发送已读回执的消息",MESSAGE_SEND_GROUP_WITH_TOPIC_FAIL:"不能在支持话题的群组中发消息,请检查群组 isSupportTopic 属性",CANNOT_DELETE_GROUP_SYSTEM_NOTICE:"不支持删除群系统通知",MESSAGE_IMAGE_SELECT_FILE_FIRST:"请先选择一个图片",MESSAGE_IMAGE_TYPES_LIMIT:"只允许上传 jpg png jpeg gif bmp image webp 格式的图片",MESSAGE_IMAGE_SIZE_LIMIT:"图片大小超过20M,无法发送",MESSAGE_AUDIO_UPLOAD_FAIL:"语音上传失败",MESSAGE_AUDIO_SIZE_LIMIT:"语音大小大于20M,无法发送",MESSAGE_VIDEO_UPLOAD_FAIL:"视频上传失败",MESSAGE_VIDEO_SIZE_LIMIT:"视频大小超过100M,无法发送",MESSAGE_VIDEO_TYPES_LIMIT:"只允许上传 mp4 格式的视频",MESSAGE_FILE_UPLOAD_FAIL:"文件上传失败",MESSAGE_FILE_SELECT_FILE_FIRST:"请先选择一个文件",MESSAGE_FILE_SIZE_LIMIT:"文件大小超过100M,无法发送 ",MESSAGE_FILE_URL_IS_EMPTY:"缺少必要的参数文件 URL",MESSAGE_MERGER_TYPE_INVALID:"非合并消息",MESSAGE_MERGER_KEY_INVALID:"合并消息的 messageKey 无效",MESSAGE_MERGER_DOWNLOAD_FAIL:"下载合并消息失败",MESSAGE_FORWARD_TYPE_INVALID:"选择的消息类型(如群提示消息)不可以转发",MESSAGE_AT_TYPE_INVALID:"社群/话题不支持 @ 所有人",MESSAGE_MODIFY_CONFLICT:"修改消息时发生冲突",MESSAGE_MODIFY_DISABLED_IN_AVCHATROOM:"直播群不支持修改消息",CONVERSATION_NOT_FOUND:"没有找到相应的会话,请检查传入参数",USER_OR_GROUP_NOT_FOUND:"没有找到相应的用户或群组,请检查传入参数",CONVERSATION_UN_RECORDED_TYPE:"未记录的会话类型",ILLEGAL_GROUP_TYPE:"非法的群类型,请检查传入参数",CANNOT_JOIN_WORK:"不能加入 Work 类型的群组",ILLEGAL_GROUP_ID:"群组 ID 非法,非 Community 类型群组不能以 @TGS#_ 为前缀,Community 类型群组必须以 @TGS#_ 为前缀且不能包含 @TOPIC#_ 字符串",CANNOT_CHANGE_OWNER_IN_AVCHATROOM:"AVChatRoom 类型的群组不能转让群主",CANNOT_CHANGE_OWNER_TO_SELF:"不能把群主转让给自己",CANNOT_DISMISS_WORK:"不能解散 Work 类型的群组",MEMBER_NOT_IN_GROUP:"用户不在该群组内",JOIN_GROUP_FAIL:"加群失败,请检查传入参数或重试",CANNOT_ADD_MEMBER_IN_AVCHATROOM:"AVChatRoom 类型的群不支持邀请群成员",CANNOT_JOIN_NON_AVCHATROOM_WITHOUT_LOGIN:"非 AVChatRoom 类型的群组不允许匿名加群,请先登录后再加群",CANNOT_KICK_MEMBER_IN_AVCHATROOM:"不能在 AVChatRoom 类型的群组踢人",NOT_OWNER:"你不是群主,只有群主才有权限操作",CANNOT_SET_MEMBER_ROLE_IN_WORK_AND_AVCHATROOM:"不能在 Work / AVChatRoom 类型的群中设置群成员身份",INVALID_MEMBER_ROLE:"不合法的群成员身份,请检查传入参数",CANNOT_SET_SELF_MEMBER_ROLE:"不能设置自己的群成员身份,请检查传入参数",CANNOT_MUTE_SELF:"不能将自己禁言,请检查传入参数",NOT_MY_FRIEND:"非好友关系",ALREADY_MY_FRIEND:"已经是好友关系",FRIEND_GROUP_EXISTED:"好友分组已存在",FRIEND_GROUP_NOT_EXIST:"好友分组不存在",FRIEND_APPLICATION_NOT_EXIST:"好友申请不存在",UPDATE_PROFILE_INVALID_PARAM:"传入 updateMyProfile 接口的参数无效",UPDATE_PROFILE_NO_KEY:"updateMyProfile 无标配资料字段或自定义资料字段",ADD_BLACKLIST_INVALID_PARAM:"传入 addToBlacklist 接口的参数无效",DEL_BLACKLIST_INVALID_PARAM:"传入 removeFromBlacklist 接口的参数无效",CANNOT_ADD_SELF_TO_BLACKLIST:"不能拉黑自己",ADD_FRIEND_INVALID_PARAM:"传入 addFriend 接口的参数无效",NETWORK_ERROR:"网络错误",NETWORK_TIMEOUT:"请求超时",NETWORK_BASE_OPTIONS_NO_URL:"网络层初始化错误,缺少 URL 参数",NETWORK_UNDEFINED_SERVER_NAME:"打包错误,未定义的 serverName",NETWORK_PACKAGE_UNDEFINED:"未定义的 packageConfig",NO_NETWORK:"未连接到网络",CONVERTOR_IRREGULAR_PARAMS:"不规范的参数名称",NOTICE_RUNLOOP_UNEXPECTED_CONDITION:"意料外的通知条件",NOTICE_RUNLOOP_OFFSET_LOST:"_syncOffset 丢失",GET_LONGPOLL_ID_FAILED:"获取 longpolling id 失败",UNCAUGHT_ERROR:"未经明确定义的错误",INVALID_OPERATION:"无效操作,如调用了未定义或者未实现的方法等",CANNOT_FIND_PROTOCOL:"无法找到协议",CANNOT_FIND_MODULE:"无法找到模块,请参考:https://web.sdk.qcloud.com/im/doc/zh-cn/tutorial-03-sns.html",SDK_IS_NOT_READY:"接口需要 SDK 处于 ready 状态后才能调用",LOGGING_IN:"用户正在登录中",LOGIN_FAILED:"用户登录失败",KICKED_OUT_MULT_DEVICE:"用户多终端登录被踢出",KICKED_OUT_MULT_ACCOUNT:"用户多实例登录被踢出",KICKED_OUT_USERSIG_EXPIRED:"用户 userSig 过期被踢出",LOGGED_OUT:"用户已登出",KICKED_OUT_REST_API:"用户被 REST API - kick 接口: https://cloud.tencent.com/document/product/269/3853 踢出",OVER_FREQUENCY_LIMIT:"超出 SDK 频率控制",LONG_POLL_KICK_OUT:"检测到多个 web 实例登录,消息通道下线",OPEN_SERVICE_OVERLOAD_ERROR:"后台服务正忙,请稍后再试",MESSAGE_A2KEY_EXPIRED:"消息错误码:UserSig 或 A2 失效。",ACCOUNT_A2KEY_EXPIRED:"帐号错误码:UserSig 已过期,请重新生成。建议 UserSig 有效期设置不小于24小时。",LONG_POLL_API_PARAM_ERROR:"longPoll API parameters error",ILLEGAL_TOPIC_ID:"topicID 非法"},sa="networkRTT",ra="messageE2EDelay",ia="sendMessageC2C",ca="sendMessageGroup",ua="sendMessageGroupAV",la="sendMessageRichMedia",da="cosUpload",pa="messageReceivedGroup",ga="messageReceivedGroupAVPush",_a="messageReceivedGroupAVPull",ha=(r(Bt={},sa,2),r(Bt,ra,3),r(Bt,ia,4),r(Bt,ca,5),r(Bt,ua,6),r(Bt,la,7),r(Bt,pa,8),r(Bt,ga,9),r(Bt,_a,10),r(Bt,da,11),Bt),fa={info:4,warning:5,error:6},ma={wifi:1,"2g":2,"3g":3,"4g":4,"5g":5,unknown:6,none:7,online:8},Ma={login:4},va=function(){function e(t){n(this,e),this.eventType=Ma[t]||0,this.timestamp=0,this.networkType=8,this.code=0,this.message="",this.moreMessage="",this.extension=t,this.costTime=0,this.duplicate=!1,this.level=4,this.uiPlatform=void 0,this._sentFlag=!1,this._startts=Re()}return s(e,[{key:"updateTimeStamp",value:function(){this.timestamp=Re()}},{key:"start",value:function(e){return this._startts=e,this}},{key:"end",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(!this._sentFlag){var o=Re();0===this.costTime&&(this.costTime=o-this._startts),this.setMoreMessage("startts:".concat(this._startts," endts:").concat(o)),t?(this._sentFlag=!0,this._eventStatModule&&this._eventStatModule.pushIn(this)):setTimeout((function(){e._sentFlag=!0,e._eventStatModule&&e._eventStatModule.pushIn(e)}),0)}}},{key:"setError",value:function(e,t,o){return e instanceof Error?(this._sentFlag||(this.setNetworkType(o),t?(e.code&&this.setCode(e.code),e.message&&this.setMoreMessage(e.message)):(this.setCode(na.NO_NETWORK),this.setMoreMessage(aa.NO_NETWORK)),this.setLevel("error")),this):(we.warn("SSOLogData.setError value not instanceof Error, please check!"),this)}},{key:"setCode",value:function(e){return Ze(e)||this._sentFlag||("ECONNABORTED"===e&&(this.code=103),$e(e)?this.code=e:we.warn("SSOLogData.setCode value not a number, please check!",e,o(e))),this}},{key:"setMessage",value:function(e){return Ze(e)||this._sentFlag||($e(e)&&(this.message=e.toString()),ze(e)&&(this.message=e)),this}},{key:"setCostTime",value:function(e){return this.costTime=e,this}},{key:"setLevel",value:function(e){return Ze(e)||this._sentFlag||(this.level=fa[e]),this}},{key:"setMoreMessage",value:function(e){return Vt(this.moreMessage)?this.moreMessage="".concat(e):this.moreMessage+=" ".concat(e),this}},{key:"setNetworkType",value:function(e){if(Ze(e))we.warn("SSOLogData.setNetworkType value is undefined, please check!");else{var t=ma[e.toLowerCase()];Ze(t)||(this.networkType=t)}return this}},{key:"getStartTs",value:function(){return this._startts}},{key:"setUIPlatform",value:function(e){this.uiPlatform=e}}],[{key:"bindEventStatModule",value:function(t){e.prototype._eventStatModule=t}}]),e}(),ya={SDK_CONSTRUCT:"sdkConstruct",SDK_READY:"sdkReady",LOGIN:"login",LOGOUT:"logout",KICKED_OUT:"kickedOut",REGISTER_PLUGIN:"registerPlugin",KICK_OTHER:"kickOther",WS_CONNECT:"wsConnect",WS_ON_OPEN:"wsOnOpen",WS_ON_CLOSE:"wsOnClose",WS_ON_ERROR:"wsOnError",NETWORK_CHANGE:"networkChange",GET_COS_AUTH_KEY:"getCosAuthKey",GET_COS_PRE_SIG_URL:"getCosPreSigUrl",GET_SNAPSHOT_INFO:"getSnapshotInfo",UPLOAD:"upload",SEND_MESSAGE:"sendMessage",SEND_MESSAGE_WITH_RECEIPT:"sendMessageWithReceipt",SEND_COMBO_MESSAGE:"sendComboMessage",GET_C2C_ROAMING_MESSAGES:"getC2CRoamingMessages",GET_GROUP_ROAMING_MESSAGES:"getGroupRoamingMessages",GET_C2C_ROAMING_MESSAGES_HOPPING:"getC2CRoamingMessagesHopping",GET_GROUP_ROAMING_MESSAGES_HOPPING:"getGroupRoamingMessagesHopping",GET_READ_RECEIPT:"getReadReceipt",GET_READ_RECEIPT_DETAIL:"getReadReceiptDetail",SEND_READ_RECEIPT:"sendReadReceipt",SEND_C2C_READ_RECEIPT:"sendC2CReadReceipt",REVOKE_MESSAGE:"revokeMessage",DELETE_MESSAGE:"deleteMessage",EDIT_MESSAGE:"modifyMessage",SET_C2C_MESSAGE_READ:"setC2CMessageRead",SET_GROUP_MESSAGE_READ:"setGroupMessageRead",EMPTY_MESSAGE_BODY:"emptyMessageBody",GET_PEER_READ_TIME:"getPeerReadTime",UPLOAD_MERGER_MESSAGE:"uploadMergerMessage",DOWNLOAD_MERGER_MESSAGE:"downloadMergerMessage",JSON_PARSE_ERROR:"jsonParseError",MESSAGE_E2E_DELAY_EXCEPTION:"messageE2EDelayException",GET_CONVERSATION_LIST:"getConversationList",GET_CONVERSATION_PROFILE:"getConversationProfile",DELETE_CONVERSATION:"deleteConversation",PIN_CONVERSATION:"pinConversation",GET_CONVERSATION_LIST_IN_STORAGE:"getConversationListInStorage",SYNC_CONVERSATION_LIST:"syncConversationList",SET_ALL_MESSAGE_READ:"setAllMessageRead",CREATE_GROUP:"createGroup",APPLY_JOIN_GROUP:"applyJoinGroup",QUIT_GROUP:"quitGroup",SEARCH_GROUP_BY_ID:"searchGroupByID",CHANGE_GROUP_OWNER:"changeGroupOwner",HANDLE_GROUP_APPLICATION:"handleGroupApplication",HANDLE_GROUP_INVITATION:"handleGroupInvitation",SET_MESSAGE_REMIND_TYPE:"setMessageRemindType",DISMISS_GROUP:"dismissGroup",UPDATE_GROUP_PROFILE:"updateGroupProfile",GET_GROUP_LIST:"getGroupList",GET_GROUP_PROFILE:"getGroupProfile",GET_GROUP_LIST_IN_STORAGE:"getGroupListInStorage",GET_GROUP_LAST_SEQUENCE:"getGroupLastSequence",GET_GROUP_MISSING_MESSAGE:"getGroupMissingMessage",PAGING_GET_GROUP_LIST:"pagingGetGroupList",PAGING_GET_GROUP_LIST_WITH_TOPIC:"pagingGetGroupListWithTopic",GET_GROUP_SIMPLIFIED_INFO:"getGroupSimplifiedInfo",JOIN_WITHOUT_AUTH:"joinWithoutAuth",INIT_GROUP_ATTRIBUTES:"initGroupAttributes",SET_GROUP_ATTRIBUTES:"setGroupAttributes",DELETE_GROUP_ATTRIBUTES:"deleteGroupAttributes",GET_GROUP_ATTRIBUTES:"getGroupAttributes",GET_GROUP_MEMBER_LIST:"getGroupMemberList",GET_GROUP_MEMBER_PROFILE:"getGroupMemberProfile",ADD_GROUP_MEMBER:"addGroupMember",DELETE_GROUP_MEMBER:"deleteGroupMember",SET_GROUP_MEMBER_MUTE_TIME:"setGroupMemberMuteTime",SET_GROUP_MEMBER_NAME_CARD:"setGroupMemberNameCard",SET_GROUP_MEMBER_ROLE:"setGroupMemberRole",SET_GROUP_MEMBER_CUSTOM_FIELD:"setGroupMemberCustomField",GET_GROUP_ONLINE_MEMBER_COUNT:"getGroupOnlineMemberCount",SYNC_MESSAGE:"syncMessage",LONG_POLLING_AV_ERROR:"longPollingAVError",MESSAGE_LOSS:"messageLoss",MESSAGE_STACKED:"messageStacked",GET_USER_PROFILE:"getUserProfile",UPDATE_MY_PROFILE:"updateMyProfile",GET_BLACKLIST:"getBlacklist",ADD_TO_BLACKLIST:"addToBlacklist",REMOVE_FROM_BLACKLIST:"removeFromBlacklist",ADD_FRIEND:"addFriend",CHECK_FRIEND:"checkFriend",DELETE_FRIEND:"removeFromFriendList",GET_FRIEND_PROFILE:"getFriendProfile",GET_FRIEND_LIST:"getFriendList",UPDATE_FRIEND:"updateFriend",GET_FRIEND_APPLICATION_LIST:"getFriendApplicationList",DELETE_FRIEND_APPLICATION:"deleteFriendApplication",ACCEPT_FRIEND_APPLICATION:"acceptFriendApplication",REFUSE_FRIEND_APPLICATION:"refuseFriendApplication",SET_FRIEND_APPLICATION_READ:"setFriendApplicationRead",CREATE_FRIEND_GROUP:"createFriendGroup",DELETE_FRIEND_GROUP:"deleteFriendGroup",RENAME_FRIEND_GROUP:"renameFriendGroup",ADD_TO_FRIEND_GROUP:"addToFriendGroup",REMOVE_FROM_FRIEND_GROUP:"removeFromFriendGroup",GET_FRIEND_GROUP_LIST:"getFriendGroupList",CREATE_TOPIC:"createTopic",DELETE_TOPIC:"deleteTopic",UPDATE_TOPIC_PROFILE:"updateTopicProfile",GET_TOPIC_LIST:"getTopicList",RELAY_GET_TOPIC_LIST:"relayGetTopicList",GET_TOPIC_LAST_SEQUENCE:"getTopicLastSequence",MP_HIDE_TO_SHOW:"mpHideToShow",CALLBACK_FUNCTION_ERROR:"callbackFunctionError",FETCH_CLOUD_CONTROL_CONFIG:"fetchCloudControlConfig",PUSHED_CLOUD_CONTROL_CONFIG:"pushedCloudControlConfig",FETCH_COMMERCIAL_CONFIG:"fetchCommercialConfig",PUSHED_COMMERCIAL_CONFIG:"pushedCommercialConfig",ERROR:"error",LAST_MESSAGE_NOT_EXIST:"lastMessageNotExist"},Ia=function(){function e(t){n(this,e),this.type=D.MSG_TEXT,this.content={text:t.text||""}}return s(e,[{key:"setText",value:function(e){this.content.text=e}},{key:"sendable",value:function(){return 0!==this.content.text.length}}]),e}(),Ea=function(){function e(t){n(this,e),this._imageMemoryURL="",te?this.createImageDataASURLInWXMiniApp(t.file):this.createImageDataASURLInWeb(t.file),this._initImageInfoModel(),this.type=D.MSG_IMAGE,this._percent=0,this.content={imageFormat:t.imageFormat||be.UNKNOWN,uuid:t.uuid,imageInfoArray:[]},this.initImageInfoArray(t.imageInfoArray),this._defaultImage="http://imgcache.qq.com/open/qcloud/video/act/webim-images/default.jpg",this._autoFixUrl()}return s(e,[{key:"_initImageInfoModel",value:function(){var e=this;this._ImageInfoModel=function(t){this.instanceID=dt(9999999),this.sizeType=t.type||0,this.type=0,this.size=t.size||0,this.width=t.width||0,this.height=t.height||0,this.imageUrl=t.url||"",this.url=t.url||e._imageMemoryURL||e._defaultImage},this._ImageInfoModel.prototype={setSizeType:function(e){this.sizeType=e},setType:function(e){this.type=e},setImageUrl:function(e){e&&(this.imageUrl=e)},getImageUrl:function(){return this.imageUrl}}}},{key:"initImageInfoArray",value:function(e){for(var t=0,o=null,n=null;t<=2;)n=Ze(e)||Ze(e[t])?{type:0,size:0,width:0,height:0,url:""}:e[t],(o=new this._ImageInfoModel(n)).setSizeType(t+1),o.setType(t),this.addImageInfo(o),t++;this.updateAccessSideImageInfoArray()}},{key:"updateImageInfoArray",value:function(e){for(var t,o=this.content.imageInfoArray.length,n=0;n1&&(this._percent=1)}},{key:"updateImageFormat",value:function(e){this.content.imageFormat=be[e.toUpperCase()]||be.UNKNOWN}},{key:"createImageDataASURLInWeb",value:function(e){void 0!==e&&e.files.length>0&&(this._imageMemoryURL=window.URL.createObjectURL(e.files[0]))}},{key:"createImageDataASURLInWXMiniApp",value:function(e){e&&e.url&&(this._imageMemoryURL=e.url)}},{key:"replaceImageInfo",value:function(e,t){this.content.imageInfoArray[t]instanceof this._ImageInfoModel||(this.content.imageInfoArray[t]=e)}},{key:"addImageInfo",value:function(e){this.content.imageInfoArray.length>=3||this.content.imageInfoArray.push(e)}},{key:"updateAccessSideImageInfoArray",value:function(){var e=this.content.imageInfoArray,t=e[0],o=t.width,n=void 0===o?0:o,a=t.height,s=void 0===a?0:a;0!==n&&0!==s&&(kt(e),Object.assign(e[2],Lt({originWidth:n,originHeight:s,min:720})))}},{key:"sendable",value:function(){return 0!==this.content.imageInfoArray.length&&(""!==this.content.imageInfoArray[0].imageUrl&&0!==this.content.imageInfoArray[0].size)}}]),e}(),Ta=function(){function e(t){n(this,e),this.type=D.MSG_FACE,this.content=t||null}return s(e,[{key:"sendable",value:function(){return null!==this.content}}]),e}(),Ca=function(){function e(t){n(this,e),this.type=D.MSG_AUDIO,this._percent=0,this.content={downloadFlag:2,second:t.second,size:t.size,url:t.url,remoteAudioUrl:t.url||"",uuid:t.uuid}}return s(e,[{key:"updatePercent",value:function(e){this._percent=e,this._percent>1&&(this._percent=1)}},{key:"updateAudioUrl",value:function(e){this.content.remoteAudioUrl=e}},{key:"sendable",value:function(){return""!==this.content.remoteAudioUrl}}]),e}(),Sa={from:!0,groupID:!0,groupName:!0,to:!0},Da=function(){function e(t){n(this,e),this.type=D.MSG_GRP_TIP,this.content={},this._initContent(t)}return s(e,[{key:"_initContent",value:function(e){var t=this;Object.keys(e).forEach((function(o){switch(o){case"remarkInfo":break;case"groupProfile":t.content.groupProfile={},t._initGroupProfile(e[o]);break;case"operatorInfo":break;case"memberInfoList":case"msgMemberInfo":t._updateMemberList(e[o]);break;case"onlineMemberInfo":break;case"memberNum":t.content[o]=e[o],t.content.memberCount=e[o];break;case"newGroupProfile":t.content.newGroupProfile={},t._initNewGroupProfile(e[o]);break;default:t.content[o]=e[o]}})),this.content.userIDList||(this.content.userIDList=[this.content.operatorID])}},{key:"_initGroupProfile",value:function(e){for(var t=Object.keys(e),o=0;o1&&(this._percent=1)}},{key:"updateFileUrl",value:function(e){this.content.fileUrl=e}},{key:"sendable",value:function(){return""!==this.content.fileUrl&&(""!==this.content.fileName&&0!==this.content.fileSize)}}]),e}(),Ra=function(){function e(t){n(this,e),this.type=D.MSG_CUSTOM,this.content={data:t.data||"",description:t.description||"",extension:t.extension||""}}return s(e,[{key:"setData",value:function(e){return this.content.data=e,this}},{key:"setDescription",value:function(e){return this.content.description=e,this}},{key:"setExtension",value:function(e){return this.content.extension=e,this}},{key:"sendable",value:function(){return 0!==this.content.data.length||0!==this.content.description.length||0!==this.content.extension.length}}]),e}(),La=function(){function e(t){n(this,e),this.type=D.MSG_VIDEO,this._percent=0,this.content={remoteVideoUrl:t.remoteVideoUrl||t.videoUrl||"",videoFormat:t.videoFormat,videoSecond:parseInt(t.videoSecond,10),videoSize:t.videoSize,videoUrl:t.videoUrl,videoDownloadFlag:2,videoUUID:t.videoUUID,thumbUUID:t.thumbUUID,thumbFormat:t.thumbFormat,thumbWidth:t.thumbWidth,snapshotWidth:t.thumbWidth,thumbHeight:t.thumbHeight,snapshotHeight:t.thumbHeight,thumbSize:t.thumbSize,snapshotSize:t.thumbSize,thumbDownloadFlag:2,thumbUrl:t.thumbUrl,snapshotUrl:t.thumbUrl}}return s(e,[{key:"updatePercent",value:function(e){this._percent=e,this._percent>1&&(this._percent=1)}},{key:"updateVideoUrl",value:function(e){e&&(this.content.remoteVideoUrl=e)}},{key:"updateSnapshotInfo",value:function(e){var t=e.snapshotUrl,o=e.snapshotWidth,n=e.snapshotHeight;Vt(t)||(this.content.thumbUrl=this.content.snapshotUrl=t),Vt(o)||(this.content.thumbWidth=this.content.snapshotWidth=Number(o)),Vt(n)||(this.content.thumbHeight=this.content.snapshotHeight=Number(n))}},{key:"sendable",value:function(){return""!==this.content.remoteVideoUrl}}]),e}(),ka=function(){function e(t){n(this,e),this.type=D.MSG_LOCATION;var o=t.description,a=t.longitude,s=t.latitude;this.content={description:o,longitude:a,latitude:s}}return s(e,[{key:"sendable",value:function(){return!0}}]),e}(),Ga=function(){function e(t){if(n(this,e),this.from=t.from,this.messageSender=t.from,this.time=t.time,this.messageSequence=t.sequence,this.clientSequence=t.clientSequence||t.sequence,this.messageRandom=t.random,this.cloudCustomData=t.cloudCustomData||"",t.ID)this.nick=t.nick||"",this.avatar=t.avatar||"",this.messageBody=[{type:t.type,payload:t.payload}],t.conversationType.startsWith(D.CONV_C2C)?this.receiverUserID=t.to:t.conversationType.startsWith(D.CONV_GROUP)&&(this.receiverGroupID=t.to),this.messageReceiver=t.to;else{this.nick=t.nick||"",this.avatar=t.avatar||"",this.messageBody=[];var o=t.elements[0].type,a=t.elements[0].content;this._patchRichMediaPayload(o,a),o===D.MSG_MERGER?this.messageBody.push({type:o,payload:new Pa(a).content}):this.messageBody.push({type:o,payload:a}),t.groupID&&(this.receiverGroupID=t.groupID,this.messageReceiver=t.groupID),t.to&&(this.receiverUserID=t.to,this.messageReceiver=t.to)}}return s(e,[{key:"_patchRichMediaPayload",value:function(e,t){e===D.MSG_IMAGE?t.imageInfoArray.forEach((function(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===D.MSG_VIDEO?!t.remoteVideoUrl&&t.videoUrl&&(t.remoteVideoUrl=t.videoUrl):e===D.MSG_AUDIO?!t.remoteAudioUrl&&t.url&&(t.remoteAudioUrl=t.url):e===D.MSG_FILE&&!t.fileUrl&&t.url&&(t.fileUrl=t.url,t.url=void 0)}}]),e}(),Pa=function(){function e(t){if(n(this,e),this.type=D.MSG_MERGER,this.content={downloadKey:"",pbDownloadKey:"",messageList:[],title:"",abstractList:[],compatibleText:"",version:0,layersOverLimit:!1},t.downloadKey){var o=t.downloadKey,a=t.pbDownloadKey,s=t.title,r=t.abstractList,i=t.compatibleText,c=t.version;this.content.downloadKey=o,this.content.pbDownloadKey=a,this.content.title=s,this.content.abstractList=r,this.content.compatibleText=i,this.content.version=c||0}else if(Vt(t.messageList))1===t.layersOverLimit&&(this.content.layersOverLimit=!0);else{var u=t.messageList,l=t.title,d=t.abstractList,p=t.compatibleText,g=t.version,_=[];u.forEach((function(e){if(!Vt(e)){var t=new Ga(e);_.push(t)}})),this.content.messageList=_,this.content.title=l,this.content.abstractList=d,this.content.compatibleText=p,this.content.version=g||0}we.debug("MergerElement.content:",this.content)}return s(e,[{key:"sendable",value:function(){return!Vt(this.content.messageList)||!Vt(this.content.downloadKey)}}]),e}(),Ua={1:D.MSG_PRIORITY_HIGH,2:D.MSG_PRIORITY_NORMAL,3:D.MSG_PRIORITY_LOW,4:D.MSG_PRIORITY_LOWEST},wa=function(){function e(t){n(this,e),this.ID="",this.conversationID=t.conversationID||null,this.conversationType=t.conversationType||D.CONV_C2C,this.conversationSubType=t.conversationSubType,this.time=t.time||Math.ceil(Date.now()/1e3),this.sequence=t.sequence||0,this.clientSequence=t.clientSequence||t.sequence||0,this.random=t.random||0===t.random?t.random:dt(),this.priority=this._computePriority(t.priority),this.nick=t.nick||"",this.avatar=t.avatar||"",this.isPeerRead=1===t.isPeerRead||!1,this.nameCard="",this._elements=[],this.isPlaceMessage=t.isPlaceMessage||0,this.isRevoked=2===t.isPlaceMessage||8===t.msgFlagBits,this.from=t.from||null,this.to=t.to||null,this.flow="",this.isSystemMessage=t.isSystemMessage||!1,this.protocol=t.protocol||"JSON",this.isResend=!1,this.isRead=!1,this.status=t.status||xt.SUCCESS,this._onlineOnlyFlag=!1,this._groupAtInfoList=[],this._relayFlag=!1,this.atUserList=[],this.cloudCustomData=t.cloudCustomData||"",this.isDeleted=!1,this.isModified=!1,this._isExcludedFromUnreadCount=!(!t.messageControlInfo||1!==t.messageControlInfo.excludedFromUnreadCount),this._isExcludedFromLastMessage=!(!t.messageControlInfo||1!==t.messageControlInfo.excludedFromLastMessage),this.clientTime=t.clientTime||ke()||0,this.senderTinyID=t.senderTinyID||t.tinyID||"",this.readReceiptInfo=t.readReceiptInfo||{readCount:void 0,unreadCount:void 0},this.needReadReceipt=!0===t.needReadReceipt||1===t.needReadReceipt,this.version=t.messageVersion||0,this.reInitialize(t.currentUser),this.extractGroupInfo(t.groupProfile||null),this.handleGroupAtInfo(t)}return s(e,[{key:"elements",get:function(){return we.warn("!!!Message 实例的 elements 属性即将废弃,请尽快修改。使用 type 和 payload 属性处理单条消息,兼容组合消息使用 _elements 属性!!!"),this._elements}},{key:"getElements",value:function(){return this._elements}},{key:"extractGroupInfo",value:function(e){if(null!==e){ze(e.nick)&&(this.nick=e.nick),ze(e.avatar)&&(this.avatar=e.avatar);var t=e.messageFromAccountExtraInformation;Xe(t)&&ze(t.nameCard)&&(this.nameCard=t.nameCard)}}},{key:"handleGroupAtInfo",value:function(e){var t=this;e.payload&&e.payload.atUserList&&e.payload.atUserList.forEach((function(e){e!==D.MSG_AT_ALL?(t._groupAtInfoList.push({groupAtAllFlag:0,groupAtUserID:e}),t.atUserList.push(e)):(t._groupAtInfoList.push({groupAtAllFlag:1}),t.atUserList.push(D.MSG_AT_ALL))})),Qe(e.groupAtInfo)&&e.groupAtInfo.forEach((function(e){0===e.groupAtAllFlag?t.atUserList.push(e.groupAtUserID):1===e.groupAtAllFlag&&t.atUserList.push(D.MSG_AT_ALL)}))}},{key:"getGroupAtInfoList",value:function(){return this._groupAtInfoList}},{key:"_initProxy",value:function(){this._elements[0]&&(this.payload=this._elements[0].content,this.type=this._elements[0].type)}},{key:"reInitialize",value:function(e){e&&(this.status=this.from?xt.SUCCESS:xt.UNSEND,!this.from&&(this.from=e)),this._initFlow(e),this._initSequence(e),this._concatConversationID(e),this.generateMessageID()}},{key:"isSendable",value:function(){return 0!==this._elements.length&&("function"!=typeof this._elements[0].sendable?(we.warn("".concat(this._elements[0].type,' need "boolean : sendable()" method')),!1):this._elements[0].sendable())}},{key:"_initTo",value:function(e){this.conversationType===D.CONV_GROUP&&(this.to=e.groupID)}},{key:"_initSequence",value:function(e){0===this.clientSequence&&e&&(this.clientSequence=function(e){if(!e)return we.error("autoIncrementIndex(string: key) need key parameter"),!1;if(void 0===ht[e]){var t=new Date,o="3".concat(t.getHours()).slice(-2),n="0".concat(t.getMinutes()).slice(-2),a="0".concat(t.getSeconds()).slice(-2);ht[e]=parseInt([o,n,a,"0001"].join("")),o=null,n=null,a=null,we.log("autoIncrementIndex start index:".concat(ht[e]))}return ht[e]++}(e)),0===this.sequence&&this.conversationType===D.CONV_C2C&&(this.sequence=this.clientSequence)}},{key:"generateMessageID",value:function(){this.from===D.CONV_SYSTEM&&(this.senderTinyID="144115198244471703"),this.ID="".concat(this.senderTinyID,"-").concat(this.clientTime,"-").concat(this.random)}},{key:"_initFlow",value:function(e){""!==e&&(e===this.from?(this.flow="out",this.isRead=!0):this.flow="in")}},{key:"_concatConversationID",value:function(e){var t=this.to,o="",n=this.conversationType;n!==D.CONV_SYSTEM?(o=n===D.CONV_C2C?e===this.from?t:this.from:this.to,this.conversationID="".concat(n).concat(o)):this.conversationID=D.CONV_SYSTEM}},{key:"isElement",value:function(e){return e instanceof Ia||e instanceof Ea||e instanceof Ta||e instanceof Ca||e instanceof Oa||e instanceof La||e instanceof Da||e instanceof Aa||e instanceof Ra||e instanceof ka||e instanceof Pa}},{key:"setElement",value:function(e){var t=this;if(this.isElement(e))return this._elements=[e],void this._initProxy();var o=function(e){if(e.type&&e.content)switch(e.type){case D.MSG_TEXT:t.setTextElement(e.content);break;case D.MSG_IMAGE:t.setImageElement(e.content);break;case D.MSG_AUDIO:t.setAudioElement(e.content);break;case D.MSG_FILE:t.setFileElement(e.content);break;case D.MSG_VIDEO:t.setVideoElement(e.content);break;case D.MSG_CUSTOM:t.setCustomElement(e.content);break;case D.MSG_LOCATION:t.setLocationElement(e.content);break;case D.MSG_GRP_TIP:t.setGroupTipElement(e.content);break;case D.MSG_GRP_SYS_NOTICE:t.setGroupSystemNoticeElement(e.content);break;case D.MSG_FACE:t.setFaceElement(e.content);break;case D.MSG_MERGER:t.setMergerElement(e.content);break;default:we.warn(e.type,e.content,"no operation......")}};if(Qe(e))for(var n=0;n1&&void 0!==arguments[1]&&arguments[1];if(e instanceof Ba)return t&&null!==xa&&xa.emit(S.ERROR,e),Promise.reject(e);if(e instanceof Error){var o=new Ba({code:na.UNCAUGHT_ERROR,message:e.message});return t&&null!==xa&&xa.emit(S.ERROR,o),Promise.reject(o)}if(Ze(e)||Ze(e.code)||Ze(e.message))we.error("IMPromise.reject 必须指定code(错误码)和message(错误信息)!!!");else{if($e(e.code)&&ze(e.message)){var n=new Ba(e);return t&&null!==xa&&xa.emit(S.ERROR,n),Promise.reject(n)}we.error("IMPromise.reject code(错误码)必须为数字,message(错误信息)必须为字符串!!!")}},$a=function(e){i(a,e);var o=f(a);function a(e){var t;return n(this,a),(t=o.call(this,e))._className="C2CModule",t._messageFromUnreadDBMap=new Map,t}return s(a,[{key:"onNewC2CMessage",value:function(e){var t=e.dataList,o=e.isInstantMessage,n=e.C2CRemainingUnreadList,a=e.C2CPairUnreadList;we.debug("".concat(this._className,".onNewC2CMessage count:").concat(t.length," isInstantMessage:").concat(o));var s=this._newC2CMessageStoredAndSummary({dataList:t,C2CRemainingUnreadList:n,C2CPairUnreadList:a,isInstantMessage:o}),r=s.conversationOptionsList,i=s.messageList,c=s.isUnreadC2CMessage;(this.filterModifiedMessage(i),r.length>0)&&this.getModule(co).onNewMessage({conversationOptionsList:r,isInstantMessage:o,isUnreadC2CMessage:c});var u=this.filterUnmodifiedMessage(i);o&&u.length>0&&this.emitOuterEvent(S.MESSAGE_RECEIVED,u),i.length=0}},{key:"_newC2CMessageStoredAndSummary",value:function(e){for(var t=e.dataList,o=e.C2CRemainingUnreadList,n=e.C2CPairUnreadList,a=e.isInstantMessage,s=null,r=[],i=[],c={},u=this.getModule(_o),l=this.getModule(Co),d=!1,p=this.getModule(co),g=0,_=t.length;g<_;g++){var h=t[g];h.currentUser=this.getMyUserID(),h.conversationType=D.CONV_C2C,h.isSystemMessage=!!h.isSystemMessage,(Ze(h.nick)||Ze(h.avatar))&&(d=!0,we.debug("".concat(this._className,"._newC2CMessageStoredAndSummary nick or avatar missing!"))),s=new wa(h),h.elements=u.parseElements(h.elements,h.from),s.setElement(h.elements),s.setNickAndAvatar({nick:h.nick,avatar:h.avatar});var f=s.conversationID;if(a){if(1===this._messageFromUnreadDBMap.get(s.ID))continue;var m=!1;if(s.from!==this.getMyUserID()){var M=p.getLatestMessageSentByPeer(f);if(M){var v=M.nick,y=M.avatar;d?s.setNickAndAvatar({nick:v,avatar:y}):v===s.nick&&y===s.avatar||(m=!0)}}else{var I=p.getLatestMessageSentByMe(f);if(I){var E=I.nick,T=I.avatar;E===s.nick&&T===s.avatar||p.modifyMessageSentByMe({conversationID:f,latestNick:s.nick,latestAvatar:s.avatar})}}var C=1===t[g].isModified;if(p.isMessageSentByCurrentInstance(s)?s.isModified=C:C=!1,0===h.msgLifeTime)s._onlineOnlyFlag=!0,i.push(s);else{if(!p.pushIntoMessageList(i,s,C))continue;m&&(p.modifyMessageSentByPeer({conversationID:f,latestNick:s.nick,latestAvatar:s.avatar}),p.updateUserProfileSpecifiedKey({conversationID:f,nick:s.nick,avatar:s.avatar}))}a&&s.clientTime>0&&l.addMessageDelay(s.clientTime)}else this._messageFromUnreadDBMap.set(s.ID,1);if(0!==h.msgLifeTime){if(!1===s._onlineOnlyFlag){var S=p.getLastMessageTime(f);if($e(S)&&s.time0){O=!0;var o=r.find((function(t){return t.conversationID==="C2C".concat(n[e].from)}));o?o.unreadCount=n[e].unreadCount:r.push({conversationID:"C2C".concat(n[e].from),unreadCount:n[e].unreadCount,type:D.CONV_C2C})}},L=0,k=n.length;L0&&(n=e.cloudCustomData);var a=[];if(Xe(t)&&Xe(t.messageControlInfo)){var s=t.messageControlInfo,r=s.excludedFromUnreadCount,i=s.excludedFromLastMessage;!0===r&&a.push("NoUnread"),!0===i&&a.push("NoLastMsg")}return{protocolName:Go,tjgID:this.generateTjgID(e),requestData:{fromAccount:this.getMyUserID(),toAccount:e.to,msgBody:e.getElements(),cloudCustomData:n,msgSeq:e.sequence,msgRandom:e.random,msgLifeTime:this.isOnlineMessage(e,t)?0:void 0,nick:e.nick,avatar:e.avatar,offlinePushInfo:o?{pushFlag:!0===o.disablePush?1:0,title:o.title||"",desc:o.description||"",ext:o.extension||"",apnsInfo:{badgeMode:!0===o.ignoreIOSBadge?1:0},androidInfo:{OPPOChannelID:o.androidOPPOChannelID||""}}:void 0,messageControlInfo:a,clientTime:e.clientTime,needReadReceipt:!0===e.needReadReceipt?1:0}}}},{key:"isOnlineMessage",value:function(e,t){return!(!t||!0!==t.onlineUserOnly)}},{key:"revokeMessage",value:function(e){return this.request({protocolName:Vo,requestData:{msgInfo:{fromAccount:e.from,toAccount:e.to,msgSeq:e.sequence,msgRandom:e.random,msgTimeStamp:e.time}}})}},{key:"deleteMessage",value:function(e){var t=e.to,o=e.keyList;return we.log("".concat(this._className,".deleteMessage toAccount:").concat(t," count:").concat(o.length)),this.request({protocolName:Yo,requestData:{fromAccount:this.getMyUserID(),to:t,keyList:o}})}},{key:"modifyRemoteMessage",value:function(e){var t=e.from,o=e.to,n=e.version,a=void 0===n?0:n,s=e.sequence,r=e.random,i=e.time,c=e.payload,u=e.type,l=e.cloudCustomData;return this.request({protocolName:jo,requestData:{from:t,to:o,version:a,sequence:s,random:r,time:i,elements:[{type:u,content:c}],cloudCustomData:l}})}},{key:"setMessageRead",value:function(e){var t=this,o=e.conversationID,n=e.lastMessageTime,a="".concat(this._className,".setMessageRead");we.log("".concat(a," conversationID:").concat(o," lastMessageTime:").concat(n)),$e(n)||we.warn("".concat(a," 请勿修改 Conversation.lastMessage.lastTime,否则可能会导致已读上报结果不准确"));var s=new va(ya.SET_C2C_MESSAGE_READ);return s.setMessage("conversationID:".concat(o," lastMessageTime:").concat(n)),this.request({protocolName:Ko,requestData:{C2CMsgReaded:{cookie:"",C2CMsgReadedItem:[{toAccount:o.replace("C2C",""),lastMessageTime:n,receipt:1}]}}}).then((function(){s.setNetworkType(t.getNetworkType()).end(),we.log("".concat(a," ok"));var e=t.getModule(co);return e.updateIsReadAfterReadReport({conversationID:o,lastMessageTime:n}),e.updateUnreadCount(o),ba()})).catch((function(e){return t.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];s.setError(e,n,a).end()})),we.log("".concat(a," failed. error:"),e),ja(e)}))}},{key:"getRoamingMessage",value:function(e){var t=this,o="".concat(this._className,".getRoamingMessage"),n=e.peerAccount,a=e.conversationID,s=e.count,r=e.lastMessageTime,i=e.messageKey,c="peerAccount:".concat(n," count:").concat(s||15," lastMessageTime:").concat(r||0," messageKey:").concat(i);we.log("".concat(o," ").concat(c));var u=new va(ya.GET_C2C_ROAMING_MESSAGES);return this.request({protocolName:xo,requestData:{peerAccount:n,count:s||15,lastMessageTime:r||0,messageKey:i}}).then((function(e){var n=e.data,s=n.complete,r=n.messageList,i=n.messageKey,l=n.lastMessageTime;Ze(r)?we.log("".concat(o," ok. complete:").concat(s," but messageList is undefined!")):we.log("".concat(o," ok. complete:").concat(s," count:").concat(r.length)),u.setNetworkType(t.getNetworkType()).setMessage("".concat(c," complete:").concat(s," length:").concat(r.length)).end();var d=t.getModule(co);1===s&&d.setCompleted(a);var p=d.onRoamingMessage(r,a);d.modifyMessageList(a),d.updateIsRead(a),d.updateRoamingMessageKeyAndTime(a,i,l);var g=d.getPeerReadTime(a);if(we.log("".concat(o," update isPeerRead property. conversationID:").concat(a," peerReadTime:").concat(g)),g)d.updateMessageIsPeerReadProperty(a,g);else{var _=a.replace(D.CONV_C2C,"");t.getRemotePeerReadTime([_]).then((function(){d.updateMessageIsPeerReadProperty(a,d.getPeerReadTime(a))}))}var h="";if(p.length>0)h=p[0].ID;else{var f=d.getLocalOldestMessage(a);f&&(h=f.ID)}return we.log("".concat(o," nextReqID:").concat(h," stored message count:").concat(p.length)),{nextReqID:h,storedMessageList:p}})).catch((function(e){return t.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];u.setMessage(c).setError(e,n,a).end()})),we.warn("".concat(o," failed. error:"),e),ja(e)}))}},{key:"getRoamingMessagesHopping",value:function(e){var t=this,o="".concat(this._className,".getRoamingMessagesHopping"),n=e.peerAccount,a=e.time,s=void 0===a?0:a,r=e.count,i=e.direction,c="peerAccount:".concat(n," count:").concat(r," time:").concat(s," direction:").concat(i);we.log("".concat(o," ").concat(c));var u=new va(ya.GET_C2C_ROAMING_MESSAGES_HOPPING);return this.request({protocolName:xo,requestData:{peerAccount:n,count:r,lastMessageTime:s,direction:i}}).then((function(e){var a=e.data,s=a.complete,r=a.messageList,i=void 0===r?[]:r;we.log("".concat(o," ok. complete:").concat(s," count:").concat(i.length)),u.setNetworkType(t.getNetworkType()).setMessage("".concat(c," complete:").concat(s," length:").concat(i.length)).end();var l="".concat(D.CONV_C2C).concat(n),d=t.getModule(co).onRoamingMessage(i,l,!1);return t._modifyMessageList(l,d),d})).catch((function(e){return t.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];u.setMessage(c).setError(e,n,a).end()})),we.warn("".concat(o," failed. error:"),e),ja(e)}))}},{key:"_modifyMessageList",value:function(e,t){var o=this.getModule(co).getLocalConversation(e);if(o)for(var n=o.userProfile.nick,a=o.userProfile.avatar,s=this.getModule(oo).getNickAndAvatarByUserID(this.getMyUserID()),r=s.nick,i=s.avatar,c=t.length-1;c>=0;c--){var u=t[c];"in"===u.flow&&(u.nick!==n&&u.setNickAndAvatar({nick:n}),u.avatar!==a&&u.setNickAndAvatar({avatar:a})),"out"===u.flow&&(u.nick!==r&&u.setNickAndAvatar({nick:r}),u.avatar!==i&&u.setNickAndAvatar({avatar:i}))}}},{key:"getRemotePeerReadTime",value:function(e){var t=this,o="".concat(this._className,".getRemotePeerReadTime");if(Vt(e))return we.warn("".concat(o," userIDList is empty!")),Promise.resolve();var n=new va(ya.GET_PEER_READ_TIME);return we.log("".concat(o," userIDList:").concat(e)),this.request({protocolName:Wo,requestData:{userIDList:e}}).then((function(a){var s=a.data.peerReadTimeList;we.log("".concat(o," ok. peerReadTimeList:").concat(s));for(var r="",i=t.getModule(co),c=0;c0&&i.recordPeerReadTime("C2C".concat(e[c]),s[c]);n.setNetworkType(t.getNetworkType()).setMessage(r).end()})).catch((function(e){t.probeNetwork().then((function(t){var o=m(t,2),a=o[0],s=o[1];n.setError(e,a,s).end()})),we.warn("".concat(o," failed. error:"),e)}))}},{key:"sendReadReceipt",value:function(e){var t=this,o=e[0].conversationID.replace(D.CONV_C2C,""),n=new va(ya.SEND_C2C_READ_RECEIPT);n.setMessage("peerAccount:".concat(o));var a=this.getMyUserID(),s=e.filter((function(e){return e.from!==a&&!0===e.needReadReceipt})).map((function(e){return{fromAccount:e.from,toAccount:e.to,sequence:e.sequence,random:e.random,time:e.time,clientTime:e.clientTime}}));if(0===s.length)return ja({code:na.READ_RECEIPT_MESSAGE_LIST_EMPTY,message:aa.READ_RECEIPT_MESSAGE_LIST_EMPTY});var r="".concat(this._className,".sendReadReceipt");return we.log("".concat(r,". peerAccount:").concat(o," messageInfoList length:").concat(s.length)),this.request({protocolName:Mn,requestData:{peerAccount:o,messageInfoList:s}}).then((function(e){return n.end(),we.log("".concat(r," ok")),ba()})).catch((function(e){return t.probeNetwork().then((function(t){var o=m(t,2),a=o[0],s=o[1];n.setError(e,a,s).end()})),we.warn("".concat(r," failed. error:"),e),ja(e)}))}},{key:"getReadReceiptList",value:function(e){var t="".concat(this._className,".getReadReceiptList"),o=this.getMyUserID(),n=e.filter((function(e){return e.from===o&&!0===e.needReadReceipt}));return we.log("".concat(t," userID:").concat(o," messageList length:").concat(n.length)),Ya({messageList:n})}},{key:"reset",value:function(){we.log("".concat(this._className,".reset")),this._messageFromUnreadDBMap.clear()}}]),a}(Do),za=function(){function e(){n(this,e),this.list=new Map,this._className="MessageListHandler",this._latestMessageSentByPeerMap=new Map,this._latestMessageSentByMeMap=new Map,this._groupLocalLastMessageSequenceMap=new Map}return s(e,[{key:"getLocalOldestMessageByConversationID",value:function(e){if(!e)return null;if(!this.list.has(e))return null;var t=this.list.get(e).values();return t?t.next().value:null}},{key:"pushIn",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],o=e.conversationID,n=!0;this.list.has(o)||this.list.set(o,new Map);var a=this._getUniqueIDOfMessage(e),s=this.list.get(o).has(a);if(s){var r=this.list.get(o).get(a);if(!t||!0===r.isModified)return n=!1}return this.list.get(o).set(a,e),this._setLatestMessageSentByPeer(o,e),this._setLatestMessageSentByMe(o,e),this._setGroupLocalLastMessageSequence(o,e),n}},{key:"unshift",value:function(e,t){var o;if(Qe(e)){if(e.length>0){o=e[0].conversationID;var n=e.length;this._unshiftMultipleMessages(e,t),this._setGroupLocalLastMessageSequence(o,e[n-1])}}else o=e.conversationID,this._unshiftSingleMessage(e,t),this._setGroupLocalLastMessageSequence(o,e);if(o&&o.startsWith(D.CONV_C2C)){var a=Array.from(this.list.get(o).values()),s=a.length;if(0===s)return;for(var r=s-1;r>=0;r--)if("out"===a[r].flow){this._setLatestMessageSentByMe(o,a[r]);break}for(var i=s-1;i>=0;i--)if("in"===a[i].flow){this._setLatestMessageSentByPeer(o,a[i]);break}}}},{key:"_unshiftSingleMessage",value:function(e,t){var o=e.conversationID,n=this._getUniqueIDOfMessage(e);if(!this.list.has(o))return this.list.set(o,new Map),this.list.get(o).set(n,e),void t.push(e);var a=this.list.get(o),s=Array.from(a);a.has(n)||(s.unshift([n,e]),this.list.set(o,new Map(s)),t.push(e))}},{key:"_unshiftMultipleMessages",value:function(e,t){for(var o=e.length,n=[],a=e[0].conversationID,s=this.list.get(a),r=this.list.has(a)?Array.from(s):[],i=0;i=0;l--)"in"===s[l].flow&&((i=s[l]).nick!==o&&(i.setNickAndAvatar({nick:o}),u=!0),i.avatar!==n&&(i.setNickAndAvatar({avatar:n}),u=!0),u&&(c+=1));we.log("".concat(this._className,".modifyMessageSentByPeer conversationID:").concat(t," count:").concat(c))}}}},{key:"modifyMessageSentByMe",value:function(e){var t=e.conversationID,o=e.latestNick,n=e.latestAvatar,a=this.list.get(t);if(!Vt(a)){var s=Array.from(a.values()),r=s.length;if(0!==r){for(var i=null,c=0,u=!1,l=r-1;l>=0;l--)"out"===s[l].flow&&((i=s[l]).nick!==o&&(i.setNickAndAvatar({nick:o}),u=!0),i.avatar!==n&&(i.setNickAndAvatar({avatar:n}),u=!0),u&&(c+=1));we.log("".concat(this._className,".modifyMessageSentByMe conversationID:").concat(t," count:").concat(c))}}}},{key:"getLocalMessageListHopping",value:function(e){var t=e.conversationID,o=e.sequence,n=e.time,a=e.count,s=e.direction,r=this.getLocalMessageList(t),i=-1;if(t.startsWith(D.CONV_C2C)?i=r.findIndex((function(e){return e.time===n})):t.startsWith(D.CONV_GROUP)&&(i=r.findIndex((function(e){return e.sequence===o}))),-1===i)return[];var c=i+1,u=c>a?c-a:0;return 1===s&&(u=i,c=i+a),r.slice(u,c)}},{key:"getConversationIDList",value:function(e){return M(this.list.keys()).filter((function(t){return t.startsWith(e)}))}},{key:"traversal",value:function(){if(0!==this.list.size&&-1===we.getLevel()){console.group("conversationID-messageCount");var e,t=C(this.list);try{for(t.s();!(e=t.n()).done;){var o=m(e.value,2),n=o[0],a=o[1];console.log("".concat(n,"-").concat(a.size))}}catch(s){t.e(s)}finally{t.f()}console.groupEnd()}}},{key:"onMessageModified",value:function(e,t){if(!this.list.has(e))return{isUpdated:!1,message:null};var o=this._getUniqueIDOfMessage(t),n=this.list.get(e).has(o);if(we.debug("".concat(this._className,".onMessageModified conversationID:").concat(e," uniqueID:").concat(o," has:").concat(n)),n){var a=this.list.get(e).get(o),s=t.messageVersion,r=t.elements,i=t.cloudCustomData;return a.version1&&void 0!==arguments[1]&&arguments[1];if(e)return this._isReady?void(t?e.call(this):setTimeout(e,1)):(this._readyQueue=this._readyQueue||[],void this._readyQueue.push(e))},t.triggerReady=function(){var e=this;this._isReady=!0,setTimeout((function(){var t=e._readyQueue;e._readyQueue=[],t&&t.length>0&&t.forEach((function(e){e.call(this)}),e)}),1)},t.resetReady=function(){this._isReady=!1,this._readyQueue=[]},t.isReady=function(){return this._isReady}};var es=["jpg","jpeg","gif","png","bmp","image","webp"],ts=["mp4"],os=1,ns=2,as=3,ss=255,rs=function(){function e(t){var o=this;n(this,e),Vt(t)||(this.userID=t.userID||"",this.nick=t.nick||"",this.gender=t.gender||"",this.birthday=t.birthday||0,this.location=t.location||"",this.selfSignature=t.selfSignature||"",this.allowType=t.allowType||D.ALLOW_TYPE_ALLOW_ANY,this.language=t.language||0,this.avatar=t.avatar||"",this.messageSettings=t.messageSettings||0,this.adminForbidType=t.adminForbidType||D.FORBID_TYPE_NONE,this.level=t.level||0,this.role=t.role||0,this.lastUpdatedTime=0,this.profileCustomField=[],Vt(t.profileCustomField)||t.profileCustomField.forEach((function(e){o.profileCustomField.push({key:e.key,value:e.value})})))}return s(e,[{key:"validate",value:function(e){var t=!0,o="";if(Vt(e))return{valid:!1,tips:"empty options"};if(e.profileCustomField)for(var n=e.profileCustomField.length,a=null,s=0;s500&&(o="nick name limited: must less than or equal to ".concat(500," bytes, current size: ").concat(lt(e[r])," bytes"),t=!1);break;case"gender":_t(qe,e.gender)||(o="key:gender, invalid value:"+e.gender,t=!1);break;case"birthday":$e(e.birthday)||(o="birthday should be a number",t=!1);break;case"location":ze(e.location)||(o="location should be a string",t=!1);break;case"selfSignature":ze(e.selfSignature)||(o="selfSignature should be a string",t=!1);break;case"allowType":_t(Ke,e.allowType)||(o="key:allowType, invalid value:"+e.allowType,t=!1);break;case"language":$e(e.language)||(o="language should be a number",t=!1);break;case"avatar":ze(e.avatar)||(o="avatar should be a string",t=!1);break;case"messageSettings":0!==e.messageSettings&&1!==e.messageSettings&&(o="messageSettings should be 0 or 1",t=!1);break;case"adminForbidType":_t(Ve,e.adminForbidType)||(o="key:adminForbidType, invalid value:"+e.adminForbidType,t=!1);break;case"level":$e(e.level)||(o="level should be a number",t=!1);break;case"role":$e(e.role)||(o="role should be a number",t=!1);break;default:o="unknown key:"+r+" "+e[r],t=!1}}return{valid:t,tips:o}}}]),e}(),is=s((function e(t){n(this,e),this.value=t,this.next=null})),cs=function(){function e(t){n(this,e),this.MAX_LENGTH=t,this.pTail=null,this.pNodeToDel=null,this.map=new Map,we.debug("SinglyLinkedList init MAX_LENGTH:".concat(this.MAX_LENGTH))}return s(e,[{key:"set",value:function(e){var t=new is(e);if(this.map.size0&&o.members.forEach((function(e){e.userID===t.selfInfo.userID&&ct(t.selfInfo,e,["sequence"])}))}},{key:"updateSelfInfo",value:function(e){var o={nameCard:e.nameCard,joinTime:e.joinTime,role:e.role,messageRemindType:e.messageRemindType,readedSequence:e.readedSequence,excludedUnreadSequenceList:e.excludedUnreadSequenceList};ct(this.selfInfo,t({},o),[],["",null,void 0,0,NaN])}},{key:"setSelfNameCard",value:function(e){this.selfInfo.nameCard=e}}]),e}(),ds=function(e){return Ze(e)?{lastTime:0,lastSequence:0,fromAccount:0,messageForShow:"",payload:null,type:"",isRevoked:!1,cloudCustomData:"",onlineOnlyFlag:!1,nick:"",nameCard:"",version:0,isPeerRead:!1}:e instanceof wa?{lastTime:e.time||0,lastSequence:e.sequence||0,fromAccount:e.from||"",messageForShow:Ft(e.type,e.payload),payload:e.payload||null,type:e.type||null,isRevoked:e.isRevoked||!1,cloudCustomData:e.cloudCustomData||"",onlineOnlyFlag:e._onlineOnlyFlag||!1,nick:e.nick||"",nameCard:e.nameCard||"",version:e.version||0,isPeerRead:e.isPeerRead||!1}:t(t({},e),{},{messageForShow:Ft(e.type,e.payload)})},ps=function(){function e(t){n(this,e),this.conversationID=t.conversationID||"",this.unreadCount=t.unreadCount||0,this.type=t.type||"",this.lastMessage=ds(t.lastMessage),t.lastMsgTime&&(this.lastMessage.lastTime=t.lastMsgTime),this._isInfoCompleted=!1,this.peerReadTime=t.peerReadTime||0,this.groupAtInfoList=[],this.remark="",this.isPinned=t.isPinned||!1,this.messageRemindType="",this._initProfile(t)}return s(e,[{key:"toAccount",get:function(){return this.conversationID.startsWith(D.CONV_C2C)?this.conversationID.replace(D.CONV_C2C,""):this.conversationID.startsWith(D.CONV_GROUP)?this.conversationID.replace(D.CONV_GROUP,""):""}},{key:"subType",get:function(){return this.groupProfile?this.groupProfile.type:""}},{key:"_initProfile",value:function(e){var t=this;Object.keys(e).forEach((function(o){switch(o){case"userProfile":t.userProfile=e.userProfile;break;case"groupProfile":t.groupProfile=e.groupProfile}})),Ze(this.userProfile)&&this.type===D.CONV_C2C?this.userProfile=new rs({userID:e.conversationID.replace("C2C","")}):Ze(this.groupProfile)&&this.type===D.CONV_GROUP&&(this.groupProfile=new ls({groupID:e.conversationID.replace("GROUP","")}))}},{key:"updateUnreadCount",value:function(e){var t=e.nextUnreadCount,o=e.isFromGetConversations,n=e.isUnreadC2CMessage;Ze(t)||(It(this.subType)?this.unreadCount=0:o&&this.type===D.CONV_GROUP||o&&this.type===D.CONV_TOPIC||n&&this.type===D.CONV_C2C?this.unreadCount=t:this.unreadCount=this.unreadCount+t)}},{key:"updateLastMessage",value:function(e){this.lastMessage=ds(e)}},{key:"updateGroupAtInfoList",value:function(e){var t,o=(v(t=e.groupAtType)||y(t)||I(t)||T()).slice(0);-1!==o.indexOf(D.CONV_AT_ME)&&-1!==o.indexOf(D.CONV_AT_ALL)&&(o=[D.CONV_AT_ALL_AT_ME]);var n={from:e.from,groupID:e.groupID,topicID:e.topicID,messageSequence:e.sequence,atTypeArray:o,__random:e.__random,__sequence:e.__sequence};this.groupAtInfoList.push(n),we.debug("Conversation.updateGroupAtInfoList conversationID:".concat(this.conversationID),this.groupAtInfoList)}},{key:"clearGroupAtInfoList",value:function(){this.groupAtInfoList.length=0}},{key:"reduceUnreadCount",value:function(){this.unreadCount>=1&&(this.unreadCount-=1)}},{key:"isLastMessageRevoked",value:function(e){var t=e.sequence,o=e.time;return this.type===D.CONV_C2C&&t===this.lastMessage.lastSequence&&o===this.lastMessage.lastTime||this.type===D.CONV_GROUP&&t===this.lastMessage.lastSequence}},{key:"setLastMessageRevoked",value:function(e){this.lastMessage.isRevoked=e}}]),e}(),gs=function(){function e(t){n(this,e),this._conversationModule=t,this._className="MessageRemindHandler",this._updateSequence=0}return s(e,[{key:"getC2CMessageRemindType",value:function(){var e=this,t="".concat(this._className,".getC2CMessageRemindType");return this._conversationModule.request({protocolName:Bo,updateSequence:this._updateSequence}).then((function(o){we.log("".concat(t," ok"));var n=o.data,a=n.updateSequence,s=n.muteFlagList;e._updateSequence=a,e._patchC2CMessageRemindType(s)})).catch((function(e){we.error("".concat(t," failed. error:"),e)}))}},{key:"_patchC2CMessageRemindType",value:function(e){var t=this,o=0,n="";Qe(e)&&e.length>0&&e.forEach((function(e){var a=e.userID,s=e.muteFlag;0===s?n=D.MSG_REMIND_ACPT_AND_NOTE:1===s?n=D.MSG_REMIND_DISCARD:2===s&&(n=D.MSG_REMIND_ACPT_NOT_NOTE),!0===t._conversationModule.patchMessageRemindType({ID:a,isC2CConversation:!0,messageRemindType:n})&&(o+=1)})),we.log("".concat(this._className,"._patchC2CMessageRemindType count:").concat(o))}},{key:"set",value:function(e){return e.groupID?this._setGroupMessageRemindType(e):Qe(e.userIDList)?this._setC2CMessageRemindType(e):void 0}},{key:"_setGroupMessageRemindType",value:function(e){var t=this,o="".concat(this._className,"._setGroupMessageRemindType"),n=e.groupID,a=e.messageRemindType,s="groupID:".concat(n," messageRemindType:").concat(a),r=new va(ya.SET_MESSAGE_REMIND_TYPE);return r.setMessage(s),this._getModule(ro).modifyGroupMemberInfo({groupID:n,messageRemindType:a,userID:this._conversationModule.getMyUserID()}).then((function(){r.setNetworkType(t._conversationModule.getNetworkType()).end(),we.log("".concat(o," ok. ").concat(s));var e=t._getModule(ao).getLocalGroupProfile(n);if(e&&(e.selfInfo.messageRemindType=a),Tt(n)){var i=t._getModule(io),c=bt(n),u=i.getLocalTopic(c,n);return u&&(u.updateSelfInfo({messageRemindType:a}),t._conversationModule.emitOuterEvent(S.TOPIC_UPDATED,{groupID:n,topic:u})),ba({group:e})}return t._conversationModule.patchMessageRemindType({ID:n,isC2CConversation:!1,messageRemindType:a})&&t._emitConversationUpdate(),ba({group:e})})).catch((function(e){return t._conversationModule.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];r.setError(e,n,a).end()})),we.error("".concat(o," failed. error:"),e),ja(e)}))}},{key:"_setC2CMessageRemindType",value:function(e){var t=this,o="".concat(this._className,"._setC2CMessageRemindType"),n=e.userIDList,a=e.messageRemindType,s=n.slice(0,30),r=0;a===D.MSG_REMIND_DISCARD?r=1:a===D.MSG_REMIND_ACPT_NOT_NOTE&&(r=2);var i="userIDList:".concat(s," messageRemindType:").concat(a),c=new va(ya.SET_MESSAGE_REMIND_TYPE);return c.setMessage(i),this._conversationModule.request({protocolName:Ho,requestData:{userIDList:s,muteFlag:r}}).then((function(e){c.setNetworkType(t._conversationModule.getNetworkType()).end();var n=e.data,r=n.updateSequence,i=n.errorList;t._updateSequence=r;var u=[],l=[];Qe(i)&&i.forEach((function(e){u.push(e.userID),l.push({userID:e.userID,code:e.errorCode})}));var d=s.filter((function(e){return-1===u.indexOf(e)}));we.log("".concat(o," ok. successUserIDList:").concat(d," failureUserIDList:").concat(JSON.stringify(l)));var p=0;return d.forEach((function(e){t._conversationModule.patchMessageRemindType({ID:e,isC2CConversation:!0,messageRemindType:a})&&(p+=1)})),p>=1&&t._emitConversationUpdate(),s.length=u.length=0,Ya({successUserIDList:d.map((function(e){return{userID:e}})),failureUserIDList:l})})).catch((function(e){return t._conversationModule.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];c.setError(e,n,a).end()})),we.error("".concat(o," failed. error:"),e),ja(e)}))}},{key:"_getModule",value:function(e){return this._conversationModule.getModule(e)}},{key:"_emitConversationUpdate",value:function(){this._conversationModule.emitConversationUpdate(!0,!1)}},{key:"setUpdateSequence",value:function(e){this._updateSequence=e}},{key:"reset",value:function(){we.log("".concat(this._className,".reset")),this._updateSequence=0}}]),e}(),_s=function(e){i(a,e);var o=f(a);function a(e){var t;return n(this,a),(t=o.call(this,e))._className="ConversationModule",Za.mixin(_(t)),t._messageListHandler=new za,t._messageRemindHandler=new gs(_(t)),t.singlyLinkedList=new cs(100),t._pagingStatus=Wt.NOT_START,t._pagingTimeStamp=0,t._pagingStartIndex=0,t._pagingPinnedTimeStamp=0,t._pagingPinnedStartIndex=0,t._conversationMap=new Map,t._tmpGroupList=[],t._tmpGroupAtTipsList=[],t._peerReadTimeMap=new Map,t._completedMap=new Map,t._roamingMessageKeyAndTimeMap=new Map,t._roamingMessageSequenceMap=new Map,t._remoteGroupReadSequenceMap=new Map,t._initListeners(),t}return s(a,[{key:"_initListeners",value:function(){var e=this.getInnerEmitterInstance();e.on(Ja,this._initLocalConversationList,this),e.on(Qa,this._onProfileUpdated,this)}},{key:"onCheckTimer",value:function(e){e%60==0&&this._messageListHandler.traversal()}},{key:"_initLocalConversationList",value:function(){var e=this,t=new va(ya.GET_CONVERSATION_LIST_IN_STORAGE);we.log("".concat(this._className,"._initLocalConversationList."));var o="",n=this._getStorageConversationList();if(n){for(var a=n.length,s=0;s0&&(e.updateConversationGroupProfile(e._tmpGroupList),e._tmpGroupList.length=0)})),this.syncConversationList()}},{key:"onMessageSent",value:function(e){this._onSendOrReceiveMessage({conversationOptionsList:e.conversationOptionsList,isInstantMessage:!0})}},{key:"onNewMessage",value:function(e){this._onSendOrReceiveMessage(e)}},{key:"_onSendOrReceiveMessage",value:function(e){var t=this,o=e.conversationOptionsList,n=e.isInstantMessage,a=void 0===n||n,s=e.isUnreadC2CMessage,r=void 0!==s&&s;this._isReady?0!==o.length&&(this._getC2CPeerReadTime(o),this._updateLocalConversationList({conversationOptionsList:o,isInstantMessage:a,isUnreadC2CMessage:r,isFromGetConversations:!1}),this._setStorageConversationList(),o.filter((function(e){return e.type===D.CONV_TOPIC})).length>0||this.emitConversationUpdate()):this.ready((function(){t._onSendOrReceiveMessage(e)}))}},{key:"updateConversationGroupProfile",value:function(e){var t=this;if(!Qe(e)||0!==e.length)if(0!==this._conversationMap.size){var o=!1;e.forEach((function(e){var n="GROUP".concat(e.groupID);if(t._conversationMap.has(n)){o=!0;var a=t._conversationMap.get(n);a.groupProfile=JSON.parse(JSON.stringify(e)),a.lastMessage.lastSequence=0;r--)if(!a[r].isDeleted){s=a[r];break}var i=this._conversationMap.get(n);if(i){var c=!1;i.lastMessage.lastSequence===s.sequence&&i.lastMessage.lastTime===s.time||(Vt(s)&&(s=void 0),i.updateLastMessage(s),i.type!==D.CONV_TOPIC&&(c=!0),we.log("".concat(this._className,".onMessageDeleted. update conversationID:").concat(n," with lastMessage:"),i.lastMessage)),n.startsWith(D.CONV_C2C)&&this.updateUnreadCount(n),c&&this.emitConversationUpdate(!0,!1)}}}},{key:"onMessageModified",value:function(e){var t=e.conversationType,o=e.from,n=e.to,a=e.time,s=e.sequence,r=e.elements,i=e.cloudCustomData,c=e.messageVersion,u=this.getMyUserID(),l="".concat(t).concat(n);n===u&&t===D.CONV_C2C&&(l="".concat(t).concat(o));var d=this._messageListHandler.onMessageModified(l,e),p=d.isUpdated,g=d.message;!0===p&&this.emitOuterEvent(S.MESSAGE_MODIFIED,[g]);var _=this._isTopicConversation(l);if(we.log("".concat(this._className,".onMessageModified isUpdated:").concat(p," isTopicMessage:").concat(_," from:").concat(o," to:").concat(n)),_){this.getModule(io).onMessageModified(e)}else{var h=this._conversationMap.get(l);if(h){var f=h.lastMessage;we.debug("".concat(this._className.onMessageModified," lastMessage:"),JSON.stringify(f),"options:",JSON.stringify(e)),f&&f.lastTime===a&&f.lastSequence===s&&f.version!==c&&(f.type=r[0].type,f.payload=r[0].content,f.messageForShow=Ft(f.type,f.payload),f.cloudCustomData=i,f.version=c,this.emitConversationUpdate(!0,!1))}}return g}},{key:"onNewGroupAtTips",value:function(e){var o=this,n=e.dataList,a=null;n.forEach((function(e){e.groupAtTips?a=e.groupAtTips:e.elements&&(a=t(t({},e.elements),{},{sync:!0})),a.__random=e.random,a.__sequence=e.clientSequence,o._tmpGroupAtTipsList.push(a)})),we.debug("".concat(this._className,".onNewGroupAtTips isReady:").concat(this._isReady),this._tmpGroupAtTipsList),this._isReady&&this._handleGroupAtTipsList()}},{key:"_handleGroupAtTipsList",value:function(){var e=this;if(0!==this._tmpGroupAtTipsList.length){var t=!1;this._tmpGroupAtTipsList.forEach((function(o){var n=o.groupID,a=o.from,s=o.topicID,r=void 0===s?void 0:s,i=o.sync,c=void 0!==i&&i;if(a!==e.getMyUserID())if(Ze(r)){var u=e._conversationMap.get("".concat(D.CONV_GROUP).concat(n));u&&(u.updateGroupAtInfoList(o),t=!0)}else{var l=e._conversationMap.get("".concat(D.CONV_GROUP).concat(r));if(l){l.updateGroupAtInfoList(o);var d=e.getModule(io),p=l.groupAtInfoList;d.onConversationProxy({topicID:r,groupAtInfoList:p})}if(Vt(l)&&c)e.updateTopicConversation([{conversationID:"".concat(D.CONV_GROUP).concat(r),type:D.CONV_TOPIC}]),e._conversationMap.get("".concat(D.CONV_GROUP).concat(r)).updateGroupAtInfoList(o)}})),t&&this.emitConversationUpdate(!0,!1),this._tmpGroupAtTipsList.length=0}}},{key:"_getC2CPeerReadTime",value:function(e){var t=this,o=[];if(e.forEach((function(e){t._conversationMap.has(e.conversationID)||e.type!==D.CONV_C2C||o.push(e.conversationID.replace(D.CONV_C2C,""))})),o.length>0){we.debug("".concat(this._className,"._getC2CPeerReadTime userIDList:").concat(o));var n=this.getModule(no);n&&n.getRemotePeerReadTime(o)}}},{key:"_getStorageConversationList",value:function(){return this.getModule(lo).getItem("conversationMap")}},{key:"_setStorageConversationList",value:function(){var e=this.getLocalConversationList().slice(0,20).map((function(e){return{conversationID:e.conversationID,type:e.type,subType:e.subType,lastMessage:e.lastMessage,groupProfile:e.groupProfile,userProfile:e.userProfile}}));this.getModule(lo).setItem("conversationMap",e)}},{key:"emitConversationUpdate",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],o=this.getLocalConversationList();if(t){var n=this.getModule(ao);n&&n.updateGroupLastMessage(o)}e&&this.emitOuterEvent(S.CONVERSATION_LIST_UPDATED)}},{key:"getLocalConversationList",value:function(){return M(this._conversationMap.values()).filter((function(e){return e.type!==D.CONV_TOPIC}))}},{key:"getLocalConversation",value:function(e){return this._conversationMap.get(e)}},{key:"getLocalOldestMessage",value:function(e){return this._messageListHandler.getLocalOldestMessage(e)}},{key:"syncConversationList",value:function(){var e=this,t=new va(ya.SYNC_CONVERSATION_LIST);return this._pagingStatus===Wt.NOT_START&&this._conversationMap.clear(),this._pagingGetConversationList().then((function(o){return e._pagingStatus=Wt.RESOLVED,e._setStorageConversationList(),e._handleC2CPeerReadTime(),e._patchConversationProperties(),t.setMessage(e._conversationMap.size).setNetworkType(e.getNetworkType()).end(),o})).catch((function(o){return e._pagingStatus=Wt.REJECTED,t.setMessage(e._pagingTimeStamp),e.probeNetwork().then((function(e){var n=m(e,2),a=n[0],s=n[1];t.setError(o,a,s).end()})),ja(o)}))}},{key:"_patchConversationProperties",value:function(){var e=this,t=Date.now(),o=this.checkAndPatchRemark(),n=this._messageRemindHandler.getC2CMessageRemindType(),a=this.getModule(ao).getGroupList();Promise.all([o,n,a]).then((function(){var o=Date.now()-t;we.log("".concat(e._className,"._patchConversationProperties ok. cost ").concat(o," ms")),e.emitConversationUpdate(!0,!1)}))}},{key:"_pagingGetConversationList",value:function(){var e=this,t="".concat(this._className,"._pagingGetConversationList");return we.log("".concat(t," timeStamp:").concat(this._pagingTimeStamp," startIndex:").concat(this._pagingStartIndex)+" pinnedTimeStamp:".concat(this._pagingPinnedTimeStamp," pinnedStartIndex:").concat(this._pagingPinnedStartIndex)),this._pagingStatus=Wt.PENDING,this.request({protocolName:$o,requestData:{fromAccount:this.getMyUserID(),timeStamp:this._pagingTimeStamp,startIndex:this._pagingStartIndex,pinnedTimeStamp:this._pagingPinnedTimeStamp,pinnedStartIndex:this._pagingStartIndex,orderType:1}}).then((function(o){var n=o.data,a=n.completeFlag,s=n.conversations,r=void 0===s?[]:s,i=n.timeStamp,c=n.startIndex,u=n.pinnedTimeStamp,l=n.pinnedStartIndex;if(we.log("".concat(t," ok. completeFlag:").concat(a," count:").concat(r.length," isReady:").concat(e._isReady)),r.length>0){var d=e._getConversationOptions(r);e._updateLocalConversationList({conversationOptionsList:d,isFromGetConversations:!0}),e.isLoggedIn()&&e.emitConversationUpdate()}if(!e._isReady){if(!e.isLoggedIn())return Ya();e.triggerReady()}return e._pagingTimeStamp=i,e._pagingStartIndex=c,e._pagingPinnedTimeStamp=u,e._pagingPinnedStartIndex=l,1!==a?e._pagingGetConversationList():(e._handleGroupAtTipsList(),Ya())})).catch((function(o){throw e.isLoggedIn()&&(e._isReady||(we.warn("".concat(t," failed. error:"),o),e.triggerReady())),o}))}},{key:"_updateLocalConversationList",value:function(e){var t,o=e.isFromGetConversations,n=Date.now();t=this._getTmpConversationListMapping(e),this._conversationMap=new Map(this._sortConversationList([].concat(M(t.toBeUpdatedConversationList),M(this._conversationMap)))),o||this._updateUserOrGroupProfile(t.newConversationList),we.debug("".concat(this._className,"._updateLocalConversationList cost ").concat(Date.now()-n," ms"))}},{key:"_getTmpConversationListMapping",value:function(e){for(var t=e.conversationOptionsList,o=e.isFromGetConversations,n=e.isInstantMessage,a=e.isUnreadC2CMessage,s=void 0!==a&&a,r=[],i=[],c=this.getModule(ao),u=this.getModule(so),l=0,d=t.length;l0&&a.getUserProfile({userIDList:o}).then((function(e){var o=e.data;Qe(o)?o.forEach((function(e){t._conversationMap.get("C2C".concat(e.userID)).userProfile=e})):t._conversationMap.get("C2C".concat(o.userID)).userProfile=o})),n.length>0&&s.getGroupProfileAdvance({groupIDList:n,responseFilter:{groupBaseInfoFilter:["Type","Name","FaceUrl"]}}).then((function(e){e.data.successGroupList.forEach((function(e){var o="GROUP".concat(e.groupID);if(t._conversationMap.has(o)){var n=t._conversationMap.get(o);ct(n.groupProfile,e,[],[null,void 0,"",0,NaN]),!n.subType&&e.type&&(n.subType=e.type)}}))}))}}},{key:"_getConversationOptions",value:function(e){var o=this,n=[],a=e.filter((function(e){var t=e.lastMsg;return Xe(t)})).filter((function(e){var t=e.type,o=e.userID;return 1===t&&"@TLS#NOT_FOUND"!==o&&"@TLS#ERROR"!==o||2===t})),s=this.getMyUserID(),r=a.map((function(e){if(1===e.type){var a={userID:e.userID,nick:e.peerNick,avatar:e.peerAvatar};return n.push(a),{conversationID:"C2C".concat(e.userID),type:"C2C",lastMessage:{lastTime:e.time,lastSequence:e.sequence,fromAccount:e.lastC2CMsgFromAccount,messageForShow:e.messageShow,type:e.lastMsg.elements[0]?e.lastMsg.elements[0].type:null,payload:e.lastMsg.elements[0]?e.lastMsg.elements[0].content:null,cloudCustomData:e.lastMsg.cloudCustomData||"",isRevoked:8===e.lastMessageFlag,onlineOnlyFlag:!1,nick:"",nameCard:"",version:0,isPeerRead:e.lastC2CMsgFromAccount===s&&e.time<=e.c2cPeerReadTime},userProfile:new rs(a),peerReadTime:e.c2cPeerReadTime,isPinned:1===e.isPinned,messageRemindType:""}}return{conversationID:"GROUP".concat(e.groupID),type:"GROUP",lastMessage:t(t({lastTime:e.time,lastSequence:e.messageReadSeq+e.unreadCount,fromAccount:e.msgGroupFromAccount,messageForShow:e.messageShow},o._patchTypeAndPayload(e)),{},{cloudCustomData:e.lastMsg.cloudCustomData||"",isRevoked:2===e.lastMessageFlag,onlineOnlyFlag:!1,nick:e.senderNick||"",nameCard:e.senderNameCard||""}),groupProfile:new ls({groupID:e.groupID,name:e.groupNick,avatar:e.groupImage}),unreadCount:e.unreadCount,peerReadTime:0,isPinned:1===e.isPinned,messageRemindType:"",version:0}}));n.length>0&&this.getModule(oo).onConversationsProfileUpdated(n);return r}},{key:"_patchTypeAndPayload",value:function(e){var o=e.lastMsg,n=o.event,a=void 0===n?void 0:n,s=o.elements,r=void 0===s?[]:s,i=o.groupTips,c=void 0===i?{}:i;if(!Ze(a)&&!Vt(c)){var u=new wa(c);u.setElement({type:D.MSG_GRP_TIP,content:t(t({},c.elements),{},{groupProfile:c.groupProfile})});var l=JSON.parse(JSON.stringify(u.payload));return u=null,{type:D.MSG_GRP_TIP,payload:l}}return{type:r[0]?r[0].type:null,payload:r[0]?r[0].content:null}}},{key:"getLocalMessageList",value:function(e){return this._messageListHandler.getLocalMessageList(e)}},{key:"deleteLocalMessage",value:function(e){e instanceof wa&&this._messageListHandler.remove(e)}},{key:"onConversationDeleted",value:function(e){var t=this;we.log("".concat(this._className,".onConversationDeleted")),Qe(e)&&e.forEach((function(e){var o=e.type,n=e.userID,a=e.groupID,s="";1===o?s="".concat(D.CONV_C2C).concat(n):2===o&&(s="".concat(D.CONV_GROUP).concat(a)),t.deleteLocalConversation(s)}))}},{key:"onConversationPinned",value:function(e){var t=this;if(Qe(e)){var o=!1;e.forEach((function(e){var n,a=e.type,s=e.userID,r=e.groupID;1===a?n=t.getLocalConversation("".concat(D.CONV_C2C).concat(s)):2===a&&(n=t.getLocalConversation("".concat(D.CONV_GROUP).concat(r))),n&&(we.log("".concat(t._className,".onConversationPinned conversationID:").concat(n.conversationID," isPinned:").concat(n.isPinned)),n.isPinned||(n.isPinned=!0,o=!0))})),o&&this._sortConversationListAndEmitEvent()}}},{key:"onConversationUnpinned",value:function(e){var t=this;if(Qe(e)){var o=!1;e.forEach((function(e){var n,a=e.type,s=e.userID,r=e.groupID;1===a?n=t.getLocalConversation("".concat(D.CONV_C2C).concat(s)):2===a&&(n=t.getLocalConversation("".concat(D.CONV_GROUP).concat(r))),n&&(we.log("".concat(t._className,".onConversationUnpinned conversationID:").concat(n.conversationID," isPinned:").concat(n.isPinned)),n.isPinned&&(n.isPinned=!1,o=!0))})),o&&this._sortConversationListAndEmitEvent()}}},{key:"getMessageList",value:function(e){var t=this,o=e.conversationID,n=e.nextReqMessageID,a=e.count,s="".concat(this._className,".getMessageList"),r=this.getLocalConversation(o),i="";if(r&&r.groupProfile&&(i=r.groupProfile.type),It(i))return we.log("".concat(s," not available in avchatroom. conversationID:").concat(o)),Ya({messageList:[],nextReqMessageID:"",isCompleted:!0});(Ze(a)||a>15)&&(a=15),this._isFirstGetTopicMessageWithUnJoined(o,n)&&this.removeConversationMessageCache(o);var c=this._computeRemainingCount({conversationID:o,nextReqMessageID:n}),u=this._completedMap.has(o);if(we.log("".concat(s," conversationID:").concat(o," nextReqMessageID:").concat(n)+" remainingCount:".concat(c," count:").concat(a," isCompleted:").concat(u)),this._needGetHistory({conversationID:o,remainingCount:c,count:a}))return this.getHistoryMessages({conversationID:o,nextReqMessageID:n,count:20}).then((function(e){var n=e.nextReqID,a=e.storedMessageList,r=t._completedMap.has(o),i=a;c>0&&(i=t._messageListHandler.getLocalMessageList(o).slice(0,a.length+c));var u={nextReqMessageID:r?"":n,messageList:i,isCompleted:r};return we.log("".concat(s," ret.nextReqMessageID:").concat(u.nextReqMessageID," ret.isCompleted:").concat(u.isCompleted," ret.length:").concat(i.length)),ba(u)}));this.modifyMessageList(o);var l=this._getMessageListFromMemory({conversationID:o,nextReqMessageID:n,count:a});return Ya(l)}},{key:"_getMessageListFromMemory",value:function(e){var t=e.conversationID,o=e.nextReqMessageID,n=e.count,a="".concat(this._className,"._getMessageListFromMemory"),s=this._messageListHandler.getLocalMessageList(t),r=s.length,i=0,c={isCompleted:!1,nextReqMessageID:"",messageList:[]};return o?(i=s.findIndex((function(e){return e.ID===o})))>n?(c.messageList=s.slice(i-n,i),c.nextReqMessageID=s[i-n].ID):(c.messageList=s.slice(0,i),c.isCompleted=!0):r>n?(i=r-n,c.messageList=s.slice(i,r),c.nextReqMessageID=s[i].ID):(c.messageList=s.slice(0,r),c.isCompleted=!0),we.log("".concat(a," conversationID:").concat(t)+" ret.nextReqMessageID:".concat(c.nextReqMessageID," ret.isCompleted:").concat(c.isCompleted," ret.length:").concat(c.messageList.length)),c}},{key:"getMessageListHopping",value:function(e){var t="".concat(this._className,".getMessageListHopping"),o=e.conversationID,n=e.sequence,a=e.time,s=e.count,r=e.direction,i=void 0===r?0:r;(Ze(s)||s>15)&&(s=15);var c=this._messageListHandler.getLocalMessageListHopping({conversationID:o,sequence:n,time:a,count:s,direction:i});if(!Vt(c)){var u=c.length;if(u===s||o.startsWith(D.CONV_GROUP)&&1===c[0].sequence)return we.log("".concat(t,". conversationID:").concat(o," message from memory:").concat(c.length)),Ya({messageList:c});var l=s-u+1,d=1===i?c.pop():c.shift();return this._getRoamingMessagesHopping({conversationID:o,sequence:d.sequence,time:d.time,count:l,direction:i}).then((function(e){var n,a;(we.log("".concat(t,". conversationID:").concat(o," message from memory:").concat(c.length,", message from remote:").concat(e.length)),1===i)?(n=c).push.apply(n,M(e)):(a=c).unshift.apply(a,M(e));if(o.startsWith(D.CONV_C2C)){var s=[];c.forEach((function(e){s.push([e.ID,e])})),c=M(new Map(s).values())}return ba({messageList:c})}))}return this._getRoamingMessagesHopping({conversationID:o,sequence:n,time:a,count:s,direction:i}).then((function(e){return we.log("".concat(t,". conversationID:").concat(o," message from remote:").concat(e.length)),ba({messageList:e})}))}},{key:"_getRoamingMessagesHopping",value:function(e){var t=e.conversationID,o=e.sequence,n=e.time,a=e.count,s=e.direction;if(t.startsWith(D.CONV_C2C)){var r=this.getModule(no),i=t.replace(D.CONV_C2C,"");return r.getRoamingMessagesHopping({peerAccount:i,time:n,count:a,direction:s})}if(t.startsWith(D.CONV_GROUP)){var c=this.getModule(ao),u=t.replace(D.CONV_GROUP,""),l=o;return 1===s&&(l=o+a-1),c.getRoamingMessagesHopping({groupID:u,sequence:l,count:a}).then((function(e){var t=e.findIndex((function(e){return e.sequence===o}));return 1===s?-1===t?[]:e.slice(t):e}))}}},{key:"_computeRemainingCount",value:function(e){var t=e.conversationID,o=e.nextReqMessageID,n=this._messageListHandler.getLocalMessageList(t),a=n.length;if(!o)return a;var s=0;return Ct(t)?s=n.findIndex((function(e){return e.ID===o})):St(t)&&(s=-1!==o.indexOf("-")?n.findIndex((function(e){return e.ID===o})):n.findIndex((function(e){return e.sequence===o}))),-1===s&&(s=0),s}},{key:"_getMessageListSize",value:function(e){return this._messageListHandler.getLocalMessageList(e).length}},{key:"_needGetHistory",value:function(e){var t=e.conversationID,o=e.remainingCount,n=e.count,a=this.getLocalConversation(t),s="";return a&&a.groupProfile&&(s=a.groupProfile.type),!Dt(t)&&!It(s)&&(!(St(t)&&!this._hasLocalGroup(t)&&!this._isTopicConversation(t))&&(o<=n&&!this._completedMap.has(t)))}},{key:"_isTopicConversation",value:function(e){var t=e.replace(D.CONV_GROUP,"");return Tt(t)}},{key:"getHistoryMessages",value:function(e){var t=e.conversationID,o=e.count;if(t===D.CONV_SYSTEM)return Ya();var n=15;o>20&&(n=20);var a=null;if(Ct(t)){var s=this._roamingMessageKeyAndTimeMap.has(t);return(a=this.getModule(no))?a.getRoamingMessage({conversationID:t,peerAccount:t.replace(D.CONV_C2C,""),count:n,lastMessageTime:s?this._roamingMessageKeyAndTimeMap.get(t).lastMessageTime:0,messageKey:s?this._roamingMessageKeyAndTimeMap.get(t).messageKey:""}):ja({code:na.CANNOT_FIND_MODULE,message:aa.CANNOT_FIND_MODULE})}if(St(t)){if(!(a=this.getModule(ao)))return ja({code:na.CANNOT_FIND_MODULE,message:aa.CANNOT_FIND_MODULE});var r=null;this._conversationMap.has(t)&&(r=this._conversationMap.get(t).lastMessage);var i=0;r&&(i=r.lastSequence);var c=this._roamingMessageSequenceMap.get(t);return a.getRoamingMessage({conversationID:t,groupID:t.replace(D.CONV_GROUP,""),count:n,sequence:c||i})}return Ya()}},{key:"patchConversationLastMessage",value:function(e){var t=this.getLocalConversation(e);if(t){var o=t.lastMessage,n=o.messageForShow,a=o.payload;if(Vt(n)||Vt(a)){var s=this._messageListHandler.getLocalMessageList(e);if(0===s.length)return;var r=s[s.length-1];we.log("".concat(this._className,".patchConversationLastMessage conversationID:").concat(e," payload:"),r.payload),t.updateLastMessage(r)}}}},{key:"onRoamingMessage",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],o=arguments.length>1?arguments[1]:void 0,n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],a=o.startsWith(D.CONV_C2C)?D.CONV_C2C:D.CONV_GROUP,s=null,r=[],i=[],c=0,u=e.length,l=null,d=a===D.CONV_GROUP,p=this.getModule(_o),g=function(){c=d?e.length-1:0,u=d?0:e.length},_=function(){d?--c:++c},h=function(){return d?c>=u:c0&&void 0!==arguments[0]?arguments[0]:{},o="".concat(this._className,".setAllMessageRead");t.scope||(t.scope=D.READ_ALL_MSG),we.log("".concat(o," options:"),t);var n=this._createSetAllMessageReadPack(t);if(0===n.readAllC2CMessage&&0===n.groupMessageReadInfoList.length)return Ya();var a=new va(ya.SET_ALL_MESSAGE_READ);return this.request({protocolName:_n,requestData:n}).then((function(o){var n=o.data,s=e._handleAllMessageRead(n);return a.setMessage("scope:".concat(t.scope," failureGroups:").concat(JSON.stringify(s))).setNetworkType(e.getNetworkType()).end(),Ya()})).catch((function(t){return e.probeNetwork().then((function(e){var o=m(e,2),n=o[0],s=o[1];a.setError(t,n,s).end()})),we.warn("".concat(o," failed. error:"),t),ja({code:t&&t.code?t.code:na.MESSAGE_UNREAD_ALL_FAIL,message:t&&t.message?t.message:aa.MESSAGE_UNREAD_ALL_FAIL})}))}},{key:"_getConversationLastMessageSequence",value:function(e){var t=this._messageListHandler.getLocalLastMessage(e.conversationID),o=e.lastMessage.lastSequence;return t&&o0)if(s.type===D.CONV_C2C&&0===o.readAllC2CMessage){if(n===D.READ_ALL_MSG)o.readAllC2CMessage=1;else if(n===D.READ_ALL_C2C_MSG){o.readAllC2CMessage=1;break}}else if(s.type===D.CONV_GROUP&&(n===D.READ_ALL_GROUP_MSG||n===D.READ_ALL_MSG)){var r=this._getConversationLastMessageSequence(s);o.groupMessageReadInfoList.push({groupID:s.groupProfile.groupID,messageSequence:r})}}}catch(i){a.e(i)}finally{a.f()}return o}},{key:"onPushedAllMessageRead",value:function(e){this._handleAllMessageRead(e)}},{key:"_handleAllMessageRead",value:function(e){var t=e.groupMessageReadInfoList,o=e.readAllC2CMessage,n=this._parseGroupReadInfo(t);return this._updateAllConversationUnreadCount({readAllC2CMessage:o})>=1&&this.emitConversationUpdate(!0,!1),n}},{key:"_parseGroupReadInfo",value:function(e){var t=[];if(e&&e.length)for(var o=0,n=e.length;o=1){if(1===o&&i.type===D.CONV_C2C){var c=this._getConversationLastMessageTime(i);this.updateIsReadAfterReadReport({conversationID:r,lastMessageTime:c})}else if(i.type===D.CONV_GROUP){var u=r.replace(D.CONV_GROUP,"");if(this._remoteGroupReadSequenceMap.has(u)){var l=this._remoteGroupReadSequenceMap.get(u),d=this._getConversationLastMessageSequence(i);this.updateIsReadAfterReadReport({conversationID:r,remoteReadSequence:l}),d>=l&&this._remoteGroupReadSequenceMap.delete(u)}}this.updateUnreadCount(r,!1)&&(n+=1)}}}catch(p){a.e(p)}finally{a.f()}return n}},{key:"isRemoteRead",value:function(e){var t=e.conversationID,o=e.sequence,n=t.replace(D.CONV_GROUP,""),a=!1;if(this._remoteGroupReadSequenceMap.has(n)){var s=this._remoteGroupReadSequenceMap.get(n);o<=s&&(a=!0,we.log("".concat(this._className,".isRemoteRead conversationID:").concat(t," messageSequence:").concat(o," remoteReadSequence:").concat(s))),o>=s+10&&this._remoteGroupReadSequenceMap.delete(n)}return a}},{key:"updateIsReadAfterReadReport",value:function(e){var t=e.conversationID,o=e.lastMessageSeq,n=e.lastMessageTime,a=this._messageListHandler.getLocalMessageList(t);if(0!==a.length)for(var s,r=a.length-1;r>=0;r--)if(s=a[r],!(n&&s.time>n||o&&s.sequence>o)){if("in"===s.flow&&s.isRead)break;s.setIsRead(!0)}}},{key:"updateUnreadCount",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],o=!1,n=this.getLocalConversation(e),a=this._messageListHandler.getLocalMessageList(e);if(n){var s=n.unreadCount,r=a.filter((function(e){return!e.isRead&&!e._onlineOnlyFlag&&!e.isDeleted})).length;if(s!==r&&(n.unreadCount=r,o=!0,we.log("".concat(this._className,".updateUnreadCount from ").concat(s," to ").concat(r,", conversationID:").concat(e)),!0===t&&this.emitConversationUpdate(!0,!1)),o&&n.type===D.CONV_TOPIC){var i=n.unreadCount,c=n.groupAtInfoList,u=this.getModule(io),l=e.replace(D.CONV_GROUP,"");u.onConversationProxy({topicID:l,unreadCount:i,groupAtInfoList:c})}return o}}},{key:"updateReadReceiptInfo",value:function(e){var t=this,o=e.userID,n=void 0===o?void 0:o,a=e.groupID,s=void 0===a?void 0:a,r=e.readReceiptList;if(!Vt(r)){var i=[];if(Ze(n)){if(!Ze(s)){var c="".concat(D.CONV_GROUP).concat(s);r.forEach((function(e){var o=e.tinyID,n=e.clientTime,a=e.random,r=e.readCount,u=e.unreadCount,l="".concat(o,"-").concat(n,"-").concat(a),d=t._messageListHandler.getLocalMessage(c,l),p={groupID:s,messageID:l,readCount:0,unreadCount:0};d&&($e(r)&&(d.readReceiptInfo.readCount=r,p.readCount=r),$e(u)&&(d.readReceiptInfo.unreadCount=u,p.unreadCount=u),i.push(p))}))}}else{var u="".concat(D.CONV_C2C).concat(n);r.forEach((function(e){var o=e.tinyID,a=e.clientTime,s=e.random,r="".concat(o,"-").concat(a,"-").concat(s),c=t._messageListHandler.getLocalMessage(u,r);if(c&&!c.isPeerRead){c.isPeerRead=!0;var l={userID:n,messageID:r,isPeerRead:!0};i.push(l)}}))}i.length>0&&this.emitOuterEvent(S.MESSAGE_READ_RECEIPT_RECEIVED,i)}}},{key:"recomputeGroupUnreadCount",value:function(e){var t=e.conversationID,o=e.count,n=this.getLocalConversation(t);if(n){var a=n.unreadCount,s=a-o;s<0&&(s=0),n.unreadCount=s,we.log("".concat(this._className,".recomputeGroupUnreadCount from ").concat(a," to ").concat(s,", conversationID:").concat(t))}}},{key:"updateIsRead",value:function(e){var t=this.getLocalConversation(e),o=this.getLocalMessageList(e);if(t&&0!==o.length&&!Dt(t.type)){for(var n=[],a=0,s=o.length;a0){var o=this._messageListHandler.updateMessageIsPeerReadProperty(e,t);if(o.length>0&&this.emitOuterEvent(S.MESSAGE_READ_BY_PEER,o),this._conversationMap.has(e)){var n=this._conversationMap.get(e).lastMessage;Vt(n)||n.fromAccount===this.getMyUserID()&&n.lastTime<=t&&!n.isPeerRead&&(n.isPeerRead=!0,this.emitConversationUpdate(!0,!1))}}}},{key:"updateMessageIsModifiedProperty",value:function(e){this._messageListHandler.updateMessageIsModifiedProperty(e)}},{key:"setCompleted",value:function(e){we.log("".concat(this._className,".setCompleted. conversationID:").concat(e)),this._completedMap.set(e,!0)}},{key:"updateRoamingMessageKeyAndTime",value:function(e,t,o){this._roamingMessageKeyAndTimeMap.set(e,{messageKey:t,lastMessageTime:o})}},{key:"updateRoamingMessageSequence",value:function(e,t){this._roamingMessageSequenceMap.set(e,t)}},{key:"getConversationList",value:function(e){var t=this,o="".concat(this._className,".getConversationList"),n="pagingStatus:".concat(this._pagingStatus,", local conversation count:").concat(this._conversationMap.size,", options:").concat(e);if(we.log("".concat(o,". ").concat(n)),this._pagingStatus===Wt.REJECTED){var a=new va(ya.GET_CONVERSATION_LIST);return a.setMessage(n),this.syncConversationList().then((function(){a.setNetworkType(t.getNetworkType()).end();var o=t._getConversationList(e);return ba({conversationList:o})})).catch((function(e){return t.probeNetwork().then((function(t){var o=m(t,2),n=o[0],s=o[1];a.setError(e,n,s).end()})),we.error("".concat(o," failed. error:"),e),ja(e)}))}if(0===this._conversationMap.size){var s=new va(ya.GET_CONVERSATION_LIST);return s.setMessage(n),this.syncConversationList().then((function(){s.setNetworkType(t.getNetworkType()).end();var o=t._getConversationList(e);return ba({conversationList:o})})).catch((function(e){return t.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];s.setError(e,n,a).end()})),we.error("".concat(o," failed. error:"),e),ja(e)}))}var r=this._getConversationList(e);return we.log("".concat(o,". returned conversation count:").concat(r.length)),Ya({conversationList:r})}},{key:"_getConversationList",value:function(e){var t=this;if(Ze(e))return this.getLocalConversationList();if(Qe(e)){var o=[];return e.forEach((function(e){if(t._conversationMap.has(e)){var n=t.getLocalConversation(e);o.push(n)}})),o}}},{key:"_handleC2CPeerReadTime",value:function(){var e,t=C(this._conversationMap);try{for(t.s();!(e=t.n()).done;){var o=m(e.value,2),n=o[0],a=o[1];a.type===D.CONV_C2C&&(we.debug("".concat(this._className,"._handleC2CPeerReadTime conversationID:").concat(n," peerReadTime:").concat(a.peerReadTime)),this.recordPeerReadTime(n,a.peerReadTime))}}catch(s){t.e(s)}finally{t.f()}}},{key:"_hasLocalGroup",value:function(e){return this.getModule(ao).hasLocalGroup(e.replace(D.CONV_GROUP,""))}},{key:"getConversationProfile",value:function(e){var t,o=this;if((t=this._conversationMap.has(e)?this._conversationMap.get(e):new ps({conversationID:e,type:e.slice(0,3)===D.CONV_C2C?D.CONV_C2C:D.CONV_GROUP}))._isInfoCompleted||t.type===D.CONV_SYSTEM)return Ya({conversation:t});if(St(e)&&!this._hasLocalGroup(e))return Ya({conversation:t});var n=new va(ya.GET_CONVERSATION_PROFILE),a="".concat(this._className,".getConversationProfile");return we.log("".concat(a,". conversationID:").concat(e," remark:").concat(t.remark," lastMessage:"),t.lastMessage),this._updateUserOrGroupProfileCompletely(t).then((function(s){n.setNetworkType(o.getNetworkType()).setMessage("conversationID:".concat(e," unreadCount:").concat(s.data.conversation.unreadCount)).end();var r=o.getModule(so);if(r&&t.type===D.CONV_C2C){var i=e.replace(D.CONV_C2C,"");if(r.isMyFriend(i)){var c=r.getFriendRemark(i);t.remark!==c&&(t.remark=c,we.log("".concat(a,". conversationID:").concat(e," patch remark:").concat(t.remark)))}}return we.log("".concat(a," ok. conversationID:").concat(e)),s})).catch((function(t){return o.probeNetwork().then((function(o){var a=m(o,2),s=a[0],r=a[1];n.setError(t,s,r).setMessage("conversationID:".concat(e)).end()})),we.error("".concat(a," failed. error:"),t),ja(t)}))}},{key:"_updateUserOrGroupProfileCompletely",value:function(e){var t=this;return e.type===D.CONV_C2C?this.getModule(oo).getUserProfile({userIDList:[e.toAccount]}).then((function(o){var n=o.data;return 0===n.length?ja(new Ba({code:na.USER_OR_GROUP_NOT_FOUND,message:aa.USER_OR_GROUP_NOT_FOUND})):(e.userProfile=n[0],e._isInfoCompleted=!0,t._unshiftConversation(e),Ya({conversation:e}))})):this.getModule(ao).getGroupProfile({groupID:e.toAccount}).then((function(o){return e.groupProfile=o.data.group,e._isInfoCompleted=!0,t._unshiftConversation(e),Ya({conversation:e})}))}},{key:"_unshiftConversation",value:function(e){e instanceof ps&&!this._conversationMap.has(e.conversationID)&&(this._conversationMap=new Map([[e.conversationID,e]].concat(M(this._conversationMap))),this._setStorageConversationList(),this.emitConversationUpdate(!0,!1))}},{key:"_onProfileUpdated",value:function(e){var t=this;e.data.forEach((function(e){var o=e.userID;if(o===t.getMyUserID())t._onMyProfileModified({latestNick:e.nick,latestAvatar:e.avatar});else{var n=t._conversationMap.get("".concat(D.CONV_C2C).concat(o));n&&(n.userProfile=e)}}))}},{key:"deleteConversation",value:function(e){var t=this,o={fromAccount:this.getMyUserID(),toAccount:void 0,type:void 0,toGroupID:void 0};if(!this._conversationMap.has(e)){var n=new Ba({code:na.CONVERSATION_NOT_FOUND,message:aa.CONVERSATION_NOT_FOUND});return ja(n)}var a=this._conversationMap.get(e).type;if(a===D.CONV_C2C)o.type=1,o.toAccount=e.replace(D.CONV_C2C,"");else{if(a!==D.CONV_GROUP){if(a===D.CONV_SYSTEM)return this.getModule(ao).deleteGroupSystemNotice({messageList:this._messageListHandler.getLocalMessageList(e)}),this.deleteLocalConversation(e),Ya({conversationID:e});var s=new Ba({code:na.CONVERSATION_UN_RECORDED_TYPE,message:aa.CONVERSATION_UN_RECORDED_TYPE});return ja(s)}if(!this._hasLocalGroup(e))return this.deleteLocalConversation(e),Ya({conversationID:e});o.type=2,o.toGroupID=e.replace(D.CONV_GROUP,"")}var r=new va(ya.DELETE_CONVERSATION);r.setMessage("conversationID:".concat(e));var i="".concat(this._className,".deleteConversation");return we.log("".concat(i,". conversationID:").concat(e)),this.setMessageRead({conversationID:e}).then((function(){return t.request({protocolName:Jo,requestData:o})})).then((function(){return r.setNetworkType(t.getNetworkType()).end(),we.log("".concat(i," ok")),t.deleteLocalConversation(e),Ya({conversationID:e})})).catch((function(e){return t.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];r.setError(e,n,a).end()})),we.error("".concat(i," failed. error:"),e),ja(e)}))}},{key:"pinConversation",value:function(e){var t=this,o=e.conversationID,n=e.isPinned;if(!this._conversationMap.has(o))return ja({code:na.CONVERSATION_NOT_FOUND,message:aa.CONVERSATION_NOT_FOUND});var a=this.getLocalConversation(o);if(a.isPinned===n)return Ya({conversationID:o});var s=new va(ya.PIN_CONVERSATION);s.setMessage("conversationID:".concat(o," isPinned:").concat(n));var r="".concat(this._className,".pinConversation");we.log("".concat(r,". conversationID:").concat(o," isPinned:").concat(n));var i=null;return Ct(o)?i={type:1,toAccount:o.replace(D.CONV_C2C,"")}:St(o)&&(i={type:2,groupID:o.replace(D.CONV_GROUP,"")}),this.request({protocolName:Xo,requestData:{fromAccount:this.getMyUserID(),operationType:!0===n?1:2,itemList:[i]}}).then((function(){return s.setNetworkType(t.getNetworkType()).end(),we.log("".concat(r," ok")),a.isPinned!==n&&(a.isPinned=n,t._sortConversationListAndEmitEvent()),ba({conversationID:o})})).catch((function(e){return t.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];s.setError(e,n,a).end()})),we.error("".concat(r," failed. error:"),e),ja(e)}))}},{key:"setMessageRemindType",value:function(e){return this._messageRemindHandler.set(e)}},{key:"patchMessageRemindType",value:function(e){var t=e.ID,o=e.isC2CConversation,n=e.messageRemindType,a=!1,s=this.getLocalConversation(o?"".concat(D.CONV_C2C).concat(t):"".concat(D.CONV_GROUP).concat(t));return s&&s.messageRemindType!==n&&(s.messageRemindType=n,a=!0),a}},{key:"onC2CMessageRemindTypeSynced",value:function(e){var t=this;we.debug("".concat(this._className,".onC2CMessageRemindTypeSynced options:"),e),e.dataList.forEach((function(e){if(!Vt(e.muteNotificationsSync)){var o,n=e.muteNotificationsSync,a=n.to,s=n.updateSequence,r=n.muteFlag;t._messageRemindHandler.setUpdateSequence(s),0===r?o=D.MSG_REMIND_ACPT_AND_NOTE:1===r?o=D.MSG_REMIND_DISCARD:2===r&&(o=D.MSG_REMIND_ACPT_NOT_NOTE);var i=0;t.patchMessageRemindType({ID:a,isC2CConversation:!0,messageRemindType:o})&&(i+=1),we.log("".concat(t._className,".onC2CMessageRemindTypeSynced updateCount:").concat(i)),i>=1&&t.emitConversationUpdate(!0,!1)}}))}},{key:"deleteLocalConversation",value:function(e){var t=this._conversationMap.has(e);we.log("".concat(this._className,".deleteLocalConversation conversationID:").concat(e," has:").concat(t)),t&&(this._conversationMap.delete(e),this._roamingMessageKeyAndTimeMap.has(e)&&this._roamingMessageKeyAndTimeMap.delete(e),this._roamingMessageSequenceMap.has(e)&&this._roamingMessageSequenceMap.delete(e),this._setStorageConversationList(),this._messageListHandler.removeByConversationID(e),this._completedMap.delete(e),this.emitConversationUpdate(!0,!1))}},{key:"isMessageSentByCurrentInstance",value:function(e){return!(!this._messageListHandler.hasLocalMessage(e.conversationID,e.ID)&&!this.singlyLinkedList.has(e.random))}},{key:"modifyMessageList",value:function(e){if(e.startsWith(D.CONV_C2C)&&this._conversationMap.has(e)){var t=this._conversationMap.get(e),o=Date.now();this._messageListHandler.modifyMessageSentByPeer({conversationID:e,latestNick:t.userProfile.nick,latestAvatar:t.userProfile.avatar});var n=this.getModule(oo).getNickAndAvatarByUserID(this.getMyUserID());this._messageListHandler.modifyMessageSentByMe({conversationID:e,latestNick:n.nick,latestAvatar:n.avatar}),we.log("".concat(this._className,".modifyMessageList conversationID:").concat(e," cost ").concat(Date.now()-o," ms"))}}},{key:"updateUserProfileSpecifiedKey",value:function(e){we.log("".concat(this._className,".updateUserProfileSpecifiedKey options:"),e);var t=e.conversationID,o=e.nick,n=e.avatar;if(this._conversationMap.has(t)){var a=this._conversationMap.get(t).userProfile;ze(o)&&a.nick!==o&&(a.nick=o),ze(n)&&a.avatar!==n&&(a.avatar=n),this.emitConversationUpdate(!0,!1)}}},{key:"_onMyProfileModified",value:function(e){var o=this,n=this.getLocalConversationList(),a=Date.now();n.forEach((function(n){o.modifyMessageSentByMe(t({conversationID:n.conversationID},e))})),we.log("".concat(this._className,"._onMyProfileModified. modify all messages sent by me, cost ").concat(Date.now()-a," ms"))}},{key:"modifyMessageSentByMe",value:function(e){this._messageListHandler.modifyMessageSentByMe(e)}},{key:"getLatestMessageSentByMe",value:function(e){return this._messageListHandler.getLatestMessageSentByMe(e)}},{key:"modifyMessageSentByPeer",value:function(e){this._messageListHandler.modifyMessageSentByPeer(e)}},{key:"getLatestMessageSentByPeer",value:function(e){return this._messageListHandler.getLatestMessageSentByPeer(e)}},{key:"pushIntoNoticeResult",value:function(e,t){return!(!this._messageListHandler.pushIn(t)||this.singlyLinkedList.has(t.random))&&(e.push(t),!0)}},{key:"getGroupLocalLastMessageSequence",value:function(e){return this._messageListHandler.getGroupLocalLastMessageSequence(e)}},{key:"checkAndPatchRemark",value:function(){var e=Promise.resolve();if(0===this._conversationMap.size)return e;var t=this.getModule(so);if(!t)return e;var o=M(this._conversationMap.values()).filter((function(e){return e.type===D.CONV_C2C}));if(0===o.length)return e;var n=0;return o.forEach((function(e){var o=e.conversationID.replace(D.CONV_C2C,"");if(t.isMyFriend(o)){var a=t.getFriendRemark(o);e.remark!==a&&(e.remark=a,n+=1)}})),we.log("".concat(this._className,".checkAndPatchRemark. c2c conversation count:").concat(o.length,", patched count:").concat(n)),e}},{key:"updateTopicConversation",value:function(e){this._updateLocalConversationList({conversationOptionsList:e,isFromGetConversations:!0})}},{key:"sendReadReceipt",value:function(e){var t=e[0],o=null;return t.conversationType===D.CONV_C2C?o=this._moduleManager.getModule(no):t.conversationType===D.CONV_GROUP&&(o=this._moduleManager.getModule(ao)),o?o.sendReadReceipt(e):ja({code:na.CANNOT_FIND_MODULE,message:aa.CANNOT_FIND_MODULE})}},{key:"getReadReceiptList",value:function(e){var t=e[0],o=null;return t.conversationType===D.CONV_C2C?o=this._moduleManager.getModule(no):t.conversationType===D.CONV_GROUP&&(o=this._moduleManager.getModule(ao)),o?o.getReadReceiptList(e):ja({code:na.CANNOT_FIND_MODULE,message:aa.CANNOT_FIND_MODULE})}},{key:"getLastMessageTime",value:function(e){var t=this.getLocalConversation(e);return t?t.lastMessage.lastTime:0}},{key:"reset",value:function(){we.log("".concat(this._className,".reset")),this._pagingStatus=Wt.NOT_START,this._messageListHandler.reset(),this._messageRemindHandler.reset(),this._roamingMessageKeyAndTimeMap.clear(),this._roamingMessageSequenceMap.clear(),this.singlyLinkedList.reset(),this._peerReadTimeMap.clear(),this._completedMap.clear(),this._conversationMap.clear(),this._pagingTimeStamp=0,this._pagingStartIndex=0,this._pagingPinnedTimeStamp=0,this._pagingPinnedStartIndex=0,this._remoteGroupReadSequenceMap.clear(),this.resetReady()}}]),a}(Do),hs=function(){function e(t){n(this,e),this._groupModule=t,this._className="GroupTipsHandler",this._cachedGroupTipsMap=new Map,this._checkCountMap=new Map,this.MAX_CHECK_COUNT=4,this._getTopicPendingMap=new Map}return s(e,[{key:"onCheckTimer",value:function(e){e%1==0&&this._cachedGroupTipsMap.size>0&&this._checkCachedGroupTips()}},{key:"_checkCachedGroupTips",value:function(){var e=this;this._cachedGroupTipsMap.forEach((function(t,o){var n=e._checkCountMap.get(o),a=e._groupModule.hasLocalGroup(o);we.log("".concat(e._className,"._checkCachedGroupTips groupID:").concat(o," hasLocalGroup:").concat(a," checkCount:").concat(n)),a?(e._notifyCachedGroupTips(o),e._checkCountMap.delete(o),e._groupModule.deleteUnjoinedAVChatRoom(o)):n>=e.MAX_CHECK_COUNT?(e._deleteCachedGroupTips(o),e._checkCountMap.delete(o)):(n++,e._checkCountMap.set(o,n))}))}},{key:"onNewGroupTips",value:function(e){we.debug("".concat(this._className,".onReceiveGroupTips count:").concat(e.dataList.length));var t=this.newGroupTipsStoredAndSummary(e),o=t.eventDataList,n=t.result,a=t.AVChatRoomMessageList;(a.length>0&&this._groupModule.onAVChatRoomMessage(a),o.length>0)&&(this._groupModule.updateNextMessageSeq(o),this._groupModule.getModule(co).onNewMessage({conversationOptionsList:o,isInstantMessage:!0}));n.length>0&&(this._groupModule.emitOuterEvent(S.MESSAGE_RECEIVED,n),this.handleMessageList(n))}},{key:"newGroupTipsStoredAndSummary",value:function(e){for(var o=this,n=e.event,a=e.dataList,s=null,r=[],i=[],c={},u=[],l=function(e,l){var d=Mt(a[e]),p=d.groupProfile,g=p.groupID,_=p.communityType,h=void 0===_?0:_,f=p.topicID,m=void 0===f?void 0:f,M=void 0,v=2===h&&!Vt(m);if(v){M=D.CONV_TOPIC,d.to=m;var y=o._groupModule.getModule(io);y.hasLocalTopic(g,m)||o._getTopicPendingMap.has(m)||(o._getTopicPendingMap.set(m,1),y.getTopicList({groupID:g,topicIDList:[m]}).finally((function(){o._getTopicPendingMap.delete(m)})))}if(2===h&&Vt(m))return"continue";var I=o._groupModule.hasLocalGroup(g);if(!I&&o._groupModule.isUnjoinedAVChatRoom(g))return"continue";if(!I&&!v)return o._cacheGroupTipsAndProbe({groupID:g,event:n,item:d}),"continue";if(o._groupModule.isMessageFromOrToAVChatroom(g))return d.event=n,u.push(d),"continue";d.currentUser=o._groupModule.getMyUserID(),d.conversationType=D.CONV_GROUP,(s=new wa(d)).setElement({type:D.MSG_GRP_TIP,content:t(t({},d.elements),{},{groupProfile:d.groupProfile})}),s.isSystemMessage=!1;var E=o._groupModule.getModule(co),T=s,C=T.conversationID,S=T.sequence;if(6===n)s._onlineOnlyFlag=!0,i.push(s);else if(!E.pushIntoNoticeResult(i,s))return"continue";if(6===n&&E.getLocalConversation(C))return"continue";6!==n&&o._groupModule.getModule(Co).addMessageSequence({key:pa,message:s});var N=E.isRemoteRead({conversationID:C,sequence:S});if(Ze(c[C])){var A=0;"in"===s.flow&&(s._isExcludedFromUnreadCount||s._onlineOnlyFlag||N||(A=1)),c[C]=r.push({conversationID:C,unreadCount:A,type:Ze(M)?s.conversationType:M,subType:s.conversationSubType,lastMessage:s._isExcludedFromLastMessage?"":s})-1}else{var O=c[C];r[O].type=s.conversationType,r[O].subType=s.conversationSubType,r[O].lastMessage=s._isExcludedFromLastMessage?"":s,"in"===s.flow&&(s._isExcludedFromUnreadCount||s._onlineOnlyFlag||N||r[O].unreadCount++)}},d=0,p=a.length;d=0){c.updateSelfInfo({muteTime:d.muteTime}),u=!0;break}}u&&this._groupModule.emitOuterEvent(S.TOPIC_UPDATED,{groupID:i,topic:c})}}},{key:"_onTopicProfileUpdated",value:function(e){var o=e.payload,n=o.groupProfile.groupID,a=o.newTopicInfo;this._groupModule.getModule(io).onTopicProfileUpdated(t({groupID:n,topicID:e.to},a))}},{key:"_cacheGroupTips",value:function(e,t){this._cachedGroupTipsMap.has(e)||this._cachedGroupTipsMap.set(e,[]),this._cachedGroupTipsMap.get(e).push(t)}},{key:"_deleteCachedGroupTips",value:function(e){this._cachedGroupTipsMap.has(e)&&this._cachedGroupTipsMap.delete(e)}},{key:"_notifyCachedGroupTips",value:function(e){var t=this,o=this._cachedGroupTipsMap.get(e)||[];o.forEach((function(e){t.onNewGroupTips(e)})),this._deleteCachedGroupTips(e),we.log("".concat(this._className,"._notifyCachedGroupTips groupID:").concat(e," count:").concat(o.length))}},{key:"_cacheGroupTipsAndProbe",value:function(e){var t=this,o=e.groupID,n=e.event,a=e.item;this._cacheGroupTips(o,{event:n,dataList:[a]}),this._groupModule.getGroupSimplifiedInfo(o).then((function(e){e.type===D.GRP_AVCHATROOM?t._groupModule.hasLocalGroup(o)?t._notifyCachedGroupTips(o):t._groupModule.setUnjoinedAVChatRoom(o):(t._groupModule.updateGroupMap([e]),t._notifyCachedGroupTips(o))})),this._checkCountMap.has(o)||this._checkCountMap.set(o,0),we.log("".concat(this._className,"._cacheGroupTipsAndProbe groupID:").concat(o))}},{key:"reset",value:function(){this._cachedGroupTipsMap.clear(),this._checkCountMap.clear(),this._getTopicPendingMap.clear()}}]),e}(),fs=function(){function e(t){n(this,e),this._groupModule=t,this._className="CommonGroupHandler",this.tempConversationList=null,this._cachedGroupMessageMap=new Map,this._checkCountMap=new Map,this.MAX_CHECK_COUNT=4,this._getTopicPendingMap=new Map,t.getInnerEmitterInstance().once(Ja,this._initGroupList,this)}return s(e,[{key:"onCheckTimer",value:function(e){e%1==0&&this._cachedGroupMessageMap.size>0&&this._checkCachedGroupMessage()}},{key:"_checkCachedGroupMessage",value:function(){var e=this;this._cachedGroupMessageMap.forEach((function(t,o){var n=e._checkCountMap.get(o),a=e._groupModule.hasLocalGroup(o);we.log("".concat(e._className,"._checkCachedGroupMessage groupID:").concat(o," hasLocalGroup:").concat(a," checkCount:").concat(n)),a?(e._notifyCachedGroupMessage(o),e._checkCountMap.delete(o),e._groupModule.deleteUnjoinedAVChatRoom(o)):n>=e.MAX_CHECK_COUNT?(e._deleteCachedGroupMessage(o),e._checkCountMap.delete(o)):(n++,e._checkCountMap.set(o,n))}))}},{key:"_initGroupList",value:function(){var e=this;we.log("".concat(this._className,"._initGroupList"));var t=new va(ya.GET_GROUP_LIST_IN_STORAGE),o=this._groupModule.getStorageGroupList();if(Qe(o)&&o.length>0){o.forEach((function(t){e._groupModule.initGroupMap(t)})),this._groupModule.emitGroupListUpdate(!0,!1);var n=this._groupModule.getLocalGroupList().length;t.setNetworkType(this._groupModule.getNetworkType()).setMessage("group count:".concat(n)).end()}else t.setNetworkType(this._groupModule.getNetworkType()).setMessage("group count:0").end();we.log("".concat(this._className,"._initGroupList ok"))}},{key:"handleUpdateGroupLastMessage",value:function(e){var t="".concat(this._className,".handleUpdateGroupLastMessage");if(we.debug("".concat(t," conversation count:").concat(e.length,", local group count:").concat(this._groupModule.getLocalGroupList().length)),0!==this._groupModule.getGroupMap().size){for(var o,n,a,s=!1,r=0,i=e.length;r0&&this._groupModule.onAVChatRoomMessage(a),this._groupModule.filterModifiedMessage(n),o.length>0)&&(this._groupModule.updateNextMessageSeq(o),this._groupModule.getModule(co).onNewMessage({conversationOptionsList:o,isInstantMessage:!0}));var s=this._groupModule.filterUnmodifiedMessage(n);s.length>0&&this._groupModule.emitOuterEvent(S.MESSAGE_RECEIVED,s),n.length=0}},{key:"_newGroupMessageStoredAndSummary",value:function(e){var t=this,o=e.dataList,n=e.event,a=e.isInstantMessage,s=null,r=[],i=[],c=[],u={},l=this._groupModule.getModule(_o),d=this._groupModule.getModule(Co),p=o.length;p>1&&o.sort((function(e,t){return e.sequence-t.sequence}));for(var g=function(e){var p=Mt(o[e]),g=p.groupProfile,_=g.groupID,h=g.communityType,f=void 0===h?0:h,m=g.topicID,M=void 0===m?void 0:m,v=void 0,y=2===f&&!Vt(M);if(y){v=D.CONV_TOPIC,p.to=M;var I=t._groupModule.getModule(io);I.hasLocalTopic(_,M)||t._getTopicPendingMap.has(M)||(t._getTopicPendingMap.set(M,1),I.getTopicList({groupID:_,topicIDList:[M]}).finally((function(){t._getTopicPendingMap.delete(M)})))}if(2===f&&Vt(M))return"continue";var E=t._groupModule.hasLocalGroup(_);if(!E&&t._groupModule.isUnjoinedAVChatRoom(_))return"continue";if(!E&&!y)return t._cacheGroupMessageAndProbe({groupID:_,event:n,item:p}),"continue";if(t._groupModule.isMessageFromOrToAVChatroom(_))return p.event=n,c.push(p),"continue";p.currentUser=t._groupModule.getMyUserID(),p.conversationType=D.CONV_GROUP,p.isSystemMessage=!!p.isSystemMessage,s=new wa(p),p.elements=l.parseElements(p.elements,p.from),s.setElement(p.elements);var T=1===o[e].isModified,C=t._groupModule.getModule(co);if(C.isMessageSentByCurrentInstance(s)?s.isModified=T:T=!1,1===p.onlineOnlyFlag)s._onlineOnlyFlag=!0,i.push(s);else{if(!C.pushIntoMessageList(i,s,T))return"continue";d.addMessageSequence({key:pa,message:s}),a&&s.clientTime>0&&d.addMessageDelay(s.clientTime);var S=s,N=S.conversationID,A=S.sequence,O=C.isRemoteRead({conversationID:N,sequence:A});if(Ze(u[N])){var R=0;"in"===s.flow&&(s._isExcludedFromUnreadCount||O||(R=1)),u[N]=r.push({conversationID:N,unreadCount:R,type:Ze(v)?s.conversationType:v,subType:s.conversationSubType,lastMessage:s._isExcludedFromLastMessage?"":s})-1}else{var L=u[N];r[L].type=Ze(v)?s.conversationType:v,r[L].subType=s.conversationSubType,r[L].lastMessage=s._isExcludedFromLastMessage?"":s,"in"===s.flow&&(s._isExcludedFromUnreadCount||O||r[L].unreadCount++)}}},_=0;_g),h="offset:".concat(c," totalCount:").concat(p," isCompleted:").concat(_," ")+"currentCount:".concat(l.length," isCommunityRelay:").concat(a);return d.setNetworkType(t._groupModule.getNetworkType()).setMessage("".concat(h)).end(),a||_?!a&&_?(we.log("".concat(o," start to get community list")),c=0,t._pagingGetGroupList({limit:i,offset:c,groupBaseInfoFilter:u,groupList:l,isCommunityRelay:!0})):a&&!_?(c=g,t._pagingGetGroupList({limit:i,offset:c,groupBaseInfoFilter:u,groupList:l,isCommunityRelay:!0})):(we.log("".concat(o," ok. totalCount:").concat(l.length)),ba({groupList:l})):(c=g,t._pagingGetGroupList({limit:i,offset:c,groupBaseInfoFilter:u,groupList:l}))})).catch((function(e){return 11e3!==e.code&&t._groupModule.probeNetwork().then((function(t){var o=m(t,2),n=o[0],s=o[1];d.setMessage("isCommunityRelay:".concat(a)).setError(e,n,s).end()})),a?(11e3===e.code&&(d=null,we.log("".concat(o," ok. community unavailable"))),Ya({groupList:l})):ja(e)}))}},{key:"_pagingGetGroupListWithTopic",value:function(e){var t=this,o="".concat(this._className,"._pagingGetGroupListWithTopic"),n=e.limit,a=e.offset,s=e.groupBaseInfoFilter,r=e.groupList,i=new va(ya.PAGING_GET_GROUP_LIST_WITH_TOPIC);return this._groupModule.request({protocolName:Zo,requestData:{type:D.GRP_COMMUNITY,memberAccount:this._groupModule.getMyUserID(),limit:n,offset:a,responseFilter:{groupBaseInfoFilter:s,selfInfoFilter:["Role","JoinTime","MsgFlag","MsgSeq"]},isSupportTopic:1}}).then((function(e){var c=e.data,u=c.groups,l=void 0===u?[]:u,d=c.totalCount;r.push.apply(r,M(l));var p=a+n,g=!(d>p),_="offset:".concat(a," totalCount:").concat(d," isCompleted:").concat(g," ")+"currentCount:".concat(r.length);return i.setNetworkType(t._groupModule.getNetworkType()).setMessage("".concat(_)).end(),g?(we.log("".concat(o," ok. totalCount:").concat(r.length)),ba({groupList:r})):(a=p,t._pagingGetGroupListWithTopic({limit:n,offset:a,groupBaseInfoFilter:s,groupList:r}))})).catch((function(e){return t._groupModule.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];i.setError(e,n,a).end()})),ja(e)}))}},{key:"_cacheGroupMessage",value:function(e,t){this._cachedGroupMessageMap.has(e)||this._cachedGroupMessageMap.set(e,[]),this._cachedGroupMessageMap.get(e).push(t)}},{key:"_deleteCachedGroupMessage",value:function(e){this._cachedGroupMessageMap.has(e)&&this._cachedGroupMessageMap.delete(e)}},{key:"_notifyCachedGroupMessage",value:function(e){var t=this,o=this._cachedGroupMessageMap.get(e)||[];o.forEach((function(e){t.onNewGroupMessage(e)})),this._deleteCachedGroupMessage(e),we.log("".concat(this._className,"._notifyCachedGroupMessage groupID:").concat(e," count:").concat(o.length))}},{key:"_cacheGroupMessageAndProbe",value:function(e){var t=this,o=e.groupID,n=e.event,a=e.item;this._cacheGroupMessage(o,{event:n,dataList:[a]}),this._groupModule.getGroupSimplifiedInfo(o).then((function(e){e.type===D.GRP_AVCHATROOM?t._groupModule.hasLocalGroup(o)?t._notifyCachedGroupMessage(o):t._groupModule.setUnjoinedAVChatRoom(o):(t._groupModule.updateGroupMap([e]),t._notifyCachedGroupMessage(o))})),this._checkCountMap.has(o)||this._checkCountMap.set(o,0),we.log("".concat(this._className,"._cacheGroupMessageAndProbe groupID:").concat(o))}},{key:"reset",value:function(){this._cachedGroupMessageMap.clear(),this._checkCountMap.clear(),this._getTopicPendingMap.clear(),this._groupModule.getInnerEmitterInstance().once(Ja,this._initGroupList,this)}}]),e}(),ms={1:"init",2:"modify",3:"clear",4:"delete"},Ms=function(){function e(t){n(this,e),this._groupModule=t,this._className="GroupAttributesHandler",this._groupAttributesMap=new Map,this.CACHE_EXPIRE_TIME=3e4,this._groupModule.getInnerEmitterInstance().on(Xa,this._onCloudConfigUpdated,this)}return s(e,[{key:"_onCloudConfigUpdated",value:function(){var e=this._groupModule.getCloudConfig("grp_attr_cache_time");Ze(e)||(this.CACHE_EXPIRE_TIME=Number(e))}},{key:"updateLocalMainSequenceOnReconnected",value:function(){this._groupAttributesMap.forEach((function(e){e.localMainSequence=0}))}},{key:"onGroupAttributesUpdated",value:function(e){var t=this,o=e.groupID,n=e.groupAttributeOption,a=n.mainSequence,s=n.hasChangedAttributeInfo,r=n.groupAttributeList,i=void 0===r?[]:r,c=n.operationType;if(we.log("".concat(this._className,".onGroupAttributesUpdated. groupID:").concat(o," hasChangedAttributeInfo:").concat(s," operationType:").concat(c)),!Ze(c)){if(1===s){if(4===c){var u=[];i.forEach((function(e){u.push(e.key)})),i=M(u),u=null}return this._refreshCachedGroupAttributes({groupID:o,remoteMainSequence:a,groupAttributeList:i,operationType:ms[c]}),void this._emitGroupAttributesUpdated(o)}if(this._groupAttributesMap.has(o)){var l=this._groupAttributesMap.get(o).avChatRoomKey;this._getGroupAttributes({groupID:o,avChatRoomKey:l}).then((function(){t._emitGroupAttributesUpdated(o)}))}}}},{key:"initGroupAttributesCache",value:function(e){var t=e.groupID,o=e.avChatRoomKey;this._groupAttributesMap.set(t,{lastUpdateTime:0,localMainSequence:0,remoteMainSequence:0,attributes:new Map,avChatRoomKey:o}),we.log("".concat(this._className,".initGroupAttributesCache groupID:").concat(t," avChatRoomKey:").concat(o))}},{key:"initGroupAttributes",value:function(e){var t=this,o=e.groupID,n=e.groupAttributes,a=this._checkCachedGroupAttributes({groupID:o,funcName:"initGroupAttributes"});if(!0!==a)return ja(a);var s=this._groupAttributesMap.get(o),r=s.remoteMainSequence,i=s.avChatRoomKey,c=new va(ya.INIT_GROUP_ATTRIBUTES);return c.setMessage("groupID:".concat(o," mainSequence:").concat(r," groupAttributes:").concat(JSON.stringify(n))),this._groupModule.request({protocolName:Nn,requestData:{groupID:o,avChatRoomKey:i,mainSequence:r,groupAttributeList:this._transformGroupAttributes(n)}}).then((function(e){var a=e.data,s=a.mainSequence,r=M(a.groupAttributeList);return r.forEach((function(e){e.value=n[e.key]})),t._refreshCachedGroupAttributes({groupID:o,remoteMainSequence:s,groupAttributeList:r,operationType:"init"}),c.setNetworkType(t._groupModule.getNetworkType()).end(),we.log("".concat(t._className,".initGroupAttributes ok. groupID:").concat(o)),ba({groupAttributes:n})})).catch((function(e){return t._groupModule.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];c.setError(e,n,a).end()})),ja(e)}))}},{key:"setGroupAttributes",value:function(e){var t=this,o=e.groupID,n=e.groupAttributes,a=this._checkCachedGroupAttributes({groupID:o,funcName:"setGroupAttributes"});if(!0!==a)return ja(a);var s=this._groupAttributesMap.get(o),r=s.remoteMainSequence,i=s.avChatRoomKey,c=s.attributes,u=this._transformGroupAttributes(n);u.forEach((function(e){var t=e.key;e.sequence=0,c.has(t)&&(e.sequence=c.get(t).sequence)}));var l=new va(ya.SET_GROUP_ATTRIBUTES);return l.setMessage("groupID:".concat(o," mainSequence:").concat(r," groupAttributes:").concat(JSON.stringify(n))),this._groupModule.request({protocolName:An,requestData:{groupID:o,avChatRoomKey:i,mainSequence:r,groupAttributeList:u}}).then((function(e){var a=e.data,s=a.mainSequence,r=M(a.groupAttributeList);return r.forEach((function(e){e.value=n[e.key]})),t._refreshCachedGroupAttributes({groupID:o,remoteMainSequence:s,groupAttributeList:r,operationType:"modify"}),l.setNetworkType(t._groupModule.getNetworkType()).end(),we.log("".concat(t._className,".setGroupAttributes ok. groupID:").concat(o)),ba({groupAttributes:n})})).catch((function(e){return t._groupModule.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];l.setError(e,n,a).end()})),ja(e)}))}},{key:"deleteGroupAttributes",value:function(e){var t=this,o=e.groupID,n=e.keyList,a=void 0===n?[]:n,s=this._checkCachedGroupAttributes({groupID:o,funcName:"deleteGroupAttributes"});if(!0!==s)return ja(s);var r=this._groupAttributesMap.get(o),i=r.remoteMainSequence,c=r.avChatRoomKey,u=r.attributes,l=M(u.keys()),d=Rn,p="clear",g={groupID:o,avChatRoomKey:c,mainSequence:i};if(a.length>0){var _=[];l=[],d=On,p="delete",a.forEach((function(e){var t=0;u.has(e)&&(t=u.get(e).sequence,l.push(e)),_.push({key:e,sequence:t})})),g.groupAttributeList=_}var h=new va(ya.DELETE_GROUP_ATTRIBUTES);return h.setMessage("groupID:".concat(o," mainSequence:").concat(i," keyList:").concat(a," protocolName:").concat(d)),this._groupModule.request({protocolName:d,requestData:g}).then((function(e){var n=e.data.mainSequence;return t._refreshCachedGroupAttributes({groupID:o,remoteMainSequence:n,groupAttributeList:a,operationType:p}),h.setNetworkType(t._groupModule.getNetworkType()).end(),we.log("".concat(t._className,".deleteGroupAttributes ok. groupID:").concat(o)),ba({keyList:l})})).catch((function(e){return t._groupModule.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];h.setError(e,n,a).end()})),ja(e)}))}},{key:"getGroupAttributes",value:function(e){var t=this,o=e.groupID,n=this._checkCachedGroupAttributes({groupID:o,funcName:"getGroupAttributes"});if(!0!==n)return ja(n);var a=this._groupAttributesMap.get(o),s=a.avChatRoomKey,r=a.lastUpdateTime,i=a.localMainSequence,c=a.remoteMainSequence,u=new va(ya.GET_GROUP_ATTRIBUTES);if(u.setMessage("groupID:".concat(o," localMainSequence:").concat(i," remoteMainSequence:").concat(c," keyList:").concat(e.keyList)),Date.now()-r>=this.CACHE_EXPIRE_TIME||i0)n.forEach((function(e){s.has(e)&&(a[e]=s.get(e).value)}));else{var r,i=C(s.keys());try{for(i.s();!(r=i.n()).done;){var c=r.value;a[c]=s.get(c).value}}catch(u){i.e(u)}finally{i.f()}}return a}},{key:"_refreshCachedGroupAttributes",value:function(e){var t=e.groupID,o=e.remoteMainSequence,n=e.groupAttributeList,a=e.operationType;if(this._groupAttributesMap.has(t)){var s=this._groupAttributesMap.get(t),r=s.localMainSequence;if("get"===a||o-r==1)s.remoteMainSequence=o,s.localMainSequence=o,s.lastUpdateTime=Date.now(),this._updateCachedAttributes({groupAttributes:s,groupAttributeList:n,operationType:a});else{if(r===o)return;s.remoteMainSequence=o}this._groupAttributesMap.set(t,s);var i="operationType:".concat(a," localMainSequence:").concat(r," remoteMainSequence:").concat(o);we.log("".concat(this._className,"._refreshCachedGroupAttributes. ").concat(i))}}},{key:"_updateCachedAttributes",value:function(e){var t=e.groupAttributes,o=e.groupAttributeList,n=e.operationType;"clear"!==n?"delete"!==n?("init"===n&&t.attributes.clear(),o.forEach((function(e){var o=e.key,n=e.value,a=e.sequence;t.attributes.set(o,{value:n,sequence:a})}))):o.forEach((function(e){t.attributes.delete(e)})):t.attributes.clear()}},{key:"_checkCachedGroupAttributes",value:function(e){var t=e.groupID,o=e.funcName;if(this._groupModule.hasLocalGroup(t)&&this._groupModule.getLocalGroupProfile(t).type!==D.GRP_AVCHATROOM){return we.warn("".concat(this._className,"._checkCachedGroupAttributes. ").concat("非直播群不能使用群属性 API")),new Ba({code:na.CANNOT_USE_GRP_ATTR_NOT_AVCHATROOM,message:"非直播群不能使用群属性 API"})}var n=this._groupAttributesMap.get(t);if(Ze(n)){var a="如果 groupID:".concat(t," 是直播群,使用 ").concat(o," 前先使用 joinGroup 接口申请加入群组,详细请参考 https://web.sdk.qcloud.com/im/doc/zh-cn/SDK.html#joinGroup");return we.warn("".concat(this._className,"._checkCachedGroupAttributes. ").concat(a)),new Ba({code:na.CANNOT_USE_GRP_ATTR_AVCHATROOM_UNJOIN,message:a})}return!0}},{key:"_transformGroupAttributes",value:function(e){var t=[];return Object.keys(e).forEach((function(o){t.push({key:o,value:e[o]})})),t}},{key:"_emitGroupAttributesUpdated",value:function(e){var t=this._getLocalGroupAttributes({groupID:e});this._groupModule.emitOuterEvent(S.GROUP_ATTRIBUTES_UPDATED,{groupID:e,groupAttributes:t})}},{key:"reset",value:function(){this._groupAttributesMap.clear(),this.CACHE_EXPIRE_TIME=3e4}}]),e}(),vs=function(){function e(t){n(this,e);var o=t.manager,a=t.groupID,s=t.onInit,r=t.onSuccess,i=t.onFail;this._className="Polling",this._manager=o,this._groupModule=o._groupModule,this._onInit=s,this._onSuccess=r,this._onFail=i,this._groupID=a,this._timeoutID=-1,this._isRunning=!1,this._protocolName=En}return s(e,[{key:"start",value:function(){var e=this._groupModule.isLoggedIn();e||(this._protocolName=Tn),we.log("".concat(this._className,".start pollingInterval:").concat(this._manager.getPollingInterval()," isLoggedIn:").concat(e)),this._isRunning=!0,this._request()}},{key:"isRunning",value:function(){return this._isRunning}},{key:"_request",value:function(){var e=this,t=this._onInit(this._groupID);this._groupModule.request({protocolName:this._protocolName,requestData:t}).then((function(t){e._onSuccess(e._groupID,t),e.isRunning()&&(clearTimeout(e._timeoutID),e._timeoutID=setTimeout(e._request.bind(e),e._manager.getPollingInterval()))})).catch((function(t){e._onFail(e._groupID,t),e.isRunning()&&(clearTimeout(e._timeoutID),e._timeoutID=setTimeout(e._request.bind(e),e._manager.MAX_POLLING_INTERVAL))}))}},{key:"stop",value:function(){we.log("".concat(this._className,".stop")),this._timeoutID>0&&(clearTimeout(this._timeoutID),this._timeoutID=-1),this._isRunning=!1}}]),e}(),ys={3:!0,4:!0,5:!0,6:!0},Is=function(){function e(t){n(this,e),this._groupModule=t,this._className="AVChatRoomHandler",this._joinedGroupMap=new Map,this._pollingRequestInfoMap=new Map,this._pollingInstanceMap=new Map,this.sequencesLinkedList=new cs(200),this.messageIDLinkedList=new cs(100),this.receivedMessageCount=0,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}return s(e,[{key:"hasJoinedAVChatRoom",value:function(){return this._joinedGroupMap.size>0}},{key:"checkJoinedAVChatRoomByID",value:function(e){return this._joinedGroupMap.has(e)}},{key:"getJoinedAVChatRoom",value:function(){return this._joinedGroupMap.size>0?M(this._joinedGroupMap.keys()):null}},{key:"_updateRequestData",value:function(e){return t({},this._pollingRequestInfoMap.get(e))}},{key:"_handleSuccess",value:function(e,t){var o=t.data,n=o.key,a=o.nextSeq,s=o.rspMsgList;if(0!==o.errorCode){var r=this._pollingRequestInfoMap.get(e),i=new va(ya.LONG_POLLING_AV_ERROR),c=r?"".concat(r.key,"-").concat(r.startSeq):"requestInfo is undefined";i.setMessage("".concat(e,"-").concat(c,"-").concat(t.errorInfo)).setCode(t.errorCode).setNetworkType(this._groupModule.getNetworkType()).end(!0)}else{if(!this.checkJoinedAVChatRoomByID(e))return;ze(n)&&$e(a)&&this._pollingRequestInfoMap.set(e,{key:n,startSeq:a}),Qe(s)&&s.length>0?(s.forEach((function(e){e.to=e.groupID})),this.onMessage(s)):(this._pollingNoMessageCount+=1,this._pollingNoMessageCount===this.DEFAULT_POLLING_NO_MESSAGE_COUNT&&(this._pollingInterval=this.DEFAULT_POLLING_INTERVAL+this.DEFAULT_POLLING_INTERVAL_PLUS))}}},{key:"_handleFailure",value:function(e,t){}},{key:"onMessage",value:function(e){if(Qe(e)&&0!==e.length){0!==this._pollingNoMessageCount&&(this._pollingNoMessageCount=0,this._pollingInterval=this.DEFAULT_POLLING_INTERVAL);var t=null,o=[],n=this._getModule(co),a=this._getModule(Co),s=e.length;s>1&&e.sort((function(e,t){return e.sequence-t.sequence}));for(var r=this._getModule(uo),i=0;i1&&p<=20?this._getModule(yo).onMessageMaybeLost(l,d+1,p-1):p<-1&&p>=-20&&this._getModule(yo).onMessageMaybeLost(l,t.sequence+1,Math.abs(p)-1)}this.sequencesLinkedList.set(t.sequence),this.messageIDLinkedList.set(t.ID);var g=!1;if(this._isMessageSentByCurrentInstance(t)?c&&(g=!0,t.isModified=c,n.updateMessageIsModifiedProperty(t)):g=!0,g){if(t.conversationType===D.CONV_SYSTEM&&5===t.payload.operationType&&this._onGroupDismissed(t.payload.groupProfile.groupID),!u&&t.conversationType!==D.CONV_SYSTEM){var _=t.conversationID.replace(D.CONV_GROUP,"");this._pollingInstanceMap.has(_)?a.addMessageSequence({key:_a,message:t}):(t.type!==D.MSG_GRP_TIP&&t.clientTime>0&&a.addMessageDelay(t.clientTime),a.addMessageSequence({key:ga,message:t}))}o.push(t)}}}else we.warn("".concat(this._className,".onMessage 未处理的 event 类型: ").concat(e[i].event));if(0!==o.length){this._groupModule.filterModifiedMessage(o);var h=this.packConversationOption(o);if(h.length>0)this._getModule(co).onNewMessage({conversationOptionsList:h,isInstantMessage:!0});we.debug("".concat(this._className,".onMessage count:").concat(o.length)),this._checkMessageStacked(o);var f=this._groupModule.filterUnmodifiedMessage(o);f.length>0&&this._groupModule.emitOuterEvent(S.MESSAGE_RECEIVED,f),o.length=0}}}},{key:"_onGroupDismissed",value:function(e){we.log("".concat(this._className,"._onGroupDismissed groupID:").concat(e)),this._groupModule.deleteLocalGroupAndConversation(e),this.reset(e)}},{key:"_checkMessageStacked",value:function(e){var t=e.length;t>=100&&(we.warn("".concat(this._className,"._checkMessageStacked 直播群消息堆积数:").concat(e.length,'!可能会导致微信小程序渲染时遇到 "Dom limit exceeded" 的错误,建议接入侧此时只渲染最近的10条消息')),this._reportMessageStackedCount<5&&(new va(ya.MESSAGE_STACKED).setNetworkType(this._groupModule.getNetworkType()).setMessage("count:".concat(t," groupID:").concat(M(this._joinedGroupMap.keys()))).setLevel("warning").end(),this._reportMessageStackedCount+=1))}},{key:"_isMessageSentByCurrentInstance",value:function(e){return!!this._getModule(co).isMessageSentByCurrentInstance(e)}},{key:"packMessage",value:function(e,t){e.currentUser=this._groupModule.getMyUserID(),e.conversationType=5===t?D.CONV_SYSTEM:D.CONV_GROUP,e.isSystemMessage=!!e.isSystemMessage;var o=new wa(e),n=this.packElements(e,t);return o.setElement(n),o}},{key:"packElements",value:function(e,o){return 4===o||6===o?(this._updateMemberCountByGroupTips(e),this._onGroupAttributesUpdated(e),{type:D.MSG_GRP_TIP,content:t(t({},e.elements),{},{groupProfile:e.groupProfile})}):5===o?{type:D.MSG_GRP_SYS_NOTICE,content:t(t({},e.elements),{},{groupProfile:t(t({},e.groupProfile),{},{groupID:e.groupID})})}:this._getModule(_o).parseElements(e.elements,e.from)}},{key:"packConversationOption",value:function(e){for(var t=new Map,o=0;o1e3*t.expireTime&&o-t.latestUpdateTime>1e4&&o-t.lastReqTime>3e3?(t.lastReqTime=o,this._onlineMemberCountMap.set(e,t),this._getGroupOnlineMemberCount(e).then((function(e){return ba({memberCount:e.memberCount})})).catch((function(e){return ja(e)}))):Ya({memberCount:t.memberCount})}},{key:"_getGroupOnlineMemberCount",value:function(e){var t=this,o="".concat(this._className,"._getGroupOnlineMemberCount");return this._groupModule.request({protocolName:Cn,requestData:{groupID:e}}).then((function(n){var a=t._onlineMemberCountMap.get(e)||{},s=n.data,r=s.onlineMemberNum,i=void 0===r?0:r,c=s.expireTime,u=void 0===c?t.DEFAULT_EXPIRE_TIME:c;we.log("".concat(o," ok. groupID:").concat(e," memberCount:").concat(i," expireTime:").concat(u));var l=Date.now();return Vt(a)&&(a.lastReqTime=l),t._onlineMemberCountMap.set(e,Object.assign(a,{lastSyncTime:l,latestUpdateTime:l,memberCount:i,expireTime:u})),{memberCount:i}})).catch((function(n){return we.warn("".concat(o," failed. error:"),n),new va(ya.GET_GROUP_ONLINE_MEMBER_COUNT).setCode(n.code).setMessage("groupID:".concat(e," error:").concat(JSON.stringify(n))).setNetworkType(t._groupModule.getNetworkType()).end(),Promise.reject(n)}))}},{key:"_onGroupAttributesUpdated",value:function(e){var t=e.groupID,o=e.elements,n=o.operationType,a=o.newGroupProfile;if(6===n){var s=(void 0===a?void 0:a).groupAttributeOption;Vt(s)||this._groupModule.onGroupAttributesUpdated({groupID:t,groupAttributeOption:s})}}},{key:"_getModule",value:function(e){return this._groupModule.getModule(e)}},{key:"setPollingInterval",value:function(e){Ze(e)||($e(e)?this._pollingInterval=this.DEFAULT_POLLING_INTERVAL=e:this._pollingInterval=this.DEFAULT_POLLING_INTERVAL=parseInt(e,10))}},{key:"setPollingIntervalPlus",value:function(e){Ze(e)||($e(e)?this.DEFAULT_POLLING_INTERVAL_PLUS=e:this.DEFAULT_POLLING_INTERVAL_PLUS=parseInt(e,10))}},{key:"setPollingNoMessageCount",value:function(e){Ze(e)||($e(e)?this.DEFAULT_POLLING_NO_MESSAGE_COUNT=e:this.DEFAULT_POLLING_NO_MESSAGE_COUNT=parseInt(e,10))}},{key:"getPollingInterval",value:function(){return this._pollingInterval}},{key:"reset",value:function(e){if(e){we.log("".concat(this._className,".reset groupID:").concat(e));var 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{we.log("".concat(this._className,".reset all"));var o,n=C(this._pollingInstanceMap.values());try{for(n.s();!(o=n.n()).done;){o.value.stop()}}catch(a){n.e(a)}finally{n.f()}this._pollingInstanceMap.clear(),this._joinedGroupMap.clear(),this._pollingRequestInfoMap.clear(),this._onlineMemberCountMap.clear()}this.sequencesLinkedList.reset(),this.messageIDLinkedList.reset(),this.receivedMessageCount=0,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}}]),e}(),Es=1,Ts=15,Cs=function(){function e(t){n(this,e),this._groupModule=t,this._className="GroupSystemNoticeHandler",this.pendencyMap=new Map}return s(e,[{key:"onNewGroupSystemNotice",value:function(e){var t=e.dataList,o=e.isSyncingEnded,n=e.isInstantMessage;we.debug("".concat(this._className,".onReceiveSystemNotice count:").concat(t.length));var a=this.newSystemNoticeStoredAndSummary({notifiesList:t,isInstantMessage:n}),s=a.eventDataList,r=a.result;s.length>0&&(this._groupModule.getModule(co).onNewMessage({conversationOptionsList:s,isInstantMessage:n}),this._onReceivedGroupSystemNotice({result:r,isInstantMessage:n}));n?r.length>0&&this._groupModule.emitOuterEvent(S.MESSAGE_RECEIVED,r):!0===o&&this._clearGroupSystemNotice()}},{key:"newSystemNoticeStoredAndSummary",value:function(e){var o=e.notifiesList,n=e.isInstantMessage,a=null,s=o.length,r=0,i=[],c={conversationID:D.CONV_SYSTEM,unreadCount:0,type:D.CONV_SYSTEM,subType:null,lastMessage:null};for(r=0;r0?[c]:[],result:i}}},{key:"_clearGroupSystemNotice",value:function(){var e=this;this.getPendencyList().then((function(t){t.forEach((function(t){e.pendencyMap.set("".concat(t.from,"_").concat(t.groupID,"_").concat(t.to),t)}));var o=e._groupModule.getModule(co).getLocalMessageList(D.CONV_SYSTEM),n=[];o.forEach((function(t){var o=t.payload,a=o.operatorID,s=o.operationType,r=o.groupProfile;if(s===Es){var i="".concat(a,"_").concat(r.groupID,"_").concat(r.to),c=e.pendencyMap.get(i);c&&$e(c.handled)&&0!==c.handled&&n.push(t)}})),e.deleteGroupSystemNotice({messageList:n})}))}},{key:"deleteGroupSystemNotice",value:function(e){var t=this,o="".concat(this._className,".deleteGroupSystemNotice");return Qe(e.messageList)&&0!==e.messageList.length?(we.log("".concat(o," ")+e.messageList.map((function(e){return e.ID}))),this._groupModule.request({protocolName:In,requestData:{messageListToDelete:e.messageList.map((function(e){return{from:D.CONV_SYSTEM,messageSeq:e.clientSequence,messageRandom:e.random}}))}}).then((function(){we.log("".concat(o," ok"));var n=t._groupModule.getModule(co);return e.messageList.forEach((function(e){n.deleteLocalMessage(e)})),ba()})).catch((function(e){return we.error("".concat(o," error:"),e),ja(e)}))):Ya()}},{key:"getPendencyList",value:function(e){var t=this;return this._groupModule.request({protocolName:yn,requestData:{startTime:e&&e.startTime?e.startTime:0,limit:e&&e.limit?e.limit:10,handleAccount:this._groupModule.getMyUserID()}}).then((function(e){var o=e.data.pendencyList;return 0!==e.data.nextStartTime?t.getPendencyList({startTime:e.data.nextStartTime}).then((function(e){return[].concat(M(o),M(e))})):o}))}},{key:"_onReceivedGroupSystemNotice",value:function(e){var t=this,o=e.result;e.isInstantMessage&&o.forEach((function(e){switch(e.payload.operationType){case 1:break;case 2:t._onApplyGroupRequestAgreed(e);break;case 3:break;case 4:t._onMemberKicked(e);break;case 5:t._onGroupDismissed(e);break;case 6:break;case 7:t._onInviteGroup(e);break;case 8:t._onQuitGroup(e);break;case 9:t._onSetManager(e);break;case 10:t._onDeleteManager(e)}}))}},{key:"_onApplyGroupRequestAgreed",value:function(e){var t=this,o=e.payload.groupProfile.groupID;this._groupModule.hasLocalGroup(o)||this._groupModule.getGroupProfile({groupID:o}).then((function(e){var o=e.data.group;if(o){t._groupModule.updateGroupMap([o]);var n=!o.isSupportTopic;t._groupModule.emitGroupListUpdate(!0,n)}}))}},{key:"_onMemberKicked",value:function(e){var t=e.payload.groupProfile.groupID;this._groupModule.hasLocalGroup(t)&&this._groupModule.deleteLocalGroupAndConversation(t)}},{key:"_onGroupDismissed",value:function(e){var t=e.payload.groupProfile.groupID;this._groupModule.hasLocalGroup(t)&&this._groupModule.deleteLocalGroupAndConversation(t);var o=this._groupModule._AVChatRoomHandler;o&&o.checkJoinedAVChatRoomByID(t)&&o.reset(t)}},{key:"_onInviteGroup",value:function(e){var t=this,o=e.payload.groupProfile.groupID;this._groupModule.hasLocalGroup(o)||this._groupModule.getGroupProfile({groupID:o}).then((function(e){var o=e.data.group;o&&(t._groupModule.updateGroupMap([o]),t._groupModule.emitGroupListUpdate())}))}},{key:"_onQuitGroup",value:function(e){var t=e.payload.groupProfile.groupID;this._groupModule.hasLocalGroup(t)&&this._groupModule.deleteLocalGroupAndConversation(t)}},{key:"_onSetManager",value:function(e){var t=e.payload.groupProfile,o=t.to,n=t.groupID,a=this._groupModule.getModule(ro).getLocalGroupMemberInfo(n,o);a&&a.updateRole(D.GRP_MBR_ROLE_ADMIN)}},{key:"_onDeleteManager",value:function(e){var t=e.payload.groupProfile,o=t.to,n=t.groupID,a=this._groupModule.getModule(ro).getLocalGroupMemberInfo(n,o);a&&a.updateRole(D.GRP_MBR_ROLE_MEMBER)}},{key:"_handleTopicSystemNotice",value:function(e){var t=e.groupProfile,o=t.groupID,n=t.topicID,a=e.elements,s=a.operationType,r=a.topicIDList,i=this._groupModule.getModule(io);17===s?i.onTopicCreated({groupID:o,topicID:n}):18===s&&i.onTopicDeleted({groupID:o,topicIDList:r})}},{key:"reset",value:function(){this.pendencyMap.clear()}}]),e}(),Ss=["relayFlag"],Ds=function(e){i(a,e);var o=f(a);function a(e){var t;return n(this,a),(t=o.call(this,e))._className="GroupModule",t._commonGroupHandler=null,t._AVChatRoomHandler=null,t._groupSystemNoticeHandler=null,t._commonGroupHandler=new fs(_(t)),t._groupAttributesHandler=new Ms(_(t)),t._AVChatRoomHandler=new Is(_(t)),t._groupTipsHandler=new hs(_(t)),t._groupSystemNoticeHandler=new Cs(_(t)),t.groupMap=new Map,t._unjoinedAVChatRoomList=new Map,t._receiptDetailCompleteMap=new Map,t.getInnerEmitterInstance().on(Xa,t._onCloudConfigUpdated,_(t)),t}return s(a,[{key:"_onCloudConfigUpdated",value:function(){var e=this.getCloudConfig("polling_interval"),t=this.getCloudConfig("polling_interval_plus"),o=this.getCloudConfig("polling_no_msg_count");this._AVChatRoomHandler&&(we.log("".concat(this._className,"._onCloudConfigUpdated pollingInterval:").concat(e)+" pollingIntervalPlus:".concat(t," pollingNoMessageCount:").concat(o)),this._AVChatRoomHandler.setPollingInterval(e),this._AVChatRoomHandler.setPollingIntervalPlus(t),this._AVChatRoomHandler.setPollingNoMessageCount(o))}},{key:"onCheckTimer",value:function(e){this.isLoggedIn()&&(this._commonGroupHandler.onCheckTimer(e),this._groupTipsHandler.onCheckTimer(e))}},{key:"guardForAVChatRoom",value:function(e){var t=this;if(e.conversationType===D.CONV_GROUP){var o=Tt(e.to)?bt(e.to):e.to;return this.hasLocalGroup(o)?Ya():this.getGroupProfile({groupID:o}).then((function(n){var a=n.data.group.type;if(we.log("".concat(t._className,".guardForAVChatRoom. groupID:").concat(o," type:").concat(a)),a===D.GRP_AVCHATROOM){var s="userId:".concat(e.from," 未加入群 groupID:").concat(o,"。发消息前先使用 joinGroup 接口申请加群,详细请参考 https://web.sdk.qcloud.com/im/doc/zh-cn/SDK.html#joinGroup");return we.warn("".concat(t._className,".guardForAVChatRoom sendMessage not allowed. ").concat(s)),ja(new Ba({code:na.MESSAGE_SEND_FAIL,message:s,data:{message:e}}))}return Ya()}))}return Ya()}},{key:"checkJoinedAVChatRoomByID",value:function(e){return!!this._AVChatRoomHandler&&this._AVChatRoomHandler.checkJoinedAVChatRoomByID(e)}},{key:"onNewGroupMessage",value:function(e){this._commonGroupHandler&&this._commonGroupHandler.onNewGroupMessage(e)}},{key:"updateNextMessageSeq",value:function(e){var t=this;if(Qe(e)){var o=this.getModule(io);e.forEach((function(e){var n=e.conversationID.replace(D.CONV_GROUP,"");if(Tt(n)){var a=e.lastMessage.sequence+1,s=bt(n),r=o.getLocalTopic(s,n);r&&(r.updateNextMessageSeq(a),r.updateLastMessage(e.lastMessage))}t.groupMap.has(n)&&(t.groupMap.get(n).nextMessageSeq=e.lastMessage.sequence+1)}))}}},{key:"onNewGroupTips",value:function(e){this._groupTipsHandler&&this._groupTipsHandler.onNewGroupTips(e)}},{key:"onGroupMessageRevoked",value:function(e){this._commonGroupHandler&&this._commonGroupHandler.onGroupMessageRevoked(e)}},{key:"onNewGroupSystemNotice",value:function(e){this._groupSystemNoticeHandler&&this._groupSystemNoticeHandler.onNewGroupSystemNotice(e)}},{key:"onGroupMessageReadNotice",value:function(e){var t=this;e.dataList.forEach((function(e){var o=e.elements.groupMessageReadNotice;if(!Ze(o)){var n=t.getModule(co);o.forEach((function(e){var o=e.groupID,a=e.topicID,s=void 0===a?void 0:a,r=e.lastMessageSeq;we.debug("".concat(t._className,".onGroupMessageReadNotice groupID:").concat(o," lastMessageSeq:").concat(r));var i="".concat(D.CONV_GROUP).concat(o),c=!0;Vt(s)||(i="".concat(D.CONV_GROUP).concat(s),c=!1),n.updateIsReadAfterReadReport({conversationID:i,lastMessageSeq:r}),n.updateUnreadCount(i,c)}))}}))}},{key:"onReadReceiptList",value:function(e){var t=this;we.debug("".concat(this._className,".onReadReceiptList options:"),JSON.stringify(e)),e.dataList.forEach((function(e){var o=e.groupProfile,n=e.elements,a=o.groupID,s=t.getModule(co),r=n.readReceiptList;s.updateReadReceiptInfo({groupID:a,readReceiptList:r})}))}},{key:"onGroupMessageModified",value:function(e){we.debug("".concat(this._className,".onGroupMessageModified options:"),JSON.stringify(e));var o=this.getModule(co);e.dataList.forEach((function(e){o.onMessageModified(t(t({},e),{},{conversationType:D.CONV_GROUP,to:e.topicID?e.topicID:e.groupID}))}))}},{key:"deleteGroupSystemNotice",value:function(e){this._groupSystemNoticeHandler&&this._groupSystemNoticeHandler.deleteGroupSystemNotice(e)}},{key:"initGroupMap",value:function(e){this.groupMap.set(e.groupID,new ls(e))}},{key:"deleteGroup",value:function(e){this.groupMap.delete(e)}},{key:"updateGroupMap",value:function(e){var t=this;e.forEach((function(e){t.groupMap.has(e.groupID)?t.groupMap.get(e.groupID).updateGroup(e):t.groupMap.set(e.groupID,new ls(e))}));var o,n=this.getMyUserID(),a=C(this.groupMap);try{for(a.s();!(o=a.n()).done;){m(o.value,2)[1].selfInfo.userID=n}}catch(s){a.e(s)}finally{a.f()}this._setStorageGroupList()}},{key:"getStorageGroupList",value:function(){return this.getModule(lo).getItem("groupMap")}},{key:"_setStorageGroupList",value:function(){var e=this.getLocalGroupList().filter((function(e){var t=e.type;return!It(t)})).filter((function(e){return!e.isSupportTopic})).slice(0,20).map((function(e){return{groupID:e.groupID,name:e.name,avatar:e.avatar,type:e.type}}));this.getModule(lo).setItem("groupMap",e)}},{key:"getGroupMap",value:function(){return this.groupMap}},{key:"getLocalGroupList",value:function(){return M(this.groupMap.values())}},{key:"getLocalGroupProfile",value:function(e){return this.groupMap.get(e)}},{key:"sortLocalGroupList",value:function(){var e=M(this.groupMap).filter((function(e){var t=m(e,2);t[0];return!Vt(t[1].lastMessage)}));e.sort((function(e,t){return t[1].lastMessage.lastTime-e[1].lastMessage.lastTime})),this.groupMap=new Map(M(e))}},{key:"updateGroupLastMessage",value:function(e){this._commonGroupHandler&&this._commonGroupHandler.handleUpdateGroupLastMessage(e)}},{key:"emitGroupListUpdate",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],o=this.getLocalGroupList();if(e&&this.emitOuterEvent(S.GROUP_LIST_UPDATED),t){var n=JSON.parse(JSON.stringify(o)),a=this.getModule(co);a.updateConversationGroupProfile(n)}}},{key:"patchGroupMessageRemindType",value:function(){var e=this.getLocalGroupList(),t=this.getModule(co),o=0;e.forEach((function(e){!0===t.patchMessageRemindType({ID:e.groupID,isC2CConversation:!1,messageRemindType:e.selfInfo.messageRemindType})&&(o+=1)})),we.log("".concat(this._className,".patchGroupMessageRemindType count:").concat(o))}},{key:"recomputeUnreadCount",value:function(){var e=this.getLocalGroupList(),t=this.getModule(co);e.forEach((function(e){var o=e.groupID,n=e.selfInfo,a=n.excludedUnreadSequenceList,s=n.readedSequence;if(Qe(a)){var r=0;a.forEach((function(t){t>=s&&t<=e.nextMessageSeq-1&&(r+=1)})),r>=1&&t.recomputeGroupUnreadCount({conversationID:"".concat(D.CONV_GROUP).concat(o),count:r})}}))}},{key:"getMyNameCardByGroupID",value:function(e){var t=this.getLocalGroupProfile(e);return t?t.selfInfo.nameCard:""}},{key:"getGroupList",value:function(e){return this._commonGroupHandler?this._commonGroupHandler.getGroupList(e):Ya()}},{key:"getGroupProfile",value:function(e){var t=this,o=new va(ya.GET_GROUP_PROFILE),n="".concat(this._className,".getGroupProfile"),a=e.groupID,s=e.groupCustomFieldFilter;we.log("".concat(n," groupID:").concat(a));var r={groupIDList:[a],responseFilter:{groupBaseInfoFilter:["Type","Name","Introduction","Notification","FaceUrl","Owner_Account","CreateTime","InfoSeq","LastInfoTime","LastMsgTime","MemberNum","MaxMemberNum","ApplyJoinOption","NextMsgSeq","ShutUpAllMember"],groupCustomFieldFilter:s,memberInfoFilter:["Role","JoinTime","MsgSeq","MsgFlag","NameCard"]}};return this.getGroupProfileAdvance(r).then((function(e){var s,r=e.data,i=r.successGroupList,c=r.failureGroupList;if(we.log("".concat(n," ok")),c.length>0)return ja(c[0]);(It(i[0].type)&&!t.hasLocalGroup(a)?s=new ls(i[0]):(t.updateGroupMap(i),s=t.getLocalGroupProfile(a)),s.isSupportTopic)||t.getModule(co).updateConversationGroupProfile([s]);return o.setNetworkType(t.getNetworkType()).setMessage("groupID:".concat(a," type:").concat(s.type," muteAllMembers:").concat(s.muteAllMembers," ownerID:").concat(s.ownerID)).end(),ba({group:s})})).catch((function(a){return t.probeNetwork().then((function(t){var n=m(t,2),s=n[0],r=n[1];o.setError(a,s,r).setMessage("groupID:".concat(e.groupID)).end()})),we.error("".concat(n," failed. error:"),a),ja(a)}))}},{key:"getGroupProfileAdvance",value:function(e){var o=this,n="".concat(this._className,".getGroupProfileAdvance"),a=e.groupIDList;Qe(a)&&a.length>50&&(we.warn("".concat(n," 获取群资料的数量不能超过50个")),a.length=50);var s=[],r=[];a.forEach((function(e){Et({groupID:e})?r.push(e):s.push(e)}));var i=[];if(s.length>0){var c=this._getGroupProfileAdvance(t(t({},e),{},{groupIDList:s}));i.push(c)}if(r.length>0){var u=this._getGroupProfileAdvance(t(t({},e),{},{groupIDList:r,relayFlag:s.length>0}));i.push(u)}return Promise.all(i).then((function(e){var t=[],o=[];return e.forEach((function(e){t.push.apply(t,M(e.successGroupList)),o.push.apply(o,M(e.failureGroupList))})),ba({successGroupList:t,failureGroupList:o})})).catch((function(e){return we.error("".concat(o._className,"._getGroupProfileAdvance failed. error:"),e),ja(e)}))}},{key:"_getGroupProfileAdvance",value:function(e){var t=this,o=e.relayFlag,n=void 0!==o&&o,a=g(e,Ss);return this.request({protocolName:en,requestData:a}).then((function(e){we.log("".concat(t._className,"._getGroupProfileAdvance ok."));var o=e.data.groups;return{successGroupList:o.filter((function(e){return Ze(e.errorCode)||0===e.errorCode})),failureGroupList:o.filter((function(e){return e.errorCode&&0!==e.errorCode})).map((function(e){return new Ba({code:e.errorCode,message:e.errorInfo,data:{groupID:e.groupID}})}))}})).catch((function(t){return n&&Et({groupID:e.groupIDList[0]})?{successGroupList:[],failureGroupList:[]}:ja(t)}))}},{key:"createGroup",value:function(e){var o=this,n="".concat(this._className,".createGroup"),a=e.type,s=e.groupID;if(!["Public","Private","ChatRoom","AVChatRoom","Community"].includes(a))return ja({code:na.ILLEGAL_GROUP_TYPE,message:aa.ILLEGAL_GROUP_TYPE});if(!Et({type:a})){if(!Vt(s)&&Et({groupID:s}))return ja({code:na.ILLEGAL_GROUP_ID,message:aa.ILLEGAL_GROUP_ID});e.isSupportTopic=void 0}if(It(a)&&!Ze(e.memberList)&&e.memberList.length>0&&(we.warn("".concat(n," 创建 AVChatRoom 时不能添加群成员,自动忽略该字段")),e.memberList=void 0),yt(a)||Ze(e.joinOption)||(we.warn("".concat(n," 创建 Work/Meeting/AVChatRoom/Community 群时不能设置字段 joinOption,自动忽略该字段")),e.joinOption=void 0),Et({type:a})){if(!Vt(s)&&!Et({groupID:s}))return ja({code:na.ILLEGAL_GROUP_ID,message:aa.ILLEGAL_GROUP_ID});e.isSupportTopic=!0===e.isSupportTopic?1:0}var r=new va(ya.CREATE_GROUP);we.log("".concat(n," options:"),e);var i=[];return this.request({protocolName:tn,requestData:t(t({},e),{},{ownerID:this.getMyUserID(),webPushFlag:1})}).then((function(a){var s=a.data,c=s.groupID,u=s.overLimitUserIDList,l=void 0===u?[]:u;if(i=l,r.setNetworkType(o.getNetworkType()).setMessage("groupType:".concat(e.type," groupID:").concat(c," overLimitUserIDList=").concat(l)).end(),we.log("".concat(n," ok groupID:").concat(c," overLimitUserIDList:"),l),e.type===D.GRP_AVCHATROOM)return o.getGroupProfile({groupID:c});if(e.type===D.GRP_COMMUNITY&&1===e.isSupportTopic)return o.getGroupProfile({groupID:c});Vt(e.memberList)||Vt(l)||(e.memberList=e.memberList.filter((function(e){return-1===l.indexOf(e.userID)}))),o.updateGroupMap([t(t({},e),{},{groupID:c})]);var d=o.getModule(to),p=d.createCustomMessage({to:c,conversationType:D.CONV_GROUP,payload:{data:"group_create",extension:"".concat(o.getMyUserID(),"创建群组")}});return d.sendMessageInstance(p),o.emitGroupListUpdate(),o.getGroupProfile({groupID:c})})).then((function(e){var t=e.data.group,o=t.selfInfo,n=o.nameCard,a=o.joinTime;return t.updateSelfInfo({nameCard:n,joinTime:a,messageRemindType:D.MSG_REMIND_ACPT_AND_NOTE,role:D.GRP_MBR_ROLE_OWNER}),ba({group:t,overLimitUserIDList:i})})).catch((function(t){return r.setMessage("groupType:".concat(e.type)),o.probeNetwork().then((function(e){var o=m(e,2),n=o[0],a=o[1];r.setError(t,n,a).end()})),we.error("".concat(n," failed. error:"),t),ja(t)}))}},{key:"dismissGroup",value:function(e){var t=this,o="".concat(this._className,".dismissGroup");if(this.hasLocalGroup(e)&&this.getLocalGroupProfile(e).type===D.GRP_WORK)return ja(new Ba({code:na.CANNOT_DISMISS_WORK,message:aa.CANNOT_DISMISS_WORK}));var n=new va(ya.DISMISS_GROUP);return n.setMessage("groupID:".concat(e)),we.log("".concat(o," groupID:").concat(e)),this.request({protocolName:on,requestData:{groupID:e}}).then((function(){return n.setNetworkType(t.getNetworkType()).end(),we.log("".concat(o," ok")),t.deleteLocalGroupAndConversation(e),t.checkJoinedAVChatRoomByID(e)&&t._AVChatRoomHandler.reset(e),ba({groupID:e})})).catch((function(e){return t.probeNetwork().then((function(t){var o=m(t,2),a=o[0],s=o[1];n.setError(e,a,s).end()})),we.error("".concat(o," failed. error:"),e),ja(e)}))}},{key:"updateGroupProfile",value:function(e){var t=this,o="".concat(this._className,".updateGroupProfile");!this.hasLocalGroup(e.groupID)||yt(this.getLocalGroupProfile(e.groupID).type)||Ze(e.joinOption)||(we.warn("".concat(o," Work/Meeting/AVChatRoom/Community 群不能设置字段 joinOption,自动忽略该字段")),e.joinOption=void 0),Ze(e.muteAllMembers)||(e.muteAllMembers?e.muteAllMembers="On":e.muteAllMembers="Off");var n=new va(ya.UPDATE_GROUP_PROFILE);return n.setMessage(JSON.stringify(e)),we.log("".concat(o," groupID:").concat(e.groupID)),this.request({protocolName:nn,requestData:e}).then((function(){(n.setNetworkType(t.getNetworkType()).end(),we.log("".concat(o," ok")),t.hasLocalGroup(e.groupID))&&(t.groupMap.get(e.groupID).updateGroup(e),t._setStorageGroupList());return ba({group:t.groupMap.get(e.groupID)})})).catch((function(e){return t.probeNetwork().then((function(t){var o=m(t,2),a=o[0],s=o[1];n.setError(e,a,s).end()})),we.log("".concat(o," failed. error:"),e),ja(e)}))}},{key:"joinGroup",value:function(e){var t=this,o=e.groupID,n=e.type,a="".concat(this._className,".joinGroup");if(n===D.GRP_WORK){var s=new Ba({code:na.CANNOT_JOIN_WORK,message:aa.CANNOT_JOIN_WORK});return ja(s)}if(this.deleteUnjoinedAVChatRoom(o),this.hasLocalGroup(o)){if(!this.isLoggedIn())return Ya({status:D.JOIN_STATUS_ALREADY_IN_GROUP});var r=new va(ya.APPLY_JOIN_GROUP);return this.getGroupProfile({groupID:o}).then((function(){return r.setNetworkType(t.getNetworkType()).setMessage("groupID:".concat(o," joinedStatus:").concat(D.JOIN_STATUS_ALREADY_IN_GROUP)).end(),Ya({status:D.JOIN_STATUS_ALREADY_IN_GROUP})})).catch((function(n){return r.setNetworkType(t.getNetworkType()).setMessage("groupID:".concat(o," unjoined")).end(),we.warn("".concat(a," ").concat(o," was unjoined, now join!")),t.groupMap.delete(o),t.applyJoinGroup(e)}))}return we.log("".concat(a," groupID:").concat(o)),this.isLoggedIn()?this.applyJoinGroup(e):this._AVChatRoomHandler.joinWithoutAuth(e)}},{key:"applyJoinGroup",value:function(e){var o=this,n="".concat(this._className,".applyJoinGroup"),a=e.groupID,s=new va(ya.APPLY_JOIN_GROUP),r=t({},e),i=this.canIUse(B.AVCHATROOM_HISTORY_MSG);return i&&(r.historyMessageFlag=1),this.getModule(co).removeConversationMessageCache("".concat(D.CONV_GROUP).concat(a)),this.request({protocolName:an,requestData:r}).then((function(e){var t=e.data,r=t.joinedStatus,c=t.longPollingKey,u=t.avChatRoomFlag,l=t.avChatRoomKey,d=t.messageList,p="groupID:".concat(a," joinedStatus:").concat(r," longPollingKey:").concat(c)+" avChatRoomFlag:".concat(u," canGetAVChatRoomHistoryMessage:").concat(i,",")+" history message count:".concat(Vt(d)?0:d.length);switch(s.setNetworkType(o.getNetworkType()).setMessage("".concat(p)).end(),we.log("".concat(n," ok. ").concat(p)),r){case Be:return ba({status:Be});case He:return o.getGroupProfile({groupID:a}).then((function(e){var t,n=e.data.group,s={status:He,group:n};return 1===u?(o.getModule(co).setCompleted("".concat(D.CONV_GROUP).concat(a)),o._groupAttributesHandler.initGroupAttributesCache({groupID:a,avChatRoomKey:l}),(t=Ze(c)?o._AVChatRoomHandler.handleJoinResult({group:n}):o._AVChatRoomHandler.startRunLoop({longPollingKey:c,group:n})).then((function(){o._onAVChatRoomHistoryMessage(d)})),t):(o.emitGroupListUpdate(!0,!1),ba(s))}));default:var g=new Ba({code:na.JOIN_GROUP_FAIL,message:aa.JOIN_GROUP_FAIL});return we.error("".concat(n," error:"),g),ja(g)}})).catch((function(t){return s.setMessage("groupID:".concat(e.groupID)),o.probeNetwork().then((function(e){var o=m(e,2),n=o[0],a=o[1];s.setError(t,n,a).end()})),we.error("".concat(n," error:"),t),ja(t)}))}},{key:"quitGroup",value:function(e){var t=this,o="".concat(this._className,".quitGroup");we.log("".concat(o," groupID:").concat(e));var n=this.checkJoinedAVChatRoomByID(e);if(!n&&!this.hasLocalGroup(e)){var a=new Ba({code:na.MEMBER_NOT_IN_GROUP,message:aa.MEMBER_NOT_IN_GROUP});return ja(a)}if(n&&!this.isLoggedIn())return we.log("".concat(o," anonymously ok. groupID:").concat(e)),this.deleteLocalGroupAndConversation(e),this._AVChatRoomHandler.reset(e),Ya({groupID:e});var s=new va(ya.QUIT_GROUP);return s.setMessage("groupID:".concat(e)),this.request({protocolName:rn,requestData:{groupID:e}}).then((function(){return s.setNetworkType(t.getNetworkType()).end(),we.log("".concat(o," ok")),t.deleteLocalGroupAndConversation(e),n&&t._AVChatRoomHandler.reset(e),ba({groupID:e})})).catch((function(e){return t.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];s.setError(e,n,a).end()})),we.error("".concat(o," failed. error:"),e),ja(e)}))}},{key:"searchGroupByID",value:function(e){var t=this,o="".concat(this._className,".searchGroupByID"),n={groupIDList:[e]},a=new va(ya.SEARCH_GROUP_BY_ID);return a.setMessage("groupID:".concat(e)),we.log("".concat(o," groupID:").concat(e)),this.request({protocolName:cn,requestData:n}).then((function(e){var n=e.data.groupProfile;if(0!==n[0].errorCode)throw new Ba({code:n[0].errorCode,message:n[0].errorInfo});return a.setNetworkType(t.getNetworkType()).end(),we.log("".concat(o," ok")),ba({group:new ls(n[0])})})).catch((function(e){return t.probeNetwork().then((function(t){var o=m(t,2),n=o[0],s=o[1];a.setError(e,n,s).end()})),we.warn("".concat(o," failed. error:"),e),ja(e)}))}},{key:"changeGroupOwner",value:function(e){var t=this,o="".concat(this._className,".changeGroupOwner");if(this.hasLocalGroup(e.groupID)&&this.getLocalGroupProfile(e.groupID).type===D.GRP_AVCHATROOM)return ja(new Ba({code:na.CANNOT_CHANGE_OWNER_IN_AVCHATROOM,message:aa.CANNOT_CHANGE_OWNER_IN_AVCHATROOM}));if(e.newOwnerID===this.getMyUserID())return ja(new Ba({code:na.CANNOT_CHANGE_OWNER_TO_SELF,message:aa.CANNOT_CHANGE_OWNER_TO_SELF}));var n=new va(ya.CHANGE_GROUP_OWNER);return n.setMessage("groupID:".concat(e.groupID," newOwnerID:").concat(e.newOwnerID)),we.log("".concat(o," groupID:").concat(e.groupID)),this.request({protocolName:un,requestData:e}).then((function(){n.setNetworkType(t.getNetworkType()).end(),we.log("".concat(o," ok"));var a=e.groupID,s=e.newOwnerID;t.groupMap.get(a).ownerID=s;var r=t.getModule(ro).getLocalGroupMemberList(a);if(r instanceof Map){var i=r.get(t.getMyUserID());Ze(i)||(i.updateRole("Member"),t.groupMap.get(a).selfInfo.role="Member");var c=r.get(s);Ze(c)||c.updateRole("Owner")}return t.emitGroupListUpdate(!0,!1),ba({group:t.groupMap.get(a)})})).catch((function(e){return t.probeNetwork().then((function(t){var o=m(t,2),a=o[0],s=o[1];n.setError(e,a,s).end()})),we.error("".concat(o," failed. error:"),e),ja(e)}))}},{key:"handleGroupApplication",value:function(e){var o=this,n="".concat(this._className,".handleGroupApplication"),a=e.message.payload,s=a.groupProfile.groupID,r=a.authentication,i=a.messageKey,c=a.operatorID,u=new va(ya.HANDLE_GROUP_APPLICATION);return u.setMessage("groupID:".concat(s)),we.log("".concat(n," groupID:").concat(s)),this.request({protocolName:ln,requestData:t(t({},e),{},{applicant:c,groupID:s,authentication:r,messageKey:i})}).then((function(){return u.setNetworkType(o.getNetworkType()).end(),we.log("".concat(n," ok")),o._groupSystemNoticeHandler.deleteGroupSystemNotice({messageList:[e.message]}),ba({group:o.getLocalGroupProfile(s)})})).catch((function(e){return o.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];u.setError(e,n,a).end()})),we.error("".concat(n," failed. error"),e),ja(e)}))}},{key:"handleGroupInvitation",value:function(e){var o=this,n="".concat(this._className,".handleGroupInvitation"),a=e.message.payload,s=a.groupProfile.groupID,r=a.authentication,i=a.messageKey,c=a.operatorID,u=e.handleAction,l=new va(ya.HANDLE_GROUP_INVITATION);return l.setMessage("groupID:".concat(s," inviter:").concat(c," handleAction:").concat(u)),we.log("".concat(n," groupID:").concat(s," inviter:").concat(c," handleAction:").concat(u)),this.request({protocolName:dn,requestData:t(t({},e),{},{inviter:c,groupID:s,authentication:r,messageKey:i})}).then((function(){return l.setNetworkType(o.getNetworkType()).end(),we.log("".concat(n," ok")),o._groupSystemNoticeHandler.deleteGroupSystemNotice({messageList:[e.message]}),ba({group:o.getLocalGroupProfile(s)})})).catch((function(e){return o.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];l.setError(e,n,a).end()})),we.error("".concat(n," failed. error"),e),ja(e)}))}},{key:"getGroupOnlineMemberCount",value:function(e){return this._AVChatRoomHandler?this._AVChatRoomHandler.checkJoinedAVChatRoomByID(e)?this._AVChatRoomHandler.getGroupOnlineMemberCount(e):Ya({memberCount:0}):ja({code:na.CANNOT_FIND_MODULE,message:aa.CANNOT_FIND_MODULE})}},{key:"hasLocalGroup",value:function(e){return this.groupMap.has(e)}},{key:"deleteLocalGroupAndConversation",value:function(e){var t=this.checkJoinedAVChatRoomByID(e);(we.log("".concat(this._className,".deleteLocalGroupAndConversation isJoinedAVChatRoom:").concat(t)),t)&&this.getModule(co).deleteLocalConversation("GROUP".concat(e));this._deleteLocalGroup(e),this.emitGroupListUpdate(!0,!1)}},{key:"_deleteLocalGroup",value:function(e){this.groupMap.delete(e),this.getModule(ro).deleteGroupMemberList(e),this._setStorageGroupList()}},{key:"sendMessage",value:function(e,t){var o=this.createGroupMessagePack(e,t);return this.request(o)}},{key:"createGroupMessagePack",value:function(e,t){var o=null;t&&t.offlinePushInfo&&(o=t.offlinePushInfo);var n="";ze(e.cloudCustomData)&&e.cloudCustomData.length>0&&(n=e.cloudCustomData);var a=[];if(Xe(t)&&Xe(t.messageControlInfo)){var s=t.messageControlInfo,r=s.excludedFromUnreadCount,i=s.excludedFromLastMessage;!0===r&&a.push("NoUnread"),!0===i&&a.push("NoLastMsg")}var c=e.getGroupAtInfoList(),u={fromAccount:this.getMyUserID(),groupID:e.to,msgBody:e.getElements(),cloudCustomData:n,random:e.random,priority:e.priority,clientSequence:e.clientSequence,groupAtInfo:e.type!==D.MSG_TEXT||Vt(c)?void 0:c,onlineOnlyFlag:this.isOnlineMessage(e,t)?1:0,clientTime:e.clientTime,offlinePushInfo:o?{pushFlag:!0===o.disablePush?1:0,title:o.title||"",desc:o.description||"",ext:o.extension||"",apnsInfo:{badgeMode:!0===o.ignoreIOSBadge?1:0},androidInfo:{OPPOChannelID:o.androidOPPOChannelID||""}}:void 0,messageControlInfo:a,needReadReceipt:!0!==e.needReadReceipt||this.isMessageFromOrToAVChatroom(e.to)?0:1};return Tt(e.to)&&(u.groupID=bt(e.to),u.topicID=e.to),{protocolName:Po,tjgID:this.generateTjgID(e),requestData:u}}},{key:"revokeMessage",value:function(e){var t={groupID:e.to,msgSeqList:[{msgSeq:e.sequence}]};return Tt(e.to)&&(t.groupID=bt(e.to),t.topicID=e.to),this.request({protocolName:pn,requestData:t})}},{key:"deleteMessage",value:function(e){var t=e.to,o=e.keyList;we.log("".concat(this._className,".deleteMessage groupID:").concat(t," count:").concat(o.length));var n={groupID:t,deleter:this.getMyUserID(),keyList:o};return Tt(t)&&(n.groupID=bt(t),n.topicID=t),this.request({protocolName:Sn,requestData:n})}},{key:"modifyRemoteMessage",value:function(e){var t=e.to,o=e.sequence,n=e.payload,a=e.type,s=e.version,r=void 0===s?0:s,i=e.cloudCustomData,c=t,u=void 0;return Tt(t)&&(c=bt(t),u=t),this.request({protocolName:Dn,requestData:{groupID:c,topicID:u,sequence:o,version:r,elements:[{type:a,content:n}],cloudCustomData:i}})}},{key:"getRoamingMessage",value:function(e){var t=this,o="".concat(this._className,".getRoamingMessage"),n=e.conversationID,a=e.groupID,s=e.sequence,r=new va(ya.GET_GROUP_ROAMING_MESSAGES),i=0,c=void 0;return Tt(a)&&(a=bt(c=a)),this._computeLastSequence({groupID:a,topicID:c,sequence:s}).then((function(e){return i=e,we.log("".concat(o," groupID:").concat(a," startSequence:").concat(i)),t.request({protocolName:hn,requestData:{groupID:a,count:21,sequence:i,topicID:c}})})).then((function(e){var s=e.data,u=s.messageList,l=s.complete;Ze(u)?we.log("".concat(o," ok. complete:").concat(l," but messageList is undefined!")):we.log("".concat(o," ok. complete:").concat(l," count:").concat(u.length)),r.setNetworkType(t.getNetworkType()).setMessage("groupID:".concat(a," topicID:").concat(c," startSequence:").concat(i," complete:").concat(l," count:").concat(u?u.length:"undefined")).end();var d=t.getModule(co);if(2===l||Vt(u))return d.setCompleted(n),{nextReqID:"",storedMessageList:[]};var p=u[u.length-1].sequence-1;d.updateRoamingMessageSequence(n,p);var g=d.onRoamingMessage(u,n);return d.updateIsRead(n),d.patchConversationLastMessage(n),we.log("".concat(o," nextReqID:").concat(p," stored message count:").concat(g.length)),{nextReqID:p+"",storedMessageList:g}})).catch((function(e){return t.probeNetwork().then((function(t){var o=m(t,2),n=o[0],s=o[1];r.setError(e,n,s).setMessage("groupID:".concat(a," topicID:").concat(c," startSequence:").concat(i)).end()})),we.warn("".concat(o," failed. error:"),e),ja(e)}))}},{key:"_getGroupIDOfMessage",value:function(e){return e.conversationID.replace(D.CONV_GROUP,"")}},{key:"getReadReceiptList",value:function(e){var t=this,o="".concat(this._className,".getReadReceiptList"),n=this._getGroupIDOfMessage(e[0]),a=this.getMyUserID(),s=e.filter((function(e){return e.from===a&&!0===e.needReadReceipt})).map((function(e){return{sequence:e.sequence}}));if(we.log("".concat(o," groupID:").concat(n," sequenceList:").concat(JSON.stringify(s))),0===s.length)return Ya({messageList:e});var r=new va(ya.GET_READ_RECEIPT);return r.setMessage("groupID:".concat(n)),this.request({protocolName:fn,requestData:{groupID:n,sequenceList:s}}).then((function(t){r.end(),we.log("".concat(o," ok"));var n=t.data.readReceiptList;return Qe(n)&&n.forEach((function(t){e.forEach((function(e){0===t.code&&t.sequence===e.sequence&&(e.readReceiptInfo.readCount=t.readCount,e.readReceiptInfo.unreadCount=t.unreadCount)}))})),ba({messageList:e})})).catch((function(e){return t.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];r.setError(e,n,a).end()})),we.warn("".concat(o," failed. error:"),e),ja(e)}))}},{key:"sendReadReceipt",value:function(e){var t=this,o=this._getGroupIDOfMessage(e[0]),n=new va(ya.SEND_READ_RECEIPT);n.setMessage("groupID:".concat(o));var a=this.getMyUserID(),s=e.filter((function(e){return e.from!==a&&!0===e.needReadReceipt})).map((function(e){return{sequence:e.sequence}}));if(0===s.length)return ja({code:na.READ_RECEIPT_MESSAGE_LIST_EMPTY,message:aa.READ_RECEIPT_MESSAGE_LIST_EMPTY});var r="".concat(this._className,".sendReadReceipt");return we.log("".concat(r,". sequenceList:").concat(JSON.stringify(s))),this.request({protocolName:mn,requestData:{groupID:o,sequenceList:s}}).then((function(e){return n.end(),we.log("".concat(r," ok")),ba()})).catch((function(e){return t.probeNetwork().then((function(t){var o=m(t,2),a=o[0],s=o[1];n.setError(e,a,s).end()})),we.warn("".concat(r," failed. error:"),e),ja(e)}))}},{key:"getReadReceiptDetail",value:function(e){var t=this,o=e.message,n=e.filter,a=e.cursor,s=e.count,r=this._getGroupIDOfMessage(o),i=o.ID,c=o.sequence,u="".concat(this._className,".getReadReceiptDetail"),l=this._receiptDetailCompleteMap.get(i)||!1,d=0!==n&&1!==n?0:n,p=ze(a)?a:"",g=!$e(s)||s<=0||s>=100?100:s,_="groupID:".concat(r," sequence:").concat(c," cursor:").concat(p," filter:").concat(d," completeFlag:").concat(l);we.log("".concat(u," ").concat(_));var h={cursor:"",isCompleted:!1,messageID:i,unreadUserIDList:[],readUserIDList:[]},f=new va(ya.GET_READ_RECEIPT_DETAIL);return f.setMessage(_),this.request({protocolName:vn,requestData:{groupID:r,sequence:c,flag:d,cursor:p,count:g}}).then((function(e){f.end();var o=e.data,n=o.cursor,a=o.isCompleted,s=o.unreadUserIDList,r=o.readUserIDList;return h.cursor=n,1===a&&(h.isCompleted=!0,t._receiptDetailCompleteMap.set(i,!0)),0===d?h.readUserIDList=r.map((function(e){return e.userID})):1===d&&(h.unreadUserIDList=s.map((function(e){return e.userID}))),we.log("".concat(u," ok")),ba(h)})).catch((function(e){return t.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];f.setError(e,n,a).end()})),we.warn("".concat(u," failed. error:"),e),ja(e)}))}},{key:"getRoamingMessagesHopping",value:function(e){var t=this,o="".concat(this._className,".getRoamingMessagesHopping"),n=new va(ya.GET_GROUP_ROAMING_MESSAGES_HOPPING),a=e.groupID,s=e.count,r=e.sequence,i=void 0;return Tt(a)&&(a=bt(i=a)),this.request({protocolName:hn,requestData:{groupID:a,count:s,sequence:r,topicID:i}}).then((function(s){var c=s.data,u=c.messageList,l=c.complete,d="groupID:".concat(a," topicID:").concat(i," sequence:").concat(r," complete:").concat(l," count:").concat(u?u.length:0);if(we.log("".concat(o," ok. ").concat(d)),n.setNetworkType(t.getNetworkType()).setMessage("".concat(d)).end(),2===l||Vt(u))return[];var p="".concat(D.CONV_GROUP).concat(e.groupID);return t.getModule(co).onRoamingMessage(u,p,!1)})).catch((function(e){return t.probeNetwork().then((function(t){var o=m(t,2),i=o[0],c=o[1];n.setError(e,i,c).setMessage("groupID:".concat(a," sequence:").concat(r," count:").concat(s)).end()})),we.warn("".concat(o," failed. error:"),e),ja(e)}))}},{key:"setMessageRead",value:function(e){var t=this,o=e.conversationID,n=e.lastMessageSeq,a="".concat(this._className,".setMessageRead");we.log("".concat(a," conversationID:").concat(o," lastMessageSeq:").concat(n)),$e(n)||we.warn("".concat(a," 请勿修改 Conversation.lastMessage.lastSequence,否则可能会导致已读上报结果不准确"));var s=new va(ya.SET_GROUP_MESSAGE_READ);s.setMessage("".concat(o,"-").concat(n));var r=o.replace(D.CONV_GROUP,""),i=void 0;return Tt(r)&&(r=bt(i=r)),this.request({protocolName:gn,requestData:{groupID:r,topicID:i,messageReadSeq:n}}).then((function(){s.setNetworkType(t.getNetworkType()).end(),we.log("".concat(a," ok."));var e=t.getModule(co);e.updateIsReadAfterReadReport({conversationID:o,lastMessageSeq:n});var c=!0;if(!Ze(i)){c=!1;var u=t.getModule(io).getLocalTopic(r,i);u&&u.updateSelfInfo({readedSequence:n})}return e.updateUnreadCount(o,c),ba()})).catch((function(e){return t.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];s.setError(e,n,a).end()})),we.log("".concat(a," failed. error:"),e),ja(e)}))}},{key:"_computeLastSequence",value:function(e){var t=e.groupID,o=e.topicID,n=void 0===o?void 0:o,a=e.sequence;return a>0?Promise.resolve(a):Ze(n)||this.hasLocalGroup(t)?Ze(n)?this.getGroupLastSequence(t):this.getTopicLastSequence({groupID:t,topicID:n}):Promise.resolve(0)}},{key:"getGroupLastSequence",value:function(e){var t=this,o="".concat(this._className,".getGroupLastSequence"),n=new va(ya.GET_GROUP_LAST_SEQUENCE),a=0,s="";if(this.hasLocalGroup(e)){var r=this.getLocalGroupProfile(e),i=r.lastMessage;if(i.lastSequence>0&&!1===i.onlineOnlyFlag)return a=i.lastSequence,s="got lastSequence:".concat(a," from local group profile[lastMessage.lastSequence]. groupID:").concat(e),we.log("".concat(o," ").concat(s)),n.setNetworkType(this.getNetworkType()).setMessage("".concat(s)).end(),Promise.resolve(a);if(r.nextMessageSeq>1)return a=r.nextMessageSeq-1,s="got lastSequence:".concat(a," from local group profile[nextMessageSeq]. groupID:").concat(e),we.log("".concat(o," ").concat(s)),n.setNetworkType(this.getNetworkType()).setMessage("".concat(s)).end(),Promise.resolve(a)}var c="GROUP".concat(e),u=this.getModule(co).getLocalConversation(c);if(u&&u.lastMessage.lastSequence&&!1===u.lastMessage.onlineOnlyFlag)return a=u.lastMessage.lastSequence,s="got lastSequence:".concat(a," from local conversation profile[lastMessage.lastSequence]. groupID:").concat(e),we.log("".concat(o," ").concat(s)),n.setNetworkType(this.getNetworkType()).setMessage("".concat(s)).end(),Promise.resolve(a);var l={groupIDList:[e],responseFilter:{groupBaseInfoFilter:["NextMsgSeq"]}};return this.getGroupProfileAdvance(l).then((function(r){var i=r.data.successGroupList;return Vt(i)?we.log("".concat(o," successGroupList is empty. groupID:").concat(e)):(a=i[0].nextMessageSeq-1,s="got lastSequence:".concat(a," from getGroupProfileAdvance. groupID:").concat(e),we.log("".concat(o," ").concat(s))),n.setNetworkType(t.getNetworkType()).setMessage("".concat(s)).end(),a})).catch((function(a){return t.probeNetwork().then((function(t){var o=m(t,2),s=o[0],r=o[1];n.setError(a,s,r).setMessage("get lastSequence failed from getGroupProfileAdvance. groupID:".concat(e)).end()})),we.warn("".concat(o," failed. error:"),a),ja(a)}))}},{key:"getTopicLastSequence",value:function(e){var t=this,o=e.groupID,n=e.topicID,a="".concat(this._className,".getTopicLastSequence"),s=new va(ya.GET_TOPIC_LAST_SEQUENCE),r=0,i="",c=this.getModule(io);return c.hasLocalTopic(o,n)?(r=c.getLocalTopic(o,n).nextMessageSeq-1,i="get lastSequence:".concat(r," from local topic info[nextMessageSeq]. topicID:").concat(n),we.log("".concat(a," ").concat(i)),s.setNetworkType(this.getNetworkType()).setMessage("".concat(i)).end(),Promise.resolve(r)):c.getTopicList({groupID:o,topicIDList:[n]}).then((function(e){var o=e.data.successTopicList;return Vt(o)?we.log("".concat(a," successTopicList is empty. topicID:").concat(n)):(r=o[0].nextMessageSeq-1,i="get lastSequence:".concat(r," from getTopicList. topicID:").concat(n),we.log("".concat(a," ").concat(i))),s.setNetworkType(t.getNetworkType()).setMessage("".concat(i)).end(),r})).catch((function(e){return t.probeNetwork().then((function(t){var o=m(t,2),a=o[0],r=o[1];s.setError(e,a,r).setMessage("get lastSequence failed from getTopicList. topicID:".concat(n)).end()})),we.warn("".concat(a," failed. error:"),e),ja(e)}))}},{key:"isMessageFromOrToAVChatroom",value:function(e){return!!this._AVChatRoomHandler&&this._AVChatRoomHandler.checkJoinedAVChatRoomByID(e)}},{key:"hasJoinedAVChatRoom",value:function(){return this._AVChatRoomHandler?this._AVChatRoomHandler.hasJoinedAVChatRoom():0}},{key:"getJoinedAVChatRoom",value:function(){return this._AVChatRoomHandler?this._AVChatRoomHandler.getJoinedAVChatRoom():[]}},{key:"isOnlineMessage",value:function(e,t){return!(!this._canIUseOnlineOnlyFlag(e)||!t||!0!==t.onlineUserOnly)}},{key:"_canIUseOnlineOnlyFlag",value:function(e){var t=this.getJoinedAVChatRoom();return!t||!t.includes(e.to)||e.conversationType!==D.CONV_GROUP}},{key:"_onAVChatRoomHistoryMessage",value:function(e){if(!Vt(e)){we.log("".concat(this._className,"._onAVChatRoomHistoryMessage count:").concat(e.length));var o=[];e.forEach((function(e){o.push(t(t({},e),{},{isHistoryMessage:1}))})),this.onAVChatRoomMessage(o)}}},{key:"onAVChatRoomMessage",value:function(e){this._AVChatRoomHandler&&this._AVChatRoomHandler.onMessage(e)}},{key:"getGroupSimplifiedInfo",value:function(e){var t=this,o=new va(ya.GET_GROUP_SIMPLIFIED_INFO),n={groupIDList:[e],responseFilter:{groupBaseInfoFilter:["Type","Name"]}};return this.getGroupProfileAdvance(n).then((function(n){var a=n.data.successGroupList;return o.setNetworkType(t.getNetworkType()).setMessage("groupID:".concat(e," type:").concat(a[0].type)).end(),a[0]})).catch((function(n){t.probeNetwork().then((function(t){var a=m(t,2),s=a[0],r=a[1];o.setError(n,s,r).setMessage("groupID:".concat(e)).end()}))}))}},{key:"setUnjoinedAVChatRoom",value:function(e){this._unjoinedAVChatRoomList.set(e,1)}},{key:"deleteUnjoinedAVChatRoom",value:function(e){this._unjoinedAVChatRoomList.has(e)&&this._unjoinedAVChatRoomList.delete(e)}},{key:"isUnjoinedAVChatRoom",value:function(e){return this._unjoinedAVChatRoomList.has(e)}},{key:"onGroupAttributesUpdated",value:function(e){this._groupAttributesHandler&&this._groupAttributesHandler.onGroupAttributesUpdated(e)}},{key:"updateLocalMainSequenceOnReconnected",value:function(){this._groupAttributesHandler&&this._groupAttributesHandler.updateLocalMainSequenceOnReconnected()}},{key:"initGroupAttributes",value:function(e){return this._groupAttributesHandler.initGroupAttributes(e)}},{key:"setGroupAttributes",value:function(e){return this._groupAttributesHandler.setGroupAttributes(e)}},{key:"deleteGroupAttributes",value:function(e){return this._groupAttributesHandler.deleteGroupAttributes(e)}},{key:"getGroupAttributes",value:function(e){return this._groupAttributesHandler.getGroupAttributes(e)}},{key:"reset",value:function(){this.groupMap.clear(),this._unjoinedAVChatRoomList.clear(),this._receiptDetailCompleteMap.clear(),this._commonGroupHandler.reset(),this._groupSystemNoticeHandler.reset(),this._groupTipsHandler.reset(),this._AVChatRoomHandler&&this._AVChatRoomHandler.reset()}}]),a}(Do),Ns=function(){function e(t){n(this,e),this.userID="",this.avatar="",this.nick="",this.role="",this.joinTime="",this.lastSendMsgTime="",this.nameCard="",this.muteUntil=0,this.memberCustomField=[],this._initMember(t)}return s(e,[{key:"_initMember",value:function(e){this.updateMember(e)}},{key:"updateMember",value:function(e){var t=[null,void 0,"",0,NaN];e.memberCustomField&&vt(this.memberCustomField,e.memberCustomField),ct(this,e,["memberCustomField"],t)}},{key:"updateRole",value:function(e){["Owner","Admin","Member"].indexOf(e)<0||(this.role=e)}},{key:"updateMuteUntil",value:function(e){Ze(e)||(this.muteUntil=Math.floor((Date.now()+1e3*e)/1e3))}},{key:"updateNameCard",value:function(e){Ze(e)||(this.nameCard=e)}},{key:"updateMemberCustomField",value:function(e){e&&vt(this.memberCustomField,e)}}]),e}(),As=function(e){i(a,e);var o=f(a);function a(e){var t;return n(this,a),(t=o.call(this,e))._className="GroupMemberModule",t.groupMemberListMap=new Map,t.getInnerEmitterInstance().on(Qa,t._onProfileUpdated,_(t)),t}return s(a,[{key:"_onProfileUpdated",value:function(e){for(var t=this,o=e.data,n=function(e){var n=o[e];t.groupMemberListMap.forEach((function(e){e.has(n.userID)&&e.get(n.userID).updateMember({nick:n.nick,avatar:n.avatar})}))},a=0;a100?100:r};Et({groupID:o})?d.next="".concat(a):(d.offset=a,l=a+1);var p=[];return this.request({protocolName:kn,requestData:d}).then((function(e){var n=e.data,a=n.members,s=n.memberNum,r=n.next,i=void 0===r?void 0:r;if(Ze(i)||(l=Vt(i)?0:i),!Qe(a)||0===a.length)return l=0,Promise.resolve([]);var c=t.getModule(ao);return c.hasLocalGroup(o)&&(c.getLocalGroupProfile(o).memberNum=s),p=t._updateLocalGroupMemberMap(o,a),t.getModule(oo).getUserProfile({userIDList:a.map((function(e){return e.userID})),tagList:[Fe.NICK,Fe.AVATAR]})})).then((function(e){var n=e.data;if(!Qe(n)||0===n.length)return Ya({memberList:[],offset:l});var a=n.map((function(e){return{userID:e.userID,nick:e.nick,avatar:e.avatar}}));return t._updateLocalGroupMemberMap(o,a),u.setNetworkType(t.getNetworkType()).setMessage("groupID:".concat(o," offset:").concat(l," count:").concat(r)).end(),we.log("".concat(i," ok.")),ba({memberList:p,offset:l})})).catch((function(e){return t.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];u.setError(e,n,a).end()})),we.error("".concat(i," failed. error:"),e),ja(e)}))}},{key:"getGroupMemberProfile",value:function(e){var o=this,n="".concat(this._className,".getGroupMemberProfile"),a=new va(ya.GET_GROUP_MEMBER_PROFILE);a.setMessage(e.userIDList.length>5?"userIDList.length:".concat(e.userIDList.length):"userIDList:".concat(e.userIDList)),we.log("".concat(n," groupID:").concat(e.groupID," userIDList:").concat(e.userIDList.join(","))),e.userIDList.length>50&&(e.userIDList=e.userIDList.slice(0,50));var s=e.groupID,r=e.userIDList;return this._getGroupMemberProfileAdvance(t(t({},e),{},{userIDList:r})).then((function(e){var t=e.data.members;return Qe(t)&&0!==t.length?(o._updateLocalGroupMemberMap(s,t),o.getModule(oo).getUserProfile({userIDList:t.map((function(e){return e.userID})),tagList:[Fe.NICK,Fe.AVATAR]})):Ya([])})).then((function(e){var t=e.data.map((function(e){return{userID:e.userID,nick:e.nick,avatar:e.avatar}}));o._updateLocalGroupMemberMap(s,t);var n=r.filter((function(e){return o.hasLocalGroupMember(s,e)})).map((function(e){return o.getLocalGroupMemberInfo(s,e)}));return a.setNetworkType(o.getNetworkType()).end(),ba({memberList:n})}))}},{key:"addGroupMember",value:function(e){var t=this,o="".concat(this._className,".addGroupMember"),n=e.groupID,a=this.getModule(ao).getLocalGroupProfile(n),s=a.type,r=new va(ya.ADD_GROUP_MEMBER);if(r.setMessage("groupID:".concat(n," groupType:").concat(s)),It(s)){var i=new Ba({code:na.CANNOT_ADD_MEMBER_IN_AVCHATROOM,message:aa.CANNOT_ADD_MEMBER_IN_AVCHATROOM});return r.setCode(na.CANNOT_ADD_MEMBER_IN_AVCHATROOM).setError(aa.CANNOT_ADD_MEMBER_IN_AVCHATROOM).setNetworkType(this.getNetworkType()).end(),ja(i)}return e.userIDList=e.userIDList.map((function(e){return{userID:e}})),we.log("".concat(o," groupID:").concat(n)),this.request({protocolName:Pn,requestData:e}).then((function(n){var s=n.data.members;we.log("".concat(o," ok"));var i=s.filter((function(e){return 1===e.result})).map((function(e){return e.userID})),c=s.filter((function(e){return 0===e.result})).map((function(e){return e.userID})),u=s.filter((function(e){return 2===e.result})).map((function(e){return e.userID})),l=s.filter((function(e){return 4===e.result})).map((function(e){return e.userID})),d="groupID:".concat(e.groupID,", ")+"successUserIDList:".concat(i,", ")+"failureUserIDList:".concat(c,", ")+"existedUserIDList:".concat(u,", ")+"overLimitUserIDList:".concat(l);return r.setNetworkType(t.getNetworkType()).setMoreMessage(d).end(),0===i.length?ba({successUserIDList:i,failureUserIDList:c,existedUserIDList:u,overLimitUserIDList:l}):(a.memberCount+=i.length,t._updateConversationGroupProfile(a),ba({successUserIDList:i,failureUserIDList:c,existedUserIDList:u,overLimitUserIDList:l,group:a}))})).catch((function(e){return t.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];r.setError(e,n,a).end()})),we.error("".concat(o," failed. error:"),e),ja(e)}))}},{key:"deleteGroupMember",value:function(e){var t=this,o="".concat(this._className,".deleteGroupMember"),n=e.groupID,a=e.userIDList,s=new va(ya.DELETE_GROUP_MEMBER),r="groupID:".concat(n," ").concat(a.length>5?"userIDList.length:".concat(a.length):"userIDList:".concat(a));s.setMessage(r),we.log("".concat(o," groupID:").concat(n," userIDList:"),a);var i=this.getModule(ao).getLocalGroupProfile(n);return It(i.type)?ja(new Ba({code:na.CANNOT_KICK_MEMBER_IN_AVCHATROOM,message:aa.CANNOT_KICK_MEMBER_IN_AVCHATROOM})):this.request({protocolName:Un,requestData:e}).then((function(){return s.setNetworkType(t.getNetworkType()).end(),we.log("".concat(o," ok")),i.memberCount-=1,t._updateConversationGroupProfile(i),t.deleteLocalGroupMembers(n,a),ba({group:i,userIDList:a})})).catch((function(e){return t.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];s.setError(e,n,a).end()})),we.error("".concat(o," failed. error:"),e),ja(e)}))}},{key:"_updateConversationGroupProfile",value:function(e){this.getModule(co).updateConversationGroupProfile([e])}},{key:"setGroupMemberMuteTime",value:function(e){var t=this,o=e.groupID,n=e.userID,a=e.muteTime,s="".concat(this._className,".setGroupMemberMuteTime");if(n===this.getMyUserID())return ja(new Ba({code:na.CANNOT_MUTE_SELF,message:aa.CANNOT_MUTE_SELF}));we.log("".concat(s," groupID:").concat(o," userID:").concat(n));var r=new va(ya.SET_GROUP_MEMBER_MUTE_TIME);return r.setMessage("groupID:".concat(o," userID:").concat(n," muteTime:").concat(a)),this.modifyGroupMemberInfo({groupID:o,userID:n,muteTime:a}).then((function(e){r.setNetworkType(t.getNetworkType()).end(),we.log("".concat(s," ok"));var n=t.getModule(ao);return ba({group:n.getLocalGroupProfile(o),member:e})})).catch((function(e){return t.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];r.setError(e,n,a).end()})),we.error("".concat(s," failed. error:"),e),ja(e)}))}},{key:"setGroupMemberRole",value:function(e){var t=this,o="".concat(this._className,".setGroupMemberRole"),n=e.groupID,a=e.userID,s=e.role,r=this.getModule(ao).getLocalGroupProfile(n);if(r.selfInfo.role!==D.GRP_MBR_ROLE_OWNER)return ja({code:na.NOT_OWNER,message:aa.NOT_OWNER});if([D.GRP_WORK,D.GRP_AVCHATROOM].includes(r.type))return ja({code:na.CANNOT_SET_MEMBER_ROLE_IN_WORK_AND_AVCHATROOM,message:aa.CANNOT_SET_MEMBER_ROLE_IN_WORK_AND_AVCHATROOM});var i=[D.GRP_MBR_ROLE_ADMIN,D.GRP_MBR_ROLE_MEMBER];if(Et({groupID:n})&&i.push(D.GRP_MBR_ROLE_CUSTOM),i.indexOf(s)<0)return ja({code:na.INVALID_MEMBER_ROLE,message:aa.INVALID_MEMBER_ROLE});if(a===this.getMyUserID())return ja({code:na.CANNOT_SET_SELF_MEMBER_ROLE,message:aa.CANNOT_SET_SELF_MEMBER_ROLE});var c=new va(ya.SET_GROUP_MEMBER_ROLE);return c.setMessage("groupID:".concat(n," userID:").concat(a," role:").concat(s)),we.log("".concat(o," groupID:").concat(n," userID:").concat(a)),this.modifyGroupMemberInfo({groupID:n,userID:a,role:s}).then((function(e){return c.setNetworkType(t.getNetworkType()).end(),we.log("".concat(o," ok")),ba({group:r,member:e})})).catch((function(e){return t.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];c.setError(e,n,a).end()})),we.error("".concat(o," failed. error:"),e),ja(e)}))}},{key:"setGroupMemberNameCard",value:function(e){var t=this,o="".concat(this._className,".setGroupMemberNameCard"),n=e.groupID,a=e.userID,s=void 0===a?this.getMyUserID():a,r=e.nameCard;we.log("".concat(o," groupID:").concat(n," userID:").concat(s));var i=new va(ya.SET_GROUP_MEMBER_NAME_CARD);return i.setMessage("groupID:".concat(n," userID:").concat(s," nameCard:").concat(r)),this.modifyGroupMemberInfo({groupID:n,userID:s,nameCard:r}).then((function(e){we.log("".concat(o," ok")),i.setNetworkType(t.getNetworkType()).end();var a=t.getModule(ao).getLocalGroupProfile(n);return s===t.getMyUserID()&&a&&a.setSelfNameCard(r),ba({group:a,member:e})})).catch((function(e){return t.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];i.setError(e,n,a).end()})),we.error("".concat(o," failed. error:"),e),ja(e)}))}},{key:"setGroupMemberCustomField",value:function(e){var t=this,o="".concat(this._className,".setGroupMemberCustomField"),n=e.groupID,a=e.userID,s=void 0===a?this.getMyUserID():a,r=e.memberCustomField;we.log("".concat(o," groupID:").concat(n," userID:").concat(s));var i=new va(ya.SET_GROUP_MEMBER_CUSTOM_FIELD);return i.setMessage("groupID:".concat(n," userID:").concat(s," memberCustomField:").concat(JSON.stringify(r))),this.modifyGroupMemberInfo({groupID:n,userID:s,memberCustomField:r}).then((function(e){i.setNetworkType(t.getNetworkType()).end(),we.log("".concat(o," ok"));var a=t.getModule(ao).getLocalGroupProfile(n);return ba({group:a,member:e})})).catch((function(e){return t.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];i.setError(e,n,a).end()})),we.error("".concat(o," failed. error:"),e),ja(e)}))}},{key:"modifyGroupMemberInfo",value:function(e){var o=this,n=e.groupID,a=e.userID,s=void 0;return Tt(n)&&(n=bt(s=n)),this.request({protocolName:wn,requestData:t(t({},e),{},{groupID:n,topicID:s})}).then((function(){if(o.hasLocalGroupMember(n,a)){var t=o.getLocalGroupMemberInfo(n,a);return Ze(e.muteTime)||t.updateMuteUntil(e.muteTime),Ze(e.role)||t.updateRole(e.role),Ze(e.nameCard)||t.updateNameCard(e.nameCard),Ze(e.memberCustomField)||t.updateMemberCustomField(e.memberCustomField),t}return o.getGroupMemberProfile({groupID:n,userIDList:[a]}).then((function(e){return m(e.data.memberList,1)[0]}))}))}},{key:"_getGroupMemberProfileAdvance",value:function(e){return this.request({protocolName:Gn,requestData:t(t({},e),{},{memberInfoFilter:e.memberInfoFilter?e.memberInfoFilter:["Role","JoinTime","NameCard","ShutUpUntil"]})})}},{key:"_updateLocalGroupMemberMap",value:function(e,t){var o=this;return Qe(t)&&0!==t.length?t.map((function(t){return o.hasLocalGroupMember(e,t.userID)?o.getLocalGroupMemberInfo(e,t.userID).updateMember(t):o.setLocalGroupMember(e,new Ns(t)),o.getLocalGroupMemberInfo(e,t.userID)})):[]}},{key:"deleteLocalGroupMembers",value:function(e,t){var o=this.groupMemberListMap.get(e);o&&t.forEach((function(e){o.delete(e)}))}},{key:"getLocalGroupMemberInfo",value:function(e,t){return this.groupMemberListMap.has(e)?this.groupMemberListMap.get(e).get(t):null}},{key:"setLocalGroupMember",value:function(e,t){if(this.groupMemberListMap.has(e))this.groupMemberListMap.get(e).set(t.userID,t);else{var o=(new Map).set(t.userID,t);this.groupMemberListMap.set(e,o)}}},{key:"getLocalGroupMemberList",value:function(e){return this.groupMemberListMap.get(e)}},{key:"hasLocalGroupMember",value:function(e,t){return this.groupMemberListMap.has(e)&&this.groupMemberListMap.get(e).has(t)}},{key:"hasLocalGroupMemberMap",value:function(e){return this.groupMemberListMap.has(e)}},{key:"reset",value:function(){this.groupMemberListMap.clear()}}]),a}(Do),Os=["topicID","topicName","avatar","introduction","notification","unreadCount","muteAllMembers","customData","groupAtInfoList","nextMessageSeq","selfInfo"],Rs=function(e){return Ze(e)?{lastTime:0,lastSequence:0,fromAccount:"",payload:null,type:"",onlineOnlyFlag:!1}:e?{lastTime:e.time||0,lastSequence:e.sequence||0,fromAccount:e.from||"",payload:e.payload||null,type:e.type||"",onlineOnlyFlag:e._onlineOnlyFlag||!1}:void 0},Ls=function(){function e(t){n(this,e),this.topicID="",this.topicName="",this.avatar="",this.introduction="",this.notification="",this.unreadCount=0,this.muteAllMembers=!1,this.customData="",this.groupAtInfoList=[],this.nextMessageSeq=0,this.lastMessage=Rs(t.lastMessage),this.selfInfo={muteTime:0,readedSequence:0,messageRemindType:""},this._initGroupTopic(t)}return s(e,[{key:"_initGroupTopic",value:function(e){for(var t in e)Os.indexOf(t)<0||("selfInfo"===t?this.updateSelfInfo(e[t]):this[t]="muteAllMembers"===t?1===e[t]:e[t])}},{key:"updateUnreadCount",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this.unreadCount=e}},{key:"updateNextMessageSeq",value:function(e){this.nextMessageSeq=e}},{key:"updateLastMessage",value:function(e){this.lastMessage=Rs(e)}},{key:"updateGroupAtInfoList",value:function(e){this.groupAtInfoList=JSON.parse(JSON.stringify(e))}},{key:"updateTopic",value:function(e){Ze(e.selfInfo)||this.updateSelfInfo(e.selfInfo),Ze(e.muteAllMembers)||(this.muteAllMembers=1===e.muteAllMembers),ct(this,e,["groupID","lastMessageTime","selfInfo","muteAllMembers"])}},{key:"updateSelfInfo",value:function(e){ct(this.selfInfo,e,[],[""])}}]),e}(),ks=function(e){i(a,e);var o=f(a);function a(e){var t;return n(this,a),(t=o.call(this,e))._className="TopicModule",t._topicMap=new Map,t._getTopicTimeMap=new Map,t.TOPIC_CACHE_TIME=300,t.TOPIC_LAST_ACTIVE_TIME=3600,t.getInnerEmitterInstance().on(Xa,t._onCloudConfigUpdated,_(t)),t}return s(a,[{key:"_onCloudConfigUpdated",value:function(){var e=this.getCloudConfig("topic_cache_time"),t=this.getCloudConfig("topic_last_active_time");Ze(e)||(this.TOPIC_CACHE_TIME=Number(e)),Ze(t)||(this.TOPIC_LAST_ACTIVE_TIME=Number(t))}},{key:"onTopicCreated",value:function(e){var t=e.groupID;this.resetGetTopicTime(t),this.emitOuterEvent(S.TOPIC_CREATED,e)}},{key:"onTopicDeleted",value:function(e){var t=this,o=e.groupID,n=e.topicIDList;(void 0===n?[]:n).forEach((function(e){t._deleteLocalTopic(o,e)})),this.emitOuterEvent(S.TOPIC_DELETED,e)}},{key:"onTopicProfileUpdated",value:function(e){var t=e.groupID,o=e.topicID,n=this.getLocalTopic(t,o);n&&(n.updateTopic(e),this.emitOuterEvent(S.TOPIC_UPDATED,{groupID:t,topic:n}))}},{key:"onConversationProxy",value:function(e){var t=e.topicID,o=e.unreadCount,n=e.groupAtInfoList,a=bt(t),s=this.getLocalTopic(a,t),r=!1;s&&(Ze(o)||s.unreadCount===o||(s.updateUnreadCount(o),r=!0),Ze(n)||(s.updateGroupAtInfoList(n),r=!0)),r&&this.emitOuterEvent(S.TOPIC_UPDATED,{groupID:a,topic:s})}},{key:"onMessageSent",value:function(e){var t=e.groupID,o=e.topicID,n=e.lastMessage,a=this.getLocalTopic(t,o);a&&(a.nextMessageSeq+=1,a.updateLastMessage(n),this.emitOuterEvent(S.TOPIC_UPDATED,{groupID:t,topic:a}))}},{key:"onMessageModified",value:function(e){var t=e.to,o=e.time,n=e.sequence,a=e.elements,s=e.cloudCustomData,r=e.messageVersion,i=bt(t),c=this.getLocalTopic(i,t);if(c){var u=c.lastMessage;we.debug("".concat(this._className,".onMessageModified topicID:").concat(t," lastMessage:"),JSON.stringify(u),"options:",JSON.stringify(e)),u&&(null===u.payload||u.lastTime===o&&u.lastSequence===n&&u.version!==r)&&(u.type=a[0].type,u.payload=a[0].content,u.messageForShow=Ft(u.type,u.payload),u.cloudCustomData=s,u.version=r,u.lastSequence=n,u.lastTime=o,this.emitOuterEvent(S.TOPIC_UPDATED,{groupID:i,topic:c}))}}},{key:"getJoinedCommunityList",value:function(){return this.getModule(ao).getGroupList({isGroupWithTopicOnly:!0}).then((function(e){var t=e.data.groupList;return ba({groupList:void 0===t?[]:t})})).catch((function(e){return ja(e)}))}},{key:"createTopicInCommunity",value:function(e){var o=this,n="".concat(this._className,".createTopicInCommunity"),a=e.topicID;if(!Ze(a)&&!Tt(a))return ja({code:na.ILLEGAL_TOPIC_ID,message:aa.ILLEGAL_TOPIC_ID});var s=new va(ya.CREATE_TOPIC);return this.request({protocolName:Zn,requestData:t({},e)}).then((function(a){var r=a.data.topicID;return s.setMessage("topicID:".concat(r)).setNetworkType(o.getNetworkType()).end(),we.log("".concat(n," ok")),o._updateTopicMap([t(t({},e),{},{topicID:r})]),ba({topicID:r})})).catch((function(e){return o.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];s.setError(e,n,a).end()})),we.error("".concat(n," failed. error:"),e),ja(e)}))}},{key:"deleteTopicFromCommunity",value:function(e){var t=this,o="".concat(this._className,".deleteTopicFromCommunity"),n=e.groupID,a=e.topicIDList,s=void 0===a?[]:a,r=new va(ya.DELETE_TOPIC);return r.setMessage("groupID:".concat(n," topicIDList:").concat(s)),this.request({protocolName:ea,requestData:{groupID:n,topicIDList:s}}).then((function(e){var o=e.data.resultList,a=void 0===o?[]:o,s=a.filter((function(e){return 0===e.code})).map((function(e){return{topicID:e.topicID}})),i=a.filter((function(e){return 0!==e.code})),c="success count:".concat(s.length,", fail count:").concat(i.length);return r.setMoreMessage("".concat(c)).setNetworkType(t.getNetworkType()).end(),we.log("".concat(c)),s.forEach((function(e){t._deleteLocalTopic(n,e.topicID)})),ba({successTopicList:s,failureTopicList:i})})).catch((function(e){return t.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];r.setError(e,n,a).end()})),we.error("".concat(o," failed. error:"),e),ja(e)}))}},{key:"updateTopicProfile",value:function(e){var o=this,n="".concat(this._className,".updateTopicProfile"),a=new va(ya.UPDATE_TOPIC_PROFILE);return a.setMessage("groupID:".concat(e.groupID," topicID:").concat(e.topicID)),we.log("".concat(n," options:"),e),Ze(e.muteAllMembers)||(e.muteAllMembers=!0===e.muteAllMembers?"On":"Off"),this.request({protocolName:ta,requestData:t({},e)}).then((function(){return a.setNetworkType(o.getNetworkType()).end(),we.log("".concat(n," ok")),o._updateTopicMap([e]),ba({topic:o.getLocalTopic(e.groupID,e.topicID)})})).catch((function(e){return o.probeNetwork().then((function(t){var o=m(t,2),n=o[0],s=o[1];a.setError(e,n,s).end()})),we.error("".concat(n," failed. error:"),e),ja(e)}))}},{key:"getTopicList",value:function(e){var o=this,n="".concat(this._className,".getTopicList"),a=e.groupID,s=e.topicIDList,r=void 0===s?[]:s,i=new va(ya.GET_TOPIC_LIST);if(i.setMessage("groupID:".concat(a)),this._getTopicTimeMap.has(a)){var c=this._getTopicTimeMap.get(a);if(Date.now()-c<1e3*this.TOPIC_CACHE_TIME){var u=this._getLocalTopicList(a,r);return i.setNetworkType(this.getNetworkType()).setMoreMessage("from cache. topicList:".concat(u.length)).end(),we.log("".concat(n," groupID:").concat(a," from cache. topicList:").concat(u.length)),Ya({successTopicList:u,failureTopicList:[]})}}return this.request({protocolName:oa,requestData:{groupID:a,topicIDList:r}}).then((function(e){var s=e.data.topicInfoList,c=[],u=[],l=[];(void 0===s?[]:s).forEach((function(e){var o=e.topic,n=e.selfInfo,a=e.code,s=e.message,r=o.topicID;0===a?(c.push(t(t({},o),{},{selfInfo:n})),u.push(r)):l.push({topicID:r,code:a,message:s})})),o._updateTopicMap(c);var d="successTopicList:".concat(u.length," failureTopicList:").concat(l.length);i.setNetworkType(o.getNetworkType()).setMoreMessage("".concat(d)).end(),we.log("".concat(n," groupID:").concat(a," from remote. ").concat(d)),Vt(r)&&!Vt(u)&&o._getTopicTimeMap.set(a,Date.now());var p=[];return Vt(u)||(p=o._getLocalTopicList(a,u)),ba({successTopicList:p,failureTopicList:l})})).catch((function(e){return o.probeNetwork(e).then((function(t){var o=m(t,2),n=o[0],a=o[1];i.setError(e,n,a).end()})),we.error("".concat(n," failed. error:"),e),ja(e)}))}},{key:"hasLocalTopic",value:function(e,t){return!!this._topicMap.has(e)&&!!this._topicMap.get(e).has(t)}},{key:"getLocalTopic",value:function(e,t){var o=null;return this._topicMap.has(e)&&(o=this._topicMap.get(e).get(t)),o}},{key:"_getLocalTopicList",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],o=this._topicMap.get(e),n=[];return o&&(n=M(o.values())),0===t.length?n:n.filter((function(e){return t.includes(e.topicID)}))}},{key:"_deleteLocalTopic",value:function(e,t){this._topicMap.has(e)&&this._topicMap.get(e).delete(t)}},{key:"_updateTopicMap",value:function(e){var t=this,o=[];(e.forEach((function(e){var n=e.groupID,a=e.topicID,s=null;t._topicMap.has(n)||t._topicMap.set(n,new Map),t._topicMap.get(n).has(a)?(s=t._topicMap.get(n).get(a)).updateTopic(e):(s=new Ls(e),t._topicMap.get(n).set(a,s));var r=s.nextMessageSeq-s.selfInfo.readedSequence-1;o.push({conversationID:"".concat(D.CONV_GROUP).concat(a),type:D.CONV_TOPIC,unreadCount:r>0?r:0})})),o.length>0)&&this.getModule(co).updateTopicConversation(o)}},{key:"resetGetTopicTime",value:function(e){var t=this;Ze(e)?M(this._getTopicTimeMap.keys()).forEach((function(e){t._getTopicTimeMap.set(e,0)})):this._getTopicTimeMap.set(e,0)}},{key:"getTopicListOnReconnected",value:function(){var e=this,t=M(this._topicMap.keys()),o=[];t.forEach((function(t){var n=[];e._getLocalTopicList(t).forEach((function(t){var o=t.lastMessage.lastTime,a=void 0===o?0:o;Date.now()-1e3*a<1e3*e.TOPIC_LAST_ACTIVE_TIME&&n.push(t.topicID)})),n.length>0&&o.push({groupID:t,topicIDList:n})})),we.log("".concat(this._className,".getTopicListOnReconnected. active community count:").concat(o.length)),this._relayGetTopicList(o)}},{key:"_relayGetTopicList",value:function(e){var t=this;if(0!==e.length){var o=e.shift(),n=o.topicIDList.length>5?"topicIDList.length:".concat(o.topicIDList.length):"topicIDList:".concat(o.topicIDList),a=new va(ya.RELAY_GET_TOPIC_LIST);a.setMessage(n),we.log("".concat(this._className,"._relayGetTopicList. ").concat(n)),this.getTopicList(o).then((function(){a.setNetworkType(t.getNetworkType()).end(),t._relayGetTopicList(e)})).catch((function(o){t.probeNetwork().then((function(e){var t=m(e,2),n=t[0],s=t[1];a.setError(o,n,s).end()})),t._relayGetTopicList(e)}))}}},{key:"reset",value:function(){we.log("".concat(this._className,".reset")),this._topicMap.clear(),this._getTopicTimeMap.clear(),this.TOPIC_CACHE_TIME=300,this.TOPIC_LAST_ACTIVE_TIME=3600}}]),a}(Do),Gs=function(){function e(t){n(this,e),this._userModule=t,this._className="ProfileHandler",this.TAG="profile",this.accountProfileMap=new Map,this.expirationTime=864e5}return s(e,[{key:"setExpirationTime",value:function(e){this.expirationTime=e}},{key:"getUserProfile",value:function(e){var t=this,o=e.userIDList;e.fromAccount=this._userModule.getMyAccount(),o.length>100&&(we.warn("".concat(this._className,".getUserProfile 获取用户资料人数不能超过100人")),o.length=100);for(var n,a=[],s=[],r=0,i=o.length;r5?"userIDList.length:".concat(o.length):"userIDList:".concat(o)),this._userModule.request({protocolName:Uo,requestData:e}).then((function(e){l.setNetworkType(t._userModule.getNetworkType()).end(),we.info("".concat(t._className,".getUserProfile ok"));var o=t._handleResponse(e).concat(s);return ba(c?o[0]:o)})).catch((function(e){return t._userModule.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];l.setError(e,n,a).end()})),we.error("".concat(t._className,".getUserProfile failed. error:"),e),ja(e)}))}},{key:"getMyProfile",value:function(){var e=this._userModule.getMyAccount();if(we.log("".concat(this._className,".getMyProfile myAccount:").concat(e)),this._fillMap(),this._containsAccount(e)){var t=this._getProfileFromMap(e);return we.debug("".concat(this._className,".getMyProfile from cache, myProfile:")+JSON.stringify(t)),Ya(t)}return this.getUserProfile({fromAccount:e,userIDList:[e],bFromGetMyProfile:!0})}},{key:"_handleResponse",value:function(e){for(var t,o,n=it.now(),a=e.data.userProfileItem,s=[],r=0,i=a.length;r-1)o.profileCustomField.push({key:t[n].tag,value:t[n].value});else switch(t[n].tag){case Fe.NICK:o.nick=t[n].value;break;case Fe.GENDER:o.gender=t[n].value;break;case Fe.BIRTHDAY:o.birthday=t[n].value;break;case Fe.LOCATION:o.location=t[n].value;break;case Fe.SELFSIGNATURE:o.selfSignature=t[n].value;break;case Fe.ALLOWTYPE:o.allowType=t[n].value;break;case Fe.LANGUAGE:o.language=t[n].value;break;case Fe.AVATAR:o.avatar=t[n].value;break;case Fe.MESSAGESETTINGS:o.messageSettings=t[n].value;break;case Fe.ADMINFORBIDTYPE:o.adminForbidType=t[n].value;break;case Fe.LEVEL:o.level=t[n].value;break;case Fe.ROLE:o.role=t[n].value;break;default:we.warn("".concat(this._className,"._handleResponse unknown tag:"),t[n].tag,t[n].value)}return o}},{key:"updateMyProfile",value:function(e){var t=this,o="".concat(this._className,".updateMyProfile"),n=new va(ya.UPDATE_MY_PROFILE);n.setMessage(JSON.stringify(e));var a=(new rs).validate(e);if(!a.valid)return n.setCode(na.UPDATE_PROFILE_INVALID_PARAM).setMoreMessage("".concat(o," info:").concat(a.tips)).setNetworkType(this._userModule.getNetworkType()).end(),we.error("".concat(o," info:").concat(a.tips,",请参考 https://web.sdk.qcloud.com/im/doc/zh-cn/SDK.html#updateMyProfile")),ja({code:na.UPDATE_PROFILE_INVALID_PARAM,message:aa.UPDATE_PROFILE_INVALID_PARAM});var s=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&("profileCustomField"===r?e.profileCustomField.forEach((function(e){s.push({tag:e.key,value:e.value})})):s.push({tag:Fe[r.toUpperCase()],value:e[r]}));return 0===s.length?(n.setCode(na.UPDATE_PROFILE_NO_KEY).setMoreMessage(aa.UPDATE_PROFILE_NO_KEY).setNetworkType(this._userModule.getNetworkType()).end(),we.error("".concat(o," info:").concat(aa.UPDATE_PROFILE_NO_KEY,",请参考 https://web.sdk.qcloud.com/im/doc/zh-cn/SDK.html#updateMyProfile")),ja({code:na.UPDATE_PROFILE_NO_KEY,message:aa.UPDATE_PROFILE_NO_KEY})):this._userModule.request({protocolName:wo,requestData:{fromAccount:this._userModule.getMyAccount(),profileItem:s}}).then((function(a){n.setNetworkType(t._userModule.getNetworkType()).end(),we.info("".concat(o," ok"));var s=t._updateMap(t._userModule.getMyAccount(),e);return t._userModule.emitOuterEvent(S.PROFILE_UPDATED,[s]),Ya(s)})).catch((function(e){return t._userModule.probeNetwork().then((function(t){var o=m(t,2),a=o[0],s=o[1];n.setError(e,a,s).end()})),we.error("".concat(o," failed. error:"),e),ja(e)}))}},{key:"onProfileModified",value:function(e){var t=e.dataList;if(!Vt(t)){var o,n,a=t.length;we.debug("".concat(this._className,".onProfileModified count:").concat(a," dataList:"),e.dataList);for(var s=[],r=0;r0&&(this._userModule.emitInnerEvent(Qa,s),this._userModule.emitOuterEvent(S.PROFILE_UPDATED,s))}}},{key:"_fillMap",value:function(){if(0===this.accountProfileMap.size){for(var e=this._getCachedProfiles(),t=Date.now(),o=0,n=e.length;o0&&a.push(o)):a.push(t.userID));0!==a.length&&(we.info("".concat(this._className,".onConversationsProfileUpdated toAccountList:").concat(a)),this.getUserProfile({userIDList:a}))}},{key:"getNickAndAvatarByUserID",value:function(e){if(this._containsAccount(e)){var t=this._getProfileFromMap(e);return{nick:t.nick,avatar:t.avatar}}return{nick:"",avatar:""}}},{key:"reset",value:function(){this._flushMap(!0),this.accountProfileMap.clear()}}]),e}(),Ps=s((function e(t){n(this,e),Vt||(this.userID=t.userID||"",this.timeStamp=t.timeStamp||0)})),Us=function(){function e(t){n(this,e),this._userModule=t,this._className="BlacklistHandler",this._blacklistMap=new Map,this.startIndex=0,this.maxLimited=100,this.currentSequence=0}return s(e,[{key:"getLocalBlacklist",value:function(){return M(this._blacklistMap.keys())}},{key:"getBlacklist",value:function(){var e=this,t="".concat(this._className,".getBlacklist"),o={fromAccount:this._userModule.getMyAccount(),maxLimited:this.maxLimited,startIndex:0,lastSequence:this.currentSequence},n=new va(ya.GET_BLACKLIST);return this._userModule.request({protocolName:bo,requestData:o}).then((function(o){var a=o.data,s=a.blackListItem,r=a.currentSequence,i=Vt(s)?0:s.length;n.setNetworkType(e._userModule.getNetworkType()).setMessage("blackList count:".concat(i)).end(),we.info("".concat(t," ok")),e.currentSequence=r,e._handleResponse(s,!0),e._userModule.emitOuterEvent(S.BLACKLIST_UPDATED,M(e._blacklistMap.keys()))})).catch((function(o){return e._userModule.probeNetwork().then((function(e){var t=m(e,2),a=t[0],s=t[1];n.setError(o,a,s).end()})),we.error("".concat(t," failed. error:"),o),ja(o)}))}},{key:"addBlacklist",value:function(e){var t=this,o="".concat(this._className,".addBlacklist"),n=new va(ya.ADD_TO_BLACKLIST);if(!Qe(e.userIDList))return n.setCode(na.ADD_BLACKLIST_INVALID_PARAM).setMessage(aa.ADD_BLACKLIST_INVALID_PARAM).setNetworkType(this._userModule.getNetworkType()).end(),we.error("".concat(o," options.userIDList 必需是数组")),ja({code:na.ADD_BLACKLIST_INVALID_PARAM,message:aa.ADD_BLACKLIST_INVALID_PARAM});var a=this._userModule.getMyAccount();return 1===e.userIDList.length&&e.userIDList[0]===a?(n.setCode(na.CANNOT_ADD_SELF_TO_BLACKLIST).setMessage(aa.CANNOT_ADD_SELF_TO_BLACKLIST).setNetworkType(this._userModule.getNetworkType()).end(),we.error("".concat(o," 不能把自己拉黑")),ja({code:na.CANNOT_ADD_SELF_TO_BLACKLIST,message:aa.CANNOT_ADD_SELF_TO_BLACKLIST})):(e.userIDList.includes(a)&&(e.userIDList=e.userIDList.filter((function(e){return e!==a})),we.warn("".concat(o," 不能把自己拉黑,已过滤"))),e.fromAccount=this._userModule.getMyAccount(),e.toAccount=e.userIDList,this._userModule.request({protocolName:Fo,requestData:e}).then((function(a){return n.setNetworkType(t._userModule.getNetworkType()).setMessage(e.userIDList.length>5?"userIDList.length:".concat(e.userIDList.length):"userIDList:".concat(e.userIDList)).end(),we.info("".concat(o," ok")),t._handleResponse(a.resultItem,!0),ba(M(t._blacklistMap.keys()))})).catch((function(e){return t._userModule.probeNetwork().then((function(t){var o=m(t,2),a=o[0],s=o[1];n.setError(e,a,s).end()})),we.error("".concat(o," failed. error:"),e),ja(e)})))}},{key:"_handleResponse",value:function(e,t){if(!Vt(e))for(var o,n,a,s=0,r=e.length;s5?"userIDList.length:".concat(e.userIDList.length):"userIDList:".concat(e.userIDList)).end(),we.info("".concat(o," ok")),t._handleResponse(a.data.resultItem,!1),ba(M(t._blacklistMap.keys()))})).catch((function(e){return t._userModule.probeNetwork().then((function(t){var o=m(t,2),a=o[0],s=o[1];n.setError(e,a,s).end()})),we.error("".concat(o," failed. error:"),e),ja(e)}))):(n.setCode(na.DEL_BLACKLIST_INVALID_PARAM).setMessage(aa.DEL_BLACKLIST_INVALID_PARAM).setNetworkType(this._userModule.getNetworkType()).end(),we.error("".concat(o," options.userIDList 必需是数组")),ja({code:na.DEL_BLACKLIST_INVALID_PARAM,message:aa.DEL_BLACKLIST_INVALID_PARAM}))}},{key:"onAccountDeleted",value:function(e){for(var t,o=[],n=0,a=e.length;n0&&(we.log("".concat(this._className,".onAccountDeleted count:").concat(o.length," userIDList:"),o),this._userModule.emitOuterEvent(S.BLACKLIST_UPDATED,M(this._blacklistMap.keys())))}},{key:"onAccountAdded",value:function(e){for(var t,o=[],n=0,a=e.length;n0&&(we.log("".concat(this._className,".onAccountAdded count:").concat(o.length," userIDList:"),o),this._userModule.emitOuterEvent(S.BLACKLIST_UPDATED,M(this._blacklistMap.keys())))}},{key:"reset",value:function(){this._blacklistMap.clear(),this.startIndex=0,this.maxLimited=100,this.currentSequence=0}}]),e}(),ws=function(e){i(o,e);var t=f(o);function o(e){var a;return n(this,o),(a=t.call(this,e))._className="UserModule",a._profileHandler=new Gs(_(a)),a._blacklistHandler=new Us(_(a)),a.getInnerEmitterInstance().on(Ja,a.onContextUpdated,_(a)),a}return s(o,[{key:"onContextUpdated",value:function(e){this._profileHandler.getMyProfile(),this._blacklistHandler.getBlacklist()}},{key:"onProfileModified",value:function(e){this._profileHandler.onProfileModified(e)}},{key:"onRelationChainModified",value:function(e){var t=e.dataList;if(!Vt(t)){var o=[];t.forEach((function(e){e.blackListDelAccount&&o.push.apply(o,M(e.blackListDelAccount))})),o.length>0&&this._blacklistHandler.onAccountDeleted(o);var n=[];t.forEach((function(e){e.blackListAddAccount&&n.push.apply(n,M(e.blackListAddAccount))})),n.length>0&&this._blacklistHandler.onAccountAdded(n)}}},{key:"onConversationsProfileUpdated",value:function(e){this._profileHandler.onConversationsProfileUpdated(e)}},{key:"getMyAccount",value:function(){return this.getMyUserID()}},{key:"getMyProfile",value:function(){return this._profileHandler.getMyProfile()}},{key:"getStorageModule",value:function(){return this.getModule(lo)}},{key:"isMyFriend",value:function(e){var t=this.getModule(so);return!!t&&t.isMyFriend(e)}},{key:"getUserProfile",value:function(e){return this._profileHandler.getUserProfile(e)}},{key:"updateMyProfile",value:function(e){return this._profileHandler.updateMyProfile(e)}},{key:"getNickAndAvatarByUserID",value:function(e){return this._profileHandler.getNickAndAvatarByUserID(e)}},{key:"getLocalBlacklist",value:function(){var e=this._blacklistHandler.getLocalBlacklist();return Ya(e)}},{key:"addBlacklist",value:function(e){return this._blacklistHandler.addBlacklist(e)}},{key:"deleteBlacklist",value:function(e){return this._blacklistHandler.deleteBlacklist(e)}},{key:"reset",value:function(){we.log("".concat(this._className,".reset")),this._profileHandler.reset(),this._blacklistHandler.reset()}}]),o}(Do),bs=function(){function e(t,o){n(this,e),this._moduleManager=t,this._isLoggedIn=!1,this._SDKAppID=o.SDKAppID,this._userID=o.userID||"",this._userSig=o.userSig||"",this._version="2.20.1",this._a2Key="",this._tinyID="",this._contentType="json",this._unlimitedAVChatRoom=o.unlimitedAVChatRoom,this._scene=o.scene||"",this._oversea=o.oversea,this._instanceID=o.instanceID,this._statusInstanceID=0,this._isDevMode=o.devMode,this._proxyServer=o.proxyServer}return s(e,[{key:"isLoggedIn",value:function(){return this._isLoggedIn}},{key:"isOversea",value:function(){return this._oversea}},{key:"isPrivateNetWork",value:function(){return this._proxyServer}},{key:"isDevMode",value:function(){return this._isDevMode}},{key:"isSingaporeSite",value:function(){return this._SDKAppID>=2e7&&this._SDKAppID<3e7}},{key:"isKoreaSite",value:function(){return this._SDKAppID>=3e7&&this._SDKAppID<4e7}},{key:"isGermanySite",value:function(){return this._SDKAppID>=4e7&&this._SDKAppID<5e7}},{key:"isIndiaSite",value:function(){return this._SDKAppID>=5e7&&this._SDKAppID<6e7}},{key:"isUnlimitedAVChatRoom",value:function(){return this._unlimitedAVChatRoom}},{key:"getUserID",value:function(){return this._userID}},{key:"setUserID",value:function(e){this._userID=e}},{key:"setUserSig",value:function(e){this._userSig=e}},{key:"getUserSig",value:function(){return this._userSig}},{key:"getSDKAppID",value:function(){return this._SDKAppID}},{key:"getTinyID",value:function(){return this._tinyID}},{key:"setTinyID",value:function(e){this._tinyID=e,this._isLoggedIn=!0}},{key:"getScene",value:function(){return this._isTUIKit()?"tuikit":this._scene}},{key:"getInstanceID",value:function(){return this._instanceID}},{key:"getStatusInstanceID",value:function(){return this._statusInstanceID}},{key:"setStatusInstanceID",value:function(e){this._statusInstanceID=e}},{key:"getVersion",value:function(){return this._version}},{key:"getA2Key",value:function(){return this._a2Key}},{key:"setA2Key",value:function(e){this._a2Key=e}},{key:"getContentType",value:function(){return this._contentType}},{key:"getProxyServer",value:function(){return this._proxyServer}},{key:"_isTUIKit",value:function(){var e=!1,t=!1,o=!1,n=!1,a=[];te&&(a=Object.keys(ne)),oe&&(a=ee?Object.keys(uni):Object.keys(window));for(var s=0,r=a.length;s0){for(var u=0,l=c.length;u0&&void 0!==arguments[0]?arguments[0]:0;if(!this.isLoggedIn())return ja({code:na.USER_NOT_LOGGED_IN,message:aa.USER_NOT_LOGGED_IN});var o=new va(ya.LOGOUT);return o.setNetworkType(this.getNetworkType()).setMessage("identifier:".concat(this.getMyUserID())).end(!0),we.info("".concat(this._className,".logout type:").concat(t)),0===t&&this._moduleManager.setNotReadyReason(na.LOGGED_OUT),this.request({protocolName:Ao,requestData:{type:t}}).then((function(){return e.resetReady(),Ya({})})).catch((function(t){return we.error("".concat(e._className,"._logout error:"),t),e.resetReady(),Ya({})}))}},{key:"_fetchCloudControlConfig",value:function(){this.getModule(Io).fetchConfig()}},{key:"_hello",value:function(){var e=this;this._lastWsHelloTs=Date.now(),this.request({protocolName:Oo}).catch((function(t){we.warn("".concat(e._className,"._hello error:"),t)}))}},{key:"getLastWsHelloTs",value:function(){return this._lastWsHelloTs}},{key:"_checkLoginInfo",value:function(e){var t=0,o="";return Vt(this.getModule(uo).getSDKAppID())?(t=na.NO_SDKAPPID,o=aa.NO_SDKAPPID):Vt(e.userID)?(t=na.NO_IDENTIFIER,o=aa.NO_IDENTIFIER):Vt(e.userSig)&&(t=na.NO_USERSIG,o=aa.NO_USERSIG),{code:t,message:o}}},{key:"onMultipleAccountKickedOut",value:function(e){var t=this;new va(ya.KICKED_OUT).setNetworkType(this.getNetworkType()).setMessage("type:".concat(D.KICKED_OUT_MULT_ACCOUNT," newInstanceInfo:").concat(JSON.stringify(e))).end(!0),we.warn("".concat(this._className,".onMultipleAccountKickedOut userID:").concat(this.getMyUserID()," newInstanceInfo:"),e),this.logout(1).then((function(){t.emitOuterEvent(S.KICKED_OUT,{type:D.KICKED_OUT_MULT_ACCOUNT}),t._moduleManager.setNotReadyReason(na.KICKED_OUT_MULT_ACCOUNT),t._moduleManager.reset()}))}},{key:"onMultipleDeviceKickedOut",value:function(e){var t=this;new va(ya.KICKED_OUT).setNetworkType(this.getNetworkType()).setMessage("type:".concat(D.KICKED_OUT_MULT_DEVICE," newInstanceInfo:").concat(JSON.stringify(e))).end(!0),we.warn("".concat(this._className,".onMultipleDeviceKickedOut userID:").concat(this.getMyUserID()," newInstanceInfo:"),e),this.logout(1).then((function(){t.emitOuterEvent(S.KICKED_OUT,{type:D.KICKED_OUT_MULT_DEVICE}),t._moduleManager.setNotReadyReason(na.KICKED_OUT_MULT_DEVICE),t._moduleManager.reset()}))}},{key:"onUserSigExpired",value:function(){new va(ya.KICKED_OUT).setNetworkType(this.getNetworkType()).setMessage(D.KICKED_OUT_USERSIG_EXPIRED).end(!0),we.warn("".concat(this._className,".onUserSigExpired: userSig 签名过期被踢下线")),0!==this.getModule(uo).getStatusInstanceID()&&(this.emitOuterEvent(S.KICKED_OUT,{type:D.KICKED_OUT_USERSIG_EXPIRED}),this._moduleManager.setNotReadyReason(na.KICKED_OUT_USERSIG_EXPIRED),this._moduleManager.reset())}},{key:"onRestApiKickedOut",value:function(e){(new va(ya.KICKED_OUT).setNetworkType(this.getNetworkType()).setMessage("type:".concat(D.KICKED_OUT_REST_API," newInstanceInfo:").concat(JSON.stringify(e))).end(!0),we.warn("".concat(this._className,".onRestApiKickedOut userID:").concat(this.getMyUserID()," newInstanceInfo:"),e),0!==this.getModule(uo).getStatusInstanceID())&&(this.emitOuterEvent(S.KICKED_OUT,{type:D.KICKED_OUT_REST_API}),this._moduleManager.setNotReadyReason(na.KICKED_OUT_REST_API),this._moduleManager.reset(),this.getModule(vo).onRestApiKickedOut())}},{key:"reset",value:function(){we.log("".concat(this._className,".reset")),this.resetReady(),this._helloInterval=120,this._lastLoginTs=0,this._lastWsHelloTs=0}}]),o}(Do);function qs(){return null}var Vs=function(){function e(t){n(this,e),this._moduleManager=t,this._className="StorageModule",this._storageQueue=new Map,this._errorTolerantHandle()}return s(e,[{key:"_errorTolerantHandle",value:function(){te||!Ze(window)&&!Ze(window.localStorage)||(this.getItem=qs,this.setItem=qs,this.removeItem=qs,this.clear=qs)}},{key:"onCheckTimer",value:function(e){if(e%20==0){if(0===this._storageQueue.size)return;this._doFlush()}}},{key:"_doFlush",value:function(){try{var e,t=C(this._storageQueue);try{for(t.s();!(e=t.n()).done;){var o=m(e.value,2),n=o[0],a=o[1];this._setStorageSync(this._getKey(n),a)}}catch(s){t.e(s)}finally{t.f()}this._storageQueue.clear()}catch(r){we.warn("".concat(this._className,"._doFlush error:"),r)}}},{key:"_getPrefix",value:function(){var e=this._moduleManager.getModule(uo);return"TIM_".concat(e.getSDKAppID(),"_").concat(e.getUserID(),"_")}},{key:"_getKey",value:function(e){return"".concat(this._getPrefix()).concat(e)}},{key:"getItem",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];try{var o=t?this._getKey(e):e;return this.getStorageSync(o)}catch(n){return we.warn("".concat(this._className,".getItem error:"),n),{}}}},{key:"setItem",value:function(e,t){var o=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];if(o){var a=n?this._getKey(e):e;this._setStorageSync(a,t)}else this._storageQueue.set(e,t)}},{key:"clear",value:function(){try{te?ne.clearStorageSync():localStorage&&localStorage.clear()}catch(e){we.warn("".concat(this._className,".clear error:"),e)}}},{key:"removeItem",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];try{var o=t?this._getKey(e):e;this._removeStorageSync(o)}catch(n){we.warn("".concat(this._className,".removeItem error:"),n)}}},{key:"getSize",value:function(e){var t=this,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"b";try{var n={size:0,limitSize:5242880,unit:o};if(Object.defineProperty(n,"leftSize",{enumerable:!0,get:function(){return n.limitSize-n.size}}),te&&(n.limitSize=1024*ne.getStorageInfoSync().limitSize),e)n.size=JSON.stringify(this.getItem(e)).length+this._getKey(e).length;else if(te){var a=ne.getStorageInfoSync(),s=a.keys;s.forEach((function(e){n.size+=JSON.stringify(t.getStorageSync(e)).length+t._getKey(e).length}))}else if(localStorage)for(var r in localStorage)localStorage.hasOwnProperty(r)&&(n.size+=localStorage.getItem(r).length+r.length);return this._convertUnit(n)}catch(i){we.warn("".concat(this._className," error:"),i)}}},{key:"_convertUnit",value:function(e){var t={},o=e.unit;for(var n in t.unit=o,e)"number"==typeof e[n]&&("kb"===o.toLowerCase()?t[n]=Math.round(e[n]/1024):"mb"===o.toLowerCase()?t[n]=Math.round(e[n]/1024/1024):t[n]=e[n]);return t}},{key:"_setStorageSync",value:function(e,t){te?Q?my.setStorageSync({key:e,data:t}):ne.setStorageSync(e,t):localStorage&&localStorage.setItem(e,JSON.stringify(t))}},{key:"getStorageSync",value:function(e){return te?Q?my.getStorageSync({key:e}).data:ne.getStorageSync(e):localStorage?JSON.parse(localStorage.getItem(e)):{}}},{key:"_removeStorageSync",value:function(e){te?Q?my.removeStorageSync({key:e}):ne.removeStorageSync(e):localStorage&&localStorage.removeItem(e)}},{key:"reset",value:function(){we.log("".concat(this._className,".reset")),this._doFlush()}}]),e}(),Ks=function(){function e(t){n(this,e),this._className="SSOLogBody",this._report=[]}return s(e,[{key:"pushIn",value:function(e){we.debug("".concat(this._className,".pushIn"),this._report.length,e),this._report.push(e)}},{key:"backfill",value:function(e){var t;Qe(e)&&0!==e.length&&(we.debug("".concat(this._className,".backfill"),this._report.length,e.length),(t=this._report).unshift.apply(t,M(e)))}},{key:"getLogsNumInMemory",value:function(){return this._report.length}},{key:"isEmpty",value:function(){return 0===this._report.length}},{key:"_reset",value:function(){this._report.length=0,this._report=[]}},{key:"getLogsInMemory",value:function(){var e=this._report.slice();return this._reset(),e}}]),e}(),Hs=function(e){var t=e.getModule(uo);return{SDKType:10,SDKAppID:t.getSDKAppID(),SDKVersion:t.getVersion(),tinyID:Number(t.getTinyID()),userID:t.getUserID(),platform:e.getPlatform(),instanceID:t.getInstanceID(),traceID:Re()}},Bs=function(e){i(a,e);var o=f(a);function a(e){var t;n(this,a),(t=o.call(this,e))._className="EventStatModule",t.TAG="im-ssolog-event",t._reportBody=new Ks,t.MIN_THRESHOLD=20,t.MAX_THRESHOLD=100,t.WAITING_TIME=6e4,t.REPORT_LEVEL=[4,5,6],t.REPORT_SDKAPPID_BLACKLIST=[],t.REPORT_TINYID_WHITELIST=[],t._lastReportTime=Date.now();var s=t.getInnerEmitterInstance();return s.on(Ja,t._onLoginSuccess,_(t)),s.on(Xa,t._onCloudConfigUpdated,_(t)),t}return s(a,[{key:"reportAtOnce",value:function(){we.debug("".concat(this._className,".reportAtOnce")),this._report()}},{key:"_onLoginSuccess",value:function(){var e=this,t=this.getModule(lo),o=t.getItem(this.TAG,!1);!Vt(o)&&ot(o.forEach)&&(we.log("".concat(this._className,"._onLoginSuccess get ssolog in storage, count:").concat(o.length)),o.forEach((function(t){e._reportBody.pushIn(t)})),t.removeItem(this.TAG,!1))}},{key:"_onCloudConfigUpdated",value:function(){var e=this.getCloudConfig("evt_rpt_threshold"),t=this.getCloudConfig("evt_rpt_waiting"),o=this.getCloudConfig("evt_rpt_level"),n=this.getCloudConfig("evt_rpt_sdkappid_bl"),a=this.getCloudConfig("evt_rpt_tinyid_wl");Ze(e)||(this.MIN_THRESHOLD=Number(e)),Ze(t)||(this.WAITING_TIME=Number(t)),Ze(o)||(this.REPORT_LEVEL=o.split(",").map((function(e){return Number(e)}))),Ze(n)||(this.REPORT_SDKAPPID_BLACKLIST=n.split(",").map((function(e){return Number(e)}))),Ze(a)||(this.REPORT_TINYID_WHITELIST=a.split(","))}},{key:"pushIn",value:function(e){e instanceof va&&(e.updateTimeStamp(),this._reportBody.pushIn(e),this._reportBody.getLogsNumInMemory()>=this.MIN_THRESHOLD&&this._report())}},{key:"onCheckTimer",value:function(){Date.now()e.MAX_THRESHOLD&&e._flushAtOnce()}))}else this._lastReportTime=Date.now()}}},{key:"_flushAtOnce",value:function(){var e=this.getModule(lo),t=e.getItem(this.TAG,!1),o=this._reportBody.getLogsInMemory();if(Vt(t))we.log("".concat(this._className,"._flushAtOnce count:").concat(o.length)),e.setItem(this.TAG,o,!0,!1);else{var n=o.concat(t);n.length>this.MAX_THRESHOLD&&(n=n.slice(0,this.MAX_THRESHOLD)),we.log("".concat(this._className,"._flushAtOnce count:").concat(n.length)),e.setItem(this.TAG,n,!0,!1)}}},{key:"reset",value:function(){we.log("".concat(this._className,".reset")),this._lastReportTime=0,this._report(),this.REPORT_SDKAPPID_BLACKLIST=[],this.REPORT_TINYID_WHITELIST=[]}}]),a}(Do),xs="none",Ws="online",Ys=[na.OVER_FREQUENCY_LIMIT,na.OPEN_SERVICE_OVERLOAD_ERROR],js=function(){function e(t){n(this,e),this._moduleManager=t,this._networkType="",this._className="NetMonitorModule",this.MAX_WAIT_TIME=3e3,this._mpNetworkStatusCallback=null,this._webOnlineCallback=null,this._webOfflineCallback=null}return s(e,[{key:"start",value:function(){var e=this;te?(ne.getNetworkType({success:function(t){e._networkType=t.networkType,t.networkType===xs?we.warn("".concat(e._className,".start no network, please check!")):we.info("".concat(e._className,".start networkType:").concat(t.networkType))}}),this._mpNetworkStatusCallback=this._onNetworkStatusChange.bind(this),ne.onNetworkStatusChange(this._mpNetworkStatusCallback)):(this._networkType=Ws,this._webOnlineCallback=this._onWebOnline.bind(this),this._webOfflineCallback=this._onWebOffline.bind(this),window&&(window.addEventListener("online",this._webOnlineCallback),window.addEventListener("offline",this._webOfflineCallback)))}},{key:"_onWebOnline",value:function(){this._onNetworkStatusChange({isConnected:!0,networkType:Ws})}},{key:"_onWebOffline",value:function(){this._onNetworkStatusChange({isConnected:!1,networkType:xs})}},{key:"_onNetworkStatusChange",value:function(e){var t=e.isConnected,o=e.networkType,n=!1;t?(we.info("".concat(this._className,"._onNetworkStatusChange previousNetworkType:").concat(this._networkType," currentNetworkType:").concat(o)),this._networkType!==o&&(n=!0,this._moduleManager.getModule(vo).reConnect(!0))):this._networkType!==o&&(n=!0,we.warn("".concat(this._className,"._onNetworkStatusChange no network, please check!")),this._moduleManager.getModule(vo).offline());n&&(new va(ya.NETWORK_CHANGE).setMessage("isConnected:".concat(t," previousNetworkType:").concat(this._networkType," networkType:").concat(o)).end(),this._networkType=o)}},{key:"probe",value:function(e){var t=this;return!Ze(e)&&Ys.includes(e.code)?Promise.resolve([!0,this._networkType]):new Promise((function(e,o){if(te)ne.getNetworkType({success:function(o){t._networkType=o.networkType,o.networkType===xs?(we.warn("".concat(t._className,".probe no network, please check!")),e([!1,o.networkType])):(we.info("".concat(t._className,".probe networkType:").concat(o.networkType)),e([!0,o.networkType]))}});else if(window&&window.fetch)fetch("".concat(ft(),"//web.sdk.qcloud.com/im/assets/speed.xml?random=").concat(Math.random())).then((function(t){t.ok?e([!0,Ws]):e([!1,xs])})).catch((function(t){e([!1,xs])}));else{var n=new XMLHttpRequest,a=setTimeout((function(){we.warn("".concat(t._className,".probe fetch timeout. Probably no network, please check!")),n.abort(),t._networkType=xs,e([!1,xs])}),t.MAX_WAIT_TIME);n.onreadystatechange=function(){4===n.readyState&&(clearTimeout(a),200===n.status||304===n.status||514===n.status?(this._networkType=Ws,e([!0,Ws])):(we.warn("".concat(this.className,".probe fetch status:").concat(n.status,". Probably no network, please check!")),this._networkType=xs,e([!1,xs])))},n.open("GET","".concat(ft(),"//web.sdk.qcloud.com/im/assets/speed.xml?random=").concat(Math.random())),n.send()}}))}},{key:"getNetworkType",value:function(){return this._networkType}},{key:"reset",value:function(){we.log("".concat(this._className,".reset")),te?null!==this._mpNetworkStatusCallback&&(ne.offNetworkStatusChange&&(Z||J?ne.offNetworkStatusChange(this._mpNetworkStatusCallback):ne.offNetworkStatusChange()),this._mpNetworkStatusCallback=null):window&&(null!==this._webOnlineCallback&&(window.removeEventListener("online",this._webOnlineCallback),this._webOnlineCallback=null),null!==this._onWebOffline&&(window.removeEventListener("offline",this._webOfflineCallback),this._webOfflineCallback=null))}}]),e}(),$s=O((function(e){var t=Object.prototype.hasOwnProperty,o="~";function n(){}function a(e,t,o){this.fn=e,this.context=t,this.once=o||!1}function s(e,t,n,s,r){if("function"!=typeof n)throw new TypeError("The listener must be a function");var i=new a(n,s||e,r),c=o?o+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],i]:e._events[c].push(i):(e._events[c]=i,e._eventsCount++),e}function r(e,t){0==--e._eventsCount?e._events=new n:delete e._events[t]}function i(){this._events=new n,this._eventsCount=0}Object.create&&(n.prototype=Object.create(null),(new n).__proto__||(o=!1)),i.prototype.eventNames=function(){var e,n,a=[];if(0===this._eventsCount)return a;for(n in e=this._events)t.call(e,n)&&a.push(o?n.slice(1):n);return Object.getOwnPropertySymbols?a.concat(Object.getOwnPropertySymbols(e)):a},i.prototype.listeners=function(e){var t=o?o+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var a=0,s=n.length,r=new Array(s);a=this.cosOptions.expiredTime-120&&this._getAuthorizationKey())}},{key:"_getAuthorization",value:function(e,t){t({TmpSecretId:this.cosOptions.secretId,TmpSecretKey:this.cosOptions.secretKey,XCosSecurityToken:this.cosOptions.sessionToken,ExpiredTime:this.cosOptions.expiredTime})}},{key:"upload",value:function(e){if(!0===e.getRelayFlag())return Promise.resolve();var t=this.getModule(Co);switch(e.type){case D.MSG_IMAGE:return t.addTotalCount(da),this._uploadImage(e);case D.MSG_FILE:return t.addTotalCount(da),this._uploadFile(e);case D.MSG_AUDIO:return t.addTotalCount(da),this._uploadAudio(e);case D.MSG_VIDEO:return t.addTotalCount(da),this._uploadVideo(e);default:return Promise.resolve()}}},{key:"_uploadImage",value:function(e){var o=this,n=this.getModule(to),a=e.getElements()[0],s=n.getMessageOption(e.clientSequence);return this.doUploadImage({file:s.payload.file,to:s.to,onProgress:function(e){if(a.updatePercent(e),ot(s.onProgress))try{s.onProgress(e)}catch(t){return ja({code:na.MESSAGE_ONPROGRESS_FUNCTION_ERROR,message:aa.MESSAGE_ONPROGRESS_FUNCTION_ERROR})}}}).then((function(n){var s=n.location,r=n.fileType,i=n.fileSize,c=n.width,u=n.height,l=o.isPrivateNetWork()?s:mt(s);a.updateImageFormat(r);var d=Lt({originUrl:l,originWidth:c,originHeight:u,min:198}),p=Lt({originUrl:l,originWidth:c,originHeight:u,min:720});return a.updateImageInfoArray([{size:i,url:l,width:c,height:u},t({},p),t({},d)]),e}))}},{key:"_uploadFile",value:function(e){var t=this,o=this.getModule(to),n=e.getElements()[0],a=o.getMessageOption(e.clientSequence);return this.doUploadFile({file:a.payload.file,to:a.to,onProgress:function(e){if(n.updatePercent(e),ot(a.onProgress))try{a.onProgress(e)}catch(t){return ja({code:na.MESSAGE_ONPROGRESS_FUNCTION_ERROR,message:aa.MESSAGE_ONPROGRESS_FUNCTION_ERROR})}}}).then((function(o){var a=o.location,s=t.isPrivateNetWork()?a:mt(a);return n.updateFileUrl(s),e}))}},{key:"_uploadAudio",value:function(e){var t=this,o=this.getModule(to),n=e.getElements()[0],a=o.getMessageOption(e.clientSequence);return this.doUploadAudio({file:a.payload.file,to:a.to,onProgress:function(e){if(n.updatePercent(e),ot(a.onProgress))try{a.onProgress(e)}catch(t){return ja({code:na.MESSAGE_ONPROGRESS_FUNCTION_ERROR,message:aa.MESSAGE_ONPROGRESS_FUNCTION_ERROR})}}}).then((function(o){var a=o.location,s=t.isPrivateNetWork()?a:mt(a);return n.updateAudioUrl(s),e}))}},{key:"_uploadVideo",value:function(e){var t=this,o=this.getModule(to),n=e.getElements()[0],a=o.getMessageOption(e.clientSequence);return this.doUploadVideo({file:a.payload.file,to:a.to,onProgress:function(e){if(n.updatePercent(e),ot(a.onProgress))try{a.onProgress(e)}catch(t){return ja({code:na.MESSAGE_ONPROGRESS_FUNCTION_ERROR,message:aa.MESSAGE_ONPROGRESS_FUNCTION_ERROR})}}}).then((function(o){var a=o.location,s=o.snapshotInfo,r=t.isPrivateNetWork()?a:mt(a);return n.updateVideoUrl(r),Vt(s)||n.updateSnapshotInfo(s),e}))}},{key:"doUploadImage",value:function(e){var t=this;if(!e.file)return ja({code:na.MESSAGE_IMAGE_SELECT_FILE_FIRST,message:aa.MESSAGE_IMAGE_SELECT_FILE_FIRST});var o=this._checkImageType(e.file);if(!0!==o)return o;var n=this._checkImageSize(e.file);if(!0!==n)return n;var a=null;return this._setUploadFileType(os),this.uploadByCOS(e).then((function(e){return a=e,t.isPrivateNetWork()?At(e.location):At("https://".concat(e.location))})).then((function(e){return a.width=e.width,a.height=e.height,Promise.resolve(a)}))}},{key:"_checkImageType",value:function(e){var t="";return t=te?e.url.slice(e.url.lastIndexOf(".")+1):e.files[0].name.slice(e.files[0].name.lastIndexOf(".")+1),es.indexOf(t.toLowerCase())>=0||ja({code:na.MESSAGE_IMAGE_TYPES_LIMIT,message:aa.MESSAGE_IMAGE_TYPES_LIMIT})}},{key:"_checkImageSize",value:function(e){var t=0;return 0===(t=te?e.size:e.files[0].size)?ja({code:na.MESSAGE_FILE_IS_EMPTY,message:"".concat(aa.MESSAGE_FILE_IS_EMPTY)}):t<20971520||ja({code:na.MESSAGE_IMAGE_SIZE_LIMIT,message:"".concat(aa.MESSAGE_IMAGE_SIZE_LIMIT)})}},{key:"doUploadFile",value:function(e){var t=null;return e.file?e.file.files[0].size>104857600?ja(t={code:na.MESSAGE_FILE_SIZE_LIMIT,message:aa.MESSAGE_FILE_SIZE_LIMIT}):0===e.file.files[0].size?(t={code:na.MESSAGE_FILE_IS_EMPTY,message:"".concat(aa.MESSAGE_FILE_IS_EMPTY)},ja(t)):(this._setUploadFileType(ss),this.uploadByCOS(e)):ja(t={code:na.MESSAGE_FILE_SELECT_FILE_FIRST,message:aa.MESSAGE_FILE_SELECT_FILE_FIRST})}},{key:"doUploadVideo",value:function(e){return e.file.videoFile.size>104857600?ja({code:na.MESSAGE_VIDEO_SIZE_LIMIT,message:"".concat(aa.MESSAGE_VIDEO_SIZE_LIMIT)}):0===e.file.videoFile.size?ja({code:na.MESSAGE_FILE_IS_EMPTY,message:"".concat(aa.MESSAGE_FILE_IS_EMPTY)}):-1===ts.indexOf(e.file.videoFile.type)?ja({code:na.MESSAGE_VIDEO_TYPES_LIMIT,message:"".concat(aa.MESSAGE_VIDEO_TYPES_LIMIT)}):(this._setUploadFileType(ns),te?this.handleVideoUpload({file:e.file.videoFile,onProgress:e.onProgress}):oe?this.handleVideoUpload(e):void 0)}},{key:"handleVideoUpload",value:function(e){var t=this;return new Promise((function(o,n){t.uploadByCOS(e).then((function(e){o(e)})).catch((function(){t.uploadByCOS(e).then((function(e){o(e)})).catch((function(){n(new Ba({code:na.MESSAGE_VIDEO_UPLOAD_FAIL,message:aa.MESSAGE_VIDEO_UPLOAD_FAIL}))}))}))}))}},{key:"doUploadAudio",value:function(e){return e.file?e.file.size>20971520?ja(new Ba({code:na.MESSAGE_AUDIO_SIZE_LIMIT,message:"".concat(aa.MESSAGE_AUDIO_SIZE_LIMIT)})):0===e.file.size?ja(new Ba({code:na.MESSAGE_FILE_IS_EMPTY,message:"".concat(aa.MESSAGE_FILE_IS_EMPTY)})):(this._setUploadFileType(as),this.uploadByCOS(e)):ja(new Ba({code:na.MESSAGE_AUDIO_UPLOAD_FAIL,message:aa.MESSAGE_AUDIO_UPLOAD_FAIL}))}},{key:"uploadByCOS",value:function(e){var t=this,o="".concat(this._className,".uploadByCOS");if(!ot(this._cosUploadMethod))return we.warn("".concat(o," 没有检测到上传插件,将无法发送图片、音频、视频、文件等类型的消息。详细请参考 https://web.sdk.qcloud.com/im/doc/zh-cn/SDK.html#registerPlugin")),ja({code:na.COS_UNDETECTED,message:aa.COS_UNDETECTED});if(this.timUploadPlugin)return this._uploadWithPreSigUrl(e);var n=new va(ya.UPLOAD),a=Date.now(),s=this._getFile(e);return new Promise((function(r,i){var c=te?t._createCosOptionsWXMiniApp(e):t._createCosOptionsWeb(e),u=t;t._cosUploadMethod(c,(function(e,c){var l=Object.create(null);if(c){if(e||Qe(c.files)&&c.files[0].error){var d=new Ba({code:na.MESSAGE_FILE_UPLOAD_FAIL,message:aa.MESSAGE_FILE_UPLOAD_FAIL});return n.setError(d,!0,t.getNetworkType()).end(),we.log("".concat(o," failed. error:"),c.files[0].error),403===c.files[0].error.statusCode&&(we.warn("".concat(o," failed. cos AccessKeyId was invalid, regain auth key!")),t._getAuthorizationKey()),void i(d)}l.fileName=s.name,l.fileSize=s.size,l.fileType=s.type.slice(s.type.indexOf("/")+1).toLowerCase(),l.location=te?c.Location:c.files[0].data.Location;var p=Date.now()-a,g=u._formatFileSize(s.size),_=u._formatSpeed(1e3*s.size/p),h="size:".concat(g," time:").concat(p,"ms speed:").concat(_);we.log("".concat(o," success. name:").concat(s.name," ").concat(h)),r(l);var f=t.getModule(Co);return f.addCost(da,p),f.addFileSize(da,s.size),void n.setNetworkType(t.getNetworkType()).setMessage(h).end()}var m=new Ba({code:na.MESSAGE_FILE_UPLOAD_FAIL,message:aa.MESSAGE_FILE_UPLOAD_FAIL});n.setError(m,!0,u.getNetworkType()).end(),we.warn("".concat(o," failed. error:"),e),403===e.statusCode&&(we.warn("".concat(o," failed. cos AccessKeyId was invalid, regain auth key!")),t._getAuthorizationKey()),i(m)}))}))}},{key:"_uploadWithPreSigUrl",value:function(e){var t=this,o="".concat(this._className,"._uploadWithPreSigUrl"),n=this._getFile(e);return this._createCosOptionsPreSigUrl(e).then((function(e){return new Promise((function(a,s){var r=new va(ya.UPLOAD),i=e.requestSnapshotUrl,c=void 0===i?void 0:i,u=g(e,Js),l=Date.now();t._cosUploadMethod(u,(function(e,i){var u=Object.create(null);if(e||403===i.statusCode){var d=new Ba({code:na.MESSAGE_FILE_UPLOAD_FAIL,message:aa.MESSAGE_FILE_UPLOAD_FAIL});return r.setError(d,!0,t.getNetworkType()).end(),we.log("".concat(o," failed, error:"),e),void s(d)}var p=i.data.location||"";t.isPrivateNetWork()||0!==p.indexOf("https://")&&0!==p.indexOf("http://")||(p=p.split("//")[1]),u.fileName=n.name,u.fileSize=n.size,u.fileType=n.type.slice(n.type.indexOf("/")+1).toLowerCase(),u.location=p;var g=Date.now()-l,_=t._formatFileSize(n.size),h=t._formatSpeed(1e3*n.size/g),f="size:".concat(_,",time:").concat(g,"ms,speed:").concat(h," res:").concat(JSON.stringify(i.data));we.log("".concat(o," success name:").concat(n.name,",").concat(f)),r.setNetworkType(t.getNetworkType()).setMessage(f).end();var m=t.getModule(Co);if(m.addCost(da,g),m.addFileSize(da,n.size),!Vt(c))return t._getSnapshotInfoByUrl(c).then((function(e){u.snapshotInfo=e,a(u)}));a(u)}))}))}))}},{key:"_getFile",value:function(e){var t=null;return te?t=Z&&Qe(e.file.files)?e.file.files[0]:e.file:oe&&(t=e.file.files[0]),t}},{key:"_formatFileSize",value:function(e){return e<1024?e+"B":e<1048576?Math.floor(e/1024)+"KB":Math.floor(e/1048576)+"MB"}},{key:"_formatSpeed",value:function(e){return e<=1048576?Pt(e/1024,1)+"KB/s":Pt(e/1048576,1)+"MB/s"}},{key:"_createCosOptionsWeb",value:function(e){var t=e.file.files[0].name,o=t.slice(t.lastIndexOf(".")),n=this._genFileName("".concat(dt(999999)).concat(o));return{files:[{Bucket:"".concat(this.bucketName,"-").concat(this.appid),Region:this.region,Key:"".concat(this.directory,"/").concat(n),Body:e.file.files[0]}],SliceSize:1048576,onProgress:function(t){if("function"==typeof e.onProgress)try{e.onProgress(t.percent)}catch(o){we.warn("onProgress callback error:",o)}},onFileFinish:function(e,t,o){}}}},{key:"_createCosOptionsWXMiniApp",value:function(e){var t=this._getFile(e),o=this._genFileName(t.name),n=t.url;return{Bucket:"".concat(this.bucketName,"-").concat(this.appid),Region:this.region,Key:"".concat(this.directory,"/").concat(o),FilePath:n,onProgress:function(t){if(we.log(JSON.stringify(t)),"function"==typeof e.onProgress)try{e.onProgress(t.percent)}catch(o){we.warn("onProgress callback error:",o)}}}}},{key:"_createCosOptionsPreSigUrl",value:function(e){var t=this,o="",n="",a=0;if(te){var s=this._getFile(e);o=this._genFileName(s.name),n=s.url,a=1}else{var r=e.file.files[0].name,i=r.slice(r.lastIndexOf("."));o=this._genFileName("".concat(dt(999999)).concat(i)),n=e.file.files[0],a=0}return this._getCosPreSigUrl({fileType:this.uploadFileType,fileName:o,uploadMethod:a,duration:this.duration}).then((function(a){var s=a.uploadUrl,r=a.downloadUrl,i=a.requestSnapshotUrl,c=void 0===i?void 0:i;return{url:s,fileType:t.uploadFileType,fileName:o,resources:n,downloadUrl:r,requestSnapshotUrl:c,onProgress:function(t){if("function"==typeof e.onProgress)try{e.onProgress(t.percent)}catch(o){we.warn("onProgress callback error:",o),we.error(o)}}}}))}},{key:"_genFileName",value:function(e){return"".concat(Ot(),"-").concat(e)}},{key:"_setUploadFileType",value:function(e){this.uploadFileType=e}},{key:"_getSnapshotInfoByUrl",value:function(e){var t=this,o=new va(ya.GET_SNAPSHOT_INFO);return this.request({protocolName:qn,requestData:{platform:this.getPlatform(),coverName:this._genFileName(dt(99999)),requestSnapshotUrl:e}}).then((function(e){var t=(e.data||{}).snapshotUrl;return o.setMessage("snapshotUrl:".concat(t)).end(),Vt(t)?{}:At(t).then((function(e){return{snapshotUrl:t,snapshotWidth:e.width,snapshotHeight:e.height}}))})).catch((function(e){return we.warn("".concat(t._className,"._getSnapshotInfoByUrl failed. error:"),e),o.setCode(e.errorCode).setMessage(e.errorInfo).end(),{}}))}},{key:"reset",value:function(){we.log("".concat(this._className,".reset"))}}]),a}(Do),Qs=["downloadKey","pbDownloadKey","messageList"],Zs=function(){function e(t){n(this,e),this._className="MergerMessageHandler",this._messageModule=t}return s(e,[{key:"uploadMergerMessage",value:function(e,t){var o=this;we.debug("".concat(this._className,".uploadMergerMessage message:"),e,"messageBytes:".concat(t));var n=e.payload.messageList,a=n.length,s=new va(ya.UPLOAD_MERGER_MESSAGE);return this._messageModule.request({protocolName:Yn,requestData:{messageList:n}}).then((function(e){we.debug("".concat(o._className,".uploadMergerMessage ok. response:"),e.data);var n=e.data,r=n.pbDownloadKey,i=n.downloadKey,c={pbDownloadKey:r,downloadKey:i,messageNumber:a};return s.setNetworkType(o._messageModule.getNetworkType()).setMessage("".concat(a,"-").concat(t,"-").concat(i)).end(),c})).catch((function(e){throw we.warn("".concat(o._className,".uploadMergerMessage failed. error:"),e),o._messageModule.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];s.setError(e,n,a).end()})),e}))}},{key:"downloadMergerMessage",value:function(e){var o=this;we.debug("".concat(this._className,".downloadMergerMessage message:"),e);var n=e.payload.downloadKey,a=new va(ya.DOWNLOAD_MERGER_MESSAGE);return a.setMessage("downloadKey:".concat(n)),this._messageModule.request({protocolName:jn,requestData:{downloadKey:n}}).then((function(n){if(we.debug("".concat(o._className,".downloadMergerMessage ok. response:"),n.data),ot(e.clearElement)){var s=e.payload,r=(s.downloadKey,s.pbDownloadKey,s.messageList,g(s,Qs));e.clearElement(),e.setElement({type:e.type,content:t({messageList:n.data.messageList},r)})}else{var i=[];n.data.messageList.forEach((function(e){if(!Vt(e)){var t=new Ga(e);i.push(t)}})),e.payload.messageList=i,e.payload.downloadKey="",e.payload.pbDownloadKey=""}return a.setNetworkType(o._messageModule.getNetworkType()).end(),e})).catch((function(e){throw we.warn("".concat(o._className,".downloadMergerMessage failed. key:").concat(n," error:"),e),o._messageModule.probeNetwork().then((function(t){var o=m(t,2),n=o[0],s=o[1];a.setError(e,n,s).end()})),e}))}},{key:"createMergerMessagePack",value:function(e,t,o){return e.conversationType===D.CONV_C2C?this._createC2CMergerMessagePack(e,t,o):this._createGroupMergerMessagePack(e,t,o)}},{key:"_createC2CMergerMessagePack",value:function(e,t,o){var n=null;t&&(t.offlinePushInfo&&(n=t.offlinePushInfo),!0===t.onlineUserOnly&&(n?n.disablePush=!0:n={disablePush:!0}));var a="";ze(e.cloudCustomData)&&e.cloudCustomData.length>0&&(a=e.cloudCustomData);var s=o.pbDownloadKey,r=o.downloadKey,i=o.messageNumber,c=e.payload,u=c.title,l=c.abstractList,d=c.compatibleText,p=this._messageModule.getModule(no);return{protocolName:Go,tjgID:this._messageModule.generateTjgID(e),requestData:{fromAccount:this._messageModule.getMyUserID(),toAccount:e.to,msgBody:[{msgType:e.type,msgContent:{pbDownloadKey:s,downloadKey:r,title:u,abstractList:l,compatibleText:d,messageNumber:i}}],cloudCustomData:a,msgSeq:e.sequence,msgRandom:e.random,msgLifeTime:p&&p.isOnlineMessage(e,t)?0:void 0,offlinePushInfo:n?{pushFlag:!0===n.disablePush?1:0,title:n.title||"",desc:n.description||"",ext:n.extension||"",apnsInfo:{badgeMode:!0===n.ignoreIOSBadge?1:0},androidInfo:{OPPOChannelID:n.androidOPPOChannelID||""}}:void 0}}}},{key:"_createGroupMergerMessagePack",value:function(e,t,o){var n=null;t&&t.offlinePushInfo&&(n=t.offlinePushInfo);var a="";ze(e.cloudCustomData)&&e.cloudCustomData.length>0&&(a=e.cloudCustomData);var s=o.pbDownloadKey,r=o.downloadKey,i=o.messageNumber,c=e.payload,u=c.title,l=c.abstractList,d=c.compatibleText,p=this._messageModule.getModule(ao);return{protocolName:Po,tjgID:this._messageModule.generateTjgID(e),requestData:{fromAccount:this._messageModule.getMyUserID(),groupID:e.to,msgBody:[{msgType:e.type,msgContent:{pbDownloadKey:s,downloadKey:r,title:u,abstractList:l,compatibleText:d,messageNumber:i}}],random:e.random,priority:e.priority,clientSequence:e.clientSequence,groupAtInfo:void 0,cloudCustomData:a,onlineOnlyFlag:p&&p.isOnlineMessage(e,t)?1:0,offlinePushInfo:n?{pushFlag:!0===n.disablePush?1:0,title:n.title||"",desc:n.description||"",ext:n.extension||"",apnsInfo:{badgeMode:!0===n.ignoreIOSBadge?1:0},androidInfo:{OPPOChannelID:n.androidOPPOChannelID||""}}:void 0,clientTime:e.clientTime,needReadReceipt:!0!==e.needReadReceipt||p.isMessageFromOrToAVChatroom(e.to)?0:1}}}}]),e}(),er={ERR_SVR_COMM_SENSITIVE_TEXT:80001,ERR_SVR_COMM_BODY_SIZE_LIMIT:80002,OPEN_SERVICE_OVERLOAD_ERROR:60022,ERR_SVR_MSG_PKG_PARSE_FAILED:20001,ERR_SVR_MSG_INTERNAL_AUTH_FAILED:20002,ERR_SVR_MSG_INVALID_ID:20003,ERR_SVR_MSG_PUSH_DENY:20006,ERR_SVR_MSG_IN_PEER_BLACKLIST:20007,ERR_SVR_MSG_BOTH_NOT_FRIEND:20009,ERR_SVR_MSG_NOT_PEER_FRIEND:20010,ERR_SVR_MSG_NOT_SELF_FRIEND:20011,ERR_SVR_MSG_SHUTUP_DENY:20012,ERR_SVR_GROUP_INVALID_PARAMETERS:10004,ERR_SVR_GROUP_PERMISSION_DENY:10007,ERR_SVR_GROUP_NOT_FOUND:10010,ERR_SVR_GROUP_INVALID_GROUPID:10015,ERR_SVR_GROUP_REJECT_FROM_THIRDPARTY:10016,ERR_SVR_GROUP_SHUTUP_DENY:10017,MESSAGE_SEND_FAIL:2100,OVER_FREQUENCY_LIMIT:2996},tr=[na.MESSAGE_ONPROGRESS_FUNCTION_ERROR,na.MESSAGE_IMAGE_SELECT_FILE_FIRST,na.MESSAGE_IMAGE_TYPES_LIMIT,na.MESSAGE_FILE_IS_EMPTY,na.MESSAGE_IMAGE_SIZE_LIMIT,na.MESSAGE_FILE_SELECT_FILE_FIRST,na.MESSAGE_FILE_SIZE_LIMIT,na.MESSAGE_VIDEO_SIZE_LIMIT,na.MESSAGE_VIDEO_TYPES_LIMIT,na.MESSAGE_AUDIO_UPLOAD_FAIL,na.MESSAGE_AUDIO_SIZE_LIMIT,na.COS_UNDETECTED];var or=function(e){i(o,e);var t=f(o);function o(e){var a;return n(this,o),(a=t.call(this,e))._className="MessageModule",a._messageOptionsMap=new Map,a._mergerMessageHandler=new Zs(_(a)),a}return s(o,[{key:"createTextMessage",value:function(e){var t=e.to,o=e.payload.atUserList,n=void 0===o?[]:o;if((Et({groupID:t})||Tt(t))&&n.includes(D.MSG_AT_ALL))return ja({code:na.MESSAGE_AT_TYPE_INVALID,message:aa.MESSAGE_AT_TYPE_INVALID});var a=this.getMyUserID();e.currentUser=a,e.senderTinyID=this.getMyTinyID();var s=new wa(e),r="string"==typeof e.payload?e.payload:e.payload.text,i=new Ia({text:r}),c=this._getNickAndAvatarByUserID(a);return s.setElement(i),s.setNickAndAvatar(c),s.setNameCard(this._getNameCardByGroupID(s)),s}},{key:"createImageMessage",value:function(e){var t=this.getMyUserID();e.currentUser=t,e.senderTinyID=this.getMyTinyID();var o=new wa(e);if(te){var n=e.payload.file;if(je(n))return void we.warn("小程序环境下调用 createImageMessage 接口时,payload.file 不支持传入 File 对象");var a=n.tempFilePaths[0],s={url:a,name:a.slice(a.lastIndexOf("/")+1),size:n.tempFiles&&n.tempFiles[0].size||1,type:a.slice(a.lastIndexOf(".")+1).toLowerCase()};e.payload.file=s}else if(oe)if(je(e.payload.file)){var r=e.payload.file;e.payload.file={files:[r]}}else if(Xe(e.payload.file)&&"undefined"!=typeof uni){var i=e.payload.file.tempFiles[0];e.payload.file={files:[i]}}var c=new Ea({imageFormat:be.UNKNOWN,uuid:this._generateUUID(),file:e.payload.file}),u=this._getNickAndAvatarByUserID(t);return o.setElement(c),o.setNickAndAvatar(u),o.setNameCard(this._getNameCardByGroupID(o)),this._messageOptionsMap.set(o.clientSequence,e),o}},{key:"createAudioMessage",value:function(e){if(te){var t=e.payload.file;if(te){var o={url:t.tempFilePath,name:t.tempFilePath.slice(t.tempFilePath.lastIndexOf("/")+1),size:t.fileSize,second:parseInt(t.duration)/1e3,type:t.tempFilePath.slice(t.tempFilePath.lastIndexOf(".")+1).toLowerCase()};e.payload.file=o}var n=this.getMyUserID();e.currentUser=n,e.senderTinyID=this.getMyTinyID();var a=new wa(e),s=new Ca({second:Math.floor(t.duration/1e3),size:t.fileSize,url:t.tempFilePath,uuid:this._generateUUID()}),r=this._getNickAndAvatarByUserID(n);return a.setElement(s),a.setNickAndAvatar(r),a.setNameCard(this._getNameCardByGroupID(a)),this._messageOptionsMap.set(a.clientSequence,e),a}we.warn("createAudioMessage 目前只支持小程序环境下发语音消息")}},{key:"createVideoMessage",value:function(e){var t=this.getMyUserID();e.currentUser=t,e.senderTinyID=this.getMyTinyID(),e.payload.file.thumbUrl="https://web.sdk.qcloud.com/im/assets/images/transparent.png",e.payload.file.thumbSize=1668;var o={};if(te){if(Q)return void we.warn("createVideoMessage 不支持在支付宝小程序环境下使用");if(je(e.payload.file))return void we.warn("小程序环境下调用 createVideoMessage 接口时,payload.file 不支持传入 File 对象");var n=e.payload.file;o.url=n.tempFilePath,o.name=n.tempFilePath.slice(n.tempFilePath.lastIndexOf("/")+1),o.size=n.size,o.second=n.duration,o.type=n.tempFilePath.slice(n.tempFilePath.lastIndexOf(".")+1).toLowerCase()}else if(oe){if(je(e.payload.file)){var a=e.payload.file;e.payload.file.files=[a]}else if(Xe(e.payload.file)&&"undefined"!=typeof uni){var s=e.payload.file.tempFile;e.payload.file.files=[s]}var r=e.payload.file;o.url=window.URL.createObjectURL(r.files[0]),o.name=r.files[0].name,o.size=r.files[0].size,o.second=r.files[0].duration||0,o.type=r.files[0].type.split("/")[1]}e.payload.file.videoFile=o;var i=new wa(e),c=new La({videoFormat:o.type,videoSecond:Pt(o.second,0),videoSize:o.size,remoteVideoUrl:"",videoUrl:o.url,videoUUID:this._generateUUID(),thumbUUID:this._generateUUID(),thumbWidth:e.payload.file.width||200,thumbHeight:e.payload.file.height||200,thumbUrl:e.payload.file.thumbUrl,thumbSize:e.payload.file.thumbSize,thumbFormat:e.payload.file.thumbUrl.slice(e.payload.file.thumbUrl.lastIndexOf(".")+1).toLowerCase()}),u=this._getNickAndAvatarByUserID(t);return i.setElement(c),i.setNickAndAvatar(u),i.setNameCard(this._getNameCardByGroupID(i)),this._messageOptionsMap.set(i.clientSequence,e),i}},{key:"createCustomMessage",value:function(e){var t=this.getMyUserID();e.currentUser=t,e.senderTinyID=this.getMyTinyID();var o=new wa(e),n=new Ra({data:e.payload.data,description:e.payload.description,extension:e.payload.extension}),a=this._getNickAndAvatarByUserID(t);return o.setElement(n),o.setNickAndAvatar(a),o.setNameCard(this._getNameCardByGroupID(o)),o}},{key:"createFaceMessage",value:function(e){var t=this.getMyUserID();e.currentUser=t,e.senderTinyID=this.getMyTinyID();var o=new wa(e),n=new Ta(e.payload),a=this._getNickAndAvatarByUserID(t);return o.setElement(n),o.setNickAndAvatar(a),o.setNameCard(this._getNameCardByGroupID(o)),o}},{key:"createMergerMessage",value:function(e){var t=this.getMyUserID();e.currentUser=t,e.senderTinyID=this.getMyTinyID();var o=this._getNickAndAvatarByUserID(t),n=new wa(e),a=new Pa(e.payload);return n.setElement(a),n.setNickAndAvatar(o),n.setNameCard(this._getNameCardByGroupID(n)),n.setRelayFlag(!0),n}},{key:"createForwardMessage",value:function(e){var t=e.to,o=e.conversationType,n=e.priority,a=e.payload,s=e.needReadReceipt,r=this.getMyUserID(),i=this._getNickAndAvatarByUserID(r);if(a.type===D.MSG_GRP_TIP)return ja(new Ba({code:na.MESSAGE_FORWARD_TYPE_INVALID,message:aa.MESSAGE_FORWARD_TYPE_INVALID}));var c={to:t,conversationType:o,conversationID:"".concat(o).concat(t),priority:n,isPlaceMessage:0,status:xt.UNSEND,currentUser:r,senderTinyID:this.getMyTinyID(),cloudCustomData:e.cloudCustomData||a.cloudCustomData||"",needReadReceipt:s},u=new wa(c);return u.setElement(a.getElements()[0]),u.setNickAndAvatar(i),u.setNameCard(this._getNameCardByGroupID(a)),u.setRelayFlag(!0),u}},{key:"downloadMergerMessage",value:function(e){return this._mergerMessageHandler.downloadMergerMessage(e)}},{key:"createFileMessage",value:function(e){if(!te||Z){if(oe||Z)if(je(e.payload.file)){var t=e.payload.file;e.payload.file={files:[t]}}else if(Xe(e.payload.file)&&"undefined"!=typeof uni){var o=e.payload.file,n=o.tempFiles,a=o.files,s=null;Qe(n)?s=n[0]:Qe(a)&&(s=a[0]),e.payload.file={files:[s]}}var r=this.getMyUserID();e.currentUser=r,e.senderTinyID=this.getMyTinyID();var i=new wa(e),c=new Oa({uuid:this._generateUUID(),file:e.payload.file}),u=this._getNickAndAvatarByUserID(r);return i.setElement(c),i.setNickAndAvatar(u),i.setNameCard(this._getNameCardByGroupID(i)),this._messageOptionsMap.set(i.clientSequence,e),i}we.warn("小程序目前不支持选择文件, createFileMessage 接口不可用!")}},{key:"createLocationMessage",value:function(e){var t=this.getMyUserID();e.currentUser=t,e.senderTinyID=this.getMyTinyID();var o=new wa(e),n=new ka(e.payload),a=this._getNickAndAvatarByUserID(t);return o.setElement(n),o.setNickAndAvatar(a),o.setNameCard(this._getNameCardByGroupID(o)),o}},{key:"_onCannotFindModule",value:function(){return ja({code:na.CANNOT_FIND_MODULE,message:aa.CANNOT_FIND_MODULE})}},{key:"sendMessageInstance",value:function(e,t){var o,n=this,a=null;switch(e.conversationType){case D.CONV_C2C:if(!(a=this.getModule(no)))return this._onCannotFindModule();break;case D.CONV_GROUP:if(!(a=this.getModule(ao)))return this._onCannotFindModule();if(Et({groupID:e.to})){var s=a.getLocalGroupProfile(e.to);if(s&&s.isSupportTopic)return ja({code:na.MESSAGE_SEND_GROUP_WITH_TOPIC_FAIL,message:aa.MESSAGE_SEND_GROUP_WITH_TOPIC_FAIL});if(!Ze(t)&&!Ze(t.messageControlInfo))return ja({code:na.MESSAGE_CONTROL_INFO_FAIL,message:aa.MESSAGE_CONTROL_INFO_FAIL})}break;default:return ja({code:na.MESSAGE_SEND_INVALID_CONVERSATION_TYPE,message:aa.MESSAGE_SEND_INVALID_CONVERSATION_TYPE})}var r=this.getModule(ho),i=this.getModule(ao);return r.upload(e).then((function(){n._getSendMessageSpecifiedKey(e)===la&&n.getModule(Co).addSuccessCount(da);return i.guardForAVChatRoom(e).then((function(){if(!e.isSendable())return ja({code:na.MESSAGE_FILE_URL_IS_EMPTY,message:aa.MESSAGE_FILE_URL_IS_EMPTY});n._addSendMessageTotalCount(e),o=Date.now();var s=function(e){var t="utf-8";oe&&document&&(t=document.charset.toLowerCase());var o,n,a=0;if(n=e.length,"utf-8"===t||"utf8"===t)for(var s=0;s7e3?n._mergerMessageHandler.uploadMergerMessage(e,s).then((function(o){var a=n._mergerMessageHandler.createMergerMessagePack(e,t,o);return n.request(a)})):(n.getModule(co).setMessageRandom(e),e.conversationType===D.CONV_C2C||e.conversationType===D.CONV_GROUP?a.sendMessage(e,t):void 0)})).then((function(s){var r=s.data,i=r.time,c=r.sequence,u=r.readReceiptCode;$e(u)&&0!==u&&(new va(ya.SEND_MESSAGE_WITH_RECEIPT).setMessage("from:".concat(e.from," to:").concat(e.to," sequence:").concat(c," readReceiptCode:").concat(u)).end(),we.warn("".concat(n._className,".sendMessageInstance readReceiptCode:").concat(u," message:").concat(Ha[u])));n._addSendMessageSuccessCount(e,o),n._messageOptionsMap.delete(e.clientSequence);var l=n.getModule(co);e.status=xt.SUCCESS,e.time=i;var d=!1;if(e.conversationType===D.CONV_GROUP)e.sequence=c;else if(e.conversationType===D.CONV_C2C){var p=l.getLatestMessageSentByMe(e.conversationID);if(p){var g=p.nick,_=p.avatar;g===e.nick&&_===e.avatar||(d=!0)}}if(l.appendToMessageList(e),d&&l.modifyMessageSentByMe({conversationID:e.conversationID,latestNick:e.nick,latestAvatar:e.avatar}),a.isOnlineMessage(e,t))e._onlineOnlyFlag=!0;else{var h=e;Xe(t)&&Xe(t.messageControlInfo)&&(!0===t.messageControlInfo.excludedFromLastMessage&&(e._isExcludedFromLastMessage=!0,h=""),!0===t.messageControlInfo.excludedFromUnreadCount&&(e._isExcludedFromUnreadCount=!0));var f=e.conversationType;if(Tt(e.to))f=D.CONV_TOPIC,n.getModule(io).onMessageSent({groupID:bt(e.to),topicID:e.to,lastMessage:h});l.onMessageSent({conversationOptionsList:[{conversationID:e.conversationID,unreadCount:0,type:f,subType:e.conversationSubType,lastMessage:h}]})}return e.getRelayFlag()||"TIMImageElem"!==e.type||kt(e.payload.imageInfoArray),ba({message:e})}))})).catch((function(t){return n._onSendMessageFailed(e,t)}))}},{key:"_onSendMessageFailed",value:function(e,t){e.status=xt.FAIL,this.getModule(co).deleteMessageRandom(e),this._addSendMessageFailCountOnUser(e,t);var o=new va(ya.SEND_MESSAGE);return o.setMessage("tjg_id:".concat(this.generateTjgID(e)," type:").concat(e.type," from:").concat(e.from," to:").concat(e.to)),this.probeNetwork().then((function(e){var n=m(e,2),a=n[0],s=n[1];o.setError(t,a,s).end()})),we.error("".concat(this._className,"._onSendMessageFailed error:"),t),ja(new Ba({code:t&&t.code?t.code:na.MESSAGE_SEND_FAIL,message:t&&t.message?t.message:aa.MESSAGE_SEND_FAIL,data:{message:e}}))}},{key:"_getSendMessageSpecifiedKey",value:function(e){if([D.MSG_IMAGE,D.MSG_AUDIO,D.MSG_VIDEO,D.MSG_FILE].includes(e.type))return la;if(e.conversationType===D.CONV_C2C)return ia;if(e.conversationType===D.CONV_GROUP){var t=this.getModule(ao).getLocalGroupProfile(e.to);if(!t)return;var o=t.type;return It(o)?ua:ca}}},{key:"_addSendMessageTotalCount",value:function(e){var t=this._getSendMessageSpecifiedKey(e);t&&this.getModule(Co).addTotalCount(t)}},{key:"_addSendMessageSuccessCount",value:function(e,t){var o=Math.abs(Date.now()-t),n=this._getSendMessageSpecifiedKey(e);if(n){var a=this.getModule(Co);a.addSuccessCount(n),a.addCost(n,o)}}},{key:"_addSendMessageFailCountOnUser",value:function(e,t){var o,n,a=t.code,s=void 0===a?-1:a,r=this.getModule(Co),i=this._getSendMessageSpecifiedKey(e);i===la&&(o=s,n=!1,tr.includes(o)&&(n=!0),n)?r.addFailedCountOfUserSide(da):function(e){var t=!1;return Object.values(er).includes(e)&&(t=!0),(e>=120001&&e<=13e4||e>=10100&&e<=10200)&&(t=!0),t}(s)&&i&&r.addFailedCountOfUserSide(i)}},{key:"resendMessage",value:function(e){return e.isResend=!0,e.status=xt.UNSEND,e.random=dt(),e.clientTime=ke(),e.generateMessageID(),this.sendMessageInstance(e)}},{key:"revokeMessage",value:function(e){var t=this,o=null;if(e.conversationType===D.CONV_C2C){if(!(o=this.getModule(no)))return this._onCannotFindModule()}else if(e.conversationType===D.CONV_GROUP&&!(o=this.getModule(ao)))return this._onCannotFindModule();var n=new va(ya.REVOKE_MESSAGE);return n.setMessage("tjg_id:".concat(this.generateTjgID(e)," type:").concat(e.type," from:").concat(e.from," to:").concat(e.to)),o.revokeMessage(e).then((function(o){var a=o.data.recallRetList;if(!Vt(a)&&0!==a[0].retCode){var s=new Ba({code:a[0].retCode,message:Ha[a[0].retCode]||aa.MESSAGE_REVOKE_FAIL,data:{message:e}});return n.setCode(s.code).setMoreMessage(s.message).end(),ja(s)}return we.info("".concat(t._className,".revokeMessage ok. ID:").concat(e.ID)),e.isRevoked=!0,n.end(),t.getModule(co).onMessageRevoked([e]),ba({message:e})})).catch((function(o){t.probeNetwork().then((function(e){var t=m(e,2),a=t[0],s=t[1];n.setError(o,a,s).end()}));var a=new Ba({code:o&&o.code?o.code:na.MESSAGE_REVOKE_FAIL,message:o&&o.message?o.message:aa.MESSAGE_REVOKE_FAIL,data:{message:e}});return we.warn("".concat(t._className,".revokeMessage failed. error:"),o),ja(a)}))}},{key:"deleteMessage",value:function(e){var t=this,o=null,n=e[0],a=n.conversationID,s="",r=[],i=[];if(n.conversationType===D.CONV_C2C)o=this.getModule(no),s=a.replace(D.CONV_C2C,""),e.forEach((function(e){e&&e.status===xt.SUCCESS&&e.conversationID===a&&(e._onlineOnlyFlag||r.push("".concat(e.sequence,"_").concat(e.random,"_").concat(e.time)),i.push(e))}));else if(n.conversationType===D.CONV_GROUP)o=this.getModule(ao),s=a.replace(D.CONV_GROUP,""),e.forEach((function(e){e&&e.status===xt.SUCCESS&&e.conversationID===a&&(e._onlineOnlyFlag||r.push("".concat(e.sequence)),i.push(e))}));else if(n.conversationType===D.CONV_SYSTEM)return ja({code:na.CANNOT_DELETE_GROUP_SYSTEM_NOTICE,message:aa.CANNOT_DELETE_GROUP_SYSTEM_NOTICE});if(!o)return this._onCannotFindModule();if(0===r.length)return this._onMessageDeleted(i);r.length>30&&(r=r.slice(0,30),i=i.slice(0,30));var c=new va(ya.DELETE_MESSAGE);return c.setMessage("to:".concat(s," count:").concat(r.length)),o.deleteMessage({to:s,keyList:r}).then((function(e){return c.end(),we.info("".concat(t._className,".deleteMessage ok")),t._onMessageDeleted(i)})).catch((function(e){t.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];c.setError(e,n,a).end()})),we.warn("".concat(t._className,".deleteMessage failed. error:"),e);var o=new Ba({code:e&&e.code?e.code:na.MESSAGE_DELETE_FAIL,message:e&&e.message?e.message:aa.MESSAGE_DELETE_FAIL});return ja(o)}))}},{key:"_onMessageDeleted",value:function(e){return this.getModule(co).onMessageDeleted(e),Ya({messageList:e})}},{key:"modifyRemoteMessage",value:function(e){var t=this,o=null,n=e.conversationType,a=e.to;if(this.getModule(ao).isMessageFromOrToAVChatroom(a))return ja({code:na.MESSAGE_MODIFY_DISABLED_IN_AVCHATROOM,message:aa.MESSAGE_MODIFY_DISABLED_IN_AVCHATROOM,data:{message:e}});n===D.CONV_C2C?o=this.getModule(no):n===D.CONV_GROUP&&(o=this.getModule(ao));var s=new va(ya.MODIFY_MESSAGE);return s.setMessage("to:".concat(a)),o.modifyRemoteMessage(e).then((function(o){s.end(),we.info("".concat(t._className,".modifyRemoteMessage ok"));var n=t._onModifyRemoteMessageResp(e,o.data);return ba({message:n})})).catch((function(o){if(s.setCode(o.code).setMoreMessage(o.message).end(),we.warn("".concat(t._className,".modifyRemoteMessage failed. error:"),o),20027===o.code){var n=t._onModifyRemoteMessageResp(e,o.data);return ja({code:na.MESSAGE_MODIFY_CONFLICT,message:aa.MESSAGE_MODIFY_CONFLICT,data:{message:n}})}return ja({code:o.code,message:o.message,data:{message:e}})}))}},{key:"_onModifyRemoteMessageResp",value:function(e,t){we.debug("".concat(this._className,"._onModifyRemoteMessageResp options:"),t);var o=e.conversationType,n=e.from,a=e.to,s=e.random,r=e.sequence,i=e.time,c=t.elements,u=t.messageVersion,l=t.cloudCustomData,d=void 0===l?"":l;return this.getModule(co).onMessageModified({conversationType:o,from:n,to:a,time:i,random:s,sequence:r,elements:c,cloudCustomData:d,messageVersion:u})}},{key:"_generateUUID",value:function(){var e=this.getModule(uo);return"".concat(e.getSDKAppID(),"-").concat(e.getUserID(),"-").concat(function(){for(var e="",t=32;t>0;--t)e+=pt[Math.floor(Math.random()*gt)];return e}())}},{key:"getMessageOption",value:function(e){return this._messageOptionsMap.get(e)}},{key:"_getNickAndAvatarByUserID",value:function(e){return this.getModule(oo).getNickAndAvatarByUserID(e)}},{key:"_getNameCardByGroupID",value:function(e){if(e.conversationType===D.CONV_GROUP){var t=this.getModule(ao);if(t)return t.getMyNameCardByGroupID(e.to)}return""}},{key:"reset",value:function(){we.log("".concat(this._className,".reset")),this._messageOptionsMap.clear()}}]),o}(Do),nr=function(e){i(o,e);var t=f(o);function o(e){var a;return n(this,o),(a=t.call(this,e))._className="PluginModule",a.plugins={},a}return s(o,[{key:"registerPlugin",value:function(e){var t=this;Object.keys(e).forEach((function(o){t.plugins[o]=e[o]})),new va(ya.REGISTER_PLUGIN).setMessage("key=".concat(Object.keys(e))).end()}},{key:"getPlugin",value:function(e){return this.plugins[e]}},{key:"reset",value:function(){we.log("".concat(this._className,".reset"))}}]),o}(Do),ar=function(e){i(o,e);var t=f(o);function o(e){var a;return n(this,o),(a=t.call(this,e))._className="SyncUnreadMessageModule",a._cookie="",a._onlineSyncFlag=!1,a.getInnerEmitterInstance().on(Ja,a._onLoginSuccess,_(a)),a}return s(o,[{key:"_onLoginSuccess",value:function(e){this._startSync({cookie:this._cookie,syncFlag:0,isOnlineSync:0})}},{key:"_startSync",value:function(e){var t=this,o=e.cookie,n=e.syncFlag,a=e.isOnlineSync;we.log("".concat(this._className,"._startSync cookie:").concat(o," syncFlag:").concat(n," isOnlineSync:").concat(a)),this.request({protocolName:Lo,requestData:{cookie:o,syncFlag:n,isOnlineSync:a}}).then((function(e){var o=e.data,n=o.cookie,a=o.syncFlag,s=o.eventArray,r=o.messageList,i=o.C2CRemainingUnreadList,c=o.C2CPairUnreadList;if(t._cookie=n,Vt(n));else if(0===a||1===a){if(s)t.getModule(Mo).onMessage({head:{},body:{eventArray:s,isInstantMessage:t._onlineSyncFlag,isSyncingEnded:!1}});t.getModule(no).onNewC2CMessage({dataList:r,isInstantMessage:!1,C2CRemainingUnreadList:i,C2CPairUnreadList:c}),t._startSync({cookie:n,syncFlag:a,isOnlineSync:0})}else if(2===a){if(s)t.getModule(Mo).onMessage({head:{},body:{eventArray:s,isInstantMessage:t._onlineSyncFlag,isSyncingEnded:!0}});t.getModule(no).onNewC2CMessage({dataList:r,isInstantMessage:t._onlineSyncFlag,C2CRemainingUnreadList:i,C2CPairUnreadList:c})}})).catch((function(e){we.error("".concat(t._className,"._startSync failed. error:"),e)}))}},{key:"startOnlineSync",value:function(){we.log("".concat(this._className,".startOnlineSync")),this._onlineSyncFlag=!0,this._startSync({cookie:this._cookie,syncFlag:0,isOnlineSync:1})}},{key:"startSyncOnReconnected",value:function(){we.log("".concat(this._className,".startSyncOnReconnected.")),this._onlineSyncFlag=!0,this._startSync({cookie:this._cookie,syncFlag:0,isOnlineSync:0})}},{key:"reset",value:function(){we.log("".concat(this._className,".reset")),this._onlineSyncFlag=!1,this._cookie=""}}]),o}(Do),sr={request:{toAccount:"To_Account",fromAccount:"From_Account",to:"To_Account",from:"From_Account",groupID:"GroupId",groupAtUserID:"GroupAt_Account",extension:"Ext",data:"Data",description:"Desc",elements:"MsgBody",sizeType:"Type",downloadFlag:"Download_Flag",thumbUUID:"ThumbUUID",videoUUID:"VideoUUID",remoteAudioUrl:"Url",remoteVideoUrl:"VideoUrl",videoUrl:"",imageUrl:"URL",fileUrl:"Url",uuid:"UUID",priority:"MsgPriority",receiverUserID:"To_Account",receiverGroupID:"GroupId",messageSender:"SenderId",messageReceiver:"ReceiverId",nick:"From_AccountNick",avatar:"From_AccountHeadurl",messageNumber:"MsgNum",pbDownloadKey:"PbMsgKey",downloadKey:"JsonMsgKey",applicationType:"PendencyType",userIDList:"To_Account",groupNameList:"GroupName",userID:"To_Account",groupAttributeList:"GroupAttr",mainSequence:"AttrMainSeq",avChatRoomKey:"BytesKey",attributeControl:"AttrControl",sequence:"seq",messageControlInfo:"SendMsgControl",updateSequence:"UpdateSeq",clientTime:"MsgClientTime",sequenceList:"MsgSeqList",topicID:"TopicId",customData:"CustomString",isSupportTopic:"SupportTopic"},response:{MsgPriority:"priority",ThumbUUID:"thumbUUID",VideoUUID:"videoUUID",Download_Flag:"downloadFlag",GroupId:"groupID",Member_Account:"userID",MsgList:"messageList",SyncFlag:"syncFlag",To_Account:"to",From_Account:"from",MsgSeq:"sequence",MsgRandom:"random",MsgTime:"time",MsgTimeStamp:"time",MsgContent:"content",MsgBody:"elements",From_AccountNick:"nick",From_AccountHeadurl:"avatar",GroupWithdrawInfoArray:"revokedInfos",GroupReadInfoArray:"groupMessageReadNotice",LastReadMsgSeq:"lastMessageSeq",WithdrawC2cMsgNotify:"c2cMessageRevokedNotify",C2cWithdrawInfoArray:"revokedInfos",C2cReadedReceipt:"c2cMessageReadReceipt",ReadC2cMsgNotify:"c2cMessageReadNotice",LastReadTime:"peerReadTime",MsgRand:"random",MsgType:"type",MsgShow:"messageShow",NextMsgSeq:"nextMessageSeq",FaceUrl:"avatar",ProfileDataMod:"profileModify",Profile_Account:"userID",ValueBytes:"value",ValueNum:"value",NoticeSeq:"noticeSequence",NotifySeq:"notifySequence",MsgFrom_AccountExtraInfo:"messageFromAccountExtraInformation",Operator_Account:"operatorID",OpType:"operationType",ReportType:"operationType",UserId:"userID",User_Account:"userID",List_Account:"userIDList",MsgOperatorMemberExtraInfo:"operatorInfo",MsgMemberExtraInfo:"memberInfoList",ImageUrl:"avatar",NickName:"nick",MsgGroupNewInfo:"newGroupProfile",MsgAppDefinedData:"groupCustomField",Owner_Account:"ownerID",GroupFaceUrl:"avatar",GroupIntroduction:"introduction",GroupNotification:"notification",GroupApplyJoinOption:"joinOption",MsgKey:"messageKey",GroupInfo:"groupProfile",ShutupTime:"muteTime",Desc:"description",Ext:"extension",GroupAt_Account:"groupAtUserID",MsgNum:"messageNumber",PbMsgKey:"pbDownloadKey",JsonMsgKey:"downloadKey",MsgModifiedFlag:"isModified",PendencyItem:"applicationItem",PendencyType:"applicationType",AddTime:"time",AddSource:"source",AddWording:"wording",ProfileImImage:"avatar",PendencyAdd:"friendApplicationAdded",FrienPencydDel_Account:"friendApplicationDeletedUserIDList",Peer_Account:"userID",GroupAttr:"groupAttributeList",GroupAttrAry:"groupAttributeList",AttrMainSeq:"mainSequence",seq:"sequence",GroupAttrOption:"groupAttributeOption",BytesChangedKeys:"changedKeyList",GroupAttrInfo:"groupAttributeList",GroupAttrSeq:"mainSequence",PushChangedAttrValFlag:"hasChangedAttributeInfo",SubKeySeq:"sequence",Val:"value",MsgGroupFromCardName:"senderNameCard",MsgGroupFromNickName:"senderNick",C2cNick:"peerNick",C2cImage:"peerAvatar",SendMsgControl:"messageControlInfo",NoLastMsg:"excludedFromLastMessage",NoUnread:"excludedFromUnreadCount",UpdateSeq:"updateSequence",MuteNotifications:"muteFlag",MsgClientTime:"clientTime",TinyId:"tinyID",GroupMsgReceiptList:"readReceiptList",ReadNum:"readCount",UnreadNum:"unreadCount",TopicId:"topicID",MillionGroupFlag:"communityType",SupportTopic:"isSupportTopic",MsgTopicNewInfo:"newTopicInfo",ShutupAll:"muteAllMembers",CustomString:"customData",TopicFaceUrl:"avatar",TopicIntroduction:"introduction",TopicNotification:"notification",TopicIdArray:"topicIDList",MsgVersion:"messageVersion",C2cMsgModNotifys:"c2cMessageModified",GroupMsgModNotifys:"groupMessageModified"},ignoreKeyWord:["C2C","ID","USP"]};function rr(e,t){if("string"!=typeof e&&!Array.isArray(e))throw new TypeError("Expected the input to be `string | string[]`");t=Object.assign({pascalCase:!1},t);var o;return 0===(e=Array.isArray(e)?e.map((function(e){return e.trim()})).filter((function(e){return e.length})).join("-"):e.trim()).length?"":1===e.length?t.pascalCase?e.toUpperCase():e.toLowerCase():(e!==e.toLowerCase()&&(e=ir(e)),e=e.replace(/^[_.\- ]+/,"").toLowerCase().replace(/[_.\- ]+(\w|$)/g,(function(e,t){return t.toUpperCase()})).replace(/\d+(\w|$)/g,(function(e){return e.toUpperCase()})),o=e,t.pascalCase?o.charAt(0).toUpperCase()+o.slice(1):o)}var ir=function(e){for(var t=!1,o=!1,n=!1,a=0;a100)return o--,t;if(Qe(t)){var a=t.map((function(t){return Je(t)?e(t,n):t}));return o--,a}if(Je(t)){var s=(r=t,i=function(e,t){if(!st(t))return!1;if((a=t)!==rr(a))for(var o=0;o65535)return lr(240|t>>>18,128|t>>>12&63,128|t>>>6&63,128|63&t)}else t=65533}else t<=57343&&(t=65533);return t<=2047?lr(192|t>>>6,128|63&t):lr(224|t>>>12,128|t>>>6&63,128|63&t)},pr=function(e){for(var t=void 0===e?"":(""+e).replace(/[\x80-\uD7ff\uDC00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]?/g,dr),o=0|t.length,n=new Uint8Array(o),a=0;a0)for(var c=0;c=s&&(we.log("".concat(e._className,"._checkPromiseMap request timeout, delete requestID:").concat(o)),e._promiseMap.delete(o),n(new Ba({code:na.NETWORK_TIMEOUT,message:aa.NETWORK_TIMEOUT})),e._channelModule.onRequestTimeout(o))}))}},{key:"onOpen",value:function(e){if(""!==this._readyState){this._onOpenTs=Date.now();var t=e.id;this._socketID=t;var o=Date.now()-this._startTs;we.log("".concat(this._className,"._onOpen cost ").concat(o," ms. socketID:").concat(t)),new va(ya.WS_ON_OPEN).setMessage(o).setCostTime(o).setMoreMessage("socketID:".concat(t)).end(),e.id===this._socketID&&(this._readyState=vr,this._reConnectCount=0,this._resend(),!0===this._reConnectFlag&&(this._channelModule.onReconnected(),this._reConnectFlag=!1),this._channelModule.onOpen())}}},{key:"onClose",value:function(e){var t=new va(ya.WS_ON_CLOSE),o=e.id,n=e.e,a="sourceSocketID:".concat(o," currentSocketID:").concat(this._socketID," code:").concat(n.code," reason:").concat(n.reason),s=0;0!==this._onOpenTs&&(s=Date.now()-this._onOpenTs),t.setMessage(s).setCostTime(s).setMoreMessage(a).setCode(n.code).end(),we.log("".concat(this._className,"._onClose ").concat(a," onlineTime:").concat(s)),o===this._socketID&&(this._readyState=Ir,s<1e3?this._channelModule.onReconnectFailed():this._channelModule.onClose())}},{key:"onError",value:function(e){var t=e.id,o=e.e,n="sourceSocketID:".concat(t," currentSocketID:").concat(this._socketID);new va(ya.WS_ON_ERROR).setMessage(o.errMsg||ut(o)).setMoreMessage(n).setLevel("error").end(),we.warn("".concat(this._className,"._onError"),o,n),t===this._socketID&&(this._readyState="",this._channelModule.onError())}},{key:"onMessage",value:function(e){var t;try{t=JSON.parse(e.data)}catch(u){new va(ya.JSON_PARSE_ERROR).setMessage(e.data).end()}if(t&&t.head){var o=this._getRequestIDFromHead(t.head),n=Gt(t.head),a=ur(t.body,this._getResponseKeyMap(n));if(we.debug("".concat(this._className,".onMessage ret:").concat(JSON.stringify(a)," requestID:").concat(o," has:").concat(this._promiseMap.has(o))),this._setNextPingTs(),this._promiseMap.has(o)){var s=this._promiseMap.get(o),r=s.resolve,i=s.reject,c=s.timestamp;return this._promiseMap.delete(o),this._calcRTT(c),void(a.errorCode&&0!==a.errorCode?(this._channelModule.onErrorCodeNotZero(a),i(new Ba({code:a.errorCode,message:a.errorInfo||"",data:{elements:a.elements,messageVersion:a.messageVersion,cloudCustomData:a.cloudCustomData}}))):r(ba(a)))}this._channelModule.onMessage({head:t.head,body:a})}}},{key:"_calcRTT",value:function(e){var t=Date.now()-e;this._channelModule.getModule(Co).addRTT(t)}},{key:"_connect",value:function(){this._startTs=Date.now(),this._onOpenTs=0,this._socket=new _r(this),this._socketID=this._socket.getID(),this._readyState=yr,we.log("".concat(this._className,"._connect isWorkerEnabled:").concat(this.getIsWorkerEnabled()," socketID:").concat(this._socketID," url:").concat(this.getURL())),new va(ya.WS_CONNECT).setMessage("socketID:".concat(this._socketID," url:").concat(this.getURL())).end()}},{key:"getURL",value:function(){var e=this._channelModule.getModule(uo);e.isDevMode()&&(this._canIUseBinaryFrame=!1);var t=Rt();(Q||$&&"windows"===t||Z)&&(this._canIUseBinaryFrame=!1);var o=-1;"ios"===t?o=de||-1:"android"===t&&(o=ge||-1);var n=this._channelModule.getPlatform(),a=e.getSDKAppID(),s=e.getInstanceID();return this._canIUseBinaryFrame?"".concat(this._url,"/binfo?sdkappid=").concat(a,"&instanceid=").concat(s,"&random=").concat(this._getRandom(),"&platform=").concat(n,"&host=").concat(t,"&version=").concat(o):"".concat(this._url,"/info?sdkappid=").concat(a,"&instanceid=").concat(s,"&random=").concat(this._getRandom(),"&platform=").concat(n,"&host=").concat(t,"&version=").concat(o)}},{key:"_closeConnection",value:function(e){we.log("".concat(this._className,"._closeConnection socketID:").concat(this._socketID)),this._socket&&(this._socket.close(e),this._socketID=-1,this._socket=null,this._readyState=Ir)}},{key:"_resend",value:function(){var e=this;if(we.log("".concat(this._className,"._resend reConnectFlag:").concat(this._reConnectFlag),"promiseMap.size:".concat(this._promiseMap.size," simpleRequestMap.size:").concat(this._simpleRequestMap.size)),this._promiseMap.size>0&&this._promiseMap.forEach((function(t,o){var n=t.uplinkData,a=t.resolve,s=t.reject;e._promiseMap.set(o,{resolve:a,reject:s,timestamp:Date.now(),uplinkData:n}),e._execute(o,n)})),this._simpleRequestMap.size>0){var t,o=C(this._simpleRequestMap);try{for(o.s();!(t=o.n()).done;){var n=m(t.value,2),a=n[0],s=n[1];this._execute(a,s)}}catch(r){o.e(r)}finally{o.f()}this._simpleRequestMap.clear()}}},{key:"send",value:function(e){var t=this;e.head.seq=this._getSequence(),e.head.reqtime=Math.floor(Date.now()/1e3);e.keyMap;var o=g(e,mr),n=this._getRequestIDFromHead(e.head),a=JSON.stringify(o);return new Promise((function(e,s){(t._promiseMap.set(n,{resolve:e,reject:s,timestamp:Date.now(),uplinkData:a}),we.debug("".concat(t._className,".send uplinkData:").concat(JSON.stringify(o)," requestID:").concat(n," readyState:").concat(t._readyState)),t._readyState!==vr)?t._reConnect():(t._execute(n,a),t._channelModule.getModule(Co).addRequestCount())}))}},{key:"simplySend",value:function(e){e.head.seq=this._getSequence(),e.head.reqtime=Math.floor(Date.now()/1e3);e.keyMap;var t=g(e,Mr),o=this._getRequestIDFromHead(e.head),n=JSON.stringify(t);this._readyState!==vr?(this._simpleRequestMap.size0&&(clearInterval(this._timerForNotLoggedIn),this._timerForNotLoggedIn=-1),this._socketHandler.onCheckTimer(e)):this._socketHandler.onCheckTimer(1),this._checkNextPing())}},{key:"onErrorCodeNotZero",value:function(e){this.getModule(Mo).onErrorCodeNotZero(e)}},{key:"onMessage",value:function(e){this.getModule(Mo).onMessage(e)}},{key:"send",value:function(e){return this._socketHandler?this._previousState!==D.NET_STATE_CONNECTED&&e.head.servcmd.includes(Vn)?(this.reConnect(),this._sendLogViaHTTP(e)):this._socketHandler.send(e):Promise.reject()}},{key:"_sendLogViaHTTP",value:function(e){var t=H.HOST.CURRENT.STAT;return new Promise((function(o,n){var a="".concat(t,"/v4/imopenstat/tim_web_report_v2?sdkappid=").concat(e.head.sdkappid,"&reqtime=").concat(Date.now()),s=JSON.stringify(e.body),r="application/x-www-form-urlencoded;charset=UTF-8";if(te)ne.request({url:a,data:s,method:"POST",timeout:3e3,header:{"content-type":r},success:function(){o()},fail:function(){n(new Ba({code:na.NETWORK_ERROR,message:aa.NETWORK_ERROR}))}});else{var i=new XMLHttpRequest,c=setTimeout((function(){i.abort(),n(new Ba({code:na.NETWORK_TIMEOUT,message:aa.NETWORK_TIMEOUT}))}),3e3);i.onreadystatechange=function(){4===i.readyState&&(clearTimeout(c),200===i.status||304===i.status?o():n(new Ba({code:na.NETWORK_ERROR,message:aa.NETWORK_ERROR})))},i.open("POST",a,!0),i.setRequestHeader("Content-type",r),i.send(s)}}))}},{key:"simplySend",value:function(e){return this._socketHandler?this._socketHandler.simplySend(e):Promise.reject()}},{key:"onOpen",value:function(){this._ping()}},{key:"onClose",value:function(){this._socketHandler&&(this._socketHandler.getReconnectFlag()&&this._emitNetStateChangeEvent(D.NET_STATE_DISCONNECTED));this.reConnect()}},{key:"onError",value:function(){te&&!Z&&we.error("".concat(this._className,".onError 从v2.11.2起,SDK 支持了 WebSocket,如您未添加相关受信域名,请先添加!(如已添加请忽略),升级指引: https://web.sdk.qcloud.com/im/doc/zh-cn/tutorial-02-upgradeguideline.html")),this._emitNetStateChangeEvent(D.NET_STATE_DISCONNECTED)}},{key:"getKeyMap",value:function(e){return this.getModule(Mo).getKeyMap(e)}},{key:"_onAppHide",value:function(){this._isAppShowing=!1}},{key:"_onAppShow",value:function(){this._isAppShowing=!0}},{key:"onRequestTimeout",value:function(e){}},{key:"onReconnected",value:function(){we.log("".concat(this._className,".onReconnected")),this.getModule(Mo).onReconnected(),this._emitNetStateChangeEvent(D.NET_STATE_CONNECTED)}},{key:"onReconnectFailed",value:function(){we.log("".concat(this._className,".onReconnectFailed")),this._emitNetStateChangeEvent(D.NET_STATE_DISCONNECTED)}},{key:"setIsWorkerEnabled",value:function(e){this._socketHandler&&this._socketHandler.setIsWorkerEnabled(!1)}},{key:"offline",value:function(){this._emitNetStateChangeEvent(D.NET_STATE_DISCONNECTED)}},{key:"reConnect",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=!1;this._socketHandler&&(t=this._socketHandler.getReconnectFlag());var o="forcedFlag:".concat(e," fatalErrorFlag:").concat(this._fatalErrorFlag," previousState:").concat(this._previousState," reconnectFlag:").concat(t);if(we.log("".concat(this._className,".reConnect ").concat(o)),!this._fatalErrorFlag&&this._socketHandler){if(!0===e)this._socketHandler.forcedReconnect();else{if(this._previousState===D.NET_STATE_CONNECTING&&t)return;this._socketHandler.forcedReconnect()}this._emitNetStateChangeEvent(D.NET_STATE_CONNECTING)}}},{key:"_emitNetStateChangeEvent",value:function(e){this._previousState!==e&&(we.log("".concat(this._className,"._emitNetStateChangeEvent from ").concat(this._previousState," to ").concat(e)),this._previousState=e,this.emitOuterEvent(S.NET_STATE_CHANGE,{state:e}))}},{key:"_ping",value:function(){var e=this;if(!0!==this._probing){this._probing=!0;var t=this.getModule(Mo).getProtocolData({protocolName:Kn});this.send(t).then((function(){e._probing=!1})).catch((function(t){if(we.warn("".concat(e._className,"._ping failed. error:"),t),e._probing=!1,t&&60002===t.code)return new va(ya.ERROR).setMessage("code:".concat(t.code," message:").concat(t.message)).setNetworkType(e.getModule(go).getNetworkType()).end(),e._fatalErrorFlag=!0,void e._emitNetStateChangeEvent(D.NET_STATE_DISCONNECTED);e.probeNetwork().then((function(t){var o=m(t,2),n=o[0],a=o[1];we.log("".concat(e._className,"._ping failed. probe network, isAppShowing:").concat(e._isAppShowing," online:").concat(n," networkType:").concat(a)),n?e.reConnect():e._emitNetStateChangeEvent(D.NET_STATE_DISCONNECTED)}))}))}}},{key:"_checkNextPing",value:function(){this._socketHandler&&(this._socketHandler.isConnected()&&Date.now()>=this._socketHandler.getNextPingTs()&&this._ping())}},{key:"dealloc",value:function(){this._socketHandler&&(this._socketHandler.close(),this._socketHandler=null),this._timerForNotLoggedIn>-1&&clearInterval(this._timerForNotLoggedIn)}},{key:"onRestApiKickedOut",value:function(){this._socketHandler&&(this._socketHandler.close(),this.reConnect(!0))}},{key:"reset",value:function(){we.log("".concat(this._className,".reset")),this._previousState=D.NET_STATE_CONNECTED,this._probing=!1,this._fatalErrorFlag=!1,this._timerForNotLoggedIn=setInterval(this.onCheckTimer.bind(this),1e3)}}]),o}(Do),Cr=["a2","tinyid"],Sr=["a2","tinyid"],Dr=function(){function e(t){n(this,e),this._className="ProtocolHandler",this._sessionModule=t,this._configMap=new Map,this._fillConfigMap()}return s(e,[{key:"_fillConfigMap",value:function(){this._configMap.clear();var e=this._sessionModule.genCommonHead(),o=this._sessionModule.genCosSpecifiedHead(),n=this._sessionModule.genSSOReportHead();this._configMap.set(No,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.IM_OPEN_STATUS,".").concat(H.CMD.LOGIN)}),body:{state:"Online"},keyMap:{response:{InstId:"instanceID",HelloInterval:"helloInterval"}}}}(e)),this._configMap.set(Ao,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.IM_OPEN_STATUS,".").concat(H.CMD.LOGOUT)}),body:{type:0},keyMap:{request:{type:"wslogout_type"}}}}(e)),this._configMap.set(Oo,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.IM_OPEN_STATUS,".").concat(H.CMD.HELLO)}),body:{},keyMap:{response:{NewInstInfo:"newInstanceInfo"}}}}(e)),this._configMap.set(Ro,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.STAT_SERVICE,".").concat(H.CMD.KICK_OTHER)}),body:{}}}(e)),this._configMap.set(bn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.IM_COS_SIGN,".").concat(H.CMD.COS_SIGN)}),body:{cmd:"open_im_cos_svc",subCmd:"get_cos_token",duration:300,version:2},keyMap:{request:{userSig:"usersig",subCmd:"sub_cmd",cmd:"cmd",duration:"duration",version:"version"},response:{expired_time:"expiredTime",bucket_name:"bucketName",session_token:"sessionToken",tmp_secret_id:"secretId",tmp_secret_key:"secretKey"}}}}(o)),this._configMap.set(Fn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.CUSTOM_UPLOAD,".").concat(H.CMD.COS_PRE_SIG)}),body:{fileType:void 0,fileName:void 0,uploadMethod:0,duration:900},keyMap:{request:{userSig:"usersig",fileType:"file_type",fileName:"file_name",uploadMethod:"upload_method"},response:{expired_time:"expiredTime",request_id:"requestId",head_url:"headUrl",upload_url:"uploadUrl",download_url:"downloadUrl",ci_url:"ciUrl",snapshot_url:"requestSnapshotUrl"}}}}(o)),this._configMap.set(qn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.CUSTOM_UPLOAD,".").concat(H.CMD.VIDEO_COVER)}),body:{version:1,platform:void 0,coverName:void 0,requestSnapshotUrl:void 0},keyMap:{request:{version:"version",platform:"platform",coverName:"cover_name",requestSnapshotUrl:"snapshot_url"},response:{error_code:"errorCode",error_msg:"errorInfo",download_url:"snapshotUrl"}}}}(o)),this._configMap.set(Jn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.IM_CONFIG_MANAGER,".").concat(H.CMD.FETCH_COMMERCIAL_CONFIG)}),body:{SDKAppID:0},keyMap:{request:{SDKAppID:"uint32_sdkappid"},response:{int32_error_code:"errorCode",str_error_message:"errorMessage",str_purchase_bits:"purchaseBits",uint32_expired_time:"expiredTime"}}}}(e)),this._configMap.set(Xn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.IM_CONFIG_MANAGER,".").concat(H.CMD.PUSHED_COMMERCIAL_CONFIG)}),body:{},keyMap:{response:{int32_error_code:"errorCode",str_error_message:"errorMessage",str_purchase_bits:"purchaseBits",uint32_expired_time:"expiredTime"}}}}(e)),this._configMap.set($n,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.IM_CONFIG_MANAGER,".").concat(H.CMD.FETCH_CLOUD_CONTROL_CONFIG)}),body:{SDKAppID:0,version:0},keyMap:{request:{SDKAppID:"uint32_sdkappid",version:"uint64_version"},response:{int32_error_code:"errorCode",str_error_message:"errorMessage",str_json_config:"cloudControlConfig",uint32_expired_time:"expiredTime",uint32_sdkappid:"SDKAppID",uint64_version:"version"}}}}(e)),this._configMap.set(zn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.IM_CONFIG_MANAGER,".").concat(H.CMD.PUSHED_CLOUD_CONTROL_CONFIG)}),body:{},keyMap:{response:{int32_error_code:"errorCode",str_error_message:"errorMessage",str_json_config:"cloudControlConfig",uint32_expired_time:"expiredTime",uint32_sdkappid:"SDKAppID",uint64_version:"version"}}}}(e)),this._configMap.set(Qn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.OVERLOAD_PUSH,".").concat(H.CMD.OVERLOAD_NOTIFY)}),body:{},keyMap:{response:{OverLoadServCmd:"overloadCommand",DelaySecs:"waitingTime"}}}}(e)),this._configMap.set(Lo,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.OPEN_IM,".").concat(H.CMD.GET_MESSAGES)}),body:{cookie:"",syncFlag:0,needAbstract:1,isOnlineSync:0},keyMap:{request:{fromAccount:"From_Account",toAccount:"To_Account",from:"From_Account",to:"To_Account",time:"MsgTimeStamp",sequence:"MsgSeq",random:"MsgRandom",elements:"MsgBody"},response:{MsgList:"messageList",SyncFlag:"syncFlag",To_Account:"to",From_Account:"from",ClientSeq:"clientSequence",MsgSeq:"sequence",NoticeSeq:"noticeSequence",NotifySeq:"notifySequence",MsgRandom:"random",MsgTimeStamp:"time",MsgContent:"content",ToGroupId:"groupID",MsgKey:"messageKey",GroupTips:"groupTips",MsgBody:"elements",MsgType:"type",C2CRemainingUnreadCount:"C2CRemainingUnreadList",C2CPairUnreadCount:"C2CPairUnreadList"}}}}(e)),this._configMap.set(ko,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.OPEN_IM,".").concat(H.CMD.BIG_DATA_HALLWAY_AUTH_KEY)}),body:{}}}(e)),this._configMap.set(Go,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.OPEN_IM,".").concat(H.CMD.SEND_MESSAGE)}),body:{fromAccount:"",toAccount:"",msgSeq:0,msgRandom:0,msgBody:[],cloudCustomData:void 0,nick:"",avatar:"",msgLifeTime:void 0,offlinePushInfo:{pushFlag:0,title:"",desc:"",ext:"",apnsInfo:{badgeMode:0},androidInfo:{OPPOChannelID:""}},messageControlInfo:void 0,clientTime:void 0,needReadReceipt:0},keyMap:{request:{fromAccount:"From_Account",toAccount:"To_Account",msgTimeStamp:"MsgTimeStamp",msgSeq:"MsgSeq",msgRandom:"MsgRandom",msgBody:"MsgBody",count:"MaxCnt",lastMessageTime:"LastMsgTime",messageKey:"MsgKey",peerAccount:"Peer_Account",data:"Data",description:"Desc",extension:"Ext",type:"MsgType",content:"MsgContent",sizeType:"Type",uuid:"UUID",url:"",imageUrl:"URL",fileUrl:"Url",remoteAudioUrl:"Url",remoteVideoUrl:"VideoUrl",thumbUUID:"ThumbUUID",videoUUID:"VideoUUID",videoUrl:"",downloadFlag:"Download_Flag",nick:"From_AccountNick",avatar:"From_AccountHeadurl",from:"From_Account",time:"MsgTimeStamp",messageRandom:"MsgRandom",messageSequence:"MsgSeq",elements:"MsgBody",clientSequence:"ClientSeq",payload:"MsgContent",messageList:"MsgList",messageNumber:"MsgNum",abstractList:"AbstractList",messageBody:"MsgBody",needReadReceipt:"IsNeedReadReceipt"}}}}(e)),this._configMap.set(Po,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.SEND_GROUP_MESSAGE)}),body:{fromAccount:"",groupID:"",random:0,clientSequence:0,priority:"",msgBody:[],cloudCustomData:void 0,onlineOnlyFlag:0,offlinePushInfo:{pushFlag:0,title:"",desc:"",ext:"",apnsInfo:{badgeMode:0},androidInfo:{OPPOChannelID:""}},groupAtInfo:[],messageControlInfo:void 0,clientTime:void 0,needReadReceipt:0,topicID:void 0},keyMap:{request:{to:"GroupId",extension:"Ext",data:"Data",description:"Desc",random:"Random",sequence:"ReqMsgSeq",count:"ReqMsgNumber",type:"MsgType",priority:"MsgPriority",content:"MsgContent",elements:"MsgBody",sizeType:"Type",uuid:"UUID",url:"",imageUrl:"URL",fileUrl:"Url",remoteAudioUrl:"Url",remoteVideoUrl:"VideoUrl",thumbUUID:"ThumbUUID",videoUUID:"VideoUUID",videoUrl:"",downloadFlag:"Download_Flag",clientSequence:"ClientSeq",from:"From_Account",time:"MsgTimeStamp",messageRandom:"MsgRandom",messageSequence:"MsgSeq",payload:"MsgContent",messageList:"MsgList",messageNumber:"MsgNum",abstractList:"AbstractList",messageBody:"MsgBody",needReadReceipt:"NeedReadReceipt"},response:{MsgTime:"time",MsgSeq:"sequence"}}}}(e)),this._configMap.set(Vo,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.OPEN_IM,".").concat(H.CMD.REVOKE_C2C_MESSAGE)}),body:{msgInfo:{fromAccount:"",toAccount:"",msgTimeStamp:0,msgSeq:0,msgRandom:0}},keyMap:{request:{msgInfo:"MsgInfo",msgTimeStamp:"MsgTimeStamp",msgSeq:"MsgSeq",msgRandom:"MsgRandom"}}}}(e)),this._configMap.set(pn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.REVOKE_GROUP_MESSAGE)}),body:{groupID:"",msgSeqList:void 0,topicID:""},keyMap:{request:{msgSeqList:"MsgSeqList",msgSeq:"MsgSeq"}}}}(e)),this._configMap.set(xo,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.OPEN_IM,".").concat(H.CMD.GET_C2C_ROAM_MESSAGES)}),body:{peerAccount:"",count:15,lastMessageTime:0,messageKey:"",withRecalledMessage:1,direction:0},keyMap:{request:{messageKey:"MsgKey",peerAccount:"Peer_Account",count:"MaxCnt",lastMessageTime:"LastMsgTime",withRecalledMessage:"WithRecalledMsg",direction:"GetDirection"},response:{LastMsgTime:"lastMessageTime",IsNeedReadReceipt:"needReadReceipt"}}}}(e)),this._configMap.set(jo,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.OPEN_IM,".").concat(H.CMD.MODIFY_C2C_MESSAGE)}),body:{from:"",to:"",sequence:0,random:0,time:0,version:0,elements:void 0,cloudCustomData:void 0},keyMap:{request:{sequence:"MsgSeq",random:"MsgRandom",time:"MsgTime",version:"MsgVersion",type:"MsgType",content:"MsgContent"}}}}(e)),this._configMap.set(hn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.GET_GROUP_ROAM_MESSAGES)}),body:{withRecalledMsg:1,groupID:"",count:15,sequence:"",topicID:void 0},keyMap:{request:{sequence:"ReqMsgSeq",count:"ReqMsgNumber",withRecalledMessage:"WithRecalledMsg"},response:{Random:"random",MsgTime:"time",MsgSeq:"sequence",ReqMsgSeq:"sequence",RspMsgList:"messageList",IsPlaceMsg:"isPlaceMessage",IsSystemMsg:"isSystemMessage",ToGroupId:"to",EnumFrom_AccountType:"fromAccountType",EnumTo_AccountType:"toAccountType",GroupCode:"groupCode",MsgPriority:"priority",MsgBody:"elements",MsgType:"type",MsgContent:"content",IsFinished:"complete",Download_Flag:"downloadFlag",ClientSeq:"clientSequence",ThumbUUID:"thumbUUID",VideoUUID:"videoUUID",ToTopicId:"topicID"}}}}(e)),this._configMap.set(Ko,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.OPEN_IM,".").concat(H.CMD.SET_C2C_MESSAGE_READ)}),body:{C2CMsgReaded:void 0},keyMap:{request:{lastMessageTime:"LastedMsgTime"}}}}(e)),this._configMap.set(Ho,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.OPEN_IM,".").concat(H.CMD.SET_C2C_PEER_MUTE_NOTIFICATIONS)}),body:{userIDList:void 0,muteFlag:0},keyMap:{request:{userIDList:"Peer_Account",muteFlag:"Mute_Notifications"}}}}(e)),this._configMap.set(Bo,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.OPEN_IM,".").concat(H.CMD.GET_C2C_PEER_MUTE_NOTIFICATIONS)}),body:{updateSequence:0},keyMap:{response:{MuteNotificationsList:"muteFlagList"}}}}(e)),this._configMap.set(gn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.SET_GROUP_MESSAGE_READ)}),body:{groupID:void 0,messageReadSeq:void 0,topicID:void 0},keyMap:{request:{messageReadSeq:"MsgReadedSeq"}}}}(e)),this._configMap.set(_n,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.OPEN_IM,".").concat(H.CMD.SET_ALL_MESSAGE_READ)}),body:{readAllC2CMessage:0,groupMessageReadInfoList:[]},keyMap:{request:{readAllC2CMessage:"C2CReadAllMsg",groupMessageReadInfoList:"GroupReadInfo",messageSequence:"MsgSeq"},response:{C2CReadAllMsg:"readAllC2CMessage",GroupReadInfoArray:"groupMessageReadInfoList"}}}}(e)),this._configMap.set(Yo,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.OPEN_IM,".").concat(H.CMD.DELETE_C2C_MESSAGE)}),body:{fromAccount:"",to:"",keyList:void 0},keyMap:{request:{keyList:"MsgKeyList"}}}}(e)),this._configMap.set(Sn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.DELETE_GROUP_MESSAGE)}),body:{groupID:"",deleter:"",keyList:void 0,topicID:void 0},keyMap:{request:{deleter:"Deleter_Account",keyList:"Seqs"}}}}(e)),this._configMap.set(Dn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.OPEN_IM,".").concat(H.CMD.MODIFY_GROUP_MESSAGE)}),body:{groupID:"",topicID:void 0,sequence:0,version:0,elements:void 0,cloudCustomData:void 0},keyMap:{request:{sequence:"MsgSeq",version:"MsgVersion",type:"MsgType",content:"MsgContent"}}}}(e)),this._configMap.set(fn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.GET_READ_RECEIPT)}),body:{groupID:"",sequenceList:void 0},keyMap:{request:{sequence:"MsgSeq"}}}}(e)),this._configMap.set(Mn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.OPEN_IM,".").concat(H.CMD.SEND_C2C_READ_RECEIPT)}),body:{peerAccount:"",messageInfoList:void 0},keyMap:{request:{peerAccount:"Peer_Account",messageInfoList:"C2CMsgInfo",fromAccount:"From_Account",toAccount:"To_Account",sequence:"MsgSeq",random:"MsgRandom",time:"MsgTime",clientTime:"MsgClientTime"}}}}(e)),this._configMap.set(mn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.SEND_READ_RECEIPT)}),body:{groupID:"",sequenceList:void 0},keyMap:{request:{sequenceList:"MsgSeqList",sequence:"MsgSeq"}}}}(e)),this._configMap.set(vn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.GET_READ_RECEIPT_DETAIL)}),body:{groupID:"",sequence:void 0,flag:0,cursor:0,count:0},keyMap:{request:{sequence:"MsgSeq",count:"Num"},response:{ReadList:"readUserIDList",Read_Account:"userID",UnreadList:"unreadUserIDList",Unread_Account:"userID",IsFinish:"isCompleted"}}}}(e)),this._configMap.set(Wo,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.OPEN_IM,".").concat(H.CMD.GET_PEER_READ_TIME)}),body:{userIDList:void 0},keyMap:{request:{userIDList:"To_Account"},response:{ReadTime:"peerReadTimeList"}}}}(e)),this._configMap.set(zo,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.RECENT_CONTACT,".").concat(H.CMD.GET_CONVERSATION_LIST)}),body:{fromAccount:void 0,count:0},keyMap:{request:{},response:{SessionItem:"conversations",ToAccount:"groupID",To_Account:"userID",UnreadMsgCount:"unreadCount",MsgGroupReadedSeq:"messageReadSeq",C2cPeerReadTime:"c2cPeerReadTime"}}}}(e)),this._configMap.set($o,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.RECENT_CONTACT,".").concat(H.CMD.PAGING_GET_CONVERSATION_LIST)}),body:{fromAccount:void 0,timeStamp:void 0,startIndex:void 0,pinnedTimeStamp:void 0,pinnedStartIndex:void 0,orderType:void 0,messageAssistFlag:4,assistFlag:15},keyMap:{request:{messageAssistFlag:"MsgAssistFlags",assistFlag:"AssistFlags",pinnedTimeStamp:"TopTimeStamp",pinnedStartIndex:"TopStartIndex"},response:{SessionItem:"conversations",ToAccount:"groupID",To_Account:"userID",UnreadMsgCount:"unreadCount",MsgGroupReadedSeq:"messageReadSeq",C2cPeerReadTime:"c2cPeerReadTime",LastMsgFlags:"lastMessageFlag",TopFlags:"isPinned",TopTimeStamp:"pinnedTimeStamp",TopStartIndex:"pinnedStartIndex"}}}}(e)),this._configMap.set(Jo,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.RECENT_CONTACT,".").concat(H.CMD.DELETE_CONVERSATION)}),body:{fromAccount:"",toAccount:void 0,type:1,toGroupID:void 0,clearHistoryMessage:1},keyMap:{request:{toGroupID:"ToGroupid",clearHistoryMessage:"ClearRamble"}}}}(e)),this._configMap.set(Xo,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.RECENT_CONTACT,".").concat(H.CMD.PIN_CONVERSATION)}),body:{fromAccount:"",operationType:1,itemList:void 0},keyMap:{request:{itemList:"RecentContactItem"}}}}(e)),this._configMap.set(Qo,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.OPEN_IM,".").concat(H.CMD.DELETE_GROUP_AT_TIPS)}),body:{messageListToDelete:void 0},keyMap:{request:{messageListToDelete:"DelMsgList",messageSeq:"MsgSeq",messageRandom:"MsgRandom"}}}}(e)),this._configMap.set(Uo,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.PROFILE,".").concat(H.CMD.PORTRAIT_GET)}),body:{fromAccount:"",userItem:[]},keyMap:{request:{toAccount:"To_Account",standardSequence:"StandardSequence",customSequence:"CustomSequence"}}}}(e)),this._configMap.set(wo,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.PROFILE,".").concat(H.CMD.PORTRAIT_SET)}),body:{fromAccount:"",profileItem:[{tag:Fe.NICK,value:""},{tag:Fe.GENDER,value:""},{tag:Fe.ALLOWTYPE,value:""},{tag:Fe.AVATAR,value:""}]},keyMap:{request:{toAccount:"To_Account",standardSequence:"StandardSequence",customSequence:"CustomSequence"}}}}(e)),this._configMap.set(bo,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.FRIEND,".").concat(H.CMD.GET_BLACKLIST)}),body:{fromAccount:"",startIndex:0,maxLimited:30,lastSequence:0},keyMap:{response:{CurruentSequence:"currentSequence"}}}}(e)),this._configMap.set(Fo,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.FRIEND,".").concat(H.CMD.ADD_BLACKLIST)}),body:{fromAccount:"",toAccount:[]}}}(e)),this._configMap.set(qo,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.FRIEND,".").concat(H.CMD.DELETE_BLACKLIST)}),body:{fromAccount:"",toAccount:[]}}}(e)),this._configMap.set(Zo,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.GET_JOINED_GROUPS)}),body:{memberAccount:"",limit:void 0,offset:void 0,groupType:void 0,responseFilter:{groupBaseInfoFilter:void 0,selfInfoFilter:void 0},isSupportTopic:0},keyMap:{request:{memberAccount:"Member_Account"},response:{GroupIdList:"groups",MsgFlag:"messageRemindType",NoUnreadSeqList:"excludedUnreadSequenceList",MsgSeq:"readedSequence"}}}}(e)),this._configMap.set(en,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.GET_GROUP_INFO)}),body:{groupIDList:void 0,responseFilter:{groupBaseInfoFilter:["Type","Name","Introduction","Notification","FaceUrl","Owner_Account","CreateTime","InfoSeq","LastInfoTime","LastMsgTime","MemberNum","MaxMemberNum","ApplyJoinOption","NextMsgSeq","ShutUpAllMember"],groupCustomFieldFilter:void 0,memberInfoFilter:void 0,memberCustomFieldFilter:void 0}},keyMap:{request:{groupIDList:"GroupIdList",groupCustomField:"AppDefinedData",memberCustomField:"AppMemberDefinedData",groupCustomFieldFilter:"AppDefinedDataFilter_Group",memberCustomFieldFilter:"AppDefinedDataFilter_GroupMember"},response:{GroupIdList:"groups",MsgFlag:"messageRemindType",AppDefinedData:"groupCustomField",AppMemberDefinedData:"memberCustomField",AppDefinedDataFilter_Group:"groupCustomFieldFilter",AppDefinedDataFilter_GroupMember:"memberCustomFieldFilter",InfoSeq:"infoSequence",MemberList:"members",GroupInfo:"groups",ShutUpUntil:"muteUntil",ShutUpAllMember:"muteAllMembers",ApplyJoinOption:"joinOption"}}}}(e)),this._configMap.set(tn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.CREATE_GROUP)}),body:{type:void 0,name:void 0,groupID:void 0,ownerID:void 0,introduction:void 0,notification:void 0,maxMemberNum:void 0,joinOption:void 0,memberList:void 0,groupCustomField:void 0,memberCustomField:void 0,webPushFlag:1,avatar:"",isSupportTopic:void 0},keyMap:{request:{ownerID:"Owner_Account",userID:"Member_Account",avatar:"FaceUrl",maxMemberNum:"MaxMemberCount",joinOption:"ApplyJoinOption",groupCustomField:"AppDefinedData",memberCustomField:"AppMemberDefinedData"},response:{HugeGroupFlag:"avChatRoomFlag",OverJoinedGroupLimit_Account:"overLimitUserIDList"}}}}(e)),this._configMap.set(on,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.DESTROY_GROUP)}),body:{groupID:void 0}}}(e)),this._configMap.set(nn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.MODIFY_GROUP_INFO)}),body:{groupID:void 0,name:void 0,introduction:void 0,notification:void 0,avatar:void 0,maxMemberNum:void 0,joinOption:void 0,groupCustomField:void 0,muteAllMembers:void 0},keyMap:{request:{maxMemberNum:"MaxMemberCount",groupCustomField:"AppDefinedData",muteAllMembers:"ShutUpAllMember",joinOption:"ApplyJoinOption",avatar:"FaceUrl"},response:{AppDefinedData:"groupCustomField",ShutUpAllMember:"muteAllMembers",ApplyJoinOption:"joinOption"}}}}(e)),this._configMap.set(an,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.APPLY_JOIN_GROUP)}),body:{groupID:void 0,applyMessage:void 0,userDefinedField:void 0,webPushFlag:1,historyMessageFlag:void 0},keyMap:{request:{applyMessage:"ApplyMsg",historyMessageFlag:"HugeGroupHistoryMsgFlag"},response:{HugeGroupFlag:"avChatRoomFlag",AVChatRoomKey:"avChatRoomKey",RspMsgList:"messageList",ToGroupId:"to"}}}}(e)),this._configMap.set(sn,function(e){e.a2,e.tinyid;return{head:t(t({},g(e,Cr)),{},{servcmd:"".concat(H.NAME.BIG_GROUP_NO_AUTH,".").concat(H.CMD.APPLY_JOIN_GROUP)}),body:{groupID:void 0,applyMessage:void 0,userDefinedField:void 0,webPushFlag:1},keyMap:{request:{applyMessage:"ApplyMsg"},response:{HugeGroupFlag:"avChatRoomFlag"}}}}(e)),this._configMap.set(rn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.QUIT_GROUP)}),body:{groupID:void 0}}}(e)),this._configMap.set(cn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.SEARCH_GROUP_BY_ID)}),body:{groupIDList:void 0,responseFilter:{groupBasePublicInfoFilter:["Type","Name","Introduction","Notification","FaceUrl","CreateTime","Owner_Account","LastInfoTime","LastMsgTime","NextMsgSeq","MemberNum","MaxMemberNum","ApplyJoinOption"]}},keyMap:{response:{ApplyJoinOption:"joinOption"}}}}(e)),this._configMap.set(un,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.CHANGE_GROUP_OWNER)}),body:{groupID:void 0,newOwnerID:void 0},keyMap:{request:{newOwnerID:"NewOwner_Account"}}}}(e)),this._configMap.set(ln,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.HANDLE_APPLY_JOIN_GROUP)}),body:{groupID:void 0,applicant:void 0,handleAction:void 0,handleMessage:void 0,authentication:void 0,messageKey:void 0,userDefinedField:void 0},keyMap:{request:{applicant:"Applicant_Account",handleAction:"HandleMsg",handleMessage:"ApprovalMsg",messageKey:"MsgKey"}}}}(e)),this._configMap.set(dn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.HANDLE_GROUP_INVITATION)}),body:{groupID:void 0,inviter:void 0,handleAction:void 0,handleMessage:void 0,authentication:void 0,messageKey:void 0,userDefinedField:void 0},keyMap:{request:{inviter:"Inviter_Account",handleAction:"HandleMsg",handleMessage:"ApprovalMsg",messageKey:"MsgKey"}}}}(e)),this._configMap.set(yn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.GET_GROUP_APPLICATION)}),body:{startTime:void 0,limit:void 0,handleAccount:void 0},keyMap:{request:{handleAccount:"Handle_Account"}}}}(e)),this._configMap.set(In,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.OPEN_IM,".").concat(H.CMD.DELETE_GROUP_SYSTEM_MESSAGE)}),body:{messageListToDelete:void 0},keyMap:{request:{messageListToDelete:"DelMsgList",messageSeq:"MsgSeq",messageRandom:"MsgRandom"}}}}(e)),this._configMap.set(En,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.BIG_GROUP_LONG_POLLING,".").concat(H.CMD.AVCHATROOM_LONG_POLL)}),body:{USP:1,startSeq:1,holdTime:90,key:void 0},keyMap:{request:{USP:"USP"},response:{ToGroupId:"groupID"}}}}(e)),this._configMap.set(Tn,function(e){e.a2,e.tinyid;return{head:t(t({},g(e,Sr)),{},{servcmd:"".concat(H.NAME.BIG_GROUP_LONG_POLLING_NO_AUTH,".").concat(H.CMD.AVCHATROOM_LONG_POLL)}),body:{USP:1,startSeq:1,holdTime:90,key:void 0},keyMap:{request:{USP:"USP"},response:{ToGroupId:"groupID"}}}}(e)),this._configMap.set(Cn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.GET_ONLINE_MEMBER_NUM)}),body:{groupID:void 0}}}(e)),this._configMap.set(Nn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.SET_GROUP_ATTRIBUTES)}),body:{groupID:void 0,groupAttributeList:void 0,mainSequence:void 0,avChatRoomKey:void 0,attributeControl:["RaceConflict"]},keyMap:{request:{key:"key",value:"value"}}}}(e)),this._configMap.set(An,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.MODIFY_GROUP_ATTRIBUTES)}),body:{groupID:void 0,groupAttributeList:void 0,mainSequence:void 0,avChatRoomKey:void 0,attributeControl:["RaceConflict"]},keyMap:{request:{key:"key",value:"value"}}}}(e)),this._configMap.set(On,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.DELETE_GROUP_ATTRIBUTES)}),body:{groupID:void 0,groupAttributeList:void 0,mainSequence:void 0,avChatRoomKey:void 0,attributeControl:["RaceConflict"]},keyMap:{request:{key:"key"}}}}(e)),this._configMap.set(Rn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.CLEAR_GROUP_ATTRIBUTES)}),body:{groupID:void 0,mainSequence:void 0,avChatRoomKey:void 0,attributeControl:["RaceConflict"]}}}(e)),this._configMap.set(Ln,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP_ATTR,".").concat(H.CMD.GET_GROUP_ATTRIBUTES)}),body:{groupID:void 0,avChatRoomKey:void 0,groupType:1},keyMap:{request:{avChatRoomKey:"Key",groupType:"GroupType"}}}}(e)),this._configMap.set(Zn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP_COMMUNITY,".").concat(H.CMD.CREATE_TOPIC)}),body:{groupID:void 0,topicName:void 0,avatar:void 0,customData:void 0,topicID:void 0,notification:void 0,introduction:void 0},keyMap:{request:{avatar:"FaceUrl"}}}}(e)),this._configMap.set(ea,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP_COMMUNITY,".").concat(H.CMD.DELETE_TOPIC)}),body:{groupID:void 0,topicIDList:void 0},keyMap:{request:{topicIDList:"TopicIdList"},response:{DestroyResultItem:"resultList",ErrorCode:"code",ErrorInfo:"message"}}}}(e)),this._configMap.set(ta,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP_COMMUNITY,".").concat(H.CMD.UPDATE_TOPIC_PROFILE)}),body:{groupID:void 0,topicID:void 0,avatar:void 0,customData:void 0,notification:void 0,introduction:void 0,muteAllMembers:void 0,topicName:void 0},keyMap:{request:{avatar:"FaceUrl",muteAllMembers:"ShutUpAllMember"}}}}(e)),this._configMap.set(oa,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP_COMMUNITY,".").concat(H.CMD.GET_TOPIC_LIST)}),body:{groupID:void 0,topicIDList:void 0},keyMap:{request:{topicIDList:"TopicIdList"},response:{TopicAndSelfInfo:"topicInfoList",TopicInfo:"topic",GroupID:"groupID",ShutUpTime:"muteTime",ShutUpAllFlag:"muteAllMembers",LastMsgTime:"lastMessageTime",MsgSeq:"readedSequence",MsgFlag:"messageRemindType",ErrorCode:"code",ErrorInfo:"message"}}}}(e)),this._configMap.set(kn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.GET_GROUP_MEMBER_LIST)}),body:{groupID:void 0,limit:0,offset:void 0,next:void 0,memberRoleFilter:void 0,memberInfoFilter:["Role","NameCard","ShutUpUntil","JoinTime"],memberCustomFieldFilter:void 0},keyMap:{request:{memberCustomFieldFilter:"AppDefinedDataFilter_GroupMember"},response:{AppMemberDefinedData:"memberCustomField",AppDefinedDataFilter_GroupMember:"memberCustomFieldFilter",MemberList:"members",ShutUpUntil:"muteUntil"}}}}(e)),this._configMap.set(Gn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.GET_GROUP_MEMBER_INFO)}),body:{groupID:void 0,userIDList:void 0,memberInfoFilter:void 0,memberCustomFieldFilter:void 0},keyMap:{request:{userIDList:"Member_List_Account",memberCustomFieldFilter:"AppDefinedDataFilter_GroupMember"},response:{MemberList:"members",ShutUpUntil:"muteUntil",AppDefinedDataFilter_GroupMember:"memberCustomFieldFilter",AppMemberDefinedData:"memberCustomField"}}}}(e)),this._configMap.set(Pn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.ADD_GROUP_MEMBER)}),body:{groupID:void 0,silence:void 0,userIDList:void 0},keyMap:{request:{userID:"Member_Account",userIDList:"MemberList"},response:{MemberList:"members"}}}}(e)),this._configMap.set(Un,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.DELETE_GROUP_MEMBER)}),body:{groupID:void 0,userIDList:void 0,reason:void 0},keyMap:{request:{userIDList:"MemberToDel_Account"}}}}(e)),this._configMap.set(wn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.GROUP,".").concat(H.CMD.MODIFY_GROUP_MEMBER_INFO)}),body:{groupID:void 0,topicID:void 0,userID:void 0,messageRemindType:void 0,nameCard:void 0,role:void 0,memberCustomField:void 0,muteTime:void 0},keyMap:{request:{userID:"Member_Account",memberCustomField:"AppMemberDefinedData",muteTime:"ShutUpTime",messageRemindType:"MsgFlag"}}}}(e)),this._configMap.set(Vn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.IM_OPEN_STAT,".").concat(H.CMD.TIM_WEB_REPORT_V2)}),body:{header:{},event:[],quality:[]},keyMap:{request:{SDKType:"sdk_type",SDKVersion:"sdk_version",deviceType:"device_type",platform:"platform",instanceID:"instance_id",traceID:"trace_id",SDKAppID:"sdk_app_id",userID:"user_id",tinyID:"tiny_id",extension:"extension",timestamp:"timestamp",networkType:"network_type",eventType:"event_type",code:"error_code",message:"error_message",moreMessage:"more_message",duplicate:"duplicate",costTime:"cost_time",level:"level",qualityType:"quality_type",reportIndex:"report_index",wholePeriod:"whole_period",totalCount:"total_count",rttCount:"success_count_business",successRateOfRequest:"percent_business",countLessThan1Second:"success_count_business",percentOfCountLessThan1Second:"percent_business",countLessThan3Second:"success_count_platform",percentOfCountLessThan3Second:"percent_platform",successCountOfBusiness:"success_count_business",successRateOfBusiness:"percent_business",successCountOfPlatform:"success_count_platform",successRateOfPlatform:"percent_platform",successCountOfMessageReceived:"success_count_business",successRateOfMessageReceived:"percent_business",avgRTT:"average_value",avgDelay:"average_value",avgValue:"average_value",uiPlatform:"ui_platform"}}}}(n)),this._configMap.set(Kn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.HEARTBEAT,".").concat(H.CMD.ALIVE)}),body:{}}}(e)),this._configMap.set(Hn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.IM_OPEN_PUSH,".").concat(H.CMD.MESSAGE_PUSH)}),body:{},keyMap:{response:{C2cMsgArray:"C2CMessageArray",GroupMsgArray:"groupMessageArray",GroupTips:"groupTips",C2cNotifyMsgArray:"C2CNotifyMessageArray",C2cMsgInfo:"C2CReadReceiptArray",ClientSeq:"clientSequence",MsgPriority:"priority",NoticeSeq:"noticeSequence",MsgContent:"content",MsgType:"type",MsgBody:"elements",ToGroupId:"to",Desc:"description",Ext:"extension",IsSyncMsg:"isSyncMessage",Flag:"needSync",NeedAck:"needAck",PendencyAdd_Account:"userID",ProfileImNick:"nick",PendencyType:"applicationType",C2CReadAllMsg:"readAllC2CMessage",IsNeedReadReceipt:"needReadReceipt"}}}}(e)),this._configMap.set(Bn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.IM_OPEN_PUSH,".").concat(H.CMD.MULTI_MESSAGE_PUSH)}),body:{},keyMap:{response:{GroupMsgArray:"groupMessageArray",GroupTips:"groupTips",ClientSeq:"clientSequence",MsgPriority:"priority",NoticeSeq:"noticeSequence",MsgContent:"content",MsgType:"type",MsgBody:"elements",ToGroupId:"to",Desc:"description",Ext:"extension",IsSyncMsg:"isSyncMessage",Flag:"needSync",NeedAck:"needAck",PendencyType:"applicationType"}}}}(e)),this._configMap.set(xn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.OPEN_IM,".").concat(H.CMD.MESSAGE_PUSH_ACK)}),body:{sessionData:void 0},keyMap:{request:{sessionData:"SessionData"}}}}(e)),this._configMap.set(Wn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.IM_OPEN_STATUS,".").concat(H.CMD.STATUS_FORCE_OFFLINE)}),body:{},keyMap:{response:{C2cNotifyMsgArray:"C2CNotifyMessageArray",NoticeSeq:"noticeSequence",KickoutMsgNotify:"kickoutMsgNotify",NewInstInfo:"newInstanceInfo"}}}}(e)),this._configMap.set(jn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.IM_LONG_MESSAGE,".").concat(H.CMD.DOWNLOAD_MERGER_MESSAGE)}),body:{downloadKey:""},keyMap:{response:{Data:"data",Desc:"description",Ext:"extension",Download_Flag:"downloadFlag",ThumbUUID:"thumbUUID",VideoUUID:"videoUUID"}}}}(e)),this._configMap.set(Yn,function(e){return{head:t(t({},e),{},{servcmd:"".concat(H.NAME.IM_LONG_MESSAGE,".").concat(H.CMD.UPLOAD_MERGER_MESSAGE)}),body:{messageList:[]},keyMap:{request:{fromAccount:"From_Account",toAccount:"To_Account",msgTimeStamp:"MsgTimeStamp",msgSeq:"MsgSeq",msgRandom:"MsgRandom",msgBody:"MsgBody",type:"MsgType",content:"MsgContent",data:"Data",description:"Desc",extension:"Ext",sizeType:"Type",uuid:"UUID",url:"",imageUrl:"URL",fileUrl:"Url",remoteAudioUrl:"Url",remoteVideoUrl:"VideoUrl",thumbUUID:"ThumbUUID",videoUUID:"VideoUUID",videoUrl:"",downloadFlag:"Download_Flag",from:"From_Account",time:"MsgTimeStamp",messageRandom:"MsgRandom",messageSequence:"MsgSeq",elements:"MsgBody",clientSequence:"ClientSeq",payload:"MsgContent",messageList:"MsgList",messageNumber:"MsgNum",abstractList:"AbstractList",messageBody:"MsgBody"}}}}(e))}},{key:"has",value:function(e){return this._configMap.has(e)}},{key:"get",value:function(e){return this._configMap.get(e)}},{key:"update",value:function(){this._fillConfigMap()}},{key:"getKeyMap",value:function(e){return this.has(e)?this.get(e).keyMap||{}:(we.warn("".concat(this._className,".getKeyMap unknown protocolName:").concat(e)),{})}},{key:"getProtocolData",value:function(e){var t=e.protocolName,o=e.requestData,n=this.get(t),a=null;if(o){var s=this._simpleDeepCopy(n),r=this._updateService(o,s),i=r.body,c=Object.create(null);for(var u in i)if(Object.prototype.hasOwnProperty.call(i,u)){if(c[u]=i[u],void 0===o[u])continue;c[u]=o[u]}r.body=c,a=this._getUplinkData(r)}else a=this._getUplinkData(n);return a}},{key:"_getUplinkData",value:function(e){var t=this._requestDataCleaner(e),o=Gt(t.head),n=cr(t.body,this._getRequestKeyMap(o));return t.body=n,t}},{key:"_updateService",value:function(e,t){var o=Gt(t.head);if(t.head.servcmd.includes(H.NAME.GROUP)){var n=e.type,a=e.groupID,s=void 0===a?void 0:a,r=e.groupIDList,i=void 0===r?[]:r;Ze(s)&&(s=i[0]||""),Et({type:n,groupID:s})&&(t.head.servcmd="".concat(H.NAME.GROUP_COMMUNITY,".").concat(o))}return t}},{key:"_getRequestKeyMap",value:function(e){var o=this.getKeyMap(e);return t(t({},sr.request),o.request)}},{key:"_requestDataCleaner",value:function(e){var t=Array.isArray(e)?[]:Object.create(null);for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&st(n)&&null!==e[n]&&void 0!==e[n]&&("object"!==o(e[n])?t[n]=e[n]:t[n]=this._requestDataCleaner.bind(this)(e[n]));return t}},{key:"_simpleDeepCopy",value:function(e){for(var t,o=Object.keys(e),n={},a=0,s=o.length;a1e3*a)return this._commandRequestInfoMap.set(t,{startTime:Date.now(),requestCount:1}),!1;i+=1,this._commandRequestInfoMap.set(t,{startTime:r,requestCount:i});var c=!1;return i>n&&(c=!0),c}},{key:"_isServerOverload",value:function(e){if(!this._serverOverloadInfoMap.has(e))return!1;var t=this._serverOverloadInfoMap.get(e),o=t.overloadTime,n=t.waitingTime,a=!1;return Date.now()-o<=1e3*n?a=!0:(this._serverOverloadInfoMap.delete(e),a=!1),a}},{key:"onPushedServerOverload",value:function(e){var t=e.overloadCommand,o=e.waitingTime;this._serverOverloadInfoMap.set(t,{overloadTime:Date.now(),waitingTime:o}),we.warn("".concat(this._className,".onPushedServerOverload waitingTime:").concat(o,"s"))}},{key:"reset",value:function(){we.log("".concat(this._className,".reset")),this._updateCommandFrequencyLimitMap(Or),this._commandRequestInfoMap.clear(),this._serverOverloadInfoMap.clear()}}]),o}(Do),Lr=function(e){i(o,e);var t=f(o);function o(e){var a;return n(this,o),(a=t.call(this,e))._className="MessageLossDetectionModule",a._maybeLostSequencesMap=new Map,a._firstRoundRet=[],a}return s(o,[{key:"onMessageMaybeLost",value:function(e,t,o){this._maybeLostSequencesMap.has(e)||this._maybeLostSequencesMap.set(e,[]);for(var n=this._maybeLostSequencesMap.get(e),a=0;a=this._expiredTime}},{key:"fetchConfig",value:function(){var e=this,t=this._canFetchConfig();if(we.log("".concat(this._className,".fetchConfig canFetchConfig:").concat(t)),t){var o=new va(ya.FETCH_CLOUD_CONTROL_CONFIG),n=this.getModule(uo).getSDKAppID();this._isFetching=!0,this.request({protocolName:$n,requestData:{SDKAppID:n,version:this._version}}).then((function(t){e._isFetching=!1,o.setMessage("version:".concat(e._version," newVersion:").concat(t.data.version," config:").concat(t.data.cloudControlConfig)).setNetworkType(e.getNetworkType()).end(),we.log("".concat(e._className,".fetchConfig ok")),e._parseCloudControlConfig(t.data)})).catch((function(t){e._isFetching=!1,e.probeNetwork().then((function(e){var n=m(e,2),a=n[0],s=n[1];o.setError(t,a,s).end()})),we.log("".concat(e._className,".fetchConfig failed. error:"),t),e._setExpiredTimeOnResponseError(12e4)}))}}},{key:"onPushedCloudControlConfig",value:function(e){we.log("".concat(this._className,".onPushedCloudControlConfig")),new va(ya.PUSHED_CLOUD_CONTROL_CONFIG).setNetworkType(this.getNetworkType()).setMessage("newVersion:".concat(e.version," config:").concat(e.cloudControlConfig)).end(),this._parseCloudControlConfig(e)}},{key:"onCheckTimer",value:function(e){this._canFetchConfig()&&this.fetchConfig()}},{key:"_parseCloudControlConfig",value:function(e){var t=this,o="".concat(this._className,"._parseCloudControlConfig"),n=e.errorCode,a=e.errorMessage,s=e.cloudControlConfig,r=e.version,i=e.expiredTime;if(0===n){if(this._version!==r){var c=null;try{c=JSON.parse(s)}catch(u){we.error("".concat(o," JSON parse error:").concat(s))}c&&(this._cloudConfig.clear(),Object.keys(c).forEach((function(e){t._cloudConfig.set(e,c[e])})),this._version=r,this.emitInnerEvent(Xa))}this._expiredTime=Date.now()+1e3*i}else Ze(n)?(we.log("".concat(o," failed. Invalid message format:"),e),this._setExpiredTimeOnResponseError(36e5)):(we.error("".concat(o," errorCode:").concat(n," errorMessage:").concat(a)),this._setExpiredTimeOnResponseError(12e4))}},{key:"_setExpiredTimeOnResponseError",value:function(e){this._expiredTime=Date.now()+e}},{key:"reset",value:function(){we.log("".concat(this._className,".reset")),this._cloudConfig.clear(),this._expiredTime=0,this._version=0,this._isFetching=!1}}]),o}(Do),Gr=function(e){i(o,e);var t=f(o);function o(e){var a;return n(this,o),(a=t.call(this,e))._className="PullGroupMessageModule",a._remoteLastMessageSequenceMap=new Map,a.PULL_LIMIT_COUNT=15,a}return s(o,[{key:"startPull",value:function(){var e=this,t=this._getNeedPullConversationList();this._getRemoteLastMessageSequenceList().then((function(){var o=e.getModule(co);t.forEach((function(t){var n=t.conversationID,a=n.replace(D.CONV_GROUP,""),s=o.getGroupLocalLastMessageSequence(n),r=e._remoteLastMessageSequenceMap.get(a)||0,i=r-s;we.log("".concat(e._className,".startPull groupID:").concat(a," localLastMessageSequence:").concat(s," ")+"remoteLastMessageSequence:".concat(r," diff:").concat(i)),s>0&&i>=1&&i<300&&e._pullMissingMessage({groupID:a,localLastMessageSequence:s,remoteLastMessageSequence:r,diff:i})}))}))}},{key:"_getNeedPullConversationList",value:function(){return this.getModule(co).getLocalConversationList().filter((function(e){return e.type===D.CONV_GROUP&&e.groupProfile.type!==D.GRP_AVCHATROOM}))}},{key:"_getRemoteLastMessageSequenceList",value:function(){var e=this;return this.getModule(ao).getGroupList().then((function(t){for(var o=t.data.groupList,n=void 0===o?[]:o,a=0;athis.PULL_LIMIT_COUNT?this.PULL_LIMIT_COUNT:a,e.sequence=a>this.PULL_LIMIT_COUNT?o+this.PULL_LIMIT_COUNT:o+a,this._getGroupMissingMessage(e).then((function(s){s.length>0&&(s[0].sequence+1<=n&&(e.localLastMessageSequence=o+t.PULL_LIMIT_COUNT,e.diff=a-t.PULL_LIMIT_COUNT,t._pullMissingMessage(e)),t.getModule(ao).onNewGroupMessage({dataList:s,isInstantMessage:!1}))}))}},{key:"_getGroupMissingMessage",value:function(e){var t=this,o=new va(ya.GET_GROUP_MISSING_MESSAGE);return this.request({protocolName:hn,requestData:{groupID:e.groupID,count:e.count,sequence:e.sequence}}).then((function(n){var a=n.data.messageList,s=void 0===a?[]:a;return o.setNetworkType(t.getNetworkType()).setMessage("groupID:".concat(e.groupID," count:").concat(e.count," sequence:").concat(e.sequence," messageList length:").concat(s.length)).end(),s})).catch((function(e){t.probeNetwork().then((function(t){var n=m(t,2),a=n[0],s=n[1];o.setError(e,a,s).end()}))}))}},{key:"reset",value:function(){we.log("".concat(this._className,".reset")),this._remoteLastMessageSequenceMap.clear()}}]),o}(Do),Pr=function(){function e(){n(this,e),this._className="AvgE2EDelay",this._e2eDelayArray=[]}return s(e,[{key:"addMessageDelay",value:function(e){var t=ke()-e;t>=0&&this._e2eDelayArray.push(t)}},{key:"_calcAvg",value:function(e,t){if(0===t)return 0;var o=0;return e.forEach((function(e){o+=e})),Pt(o/t,1)}},{key:"_calcCountWithLimit",value:function(e){var t=e.e2eDelayArray,o=e.min,n=e.max;return t.filter((function(e){return o<=e&&e100&&(o=100),o}},{key:"_checkE2EDelayException",value:function(e,t){var o=e.filter((function(e){return e>t}));if(o.length>0){var n=o.length,a=Math.min.apply(Math,M(o)),s=Math.max.apply(Math,M(o)),r=this._calcAvg(o,n),i=Pt(n/e.length*100,2);if(i>50)new va(ya.MESSAGE_E2E_DELAY_EXCEPTION).setMessage("message e2e delay exception. count:".concat(n," min:").concat(a," max:").concat(s," avg:").concat(r," percent:").concat(i)).setLevel("warning").end()}}},{key:"getStatResult",value:function(){var e=this._e2eDelayArray.length;if(0===e)return null;var t=M(this._e2eDelayArray),o=this._calcCountWithLimit({e2eDelayArray:t,min:0,max:1}),n=this._calcCountWithLimit({e2eDelayArray:t,min:1,max:3}),a=this._calcPercent(o,e),s=this._calcPercent(n,e),r=this._calcAvg(t,e);return this._checkE2EDelayException(t,3),t.length=0,this.reset(),{totalCount:e,countLessThan1Second:o,percentOfCountLessThan1Second:a,countLessThan3Second:n,percentOfCountLessThan3Second:s,avgDelay:r}}},{key:"reset",value:function(){this._e2eDelayArray.length=0}}]),e}(),Ur=function(){function e(){n(this,e),this._className="AvgRTT",this._requestCount=0,this._rttArray=[]}return s(e,[{key:"addRequestCount",value:function(){this._requestCount+=1}},{key:"addRTT",value:function(e){this._rttArray.push(e)}},{key:"_calcTotalCount",value:function(){return this._requestCount}},{key:"_calcRTTCount",value:function(e){return e.length}},{key:"_calcSuccessRateOfRequest",value:function(e,t){if(0===t)return 0;var o=Pt(e/t*100,2);return o>100&&(o=100),o}},{key:"_calcAvg",value:function(e,t){if(0===t)return 0;var o=0;return e.forEach((function(e){o+=e})),parseInt(o/t)}},{key:"_calcMax",value:function(){return Math.max.apply(Math,M(this._rttArray))}},{key:"_calcMin",value:function(){return Math.min.apply(Math,M(this._rttArray))}},{key:"getStatResult",value:function(){var e=this._calcTotalCount(),t=M(this._rttArray);if(0===e)return null;var o=this._calcRTTCount(t),n=this._calcSuccessRateOfRequest(o,e),a=this._calcAvg(t,o);return we.log("".concat(this._className,".getStatResult max:").concat(this._calcMax()," min:").concat(this._calcMin()," avg:").concat(a)),this.reset(),{totalCount:e,rttCount:o,successRateOfRequest:n,avgRTT:a}}},{key:"reset",value:function(){this._requestCount=0,this._rttArray.length=0}}]),e}(),wr=function(){function e(){n(this,e),this._map=new Map}return s(e,[{key:"initMap",value:function(e){var t=this;e.forEach((function(e){t._map.set(e,{totalCount:0,successCount:0,failedCountOfUserSide:0,costArray:[],fileSizeArray:[]})}))}},{key:"addTotalCount",value:function(e){return!(Ze(e)||!this._map.has(e))&&(this._map.get(e).totalCount+=1,!0)}},{key:"addSuccessCount",value:function(e){return!(Ze(e)||!this._map.has(e))&&(this._map.get(e).successCount+=1,!0)}},{key:"addFailedCountOfUserSide",value:function(e){return!(Ze(e)||!this._map.has(e))&&(this._map.get(e).failedCountOfUserSide+=1,!0)}},{key:"addCost",value:function(e,t){return!(Ze(e)||!this._map.has(e))&&(this._map.get(e).costArray.push(t),!0)}},{key:"addFileSize",value:function(e,t){return!(Ze(e)||!this._map.has(e))&&(this._map.get(e).fileSizeArray.push(t),!0)}},{key:"_calcSuccessRateOfBusiness",value:function(e){if(Ze(e)||!this._map.has(e))return-1;var t=this._map.get(e),o=Pt(t.successCount/t.totalCount*100,2);return o>100&&(o=100),o}},{key:"_calcSuccessRateOfPlatform",value:function(e){if(Ze(e)||!this._map.has(e))return-1;var t=this._map.get(e),o=this._calcSuccessCountOfPlatform(e)/t.totalCount*100;return(o=Pt(o,2))>100&&(o=100),o}},{key:"_calcTotalCount",value:function(e){return Ze(e)||!this._map.has(e)?-1:this._map.get(e).totalCount}},{key:"_calcSuccessCountOfBusiness",value:function(e){return Ze(e)||!this._map.has(e)?-1:this._map.get(e).successCount}},{key:"_calcSuccessCountOfPlatform",value:function(e){if(Ze(e)||!this._map.has(e))return-1;var t=this._map.get(e);return t.successCount+t.failedCountOfUserSide}},{key:"_calcAvg",value:function(e){return Ze(e)||!this._map.has(e)?-1:e===da?this._calcAvgSpeed(e):this._calcAvgCost(e)}},{key:"_calcAvgCost",value:function(e){var t=this._map.get(e).costArray.length;if(0===t)return 0;var o=0;return this._map.get(e).costArray.forEach((function(e){o+=e})),parseInt(o/t)}},{key:"_calcAvgSpeed",value:function(e){var t=0,o=0;return this._map.get(e).costArray.forEach((function(e){t+=e})),this._map.get(e).fileSizeArray.forEach((function(e){o+=e})),parseInt(1e3*o/t)}},{key:"getStatResult",value:function(e){var t=this._calcTotalCount(e);if(0===t)return null;var o=this._calcSuccessCountOfBusiness(e),n=this._calcSuccessRateOfBusiness(e),a=this._calcSuccessCountOfPlatform(e),s=this._calcSuccessRateOfPlatform(e),r=this._calcAvg(e);return this.reset(e),{totalCount:t,successCountOfBusiness:o,successRateOfBusiness:n,successCountOfPlatform:a,successRateOfPlatform:s,avgValue:r}}},{key:"reset",value:function(e){Ze(e)?this._map.clear():this._map.set(e,{totalCount:0,successCount:0,failedCountOfUserSide:0,costArray:[],fileSizeArray:[]})}}]),e}(),br=function(){function e(){n(this,e),this._lastMap=new Map,this._currentMap=new Map}return s(e,[{key:"initMap",value:function(e){var t=this;e.forEach((function(e){t._lastMap.set(e,new Map),t._currentMap.set(e,new Map)}))}},{key:"addMessageSequence",value:function(e){var t=e.key,o=e.message;if(Ze(t)||!this._lastMap.has(t)||!this._currentMap.has(t))return!1;var n=o.conversationID,a=o.sequence,s=n.replace(D.CONV_GROUP,"");if(0===this._lastMap.get(t).size)this._addCurrentMap(e);else if(this._lastMap.get(t).has(s)){var r=this._lastMap.get(t).get(s),i=r.length-1;a>r[0]&&a100&&(n=100),this._copyData(e),{totalCount:t,successCountOfMessageReceived:o,successRateOfMessageReceived:n}}},{key:"reset",value:function(){this._currentMap.clear(),this._lastMap.clear()}}]),e}(),Fr=function(e){i(a,e);var o=f(a);function a(e){var t;n(this,a),(t=o.call(this,e))._className="QualityStatModule",t.TAG="im-ssolog-quality-stat",t.reportIndex=0,t.wholePeriod=!1,t._qualityItems=[sa,ra,ia,ca,ua,la,da,pa,ga,_a],t._messageSentItems=[ia,ca,ua,la,da],t._messageReceivedItems=[pa,ga,_a],t.REPORT_INTERVAL=120,t.REPORT_SDKAPPID_BLACKLIST=[],t.REPORT_TINYID_WHITELIST=[],t._statInfoArr=[],t._avgRTT=new Ur,t._avgE2EDelay=new Pr,t._rateMessageSent=new wr,t._rateMessageReceived=new br;var s=t.getInnerEmitterInstance();return s.on(Ja,t._onLoginSuccess,_(t)),s.on(Xa,t._onCloudConfigUpdated,_(t)),t}return s(a,[{key:"_onLoginSuccess",value:function(){var e=this;this._rateMessageSent.initMap(this._messageSentItems),this._rateMessageReceived.initMap(this._messageReceivedItems);var t=this.getModule(lo),o=t.getItem(this.TAG,!1);!Vt(o)&&ot(o.forEach)&&(we.log("".concat(this._className,"._onLoginSuccess.get quality stat log in storage, nums=").concat(o.length)),o.forEach((function(t){e._statInfoArr.push(t)})),t.removeItem(this.TAG,!1))}},{key:"_onCloudConfigUpdated",value:function(){var e=this.getCloudConfig("q_rpt_interval"),t=this.getCloudConfig("q_rpt_sdkappid_bl"),o=this.getCloudConfig("q_rpt_tinyid_wl");Ze(e)||(this.REPORT_INTERVAL=Number(e)),Ze(t)||(this.REPORT_SDKAPPID_BLACKLIST=t.split(",").map((function(e){return Number(e)}))),Ze(o)||(this.REPORT_TINYID_WHITELIST=o.split(","))}},{key:"onCheckTimer",value:function(e){this.isLoggedIn()&&e%this.REPORT_INTERVAL==0&&(this.wholePeriod=!0,this._report())}},{key:"addRequestCount",value:function(){this._avgRTT.addRequestCount()}},{key:"addRTT",value:function(e){this._avgRTT.addRTT(e)}},{key:"addMessageDelay",value:function(e){this._avgE2EDelay.addMessageDelay(e)}},{key:"addTotalCount",value:function(e){this._rateMessageSent.addTotalCount(e)||we.warn("".concat(this._className,".addTotalCount invalid key:"),e)}},{key:"addSuccessCount",value:function(e){this._rateMessageSent.addSuccessCount(e)||we.warn("".concat(this._className,".addSuccessCount invalid key:"),e)}},{key:"addFailedCountOfUserSide",value:function(e){this._rateMessageSent.addFailedCountOfUserSide(e)||we.warn("".concat(this._className,".addFailedCountOfUserSide invalid key:"),e)}},{key:"addCost",value:function(e,t){this._rateMessageSent.addCost(e,t)||we.warn("".concat(this._className,".addCost invalid key or cost:"),e,t)}},{key:"addFileSize",value:function(e,t){this._rateMessageSent.addFileSize(e,t)||we.warn("".concat(this._className,".addFileSize invalid key or size:"),e,t)}},{key:"addMessageSequence",value:function(e){this._rateMessageReceived.addMessageSequence(e)||we.warn("".concat(this._className,".addMessageSequence invalid key:"),e.key)}},{key:"_getQualityItem",value:function(e){var o={},n=ma[this.getNetworkType()];Ze(n)&&(n=8);var a={qualityType:ha[e],timestamp:Re(),networkType:n,extension:""};switch(e){case sa:o=this._avgRTT.getStatResult();break;case ra:o=this._avgE2EDelay.getStatResult();break;case ia:case ca:case ua:case la:case da:o=this._rateMessageSent.getStatResult(e);break;case pa:case ga:case _a:o=this._rateMessageReceived.getStatResult(e)}return null===o?null:t(t({},a),o)}},{key:"_report",value:function(e){var t=this,o=[],n=null;Ze(e)?this._qualityItems.forEach((function(e){null!==(n=t._getQualityItem(e))&&(n.reportIndex=t.reportIndex,n.wholePeriod=t.wholePeriod,o.push(n))})):null!==(n=this._getQualityItem(e))&&(n.reportIndex=this.reportIndex,n.wholePeriod=this.wholePeriod,o.push(n)),we.debug("".concat(this._className,"._report"),o),this._statInfoArr.length>0&&(o=o.concat(this._statInfoArr),this._statInfoArr=[]);var a=this.getModule(uo),s=a.getSDKAppID(),r=a.getTinyID();Ut(this.REPORT_SDKAPPID_BLACKLIST,s)&&!wt(this.REPORT_TINYID_WHITELIST,r)&&(o=[]),o.length>0&&this._doReport(o)}},{key:"_doReport",value:function(e){var o=this,n={header:Hs(this),quality:e};this.request({protocolName:Vn,requestData:t({},n)}).then((function(){o.reportIndex++,o.wholePeriod=!1})).catch((function(t){we.warn("".concat(o._className,"._doReport, online:").concat(o.getNetworkType()," error:"),t),o._statInfoArr=o._statInfoArr.concat(e),o._flushAtOnce()}))}},{key:"_flushAtOnce",value:function(){var e=this.getModule(lo),t=e.getItem(this.TAG,!1),o=this._statInfoArr;if(Vt(t))we.log("".concat(this._className,"._flushAtOnce count:").concat(o.length)),e.setItem(this.TAG,o,!0,!1);else{var n=o.concat(t);n.length>10&&(n=n.slice(0,10)),we.log("".concat(this.className,"._flushAtOnce count:").concat(n.length)),e.setItem(this.TAG,n,!0,!1)}this._statInfoArr=[]}},{key:"reset",value:function(){we.log("".concat(this._className,".reset")),this._report(),this.reportIndex=0,this.wholePeriod=!1,this.REPORT_SDKAPPID_BLACKLIST=[],this.REPORT_TINYID_WHITELIST=[],this._avgRTT.reset(),this._avgE2EDelay.reset(),this._rateMessageSent.reset(),this._rateMessageReceived.reset()}}]),a}(Do),qr=function(e){i(o,e);var t=f(o);function o(e){var a;return n(this,o),(a=t.call(this,e))._className="WorkerTimerModule",a._isWorkerEnabled=!0,a._workerTimer=null,a._init(),a.getInnerEmitterInstance().on(Xa,a._onCloudConfigUpdated,_(a)),a}return s(o,[{key:"isWorkerEnabled",value:function(){return this._isWorkerEnabled&&Ee}},{key:"startWorkerTimer",value:function(){we.log("".concat(this._className,".startWorkerTimer")),this._workerTimer&&this._workerTimer.postMessage("start")}},{key:"stopWorkerTimer",value:function(){we.log("".concat(this._className,".stopWorkerTimer")),this._workerTimer&&this._workerTimer.postMessage("stop")}},{key:"_init",value:function(){if(Ee){var e=URL.createObjectURL(new Blob(['let interval = -1;onmessage = function(event) { if (event.data === "start") { if (interval > 0) { clearInterval(interval); } interval = setInterval(() => { postMessage(""); }, 1000) } else if (event.data === "stop") { clearInterval(interval); interval = -1; }};'],{type:"application/javascript; charset=utf-8"}));this._workerTimer=new Worker(e);var t=this;this._workerTimer.onmessage=function(){t._moduleManager.onCheckTimer()}}}},{key:"_onCloudConfigUpdated",value:function(){var e=this.getCloudConfig("enable_worker");we.log("".concat(this._className,"._onCloudConfigUpdated enableWorker:").concat(e)),"1"===e?!this._isWorkerEnabled&&Ee&&(this._isWorkerEnabled=!0,this.startWorkerTimer(),this._moduleManager.onWorkerTimerEnabled()):this._isWorkerEnabled&&Ee&&(this._isWorkerEnabled=!1,this.stopWorkerTimer(),this._moduleManager.onWorkerTimerDisabled())}},{key:"terminate",value:function(){we.log("".concat(this._className,".terminate")),this._workerTimer&&(this._workerTimer.terminate(),this._workerTimer=null)}},{key:"reset",value:function(){we.log("".concat(this._className,".reset"))}}]),o}(Do),Vr=function(){function e(){n(this,e),this._className="PurchasedFeatureHandler",this._purchasedFeatureMap=new Map}return s(e,[{key:"isValidPurchaseBits",value:function(e){return e&&"string"==typeof e&&e.length>=1&&e.length<=64&&/[01]{1,64}/.test(e)}},{key:"parsePurchaseBits",value:function(e){var t="".concat(this._className,".parsePurchaseBits");if(this.isValidPurchaseBits(e)){this._purchasedFeatureMap.clear();for(var o=Object.values(B),n=null,a=e.length-1,s=0;a>=0;a--,s++)n=s<32?new L(0,Math.pow(2,s)).toString():new L(Math.pow(2,s-32),0).toString(),-1!==o.indexOf(n)&&("1"===e[a]?this._purchasedFeatureMap.set(n,!0):this._purchasedFeatureMap.set(n,!1))}else we.warn("".concat(t," invalid purchase bits:").concat(e))}},{key:"hasPurchasedFeature",value:function(e){return!!this._purchasedFeatureMap.get(e)}},{key:"clear",value:function(){this._purchasedFeatureMap.clear()}}]),e}(),Kr=function(e){i(o,e);var t=f(o);function o(e){var a;return n(this,o),(a=t.call(this,e))._className="CommercialConfigModule",a._expiredTime=0,a._isFetching=!1,a._purchasedFeatureHandler=new Vr,a}return s(o,[{key:"_canFetch",value:function(){return this.isLoggedIn()?!this._isFetching&&Date.now()>=this._expiredTime:(this._expiredTime=Date.now()+2e3,!1)}},{key:"onCheckTimer",value:function(e){this._canFetch()&&this.fetchConfig()}},{key:"fetchConfig",value:function(){var e=this,t=this._canFetch(),o="".concat(this._className,".fetchConfig");if(we.log("".concat(o," canFetch:").concat(t)),t){var n=new va(ya.FETCH_COMMERCIAL_CONFIG);n.setNetworkType(this.getNetworkType());var a=this.getModule(uo).getSDKAppID();this._isFetching=!0,this.request({protocolName:Jn,requestData:{SDKAppID:a}}).then((function(t){n.setMessage("purchaseBits:".concat(t.data.purchaseBits)).end(),we.log("".concat(o," ok.")),e._parseConfig(t.data),e._isFetching=!1})).catch((function(t){e.probeNetwork().then((function(e){var o=m(e,2),a=o[0],s=o[1];n.setError(t,a,s).end()})),e._isFetching=!1}))}}},{key:"onPushedConfig",value:function(e){var t="".concat(this._className,".onPushedConfig");we.log("".concat(t)),new va(ya.PUSHED_COMMERCIAL_CONFIG).setNetworkType(this.getNetworkType()).setMessage("purchaseBits:".concat(e.purchaseBits)).end(),this._parseConfig(e)}},{key:"_parseConfig",value:function(e){var t="".concat(this._className,"._parseConfig"),o=e.errorCode,n=e.errorMessage,a=e.purchaseBits,s=e.expiredTime;0===o?(this._purchasedFeatureHandler.parsePurchaseBits(a),this._expiredTime=Date.now()+1e3*s):Ze(o)?(we.log("".concat(t," failed. Invalid message format:"),e),this._setExpiredTimeOnResponseError(36e5)):(we.error("".concat(t," errorCode:").concat(o," errorMessage:").concat(n)),this._setExpiredTimeOnResponseError(12e4))}},{key:"_setExpiredTimeOnResponseError",value:function(e){this._expiredTime=Date.now()+e}},{key:"hasPurchasedFeature",value:function(e){return this._purchasedFeatureHandler.hasPurchasedFeature(e)}},{key:"reset",value:function(){we.log("".concat(this._className,".reset")),this._expiredTime=0,this._isFetching=!1,this._purchasedFeatureHandler.clear()}}]),o}(Do),Hr=function(){function e(t){n(this,e);var o=new va(ya.SDK_CONSTRUCT);this._className="ModuleManager",this._isReady=!1,this._reason=na.USER_NOT_LOGGED_IN,this._startLoginTs=0,this._moduleMap=new Map,this._innerEmitter=null,this._outerEmitter=null,this._checkCount=0,this._checkTimer=-1,this._moduleMap.set(uo,new bs(this,t)),this._moduleMap.set(So,new Kr(this)),this._moduleMap.set(Io,new kr(this)),this._moduleMap.set(Eo,new qr(this)),this._moduleMap.set(Co,new Fr(this)),this._moduleMap.set(vo,new Tr(this)),this._moduleMap.set(Mo,new Rr(this)),this._moduleMap.set(eo,new Fs(this)),this._moduleMap.set(to,new or(this)),this._moduleMap.set(oo,new ws(this)),this._moduleMap.set(no,new $a(this)),this._moduleMap.set(co,new _s(this)),this._moduleMap.set(ao,new Ds(this)),this._moduleMap.set(ro,new As(this)),this._moduleMap.set(io,new ks(this)),this._moduleMap.set(lo,new Vs(this)),this._moduleMap.set(po,new Bs(this)),this._moduleMap.set(go,new js(this)),this._moduleMap.set(_o,new zs(this)),this._moduleMap.set(ho,new Xs(this)),this._moduleMap.set(fo,new nr(this)),this._moduleMap.set(mo,new ar(this)),this._moduleMap.set(yo,new Lr(this)),this._moduleMap.set(To,new Gr(this)),this._eventThrottleMap=new Map;var a=t.instanceID,s=t.oversea,r=t.SDKAppID,i="instanceID:".concat(a," SDKAppID:").concat(r," host:").concat(Rt()," oversea:").concat(s," inBrowser:").concat(oe," inMiniApp:").concat(te)+" workerAvailable:".concat(Ee," UserAgent:").concat(se);va.bindEventStatModule(this._moduleMap.get(po)),o.setMessage("".concat(i," ").concat(function(){var e="";if(te)try{var t=ne.getSystemInfoSync(),o=t.model,n=t.version,a=t.system,s=t.platform,r=t.SDKVersion;e="model:".concat(o," version:").concat(n," system:").concat(a," platform:").concat(s," SDKVersion:").concat(r)}catch(i){e=""}return e}())).end(),we.info("SDK ".concat(i)),this._readyList=void 0,this._ssoLogForReady=null,this._initReadyList()}return s(e,[{key:"_startTimer",value:function(){var e=this._moduleMap.get(Eo),t=e.isWorkerEnabled();we.log("".concat(this._className,".startTimer isWorkerEnabled:").concat(t," seed:").concat(this._checkTimer)),t?e.startWorkerTimer():this._startMainThreadTimer()}},{key:"_startMainThreadTimer",value:function(){we.log("".concat(this._className,"._startMainThreadTimer")),this._checkTimer<0&&(this._checkTimer=setInterval(this.onCheckTimer.bind(this),1e3))}},{key:"stopTimer",value:function(){var e=this._moduleMap.get(Eo),t=e.isWorkerEnabled();we.log("".concat(this._className,".stopTimer isWorkerEnabled:").concat(t," seed:").concat(this._checkTimer)),t?e.stopWorkerTimer():this._stopMainThreadTimer()}},{key:"_stopMainThreadTimer",value:function(){we.log("".concat(this._className,"._stopMainThreadTimer")),this._checkTimer>0&&(clearInterval(this._checkTimer),this._checkTimer=-1,this._checkCount=0)}},{key:"_stopMainThreadSocket",value:function(){we.log("".concat(this._className,"._stopMainThreadSocket"));var e=this._moduleMap.get(vo);e.setIsWorkerEnabled(!0),e.reConnect()}},{key:"_startMainThreadSocket",value:function(){we.log("".concat(this._className,"._startMainThreadSocket"));var e=this._moduleMap.get(vo);e.setIsWorkerEnabled(!1),e.reConnect()}},{key:"onWorkerTimerEnabled",value:function(){we.log("".concat(this._className,".onWorkerTimerEnabled, disable main thread timer and socket")),this._stopMainThreadTimer(),this._stopMainThreadSocket()}},{key:"onWorkerTimerDisabled",value:function(){we.log("".concat(this._className,".onWorkerTimerDisabled, enable main thread timer and socket")),this._startMainThreadTimer(),this._startMainThreadSocket()}},{key:"onCheckTimer",value:function(){this._checkCount+=1;var e,t=C(this._moduleMap);try{for(t.s();!(e=t.n()).done;){var o=m(e.value,2)[1];o.onCheckTimer&&o.onCheckTimer(this._checkCount)}}catch(n){t.e(n)}finally{t.f()}}},{key:"_initReadyList",value:function(){var e=this;this._readyList=[this._moduleMap.get(eo),this._moduleMap.get(co)],this._readyList.forEach((function(t){t.ready((function(){return e._onModuleReady()}))}))}},{key:"_onModuleReady",value:function(){var e=!0;if(this._readyList.forEach((function(t){t.isReady()||(e=!1)})),e&&!this._isReady){this._isReady=!0,this._outerEmitter.emit(S.SDK_READY);var t=Date.now()-this._startLoginTs;we.warn("SDK is ready. cost ".concat(t," ms")),this._startLoginTs=Date.now();var o=this._moduleMap.get(go).getNetworkType(),n=this._ssoLogForReady.getStartTs()+Oe;this._ssoLogForReady.setNetworkType(o).setMessage(t).start(n).end()}}},{key:"login",value:function(){0===this._startLoginTs&&(Le(),this._startLoginTs=Date.now(),this._startTimer(),this._moduleMap.get(go).start(),this._ssoLogForReady=new va(ya.SDK_READY),this._reason=na.LOGGING_IN)}},{key:"onLoginFailed",value:function(){this._startLoginTs=0}},{key:"getOuterEmitterInstance",value:function(){return null===this._outerEmitter&&(this._outerEmitter=new $s,Wa(this._outerEmitter),this._outerEmitter._emit=this._outerEmitter.emit,this._outerEmitter.emit=function(e,t){var o=this;if(e===S.CONVERSATION_LIST_UPDATED||e===S.FRIEND_LIST_UPDATED||e===S.GROUP_LIST_UPDATED)if(this._eventThrottleMap.has(e)){var n=Date.now(),a=this._eventThrottleMap.get(e);n-a.last<1e3?(a.timeoutID&&clearTimeout(a.timeoutID),a.timeoutID=setTimeout((function(){a.last=n,o._outerEmitter._emit.apply(o._outerEmitter,[e,{name:e,data:o._getEventData(e)}])}),500)):(a.last=n,this._outerEmitter._emit.apply(this._outerEmitter,[e,{name:e,data:this._getEventData(e)}]))}else this._eventThrottleMap.set(e,{last:Date.now(),timeoutID:-1}),this._outerEmitter._emit.apply(this._outerEmitter,[e,{name:e,data:this._getEventData(e)}]);else this._outerEmitter._emit.apply(this._outerEmitter,[e,{name:e,data:arguments[1]}])}.bind(this)),this._outerEmitter}},{key:"_getEventData",value:function(e){return e===S.CONVERSATION_LIST_UPDATED?this._moduleMap.get(co).getLocalConversationList():e===S.FRIEND_LIST_UPDATED?this._moduleMap.get(so).getLocalFriendList(!1):e===S.GROUP_LIST_UPDATED?this._moduleMap.get(ao).getLocalGroupList():void 0}},{key:"getInnerEmitterInstance",value:function(){return null===this._innerEmitter&&(this._innerEmitter=new $s,this._innerEmitter._emit=this._innerEmitter.emit,this._innerEmitter.emit=function(e,t){var o;Xe(arguments[1])&&arguments[1].data?(we.warn("inner eventData has data property, please check!"),o=[e,{name:arguments[0],data:arguments[1].data}]):o=[e,{name:arguments[0],data:arguments[1]}],this._innerEmitter._emit.apply(this._innerEmitter,o)}.bind(this)),this._innerEmitter}},{key:"hasModule",value:function(e){return this._moduleMap.has(e)}},{key:"getModule",value:function(e){return this._moduleMap.get(e)}},{key:"isReady",value:function(){return this._isReady}},{key:"getNotReadyReason",value:function(){return this._reason}},{key:"setNotReadyReason",value:function(e){this._reason=e}},{key:"onError",value:function(e){we.warn("Oops! code:".concat(e.code," message:").concat(e.message)),new va(ya.ERROR).setMessage("code:".concat(e.code," message:").concat(e.message)).setNetworkType(this.getModule(go).getNetworkType()).setLevel("error").end(),this.getOuterEmitterInstance().emit(S.ERROR,e)}},{key:"reset",value:function(){we.log("".concat(this._className,".reset")),Le();var e,t=C(this._moduleMap);try{for(t.s();!(e=t.n()).done;){var o=m(e.value,2)[1];o.reset&&o.reset()}}catch(r){t.e(r)}finally{t.f()}this._startLoginTs=0,this._initReadyList(),this._isReady=!1,this.stopTimer(),this._outerEmitter.emit(S.SDK_NOT_READY);var n,a=C(this._eventThrottleMap);try{for(a.s();!(n=a.n()).done;){var s=m(n.value,2)[1];s.timeoutID&&clearTimeout(s.timeoutID)}}catch(r){a.e(r)}finally{a.f()}this._eventThrottleMap.clear()}}]),e}(),Br=function(){function e(){n(this,e),this._funcMap=new Map}return s(e,[{key:"defense",value:function(e,t){var o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0;if("string"!=typeof e)return null;if(0===e.length)return null;if("function"!=typeof t)return null;if(this._funcMap.has(e)&&this._funcMap.get(e).has(t))return this._funcMap.get(e).get(t);this._funcMap.has(e)||this._funcMap.set(e,new Map);var n=null;return this._funcMap.get(e).has(t)?n=this._funcMap.get(e).get(t):(n=this._pack(e,t,o),this._funcMap.get(e).set(t,n)),n}},{key:"defenseOnce",value:function(e,t){var o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0;return"function"!=typeof t?null:this._pack(e,t,o)}},{key:"find",value:function(e,t){return"string"!=typeof e||0===e.length||"function"!=typeof t?null:this._funcMap.has(e)?this._funcMap.get(e).has(t)?this._funcMap.get(e).get(t):(we.log("SafetyCallback.find: 找不到 func —— ".concat(e,"/").concat(""!==t.name?t.name:"[anonymous]")),null):(we.log("SafetyCallback.find: 找不到 eventName-".concat(e," 对应的 func")),null)}},{key:"delete",value:function(e,t){return"function"==typeof t&&(!!this._funcMap.has(e)&&(!!this._funcMap.get(e).has(t)&&(this._funcMap.get(e).delete(t),0===this._funcMap.get(e).size&&this._funcMap.delete(e),!0)))}},{key:"_pack",value:function(e,t,o){return function(){try{t.apply(o,Array.from(arguments))}catch(r){var n=Object.values(S).indexOf(e);if(-1!==n){var a=Object.keys(S)[n];we.warn("接入侧事件 TIM.EVENT.".concat(a," 对应的回调函数逻辑存在问题,请检查!"),r)}var s=new va(ya.CALLBACK_FUNCTION_ERROR);s.setMessage("eventName:".concat(e)).setMoreMessage(r.message).end()}}}}]),e}(),xr=function(){function e(t){n(this,e);var o={SDKAppID:t.SDKAppID,unlimitedAVChatRoom:t.unlimitedAVChatRoom||!1,scene:t.scene||"",oversea:t.oversea||!1,instanceID:Ot(),devMode:t.devMode||!1,proxyServer:t.proxyServer||void 0};this._moduleManager=new Hr(o),this._safetyCallbackFactory=new Br}return s(e,[{key:"onError",value:function(e){this._moduleManager.onError(e)}},{key:"login",value:function(e){return this._moduleManager.login(),this._moduleManager.getModule(eo).login(e)}},{key:"logout",value:function(){var e=this;return this._moduleManager.getModule(eo).logout().then((function(t){return e._moduleManager.reset(),t}))}},{key:"isReady",value:function(){return this._moduleManager.isReady()}},{key:"getNotReadyReason",value:function(){return this._moduleManager.getNotReadyReason()}},{key:"destroy",value:function(){var e=this;return this.logout().finally((function(){e._moduleManager.stopTimer(),e._moduleManager.getModule(Eo).terminate(),e._moduleManager.getModule(vo).dealloc();var t=e._moduleManager.getOuterEmitterInstance(),o=e._moduleManager.getModule(uo);t.emit(S.SDK_DESTROY,{SDKAppID:o.getSDKAppID()})}))}},{key:"on",value:function(e,t,o){e===S.GROUP_SYSTEM_NOTICE_RECEIVED&&we.warn("!!!TIM.EVENT.GROUP_SYSTEM_NOTICE_RECEIVED v2.6.0起弃用,为了更好的体验,请在 TIM.EVENT.MESSAGE_RECEIVED 事件回调内接收处理群系统通知,详细请参考:https://web.sdk.qcloud.com/im/doc/zh-cn/Message.html#.GroupSystemNoticePayload"),we.debug("on","eventName:".concat(e)),this._moduleManager.getOuterEmitterInstance().on(e,this._safetyCallbackFactory.defense(e,t,o),o)}},{key:"once",value:function(e,t,o){we.debug("once","eventName:".concat(e)),this._moduleManager.getOuterEmitterInstance().once(e,this._safetyCallbackFactory.defenseOnce(e,t,o),o||this)}},{key:"off",value:function(e,t,o,n){we.debug("off","eventName:".concat(e));var a=this._safetyCallbackFactory.find(e,t);null!==a&&(this._moduleManager.getOuterEmitterInstance().off(e,a,o,n),this._safetyCallbackFactory.delete(e,t))}},{key:"registerPlugin",value:function(e){this._moduleManager.getModule(fo).registerPlugin(e)}},{key:"setLogLevel",value:function(e){if(e<=0){console.log([""," ________ ______ __ __ __ __ ________ _______","| \\| \\| \\ / \\| \\ _ | \\| \\| \\"," \\$$$$$$$$ \\$$$$$$| $$\\ / $$| $$ / \\ | $$| $$$$$$$$| $$$$$$$\\"," | $$ | $$ | $$$\\ / $$$| $$/ $\\| $$| $$__ | $$__/ $$"," | $$ | $$ | $$$$\\ $$$$| $$ $$$\\ $$| $$ \\ | $$ $$"," | $$ | $$ | $$\\$$ $$ $$| $$ $$\\$$\\$$| $$$$$ | $$$$$$$\\"," | $$ _| $$_ | $$ \\$$$| $$| $$$$ \\$$$$| $$_____ | $$__/ $$"," | $$ | $$ \\| $$ \\$ | $$| $$$ \\$$$| $$ \\| $$ $$"," \\$$ \\$$$$$$ \\$$ \\$$ \\$$ \\$$ \\$$$$$$$$ \\$$$$$$$","",""].join("\n")),console.log("%cIM 智能客服,随时随地解决您的问题 →_→ https://cloud.tencent.com/act/event/smarty-service?from=im-doc","color:#006eff"),console.log("%c从v2.11.2起,SDK 支持了 WebSocket,小程序需要添加受信域名!升级指引: https://web.sdk.qcloud.com/im/doc/zh-cn/tutorial-02-upgradeguideline.html","color:#ff0000");console.log(["","参考以下文档,会更快解决问题哦!(#^.^#)\n","SDK 更新日志: https://cloud.tencent.com/document/product/269/38492\n","SDK 接口文档: https://web.sdk.qcloud.com/im/doc/zh-cn/SDK.html\n","常见问题: https://web.sdk.qcloud.com/im/doc/zh-cn/tutorial-01-faq.html\n","反馈问题?戳我提 issue: https://github.com/tencentyun/TIMSDK/issues\n","如果您需要在生产环境关闭上面的日志,请 tim.setLogLevel(1)\n"].join("\n"))}we.setLevel(e)}},{key:"createTextMessage",value:function(e){return this._moduleManager.getModule(to).createTextMessage(e)}},{key:"createTextAtMessage",value:function(e){return this._moduleManager.getModule(to).createTextMessage(e)}},{key:"createImageMessage",value:function(e){return this._moduleManager.getModule(to).createImageMessage(e)}},{key:"createAudioMessage",value:function(e){return this._moduleManager.getModule(to).createAudioMessage(e)}},{key:"createVideoMessage",value:function(e){return this._moduleManager.getModule(to).createVideoMessage(e)}},{key:"createCustomMessage",value:function(e){return this._moduleManager.getModule(to).createCustomMessage(e)}},{key:"createFaceMessage",value:function(e){return this._moduleManager.getModule(to).createFaceMessage(e)}},{key:"createFileMessage",value:function(e){return this._moduleManager.getModule(to).createFileMessage(e)}},{key:"createLocationMessage",value:function(e){return this._moduleManager.getModule(to).createLocationMessage(e)}},{key:"createMergerMessage",value:function(e){return this._moduleManager.getModule(to).createMergerMessage(e)}},{key:"downloadMergerMessage",value:function(e){return e.type!==D.MSG_MERGER?ja(new Ba({code:na.MESSAGE_MERGER_TYPE_INVALID,message:aa.MESSAGE_MERGER_TYPE_INVALID})):Vt(e.payload.downloadKey)?ja(new Ba({code:na.MESSAGE_MERGER_KEY_INVALID,message:aa.MESSAGE_MERGER_KEY_INVALID})):this._moduleManager.getModule(to).downloadMergerMessage(e).catch((function(e){return ja(new Ba({code:na.MESSAGE_MERGER_DOWNLOAD_FAIL,message:aa.MESSAGE_MERGER_DOWNLOAD_FAIL}))}))}},{key:"createForwardMessage",value:function(e){return this._moduleManager.getModule(to).createForwardMessage(e)}},{key:"sendMessage",value:function(e,t){return e instanceof wa?this._moduleManager.getModule(to).sendMessageInstance(e,t):ja(new Ba({code:na.MESSAGE_SEND_NEED_MESSAGE_INSTANCE,message:aa.MESSAGE_SEND_NEED_MESSAGE_INSTANCE}))}},{key:"callExperimentalAPI",value:function(e,t){return"handleGroupInvitation"===e?this._moduleManager.getModule(ao).handleGroupInvitation(t):ja(new Ba({code:na.INVALID_OPERATION,message:aa.INVALID_OPERATION}))}},{key:"revokeMessage",value:function(e){return this._moduleManager.getModule(to).revokeMessage(e)}},{key:"resendMessage",value:function(e){return this._moduleManager.getModule(to).resendMessage(e)}},{key:"deleteMessage",value:function(e){return this._moduleManager.getModule(to).deleteMessage(e)}},{key:"modifyMessage",value:function(e){return this._moduleManager.getModule(to).modifyRemoteMessage(e)}},{key:"getMessageList",value:function(e){return this._moduleManager.getModule(co).getMessageList(e)}},{key:"getMessageListHopping",value:function(e){return this._moduleManager.getModule(co).getMessageListHopping(e)}},{key:"sendMessageReadReceipt",value:function(e){return this._moduleManager.getModule(co).sendReadReceipt(e)}},{key:"getMessageReadReceiptList",value:function(e){return this._moduleManager.getModule(co).getReadReceiptList(e)}},{key:"getGroupMessageReadMemberList",value:function(e){return this._moduleManager.getModule(ao).getReadReceiptDetail(e)}},{key:"findMessage",value:function(e){return this._moduleManager.getModule(co).findMessage(e)}},{key:"setMessageRead",value:function(e){return this._moduleManager.getModule(co).setMessageRead(e)}},{key:"getConversationList",value:function(e){return this._moduleManager.getModule(co).getConversationList(e)}},{key:"getConversationProfile",value:function(e){return this._moduleManager.getModule(co).getConversationProfile(e)}},{key:"deleteConversation",value:function(e){return this._moduleManager.getModule(co).deleteConversation(e)}},{key:"pinConversation",value:function(e){return this._moduleManager.getModule(co).pinConversation(e)}},{key:"setAllMessageRead",value:function(e){return this._moduleManager.getModule(co).setAllMessageRead(e)}},{key:"setMessageRemindType",value:function(e){return this._moduleManager.getModule(co).setMessageRemindType(e)}},{key:"getMyProfile",value:function(){return this._moduleManager.getModule(oo).getMyProfile()}},{key:"getUserProfile",value:function(e){return this._moduleManager.getModule(oo).getUserProfile(e)}},{key:"updateMyProfile",value:function(e){return this._moduleManager.getModule(oo).updateMyProfile(e)}},{key:"getBlacklist",value:function(){return this._moduleManager.getModule(oo).getLocalBlacklist()}},{key:"addToBlacklist",value:function(e){return this._moduleManager.getModule(oo).addBlacklist(e)}},{key:"removeFromBlacklist",value:function(e){return this._moduleManager.getModule(oo).deleteBlacklist(e)}},{key:"getFriendList",value:function(){var e=this._moduleManager.getModule(so);return e?e.getLocalFriendList():ja({code:na.CANNOT_FIND_MODULE,message:aa.CANNOT_FIND_MODULE})}},{key:"addFriend",value:function(e){var t=this._moduleManager.getModule(so);return t?t.addFriend(e):ja({code:na.CANNOT_FIND_MODULE,message:aa.CANNOT_FIND_MODULE})}},{key:"deleteFriend",value:function(e){var t=this._moduleManager.getModule(so);return t?t.deleteFriend(e):ja({code:na.CANNOT_FIND_MODULE,message:aa.CANNOT_FIND_MODULE})}},{key:"checkFriend",value:function(e){var t=this._moduleManager.getModule(so);return t?t.checkFriend(e):ja({code:na.CANNOT_FIND_MODULE,message:aa.CANNOT_FIND_MODULE})}},{key:"getFriendProfile",value:function(e){var t=this._moduleManager.getModule(so);return t?t.getFriendProfile(e):ja({code:na.CANNOT_FIND_MODULE,message:aa.CANNOT_FIND_MODULE})}},{key:"updateFriend",value:function(e){var t=this._moduleManager.getModule(so);return t?t.updateFriend(e):ja({code:na.CANNOT_FIND_MODULE,message:aa.CANNOT_FIND_MODULE})}},{key:"getFriendApplicationList",value:function(){var e=this._moduleManager.getModule(so);return e?e.getLocalFriendApplicationList():ja({code:na.CANNOT_FIND_MODULE,message:aa.CANNOT_FIND_MODULE})}},{key:"acceptFriendApplication",value:function(e){var t=this._moduleManager.getModule(so);return t?t.acceptFriendApplication(e):ja({code:na.CANNOT_FIND_MODULE,message:aa.CANNOT_FIND_MODULE})}},{key:"refuseFriendApplication",value:function(e){var t=this._moduleManager.getModule(so);return t?t.refuseFriendApplication(e):ja({code:na.CANNOT_FIND_MODULE,message:aa.CANNOT_FIND_MODULE})}},{key:"deleteFriendApplication",value:function(e){var t=this._moduleManager.getModule(so);return t?t.deleteFriendApplication(e):ja({code:na.CANNOT_FIND_MODULE,message:aa.CANNOT_FIND_MODULE})}},{key:"setFriendApplicationRead",value:function(){var e=this._moduleManager.getModule(so);return e?e.setFriendApplicationRead():ja({code:na.CANNOT_FIND_MODULE,message:aa.CANNOT_FIND_MODULE})}},{key:"getFriendGroupList",value:function(){var e=this._moduleManager.getModule(so);return e?e.getLocalFriendGroupList():ja({code:na.CANNOT_FIND_MODULE,message:aa.CANNOT_FIND_MODULE})}},{key:"createFriendGroup",value:function(e){var t=this._moduleManager.getModule(so);return t?t.createFriendGroup(e):ja({code:na.CANNOT_FIND_MODULE,message:aa.CANNOT_FIND_MODULE})}},{key:"deleteFriendGroup",value:function(e){var t=this._moduleManager.getModule(so);return t?t.deleteFriendGroup(e):ja({code:na.CANNOT_FIND_MODULE,message:aa.CANNOT_FIND_MODULE})}},{key:"addToFriendGroup",value:function(e){var t=this._moduleManager.getModule(so);return t?t.addToFriendGroup(e):ja({code:na.CANNOT_FIND_MODULE,message:aa.CANNOT_FIND_MODULE})}},{key:"removeFromFriendGroup",value:function(e){var t=this._moduleManager.getModule(so);return t?t.removeFromFriendGroup(e):ja({code:na.CANNOT_FIND_MODULE,message:aa.CANNOT_FIND_MODULE})}},{key:"renameFriendGroup",value:function(e){var t=this._moduleManager.getModule(so);return t?t.renameFriendGroup(e):ja({code:na.CANNOT_FIND_MODULE,message:aa.CANNOT_FIND_MODULE})}},{key:"getGroupList",value:function(e){return this._moduleManager.getModule(ao).getGroupList(e)}},{key:"getGroupProfile",value:function(e){return this._moduleManager.getModule(ao).getGroupProfile(e)}},{key:"createGroup",value:function(e){return this._moduleManager.getModule(ao).createGroup(e)}},{key:"dismissGroup",value:function(e){return this._moduleManager.getModule(ao).dismissGroup(e)}},{key:"updateGroupProfile",value:function(e){return this._moduleManager.getModule(ao).updateGroupProfile(e)}},{key:"joinGroup",value:function(e){return this._moduleManager.getModule(ao).joinGroup(e)}},{key:"quitGroup",value:function(e){return this._moduleManager.getModule(ao).quitGroup(e)}},{key:"searchGroupByID",value:function(e){return this._moduleManager.getModule(ao).searchGroupByID(e)}},{key:"getGroupOnlineMemberCount",value:function(e){return this._moduleManager.getModule(ao).getGroupOnlineMemberCount(e)}},{key:"changeGroupOwner",value:function(e){return this._moduleManager.getModule(ao).changeGroupOwner(e)}},{key:"handleGroupApplication",value:function(e){return this._moduleManager.getModule(ao).handleGroupApplication(e)}},{key:"initGroupAttributes",value:function(e){return this._moduleManager.getModule(ao).initGroupAttributes(e)}},{key:"setGroupAttributes",value:function(e){return this._moduleManager.getModule(ao).setGroupAttributes(e)}},{key:"deleteGroupAttributes",value:function(e){return this._moduleManager.getModule(ao).deleteGroupAttributes(e)}},{key:"getGroupAttributes",value:function(e){return this._moduleManager.getModule(ao).getGroupAttributes(e)}},{key:"getGroupMemberList",value:function(e){return this._moduleManager.getModule(ro).getGroupMemberList(e)}},{key:"getGroupMemberProfile",value:function(e){return this._moduleManager.getModule(ro).getGroupMemberProfile(e)}},{key:"addGroupMember",value:function(e){return this._moduleManager.getModule(ro).addGroupMember(e)}},{key:"deleteGroupMember",value:function(e){return this._moduleManager.getModule(ro).deleteGroupMember(e)}},{key:"setGroupMemberMuteTime",value:function(e){return this._moduleManager.getModule(ro).setGroupMemberMuteTime(e)}},{key:"setGroupMemberRole",value:function(e){return this._moduleManager.getModule(ro).setGroupMemberRole(e)}},{key:"setGroupMemberNameCard",value:function(e){return this._moduleManager.getModule(ro).setGroupMemberNameCard(e)}},{key:"setGroupMemberCustomField",value:function(e){return this._moduleManager.getModule(ro).setGroupMemberCustomField(e)}},{key:"getJoinedCommunityList",value:function(){return this._moduleManager.getModule(io).getJoinedCommunityList()}},{key:"createTopicInCommunity",value:function(e){return this._moduleManager.getModule(io).createTopicInCommunity(e)}},{key:"deleteTopicFromCommunity",value:function(e){return this._moduleManager.getModule(io).deleteTopicFromCommunity(e)}},{key:"updateTopicProfile",value:function(e){return this._moduleManager.getModule(io).updateTopicProfile(e)}},{key:"getTopicList",value:function(e){return this._moduleManager.getModule(io).getTopicList(e)}}]),e}(),Wr={login:"login",logout:"logout",destroy:"destroy",on:"on",off:"off",ready:"ready",setLogLevel:"setLogLevel",joinGroup:"joinGroup",quitGroup:"quitGroup",registerPlugin:"registerPlugin",getGroupOnlineMemberCount:"getGroupOnlineMemberCount"};function Yr(e,t){if(e.isReady()||void 0!==Wr[t])return!0;var o=e.getNotReadyReason(),n="";Object.getOwnPropertyNames(na).forEach((function(e){na[e]===o&&(n=aa[e])}));var a={code:o,message:"".concat(n,"导致 sdk not ready。").concat(t," ").concat(aa.SDK_IS_NOT_READY,",请参考 https://web.sdk.qcloud.com/im/doc/zh-cn/module-EVENT.html#.SDK_READY")};return e.onError(a),a}var jr={},$r={};return $r.create=function(e){var o=0;if($e(e.SDKAppID))o=e.SDKAppID;else if(we.warn("TIM.create SDKAppID 的类型应该为 Number,请修改!"),o=parseInt(e.SDKAppID),isNaN(o))return we.error("TIM.create failed. 解析 SDKAppID 失败,请检查传参!"),null;if(o&&jr[o])return jr[o];we.log("TIM.create");var n=new xr(t(t({},e),{},{SDKAppID:o}));n.on(S.SDK_DESTROY,(function(e){jr[e.data.SDKAppID]=null,delete jr[e.data.SDKAppID]}));var a=function(e){var t=Object.create(null);return Object.keys(Zt).forEach((function(o){if(e[o]){var n=Zt[o],a=new N;t[n]=function(){var t=Array.from(arguments);return a.use((function(t,n){var a=Yr(e,o);return!0===a?n():ja(a)})).use((function(e,t){if(!0===Kt(e,Qt[o],n))return t()})).use((function(t,n){return e[o].apply(e,t)})),a.run(t)}}})),t}(n);return jr[o]=a,we.log("TIM.create ok"),a},$r.TYPES=D,$r.EVENT=S,$r.VERSION="2.20.1",we.log("TIM.VERSION: ".concat($r.VERSION)),$r})); diff --git a/MiniProgram/TUIKit/miniprogram/components/TUICalling/TRTCCalling/node_module/trtc-wx.js b/MiniProgram/TUIKit/miniprogram/components/TUICalling/TRTCCalling/node_module/trtc-wx.js index 3fba0729ee..5d077a63fa 100644 --- a/MiniProgram/TUIKit/miniprogram/components/TUICalling/TRTCCalling/node_module/trtc-wx.js +++ b/MiniProgram/TUIKit/miniprogram/components/TUICalling/TRTCCalling/node_module/trtc-wx.js @@ -1,331 +1,2 @@ -!(function (e, t) { - 'object' === typeof exports && 'undefined' !== typeof module ? module.exports = t() : 'function' === typeof define && define.amd ? define(t) : (e = 'undefined' !== typeof globalThis ? globalThis : e || self).TRTC = t(); -}(this, (() => { - 'use strict';function e(e, t) { - if (!(e instanceof t)) throw new TypeError('Cannot call a class as a function'); - } function t(e, t) { - for (let r = 0;r < t.length;r++) { - const s = t[r];s.enumerable = s.enumerable || !1, s.configurable = !0, 'value' in s && (s.writable = !0), Object.defineProperty(e, s.key, s); - } - } function r(e, r, s) { - return r && t(e.prototype, r), s && t(e, s), e; - } function s(e, t, r) { - return t in e ? Object.defineProperty(e, t, { value: r, enumerable: !0, configurable: !0, writable: !0 }) : e[t] = r, e; - } function i(e, t) { - const r = Object.keys(e);if (Object.getOwnPropertySymbols) { - let s = Object.getOwnPropertySymbols(e);t && (s = s.filter((t => Object.getOwnPropertyDescriptor(e, t).enumerable))), r.push.apply(r, s); - } return r; - } function a(e) { - for (let t = 1;t < arguments.length;t++) { - var r = null != arguments[t] ? arguments[t] : {};t % 2 ? i(Object(r), !0).forEach(((t) => { - s(e, t, r[t]); - })) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(r)) : i(Object(r)).forEach(((t) => { - Object.defineProperty(e, t, Object.getOwnPropertyDescriptor(r, t)); - })); - } return e; - } function n() { - const e = (new Date).getTime(); const t = new Date(e); let r = t.getHours(); let s = t.getMinutes(); let i = t.getSeconds(); const a = t.getMilliseconds();return r = r < 10 ? '0'.concat(r) : r, s = s < 10 ? '0'.concat(s) : s, i = i < 10 ? '0'.concat(i) : i, ''.concat(r, ':').concat(s, ':') - .concat(i, '.') - .concat(a); - } const o = 'TRTC-WX'; const u = 0; const c = 1; const l = new (function () { - function t() { - e(this, t), this.logLevel = 0; - } return r(t, [{ key: 'setLogLevel', value(e) { - this.logLevel = e; - } }, { key: 'log', value() { - let e;this.logLevel === u && (e = console).log.apply(e, [o, n()].concat(Array.prototype.slice.call(arguments))); - } }, { key: 'warn', value() { - let e;this.logLevel <= c && (e = console).warn.apply(e, [o, n()].concat(Array.prototype.slice.call(arguments))); - } }, { key: 'error', value() { - let e;(e = console).error.apply(e, [o, n()].concat(Array.prototype.slice.call(arguments))); - } }]), t; - }());const h = function (e) { - const t = /[\u4e00-\u9fa5]/;return e.sdkAppID ? void 0 === e.roomID && void 0 === e.strRoomID ? (l.error('未设置 roomID'), !1) : !e.strRoomID && (e.roomID < 1 || e.roomID > 4294967296) ? (l.error('roomID 超出取值范围 1 ~ 4294967295'), !1) : e.strRoomID && t.test(e.strRoomID) ? (l.error('strRoomID 请勿使用中文字符'), !1) : e.userID ? e.userID && t.test(e.userID) ? (l.error('userID 请勿使用中文字符'), !1) : !!e.userSig || (l.error('未设置 userSig'), !1) : (l.error('未设置 userID'), !1) : (l.error('未设置 sdkAppID'), !1); - }; const p = { LOCAL_JOIN: 'LOCAL_JOIN', LOCAL_LEAVE: 'LOCAL_LEAVE', KICKED_OUT: 'KICKED_OUT', REMOTE_USER_JOIN: 'REMOTE_USER_JOIN', REMOTE_USER_LEAVE: 'REMOTE_USER_LEAVE', REMOTE_VIDEO_ADD: 'REMOTE_VIDEO_ADD', REMOTE_VIDEO_REMOVE: 'REMOTE_VIDEO_REMOVE', REMOTE_AUDIO_ADD: 'REMOTE_AUDIO_ADD', REMOTE_AUDIO_REMOVE: 'REMOTE_AUDIO_REMOVE', REMOTE_STATE_UPDATE: 'REMOTE_STATE_UPDATE', LOCAL_NET_STATE_UPDATE: 'LOCAL_NET_STATE_UPDATE', REMOTE_NET_STATE_UPDATE: 'REMOTE_NET_STATE_UPDATE', LOCAL_AUDIO_VOLUME_UPDATE: 'LOCAL_AUDIO_VOLUME_UPDATE', REMOTE_AUDIO_VOLUME_UPDATE: 'REMOTE_AUDIO_VOLUME_UPDATE', VIDEO_FULLSCREEN_UPDATE: 'VIDEO_FULLSCREEN_UPDATE', BGM_PLAY_START: 'BGM_PLAY_START', BGM_PLAY_FAIL: 'BGM_PLAY_FAIL', BGM_PLAY_PROGRESS: 'BGM_PLAY_PROGRESS', BGM_PLAY_COMPLETE: 'BGM_PLAY_COMPLETE', ERROR: 'ERROR', IM_READY: 'IM_READY', IM_MESSAGE_RECEIVED: 'IM_MESSAGE_RECEIVED', IM_NOT_READY: 'IM_NOT_READY', IM_KICKED_OUT: 'IM_KICKED_OUT', IM_ERROR: 'IM_ERROR' }; const m = { url: '', mode: 'RTC', autopush: !1, enableCamera: !1, enableMic: !1, enableAgc: !1, enableAns: !1, enableEarMonitor: !1, enableAutoFocus: !0, enableZoom: !1, minBitrate: 600, maxBitrate: 900, videoWidth: 360, videoHeight: 640, beautyLevel: 0, whitenessLevel: 0, videoOrientation: 'vertical', videoAspect: '9:16', frontCamera: 'front', enableRemoteMirror: !1, localMirror: 'auto', enableBackgroundMute: !1, audioQuality: 'high', audioVolumeType: 'voicecall', audioReverbType: 0, waitingImage: 'https://mc.qcloudimg.com/static/img/daeed8616ac5df256c0591c22a65c4d3/pause_publish.jpg', waitingImageHash: '', beautyStyle: 'smooth', filter: '', netStatus: {} }; const f = { src: '', mode: 'RTC', autoplay: !0, muteAudio: !0, muteVideo: !0, orientation: 'vertical', objectFit: 'fillCrop', enableBackgroundMute: !1, minCache: 1, maxCache: 2, soundMode: 'speaker', enableRecvMessage: !1, autoPauseIfNavigate: !0, autoPauseIfOpenNative: !0, isVisible: !0, _definitionType: 'main', netStatus: {} };(new Date).getTime();function d() { - const e = new Date;return e.setTime((new Date).getTime() + 0), e.toLocaleString(); - } function v(e) { - const t = this; let r = []; let s = [];this.length = function () { - return r.length; - }, this.sent = function () { - return s.length; - }, this.push = function (t) { - r.push(t), r.length > e && r.shift(); - }, this.send = function () { - return s.length || (s = r, r = []), s; - }, this.confirm = function () { - s = [], t.content = ''; - }, this.fail = function () { - r = s.concat(r), t.confirm();const i = 1 + r.length + s.length - e;i > 0 && (s.splice(0, i), r = s.concat(r), t.confirm()); - }; - } const g = new (function () { - function t() { - e(this, t), this.sdkAppId = '', this.userId = '', this.version = '', this.queue = new v(20); - } return r(t, [{ key: 'setConfig', value(e) { - this.sdkAppId = ''.concat(e.sdkAppId), this.userId = ''.concat(e.userId), this.version = ''.concat(e.version); - } }, { key: 'push', value(e) { - this.queue.push(e); - } }, { key: 'log', value(e) { - wx.request({ url: 'https://yun.tim.qq.com/v5/AVQualityReportSvc/C2S?sdkappid=1&cmdtype=jssdk_log', method: 'POST', header: { 'content-type': 'application/json' }, data: { timestamp: d(), sdkAppId: this.sdkAppId, userId: this.userId, version: this.version, log: e } }); - } }, { key: 'send', value() { - const e = this;if (!this.queue.sent()) { - if (!this.queue.length()) return;const t = this.queue.send();this.queue.content = 'string' !== typeof log ? '{"logs":['.concat(t.join(','), ']}') : t.join('\n'), wx.request({ url: 'https://yun.tim.qq.com/v5/AVQualityReportSvc/C2S?sdkappid=1&cmdtype=jssdk_log', method: 'POST', header: { 'content-type': 'application/json' }, data: { timestamp: d(), sdkAppId: this.sdkAppId, userId: this.userId, version: this.version, log: this.queue.content }, success() { - e.queue.confirm(); - }, fail() { - e.queue.fail(); - } }); - } - } }]), t; - }()); const y = (function () { - function t(r, s) { - e(this, t), this.context = wx.createLivePusherContext(s), this.pusherAttributes = {}, Object.assign(this.pusherAttributes, m, r); - } return r(t, [{ key: 'setPusherAttributes', value(e) { - return Object.assign(this.pusherAttributes, e), this.pusherAttributes; - } }, { key: 'start', value(e) { - l.log('[apiLog][pusherStart]'), g.log('pusherStart'), this.context.start(e); - } }, { key: 'stop', value(e) { - l.log('[apiLog][pusherStop]'), g.log('pusherStop'), this.context.stop(e); - } }, { key: 'pause', value(e) { - l.log('[apiLog] pusherPause()'), g.log('pusherPause'), this.context.pause(e); - } }, { key: 'resume', value(e) { - l.log('[apiLog][pusherResume]'), g.log('pusherResume'), this.context.resume(e); - } }, { key: 'switchCamera', value(e) { - return l.log('[apiLog][switchCamera]'), this.pusherAttributes.frontCamera = 'front' === this.pusherAttributes.frontCamera ? 'back' : 'front', this.context.switchCamera(e), this.pusherAttributes; - } }, { key: 'sendMessage', value(e) { - l.log('[apiLog][sendMessage]', e.msg), this.context.sendMessage(e); - } }, { key: 'snapshot', value() { - const e = this;return l.log('[apiLog][pusherSnapshot]'), new Promise(((t, r) => { - e.context.snapshot({ quality: 'raw', complete(e) { - e.tempImagePath ? (wx.saveImageToPhotosAlbum({ filePath: e.tempImagePath, success(r) { - t(e); - }, fail(e) { - l.error('[error] pusher截图失败: ', e), r(new Error('截图失败')); - } }), t(e)) : (l.error('[error] snapShot 回调失败', e), r(new Error('截图失败'))); - } }); - })); - } }, { key: 'toggleTorch', value(e) { - this.context.toggleTorch(e); - } }, { key: 'startDumpAudio', value(e) { - this.context.startDumpAudio(e); - } }, { key: 'stopDumpAudio', value(e) { - this.context.startDumpAudio(e); - } }, { key: 'playBGM', value(e) { - l.log('[apiLog] playBGM() url: ', e.url), this.context.playBGM(e); - } }, { key: 'pauseBGM', value(e) { - l.log('[apiLog] pauseBGM()'), this.context.pauseBGM(e); - } }, { key: 'resumeBGM', value(e) { - l.log('[apiLog] resumeBGM()'), this.context.resumeBGM(e); - } }, { key: 'stopBGM', value(e) { - l.log('[apiLog] stopBGM()'), this.context.stopBGM(e); - } }, { key: 'setBGMVolume', value(e) { - l.log('[apiLog] setBGMVolume() volume:', e.volume), this.context.setBGMVolume(e.volume); - } }, { key: 'setMICVolume', value(e) { - l.log('[apiLog] setMICVolume() volume:', e.volume), this.context.setMICVolume(e.volume); - } }, { key: 'startPreview', value(e) { - l.log('[apiLog] startPreview()'), this.context.startPreview(e); - } }, { key: 'stopPreview', value(e) { - l.log('[apiLog] stopPreview()'), this.context.stopPreview(e); - } }, { key: 'reset', value() { - return console.log('Pusher reset', this.context), this.pusherConfig = {}, this.context && (this.stop({ success() { - console.log('Pusher context.stop()'); - } }), this.context = null), this.pusherAttributes; - } }]), t; - }()); const E = function t(r) { - e(this, t), Object.assign(this, { userID: '', streams: {} }, r); - }; const A = (function () { - function t(r, s) { - e(this, t), this.ctx = s, this.playerAttributes = {}, Object.assign(this.playerAttributes, f, { userID: '', streamType: '', streamID: '', id: '', hasVideo: !1, hasAudio: !1, volume: 0, playerContext: void 0 }, r); - } return r(t, [{ key: 'play', value(e) { - this.getPlayerContext().play(e); - } }, { key: 'stop', value(e) { - this.getPlayerContext().stop(e); - } }, { key: 'mute', value(e) { - this.getPlayerContext().mute(e); - } }, { key: 'pause', value(e) { - this.getPlayerContext().pause(e); - } }, { key: 'resume', value(e) { - this.getPlayerContext().resume(e); - } }, { key: 'requestFullScreen', value(e) { - const t = this;return new Promise(((r, s) => { - t.getPlayerContext().requestFullScreen({ direction: e.direction, success(e) { - r(e); - }, fail(e) { - s(e); - } }); - })); - } }, { key: 'requestExitFullScreen', value() { - const e = this;return new Promise(((t, r) => { - e.getPlayerContext().exitFullScreen({ success(e) { - t(e); - }, fail(e) { - r(e); - } }); - })); - } }, { key: 'snapshot', value(e) { - const t = this;return l.log('[playerSnapshot]', e), new Promise(((e, r) => { - t.getPlayerContext().snapshot({ quality: 'raw', complete(t) { - t.tempImagePath ? (wx.saveImageToPhotosAlbum({ filePath: t.tempImagePath, success(r) { - l.log('save photo is success', r), e(t); - }, fail(e) { - l.error('save photo is fail', e), r(e); - } }), e(t)) : (l.error('snapShot 回调失败', t), r(new Error('截图失败'))); - } }); - })); - } }, { key: 'setPlayerAttributes', value(e) { - Object.assign(this.playerAttributes, e); - } }, { key: 'getPlayerContext', value() { - return this.playerContext || (this.playerContext = wx.createLivePlayerContext(this.playerAttributes.id, this.ctx)), this.playerContext; - } }, { key: 'reset', value() { - this.playerContext && (this.playerContext.stop(), this.playerContext = void 0), Object.assign(this.playerAttributes, f, { userID: '', streamType: '', streamID: '', hasVideo: !1, hasAudio: !1, volume: 0, playerContext: void 0 }); - } }]), t; - }()); const _ = 'UserController'; const I = (function () { - function t(r, s) { - e(this, t), this.ctx = s, this.userMap = new Map, this.userList = [], this.streamList = [], this.emitter = r; - } return r(t, [{ key: 'userEventHandler', value(e) { - const t = e.detail.code; const r = e.detail.message;switch (t) { - case 0:l.log(r, t);break;case 1001:l.log('已经连接推流服务器', t);break;case 1002:l.log('已经与服务器握手完毕,开始推流', t);break;case 1003:l.log('打开摄像头成功', t);break;case 1004:l.log('录屏启动成功', t);break;case 1005:l.log('推流动态调整分辨率', t);break;case 1006:l.log('推流动态调整码率', t);break;case 1007:l.log('首帧画面采集完成', t);break;case 1008:l.log('编码器启动', t);break;case 1018:l.log('进房成功', t), g.log('event enterRoom success '.concat(t)), this.emitter.emit(p.LOCAL_JOIN);break;case 1019:l.log('退出房间', t), r.indexOf('reason[0]') > -1 ? g.log('event exitRoom '.concat(t)) : (g.log('event abnormal exitRoom '.concat(r)), this.emitter.emit(p.KICKED_OUT));break;case 2003:l.log('渲染首帧视频', t);break;case -1301:l.error('打开摄像头失败: ', t), g.log('event start camera failed: '.concat(t)), this.emitter.emit(p.ERROR, { code: t, message: r });break;case -1302:l.error('打开麦克风失败: ', t), g.log('event start microphone failed: '.concat(t)), this.emitter.emit(p.ERROR, { code: t, message: r });break;case -1303:l.error('视频编码失败: ', t), g.log('event video encode failed: '.concat(t)), this.emitter.emit(p.ERROR, { code: t, message: r });break;case -1304:l.error('音频编码失败: ', t), g.log('event audio encode failed: '.concat(t)), this.emitter.emit(p.ERROR, { code: t, message: r });break;case -1307:l.error('推流连接断开: ', t), this.emitter.emit(p.ERROR, { code: t, message: r });break;case -100018:l.error('进房失败: userSig 校验失败,请检查 userSig 是否填写正确', t, r), this.emitter.emit(p.ERROR, { code: t, message: r });break;case 5e3:l.log('小程序被挂起: ', t), g.log('小程序被挂起: 5000');break;case 5001:l.log('小程序悬浮窗被关闭: ', t);break;case 1021:l.log('网络类型发生变化,需要重新进房', t);break;case 2007:l.log('本地视频播放loading: ', t);break;case 2004:l.log('本地视频播放开始: ', t);break;case 1031:case 1032:case 1033:case 1034:this._handleUserEvent(e); - } - } }, { key: '_handleUserEvent', value(e) { - let t; const r = e.detail.code; const s = e.detail.message;if (!e.detail.message || 'string' !== typeof s) return l.warn(_, 'userEventHandler 数据格式错误'), !1;try { - t = JSON.parse(e.detail.message); - } catch (e) { - return l.warn(_, 'userEventHandler 数据格式错误', e), !1; - } switch (this.emitter.emit(p.LOCAL_STATE_UPDATE, e), g.log('event code: '.concat(r, ', data: ').concat(JSON.stringify(t))), r) { - case 1031:this.addUser(t);break;case 1032:this.removeUser(t);break;case 1033:this.updateUserVideo(t);break;case 1034:this.updateUserAudio(t); - } - } }, { key: 'addUser', value(e) { - const t = this;l.log('addUser', e);const r = e.userlist;Array.isArray(r) && r.length > 0 && r.forEach(((e) => { - const r = e.userid; let s = t.getUser(r);s || (s = new E({ userID: r }), t.userList.push({ userID: r })), t.userMap.set(r, s), t.emitter.emit(p.REMOTE_USER_JOIN, { userID: r, userList: t.userList, playerList: t.getPlayerList() }); - })); - } }, { key: 'removeUser', value(e) { - const t = this; const r = e.userlist;Array.isArray(r) && r.length > 0 && r.forEach(((e) => { - const r = e.userid; let s = t.getUser(r);s && s.streams && (t._removeUserAndStream(r), s.streams.main && s.streams.main.reset(), s.streams.aux && s.streams.aux.reset(), t.emitter.emit(p.REMOTE_USER_LEAVE, { userID: r, userList: t.userList, playerList: t.getPlayerList() }), s = void 0, t.userMap.delete(r)); - })); - } }, { key: 'updateUserVideo', value(e) { - const t = this;l.log(_, 'updateUserVideo', e);const r = e.userlist;Array.isArray(r) && r.length > 0 && r.forEach(((e) => { - const r = e.userid; const s = e.streamtype; const i = ''.concat(r, '_').concat(s); const a = i; const n = e.hasvideo; const o = e.playurl; const u = t.getUser(r);if (u) { - let c = u.streams[s];l.log(_, 'updateUserVideo start', u, s, c), c ? (c.setPlayerAttributes({ hasVideo: n }), n || c.playerAttributes.hasAudio || t._removeStream(c)) : (c = new A({ userID: r, streamID: i, hasVideo: n, src: o, streamType: s, id: a }, t.ctx), u.streams[s] = c, t._addStream(c)), 'aux' === s && (n ? (c.objectFit = 'contain', t._addStream(c)) : t._removeStream(c)), t.userList.find(((e) => { - if (e.userID === r) return e['has'.concat(s.replace(/^\S/, (e => e.toUpperCase())), 'Video')] = n, !0; - })), l.log(_, 'updateUserVideo end', u, s, c);const h = n ? p.REMOTE_VIDEO_ADD : p.REMOTE_VIDEO_REMOVE;t.emitter.emit(h, { player: c.playerAttributes, userList: t.userList, playerList: t.getPlayerList() }); - } - })); - } }, { key: 'updateUserAudio', value(e) { - const t = this; const r = e.userlist;Array.isArray(r) && r.length > 0 && r.forEach(((e) => { - const r = e.userid; const s = 'main'; const i = ''.concat(r, '_').concat(s); const a = i; const n = e.hasaudio; const o = e.playurl; const u = t.getUser(r);if (u) { - let c = u.streams.main;c ? (c.setPlayerAttributes({ hasAudio: n }), n || c.playerAttributes.hasVideo || t._removeStream(c)) : (c = new A({ userID: r, streamID: i, hasAudio: n, src: o, streamType: s, id: a }, t.ctx), u.streams.main = c, t._addStream(c)), t.userList.find(((e) => { - if (e.userID === r) return e['has'.concat(s.replace(/^\S/, (e => e.toUpperCase())), 'Audio')] = n, !0; - }));const l = n ? p.REMOTE_AUDIO_ADD : p.REMOTE_AUDIO_REMOVE;t.emitter.emit(l, { player: c.playerAttributes, userList: t.userList, playerList: t.getPlayerList() }); - } - })); - } }, { key: 'getUser', value(e) { - return this.userMap.get(e); - } }, { key: 'getStream', value(e) { - const t = e.userID; const r = e.streamType; const s = this.userMap.get(t);if (s) return s.streams[r]; - } }, { key: 'getUserList', value() { - return this.userList; - } }, { key: 'getStreamList', value() { - return this.streamList; - } }, { key: 'getPlayerList', value() { - for (var e = this.getStreamList(), t = [], r = 0;r < e.length;r++)t.push(e[r].playerAttributes);return t; - } }, { key: 'reset', value() { - return this.streamList.forEach(((e) => { - e.reset(); - })), this.streamList = [], this.userList = [], this.userMap.clear(), { userList: this.userList, streamList: this.streamList }; - } }, { key: '_removeUserAndStream', value(e) { - this.streamList = this.streamList.filter((t => t.playerAttributes.userID !== e && '' !== t.playerAttributes.userID)), this.userList = this.userList.filter((t => t.userID !== e)); - } }, { key: '_addStream', value(e) { - this.streamList.includes(e) || this.streamList.push(e); - } }, { key: '_removeStream', value(e) { - this.streamList = this.streamList.filter((t => t.playerAttributes.userID !== e.playerAttributes.userID || t.playerAttributes.streamType !== e.playerAttributes.streamType)), this.getUser(e.playerAttributes.userID).streams[e.playerAttributes.streamType] = void 0; - } }]), t; - }()); const L = (function () { - function t() { - e(this, t); - } return r(t, [{ key: 'on', value(e, t, r) { - 'function' === typeof t ? (this._stores = this._stores || {}, (this._stores[e] = this._stores[e] || []).push({ cb: t, ctx: r })) : console.error('listener must be a function'); - } }, { key: 'emit', value(e) { - this._stores = this._stores || {};let t; let r = this._stores[e];if (r) { - r = r.slice(0), (t = [].slice.call(arguments, 1))[0] = { eventCode: e, data: t[0] };for (let s = 0, i = r.length;s < i;s++)r[s].cb.apply(r[s].ctx, t); - } - } }, { key: 'off', value(e, t) { - if (this._stores = this._stores || {}, arguments.length) { - const r = this._stores[e];if (r) if (1 !== arguments.length) { - for (let s = 0, i = r.length;s < i;s++) if (r[s].cb === t) { - r.splice(s, 1);break; - } - } else delete this._stores[e]; - } else this._stores = {}; - } }]), t; - }());return (function () { - function t(r, s) { - const i = this;e(this, t), this.ctx = r, this.eventEmitter = new L, this.pusherInstance = null, this.userController = new I(this.eventEmitter, this.ctx), this.EVENT = p, 'test' !== s ? wx.getSystemInfo({ success(e) { - return i.systemInfo = e; - } }) : (g.log = function () {}, l.log = function () {}, l.warn = function () {}); - } return r(t, [{ key: 'on', value(e, t, r) { - l.log('[on] 事件订阅: '.concat(e)), this.eventEmitter.on(e, t, r); - } }, { key: 'off', value(e, t) { - l.log('[off] 取消订阅: '.concat(e)), this.eventEmitter.off(e, t); - } }, { key: 'createPusher', value(e) { - return this.pusherInstance = new y(e, this.ctx), console.log('pusherInstance', this.pusherInstance), this.pusherInstance; - } }, { key: 'getPusherInstance', value() { - return this.pusherInstance; - } }, { key: 'enterRoom', value(e) { - l.log('[apiLog] [enterRoom]', e);const t = (function (e) { - if (!h(e)) return null;e.scene = e.scene && 'rtc' !== e.scene ? e.scene : 'videocall', e.enableBlackStream = e.enableBlackStream || '', e.encsmall = e.encsmall || 0, e.cloudenv = e.cloudenv || 'PRO', e.streamID = e.streamID || '', e.userDefineRecordID = e.userDefineRecordID || '', e.privateMapKey = e.privateMapKey || '', e.pureAudioMode = e.pureAudioMode || '', e.recvMode = e.recvMode || 1;let t = '';return t = e.strRoomID ? '&strroomid='.concat(e.strRoomID) : '&roomid='.concat(e.roomID), 'room://cloud.tencent.com/rtc?sdkappid='.concat(e.sdkAppID).concat(t, '&userid=') - .concat(e.userID, '&usersig=') - .concat(e.userSig, '&appscene=') - .concat(e.scene, '&encsmall=') - .concat(e.encsmall, '&cloudenv=') - .concat(e.cloudenv, '&enableBlackStream=') - .concat(e.enableBlackStream, '&streamid=') - .concat(e.streamID, '&userdefinerecordid=') - .concat(e.userDefineRecordID, '&privatemapkey=') - .concat(e.privateMapKey, '&pureaudiomode=') - .concat(e.pureAudioMode, '&recvmode=') - .concat(e.recvMode); - }(e));return t || this.eventEmitter.emit(p.ERROR, { message: '进房参数错误' }), g.setConfig({ sdkAppId: e.sdkAppID, userId: e.userID, version: 'wechat-mini' }), this.pusherInstance.setPusherAttributes(a(a({}, e), {}, { url: t })), l.warn('[statusLog] [enterRoom]', this.pusherInstance.pusherAttributes), g.log('api-enterRoom'), g.log('pusherConfig: '.concat(JSON.stringify(this.pusherInstance.pusherAttributes))), this.getPusherAttributes(); - } }, { key: 'exitRoom', value() { - g.log('api-exitRoom'), this.userController.reset();const e = Object.assign({ pusher: this.pusherInstance.reset() }, { playerList: this.userController.getPlayerList() });return this.eventEmitter.emit(p.LOCAL_LEAVE), e; - } }, { key: 'getPlayerList', value() { - const e = this.userController.getPlayerList();return l.log('[apiLog][getStreamList]', e), e; - } }, { key: 'setPusherAttributes', value(e) { - return l.log('[apiLog] [setPusherAttributes], ', e), this.pusherInstance.setPusherAttributes(e), l.warn('[statusLog] [setPusherAttributes]', this.pusherInstance.pusherAttributes), g.log('api-setPusherAttributes '.concat(JSON.stringify(e))), this.pusherInstance.pusherAttributes; - } }, { key: 'getPusherAttributes', value() { - return l.log('[apiLog] [getPusherConfig]'), this.pusherInstance.pusherAttributes; - } }, { key: 'setPlayerAttributes', value(e, t) { - l.log('[apiLog] [setPlayerAttributes] id', e, 'options: ', t);const r = this._transformStreamID(e); const s = r.userID; const i = r.streamType; const a = this.userController.getStream({ userID: s, streamType: i });return a ? (a.setPlayerAttributes(t), g.log('api-setPlayerAttributes id: '.concat(e, ' options: ').concat(JSON.stringify(t))), this.getPlayerList()) : this.getPlayerList(); - } }, { key: 'getPlayerInstance', value(e) { - const t = this._transformStreamID(e); const r = t.userID; const s = t.streamType;return l.log('[api][getPlayerInstance] id:', e), this.userController.getStream({ userID: r, streamType: s }); - } }, { key: 'switchStreamType', value(e) { - l.log('[apiLog] [switchStreamType] id: ', e);const t = this._transformStreamID(e); const r = t.userID; const s = t.streamType; const i = this.userController.getStream({ userID: r, streamType: s });return 'main' === i._definitionType ? (i.src = i.src.replace('main', 'small'), i._definitionType = 'small') : (i.src = i.src.replace('small', 'main'), i._definitionType = 'main'), this.getPlayerList(); - } }, { key: 'pusherEventHandler', value(e) { - this.userController.userEventHandler(e); - } }, { key: 'pusherNetStatusHandler', value(e) { - const t = e.detail.info;this.pusherInstance.setPusherAttributes(t), this.eventEmitter.emit(p.LOCAL_NET_STATE_UPDATE, { pusher: this.pusherInstance.pusherAttributes }); - } }, { key: 'pusherErrorHandler', value(e) { - try { - const t = e.detail.errCode; const r = e.detail.errMsg;this.eventEmitter.emit(p.ERROR, { code: t, message: r }); - } catch (t) { - l.error('pusher error data parser exception', e, t); - } - } }, { key: 'pusherBGMStartHandler', value(e) { - this.eventEmitter.emit(p.BGM_PLAY_START); - } }, { key: 'pusherBGMProgressHandler', value(e) { - let t; let r; let s; let i;this.eventEmitter.emit(p.BGM_PLAY_PROGRESS, { progress: null === (t = e.data) || void 0 === t || null === (r = t.detail) || void 0 === r ? void 0 : r.progress, duration: null === (s = e.data) || void 0 === s || null === (i = s.detail) || void 0 === i ? void 0 : i.duration }); - } }, { key: 'pusherBGMCompleteHandler', value(e) { - this.eventEmitter.emit(p.BGM_PLAY_COMPLETE); - } }, { key: 'pusherAudioVolumeNotify', value(e) { - this.pusherInstance.pusherAttributes.volume = e.detail.volume, this.eventEmitter.emit(p.LOCAL_AUDIO_VOLUME_UPDATE, { pusher: this.pusherInstance.pusherAttributes }); - } }, { key: 'playerEventHandler', value(e) { - l.log('[statusLog][playerStateChange]', e), this.eventEmitter.emit(p.REMOTE_STATE_UPDATE, e); - } }, { key: 'playerFullscreenChange', value(e) { - this.eventEmitter.emit(p.VIDEO_FULLSCREEN_UPDATE); - } }, { key: 'playerNetStatus', value(e) { - const t = this._transformStreamID(e.currentTarget.dataset.streamid); const r = t.userID; const s = t.streamType; const i = this.userController.getStream({ userID: r, streamType: s });!i || i.videoWidth === e.detail.info.videoWidth && i.videoHeight === e.detail.info.videoHeight || (i.setPlayerAttributes({ netStatus: e.detail.info }), this.eventEmitter.emit(p.REMOTE_NET_STATE_UPDATE, { playerList: this.userController.getPlayerList() })); - } }, { key: 'playerAudioVolumeNotify', value(e) { - const t = this._transformStreamID(e.currentTarget.dataset.streamid); const r = t.userID; const s = t.streamType; const i = this.userController.getStream({ userID: r, streamType: s }); const a = e.detail.volume;i.setPlayerAttributes({ volume: a }), this.eventEmitter.emit(p.REMOTE_AUDIO_VOLUME_UPDATE, { playerList: this.userController.getPlayerList() }); - } }, { key: '_transformStreamID', value(e) { - const t = e.lastIndexOf('_');return { userID: e.slice(0, t), streamType: e.slice(t + 1) }; - } }]), t; - }()); -}))); -// # sourceMappingURL=trtc-wx.js.map +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).TRTC=t()}(this,(function(){"use strict";function e(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function t(e,t){for(var r=0;r4294967296)?(c.error("roomID 超出取值范围 1 ~ 4294967295"),!1):e.strRoomID&&t.test(e.strRoomID)?(c.error("strRoomID 请勿使用中文字符"),!1):e.userID?e.userID&&t.test(e.userID)?(c.error("userID 请勿使用中文字符"),!1):!!e.userSig||(c.error("未设置 userSig"),!1):(c.error("未设置 userID"),!1):(c.error("未设置 sdkAppID"),!1)},m={LOCAL_JOIN:"LOCAL_JOIN",LOCAL_LEAVE:"LOCAL_LEAVE",KICKED_OUT:"KICKED_OUT",REMOTE_USER_JOIN:"REMOTE_USER_JOIN",REMOTE_USER_LEAVE:"REMOTE_USER_LEAVE",REMOTE_VIDEO_ADD:"REMOTE_VIDEO_ADD",REMOTE_VIDEO_REMOVE:"REMOTE_VIDEO_REMOVE",REMOTE_AUDIO_ADD:"REMOTE_AUDIO_ADD",REMOTE_AUDIO_REMOVE:"REMOTE_AUDIO_REMOVE",REMOTE_STATE_UPDATE:"REMOTE_STATE_UPDATE",LOCAL_NET_STATE_UPDATE:"LOCAL_NET_STATE_UPDATE",REMOTE_NET_STATE_UPDATE:"REMOTE_NET_STATE_UPDATE",LOCAL_AUDIO_VOLUME_UPDATE:"LOCAL_AUDIO_VOLUME_UPDATE",REMOTE_AUDIO_VOLUME_UPDATE:"REMOTE_AUDIO_VOLUME_UPDATE",VIDEO_FULLSCREEN_UPDATE:"VIDEO_FULLSCREEN_UPDATE",BGM_PLAY_START:"BGM_PLAY_START",BGM_PLAY_FAIL:"BGM_PLAY_FAIL",BGM_PLAY_PROGRESS:"BGM_PLAY_PROGRESS",BGM_PLAY_COMPLETE:"BGM_PLAY_COMPLETE",ERROR:"ERROR",IM_READY:"IM_READY",IM_MESSAGE_RECEIVED:"IM_MESSAGE_RECEIVED",IM_NOT_READY:"IM_NOT_READY",IM_KICKED_OUT:"IM_KICKED_OUT",IM_ERROR:"IM_ERROR"},p={url:"",mode:"RTC",autopush:!1,enableCamera:!1,enableMic:!1,enableAgc:!1,enableAns:!1,enableEarMonitor:!1,enableAutoFocus:!0,enableZoom:!1,minBitrate:600,maxBitrate:900,videoWidth:360,videoHeight:640,beautyLevel:0,whitenessLevel:0,videoOrientation:"vertical",videoAspect:"9:16",frontCamera:"front",enableRemoteMirror:!1,localMirror:"auto",enableBackgroundMute:!1,audioQuality:"high",audioVolumeType:"voicecall",audioReverbType:0,waitingImage:"",waitingImageHash:"",beautyStyle:"smooth",filter:"",netStatus:{}},d={src:"",mode:"RTC",autoplay:!0,muteAudio:!0,muteVideo:!0,orientation:"vertical",objectFit:"fillCrop",enableBackgroundMute:!1,minCache:1,maxCache:2,soundMode:"speaker",enableRecvMessage:!1,autoPauseIfNavigate:!0,autoPauseIfOpenNative:!0,isVisible:!0,_definitionType:"main",netStatus:{}};(new Date).getTime();function v(){var e=new Date;return e.setTime((new Date).getTime()+0),e.toLocaleString()}var g=function(e){var t=[];if(e&&e.TUIScene&&t.push(e.TUIScene),e&&"test"===e.env)return"default";if(wx&&wx.TUIScene&&t.push(wx.TUIScene),wx&&"function"==typeof getApp){var r=getApp().globalData;r&&r.TUIScene&&t.push(r.TUIScene)}return wx&&wx.getStorage({key:"TUIScene",success:function(e){t.push(e.data)}}),t[0]||"default"},y=new(function(){function t(){e(this,t),this.sdkAppId="",this.userId="",this.version="",this.common={}}return r(t,[{key:"setConfig",value:function(e){this.sdkAppId="".concat(e.sdkAppId),this.userId="".concat(e.userId),this.version="".concat(e.version),this.common.TUIScene=g(e)}},{key:"log",value:function(e){wx.request({url:"https://yun.tim.qq.com/v5/AVQualityReportSvc/C2S?sdkappid=1&cmdtype=jssdk_log",method:"POST",header:{"content-type":"application/json"},data:{timestamp:v(),sdkAppId:this.sdkAppId,userId:this.userId,version:this.version,log:JSON.stringify(i(i({},e),this.common))}})}}]),t}()),f="enterRoom",E="exitRoom",A="setPusherAttributes",I="setPlayerAttributes",_="init",L="error",D="connectServer",T="startPusher",b="openCamera",O="screenCap",k="pusherResolution",R="pusherCodeRate",P="collectionFirstFrame",S="encoderStart",M="enterRoomSuccess",U="exitRoomSuccess",C="kicked_out",x="renderFirstFrame",w="miniAppHang",V="closeSuspension",B="other",G="update",N="addUser",j="remove_user",F="update_user_video",H="update_user_audio",Y="pusherStart",K="pusherStop",q="pusherPause",J="pusherResume",W=function(){function t(r,s){e(this,t),this.context=wx.createLivePusherContext(s),this.pusherAttributes={},Object.assign(this.pusherAttributes,p,r)}return r(t,[{key:"setPusherAttributes",value:function(e){return Object.assign(this.pusherAttributes,e),this.pusherAttributes}},{key:"start",value:function(e){c.log("[apiLog][pusherStart]"),y.log({name:Y,options:e}),this.context.start(e)}},{key:"stop",value:function(e){c.log("[apiLog][pusherStop]"),y.log({name:K,options:e}),this.context.stop(e)}},{key:"pause",value:function(e){c.log("[apiLog] pusherPause()"),y.log({name:q,options:e}),this.context.pause(e)}},{key:"resume",value:function(e){c.log("[apiLog][pusherResume]"),y.log({name:J,options:e}),this.context.resume(e)}},{key:"switchCamera",value:function(e){return c.log("[apiLog][switchCamera]"),this.pusherAttributes.frontCamera="front"===this.pusherAttributes.frontCamera?"back":"front",this.context.switchCamera(e),this.pusherAttributes}},{key:"sendMessage",value:function(e){c.log("[apiLog][sendMessage]",e.msg),this.context.sendMessage(e)}},{key:"snapshot",value:function(){var e=this;return c.log("[apiLog][pusherSnapshot]"),new Promise((function(t,r){e.context.snapshot({quality:"raw",complete:function(e){e.tempImagePath?(wx.saveImageToPhotosAlbum({filePath:e.tempImagePath,success:function(r){t(e)},fail:function(e){c.error("[error] pusher截图失败: ",e),r(new Error("截图失败"))}}),t(e)):(c.error("[error] snapShot 回调失败",e),r(new Error("截图失败")))}})}))}},{key:"toggleTorch",value:function(e){this.context.toggleTorch(e)}},{key:"startDumpAudio",value:function(e){this.context.startDumpAudio(e)}},{key:"stopDumpAudio",value:function(e){this.context.startDumpAudio(e)}},{key:"playBGM",value:function(e){c.log("[apiLog] playBGM() url: ",e.url),this.context.playBGM(e)}},{key:"pauseBGM",value:function(e){c.log("[apiLog] pauseBGM()"),this.context.pauseBGM(e)}},{key:"resumeBGM",value:function(e){c.log("[apiLog] resumeBGM()"),this.context.resumeBGM(e)}},{key:"stopBGM",value:function(e){c.log("[apiLog] stopBGM()"),this.context.stopBGM(e)}},{key:"setBGMVolume",value:function(e){c.log("[apiLog] setBGMVolume() volume:",e.volume),this.context.setBGMVolume(e.volume)}},{key:"setMICVolume",value:function(e){c.log("[apiLog] setMICVolume() volume:",e.volume),this.context.setMICVolume(e.volume)}},{key:"startPreview",value:function(e){c.log("[apiLog] startPreview()"),this.context.startPreview(e)}},{key:"stopPreview",value:function(e){c.log("[apiLog] stopPreview()"),this.context.stopPreview(e)}},{key:"reset",value:function(){return console.log("Pusher reset",this.context),this.pusherConfig={},this.context&&(this.stop({success:function(){console.log("Pusher context.stop()")}}),this.context=null),this.pusherAttributes}}]),t}(),Q=function t(r){e(this,t),Object.assign(this,{userID:"",streams:{}},r)},X=function(){function t(r,s){e(this,t),this.ctx=s,this.playerAttributes={},Object.assign(this.playerAttributes,d,{userID:"",streamType:"",streamID:"",id:"",hasVideo:!1,hasAudio:!1,volume:0,playerContext:void 0},r)}return r(t,[{key:"play",value:function(e){this.getPlayerContext().play(e)}},{key:"stop",value:function(e){this.getPlayerContext().stop(e)}},{key:"mute",value:function(e){this.getPlayerContext().mute(e)}},{key:"pause",value:function(e){this.getPlayerContext().pause(e)}},{key:"resume",value:function(e){this.getPlayerContext().resume(e)}},{key:"requestFullScreen",value:function(e){var t=this;return new Promise((function(r,s){t.getPlayerContext().requestFullScreen({direction:e.direction,success:function(e){r(e)},fail:function(e){s(e)}})}))}},{key:"requestExitFullScreen",value:function(){var e=this;return new Promise((function(t,r){e.getPlayerContext().exitFullScreen({success:function(e){t(e)},fail:function(e){r(e)}})}))}},{key:"snapshot",value:function(e){var t=this;return c.log("[playerSnapshot]",e),new Promise((function(e,r){t.getPlayerContext().snapshot({quality:"raw",complete:function(t){t.tempImagePath?(wx.saveImageToPhotosAlbum({filePath:t.tempImagePath,success:function(r){c.log("save photo is success",r),e(t)},fail:function(e){c.error("save photo is fail",e),r(e)}}),e(t)):(c.error("snapShot 回调失败",t),r(new Error("截图失败")))}})}))}},{key:"setPlayerAttributes",value:function(e){Object.assign(this.playerAttributes,e)}},{key:"getPlayerContext",value:function(){return this.playerContext||(this.playerContext=wx.createLivePlayerContext(this.playerAttributes.id,this.ctx)),this.playerContext}},{key:"reset",value:function(){this.playerContext&&(this.playerContext.stop(),this.playerContext=void 0),Object.assign(this.playerAttributes,d,{userID:"",streamType:"",streamID:"",hasVideo:!1,hasAudio:!1,volume:0,playerContext:void 0})}}]),t}(),Z="UserController",z=function(){function t(r,s){e(this,t),this.ctx=s,this.userMap=new Map,this.userList=[],this.streamList=[],this.emitter=r}return r(t,[{key:"userEventHandler",value:function(e){var t=e.detail.code,r=e.detail.message,s={name:B,code:t,message:r,data:""};switch(t){case 0:c.log(r,t);break;case 1001:c.log("已经连接推流服务器",t),s.name=D;break;case 1002:c.log("已经与服务器握手完毕,开始推流",t),s.name=T;break;case 1003:c.log("打开摄像头成功",t),s.name=b;break;case 1004:c.log("录屏启动成功",t),s.name=O;break;case 1005:c.log("推流动态调整分辨率",t),s.name=k;break;case 1006:c.log("推流动态调整码率",t),s.name=R;break;case 1007:c.log("首帧画面采集完成",t),s.name=P;break;case 1008:c.log("编码器启动",t),s.name=S;break;case 1018:c.log("进房成功",t),s.name=M,s.data="event enterRoom success",this.emitter.emit(m.LOCAL_JOIN);break;case 1019:c.log("退出房间",t),r.indexOf("reason[0]")>-1?(s.name=U,s.data="event exitRoom success"):(s.name=C,s.data="event abnormal exitRoom",this.emitter.emit(m.KICKED_OUT));break;case 2003:c.log("渲染首帧视频",t),s.name=x;break;case-1301:c.error("打开摄像头失败: ",t),s.name=L,s.data="event start camera failed",this.emitter.emit(m.ERROR,{code:t,message:r});break;case-1302:s.name=L,s.data="event start microphone failed",c.error("打开麦克风失败: ",t),this.emitter.emit(m.ERROR,{code:t,message:r});break;case-1303:c.error("视频编码失败: ",t),s.name=L,s.data="event video encode failed",this.emitter.emit(m.ERROR,{code:t,message:r});break;case-1304:c.error("音频编码失败: ",t),s.name=L,s.data="event audio encode failed",this.emitter.emit(m.ERROR,{code:t,message:r});break;case-1307:c.error("推流连接断开: ",t),s.name=L,s.data="event pusher stream failed",this.emitter.emit(m.ERROR,{code:t,message:r});break;case-100018:c.error("进房失败: userSig 校验失败,请检查 userSig 是否填写正确",t,r),s.name=L,s.data="event userSig is error",this.emitter.emit(m.ERROR,{code:t,message:r});break;case 5e3:c.log("小程序被挂起: ",t),s.name=w,s.data="miniApp is hang";break;case 5001:c.log("小程序悬浮窗被关闭: ",t),s.name=V;break;case 1021:c.log("网络类型发生变化,需要重新进房",t);break;case 2007:c.log("本地视频播放loading: ",t);break;case 2004:c.log("本地视频播放开始: ",t);break;case 1031:case 1032:case 1033:case 1034:this._handleUserEvent(e)}y.log(s)}},{key:"_handleUserEvent",value:function(e){var t,r=e.detail.code,s=e.detail.message;if(!e.detail.message||"string"!=typeof s)return c.warn(Z,"userEventHandler 数据格式错误"),!1;try{t=JSON.parse(e.detail.message)}catch(e){return c.warn(Z,"userEventHandler 数据格式错误",e),!1}switch(this.emitter.emit(m.LOCAL_STATE_UPDATE,e),y.log({name:G,code:r,message:s,data:t}),r){case 1031:this.addUser(t);break;case 1032:this.removeUser(t);break;case 1033:this.updateUserVideo(t);break;case 1034:this.updateUserAudio(t)}}},{key:"addUser",value:function(e){var t=this;c.log("addUser",e);var r=e.userlist;Array.isArray(r)&&r.length>0&&r.forEach((function(e){var r=e.userid,s=t.getUser(r);s||(s=new Q({userID:r}),t.userList.push({userID:r})),t.userMap.set(r,s),t.emitter.emit(m.REMOTE_USER_JOIN,{userID:r,userList:t.userList,playerList:t.getPlayerList()}),y.log({name:N,userID:r,userList:t.userList,playerList:t.getPlayerList()})}))}},{key:"removeUser",value:function(e){var t=this,r=e.userlist;Array.isArray(r)&&r.length>0&&r.forEach((function(e){var r=e.userid,s=t.getUser(r);s&&s.streams&&(t._removeUserAndStream(r),s.streams.main&&s.streams.main.reset(),s.streams.aux&&s.streams.aux.reset(),t.emitter.emit(m.REMOTE_USER_LEAVE,{userID:r,userList:t.userList,playerList:t.getPlayerList()}),y.log({name:j,userID:r,userList:t.userList,playerList:t.getPlayerList()}),s=void 0,t.userMap.delete(r))}))}},{key:"updateUserVideo",value:function(e){var t=this;c.log(Z,"updateUserVideo",e);var r=e.userlist;Array.isArray(r)&&r.length>0&&r.forEach((function(e){var r=e.userid,s=e.streamtype,a="".concat(r,"_").concat(s),i=a,n=e.hasvideo,o=e.playurl,u=t.getUser(r);if(u){var l=u.streams[s];c.log(Z,"updateUserVideo start",u,s,l),l?(l.setPlayerAttributes({hasVideo:n}),n||l.playerAttributes.hasAudio||t._removeStream(l)):(l=new X({userID:r,streamID:a,hasVideo:n,src:o,streamType:s,id:i},t.ctx),u.streams[s]=l,t._addStream(l)),"aux"===s&&(n?(l.objectFit="contain",t._addStream(l)):t._removeStream(l)),t.userList.find((function(e){if(e.userID===r)return e["has".concat(s.replace(/^\S/,(function(e){return e.toUpperCase()})),"Video")]=n,!0})),c.log(Z,"updateUserVideo end",u,s,l);var h=n?m.REMOTE_VIDEO_ADD:m.REMOTE_VIDEO_REMOVE;t.emitter.emit(h,{player:l.playerAttributes,userList:t.userList,playerList:t.getPlayerList()}),y.log({name:F,player:l.playerAttributes,userList:t.userList,playerList:t.getPlayerList()})}}))}},{key:"updateUserAudio",value:function(e){var t=this,r=e.userlist;Array.isArray(r)&&r.length>0&&r.forEach((function(e){var r=e.userid,s="main",a="".concat(r,"_").concat(s),i=a,n=e.hasaudio,o=e.playurl,u=t.getUser(r);if(u){var l=u.streams.main;l?(l.setPlayerAttributes({hasAudio:n}),n||l.playerAttributes.hasVideo||t._removeStream(l)):(l=new X({userID:r,streamID:a,hasAudio:n,src:o,streamType:s,id:i},t.ctx),u.streams.main=l,t._addStream(l)),t.userList.find((function(e){if(e.userID===r)return e["has".concat(s.replace(/^\S/,(function(e){return e.toUpperCase()})),"Audio")]=n,!0}));var c=n?m.REMOTE_AUDIO_ADD:m.REMOTE_AUDIO_REMOVE;t.emitter.emit(c,{player:l.playerAttributes,userList:t.userList,playerList:t.getPlayerList()}),y.log({name:H,player:l.playerAttributes,userList:t.userList,playerList:t.getPlayerList()})}}))}},{key:"getUser",value:function(e){return this.userMap.get(e)}},{key:"getStream",value:function(e){var t=e.userID,r=e.streamType,s=this.userMap.get(t);if(s)return s.streams[r]}},{key:"getUserList",value:function(){return this.userList}},{key:"getStreamList",value:function(){return this.streamList}},{key:"getPlayerList",value:function(){for(var e=this.getStreamList(),t=[],r=0;r (function (t) { - const e = {};function i(n) { - if (e[n]) return e[n].exports;const o = e[n] = { i: n, l: !1, exports: {} };return t[n].call(o.exports, o, o.exports, i), o.l = !0, o.exports; - } return i.m = t, i.c = e, i.d = function (t, e, n) { - i.o(t, e) || Object.defineProperty(t, e, { enumerable: !0, get: n }); - }, i.r = function (t) { - 'undefined' !== typeof Symbol && Symbol.toStringTag && Object.defineProperty(t, Symbol.toStringTag, { value: 'Module' }), Object.defineProperty(t, '__esModule', { value: !0 }); - }, i.t = function (t, e) { - if (1 & e && (t = i(t)), 8 & e) return t;if (4 & e && 'object' === typeof t && t && t.__esModule) return t;const n = Object.create(null);if (i.r(n), Object.defineProperty(n, 'default', { enumerable: !0, value: t }), 2 & e && 'string' !== typeof t) for (const o in t)i.d(n, o, (e => t[e]).bind(null, o));return n; - }, i.n = function (t) { - const e = t && t.__esModule ? function () { - return t.default; - } : function () { - return t; - };return i.d(e, 'a', e), e; - }, i.o = function (t, e) { - return Object.prototype.hasOwnProperty.call(t, e); - }, i.p = '', i(i.s = 5); -}([function (t, e, i) { - 'use strict';i.d(e, 'e', (() => p)), i.d(e, 'g', (() => h)), i.d(e, 'c', (() => g)), i.d(e, 'f', (() => v)), i.d(e, 'b', (() => m)), i.d(e, 'd', (() => T)), i.d(e, 'a', (() => y)), i.d(e, 'h', (() => N));const n = 'undefined' !== typeof window; const o = ('undefined' !== typeof wx && wx.getSystemInfoSync, n && window.navigator && window.navigator.userAgent || ''); const r = /AppleWebKit\/([\d.]+)/i.exec(o); const s = (r && parseFloat(r.pop()), /iPad/i.test(o)); const a = /iPhone/i.test(o) && !s; const u = /iPod/i.test(o); const l = a || s || u; const c = ((function () { - const t = o.match(/OS (\d+)_/i);t && t[1] && t[1]; - }()), /Android/i.test(o)); const d = (function () { - const t = o.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);if (!t) return null;const e = t[1] && parseFloat(t[1]); const i = t[2] && parseFloat(t[2]);return e && i ? parseFloat(`${t[1]}.${t[2]}`) : e || null; - }()); const f = (c && /webkit/i.test(o), /Firefox/i.test(o), /Edge/i.test(o)); const _ = !f && /Chrome/i.test(o); const I = ((function () { - const t = o.match(/Chrome\/(\d+)/);t && t[1] && parseFloat(t[1]); - }()), /MSIE/.test(o), /MSIE\s8\.0/.test(o), (function () { - const t = /MSIE\s(\d+)\.\d/.exec(o);let e = t && parseFloat(t[1]);!e && /Trident\/7.0/i.test(o) && /rv:11.0/.test(o) && (e = 11); - }()), /Safari/i.test(o), /TBS\/\d+/i.test(o));(function () { - const t = o.match(/TBS\/(\d+)/i);if (t && t[1])t[1]; - }()), !I && /MQQBrowser\/\d+/i.test(o), !I && / QQBrowser\/\d+/i.test(o), /(micromessenger|webbrowser)/i.test(o), /Windows/i.test(o), /MAC OS X/i.test(o), /MicroMessenger/i.test(o);i(2), i(1);const p = function (t) { - return 'map' === D(t); - }; const h = function (t) { - return 'set' === D(t); - }; const g = function (t) { - return 'file' === D(t); - }; const v = function (t) { - if ('object' !== typeof t || null === t) return !1;const e = Object.getPrototypeOf(t);if (null === e) return !0;let i = e;for (;null !== Object.getPrototypeOf(i);)i = Object.getPrototypeOf(i);return e === i; - }; const E = function (t) { - return 'function' === typeof Array.isArray ? Array.isArray(t) : 'array' === D(t); - }; const m = function (t) { - return E(t) || (function (t) { - return null !== t && 'object' === typeof t; - }(t)); - }; const T = function (t) { - return t instanceof Error; - }; const D = function (t) { - return Object.prototype.toString.call(t).match(/^\[object (.*)\]$/)[1].toLowerCase(); - };let S = 0;Date.now || (Date.now = function () { - return (new Date).getTime(); - });const y = { now() { - 0 === S && (S = Date.now() - 1);const t = Date.now() - S;return t > 4294967295 ? (S += 4294967295, Date.now() - S) : t; - }, utc() { - return Math.round(Date.now() / 1e3); - } }; const N = function (t) { - return JSON.stringify(t, ['message', 'code']); - }; -}, function (t, e, i) { - 'use strict';i.r(e);const n = i(3); const o = i(0);let r = 0;const s = new Map;function a() { - const t = new Date;return `TSignaling ${t.toLocaleTimeString('en-US', { hour12: !1 })}.${(function (t) { - let e;switch (t.toString().length) { - case 1:e = `00${t}`;break;case 2:e = `0${t}`;break;default:e = t; - } return e; - }(t.getMilliseconds()))}:`; - } const u = { _data: [], _length: 0, _visible: !1, arguments2String(t) { - let e;if (1 === t.length)e = a() + t[0];else { - e = a();for (let i = 0, n = t.length;i < n;i++)Object(o.b)(t[i]) ? Object(o.d)(t[i]) ? e += Object(o.h)(t[i]) : e += JSON.stringify(t[i]) : e += t[i], e += ' '; - } return e; - }, debug() { - if (r <= -1) { - const t = this.arguments2String(arguments);u.record(t, 'debug'), n.a.debug(t); - } - }, log() { - if (r <= 0) { - const t = this.arguments2String(arguments);u.record(t, 'log'), n.a.log(t); - } - }, info() { - if (r <= 1) { - const t = this.arguments2String(arguments);u.record(t, 'info'), n.a.info(t); - } - }, warn() { - if (r <= 2) { - const t = this.arguments2String(arguments);u.record(t, 'warn'), n.a.warn(t); - } - }, error() { - if (r <= 3) { - const t = this.arguments2String(arguments);u.record(t, 'error'), n.a.error(t); - } - }, time(t) { - s.set(t, o.a.now()); - }, timeEnd(t) { - if (s.has(t)) { - const e = o.a.now() - s.get(t);return s.delete(t), e; - } return n.a.warn(`未找到对应label: ${t}, 请在调用 logger.timeEnd 前,调用 logger.time`), 0; - }, setLevel(t) { - t < 4 && n.a.log(`${a()}set level from ${r} to ${t}`), r = t; - }, record(t, e) { - 1100 === u._length && (u._data.splice(0, 100), u._length = 1e3), u._length++, u._data.push(`${t} [${e}] \n`); - }, getLog() { - return u._data; - } };e.default = u; -}, function (t, e, i) { - 'use strict';i.r(e);e.default = { MSG_PRIORITY_HIGH: 'High', MSG_PRIORITY_NORMAL: 'Normal', MSG_PRIORITY_LOW: 'Low', MSG_PRIORITY_LOWEST: 'Lowest', KICKED_OUT_MULT_ACCOUNT: 'multipleAccount', KICKED_OUT_MULT_DEVICE: 'multipleDevice', KICKED_OUT_USERSIG_EXPIRED: 'userSigExpired', NET_STATE_CONNECTED: 'connected', NET_STATE_CONNECTING: 'connecting', NET_STATE_DISCONNECTED: 'disconnected', ENTER_ROOM_SUCCESS: 'JoinedSuccess', ALREADY_IN_ROOM: 'AlreadyInGroup' }; -}, function (t, e, i) { - 'use strict';(function (t) { - let i; let n;i = 'undefined' !== typeof console ? console : void 0 !== t && t.console ? t.console : 'undefined' !== typeof window && window.console ? window.console : {};const o = function () {}; const r = ['assert', 'clear', 'count', 'debug', 'dir', 'dirxml', 'error', 'exception', 'group', 'groupCollapsed', 'groupEnd', 'info', 'log', 'markTimeline', 'profile', 'profileEnd', 'table', 'time', 'timeEnd', 'timeStamp', 'trace', 'warn'];let s = r.length;for (;s--;)n = r[s], console[n] || (i[n] = o);i.methods = r, e.a = i; - }).call(this, i(8)); -}, function (t, e, i) { - 'use strict';Object.defineProperty(e, '__esModule', { value: !0 });e.default = { NEW_INVITATION_RECEIVED: 'ts_new_invitation_received', INVITEE_ACCEPTED: 'ts_invitee_accepted', INVITEE_REJECTED: 'ts_invitee_rejected', INVITATION_CANCELLED: 'ts_invitation_cancelled', INVITATION_TIMEOUT: 'ts_invitation_timeout', SDK_READY: 'ts_im_ready', SDK_NOT_READY: 'ts_im_not_ready', TEXT_MESSAGE_RECEIVED: 'ts_text_message_received', CUSTOM_MESSAGE_RECEIVED: 'ts_custom_message_received', REMOTE_USER_JOIN: 'ts_remote_user_join', REMOTE_USER_LEAVE: 'ts_remote_user_leave', KICKED_OUT: 'ts_kicked_out', NET_STATE_CHANGE: 'ts_net_state_change' }; -}, function (t, e, i) { - 'use strict';const n = this && this.__awaiter || function (t, e, i, n) { - return new (i || (i = Promise))(((o, r) => { - function s(t) { - try { - u(n.next(t)); - } catch (t) { - r(t); - } - } function a(t) { - try { - u(n.throw(t)); - } catch (t) { - r(t); - } - } function u(t) { - let e;t.done ? o(t.value) : (e = t.value, e instanceof i ? e : new i(((t) => { - t(e); - }))).then(s, a); - }u((n = n.apply(t, e || [])).next()); - })); - }; const o = this && this.__generator || function (t, e) { - let i; let n; let o; let r; let s = { label: 0, sent() { - if (1 & o[0]) throw o[1];return o[1]; - }, trys: [], ops: [] };return r = { next: a(0), throw: a(1), return: a(2) }, 'function' === typeof Symbol && (r[Symbol.iterator] = function () { - return this; - }), r;function a(r) { - return function (a) { - return (function (r) { - if (i) throw new TypeError('Generator is already executing.');for (;s;) try { - if (i = 1, n && (o = 2 & r[0] ? n.return : r[0] ? n.throw || ((o = n.return) && o.call(n), 0) : n.next) && !(o = o.call(n, r[1])).done) return o;switch (n = 0, o && (r = [2 & r[0], o.value]), r[0]) { - case 0:case 1:o = r;break;case 4:return s.label++, { value: r[1], done: !1 };case 5:s.label++, n = r[1], r = [0];continue;case 7:r = s.ops.pop(), s.trys.pop();continue;default:if (!(o = s.trys, (o = o.length > 0 && o[o.length - 1]) || 6 !== r[0] && 2 !== r[0])) { - s = 0;continue; - } if (3 === r[0] && (!o || r[1] > o[0] && r[1] < o[3])) { - s.label = r[1];break; - } if (6 === r[0] && s.label < o[1]) { - s.label = o[1], o = r;break; - } if (o && s.label < o[2]) { - s.label = o[2], s.ops.push(r);break; - }o[2] && s.ops.pop(), s.trys.pop();continue; - }r = e.call(t, s); - } catch (t) { - r = [6, t], n = 0; - } finally { - i = o = 0; - } if (5 & r[0]) throw r[1];return { value: r[0] ? r[1] : void 0, done: !0 }; - }([r, a])); - }; - } - }; const r = this && this.__spreadArrays || function () { - for (var t = 0, e = 0, i = arguments.length;e < i;e++)t += arguments[e].length;const n = Array(t); let o = 0;for (e = 0;e < i;e++) for (let r = arguments[e], s = 0, a = r.length;s < a;s++, o++)n[o] = r[s];return n; - };Object.defineProperty(e, '__esModule', { value: !0 });const s = i(6); const a = i(7); const u = i(4); const l = i(2); const c = i(1); const d = i(9); const f = i(10); const _ = i(11); const I = i(12); const p = i(14); const h = i(15).version; const g = (function () { - function t(t) { - if (this._outerEmitter = null, this._safetyCallbackFactory = null, this._tim = null, this._imSDKAppID = 0, this._userID = null, this._groupID = '', this._isHandling = !1, this._inviteInfoMap = new Map, c.default.info(`TSignaling version:${h}`), d.default(t.SDKAppID)) return c.default.error('TSignaling 请传入 SDKAppID !!!'), null;this._outerEmitter = new a.default, this._outerEmitter._emit = this._outerEmitter.emit, this._outerEmitter.emit = function () { - for (var t = [], e = 0;e < arguments.length;e++)t[e] = arguments[e];const i = t[0]; const n = [i, { name: t[0], data: t[1] }];this._outerEmitter._emit.apply(this._outerEmitter, r(n)); - }.bind(this), this._safetyCallbackFactory = new _.default, t.tim ? this._tim = t.tim : this._tim = p.create({ SDKAppID: t.SDKAppID, scene: 'TSignaling' }), this._imSDKAppID = t.SDKAppID, this._tim.on(p.EVENT.SDK_READY, this._onIMReady.bind(this)), this._tim.on(p.EVENT.SDK_NOT_READY, this._onIMNotReady.bind(this)), this._tim.on(p.EVENT.KICKED_OUT, this._onKickedOut.bind(this)), this._tim.on(p.EVENT.NET_STATE_CHANGE, this._onNetStateChange.bind(this)), this._tim.on(p.EVENT.MESSAGE_RECEIVED, this._onMessageReceived.bind(this)); - } return t.prototype.setLogLevel = function (t) { - c.default.setLevel(t), this._tim.setLogLevel(t); - }, t.prototype.login = function (t) { - return n(this, void 0, void 0, (function () { - return o(this, (function (e) { - return c.default.log('TSignaling.login', t), this._userID = t.userID, [2, this._tim.login(t)]; - })); - })); - }, t.prototype.logout = function () { - return n(this, void 0, void 0, (function () { - return o(this, (function (t) { - return c.default.log('TSignaling.logout'), this._userID = '', this._inviteInfoMap.clear(), [2, this._tim.logout()]; - })); - })); - }, t.prototype.on = function (t, e, i) { - c.default.log(`TSignaling.on eventName:${t}`), this._outerEmitter.on(t, this._safetyCallbackFactory.defense(t, e, i), i); - }, t.prototype.off = function (t, e) { - c.default.log(`TSignaling.off eventName:${t}`), this._outerEmitter.off(t, e); - }, t.prototype.joinGroup = function (t) { - return n(this, void 0, void 0, (function () { - return o(this, (function (e) { - return c.default.log(`TSignaling.joinGroup groupID:${t}`), this._groupID = t, [2, this._tim.joinGroup({ groupID: t })]; - })); - })); - }, t.prototype.quitGroup = function (t) { - return n(this, void 0, void 0, (function () { - return o(this, (function (e) { - return c.default.log(`TSignaling.quitGroup groupID:${t}`), [2, this._tim.quitGroup(t)]; - })); - })); - }, t.prototype.sendTextMessage = function (t) { - return n(this, void 0, void 0, (function () { - let e;return o(this, (function (i) { - return e = this._tim.createTextMessage({ to: t.to, conversationType: !0 === t.groupFlag ? p.TYPES.CONV_GROUP : p.TYPES.CONV_C2C, priority: t.priority || p.TYPES.MSG_PRIORITY_NORMAL, payload: { text: t.text } }), [2, this._tim.sendMessage(e)]; - })); - })); - }, t.prototype.sendCustomMessage = function (t) { - return n(this, void 0, void 0, (function () { - let e;return o(this, (function (i) { - return e = this._tim.createCustomMessage({ to: t.to, conversationType: !0 === t.groupFlag ? p.TYPES.CONV_GROUP : p.TYPES.CONV_C2C, priority: t.priority || p.TYPES.MSG_PRIORITY_NORMAL, payload: { data: t.data || '', description: t.description || '', extension: t.extension || '' } }), [2, this._tim.sendMessage(e)]; - })); - })); - }, t.prototype.invite = function (t) { - return n(this, void 0, void 0, (function () { - let e; let i; let n; let r; let a; let u; let l;return o(this, (function (o) { - switch (o.label) { - case 0:return e = I.generate(), c.default.log('TSignaling.invite', t, `inviteID=${e}`), d.default(t) || d.default(t.userID) ? [2, Promise.reject(new f.default({ code: s.ErrorCode.ERR_INVALID_PARAMETERS, message: 'userID is invalid' }))] : (i = t.userID, n = t.data, r = t.timeout, a = t.offlinePushInfo, u = { businessID: s.BusinessID.SIGNAL, inviteID: e, inviter: this._userID, actionType: s.ActionType.INVITE, inviteeList: [i], data: n, timeout: d.default(r) ? 0 : r, groupID: '' }, [4, this._sendCustomMessage(i, u, a)]);case 1:return 0 === (l = o.sent()).code ? (c.default.log('TSignaling.invite ok'), this._inviteInfoMap.set(e, u), this._startTimer(u, !0), [2, { inviteID: e, code: l.code, data: l.data }]) : [2, l]; - } - })); - })); - }, t.prototype.inviteInGroup = function (t) { - return n(this, void 0, void 0, (function () { - let e; let i; let n; let r; let a; let u; let l; let _;return o(this, (function (o) { - switch (o.label) { - case 0:return e = I.generate(), c.default.log('TSignaling.inviteInGroup', t, `inviteID=${e}`), d.default(t) || d.default(t.groupID) ? [2, Promise.reject(new f.default({ code: s.ErrorCode.ERR_INVALID_PARAMETERS, message: 'groupID is invalid' }))] : (i = t.groupID, n = t.inviteeList, r = t.data, a = t.timeout, u = t.offlinePushInfo, l = { businessID: s.BusinessID.SIGNAL, inviteID: e, inviter: this._userID, actionType: s.ActionType.INVITE, inviteeList: n, data: r, timeout: d.default(a) ? 0 : a, groupID: i }, [4, this._sendCustomMessage(i, l, u)]);case 1:return 0 === (_ = o.sent()).code ? (c.default.log('TSignaling.inviteInGroup ok'), this._inviteInfoMap.set(e, l), this._startTimer(l, !0), [2, { inviteID: e, code: _.code, data: _.data }]) : [2, _]; - } - })); - })); - }, t.prototype.cancel = function (t) { - return n(this, void 0, void 0, (function () { - let e; let i; let n; let r; let a; let u; let l; let _; let I;return o(this, (function (o) { - switch (o.label) { - case 0:return c.default.log('TSignaling.cancel', t), d.default(t) || d.default(t.inviteID) || !this._inviteInfoMap.has(t.inviteID) || this._isHandling ? [2, Promise.reject(new f.default({ code: s.ErrorCode.ERR_SDK_SIGNALING_INVALID_INVITE_ID, message: 'inviteID is invalid or invitation has been processed' }))] : (this._isHandling = !0, e = t.inviteID, i = t.data, n = this._inviteInfoMap.get(e), r = n.inviter, a = n.groupID, u = n.inviteeList, r !== this._userID ? [3, 2] : (l = { businessID: s.BusinessID.SIGNAL, inviteID: e, inviter: r, actionType: s.ActionType.CANCEL_INVITE, inviteeList: u, data: i, timeout: 0, groupID: a }, _ = a || u[0], [4, this._sendCustomMessage(_, l)]));case 1:return I = o.sent(), this._isHandling = !1, I && 0 === I.code ? (c.default.log('TSignaling.cancel ok'), this._deleteInviteInfoByID(e), this._inviteID = null, [2, { inviteID: e, code: I.code, data: I.data }]) : [2, I];case 2:return c.default.error(`TSignaling.cancel unmatched inviter=${r} and userID=${this._userID}`), this._isHandling = !1, [2, Promise.reject(new f.default({ code: s.ErrorCode.ERR_SDK_SIGNALING_NO_PERMISSION, message: '信令请求无权限,比如取消非自己发起的邀请,接受或则拒绝非发给自己的邀请' }))]; - } - })); - })); - }, t.prototype.accept = function (t) { - return n(this, void 0, void 0, (function () { - let e; let i; let n; let r; let a; let u; let l; let _;return o(this, (function (o) { - switch (o.label) { - case 0:return c.default.log('TSignaling.accept', t), d.default(t) || d.default(t.inviteID) || !this._inviteInfoMap.has(t.inviteID) || this._isHandling ? [2, Promise.reject(new f.default({ code: s.ErrorCode.ERR_SDK_SIGNALING_INVALID_INVITE_ID, message: 'inviteID is invalid or invitation has been processed' }))] : (this._isHandling = !0, e = t.inviteID, i = t.data, n = this._inviteInfoMap.get(e), r = n.inviter, a = n.groupID, n.inviteeList.includes(this._userID) ? (u = { businessID: s.BusinessID.SIGNAL, inviteID: e, inviter: r, actionType: s.ActionType.ACCEPT_INVITE, inviteeList: [this._userID], data: i, timeout: 0, groupID: a }, l = a || r, [4, this._sendCustomMessage(l, u)]) : [3, 2]);case 1:return _ = o.sent(), this._isHandling = !1, _ && 0 === _.code ? (c.default.log('TSignaling.accept ok'), this._updateLocalInviteInfo(u), [2, { inviteID: e, code: _.code, data: _.data }]) : [2, _];case 2:return c.default.error(`TSignaling.accept inviteeList do not include userID=${this._userID}. inviteID=${e} groupID=${a}`), this._isHandling = !1, [2, Promise.reject(new f.default({ code: s.ErrorCode.ERR_SDK_SIGNALING_INVALID_INVITE_ID, message: 'inviteID is invalid or invitation has been processed' }))]; - } - })); - })); - }, t.prototype.reject = function (t) { - return n(this, void 0, void 0, (function () { - let e; let i; let n; let r; let a; let u; let l; let _;return o(this, (function (o) { - switch (o.label) { - case 0:return c.default.log('TSignaling.reject', t), d.default(t) || d.default(t.inviteID) || !this._inviteInfoMap.has(t.inviteID) || this._isHandling ? [2, Promise.reject(new f.default({ code: s.ErrorCode.ERR_SDK_SIGNALING_INVALID_INVITE_ID, message: 'inviteID is invalid or invitation has been processed' }))] : (this._isHandling = !0, e = t.inviteID, i = t.data, n = this._inviteInfoMap.get(e), r = n.inviter, a = n.groupID, n.inviteeList.includes(this._userID) ? (u = { businessID: s.BusinessID.SIGNAL, inviteID: e, inviter: r, actionType: s.ActionType.REJECT_INVITE, inviteeList: [this._userID], data: i, timeout: 0, groupID: a }, l = a || r, [4, this._sendCustomMessage(l, u)]) : [3, 2]);case 1:return _ = o.sent(), this._isHandling = !1, _ && 0 === _.code ? (c.default.log('TSignaling.reject ok'), this._updateLocalInviteInfo(u), [2, { inviteID: e, code: _.code, data: _.data }]) : [2, _];case 2:return c.default.error(`TSignaling.reject inviteeList do not include userID=${this._userID}. inviteID=${e} groupID=${a}`), this._isHandling = !1, [2, Promise.reject(new f.default({ code: s.ErrorCode.ERR_SDK_SIGNALING_INVALID_INVITE_ID, message: 'inviteID is invalid or invitation has been processed' }))]; - } - })); - })); - }, t.prototype._onIMReady = function (t) { - c.default.log('TSignaling._onIMReady'), this._outerEmitter.emit(u.default.SDK_READY); - }, t.prototype._onIMNotReady = function (t) { - c.default.log('TSignaling.onSdkNotReady'), this._outerEmitter.emit(u.default.SDK_NOT_READY); - }, t.prototype._onKickedOut = function (t) { - c.default.log('TSignaling._onKickedOut'), this._outerEmitter.emit(u.default.KICKED_OUT, t.data); - }, t.prototype._onNetStateChange = function (t) { - c.default.log('TSignaling._onNetStateChange'), this._outerEmitter.emit(u.default.NET_STATE_CHANGE, t.data); - }, t.prototype._onMessageReceived = function (t) { - const e = this; const i = t.data; const n = i.filter((t => t.type === p.TYPES.MSG_TEXT));d.default(n) || this._outerEmitter.emit(u.default.TEXT_MESSAGE_RECEIVED, n);const o = i.filter((t => t.type === p.TYPES.MSG_GRP_TIP && t.payload.operationType === p.TYPES.GRP_TIP_MBR_JOIN));d.default(o) || this._outerEmitter.emit(u.default.REMOTE_USER_JOIN, o);const r = i.filter((t => t.type === p.TYPES.MSG_GRP_TIP && t.payload.operationType === p.TYPES.GRP_TIP_MBR_QUIT));d.default(r) || this._outerEmitter.emit(u.default.REMOTE_USER_LEAVE, r);const a = i.filter((t => t.type === p.TYPES.MSG_CUSTOM)); const l = [];a.forEach(((t) => { - let i; const n = t.payload.data; let o = !0;try { - i = JSON.parse(n); - } catch (t) { - o = !1; - } if (o) { - const r = i.businessID; const a = i.actionType;if (1 === r) switch (a) { - case s.ActionType.INVITE:e._onNewInvitationReceived(i);break;case s.ActionType.REJECT_INVITE:e._onInviteeRejected(i);break;case s.ActionType.ACCEPT_INVITE:e._onInviteeAccepted(i);break;case s.ActionType.CANCEL_INVITE:e._onInvitationCancelled(i);break;case s.ActionType.INVITE_TIMEOUT:e._onInvitationTimeout(i); - } else { - if ('av_call' === r) return !0;c.default.warn(`TSignaling._onMessageReceived unknown businessID=${r}`), l.push(t); - } - } else l.push(t); - })), d.default(l) || this._outerEmitter.emit(u.default.CUSTOM_MESSAGE_RECEIVED, l); - }, t.prototype._hasLocalInviteInfo = function (t, e) { - const i = t.inviteID; const n = t.groupID;if (c.default.log(`TSignaling._hasLocalInviteInfo inviteID=${i} groupID=${n}`), !this._inviteInfoMap.has(i)) return !1;const o = this._inviteInfoMap.get(i).inviteeList;return !n || (e ? o.length > 0 : o.length > 0 && o.includes(this._userID)); - }, t.prototype._startTimer = function (t, e) { - const i = this;void 0 === e && (e = !0);const n = t.timeout;if (c.default.log(`TSignaling._startTimer timeout=${n} isInvitator=${e} timeoutStatus=${0 === n}`), 0 !== n) var o = e ? n + 5 : n, r = 1, s = setInterval((() => { - const n = i._hasLocalInviteInfo(t, e);c.default.log(`TSignaling.setInterval hasInviteInfo=${n}`), r < o && n ? ++r : (n && i._sendTimeoutNotice(t, e), clearInterval(s)); - }), 1e3); - }, t.prototype._sendTimeoutNotice = function (t, e) { - return n(this, void 0, void 0, (function () { - let i; let n; let r; let a; let l; let d; let f; let _;return o(this, (function (o) { - switch (o.label) { - case 0:return i = t.inviteID, n = t.groupID, r = t.inviteeList, a = t.inviter, l = t.data, d = e ? n || r[0] : n || a, c.default.log(`TSignaling._sendTimeoutNotice inviteID=${i} to=${d} isInvitator=${e}`), f = { businessID: s.BusinessID.SIGNAL, inviteID: i, inviter: a, actionType: s.ActionType.INVITE_TIMEOUT, inviteeList: e ? r : [this._userID], data: l, timeout: 0, groupID: n }, [4, this._sendCustomMessage(d, f)];case 1:return (_ = o.sent()) && 0 === _.code && (this._outerEmitter.emit(u.default.INVITATION_TIMEOUT, { inviter: a, inviteID: i, groupID: n, inviteeList: f.inviteeList, isSelfTimeout: !0 }), e ? this._deleteInviteInfoByID(i) : this._updateLocalInviteInfo(f)), [2, _]; - } - })); - })); - }, t.prototype._onNewInvitationReceived = function (e) { - const i = e.inviteID; const n = e.inviter; const o = e.inviteeList; const r = e.groupID; const s = e.data; const a = o.includes(this._userID);c.default.log('TSignaling._onNewInvitationReceived', e, `myselfIncluded=${a}`);const u = JSON.parse(s);r && (0 === u.call_end || d.default(u.room_id) || d.default(u.data.room_id)) ? this._outerEmitter.emit(t.EVENT.NEW_INVITATION_RECEIVED, { inviteID: i, inviter: n, groupID: r, inviteeList: o, data: e.data || '' }) : (r && a || !r) && (this._inviteInfoMap.set(i, e), this._outerEmitter.emit(t.EVENT.NEW_INVITATION_RECEIVED, { inviteID: i, inviter: n, groupID: r, inviteeList: o, data: e.data || '' }), this._startTimer(e, !1)); - }, t.prototype._onInviteeRejected = function (t) { - const e = t.inviteID; const i = t.inviter; const n = t.groupID; const o = this._inviteInfoMap.has(e);c.default.log(`TSignaling._onInviteeRejected inviteID=${e} hasInviteID=${o} inviter=${i} groupID=${n}`), (n && o || !n) && (this._updateLocalInviteInfo(t), this._outerEmitter.emit(u.default.INVITEE_REJECTED, { inviteID: e, inviter: i, groupID: n, invitee: t.inviteeList[0], data: t.data || '' })); - }, t.prototype._onInviteeAccepted = function (t) { - const e = t.inviteID; const i = t.inviter; const n = t.groupID; const o = this._inviteInfoMap.has(e);c.default.log(`TSignaling._onInviteeAccepted inviteID=${e} hasInviteID=${o} inviter=${i} groupID=${n}`), (n && o || !n) && (this._updateLocalInviteInfo(t), this._outerEmitter.emit(u.default.INVITEE_ACCEPTED, { inviteID: e, inviter: i, groupID: n, invitee: t.inviteeList[0], data: t.data || '' })); - }, t.prototype._onInvitationCancelled = function (t) { - const e = t.inviteID; const i = t.inviter; const n = t.groupID; const o = this._inviteInfoMap.has(e);c.default.log(`TSignaling._onInvitationCancelled inviteID=${e} hasInviteID=${o} inviter=${i} groupID=${n}`), (n && o || !n) && (this._deleteInviteInfoByID(e), this._outerEmitter.emit(u.default.INVITATION_CANCELLED, { inviteID: e, inviter: i, groupID: n, data: t.data || '' })); - }, t.prototype._onInvitationTimeout = function (t) { - const e = t.inviteID; const i = t.inviter; const n = t.groupID; const o = this._inviteInfoMap.has(e);c.default.log(`TSignaling._onInvitationTimeout inviteID=${e} hasInviteID=${o} inviter=${i} groupID=${n}`), (n && o || !n) && (this._updateLocalInviteInfo(t), this._outerEmitter.emit(u.default.INVITATION_TIMEOUT, { inviteID: e, inviter: i, groupID: n, inviteeList: t.inviteeList, isSelfTimeout: !1 })); - }, t.prototype._updateLocalInviteInfo = function (t) { - const e = t.inviteID; const i = t.inviter; const n = t.inviteeList; const o = t.groupID;if (c.default.log(`TSignaling._updateLocalInviteInfo inviteID=${e} inviter=${i} groupID=${o}`), o) { - if (this._inviteInfoMap.has(e)) { - const r = n[0]; const s = this._inviteInfoMap.get(e).inviteeList;s.includes(r) && (s.splice(s.indexOf(r), 1), c.default.log(`TSignaling._updateLocalInviteInfo remove ${r} from localInviteeList. ${s.length} invitees left`)), 0 === s.length && this._deleteInviteInfoByID(e); - } - } else this._deleteInviteInfoByID(e); - }, t.prototype._deleteInviteInfoByID = function (t) { - this._inviteInfoMap.has(t) && (c.default.log(`TSignaling._deleteInviteInfoByID remove ${t} from inviteInfoMap.`), this._inviteInfoMap.delete(t)); - }, t.prototype._sendCustomMessage = function (t, e, i) { - return n(this, void 0, void 0, (function () { - let n; let r; let a; let u;return o(this, (function (o) { - return n = e.groupID, r = this._tim.createCustomMessage({ to: t, conversationType: n ? p.TYPES.CONV_GROUP : p.TYPES.CONV_C2C, priority: p.TYPES.MSG_PRIORITY_HIGH, payload: { data: JSON.stringify(e) } }), e.actionType === s.ActionType.INVITE ? (u = { title: (a = i || {}).title || '', description: a.description || '您有一个通话请求', androidOPPOChannelID: a.androidOPPOChannelID || '', extension: this._handleOfflineInfo(e) }, c.default.log(`TSignaling.offlinePushInfo ${JSON.stringify(u)}`), [2, this._tim.sendMessage(r, { offlinePushInfo: u })]) : [2, this._tim.sendMessage(r)]; - })); - })); - }, t.prototype._handleOfflineInfo = function (t) { - const e = { action: t.actionType, call_type: t.groupID ? 2 : 1, room_id: t.data.room_id, call_id: t.inviteID, timeout: t.data.timeout, version: 4, invited_list: t.inviteeList };t.groupID && (e.group_id = t.groupID);const i = { entity: { action: 2, chatType: t.groupID ? 2 : 1, content: JSON.stringify(e), sendTime: parseInt(`${Date.now() / 1e3}`), sender: t.inviter, version: 1 } }; const n = JSON.stringify(i);return c.default.log(`TSignaling._handleOfflineInfo ${n}`), n; - }, t.EVENT = u.default, t.TYPES = l.default, t; - }());e.default = g; -}, function (t, e, i) { - 'use strict';let n; let o; let r;Object.defineProperty(e, '__esModule', { value: !0 }), e.ErrorCode = e.BusinessID = e.ActionType = void 0, (function (t) { - t[t.INVITE = 1] = 'INVITE', t[t.CANCEL_INVITE = 2] = 'CANCEL_INVITE', t[t.ACCEPT_INVITE = 3] = 'ACCEPT_INVITE', t[t.REJECT_INVITE = 4] = 'REJECT_INVITE', t[t.INVITE_TIMEOUT = 5] = 'INVITE_TIMEOUT'; - }(n || (n = {}))), e.ActionType = n, (function (t) { - t[t.SIGNAL = 1] = 'SIGNAL'; - }(o || (o = {}))), e.BusinessID = o, (function (t) { - t[t.ERR_INVALID_PARAMETERS = 6017] = 'ERR_INVALID_PARAMETERS', t[t.ERR_SDK_SIGNALING_INVALID_INVITE_ID = 8010] = 'ERR_SDK_SIGNALING_INVALID_INVITE_ID', t[t.ERR_SDK_SIGNALING_NO_PERMISSION = 8011] = 'ERR_SDK_SIGNALING_NO_PERMISSION'; - }(r || (r = {}))), e.ErrorCode = r; -}, function (t, e, i) { - 'use strict';i.r(e), i.d(e, 'default', (() => s));const n = Function.prototype.apply; const o = new WeakMap;function r(t) { - return o.has(t) || o.set(t, {}), o.get(t); - } class s { - constructor(t = null, e = console) { - const i = r(this);return i._events = new Set, i._callbacks = {}, i._console = e, i._maxListeners = null === t ? null : parseInt(t, 10), this; - }_addCallback(t, e, i, n) { - return this._getCallbacks(t).push({ callback: e, context: i, weight: n }), this._getCallbacks(t).sort((t, e) => t.weight > e.weight), this; - }_getCallbacks(t) { - return r(this)._callbacks[t]; - }_getCallbackIndex(t, e) { - return this._has(t) ? this._getCallbacks(t).findIndex(t => t.callback === e) : null; - }_achieveMaxListener(t) { - return null !== r(this)._maxListeners && r(this)._maxListeners <= this.listenersNumber(t); - }_callbackIsExists(t, e, i) { - const n = this._getCallbackIndex(t, e); const o = -1 !== n ? this._getCallbacks(t)[n] : void 0;return -1 !== n && o && o.context === i; - }_has(t) { - return r(this)._events.has(t); - }on(t, e, i = null, n = 1) { - const o = r(this);if ('function' !== typeof e) throw new TypeError(`${e} is not a function`);return this._has(t) ? (this._achieveMaxListener(t) && o._console.warn(`Max listeners (${o._maxListeners}) for event "${t}" is reached!`), this._callbackIsExists(...arguments) && o._console.warn(`Event "${t}" already has the callback ${e}.`)) : (o._events.add(t), o._callbacks[t] = []), this._addCallback(...arguments), this; - }once(t, e, i = null, o = 1) { - const r = (...o) => (this.off(t, r), n.call(e, i, o));return this.on(t, r, i, o); - }off(t, e = null) { - const i = r(this);let n;return this._has(t) && (null === e ? (i._events.delete(t), i._callbacks[t] = null) : (n = this._getCallbackIndex(t, e), -1 !== n && (i._callbacks[t].splice(n, 1), this.off(...arguments)))), this; - }emit(t, ...e) { - return this._has(t) && this._getCallbacks(t).forEach(t => n.call(t.callback, t.context, e)), this; - }clear() { - const t = r(this);return t._events.clear(), t._callbacks = {}, this; - }listenersNumber(t) { - return this._has(t) ? this._getCallbacks(t).length : null; - } - } -}, function (t, e) { - let i;i = (function () { - return this; - }());try { - i = i || new Function('return this')(); - } catch (t) { - 'object' === typeof window && (i = window); - }t.exports = i; -}, function (t, e, i) { - 'use strict';i.r(e);const n = i(0);const o = Object.prototype.hasOwnProperty;e.default = function (t) { - if (null == t) return !0;if ('boolean' === typeof t) return !1;if ('number' === typeof t) return 0 === t;if ('string' === typeof t) return 0 === t.length;if ('function' === typeof t) return 0 === t.length;if (Array.isArray(t)) return 0 === t.length;if (t instanceof Error) return '' === t.message;if (Object(n.f)(t)) { - for (const e in t) if (o.call(t, e)) return !1;return !0; - } return !!(Object(n.e)(t) || Object(n.g)(t) || Object(n.c)(t)) && 0 === t.size; - }; -}, function (t, e, i) { - 'use strict';i.r(e);class n extends Error { - constructor(t) { - super(), this.code = t.code, this.message = t.message, this.data = t.data || {}; - } - }e.default = n; -}, function (t, e, i) { - 'use strict';i.r(e);const n = i(1); const o = i(4); const r = i.n(o);e.default = class { - constructor() { - this._funcMap = new Map; - }defense(t, e, i) { - if ('string' !== typeof t) return null;if (0 === t.length) return null;if ('function' !== typeof e) return null;if (this._funcMap.has(t) && this._funcMap.get(t).has(e)) return this._funcMap.get(t).get(e);this._funcMap.has(t) || this._funcMap.set(t, new Map);let n = null;return this._funcMap.get(t).has(e) ? n = this._funcMap.get(t).get(e) : (n = this._pack(t, e, i), this._funcMap.get(t).set(e, n)), n; - }defenseOnce(t, e, i) { - return 'function' !== typeof e ? null : this._pack(t, e, i); - }find(t, e) { - return 'string' !== typeof t || 0 === t.length || 'function' !== typeof e ? null : this._funcMap.has(t) ? this._funcMap.get(t).has(e) ? this._funcMap.get(t).get(e) : (n.default.log(`SafetyCallback.find: 找不到 func —— ${t}/${'' !== e.name ? e.name : '[anonymous]'}`), null) : (n.default.log(`SafetyCallback.find: 找不到 eventName-${t} 对应的 func`), null); - }delete(t, e) { - return 'function' === typeof e && (!!this._funcMap.has(t) && (!!this._funcMap.get(t).has(e) && (this._funcMap.get(t).delete(e), 0 === this._funcMap.get(t).size && this._funcMap.delete(t), !0))); - }_pack(t, e, i) { - return function () { - try { - e.apply(i, Array.from(arguments)); - } catch (e) { - const i = Object.values(r.a).indexOf(t); const o = Object.keys(r.a)[i];n.default.error(`接入侧事件 EVENT.${o} 对应的回调函数逻辑存在问题,请检查!`, e); - } - }; - } - }; -}, function (t, e, i) { +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("tim-wx-sdk")):"function"==typeof define&&define.amd?define(["tim-wx-sdk"],e):"object"==typeof exports?exports.TSignaling=e(require("tim-wx-sdk")):t.TSignaling=e(t.TIM)}(window,(function(t){return function(t){var e={};function i(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,i),o.l=!0,o.exports}return i.m=t,i.c=e,i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)i.d(n,o,function(e){return t[e]}.bind(null,o));return n},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=5)}([function(t,e,i){"use strict";i.d(e,"e",(function(){return p})),i.d(e,"g",(function(){return g})),i.d(e,"c",(function(){return h})),i.d(e,"f",(function(){return v})),i.d(e,"b",(function(){return m})),i.d(e,"d",(function(){return T})),i.d(e,"a",(function(){return y})),i.d(e,"h",(function(){return N}));const n="undefined"!=typeof window,o=("undefined"!=typeof wx&&wx.getSystemInfoSync,n&&window.navigator&&window.navigator.userAgent||""),r=/AppleWebKit\/([\d.]+)/i.exec(o),s=(r&&parseFloat(r.pop()),/iPad/i.test(o)),a=/iPhone/i.test(o)&&!s,u=/iPod/i.test(o),l=a||s||u,c=(function(){const t=o.match(/OS (\d+)_/i);t&&t[1]&&t[1]}(),/Android/i.test(o)),d=function(){const t=o.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);if(!t)return null;const e=t[1]&&parseFloat(t[1]),i=t[2]&&parseFloat(t[2]);return e&&i?parseFloat(t[1]+"."+t[2]):e||null}(),f=(c&&/webkit/i.test(o),/Firefox/i.test(o),/Edge/i.test(o)),_=!f&&/Chrome/i.test(o),I=(function(){const t=o.match(/Chrome\/(\d+)/);t&&t[1]&&parseFloat(t[1])}(),/MSIE/.test(o),/MSIE\s8\.0/.test(o),function(){const t=/MSIE\s(\d+)\.\d/.exec(o);let e=t&&parseFloat(t[1]);!e&&/Trident\/7.0/i.test(o)&&/rv:11.0/.test(o)&&(e=11)}(),/Safari/i.test(o),/TBS\/\d+/i.test(o));(function(){const t=o.match(/TBS\/(\d+)/i);if(t&&t[1])t[1]})(),!I&&/MQQBrowser\/\d+/i.test(o),!I&&/ QQBrowser\/\d+/i.test(o),/(micromessenger|webbrowser)/i.test(o),/Windows/i.test(o),/MAC OS X/i.test(o),/MicroMessenger/i.test(o);i(2),i(1);const p=function(t){return"map"===D(t)},g=function(t){return"set"===D(t)},h=function(t){return"file"===D(t)},v=function(t){if("object"!=typeof t||null===t)return!1;const e=Object.getPrototypeOf(t);if(null===e)return!0;let i=e;for(;null!==Object.getPrototypeOf(i);)i=Object.getPrototypeOf(i);return e===i},E=function(t){return"function"==typeof Array.isArray?Array.isArray(t):"array"===D(t)},m=function(t){return E(t)||function(t){return null!==t&&"object"==typeof t}(t)},T=function(t){return t instanceof Error},D=function(t){return Object.prototype.toString.call(t).match(/^\[object (.*)\]$/)[1].toLowerCase()};let S=0;Date.now||(Date.now=function(){return(new Date).getTime()});const y={now:function(){0===S&&(S=Date.now()-1);const t=Date.now()-S;return t>4294967295?(S+=4294967295,Date.now()-S):t},utc:function(){return Math.round(Date.now()/1e3)}},N=function(t){return JSON.stringify(t,["message","code"])}},function(t,e,i){"use strict";i.r(e);var n=i(3),o=i(0);let r=0;const s=new Map;function a(){const t=new Date;return"TSignaling "+t.toLocaleTimeString("en-US",{hour12:!1})+"."+function(t){let e;switch(t.toString().length){case 1:e="00"+t;break;case 2:e="0"+t;break;default:e=t}return e}(t.getMilliseconds())+":"}const u={_data:[],_length:0,_visible:!1,arguments2String(t){let e;if(1===t.length)e=a()+t[0];else{e=a();for(let i=0,n=t.length;i0&&o[o.length-1])||6!==r[0]&&2!==r[0])){s=0;continue}if(3===r[0]&&(!o||r[1]>o[0]&&r[1]t.weight>e.weight),this}_getCallbacks(t){return r(this)._callbacks[t]}_getCallbackIndex(t,e){return this._has(t)?this._getCallbacks(t).findIndex(t=>t.callback===e):null}_achieveMaxListener(t){return null!==r(this)._maxListeners&&r(this)._maxListeners<=this.listenersNumber(t)}_callbackIsExists(t,e,i){const n=this._getCallbackIndex(t,e),o=-1!==n?this._getCallbacks(t)[n]:void 0;return-1!==n&&o&&o.context===i}_has(t){return r(this)._events.has(t)}on(t,e,i=null,n=1){const o=r(this);if("function"!=typeof e)throw new TypeError(e+" is not a function");return this._has(t)?(this._achieveMaxListener(t)&&o._console.warn(`Max listeners (${o._maxListeners}) for event "${t}" is reached!`),this._callbackIsExists(...arguments)&&o._console.warn(`Event "${t}" already has the callback ${e}.`)):(o._events.add(t),o._callbacks[t]=[]),this._addCallback(...arguments),this}once(t,e,i=null,o=1){const r=(...o)=>(this.off(t,r),n.call(e,i,o));return this.on(t,r,i,o)}off(t,e=null){const i=r(this);let n;return this._has(t)&&(null===e?(i._events.delete(t),i._callbacks[t]=null):(n=this._getCallbackIndex(t,e),-1!==n&&(i._callbacks[t].splice(n,1),this.off(...arguments)))),this}emit(t,...e){return this._has(t)&&this._getCallbacks(t).forEach(t=>n.call(t.callback,t.context,e)),this}clear(){const t=r(this);return t._events.clear(),t._callbacks={},this}listenersNumber(t){return this._has(t)?this._getCallbacks(t).length:null}}},function(t,e){var i;i=function(){return this}();try{i=i||new Function("return this")()}catch(t){"object"==typeof window&&(i=window)}t.exports=i},function(t,e,i){"use strict";i.r(e);var n=i(0);const o=Object.prototype.hasOwnProperty;e.default=function(t){if(null==t)return!0;if("boolean"==typeof t)return!1;if("number"==typeof t)return 0===t;if("string"==typeof t)return 0===t.length;if("function"==typeof t)return 0===t.length;if(Array.isArray(t))return 0===t.length;if(t instanceof Error)return""===t.message;if(Object(n.f)(t)){for(const e in t)if(o.call(t,e))return!1;return!0}return!!(Object(n.e)(t)||Object(n.g)(t)||Object(n.c)(t))&&0===t.size}},function(t,e,i){"use strict";i.r(e);class n extends Error{constructor(t){super(),this.code=t.code,this.message=t.message,this.data=t.data||{}}}e.default=n},function(t,e,i){"use strict";i.r(e);var n=i(1),o=i(4),r=i.n(o);e.default=class{constructor(){this._funcMap=new Map}defense(t,e,i){if("string"!=typeof t)return null;if(0===t.length)return null;if("function"!=typeof e)return null;if(this._funcMap.has(t)&&this._funcMap.get(t).has(e))return this._funcMap.get(t).get(e);this._funcMap.has(t)||this._funcMap.set(t,new Map);let n=null;return this._funcMap.get(t).has(e)?n=this._funcMap.get(t).get(e):(n=this._pack(t,e,i),this._funcMap.get(t).set(e,n)),n}defenseOnce(t,e,i){return"function"!=typeof e?null:this._pack(t,e,i)}find(t,e){return"string"!=typeof t||0===t.length||"function"!=typeof e?null:this._funcMap.has(t)?this._funcMap.get(t).has(e)?this._funcMap.get(t).get(e):(n.default.log(`SafetyCallback.find: 找不到 func —— ${t}/${""!==e.name?e.name:"[anonymous]"}`),null):(n.default.log(`SafetyCallback.find: 找不到 eventName-${t} 对应的 func`),null)}delete(t,e){return"function"==typeof e&&(!!this._funcMap.has(t)&&(!!this._funcMap.get(t).has(e)&&(this._funcMap.get(t).delete(e),0===this._funcMap.get(t).size&&this._funcMap.delete(t),!0)))}_pack(t,e,i){return function(){try{e.apply(i,Array.from(arguments))}catch(e){const i=Object.values(r.a).indexOf(t),o=Object.keys(r.a)[i];n.default.error(`接入侧事件 EVENT.${o} 对应的回调函数逻辑存在问题,请检查!`,e)}}}}},function(t,e,i){ /** * UUID.js - RFC-compliant UUID Generator for JavaScript * * @file * @author LiosK - * @version v4.2.8 - * @license Apache License 2.0: Copyright (c) 2010-2021 LiosK + * @version v4.2.5 + * @license Apache License 2.0: Copyright (c) 2010-2020 LiosK */ - let n;n = (function (e) { - 'use strict';function n() { - const t = o._getRandomInt;this.timestamp = 0, this.sequence = t(14), this.node = 1099511627776 * (1 | t(8)) + t(40), this.tick = t(4); - } function o() {} return o.generate = function () { - const t = o._getRandomInt; const e = o._hexAligner;return `${e(t(32), 8)}-${e(t(16), 4)}-${e(16384 | t(12), 4)}-${e(32768 | t(14), 4)}-${e(t(48), 12)}`; - }, o._getRandomInt = function (t) { - if (t < 0 || t > 53) return NaN;const e = 0 | 1073741824 * Math.random();return t > 30 ? e + 1073741824 * (0 | Math.random() * (1 << t - 30)) : e >>> 30 - t; - }, o._hexAligner = function (t, e) { - for (var i = t.toString(16), n = e - i.length, o = '0';n > 0;n >>>= 1, o += o)1 & n && (i = o + i);return i; - }, o.overwrittenUUID = e, (function () { - const t = o._getRandomInt;o.useMathRandom = function () { - o._getRandomInt = t; - };let e = null; let n = t;'undefined' !== typeof window && (e = window.crypto || window.msCrypto) ? e.getRandomValues && 'undefined' !== typeof Uint32Array && (n = function (t) { - if (t < 0 || t > 53) return NaN;let i = new Uint32Array(t > 32 ? 2 : 1);return i = e.getRandomValues(i) || i, t > 32 ? i[0] + 4294967296 * (i[1] >>> 64 - t) : i[0] >>> 32 - t; - }) : (e = i(13)) && e.randomBytes && (n = function (t) { - if (t < 0 || t > 53) return NaN;const i = e.randomBytes(t > 32 ? 8 : 4); const n = i.readUInt32BE(0);return t > 32 ? n + 4294967296 * (i.readUInt32BE(4) >>> 64 - t) : n >>> 32 - t; - }), o._getRandomInt = n; - }()), o.FIELD_NAMES = ['timeLow', 'timeMid', 'timeHiAndVersion', 'clockSeqHiAndReserved', 'clockSeqLow', 'node'], o.FIELD_SIZES = [32, 16, 16, 8, 8, 48], o.genV4 = function () { - const t = o._getRandomInt;return (new o)._init(t(32), t(16), 16384 | t(12), 128 | t(6), t(8), t(48)); - }, o.parse = function (t) { - let e;if (e = /^\s*(urn:uuid:|\{)?([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{2})([0-9a-f]{2})-([0-9a-f]{12})(\})?\s*$/i.exec(t)) { - const i = e[1] || ''; const n = e[8] || '';if (i + n === '' || '{' === i && '}' === n || 'urn:uuid:' === i.toLowerCase() && '' === n) return (new o)._init(parseInt(e[2], 16), parseInt(e[3], 16), parseInt(e[4], 16), parseInt(e[5], 16), parseInt(e[6], 16), parseInt(e[7], 16)); - } return null; - }, o.prototype._init = function () { - const t = o.FIELD_NAMES; const e = o.FIELD_SIZES; const i = o._binAligner; const n = o._hexAligner;this.intFields = new Array(6), this.bitFields = new Array(6), this.hexFields = new Array(6);for (let r = 0;r < 6;r++) { - const s = parseInt(arguments[r] || 0);this.intFields[r] = this.intFields[t[r]] = s, this.bitFields[r] = this.bitFields[t[r]] = i(s, e[r]), this.hexFields[r] = this.hexFields[t[r]] = n(s, e[r] >>> 2); - } return this.version = this.intFields.timeHiAndVersion >>> 12 & 15, this.bitString = this.bitFields.join(''), this.hexNoDelim = this.hexFields.join(''), this.hexString = `${this.hexFields[0]}-${this.hexFields[1]}-${this.hexFields[2]}-${this.hexFields[3]}${this.hexFields[4]}-${this.hexFields[5]}`, this.urn = `urn:uuid:${this.hexString}`, this; - }, o._binAligner = function (t, e) { - for (var i = t.toString(2), n = e - i.length, o = '0';n > 0;n >>>= 1, o += o)1 & n && (i = o + i);return i; - }, o.prototype.toString = function () { - return this.hexString; - }, o.prototype.equals = function (t) { - if (!(t instanceof o)) return !1;for (let e = 0;e < 6;e++) if (this.intFields[e] !== t.intFields[e]) return !1;return !0; - }, o.NIL = (new o)._init(0, 0, 0, 0, 0, 0), o.genV1 = function () { - null == o._state && o.resetState();const t = (new Date).getTime(); const e = o._state;t != e.timestamp ? (t < e.timestamp && e.sequence++, e.timestamp = t, e.tick = o._getRandomInt(4)) : Math.random() < o._tsRatio && e.tick < 9984 ? e.tick += 1 + o._getRandomInt(4) : e.sequence++;const i = o._getTimeFieldValues(e.timestamp); const n = i.low + e.tick; const r = 4095 & i.hi | 4096;e.sequence &= 16383;const s = e.sequence >>> 8 | 128; const a = 255 & e.sequence;return (new o)._init(n, i.mid, r, s, a, e.node); - }, o.resetState = function () { - o._state = new n; - }, o._tsRatio = 1 / 4, o._state = null, o._getTimeFieldValues = function (t) { - const e = t - Date.UTC(1582, 9, 15); const i = e / 4294967296 * 1e4 & 268435455;return { low: 1e4 * (268435455 & e) % 4294967296, mid: 65535 & i, hi: i >>> 16, timestamp: e }; - }, 'object' === typeof t.exports && (t.exports = o), o; - }(n)); -}, function (t, e) {}, function (e, i) { - e.exports = t; -}, function (t) { - t.exports = JSON.parse('{"name":"tsignaling","version":"0.7.0-beta.1","description":"腾讯云 Web 信令 SDK","main":"./src/index.ts","scripts":{"lint":"./node_modules/.bin/eslint ./src","fix":"./node_modules/.bin/eslint --fix ./src","ts2js":"tsc src/index.ts --outDir build/ts2js","doc":"npm run ts2js && npm run doc:clean && npm run doc:build","doc:build":"./node_modules/.bin/jsdoc -c build/jsdoc/jsdoc.json && node ./build/jsdoc/fix-doc.js","doc:clean":"node ./build/jsdoc/clean-doc.js","build:wx":"cross-env NODE_ENV=wx webpack --config webpack.prod.config.js","build:web":"node node_modules/cross-env/src/bin/cross-env.js NODE_ENV=web node_modules/webpack/bin/webpack.js --config webpack.prod.config.js","build:package":"node build/package-bundle.js","prerelease":"npm run build:web && npm run build:wx && npm run build:package && node ./build/copy.js","start:wx":"cross-env NODE_ENV=wx webpack-dev-server --config webpack.config.js","start:web":"node node_modules/cross-env/src/bin/cross-env.js NODE_ENV=web node_modules/webpack-dev-server/bin/webpack-dev-server.js --config webpack.dev.config.js","build_withcopy":"npm run build:web && cp dist/npm/tsignaling-js.js ../TIM-demo-web/node_modules/tsignaling/tsignaling-js.js","build_withcopy:mp":"npm run build:wx && cp dist/npm/tsignaling-wx.js ../TIM-demo-mini/static/component/TRTCCalling/utils/tsignaling-wx.js","changelog":"conventional-changelog -p angular -i CHANGELOG.md -s -r 0 && cp CHANGELOG.md build/jsdoc/tutorials/CHANGELOG.md"},"husky":{"hooks":{"pre-commit":"npm run lint"}},"lint-staged":{"*.{.ts,.tsx}":["eslint","git add"]},"keywords":["腾讯云","即时通信","信令"],"author":"","license":"ISC","devDependencies":{"conventional-changelog-cli":"^2.1.1","cross-env":"^7.0.2","fs-extra":"^9.0.1","html-webpack-plugin":"^4.3.0","ts-loader":"^7.0.5","typescript":"^3.9.9","webpack":"^4.43.0","webpack-cli":"^3.3.11","webpack-dev-server":"^3.11.0"},"dependencies":{"@typescript-eslint/eslint-plugin":"^4.22.1","@typescript-eslint/parser":"^4.22.1","EventEmitter":"^1.0.0","docdash-blue":"^1.1.3","eslint":"^5.16.0","eslint-config-google":"^0.13.0","eslint-plugin-classes":"^0.1.1","jsdoc":"^3.6.4","jsdoc-plugin-typescript":"^2.0.5","pretty":"^2.0.0","replace":"^1.2.0","uuidjs":"^4.2.5"}}'); -}])).default))); +var n;n=function(e){"use strict";function n(){var t=o._getRandomInt;this.timestamp=0,this.sequence=t(14),this.node=1099511627776*(1|t(8))+t(40),this.tick=t(4)}function o(){}return o.generate=function(){var t=o._getRandomInt,e=o._hexAligner;return e(t(32),8)+"-"+e(t(16),4)+"-"+e(16384|t(12),4)+"-"+e(32768|t(14),4)+"-"+e(t(48),12)},o._getRandomInt=function(t){if(t<0||t>53)return NaN;var e=0|1073741824*Math.random();return t>30?e+1073741824*(0|Math.random()*(1<>>30-t},o._hexAligner=function(t,e){for(var i=t.toString(16),n=e-i.length,o="0";n>0;n>>>=1,o+=o)1&n&&(i=o+i);return i},o.overwrittenUUID=e,function(){var t=o._getRandomInt;o.useMathRandom=function(){o._getRandomInt=t};var e=null,n=t;"undefined"!=typeof window&&(e=window.crypto||window.msCrypto)?e.getRandomValues&&"undefined"!=typeof Uint32Array&&(n=function(t){if(t<0||t>53)return NaN;var i=new Uint32Array(t>32?2:1);return i=e.getRandomValues(i)||i,t>32?i[0]+4294967296*(i[1]>>>64-t):i[0]>>>32-t}):(e=i(13))&&e.randomBytes&&(n=function(t){if(t<0||t>53)return NaN;var i=e.randomBytes(t>32?8:4),n=i.readUInt32BE(0);return t>32?n+4294967296*(i.readUInt32BE(4)>>>64-t):n>>>32-t}),o._getRandomInt=n}(),o.FIELD_NAMES=["timeLow","timeMid","timeHiAndVersion","clockSeqHiAndReserved","clockSeqLow","node"],o.FIELD_SIZES=[32,16,16,8,8,48],o.genV4=function(){var t=o._getRandomInt;return(new o)._init(t(32),t(16),16384|t(12),128|t(6),t(8),t(48))},o.parse=function(t){var e;if(e=/^\s*(urn:uuid:|\{)?([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{2})([0-9a-f]{2})-([0-9a-f]{12})(\})?\s*$/i.exec(t)){var i=e[1]||"",n=e[8]||"";if(i+n===""||"{"===i&&"}"===n||"urn:uuid:"===i.toLowerCase()&&""===n)return(new o)._init(parseInt(e[2],16),parseInt(e[3],16),parseInt(e[4],16),parseInt(e[5],16),parseInt(e[6],16),parseInt(e[7],16))}return null},o.prototype._init=function(){var t=o.FIELD_NAMES,e=o.FIELD_SIZES,i=o._binAligner,n=o._hexAligner;this.intFields=new Array(6),this.bitFields=new Array(6),this.hexFields=new Array(6);for(var r=0;r<6;r++){var s=parseInt(arguments[r]||0);this.intFields[r]=this.intFields[t[r]]=s,this.bitFields[r]=this.bitFields[t[r]]=i(s,e[r]),this.hexFields[r]=this.hexFields[t[r]]=n(s,e[r]>>>2)}return this.version=this.intFields.timeHiAndVersion>>>12&15,this.bitString=this.bitFields.join(""),this.hexNoDelim=this.hexFields.join(""),this.hexString=this.hexFields[0]+"-"+this.hexFields[1]+"-"+this.hexFields[2]+"-"+this.hexFields[3]+this.hexFields[4]+"-"+this.hexFields[5],this.urn="urn:uuid:"+this.hexString,this},o._binAligner=function(t,e){for(var i=t.toString(2),n=e-i.length,o="0";n>0;n>>>=1,o+=o)1&n&&(i=o+i);return i},o.prototype.toString=function(){return this.hexString},o.prototype.equals=function(t){if(!(t instanceof o))return!1;for(var e=0;e<6;e++)if(this.intFields[e]!==t.intFields[e])return!1;return!0},o.NIL=(new o)._init(0,0,0,0,0,0),o.genV1=function(){null==o._state&&o.resetState();var t=(new Date).getTime(),e=o._state;t!=e.timestamp?(t>>8|128,a=255&e.sequence;return(new o)._init(n,i.mid,r,s,a,e.node)},o.resetState=function(){o._state=new n},o._tsRatio=1/4,o._state=null,o._getTimeFieldValues=function(t){var e=t-Date.UTC(1582,9,15),i=e/4294967296*1e4&268435455;return{low:1e4*(268435455&e)%4294967296,mid:65535&i,hi:i>>>16,timestamp:e}},"object"==typeof t.exports&&(t.exports=o),o}(n)},function(t,e){},function(e,i){e.exports=t},function(t){t.exports=JSON.parse('{"name":"tsignaling","version":"0.10.0","description":"腾讯云 Web 信令 SDK","main":"./src/index.ts","scripts":{"lint":"./node_modules/.bin/eslint ./src","fix":"./node_modules/.bin/eslint --fix ./src","ts2js":"tsc src/index.ts --outDir build/ts2js","doc":"npm run ts2js && npm run doc:clean && npm run doc:build","doc:build":"./node_modules/.bin/jsdoc -c build/jsdoc/jsdoc.json && node ./build/jsdoc/fix-doc.js","doc:clean":"node ./build/jsdoc/clean-doc.js","build:wx":"cross-env NODE_ENV=wx webpack --config webpack.prod.config.js","build:web":"node node_modules/cross-env/src/bin/cross-env.js NODE_ENV=web node_modules/webpack/bin/webpack.js --config webpack.prod.config.js","build:package":"node build/package-bundle.js","prerelease":"npm run build:web && npm run build:wx && npm run build:package && node ./build/copy.js","start:wx":"cross-env NODE_ENV=wx webpack-dev-server --config webpack.config.js","start:web":"node node_modules/cross-env/src/bin/cross-env.js NODE_ENV=web node_modules/webpack-dev-server/bin/webpack-dev-server.js --config webpack.dev.config.js","build_withcopy":"npm run build:web && cp dist/npm/tsignaling-js.js ../TIM-demo-web/node_modules/tsignaling/tsignaling-js.js","build_withcopy:mp":"npm run build:wx && cp dist/npm/tsignaling-wx.js ../TIM-demo-mini/static/component/TRTCCalling/utils/tsignaling-wx.js","changelog":"cp CHANGELOG.md build/jsdoc/tutorials/CHANGELOG.md"},"husky":{"hooks":{"pre-commit":"npm run lint"}},"lint-staged":{"*.{.ts,.tsx}":["eslint","git add"]},"keywords":["腾讯云","即时通信","信令"],"author":"","license":"ISC","devDependencies":{"conventional-changelog-cli":"^2.1.1","cross-env":"^7.0.2","fs-extra":"^9.0.1","html-webpack-plugin":"^4.3.0","ts-loader":"^7.0.5","typescript":"^3.9.9","webpack":"^4.43.0","webpack-cli":"^3.3.11","webpack-dev-server":"^3.11.0"},"dependencies":{"@typescript-eslint/eslint-plugin":"^4.22.1","@typescript-eslint/parser":"^4.22.1","EventEmitter":"^1.0.0","docdash-blue":"^1.1.3","eslint":"^5.16.0","eslint-config-google":"^0.13.0","eslint-plugin-classes":"^0.1.1","jsdoc":"^3.6.4","jsdoc-plugin-typescript":"^2.0.5","pretty":"^2.0.0","replace":"^1.2.0","uuidjs":"^4.2.5"}}')}]).default})); \ No newline at end of file diff --git a/MiniProgram/TUIKit/miniprogram/components/TUICalling/TRTCCalling/utils/event.js b/MiniProgram/TUIKit/miniprogram/components/TUICalling/TRTCCalling/utils/event.js index c6dece9bd0..861fb06375 100644 --- a/MiniProgram/TUIKit/miniprogram/components/TUICalling/TRTCCalling/utils/event.js +++ b/MiniProgram/TUIKit/miniprogram/components/TUICalling/TRTCCalling/utils/event.js @@ -59,4 +59,4 @@ class EventEmitter { } } -module.exports = EventEmitter +export default EventEmitter diff --git a/MiniProgram/TUIKit/miniprogram/components/TUICalling/TUICalling.js b/MiniProgram/TUIKit/miniprogram/components/TUICalling/TUICalling.js index 9ce35ef0b8..9db56c3381 100644 --- a/MiniProgram/TUIKit/miniprogram/components/TUICalling/TUICalling.js +++ b/MiniProgram/TUIKit/miniprogram/components/TUICalling/TUICalling.js @@ -1,13 +1,11 @@ import TRTCCalling from './TRTCCalling/TRTCCalling.js'; - const TAG_NAME = 'TUICalling'; // 组件旨在跨终端维护一个通话状态管理机,以事件发布机制驱动上层进行管理,并通过API调用进行状态变更。 // 组件设计思路将UI和状态管理分离。您可以通过修改`component`文件夹下的文件,适配您的业务场景, // 在UI展示上,您可以通过属性的方式,将上层的用户头像,名称等数据传入组件内部,`static`下的icon和默认头像图片, // 只是为了展示基础的效果,您需要根据业务场景进行修改。 -// eslint-disable-next-line no-undef Component({ properties: { config: { @@ -37,8 +35,10 @@ Component({ remoteUsers: [], // 远程用户资料 screen: 'pusher', // 视屏通话中,显示大屏幕的流(只限1v1聊天 soundMode: 'speaker', // 声音模式 听筒/扬声器 + userList: null, //接受邀请的用户信息 }, + methods: { initCall() { // 收起键盘 @@ -62,6 +62,7 @@ Component({ console.log(`${TAG_NAME}, handleUserAccept, event${JSON.stringify(event)}`); this.setData({ callStatus: 'connection', + userList: event.data.userList, }); }, @@ -109,6 +110,9 @@ Component({ // 用户拒绝 handleInviteeReject(event) { console.log(`${TAG_NAME}, handleInviteeReject, event${JSON.stringify(event)}`); + if (this.data.playerList.length===0) { + this.reset(); + } wx.showToast({ title: `${this.handleCallingUser([event.data.invitee])}已拒绝`, }); @@ -116,6 +120,9 @@ Component({ // 用户不在线 handleNoResponse(event) { console.log(`${TAG_NAME}, handleNoResponse, event${JSON.stringify(event)}`); + if (this.data.playerList.length===0) { + this.reset(); + } wx.showToast({ title: `${this.handleCallingUser(event.data.timeoutUserList)}不在线`, }); @@ -123,6 +130,9 @@ Component({ // 用户忙线 handleLineBusy(event) { console.log(`${TAG_NAME}, handleLineBusy, event${JSON.stringify(event)}`); + if (this.data.playerList.length===0) { + this.reset(); + } wx.showToast({ title: `${this.handleCallingUser([event.data.invitee])}忙线中`, }); @@ -130,6 +140,9 @@ Component({ // 用户取消 handleCallingCancel(event) { console.log(`${TAG_NAME}, handleCallingCancel, event${JSON.stringify(event)}`); + if (this.data.playerList.length===0) { + this.reset(); + } wx.showToast({ title: `${this.handleCallingUser([event.data.invitee])}取消通话`, }); @@ -137,6 +150,9 @@ Component({ // 通话超时未应答 handleCallingTimeout(event) { console.log(`${TAG_NAME}, handleCallingTimeout, event${JSON.stringify(event)}`); + if (this.data.playerList.length===0) { + this.reset(); + } wx.showToast({ title: `${this.handleCallingUser(event.data.timeoutUserList)}超时无应答`, }); @@ -183,6 +199,7 @@ Component({ // 切换通话模式 handleCallMode(event) { this.data.config.type = event.data.type; + this.toggleSoundMode(); this.setData({ config: this.data.config, }); @@ -261,6 +278,10 @@ Component({ */ async call(params) { this.initCall(); + if (this.data.callStatus !== 'idle') { + console.warn(`${TAG_NAME}, call callStatus isn't idle`); + return; + } wx.$TRTCCalling.call({ userID: params.userID, type: params.type }).then((res) => { this.data.config.type = params.type; this.getUserProfile([params.userID]); @@ -285,6 +306,10 @@ Component({ */ async groupCall(params) { this.initCall(); + if (this.data.callStatus !== 'idle') { + console.warn(`${TAG_NAME}, groupCall callStatus isn't idle`); + return; + } wx.$TRTCCalling.groupCall({ userIDList: params.userIDList, type: params.type, groupID: params.groupID }).then((res) => { this.data.config.type = params.type; this.getUserProfile(params.userIDList); @@ -301,6 +326,7 @@ Component({ */ async accept() { wx.$TRTCCalling.accept().then((res) => { + console.log('accept', res); this.setData({ pusher: res.pusher, callStatus: 'connection', @@ -348,6 +374,7 @@ Component({ this.setData({ callStatus: 'idle', isSponsor: false, + soundMode: 'speaker', pusher: {}, // TRTC 本地流 playerList: [], // TRTC 远端流 }); @@ -371,6 +398,7 @@ Component({ case 'switchAudioCall': wx.$TRTCCalling.switchAudioCall().then((res) => { this.data.config.type = wx.$TRTCCalling.CALL_TYPE.AUDIO; + this.toggleSoundMode(); this.setData({ config: this.data.config, }); @@ -426,7 +454,8 @@ Component({ break; case 'switchAudioCall': wx.$TRTCCalling.switchAudioCall().then((res) => { - this.data.config.type = 1; + this.data.config.type = wx.$TRTCCalling.CALL_TYPE.AUDIO; + this.toggleSoundMode(); this.setData({ config: this.data.config, }); @@ -453,12 +482,12 @@ Component({ }, // 初始化TRTCCalling async init() { + this._addTSignalingEvent(); try { const res = await wx.$TRTCCalling.login({ userID: this.data.config.userID, userSig: this.data.config.userSig, }); - this._addTSignalingEvent(); return res; } catch (error) { throw new Error('TRTCCalling login failure', error); @@ -488,7 +517,7 @@ Component({ if (!wx.$TRTCCalling) { wx.$TRTCCalling = new TRTCCalling({ sdkAppID: this.data.config.sdkAppID, - tim: this.data.config.tim, + tim: wx.$tim, }); } wx.$TRTCCalling.initData(); diff --git a/MiniProgram/TUIKit/miniprogram/components/TUICalling/TUICalling.wxml b/MiniProgram/TUIKit/miniprogram/components/TUICalling/TUICalling.wxml index 8fd46f33f7..5141631870 100644 --- a/MiniProgram/TUIKit/miniprogram/components/TUICalling/TUICalling.wxml +++ b/MiniProgram/TUIKit/miniprogram/components/TUICalling/TUICalling.wxml @@ -8,9 +8,10 @@ remoteUsers="{{remoteUsers}}" bind:callingEvent="handleCallingEvent" > - - \ No newline at end of file + diff --git a/MiniProgram/TUIKit/miniprogram/components/TUICalling/component/calling/calling.js b/MiniProgram/TUIKit/miniprogram/components/TUICalling/component/calling/calling.js index 035c2fcfbd..e6dcfaa148 100644 --- a/MiniProgram/TUIKit/miniprogram/components/TUICalling/component/calling/calling.js +++ b/MiniProgram/TUIKit/miniprogram/components/TUICalling/component/calling/calling.js @@ -1,5 +1,4 @@ // components/tui-calling/TUICalling/component/calling.js -// eslint-disable-next-line no-undef Component({ /** * 组件的属性列表 @@ -27,6 +26,25 @@ Component({ }, + /** + * 生命周期方法 + */ + lifetimes: { + created() { + + }, + attached() { + }, + ready() { + wx.createLivePusherContext().startPreview() + }, + detached() { + wx.createLivePusherContext().stopPreview() + }, + error() { + }, + }, + /** * 组件的方法列表 */ diff --git a/MiniProgram/TUIKit/miniprogram/components/TUICalling/component/calling/calling.wxml b/MiniProgram/TUIKit/miniprogram/components/TUICalling/component/calling/calling.wxml index e733d944f0..847748c88a 100644 --- a/MiniProgram/TUIKit/miniprogram/components/TUICalling/component/calling/calling.wxml +++ b/MiniProgram/TUIKit/miniprogram/components/TUICalling/component/calling/calling.wxml @@ -1,47 +1,57 @@ - + - - - - + + - - 邀请你视频通话 - 等待对方接受 + + 邀请你视频通话 + 等待对方接受 - + - - - + + + - - 邀请你视频通话 - 等待对方接受 + + 邀请你视频通话 + 等待对方接受 - 切换到语音通话 + 切到语音通话 - - - + + + + + + + + 挂断 + - + @@ -49,52 +59,55 @@ 挂断 - - + + 接听 - + - - - {{remoteUsers[0].nick || remoteUsers[0].userID}} - {{'等待对方接受'}} + + + {{remoteUsers[0].nick || remoteUsers[0].userID}} + {{'等待对方接受'}} - - - + + + - - 邀请你视频通话 - 等待对方接受 + + 邀请你视频通话 + 等待对方接受 - - - + + + + + 挂断 - - + + + + + 接听 - - + + + + + 挂断 - \ No newline at end of file + diff --git a/MiniProgram/TUIKit/miniprogram/components/TUICalling/component/calling/calling.wxss b/MiniProgram/TUIKit/miniprogram/components/TUICalling/component/calling/calling.wxss index 1474a46975..9f30af3ae9 100644 --- a/MiniProgram/TUIKit/miniprogram/components/TUICalling/component/calling/calling.wxss +++ b/MiniProgram/TUIKit/miniprogram/components/TUICalling/component/calling/calling.wxss @@ -7,26 +7,36 @@ justify-content: center; align-items: center; } +.button-container { + display: flex; + flex-direction: column; + text-align: center; +} .btn-operate { display: flex; justify-content: space-between; + /* flex-direction: column; + text-align: center; */ + } .btn-operate-item{ display: flex; flex-direction: column; align-items: center; + margin-bottom: 20px; } .btn-operate-item text { - padding: 8px 0; - font-size: 18px; - color: #FFFFFF; + font-size: 14px; + color: #f0e9e9; + padding: 5px; letter-spacing: 0; font-weight: 400; } .call-switch text{ - padding: 0; + padding: 5px; + color: #f0e9e9; font-size: 14px; } @@ -42,13 +52,12 @@ } .call-switch .call-operate { width: 4vh; - height: 4vh; - padding: 2vh 0 4vh; + height: 3vh; } .call-operate image { - width: 4vh; - height: 4vh; + width: 100%; + height: 100%; background: none; } @@ -96,9 +105,18 @@ .invite-calling-header { margin-top:107px; display: flex; - justify-content: space-between; + justify-content: flex-end; padding: 0 16px; - + +} +.btn-container { + display: flex; + align-items: center; + position: relative; +} +.invite-calling-header-left { + position: absolute; + right: 0; } .invite-calling-header-left image { width: 32px; @@ -126,6 +144,7 @@ .invite-calling .btn-operate{ display: flex; justify-content: center; + align-items: center; } @@ -220,4 +239,4 @@ .avatar { background: #dddddd; -} \ No newline at end of file +} diff --git a/MiniProgram/TUIKit/miniprogram/components/TUICalling/component/connected/connected.js b/MiniProgram/TUIKit/miniprogram/components/TUICalling/component/connected/connected.js index 875cfe2a4a..feb6a09b03 100644 --- a/MiniProgram/TUIKit/miniprogram/components/TUICalling/component/connected/connected.js +++ b/MiniProgram/TUIKit/miniprogram/components/TUICalling/component/connected/connected.js @@ -1,4 +1,3 @@ -// eslint-disable-next-line no-undef Component({ /** * 组件的属性列表 @@ -19,6 +18,9 @@ Component({ screen: { type: String, }, + userList: { + type: Object, + }, }, /** @@ -124,21 +126,20 @@ Component({ this.triggerEvent('connectedEvent', data); }, handleConnectErrorImage(e) { - const { value, flag } = e.target.dataset; + const { flag, key, index } = e.target.dataset; if (flag === 'pusher') { this.data.pusher.avatar = '../../static/default_avatar.png'; this.setData({ pusher: this.data.pusher, }); } else { - const playerList = this.data.playerList.map((item) => { - if (item.userID === value) { - item.avatar = '../../static/default_avatar.png'; - } - return item; - }); + this.data[key][index].avatar = '../../static/default_avatar.png'; + if(this.data.playerList[index]) { + this.data.playerList[index].avatar = '../../static/default_avatar.png'; + } this.setData({ - playerList, + playerList: this.data.playerList, + [key]: this.data[key] }); } }, diff --git a/MiniProgram/TUIKit/miniprogram/components/TUICalling/component/connected/connected.wxml b/MiniProgram/TUIKit/miniprogram/components/TUICalling/component/connected/connected.wxml index 86ecda05c9..d97199bb91 100644 --- a/MiniProgram/TUIKit/miniprogram/components/TUICalling/component/connected/connected.wxml +++ b/MiniProgram/TUIKit/miniprogram/components/TUICalling/component/connected/connected.wxml @@ -1,116 +1,118 @@ - - + + - + {{pusher.nick || pusher.userID}}(自己) - - + + {{item.nick || item.userID}} - - - + + + {{pusher.chatTime}} + + + + + 切到语音通话 + - - + + + + + + 麦克风 - - + + + + + + 挂断 - - + + + + + + 扬声器 - - + + + + + + + 摄像头 - + - - + + + + + + + 挂断 - + diff --git a/MiniProgram/TUIKit/miniprogram/components/TUICalling/component/connected/connected.wxss b/MiniProgram/TUIKit/miniprogram/components/TUICalling/component/connected/connected.wxss index 348110fa59..d7f0ee2c23 100644 --- a/MiniProgram/TUIKit/miniprogram/components/TUICalling/component/connected/connected.wxss +++ b/MiniProgram/TUIKit/miniprogram/components/TUICalling/component/connected/connected.wxss @@ -6,83 +6,97 @@ height: 178px; padding: 16px; z-index: 3; - } - .pusher-video { +} + +.pusher-video { position: absolute; width: 100%; height: 100%; /* background-color: #f75c45; */ z-index: 1; - } - .stream-box { +} + +.stream-box { position: relative; float: left; width: 50vw; height: 260px; /* background-color: #f75c45; */ z-index: 3; - } - .handle-btns { +} + +.handle-btns { position: absolute; bottom: 44px; width: 100vw; z-index: 3; display: flex; flex-direction: column; - } - .handle-btns .btn-list { +} + +.handle-btns .btn-list { display: flex; flex-direction: row; justify-content: space-around; align-items: center; - } - - .btn-normal { +} + +.button-container { + display: flex; + flex-direction: column; + text-align: center; +} + +.btn-normal { width: 8vh; height: 8vh; box-sizing: border-box; display: flex; + flex-direction: column; /* background: white; */ justify-content: center; align-items: center; border-radius: 50%; - } - .btn-image{ - width: 8vh; - height: 8vh; +} + +.btn-image { + width: 100%; + height: 100%; background: none; - } - .btn-hangup { +} + +.btn-hangup { width: 8vh; height: 8vh; - background: #f75c45; + /*background: #f75c45;*/ box-sizing: border-box; display: flex; justify-content: center; align-items: center; border-radius: 50%; - } - .btn-hangup>.btn-image { - width: 4vh; - height: 4vh; +} + +.btn-hangup > .btn-image { + width: 100%; + height: 100%; background: none; - } - - .TRTCCalling-call-audio { +} + +.TRTCCalling-call-audio { width: 100%; height: 100%; - } +} - .btn-footer { +.btn-footer { position: relative; - } - - .btn-footer .multi-camera { +} + +.btn-footer .multi-camera { width: 32px; height: 32px; - } - - .btn-footer .camera { +} + +.btn-footer .camera { width: 64px; height: 64px; position: fixed; @@ -91,96 +105,149 @@ display: flex; justify-content: center; align-items: center; - background: rgba(#ffffff, 0.7); - } - .btn-footer .camera .camera-image { + background: rgba(255, 255, 255, 0.7); +} + +.btn-footer .camera .camera-image { width: 32px; height: 32px; - } - +} + .TUICalling-connected-layout { - width: 100%; - height: 100%; + width: 100%; + height: 100%; } -.audio{ - padding-top: 15vh; - background: #ffffff; + +.audio { + padding-top: 15vh; + background: #ffffff; } .pusher-audio { - width: 0; - height: 0; + width: 0; + height: 0; } -.player-audio{ - width: 0; - height: 0; +.player-audio { + width: 0; + height: 0; } .live { - width: 100%; - height: 100%; + width: 100%; + height: 100%; } .other-view { - display: flex; - flex-direction: column; - align-items: center; - font-size: 18px; - letter-spacing: 0; - font-weight: 400; - padding: 16px; + display: flex; + flex-direction: column; + align-items: center; + font-size: 18px; + letter-spacing: 0; + font-weight: 400; + padding: 16px; } .white { - color: #FFFFFF; - padding: 5px; + color: #f0e9e9; + padding: 5px; + font-size: 14px; } .black { - color: #000000; - padding: 5px; + color: #000000; + padding: 5px; } .TRTCCalling-call-audio-box { - display: flex; - flex-wrap: wrap; - justify-content: center; + display: flex; + flex-wrap: wrap; + justify-content: center; } + .mutil-img { - justify-content: flex-start !important; + justify-content: flex-start !important; } .TRTCCalling-call-audio-img { - display: flex; - flex-direction: column; - align-items: center; + display: flex; + flex-direction: column; + align-items: center; } -.TRTCCalling-call-audio-img>image { - width: 25vw; - height: 25vw; - margin: 0 4vw; - border-radius: 4vw; - position: relative; + +.TRTCCalling-call-audio-img > image { + width: 25vw; + height: 25vw; + margin: 0 4vw; + border-radius: 4vw; + position: relative; } -.TRTCCalling-call-audio-img text{ - font-size: 20px; - color: #333333; - letter-spacing: 0; - font-weight: 500; + +.TRTCCalling-call-audio-img text { + font-size: 20px; + color: #333333; + letter-spacing: 0; + font-weight: 500; } .btn-list-item { - flex: 1; - display: flex; - justify-content: center; - padding: 16px 0; + flex: 1; + display: flex; + justify-content: center; + padding: 16px 0; } .btn-image-small { - transform: scale(.7); + transform: scale(.7); } .avatar { - background: #dddddd; -} \ No newline at end of file + background: #dddddd; +} + +.btn-container { + display: flex; + align-items: center; + position: relative; +} + +.invite-calling-header-left { + position: absolute; + right: -88px; +} + +.invite-calling-header-left image { + width: 32px; + height: 32px; +} + +.call-switch .call-operate { + width: 4vh; + height: 3vh; +} + +.call-operate image { + width: 100%; + height: 100%; + background: none; +} + +.call-switch text { + padding: 0; + font-size: 14px; +} + +.btn-operate-item { + display: flex; + flex-direction: column; + align-items: center; +} + +.btn-operate-item text { + padding: 8px 0; + font-size: 18px; + color: #FFFFFF; + letter-spacing: 0; + font-weight: 400; + font-size: 14px; +} diff --git a/MiniProgram/TUIKit/miniprogram/components/TUICalling/static/audio-false.png b/MiniProgram/TUIKit/miniprogram/components/TUICalling/static/audio-false.png index e962fa9795..f0b99788c7 100644 Binary files a/MiniProgram/TUIKit/miniprogram/components/TUICalling/static/audio-false.png and b/MiniProgram/TUIKit/miniprogram/components/TUICalling/static/audio-false.png differ diff --git a/MiniProgram/TUIKit/miniprogram/components/TUICalling/static/audio-true.png b/MiniProgram/TUIKit/miniprogram/components/TUICalling/static/audio-true.png index 909520009d..8a13b6d9c3 100644 Binary files a/MiniProgram/TUIKit/miniprogram/components/TUICalling/static/audio-true.png and b/MiniProgram/TUIKit/miniprogram/components/TUICalling/static/audio-true.png differ diff --git a/MiniProgram/TUIKit/miniprogram/components/TUICalling/static/camera-false.png b/MiniProgram/TUIKit/miniprogram/components/TUICalling/static/camera-false.png index 4889104554..2093ad2040 100644 Binary files a/MiniProgram/TUIKit/miniprogram/components/TUICalling/static/camera-false.png and b/MiniProgram/TUIKit/miniprogram/components/TUICalling/static/camera-false.png differ diff --git a/MiniProgram/TUIKit/miniprogram/components/TUICalling/static/camera-true.png b/MiniProgram/TUIKit/miniprogram/components/TUICalling/static/camera-true.png index 8502a30fe0..c4c00b0605 100644 Binary files a/MiniProgram/TUIKit/miniprogram/components/TUICalling/static/camera-true.png and b/MiniProgram/TUIKit/miniprogram/components/TUICalling/static/camera-true.png differ diff --git a/MiniProgram/TUIKit/miniprogram/components/TUICalling/static/dialing.png b/MiniProgram/TUIKit/miniprogram/components/TUICalling/static/dialing.png new file mode 100644 index 0000000000..c762da9cec Binary files /dev/null and b/MiniProgram/TUIKit/miniprogram/components/TUICalling/static/dialing.png differ diff --git a/MiniProgram/TUIKit/miniprogram/components/TUICalling/static/hangup.png b/MiniProgram/TUIKit/miniprogram/components/TUICalling/static/hangup.png index c548495448..24341516ff 100644 Binary files a/MiniProgram/TUIKit/miniprogram/components/TUICalling/static/hangup.png and b/MiniProgram/TUIKit/miniprogram/components/TUICalling/static/hangup.png differ diff --git a/MiniProgram/TUIKit/miniprogram/components/TUICalling/static/speaker-false.png b/MiniProgram/TUIKit/miniprogram/components/TUICalling/static/speaker-false.png index 0357745f01..4042495ae8 100644 Binary files a/MiniProgram/TUIKit/miniprogram/components/TUICalling/static/speaker-false.png and b/MiniProgram/TUIKit/miniprogram/components/TUICalling/static/speaker-false.png differ diff --git a/MiniProgram/TUIKit/miniprogram/components/TUICalling/static/speaker-true.png b/MiniProgram/TUIKit/miniprogram/components/TUICalling/static/speaker-true.png index 40b728e3ac..5ec86cab71 100644 Binary files a/MiniProgram/TUIKit/miniprogram/components/TUICalling/static/speaker-true.png and b/MiniProgram/TUIKit/miniprogram/components/TUICalling/static/speaker-true.png differ diff --git a/MiniProgram/TUIKit/miniprogram/components/TUICalling/static/switch_camera.png b/MiniProgram/TUIKit/miniprogram/components/TUICalling/static/switch_camera.png new file mode 100644 index 0000000000..6159919670 Binary files /dev/null and b/MiniProgram/TUIKit/miniprogram/components/TUICalling/static/switch_camera.png differ diff --git a/MiniProgram/TUIKit/miniprogram/components/TUICalling/static/trans.png b/MiniProgram/TUIKit/miniprogram/components/TUICalling/static/trans.png index 8c77517bf0..1bbcea7d43 100644 Binary files a/MiniProgram/TUIKit/miniprogram/components/TUICalling/static/trans.png and b/MiniProgram/TUIKit/miniprogram/components/TUICalling/static/trans.png differ