2025-04-09 18:55:14 +08:00

2 lines
430 KiB
JavaScript

'use strict';const e={SDK_READY:"sdkStateReady",SDK_NOT_READY:"sdkStateNotReady",SDK_DESTROY:"sdkDestroy",MESSAGE_RECEIVED:"onMessageReceived",ROOM_CUSTOM_DATA_RECEIVED:"onRoomCustomDataReceived",MESSAGE_MODIFIED:"onMessageModified",MESSAGE_REVOKED:"onMessageRevoked",MESSAGE_READ_BY_PEER:"onMessageReadByPeer",MESSAGE_READ_RECEIPT_RECEIVED:"onMessageReadReceiptReceived",MESSAGE_EXTENSIONS_UPDATED:"onMessageExtensionsUpdated",MESSAGE_EXTENSIONS_DELETED:"onMessageExtensionsDeleted",MESSAGE_REACTIONS_UPDATED:"onMessageReactionsUpdated",CONVERSATION_LIST_UPDATED:"onConversationListUpdated",TOTAL_UNREAD_MESSAGE_COUNT_UPDATED:"onTotalUnreadMessageCountUpdated",CONVERSATION_GROUP_LIST_UPDATED:"onConversationGroupListUpdated",CONVERSATION_IN_GROUP_UPDATED:"onConversationInGroupUpdated",GROUP_LIST_UPDATED:"onGroupListUpdated",GROUP_ATTRIBUTES_UPDATED:"groupAttributesUpdated",GROUP_COUNTER_UPDATED:"onGroupCounterUpdated",TOPIC_CREATED:"onTopicCreated",TOPIC_DELETED:"onTopicDeleted",TOPIC_UPDATED:"onTopicUpdated",PROFILE_UPDATED:"onProfileUpdated",USER_STATUS_UPDATED:"onUserStatusUpdated",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"},t={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,CONV_MARK_TYPE_STAR:1,CONV_MARK_TYPE_UNREAD:2,CONV_MARK_TYPE_FOLD:4,CONV_MARK_TYPE_HIDE:8,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,GRP_TIP_BAN_AVCHATROOM_MEMBER:10,GRP_TIP_UNBAN_AVCHATROOM_MEMBER:11,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",INVITE_OPTIONS_DISABLE_INVITE:"DisableInvite",INVITE_OPTIONS_NEED_PERMISSION:"NeedPermission",INVITE_OPTIONS_FREE_ACCESS:"FreeAccess",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_INVITE_OPTION:"inviteOption",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",USER_STATUS_UNKNOWN:0,USER_STATUS_ONLINE:1,USER_STATUS_OFFLINE:2,USER_STATUS_UNLOGINED:3};class s{constructor(){this.cache=[],this.options=null}use(e){if("function"!=typeof e)throw"middleware must be a function";return this.cache.push(e),this}next(e){if(this.middlewares&&this.middlewares.length>0){return this.middlewares.shift().call(this,this.options,this.next.bind(this))}}run(e){return this.middlewares=this.cache.map((function(e){return e})),this.options=e,this.next()}}class o{constructor(e=0,t=0){this.high=e,this.low=t}equal(e){return null!==e&&(this.low===e.low&&this.high===e.high)}toString(){const e=Number(this.high).toString(16);let t=Number(this.low).toString(16);if(t.length<8){let e=8-t.length;for(;e;)t="0"+t,e--}return e+t}}const i={TEST:{CHINA:{DEFAULT:"wss://wss-dev.tim.qq.com"},OVERSEA:{DEFAULT:"wss://wss-dev.tim.qq.com"},SINGAPORE:{DEFAULT:"wss://wsssgp-dev.im.qcloud.com"},KOREA:{DEFAULT:"wss://wsskr-dev.im.qcloud.com"},GERMANY:{DEFAULT:"wss://wssger-dev.im.qcloud.com"},IND:{DEFAULT:"wss://wssind-dev.im.qcloud.com"},JPN:{DEFAULT:"wss://wssjpn-dev.im.qcloud.com"},USA:{DEFAULT:"wss://wssusa-dev.im.qcloud.com"},INDONESIA:{DEFAULT:"wss://wssidn-dev.im.qcloud.com"}},PRODUCTION:{CHINA:{DEFAULT:"wss://wss.im.qcloud.com",BACKUP:"wss://wss.tim.qq.com",STAT:"https://events.im.qcloud.com",ANYCAST:"wss://162.14.13.203"},OVERSEA:{DEFAULT:"wss://wss.im.qcloud.com",BACKUP:"wss://wss.my-imcloud.com",STAT:"https://api.my-imcloud.com"},SINGAPORE:{DEFAULT:"wss://wsssgp.im.qcloud.com",BACKUP:"wss://wsssgp.my-imcloud.com",STAT:"https://apisgp.my-imcloud.com",ANYCAST:"wss://162.14.19.159"},KOREA:{DEFAULT:"wss://wsskr.im.qcloud.com",BACKUP:"wss://wsskr.my-imcloud.com",STAT:"https://apikr.my-imcloud.com",ANYCAST:"wss://162.14.13.104"},GERMANY:{DEFAULT:"wss://wssger.im.qcloud.com",BACKUP:"wss://wssger.my-imcloud.com",STAT:"https://apiger.my-imcloud.com",ANYCAST:"wss://162.14.3.17"},IND:{DEFAULT:"wss://wssind.my-imcloud.com",BACKUP:"wss://wssind.im.qcloud.com",STAT:"https://apiind.my-imcloud.com",ANYCAST:"wss://162.14.18.188"},JPN:{DEFAULT:"wss://wssjpn.im.qcloud.com",BACKUP:"wss://wssjpn.my-imcloud.com",STAT:"https://apijpn.my-imcloud.com"},USA:{DEFAULT:"wss://wssusa.im.qcloud.com",BACKUP:"wss://wssusa.my-imcloud.com",STAT:"https://apiusa.my-imcloud.com",ANYCAST:"wss://162.14.10.42"},INDONESIA:{DEFAULT:"wss://wssidn.im.qcloud.com",BACKUP:"wss://wssidn.my-imcloud.com",STAT:"https://apiidn.my-imcloud.com",ANYCAST:"wss://43.129.34.169"}}},n={ANDROID:2,IOS:3,MAC:4,WEB:7,WX_MP:8,QQ_MP:9,TT_MP:10,BAIDU_MP:11,ALI_MP:12,IPAD:13,UNI_NATIVE_APP:15},r="1.7.3",a=537048168,c="CHINA",u="OVERSEA",l="SINGAPORE",d="KOREA",_="GERMANY",p="IND",h="JPN",g="USA",m="INDONESIA",M={HOST:{CURRENT:{DEFAULT:"wss://wss.im.qcloud.com",STAT:"https://events.im.qcloud.com"},setCurrent(e=c){this.CURRENT=i.PRODUCTION[e]}},NAME:{OPEN_IM:"openim",OPEN_IM_MSG_EXT:"openim_msg_ext_http_svc",GROUP:"group_open_http_svc",GROUP_AVCHATROOM:"group_open_avchatroom_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",IM_MSG_AUDIT_MGR:"im_msg_audit_mgr",TUIROOM_SVR:"tui_room_svr",IM_OPEN_TRANSLATE:"im_open_translate",IM_OPEN_SPEECH:"im_open_speech",MESSAGE_SEARCH:"message_search"},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"}},I={SEARCH_MSG:new o(0,Math.pow(2,0)).toString(),SEARCH_GRP_SNS:new o(0,Math.pow(2,1)).toString(),AVCHATROOM_HISTORY_MSG:new o(0,Math.pow(2,2)).toString(),GRP_COMMUNITY:new o(0,Math.pow(2,3)).toString(),MSG_TO_SPECIFIED_GRP_MBR:new o(0,Math.pow(2,4)).toString(),AVCHATROOM_MBR_LIST:new o(0,Math.pow(2,6)).toString(),USER_STATUS:new o(0,Math.pow(2,7)).toString(),CONV_MARK:new o(0,Math.pow(2,9)).toString(),CONV_GROUP:new o(0,Math.pow(2,10)).toString(),AVCHATROOM_BAN_MBR:new o(0,Math.pow(2,11)).toString(),MSG_EXT:new o(0,Math.pow(2,13)).toString(),GRP_COUNTER:new o(0,Math.pow(2,15)).toString(),MSG_REACTION:new o(Math.pow(2,16)).toString()},f="c2c_text_message",T="c2c_custom_message",C="group_text_message",E="group_custom_message",S="user_profile",y="group_profile";M.HOST.setCurrent(c);const D="undefined"!=typeof wx&&"function"==typeof wx.getSystemInfoSync&&Boolean(wx.getSystemInfoSync().fontSizeSetting),N=D&&"function"==typeof wx.createGamePortal,v="undefined"!=typeof qq&&"function"==typeof qq.getSystemInfoSync&&Boolean(qq.getSystemInfoSync().fontSizeSetting),A="undefined"!=typeof tt&&"function"==typeof tt.getSystemInfoSync&&Boolean(tt.getSystemInfoSync().fontSizeSetting),O="undefined"!=typeof swan&&"function"==typeof swan.getSystemInfoSync&&Boolean(swan.getSystemInfoSync().fontSizeSetting),R="undefined"!=typeof my&&"function"==typeof my.getSystemInfoSync&&Boolean(my.getSystemInfoSync().fontSizeSetting),L="undefined"!=typeof jd&&"function"==typeof jd.getSystemInfoSync,U="undefined"!=typeof uni&&"undefined"==typeof window&&"function"==typeof uni.requireNativePlugin,P="undefined"!=typeof uni,G=D||v||A||O||R||U||L,k=("undefined"!=typeof uni||"undefined"!=typeof window)&&!G,w=v?qq:A?tt:O?swan:R?my:D?wx:U?uni:L?jd:{},F=k&&window&&window.navigator&&window.navigator.userAgent||"",$=/(micromessenger|webbrowser)/i.test(F),b=/AppleWebKit\/([\d.]+)/i.exec(F);b&&parseFloat(b.pop());const q=function(){let e="WEB";return $?e="WEB":v?e="QQ_MP":A?e="TT_MP":O?e="BAIDU_MP":R?e="ALI_MP":D?e="WX_MP":U&&(e="UNI_NATIVE_APP"),n[e]}(),x=/iPad/i.test(F),V=/iPhone/i.test(F)&&!x,B=/iPod/i.test(F),K=V||x||B,H=function(){const e=F.match(/OS (\d+)_/i);return e&&e[1]?e[1]:null}(),Y=/Android/i.test(F),W=function(){const e=F.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);if(!e)return null;const t=e[1]&&parseFloat(e[1]),s=e[2]&&parseFloat(e[2]);return t&&s?parseFloat(e[1]+"."+e[2]):t||null}(),z=/Edge/i.test(F),j=!z&&/Chrome/i.test(F);!function(){const e=F.match(/Chrome\/(\d+)/);e&&e[1]&&parseFloat(e[1])}();const J=/MSIE/.test(F)||F.indexOf("Trident")>-1&&F.indexOf("rv:11.0")>-1,X=function(){const e=/MSIE\s(\d+)\.\d/.exec(F);let t=e&&parseFloat(e[1]);return!t&&/Trident\/7.0/i.test(F)&&/rv:11.0/.test(F)&&(t=11),t}(),Q=/Safari/i.test(F)&&!j&&!Y&&!z;!function(){const e=F.match(/TBS\/(\d+)/i);if(e&&e[1])e[1]}();const Z=/Windows/i.test(F),ee=/MAC OS X/i.test(F),te=k&&"undefined"!=typeof Worker&&!J,se=Y||K,oe=k&&void 0!==window.tencent_cloud_im_csig_flutter_for_web_25F_cy,ie=function(){if("undefined"==typeof window)return!1;const e=window.navigator.standalone;return!(!K||e||Q)}();let ne,re;ne="undefined"!=typeof console?console:"undefined"!=typeof global&&global.console?global.console:"undefined"!=typeof window&&window.console?window.console:{};const ae=function(){},ce=["assert","clear","count","debug","dir","dirxml","error","group","groupCollapsed","groupEnd","info","log","profile","profileEnd","table","time","timeEnd","timeStamp","trace","warn"];let ue=ce.length;for(;ue--;)re=ce[ue],console[re]||(ne[re]=ae);var le=ne;let de=0;const _e=function(){return(new Date).getTime()+de},pe=function(){de=0},he=function(){return Math.floor(_e()/1e3)};let ge=0;function me(){return Mt()?"%c Chat %c":"Chat"}function Me(){const e=function(){const e=new Date;return e.setTime(_e()),e}();return e.toLocaleTimeString("en-US",{hour12:!1})+"."+function(e){let t;switch(e.toString().length){case 1:t="00"+e;break;case 2:t="0"+e;break;default:t=e}return t}(e.getMilliseconds())}const Ie={arguments2String(e){let t="";if(1===e.length)t=e[0];else for(let s=0,o=e.length;s<o;s++)Ge(e[s])?we(e[s])?t+=xe(e[s]):t+=JSON.stringify(e[s]):t+=e[s],t+=" ";return t},_exec(e,t){Mt()?le[e](me(),"background:#0abf5b; padding:1px; border-radius:3px; color: #fff","background:transparent",Me(),t):le[e](`${me()} ${Me()} ${t}`)},d:function(){if(ge<=-1){const e=this.arguments2String(arguments);this._exec("debug",e)}},l:function(){if(ge<=0){const e=this.arguments2String(arguments);this._exec("log",e)}},log:function(){if(ge<=0){const e=this.arguments2String(arguments);this._exec("log",e)}},i:function(){if(ge<=1){const e=this.arguments2String(arguments);this._exec("info",e)}},w:function(){if(ge<=2){const e=this.arguments2String(arguments);this._exec("warn",e)}},e:function(){if(ge<=3){const e=this.arguments2String(arguments);this._exec("error",e)}},setLevel:function(e){e<4&&this._exec("log","set level from "+ge+" to "+e),ge=e},getLevel:function(){return ge}},fe={JPG:1,JPEG:1,GIF:2,PNG:3,BMP:4,UNKNOWN:255},Te={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"},Ce={UNKNOWN:"Gender_Type_Unknown",FEMALE:"Gender_Type_Female",MALE:"Gender_Type_Male"},Ee={NONE:"AdminForbid_Type_None",SEND_OUT:"AdminForbid_Type_SendOut"},Se={NEED_CONFIRM:"AllowType_Type_NeedConfirm",ALLOW_ANY:"AllowType_Type_AllowAny",DENY_ANY:"AllowType_Type_DenyAny"},ye="@TGS#_",De="@TOPIC#_",Ne=function(e){return"map"===$e(e)},ve=function(e){return"file"===$e(e)},Ae=function(e){return null!==e&&("number"==typeof e&&!isNaN(e-0)||"object"==typeof e&&e.constructor===Number)},Oe=function(e){return"string"==typeof e},Re=function(e){return null!==e&&"object"==typeof e},Le=function(e){if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);if(null===t)return!0;let s=t;for(;null!==Object.getPrototypeOf(s);)s=Object.getPrototypeOf(s);return t===s},Ue=function(e){return"function"==typeof Array.isArray?Array.isArray(e):"array"===$e(e)},Pe=function(e){return void 0===e},Ge=function(e){return Ue(e)||Re(e)},ke=function(e){return"function"==typeof e},we=function(e){return e instanceof Error},Fe=function(e){return"filelist"===$e(e)},$e=function(e){return Object.prototype.toString.call(e).match(/^\[object (.*)\]$/)[1].toLowerCase()},be=function(e){if("string"!=typeof e)return!1;const t=e[0];return!/[^a-zA-Z0-9]/.test(t)};Date.now||(Date.now=function(){return(new Date).getTime()});const qe=function(e,t,s,o){if(!Ge(e)||!Ge(t))return 0;let i=0;const n=Object.keys(t);let r;for(let a=0,c=n.length;a<c;a++)if(r=n[a],!(Pe(t[r])||s&&s.includes(r)))if(Ge(e[r])&&Ge(t[r]))i+=qe(e[r],t[r],s,o);else{if(o&&o.includes(t[r]))continue;e[r]!==t[r]&&(e[r]=t[r],i+=1)}return i},xe=function(e){return JSON.stringify(e,["message","code"])},Ve=function(e){if(0===e.length)return 0;let t=0,s="",o=0,i=1;const n="undefined"!=typeof document&&void 0!==document.characterSet?document.characterSet:"UTF-8";for(;void 0!==e[t];)s=e[t++],i=s.charCodeAt[t]<=255?1:!1===n?3:2,o+=i;return o},Be=function(e){const t=e||99999999;return Math.round(Math.random()*t)},Ke="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",He=Ke.length,Ye=function(e,t){for(const s in e)if(e[s]===t)return!0;return!1},We={},ze=function(e){return-1===e.indexOf("http://")||-1===e.indexOf("https://")?"https://"+e:e.replace(/https|http/,"https")};function je(e,t){if(!Ue(e)||!Ue(t))return!1;let s=!1;return t.forEach(({key:t,value:o})=>{const i=e.find(e=>e.key===t);i?i.value!==o&&(i.value=o,s=!0):(e.push({key:t,value:o}),s=!0)}),s}const Je=e=>e===t.GRP_AVCHATROOM,Xe=({type:e,groupID:s})=>e===t.GRP_COMMUNITY||(""+s).startsWith(ye)&&!(""+s).includes(De),Qe=e=>(""+e).startsWith(ye)&&(""+e).includes(De),Ze=e=>Oe(e)&&e.slice(0,3)===t.CONV_C2C,et=e=>Oe(e)&&e.slice(0,5)===t.CONV_GROUP,st=e=>Oe(e)&&e===t.CONV_SYSTEM;function ot(e,t){const s={};return Object.keys(e).forEach(o=>{s[o]=t(e[o],o)}),s}function it(e){return G?new Promise((t,s)=>{w.getImageInfo({src:e,success(e){t({width:e.width,height:e.height})},fail(){t({width:0,height:0})}})}):J&&9===X?Promise.resolve({width:0,height:0}):new Promise((t,s)=>{let o=new Image;o.onload=function(){t({width:this.width,height:this.height}),o=null},o.onerror=function(){t({width:0,height:0}),o=null},o.src=e})}function nt(){function e(){return(65536*(1+Math.random())|0).toString(16).substring(1)}return`${e()+e()}${e()}${e()}${e()}${e()}${e()}${e()}`}function rt(){let e="unknown";if(ee&&(e="mac"),Z&&(e="windows"),K&&(e="ios"),Y&&(e="android"),G)try{const t=w.getSystemInfoSync().platform;void 0!==t&&(e=t)}catch(t){}return e}function at(e,t){e=e.split("."),t=t.split(".");const s=Math.max(e.length,t.length);for(;e.length<s;)e.push("0");for(;t.length<s;)t.push("0");for(let o=0;o<s;o++){const s=parseInt(e[o]),i=parseInt(t[o]);if(s>i)return 1;if(s<i)return-1}return 0}function ct(e){const{originUrl:t,originWidth:s,originHeight:o,min:i=198}=e,n=parseInt(s),r=parseInt(o),a={url:void 0,width:0,height:0};if((n<=r?n:r)<=i)a.url=t,a.width=n,a.height=r;else{r<=n?(a.width=Math.ceil(n*i/r),a.height=i):(a.width=i,a.height=Math.ceil(r*i/n));const e=t&&t.indexOf("?")>-1?t+"&":t+"?";a.url=198===i?e+"imageView2/3/w/198/h/198":e+"imageView2/3/w/720/h/720"}if(Pe(t)){const{url:e,...t}=a;return t}return a}function ut(e){const t=e[2];e[2]=e[1],e[1]=t;for(let s=0;s<e.length;s++)e[s].setType(s)}function lt(e){const{servcmd:t}=e;return t.slice(t.indexOf(".")+1)}function dt(e,t){return Math.round(Number(e)*Math.pow(10,t))/Math.pow(10,t)}function _t(e,t){return e.includes(t)}function pt(e,t){return e.includes(t)}function ht(e){return e.split(De)[0]}const gt=function(e,s,o){if(Pe(s))return"";switch(e){case t.MSG_TEXT:return s.text;case t.MSG_IMAGE:return o?"[Image]":"[图片]";case t.MSG_LOCATION:return o?"[Location]":"[位置]";case t.MSG_AUDIO:return o?"[Voice]":"[语音]";case t.MSG_VIDEO:return o?"[Video]":"[视频]";case t.MSG_FILE:return o?"[File]":"[文件]";case t.MSG_CUSTOM:return o?"[Custom Messages]":"[自定义消息]";case t.MSG_GRP_TIP:return o?"[Group Notification]":"[群提示消息]";case t.MSG_GRP_SYS_NOTICE:return o?"[Group System Message]":"[群系统通知]";case t.MSG_FACE:return o?"[Animated Sticker]":"[动画表情]";case t.MSG_MERGER:return o?"[Chat Record]":"[聊天记录]";default:return""}};function mt(e){const t=[];if(!Oe(e))return t;const s=e.length;if(0===s)return t;for(let o=s-1;o>=0;o--)"1"===e[o]&&t.push(Math.pow(2,s-o-1));return t}function Mt(){return!J&&!G}function It(e){return"the length of userIDList cannot exceed "+e}function ft(e,t){if(!e)return;let s=e;return t&&(e.startsWith("http://")?s=e.replace(/^http:\/\/[^/]+/,t):e.startsWith("https://")&&(s=e.replace(/^https:\/\/[^/]+/,t))),s}function Tt(e,t=!0,s=!0){const o=Date.now();return t?s?o-e+" ms":Math.round((o-e)/1e3)+" s":s?o-e:Math.round((o-e)/1e3)}function Ct(e){let t=!1;return e&&e>1&&(t=!0),t}const Et=Object.prototype.hasOwnProperty;function St(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(Et.call(e,t))return!1;return!0}return!(!Ne(e)&&(t=e,"set"!==$e(t))&&!ve(e))&&0===e.size;var t}function yt(e,t,s){if(void 0===t)return!0;let o=!0;if(Le(t))Object.keys(t).forEach(i=>{const n=1===e.length?e[0][i]:void 0;o=!!Dt(n,t[i],s,i)&&o});else if(Ue(t))for(let i=0;i<t.length;i++)o=!!Dt(e[i],t[i],s,t[i].name)&&o;if(o)return o;throw new Error("Params validate failed.")}function Dt(e,t,s,o){if(void 0===t)return!0;let i=!0;if(t.required&&St(e)&&(Ie.e(`[${s}] Missing required params: "${o}".`),i=!1),!St(e)){const n=$e(e),r=t.type.toLowerCase();n!==r&&("asyncfunction"===n&&"function"===r||(Ie.e(`[${s}] Invalid params: type check failed for "${o}". Expected ${t.type}.`),i=!1))}return t.validator&&!t.validator(e,s,o)&&(Ie.e(`[${s}] Invalid params: custom validator check failed for "${o}".`),i=!1),i}const Nt={UNSEND:"unSend",SUCCESS:"success",FAIL:"fail"},vt={NOT_START:"notStart",PENDING:"pending",RESOLVED:"resolved",REJECTED:"rejected"},At=function(e){if(!e)return!1;if(Ze(e)||et(e)||st(e))return!0;const t=os("InvalidConversationID",e);return t&&Ie.w(t),!1},Ot=function(e){""!==e.desc&&""!==os("API_REFER")&&Ie.w(`[${e.api}] | ${e.paramName} | ${e.desc}, ${os("API_REFER")}${e.api}`)},Rt=function(){return os("StringRequiredLog")},Lt=function(e){return os("NonEmptyStringRequiredLog",e)},Ut=function(){return os("NumberRequiredLog")},Pt=function(){return os("UndefinedNotAllowedLog")},Gt=function(){return os("FileRequiredLog")},kt=function(){return os("FunctionRequiredLog")},wt=function(){return os("ArrayRequiredLog")},Ft=function(){return os("NonEmptyArrayLog")},$t=function(){return os("CallbackMissingLog")},bt=function(){return os("PositiveIntegerRequiredLog")},qt=function(e,t){return os("StringNotLongerThanLog",e,t)},xt=function(e,t){return os("NumberLessThanLog",e,t)},Vt=function(e,t){return os("NumberGreaterOrEqualLog",e,t)},Bt=function(e){return os("KeyValueStringRequiredLog",e)},Kt=function(){return os("PlainObjectRequiredLog")},Ht=function(){return os("NonEmptyContentRequiredLog")},Yt=function(){return os("FileNotSelectedLog")},Wt=function(){return os("MessageInstanceRequiredLog")},zt=function(){return os("NonAnonymousFunctionLog")},jt=function(){return os("MessageExtensionNotAvailableLog")},Jt=function(){return os("MessageReactionRequiredLog")},Xt=function(e,t){return os("MaximumArrayLengthLog",e,t)},Qt={type:"String",required:!0},Zt={type:"Array",required:!0},es={type:"Object",required:!0},ts={type:"Boolean",required:!0},ss={type:"number",required:!0};let os=null;const is={hookGetAPITips:function(e){os=e},login:{userID:Qt,userSig:Qt},addToBlacklist:{userIDList:Zt},removeFromBlacklist:{userIDList:Zt},on:[{name:"eventName",type:"String",validator:(e,t,s)=>"string"==typeof e&&0!==e.length||(Ot({api:t,paramName:s,desc:Lt(s)}),!1)},{name:"handler",type:"Function",validator:(e,t,s)=>"function"!=typeof e?(Ot({api:t,paramName:s,desc:kt()}),!1):(""===e.name&&Ot({api:t,paramName:s,desc:zt()}),!0)}],once:[{name:"eventName",type:"String",validator:(e,t,s)=>"string"==typeof e&&0!==e.length||(Ot({api:t,paramName:s,desc:Lt(s)}),!1)},{name:"handler",type:"Function",validator:(e,t,s)=>"function"!=typeof e?(Ot({api:t,paramName:s,desc:kt()}),!1):(""===e.name&&Ot({api:t,paramName:s,desc:zt()}),!0)}],off:[{name:"eventName",type:"String",validator:(e,t,s)=>"string"==typeof e&&0!==e.length||(Ot({api:t,paramName:s,desc:Lt(s)}),!1)},{name:"handler",type:"Function",validator:(e,t,s)=>"function"!=typeof e?(Ot({api:t,paramName:s,desc:kt()}),!1):(""===e.name&&Ot({api:t,paramName:s,desc:zt()}),!0)}],sendMessage:[{name:"message",...es}],setMessageExtensions:[{name:"message",...es,validator:(e,t,s)=>e.status===Nt.SUCCESS&&!0===e.isSupportExtension||(Ot({api:t,paramName:s,desc:jt()}),!1)},{name:"extensions",...Zt}],getMessageExtensions:[{name:"message",...es,validator:(e,t,s)=>e.status===Nt.SUCCESS&&!0===e.isSupportExtension||(Ot({api:t,paramName:s,desc:jt()}),!1)}],deleteMessageExtensions:[{name:"message",...es,validator:(e,t,s)=>e.status===Nt.SUCCESS&&!0===e.isSupportExtension||(Ot({api:t,paramName:s,desc:jt()}),!1)}],addMessageReaction:[{name:"message",...es,validator:(e,t,s)=>e.status===Nt.SUCCESS||(Ot({api:t,paramName:s,desc:Jt()}),!1)},{name:"reactionID",...Qt}],removeMessageReaction:[{name:"message",...es,validator:(e,t,s)=>e.status===Nt.SUCCESS||(Ot({api:t,paramName:s,desc:Jt()}),!1)},{name:"reactionID",...Qt}],getMessageReactions:{messageList:{...Zt}},getAllUserListOfMessageReaction:{message:{...es,validator:(e,t,s)=>e.status===Nt.SUCCESS||(Ot({api:t,paramName:s,desc:Jt()}),!1)},reactionID:{...Qt},nextSeq:{type:"Number"},count:{type:"Number"}},getMessageList:{conversationID:{...Qt,validator:e=>At(e)},nextReqMessageID:{type:"String"},count:{type:"Number",validator:(e,t,s)=>!(!Pe(e)&&!/^[1-9][0-9]*$/.test(e))||(Ot({api:t,paramName:s,desc:bt()}),!1)}},getMessageListHopping:{conversationID:{...Qt,validator:e=>At(e)},sequence:{type:"Number"},time:{type:"Number"},direction:{type:"Number",validator:(e,t,s)=>!(!Pe(e)&&0!==e&&1!==e)||(Ot({api:t,paramName:s,desc:os("0Or1RequiredLog")}),!1)},count:{type:"Number",validator:(e,t,s)=>!(!Pe(e)&&!/^[1-9][0-9]*$/.test(e))||(Ot({api:t,paramName:s,desc:bt}),!1)}},setMessageRead:{conversationID:{...Qt,validator:e=>At(e)}},setAllMessageRead:{scope:{type:"String",required:!1,validator:(e,s,o)=>!e||-1!==[t.READ_ALL_C2C_MSG,t.READ_ALL_GROUP_MSG,t.READ_ALL_MSG].indexOf(e)||(Ot({api:s,paramName:o,desc:os("ValidScopeRequired")}),!1)}},getConversationProfile:[{name:"conversationID",...Qt,validator:e=>At(e)}],clearHistoryMessage:[{name:"conversationID",...Qt,validator:e=>At(e)}],pinConversation:{conversationID:{...Qt,validator:e=>At(e)},isPinned:{...ts}},setConversationDraft:{conversationID:{...Qt,validator:e=>At(e)},draftText:{type:"String",validator:(e,t,s)=>!!Oe(e)||(Ot({api:t,paramName:s,desc:Rt()}),!1)}},setConversationCustomData:{conversationIDList:{...Zt},customData:{type:"String",validator:(e,t,s)=>Oe(e)?!(e.length>256)||(Ot({api:t,paramName:s,desc:qt(s,256)}),!1):(Ot({api:t,paramName:s,desc:Rt()}),!1)}},markConversation:{conversationIDList:{...Zt},markType:{type:"number",validator:(e,t,s)=>{return Ae(e)?e<=0?(Ot({api:t,paramName:s,desc:(o=s,i=0,os("NumberGreaterThanLog",o,i))}),!1):!(e>=Math.pow(2,64))||(Ot({api:t,paramName:s,desc:xt(s,"Math.pow(2,64)")}),!1):(Ot({api:t,paramName:s,desc:Ut()}),!1);var o,i}},enableMark:{...ts}},createConversationGroup:{conversationIDList:{...Zt},groupName:{...Qt,validator:(e,t,s)=>!!e&&(!(e.length>32)||(Ot({api:t,paramName:s,desc:qt(s,32)}),!1))}},deleteConversationGroup:[{name:"groupName",...Qt}],renameConversationGroup:{oldName:{...Qt},newName:{...Qt,validator:(e,t,s)=>!!e&&(!(e.length>32)||(Ot({api:t,paramName:s,desc:qt(s,32)}),!1))}},addConversationsToGroup:{conversationIDList:{...Zt},groupName:{...Qt}},deleteConversationsFromGroup:{conversationIDList:{...Zt},groupName:{...Qt}},getGroupList:{groupProfileFilter:{type:"Array"}},getGroupProfile:{groupID:Qt,groupCustomFieldFilter:{type:"Array"},memberCustomFieldFilter:{type:"Array"}},getGroupProfileAdvance:{groupIDList:Zt},createGroup:{name:Qt},joinGroup:{groupID:Qt,type:{type:"String"},applyMessage:{type:"String"}},quitGroup:[{name:"groupID",...Qt}],handleApplication:{message:es,handleAction:Qt,handleMessage:{type:"String"}},changeGroupOwner:{groupID:Qt,newOwnerID:Qt},updateGroupProfile:{groupID:Qt,muteAllMembers:{type:"Boolean"}},dismissGroup:[{name:"groupID",...Qt}],searchGroupByID:[{name:"groupID",...Qt}],getGroupOnlineMemberCount:[{name:"groupID",...Qt}],initGroupAttributes:{groupID:Qt,groupAttributes:{...es,validator:(e,t,s)=>{let o=!0;return Object.keys(e).forEach(i=>{if(!Oe(e[i]))return Ot({api:t,paramName:s,desc:Bt("value")}),o=!1,o}),o}}},setGroupAttributes:{groupID:Qt,groupAttributes:{...es,validator:(e,t,s)=>{let o=!0;return Object.keys(e).forEach(i=>{if(!Oe(e[i]))return Ot({api:t,paramName:s,desc:Bt("value")}),o=!1,o}),o}}},deleteGroupAttributes:{groupID:Qt,keyList:{type:"Array",validator:(e,t,s)=>{if(Pe(e)||!Ue(e))return Ot({api:t,paramName:s,desc:wt()}),!1;if(!St(e)){let o=!0;return e.forEach(e=>{if(!Oe(e))return Ot({api:t,paramName:s,desc:os("StringArrayRequiredLog")}),o=!1,o}),o}return!0}}},getGroupAttributes:{groupID:Qt,keyList:{type:"Array",validator:(e,t,s)=>{if(Pe(e)||!Ue(e))return Ot({api:t,paramName:s,desc:wt()}),!1;if(!St(e)){let o=!0;return e.forEach(e=>{if(!Oe(e))return Ot({api:t,paramName:s,desc:Bt("key")}),o=!1,o}),o}return!0}}},setGroupCounters:{groupID:Qt,counters:es},increaseGroupCounter:{groupID:Qt,key:Qt,value:ss},decreaseGroupCounter:{groupID:Qt,key:Qt,value:ss},getGroupCounters:{groupID:Qt},getGroupMemberList:{groupID:Qt,count:{type:"Number"}},getGroupMemberProfile:{groupID:Qt,userIDList:Zt,memberCustomFieldFilter:{type:"Array"}},addGroupMember:{groupID:Qt,userIDList:Zt},setGroupMemberRole:{groupID:Qt,userID:Qt,role:Qt},setGroupMemberMuteTime:{groupID:Qt,userID:Qt,muteTime:{type:"Number",validator:e=>e>=0}},setGroupMemberNameCard:{groupID:Qt,userID:{type:"String"},nameCard:{type:"String",validator:(e,t,s)=>Oe(e)?(e.length,!0):(Ot({api:t,paramName:s,desc:Rt()}),!1)}},setGroupMemberCustomField:{groupID:Qt,userID:{type:"String"},memberCustomField:Zt},deleteGroupMember:{groupID:Qt},markGroupMemberList:{groupID:Qt,markType:{type:"number",validator:(e,t,s)=>Ae(e)?!(e<1e3)||(Ot({api:t,paramName:s,desc:Vt(s,1e3)}),!1):(Ot({api:t,paramName:s,desc:Ut()}),!1)},userIDList:{...Zt},enableMark:{...ts}},createTextMessage:{to:Qt,conversationType:Qt,payload:{...es,validator:(e,t,s)=>Le(e)?Oe(e.text)?0!==e.text.length||(Ot({api:t,paramName:"payload.text",desc:Ht()}),!1):(Ot({api:t,paramName:"payload.text",desc:Rt()}),!1):(Ot({api:t,paramName:s,desc:Kt()}),!1)}},createTextAtMessage:{to:Qt,conversationType:Qt,payload:{...es,validator:(e,t,s)=>Le(e)?Oe(e.text)?0===e.text.length?(Ot({api:t,paramName:"payload.text",desc:Ht()}),!1):!(e.atUserList&&!Ue(e.atUserList))||(Ot({api:t,paramName:"payload.atUserList",desc:wt()}),!1):(Ot({api:t,paramName:"payload.text",desc:Rt()}),!1):(Ot({api:t,paramName:s,desc:Kt()}),!1)}},createCustomMessage:{to:Qt,conversationType:Qt,payload:{...es,validator:(e,t,s)=>Le(e)?e.data&&!Oe(e.data)?(Ot({api:t,paramName:"payload.data",desc:Rt()}),!1):e.description&&!Oe(e.description)?(Ot({api:t,paramName:"payload.description",desc:Rt()}),!1):!(e.extension&&!Oe(e.extension))||(Ot({api:t,paramName:"payload.extension",desc:Rt()}),!1):(Ot({api:t,paramName:"payload",desc:Kt()}),!1)}},createImageMessage:{to:Qt,conversationType:Qt,payload:{...es,validator:(e,t,s)=>{if(!Le(e))return Ot({api:t,paramName:s,desc:Kt()}),!1;if(Pe(e.file))return Ot({api:t,paramName:"payload.file",desc:Pt()}),!1;if(k){if(!(e.file instanceof HTMLInputElement||ve(e.file)))return Le(e.file)&&"undefined"!=typeof uni?0!==e.file.tempFilePaths.length&&0!==e.file.tempFiles.length||(Ot({api:t,paramName:"payload.file",desc:Yt()}),!1):(Ot({api:t,paramName:"payload.file",desc:Gt()}),!1);if(e.file instanceof HTMLInputElement&&0===e.file.files.length)return Ot({api:t,paramName:"payload.file",desc:Yt()}),!1}return!0},onProgress:{type:"Function",required:!1,validator:(e,t,s)=>(Pe(e)&&Ot({api:t,paramName:s,desc:$t()}),!0)}}},createAudioMessage:{to:Qt,conversationType:Qt,payload:{...es,validator:(e,t,s)=>!!Le(e)||(Ot({api:t,paramName:s,desc:Kt()}),!1)},onProgress:{type:"Function",required:!1,validator:(e,t,s)=>(Pe(e)&&Ot({api:t,paramName:s,desc:$t()}),!0)}},createVideoMessage:{to:Qt,conversationType:Qt,payload:{...es,validator:(e,t,s)=>{if(!Le(e))return Ot({api:t,paramName:s,desc:Kt()}),!1;if(Pe(e.file))return Ot({api:t,paramName:"payload.file",desc:Pt()}),!1;if(k){if(!(e.file instanceof HTMLInputElement||ve(e.file)))return Le(e.file)&&"undefined"!=typeof uni?!!ve(e.file.tempFile)||(Ot({api:t,paramName:"payload.file",desc:Yt()}),!1):(Ot({api:t,paramName:"payload.file",desc:Gt()}),!1);if(e.file instanceof HTMLInputElement&&0===e.file.files.length)return Ot({api:t,paramName:"payload.file",desc:Yt()}),!1}return!0}},onProgress:{type:"Function",required:!1,validator:(e,t,s)=>(Pe(e)&&Ot({api:t,paramName:s,desc:$t()}),!0)}},createFaceMessage:{to:Qt,conversationType:Qt,payload:{...es,validator:(e,t,s)=>Le(e)?Ae(e.index)?!!Oe(e.data)||(Ot({api:t,paramName:"payload.data",desc:Rt()}),!1):(Ot({api:t,paramName:"payload.index",desc:Ut()}),!1):(Ot({api:t,paramName:s,desc:Kt()}),!1)}},createFileMessage:{to:Qt,conversationType:Qt,payload:{...es,validator:(e,t,s)=>{if(!Le(e))return Ot({api:t,paramName:s,desc:Kt()}),!1;if(Pe(e.file))return Ot({api:t,paramName:"payload.file",desc:Pt()}),!1;if(k){if(!(e.file instanceof HTMLInputElement||ve(e.file)))return Le(e.file)&&"undefined"!=typeof uni?0!==e.file.tempFilePaths.length&&0!==e.file.tempFiles.length||(Ot({api:t,paramName:"payload.file",desc:Yt()}),!1):(Ot({api:t,paramName:"payload.file",desc:Gt()}),!1);if(e.file instanceof HTMLInputElement&&0===e.file.files.length)return Ot({api:t,paramName:"payload.file",desc:Yt()}),!1}return!0}},onProgress:{type:"Function",required:!1,validator:(e,t,s)=>(Pe(e)&&Ot({api:t,paramName:s,desc:$t()}),!0)}},createLocationMessage:{to:Qt,conversationType:Qt,payload:{...es,validator:(e,t,s)=>Le(e)?Oe(e.description)?Ae(e.longitude)?!!Ae(e.latitude)||(Ot({api:t,paramName:"payload.latitude",desc:Ut()}),!1):(Ot({api:t,paramName:"payload.longitude",desc:Ut()}),!1):(Ot({api:t,paramName:"payload.description",desc:Rt()}),!1):(Ot({api:t,paramName:s,desc:Kt()}),!1)}},createMergerMessage:{to:Qt,conversationType:Qt,payload:{...es,validator:(e,t,s)=>{if(St(e.messageList))return Ot({api:t,paramName:"payload.messageList",desc:Ft()}),!1;if(St(e.compatibleText))return Ot({api:t,paramName:"payload.compatibleText",desc:Lt("compatibleText")}),!1;let o=!1;return e.messageList.forEach(e=>{e.status===Nt.FAIL&&(o=!0)}),!o||(Ot({api:t,paramName:"payload.messageList",desc:os("MergeFailedMessageLog")}),!1)}}},revokeMessage:[{name:"message",...es,validator:(e,s,o)=>St(e)?(Ot({api:s,paramName:o,desc:Wt()}),!1):e.conversationType===t.CONV_SYSTEM?(Ot({api:s,paramName:o,desc:os("MessageCanBeRevokedDesc")}),!1):!0!==e.isRevoked||(Ot({api:s,paramName:o,desc:os("MessageRevokedLog")}),!1)}],deleteMessage:[{name:"messageList",...Zt,validator:(e,t,s)=>!St(e)||(Ot({api:t,paramName:s,desc:Ft()}),!1)}],translateText:{sourceTextList:Zt,sourceLanguage:Qt,targetLanguage:Qt},convertVoiceToText:{message:{...es,validator:(e,s,o)=>St(e)?(Ot({api:s,paramName:o,desc:Wt()}),!1):e.type===t.MSG_AUDIO&&e.status===Nt.SUCCESS||(Ot({api:s,paramName:o,desc:os("AudioMessageRequiredLog")}),!1)}},modifyMessage:[{name:"message",...es,validator:(e,s,o)=>St(e)?(Ot({api:s,paramName:o,desc:Wt()}),!1):e.conversationType===t.CONV_SYSTEM?(Ot({api:s,paramName:o,desc:os("MessageCanBeModifiedLog")}),!1):!0!==e._onlineOnlyFlag||(Ot({api:s,paramName:o,desc:os("OnlineMessageNotSupportLog")}),!1)}],searchCloudMessages:{keywordList:{type:"Array",required:!1,validator:(e,t,s)=>!e||(Ue(e)?0===e.length?(Ot({api:t,paramName:s,desc:Ft()}),!1):!(e.length>5)||(Ot({api:t,paramName:s,desc:Xt(s,5)}),!1):(Ot({api:t,paramName:s,desc:wt()}),!1))},keywordListMatchType:{type:"String",required:!1,validator:(e,t,s)=>!e||("or"===e||"and"===e||Ot({api:t,paramName:s,desc:e+" is invalid match type"}))},senderUserIDList:{type:"Array",required:!1,validator:(e,t,s)=>!e||(Ue(e)?(0===e.length&&Ot({api:t,paramName:s,desc:Ft()}),!(e.length>5)||(Ot({api:t,paramName:s,desc:Xt(s,5)}),!1)):(Ot({api:t,paramName:s,desc:wt()}),!1))},messageTypeList:{type:"Array",required:!1,validator:(e,s,o)=>{if(!e)return!0;if(!Ue(e))return Ot({api:s,paramName:o,desc:wt()}),!1;0===e.length&&Ot({api:s,paramName:o,desc:Ft()});const i=[t.MSG_TEXT,t.MSG_IMAGE,t.MSG_AUDIO,t.MSG_FILE,t.MSG_VIDEO,t.MSG_LOCATION,t.MSG_CUSTOM,t.MSG_MERGER];return!(e.filter(e=>-1===i.indexOf(e)).length>0)||(Ot({api:s,paramName:o,desc:(n=o,os("ContainsUnsupportedMessageTypeLog",n))}),!1);var n}},conversationID:{type:"String",required:!1,validator:e=>!e||At(e)},timePosition:{type:"number",required:!1,validator:(e,t,s)=>!e||(!(e<0)||(Ot({api:t,paramName:s,desc:Vt(s,0)}),!1))},timePeriod:{type:"number",required:!1,validator:(e,t,s)=>!e||(!(e<0)||(Ot({api:t,paramName:s,desc:Vt(s,0)}),!1))},cursor:{type:"String",required:!1}},getUserProfile:{userIDList:{type:"Array",validator:(e,t,s)=>Ue(e)?(0===e.length&&Ot({api:t,paramName:s,desc:Ft()}),!0):(Ot({api:t,paramName:s,desc:wt()}),!1)}},updateMyProfile:{profileCustomField:{type:"Array",validator:(e,t,s)=>!!Pe(e)||(!!Ue(e)||(Ot({api:t,paramName:s,desc:wt()}),!1))}},setSelfStatus:{customStatus:{type:"String",validator:(e,t,s)=>!!Oe(e)||(Ot({api:t,paramName:s,desc:Rt()}),!1)}},getUserStatus:{userIDList:{type:"Array",validator:(e,t,s)=>Ue(e)?0!==e.length||(Ot({api:t,paramName:s,desc:Ft()}),!1):(Ot({api:t,paramName:s,desc:wt()}),!1)}},subscribeUserStatus:{userIDList:{type:"Array",validator:(e,t,s)=>Ue(e)?0!==e.length||(Ot({api:t,paramName:s,desc:Ft()}),!1):(Ot({api:t,paramName:s,desc:wt()}),!1)}},unsubscribeUserStatus:{userIDList:{type:"Array",validator:(e,t,s)=>!e||(!!Ue(e)||(Ot({api:t,paramName:s,desc:wt()}),!1))}},addFriend:{to:Qt,source:{type:"String",required:!0,validator:(e,t,s)=>{if(!e)return!1;if(!e.startsWith("AddSource_Type_"))return Ot({api:t,paramName:s,desc:os("SourcePrefixLog")}),!1;return!(e.replace("AddSource_Type_","").length>8)||(Ot({api:t,paramName:s,desc:qt("keyword",8)}),!1)}},remark:{type:"String",required:!1,validator:(e,t,s)=>!(Oe(e)&&e.length>96)||(Ot({api:t,paramName:s,desc:qt(s,96)}),!1)}},deleteFriend:{userIDList:Zt},checkFriend:{userIDList:Zt},getFriendProfile:{userIDList:Zt},updateFriend:{userID:Qt,remark:{type:"String",required:!1,validator:(e,t,s)=>!(Oe(e)&&e.length>96)||(Ot({api:t,paramName:s,desc:qt(s,96)}),!1)},friendCustomField:{type:"Array",required:!1,validator:(e,t,s)=>{if(e){if(!Ue(e))return Ot({api:t,paramName:s,desc:wt()}),!1;let o=!0;return e.forEach(e=>{if(!Oe(e.key)||-1===e.key.indexOf("Tag_SNS_Custom"))return Ot({api:t,paramName:s,desc:os("FriendCustomFieldPrefixLog")}),o=!1,o;if(!Oe(e.value))return Ot({api:t,paramName:s,desc:Bt("value")}),o=!1,o;return e.key.replace("Tag_SNS_Custom_","").length>8?(Ot({api:t,paramName:s,desc:qt("keyword",8)}),o=!1,o):void 0}),o}return!0}}},acceptFriendApplication:{userID:Qt},refuseFriendApplication:{userID:Qt},deleteFriendApplication:{userID:Qt},createFriendGroup:{name:Qt},deleteFriendGroup:{name:Qt},addToFriendGroup:{name:Qt,userIDList:Zt},removeFromFriendGroup:{name:Qt,userIDList:Zt},renameFriendGroup:{oldName:Qt,newName:Qt},sendMessageReadReceipt:[{name:"messageList",type:"Array",validator:(e,t,s)=>Ue(e)?0!==e.length||(Ot({api:t,paramName:s,desc:Ft()}),!1):(Ot({api:t,paramName:s,desc:wt()}),!1)}],getMessageReadReceiptList:[{name:"messageList",type:"Array",validator:(e,t,s)=>Ue(e)?0!==e.length||(Ot({api:t,paramName:s,desc:Ft()}),!1):(Ot({api:t,paramName:s,desc:wt()}),!1)}],createTopicInCommunity:{groupID:Qt,topicName:Qt},deleteTopicFromCommunity:{groupID:Qt,topicIDList:{type:"Array",validator:(e,t,s)=>!e||(!!Ue(e)||(Ot({api:t,paramName:s,desc:wt()}),!1))}},updateTopicProfile:{groupID:Qt,topicID:Qt},getTopicList:{groupID:Qt,topicIDList:{type:"Array",validator:(e,t,s)=>!e||(!!Ue(e)||(Ot({api:t,paramName:s,desc:wt()}),!1))}},addSignalingListener:[{name:"eventName",type:"String",validator:(e,t,s)=>"string"==typeof e&&0!==e.length||(Ot({api:t,paramName:s,desc:Lt(s)}),!1)},{name:"handler",type:"Function",validator:(e,t,s)=>"function"!=typeof e?(Ot({api:t,paramName:s,desc:kt()}),!1):(""===e.name&&Ot({api:t,paramName:s,desc:zt()}),!0)}],removeSignalingListener:[{name:"eventName",type:"String",validator:(e,t,s)=>"string"==typeof e&&0!==e.length||(Ot({api:t,paramName:s,desc:Lt(s)}),!1)},{name:"handler",type:"Function",validator:(e,t,s)=>"function"!=typeof e?(Ot({api:t,paramName:s,desc:kt()}),!1):(""===e.name&&Ot({api:t,paramName:s,desc:zt()}),!0)}],invite:{userID:Qt},inviteSync:[{...es,validator:(e,t,s)=>Le(e)?!!Oe(e.userID)||(Ot({api:t,paramName:"options.userID",desc:Rt()}),!1):(Ot({api:t,paramName:"options",desc:Kt()}),!1)},{name:"successCb",type:"Function",required:!1,validator:(e,t,s)=>(Pe(e)&&Ot({api:t,paramName:s,desc:kt()}),!0)},{name:"errorCb",type:"Function",required:!1,validator:(e,t,s)=>(Pe(e)&&Ot({api:t,paramName:s,desc:kt()}),!0)}],inviteInGroup:{groupID:Qt,inviteeList:Zt},inviteInGroupSync:[{...es,validator:(e,t,s)=>Le(e)?Oe(e.groupID)?!!Ue(e.inviteeList)||(Ot({api:t,paramName:"options.inviteeList",desc:wt()}),!1):(Ot({api:t,paramName:"options.groupID",desc:Rt()}),!1):(Ot({api:t,paramName:"options",desc:Kt()}),!1)},{name:"successCb",type:"Function",required:!1,validator:(e,t,s)=>(Pe(e)&&Ot({api:t,paramName:s,desc:kt()}),!0)},{name:"errorCb",type:"Function",required:!1,validator:(e,t,s)=>(Pe(e)&&Ot({api:t,paramName:s,desc:kt()}),!0)}],accept:{inviteID:Qt},reject:{inviteID:Qt},getSignalingInfo:[{name:"message",...es,validator:(e,t,s)=>!St(e)||(Ot({api:t,paramName:s,desc:Wt()}),!1)}],modifyInvitation:{inviteID:Qt,data:Qt}},ns={login:1,logout:1,getLoginUser:1,on:1,once:1,off:1,setLogLevel:1,registerPlugin:1,destroy:1,isReady:1,createTextMessage:1,createTextAtMessage:1,createImageMessage:1,createAudioMessage:1,createVideoMessage:1,createCustomMessage:1,createFaceMessage:1,createFileMessage:1,createLocationMessage:1,createMergerMessage:1,downloadMergerMessage:1,createForwardMessage:1,sendMessage:1,resendMessage:1,revokeMessage:1,deleteMessage:1,translateText:1,convertVoiceToText:1,modifyMessage:1,searchCloudMessages:1,sendMessageReadReceipt:1,getGroupMessageReadMemberList:1,getMessageReadReceiptList:1,setMessageExtensions:1,getMessageExtensions:1,deleteMessageExtensions:1,addMessageReaction:1,removeMessageReaction:1,getMessageReactions:1,getAllUserListOfMessageReaction:1,getMessageList:1,findMessage:1,getMessageListHopping:1,setMessageRead:1,setAllMessageRead:1,getConversationList:1,getConversationProfile:1,deleteConversation:1,setConversationDraft:1,pinConversation:1,getTotalUnreadMessageCount:1,setConversationCustomData:1,markConversation:1,createConversationGroup:1,getConversationGroupList:1,deleteConversationGroup:1,renameConversationGroup:1,addConversationsToGroup:1,deleteConversationsFromGroup:1,clearHistoryMessage:1,getGroupList:1,getGroupProfile:1,createGroup:1,joinGroup:1,updateGroupProfile:1,quitGroup:1,dismissGroup:1,changeGroupOwner:1,searchGroupByID:1,setMessageRemindType:1,getGroupApplicationList:1,handleGroupApplication:1,initGroupAttributes:1,setGroupAttributes:1,deleteGroupAttributes:1,getGroupAttributes:1,setGroupCounters:1,increaseGroupCounter:1,decreaseGroupCounter:1,getGroupCounters:1,getJoinedCommunityList:1,createTopicInCommunity:1,deleteTopicFromCommunity:1,updateTopicProfile:1,getTopicList:1,getGroupMemberProfile:1,getGroupMemberList:1,addGroupMember:1,deleteGroupMember:1,setGroupMemberNameCard:1,setGroupMemberMuteTime:1,setGroupMemberRole:1,setGroupMemberCustomField:1,getGroupOnlineMemberCount:1,markGroupMemberList:1,getMyProfile:1,getUserProfile:1,updateMyProfile:1,setSelfStatus:1,getUserStatus:1,subscribeUserStatus:1,unsubscribeUserStatus:1,getBlacklist:1,addToBlacklist:1,removeFromBlacklist:1,getFriendList:1,addFriend:1,deleteFriend:1,checkFriend:1,updateFriend:1,getFriendProfile:1,getFriendApplicationList:1,refuseFriendApplication:1,deleteFriendApplication:1,acceptFriendApplication:1,setFriendApplicationRead:1,getFriendGroupList:1,createFriendGroup:1,renameFriendGroup:1,deleteFriendGroup:1,addToFriendGroup:1,removeFromFriendGroup:1,callExperimentalAPI:1,addSignalingListener:1,removeSignalingListener:1,invite:1,inviteSync:1,inviteInGroup:1,inviteInGroupSync:1,cancel:1,accept:1,reject:1,getSignalingInfo:1,modifyInvitation:1},rs=1,as=2,cs=3,us=4,ls=6,ds=7,_s=8,ps=10,hs=11,gs=12,ms=13,Ms=14,Is=15,fs=17,Ts=18,Cs=19,Es=20,Ss=21,ys=23,Ds=24,Ns=25,vs=26,As=27,Os=28,Rs=29,Ls=30,Us=31,Ps=32,Gs=33,ks=34,ws=function(e){return{code:0,data:e||{}}};class Fs extends Error{constructor(e){super();const{code:t,message:s,data:o}=e;this.code=t,this.message=s||this._getErrorMessage(this.code),this.data=o||{}}}const $s={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,MSG_SEND_FAIL:2100,MSG_SEND_FAIL_NOT_IN_AVCHATROOM:2101,MSG_INSTANCE_REQUIRED:2105,MSG_INVALID_CONV_TYPE:2106,MSG_F_IS_EMPTY:2108,MSG_ONPROGRESS_FUNCTION_ERROR:2109,MSG_REVOKE_FAIL:2110,MSG_DELETE_FAIL:2111,MSG_UNREAD_ALL_FAIL:2112,READ_RECEIPT_MSG_LIST_EMPTY:2114,MSG_SEND_GRP_WITH_TOPIC_FAIL:2115,CANNOT_DELETE_GRP_SYSTEM_NOTICE:2116,TRANSLATE_TEXT_FAIL:2117,VOICE_TO_TEXT_FAIL:2118,UNSUPPORTED_VOICE_FORMAT:2119,MSG_I_SELECT_F_FIRST:2251,MSG_I_TYPES_LIMIT:2252,MSG_I_SIZE_LIMIT:2253,MSG_A_UPLOAD_FAIL:2300,MSG_A_SIZE_LIMIT:2301,MSG_V_UPLOAD_FAIL:2350,MSG_V_SIZE_LIMIT:2351,MSG_V_TYPES_LIMIT:2352,MSG_F_UPLOAD_FAIL:2400,MSG_F_SELECT_F_FIRST:2401,MSG_F_SIZE_LIMIT:2402,MSG_F_URL_IS_EMPTY:2403,MSG_MERGER_TYPE_INVALID:2450,MSG_MERGER_KEY_INVALID:2451,MSG_MERGER_DOWNLOAD_FAIL:2452,MSG_FORWARD_TYPE_INVALID:2453,MSG_FORWARD_INVALID_ELEMENTS:2454,MSG_MODIFY_CONFLICT:2480,MSG_MODIFY_DISABLED_IN_AVCHATROOM:2481,CONV_NOT_FOUND:2500,USER_OR_GRP_NOT_FOUND:2501,CONV_UN_RECORDED_TYPE:2502,INVALID_CONV_ID:2503,ILLEGAL_GRP_TYPE:2600,CANNOT_JOIN_WORK:2601,ILLEGAL_GRP_ID:2602,CANNOT_FIND_GRP:2603,CANNOT_CHANGE_OWNER_IN_AVCHATROOM:2620,CANNOT_CHANGE_OWNER_TO_SELF:2621,CANNOT_DISMISS_WORK:2622,MEMBER_NOT_IN_GRP:2623,JOIN_GRP_FAIL:2660,CANNOT_ADD_MEMBER_IN_AVCHATROOM:2661,CANNOT_JOIN_NON_AVCHATROOM_WITHOUT_LOGIN:2662,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,BAN_DURATION_INVALID:2686,OPERATION_NOT_SUPPORTED_IN_AVCHATROOM:2687,NOT_MY_FRIEND:2700,ALREADY_MY_FRIEND:2701,FRIEND_GRP_EXISTED:2710,FRIEND_GRP_NOT_EXIST:2711,FRIEND_APPLICATION_NOT_EXIST:2716,UPDATE_PROFILE_INVALID_PARAM:2721,UPDATE_PROFILE_NO_KEY:2722,CANNOT_ADD_SELF_TO_BLACKLIST:2742,NETWORK_ERROR:2800,NETWORK_TIMEOUT:2801,NO_NETWORK:2805,UNCAUGHT_ERROR:2903,INVALID_OPERATION:2905,INVALID_TRTC_CMD:2995,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,CANNOT_USE_COMMERCIAL_ABILITY:3122,PROFANITY_FOUND:3123,OPTIONS_IS_EMPTY:3153,MSG_A2KEY_EXPIRED:20002,ACCOUNT_A2KEY_EXPIRED:70001,HELLO_ANSWER_KICKED_OUT:1002,OPEN_SERVICE_OVERLOAD_ERROR:60022,SIGNALING_INVALID_INVITE_ID:8010,SIGNALING_NO_PERMISSION:8011,SIGNALING_ALREADY_EXISTS:8012,INVALID_CANCEL_MESSAGE:8020,MSG_SEARCH_CURSOR_INVALID:27002,MSG_SEARCH_CURSOR_EXPIRED:27003};let bs=null;const qs=function(e){bs=e},xs=function(e){return Promise.resolve(ws(e))},Vs=function(t,s=!1){if(t instanceof Fs)return s&&null!==bs&&bs.emit(e.ERROR,t),Promise.reject(t);if(t instanceof Error){const t=new Fs({code:$s.UNCAUGHT_ERROR});return s&&null!==bs&&bs.emit(e.ERROR,t),Promise.reject(t)}if(Pe(t)||Pe(t.code))return Promise.reject(new Fs({code:$s.UNCAUGHT_ERROR}));const o=new Fs(t);return s&&null!==bs&&bs.emit(e.ERROR,o),Promise.reject(o)};class Bs{constructor(e){this._m=e,this._n=""}isLoggedIn(){return this._m.getModule(gs).isLoggedIn()}isOversea(){return this._m.getModule(gs).isOversea()}isPrivateNetWork(){return this._m.getModule(gs).isPrivateNetWork()}getFileDownloadProxy(){return this._m.getModule(gs).getFileDownloadProxy()}getMyUserID(){return this._m.getModule(gs).getUserID()}getMyTinyID(){return this._m.getModule(gs).getTinyID()}getSDKAppID(){return this._m.getModule(gs).getSDKAppID()}isIntl(){return this._m.getModule(gs).isIntl()}isUsingChatCore(){return this._m.getModule(gs).isUsingChatCore()}isDevMode(){return this._m.getModule(gs).isDevMode()}getModule(e){return this._m.getModule(e)}getPlatform(){return q}getNetworkType(){return this._m.getModule(Is).getNetworkType()}probeNetwork(e){return this._m.getModule(Is).probe(e)}getCloudConfig(e){return this._m.getModule(ys).getCloudConfig(e)}emitOuterEvent(e,t){this._m.getOuterEmitterInstance().emit(e,t)}emitInnerEvent(e,t){this._m.getInnerEmitterInstance().emit(e,t)}getInnerEmitterInstance(){return this._m.getInnerEmitterInstance()}generateTjgID(e){return this._m.getModule(gs).getTinyID()+"-"+e.random}filterModifiedMessage(t){if(St(t))return;const s=t.filter(e=>!0===e.isModified);s.length>0&&this.emitOuterEvent(e.MESSAGE_MODIFIED,s)}filterUnmodifiedMessage(e){if(St(e))return[];return e.filter(e=>!1===e.isModified)}request(e){return this._m.getModule(Es).request(e)}canIUse(e){return this._m.getModule(As).canIUse(e)}getErrorMessage(e,t,s){return this._m.getErrorMessage(e,t,s)}outputWarning(e,t,s){const o=this.getErrorMessage(e,t,s);o&&Ie.w(o)}cannotUseCommercialAbility(e){const t=$s.CANNOT_USE_COMMERCIAL_ABILITY;return Vs({code:t,message:this.getErrorMessage(t,e)})}}const Ks={LOGIN:"wslogin",LOGOUT:"wslogout",HELLO:"wshello",KICK_OTHER:"KickOther",SYNC_UNREAD_MESSAGE:"getmsg",SEND_C2C_MESSAGE:"sendmsg",SEND_GROUP_MESSAGE:"send_group_msg",GET_USER_PROFILE:"portrait_get_all",UPDATE_MY_PROFILE:"portrait_set",GET_BLACKLIST:"black_list_get",ADD_TO_BLACKLIST:"black_list_add",REMOVE_FROM_BLACKLIST:"black_list_delete",GET_FRIEND_LIST:"friend_get",GET_FRIEND_PROFILE:"friend_get_specified",CHECK_FRIEND:"friend_check",DELETE_FRIEND:"friend_delete",ADD_FRIEND:"friend_add",UPDATE_FRIEND:"friend_update",RESPOND_FRIEND_APPLICATION:"friend_response",GET_FRIEND_APPLICATION_LIST:"pendency_get",DELETE_FRIEND_APPLICATION:"pendency_delete",REFUSE_FRIEND_APPLICATION:"pendency_refuse",REPORT_FRIEND_APPLICATION:"pendency_report",GET_FRIEND_GROUP_LIST:"group_get",CREATE_FRIEND_GROUP:"group_add",DELETE_FRIEND_GROUP:"group_delete",UPDATE_FRIEND_GROUP:"group_update",REVOKE_C2C_MESSAGE:"msgwithdraw",SET_C2C_MESSAGE_READ:"msgreaded",SET_C2C_PEER_MUTE_NOTIFICATIONS:"set_c2c_peer_mute_notifications",GET_C2C_PEER_MUTE_NOTIFICATIONS:"get_c2c_peer_mute_notifications",GET_C2C_ROAMING_MESSAGE:"getroammsg",GET_C2C_PEER_READ_TIME:"get_peer_read_time",DELETE_C2C_MESSAGE:"delete_c2c_msg_ramble",MODIFY_C2C_MESSAGE:"modify_c2c_msg",MODIFY_C2C_MESSAGE_EXTENSIONS:"set_key_values",GET_C2C_MESSAGE_EXTENSIONS:"get_key_values",ADD_C2C_MSG_REACTION:"reaction_add",REMOVE_C2C_MSG_REACTION:"reaction_del",GET_C2C_MSG_REACTIONS:"reaction_multi_stat",GET_C2C_MSG_REACTION_USER_LIST:"reaction_iterate",PAGING_GET_CONVERSATION_LIST:"page_get",DELETE_CONVERSATION:"batch_delete",CLEAR_HISTORY_MESSAGE:"clear_msg",PIN_CONVERSATION:"top",DELETE_GROUP_AT_TIPS:"deletemsg",SET_CONVERSATION_CUSTOM_DATA:"set_conv_custom_data",MARK_CONVERSATION:"mark_contact",CREATE_CONVERSATION_GROUP:"create_contact_group",DELETE_CONVERSATION_GROUP:"del_contact_group",RENAME_CONVERSATION_GROUP:"update_contact_group",ADD_CONVERSATIONS_TO_GROUP:"add_conv_to_group",DELETE_CONVERSATIONS_FROM_GROUP:"del_conv_from_group",GET_CONVERSATION_GROUP_LIST:"get_contact_group",GET_GROUP_LIST:"get_joined_group_list",GET_GROUP_PROFILE:"get_group_self_member_info",CREATE_GROUP:"create_group",DISMISS_GROUP:"destroy_group",UPDATE_GROUP_PROFILE:"modify_group_base_info",APPLY_JOIN_GROUP:"apply_join_group",APPLY_JOIN_GROUP_NOAUTH:"apply_join_group_noauth",QUIT_GROUP:"quit_group",SEARCH_GROUP:"get_group_public_info",CHANGE_GROUP_OWNER:"change_group_owner",HANDLE_GROUP_APPLICATION:"handle_apply_join_group",HANDLE_INVITE_JOIN_GROUP:"handle_invite_join_permission_group",HANDLE_GROUP_INVITATION:"handle_invite_join_group",REVOKE_GROUP_MESSAGE:"group_msg_recall",SET_GROUP_MESSAGE_READ:"msg_read_report",SET_ALL_MESSAGE_READ:"read_all_unread_msg",GET_GROUP_ROAMING_MESSAGE:"group_msg_get",GET_READ_RECEIPT:"get_group_msg_receipt",SEND_READ_RECEIPT:"group_msg_receipt",SEND_C2C_READ_RECEIPT:"c2c_msg_read_receipt",GET_READ_RECEIPT_DETAIL:"get_group_msg_receipt_detail",GET_GROUP_PENDENCY:"get_pendency",DELETE_GROUP_SYSTEM_NOTICE:"deletemsg",AVCHATROOM_POLLING:"get_msg",AVCHATROOM_NOAUTH_POLLING:"get_msg_noauth",GET_ONLINE_MEMBER_NUM:"get_online_member_num",DELETE_GROUP_MESSAGE:"delete_group_ramble_msg_by_seq",MODIFY_GROUP_MESSAGE:"modify_group_msg",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",MODIFY_GROUP_MESSAGE_EXTENSIONS:"group_set_key_values",GET_GROUP_MESSAGE_EXTENSIONS:"group_get_key_values",GET_GROUP_NOTIFY:"batch_get_group_notify",UPDATE_GROUP_COUNTER:"update_group_counter",GET_GROUP_COUNTER:"get_group_counter",ADD_GRP_MSG_REACTION:"group_reaction_add",REMOVE_GRP_MSG_REACTION:"group_reaction_del",GET_GRP_MSG_REACTIONS:"group_reaction_multi_stat",GET_GRP_MSG_REACTION_USER_LIST:"group_reaction_iterate",GET_GROUP_MEMBER_LIST:"get_group_member_info",GET_AVCHATROOM_MEMBER_LIST:"get_members",GET_GROUP_MEMBER_PROFILE:"get_specified_group_member_info",ADD_GROUP_MEMBER:"add_group_member",DELETE_GROUP_MEMBER:"delete_group_member",BAN_AVCHATROOM_MEMBER:"ban_group_member",MODIFY_GROUP_MEMBER_INFO:"modify_group_member_info",MARK_AVCHATROOM_MEMBER_INFO:"modify_user_info",COS_SIGN:"cos",COS_PRE_SIG:"pre_sig",SIMPLE_COS_PRE_SIG:"simple_sig",GET_IMAGE_INFO:"get_imageinfo",GET_IP:"get_final_ip",VIDEO_COVER:"video_cover",SSO_STAT:"tim_web_report_v2",PING:"alive",MESSAGE_PUSH:"msg_push",MESSAGE_CLOUD_SEARCH:"query",MULTI_MESSAGE_PUSH:"multi_msg_push_ws",MESSAGE_PUSH_ACK:"ws_msg_push_ack",STATUS_FORCE_OFFLINE:"stat_forceoffline",UPLOAD_MERGER_MESSAGE:"save_relay_json_msg",DOWNLOAD_MERGER_MESSAGE:"get_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",OVERLOAD_NOTIFY:"notify2",CREATE_TOPIC:"create_topic",DELETE_TOPIC:"destroy_topic",UPDATE_TOPIC_PROFILE:"modify_topic",GET_TOPIC_LIST:"get_topic",SET_SELF_STATUS:"ws_set_custom_status",GET_USER_STATUS:"ws_get_user_status",SUBSCRIBE_USER_STATUS:"ws_status_subscribe",UNSUBSCRIBE_USER_STATUS:"ws_status_unsubscribe",STAT_BACKGROUND:"ws_stat_background",STAT_FOREGROUND:"ws_stat_foreground",SET_TOKEN:"ws_stat_settoken",GET_PROFANITY_LIST:"get_local_words",TRANSLATE_TEXT:"ws_batch_trans_text",VOICE_TO_TEXT:"ws_sentence_recognition"},Hs="networkRTT",Ys="messageE2EDelay",Ws="sendMessageC2C",zs="sendMessageGroup",js="sendMessageGroupAV",Js="sendMessageRichMedia",Xs="cosUpload",Qs="messageReceivedGroup",Zs="messageReceivedGroupAVPush",eo="messageReceivedGroupAVPull",to={[Hs]:2,[Ys]:3,[Ws]:4,[zs]:5,[js]:6,[Js]:7,[Qs]:8,[Zs]:9,[eo]:10,[Xs]:11},so={info:4,warning:5,error:6},oo={wifi:1,"2g":2,"3g":3,"4g":4,"5g":5,unknown:6,none:7,online:8},io={login:4};class no{constructor(e){this._n="SSOLogData",this.eventType=io[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.uiPlatform=void 0,this._sentFlag=!1,this._startts=_e()}static bindEventStatModule(e){no.prototype._eventStatModule=e}updateTimeStamp(){this.timestamp=_e()}start(e){return this._startts=e,this}end(e=!1){if(this._sentFlag)return;const t=_e();0===this.costTime&&(this.costTime=t-this._startts),this.setMoreMessage(`startts:${this._startts} endts:${t}`),e?(this._sentFlag=!0,this._eventStatModule&&this._eventStatModule.pushIn(this)):setTimeout(()=>{this._sentFlag=!0,this._eventStatModule&&this._eventStatModule.pushIn(this)},0)}setError(e,t,s){if(!(e instanceof Error))return Ie.w(this._n+".setError value not instanceof Error, please check!"),this;if(this._sentFlag)return this;if(this.setNetworkType(s),t)e.code&&this.setCode(e.code),e.message&&this.setMoreMessage(e.message);else{const e=$s.NO_NETWORK;this.setCode(e)}return this.setLevel("error"),this}setCode(e){return Pe(e)||this._sentFlag||("ECONNABORTED"===e&&(this.code=103),Ae(e)?this.code=e:Ie.w(this._n+".setCode value not a number, please check!",e,typeof e)),this}setMessage(e){return Pe(e)||this._sentFlag||(Ae(e)&&(this.message=e.toString()),Oe(e)&&(this.message=e)),this}setCostTime(e){return this.costTime=e,this}setLevel(e){return Pe(e)||this._sentFlag||(this.level=so[e]),this}setMoreMessage(e){return St(this.moreMessage)?this.moreMessage=""+e:this.moreMessage+=" "+e,this}setNetworkType(e){if(Pe(e))Ie.w(this._n+".setNetworkType value is undefined, please check!");else{const t=oo[e.toLowerCase()];Pe(t)||(this.networkType=t)}return this}getStartTs(){return this._startts}setUIPlatform(e){this.uiPlatform=e}setExtension(e){return this.extension=e,this}setEventType(e){return this.eventType=e,this}}class ro{constructor(e){this.type=t.MSG_TEXT,this.content={text:e.text||""}}setText(e){this.content.text=e}sendable(){return 0!==this.content.text.length}}class ao{constructor(e,s){this._imageMemoryURL="",this._fileDownloadProxy=s,G?this.createImageDataASURLInWXMiniApp(e.file):this.createImageDataASURLInWeb(e.file),this._initImageInfoModel(),this.type=t.MSG_IMAGE,this._percent=0,this.content={imageFormat:e.imageFormat||fe.UNKNOWN,uuid:e.uuid,imageInfoArray:[]},this.initImageInfoArray(e.imageInfoArray),this._autoFixUrl()}_initImageInfoModel(){const e=this;this._ImageInfoModel=function(t){this.instanceID=Be(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.imageUrl||t.url||"",this.url=ft(t.url||e._imageMemoryURL,e._fileDownloadProxy)},this._ImageInfoModel.prototype={setSizeType(e){this.sizeType=e},setType(e){this.type=e},setImageUrl(e){e&&(this.imageUrl=e)},getImageUrl(){return this.imageUrl}}}initImageInfoArray(e){let t=0,s=null,o=null;for(;t<=2;)o=Pe(e)||Pe(e[t])?{type:0,size:0,width:0,height:0,url:""}:e[t],s=new this._ImageInfoModel(o),s.setSizeType(t+1),s.setType(t),this.addImageInfo(s),t++;this.updateAccessSideImageInfoArray()}updateImageInfoArray(e){const t=this.content.imageInfoArray.length;let s;for(let o=0;o<t;o++)s=this.content.imageInfoArray[o],e[o].size&&(s.size=e[o].size),e[o].url&&s.setImageUrl(e[o].url),e[o].width&&(s.width=e[o].width),e[o].height&&(s.height=e[o].height)}_autoFixUrl(){const e=this.content.imageInfoArray.length;let t="",s="";const o=["http","https"];let i=null;for(let n=0;n<e;n++)this.content.imageInfoArray[n].url&&(i=this.content.imageInfoArray[n],""!==i.imageUrl&&(s=i.imageUrl.slice(0,i.imageUrl.indexOf("://")+1),t=i.imageUrl.slice(i.imageUrl.indexOf("://")+1),o.indexOf(s)<0&&(s="https:"),this.content.imageInfoArray[n].setImageUrl([s,t].join(""))))}updatePercent(e){this._percent=e,this._percent>1&&(this._percent=1)}updateImageFormat(e){this.content.imageFormat=fe[e.toUpperCase()]||fe.UNKNOWN}createImageDataASURLInWeb(e){void 0!==e&&e.files.length>0&&(this._imageMemoryURL=window.URL.createObjectURL(e.files[0]))}createImageDataASURLInWXMiniApp(e){e&&e.url&&(this._imageMemoryURL=e.url)}replaceImageInfo(e,t){this.content.imageInfoArray[t]instanceof this._ImageInfoModel||(this.content.imageInfoArray[t]=e)}addImageInfo(e){this.content.imageInfoArray.length>=3||this.content.imageInfoArray.push(e)}updateAccessSideImageInfoArray(){const e=this.content.imageInfoArray,{width:t=0,height:s=0}=e[0];0!==t&&0!==s&&(ut(e),Object.assign(e[2],ct({originWidth:t,originHeight:s,min:720})))}sendable(){return 0!==this.content.imageInfoArray.length&&(""!==this.content.imageInfoArray[0].imageUrl&&0!==this.content.imageInfoArray[0].size)}}class co{constructor(e){this.type=t.MSG_FACE,this.content=e||null}sendable(){return null!==this.content}}class uo{constructor(e,s){this.type=t.MSG_AUDIO,this._percent=0,this.content={downloadFlag:2,second:e.second,size:e.size,url:ft(e.url,s),remoteAudioUrl:e.url||"",uuid:e.uuid}}updatePercent(e){this._percent=e,this._percent>1&&(this._percent=1)}updateAudioUrl(e){this.content.remoteAudioUrl=e}sendable(){return""!==this.content.remoteAudioUrl}}const lo={from:!0,groupID:!0,groupName:!0,to:!0};class _o{constructor(e){this.type=t.MSG_GRP_TIP,this.content={},this._initContent(e)}_initContent(e){Object.keys(e).forEach(t=>{switch(t){case"remarkInfo":break;case"groupProfile":this.content.groupProfile={},this._initGroupProfile(e[t]);break;case"operatorInfo":break;case"memberInfoList":case"msgMemberInfo":this._updateMemberList(e[t]);break;case"memberExtraInfo":case"onlineMemberInfo":break;case"memberNum":this.content[t]=e[t],this.content.memberCount=e[t];break;case"newGroupProfile":this.content.newGroupProfile={},this._initNewGroupProfile(e[t]);break;default:this.content[t]=e[t]}}),this.content.userIDList||(this.content.userIDList=[this.content.operatorID])}_initGroupProfile(e){const t=Object.keys(e);for(let s=0;s<t.length;s++){const o=t[s];lo[o]&&(this.content.groupProfile[o]=e[o])}}_updateMemberList(e){St(this.content.memberList)?this.content.memberList=e:this.content.memberList.forEach(t=>{e.forEach(e=>{t.userID===e.userID&&Object.assign(t,e)})})}_initNewGroupProfile(e){const t=Object.keys(e);for(let s=0;s<t.length;s++){const o=t[s];"muteAllMembers"!==o?this.content.newGroupProfile[o]=e[o]:this.content.newGroupProfile[o]=1===e[o]}}}const po={from:!0,groupID:!0,groupName:!0,to:!0};class ho{constructor(e){this.type=t.MSG_GRP_SYS_NOTICE,this.content={},this._initContent(e)}_initContent(e){Object.keys(e).forEach(t=>{switch(t){case"memberInfoList":break;case"remarkInfo":this.content.handleMessage=e[t];break;case"groupProfile":this.content.groupProfile={},this._initGroupProfile(e[t]);break;default:this.content[t]=e[t]}})}_initGroupProfile(e){const t=Object.keys(e);for(let s=0;s<t.length;s++){const o=t[s];po[o]&&("groupName"===o?this.content.groupProfile.name=e[o]:this.content.groupProfile[o]=e[o])}}}class go{constructor(e,s){this.type=t.MSG_FILE,this._percent=0;const o=this._getFileInfo(e);this.content={downloadFlag:2,fileUrl:ft(e.url||e.fileUrl,s)||"",uuid:e.uuid,fileName:o.name||"",fileSize:o.size||0}}_getFileInfo(e){if(!Pe(e.fileName)&&!Pe(e.fileSize))return{size:e.fileSize,name:e.fileName};const t=e.file.files[0];if(U){if(t.path&&-1!==t.path.indexOf(".")){const e=t.path.slice(t.path.lastIndexOf(".")+1).toLowerCase();t.type=e,t.name||(t.name=`${Be(999999)}.${e}`)}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}}updatePercent(e){this._percent=e,this._percent>1&&(this._percent=1)}updateFileUrl(e){this.content.fileUrl=e}sendable(){return""!==this.content.fileUrl&&(""!==this.content.fileName&&0!==this.content.fileSize)}}class mo{constructor(e){this.type=t.MSG_CUSTOM,this.content={data:e.data||"",description:e.description||"",extension:e.extension||""}}setData(e){return this.content.data=e,this}setDescription(e){return this.content.description=e,this}setExtension(e){return this.content.extension=e,this}sendable(){return 0!==this.content.data.length||0!==this.content.description.length||0!==this.content.extension.length}}class Mo{constructor(e,s){this.type=t.MSG_VIDEO,this._percent=0,this.content={remoteVideoUrl:e.remoteVideoUrl||e.videoUrl||"",videoFormat:e.videoFormat,videoSecond:parseInt(e.videoSecond,10),videoSize:e.videoSize,videoUrl:ft(e.videoUrl,s),videoDownloadFlag:2,videoUUID:e.videoUUID,thumbUUID:e.thumbUUID,thumbFormat:e.thumbFormat,thumbWidth:e.thumbWidth,snapshotWidth:e.thumbWidth,thumbHeight:e.thumbHeight,snapshotHeight:e.thumbHeight,thumbSize:e.thumbSize,snapshotSize:e.thumbSize,thumbDownloadFlag:2,thumbUrl:ft(e.thumbUrl,s),snapshotUrl:ft(e.thumbUrl,s)}}updatePercent(e){this._percent=e,this._percent>1&&(this._percent=1)}updateVideoUrl(e){e&&(this.content.remoteVideoUrl=e)}updateSnapshotInfo(e){const{snapshotUrl:t,snapshotWidth:s,snapshotHeight:o}=e;St(t)||(this.content.thumbUrl=this.content.snapshotUrl=t),St(s)||(this.content.thumbWidth=this.content.snapshotWidth=Number(s)),St(o)||(this.content.thumbHeight=this.content.snapshotHeight=Number(o))}sendable(){return""!==this.content.remoteVideoUrl}}class Io{constructor(e){this.type=t.MSG_LOCATION;const{description:s,longitude:o,latitude:i}=e;this.content={description:s,longitude:o,latitude:i}}sendable(){return!0}}class fo{constructor(e,s){if(this.from=e.from,this.messageSender=e.from,this.time=e.time,this.messageSequence=e.sequence,this.clientSequence=e.clientSequence||e.sequence,this.messageRandom=e.random,this.cloudCustomData=e.cloudCustomData||"",this.clientTime=e.clientTime||void 0,e.ID)this.ID=e.ID||"",this.nick=e.nick||"",this.avatar=e.avatar||"",e.messageBody?this.messageBody=JSON.parse(JSON.stringify(e.messageBody)):this.messageBody=[{type:e.type,payload:e.payload}],e.conversationType?e.conversationType.startsWith(t.CONV_C2C)?this.receiverUserID=e.to:e.conversationType.startsWith(t.CONV_GROUP)&&(this.receiverGroupID=e.to):e.receiverGroupID?this.receiverGroupID=e.receiverGroupID:e.receiverUserID&&(this.receiverUserID=e.receiverUserID),this.messageReceiver=e.to||e.messageReceiver;else{this.nick=e.nick||"",this.avatar=e.avatar||"",this.messageBody=[];const o=e.elements[0].type,i=e.elements[0].content;this._patchRichMediaPayload(o,i),this._updateRichMediaDownloadUrl(o,i,s),o===t.MSG_MERGER?this.messageBody.push({type:o,payload:new To(i).content}):this.messageBody.push({type:o,payload:i}),e.groupID&&(this.receiverGroupID=e.groupID,this.messageReceiver=e.groupID),e.to&&(this.receiverUserID=e.to,this.messageReceiver=e.to),this.ID=`${e.tinyID}-${e.clientTime}-${e.random}`}}_patchRichMediaPayload(e,s){e===t.MSG_IMAGE?s.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===t.MSG_VIDEO?!s.remoteVideoUrl&&s.videoUrl&&(s.remoteVideoUrl=s.videoUrl):e===t.MSG_AUDIO?!s.remoteAudioUrl&&s.url&&(s.remoteAudioUrl=s.url):e===t.MSG_FILE&&!s.fileUrl&&s.url&&(s.fileUrl=s.url,s.url=void 0)}_updateRichMediaDownloadUrl(e,s,o){o&&(e===t.MSG_IMAGE?s.imageInfoArray.forEach(e=>{e.url=ft(e.url,o)}):e===t.MSG_VIDEO?(s.videoUrl=ft(s.videoUrl,o),s.snapshotUrl=ft(s.thumbUrl,o),s.snapshotHeight=s.thumbHeight,s.snapshotWidth=s.thumbWidth):e===t.MSG_AUDIO?s.url=ft(s.url,o):e===t.MSG_FILE&&(s.fileUrl=ft(s.fileUrl,o)))}}var To=class{constructor(e,s){if(this.type=t.MSG_MERGER,this.content={downloadKey:"",pbDownloadKey:"",messageList:[],title:"",abstractList:[],compatibleText:"",version:0,layersOverLimit:!1},e.downloadKey){const{downloadKey:t,pbDownloadKey:s,title:o,abstractList:i,compatibleText:n,version:r}=e;this.content.downloadKey=t,this.content.pbDownloadKey=s,this.content.title=o,this.content.abstractList=i,this.content.compatibleText=n,this.content.version=r||0}else if(St(e.messageList))1===e.layersOverLimit&&(this.content.layersOverLimit=!0);else{const{messageList:t,title:o,abstractList:i,compatibleText:n,version:r}=e,a=[];t.forEach(e=>{if(!St(e)){const t=new fo(e,s);a.push(t)}}),this.content.messageList=a,this.content.title=o,this.content.abstractList=i,this.content.compatibleText=n,this.content.version=r||0}}sendable(){return!St(this.content.messageList)||!St(this.content.downloadKey)}};const Co={1:t.MSG_PRIORITY_HIGH,2:t.MSG_PRIORITY_NORMAL,3:t.MSG_PRIORITY_LOW,4:t.MSG_PRIORITY_LOWEST};class Eo{constructor(e){this.ID="",this.conversationID=e.conversationID||null,this.conversationType=e.conversationType||t.CONV_C2C,this.conversationSubType=e.conversationSubType,this.time=e.time||Math.ceil(Date.now()/1e3),this.sequence=e.sequence||0,this.clientSequence=e.clientSequence||e.sequence||0,this.random=e.random||0===e.random?e.random:Be(),this.priority=this._computePriority(e.priority),this.nick=e.nick||"",this.avatar=e.avatar||"",this.isPeerRead=!1,this.nameCard="",this.hasRiskContent=Ct(e.checkResult),this._elements=[],this.isPlaceMessage=e.isPlaceMessage||0,this.isRevoked=2===e.isPlaceMessage||8===e.msgFlagBits,this.from=e.from||null,this.to=e.to||null,this.flow="",this.isSystemMessage=e.isSystemMessage||!1,this.protocol=e.protocol||"JSON",this.isResend=!1,this.isRead=!1,this.status=e.status||Nt.SUCCESS,this._onlineOnlyFlag=!1,this._groupAtInfoList=[],this._relayFlag=!1,this.atUserList=[],this.cloudCustomData=e.cloudCustomData||"",this.isDeleted=!1,this.isModified=!1,this._isExcludedFromUnreadCount=!(!e.messageControlInfo||1!==e.messageControlInfo.excludedFromUnreadCount),this._isExcludedFromLastMessage=!(!e.messageControlInfo||1!==e.messageControlInfo.excludedFromLastMessage),this.clientTime=e.clientTime||he()||0,this.senderTinyID=e.senderTinyID||e.tinyID||"",this.readReceiptInfo=e.readReceiptInfo||{readCount:void 0,unreadCount:void 0,isPeerRead:void 0},this.needReadReceipt=!0===e.needReadReceipt||1===e.needReadReceipt,this.version=e.messageVersion||0,this.isBroadcastMessage=e.isBroadcastMessage||!1,this._receiverList=e.receiverList||void 0,this.isSupportExtension=!0===e.isSupportExtension||1===e.isSupportExtension,this.revoker=e.revokerInfo&&e.revokerInfo.revoker||"",this.revokerInfo=e.revokerInfo||{userID:"",nick:"",avatar:""},this.revokeReason=e.revokeReason||"",this.reInitialize(e.currentUser),this.extractGroupInfo(e.groupProfile||null),this.handleGroupAtInfo(e),this.initC2CReadReceiptInfo(e.readReceiptSentByPeer)}get elements(){return this._elements}getElements(){return this._elements}extractGroupInfo(e){if(null===e)return;Oe(e.nick)&&(this.nick=e.nick),Oe(e.avatar)&&(this.avatar=e.avatar);const{messageFromAccountExtraInformation:t}=e;Le(t)&&Oe(t.nameCard)&&(this.nameCard=t.nameCard)}handleGroupAtInfo(e){e.payload&&e.payload.atUserList&&e.payload.atUserList.forEach(e=>{e!==t.MSG_AT_ALL?(this._groupAtInfoList.push({groupAtAllFlag:0,groupAtUserID:e}),this.atUserList.push(e)):(this._groupAtInfoList.push({groupAtAllFlag:1}),this.atUserList.push(t.MSG_AT_ALL))}),Ue(e.groupAtInfo)&&e.groupAtInfo.forEach(e=>{0===e.groupAtAllFlag?this.atUserList.push(e.groupAtUserID):1===e.groupAtAllFlag&&this.atUserList.push(t.MSG_AT_ALL)})}getGroupAtInfoList(){return this._groupAtInfoList}_initProxy(){this._elements[0]&&(this.payload=this._elements[0].content,this.type=this._elements[0].type)}reInitialize(e){e&&(this.status=this.from?Nt.SUCCESS:Nt.UNSEND,!this.from&&(this.from=e)),this._initFlow(e),this._initSequence(e),this._concatConversationID(e),this.generateMessageID()}isSendable(){return 0!==this._elements.length&&(!0===this._relayFlag||"function"==typeof this._elements[0].sendable&&this._elements[0].sendable())}_initTo(e){this.conversationType===t.CONV_GROUP&&(this.to=e.groupID)}_initSequence(e){0===this.clientSequence&&e&&(this.clientSequence=function(e){if(!e)return!1;if(void 0===We[e]){const t=new Date;let s=("3"+t.getHours()).slice(-2),o=("0"+t.getMinutes()).slice(-2),i=("0"+t.getSeconds()).slice(-2);We[e]=parseInt([s,o,i,"0001"].join("")),s=null,o=null,i=null,Ie.l("autoIncrementIndex start index:"+We[e])}return We[e]++}(e)),0===this.sequence&&this.conversationType===t.CONV_C2C&&(this.sequence=this.clientSequence)}generateMessageID(){this.from===t.CONV_SYSTEM&&(this.senderTinyID="144115198244471703"),this.ID=`${this.senderTinyID}-${this.clientTime}-${this.random}`}_initFlow(e){""!==e&&(e===this.from?(this.flow="out",this.isRead=!0):this.flow="in")}_concatConversationID(e){const{to:s}=this;let o="";const i=this.conversationType;i!==t.CONV_SYSTEM?(o=i===t.CONV_C2C?e===this.from?s:this.from:this.to,this.conversationID=o?`${i}${o}`:null):this.conversationID=t.CONV_SYSTEM}isElement(e){return e instanceof ro||e instanceof ao||e instanceof co||e instanceof uo||e instanceof go||e instanceof Mo||e instanceof _o||e instanceof ho||e instanceof mo||e instanceof Io||e instanceof To}setElement(e,s){if(this.isElement(e))return this._elements=[e],void this._initProxy();const o=e=>{if(e.type&&e.content)switch(e.type){case t.MSG_TEXT:this.setTextElement(e.content);break;case t.MSG_IMAGE:this.setImageElement(e.content,s);break;case t.MSG_AUDIO:this.setAudioElement(e.content,s);break;case t.MSG_FILE:this.setFileElement(e.content,s);break;case t.MSG_VIDEO:this.setVideoElement(e.content,s);break;case t.MSG_CUSTOM:this.setCustomElement(e.content);break;case t.MSG_LOCATION:this.setLocationElement(e.content);break;case t.MSG_GRP_TIP:this.setGroupTipElement(e.content);break;case t.MSG_GRP_SYS_NOTICE:this.setGroupSystemNoticeElement(e.content);break;case t.MSG_FACE:this.setFaceElement(e.content);break;case t.MSG_MERGER:this.setMergerElement(e.content,s)}};if(Ue(e))for(let t=0;t<e.length;t++)o(e[t]);else o(e);this._initProxy()}clearElement(){this._elements.length=0}setTextElement(e){const t="string"==typeof e?e:e.text,s=new ro({text:t});this._elements.push(s)}setImageElement(e,t){const s=new ao(e,t);this._elements.push(s)}setAudioElement(e,t){const s=new uo(e,t);this._elements.push(s)}setFileElement(e,t){const s=new go(e,t);this._elements.push(s)}setVideoElement(e,t){const s=new Mo(e,t);this._elements.push(s)}setLocationElement(e){const t=new Io(e);this._elements.push(t)}setCustomElement(e){const t=new mo(e);this._elements.push(t)}setGroupTipElement(e){let s={};const o=e.operationType;if(St(e.memberInfoList)?e.operatorInfo&&(s=e.operatorInfo):o!==t.GRP_TIP_MBR_JOIN&&o!==t.GRP_TIP_MBR_KICKED_OUT&&o!==t.GRP_TIP_MBR_SET_ADMIN&&o!==t.GRP_TIP_MBR_CANCELED_ADMIN||(s=e.memberInfoList[0]),!St(e.memberExtraInfo)){const{reason:t}=e.memberExtraInfo;e.msgMemberInfo.forEach(e=>{e.reason=t})}const{nick:i,avatar:n}=s;Oe(i)&&(this.nick=i),Oe(n)&&(this.avatar=n);const r=new _o(e);this._elements.push(r)}setGroupSystemNoticeElement(e){const t=new ho(e);this._elements.push(t)}setFaceElement(e){const t=new co(e);this._elements.push(t)}setMergerElement(e,t){const s=new To(e,t);this._elements.push(s)}setIsRead(e){this.isRead=e}setRelayFlag(e){this._relayFlag=e}_computePriority(e){if(Pe(e))return t.MSG_PRIORITY_NORMAL;if(Oe(e)&&-1!==Object.values(Co).indexOf(e))return e;if(Ae(e)){const t=""+e;if(-1!==Object.keys(Co).indexOf(t))return Co[t]}return t.MSG_PRIORITY_NORMAL}setNickAndAvatar(e){const{nick:t,avatar:s}=e;Oe(t)&&(this.nick=t),Oe(s)&&(this.avatar=s)}setNameCard(e){Oe(e)&&(this.nameCard=e)}initC2CReadReceiptInfo(e){this.conversationType===t.CONV_C2C&&!0===this.needReadReceipt&&(this.readReceiptInfo.isPeerRead=1===e)}}class So extends Bs{constructor(e){super(e),this._n="C2CModule",this._messageFromUnreadDBMap=new Map,this._noticeFromUnreadDBList=[]}onNewC2CMessage(t){const{dataList:s,isInstantMessage:o,C2CRemainingUnreadList:i,C2CPairUnreadList:n,isSyncingEnded:r}=t;Ie.d(`${this._n}.onNewC2CMessage count:${s.length} isInstantMessage:${o}`);const{conversationOptionsList:a,messageList:c,isUnreadC2CMessage:u}=this._newC2CMessageStoredAndSummary({dataList:s,C2CRemainingUnreadList:i,C2CPairUnreadList:n,isInstantMessage:o});this.filterModifiedMessage(c);this.getModule(hs).onNewMessage({conversationOptionsList:a,isInstantMessage:o,isUnreadC2CMessage:u,isSyncingEnded:r});const l=this.filterUnmodifiedMessage(c);o&&l.length>0&&this.emitOuterEvent(e.MESSAGE_RECEIVED,l),c.length=0}_newC2CMessageStoredAndSummary({dataList:e,C2CRemainingUnreadList:s,C2CPairUnreadList:o,isInstantMessage:i}){let n=null;const r=[],a=[],c={},u=this.getModule(vs);let l=!1;const d=this.getModule(hs),_=this.getModule(us),p=this.getFileDownloadProxy();for(let g=0,m=e.length;g<m;g++){if(this._isC2CNotice(e[g])){this._noticeFromUnreadDBList.push(e[g].eventArray[0].c2CNotifyMsgArray[0]);continue}const s=e[g];s.currentUser=this.getMyUserID(),s.conversationType=t.CONV_C2C,s.isSystemMessage=!!s.isSystemMessage,(Pe(s.nick)||Pe(s.avatar))&&(l=!0,Ie.d(this._n+"._newC2CMessageStoredAndSummary nick or avatar missing!")),n=new Eo(s),n.setElement(s.elements,p),n.setNickAndAvatar({nick:s.nick,avatar:s.avatar});const{conversationID:o}=n;if(i){if(1===this._messageFromUnreadDBMap.get(n.ID))continue;let t=!1;if(n.from!==this.getMyUserID()){const e=d.getLatestMessageSentByPeer(o);if(e){const{nick:s,avatar:o}=e;l?n.setNickAndAvatar({nick:s,avatar:o}):s===n.nick&&o===n.avatar||(t=!0)}}else{const e=d.getLatestMessageSentByMe(o);if(e){const{nick:t,avatar:s}=e;t===n.nick&&s===n.avatar||(d.modifyMessageSentByMe({conversationID:o,latestNick:n.nick,latestAvatar:n.avatar}),_.mockOnNickAvatarModified(n.nick,n.avatar))}}let r=1===e[g].isModified;if(d.isMessageSentByCurrentInstance(n)?n.isModified=r:r=!1,0===s.msgLifeTime)n._onlineOnlyFlag=!0,d.isMessageSentByCurrentInstance(n)||a.push(n);else{if(!d.pushIntoMessageList(a,n,r))continue;t&&(d.modifyMessageSentByPeer({conversationID:o,latestNick:n.nick,latestAvatar:n.avatar}),d.updateUserProfileSpecifiedKey({conversationID:o,nick:n.nick,avatar:n.avatar}))}i&&n.clientTime>0&&u.addMessageDelay(n.clientTime)}else this._messageFromUnreadDBMap.set(n.ID,1);if(0!==s.msgLifeTime){if(!1===n._onlineOnlyFlag){const e=d.getLastMessageTime(o);if(Ae(e)&&n.time<e)continue;if(Pe(c[o])){let e=0;"in"===n.flow&&(n._isExcludedFromUnreadCount||(e=1)),c[o]=r.push({conversationID:o,unreadCount:e,type:n.conversationType,subType:n.conversationSubType,lastMessage:n._isExcludedFromLastMessage?"":n})-1}else{const e=c[o];r[e].type=n.conversationType,r[e].subType=n.conversationSubType,r[e].lastMessage=n._isExcludedFromLastMessage?"":n,"in"===n.flow&&(n._isExcludedFromUnreadCount||r[e].unreadCount++)}}}else n._onlineOnlyFlag=!0}this._handleRevokedNoticeFromUnreadDB();let h=!1;if(Ue(o))for(let g=0,m=o.length;g<m;g++)if(o[g].unreadCount>0){h=!0;const e=r.find(({conversationID:e})=>e==="C2C"+o[g].from);e?e.unreadCount=o[g].unreadCount:r.push({conversationID:"C2C"+o[g].from,unreadCount:o[g].unreadCount,type:t.CONV_C2C})}if(Ue(s))for(let g=0,m=s.length;g<m;g++){r.find(({conversationID:e})=>e==="C2C"+s[g].from)||r.push({conversationID:"C2C"+s[g].from,type:t.CONV_C2C,lastMsgTime:s[g].lastMsgTime})}return{conversationOptionsList:r,messageList:a,isUnreadC2CMessage:h}}_isC2CNotice(e){const{eventArray:t}=e;return!(!Ue(t)||10!==t[0].event)}_handleRevokedNoticeFromUnreadDB(){const e=this._noticeFromUnreadDBList.length;if(0===e)return;Ie.l(`${this._n}._handleRevokedNoticeFromUnreadDB count:${e}`);const t=[];this._noticeFromUnreadDBList.forEach(e=>{e.hasOwnProperty("c2cMessageRevokedNotify")&&t.push(e)}),this.onC2CMessageRevoked({dataList:t}),this._noticeFromUnreadDBList.length=0,t.length=0}onC2CMessageRevoked(s){const o=this.getModule(hs),i=[];let n=null;s.dataList.forEach(e=>{if(e.c2cMessageRevokedNotify){const{revokedInfos:s}=e.c2cMessageRevokedNotify;Pe(s)||s.forEach(e=>{const s=this.getMyUserID()===e.from?`${t.CONV_C2C}${e.to}`:`${t.CONV_C2C}${e.from}`;n=o.revoke(s,e.sequence,e.random);const r=e.revokerInfo&&e.revokerInfo.revoker,a=e.revokerInfo&&e.revokerInfo.reason||"";let c;n?c=n:(c={conversationID:s,sequence:e.sequence},e.tinyID&&e.clientTime&&e.random&&(c.ID=`${e.tinyID}-${e.clientTime}-${e.random}`),e.time&&(c.time=e.time)),c&&(c.revoker=r,c.revokeReason=a,c.revokerInfo={userID:r,nick:"",avatar:""},i.push(c))})}}),0!==i.length&&(o.onMessageRevoked(i),Ie.l(`${this._n}.onC2CMessageRevoked count:${i.length}`),o.updateRevokerInfo(i).then(t=>{this.emitOuterEvent(e.MESSAGE_REVOKED,t)}))}onC2CMessageReadReceipt(e){e.dataList.forEach(e=>{if(!St(e.c2cMessageReadReceipt)){const{to:s}=e.c2cMessageReadReceipt;e.c2cMessageReadReceipt.uinPairReadArray.forEach(e=>{const{peerReadTime:o}=e;Ie.d(`${this._n}._onC2CMessageReadReceipt to:${s} peerReadTime:${o}`);const i=`${t.CONV_C2C}${s}`,n=this.getModule(hs);n.recordPeerReadTime(i,o),n.updateMessageIsPeerReadProperty(i,o)})}})}onC2CMessageReadNotice(e){e.dataList.forEach(e=>{if(!St(e.c2cMessageReadNotice)){const s=this.getModule(hs);e.c2cMessageReadNotice.uinPairReadArray.forEach(e=>{const{from:o,peerReadTime:i}=e;Ie.d(`${this._n}.onC2CMessageReadNotice from:${o} lastReadTime:${i}`);const n=`${t.CONV_C2C}${o}`;s.updateIsReadAfterReadReport({conversationID:n,lastMessageTime:i}),s.updateUnreadCount(n)})}})}onC2CMessageModified(e){Ie.d(this._n+".onC2CMessageModified options:",JSON.stringify(e));const s=this.getModule(hs);e.dataList.forEach(e=>{s.onMessageModified({...e,conversationType:t.CONV_C2C})})}onReadReceiptList(e){Ie.d(this._n+".onReadReceiptList options:",JSON.stringify(e));const{userID:t,readReceiptList:s}=e.dataList;this.getModule(hs).updateReadReceiptInfo({userID:t,readReceiptList:s})}sendMessage(e,t){const s=this._createC2CMessagePack(e,t);return this.request(s)}_createC2CMessagePack(e,t){let s=null;t&&(t.offlinePushInfo&&(s=t.offlinePushInfo),!0===t.onlineUserOnly&&(s?s.disablePush=!0:s={disablePush:!0}));let o="";Oe(e.cloudCustomData)&&e.cloudCustomData.length>0&&(o=e.cloudCustomData);const i=[];if(Le(t)&&Le(t.messageControlInfo)){const{excludedFromUnreadCount:e,excludedFromLastMessage:s,excludedFromContentModeration:o}=t.messageControlInfo;!0===e&&i.push("NoUnread"),!0===s&&i.push("NoLastMsg"),!0===o&&i.push("NoMsgCheck")}const n=this.isOnlineMessage(e,t)?0:void 0;return{protocolName:Ks.SEND_C2C_MESSAGE,tjgID:this.generateTjgID(e),requestData:{fromAccount:this.getMyUserID(),toAccount:e.to,msgBody:e.getElements(),cloudCustomData:o,msgSeq:e.sequence,msgRandom:e.random,msgLifeTime:n,nick:e.nick,avatar:e.avatar,offlinePushInfo:s?{pushFlag:!0===s.disablePush?1:0,title:s.title||"",desc:s.description||"",ext:s.extension||"",apnsInfo:{badgeMode:!0===s.ignoreIOSBadge?1:0,isVoipPush:this._isVoipPush(s)},androidInfo:{OPPOChannelID:s.androidOPPOChannelID||""}}:void 0,messageControlInfo:0!==n?i:void 0,clientTime:e.clientTime,needReadReceipt:!0===e.needReadReceipt?1:0,isSupportExtension:!0===e.isSupportExtension?1:0,isRelayMessage:!0===e._relayFlag?1:0}}}_isVoipPush(e){let t=void 0;return Pe(e.disableVoipPush)||(t=!1===e.disableVoipPush?1:0),t}isOnlineMessage(e,t){return!(!t||!0!==t.onlineUserOnly)}revokeMessage(e){return this.request({protocolName:Ks.REVOKE_C2C_MESSAGE,requestData:{msgInfo:{fromAccount:e.from,toAccount:e.to,msgSeq:e.sequence,msgRandom:e.random,msgTimeStamp:e.time}}})}deleteMessage(e){const{to:t,keyList:s}=e;return Ie.l(`${this._n}.deleteMessage toAccount:${t} count:${s.length}`),this.request({protocolName:Ks.DELETE_C2C_MESSAGE,requestData:{fromAccount:this.getMyUserID(),to:t,keyList:s}})}modifyRemoteMessage(e){const{from:s,to:o,version:i=0,sequence:n,random:r,time:a,payload:c,type:u,cloudCustomData:l}=e;let d=void 0;return function(e){return e===t.MSG_TEXT||e===t.MSG_CUSTOM||e===t.MSG_LOCATION||e===t.MSG_FACE}(u)&&(d=[],d.push({type:u,content:c})),this.request({protocolName:Ks.MODIFY_C2C_MESSAGE,requestData:{from:s,to:o,version:i,sequence:n,random:r,time:a,elements:d,cloudCustomData:l}})}setMessageRead({conversationID:e,lastMessageTime:t}){const s=this._n+".setMessageRead";Ie.l(`${s} conversationID:${e} lastMessageTime:${t}`),Ae(t)||this.outputWarning("DoNotModifyLastTime");const o=new no("setC2CMessageRead");return o.setMessage(`conversationID:${e} lastMessageTime:${t}`),this.request({protocolName:Ks.SET_C2C_MESSAGE_READ,requestData:{C2CMsgReaded:{cookie:"",C2CMsgReadedItem:[{toAccount:e.replace("C2C",""),lastMessageTime:t,receipt:1}]}}}).then(()=>{o.setNetworkType(this.getNetworkType()).end(),Ie.l(s+" ok");const i=this.getModule(hs);return i.updateIsReadAfterReadReport({conversationID:e,lastMessageTime:t}),i.updateUnreadCount(e),ws()}).catch(e=>(this.probeNetwork().then(([t,s])=>{o.setError(e,t,s).end()}),Ie.l(s+" failed. error:",e),Vs(e)))}getRoamingMessage(e){const s=this._n+".getRoamingMessage",{peerAccount:o,conversationID:i,count:n,lastMessageTime:r,messageKey:a}=e,c=`peerAccount:${o} count:${n||15} lastMessageTime:${r||0} messageKey:${a}`;Ie.l(`${s} ${c}`);const u=new no("getC2CRoamingMessages");return this.request({protocolName:Ks.GET_C2C_ROAMING_MESSAGE,requestData:{peerAccount:o,count:n||15,lastMessageTime:r||0,messageKey:a}}).then(e=>{const{complete:o,messageList:n,messageKey:r,lastMessageTime:a}=e.data;Pe(n)?Ie.l(`${s} ok. complete:${o} but messageList is undefined!`):Ie.l(`${s} ok. complete:${o} count:${n.length}`),u.setNetworkType(this.getNetworkType()).setMessage(`${c} complete:${o} length:${n.length}`).end();const l=this.getModule(hs);1===o&&l.setCompleted(i);const d=l.onRoamingMessage(n,i);l.modifyMessageList(i),l.updateIsRead(i),l.updateRoamingMessageKeyAndTime(i,r,a);const _=l.getPeerReadTime(i);if(Ie.l(`${s} update isPeerRead property. conversationID:${i} peerReadTime:${_}`),_)l.updateMessageIsPeerReadProperty(i,_);else{const e=i.replace(t.CONV_C2C,"");this.getRemotePeerReadTime([e]).then(()=>{l.updateMessageIsPeerReadProperty(i,l.getPeerReadTime(i))})}let p="";if(d.length>0)p=d[0].ID;else{const e=l.getLocalOldestMessage(i);e&&(p=e.ID)}return Ie.l(`${s} nextReqID:${p} stored message count:${d.length}`),{nextReqID:p,storedMessageList:d}}).catch(e=>(this.probeNetwork().then(([t,s])=>{u.setMessage(c).setError(e,t,s).end()}),Ie.w(s+" failed. error:",e),Vs(e)))}getRoamingMessagesHopping(e){const s=this._n+".getRoamingMessagesHopping",{peerAccount:o,time:i=0,count:n,direction:r}=e,a=`${t.CONV_C2C}${o}`,c=`peerAccount:${o} count:${n} time:${i} direction:${r}`;Ie.l(`${s} ${c}`);const u=new no("getC2CRoamingMessagesHopping");return this.request({protocolName:Ks.GET_C2C_ROAMING_MESSAGE,requestData:{peerAccount:o,count:n+1,lastMessageTime:i,direction:r}}).then(e=>{const{complete:t,messageList:o=[],lastMessageTime:i}=e.data;Ie.l(`${s} ok. complete:${t} count:${o.length}`),u.setNetworkType(this.getNetworkType()).setMessage(`${c} complete:${t} length:${o.length}`).end(),1!==t&&(1===r?o.pop():o.shift());const n=this.getModule(hs).onRoamingMessage(o,a,!1);this._modifyMessageList(a,n);const l=this._computeResult({complete:t,lastMessageTime:i,resultList:n});return ws(l)}).catch(e=>(this.probeNetwork().then(([t,s])=>{u.setMessage(c).setError(e,t,s).end()}),Ie.w(s+" failed. error:",e),Vs(e)))}_computeResult(e){const{complete:t=0,lastMessageTime:s,resultList:o=[]}=e,i={messageList:[...o],isCompleted:!1,nextMessageTime:""};return 1===t?(i.isCompleted=!0,i):(i.nextMessageTime=s,i)}_modifyMessageList(e,t){const s=this.getModule(hs).getLocalConversation(e);if(!s)return;const o=s.userProfile.nick,i=s.userProfile.avatar,n=this.getModule(us).getNickAndAvatarByUserID(this.getMyUserID()),r=n.nick,a=n.avatar;for(let c=t.length-1;c>=0;c--){const e=t[c];"in"===e.flow&&(e.nick!==o&&e.setNickAndAvatar({nick:o}),e.avatar!==i&&e.setNickAndAvatar({avatar:i})),"out"===e.flow&&(e.nick!==r&&e.setNickAndAvatar({nick:r}),e.avatar!==a&&e.setNickAndAvatar({avatar:a}))}}getRemotePeerReadTime(e){const t=this._n+".getRemotePeerReadTime";if(St(e))return Ie.w(t+" userIDList is empty!"),Promise.resolve();const s=new no("getPeerReadTime");return Ie.l(`${t} userIDList:${e}`),this.request({protocolName:Ks.GET_C2C_PEER_READ_TIME,requestData:{userIDList:e}}).then(o=>{const{peerReadTimeList:i}=o.data;Ie.l(`${t} ok. peerReadTimeList:${i}`);let n="";const r=this.getModule(hs);for(let t=0;t<e.length;t++)n+=`${e[t]}-${i[t]} `,i[t]>0&&r.recordPeerReadTime("C2C"+e[t],i[t]);s.setNetworkType(this.getNetworkType()).setMessage(n).end()}).catch(e=>{this.probeNetwork().then(([t,o])=>{s.setError(e,t,o).end()}),Ie.w(t+" failed. error:",e)})}sendReadReceipt(e){const s=e[0].conversationID.replace(t.CONV_C2C,""),o=new no("sendC2CReadReceipt");o.setMessage("peerAccount:"+s);const i=this.getMyUserID(),n=e.filter(e=>e.from!==i&&!0===e.needReadReceipt).map(e=>{const{from:t,to:s,sequence:o,random:i,time:n,clientTime:r}=e;return{fromAccount:t,toAccount:s,sequence:o,random:i,time:n,clientTime:r}});if(0===n.length)return Vs({code:$s.READ_RECEIPT_MSG_LIST_EMPTY});const r=this._n+".sendReadReceipt";return Ie.l(`${r}. peerAccount:${s} messageInfoList length:${n.length}`),this.request({protocolName:Ks.SEND_C2C_READ_RECEIPT,requestData:{peerAccount:s,messageInfoList:n}}).then(e=>(o.end(),Ie.l(r+" ok"),ws())).catch(e=>(this.probeNetwork().then(([t,s])=>{o.setError(e,t,s).end()}),Ie.w(r+" failed. error:",e),Vs(e)))}getReadReceiptList(e){const t=this._n+".getReadReceiptList",s=this.getMyUserID(),o=e.filter(e=>e.from===s&&!0===e.needReadReceipt);return Ie.l(`${t} userID:${s} messageList length:${o.length}`),xs({messageList:o})}getMessageExtensions(e,t){return Ie.l(`${this._n}.getMessageExtensions startSequence:${t}`),this.request({protocolName:Ks.GET_C2C_MESSAGE_EXTENSIONS,requestData:{from:e.from,to:e.to,messageKey:this.getMessageKey(e),startSequence:t}})}modifyMessageExtensions(e,t,s=1){return Ie.l(`${this._n}.modifyMessageExtensions operateType:${s}`),this.request({protocolName:Ks.MODIFY_C2C_MESSAGE_EXTENSIONS,requestData:{from:e.from,to:e.to,messageKey:this.getMessageKey(e),extensionList:t,operateType:s}})}getMessageKey(e){const{clientSequence:t,random:s,time:o}=e;return`${t}_${s}_${o}`}reset(){Ie.l(this._n+".reset"),this._messageFromUnreadDBMap.clear(),this._noticeFromUnreadDBList.length=0}}class yo{constructor(){this.list=new Map,this._n="MessageListHandler",this._latestMessageSentByPeerMap=new Map,this._latestMessageSentByMeMap=new Map}getLocalOldestMessageByConversationID(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}pushIn(e,t=!1){const{conversationID:s}=e;let o=!0;this.list.has(s)||this.list.set(s,new Map);const i=this._getUniqueIDOfMessage(e);if(this.list.get(s).has(i)){const e=this.list.get(s).get(i);if(!t||!0===e.isModified)return o=!1,o}return this.list.get(s).set(i,e),this._setLatestMessageSentByPeer(s,e),this._setLatestMessageSentByMe(s,e),o}unshift(e,s){let o;if(Ue(e)?e.length>0&&(o=e[0].conversationID,this._unshiftMultipleMessages(e,s)):(o=e.conversationID,this._unshiftSingleMessage(e,s)),o){const e=Array.from(this.list.get(o).values()),s=e.length;if(0===s)return;for(let t=s-1;t>=0;t--)if("out"===e[t].flow){this._setLatestMessageSentByMe(o,e[t]);break}if(o.startsWith(t.CONV_C2C))for(let t=s-1;t>=0;t--)if("in"===e[t].flow){this._setLatestMessageSentByPeer(o,e[t]);break}}}_unshiftSingleMessage(e,t){const{conversationID:s}=e,o=this._getUniqueIDOfMessage(e);if(!this.list.has(s))return this.list.set(s,new Map),this.list.get(s).set(o,e),void t.push(e);const i=this.list.get(s),n=Array.from(i);i.has(o)||(n.unshift([o,e]),this.list.set(s,new Map(n)),t.push(e))}_unshiftMultipleMessages(e,t){const s=e.length,o=[],i=e[0].conversationID,n=this.list.get(i),r=this.list.has(i)?Array.from(n):[];for(let a=0;a<s;a++){const s=this._getUniqueIDOfMessage(e[a]);n&&n.has(s)||(o.push([s,e[a]]),t.push(e[a]))}this.list.set(i,new Map(o.concat(r)))}remove(e){const{conversationID:t}=e,s=this._getUniqueIDOfMessage(e);this.list.has(t)&&this.list.get(t).delete(s)}revoke(e,t,s){if(Ie.d("revoke message",e,t,s),this.list.has(e)){const o=this.list.get(e);for(const[,e]of o)if(e.sequence===t&&(Pe(s)||e.random===s))return e.isRevoked||(e.isRevoked=!0),e}return null}removeByConversationID(e){const t=this.list.has(e);Ie.l(`${this._n}.removeByConversationID conversationID:${e} has:${t}`),t&&(this.list.delete(e),this._latestMessageSentByPeerMap.delete(e),this._latestMessageSentByMeMap.delete(e))}findMessage(e){let t=null;for(const[,s]of this.list){const o=[...s.values()],i=o.length;for(let s=0;s<i;s++)if(o[s].ID===e){t=o[s];break}}return t}updateMessageIsPeerReadProperty(e,t){const s=[];if(this.list.has(e)){const o=this.list.get(e);for(const[,e]of o)e.time<=t&&!e.isPeerRead&&"out"===e.flow&&(e.isPeerRead=!0,s.push(e));Ie.l(`${this._n}.updateMessageIsPeerReadProperty conversationID:${e} peerReadTime:${t} count:${s.length}`)}return s}updateMessageIsModifiedProperty(e){const{conversationID:t}=e;if(!this.list.has(t))return;const s=this._getUniqueIDOfMessage(e),o=this.list.get(t).get(s);o&&(o.isModified=!0)}hasLocalMessageList(e){return this.list.has(e)}getLocalMessageList(e){return this.hasLocalMessageList(e)?[...this.list.get(e).values()]:[]}hasLocalMessage(e,t){let s=!1;const o=this.getLocalMessageList(e),i=o.length;for(let n=0;n<i;n++)o[n].ID===t&&(s=!0);return s}getLocalMessage(e,t){let s=null;const o=this.getLocalMessageList(e),i=o.length;for(let n=0;n<i;n++)if(o[n].ID===t){s=o[n];break}return s}getLocalLastMessage(e){const t=this.getLocalMessageList(e);return t[t.length-1]}getLocalOldestMessage(e){return this.getLocalMessageList(e)[0]}_setLatestMessageSentByPeer(e,s){e.startsWith(t.CONV_C2C)&&"in"===s.flow&&this._latestMessageSentByPeerMap.set(e,s)}_setLatestMessageSentByMe(e,t){"out"===t.flow&&this._latestMessageSentByMeMap.set(e,t)}getLatestMessageSentByPeer(e){return this._latestMessageSentByPeerMap.get(e)}getLatestMessageSentByMe(e){return this._latestMessageSentByMeMap.get(e)}modifyMessageSentByPeer(e){const{conversationID:t,latestNick:s,latestAvatar:o}=e,i=this.list.get(t);if(St(i))return;const n=Array.from(i.values()),r=n.length;if(0===r)return;let a=null,c=0,u=!1;for(let l=r-1;l>=0;l--)"in"===n[l].flow&&(a=n[l],a.nick!==s&&(a.setNickAndAvatar({nick:s}),u=!0),a.avatar!==o&&(a.setNickAndAvatar({avatar:o}),u=!0),u&&(c+=1));Ie.l(`${this._n}.modifyMessageSentByPeer conversationID:${t} count:${c}`)}modifyMessageSentByMe(e){const{conversationID:t,latestNick:s,latestAvatar:o}=e,i=this.list.get(t);if(St(i))return;const n=Array.from(i.values()),r=n.length;if(0===r)return;let a=null,c=0,u=!1;for(let l=r-1;l>=0;l--)"out"===n[l].flow&&(a=n[l],a.nick!==s&&(a.setNickAndAvatar({nick:s}),u=!0),a.avatar!==o&&(a.setNickAndAvatar({avatar:o}),u=!0),u&&(c+=1));Ie.l(`${this._n}.modifyMessageSentByMe conversationID:${t} count:${c}`)}getTopicConversationIDList(e){return[...this.list.keys()].filter(s=>s.startsWith(`${t.CONV_GROUP}${e}`))}traversal(){if(0!==this.list.size&&-1===Ie.getLevel()){console.group("conversationID-messageCount");for(const[e,t]of this.list)console.log(`${e}-${t.size}`);console.groupEnd()}}onMessageModified(e,t){if(!this.list.has(e))return{isUpdated:!1,message:null};const s=this._n+".onMessageModified",o=this._getUniqueIDOfMessage(t),i=this.list.get(e).has(o);if(Ie.l(`${s} conversationID:${e} uniqueID:${o} has:${i}`),i){const i=this.list.get(e).get(o),{messageVersion:n,elements:r,cloudCustomData:a,checkResult:c}=t;return Ie.l(`${s} localVersion:${i.version} remoteVersion:${n}`),i.version<n?(i.version=n,i._elements=JSON.parse(JSON.stringify(r)),i.payload=JSON.parse(JSON.stringify(r[0].content)),i.type=r[0].type,i.cloudCustomData=a,i.isModified=!0,i.hasRiskContent=Ct(c),{isUpdated:!0,message:i}):{isUpdated:!1,message:i}}return{isUpdated:!1,message:null}}_getUniqueIDOfMessage(e){const{from:t,to:s,random:o,sequence:i,time:n}=e;return`${t}-${s}-${o}-${i}-${n}`}reset(){this.list.clear(),this._latestMessageSentByPeerMap.clear(),this._latestMessageSentByMeMap.clear()}}const Do={A2KEY_AND_TINYID_UPDATED:"_inner1",CLOUD_CONFIG_UPDATED:"_inner2",PROFILE_UPDATED:"_inner3",CONV_SYNC_COMPLETED:"_inner4",C2C_UNREAD_HANDLE_COMPLETED:"_inner5"};function No(e){this.mixin(e)}No.mixin=function(e){const t=e.prototype||e;t._isReady=!1,t.ready=function(e,t=!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(){this._isReady=!0,setTimeout(()=>{const e=this._readyQueue;this._readyQueue=[],e&&e.length>0&&e.forEach((function(e){e.call(this)}),this)},1)},t.resetReady=function(){this._isReady=!1,this._readyQueue=[]},t.isReady=function(){return this._isReady}};const vo=["jpg","jpeg","gif","png","bmp","image","webp"],Ao=["mp4","quicktime","mov"],Oo=1,Ro=2,Lo=3,Uo=255;class Po{constructor(e){St(e)||(this.userID=e.userID||"",this.nick=e.nick||"",this.gender=e.gender||"",this.birthday=e.birthday||0,this.location=e.location||"",this.selfSignature=e.selfSignature||"",this.allowType=e.allowType||t.ALLOW_TYPE_ALLOW_ANY,this.language=e.language||0,this.avatar=e.avatar||"",this.messageSettings=e.messageSettings||0,this.adminForbidType=e.adminForbidType||t.FORBID_TYPE_NONE,this.level=e.level||0,this.role=e.role||0,this.lastUpdatedTime=0,this.profileCustomField=[],St(e.profileCustomField)||e.profileCustomField.forEach(e=>{this.profileCustomField.push({key:e.key,value:e.value})}))}validate(e){let t=!0,s="";if(St(e))return{valid:!1,tips:"empty options"};if(e.profileCustomField){const t=e.profileCustomField.length;let s=null;for(let o=0;o<t;o++){if(s=e.profileCustomField[o],!Oe(s.key)||-1===s.key.indexOf("Tag_Profile_Custom"))return{valid:!1,tips:"The prefix of keys of the custom profile key-value pairs (which is profileCustomField) must be Tag_Profile_Custom"};if(!Oe(s.value))return{valid:!1,tips:"The type of values of the custom profile key-value pairs (which is profileCustomField) must be String"}}}for(const o in e)if(Object.prototype.hasOwnProperty.call(e,o)){if("profileCustomField"===o)continue;if(St(e[o])&&!Oe(e[o])&&!Ae(e[o])){s="key:"+o+", invalid value:"+e[o],t=!1;continue}switch(o){case"nick":Oe(e[o])||(s="nick must be a string",t=!1),Ve(e[o])>500&&(s=`nick name limited: must less than or equal to 500 bytes, current size: ${Ve(e[o])} bytes`,t=!1);break;case"gender":Ye(Ce,e.gender)||(s="key:gender, invalid value:"+e.gender,t=!1);break;case"birthday":Ae(e.birthday)||(s="birthday must be a number",t=!1);break;case"location":Oe(e.location)||(s="location must be a string",t=!1);break;case"selfSignature":Oe(e.selfSignature)||(s="selfSignature must be a string",t=!1);break;case"allowType":Ye(Se,e.allowType)||(s="key:allowType, invalid value:"+e.allowType,t=!1);break;case"language":Ae(e.language)||(s="language must be a number",t=!1);break;case"avatar":Oe(e.avatar)||(s="avatar must be a string",t=!1);break;case"messageSettings":0!==e.messageSettings&&1!==e.messageSettings&&(s="messageSettings must be 0 or 1",t=!1);break;case"adminForbidType":Ye(Ee,e.adminForbidType)||(s="key:adminForbidType, invalid value:"+e.adminForbidType,t=!1);break;case"level":Ae(e.level)||(s="level must be a number",t=!1);break;case"role":Ae(e.role)||(s="role must be a number",t=!1);break;default:s="unknown key:"+o+" "+e[o],t=!1}}return{valid:t,tips:s}}}class Go{constructor(e){this.value=e,this.next=null}}class ko{constructor(e){this.MAX_LENGTH=e,this.pTail=null,this.pNodeToDel=null,this.map=new Map}set(e){const t=new Go(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 s=this.pNodeToDel;this.pNodeToDel=this.pNodeToDel.next,this.map.delete(s.value),s.next=null,s=null,this.pTail.next=t,this.pTail=t,this.map.set(e,1)}}has(e){return this.map.has(e)}delete(e){this.has(e)&&this.map.delete(e)}tail(){return this.pTail}size(){return this.map.size}data(){return Array.from(this.map.keys())}reset(){let e;for(;null!==this.pNodeToDel;)e=this.pNodeToDel,this.pNodeToDel=this.pNodeToDel.next,e.next=null,e=null;this.pTail=null,this.map.clear()}}const wo=["groupID","name","avatar","type","introduction","notification","ownerID","selfInfo","createTime","infoSequence","lastInfoTime","lastMessage","nextMessageSeq","memberNum","maxMemberNum","memberList","joinOption","groupCustomField","muteAllMembers","isSupportTopic","inviteOption","_lastRevokedTime"];class Fo{constructor(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.inviteOption="",this.groupCustomField=[],this.muteAllMembers=!1,this.isSupportTopic=!1,this._lastRevokedTime=0,this._initGroup(e)}set memberNum(e){}set maxMemberNum(e){}get memberNum(){return this.memberCount}get maxMemberNum(){return this.maxMemberCount}_initGroup(e){for(const t in e)wo.indexOf(t)<0||("selfInfo"!==t?("memberNum"===t&&(this.memberCount=e[t]),"maxMemberNum"===t&&(this.maxMemberCount=e[t]),"isSupportTopic"!==t?this[t]=e[t]:this.isSupportTopic=1===e[t]):this.updateSelfInfo(e[t]))}updateGroup(e){e.appid=void 0,e.grossTopicNextMsgSeq=void 0,e.selfInfo&&(e.selfInfo.grossTopicReadSeq=void 0);const t=JSON.parse(JSON.stringify(e));t.lastMsgTime&&(this.lastMessage.lastTime=t.lastMsgTime),Pe(t.muteAllMembers)||("On"===t.muteAllMembers?t.muteAllMembers=!0:t.muteAllMembers=!1),t.groupCustomField&&je(this.groupCustomField,t.groupCustomField),Pe(t.memberNum)||(this.memberCount=t.memberNum),Pe(t.maxMemberNum)||(this.maxMemberCount=t.maxMemberNum),Pe(t.isSupportTopic)||(this.isSupportTopic=Ae(t.isSupportTopic)?1===t.isSupportTopic:t.isSupportTopic),qe(this,t,["members","errorCode","lastMsgTime","groupCustomField","memberNum","maxMemberNum","isSupportTopic"]),Ue(t.members)&&t.members.length>0&&t.members.forEach(e=>{e.userID===this.selfInfo.userID&&qe(this.selfInfo,e,["sequence"])})}updateSelfInfo({nameCard:e,joinTime:t,role:s,messageRemindType:o,readedSequence:i,excludedUnreadSequenceList:n}){const r={nameCard:e,joinTime:t,role:s,messageRemindType:o,readedSequence:i,excludedUnreadSequenceList:n};qe(this.selfInfo,{...r},[],["",null,void 0,0,NaN])}setSelfNameCard(e){this.selfInfo.nameCard=e}}const $o=function(e,t,s){return Pe(e)?{lastTime:0,lastSequence:0,fromAccount:"",messageForShow:"",payload:null,type:"",isRevoked:!1,cloudCustomData:"",onlineOnlyFlag:!1,nick:"",nameCard:"",version:0,isPeerRead:!1,revoker:null}:s&&e.ID||e instanceof Eo?{lastTime:e.time||0,lastSequence:e.sequence||0,fromAccount:e.from||"",messageForShow:gt(e.type,e.payload,t),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,revoker:e.revoker||null}:{...e,messageForShow:gt(e.type,e.payload,t)}};class bo{constructor(e,t,s=!1){this.conversationID=e.conversationID||"",this.unreadCount=e.unreadCount||0,this.type=e.type||"",this.lastMessage=$o(e.lastMessage,t,s),e.lastMsgTime&&(this.lastMessage.lastTime=e.lastMsgTime),this._isInfoCompleted=!1,this.peerReadTime=e.peerReadTime||0,this.groupAtInfoList=[],this.remark="",this.isPinned=e.isPinned||!1,this.messageRemindType=e.messageRemindType,this.markList=e.markList||[],this.customData=e.customData||"",this.conversationGroupList=e.conversationGroupList||[],this.draftText=e.draftText||"",this._initProfile(e),this.subType=this.groupProfile?this.groupProfile.type:""}get toAccount(){return this.conversationID.startsWith(t.CONV_C2C)?this.conversationID.replace(t.CONV_C2C,""):this.conversationID.startsWith(t.CONV_GROUP)?this.conversationID.replace(t.CONV_GROUP,""):""}_initProfile(e){Object.keys(e).forEach(t=>{switch(t){case"userProfile":this.userProfile=e.userProfile;break;case"groupProfile":this.groupProfile=e.groupProfile}}),Pe(this.userProfile)&&this.type===t.CONV_C2C?this.userProfile=new Po({userID:e.conversationID.replace("C2C","")}):Pe(this.groupProfile)&&this.type===t.CONV_GROUP&&(this.groupProfile=new Fo({groupID:e.conversationID.replace("GROUP","")}))}updateUnreadCount(e){const{nextUnreadCount:s,isFromGetConversations:o,isUnreadC2CMessage:i}=e;Pe(s)||(Je(this.subType)?this.unreadCount=0:o&&this.type===t.CONV_GROUP||o&&this.type===t.CONV_TOPIC||i&&this.type===t.CONV_C2C?this.unreadCount=s:this.unreadCount=this.unreadCount+s)}updateLastMessage(e){this.lastMessage=$o(e)}updateGroupAtInfoList(e){if(this._isNeedMergeGroupAtInfo(e))return;let[...s]=e.groupAtType;-1!==s.indexOf(t.CONV_AT_ME)&&-1!==s.indexOf(t.CONV_AT_ALL)&&(s=[t.CONV_AT_ALL_AT_ME]);const o={from:e.from,groupID:e.groupID,topicID:e.topicID,messageSequence:e.sequence,atTypeArray:s,__random:e.__random,__sequence:e.__sequence};this.groupAtInfoList.push(o)}_isNeedMergeGroupAtInfo(e){const{groupID:s,sequence:o}=e;if(!Xe({groupID:s}))return!1;let i=!1;return this.groupAtInfoList.forEach(s=>{s.messageSequence===o&&(s.atTypeArray.indexOf(t.CONV_AT_ME)>-1&&e.groupAtType.indexOf(t.CONV_AT_ALL)>-1&&(s.atTypeArray=[t.CONV_AT_ALL_AT_ME]),s.atTypeArray.indexOf(t.CONV_AT_ALL)>-1&&e.groupAtType.indexOf(t.CONV_AT_ME)>-1&&(s.atTypeArray=[t.CONV_AT_ALL_AT_ME],s.__random=e.__random,s.__sequence=e.__sequence),i=!0)}),i}clearGroupAtInfoList(){this.groupAtInfoList.length=0}reduceUnreadCount(){return this.unreadCount>=1&&(this.unreadCount-=1,!0)}isLastMessageRevoked({sequence:e,time:s}){return this.type===t.CONV_C2C&&e===this.lastMessage.lastSequence&&s===this.lastMessage.lastTime||this.type===t.CONV_GROUP&&e===this.lastMessage.lastSequence}setLastMessageRevoked(e){this.lastMessage.isRevoked=e}setLastMessageRevoker(e){this.lastMessage.revoker=e}setDraftText(e){this.draftText=e}}class qo{constructor(e){this._conversationModule=e,this._n="MessageRemindHandler"}getC2CMessageRemindType(e){const t=this._n+".getC2CMessageRemindType";return this._conversationModule.request({protocolName:Ks.GET_C2C_PEER_MUTE_NOTIFICATIONS,requestData:{toAccount:this._conversationModule.getMyUserID(),userIDList:e}}).then(s=>{Ie.l(`${t} ok. userIDList:${e}`);const{muteFlagList:o}=s.data;this._conversationModule.onC2CMessageRemindTypeFetched(o)}).catch(e=>{Ie.e(t+" failed. error:",e)})}set(e){return e.groupID?this._setGroupMessageRemindType(e):Ue(e.userIDList)?this._setC2CMessageRemindType(e):void 0}_setGroupMessageRemindType(e){const t=this._n+"._setGroupMessageRemindType",{groupID:s,messageRemindType:o}=e,i=`groupID:${s} messageRemindType:${o}`,n=new no("setMessageRemindType");n.setMessage(i);const r=this._getModule(ds);return r?r.modifyGroupMemberInfo({groupID:s,messageRemindType:o,userID:this._conversationModule.getMyUserID()}).then(()=>{n.setNetworkType(this._conversationModule.getNetworkType()).end(),Ie.l(`${t} ok. ${i}`);const s=this.onGroupMessageRemindTypeUpdated(e);return this._conversationModule.emitTotalUnreadMessageCountUpdate(),ws(s)}).catch(e=>(this._conversationModule.probeNetwork().then(([t,s])=>{n.setError(e,t,s).end()}),Ie.e(t+" failed. error:",e),Vs(e))):Vs({code:$s.CANNOT_FIND_MODULE})}onGroupMessageRemindTypeUpdated(t){const{groupID:s,messageRemindType:o}=t;Ie.l(`${this._n}.onGroupMessageRemindTypeUpdated groupID:${s} messageRemindType:${o}`);const i=this._getModule(ds).getLocalGroupProfile(s);if(i&&(i.selfInfo.messageRemindType=o),Qe(s)){const t=s,i=ht(t),n=this._getModule(ps).getLocalTopic(i,t);return n&&(n.updateSelfInfo({messageRemindType:o}),this._conversationModule.emitOuterEvent(e.TOPIC_UPDATED,{groupID:i,topic:n})),{topic:n}}return this._conversationModule.patchMessageRemindType({ID:s,isC2CConversation:!1,messageRemindType:o})&&this._emitConversationUpdate(),{group:i}}_setC2CMessageRemindType(e){const s=this._n+"._setC2CMessageRemindType",{userIDList:o,messageRemindType:i}=e,n=o.slice(0,30);let r=0;i===t.MSG_REMIND_DISCARD?r=1:i===t.MSG_REMIND_ACPT_NOT_NOTE&&(r=2);const a=`userIDList:${n} messageRemindType:${i}`,c=new no("setMessageRemindType");return c.setMessage(a),this._conversationModule.request({protocolName:Ks.SET_C2C_PEER_MUTE_NOTIFICATIONS,requestData:{userIDList:n,muteFlag:r}}).then(e=>{c.setNetworkType(this._conversationModule.getNetworkType()).end();const{errorList:t}=e.data,o=[],r=[];Ue(t)&&t.forEach(e=>{o.push(e.userID),r.push({userID:e.userID,code:e.errorCode})});const u=n.filter(e=>-1===o.indexOf(e));Ie.l(`${s} ok. ${a} successUserIDList:${u} failureUserIDList:${JSON.stringify(r)}`);let l=0;return u.forEach(e=>{this._conversationModule.patchMessageRemindType({ID:e,isC2CConversation:!0,messageRemindType:i})&&(l+=1)}),l>=1&&this._emitConversationUpdate(),n.length=o.length=0,this._conversationModule.emitTotalUnreadMessageCountUpdate(),xs({successUserIDList:u.map(e=>({userID:e})),failureUserIDList:r})}).catch(e=>(this._conversationModule.probeNetwork().then(([t,s])=>{c.setError(e,t,s).end()}),Ie.e(s+" failed. error:",e),Vs(e)))}_getModule(e){return this._conversationModule.getModule(e)}_emitConversationUpdate(){this._conversationModule.emitConversationUpdate(!0,!1)}reset(){Ie.l(this._n+".reset")}}class xo{constructor(e){this._conversationModule=e,this._n="ConvGroupHandler",this._convGroupMap=new Map,this._startIndex=0,this._pagingStatus=vt.NOT_START}setConvCustomData(e){const s=this._n+".setConvCustomData",{conversationIDList:o,customData:i}=e;Ie.l(s+" options:",e);const n=new no("setConvCustomData");n.setMessage(JSON.stringify(e));const r={fromAccount:this._getMyUserID(),itemList:[]},a=[],c=[];return o.forEach(e=>{if(!this._hasLocalConversation(e))return this._onConversationNotFound(c,e),!0;if(!Ze(e)&&!et(e))return this._onConversationIDInvalid(c,e),!0;const s={operationType:2,contactItem:void 0,customMark:i};Ze(e)?s.contactItem={type:1,toAccount:e.replace(t.CONV_C2C,"")}:et(e)&&(s.contactItem={type:2,groupID:e.replace(t.CONV_GROUP,"")}),r.itemList.push(s)}),c.length===o.length?xs({successConversationIDList:a,failureConversationIDList:c}):this._conversationModule.request({protocolName:Ks.SET_CONVERSATION_CUSTOM_DATA,requestData:r}).then(e=>{n.setNetworkType(this._conversationModule.getNetworkType()).end(),Ie.l(s+" ok");const{resultItem:t}=e.data;if(Ue(t)){let e,s,o=!1;t.forEach(t=>{e=this._concatConversationID(t.contactItem),0===t.resultCode?(a.push(e),s=this._getLocalConversation(e),s&&s.customData!==i&&(s.customData=i,o=!0)):c.push({conversationID:e,code:t.resultCode,message:t.resultInfo})}),!0===o&&this._emitConversationUpdate()}return ws({successConversationIDList:a,failureConversationIDList:c})}).catch(e=>(this._conversationModule.probeNetwork().then(([t,s])=>{n.setError(e,t,s).end()}),Ie.e(s+" failed. error:",e),Vs(e)))}markConversation(e){if(!this._conversationModule.canIUse(I.CONV_MARK))return this._conversationModule.cannotUseCommercialAbility("markConversation");const s=this._n+".markConversation",{conversationIDList:o,markType:i,enableMark:n}=e;Ie.l(s+" options:",e);const r=new no("markConversation");r.setMessage(JSON.stringify(e));let a=void 0,c=void 0;const u=this._getFlagBit(i);!0===n?c=[u]:a=[u];const l={fromAccount:this._getMyUserID(),itemList:[]},d=[],_=[];return o.forEach(e=>{if(!this._hasLocalConversation(e))return this._onConversationNotFound(_,e),!0;if(!Ze(e)&&!et(e))return this._onConversationIDInvalid(_,e),!0;const s={operationType:1,contactItem:void 0,clearMark:a,setMark:c};Ze(e)?s.contactItem={type:1,toAccount:e.replace(t.CONV_C2C,"")}:et(e)&&(s.contactItem={type:2,groupID:e.replace(t.CONV_GROUP,"")}),l.itemList.push(s)}),_.length===o.length?xs({successConversationIDList:d,failureConversationIDList:_}):this._conversationModule.request({protocolName:Ks.MARK_CONVERSATION,requestData:l}).then(e=>{r.setNetworkType(this._conversationModule.getNetworkType()).end(),Ie.l(s+" ok");const{resultItem:t}=e.data;if(Ue(t)){let e,s,o=!1;t.forEach(t=>{if(e=this._concatConversationID(t.contactItem),0===t.resultCode){if(d.push(e),s=this._getLocalConversation(e),s){const e=s.markList.indexOf(i);!0===n?-1===e&&(s.markList.push(i),o=!0):-1!==e&&(s.markList.splice(e,1),o=!0)}}else _.push({conversationID:e,code:t.resultCode,message:t.resultInfo})}),!0===o&&this._emitConversationUpdate()}return ws({successConversationIDList:d,failureConversationIDList:_})}).catch(e=>(this._conversationModule.probeNetwork().then(([t,s])=>{r.setError(e,t,s).end()}),Ie.e(s+" failed. error:",e),Vs(e)))}getLocalConvGroupList(){return Ie.l(`${this._n}.getLocalConvGroupList pagingStatus:${this._pagingStatus}`),this._pagingStatus===vt.REJECTED?this.getRemoteConvGroupList().then(()=>ws([...this._convGroupMap.values()])):xs([...this._convGroupMap.values()])}getRemoteConvGroupList(){const e=this._n+".getRemoteConvGroupList";return this._pagingStatus=vt.PENDING,this._conversationModule.request({protocolName:Ks.GET_CONVERSATION_GROUP_LIST,requestData:{fromAccount:this._getMyUserID(),startIndex:this._startIndex,startTime:he()}}).then(t=>{const{completeFlag:s,contactItem:o,nextStartIndex:i=0,groupItem:n}=t.data;if(this._startIndex=i,Ie.l(`${e} completeFlag:${s} nextStartIndex:${i}`),Ue(n)&&n.forEach(e=>{const{convGroupID:t,groupName:s}=e;this._convGroupMap.set(t,s)}),Ue(o)){let e,t;o.forEach(s=>{const{standardMark:o,customData:i,convGroupIDList:n}=s;if(e=this._concatConversationID(s),t=this._getLocalConversation(e),t&&(t.markList=mt(o),t.customData=i||"",Ue(n))){const e=[];n.forEach(t=>{this._convGroupMap.has(t)&&e.push(this._convGroupMap.get(t))}),t.conversationGroupList=[...e],e.length=0}})}if(0===s)return this.getRemoteConvGroupList();1===s&&(this._pagingStatus=vt.RESOLVED,this._emitConversationUpdate(),this._emitConvGroupListUpdate())}).catch(t=>{this._pagingStatus=vt.REJECTED,Ie.w(e+" failed. error:",t)})}createConvGroup(e){const s="createConversationGroup";if(!this._conversationModule.canIUse(I.CONV_GROUP))return this._conversationModule.cannotUseCommercialAbility(s);const o=`${this._n}.${s}`;Ie.l(o+" options:",e);const i=new no(s);i.setMessage(JSON.stringify(e));const{groupName:n,conversationIDList:r}=e,a={fromAccount:this._getMyUserID(),itemList:[{groupName:n,contactItem:[]}]},c=[],u=[];return r.forEach(e=>this._hasLocalConversation(e)?Ze(e)||et(e)?void(Ze(e)?a.itemList[0].contactItem.push({type:1,toAccount:e.replace(t.CONV_C2C,"")}):et(e)&&a.itemList[0].contactItem.push({type:2,groupID:e.replace(t.CONV_GROUP,"")})):(this._onConversationIDInvalid(u,e),!0):(this._onConversationNotFound(u,e),!0)),u.length===r.length?xs({successConversationIDList:c,failureConversationIDList:u}):this._conversationModule.request({protocolName:Ks.CREATE_CONVERSATION_GROUP,requestData:a}).then(e=>{i.setNetworkType(this._conversationModule.getNetworkType()).end(),Ie.l(o+" ok");const{groupResultItem:t}=e.data,{groupItem:s,resultItem:r}=t[0];if(Le(s)&&(this._convGroupMap.set(s.convGroupID,s.groupName),this._emitConvGroupListUpdate()),Ue(r)){let e,t,s=!1;r.forEach(o=>{e=this._concatConversationID(o.contactItem),0===o.resultCode?(c.push(e),t=this._getLocalConversation(e),t&&-1===t.conversationGroupList.indexOf(n)&&(t.conversationGroupList.push(n),s=!0)):u.push({conversationID:e,code:o.resultCode,message:o.resultInfo})}),!0===s&&(this._emitConversationUpdate(),this._emitConvGroupListUpdate())}return ws({successConversationIDList:c,failureConversationIDList:u})}).catch(e=>(this._conversationModule.probeNetwork().then(([t,s])=>{i.setError(e,t,s).end()}),Ie.e(o+" failed. error:",e),Vs(e)))}deleteConvGroup(e){const t="deleteConversationGroup";if(!this._conversationModule.canIUse(I.CONV_GROUP))return this._conversationModule.cannotUseCommercialAbility(t);const s=`${this._n}.${t}`;Ie.l(`${s} groupName:${e}`);const o=new no(t);return o.setMessage(e),this._conversationModule.request({protocolName:Ks.DELETE_CONVERSATION_GROUP,requestData:{fromAccount:this._getMyUserID(),groupName:[e]}}).then(t=>{o.setNetworkType(this._conversationModule.getNetworkType()).end(),Ie.l(s+" ok");const{groupItem:i}=t.data;if(Ue(i)){let e=!1;i.forEach(t=>{this._convGroupMap.has(t.convGroupID)&&(this._convGroupMap.delete(t.convGroupID),e=!0)}),!0===e&&this._emitConvGroupListUpdate()}this._eraseFromConversationGroupList([e])}).catch(e=>(this._conversationModule.probeNetwork().then(([t,s])=>{o.setError(e,t,s).end()}),Ie.e(s+" failed. error:",e),Vs(e)))}renameConvGroup(e){const t="renameConversationGroup";if(!this._conversationModule.canIUse(I.CONV_GROUP))return this._conversationModule.cannotUseCommercialAbility(t);const s=`${this._n}.${t}`;Ie.l(s+" options:",e);const o=new no(t);o.setMessage(JSON.stringify(e));const{oldName:i,newName:n}=e;return this._conversationModule.request({protocolName:Ks.RENAME_CONVERSATION_GROUP,requestData:{fromAccount:this._getMyUserID(),updateType:1,updateGroup:{updateGroupType:1,oldName:i,newName:n}}}).then(e=>{o.setNetworkType(this._conversationModule.getNetworkType()).end(),Ie.l(s+" ok");const{updateGroupResult:t}=e.data,{convGroupID:r}=t;this._convGroupMap.set(r,n),this._emitConvGroupListUpdate();const a=this._conversationModule.getLocalConversationList();let c,u,l=!1;a.forEach(e=>{c=e.conversationGroupList,u=c.indexOf(i),-1!==u&&(c.splice(u,1,n),l=!0)}),!0===l&&this._emitConversationUpdate()}).catch(e=>(this._conversationModule.probeNetwork().then(([t,s])=>{o.setError(e,t,s).end()}),Ie.e(s+" failed. error:",e),Vs(e)))}addConvsToGroup(e){const s="addConversationsToGroup";if(!this._conversationModule.canIUse(I.CONV_GROUP))return this._conversationModule.cannotUseCommercialAbility(s);const o=`${this._n}.${s}`;Ie.l(o+" options:",e);const i=new no(s);i.setMessage(JSON.stringify(e));const{conversationIDList:n,groupName:r}=e,a={fromAccount:this._getMyUserID(),updateType:1,updateGroup:{updateGroupType:2,groupName:r,updateItem:[]}},c=[],u=[];return n.forEach(e=>this._hasLocalConversation(e)?Ze(e)||et(e)?void(Ze(e)?a.updateGroup.updateItem.push({operationType:1,contactItem:{type:1,toAccount:e.replace(t.CONV_C2C,"")}}):et(e)&&a.updateGroup.updateItem.push({operationType:1,contactItem:{type:2,groupID:e.replace(t.CONV_GROUP,"")}})):(this._onConversationIDInvalid(u,e),!0):(this._onConversationNotFound(u,e),!0)),u.length===n.length?xs({successConversationIDList:c,failureConversationIDList:u}):this._conversationModule.request({protocolName:Ks.ADD_CONVERSATIONS_TO_GROUP,requestData:a}).then(e=>{i.setNetworkType(this._conversationModule.getNetworkType()).end(),Ie.l(o+" ok");const{contactResultItem:t}=e.data.updateGroupResult;if(Ue(t)){let e,s,o=!1;t.forEach(t=>{e=this._concatConversationID(t.contactItem),0===t.resultCode?(s=this._getLocalConversation(e),s&&-1===s.conversationGroupList.indexOf(r)&&(s.conversationGroupList.push(r),c.push(e),o=!0)):u.push({conversationID:e,code:t.resultCode,message:t.resultInfo})}),!0===o&&(this._emitConversationUpdate(),this._emitConvInGroupUpdate(r))}return ws({successConversationIDList:c,failureConversationIDList:u})}).catch(e=>(this._conversationModule.probeNetwork().then(([t,s])=>{i.setError(e,t,s).end()}),Ie.e(o+" failed. error:",e),Vs(e)))}deleteConvsFromGroup(e){const s="deleteConversationsFromGroup";if(!this._conversationModule.canIUse(I.CONV_GROUP))return this._conversationModule.cannotUseCommercialAbility(s);const o=`${this._n}.${s}`;Ie.l(o+" options:",e);const i=new no(s);i.setMessage(JSON.stringify(e));const{conversationIDList:n,groupName:r}=e,a={fromAccount:this._getMyUserID(),updateType:1,updateGroup:{updateGroupType:2,groupName:r,updateItem:[]}},c=[],u=[];return n.forEach(e=>this._hasLocalConversation(e)?Ze(e)||et(e)?void(Ze(e)?a.updateGroup.updateItem.push({operationType:2,contactItem:{type:1,toAccount:e.replace(t.CONV_C2C,"")}}):et(e)&&a.updateGroup.updateItem.push({operationType:2,contactItem:{type:2,groupID:e.replace(t.CONV_GROUP,"")}})):(this._onConversationIDInvalid(u,e),!0):(this._onConversationNotFound(u,e),!0)),u.length===n.length?xs({successConversationIDList:c,failureConversationIDList:u}):this._conversationModule.request({protocolName:Ks.DELETE_CONVERSATIONS_FROM_GROUP,requestData:a}).then(e=>{i.setNetworkType(this._conversationModule.getNetworkType()).end(),Ie.l(o+" ok");const{contactResultItem:t}=e.data.updateGroupResult;if(Ue(t)){let e,s,o=!1;t.forEach(t=>{if(e=this._concatConversationID(t.contactItem),0===t.resultCode){if(s=this._getLocalConversation(e),s){const t=s.conversationGroupList.indexOf(r);-1!==t&&(s.conversationGroupList.splice(t,1),c.push(e),o=!0)}}else u.push({conversationID:e,code:t.resultCode,message:t.resultInfo})}),!0===o&&(this._emitConversationUpdate(),this._emitConvInGroupUpdate(r))}return ws({successConversationIDList:c,failureConversationIDList:u})}).catch(e=>(this._conversationModule.probeNetwork().then(([t,s])=>{i.setError(e,t,s).end()}),Ie.e(o+" failed. error:",e),Vs(e)))}onConvMarkUpdated(e){if(St(e))return;let t,s;Ie.d(this._n+".onConvMarkUpdated markItemList:",e);let o=!1;e.forEach(e=>{const{recentContactItem:i,optType:n,standardMark:r,customMark:a}=e;t=this._concatConversationID(i),s=this._getLocalConversation(t),s&&(1===n?o=this._diffStandardMark(s,r):2===n?o=this._diffCustomMark(s,a):3===n&&(o=this._diffStandardMark(s,r)||this._diffCustomMark(s,a)))}),!0===o&&this._emitConversationUpdate()}_diffStandardMark(e,t){const s=mt(t);let o=!1;return!0!==function(e,t){if(e===t)return!0;if(!e||!t)return!1;if(e.length!==t.length)return!1;for(let s=0,o=e.length;s<o;s++)if(e[s]!==t[s])return!1;return!0}(e.markList,s)&&(e.markList=s,o=!0),o}_diffCustomMark(e,t){let s=!1;return e.customData!==t&&void 0!==t&&(e.customData=t,s=!0),s}onConvGroupCreated(e){Ie.d(this._n+".onConvGroupCreated resultList:",e);let t=!1,s=!1;Ue(e)&&(e.forEach(e=>{const{groupID:o,groupName:i}=e.msgGroupItem;this._convGroupMap.get(o)!==i&&(this._convGroupMap.set(o,i),s=!0);const n=e.msgRecentContactItem;if(Ue(n)){let e,s;n.forEach(o=>{e=this._concatConversationID(o),s=this._getLocalConversation(e),s&&-1===s.conversationGroupList.indexOf(i)&&(s.conversationGroupList.push(i),t=!0)})}}),!0===t&&this._emitConversationUpdate(),!0===s&&this._emitConvGroupListUpdate())}onConvGroupDeleted(e){Ie.d(this._n+".onConvGroupDeleted groupItemList:",e);const t=[];if(Ue(e)){let s=!1;e.forEach(e=>{const{groupID:o,groupName:i}=e;this._convGroupMap.has(o)&&(this._convGroupMap.delete(o),s=!0,t.push(i))}),!0===s&&this._emitConvGroupListUpdate()}this._eraseFromConversationGroupList(t)}_eraseFromConversationGroupList(e){if(St(e))return;this._conversationModule.getLocalConversationList().forEach(t=>{t.conversationGroupList=t.conversationGroupList.filter(t=>!e.includes(t))}),this._emitConversationUpdate()}onConvGroupNameUpdated(e){Ie.d(this._n+".onConvGroupNameUpdated options:",e);const{groupID:t,groupName:s,oldGroupName:o}=e;if(this._convGroupMap.get(t)===s)return;this._convGroupMap.set(t,s),this._emitConvGroupListUpdate();const i=this._conversationModule.getLocalConversationList();let n,r,a=!1;i.forEach(e=>{n=e.conversationGroupList,r=n.indexOf(o),-1!==r&&(n.splice(r,1,s),a=!0)}),!0===a&&this._emitConversationUpdate()}onConvInGroupUpdated(e){Ie.d(this._n+".onConvInGroupUpdated options:",e);const{oldGroupName:t,recentContactUpdateGroupItem:s}=e;if(Ue(s)){let e,o,i,n=!1;s.forEach(s=>{const{contactOptType:r,recentContactItem:a}=s;e=this._concatConversationID(a),o=this._getLocalConversation(e),o&&(i=o.conversationGroupList.indexOf(t),1===r?-1===i&&(o.conversationGroupList.push(t),n=!0):2===r&&-1!==i&&(o.conversationGroupList.splice(i,1),n=!0))}),!0===n&&(this._emitConversationUpdate(),this._emitConvInGroupUpdate(t))}}onConvAddedToOrDeletedFromGroup(e){Ie.d(this._n+".onConvAddedToOrDeletedFromGroup options:",e);const{msgRecentContactItem:t,msgRecentContactUpdateContactItem:s}=e,o=this._concatConversationID(t),i=this._getLocalConversation(o);if(i&&Ue(s)){let e,t=!1;s.forEach(s=>{const{groupOptType:o,recentContactGroupItem:n}=s,{groupName:r}=n;e=i.conversationGroupList.indexOf(r),1===o?-1===e&&(i.conversationGroupList.push(r),t=!0):2===o&&-1!==e&&(i.conversationGroupList.splice(e,1),t=!0),!0===t&&this._emitConvInGroupUpdate(r)}),!0===t&&this._emitConversationUpdate()}}onConvGroupListSynced(e){Ue(e)&&0!==e.length&&(Ie.l(this._n+".onConvGroupListSynced groupItemList:",e),e.forEach(e=>{this._convGroupMap.set(e.convGroupID,e.groupName)}))}getConvGroupListByID(e){if(St(e))return;const t=[];return e.forEach(e=>{this._convGroupMap.has(e)&&t.push(this._convGroupMap.get(e))}),t}_onConversationNotFound(e,t){e.push({conversationID:t,code:$s.CONV_NOT_FOUND,message:this._conversationModule.getErrorMessage($s.CONV_NOT_FOUND)})}_onConversationIDInvalid(e,t){e.push({conversationID:t,code:$s.INVALID_CONV_ID,message:this._conversationModule.getErrorMessage($s.INVALID_CONV_ID)})}_getFlagBit(e){const t=e.toString(2),s=t.length;for(let o=s-1;o>=0;o--)if("1"===t[o])return s-o-1}_concatConversationID(e){const{type:s,to:o,groupID:i,userID:n}=e;let r;return 1===s?Pe(n)?Pe(o)||(r=`${t.CONV_C2C}${o}`):r=`${t.CONV_C2C}${n}`:2===s&&(r=`${t.CONV_GROUP}${i}`),r}_getMyUserID(){return this._conversationModule.getMyUserID()}_insertConversationGroup(e,t){const s=this._getLocalConversation(e);if(s){const e=s.conversationGroupList;-1===e.indexOf(t)&&e.push(t)}}_getLocalConversation(e){return this._conversationModule.getLocalConversation(e)}_hasLocalConversation(e){return this._conversationModule.hasLocalConversation(e)}_emitConversationUpdate(){this._conversationModule.emitConversationUpdate(!0,!1)}_emitConvGroupListUpdate(){this._conversationModule.emitOuterEvent(e.CONVERSATION_GROUP_LIST_UPDATED,[...this._convGroupMap.values()])}_emitConvInGroupUpdate(t){const s={groupName:t,conversationList:[]},o=this._conversationModule.getLocalConversationList();s.conversationList=o.filter(e=>e.conversationGroupList.includes(t)),this._conversationModule.emitOuterEvent(e.CONVERSATION_IN_GROUP_UPDATED,s)}reset(){Ie.l(this._n+".reset"),this._convGroupMap.clear(),this._startIndex=0,this._pagingStatus=vt.NOT_START}}class Vo extends Bs{constructor(e){super(e),this._n="ConversationModule",No.mixin(this),this._messageListHandler=new yo,this._messageRemindHandler=new qo(this),this._convGroupHandler=new xo(this),this.singlyLinkedList=new ko(100),this._pagingStatus=vt.NOT_START,this._pagingTimeStamp=0,this._pagingStartIndex=0,this._pagingPinnedTimeStamp=0,this._pagingPinnedStartIndex=0,this._pagingConvIDMap=new Map,this._convIDFromUnreadDBMap=new Map,this._conversationMap=new Map,this._tmpGroupList=[],this._tmpGroupAtTipsList=[],this._peerReadTimeMap=new Map,this._completedMap=new Map,this._roamingMessageKeyAndTimeMap=new Map,this._roamingMessageSequenceMap=new Map,this._remoteGroupReadSequenceMap=new Map,this._convTotalUnreadCount=0,this._pagingGetCostList=[],this._initListeners()}_initListeners(){const e=this.getInnerEmitterInstance();e.on(Do.A2KEY_AND_TINYID_UPDATED,this._init,this),e.on(Do.PROFILE_UPDATED,this._onProfileUpdated,this)}onCheckTimer(e){e%60==0&&this._messageListHandler.traversal()}_init(){Ie.l(this._n+"._init");const e=this.getModule(ms).getItem("conversationMap"),t=this.isIntl(),s=this.isUsingChatCore();if(e){const o=e.length;for(let i=0;i<o;i++){const o=e[i];if(o){if(this._isNonExistentAccount(o.conversationID))continue;if(o.groupProfile){const e=o.groupProfile.type;if(Je(e))continue}}this._conversationMap.set(o.conversationID,new bo(e[i],t,s))}this.emitConversationUpdate(!0,!1)}this.ready(()=>{this._tmpGroupList.length>0&&(this.updateConversationGroupProfile(this._tmpGroupList),this._tmpGroupList.length=0)}),this.syncConversationList()}_isNonExistentAccount(e){let s;return e.startsWith(t.CONV_C2C)&&(s=e.replace(t.CONV_C2C,"")),"@TLS#ERROR"===s||"@TLS#NOT_FOUND"===s}onMessageSent(e){this._onSendOrReceiveMessage({conversationOptionsList:e.conversationOptionsList,isInstantMessage:!0})}onNewMessage(e){this._onSendOrReceiveMessage(e)}_onSendOrReceiveMessage(e){const{conversationOptionsList:s,isInstantMessage:o=!0,isUnreadC2CMessage:i=!1,updateUnreadCount:n=!0,isSyncingEnded:r=!1}=e;if(!this._isReady)return void this.ready(()=>{this._onSendOrReceiveMessage(e)});if(0===s.length)return void(r&&this.emitInnerEvent(Do.C2C_UNREAD_HANDLE_COMPLETED));!0===o&&this._checkNewConversation(s),this._updateLocalConversationList({conversationOptionsList:s,isInstantMessage:o,isUnreadC2CMessage:i,isFromGetConversations:!1,updateUnreadCount:n}),o||(this._convIDFromUnreadDBMap=new Map([...this._convIDFromUnreadDBMap,...s.map(e=>[e.conversationID,1])]),this._diffAndDeleteConversation(),r&&this.emitInnerEvent(Do.C2C_UNREAD_HANDLE_COMPLETED));s.filter(e=>e.type===t.CONV_TOPIC).length>0||this.emitConversationUpdate()}updateConversationGroupProfile(e){if(Ue(e)&&0===e.length)return;if(0===this._conversationMap.size)return void(this._tmpGroupList=e);let t=!1;e.forEach(e=>{const s="GROUP"+e.groupID;if(this._conversationMap.has(s)){t=!0;const o=this._conversationMap.get(s);o.groupProfile=JSON.parse(JSON.stringify(e)),o.lastMessage.lastSequence<e.nextMessageSeq&&(o.lastMessage.lastSequence=e.nextMessageSeq-1),o.subType||(o.subType=e.type)}}),t&&this.emitConversationUpdate(!0,!1)}_updateConversationUserProfile({data:e}){e.forEach(e=>{const t="C2C"+e.userID;this._conversationMap.has(t)&&(this._conversationMap.get(t).userProfile=e)}),this.emitConversationUpdate(!0,!1)}onMessageRevoked(e){if(0===e.length)return;let s=null,o=!1;const i=[];e.forEach(e=>{s=this._conversationMap.get(e.conversationID),s&&(s.type===t.CONV_TOPIC?i.push(e):(s.reduceUnreadCount()&&(o=!0),s.isLastMessageRevoked({sequence:e.sequence,time:e.time})&&(s.setLastMessageRevoked(!0),s.setLastMessageRevoker(e.revoker),o=!0)))});this.getModule(ps).onMessageRevoked(i),o&&(this.emitConversationUpdate(!0,!1),this.emitTotalUnreadMessageCountUpdate())}updateRevokerInfo(e){const t=new Set;for(let i=0;i<e.length;i++){const{revoker:s}=e[i];t.add(s)}const s=[...t],o=this.getModule(us);return new Promise(t=>{o.getUserProfile({userIDList:s}).then(s=>{const{data:o}=s;if(!Ue(o)||0===o.length)return t(e);const i={};for(const{userID:e,nick:t,avatar:n}of o)i[e]={nick:t,avatar:n};e.forEach(e=>{const{revoker:t}=e;i[t]&&(e.revokerInfo.nick=i[t].nick||"",e.revokerInfo.avatar=i[t].avatar||"")}),t(e)}).catch(()=>{t(e)})})}isLastMessageRevoked(e){let s=!1;const{conversationID:o,sequence:i,time:n}=e,r=this._conversationMap.get(o);if(r)if(r.type===t.CONV_TOPIC){s=this.getModule(ps).isLastMessageRevoked({topicID:o.replace(t.CONV_GROUP,""),sequence:i})}else s=r.isLastMessageRevoked({sequence:i,time:n});return Ie.l(`${this._n}.isLastMessageRevoked options:${JSON.stringify(e)} ret:${s}`),s}onMessageDeleted(e){if(0===e.length)return;let s=null;e.forEach(e=>{s=this._messageListHandler.getLocalMessage(e.conversationID,e.ID),s&&(s.isDeleted=!0),e!==s&&(e.isDeleted=!0)});const o=e[0].conversationID,i=this._messageListHandler.getLocalMessageList(o);let n={};for(let t=i.length-1;t>=0;t--)if(!i[t].isDeleted){n=i[t];break}const r=this._conversationMap.get(o);if(!r)return;let a=!1;r.lastMessage.lastSequence===n.sequence&&r.lastMessage.lastTime===n.time||(St(n)&&(n=void 0),r.updateLastMessage(n),r.type!==t.CONV_TOPIC&&(a=!0),Ie.l(`${this._n}.onMessageDeleted. update conversationID:${o} with lastMessage:`,r.lastMessage)),o.startsWith(t.CONV_C2C)&&this.updateUnreadCount(o),a&&this.emitConversationUpdate(!0,!1)}onMessageModified(s){const o=this._n+".onMessageModified",{conversationType:i,from:n,to:r,time:a,sequence:c,elements:u,cloudCustomData:l,messageVersion:d}=s;let _=`${i}${r}`;r===this.getMyUserID()&&i===t.CONV_C2C&&(_=`${i}${n}`);const{isUpdated:p,message:h}=this._messageListHandler.onMessageModified(_,s);!0===p&&this.emitOuterEvent(e.MESSAGE_MODIFIED,[h]);const g=this._isTopicConversation(_);if(null===h?Ie.l(`${o} message is null! options:${JSON.stringify(s)}}`):Ie.l(`${o} isUpdated:${p} isTopicMessage:${g} from:${n} to:${r} sequence:${h.sequence} time:${h.time}`),g){this.getModule(ps).onMessageModified(s)}else{const e=this._conversationMap.get(_);if(e){const t=e.lastMessage;t&&t.lastTime===a&&t.lastSequence===c&&t.version!==d&&(Ie.l(`${o} conversationID:${_} lastMessage updated`),t.type=u[0].type,t.payload=u[0].content,t.messageForShow=gt(t.type,t.payload,this.isIntl()),t.cloudCustomData=l,t.version=d,this.emitConversationUpdate(!0,!1))}}return h}onNewGroupAtTips(e){const t=e.dataList;let s=null;t.forEach(e=>{e.groupAtTips?s=e.groupAtTips:e.elements?s={...e.elements,sync:!0}:e.groupAtType&&(s={...e,sync:!0}),s.__random=e.random,s.__sequence=e.clientSequence,this._tmpGroupAtTipsList.push(s)}),Ie.d(`${this._n}.onNewGroupAtTips isReady:${this._isReady}`,this._tmpGroupAtTipsList),this._isReady&&this._handleGroupAtTipsList()}_handleGroupAtTipsList(){if(0===this._tmpGroupAtTipsList.length)return;let e=!1;this._tmpGroupAtTipsList.forEach(s=>{const{groupID:o,from:i,topicID:n,sync:r=!1}=s;if(i!==this.getMyUserID())if(Pe(n)){const i=this._conversationMap.get(`${t.CONV_GROUP}${o}`);i&&(i.updateGroupAtInfoList(s),e=!0)}else{const e=this._conversationMap.get(`${t.CONV_GROUP}${n}`);if(e){e.updateGroupAtInfoList(s);const t=this.getModule(ps),{groupAtInfoList:o}=e;t.onConversationProxy({topicID:n,groupAtInfoList:o})}if(St(e)&&r){this.updateTopicConversation([{conversationID:`${t.CONV_GROUP}${n}`,type:t.CONV_TOPIC}]);this._conversationMap.get(`${t.CONV_GROUP}${n}`).updateGroupAtInfoList(s)}}}),e&&this.emitConversationUpdate(!0,!1),this._tmpGroupAtTipsList.length=0}_checkNewConversation(e){let s=[],o=[];e.forEach(e=>{this._conversationMap.has(e.conversationID)||(e.type===t.CONV_C2C?s.push(e.conversationID.replace(t.CONV_C2C,"")):e.type===t.CONV_GROUP&&o.push(e.conversationID.replace(t.CONV_GROUP,"")))}),s.length>0&&(this._onNewC2CConversation(s),s=null),o.length>0&&(this._onNewGroupConversation(o),o=null)}_onNewC2CConversation(e){this.getModule(ls).getRemotePeerReadTime(e),this._messageRemindHandler.getC2CMessageRemindType(e)}_onNewGroupConversation(e){const t=this.getModule(ds);t&&t.getMessageRemindType(e)}_setStorageConversationList(e=!1){const s=this.getLocalConversationList().filter(e=>e.type===t.CONV_C2C||e.type===t.CONV_GROUP&&e.lastMessage.type!==t.MSG_GRP_TIP).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(ms).setItem("conversationMap",s,e)}emitConversationUpdate(t=!0,s=!0){const o=this.getLocalConversationList();if(s){const e=this.getModule(ds);e&&e.updateGroupLastMessage(o)}t&&this.emitOuterEvent(e.CONVERSATION_LIST_UPDATED)}getLocalConversationList(){return[...this._conversationMap.values()].filter(e=>e.type!==t.CONV_TOPIC)}getLocalConversation(e){return this._conversationMap.get(e)}hasLocalConversation(e){return this._conversationMap.has(e)}getLocalOldestMessage(e){return this._messageListHandler.getLocalOldestMessage(e)}syncConversationList(e=!0){const t=new no("syncConversationList");return this._pagingStatus===vt.NOT_START&&this._conversationMap.clear(),this._pagingGetConversationList(e).then(e=>{const s=function(e){if(!Ue(e)||0===e.length)return;let t=0;return e.forEach(e=>{t+=e}),(t/e.length).toFixed(0)}(this._pagingGetCostList),o=function(e){if(!Ue(e)||0===e.length)return;let t=0;return e.forEach(e=>{t+=e}),t.toFixed(0)}(this._pagingGetCostList);this._pagingGetCostList.length=0,this._pagingStatus=vt.RESOLVED,this._diffAndDeleteConversation(),this.emitConversationUpdate(!0,!1),this._setStorageConversationList(),this._handleC2CPeerReadTime(),this.emitInnerEvent(Do.CONV_SYNC_COMPLETED);const i=`count:${this._conversationMap.size} sum:${o} avg:${s}`;return Ie.l(`${this._n}.syncConversationList. ${i}`),t.setMessage(i).setNetworkType(this.getNetworkType()).end(),e}).catch(e=>(this._pagingStatus=vt.REJECTED,t.setMessage(this._pagingTimeStamp),this.probeNetwork().then(([s,o])=>{t.setError(e,s,o).end()}),Vs(e)))}_diffAndDeleteConversation(){if(this._isSyncCompleted()){let e=[];this._conversationMap.forEach((t,s)=>{!this._pagingConvIDMap.has(s)&&this._convIDFromUnreadDBMap.has(s)&&(this._conversationMap.delete(s),e.push(s))}),Ie.l(`${this._n}._diffAndDeleteConversation list:${e}`),e=null}}_pagingGetConversationList(e=!0){const t=this._n+"._pagingGetConversationList";Ie.l(`${t} incrementalPullFlag:${e} timeStamp:${this._pagingTimeStamp} startIndex:${this._pagingStartIndex} pinnedTimeStamp:${this._pagingPinnedTimeStamp} pinnedStartIndex:${this._pagingPinnedStartIndex}`);const s=Date.now();return this._pagingStatus=vt.PENDING,this.request({protocolName:Ks.PAGING_GET_CONVERSATION_LIST,requestData:{fromAccount:this.getMyUserID(),timeStamp:e?this._pagingTimeStamp:0,startIndex:e?this._pagingStartIndex:0,pinnedTimeStamp:e?this._pagingPinnedTimeStamp:0,pinnedStartIndex:e?this._pagingPinnedStartIndex:0,orderType:1}}).then(e=>{const{completeFlag:o,conversations:i=[],timeStamp:n,startIndex:r,pinnedTimeStamp:a,pinnedStartIndex:c,groupItem:u}=e.data;if(this._pagingGetCostList.push(Tt(s,!1)),Ie.l(`${t} ok. completeFlag:${o} count:${i.length} cost:${Tt(s)}`),this._convGroupHandler.onConvGroupListSynced(u),i.length>0){const e=this._getConversationOptions(i);this._pagingConvIDMap=new Map([...this._pagingConvIDMap,...e.map(e=>[e.conversationID,1])]),this._updateLocalConversationList({conversationOptionsList:e,isFromGetConversations:!0,updateUnreadCount:!0}),this.isLoggedIn()&&this.emitConversationUpdate()}if(!this._isReady){if(!this.isLoggedIn())return xs();this.triggerReady()}return this._pagingTimeStamp=n,this._pagingStartIndex=r,this._pagingPinnedTimeStamp=a,this._pagingPinnedStartIndex=c,1!==o?this._pagingGetConversationList():(this._handleGroupAtTipsList(),this._convGroupHandler.getRemoteConvGroupList(),xs())}).catch(e=>{throw this.isLoggedIn()&&(this._isReady||(Ie.w(t+" failed. error:",e),this.triggerReady())),e})}_updateLocalConversationList(e){const{isFromGetConversations:t,isInstantMessage:s}=e,o=Date.now();let i={toBeUpdatedConversationList:[],newConversationList:[]};i=this._getTmpConversationListMapping(e),this._conversationMap=new Map(this._sortConversationList([...i.toBeUpdatedConversationList,...this._conversationMap])),t||(this._updateUserOrGroupProfile(i.newConversationList),s&&this.emitTotalUnreadMessageCountUpdate()),Ie.l(`${this._n}._updateLocalConversationList cost:${Tt(o)}`)}_getTmpConversationListMapping(e){const{conversationOptionsList:s,isFromGetConversations:o,isInstantMessage:i,isUnreadC2CMessage:n=!1,updateUnreadCount:r}=e,a=[],c=[],u=this.getModule(ds),l=this.getModule(_s),d=this.isIntl(),_=this.isUsingChatCore();for(let g=0,m=s.length;g<m;g++){const e=new bo(s[g],d,_),{conversationID:p}=e;if(!this._isNonExistentAccount(p))if(this._conversationMap.has(p)){const c=this._conversationMap.get(p),u=["unreadCount","allowType","adminForbidType","payload"];!1===i?u.push("lastMessage"):u.push("isPinned");const l=s[g].lastMessage,d=!Pe(l);d||s[g].type===t.CONV_TOPIC||this._onLastMessageNotExist(s[g]),Pe(i)&&d&&null===c.lastMessage.payload&&(c.lastMessage.payload=l.payload),St(c.lastMessage.revoker)||(c.lastMessage.revoker=null);qe(c,e,u,[null,void 0,"",0,NaN]),!0===r&&c.updateUnreadCount({nextUnreadCount:e.unreadCount,isFromGetConversations:o,isUnreadC2CMessage:n}),i&&d&&(l.payload&&(c.lastMessage.payload=l.payload),c.type===t.CONV_GROUP&&(c.lastMessage.nameCard=l.nameCard,c.lastMessage.nick=l.nick)),d&&c.lastMessage.cloudCustomData!==l.cloudCustomData&&(c.lastMessage.cloudCustomData=l.cloudCustomData||""),this._conversationMap.delete(p),a.push([p,c])}else{if(e.type===t.CONV_GROUP&&u){const{groupID:t}=e.groupProfile,s=u.getLocalGroupProfile(t);s&&(e.groupProfile=s,!0===r&&e.updateUnreadCount({nextUnreadCount:0}))}else if(e.type===t.CONV_C2C){const s=p.replace(t.CONV_C2C,"");l&&l.isMyFriend(s)&&(e.remark=l.getFriendRemark(s))}c.push(e),a.push([p,e])}}const p=this.getModule(ps),h=a.length;for(let g=0;g<h;g++){if(a[g][1].type!==t.CONV_TOPIC)continue;const{conversationID:e,unreadCount:s,groupAtInfoList:o}=a[g][1];p.onConversationProxy({topicID:e.replace(t.CONV_GROUP,""),unreadCount:s,groupAtInfoList:St(o)?void 0:o})}return{toBeUpdatedConversationList:a,newConversationList:c}}_onLastMessageNotExist(e){new no("lastMessageNotExist").setMessage(JSON.stringify(e)).setNetworkType(this.getNetworkType()).end()}_sortConversationList(e){const t=[],s=[],o=[],i=[];return e.forEach(e=>{!0===e[1].isPinned?St(e[1].lastMessage.lastTime)?s.push(e):t.push(e):St(e[1].lastMessage.lastTime)?i.push(e):o.push(e)}),t.sort((e,t)=>t[1].lastMessage.lastTime-e[1].lastMessage.lastTime).concat(s).concat(o.sort((e,t)=>t[1].lastMessage.lastTime-e[1].lastMessage.lastTime)).concat(i)}_sortConversationListAndEmitEvent(){this._conversationMap=new Map(this._sortConversationList([...this._conversationMap])),this.emitConversationUpdate(!0,!1)}_updateUserOrGroupProfile(e){if(0===e.length)return;const s=[],o=[],i=this.getModule(us),n=this.getModule(ds);e.forEach(e=>{if(e.type===t.CONV_C2C)s.push(e.toAccount);else if(e.type===t.CONV_GROUP){const t=e.toAccount;n.hasLocalGroup(t)?e.groupProfile=n.getLocalGroupProfile(t):o.push(t)}}),Ie.l(`${this._n}._updateUserOrGroupProfile c2cUserIDList:${s} groupIDList:${o}`),s.length>0&&i.getUserProfile({userIDList:s}).then(({data:e})=>{Ue(e)?e.forEach(e=>{this._doUpdateUserProfile("C2C"+e.userID,e)}):this._doUpdateUserProfile("C2C"+e.userID,e)}),o.length>0&&n.getGroupProfileAdvance({groupIDList:o,responseFilter:{groupBaseInfoFilter:["Type","Name","FaceUrl"]}}).then(({data:{successGroupList:e}})=>{e.forEach(e=>{const t="GROUP"+e.groupID;if(this._conversationMap.has(t)){const s=this._conversationMap.get(t);qe(s.groupProfile,e,[],[null,void 0,"",0,NaN]),!s.subType&&e.type&&(s.subType=e.type)}})})}_doUpdateUserProfile(e,t){this.hasLocalConversation(e)&&(this.getLocalConversation(e).userProfile=t)}_getConversationOptions(e){const t=[],s=e.filter(({type:e,userID:t})=>1===e&&!this._isNonExistentAccount(t)||2===e),o=this.getMyUserID(),i=s.map(e=>{if(Pe(e.lastMsg)&&(e.lastMsg={elements:[]}),1===e.type){const s={userID:e.userID,nick:e.peerNick,avatar:e.peerAvatar};return t.push(s),{conversationID:"C2C"+e.userID,type:"C2C",lastMessage:{lastTime:e.time,lastSequence:e.sequence,fromAccount:e.lastC2CMsgFromAccount,type:e.lastMsg.elements[0]?e.lastMsg.elements[0].type:null,payload:e.lastMsg.elements[0]?this._amendLayersOverLimitProperty(e.lastMsg.elements[0].content):null,cloudCustomData:e.lastMsg.cloudCustomData||"",isRevoked:8===e.lastMessageFlag,onlineOnlyFlag:!1,nick:"",nameCard:"",version:0,isPeerRead:e.lastC2CMsgFromAccount===o&&e.time<=e.c2cPeerReadTime,revoker:e.lastMsg.revokerInfo?e.lastMsg.revokerInfo.revoker:null},userProfile:new Po(s),peerReadTime:e.c2cPeerReadTime,isPinned:1===e.isPinned,customData:e.customMark||"",markList:mt(e.standardMark),conversationGroupList:this._convGroupHandler.getConvGroupListByID(e.contactGroupId),remark:e.friendRemark||"",messageRemindType:this._transMessageRemindType(e.messageRemindType)}}return{conversationID:"GROUP"+e.groupID,type:"GROUP",lastMessage:{lastTime:e.time,lastSequence:e.sequence,fromAccount:e.msgGroupFromAccount,...this._patchTypeAndPayload(e),cloudCustomData:e.lastMsg.cloudCustomData||"",isRevoked:2===e.lastMessageFlag,onlineOnlyFlag:!1,nick:e.senderNick||"",nameCard:e.senderNameCard||"",revoker:e.lastMsg.revokerInfo?e.lastMsg.revokerInfo.revoker:null},groupProfile:new Fo({groupID:e.groupID,name:e.groupNick,avatar:e.groupImage,type:e.groupType,nextMessageSeq:e.nextMessageSeq}),unreadCount:this._computeGroupUnreadCount(e),peerReadTime:0,isPinned:1===e.isPinned,version:0,customData:e.customMark||"",markList:mt(e.standardMark),conversationGroupList:this._convGroupHandler.getConvGroupListByID(e.contactGroupId),messageRemindType:this._transMessageRemindType(e.messageRemindType)}});if(t.length>0){this.getModule(us).onConversationsProfileUpdated(t)}return i}_transMessageRemindType(e){let s="";return 0===e?s=t.MSG_REMIND_ACPT_AND_NOTE:1===e?s=t.MSG_REMIND_DISCARD:2===e&&(s=t.MSG_REMIND_ACPT_NOT_NOTE),s}_computeGroupUnreadCount(e){const{unreadCount:t=0,noUnreadCount:s=0}=e,o=t-s;return o>0?o:0}_patchTypeAndPayload(e){const{event:s,elements:o=[],groupTips:i={}}=e.lastMsg;if(!Pe(s)&&!St(i)){let e=new Eo(i);e.setElement({type:t.MSG_GRP_TIP,content:{...i.elements,groupProfile:i.groupProfile}});const s=JSON.parse(JSON.stringify(e.payload));return e=null,{type:t.MSG_GRP_TIP,payload:s}}return{type:o[0]?o[0].type:null,payload:o[0]?this._amendLayersOverLimitProperty(o[0].content):null}}_amendLayersOverLimitProperty(e){const{layersOverLimit:t}=e;return 0===t?e.layersOverLimit=!1:1===t&&(e.layersOverLimit=!0),e}getLocalMessageList(e){return this._messageListHandler.getLocalMessageList(e)}deleteLocalMessage(e){e instanceof Eo&&this._messageListHandler.remove(e)}onConversationDeleted(e){if(!Ue(e))return;const s=e.map(e=>{const{type:s,userID:o,groupID:i}=e;return 1===s?`${t.CONV_C2C}${o}`:2===s?`${t.CONV_GROUP}${i}`:void 0});Ie.l(`${this._n}.onConversationDeleted conversationIDList:${s}`),this.deleteLocalConversationList(s)}onConversationPinned(e){if(!Ue(e))return;let s=!1;e.forEach(e=>{const{type:o,userID:i,groupID:n}=e;let r;1===o?r=this.getLocalConversation(`${t.CONV_C2C}${i}`):2===o&&(r=this.getLocalConversation(`${t.CONV_GROUP}${n}`)),r&&(Ie.l(`${this._n}.onConversationPinned conversationID:${r.conversationID} isPinned:${r.isPinned}`),r.isPinned||(r.isPinned=!0,s=!0))}),s&&this._sortConversationListAndEmitEvent()}onConversationUnpinned(e){if(!Ue(e))return;let s=!1;e.forEach(e=>{const{type:o,userID:i,groupID:n}=e;let r;1===o?r=this.getLocalConversation(`${t.CONV_C2C}${i}`):2===o&&(r=this.getLocalConversation(`${t.CONV_GROUP}${n}`)),r&&(Ie.l(`${this._n}.onConversationUnpinned conversationID:${r.conversationID} isPinned:${r.isPinned}`),r.isPinned&&(r.isPinned=!1,s=!0))}),s&&this._sortConversationListAndEmitEvent()}getMessageList({conversationID:e,nextReqMessageID:t,count:s}){const o=this._n+".getMessageList",i=this.getLocalConversation(e);let n="";if(i&&i.groupProfile&&(n=i.groupProfile.type),Je(n))return Ie.l(`${o} not available in avchatroom. conversationID:${e}`),xs({messageList:[],nextReqMessageID:"",isCompleted:!0});(Pe(s)||s>15)&&(s=15),!t&&this._isNotInCommunity(e)&&(this._messageListHandler.removeByConversationID(e),this._completedMap.delete(e),this._roamingMessageSequenceMap.delete(e));const r=this._computeRemainingCount({conversationID:e,nextReqMessageID:t}),a=this._completedMap.has(e);if(Ie.l(`${o} conversationID:${e} nextReqMessageID:${t} remainingCount:${r} count:${s} isCompleted:${a}`),this._needGetHistory({conversationID:e,remainingCount:r,count:s}))return this.getHistoryMessages({conversationID:e,nextReqMessageID:t,count:20}).then(t=>{const{nextReqID:s,storedMessageList:i}=t,n=this._completedMap.has(e);let a=i;if(r>0){a=this._messageListHandler.getLocalMessageList(e).slice(0,i.length+r)}const c={nextReqMessageID:n?"":s,messageList:a,isCompleted:n},u=c.messageList.filter(e=>e.isRevoked)||[],l=a.map(e=>e.sequence);return Ie.l(`${o} ret.nextReqMessageID:${c.nextReqMessageID} ret.isCompleted:${c.isCompleted} ret.length:${a.length} sequenceList:${l}`),Ue(u)&&0!==u.length?this.updateRevokerInfo(u).then(e=>(e.forEach(e=>{const{revokerInfo:t}=e;c.messageList=c.messageList.map(s=>(s.ID===e.ID&&t&&(s.revokeReason=t.reason||"",s.revokerInfo={userID:t.revoker||s.revoker,nick:t.nick,avatar:t.avatar}),s))}),ws(c))):ws(c)});this.modifyMessageList(e);const c=this._getMessageListFromMemory({conversationID:e,nextReqMessageID:t,count:s});return xs(c)}_getMessageListFromMemory({conversationID:e,nextReqMessageID:t,count:s}){const o=this._n+"._getMessageListFromMemory",i=this._messageListHandler.getLocalMessageList(e),n=i.length;let r=0;const a={isCompleted:!1,nextReqMessageID:"",messageList:[]};return t?(r=i.findIndex(e=>e.ID===t),r>s?(a.messageList=i.slice(r-s,r),a.nextReqMessageID=i[r-s].ID):(a.messageList=i.slice(0,r),a.isCompleted=!0)):n>s?(r=n-s,a.messageList=i.slice(r,n),a.nextReqMessageID=i[r].ID):(a.messageList=i.slice(0,n),a.isCompleted=!0),Ie.l(`${o} conversationID:${e} ret.nextReqMessageID:${a.nextReqMessageID} ret.isCompleted:${a.isCompleted} ret.length:${a.messageList.length}`),a}getMessageListHopping(e){let{conversationID:s,sequence:o,time:i,count:n,direction:r=0}=e;if((Pe(n)||n>15)&&(n=15),s.startsWith(t.CONV_C2C)){const e=this.getModule(ls),o=s.replace(t.CONV_C2C,"");return e.getRoamingMessagesHopping({peerAccount:o,time:i,count:n,direction:r})}if(s.startsWith(t.CONV_GROUP)){const e=this.getModule(ds),i=s.replace(t.CONV_GROUP,"");return e.getRoamingMessagesHopping({groupID:i,sequence:o,count:n,direction:r})}}_computeRemainingCount({conversationID:e,nextReqMessageID:t}){const s=this._messageListHandler.getLocalMessageList(e),o=s.length;if(!t)return o;let i=0;return Ze(e)?i=s.findIndex(e=>e.ID===t):et(e)&&(i=-1!==t.indexOf("-")?s.findIndex(e=>e.ID===t):s.findIndex(e=>e.sequence===t)),-1===i&&(i=0),i}_getMessageListSize(e){return this._messageListHandler.getLocalMessageList(e).length}_needGetHistory({conversationID:e,remainingCount:t,count:s}){const o=this.getLocalConversation(e);let i="";if(o&&o.groupProfile&&(i=o.groupProfile.type),st(e)||Je(i))return!1;let n=!1;const r=`${this._n}._needGetHistory conversationID:${e}`;if(et(e)){const t=this._isPagingGetGroupListCompleted(),s=this._getLocalGroupCount(),o=this._hasLocalGroup(e),i=this._isTopicConversation(e);if(Ie.l(`${r} isGroupListCompleted:${t} localGroupCount:${s} isGroupInList:${o} isTopic:${i}`),t&&s<=500&&!o&&!i)return n}return n=t<=s&&!this._completedMap.has(e),Ie.l(`${r} ret:${n}`),n}_isTopicConversation(e){const s=e.replace(t.CONV_GROUP,"");return Qe(s)}getHistoryMessages(e){const{conversationID:s,count:o}=e;if(s===t.CONV_SYSTEM)return xs();let i=15;o>20&&(i=20);let n=null;if(Ze(s)){const e=this._roamingMessageKeyAndTimeMap.has(s);return n=this.getModule(ls),n?n.getRoamingMessage({conversationID:s,peerAccount:s.replace(t.CONV_C2C,""),count:i,lastMessageTime:e?this._roamingMessageKeyAndTimeMap.get(s).lastMessageTime:0,messageKey:e?this._roamingMessageKeyAndTimeMap.get(s).messageKey:""}):Vs({code:$s.CANNOT_FIND_MODULE})}if(et(s)){if(n=this.getModule(ds),!n)return Vs({code:$s.CANNOT_FIND_MODULE});const e=s.replace(t.CONV_GROUP,"");let o=null;this._conversationMap.has(s)&&!Qe(e)&&(o=this._conversationMap.get(s).lastMessage);let r=0;o&&(r=o.lastSequence);const a=this._roamingMessageSequenceMap.get(s);return n.getRoamingMessage({conversationID:s,groupID:e,count:i,sequence:a||r})}return xs()}patchConversationLastMessage(e){const t=this.getLocalConversation(e);if(!t)return;const{messageForShow:s,payload:o}=t.lastMessage;if(St(s)||St(o)){const s=this._messageListHandler.getLocalMessageList(e);if(0===s.length)return;const o=s[s.length-1];Ie.l(`${this._n}.patchConversationLastMessage conversationID:${e} payload:`,o.payload),t.updateLastMessage(o)}}onRoamingMessage(e=[],s,o=!0){const i=s.startsWith(t.CONV_C2C)?t.CONV_C2C:t.CONV_GROUP;let n=null,r=[],a=[],c=0,u=e.length,l=null;const d=i===t.CONV_GROUP,_=this.getFileDownloadProxy();let p=()=>{c=d?e.length-1:0,u=d?0:e.length},h=()=>{d?--c:++c},g=()=>d?c>=u:c<u;for(p();g();h())if(d&&1===e[c].sequence&&o&&this.setCompleted(s),1!==e[c].isPlaceMessage)if(n=new Eo(e[c]),n.to=e[c].to,i!==t.CONV_GROUP||Pe(e[c].topicID)||(n.to=e[c].topicID),n.isSystemMessage=!!e[c].isSystemMessage,n.conversationType=i,l=4===e[c].event?{type:t.MSG_GRP_TIP,content:{...e[c].elements,groupProfile:e[c].groupProfile}}:e[c].elements,d||n.setNickAndAvatar({nick:e[c].nick,avatar:e[c].avatar}),St(l)){const t=new no("emptyMessageBody");t.setMessage(`from:${n.from} to:${n.to} sequence:${n.sequence} event:${e[c].event}`),t.setNetworkType(this.getNetworkType()).setLevel("warning").end()}else n.setElement(l,_),n.reInitialize(this.getMyUserID()),r.push(n);return p=h=g=null,o?(this._messageListHandler.unshift(r,a),r=null,a):(a=null,r)}findMessage(e){return this._messageListHandler.findMessage(e)}_isNotInCommunity(e){let s=!1;if(e.startsWith(t.CONV_GROUP)&&this._isTopicConversation(e)){const o=ht(e.replace(t.CONV_GROUP,""));this.getModule(ds).hasLocalGroup(o)||(s=!0)}return s}deleteTopicRoamingMessageInfo(e){if(!Xe({groupID:e}))return;this._messageListHandler.getTopicConversationIDList(e).forEach(e=>{this._completedMap.delete(e),this._roamingMessageSequenceMap.delete(e)})}deleteGroupRoamingMessageInfo(e){const s=`${t.CONV_GROUP}${e}`;this._completedMap.delete(s),this._roamingMessageSequenceMap.delete(s)}setMessageRead({conversationID:e}){const s=this.getLocalConversation(e);if(Ie.l(`${this._n}.setMessageRead conversationID:${e} unreadCount:${s?s.unreadCount:0}`),!s)return xs();if(s.type!==t.CONV_GROUP&&s.type!==t.CONV_TOPIC||St(s.groupAtInfoList)||this.deleteGroupAtTips(e),0===s.unreadCount)return xs();if(s.type===t.CONV_GROUP&&!this._hasLocalGroup(e))return 0!==s.unreadCount&&(s.unreadCount=0,this.emitConversationUpdate(!0,!1)),xs();const o=this._messageListHandler.getLocalLastMessage(e);let i=s.lastMessage.lastTime;o&&i<o.time&&(i=o.time);let n=s.lastMessage.lastSequence;if(o&&n<o.sequence&&(n=o.sequence),s.type===t.CONV_TOPIC&&Pe(o)){const s=this.getModule(ps),o=e.replace(t.CONV_GROUP,""),i=ht(o),r=s.getLocalTopic(i,o);r&&(n=r.nextMessageSeq-1)}let r=null;switch(s.type){case t.CONV_C2C:return r=this.getModule(ls),r?r.setMessageRead({conversationID:e,lastMessageTime:i}):Vs({code:$s.CANNOT_FIND_MODULE});case t.CONV_GROUP:case t.CONV_TOPIC:return r=this.getModule(ds),r?r.setMessageRead({conversationID:e,lastMessageSeq:n}):Vs({code:$s.CANNOT_FIND_MODULE});case t.CONV_SYSTEM:return s.unreadCount=0,this.emitConversationUpdate(!0,!1),xs();default:return xs()}}setAllMessageRead(e={}){const s=this._n+".setAllMessageRead";e.scope||(e.scope=t.READ_ALL_MSG),Ie.l(s+" options:",e);const o=this._createSetAllMessageReadPack(e);if(0===o.readAllC2CMessage&&0===o.groupMessageReadInfoList.length)return xs();const i=new no("setAllMessageRead");return this.request({protocolName:Ks.SET_ALL_MESSAGE_READ,requestData:o}).then(t=>{const{data:s}=t,o=this._handleAllMessageRead(s);return i.setMessage(`scope:${e.scope} failureGroups:${JSON.stringify(o)}`).setNetworkType(this.getNetworkType()).end(),xs()}).catch(e=>(this.probeNetwork().then(([t,s])=>{i.setError(e,t,s).end()}),Ie.w(s+" failed. error:",e),Vs({code:e&&e.code?e.code:$s.MSG_UNREAD_ALL_FAIL,message:e&&e.message?e.message:void 0})))}setConversationCustomData(e){return this._convGroupHandler.setConvCustomData(e)}markConversation(e){return this._convGroupHandler.markConversation(e)}getConversationGroupList(){return this._convGroupHandler.getLocalConvGroupList()}createConversationGroup(e){return this._convGroupHandler.createConvGroup(e)}deleteConversationGroup(e){return this._convGroupHandler.deleteConvGroup(e)}renameConversationGroup(e){return this._convGroupHandler.renameConvGroup(e)}addConversationsToGroup(e){return this._convGroupHandler.addConvsToGroup(e)}deleteConversationsFromGroup(e){return this._convGroupHandler.deleteConvsFromGroup(e)}onConversationMarkUpdated(e){this._convGroupHandler.onConvMarkUpdated(e)}onConversationGroupCreated(e){this._convGroupHandler.onConvGroupCreated(e)}onConversationGroupDeleted(e){this._convGroupHandler.onConvGroupDeleted(e)}onConversationGroupNameUpdated(e){this._convGroupHandler.onConvGroupNameUpdated(e)}onConversationInGroupUpdated(e){this._convGroupHandler.onConvInGroupUpdated(e)}onConversationAddedToOrDeletedFromGroup(e){this._convGroupHandler.onConvAddedToOrDeletedFromGroup(e)}_getConversationLastMessageSequence(e){const t=this._messageListHandler.getLocalLastMessage(e.conversationID);let s=e.lastMessage.lastSequence;return t&&s<t.sequence&&(s=t.sequence),s}_getConversationLastMessageTime(e){const t=this._messageListHandler.getLocalLastMessage(e.conversationID);let s=e.lastMessage.lastTime;return t&&s<t.time&&(s=t.time),s}_createSetAllMessageReadPack(e){const s={readAllC2CMessage:0,groupMessageReadInfoList:[]},{scope:o}=e;for(const[,i]of this._conversationMap)if(i.unreadCount>0)if(i.type===t.CONV_C2C&&0===s.readAllC2CMessage){if(o===t.READ_ALL_MSG)s.readAllC2CMessage=1;else if(o===t.READ_ALL_C2C_MSG){s.readAllC2CMessage=1;break}}else if(i.type===t.CONV_GROUP&&(o===t.READ_ALL_GROUP_MSG||o===t.READ_ALL_MSG)){const e=this._getConversationLastMessageSequence(i);s.groupMessageReadInfoList.push({groupID:i.groupProfile.groupID,messageSequence:e})}return s}onPushedAllMessageRead(e){this._handleAllMessageRead(e)}_handleAllMessageRead(e){const{groupMessageReadInfoList:t,readAllC2CMessage:s}=e,o=this._parseGroupReadInfo(t);return this._updateAllConversationUnreadCount({readAllC2CMessage:s})>=1&&(this.emitConversationUpdate(!0,!1),this.emitTotalUnreadMessageCountUpdate()),o}_parseGroupReadInfo(e){const t=[];if(e&&e.length)for(let s=0,o=e.length;s<o;s++){const{groupID:o,sequence:i,retCode:n,lastMessageSeq:r}=e[s];Pe(n)?this._remoteGroupReadSequenceMap.set(o,r):(this._remoteGroupReadSequenceMap.set(o,i),0!==n&&t.push(`${o}-${i}-${n}`))}return t}_updateAllConversationUnreadCount(e){const{readAllC2CMessage:s}=e;let o=0;for(const[i,n]of this._conversationMap)if(n.unreadCount>=1){if(1===s&&n.type===t.CONV_C2C){const e=this._getConversationLastMessageTime(n);this.updateIsReadAfterReadReport({conversationID:i,lastMessageTime:e})}else if(n.type===t.CONV_GROUP){const e=i.replace(t.CONV_GROUP,"");if(this._remoteGroupReadSequenceMap.has(e)){const t=this._remoteGroupReadSequenceMap.get(e),s=this._getConversationLastMessageSequence(n);this.updateIsReadAfterReadReport({conversationID:i,remoteReadSequence:t}),s>=t&&this._remoteGroupReadSequenceMap.delete(e)}}this.updateUnreadCount(i,!1)&&(o+=1)}return o}isRemoteRead(e){const{conversationID:s,sequence:o}=e,i=s.replace(t.CONV_GROUP,"");let n=!1;if(this._remoteGroupReadSequenceMap.has(i)){const e=this._remoteGroupReadSequenceMap.get(i);o<=e&&(n=!0,Ie.l(`${this._n}.isRemoteRead conversationID:${s} messageSequence:${o} remoteReadSequence:${e}`)),o>=e+10&&this._remoteGroupReadSequenceMap.delete(i)}return n}updateIsReadAfterReadReport({conversationID:e,lastMessageSeq:t,lastMessageTime:s}){const o=this._messageListHandler.getLocalMessageList(e);if(0===o.length)return;let i;for(let n=o.length-1;n>=0;n--)if(i=o[n],!(s&&i.time>s||t&&i.sequence>t)){if("in"===i.flow&&i.isRead)break;i.setIsRead(!0)}}updateUnreadCount(e,s=!0){let o=!1;const i=this.getLocalConversation(e),n=this._messageListHandler.getLocalMessageList(e);if(!i)return;const r=i.unreadCount,a=n.filter(e=>!e.isRead&&!e._onlineOnlyFlag&&!e.isDeleted).length;if(r!==a&&(i.unreadCount=a,o=!0,Ie.l(`${this._n}.updateUnreadCount from ${r} to ${a}, conversationID:${e}`),!0===s&&(this.emitConversationUpdate(!0,!1),this.emitTotalUnreadMessageCountUpdate())),o&&i.type===t.CONV_TOPIC){const{unreadCount:s}=i,o=this.getModule(ps),n=e.replace(t.CONV_GROUP,"");o.onConversationProxy({topicID:n,unreadCount:s})}return o}clearGroupAtInfoList(e,s=!0){const o=this.getLocalConversation(e);if(o&&o.groupAtInfoList.length>0){if(o.clearGroupAtInfoList(),Ie.l(`${this._n}.clearGroupAtInfoList conversationID:${e}`),o.type===t.CONV_TOPIC){const{groupAtInfoList:s}=o,i=this.getModule(ps),n=e.replace(t.CONV_GROUP,"");i.onConversationProxy({topicID:n,groupAtInfoList:s})}!0===s&&this.emitConversationUpdate(!0,!1)}}updateReadReceiptInfo(s){const{userID:o,groupID:i,readReceiptList:n}=s;if(St(n))return;const r=[];if(Pe(o)){if(!Pe(i)){const e=`${t.CONV_GROUP}${i}`;n.forEach(t=>{const{tinyID:s,clientTime:o,random:n,readCount:a,unreadCount:c}=t,u=`${s}-${o}-${n}`,l=this._messageListHandler.getLocalMessage(e,u),d={groupID:i,messageID:u,readCount:0,unreadCount:0};l&&(Ae(a)&&(l.readReceiptInfo.readCount=a,d.readCount=a),Ae(c)&&(l.readReceiptInfo.unreadCount=c,d.unreadCount=c),r.push(d))})}}else{const e=`${t.CONV_C2C}${o}`;n.forEach(t=>{const{tinyID:s,clientTime:i,random:n}=t,a=`${s}-${i}-${n}`,c=this._messageListHandler.getLocalMessage(e,a);if(c){c.readReceiptInfo.isPeerRead=!0;const e={userID:o,messageID:a,isPeerRead:!0};r.push(e)}})}r.length>0&&this.emitOuterEvent(e.MESSAGE_READ_RECEIPT_RECEIVED,r)}updateIsRead(e){const s=this.getLocalConversation(e),o=this.getLocalMessageList(e);if(!s||0===o.length||st(s.type))return;const i=[];for(let t=0,r=o.length;t<r;t++)"in"!==o[t].flow?"out"!==o[t].flow||o[t].isRead||o[t].setIsRead(!0):i.push(o[t]);let n=0;if(s.type===t.CONV_C2C){const e=i.slice(-s.unreadCount).filter(e=>e.isRevoked).length;n=i.length-s.unreadCount-e}else n=i.length-s.unreadCount;for(let t=0;t<n&&!i[t].isRead;t++)i[t].setIsRead(!0)}deleteGroupAtTips(e){const s=this._n+".deleteGroupAtTips";Ie.l(""+s);const o=this._conversationMap.get(e);if(!o)return Promise.resolve();const i=o.groupAtInfoList;if(0===i.length)return Promise.resolve();let n=void 0;e.startsWith(t.CONV_GROUP)&&(n=e.replace(t.CONV_GROUP,""));let r=[...i];if((Xe({groupID:n})||Qe(n))&&(r=i.filter(e=>!e.atTypeArray.includes(t.CONV_AT_ALL)),0===r.length))return this.clearGroupAtInfoList(e,!1),Promise.resolve();const a=this.getMyUserID();return this.request({protocolName:Ks.DELETE_GROUP_AT_TIPS,requestData:{messageListToDelete:r.map(e=>({from:e.from,to:a,messageSeq:e.__sequence,messageRandom:e.__random,groupID:Pe(e.topicID)?e.groupID:e.topicID}))}}).then(()=>(Ie.l(`${s} ok. count:${i.length}`),this.clearGroupAtInfoList(e,!1),Promise.resolve())).catch(e=>(Ie.e(s+" failed. error:",e),Vs(e)))}appendToMessageList(e){return this._messageListHandler.pushIn(e)}setMessageRandom(e){this.singlyLinkedList.set(e.random)}deleteMessageRandom(e){this.singlyLinkedList.delete(e.random)}pushIntoMessageList(e,t,s){return!(!this._messageListHandler.pushIn(t,s)||this._isMessageFromCurrentInstance(t)&&!s)&&(e.push(t),!0)}_isMessageFromCurrentInstance(e){return this.singlyLinkedList.has(e.random)}revoke(e,t,s){return this._messageListHandler.revoke(e,t,s)}getPeerReadTime(e){return this._peerReadTimeMap.get(e)}recordPeerReadTime(e,t){if(this._peerReadTimeMap.has(e)){this._peerReadTimeMap.get(e)<t&&this._peerReadTimeMap.set(e,t)}else this._peerReadTimeMap.set(e,t)}updateMessageIsPeerReadProperty(s,o){if(s.startsWith(t.CONV_C2C)&&o>0){const t=this._messageListHandler.updateMessageIsPeerReadProperty(s,o);if(t.length>0&&this.emitOuterEvent(e.MESSAGE_READ_BY_PEER,t),this._conversationMap.has(s)){const e=this._conversationMap.get(s).lastMessage;St(e)||e.fromAccount===this.getMyUserID()&&e.lastTime<=o&&!e.isPeerRead&&(e.isPeerRead=!0,this.emitConversationUpdate(!0,!1))}}}updateMessageIsModifiedProperty(e){this._messageListHandler.updateMessageIsModifiedProperty(e)}setCompleted(e){Ie.l(`${this._n}.setCompleted. conversationID:${e}`),this._completedMap.set(e,!0)}updateRoamingMessageKeyAndTime(e,t,s){this._roamingMessageKeyAndTimeMap.set(e,{messageKey:t,lastMessageTime:s})}updateRoamingMessageSequence(e,t){this._roamingMessageSequenceMap.set(e,t)}getConversationList(e){const t=this._n+".getConversationList",s=`pagingStatus:${this._pagingStatus}, local conversation count:${this._conversationMap.size}, options:${e}`;if(Ie.l(`${t}. ${s}`),this._pagingStatus===vt.REJECTED){const o=new no("getConversationList");return o.setMessage(s),this.syncConversationList().then(()=>{o.setNetworkType(this.getNetworkType()).end();const t=this._getConversationList(e);return ws({conversationList:t,isSyncCompleted:this._isSyncCompleted()})}).catch(e=>(this.probeNetwork().then(([t,s])=>{o.setError(e,t,s).end()}),Ie.e(t+" failed. error:",e),Vs(e)))}const o=this._getConversationList(e);return Ie.l(`${t}. returned conversation count:${o.length}`),xs({conversationList:o,isSyncCompleted:this._isSyncCompleted()})}_getConversationList(e){if(Pe(e))return this.getLocalConversationList();if(Ue(e)){if(0===e.length)return[];return this.getLocalConversationList().filter(t=>e.includes(t.conversationID))}if(Le(e)){const{type:s,markType:o,groupName:i}=e;return this.getLocalConversationList().filter(e=>(s!==t.CONV_C2C&&s!==t.CONV_GROUP||e.type===s)&&(!Oe(i)||e.conversationGroupList.includes(i))&&(!Ae(o)||e.markList.includes(o)))}return[]}_handleC2CPeerReadTime(){for(const[e,s]of this._conversationMap)s.type===t.CONV_C2C&&(Ie.d(`${this._n}._handleC2CPeerReadTime conversationID:${e} peerReadTime:${s.peerReadTime}`),this.recordPeerReadTime(e,s.peerReadTime))}_isPagingGetGroupListCompleted(){const e=this.getModule(ds);return!e||e.isPagingGetCompleted()}_getLocalGroupCount(){const e=this.getModule(ds);return e?e.getLocalGroupList().length:0}_hasLocalGroup(e){const s=this.getModule(ds);return!!s&&s.hasLocalGroup(e.replace(t.CONV_GROUP,""))}getConversationProfile(e){let s;if(s=this._conversationMap.has(e)?this._conversationMap.get(e):new bo({conversationID:e,type:e.slice(0,3)===t.CONV_C2C?t.CONV_C2C:t.CONV_GROUP},this.isIntl(),this.isUsingChatCore()),s._isInfoCompleted||s.type===t.CONV_SYSTEM)return xs({conversation:s});if(et(e)&&!this._hasLocalGroup(e))return xs({conversation:s});const o=this._n+".getConversationProfile",i=new no("getConversationProfile");return Ie.l(`${o}. conversationID:${e} remark:${s.remark} lastMessage:`,s.lastMessage),this._updateUserOrGroupProfileCompletely(s).then(n=>{i.setNetworkType(this.getNetworkType()).setMessage(`conversationID:${e} unreadCount:${n.data.conversation.unreadCount}`).end();const r=this.getModule(_s);if(r&&s.type===t.CONV_C2C){const i=e.replace(t.CONV_C2C,"");if(r.isMyFriend(i)){const t=r.getFriendRemark(i);s.remark!==t&&(s.remark=t,Ie.l(`${o}. conversationID:${e} patch remark:${s.remark}`))}}return Ie.l(`${o} ok. conversationID:${e}`),n}).catch(t=>(this.probeNetwork().then(([s,o])=>{i.setError(t,s,o).setMessage("conversationID:"+e).end()}),Ie.e(o+" failed. error:",t),Vs(t)))}_updateUserOrGroupProfileCompletely(e){if(e.type===t.CONV_C2C){return this.getModule(us).getUserProfile({userIDList:[e.toAccount]}).then(t=>{const s=t.data;return 0===s.length?Vs(new Fs({code:$s.USER_OR_GRP_NOT_FOUND})):(e.userProfile=s[0],e._isInfoCompleted=!0,this._unshiftConversation(e),xs({conversation:e}))})}return this.getModule(ds).getGroupProfile({groupID:e.toAccount}).then(t=>(e.groupProfile=t.data.group,e._isInfoCompleted=!0,this._unshiftConversation(e),xs({conversation:e})))}_unshiftConversation(e){e instanceof bo&&!this._conversationMap.has(e.conversationID)&&(this._conversationMap=new Map([[e.conversationID,e],...this._conversationMap]),this._setStorageConversationList(),this.emitConversationUpdate(!0,!1))}_onProfileUpdated(e){e.data.forEach(e=>{const{userID:s}=e;if(s===this.getMyUserID())this._onMyProfileModified({latestNick:e.nick,latestAvatar:e.avatar});else{const o=this._conversationMap.get(`${t.CONV_C2C}${s}`);o&&(o.userProfile=e)}})}_isSyncCompleted(){return this._pagingStatus===vt.RESOLVED}_errorLog(e,t,s,o){const i=new Error("Params validate failed."),n=`${this.getErrorMessage("API_REFER")}${e}`;throw Ie.w(`[${e}] | ${t} | ${this.getErrorMessage(s,o)}, ${n}`),Ie.e(`[${e}] Invalid ${t}: type check failed for ${t}.`),i}_isValidConversationID(e){return Ze(e)||et(e)||st(e)}deleteConversation(e){const t="deleteConversation";return Oe(e)||Re(e)||this._errorLog(t,"options","StringOrObjectRequiredLog"),Oe(e)?(this._isValidConversationID(e)||this._errorLog(t,"options","InvalidConversationID",e),Ie.l(`${this._n}.${t} conversationID:${e}`),this.deleteConversationList({conversationIDList:[e],flag:1})):(Ue(e.conversationIDList)||this._errorLog(t,"conversationIDList","ArrayRequiredLog"),0===e.conversationIDList.length&&this._errorLog(t,"conversationIDList","NonEmptyArrayLog"),e.conversationIDList.forEach(e=>{this._isValidConversationID(e)||this._errorLog(t,"conversationIDList","InvalidConversationID",e)}),"clearHistoryMessage"in e&&"boolean"!=typeof e.clearHistoryMessage&&this._errorLog(t,"clearHistoryMessage","BooleanRequiredLog"),e.conversationIDList.length>100&&(e.conversationIDList=e.conversationIDList.slice(0,100)),this.deleteConversationList(e))}deleteConversationList(e){const{conversationIDList:t=[],clearHistoryMessage:s=!0,flag:o=0}=e,i=this._n+".deleteConversationList";Ie.l(`${i} conversationIDList.length:${t.length} clearHistoryMessage:${s}`);const n=new no("deleteConversationList");return n.setMessage("conversationIDList:"+t),Promise.all([this.rmLocalOnlyConversationList(t),this.rmLocalAndRemoteConversationList(t,s)]).then(e=>{n.setNetworkType(this.getNetworkType()).end();const t=[...e[0],...e[1]];return 0===t.length?Vs(new Fs({code:$s.CONV_NOT_FOUND})):(Ie.l(i+" ok"),xs(1===o?{conversationID:t[0]}:{conversationIDList:t}))}).catch(e=>(this.probeNetwork().then(([t,s])=>{n.setError(e,t,s).end()}),Ie.e(i+" failed. error:",e),Vs(e)))}rmLocalOnlyConversationList(e){return e.filter(e=>{if(!this._conversationMap.has(e))return!1;const s=this.getLocalConversation(e).type;if(s===t.CONV_GROUP&&!this._hasLocalGroup(e))return this.deleteLocalConversation(e),!0;if(s===t.CONV_SYSTEM){return this.getModule(ds).deleteGroupSystemNotice({messageList:this._messageListHandler.getLocalMessageList(e)}),this.deleteLocalConversation(e),!0}return!1})}rmLocalAndRemoteConversationList(e,s){const o={fromAccount:this.getMyUserID(),conversationList:[],clearHistoryMessage:s?1:0};return e.forEach(e=>{if(this._conversationMap.has(e)){const s=this.getLocalConversation(e).type;s===t.CONV_C2C?o.conversationList.push({toAccount:e.replace(s,""),type:1}):s===t.CONV_GROUP&&this._hasLocalGroup(e)&&o.conversationList.push({toGroupID:e.replace(s,""),type:2})}}),0===o.conversationList.length?[]:this.request({protocolName:Ks.DELETE_CONVERSATION,requestData:o}).then(e=>{const s=[];return e.data.resultList.length>0&&e.data.resultList.map(e=>{if(0===e.code){const o=1===e.type?`${t.CONV_C2C}${e.to}`:`${t.CONV_GROUP}${e.groupID}`;s.push(o)}}),this.deleteLocalConversationList(s),s})}setConversationDraft(e){const{conversationID:t,draftText:s}=e,o=this._n+".setConversationDraft";if(Ie.l(`${o} conversationID:${t} draftText:${s}`),!this._conversationMap.has(t))return Vs({code:$s.CONV_NOT_FOUND});const i=this._conversationMap.get(t);return i.setDraftText(s),xs({code:0,conversation:i})}clearHistoryMessage(e){const s={fromAccount:this.getMyUserID(),toAccount:void 0,type:void 0,toGroupID:void 0};if(!this._conversationMap.has(e))return Vs({code:$s.CONV_NOT_FOUND});const o=this._conversationMap.get(e).type;if(o===t.CONV_C2C)s.type=1,s.toAccount=e.replace(t.CONV_C2C,"");else{if(o!==t.CONV_GROUP){if(o===t.CONV_SYSTEM){return this.getModule(ds).deleteGroupSystemNotice({messageList:this._messageListHandler.getLocalMessageList(e)}),xs({conversationID:e})}return Vs({code:$s.CONV_UN_RECORDED_TYPE})}s.type=2,s.toGroupID=e.replace(t.CONV_GROUP,"")}const i=this._n+".clearHistoryMessage",n=new no("clearHistoryMessage");return n.setMessage("conversationID:"+e),Ie.l(`${i}. conversationID:${e}`),this.setMessageRead({conversationID:e}).then(()=>this.request({protocolName:Ks.CLEAR_HISTORY_MESSAGE,requestData:s})).then(()=>{n.setNetworkType(this.getNetworkType()).end(),Ie.l(i+" ok"),this._messageListHandler.removeByConversationID(e),this.setCompleted(e);const t=this.getLocalConversation(e);return t&&(t.updateLastMessage(),this._sortConversationListAndEmitEvent()),xs({conversationID:e})}).catch(e=>(this.probeNetwork().then(([t,s])=>{n.setError(e,t,s).end()}),Ie.e(i+" failed. error:",e),Vs(e)))}pinConversation(e){const{conversationID:s,isPinned:o}=e;if(!this._conversationMap.has(s))return Vs({code:$s.CONV_NOT_FOUND});const i=this.getLocalConversation(s);if(i.isPinned===o)return xs({conversationID:s});const n=this._n+".pinConversation",r=new no("pinConversation");r.setMessage(`conversationID:${s} isPinned:${o}`),Ie.l(`${n}. conversationID:${s} isPinned:${o}`);let a=null;return Ze(s)?a={type:1,toAccount:s.replace(t.CONV_C2C,"")}:et(s)&&(a={type:2,groupID:s.replace(t.CONV_GROUP,"")}),this.request({protocolName:Ks.PIN_CONVERSATION,requestData:{fromAccount:this.getMyUserID(),operationType:!0===o?1:2,itemList:[a]}}).then(()=>(r.setNetworkType(this.getNetworkType()).end(),Ie.l(n+" ok"),i.isPinned!==o&&(i.isPinned=o,this._sortConversationListAndEmitEvent()),ws({conversationID:s}))).catch(e=>(this.probeNetwork().then(([t,s])=>{r.setError(e,t,s).end()}),Ie.e(n+" failed. error:",e),Vs(e)))}setMessageRemindType(e){return this._messageRemindHandler.set(e)}patchMessageRemindType(e){const{ID:s,isC2CConversation:o,messageRemindType:i}=e;let n=!1;const r=this.getLocalConversation(o?`${t.CONV_C2C}${s}`:`${t.CONV_GROUP}${s}`);return r&&r.messageRemindType!==i&&(r.messageRemindType=i,n=!0),Ie.d(this._n+".patchMessageRemindType options:",e,"ret:"+n),n}onC2CMessageRemindTypeFetched(e){if(Ue(e)&&e.length>0){let t=0;e.forEach(e=>{const{userID:s,muteFlag:o}=e,i=this._transMessageRemindType(o);!0===this.patchMessageRemindType({ID:s,isC2CConversation:!0,messageRemindType:i})&&(t+=1)}),Ie.l(`${this._n}.onC2CMessageRemindTypeFetched updateCount:${t}`),t>=1&&this.emitConversationUpdate(!0,!1)}}onC2CMessageRemindTypeSynced(e){const t=this._n+".onC2CMessageRemindTypeSynced";Ie.d(t,e),e.dataList.forEach(e=>{if(!St(e.muteNotificationsSync)){const{to:s,muteFlag:o}=e.muteNotificationsSync,i=this._transMessageRemindType(o);let n=0;this.patchMessageRemindType({ID:s,isC2CConversation:!0,messageRemindType:i})&&(n+=1),Ie.l(`${t} updateCount:${n}`),n>=1&&this.emitConversationUpdate(!0,!1)}})}onGroupMessageRemindTypeUpdated(e){Ie.d(this._n+".onGroupMessageRemindTypeUpdated options:",e),this._messageRemindHandler.onGroupMessageRemindTypeUpdated(e)}deleteLocalConversation(e,t=!0){const s=this._conversationMap.has(e);if(Ie.d(`${this._n}.deleteLocalConversation conversationID:${e} has:${s}`),s&&(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),t)){const t=!this._isTopicConversation(e);this.emitConversationUpdate(t,!1)}}deleteLocalConversationList(e){let t=0,s=!1;e.forEach(e=>{this._conversationMap.has(e)&&(t+=this._conversationMap.get(e).unreadCount||0,this.deleteLocalConversation(e,!1),s=!0)}),Ie.l(`${this._n}.deleteLocalConversationList conversationIDList.length:${e.length} isConvIDExisted:${s}`),s&&(this.emitConversationUpdate(!0,!1),t>0&&this.emitTotalUnreadMessageCountUpdate())}isMessageSentByCurrentInstance(e){return!(!this._messageListHandler.hasLocalMessage(e.conversationID,e.ID)&&!this.singlyLinkedList.has(e.random))}modifyMessageList(e){if(!e.startsWith(t.CONV_C2C))return;if(!this._conversationMap.has(e))return;const s=this._conversationMap.get(e),o=Date.now();this._messageListHandler.modifyMessageSentByPeer({conversationID:e,latestNick:s.userProfile.nick,latestAvatar:s.userProfile.avatar});const i=this.getModule(us).getNickAndAvatarByUserID(this.getMyUserID());this._messageListHandler.modifyMessageSentByMe({conversationID:e,latestNick:i.nick,latestAvatar:i.avatar}),Ie.l(`${this._n}.modifyMessageList conversationID:${e} cost:${Tt(o)}`)}updateUserProfileSpecifiedKey(e){Ie.l(this._n+".updateUserProfileSpecifiedKey options:",e);const{conversationID:t,nick:s,avatar:o}=e;if(this._conversationMap.has(t)){const e=this._conversationMap.get(t).userProfile;Oe(s)&&e.nick!==s&&(e.nick=s),Oe(o)&&e.avatar!==o&&(e.avatar=o),this.emitConversationUpdate(!0,!1)}}_onMyProfileModified(e){const t=this.getLocalConversationList(),s=Date.now();t.forEach(t=>{this.modifyMessageSentByMe({conversationID:t.conversationID,...e})}),Ie.l(`${this._n}._onMyProfileModified. modify all messages sent by me, cost:${Tt(s)}`)}modifyMessageSentByMe(e){this._messageListHandler.modifyMessageSentByMe(e)}getLatestMessageSentByMe(e){return this._messageListHandler.getLatestMessageSentByMe(e)}modifyMessageSentByPeer(e){this._messageListHandler.modifyMessageSentByPeer(e)}getLatestMessageSentByPeer(e){return this._messageListHandler.getLatestMessageSentByPeer(e)}pushIntoNoticeResult(e,t){return!(!this._messageListHandler.pushIn(t)||this.singlyLinkedList.has(t.random))&&(e.push(t),!0)}getLocalLastMessage(e){return this._messageListHandler.getLocalLastMessage(e)}checkAndPatchRemark(){const e=this.getModule(_s);if(0===this._conversationMap.size||!e)return;const s=[...this._conversationMap.values()].filter(e=>e.type===t.CONV_C2C);if(0===s.length)return;let o=0;s.forEach(s=>{const i=s.conversationID.replace(t.CONV_C2C,"");if(e.isMyFriend(i)){const t=e.getFriendRemark(i);s.remark!==t&&(s.remark=t,o+=1)}}),Ie.l(`${this._n}.checkAndPatchRemark. c2c conversation count:${s.length}, patched count:${o}`)}updateTopicConversation(e){this._updateLocalConversationList({conversationOptionsList:e,isFromGetConversations:!0,updateUnreadCount:!0})}sendReadReceipt(e){const s=e[0];let o=null;return s.conversationType===t.CONV_C2C?o=this._m.getModule(ls):s.conversationType===t.CONV_GROUP&&(o=this._m.getModule(ds)),o?o.sendReadReceipt(e):Vs({code:$s.CANNOT_FIND_MODULE})}getReadReceiptList(e){const s=e[0];let o=null;return s.conversationType===t.CONV_C2C?o=this._m.getModule(ls):s.conversationType===t.CONV_GROUP&&(o=this._m.getModule(ds)),o?o.getReadReceiptList(e):Vs({code:$s.CANNOT_FIND_MODULE})}getLastMessageTime(e){const t=this.getLocalConversation(e);return t?t.lastMessage.lastTime:0}getTotalUnreadMessageCount(){const e=this.getLocalConversationList();let s=0;return e.forEach(e=>{e.type!==t.CONV_SYSTEM&&(""!==e.messageRemindType&&e.messageRemindType!==t.MSG_REMIND_ACPT_AND_NOTE||(s+=e.unreadCount))}),s}emitTotalUnreadMessageCountUpdate(){const t=this.getTotalUnreadMessageCount();this._convTotalUnreadCount!==t&&(Ie.l(`${this._n}.emitTotalUnreadMessageCountUpdate from ${this._convTotalUnreadCount} to ${t}`),this._convTotalUnreadCount=t,this.emitOuterEvent(e.TOTAL_UNREAD_MESSAGE_COUNT_UPDATED))}reset(){Ie.l(this._n+".reset"),this._setStorageConversationList(!0),this._pagingStatus=vt.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._convTotalUnreadCount=0,this._pagingGetCostList.length=0,this._pagingConvIDMap.clear(),this._convIDFromUnreadDBMap.clear(),this._pagingGetCostList.length=0,this.resetReady()}}const Bo=["topicID","topicName","avatar","introduction","notification","unreadCount","muteAllMembers","customData","groupAtInfoList","nextMessageSeq","selfInfo"],Ko=function(e,t){return St(e)?{lastTime:0,lastSequence:0,fromAccount:"",payload:null,type:"",messageForShow:"",nick:"",avatar:"",version:0,cloudCustomData:"",isRevoked:!1,revoker:null}:{lastTime:e.time||0,lastSequence:e.sequence||0,fromAccount:e.from||"",payload:e.payload||null,type:e.type||"",messageForShow:gt(e.type,e.payload,t),nick:e.nick||"",avatar:e.avatar||"",version:e.version||0,cloudCustomData:e.cloudCustomData||"",isRevoked:e.isRevoked||!1,revoker:e.revoker||null}};class Ho{constructor(e,t){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=Ko(e.lastMessage,t),this.selfInfo={muteTime:0,readedSequence:0,messageRemindType:"",excludedUnreadSequenceList:void 0},this._initTopic(e)}_initTopic(e){for(const t in e)Bo.indexOf(t)<0||("selfInfo"===t?this.updateSelfInfo(e[t]):this[t]="muteAllMembers"===t?1===e[t]:e[t])}updateUnreadCount(e=0){this.unreadCount=e}updateNextMessageSeq(e){this.nextMessageSeq=e}updateLastMessage(e){this.lastMessage=Ko(e)}updateGroupAtInfoList(e){this.groupAtInfoList=JSON.parse(JSON.stringify(e))}updateTopic(e){Pe(e.selfInfo)||this.updateSelfInfo(e.selfInfo),Pe(e.muteAllMembers)||(this.muteAllMembers=1===e.muteAllMembers),qe(this,e,["groupID","lastMessageTime","selfInfo","muteAllMembers","lastMsg"])}updateSelfInfo(e){return 0!==qe(this.selfInfo,e,[],[""])}reduceUnreadCount(){return this.unreadCount>=1&&(this.unreadCount-=1,!0)}isLastMessageRevoked({sequence:e}){return e===this.lastMessage.lastSequence}setLastMessageRevoked(e){this.lastMessage.isRevoked=e}setLastMessageRevoker(e){this.lastMessage.revoker=e}}class Yo extends Bs{constructor(e){super(e),this._n="TopicModule",this._topicMap=new Map,this._getTopicTimeMap=new Map,this.TOPIC_CACHE_TIME=300,this.TOPIC_LAST_ACTIVE_TIME=3600;this.getInnerEmitterInstance().on(Do.CLOUD_CONFIG_UPDATED,this._onCloudConfigUpdated,this)}_onCloudConfigUpdated(){const e=this.getCloudConfig("topic_cache_time"),t=this.getCloudConfig("topic_last_active_time");Pe(e)||(this.TOPIC_CACHE_TIME=Number(e)),Pe(t)||(this.TOPIC_LAST_ACTIVE_TIME=Number(t))}onTopicCreated(t){const{groupID:s}=t;this.resetGetTopicTime(s),this.emitOuterEvent(e.TOPIC_CREATED,t)}onTopicDeleted(t){const{groupID:s,topicIDList:o=[]}=t;o.forEach(e=>{this._deleteLocalTopic(s,e)}),this.emitOuterEvent(e.TOPIC_DELETED,t)}onTopicMessageRemindTypeUpdated(t){const{groupID:s,topicID:o,messageRemindType:i}=t,n=this.getLocalTopic(s,o);if(n){const t=n.updateSelfInfo({messageRemindType:i});t&&this.emitOuterEvent(e.TOPIC_UPDATED,{groupID:s,topic:n}),Ie.d(`${this._n}.onTopicMessageRemindTypeUpdated topicID:${o} messageRemindType:${i} isTopicUpdated:${t}`)}}onTopicProfileUpdated(t){const{groupID:s,topicID:o}=t,i=this.getLocalTopic(s,o);i&&(i.updateTopic(t),this.emitOuterEvent(e.TOPIC_UPDATED,{groupID:s,topic:i}))}onConversationProxy(t){const{topicID:s,unreadCount:o,groupAtInfoList:i}=t,n=ht(s),r=this.getLocalTopic(n,s);let a=!1;r&&(Pe(o)||r.unreadCount===o||(r.updateUnreadCount(o),a=!0),Pe(i)||(r.updateGroupAtInfoList(i),a=!0)),a&&this.emitOuterEvent(e.TOPIC_UPDATED,{groupID:n,topic:r})}onMessageSent(t){const{groupID:s,topicID:o,lastMessage:i}=t,n=this.getLocalTopic(s,o);n&&(n.nextMessageSeq+=1,n.updateLastMessage(i),this.emitOuterEvent(e.TOPIC_UPDATED,{groupID:s,topic:n}))}onMessageModified(t){const{to:s,time:o,sequence:i,elements:n,cloudCustomData:r,messageVersion:a}=t,c=ht(s),u=this.getLocalTopic(c,s);if(u){const l=u.lastMessage;Ie.d(`${this._n}.onMessageModified topicID:${s} lastMessage:`,JSON.stringify(l),"options:",JSON.stringify(t)),l&&(null===l.payload||l.lastTime===o&&l.lastSequence===i&&l.version!==a)&&(l.type=n[0].type,l.payload=n[0].content,l.messageForShow=gt(l.type,l.payload,this.isIntl()),l.cloudCustomData=r,l.version=a,l.lastSequence=i,l.lastTime=o,this.emitOuterEvent(e.TOPIC_UPDATED,{groupID:c,topic:u}))}}onMessageRevoked(t){if(0===t.length)return;let s=null,o=null,i=!1;t.forEach(e=>{const t=e.to;o=ht(t),s=this.getLocalTopic(o,t),s&&(s.reduceUnreadCount()&&(i=!0),s.isLastMessageRevoked(e)&&(s.setLastMessageRevoked(!0),s.setLastMessageRevoker(e.revoker),i=!0))}),i&&this.emitOuterEvent(e.TOPIC_UPDATED,{groupID:o,topic:s})}isLastMessageRevoked(e){const{topicID:t,sequence:s}=e,o=ht(t),i=this.getLocalTopic(o,t);let n=!1;return i&&(n=i.isLastMessageRevoked({sequence:s})),n}getJoinedCommunityList(){return this.getModule(ds).syncCommunityWithTopic()}createTopicInCommunity(e){const t=this._n+".createTopicInCommunity",{topicID:s}=e;if(!Pe(s)&&!Qe(s))return Vs({code:$s.ILLEGAL_TOPIC_ID});if(e.topicName&&!1===this._filterProfanity("topicName",e))return Vs({code:$s.PROFANITY_FOUND});if(e.introduction&&!1===this._filterProfanity("introduction",e))return Vs({code:$s.PROFANITY_FOUND});if(e.notification&&!1===this._filterProfanity("notification",e))return Vs({code:$s.PROFANITY_FOUND});const o=new no("createTopicInCommunity");return this.request({protocolName:Ks.CREATE_TOPIC,requestData:{...e}}).then(s=>{const{topicID:i}=s.data;return o.setMessage("topicID:"+i).setNetworkType(this.getNetworkType()).end(),Ie.l(`${t} ok. topicID:${i}`),this._updateTopicMap([{...e,topicID:i}]),ws({topicID:i})}).catch(e=>(this.probeNetwork().then(([t,s])=>{o.setError(e,t,s).end()}),Ie.e(t+" failed. error:",e),Vs(e)))}deleteTopicFromCommunity(e){const t=this._n+".deleteTopicFromCommunity",{groupID:s,topicIDList:o=[]}=e,i=new no("deleteTopicFromCommunity");return i.setMessage(`groupID:${s} topicIDList:${o}`),this.request({protocolName:Ks.DELETE_TOPIC,requestData:{groupID:s,topicIDList:o}}).then(e=>{const{resultList:o=[]}=e.data,n=[],r=[];o.forEach(e=>{const{topicID:t,errorCode:s,errorInfo:o}=e;0===s?n.push({topicID:t}):r.push({topicID:t,code:s,message:o})});const a=`success count:${n.length}, fail count:${r.length}`;return i.setMoreMessage(a).setNetworkType(this.getNetworkType()).end(),Ie.l(`${t} ok. ${a}`),n.forEach(e=>{this._deleteLocalTopic(s,e.topicID)}),ws({successTopicList:n,failureTopicList:r})}).catch(e=>(this.probeNetwork().then(([t,s])=>{i.setError(e,t,s).end()}),Ie.e(t+" failed. error:",e),Vs(e)))}updateTopicProfile(e){const t=this._n+".updateTopicProfile";if(Ie.l(t+" options:",e),e.topicName&&!1===this._filterProfanity("topicName",e))return Vs({code:$s.PROFANITY_FOUND});if(e.introduction&&!1===this._filterProfanity("introduction",e))return Vs({code:$s.PROFANITY_FOUND});if(e.notification&&!1===this._filterProfanity("notification",e))return Vs({code:$s.PROFANITY_FOUND});const s=new no("updateTopicProfile");return s.setMessage(`groupID:${e.groupID} topicID:${e.topicID}`),Pe(e.muteAllMembers)||(e.muteAllMembers=!0===e.muteAllMembers?"On":"Off"),this.request({protocolName:Ks.UPDATE_TOPIC_PROFILE,requestData:{...e}}).then(()=>(s.setNetworkType(this.getNetworkType()).end(),Ie.l(t+" ok"),this._updateTopicMap([e]),ws({topic:this.getLocalTopic(e.groupID,e.topicID)}))).catch(e=>(this.probeNetwork().then(([t,o])=>{s.setError(e,t,o).end()}),Ie.e(t+" failed. error:",e),Vs(e)))}getTopicList(e){const t=this._n+".getTopicList",{groupID:s,topicIDList:o=[]}=e,i=0===o.length,n=new no("getTopicList");if(n.setMessage("groupID:"+s),this._getTopicTimeMap.has(s)){const{isGetAll:e,time:r}=this._getTopicTimeMap.get(s);if((e||!e&&!i)&&Date.now()-r<1e3*this.TOPIC_CACHE_TIME){const e=this._getLocalTopicList(s,o);if(i||e.length===o.length)return n.setNetworkType(this.getNetworkType()).setMoreMessage("from cache, topic count:"+e.length).end(),Ie.l(`${t} groupID:${s} from cache, topic count:${e.length}`),xs({successTopicList:e,failureTopicList:[]})}}return this.request({protocolName:Ks.GET_TOPIC_LIST,requestData:{groupID:s,topicIDList:o}}).then(e=>{const{topicInfoList:o=[]}=e.data,r=[],a=[],c=[];o.forEach(e=>{const{topic:t,selfInfo:s,errorCode:o,errorInfo:i}=e,{topicID:n}=t;0===o?(r.push({...t,selfInfo:s}),a.push(n)):c.push({topicID:n,code:o,message:i})}),this._updateTopicMap(r),this._handleTopicAtInfo(r);const u=`success count:${a.length}, fail count:${c.length}`;n.setNetworkType(this.getNetworkType()).setMoreMessage(u).end(),Ie.l(`${t} groupID:${s} from remote, ${u}`);let l=[];return St(a)||(this._getTopicTimeMap.set(s,{time:Date.now(),isGetAll:i}),l=this._getLocalTopicList(s,a)),ws({successTopicList:l,failureTopicList:c})}).catch(e=>(this.probeNetwork(e).then(([t,s])=>{n.setError(e,t,s).end()}),Ie.e(t+" failed. error:",e),Vs(e)))}hasLocalTopic(e,t){return!!this._topicMap.has(e)&&this._topicMap.get(e).has(t)}getLocalTopic(e,t){let s=null;return this._topicMap.has(e)&&(s=this._topicMap.get(e).get(t)),s}_getLocalTopicList(e,t=[]){const s=this._topicMap.get(e);let o=[];return s&&(o=[...s.values()]),0===t.length?o:o.filter(e=>t.includes(e.topicID))}_deleteLocalTopic(e,t){this._topicMap.has(e)&&this._topicMap.get(e).has(t)&&(this._topicMap.get(e).delete(t),Ie.l(`${this._n}._deleteLocalTopic groupID:${e} topicID:${t}`))}_updateTopicMap(e){const s=[];if(e.forEach(e=>{const{groupID:o,topicID:i}=e;let n=null;this._topicMap.has(o)||this._topicMap.set(o,new Map);this._topicMap.get(o).has(i)?(n=this._topicMap.get(o).get(i),n.updateTopic(e)):(this._getTopicLastMessage(e),n=new Ho(e,this.isIntl()),this._topicMap.get(o).set(i,n));const r=this._computeUnreadCount(n);n.updateUnreadCount(r),s.push({conversationID:`${t.CONV_GROUP}${i}`,type:t.CONV_TOPIC,unreadCount:r})}),s.length>0){this.getModule(hs).updateTopicConversation(s)}}resetGetTopicTime(e){if(!Pe(e))return void this._getTopicTimeMap.set(e,0);[...this._getTopicTimeMap.keys()].forEach(e=>{this._getTopicTimeMap.set(e,0)})}getTopicListOnReconnected(){const e=[...this._topicMap.keys()],t=[],s=this.getModule(hs);e.forEach(e=>{const o=[],i=this._getLocalTopicList(e);s.deleteTopicRoamingMessageInfo(e),i.forEach(e=>{const{lastMessage:{lastTime:t=0}}=e;Date.now()-1e3*t<1e3*this.TOPIC_LAST_ACTIVE_TIME&&o.push(e.topicID)}),o.length>0&&t.push({groupID:e,topicIDList:o})}),Ie.l(`${this._n}.getTopicListOnReconnected. active community count:${t.length}`),this._relayGetTopicList(t)}_relayGetTopicList(e){if(0===e.length)return;const t=e.shift(),s=t.topicIDList.length>5?"topicIDList.length:"+t.topicIDList.length:"topicIDList:"+t.topicIDList,o=new no("relayGetTopicList");o.setMessage(s),Ie.l(`${this._n}._relayGetTopicList. ${s}`),this.getTopicList(t).then(()=>{o.setNetworkType(this.getNetworkType()).end(),this._relayGetTopicList(e)}).catch(t=>{this.probeNetwork().then(([e,s])=>{o.setError(t,e,s).end()}),this._relayGetTopicList(e)})}_handleTopicAtInfo(e){0!==e.length&&e.forEach(e=>{const{groupID:t,topicID:s,groupAtInfoList:o}=e,i=[];if(!Pe(o)){o.forEach(e=>{i.push({...e,groupID:t,topicID:s})});this.getModule(hs).onNewGroupAtTips({dataList:i})}})}_getTopicLastMessage(e){if(!Pe(e.lastMsg)){const t={time:e.lastMsg.time,sequence:e.lastMsg.sequence,from:e.lastMsg.from,payload:e.lastMsg.elements[0]?e.lastMsg.elements[0].content:null,type:e.lastMsg.elements[0]?e.lastMsg.elements[0].type:"",nick:e.lastMsg.nick,avatar:e.lastMsg.avatar,version:e.lastMsg.messageVersion,cloudCustomData:e.lastMsg.cloudCustomData,isRevoked:2===e.lastMsg.isPlaceMessage,revoker:St(e.lastMsg.revokerInfo)?null:e.lastMsg.revokerInfo.revoker};e.lastMessage=t}}deleteTopicListInCommunity(e){const s=this._getLocalTopicList(e),o=this.getModule(hs);s.forEach(s=>{const{topicID:i}=s;this._deleteLocalTopic(e,i),this._getTopicTimeMap.delete(e),o.deleteLocalConversation(`${t.CONV_GROUP}${i}`)})}_computeUnreadCount(e){const{excludedUnreadSequenceList:t,readedSequence:s}=e.selfInfo;let o=e.nextMessageSeq-e.selfInfo.readedSequence-1;if(Ue(t)){let i=0;t.forEach(t=>{t>=s&&t<=e.nextMessageSeq-1&&(i+=1)}),i>=1&&(o-=i)}return o<0?0:o}_filterProfanity(e,t){const s=this.getModule(Rs);if(!s)return!0;const{isAllowedToSend:o,modifiedText:i}=s.filterText(t[e],y);return!0===o&&(t[e]=i,!0)}updateLastMessage(t,s){const o=ht(t),i=this.getLocalTopic(o,t);if(i){const t=s.sequence+1;i.updateNextMessageSeq(t),i.updateLastMessage(s),this.emitOuterEvent(e.TOPIC_UPDATED,{groupID:o,topic:i})}}getMessageExtensions(e,t){Ie.l(`${this._n}.getMessageExtensions startSequence:${t}`);const s=ht(e.to);return this.request({protocolName:Ks.GET_GROUP_MESSAGE_EXTENSIONS,requestData:{groupID:s,topicID:e.to,messageSequence:e.sequence,startSequence:t}})}modifyMessageExtensions(e,t,s=1){Ie.l(`${this._n}.modifyMessageExtensions operateType:${s}`);const o=ht(e.to);return this.request({protocolName:Ks.MODIFY_GROUP_MESSAGE_EXTENSIONS,requestData:{groupID:o,topicID:e.to,messageSequence:e.sequence,extensionList:t,operateType:s}})}reset(){Ie.l(this._n+".reset"),this._topicMap.clear(),this._getTopicTimeMap.clear(),this.TOPIC_CACHE_TIME=300,this.TOPIC_LAST_ACTIVE_TIME=3600}}class Wo{constructor(e){this._userModule=e,this._n="ProfileHandler",this.TAG="profile",this.accountProfileMap=new Map,this.expirationTime=864e5}setExpirationTime(e){this.expirationTime=e}getUserProfile(e){const t=this._n+".getUserProfile",s=e.userIDList;e.fromAccount=this._userModule.getMyAccount(),s.length>100&&(Ie.w(`${t} ${It(100)}`),s.length=100);const o=[],i=[];let n;for(let u=0,l=s.length;u<l;u++)n=s[u],this._userModule.isMyFriend(n)&&this._contains(n)?i.push(this._getProfileFromMap(n)):o.push(n);if(0===o.length)return xs(i);e.toAccount=o;const r=e.bFromGetMyProfile||!1,a=[];e.toAccount.forEach(e=>{a.push({toAccount:e,standardSequence:0,customSequence:0})}),e.userItem=a;const c=new no("getUserProfile");c.setMessage(s.length>5?"userIDList.length:"+s.length:"userIDList:"+s);return this._userModule.request({protocolName:Ks.GET_USER_PROFILE,requestData:e}).then(e=>{c.setNetworkType(this._userModule.getNetworkType()).end(),Ie.i(t+" ok");const s=this._handleResponse(e).concat(i);return ws(r?s[0]:s)}).catch(e=>(this._userModule.probeNetwork().then(([t,s])=>{c.setError(e,t,s).end()}),Ie.e(t+" failed. error:",e),Vs(e)))}getMyProfile(){const e=this._userModule.getMyAccount(),t=this._n+".getMyProfile";if(Ie.l(`${t} myAccount:${e}`),this._fill(),this._contains(e)){const s=this._getProfileFromMap(e);return Ie.d(`${t} from cache, myProfile:${JSON.stringify(s)}`),xs(s)}return this.getUserProfile({fromAccount:e,userIDList:[e],bFromGetMyProfile:!0})}_handleResponse(e){const{userProfileItem:t}=e.data;if(!Ue(t))return[];const s=[],o=Date.now();for(let i=0,n=t.length;i<n;i++){const{to:e,profileItem:o}=t[i];if("@TLS#NOT_FOUND"===e||""===e)continue;const{latestProfile:n}=this._update(e,this._getLatestProfileFromResponse(e,o));s.push(n)}return Ie.l(`${this._n}._handleResponse cost:${Tt(o)}`),s}_getLatestProfileFromResponse(e,t){const s={userID:e,profileCustomField:[]};if(!St(t))for(let o=0,i=t.length;o<i;o++)if(t[o].tag.indexOf("Tag_Profile_Custom")>-1)s.profileCustomField.push({key:t[o].tag,value:t[o].value});else switch(t[o].tag){case Te.NICK:s.nick=t[o].value;break;case Te.GENDER:s.gender=t[o].value;break;case Te.BIRTHDAY:s.birthday=t[o].value;break;case Te.LOCATION:s.location=t[o].value;break;case Te.SELFSIGNATURE:s.selfSignature=t[o].value;break;case Te.ALLOWTYPE:s.allowType=t[o].value;break;case Te.LANGUAGE:s.language=t[o].value;break;case Te.AVATAR:s.avatar=t[o].value;break;case Te.MESSAGESETTINGS:s.messageSettings=t[o].value;break;case Te.ADMINFORBIDTYPE:s.adminForbidType=t[o].value;break;case Te.LEVEL:s.level=t[o].value;break;case Te.ROLE:s.role=t[o].value;break;default:Ie.w(this._n+"._getLatestProfileFromResponse unknown tag:",t[o].tag,t[o].value)}return s}updateMyProfile(t){const s=this._n+".updateMyProfile";if(t.nick&&!1===this._userModule.filterProfanity("nick",t))return Vs({code:$s.PROFANITY_FOUND});if(t.selfSignature&&!1===this._userModule.filterProfanity("selfSignature",t))return Vs({code:$s.PROFANITY_FOUND});const o=new no("updateMyProfile");o.setMessage(JSON.stringify(t));const i=(new Po).validate(t);if(!i.valid)return o.setCode($s.UPDATE_PROFILE_INVALID_PARAM).setMoreMessage("info:"+i.tips).setNetworkType(this._userModule.getNetworkType()).end(),Ie.e(`${s} info:${i.tips}`),Vs({code:$s.UPDATE_PROFILE_INVALID_PARAM});const n=[];for(const e in t)Object.prototype.hasOwnProperty.call(t,e)&&("profileCustomField"===e?t.profileCustomField.forEach(e=>{n.push({tag:e.key,value:e.value})}):n.push({tag:Te[e.toUpperCase()],value:t[e]}));if(0===n.length){const e=new Fs({code:$s.UPDATE_PROFILE_NO_KEY});return o.setError(e,!0,this._userModule.getNetworkType()).end(),Ie.e(s+" failed. error:",e),Vs(e)}const r=this._userModule.getMyAccount();return this._userModule.request({protocolName:Ks.UPDATE_MY_PROFILE,requestData:{fromAccount:r,profileItem:n}}).then(i=>{o.setNetworkType(this._userModule.getNetworkType()).end(),Ie.i(s+" ok");const{isProfileUpdated:n,latestProfile:a}=this._update(r,t);return!0===n&&this._userModule.emitOuterEvent(e.PROFILE_UPDATED,[a]),xs(a)}).catch(e=>(this._userModule.probeNetwork().then(([t,s])=>{o.setError(e,t,s).end()}),Ie.e(s+" failed. error:",e),Vs(e)))}onProfileModified(t){const s=t.dataList;if(St(s))return;const o=s.length;let i;Ie.d(`${this._n}.onProfileModified count:${o} dataList:`,t.dataList);const n=[];for(let e=0;e<o;e++){i=s[e].userID;const{isProfileUpdated:t,latestProfile:o}=this._update(i,this._getLatestProfileFromResponse(i,s[e].profileList));!0===t&&n.push(o)}n.length>0&&(this._userModule.emitInnerEvent(Do.PROFILE_UPDATED,n),this._userModule.emitOuterEvent(e.PROFILE_UPDATED,n))}_fill(){if(0===this.accountProfileMap.size){const e=this._getCachedProfiles(),t=Date.now();for(let s=0,o=e.length;s<o;s++)t-e[s].lastUpdatedTime<this.expirationTime&&this.accountProfileMap.set(e[s].userID,e[s]);Ie.l(`${this._n}._fill from cache, size:${this.accountProfileMap.size}`)}}_update(e,t){let s,o=!1;const i=Date.now();if(this._contains(e)){s=this._getProfileFromMap(e),t.profileCustomField&&!0===je(s.profileCustomField,t.profileCustomField)&&(s.lastUpdatedTime=i,o=!0);qe(s,t,["profileCustomField"])>0&&(s.lastUpdatedTime=i,o=!0)}else s=new Po(t),(this._userModule.isMyFriend(e)||e===this._userModule.getMyAccount())&&(s.lastUpdatedTime=i,o=!0,this.accountProfileMap.set(e,s));return this._flush(e===this._userModule.getMyAccount()),!0===o&&Ie.l(`${this._n}._update account:${e} isProfileUpdated:${o}`),{isProfileUpdated:o,latestProfile:s}}_flush(e){const t=[...this.accountProfileMap.values()],s=this._userModule.getStorageModule();Ie.d(`${this._n}._flush length:${t.length} flushAtOnce:${e}`),s.setItem(this.TAG,t,e)}_contains(e){return this.accountProfileMap.has(e)}_getProfileFromMap(e){return this.accountProfileMap.get(e)}_getCachedProfiles(){const e=this._userModule.getStorageModule().getItem(this.TAG);return St(e)?[]:e}onConversationsProfileUpdated(e){let t,s;const o=[];let i;for(let n=0,r=e.length;n<r;n++)t=e[n],s=t.userID,this._userModule.isMyFriend(s)&&(this._contains(s)?(i=this._getProfileFromMap(s),qe(i,t)>0&&o.push(s)):o.push(t.userID));0!==o.length&&(Ie.i(`${this._n}.onConversationsProfileUpdated toAccountList:${o}`),this.getUserProfile({userIDList:o}))}getNickAndAvatarByUserID(e){if(this._contains(e)){const t=this._getProfileFromMap(e);return{nick:t.nick,avatar:t.avatar}}return{nick:"",avatar:""}}getUserNickAndAvatar(e){const t=[...new Set(e)];Ie.l(`${this._n}.getUserNickAndAvatar userIDList.length:${e.length} uniqueUserIDList.length:${t.length}`);const s=[];if(0===e.length)return Promise.resolve(s);const o=this._createUserIDListGroup(t),i=[];return o.forEach(e=>{i.push(this.getUserProfile({userIDList:e}))}),Promise.all(i).then(e=>(e.forEach(e=>{const t=e.data.map(({userID:e,nick:t,avatar:s})=>({userID:e,nick:t,avatar:s}));s.push(...t)}),s))}_createUserIDListGroup(e){const t=[];let s=0;for(;s<e.length;)t.push(e.slice(s,s+=100));return t}reset(){this._flush(!0),this.accountProfileMap.clear()}}class zo{constructor(e){St||(this.userID=e.userID||"",this.timeStamp=e.timeStamp||0)}}class jo{constructor(e){this._userModule=e,this._n="BlacklistHandler",this._blacklistMap=new Map,this.startIndex=0,this.maxLimited=100,this.currentSequence=0}getLocalBlacklist(){return[...this._blacklistMap.keys()]}getBlacklist(){const t=this._n+".getBlacklist",s={fromAccount:this._userModule.getMyAccount(),maxLimited:this.maxLimited,startIndex:0,lastSequence:this.currentSequence},o=new no("getBlacklist");return this._userModule.request({protocolName:Ks.GET_BLACKLIST,requestData:s}).then(s=>{const{blackListItem:i,currentSequence:n}=s.data,r=St(i)?0:i.length;o.setNetworkType(this._userModule.getNetworkType()).setMessage("count:"+r).end(),Ie.i(t+" ok"),this.currentSequence=n,this._handleResponse(i,!0),this._userModule.emitOuterEvent(e.BLACKLIST_UPDATED,[...this._blacklistMap.keys()])}).catch(e=>(this._userModule.probeNetwork().then(([t,s])=>{o.setError(e,t,s).end()}),Ie.e(t+" failed. error:",e),Vs(e)))}addBlacklist(e){const t=new no("addToBlacklist"),s=this._n+".addBlacklist",o=this._userModule.getMyAccount();if(1===e.userIDList.length&&e.userIDList[0]===o){const e=$s.CANNOT_ADD_SELF_TO_BLACKLIST,o=this._userModule.getErrorMessage(e);t.setCode(e).setMessage(o).setNetworkType(this._userModule.getNetworkType()).end();const i=new Fs({code:e});return Ie.e(s+" failed. error:",i),Vs(i)}e.userIDList.includes(o)&&(e.userIDList=e.userIDList.filter(e=>e!==o)),e.fromAccount=this._userModule.getMyAccount(),e.toAccount=e.userIDList;return this._userModule.request({protocolName:Ks.ADD_TO_BLACKLIST,requestData:e}).then(o=>(t.setNetworkType(this._userModule.getNetworkType()).setMessage(e.userIDList.length>5?"userIDList.length:"+e.userIDList.length:"userIDList:"+e.userIDList).end(),Ie.i(s+" ok"),this._handleResponse(o.resultItem,!0),ws([...this._blacklistMap.keys()]))).catch(e=>(this._userModule.probeNetwork().then(([s,o])=>{t.setError(e,s,o).end()}),Ie.e(s+" failed. error:",e),Vs(e)))}_handleResponse(e,t){if(!St(e)){let s,o,i;for(let n=0,r=e.length;n<r;n++)o=e[n].to,i=e[n].resultCode,(Pe(i)||0===i)&&(t?(s=this._blacklistMap.has(o)?this._blacklistMap.get(o):new zo,s.userID=o,!St(e[n].addBlackTimeStamp)&&(s.timeStamp=e[n].addBlackTimeStamp),this._blacklistMap.set(o,s)):this._blacklistMap.has(o)&&(s=this._blacklistMap.get(o),this._blacklistMap.delete(o)))}Ie.l(`${this._n}._handleResponse total:${this._blacklistMap.size} bAdd:${t}`)}deleteBlacklist(e){const t=this._n+".deleteBlacklist",s=new no("removeFromBlacklist");e.fromAccount=this._userModule.getMyAccount(),e.toAccount=e.userIDList;return this._userModule.request({protocolName:Ks.REMOVE_FROM_BLACKLIST,requestData:e}).then(o=>(s.setNetworkType(this._userModule.getNetworkType()).setMessage(e.userIDList.length>5?"userIDList.length:"+e.userIDList.length:"userIDList:"+e.userIDList).end(),Ie.i(t+" ok"),this._handleResponse(o.data.resultItem,!1),ws([...this._blacklistMap.keys()]))).catch(e=>(this._userModule.probeNetwork().then(([t,o])=>{s.setError(e,t,o).end()}),Ie.e(t+" failed. error:",e),Vs(e)))}onAccountDeleted(t){for(let e=0,o=t.length;e<o;e++){const s=t[e];this._blacklistMap.has(s)&&this._blacklistMap.delete(s)}const s=t.length;s>0&&(Ie.l(`${this._n}.onAccountDeleted count:${s} ${s<30?"userIDList:"+t:""}`),this._userModule.emitOuterEvent(e.BLACKLIST_UPDATED,[...this._blacklistMap.keys()]))}onAccountAdded(t){const s=[];let o;for(let e=0,i=t.length;e<i;e++)o=t[e],this._blacklistMap.has(o)||(this._blacklistMap.set(o,new zo({userID:o})),s.push(o));s.length>0&&(Ie.l(`${this._n}.onAccountAdded count:${s.length} userIDList:`,s),this._userModule.emitOuterEvent(e.BLACKLIST_UPDATED,[...this._blacklistMap.keys()]))}reset(){this._blacklistMap.clear(),this.startIndex=0,this.maxLimited=100,this.currentSequence=0}}const Jo=function(e){const t=String(e).replace(/[=]+$/,"");let s="";if(t.length%4==1)return"";for(let i,n,r=0,a=0;n=t.charAt(a++);~n&&(i=r%4?64*i+n:n,r++%4)?s+=String.fromCharCode(255&i>>(-2*r&6)):0)n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(n);try{return decodeURIComponent(escape(s))}catch(o){return""}};class Xo{constructor(e){this._userModule=e,this._n="UserStatusHandler",this.MAX_QUERY_USER_COUNT=500,this.MAX_SUBSCRIBE_USER_COUNT=100,this.MAX_UNSUBSCRIBE_USER_COUNT=100;this._userModule.getInnerEmitterInstance().on(Do.CLOUD_CONFIG_UPDATED,this._onCloudConfigUpdated,this)}_onCloudConfigUpdated(){const e=this._userModule.getCloudConfig("status_query_count"),t=this._userModule.getCloudConfig("status_sub_count"),s=this._userModule.getCloudConfig("status_unsub_count");Ie.l(`${this._n}._onCloudConfigUpdated statusQueryCount:${e} statusSubscribeCount:${t} statusUnsubscribeCount:`+s),Pe(e)||(this.MAX_QUERY_USER_COUNT=parseInt(e,10)),Pe(e)||(this.MAX_SUBSCRIBE_USER_COUNT=parseInt(t,10)),Pe(e)||(this.MAX_UNSUBSCRIBE_USER_COUNT=parseInt(s,10))}onUserStatusUpdated(t){const{dataList:s}=t,o=this._userModule.getMyUserID(),i=this._userModule.getModule(gs),n=s.map(e=>{const{to:t,statusType:s,customStatus:n}=e,r=Jo(n);return t===o&&i.setCustomStatus(r),{userID:t,statusType:s,customStatus:r}});this._userModule.emitOuterEvent(e.USER_STATUS_UPDATED,n)}setSelfStatus(e){const t=this._n+".setSelfStatus";if(!1===this._userModule.filterProfanity("customStatus",e))return Vs({code:$s.PROFANITY_FOUND});const s=new no("setSelfStatus"),{customStatus:o}=e;return this._userModule.request({protocolName:Ks.SET_SELF_STATUS,requestData:{customStatus:o}}).then(e=>{s.setNetworkType(this._userModule.getNetworkType()).setMessage("customStatus:"+o).end(),Ie.l(`${t} ok. customStatus:${o}`);return this._userModule.getModule(gs).setCustomStatus(o),ws({userID:this._userModule.getMyUserID(),statusType:1,customStatus:o})}).catch(e=>(this._userModule.probeNetwork().then(([t,o])=>{s.setError(e,t,o).end()}),Ie.e(t+" failed. error:",e),Vs(e)))}getUserStatus(e){const t=this._n+".getUserStatus",{userIDList:s=[]}=e,o=this._userModule.getMyUserID();let i=[...s],n=void 0;const r=i.indexOf(o);if(r>-1){i.splice(r,1);const e=this._userModule.getModule(gs).getCustomStatus();n={userID:o,statusType:1,customStatus:e}}if(0===i.length)return xs({successUserList:[n],failureUserList:[]});if(!this._userModule.canIUse(I.USER_STATUS))return this._userModule.cannotUseCommercialAbility("getUserStatus");i.length>this.MAX_QUERY_USER_COUNT&&(Ie.w(`${t} ${It(this.MAX_QUERY_USER_COUNT)}`),i=s.slice(0,this.MAX_QUERY_USER_COUNT));const a=new no("getUserStatus");return this._userModule.request({protocolName:Ks.GET_USER_STATUS,requestData:{userIDList:i}}).then(e=>{const{successUserList:o=[],failureUserList:i=[]}=e.data,r=o.map(e=>{const{userID:t,statusType:s,customStatus:o}=e;return{userID:t,statusType:s,customStatus:Jo(o)}}),c=i.map(e=>{const{userID:t,invalidUserID:s,errorCode:o,errorInfo:i}=e;return{userID:St(s)?t:s,code:o,message:i}});Pe(n)||r.unshift(n);const u=`userID count:${s.length}, success count:${r.length}, fail count:${c.length}`;return a.setNetworkType(this._userModule.getNetworkType()).setMessage(""+u).end(),Ie.l(`${t} ok. ${u}.`),ws({successUserList:r,failureUserList:c})}).catch(e=>(this._userModule.probeNetwork().then(([t,o])=>{a.setMessage("userID count:"+s.length).setError(e,t,o).end()}),Ie.e(t+" failed. error:",e),Vs(e)))}subscribeUserStatus(e){const t="subscribeUserStatus";if(!this._userModule.canIUse(I.USER_STATUS))return this._userModule.cannotUseCommercialAbility(t);const s=`${this._n}.${t}`,{userIDList:o=[]}=e;let i=[...o];i.length>this.MAX_SUBSCRIBE_USER_COUNT&&(Ie.w(`${s} ${It(this.MAX_SUBSCRIBE_USER_COUNT)}`),i=o.slice(0,this.MAX_SUBSCRIBE_USER_COUNT));const n=new no(t),r="userID count:"+o.length;return Ie.l(`${s} ${r}`),this._userModule.request({protocolName:Ks.SUBSCRIBE_USER_STATUS,requestData:{userIDList:i}}).then(e=>{const{failureUserList:t=[]}=e.data,o=t.map(e=>{const{userID:t,invalidUserID:s,errorCode:o,errorInfo:i}=e;return{userID:St(s)?t:s,code:o,message:i}});return n.setNetworkType(this._userModule.getNetworkType()).setMessage(`${r} fail count:${o.length}`).end(),Ie.l(`${s} ok. fail count:${o.length}.`),ws({failureUserList:o})}).catch(e=>(this._userModule.probeNetwork().then(([t,s])=>{n.setMessage(""+r).setError(e,t,s).end()}),Ie.e(s+" failed. error:",e),Vs(e)))}unsubscribeUserStatus(e){const t="unsubscribeUserStatus";if(!this._userModule.canIUse(I.USER_STATUS))return this._userModule.cannotUseCommercialAbility(t);const s=`${this._n}.${t}`,{userIDList:o=[]}=e||{};let i=[...o];o.length>this.MAX_UNSUBSCRIBE_USER_COUNT&&(Ie.w(`${s} ${It(this.MAX_UNSUBSCRIBE_USER_COUNT)}`),i=o.slice(0,this.MAX_UNSUBSCRIBE_USER_COUNT));const n=new no(t),r="userID count:"+o.length;Ie.l(`${s} ${r}`);const a={userIDList:i};return 0===i.length&&(a.userIDList=void 0,a.unsubscribeAll=1),this._userModule.request({protocolName:Ks.UNSUBSCRIBE_USER_STATUS,requestData:a}).then(e=>{const{failureUserList:t=[]}=e.data,o=t.map(e=>{const{userID:t,invalidUserID:s,errorCode:o,errorInfo:i}=e;return{userID:St(s)?t:s,code:o,message:i}});return n.setNetworkType(this._userModule.getNetworkType()).setMessage(`${r} fail count:${o.length}`).end(),Ie.l(`${s} ok. fail count:${o.length}.`),ws({failureUserList:o})}).catch(e=>(this._userModule.probeNetwork().then(([t,s])=>{n.setMessage(""+r).setError(e,t,s).end()}),Ie.e(s+" failed. error:",e),Vs(e)))}reset(){this.MAX_QUERY_USER_COUNT=500,this.MAX_SUBSCRIBE_USER_COUNT=100,this.MAX_UNSUBSCRIBE_USER_COUNT=100}}class Qo extends Bs{constructor(e){super(e),this._n="UserModule",this._profileHandler=new Wo(this),this._blacklistHandler=new jo(this),this._userStatusHandler=new Xo(this);this.getInnerEmitterInstance().on(Do.A2KEY_AND_TINYID_UPDATED,this.onContextUpdated,this)}onContextUpdated(e){this._profileHandler.getMyProfile(),this._blacklistHandler.getBlacklist()}mockOnNickAvatarModified(e,t){Ie.l(`${this._n}._mockOnNickAvatarModified nick:${e} avatar:${t}`),this.onProfileModified({dataList:[{pushType:1,userID:this.getMyUserID(),profileList:[{tag:Te.NICK,value:e},{tag:Te.AVATAR,value:t}]}]})}onProfileModified(e){this._profileHandler.onProfileModified(e)}onRelationChainModified(e){const{dataList:t}=e;if(St(t))return;const s=[];t.forEach(e=>{e.blackListDelAccount&&s.push(...e.blackListDelAccount)}),s.length>0&&this._blacklistHandler.onAccountDeleted(s);const o=[];t.forEach(e=>{e.blackListAddAccount&&o.push(...e.blackListAddAccount)}),o.length>0&&this._blacklistHandler.onAccountAdded(o)}onConversationsProfileUpdated(e){this._profileHandler.onConversationsProfileUpdated(e)}getMyAccount(){return this.getMyUserID()}getMyNick(){return this._profileHandler.getNickAndAvatarByUserID(this.getMyUserID()).nick}getMyProfile(){return this._profileHandler.getMyProfile()}getStorageModule(){return this.getModule(ms)}filterProfanity(e,t){const s=this.getModule(Rs);if(!s)return!0;const{isAllowedToSend:o,modifiedText:i}=s.filterText(t[e],S);return!0===o&&(t[e]=i,!0)}isMyFriend(e){const t=this.getModule(_s);return!!t&&t.isMyFriend(e)}getUserProfile(e){return this._profileHandler.getUserProfile(e)}updateMyProfile(e){return this._profileHandler.updateMyProfile(e)}getNickAndAvatarByUserID(e){return this._profileHandler.getNickAndAvatarByUserID(e)}getUserNickAndAvatar(e){return this._profileHandler.getUserNickAndAvatar(e)}getLocalBlacklist(){const e=this._blacklistHandler.getLocalBlacklist();return xs(e)}addBlacklist(e){return this._blacklistHandler.addBlacklist(e)}deleteBlacklist(e){return this._blacklistHandler.deleteBlacklist(e)}onUserStatusUpdated(e){this._userStatusHandler.onUserStatusUpdated(e)}setSelfStatus(e){return this._userStatusHandler.setSelfStatus(e)}getUserStatus(e){return this._userStatusHandler.getUserStatus(e)}subscribeUserStatus(e){return this._userStatusHandler.subscribeUserStatus(e)}unsubscribeUserStatus(e){return this._userStatusHandler.unsubscribeUserStatus(e)}reset(){Ie.l(this._n+".reset"),this._profileHandler.reset(),this._blacklistHandler.reset(),this._userStatusHandler.reset()}}class Zo{constructor(e,t){this._m=e,this._isLoggedIn=!1,this._SDKAppID=t.SDKAppID,this._userID=t.userID||"",this._userSig=t.userSig||"",this._version="3.2.3",this._a2Key="",this._tinyID="",this._customStatus="",this._contentType="json",this._unlimitedAVChatRoom=t.unlimitedAVChatRoom,this._scene=t.scene||"",this._oversea=t.oversea,this._instanceID=t.instanceID,this._statusInstanceID=0,this._isDevMode=t.devMode,this._proxyServer=t.proxyServer,this._fileUploadProxy=t.fileUploadProxy,this._fileDownloadProxy=t.fileDownloadProxy,this._applicationID=0,this._isUsingChatCore=!1}isLoggedIn(){return this._isLoggedIn}isOversea(){return this._oversea}isPrivateNetWork(){return this._proxyServer}isDevMode(){return this._isDevMode}isSingaporeSite(){return this._SDKAppID>=2e7&&this._SDKAppID<3e7||this._SDKAppID>=172e7&&this._SDKAppID<173e7}isKoreaSite(){return this._SDKAppID>=3e7&&this._SDKAppID<4e7||this._SDKAppID>=173e7&&this._SDKAppID<174e7}isGermanySite(){return this._SDKAppID>=4e7&&this._SDKAppID<5e7||this._SDKAppID>=174e7&&this._SDKAppID<175e7}isIndiaSite(){return this._SDKAppID>=5e7&&this._SDKAppID<6e7||this._SDKAppID>=175e7&&this._SDKAppID<176e7}isJapanSite(){return this._SDKAppID>=6e7&&this._SDKAppID<7e7||this._SDKAppID>=176e7&&this._SDKAppID<177e7}isUSASite(){return this._SDKAppID>=7e7&&this._SDKAppID<8e7||this._SDKAppID>=177e7&&this._SDKAppID<178e7}isIndonesiaSite(){return this._SDKAppID>=8e7&&this._SDKAppID<9e7||this._SDKAppID>=178e7&&this._SDKAppID<179e7}isIntl(){return 0===(e=this._SDKAppID)||e>=2e7&&e<9e7||e>=172e7&&e<179e7;var e}isUnlimitedAVChatRoom(){return this._unlimitedAVChatRoom}isUsingChatCore(){return this._isUsingChatCore}setUsingChatCore(e){this._isUsingChatCore=e}setUserID(e){this._userID=e}getUserID(){return this._userID}setUserSig(e){this._userSig=e}getUserSig(){return this._userSig}getSDKAppID(){return this._SDKAppID}setTinyID(e){this._tinyID=e,this._isLoggedIn=!0}getTinyID(){return this._tinyID}setCustomStatus(e){this._customStatus=e}getCustomStatus(){return this._customStatus}getScene(){return oe?window.tencent_cloud_im_csig_flutter_for_web_25F_cy:this._isTUIKit()?"tuikit":this._scene}getInstanceID(){return this._instanceID}getStatusInstanceID(){return this._statusInstanceID}setStatusInstanceID(e){this._statusInstanceID=e}getVersion(){return this._version}getA2Key(){return this._a2Key}setA2Key(e){this._a2Key=e}getContentType(){return this._contentType}getProxyServer(){return this._proxyServer}getFileUploadProxy(){return this._fileUploadProxy}getFileDownloadProxy(){return this._fileDownloadProxy}setApplicationID(e){this._applicationID=e}getApplicationID(){return this._applicationID}_isTUIKit(){let e=!1,t=!1,s=!1,o=!1,i=[];G&&(i=Object.keys(w)),k&&(i=P?Object.keys(uni):Object.keys(window));for(let r=0,a=i.length;r<a;r++)if(i[r].toLowerCase().includes("uikit")){e=!0;break}if(i=null,G&&!ke(w.createGamePortal)&&ke(getApp)&&!Pe(getApp())){const e=getApp().globalData;Le(e)&&!0===e.isTUIKit&&(t=!0)}!0===this._m.getModule(ms).getStorageSync(`TIM_${this._SDKAppID}_isTUIKit`)&&(s=!0);let n=null;if(D&&!A&&"undefined"==typeof uni&&__wxConfig&&(n=__wxConfig.pages),v&&"undefined"==typeof uni&&__qqConfig&&(n=__qqConfig.pages),Ue(n)&&n.length>0){for(let e=0,t=n.length;e<t;e++)if(n[e].toLowerCase().includes("tui")){o=!0;break}n=null}return e||t||s||o}reset(){this._isLoggedIn=!1,this._userSig="",this._a2Key="",this._tinyID="",this._customStatus="",this._statusInstanceID=0}}const ei={"k-vue2-pc":1,"k-vue2-h5":2,"k-vue2-h5-uni":3,"k-vue2-app-uni":4,"k-vue2-mp-uni":5,"k-vue2-pc-uni":6,"k-vue3-pc":7,"k-vue3-h5":8,"k-vue3-h5-uni":9,"k-vue3-app-uni":10,"k-vue3-mp-uni":11,"k-vue3-pc-uni":12};class ti extends Bs{constructor(e){super(e),this._n="SignModule",this._helloInterval=120,this._lastLoginTs=0,this._lastWsHelloTs=0,this._isWebUniapp=0,No.mixin(this)}onCheckTimer(e){this.isLoggedIn()&&e%this._helloInterval==0&&this._hello()}login(e){let t="";if(this.isLoggedIn()){const e=this.getMyUserID();return t=this.getErrorMessage("RepeatLogin",e),t&&Ie.w(t),xs({actionStatus:"OK",errorCode:0,errorInfo:t,repeatLogin:!0})}if(Date.now()-this._lastLoginTs<=15e3)return this.outputWarning("LoggingIn",e.userID),Vs({code:$s.REPEAT_LOGIN});Ie.l(`${this._n}.login userID:${e.userID}`);const s=this._checkLoginInfo(e);if(0!==s.code)return Vs(s);const o=this.getModule(gs),{userID:i,userSig:n}=e;o.setUserID(i),o.setUserSig(n);return this.getModule(Es).updateProtocolConfig(),this._login()}_login(){const e=this.getModule(gs);let t=e.getScene(),s=0,o=t;t&&t.startsWith("k-")&&(o=ei[t],t="tuikit");const i=new no("login");i.setMessage(""+o).setMoreMessage("identifier:"+this.getMyUserID());const n="tuikit"===t;P?n?3===o||4===o||5===o||6===o?i.setUIPlatform(31):9===o||10===o||11===o||12===o?i.setUIPlatform(32):i.setUIPlatform(4):i.setUIPlatform(3):G?"tuikit"===t?i.setUIPlatform(12):i.setUIPlatform(11):k&&(oe?"flutter_web_uikit"===t?i.setUIPlatform(21):i.setUIPlatform(20):this._isReactUIKit()?se?i.setUIPlatform(25):i.setUIPlatform(24):n?1===o||2===o?i.setUIPlatform(29):7===o||8===o?i.setUIPlatform(30):se?i.setUIPlatform(17):i.setUIPlatform(14):se?i.setUIPlatform(16):i.setUIPlatform(13));const r=this.getModule(Os);if(r.canIUseOfflinePush()){this._isWebUniapp=r.getUniAppPlatform();const t=this._getStatusInstanceID();e.setStatusInstanceID(t);this.getModule(Es).updateProtocolConfig(),s=r.getDeviceBrand()}const a=this._n+"._login";return this._lastLoginTs=Date.now(),this.request({protocolName:Ks.LOGIN,requestData:{deviceBrand:s,isWebUniapp:this._isWebUniapp}}).then(s=>{this._lastLoginTs=0;const o=Date.now();let n=null;const{a2Key:r,tinyID:c,helloInterval:u,instanceID:l,timeStamp:d,customStatus:_="",purchaseBits:p}=s.data,h=1e3*d,g=o-i.getStartTs(),m=h+parseInt(g/2)-o,M=i.getStartTs()+m;if(i.start(M),function(e,t){de=t;const s=new Date;s.setTime(e),Ie.i(`baseTime from server:${s} offset:${de}`)}(h,m),!c)throw n=new Fs({code:$s.NO_TINYID}),i.setError(n,!0,this.getNetworkType()).end(),n;if(!r)throw n=new Fs({code:$s.NO_A2KEY}),i.setError(n,!0,this.getNetworkType()).end(),n;const I=Jo(_),f=`scene:${t} helloInterval:${u} instanceID:${l} timeStamp:${d} offset:${m} customStatus:${I} `;Ie.l(`${a} ok. ${f}`);let T="",C="";if(D&&ke(w.getAccountInfoSync)){const e=w.getAccountInfoSync().miniProgram;e&&(T=e.appId,C=e.envVersion)}if(i.setNetworkType(this.getNetworkType()).setMoreMessage(`${f} href:${k?window.location.href:""} mpAppId:${T} envVersion:${C}`).end(),e.setA2Key(r),e.setTinyID(c),e.setStatusInstanceID(l),e.setCustomStatus(I),p){this.getModule(As).onPushedConfig({errorCode:0,expiredTime:0,purchaseBits:p})}this.getModule(Es).updateProtocolConfig(),this.emitInnerEvent(Do.A2KEY_AND_TINYID_UPDATED),this._helloInterval=u,this.triggerReady();const E=this.getModule(Os);E.canIUseOfflinePush()&&(uni.setStorageSync("timUniAppInstanceID",l),E.init()),this._fetchCloudControlConfig();return this.getModule(Rs).init(),s}).catch(e=>(this.probeNetwork().then(([t,s])=>{i.setError(e,t,s).end(!0)}),this._m.setNotReadyReason($s.LOGIN_FAILED),Ie.e(a+" failed. error:",e),this._lastLoginTs=0,this._m.onLoginFailed(),Vs(e)))}logout(e=0){if(!this.isLoggedIn())return Vs({code:$s.USER_NOT_LOGGED_IN});new no("logout").setNetworkType(this.getNetworkType()).setMessage("identifier:"+this.getMyUserID()).end(!0);const t=this._n+".logout";return Ie.i(`${t} type:${e}`),0===e&&this._m.setNotReadyReason($s.LOGGED_OUT),this.request({protocolName:Ks.LOGOUT,requestData:{type:e}}).then(()=>(this.resetReady(),xs({}))).catch(e=>(Ie.e(t+" error:",e),this.resetReady(),xs({})))}getLoginUser(){return this.isLoggedIn()?this.getMyUserID():""}_fetchCloudControlConfig(){this.getModule(ys).fetchConfig()}_getStatusInstanceID(){return uni.getStorageSync("timUniAppInstanceID")}_hello(){this._lastWsHelloTs=Date.now(),this.request({protocolName:Ks.HELLO,requestData:{isWebUniapp:this._isWebUniapp}}).catch(e=>{Ie.w(this._n+"._hello error:",e)})}getLastWsHelloTs(){return this._lastWsHelloTs}_checkLoginInfo(e){let t=0;return St(this.getModule(gs).getSDKAppID())?t=$s.NO_SDKAPPID:St(e.userID)?t=$s.NO_IDENTIFIER:St(e.userSig)&&(t=$s.NO_USERSIG),{code:t}}_isReactUIKit(){return k&&void 0!==window.tencent_cloud_im_csig_react_uikit_23F_xa}onMultipleAccountKickedOut(s){new no("kickedOut").setNetworkType(this.getNetworkType()).setMessage(`type:${t.KICKED_OUT_MULT_ACCOUNT} newInstanceInfo:${JSON.stringify(s)}`).end(!0),Ie.w(`${this._n}.onMultipleAccountKickedOut userID:${this.getMyUserID()} newInstanceInfo:`,s),this.logout(1).then(()=>{this.emitOuterEvent(e.KICKED_OUT,{type:t.KICKED_OUT_MULT_ACCOUNT}),this._m.setNotReadyReason($s.KICKED_OUT_MULT_ACCOUNT),this._m.reset()})}onMultipleDeviceKickedOut(s){new no("kickedOut").setNetworkType(this.getNetworkType()).setMessage(`type:${t.KICKED_OUT_MULT_DEVICE} newInstanceInfo:${JSON.stringify(s)}`).end(!0),Ie.w(`${this._n}.onMultipleDeviceKickedOut userID:${this.getMyUserID()} newInstanceInfo:`,s),this.logout(1).then(()=>{this.emitOuterEvent(e.KICKED_OUT,{type:t.KICKED_OUT_MULT_DEVICE}),this._m.setNotReadyReason($s.KICKED_OUT_MULT_DEVICE),this._m.reset()})}onUserSigExpired(){new no("kickedOut").setNetworkType(this.getNetworkType()).setMessage(t.KICKED_OUT_USERSIG_EXPIRED).end(!0),Ie.w(`${this._n}.onUserSigExpired userID:${this.getMyUserID()}`);0!==this.getModule(gs).getStatusInstanceID()&&(this.emitOuterEvent(e.KICKED_OUT,{type:t.KICKED_OUT_USERSIG_EXPIRED}),this._m.setNotReadyReason($s.KICKED_OUT_USERSIG_EXPIRED),this._m.reset())}onRestApiKickedOut(s){new no("kickedOut").setNetworkType(this.getNetworkType()).setMessage(`type:${t.KICKED_OUT_REST_API} newInstanceInfo:${JSON.stringify(s)}`).end(!0),Ie.w(`${this._n}.onRestApiKickedOut userID:${this.getMyUserID()} newInstanceInfo:`,s);if(0!==this.getModule(gs).getStatusInstanceID()){this.emitOuterEvent(e.KICKED_OUT,{type:t.KICKED_OUT_REST_API}),this._m.setNotReadyReason($s.KICKED_OUT_REST_API),this._m.reset();this.getModule(Ss).onRestApiKickedOut()}}reset(){Ie.l(this._n+".reset"),this.resetReady(),this._helloInterval=120,this._lastLoginTs=0,this._lastWsHelloTs=0,this._isWebUniapp=0}}function si(){return null}class oi{constructor(e){this._m=e,this._n="StorageModule",this._storageQueue=new Map,this._errorTolerantHandle()}_errorTolerantHandle(){G||!Pe(window)&&this._canIUseCookies()||(this.getItem=si,this.setItem=si,this.removeItem=si,this.clear=si)}onCheckTimer(e){if(e%20==0){if(0===this._storageQueue.size)return;this._doFlush()}}_doFlush(){try{for(const[e,t]of this._storageQueue)this._setStorageSync(this._getKey(e),t);this._storageQueue.clear()}catch(e){Ie.w(this._n+"._doFlush error:",e)}}_getPrefix(){const e=this._m.getModule(gs);return`TIM_${e.getSDKAppID()}_${e.getUserID()}_`}_getKey(e){return`${this._getPrefix()}${e}`}getItem(e,t=!0){try{const s=t?this._getKey(e):e;return this.getStorageSync(s)}catch(s){return Ie.w(this._n+".getItem error:",s),{}}}setItem(e,t,s=!1,o=!0){if(s){const s=o?this._getKey(e):e;this._setStorageSync(s,t)}else this._storageQueue.set(e,t)}clear(){try{G?w.clearStorageSync():this._canIUseCookies()&&localStorage.clear()}catch(e){Ie.w(this._n+".clear error:",e)}}removeItem(e,t=!0){try{const s=t?this._getKey(e):e;this._removeStorageSync(s)}catch(s){Ie.w(this._n+".removeItem error:",s)}}getSize(e,t="b"){try{const s={size:0,limitSize:5242880,unit:t};if(Object.defineProperty(s,"leftSize",{enumerable:!0,get:()=>s.limitSize-s.size}),G&&(s.limitSize=1024*w.getStorageInfoSync().limitSize),e)s.size=JSON.stringify(this.getItem(e)).length+this._getKey(e).length;else if(G){const{keys:e}=w.getStorageInfoSync();e.forEach(e=>{s.size+=JSON.stringify(this.getStorageSync(e)).length+this._getKey(e).length})}else if(this._canIUseCookies())for(const e in localStorage)localStorage.hasOwnProperty(e)&&(s.size+=localStorage.getItem(e).length+e.length);return this._convertUnit(s)}catch(s){Ie.w(this._n+" error:",s)}}_convertUnit(e){const t={},{unit:s}=e;t.unit=s;for(const o in e)"number"==typeof e[o]&&("kb"===s.toLowerCase()?t[o]=Math.round(e[o]/1024):"mb"===s.toLowerCase()?t[o]=Math.round(e[o]/1024/1024):t[o]=e[o]);return t}_setStorageSync(e,t){G?R?my.setStorageSync({key:e,data:t}):w.setStorageSync(e,t):this._canIUseCookies()&&localStorage.setItem(e,JSON.stringify(t))}getStorageSync(e){if(G){if(R){return my.getStorageSync({key:e}).data}return w.getStorageSync(e)}return this._canIUseCookies()?JSON.parse(localStorage.getItem(e)):{}}_removeStorageSync(e){G?R?my.removeStorageSync({key:e}):w.removeStorageSync(e):this._canIUseCookies()&&localStorage.removeItem(e)}_canIUseCookies(){return navigator&&navigator.cookieEnabled&&localStorage}reset(){Ie.l(this._n+".reset"),this._doFlush()}}class ii{constructor(e){this._n="SSOLogBody",this._report=[]}pushIn(e){Ie.d(this._n+".pushIn",this._report.length,e),this._report.push(e)}backfill(e){Ue(e)&&0!==e.length&&(Ie.d(this._n+".backfill",this._report.length,e.length),this._report.unshift(...e))}getLogsNumInMemory(){return this._report.length}isEmpty(){return 0===this._report.length}_reset(){this._report.length=0,this._report=[]}getLogsInMemory(){const e=this._report.slice();return this._reset(),e}}const ni=function(e){const t=e.getModule(gs);return{SDKType:10,SDKAppID:t.getSDKAppID(),SDKVersion:t.getVersion(),tinyID:Number(t.getTinyID()),userID:t.getUserID(),platform:e.getPlatform(),instanceID:t.getInstanceID(),traceID:_e()}};class ri extends Bs{constructor(e){super(e),this._n="EventStatModule",this.TAG="im-ssolog-event",this._reportBody=new ii,this.MIN_THRESHOLD=20,this.MAX_THRESHOLD=100,this.WAITING_TIME=6e4,this.REPORT_LEVEL=[4,5,6],this.REPORT_SDKAPPID_BLACKLIST=[],this.REPORT_TINYID_WHITELIST=[],this._lastReportTime=Date.now();const t=this.getInnerEmitterInstance();t.on(Do.A2KEY_AND_TINYID_UPDATED,this._onLoginSuccess,this),t.on(Do.CLOUD_CONFIG_UPDATED,this._onCloudConfigUpdated,this)}reportAtOnce(){this._report()}_onLoginSuccess(){const e=this.getModule(ms),t=e.getItem(this.TAG,!1);!St(t)&&ke(t.forEach)&&(Ie.l(`${this._n}._onLoginSuccess. logs count:${t.length}`),t.forEach(e=>{this._reportBody.pushIn(e)}),e.removeItem(this.TAG,!1))}_onCloudConfigUpdated(){const e=this.getCloudConfig("evt_rpt_threshold"),t=this.getCloudConfig("evt_rpt_waiting"),s=this.getCloudConfig("evt_rpt_level"),o=this.getCloudConfig("evt_rpt_sdkappid_bl"),i=this.getCloudConfig("evt_rpt_tinyid_wl");Pe(e)||(this.MIN_THRESHOLD=Number(e)),Pe(t)||(this.WAITING_TIME=Number(t)),Pe(s)||(this.REPORT_LEVEL=s.split(",").map(e=>Number(e))),Pe(o)||(this.REPORT_SDKAPPID_BLACKLIST=o.split(",").map(e=>Number(e))),Pe(i)||(this.REPORT_TINYID_WHITELIST=i.split(","))}pushIn(e){e instanceof no&&(e.updateTimeStamp(),this._reportBody.pushIn(e),this._reportBody.getLogsNumInMemory()>=this.MIN_THRESHOLD&&this._report())}onCheckTimer(){Date.now()<this._lastReportTime+this.WAITING_TIME||this._reportBody.isEmpty()||this._report()}_filterLogs(e){const t=this.getModule(gs),s=t.getSDKAppID(),o=t.getTinyID();if(_t(this.REPORT_SDKAPPID_BLACKLIST,s)&&!pt(this.REPORT_TINYID_WHITELIST,o))return[];return e.filter(e=>this.REPORT_LEVEL.includes(e.level))}_report(){if(this._reportBody.isEmpty())return;const e=this._reportBody.getLogsInMemory(),t=this._filterLogs(e);if(0===t.length)return void(this._lastReportTime=Date.now());const s={header:ni(this),event:t};this.request({protocolName:Ks.SSO_STAT,requestData:{...s}}).then(()=>{this._lastReportTime=Date.now()}).catch(t=>{Ie.w(`${this._n}._report failed. networkType:${this.getNetworkType()} error:`,t),this._lastReportTime=Date.now(),this._reportBody.backfill(e);this._reportBody.getLogsNumInMemory()>this.MAX_THRESHOLD&&this._flushAtOnce()})}_flushAtOnce(){const e=this.getModule(ms),t=e.getItem(this.TAG,!1),s=this._reportBody.getLogsInMemory(),o=this._n+"._flushAtOnce";if(St(t))Ie.l(`${o} count:${s.length}`),e.setItem(this.TAG,s,!0,!1);else{let i=s.concat(t);i.length>this.MAX_THRESHOLD&&(i=i.slice(0,this.MAX_THRESHOLD)),Ie.l(`${o} count:${i.length}`),e.setItem(this.TAG,i,!0,!1)}}reset(){Ie.l(this._n+".reset"),this._lastReportTime=0,this._report(),this.REPORT_SDKAPPID_BLACKLIST=[],this.REPORT_TINYID_WHITELIST=[]}}const ai="none",ci="online",ui=[$s.OVER_FREQUENCY_LIMIT,$s.OPEN_SERVICE_OVERLOAD_ERROR];class li{constructor(e){this._m=e,this._networkType="",this._n="NetMonitorModule",this.MAX_WAIT_TIME=3e3,this._mpNetworkStatusCallback=null,this._webOnlineCallback=null,this._webOfflineCallback=null}start(){G?(w.getNetworkType({success:e=>{this._networkType=e.networkType||e.subtype||"",e.networkType===ai?Ie.w(this._n+".start no network, please check!"):Ie.i(`${this._n}.start networkType:${e.networkType}`)}}),this._mpNetworkStatusCallback=this._onNetworkStatusChange.bind(this),w.onNetworkStatusChange(this._mpNetworkStatusCallback)):(this._networkType=ci,this._webOnlineCallback=this._onWebOnline.bind(this),this._webOfflineCallback=this._onWebOffline.bind(this),window&&(window.addEventListener("online",this._webOnlineCallback),window.addEventListener("offline",this._webOfflineCallback)))}_onWebOnline(){this._onNetworkStatusChange({isConnected:!0,networkType:ci})}_onWebOffline(){this._onNetworkStatusChange({isConnected:!1,networkType:ai})}_onNetworkStatusChange(e){const{isConnected:t,networkType:s}=e,o=this._n+"._onNetworkStatusChange";let i=!1;if(t){if(Ie.i(`${o} previous:${this._networkType} current:${s}`),this._networkType!==s){i=!0;this._m.getModule(Ss).reConnect(!0)}}else if(this._networkType!==s){i=!0,Ie.w(o+" no network, please check!");this._m.getModule(Ss).offline()}if(i){new no("networkChange").setMessage(`isConnected:${t} previousNetworkType:${this._networkType} networkType:${s}`).end(),this._networkType=s}}probe(e){if(!Pe(e)&&ui.includes(e.code))return Promise.resolve([!0,this._networkType]);const t=this._n+".probe";return new Promise((e,s)=>{G?w.getNetworkType({success:s=>{this._networkType=s.networkType,s.networkType===ai?(Ie.w(t+" no network, please check!"),e([!1,s.networkType])):(Ie.i(`${t} networkType:${s.networkType}`),e([!0,s.networkType]))}}):this._networkType===ai?e([!1,ai]):e([!0,ci])})}getNetworkType(){return this._networkType}reset(){Ie.l(this._n+".reset"),G?null!==this._mpNetworkStatusCallback&&(w.offNetworkStatusChange&&(U||A?w.offNetworkStatusChange(this._mpNetworkStatusCallback):w.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))}}var di=function(e,t){return e(t={exports:{}},t.exports),t.exports}((function(e){var t=Object.prototype.hasOwnProperty,s="~";function o(){}function i(e,t,s){this.fn=e,this.context=t,this.once=s||!1}function n(e,t,o,n,r){if("function"!=typeof o)throw new TypeError("The listener must be a function");var a=new i(o,n||e,r),c=s?s+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],a]:e._events[c].push(a):(e._events[c]=a,e._eventsCount++),e}function r(e,t){0==--e._eventsCount?e._events=new o:delete e._events[t]}function a(){this._events=new o,this._eventsCount=0}Object.create&&(o.prototype=Object.create(null),(new o).__proto__||(s=!1)),a.prototype.eventNames=function(){var e,o,i=[];if(0===this._eventsCount)return i;for(o in e=this._events)t.call(e,o)&&i.push(s?o.slice(1):o);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(e)):i},a.prototype.listeners=function(e){var t=s?s+e:e,o=this._events[t];if(!o)return[];if(o.fn)return[o.fn];for(var i=0,n=o.length,r=new Array(n);i<n;i++)r[i]=o[i].fn;return r},a.prototype.listenerCount=function(e){var t=s?s+e:e,o=this._events[t];return o?o.fn?1:o.length:0},a.prototype.emit=function(e,t,o,i,n,r){var a=s?s+e:e;if(!this._events[a])return!1;var c,u,l=this._events[a],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,i),!0;case 5:return l.fn.call(l.context,t,o,i,n),!0;case 6:return l.fn.call(l.context,t,o,i,n,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{var _,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,i);break;default:if(!c)for(_=1,c=new Array(d-1);_<d;_++)c[_-1]=arguments[_];l[u].fn.apply(l[u].context,c)}}return!0},a.prototype.on=function(e,t,s){return n(this,e,t,s,!1)},a.prototype.once=function(e,t,s){return n(this,e,t,s,!0)},a.prototype.removeListener=function(e,t,o,i){var n=s?s+e:e;if(!this._events[n])return this;if(!t)return r(this,n),this;var a=this._events[n];if(a.fn)a.fn!==t||i&&!a.once||o&&a.context!==o||r(this,n);else{for(var c=0,u=[],l=a.length;c<l;c++)(a[c].fn!==t||i&&!a[c].once||o&&a[c].context!==o)&&u.push(a[c]);u.length?this._events[n]=1===u.length?u[0]:u:r(this,n)}return this},a.prototype.removeAllListeners=function(e){var t;return e?(t=s?s+e:e,this._events[t]&&r(this,t)):(this._events=new o,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=s,a.EventEmitter=a,e.exports=a}));const _i=9999,pi=1e4;class hi extends Bs{constructor(e){super(e),this._n="UploadModule",this.TIMUploadPlugin=null,this.timUploadPlugin=null,this.COSSDK=null,this._cosUploadMethod=null,this.expiredTimeLimit=600,this.appid=0,this.bucketName="",this.ciUrl="",this.directory="",this.downloadUrl="",this.uploadUrl="",this.region="ap-shanghai",this.cos=null,this.cosOptions={secretId:"",secretKey:"",sessionToken:"",expiredTime:0},this.uploadFileType="",this.duration=900,this.tryCount=0,this.UPLOAD_SIZE_LIMIT={A:20971520,F:104857600,I:20971520,V:104857600},this.isSimpleCos=!1;const t=this.getInnerEmitterInstance();t.on(Do.A2KEY_AND_TINYID_UPDATED,this._init,this),t.on(Do.CLOUD_CONFIG_UPDATED,this._onCloudConfigUpdated,this)}_init(){const e=this.getModule(Ts);if(this.TIMUploadPlugin=e.getPlugin("tim-upload-plugin"),this.TIMUploadPlugin)return void this._initUploaderMethod();const t=G?"cos-wx-sdk":"cos-js-sdk";this.COSSDK=e.getPlugin(t),this.COSSDK?(this._getAuthorizationKey(),this.outputWarning("CosReplacement",t)):this.outputWarning("PluginUndetected")}_onCloudConfigUpdated(){const e=this._n+"._onCloudConfigUpdated",t=this.getCloudConfig("upload_size_limit"),s=this.getCloudConfig("simple_cos");if(Ie.l(`${e} uploadSizeLimit:${t} simpleCos:${s}`),!Pe(t))try{const e=JSON.parse(t);this.UPLOAD_SIZE_LIMIT={A:e.a?1048576*parseInt(e.a):this.UPLOAD_SIZE_LIMIT.A,F:e.f?1048576*parseInt(e.f):this.UPLOAD_SIZE_LIMIT.F,I:e.i?1048576*parseInt(e.i):this.UPLOAD_SIZE_LIMIT.I,V:e.v?1048576*parseInt(e.v):this.UPLOAD_SIZE_LIMIT.V}}catch(o){}Pe(s)||(this.isSimpleCos="1"===s)}_getAuthorizationKey(){const e=this._n+"._getAuthorizationKey",t=new no("_getAuthorizationKey"),s=Math.ceil(Date.now()/1e3);this.request({protocolName:Ks.COS_SIGN,requestData:{duration:this.expiredTimeLimit}}).then(o=>{const{data:i}=o;Ie.l(e+" ok. data:",i);const n=i.expiredTime-s;t.setMessage(`requestId:${i.requestId} requestTime:${s} expiredTime:${i.expiredTime} diff:${n}s`).setNetworkType(this.getNetworkType()).end(),!G&&i.region&&(this.region=i.region),this.appid=i.appid,this.bucketName=i.bucketName,this.ciUrl=i.ciUrl,this.directory=i.directory,this.downloadUrl=i.downloadUrl,this.uploadUrl=i.uploadUrl,this.cosOptions={secretId:i.secretId,secretKey:i.secretKey,sessionToken:i.sessionToken,expiredTime:i.expiredTime},Ie.l(`${e} ok. region:${this.region} bucketName:${this.bucketName}`),this._initUploaderMethod()}).catch(s=>{this.probeNetwork().then(([e,o])=>{t.setError(s,e,o).end()}),Ie.w(e+" failed. error:",s)})}_getCosPreSigUrl(e){const t=this._n+"._getCosPreSigUrl",s=Math.ceil(Date.now()/1e3),o=new no("_getCosPreSigUrl");let i={uploadMethod:e.uploadMethod,platform:this.getPlatform(),SDKAppID:this.getSDKAppID(),userID:e.userID,conversationType:e.conversationType,uploadConfig:[{fileID:1,fileType:e.fileType,fileName:e.fileName}]},n=Ks.SIMPLE_COS_PRE_SIG;return this.isSimpleCos||(i={fileType:e.fileType,fileName:e.fileName,uploadMethod:e.uploadMethod,duration:e.duration},n=Ks.COS_PRE_SIG),this.request({protocolName:n,requestData:i}).then(e=>{this.tryCount=0;const i=e.data||{};Ie.l(`${t} ok. isSimpleCos:${this.isSimpleCos} data:`,i);let n="";if(this.isSimpleCos){const{uploadUrl:e,fileKey:t}=i.preSig[0];n=`uploadIP:${i.uploadIP} uploadUrl:${e} fileKey:${t} cost:${Tt(s)}`}else n=`requestId:${i.requestId} expiredTime:${i.expiredTime} diff:${i.expiredTime-s}s`;return o.setMessage(n).setNetworkType(this.getNetworkType()).end(),i}).catch(s=>(-1===s.code&&(s.code=$s.COS_GET_SIG_FAIL),this.probeNetwork().then(([e,t])=>{o.setError(s,e,t).end()}),Ie.w(t+" failed. error:",s),this.tryCount<1?(this.tryCount++,this._getCosPreSigUrl(e)):(this.tryCount=0,Vs({code:$s.COS_GET_SIG_FAIL}))))}_initUploaderMethod(){if(this.TIMUploadPlugin)return this.timUploadPlugin=new this.TIMUploadPlugin,void(this._cosUploadMethod=(e,t)=>{this.timUploadPlugin.uploadFile(e,t)});this.appid&&(this.cos=G?new this.COSSDK({ForcePathStyle:!0,getAuthorization:this._getAuthorization.bind(this)}):new this.COSSDK({getAuthorization:this._getAuthorization.bind(this)}),this._cosUploadMethod=G?(e,t)=>{this.cos.postObject(e,t)}:(e,t)=>{this.cos.uploadFiles(e,t)})}onCheckTimer(e){if(!this.COSSDK)return;if(this.TIMUploadPlugin)return;if(!this.isLoggedIn())return;if(e%60!=0)return;Math.ceil(Date.now()/1e3)>=this.cosOptions.expiredTime-120&&this._getAuthorizationKey()}_getAuthorization(e,t){t({TmpSecretId:this.cosOptions.secretId,TmpSecretKey:this.cosOptions.secretKey,XCosSecurityToken:this.cosOptions.sessionToken,ExpiredTime:this.cosOptions.expiredTime})}upload(e){if(!0===e._relayFlag)return Promise.resolve();const s=this.getModule(vs);switch(e.type){case t.MSG_IMAGE:return s.addTotalCount(Xs),this._uploadImage(e);case t.MSG_FILE:return s.addTotalCount(Xs),this._uploadFile(e);case t.MSG_AUDIO:return s.addTotalCount(Xs),this._uploadAudio(e);case t.MSG_VIDEO:return s.addTotalCount(Xs),this._uploadVideo(e);default:return Promise.resolve()}}_uploadImage(e){const t=this.getModule(as),s=e.getElements()[0],o=t.getMessageOption(e.clientSequence);return this.doUploadImage({file:o.payload.file,to:o.to,message:e,onProgress:e=>{if(s.updatePercent(e),ke(o.onProgress))try{o.onProgress(e)}catch(t){return Vs({code:$s.MSG_ONPROGRESS_FUNCTION_ERROR})}}}).then(t=>{const{location:o,fileType:i,fileSize:n,width:r,height:a,smallImageUrl:c,smallImageWidth:u,smallImageHeight:l,largeImageUrl:d,largeImageWidth:_,largeImageHeight:p,imageInfoArray:h}=t,g=this.isPrivateNetWork()?o:ze(o);s.updateImageFormat(i);let m,M,I={size:n,url:g,width:r,height:a};if(h&&h.length>0)for(let e=0;e<h.length;e++){const t=h[e];1===t.type?m=t:2===t.type?M=t:I={...I,...t}}else c&&d?(m={url:c,width:u,height:l},M={url:d,width:_,height:p}):(m=ct({originUrl:g,originWidth:r,originHeight:a,min:198}),M=ct({originUrl:g,originWidth:r,originHeight:a,min:720}));return s.updateImageInfoArray([{...I},{...M},{...m}]),e})}_uploadFile(e){const t=this.getModule(as),s=e.getElements()[0],o=t.getMessageOption(e.clientSequence);return this.doUploadFile({file:o.payload.file,to:o.to,message:e,onProgress:e=>{if(s.updatePercent(e),ke(o.onProgress))try{o.onProgress(e)}catch(t){return Vs({code:$s.MSG_ONPROGRESS_FUNCTION_ERROR})}}}).then(({location:t})=>{const o=this.isPrivateNetWork()?t:ze(t);return s.updateFileUrl(o),e})}_uploadAudio(e){const t=this.getModule(as),s=e.getElements()[0],o=t.getMessageOption(e.clientSequence);return this.doUploadAudio({file:o.payload.file,to:o.to,message:e,onProgress:e=>{if(s.updatePercent(e),ke(o.onProgress))try{o.onProgress(e)}catch(t){return Vs({code:$s.MSG_ONPROGRESS_FUNCTION_ERROR})}}}).then(({location:t})=>{const o=this.isPrivateNetWork()?t:ze(t);return s.updateAudioUrl(o),e})}_uploadVideo(e){const t=this.getModule(as),s=e.getElements()[0],o=t.getMessageOption(e.clientSequence);return this.doUploadVideo({file:o.payload.file,to:o.to,message:e,onProgress:e=>{if(s.updatePercent(e),ke(o.onProgress))try{o.onProgress(e)}catch(t){return Vs({code:$s.MSG_ONPROGRESS_FUNCTION_ERROR})}}}).then(t=>{const{location:o,snapshotInfo:i}=t,n=this.isPrivateNetWork()?o:ze(o);return s.updateVideoUrl(n),St(i)||s.updateSnapshotInfo(i),e})}_checkSizeError(e){let t="";return"A"===e?t="audio":"I"===e?t="image":"V"===e?t="video":"F"===e&&(t="file"),Vs({code:$s[`MSG_${e}_SIZE_LIMIT`],message:this.getErrorMessage("UploadSizeLimit",t,this.UPLOAD_SIZE_LIMIT[e]/1048576+"MB")})}doUploadImage(e){if(!e.file||this._isEmptyFileList(e.file.files))return Vs({code:$s.MSG_I_SELECT_F_FIRST});const t=this._checkImageType(e.file);if(!0!==t)return t;const s=this._checkImageSize(e.file);if(!0!==s)return s;let o=null;return this._setUploadFileType(Oo),this.uploadByCOS(e).then(e=>{if(o=e,this.isPrivateNetWork())return it(e.location);if(Ue(o.imageInfoArray)){const e=o.imageInfoArray.find(e=>3===e.type);if(e)return e}return it("https://"+e.location)}).then(e=>(o.width=e.width,o.height=e.height,Promise.resolve(o)))}_checkImageType(e){let t="";return t=G?e.url.slice(e.url.lastIndexOf(".")+1):e.files[0].name.slice(e.files[0].name.lastIndexOf(".")+1),vo.indexOf(t.toLowerCase())>=0||Vs({code:$s.MSG_I_TYPES_LIMIT})}_checkImageSize(e){let t=0;return t=G?e.size:e.files[0].size,0===t?Vs({code:$s.MSG_F_IS_EMPTY}):t<this.UPLOAD_SIZE_LIMIT.I||this._checkSizeError("I")}doUploadFile(e){let t=null;return!e.file||this._isEmptyFileList(e.file.files)?(t={code:$s.MSG_F_SELECT_F_FIRST},Vs(t)):e.file.files[0].size>this.UPLOAD_SIZE_LIMIT.F?this._checkSizeError("F"):0===e.file.files[0].size?(t={code:$s.MSG_F_IS_EMPTY},Vs(t)):(this._setUploadFileType(Uo),this.uploadByCOS(e))}doUploadVideo(e){return e.file.videoFile.size>this.UPLOAD_SIZE_LIMIT.V?this._checkSizeError("V"):0===e.file.videoFile.size?Vs({code:$s.MSG_F_IS_EMPTY}):-1===Ao.indexOf(e.file.videoFile.type)?Vs({code:$s.MSG_V_TYPES_LIMIT}):(this._setUploadFileType(Ro),G?this.handleVideoUpload({...e,file:e.file.videoFile}):k?this.handleVideoUpload(e):void 0)}handleVideoUpload(e){return new Promise((t,s)=>{this.uploadByCOS(e).then(e=>{t(e)}).catch(()=>{this.uploadByCOS(e).then(e=>{t(e)}).catch(()=>{s(new Fs({code:$s.MSG_V_UPLOAD_FAIL}))})})})}doUploadAudio(e){return e.file?e.file.size>this.UPLOAD_SIZE_LIMIT.A?this._checkSizeError("A"):0===e.file.size?Vs({code:$s.MSG_F_IS_EMPTY}):(this._setUploadFileType(Lo),this.uploadByCOS(e)):Vs({code:$s.MSG_A_UPLOAD_FAIL})}uploadByCOS(e){if(!ke(this._cosUploadMethod))return this.outputWarning("PluginUndetected"),Vs({code:$s.COS_UNDETECTED});if(this.timUploadPlugin)return this._uploadWithPreSigUrl(e);const t=new no("upload"),s=this._n+".uploadByCOS",o=Date.now(),i=this._getFile(e);return new Promise((n,r)=>{const a=G?this._createCosOptionsWXMiniApp(e):this._createCosOptionsWeb(e),c=this;this._cosUploadMethod(a,(e,a)=>{const u=Object.create(null);if(a){if(e||Ue(a.files)&&a.files[0].error){const e=new Fs({code:$s.MSG_F_UPLOAD_FAIL});return t.setError(e,!0,this.getNetworkType()).end(),Ie.l(s+" failed. error:",a.files[0].error),403===a.files[0].error.statusCode&&(Ie.w(s+" failed. cos AccessKeyId was invalid, regain auth key!"),this._getAuthorizationKey()),void r(e)}u.fileName=i.name,u.fileSize=i.size,u.fileType=i.type.slice(i.type.indexOf("/")+1).toLowerCase(),u.location=G?a.Location:a.files[0].data.Location;const l=Date.now()-o,d=`size:${c._formatFileSize(i.size)} time:${l}ms speed:${c._formatSpeed(1e3*i.size/l)}`;Ie.l(`${s} success. name:${i.name} ${d}`),n(u);const _=this.getModule(vs);return _.addCost(Xs,l),_.addFileSize(Xs,i.size),void t.setNetworkType(this.getNetworkType()).setMessage(d).end()}const l=new Fs({code:$s.MSG_F_UPLOAD_FAIL});t.setError(l,!0,c.getNetworkType()).end(),Ie.w(s+" failed. error:",e),403===e.statusCode&&(Ie.w(s+" failed. cos AccessKeyId was invalid, regain auth key!"),this._getAuthorizationKey()),r(l)})})}_uploadWithPreSigUrl(e){const t=this._n+"._uploadWithPreSigUrl",s=this._getFile(e);return this._createCosOptionsPreSigUrl(e).then(e=>new Promise((o,i)=>{const n=new no("upload"),{requestSnapshotUrl:r,...a}=e,c=Date.now();this._cosUploadMethod(a,(u,l)=>{if(u||403===l.statusCode){n.setError(new Fs(u),!0,this.getNetworkType()).end();const s={HttpStatusCode:_i,CostTime:Tt(c,!1),error:u,url:e.url};return l.data&&l.data.uploadIP&&(s.uploadIP=l.data.uploadIP),this._uploadSSOLog(s),Ie.l(t+" failed, error:",u),void i(new Fs({code:$s.MSG_F_UPLOAD_FAIL}))}const d=Object.create(null);let _=l.data.location||"";this.isPrivateNetWork()||0!==_.indexOf("https://")&&0!==_.indexOf("http://")||(_=_.split("//")[1]),d.fileName=s.name,d.fileSize=s.size,d.fileType=s.type.slice(s.type.indexOf("/")+1).toLowerCase(),d.location=_;const p=Tt(c,!1),h=`size:${this._formatFileSize(s.size)} time:${p}ms speed:${this._formatSpeed(1e3*s.size/p)} res:${JSON.stringify(l.data)}`;Ie.l(`${t} ok. name:${s.name} ${h}`),n.setNetworkType(this.getNetworkType()).setMessage(h).end();const g={HttpStatusCode:l.statusCode,FileSize:s.size,CostTime:p,url:e.url};l.data&&l.data.uploadIP&&(g.uploadIP=l.data.uploadIP),this._uploadSSOLog(g);const m=this.getModule(vs);m.addCost(Xs,p),m.addFileSize(Xs,s.size);const M=[];if(a.thumbUrl&&a.largeUrl&&M.push(this._getSmallImageInfoByUrl(a.thumbUrl,d),this._getLargeImageInfoByUrl(a.largeUrl,d)),this.uploadFileType===Oo&&this.isSimpleCos&&(M.push(this._getImageInfoArray(a.downloadUrl,d)),l.data.uploadIP&&M.push(this._getDownloadIP(a.downloadUrl.split("//")[1].split("/")[0],d))),r&&M.push(this._getSnapshotInfoByUrl(r,d)),M.length>0)return Promise.all(M).then(()=>{o(d)});o(d)})}))}_getDownloadIP(e,t){const s=this._n+"._getDownloadIP",o=Date.now();return this.request({protocolName:Ks.GET_IP,requestData:{domainName:e}}).then(e=>{if(!e.data||!e.data.ip)return;Ie.l(`${s} ok. downloadIP:${e.data.ip} cost:${Tt(o)}`);const i=t.location.split("/");i[0]=e.data.ip,t.location=i.join("/")}).catch(e=>{})}_getImageInfoArray(e,t){const s=this._n+"._getImageInfoArray",o=Date.now();return this.request({protocolName:Ks.GET_IMAGE_INFO,requestData:{imageUrl:e}}).then(e=>{const i=e.data||{};return Ie.l(`${s} ok. data: ${JSON.stringify(i)} cost:${Tt(o)}`),t.imageInfoArray=i.imageInfoArray,i}).catch(s=>{t.imageInfoArray=void 0,this._uploadSSOLog({HttpStatusCode:pi,CostTime:Tt(o,!1),url:e})})}_uploadSSOLog(e){if(!this.isSimpleCos)return;const t=new no;t.setEventType(18),e.error?t.setError(new Fs(e.error),!0,this.getNetworkType()):t.setNetworkType(this.getNetworkType());let s=`HttpStatusCode:${e.HttpStatusCode}|CosRequestId:${e.CosRequestId||""}|FileAlreadyExist:${e.FileAlreadyExist||0}|FileSize:${e.FileSize||0}|CostTime:${e.CostTime}`;e.uploadIP&&(s+="|FinalIP:"+e.uploadIP),t.setMessage("OK").setMoreMessage(e.url).setExtension(s).end()}_getRawOrUploadProxyUrl(e){const t=this.getModule(gs).getFileUploadProxy();let s=e;return t&&(s=e.replace(/^https:\/\/[^/]+/,t)),s}_getFile(e){let t=null;return t=Ue(e.file.files)||Fe(e.file.files)?e.file.files[0]:e.file,t}_formatFileSize(e){return e<1024?e+"B":e<1048576?Math.floor(e/1024)+"KB":Math.floor(e/1048576)+"MB"}_formatSpeed(e){if(e<=1048576){return dt(e/1024,1)+"KB/s"}return dt(e/1048576,1)+"MB/s"}_createCosOptionsWeb(e){const t=this._getFile(e),s=t.name,o=s.slice(s.lastIndexOf(".")),i=this._genFileName(`${Be(999999)}${o}`);return{files:[{Bucket:`${this.bucketName}-${this.appid}`,Region:this.region,Key:`${this.directory}/${i}`,Body:t}],SliceSize:1048576,onProgress:t=>{if("function"==typeof e.onProgress)try{e.onProgress(t.percent)}catch(s){Ie.w("onProgress callback error:",s)}},onFileFinish:(e,t,s)=>{}}}_createCosOptionsWXMiniApp(e){const t=this._getFile(e),s=this._genFileName(t.name),o=t.url;return{Bucket:`${this.bucketName}-${this.appid}`,Region:this.region,Key:`${this.directory}/${s}`,FilePath:o,onProgress:t=>{if(Ie.l(JSON.stringify(t)),"function"==typeof e.onProgress)try{e.onProgress(t.percent)}catch(s){Ie.w("onProgress callback error:",s)}}}}_createCosOptionsPreSigUrl(e){let s="",o="",i=0;const n=this._getFile(e);if(G){if(e.message.type===t.MSG_FILE){const e=n.name,t=e.slice(e.lastIndexOf("."));s=this._genFileName(`${Be(999999)}${t}`)}else s=this._genFileName(n.name);o=n.url,i=1}else{const e=n.name,t=e.slice(e.lastIndexOf("."));s=this._genFileName(`${Be(999999)}${t}`),o=n,i=0}return this._getCosPreSigUrl({fileType:this.uploadFileType,fileName:s,uploadMethod:i,duration:this.duration,userID:e.message.from,conversationType:Ze(e.message.conversationID)?1:2}).then(t=>{const i=this.isSimpleCos?t.preSig[0]:t,{uploadUrl:n,downloadUrl:r,requestSnapshotUrl:a,thumbUrl:c,largeUrl:u,fileKey:l}=i,{uploadIP:d=""}=t;return{url:this._getRawOrUploadProxyUrl(n),fileType:this.uploadFileType,fileName:s,resources:o,downloadUrl:r,requestSnapshotUrl:a,thumbUrl:c,largeUrl:u,fileKey:l,uploadIP:!this.isPrivateNetWork()&&d,onProgress:t=>{if("function"==typeof e.onProgress)try{e.onProgress(t.percent)}catch(s){Ie.w("onProgress callback error:",s),Ie.e(s)}}}})}_genFileName(e){return`${nt()}-${e}`}_setUploadFileType(e){this.uploadFileType=e}_getSnapshotInfoByUrl(e,t){const s="_getSnapshotInfoByUrl",o=new no(s);return this.request({protocolName:Ks.VIDEO_COVER,requestData:{platform:this.getPlatform(),coverName:this._genFileName(Be(99999)),requestSnapshotUrl:e}}).then(e=>{const{snapshotUrl:i}=e.data||{};return Ie.l(`${this._n}.${s} ok. snapshotUrl:${i}`),o.setMessage("snapshotUrl:"+i).end(),St(i)?{}:it(i).then(e=>{t.snapshotInfo={snapshotUrl:i,snapshotWidth:e.width,snapshotHeight:e.height}})}).catch(e=>(Ie.w(`${this._n}.${s} failed. error:`,e),o.setCode(e.errorCode).setMessage(e.errorInfo).end(),{}))}_getSmallImageInfoByUrl(e,t){return it(e).then(s=>{t.smallImageUrl=e,t.smallImageWidth=s.width,t.smallImageHeight=s.height})}_getLargeImageInfoByUrl(e,t){return it(e).then(s=>{t.largeImageUrl=e,t.largeImageWidth=s.width,t.largeImageHeight=s.height})}_isEmptyFileList(e){return!(!Fe(e)||0!==e.length)}reset(){Ie.l(this._n+".reset")}}class gi{constructor(e){this._n="MergerMessageHandler",this._messageModule=e}uploadMergerMessage(e,t){const s=this._n+".uploadMergerMessage";Ie.d(s+" message:",e,"messageBytes:"+t);const{messageList:o}=e.payload,i=o.length,n=new no("uploadMergerMessage");return this._messageModule.request({protocolName:Ks.UPLOAD_MERGER_MESSAGE,requestData:{messageList:o}}).then(e=>{Ie.d(s+" ok. response:",e.data);const{pbDownloadKey:o,downloadKey:r}=e.data,a={pbDownloadKey:o,downloadKey:r,messageNumber:i};return n.setNetworkType(this._messageModule.getNetworkType()).setMessage(`${i}-${t}-${r}`).end(),a}).catch(e=>{throw Ie.w(s+" failed. error:",e),this._messageModule.probeNetwork().then(([t,s])=>{n.setError(e,t,s).end()}),e})}downloadMergerMessage(e){const t=this._n+".downloadMergerMessage";Ie.d(t+" message:",e);const{downloadKey:s}=e.payload,o=this._messageModule.getFileDownloadProxy(),i=new no("downloadMergerMessage");return i.setMessage("downloadKey:"+s),this._messageModule.request({protocolName:Ks.DOWNLOAD_MERGER_MESSAGE,requestData:{downloadKey:s}}).then(s=>{if(Ie.d(t+" ok. response:",s.data),ke(e.clearElement)){const{downloadKey:t,pbDownloadKey:i,messageList:n,...r}=e.payload;e.clearElement(),e.setElement({type:e.type,content:{messageList:s.data.messageList,...r}},o)}else{const t=[];s.data.messageList.forEach(e=>{if(!St(e)){const s=new fo(e,o);t.push(s)}}),e.payload.messageList=t,e.payload.downloadKey="",e.payload.pbDownloadKey=""}return i.setNetworkType(this._messageModule.getNetworkType()).end(),e}).catch(e=>{throw Ie.w(`${t} failed. key:${s} error:`,e),this._messageModule.probeNetwork().then(([t,s])=>{i.setError(e,t,s).end()}),e})}createMergerMessagePack(e,s,o){return e.conversationType===t.CONV_C2C?this._createC2CMergerMessagePack(e,s,o):this._createGroupMergerMessagePack(e,s,o)}_createC2CMergerMessagePack(e,t,s){let o=null;t&&(t.offlinePushInfo&&(o=t.offlinePushInfo),!0===t.onlineUserOnly&&(o?o.disablePush=!0:o={disablePush:!0}));const i=[];if(Le(t)&&Le(t.messageControlInfo)){const{excludedFromUnreadCount:e,excludedFromLastMessage:s,excludedFromContentModeration:o}=t.messageControlInfo;!0===e&&i.push("NoUnread"),!0===s&&i.push("NoLastMsg"),!0===o&&i.push("NoMsgCheck")}let n="";Oe(e.cloudCustomData)&&e.cloudCustomData.length>0&&(n=e.cloudCustomData);const{pbDownloadKey:r,downloadKey:a,messageNumber:c}=s,{title:u,abstractList:l,compatibleText:d}=e.payload,_=this._messageModule.getModule(ls),p=_&&_.isOnlineMessage(e,t)?0:void 0;return{protocolName:Ks.SEND_C2C_MESSAGE,tjgID:this._messageModule.generateTjgID(e),requestData:{fromAccount:this._messageModule.getMyUserID(),toAccount:e.to,msgBody:[{msgType:e.type,msgContent:{pbDownloadKey:r,downloadKey:a,title:u,abstractList:l,compatibleText:d,messageNumber:c}}],cloudCustomData:n,clientTime:e.clientTime,msgSeq:e.sequence,msgRandom:e.random,msgLifeTime:p,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:0!==p?i:void 0,isSupportExtension:!0===e.isSupportExtension?1:0,isRelayMessage:!0===e._relayFlag?1:0}}}_createGroupMergerMessagePack(e,t,s){let o=null;t&&t.offlinePushInfo&&(o=t.offlinePushInfo);const i=[];if(Le(t)&&Le(t.messageControlInfo)){const{excludedFromUnreadCount:e,excludedFromLastMessage:s,excludedFromContentModeration:o}=t.messageControlInfo;!0===e&&i.push("NoUnread"),!0===s&&i.push("NoLastMsg"),!0===o&&i.push("NoMsgCheck")}let n="";Oe(e.cloudCustomData)&&e.cloudCustomData.length>0&&(n=e.cloudCustomData);const{pbDownloadKey:r,downloadKey:a,messageNumber:c}=s,{title:u,abstractList:l,compatibleText:d}=e.payload,_=this._messageModule.getModule(ds),p=_&&_.isOnlineMessage(e,t)?1:0;return{protocolName:Ks.SEND_GROUP_MESSAGE,tjgID:this._messageModule.generateTjgID(e),requestData:{fromAccount:this._messageModule.getMyUserID(),groupID:e.to,msgBody:[{msgType:e.type,msgContent:{pbDownloadKey:r,downloadKey:a,title:u,abstractList:l,compatibleText:d,messageNumber:c}}],random:e.random,priority:e.priority,clientSequence:e.clientSequence,groupAtInfo:void 0,cloudCustomData:n,onlineOnlyFlag:p,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,clientTime:e.clientTime,needReadReceipt:!0!==e.needReadReceipt||_.isMessageFromOrToAVChatroom(e.to)?0:1,messageControlInfo:0===p?i:void 0,isSupportExtension:!0===e.isSupportExtension?1:0,isRelayMessage:!0===e._relayFlag?1:0}}}}const mi={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,MSG_SEND_FAIL:2100,OVER_FREQUENCY_LIMIT:2996},Mi=[$s.MSG_ONPROGRESS_FUNCTION_ERROR,$s.MSG_I_SELECT_F_FIRST,$s.MSG_I_TYPES_LIMIT,$s.MSG_F_IS_EMPTY,$s.MSG_I_SIZE_LIMIT,$s.MSG_F_SELECT_F_FIRST,$s.MSG_F_SIZE_LIMIT,$s.MSG_V_SIZE_LIMIT,$s.MSG_V_TYPES_LIMIT,$s.MSG_A_UPLOAD_FAIL,$s.MSG_A_SIZE_LIMIT,$s.COS_UNDETECTED];function Ii(e){let t=!1;return Object.values(mi).includes(e)&&(t=!0),(e>=120001&&e<=13e4||e>=10100&&e<=10200)&&(t=!0),t}class fi extends Bs{constructor(e){super(e),this._n="MessageModule",this._messageOptionsMap=new Map,this._mergerMessageHandler=new gi(this)}createTextMessage(e){const t=this.getMyUserID();e.currentUser=t,e.senderTinyID=this.getMyTinyID();const s=new Eo(e),o=Oe(e.payload)?e.payload:e.payload.text,i=new ro({text:o}),n=this._getNickAndAvatarByUserID(t);return s.setElement(i),s.setNickAndAvatar(n),s.setNameCard(this._getNameCardByGroupID(s)),s}createImageMessage(e){const t=this.getMyUserID();e.currentUser=t,e.senderTinyID=this.getMyTinyID();const s=new Eo(e);if(G){const{file:t}=e.payload;if(ve(t))return void this.outputWarning("FileUnsupportedInMP","createImageMessage");const s=t.tempFiles[0].path||t.tempFiles[0].tempFilePath,o={url:s,name:s.slice(s.lastIndexOf("/")+1),size:t.tempFiles&&t.tempFiles[0].size||1,type:s.slice(s.lastIndexOf(".")+1).toLowerCase()};e.payload.file=o}else if(k)if(ve(e.payload.file)){const t=e.payload.file;e.payload.file={files:[t]}}else if(Le(e.payload.file)&&"undefined"!=typeof uni){const t=e.payload.file.tempFiles[0];e.payload.file={files:[t]}}const o=new ao({imageFormat:fe.UNKNOWN,uuid:this._generateUUID(e.payload.file),file:e.payload.file}),i=this._getNickAndAvatarByUserID(t);return s.setElement(o),s.setNickAndAvatar(i),s.setNameCard(this._getNameCardByGroupID(s)),this._messageOptionsMap.set(s.clientSequence,e),s}createAudioMessage(e){const{file:t}=e.payload;if(G){const s={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=s}const s=this.getMyUserID();e.currentUser=s,e.senderTinyID=this.getMyTinyID();const o=new Eo(e),i=new uo({second:Math.floor(t.duration/1e3),size:t.fileSize||t.size,url:t.tempFilePath,uuid:this._generateUUID(e.payload.file)}),n=this._getNickAndAvatarByUserID(s);return o.setElement(i),o.setNickAndAvatar(n),o.setNameCard(this._getNameCardByGroupID(o)),this._messageOptionsMap.set(o.clientSequence,e),o}createVideoMessage(e){const t=this.getMyUserID();e.currentUser=t,e.senderTinyID=this.getMyTinyID(),e.payload.file.thumbUrl="",e.payload.file.thumbSize=0;const s={};if(G){if(R)return void this.outputWarning("VideoUnsupportedInAlipay");if(ve(e.payload.file))return void this.outputWarning("FileUnsupportedInMP","createVideoMessage");let{file:t}=e.payload;Ue(t.tempFiles)&&(t=t.tempFiles[0]),s.url=t.tempFilePath,s.name=t.tempFilePath.slice(t.tempFilePath.lastIndexOf("/")+1),s.size=t.size||1,s.second=t.duration||0,s.type=t.tempFilePath.slice(t.tempFilePath.lastIndexOf(".")+1).toLowerCase()}else if(k){if(ve(e.payload.file)){const t=e.payload.file;e.payload.file.files=[t]}else if(Le(e.payload.file)&&"undefined"!=typeof uni){const t=e.payload.file.tempFile;e.payload.file.files=[t]}const{file:t}=e.payload;s.url=window.URL.createObjectURL(t.files[0]),s.name=t.files[0].name,s.size=t.files[0].size||1,s.second=t.files[0].duration||0,s.type=t.files[0].type.split("/")[1]}e.payload.file.videoFile=s;const o=new Eo(e),i=new Mo({videoFormat:s.type,videoSecond:dt(s.second,0),videoSize:s.size,remoteVideoUrl:"",videoUrl:s.url,videoUUID:this._generateUUID(e.payload.file.videoFile),thumbUUID:this._generateUUID(e.payload.file.videoFile),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()}),n=this._getNickAndAvatarByUserID(t);return o.setElement(i),o.setNickAndAvatar(n),o.setNameCard(this._getNameCardByGroupID(o)),this._messageOptionsMap.set(o.clientSequence,e),o}createCustomMessage(e){const t=this.getMyUserID();e.currentUser=t,e.senderTinyID=this.getMyTinyID();const s=new Eo(e),o=new mo({data:e.payload.data,description:e.payload.description,extension:e.payload.extension}),i=this._getNickAndAvatarByUserID(t);return s.setElement(o),s.setNickAndAvatar(i),s.setNameCard(this._getNameCardByGroupID(s)),s}createFaceMessage(e){const t=this.getMyUserID();e.currentUser=t,e.senderTinyID=this.getMyTinyID();const s=new Eo(e),o=new co(e.payload),i=this._getNickAndAvatarByUserID(t);return s.setElement(o),s.setNickAndAvatar(i),s.setNameCard(this._getNameCardByGroupID(s)),s}createMergerMessage(e){const t=this.getMyUserID();e.currentUser=t,e.senderTinyID=this.getMyTinyID();const s=this._getNickAndAvatarByUserID(t),o=new Eo(e),i=new To(e.payload);return o.setElement(i),o.setNickAndAvatar(s),o.setNameCard(this._getNameCardByGroupID(o)),o.setRelayFlag(!0),o}createForwardMessage(e){const{to:s,conversationType:o,priority:i,payload:n,needReadReceipt:r,receiverList:a}=e;if(!Ue(n._elements))return Vs({code:$s.MSG_FORWARD_INVALID_ELEMENTS});const c=this.getMyUserID(),u=this._getNickAndAvatarByUserID(c);if(n.type===t.MSG_GRP_TIP)return Vs({code:$s.MSG_FORWARD_TYPE_INVALID});const l={to:s,conversationType:o,conversationID:`${o}${s}`,priority:i,isPlaceMessage:0,status:Nt.UNSEND,currentUser:c,senderTinyID:this.getMyTinyID(),cloudCustomData:e.cloudCustomData||n.cloudCustomData||"",needReadReceipt:r,receiverList:a,isSupportExtension:e.isSupportExtension||!1},d=new Eo(l);return d.setElement(n._elements[0]),d.setNickAndAvatar(u),d.setNameCard(this._getNameCardByGroupID(n)),d.setRelayFlag(!0),d}downloadMergerMessage(e){return this._mergerMessageHandler.downloadMergerMessage(e)}createFileMessage(e){if(G){if(!D&&!v&&!U)return;let e;const t=w.getSystemInfoSync().SDKVersion;if(D&&(e="2.5.0",at(t,e)<0))return void this.outputWarning("WXChooseMessageFile");if(v&&(e="1.18.0",at(t,e)<0))return void this.outputWarning("QQChooseMessageFile")}if(k||U){if(ve(e.payload.file)){const t=e.payload.file;e.payload.file={files:[t]}}else if(Le(e.payload.file)&&"undefined"!=typeof uni){const{tempFiles:t,files:s}=e.payload.file;let o=null;Ue(t)?o=t[0]:Ue(s)&&(o=s[0]),e.payload.file={files:[o]}}}else if(D||v){const{tempFiles:t}=e.payload.file,s={...t[0],url:t[0].path};e.payload.file={files:[s]}}const t=this.getMyUserID();e.currentUser=t,e.senderTinyID=this.getMyTinyID();const s=new Eo(e),o=new go({uuid:this._generateUUID(e.payload.file),file:e.payload.file}),i=this._getNickAndAvatarByUserID(t);return s.setElement(o),s.setNickAndAvatar(i),s.setNameCard(this._getNameCardByGroupID(s)),this._messageOptionsMap.set(s.clientSequence,e),s}createLocationMessage(e){const t=this.getMyUserID();e.currentUser=t,e.senderTinyID=this.getMyTinyID();const s=new Eo(e),o=new Io(e.payload),i=this._getNickAndAvatarByUserID(t);return s.setElement(o),s.setNickAndAvatar(i),s.setNameCard(this._getNameCardByGroupID(s)),s}_onCannotFindModule(){return Vs({code:$s.CANNOT_FIND_MODULE})}sendMessageInstance(e,s){if(!1===this.getModule(Rs).filterMessage(e,s))return e.hasRiskContent=!0,this._onSendMessageFailed(e,new Fs({code:$s.PROFANITY_FOUND}));let o=null;if(e.conversationType===t.CONV_C2C)o=this.getModule(ls);else{if(e.conversationType!==t.CONV_GROUP)return Vs({code:$s.MSG_INVALID_CONV_TYPE});o=this.getModule(ds)}const i=this._n+".sendMessageInstance",n=this.getModule(hs),r=o.isOnlineMessage(e,s);let a;return this.getModule(fs).upload(e).then(()=>{if(this._getSendMessageSpecifiedKey(e)===Js){this.getModule(vs).addSuccessCount(Xs)}return this._guardForGroup(e).then(()=>{if(!e.isSendable())return Vs({code:$s.MSG_F_URL_IS_EMPTY});this._addSendMessageTotalCount(e),a=Date.now();const i=function(e){let t="utf-8";k&&document&&(t=document.charset.toLowerCase());let s,o=0,i=0;if(i=e.length,"utf-8"===t||"utf8"===t)for(let n=0;n<i;n++)s=e.codePointAt(n),s<=127?o+=1:s<=2047?o+=2:s<=65535?o+=3:(o+=4,n++);else if("utf-16"===t||"utf16"===t)for(let n=0;n<i;n++)s=e.codePointAt(n),s<=65535?o+=2:(o+=4,n++);else o=e.replace(/[^\x00-\xff]/g,"aa").length;return o}(JSON.stringify(e));return e.type===t.MSG_MERGER&&i>11264?this._mergerMessageHandler.uploadMergerMessage(e,i).then(t=>{const o=this._mergerMessageHandler.createMergerMessagePack(e,s,t);return this.request(o)}):(n.setMessageRandom(e),o.sendMessage(e,s))}).then(o=>{const{time:c,sequence:u,readReceiptCode:l,messageDropReason:d}=o.data;if(Ae(l)&&0!==l){new no("sendMessageWithReceipt").setMessage(`from:${e.from} to:${e.to} sequence:${u} readReceiptCode:${l}`).end(),Ie.w(`${i} readReceiptCode:${l} message:${this.getErrorMessage(l)}`)}if(d){const t=new no("messageDropReason"),s=`from:${e.from} to:${e.to} sequence:${u} messageDropReason:${d}`;t.setMessage(s).end(),Ie.w(`${i} ${s}`)}if(this._addSendMessageSuccessCount(e,a),this._messageOptionsMap.delete(e.clientSequence),!0===e.isResend){const t=n.findMessage(e.ID);t&&(Ie.l(`${i} resend ok. ID:${t.ID}`),n.deleteLocalMessage(t))}e.status=Nt.SUCCESS,e.time=c;let _=!1;if(e.conversationType===t.CONV_GROUP)e.sequence=u;else if(e.conversationType===t.CONV_C2C){const t=n.getLatestMessageSentByMe(e.conversationID);if(t){const{nick:s,avatar:o}=t;s===e.nick&&o===e.avatar||(_=!0)}}if(_&&n.modifyMessageSentByMe({conversationID:e.conversationID,latestNick:e.nick,latestAvatar:e.avatar}),!0===r)e._onlineOnlyFlag=!0;else{n.appendToMessageList(e);let o=e;Le(s)&&Le(s.messageControlInfo)&&(!0===s.messageControlInfo.excludedFromLastMessage&&(e._isExcludedFromLastMessage=!0,o=""),!0===s.messageControlInfo.excludedFromUnreadCount&&(e._isExcludedFromUnreadCount=!0));let i=e.conversationType;if(Qe(e.to)){i=t.CONV_TOPIC;this.getModule(ps).onMessageSent({groupID:ht(e.to),topicID:e.to,lastMessage:o})}n.onMessageSent({conversationOptionsList:[{conversationID:e.conversationID,unreadCount:0,type:i,subType:e.conversationSubType,lastMessage:o}]})}return e._relayFlag||"TIMImageElem"!==e.type||ut(e.payload.imageInfoArray),ws({message:e})})}).catch(t=>this._onSendMessageFailed(e,t,r))}_guardForGroup(e){if(e.conversationType!==t.CONV_GROUP)return Promise.resolve();const s=this.getModule(ds);if(!s)return this._onCannotFindModule();if(Xe({groupID:e.to})){const t=s.getLocalGroupProfile(e.to);if(t&&t.isSupportTopic)return Vs({code:$s.MSG_SEND_GRP_WITH_TOPIC_FAIL})}return s.guardForAVChatRoom(e)}_onSendMessageFailed(e,t,s=!1){const o=this._n+"._onSendMessageFailed";e.status=Nt.FAIL,80001!==t.code&&80004!==t.code||(e.hasRiskContent=!0);const i=this.getModule(hs);i.deleteMessageRandom(e);const n=t.code>=10100&&t.code<=10200||t.code>=120001&&t.code<=13e4;if(!s&&!n){!0===i.appendToMessageList(e)&&Ie.l(`${o} message stored, ID:${e.ID}`)}this._addSendMessageFailCountOnUser(e,t);const r=new no("sendMessage");return r.setMessage(`tjg_id:${this.generateTjgID(e)} type:${e.type} from:${e.from} to:${e.to}`),this.probeNetwork().then(([e,s])=>{r.setError(t,e,s).end()}),Ie.e(o+" error:",t),Vs(new Fs({code:t&&t.code?t.code:$s.MSG_SEND_FAIL,message:t&&t.message?t.message:void 0,data:{message:e}}))}_getSendMessageSpecifiedKey(e){if([t.MSG_IMAGE,t.MSG_AUDIO,t.MSG_VIDEO,t.MSG_FILE].includes(e.type))return Js;if(e.conversationType===t.CONV_C2C)return Ws;if(e.conversationType===t.CONV_GROUP){const t=this.getModule(ds);if(!t)return;const s=t.getLocalGroupProfile(e.to);if(!s)return;const o=s.type;return Je(o)?js:zs}}_addSendMessageTotalCount(e){const t=this._getSendMessageSpecifiedKey(e);if(t){this.getModule(vs).addTotalCount(t)}}_addSendMessageSuccessCount(e,t){const s=this._getSendMessageSpecifiedKey(e);if(s){const e=this.getModule(vs);e.addSuccessCount(s),e.addCost(s,Tt(t,!1))}}_addSendMessageFailCountOnUser(e,t){const{code:s=-1}=t,o=this.getModule(vs),i=this._getSendMessageSpecifiedKey(e);i===Js&&function(e){let t=!1;return Mi.includes(e)&&(t=!0),t}(s)?o.addFailedCountOfUserSide(Xs):Ii(s)&&i&&o.addFailedCountOfUserSide(i)}resendMessage(e,t){return e.isResend=!0,e.status=Nt.UNSEND,this.sendMessageInstance(e,t)}revokeMessage(e){let s=null;if(e.conversationType===t.CONV_C2C?s=this.getModule(ls):e.conversationType===t.CONV_GROUP&&(s=this.getModule(ds)),!s)return this._onCannotFindModule();const o=new no("revokeMessage");o.setMessage(`tjg_id:${this.generateTjgID(e)} type:${e.type} from:${e.from} to:${e.to}`);const i=this._n+".revokeMessage";return s.revokeMessage(e).then(t=>{const s=t.data.recallRetList;if(!St(s)&&0!==s[0].retCode){const t=new Fs({code:s[0].retCode,data:{message:e}});return o.setCode(t.code).setMoreMessage(t.message).end(),Vs(t)}Ie.i(`${i} ok. ID:${e.ID}`),e.isRevoked=!0,o.end();return this.getModule(hs).onMessageRevoked([e]),ws({message:e})}).catch(t=>{this.probeNetwork().then(([e,s])=>{o.setError(t,e,s).end()});const s=new Fs({code:t&&t.code?t.code:$s.MSG_REVOKE_FAIL,message:t&&t.message?t.message:void 0,data:{message:e}});return Ie.w(i+" failed. error:",t),Vs(s)})}deleteMessage(e){let s=null;const o=e[0],i=o.conversationID;let n="",r=[],a=[];if(o.conversationType===t.CONV_C2C)s=this.getModule(ls),n=i.replace(t.CONV_C2C,""),e.forEach(e=>{e&&e.status===Nt.SUCCESS&&e.conversationID===i&&(e._onlineOnlyFlag||r.push(`${e.sequence}_${e.random}_${e.time}`),a.push(e))});else if(o.conversationType===t.CONV_GROUP)s=this.getModule(ds),n=i.replace(t.CONV_GROUP,""),e.forEach(e=>{e&&e.status===Nt.SUCCESS&&e.conversationID===i&&(e._onlineOnlyFlag||r.push(""+e.sequence),a.push(e))});else if(o.conversationType===t.CONV_SYSTEM)return Vs({code:$s.CANNOT_DELETE_GRP_SYSTEM_NOTICE});if(!s)return this._onCannotFindModule();if(0===r.length)return this._onMessageDeleted(a);r.length>30&&(r=r.slice(0,30),a=a.slice(0,30));const c=new no("deleteMessage");c.setMessage(`to:${n} count:${r.length}`);const u=this._n+".deleteMessage";return s.deleteMessage({to:n,keyList:r}).then(e=>(c.end(),Ie.i(u+" ok"),this._onMessageDeleted(a))).catch(e=>{this.probeNetwork().then(([t,s])=>{c.setError(e,t,s).end()}),Ie.w(u+" failed. error:",e);const t=new Fs({code:e&&e.code?e.code:$s.MSG_DELETE_FAIL,message:e&&e.message?e.message:void 0});return Vs(t)})}_onMessageDeleted(e){return this.getModule(hs).onMessageDeleted(e),xs({messageList:e})}translateText(e){const t=this._n+".translateText",{sourceTextList:s,sourceLanguage:o,targetLanguage:i}=e,n=new no("translateText");return n.setMessage(`sourceLanguage:${o} targetLanguage:${i}`),this.request({protocolName:Ks.TRANSLATE_TEXT,requestData:{sourceTextList:s,source:o||"auto",target:i,from:this.getMyTinyID(),SDKAppID:this.getSDKAppID()}}).then(e=>{const{error:s,requestID:o,translatedTextList:i}=e.data,{code:r}=s;if(0===r)return n.end(),Ie.i(`${t} ok. requestID:${o}`),ws({translatedTextList:i});throw{...s,requestID:o}}).catch(e=>(n.setCode(e.code).setMoreMessage(e.requestID).end(),Ie.w(t+" failed. error:",e),Vs({code:$s.TRANSLATE_TEXT_FAIL})))}convertVoiceToText(e){const{message:t,language:s}=e;let o=t.payload.url;t.from===this.getMyUserID()&&"out"===t.flow&&(o=t.payload.remoteAudioUrl);const i=/\.(wav|pcm|ogg-opus|speex|silk|mp3|m4a|aac|amr)/;if(!i.test(o))return Vs({code:$s.UNSUPPORTED_VOICE_FORMAT});const n=i.exec(o)[1]||"mp3";let r="16k_zh-PY";s?"zh (cmn-Hans-CN)"===s?r="16k_zh":"en-US"===s?r="16k_en":"yue-Hant-HK"===s?r="16k_yue":"ja-JP"===s&&(r="16k_ja"):r="16k_zh-PY";const a=`serviceType:${r} url:${o}`,c=this._n+".convertVoiceToText";Ie.i(`${c} ${a}`);const u=new no("convertVoiceToText");return u.setMessage(a),this.request({protocolName:Ks.VOICE_TO_TEXT,requestData:{url:o,language:r,SDKAppID:this.getSDKAppID(),format:n}}).then(e=>{const{error:t,requestID:s,result:o}=e.data,{code:i}=t;if(0===i)return u.end(),Ie.i(`${c} ok. requestID:${s}`),ws({result:o});throw{...t,requestID:s}}).catch(e=>(u.setCode(e.code).setMoreMessage(e.requestID||"").end(),Ie.w(c+" failed. error:",e),Vs({code:$s.VOICE_TO_TEXT_FAIL})))}modifyRemoteMessage(e){let s=null;const{conversationType:o,to:i}=e,n=this.getModule(ds);if(!n)return this._onCannotFindModule();if(n.isMessageFromOrToAVChatroom(i))return Vs({code:$s.MSG_MODIFY_DISABLED_IN_AVCHATROOM,data:{message:e}});if(!1===this.getModule(Rs).filterMessage(e))return e.hasRiskContent=!0,Vs({code:$s.PROFANITY_FOUND,data:{message:e}});o===t.CONV_C2C?s=this.getModule(ls):o===t.CONV_GROUP&&(s=this.getModule(ds));const r=new no("modifyMessage");r.setMessage("to:"+i);const a=this._n+".modifyRemoteMessage";return s.modifyRemoteMessage(e).then(t=>{r.end(),Ie.i(a+" ok");const s=this._onModifyRemoteMessageResp(e,t.data);return ws({message:s})}).catch(t=>{if(r.setCode(t.code).setMoreMessage(t.message).end(),Ie.w(a+" failed. error:",t),20027===t.code){const s=this._onModifyRemoteMessageResp(e,t.data);return Vs({code:$s.MSG_MODIFY_CONFLICT,data:{message:s}})}return Vs({code:t.code,message:t.message,data:{message:e}})})}_generateSearchRequestData(e){const{conversationID:s,timePosition:o,timePeriod:i,...n}=e;return Pe(s)||(Ze(s)&&(n.account=s.replace(t.CONV_C2C,"")),et(s)&&(n.groupID=s.replace(t.CONV_GROUP,""))),Ae(i)&&i>0&&(Ae(o)&&o>0?n.startTime=o-i:n.startTime=he()-i),n.startTime&&n.startTime<0&&(n.startTime=void 0),Ae(o)&&o>0&&(n.endTime=o),n}searchCloudMessages(e){const t="searchCloudMessages",s=`${this._n}.${t}`;if(!e)return Vs({code:$s.OPTIONS_IS_EMPTY,message:this.getErrorMessage($s.OPTIONS_IS_EMPTY,t)});const{keywordList:o,keywordListMatchType:i,conversationID:n,cursor:r}=e,a=Ue(e.senderUserIDList)&&e.senderUserIDList.length>0,c=Ue(e.messageTypeList)&&e.messageTypeList.length>0;if(!o&&!a&&!c)throw Ie.e(`[${t}] Missing required params: "keywordList".`),new Error("Params validate failed.");const u=Date.now(),l=new no(t),d=`keywordList:${o} keywordListMatchType:${i} conversationID:${n} cursor:${r}`;return Ie.l(`${s} ${d}`),this.request({protocolName:Ks.MESSAGE_CLOUD_SEARCH,requestData:this._generateSearchRequestData(e)}).then(t=>{const{code:o,message:i}=t.data;if(0!==o){let e=o;60020===o&&(e="SearchCloudMessagesUnavailable");const t=this.getErrorMessage(e)||i,s=new Fs({code:o,message:t});return this.probeNetwork().then(([e,t])=>{l.setMessage(d).setError(s,e,t).end()}),Vs(s)}const{cursor:n,totalCount:r,searchResult:a}=t.data,c=`totalCount:${r} cost:${Tt(u)}`;Ie.l(`${s} ok. cursor:${n} ${c}`),l.setNetworkType(this.getNetworkType()).setMessage(`${d} ${c}`).end();const _=this._handleSearchResults(a,!e.conversationID);return ws({searchResultList:_,cursor:n,totalCount:r})}).catch(e=>(this.probeNetwork().then(([t,s])=>{l.setMessage(d).setError(e,t,s).end()}),Vs(e)))}_handleSearchResults(e,s){const o=this.getModule(hs);return Ue(e)&&0!==e.length?e.map(({groupID:e,userID:i,messageCount:n,messageList:r})=>{const a=e?`${t.CONV_GROUP}${e}`:`${t.CONV_C2C}${i}`,c={conversationID:a,messageCount:n,messageList:[]};if(s&&n>1)return c;if(r&&r.length>0){const t=o.onRoamingMessage(r,a,!1);e&&t.reverse(),c.messageList=t}return c}):[]}_onModifyRemoteMessageResp(e,t){Ie.d(this._n+"._onModifyRemoteMessageResp options:",t);const{conversationType:s,from:o,to:i,random:n,sequence:r,time:a}=e,{elements:c,messageVersion:u,cloudCustomData:l=""}=t;return this.getModule(hs).onMessageModified({conversationType:s,from:o,to:i,time:a,random:n,sequence:r,elements:c,cloudCustomData:l,messageVersion:u})}_generateUUID(e){const t=this.getModule(gs);let s=`${t.getSDKAppID()}-${t.getUserID()}-${function(){let e="";for(let t=32;t>0;--t)e+=Ke[Math.floor(Math.random()*He)];return e}()}`;const o=e.name||e.value||e.url||e.tempFilePath,i=o&&o.slice(o.lastIndexOf(".")+1);return i&&(s=`${s}.${i}`),s}getMessageOption(e){return this._messageOptionsMap.get(e)}_getNickAndAvatarByUserID(e){return this.getModule(us).getNickAndAvatarByUserID(e)}_getNameCardByGroupID(e){if(e.conversationType===t.CONV_GROUP){const t=this.getModule(ds);if(t)return t.getMyNameCardByGroupID(e.to)}return""}reset(){Ie.l(this._n+".reset"),this._messageOptionsMap.clear()}}class Ti extends Bs{constructor(e){super(e),this._n="MessageExtensionModule",this.messageExtensionMap=new Map,this.globalSeqMap=new Map,this.getMessageExtensionsMap=new Map}onMessageExtensionNotify(t){const{messageInfo:s,operateType:o,operateResultList:i,tinyID:n,globalSequence:r}=t.dataList,{clientTime:a,random:c}=s,u=`${n}-${a}-${c}`,l=[],d=[];Ie.l(`${this._n}.onMessageExtensionNotify messageID:${u} operateType:${o} globalSequence:${r}`),this._updateGlobalSequence(u,r);let _=!1,p=!1;i.forEach(e=>{const{extensions:t=[],clearSequence:s}=e;if(1===o)_=!0,t.forEach(e=>{l.push({key:e.key,value:e.value})}),this._updateLocalExtension(u,t);else if(2===o)p=!0,t.forEach(e=>{d.push(e.key)}),this._updateLocalExtension(u,t);else if(3===o){if(p=!0,this._hasLocalExtension(u)){this._getLocalExtension(u).forEach((e,t)=>{e.seq<=s&&!St(e.value)&&d.push(t)})}this._clearLocalExtension(u,s)}}),_&&this.emitOuterEvent(e.MESSAGE_EXTENSIONS_UPDATED,{messageID:u,extensions:l}),p&&this.emitOuterEvent(e.MESSAGE_EXTENSIONS_DELETED,{messageID:u,keyList:d})}setMessageExtensions(e,t){const s="setMessageExtensions";if(!this.canIUse(I.MSG_EXT))return this.cannotUseCommercialAbility(s);const o=`${this._n}.${s}`,{ID:i,conversationID:n,sequence:r,time:a}=e;let c=[...t];t.length>20&&(c=t.slice(0,20),Ie.w(o+". the length of extensions cannot exceed 20."));const u=`conversationID:${n} messageID:${i} sequence:${r} time:${a} count:${c.length}`,l=new no(s);return l.setMessage(u),Ie.l(`${o} ${u}`),this._modifyMessageExtensions(e,c).then(e=>{const{resultList:t,successCount:s,failureCount:i}=e,n=`success count:${s} fail count:${i}`;return l.setMoreMessage(n).end(),Ie.l(`${o} ok. ${n}`),ws({extensions:t})}).catch(e=>(this.probeNetwork().then(([t,s])=>{l.setError(e,t,s).end()}),Ie.e(o+" failed. error:",e),Vs(e)))}getMessageExtensions(e){const t="getMessageExtensions";if(!this.canIUse(I.MSG_EXT))return this.cannotUseCommercialAbility(t);const s=`${this._n}.${t}`,{ID:o,conversationID:i,sequence:n,time:r}=e,a=`conversationID:${i} messageID:${o} sequence:${n} time:${r}`,c=new no(t);c.setMessage(a),Ie.l(`${s} ${a}`);let u=void 0;return this.getMessageExtensionsMap.has(o)&&(u=this._getGlobalSequence(o)),this._getMessageExtensions(e,u).then(e=>(c.end(),Ie.l(`${s} ok. total count:${e.length}`),Pe(u)&&e.length>0&&this.getMessageExtensionsMap.set(o,1),ws({extensions:e}))).catch(e=>(this.probeNetwork().then(([t,s])=>{c.setError(e,t,s).end()}),Ie.e(s+" failed. error:",e),Vs(e)))}deleteMessageExtensions(e,t){const s="deleteMessageExtensions";if(!this.canIUse(I.MSG_EXT))return this.cannotUseCommercialAbility(s);const o=`${this._n}.${s}`,i=[];let n=3;St(t)||(n=2,t.forEach(e=>{i.push({key:e,value:"",seq:0})}));const{ID:r,conversationID:a,sequence:c,time:u}=e,l=`conversationID:${a} messageID:${r} sequence:${c} time:${u} operateType:${n}`,d=new no(s);return d.setMessage(l),Ie.l(`${o} ${l}`),this._modifyMessageExtensions(e,i,n).then(e=>{const{resultList:t,successCount:s,failureCount:i}=e;let r="";return 2===n&&(r=`success count:${s} fail count:${i}`),d.setMoreMessage(""+r).end(),Ie.l(`${o} ok. ${r}`),ws({extensions:t})}).catch(e=>(this.probeNetwork().then(([t,s])=>{d.setError(e,t,s).end()}),Ie.e(o+" failed. error:",e),Vs(e)))}_modifyMessageExtensions(e,s,o=1){const i=Qe(e.to)?t.CONV_TOPIC:e.conversationType;let n=void 0;3!==o&&(n=this._getRequestExtensions(e,s));let r=null;switch(i){case t.CONV_C2C:r=this.getModule(ls);break;case t.CONV_GROUP:r=this.getModule(ds);break;case t.CONV_TOPIC:r=this.getModule(ps);break;default:return Vs({code:$s.CANNOT_FIND_MODULE})}return r.modifyMessageExtensions(e,n,o).then(t=>{let{extensions:s,seq:o}=t.data;const i=[];let n=0,r=0,a=[];return s=St(s)?[]:s,s.forEach(e=>{const{errorCode:t,extension:s}=e,{key:o,value:c,seq:u}=s;i.push({code:t,key:o,value:c}),0===t?n++:r++,a.push({key:o,value:c,seq:u})}),this._updateGlobalSequence(e.ID,o),a.length>0&&(this._updateLocalExtension(e.ID,a),a=null),{resultList:i,successCount:n,failureCount:r}}).catch(e=>Vs(e))}_getRequestExtensions(e,t){const s=[];if(this._hasLocalExtension(e.ID)){const o=this._getLocalExtension(e.ID);return t.forEach(e=>{const{key:t,value:i}=e;let n=0;o.has(t)&&(n=o.get(t).seq),s.push({key:t,value:i,seq:n})}),s}return t.forEach(e=>{const{key:t,value:o}=e;s.push({key:t,value:o,seq:0})}),s}_getMessageExtensions(e,s){const o=this._n+"._getMessageExtensions",{ID:i,to:n}=e;let r=null;switch(Qe(n)?t.CONV_TOPIC:e.conversationType){case t.CONV_C2C:r=this.getModule(ls);break;case t.CONV_GROUP:r=this.getModule(ds);break;case t.CONV_TOPIC:r=this.getModule(ps);break;default:return Vs({code:$s.CANNOT_FIND_MODULE})}return r.getMessageExtensions(e,s).then(t=>{let{extensions:s,completeFlag:n,globalSequence:r,clearSequence:a}=t.data;if(s=St(s)?[]:s,Ie.l(`${o} ok. completeFlag:${n} globalSequence:${r} clearSequence:${a} count:${s.length}`),this._updateLocalExtension(i,s),this._clearLocalExtension(i,a),this._updateGlobalSequence(i,r),1!==n){const t=s.slice(-1)[0].seq+1;return this._getMessageExtensions(e,t)}return this._getLocalExtensions(i)}).catch(e=>Vs(e))}_hasLocalExtension(e){return this.messageExtensionMap.has(e)}_getLocalExtension(e){return this.messageExtensionMap.get(e)}_updateLocalExtension(e,t){this._hasLocalExtension(e)||this.messageExtensionMap.set(e,new Map);const s=this._getLocalExtension(e);t.forEach(e=>{const{key:t,value:o="",seq:i}=e;s.set(t,{value:o,seq:i})})}_clearLocalExtension(e,t){if(!(t<=0)&&this._hasLocalExtension(e)){const s=this._getLocalExtension(e);s.forEach((e,o)=>{e.seq<=t&&s.delete(o)})}}_getLocalExtensions(e){const t=[];if(this._hasLocalExtension(e)){this._getLocalExtension(e).forEach((e,s)=>{const{value:o}=e;St(o)||t.push({key:s,value:o})})}return t}_getGlobalSequence(e){return this.globalSeqMap.get(e)}_updateGlobalSequence(e,t){this.globalSeqMap.set(e,t)}reset(){Ie.l(this._n+".reset"),this.messageExtensionMap.clear(),this.globalSeqMap.clear(),this.getMessageExtensionsMap.clear()}}class Ci extends Bs{constructor(e){super(e),this._n="MessageReactionModule",this._reactedByMyselfMap=new Map,this._reactionInfoMap=new Map}onMessageReactionNotifyList(t){const{dataList:s=[]}=t||{};s.forEach(t=>{const{C2CMessageInfo:s={},groupMessageInfo:o={},reactionList:i=[]}=t,{tinyID:n,clientTime:r,random:a}={...s,...o},c=`${n}-${r}-${a}`,u=[];i.forEach(e=>{Pe(e.userIDList)&&(e.userIDList=[],e.count=0),u.push(...e.userIDList)}),Ie.l(`${this._n}.onMessageReactionNotifyList messageID:${c} reactionList:${i.length}`),this._handleReactionSummary([{messageID:c,reactionList:i}],u).then(t=>{this.emitOuterEvent(e.MESSAGE_REACTIONS_UPDATED,{...t[0]})})})}onMessageReactionNotify(t){const{C2CMessageInfo:s={},groupMessageInfo:o={},reactionID:i,operateType:n}=t.dataList||{},{tinyID:r,clientTime:a,random:c}={...s,...o},u=`${r}-${a}-${c}`;Ie.l(`${this._n}.onMessageReactionNotify messageID:${u} reactionID:${i} operateType:${n}`),1===n?this._addReactedByMyselfMap(u,i):this._removeReactedByMyselfMap(u,i);const l=`${u}-${i}`;if(this._reactionInfoMap.has(l)){const t=this._reactionInfoMap.get(l);t.reactedByMyself=1===n,this.emitOuterEvent(e.MESSAGE_REACTIONS_UPDATED,{messageID:u,reactionList:[t]})}}addMessageReaction(e,t){const s="addMessageReaction";if(!this.canIUse(I.MSG_REACTION))return this.cannotUseCommercialAbility(s);const o=`${this._n}.${s}`,{ID:i,conversationID:n}=e,r=`conversationID:${n} messageID:${i} reactionID:${t}`,a=new no(s);a.setMessage(r),Ie.l(`${o} ${r}`);const c=this._createReactionOperationPack(e,t,1);return this._addReactedByMyselfMap(e.ID,t),this.request(c).then(()=>(a.end(),Ie.l(o+" ok."),ws())).catch(s=>(this._removeReactedByMyselfMap(e.ID,t),this.probeNetwork().then(([e,t])=>{a.setError(s,e,t).end()}),Ie.e(o+" failed. error:",s),Vs(s)))}removeMessageReaction(e,t){const s="removeMessageReaction";if(!this.canIUse(I.MSG_REACTION))return this.cannotUseCommercialAbility(s);const o=`${this._n}.${s}`,{ID:i,conversationID:n}=e,r=`conversationID:${n} messageID:${i} reactionID:${t}`,a=new no(s);a.setMessage(r),Ie.l(`${o} ${r}`);const c=this._createReactionOperationPack(e,t,2);return this._removeReactedByMyselfMap(e.ID,t),this.request(c).then(()=>(a.end(),Ie.l(o+" ok."),ws())).catch(e=>(this.probeNetwork().then(([t,s])=>{a.setError(e,t,s).end()}),Ie.e(o+" failed. error:",e),Vs(e)))}getMessageReactions(e){const t="getMessageReactions";if(!this.canIUse(I.MSG_REACTION))return this.cannotUseCommercialAbility(t);const s=`${this._n}.${t}`,{messageList:o,maxUserCountPerReaction:i}=e,{conversationID:n}=o[0],r=`conversationID:${n} maxUserCountPerReaction:${i} messageList:${o.length}`,a=new no(t);a.setMessage(r),Ie.l(`${s} ${r}`);const c=new Map,u=this._createReactionSummaryPack({...e,messageIDMap:c});return this.request(u).then(e=>{const{resultList:t=[]}=e.data,s=[],o=[];return t.forEach(e=>{const{messageKey:t,messageSequence:i,reactionList:n=[]}=e,r=Pe(t)?c.get(i):c.get(t);s.push({messageID:r,reactionList:n}),n.forEach(e=>{o.push(...e.userIDList)})}),this._handleReactionSummary(s,o)}).then(e=>(a.end(),Ie.l(s+" ok."),c.clear(),ws({resultList:e}))).catch(e=>(this.probeNetwork().then(([t,s])=>{a.setError(e,t,s).end()}),Ie.e(s+" failed. error:",e),Vs(e)))}getAllUserListOfMessageReaction(e){const t="getAllUserListOfMessageReaction";if(!this.canIUse(I.MSG_REACTION))return this.cannotUseCommercialAbility(t);const s=`${this._n}.${t}`,{message:o,reactionID:i,nextSeq:n,count:r}=e,{ID:a,conversationID:c}=o,u=`conversationID:${c} messageID:${a} reactionID:${i} nextSeq:${n} count:${r}`,l=new no(t);l.setMessage(u),Ie.l(`${s} ${u}`);const d={userList:[],nextSeq:0,isCompleted:!1},_=this._createReactionUserListPack(e);return this.request(_).then(e=>{const{userIDList:t=[],nextSeq:s=0}=e.data;d.nextSeq=s,d.isCompleted=0===s;return this.getModule(us).getUserNickAndAvatar(t)}).then(e=>(d.userList=e,l.end(),Ie.l(s+" ok."),ws(d))).catch(e=>(this.probeNetwork().then(([t,s])=>{l.setError(e,t,s).end()}),Ie.e(s+" failed. error:",e),Vs(e)))}_createReactionOperationPack(e,s,o){let i=void 0;const n={reactionID:s,userIDList:[this.getMyUserID()]};if(e.conversationType===t.CONV_C2C){const t=this.getModule(ls);i=1===o?Ks.ADD_C2C_MSG_REACTION:Ks.REMOVE_C2C_MSG_REACTION,n.from=e.from,n.to=e.to,n.messageKey=t.getMessageKey(e)}if(e.conversationType===t.CONV_GROUP){let t=void 0,s=e.to;Qe(e.to)&&(t=e.to,s=ht(t)),i=1===o?Ks.ADD_GRP_MSG_REACTION:Ks.REMOVE_GRP_MSG_REACTION,n.groupID=s,n.topicID=t,n.messageSequence=e.sequence}return{protocolName:i,requestData:n}}_createReactionSummaryPack(e){const{messageList:s,maxUserCountPerReaction:o=10,messageIDMap:i}=e,n=s[0];let r=void 0,a=void 0;if(n.conversationType===t.CONV_C2C){const e=this.getModule(ls),t=s.map(t=>{const s=e.getMessageKey(t);return i.set(s,t.ID),s});r=Ks.GET_C2C_MSG_REACTIONS,a={from:n.from,to:n.to,messageKeyList:t,count:o}}if(n.conversationType===t.CONV_GROUP){let e=void 0,t=n.to;Qe(n.to)&&(e=n.to,t=ht(e));const c=s.map(e=>(i.set(e.sequence,e.ID),e.sequence));r=Ks.GET_GRP_MSG_REACTIONS,a={groupID:t,topicID:e,messageSequenceList:c,count:o}}return{protocolName:r,requestData:a}}_createReactionUserListPack(e){const{message:s,reactionID:o,nextSeq:i=0,count:n=100}=e;let r=void 0;const a={reactionID:o,nextSeq:i,count:n>100?100:n};if(s.conversationType===t.CONV_C2C){const e=this.getModule(ls);r=Ks.GET_C2C_MSG_REACTION_USER_LIST,a.from=s.from,a.to=s.to,a.messageKey=e.getMessageKey(s)}if(s.conversationType===t.CONV_GROUP){let e=void 0,t=s.to;Qe(s.to)&&(e=s.to,t=ht(e)),r=Ks.GET_GRP_MSG_REACTION_USER_LIST,a.groupID=t,a.topicID=e,a.messageSequence=s.sequence}return{protocolName:r,requestData:a}}_handleReactionSummary(e,t){return this.getModule(us).getUserNickAndAvatar(t).then(t=>{const s=[];return e.forEach(e=>{const o=[];e.reactionList.forEach(s=>{const{reactionID:i,count:n,userIDList:r,reactedByMyself:a}=s,c=[];r.forEach(e=>{t.forEach(t=>{e===t.userID&&c.push(t)})});const u={reactionID:i,totalUserCount:n,partialUserList:c,reactedByMyself:this._computeReactedByMyself({reactedByMyself:a,messageID:e.messageID,reactionID:i})};if(o.push(u),Pe(a)&&!this._reactedByMyselfMap.has(e.messageID)){const t=`${e.messageID}-${i}`;this._reactionInfoMap.set(t,u)}}),s.push({messageID:e.messageID,reactionList:o})}),s})}_addReactedByMyselfMap(e,t){this._reactedByMyselfMap.has(e)||this._reactedByMyselfMap.set(e,[]);const s=this._reactedByMyselfMap.get(e);-1===s.indexOf(t)&&s.push(t)}_removeReactedByMyselfMap(e,t){if(!this._reactedByMyselfMap.has(e))return;const s=this._reactedByMyselfMap.get(e),o=s.indexOf(t);o>-1&&s.splice(o,1)}_computeReactedByMyself({reactedByMyself:e,messageID:t,reactionID:s}){return Pe(e)?!!this._reactedByMyselfMap.has(t)&&this._reactedByMyselfMap.get(t).includes(s):1===e}reset(){Ie.l(this._n+".reset"),this._reactedByMyselfMap.clear(),this._reactionInfoMap.clear()}}class Ei extends Bs{constructor(e){super(e),this._n="ComboMessageModule"}sendMessage(e){const s=this._constructMessageInstance(e);if(null===s)return Vs({code:$s.MSG_SEND_FAIL});this._addSendMessageTotalCount(s);const o=Date.now();return this.getModule(hs).setMessageRandom(s),this._sendComboMessage(s,e).then(e=>{const{time:i,sequence:n,readReceiptCode:r}=e.data;if(Ae(r)&&0!==r){new no("sendMessageWithReceipt").setMessage(`from:${s.from} to:${s.to} sequence:${n} readReceiptCode:${r}`).end(),Ie.w(`${this._n}.sendMessage readReceiptCode:${r} message:${this.getErrorMessage(r)}`)}this._addSendMessageSuccessCount(s,o);const a=this.getModule(hs);s.status=Nt.SUCCESS,s.time=i,s.conversationType===t.CONV_GROUP&&(s.sequence=n),a.appendToMessageList(s);let c=s;return!0===s._isExcludedFromLastMessage&&(c=""),a.onMessageSent({conversationOptionsList:[{conversationID:s.conversationID,unreadCount:0,type:s.conversationType,subType:s.conversationSubType,lastMessage:c}]}),ws({message:s})}).catch(e=>this._onSendMessageFailed(s,e))}_sendComboMessage(e,s){const o=this._m.getModule(Es);let i="";return e.conversationType===t.CONV_C2C&&(i=`${M.NAME.OPEN_IM}.${Ks.SEND_C2C_MESSAGE}`),e.conversationType===t.CONV_GROUP&&(i=`${M.NAME.GROUP}.${Ks.SEND_GROUP_MESSAGE}`),o.sendComboMessage({servcmd:i,data:s})}_constructMessageInstance(e){const s=this._n+"._constructMessageInstance";let o=null;try{const i=this.getMyUserID(),n={};if(n.senderTinyID=this.getMyTinyID(),n.currentUser=i,n.from=e.From_Account||i,e.GroupId?(n.conversationID=`${t.CONV_GROUP}${e.GroupId}`,n.conversationType=t.CONV_GROUP,n.to=e.GroupId):e.To_Account&&(n.conversationID=`${t.CONV_C2C}${e.To_Account}`,n.conversationType=t.CONV_C2C,n.to=e.To_Account),n.time=e.MsgTimeStamp||0,n.random=e.Random||e.MsgRandom||0,n.priority=e.MsgPriority,Oe(e.CloudCustomData)&&e.CloudCustomData.length>0&&(n.cloudCustomData=e.CloudCustomData),Ue(e.SendMsgControl)&&(n.messageControlInfo={},e.SendMsgControl.includes("NoUnread")&&(n.messageControlInfo.excludedFromUnreadCount=1),e.SendMsgControl.includes("NoLastMsg")&&(n.messageControlInfo.excludedFromLastMessage=1)),n.conversationType===t.CONV_GROUP&&Ue(e.To_Account)&&e.To_Account.length>0){let t=e.To_Account;e.To_Account.length>50&&(t=e.To_Account.slice(0,50),Ie.w(s+" To_Account must be less than or equal to 50.")),n.receiverList=[...t],e.To_Account=[...t]}1!==e.IsNeedReadReceipt&&1!==e.NeedReadReceipt||(n.needReadReceipt=!0),1===e.SupportMessageExtension&&(n.isSupportExtension=!0),o=new Eo(n),o.status=Nt.UNSEND,e.MsgClientTime=o.clientTime,o.conversationType===t.CONV_C2C&&(e.MsgSeq=o.sequence);const r=e.MsgBody.length;let a;for(let t=0;t<r;t++)a=e.MsgBody[t],"TIMTextElem"===a.MsgType?o.setTextElement(a.MsgContent.Text):"TIMCustomElem"===a.MsgType?o.setCustomElement({data:a.MsgContent.Data||"",description:a.MsgContent.Desc||"",extension:a.MsgContent.Ext||""}):"TIMFaceElem"===a.MsgType&&o.setFaceElement({index:a.MsgContent.Index,data:a.MsgContent.Data});const c=o.getElements();o.payload=c[0].content,o.type=c[0].type}catch(i){o=null,Ie.e(s+" failed. error:",i)}return o}_onSendMessageFailed(e,t){e.status=Nt.FAIL;this.getModule(hs).deleteMessageRandom(e),this._addSendMessageFailCountOnUser(e,t);const s=new no("sendMessage");return s.setMessage(`tjg_id:${this.generateTjgID(e)} type:${e.type} from:${e.from} to:${e.to}`),this.probeNetwork().then(([e,o])=>{s.setError(t,e,o).end()}),Ie.e(this._n+"._onSendMessageFailed error:",t),Vs(new Fs({code:t&&t.code?t.code:$s.MSG_SEND_FAIL,message:t&&t.message?t.message:void 0,data:{message:e}}))}_getSendMessageSpecifiedKey(e){if(e.conversationType===t.CONV_C2C)return Ws;if(e.conversationType===t.CONV_GROUP){const t=this.getModule(ds).getLocalGroupProfile(e.to);if(!t)return;const s=t.type;return Je(s)?js:zs}}_addSendMessageTotalCount(e){const t=this._getSendMessageSpecifiedKey(e);if(t){this.getModule(vs).addTotalCount(t)}}_addSendMessageSuccessCount(e,t){const s=this._getSendMessageSpecifiedKey(e);if(s){const e=this.getModule(vs);e.addSuccessCount(s),e.addCost(s,Tt(t,!1))}}_addSendMessageFailCountOnUser(e,t){const{code:s=-1}=t,o=this.getModule(vs),i=this._getSendMessageSpecifiedKey(e);Ii(s)&&i&&o.addFailedCountOfUserSide(i)}}class Si extends Bs{constructor(e){super(e),this._n="PluginModule",this.plugins={}}registerPlugin(e){Object.keys(e).forEach(t=>{this.plugins[t]=e[t]});new no("registerPlugin").setMessage(""+Object.keys(e)).end()}getPlugin(e){return this.plugins[e]}reset(){}}class yi extends Bs{constructor(e){super(e),this._n="SyncUnreadMessageModule",this._cookie="",this._onlineSyncFlag=!1,this.getInnerEmitterInstance().on(Do.A2KEY_AND_TINYID_UPDATED,this._onLoginSuccess,this)}_onLoginSuccess(e){this._startSync({cookie:this._cookie,syncFlag:0,isOnlineSync:0})}_startSync(e){const{cookie:t,syncFlag:s,isOnlineSync:o}=e,i=this._n+"._startSync";Ie.l(`${i} cookie:${t} syncFlag:${s} isOnlineSync:${o}`),this.request({protocolName:Ks.SYNC_UNREAD_MESSAGE,requestData:{cookie:t,syncFlag:s,isOnlineSync:o}}).then(e=>{const{cookie:t,syncFlag:s}=e.data;this._cookie=t,St(t)||(0===s||1===s?(this._dispatchUnreadMessage({...e.data,isSyncingEnded:!1}),this._startSync({cookie:t,syncFlag:s,isOnlineSync:0})):2===s&&this._dispatchUnreadMessage({...e.data,isSyncingEnded:!0}))}).catch(e=>{Ie.e(i+" failed. error:",e)})}_dispatchUnreadMessage(e){if(e.eventArray){this.getModule(Es).onMessage({head:{},body:{eventArray:e.eventArray,isInstantMessage:this._onlineSyncFlag,isSyncingEnded:e.isSyncingEnded}})}this.getModule(ls).onNewC2CMessage({dataList:e.messageList,isInstantMessage:!!e.isSyncingEnded&&this._onlineSyncFlag,C2CRemainingUnreadList:e.C2CRemainingUnreadList,C2CPairUnreadList:e.C2CPairUnreadList,isSyncingEnded:e.isSyncingEnded})}startOnlineSync(){Ie.l(this._n+".startOnlineSync"),this._onlineSyncFlag=!0,this._startSync({cookie:this._cookie,syncFlag:0,isOnlineSync:1})}startSyncOnReconnected(){Ie.l(this._n+".startSyncOnReconnected."),this._onlineSyncFlag=!0,this._startSync({cookie:this._cookie,syncFlag:0,isOnlineSync:0})}reset(){Ie.l(this._n+".reset"),this._onlineSyncFlag=!1,this._cookie=""}}const Di={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",isWebUniapp:"is_web_uniapp",isSupportExtension:"SupportMessageExtension",messageSequence:"MsgSeq",messageKey:"MsgKey",startSequence:"startSeq",simplifiedMessage:"DownsizeFlag",isRelayMessage:"IsRelayMsg",reactionID:"Reaction",messageSequenceList:"MsgSeqList",messageKeyList:"MsgKeyList"},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:"isWithChangedAttributeInfo",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",ApplyJoinOption:"joinOption",MsgFlag:"messageRemindType",AtInfoList:"groupAtInfoList",AtFlagList:"groupAtType",AtMsgSeq:"sequence",BanDuration:"duration",BanDescription:"reason",NotVisible:"invisible",BytesTag:"tag",BytesValue:"value",RptBytesValue:"value",LatestSeq:"globalSequence",ClearSeq:"clearSequence",SupportMessageExtension:"isSupportExtension",ExtensionList:"extensions",GroupCounter:"counterList",Revoker_Account:"revoker",MsgExtensionNotify:"messageExtensionNotify",ExtensionC2cMsgInfo:"messageInfo",ExtensionGroupMsgInfo:"messageInfo",MsgOptType:"operateType",SetKVInfo:"operateResultList",DeleteKVInfo:"operateResultList",ClearKVInfo:"operateResultList",MsgKeyValue:"extensions",ClearMsgSeq:"clearSequence",MsgLastSeq:"globalSequence",InviteJoinOption:"inviteOption",MemberList_Account:"inviteeList",MsgMemberExtraInfoList:"inviteeInfoList",E:"event",GInf:"groupProfile",MCT:"clientTime",MR:"random",MP:"priority",MTS:"time",GId:"groupID",MS:"sequence",CCD:"cloudCustomData",F_Account:"from",F_Hd:"avatar",F_NN:"nick",GN:"groupName",GT:"groupType",IsSys:"isSystemMessage",OpInf:"operatorInfo",Img:"avatar",NN:"nick",OnlineInf:"onlineMemberInfo",ET:"expireTime",Num:"onlineMemberNum",Opt:"operationType",O_Account:"operatorID",RT:"operationType",UDF:"userDefinedField",L_Account:"userIDList",IsPlaceMsg:"isPlaceMessage",MsgCheckResult:"checkResult",Results:"resultList",Reaction:"reactionID",Reaction_Account:"userIDList",MsgReactionNotifyList:"messageReactionNotifyList",MsgReactionNotify:"messageReactionNotify",MsgReactionSummary:"reactionList",C2CMsgInfo:"C2CMessageInfo",GroupMsgInfo:"groupMessageInfo",int32_err_code:"errorCode",str_err_msg:"errorMsg",MsgDropReason:"messageDropReason",ReactedByMe:"reactedByMyself"},ignoreKeyWord:["C2C","ID","USP"]};function Ni(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);if(0===(e=Array.isArray(e)?e.map(e=>e.trim()).filter(e=>e.length).join("-"):e.trim()).length)return"";if(1===e.length)return t.pascalCase?e.toUpperCase():e.toLowerCase();return e!==e.toLowerCase()&&(e=vi(e)),e=e.replace(/^[_.\- ]+/,"").toLowerCase().replace(/[_.\- ]+(\w|$)/g,(e,t)=>t.toUpperCase()).replace(/\d+(\w|$)/g,e=>e.toUpperCase()),s=e,t.pascalCase?s.charAt(0).toUpperCase()+s.slice(1):s;var s}const vi=e=>{let t=!1,s=!1,o=!1;for(let i=0;i<e.length;i++){const n=e[i];t&&/[a-zA-Z]/.test(n)&&n.toUpperCase()===n?(e=e.slice(0,i)+"-"+e.slice(i),t=!1,o=s,s=!0,i++):s&&o&&/[a-zA-Z]/.test(n)&&n.toLowerCase()===n?(e=e.slice(0,i-1)+"-"+e.slice(i-1),o=s,s=!1,t=!0):(t=n.toLowerCase()===n&&n.toUpperCase()!==n,o=s,s=n.toUpperCase()===n&&n.toLowerCase()!==n)}return e};function Ai(e,t){let s=0;return function e(t,o){if(s++,s>100)return s--,t;if(Ue(t)){const i=t.map(t=>Re(t)?e(t,o):t);return s--,i}if(Re(t)){let i=function(e,t){const s=Object.create(null);return Object.keys(e).forEach(o=>{const i=t(e[o],o);i&&(s[i]=e[o])}),s}(t,(e,t)=>{if(!be(t))return!1;if((s=t)!==Ni(s))for(let o=0;o<Di.ignoreKeyWord.length&&!t.includes(Di.ignoreKeyWord[o]);o++);var s;return Pe(o[t])?function(e){if("OPPOChannelID"===e)return e;return e[0].toUpperCase()+Ni(e).slice(1)}(t):o[t]});return i=ot(i,(t,s)=>Ue(t)||Re(t)?e(t,o):t),s--,i}}(e,t)}function Oi(e,t){if(Ue(e))return e.map(e=>Re(e)?Oi(e,t):e);if(Re(e)){let s=function(e,t){const s={};return Object.keys(e).forEach(o=>{s[t(e[o],o)]=e[o]}),s}(e,(e,s)=>Pe(t[s])?Ni(s):t[s]);return s=ot(s,e=>Ue(e)||Re(e)?Oi(e,t):e),s}}const Ri=String.fromCharCode,Li=function(e){let t=0|e.charCodeAt(0);if(55296<=t)if(t<56320){const s=0|e.charCodeAt(1);if(56320<=s&&s<=57343){if(t=(t<<10)+s-56613888|0,t>65535)return Ri(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?Ri(192|t>>>6,128|63&t):Ri(224|t>>>12,128|t>>>6&63,128|63&t)},Ui=function(e){const t=void 0===e?"":(""+e).replace(/[\x80-\uD7ff\uDC00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]?/g,Li),s=0|t.length,o=new Uint8Array(s);let i=0;for(;i<s;i=i+1|0)o[i]=0|t.charCodeAt(i);return o},Pi=function(e){const t=new Uint8Array(e);let s="",o=0;const i=t.length;for(;o<i;){let e=t[o],n=0,r=0;if(e<=127?(n=0,r=255&e):e<=223?(n=1,r=31&e):e<=239?(n=2,r=15&e):e<=244&&(n=3,r=7&e),i-o-n>0){let s=0;for(;s<n;)e=t[o+s+1],r=r<<6|63&e,s+=1}else r=65533,n=i-o;s+=String.fromCodePoint(r),o+=n+1}return s};class Gi{constructor(e){this._handler=e;const t=e.getURL();if(this._socket=null,this._workerSocket=null,this._id=Be(),this._handler.getIsWorkerEnabled()){const e=URL.createObjectURL(new Blob([';let _socket = null;onmessage = function(event) { if (event.data.cmd === "start") { const url = event.data.url; _socket = new WebSocket(url); _socket.binaryType = "arraybuffer"; _socket.onopen = function() { postMessage({ callback: "onOpen" }); }; _socket.onclose = function(e) { postMessage({ callback: "onOpen", e: { code: e.code, reason: e.reason } }); }; _socket.onmessage = function(e) { postMessage({ callback: "onMessage", data: e.data }); }; _socket.onerror = function(e) { postMessage({ callback: "onError", e: { isTrusted: "true" } }); }; } else if (event.data.cmd === "sendMessage") { if (_socket !== null) { _socket.send(event.data.data); } } else if (event.data.cmd === "stop") { if (_socket !== null) { _socket.close(event.data.code); _socket = null; } }};'],{type:"application/javascript; charset=utf-8"}));this._workerSocket=new Worker(e);const s=this;this._workerSocket.onmessage=function(e){const{callback:t,e:o}=e.data;"onOpen"===t?s._onOpen():"onClose"===t?s._onClose(o):"onError"===t?s._onError(o):"onMessage"===t&&s._onMessage(e.data)},this._workerSocket.postMessage({cmd:"start",id:this._id,url:t})}else G?R?(w.connectSocket({url:t,header:{"content-type":"application/json"}}),w.onSocketClose(this._onClose.bind(this)),w.onSocketOpen(this._onOpen.bind(this)),w.onSocketMessage(this._onMessage.bind(this)),w.onSocketError(this._onError.bind(this))):(this._socket=w.connectSocket({url:t,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))):k&&(this._socket=new WebSocket(t),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));this._canIUseBinaryFrame=e.canIUseBinaryFrame()}getID(){return this._id}_onOpen(){this._handler.onOpen({id:this._id})}_onClose(e){this._handler.onClose({id:this._id,e:e})}_onMessage(e){this._handler.onMessage({data:this._canIUseBinaryFrame?Pi(e.data):e.data})}_onError(e){this._handler.onError({id:this._id,e:e})}setIsWorkerEnabled(e){this._isWorkerEnabled=!0}close(e){if(this._workerSocket&&(this._workerSocket.postMessage({cmd:"stop",code:e}),this._workerSocket.terminate(),this._workerSocket=null),R)return w.offSocketClose(),w.offSocketMessage(),w.offSocketOpen(),w.offSocketError(),void w.closeSocket();this._socket&&(G?(this._socket.onClose(()=>{}),this._socket.onOpen(()=>{}),this._socket.onMessage(()=>{}),this._socket.onError(()=>{})):k&&(this._socket.onopen=null,this._socket.onmessage=null,this._socket.onclose=null,this._socket.onerror=null),O?this._socket.close({code:e}):this._socket.close(e),this._socket=null)}send(e){if(this._workerSocket)this._workerSocket.postMessage({cmd:"sendMessage",data:this._canIUseBinaryFrame?Ui(e.data).buffer:e.data});else{if(R)return void w.sendSocketMessage({data:e.data,fail:()=>{e.fail&&e.requestID&&e.fail(e.requestID)}});this._socket&&(G?this._socket.send({data:this._canIUseBinaryFrame?Ui(e.data).buffer:e.data,fail:()=>{e.fail&&e.requestID&&e.fail(e.requestID)}}):k&&this._socket.send(this._canIUseBinaryFrame?Ui(e.data).buffer:e.data))}}}const ki=4e3,wi=4001,Fi="connected",$i="connecting",bi="disconnected";class qi{constructor(e){this._channelModule=e,this._n="SocketHandler",this._promiseMap=new Map,this._readyState=bi,this._simpleRequestMap=new Map,this.MAX_SIZE=100,this._startSequence=Be(),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._isWorkerEnabled=!0,this._setWebsocketHost(),this._initConnection()}_setWebsocketHost(){const e=this._channelModule.getModule(gs);let t=c;this._channelModule.isOversea()&&(t=u),e.isSingaporeSite()?t=l:e.isKoreaSite()?t=d:e.isGermanySite()?t=_:e.isIndiaSite()?t=p:e.isJapanSite()?t=h:e.isUSASite()?t=g:e.isIndonesiaSite()&&(t=m),M.HOST.setCurrent(t)}_initConnection(){Pe(M.HOST.CURRENT.BACKUP)||""===this._url?this._url=M.HOST.CURRENT.DEFAULT:this._url===M.HOST.CURRENT.DEFAULT?this._url=M.HOST.CURRENT.BACKUP:this._url===M.HOST.CURRENT.BACKUP?this._url=this._canIUseAnyCast()?M.HOST.CURRENT.ANYCAST:M.HOST.CURRENT.DEFAULT:this._url===M.HOST.CURRENT.ANYCAST&&(M.HOST.CURRENT.ANYCAST="",this._url=M.HOST.CURRENT.DEFAULT);const e=this._channelModule.getModule(gs).getProxyServer();St(e)||(this._url=e),this._connect(),this._nextPingTs=0}_canIUseAnyCast(){return k&&M.HOST.CURRENT.ANYCAST}onCheckTimer(e){e%1==0&&this._checkPromiseMap()}_checkPromiseMap(){0!==this._promiseMap.size&&this._promiseMap.forEach((e,t)=>{const{reject:s,timestamp:o}=e;let i=15e3;-1!==t.indexOf(Ks.LOGIN)&&(i=9e4),Date.now()-o>=i&&(Ie.l(`${this._n}._checkPromiseMap request timeout, delete requestID:${t}`),this._promiseMap.delete(t),s(new Fs({code:$s.NETWORK_TIMEOUT})),this._channelModule.onRequestTimeout(t))})}onOpen(e){if(""===this._readyState)return;this._onOpenTs=Date.now();const{id:t}=e;this._socketID=t;const s=Tt(this._startTs,!1);Ie.l(`${this._n}._onOpen cost:${s} ms. socketID:${t}`);new no("wsOnOpen").setMessage(s).setCostTime(s).setMoreMessage("socketID:"+t).end(),e.id===this._socketID&&(this._readyState=Fi,this._reConnectCount=0,this._resend(),!0===this._reConnectFlag&&(this._channelModule.onReconnected(),this._reConnectFlag=!1),this._channelModule.onOpen())}onClose(e){const t=new no("wsOnClose"),{id:s,e:o}=e,i=`sourceSocketID:${s} currentSocketID:${this._socketID} code:${o.code} reason:${o.reason}`;let n=0;0!==this._onOpenTs&&(n=Date.now()-this._onOpenTs),t.setMessage(n).setCostTime(n).setMoreMessage(i).setCode(o.code).end(),Ie.l(`${this._n}._onClose ${i} onlineTime:${n}`),s===this._socketID&&(this._readyState=bi,n<1e3?this._channelModule.onReconnectFailed():this._channelModule.onClose())}onError(e){const{id:t,e:s}=e,o=`sourceSocketID:${t} currentSocketID:${this._socketID}`;new no("wsOnError").setMessage(s.errMsg||xe(s)).setMoreMessage(o).setLevel("error").end(),Ie.w(this._n+"._onError",s,o),t===this._socketID&&(this._readyState="",this._channelModule.onError())}onMessage(e){let t;try{t=JSON.parse(e.data)}catch(i){new no("jsonParseError").setMessage(e.data).end()}if(!t||!t.head)return;const s=this._getRequestIDFromHead(t.head);let o=t.body;if(!this._channelModule.getModule(Ls).isTRTCCommand(s)){const e=lt(t.head);o=Oi(t.body,this._getResponseKeyMap(e))}if(Ie.d(`${this._n}.onMessage ret:${JSON.stringify(o)} requestID:${s} has:${this._promiseMap.has(s)}`),this._setNextPingTs(),this._promiseMap.has(s)){const{resolve:e,reject:t,timestamp:i}=this._promiseMap.get(s);return this._promiseMap.delete(s),this._calcRTT(i),void(o.errorCode&&0!==o.errorCode?(this._channelModule.onErrorCodeNotZero(o),t(new Fs({code:o.errorCode,message:o.errorInfo||"",data:s.includes(Ks.MODIFY_C2C_MESSAGE)||s.includes(Ks.MODIFY_GROUP_MESSAGE)?{elements:o.elements,messageVersion:o.messageVersion,cloudCustomData:o.cloudCustomData}:void 0}))):e(ws(o)))}this._channelModule.onMessage({head:t.head,body:o})}_calcRTT(e){const t=Date.now()-e;this._channelModule.getModule(vs).addRTT(t)}_connect(){this._startTs=Date.now(),this._onOpenTs=0,this._socket=new Gi(this),this._socketID=this._socket.getID(),this._readyState=$i,Ie.l(`${this._n}._connect isWorkerEnabled:${this.getIsWorkerEnabled()} socketID:${this._socketID} url:${this.getURL()}`);new no("wsConnect").setMessage(`socketID:${this._socketID} url:${this.getURL()}`).end()}getURL(){this._channelModule.isDevMode()&&(this._canIUseBinaryFrame=!1);const e=rt();(R||D&&"windows"===e||U)&&(this._canIUseBinaryFrame=!1);let t=-1;"ios"===e?t=H||-1:"android"===e&&(t=W||-1);const s=this._channelModule.getModule(gs),o=this._channelModule.getPlatform();let i=`sdkappid=${s.getSDKAppID()}&instanceid=${s.getInstanceID()}&random=${this._getRandom()}&platform=${o}&host=${e}&version=${t}&sdkversion=3.2.3`;return N&&(i+="&isminigame=1"),this._canIUseBinaryFrame?`${this._url}/binfo?${i}`:`${this._url}/info?${i}`}_closeConnection(e){Ie.l(`${this._n}._closeConnection socketID:${this._socketID}`),this._socket&&(this._socket.close(e),this._socketID=-1,this._socket=null,this._readyState=bi)}_resend(){if(Ie.l(`${this._n}._resend reConnectFlag:${this._reConnectFlag}`,`promiseMap.size:${this._promiseMap.size} simpleRequestMap.size:${this._simpleRequestMap.size}`),this._promiseMap.size>0&&this._promiseMap.forEach((e,t)=>{const{uplinkData:s,resolve:o,reject:i}=e;this._promiseMap.set(t,{resolve:o,reject:i,timestamp:Date.now(),uplinkData:s}),this._execute(t,s)}),this._simpleRequestMap.size>0){for(const[e,t]of this._simpleRequestMap)this._execute(e,t);this._simpleRequestMap.clear()}}send(e){e.head.seq=this._getSequence(),e.head.reqtime=Math.floor(Date.now()/1e3);const{keyMap:t,...s}=e,o=this._getRequestIDFromHead(e.head),i=JSON.stringify(s);return new Promise((e,t)=>{if(this._promiseMap.set(o,{resolve:e,reject:t,timestamp:Date.now(),uplinkData:i}),Ie.d(`${this._n}.send uplinkData:${JSON.stringify(s)} requestID:${o} readyState:${this._readyState}`),this._readyState!==Fi)this._reConnect();else{this._execute(o,i);this._channelModule.getModule(vs).addRequestCount()}})}simplySend(e){e.head.seq=this._getSequence(),e.head.reqtime=Math.floor(Date.now()/1e3);const{keyMap:t,...s}=e,o=this._getRequestIDFromHead(e.head),i=JSON.stringify(s);this._readyState!==Fi?(this._simpleRequestMap.size<this.MAX_SIZE?this._simpleRequestMap.set(o,i):Ie.l(this._n+".simplySend. simpleRequestMap is full, drop request!"),this._reConnect()):this._execute(o,i)}_execute(e,t){this._socket.send({data:t,fail:G?this._onSendFail.bind(this):void 0,requestID:e})}_onSendFail(e){Ie.l(`${this._n}._onSendFail requestID:${e}`)}_getSequence(){let e;if(this._startSequence<2415919103)return e=this._startSequence,this._startSequence+=1,2415919103===this._startSequence&&(this._startSequence=Be()),e}_getRequestIDFromHead(e){const{servcmd:t,seq:s}=e;return t+s}_getResponseKeyMap(e){const t=this._channelModule.getKeyMap(e);return{...Di.response,...t.response}}_reConnect(){this._readyState!==Fi&&this._readyState!==$i&&this.forcedReconnect()}forcedReconnect(){const e=this._n+".forcedReconnect";Ie.l(`${e} count:${this._reConnectCount} readyState:${this._readyState}`),this._reConnectFlag=!0,this._resetRandom(),this._reConnectCount<this.MAX_RECONNECT_COUNT?(this._reConnectCount+=1,this._closeConnection(wi),this._initConnection()):(this._reConnectCount=0,this._channelModule.probeNetwork().then(([t,s])=>{t?(Ie.w(e+" disconnected from wsserver but network is ok, continue..."),this._closeConnection(wi),this._initConnection()):this._channelModule.onReconnectFailed()}))}getReconnectFlag(){return this._reConnectFlag}_setNextPingTs(){this._nextPingTs=Date.now()+1e4}getNextPingTs(){return this._nextPingTs}isConnected(){return this._readyState===Fi}canIUseBinaryFrame(){return this._canIUseBinaryFrame}setIsWorkerEnabled(e){Ie.l(`${this._n}.setIsWorkerEnabled flag:${e}`),this._isWorkerEnabled=e}getIsWorkerEnabled(){return this._isWorkerEnabled&&te}_getRandom(){return 0===this._random&&(this._random=Math.random()),this._random}_resetRandom(){this._random=0}close(){Ie.l(this._n+".close"),this._closeConnection(ki),this._promiseMap.clear(),this._startSequence=Be(),this._readyState=bi,this._simpleRequestMap.clear(),this._reConnectFlag=!1,this._reConnectCount=0,this._onOpenTs=0,this._url="",this._random=0,this._canIUseBinaryFrame=!0,this._isWorkerEnabled=!0}}class xi extends Bs{constructor(e){if(super(e),this._n="ChannelModule",this._socketHandler=new qi(this),this._probing=!1,this._isAppShowing=!0,this._previousState=t.NET_STATE_CONNECTED,G&&"function"==typeof w.onAppShow&&"function"==typeof w.onAppHide){const e=this._onAppHide.bind(this),t=this._onAppShow.bind(this);"function"==typeof w.offAppHide&&w.offAppHide(e),"function"==typeof w.offAppShow&&w.offAppShow(t),w.onAppHide(e),w.onAppShow(t)}this._timerForNotLoggedIn=-1,this._timerForNotLoggedIn=setInterval(this.onCheckTimer.bind(this),1e3),this._fatalErrorFlag=!1,this._disconnectedTS=0}onCheckTimer(e){this._socketHandler&&(this.isLoggedIn()?(this._timerForNotLoggedIn>0&&(clearInterval(this._timerForNotLoggedIn),this._timerForNotLoggedIn=-1),this._socketHandler.onCheckTimer(e)):this._socketHandler.onCheckTimer(1),this._checkNextPing())}onErrorCodeNotZero(e){this.getModule(Es).onErrorCodeNotZero(e)}onMessage(e){this.getModule(Es).onMessage(e)}send(e){if(!this._socketHandler)return Promise.reject();if(this._previousState!==t.NET_STATE_CONNECTED&&e.head.servcmd.includes(Ks.SSO_STAT)){this.reConnect();return this.getModule(gs).getProxyServer()?Promise.resolve():this._sendLogViaHTTP(e)}return this._socketHandler.send(e)}_sendLogViaHTTP(e){const t=M.HOST.CURRENT.STAT;return new Promise((s,o)=>{const i=`${t}/v4/imopenstat/tim_web_report_v2?sdkappid=${e.head.sdkappid}&reqtime=${Date.now()}`,n=JSON.stringify(e.body),r="application/x-www-form-urlencoded;charset=UTF-8";if(G)w.request({url:i,data:n,method:"POST",timeout:3e3,header:{"content-type":r},success:()=>{s()},fail:()=>{o(new Fs({code:$s.NETWORK_ERROR}))}});else{const e=new XMLHttpRequest,t=setTimeout(()=>{e.abort(),o(new Fs({code:$s.NETWORK_TIMEOUT}))},3e3);e.onreadystatechange=function(){4===e.readyState&&(clearTimeout(t),200===e.status||304===e.status?s():o(new Fs({code:$s.NETWORK_ERROR})))},e.open("POST",i,!0),e.setRequestHeader("Content-type",r),e.send(n)}})}simplySend(e){return this._socketHandler?this._socketHandler.simplySend(e):Promise.reject()}onOpen(){this._ping()}onClose(){if(this._socketHandler){this._socketHandler.getReconnectFlag()&&this._emitNetStateChangeEvent(t.NET_STATE_DISCONNECTED)}this.reConnect()}onError(){G&&!U&&this.outputWarning("DomainNameInMP"),this._emitNetStateChangeEvent(t.NET_STATE_DISCONNECTED)}getKeyMap(e){return this.getModule(Es).getKeyMap(e)}_onAppHide(){this._isAppShowing=!1}_onAppShow(){this._isAppShowing=!0}onRequestTimeout(e){}onReconnected(){Ie.l(`${this._n}.onReconnected cost:${Tt(this._disconnectedTS,!0,!1)}`),this._m.restartTimer();this.getModule(Es).onReconnected(Tt(this._disconnectedTS,!1,!1)),this._disconnectedTS=0,this._emitNetStateChangeEvent(t.NET_STATE_CONNECTED)}onReconnectFailed(){Ie.l(this._n+".onReconnectFailed"),this._emitNetStateChangeEvent(t.NET_STATE_DISCONNECTED)}setIsWorkerEnabled(e){this._socketHandler&&this._socketHandler.setIsWorkerEnabled(!1)}offline(){this._emitNetStateChangeEvent(t.NET_STATE_DISCONNECTED)}reConnect(e=!1){let s=!1;this._socketHandler&&(s=this._socketHandler.getReconnectFlag());const o=`forcedFlag:${e} fatalErrorFlag:${this._fatalErrorFlag} previousState:${this._previousState} reconnectFlag:${s}`;if(Ie.l(`${this._n}.reConnect ${o}`),!this._fatalErrorFlag&&this._socketHandler){if(!0===e)this._socketHandler.forcedReconnect();else{if(this._previousState===t.NET_STATE_CONNECTING&&s)return;this._socketHandler.forcedReconnect()}this._emitNetStateChangeEvent(t.NET_STATE_CONNECTING)}}_emitNetStateChangeEvent(s){this._previousState!==s&&(Ie.l(`${this._n}._emitNetStateChangeEvent from ${this._previousState} to ${s}`),s===t.NET_STATE_DISCONNECTED&&0===this._disconnectedTS&&(this._disconnectedTS=Date.now()),this._previousState=s,this.emitOuterEvent(e.NET_STATE_CHANGE,{state:s}))}_ping(){if(!0===this._probing)return;this._probing=!0;const e=this.getModule(Es).getProtocolData({protocolName:Ks.PING});this.send(e).then(()=>{this._probing=!1}).catch(e=>{if(Ie.w(this._n+"._ping failed. error:",e),this._probing=!1,e&&60002===e.code){return new no("error").setMessage(`code:${e.code} message:${e.message}`).setNetworkType(this.getModule(Is).getNetworkType()).end(),this._fatalErrorFlag=!0,void this._emitNetStateChangeEvent(t.NET_STATE_DISCONNECTED)}this.probeNetwork().then(([e,s])=>{Ie.l(`${this._n}._ping failed. probe network, isAppShowing:${this._isAppShowing} online:${e} networkType:${s}`),e?this.reConnect():this._emitNetStateChangeEvent(t.NET_STATE_DISCONNECTED)})})}_checkNextPing(){if(!this._socketHandler)return;if(!this._socketHandler.isConnected())return;Date.now()>=this._socketHandler.getNextPingTs()&&this._ping()}dealloc(){this._socketHandler&&(this._socketHandler.close(),this._socketHandler=null),this._timerForNotLoggedIn>-1&&clearInterval(this._timerForNotLoggedIn)}onRestApiKickedOut(){this._socketHandler&&(this._socketHandler.close(),this.reConnect(!0))}reset(){Ie.l(this._n+".reset"),this._previousState=t.NET_STATE_CONNECTED,this._probing=!1,this._fatalErrorFlag=!1,this._timerForNotLoggedIn=setInterval(this.onCheckTimer.bind(this),1e3),this._disconnectedTS=0}}class Vi{constructor(e){this._n="ProtocolHandler",this._sessionModule=e,this._configMap=new Map,this._fillConfigMap()}_fillConfigMap(){this._configMap.clear();const e=this._sessionModule.genCommonHead(),t=this._sessionModule.genCosSpecifiedHead(),s=this._sessionModule.genSSOReportHead();this._configMap.set(Ks.LOGIN,function(e){return{head:{...e,servcmd:`${M.NAME.IM_OPEN_STATUS}.${Ks.LOGIN}`},body:{state:"Online",isWebUniapp:0,deviceBrand:0},keyMap:{request:{deviceBrand:"InstType"},response:{InstId:"instanceID",HelloInterval:"helloInterval"}}}}(e)),this._configMap.set(Ks.LOGOUT,function(e){return{head:{...e,servcmd:`${M.NAME.IM_OPEN_STATUS}.${Ks.LOGOUT}`},body:{type:0},keyMap:{request:{type:"wslogout_type"}}}}(e)),this._configMap.set(Ks.HELLO,function(e){return{head:{...e,servcmd:`${M.NAME.IM_OPEN_STATUS}.${Ks.HELLO}`},body:{isWebUniapp:0},keyMap:{response:{NewInstInfo:"newInstanceInfo"}}}}(e)),this._configMap.set(Ks.KICK_OTHER,function(e){return{head:{...e,servcmd:`${M.NAME.STAT_SERVICE}.${Ks.KICK_OTHER}`},body:{}}}(e)),this._configMap.set(Ks.COS_SIGN,function(e){return{head:{...e,servcmd:`${M.NAME.IM_COS_SIGN}.${Ks.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(Ks.COS_PRE_SIG,function(e){return{head:{...e,servcmd:`${M.NAME.CUSTOM_UPLOAD}.${Ks.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"}}}}(t)),this._configMap.set(Ks.SIMPLE_COS_PRE_SIG,function(e){return{head:{...e,servcmd:`${M.NAME.CUSTOM_UPLOAD}.${Ks.SIMPLE_COS_PRE_SIG}`},body:{uploadMethod:0,platform:2,SDKAppID:0,userID:"",conversationType:1,uploadConfig:[{fileID:1,fileType:1,fileName:""}]},keyMap:{request:{platform:"uint32_platform",SDKAppID:"uint32_sdkappid",userID:"str_user_id",uploadMethod:"uint32_upload_method",conversationType:"uint32_scene",uploadConfig:"rpt_upload_object",fileID:"uint32_file_id",fileType:"uint32_file_type",fileName:"str_file_name"},response:{str_final_ip:"uploadIP",rpt_pre_sig:"preSig",uint32_file_id:"fileID",uint32_exist_flag:"existFlag",str_download_url:"downloadUrl",str_upload_url:"uploadUrl",str_snapshot_url:"requestSnapshotUrl",str_file_key:"fileKey"}}}}(t)),this._configMap.set(Ks.GET_IMAGE_INFO,function(e){return{head:{...e,servcmd:`${M.NAME.CUSTOM_UPLOAD}.${Ks.GET_IMAGE_INFO}`},body:{imageUrl:""},keyMap:{request:{imageUrl:"str_image_url"},response:{rpt_msg_image_info:"imageInfoArray",uint32_image_type:"type",str_url:"url",uint32_width:"width",uint32_height:"height",str_image_format:"imageFormat"}}}}(t)),this._configMap.set(Ks.GET_IP,function(e){return{head:{...e,servcmd:`${M.NAME.CUSTOM_UPLOAD}.${Ks.GET_IP}`},body:{domainName:""},keyMap:{request:{domainName:"str_domain"},response:{str_final_ip:"ip"}}}}(t)),this._configMap.set(Ks.VIDEO_COVER,function(e){return{head:{...e,servcmd:`${M.NAME.CUSTOM_UPLOAD}.${Ks.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"}}}}(t)),this._configMap.set(Ks.FETCH_COMMERCIAL_CONFIG,function(e){return{head:{...e,servcmd:`${M.NAME.IM_CONFIG_MANAGER}.${Ks.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(Ks.PUSHED_COMMERCIAL_CONFIG,function(e){return{head:{...e,servcmd:`${M.NAME.IM_CONFIG_MANAGER}.${Ks.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(Ks.FETCH_CLOUD_CONTROL_CONFIG,function(e){return{head:{...e,servcmd:`${M.NAME.IM_CONFIG_MANAGER}.${Ks.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(Ks.PUSHED_CLOUD_CONTROL_CONFIG,function(e){return{head:{...e,servcmd:`${M.NAME.IM_CONFIG_MANAGER}.${Ks.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(Ks.OVERLOAD_NOTIFY,function(e){return{head:{...e,servcmd:`${M.NAME.OVERLOAD_PUSH}.${Ks.OVERLOAD_NOTIFY}`},body:{},keyMap:{response:{OverLoadServCmd:"overloadCommand",DelaySecs:"waitingTime"}}}}(e)),this._configMap.set(Ks.SYNC_UNREAD_MESSAGE,function(e){return{head:{...e,servcmd:`${M.NAME.OPEN_IM}.${Ks.SYNC_UNREAD_MESSAGE}`},body:{cookie:"",syncFlag:0,needAbstract:1,isOnlineSync:0,needSignaling:1},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:"to",MsgKey:"messageKey",GroupTips:"groupTips",MsgBody:"elements",MsgType:"type",C2CRemainingUnreadCount:"C2CRemainingUnreadList",C2CPairUnreadCount:"C2CPairUnreadList"}}}}(e)),this._configMap.set(Ks.GET_PROFANITY_LIST,function(e){return{head:{...e,servcmd:`${M.NAME.IM_MSG_AUDIT_MGR}.${Ks.GET_PROFANITY_LIST}`},body:{version:0,deviceID:"",startIndex:void 0},keyMap:{request:{version:"uint64_version",deviceID:"str_device_id",startIndex:"uint64_start_index"},response:{msg_cmd_error_code:"errorInfo",str_err_msg:"errorMessage",uint32_code:"errorCode",msg_scene_ctl_config:"filterConfig",uint64_c2c_custom_msg_flag:"c2c_custom_message",uint64_c2c_text_msg_flag:"c2c_text_message",uint64_group_custom_msg_flag:"group_custom_message",uint64_group_text_msg_flag:"group_text_message",uint64_group_info_flag:"group_profile",uint64_group_member_info_flag:"group_member_profile",uint64_relation_chain_flag:"sns",uint64_user_info_flag:"user_profile",rpt_msg_dirty_word:"lexicon",str_dirty_word:"profanity",str_replaced_content:"replacement",uint64_filter_type:"filterType",uint64_id:"id",uint64_word_type:"profanityType",uint64_complete_flag:"completeFlag",uint64_next_start_index:"nextStartIndex",uint64_version:"version",uint64_expired_time:"expiredTime"}}}}(e)),this._configMap.set(Ks.SEND_C2C_MESSAGE,function(e){return{head:{...e,servcmd:`${M.NAME.OPEN_IM}.${Ks.SEND_C2C_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,isVoipPush:void 0},androidInfo:{OPPOChannelID:""}},messageControlInfo:void 0,clientTime:void 0,needReadReceipt:0,isSupportExtension:0,isRelayMessage: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(Ks.SEND_GROUP_MESSAGE,function(e){return{head:{...e,servcmd:`${M.NAME.GROUP}.${Ks.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,isVoipPush:void 0},androidInfo:{OPPOChannelID:""}},groupAtInfo:[],messageControlInfo:void 0,clientTime:void 0,needReadReceipt:0,topicID:void 0,receiverList:void 0,isSupportExtension:0,isRelayMessage: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",receiverList:"To_Account"},response:{MsgTime:"time",MsgSeq:"sequence"}}}}(e)),this._configMap.set(Ks.REVOKE_C2C_MESSAGE,function(e){return{head:{...e,servcmd:`${M.NAME.OPEN_IM}.${Ks.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(Ks.REVOKE_GROUP_MESSAGE,function(e){return{head:{...e,servcmd:`${M.NAME.GROUP}.${Ks.REVOKE_GROUP_MESSAGE}`},body:{groupID:"",msgSeqList:void 0,topicID:""},keyMap:{request:{msgSeqList:"MsgSeqList",msgSeq:"MsgSeq"}}}}(e)),this._configMap.set(Ks.GET_C2C_ROAMING_MESSAGE,function(e){return{head:{...e,servcmd:`${M.NAME.OPEN_IM}.${Ks.GET_C2C_ROAMING_MESSAGE}`},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",IsPeerRead:"readReceiptSentByPeer"}}}}(e)),this._configMap.set(Ks.MODIFY_C2C_MESSAGE,function(e){return{head:{...e,servcmd:`${M.NAME.OPEN_IM}.${Ks.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(Ks.GET_GROUP_ROAMING_MESSAGE,function(e){return{head:{...e,servcmd:`${M.NAME.GROUP}.${Ks.GET_GROUP_ROAMING_MESSAGE}`},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",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",InvisibleMsgSeq:"invisibleSequenceList",NextReqMsgSeq:"nextSequence"}}}}(e)),this._configMap.set(Ks.SET_C2C_MESSAGE_READ,function(e){return{head:{...e,servcmd:`${M.NAME.OPEN_IM}.${Ks.SET_C2C_MESSAGE_READ}`},body:{C2CMsgReaded:void 0},keyMap:{request:{lastMessageTime:"LastedMsgTime"}}}}(e)),this._configMap.set(Ks.SET_C2C_PEER_MUTE_NOTIFICATIONS,function(e){return{head:{...e,servcmd:`${M.NAME.OPEN_IM}.${Ks.SET_C2C_PEER_MUTE_NOTIFICATIONS}`},body:{userIDList:void 0,muteFlag:0},keyMap:{request:{userIDList:"Peer_Account",muteFlag:"Mute_Notifications"}}}}(e)),this._configMap.set(Ks.GET_C2C_PEER_MUTE_NOTIFICATIONS,function(e){return{head:{...e,servcmd:`${M.NAME.OPEN_IM}.${Ks.GET_C2C_PEER_MUTE_NOTIFICATIONS}`},body:{toAccount:void 0,userIDList:void 0},keyMap:{request:{userIDList:"Peer_Account"},response:{MuteNotificationsList:"muteFlagList"}}}}(e)),this._configMap.set(Ks.SET_GROUP_MESSAGE_READ,function(e){return{head:{...e,servcmd:`${M.NAME.GROUP}.${Ks.SET_GROUP_MESSAGE_READ}`},body:{groupID:void 0,messageReadSeq:void 0,topicID:void 0},keyMap:{request:{messageReadSeq:"MsgReadedSeq"}}}}(e)),this._configMap.set(Ks.SET_ALL_MESSAGE_READ,function(e){return{head:{...e,servcmd:`${M.NAME.OPEN_IM}.${Ks.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(Ks.DELETE_C2C_MESSAGE,function(e){return{head:{...e,servcmd:`${M.NAME.OPEN_IM}.${Ks.DELETE_C2C_MESSAGE}`},body:{fromAccount:"",to:"",keyList:void 0},keyMap:{request:{keyList:"MsgKeyList"}}}}(e)),this._configMap.set(Ks.DELETE_GROUP_MESSAGE,function(e){return{head:{...e,servcmd:`${M.NAME.GROUP}.${Ks.DELETE_GROUP_MESSAGE}`},body:{groupID:"",deleter:"",keyList:void 0,topicID:void 0},keyMap:{request:{deleter:"Deleter_Account",keyList:"Seqs"}}}}(e)),this._configMap.set(Ks.TRANSLATE_TEXT,function(e){return{head:{...e,servcmd:`${M.NAME.IM_OPEN_TRANSLATE}.${Ks.TRANSLATE_TEXT}`},body:{sourceTextList:void 0,SDKAppID:0,from:0,source:"",target:""},keyMap:{request:{sourceTextList:"SourceText",SDKAppID:"SdkAppId",from:"FromAccount"},response:{TargetText:"translatedTextList",RequestId:"requestID",CmdErrorCode:"error",ErrorCode:"code",ErrorInfo:"message"}}}}(e)),this._configMap.set(Ks.VOICE_TO_TEXT,function(e){return{head:{...e,servcmd:`${M.NAME.IM_OPEN_SPEECH}.${Ks.VOICE_TO_TEXT}`},body:{url:"",SDKAppID:0,format:"",sourceType:0,language:""},keyMap:{request:{url:"BytesUrl",SDKAppID:"Uint32Sdkappid",format:"BytesVoiceFormat",sourceType:"Uint64SourceType",language:"BytesEngServiceType"},response:{BytesRequestid:"requestID",BytesResult:"result",CmdErrorCode:"error",ErrorCode:"code",ErrorInfo:"message"}}}}(e)),this._configMap.set(Ks.MODIFY_GROUP_MESSAGE,function(e){return{head:{...e,servcmd:`${M.NAME.OPEN_IM}.${Ks.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(Ks.GET_READ_RECEIPT,function(e){return{head:{...e,servcmd:`${M.NAME.GROUP}.${Ks.GET_READ_RECEIPT}`},body:{groupID:"",sequenceList:void 0},keyMap:{request:{sequence:"MsgSeq"}}}}(e)),this._configMap.set(Ks.SEND_C2C_READ_RECEIPT,function(e){return{head:{...e,servcmd:`${M.NAME.OPEN_IM}.${Ks.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(Ks.SEND_READ_RECEIPT,function(e){return{head:{...e,servcmd:`${M.NAME.GROUP}.${Ks.SEND_READ_RECEIPT}`},body:{groupID:"",sequenceList:void 0},keyMap:{request:{sequenceList:"MsgSeqList",sequence:"MsgSeq"}}}}(e)),this._configMap.set(Ks.GET_READ_RECEIPT_DETAIL,function(e){return{head:{...e,servcmd:`${M.NAME.GROUP}.${Ks.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(Ks.MODIFY_C2C_MESSAGE_EXTENSIONS,function(e){return{head:{...e,servcmd:`${M.NAME.OPEN_IM_MSG_EXT}.${Ks.MODIFY_C2C_MESSAGE_EXTENSIONS}`},body:{from:void 0,to:void 0,messageKey:void 0,operateType:void 0,extensionList:void 0}}}(e)),this._configMap.set(Ks.GET_C2C_MESSAGE_EXTENSIONS,function(e){return{head:{...e,servcmd:`${M.NAME.OPEN_IM_MSG_EXT}.${Ks.GET_C2C_MESSAGE_EXTENSIONS}`},body:{from:void 0,to:void 0,messageKey:void 0,startSequence:void 0}}}(e)),this._configMap.set(Ks.MODIFY_GROUP_MESSAGE_EXTENSIONS,function(e){return{head:{...e,servcmd:`${M.NAME.OPEN_IM_MSG_EXT}.${Ks.MODIFY_GROUP_MESSAGE_EXTENSIONS}`},body:{groupID:void 0,topicID:void 0,messageSequence:void 0,operateType:void 0,extensionList:void 0}}}(e)),this._configMap.set(Ks.GET_GROUP_MESSAGE_EXTENSIONS,function(e){return{head:{...e,servcmd:`${M.NAME.OPEN_IM_MSG_EXT}.${Ks.GET_GROUP_MESSAGE_EXTENSIONS}`},body:{groupID:void 0,topicID:void 0,messageSequence:void 0,startSequence:void 0}}}(e)),this._configMap.set(Ks.MESSAGE_CLOUD_SEARCH,function(e){return{head:{...e,servcmd:`${M.NAME.MESSAGE_SEARCH}.${Ks.MESSAGE_CLOUD_SEARCH}`},body:{keywordList:void 0,keywordListMatchType:"or",account:void 0,groupID:void 0,count:100,cursor:void 0,messageTypeList:void 0,senderUserIDList:void 0,startTime:void 0,endTime:void 0},keyMap:{request:{keywordListMatchType:"MatchType",account:"PeerAccount",groupID:"GroupID",messageTypeList:"MsgTypeList",senderUserIDList:"SendUserIDList"},response:{GroupID:"groupID",UserID:"userID",Count:"messageCount",LastMsgTime:"lastMessageTime",ConversationMsgs:"searchResult",IsNeedReadReceipt:"needReadReceipt",IsPeerRead:"readReceiptSentByPeer",MsgSeq:"sequence",ReqMsgSeq:"sequence",IsSystemMsg:"isSystemMessage",ToGroupId:"to",EnumFrom_AccountType:"fromAccountType",EnumTo_AccountType:"toAccountType",GroupCode:"groupCode",MsgContent:"content",ClientSeq:"clientSequence",ToTopicId:"topicID",InvisibleMsgSeq:"invisibleSequenceList",ErrorCode:"code",ErrorInfo:"message"}}}}(e)),this._configMap.set(Ks.ADD_C2C_MSG_REACTION,function(e){return{head:{...e,servcmd:`${M.NAME.OPEN_IM_MSG_EXT}.${Ks.ADD_C2C_MSG_REACTION}`},body:{from:void 0,to:void 0,reactionID:void 0,messageKey:void 0,userIDList:void 0},keyMap:{request:{userIDList:"Add_Account"}}}}(e)),this._configMap.set(Ks.REMOVE_C2C_MSG_REACTION,function(e){return{head:{...e,servcmd:`${M.NAME.OPEN_IM_MSG_EXT}.${Ks.REMOVE_C2C_MSG_REACTION}`},body:{from:void 0,to:void 0,reactionID:void 0,messageKey:void 0,userIDList:void 0},keyMap:{request:{userIDList:"Del_Account"}}}}(e)),this._configMap.set(Ks.GET_C2C_MSG_REACTIONS,function(e){return{head:{...e,servcmd:`${M.NAME.OPEN_IM_MSG_EXT}.${Ks.GET_C2C_MSG_REACTIONS}`},body:{from:void 0,to:void 0,messageKeyList:void 0,count:void 0}}}(e)),this._configMap.set(Ks.GET_C2C_MSG_REACTION_USER_LIST,function(e){return{head:{...e,servcmd:`${M.NAME.OPEN_IM_MSG_EXT}.${Ks.GET_C2C_MSG_REACTION_USER_LIST}`},body:{from:void 0,to:void 0,reactionID:void 0,messageKey:void 0,count:void 0}}}(e)),this._configMap.set(Ks.ADD_GRP_MSG_REACTION,function(e){return{head:{...e,servcmd:`${M.NAME.OPEN_IM_MSG_EXT}.${Ks.ADD_GRP_MSG_REACTION}`},body:{groupID:void 0,topicID:void 0,reactionID:void 0,messageSequence:void 0,userIDList:void 0},keyMap:{request:{userIDList:"Add_Account"}}}}(e)),this._configMap.set(Ks.REMOVE_GRP_MSG_REACTION,function(e){return{head:{...e,servcmd:`${M.NAME.OPEN_IM_MSG_EXT}.${Ks.REMOVE_GRP_MSG_REACTION}`},body:{groupID:void 0,topicID:void 0,reactionID:void 0,messageSequence:void 0,userIDList:void 0},keyMap:{request:{userIDList:"Del_Account"}}}}(e)),this._configMap.set(Ks.GET_GRP_MSG_REACTIONS,function(e){return{head:{...e,servcmd:`${M.NAME.OPEN_IM_MSG_EXT}.${Ks.GET_GRP_MSG_REACTIONS}`},body:{groupID:void 0,topicID:void 0,messageSequenceList:void 0,count:void 0},keyMap:{response:{MsgSeq:"messageSequence"}}}}(e)),this._configMap.set(Ks.GET_GRP_MSG_REACTION_USER_LIST,function(e){return{head:{...e,servcmd:`${M.NAME.OPEN_IM_MSG_EXT}.${Ks.GET_GRP_MSG_REACTION_USER_LIST}`},body:{groupID:void 0,topicID:void 0,reactionID:void 0,messageSequence:void 0,nextSeq:void 0,count:void 0}}}(e)),this._configMap.set(Ks.GET_C2C_PEER_READ_TIME,function(e){return{head:{...e,servcmd:`${M.NAME.OPEN_IM}.${Ks.GET_C2C_PEER_READ_TIME}`},body:{userIDList:void 0},keyMap:{request:{userIDList:"To_Account"},response:{ReadTime:"peerReadTimeList"}}}}(e)),this._configMap.set(Ks.PAGING_GET_CONVERSATION_LIST,function(e){return{head:{...e,servcmd:`${M.NAME.RECENT_CONTACT}.${Ks.PAGING_GET_CONVERSATION_LIST}`},body:{fromAccount:void 0,timeStamp:void 0,startIndex:void 0,pinnedTimeStamp:void 0,pinnedStartIndex:void 0,orderType:void 0,messageAssistFlag:15,assistFlag:31},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",GroupId:"convGroupID",C2cRemark:"friendRemark",MsgRecvOption:"messageRemindType",GroupIgnoredUnreadSeqCount:"noUnreadCount",GroupNextMsgSeq:"nextMessageSeq"}}}}(e)),this._configMap.set(Ks.DELETE_CONVERSATION,function(e){return{head:{...e,servcmd:`${M.NAME.RECENT_CONTACT}.${Ks.DELETE_CONVERSATION}`},body:{fromAccount:"",conversationList:void 0,clearHistoryMessage:void 0},keyMap:{request:{toGroupID:"ToGroupid",clearHistoryMessage:"ClearRamble",conversationList:"ContactItem"},response:{ResultItem:"resultList",ToGroupid:"groupID",ResultCode:"code",ResultInfo:"info"}}}}(e)),this._configMap.set(Ks.CLEAR_HISTORY_MESSAGE,function(e){return{head:{...e,servcmd:`${M.NAME.RECENT_CONTACT}.${Ks.CLEAR_HISTORY_MESSAGE}`},body:{fromAccount:"",toAccount:void 0,type:1,toGroupID:void 0},keyMap:{request:{toGroupID:"ToGroupid"}}}}(e)),this._configMap.set(Ks.PIN_CONVERSATION,function(e){return{head:{...e,servcmd:`${M.NAME.RECENT_CONTACT}.${Ks.PIN_CONVERSATION}`},body:{fromAccount:"",operationType:1,itemList:void 0},keyMap:{request:{itemList:"RecentContactItem"}}}}(e)),this._configMap.set(Ks.DELETE_GROUP_AT_TIPS,function(e){return{head:{...e,servcmd:`${M.NAME.OPEN_IM}.${Ks.DELETE_GROUP_AT_TIPS}`},body:{messageListToDelete:void 0},keyMap:{request:{messageListToDelete:"DelMsgList",messageSeq:"MsgSeq",messageRandom:"MsgRandom"}}}}(e)),this._configMap.set(Ks.SET_CONVERSATION_CUSTOM_DATA,function(e){return{head:{...e,servcmd:`${M.NAME.RECENT_CONTACT}.${Ks.MARK_CONVERSATION}`},body:{fromAccount:"",itemList:void 0},keyMap:{request:{itemList:"MarkItem",operationType:"OptType",groupID:"ToGroupId"},response:{ToGroupId:"groupID",OptType:"operationType"}}}}(e)),this._configMap.set(Ks.MARK_CONVERSATION,function(e){return{head:{...e,servcmd:`${M.NAME.RECENT_CONTACT}.${Ks.MARK_CONVERSATION}`},body:{fromAccount:"",itemList:void 0},keyMap:{request:{itemList:"MarkItem",operationType:"OptType",groupID:"ToGroupId"},response:{ToGroupId:"groupID",OptType:"operationType"}}}}(e)),this._configMap.set(Ks.CREATE_CONVERSATION_GROUP,function(e){return{head:{...e,servcmd:`${M.NAME.RECENT_CONTACT}.${Ks.RENAME_CONVERSATION_GROUP}`},body:{fromAccount:"",itemList:void 0},keyMap:{request:{itemList:"GroupContactItem",groupID:"ToGroupId"},response:{GroupId:"convGroupID",ToGroupId:"groupID",OptType:"operationType"}}}}(e)),this._configMap.set(Ks.DELETE_CONVERSATION_GROUP,function(e){return{head:{...e,servcmd:`${M.NAME.RECENT_CONTACT}.${Ks.DELETE_CONVERSATION_GROUP}`},body:{fromAccount:"",groupName:void 0},keyMap:{request:{},response:{GroupId:"convGroupID"}}}}(e)),this._configMap.set(Ks.RENAME_CONVERSATION_GROUP,function(e){return{head:{...e,servcmd:`${M.NAME.RECENT_CONTACT}.${Ks.RENAME_CONVERSATION_GROUP}`},body:{fromAccount:"",updateType:void 0,updateGroup:void 0},keyMap:{request:{oldName:"OldGroupName",newName:"NewGroupName",groupID:"ToGroupId",operationType:"ContactOptType",groupName:"OldGroupName",updateItem:"ContactUpdateItem"},response:{ContactOptType:"operationType",ToGroupId:"groupID",GroupId:"convGroupID"}}}}(e)),this._configMap.set(Ks.ADD_CONVERSATIONS_TO_GROUP,function(e){return{head:{...e,servcmd:`${M.NAME.RECENT_CONTACT}.${Ks.RENAME_CONVERSATION_GROUP}`},body:{fromAccount:"",updateType:void 0,updateGroup:{groupName:void 0,updateGroupType:void 0,updateItem:void 0}},keyMap:{request:{},response:{}}}}(e)),this._configMap.set(Ks.DELETE_CONVERSATIONS_FROM_GROUP,function(e){return{head:{...e,servcmd:`${M.NAME.RECENT_CONTACT}.${Ks.RENAME_CONVERSATION_GROUP}`},body:{fromAccount:"",updateType:void 0,updateGroup:void 0},keyMap:{request:{},response:{}}}}(e)),this._configMap.set(Ks.GET_CONVERSATION_GROUP_LIST,function(e){return{head:{...e,servcmd:`${M.NAME.RECENT_CONTACT}.${Ks.GET_CONVERSATION_GROUP_LIST}`},body:{fromAccount:"",startTime:void 0,startIndex:void 0},keyMap:{request:{},response:{GroupId:"convGroupID",ToGroupId:"groupID",OptType:"operationType",CustomMark:"customData",ContactGroupId:"convGroupIDList"}}}}(e)),this._configMap.set(Ks.GET_USER_PROFILE,function(e){return{head:{...e,servcmd:`${M.NAME.PROFILE}.${Ks.GET_USER_PROFILE}`},body:{fromAccount:"",userItem:[]},keyMap:{request:{toAccount:"To_Account",standardSequence:"StandardSequence",customSequence:"CustomSequence"}}}}(e)),this._configMap.set(Ks.UPDATE_MY_PROFILE,function(e){return{head:{...e,servcmd:`${M.NAME.PROFILE}.${Ks.UPDATE_MY_PROFILE}`},body:{fromAccount:"",profileItem:[{tag:Te.NICK,value:""},{tag:Te.GENDER,value:""},{tag:Te.ALLOWTYPE,value:""},{tag:Te.AVATAR,value:""}]},keyMap:{request:{toAccount:"To_Account",standardSequence:"StandardSequence",customSequence:"CustomSequence"}}}}(e)),this._configMap.set(Ks.GET_BLACKLIST,function(e){return{head:{...e,servcmd:`${M.NAME.FRIEND}.${Ks.GET_BLACKLIST}`},body:{fromAccount:"",startIndex:0,maxLimited:30,lastSequence:0},keyMap:{response:{CurruentSequence:"currentSequence"}}}}(e)),this._configMap.set(Ks.ADD_TO_BLACKLIST,function(e){return{head:{...e,servcmd:`${M.NAME.FRIEND}.${Ks.ADD_TO_BLACKLIST}`},body:{fromAccount:"",toAccount:[]}}}(e)),this._configMap.set(Ks.REMOVE_FROM_BLACKLIST,function(e){return{head:{...e,servcmd:`${M.NAME.FRIEND}.${Ks.REMOVE_FROM_BLACKLIST}`},body:{fromAccount:"",toAccount:[]}}}(e)),this._configMap.set(Ks.SET_SELF_STATUS,function(e){return{head:{...e,servcmd:`${M.NAME.IM_OPEN_STATUS}.${Ks.SET_SELF_STATUS}`},body:{customStatus:""},keyMap:{}}}(e)),this._configMap.set(Ks.GET_USER_STATUS,function(e){return{head:{...e,servcmd:`${M.NAME.IM_OPEN_STATUS}.${Ks.GET_USER_STATUS}`},body:{userIDList:void 0},keyMap:{response:{UserStatusList:"successUserList",ErrorList:"failureUserList",To_Account:"userID",Invalid_Account:"invalidUserID",Status:"statusType"}}}}(e)),this._configMap.set(Ks.SUBSCRIBE_USER_STATUS,function(e){return{head:{...e,servcmd:`${M.NAME.IM_OPEN_STATUS}.${Ks.SUBSCRIBE_USER_STATUS}`},body:{userIDList:void 0},keyMap:{response:{ErrorList:"failureUserList",To_Account:"userID",Invalid_Account:"invalidUserID"}}}}(e)),this._configMap.set(Ks.UNSUBSCRIBE_USER_STATUS,function(e){return{head:{...e,servcmd:`${M.NAME.IM_OPEN_STATUS}.${Ks.UNSUBSCRIBE_USER_STATUS}`},body:{userIDList:void 0,unsubscribeAll:void 0},keyMap:{response:{ErrorList:"failureUserList",To_Account:"userID",Invalid_Account:"invalidUserID"}}}}(e)),this._configMap.set(Ks.GET_FRIEND_LIST,function(e){return{head:{...e,servcmd:`${M.NAME.FRIEND}.${Ks.GET_FRIEND_LIST}`},body:{fromAccount:"",startIndex:0,standardSequence:0,customSequence:0},keyMap:{response:{FriendNum:"friendCount",UserDataItem:"resultList",ValueItem:"tagValueList"}}}}(e)),this._configMap.set(Ks.ADD_FRIEND,function(e){return{head:{...e,servcmd:`${M.NAME.FRIEND}.${Ks.ADD_FRIEND}`},body:{fromAccount:"",addFriendItem:[],type:""},keyMap:{request:{source:"AddSource",wording:"AddWording",type:"AddType"},response:{ResultItem:"resultList"}}}}(e)),this._configMap.set(Ks.UPDATE_FRIEND,function(e){return{head:{...e,servcmd:`${M.NAME.FRIEND}.${Ks.UPDATE_FRIEND}`},body:{fromAccount:"",updateItem:void 0},keyMap:{request:{snsItem:"SnsItem"},response:{ResultItem:"resultList"}}}}(e)),this._configMap.set(Ks.DELETE_FRIEND,function(e){return{head:{...e,servcmd:`${M.NAME.FRIEND}.${Ks.DELETE_FRIEND}`},body:{fromAccount:"",userIDList:[],type:""},keyMap:{request:{type:"DeleteType"},response:{ResultItem:"resultList"}}}}(e)),this._configMap.set(Ks.GET_FRIEND_PROFILE,function(e){return{head:{...e,servcmd:`${M.NAME.FRIEND}.${Ks.GET_FRIEND_PROFILE}`},body:{fromAccount:"",userIDList:void 0},keyMap:{response:{InfoItem:"resultList",SnsProfileItem:"tagValueList"}}}}(e)),this._configMap.set(Ks.CHECK_FRIEND,function(e){return{head:{...e,servcmd:`${M.NAME.FRIEND}.${Ks.CHECK_FRIEND}`},body:{fromAccount:"",userIDList:[],type:""},keyMap:{request:{type:"CheckType"},response:{InfoItem:"resultList"}}}}(e)),this._configMap.set(Ks.GET_FRIEND_APPLICATION_LIST,function(e){return{head:{...e,servcmd:`${M.NAME.FRIEND}.${Ks.GET_FRIEND_APPLICATION_LIST}`},body:{fromAccount:"",applicationType:"",startTime:0,maxLimited:0,lastSequence:0},keyMap:{response:{PendencyItem:"resultList",AddSource:"source",AddTime:"time",AddWording:"wording",Image:"avatar",UnreadPendencyCount:"unreadCount",To_Account:"userID",PendencyType:"type"}}}}(e)),this._configMap.set(Ks.RESPOND_FRIEND_APPLICATION,function(e){return{head:{...e,servcmd:`${M.NAME.FRIEND}.${Ks.RESPOND_FRIEND_APPLICATION}`},body:{fromAccount:"",responseFriendItem:[]},keyMap:{request:{tag:"TagName",action:"ResponseAction"},response:{ResultItem:"resultList"}}}}(e)),this._configMap.set(Ks.DELETE_FRIEND_APPLICATION,function(e){return{head:{...e,servcmd:`${M.NAME.FRIEND}.${Ks.DELETE_FRIEND_APPLICATION}`},body:{fromAccount:"",type:"",userIDList:void 0},keyMap:{request:{type:"PendencyType",userIDList:"To_Account"},response:{ResultItem:"resultList"}}}}(e)),this._configMap.set(Ks.REPORT_FRIEND_APPLICATION,function(e){return{head:{...e,servcmd:`${M.NAME.FRIEND}.${Ks.REPORT_FRIEND_APPLICATION}`},body:{fromAccount:"",latestTimeStamp:""},keyMap:{request:{latestTimeStamp:"LatestPendencyTimeStamp"}}}}(e)),this._configMap.set(Ks.CREATE_FRIEND_GROUP,function(e){return{head:{...e,servcmd:`${M.NAME.FRIEND}.${Ks.CREATE_FRIEND_GROUP}`},body:{fromAccount:"",groupName:void 0,userIDList:void 0},keyMap:{request:{groupName:"GroupName",userIDList:"To_Account"},response:{ResultItem:"resultList"}}}}(e)),this._configMap.set(Ks.DELETE_FRIEND_GROUP,function(e){return{head:{...e,servcmd:`${M.NAME.FRIEND}.${Ks.DELETE_FRIEND_GROUP}`},body:{fromAccount:"",nameList:void 0},keyMap:{request:{nameList:"GroupName"}}}}(e)),this._configMap.set(Ks.GET_FRIEND_GROUP_LIST,function(e){return{head:{...e,servcmd:`${M.NAME.FRIEND}.${Ks.GET_FRIEND_GROUP_LIST}`},body:{fromAccount:"",lastSequence:0,needFriend:"Need_Friend_Type_Yes"},keyMap:{response:{ResultItem:"resultList",GroupName:"name",FriendNumber:"friendCount",To_Account:"userIDList"}}}}(e)),this._configMap.set(Ks.UPDATE_FRIEND_GROUP,function(e){return{head:{...e,servcmd:`${M.NAME.FRIEND}.${Ks.UPDATE_FRIEND_GROUP}`},body:{fromAccount:"",oldName:"",newName:void 0,updateGroupItem:void 0},keyMap:{request:{oldName:"GroupOldName",newName:"GroupNewName"},response:{UpdateType:"type",ResultItem:"resultList"}}}}(e)),this._configMap.set(Ks.GET_GROUP_LIST,function(e){return{head:{...e,servcmd:`${M.NAME.GROUP}.${Ks.GET_GROUP_LIST}`},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",NoUnreadSeqList:"excludedUnreadSequenceList",MsgSeq:"readedSequence",LastRecallTime:"_lastRevokedTime"}}}}(e)),this._configMap.set(Ks.GET_GROUP_PROFILE,function(e){return{head:{...e,servcmd:`${M.NAME.GROUP}.${Ks.GET_GROUP_PROFILE}`},body:{groupIDList:void 0,responseFilter:{groupBaseInfoFilter:void 0,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",AppDefinedData:"groupCustomField",AppMemberDefinedData:"memberCustomField",AppDefinedDataFilter_Group:"groupCustomFieldFilter",AppDefinedDataFilter_GroupMember:"memberCustomFieldFilter",InfoSeq:"infoSequence",MemberList:"members",GroupInfo:"groups",ShutUpUntil:"muteUntil",ShutUpAllMember:"muteAllMembers"}}}}(e)),this._configMap.set(Ks.CREATE_GROUP,function(e){return{head:{...e,servcmd:`${M.NAME.GROUP}.${Ks.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,inviteOption:void 0},keyMap:{request:{ownerID:"Owner_Account",userID:"Member_Account",avatar:"FaceUrl",maxMemberNum:"MaxMemberCount",joinOption:"ApplyJoinOption",groupCustomField:"AppDefinedData",memberCustomField:"AppMemberDefinedData",inviteOption:"InviteJoinOption"},response:{HugeGroupFlag:"avChatRoomFlag",OverJoinedGroupLimit_Account:"overLimitUserIDList"}}}}(e)),this._configMap.set(Ks.DISMISS_GROUP,function(e){return{head:{...e,servcmd:`${M.NAME.GROUP}.${Ks.DISMISS_GROUP}`},body:{groupID:void 0}}}(e)),this._configMap.set(Ks.UPDATE_GROUP_PROFILE,function(e){return{head:{...e,servcmd:`${M.NAME.GROUP}.${Ks.UPDATE_GROUP_PROFILE}`},body:{groupID:void 0,name:void 0,introduction:void 0,notification:void 0,avatar:void 0,joinOption:void 0,groupCustomField:void 0,muteAllMembers:void 0,inviteOption:void 0},keyMap:{request:{groupCustomField:"AppDefinedData",muteAllMembers:"ShutUpAllMember",joinOption:"ApplyJoinOption",avatar:"FaceUrl",inviteOption:"InviteJoinOption"},response:{AppDefinedData:"groupCustomField",ShutUpAllMember:"muteAllMembers"}}}}(e)),this._configMap.set(Ks.APPLY_JOIN_GROUP,function(e){return{head:{...e,servcmd:`${M.NAME.GROUP}.${Ks.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(Ks.APPLY_JOIN_GROUP_NOAUTH,function(e){const{a2:t,tinyid:s,...o}=e;return{head:{...o,servcmd:`${M.NAME.BIG_GROUP_NO_AUTH}.${Ks.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(Ks.QUIT_GROUP,function(e){return{head:{...e,servcmd:`${M.NAME.GROUP}.${Ks.QUIT_GROUP}`},body:{groupID:void 0}}}(e)),this._configMap.set(Ks.SEARCH_GROUP,function(e){return{head:{...e,servcmd:`${M.NAME.GROUP}.${Ks.SEARCH_GROUP}`},body:{groupIDList:void 0,responseFilter:{groupBasePublicInfoFilter:["Type","Name","Introduction","Notification","FaceUrl","CreateTime","Owner_Account","LastInfoTime","LastMsgTime","NextMsgSeq","MemberNum","MaxMemberNum","ApplyJoinOption","InviteJoinOption"]}},keyMap:{response:{}}}}(e)),this._configMap.set(Ks.CHANGE_GROUP_OWNER,function(e){return{head:{...e,servcmd:`${M.NAME.GROUP}.${Ks.CHANGE_GROUP_OWNER}`},body:{groupID:void 0,newOwnerID:void 0},keyMap:{request:{newOwnerID:"NewOwner_Account"}}}}(e)),this._configMap.set(Ks.HANDLE_GROUP_APPLICATION,function(e){return{head:{...e,servcmd:`${M.NAME.GROUP}.${Ks.HANDLE_GROUP_APPLICATION}`},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(Ks.HANDLE_INVITE_JOIN_GROUP,function(e){return{head:{...e,servcmd:`${M.NAME.GROUP}.${Ks.HANDLE_INVITE_JOIN_GROUP}`},body:{groupID:void 0,applicant:void 0,invitee:void 0,handleAction:void 0,handleMessage:void 0,authentication:void 0,userDefinedField:void 0},keyMap:{request:{applicant:"Applicant_Account",invitee:"Invited_Account",handleAction:"HandleMsg",handleMessage:"ApprovalMsg"}}}}(e)),this._configMap.set(Ks.HANDLE_GROUP_INVITATION,function(e){return{head:{...e,servcmd:`${M.NAME.GROUP}.${Ks.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(Ks.GET_GROUP_PENDENCY,function(e){return{head:{...e,servcmd:`${M.NAME.GROUP}.${Ks.GET_GROUP_PENDENCY}`},body:{startTime:void 0,limit:void 0,handleAccount:void 0},keyMap:{request:{handleAccount:"Handle_Account"},response:{To_Account:"userID",ApplyInviteMsg:"note"}}}}(e)),this._configMap.set(Ks.DELETE_GROUP_SYSTEM_NOTICE,function(e){return{head:{...e,servcmd:`${M.NAME.OPEN_IM}.${Ks.DELETE_GROUP_SYSTEM_NOTICE}`},body:{messageListToDelete:void 0},keyMap:{request:{messageListToDelete:"DelMsgList",messageSeq:"MsgSeq",messageRandom:"MsgRandom"}}}}(e)),this._configMap.set(Ks.AVCHATROOM_POLLING,function(e){return{head:{...e,servcmd:`${M.NAME.BIG_GROUP_LONG_POLLING}.${Ks.AVCHATROOM_POLLING}`},body:{USP:1,startSeq:1,startBroadcastSeq:void 0,holdTime:90,key:void 0,simplifiedMessage:void 0},keyMap:{request:{USP:"USP"},response:{ToGroupId:"groupID",RspBroadcastMsgList:"broadcastMessageList",IsSystemMsg:"isSystemMessage"}}}}(e)),this._configMap.set(Ks.AVCHATROOM_NOAUTH_POLLING,function(e){const{a2:t,tinyid:s,...o}=e;return{head:{...o,servcmd:`${M.NAME.BIG_GROUP_LONG_POLLING_NO_AUTH}.${Ks.AVCHATROOM_POLLING}`},body:{USP:1,startSeq:1,holdTime:90,key:void 0,simplifiedMessage:void 0},keyMap:{request:{USP:"USP"},response:{ToGroupId:"groupID",RspBroadcastMsgList:"broadcastMessageList",IsSystemMsg:"isSystemMessage"}}}}(e)),this._configMap.set(Ks.GET_ONLINE_MEMBER_NUM,function(e){return{head:{...e,servcmd:`${M.NAME.GROUP}.${Ks.GET_ONLINE_MEMBER_NUM}`},body:{groupID:void 0},keyMap:{response:{OnlineMemberNum:"memberCount"}}}}(e)),this._configMap.set(Ks.SET_GROUP_ATTRIBUTES,function(e){return{head:{...e,servcmd:`${M.NAME.GROUP}.${Ks.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(Ks.MODIFY_GROUP_ATTRIBUTES,function(e){return{head:{...e,servcmd:`${M.NAME.GROUP}.${Ks.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(Ks.DELETE_GROUP_ATTRIBUTES,function(e){return{head:{...e,servcmd:`${M.NAME.GROUP}.${Ks.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(Ks.CLEAR_GROUP_ATTRIBUTES,function(e){return{head:{...e,servcmd:`${M.NAME.GROUP}.${Ks.CLEAR_GROUP_ATTRIBUTES}`},body:{groupID:void 0,mainSequence:void 0,avChatRoomKey:void 0,attributeControl:["RaceConflict"]}}}(e)),this._configMap.set(Ks.GET_GROUP_ATTRIBUTES,function(e){return{head:{...e,servcmd:`${M.NAME.GROUP_ATTR}.${Ks.GET_GROUP_ATTRIBUTES}`},body:{groupID:void 0,avChatRoomKey:void 0,groupType:1},keyMap:{request:{avChatRoomKey:"Key",groupType:"GroupType"}}}}(e)),this._configMap.set(Ks.GET_GROUP_NOTIFY,function(e){return{head:{...e,servcmd:`${M.NAME.GROUP}.${Ks.GET_GROUP_NOTIFY}`},body:{notifyReqList:[]},keyMap:{request:{notifyReqList:"NotifyReqList"},response:{NextMsgTime:"nextRevokedTime",NotifyMsgList:"notifyList",NotifyRspList:"notifyRspList"}}}}(e)),this._configMap.set(Ks.UPDATE_GROUP_COUNTER,function(e){return{head:{...e,servcmd:`${M.NAME.GROUP}.${Ks.UPDATE_GROUP_COUNTER}`},body:{groupID:void 0,counterList:void 0,avChatRoomKey:void 0,mode:void 0},keyMap:{request:{counterList:"GroupCounter"}}}}(e)),this._configMap.set(Ks.GET_GROUP_COUNTER,function(e){return{head:{...e,servcmd:`${M.NAME.GROUP}.${Ks.GET_GROUP_COUNTER}`},body:{groupID:void 0,keyList:[],avChatRoomKey:void 0},keyMap:{request:{keyList:"GroupCounterKeys"}}}}(e)),this._configMap.set(Ks.CREATE_TOPIC,function(e){return{head:{...e,servcmd:`${M.NAME.GROUP_COMMUNITY}.${Ks.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(Ks.DELETE_TOPIC,function(e){return{head:{...e,servcmd:`${M.NAME.GROUP_COMMUNITY}.${Ks.DELETE_TOPIC}`},body:{groupID:void 0,topicIDList:void 0},keyMap:{request:{topicIDList:"TopicIdList"},response:{DestroyResultItem:"resultList"}}}}(e)),this._configMap.set(Ks.UPDATE_TOPIC_PROFILE,function(e){return{head:{...e,servcmd:`${M.NAME.GROUP_COMMUNITY}.${Ks.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(Ks.GET_TOPIC_LIST,function(e){return{head:{...e,servcmd:`${M.NAME.GROUP_COMMUNITY}.${Ks.GET_TOPIC_LIST}`},body:{groupID:void 0,topicIDList:void 0,MemberInfoFilter:["NoUnreadSeqList"]},keyMap:{request:{topicIDList:"TopicIdList"},response:{TopicAndSelfInfo:"topicInfoList",TopicInfo:"topic",GroupID:"groupID",ShutUpTime:"muteTime",ShutUpAllFlag:"muteAllMembers",LastMsgTime:"lastMessageTime",MsgSeq:"readedSequence",LastMsgSeq:"sequence",NoUnreadSeqList:"excludedUnreadSequenceList"}}}}(e)),this._configMap.set(Ks.GET_GROUP_MEMBER_LIST,function(e){return{head:{...e,servcmd:`${M.NAME.GROUP}.${Ks.GET_GROUP_MEMBER_LIST}`},body:{groupID:void 0,limit:0,offset:void 0,next:void 0,memberRoleFilter:void 0,memberInfoFilter:void 0,memberCustomFieldFilter:void 0},keyMap:{request:{memberCustomFieldFilter:"AppDefinedDataFilter_GroupMember"},response:{AppMemberDefinedData:"memberCustomField",AppDefinedDataFilter_GroupMember:"memberCustomFieldFilter",MemberList:"members",ShutUpUntil:"muteUntil"}}}}(e)),this._configMap.set(Ks.GET_AVCHATROOM_MEMBER_LIST,function(e){return{head:{...e,servcmd:`${M.NAME.GROUP_AVCHATROOM}.${Ks.GET_AVCHATROOM_MEMBER_LIST}`},body:{groupID:void 0,offset:void 0,filter:void 0},keyMap:{request:{offset:"Timestamp",filter:"Mark"},response:{NextTimestamp:"offset"}}}}(e)),this._configMap.set(Ks.GET_GROUP_MEMBER_PROFILE,function(e){return{head:{...e,servcmd:`${M.NAME.GROUP}.${Ks.GET_GROUP_MEMBER_PROFILE}`},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(Ks.ADD_GROUP_MEMBER,function(e){return{head:{...e,servcmd:`${M.NAME.GROUP}.${Ks.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(Ks.DELETE_GROUP_MEMBER,function(e){return{head:{...e,servcmd:`${M.NAME.GROUP}.${Ks.DELETE_GROUP_MEMBER}`},body:{groupID:void 0,userIDList:void 0,reason:void 0},keyMap:{request:{userIDList:"MemberToDel_Account"}}}}(e)),this._configMap.set(Ks.BAN_AVCHATROOM_MEMBER,function(e){return{head:{...e,servcmd:`${M.NAME.GROUP}.${Ks.BAN_AVCHATROOM_MEMBER}`},body:{groupID:void 0,userIDList:void 0,duration:void 0,reason:""},keyMap:{request:{userIDList:"Members_Account",duration:"Duration",reason:"Description"}}}}(e)),this._configMap.set(Ks.MODIFY_GROUP_MEMBER_INFO,function(e){return{head:{...e,servcmd:`${M.NAME.GROUP}.${Ks.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(Ks.MARK_AVCHATROOM_MEMBER_INFO,function(e){return{head:{...e,servcmd:`${M.NAME.GROUP_AVCHATROOM}.${Ks.MARK_AVCHATROOM_MEMBER_INFO}`},body:{groupID:void 0,operationType:1,memberList:[]},keyMap:{request:{operationType:"CommandType",memberList:"MemberList",markType:"Marks",userID:"Member_Account"},response:{CommandType:"operationType",Marks:"markType",Member_Account:"userID"}}}}(e)),this._configMap.set(Ks.SSO_STAT,function(e){return{head:{...e,servcmd:`${M.NAME.IM_OPEN_STAT}.${Ks.SSO_STAT}`},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"}}}}(s)),this._configMap.set(Ks.PING,function(e){return{head:{...e,servcmd:`${M.NAME.HEARTBEAT}.${Ks.PING}`},body:{}}}(e)),this._configMap.set(Ks.MESSAGE_PUSH,function(e){return{head:{...e,servcmd:`${M.NAME.IM_OPEN_PUSH}.${Ks.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",Status:"statusType"}}}}(e)),this._configMap.set(Ks.MULTI_MESSAGE_PUSH,function(e){return{head:{...e,servcmd:`${M.NAME.IM_OPEN_PUSH}.${Ks.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(Ks.MESSAGE_PUSH_ACK,function(e){return{head:{...e,servcmd:`${M.NAME.OPEN_IM}.${Ks.MESSAGE_PUSH_ACK}`},body:{sessionData:void 0},keyMap:{request:{sessionData:"SessionData"}}}}(e)),this._configMap.set(Ks.STATUS_FORCE_OFFLINE,function(e){return{head:{...e,servcmd:`${M.NAME.IM_OPEN_STATUS}.${Ks.STATUS_FORCE_OFFLINE}`},body:{},keyMap:{response:{C2cNotifyMsgArray:"C2CNotifyMessageArray",NoticeSeq:"noticeSequence",KickoutMsgNotify:"kickoutMsgNotify",NewInstInfo:"newInstanceInfo"}}}}(e)),this._configMap.set(Ks.DOWNLOAD_MERGER_MESSAGE,function(e){return{head:{...e,servcmd:`${M.NAME.IM_LONG_MESSAGE}.${Ks.DOWNLOAD_MERGER_MESSAGE}`},body:{downloadKey:""},keyMap:{response:{Data:"data",Desc:"description",Ext:"extension",Download_Flag:"downloadFlag",ThumbUUID:"thumbUUID",VideoUUID:"videoUUID"}}}}(e)),this._configMap.set(Ks.UPLOAD_MERGER_MESSAGE,function(e){return{head:{...e,servcmd:`${M.NAME.IM_LONG_MESSAGE}.${Ks.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)),this._configMap.set(Ks.SET_TOKEN,function(e){return{head:{...e,servcmd:`${M.NAME.IM_OPEN_STATUS}.${Ks.SET_TOKEN}`},body:{tokenID:"",pushMsg:0,sdkAppID:0,businessID:"",deviceBrand:"",deviceToken:"",isTpns:0,isWebUniapp:0},keyMap:{request:{tokenID:"TokenID",pushMsg:"PushMsg",sdkAppID:"EnterVersion",businessID:"BusiID",deviceBrand:"InstType",deviceToken:"VarToken",isTpns:"IsTpns"}}}}(e)),this._configMap.set(Ks.STAT_FOREGROUND,function(e){return{head:{...e,servcmd:`${M.NAME.IM_OPEN_STATUS}.${Ks.STAT_FOREGROUND}`},body:{isWebUniapp:0}}}(e)),this._configMap.set(Ks.STAT_BACKGROUND,function(e){return{head:{...e,servcmd:`${M.NAME.IM_OPEN_STATUS}.${Ks.STAT_BACKGROUND}`},body:{C2CUnread:0,GroupUnread:0,isWebUniapp:0},keyMap:{request:{c2cUnreadCount:"C2cUnread",groupUnreadCount:"GrpUnread"}}}}(e))}has(e){return this._configMap.has(e)}get(e){return this._configMap.get(e)}update(){this._fillConfigMap()}getKeyMap(e){return this.has(e)?this.get(e).keyMap||{}:(Ie.w(`${this._n}.getKeyMap unknown protocolName:${e}`),{})}getProtocolData(e){const{protocolName:t,requestData:s}=e,o=this.get(t);let i=null;if(s){const e=this._simpleDeepCopy(o),t=this._updateService(s,e),n=t.body,r=Object.create(null);for(const o in n)if(Object.prototype.hasOwnProperty.call(n,o)){if(r[o]=n[o],void 0===s[o])continue;r[o]=s[o]}t.body=r,i=this._getUplinkData(t)}else i=this._getUplinkData(o);return i}_getUplinkData(e){const t=this._requestDataCleaner(e),s=lt(t.head),o=Ai(t.body,this._getRequestKeyMap(s));return t.body=o,t}_updateService(e,t){const s=lt(t.head);if(this._isFromGroupRequest(t)){let{type:o,groupID:i,groupIDList:n=[]}=e;Pe(i)&&(i=n[0]||""),Xe({type:o,groupID:i})&&(t.head.servcmd=`${M.NAME.GROUP_COMMUNITY}.${s}`)}return t}_isFromGroupRequest(e){return e.head.servcmd.includes(M.NAME.GROUP)||e.head.servcmd.includes(M.NAME.GROUP_ATTR)}_getRequestKeyMap(e){const t=this.getKeyMap(e);return{...Di.request,...t.request}}_requestDataCleaner(e){const t=Array.isArray(e)?[]:Object.create(null);for(const s in e)Object.prototype.hasOwnProperty.call(e,s)&&be(s)&&null!==e[s]&&void 0!==e[s]&&("object"!=typeof e[s]?t[s]=e[s]:t[s]=this._requestDataCleaner.bind(this)(e[s]));return t}_simpleDeepCopy(e){const t=Object.keys(e),s={};let o;for(let i=0,n=t.length;i<n;i++)o=t[i],Ue(e[o])?s[o]=Array.from(e[o]):Re(e[o])?s[o]=this._simpleDeepCopy(e[o]):s[o]=e[o];return s}}const Bi=[Ks.MESSAGE_PUSH_ACK];class Ki{constructor(e){this._sessionModule=e,this._n="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("C2CReadReceiptArray",this._C2CReadReceiptArrayHandler.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._eventHandlerMap.set("c2cMessageModified",this._c2cMessageModifiedHandler.bind(this)),this._eventHandlerMap.set("groupMessageModified",this._groupMessageModifiedHandler.bind(this)),this._eventHandlerMap.set("userStatusList",this._userStatusListHandler.bind(this)),this._eventHandlerMap.set("messageExtensionNotify",this._messageExtensionNotifyHandler.bind(this)),this._eventHandlerMap.set("messageReactionNotifyList",this._messageReactionNotifyListHandler.bind(this)),this._eventHandlerMap.set("messageReactionNotify",this._messageReactionNotifyHandler.bind(this)),this._keys=[...this._eventHandlerMap.keys()]}_c2cMessageArrayHandler(e){const t=this._sessionModule.getModule(ls);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(Cs).startOnlineSync()}t.onNewC2CMessage({dataList:e.dataList,isInstantMessage:!0})}}_c2cMessageModifiedHandler(e){const t=this._sessionModule.getModule(ls);t&&t.onC2CMessageModified(e)}_groupMessageArrayHandler(e){const t=this._sessionModule.getModule(ds);t&&t.onNewGroupMessage({event:e.event,dataList:e.dataList,isInstantMessage:!0})}_groupMessageModifiedHandler(e){const t=this._sessionModule.getModule(ds);t&&t.onGroupMessageModified(e)}_groupTipsHandler(e){const t=this._sessionModule.getModule(ds);if(!t)return;const{event:s,dataList:o,isInstantMessage:i=!0,isSyncingEnded:n}=e;switch(s){case 4:case 6:t.onNewGroupTips({event:s,dataList:o});break;case 5:for(let e=0;e<o.length;e++)if(Ue(o[e].elements.revokedInfos))t.onGroupMessageRevoked({dataList:o});else if(Ue(o[e].elements.groupMessageReadNotice))t.onGroupMessageReadNotice({dataList:o});else{if(!Ue(o[e].elements.readReceiptList)){t.onNewGroupSystemNotice({dataList:o,isInstantMessage:i,isSyncingEnded:n});break}t.onReadReceiptList({dataList:o})}break;case 12:this._sessionModule.getModule(hs).onNewGroupAtTips({dataList:o});break;default:Ie.l(`${this._n}._groupTipsHandler unknown event:${s} dataList:`,o)}}_C2CNotifyMessageArrayHandler(e){const{dataList:t}=e;if(!Ue(t))return;const s=this._sessionModule.getModule(ls);t.forEach(e=>{if(Le(e))if(e.hasOwnProperty("kickoutMsgNotify")){const{kickoutMsgNotify:{kickType:t,newInstanceInfo:s={}}}=e;1===t?this._sessionModule.onMultipleAccountKickedOut(s):2===t?this._sessionModule.onMultipleDeviceKickedOut(s):3===t&&this._sessionModule.onRestApiKickedOut(s)}else if(e.hasOwnProperty("c2cMessageRevokedNotify"))s&&s.onC2CMessageRevoked({dataList:t});else if(e.hasOwnProperty("c2cMessageReadReceipt"))s&&s.onC2CMessageReadReceipt({dataList:t});else if(e.hasOwnProperty("c2cMessageReadNotice"))s&&s.onC2CMessageReadNotice({dataList:t});else if(e.hasOwnProperty("muteNotificationsSync")){this._sessionModule.getModule(hs).onC2CMessageRemindTypeSynced({dataList:t})}})}_C2CReadReceiptArrayHandler(e){this._sessionModule.getModule(ls).onReadReceiptList(e)}_profileHandler(e){this._sessionModule.getModule(us).onProfileModified({dataList:e.dataList});const t=this._sessionModule.getModule(_s);t&&t.onFriendProfileModified({dataList:e.dataList})}_relationChainHandler(e){this._sessionModule.getModule(us).onRelationChainModified({dataList:e.dataList});const t=this._sessionModule.getModule(_s);t&&t.onRelationChainModified({dataList:e.dataList})}_recentContactHandler(e){const{dataList:t}=e;if(!Ue(t))return;const s=this._sessionModule.getModule(hs);s&&t.forEach(e=>{const{pushType:t}=e;if(1===t){const{recentContactDeleteItem:t}=e;s.onConversationDeleted(t.recentContactList)}else if(2===t){const{recentContactTopItem:t}=e;s.onConversationPinned(t.recentContactList)}else if(3===t){const{recentContactTopItem:t}=e;s.onConversationUnpinned(t.recentContactList)}else if(4===t){const{recentContactMarkContact:t}=e;s.onConversationMarkUpdated(t.recentContactMarkContactItem)}else if(5===t){const{recentContactCreateContactGroup:t}=e;s.onConversationGroupCreated(t.msgContactGroupContactItem)}else if(6===t){const{recentContactDelContactGroup:t}=e;s.onConversationGroupDeleted(t.msgGroupItem)}else if(7===t){const{recentContactUpdateContactGroup:t}=e,{updateType:o,msgUpdateGroup:i,msgUpdateContact:n}=t;if(1===o){const{updateGroupType:e}=i;1===e?s.onConversationGroupNameUpdated(i):2===e&&s.onConversationInGroupUpdated(i)}else 2===o&&s.onConversationAddedToOrDeletedFromGroup(n)}})}_allMessageReadHandler(e){const{dataList:t}=e,s=this._sessionModule.getModule(hs);s&&s.onPushedAllMessageRead(t)}_userStatusListHandler(e){this._sessionModule.getModule(us).onUserStatusUpdated(e)}_messageExtensionNotifyHandler(e){this._sessionModule.getModule(cs).onMessageExtensionNotify(e)}_messageReactionNotifyListHandler(e){this._sessionModule.getModule(ks).onMessageReactionNotifyList(e)}_messageReactionNotifyHandler(e){this._sessionModule.getModule(ks).onMessageReactionNotify(e)}onMessage(e){const{body:t}=e;if(!this._filterMessageFromIMOpenPush(e))return;const{eventArray:s,isInstantMessage:o,isSyncingEnded:i,needSync:n}=t;if(!Ue(s))return;let r=null,a=null,c=0;for(let u=0,l=s.length;u<l;u++){if(r=s[u],c=r.event,100===c){this._onRoomCustomData(r.content);continue}const e=Object.keys(r).find(e=>-1!==this._keys.indexOf(e));e?(a=14===c?{readAllC2CMessage:r[e],groupMessageReadInfoList:r.groupMessageReadNotice||[]}:16===c?{userID:r.userID,readReceiptList:r[e]}:r[e],this._eventHandlerMap.get(e)({event:c,dataList:a,isInstantMessage:o,isSyncingEnded:i,needSync:n})):Ie.l(`${this._n}.onMessage unknown eventItem:${r}`)}}_onRoomCustomData(e){this._sessionModule.getModule(Ls).onRoomCustomDataReceived(e)}_filterMessageFromIMOpenPush(e){const{head:t,body:s}=e,{servcmd:o}=t;let i=!1;if(Pe(o)||(i=o.includes(M.NAME.IM_CONFIG_MANAGER)||o.includes(M.NAME.OVERLOAD_PUSH)||o.includes(M.NAME.STAT_SERVICE)),!i)return!0;if(o.includes(Ks.PUSHED_CLOUD_CONTROL_CONFIG)){this._sessionModule.getModule(ys).onPushedCloudControlConfig(s)}else if(o.includes(Ks.PUSHED_COMMERCIAL_CONFIG)){this._sessionModule.getModule(As).onPushedConfig(s)}else if(o.includes(Ks.OVERLOAD_NOTIFY))this._sessionModule.onPushedServerOverload(s);else if(o.includes(Ks.KICK_OTHER)){const e=Date.now();this._sessionModule.reLoginOnKickOther();const t=new no("kickOther"),s=this._sessionModule.getModule(rs).getLastWsHelloTs(),o=e-s;t.setMessage(`last wshello time:${s} diff:${o}ms`).setNetworkType(this._sessionModule.getNetworkType()).end()}return!1}}const Hi=[{cmd:Ks.GET_GROUP_PROFILE,interval:1,count:8},{cmd:Ks.UPDATE_GROUP_PROFILE,interval:1,count:8},{cmd:Ks.GET_AVCHATROOM_MEMBER_LIST,interval:3,count:1},{cmd:Ks.GET_GROUP_PENDENCY,interval:1,count:15},{cmd:Ks.GET_TOPIC_LIST,interval:1,count:10},{cmd:Ks.SET_GROUP_ATTRIBUTES,interval:5,count:10},{cmd:Ks.MODIFY_GROUP_ATTRIBUTES,interval:5,count:10},{cmd:Ks.DELETE_GROUP_ATTRIBUTES,interval:5,count:10},{cmd:Ks.CLEAR_GROUP_ATTRIBUTES,interval:5,count:10},{cmd:Ks.GET_GROUP_ATTRIBUTES,interval:5,count:20},{cmd:Ks.UPDATE_GROUP_COUNTER,interval:5,count:20},{cmd:Ks.GET_GROUP_COUNTER,interval:5,count:20},{cmd:Ks.SET_ALL_MESSAGE_READ,interval:1,count:1},{cmd:Ks.GET_USER_STATUS,interval:5,count:20},{cmd:Ks.SUBSCRIBE_USER_STATUS,interval:5,count:20},{cmd:Ks.UNSUBSCRIBE_USER_STATUS,interval:5,count:20},{cmd:Ks.MESSAGE_CLOUD_SEARCH,interval:1,count:2}],Yi=new Map,Wi=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F"];for(let tt=0,In=Wi.length;tt<In;tt++)Yi.set(tt,Wi[tt]);function zi(e){let t,s,o=e;e.length%8!=0&&(o="0".repeat(8-e.length%8)+e);let i="";for(let n=0,r=o.length;n<r;n+=8)t=parseInt(o.slice(n,n+4),2),s=parseInt(o.slice(n+4,n+8),2),i+=Yi.get(t)+Yi.get(s);return i}class ji extends Bs{constructor(e){super(e),this._n="SessionModule",this._platform=this.getPlatform(),this._protocolHandler=new Vi(this),this._messageDispatcher=new Ki(this),this._commandFrequencyLimitMap=new Map,this._commandRequestInfoMap=new Map,this._serverOverloadInfoMap=new Map,this._incrementalPullContactFlag=!0,this._init();this.getInnerEmitterInstance().on(Do.CLOUD_CONFIG_UPDATED,this._onCloudConfigUpdated,this)}_init(){this._updateCommandFrequencyLimitMap(Hi)}_onCloudConfigUpdated(){let e=this.getCloudConfig("cmd_frequency_limit");Pe(e)||(e=JSON.parse(e),this._updateCommandFrequencyLimitMap(e))}_updateCommandFrequencyLimitMap(e){e.forEach(e=>{this._commandFrequencyLimitMap.set(e.cmd,{interval:e.interval,count:e.count})})}updateProtocolConfig(){this._protocolHandler.update()}request(e){Ie.d(this._n+".request options:",e);const{protocolName:t,tjgID:s}=e;if(!this._protocolHandler.has(t))return Ie.w(`${this._n}.request unknown protocol:${t}`),Vs({code:$s.CANNOT_FIND_PROTOCOL});const o=this.getProtocolData(e),{servcmd:i}=o.head;let n;if(this._isFrequencyOverLimit(i))return n=$s.OVER_FREQUENCY_LIMIT,Vs({code:n,message:this.getErrorMessage(n,this._getCmd(i))});if(this._isServerOverload(i))return n=$s.OPEN_SERVICE_OVERLOAD_ERROR,Vs({code:n,message:this.getErrorMessage(n,this._getCmd(i))});St(s)||(o.head.tjgID=s);const r=this.getModule(Ss);return Bi.includes(t)?r.simplySend(o):r.send(o)}getKeyMap(e){return this._protocolHandler.getKeyMap(e)}genCommonHead(){const e=this.getModule(gs);return{ver:"v4",platform:this._platform,websdkappid:a,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:192371,sdkability_ext:zi(""),cappid:e.getApplicationID(),tjgID:""}}genCosSpecifiedHead(){const e=this.getModule(gs);return{ver:"v4",platform:this._platform,websdkappid:a,websdkversion:r,sdkappid:e.getSDKAppID(),contenttype:e.getContentType(),reqtime:0,identifier:e.getUserID(),usersig:e.getUserSig(),status_instid:e.getStatusInstanceID(),sdkability:192371,sdkability_ext:zi(""),cappid:e.getApplicationID()}}genSSOReportHead(){const e=this.getModule(gs);return{ver:"v4",platform:this._platform,websdkappid:a,websdkversion:r,sdkappid:e.getSDKAppID(),contenttype:"",reqtime:0,identifier:"",usersig:"",status_instid:e.getStatusInstanceID(),sdkability:192371,sdkability_ext:zi(""),cappid:e.getApplicationID()}}getProtocolData(e){return this._protocolHandler.getProtocolData(e)}trans(e){const{servcmd:t,data:s}=e,o={head:{...this.genCommonHead(),servcmd:t},body:s};return this.getModule(Ss).send(o)}sendComboMessage(e){const{servcmd:t,data:s}=e,o={head:{...this.genCommonHead(),servcmd:t},body:s};return this.getModule(Ss).send(o)}onErrorCodeNotZero(e){const{errorCode:t}=e;if(t===$s.HELLO_ANSWER_KICKED_OUT){const{kickType:t,newInstanceInfo:s={}}=e;1===t?this.onMultipleAccountKickedOut(s):2===t?this.onMultipleDeviceKickedOut(s):3===t&&this.onRestApiKickedOut(s)}if(t===$s.MSG_A2KEY_EXPIRED||t===$s.ACCOUNT_A2KEY_EXPIRED){this._onUserSigExpired();this.getModule(Ss).reConnect()}}onMessage(e){const{body:t}=e,{needAck:s=0,sessionData:o}=t;1===s&&this._sendACK(o),this._messageDispatcher.onMessage(e)}onReconnected(e){this._incrementalPullContactFlag=e<=300,this._reLoginOnReconnected()}reLoginOnKickOther(){Ie.l(this._n+".reLoginOnKickOther"),this._reLogin()}_reLoginOnReconnected(){Ie.l(this._n+"._reLoginOnReconnected"),this._reLogin()}_reLogin(){const e=this._n+"._reLogin";if(this.isLoggedIn()){let t=0;const s=this.getModule(Os);s.canIUseOfflinePush()&&(t=s.getUniAppPlatform()),this.request({protocolName:Ks.LOGIN,requestData:{isWebUniapp:t}}).then(t=>{const{instanceID:s}=t.data;this.getModule(gs).setStatusInstanceID(s),Ie.l(`${e} ok. instanceID:${s}`);this.getModule(hs).syncConversationList(this._incrementalPullContactFlag).then(()=>{Ie.l(e+", sync conversation list ok.");this.getModule(Ns).start()});const o=this.getModule(ds);o&&o.updateLocalMainSequenceOnReconnected();const i=this.getModule(ps);i.resetGetTopicTime(),i.getTopicListOnReconnected()})}}onMultipleAccountKickedOut(e){this.getModule(rs).onMultipleAccountKickedOut(e)}onMultipleDeviceKickedOut(e){this.getModule(rs).onMultipleDeviceKickedOut(e)}_onUserSigExpired(){this.getModule(rs).onUserSigExpired()}onRestApiKickedOut(e){this.getModule(rs).onRestApiKickedOut(e)}_sendACK(e){this.request({protocolName:Ks.MESSAGE_PUSH_ACK,requestData:{sessionData:e}})}_isFrequencyOverLimit(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{count:s,interval:o}=this._commandFrequencyLimitMap.get(t);let{startTime:i,requestCount:n}=this._commandRequestInfoMap.get(t);if(Date.now()-i>1e3*o)return this._commandRequestInfoMap.set(t,{startTime:Date.now(),requestCount:1}),!1;n+=1,this._commandRequestInfoMap.set(t,{startTime:i,requestCount:n});let r=!1;return n>s&&(r=!0),r}_isServerOverload(e){if(!this._serverOverloadInfoMap.has(e))return!1;const{overloadTime:t,waitingTime:s}=this._serverOverloadInfoMap.get(e);let o=!1;return Date.now()-t<=1e3*s?o=!0:(this._serverOverloadInfoMap.delete(e),o=!1),o}_getCmd(e){let t="";if(!e.includes("."))return t;const s=e.split(".")[1];for(const o in Ks)if(Ks[o]===s){t=o;break}return t}onPushedServerOverload(e){const{overloadCommand:t,waitingTime:s}=e;this._serverOverloadInfoMap.set(t,{overloadTime:Date.now(),waitingTime:s}),Ie.w(`${this._n}.onPushedServerOverload waitingTime:${s}s cmd:${this._getCmd(t)}`)}reset(){Ie.l(this._n+".reset"),this._updateCommandFrequencyLimitMap(Hi),this._commandRequestInfoMap.clear(),this._serverOverloadInfoMap.clear(),this._incrementalPullContactFlag=!0}}class Ji extends Bs{constructor(e){super(e),this._n="CloudControlModule",this._cloudConfig=new Map,this._expiredTime=0,this._version=0,this._isFetching=!1}getCloudConfig(e){return Pe(e)?this._cloudConfig:this._cloudConfig.has(e)?this._cloudConfig.get(e):void 0}getServerConfig(e){const t={code:0,data:""};return!Pe(e)&&this._cloudConfig.has(e)&&(t.data=this._cloudConfig.get(e)),Promise.resolve(t)}_canFetchConfig(){return this.isLoggedIn()&&!this._isFetching&&Date.now()>=this._expiredTime}fetchConfig(){const e=this._canFetchConfig();if(Ie.l(`${this._n}.fetchConfig canFetchConfig:${e}`),!e)return;const t=new no("fetchCloudControlConfig"),s=this.getModule(gs).getSDKAppID();this._isFetching=!0,this.request({protocolName:Ks.FETCH_CLOUD_CONTROL_CONFIG,requestData:{SDKAppID:s,version:this._version}}).then(e=>{this._isFetching=!1,t.setMessage(`version:${this._version} newVersion:${e.data.version} config:${e.data.cloudControlConfig}`).setNetworkType(this.getNetworkType()).end(),Ie.l(this._n+".fetchConfig ok"),this._parseCloudControlConfig(e.data)}).catch(e=>{this._isFetching=!1,this.probeNetwork().then(([s,o])=>{t.setError(e,s,o).end()}),Ie.l(this._n+".fetchConfig failed. error:",e),this._setExpiredTimeOnResponseError(12e4)})}onPushedCloudControlConfig(e){Ie.l(this._n+".onPushedCloudControlConfig");new no("pushedCloudControlConfig").setNetworkType(this.getNetworkType()).setMessage(`newVersion:${e.version} config:${e.cloudControlConfig}`).end(),this._parseCloudControlConfig(e)}onCheckTimer(e){this._canFetchConfig()&&this.fetchConfig()}_parseCloudControlConfig(e){const t=this._n+"._parseCloudControlConfig",{errorCode:s,errorMessage:o,cloudControlConfig:i,version:n,expiredTime:r}=e;if(0===s){if(this._version!==n){let e=null;try{e=JSON.parse(i)}catch(a){this.isPrivateNetWork()||Ie.e(t+" JSON parse error. cloudControlConfig:",i)}e&&(this._cloudConfig.clear(),Object.keys(e).forEach(t=>{this._cloudConfig.set(t,e[t])}),this._version=n,this.emitInnerEvent(Do.CLOUD_CONFIG_UPDATED))}this._expiredTime=Date.now()+1e3*r}else Pe(s)?(Ie.l(t+" failed. Invalid message format:",e),this._setExpiredTimeOnResponseError(36e5)):(Ie.e(`${t} errorCode:${s} errorMessage:${o}`),this._setExpiredTimeOnResponseError(12e4))}_setExpiredTimeOnResponseError(e){this._expiredTime=Date.now()+e}reset(){Ie.l(this._n+".reset"),this._cloudConfig.clear(),this._expiredTime=0,this._version=0,this._isFetching=!1}}class Xi extends Bs{constructor(e){super(e),this._n="RecoverMessageModule",this.PULL_LIMIT_COUNT=15}start(){this._recoverGroupChat(),this._recoverC2CChat()}_recoverGroupChat(){const e=this._getLocalConversationList().filter(e=>e.type===t.CONV_GROUP&&e.groupProfile.type!==t.GRP_AVCHATROOM),s=this.getModule(hs);let o,i,n=0,r=0,a=0;const c=[];e.forEach(e=>{const{conversationID:u,lastMessage:l}=e;i=u.replace(t.CONV_GROUP,""),o=s.getLocalLastMessage(u),l&&0!==l.lastSequence&&o?(r=l.lastSequence,n=o.sequence,a=r-n,n>0&&a>=1&&a<300?this._recoverGroupMessage({groupID:i,localLastMessageSequence:n,remoteLastMessageSequence:r}):c.push(i)):c.push(i)}),this._getGroupNotify(c)}_recoverC2CChat(){const e=this._getLocalConversationList().filter(e=>e.type===t.CONV_C2C),s=this.getModule(hs);let o,i=0,n=0,r=0;const a=[Promise.resolve()];e.forEach(e=>{const{conversationID:t,lastMessage:c}=e;o=s.getLocalLastMessage(t),c&&0!==c.lastTime&&o&&(n=c.lastTime,i=o.time,r=n-i,i>0&&r>=1&&r<=600&&a.push(this._recoverC2CMessage({conversationID:t,localLastMessageTime:i,remoteLastMessageTime:n})))}),Promise.all(a).then(()=>{Ie.l(this._n+"._recoverC2CChat all promise fulfilled, start to sync unread messages");this.getModule(Cs).startSyncOnReconnected()})}_getLocalConversationList(){return this.getModule(hs).getLocalConversationList()}_recoverGroupMessage(e){const s=this._n+"._recoverGroupMessage";Ie.l(s+" options:",e);const{groupID:o,localLastMessageSequence:i,remoteLastMessageSequence:n}=e;this._getGroupRoamingMessage({groupID:o,sequence:i}).then(e=>{const{complete:i,messageList:r}=e.data;if(!Pe(r)){const e=r[0].sequence,a=`groupID:${o} pkgLastSequence:${e} remoteLastSequence:${n} complete:${i} count:${r.length}`;Ie.l(`${s} ${a}`),e<n&&2!==i&&this._recoverGroupMessage({groupID:o,localLastMessageSequence:e,remoteLastMessageSequence:n});new no("recoverMessage").setNetworkType(this.getNetworkType()).setMessage(a).end();const c=this.getModule(ds);r.length>1&&r.sort((e,t)=>e.sequence-t.sequence);for(let s=0;s<r.length;s++){const e=r[s];e.from!==t.CONV_SYSTEM?c.onNewGroupMessage({dataList:[e],isInstantMessage:!1,updateUnreadCount:!1}):c.onNewGroupTips({event:e.event,dataList:[e]})}this._getGroupNotify([o])}})}_genMultiGroupIDList(e,t){const s=t&&t>1?t:1,o=e.length,i=[];if(o>0)for(let n=0;n<o;n+=s)i.push(e.slice(n,n+s));return i}_getGroupNotify(e){const t=this._genMultiGroupIDList(e,10);if(t.length>0){const e=this.getModule(ds);for(let s=0,o=t.length;s<o;s++)e.getGroupNotify(t[s])}}_getGroupRoamingMessage(e){const{groupID:t,sequence:s}=e;return this.request({protocolName:Ks.GET_GROUP_ROAMING_MESSAGE,requestData:{groupID:t,count:this.PULL_LIMIT_COUNT,sequence:s+this.PULL_LIMIT_COUNT-1}})}_recoverC2CMessage(e){const s=this._n+"._recoverC2CMessage";Ie.l(s+" options:",e);const{conversationID:o,localLastMessageTime:i,remoteLastMessageTime:n}=e;return this._getC2CRoamingMessage({conversationID:o,time:i}).then(e=>{const{complete:i,messageList:r}=e.data;if(!Pe(r)){const e=r.length;this.getModule(ls).onNewC2CMessage({dataList:r,isInstantMessage:!0});const a=r[e-1].time,c=`peerAccount:${o.replace(t.CONV_C2C,"")} pkgLastTime:${a} remoteLastTime:${n} complete:${i} count:${e}`;Ie.l(`${s} ${c}`);if(new no("recoverMessage").setNetworkType(this.getNetworkType()).setMessage(c).end(),a<n&&1!==i)return this._recoverC2CMessage({conversationID:o,localLastMessageTime:a,remoteLastMessageTime:n})}})}_getC2CRoamingMessage(e){const{conversationID:s,time:o}=e;return this.request({protocolName:Ks.GET_C2C_ROAMING_MESSAGE,requestData:{peerAccount:s.replace(t.CONV_C2C,""),count:this.PULL_LIMIT_COUNT+1,lastMessageTime:o,direction:1}})}reset(){Ie.l(this._n+".reset")}}class Qi{constructor(){this._n="AvgE2EDelay",this._e2eDelayArray=[]}addMessageDelay(e){const t=he()-e;t>=0&&this._e2eDelayArray.push(t)}_calcAvg(e,t){if(0===t)return 0;let s=0;return e.forEach(e=>{s+=e}),dt(s/t,1)}_calcCountWithLimit(e){const{e2eDelayArray:t,min:s,max:o}=e;return t.filter(e=>s<=e&&e<o).length}_calcPercent(e,t){let s=dt(e/t*100,2);return s>100&&(s=100),s}_checkE2EDelayException(e,t){const s=e.filter(e=>e>t);if(s.length>0){const t=s.length,o=Math.min(...s),i=Math.max(...s),n=this._calcAvg(s,t),r=dt(t/e.length*100,2);if(r>50){new no("messageE2EDelayException").setMessage(`count:${t} min:${o} max:${i} avg:${n} percent:${r}`).setLevel("warning").end()}}}getStatResult(){const e=this._e2eDelayArray.length;if(0===e)return null;const t=[...this._e2eDelayArray],s=this._calcCountWithLimit({e2eDelayArray:t,min:0,max:1}),o=this._calcCountWithLimit({e2eDelayArray:t,min:1,max:3}),i=this._calcPercent(s,e),n=this._calcPercent(o,e),r=this._calcAvg(t,e);return this._checkE2EDelayException(t,3),t.length=0,this.reset(),{totalCount:e,countLessThan1Second:s,percentOfCountLessThan1Second:i,countLessThan3Second:o,percentOfCountLessThan3Second:n,avgDelay:r}}reset(){this._e2eDelayArray.length=0}}class Zi{constructor(){this._n="AvgRTT",this._requestCount=0,this._rttArray=[]}addRequestCount(){this._requestCount+=1}addRTT(e){this._rttArray.push(e)}_calcTotalCount(){return this._requestCount}_calcRTTCount(e){return e.length}_calcSuccessRateOfRequest(e,t){if(0===t)return 0;let s=dt(e/t*100,2);return s>100&&(s=100),s}_calcAvg(e,t){if(0===t)return 0;let s=0;return e.forEach(e=>{s+=e}),parseInt(s/t)}_calcMax(){return Math.max(...this._rttArray)}_calcMin(){return Math.min(...this._rttArray)}getStatResult(){const e=this._calcTotalCount(),t=[...this._rttArray];if(0===e)return null;const s=this._calcRTTCount(t),o=this._calcSuccessRateOfRequest(s,e),i=this._calcAvg(t,s);return Ie.l(`${this._n}.getStatResult max:${this._calcMax()} min:${this._calcMin()} avg:${i}`),this.reset(),{totalCount:e,rttCount:s,successRateOfRequest:o,avgRTT:i}}reset(){this._requestCount=0,this._rttArray.length=0}}class en{constructor(){this._map=new Map}initMap(e){e.forEach(e=>{this._map.set(e,{totalCount:0,successCount:0,failedCountOfUserSide:0,costArray:[],fileSizeArray:[]})})}addTotalCount(e){return!(Pe(e)||!this._map.has(e))&&(this._map.get(e).totalCount+=1,!0)}addSuccessCount(e){return!(Pe(e)||!this._map.has(e))&&(this._map.get(e).successCount+=1,!0)}addFailedCountOfUserSide(e){return!(Pe(e)||!this._map.has(e))&&(this._map.get(e).failedCountOfUserSide+=1,!0)}addCost(e,t){return!(Pe(e)||!this._map.has(e))&&(this._map.get(e).costArray.push(t),!0)}addFileSize(e,t){return!(Pe(e)||!this._map.has(e))&&(this._map.get(e).fileSizeArray.push(t),!0)}_calcSuccessRateOfBusiness(e){if(Pe(e)||!this._map.has(e))return-1;const t=this._map.get(e);let s=dt(t.successCount/t.totalCount*100,2);return s>100&&(s=100),s}_calcSuccessRateOfPlatform(e){if(Pe(e)||!this._map.has(e))return-1;const t=this._map.get(e);let s=this._calcSuccessCountOfPlatform(e)/t.totalCount*100;return s=dt(s,2),s>100&&(s=100),s}_calcTotalCount(e){return Pe(e)||!this._map.has(e)?-1:this._map.get(e).totalCount}_calcSuccessCountOfBusiness(e){return Pe(e)||!this._map.has(e)?-1:this._map.get(e).successCount}_calcSuccessCountOfPlatform(e){if(Pe(e)||!this._map.has(e))return-1;const t=this._map.get(e);return t.successCount+t.failedCountOfUserSide}_calcAvg(e){return Pe(e)||!this._map.has(e)?-1:e===Xs?this._calcAvgSpeed(e):this._calcAvgCost(e)}_calcAvgCost(e){const t=this._map.get(e).costArray.length;if(0===t)return 0;let s=0;return this._map.get(e).costArray.forEach(e=>{s+=e}),parseInt(s/t)}_calcAvgSpeed(e){let t=0,s=0;return this._map.get(e).costArray.forEach(e=>{t+=e}),this._map.get(e).fileSizeArray.forEach(e=>{s+=e}),parseInt(1e3*s/t)}getStatResult(e){const t=this._calcTotalCount(e);if(0===t)return null;const s=this._calcSuccessCountOfBusiness(e),o=this._calcSuccessRateOfBusiness(e),i=this._calcSuccessCountOfPlatform(e),n=this._calcSuccessRateOfPlatform(e),r=this._calcAvg(e);return this.reset(e),{totalCount:t,successCountOfBusiness:s,successRateOfBusiness:o,successCountOfPlatform:i,successRateOfPlatform:n,avgValue:r}}reset(e){Pe(e)?this._map.clear():this._map.set(e,{totalCount:0,successCount:0,failedCountOfUserSide:0,costArray:[],fileSizeArray:[]})}}class tn{constructor(){this._lastMap=new Map,this._currentMap=new Map}initMap(e){e.forEach(e=>{this._lastMap.set(e,new Map),this._currentMap.set(e,new Map)})}addMessageSequence(e){const{key:s,message:o}=e;if(Pe(s)||!this._lastMap.has(s)||!this._currentMap.has(s))return!1;const{conversationID:i,sequence:n}=o,r=i.replace(t.CONV_GROUP,"");if(0===this._lastMap.get(s).size)this._addCurrentMap(e);else if(this._lastMap.get(s).has(r)){const t=this._lastMap.get(s).get(r),o=t.length-1;n>t[0]&&n<t[o]?(t.push(n),t.sort(),this._lastMap.get(s).set(r,t)):this._addCurrentMap(e)}else this._addCurrentMap(e);return!0}_addCurrentMap(e){const{key:s,message:o}=e,{conversationID:i,sequence:n}=o,r=i.replace(t.CONV_GROUP,"");this._currentMap.get(s).has(r)||this._currentMap.get(s).set(r,[]),this._currentMap.get(s).get(r).push(n)}_copyData(e){if(!Pe(e)){this._lastMap.set(e,new Map);let t=this._lastMap.get(e);for(const[s,o]of this._currentMap.get(e))t.set(s,o);t=null,this._currentMap.set(e,new Map)}}getStatResult(e){if(Pe(this._currentMap.get(e))||Pe(this._lastMap.get(e)))return null;if(0===this._lastMap.get(e).size)return this._copyData(e),null;let t=0,s=0;if(this._lastMap.get(e).forEach((e,o)=>{const i=[...e.values()],n=i.length;t+=i[n-1]-i[0]+1,s+=n}),0===t)return null;let o=dt(s/t*100,2);return o>100&&(o=100),this._copyData(e),{totalCount:t,successCountOfMessageReceived:s,successRateOfMessageReceived:o}}reset(){this._currentMap.clear(),this._lastMap.clear()}}class sn extends Bs{constructor(e){super(e),this._n="QualityStatModule",this.TAG="im-ssolog-quality-stat",this.reportIndex=0,this.wholePeriod=!1,this._qualityItems=[Hs,Ys,Ws,zs,js,Js,Xs,Qs,Zs,eo],this._messageSentItems=[Ws,zs,js,Js,Xs],this._messageReceivedItems=[Qs,Zs,eo],this.REPORT_INTERVAL=120,this.REPORT_SDKAPPID_BLACKLIST=[],this.REPORT_TINYID_WHITELIST=[],this._statInfoArr=[],this._avgRTT=new Zi,this._avgE2EDelay=new Qi,this._rateMessageSent=new en,this._rateMessageReceived=new tn;const t=this.getInnerEmitterInstance();t.on(Do.A2KEY_AND_TINYID_UPDATED,this._onLoginSuccess,this),t.on(Do.CLOUD_CONFIG_UPDATED,this._onCloudConfigUpdated,this)}_onLoginSuccess(){this._rateMessageSent.initMap(this._messageSentItems),this._rateMessageReceived.initMap(this._messageReceivedItems);const e=this.getModule(ms),t=e.getItem(this.TAG,!1);!St(t)&&ke(t.forEach)&&(Ie.l(`${this._n}._onLoginSuccess. logs count:${t.length}`),t.forEach(e=>{this._statInfoArr.push(e)}),e.removeItem(this.TAG,!1))}_onCloudConfigUpdated(){const e=this.getCloudConfig("q_rpt_interval"),t=this.getCloudConfig("q_rpt_sdkappid_bl"),s=this.getCloudConfig("q_rpt_tinyid_wl");Pe(e)||(this.REPORT_INTERVAL=Number(e)),Pe(t)||(this.REPORT_SDKAPPID_BLACKLIST=t.split(",").map(e=>Number(e))),Pe(s)||(this.REPORT_TINYID_WHITELIST=s.split(","))}onCheckTimer(e){this.isLoggedIn()&&e%this.REPORT_INTERVAL==0&&(this.wholePeriod=!0,this._report())}addRequestCount(){this._avgRTT.addRequestCount()}addRTT(e){this._avgRTT.addRTT(e)}addMessageDelay(e){this._avgE2EDelay.addMessageDelay(e)}addTotalCount(e){this._rateMessageSent.addTotalCount(e)||Ie.w(this._n+".addTotalCount invalid key:",e)}addSuccessCount(e){this._rateMessageSent.addSuccessCount(e)||Ie.w(this._n+".addSuccessCount invalid key:",e)}addFailedCountOfUserSide(e){this._rateMessageSent.addFailedCountOfUserSide(e)||Ie.w(this._n+".addFailedCountOfUserSide invalid key:",e)}addCost(e,t){this._rateMessageSent.addCost(e,t)||Ie.w(this._n+".addCost invalid key or cost:",e,t)}addFileSize(e,t){this._rateMessageSent.addFileSize(e,t)||Ie.w(this._n+".addFileSize invalid key or size:",e,t)}addMessageSequence(e){this._rateMessageReceived.addMessageSequence(e)||Ie.w(this._n+".addMessageSequence invalid key:",e.key)}_getQualityItem(e){let t={},s=oo[this.getNetworkType()];Pe(s)&&(s=8);const o={qualityType:to[e],timestamp:_e(),networkType:s,extension:""};switch(e){case Hs:t=this._avgRTT.getStatResult();break;case Ys:t=this._avgE2EDelay.getStatResult();break;case Ws:case zs:case js:case Js:case Xs:t=this._rateMessageSent.getStatResult(e);break;case Qs:case Zs:case eo:t=this._rateMessageReceived.getStatResult(e)}return null===t?null:{...o,...t}}_report(e){let t=[],s=null;Pe(e)?this._qualityItems.forEach(e=>{s=this._getQualityItem(e),null!==s&&(s.reportIndex=this.reportIndex,s.wholePeriod=this.wholePeriod,t.push(s))}):(s=this._getQualityItem(e),null!==s&&(s.reportIndex=this.reportIndex,s.wholePeriod=this.wholePeriod,t.push(s))),Ie.d(this._n+"._report",t),this._statInfoArr.length>0&&(t=t.concat(this._statInfoArr),this._statInfoArr=[]);const o=this.getModule(gs),i=o.getSDKAppID(),n=o.getTinyID();_t(this.REPORT_SDKAPPID_BLACKLIST,i)&&!pt(this.REPORT_TINYID_WHITELIST,n)&&(t=[]),t.length>0&&this._doReport(t)}_doReport(e){const t={header:ni(this),quality:e};this.request({protocolName:Ks.SSO_STAT,requestData:{...t}}).then(()=>{this.reportIndex++,this.wholePeriod=!1}).catch(t=>{Ie.w(`${this._n}._doReport failed. networkType:${this.getNetworkType()} error:`,t),this._statInfoArr=this._statInfoArr.concat(e),this._flushAtOnce()})}_flushAtOnce(){const e=this.getModule(ms),t=e.getItem(this.TAG,!1),s=this._statInfoArr,o=this._n+"._flushAtOnce";if(St(t))Ie.l(`${o} count:${s.length}`),e.setItem(this.TAG,s,!0,!1);else{let i=s.concat(t);i.length>10&&(i=i.slice(0,10)),Ie.l(`${o} count:${i.length}`),e.setItem(this.TAG,i,!0,!1)}this._statInfoArr=[]}reset(){Ie.l(this._n+".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()}}class on extends Bs{constructor(e){super(e),this._n="WorkerTimerModule",this._isWorkerEnabled=!0,this._workerTimer=null,this._timerID=-1,this._init();this.getInnerEmitterInstance().on(Do.CLOUD_CONFIG_UPDATED,this._onCloudConfigUpdated,this)}isWorkerEnabled(){return this._isWorkerEnabled&&te}startWorkerTimer(){Ie.l(this._n+".startWorkerTimer"),this._workerTimer&&this._workerTimer.postMessage("start")}stopWorkerTimer(){Ie.l(this._n+".stopWorkerTimer"),this._workerTimer&&this._workerTimer.postMessage("stop")}_init(){if(te){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); postMessage(interval); } 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(e){e.data?(t._timerID=e.data,Ie.l(`${t._n}._init seed:${t._timerID}`)):t._m.onCheckTimer()}}}_onCloudConfigUpdated(){const e=this.getCloudConfig("enable_worker");Ie.l(`${this._n}._onCloudConfigUpdated enableWorker:${e}`),Pe(e)||"1"===e?!this._isWorkerEnabled&&te&&(this._isWorkerEnabled=!0,this.startWorkerTimer(),this._m.onWorkerTimerEnabled()):this._isWorkerEnabled&&te&&(this._isWorkerEnabled=!1,this.stopWorkerTimer(),this._m.onWorkerTimerDisabled())}terminate(){Ie.l(this._n+".terminate"),this._workerTimer&&(this._workerTimer.terminate(),this._workerTimer=null,this._timerID=-1)}getTimerID(){return this._timerID}reset(){Ie.l(this._n+".reset")}}class nn{constructor(){this._n="PurchasedFeatureHandler",this._purchasedFeatureMap=new Map}isValidPurchaseBits(e){return e&&"string"==typeof e&&e.length>=1&&e.length<=64&&/[01]{1,64}/.test(e)}parsePurchaseBits(e){if(this.isValidPurchaseBits(e)){this._purchasedFeatureMap.clear();let t=null;for(let s=e.length-1,i=0;s>=0;s--,i++)t=i<32?new o(0,Math.pow(2,i)).toString():new o(Math.pow(2,i-32),0).toString(),"1"===e[s]?this._purchasedFeatureMap.set(t,!0):this._purchasedFeatureMap.set(t,!1)}else Ie.w(`${this._n}.parsePurchaseBits invalid purchasebits:${e}`)}hasPurchasedFeature(e){return!!this._purchasedFeatureMap.get(e)}isFeatureEnabled(e){const t=parseInt(e).toString(2);let s=void 0,i=!0;for(let n=t.length-1,r=0;n>=0;n--,r++)if("1"===t.charAt(n)&&(s=r<32?new o(0,Math.pow(2,r)).toString():new o(Math.pow(2,r-32),0).toString(),!this._purchasedFeatureMap.get(s))){i=!1;break}return Ie.l(`${this._n}.isFeatureEnabled decimalNumber:${e} binaryString:${t} ret:${i}`),xs({enabled:i})}clear(){this._purchasedFeatureMap.clear()}}class rn{constructor(e){this._m=e,this._n="CommercialConfigModule",this._expiredTime=0,this._isFetching=!1,this._purchasedFeatureHandler=new nn}_canFetch(){return this._getModule(gs).isLoggedIn()?!this._isFetching&&Date.now()>=this._expiredTime:(this._expiredTime=Date.now()+2e3,!1)}onCheckTimer(e){this._canFetch()&&this.fetchConfig()}fetchConfig(){const e=this._canFetch(),t=this._n+".fetchConfig";if(Ie.l(`${t} canFetch:${e}`),!e)return;const s=this._getModule(Is),o=new no("fetchCommercialConfig");o.setNetworkType(s.getNetworkType());const i=this._getModule(gs).getSDKAppID(),n=this._getModule(Es);this._isFetching=!0,n.request({protocolName:Ks.FETCH_COMMERCIAL_CONFIG,requestData:{SDKAppID:i}}).then(e=>{o.setMessage("purchaseBits:"+e.data.purchaseBits).end(),Ie.l(t+" ok."),this._parseConfig(e.data),this._isFetching=!1}).catch(e=>{s.probe().then(([t,s])=>{o.setError(e,t,s).end()}),this._isFetching=!1})}onPushedConfig(e){const t=`${this._n}.onPushedConfig data:${JSON.stringify(e)}`;Ie.l(""+t);new no("pushedCommercialConfig").setNetworkType(this._getModule(Is).getNetworkType()).setMessage("purchaseBits:"+e.purchaseBits).end(),this._parseConfig(e)}_parseConfig(e){const t=this._n+"._parseConfig",{errorCode:s,errorMessage:o,purchaseBits:i,expiredTime:n}=e;0===s?(this._purchasedFeatureHandler.parsePurchaseBits(i),this._expiredTime=Date.now()+1e3*n):Pe(s)?(Ie.l(t+" failed. Invalid message format:",e),this._setExpiredTimeOnResponseError(36e5)):(Ie.e(`${t} errorCode:${s} errorMessage:${o}`),this._setExpiredTimeOnResponseError(12e4))}_setExpiredTimeOnResponseError(e){this._expiredTime=Date.now()+e}canIUse(e){return this._purchasedFeatureHandler.hasPurchasedFeature(e)}isFeatureEnabled(e){return this._purchasedFeatureHandler.isFeatureEnabled(e)}_getModule(e){return this._m.getModule(e)}reset(){Ie.l(this._n+".reset"),this._expiredTime=0,this._isFetching=!1,this._purchasedFeatureHandler.clear()}}class an extends Bs{constructor(e){super(e),this._m=e,this._n="OfflinePushModule",this._offlinePushPlugin=void 0,this._androidPushConfig={huaweiPushBussinessId:"",xiaomiPushBussinessId:"",xiaomiPushAppId:"",xiaomiPushAppKey:"",meizuPushBussinessId:"",meizuPushAppId:"",meizuPushAppKey:"",vivoPushBussinessId:"",fcmPushBussinessId:"",oppoPushBussinessId:"",oppoPushAppKey:"",oppoPushAppSecret:"",honorPushBussinessId:""},this._deviceToken="",this._businessID=0,this._iosBusinessID=0,this._c2cUnreadCount=0,this._groupUnreadCount=0,this._isWebUniapp=0}registerPlugin(e){if(!U)return void this.outputWarning("OfflinePushInUniapp");this._offlinePushPlugin=e["tim-offline-push-plugin"];const{huaweiBusinessID:t,xiaomiBusinessID:s,xiaomiAppID:o,xiaomiAppKey:i,meizuBusinessID:n,meizuAppID:r,meizuAppKey:a,vivoBusinessID:c,oppoBusinessID:u,oppoAppKey:l,oppoAppSecret:d,honorBusinessID:_,iosBusinessID:p}=e.offlinePushConfig||{};this._androidPushConfig.huaweiPushBussinessId=t,this._androidPushConfig.xiaomiPushBussinessId=s,this._androidPushConfig.xiaomiPushAppId=o,this._androidPushConfig.xiaomiPushAppKey=i,this._androidPushConfig.meizuPushBussinessId=n,this._androidPushConfig.meizuPushAppId=r,this._androidPushConfig.meizuPushAppKey=a,this._androidPushConfig.vivoPushBussinessId=c,this._androidPushConfig.oppoPushBussinessId=u,this._androidPushConfig.oppoPushAppKey=l,this._androidPushConfig.oppoPushAppSecret=d,this._androidPushConfig.honorPushBussinessId=_;new no("registerPlugin").setMessage("tim-offline-push-plugin").setMoreMessage("isExist:"+!Pe(this._offlinePushPlugin)).end(!0),Ie.l(`${this._n}.registerPlugin ok. offlinePushConfig:${JSON.stringify(e.offlinePushConfig)}`),this._iosBusinessID=p,this._setAppShowListener()}init(){this._isWebUniapp=this.getUniAppPlatform(),this._getDeviceToken()}_getDeviceToken(){const e=this._n+"._getDeviceToken";if(!ke(this._offlinePushPlugin.getDeviceToken))return void Ie.e(e+" getDeviceToken is not a function");let t=`androidPushConfig:${JSON.stringify(this._androidPushConfig)}, iosBusinessID:${this._iosBusinessID}`;Ie.l(`${e} start. ${t}`);new no("_getDeviceToken").setMessage(""+t).end(!0),this._offlinePushPlugin.getDeviceToken(this._androidPushConfig,s=>{const o=new no("getDeviceTokenRes"),{code:i,msg:n}=s;if(0===i){const{deviceToken:i,deviceBrand:n,deviceType:r,bussinessId:a}=s.data;this._deviceToken=i,this._businessID=a||this._iosBusinessID,t=`deviceToken:${i}, deviceBrand:${n||r}, businessID:${this._businessID}`,Ie.l(`${e} ok. ${t}`),o.setMessage(t).end(!0),this._setToken()}else o.setMessage(`code:${i}, msg:${n}`).end(!0),Ie.e(e+" failed. error:",s)})}canIUseOfflinePush(){return U&&!Pe(this._offlinePushPlugin)}_setAppShowListener(){const e=this._n+"._setAppShowListener";if(Pe(this._offlinePushPlugin))return void Ie.e(e+" offlinePushPlugin is undefined");if(!ke(this._offlinePushPlugin.setAppShowListener))return void Ie.e(e+" setAppShowListener is not a function");new no("_setAppShowListener").end(!0),Ie.l(e+" start"),this._offlinePushPlugin.setAppShowListener(t=>{const{appShow:s}=t||{};new no("setAppShowListenerRes").setMessage("appShow:"+s).end(!0),Ie.l(`${e} ok. appShow:${s}`),this._m.isReady()&&(0===s?(this._getConvUnreadCount(),this._onBackground()):1===s&&this._onForeground())})}getDeviceBrand(){if(!Pe(this._offlinePushPlugin)&&ke(this._offlinePushPlugin.getDeviceType)){const{deviceType:e}=this._offlinePushPlugin.getDeviceType()||{};return Ie.l(`${this._n}.getDeviceBrand ok. deviceType:${e}`),e}}_setToken(){const e=this._n+"._setToken",t=this.getModule(gs);let s="",o=1,i="",r="";St(this._deviceToken)&&(o=0);const a=this.getUniAppPlatform(),c=this.getDeviceBrand();a===n.IOS||a===n.IPAD||a===n.MAC?r=this._deviceToken:a===n.ANDROID&&(i=this._deviceToken);const u=new no("offlinePushSetToken");return s=`deviceToken:${r||i}, businessID:${this._businessID}, deviceBrand:${c}, isWebUniapp:${this._isWebUniapp}, pushMsg:${o}, platform:${a}`,u.setMessage(""+s),Ie.l(`${e} ${s}`),this.request({protocolName:Ks.SET_TOKEN,requestData:{tokenID:i,pushMsg:o,sdkAppID:t.getSDKAppID(),businessID:parseInt(this._businessID),deviceBrand:c,deviceToken:r,isWebUniapp:this._isWebUniapp}}).then(t=>(u.end(),Ie.l(e+" ok"),t)).catch(t=>(this.probeNetwork().then(([e,s])=>{u.setError(t,e,s).end()}),Ie.e(e+" failed. error:",t),Vs(t)))}_getConvUnreadCount(){this._c2cUnreadCount=0,this._groupUnreadCount=0;this.getModule(hs).getLocalConversationList().forEach(e=>{e.type===t.CONV_C2C&&(this._c2cUnreadCount+=e.unreadCount),e.type===t.CONV_GROUP&&(this._groupUnreadCount+=e.unreadCount)})}_onBackground(){const e=this._n+"._onBackground",t=new no("_onBackground");this.request({protocolName:Ks.STAT_BACKGROUND,requestData:{c2cUnreadCount:this._c2cUnreadCount,groupUnreadCount:this._groupUnreadCount,isWebUniapp:this._isWebUniapp}}).then(s=>(t.setMessage(`c2cUnreadCount: ${this._c2cUnreadCount}, groupUnreadCount: ${this._groupUnreadCount}`).end(),Ie.l(e+" ok"),s)).catch(s=>{this.probeNetwork().then(([e,o])=>{t.setError(s,e,o).end()}),Ie.e(e+" failed. error:",s)})}_onForeground(){const e=this._n+"._onForeground",t=new no("_onForeground");this.request({protocolName:Ks.STAT_FOREGROUND,requestData:{isWebUniapp:this._isWebUniapp}}).then(s=>(t.end(),Ie.l(e+" ok"),s)).catch(s=>{this.probeNetwork().then(([e,o])=>{t.setError(s,e,o).end()}),Ie.e(e+" failed. error:",s)})}getUniAppPlatform(){const e=uni.getSystemInfoSync().platform,t=this.getDeviceBrand();return"ios"===e?n.IOS:"android"===e?n.ANDROID:1002===t?n.IPAD:1001===t?n.MAC:void 0}reset(){this._deviceToken="",this._businessID=0,this._c2cUnreadCount=0,this._groupUnreadCount=0,this._isWebUniapp=0,Ie.l(this._n+".reset")}}class cn extends Bs{constructor(e){super(e),this._n="ProfanityFilterModule",this._plugin=null,this._filterConfigMap=new Map,this._startIndex=0,this._version=0,this._canIUseLexicon=!1,this._isFetching=!1,this._expiredTime=0}init(){const e=this.getModule(Ts).getPlugin("tim-profanity-filter-plugin");e?(this._plugin=new e({logger:Ie,isArray:Ue,isMap:Ne,isDevMode:this.isDevMode()}),this._getLexicon()):this.outputWarning("ProfanityPluginNotFound")}onCheckTimer(){this._plugin&&this._canIUseLexicon&&this.isLoggedIn()&&!this._isFetching&&Date.now()>=this._expiredTime&&this._getLexicon()}filterMessage(e,s){let o=!0;if(!this._plugin||!this._canIUseLexicon)return o;if(s&&s.messageControlInfo&&!0===s.messageControlInfo.excludedFromContentModeration)return o;const{type:i,conversationType:n}=e;if(i!==t.MSG_TEXT&&i!==t.MSG_CUSTOM)return o;const r=this._n+".filterMessage";let a;if(Ie.l(""+r),i===t.MSG_TEXT){if(n===t.CONV_C2C?a=f:n===t.CONV_GROUP&&(a=C),!this._isConfigOn(a))return o;const{type:s,modifiedText:i}=this._plugin.filter(e.payload.text);1===s?o=!1:2===s&&(e.payload.text=i)}else if(i===t.MSG_CUSTOM){if(n===t.CONV_C2C?a=T:n===t.CONV_GROUP&&(a=E),!this._isConfigOn(a))return o;const s=this._plugin.filter(e.payload.data),i=this._plugin.filter(e.payload.description),r=this._plugin.filter(e.payload.extension);1===s.type||1===i.type||1===r.type?o=!1:(2===s.type&&(e.payload.data=s.modifiedText),2===i.type&&(e.payload.description=i.modifiedText),2===r.type&&(e.payload.extension=r.modifiedText))}return Ie.l(`${r} done. isAllowedToSend:${o}`),o}filterText(e,t){const s=this._n+".filterText",o={isAllowedToSend:!0,modifiedText:e};if(!this._plugin||!this._canIUseLexicon)return o;if(!this._isConfigOn(t))return o;Ie.l(""+s);const{type:i,modifiedText:n}=this._plugin.filter(e);return 1===i?o.isAllowedToSend=!1:2===i&&(o.modifiedText=n),Ie.l(s+" done. ret:",o),o}_getLexicon(){const e=new no("profanityFilter"),t=this._n+"._getLexicon";this._isFetching=!0,this.request({protocolName:Ks.GET_PROFANITY_LIST,requestData:{startIndex:this._startIndex,version:this._version}}).then(s=>{const{errorInfo:o,filterConfig:i,lexicon:n,strToken:r,completeFlag:a,nextStartIndex:c,version:u,expiredTime:l}=s.data,{errorCode:d,errorMessage:_}=o;return 0!==d?(this._isFetching=!1,Ie.w(t+" failed. error:",o),void e.setCode(d).setMessage(_).end()):(this._onFilterConfig(i),this._getToken(r),1===a?(Ie.l(`${t} done. version:${u} expiredTime:${l}`),this._version=u,this._canIUseLexicon=!0,this._isFetching=!1,this._expiredTime=Date.now()+1e3*l,void this._plugin.onLexiconCompleted(n)):(this._startIndex=c,this._plugin.onLexiconSliced(n),void this._getLexicon()))}).catch(s=>{this.probeNetwork().then(([t,o])=>{e.setError(s,t,o).end()}),this._isFetching=!1,Ie.l(t+" failed. error:",s)})}_onFilterConfig(e){St(e)||(this._filterConfigMap.clear(),Object.keys(e).forEach(t=>{this._filterConfigMap.set(t,e[t])}),Ie.l(`${this._n}._onFilterConfig. keys:${Array.from(this._filterConfigMap.keys())} values:${Array.from(this._filterConfigMap.values())}`))}_isConfigOn(e){return 1===this._filterConfigMap.get(e)}_getToken(e){if(!Oe(e))return;const t=e.length;let s="";if(t%2==0)for(let o=0;o<=t-1;o+=2)s+=e[o+1],s+=e[o];else{for(let o=0;o<t-1;o+=2)s+=e[o+1],s+=e[o];s+=e[t-1]}this._plugin.onToken(s)}reset(){Ie.l(this._n+".reset"),this._plugin&&(this._plugin.reset(),this._plugin=null),this._filterConfigMap.clear(),this._startIndex=0,this._version=0,this._canIUseLexicon=!1,this._isFetching=!1,this._expiredTime=0}}class un{constructor(e){this._m=e,this._n="TransCmdModule",this._TRTCCommandList=["tui_room_svr.*","callkit_records_svr.*","room_engine_srv.*","room_engine_http_srv.*","room_engine_mic.*"],this._TRTCCommandMap=new Map,this._setTRTCCommandMap();this._m.getInnerEmitterInstance().on(Do.CLOUD_CONFIG_UPDATED,this._onCloudConfigUpdated,this)}_onCloudConfigUpdated(){let e=this._m.getModule(ys).getCloudConfig("rtc_cmd");Pe(e)||(e=JSON.parse(e),e.forEach(e=>{this._TRTCCommandList.includes(e)||this._TRTCCommandList.push(e)}),this._setTRTCCommandMap())}_setTRTCCommandMap(){let e=null;for(let t=0,s=this._TRTCCommandList.length;t<s;t++)e=this._TRTCCommandList[t].split(".")[0],this._TRTCCommandMap.set(e,1)}onRoomCustomDataReceived(t){this._m.getOuterEmitterInstance().emit(e.ROOM_CUSTOM_DATA_RECEIVED,t)}sendTRTCCustomData(e){const{serviceCommand:t,data:s}=e;let o=M.NAME.TUIROOM_SVR+".*";return Pe(t)||(o=t),this._isValidServiceCommand(o)?this._trans({servcmd:o,data:s}):Vs({code:$s.INVALID_TRTC_CMD})}_trans(e){Ie.d(`${this._n}._trans. options:${JSON.stringify(e)}`);const{servcmd:t,data:s}=e;return this._m.getModule(Es).trans({servcmd:t,data:Oe(s)?JSON.parse(s):s})}_isValidServiceCommand(e){if(e.endsWith(".*"))return this._TRTCCommandList.includes(e);const t=e.split(".")[0];return this._TRTCCommandMap.has(t)}isTRTCCommand(e){const t=e.split(".")[0];return this._TRTCCommandMap.has(t)}reset(){Ie.l(this._n+".reset")}}class ln{constructor(e){this._m=e,this._n="ErrorMessageModule",this.TIM_ERROR_ASSISTANCE="tim_error_assistance",this.STORAGE_EXPIRES_TIME=6048e5,this._map=new Map,this._init()}_init(){const e=this._getStorageModule().getItem(this.TIM_ERROR_ASSISTANCE,!1);if(!e)return void this._fetch();let t;try{t=JSON.parse(e)}catch(s){this._getStorageModule().removeItem(this.TIM_ERROR_ASSISTANCE,!1),Ie.w(this._n+"._init error:",s)}t&&(this._needToUpdate(t)?this._fetch():this._fillMap(t.message))}_needToUpdate(e){const{localSavedTime:t,localSavedVersion:s}=e,o=t&&(new Date).getTime()-t>=this.STORAGE_EXPIRES_TIME,i=!s||"3.2.3"!==s;return Ie.l(`${this._n}._needToUpdate isTimeout:${o} isDifferentVersion:${i}`),o||i}_fetch(){if(this._m.getModule(gs).isPrivateNetWork())return;const e="https://web.sdk.qcloud.com/im/download/error-message/v3/0.0.4/tim-error-message.txt",t="application/x-www-form-urlencoded;charset=UTF-8",s=this._n+"._fetch ok in",o=this;if(G)w.request({url:e,method:"GET",timeout:3e3,header:{"content-type":t},dataType:"text",success:e=>{o._fillAndSave(e.data),Ie.l(s+" mini program")},fail:()=>{}});else{const i=new XMLHttpRequest,n=setTimeout(()=>{i.abort()},3e3);i.onreadystatechange=function(){4===i.readyState&&(clearTimeout(n),200!==i.status&&304!==i.status||(Ie.l(s+" browser"),o._fillAndSave(i.responseText)))},i.open("GET",e,!0),i.setRequestHeader("Content-type",t),i.send()}}_fillAndSave(e){this._fillMap(e),this._getStorageModule().setItem(this.TIM_ERROR_ASSISTANCE,JSON.stringify({message:e,localSavedTime:(new Date).getTime(),localSavedVersion:"3.2.3"}),!0,!1)}_getStorageModule(){return this._m.getModule(ms)}_fillMap(e){this._map.clear();const t=e.split(";\n"),s=t.length;let o,i,n;const r=new RegExp(/'/g);for(let a=0;a<s;a++)if(o=t[a].indexOf(":"),i=t[a].slice(0,o),n=t[a].slice(o+1,t[a].length),!i.startsWith("//")){if(Pe(n))continue;this._map.set(i,n.replace(r,""))}}get(e){const{isIntl:t,key:s,replacement1:o,replacement2:i}=e;let n=t?s+"_en":s+"_cn";!this._map.has(n)&&this._map.has(s)&&(n=s);let r="";return this._map.has(n)?(r=this._map.get(n),Pe(o)||(r=r.replace("$replacement1",o)),Pe(i)||(r=r.replace("$replacement2",i)),r):r}reset(){Ie.l(this._n+".reset")}}class dn{constructor(e){const t=new no("sdkConstruct");if(this._n="ModuleManager",this._isReady=!1,this._reason=$s.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(gs,new Zo(this,e)),this._moduleMap.set(As,new rn(this)),this._moduleMap.set(ys,new Ji(this)),this._moduleMap.set(Ds,new on(this)),this._moduleMap.set(vs,new sn(this)),this._moduleMap.set(Ss,new xi(this)),this._moduleMap.set(Es,new ji(this)),this._moduleMap.set(rs,new ti(this)),this._moduleMap.set(as,new fi(this)),this._moduleMap.set(cs,new Ti(this)),this._moduleMap.set(ks,new Ci(this)),this._moduleMap.set(Us,new Ei(this)),this._moduleMap.set(us,new Qo(this)),this._moduleMap.set(ls,new So(this)),this._moduleMap.set(hs,new Vo(this)),this._moduleMap.set(ps,new Yo(this)),this._moduleMap.set(ms,new oi(this)),this._moduleMap.set(Ps,new ln(this)),this._moduleMap.set(Ms,new ri(this)),this._moduleMap.set(Is,new li(this)),this._moduleMap.set(fs,new hi(this)),this._moduleMap.set(Ts,new Si(this)),this._moduleMap.set(Cs,new yi(this)),this._moduleMap.set(Ns,new Xi(this)),this._moduleMap.set(Os,new an(this)),this._moduleMap.set(Rs,new cn(this)),this._moduleMap.set(Ls,new un(this)),this._eventThrottleMap=new Map,Le(e.modules)){let t;Object.keys(e.modules).forEach(s=>{t=e.modules[s],"group-module"===s?this._moduleMap.set(ds,new t(this)):"relationship-module"===s?this._moduleMap.set(_s,new t(this)):"signaling-module"===s&&this._moduleMap.set(Gs,new t(this))}),this._moduleMap.get(gs).setUsingChatCore(!0)}else this._moduleMap.has(ds)||this._moduleMap.get(gs).setUsingChatCore(!0);const{instanceID:s,SDKAppID:o}=e,i=`instanceID:${s} SDKAppID:${o} isIntl:${this._moduleMap.get(gs).isIntl()} isUsingChatCore:${this._moduleMap.get(gs).isUsingChatCore()} host:${rt()} isIOSWebView:${ie} inBrowser:${k} inMiniApp:${G} workerAvailable:${te} UserAgent:${F}`;no.bindEventStatModule(this._moduleMap.get(Ms)),t.setMessage(`${i} ${function(){let e="";if(G)try{const{model:t,version:s,system:o,platform:i,SDKVersion:n}=w.getSystemInfoSync();e=`model:${t} version:${s} system:${o} platform:${i} SDKVersion:${n}`}catch(t){e=""}return e}()}`).end(),Ie.i("SDK "+i),Fs.prototype._getErrorMessage=this.getErrorMessage.bind(this),this._readyList=void 0,this._ssoLogForReady=null,this._initReadyList()}_startTimer(){const e=this._moduleMap.get(Ds),t=e.isWorkerEnabled();Ie.l(`${this._n}.startTimer isWorkerEnabled:${t} seed:${this._checkTimer}`),t?e.startWorkerTimer():this._startMainThreadTimer()}_startMainThreadTimer(){this._checkTimer<0&&(this._checkTimer=setInterval(this.onCheckTimer.bind(this),1e3)),Ie.l(`${this._n}._startMainThreadTimer seed:${this._checkTimer}`)}stopTimer(){const e=this._moduleMap.get(Ds),t=e.isWorkerEnabled();Ie.l(`${this._n}.stopTimer isWorkerEnabled:${t} seed:${this._checkTimer}`),t?e.stopWorkerTimer():this._stopMainThreadTimer()}_stopMainThreadTimer(){Ie.l(this._n+"._stopMainThreadTimer"),this._checkTimer>0&&(clearInterval(this._checkTimer),this._checkTimer=-1,this._checkCount=0)}_stopMainThreadSocket(){Ie.l(this._n+"._stopMainThreadSocket");const e=this._moduleMap.get(Ss);e.setIsWorkerEnabled(!0),e.reConnect()}_startMainThreadSocket(){Ie.l(this._n+"._startMainThreadSocket");const e=this._moduleMap.get(Ss);e.setIsWorkerEnabled(!1),e.reConnect()}onWorkerTimerEnabled(){Ie.l(this._n+".onWorkerTimerEnabled, disable main thread timer and socket"),this._stopMainThreadTimer(),this._stopMainThreadSocket()}onWorkerTimerDisabled(){Ie.l(this._n+".onWorkerTimerDisabled, enable main thread timer and socket"),this._startMainThreadTimer(),this._startMainThreadSocket()}onCheckTimer(){this._checkCount+=1;for(const[,e]of this._moduleMap)e.onCheckTimer&&e.onCheckTimer(this._checkCount)}_initReadyList(){this._readyList=[this._moduleMap.get(rs)],this._readyList.forEach(e=>{e.ready(()=>this._onModuleReady())})}_onModuleReady(){let t=!0;if(this._readyList.forEach(e=>{e.isReady()||(t=!1)}),t&&!this._isReady){this._isReady=!0,this._outerEmitter.emit(e.SDK_READY);const t=Date.now()-this._startLoginTs;Ie.w(`SDK is ready. cost ${t} ms`),this._startLoginTs=Date.now();const s=this._moduleMap.get(Is).getNetworkType(),o=this._ssoLogForReady.getStartTs()+de;this._ssoLogForReady.setNetworkType(s).setMessage(t).start(o).end()}}login(){0===this._startLoginTs&&(pe(),this._startLoginTs=Date.now(),this._startTimer(),this._moduleMap.get(Is).start(),this._ssoLogForReady=new no("sdkReady"),this._reason=$s.LOGGING_IN)}onLoginFailed(){this._startLoginTs=0}getOuterEmitterInstance(){return null===this._outerEmitter&&(this._outerEmitter=new di,qs(this._outerEmitter),this._outerEmitter._emit=this._outerEmitter.emit,this._outerEmitter.emit=function(t,s){if(this._canIUseSignaling()){if(t===e.MESSAGE_RECEIVED){this.getModule(Gs).onNewMessageList(s)}if(t===e.MESSAGE_MODIFIED){this.getModule(Gs).onMessageModified(s)}}if(t===e.CONVERSATION_LIST_UPDATED||t===e.FRIEND_LIST_UPDATED||t===e.GROUP_LIST_UPDATED||t===e.TOTAL_UNREAD_MESSAGE_COUNT_UPDATED)if(this._eventThrottleMap.has(t)){const e=Date.now(),s=this._eventThrottleMap.get(t);e-s.last<=1e3?(s.timeoutID&&clearTimeout(s.timeoutID),s.timeoutID=setTimeout(()=>{s.last=Date.now(),this._outerEmitter._emit.apply(this._outerEmitter,[t,{name:t,data:this._getEventData(t)}])},1e3)):(s.last=e,this._outerEmitter._emit.apply(this._outerEmitter,[t,{name:t,data:this._getEventData(t)}]))}else this._eventThrottleMap.set(t,{last:Date.now(),timeoutID:-1}),this._outerEmitter._emit.apply(this._outerEmitter,[t,{name:t,data:this._getEventData(t)}]);else this._outerEmitter._emit.apply(this._outerEmitter,[t,{name:t,data:arguments[1]}])}.bind(this)),this._outerEmitter}_canIUseSignaling(){const e=this.getModule(Gs);return!!e&&e.canIUseSignaling()}_getEventData(t){return t===e.CONVERSATION_LIST_UPDATED?this._moduleMap.get(hs).getLocalConversationList():t===e.FRIEND_LIST_UPDATED?this._moduleMap.get(_s).getLocalFriendList(!1):t===e.GROUP_LIST_UPDATED?this._moduleMap.get(ds).getLocalGroupList():t===e.TOTAL_UNREAD_MESSAGE_COUNT_UPDATED?this._moduleMap.get(hs).getTotalUnreadMessageCount():void 0}getInnerEmitterInstance(){return null===this._innerEmitter&&(this._innerEmitter=new di,this._innerEmitter._emit=this._innerEmitter.emit,this._innerEmitter.emit=function(e,t){let s;s=Le(arguments[1])&&arguments[1].data?[e,{name:arguments[0],data:arguments[1].data}]:[e,{name:arguments[0],data:arguments[1]}],this._innerEmitter._emit.apply(this._innerEmitter,s)}.bind(this)),this._innerEmitter}hasModule(e){return this._moduleMap.has(e)}getModule(e){return this._moduleMap.get(e)}isReady(){return this._isReady}isIntl(){return this.getModule(gs).isIntl()}getNotReadyReason(){return this._reason}setNotReadyReason(e){this._reason=e}getErrorMessage(e,t,s){return this._moduleMap.get(Ps).get({key:e,replacement1:t,replacement2:s,isIntl:this.isIntl()})}outputWarning(e,t,s){const o=this.getErrorMessage(e,t,s);o&&Ie.w(o)}onError(t){const s=`code:${t.code} message:${t.message}`;Ie.w("Oops! "+s);new no("error").setMessage(s).setNetworkType(this.getModule(Is).getNetworkType()).setLevel("error").end(),this.getOuterEmitterInstance().emit(e.ERROR,t)}restartTimer(){Ie.l(this._n+".restartTimer"),this.stopTimer(),this._startTimer();const e=this.getModule(ds);e&&e.restartPolling()}getTimerID(){const e=this._moduleMap.get(Ds);return e.isWorkerEnabled()?e.getTimerID():this._checkTimer}getPollingTimerID(e){return this._moduleMap.get(ds).getPollingTimerID(e)}reset(){Ie.l(this._n+".reset"),pe();for(const[,e]of this._moduleMap)e.reset&&e.reset();this._startLoginTs=0,this._initReadyList(),this._isReady=!1,this.stopTimer(),this._outerEmitter.emit(e.SDK_NOT_READY);for(const[,e]of this._eventThrottleMap)e.timeoutID&&clearTimeout(e.timeoutID);this._eventThrottleMap.clear()}}class _n{constructor(e){this._funcMap=new Map,this._m=e,this._n="SafetyCallback",this._reportCount=0}defense(e,t,s){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,s),this._funcMap.get(e).set(t,o)),o}defenseOnce(e,t,s){return"function"!=typeof t?null:this._pack(e,t,s)}find(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):(this._m.outputWarning("ListenerFnNotFound",e),null)}delete(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)))}_pack(t,s,o){const i=this;return function(){try{s.apply(o,Array.from(arguments))}catch(n){const s=Object.values(e).indexOf(t),o="CallbackError";if(-1!==s){const t=Object.keys(e)[s];i._m.outputWarning(o,t,n)}if(i._reportCount<5){new no(o).setMessage("eventName:"+t).setMoreMessage(n.message).end(),i._reportCount+=1}}}}destroy(){this._funcMap.clear()}reset(){Ie.l(this._n+".reset"),this._reportCount=0}}class pn{constructor(e){const t={SDKAppID:e.SDKAppID,unlimitedAVChatRoom:e.unlimitedAVChatRoom||!1,scene:e.scene||"",oversea:e.oversea||!1,instanceID:nt(),devMode:e.devMode||!1,proxyServer:e.proxyServer||void 0,fileUploadProxy:e.fileUploadProxy||void 0,fileDownloadProxy:e.fileDownloadProxy||e.fileUploadProxy||void 0,modules:e.modules||void 0};this._m=new dn(t),this._vendorMap=new Map,this._safetyCallbackFactory=new _n(this._m)}onError(e){this._m.onError(e)}login(e){this._m.login();return this._getModule(rs).login(e)}logout(){return this._getModule(rs).logout().then(e=>(this._safetyCallbackFactory.reset(),this._m.reset(),e))}getLoginUser(){return this._getModule(rs).getLoginUser()}isReady(){return this._m.isReady()}isIntl(){return this._m.isIntl()}getNotReadyReason(){return this._m.getNotReadyReason()}getErrorMessage(e,t,s){return this._m.getErrorMessage(e,t,s)}_getModule(e){return this._m.getModule(e)}destroy(){return this.logout().finally(()=>{this._safetyCallbackFactory.destroy(),this._m.stopTimer();this._getModule(Ds).terminate();this._getModule(Ss).dealloc();const t=this._m.getOuterEmitterInstance(),s=this._getModule(gs);t.emit(e.SDK_DESTROY,{SDKAppID:s.getSDKAppID()})})}on(e,t,s){Ie.d("on","eventName:"+e);this._m.getOuterEmitterInstance().on(e,this._safetyCallbackFactory.defense(e,t,s),s)}once(e,t,s){Ie.d("once","eventName:"+e);this._m.getOuterEmitterInstance().once(e,this._safetyCallbackFactory.defenseOnce(e,t,s),s||this)}off(e,t,s,o){Ie.d("off","eventName:"+e);const i=this._safetyCallbackFactory.find(e,t);if(null!==i){this._m.getOuterEmitterInstance().off(e,i,s,o),this._safetyCallbackFactory.delete(e,t)}}registerPlugin(e){if(Pe(e["tim-offline-push-plugin"])){this._getModule(Ts).registerPlugin(e)}else{this._getModule(Os).registerPlugin(e)}}setLogLevel(e){if(e<=0){const e=this.getErrorMessage("TIM_ASCII_ART");e&&console.log(e);const t=this.getErrorMessage("API_REFER");if(t){const e="IM SDK API ->";Mt()?console.log(`%c ${e} %c`,"background:#ff9d00; padding:1px; border-radius:3px; color: #fff","background:transparent",t):console.log(e,t)}const s=this.getErrorMessage("DOCS_GUIDE");s&&console.log(s);const o=this.getErrorMessage("IOS_WEBVIEW_WARNING");ie&&o&&console.warn(o)}Ie.setLevel(e)}createTextMessage(e){return this._getModule(as).createTextMessage(e)}createTextAtMessage(e){return this._getModule(as).createTextMessage(e)}createImageMessage(e){return this._getModule(as).createImageMessage(e)}createAudioMessage(e){return this._getModule(as).createAudioMessage(e)}createVideoMessage(e){return this._getModule(as).createVideoMessage(e)}createCustomMessage(e){return this._getModule(as).createCustomMessage(e)}createFaceMessage(e){return this._getModule(as).createFaceMessage(e)}createFileMessage(e){return this._getModule(as).createFileMessage(e)}createLocationMessage(e){return this._getModule(as).createLocationMessage(e)}createMergerMessage(e){return this._getModule(as).createMergerMessage(e)}downloadMergerMessage(e){if(e.type!==t.MSG_MERGER)return Vs({code:$s.MSG_MERGER_TYPE_INVALID});if(St(e.payload.downloadKey))return Vs({code:$s.MSG_MERGER_KEY_INVALID});return this._getModule(as).downloadMergerMessage(e).catch(e=>Vs({code:$s.MSG_MERGER_DOWNLOAD_FAIL}))}createForwardMessage(e){return this._getModule(as).createForwardMessage(e)}sendMessage(e,t){if(!(e instanceof Eo))return Vs({code:$s.MSG_INSTANCE_REQUIRED});return this._getModule(as).sendMessageInstance(e,t)}searchCloudMessages(e){return this._getModule(as).searchCloudMessages(e)}callExperimentalAPI(e,t){if("sendComboMessage"===e){return this._getModule(Us).sendMessage(t)}if("handleGroupInvitation"===e){return this._getModule(ds).handleGroupInvitation(t)}if("isCommercialAbilityEnabled"===e){return this._getModule(As).isFeatureEnabled(t)}if("isIntl"===e)return this.isIntl();if("sendTRTCCustomData"===e){return this._getModule(Ls).sendTRTCCustomData(t)}if("sendRoomCustomData"===e){return this._getModule(Ls).sendTRTCCustomData(t)}if("getTimerID"===e)return this._m.getTimerID();if("getPollingTimerID"===e)return this._m.getPollingTimerID(t);if("setApplicationID"!==e){if("getServerConfig"===e){return this._getModule(ys).getServerConfig(t)}return Vs({code:$s.INVALID_OPERATION})}this._getModule(gs).setApplicationID(t);this._getModule(Es).updateProtocolConfig()}revokeMessage(e){return this._getModule(as).revokeMessage(e)}resendMessage(e,t){if(!(e instanceof Eo))return Vs({code:$s.MSG_INSTANCE_REQUIRED});return this._getModule(as).resendMessage(e,t)}deleteMessage(e){return this._getModule(as).deleteMessage(e)}translateText(e){return this._getModule(as).translateText(e)}convertVoiceToText(e){return this._getModule(as).convertVoiceToText(e)}setMessageExtensions(e,t){return this._getModule(cs).setMessageExtensions(e,t)}getMessageExtensions(e){return this._getModule(cs).getMessageExtensions(e)}deleteMessageExtensions(e,t){return this._getModule(cs).deleteMessageExtensions(e,t)}addMessageReaction(e,t){return this._getModule(ks).addMessageReaction(e,t)}removeMessageReaction(e,t){return this._getModule(ks).removeMessageReaction(e,t)}getMessageReactions(e){return this._getModule(ks).getMessageReactions(e)}getAllUserListOfMessageReaction(e){return this._getModule(ks).getAllUserListOfMessageReaction(e)}modifyMessage(e){return this._getModule(as).modifyRemoteMessage(e)}getMessageList(e){return this._getModule(hs).getMessageList(e)}getMessageListHopping(e){return this._getModule(hs).getMessageListHopping(e)}sendMessageReadReceipt(e){return this._getModule(hs).sendReadReceipt(e)}getMessageReadReceiptList(e){return this._getModule(hs).getReadReceiptList(e)}getGroupMessageReadMemberList(e){const t=this._getModule(ds);return t?t.getReadReceiptDetail(e):Vs({code:$s.CANNOT_FIND_MODULE})}findMessage(e){return this._getModule(hs).findMessage(e)}setMessageRead(e){return this._getModule(hs).setMessageRead(e)}getConversationList(e){return this._getModule(hs).getConversationList(e)}getConversationProfile(e){return this._getModule(hs).getConversationProfile(e)}deleteConversation(e){return this._getModule(hs).deleteConversation(e)}setConversationDraft(e){return this._getModule(hs).setConversationDraft(e)}clearHistoryMessage(e){return this._getModule(hs).clearHistoryMessage(e)}pinConversation(e){return this._getModule(hs).pinConversation(e)}setAllMessageRead(e){return this._getModule(hs).setAllMessageRead(e)}setMessageRemindType(e){return this._getModule(hs).setMessageRemindType(e)}getTotalUnreadMessageCount(){return this._getModule(hs).getTotalUnreadMessageCount()}setConversationCustomData(e){return this._getModule(hs).setConversationCustomData(e)}markConversation(e){return this._getModule(hs).markConversation(e)}getConversationGroupList(){return this._getModule(hs).getConversationGroupList()}createConversationGroup(e){return this._getModule(hs).createConversationGroup(e)}deleteConversationGroup(e){return this._getModule(hs).deleteConversationGroup(e)}renameConversationGroup(e){return this._getModule(hs).renameConversationGroup(e)}addConversationsToGroup(e){return this._getModule(hs).addConversationsToGroup(e)}deleteConversationsFromGroup(e){return this._getModule(hs).deleteConversationsFromGroup(e)}getMyProfile(){return this._getModule(us).getMyProfile()}getUserProfile(e){return this._getModule(us).getUserProfile(e)}updateMyProfile(e){return this._getModule(us).updateMyProfile(e)}getBlacklist(){return this._getModule(us).getLocalBlacklist()}addToBlacklist(e){return this._getModule(us).addBlacklist(e)}removeFromBlacklist(e){return this._getModule(us).deleteBlacklist(e)}setSelfStatus(e){return this._getModule(us).setSelfStatus(e)}getUserStatus(e){return this._getModule(us).getUserStatus(e)}subscribeUserStatus(e){return this._getModule(us).subscribeUserStatus(e)}unsubscribeUserStatus(e){return this._getModule(us).unsubscribeUserStatus(e)}getFriendList(){const e=this._getModule(_s);return e?e.getLocalFriendList():Vs({code:$s.CANNOT_FIND_MODULE})}addFriend(e){const t=this._getModule(_s);return t?t.addFriend(e):Vs({code:$s.CANNOT_FIND_MODULE})}deleteFriend(e){const t=this._getModule(_s);return t?t.deleteFriend(e):Vs({code:$s.CANNOT_FIND_MODULE})}checkFriend(e){const t=this._getModule(_s);return t?t.checkFriend(e):Vs({code:$s.CANNOT_FIND_MODULE})}getFriendProfile(e){const t=this._getModule(_s);return t?t.getFriendProfile(e):Vs({code:$s.CANNOT_FIND_MODULE})}updateFriend(e){const t=this._getModule(_s);return t?t.updateFriend(e):Vs({code:$s.CANNOT_FIND_MODULE})}getFriendApplicationList(){const e=this._getModule(_s);return e?e.getLocalFriendApplicationList():Vs({code:$s.CANNOT_FIND_MODULE})}acceptFriendApplication(e){const t=this._getModule(_s);return t?t.acceptFriendApplication(e):Vs({code:$s.CANNOT_FIND_MODULE})}refuseFriendApplication(e){const t=this._getModule(_s);return t?t.refuseFriendApplication(e):Vs({code:$s.CANNOT_FIND_MODULE})}deleteFriendApplication(e){const t=this._getModule(_s);return t?t.deleteFriendApplication(e):Vs({code:$s.CANNOT_FIND_MODULE})}setFriendApplicationRead(){const e=this._getModule(_s);return e?e.setFriendApplicationRead():Vs({code:$s.CANNOT_FIND_MODULE})}getFriendGroupList(){const e=this._getModule(_s);return e?e.getLocalFriendGroupList():Vs({code:$s.CANNOT_FIND_MODULE})}createFriendGroup(e){const t=this._getModule(_s);return t?t.createFriendGroup(e):Vs({code:$s.CANNOT_FIND_MODULE})}deleteFriendGroup(e){const t=this._getModule(_s);return t?t.deleteFriendGroup(e):Vs({code:$s.CANNOT_FIND_MODULE})}addToFriendGroup(e){const t=this._getModule(_s);return t?t.addToFriendGroup(e):Vs({code:$s.CANNOT_FIND_MODULE})}removeFromFriendGroup(e){const t=this._getModule(_s);return t?t.removeFromFriendGroup(e):Vs({code:$s.CANNOT_FIND_MODULE})}renameFriendGroup(e){const t=this._getModule(_s);return t?t.renameFriendGroup(e):Vs({code:$s.CANNOT_FIND_MODULE})}getGroupList(){const e=this._getModule(ds);return e?e.getGroupList():Vs({code:$s.CANNOT_FIND_MODULE})}getGroupProfile(e){const t=this._getModule(ds);return t?t.getGroupProfile(e):Vs({code:$s.CANNOT_FIND_MODULE})}createGroup(e){const t=this._getModule(ds);return t?t.createGroup(e):Vs({code:$s.CANNOT_FIND_MODULE})}dismissGroup(e){const t=this._getModule(ds);return t?t.dismissGroup(e):Vs({code:$s.CANNOT_FIND_MODULE})}updateGroupProfile(e){const t=this._getModule(ds);return t?t.updateGroupProfile(e):Vs({code:$s.CANNOT_FIND_MODULE})}joinGroup(e){const t=this._getModule(ds);return t?t.joinGroup(e):Vs({code:$s.CANNOT_FIND_MODULE})}quitGroup(e){const t=this._getModule(ds);return t?t.quitGroup(e):Vs({code:$s.CANNOT_FIND_MODULE})}searchGroupByID(e){const t=this._getModule(ds);return t?t.searchGroupByID(e):Vs({code:$s.CANNOT_FIND_MODULE})}getGroupOnlineMemberCount(e){const t=this._getModule(ds);return t?t.getGroupOnlineMemberCount(e):Vs({code:$s.CANNOT_FIND_MODULE})}changeGroupOwner(e){const t=this._getModule(ds);return t?t.changeGroupOwner(e):Vs({code:$s.CANNOT_FIND_MODULE})}getGroupApplicationList(){const e=this._getModule(ds);return e?e.getGroupApplicationList():Vs({code:$s.CANNOT_FIND_MODULE})}handleGroupApplication(e){const t=this._getModule(ds);return t?t.handleGroupApplication(e):Vs({code:$s.CANNOT_FIND_MODULE})}initGroupAttributes(e){const t=this._getModule(ds);return t?t.initGroupAttributes(e):Vs({code:$s.CANNOT_FIND_MODULE})}setGroupAttributes(e){const t=this._getModule(ds);return t?t.setGroupAttributes(e):Vs({code:$s.CANNOT_FIND_MODULE})}deleteGroupAttributes(e){const t=this._getModule(ds);return t?t.deleteGroupAttributes(e):Vs({code:$s.CANNOT_FIND_MODULE})}getGroupAttributes(e){const t=this._getModule(ds);return t?t.getGroupAttributes(e):Vs({code:$s.CANNOT_FIND_MODULE})}setGroupCounters(e){const t=this._getModule(ds);return t?t.setGroupCounters(e):Vs({code:$s.CANNOT_FIND_MODULE})}increaseGroupCounter(e){const t=this._getModule(ds);return t?t.increaseGroupCounter(e):Vs({code:$s.CANNOT_FIND_MODULE})}decreaseGroupCounter(e){const t=this._getModule(ds);return t?t.decreaseGroupCounter(e):Vs({code:$s.CANNOT_FIND_MODULE})}getGroupCounters(e){const t=this._getModule(ds);return t?t.getGroupCounters(e):Vs({code:$s.CANNOT_FIND_MODULE})}getGroupMemberList(e){const t=this._getModule(ds);return t?t.getGroupMemberList(e):Vs({code:$s.CANNOT_FIND_MODULE})}getGroupMemberProfile(e){const t=this._getModule(ds);return t?t.getGroupMemberProfile(e):Vs({code:$s.CANNOT_FIND_MODULE})}addGroupMember(e){const t=this._getModule(ds);return t?t.addGroupMember(e):Vs({code:$s.CANNOT_FIND_MODULE})}deleteGroupMember(e){const t=this._getModule(ds);return t?t.deleteGroupMember(e):Vs({code:$s.CANNOT_FIND_MODULE})}setGroupMemberMuteTime(e){const t=this._getModule(ds);return t?t.setGroupMemberMuteTime(e):Vs({code:$s.CANNOT_FIND_MODULE})}setGroupMemberRole(e){const t=this._getModule(ds);return t?t.setGroupMemberRole(e):Vs({code:$s.CANNOT_FIND_MODULE})}setGroupMemberNameCard(e){const t=this._getModule(ds);return t?t.setGroupMemberNameCard(e):Vs({code:$s.CANNOT_FIND_MODULE})}setGroupMemberCustomField(e){const t=this._getModule(ds);return t?t.setGroupMemberCustomField(e):Vs({code:$s.CANNOT_FIND_MODULE})}markGroupMemberList(e){const t=this._getModule(ds);return t?t.markGroupMemberList(e):Vs({code:$s.CANNOT_FIND_MODULE})}getJoinedCommunityList(){return this._getModule(ps).getJoinedCommunityList()}createTopicInCommunity(e){return this._getModule(ps).createTopicInCommunity(e)}deleteTopicFromCommunity(e){return this._getModule(ps).deleteTopicFromCommunity(e)}updateTopicProfile(e){return this._getModule(ps).updateTopicProfile(e)}getTopicList(e){return this._getModule(ps).getTopicList(e)}addSignalingListener(e,t,s){const o=this._getModule(Gs);o&&o.addSignalingListener(e,this._safetyCallbackFactory.defense(e,t,s),s)}removeSignalingListener(e,t,s){const o=this._safetyCallbackFactory.find(e,t);if(null!==o){const i=this._getModule(Gs);i&&(i.removeSignalingListener(e,o,s),this._safetyCallbackFactory.delete(e,t))}}invite(e){const t=this._getModule(Gs);return t?t.invite(e):Vs({code:$s.CANNOT_FIND_MODULE})}inviteSync(e,t,s){const o=this._getModule(Gs);return o?o.inviteSync(e,t,s):""}inviteInGroup(e){const t=this._getModule(Gs);return t?t.invite(e):Vs({code:$s.CANNOT_FIND_MODULE})}inviteInGroupSync(e,t,s){const o=this._getModule(Gs);return o?o.inviteSync(e,t,s):""}cancel(e){const t=this._getModule(Gs);return t?t.cancel(e):Vs({code:$s.CANNOT_FIND_MODULE})}accept(e){const t=this._getModule(Gs);return t?t.accept(e):Vs({code:$s.CANNOT_FIND_MODULE})}reject(e){const t=this._getModule(Gs);return t?t.reject(e):Vs({code:$s.CANNOT_FIND_MODULE})}getSignalingInfo(e){const t=this._getModule(Gs);return t?t.getSignalingInfo(e):null}modifyInvitation(e){const t=this._getModule(Gs);return t?t.modifyInvitation(e):Vs({code:$s.CANNOT_FIND_MODULE})}}const hn={login:1,logout:1,getLoginUser:1,destroy:1,on:1,off:1,ready:1,setLogLevel:1,joinGroup:1,quitGroup:1,registerPlugin:1,getGroupOnlineMemberCount:1,isReady:1,addSignalingListener:1,removeSignalingListener:1,callExperimentalAPI:1};function gn(e,t){if(e.isReady()||1===hn[t])return!0;const s=e.getNotReadyReason(),o={code:s,message:`${e.getErrorMessage(s)} | ${t} | ${e.getErrorMessage($s.SDK_IS_NOT_READY)}`};return e.onError(o),o}const mn={},Mn={};Mn.create=function(t){const o="TencentCloudChat.create";let i=0;const{SDKAppID:n}=t;if(Ae(n))i=n;else if(i=parseInt(n),isNaN(n))return Ie.e(o+" failed. Failed to parse the SDKAppID, please check the arguments"),null;if(i&&mn[i])return mn[i];Ie.l(""+o);const r=new pn({...t,SDKAppID:i});r.on(e.SDK_DESTROY,e=>{mn[e.data.SDKAppID]=null,delete mn[e.data.SDKAppID]});const a=function(e){const t=Object.create(null);return Object.keys(ns).forEach(o=>{if(!e[o])return;const i=new s;t[o]=function(){const t=Array.from(arguments);return i.use((function(t,s){const i=gn(e,o);return!0===i?s():Vs(i)})).use((function(e,t){if(!0===yt(e,is[o],o))return t()})).use((function(t,s){return e[o].apply(e,t)})),i.run(t)}}),t}(r);return mn[i]=a,is.hookGetAPITips(r.getErrorMessage.bind(r)),Ie.l(o+" ok"),a},Mn.TYPES=t,Mn.EVENT=e,Mn.TSignaling={NEW_INVITATION_RECEIVED:"newInvitationReceived",INVITEE_ACCEPTED:"ts_invitee_accepted",INVITEE_REJECTED:"ts_invitee_rejected",INVITATION_CANCELLED:"ts_invitation_cancelled",INVITATION_TIMEOUT:"ts_invitation_timeout",INVITATION_MODIFIED:"ts_invitation_modified",ACTION_TYPE_UNKNOWN:0,ACTION_TYPE_INVITE:1,ACTION_TYPE_CANCEL_INVITE:2,ACTION_TYPE_ACCEPT_INVITE:3,ACTION_TYPE_REJECT_INVITE:4,ACTION_TYPE_INVITE_TIMEOUT:5},Mn.VERSION="3.2.3",Ie.l("TencentCloudChat.VERSION:"+Mn.VERSION);export{Mn as default};