tim-wx-friendship.es.js 551 KB

1
  1. 'use strict';const e={SDK_READY:"sdkStateReady",SDK_NOT_READY:"sdkStateNotReady",SDK_DESTROY:"sdkDestroy",MESSAGE_RECEIVED:"onMessageReceived",MESSAGE_MODIFIED:"onMessageModified",MESSAGE_REVOKED:"onMessageRevoked",MESSAGE_READ_BY_PEER:"onMessageReadByPeer",MESSAGE_READ_RECEIPT_RECEIVED:"onMessageReadReceiptReceived",MESSAGE_EXTENSIONS_UPDATED:"onMessageExtensionsUpdated",MESSAGE_EXTENSIONS_DELETED:"onMessageExtensionsDeleted",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_SYSTEM_NOTICE_RECEIVED:"receiveGroupSystemNotice",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",SDK_RELOAD:"sdkReload"},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"}},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"},KOREA:{DEFAULT:"wss://wsskr.im.qcloud.com",BACKUP:"wss://wsskr.my-imcloud.com",STAT:"https://apikr.my-imcloud.com"},GERMANY:{DEFAULT:"wss://wssger.im.qcloud.com",BACKUP:"wss://wssger.my-imcloud.com",STAT:"https://apiger.my-imcloud.com"},IND:{DEFAULT:"wss://wssind.my-imcloud.com",BACKUP:"wss://wssind.im.qcloud.com",STAT:"https://apiind.my-imcloud.com"},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"}}},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,u="CHINA",c="OVERSEA",l="SINGAPORE",d="KOREA",p="GERMANY",h="IND",g="JPN",_="USA",m={HOST:{CURRENT:{DEFAULT:"wss://wss.im.qcloud.com",STAT:"https://events.im.qcloud.com"},setCurrent(e=u){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"},CMD:{LOGIN:"wslogin",LOGOUT_LONG_POLL:"longpollinglogout",LOGOUT:"wslogout",HELLO:"wshello",STAT_BACKGROUND:"ws_stat_background",STAT_FOREGROUND:"ws_stat_foreground",SET_TOKEN:"ws_stat_settoken",PORTRAIT_GET:"portrait_get_all",PORTRAIT_SET:"portrait_set",GET_LONG_POLL_ID:"getlongpollingid",LONG_POLL:"longpolling",AVCHATROOM_LONG_POLL:"get_msg",ADD_FRIEND:"friend_add",UPDATE_FRIEND:"friend_update",GET_FRIEND_LIST:"friend_get",GET_FRIEND_PROFILE:"friend_get_specified",DELETE_FRIEND:"friend_delete",CHECK_FRIEND:"friend_check",GET_FRIEND_GROUP_LIST:"group_get",RESPOND_FRIEND_APPLICATION:"friend_response",GET_FRIEND_APPLICATION_LIST:"pendency_get",DELETE_FRIEND_APPLICATION:"pendency_delete",REPORT_FRIEND_APPLICATION:"pendency_report",GET_GROUP_APPLICATION:"get_pendency",CREATE_FRIEND_GROUP:"group_add",DELETE_FRIEND_GROUP:"group_delete",UPDATE_FRIEND_GROUP:"group_update",GET_BLACKLIST:"black_list_get",ADD_BLACKLIST:"black_list_add",DELETE_BLACKLIST:"black_list_delete",CREATE_GROUP:"create_group",GET_JOINED_GROUPS:"get_joined_group_list",SET_GROUP_ATTRIBUTES:"set_group_attr",MODIFY_GROUP_ATTRIBUTES:"modify_group_attr",DELETE_GROUP_ATTRIBUTES:"delete_group_attr",CLEAR_GROUP_ATTRIBUTES:"clear_group_attr",GET_GROUP_ATTRIBUTES:"get_group_attr",SEND_MESSAGE:"sendmsg",REVOKE_C2C_MESSAGE:"msgwithdraw",DELETE_C2C_MESSAGE:"delete_c2c_msg_ramble",MODIFY_C2C_MESSAGE:"modify_c2c_msg",MODIFY_C2C_MESSAGE_EXTENSIONS:"set_key_values",GET_C2C_MESSAGE_EXTENSIONS:"get_key_values",SEND_GROUP_MESSAGE:"send_group_msg",REVOKE_GROUP_MESSAGE:"group_msg_recall",DELETE_GROUP_MESSAGE:"delete_group_ramble_msg_by_seq",MODIFY_GROUP_MESSAGE:"modify_group_msg",MODIFY_GROUP_MESSAGE_EXTENSIONS:"group_set_key_values",GET_GROUP_MESSAGE_EXTENSIONS:"group_get_key_values",GET_GROUP_INFO:"get_group_self_member_info",GET_GROUP_MEMBER_INFO:"get_specified_group_member_info",GET_GROUP_MEMBER_LIST:"get_group_member_info",GET_AVCHATROOM_MEMBER_LIST:"get_members",MARK_AVCHATROOM_MEMBER_INFO:"modify_user_info",QUIT_GROUP:"quit_group",CHANGE_GROUP_OWNER:"change_group_owner",DESTROY_GROUP:"destroy_group",ADD_GROUP_MEMBER:"add_group_member",DELETE_GROUP_MEMBER:"delete_group_member",BAN_AVCHATROOM_MEMBER:"ban_group_member",SEARCH_GROUP_BY_ID:"get_group_public_info",APPLY_JOIN_GROUP:"apply_join_group",HANDLE_APPLY_JOIN_GROUP:"handle_apply_join_group",HANDLE_INVITE_JOIN_GROUP:"handle_invite_join_permission_group",HANDLE_GROUP_INVITATION:"handle_invite_join_group",MODIFY_GROUP_INFO:"modify_group_base_info",MODIFY_GROUP_MEMBER_INFO:"modify_group_member_info",DELETE_GROUP_SYSTEM_MESSAGE:"deletemsg",DELETE_GROUP_AT_TIPS:"deletemsg",GET_GROUP_NOTIFY:"get_group_notify",GET_CONVERSATION_LIST:"get",PAGING_GET_CONVERSATION_LIST:"page_get",DELETE_CONVERSATION:"batch_delete",CLEAR_HISTORY_MESSAGE:"clear_msg",PIN_CONVERSATION:"top",SET_CONVERSATION_CUSTOM_DATA:"mark_contact",MARK_CONVERSATION:"mark_contact",CREATE_CONVERSATION_GROUP:"create_contact_group",DELETE_CONVERSATION_GROUP:"del_contact_group",UPDATE_CONVERSATION_GROUP:"update_contact_group",GET_CONVERSATION_GROUP_LIST:"get_contact_group",GET_MESSAGES:"getmsg",GET_C2C_ROAM_MESSAGES:"getroammsg",SET_C2C_PEER_MUTE_NOTIFICATIONS:"set_c2c_peer_mute_notifications",GET_C2C_PEER_MUTE_NOTIFICATIONS:"get_c2c_peer_mute_notifications",GET_GROUP_ROAM_MESSAGES:"group_msg_get",GET_READ_RECEIPT:"get_group_msg_receipt",GET_READ_RECEIPT_DETAIL:"get_group_msg_receipt_detail",SEND_READ_RECEIPT:"group_msg_receipt",SEND_C2C_READ_RECEIPT:"c2c_msg_read_receipt",SET_C2C_MESSAGE_READ:"msgreaded",GET_PEER_READ_TIME:"get_peer_read_time",SET_GROUP_MESSAGE_READ:"msg_read_report",FILE_READ_AND_WRITE_AUTHKEY:"authkey",FILE_UPLOAD:"pic_up",COS_SIGN:"cos",COS_PRE_SIG:"pre_sig",VIDEO_COVER:"video_cover",TIM_WEB_REPORT_V2:"tim_web_report_v2",BIG_DATA_HALLWAY_AUTH_KEY:"authkey",GET_ONLINE_MEMBER_NUM:"get_online_member_num",ALIVE:"alive",MESSAGE_PUSH:"msg_push",MULTI_MESSAGE_PUSH:"multi_msg_push_ws",MESSAGE_PUSH_ACK:"ws_msg_push_ack",STATUS_FORCE_OFFLINE:"stat_forceoffline",DOWNLOAD_MERGER_MESSAGE:"get_relay_json_msg",UPLOAD_MERGER_MESSAGE:"save_relay_json_msg",FETCH_CLOUD_CONTROL_CONFIG:"fetch_config",PUSHED_CLOUD_CONTROL_CONFIG:"push_configv2",FETCH_COMMERCIAL_CONFIG:"fetch_imsdk_purchase_bitsv2",PUSHED_COMMERCIAL_CONFIG:"push_imsdk_purchase_bitsv2",KICK_OTHER:"KickOther",OVERLOAD_NOTIFY:"notify2",SET_ALL_MESSAGE_READ:"read_all_unread_msg",CREATE_TOPIC:"create_topic",DELETE_TOPIC:"destroy_topic",UPDATE_TOPIC_PROFILE:"modify_topic",GET_TOPIC_LIST:"get_topic",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",GET_RPOFANITY_LIST:"get_local_words",TRANSLATE_TEXT:"ws_batch_trans_text",UPDATE_GROUP_COUNTER:"update_group_counter",GET_GROUP_COUNTER:"get_group_counter"},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"}},M={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()},f="c2c_text_message",I="c2c_custom_message",C="group_text_message",T="group_custom_message",y="user_profile",D="sns",E="group_profile",S="group_member_profile";m.HOST.setCurrent(u);const L="undefined"!=typeof wx&&"function"==typeof wx.getSystemInfoSync&&Boolean(wx.getSystemInfoSync().fontSizeSetting),A=L&&"function"==typeof wx.createGamePortal,v="undefined"!=typeof qq&&"function"==typeof qq.getSystemInfoSync&&Boolean(qq.getSystemInfoSync().fontSizeSetting),N="undefined"!=typeof tt&&"function"==typeof tt.getSystemInfoSync&&Boolean(tt.getSystemInfoSync().fontSizeSetting),R="undefined"!=typeof swan&&"function"==typeof swan.getSystemInfoSync&&Boolean(swan.getSystemInfoSync().fontSizeSetting),O="undefined"!=typeof my&&"function"==typeof my.getSystemInfoSync&&Boolean(my.getSystemInfoSync().fontSizeSetting),G="undefined"!=typeof jd&&"function"==typeof jd.getSystemInfoSync,U="undefined"!=typeof uni&&"undefined"==typeof window&&"function"==typeof uni.requireNativePlugin,k="undefined"!=typeof uni,P=L||v||N||R||O||U||G,b=("undefined"!=typeof uni||"undefined"!=typeof window)&&!P,w=v?qq:N?tt:R?swan:O?my:L?wx:U?uni:G?jd:{},F=b&&window&&window.navigator&&window.navigator.userAgent||"",$=/(micromessenger|webbrowser)/i.test(F),q=/AppleWebKit\/([\d.]+)/i.exec(F);q&&parseFloat(q.pop());const x=function(){let e="WEB";return $?e="WEB":v?e="QQ_MP":N?e="TT_MP":R?e="BAIDU_MP":O?e="ALI_MP":L?e="WX_MP":U&&(e="UNI_NATIVE_APP"),n[e]}(),V=/iPad/i.test(F),B=/iPhone/i.test(F)&&!V,H=/iPod/i.test(F),K=B||V||H,W=function(){const e=F.match(/OS (\d+)_/i);return e&&e[1]?e[1]:null}(),Y=/Android/i.test(F),j=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}();!function(){const e=F.match(/Chrome\/(\d+)/);e&&e[1]&&parseFloat(e[1])}();const z=/MSIE/.test(F)||F.indexOf("Trident")>-1&&F.indexOf("rv:11.0")>-1,J=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}();!function(){const e=F.match(/TBS\/(\d+)/i);if(e&&e[1])e[1]}();const X=/Windows/i.test(F),Z=/MAC OS X/i.test(F),Q=b&&"undefined"!=typeof Worker&&!z,ee=Y||K,te=b&&void 0!==window.tencent_cloud_im_csig_flutter_for_web_25F_cy;let se,oe;se="undefined"!=typeof console?console:"undefined"!=typeof global&&global.console?global.console:"undefined"!=typeof window&&window.console?window.console:{};const ie=function(){},ne=["assert","clear","count","debug","dir","dirxml","error","group","groupCollapsed","groupEnd","info","log","profile","profileEnd","table","time","timeEnd","timeStamp","trace","warn"];let re=ne.length;for(;re--;)oe=ne[re],console[oe]||(se[oe]=ie);var ae=se;let ue=0;const ce=function(){return(new Date).getTime()+ue},le=function(){ue=0},de=function(){return Math.floor(ce()/1e3)};let pe=0;function he(){return yt()?"%c TIM %c":"TIM"}function ge(){const e=function(){const e=new Date;return e.setTime(ce()),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 _e={arguments2String(e){let t="";if(1===e.length)t=e[0];else for(let s=0,o=e.length;s<o;s++)Fe(e[s])?qe(e[s])?t+=He(e[s]):t+=JSON.stringify(e[s]):t+=e[s],t+=" ";return t},_exec(e,t){yt()?ae[e](he(),"background:#0abf5b; padding:1px; border-radius:3px; color: #fff","background:transparent",ge(),t):ae[e](`${he()} ${ge()} ${t}`)},d:function(){if(pe<=-1){const e=this.arguments2String(arguments);this._exec("debug",e)}},l:function(){if(pe<=0){const e=this.arguments2String(arguments);this._exec("log",e)}},log:function(){if(pe<=0){const e=this.arguments2String(arguments);this._exec("log",e)}},i:function(){if(pe<=1){const e=this.arguments2String(arguments);this._exec("info",e)}},w:function(){if(pe<=2){const e=this.arguments2String(arguments);this._exec("warn",e)}},e:function(){if(pe<=3){const e=this.arguments2String(arguments);this._exec("error",e)}},setLevel:function(e){e<4&&this._exec("log","set level from "+pe+" to "+e),pe=e},getLevel:function(){return pe}},me={JPG:1,JPEG:1,GIF:2,PNG:3,BMP:4,UNKNOWN:255},Me={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"},fe="Tag_SNS_IM_Group",Ie="Tag_SNS_IM_Remark",Ce="Tag_SNS_IM_AddSource",Te="Tag_SNS_IM_AddWording",ye="Tag_SNS_IM_AddTime",De={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"},Le="JoinedSuccess",Ae="WaitAdminApproval",ve="@TGS#_",Ne="@TOPIC#_",Re=function(e){return"map"===xe(e)},Oe=function(e){return"file"===xe(e)},Ge=function(e){return null!==e&&("number"==typeof e&&!isNaN(e-0)||"object"==typeof e&&e.constructor===Number)},Ue=function(e){return"string"==typeof e},ke=function(e){return null!==e&&"object"==typeof e},Pe=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},be=function(e){return"function"==typeof Array.isArray?Array.isArray(e):"array"===xe(e)},we=function(e){return void 0===e},Fe=function(e){return be(e)||ke(e)},$e=function(e){return"function"==typeof e},qe=function(e){return e instanceof Error},xe=function(e){return Object.prototype.toString.call(e).match(/^\[object (.*)\]$/)[1].toLowerCase()},Ve=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 Be=function(e,t,s,o){if(!Fe(e)||!Fe(t))return 0;let i=0;const n=Object.keys(t);let r;for(let a=0,u=n.length;a<u;a++)if(r=n[a],!(we(t[r])||s&&s.includes(r)))if(Fe(e[r])&&Fe(t[r]))i+=Be(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},He=function(e){return JSON.stringify(e,["message","code"])},Ke=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},We=function(e){const t=e||99999999;return Math.round(Math.random()*t)},Ye="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",je=Ye.length,ze=function(e,t){for(const s in e)if(e[s]===t)return!0;return!1},Je={},Xe=function(e){return-1===e.indexOf("http://")||-1===e.indexOf("https://")?"https://"+e:e.replace(/https|http/,"https")},Ze=function(e){if(0===Object.getOwnPropertyNames(e).length)return Object.create(null);const t=Array.isArray(e)?[]:Object.create(null);let s="";for(const o in e)null!==e[o]?void 0!==e[o]?(s=typeof e[o],["string","number","function","boolean"].indexOf(s)>=0?t[o]=e[o]:t[o]=Ze(e[o])):t[o]=void 0:t[o]=null;return t};function Qe(e,t){if(!be(e)||!be(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 et=e=>e===t.GRP_AVCHATROOM,st=({type:e,groupID:s})=>e===t.GRP_COMMUNITY||(""+s).startsWith(ve)&&!(""+s).includes(Ne),ot=e=>(""+e).startsWith(ve)&&(""+e).includes(Ne),it=e=>Ue(e)&&e.slice(0,3)===t.CONV_C2C,nt=e=>Ue(e)&&e.slice(0,5)===t.CONV_GROUP,rt=e=>Ue(e)&&e===t.CONV_SYSTEM;function at(e,t){const s={};return Object.keys(e).forEach(o=>{s[o]=t(e[o],o)}),s}function ut(e){return P?new Promise((t,s)=>{w.getImageInfo({src:e,success(e){t({width:e.width,height:e.height})},fail(){t({width:0,height:0})}})}):z&&9===J?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 ct(){function e(){return(65536*(1+Math.random())|0).toString(16).substring(1)}return`${e()+e()}${e()}${e()}${e()}${e()}${e()}${e()}`}function lt(){let e="unknown";if(Z&&(e="mac"),X&&(e="windows"),K&&(e="ios"),Y&&(e="android"),P)try{const t=w.getSystemInfoSync().platform;void 0!==t&&(e=t)}catch(t){}return e}function dt(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 pt(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(we(t)){const{url:e,...t}=a;return t}return a}function ht(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 gt(e){const{servcmd:t}=e;return t.slice(t.indexOf(".")+1)}function _t(e,t){return Math.round(Number(e)*Math.pow(10,t))/Math.pow(10,t)}function mt(e,t){return e.includes(t)}function Mt(e,t){return e.includes(t)}function ft(e){return e.split(Ne)[0]}const It=function(e,s,o){if(we(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 Ct(e){return e===t.MSG_TEXT||e===t.MSG_CUSTOM||e===t.MSG_LOCATION||e===t.MSG_FACE}function Tt(e){const t=[];if(!Ue(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 yt(){return!z&&!P}function Dt(e){return"the length of userIDList cannot exceed "+e}function Et(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}const St=Object.prototype.hasOwnProperty;function Lt(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(Pe(e)){for(const t in e)if(St.call(e,t))return!1;return!0}return!(!Re(e)&&(t=e,"set"!==xe(t))&&!Oe(e))&&0===e.size;var t}function At(e,t,s){if(void 0===t)return!0;let o=!0;if(Pe(t))Object.keys(t).forEach(i=>{const n=1===e.length?e[0][i]:void 0;o=!!vt(n,t[i],s,i)&&o});else if(be(t))for(let i=0;i<t.length;i++)o=!!vt(e[i],t[i],s,t[i].name)&&o;if(o)return o;throw new Error("Params validate failed.")}function vt(e,t,s,o){if(void 0===t)return!0;let i=!0;if(t.required&&Lt(e)&&(_e.e(`[${s}] Missing required params: "${o}".`),i=!1),!Lt(e)){const n=xe(e),r=t.type.toLowerCase();n!==r&&("asyncfunction"===n&&"function"===r||(_e.e(`[${s}] Invalid params: type check failed for "${o}".Expected ${t.type}.`),i=!1))}return t.validator&&!t.validator(e)&&(_e.e(`[${s}] Invalid params: custom validator check failed for params.`),i=!1),i}const Nt={UNSEND:"unSend",SUCCESS:"success",FAIL:"fail"},Rt={NOT_START:"notStart",PENDING:"pending",RESOLVED:"resolved",REJECTED:"rejected"},Ot=function(e){if(!e)return!1;if(it(e)||nt(e)||rt(e))return!0;const t=os("InvalidConversationID",e);return t&&_e.w(t),!1},Gt=function(e){""!==e.desc&&""!==os("API_REFER")&&_e.w(`[${e.api}] | ${e.param} | ${e.desc}, ${os("API_REFER")}${e.api}`)},Ut=function(){return os("StringRequiredLog")},kt=function(e){return os("NonEmptyStringRequiredLog",e)},Pt=function(){return os("NumberRequiredLog")},bt=function(){return os("UndefinedNotAllowedLog")},wt=function(){return os("FileRequiredLog")},Ft=function(){return os("FunctionRequiredLog")},$t=function(){return os("ArrayRequiredLog")},qt=function(){return os("NonEmptyArrayLog")},xt=function(){return os("CallbackMissingLog")},Vt=function(){return os("PositiveIntegerRequiredLog")},Bt=function(e,t){return os("StringNotLongerThanLog",e,t)},Ht=function(e,t){return os("NumberLessThanLog",e,t)},Kt=function(e){return os("KeyValueStringRequiredLog",e)},Wt=function(){return os("PlainObjectRequiredLog")},Yt=function(){return os("NonEmptyContentRequiredLog")},jt=function(){return os("FileNotSelectedLog")},zt=function(){return os("MessageInstanceRequiredLog")},Jt=function(){return os("NonAnonymousFunctionLog")},Xt=function(){return os("MessageExtensionNotAvailableLog")},Zt={type:"String",required:!0},Qt={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:Zt,userSig:Zt},addToBlacklist:{userIDList:Qt},removeFromBlacklist:{userIDList:Qt},on:[{name:"eventName",type:"String",validator:e=>"string"==typeof e&&0!==e.length||(Gt({api:"on",param:"eventName",desc:kt("eventName")}),!1)},{name:"handler",type:"Function",validator:e=>"function"!=typeof e?(Gt({api:"on",param:"handler",desc:Ft()}),!1):(""===e.name&&Gt({api:"on",param:"handler",desc:Jt()}),!0)}],once:[{name:"eventName",type:"String",validator:e=>"string"==typeof e&&0!==e.length||(Gt({api:"once",param:"eventName",desc:kt("eventName")}),!1)},{name:"handler",type:"Function",validator:e=>"function"!=typeof e?(Gt({api:"once",param:"handler",desc:Ft()}),!1):(""===e.name&&Gt({api:"once",param:"handler",desc:Jt()}),!0)}],off:[{name:"eventName",type:"String",validator:e=>"string"==typeof e&&0!==e.length||(Gt({api:"off",param:"eventName",desc:kt("eventName")}),!1)},{name:"handler",type:"Function",validator:e=>"function"!=typeof e?(Gt({api:"off",param:"handler",desc:Ft()}),!1):(""===e.name&&Gt({api:"off",param:"handler",desc:Jt()}),!0)}],sendMessage:[{name:"message",...es}],setMessageExtensions:[{name:"message",...es,validator:e=>e.status===Nt.SUCCESS&&!0===e.isSupportExtension||(Gt({api:"setMessageExtensions",param:"message",desc:Xt()}),!1)},{name:"extensions",...Qt}],getMessageExtensions:[{name:"message",...es,validator:e=>e.status===Nt.SUCCESS&&!0===e.isSupportExtension||(Gt({api:"getMessageExtensions",param:"message",desc:Xt()}),!1)}],deleteMessageExtensions:[{name:"message",...es,validator:e=>e.status===Nt.SUCCESS&&!0===e.isSupportExtension||(Gt({api:"deleteMessageExtensions",param:"message",desc:Xt()}),!1)}],getMessageList:{conversationID:{...Zt,validator:e=>Ot(e)},nextReqMessageID:{type:"String"},count:{type:"Number",validator:e=>!(!we(e)&&!/^[1-9][0-9]*$/.test(e))||(Gt({api:"getMessageList",param:"count",desc:Vt()}),!1)}},getMessageListHopping:{conversationID:{...Zt,validator:e=>Ot(e)},sequence:{type:"Number"},time:{type:"Number"},direction:{type:"Number",validator:e=>!(!we(e)&&0!==e&&1!==e)||(Gt({api:"getMessageListHopping",param:"direction",desc:os("0Or1RequiredLog")}),!1)},count:{type:"Number",validator:e=>!(!we(e)&&!/^[1-9][0-9]*$/.test(e))||(Gt({api:"getMessageListHopping",param:"count",desc:Vt}),!1)}},setMessageRead:{conversationID:{...Zt,validator:e=>Ot(e)}},setAllMessageRead:{scope:{type:"String",required:!1,validator:e=>!e||-1!==[t.READ_ALL_C2C_MSG,t.READ_ALL_GROUP_MSG,t.READ_ALL_MSG].indexOf(e)||(Gt({api:"setAllMessageRead",param:"scope",desc:"TIM.TYPES.READ_ALL_C2C_MSG or TIM.TYPES.READ_ALL_GROUP_MSG or TIM.TYPES.READ_ALL_MSG required"}),!1)}},getConversationProfile:[{name:"conversationID",...Zt,validator:e=>Ot(e)}],clearHistoryMessage:[{name:"conversationID",...Zt,validator:e=>Ot(e)}],pinConversation:{conversationID:{...Zt,validator:e=>Ot(e)},isPinned:{...ts}},setConversationCustomData:{conversationIDList:{...Qt},customData:{type:"String",validator:e=>Ue(e)?!(e.length>256)||(Gt({api:"setConversationCustomData",param:"customData",desc:Bt("customData",256)}),!1):(Gt({api:"setConversationCustomData",param:"customData",desc:Ut()}),!1)}},markConversation:{conversationIDList:{...Qt},markType:{type:"number",validator:e=>{return Ge(e)?e<=0?(Gt({api:"markConversation",param:"markType",desc:(t="markType",s=0,os("NumberGreaterThanLog",t,s))}),!1):!(e>=Math.pow(2,64))||(Gt({api:"markConversation",param:"markType",desc:Ht("markType","Math.pow(2,64)")}),!1):(Gt({api:"markConversation",param:"markType",desc:Pt()}),!1);var t,s}},enableMark:{...ts}},createConversationGroup:{conversationIDList:{...Qt},groupName:{...Zt,validator:e=>!!e&&(!(e.length>32)||(Gt({api:"createConversationGroup",param:"groupName",desc:Bt("groupName",32)}),!1))}},deleteConversationGroup:[{name:"groupName",...Zt}],renameConversationGroup:{oldName:{...Zt},newName:{...Zt,validator:e=>!!e&&(!(e.length>32)||(Gt({api:"renameConversationGroup",param:"newName",desc:Bt("newName",32)}),!1))}},addConversationsToGroup:{conversationIDList:{...Qt},groupName:{...Zt}},deleteConversationsFromGroup:{conversationIDList:{...Qt},groupName:{...Zt}},getGroupList:{groupProfileFilter:{type:"Array"}},getGroupProfile:{groupID:Zt,groupCustomFieldFilter:{type:"Array"},memberCustomFieldFilter:{type:"Array"}},getGroupProfileAdvance:{groupIDList:Qt},createGroup:{name:Zt},joinGroup:{groupID:Zt,type:{type:"String"},applyMessage:{type:"String"}},quitGroup:[{name:"groupID",...Zt}],handleApplication:{message:es,handleAction:Zt,handleMessage:{type:"String"}},changeGroupOwner:{groupID:Zt,newOwnerID:Zt},updateGroupProfile:{groupID:Zt,muteAllMembers:{type:"Boolean"}},dismissGroup:[{name:"groupID",...Zt}],searchGroupByID:[{name:"groupID",...Zt}],initGroupAttributes:{groupID:Zt,groupAttributes:{...es,validator:e=>{let t=!0;return Object.keys(e).forEach(s=>{if(!Ue(e[s]))return Gt({api:"initGroupAttributes",param:"groupAttributes",desc:Kt("value")}),t=!1,t}),t}}},setGroupAttributes:{groupID:Zt,groupAttributes:{...es,validator:e=>{let t=!0;return Object.keys(e).forEach(s=>{if(!Ue(e[s]))return Gt({api:"setGroupAttributes",param:"groupAttributes",desc:Kt("value")}),t=!1,t}),t}}},deleteGroupAttributes:{groupID:Zt,keyList:{type:"Array",validator:e=>{if(we(e)||!be(e))return Gt({api:"deleteGroupAttributes",param:"keyList",desc:$t()}),!1;if(!Lt(e)){let t=!0;return e.forEach(e=>{if(!Ue(e))return Gt({api:"deleteGroupAttributes",param:"keyList",desc:os("StringArrayRequiredLog")}),t=!1,t}),t}return!0}}},getGroupAttributes:{groupID:Zt,keyList:{type:"Array",validator:e=>{if(we(e)||!be(e))return Gt({api:"getGroupAttributes",param:"keyList",desc:$t()}),!1;if(!Lt(e)){let t=!0;return e.forEach(e=>{if(!Ue(e))return Gt({api:"getGroupAttributes",param:"keyList",desc:Kt("key")}),t=!1,t}),t}return!0}}},setGroupCounters:{groupID:Zt,counters:es},increaseGroupCounter:{groupID:Zt,key:Zt,value:ss},decreaseGroupCounter:{groupID:Zt,key:Zt,value:ss},getGroupCounters:{groupID:Zt},getGroupMemberList:{groupID:Zt,count:{type:"Number"}},getGroupMemberProfile:{groupID:Zt,userIDList:Qt,memberCustomFieldFilter:{type:"Array"}},addGroupMember:{groupID:Zt,userIDList:Qt},setGroupMemberRole:{groupID:Zt,userID:Zt,role:Zt},setGroupMemberMuteTime:{groupID:Zt,userID:Zt,muteTime:{type:"Number",validator:e=>e>=0}},setGroupMemberNameCard:{groupID:Zt,userID:{type:"String"},nameCard:{type:"String",validator:e=>Ue(e)?(e.length,!0):(Gt({api:"setGroupMemberNameCard",param:"nameCard",desc:Ut()}),!1)}},setGroupMemberCustomField:{groupID:Zt,userID:{type:"String"},memberCustomField:Qt},deleteGroupMember:{groupID:Zt},markGroupMemberList:{groupID:Zt,markType:{type:"number",validator:e=>{return Ge(e)?!(e<1e3)||(Gt({api:"markGroupMemberList",param:"markType",desc:(t="markType",s=1e3,os("NumberGreaterOrEqualLog",t,s))}),!1):(Gt({api:"markGroupMemberList",param:"markType",desc:Pt()}),!1);var t,s}},userIDList:{...Qt},enableMark:{...ts}},createTextMessage:{to:Zt,conversationType:Zt,payload:{...es,validator:e=>Pe(e)?Ue(e.text)?0!==e.text.length||(Gt({api:"createTextMessage",param:"payload.text",desc:Yt()}),!1):(Gt({api:"createTextMessage",param:"payload.text",desc:Ut()}),!1):(Gt({api:"createTextMessage",param:"payload",desc:Wt()}),!1)}},createTextAtMessage:{to:Zt,conversationType:Zt,payload:{...es,validator:e=>Pe(e)?Ue(e.text)?0===e.text.length?(Gt({api:"createTextAtMessage",param:"payload.text",desc:Yt()}),!1):!(e.atUserList&&!be(e.atUserList))||(Gt({api:"createTextAtMessage",param:"payload.atUserList",desc:$t()}),!1):(Gt({api:"createTextAtMessage",param:"payload.text",desc:Ut()}),!1):(Gt({api:"createTextAtMessage",param:"payload",desc:Wt()}),!1)}},createCustomMessage:{to:Zt,conversationType:Zt,payload:{...es,validator:e=>Pe(e)?e.data&&!Ue(e.data)?(Gt({api:"createCustomMessage",param:"payload.data",desc:Ut()}),!1):e.description&&!Ue(e.description)?(Gt({api:"createCustomMessage",param:"payload.description",desc:Ut()}),!1):!(e.extension&&!Ue(e.extension))||(Gt({api:"createCustomMessage",param:"payload.extension",desc:Ut()}),!1):(Gt({api:"createCustomMessage",param:"payload",desc:Wt()}),!1)}},createImageMessage:{to:Zt,conversationType:Zt,payload:{...es,validator:e=>{if(!Pe(e))return Gt({api:"createImageMessage",param:"payload",desc:Wt()}),!1;if(we(e.file))return Gt({api:"createImageMessage",param:"payload.file",desc:bt()}),!1;if(b){if(!(e.file instanceof HTMLInputElement||Oe(e.file)))return Pe(e.file)&&"undefined"!=typeof uni?0!==e.file.tempFilePaths.length&&0!==e.file.tempFiles.length||(Gt({api:"createImageMessage",param:"payload.file",desc:jt()}),!1):(Gt({api:"createImageMessage",param:"payload.file",desc:wt()}),!1);if(e.file instanceof HTMLInputElement&&0===e.file.files.length)return Gt({api:"createImageMessage",param:"payload.file",desc:jt()}),!1}return!0},onProgress:{type:"Function",required:!1,validator:e=>(we(e)&&Gt({api:"createImageMessage",param:"onProgress",desc:xt()}),!0)}}},createAudioMessage:{to:Zt,conversationType:Zt,payload:{...es,validator:e=>!!Pe(e)||(Gt({api:"createAudioMessage",param:"payload",desc:Wt()}),!1)},onProgress:{type:"Function",required:!1,validator:e=>(we(e)&&Gt({api:"createAudioMessage",param:"onProgress",desc:xt()}),!0)}},createVideoMessage:{to:Zt,conversationType:Zt,payload:{...es,validator:e=>{if(!Pe(e))return Gt({api:"createVideoMessage",param:"payload",desc:Wt()}),!1;if(we(e.file))return Gt({api:"createVideoMessage",param:"payload.file",desc:bt()}),!1;if(b){if(!(e.file instanceof HTMLInputElement||Oe(e.file)))return Pe(e.file)&&"undefined"!=typeof uni?!!Oe(e.file.tempFile)||(Gt({api:"createVideoMessage",param:"payload.file",desc:jt()}),!1):(Gt({api:"createVideoMessage",param:"payload.file",desc:wt()}),!1);if(e.file instanceof HTMLInputElement&&0===e.file.files.length)return Gt({api:"createVideoMessage",param:"payload.file",desc:jt()}),!1}return!0}},onProgress:{type:"Function",required:!1,validator:e=>(we(e)&&Gt({api:"createVideoMessage",param:"onProgress",desc:xt()}),!0)}},createFaceMessage:{to:Zt,conversationType:Zt,payload:{...es,validator:e=>Pe(e)?Ge(e.index)?!!Ue(e.data)||(Gt({api:"createFaceMessage",param:"payload.data",desc:Ut()}),!1):(Gt({api:"createFaceMessage",param:"payload.index",desc:Pt()}),!1):(Gt({api:"createFaceMessage",param:"payload",desc:Wt()}),!1)}},createFileMessage:{to:Zt,conversationType:Zt,payload:{...es,validator:e=>{if(!Pe(e))return Gt({api:"createFileMessage",param:"payload",desc:Wt()}),!1;if(we(e.file))return Gt({api:"createFileMessage",param:"payload.file",desc:bt()}),!1;if(b){if(!(e.file instanceof HTMLInputElement||Oe(e.file)))return Pe(e.file)&&"undefined"!=typeof uni?0!==e.file.tempFilePaths.length&&0!==e.file.tempFiles.length||(Gt({api:"createFileMessage",param:"payload.file",desc:jt()}),!1):(Gt({api:"createFileMessage",param:"payload.file",desc:wt()}),!1);if(e.file instanceof HTMLInputElement&&0===e.file.files.length)return Gt({api:"createFileMessage",param:"payload.file",desc:jt()}),!1}return!0}},onProgress:{type:"Function",required:!1,validator:e=>(we(e)&&Gt({api:"createFileMessage",param:"onProgress",desc:xt()}),!0)}},createLocationMessage:{to:Zt,conversationType:Zt,payload:{...es,validator:e=>Pe(e)?Ue(e.description)?Ge(e.longitude)?!!Ge(e.latitude)||(Gt({api:"createLocationMessage",param:"payload.latitude",desc:Pt()}),!1):(Gt({api:"createLocationMessage",param:"payload.longitude",desc:Pt()}),!1):(Gt({api:"createLocationMessage",param:"payload.description",desc:Ut()}),!1):(Gt({api:"createLocationMessage",param:"payload",desc:Wt()}),!1)}},createMergerMessage:{to:Zt,conversationType:Zt,payload:{...es,validator:e=>{if(Lt(e.messageList))return Gt({api:"createMergerMessage",param:"payload.messageList",desc:qt()}),!1;if(Lt(e.compatibleText))return Gt({api:"createMergerMessage",param:"payload.compatibleText",desc:kt("compatibleText")}),!1;let t=!1;return e.messageList.forEach(e=>{e.status===Nt.FAIL&&(t=!0)}),!t||(Gt({api:"createMergerMessage",param:"payload.messageList",desc:os("MergeFailedMessageLog")}),!1)}}},revokeMessage:[{name:"message",...es,validator:e=>Lt(e)?(Gt({api:"revokeMessage",param:"message",desc:zt()}),!1):e.conversationType===t.CONV_SYSTEM?(Gt({api:"revokeMessage",param:"message",desc:os("MessageCanBeRevokedDesc")}),!1):!0!==e.isRevoked||(Gt({api:"revokeMessage",param:"message",desc:os("MessageRevokedLog")}),!1)}],deleteMessage:[{name:"messageList",...Qt,validator:e=>!Lt(e)||(Gt({api:"deleteMessage",param:"messageList",desc:qt()}),!1)}],translateText:{sourceTextList:Qt,sourceLanguage:Zt,targetLanguage:Zt},modifyMessage:[{name:"message",...es,validator:e=>Lt(e)?(Gt({api:"modifyMessage",param:"message",desc:zt()}),!1):e.conversationType===t.CONV_SYSTEM?(Gt({api:"modifyMessage",param:"message",desc:os("MessageCanBeModifiedLog")}),!1):!0!==e._onlineOnlyFlag||(Gt({api:"modifyMessage",param:"message",desc:os("OnlineMessageNotSupportLog")}),!1)}],getUserProfile:{userIDList:{type:"Array",validator:e=>be(e)?(0===e.length&&Gt({api:"getUserProfile",param:"userIDList",desc:qt()}),!0):(Gt({api:"getUserProfile",param:"userIDList",desc:$t()}),!1)}},updateMyProfile:{profileCustomField:{type:"Array",validator:e=>!!we(e)||(!!be(e)||(Gt({api:"updateMyProfile",param:"profileCustomField",desc:$t()}),!1))}},setSelfStatus:{customStatus:{type:"String",validator:e=>!!Ue(e)||(Gt({api:"setSelfStatus",param:"customStatus",desc:Ut()}),!1)}},getUserStatus:{userIDList:{type:"Array",validator:e=>be(e)?0!==e.length||(Gt({api:"getUserStatus",param:"userIDList",desc:qt()}),!1):(Gt({api:"getUserStatus",param:"userIDList",desc:$t()}),!1)}},subscribeUserStatus:{userIDList:{type:"Array",validator:e=>be(e)?0!==e.length||(Gt({api:"subscribeUserStatus",param:"userIDList",desc:qt()}),!1):(Gt({api:"subscribeUserStatus",param:"userIDList",desc:$t()}),!1)}},unsubscribeUserStatus:{userIDList:{type:"Array",validator:e=>!e||(!!be(e)||(Gt({api:"subscribeUserStatus",param:"userIDList",desc:$t()}),!1))}},addFriend:{to:Zt,source:{type:"String",required:!0,validator:e=>{if(!e)return!1;if(!e.startsWith("AddSource_Type_"))return Gt({api:"addFriend",param:"source",desc:os("SourcePrefixLog")}),!1;return!(e.replace("AddSource_Type_","").length>8)||(Gt({api:"addFriend",param:"source",desc:Bt("keyword",8)}),!1)}},remark:{type:"String",required:!1,validator:e=>!(Ue(e)&&e.length>96)||(Gt({api:"addFriend",param:"remark",desc:Bt("remark",96)}),!1)}},deleteFriend:{userIDList:Qt},checkFriend:{userIDList:Qt},getFriendProfile:{userIDList:Qt},updateFriend:{userID:Zt,remark:{type:"String",required:!1,validator:e=>!(Ue(e)&&e.length>96)||(Gt({api:"updateFriend",param:"remark",desc:Bt("remark",96)}),!1)},friendCustomField:{type:"Array",required:!1,validator:e=>{if(e){if(!be(e))return Gt({api:"updateFriend",param:"friendCustomField",desc:$t()}),!1;let t=!0;return e.forEach(e=>{if(!Ue(e.key)||-1===e.key.indexOf("Tag_SNS_Custom"))return Gt({api:"updateFriend",param:"friendCustomField",desc:os("FriendCustomFieldPrefixLog")}),t=!1,t;if(!Ue(e.value))return Gt({api:"updateFriend",param:"friendCustomField",desc:Kt("value")}),t=!1,t;return e.key.replace("Tag_SNS_Custom_","").length>8?(Gt({api:"updateFriend",param:"friendCustomField",desc:Bt("keyword",8)}),t=!1,t):void 0}),t}return!0}}},acceptFriendApplication:{userID:Zt},refuseFriendApplication:{userID:Zt},deleteFriendApplication:{userID:Zt},createFriendGroup:{name:Zt},deleteFriendGroup:{name:Zt},addToFriendGroup:{name:Zt,userIDList:Qt},removeFromFriendGroup:{name:Zt,userIDList:Qt},renameFriendGroup:{oldName:Zt,newName:Zt},sendMessageReadReceipt:[{name:"messageList",type:"Array",validator:e=>be(e)?0!==e.length||(Gt({api:"sendMessageReadReceipt",param:"messageList",desc:qt()}),!1):(Gt({api:"sendMessageReadReceipt",param:"messageList",desc:$t()}),!1)}],getMessageReadReceiptList:[{name:"messageList",type:"Array",validator:e=>be(e)?0!==e.length||(Gt({api:"getMessageReadReceiptList",param:"messageList",desc:qt()}),!1):(Gt({api:"getMessageReadReceiptList",param:"messageList",desc:$t()}),!1)}],createTopicInCommunity:{groupID:Zt,topicName:Zt},deleteTopicFromCommunity:{groupID:Zt,topicIDList:{type:"Array",validator:e=>!e||(!!be(e)||(Gt({api:"deleteTopicFromCommunity",param:"topicIDList",desc:$t()}),!1))}},updateTopicProfile:{groupID:Zt,topicID:Zt},getTopicList:{groupID:Zt,topicIDList:{type:"Array",validator:e=>!e||(!!be(e)||(Gt({api:"getTopicList",param:"topicIDList",desc:$t()}),!1))}}},ns={login:1,logout:1,on:1,once:1,off:1,setLogLevel:1,registerPlugin:1,destroy: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,modifyMessage:1,sendMessageReadReceipt:1,getGroupMessageReadMemberList:1,getMessageReadReceiptList:1,setMessageExtensions:1,getMessageExtensions:1,deleteMessageExtensions:1,getMessageList:1,findMessage:1,getMessageListHopping:1,setMessageRead:1,setAllMessageRead:1,getConversationList:1,getConversationProfile:1,deleteConversation: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},rs=1,as=2,us=3,cs=4,ls=6,ds=7,ps=8,hs=9,gs=10,_s=11,ms=12,Ms=13,fs=14,Is=15,Cs=16,Ts=17,ys=18,Ds=19,Es=20,Ss=21,Ls=22,As=23,vs=24,Ns=25,Rs=26,Os=27,Gs=28,Us=29,ks=30,Ps=31,bs=32,ws=37;class Fs{constructor(e){this._m=e,this._n=""}isLoggedIn(){return this._m.getModule(ms).isLoggedIn()}isOversea(){return this._m.getModule(ms).isOversea()}isPrivateNetWork(){return this._m.getModule(ms).isPrivateNetWork()}getFileDownloadProxy(){return this._m.getModule(ms).getFileDownloadProxy()}getMyUserID(){return this._m.getModule(ms).getUserID()}getMyTinyID(){return this._m.getModule(ms).getTinyID()}getSDKAppID(){return this._m.getModule(ms).getSDKAppID()}isIntl(){return this._m.getModule(ms).isIntl()}isDevMode(){return this._m.getModule(ms).isDevMode()}getModule(e){return this._m.getModule(e)}getPlatform(){return x}getNetworkType(){return this._m.getModule(Is).getNetworkType()}probeNetwork(e){return this._m.getModule(Is).probe(e)}getCloudConfig(e){return this._m.getModule(As).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(ms).getTinyID()+"-"+e.random}filterModifiedMessage(t){if(Lt(t))return;const s=t.filter(e=>!0===e.isModified);s.length>0&&this.emitOuterEvent(e.MESSAGE_MODIFIED,s)}filterUnmodifiedMessage(e){if(Lt(e))return[];return e.filter(e=>!1===e.isModified)}request(e){return this._m.getModule(Es).request(e)}canIUse(e){return this._m.getModule(Os).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&&_e.w(o)}}const $s="wslogin",qs="wslogout",xs="wshello",Vs="KickOther",Bs="getmsg",Hs="authkey",Ks="sendmsg",Ws="send_group_msg",Ys="portrait_get_all",js="portrait_set",zs="black_list_get",Js="black_list_add",Xs="black_list_delete",Zs="friend_get",Qs="friend_get_specified",eo="friend_check",to="friend_delete",so="friend_add",oo="friend_update",io="friend_response",no="pendency_get",ro="pendency_delete",ao="pendency_report",uo="group_get",co="group_add",lo="group_delete",po="group_update",ho="msgwithdraw",go="msgreaded",_o="set_c2c_peer_mute_notifications",mo="get_c2c_peer_mute_notifications",Mo="getroammsg",fo="get_peer_read_time",Io="delete_c2c_msg_ramble",Co="modify_c2c_msg",To="set_key_values",yo="get_key_values",Do="page_get",Eo="get",So="batch_delete",Lo="clear_msg",Ao="top",vo="deletemsg",No="set_conv_custom_data",Ro="mark_contact",Oo="create_contact_group",Go="del_contact_group",Uo="update_contact_group",ko="add_conv_to_group",Po="del_conv_from_group",bo="get_contact_group",wo="get_joined_group_list",Fo="get_group_self_member_info",$o="create_group",qo="destroy_group",xo="modify_group_base_info",Vo="apply_join_group",Bo="apply_join_group_noauth",Ho="quit_group",Ko="get_group_public_info",Wo="change_group_owner",Yo="handle_apply_join_group",jo="handle_invite_join_permission_group",zo="handle_invite_join_group",Jo="group_msg_recall",Xo="msg_read_report",Zo="read_all_unread_msg",Qo="group_msg_get",ei="get_group_msg_receipt",ti="group_msg_receipt",si="c2c_msg_read_receipt",oi="get_group_msg_receipt_detail",ii="get_pendency",ni="deletemsg",ri="get_msg",ai="get_msg_noauth",ui="get_online_member_num",ci="delete_group_ramble_msg_by_seq",li="modify_group_msg",di="set_group_attr",pi="modify_group_attr",hi="delete_group_attr",gi="clear_group_attr",_i="get_group_attr",mi="group_set_key_values",Mi="group_get_key_values",fi="get_group_notify",Ii="update_group_counter",Ci="get_group_counter",Ti="get_group_member_info",yi="get_members",Di="get_specified_group_member_info",Ei="add_group_member",Si="delete_group_member",Li="ban_group_member",Ai="modify_group_member_info",vi="modify_user_info",Ni="cos",Ri="pre_sig",Oi="video_cover",Gi="tim_web_report_v2",Ui="alive",ki="msg_push",Pi="multi_msg_push_ws",bi="ws_msg_push_ack",wi="stat_forceoffline",Fi="save_relay_json_msg",$i="get_relay_json_msg",qi="fetch_config",xi="push_configv2",Vi="fetch_imsdk_purchase_bitsv2",Bi="push_imsdk_purchase_bitsv2",Hi="notify2",Ki="create_topic",Wi="destroy_topic",Yi="modify_topic",ji="get_topic",zi="ws_set_custom_status",Ji="ws_get_user_status",Xi="ws_status_subscribe",Zi="ws_status_unsubscribe",Qi="ws_stat_background",en="ws_stat_foreground",tn="ws_stat_settoken",sn="get_local_words",on="ws_batch_trans_text",nn={NO_SDKAPPID:2e3,NO_ACCOUNT_TYPE:2001,NO_IDENTIFIER:2002,NO_USERSIG:2003,NO_TINYID:2022,NO_A2KEY:2023,USER_NOT_LOGGED_IN:2024,REPEAT_LOGIN:2025,COS_UNDETECTED:2040,COS_GET_SIG_FAIL:2041,MESSAGE_SEND_FAIL:2100,MESSAGE_SEND_FAIL_NOT_IN_AVCHATROOM:2101,MESSAGE_SEND_NEED_MESSAGE_INSTANCE:2105,MESSAGE_SEND_INVALID_CONVERSATION_TYPE:2106,MESSAGE_FILE_IS_EMPTY:2108,MESSAGE_ONPROGRESS_FUNCTION_ERROR:2109,MESSAGE_REVOKE_FAIL:2110,MESSAGE_DELETE_FAIL:2111,MESSAGE_UNREAD_ALL_FAIL:2112,READ_RECEIPT_MESSAGE_LIST_EMPTY:2114,MESSAGE_SEND_GROUP_WITH_TOPIC_FAIL:2115,CANNOT_DELETE_GROUP_SYSTEM_NOTICE:2116,TRANSLATE_TEXT_FAIL:2117,MESSAGE_IMAGE_SELECT_FILE_FIRST:2251,MESSAGE_IMAGE_TYPES_LIMIT:2252,MESSAGE_IMAGE_SIZE_LIMIT:2253,MESSAGE_AUDIO_UPLOAD_FAIL:2300,MESSAGE_AUDIO_SIZE_LIMIT:2301,MESSAGE_VIDEO_UPLOAD_FAIL:2350,MESSAGE_VIDEO_SIZE_LIMIT:2351,MESSAGE_VIDEO_TYPES_LIMIT:2352,MESSAGE_FILE_UPLOAD_FAIL:2400,MESSAGE_FILE_SELECT_FILE_FIRST:2401,MESSAGE_FILE_SIZE_LIMIT:2402,MESSAGE_FILE_URL_IS_EMPTY:2403,MESSAGE_MERGER_TYPE_INVALID:2450,MESSAGE_MERGER_KEY_INVALID:2451,MESSAGE_MERGER_DOWNLOAD_FAIL:2452,MESSAGE_FORWARD_TYPE_INVALID:2453,MESSAGE_MODIFY_CONFLICT:2480,MESSAGE_MODIFY_DISABLED_IN_AVCHATROOM:2481,CONVERSATION_NOT_FOUND:2500,USER_OR_GROUP_NOT_FOUND:2501,CONVERSATION_UN_RECORDED_TYPE:2502,INVALID_CONVERSATION_ID:2503,ILLEGAL_GROUP_TYPE:2600,CANNOT_JOIN_WORK:2601,ILLEGAL_GROUP_ID:2602,CANNOT_FIND_GROUP:2603,CANNOT_CHANGE_OWNER_IN_AVCHATROOM:2620,CANNOT_CHANGE_OWNER_TO_SELF:2621,CANNOT_DISMISS_WORK:2622,MEMBER_NOT_IN_GROUP:2623,JOIN_GROUP_FAIL:2660,CANNOT_ADD_MEMBER_IN_AVCHATROOM:2661,CANNOT_JOIN_NON_AVCHATROOM_WITHOUT_LOGIN:2662,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,NOT_MY_FRIEND:2700,ALREADY_MY_FRIEND:2701,FRIEND_GROUP_EXISTED:2710,FRIEND_GROUP_NOT_EXIST:2711,FRIEND_APPLICATION_NOT_EXIST:2716,UPDATE_PROFILE_INVALID_PARAM:2721,UPDATE_PROFILE_NO_KEY:2722,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,MESSAGE_A2KEY_EXPIRED:20002,ACCOUNT_A2KEY_EXPIRED:70001,HELLO_ANSWER_KICKED_OUT:1002,OPEN_SERVICE_OVERLOAD_ERROR:60022},rn="networkRTT",an="messageE2EDelay",un="sendMessageC2C",cn="sendMessageGroup",ln="sendMessageGroupAV",dn="sendMessageRichMedia",pn="cosUpload",hn="messageReceivedGroup",gn="messageReceivedGroupAVPush",_n="messageReceivedGroupAVPull",mn={[rn]:2,[an]:3,[un]:4,[cn]:5,[ln]:6,[dn]:7,[hn]:8,[gn]:9,[_n]:10,[pn]:11},Mn={info:4,warning:5,error:6},fn={wifi:1,"2g":2,"3g":3,"4g":4,"5g":5,unknown:6,none:7,online:8},In={login:4};class Cn{constructor(e){this._n="SSOLogData",this.eventType=In[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=ce()}static bindEventStatModule(e){Cn.prototype._eventStatModule=e}updateTimeStamp(){this.timestamp=ce()}start(e){return this._startts=e,this}end(e=!1){if(this._sentFlag)return;const t=ce();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 _e.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=nn.NO_NETWORK;this.setCode(e)}return this.setLevel("error"),this}setCode(e){return we(e)||this._sentFlag||("ECONNABORTED"===e&&(this.code=103),Ge(e)?this.code=e:_e.w(this._n+".setCode value not a number, please check!",e,typeof e)),this}setMessage(e){return we(e)||this._sentFlag||(Ge(e)&&(this.message=e.toString()),Ue(e)&&(this.message=e)),this}setCostTime(e){return this.costTime=e,this}setLevel(e){return we(e)||this._sentFlag||(this.level=Mn[e]),this}setMoreMessage(e){return Lt(this.moreMessage)?this.moreMessage=""+e:this.moreMessage+=" "+e,this}setNetworkType(e){if(we(e))_e.w(this._n+".setNetworkType value is undefined, please check!");else{const t=fn[e.toLowerCase()];we(t)||(this.networkType=t)}return this}getStartTs(){return this._startts}setUIPlatform(e){this.uiPlatform=e}}class Tn{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 yn{constructor(e,s){this._imageMemoryURL="",this._fileDownloadProxy=s,P?this.createImageDataASURLInWXMiniApp(e.file):this.createImageDataASURLInWeb(e.file),this._initImageInfoModel(),this.type=t.MSG_IMAGE,this._percent=0,this.content={imageFormat:e.imageFormat||me.UNKNOWN,uuid:e.uuid,imageInfoArray:[]},this.initImageInfoArray(e.imageInfoArray),this._autoFixUrl()}_initImageInfoModel(){const e=this;this._ImageInfoModel=function(t){this.instanceID=We(9999999),this.sizeType=t.type||0,this.type=0,this.size=t.size||0,this.width=t.width||0,this.height=t.height||0,this.imageUrl=t.url||"",this.url=Et(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=we(e)||we(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=me[e.toUpperCase()]||me.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&&(ht(e),Object.assign(e[2],pt({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 Dn{constructor(e){this.type=t.MSG_FACE,this.content=e||null}sendable(){return null!==this.content}}class En{constructor(e,s){this.type=t.MSG_AUDIO,this._percent=0,this.content={downloadFlag:2,second:e.second,size:e.size,url:Et(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 Sn={from:!0,groupID:!0,groupName:!0,to:!0};class Ln{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];Sn[o]&&(this.content.groupProfile[o]=e[o])}}_updateMemberList(e){Lt(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 An={from:!0,groupID:!0,groupName:!0,to:!0};class vn{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];An[o]&&("groupName"===o?this.content.groupProfile.name=e[o]:this.content.groupProfile[o]=e[o])}}}class Nn{constructor(e,s){this.type=t.MSG_FILE,this._percent=0;const o=this._getFileInfo(e);this.content={downloadFlag:2,fileUrl:Et(e.url,s)||"",uuid:e.uuid,fileName:o.name||"",fileSize:o.size||0}}_getFileInfo(e){if(!we(e.fileName)&&!we(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=`${We(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 Rn{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 On{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:Et(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:Et(e.thumbUrl,s),snapshotUrl:Et(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;Lt(t)||(this.content.thumbUrl=this.content.snapshotUrl=t),Lt(s)||(this.content.thumbWidth=this.content.snapshotWidth=Number(s)),Lt(o)||(this.content.thumbHeight=this.content.snapshotHeight=Number(o))}sendable(){return""!==this.content.remoteVideoUrl}}class Gn{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 Un{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||"",this.messageBody=[{type:e.type,payload:e.payload}],e.conversationType.startsWith(t.CONV_C2C)?this.receiverUserID=e.to:e.conversationType.startsWith(t.CONV_GROUP)&&(this.receiverGroupID=e.to),this.messageReceiver=e.to;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 kn(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=Et(e.url,o)}):e===t.MSG_VIDEO?(s.videoUrl=Et(s.videoUrl,o),s.snapshotUrl=Et(s.thumbUrl,o),s.snapshotHeight=s.thumbHeight,s.snapshotWidth=s.thumbWidth):e===t.MSG_AUDIO?s.url=Et(s.url,o):e===t.MSG_FILE&&(s.fileUrl=Et(s.fileUrl,o)))}}var kn=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(Lt(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(!Lt(e)){const t=new Un(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!Lt(this.content.messageList)||!Lt(this.content.downloadKey)}};const Pn={1:t.MSG_PRIORITY_HIGH,2:t.MSG_PRIORITY_NORMAL,3:t.MSG_PRIORITY_LOW,4:t.MSG_PRIORITY_LOWEST};class bn{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:We(),this.priority=this._computePriority(e.priority),this.nick=e.nick||"",this.avatar=e.avatar||"",this.isPeerRead=!1,this.nameCard="",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||de()||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||null,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;Ue(e.nick)&&(this.nick=e.nick),Ue(e.avatar)&&(this.avatar=e.avatar);const{messageFromAccountExtraInformation:t}=e;Pe(t)&&Ue(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))}),be(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&&("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===Je[e]){const t=new Date;let s=("3"+t.getHours()).slice(-2),o=("0"+t.getMinutes()).slice(-2),i=("0"+t.getSeconds()).slice(-2);Je[e]=parseInt([s,o,i,"0001"].join("")),s=null,o=null,i=null,_e.l("autoIncrementIndex start index:"+Je[e])}return Je[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 Tn||e instanceof yn||e instanceof Dn||e instanceof En||e instanceof Nn||e instanceof On||e instanceof Ln||e instanceof vn||e instanceof Rn||e instanceof Gn||e instanceof kn}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(be(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 Tn({text:t});this._elements.push(s)}setImageElement(e,t){const s=new yn(e,t);this._elements.push(s)}setAudioElement(e,t){const s=new En(e,t);this._elements.push(s)}setFileElement(e,t){const s=new Nn(e,t);this._elements.push(s)}setVideoElement(e,t){const s=new On(e,t);this._elements.push(s)}setLocationElement(e){const t=new Gn(e);this._elements.push(t)}setCustomElement(e){const t=new Rn(e);this._elements.push(t)}setGroupTipElement(e){let s={};const o=e.operationType;if(Lt(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]),!Lt(e.memberExtraInfo)){const{reason:t}=e.memberExtraInfo;e.msgMemberInfo.forEach(e=>{e.reason=t})}const{nick:i,avatar:n}=s;Ue(i)&&(this.nick=i),Ue(n)&&(this.avatar=n);const r=new Ln(e);this._elements.push(r)}setGroupSystemNoticeElement(e){const t=new vn(e);this._elements.push(t)}setFaceElement(e){const t=new Dn(e);this._elements.push(t)}setMergerElement(e,t){const s=new kn(e,t);this._elements.push(s)}setIsRead(e){this.isRead=e}setRelayFlag(e){this._relayFlag=e}getRelayFlag(){return this._relayFlag}_computePriority(e){if(we(e))return t.MSG_PRIORITY_NORMAL;if(Ue(e)&&-1!==Object.values(Pn).indexOf(e))return e;if(Ge(e)){const t=""+e;if(-1!==Object.keys(Pn).indexOf(t))return Pn[t]}return t.MSG_PRIORITY_NORMAL}setNickAndAvatar(e){const{nick:t,avatar:s}=e;Ue(t)&&(this.nick=t),Ue(s)&&(this.avatar=s)}setNameCard(e){Ue(e)&&(this.nameCard=e)}initC2CReadReceiptInfo(e){this.conversationType===t.CONV_C2C&&!0===this.needReadReceipt&&(this.readReceiptInfo.isPeerRead=1===e)}}const wn=function(e){return{code:0,data:e||{}}};class Fn 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||{}}}let $n=null;const qn=function(e){$n=e},xn=function(e){return Promise.resolve(wn(e))},Vn=function(t,s=!1){if(t instanceof Fn)return s&&null!==$n&&$n.emit(e.ERROR,t),Promise.reject(t);if(t instanceof Error){const t=new Fn({code:nn.UNCAUGHT_ERROR});return s&&null!==$n&&$n.emit(e.ERROR,t),Promise.reject(t)}if(we(t)||we(t.code))return;const o=new Fn(t);return s&&null!==$n&&$n.emit(e.ERROR,o),Promise.reject(o)};class Bn extends Fs{constructor(e){super(e),this._n="C2CModule",this._messageFromUnreadDBMap=new Map,this._signalingFromUnreadDBList=[]}onNewC2CMessage(t){const{dataList:s,isInstantMessage:o,C2CRemainingUnreadList:i,C2CPairUnreadList:n}=t;_e.d(`${this._n}.onNewC2CMessage count:${s.length} isInstantMessage:${o}`);const{conversationOptionsList:r,messageList:a,isUnreadC2CMessage:u}=this._newC2CMessageStoredAndSummary({dataList:s,C2CRemainingUnreadList:i,C2CPairUnreadList:n,isInstantMessage:o});if(this.filterModifiedMessage(a),r.length>0){this.getModule(_s).onNewMessage({conversationOptionsList:r,isInstantMessage:o,isUnreadC2CMessage:u})}const c=this.filterUnmodifiedMessage(a);o&&c.length>0&&this.emitOuterEvent(e.MESSAGE_RECEIVED,c),a.length=0}_newC2CMessageStoredAndSummary({dataList:e,C2CRemainingUnreadList:s,C2CPairUnreadList:o,isInstantMessage:i}){let n=null;const r=[],a=[],u={},c=this.getModule(Cs),l=this.getModule(Rs);let d=!1;const p=this.getModule(_s),h=this.getFileDownloadProxy();for(let _=0,m=e.length;_<m;_++){if(this._isSignaling(e[_])){this._signalingFromUnreadDBList.push(e[_].eventArray[0].c2CNotifyMsgArray[0]);continue}const s=e[_];s.currentUser=this.getMyUserID(),s.conversationType=t.CONV_C2C,s.isSystemMessage=!!s.isSystemMessage,(we(s.nick)||we(s.avatar))&&(d=!0,_e.d(this._n+"._newC2CMessageStoredAndSummary nick or avatar missing!")),n=new bn(s),s.elements=c.parseElements(s.elements,s.from),n.setElement(s.elements,h),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=p.getLatestMessageSentByPeer(o);if(e){const{nick:s,avatar:o}=e;d?n.setNickAndAvatar({nick:s,avatar:o}):s===n.nick&&o===n.avatar||(t=!0)}}else{const e=p.getLatestMessageSentByMe(o);if(e){const{nick:t,avatar:s}=e;t===n.nick&&s===n.avatar||p.modifyMessageSentByMe({conversationID:o,latestNick:n.nick,latestAvatar:n.avatar})}}let r=1===e[_].isModified;if(p.isMessageSentByCurrentInstance(n)?n.isModified=r:r=!1,0===s.msgLifeTime)n._onlineOnlyFlag=!0,p.isMessageSentByCurrentInstance(n)||a.push(n);else{if(!p.pushIntoMessageList(a,n,r))continue;t&&(p.modifyMessageSentByPeer({conversationID:o,latestNick:n.nick,latestAvatar:n.avatar}),p.updateUserProfileSpecifiedKey({conversationID:o,nick:n.nick,avatar:n.avatar}))}i&&n.clientTime>0&&l.addMessageDelay(n.clientTime)}else this._messageFromUnreadDBMap.set(n.ID,1);if(0!==s.msgLifeTime){if(!1===n._onlineOnlyFlag){const e=p.getLastMessageTime(o);if(Ge(e)&&n.time<e)continue;if(we(u[o])){let e=0;"in"===n.flow&&(n._isExcludedFromUnreadCount||(e=1)),u[o]=r.push({conversationID:o,unreadCount:e,type:n.conversationType,subType:n.conversationSubType,lastMessage:n._isExcludedFromLastMessage?"":n})-1}else{const e=u[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._handleSignalingFromUnreadDB();let g=!1;if(be(o))for(let _=0,m=o.length;_<m;_++)if(o[_].unreadCount>0){g=!0;const e=r.find(({conversationID:e})=>e==="C2C"+o[_].from);e?e.unreadCount=o[_].unreadCount:r.push({conversationID:"C2C"+o[_].from,unreadCount:o[_].unreadCount,type:t.CONV_C2C})}if(be(s))for(let _=0,m=s.length;_<m;_++){r.find(({conversationID:e})=>e==="C2C"+s[_].from)||r.push({conversationID:"C2C"+s[_].from,type:t.CONV_C2C,lastMsgTime:s[_].lastMsgTime})}return{conversationOptionsList:r,messageList:a,isUnreadC2CMessage:g}}_isSignaling(e){const{eventArray:t}=e;return!(!be(t)||10!==t[0].event)}_handleSignalingFromUnreadDB(){const e=this._signalingFromUnreadDBList.length;if(_e.l(`${this._n}._handleSignalingFromUnreadDB signalingCount:${e}`),0===e)return;const t=[];this._signalingFromUnreadDBList.forEach(e=>{e.hasOwnProperty("c2cMessageRevokedNotify")&&t.push(e)}),this.onC2CMessageRevoked({dataList:t}),this._signalingFromUnreadDBList.length=0,t.length=0}onC2CMessageRevoked(s){const o=this.getModule(_s),i=[];let n=null,r=!0;s.dataList.forEach(e=>{if(e.c2cMessageRevokedNotify){const{revokedInfos:s}=e.c2cMessageRevokedNotify;we(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 a=e.revokerInfo&&e.revokerInfo.revoker;if(n)n.revoker||(n.revoker=a,i.push(n));else{const t={conversationID:s,sequence:e.sequence,time:e.time,revoker:a};o.isLastMessageRevoked(t)&&(i.push(t),r=!1)}})}}),0!==i.length&&(o.onMessageRevoked(i),!0===r&&(_e.l(`${this._n}.onC2CMessageRevoked count:${i.length}`),this.emitOuterEvent(e.MESSAGE_REVOKED,i)))}onC2CMessageReadReceipt(e){e.dataList.forEach(e=>{if(!Lt(e.c2cMessageReadReceipt)){const{to:s}=e.c2cMessageReadReceipt;e.c2cMessageReadReceipt.uinPairReadArray.forEach(e=>{const{peerReadTime:o}=e;_e.d(`${this._n}._onC2CMessageReadReceipt to:${s} peerReadTime:${o}`);const i=`${t.CONV_C2C}${s}`,n=this.getModule(_s);n.recordPeerReadTime(i,o),n.updateMessageIsPeerReadProperty(i,o)})}})}onC2CMessageReadNotice(e){e.dataList.forEach(e=>{if(!Lt(e.c2cMessageReadNotice)){const s=this.getModule(_s);e.c2cMessageReadNotice.uinPairReadArray.forEach(e=>{const{from:o,peerReadTime:i}=e;_e.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){_e.d(this._n+".onC2CMessageModified options:",JSON.stringify(e));const s=this.getModule(_s);e.dataList.forEach(e=>{s.onMessageModified({...e,conversationType:t.CONV_C2C})})}onReadReceiptList(e){_e.d(this._n+".onReadReceiptList options:",JSON.stringify(e));const{userID:t,readReceiptList:s}=e.dataList;this.getModule(_s).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="";Ue(e.cloudCustomData)&&e.cloudCustomData.length>0&&(o=e.cloudCustomData);const i=[];if(Pe(t)&&Pe(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,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}}}_isVoipPush(e){let t=void 0;return we(e.disableVoipPush)||(t=!1===e.disableVoipPush?1:0),t}isOnlineMessage(e,t){return!(!t||!0!==t.onlineUserOnly)}revokeMessage(e){return this.request({protocolName:ho,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 _e.l(`${this._n}.deleteMessage toAccount:${t} count:${s.length}`),this.request({protocolName:Io,requestData:{fromAccount:this.getMyUserID(),to:t,keyList:s}})}modifyRemoteMessage(e){const{from:t,to:s,version:o=0,sequence:i,random:n,time:r,payload:a,type:u,cloudCustomData:c}=e;let l=void 0;return Ct(u)&&(l=[],l.push({type:u,content:a})),this.request({protocolName:Co,requestData:{from:t,to:s,version:o,sequence:i,random:n,time:r,elements:l,cloudCustomData:c}})}setMessageRead({conversationID:e,lastMessageTime:t}){const s=this._n+".setMessageRead";_e.l(`${s} conversationID:${e} lastMessageTime:${t}`),Ge(t)||this.outputWarning("DoNotModifyLastTime");const o=new Cn("setC2CMessageRead");return o.setMessage(`conversationID:${e} lastMessageTime:${t}`),this.request({protocolName:go,requestData:{C2CMsgReaded:{cookie:"",C2CMsgReadedItem:[{toAccount:e.replace("C2C",""),lastMessageTime:t,receipt:1}]}}}).then(()=>{o.setNetworkType(this.getNetworkType()).end(),_e.l(s+" ok");const i=this.getModule(_s);return i.updateIsReadAfterReadReport({conversationID:e,lastMessageTime:t}),i.updateUnreadCount(e),wn()}).catch(e=>(this.probeNetwork().then(([t,s])=>{o.setError(e,t,s).end()}),_e.l(s+" failed. error:",e),Vn(e)))}getRoamingMessage(e){const s=this._n+".getRoamingMessage",{peerAccount:o,conversationID:i,count:n,lastMessageTime:r,messageKey:a}=e,u=`peerAccount:${o} count:${n||15} lastMessageTime:${r||0} messageKey:${a}`;_e.l(`${s} ${u}`);const c=new Cn("getC2CRoamingMessages");return this.request({protocolName:Mo,requestData:{peerAccount:o,count:n||15,lastMessageTime:r||0,messageKey:a}}).then(e=>{const{complete:o,messageList:n,messageKey:r,lastMessageTime:a}=e.data;we(n)?_e.l(`${s} ok. complete:${o} but messageList is undefined!`):_e.l(`${s} ok. complete:${o} count:${n.length}`),c.setNetworkType(this.getNetworkType()).setMessage(`${u} complete:${o} length:${n.length}`).end();const l=this.getModule(_s);1===o&&l.setCompleted(i);const d=l.onRoamingMessage(n,i);l.modifyMessageList(i),l.updateIsRead(i),l.updateRoamingMessageKeyAndTime(i,r,a);const p=l.getPeerReadTime(i);if(_e.l(`${s} update isPeerRead property. conversationID:${i} peerReadTime:${p}`),p)l.updateMessageIsPeerReadProperty(i,p);else{const e=i.replace(t.CONV_C2C,"");this.getRemotePeerReadTime([e]).then(()=>{l.updateMessageIsPeerReadProperty(i,l.getPeerReadTime(i))})}let h="";if(d.length>0)h=d[0].ID;else{const e=l.getLocalOldestMessage(i);e&&(h=e.ID)}return _e.l(`${s} nextReqID:${h} stored message count:${d.length}`),{nextReqID:h,storedMessageList:d}}).catch(e=>(this.probeNetwork().then(([t,s])=>{c.setMessage(u).setError(e,t,s).end()}),_e.w(s+" failed. error:",e),Vn(e)))}getRoamingMessagesHopping(e){const s=this._n+".getRoamingMessagesHopping",{peerAccount:o,time:i=0,count:n,direction:r}=e,a=`${t.CONV_C2C}${o}`,u=`peerAccount:${o} count:${n} time:${i} direction:${r}`;_e.l(`${s} ${u}`);const c=new Cn("getC2CRoamingMessagesHopping");return this.request({protocolName:Mo,requestData:{peerAccount:o,count:n+1,lastMessageTime:i,direction:r}}).then(e=>{const{complete:t,messageList:o=[],lastMessageTime:i}=e.data;_e.l(`${s} ok. complete:${t} count:${o.length}`),c.setNetworkType(this.getNetworkType()).setMessage(`${u} complete:${t} length:${o.length}`).end(),1!==t&&(1===r?o.pop():o.shift());const n=this.getModule(_s).onRoamingMessage(o,a,!1);this._modifyMessageList(a,n);const l=this._computeResult({complete:t,lastMessageTime:i,resultList:n});return wn(l)}).catch(e=>(this.probeNetwork().then(([t,s])=>{c.setMessage(u).setError(e,t,s).end()}),_e.w(s+" failed. error:",e),Vn(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(_s).getLocalConversation(e);if(!s)return;const o=s.userProfile.nick,i=s.userProfile.avatar,n=this.getModule(cs).getNickAndAvatarByUserID(this.getMyUserID()),r=n.nick,a=n.avatar;for(let u=t.length-1;u>=0;u--){const e=t[u];"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(Lt(e))return _e.w(t+" userIDList is empty!"),Promise.resolve();const s=new Cn("getPeerReadTime");return _e.l(`${t} userIDList:${e}`),this.request({protocolName:fo,requestData:{userIDList:e}}).then(o=>{const{peerReadTimeList:i}=o.data;_e.l(`${t} ok. peerReadTimeList:${i}`);let n="";const r=this.getModule(_s);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()}),_e.w(t+" failed. error:",e)})}sendReadReceipt(e){const s=e[0].conversationID.replace(t.CONV_C2C,""),o=new Cn("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 Vn({code:nn.READ_RECEIPT_MESSAGE_LIST_EMPTY});const r=this._n+".sendReadReceipt";return _e.l(`${r}. peerAccount:${s} messageInfoList length:${n.length}`),this.request({protocolName:si,requestData:{peerAccount:s,messageInfoList:n}}).then(e=>(o.end(),_e.l(r+" ok"),wn())).catch(e=>(this.probeNetwork().then(([t,s])=>{o.setError(e,t,s).end()}),_e.w(r+" failed. error:",e),Vn(e)))}getReadReceiptList(e){const t=this._n+".getReadReceiptList",s=this.getMyUserID(),o=e.filter(e=>e.from===s&&!0===e.needReadReceipt);return _e.l(`${t} userID:${s} messageList length:${o.length}`),xn({messageList:o})}getMessageExtensions(e,t){return _e.l(`${this._n}.getMessageExtensions startSequence:${t}`),this.request({protocolName:yo,requestData:{from:e.from,to:e.to,messageKey:this._getMessageKey(e),startSequence:t}})}modifyMessageExtensions(e,t,s=1){return _e.l(`${this._n}.modifyMessageExtensions operateType:${s}`),this.request({protocolName:To,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(){_e.l(this._n+".reset"),this._messageFromUnreadDBMap.clear(),this._signalingFromUnreadDBList.length=0}}class Hn{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(be(e)?e.length>0&&(o=e[0].conversationID,this._unshiftMultipleMessages(e,s)):(o=e.conversationID,this._unshiftSingleMessage(e,s)),o&&o.startsWith(t.CONV_C2C)){const e=Array.from(this.list.get(o).values()),t=e.length;if(0===t)return;for(let s=t-1;s>=0;s--)if("out"===e[s].flow){this._setLatestMessageSentByMe(o,e[s]);break}for(let s=t-1;s>=0;s--)if("in"===e[s].flow){this._setLatestMessageSentByPeer(o,e[s]);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(_e.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&&(we(s)||e.random===s))return e.isRevoked||(e.isRevoked=!0),e}return null}removeByConversationID(e){this.list.has(e)&&(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));_e.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,s){e.startsWith(t.CONV_C2C)&&"out"===s.flow&&this._latestMessageSentByMeMap.set(e,s)}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(Lt(i))return;const n=Array.from(i.values()),r=n.length;if(0===r)return;let a=null,u=0,c=!1;for(let l=r-1;l>=0;l--)"in"===n[l].flow&&(a=n[l],a.nick!==s&&(a.setNickAndAvatar({nick:s}),c=!0),a.avatar!==o&&(a.setNickAndAvatar({avatar:o}),c=!0),c&&(u+=1));_e.l(`${this._n}.modifyMessageSentByPeer conversationID:${t} count:${u}`)}modifyMessageSentByMe(e){const{conversationID:t,latestNick:s,latestAvatar:o}=e,i=this.list.get(t);if(Lt(i))return;const n=Array.from(i.values()),r=n.length;if(0===r)return;let a=null,u=0,c=!1;for(let l=r-1;l>=0;l--)"out"===n[l].flow&&(a=n[l],a.nick!==s&&(a.setNickAndAvatar({nick:s}),c=!0),a.avatar!==o&&(a.setNickAndAvatar({avatar:o}),c=!0),c&&(u+=1));_e.l(`${this._n}.modifyMessageSentByMe conversationID:${t} count:${u}`)}getTopicConversationIDList(e){return[...this.list.keys()].filter(s=>s.startsWith(`${t.CONV_GROUP}${e}`))}traversal(){if(0!==this.list.size&&-1===_e.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._getUniqueIDOfMessage(t),o=this.list.get(e).has(s);if(_e.d(`${this._n}.onMessageModified conversationID:${e} uniqueID:${s} has:${o}`),o){const o=this.list.get(e).get(s),{messageVersion:i,elements:n,cloudCustomData:r}=t;return o.version<i?(o.version=i,o._elements=JSON.parse(JSON.stringify(n)),o.payload=JSON.parse(JSON.stringify(n[0].content)),o.type=n[0].type,o.cloudCustomData=r,o.isModified=!0,{isUpdated:!0,message:o}):{isUpdated:!1,message:o}}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 Kn="_a2KeyAndTinyIDUpdated",Wn="_cloudConfigUpdated",Yn="_profileUpdated";function jn(e){this.mixin(e)}jn.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 zn=["jpg","jpeg","gif","png","bmp","image","webp"],Jn=["mp4","quicktime","mov"],Xn=1,Zn=2,Qn=3,er=255;class tr{constructor(e){Lt(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=[],Lt(e.profileCustomField)||e.profileCustomField.forEach(e=>{this.profileCustomField.push({key:e.key,value:e.value})}))}validate(e){let t=!0,s="";if(Lt(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],!Ue(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(!Ue(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(Lt(e[o])&&!Ue(e[o])&&!Ge(e[o])){s="key:"+o+", invalid value:"+e[o],t=!1;continue}switch(o){case"nick":Ue(e[o])||(s="nick must be a string",t=!1),Ke(e[o])>500&&(s=`nick name limited: must less than or equal to 500 bytes, current size: ${Ke(e[o])} bytes`,t=!1);break;case"gender":ze(De,e.gender)||(s="key:gender, invalid value:"+e.gender,t=!1);break;case"birthday":Ge(e.birthday)||(s="birthday must be a number",t=!1);break;case"location":Ue(e.location)||(s="location must be a string",t=!1);break;case"selfSignature":Ue(e.selfSignature)||(s="selfSignature must be a string",t=!1);break;case"allowType":ze(Se,e.allowType)||(s="key:allowType, invalid value:"+e.allowType,t=!1);break;case"language":Ge(e.language)||(s="language must be a number",t=!1);break;case"avatar":Ue(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":ze(Ee,e.adminForbidType)||(s="key:adminForbidType, invalid value:"+e.adminForbidType,t=!1);break;case"level":Ge(e.level)||(s="level must be a number",t=!1);break;case"role":Ge(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 sr{constructor(e){this.value=e,this.next=null}}class or{constructor(e){this.MAX_LENGTH=e,this.pTail=null,this.pNodeToDel=null,this.map=new Map}set(e){const t=new sr(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 ir=["groupID","name","avatar","type","introduction","notification","ownerID","selfInfo","createTime","infoSequence","lastInfoTime","lastMessage","nextMessageSeq","memberNum","maxMemberNum","memberList","joinOption","groupCustomField","muteAllMembers","isSupportTopic","inviteOption","_lastRevokedTime"];class nr{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)ir.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),we(t.muteAllMembers)||("On"===t.muteAllMembers?t.muteAllMembers=!0:t.muteAllMembers=!1),t.groupCustomField&&Qe(this.groupCustomField,t.groupCustomField),we(t.memberNum)||(this.memberCount=t.memberNum),we(t.maxMemberNum)||(this.maxMemberCount=t.maxMemberNum),we(t.isSupportTopic)||(this.isSupportTopic=Ge(t.isSupportTopic)?1===t.isSupportTopic:t.isSupportTopic),Be(this,t,["members","errorCode","lastMsgTime","groupCustomField","memberNum","maxMemberNum","isSupportTopic"]),be(t.members)&&t.members.length>0&&t.members.forEach(e=>{e.userID===this.selfInfo.userID&&Be(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};Be(this.selfInfo,{...r},[],["",null,void 0,0,NaN])}setSelfNameCard(e){this.selfInfo.nameCard=e}}const rr=function(e,t){return we(e)?{lastTime:0,lastSequence:0,fromAccount:0,messageForShow:"",payload:null,type:"",isRevoked:!1,cloudCustomData:"",onlineOnlyFlag:!1,nick:"",nameCard:"",version:0,isPeerRead:!1,revoker:null}:e instanceof bn?{lastTime:e.time||0,lastSequence:e.sequence||0,fromAccount:e.from||"",messageForShow:It(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:It(e.type,e.payload,t)}};class ar{constructor(e,t){this.conversationID=e.conversationID||"",this.unreadCount=e.unreadCount||0,this.type=e.type||"",this.lastMessage=rr(e.lastMessage,t),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="",this.markList=e.markList||[],this.customData=e.customData||"",this.conversationGroupList=e.conversationGroupList||[],this._initProfile(e)}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,""):""}get subType(){return this.groupProfile?this.groupProfile.type:""}_initProfile(e){Object.keys(e).forEach(t=>{switch(t){case"userProfile":this.userProfile=e.userProfile;break;case"groupProfile":this.groupProfile=e.groupProfile}}),we(this.userProfile)&&this.type===t.CONV_C2C?this.userProfile=new tr({userID:e.conversationID.replace("C2C","")}):we(this.groupProfile)&&this.type===t.CONV_GROUP&&(this.groupProfile=new nr({groupID:e.conversationID.replace("GROUP","")}))}updateUnreadCount(e){const{nextUnreadCount:s,isFromGetConversations:o,isUnreadC2CMessage:i}=e;we(s)||(et(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=rr(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(!st({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}}class ur{constructor(e){this._conversationModule=e,this._n="MessageRemindHandler",this._updateSequence=0}getC2CMessageRemindType(){const e=this._n+".getC2CMessageRemindType";return this._conversationModule.request({protocolName:mo,updateSequence:this._updateSequence}).then(t=>{_e.l(e+" ok");const{updateSequence:s,muteFlagList:o}=t.data;this._updateSequence=s,this._patchC2CMessageRemindType(o)}).catch(t=>{_e.e(e+" failed. error:",t)})}_patchC2CMessageRemindType(e){let s=0,o="";be(e)&&e.length>0&&e.forEach(e=>{const{userID:i,muteFlag:n}=e;0===n?o=t.MSG_REMIND_ACPT_AND_NOTE:1===n?o=t.MSG_REMIND_DISCARD:2===n&&(o=t.MSG_REMIND_ACPT_NOT_NOTE),!0===this._conversationModule.patchMessageRemindType({ID:i,isC2CConversation:!0,messageRemindType:o})&&(s+=1)}),_e.l(`${this._n}._patchC2CMessageRemindType count:${s}`)}set(e){return e.groupID?this._setGroupMessageRemindType(e):be(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 Cn("setMessageRemindType");n.setMessage(i);return this._getModule(hs).modifyGroupMemberInfo({groupID:s,messageRemindType:o,userID:this._conversationModule.getMyUserID()}).then(()=>{n.setNetworkType(this._conversationModule.getNetworkType()).end(),_e.l(`${t} ok. ${i}`);const s=this.onGroupMessageRemindTypeUpdated(e);return this._conversationModule.emitTotalUnreadMessageCountUpdate(),wn(s)}).catch(e=>(this._conversationModule.probeNetwork().then(([t,s])=>{n.setError(e,t,s).end()}),_e.e(t+" failed. error:",e),Vn(e)))}onGroupMessageRemindTypeUpdated(t){const{groupID:s,messageRemindType:o}=t,i=this._getModule(ds).getLocalGroupProfile(s);if(i&&(i.selfInfo.messageRemindType=o),ot(s)){const t=s,i=ft(t),n=this._getModule(gs).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}`,u=new Cn("setMessageRemindType");return u.setMessage(a),this._conversationModule.request({protocolName:_o,requestData:{userIDList:n,muteFlag:r}}).then(e=>{u.setNetworkType(this._conversationModule.getNetworkType()).end();const{updateSequence:t,errorList:o}=e.data;this._updateSequence=t;const r=[],a=[];be(o)&&o.forEach(e=>{r.push(e.userID),a.push({userID:e.userID,code:e.errorCode})});const c=n.filter(e=>-1===r.indexOf(e));_e.l(`${s} ok. successUserIDList:${c} failureUserIDList:${JSON.stringify(a)}`);let l=0;return c.forEach(e=>{this._conversationModule.patchMessageRemindType({ID:e,isC2CConversation:!0,messageRemindType:i})&&(l+=1)}),l>=1&&this._emitConversationUpdate(),n.length=r.length=0,this._conversationModule.emitTotalUnreadMessageCountUpdate(),xn({successUserIDList:c.map(e=>({userID:e})),failureUserIDList:a})}).catch(e=>(this._conversationModule.probeNetwork().then(([t,s])=>{u.setError(e,t,s).end()}),_e.e(s+" failed. error:",e),Vn(e)))}_getModule(e){return this._conversationModule.getModule(e)}_emitConversationUpdate(){this._conversationModule.emitConversationUpdate(!0,!1)}setUpdateSequence(e){this._updateSequence=e}reset(){_e.l(this._n+".reset"),this._updateSequence=0}}class cr{constructor(e){this._conversationModule=e,this._n="ConvGroupHandler",this._convGroupMap=new Map,this._startIndex=0,this._pagingStatus=Rt.NOT_START}setConvCustomData(e){const s=this._n+".setConvCustomData",{conversationIDList:o,customData:i}=e;_e.l(s+" options:",e);const n=new Cn("setConvCustomData");n.setMessage(JSON.stringify(e));const r={fromAccount:this._getMyUserID(),itemList:[]},a=[],u=[];return o.forEach(e=>{if(!this._hasLocalConversation(e))return this._onConversationNotFound(u,e),!0;if(!it(e)&&!nt(e))return this._onConversationIDInvalid(u,e),!0;const s={operationType:2,contactItem:void 0,customMark:i};it(e)?s.contactItem={type:1,toAccount:e.replace(t.CONV_C2C,"")}:nt(e)&&(s.contactItem={type:2,groupID:e.replace(t.CONV_GROUP,"")}),r.itemList.push(s)}),u.length===o.length?xn({successConversationIDList:a,failureConversationIDList:u}):this._conversationModule.request({protocolName:No,requestData:r}).then(e=>{n.setNetworkType(this._conversationModule.getNetworkType()).end(),_e.l(s+" ok");const{resultItem:t}=e.data;if(be(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)):u.push({conversationID:e,code:t.resultCode,message:t.resultInfo})}),!0===o&&this._emitConversationUpdate()}return wn({successConversationIDList:a,failureConversationIDList:u})}).catch(e=>(this._conversationModule.probeNetwork().then(([t,s])=>{n.setError(e,t,s).end()}),_e.e(s+" failed. error:",e),Vn(e)))}markConversation(e){if(!this._conversationModule.canIUse(M.CONV_MARK))return Vn({code:nn.CANNOT_USE_COMMERCIAL_ABILITY});const s=this._n+".markConversation",{conversationIDList:o,markType:i,enableMark:n}=e;_e.l(s+" options:",e);const r=new Cn("markConversation");r.setMessage(JSON.stringify(e));let a=void 0,u=void 0;const c=this._getFlagBit(i);!0===n?u=[c]:a=[c];const l={fromAccount:this._getMyUserID(),itemList:[]},d=[],p=[];return o.forEach(e=>{if(!this._hasLocalConversation(e))return this._onConversationNotFound(p,e),!0;if(!it(e)&&!nt(e))return this._onConversationIDInvalid(p,e),!0;const s={operationType:1,contactItem:void 0,clearMark:a,setMark:u};it(e)?s.contactItem={type:1,toAccount:e.replace(t.CONV_C2C,"")}:nt(e)&&(s.contactItem={type:2,groupID:e.replace(t.CONV_GROUP,"")}),l.itemList.push(s)}),p.length===o.length?xn({successConversationIDList:d,failureConversationIDList:p}):this._conversationModule.request({protocolName:Ro,requestData:l}).then(e=>{r.setNetworkType(this._conversationModule.getNetworkType()).end(),_e.l(s+" ok");const{resultItem:t}=e.data;if(be(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 p.push({conversationID:e,code:t.resultCode,message:t.resultInfo})}),!0===o&&this._emitConversationUpdate()}return wn({successConversationIDList:d,failureConversationIDList:p})}).catch(e=>(this._conversationModule.probeNetwork().then(([t,s])=>{r.setError(e,t,s).end()}),_e.e(s+" failed. error:",e),Vn(e)))}getLocalConvGroupList(){return _e.l(`${this._n}.getLocalConvGroupList pagingStatus:${this._pagingStatus}`),this._pagingStatus===Rt.REJECTED?this.getRemoteConvGroupList().then(()=>wn([...this._convGroupMap.values()])):xn([...this._convGroupMap.values()])}getRemoteConvGroupList(){const e=this._n+".getRemoteConvGroupList";return this._pagingStatus=Rt.PENDING,this._conversationModule.request({protocolName:bo,requestData:{fromAccount:this._getMyUserID(),startIndex:this._startIndex,startTime:de()}}).then(t=>{const{completeFlag:s,contactItem:o,nextStartIndex:i=0,groupItem:n}=t.data;if(this._startIndex=i,_e.l(`${e} completeFlag:${s} nextStartIndex:${i}`),be(n)&&n.forEach(e=>{const{convGroupID:t,groupName:s}=e;this._convGroupMap.set(t,s)}),be(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=Tt(o),t.customData=i||"",be(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=Rt.RESOLVED,this._emitConversationUpdate(),this._emitConvGroupListUpdate())}).catch(t=>{this._pagingStatus=Rt.REJECTED,_e.w(e+" failed. error:",t)})}createConvGroup(e){if(!this._conversationModule.canIUse(M.CONV_GROUP))return Vn({code:nn.CANNOT_USE_COMMERCIAL_ABILITY});const s=this._n+".createConvGroup";_e.l(s+" options:",e);const o=new Cn("createConvGroup");o.setMessage(JSON.stringify(e));const{groupName:i,conversationIDList:n}=e,r={fromAccount:this._getMyUserID(),itemList:[{groupName:i,contactItem:[]}]},a=[],u=[];return n.forEach(e=>this._hasLocalConversation(e)?it(e)||nt(e)?void(it(e)?r.itemList[0].contactItem.push({type:1,toAccount:e.replace(t.CONV_C2C,"")}):nt(e)&&r.itemList[0].contactItem.push({type:2,groupID:e.replace(t.CONV_GROUP,"")})):(this._onConversationIDInvalid(u,e),!0):(this._onConversationNotFound(u,e),!0)),u.length===n.length?xn({successConversationIDList:a,failureConversationIDList:u}):this._conversationModule.request({protocolName:Oo,requestData:r}).then(e=>{o.setNetworkType(this._conversationModule.getNetworkType()).end(),_e.l(s+" ok");const{groupResultItem:t}=e.data,{groupItem:n,resultItem:r}=t[0];if(Pe(n)&&(this._convGroupMap.set(n.convGroupID,n.groupName),this._emitConvGroupListUpdate()),be(r)){let e,t,s=!1;r.forEach(o=>{e=this._concatConversationID(o.contactItem),0===o.resultCode?(a.push(e),t=this._getLocalConversation(e),t&&-1===t.conversationGroupList.indexOf(i)&&(t.conversationGroupList.push(i),s=!0)):u.push({conversationID:e,code:o.resultCode,message:o.resultInfo})}),!0===s&&(this._emitConversationUpdate(),this._emitConvGroupListUpdate())}return wn({successConversationIDList:a,failureConversationIDList:u})}).catch(e=>(this._conversationModule.probeNetwork().then(([t,s])=>{o.setError(e,t,s).end()}),_e.e(s+" failed. error:",e),Vn(e)))}deleteConvGroup(e){if(!this._conversationModule.canIUse(M.CONV_GROUP))return Vn({code:nn.CANNOT_USE_COMMERCIAL_ABILITY});const t=this._n+".deleteConvGroup";_e.l(`${t} groupName:${e}`);const s=new Cn("deleteConvGroup");return s.setMessage(e),this._conversationModule.request({protocolName:Go,requestData:{fromAccount:this._getMyUserID(),groupName:[e]}}).then(o=>{s.setNetworkType(this._conversationModule.getNetworkType()).end(),_e.l(t+" ok");const{groupItem:i}=o.data;if(be(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,o])=>{s.setError(e,t,o).end()}),_e.e(t+" failed. error:",e),Vn(e)))}renameConvGroup(e){if(!this._conversationModule.canIUse(M.CONV_GROUP))return Vn({code:nn.CANNOT_USE_COMMERCIAL_ABILITY});const t=this._n+".renameConvGroup";_e.l(t+" options:",e);const s=new Cn("renameConvGroup");s.setMessage(JSON.stringify(e));const{oldName:o,newName:i}=e;return this._conversationModule.request({protocolName:Uo,requestData:{fromAccount:this._getMyUserID(),updateType:1,updateGroup:{updateGroupType:1,oldName:o,newName:i}}}).then(e=>{s.setNetworkType(this._conversationModule.getNetworkType()).end(),_e.l(t+" ok");const{updateGroupResult:n}=e.data,{convGroupID:r}=n;this._convGroupMap.set(r,i),this._emitConvGroupListUpdate();const a=this._conversationModule.getLocalConversationList();let u,c,l=!1;a.forEach(e=>{u=e.conversationGroupList,c=u.indexOf(o),-1!==c&&(u.splice(c,1,i),l=!0)}),!0===l&&this._emitConversationUpdate()}).catch(e=>(this._conversationModule.probeNetwork().then(([t,o])=>{s.setError(e,t,o).end()}),_e.e(t+" failed. error:",e),Vn(e)))}addConvsToGroup(e){if(!this._conversationModule.canIUse(M.CONV_GROUP))return Vn({code:nn.CANNOT_USE_COMMERCIAL_ABILITY});const s=this._n+".addConvsToGroup";_e.l(s+" options:",e);const o=new Cn("addConvsToGroup");o.setMessage(JSON.stringify(e));const{conversationIDList:i,groupName:n}=e,r={fromAccount:this._getMyUserID(),updateType:1,updateGroup:{updateGroupType:2,groupName:n,updateItem:[]}},a=[],u=[];return i.forEach(e=>this._hasLocalConversation(e)?it(e)||nt(e)?void(it(e)?r.updateGroup.updateItem.push({operationType:1,contactItem:{type:1,toAccount:e.replace(t.CONV_C2C,"")}}):nt(e)&&r.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===i.length?xn({successConversationIDList:a,failureConversationIDList:u}):this._conversationModule.request({protocolName:ko,requestData:r}).then(e=>{o.setNetworkType(this._conversationModule.getNetworkType()).end(),_e.l(s+" ok");const{contactResultItem:t}=e.data.updateGroupResult;if(be(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(n)&&(s.conversationGroupList.push(n),a.push(e),o=!0)):u.push({conversationID:e,code:t.resultCode,message:t.resultInfo})}),!0===o&&(this._emitConversationUpdate(),this._emitConvInGroupUpdate(n))}return wn({successConversationIDList:a,failureConversationIDList:u})}).catch(e=>(this._conversationModule.probeNetwork().then(([t,s])=>{o.setError(e,t,s).end()}),_e.e(s+" failed. error:",e),Vn(e)))}deleteConvsFromGroup(e){if(!this._conversationModule.canIUse(M.CONV_GROUP))return Vn({code:nn.CANNOT_USE_COMMERCIAL_ABILITY});const s=this._n+".deleteConvsFromGroup";_e.l(s+" options:",e);const o=new Cn("deleteConvsFromGroup");o.setMessage(JSON.stringify(e));const{conversationIDList:i,groupName:n}=e,r={fromAccount:this._getMyUserID(),updateType:1,updateGroup:{updateGroupType:2,groupName:n,updateItem:[]}},a=[],u=[];return i.forEach(e=>this._hasLocalConversation(e)?it(e)||nt(e)?void(it(e)?r.updateGroup.updateItem.push({operationType:2,contactItem:{type:1,toAccount:e.replace(t.CONV_C2C,"")}}):nt(e)&&r.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===i.length?xn({successConversationIDList:a,failureConversationIDList:u}):this._conversationModule.request({protocolName:Po,requestData:r}).then(e=>{o.setNetworkType(this._conversationModule.getNetworkType()).end(),_e.l(s+" ok");const{contactResultItem:t}=e.data.updateGroupResult;if(be(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(n);-1!==t&&(s.conversationGroupList.splice(t,1),a.push(e),o=!0)}}else u.push({conversationID:e,code:t.resultCode,message:t.resultInfo})}),!0===o&&(this._emitConversationUpdate(),this._emitConvInGroupUpdate(n))}return wn({successConversationIDList:a,failureConversationIDList:u})}).catch(e=>(this._conversationModule.probeNetwork().then(([t,s])=>{o.setError(e,t,s).end()}),_e.e(s+" failed. error:",e),Vn(e)))}onConvMarkUpdated(e){if(Lt(e))return;let t,s;_e.d(this._n+".onConvMarkUpdated markItemList:",e);let o=!1;e.forEach(e=>{const{recentContactItem:i,optType:n,standardMark:r,customMark:a}=e;if(t=this._concatConversationID(i),s=this._getLocalConversation(t),s)if(1===n){const e=Tt(r);!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}(s.markList,e)&&(s.markList=e,o=!0)}else 2===n&&s.customData!==a&&void 0!==a&&(s.customData=a,o=!0)}),!0===o&&this._emitConversationUpdate()}onConvGroupCreated(e){_e.d(this._n+".onConvGroupCreated resultList:",e);let t=!1,s=!1;be(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(be(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){_e.d(this._n+".onConvGroupDeleted groupItemList:",e);const t=[];if(be(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(Lt(e))return;this._conversationModule.getLocalConversationList().forEach(t=>{t.conversationGroupList=t.conversationGroupList.filter(t=>!e.includes(t))}),this._emitConversationUpdate()}onConvGroupNameUpdated(e){_e.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){_e.d(this._n+".onConvInGroupUpdated options:",e);const{oldGroupName:t,recentContactUpdateGroupItem:s}=e;if(be(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){_e.d(this._n+".onConvAddedToOrDeletedFromGroup options:",e);const{msgRecentContactItem:t,msgRecentContactUpdateContactItem:s}=e,o=this._concatConversationID(t),i=this._getLocalConversation(o);if(i&&be(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){be(e)&&0!==e.length&&(_e.l(this._n+".onConvGroupListSynced groupItemList:",e),e.forEach(e=>{this._convGroupMap.set(e.convGroupID,e.groupName)}))}getConvGroupListByID(e){if(Lt(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:nn.CONVERSATION_NOT_FOUND,message:this._conversationModule.getErrorMessage(nn.CONVERSATION_NOT_FOUND)})}_onConversationIDInvalid(e,t){e.push({conversationID:t,code:nn.INVALID_CONVERSATION_ID,message:this._conversationModule.getErrorMessage(nn.INVALID_CONVERSATION_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?we(n)?we(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(){_e.l(this._n+".reset"),this._convGroupMap.clear(),this._startIndex=0,this._pagingStatus=Rt.NOT_START}}class lr extends Fs{constructor(e){super(e),this._n="ConversationModule",jn.mixin(this),this._messageListHandler=new Hn,this._messageRemindHandler=new ur(this),this._convGroupHandler=new cr(this),this.singlyLinkedList=new or(100),this._pagingStatus=Rt.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(Kn,this._initLocalConversationList,this),e.on(Yn,this._onProfileUpdated,this)}onCheckTimer(e){e%60==0&&this._messageListHandler.traversal()}_initLocalConversationList(){const e=new Cn("_initLocalConversationList");_e.l(this._n+"._initLocalConversationList");let s="";const o=this._getStorageConversationList(),i=this.isIntl();if(o){const e=o.length;for(let s=0;s<e;s++){const e=o[s];if(e){if(e.conversationID===t.CONV_C2C+"@TLS#ERROR"||e.conversationID===t.CONV_C2C+"@TLS#NOT_FOUND")continue;if(e.groupProfile){const t=e.groupProfile.type;if(et(t))continue}}this._conversationMap.set(o[s].conversationID,new ar(o[s],i))}this.emitConversationUpdate(!0,!1),s="count:"+e}else s="count:0";e.setNetworkType(this.getNetworkType()).setMessage(s).end(),this.getModule(ls)||this.triggerReady(),this.ready(()=>{this._tmpGroupList.length>0&&(this.updateConversationGroupProfile(this._tmpGroupList),this._tmpGroupList.length=0)}),this.syncConversationList()}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}=e;if(!this._isReady)return void this.ready(()=>{this._onSendOrReceiveMessage(e)});if(0===s.length)return;this._getC2CPeerReadTime(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()),this._setStorageConversationList();s.filter(e=>e.type===t.CONV_TOPIC).length>0||this.emitConversationUpdate()}updateConversationGroupProfile(e){if(be(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(gs).onMessageRevoked(i),o&&(this.emitConversationUpdate(!0,!1),this.emitTotalUnreadMessageCountUpdate())}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(gs).isLastMessageRevoked({topicID:o.replace(t.CONV_GROUP,""),sequence:i})}else s=r.isLastMessageRevoked({sequence:i,time:n});return _e.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||(Lt(n)&&(n=void 0),r.updateLastMessage(n),r.type!==t.CONV_TOPIC&&(a=!0),_e.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{conversationType:o,from:i,to:n,time:r,sequence:a,elements:u,cloudCustomData:c,messageVersion:l}=s;let d=`${o}${n}`;n===this.getMyUserID()&&o===t.CONV_C2C&&(d=`${o}${i}`);const{isUpdated:p,message:h}=this._messageListHandler.onMessageModified(d,s);!0===p&&this.emitOuterEvent(e.MESSAGE_MODIFIED,[h]);const g=this._isTopicConversation(d);if(_e.l(`${this._n}.onMessageModified isUpdated:${p} isTopicMessage:${g} from:${i} to:${n}`),g){this.getModule(gs).onMessageModified(s)}else{const e=this._conversationMap.get(d);if(e){const t=e.lastMessage;_e.d(this._n.onMessageModified+" lastMessage:",JSON.stringify(t),"options:",JSON.stringify(s)),t&&t.lastTime===r&&t.lastSequence===a&&t.version!==l&&(t.type=u[0].type,t.payload=u[0].content,t.messageForShow=It(t.type,t.payload,this.isIntl()),t.cloudCustomData=c,t.version=l,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)}),_e.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(we(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(gs),{groupAtInfoList:o}=e;t.onConversationProxy({topicID:n,groupAtInfoList:o})}if(Lt(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}_getC2CPeerReadTime(e){const s=[];if(e.forEach(e=>{this._conversationMap.has(e.conversationID)||e.type!==t.CONV_C2C||s.push(e.conversationID.replace(t.CONV_C2C,""))}),s.length>0){_e.d(`${this._n}._getC2CPeerReadTime userIDList:${s}`);const e=this.getModule(ls);e&&e.getRemotePeerReadTime(s)}}_getStorageConversationList(){return this.getModule(Ms).getItem("conversationMap")}_setStorageConversationList(){const e=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",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(){const e=new Cn("syncConversationList");return this._pagingStatus===Rt.NOT_START&&this._conversationMap.clear(),this._pagingGetConversationList().then(t=>{const s=function(e){if(!be(e)||0===e.length)return;let t=0;return e.forEach(e=>{t+=e}),(t/e.length).toFixed(0)}(this._pagingGetCostList);return _e.l(`${this._n}.syncConversationList. sum ${function(e){if(!be(e)||0===e.length)return;let t=0;return e.forEach(e=>{t+=e}),t.toFixed(0)}(this._pagingGetCostList)} ms, average ${s} ms`),this._pagingGetCostList.length=0,this._pagingStatus=Rt.RESOLVED,this._diffAndDeleteConversation(),this.emitConversationUpdate(!0,!1),this._setStorageConversationList(),this._handleC2CPeerReadTime(),this._patchConversationProperties(),e.setMessage(this._conversationMap.size).setMoreMessage(s).setNetworkType(this.getNetworkType()).end(),t}).catch(t=>(this._pagingStatus=Rt.REJECTED,e.setMessage(this._pagingTimeStamp),this.probeNetwork().then(([s,o])=>{e.setError(t,s,o).end()}),Vn(t)))}_diffAndDeleteConversation(){if(this._isSyncCompleted()){const e=[];this._conversationMap.forEach((t,s)=>{!this._pagingConvIDMap.has(s)&&this._convIDFromUnreadDBMap.has(s)&&(this._conversationMap.delete(s),e.push(s))}),_e.l(`${this._n}._diffAndDeleteConversation list:${e}`)}}_patchConversationProperties(){const e=Date.now(),t=this.checkAndPatchRemark(),s=this._messageRemindHandler.getC2CMessageRemindType(),o=this.getModule(ds).getGroupList();Promise.all([t,s,o]).then(()=>{const t=Date.now()-e;_e.l(`${this._n}._patchConversationProperties ok. cost ${t} ms`),this.emitConversationUpdate(!0,!1),this.emitTotalUnreadMessageCountUpdate()})}_pagingGetConversationList(){const e=this._n+"._pagingGetConversationList";_e.l(`${e} timeStamp:${this._pagingTimeStamp} startIndex:${this._pagingStartIndex} pinnedTimeStamp:${this._pagingPinnedTimeStamp} pinnedStartIndex:${this._pagingPinnedStartIndex}`);const t=Date.now();return this._pagingStatus=Rt.PENDING,this.request({protocolName:Do,requestData:{fromAccount:this.getMyUserID(),timeStamp:this._pagingTimeStamp,startIndex:this._pagingStartIndex,pinnedTimeStamp:this._pagingPinnedTimeStamp,pinnedStartIndex:this._pagingPinnedStartIndex,orderType:1}}).then(s=>{const{completeFlag:o,conversations:i=[],timeStamp:n,startIndex:r,pinnedTimeStamp:a,pinnedStartIndex:u,groupItem:c}=s.data,l=Date.now()-t;if(this._pagingGetCostList.push(l),_e.l(`${e} ok. completeFlag:${o} count:${i.length} cost ${l} ms`),this._convGroupHandler.onConvGroupListSynced(c),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}),this.isLoggedIn()&&this.emitConversationUpdate()}if(!this._isReady){if(!this.isLoggedIn())return xn();this.triggerReady()}return this._pagingTimeStamp=n,this._pagingStartIndex=r,this._pagingPinnedTimeStamp=a,this._pagingPinnedStartIndex=u,1!==o?this._pagingGetConversationList():(this._handleGroupAtTipsList(),this._convGroupHandler.getRemoteConvGroupList(),xn())}).catch(t=>{throw this.isLoggedIn()&&(this._isReady||(_e.w(e+" failed. error:",t),this.triggerReady())),t})}_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()),_e.d(`${this._n}._updateLocalConversationList cost ${Date.now()-o} ms`)}_getTmpConversationListMapping(e){const{conversationOptionsList:s,isFromGetConversations:o,isInstantMessage:i,isUnreadC2CMessage:n=!1,updateUnreadCount:r}=e,a=[],u=[],c=this.getModule(ds),l=this.getModule(ps),d=this.isIntl();for(let h=0,g=s.length;h<g;h++){const e=new ar(s[h],d),{conversationID:p}=e;if(p!==t.CONV_C2C+"@TLS#ERROR"&&p!==t.CONV_C2C+"@TLS#NOT_FOUND")if(this._conversationMap.has(p)){const u=this._conversationMap.get(p),c=["unreadCount","allowType","adminForbidType","payload","isPinned"];!1===i&&c.push("lastMessage");const l=s[h].lastMessage,d=!we(l);d||s[h].type===t.CONV_TOPIC||this._onLastMessageNotExist(s[h]),we(i)&&d&&null===u.lastMessage.payload&&(u.lastMessage.payload=l.payload),Lt(u.lastMessage.revoker)||(u.lastMessage.revoker=null);Be(u,e,c,[null,void 0,"",0,NaN]),!0===r&&u.updateUnreadCount({nextUnreadCount:e.unreadCount,isFromGetConversations:o,isUnreadC2CMessage:n}),i&&d&&(l.payload&&(u.lastMessage.payload=l.payload),u.type===t.CONV_GROUP&&(u.lastMessage.nameCard=l.nameCard,u.lastMessage.nick=l.nick)),d&&u.lastMessage.cloudCustomData!==l.cloudCustomData&&(u.lastMessage.cloudCustomData=l.cloudCustomData||""),this._conversationMap.delete(p),a.push([p,u])}else{if(e.type===t.CONV_GROUP&&c){const{groupID:t}=e.groupProfile,s=c.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))}u.push(e),a.push([p,e])}}const p=this.getModule(gs);return a.forEach(e=>{if(e[1].type===t.CONV_TOPIC){const{conversationID:s,unreadCount:o,groupAtInfoList:i}=e[1];p.onConversationProxy({topicID:s.replace(t.CONV_GROUP,""),unreadCount:o,groupAtInfoList:Lt(i)?void 0:i})}}),{toBeUpdatedConversationList:a,newConversationList:u}}_onLastMessageNotExist(e){new Cn("lastMessageNotExist").setMessage(""+JSON.stringify(e)).setNetworkType(this.getNetworkType()).end()}_sortConversationList(e){const t=[],s=[],o=[],i=[];return e.forEach(e=>{!0===e[1].isPinned?Lt(e[1].lastMessage.lastTime)?s.push(e):t.push(e):Lt(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(cs),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)}}),_e.l(`${this._n}._updateUserOrGroupProfile c2cUserIDList:${s} groupIDList:${o}`),s.length>0&&i.getUserProfile({userIDList:s}).then(({data:e})=>{be(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);Be(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&&"@TLS#NOT_FOUND"!==t&&"@TLS#ERROR"!==t||2===e),o=this.getMyUserID(),i=s.map(e=>{if(we(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,messageForShow:e.messageShow,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 tr(s),peerReadTime:e.c2cPeerReadTime,isPinned:1===e.isPinned,messageRemindType:"",customData:e.customMark||"",markList:Tt(e.standardMark),conversationGroupList:this._convGroupHandler.getConvGroupListByID(e.contactGroupId)}}return{conversationID:"GROUP"+e.groupID,type:"GROUP",lastMessage:{lastTime:e.time,lastSequence:e.sequence,fromAccount:e.msgGroupFromAccount,messageForShow:e.messageShow,...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 nr({groupID:e.groupID,name:e.groupNick,avatar:e.groupImage}),unreadCount:e.unreadCount,peerReadTime:0,isPinned:1===e.isPinned,messageRemindType:"",version:0,customData:e.customMark||"",markList:Tt(e.standardMark),conversationGroupList:this._convGroupHandler.getConvGroupListByID(e.contactGroupId)}});if(t.length>0){this.getModule(cs).onConversationsProfileUpdated(t)}return i}_patchTypeAndPayload(e){const{event:s,elements:o=[],groupTips:i={}}=e.lastMsg;if(!we(s)&&!Lt(i)){let e=new bn(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 bn&&this._messageListHandler.remove(e)}onConversationDeleted(e){if(!be(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});_e.l(`${this._n}.onConversationDeleted conversationIDList:${s}`),this.deleteLocalConversationList(s)}onConversationPinned(e){if(!be(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&&(_e.l(`${this._n}.onConversationPinned conversationID:${r.conversationID} isPinned:${r.isPinned}`),r.isPinned||(r.isPinned=!0,s=!0))}),s&&this._sortConversationListAndEmitEvent()}onConversationUnpinned(e){if(!be(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&&(_e.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),et(n))return _e.l(`${o} not available in avchatroom. conversationID:${e}`),xn({messageList:[],nextReqMessageID:"",isCompleted:!0});(we(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(_e.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 u={nextReqMessageID:n?"":s,messageList:a,isCompleted:n};return _e.l(`${o} ret.nextReqMessageID:${u.nextReqMessageID} ret.isCompleted:${u.isCompleted} ret.length:${a.length}`),wn(u)});this.modifyMessageList(e);const u=this._getMessageListFromMemory({conversationID:e,nextReqMessageID:t,count:s});return xn(u)}_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),_e.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((we(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 it(e)?i=s.findIndex(e=>e.ID===t):nt(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="";return o&&o.groupProfile&&(i=o.groupProfile.type),!rt(e)&&!et(i)&&(!(nt(e)&&this._isPagingGetGroupListCompleted()&&this._getLocalGroupCount()<=4e3&&!this._hasLocalGroup(e)&&!this._isTopicConversation(e))&&(t<=s&&!this._completedMap.has(e)))}_isTopicConversation(e){const s=e.replace(t.CONV_GROUP,"");return ot(s)}getHistoryMessages(e){const{conversationID:s,count:o}=e;if(s===t.CONV_SYSTEM)return xn();let i=15;o>20&&(i=20);let n=null;if(it(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:""}):Vn({code:nn.CANNOT_FIND_MODULE})}if(nt(s)){if(n=this.getModule(ds),!n)return Vn({code:nn.CANNOT_FIND_MODULE});let e=null;this._conversationMap.has(s)&&(e=this._conversationMap.get(s).lastMessage);let o=0;e&&(o=e.lastSequence);const r=this._roamingMessageSequenceMap.get(s);return n.getRoamingMessage({conversationID:s,groupID:s.replace(t.CONV_GROUP,""),count:i,sequence:r||o})}return xn()}patchConversationLastMessage(e){const t=this.getLocalConversation(e);if(!t)return;const{messageForShow:s,payload:o}=t.lastMessage;if(Lt(s)||Lt(o)){const s=this._messageListHandler.getLocalMessageList(e);if(0===s.length)return;const o=s[s.length-1];_e.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=[],u=0,c=e.length,l=null;const d=i===t.CONV_GROUP,p=this.getModule(Cs),h=this.getFileDownloadProxy();let g=()=>{u=d?e.length-1:0,c=d?0:e.length},_=()=>{d?--u:++u},m=()=>d?u>=c:u<c;for(g();m();_())if(d&&1===e[u].sequence&&o&&this.setCompleted(s),1!==e[u].isPlaceMessage)if(n=new bn(e[u]),n.to=e[u].to,i!==t.CONV_GROUP||we(e[u].topicID)||(n.to=e[u].topicID),n.isSystemMessage=!!e[u].isSystemMessage,n.conversationType=i,4===e[u].event?l={type:t.MSG_GRP_TIP,content:{...e[u].elements,groupProfile:e[u].groupProfile}}:(e[u].elements=p.parseElements(e[u].elements,e[u].from),l=e[u].elements),d||n.setNickAndAvatar({nick:e[u].nick,avatar:e[u].avatar}),Lt(l)){const t=new Cn("emptyMessageBody");t.setMessage(`from:${n.from} to:${n.to} sequence:${n.sequence} event:${e[u].event}`),t.setNetworkType(this.getNetworkType()).setLevel("warning").end()}else n.setElement(l,h),n.reInitialize(this.getMyUserID()),r.push(n);return g=_=m=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=ft(e.replace(t.CONV_GROUP,""));this.getModule(ds).hasLocalGroup(o)||(s=!0)}return s}deleteTopicRoamingMessageInfo(e){if(!st({groupID:e}))return;this._messageListHandler.getTopicConversationIDList(e).forEach(e=>{this._messageListHandler.removeByConversationID(e),this._completedMap.delete(e),this._roamingMessageSequenceMap.delete(e)})}deleteGroupRomaingMessageInfo(e){const s=`${t.CONV_GROUP}${e}`;this._messageListHandler.removeByConversationID(s),this._completedMap.delete(s),this._roamingMessageSequenceMap.delete(s)}setMessageRead({conversationID:e}){const s=this.getLocalConversation(e);if(_e.l(`${this._n}.setMessageRead conversationID:${e} unreadCount:${s?s.unreadCount:0}`),!s)return xn();if(s.type!==t.CONV_GROUP&&s.type!==t.CONV_TOPIC||Lt(s.groupAtInfoList)||this.deleteGroupAtTips(e),0===s.unreadCount)return xn();if(s.type===t.CONV_GROUP&&!this._hasLocalGroup(e))return 0!==s.unreadCount&&(s.unreadCount=0,this.emitConversationUpdate(!0,!1)),xn();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&&we(o)){const s=this.getModule(gs),o=e.replace(t.CONV_GROUP,""),i=ft(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}):Vn({code:nn.CANNOT_FIND_MODULE});case t.CONV_GROUP:case t.CONV_TOPIC:return r=this.getModule(ds),r?r.setMessageRead({conversationID:e,lastMessageSeq:n}):Vn({code:nn.CANNOT_FIND_MODULE});case t.CONV_SYSTEM:return s.unreadCount=0,this.emitConversationUpdate(!0,!1),xn();default:return xn()}}setAllMessageRead(e={}){const s=this._n+".setAllMessageRead";e.scope||(e.scope=t.READ_ALL_MSG),_e.l(s+" options:",e);const o=this._createSetAllMessageReadPack(e);if(0===o.readAllC2CMessage&&0===o.groupMessageReadInfoList.length)return xn();const i=new Cn("setAllMessageRead");return this.request({protocolName:Zo,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(),xn()}).catch(e=>(this.probeNetwork().then(([t,s])=>{i.setError(e,t,s).end()}),_e.w(s+" failed. error:",e),Vn({code:e&&e.code?e.code:nn.MESSAGE_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];we(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,_e.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,_e.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(gs),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(),_e.l(`${this._n}.clearGroupAtInfoList conversationID:${e}`),o.type===t.CONV_TOPIC){const{groupAtInfoList:s}=o,i=this.getModule(gs),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(Lt(n))return;const r=[];if(we(o)){if(!we(i)){const e=`${t.CONV_GROUP}${i}`;n.forEach(t=>{const{tinyID:s,clientTime:o,random:n,readCount:a,unreadCount:u}=t,c=`${s}-${o}-${n}`,l=this._messageListHandler.getLocalMessage(e,c),d={groupID:i,messageID:c,readCount:0,unreadCount:0};l&&(Ge(a)&&(l.readReceiptInfo.readCount=a,d.readCount=a),Ge(u)&&(l.readReceiptInfo.unreadCount=u,d.unreadCount=u),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}`,u=this._messageListHandler.getLocalMessage(e,a);if(u){u.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)}recomputeGroupUnreadCount(e){const{conversationID:t,count:s}=e,o=this.getLocalConversation(t);if(o){const e=o.unreadCount;let i=e-s;i<0&&(i=0),o.unreadCount=i,_e.l(`${this._n}.recomputeGroupUnreadCount from ${e} to ${i}, conversationID:${t}`)}}updateIsRead(e){const s=this.getLocalConversation(e),o=this.getLocalMessageList(e);if(!s||0===o.length||rt(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";_e.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((st({groupID:n})||ot(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:vo,requestData:{messageListToDelete:r.map(e=>({from:e.from,to:a,messageSeq:e.__sequence,messageRandom:e.__random,groupID:we(e.topicID)?e.groupID:e.topicID}))}}).then(()=>(_e.l(`${s} ok. count:${i.length}`),this.clearGroupAtInfoList(e,!1),Promise.resolve())).catch(e=>(_e.e(s+" failed. error:",e),Vn(e)))}appendToMessageList(e){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;Lt(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){_e.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="getConversationList",s=`${this._n}.${t}`,o=`pagingStatus:${this._pagingStatus}, local conversation count:${this._conversationMap.size}, options:${e}`;if(_e.l(`${s}. ${o}`),this._pagingStatus===Rt.REJECTED){const i=new Cn(t);return i.setMessage(o),this.syncConversationList().then(()=>{i.setNetworkType(this.getNetworkType()).end();const t=this._getConversationList(e);return wn({conversationList:t,isSyncCompleted:this._isSyncCompleted()})}).catch(e=>(this.probeNetwork().then(([t,s])=>{i.setError(e,t,s).end()}),_e.e(s+" failed. error:",e),Vn(e)))}if(0===this._conversationMap.size){const i=new Cn(t);return i.setMessage(o),this.syncConversationList().then(()=>{i.setNetworkType(this.getNetworkType()).end();const t=this._getConversationList(e);return wn({conversationList:t,isSyncCompleted:this._isSyncCompleted()})}).catch(e=>(this.probeNetwork().then(([t,s])=>{i.setError(e,t,s).end()}),_e.e(s+" failed. error:",e),Vn(e)))}const i=this._getConversationList(e);return _e.l(`${s}. returned conversation count:${i.length}`),xn({conversationList:i,isSyncCompleted:this._isSyncCompleted()})}_getConversationList(e){if(we(e))return this.getLocalConversationList();if(be(e)){if(0===e.length)return[];return this.getLocalConversationList().filter(t=>e.includes(t.conversationID))}if(Pe(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)&&(!Ue(i)||e.conversationGroupList.includes(i))&&(!Ge(o)||e.markList.includes(o)))}return[]}_handleC2CPeerReadTime(){for(const[e,s]of this._conversationMap)s.type===t.CONV_C2C&&(_e.d(`${this._n}._handleC2CPeerReadTime conversationID:${e} peerReadTime:${s.peerReadTime}`),this.recordPeerReadTime(e,s.peerReadTime))}_isPagingGetGroupListCompleted(){return this.getModule(ds).isPagingGetCompleted()}_getLocalGroupCount(){return this.getModule(ds).getLocalGroupList().length}_hasLocalGroup(e){return this.getModule(ds).hasLocalGroup(e.replace(t.CONV_GROUP,""))}getConversationProfile(e){let s;if(s=this._conversationMap.has(e)?this._conversationMap.get(e):new ar({conversationID:e,type:e.slice(0,3)===t.CONV_C2C?t.CONV_C2C:t.CONV_GROUP},this.isIntl()),s._isInfoCompleted||s.type===t.CONV_SYSTEM)return xn({conversation:s});if(nt(e)&&!this._hasLocalGroup(e))return xn({conversation:s});const o=this._n+".getConversationProfile",i=new Cn("getConversationProfile");return _e.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(ps);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,_e.l(`${o}. conversationID:${e} patch remark:${s.remark}`))}}return _e.l(`${o} ok. conversationID:${e}`),n}).catch(t=>(this.probeNetwork().then(([s,o])=>{i.setError(t,s,o).setMessage("conversationID:"+e).end()}),_e.e(o+" failed. error:",t),Vn(t)))}_updateUserOrGroupProfileCompletely(e){if(e.type===t.CONV_C2C){return this.getModule(cs).getUserProfile({userIDList:[e.toAccount]}).then(t=>{const s=t.data;return 0===s.length?Vn(new Fn({code:nn.USER_OR_GROUP_NOT_FOUND})):(e.userProfile=s[0],e._isInfoCompleted=!0,this._unshiftConversation(e),xn({conversation:e}))})}return this.getModule(ds).getGroupProfile({groupID:e.toAccount}).then(t=>(e.groupProfile=t.data.group,e._isInfoCompleted=!0,this._unshiftConversation(e),xn({conversation:e})))}_unshiftConversation(e){e instanceof ar&&!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===Rt.RESOLVED}_errorLog(e,t,s,o){const i=new Error("Params validate failed."),n=`${this.getErrorMessage("API_REFER")}${e}`;throw _e.w(`[${e}] | ${t} | ${this.getErrorMessage(s,o)}, ${n}`),_e.e(`[${e}] Invalid ${t}: type check failed for ${t}.`),i}_isValidConversationID(e){return it(e)||nt(e)||rt(e)}deleteConversation(e){const t="deleteConversation";return Ue(e)||ke(e)||this._errorLog(t,"options","StringOrObjectRequiredLog"),Ue(e)?(this._isValidConversationID(e)||this._errorLog(t,"options","InvalidConversationID",e),_e.l(`${this._n}.${t} conversationID:${e}`),this.deleteConversationList({conversationIDList:[e],flag:1})):(be(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";_e.l(`${i} conversationIDList.length:${t.length} clearHistoryMessage:${s}`);const n=new Cn("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?Vn(new Fn({code:nn.CONVERSATION_NOT_FOUND})):(_e.l(i+" ok"),xn(1===o?{conversationID:t[0]}:{conversationIDList:t}))}).catch(e=>(this.probeNetwork().then(([t,s])=>{n.setError(e,t,s).end()}),_e.e(i+" failed. error:",e),Vn(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:So,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})}clearHistoryMessage(e){const s={fromAccount:this.getMyUserID(),toAccount:void 0,type:void 0,toGroupID:void 0};if(!this._conversationMap.has(e))return Vn({code:nn.CONVERSATION_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)}),xn({conversationID:e})}return Vn({code:nn.CONVERSATION_UN_RECORDED_TYPE})}s.type=2,s.toGroupID=e.replace(t.CONV_GROUP,"")}const i=this._n+".clearHistoryMessage",n=new Cn("clearHistoryMessage");return n.setMessage("conversationID:"+e),_e.l(`${i}. conversationID:${e}`),this.setMessageRead({conversationID:e}).then(()=>this.request({protocolName:Lo,requestData:s})).then(()=>{n.setNetworkType(this.getNetworkType()).end(),_e.l(i+" ok"),this._messageListHandler.removeByConversationID(e),this.setCompleted(e);const t=this.getLocalConversation(e);return t&&(t.updateLastMessage(),this._sortConversationListAndEmitEvent()),xn({conversationID:e})}).catch(e=>(this.probeNetwork().then(([t,s])=>{n.setError(e,t,s).end()}),_e.e(i+" failed. error:",e),Vn(e)))}pinConversation(e){const{conversationID:s,isPinned:o}=e;if(!this._conversationMap.has(s))return Vn({code:nn.CONVERSATION_NOT_FOUND});const i=this.getLocalConversation(s);if(i.isPinned===o)return xn({conversationID:s});const n=this._n+".pinConversation",r=new Cn("pinConversation");r.setMessage(`conversationID:${s} isPinned:${o}`),_e.l(`${n}. conversationID:${s} isPinned:${o}`);let a=null;return it(s)?a={type:1,toAccount:s.replace(t.CONV_C2C,"")}:nt(s)&&(a={type:2,groupID:s.replace(t.CONV_GROUP,"")}),this.request({protocolName:Ao,requestData:{fromAccount:this.getMyUserID(),operationType:!0===o?1:2,itemList:[a]}}).then(()=>(r.setNetworkType(this.getNetworkType()).end(),_e.l(n+" ok"),i.isPinned!==o&&(i.isPinned=o,this._sortConversationListAndEmitEvent()),wn({conversationID:s}))).catch(e=>(this.probeNetwork().then(([t,s])=>{r.setError(e,t,s).end()}),_e.e(n+" failed. error:",e),Vn(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),_e.d(this._n+".patchMessageRemindType options:",e,"ret:"+n),n}onC2CMessageRemindTypeSynced(e){const s=this._n+".onC2CMessageRemindTypeSynced";_e.d(s,e),e.dataList.forEach(e=>{if(!Lt(e.muteNotificationsSync)){const{to:o,updateSequence:i,muteFlag:n}=e.muteNotificationsSync;let r;this._messageRemindHandler.setUpdateSequence(i),0===n?r=t.MSG_REMIND_ACPT_AND_NOTE:1===n?r=t.MSG_REMIND_DISCARD:2===n&&(r=t.MSG_REMIND_ACPT_NOT_NOTE);let a=0;this.patchMessageRemindType({ID:o,isC2CConversation:!0,messageRemindType:r})&&(a+=1),_e.l(`${s} updateCount:${a}`),a>=1&&this.emitConversationUpdate(!0,!1)}})}onGroupMessageRemindTypeSynced(e){_e.d(this._n+".onGroupMessageRemindTypeSynced options:",e),this._messageRemindHandler.onGroupMessageRemindTypeUpdated(e)}deleteLocalConversation(e,t=!0){const s=this._conversationMap.has(e);if(_e.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)}),_e.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(cs).getNickAndAvatarByUserID(this.getMyUserID());this._messageListHandler.modifyMessageSentByMe({conversationID:e,latestNick:i.nick,latestAvatar:i.avatar}),_e.l(`${this._n}.modifyMessageList conversationID:${e} cost ${Date.now()-o} ms`)}updateUserProfileSpecifiedKey(e){_e.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;Ue(s)&&e.nick!==s&&(e.nick=s),Ue(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})}),_e.l(`${this._n}._onMyProfileModified. modify all messages sent by me, cost ${Date.now()-s} ms`)}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=Promise.resolve();if(0===this._conversationMap.size)return e;const s=this.getModule(ps);if(!s)return e;const o=[...this._conversationMap.values()].filter(e=>e.type===t.CONV_C2C);if(0===o.length)return e;let i=0;return o.forEach(e=>{const o=e.conversationID.replace(t.CONV_C2C,"");if(s.isMyFriend(o)){const t=s.getFriendRemark(o);e.remark!==t&&(e.remark=t,i+=1)}}),_e.l(`${this._n}.checkAndPatchRemark. c2c conversation count:${o.length}, patched count:${i}`),e}updateTopicConversation(e){this._updateLocalConversationList({conversationOptionsList:e,isFromGetConversations:!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):Vn({code:nn.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):Vn({code:nn.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&&(_e.l(`${this._n}.emitTotalUnreadMessageCountUpdate from ${this._convTotalUnreadCount} to ${t}`),this._convTotalUnreadCount=t,this.emitOuterEvent(e.TOTAL_UNREAD_MESSAGE_COUNT_UPDATED))}reset(){_e.l(this._n+".reset"),this._pagingStatus=Rt.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.resetReady()}}class dr{constructor(e){this._groupModule=e,this._n="GroupTipsHandler",this._cachedGroupTipsMap=new Map,this._checkCountMap=new Map,this.MAX_CHECK_COUNT=4,this._getTopicPendingMap=new Map}onCheckTimer(e){e%1==0&&this._cachedGroupTipsMap.size>0&&this._checkCachedGroupTips()}_checkCachedGroupTips(){this._cachedGroupTipsMap.forEach((e,t)=>{let s=this._checkCountMap.get(t);const o=this._groupModule.hasLocalGroup(t);_e.l(`${this._n}._checkCachedGroupTips groupID:${t} hasLocalGroup:${o} checkCount:${s}`),o?(this._notifyCachedGroupTips(t),this._checkCountMap.delete(t),this._groupModule.deleteUnjoinedAVChatRoom(t)):s>=this.MAX_CHECK_COUNT?(this._deleteCachedGroupTips(t),this._checkCountMap.delete(t)):(s++,this._checkCountMap.set(t,s))})}onNewGroupTips(t){_e.d(`${this._n}.onReceiveGroupTips count:${t.dataList.length}`);const{eventDataList:s,result:o,AVChatRoomMessageList:i}=this.newGroupTipsStoredAndSummary(t);if(i.length>0&&this._groupModule.onAVChatRoomMessage(i),s.length>0){this._groupModule.updateNextMessageSeq(s);this._groupModule.getModule(_s).onNewMessage({conversationOptionsList:s,isInstantMessage:!0})}o.length>0&&(this._groupModule.emitOuterEvent(e.MESSAGE_RECEIVED,o),this.handleMessageList(o))}newGroupTipsStoredAndSummary(e){const{event:s,dataList:o}=e;let i=null;const n=[],r=[],a={},u=[];for(let c=0,l=o.length;c<l;c++){const e=Ze(o[c]);if(6===s){if(this._groupModule.isGroupAttributesUpdatedNotice(e))continue;if(this._groupModule.isGroupCountersNotice(e))continue}const{groupProfile:{groupID:l,communityType:d=0,topicID:p,invisible:h}}=e;let g=void 0;const _=this._groupModule.isMessageFromTopic(d,p);if(_){g=t.CONV_TOPIC,e.to=p;const s=this._groupModule.getModule(gs);s.hasLocalTopic(l,p)||this._getTopicPendingMap.has(p)||(this._getTopicPendingMap.set(p,1),s.getTopicList({groupID:l,topicIDList:[p]}).finally(()=>{this._getTopicPendingMap.delete(p)}))}const m=this._groupModule.hasLocalGroup(l);if(!m&&this._groupModule.isUnjoinedAVChatRoom(l))continue;if(!m&&!_){this._cacheGroupTipsAndProbe({groupID:l,event:s,item:e});continue}if(this._groupModule.isMessageFromOrToAVChatroom(l)){e.event=s,u.push(e);continue}if(e.currentUser=this._groupModule.getMyUserID(),e.conversationType=t.CONV_GROUP,i=new bn(e),i.setElement({type:t.MSG_GRP_TIP,content:{...e.elements,groupProfile:e.groupProfile}}),i.isSystemMessage=!1,1===h){this._qualityStat(i);continue}const M=this._groupModule.getModule(_s),{conversationID:f,sequence:I}=i;if(6===s)i._onlineOnlyFlag=!0,r.push(i);else{if(!M.pushIntoNoticeResult(r,i))continue}if(this._groupModule.isMessageFromCommunityOfTopic(d,p))continue;if(6===s&&M.getLocalConversation(f))continue;6!==s&&this._qualityStat(i);const C=M.isRemoteRead({conversationID:f,sequence:I});if(we(a[f])){let e=0;"in"===i.flow&&(i._isExcludedFromUnreadCount||i._onlineOnlyFlag||C||(e=1)),a[f]=n.push({conversationID:f,unreadCount:e,type:we(g)?i.conversationType:g,subType:i.conversationSubType,lastMessage:i._isExcludedFromLastMessage?"":i})-1}else{const e=a[f];n[e].type=i.conversationType,n[e].subType=i.conversationSubType,n[e].lastMessage=i._isExcludedFromLastMessage?"":i,"in"===i.flow&&(i._isExcludedFromUnreadCount||i._onlineOnlyFlag||C||n[e].unreadCount++)}}return{eventDataList:n,result:r,AVChatRoomMessageList:u}}_qualityStat(e){this._groupModule.getModule(Rs).addMessageSequence({key:hn,message:e})}handleMessageList(e){e.forEach(e=>{switch(e.payload.operationType){case 1:this._onNewMemberComeIn(e);break;case 2:this._onMemberQuit(e);break;case 3:this._onMemberKickedOut(e);break;case 4:this._onMemberSetAdmin(e);break;case 5:this._onMemberCancelledAdmin(e);break;case 6:this._onGroupProfileModified(e);break;case 7:this._onMemberInfoModified(e);break;case 8:this._onTopicProfileUpdated(e);break;default:_e.w(`${this._n}.handleMessageList unknown operationType:${e.payload.operationType}`)}})}_onNewMemberComeIn(e){const{memberNum:t,groupProfile:{groupID:s}}=e.payload,o=this._groupModule.getLocalGroupProfile(s);o&&Ge(t)&&o.memberCount!==t&&(o.memberCount=t,this._updateConversationGroupProfile(o))}_onMemberQuit(e){const{memberNum:t,groupProfile:{groupID:s}}=e.payload,o=this._groupModule.getLocalGroupProfile(s);o&&Ge(t)&&o.memberCount!==t&&(o.memberCount=t,this._updateConversationGroupProfile(o));this._groupModule.getModule(hs).deleteLocalGroupMembers(s,e.payload.userIDList)}_onMemberKickedOut(e){const{memberNum:t,groupProfile:{groupID:s}}=e.payload,o=this._groupModule.getLocalGroupProfile(s);o&&Ge(t)&&o.memberCount!==t&&(o.memberCount=t,this._updateConversationGroupProfile(o));this._groupModule.getModule(hs).deleteLocalGroupMembers(s,e.payload.userIDList)}_updateConversationGroupProfile(e){this._groupModule.getModule(_s).updateConversationGroupProfile([e])}_onMemberSetAdmin(e){const s=e.payload.groupProfile.groupID,o=e.payload.userIDList,i=this._groupModule.getModule(hs);o.forEach(e=>{const o=i.getLocalGroupMemberInfo(s,e);o&&o.updateRole(t.GRP_MBR_ROLE_ADMIN)})}_onMemberCancelledAdmin(e){const s=e.payload.groupProfile.groupID,o=e.payload.userIDList,i=this._groupModule.getModule(hs);o.forEach(e=>{const o=i.getLocalGroupMemberInfo(s,e);o&&o.updateRole(t.GRP_MBR_ROLE_MEMBER)})}_onGroupProfileModified(e){const{newGroupProfile:t,groupProfile:s}=e.payload,{groupID:o}=s,i=this._groupModule.getLocalGroupProfile(o);Object.keys(t).forEach(e=>{switch(e){case"ownerID":this._ownerChanged(i,t);break;case"groupName":i.name=t[e];break;default:i[e]=t[e]}});const n=!i.isSupportTopic;this._groupModule.emitGroupListUpdate(!0,n)}_ownerChanged({groupID:e},s){const o=this._groupModule.getLocalGroupProfile(e),i=this._groupModule.getMyUserID();if(i===s.ownerID){o.updateGroup({selfInfo:{role:t.GRP_MBR_ROLE_OWNER}});const s=this._groupModule.getModule(hs),n=s.getLocalGroupMemberInfo(e,i),r=this._groupModule.getLocalGroupProfile(e).ownerID,a=s.getLocalGroupMemberInfo(e,r);n&&n.updateRole(t.GRP_MBR_ROLE_OWNER),a&&a.updateRole(t.GRP_MBR_ROLE_MEMBER)}}_onMemberInfoModified(e){const{to:t,payload:{groupProfile:s,memberList:o}}=e,i=s.groupID;ot(t)&&this._updateTopicMuteTime(e);const n=this._groupModule.getModule(hs);o.forEach(e=>{const t=n.getLocalGroupMemberInfo(i,e.userID);t&&Ge(e.muteTime)&&t.updateMuteUntil(e.muteTime)})}_updateTopicMuteTime(t){const{to:s,payload:{groupProfile:o,memberList:i=[]}}=t,n=this._groupModule.getModule(gs),{groupID:r}=o,a=n.getLocalTopic(r,s);if(a){let t=!1;for(let e=0;e<i.length;e++){const s=i[e];if(s.userID===this._groupModule.getMyUserID()&&s.muteTime>=0){a.updateSelfInfo({muteTime:s.muteTime}),t=!0;break}}t&&this._groupModule.emitOuterEvent(e.TOPIC_UPDATED,{groupID:r,topic:a})}}_onTopicProfileUpdated(e){const{groupProfile:{groupID:t},newTopicInfo:s}=e.payload;this._groupModule.getModule(gs).onTopicProfileUpdated({groupID:t,topicID:e.to,...s})}_cacheGroupTips(e,t){this._cachedGroupTipsMap.has(e)||this._cachedGroupTipsMap.set(e,[]),this._cachedGroupTipsMap.get(e).push(t)}_deleteCachedGroupTips(e){this._cachedGroupTipsMap.has(e)&&this._cachedGroupTipsMap.delete(e)}_notifyCachedGroupTips(e){const t=this._cachedGroupTipsMap.get(e)||[];t.forEach(e=>{this.onNewGroupTips(e)}),this._deleteCachedGroupTips(e),_e.l(`${this._n}._notifyCachedGroupTips groupID:${e} count:${t.length}`)}_cacheGroupTipsAndProbe(e){const{groupID:s,event:o,item:i}=e;this._cacheGroupTips(s,{event:o,dataList:[i]}),this._groupModule.getGroupSimplifiedInfo(s).then(e=>{const{type:o}=e;o===t.GRP_AVCHATROOM?this._groupModule.hasLocalGroup(s)?this._notifyCachedGroupTips(s):this._groupModule.setUnjoinedAVChatRoom(s):(this._groupModule.updateGroupMap([e]),this._notifyCachedGroupTips(s))}),this._checkCountMap.has(s)||this._checkCountMap.set(s,0),_e.l(`${this._n}._cacheGroupTipsAndProbe groupID:${s}`)}reset(){this._cachedGroupTipsMap.clear(),this._checkCountMap.clear(),this._getTopicPendingMap.clear()}}class pr{constructor(e){this._groupModule=e,this._n="CommonGroupHandler",this.tempConversationList=null,this._cachedGroupMessageMap=new Map,this._checkCountMap=new Map,this.MAX_CHECK_COUNT=4,this._getTopicPendingMap=new Map,this._isPagingGetCompleted=!1;e.getInnerEmitterInstance().once(Kn,this._initGroupList,this)}onCheckTimer(e){e%1==0&&this._cachedGroupMessageMap.size>0&&this._checkCachedGroupMessage()}_checkCachedGroupMessage(){this._cachedGroupMessageMap.forEach((e,t)=>{let s=this._checkCountMap.get(t);const o=this._groupModule.hasLocalGroup(t);_e.l(`${this._n}._checkCachedGroupMessage groupID:${t} hasLocalGroup:${o} checkCount:${s}`),o?(this._notifyCachedGroupMessage(t),this._checkCountMap.delete(t),this._groupModule.deleteUnjoinedAVChatRoom(t)):s>=this.MAX_CHECK_COUNT?(this._deleteCachedGroupMessage(t),this._checkCountMap.delete(t)):(s++,this._checkCountMap.set(t,s))})}_initGroupList(){_e.l(this._n+"._initGroupList");const e=new Cn("getGroupListInStorage"),t=this._groupModule.getStorageGroupList();if(be(t)&&t.length>0){t.forEach(e=>{this._groupModule.initGroupMap(e)}),this._groupModule.emitGroupListUpdate(!0,!1);const s=this._groupModule.getLocalGroupList().length;e.setNetworkType(this._groupModule.getNetworkType()).setMessage("group count:"+s).end()}else e.setNetworkType(this._groupModule.getNetworkType()).setMessage("group count:0").end();_e.l(this._n+"._initGroupList ok")}handleUpdateGroupLastMessage(e){const s=this._n+".handleUpdateGroupLastMessage";if(_e.l(`${s} conversation count:${e.length}, local group count:${this._groupModule.getLocalGroupList().length}`),0===this._groupModule.getGroupMap().size)return void(this.tempConversationList=e);let o,i,n,r=!1;for(let a=0,u=e.length;a<u;a++)o=e[a],o.type===t.CONV_GROUP&&(i=o.conversationID.split(/^GROUP/)[1],n=this._groupModule.getLocalGroupProfile(i),n&&(n.lastMessage={...o.lastMessage},r=!0));r&&(this._groupModule.sortLocalGroupList(),this._groupModule.emitGroupListUpdate(!0,!1))}onNewGroupMessage(t){_e.d(`${this._n}.onNewGroupMessage count:${t.dataList.length}`);const{conversationOptionsList:s,messageList:o,AVChatRoomMessageList:i}=this._newGroupMessageStoredAndSummary(t);if(i.length>0&&this._groupModule.onAVChatRoomMessage(i),this._groupModule.filterModifiedMessage(o),s.length>0){this._groupModule.updateNextMessageSeq(s);this._groupModule.getModule(_s).onNewMessage({conversationOptionsList:s,isInstantMessage:t.isInstantMessage||!0,updateUnreadCount:t.updateUnreadCount||!0})}const n=this._groupModule.filterUnmodifiedMessage(o);n.length>0&&this._groupModule.emitOuterEvent(e.MESSAGE_RECEIVED,n),o.length=0}_newGroupMessageStoredAndSummary(e){const{dataList:s,event:o,isInstantMessage:i}=e;let n=null;const r=[],a=[],u=[],c={},l=this._groupModule.getModule(Cs),d=this._groupModule.getFileDownloadProxy(),p=s.length;p>1&&s.sort((e,t)=>e.sequence-t.sequence);for(let h=0;h<p;h++){const e=Ze(s[h]),{groupProfile:{groupID:p,communityType:g=0,topicID:_,invisible:m}}=e;let M=void 0;const f=this._groupModule.isMessageFromTopic(g,_);if(f){M=t.CONV_TOPIC,e.to=_;const s=this._groupModule.getModule(gs);s.hasLocalTopic(p,_)||this._getTopicPendingMap.has(_)||(this._getTopicPendingMap.set(_,1),s.getTopicList({groupID:p,topicIDList:[_]}).finally(()=>{this._getTopicPendingMap.delete(_)}))}const I=this._groupModule.hasLocalGroup(p);if(!I&&this._groupModule.isUnjoinedAVChatRoom(p))continue;if(!I&&!f){this._cacheGroupMessageAndProbe({groupID:p,event:o,item:e});continue}if(this._groupModule.isMessageFromOrToAVChatroom(p)){e.event=o,u.push(e);continue}if(e.currentUser=this._groupModule.getMyUserID(),e.conversationType=t.CONV_GROUP,e.isSystemMessage=!!e.isSystemMessage,n=new bn(e),e.elements=l.parseElements(e.elements,e.from),n.setElement(e.elements,d),1===m){this._qualityStat(i,n);continue}let C=1===s[h].isModified;const T=this._groupModule.getModule(_s);if(T.isMessageSentByCurrentInstance(n)?n.isModified=C:C=!1,1===e.onlineOnlyFlag)n._onlineOnlyFlag=!0,T.isMessageSentByCurrentInstance(n)||a.push(n);else{if(this._groupModule.isMessageFromCommunityOfTopic(g,_)){a.push(n);continue}if(!T.pushIntoMessageList(a,n,C))continue;this._qualityStat(i,n);const{conversationID:e,sequence:t}=n,s=T.isRemoteRead({conversationID:e,sequence:t});if(we(c[e])){let t=0;"in"===n.flow&&(n._isExcludedFromUnreadCount||s||(t=1)),c[e]=r.push({conversationID:e,unreadCount:t,type:we(M)?n.conversationType:M,subType:n.conversationSubType,lastMessage:n._isExcludedFromLastMessage?"":n})-1}else{const t=c[e];r[t].type=we(M)?n.conversationType:M,r[t].subType=n.conversationSubType,r[t].lastMessage=n._isExcludedFromLastMessage?"":n,"in"===n.flow&&(n._isExcludedFromUnreadCount||s||r[t].unreadCount++)}}}return{conversationOptionsList:r,messageList:a,AVChatRoomMessageList:u}}_qualityStat(e,t){const s=this._groupModule.getModule(Rs);s.addMessageSequence({key:hn,message:t}),e&&t.clientTime>0&&s.addMessageDelay(t.clientTime)}onGroupMessageRevoked(t){const s=this._groupModule.getModule(_s),o=[];let i=null,n=!0;t.dataList.forEach(e=>{const{revokedInfos:t}=e.elements;we(t)||t.forEach(e=>{const t=Lt(e.topicID)?"GROUP"+e.groupID:"GROUP"+e.topicID;i=s.revoke(t,e.sequence,e.random);const r=e.revokerInfo&&e.revokerInfo.revoker;if(i)i.revoker=r,o.push(i);else{const i={conversationID:t,to:e.topicID||"",sequence:e.sequence,time:e.time,revoker:r};s.isLastMessageRevoked(i)&&(o.push(i),n=!1)}})}),0!==o.length&&(s.onMessageRevoked(o),!0===n&&(_e.l(`${this._n}.onGroupMessageRevoked count:${o.length}`),this._groupModule.emitOuterEvent(e.MESSAGE_REVOKED,o)))}_groupListTreeShaking(e){const t=new Map([...this._groupModule.getGroupMap()]);for(let o=0,i=e.length;o<i;o++)t.delete(e[o].groupID);if(this._groupModule.hasJoinedAVChatRoom()){this._groupModule.getJoinedAVChatRoom().forEach(e=>{t.delete(e)})}this._groupModule.getGroupMap().forEach((e,s)=>{e.isSupportTopic&&t.delete(s)});const s=[...t.keys()];for(let o=0,i=s.length;o<i;o++)this._groupModule.deleteGroup(s[o])}getGroupList(e){const t=this._n+".getGroupList",s=new Cn("getGroupList");_e.l(""+t);const o={introduction:"Introduction",notification:"Notification",createTime:"CreateTime",ownerID:"Owner_Account",lastInfoTime:"LastInfoTime",memberNum:"MemberNum",maxMemberNum:"MaxMemberNum",joinOption:"ApplyJoinOption",inviteOption:"InviteJoinOption",muteAllMembers:"ShutUpAllMember"},i=["Type","Name","FaceUrl","NextMsgSeq","LastMsgTime","AtInfoList","LastRecallTime"],n=[];e&&e.groupProfileFilter&&e.groupProfileFilter.forEach(e=>{o[e]&&i.push(o[e])});const{isGroupWithTopicOnly:r=!1}=e||{};return this._pagingGetGroupList({limit:50,offset:0,groupBaseInfoFilter:i,groupList:n,isGroupWithTopicOnly:r}).then(()=>{_e.l(`${t} ok. count:${n.length} isGroupWithTopicOnly:${r}`),r||this._groupListTreeShaking(n),this._groupModule.updateGroupMap(n);const e=this._groupModule.getLocalGroupList().length;s.setNetworkType(this._groupModule.getNetworkType()).setMessage(`remote count:${n.length}, after tree shaking, local count:${e}, isGroupWithTopicOnly:${r}`).end(),this.tempConversationList&&(this.handleUpdateGroupLastMessage(this.tempConversationList),this.tempConversationList=null),this._groupModule.patchGroupMessageRemindType(),this._groupModule.recomputeUnreadCount(),this._groupModule.emitGroupListUpdate(!0,!r);const o=this._groupModule.getLocalGroupList();if(r){const e=o.filter(e=>!0===e.isSupportTopic);return wn({groupList:e})}return this._isPagingGetCompleted=!0,wn({groupList:o})}).catch(e=>(this._groupModule.probeNetwork().then(([t,o])=>{s.setError(e,t,o).end()}),_e.e(t+" failed. error:",e),Vn(e)))}isPagingGetCompleted(){return this._isPagingGetCompleted}_pagingGetGroupList(e){const s=this._n+"._pagingGetGroupList";let{isCommunityRelay:o=!1,isGroupWithTopicOnly:i=!1,limit:n,offset:r,groupBaseInfoFilter:a,groupList:u}=e;if(i)return this._pagingGetGroupListWithTopic({limit:n,offset:r,groupBaseInfoFilter:a,groupList:u});let c=new Cn("_pagingGetGroupList");return this._groupModule.request({protocolName:wo,requestData:{type:o?t.GRP_COMMUNITY:void 0,memberAccount:this._groupModule.getMyUserID(),limit:n,offset:r,responseFilter:{groupBaseInfoFilter:a,selfInfoFilter:["Role","JoinTime","MsgFlag","MsgSeq"]}}}).then(e=>{const{groups:t=[],totalCount:i}=e.data;u.push(...t),this._handleGroupAtInfoWithoutTopic(o,t);const l=r+n,d=!(i>l),p=`offset:${r} totalCount:${i} isCompleted:${d} currentCount:${u.length} isCommunityRelay:${o}`;return c.setNetworkType(this._groupModule.getNetworkType()).setMessage(""+p).end(),o||d?!o&&d?(_e.l(s+" start to get community list"),r=0,this._pagingGetGroupList({limit:n,offset:r,groupBaseInfoFilter:a,groupList:u,isCommunityRelay:!0})):o&&!d?(r=l,this._pagingGetGroupList({limit:n,offset:r,groupBaseInfoFilter:a,groupList:u,isCommunityRelay:!0})):(_e.l(`${s} ok. totalCount:${u.length}`),wn({groupList:u})):(r=l,this._pagingGetGroupList({limit:n,offset:r,groupBaseInfoFilter:a,groupList:u}))}).catch(e=>(11e3!==e.code&&this._groupModule.probeNetwork().then(([t,s])=>{c.setMessage("isCommunityRelay:"+o).setError(e,t,s).end()}),o?(11e3===e.code&&(c=null,_e.l(s+" ok. community unavailable")),xn({groupList:u})):Vn(e)))}_pagingGetGroupListWithTopic(e){const s=this._n+"._pagingGetGroupListWithTopic";let{limit:o,offset:i,groupBaseInfoFilter:n,groupList:r}=e;const a=new Cn("pagingGetGroupListWithTopic");return this._groupModule.request({protocolName:wo,requestData:{type:t.GRP_COMMUNITY,memberAccount:this._groupModule.getMyUserID(),limit:o,offset:i,responseFilter:{groupBaseInfoFilter:n,selfInfoFilter:["Role","JoinTime","MsgFlag","MsgSeq"]},isSupportTopic:1}}).then(e=>{const{groups:t=[],totalCount:u}=e.data;r.push(...t);const c=i+o,l=!(u>c),d=`offset:${i} totalCount:${u} isCompleted:${l} currentCount:`+r.length;return a.setNetworkType(this._groupModule.getNetworkType()).setMessage(""+d).end(),l?(_e.l(`${s} ok. totalCount:${r.length}`),wn({groupList:r})):(i=c,this._pagingGetGroupListWithTopic({limit:o,offset:i,groupBaseInfoFilter:n,groupList:r}))}).catch(e=>(this._groupModule.probeNetwork().then(([t,s])=>{a.setError(e,t,s).end()}),Vn(e)))}_cacheGroupMessage(e,t){this._cachedGroupMessageMap.has(e)||this._cachedGroupMessageMap.set(e,[]),this._cachedGroupMessageMap.get(e).push(t)}_deleteCachedGroupMessage(e){this._cachedGroupMessageMap.has(e)&&this._cachedGroupMessageMap.delete(e)}_notifyCachedGroupMessage(e){const t=this._cachedGroupMessageMap.get(e)||[];t.forEach(e=>{this.onNewGroupMessage(e)}),this._deleteCachedGroupMessage(e),_e.l(`${this._n}._notifyCachedGroupMessage groupID:${e} count:${t.length}`)}_cacheGroupMessageAndProbe(e){const{groupID:s,event:o,item:i}=e;this._cacheGroupMessage(s,{event:o,dataList:[i]}),this._groupModule.getGroupSimplifiedInfo(s).then(e=>{const{type:o}=e;o===t.GRP_AVCHATROOM?this._groupModule.hasLocalGroup(s)?this._notifyCachedGroupMessage(s):this._groupModule.setUnjoinedAVChatRoom(s):(this._groupModule.updateGroupMap([e]),this._notifyCachedGroupMessage(s))}),this._checkCountMap.has(s)||this._checkCountMap.set(s,0),_e.l(`${this._n}._cacheGroupMessageAndProbe groupID:${s}`)}_handleGroupAtInfoWithoutTopic(e,t){e&&0!==t.length&&t.forEach(e=>{const{groupID:t,groupAtInfoList:s}=e,o=[];if(!we(s)){s.forEach(e=>{o.push({...e,groupID:t})});this._groupModule.getModule(_s).onNewGroupAtTips({dataList:o})}})}reset(){this._cachedGroupMessageMap.clear(),this._checkCountMap.clear(),this._getTopicPendingMap.clear(),this._isPagingGetCompleted=!1;this._groupModule.getInnerEmitterInstance().once(Kn,this._initGroupList,this)}}const hr=1,gr=2,_r=3,mr=4,Mr=5;class fr{constructor(e){this._groupModule=e,this._n="GroupAttributesHandler",this._groupAttributesMap=new Map,this._groupAttributesCopy={},this.CACHE_EXPIRE_TIME=3e4;this._groupModule.getInnerEmitterInstance().on(Wn,this._onCloudConfigUpdated,this)}_onCloudConfigUpdated(){const e=this._groupModule.getCloudConfig("grp_attr_cache_time");we(e)||(this.CACHE_EXPIRE_TIME=Number(e))}updateLocalMainSequenceOnReconnected(){this._groupAttributesMap.forEach(e=>{e.localMainSequence=0})}isGroupAttributesUpdatedNotice(e){const{to:t,elements:{newGroupProfile:s}}=e,o=!we(s)&&!Lt(s.groupAttributeOption);return o&&this._onGroupAttributesUpdated({groupID:t,groupAttributeOption:s.groupAttributeOption}),o}_onGroupAttributesUpdated(e){const{groupID:t,groupAttributeOption:s}=e,{mainSequence:o,isWithChangedAttributeInfo:i,groupAttributeList:n=[],operationType:r}=s;if(_e.l(this._n+".onGroupAttributesUpdated. "+`groupID:${t} isWithChangedAttributeInfo:${i} operationType:${r}`),we(r))return;this._groupAttributesCopy=this._getCachedAttributes({groupID:t});const{localMainSequence:a}=this._getLocalGroupAttributes(t),u=o-a;if(0!==u){if(1===i&&1===u)return this._refreshCachedGroupAttributes({groupID:t,remoteMainSequence:o,groupAttributeList:n,operationType:r}),void this._emitGroupAttributesUpdated(t);if(this._hasLocalGroupAttributes(t)){const{avChatRoomKey:e}=this._getLocalGroupAttributes(t);this._getGroupAttributes({groupID:t,avChatRoomKey:e}).then(()=>{this._emitGroupAttributesUpdated(t)})}}}initGroupAttributesCache(e){const{groupID:t,avChatRoomKey:s}=e;this._groupAttributesMap.set(t,{lastUpdateTime:0,localMainSequence:0,remoteMainSequence:0,attributes:new Map,avChatRoomKey:s}),_e.l(`${this._n}.initGroupAttributesCache groupID:${t} avChatRoomKey:${s}`)}initGroupAttributes(e){const{groupID:t,groupAttributes:s}=e,{remoteMainSequence:o,avChatRoomKey:i}=this._getLocalGroupAttributes(t),n=new Cn("initGroupAttributes");return n.setMessage(`groupID:${t} avChatRoomKey:${i} mainSequence:${o}`),this._groupModule.request({protocolName:di,requestData:{groupID:t,avChatRoomKey:i,mainSequence:o,groupAttributeList:this._transformGroupAttributes(s)}}).then(e=>{_e.l(`${this._n}.initGroupAttributes ok. groupID:${t}`);const{mainSequence:o,groupAttributeList:i}=e.data,r=[...i];return r.forEach(e=>{e.value=s[e.key]}),this._groupAttributesCopy=this._getCachedAttributes({groupID:t}),this._refreshCachedGroupAttributes({groupID:t,remoteMainSequence:o,groupAttributeList:r,operationType:hr}),this._emitGroupAttributesUpdated(t),n.setNetworkType(this._groupModule.getNetworkType()).end(),wn({groupAttributes:s})}).catch(e=>(this._groupModule.probeNetwork().then(([t,s])=>{n.setError(e,t,s).end()}),Vn(e)))}setGroupAttributes(e){const t=this._n+".setGroupAttributes",{groupID:s,groupAttributes:o}=e,{remoteMainSequence:i,avChatRoomKey:n,attributes:r}=this._getLocalGroupAttributes(s),a=this._transformGroupAttributes(o);a.forEach(e=>{const{key:t}=e;e.sequence=0,r.has(t)&&(e.sequence=r.get(t).sequence)});const u=new Cn("setGroupAttributes");return u.setMessage(`groupID:${s} groupAttributes:${JSON.stringify(o)}`),_e.l(`${t}. groupID:${s} mainSequence:${i}`),this._groupModule.request({protocolName:pi,requestData:{groupID:s,avChatRoomKey:n,mainSequence:i,groupAttributeList:a}}).then(e=>{_e.l(t+" ok.");const{mainSequence:i,groupAttributeList:n}=e.data,r=[...n];return r.forEach(e=>{e.value=o[e.key]}),this._groupAttributesCopy=this._getCachedAttributes({groupID:s}),this._refreshCachedGroupAttributes({groupID:s,remoteMainSequence:i,groupAttributeList:r,operationType:gr}),this._emitGroupAttributesUpdated(s),u.setNetworkType(this._groupModule.getNetworkType()).end(),wn({groupAttributes:o})}).catch(e=>(this._groupModule.probeNetwork().then(([t,s])=>{u.setError(e,t,s).end()}),Vn(e)))}deleteGroupAttributes(e){const{groupID:t,keyList:s=[]}=e,{remoteMainSequence:o,avChatRoomKey:i,attributes:n}=this._getLocalGroupAttributes(t);let r=[...n.keys()],a=gi,u=_r;const c={groupID:t,avChatRoomKey:i,mainSequence:o},l=[];s.length>0&&(r=[],a=hi,u=mr,s.forEach(e=>{let t=0;n.has(e)&&(t=n.get(e).sequence,r.push(e)),l.push({key:e,sequence:t})}),c.groupAttributeList=l);const d=new Cn("deleteGroupAttributes");return d.setMessage(`groupID:${t} mainSequence:${o} keyList:${s} protocolName:${a}`),this._groupModule.request({protocolName:a,requestData:c}).then(e=>{_e.l(`${this._n}.deleteGroupAttributes ok. groupID:${t}`);const{mainSequence:s}=e.data;return this._groupAttributesCopy=this._getCachedAttributes({groupID:t}),this._refreshCachedGroupAttributes({groupID:t,remoteMainSequence:s,groupAttributeList:l,operationType:u}),this._emitGroupAttributesUpdated(t),d.setNetworkType(this._groupModule.getNetworkType()).end(),wn({keyList:r})}).catch(e=>(this._groupModule.probeNetwork().then(([t,s])=>{d.setError(e,t,s).end()}),Vn(e)))}getGroupAttributes(e){const t=this._n+".getGroupAttributes",{groupID:s}=e,{avChatRoomKey:o,lastUpdateTime:i,localMainSequence:n,remoteMainSequence:r}=this._getLocalGroupAttributes(s),a=new Cn("getGroupAttributes");if(a.setMessage(`groupID:${s} localMainSequence:${n} remoteMainSequence:${r} keyList:${e.keyList}`),Date.now()-i>=this.CACHE_EXPIRE_TIME||n<r)return this._getGroupAttributes({groupID:s,avChatRoomKey:o}).then(o=>{a.setMoreMessage("get attributes from remote. count:"+o.length).setNetworkType(this._groupModule.getNetworkType()).end(),_e.l(`${t} from remote. groupID:${s}`);const i=this._getCachedAttributes(e);return wn({groupAttributes:i})}).catch(e=>(this._groupModule.probeNetwork().then(([t,s])=>{a.setError(e,t,s).end()}),Vn(e)));a.setMoreMessage("get attributes from cache").setNetworkType(this._groupModule.getNetworkType()).end(),_e.l(`${t} from cache. groupID:${s}`);const u=this._getCachedAttributes(e);return xn({groupAttributes:u})}_getGroupAttributes(e){let t=0;return we(e.avChatRoomKey)||(t=1),this._groupModule.request({protocolName:_i,requestData:{...e,groupType:t}}).then(t=>{_e.l(`${this._n}._getGroupAttributes ok. groupID:${e.groupID}`);const{mainSequence:s,groupAttributeList:o}=t.data,i=[...o];return we(s)||this._refreshCachedGroupAttributes({groupID:e.groupID,remoteMainSequence:s,groupAttributeList:i,operationType:Mr}),o}).catch(e=>Vn(e))}_refreshCachedGroupAttributes(e){const{groupID:t,remoteMainSequence:s,groupAttributeList:o,operationType:i}=e;if(this._hasLocalGroupAttributes(t)){const e=this._getLocalGroupAttributes(t),{localMainSequence:n}=e;if(i===Mr||s-n==1)e.remoteMainSequence=s,e.localMainSequence=s,e.lastUpdateTime=Date.now(),this._updateCachedAttributes({groupAttributes:e,groupAttributeList:o,operationType:i});else{if(n===s)return;e.remoteMainSequence=s}this._groupAttributesMap.set(t,e);const r=`operationType:${i} localMainSequence:${n} remoteMainSequence:${s}`;_e.l(`${this._n}._refreshCachedGroupAttributes. ${r}`)}}_getCachedAttributes(e){const{groupID:t,keyList:s=[]}=e,o={};if(this._hasLocalGroupAttributes(t)){const{attributes:e}=this._getLocalGroupAttributes(t);if(s.length>0)s.forEach(t=>{e.has(t)&&(o[t]=e.get(t).value)});else for(const t of e.keys())o[t]=e.get(t).value}return o}_updateCachedAttributes(e){const{groupAttributes:t,groupAttributeList:s,operationType:o}=e;o!==_r?o!==mr?(o===hr&&t.attributes.clear(),s.forEach(e=>{const{key:s,value:o,sequence:i}=e;t.attributes.set(s,{value:o,sequence:i})})):s.forEach(e=>{t.attributes.delete(e.key)}):t.attributes.clear()}_hasLocalGroupAttributes(e){return this._groupAttributesMap.has(e)}_getLocalGroupAttributes(e){return this._hasLocalGroupAttributes(e)||this.initGroupAttributesCache({groupID:e}),this._groupAttributesMap.get(e)}_transformGroupAttributes(e){const t=[];return Object.keys(e).forEach(s=>{t.push({key:s,value:e[s]})}),t}_emitGroupAttributesUpdated(t){const s=this._getCachedAttributes({groupID:t}),{updatedKeyList:o,deletedKeyList:i}=this._computeAttrChangedInfo(s);_e.l(`${this._n}._emitGroupAttributesUpdated update:${o.length}, delete:${i.length}`),0===o.length&&0===i.length||this._groupModule.emitOuterEvent(e.GROUP_ATTRIBUTES_UPDATED,{groupID:t,groupAttributes:s,updatedKeyList:o,deletedKeyList:i})}_computeAttrChangedInfo(e){const t=[],s=[];return Object.keys(e).forEach(s=>{e[s]!==this._groupAttributesCopy[s]&&t.push(s)}),Object.keys(this._groupAttributesCopy).forEach(t=>{we(e[t])&&s.push(t)}),this._groupAttributesCopy={},{updatedKeyList:t,deletedKeyList:s}}deleteLocalGroupAttributes(e){this._hasLocalGroupAttributes(e)&&this._groupAttributesMap.delete(e)}reset(){this._groupAttributesMap.clear(),this._groupAttributesCopy={},this.CACHE_EXPIRE_TIME=3e4}}const Ir="Set",Cr="Increase",Tr="Decrease";class yr{constructor(e){this._groupModule=e,this._n="GroupCountersHandler",this._groupCountersMap=new Map,this.EXPIRE_TIME=3e4;this._groupModule.getInnerEmitterInstance().on(Wn,this._onCloudConfigUpdated,this)}_onCloudConfigUpdated(){const e=this._groupModule.getCloudConfig("grp_counter_expire_time");we(e)||(this.EXPIRE_TIME=Number(e))}isGroupCountersNotice(e){const{to:t,elements:{groupCounterInfo:s}}=e;let o=!1;return Lt(s)||(this._onGroupCountersUpdated({groupID:t,groupCounterInfo:s}),o=!0),o}_onGroupCountersUpdated(t){const{groupID:s,groupCounterInfo:o}=t;o.forEach(t=>{const{type:o,groupCounterSeq:i,counterList:n=[]}=t;0!==o&&2!==o||(this._updateLocalGroupCounters({groupID:s,groupCounterSeq:i,counterList:n}),n.forEach(t=>{this._groupModule.emitOuterEvent(e.GROUP_COUNTER_UPDATED,{groupID:s,key:t.key,value:t.value})})),1===o&&this._deleteLocalGroupCounters({groupID:s,groupCounterSeq:i,counterList:n})}),_e.l(`${this._n}._onGroupCountersUpdated groupID:${s}`)}initGroupCountersCache(e){const{groupID:t,avChatRoomKey:s}=e;this._groupCountersMap.set(t,{lastUpdateTime:0,groupCounterSeq:0,counters:new Map,avChatRoomKey:s}),_e.l(`${this._n}.initGroupCountersCache groupID:${t} avChatRoomKey:${s}`)}setGroupCounters(e){if(!this._groupModule.canIUse(M.GRP_COUNTER))return Vn({code:nn.CANNOT_USE_COMMERCIAL_ABILITY});const t=this._n+".setGroupCounters",{groupID:s,counters:o}=e,i=this._convertObjectToList(o),{avChatRoomKey:n}=this._getLocalGroupCounters(s),r=`groupID:${s} count:${i.length}`,a=new Cn("setGroupCounters");return a.setMessage(""+r),_e.l(`${t}. ${r}`),this._updateGroupCounters({groupID:s,counterList:i,avChatRoomKey:n,mode:Ir}).then(e=>(a.end(),_e.l(t+" ok."),wn({counters:e}))).catch(e=>(this._groupModule.probeNetwork().then(([t,s])=>{a.setError(e,t,s).end()}),_e.e(t+" failed. error:",e),Vn(e)))}increaseGroupCounter(e){if(!this._groupModule.canIUse(M.GRP_COUNTER))return Vn({code:nn.CANNOT_USE_COMMERCIAL_ABILITY});const t=this._n+".increaseGroupCounters",{groupID:s,key:o,value:i}=e,{avChatRoomKey:n}=this._getLocalGroupCounters(s),r=`groupID:${s} key:${o} value:${i}`,a=new Cn("increaseGroupCounter");a.setMessage(""+r),_e.l(`${t}. ${r}`);const u=[{key:o,value:i}];return this._updateGroupCounters({groupID:s,counterList:u,avChatRoomKey:n,mode:Cr}).then(e=>(a.end(),_e.l(t+" ok."),wn({counters:e}))).catch(e=>(this._groupModule.probeNetwork().then(([t,s])=>{a.setError(e,t,s).end()}),_e.e(t+" failed. error:",e),Vn(e)))}decreaseGroupCounter(e){if(!this._groupModule.canIUse(M.GRP_COUNTER))return Vn({code:nn.CANNOT_USE_COMMERCIAL_ABILITY});const t=this._n+".decreaseGroupCounter",{groupID:s,key:o,value:i}=e,{avChatRoomKey:n}=this._getLocalGroupCounters(s),r=`groupID:${s} key:${o} value:${i}`,a=new Cn("decreaseGroupCounter");a.setMessage(""+r),_e.l(`${t}. ${r}`);const u=[{key:o,value:i}];return this._updateGroupCounters({groupID:s,counterList:u,avChatRoomKey:n,mode:Tr}).then(e=>(a.end(),_e.l(t+" ok."),wn({counters:e}))).catch(e=>(this._groupModule.probeNetwork().then(([t,s])=>{a.setError(e,t,s).end()}),_e.e(t+" failed. error:",e),Vn(e)))}getGroupCounters(e){if(!this._groupModule.canIUse(M.GRP_COUNTER))return Vn({code:nn.CANNOT_USE_COMMERCIAL_ABILITY});const t=this._n+".getGroupCounters",{groupID:s,keyList:o=[]}=e,{avChatRoomKey:i,lastUpdateTime:n}=this._getLocalGroupCounters(s),r=new Cn("getGroupCounters");if(r.setMessage("groupID:"+s),Date.now()-n>=this.EXPIRE_TIME)return this._getRemoteGroupCounters({groupID:s,avChatRoomKey:i}).then(e=>{r.setMoreMessage("from remote. count:"+e.length).end(),_e.l(`${t} from remote. groupID:${s}`);const i=this._getLocalCounters(s,o);return wn({counters:i})}).catch(e=>(this._groupModule.probeNetwork().then(([t,s])=>{r.setError(e,t,s).end()}),Vn(e)));r.setMoreMessage("from cache").end(),_e.l(`${t} from cache. groupID:${s}`);const a=this._getLocalCounters(s,o);return xn({counters:a})}_getRemoteGroupCounters(e){return this._groupModule.request({protocolName:Ci,requestData:{...e}}).then(t=>{const{counterList:s=[],groupCounterSeq:o}=t.data;return this._updateLocalGroupCounters({groupID:e.groupID,counterList:s,groupCounterSeq:o}),_e.l(`${this._n}._getRemoteGroupCounters ok. groupID:${e.groupID}`),s}).catch(e=>Vn(e))}_convertObjectToList(e){const t=[];return Object.keys(e).forEach(s=>{t.push({key:s,value:e[s]})}),t}_updateGroupCounters(e){const t=this._n+"._updateGroupCounters",{groupID:s,avChatRoomKey:o,mode:i}=e;return _e.l(`${t}. groupID:${s} avChatRoomKey:${o} mode:${i}`),this._groupModule.request({protocolName:Ii,requestData:{...e}}).then(e=>{_e.l(t+" ok.");const{counterList:s=[]}=e.data,o={};return s.forEach(e=>{const{key:t,value:s}=e;o[t]=s}),o}).catch(e=>Vn(e))}_hasLocalGroupCounters(e){return this._groupCountersMap.has(e)}_getLocalGroupCounters(e){return this._hasLocalGroupCounters(e)||this.initGroupCountersCache({groupID:e}),this._groupCountersMap.get(e)}_updateLocalGroupCounters(e){const{groupID:t,counterList:s=[],groupCounterSeq:o}=e;if(this._hasLocalGroupCounters(t)){const{counters:e,avChatRoomKey:i,groupCounterSeq:n}=this._getLocalGroupCounters(t);if(o>0&&o<n)return;s.forEach(t=>{const{key:s,value:o}=t;e.set(s,o)}),this._groupCountersMap.set(t,{lastUpdateTime:Date.now(),groupCounterSeq:o,counters:e,avChatRoomKey:i})}}_deleteLocalGroupCounters(e){const{groupID:t,counterList:s=[],groupCounterSeq:o}=e;if(this._hasLocalGroupCounters(t)){const{counters:e,avChatRoomKey:i}=this._getLocalGroupCounters(t);s.forEach(t=>{e.delete(t.key)}),this._groupCountersMap.set(t,{lastUpdateTime:Date.now(),groupCounterSeq:o,counters:e,avChatRoomKey:i})}}_getLocalCounters(e,t){const s={};if(!this._hasLocalGroupCounters(e))return s;const{counters:o}=this._getLocalGroupCounters(e);if(t.length>0)t.forEach(e=>{o.has(e)&&(s[e]=o.get(e))});else for(const i of o.keys())s[i]=o.get(i);return s}reset(){this._groupCountersMap.clear(),this.EXPIRE_TIME=3e4}}class Dr{constructor(e){const{manager:t,groupID:s,onInit:o,onSuccess:i,onFail:n}=e;this._n="Polling",this._manager=t,this._groupModule=t._groupModule,this._onInit=o,this._onSuccess=i,this._onFail=n,this._groupID=s,this._timeoutID=-1,this._isRunning=!1,this._protocolName=ri}start(){const e=this._groupModule.isLoggedIn();e||(this._protocolName=ai),_e.l(`${this._n}.start pollingInterval:${this._manager.getPollingInterval()} isLoggedIn:${e}`),this._isRunning=!0,this._request()}isRunning(){return this._isRunning}_request(){const e=this._onInit(this._groupID);this._groupModule.request({protocolName:this._protocolName,requestData:e}).then(e=>{this._onSuccess(this._groupID,e),this.isRunning()&&(clearTimeout(this._timeoutID),this._timeoutID=setTimeout(this._request.bind(this),this._manager.getPollingInterval()))}).catch(e=>{this._onFail(this._groupID,e),this.isRunning()&&(clearTimeout(this._timeoutID),this._timeoutID=setTimeout(this._request.bind(this),this._manager.MAX_POLLING_INTERVAL))})}stop(){_e.l(this._n+".stop"),this._timeoutID>0&&(clearTimeout(this._timeoutID),this._timeoutID=-1),this._isRunning=!1}getPollingTimerID(){return this._timeoutID}}const Er={3:!0,4:!0,5:!0,6:!0,17:!0};class Sr{constructor(e){this._groupModule=e,this._n="AVChatRoomHandler",this._joinedGroupMap=new Map,this._pollingRequestInfoMap=new Map,this._pollingInstanceMap=new Map,this.sequencesLinkedList=new or(200),this.messageIDLinkedList=new or(100),this.receivedMessageCount=0,this._reportMessageStackedCount=0,this._onlineMemberCountMap=new Map,this.DEFAULT_EXPIRE_TIME=60,this.DEFAULT_POLLING_INTERVAL=300,this.MAX_POLLING_INTERVAL=2e3,this._pollingInterval=this.DEFAULT_POLLING_INTERVAL,this.DEFAULT_POLLING_NO_MESSAGE_COUNT=20,this.DEFAULT_POLLING_INTERVAL_PLUS=2e3,this._pollingNoMessageCount=0,this._startBroadcastSeq=1,this._broadcastMessageIDMap=new Map,this.DEFAULT_POLLING_SIMPLIFIED_MSG=0}hasJoinedAVChatRoom(){return this._joinedGroupMap.size>0}checkJoinedAVChatRoomByID(e){return this._joinedGroupMap.has(e)}getJoinedAVChatRoom(){return this._joinedGroupMap.size>0?[...this._joinedGroupMap.keys()]:null}_updateRequestData(e){const t=this._pollingRequestInfoMap.get(e);return e===[...this._pollingInstanceMap.keys()][0]?{...t,startBroadcastSeq:this._startBroadcastSeq,simplifiedMessage:this.DEFAULT_POLLING_SIMPLIFIED_MSG}:{...t,simplifiedMessage:this.DEFAULT_POLLING_SIMPLIFIED_MSG}}_handleSuccess(e,t){const{key:s,nextSeq:o,rspMsgList:i,errorCode:n,nextBroadcastSeq:r,broadcastMessageList:a}=t.data;if(0!==n){const s=this._pollingRequestInfoMap.get(e),o=new Cn("longPollingAVError"),i=s?`${s.key}-${s.startSeq}`:"requestInfo is undefined";o.setMessage(`${e}-${i}-${t.errorInfo}`).setCode(t.errorCode).setNetworkType(this._groupModule.getNetworkType()).end(!0)}else{if(!this.checkJoinedAVChatRoomByID(e))return;Ue(s)&&Ge(o)&&this._pollingRequestInfoMap.set(e,{key:s,startSeq:o}),Ge(r)&&r>this._startBroadcastSeq&&(this._startBroadcastSeq=r),be(i)&&i.length>0?(i.forEach(e=>{e.to=e.groupID}),this.onMessage(i)):(this._pollingNoMessageCount+=1,this._pollingNoMessageCount===this.DEFAULT_POLLING_NO_MESSAGE_COUNT&&(this._pollingInterval=this.DEFAULT_POLLING_INTERVAL+this.DEFAULT_POLLING_INTERVAL_PLUS)),this._onBroadcastMessage(a)}}_handleFailure(e,t){}onMessage(s){if(!be(s)||0===s.length)return;0!==this._pollingNoMessageCount&&(this._pollingNoMessageCount=0,this._pollingInterval=this.DEFAULT_POLLING_INTERVAL);let o=null;const i=[],n=this._getModule(_s),r=this._getModule(Rs),a=s.length;a>1&&s.sort((e,t)=>e.sequence-t.sequence);const u=this._getModule(ms);for(let e=0;e<a;e++){const a=this.restoreMessageFromSimplified(s[e]);if(!Er[a.event]){_e.w(`${this._n}.onMessage unknown event:${a.event}`);continue}if(6===a.event){if(this._groupModule.isGroupAttributesUpdatedNotice(a))continue;if(this._groupModule.isGroupCountersNotice(a))continue}this.receivedMessageCount+=1,o=this.packMessage(a,a.event);const c=1===a.isModified,l=1===a.isHistoryMessage;if(!u.isUnlimitedAVChatRoom()&&this.sequencesLinkedList.has(o.sequence))continue;if(this.messageIDLinkedList.has(o.ID))continue;const{conversationID:d}=o;if(this.receivedMessageCount%50==0?this._getModule(Ls).detectFirstRound(d,this.sequencesLinkedList.data()):this.receivedMessageCount%80==0&&this._getModule(Ls).detectSecondRound(d,this.sequencesLinkedList.data()),null!==this.sequencesLinkedList.tail()){const e=this.sequencesLinkedList.tail().value,t=o.sequence-e;t>1&&t<=20?this._getModule(Ls).onMessageMaybeLost(d,e+1,t-1):t<-1&&t>=-20&&this._getModule(Ls).onMessageMaybeLost(d,o.sequence+1,Math.abs(t)-1)}this.sequencesLinkedList.set(o.sequence),this.messageIDLinkedList.set(o.ID);let p=!1;if(this._isMessageSentByCurrentInstance(o)?c&&(p=!0,o.isModified=c,n.updateMessageIsModifiedProperty(o)):p=!0,p){if(o.conversationType===t.CONV_SYSTEM&&5===o.payload.operationType&&this._onGroupDismissed(o.payload.groupProfile.groupID),!l&&o.conversationType!==t.CONV_SYSTEM){const e=o.conversationID.replace(t.CONV_GROUP,"");this._pollingInstanceMap.has(e)?this._groupModule.isLoggedIn()&&r.addMessageSequence({key:_n,message:o}):(o.type!==t.MSG_GRP_TIP&&o.clientTime>0&&r.addMessageDelay(o.clientTime),r.addMessageSequence({key:gn,message:o}))}i.push(o)}}if(0===i.length)return;this._groupModule.filterModifiedMessage(i);const c=this.packConversationOption(i);if(c.length>0){this._getModule(_s).onNewMessage({conversationOptionsList:c,isInstantMessage:!0})}_e.d(`${this._n}.onMessage count:${i.length}`),this._checkMessageStacked(i);const l=this._groupModule.filterUnmodifiedMessage(i);l.length>0&&this._groupModule.emitOuterEvent(e.MESSAGE_RECEIVED,l),i.length=0}isBroadcastOrNormal(e){return 3===e||17===e}isGroupTip(e){return 4===e||6===e}isGroupSystemNotice(e){return 5===e}restoreGroupTipElements(e={}){e.groupJoinType||(e.groupJoinType=1);const{operatorInfo:t={},operatorID:s,userIDList:o=[]}=e,{userID:i=s,avatar:n="",nick:r=""}=t;e.operatorInfo={userID:i,avatar:n,nick:r};const a=o.map(e=>({userID:e}));return e.memberInfoList=e.memberInfoList||a,e}restoreMessageFromSimplified(e){const{event:s}=e;if(this.isBroadcastOrNormal(s)&&(e.cloudCustomData=e.cloudCustomData||"",e.elements=e.elements.map(e=>{if(e.type===t.MSG_CUSTOM){const{content:t={}}=e;e.content={data:"",description:"",extension:"",...t}}return e})),(this.isGroupTip(s)||this.isGroupSystemNotice(s))&&(e.from=e.from||"@TIM#SYSTEM"),this.isGroupTip(s)){e.elements=this.restoreGroupTipElements(e.elements);const{elements:t={}}=e,{operationType:s,operatorInfo:o={}}=t;if(1===s){const e=[{userID:o.userID}];t.memberInfoList=t.memberInfoList||e}}if(this.isGroupSystemNotice(s)){let{memberInfoList:t,operatorInfo:s={}}=e.elements;t||(t=s),e.elements.memberInfoList={userID:e.elements.operatorID,avatar:"",nick:"",...t},e.elements={authentication:"",remarkInfo:"",messageKey:1e3*e.time,...e.elements};const o=Object.keys(e.elements).filter(e=>"operatorInfo"!==e).reduce((t,s)=>({...t,[s]:e.elements[s]}),{});e.elements=o}return e}_onGroupDismissed(e){_e.l(`${this._n}._onGroupDismissed groupID:${e}`),this._groupModule.deleteLocalGroupAndConversation(e),this.reset(e)}_checkMessageStacked(e){const t="MessageStacked",s=e.length;if(s>=100&&(this._groupModule.outputWarning(t,s),this._reportMessageStackedCount<5)){new Cn(t).setNetworkType(this._groupModule.getNetworkType()).setMessage(`count:${s} groupID:${[...this._joinedGroupMap.keys()]}`).setLevel("warning").end(),this._reportMessageStackedCount+=1}}_isMessageSentByCurrentInstance(e){return!!this._getModule(_s).isMessageSentByCurrentInstance(e)}packMessage(e,s){e.currentUser=this._groupModule.getMyUserID(),e.conversationType=5===s?t.CONV_SYSTEM:t.CONV_GROUP,e.isSystemMessage=!!e.isSystemMessage;const o=new bn(e),i=this.packElements(e,s);return o.setElement(i,this._groupModule.getFileDownloadProxy()),o}packElements(e,s){if(4===s||6===s)return this._updateMemberCountByGroupTips(e),{type:t.MSG_GRP_TIP,content:{...e.elements,groupProfile:e.groupProfile}};if(5===s)return{type:t.MSG_GRP_SYS_NOTICE,content:{...e.elements,groupProfile:{...e.groupProfile,groupID:e.groupID}}};return this._getModule(Cs).parseElements(e.elements,e.from)}packConversationOption(e){const t=new Map;for(let s=0;s<e.length;s++){const o=e[s],i=o.conversationID;if(t.has(i)){const e=t.get(i);e.lastMessage=o,"in"===o.flow&&e.unreadCount++}else t.set(i,{conversationID:o.conversationID,unreadCount:"out"===o.flow?0:1,type:o.conversationType,subType:o.conversationSubType,lastMessage:o})}return[...t.values()]}_updateMemberCountByGroupTips(e){const{groupProfile:{groupID:t},elements:{onlineMemberInfo:s}}=e;if(Lt(s))return;const{onlineMemberNum:o=0,expireTime:i=this.DEFAULT_EXPIRE_TIME}=s,n=this._onlineMemberCountMap.get(t)||{},r=Date.now();Lt(n)?Object.assign(n,{lastReqTime:0,lastSyncTime:0,latestUpdateTime:r,memberCount:o,expireTime:i}):(n.latestUpdateTime=r,n.memberCount=o),_e.d(this._n+"._updateMemberCountByGroupTips info:",n),this._onlineMemberCountMap.set(t,n)}_onBroadcastMessage(t){if(Lt(t))return;const s=[],o=t.length;let i=null;for(let e=0;e<o;e++){const o=this.restoreMessageFromSimplified(t[e]);Er[o.event]?(i=this.packMessage(o,o.event),i.isBroadcastMessage=!0,this._broadcastMessageIDMap.has(i.ID)||(s.push(i),this._broadcastMessageIDMap.set(i.ID,1))):_e.w(`${this._n}._onBroadcastMessage unknown event:${o.event}`)}s.length>0&&this._groupModule.emitOuterEvent(e.MESSAGE_RECEIVED,s)}start(e){if(this._pollingInstanceMap.has(e)){const t=this._pollingInstanceMap.get(e);return void(t.isRunning()||t.start())}const t=new Dr({manager:this,groupID:e,onInit:this._updateRequestData.bind(this),onSuccess:this._handleSuccess.bind(this),onFail:this._handleFailure.bind(this)});t.start(),this._pollingInstanceMap.set(e,t),_e.l(`${this._n}.start groupID:${e}`)}handleJoinResult(e){return this._preCheck().then(()=>{const{longPollingKey:t,group:s}=e,o=s.groupID;return this._joinedGroupMap.set(o,s),this._groupModule.updateGroupMap([s]),this._groupModule.deleteUnjoinedAVChatRoom(o),this._groupModule.emitGroupListUpdate(!0,!1),we(t)?xn({status:Le,group:s}):Promise.resolve()})}startRunLoop(e){return this.handleJoinResult(e).then(()=>{const{longPollingKey:t,group:s,startSeq:o=0}=e,i=s.groupID;return this._pollingRequestInfoMap.set(i,{key:t,startSeq:o}),this.start(i),this._groupModule.isLoggedIn()?xn({status:Le,group:s}):xn({status:Le})})}_preCheck(){if(this._getModule(ms).isUnlimitedAVChatRoom())return Promise.resolve();if(!this.hasJoinedAVChatRoom())return Promise.resolve();const[e,s]=this._joinedGroupMap.entries().next().value;if(this._groupModule.isLoggedIn()){if(!(s.selfInfo.role===t.GRP_MBR_ROLE_OWNER||s.ownerID===this._groupModule.getMyUserID()))return this._groupModule.quitGroup(e);this._groupModule.deleteLocalGroupAndConversation(e)}else this._groupModule.deleteLocalGroupAndConversation(e);return this.reset(e),Promise.resolve()}joinWithoutAuth(e){const{groupID:s}=e,o=this._n+".joinWithoutAuth",i=new Cn("joinWithoutAuth");return this._groupModule.request({protocolName:Bo,requestData:e}).then(({data:{longPollingKey:e}})=>{if(this._groupModule.probeNetwork().then(([t,o])=>{i.setNetworkType(o).setMessage(`groupID:${s} longPollingKey:${e}`).end(!0)}),we(e))return Vn({code:nn.CANNOT_JOIN_NON_AVCHATROOM_WITHOUT_LOGIN});_e.l(`${o} ok. groupID:${s}`);this._getModule(_s).setCompleted(`${t.CONV_GROUP}${s}`);const n=new nr({groupID:s});return this.startRunLoop({group:n,longPollingKey:e}),wn({status:Le})}).catch(e=>(_e.e(`${o} failed. groupID:${s} error:`,e),this._groupModule.probeNetwork().then(([t,o])=>{i.setError(e,t,o).setMessage("groupID:"+s).end(!0)}),Vn(e))).finally(()=>{this._groupModule.getModule(fs).reportAtOnce()})}getGroupOnlineMemberCount(e){const t=this._onlineMemberCountMap.get(e)||{},s=Date.now();return Lt(t)||s-t.lastSyncTime>1e3*t.expireTime&&s-t.latestUpdateTime>1e4&&s-t.lastReqTime>3e3?(t.lastReqTime=s,this._onlineMemberCountMap.set(e,t),this._getGroupOnlineMemberCount(e).then(e=>wn({memberCount:e.memberCount})).catch(e=>Vn(e))):xn({memberCount:t.memberCount})}_getGroupOnlineMemberCount(e){const t=this._n+"._getGroupOnlineMemberCount";return this._groupModule.request({protocolName:ui,requestData:{groupID:e}}).then(s=>{const o=this._onlineMemberCountMap.get(e)||{},{data:{onlineMemberNum:i=0,expireTime:n=this.DEFAULT_EXPIRE_TIME}}=s;_e.l(`${t} ok. groupID:${e} memberCount:${i} expireTime:${n}`);const r=Date.now();return Lt(o)&&(o.lastReqTime=r),this._onlineMemberCountMap.set(e,Object.assign(o,{lastSyncTime:r,latestUpdateTime:r,memberCount:i,expireTime:n})),{memberCount:i}}).catch(s=>{_e.w(t+" failed. error:",s);return new Cn("_getGroupOnlineMemberCount").setCode(s.code).setMessage(`groupID:${e} error:${JSON.stringify(s)}`).setNetworkType(this._groupModule.getNetworkType()).end(),Promise.reject(s)})}_getModule(e){return this._groupModule.getModule(e)}setPollingInterval(e){we(e)||(Ge(e)?this._pollingInterval=this.DEFAULT_POLLING_INTERVAL=e:this._pollingInterval=this.DEFAULT_POLLING_INTERVAL=parseInt(e,10))}setPollingIntervalPlus(e){we(e)||(Ge(e)?this.DEFAULT_POLLING_INTERVAL_PLUS=e:this.DEFAULT_POLLING_INTERVAL_PLUS=parseInt(e,10))}setPollingNoMessageCount(e){we(e)||(Ge(e)?this.DEFAULT_POLLING_NO_MESSAGE_COUNT=e:this.DEFAULT_POLLING_NO_MESSAGE_COUNT=parseInt(e,10))}setPollingSimplifiedMessage(e){we(e)||"0"!==e&&"1"!==e||(this.DEFAULT_POLLING_SIMPLIFIED_MSG=parseInt(e,10))}getPollingInterval(){return this._pollingInterval}onAVChatRoomMemberBanned(e){const{groupID:t}=e.payload.groupProfile;_e.l(`${this._n}.onAVChatRoomMemberBanned groupID:${t}`),this._groupModule.deleteLocalGroupAndConversation(t),this.reset(t)}restartPolling(){_e.l(`${this._n}.restartPolling count:${this._pollingInstanceMap.size}`);for(const e of this._pollingInstanceMap.values())e.stop(),e.start()}getPollingTimerID(e){if(!this._pollingInstanceMap.has(e))return-1;const t=this._pollingInstanceMap.get(e).getPollingTimerID();return _e.l(`${this._n}.getPollingTimerID groupID:${e} timerID:${t}`),t}reset(e){if(e){_e.l(`${this._n}.reset groupID:${e}`);const t=this._pollingInstanceMap.get(e);t&&t.stop(),this._pollingInstanceMap.delete(e),this._joinedGroupMap.delete(e),this._pollingRequestInfoMap.delete(e),this._onlineMemberCountMap.delete(e)}else{_e.l(this._n+".reset all");for(const e of this._pollingInstanceMap.values())e.stop();this._pollingInstanceMap.clear(),this._joinedGroupMap.clear(),this._pollingRequestInfoMap.clear(),this._onlineMemberCountMap.clear(),this._broadcastMessageIDMap.clear()}this.sequencesLinkedList.reset(),this.messageIDLinkedList.reset(),this.receivedMessageCount=0,this._reportMessageStackedCount=0,this._pollingInterval=this.DEFAULT_POLLING_INTERVAL=300,this.DEFAULT_POLLING_NO_MESSAGE_COUNT=20,this.DEFAULT_POLLING_INTERVAL_PLUS=2e3,this._pollingNoMessageCount=0}}const Lr=1,Ar=15;class vr{constructor(e){this._groupModule=e,this._n="GroupSystemNoticeHandler",this.pendencyMap=new Map}onNewGroupSystemNotice(t){const{dataList:s,isSyncingEnded:o,isInstantMessage:i}=t;_e.d(`${this._n}.onReceiveSystemNotice count:${s.length}`);const{eventDataList:n,result:r}=this.newSystemNoticeStoredAndSummary({notifiesList:s,isInstantMessage:i});if(n.length>0){this._groupModule.getModule(_s).onNewMessage({conversationOptionsList:n,isInstantMessage:i}),this._onReceivedGroupSystemNotice({result:r,isInstantMessage:i})}i?r.length>0&&this._groupModule.emitOuterEvent(e.MESSAGE_RECEIVED,r):!0===o&&this._clearGroupSystemNotice()}newSystemNoticeStoredAndSummary({notifiesList:e,isInstantMessage:s}){let o=null;const i=e.length;let n=0;const r=[],a={conversationID:t.CONV_SYSTEM,unreadCount:0,type:t.CONV_SYSTEM,subType:null,lastMessage:null};for(n=0;n<i;n++){const i=e[n],{groupProfile:{communityType:u=0,topicID:c},elements:{topicIDList:l,operationType:d}}=i;if(!(2!==u||Lt(c)&&Lt(l))){if([17,18,20].includes(d)){this._handleTopicSystemNotice(i);continue}Lt(c)||(i.to=c)}if(i.elements.operationType===Ar)continue;i.currentUser=this._groupModule.getMyUserID(),i.conversationType=t.CONV_SYSTEM,i.conversationID=t.CONV_SYSTEM,o=new bn(i),o.setElement({type:t.MSG_GRP_SYS_NOTICE,content:{...i.elements,groupProfile:{...i.groupProfile}}}),o.isSystemMessage=!0,(1===o.sequence&&1===o.random||2===o.sequence&&2===o.random)&&(o.sequence=We(),o.random=We(),o.generateMessageID(),_e.l(`${this._n}.newSystemNoticeStoredAndSummary sequence and random maybe duplicated, regenerate. ID:${o.ID}`));this._groupModule.getModule(_s).pushIntoNoticeResult(r,o)&&(s?a.unreadCount++:o.setIsRead(!0),a.subType=o.conversationSubType)}return a.lastMessage=r[r.length-1],{eventDataList:r.length>0?[a]:[],result:r}}_clearGroupSystemNotice(){this._getPendencyList().then(e=>{e.forEach(e=>{this.pendencyMap.set(`${e.from}_${e.groupID}_${e.to}`,e)});const s=this._groupModule.getModule(_s).getLocalMessageList(t.CONV_SYSTEM),o=[];s.forEach(e=>{const{operatorID:t,operationType:s,groupProfile:i}=e.payload;if(s===Lr){const s=`${t}_${i.groupID}_${i.to}`,n=this.pendencyMap.get(s);n&&Ge(n.handled)&&0!==n.handled&&o.push(e)}}),this.deleteGroupSystemNotice({messageList:o})})}deleteGroupSystemNotice(e){const s=this._n+".deleteGroupSystemNotice";return be(e.messageList)&&0!==e.messageList.length?(_e.l(s+" "+e.messageList.map(e=>e.ID)),this._groupModule.request({protocolName:ni,requestData:{messageListToDelete:e.messageList.map(e=>({from:t.CONV_SYSTEM,messageSeq:e.clientSequence,messageRandom:e.random}))}}).then(()=>{_e.l(s+" ok");const t=this._groupModule.getModule(_s);return e.messageList.forEach(e=>{t.deleteLocalMessage(e)}),wn()}).catch(e=>(_e.e(s+" error:",e),Vn(e)))):xn()}_getPendencyList(e={}){const{type:t,startTime:s=0,limit:o=20}=e;return this._groupModule.request({protocolName:ii,requestData:{type:t,startTime:s,limit:o,handleAccount:this._groupModule.getMyUserID()}}).then(e=>{const t=e.data.pendencyList;return 0!==e.data.nextStartTime?this._getPendencyList({startTime:e.data.nextStartTime}).then(e=>[...t,...e]):t})}getGroupApplicationList(){return this._getPendencyList().then(e=>this._getPendencyList({type:t.GRP_COMMUNITY}).then(t=>(e.push(...t),this._handlePendencyResult(e))).catch(t=>this._handlePendencyResult(e)))}_handlePendencyResult(e){const t=[];return e.forEach(e=>{this.pendencyMap.set(`${e.from}_${e.groupID}_${e.to}`,e),0===e.handled&&t.push({applicant:e.from,applicantNick:e.fromUserNickName,groupName:e.groupName,groupID:e.groupID,authentication:e.authentication,messageKey:e.time,applicationType:e.applicationType,userID:e.userID})}),xn({applicationList:t})}_onReceivedGroupSystemNotice({result:e,isInstantMessage:t}){t&&e.forEach(e=>{switch(e.payload.operationType){case 1:break;case 2:this._onApplyGroupRequestAgreed(e);break;case 3:break;case 4:this._onMemberKicked(e);break;case 5:this._onGroupDismissed(e);break;case 6:break;case 7:this._onInviteGroup(e);break;case 8:this._onQuitGroup(e);break;case 9:this._onSetManager(e);break;case 10:this._onDeleteManager(e);break;case 11:case 12:case 15:break;case 20:this._onMessageRemindTypeSynced(e);break;case 21:this._groupModule.onAVChatRoomMemberBanned(e)}})}_onApplyGroupRequestAgreed(e){const t=e.payload.groupProfile.groupID;this._groupModule.hasLocalGroup(t)||this._groupModule.getGroupProfile({groupID:t}).then(({data:{group:e}})=>{if(e){this._groupModule.updateGroupMap([e]);const t=!e.isSupportTopic;this._groupModule.emitGroupListUpdate(!0,t)}})}_onMemberKicked(e){const t=e.payload.groupProfile.groupID;this._groupModule.hasLocalGroup(t)&&this._groupModule.deleteLocalGroupAndConversation(t)}_onGroupDismissed(e){const t=e.payload.groupProfile.groupID;this._groupModule.hasLocalGroup(t)&&this._groupModule.deleteLocalGroupAndConversation(t);const{_AVChatRoomHandler:s}=this._groupModule;s&&s.checkJoinedAVChatRoomByID(t)&&s.reset(t)}_onInviteGroup(e){const t=e.payload.groupProfile.groupID;this._groupModule.hasLocalGroup(t)||this._groupModule.getGroupProfile({groupID:t}).then(({data:{group:e}})=>{e&&(this._groupModule.updateGroupMap([e]),this._groupModule.emitGroupListUpdate())})}_onQuitGroup(e){const t=e.payload.groupProfile.groupID;this._groupModule.hasLocalGroup(t)&&this._groupModule.deleteLocalGroupAndConversation(t)}_onSetManager(e){const{to:s,groupID:o}=e.payload.groupProfile,i=this._groupModule.getModule(hs).getLocalGroupMemberInfo(o,s);i&&i.updateRole(t.GRP_MBR_ROLE_ADMIN)}_onDeleteManager(e){const{to:s,groupID:o}=e.payload.groupProfile,i=this._groupModule.getModule(hs).getLocalGroupMemberInfo(o,s);i&&i.updateRole(t.GRP_MBR_ROLE_MEMBER)}_onMessageRemindTypeSynced(e){const{groupID:t}=e.payload.groupProfile,s=e.payload.messageRemindType;this._groupModule.getModule(_s).onGroupMessageRemindTypeSynced({groupID:t,messageRemindType:s})}_handleTopicSystemNotice(e){const{groupProfile:{groupID:t,topicID:s},elements:{operationType:o,topicIDList:i,messageRemindType:n}}=e,r=this._groupModule.getModule(gs);17===o?r.onTopicCreated({groupID:t,topicID:s}):18===o?r.onTopicDeleted({groupID:t,topicIDList:i}):20===o&&r.onTopicMessageRemindTypeUpdated({groupID:t,topicID:s,messageRemindType:n})}reset(){this.pendencyMap.clear()}}class Nr extends Fs{constructor(e){super(e),this._n="GroupModule",this._commonGroupHandler=null,this._AVChatRoomHandler=null,this._groupSystemNoticeHandler=null,this._commonGroupHandler=new pr(this),this._groupAttributesHandler=new fr(this),this._groupCountersHandler=new yr(this),this._AVChatRoomHandler=new Sr(this),this._groupTipsHandler=new dr(this),this._groupSystemNoticeHandler=new vr(this),this.groupMap=new Map,this._unjoinedAVChatRoomList=new Map,this._receiptDetailCompleteMap=new Map;this.getInnerEmitterInstance().on(Wn,this._onCloudConfigUpdated,this)}_onCloudConfigUpdated(){const e=this.getCloudConfig("polling_interval"),t=this.getCloudConfig("polling_interval_plus"),s=this.getCloudConfig("polling_no_msg_count"),o=this.getCloudConfig("polling_simplified_msg");this._AVChatRoomHandler&&(_e.l(`${this._n}._onCloudConfigUpdated pollingInterval:${e} pollingIntervalPlus:${t} pollingNoMessageCount:${s} pollingSimplifiedMessage:`+o),this._AVChatRoomHandler.setPollingInterval(e),this._AVChatRoomHandler.setPollingIntervalPlus(t),this._AVChatRoomHandler.setPollingNoMessageCount(s),this._AVChatRoomHandler.setPollingSimplifiedMessage(o))}onCheckTimer(e){this.isLoggedIn()&&(this._commonGroupHandler.onCheckTimer(e),this._groupTipsHandler.onCheckTimer(e))}guardForAVChatRoom(e){if(e.conversationType===t.CONV_GROUP){const s=ot(e.to)?ft(e.to):e.to;return this.hasLocalGroup(s)?xn():this.getGroupProfile({groupID:s}).then(o=>{const i=o.data.group.type;if(_e.l(`${this._n}.guardForAVChatRoom. groupID:${s} type:${i}`),i===t.GRP_AVCHATROOM){const t=nn.MESSAGE_SEND_FAIL_NOT_IN_AVCHATROOM;return Vn(new Fn({code:t,message:this.getErrorMessage(t,e.from,s),data:{message:e}}))}return xn()})}return xn()}checkJoinedAVChatRoomByID(e){return!!this._AVChatRoomHandler&&this._AVChatRoomHandler.checkJoinedAVChatRoomByID(e)}onNewGroupMessage(e){this._commonGroupHandler&&this._commonGroupHandler.onNewGroupMessage(e)}updateNextMessageSeq(e){if(be(e)){const s=this.getModule(gs);e.forEach(e=>{const o=e.conversationID.replace(t.CONV_GROUP,"");ot(o)&&s.updateLastMessage(o,e.lastMessage),this.groupMap.has(o)&&(this.groupMap.get(o).nextMessageSeq=e.lastMessage.sequence+1)})}}onNewGroupTips(e){this._groupTipsHandler&&this._groupTipsHandler.onNewGroupTips(e)}onGroupMessageRevoked(e){this._commonGroupHandler&&this._commonGroupHandler.onGroupMessageRevoked(e)}onNewGroupSystemNotice(e){this._groupSystemNoticeHandler&&this._groupSystemNoticeHandler.onNewGroupSystemNotice(e)}onGroupMessageReadNotice(e){e.dataList.forEach(e=>{const{groupMessageReadNotice:s}=e.elements;if(!we(s)){const e=this.getModule(_s);s.forEach(s=>{const{groupID:o,topicID:i,lastMessageSeq:n}=s;_e.d(`${this._n}.onGroupMessageReadNotice groupID:${o} lastMessageSeq:${n}`);let r=`${t.CONV_GROUP}${o}`,a=!0;Lt(i)||(r=`${t.CONV_GROUP}${i}`,a=!1),e.updateIsReadAfterReadReport({conversationID:r,lastMessageSeq:n}),e.updateUnreadCount(r,a),e.clearGroupAtInfoList(r,a)})}})}onReadReceiptList(e){_e.d(this._n+".onReadReceiptList options:",JSON.stringify(e)),e.dataList.forEach(e=>{const{groupProfile:t,elements:s}=e,{groupID:o}=t,i=this.getModule(_s),{readReceiptList:n}=s;i.updateReadReceiptInfo({groupID:o,readReceiptList:n})})}onGroupMessageModified(e){_e.d(this._n+".onGroupMessageModified options:",JSON.stringify(e));const s=this.getModule(_s);e.dataList.forEach(e=>{s.onMessageModified({...e,conversationType:t.CONV_GROUP,to:e.topicID?e.topicID:e.groupID})})}deleteGroupSystemNotice(e){this._groupSystemNoticeHandler&&this._groupSystemNoticeHandler.deleteGroupSystemNotice(e)}initGroupMap(e){this.groupMap.set(e.groupID,new nr(e))}deleteGroup(e){this.groupMap.delete(e)}updateGroupMap(e){const t=this.getModule(_s);let s;e.forEach(e=>{s=e.groupID,this.groupMap.has(s)?this.groupMap.get(s).updateGroup(e):(this.groupMap.set(s,new nr(e)),t.deleteGroupRomaingMessageInfo(s))});const o=this.getMyUserID();for(const[,i]of this.groupMap)i.selfInfo.userID=o,"Owner"===i.selfInfo.role&&(i.ownerID=o);this._setStorageGroupList()}getStorageGroupList(){return this.getModule(Ms).getItem("groupMap")}_setStorageGroupList(){const e=this.getLocalGroupList().filter(({type:e})=>!et(e)).filter(({isSupportTopic:e})=>!e).slice(0,20).map(({groupID:e,name:t,avatar:s,type:o})=>({groupID:e,name:t,avatar:s,type:o}));this.getModule(Ms).setItem("groupMap",e)}getGroupMap(){return this.groupMap}getLocalGroupList(){return[...this.groupMap.values()]}getLocalGroupProfile(e){return this.groupMap.get(e)}sortLocalGroupList(){const e=[...this.groupMap].filter(([e,t])=>!Lt(t.lastMessage));e.sort((e,t)=>t[1].lastMessage.lastTime-e[1].lastMessage.lastTime),this.groupMap=new Map([...e])}updateGroupLastMessage(e){this._commonGroupHandler&&this._commonGroupHandler.handleUpdateGroupLastMessage(e)}emitGroupListUpdate(t=!0,s=!0){const o=this.getLocalGroupList();if(t&&this.emitOuterEvent(e.GROUP_LIST_UPDATED),s){const e=JSON.parse(JSON.stringify(o));this.getModule(_s).updateConversationGroupProfile(e)}}patchGroupMessageRemindType(){const e=this.getLocalGroupList(),t=this.getModule(_s);let s=0;e.forEach(e=>{!0===t.patchMessageRemindType({ID:e.groupID,isC2CConversation:!1,messageRemindType:e.selfInfo.messageRemindType})&&(s+=1)}),_e.l(`${this._n}.patchGroupMessageRemindType count:${s}`)}recomputeUnreadCount(){const e=this.getLocalGroupList(),s=this.getModule(_s);e.forEach(e=>{const{groupID:o}=e,{excludedUnreadSequenceList:i,readedSequence:n}=e.selfInfo;if(be(i)){let r=0;i.forEach(t=>{t>=n&&t<=e.nextMessageSeq-1&&(r+=1)}),r>=1&&s.recomputeGroupUnreadCount({conversationID:`${t.CONV_GROUP}${o}`,count:r})}})}getMyNameCardByGroupID(e){const t=this.getLocalGroupProfile(e);return t?t.selfInfo.nameCard:""}isPagingGetCompleted(){return!!this._commonGroupHandler&&this._commonGroupHandler.isPagingGetCompleted()}getGroupList(e){return this._commonGroupHandler?this._commonGroupHandler.getGroupList(e):xn()}getGroupProfile(e){const t=this._n+".getGroupProfile",s=new Cn("getGroupProfile"),{groupID:o,groupCustomFieldFilter:i}=e;_e.l(`${t} groupID:${o}`);const n={groupIDList:[o],responseFilter:{groupBaseInfoFilter:["Type","Name","Introduction","Notification","FaceUrl","Owner_Account","CreateTime","InfoSeq","LastInfoTime","LastMsgTime","MemberNum","MaxMemberNum","ApplyJoinOption","NextMsgSeq","ShutUpAllMember","InviteJoinOption"],groupCustomFieldFilter:i,memberInfoFilter:["Role","JoinTime","MsgSeq","MsgFlag","NameCard"]}};return this.getGroupProfileAdvance(n).then(({data:{successGroupList:e,failureGroupList:i}})=>{if(_e.l(t+" ok"),i.length>0)return Vn(i[0]);let n;if(et(e[0].type)&&!this.hasLocalGroup(o)?n=new nr(e[0]):(this.updateGroupMap(e),n=this.getLocalGroupProfile(o)),!n.isSupportTopic){this.getModule(_s).updateConversationGroupProfile([n])}return s.setNetworkType(this.getNetworkType()).setMessage(`groupID:${o} type:${n.type} muteAllMembers:${n.muteAllMembers} ownerID:${n.ownerID}`).end(),wn({group:n})}).catch(o=>(this.probeNetwork().then(([t,i])=>{s.setError(o,t,i).setMessage("groupID:"+e.groupID).end()}),_e.e(t+" failed. error:",o),Vn(o)))}getGroupProfileAdvance(e){const t=this._n+".getGroupProfileAdvance",{groupIDList:s}=e;be(s)&&s.length>50&&(this.outputWarning("GetGroupProfileLimit"),s.length=50);const o=[],i=[];s.forEach(e=>{st({groupID:e})?i.push(e):o.push(e)});const n=[];if(o.length>0){const t=this._getGroupProfileAdvance({...e,groupIDList:o});n.push(t)}if(i.length>0){const t=this._getGroupProfileAdvance({...e,groupIDList:i,relayFlag:o.length>0});n.push(t)}return Promise.all(n).then(e=>{const t=[],s=[];return e.forEach(e=>{t.push(...e.successGroupList),s.push(...e.failureGroupList)}),wn({successGroupList:t,failureGroupList:s})}).catch(e=>(_e.e(t+" failed. error:",e),Vn(e)))}_getGroupProfileAdvance(e){const{relayFlag:t=!1,...s}=e;return this.request({protocolName:Fo,requestData:s}).then(e=>{_e.l(this._n+"._getGroupProfileAdvance ok.");const{groups:t}=e.data;return{successGroupList:t.filter(e=>we(e.errorCode)||0===e.errorCode),failureGroupList:t.filter(e=>e.errorCode&&0!==e.errorCode).map(e=>new Fn({code:e.errorCode,message:e.errorInfo,data:{groupID:e.groupID}}))}}).catch(s=>t&&st({groupID:e.groupIDList[0]})?{successGroupList:[],failureGroupList:[]}:Vn(s))}createGroup(e){const s=this._n+".createGroup",{type:o,groupID:i}=e;if(e.name&&!1===this._filterProfanity("name",e))return Vn({code:nn.PROFANITY_FOUND});if(e.introduction&&!1===this._filterProfanity("introduction",e))return Vn({code:nn.PROFANITY_FOUND});if(e.notification&&!1===this._filterProfanity("notification",e))return Vn({code:nn.PROFANITY_FOUND});if(!["Public","Private","ChatRoom","AVChatRoom","Community"].includes(o))return Vn({code:nn.ILLEGAL_GROUP_TYPE});if(!st({type:o})){if(!Lt(i)&&st({groupID:i}))return Vn({code:nn.ILLEGAL_GROUP_ID});e.isSupportTopic=void 0}if(et(o)&&!we(e.memberList)&&e.memberList.length>0&&(e.memberList=void 0),this._canIUseJoinOption(o)||we(e.joinOption)||(e.joinOption=void 0),st({type:o})){if(!Lt(i)&&!st({groupID:i}))return Vn({code:nn.ILLEGAL_GROUP_ID});e.isSupportTopic=!0===e.isSupportTopic?1:0}const n=new Cn("createGroup");_e.l(s+" options:",e);let r=null,a=[];return this.request({protocolName:$o,requestData:{...e,ownerID:this.getMyUserID(),webPushFlag:1}}).then(o=>{const{groupID:i,overLimitUserIDList:u=[]}=o.data;if(r=i,a=u,n.setNetworkType(this.getNetworkType()).setMessage(`groupType:${e.type} groupID:${i} overLimitUserIDList=${u}`).end(),_e.l(`${s} ok groupID:${i} overLimitUserIDList:`,u),e.type===t.GRP_AVCHATROOM)return this.getGroupProfile({groupID:i});if(e.type===t.GRP_COMMUNITY&&1===e.isSupportTopic)return this.getGroupProfile({groupID:i});Lt(e.memberList)||Lt(u)||(e.memberList=e.memberList.filter(e=>-1===u.indexOf(e.userID))),this.updateGroupMap([{...e,groupID:i}]);const c=this.getModule(as),l=c.createCustomMessage({to:i,conversationType:t.CONV_GROUP,payload:{data:"group_create",extension:this.isIntl()?this.getMyUserID()+" created a group":this.getMyUserID()+"创建群组"}});return c.sendMessageInstance(l),this.emitGroupListUpdate(),this.getGroupProfile({groupID:i})}).then(e=>{const{group:s}=e.data,{nameCard:o,joinTime:i}=s.selfInfo;return s.updateSelfInfo({nameCard:o,joinTime:i,messageRemindType:t.MSG_REMIND_ACPT_AND_NOTE,role:t.GRP_MBR_ROLE_OWNER}),wn({group:s,overLimitUserIDList:a})}).catch(t=>{if(n.setMessage("groupType:"+e.type),this.probeNetwork().then(([e,s])=>{n.setError(t,e,s).end()}),10010===t.code||10007===t.code){this.updateGroupMap([{...e,groupID:r}]);const t=this.getLocalGroupProfile(r);return _e.l(s+" success, but failed to get group profile."),wn({group:t,overLimitUserIDList:a})}return _e.e(s+" failed. error:",t),Vn(t)})}dismissGroup(e){const s=this._n+".dismissGroup";if(this.hasLocalGroup(e)&&this.getLocalGroupProfile(e).type===t.GRP_WORK)return Vn(new Fn({code:nn.CANNOT_DISMISS_WORK}));const o=new Cn("dismissGroup");return o.setMessage("groupID:"+e),_e.l(`${s} groupID:${e}`),this.request({protocolName:qo,requestData:{groupID:e}}).then(()=>(o.setNetworkType(this.getNetworkType()).end(),_e.l(s+" ok"),this.deleteLocalGroupAndConversation(e),this.checkJoinedAVChatRoomByID(e)&&this._AVChatRoomHandler.reset(e),this._groupAttributesHandler.deleteLocalGroupAttributes(e),wn({groupID:e}))).catch(e=>(this.probeNetwork().then(([t,s])=>{o.setError(e,t,s).end()}),_e.e(s+" failed. error:",e),Vn(e)))}updateGroupProfile(e){const t=this._n+".updateGroupProfile";if(this.hasLocalGroup(e.groupID)){const s=this.getLocalGroupProfile(e.groupID).type;this._canIUseJoinOption(s)||we(e.joinOption)||(_e.w(t+" joinOption is unavailable for Work/Meeting/AVChatRoom"),e.joinOption=void 0)}if(we(e.muteAllMembers)||(e.muteAllMembers?e.muteAllMembers="On":e.muteAllMembers="Off"),e.name&&!1===this._filterProfanity("name",e))return Vn({code:nn.PROFANITY_FOUND});if(e.introduction&&!1===this._filterProfanity("introduction",e))return Vn({code:nn.PROFANITY_FOUND});if(e.notification&&!1===this._filterProfanity("notification",e))return Vn({code:nn.PROFANITY_FOUND});const s=new Cn("updateGroupProfile");return s.setMessage(JSON.stringify(e)),_e.l(`${t} groupID:${e.groupID}`),this.request({protocolName:xo,requestData:e}).then(()=>{if(s.setNetworkType(this.getNetworkType()).end(),_e.l(t+" ok"),this.hasLocalGroup(e.groupID)){this.groupMap.get(e.groupID).updateGroup(e),this._setStorageGroupList()}return wn({group:this.groupMap.get(e.groupID)})}).catch(e=>(this.probeNetwork().then(([t,o])=>{s.setError(e,t,o).end()}),_e.l(t+" failed. error:",e),Vn(e)))}_filterProfanity(e,t){const s=this.getModule(Us);if(!s)return!0;const{isAllowedToSend:o,modifiedText:i}=s.filterText(t[e],E);return!0===o&&(t[e]=i,!0)}joinGroup(e){const{groupID:s,type:o}=e,i=this._n+".joinGroup";if(o===t.GRP_WORK)return Vn({code:nn.CANNOT_JOIN_WORK});if(this.deleteUnjoinedAVChatRoom(s),this.hasLocalGroup(s)){if(!this.isLoggedIn())return xn({status:t.JOIN_STATUS_ALREADY_IN_GROUP});const o=new Cn("applyJoinGroup");return this.getGroupProfile({groupID:s}).then(()=>(o.setNetworkType(this.getNetworkType()).setMessage(`groupID:${s} joinedStatus:${t.JOIN_STATUS_ALREADY_IN_GROUP}`).end(),xn({status:t.JOIN_STATUS_ALREADY_IN_GROUP}))).catch(t=>(o.setNetworkType(this.getNetworkType()).setMessage(`groupID:${s} unjoined`).end(),_e.w(`${i} ${s} was unjoined, now join!`),this.groupMap.delete(s),this.applyJoinGroup(e)))}return _e.l(`${i} groupID:${s}`),this.isLoggedIn()?this.applyJoinGroup(e):this._AVChatRoomHandler.joinWithoutAuth(e)}applyJoinGroup(e){const t=this._n+".applyJoinGroup",{groupID:s,applyMessage:o}=e;if(!Lt(o)&&!1===this._filterProfanity("applyMessage",e))return Vn({code:nn.PROFANITY_FOUND});const i=new Cn("applyJoinGroup"),n={...e},r=this.canIUse(M.AVCHATROOM_HISTORY_MSG);r&&(n.historyMessageFlag=1);return this.getModule(_s).deleteTopicRoamingMessageInfo(s),this.request({protocolName:Vo,requestData:n}).then(({data:{joinedStatus:e,longPollingKey:o,startSeq:n,avChatRoomFlag:a,avChatRoomKey:u,messageList:c}})=>{const l=`groupID:${s} joinedStatus:${e} longPollingKey:${o} startSeq:${n} avChatRoomFlag:${a} canGetAVChatRoomHistoryMessage:${r}, history message count:`+(Lt(c)?0:c.length);switch(i.setNetworkType(this.getNetworkType()).setMessage(""+l).end(),_e.l(`${t} ok. ${l}`),e){case Ae:return wn({status:Ae});case Le:return this.getGroupProfile({groupID:s}).then(({data:{group:e}})=>this._handleJoinResult({group:e,avChatRoomFlag:a,longPollingKey:o,startSeq:n,avChatRoomKey:u,messageList:c})).catch(()=>{const e=new nr({groupID:s});return this._handleJoinResult({group:e,avChatRoomFlag:a,longPollingKey:o,startSeq:n,avChatRoomKey:u,messageList:c})});default:{const e=new Fn({code:nn.JOIN_GROUP_FAIL});return _e.e(t+" failed. error:",e),Vn(e)}}}).catch(e=>(i.setMessage("groupID:"+s),this.probeNetwork().then(([t,s])=>{i.setError(e,t,s).end()}),_e.e(t+" failed. error:",e),Vn(e)))}_handleJoinResult(e){const{group:s,avChatRoomFlag:o,longPollingKey:i,startSeq:n,avChatRoomKey:r,messageList:a}=e,{groupID:u}=s;if(1===o){let e;return this.getModule(_s).setCompleted(`${t.CONV_GROUP}${u}`),this._groupAttributesHandler.initGroupAttributesCache({groupID:u,avChatRoomKey:r}),this._groupCountersHandler.initGroupCountersCache({groupID:u,avChatRoomKey:r}),e=we(i)?this._AVChatRoomHandler.handleJoinResult({group:s}):this._AVChatRoomHandler.startRunLoop({group:s,longPollingKey:i,startSeq:n}),e.then(()=>{this._onAVChatRoomHistoryMessage(a)}),e}return this.emitGroupListUpdate(!0,!1),wn({status:Le,group:s})}quitGroup(e){const t=this._n+".quitGroup";_e.l(`${t} groupID:${e}`);const s=this.checkJoinedAVChatRoomByID(e);if(!s&&!this.hasLocalGroup(e))return Vn({code:nn.MEMBER_NOT_IN_GROUP});if(s&&!this.isLoggedIn())return _e.l(`${t} anonymously ok. groupID:${e}`),this.deleteLocalGroupAndConversation(e),this._AVChatRoomHandler.reset(e),xn({groupID:e});const o=new Cn("quitGroup");return o.setMessage("groupID:"+e),this.request({protocolName:Ho,requestData:{groupID:e}}).then(()=>(o.setNetworkType(this.getNetworkType()).end(),_e.l(t+" ok"),this.deleteLocalGroupAndConversation(e),s&&this._AVChatRoomHandler.reset(e),this._groupAttributesHandler.deleteLocalGroupAttributes(e),wn({groupID:e}))).catch(e=>(this.probeNetwork().then(([t,s])=>{o.setError(e,t,s).end()}),_e.e(t+" failed. error:",e),Vn(e)))}searchGroupByID(e){const t=this._n+".searchGroupByID",s={groupIDList:[e]},o=new Cn("searchGroupByID");return o.setMessage("groupID:"+e),_e.l(`${t} groupID:${e}`),this.request({protocolName:Ko,requestData:s}).then(({data:{groupProfile:e}})=>{if(0!==e[0].errorCode)throw new Fn({code:e[0].errorCode,message:e[0].errorInfo});return o.setNetworkType(this.getNetworkType()).end(),_e.l(t+" ok"),wn({group:new nr(e[0])})}).catch(e=>(this.probeNetwork().then(([t,s])=>{o.setError(e,t,s).end()}),_e.w(t+" failed. error:",e),Vn(e)))}changeGroupOwner(e){const s=this._n+".changeGroupOwner";if(this.hasLocalGroup(e.groupID)&&this.getLocalGroupProfile(e.groupID).type===t.GRP_AVCHATROOM)return Vn({code:nn.CANNOT_CHANGE_OWNER_IN_AVCHATROOM});if(e.newOwnerID===this.getMyUserID())return Vn({code:nn.CANNOT_CHANGE_OWNER_TO_SELF});const o=new Cn("changeGroupOwner");return o.setMessage(`groupID:${e.groupID} newOwnerID:${e.newOwnerID}`),_e.l(`${s} groupID:${e.groupID}`),this.request({protocolName:Wo,requestData:e}).then(()=>{o.setNetworkType(this.getNetworkType()).end(),_e.l(s+" ok");const{groupID:t,newOwnerID:i}=e;this.groupMap.get(t).ownerID=i;const n=this.getModule(hs).getLocalGroupMemberList(t);if(n instanceof Map){const e=n.get(this.getMyUserID());we(e)||(e.updateRole("Member"),this.groupMap.get(t).selfInfo.role="Member");const s=n.get(i);we(s)||s.updateRole("Owner")}return this.emitGroupListUpdate(!0,!1),wn({group:this.groupMap.get(t)})}).catch(e=>(this.probeNetwork().then(([t,s])=>{o.setError(e,t,s).end()}),_e.e(s+" failed. error:",e),Vn(e)))}getGroupApplicationList(){return this._groupSystemNoticeHandler.getGroupApplicationList()}handleGroupApplication(e){const t=this._n+".handleGroupApplication",{handleAction:s,handleMessage:o,message:i,application:n}=e;let r,a,u,c,l;i?(r=i.payload.operatorID,a=i.payload.groupProfile.groupID,u=i.payload.authentication,c=i.payload.messageKey):n&&(r=n.applicant,a=n.groupID,u=n.authentication,c=n.messageKey);let d=Yo;n&&2===n.applicationType&&(d=jo,l=n.userID);const p=new Cn("handleGroupApplication");return p.setMessage("groupID:"+a),_e.l(`${t} groupID:${a}`),this.request({protocolName:d,requestData:{handleAction:s,handleMessage:o,applicant:r,invitee:l,groupID:a,authentication:u,messageKey:c}}).then(()=>(p.setNetworkType(this.getNetworkType()).end(),_e.l(t+" ok"),i&&this._groupSystemNoticeHandler.deleteGroupSystemNotice({messageList:[e.message]}),wn({group:this.getLocalGroupProfile(a)}))).catch(e=>(this.probeNetwork().then(([t,s])=>{p.setError(e,t,s).end()}),_e.e(t+" failed. error",e),Vn(e)))}handleGroupInvitation(e){const t=this._n+".handleGroupInvitation",{groupProfile:{groupID:s},authentication:o,messageKey:i,operatorID:n}=e.message.payload,{handleAction:r}=e,a=new Cn("handleGroupInvitation");return a.setMessage(`groupID:${s} inviter:${n} handleAction:${r}`),_e.l(`${t} groupID:${s} inviter:${n} handleAction:${r}`),this.request({protocolName:zo,requestData:{...e,inviter:n,groupID:s,authentication:o,messageKey:i}}).then(()=>(a.setNetworkType(this.getNetworkType()).end(),_e.l(t+" ok"),this._groupSystemNoticeHandler.deleteGroupSystemNotice({messageList:[e.message]}),wn({group:this.getLocalGroupProfile(s)}))).catch(e=>(this.probeNetwork().then(([t,s])=>{a.setError(e,t,s).end()}),_e.e(t+" failed. error",e),Vn(e)))}getGroupOnlineMemberCount(e){if(!this._AVChatRoomHandler)return Vn({code:nn.CANNOT_FIND_MODULE});return this._AVChatRoomHandler.checkJoinedAVChatRoomByID(e)?this._AVChatRoomHandler.getGroupOnlineMemberCount(e):xn({memberCount:0})}hasLocalGroup(e){return this.groupMap.has(e)}deleteLocalGroupAndConversation(e){const s=this.checkJoinedAVChatRoomByID(e);if(_e.l(`${this._n}.deleteLocalGroupAndConversation isJoinedAVChatRoom:${s}`),s){this.getModule(_s).deleteLocalConversation(`${t.CONV_GROUP}${e}`)}if(st({groupID:e})){const t=this.getLocalGroupProfile(e);if(t&&!0===t.isSupportTopic){this.getModule(gs).deleteTopicListInCommunity(e)}}this._deleteLocalGroup(e),this.emitGroupListUpdate(!0,!1)}_deleteLocalGroup(e){this.groupMap.delete(e);this.getModule(hs).deleteGroupMemberList(e),this._setStorageGroupList()}sendMessage(e,t){if(be(e._receiverList)&&e._receiverList.length>0){if(!this.canIUse(M.MSG_TO_SPECIFIED_GRP_MBR))return Vn({code:nn.CANNOT_USE_COMMERCIAL_ABILITY})}const s=this.createGroupMessagePack(e,t);return this.request(s)}createGroupMessagePack(e,s){let o=null;s&&s.offlinePushInfo&&(o=s.offlinePushInfo);let i="";Ue(e.cloudCustomData)&&e.cloudCustomData.length>0&&(i=e.cloudCustomData);const n=[];if(Pe(s)&&Pe(s.messageControlInfo)){const{excludedFromUnreadCount:e,excludedFromLastMessage:t,excludedFromContentModeration:o}=s.messageControlInfo;!0===e&&n.push("NoUnread"),!0===t&&n.push("NoLastMsg"),!0===o&&n.push("NoMsgCheck")}let r=void 0;be(e._receiverList)&&e._receiverList.length>0&&(r=e._receiverList,e._receiverList.length>50&&(r=e._receiverList.slice(0,50),this.outputWarning("ReceiverListLimit")));const a=this.isOnlineMessage(e,s)?1:0,u=e.getGroupAtInfoList(),c={fromAccount:this.getMyUserID(),groupID:e.to,msgBody:e.getElements(),cloudCustomData:i,random:e.random,priority:e.priority,clientSequence:e.clientSequence,groupAtInfo:e.type!==t.MSG_TEXT||Lt(u)?void 0:u,onlineOnlyFlag:a,clientTime:e.clientTime,offlinePushInfo:o?{pushFlag:!0===o.disablePush?1:0,title:o.title||"",desc:o.description||"",ext:o.extension||"",apnsInfo:{badgeMode:!0===o.ignoreIOSBadge?1:0,isVoipPush:this._isVoipPush(o)},androidInfo:{OPPOChannelID:o.androidOPPOChannelID||""}}:void 0,messageControlInfo:0===a?n:void 0,needReadReceipt:!0!==e.needReadReceipt||this.isMessageFromOrToAVChatroom(e.to)?0:1,receiverList:r,isSupportExtension:!0===e.isSupportExtension?1:0};return ot(e.to)&&(c.groupID=ft(e.to),c.topicID=e.to),{protocolName:Ws,tjgID:this.generateTjgID(e),requestData:c}}_isVoipPush(e){let t=void 0;return we(e.disableVoipPush)||(t=!1===e.disableVoipPush?1:0),t}revokeMessage(e){const t={groupID:e.to,msgSeqList:[{msgSeq:e.sequence}]};return ot(e.to)&&(t.groupID=ft(e.to),t.topicID=e.to),this.request({protocolName:Jo,requestData:t})}deleteMessage(e){const{to:t,keyList:s}=e;_e.l(`${this._n}.deleteMessage groupID:${t} count:${s.length}`);const o={groupID:t,deleter:this.getMyUserID(),keyList:s};return ot(t)&&(o.groupID=ft(t),o.topicID=t),this.request({protocolName:ci,requestData:o})}modifyRemoteMessage(e){const{to:t,sequence:s,payload:o,type:i,version:n=0,cloudCustomData:r}=e;let a=t,u=void 0;ot(t)&&(a=ft(t),u=t);let c=void 0;return Ct(i)&&(c=[],c.push({type:i,content:o})),this.request({protocolName:li,requestData:{groupID:a,topicID:u,sequence:s,version:n,elements:c,cloudCustomData:r}})}getRoamingMessage(e){const t=this._n+".getRoamingMessage";let{conversationID:s,groupID:o,sequence:i}=e;const n=new Cn("getGroupRoamingMessages");let r=0,a=void 0;return ot(o)&&(a=o,o=ft(a)),this._computeLastSequence({groupID:o,topicID:a,sequence:i}).then(e=>(r=e,_e.l(`${t} groupID:${o} startSequence:${r}`),this.request({protocolName:Qo,requestData:{groupID:o,count:21,sequence:r,topicID:a}}))).then(e=>{const{messageList:i,complete:u,invisibleSequenceList:c=[]}=e.data;we(i)?_e.l(`${t} ok. complete:${u} but messageList is undefined!`):_e.l(`${t} ok. complete:${u} count:${i.length}`);let l=this._getMinSequence(c,i)-1;n.setNetworkType(this.getNetworkType()).setMessage(`groupID:${o} topicID:${a} startSequence:${r} complete:${u} nextSequence:${l}`).end();const d=this.getModule(_s);let p=[];return Lt(i)||(d.updateRoamingMessageSequence(s,l),p=d.onRoamingMessage(i,s),d.updateIsRead(s),d.patchConversationLastMessage(s)),(2===u||l<=1)&&(d.setCompleted(s),l=""),_e.l(`${t} nextReqID:${l}, stored message count:${p.length}, invisible sequence count:${c.length}`),{nextReqID:l+"",storedMessageList:p}}).catch(e=>(this.probeNetwork().then(([t,s])=>{n.setError(e,t,s).setMessage(`groupID:${o} topicID:${a} startSequence:${r}`).end()}),_e.w(t+" failed. error:",e),Vn(e)))}_getGroupIDOfMessage(e){return e.conversationID.replace(t.CONV_GROUP,"")}_getMinSequence(e,t){let s=0;Lt(t)||(s=t[t.length-1].sequence);let o=0;if(!Lt(e)){o=e[e.length-1]}return _e.l(`${this._n}._getMinSequence minVisibleSequence:${s} minInvisibleSequence:${o}`),o>0&&o<s?o:s}getReadReceiptList(e){const t=this._n+".getReadReceiptList",s=this._getGroupIDOfMessage(e[0]),o=this.getMyUserID(),i=e.filter(e=>e.from===o&&!0===e.needReadReceipt).map(e=>({sequence:e.sequence}));if(_e.l(`${t} groupID:${s} sequenceList:${JSON.stringify(i)}`),0===i.length)return xn({messageList:e});const n=new Cn("getReadReceiptList");return n.setMessage("groupID:"+s),this.request({protocolName:ei,requestData:{groupID:s,sequenceList:i}}).then(s=>{n.end(),_e.l(t+" ok");const{readReceiptList:o}=s.data;return be(o)&&o.forEach(t=>{e.forEach(e=>{0===t.code&&t.sequence===e.sequence&&(e.readReceiptInfo.readCount=t.readCount,e.readReceiptInfo.unreadCount=t.unreadCount)})}),wn({messageList:e})}).catch(e=>(this.probeNetwork().then(([t,s])=>{n.setError(e,t,s).end()}),_e.w(t+" failed. error:",e),Vn(e)))}sendReadReceipt(e){const t=this._n+".sendReadReceipt",s=this._getGroupIDOfMessage(e[0]),o=new Cn("sendReadReceipt");o.setMessage("groupID:"+s);const i=this.getMyUserID(),n=e.filter(e=>e.from!==i&&!0===e.needReadReceipt).map(e=>({sequence:e.sequence}));return 0===n.length?Vn({code:nn.READ_RECEIPT_MESSAGE_LIST_EMPTY}):(_e.l(`${t}. sequenceList:${JSON.stringify(n)}`),this.request({protocolName:ti,requestData:{groupID:s,sequenceList:n}}).then(e=>(o.end(),_e.l(t+" ok"),wn())).catch(e=>(this.probeNetwork().then(([t,s])=>{o.setError(e,t,s).end()}),_e.w(t+" failed. error:",e),Vn(e))))}getReadReceiptDetail(e){const{message:t,filter:s,cursor:o,count:i}=e,n=this._getGroupIDOfMessage(t),r=t.ID,a=t.sequence,u=this._n+".getReadReceiptDetail",c=this._receiptDetailCompleteMap.get(r)||!1,l=0!==s&&1!==s?0:s,d=Ue(o)?o:"",p=!Ge(i)||i<=0||i>=100?100:i,h=`groupID:${n} sequence:${a} cursor:${d} filter:${l} completeFlag:${c}`;_e.l(`${u} ${h}`);const g={cursor:"",isCompleted:!1,messageID:r,unreadUserIDList:[],readUserIDList:[]},_=new Cn("getReadReceiptDetail");return _.setMessage(h),this.request({protocolName:oi,requestData:{groupID:n,sequence:a,flag:l,cursor:d,count:p}}).then(e=>{_.end();const{cursor:t,isCompleted:s,unreadUserIDList:o,readUserIDList:i}=e.data;return g.cursor=t,1===s&&(g.isCompleted=!0,this._receiptDetailCompleteMap.set(r,!0)),0===l?g.readUserIDList=i.map(e=>e.userID):1===l&&(g.unreadUserIDList=o.map(e=>e.userID)),_e.l(u+" ok"),wn(g)}).catch(e=>(this.probeNetwork().then(([t,s])=>{_.setError(e,t,s).end()}),_e.w(u+" failed. error:",e),Vn(e)))}getRoamingMessagesHopping(e){const s=this._n+".getRoamingMessagesHopping",o=new Cn("getGroupRoamingMessagesHopping");let{groupID:i,count:n,sequence:r,direction:a}=e,u=r;1===a&&(u=r+n-1);let c=void 0;ot(i)&&(c=i,i=ft(c));const l=`${c?"topicID:"+c:"groupID:"+i} sequence:${r} direction:${a}`;return _e.l(`${s} ${l}`),this.request({protocolName:Qo,requestData:{groupID:i,topicID:c,count:n,sequence:u}}).then(i=>{const{messageList:n,complete:u}=i.data,c=`complete:${u} count:${n?n.length:0}`;if(_e.l(`${s} ok. ${c}`),o.setNetworkType(this.getNetworkType()).setMessage(`${l} ${c}`).end(),2===u||Lt(n)){const e=this._computeResult();return wn(e)}const d=`${t.CONV_GROUP}${e.groupID}`,p=this.getModule(_s).onRoamingMessage(n,d,!1),h=this._computeResult({direction:a,sequence:r,remoteMessageList:n,processedMessageList:p});return wn(h)}).catch(e=>(this.probeNetwork().then(([t,s])=>{o.setError(e,t,s).setMessage(`groupID:${i} sequence:${r} count:${n}`).end()}),_e.w(s+" failed. error:",e),Vn(e)))}_computeResult(e){const t={messageList:[],isCompleted:!1,nextMessageSeq:""};if(we(e))return t.isCompleted=!0,t;const{direction:s,sequence:o,remoteMessageList:i=[],processedMessageList:n=[]}=e,r=i.length;return 1===s?(t.nextMessageSeq=i[0].sequence+1,n.forEach(e=>{e.sequence>=o&&t.messageList.push(e)}),0===t.messageList.length&&i[0].sequence<o&&(t.isCompleted=!0,t.nextMessageSeq=""),t):(t.nextMessageSeq=i[r-1].sequence-1,t.messageList=[...n],0===t.nextMessageSeq&&(t.isCompleted=!0,t.nextMessageSeq=""),t)}setMessageRead({conversationID:e,lastMessageSeq:s}){const o=this._n+".setMessageRead";_e.l(`${o} conversationID:${e} lastMessageSeq:${s}`),Ge(s)||this.outputWarning("DoNotModifyLastSeq");const i=new Cn("setGroupMessageRead");i.setMessage(`${e}-${s}`);let n=e.replace(t.CONV_GROUP,""),r=void 0;return ot(n)&&(r=n,n=ft(r)),this.request({protocolName:Xo,requestData:{groupID:n,topicID:r,messageReadSeq:s}}).then(()=>{i.setNetworkType(this.getNetworkType()).end(),_e.l(o+" ok.");const t=this.getModule(_s);t.updateIsReadAfterReadReport({conversationID:e,lastMessageSeq:s});let a=!0;if(!we(r)){a=!1;const e=this.getModule(gs).getLocalTopic(n,r);e&&e.updateSelfInfo({readedSequence:s})}return t.updateUnreadCount(e,a),wn()}).catch(e=>(this.probeNetwork().then(([t,s])=>{i.setError(e,t,s).end()}),_e.l(o+" failed. error:",e),Vn(e)))}_computeLastSequence(e){const{groupID:t,topicID:s,sequence:o}=e;return o>0?Promise.resolve(o):we(s)||this.hasLocalGroup(t)?we(s)?this.getGroupLastSequence(t):this.getTopicLastSequence({groupID:t,topicID:s}):Promise.resolve(0)}getGroupLastSequence(e){const t=this._n+".getGroupLastSequence",s=new Cn("getGroupLastSequence");let o=0,i="";if(this.hasLocalGroup(e)){const n=this.getLocalGroupProfile(e),r=n.lastMessage;if(r.lastSequence>0&&!1===r.onlineOnlyFlag)return o=r.lastSequence,i=`got lastSequence:${o} from local group profile[lastMessage.lastSequence]. groupID:${e}`,_e.l(`${t} ${i}`),s.setNetworkType(this.getNetworkType()).setMessage(""+i).end(),Promise.resolve(o);if(n.nextMessageSeq>1)return o=n.nextMessageSeq-1,i=`got lastSequence:${o} from local group profile[nextMessageSeq]. groupID:${e}`,_e.l(`${t} ${i}`),s.setNetworkType(this.getNetworkType()).setMessage(""+i).end(),Promise.resolve(o)}const n="GROUP"+e,r=this.getModule(_s).getLocalConversation(n);if(r&&r.lastMessage.lastSequence&&!1===r.lastMessage.onlineOnlyFlag)return o=r.lastMessage.lastSequence,i=`got lastSequence:${o} from local conversation profile[lastMessage.lastSequence]. groupID:${e}`,_e.l(`${t} ${i}`),s.setNetworkType(this.getNetworkType()).setMessage(""+i).end(),Promise.resolve(o);const a={groupIDList:[e],responseFilter:{groupBaseInfoFilter:["NextMsgSeq"]}};return this.getGroupProfileAdvance(a).then(({data:{successGroupList:n}})=>(Lt(n)?_e.l(`${t} successGroupList is empty. groupID:${e}`):(o=n[0].nextMessageSeq-1,i=`got lastSequence:${o} from getGroupProfileAdvance. groupID:${e}`,_e.l(`${t} ${i}`)),s.setNetworkType(this.getNetworkType()).setMessage(""+i).end(),o)).catch(o=>(this.probeNetwork().then(([t,i])=>{s.setError(o,t,i).setMessage("get lastSequence failed from getGroupProfileAdvance. groupID:"+e).end()}),_e.w(t+" failed. error:",o),Vn(o)))}getTopicLastSequence({groupID:e,topicID:t}){const s=this._n+".getTopicLastSequence",o=new Cn("getTopicLastSequence");let i=0,n="";const r=this.getModule(gs);return r.hasLocalTopic(e,t)?(i=r.getLocalTopic(e,t).nextMessageSeq-1,n=`get lastSequence:${i} from local topic info[nextMessageSeq]. topicID:${t}`,_e.l(`${s} ${n}`),o.setNetworkType(this.getNetworkType()).setMessage(""+n).end(),Promise.resolve(i)):r.getTopicList({groupID:e,topicIDList:[t]}).then(({data:{successTopicList:e}})=>(Lt(e)?_e.l(`${s} successTopicList is empty. topicID:${t}`):(i=e[0].nextMessageSeq-1,n=`get lastSequence:${i} from getTopicList. topicID:${t}`,_e.l(`${s} ${n}`)),o.setNetworkType(this.getNetworkType()).setMessage(""+n).end(),i)).catch(e=>(this.probeNetwork().then(([s,i])=>{o.setError(e,s,i).setMessage("get lastSequence failed from getTopicList. topicID:"+t).end()}),_e.w(s+" failed. error:",e),Vn(e)))}isMessageFromOrToAVChatroom(e){return!!this._AVChatRoomHandler&&this._AVChatRoomHandler.checkJoinedAVChatRoomByID(e)}hasJoinedAVChatRoom(){return this._AVChatRoomHandler?this._AVChatRoomHandler.hasJoinedAVChatRoom():0}getJoinedAVChatRoom(){return this._AVChatRoomHandler?this._AVChatRoomHandler.getJoinedAVChatRoom():[]}isOnlineMessage(e,t){return!(!this._canIUseOnlineOnlyFlag(e)||!t||!0!==t.onlineUserOnly)}_canIUseOnlineOnlyFlag(e){const s=this.getJoinedAVChatRoom();return!s||!s.includes(e.to)||e.conversationType!==t.CONV_GROUP}_onAVChatRoomHistoryMessage(e){if(Lt(e))return;_e.l(`${this._n}._onAVChatRoomHistoryMessage count:${e.length}`);const t=[];e.forEach(e=>{t.push({...e,isHistoryMessage:1})}),this.onAVChatRoomMessage(t)}onAVChatRoomMessage(e){this._AVChatRoomHandler&&this._AVChatRoomHandler.onMessage(e)}onAVChatRoomMemberBanned(e){this._AVChatRoomHandler&&this._AVChatRoomHandler.onAVChatRoomMemberBanned(e)}getGroupSimplifiedInfo(e){const t=new Cn("getGroupSimplifiedInfo"),s={groupIDList:[e],responseFilter:{groupBaseInfoFilter:["Type","Name"]}};return this.getGroupProfileAdvance(s).then(({data:{successGroupList:s}})=>(t.setNetworkType(this.getNetworkType()).setMessage(`groupID:${e} type:${s[0].type}`).end(),s[0])).catch(s=>{this.probeNetwork().then(([o,i])=>{t.setError(s,o,i).setMessage("groupID:"+e).end()})})}setUnjoinedAVChatRoom(e){this._unjoinedAVChatRoomList.set(e,1)}deleteUnjoinedAVChatRoom(e){this._unjoinedAVChatRoomList.has(e)&&this._unjoinedAVChatRoomList.delete(e)}isUnjoinedAVChatRoom(e){return this._unjoinedAVChatRoomList.has(e)}isGroupAttributesUpdatedNotice(e){return this._groupAttributesHandler.isGroupAttributesUpdatedNotice(e)}updateLocalMainSequenceOnReconnected(){this._groupAttributesHandler.updateLocalMainSequenceOnReconnected()}initGroupAttributes(e){return this._groupAttributesHandler.initGroupAttributes(e)}setGroupAttributes(e){return this._groupAttributesHandler.setGroupAttributes(e)}deleteGroupAttributes(e){return this._groupAttributesHandler.deleteGroupAttributes(e)}getGroupAttributes(e){return this._groupAttributesHandler.getGroupAttributes(e)}isMessageFromTopic(e,t){return 2===e&&!Lt(t)}isMessageFromCommunityOfTopic(e,t){return 2===e&&Lt(t)}getMessageExtensions(e,t){return _e.l(`${this._n}.getMessageExtensions startSequence:${t}`),this.request({protocolName:Mi,requestData:{groupID:e.to,messageSequence:e.sequence,startSequence:t}})}modifyMessageExtensions(e,t,s=1){return _e.l(`${this._n}.modifyMessageExtensions operateType:${s}`),this.request({protocolName:mi,requestData:{groupID:e.to,messageSequence:e.sequence,extensionList:t,operateType:s}})}getGroupNotify(e){if(!this.hasLocalGroup(e))return;const s=this.getLocalGroupProfile(e),{type:o,isSupportTopic:i}=s;if(et(o)||i)return;const n=this._n+".getGroupNotify",r=this._getGroupLastRevokedTime(e),a=1e3*ce();_e.l(`${n} groupID:${e} type:${o} beginTime:${r} endTime:${a}`),this.request({protocolName:fi,requestData:{type:st({type:o,groupID:e})?t.GRP_COMMUNITY:void 0,groupID:e,beginTime:r,endTime:a}}).then(t=>{const{nextRevokedTime:s,notifyList:o}=t.data;_e.l(`${n} ok. groupID:${e} nextRevokedTime:${s}`);const i={dataList:[{elements:{revokedInfos:[]}}]};be(o)&&o.forEach(t=>{i.dataList[0].elements.revokedInfos.push({groupID:e,sequence:t.sequence,random:t.random,revokerInfo:{...t.revokerInfo}})}),this.onGroupMessageRevoked(i),0!==s?(this._setGroupLastRevokedTime(e,s),this.getGroupNotify(e)):this._setGroupLastRevokedTime(e,1e3*ce())}).catch(e=>{_e.e(n+" failed. error:",e)})}_getGroupLastRevokedTime(e){return this.hasLocalGroup(e)?this.getLocalGroupProfile(e)._lastRevokedTime:0}_setGroupLastRevokedTime(e,t){this.hasLocalGroup(e)&&(this.getLocalGroupProfile(e)._lastRevokedTime=t)}isGroupCountersNotice(e){return this._groupCountersHandler.isGroupCountersNotice(e)}setGroupCounters(e){return this._groupCountersHandler.setGroupCounters(e)}increaseGroupCounter(e){return this._groupCountersHandler.increaseGroupCounter(e)}decreaseGroupCounter(e){return this._groupCountersHandler.decreaseGroupCounter(e)}getGroupCounters(e){return this._groupCountersHandler.getGroupCounters(e)}restartPolling(){this._AVChatRoomHandler&&this._AVChatRoomHandler.restartPolling()}getPollingTimerID(e){if(!e)return-1;const t=this.getLocalGroupProfile(e);return t&&et(t.type)?this._AVChatRoomHandler.getPollingTimerID(e):-1}_canIUseJoinOption(e){return(e=>e===t.GRP_PUBLIC)(e)||st({type:e})}reset(){this.groupMap.clear(),this._unjoinedAVChatRoomList.clear(),this._receiptDetailCompleteMap.clear(),this._commonGroupHandler.reset(),this._groupSystemNoticeHandler.reset(),this._groupTipsHandler.reset(),this._groupAttributesHandler.reset(),this._groupCountersHandler.reset(),this._AVChatRoomHandler&&this._AVChatRoomHandler.reset()}}class Rr{constructor(e){this.userID="",this.avatar="",this.nick="",this.role="",this.joinTime="",this.lastSendMsgTime="",this.nameCard="",this.muteUntil=0,this.memberCustomField=[],this._initMember(e)}_initMember(e){this.updateMember(e)}updateMember(e){const t=[null,void 0,"",0,NaN];e.memberCustomField&&Qe(this.memberCustomField,e.memberCustomField),Be(this,e,["memberCustomField","marks"],t)}updateRole(e){["Owner","Admin","Member"].indexOf(e)<0||(this.role=e)}updateMuteUntil(e){we(e)||(this.muteUntil=Math.floor((Date.now()+1e3*e)/1e3))}updateNameCard(e){we(e)||(this.nameCard=e)}updateMemberCustomField(e){e&&Qe(this.memberCustomField,e)}}class Or extends Fs{constructor(e){super(e),this._n="GroupMemberModule",this.groupMemberListMap=new Map,this.getInnerEmitterInstance().on(Yn,this._onProfileUpdated,this)}_onProfileUpdated({data:e}){for(let t=0;t<e.length;t++){const s=e[t];this.groupMemberListMap.forEach(e=>{e.has(s.userID)&&e.get(s.userID).updateMember({nick:s.nick,avatar:s.avatar})})}}deleteGroupMemberList(e){this.groupMemberListMap.delete(e)}getGroupMemberList({groupID:e,offset:s=0,count:o=15,filter:i}){const n=this._n+".getGroupMemberList",r=this.getModule(ds),a=r.hasLocalGroup(e);if(_e.l(`${n} groupID:${e} offset:${s} count:${o} hasLocalGroup:${a}`),!a)return xn({memberList:[],offset:0});if(r.getLocalGroupProfile(e).type===t.GRP_AVCHATROOM){if(this.canIUse(M.AVCHATROOM_MBR_LIST))return this._getAVChatRoomMemberList({groupID:e,offset:s,filter:i});this.outputWarning("LiveOnlineMember")}const u=new Cn("getGroupMemberList");let c=0;const l={groupID:e,limit:o>100?100:o};st({groupID:e})?l.next=""+s:(l.offset=s,c=s+o);let d=[];return this.request({protocolName:Ti,requestData:l}).then(({data:{members:t,memberNum:s,next:o}})=>{if(we(o)||(c=Lt(o)?0:o),!be(t)||0===t.length)return c=0,Promise.resolve([]);const i=this.getModule(ds);i.hasLocalGroup(e)&&(i.getLocalGroupProfile(e).memberNum=s),d=this._updateLocalGroupMemberMap(e,t);return this.getModule(cs).getUserProfile({userIDList:t.map(e=>e.userID),tagList:[Me.NICK,Me.AVATAR]})}).then(t=>{const{data:i}=t;if(!be(i)||0===i.length)return xn({memberList:[],offset:c});const r=i.map(e=>({userID:e.userID,nick:e.nick,avatar:e.avatar}));return this._updateLocalGroupMemberMap(e,r),d.length<o&&(c=0),u.setNetworkType(this.getNetworkType()).setMessage(`groupID:${e} offset:${s} count:${o}`).end(),_e.l(n+" ok."),wn({memberList:d,offset:c})}).catch(e=>(this.probeNetwork().then(([t,s])=>{u.setError(e,t,s).end()}),_e.e(n+" failed. error:",e),Vn(e)))}_getAVChatRoomMemberList({groupID:e,offset:t,filter:s}){const o=this._n+"._getAVChatRoomMemberList",i=new Cn("_getAVChatRoomMemberList");return i.setMessage(`groupID:${e} offset:${t} filter:${s}`),this.request({protocolName:yi,requestData:{groupID:e,offset:t,filter:s}}).then(t=>{const{memberList:s=[],offset:n=0}=t.data;i.setNetworkType(this.getNetworkType()).end(),_e.l(`${o} ok. member count:${s.length}, next request timestamp:${n}`);const r=this._updateLocalGroupMemberMap(e,s);return wn({memberList:r,offset:n})}).catch(e=>(this.probeNetwork().then(([t,s])=>{i.setError(e,t,s).end()}),_e.e(o+" failed. error:",e),Vn(e)))}getGroupMemberProfile(e){const t=this._n+".getGroupMemberProfile",s=new Cn("getGroupMemberProfile");s.setMessage(e.userIDList.length>5?"userIDList.length:"+e.userIDList.length:"userIDList:"+e.userIDList),_e.l(`${t} groupID:${e.groupID} userIDList:${e.userIDList.join(",")}`),e.userIDList.length>50&&(e.userIDList=e.userIDList.slice(0,50));const{groupID:o,userIDList:i}=e;return this._getGroupMemberProfileAdvance({...e,userIDList:i}).then(e=>{const{members:t}=e.data;if(!be(t)||0===t.length)return xn([]);this._updateLocalGroupMemberMap(o,t);return this.getModule(cs).getUserProfile({userIDList:t.map(({userID:e})=>e),tagList:[Me.NICK,Me.AVATAR]})}).then(e=>{const t=e.data.map(({userID:e,nick:t,avatar:s})=>({userID:e,nick:t,avatar:s}));this._updateLocalGroupMemberMap(o,t);const n=i.filter(e=>this.hasLocalGroupMember(o,e)).map(e=>this.getLocalGroupMemberInfo(o,e));return s.setNetworkType(this.getNetworkType()).end(),wn({memberList:n})})}addGroupMember(e){const t=this._n+".addGroupMember",{groupID:s}=e,o=this.getModule(ds).getLocalGroupProfile(s),{type:i}=o,n=new Cn("addGroupMember");if(n.setMessage(`groupID:${s} groupType:${i}`),et(i)){const e=new Fn({code:nn.CANNOT_ADD_MEMBER_IN_AVCHATROOM});return n.setError(e,!0,this.getNetworkType()).end(),Vn(e)}return e.userIDList=e.userIDList.map(e=>({userID:e})),_e.l(`${t} groupID:${s}`),this.request({protocolName:Ei,requestData:e}).then(({data:{members:s}})=>{_e.l(t+" ok");const i=s.filter(e=>1===e.result).map(e=>e.userID),r=s.filter(e=>0===e.result).map(e=>e.userID),a=s.filter(e=>2===e.result).map(e=>e.userID),u=s.filter(e=>4===e.result).map(e=>e.userID),c=`groupID:${e.groupID}, successUserIDList:${i}, failureUserIDList:${r}, existedUserIDList:${a}, overLimitUserIDList:`+u;return n.setNetworkType(this.getNetworkType()).setMoreMessage(c).end(),0===i.length?wn({successUserIDList:i,failureUserIDList:r,existedUserIDList:a,overLimitUserIDList:u}):(o.memberCount+=i.length,this._updateConversationGroupProfile(o),wn({successUserIDList:i,failureUserIDList:r,existedUserIDList:a,overLimitUserIDList:u,group:o}))}).catch(e=>(this.probeNetwork().then(([t,s])=>{n.setError(e,t,s).end()}),_e.e(t+" failed. error:",e),Vn(e)))}deleteGroupMember(e){const t=this._n+".deleteGroupMember",{groupID:s,userIDList:o}=e,i=this.getModule(ds).getLocalGroupProfile(s);if(we(i))return Vn({code:nn.CANNOT_FIND_GROUP});if(et(i.type)){return this.canIUse(M.AVCHATROOM_BAN_MBR)?this._banAVChatRoomMember(e):Vn({code:nn.CANNOT_USE_COMMERCIAL_ABILITY})}const n=new Cn("deleteGroupMember"),r=`groupID:${s} ${o.length>5?"userIDList.length:"+o.length:"userIDList:"+o}`;return n.setMessage(r),_e.l(`${t} groupID:${s} userIDList:`,o),this.request({protocolName:Si,requestData:e}).then(()=>(n.setNetworkType(this.getNetworkType()).end(),_e.l(t+" ok"),i.memberCount-=1,this._updateConversationGroupProfile(i),this.deleteLocalGroupMembers(s,o),wn({group:i,userIDList:o}))).catch(e=>(this.probeNetwork().then(([t,s])=>{n.setError(e,t,s).end()}),_e.e(t+" failed. error:",e),Vn(e)))}_updateConversationGroupProfile(e){this.getModule(_s).updateConversationGroupProfile([e])}_banAVChatRoomMember(e){const t=this._n+".deleteGroupMember",{groupID:s,userIDList:o}=e,i=`groupID:${s} ${o.length>5?"userIDList.length:"+o.length:"userIDList:"+o}`,n=new Cn("deleteGroupMember");n.setMessage(i),_e.l(`${t} groupID:${s} userIDList:`,o);const r=this.getModule(ds).getLocalGroupProfile(s);return we(e.duration)||0===e.duration?Vn({code:nn.BAN_DURATION_INVALID}):this.request({protocolName:Li,requestData:e}).then(()=>(n.setNetworkType(this.getNetworkType()).end(),_e.l(t+" ok"),this.deleteLocalGroupMembers(s,o),wn({group:r,userIDList:o}))).catch(e=>(this.probeNetwork().then(([t,s])=>{n.setError(e,t,s).end()}),_e.e(t+" failed. error:",e),Vn(e)))}setGroupMemberMuteTime(e){const{groupID:t,userID:s,muteTime:o}=e,i=this._n+".setGroupMemberMuteTime";if(s===this.getMyUserID())return Vn(new Fn({code:nn.CANNOT_MUTE_SELF}));_e.l(`${i} groupID:${t} userID:${s}`);const n=new Cn("setGroupMemberMuteTime");return n.setMessage(`groupID:${t} userID:${s} muteTime:${o}`),this.modifyGroupMemberInfo({groupID:t,userID:s,muteTime:o}).then(e=>{n.setNetworkType(this.getNetworkType()).end(),_e.l(i+" ok");const s=this.getModule(ds);return wn({group:s.getLocalGroupProfile(t),member:e})}).catch(e=>(this.probeNetwork().then(([t,s])=>{n.setError(e,t,s).end()}),_e.e(i+" failed. error:",e),Vn(e)))}setGroupMemberRole(e){const s=this._n+".setGroupMemberRole",{groupID:o,userID:i,role:n}=e,r=this.getModule(ds).getLocalGroupProfile(o);if(r.selfInfo.role!==t.GRP_MBR_ROLE_OWNER)return Vn({code:nn.NOT_OWNER});if([t.GRP_WORK,t.GRP_AVCHATROOM].includes(r.type))return Vn({code:nn.CANNOT_SET_MEMBER_ROLE_IN_WORK_AND_AVCHATROOM});const a=[t.GRP_MBR_ROLE_ADMIN,t.GRP_MBR_ROLE_MEMBER];if(st({groupID:o})&&a.push(t.GRP_MBR_ROLE_CUSTOM),a.indexOf(n)<0)return Vn({code:nn.INVALID_MEMBER_ROLE});if(i===this.getMyUserID())return Vn({code:nn.CANNOT_SET_SELF_MEMBER_ROLE});const u=new Cn("setGroupMemberRole");return u.setMessage(`groupID:${o} userID:${i} role:${n}`),_e.l(`${s} groupID:${o} userID:${i}`),this.modifyGroupMemberInfo({groupID:o,userID:i,role:n}).then(e=>(u.setNetworkType(this.getNetworkType()).end(),_e.l(s+" ok"),wn({group:r,member:e}))).catch(e=>(this.probeNetwork().then(([t,s])=>{u.setError(e,t,s).end()}),_e.e(s+" failed. error:",e),Vn(e)))}_filterProfanity(e,t){const s=this.getModule(Us);if(!s)return!0;const{isAllowedToSend:o,modifiedText:i}=s.filterText(t[e],S);return!0===o&&(t[e]=i,!0)}setGroupMemberNameCard(e){const t=this._n+".setGroupMemberNameCard";if(e.nameCard&&!1===this._filterProfanity("nameCard",e))return Vn({code:nn.PROFANITY_FOUND});const{groupID:s,userID:o=this.getMyUserID(),nameCard:i}=e;_e.l(`${t} groupID:${s} userID:${o}`);const n=new Cn("setGroupMemberNameCard");return n.setMessage(`groupID:${s} userID:${o} nameCard:${i}`),this.modifyGroupMemberInfo({groupID:s,userID:o,nameCard:i}).then(e=>{_e.l(t+" ok"),n.setNetworkType(this.getNetworkType()).end();const r=this.getModule(ds).getLocalGroupProfile(s);return o===this.getMyUserID()&&r&&r.setSelfNameCard(i),wn({group:r,member:e})}).catch(e=>(this.probeNetwork().then(([t,s])=>{n.setError(e,t,s).end()}),_e.e(t+" failed. error:",e),Vn(e)))}setGroupMemberCustomField(e){const t=this._n+".setGroupMemberCustomField",{groupID:s,userID:o=this.getMyUserID(),memberCustomField:i}=e;_e.l(`${t} groupID:${s} userID:${o}`);const n=new Cn("setGroupMemberCustomField");return n.setMessage(`groupID:${s} userID:${o} memberCustomField:${JSON.stringify(i)}`),this.modifyGroupMemberInfo({groupID:s,userID:o,memberCustomField:i}).then(e=>{n.setNetworkType(this.getNetworkType()).end(),_e.l(t+" ok");const o=this.getModule(ds).getLocalGroupProfile(s);return wn({group:o,member:e})}).catch(e=>(this.probeNetwork().then(([t,s])=>{n.setError(e,t,s).end()}),_e.e(t+" failed. error:",e),Vn(e)))}modifyGroupMemberInfo(e){let{groupID:t,userID:s}=e,o=void 0;return ot(t)&&(o=t,t=ft(o)),this.request({protocolName:Ai,requestData:{...e,groupID:t,topicID:o}}).then(()=>{if(this.hasLocalGroupMember(t,s)){const o=this.getLocalGroupMemberInfo(t,s);return we(e.muteTime)||o.updateMuteUntil(e.muteTime),we(e.role)||o.updateRole(e.role),we(e.nameCard)||o.updateNameCard(e.nameCard),we(e.memberCustomField)||o.updateMemberCustomField(e.memberCustomField),o}return this.getGroupMemberProfile({groupID:t,userIDList:[s]}).then(({data:{memberList:[e]}})=>e)})}markGroupMemberList(e){const t=this._n+".markGroupMemberList",{groupID:s,markType:o,enableMark:i,userIDList:n=[]}=e,r=`groupID:${s} markType:${o} enableMark:${i} userIDList count: ${n.length}`;_e.l(`${t} ${r}`);let a=2;const u=[];!0===i&&(a=1);let c=[...n];n.length>500&&(c=n.slice(0,500),_e.w(`${t} ${Dt(500)}`)),c.forEach(e=>{u.push({userID:e,markType:[o]})}),c=null;const l=new Cn("markGroupMemberList");return l.setMessage(""+r),this.request({protocolName:vi,requestData:{groupID:s,operationType:a,memberList:u}}).then(e=>{const{memberList:s=[]}=e.data,o=[],i=[];s.length===n.length?o.push(...n):(s.forEach(e=>{o.push(e.userID)}),n.forEach(e=>{o.includes(e)||i.push(e)}));const r=`success count:${o.length} fail count:${i.length}`;return l.setNetworkType(this.getNetworkType()).setMessage(r).end(),_e.l(`${t} ok. ${r}`),wn({successUserIDList:o,failureUserIDList:i})}).catch(e=>(this.probeNetwork().then(([t,s])=>{l.setError(e,t,s).end()}),_e.e(t+" failed. error:",e),Vn(e)))}_getGroupMemberProfileAdvance(e){return this.request({protocolName:Di,requestData:{...e,memberInfoFilter:e.memberInfoFilter?e.memberInfoFilter:["Role","JoinTime","NameCard","ShutUpUntil"]}})}_updateLocalGroupMemberMap(e,t){if(!be(t)||0===t.length)return[];return t.map(t=>(this.hasLocalGroupMember(e,t.userID)?this.getLocalGroupMemberInfo(e,t.userID).updateMember(t):this.setLocalGroupMember(e,new Rr(t)),this.getLocalGroupMemberInfo(e,t.userID)))}deleteLocalGroupMembers(e,t){const s=this.groupMemberListMap.get(e);s&&t.forEach(e=>{s.delete(e)})}getLocalGroupMemberInfo(e,t){return this.groupMemberListMap.has(e)?this.groupMemberListMap.get(e).get(t):null}setLocalGroupMember(e,t){if(this.groupMemberListMap.has(e))this.groupMemberListMap.get(e).set(t.userID,t);else{const s=(new Map).set(t.userID,t);this.groupMemberListMap.set(e,s)}}getLocalGroupMemberList(e){return this.groupMemberListMap.get(e)}hasLocalGroupMember(e,t){return this.groupMemberListMap.has(e)&&this.groupMemberListMap.get(e).has(t)}hasLocalGroupMemberMap(e){return this.groupMemberListMap.has(e)}reset(){this.groupMemberListMap.clear()}}const Gr=["topicID","topicName","avatar","introduction","notification","unreadCount","muteAllMembers","customData","groupAtInfoList","nextMessageSeq","selfInfo"],Ur=function(e,t){return Lt(e)?{lastTime:0,lastSequence:0,fromAccount:"",payload:null,type:"",messageForShow:"",nick:"",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:It(e.type,e.payload,t),nick:e.nick||"",version:e.version||0,cloudCustomData:e.cloudCustomData||"",isRevoked:e.isRevoked||!1,revoker:e.revoker||null}};class kr{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=Ur(e.lastMessage,t),this.selfInfo={muteTime:0,readedSequence:0,messageRemindType:"",excludedUnreadSequenceList:void 0},this._initTopic(e)}_initTopic(e){for(const t in e)Gr.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=Ur(e)}updateGroupAtInfoList(e){this.groupAtInfoList=JSON.parse(JSON.stringify(e))}updateTopic(e){we(e.selfInfo)||this.updateSelfInfo(e.selfInfo),we(e.muteAllMembers)||(this.muteAllMembers=1===e.muteAllMembers),Be(this,e,["groupID","lastMessageTime","selfInfo","muteAllMembers","lastMsg"])}updateSelfInfo(e){return 0!==Be(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 Pr extends Fs{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(Wn,this._onCloudConfigUpdated,this)}_onCloudConfigUpdated(){const e=this.getCloudConfig("topic_cache_time"),t=this.getCloudConfig("topic_last_active_time");we(e)||(this.TOPIC_CACHE_TIME=Number(e)),we(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}),_e.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=ft(s),r=this.getLocalTopic(n,s);let a=!1;r&&(we(o)||r.unreadCount===o||(r.updateUnreadCount(o),a=!0),we(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,u=ft(s),c=this.getLocalTopic(u,s);if(c){const l=c.lastMessage;_e.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=It(l.type,l.payload,this.isIntl()),l.cloudCustomData=r,l.version=a,l.lastSequence=i,l.lastTime=o,this.emitOuterEvent(e.TOPIC_UPDATED,{groupID:u,topic:c}))}}onMessageRevoked(t){if(0===t.length)return;let s=null,o=null,i=!1;t.forEach(e=>{const t=e.to;o=ft(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=ft(t),i=this.getLocalTopic(o,t);let n=!1;return i&&(n=i.isLastMessageRevoked({sequence:s})),n}getJoinedCommunityList(){return this.getModule(ds).getGroupList({isGroupWithTopicOnly:!0}).then(e=>{const{groupList:t=[]}=e.data;return wn({groupList:t})}).catch(e=>Vn(e))}createTopicInCommunity(e){const t=this._n+".createTopicInCommunity",{topicID:s}=e;if(!we(s)&&!ot(s))return Vn({code:nn.ILLEGAL_TOPIC_ID});if(e.topicName&&!1===this._filterProfanity("topicName",e))return Vn({code:nn.PROFANITY_FOUND});if(e.introduction&&!1===this._filterProfanity("introduction",e))return Vn({code:nn.PROFANITY_FOUND});if(e.notification&&!1===this._filterProfanity("notification",e))return Vn({code:nn.PROFANITY_FOUND});const o=new Cn("createTopicInCommunity");return this.request({protocolName:Ki,requestData:{...e}}).then(s=>{const{topicID:i}=s.data;return o.setMessage("topicID:"+i).setNetworkType(this.getNetworkType()).end(),_e.l(t+" ok"),this._updateTopicMap([{...e,topicID:i}]),wn({topicID:i})}).catch(e=>(this.probeNetwork().then(([t,s])=>{o.setError(e,t,s).end()}),_e.e(t+" failed. error:",e),Vn(e)))}deleteTopicFromCommunity(e){const t=this._n+".deleteTopicFromCommunity",{groupID:s,topicIDList:o=[]}=e,i=new Cn("deleteTopicFromCommunity");return i.setMessage(`groupID:${s} topicIDList:${o}`),this.request({protocolName:Wi,requestData:{groupID:s,topicIDList:o}}).then(e=>{const{resultList:t=[]}=e.data,o=[],n=[];t.forEach(e=>{const{topicID:t,errorCode:s,errorInfo:i}=e;0===s?o.push({topicID:t}):n.push({topicID:t,code:s,message:i})});const r=`success count:${o.length}, fail count:${n.length}`;return i.setMoreMessage(""+r).setNetworkType(this.getNetworkType()).end(),_e.l(""+r),o.forEach(e=>{this._deleteLocalTopic(s,e.topicID)}),wn({successTopicList:o,failureTopicList:n})}).catch(e=>(this.probeNetwork().then(([t,s])=>{i.setError(e,t,s).end()}),_e.e(t+" failed. error:",e),Vn(e)))}updateTopicProfile(e){const t=this._n+".updateTopicProfile";if(_e.l(t+" options:",e),e.topicName&&!1===this._filterProfanity("topicName",e))return Vn({code:nn.PROFANITY_FOUND});if(e.introduction&&!1===this._filterProfanity("introduction",e))return Vn({code:nn.PROFANITY_FOUND});if(e.notification&&!1===this._filterProfanity("notification",e))return Vn({code:nn.PROFANITY_FOUND});const s=new Cn("updateTopicProfile");return s.setMessage(`groupID:${e.groupID} topicID:${e.topicID}`),we(e.muteAllMembers)||(e.muteAllMembers=!0===e.muteAllMembers?"On":"Off"),this.request({protocolName:Yi,requestData:{...e}}).then(()=>(s.setNetworkType(this.getNetworkType()).end(),_e.l(t+" ok"),this._updateTopicMap([e]),wn({topic:this.getLocalTopic(e.groupID,e.topicID)}))).catch(e=>(this.probeNetwork().then(([t,o])=>{s.setError(e,t,o).end()}),_e.e(t+" failed. error:",e),Vn(e)))}getTopicList(e){const t=this._n+".getTopicList",{groupID:s,topicIDList:o=[]}=e,i=0===o.length,n=new Cn("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(),_e.l(`${t} groupID:${s} from cache, topic count:${e.length}`),xn({successTopicList:e,failureTopicList:[]})}}return this.request({protocolName:ji,requestData:{groupID:s,topicIDList:o}}).then(e=>{const{topicInfoList:o=[]}=e.data,r=[],a=[],u=[];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)):u.push({topicID:n,code:o,message:i})}),this._updateTopicMap(r),this._handleTopicAtInfo(r);const c=`success count:${a.length}, fail count:${u.length}`;n.setNetworkType(this.getNetworkType()).setMoreMessage(""+c).end(),_e.l(`${t} groupID:${s} from remote, ${c}`);let l=[];return Lt(a)||(this._getTopicTimeMap.set(s,{time:Date.now(),isGetAll:i}),l=this._getLocalTopicList(s,a)),wn({successTopicList:l,failureTopicList:u})}).catch(e=>(this.probeNetwork(e).then(([t,s])=>{n.setError(e,t,s).end()}),_e.e(t+" failed. error:",e),Vn(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).delete(t),_e.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 kr(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(_s).updateTopicConversation(s)}}resetGetTopicTime(e){if(!we(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=[];e.forEach(e=>{const s=[];this._getLocalTopicList(e).forEach(e=>{const{lastMessage:{lastTime:t=0}}=e;Date.now()-1e3*t<1e3*this.TOPIC_LAST_ACTIVE_TIME&&s.push(e.topicID)}),s.length>0&&t.push({groupID:e,topicIDList:s})}),_e.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 Cn("relayGetTopicList");o.setMessage(s),_e.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(!we(o)){o.forEach(e=>{i.push({...e,groupID:t,topicID:s})});this.getModule(_s).onNewGroupAtTips({dataList:i})}})}_getTopicLastMessage(e){if(!we(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,version:e.lastMsg.messageVersion,cloudCustomData:e.lastMsg.cloudCustomData,isRevoked:2===e.lastMsg.isPlaceMessage,revoker:Lt(e.lastMsg.revokerInfo)?null:e.lastMsg.revokerInfo.revoker};e.lastMessage=t}}deleteTopicListInCommunity(e){const s=this._getLocalTopicList(e),o=this.getModule(_s);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(be(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(Us);if(!s)return!0;const{isAllowedToSend:o,modifiedText:i}=s.filterText(t[e],E);return!0===o&&(t[e]=i,!0)}updateLastMessage(t,s){const o=ft(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){_e.l(`${this._n}.getMessageExtensions startSequence:${t}`);const s=ft(e.to);return this.request({protocolName:Mi,requestData:{groupID:s,topicID:e.to,messageSequence:e.sequence,startSequence:t}})}modifyMessageExtensions(e,t,s=1){_e.l(`${this._n}.modifyMessageExtensions operateType:${s}`);const o=ft(e.to);return this.request({protocolName:mi,requestData:{groupID:o,topicID:e.to,messageSequence:e.sequence,extensionList:t,operateType:s}})}reset(){_e.l(this._n+".reset"),this._topicMap.clear(),this._getTopicTimeMap.clear(),this.TOPIC_CACHE_TIME=300,this.TOPIC_LAST_ACTIVE_TIME=3600}}class br{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&&(_e.w(`${t} ${Dt(100)}`),s.length=100);const o=[],i=[];let n;for(let c=0,l=s.length;c<l;c++)n=s[c],this._userModule.isMyFriend(n)&&this._contains(n)?i.push(this._getProfileFromMap(n)):o.push(n);if(0===o.length)return xn(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 u=new Cn("getUserProfile");u.setMessage(s.length>5?"userIDList.length:"+s.length:"userIDList:"+s);return this._userModule.request({protocolName:Ys,requestData:e}).then(e=>{u.setNetworkType(this._userModule.getNetworkType()).end(),_e.i(t+" ok");const s=this._handleResponse(e).concat(i);return wn(r?s[0]:s)}).catch(e=>(this._userModule.probeNetwork().then(([t,s])=>{u.setError(e,t,s).end()}),_e.e(t+" failed. error:",e),Vn(e)))}getMyProfile(){const e=this._userModule.getMyAccount(),t=this._n+".getMyProfile";if(_e.l(`${t} myAccount:${e}`),this._fill(),this._contains(e)){const s=this._getProfileFromMap(e);return _e.d(`${t} from cache, myProfile:${JSON.stringify(s)}`),xn(s)}return this.getUserProfile({fromAccount:e,userIDList:[e],bFromGetMyProfile:!0})}_handleResponse(e){const{userProfileItem:t}=e.data;if(!be(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 _e.l(`${this._n}._handleResponse cost ${Date.now()-o} ms`),s}_getLatestProfileFromResponse(e,t){const s={userID:e,profileCustomField:[]};if(!Lt(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 Me.NICK:s.nick=t[o].value;break;case Me.GENDER:s.gender=t[o].value;break;case Me.BIRTHDAY:s.birthday=t[o].value;break;case Me.LOCATION:s.location=t[o].value;break;case Me.SELFSIGNATURE:s.selfSignature=t[o].value;break;case Me.ALLOWTYPE:s.allowType=t[o].value;break;case Me.LANGUAGE:s.language=t[o].value;break;case Me.AVATAR:s.avatar=t[o].value;break;case Me.MESSAGESETTINGS:s.messageSettings=t[o].value;break;case Me.ADMINFORBIDTYPE:s.adminForbidType=t[o].value;break;case Me.LEVEL:s.level=t[o].value;break;case Me.ROLE:s.role=t[o].value;break;default:_e.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 Vn({code:nn.PROFANITY_FOUND});if(t.selfSignature&&!1===this._userModule.filterProfanity("selfSignature",t))return Vn({code:nn.PROFANITY_FOUND});const o=new Cn("updateMyProfile");o.setMessage(JSON.stringify(t));const i=(new tr).validate(t);if(!i.valid)return o.setCode(nn.UPDATE_PROFILE_INVALID_PARAM).setMoreMessage("info:"+i.tips).setNetworkType(this._userModule.getNetworkType()).end(),_e.e(`${s} info:${i.tips}`),Vn({code:nn.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:Me[e.toUpperCase()],value:t[e]}));if(0===n.length){const e=new Fn({code:nn.UPDATE_PROFILE_NO_KEY});return o.setError(e,!0,this._userModule.getNetworkType()).end(),_e.e(s+" failed. error:",e),Vn(e)}const r=this._userModule.getMyAccount();return this._userModule.request({protocolName:js,requestData:{fromAccount:r,profileItem:n}}).then(i=>{o.setNetworkType(this._userModule.getNetworkType()).end(),_e.i(s+" ok");const{isProfileUpdated:n,latestProfile:a}=this._update(r,t);return!0===n&&this._userModule.emitOuterEvent(e.PROFILE_UPDATED,[a]),xn(a)}).catch(e=>(this._userModule.probeNetwork().then(([t,s])=>{o.setError(e,t,s).end()}),_e.e(s+" failed. error:",e),Vn(e)))}onProfileModified(t){const s=t.dataList;if(Lt(s))return;const o=s.length;let i;_e.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(Yn,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]);_e.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===Qe(s.profileCustomField,t.profileCustomField)&&(s.lastUpdatedTime=i,o=!0);Be(s,t,["profileCustomField"])>0&&(s.lastUpdatedTime=i,o=!0)}else s=new tr(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()),_e.l(`${this._n}._update account:${e} isProfileUpdated:${o}`),{isProfileUpdated:o,latestProfile:s}}_flush(e){const t=[...this.accountProfileMap.values()],s=this._userModule.getStorageModule();_e.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 Lt(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),Be(i,t)>0&&o.push(s)):o.push(t.userID));0!==o.length&&(_e.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:""}}reset(){this._flush(!0),this.accountProfileMap.clear()}}class wr{constructor(e){Lt||(this.userID=e.userID||"",this.timeStamp=e.timeStamp||0)}}class Fr{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 Cn("getBlacklist");return this._userModule.request({protocolName:zs,requestData:s}).then(s=>{const{blackListItem:i,currentSequence:n}=s.data,r=Lt(i)?0:i.length;o.setNetworkType(this._userModule.getNetworkType()).setMessage("count:"+r).end(),_e.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()}),_e.e(t+" failed. error:",e),Vn(e)))}addBlacklist(e){const t=new Cn("addToBlacklist"),s=this._n+".addBlacklist",o=this._userModule.getMyAccount();if(1===e.userIDList.length&&e.userIDList[0]===o){const e=nn.CANNOT_ADD_SELF_TO_BLACKLIST,o=this._userModule.getErrorMessage(e);t.setCode(e).setMessage(o).setNetworkType(this._userModule.getNetworkType()).end();const i=new Fn({code:e});return _e.e(s+" failed. error:",i),Vn(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:Js,requestData:e}).then(o=>(t.setNetworkType(this._userModule.getNetworkType()).setMessage(e.userIDList.length>5?"userIDList.length:"+e.userIDList.length:"userIDList:"+e.userIDList).end(),_e.i(s+" ok"),this._handleResponse(o.resultItem,!0),wn([...this._blacklistMap.keys()]))).catch(e=>(this._userModule.probeNetwork().then(([s,o])=>{t.setError(e,s,o).end()}),_e.e(s+" failed. error:",e),Vn(e)))}_handleResponse(e,t){if(!Lt(e)){let s,o,i;for(let n=0,r=e.length;n<r;n++)o=e[n].to,i=e[n].resultCode,(we(i)||0===i)&&(t?(s=this._blacklistMap.has(o)?this._blacklistMap.get(o):new wr,s.userID=o,!Lt(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)))}_e.l(`${this._n}._handleResponse total:${this._blacklistMap.size} bAdd:${t}`)}deleteBlacklist(e){const t=this._n+".deleteBlacklist",s=new Cn("removeFromBlacklist");e.fromAccount=this._userModule.getMyAccount(),e.toAccount=e.userIDList;return this._userModule.request({protocolName:Xs,requestData:e}).then(o=>(s.setNetworkType(this._userModule.getNetworkType()).setMessage(e.userIDList.length>5?"userIDList.length:"+e.userIDList.length:"userIDList:"+e.userIDList).end(),_e.i(t+" ok"),this._handleResponse(o.data.resultItem,!1),wn([...this._blacklistMap.keys()]))).catch(e=>(this._userModule.probeNetwork().then(([t,o])=>{s.setError(e,t,o).end()}),_e.e(t+" failed. error:",e),Vn(e)))}onAccountDeleted(t){const s=[];let o;for(let e=0,i=t.length;e<i;e++)o=t[e],this._blacklistMap.has(o)&&(this._blacklistMap.delete(o),s.push(o));s.length>0&&(_e.l(`${this._n}.onAccountDeleted count:${s.length} userIDList:`,s),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 wr({userID:o})),s.push(o));s.length>0&&(_e.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 $r=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 qr{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(Wn,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");_e.l(`${this._n}._onCloudConfigUpdated statusQueryCount:${e} statusSubscribeCount:${t} statusUnsubscribeCount:`+s),we(e)||(this.MAX_QUERY_USER_COUNT=parseInt(e,10)),we(e)||(this.MAX_SUBSCRIBE_USER_COUNT=parseInt(t,10)),we(e)||(this.MAX_UNSUBSCRIBE_USER_COUNT=parseInt(s,10))}onUserStatusUpdated(t){const{dataList:s}=t,o=this._userModule.getMyUserID(),i=this._userModule.getModule(ms),n=s.map(e=>{const{to:t,statusType:s,customStatus:n}=e,r=$r(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 Vn({code:nn.PROFANITY_FOUND});const s=new Cn("setSelfStatus"),{customStatus:o}=e;return this._userModule.request({protocolName:zi,requestData:{customStatus:o}}).then(e=>{s.setNetworkType(this._userModule.getNetworkType()).setMessage("customStatus:"+o).end(),_e.l(`${t} ok. customStatus:${o}`);return this._userModule.getModule(ms).setCustomStatus(o),wn({userID:this._userModule.getMyUserID(),statusType:1,customStatus:o})}).catch(e=>(this._userModule.probeNetwork().then(([t,o])=>{s.setError(e,t,o).end()}),_e.e(t+" failed. error:",e),Vn(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(ms).getCustomStatus();n={userID:o,statusType:1,customStatus:e}}if(0===i.length)return xn({successUserList:[n],failureUserList:[]});if(!this._userModule.canIUse(M.USER_STATUS))return Vn({code:nn.CANNOT_USE_COMMERCIAL_ABILITY});i.length>this.MAX_QUERY_USER_COUNT&&(_e.w(`${t} ${Dt(this.MAX_QUERY_USER_COUNT)}`),i=s.slice(0,this.MAX_QUERY_USER_COUNT));const a=new Cn("getUserStatus");return this._userModule.request({protocolName:Ji,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:$r(o)}}),u=i.map(e=>{const{userID:t,invalidUserID:s,errorCode:o,errorInfo:i}=e;return{userID:Lt(s)?t:s,code:o,message:i}});we(n)||r.unshift(n);const c=`userID count:${s.length}, success count:${r.length}, fail count:${u.length}`;return a.setNetworkType(this._userModule.getNetworkType()).setMessage(""+c).end(),_e.l(`${t} ok. ${c}.`),wn({successUserList:r,failureUserList:u})}).catch(e=>(this._userModule.probeNetwork().then(([t,o])=>{a.setMessage("userID count:"+s.length).setError(e,t,o).end()}),_e.e(t+" failed. error:",e),Vn(e)))}subscribeUserStatus(e){if(!this._userModule.canIUse(M.USER_STATUS))return Vn({code:nn.CANNOT_USE_COMMERCIAL_ABILITY});const t=this._n+".subscribeUserStatus",{userIDList:s=[]}=e;let o=[...s];o.length>this.MAX_SUBSCRIBE_USER_COUNT&&(_e.w(`${t} ${Dt(this.MAX_SUBSCRIBE_USER_COUNT)}`),o=s.slice(0,this.MAX_SUBSCRIBE_USER_COUNT));const i=new Cn("subscribeUserStatus"),n="userID count:"+s.length;return _e.l(`${t} ${n}`),this._userModule.request({protocolName:Xi,requestData:{userIDList:o}}).then(e=>{const{failureUserList:s=[]}=e.data,o=s.map(e=>{const{userID:t,invalidUserID:s,errorCode:o,errorInfo:i}=e;return{userID:Lt(s)?t:s,code:o,message:i}});return i.setNetworkType(this._userModule.getNetworkType()).setMessage(`${n} fail count:${o.length}`).end(),_e.l(`${t} ok. fail count:${o.length}.`),wn({failureUserList:o})}).catch(e=>(this._userModule.probeNetwork().then(([t,s])=>{i.setMessage(""+n).setError(e,t,s).end()}),_e.e(t+" failed. error:",e),Vn(e)))}unsubscribeUserStatus(e){if(!this._userModule.canIUse(M.USER_STATUS))return Vn({code:nn.CANNOT_USE_COMMERCIAL_ABILITY});const t=this._n+".unsubscribeUserStatus",{userIDList:s=[]}=e||{};let o=[...s];s.length>this.MAX_UNSUBSCRIBE_USER_COUNT&&(_e.w(`${t} ${Dt(this.MAX_UNSUBSCRIBE_USER_COUNT)}`),o=s.slice(0,this.MAX_UNSUBSCRIBE_USER_COUNT));const i=new Cn("unsubscribeUserStatus"),n="userID count:"+s.length;_e.l(`${t} ${n}`);const r={userIDList:o};return 0===o.length&&(r.userIDList=void 0,r.unsubscribeAll=1),this._userModule.request({protocolName:Zi,requestData:r}).then(e=>{const{failureUserList:s=[]}=e.data,o=s.map(e=>{const{userID:t,invalidUserID:s,errorCode:o,errorInfo:i}=e;return{userID:Lt(s)?t:s,code:o,message:i}});return i.setNetworkType(this._userModule.getNetworkType()).setMessage(`${n} fail count:${o.length}`).end(),_e.l(`${t} ok. fail count:${o.length}.`),wn({failureUserList:o})}).catch(e=>(this._userModule.probeNetwork().then(([t,s])=>{i.setMessage(""+n).setError(e,t,s).end()}),_e.e(t+" failed. error:",e),Vn(e)))}reset(){this.MAX_QUERY_USER_COUNT=500,this.MAX_SUBSCRIBE_USER_COUNT=100,this.MAX_UNSUBSCRIBE_USER_COUNT=100}}class xr extends Fs{constructor(e){super(e),this._n="UserModule",this._profileHandler=new br(this),this._blacklistHandler=new Fr(this),this._userStatusHandler=new qr(this);this.getInnerEmitterInstance().on(Kn,this.onContextUpdated,this)}onContextUpdated(e){this._profileHandler.getMyProfile(),this._blacklistHandler.getBlacklist()}onProfileModified(e){this._profileHandler.onProfileModified(e)}onRelationChainModified(e){const{dataList:t}=e;if(Lt(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()}getMyProfile(){return this._profileHandler.getMyProfile()}getStorageModule(){return this.getModule(Ms)}filterProfanity(e,t){const s=this.getModule(Us);if(!s)return!0;const{isAllowedToSend:o,modifiedText:i}=s.filterText(t[e],y);return!0===o&&(t[e]=i,!0)}isMyFriend(e){const t=this.getModule(ps);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)}getLocalBlacklist(){const e=this._blacklistHandler.getLocalBlacklist();return xn(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(){_e.l(this._n+".reset"),this._profileHandler.reset(),this._blacklistHandler.reset(),this._userStatusHandler.reset()}}class Vr{constructor(e,t){this._m=e,this._isLoggedIn=!1,this._SDKAppID=t.SDKAppID,this._userID=t.userID||"",this._userSig=t.userSig||"",this._version="2.27.6",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}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}isIntl(){return 0===(e=this._SDKAppID)||e>=2e7&&e<8e7||e>=172e7&&e<178e7;var e}isUnlimitedAVChatRoom(){return this._unlimitedAVChatRoom}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 te?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}_isTUIKit(){let e=!1,t=!1,s=!1,o=!1,i=[];P&&(i=Object.keys(w)),b&&(i=k?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,P&&!$e(w.createGamePortal)&&$e(getApp)&&!we(getApp())){const e=getApp().globalData;Pe(e)&&!0===e.isTUIKit&&(t=!0)}!0===this._m.getModule(Ms).getStorageSync(`TIM_${this._SDKAppID}_isTUIKit`)&&(s=!0);let n=null;if(L&&!N&&"undefined"==typeof uni&&__wxConfig&&(n=__wxConfig.pages),v&&"undefined"==typeof uni&&__qqConfig&&(n=__qqConfig.pages),be(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}}class Br extends Fs{constructor(e){super(e),this._n="SignModule",this._helloInterval=120,this._lastLoginTs=0,this._lastWsHelloTs=0,this._isWebUniapp=0,jn.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&&_e.w(t),xn({actionStatus:"OK",errorCode:0,errorInfo:t,repeatLogin:!0})}if(Date.now()-this._lastLoginTs<=15e3)return this.outputWarning("LoggingIn",e.userID),Vn({code:nn.REPEAT_LOGIN});_e.l(`${this._n}.login userID:${e.userID}`);const s=this._checkLoginInfo(e);if(0!==s.code)return Vn(s);const o=this.getModule(ms),{userID:i,userSig:n}=e;o.setUserID(i),o.setUserSig(n);return this.getModule(Es).updateProtocolConfig(),this._login()}_login(){const e=this.getModule(ms),t=e.getScene();let s=0;const o=new Cn("login");o.setMessage(""+t).setMoreMessage("identifier:"+this.getMyUserID()),k?"tuikit"===t?o.setUIPlatform(4):o.setUIPlatform(3):P?"tuikit"===t?o.setUIPlatform(12):o.setUIPlatform(11):b&&(te?"flutter_web_uikit"===t?o.setUIPlatform(21):o.setUIPlatform(20):this._isReactUIKit()?ee?o.setUIPlatform(25):o.setUIPlatform(24):ee?"tuikit"===t?o.setUIPlatform(17):o.setUIPlatform(16):"tuikit"===t?o.setUIPlatform(14):o.setUIPlatform(13));const i=this.getModule(Gs);if(i.canIUseOfflinePush()){this._isWebUniapp=i.getUniAppPlatform();const t=this._getStatusInstanceID();e.setStatusInstanceID(t);this.getModule(Es).updateProtocolConfig(),s=i.getDeviceBrand()}const n=this._n+"._login";return this._lastLoginTs=Date.now(),this.request({protocolName:$s,requestData:{deviceBrand:s,isWebUniapp:this._isWebUniapp}}).then(s=>{this._lastLoginTs=0;const i=Date.now();let r=null;const{a2Key:a,tinyID:u,helloInterval:c,instanceID:l,timeStamp:d,customStatus:p="",purchaseBits:h}=s.data;_e.l(`${n} ok. scene:${t} helloInterval:${c} instanceID:${l} timeStamp:${d}`);const g=1e3*d,_=i-o.getStartTs(),m=g+parseInt(_/2)-i,M=o.getStartTs()+m;if(o.start(M),function(e,t){ue=t;const s=new Date;s.setTime(e),_e.i(`baseTime from server:${s} offset:${ue}`)}(g,m),!u)throw r=new Fn({code:nn.NO_TINYID}),o.setError(r,!0,this.getNetworkType()).end(),r;if(!a)throw r=new Fn({code:nn.NO_A2KEY}),o.setError(r,!0,this.getNetworkType()).end(),r;const f=$r(p);if(o.setNetworkType(this.getNetworkType()).setMoreMessage(`helloInterval:${c} instanceID:${l} offset:${m} customStatus:${f}`).end(),e.setA2Key(a),e.setTinyID(u),e.setStatusInstanceID(l),e.setCustomStatus(f),h){this.getModule(Os).onPushedConfig({errorCode:0,expiredTime:0,purchaseBits:h})}this.getModule(Es).updateProtocolConfig(),this.emitInnerEvent(Kn),this._helloInterval=c,this.triggerReady();const I=this.getModule(Gs);I.canIUseOfflinePush()&&(uni.setStorageSync("timUniAppInstanceID",l),I.init()),this._fetchCloudControlConfig();return this.getModule(Us).init(),s}).catch(e=>(this.probeNetwork().then(([t,s])=>{o.setError(e,t,s).end(!0)}),this._m.setNotReadyReason(nn.LOGIN_FAILED),_e.e(n+" failed. error:",e),this._lastLoginTs=0,this._m.onLoginFailed(),Vn(e)))}logout(e=0){if(!this.isLoggedIn())return Vn({code:nn.USER_NOT_LOGGED_IN});new Cn("logout").setNetworkType(this.getNetworkType()).setMessage("identifier:"+this.getMyUserID()).end(!0);const t=this._n+".logout";return _e.i(`${t} type:${e}`),0===e&&this._m.setNotReadyReason(nn.LOGGED_OUT),this.request({protocolName:qs,requestData:{type:e}}).then(()=>(this.resetReady(),xn({}))).catch(e=>(_e.e(t+" error:",e),this.resetReady(),xn({})))}_fetchCloudControlConfig(){this.getModule(As).fetchConfig()}_getStatusInstanceID(){return uni.getStorageSync("timUniAppInstanceID")}_hello(){this._lastWsHelloTs=Date.now(),this.request({protocolName:xs,requestData:{isWebUniapp:this._isWebUniapp}}).catch(e=>{_e.w(this._n+"._hello error:",e)})}getLastWsHelloTs(){return this._lastWsHelloTs}_checkLoginInfo(e){let t=0;return Lt(this.getModule(ms).getSDKAppID())?t=nn.NO_SDKAPPID:Lt(e.userID)?t=nn.NO_IDENTIFIER:Lt(e.userSig)&&(t=nn.NO_USERSIG),{code:t}}_isReactUIKit(){return b&&void 0!==window.tencent_cloud_im_csig_react_uikit_23F_xa}onMultipleAccountKickedOut(s){new Cn("kickedOut").setNetworkType(this.getNetworkType()).setMessage(`type:${t.KICKED_OUT_MULT_ACCOUNT} newInstanceInfo:${JSON.stringify(s)}`).end(!0),_e.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(nn.KICKED_OUT_MULT_ACCOUNT),this._m.reset()})}onMultipleDeviceKickedOut(s){new Cn("kickedOut").setNetworkType(this.getNetworkType()).setMessage(`type:${t.KICKED_OUT_MULT_DEVICE} newInstanceInfo:${JSON.stringify(s)}`).end(!0),_e.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(nn.KICKED_OUT_MULT_DEVICE),this._m.reset()})}onUserSigExpired(){new Cn("kickedOut").setNetworkType(this.getNetworkType()).setMessage(t.KICKED_OUT_USERSIG_EXPIRED).end(!0),_e.w(this._n+".onUserSigExpired: userSig expired");0!==this.getModule(ms).getStatusInstanceID()&&(this.emitOuterEvent(e.KICKED_OUT,{type:t.KICKED_OUT_USERSIG_EXPIRED}),this._m.setNotReadyReason(nn.KICKED_OUT_USERSIG_EXPIRED),this._m.reset())}onRestApiKickedOut(s){new Cn("kickedOut").setNetworkType(this.getNetworkType()).setMessage(`type:${t.KICKED_OUT_REST_API} newInstanceInfo:${JSON.stringify(s)}`).end(!0),_e.w(`${this._n}.onRestApiKickedOut userID:${this.getMyUserID()} newInstanceInfo:`,s);if(0!==this.getModule(ms).getStatusInstanceID()){this.emitOuterEvent(e.KICKED_OUT,{type:t.KICKED_OUT_REST_API}),this._m.setNotReadyReason(nn.KICKED_OUT_REST_API),this._m.reset();this.getModule(Ss).onRestApiKickedOut()}}reset(){_e.l(this._n+".reset"),this.resetReady(),this._helloInterval=120,this._lastLoginTs=0,this._lastWsHelloTs=0,this._isWebUniapp=0}}function Hr(){return null}class Kr{constructor(e){this._m=e,this._n="StorageModule",this._storageQueue=new Map,this._errorTolerantHandle()}_errorTolerantHandle(){P||!we(window)&&this._canIUseCookies()||(this.getItem=Hr,this.setItem=Hr,this.removeItem=Hr,this.clear=Hr)}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){_e.w(this._n+"._doFlush error:",e)}}_getPrefix(){const e=this._m.getModule(ms);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 _e.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{P?w.clearStorageSync():this._canIUseCookies()&&localStorage.clear()}catch(e){_e.w(this._n+".clear error:",e)}}removeItem(e,t=!0){try{const s=t?this._getKey(e):e;this._removeStorageSync(s)}catch(s){_e.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}),P&&(s.limitSize=1024*w.getStorageInfoSync().limitSize),e)s.size=JSON.stringify(this.getItem(e)).length+this._getKey(e).length;else if(P){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){_e.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){P?O?my.setStorageSync({key:e,data:t}):w.setStorageSync(e,t):this._canIUseCookies()&&localStorage.setItem(e,JSON.stringify(t))}getStorageSync(e){if(P){if(O){return my.getStorageSync({key:e}).data}return w.getStorageSync(e)}return this._canIUseCookies()?JSON.parse(localStorage.getItem(e)):{}}_removeStorageSync(e){P?O?my.removeStorageSync({key:e}):w.removeStorageSync(e):this._canIUseCookies()&&localStorage.removeItem(e)}_canIUseCookies(){return navigator&&navigator.cookieEnabled&&localStorage}reset(){_e.l(this._n+".reset"),this._doFlush()}}class Wr{constructor(e){this._n="SSOLogBody",this._report=[]}pushIn(e){_e.d(this._n+".pushIn",this._report.length,e),this._report.push(e)}backfill(e){be(e)&&0!==e.length&&(_e.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 Yr=function(e){const t=e.getModule(ms);return{SDKType:10,SDKAppID:t.getSDKAppID(),SDKVersion:t.getVersion(),tinyID:Number(t.getTinyID()),userID:t.getUserID(),platform:e.getPlatform(),instanceID:t.getInstanceID(),traceID:ce()}};class jr extends Fs{constructor(e){super(e),this._n="EventStatModule",this.TAG="im-ssolog-event",this._reportBody=new Wr,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(Kn,this._onLoginSuccess,this),t.on(Wn,this._onCloudConfigUpdated,this)}reportAtOnce(){_e.d(this._n+".reportAtOnce"),this._report()}_onLoginSuccess(){const e=this.getModule(Ms),t=e.getItem(this.TAG,!1);!Lt(t)&&$e(t.forEach)&&(_e.l(`${this._n}._onLoginSuccess get ssolog in storage, 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");we(e)||(this.MIN_THRESHOLD=Number(e)),we(t)||(this.WAITING_TIME=Number(t)),we(s)||(this.REPORT_LEVEL=s.split(",").map(e=>Number(e))),we(o)||(this.REPORT_SDKAPPID_BLACKLIST=o.split(",").map(e=>Number(e))),we(i)||(this.REPORT_TINYID_WHITELIST=i.split(","))}pushIn(e){e instanceof Cn&&(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(ms),s=t.getSDKAppID(),o=t.getTinyID();if(mt(this.REPORT_SDKAPPID_BLACKLIST,s)&&!Mt(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:Yr(this),event:t};this.request({protocolName:Gi,requestData:{...s}}).then(()=>{this._lastReportTime=Date.now()}).catch(t=>{_e.w(`${this._n}.report failed. networkType:${this.getNetworkType()} error:`,t),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(Lt(t))_e.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)),_e.l(`${o} count:${i.length}`),e.setItem(this.TAG,i,!0,!1)}}reset(){_e.l(this._n+".reset"),this._lastReportTime=0,this._report(),this.REPORT_SDKAPPID_BLACKLIST=[],this.REPORT_TINYID_WHITELIST=[]}}const zr="none",Jr="online",Xr=[nn.OVER_FREQUENCY_LIMIT,nn.OPEN_SERVICE_OVERLOAD_ERROR];class Zr{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(){P?(w.getNetworkType({success:e=>{this._networkType=e.networkType||e.subtype||"",e.networkType===zr?_e.w(this._n+".start no network, please check!"):_e.i(`${this._n}.start networkType:${e.networkType}`)}}),this._mpNetworkStatusCallback=this._onNetworkStatusChange.bind(this),w.onNetworkStatusChange(this._mpNetworkStatusCallback)):(this._networkType=Jr,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:Jr})}_onWebOffline(){this._onNetworkStatusChange({isConnected:!1,networkType:zr})}_onNetworkStatusChange(e){const{isConnected:t,networkType:s}=e,o=this._n+"._onNetworkStatusChange";let i=!1;if(t){if(_e.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,_e.w(o+" no network, please check!");this._m.getModule(Ss).offline()}if(i){new Cn("networkChange").setMessage(`isConnected:${t} previousNetworkType:${this._networkType} networkType:${s}`).end(),this._networkType=s}}probe(e){if(!we(e)&&Xr.includes(e.code))return Promise.resolve([!0,this._networkType]);const t=this._n+".probe";return new Promise((e,s)=>{P?w.getNetworkType({success:s=>{this._networkType=s.networkType,s.networkType===zr?(_e.w(t+" no network, please check!"),e([!1,s.networkType])):(_e.i(`${t} networkType:${s.networkType}`),e([!0,s.networkType]))}}):this._networkType===zr?e([!1,zr]):e([!0,Jr])})}getNetworkType(){return this._networkType}reset(){_e.l(this._n+".reset"),P?null!==this._mpNetworkStatusCallback&&(w.offNetworkStatusChange&&(U||N?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))}}function Qr(e,t){return e(t={exports:{}},t.exports),t.exports}var ea=Qr((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),u=s?s+t:t;return e._events[u]?e._events[u].fn?e._events[u]=[e._events[u],a]:e._events[u].push(a):(e._events[u]=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 u,c,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(c=1,u=new Array(d-1);c<d;c++)u[c-1]=arguments[c];l.fn.apply(l.context,u)}else{var p,h=l.length;for(c=0;c<h;c++)switch(l[c].once&&this.removeListener(e,l[c].fn,void 0,!0),d){case 1:l[c].fn.call(l[c].context);break;case 2:l[c].fn.call(l[c].context,t);break;case 3:l[c].fn.call(l[c].context,t,o);break;case 4:l[c].fn.call(l[c].context,t,o,i);break;default:if(!u)for(p=1,u=new Array(d-1);p<d;p++)u[p-1]=arguments[p];l[c].fn.apply(l[c].context,u)}}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 u=0,c=[],l=a.length;u<l;u++)(a[u].fn!==t||i&&!a[u].once||o&&a[u].context!==o)&&c.push(a[u]);c.length?this._events[n]=1===c.length?c[0]:c: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}));class ta extends Fs{constructor(e){super(e),this._n="BigDataChannelModule",this.FILETYPE={SOUND:2106,FILE:2107,VIDEO:2113},this._bdh_download_server="grouptalk.c2c.qq.com",this._BDHBizID=10001,this._authKey="",this._expireTime=0,this.getInnerEmitterInstance().on(Kn,this._getAuthKey,this)}_getAuthKey(){this.isIntl()||this.request({protocolName:Hs}).then(e=>{e.data.authKey&&(this._authKey=e.data.authKey,this._expireTime=parseInt(e.data.expireTime))})}_isFromOlderVersion(e){return!(!e.content||2===e.content.downloadFlag)}parseElements(e,t){if(!be(e)||!t)return[];const s=[];let o=null;for(let i=0;i<e.length;i++)o=e[i],this._needParse(o)?s.push(this._parseElement(o,t)):s.push(e[i]);return s}_needParse(e){return!e.cloudCustomData&&!(!this._isFromOlderVersion(e)||e.type!==t.MSG_AUDIO&&e.type!==t.MSG_FILE&&e.type!==t.MSG_VIDEO)}_parseElement(e,s){switch(e.type){case t.MSG_AUDIO:return this._parseAudioElement(e,s);case t.MSG_FILE:return this._parseFileElement(e,s);case t.MSG_VIDEO:return this._parseVideoElement(e,s)}}_parseAudioElement(e,t){return e.content.url=this._genAudioUrl(e.content.uuid,t),e}_parseFileElement(e,t){return e.content.url=this._genFileUrl(e.content.uuid,t,e.content.fileName),e}_parseVideoElement(e,t){return e.content.url=this._genVideoUrl(e.content.uuid,t),e}_genAudioUrl(e,t){if(""===this._authKey)return"";const s=this.getModule(ms).getSDKAppID();return`https://${this._bdh_download_server}/asn.com/stddownload_common_file?authkey=${this._authKey}&bid=${this._BDHBizID}&subbid=${s}&fileid=${e}&filetype=${this.FILETYPE.SOUND}&openid=${t}&ver=0`}_genFileUrl(e,t,s){if(""===this._authKey)return"";s||(s=`${Math.floor(1e5*Math.random())}-${Date.now()}`);const o=this.getModule(ms).getSDKAppID();return`https://${this._bdh_download_server}/asn.com/stddownload_common_file?authkey=${this._authKey}&bid=${this._BDHBizID}&subbid=${o}&fileid=${e}&filetype=${this.FILETYPE.FILE}&openid=${t}&ver=0&filename=${encodeURIComponent(s)}`}_genVideoUrl(e,t){if(""===this._authKey)return"";const s=this.getModule(ms).getSDKAppID();return`https://${this._bdh_download_server}/asn.com/stddownload_common_file?authkey=${this._authKey}&bid=${this._BDHBizID}&subbid=${s}&fileid=${e}&filetype=${this.FILETYPE.VIDEO}&openid=${t}&ver=0`}reset(){this._authKey="",this.expireTime=0}}class sa extends Fs{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={AUDIO:20971520,FILE:104857600,IMAGE:20971520,VIDEO:104857600};const t=this.getInnerEmitterInstance();t.on(Kn,this._init,this),t.on(Wn,this._onCloudConfigUpdated,this)}_init(){const e=this.getModule(ys);if(this.TIMUploadPlugin=e.getPlugin("tim-upload-plugin"),this.TIMUploadPlugin)return void this._initUploaderMethod();const t=P?"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");if(_e.l(`${e} uploadSizeLimit:${t}`),!we(t))try{const e=JSON.parse(t);this.UPLOAD_SIZE_LIMIT={AUDIO:e.a?1048576*parseInt(e.a):this.UPLOAD_SIZE_LIMIT.AUDIO,FILE:e.f?1048576*parseInt(e.f):this.UPLOAD_SIZE_LIMIT.FILE,IMAGE:e.i?1048576*parseInt(e.i):this.UPLOAD_SIZE_LIMIT.IMAGE,VIDEO:e.v?1048576*parseInt(e.v):this.UPLOAD_SIZE_LIMIT.VIDEO}}catch(s){_e.e(e+" JSON parse error. uploadSizeLimit:",t)}}_getAuthorizationKey(){const e=this._n+"._getAuthorizationKey",t=new Cn("_getAuthorizationKey"),s=Math.ceil(Date.now()/1e3);this.request({protocolName:Ni,requestData:{duration:this.expiredTimeLimit}}).then(o=>{const{data:i}=o;_e.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(),!P&&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},_e.l(`${e} ok. region:${this.region} bucketName:${this.bucketName}`),this._initUploaderMethod()}).catch(s=>{this.probeNetwork().then(([e,o])=>{t.setError(s,e,o).end()}),_e.w(e+" failed. error:",s)})}_getCosPreSigUrl(e){const t=this._n+"._getCosPreSigUrl",s=Math.ceil(Date.now()/1e3),o=new Cn("_getCosPreSigUrl");return this.request({protocolName:Ri,requestData:{fileType:e.fileType,fileName:e.fileName,uploadMethod:e.uploadMethod,duration:e.duration}}).then(e=>{this.tryCount=0;const i=e.data||{},n=i.expiredTime-s;return _e.l(t+" ok. data:",i),o.setMessage(`requestId:${i.requestId} expiredTime:${i.expiredTime} diff:${n}s`).setNetworkType(this.getNetworkType()).end(),i}).catch(s=>(-1===s.code&&(s.code=nn.COS_GET_SIG_FAIL),this.probeNetwork().then(([e,t])=>{o.setError(s,e,t).end()}),_e.w(t+" failed. error:",s),this.tryCount<1?(this.tryCount++,this._getCosPreSigUrl(e)):(this.tryCount=0,Vn({code:nn.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=P?new this.COSSDK({ForcePathStyle:!0,getAuthorization:this._getAuthorization.bind(this)}):new this.COSSDK({getAuthorization:this._getAuthorization.bind(this)}),this._cosUploadMethod=P?(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.getRelayFlag())return Promise.resolve();const s=this.getModule(Rs);switch(e.type){case t.MSG_IMAGE:return s.addTotalCount(pn),this._uploadImage(e);case t.MSG_FILE:return s.addTotalCount(pn),this._uploadFile(e);case t.MSG_AUDIO:return s.addTotalCount(pn),this._uploadAudio(e);case t.MSG_VIDEO:return s.addTotalCount(pn),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,onProgress:e=>{if(s.updatePercent(e),$e(o.onProgress))try{o.onProgress(e)}catch(t){return Vn({code:nn.MESSAGE_ONPROGRESS_FUNCTION_ERROR})}}}).then(({location:t,fileType:o,fileSize:i,width:n,height:r,smallImageUrl:a,smallImageWidth:u,smallImageHeight:c,largeImageUrl:l,largeImageWidth:d,largeImageHeight:p})=>{const h=this.isPrivateNetWork()?t:Xe(t);let g,_;return s.updateImageFormat(o),a&&l?(g={url:a,width:u,height:c},_={url:l,width:d,height:p}):(g=pt({originUrl:h,originWidth:n,originHeight:r,min:198}),_=pt({originUrl:h,originWidth:n,originHeight:r,min:720})),s.updateImageInfoArray([{size:i,url:h,width:n,height:r},{..._},{...g}]),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,onProgress:e=>{if(s.updatePercent(e),$e(o.onProgress))try{o.onProgress(e)}catch(t){return Vn({code:nn.MESSAGE_ONPROGRESS_FUNCTION_ERROR})}}}).then(({location:t})=>{const o=this.isPrivateNetWork()?t:Xe(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,onProgress:e=>{if(s.updatePercent(e),$e(o.onProgress))try{o.onProgress(e)}catch(t){return Vn({code:nn.MESSAGE_ONPROGRESS_FUNCTION_ERROR})}}}).then(({location:t})=>{const o=this.isPrivateNetWork()?t:Xe(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,onProgress:e=>{if(s.updatePercent(e),$e(o.onProgress))try{o.onProgress(e)}catch(t){return Vn({code:nn.MESSAGE_ONPROGRESS_FUNCTION_ERROR})}}}).then(t=>{const{location:o,snapshotInfo:i}=t,n=this.isPrivateNetWork()?o:Xe(o);return s.updateVideoUrl(n),Lt(i)||s.updateSnapshotInfo(i),e})}_checkSizeError(e){return Vn({code:nn[`MESSAGE_${e}_SIZE_LIMIT`],message:this.getErrorMessage("UploadSizeLimit",e.toLowerCase(),this.UPLOAD_SIZE_LIMIT[e]/1048576+" MB")})}doUploadImage(e){if(!e.file)return Vn({code:nn.MESSAGE_IMAGE_SELECT_FILE_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(Xn),this.uploadByCOS(e).then(e=>(o=e,this.isPrivateNetWork()?ut(e.location):ut("https://"+e.location))).then(e=>(o.width=e.width,o.height=e.height,Promise.resolve(o)))}_checkImageType(e){let t="";return t=P?e.url.slice(e.url.lastIndexOf(".")+1):e.files[0].name.slice(e.files[0].name.lastIndexOf(".")+1),zn.indexOf(t.toLowerCase())>=0||Vn({code:nn.MESSAGE_IMAGE_TYPES_LIMIT})}_checkImageSize(e){let t=0;return t=P?e.size:e.files[0].size,0===t?Vn({code:nn.MESSAGE_FILE_IS_EMPTY}):t<this.UPLOAD_SIZE_LIMIT.IMAGE||this._checkSizeError("IMAGE")}doUploadFile(e){let t=null;return e.file?e.file.files[0].size>this.UPLOAD_SIZE_LIMIT.FILE?this._checkSizeError("FILE"):0===e.file.files[0].size?(t={code:nn.MESSAGE_FILE_IS_EMPTY},Vn(t)):(this._setUploadFileType(er),this.uploadByCOS(e)):(t={code:nn.MESSAGE_FILE_SELECT_FILE_FIRST},Vn(t))}doUploadVideo(e){return e.file.videoFile.size>this.UPLOAD_SIZE_LIMIT.VIDEO?this._checkSizeError("VIDEO"):0===e.file.videoFile.size?Vn({code:nn.MESSAGE_FILE_IS_EMPTY}):-1===Jn.indexOf(e.file.videoFile.type)?Vn({code:nn.MESSAGE_VIDEO_TYPES_LIMIT}):(this._setUploadFileType(Zn),P?this.handleVideoUpload({file:e.file.videoFile,onProgress:e.onProgress}):b?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 Fn({code:nn.MESSAGE_VIDEO_UPLOAD_FAIL}))})})})}doUploadAudio(e){return e.file?e.file.size>this.UPLOAD_SIZE_LIMIT.AUDIO?this._checkSizeError("AUDIO"):0===e.file.size?Vn({code:nn.MESSAGE_FILE_IS_EMPTY}):(this._setUploadFileType(Qn),this.uploadByCOS(e)):Vn({code:nn.MESSAGE_AUDIO_UPLOAD_FAIL})}uploadByCOS(e){if(!$e(this._cosUploadMethod))return this.outputWarning("PluginUndetected"),Vn({code:nn.COS_UNDETECTED});if(this.timUploadPlugin)return this._uploadWithPreSigUrl(e);const t=new Cn("upload"),s=this._n+".uploadByCOS",o=Date.now(),i=this._getFile(e);return new Promise((n,r)=>{const a=P?this._createCosOptionsWXMiniApp(e):this._createCosOptionsWeb(e),u=this;this._cosUploadMethod(a,(e,a)=>{const c=Object.create(null);if(a){if(e||be(a.files)&&a.files[0].error){const e=new Fn({code:nn.MESSAGE_FILE_UPLOAD_FAIL});return t.setError(e,!0,this.getNetworkType()).end(),_e.l(s+" failed. error:",a.files[0].error),403===a.files[0].error.statusCode&&(_e.w(s+" failed. cos AccessKeyId was invalid, regain auth key!"),this._getAuthorizationKey()),void r(e)}c.fileName=i.name,c.fileSize=i.size,c.fileType=i.type.slice(i.type.indexOf("/")+1).toLowerCase(),c.location=P?a.Location:a.files[0].data.Location;const l=Date.now()-o,d=`size:${u._formatFileSize(i.size)} time:${l}ms speed:${u._formatSpeed(1e3*i.size/l)}`;_e.l(`${s} success. name:${i.name} ${d}`),n(c);const p=this.getModule(Rs);return p.addCost(pn,l),p.addFileSize(pn,i.size),void t.setNetworkType(this.getNetworkType()).setMessage(d).end()}const l=new Fn({code:nn.MESSAGE_FILE_UPLOAD_FAIL});t.setError(l,!0,u.getNetworkType()).end(),_e.w(s+" failed. error:",e),403===e.statusCode&&(_e.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 Cn("upload"),{requestSnapshotUrl:r,...a}=e,u=Date.now();this._cosUploadMethod(a,(e,c)=>{if(e||403===c.statusCode)return n.setError(new Fn(e),!0,this.getNetworkType()).end(),_e.l(t+" failed, error:",e),void i(new Fn({code:nn.MESSAGE_FILE_UPLOAD_FAIL}));const l=Object.create(null);let d=c.data.location||"";this.isPrivateNetWork()||0!==d.indexOf("https://")&&0!==d.indexOf("http://")||(d=d.split("//")[1]),l.fileName=s.name,l.fileSize=s.size,l.fileType=s.type.slice(s.type.indexOf("/")+1).toLowerCase(),l.location=d;const p=Date.now()-u,h=`size:${this._formatFileSize(s.size)},time:${p}ms,speed:${this._formatSpeed(1e3*s.size/p)} res:${JSON.stringify(c.data)}`;_e.l(`${t} success name:${s.name},${h}`),n.setNetworkType(this.getNetworkType()).setMessage(h).end();const g=this.getModule(Rs);g.addCost(pn,p),g.addFileSize(pn,s.size);let _=[];if(a.thumbUrl&&a.largeUrl&&(_=[this._getSmallImageInfoByUrl(a.thumbUrl,l),this._getLargeImageInfoByUrl(a.largeUrl,l)]),r&&_.push(this._getSnapshotInfoByUrl(r,l)),_.length>0)return Promise.all(_).then(()=>{o(l)});o(l)})}))}_getRawOrUploadProxyUrl(e){const t=this.getModule(ms).getFileUploadProxy();let s=e;return t&&(s=e.replace(/^https:\/\/[^/]+/,t)),s}_getFile(e){let t=null;var s;return t=be(e.file.files)||(s=e.file.files,"filelist"===xe(s))?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 _t(e/1024,1)+"KB/s"}return _t(e/1048576,1)+"MB/s"}_createCosOptionsWeb(e){const t=this._getFile(e),s=t.name,o=s.slice(s.lastIndexOf(".")),i=this._genFileName(`${We(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){_e.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(_e.l(JSON.stringify(t)),"function"==typeof e.onProgress)try{e.onProgress(t.percent)}catch(s){_e.w("onProgress callback error:",s)}}}}_createCosOptionsPreSigUrl(e){let t="",s="",o=0;const i=this._getFile(e);if(P)t=this._genFileName(i.name),s=i.url,o=1;else{const e=i.name,n=e.slice(e.lastIndexOf("."));t=this._genFileName(`${We(999999)}${n}`),s=i,o=0}return this._getCosPreSigUrl({fileType:this.uploadFileType,fileName:t,uploadMethod:o,duration:this.duration}).then(o=>{const{uploadUrl:i,downloadUrl:n,requestSnapshotUrl:r,thumbUrl:a,largeUrl:u}=o;return{url:this._getRawOrUploadProxyUrl(i),fileType:this.uploadFileType,fileName:t,resources:s,downloadUrl:n,requestSnapshotUrl:r,thumbUrl:a,largeUrl:u,onProgress:t=>{if("function"==typeof e.onProgress)try{e.onProgress(t.percent)}catch(s){_e.w("onProgress callback error:",s),_e.e(s)}}}})}_genFileName(e){return`${ct()}-${e}`}_setUploadFileType(e){this.uploadFileType=e}_getSnapshotInfoByUrl(e,t){const s=new Cn("getSnapshotInfo");return this.request({protocolName:Oi,requestData:{platform:this.getPlatform(),coverName:this._genFileName(We(99999)),requestSnapshotUrl:e}}).then(e=>{const{snapshotUrl:o}=e.data||{};return s.setMessage("snapshotUrl:"+o).end(),Lt(o)?{}:ut(o).then(e=>{t.snapshotInfo={snapshotUrl:o,snapshotWidth:e.width,snapshotHeight:e.height}})}).catch(e=>(_e.w(this._n+"._getSnapshotInfoByUrl failed. error:",e),s.setCode(e.errorCode).setMessage(e.errorInfo).end(),{}))}_getSmallImageInfoByUrl(e,t){return ut(e).then(s=>{t.smallImageUrl=e,t.smallImageWidth=s.width,t.smallImageHeight=s.height})}_getLargeImageInfoByUrl(e,t){return ut(e).then(s=>{t.largeImageUrl=e,t.largeImageWidth=s.width,t.largeImageHeight=s.height})}reset(){_e.l(this._n+".reset")}}class oa{constructor(e){this._n="MergerMessageHandler",this._messageModule=e}uploadMergerMessage(e,t){const s=this._n+".uploadMergerMessage";_e.d(s+" message:",e,"messageBytes:"+t);const{messageList:o}=e.payload,i=o.length,n=new Cn("uploadMergerMessage");return this._messageModule.request({protocolName:Fi,requestData:{messageList:o}}).then(e=>{_e.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 _e.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";_e.d(t+" message:",e);const{downloadKey:s}=e.payload,o=this._messageModule.getFileDownloadProxy(),i=new Cn("downloadMergerMessage");return i.setMessage("downloadKey:"+s),this._messageModule.request({protocolName:$i,requestData:{downloadKey:s}}).then(s=>{if(_e.d(t+" ok. response:",s.data),$e(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(!Lt(e)){const s=new Un(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 _e.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(Pe(t)&&Pe(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="";Ue(e.cloudCustomData)&&e.cloudCustomData.length>0&&(n=e.cloudCustomData);const{pbDownloadKey:r,downloadKey:a,messageNumber:u}=s,{title:c,abstractList:l,compatibleText:d}=e.payload,p=this._messageModule.getModule(ls),h=p&&p.isOnlineMessage(e,t)?0:void 0;return{protocolName:Ks,tjgID:this._messageModule.generateTjgID(e),requestData:{fromAccount:this._messageModule.getMyUserID(),toAccount:e.to,msgBody:[{msgType:e.type,msgContent:{pbDownloadKey:r,downloadKey:a,title:c,abstractList:l,compatibleText:d,messageNumber:u}}],cloudCustomData:n,clientTime:e.clientTime,msgSeq:e.sequence,msgRandom:e.random,msgLifeTime:h,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!==h?i:void 0,isSupportExtension:!0===e.isSupportExtension?1:0}}}_createGroupMergerMessagePack(e,t,s){let o=null;t&&t.offlinePushInfo&&(o=t.offlinePushInfo);const i=[];if(Pe(t)&&Pe(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="";Ue(e.cloudCustomData)&&e.cloudCustomData.length>0&&(n=e.cloudCustomData);const{pbDownloadKey:r,downloadKey:a,messageNumber:u}=s,{title:c,abstractList:l,compatibleText:d}=e.payload,p=this._messageModule.getModule(ds),h=p&&p.isOnlineMessage(e,t)?1:0;return{protocolName:Ws,tjgID:this._messageModule.generateTjgID(e),requestData:{fromAccount:this._messageModule.getMyUserID(),groupID:e.to,msgBody:[{msgType:e.type,msgContent:{pbDownloadKey:r,downloadKey:a,title:c,abstractList:l,compatibleText:d,messageNumber:u}}],random:e.random,priority:e.priority,clientSequence:e.clientSequence,groupAtInfo:void 0,cloudCustomData:n,onlineOnlyFlag:h,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||p.isMessageFromOrToAVChatroom(e.to)?0:1,messageControlInfo:0===h?i:void 0,isSupportExtension:!0===e.isSupportExtension?1:0}}}}const ia={ERR_SVR_COMM_SENSITIVE_TEXT:80001,ERR_SVR_COMM_BODY_SIZE_LIMIT:80002,OPEN_SERVICE_OVERLOAD_ERROR:60022,ERR_SVR_MSG_PKG_PARSE_FAILED:20001,ERR_SVR_MSG_INTERNAL_AUTH_FAILED:20002,ERR_SVR_MSG_INVALID_ID:20003,ERR_SVR_MSG_PUSH_DENY:20006,ERR_SVR_MSG_IN_PEER_BLACKLIST:20007,ERR_SVR_MSG_BOTH_NOT_FRIEND:20009,ERR_SVR_MSG_NOT_PEER_FRIEND:20010,ERR_SVR_MSG_NOT_SELF_FRIEND:20011,ERR_SVR_MSG_SHUTUP_DENY:20012,ERR_SVR_GROUP_INVALID_PARAMETERS:10004,ERR_SVR_GROUP_PERMISSION_DENY:10007,ERR_SVR_GROUP_NOT_FOUND:10010,ERR_SVR_GROUP_INVALID_GROUPID:10015,ERR_SVR_GROUP_REJECT_FROM_THIRDPARTY:10016,ERR_SVR_GROUP_SHUTUP_DENY:10017,MESSAGE_SEND_FAIL:2100,OVER_FREQUENCY_LIMIT:2996},na=[nn.MESSAGE_ONPROGRESS_FUNCTION_ERROR,nn.MESSAGE_IMAGE_SELECT_FILE_FIRST,nn.MESSAGE_IMAGE_TYPES_LIMIT,nn.MESSAGE_FILE_IS_EMPTY,nn.MESSAGE_IMAGE_SIZE_LIMIT,nn.MESSAGE_FILE_SELECT_FILE_FIRST,nn.MESSAGE_FILE_SIZE_LIMIT,nn.MESSAGE_VIDEO_SIZE_LIMIT,nn.MESSAGE_VIDEO_TYPES_LIMIT,nn.MESSAGE_AUDIO_UPLOAD_FAIL,nn.MESSAGE_AUDIO_SIZE_LIMIT,nn.COS_UNDETECTED];function ra(e){let t=!1;return Object.values(ia).includes(e)&&(t=!0),(e>=120001&&e<=13e4||e>=10100&&e<=10200)&&(t=!0),t}class aa extends Fs{constructor(e){super(e),this._n="MessageModule",this._messageOptionsMap=new Map,this._mergerMessageHandler=new oa(this)}createTextMessage(e){const t=this.getMyUserID();e.currentUser=t,e.senderTinyID=this.getMyTinyID();const s=new bn(e),o="string"==typeof e.payload?e.payload:e.payload.text,i=new Tn({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 bn(e);if(P){const{file:t}=e.payload;if(Oe(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(b)if(Oe(e.payload.file)){const t=e.payload.file;e.payload.file={files:[t]}}else if(Pe(e.payload.file)&&"undefined"!=typeof uni){const t=e.payload.file.tempFiles[0];e.payload.file={files:[t]}}const o=new yn({imageFormat:me.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(P){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 bn(e),i=new En({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(P){if(O)return void this.outputWarning("VideoUnsupportedInAlipay");if(Oe(e.payload.file))return void this.outputWarning("FileUnsupportedInMP","createVideoMessage");let{file:t}=e.payload;be(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(b){if(Oe(e.payload.file)){const t=e.payload.file;e.payload.file.files=[t]}else if(Pe(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 bn(e),i=new On({videoFormat:s.type,videoSecond:_t(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 bn(e),o=new Rn({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 bn(e),o=new Dn(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 bn(e),i=new kn(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,u=this.getMyUserID(),c=this._getNickAndAvatarByUserID(u);if(n.type===t.MSG_GRP_TIP)return Vn({code:nn.MESSAGE_FORWARD_TYPE_INVALID});const l={to:s,conversationType:o,conversationID:`${o}${s}`,priority:i,isPlaceMessage:0,status:Nt.UNSEND,currentUser:u,senderTinyID:this.getMyTinyID(),cloudCustomData:e.cloudCustomData||n.cloudCustomData||"",needReadReceipt:r,receiverList:a,isSupportExtension:e.isSupportExtension||!1},d=new bn(l);return d.setElement(n.getElements()[0]),d.setNickAndAvatar(c),d.setNameCard(this._getNameCardByGroupID(n)),d.setRelayFlag(!0),d}downloadMergerMessage(e){return this._mergerMessageHandler.downloadMergerMessage(e)}createFileMessage(e){if(P){if(!L&&!v&&!U)return;let e;const t=w.getSystemInfoSync().SDKVersion;if(L&&(e="2.5.0",dt(t,e)<0))return void this.outputWarning("WXChooseMessageFile");if(v&&(e="1.18.0",dt(t,e)<0))return void this.outputWarning("QQChooseMessageFile")}if(b||U){if(Oe(e.payload.file)){const t=e.payload.file;e.payload.file={files:[t]}}else if(Pe(e.payload.file)&&"undefined"!=typeof uni){const{tempFiles:t,files:s}=e.payload.file;let o=null;be(t)?o=t[0]:be(s)&&(o=s[0]),e.payload.file={files:[o]}}}else if(L||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 bn(e),o=new Nn({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 bn(e),o=new Gn(e.payload),i=this._getNickAndAvatarByUserID(t);return s.setElement(o),s.setNickAndAvatar(i),s.setNameCard(this._getNameCardByGroupID(s)),s}_onCannotFindModule(){return Vn({code:nn.CANNOT_FIND_MODULE})}sendMessageInstance(e,s){if(!1===this.getModule(Us).filterMessage(e,s))return this._onSendMessageFailed(e,new Fn({code:nn.PROFANITY_FOUND}));let o,i=null;switch(e.conversationType){case t.CONV_C2C:if(i=this.getModule(ls),!i)return this._onCannotFindModule();break;case t.CONV_GROUP:if(i=this.getModule(ds),!i)return this._onCannotFindModule();if(st({groupID:e.to})){const t=i.getLocalGroupProfile(e.to);if(t&&t.isSupportTopic)return Vn({code:nn.MESSAGE_SEND_GROUP_WITH_TOPIC_FAIL})}break;default:return Vn({code:nn.MESSAGE_SEND_INVALID_CONVERSATION_TYPE})}const n=this.getModule(Ts),r=this.getModule(ds);return n.upload(e).then(()=>{if(this._getSendMessageSpecifiedKey(e)===dn){this.getModule(Rs).addSuccessCount(pn)}return r.guardForAVChatRoom(e).then(()=>{if(!e.isSendable())return Vn({code:nn.MESSAGE_FILE_URL_IS_EMPTY});this._addSendMessageTotalCount(e),o=Date.now();const n=function(e){let t="utf-8";b&&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));if(e.type===t.MSG_MERGER&&n>11264)return this._mergerMessageHandler.uploadMergerMessage(e,n).then(t=>{const o=this._mergerMessageHandler.createMergerMessagePack(e,s,t);return this.request(o)});return this.getModule(_s).setMessageRandom(e),e.conversationType===t.CONV_C2C||e.conversationType===t.CONV_GROUP?i.sendMessage(e,s):void 0}).then(n=>{const{time:r,sequence:a,readReceiptCode:u}=n.data;if(Ge(u)&&0!==u){new Cn("sendMessageWithReceipt").setMessage(`from:${e.from} to:${e.to} sequence:${a} readReceiptCode:${u}`).end(),_e.w(`${this._n}.sendMessageInstance readReceiptCode:${u} message:${this.getErrorMessage(u)}`)}this._addSendMessageSuccessCount(e,o),this._messageOptionsMap.delete(e.clientSequence);const c=this.getModule(_s);e.status=Nt.SUCCESS,e.time=r;let l=!1;if(e.conversationType===t.CONV_GROUP)e.sequence=a;else if(e.conversationType===t.CONV_C2C){const t=c.getLatestMessageSentByMe(e.conversationID);if(t){const{nick:s,avatar:o}=t;s===e.nick&&o===e.avatar||(l=!0)}}if(l&&c.modifyMessageSentByMe({conversationID:e.conversationID,latestNick:e.nick,latestAvatar:e.avatar}),i.isOnlineMessage(e,s))e._onlineOnlyFlag=!0;else{c.appendToMessageList(e);let o=e;Pe(s)&&Pe(s.messageControlInfo)&&(!0===s.messageControlInfo.excludedFromLastMessage&&(e._isExcludedFromLastMessage=!0,o=""),!0===s.messageControlInfo.excludedFromUnreadCount&&(e._isExcludedFromUnreadCount=!0));let i=e.conversationType;if(ot(e.to)){i=t.CONV_TOPIC;this.getModule(gs).onMessageSent({groupID:ft(e.to),topicID:e.to,lastMessage:o})}c.onMessageSent({conversationOptionsList:[{conversationID:e.conversationID,unreadCount:0,type:i,subType:e.conversationSubType,lastMessage:o}]})}return e.getRelayFlag()||"TIMImageElem"!==e.type||ht(e.payload.imageInfoArray),wn({message:e})})}).catch(t=>this._onSendMessageFailed(e,t))}_onSendMessageFailed(e,t){e.status=Nt.FAIL;this.getModule(_s).deleteMessageRandom(e),this._addSendMessageFailCountOnUser(e,t);const s=new Cn("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()}),_e.e(this._n+"._onSendMessageFailed error:",t),Vn(new Fn({code:t&&t.code?t.code:nn.MESSAGE_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 dn;if(e.conversationType===t.CONV_C2C)return un;if(e.conversationType===t.CONV_GROUP){const t=this.getModule(ds).getLocalGroupProfile(e.to);if(!t)return;const s=t.type;return et(s)?ln:cn}}_addSendMessageTotalCount(e){const t=this._getSendMessageSpecifiedKey(e);if(t){this.getModule(Rs).addTotalCount(t)}}_addSendMessageSuccessCount(e,t){const s=Math.abs(Date.now()-t),o=this._getSendMessageSpecifiedKey(e);if(o){const e=this.getModule(Rs);e.addSuccessCount(o),e.addCost(o,s)}}_addSendMessageFailCountOnUser(e,t){const{code:s=-1}=t,o=this.getModule(Rs),i=this._getSendMessageSpecifiedKey(e);i===dn&&function(e){let t=!1;return na.includes(e)&&(t=!0),t}(s)?o.addFailedCountOfUserSide(pn):ra(s)&&i&&o.addFailedCountOfUserSide(i)}resendMessage(e){return e.isResend=!0,e.status=Nt.UNSEND,this.sendMessageInstance(e)}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 Cn("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(!Lt(s)&&0!==s[0].retCode){const t=new Fn({code:s[0].retCode,data:{message:e}});return o.setCode(t.code).setMoreMessage(t.message).end(),Vn(t)}_e.i(`${i} ok. ID:${e.ID}`),e.isRevoked=!0,o.end();return this.getModule(_s).onMessageRevoked([e]),wn({message:e})}).catch(t=>{this.probeNetwork().then(([e,s])=>{o.setError(t,e,s).end()});const s=new Fn({code:t&&t.code?t.code:nn.MESSAGE_REVOKE_FAIL,message:t&&t.message?t.message:void 0,data:{message:e}});return _e.w(i+" failed. error:",t),Vn(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 Vn({code:nn.CANNOT_DELETE_GROUP_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 u=new Cn("deleteMessage");u.setMessage(`to:${n} count:${r.length}`);const c=this._n+".deleteMessage";return s.deleteMessage({to:n,keyList:r}).then(e=>(u.end(),_e.i(c+" ok"),this._onMessageDeleted(a))).catch(e=>{this.probeNetwork().then(([t,s])=>{u.setError(e,t,s).end()}),_e.w(c+" failed. error:",e);const t=new Fn({code:e&&e.code?e.code:nn.MESSAGE_DELETE_FAIL,message:e&&e.message?e.message:void 0});return Vn(t)})}_onMessageDeleted(e){return this.getModule(_s).onMessageDeleted(e),xn({messageList:e})}translateText(e){const t=this._n+".translateText",{sourceTextList:s,sourceLanguage:o,targetLanguage:i}=e,n=new Cn("translateText");return n.setMessage(`sourceLanguage:${o} targetLanguage:${i}`),this.request({protocolName:on,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(),_e.i(`${t} ok. requestID:${o}`),wn({translatedTextList:i});throw{...s,requestID:o}}).catch(e=>(n.setCode(e.code).setMoreMessage(e.requestID).end(),_e.w(t+" failed. error:",e),Vn({code:nn.TRANSLATE_TEXT_FAIL})))}modifyRemoteMessage(e){let s=null;const{conversationType:o,to:i}=e;if(this.getModule(ds).isMessageFromOrToAVChatroom(i))return Vn({code:nn.MESSAGE_MODIFY_DISABLED_IN_AVCHATROOM,data:{message:e}});if(!1===this.getModule(Us).filterMessage(e))return Vn({code:nn.PROFANITY_FOUND,data:{message:e}});o===t.CONV_C2C?s=this.getModule(ls):o===t.CONV_GROUP&&(s=this.getModule(ds));const n=new Cn("modifyMessage");n.setMessage("to:"+i);const r=this._n+".modifyRemoteMessage";return s.modifyRemoteMessage(e).then(t=>{n.end(),_e.i(r+" ok");const s=this._onModifyRemoteMessageResp(e,t.data);return wn({message:s})}).catch(t=>{if(n.setCode(t.code).setMoreMessage(t.message).end(),_e.w(r+" failed. error:",t),20027===t.code){const s=this._onModifyRemoteMessageResp(e,t.data);return Vn({code:nn.MESSAGE_MODIFY_CONFLICT,data:{message:s}})}return Vn({code:t.code,message:t.message,data:{message:e}})})}_onModifyRemoteMessageResp(e,t){_e.d(this._n+"._onModifyRemoteMessageResp options:",t);const{conversationType:s,from:o,to:i,random:n,sequence:r,time:a}=e,{elements:u,messageVersion:c,cloudCustomData:l=""}=t;return this.getModule(_s).onMessageModified({conversationType:s,from:o,to:i,time:a,random:n,sequence:r,elements:u,cloudCustomData:l,messageVersion:c})}_generateUUID(e){const t=this.getModule(ms);let s=`${t.getSDKAppID()}-${t.getUserID()}-${function(){let e="";for(let t=32;t>0;--t)e+=Ye[Math.floor(Math.random()*je)];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(cs).getNickAndAvatarByUserID(e)}_getNameCardByGroupID(e){if(e.conversationType===t.CONV_GROUP){const t=this.getModule(ds);if(t)return t.getMyNameCardByGroupID(e.to)}return""}reset(){_e.l(this._n+".reset"),this._messageOptionsMap.clear()}}class ua extends Fs{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:u}=s,c=`${n}-${a}-${u}`,l=[],d=[];_e.l(`${this._n}.onMessageExtensionNotify messageID:${c} operateType:${o} globalSequence:${r}`),this._updateGlobalSequence(c,r);let p=!1,h=!1;i.forEach(e=>{const{extensions:t=[],clearSequence:s}=e;if(1===o)p=!0,t.forEach(e=>{l.push({key:e.key,value:e.value})}),this._updateLocalExtension(c,t);else if(2===o)h=!0,t.forEach(e=>{d.push(e.key)}),this._updateLocalExtension(c,t);else if(3===o){if(h=!0,this._hasLocalExtension(c)){this._getLocalExtension(c).forEach((e,t)=>{e.seq<=s&&!Lt(e.value)&&d.push(t)})}this._clearLocalExtension(c,s)}}),p&&this.emitOuterEvent(e.MESSAGE_EXTENSIONS_UPDATED,{messageID:c,extensions:l}),h&&this.emitOuterEvent(e.MESSAGE_EXTENSIONS_DELETED,{messageID:c,keyList:d})}setMessageExtensions(e,t){if(!this.canIUse(M.MSG_EXT))return Vn({code:nn.CANNOT_USE_COMMERCIAL_ABILITY});const s=this._n+".setMessageExtensions",{ID:o,conversationID:i,sequence:n,time:r}=e;let a=[...t];t.length>20&&(a=t.slice(0,20),_e.w(s+". the length of extensions cannot exceed 20."));const u=`conversationID:${i} messageID:${o} sequence:${n} time:${r} count:${a.length}`,c=new Cn("setMessageExtensions");return c.setMessage(u),_e.l(`${s} ${u}`),this._modifyMessageExtensions(e,a).then(e=>{const{resultList:t,successCount:o,failureCount:i}=e,n=`success count:${o} fail count:${i}`;return c.setMoreMessage(n).end(),_e.l(`${s} ok. ${n}`),wn({extensions:t})}).catch(e=>(this.probeNetwork().then(([t,s])=>{c.setError(e,t,s).end()}),_e.e(s+" failed. error:",e),Vn(e)))}getMessageExtensions(e){if(!this.canIUse(M.MSG_EXT))return Vn({code:nn.CANNOT_USE_COMMERCIAL_ABILITY});const t=this._n+".getMessageExtensions",{ID:s,conversationID:o,sequence:i,time:n}=e,r=`conversationID:${o} messageID:${s} sequence:${i} time:${n}`,a=new Cn("getMessageExtensions");a.setMessage(r),_e.l(`${t} ${r}`);let u=void 0;return this.getMessageExtensionsMap.has(s)&&(u=this._getGlobalSequence(s)),this._getMessageExtensions(e,u).then(e=>(a.end(),_e.l(`${t} ok. total count:${e.length}`),we(u)&&e.length>0&&this.getMessageExtensionsMap.set(s,1),wn({extensions:e}))).catch(e=>(this.probeNetwork().then(([t,s])=>{a.setError(e,t,s).end()}),_e.e(t+" failed. error:",e),Vn(e)))}deleteMessageExtensions(e,t){if(!this.canIUse(M.MSG_EXT))return Vn({code:nn.CANNOT_USE_COMMERCIAL_ABILITY});const s=this._n+".deleteMessageExtensions",o=[];let i=3;Lt(t)||(i=2,t.forEach(e=>{o.push({key:e,value:"",seq:0})}));const{ID:n,conversationID:r,sequence:a,time:u}=e,c=`conversationID:${r} messageID:${n} sequence:${a} time:${u} operateType:${i}`,l=new Cn("deleteMessageExtensions");return l.setMessage(c),_e.l(`${s} ${c}`),this._modifyMessageExtensions(e,o,i).then(e=>{const{resultList:t,successCount:o,failureCount:n}=e;let r="";return 2===i&&(r=`success count:${o} fail count:${n}`),l.setMoreMessage(""+r).end(),_e.l(`${s} ok. ${r}`),wn({extensions:t})}).catch(e=>(this.probeNetwork().then(([t,s])=>{l.setError(e,t,s).end()}),_e.e(s+" failed. error:",e),Vn(e)))}_modifyMessageExtensions(e,s,o=1){const i=ot(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(gs);break;default:return Vn({code:nn.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=Lt(s)?[]:s,s.forEach(e=>{const{errorCode:t,extension:s}=e,{key:o,value:u,seq:c}=s;i.push({code:t,key:o,value:u}),0===t?n++:r++,a.push({key:o,value:u,seq:c})}),this._updateGlobalSequence(e.ID,o),a.length>0&&(this._updateLocalExtension(e.ID,a),a=null),{resultList:i,successCount:n,failureCount:r}}).catch(e=>Vn(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(ot(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(gs);break;default:return Vn({code:nn.CANNOT_FIND_MODULE})}return r.getMessageExtensions(e,s).then(t=>{let{extensions:s,completeFlag:n,globalSequence:r,clearSequence:a}=t.data;if(s=Lt(s)?[]:s,_e.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=>Vn(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;Lt(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(){_e.l(this._n+".reset"),this.messageExtensionMap.clear(),this.globalSeqMap.clear(),this.getMessageExtensionsMap.clear()}}class ca extends Fs{constructor(e){super(e),this._n="ComboMessageModule"}sendMessage(e){const s=this._constructMessageInstance(e);if(null===s)return Vn({code:nn.MESSAGE_SEND_FAIL});this._addSendMessageTotalCount(s);const o=Date.now();return this.getModule(_s).setMessageRandom(s),this._sendComboMessage(s,e).then(e=>{const{time:i,sequence:n,readReceiptCode:r}=e.data;if(Ge(r)&&0!==r){new Cn("sendMessageWithReceipt").setMessage(`from:${s.from} to:${s.to} sequence:${n} readReceiptCode:${r}`).end(),_e.w(`${this._n}.sendMessage readReceiptCode:${r} message:${this.getErrorMessage(r)}`)}this._addSendMessageSuccessCount(s,o);const a=this.getModule(_s);s.status=Nt.SUCCESS,s.time=i,s.conversationType===t.CONV_GROUP&&(s.sequence=n),a.appendToMessageList(s);let u=s;return!0===s._isExcludedFromLastMessage&&(u=""),a.onMessageSent({conversationOptionsList:[{conversationID:s.conversationID,unreadCount:0,type:s.conversationType,subType:s.conversationSubType,lastMessage:u}]}),wn({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}.${m.CMD.SEND_MESSAGE}`),e.conversationType===t.CONV_GROUP&&(i=`${m.NAME.GROUP}.${m.CMD.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,Ue(e.CloudCustomData)&&e.CloudCustomData.length>0&&(n.cloudCustomData=e.CloudCustomData),be(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&&be(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),_e.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 bn(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 u=o.getElements();o.payload=u[0].content,o.type=u[0].type}catch(i){o=null,_e.e(s+" failed. error:",i)}return o}_onSendMessageFailed(e,t){e.status=Nt.FAIL;this.getModule(_s).deleteMessageRandom(e),this._addSendMessageFailCountOnUser(e,t);const s=new Cn("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()}),_e.e(this._n+"._onSendMessageFailed error:",t),Vn(new Fn({code:t&&t.code?t.code:nn.MESSAGE_SEND_FAIL,message:t&&t.message?t.message:void 0,data:{message:e}}))}_getSendMessageSpecifiedKey(e){if(e.conversationType===t.CONV_C2C)return un;if(e.conversationType===t.CONV_GROUP){const t=this.getModule(ds).getLocalGroupProfile(e.to);if(!t)return;const s=t.type;return et(s)?ln:cn}}_addSendMessageTotalCount(e){const t=this._getSendMessageSpecifiedKey(e);if(t){this.getModule(Rs).addTotalCount(t)}}_addSendMessageSuccessCount(e,t){const s=Math.abs(Date.now()-t),o=this._getSendMessageSpecifiedKey(e);if(o){const e=this.getModule(Rs);e.addSuccessCount(o),e.addCost(o,s)}}_addSendMessageFailCountOnUser(e,t){const{code:s=-1}=t,o=this.getModule(Rs),i=this._getSendMessageSpecifiedKey(e);ra(s)&&i&&o.addFailedCountOfUserSide(i)}}class la extends Fs{constructor(e){super(e),this._n="PluginModule",this.plugins={}}registerPlugin(e){Object.keys(e).forEach(t=>{this.plugins[t]=e[t]});new Cn("registerPlugin").setMessage(""+Object.keys(e)).end()}getPlugin(e){return this.plugins[e]}reset(){}}class da extends Fs{constructor(e){super(e),this._n="SyncUnreadMessageModule",this._cookie="",this._onlineSyncFlag=!1,this.getInnerEmitterInstance().on(Kn,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";_e.l(`${i} cookie:${t} syncFlag:${s} isOnlineSync:${o}`),this.request({protocolName:Bs,requestData:{cookie:t,syncFlag:s,isOnlineSync:o}}).then(e=>{const{cookie:t,syncFlag:s}=e.data;this._cookie=t,Lt(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=>{_e.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})}startOnlineSync(){_e.l(this._n+".startOnlineSync"),this._onlineSyncFlag=!0,this._startSync({cookie:this._cookie,syncFlag:0,isOnlineSync:1})}startSyncOnReconnected(){_e.l(this._n+".startSyncOnReconnected."),this._onlineSyncFlag=!0,this._startSync({cookie:this._cookie,syncFlag:0,isOnlineSync:0})}reset(){_e.l(this._n+".reset"),this._onlineSyncFlag=!1,this._cookie=""}}const pa={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"},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"},ignoreKeyWord:["C2C","ID","USP"]};function ha(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=ga(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 ga=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 _a(e,t){let s=0;return function e(t,o){if(s++,s>100)return s--,t;if(be(t)){const i=t.map(t=>ke(t)?e(t,o):t);return s--,i}if(ke(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(!Ve(t))return!1;if((s=t)!==ha(s))for(let o=0;o<pa.ignoreKeyWord.length&&!t.includes(pa.ignoreKeyWord[o]);o++);var s;return we(o[t])?function(e){if("OPPOChannelID"===e)return e;return e[0].toUpperCase()+ha(e).slice(1)}(t):o[t]});return i=at(i,(t,s)=>be(t)||ke(t)?e(t,o):t),s--,i}}(e,t)}function ma(e,t){if(be(e))return e.map(e=>ke(e)?ma(e,t):e);if(ke(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)=>we(t[s])?ha(s):t[s]);return s=at(s,e=>be(e)||ke(e)?ma(e,t):e),s}}const Ma=String.fromCharCode,fa=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 Ma(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?Ma(192|t>>>6,128|63&t):Ma(224|t>>>12,128|t>>>6&63,128|63&t)},Ia=function(e){const t=void 0===e?"":(""+e).replace(/[\x80-\uD7ff\uDC00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]?/g,fa),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};class Ca{constructor(e){this._handler=e;const t=e.getURL();if(this._socket=null,this._workerSocket=null,this._id=We(),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", extensions: _socket.extensions }); }; _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,extensions:i}=e.data;"onOpen"===t?s._onOpen(i):"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 P?O?(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))):b&&(this._socket=new WebSocket(t),this._socket.binaryType="arraybuffer",this._socket.onopen=this._onOpen.bind(this,this._socket.extensions),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(e){this._handler.onOpen({id:this._id,res:JSON.stringify(e)})}_onClose(e){this._handler.onClose({id:this._id,e:e})}_onMessage(e){let t;t=this._canIUseBinaryFrame?this._isAppCompressedData(e.data)?this._handler.inflate(e.data):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}(e.data):e.data,this._handler.onMessage({data:t})}_isAppCompressedData(e){const t=new Uint8Array(e);return 67===t[0]&&79===t[1]&&77===t[2]&&80===t[3]}_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),O)return w.offSocketClose(),w.offSocketMessage(),w.offSocketOpen(),w.offSocketError(),void w.closeSocket();this._socket&&(P?(this._socket.onClose(()=>{}),this._socket.onOpen(()=>{}),this._socket.onMessage(()=>{}),this._socket.onError(()=>{})):b&&(this._socket.onopen=null,this._socket.onmessage=null,this._socket.onclose=null,this._socket.onerror=null),R?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?Ia(e.data).buffer:e.data});else{if(O)return void w.sendSocketMessage({data:e.data,fail:()=>{e.fail&&e.requestID&&e.fail(e.requestID)}});this._socket&&(P?this._socket.send({data:this._canIUseBinaryFrame?Ia(e.data).buffer:e.data,fail:()=>{e.fail&&e.requestID&&e.fail(e.requestID)}}):b&&this._socket.send(this._canIUseBinaryFrame?Ia(e.data):e.data))}}}const Ta=4e3,ya=4001,Da="connected",Ea="connecting",Sa="disconnected";class La{constructor(e){this._channelModule=e,this._n="SocketHandler",this._promiseMap=new Map,this._readyState=Sa,this._simpleRequestMap=new Map,this.MAX_SIZE=100,this._startSequence=We(),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(ms);let t=u;this._channelModule.isOversea()&&(t=c),e.isSingaporeSite()?t=l:e.isKoreaSite()?t=d:e.isGermanySite()?t=p:e.isIndiaSite()?t=h:e.isJapanSite()?t=g:e.isUSASite()&&(t=_),m.HOST.setCurrent(t)}_initConnection(){we(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(ms).getProxyServer();Lt(e)||(this._url=e),this._connect(),this._nextPingTs=0}_canIUseAnyCast(){return b&&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($s)?i=9e4:-1!==t.indexOf(Ui)&&(i=3e3),Date.now()-o>=i&&(_e.l(`${this._n}._checkPromiseMap request timeout, delete requestID:${t}`),this._promiseMap.delete(t),s(new Fn({code:nn.NETWORK_TIMEOUT})),this._channelModule.onRequestTimeout(t))})}onOpen(e){if(""===this._readyState)return;this._onOpenTs=Date.now();const{id:t,res:s}=e;this._socketID=t;const o=Date.now()-this._startTs,i=`socketID:${t} res:${s}`;_e.l(`${this._n}._onOpen cost:${o} ms. ${i}`);new Cn("wsOnOpen").setMessage(o).setCostTime(o).setMoreMessage(i).end(),e.id===this._socketID&&(this._readyState=Da,this._reConnectCount=0,this._resend(),!0===this._reConnectFlag&&(this._channelModule.onReconnected(),this._reConnectFlag=!1),this._channelModule.onOpen())}onClose(e){const t=new Cn("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(),_e.l(`${this._n}._onClose ${i} onlineTime:${n}`),s===this._socketID&&(this._readyState=Sa,n<1e3?this._channelModule.onReconnectFailed():this._channelModule.onClose())}onError(e){const{id:t,e:s}=e,o=`sourceSocketID:${t} currentSocketID:${this._socketID}`;new Cn("wsOnError").setMessage(s.errMsg||He(s)).setMoreMessage(o).setLevel("error").end(),_e.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 Cn("jsonParseError").setMessage(e.data).end()}if(!t||!t.head)return;const s=this._getRequestIDFromHead(t.head);let o=t.body;if(!this._isTRTCCommand(s)){const e=gt(t.head);o=ma(t.body,this._getResponseKeyMap(e))}if(_e.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 Fn({code:o.errorCode,message:o.errorInfo||"",data:s.includes(Co)||s.includes(li)?{elements:o.elements,messageVersion:o.messageVersion,cloudCustomData:o.cloudCustomData}:void 0}))):e(wn(o)))}this._channelModule.onMessage({head:t.head,body:o})}_isTRTCCommand(e){const t=this._channelModule.getModule(ks).getCommandList();let s=!1;for(let o=0;o<t.length;o++)if(e.startsWith(t[o])){s=!0;break}return s}_calcRTT(e){const t=Date.now()-e;this._channelModule.getModule(Rs).addRTT(t)}_connect(){this._startTs=Date.now(),this._onOpenTs=0,this._socket=new Ca(this),this._socketID=this._socket.getID(),this._readyState=Ea,_e.l(`${this._n}._connect isWorkerEnabled:${this.getIsWorkerEnabled()} socketID:${this._socketID} url:${this.getURL()}`);new Cn("wsConnect").setMessage(`socketID:${this._socketID} url:${this.getURL()}`).end()}getURL(){this._channelModule.isDevMode()&&(this._canIUseBinaryFrame=!1);const e=lt();(O||L&&"windows"===e||U)&&(this._canIUseBinaryFrame=!1);let t=-1;"ios"===e?t=W||-1:"android"===e&&(t=j||-1);const s=this._channelModule.getModule(ms),o=this._channelModule.getPlatform();let i=`sdkappid=${s.getSDKAppID()}&instanceid=${s.getInstanceID()}&random=${this._getRandom()}&platform=${o}&host=${e}&version=${t}&sdkversion=2.27.6`;return A&&(i+="&isminigame=1"),this._channelModule.canIUseInflate()&&(i+="&compress=gzip"),this._canIUseBinaryFrame?`${this._url}/binfo?${i}`:`${this._url}/info?${i}`}_closeConnection(e){_e.l(`${this._n}._closeConnection socketID:${this._socketID}`),this._socket&&(this._socket.close(e),this._socketID=-1,this._socket=null,this._readyState=Sa)}_resend(){if(_e.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}),_e.d(`${this._n}.send uplinkData:${JSON.stringify(s)} requestID:${o} readyState:${this._readyState}`),this._readyState!==Da)this._reConnect();else{this._execute(o,i);this._channelModule.getModule(Rs).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!==Da?(this._simpleRequestMap.size<this.MAX_SIZE?this._simpleRequestMap.set(o,i):_e.l(this._n+".simplySend. simpleRequestMap is full, drop request!"),this._reConnect()):this._execute(o,i)}_execute(e,t){this._socket.send({data:t,fail:P?this._onSendFail.bind(this):void 0,requestID:e})}_onSendFail(e){_e.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=We()),e}_getRequestIDFromHead(e){const{servcmd:t,seq:s}=e;return t+s}_getResponseKeyMap(e){const t=this._channelModule.getKeyMap(e);return{...pa.response,...t.response}}_reConnect(){this._readyState!==Da&&this._readyState!==Ea&&this.forcedReconnect()}forcedReconnect(){const e=this._n+".forcedReconnect";_e.l(`${e} count:${this._reConnectCount} readyState:${this._readyState}`),this._reConnectFlag=!0,this._resetRandom(),this._reConnectCount<this.MAX_RECONNECT_COUNT?(this._reConnectCount+=1,this._closeConnection(ya),this._initConnection()):(this._reConnectCount=0,this._channelModule.probeNetwork().then(([t,s])=>{t?(_e.w(e+" disconnected from wsserver but network is ok, continue..."),this._closeConnection(ya),this._initConnection()):this._channelModule.onReconnectFailed()}))}getReconnectFlag(){return this._reConnectFlag}_setNextPingTs(){this._nextPingTs=Date.now()+1e4}getNextPingTs(){return this._nextPingTs}isConnected(){return this._readyState===Da}canIUseBinaryFrame(){return this._canIUseBinaryFrame}inflate(e){if(this._channelModule.canIUseInflate())return this._channelModule.getModule(ws).inflate(e)}setIsWorkerEnabled(e){_e.l(`${this._n}.setIsWorkerEnabled flag:${e}`),this._isWorkerEnabled=e}getIsWorkerEnabled(){return this._isWorkerEnabled&&Q}_getRandom(){return 0===this._random&&(this._random=Math.random()),this._random}_resetRandom(){this._random=0}close(){_e.l(this._n+".close"),this._closeConnection(Ta),this._promiseMap.clear(),this._startSequence=We(),this._readyState=Sa,this._simpleRequestMap.clear(),this._reConnectFlag=!1,this._reConnectCount=0,this._onOpenTs=0,this._url="",this._random=0,this._canIUseBinaryFrame=!0,this._isWorkerEnabled=!0}}class Aa extends Fs{constructor(e){if(super(e),this._n="ChannelModule",this._socketHandler=new La(this),this._probing=!1,this._isAppShowing=!0,this._previousState=t.NET_STATE_CONNECTED,P&&"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}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){return this._socketHandler?this._previousState!==t.NET_STATE_CONNECTED&&e.head.servcmd.includes(Gi)?(this.reConnect(),this._sendLogViaHTTP(e)):this._socketHandler.send(e):Promise.reject()}_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(P)w.request({url:i,data:n,method:"POST",timeout:3e3,header:{"content-type":r},success:()=>{s()},fail:()=>{o(new Fn({code:nn.NETWORK_ERROR}))}});else{const e=new XMLHttpRequest,t=setTimeout(()=>{e.abort(),o(new Fn({code:nn.NETWORK_TIMEOUT}))},3e3);e.onreadystatechange=function(){4===e.readyState&&(clearTimeout(t),200===e.status||304===e.status?s():o(new Fn({code:nn.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(){P&&!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(){_e.l(this._n+".onReconnected"),this._m.restartTimer();this.getModule(Es).onReconnected(),this._emitNetStateChangeEvent(t.NET_STATE_CONNECTED)}onReconnectFailed(){_e.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(_e.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(t){this._previousState!==t&&(_e.l(`${this._n}._emitNetStateChangeEvent from ${this._previousState} to ${t}`),this._previousState=t,this.emitOuterEvent(e.NET_STATE_CHANGE,{state:t}))}_ping(){if(!0===this._probing)return;this._probing=!0;const e=this.getModule(Es).getProtocolData({protocolName:Ui});this.send(e).then(()=>{this._probing=!1}).catch(e=>{if(_e.w(this._n+"._ping failed. error:",e),this._probing=!1,e&&60002===e.code){return new Cn("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])=>{_e.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()}canIUseInflate(){return this._m.canIUseInflate()}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(){_e.l(this._n+".reset"),this._previousState=t.NET_STATE_CONNECTED,this._probing=!1,this._fatalErrorFlag=!1,this._timerForNotLoggedIn=setInterval(this.onCheckTimer.bind(this),1e3)}}class va{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(),o=this._sessionModule.isIntl();this._configMap.set($s,function(e){return{head:{...e,servcmd:`${m.NAME.IM_OPEN_STATUS}.${m.CMD.LOGIN}`},body:{state:"Online",isWebUniapp:0,deviceBrand:0},keyMap:{request:{deviceBrand:"InstType"},response:{InstId:"instanceID",HelloInterval:"helloInterval"}}}}(e)),this._configMap.set(qs,function(e){return{head:{...e,servcmd:`${m.NAME.IM_OPEN_STATUS}.${m.CMD.LOGOUT}`},body:{type:0},keyMap:{request:{type:"wslogout_type"}}}}(e)),this._configMap.set(xs,function(e){return{head:{...e,servcmd:`${m.NAME.IM_OPEN_STATUS}.${m.CMD.HELLO}`},body:{isWebUniapp:0},keyMap:{response:{NewInstInfo:"newInstanceInfo"}}}}(e)),this._configMap.set(Vs,function(e){return{head:{...e,servcmd:`${m.NAME.STAT_SERVICE}.${m.CMD.KICK_OTHER}`},body:{}}}(e)),this._configMap.set(Ni,function(e){return{head:{...e,servcmd:`${m.NAME.IM_COS_SIGN}.${m.CMD.COS_SIGN}`},body:{cmd:"open_im_cos_svc",subCmd:"get_cos_token",duration:300,version:2},keyMap:{request:{userSig:"usersig",subCmd:"sub_cmd",cmd:"cmd",duration:"duration",version:"version"},response:{expired_time:"expiredTime",bucket_name:"bucketName",session_token:"sessionToken",tmp_secret_id:"secretId",tmp_secret_key:"secretKey"}}}}(t)),this._configMap.set(Ri,function(e){return{head:{...e,servcmd:`${m.NAME.CUSTOM_UPLOAD}.${m.CMD.COS_PRE_SIG}`},body:{fileType:void 0,fileName:void 0,uploadMethod:0,duration:900},keyMap:{request:{userSig:"usersig",fileType:"file_type",fileName:"file_name",uploadMethod:"upload_method"},response:{expired_time:"expiredTime",request_id:"requestId",head_url:"headUrl",upload_url:"uploadUrl",download_url:"downloadUrl",ci_url:"ciUrl",snapshot_url:"requestSnapshotUrl"}}}}(t)),this._configMap.set(Oi,function(e){return{head:{...e,servcmd:`${m.NAME.CUSTOM_UPLOAD}.${m.CMD.VIDEO_COVER}`},body:{version:1,platform:void 0,coverName:void 0,requestSnapshotUrl:void 0},keyMap:{request:{version:"version",platform:"platform",coverName:"cover_name",requestSnapshotUrl:"snapshot_url"},response:{error_code:"errorCode",error_msg:"errorInfo",download_url:"snapshotUrl"}}}}(t)),this._configMap.set(Vi,function(e){return{head:{...e,servcmd:`${m.NAME.IM_CONFIG_MANAGER}.${m.CMD.FETCH_COMMERCIAL_CONFIG}`},body:{SDKAppID:0},keyMap:{request:{SDKAppID:"uint32_sdkappid"},response:{int32_error_code:"errorCode",str_error_message:"errorMessage",str_purchase_bits:"purchaseBits",uint32_expired_time:"expiredTime"}}}}(e)),this._configMap.set(Bi,function(e){return{head:{...e,servcmd:`${m.NAME.IM_CONFIG_MANAGER}.${m.CMD.PUSHED_COMMERCIAL_CONFIG}`},body:{},keyMap:{response:{int32_error_code:"errorCode",str_error_message:"errorMessage",str_purchase_bits:"purchaseBits",uint32_expired_time:"expiredTime"}}}}(e)),this._configMap.set(qi,function(e){return{head:{...e,servcmd:`${m.NAME.IM_CONFIG_MANAGER}.${m.CMD.FETCH_CLOUD_CONTROL_CONFIG}`},body:{SDKAppID:0,version:0},keyMap:{request:{SDKAppID:"uint32_sdkappid",version:"uint64_version"},response:{int32_error_code:"errorCode",str_error_message:"errorMessage",str_json_config:"cloudControlConfig",uint32_expired_time:"expiredTime",uint32_sdkappid:"SDKAppID",uint64_version:"version"}}}}(e)),this._configMap.set(xi,function(e){return{head:{...e,servcmd:`${m.NAME.IM_CONFIG_MANAGER}.${m.CMD.PUSHED_CLOUD_CONTROL_CONFIG}`},body:{},keyMap:{response:{int32_error_code:"errorCode",str_error_message:"errorMessage",str_json_config:"cloudControlConfig",uint32_expired_time:"expiredTime",uint32_sdkappid:"SDKAppID",uint64_version:"version"}}}}(e)),this._configMap.set(Hi,function(e){return{head:{...e,servcmd:`${m.NAME.OVERLOAD_PUSH}.${m.CMD.OVERLOAD_NOTIFY}`},body:{},keyMap:{response:{OverLoadServCmd:"overloadCommand",DelaySecs:"waitingTime"}}}}(e)),this._configMap.set(Bs,function(e){return{head:{...e,servcmd:`${m.NAME.OPEN_IM}.${m.CMD.GET_MESSAGES}`},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)),o||(this._configMap.set(Hs,function(e){return{head:{...e,servcmd:`${m.NAME.OPEN_IM}.${m.CMD.BIG_DATA_HALLWAY_AUTH_KEY}`},body:{}}}(e)),this._configMap.set(sn,function(e){return{head:{...e,servcmd:`${m.NAME.IM_MSG_AUDIT_MGR}.${m.CMD.GET_RPOFANITY_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,function(e){return{head:{...e,servcmd:`${m.NAME.OPEN_IM}.${m.CMD.SEND_MESSAGE}`},body:{fromAccount:"",toAccount:"",msgSeq:0,msgRandom:0,msgBody:[],cloudCustomData:void 0,nick:"",avatar:"",msgLifeTime:void 0,offlinePushInfo:{pushFlag:0,title:"",desc:"",ext:"",apnsInfo:{badgeMode:0,isVoipPush:void 0},androidInfo:{OPPOChannelID:""}},messageControlInfo:void 0,clientTime:void 0,needReadReceipt:0,isSupportExtension: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(Ws,function(e){return{head:{...e,servcmd:`${m.NAME.GROUP}.${m.CMD.SEND_GROUP_MESSAGE}`},body:{fromAccount:"",groupID:"",random:0,clientSequence:0,priority:"",msgBody:[],cloudCustomData:void 0,onlineOnlyFlag:0,offlinePushInfo:{pushFlag:0,title:"",desc:"",ext:"",apnsInfo:{badgeMode:0,isVoipPush:void 0},androidInfo:{OPPOChannelID:""}},groupAtInfo:[],messageControlInfo:void 0,clientTime:void 0,needReadReceipt:0,topicID:void 0,receiverList:void 0,isSupportExtension: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(ho,function(e){return{head:{...e,servcmd:`${m.NAME.OPEN_IM}.${m.CMD.REVOKE_C2C_MESSAGE}`},body:{msgInfo:{fromAccount:"",toAccount:"",msgTimeStamp:0,msgSeq:0,msgRandom:0}},keyMap:{request:{msgInfo:"MsgInfo",msgTimeStamp:"MsgTimeStamp",msgSeq:"MsgSeq",msgRandom:"MsgRandom"}}}}(e)),this._configMap.set(Jo,function(e){return{head:{...e,servcmd:`${m.NAME.GROUP}.${m.CMD.REVOKE_GROUP_MESSAGE}`},body:{groupID:"",msgSeqList:void 0,topicID:""},keyMap:{request:{msgSeqList:"MsgSeqList",msgSeq:"MsgSeq"}}}}(e)),this._configMap.set(Mo,function(e){return{head:{...e,servcmd:`${m.NAME.OPEN_IM}.${m.CMD.GET_C2C_ROAM_MESSAGES}`},body:{peerAccount:"",count:15,lastMessageTime:0,messageKey:"",withRecalledMessage:1,direction:0},keyMap:{request:{messageKey:"MsgKey",peerAccount:"Peer_Account",count:"MaxCnt",lastMessageTime:"LastMsgTime",withRecalledMessage:"WithRecalledMsg",direction:"GetDirection"},response:{LastMsgTime:"lastMessageTime",IsNeedReadReceipt:"needReadReceipt",IsPeerRead:"readReceiptSentByPeer"}}}}(e)),this._configMap.set(Co,function(e){return{head:{...e,servcmd:`${m.NAME.OPEN_IM}.${m.CMD.MODIFY_C2C_MESSAGE}`},body:{from:"",to:"",sequence:0,random:0,time:0,version:0,elements:void 0,cloudCustomData:void 0},keyMap:{request:{sequence:"MsgSeq",random:"MsgRandom",time:"MsgTime",version:"MsgVersion",type:"MsgType",content:"MsgContent"}}}}(e)),this._configMap.set(Qo,function(e){return{head:{...e,servcmd:`${m.NAME.GROUP}.${m.CMD.GET_GROUP_ROAM_MESSAGES}`},body:{withRecalledMsg:1,groupID:"",count:15,sequence:"",topicID:void 0},keyMap:{request:{sequence:"ReqMsgSeq",count:"ReqMsgNumber",withRecalledMessage:"WithRecalledMsg"},response:{Random:"random",MsgTime:"time",MsgSeq:"sequence",ReqMsgSeq:"sequence",RspMsgList:"messageList",IsPlaceMsg:"isPlaceMessage",IsSystemMsg:"isSystemMessage",ToGroupId:"to",EnumFrom_AccountType:"fromAccountType",EnumTo_AccountType:"toAccountType",GroupCode:"groupCode",MsgPriority:"priority",MsgBody:"elements",MsgType:"type",MsgContent:"content",IsFinished:"complete",Download_Flag:"downloadFlag",ClientSeq:"clientSequence",ThumbUUID:"thumbUUID",VideoUUID:"videoUUID",ToTopicId:"topicID",InvisibleMsgSeq:"invisibleSequenceList"}}}}(e)),this._configMap.set(go,function(e){return{head:{...e,servcmd:`${m.NAME.OPEN_IM}.${m.CMD.SET_C2C_MESSAGE_READ}`},body:{C2CMsgReaded:void 0},keyMap:{request:{lastMessageTime:"LastedMsgTime"}}}}(e)),this._configMap.set(_o,function(e){return{head:{...e,servcmd:`${m.NAME.OPEN_IM}.${m.CMD.SET_C2C_PEER_MUTE_NOTIFICATIONS}`},body:{userIDList:void 0,muteFlag:0},keyMap:{request:{userIDList:"Peer_Account",muteFlag:"Mute_Notifications"}}}}(e)),this._configMap.set(mo,function(e){return{head:{...e,servcmd:`${m.NAME.OPEN_IM}.${m.CMD.GET_C2C_PEER_MUTE_NOTIFICATIONS}`},body:{updateSequence:0},keyMap:{response:{MuteNotificationsList:"muteFlagList"}}}}(e)),this._configMap.set(Xo,function(e){return{head:{...e,servcmd:`${m.NAME.GROUP}.${m.CMD.SET_GROUP_MESSAGE_READ}`},body:{groupID:void 0,messageReadSeq:void 0,topicID:void 0},keyMap:{request:{messageReadSeq:"MsgReadedSeq"}}}}(e)),this._configMap.set(Zo,function(e){return{head:{...e,servcmd:`${m.NAME.OPEN_IM}.${m.CMD.SET_ALL_MESSAGE_READ}`},body:{readAllC2CMessage:0,groupMessageReadInfoList:[]},keyMap:{request:{readAllC2CMessage:"C2CReadAllMsg",groupMessageReadInfoList:"GroupReadInfo",messageSequence:"MsgSeq"},response:{C2CReadAllMsg:"readAllC2CMessage",GroupReadInfoArray:"groupMessageReadInfoList"}}}}(e)),this._configMap.set(Io,function(e){return{head:{...e,servcmd:`${m.NAME.OPEN_IM}.${m.CMD.DELETE_C2C_MESSAGE}`},body:{fromAccount:"",to:"",keyList:void 0},keyMap:{request:{keyList:"MsgKeyList"}}}}(e)),this._configMap.set(ci,function(e){return{head:{...e,servcmd:`${m.NAME.GROUP}.${m.CMD.DELETE_GROUP_MESSAGE}`},body:{groupID:"",deleter:"",keyList:void 0,topicID:void 0},keyMap:{request:{deleter:"Deleter_Account",keyList:"Seqs"}}}}(e)),this._configMap.set(on,function(e){return{head:{...e,servcmd:`${m.NAME.IM_OPEN_TRANSLATE}.${m.CMD.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(li,function(e){return{head:{...e,servcmd:`${m.NAME.OPEN_IM}.${m.CMD.MODIFY_GROUP_MESSAGE}`},body:{groupID:"",topicID:void 0,sequence:0,version:0,elements:void 0,cloudCustomData:void 0},keyMap:{request:{sequence:"MsgSeq",version:"MsgVersion",type:"MsgType",content:"MsgContent"}}}}(e)),this._configMap.set(ei,function(e){return{head:{...e,servcmd:`${m.NAME.GROUP}.${m.CMD.GET_READ_RECEIPT}`},body:{groupID:"",sequenceList:void 0},keyMap:{request:{sequence:"MsgSeq"}}}}(e)),this._configMap.set(si,function(e){return{head:{...e,servcmd:`${m.NAME.OPEN_IM}.${m.CMD.SEND_C2C_READ_RECEIPT}`},body:{peerAccount:"",messageInfoList:void 0},keyMap:{request:{peerAccount:"Peer_Account",messageInfoList:"C2CMsgInfo",fromAccount:"From_Account",toAccount:"To_Account",sequence:"MsgSeq",random:"MsgRandom",time:"MsgTime",clientTime:"MsgClientTime"}}}}(e)),this._configMap.set(ti,function(e){return{head:{...e,servcmd:`${m.NAME.GROUP}.${m.CMD.SEND_READ_RECEIPT}`},body:{groupID:"",sequenceList:void 0},keyMap:{request:{sequenceList:"MsgSeqList",sequence:"MsgSeq"}}}}(e)),this._configMap.set(oi,function(e){return{head:{...e,servcmd:`${m.NAME.GROUP}.${m.CMD.GET_READ_RECEIPT_DETAIL}`},body:{groupID:"",sequence:void 0,flag:0,cursor:0,count:0},keyMap:{request:{sequence:"MsgSeq",count:"Num"},response:{ReadList:"readUserIDList",Read_Account:"userID",UnreadList:"unreadUserIDList",Unread_Account:"userID",IsFinish:"isCompleted"}}}}(e)),this._configMap.set(To,function(e){return{head:{...e,servcmd:`${m.NAME.OPEN_IM_MSG_EXT}.${m.CMD.MODIFY_C2C_MESSAGE_EXTENSIONS}`},body:{from:void 0,to:void 0,messageKey:void 0,operateType:void 0,extensionList:void 0}}}(e)),this._configMap.set(yo,function(e){return{head:{...e,servcmd:`${m.NAME.OPEN_IM_MSG_EXT}.${m.CMD.GET_C2C_MESSAGE_EXTENSIONS}`},body:{from:void 0,to:void 0,messageKey:void 0,startSequence:void 0}}}(e)),this._configMap.set(mi,function(e){return{head:{...e,servcmd:`${m.NAME.OPEN_IM_MSG_EXT}.${m.CMD.MODIFY_GROUP_MESSAGE_EXTENSIONS}`},body:{groupID:void 0,topicID:void 0,messageSequence:void 0,operateType:void 0,extensionList:void 0}}}(e)),this._configMap.set(Mi,function(e){return{head:{...e,servcmd:`${m.NAME.OPEN_IM_MSG_EXT}.${m.CMD.GET_GROUP_MESSAGE_EXTENSIONS}`},body:{groupID:void 0,topicID:void 0,messageSequence:void 0,startSequence:void 0}}}(e)),this._configMap.set(fo,function(e){return{head:{...e,servcmd:`${m.NAME.OPEN_IM}.${m.CMD.GET_PEER_READ_TIME}`},body:{userIDList:void 0},keyMap:{request:{userIDList:"To_Account"},response:{ReadTime:"peerReadTimeList"}}}}(e)),this._configMap.set(Eo,function(e){return{head:{...e,servcmd:`${m.NAME.RECENT_CONTACT}.${m.CMD.GET_CONVERSATION_LIST}`},body:{fromAccount:void 0,count:0},keyMap:{request:{},response:{SessionItem:"conversations",ToAccount:"groupID",To_Account:"userID",UnreadMsgCount:"unreadCount",MsgGroupReadedSeq:"messageReadSeq",C2cPeerReadTime:"c2cPeerReadTime"}}}}(e)),this._configMap.set(Do,function(e){return{head:{...e,servcmd:`${m.NAME.RECENT_CONTACT}.${m.CMD.PAGING_GET_CONVERSATION_LIST}`},body:{fromAccount:void 0,timeStamp:void 0,startIndex:void 0,pinnedTimeStamp:void 0,pinnedStartIndex:void 0,orderType:void 0,messageAssistFlag:4,assistFlag:15},keyMap:{request:{messageAssistFlag:"MsgAssistFlags",assistFlag:"AssistFlags",pinnedTimeStamp:"TopTimeStamp",pinnedStartIndex:"TopStartIndex"},response:{SessionItem:"conversations",ToAccount:"groupID",To_Account:"userID",UnreadMsgCount:"unreadCount",MsgGroupReadedSeq:"messageReadSeq",C2cPeerReadTime:"c2cPeerReadTime",LastMsgFlags:"lastMessageFlag",TopFlags:"isPinned",TopTimeStamp:"pinnedTimeStamp",TopStartIndex:"pinnedStartIndex",GroupId:"convGroupID"}}}}(e)),this._configMap.set(So,function(e){return{head:{...e,servcmd:`${m.NAME.RECENT_CONTACT}.${m.CMD.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(Lo,function(e){return{head:{...e,servcmd:`${m.NAME.RECENT_CONTACT}.${m.CMD.CLEAR_HISTORY_MESSAGE}`},body:{fromAccount:"",toAccount:void 0,type:1,toGroupID:void 0},keyMap:{request:{toGroupID:"ToGroupid"}}}}(e)),this._configMap.set(Ao,function(e){return{head:{...e,servcmd:`${m.NAME.RECENT_CONTACT}.${m.CMD.PIN_CONVERSATION}`},body:{fromAccount:"",operationType:1,itemList:void 0},keyMap:{request:{itemList:"RecentContactItem"}}}}(e)),this._configMap.set(vo,function(e){return{head:{...e,servcmd:`${m.NAME.OPEN_IM}.${m.CMD.DELETE_GROUP_AT_TIPS}`},body:{messageListToDelete:void 0},keyMap:{request:{messageListToDelete:"DelMsgList",messageSeq:"MsgSeq",messageRandom:"MsgRandom"}}}}(e)),this._configMap.set(No,function(e){return{head:{...e,servcmd:`${m.NAME.RECENT_CONTACT}.${m.CMD.MARK_CONVERSATION}`},body:{fromAccount:"",itemList:void 0},keyMap:{request:{itemList:"MarkItem",operationType:"OptType",groupID:"ToGroupId"},response:{ToGroupId:"groupID",OptType:"operationType"}}}}(e)),this._configMap.set(Ro,function(e){return{head:{...e,servcmd:`${m.NAME.RECENT_CONTACT}.${m.CMD.MARK_CONVERSATION}`},body:{fromAccount:"",itemList:void 0},keyMap:{request:{itemList:"MarkItem",operationType:"OptType",groupID:"ToGroupId"},response:{ToGroupId:"groupID",OptType:"operationType"}}}}(e)),this._configMap.set(Oo,function(e){return{head:{...e,servcmd:`${m.NAME.RECENT_CONTACT}.${m.CMD.CREATE_CONVERSATION_GROUP}`},body:{fromAccount:"",itemList:void 0},keyMap:{request:{itemList:"GroupContactItem",groupID:"ToGroupId"},response:{GroupId:"convGroupID",ToGroupId:"groupID",OptType:"operationType"}}}}(e)),this._configMap.set(Go,function(e){return{head:{...e,servcmd:`${m.NAME.RECENT_CONTACT}.${m.CMD.DELETE_CONVERSATION_GROUP}`},body:{fromAccount:"",groupName:void 0},keyMap:{request:{},response:{GroupId:"convGroupID"}}}}(e)),this._configMap.set(Uo,function(e){return{head:{...e,servcmd:`${m.NAME.RECENT_CONTACT}.${m.CMD.UPDATE_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(ko,function(e){return{head:{...e,servcmd:`${m.NAME.RECENT_CONTACT}.${m.CMD.UPDATE_CONVERSATION_GROUP}`},body:{fromAccount:"",updateType:void 0,updateGroup:{groupName:void 0,updateGroupType:void 0,updateItem:void 0}},keyMap:{request:{},response:{}}}}(e)),this._configMap.set(Po,function(e){return{head:{...e,servcmd:`${m.NAME.RECENT_CONTACT}.${m.CMD.UPDATE_CONVERSATION_GROUP}`},body:{fromAccount:"",updateType:void 0,updateGroup:void 0},keyMap:{request:{},response:{}}}}(e)),this._configMap.set(bo,function(e){return{head:{...e,servcmd:`${m.NAME.RECENT_CONTACT}.${m.CMD.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(Ys,function(e){return{head:{...e,servcmd:`${m.NAME.PROFILE}.${m.CMD.PORTRAIT_GET}`},body:{fromAccount:"",userItem:[]},keyMap:{request:{toAccount:"To_Account",standardSequence:"StandardSequence",customSequence:"CustomSequence"}}}}(e)),this._configMap.set(js,function(e){return{head:{...e,servcmd:`${m.NAME.PROFILE}.${m.CMD.PORTRAIT_SET}`},body:{fromAccount:"",profileItem:[{tag:Me.NICK,value:""},{tag:Me.GENDER,value:""},{tag:Me.ALLOWTYPE,value:""},{tag:Me.AVATAR,value:""}]},keyMap:{request:{toAccount:"To_Account",standardSequence:"StandardSequence",customSequence:"CustomSequence"}}}}(e)),this._configMap.set(zs,function(e){return{head:{...e,servcmd:`${m.NAME.FRIEND}.${m.CMD.GET_BLACKLIST}`},body:{fromAccount:"",startIndex:0,maxLimited:30,lastSequence:0},keyMap:{response:{CurruentSequence:"currentSequence"}}}}(e)),this._configMap.set(Js,function(e){return{head:{...e,servcmd:`${m.NAME.FRIEND}.${m.CMD.ADD_BLACKLIST}`},body:{fromAccount:"",toAccount:[]}}}(e)),this._configMap.set(Xs,function(e){return{head:{...e,servcmd:`${m.NAME.FRIEND}.${m.CMD.DELETE_BLACKLIST}`},body:{fromAccount:"",toAccount:[]}}}(e)),this._configMap.set(zi,function(e){return{head:{...e,servcmd:`${m.NAME.IM_OPEN_STATUS}.${m.CMD.SET_SELF_STATUS}`},body:{customStatus:""},keyMap:{}}}(e)),this._configMap.set(Ji,function(e){return{head:{...e,servcmd:`${m.NAME.IM_OPEN_STATUS}.${m.CMD.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(Xi,function(e){return{head:{...e,servcmd:`${m.NAME.IM_OPEN_STATUS}.${m.CMD.SUBSCRIBE_USER_STATUS}`},body:{userIDList:void 0},keyMap:{response:{ErrorList:"failureUserList",To_Account:"userID",Invalid_Account:"invalidUserID"}}}}(e)),this._configMap.set(Zi,function(e){return{head:{...e,servcmd:`${m.NAME.IM_OPEN_STATUS}.${m.CMD.UNSUBSCRIBE_USER_STATUS}`},body:{userIDList:void 0,unsubscribeAll:void 0},keyMap:{response:{ErrorList:"failureUserList",To_Account:"userID",Invalid_Account:"invalidUserID"}}}}(e)),this._configMap.set(Zs,function(e){return{head:{...e,servcmd:`${m.NAME.FRIEND}.${m.CMD.GET_FRIEND_LIST}`},body:{fromAccount:"",startIndex:0,standardSequence:0,customSequence:0},keyMap:{response:{FriendNum:"friendCount",UserDataItem:"resultList",ValueItem:"tagValueList"}}}}(e)),this._configMap.set(so,function(e){return{head:{...e,servcmd:`${m.NAME.FRIEND}.${m.CMD.ADD_FRIEND}`},body:{fromAccount:"",addFriendItem:[],type:""},keyMap:{request:{source:"AddSource",wording:"AddWording",type:"AddType"},response:{ResultItem:"resultList"}}}}(e)),this._configMap.set(oo,function(e){return{head:{...e,servcmd:`${m.NAME.FRIEND}.${m.CMD.UPDATE_FRIEND}`},body:{fromAccount:"",updateItem:void 0},keyMap:{request:{snsItem:"SnsItem"},response:{ResultItem:"resultList"}}}}(e)),this._configMap.set(to,function(e){return{head:{...e,servcmd:`${m.NAME.FRIEND}.${m.CMD.DELETE_FRIEND}`},body:{fromAccount:"",userIDList:[],type:""},keyMap:{request:{type:"DeleteType"},response:{ResultItem:"resultList"}}}}(e)),this._configMap.set(Qs,function(e){return{head:{...e,servcmd:`${m.NAME.FRIEND}.${m.CMD.GET_FRIEND_PROFILE}`},body:{fromAccount:"",userIDList:void 0},keyMap:{response:{InfoItem:"resultList",SnsProfileItem:"tagValueList"}}}}(e)),this._configMap.set(eo,function(e){return{head:{...e,servcmd:`${m.NAME.FRIEND}.${m.CMD.CHECK_FRIEND}`},body:{fromAccount:"",userIDList:[],type:""},keyMap:{request:{type:"CheckType"},response:{InfoItem:"resultList"}}}}(e)),this._configMap.set(no,function(e){return{head:{...e,servcmd:`${m.NAME.FRIEND}.${m.CMD.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(io,function(e){return{head:{...e,servcmd:`${m.NAME.FRIEND}.${m.CMD.RESPOND_FRIEND_APPLICATION}`},body:{fromAccount:"",responseFriendItem:[]},keyMap:{request:{tag:"TagName",action:"ResponseAction"},response:{ResultItem:"resultList"}}}}(e)),this._configMap.set(ro,function(e){return{head:{...e,servcmd:`${m.NAME.FRIEND}.${m.CMD.DELETE_FRIEND_APPLICATION}`},body:{fromAccount:"",type:"",userIDList:void 0},keyMap:{request:{type:"PendencyType",userIDList:"To_Account"},response:{ResultItem:"resultList"}}}}(e)),this._configMap.set(ao,function(e){return{head:{...e,servcmd:`${m.NAME.FRIEND}.${m.CMD.REPORT_FRIEND_APPLICATION}`},body:{fromAccount:"",latestTimeStamp:""},keyMap:{request:{latestTimeStamp:"LatestPendencyTimeStamp"}}}}(e)),this._configMap.set(co,function(e){return{head:{...e,servcmd:`${m.NAME.FRIEND}.${m.CMD.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(lo,function(e){return{head:{...e,servcmd:`${m.NAME.FRIEND}.${m.CMD.DELETE_FRIEND_GROUP}`},body:{fromAccount:"",nameList:void 0},keyMap:{request:{nameList:"GroupName"}}}}(e)),this._configMap.set(uo,function(e){return{head:{...e,servcmd:`${m.NAME.FRIEND}.${m.CMD.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(po,function(e){return{head:{...e,servcmd:`${m.NAME.FRIEND}.${m.CMD.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(wo,function(e){return{head:{...e,servcmd:`${m.NAME.GROUP}.${m.CMD.GET_JOINED_GROUPS}`},body:{memberAccount:"",limit:void 0,offset:void 0,groupType:void 0,responseFilter:{groupBaseInfoFilter:void 0,selfInfoFilter:void 0},isSupportTopic:0},keyMap:{request:{memberAccount:"Member_Account"},response:{GroupIdList:"groups",NoUnreadSeqList:"excludedUnreadSequenceList",MsgSeq:"readedSequence",LastRecallTime:"_lastRevokedTime"}}}}(e)),this._configMap.set(Fo,function(e){return{head:{...e,servcmd:`${m.NAME.GROUP}.${m.CMD.GET_GROUP_INFO}`},body:{groupIDList:void 0,responseFilter:{groupBaseInfoFilter:["Type","Name","Introduction","Notification","FaceUrl","Owner_Account","CreateTime","InfoSeq","LastInfoTime","LastMsgTime","MemberNum","MaxMemberNum","ApplyJoinOption","NextMsgSeq","ShutUpAllMember"],groupCustomFieldFilter:void 0,memberInfoFilter:void 0,memberCustomFieldFilter:void 0}},keyMap:{request:{groupIDList:"GroupIdList",groupCustomField:"AppDefinedData",memberCustomField:"AppMemberDefinedData",groupCustomFieldFilter:"AppDefinedDataFilter_Group",memberCustomFieldFilter:"AppDefinedDataFilter_GroupMember"},response:{GroupIdList:"groups",AppDefinedData:"groupCustomField",AppMemberDefinedData:"memberCustomField",AppDefinedDataFilter_Group:"groupCustomFieldFilter",AppDefinedDataFilter_GroupMember:"memberCustomFieldFilter",InfoSeq:"infoSequence",MemberList:"members",GroupInfo:"groups",ShutUpUntil:"muteUntil",ShutUpAllMember:"muteAllMembers"}}}}(e)),this._configMap.set($o,function(e){return{head:{...e,servcmd:`${m.NAME.GROUP}.${m.CMD.CREATE_GROUP}`},body:{type:void 0,name:void 0,groupID:void 0,ownerID:void 0,introduction:void 0,notification:void 0,maxMemberNum:void 0,joinOption:void 0,memberList:void 0,groupCustomField:void 0,memberCustomField:void 0,webPushFlag:1,avatar:"",isSupportTopic:void 0,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(qo,function(e){return{head:{...e,servcmd:`${m.NAME.GROUP}.${m.CMD.DESTROY_GROUP}`},body:{groupID:void 0}}}(e)),this._configMap.set(xo,function(e){return{head:{...e,servcmd:`${m.NAME.GROUP}.${m.CMD.MODIFY_GROUP_INFO}`},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(Vo,function(e){return{head:{...e,servcmd:`${m.NAME.GROUP}.${m.CMD.APPLY_JOIN_GROUP}`},body:{groupID:void 0,applyMessage:void 0,userDefinedField:void 0,webPushFlag:1,historyMessageFlag:void 0},keyMap:{request:{applyMessage:"ApplyMsg",historyMessageFlag:"HugeGroupHistoryMsgFlag"},response:{HugeGroupFlag:"avChatRoomFlag",AVChatRoomKey:"avChatRoomKey",RspMsgList:"messageList",ToGroupId:"to"}}}}(e)),this._configMap.set(Bo,function(e){const{a2:t,tinyid:s,...o}=e;return{head:{...o,servcmd:`${m.NAME.BIG_GROUP_NO_AUTH}.${m.CMD.APPLY_JOIN_GROUP}`},body:{groupID:void 0,applyMessage:void 0,userDefinedField:void 0,webPushFlag:1},keyMap:{request:{applyMessage:"ApplyMsg"},response:{HugeGroupFlag:"avChatRoomFlag"}}}}(e)),this._configMap.set(Ho,function(e){return{head:{...e,servcmd:`${m.NAME.GROUP}.${m.CMD.QUIT_GROUP}`},body:{groupID:void 0}}}(e)),this._configMap.set(Ko,function(e){return{head:{...e,servcmd:`${m.NAME.GROUP}.${m.CMD.SEARCH_GROUP_BY_ID}`},body:{groupIDList:void 0,responseFilter:{groupBasePublicInfoFilter:["Type","Name","Introduction","Notification","FaceUrl","CreateTime","Owner_Account","LastInfoTime","LastMsgTime","NextMsgSeq","MemberNum","MaxMemberNum","ApplyJoinOption","InviteJoinOption"]}},keyMap:{response:{}}}}(e)),this._configMap.set(Wo,function(e){return{head:{...e,servcmd:`${m.NAME.GROUP}.${m.CMD.CHANGE_GROUP_OWNER}`},body:{groupID:void 0,newOwnerID:void 0},keyMap:{request:{newOwnerID:"NewOwner_Account"}}}}(e)),this._configMap.set(Yo,function(e){return{head:{...e,servcmd:`${m.NAME.GROUP}.${m.CMD.HANDLE_APPLY_JOIN_GROUP}`},body:{groupID:void 0,applicant:void 0,handleAction:void 0,handleMessage:void 0,authentication:void 0,messageKey:void 0,userDefinedField:void 0},keyMap:{request:{applicant:"Applicant_Account",handleAction:"HandleMsg",handleMessage:"ApprovalMsg",messageKey:"MsgKey"}}}}(e)),this._configMap.set(jo,function(e){return{head:{...e,servcmd:`${m.NAME.GROUP}.${m.CMD.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(zo,function(e){return{head:{...e,servcmd:`${m.NAME.GROUP}.${m.CMD.HANDLE_GROUP_INVITATION}`},body:{groupID:void 0,inviter:void 0,handleAction:void 0,handleMessage:void 0,authentication:void 0,messageKey:void 0,userDefinedField:void 0},keyMap:{request:{inviter:"Inviter_Account",handleAction:"HandleMsg",handleMessage:"ApprovalMsg",messageKey:"MsgKey"}}}}(e)),this._configMap.set(ii,function(e){return{head:{...e,servcmd:`${m.NAME.GROUP}.${m.CMD.GET_GROUP_APPLICATION}`},body:{startTime:void 0,limit:void 0,handleAccount:void 0},keyMap:{request:{handleAccount:"Handle_Account"},response:{To_Account:"userID"}}}}(e)),this._configMap.set(ni,function(e){return{head:{...e,servcmd:`${m.NAME.OPEN_IM}.${m.CMD.DELETE_GROUP_SYSTEM_MESSAGE}`},body:{messageListToDelete:void 0},keyMap:{request:{messageListToDelete:"DelMsgList",messageSeq:"MsgSeq",messageRandom:"MsgRandom"}}}}(e)),this._configMap.set(ri,function(e){return{head:{...e,servcmd:`${m.NAME.BIG_GROUP_LONG_POLLING}.${m.CMD.AVCHATROOM_LONG_POLL}`},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(ai,function(e){const{a2:t,tinyid:s,...o}=e;return{head:{...o,servcmd:`${m.NAME.BIG_GROUP_LONG_POLLING_NO_AUTH}.${m.CMD.AVCHATROOM_LONG_POLL}`},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(ui,function(e){return{head:{...e,servcmd:`${m.NAME.GROUP}.${m.CMD.GET_ONLINE_MEMBER_NUM}`},body:{groupID:void 0}}}(e)),this._configMap.set(di,function(e){return{head:{...e,servcmd:`${m.NAME.GROUP}.${m.CMD.SET_GROUP_ATTRIBUTES}`},body:{groupID:void 0,groupAttributeList:void 0,mainSequence:void 0,avChatRoomKey:void 0,attributeControl:["RaceConflict"]},keyMap:{request:{key:"key",value:"value"}}}}(e)),this._configMap.set(pi,function(e){return{head:{...e,servcmd:`${m.NAME.GROUP}.${m.CMD.MODIFY_GROUP_ATTRIBUTES}`},body:{groupID:void 0,groupAttributeList:void 0,mainSequence:void 0,avChatRoomKey:void 0,attributeControl:["RaceConflict"]},keyMap:{request:{key:"key",value:"value"}}}}(e)),this._configMap.set(hi,function(e){return{head:{...e,servcmd:`${m.NAME.GROUP}.${m.CMD.DELETE_GROUP_ATTRIBUTES}`},body:{groupID:void 0,groupAttributeList:void 0,mainSequence:void 0,avChatRoomKey:void 0,attributeControl:["RaceConflict"]},keyMap:{request:{key:"key"}}}}(e)),this._configMap.set(gi,function(e){return{head:{...e,servcmd:`${m.NAME.GROUP}.${m.CMD.CLEAR_GROUP_ATTRIBUTES}`},body:{groupID:void 0,mainSequence:void 0,avChatRoomKey:void 0,attributeControl:["RaceConflict"]}}}(e)),this._configMap.set(_i,function(e){return{head:{...e,servcmd:`${m.NAME.GROUP_ATTR}.${m.CMD.GET_GROUP_ATTRIBUTES}`},body:{groupID:void 0,avChatRoomKey:void 0,groupType:1},keyMap:{request:{avChatRoomKey:"Key",groupType:"GroupType"}}}}(e)),this._configMap.set(fi,function(e){return{head:{...e,servcmd:`${m.NAME.GROUP}.${m.CMD.GET_GROUP_NOTIFY}`},body:{notifyType:1,groupID:"",beginTime:0,endTime:0,limit:20},keyMap:{request:{},response:{NextMsgTime:"nextRevokedTime",NotifyMsgList:"notifyList"}}}}(e)),this._configMap.set(Ii,function(e){return{head:{...e,servcmd:`${m.NAME.GROUP}.${m.CMD.UPDATE_GROUP_COUNTER}`},body:{groupID:void 0,counterList:void 0,avChatRoomKey:void 0,mode:void 0},keyMap:{request:{counterList:"GroupCounter"}}}}(e)),this._configMap.set(Ci,function(e){return{head:{...e,servcmd:`${m.NAME.GROUP}.${m.CMD.GET_GROUP_COUNTER}`},body:{groupID:void 0,keyList:[],avChatRoomKey:void 0},keyMap:{request:{keyList:"GroupCounterKeys"}}}}(e)),this._configMap.set(Ki,function(e){return{head:{...e,servcmd:`${m.NAME.GROUP_COMMUNITY}.${m.CMD.CREATE_TOPIC}`},body:{groupID:void 0,topicName:void 0,avatar:void 0,customData:void 0,topicID:void 0,notification:void 0,introduction:void 0},keyMap:{request:{avatar:"FaceUrl"}}}}(e)),this._configMap.set(Wi,function(e){return{head:{...e,servcmd:`${m.NAME.GROUP_COMMUNITY}.${m.CMD.DELETE_TOPIC}`},body:{groupID:void 0,topicIDList:void 0},keyMap:{request:{topicIDList:"TopicIdList"},response:{DestroyResultItem:"resultList"}}}}(e)),this._configMap.set(Yi,function(e){return{head:{...e,servcmd:`${m.NAME.GROUP_COMMUNITY}.${m.CMD.UPDATE_TOPIC_PROFILE}`},body:{groupID:void 0,topicID:void 0,avatar:void 0,customData:void 0,notification:void 0,introduction:void 0,muteAllMembers:void 0,topicName:void 0},keyMap:{request:{avatar:"FaceUrl",muteAllMembers:"ShutUpAllMember"}}}}(e)),this._configMap.set(ji,function(e){return{head:{...e,servcmd:`${m.NAME.GROUP_COMMUNITY}.${m.CMD.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(Ti,function(e){return{head:{...e,servcmd:`${m.NAME.GROUP}.${m.CMD.GET_GROUP_MEMBER_LIST}`},body:{groupID:void 0,limit:0,offset:void 0,next:void 0,memberRoleFilter:void 0,memberInfoFilter:["Role","NameCard","ShutUpUntil","JoinTime"],memberCustomFieldFilter:void 0},keyMap:{request:{memberCustomFieldFilter:"AppDefinedDataFilter_GroupMember"},response:{AppMemberDefinedData:"memberCustomField",AppDefinedDataFilter_GroupMember:"memberCustomFieldFilter",MemberList:"members",ShutUpUntil:"muteUntil"}}}}(e)),this._configMap.set(yi,function(e){return{head:{...e,servcmd:`${m.NAME.GROUP_AVCHATROOM}.${m.CMD.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(Di,function(e){return{head:{...e,servcmd:`${m.NAME.GROUP}.${m.CMD.GET_GROUP_MEMBER_INFO}`},body:{groupID:void 0,userIDList:void 0,memberInfoFilter:void 0,memberCustomFieldFilter:void 0},keyMap:{request:{userIDList:"Member_List_Account",memberCustomFieldFilter:"AppDefinedDataFilter_GroupMember"},response:{MemberList:"members",ShutUpUntil:"muteUntil",AppDefinedDataFilter_GroupMember:"memberCustomFieldFilter",AppMemberDefinedData:"memberCustomField"}}}}(e)),this._configMap.set(Ei,function(e){return{head:{...e,servcmd:`${m.NAME.GROUP}.${m.CMD.ADD_GROUP_MEMBER}`},body:{groupID:void 0,silence:void 0,userIDList:void 0},keyMap:{request:{userID:"Member_Account",userIDList:"MemberList"},response:{MemberList:"members"}}}}(e)),this._configMap.set(Si,function(e){return{head:{...e,servcmd:`${m.NAME.GROUP}.${m.CMD.DELETE_GROUP_MEMBER}`},body:{groupID:void 0,userIDList:void 0,reason:void 0},keyMap:{request:{userIDList:"MemberToDel_Account"}}}}(e)),this._configMap.set(Li,function(e){return{head:{...e,servcmd:`${m.NAME.GROUP}.${m.CMD.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(Ai,function(e){return{head:{...e,servcmd:`${m.NAME.GROUP}.${m.CMD.MODIFY_GROUP_MEMBER_INFO}`},body:{groupID:void 0,topicID:void 0,userID:void 0,messageRemindType:void 0,nameCard:void 0,role:void 0,memberCustomField:void 0,muteTime:void 0},keyMap:{request:{userID:"Member_Account",memberCustomField:"AppMemberDefinedData",muteTime:"ShutUpTime",messageRemindType:"MsgFlag"}}}}(e)),this._configMap.set(vi,function(e){return{head:{...e,servcmd:`${m.NAME.GROUP_AVCHATROOM}.${m.CMD.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(Gi,function(e){return{head:{...e,servcmd:`${m.NAME.IM_OPEN_STAT}.${m.CMD.TIM_WEB_REPORT_V2}`},body:{header:{},event:[],quality:[]},keyMap:{request:{SDKType:"sdk_type",SDKVersion:"sdk_version",deviceType:"device_type",platform:"platform",instanceID:"instance_id",traceID:"trace_id",SDKAppID:"sdk_app_id",userID:"user_id",tinyID:"tiny_id",extension:"extension",timestamp:"timestamp",networkType:"network_type",eventType:"event_type",code:"error_code",message:"error_message",moreMessage:"more_message",duplicate:"duplicate",costTime:"cost_time",level:"level",qualityType:"quality_type",reportIndex:"report_index",wholePeriod:"whole_period",totalCount:"total_count",rttCount:"success_count_business",successRateOfRequest:"percent_business",countLessThan1Second:"success_count_business",percentOfCountLessThan1Second:"percent_business",countLessThan3Second:"success_count_platform",percentOfCountLessThan3Second:"percent_platform",successCountOfBusiness:"success_count_business",successRateOfBusiness:"percent_business",successCountOfPlatform:"success_count_platform",successRateOfPlatform:"percent_platform",successCountOfMessageReceived:"success_count_business",successRateOfMessageReceived:"percent_business",avgRTT:"average_value",avgDelay:"average_value",avgValue:"average_value",uiPlatform:"ui_platform"}}}}(s)),this._configMap.set(Ui,function(e){return{head:{...e,servcmd:`${m.NAME.HEARTBEAT}.${m.CMD.ALIVE}`},body:{}}}(e)),this._configMap.set(ki,function(e){return{head:{...e,servcmd:`${m.NAME.IM_OPEN_PUSH}.${m.CMD.MESSAGE_PUSH}`},body:{},keyMap:{response:{C2cMsgArray:"C2CMessageArray",GroupMsgArray:"groupMessageArray",GroupTips:"groupTips",C2cNotifyMsgArray:"C2CNotifyMessageArray",C2cMsgInfo:"C2CReadReceiptArray",ClientSeq:"clientSequence",MsgPriority:"priority",NoticeSeq:"noticeSequence",MsgContent:"content",MsgType:"type",MsgBody:"elements",ToGroupId:"to",Desc:"description",Ext:"extension",IsSyncMsg:"isSyncMessage",Flag:"needSync",NeedAck:"needAck",PendencyAdd_Account:"userID",ProfileImNick:"nick",PendencyType:"applicationType",C2CReadAllMsg:"readAllC2CMessage",IsNeedReadReceipt:"needReadReceipt",Status:"statusType"}}}}(e)),this._configMap.set(Pi,function(e){return{head:{...e,servcmd:`${m.NAME.IM_OPEN_PUSH}.${m.CMD.MULTI_MESSAGE_PUSH}`},body:{},keyMap:{response:{GroupMsgArray:"groupMessageArray",GroupTips:"groupTips",ClientSeq:"clientSequence",MsgPriority:"priority",NoticeSeq:"noticeSequence",MsgContent:"content",MsgType:"type",MsgBody:"elements",ToGroupId:"to",Desc:"description",Ext:"extension",IsSyncMsg:"isSyncMessage",Flag:"needSync",NeedAck:"needAck",PendencyType:"applicationType"}}}}(e)),this._configMap.set(bi,function(e){return{head:{...e,servcmd:`${m.NAME.OPEN_IM}.${m.CMD.MESSAGE_PUSH_ACK}`},body:{sessionData:void 0},keyMap:{request:{sessionData:"SessionData"}}}}(e)),this._configMap.set(wi,function(e){return{head:{...e,servcmd:`${m.NAME.IM_OPEN_STATUS}.${m.CMD.STATUS_FORCE_OFFLINE}`},body:{},keyMap:{response:{C2cNotifyMsgArray:"C2CNotifyMessageArray",NoticeSeq:"noticeSequence",KickoutMsgNotify:"kickoutMsgNotify",NewInstInfo:"newInstanceInfo"}}}}(e)),this._configMap.set($i,function(e){return{head:{...e,servcmd:`${m.NAME.IM_LONG_MESSAGE}.${m.CMD.DOWNLOAD_MERGER_MESSAGE}`},body:{downloadKey:""},keyMap:{response:{Data:"data",Desc:"description",Ext:"extension",Download_Flag:"downloadFlag",ThumbUUID:"thumbUUID",VideoUUID:"videoUUID"}}}}(e)),this._configMap.set(Fi,function(e){return{head:{...e,servcmd:`${m.NAME.IM_LONG_MESSAGE}.${m.CMD.UPLOAD_MERGER_MESSAGE}`},body:{messageList:[]},keyMap:{request:{fromAccount:"From_Account",toAccount:"To_Account",msgTimeStamp:"MsgTimeStamp",msgSeq:"MsgSeq",msgRandom:"MsgRandom",msgBody:"MsgBody",type:"MsgType",content:"MsgContent",data:"Data",description:"Desc",extension:"Ext",sizeType:"Type",uuid:"UUID",url:"",imageUrl:"URL",fileUrl:"Url",remoteAudioUrl:"Url",remoteVideoUrl:"VideoUrl",thumbUUID:"ThumbUUID",videoUUID:"VideoUUID",videoUrl:"",downloadFlag:"Download_Flag",from:"From_Account",time:"MsgTimeStamp",messageRandom:"MsgRandom",messageSequence:"MsgSeq",elements:"MsgBody",clientSequence:"ClientSeq",payload:"MsgContent",messageList:"MsgList",messageNumber:"MsgNum",abstractList:"AbstractList",messageBody:"MsgBody"}}}}(e)),this._configMap.set(tn,function(e){return{head:{...e,servcmd:`${m.NAME.IM_OPEN_STATUS}.${m.CMD.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(en,function(e){return{head:{...e,servcmd:`${m.NAME.IM_OPEN_STATUS}.${m.CMD.STAT_FOREGROUND}`},body:{isWebUniapp:0}}}(e)),this._configMap.set(Qi,function(e){return{head:{...e,servcmd:`${m.NAME.IM_OPEN_STATUS}.${m.CMD.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||{}:(_e.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=gt(t.head),o=_a(t.body,this._getRequestKeyMap(s));return t.body=o,t}_updateService(e,t){const s=gt(t.head);if(this._isFromGroupRequest(t)){let{type:o,groupID:i,groupIDList:n=[]}=e;we(i)&&(i=n[0]||""),st({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{...pa.request,...t.request}}_requestDataCleaner(e){const t=Array.isArray(e)?[]:Object.create(null);for(const s in e)Object.prototype.hasOwnProperty.call(e,s)&&Ve(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],be(e[o])?s[o]=Array.from(e[o]):ke(e[o])?s[o]=this._simpleDeepCopy(e[o]):s[o]=e[o];return s}}const Na=[bi];class Ra{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._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(Ds).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(be(o[e].elements.revokedInfos))t.onGroupMessageRevoked({dataList:o});else if(be(o[e].elements.groupMessageReadNotice))t.onGroupMessageReadNotice({dataList:o});else{if(!be(o[e].elements.readReceiptList)){t.onNewGroupSystemNotice({dataList:o,isInstantMessage:i,isSyncingEnded:n});break}t.onReadReceiptList({dataList:o})}break;case 12:this._sessionModule.getModule(_s).onNewGroupAtTips({dataList:o});break;default:_e.l(`${this._n}._groupTipsHandler unknown event:${s} dataList:`,o)}}_C2CNotifyMessageArrayHandler(e){const{dataList:t}=e;if(!be(t))return;const s=this._sessionModule.getModule(ls);t.forEach(e=>{if(Pe(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(_s).onC2CMessageRemindTypeSynced({dataList:t})}})}_C2CReadReceiptArrayHandler(e){this._sessionModule.getModule(ls).onReadReceiptList(e)}_profileHandler(e){this._sessionModule.getModule(cs).onProfileModified({dataList:e.dataList});const t=this._sessionModule.getModule(ps);t&&t.onFriendProfileModified({dataList:e.dataList})}_relationChainHandler(e){this._sessionModule.getModule(cs).onRelationChainModified({dataList:e.dataList});const t=this._sessionModule.getModule(ps);t&&t.onRelationChainModified({dataList:e.dataList})}_recentContactHandler(e){const{dataList:t}=e;if(!be(t))return;const s=this._sessionModule.getModule(_s);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(_s);s&&s.onPushedAllMessageRead(t)}_userStatusListHandler(e){this._sessionModule.getModule(cs).onUserStatusUpdated(e)}_messageExtensionNotifyHandler(e){this._sessionModule.getModule(us).onMessageExtensionNotify(e)}onMessage(e){const{body:t}=e;if(!this._filterMessageFromIMOpenPush(e))return;const{eventArray:s,isInstantMessage:o,isSyncingEnded:i,needSync:n}=t;if(!be(s))return;let r=null,a=null,u=0;for(let c=0,l=s.length;c<l;c++){r=s[c],u=r.event;const e=Object.keys(r).find(e=>-1!==this._keys.indexOf(e));e?(a=14===u?{readAllC2CMessage:r[e],groupMessageReadInfoList:r.groupMessageReadNotice||[]}:16===u?{userID:r.userID,readReceiptList:r[e]}:r[e],this._eventHandlerMap.get(e)({event:u,dataList:a,isInstantMessage:o,isSyncingEnded:i,needSync:n})):_e.l(`${this._n}.onMessage unknown eventItem:${r}`)}}_filterMessageFromIMOpenPush(e){const{head:t,body:s}=e,{servcmd:o}=t;let i=!1;if(we(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(m.CMD.PUSHED_CLOUD_CONTROL_CONFIG)){this._sessionModule.getModule(As).onPushedCloudControlConfig(s)}else if(o.includes(m.CMD.PUSHED_COMMERCIAL_CONFIG)){this._sessionModule.getModule(Os).onPushedConfig(s)}else if(o.includes(m.CMD.OVERLOAD_NOTIFY))this._sessionModule.onPushedServerOverload(s);else if(o.includes(m.CMD.KICK_OTHER)){const e=Date.now();this._sessionModule.reLoginOnKickOther();const t=new Cn("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 Oa=[{cmd:m.CMD.GET_GROUP_INFO,interval:1,count:20},{cmd:m.CMD.GET_AVCHATROOM_MEMBER_LIST,interval:3,count:1},{cmd:m.CMD.GET_GROUP_APPLICATION,interval:1,count:15},{cmd:m.CMD.GET_TOPIC_LIST,interval:1,count:10},{cmd:m.CMD.SET_GROUP_ATTRIBUTES,interval:5,count:10},{cmd:m.CMD.MODIFY_GROUP_ATTRIBUTES,interval:5,count:10},{cmd:m.CMD.DELETE_GROUP_ATTRIBUTES,interval:5,count:10},{cmd:m.CMD.CLEAR_GROUP_ATTRIBUTES,interval:5,count:10},{cmd:m.CMD.GET_GROUP_ATTRIBUTES,interval:5,count:20},{cmd:m.CMD.UPDATE_GROUP_COUNTER,interval:5,count:20},{cmd:m.CMD.GET_GROUP_COUNTER,interval:5,count:20},{cmd:m.CMD.SET_ALL_MESSAGE_READ,interval:1,count:1},{cmd:m.CMD.GET_USER_STATUS,interval:5,count:20},{cmd:m.CMD.SUBSCRIBE_USER_STATUS,interval:5,count:20},{cmd:m.CMD.UNSUBSCRIBE_USER_STATUS,interval:5,count:20}];class Ga extends Fs{constructor(e){super(e),this._n="SessionModule",this._platform=this.getPlatform(),this._protocolHandler=new va(this),this._messageDispatcher=new Ra(this),this._commandFrequencyLimitMap=new Map,this._commandRequestInfoMap=new Map,this._serverOverloadInfoMap=new Map,this._init();this.getInnerEmitterInstance().on(Wn,this._onCloudConfigUpdated,this)}_init(){this._updateCommandFrequencyLimitMap(Oa)}_onCloudConfigUpdated(){let e=this.getCloudConfig("cmd_frequency_limit");we(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){_e.d(this._n+".request options:",e);const{protocolName:t,tjgID:s}=e;if(!this._protocolHandler.has(t))return _e.w(`${this._n}.request unknown protocol:${t}`),Vn({code:nn.CANNOT_FIND_PROTOCOL});const o=this.getProtocolData(e),{servcmd:i}=o.head;if(this._isFrequencyOverLimit(i))return Vn({code:nn.OVER_FREQUENCY_LIMIT});if(this._isServerOverload(i))return Vn({code:nn.OPEN_SERVICE_OVERLOAD_ERROR});Lt(s)||(o.head.tjgID=s);const n=this.getModule(Ss);return Na.includes(t)?n.simplySend(o):n.send(o)}getKeyMap(e){return this._protocolHandler.getKeyMap(e)}genCommonHead(){const e=this.getModule(ms);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,tjgID:""}}genCosSpecifiedHead(){const e=this.getModule(ms);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}}genSSOReportHead(){const e=this.getModule(ms);return{ver:"v4",platform:this._platform,websdkappid:a,websdkversion:r,sdkappid:e.getSDKAppID(),contenttype:"",reqtime:0,identifier:"",usersig:"",status_instid:e.getStatusInstanceID(),sdkability:192371}}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===nn.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===nn.MESSAGE_A2KEY_EXPIRED||t===nn.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(){this._reLoginOnReconnected()}reLoginOnKickOther(){_e.l(this._n+".reLoginOnKickOther"),this._reLogin()}_reLoginOnReconnected(){_e.l(this._n+"._reLoginOnReconnected"),this._reLogin()}_reLogin(){if(this.isLoggedIn()){let e=0;const t=this.getModule(Gs);t.canIUseOfflinePush()&&(e=t.getUniAppPlatform()),this.request({protocolName:$s,requestData:{isWebUniapp:e}}).then(e=>{const{instanceID:t}=e.data;this.getModule(ms).setStatusInstanceID(t),_e.l(this._n+"._reLogin ok.");this.getModule(_s).syncConversationList().then(()=>{_e.l(this._n+"._reLogin, sync conversation list ok.");this.getModule(Ns).start()});this.getModule(ds).updateLocalMainSequenceOnReconnected();const s=this.getModule(gs);s.resetGetTopicTime(),s.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:bi,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}onPushedServerOverload(e){const{overloadCommand:t,waitingTime:s}=e;this._serverOverloadInfoMap.set(t,{overloadTime:Date.now(),waitingTime:s}),_e.w(`${this._n}.onPushedServerOverload waitingTime:${s}s`)}reset(){_e.l(this._n+".reset"),this._updateCommandFrequencyLimitMap(Oa),this._commandRequestInfoMap.clear(),this._serverOverloadInfoMap.clear()}}class Ua extends Fs{constructor(e){super(e),this._n="MessageLossDetectionModule",this._maybeLostSequencesMap=new Map,this._firstRoundRet=[]}onMessageMaybeLost(e,t,s){this._maybeLostSequencesMap.has(e)||this._maybeLostSequencesMap.set(e,[]);const o=this._maybeLostSequencesMap.get(e);for(let i=0;i<s;i++)-1===o.indexOf(t+i)&&o.push(t+i)}detectFirstRound(e,t){const s=this._maybeLostSequencesMap.get(e);if(Lt(s)||Lt(t))return;const o=s.filter(e=>-1===t.indexOf(e));0===o.length?_e.i(`${this._n}.detectFirstRound no message loss. conversationID:${e}`):this._firstRoundRet=this._firstRoundRet.concat(o),s.length=0}detectSecondRound(e,t){if(Lt(this._firstRoundRet)||Lt(t))return;const s=this._firstRoundRet.filter(e=>-1===t.indexOf(e));this._firstRoundRet.length=0;const o=s.length;if(0===o)return;let i;o<=5?i=e+"-"+s.join("-"):(s.sort((e,t)=>e-t),i=e+" start:"+s[0]+" end:"+s[o-1]+" count:"+o);new Cn("messageLoss").setMessage(i).setNetworkType(this.getNetworkType()).setLevel("warning").end(),_e.i(`${this._n}.detectSecondRound message loss detected. conversationID:${e} lostSequences:${s}`)}reset(){_e.l(this._n+".reset"),this._maybeLostSequencesMap.clear(),this._firstRoundRet.length=0}}class ka extends Fs{constructor(e){super(e),this._n="CloudControlModule",this._cloudConfig=new Map,this._expiredTime=0,this._version=0,this._isFetching=!1}getCloudConfig(e){return we(e)?this._cloudConfig:this._cloudConfig.has(e)?this._cloudConfig.get(e):void 0}_canFetchConfig(){return this.isLoggedIn()&&!this._isFetching&&Date.now()>=this._expiredTime}fetchConfig(){const e=this._canFetchConfig();if(_e.l(`${this._n}.fetchConfig canFetchConfig:${e}`),!e)return;const t=new Cn("fetchCloudControlConfig"),s=this.getModule(ms).getSDKAppID();this._isFetching=!0,this.request({protocolName:qi,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(),_e.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()}),_e.l(this._n+".fetchConfig failed. error:",e),this._setExpiredTimeOnResponseError(12e4)})}onPushedCloudControlConfig(e){_e.l(this._n+".onPushedCloudControlConfig");new Cn("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()||_e.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(Wn))}this._expiredTime=Date.now()+1e3*r}else we(s)?(_e.l(t+" failed. Invalid message format:",e),this._setExpiredTimeOnResponseError(36e5)):(_e.e(`${t} errorCode:${s} errorMessage:${o}`),this._setExpiredTimeOnResponseError(12e4))}_setExpiredTimeOnResponseError(e){this._expiredTime=Date.now()+e}reset(){_e.l(this._n+".reset"),this._cloudConfig.clear(),this._expiredTime=0,this._version=0,this._isFetching=!1}}class Pa extends Fs{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(_s);let o,i,n=0,r=0,a=0;e.forEach(e=>{const{conversationID:u,lastMessage:c}=e;i=u.replace(t.CONV_GROUP,""),o=s.getLocalLastMessage(u),c&&0!==c.lastSequence&&o?(r=c.lastSequence,n=o.sequence,a=r-n,n>0&&a>=1&&a<300?this._recoverGroupMessage({groupID:i,localLastMessageSequence:n,remoteLastMessageSequence:r}):this._getGroupNotify(i)):this._getGroupNotify(i)})}_recoverC2CChat(){const e=this._getLocalConversationList().filter(e=>e.type===t.CONV_C2C),s=this.getModule(_s);let o,i=0,n=0,r=0;const a=[Promise.resolve()];e.forEach(e=>{const{conversationID:t,lastMessage:u}=e;o=s.getLocalLastMessage(t),u&&0!==u.lastTime&&o&&(n=u.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(()=>{_e.l(this._n+"._recoverC2CChat all promise fulfilled, start to sync unread messages");this.getModule(Ds).startSyncOnReconnected()})}_getLocalConversationList(){return this.getModule(_s).getLocalConversationList()}_recoverGroupMessage(e){const s=this._n+"._recoverGroupMessage";_e.l(s+" options:",e);const{groupID:o,localLastMessageSequence:i,remoteLastMessageSequence:n}=e;this._getGroupRomaingMessage({groupID:o,sequence:i}).then(e=>{const{complete:i,messageList:r}=e.data;if(!we(r)){const e=r[0].sequence;_e.l(`${s} pkgLastMessageSequence:${e} complete:${i}`),e<n&&2!==i&&this._recoverGroupMessage({groupID:o,localLastMessageSequence:e,remoteLastMessageSequence:n});new Cn("recoverMessage").setNetworkType(this.getNetworkType()).setMessage(`groupID:${o} complete:${i} messageList length:${r.length}`).end();const a=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?a.onNewGroupMessage({dataList:[e],isInstantMessage:!1,updateUnreadCount:!1}):a.onNewGroupTips({event:e.event,dataList:[e]})}this._getGroupNotify(o)}})}_getGroupNotify(e){this.getModule(ds).getGroupNotify(e)}_getGroupRomaingMessage(e){const{groupID:t,sequence:s}=e;return this.request({protocolName:Qo,requestData:{groupID:t,count:this.PULL_LIMIT_COUNT,sequence:s+this.PULL_LIMIT_COUNT-1}})}_recoverC2CMessage(e){const t=this._n+"._recoverC2CMessage";_e.l(this._n+"._recoverC2CMessage options:",e);const{conversationID:s,localLastMessageTime:o,remoteLastMessageTime:i}=e;return this._getC2CRoamingMessage({conversationID:s,time:o}).then(e=>{const{complete:o,messageList:n}=e.data;if(!we(n)){const e=n.length;new Cn("recoverMessage").setNetworkType(this.getNetworkType()).setMessage(`${s} complete:${o} messageList length:${e}`).end();this.getModule(ls).onNewC2CMessage({dataList:n,isInstantMessage:!0});const r=n[e-1].time;if(_e.l(`${t} pkgLastMessageTime:${r} complete:${o}`),r<i&&1!==o)return this._recoverC2CMessage({conversationID:s,localLastMessageTime:r,remoteLastMessageTime:i})}})}_getC2CRoamingMessage(e){const{conversationID:s,time:o}=e;return this.request({protocolName:Mo,requestData:{peerAccount:s.replace(t.CONV_C2C,""),count:this.PULL_LIMIT_COUNT+1,lastMessageTime:o,direction:1}})}reset(){_e.l(this._n+".reset")}}class ba{constructor(){this._n="AvgE2EDelay",this._e2eDelayArray=[]}addMessageDelay(e){const t=de()-e;t>=0&&this._e2eDelayArray.push(t)}_calcAvg(e,t){if(0===t)return 0;let s=0;return e.forEach(e=>{s+=e}),_t(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=_t(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=_t(t/e.length*100,2);if(r>50){new Cn("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 wa{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=_t(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 _e.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 Fa{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!(we(e)||!this._map.has(e))&&(this._map.get(e).totalCount+=1,!0)}addSuccessCount(e){return!(we(e)||!this._map.has(e))&&(this._map.get(e).successCount+=1,!0)}addFailedCountOfUserSide(e){return!(we(e)||!this._map.has(e))&&(this._map.get(e).failedCountOfUserSide+=1,!0)}addCost(e,t){return!(we(e)||!this._map.has(e))&&(this._map.get(e).costArray.push(t),!0)}addFileSize(e,t){return!(we(e)||!this._map.has(e))&&(this._map.get(e).fileSizeArray.push(t),!0)}_calcSuccessRateOfBusiness(e){if(we(e)||!this._map.has(e))return-1;const t=this._map.get(e);let s=_t(t.successCount/t.totalCount*100,2);return s>100&&(s=100),s}_calcSuccessRateOfPlatform(e){if(we(e)||!this._map.has(e))return-1;const t=this._map.get(e);let s=this._calcSuccessCountOfPlatform(e)/t.totalCount*100;return s=_t(s,2),s>100&&(s=100),s}_calcTotalCount(e){return we(e)||!this._map.has(e)?-1:this._map.get(e).totalCount}_calcSuccessCountOfBusiness(e){return we(e)||!this._map.has(e)?-1:this._map.get(e).successCount}_calcSuccessCountOfPlatform(e){if(we(e)||!this._map.has(e))return-1;const t=this._map.get(e);return t.successCount+t.failedCountOfUserSide}_calcAvg(e){return we(e)||!this._map.has(e)?-1:e===pn?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){we(e)?this._map.clear():this._map.set(e,{totalCount:0,successCount:0,failedCountOfUserSide:0,costArray:[],fileSizeArray:[]})}}class $a{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(we(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(!we(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(we(this._currentMap.get(e))||we(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=_t(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 qa extends Fs{constructor(e){super(e),this._n="QualityStatModule",this.TAG="im-ssolog-quality-stat",this.reportIndex=0,this.wholePeriod=!1,this._qualityItems=[rn,an,un,cn,ln,dn,pn,hn,gn,_n],this._messageSentItems=[un,cn,ln,dn,pn],this._messageReceivedItems=[hn,gn,_n],this.REPORT_INTERVAL=120,this.REPORT_SDKAPPID_BLACKLIST=[],this.REPORT_TINYID_WHITELIST=[],this._statInfoArr=[],this._avgRTT=new wa,this._avgE2EDelay=new ba,this._rateMessageSent=new Fa,this._rateMessageReceived=new $a;const t=this.getInnerEmitterInstance();t.on(Kn,this._onLoginSuccess,this),t.on(Wn,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);!Lt(t)&&$e(t.forEach)&&(_e.l(`${this._n}._onLoginSuccess get quality stat logs from local storage, 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");we(e)||(this.REPORT_INTERVAL=Number(e)),we(t)||(this.REPORT_SDKAPPID_BLACKLIST=t.split(",").map(e=>Number(e))),we(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)||_e.w(this._n+".addTotalCount invalid key:",e)}addSuccessCount(e){this._rateMessageSent.addSuccessCount(e)||_e.w(this._n+".addSuccessCount invalid key:",e)}addFailedCountOfUserSide(e){this._rateMessageSent.addFailedCountOfUserSide(e)||_e.w(this._n+".addFailedCountOfUserSide invalid key:",e)}addCost(e,t){this._rateMessageSent.addCost(e,t)||_e.w(this._n+".addCost invalid key or cost:",e,t)}addFileSize(e,t){this._rateMessageSent.addFileSize(e,t)||_e.w(this._n+".addFileSize invalid key or size:",e,t)}addMessageSequence(e){this._rateMessageReceived.addMessageSequence(e)||_e.w(this._n+".addMessageSequence invalid key:",e.key)}_getQualityItem(e){let t={},s=fn[this.getNetworkType()];we(s)&&(s=8);const o={qualityType:mn[e],timestamp:ce(),networkType:s,extension:""};switch(e){case rn:t=this._avgRTT.getStatResult();break;case an:t=this._avgE2EDelay.getStatResult();break;case un:case cn:case ln:case dn:case pn:t=this._rateMessageSent.getStatResult(e);break;case hn:case gn:case _n:t=this._rateMessageReceived.getStatResult(e)}return null===t?null:{...o,...t}}_report(e){let t=[],s=null;we(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))),_e.d(this._n+"._report",t),this._statInfoArr.length>0&&(t=t.concat(this._statInfoArr),this._statInfoArr=[]);const o=this.getModule(ms),i=o.getSDKAppID(),n=o.getTinyID();mt(this.REPORT_SDKAPPID_BLACKLIST,i)&&!Mt(this.REPORT_TINYID_WHITELIST,n)&&(t=[]),t.length>0&&this._doReport(t)}_doReport(e){const t={header:Yr(this),quality:e};this.request({protocolName:Gi,requestData:{...t}}).then(()=>{this.reportIndex++,this.wholePeriod=!1}).catch(t=>{_e.w(`${this._n}._doReport, online:${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(Lt(t))_e.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)),_e.l(`${o} count:${i.length}`),e.setItem(this.TAG,i,!0,!1)}this._statInfoArr=[]}reset(){_e.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 xa{constructor(e){Lt(e)||(this.userID=e.userID||"",this.nick=e.nick||"",this.avatar=e.avatar||"",this.time=e.time||0,this.source=e.source||"",this.wording=e.wording||"",this.type=e.type||"")}}class Va{constructor(e){this._snsModule=e,this._n="FriendApplicationHandler",this._startTime=0,this._maxLimited=100,this._currentSequence=0,this._friendApplicationMap=new Map,this._unreadCount=0}getLocalFriendApplicationList(){return{friendApplicationList:[...this._friendApplicationMap.values()],unreadCount:this._unreadCount}}_onFriendApplicationListUpdated(){this._snsModule.emitOuterEvent(e.FRIEND_APPLICATION_LIST_UPDATED,{friendApplicationList:[...this._friendApplicationMap.values()],unreadCount:this._unreadCount})}onFriendApplicationRead(){this._unreadCount=0,this._onFriendApplicationListUpdated()}onFriendApplicationAdded(e,s){if(Lt(e))return;let o="";o=s===this._snsModule.getMyUserID()?t.SNS_APPLICATION_SENT_BY_ME:t.SNS_APPLICATION_SENT_TO_ME;let i=!1;e.forEach(e=>{const s=`${e.userID}_${o}`;o!==t.SNS_APPLICATION_SENT_TO_ME||this._friendApplicationMap.has(s)||(this._unreadCount+=1),this._friendApplicationMap.set(s,new xa({...e,type:o})),i=!0}),i&&this._onFriendApplicationListUpdated()}onFriendApplicationDeleted(e){Lt(e)||this.getFriendApplicationList()}getFriendApplicationList(){const e=this._n+".getFriendApplicationList",s=new Cn("getFriendApplicationList");return this._snsModule.request({protocolName:no,requestData:{applicationType:t.SNS_APPLICATION_TYPE_BOTH,fromAccount:this._snsModule.getMyUserID(),maxLimited:this._maxLimited,startTime:this._startTime,lastSequence:this._currentSequence}}).then(t=>{const{resultList:o,unreadCount:i,startTime:n,currentSequence:r}=t.data;this._startTime=n,this._currentSequence=r,this._unreadCount=i;const a=be(o)?o.length:0;s.setNetworkType(this._snsModule.getNetworkType()).setMessage(`applicationCount:${a} unreadCount:${i}`).end(),_e.i(`${e} ok. applicationCount:${a} unreadCount:${i}`),this._friendApplicationMap.clear(),be(o)&&o.forEach(e=>{const{userID:t,type:s}=e,o=new xa(e);this._friendApplicationMap.set(`${t}_${s}`,o)}),this._onFriendApplicationListUpdated()}).catch(t=>(this._snsModule.probeNetwork().then(([e,o])=>{s.setError(t,e,o).end()}),_e.w(e+" failed. error:",t),Vn(t)))}deleteFriendApplication(e){const s=this._n+".deleteFriendApplication",{userID:o,type:i}=e;let n=i;if((!n||n!==t.SNS_APPLICATION_SENT_BY_ME&&n!==t.SNS_APPLICATION_SENT_TO_ME)&&(n=t.SNS_APPLICATION_SENT_TO_ME),!this._friendApplicationMap.has(`${o}_${n}`))return Vn({code:nn.FRIEND_APPLICATION_NOT_EXIST});const r=new Cn("deleteFriendApplication");r.setMessage(`userID:${o} type:${n}`);return this._snsModule.request({protocolName:ro,requestData:{fromAccount:this._snsModule.getMyUserID(),userIDList:[o],type:n}}).then(e=>{const{resultList:t}=e.data,{to:i,resultCode:a,resultInfo:u}=t[0];return r.setNetworkType(this._snsModule.getNetworkType()).setMoreMessage("resultList:"+JSON.stringify(t)).end(),_e.i(`${s} ok. userID:${o} type:${n}`),0===a?wn():Vn({userID:i,code:a,message:u})}).catch(e=>(this._snsModule.probeNetwork().then(([t,s])=>{r.setError(e,t,s).end()}),_e.w(s+" failed. error:",e),Vn(e)))}acceptFriendApplication(e){const s=this._n+".acceptFriendApplication",{userID:o,remark:i,tag:n,type:r}=e;let a=r;(!a||a!==t.SNS_APPLICATION_AGREE&&a!==t.SNS_APPLICATION_AGREE_AND_ADD)&&(a=t.SNS_APPLICATION_AGREE_AND_ADD);const u=new Cn("acceptFriendApplication");u.setMessage(`userID:${o} type:${a}`);return this._snsModule.request({protocolName:io,requestData:{fromAccount:this._snsModule.getMyUserID(),responseFriendItem:[{userID:o,remark:i,tag:n,action:a}]}}).then(e=>{u.setNetworkType(this._snsModule.getNetworkType()).end();const{resultList:t}=e.data,{resultCode:i,resultInfo:n}=t[0];if(0!==i)return Vn({code:i,message:n});_e.i(`${s} ok. userID:${o} type:${a}`)}).catch(e=>(this._snsModule.probeNetwork().then(([t,s])=>{u.setError(e,t,s).end()}),_e.w(s+" failed. error:",e),Vn(e)))}refuseFriendApplication(e){const t=this._n+".refuseFriendApplication",{userID:s}=e,o=new Cn("refuseFriendApplication");o.setMessage("userID:"+s);return this._snsModule.request({protocolName:io,requestData:{fromAccount:this._snsModule.getMyUserID(),responseFriendItem:[{userID:s,action:"Response_Action_Reject"}]}}).then(e=>{o.setNetworkType(this._snsModule.getNetworkType()).end();const{resultList:i}=e.data,{resultCode:n,resultInfo:r}=i[0];if(0!==n)return Vn({code:n,message:r});_e.i(`${t} ok. userID:${s}`)}).catch(e=>(this._snsModule.probeNetwork().then(([t,s])=>{o.setError(e,t,s).end()}),_e.w(t+" failed. error:",e),Vn(e)))}_onFriendApplicationProcessed(e){if(0===e.length)return;let s=!1;e.forEach(e=>{const o=`${e.to}_${t.SNS_APPLICATION_SENT_TO_ME}`;this._friendApplicationMap.has(o)&&(this._friendApplicationMap.delete(o),this._unreadCount-=1,s=!0)}),this._unreadCount<0&&(this._unreadCount=0),s&&this._onFriendApplicationListUpdated()}setFriendApplicationRead(){const e=this._n+".setFriendApplicationRead",t=new Cn("setFriendApplicationRead");return this._snsModule.request({protocolName:ao,requestData:{fromAccount:this._snsModule.getMyUserID(),latestTimeStamp:_t(ce()/1e3,0)}}).then(s=>{t.setNetworkType(this._snsModule.getNetworkType()).end(),_e.i(e+" ok"),this._unreadCount=0}).catch(s=>(this._snsModule.probeNetwork().then(([e,o])=>{t.setError(s,e,o).end()}),_e.w(e+" failed. error:",s),Vn(s)))}reset(){this._startIndex=0,this._maxLimited=100,this._currentSequence=0,this._unreadCount=0,this._friendApplicationMap.clear()}}class Ba{constructor(e,t){this.userID=e,this.remark="",this.groupList=[],this.source="",this.addTime=0,this.friendCustomField=[],this.timestamp=0;const s={},o=[];if(s.userID=e,!Lt(t)){let e="",i="";for(let n=0,r=t.length;n<r;n++)if(e=t[n].tag,i=t[n].value,e.indexOf("Tag_SNS_Custom")>-1)this.friendCustomField.push({key:e,value:i});else if(e.indexOf("Tag_Profile_Custom")>-1)o.push({key:e,value:i});else switch(e){case Me.NICK:s.nick=i;break;case Me.GENDER:s.gender=i;break;case Me.BIRTHDAY:s.birthday=i;break;case Me.LOCATION:s.location=i;break;case Me.SELFSIGNATURE:s.selfSignature=i;break;case Me.ALLOWTYPE:s.allowType=i;break;case Me.LANGUAGE:s.language=i;break;case Me.AVATAR:s.avatar=i;break;case Me.MESSAGESETTINGS:s.messageSettings=i;break;case Me.ADMINFORBIDTYPE:s.adminForbidType=i;break;case Me.LEVEL:s.level=i;break;case Me.ROLE:s.role=i;break;case Ie:this.remark=i;break;case ye:this.addTime=i;break;case fe:this.groupList=JSON.parse(JSON.stringify(i));break;case Ce:this.source=i;break;case Te:break;default:_e.l("snsProfileItem unknown tag->",t[n].tag)}}this.profile=new tr({...s,profileCustomField:o})}validate(e){let t=!0,s="";if(Lt(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],!Ue(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(!Ue(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(Lt(e[o])&&!Ue(e[o])&&!Ge(e[o])){s="key:"+o+", invalid value:"+e[o],t=!1;continue}switch(o){case"nick":Ue(e[o])||(s="nick must be a string",t=!1),Ke(e[o])>500&&(s=`nick name limited: must less than or equal to 500 bytes, current size: ${Ke(e[o])} bytes`,t=!1);break;case"gender":ze(De,e.gender)||(s="key:gender, invalid value:"+e.gender,t=!1);break;case"birthday":Ge(e.birthday)||(s="birthday must be a number",t=!1);break;case"location":Ue(e.location)||(s="location must be a string",t=!1);break;case"selfSignature":Ue(e.selfSignature)||(s="selfSignature must be a string",t=!1);break;case"allowType":ze(Se,e.allowType)||(s="key:allowType, invalid value:"+e.allowType,t=!1);break;case"language":Ge(e.language)||(s="language must be a number",t=!1);break;case"avatar":Ue(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":ze(Ee,e.adminForbidType)||(s="key:adminForbidType, invalid value:"+e.adminForbidType,t=!1);break;case"level":Ge(e.level)||(s="level must be a number",t=!1);break;case"role":Ge(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}}update(e){let t="",s="";const o=[];this.friendCustomField.forEach(e=>{o.push(e.key)});for(let i=0,n=e.length;i<n;i++)if(t=e[i].tag,s=e[i].value,t.indexOf("Tag_SNS_Custom")>-1)o.indexOf(t)>-1?this.friendCustomField.forEach(e=>{e.key===t&&(e.value=s)}):this.friendCustomField.push({key:t,value:s});else if(t.indexOf("Tag_Profile_Custom")>-1){let e=!1;this.profile.profileCustomField.forEach(o=>{o.key===t&&(o.value=s,e=!0)}),e||this.profile.profileCustomField.push({key:t,value:s})}else switch(t){case Me.NICK:this.profile.nick=s;break;case Me.GENDER:this.profile.gender=s;break;case Me.BIRTHDAY:this.profile.birthday=s;break;case Me.LOCATION:this.profile.location=s;break;case Me.SELFSIGNATURE:this.profile.selfSignature=s;break;case Me.ALLOWTYPE:this.profile.allowType=s;break;case Me.LANGUAGE:this.profile.language=s;break;case Me.AVATAR:this.profile.avatar=s;break;case Me.MESSAGESETTINGS:this.profile.messageSettings=s;break;case Me.ADMINFORBIDTYPE:this.profile.adminForbidType=s;break;case Me.LEVEL:this.profile.level=s;break;case Me.ROLE:this.profile.role=s;break;case Ie:this.remark=s;break;case ye:this.addTime=s;break;case fe:this.groupList=JSON.parse(JSON.stringify(s));break;case Ce:this.source=s;break;case Te:break;default:_e.d("snsProfileItem unkown tag->",e[i].tag)}this.timestamp=Date.now(),o.length=0}updateProfile(e){this.profile=JSON.parse(JSON.stringify(e)),this.timestamp=Date.now()}addToGroupList(e){-1===this.groupList.indexOf(e)&&(this.groupList.push(e),this.count=this.groupList.length)}removeFromGroupList(e){const t=this.groupList.indexOf(e);t>-1&&(this.groupList.splice(t,1),this.count=this.groupList.length)}}class Ha{constructor(e){this._snsModule=e,this._n="FriendHandler",this._friendMap=new Map,this._startIndex=0,this._standardSequence=0,this._customSequence=0,this._expirationTime=18e4}getLocalFriendList(){return[...this._friendMap.values()]}getFriendRemark(e){return this._friendMap.has(e)?this._friendMap.get(e).remark:""}onFriendProfileModified(e){const{dataList:s}=e;if(Lt(s))return;const o=this._snsModule.getModule(_s);s.forEach(e=>{const{userID:s,profileList:i}=e;if(this.isMyFriend(s)){_e.l(`${this._n}.onFriendProfileModified. friend account:${s}, profileList:${JSON.stringify(i)}`);const e=this._friendMap.get(s);e.update(i),o.modifyMessageSentByPeer({conversationID:`${t.CONV_C2C}${s}`,latestNick:e.profile.nick,latestAvatar:e.profile.avatar})}}),this._onFriendListUpdated()}onFriendAdded(e){0!==e.length&&(_e.l(`${this._n}.onFriendAdded userIDList:${e}`),e.forEach(e=>{this._friendMap.set(e,new Ba(e))}),this.getFriendProfile({userIDList:e}).then(t=>{e.forEach(e=>{const t=this._friendMap.get(e);t.groupList.length>0&&this._snsModule.updateWhenFriendAdded({nameList:t.groupList,userID:e})}),this._onFriendListUpdated()}))}onFriendDeleted(e){0!==e.length&&(_e.l(`${this._n}.onFriendDeleted userIDList:${e}`),e.forEach(e=>{const t=this._friendMap.get(e);t.groupList.length>0&&this._snsModule.updateWhenFriendDeleted({nameList:t.groupList,userID:e}),this._friendMap.delete(e)}),this._onFriendListUpdated())}_onFriendListUpdated(){this._snsModule.emitOuterEvent(e.FRIEND_LIST_UPDATED);this._snsModule.getModule(_s).checkAndPatchRemark()}getFriendProfile(e){const t=this._n+".getFriendProfile",{userIDList:s}=e,o=[],i=[],n=[];if(s.forEach(e=>{if(this._friendMap.has(e)){const t=this._friendMap.get(e);Date.now()-t.timestamp<this._expirationTime?i.push(t):n.push(e)}else o.push({userID:e,code:nn.NOT_MY_FRIEND,message:this._snsModule.getErrorMessage(nn.NOT_MY_FRIEND)})}),0===n.length)return _e.i(t+" newUserIDList is empty"),xn({friendList:i,failureUserIDList:o});const r=new Cn("getFriendProfile");r.setMessage("userIDList:"+n),_e.i(`${t} userIDList:${n}`);return this._snsModule.request({protocolName:Qs,requestData:{fromAccount:this._snsModule.getMyUserID(),userIDList:n}}).then(e=>{r.setNetworkType(this._snsModule.getNetworkType()).end(),_e.i(t+" ok");const{resultList:s}=e.data;return s.forEach(e=>{const{to:t,resultCode:s,resultInfo:n,tagValueList:r}=e;if(we(s)||0===s){let e;this._friendMap.has(t)?(e=this._friendMap.get(t),e.update(r)):(e=new Ba(t,r),this._friendMap.set(t,e)),i.push(e)}else o.push({userID:t,code:s,message:n})}),wn({friendList:i,failureUserIDList:o})}).catch(e=>(this._snsModule.probeNetwork().then(([t,s])=>{r.setError(e,t,s).end()}),_e.w(t+" failed. error:",e),Vn(e)))}isMyFriend(e){return this._friendMap.has(e)}pagingGetFriendList(){const t=this._n+".getFriendList",s=new Cn("getFriendList"),o=Date.now();this._snsModule.request({protocolName:Zs,requestData:{fromAccount:this._snsModule.getMyUserID(),startIndex:this._startIndex,standardSequence:this._standardSequence,customSequence:this._customSequence}}).then(i=>{const{friendCount:n,resultList:r,nextStartIndex:a,standardSequence:u,customSequence:c,completeFlag:l}=i.data;this._startIndex=a,this._standardSequence=u,this._customSequence=c;const d=`friendCount:${n} nextStartIndex:${a} standardSequence:${u} customSequence:${c} completeFlag:${l} cost ${Date.now()-o} ms`;s.setNetworkType(this._snsModule.getNetworkType()).setMessage(d).end(),_e.i(t+" ok.",d),Lt(r)||r.forEach(e=>{const{to:t,tagValueList:s}=e;this._friendMap.set(t,new Ba(t,s))}),0===l?this.pagingGetFriendList():(this._snsModule.emitOuterEvent(e.FRIEND_LIST_UPDATED),this._pagingGetFriendProfile())}).catch(e=>(this._snsModule.probeNetwork().then(([t,o])=>{s.setError(e,t,o).end()}),_e.w(t+" failed. error:",e),Vn(e)))}_pagingGetFriendProfile(){const e=[...this._friendMap.keys()],t=this._snsModule.getModule(cs),s=e.length,o=s<=100?1:Math.ceil(s/100);_e.l(`${this._n}._pagingGetFriendProfile friendCount:${s} pageCount:${o}`);for(let i=0;i<o;i++)t.getUserProfile({userIDList:e.slice(100*i,100*(i+1))}).then(e=>{e.data.forEach(e=>{const t=this._friendMap.get(e.userID);t&&t.updateProfile(e)}),this._onFriendListUpdated()})}addFriend(e){const s=this._n+".addFriend";if(this._friendMap.has(e.to))return Vn({code:nn.ALREADY_MY_FRIEND});if(e.wording&&!1===this._snsModule.filterProfanity("wording",e))return Vn({code:nn.PROFANITY_FOUND});const{to:o,source:i,type:n,wording:r,remark:a,groupName:u}=e;let c=n;(!c||c!==t.SNS_ADD_TYPE_SINGLE&&c!==t.SNS_ADD_TYPE_BOTH)&&(c=t.SNS_ADD_TYPE_BOTH);const l=new Cn("addFriend");l.setMessage(`to:${o} source:${i} type:${c}`);return this._snsModule.request({protocolName:so,requestData:{fromAccount:this._snsModule.getMyUserID(),addFriendItem:[{to:o,source:i,wording:r,remark:a,groupName:u}],type:c}}).then(e=>{const{resultList:t}=e.data;l.setNetworkType(this._snsModule.getNetworkType()).setMoreMessage("resultList:"+JSON.stringify(t)).end();const{to:o,resultCode:i,resultInfo:n}=t[0];return _e.i(`${s} ok. to:${o} type:${c} code:${i}`),we(i)||0===i?wn({userID:o,code:0}):30539===i?wn({userID:o,code:i,message:this._snsModule.getErrorMessage(i)}):Vn({userID:o,code:i,message:this._snsModule.getErrorMessage(i)||n})}).catch(e=>(this._snsModule.probeNetwork().then(([t,s])=>{l.setError(e,t,s).end()}),_e.w(s+" failed. error:",e),Vn(e)))}deleteFriend(e){const s=this._n+".deleteFriend",{userIDList:o,type:i}=e;o.length>1e3&&(_e.w(`${s} ${Dt(1e3)}`),o.length=1e3);const n=[],r=[],a=[];if(o.forEach(e=>{this._friendMap.has(e)?a.push(e):n.push({userID:e,code:nn.NOT_MY_FRIEND,message:this._snsModule.getErrorMessage(nn.NOT_MY_FRIEND)})}),0===a.length)return xn({successUserIDList:r,failureUserIDList:n});let u=i;(!u||u!==t.SNS_DELETE_TYPE_SINGLE&&u!==t.SNS_DELETE_TYPE_BOTH)&&(u=t.SNS_DELETE_TYPE_BOTH);const c=new Cn("deleteFriend");c.setMessage(`userIDList:${a} type:${u}`);return this._snsModule.request({protocolName:to,requestData:{fromAccount:this._snsModule.getMyUserID(),userIDList:a,type:u}}).then(e=>{c.setNetworkType(this._snsModule.getNetworkType()).end(),_e.i(s+" ok");const{resultList:t}=e.data;return Lt(t)||t.forEach(e=>{const{to:t,resultCode:s,resultInfo:o}=e;we(s)||0===s?r.push({userID:t}):n.push({userID:t,code:s,message:o})}),wn({successUserIDList:r,failureUserIDList:n})}).catch(e=>(this._snsModule.probeNetwork().then(([t,s])=>{c.setError(e,t,s).end()}),_e.w(s+" error:",e),Vn(e)))}updateFriend(e){const{userID:t,remark:s,friendCustomField:o}=e;if(!this._friendMap.has(t))return Vn({code:nn.NOT_MY_FRIEND});const i=this._n+".updateFriend",n=new Cn("updateFriend");n.setMessage(`userID:${t} remark:${s} friendCustomField:${o}`);const r=[];we(s)||r.push({tag:Ie,value:s}),be(o)&&o.length>0&&o.forEach(e=>{r.push({tag:e.key,value:e.value})});return this._snsModule.request({protocolName:oo,requestData:{fromAccount:this._snsModule.getMyUserID(),updateItem:[{to:t,snsItem:r}]}}).then(e=>{n.setNetworkType(this._snsModule.getNetworkType()).end(),_e.i(i+" ok");const{resultList:t}=e.data,{to:r,resultCode:a,resultInfo:u}=t[0];if(we(a)||0===a){const e=this._friendMap.get(r);return e&&(we(s)||(e.remark=s),be(o)&&o.length>0&&Qe(e.friendCustomField,o),this._onFriendListUpdated()),wn(e)}return Vn({code:a,message:u})}).catch(e=>(this._snsModule.probeNetwork().then(([t,s])=>{n.setError(e,t,s).end()}),_e.w(i+" failed. error:",e),Vn(e)))}checkFriend(e){const s=this._n+".checkFriend",{userIDList:o,type:i}=e;let n=i;(!n||n!==t.SNS_CHECK_TYPE_SINGLE&&n!==t.SNS_CHECK_TYPE_BOTH)&&(n=t.SNS_CHECK_TYPE_BOTH);const r=new Cn("checkFriend");r.setMessage(`userIDList:${o} type:${n}`);return this._snsModule.request({protocolName:eo,requestData:{fromAccount:this._snsModule.getMyUserID(),userIDList:o,type:n}}).then(e=>{r.setNetworkType(this._snsModule.getNetworkType()).end(),_e.i(`${s} ok. userIDList:${o} type:${n}`);const t=[],i=[],{resultList:a}=e.data;return be(a)&&a.forEach(e=>{const{to:s,relation:o,resultCode:n,resultInfo:r}=e;we(n)||0===n?t.push({userID:s,code:0,relation:o}):i.push({userID:s,code:n,message:r})}),wn({successUserIDList:t,failureUserIDList:i})}).catch(e=>(this._snsModule.probeNetwork().then(([t,s])=>{r.setError(e,t,s).end()}),_e.w(s+" failed. error:",e),Vn(e)))}updateWhenAddedToFriendGroup(e){const{name:t,userIDList:s}=e;_e.l(`${this._n}.updateWhenAddedToFriendGroup groupName:${t} userIDList:${s}`),t&&!Lt(s)&&s.forEach(e=>{if(this._friendMap.has(e)){this._friendMap.get(e).addToGroupList(t)}})}updateWhenRemovedFromFriendGroup(e){const{name:t,userIDList:s}=e;_e.l(`${this._n}.updateWhenRemovedFromFriendGroup groupName:${t} userIDList:${s}`),t&&!Lt(s)&&s.forEach(e=>{if(this._friendMap.has(e)){this._friendMap.get(e).removeFromGroupList(t)}})}reset(){this._friendMap.clear(),this._startIndex=0,this._standardSequence=0,this._customSequence=0}}class Ka{constructor(e){Lt(e)||(this.name=e.name||"",this.userIDList=e.userIDList||[],this.count=this.userIDList.length||0)}addToUserIDList(e){-1===this.userIDList.indexOf(e)&&(this.userIDList.push(e),this.count=this.userIDList.length)}removeFromUserIDList(e){const t=this.userIDList.indexOf(e);t>-1&&(this.userIDList.splice(t,1),this.count=this.userIDList.length)}}class Wa{constructor(e){this._snsModule=e,this._n="FriendGroupHandler",this._friendGroupMap=new Map}getLocalFriendGroupList(){return[...this._friendGroupMap.values()]}_emitFriendGroupListUpdated(){const t=[...this._friendGroupMap.values()];this._snsModule.emitOuterEvent(e.FRIEND_GROUP_LIST_UPDATED,t)}getFriendGroupList(){const e=this._n+".getFriendGroupList",t=new Cn("getFriendGroupList");return this._snsModule.request({protocolName:uo,requestData:{fromAccount:this._snsModule.getMyUserID()}}).then(s=>{t.setNetworkType(this._snsModule.getNetworkType()).end();const{resultList:o}=s.data;Lt(o)?_e.i(e+" ok. friend group count:0"):(_e.i(`${e} ok. friend group count:${o.length}`),this._friendGroupMap.clear(),o.forEach(e=>{const t=new Ka(e);this._friendGroupMap.set(e.name,t)}),this._emitFriendGroupListUpdated())}).catch(s=>(this._snsModule.probeNetwork().then(([e,o])=>{t.setError(s,e,o).end()}),_e.w(e+" error:",s),Vn(s)))}createFriendGroup(e){const t=this._n+".createFriendGroup",{name:s,userIDList:o}=e;if(this._friendGroupMap.has(s))return Vn({code:nn.FRIEND_GROUP_EXISTED});const i=new Cn("createFriendGroup");return i.setMessage(`name:${s} userIDList:${o}`),this._snsModule.request({protocolName:co,requestData:{fromAccount:this._snsModule.getMyUserID(),groupName:[s],userIDList:be(o)?o:void 0}}).then(e=>{i.setNetworkType(this._snsModule.getNetworkType()).end(),_e.l(`${t} ok. name:${s} userIDList:${o}`);const{resultList:n}=e.data,r=[],a=[];n&&n.forEach(e=>{const{to:t,resultCode:s,resultInfo:o}=e;if(we(s)||0===s)r.push(t);else{const t={userID:e.to,code:s,message:o};a.push(t)}});const u=new Ka({name:s,userIDList:r});return this._friendGroupMap.set(s,u),this._snsModule.updateWhenAddedToFriendGroup({name:s,userIDList:r}),this._emitFriendGroupListUpdated(),wn({friendGroup:u,failureUserIDList:a})}).catch(e=>(this._snsModule.probeNetwork().then(([t,s])=>{i.setError(e,t,s).end()}),_e.w(t+" failed. error:",e),Vn(e)))}deleteFriendGroup(e){const t=this._n+".deleteFriendGroup",{name:s}=e;if(!this._friendGroupMap.has(s))return Vn({code:nn.FRIEND_GROUP_NOT_EXIST});const o=new Cn("deleteFriendGroup");o.setMessage("name:"+s);return this._snsModule.request({protocolName:lo,requestData:{fromAccount:this._snsModule.getMyUserID(),nameList:[s]}}).then(e=>{o.setNetworkType(this._snsModule.getNetworkType()).end(),_e.l(`${t} ok. name:${s}`);const i=this._friendGroupMap.get(s);return i&&(this._snsModule.updateWhenRemovedFromFriendGroup({name:s,userIDList:i.userIDList}),this._friendGroupMap.delete(s),i.userIDList.length=0),this._emitFriendGroupListUpdated(),wn(i)}).catch(e=>(this._snsModule.probeNetwork().then(([t,s])=>{o.setError(e,t,s).end()}),_e.w(t+" failed. error:",e),Vn(e)))}renameFriendGroup(e){const t=this._n+".renameFriendGroup",{oldName:s,newName:o}=e;if(!this._friendGroupMap.has(s))return Vn({code:nn.FRIEND_GROUP_NOT_EXIST});const i=new Cn("renameFriendGroup");i.setMessage(`oldName:${s} newName:${o}`);return this._snsModule.request({protocolName:po,requestData:{fromAccount:this._snsModule.getMyUserID(),oldName:s,newName:o}}).then(()=>{if(i.setNetworkType(this._snsModule.getNetworkType()).end(),_e.l(`${t} ok. oldName:${s} newName:${o}`),this._friendGroupMap.has(s)){const e=this._friendGroupMap.get(s);return e.name=o,this._friendGroupMap.delete(s),this._friendGroupMap.set(o,e),this._snsModule.updateWhenRemovedFromFriendGroup({name:s,userIDList:e.userIDList}),this._snsModule.updateWhenAddedToFriendGroup({name:o,userIDList:e.userIDList}),this._emitFriendGroupListUpdated(),wn(e)}return wn()}).catch(e=>(this._snsModule.probeNetwork().then(([t,s])=>{i.setError(e,t,s).end()}),_e.w(t+" failed. error:",e),Vn(e)))}addToFriendGroup(e){const t=this._n+".addToFriendGroup",{name:s,userIDList:o}=e;if(!this._friendGroupMap.has(s))return this._onFriendGroupNotExist(s);const i=new Cn("addToFriendGroup");i.setMessage(`name:${s} userIDList:${o}`),_e.l(`${t} name:${s} userIDList:${o}`);return this._snsModule.request({protocolName:po,requestData:{fromAccount:this._snsModule.getMyUserID(),oldName:s,updateGroupItem:o.filter(e=>this._snsModule.isMyFriend(e)).map(e=>({to:e,updateType:"Update_Type_Add"}))}}).then(e=>(i.setNetworkType(this._snsModule.getNetworkType()).end(),this._onFriendGroupUpdated(s,e))).catch(e=>(this._snsModule.probeNetwork().then(([t,s])=>{i.setError(e,t,s).end()}),_e.w(t+" failed. error:",e),Vn(e)))}removeFromFriendGroup(e){const t=this._n+".removeFromFriendGroup",{name:s,userIDList:o}=e;if(!this._friendGroupMap.has(s))return this._onFriendGroupNotExist(s);const i=new Cn("removeFromFriendGroup");i.setMessage(`name:${s} userIDList:${o}`),_e.l(`${t} name:${s} userIDList:${o}`);return this._snsModule.request({protocolName:po,requestData:{fromAccount:this._snsModule.getMyUserID(),oldName:s,updateGroupItem:o.filter(e=>this._snsModule.isMyFriend(e)).map(e=>({to:e,updateType:"Update_Type_Delete"}))}}).then(e=>(i.setNetworkType(this._snsModule.getNetworkType()).end(),this._onFriendGroupUpdated(s,e))).catch(e=>(this._snsModule.probeNetwork().then(([t,s])=>{i.setError(e,t,s).end()}),_e.w(t+" failed. error:",e),Vn(e)))}_onFriendGroupUpdated(e,t){const{resultList:s}=t.data,o=this._friendGroupMap.get(e),i=[],n=[],r=[];return be(s)&&s.forEach(e=>{const{to:t,resultCode:s,resultInfo:a,type:u}=e;0===s?"Update_Type_Add"===u?o&&(o.addToUserIDList(t),n.push(t)):"Update_Type_Delete"===u&&o&&(o.removeFromUserIDList(t),r.push(t)):i.push({to:e.to,code:s,message:a})}),_e.l(`${this._n}._onFriendGroupUpdated name:${e} userIDList:${o.userIDList}`),n.length>0&&this._snsModule.updateWhenAddedToFriendGroup({name:e,userIDList:n}),r.length>0&&this._snsModule.updateWhenRemovedFromFriendGroup({name:e,userIDList:r}),wn({friendGroup:o,failureUserIDList:i})}updateWhenFriendAdded(e){const{nameList:t,userID:s}=e;_e.l(`${this._n}.updateWhenFriendAdded userID:${s} nameList:${t}`),Lt(t)||t.forEach(e=>{if(this._friendGroupMap.has(e)){this._friendGroupMap.get(e).addToUserIDList(s)}})}updateWhenFriendDeleted(e){const{nameList:t,userID:s}=e;_e.l(`${this._n}.updateWhenFriendDeleted userID:${s} nameList:${t}`),Lt(t)||t.forEach(e=>{if(this._friendGroupMap.has(e)){this._friendGroupMap.get(e).removeFromUserIDList(s)}})}reset(){this._friendGroupMap.clear()}}class Ya extends Fs{constructor(e){super(e),this._n="SnsModule",this._friendHandler=new Ha(this),this._friendApplicationHandler=new Va(this),this._friendGroupHandler=new Wa(this);this.getInnerEmitterInstance().on(Kn,this.onContextUpdated,this)}onContextUpdated(e){this._friendHandler.pagingGetFriendList(),this._friendGroupHandler.getFriendGroupList(),this._friendApplicationHandler.getFriendApplicationList()}onRelationChainModified(e){const{dataList:t}=e;if(Lt(t))return;const s=[],o=[],i=[],n=[];let r=!1,a="";t.forEach(e=>{if(3!==e.pushType&&4!==e.pushType||!e.from||(a=e.from),e.friendAddAccount&&(s.push(...e.friendAddAccount),n.push(...e.friendAddAccount)),e.friendDelAccount&&o.push(...e.friendDelAccount),e.friendApplicationAdded&&i.push(...e.friendApplicationAdded),e.friendApplicationDeletedUserIDList&&n.push(...e.friendApplicationDeletedUserIDList),e.reportTime&&7===e.pushType&&(r=!0),e.friendUpInfo){const t={dataList:[]};e.friendUpInfo.forEach(e=>{t.dataList.push({userID:e.friendAccount,profileList:[...e.sns]})}),this.onFriendProfileModified(t)}}),r&&this._friendApplicationHandler.onFriendApplicationRead(),this._friendApplicationHandler.onFriendApplicationAdded(i,a),this._friendApplicationHandler.onFriendApplicationDeleted(n),this._friendHandler.onFriendAdded(s),this._friendHandler.onFriendDeleted(o)}isMyFriend(e){return this._friendHandler.isMyFriend(e)}filterProfanity(e,t){const s=this.getModule(Us);if(!s)return!0;const{isAllowedToSend:o,modifiedText:i}=s.filterText(t[e],D);return!0===o&&(t[e]=i,!0)}onFriendProfileModified(e){this._friendHandler.onFriendProfileModified(e)}getLocalFriendList(e=!0){const t=this._friendHandler.getLocalFriendList();return e?xn(t):t}getFriendRemark(e){return this._friendHandler.getFriendRemark(e)}getFriendList(){return this._friendHandler.pagingGetFriendList()}addFriend(e){return this._friendHandler.addFriend(e)}deleteFriend(e){return this._friendHandler.deleteFriend(e)}checkFriend(e){return this._friendHandler.checkFriend(e)}getFriendProfile(e){return this._friendHandler.getFriendProfile(e)}updateFriend(e){return this._friendHandler.updateFriend(e)}updateWhenAddedToFriendGroup(e){this._friendHandler.updateWhenAddedToFriendGroup(e)}updateWhenRemovedFromFriendGroup(e){this._friendHandler.updateWhenRemovedFromFriendGroup(e)}getLocalFriendApplicationList(){const e=this._friendApplicationHandler.getLocalFriendApplicationList();return xn(e)}deleteFriendApplication(e){return this._friendApplicationHandler.deleteFriendApplication(e)}refuseFriendApplication(e){return this._friendApplicationHandler.refuseFriendApplication(e)}acceptFriendApplication(e){return this._friendApplicationHandler.acceptFriendApplication(e)}setFriendApplicationRead(e){return this._friendApplicationHandler.setFriendApplicationRead(e)}getLocalFriendGroupList(){const e=this._friendGroupHandler.getLocalFriendGroupList();return xn(e)}createFriendGroup(e){return this._friendGroupHandler.createFriendGroup(e)}deleteFriendGroup(e){return this._friendGroupHandler.deleteFriendGroup(e)}addToFriendGroup(e){return this._friendGroupHandler.addToFriendGroup(e)}removeFromFriendGroup(e){return this._friendGroupHandler.removeFromFriendGroup(e)}renameFriendGroup(e){return this._friendGroupHandler.renameFriendGroup(e)}onAddToFriendGroup(e){return this._friendGroupHandler.onAddToFriendGroup(e)}updateWhenFriendAdded(e){this._friendGroupHandler.updateWhenFriendAdded(e)}updateWhenFriendDeleted(e){this._friendGroupHandler.updateWhenFriendDeleted(e)}reset(){_e.l(this._n+".reset"),this._friendHandler.reset(),this._friendGroupHandler.reset(),this._friendApplicationHandler.reset()}}class ja extends Fs{constructor(e){super(e),this._n="WorkerTimerModule",this._isWorkerEnabled=!0,this._workerTimer=null,this._timerID=-1,this._init();this.getInnerEmitterInstance().on(Wn,this._onCloudConfigUpdated,this)}isWorkerEnabled(){return this._isWorkerEnabled&&Q}startWorkerTimer(){_e.l(this._n+".startWorkerTimer"),this._workerTimer&&this._workerTimer.postMessage("start")}stopWorkerTimer(){_e.l(this._n+".stopWorkerTimer"),this._workerTimer&&this._workerTimer.postMessage("stop")}_init(){if(Q){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,_e.l(`${t._n}._init seed:${t._timerID}`)):t._m.onCheckTimer()}}}_onCloudConfigUpdated(){const e=this.getCloudConfig("enable_worker");_e.l(`${this._n}._onCloudConfigUpdated enableWorker:${e}`),we(e)||"1"===e?!this._isWorkerEnabled&&Q&&(this._isWorkerEnabled=!0,this.startWorkerTimer(),this._m.onWorkerTimerEnabled()):this._isWorkerEnabled&&Q&&(this._isWorkerEnabled=!1,this.stopWorkerTimer(),this._m.onWorkerTimerDisabled())}terminate(){_e.l(this._n+".terminate"),this._workerTimer&&(this._workerTimer.terminate(),this._workerTimer=null,this._timerID=-1)}getTimerID(){return this._timerID}reset(){_e.l(this._n+".reset")}}class za{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 _e.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 _e.l(`${this._n}.isFeatureEnabled decimalNumber:${e} binaryString:${t} ret:${i}`),xn({enabled:i})}clear(){this._purchasedFeatureMap.clear()}}class Ja{constructor(e){this._m=e,this._n="CommercialConfigModule",this._expiredTime=0,this._isFetching=!1,this._purchasedFeatureHandler=new za}_canFetch(){return this._getModule(ms).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(_e.l(`${t} canFetch:${e}`),!e)return;const s=this._getModule(Is),o=new Cn("fetchCommercialConfig");o.setNetworkType(s.getNetworkType());const i=this._getModule(ms).getSDKAppID(),n=this._getModule(Es);this._isFetching=!0,n.request({protocolName:Vi,requestData:{SDKAppID:i}}).then(e=>{o.setMessage("purchaseBits:"+e.data.purchaseBits).end(),_e.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)}`;_e.l(""+t);new Cn("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):we(s)?(_e.l(t+" failed. Invalid message format:",e),this._setExpiredTimeOnResponseError(36e5)):(_e.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(){_e.l(this._n+".reset"),this._expiredTime=0,this._isFetching=!1,this._purchasedFeatureHandler.clear()}}class Xa extends Fs{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:u,oppoBusinessID:c,oppoAppKey:l,oppoAppSecret:d,honorBusinessID:p,iosBusinessID:h}=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=u,this._androidPushConfig.oppoPushBussinessId=c,this._androidPushConfig.oppoPushAppKey=l,this._androidPushConfig.oppoPushAppSecret=d,this._androidPushConfig.honorPushBussinessId=p;new Cn("registerPlugin").setMessage("tim-offline-push-plugin").setMoreMessage("isExist:"+!we(this._offlinePushPlugin)).end(!0),_e.l(`${this._n}.registerPlugin ok. offlinePushConfig:${JSON.stringify(e.offlinePushConfig)}`),this._iosBusinessID=h,this._setAppShowListener()}init(){this._isWebUniapp=this.getUniAppPlatform(),this._getDeviceToken()}_getDeviceToken(){const e=this._n+"._getDeviceToken";if(!$e(this._offlinePushPlugin.getDeviceToken))return void _e.e(e+" getDeviceToken is not a function");let t=`androidPushConfig:${JSON.stringify(this._androidPushConfig)}, iosBusinessID:${this._iosBusinessID}`;_e.l(`${e} start. ${t}`);new Cn("_getDeviceToken").setMessage(""+t).end(!0),this._offlinePushPlugin.getDeviceToken(this._androidPushConfig,s=>{const o=new Cn("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}`,_e.l(`${e} ok. ${t}`),o.setMessage(t).end(!0),this._setToken()}else o.setMessage(`code:${i}, msg:${n}`).end(!0),_e.e(e+" failed. error:",s)})}canIUseOfflinePush(){return U&&!we(this._offlinePushPlugin)}_setAppShowListener(){const e=this._n+"._setAppShowListener";if(we(this._offlinePushPlugin))return void _e.e(e+" offlinePushPlugin is undefined");if(!$e(this._offlinePushPlugin.setAppShowListener))return void _e.e(e+" setAppShowListener is not a function");new Cn("_setAppShowListener").end(!0),_e.l(e+" start"),this._offlinePushPlugin.setAppShowListener(t=>{const{appShow:s}=t||{};new Cn("setAppShowListenerRes").setMessage("appShow:"+s).end(!0),_e.l(`${e} ok. appShow:${s}`),this._m.isReady()&&(0===s?(this._getConvUnreadCount(),this._onBackground()):1===s&&this._onForeground())})}getDeviceBrand(){if(!we(this._offlinePushPlugin)&&$e(this._offlinePushPlugin.getDeviceType)){const{deviceType:e}=this._offlinePushPlugin.getDeviceType()||{};return _e.l(`${this._n}.getDeviceBrand ok. deviceType:${e}`),e}}_setToken(){const e=this._n+"._setToken",t=this.getModule(ms);let s="",o=1,i="",r="";Lt(this._deviceToken)&&(o=0);const a=this.getUniAppPlatform(),u=this.getDeviceBrand();a===n.IOS||a===n.IPAD||a===n.MAC?r=this._deviceToken:a===n.ANDROID&&(i=this._deviceToken);const c=new Cn("offlinePushSetToken");return s=`deviceToken:${r||i}, businessID:${this._businessID}, deviceBrand:${u}, isWebUniapp:${this._isWebUniapp}, pushMsg:${o}, platform:${a}`,c.setMessage(""+s),_e.l(`${e} ${s}`),this.request({protocolName:tn,requestData:{tokenID:i,pushMsg:o,sdkAppID:t.getSDKAppID(),businessID:parseInt(this._businessID),deviceBrand:u,deviceToken:r,isWebUniapp:this._isWebUniapp}}).then(t=>(c.end(),_e.l(e+" ok"),t)).catch(t=>(this.probeNetwork().then(([e,s])=>{c.setError(t,e,s).end()}),_e.e(e+" failed. error:",t),Vn(t)))}_getConvUnreadCount(){this._c2cUnreadCount=0,this._groupUnreadCount=0;this.getModule(_s).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 Cn("_onBackground");this.request({protocolName:Qi,requestData:{c2cUnreadCount:this._c2cUnreadCount,groupUnreadCount:this._groupUnreadCount,isWebUniapp:this._isWebUniapp}}).then(s=>(t.setMessage(`c2cUnreadCount: ${this._c2cUnreadCount}, groupUnreadCount: ${this._groupUnreadCount}`).end(),_e.l(e+" ok"),s)).catch(s=>{this.probeNetwork().then(([e,o])=>{t.setError(s,e,o).end()}),_e.e(e+" failed. error:",s)})}_onForeground(){const e=this._n+"._onForeground",t=new Cn("_onForeground");this.request({protocolName:en,requestData:{isWebUniapp:this._isWebUniapp}}).then(s=>(t.end(),_e.l(e+" ok"),s)).catch(s=>{this.probeNetwork().then(([e,o])=>{t.setError(s,e,o).end()}),_e.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,_e.l(this._n+".reset")}}class Za extends Fs{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(ys).getPlugin("tim-profanity-filter-plugin");e?(this._plugin=new e({logger:_e,isArray:be,isMap:Re,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(_e.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=I:n===t.CONV_GROUP&&(a=T),!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 _e.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;_e.l(""+s);const{type:i,modifiedText:n}=this._plugin.filter(e);return 1===i?o.isAllowedToSend=!1:2===i&&(o.modifiedText=n),_e.l(s+" done. ret:",o),o}_getLexicon(){const e=new Cn("profanityFilter"),t=this._n+"._getLexicon";this._isFetching=!0,this.request({protocolName:sn,requestData:{startIndex:this._startIndex,version:this._version}}).then(s=>{const{errorInfo:o,filterConfig:i,lexicon:n,strToken:r,completeFlag:a,nextStartIndex:u,version:c,expiredTime:l}=s.data,{errorCode:d,errorMessage:p}=o;return 0!==d?(this._isFetching=!1,_e.w(t+" failed. error:",o),void e.setCode(d).setMessage(p).end()):(this._onFilterConfig(i),this._getToken(r),1===a?(_e.l(`${t} done. version:${c} expiredTime:${l}`),this._version=c,this._canIUseLexicon=!0,this._isFetching=!1,this._expiredTime=Date.now()+1e3*l,void this._plugin.onLexiconCompleted(n)):(this._startIndex=u,this._plugin.onLexiconSliced(n),void this._getLexicon()))}).catch(s=>{this.probeNetwork().then(([t,o])=>{e.setError(s,t,o).end()}),this._isFetching=!1,_e.l(t+" failed. error:",s)})}_onFilterConfig(e){Lt(e)||(this._filterConfigMap.clear(),Object.keys(e).forEach(t=>{this._filterConfigMap.set(t,e[t])}),_e.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(!Ue(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(){_e.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 Qa{constructor(e){this._m=e,this._n="TransCmdModule",this._TRTCCommandList=["tui_room_svr.*"];this._m.getInnerEmitterInstance().on(Wn,this._onCloudConfigUpdated,this)}_onCloudConfigUpdated(){let e=this._m.getModule(As).getCloudConfig("rtc_cmd");we(e)||(e=JSON.parse(e),e.forEach(e=>{this._TRTCCommandList.includes(e)||this._TRTCCommandList.push(e)}))}sendTRTCCustomData(e){const{serviceCommand:t,data:s}=e;let o=m.NAME.TUIROOM_SVR+".*";return we(t)||(o=t),this._TRTCCommandList.includes(o)?this._trans({servcmd:o,data:s}):Vn({code:nn.INVALID_TRTC_CMD})}_trans(e){_e.d(`${this._n}._trans. options:${JSON.stringify(e)}`);const{servcmd:t,data:s}=e;return this._m.getModule(Es).trans({servcmd:t,data:Ue(s)?JSON.parse(s):s})}getCommandList(){return this._TRTCCommandList}reset(){_e.l(this._n+".reset")}}class eu{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),_e.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||"2.27.6"!==s;return _e.l(`${this._n}._needToUpdate isTimeout:${o} isDifferentVersion:${i}`),o||i}_fetch(){if(this._m.getModule(ms).isPrivateNetWork())return;const e="https://web.sdk.qcloud.com/im/download/error-message/0.0.1/tim-error-message.txt",t="application/x-www-form-urlencoded;charset=UTF-8",s=this._n+"._fetch ok in",o=this;if(P)w.request({url:e,method:"GET",timeout:3e3,header:{"content-type":t},dataType:"text",success:e=>{o._fillAndSave(e.data),_e.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||(_e.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:"2.27.6"}),!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(we(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),we(o)||(r=r.replace("$replacement1",o)),we(i)||(r=r.replace("$replacement2",i)),r):r}reset(){_e.l(this._n+".reset")}}var tu=Qr((function(e,t){var s="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array;function o(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.assign=function(e){for(var t=Array.prototype.slice.call(arguments,1);t.length;){var s=t.shift();if(s){if("object"!=typeof s)throw new TypeError(s+"must be non-object");for(var i in s)o(s,i)&&(e[i]=s[i])}}return e},t.shrinkBuf=function(e,t){return e.length===t?e:e.subarray?e.subarray(0,t):(e.length=t,e)};var i={arraySet:function(e,t,s,o,i){if(t.subarray&&e.subarray)e.set(t.subarray(s,s+o),i);else for(var n=0;n<o;n++)e[i+n]=t[s+n]},flattenChunks:function(e){var t,s,o,i,n,r;for(o=0,t=0,s=e.length;t<s;t++)o+=e[t].length;for(r=new Uint8Array(o),i=0,t=0,s=e.length;t<s;t++)n=e[t],r.set(n,i),i+=n.length;return r}},n={arraySet:function(e,t,s,o,i){for(var n=0;n<o;n++)e[i+n]=t[s+n]},flattenChunks:function(e){return[].concat.apply([],e)}};t.setTyped=function(e){e?(t.Buf8=Uint8Array,t.Buf16=Uint16Array,t.Buf32=Int32Array,t.assign(t,i)):(t.Buf8=Array,t.Buf16=Array,t.Buf32=Array,t.assign(t,n))},t.setTyped(s)}));tu.assign,tu.shrinkBuf,tu.setTyped,tu.Buf8,tu.Buf16,tu.Buf32;var su=function(e,t,s,o){for(var i=65535&e|0,n=e>>>16&65535|0,r=0;0!==s;){s-=r=s>2e3?2e3:s;do{n=n+(i=i+t[o++]|0)|0}while(--r);i%=65521,n%=65521}return i|n<<16|0};var ou=function(){for(var e,t=[],s=0;s<256;s++){e=s;for(var o=0;o<8;o++)e=1&e?3988292384^e>>>1:e>>>1;t[s]=e}return t}();var iu=function(e,t,s,o){var i=ou,n=o+s;e^=-1;for(var r=o;r<n;r++)e=e>>>8^i[255&(e^t[r])];return-1^e},nu=function(e,t){var s,o,i,n,r,a,u,c,l,d,p,h,g,_,m,M,f,I,C,T,y,D,E,S,L;s=e.state,o=e.next_in,S=e.input,i=o+(e.avail_in-5),n=e.next_out,L=e.output,r=n-(t-e.avail_out),a=n+(e.avail_out-257),u=s.dmax,c=s.wsize,l=s.whave,d=s.wnext,p=s.window,h=s.hold,g=s.bits,_=s.lencode,m=s.distcode,M=(1<<s.lenbits)-1,f=(1<<s.distbits)-1;e:do{g<15&&(h+=S[o++]<<g,g+=8,h+=S[o++]<<g,g+=8),I=_[h&M];t:for(;;){if(h>>>=C=I>>>24,g-=C,0===(C=I>>>16&255))L[n++]=65535&I;else{if(!(16&C)){if(0==(64&C)){I=_[(65535&I)+(h&(1<<C)-1)];continue t}if(32&C){s.mode=12;break e}e.msg="invalid literal/length code",s.mode=30;break e}T=65535&I,(C&=15)&&(g<C&&(h+=S[o++]<<g,g+=8),T+=h&(1<<C)-1,h>>>=C,g-=C),g<15&&(h+=S[o++]<<g,g+=8,h+=S[o++]<<g,g+=8),I=m[h&f];s:for(;;){if(h>>>=C=I>>>24,g-=C,!(16&(C=I>>>16&255))){if(0==(64&C)){I=m[(65535&I)+(h&(1<<C)-1)];continue s}e.msg="invalid distance code",s.mode=30;break e}if(y=65535&I,g<(C&=15)&&(h+=S[o++]<<g,(g+=8)<C&&(h+=S[o++]<<g,g+=8)),(y+=h&(1<<C)-1)>u){e.msg="invalid distance too far back",s.mode=30;break e}if(h>>>=C,g-=C,y>(C=n-r)){if((C=y-C)>l&&s.sane){e.msg="invalid distance too far back",s.mode=30;break e}if(D=0,E=p,0===d){if(D+=c-C,C<T){T-=C;do{L[n++]=p[D++]}while(--C);D=n-y,E=L}}else if(d<C){if(D+=c+d-C,(C-=d)<T){T-=C;do{L[n++]=p[D++]}while(--C);if(D=0,d<T){T-=C=d;do{L[n++]=p[D++]}while(--C);D=n-y,E=L}}}else if(D+=d-C,C<T){T-=C;do{L[n++]=p[D++]}while(--C);D=n-y,E=L}for(;T>2;)L[n++]=E[D++],L[n++]=E[D++],L[n++]=E[D++],T-=3;T&&(L[n++]=E[D++],T>1&&(L[n++]=E[D++]))}else{D=n-y;do{L[n++]=L[D++],L[n++]=L[D++],L[n++]=L[D++],T-=3}while(T>2);T&&(L[n++]=L[D++],T>1&&(L[n++]=L[D++]))}break}}break}}while(o<i&&n<a);o-=T=g>>3,h&=(1<<(g-=T<<3))-1,e.next_in=o,e.next_out=n,e.avail_in=o<i?i-o+5:5-(o-i),e.avail_out=n<a?a-n+257:257-(n-a),s.hold=h,s.bits=g},ru=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],au=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],uu=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],cu=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64],lu=function(e,t,s,o,i,n,r,a){var u,c,l,d,p,h,g,_,m,M=a.bits,f=0,I=0,C=0,T=0,y=0,D=0,E=0,S=0,L=0,A=0,v=null,N=0,R=new tu.Buf16(16),O=new tu.Buf16(16),G=null,U=0;for(f=0;f<=15;f++)R[f]=0;for(I=0;I<o;I++)R[t[s+I]]++;for(y=M,T=15;T>=1&&0===R[T];T--);if(y>T&&(y=T),0===T)return i[n++]=20971520,i[n++]=20971520,a.bits=1,0;for(C=1;C<T&&0===R[C];C++);for(y<C&&(y=C),S=1,f=1;f<=15;f++)if(S<<=1,(S-=R[f])<0)return-1;if(S>0&&(0===e||1!==T))return-1;for(O[1]=0,f=1;f<15;f++)O[f+1]=O[f]+R[f];for(I=0;I<o;I++)0!==t[s+I]&&(r[O[t[s+I]]++]=I);if(0===e?(v=G=r,h=19):1===e?(v=ru,N-=257,G=au,U-=257,h=256):(v=uu,G=cu,h=-1),A=0,I=0,f=C,p=n,D=y,E=0,l=-1,d=(L=1<<y)-1,1===e&&L>852||2===e&&L>592)return 1;for(;;){g=f-E,r[I]<h?(_=0,m=r[I]):r[I]>h?(_=G[U+r[I]],m=v[N+r[I]]):(_=96,m=0),u=1<<f-E,C=c=1<<D;do{i[p+(A>>E)+(c-=u)]=g<<24|_<<16|m|0}while(0!==c);for(u=1<<f-1;A&u;)u>>=1;if(0!==u?(A&=u-1,A+=u):A=0,I++,0==--R[f]){if(f===T)break;f=t[s+r[I]]}if(f>y&&(A&d)!==l){for(0===E&&(E=y),p+=C,S=1<<(D=f-E);D+E<T&&!((S-=R[D+E])<=0);)D++,S<<=1;if(L+=1<<D,1===e&&L>852||2===e&&L>592)return 1;i[l=A&d]=y<<24|D<<16|p-n|0}}return 0!==A&&(i[p+A]=f-E<<24|64<<16|0),a.bits=y,0};function du(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function pu(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new tu.Buf16(320),this.work=new tu.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function hu(e){var t;return e&&e.state?(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=1,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new tu.Buf32(852),t.distcode=t.distdyn=new tu.Buf32(592),t.sane=1,t.back=-1,0):-2}function gu(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,hu(e)):-2}function _u(e,t){var s,o;return e&&e.state?(o=e.state,t<0?(s=0,t=-t):(s=1+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?-2:(null!==o.window&&o.wbits!==t&&(o.window=null),o.wrap=s,o.wbits=t,gu(e))):-2}function mu(e,t){var s,o;return e?(o=new pu,e.state=o,o.window=null,0!==(s=_u(e,t))&&(e.state=null),s):-2}var Mu,fu,Iu=!0;function Cu(e){if(Iu){var t;for(Mu=new tu.Buf32(512),fu=new tu.Buf32(32),t=0;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(lu(1,e.lens,0,288,Mu,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;lu(2,e.lens,0,32,fu,0,e.work,{bits:5}),Iu=!1}e.lencode=Mu,e.lenbits=9,e.distcode=fu,e.distbits=5}function Tu(e,t,s,o){var i,n=e.state;return null===n.window&&(n.wsize=1<<n.wbits,n.wnext=0,n.whave=0,n.window=new tu.Buf8(n.wsize)),o>=n.wsize?(tu.arraySet(n.window,t,s-n.wsize,n.wsize,0),n.wnext=0,n.whave=n.wsize):((i=n.wsize-n.wnext)>o&&(i=o),tu.arraySet(n.window,t,s-o,i,n.wnext),(o-=i)?(tu.arraySet(n.window,t,s-o,o,0),n.wnext=o,n.whave=n.wsize):(n.wnext+=i,n.wnext===n.wsize&&(n.wnext=0),n.whave<n.wsize&&(n.whave+=i))),0}var yu={inflateReset:gu,inflateReset2:_u,inflateResetKeep:hu,inflateInit:function(e){return mu(e,15)},inflateInit2:mu,inflate:function(e,t){var s,o,i,n,r,a,u,c,l,d,p,h,g,_,m,M,f,I,C,T,y,D,E,S,L=0,A=new tu.Buf8(4),v=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!e||!e.state||!e.output||!e.input&&0!==e.avail_in)return-2;12===(s=e.state).mode&&(s.mode=13),r=e.next_out,i=e.output,u=e.avail_out,n=e.next_in,o=e.input,a=e.avail_in,c=s.hold,l=s.bits,d=a,p=u,D=0;e:for(;;)switch(s.mode){case 1:if(0===s.wrap){s.mode=13;break}for(;l<16;){if(0===a)break e;a--,c+=o[n++]<<l,l+=8}if(2&s.wrap&&35615===c){s.check=0,A[0]=255&c,A[1]=c>>>8&255,s.check=iu(s.check,A,2,0),c=0,l=0,s.mode=2;break}if(s.flags=0,s.head&&(s.head.done=!1),!(1&s.wrap)||(((255&c)<<8)+(c>>8))%31){e.msg="incorrect header check",s.mode=30;break}if(8!=(15&c)){e.msg="unknown compression method",s.mode=30;break}if(l-=4,y=8+(15&(c>>>=4)),0===s.wbits)s.wbits=y;else if(y>s.wbits){e.msg="invalid window size",s.mode=30;break}s.dmax=1<<y,e.adler=s.check=1,s.mode=512&c?10:12,c=0,l=0;break;case 2:for(;l<16;){if(0===a)break e;a--,c+=o[n++]<<l,l+=8}if(s.flags=c,8!=(255&s.flags)){e.msg="unknown compression method",s.mode=30;break}if(57344&s.flags){e.msg="unknown header flags set",s.mode=30;break}s.head&&(s.head.text=c>>8&1),512&s.flags&&(A[0]=255&c,A[1]=c>>>8&255,s.check=iu(s.check,A,2,0)),c=0,l=0,s.mode=3;case 3:for(;l<32;){if(0===a)break e;a--,c+=o[n++]<<l,l+=8}s.head&&(s.head.time=c),512&s.flags&&(A[0]=255&c,A[1]=c>>>8&255,A[2]=c>>>16&255,A[3]=c>>>24&255,s.check=iu(s.check,A,4,0)),c=0,l=0,s.mode=4;case 4:for(;l<16;){if(0===a)break e;a--,c+=o[n++]<<l,l+=8}s.head&&(s.head.xflags=255&c,s.head.os=c>>8),512&s.flags&&(A[0]=255&c,A[1]=c>>>8&255,s.check=iu(s.check,A,2,0)),c=0,l=0,s.mode=5;case 5:if(1024&s.flags){for(;l<16;){if(0===a)break e;a--,c+=o[n++]<<l,l+=8}s.length=c,s.head&&(s.head.extra_len=c),512&s.flags&&(A[0]=255&c,A[1]=c>>>8&255,s.check=iu(s.check,A,2,0)),c=0,l=0}else s.head&&(s.head.extra=null);s.mode=6;case 6:if(1024&s.flags&&((h=s.length)>a&&(h=a),h&&(s.head&&(y=s.head.extra_len-s.length,s.head.extra||(s.head.extra=new Array(s.head.extra_len)),tu.arraySet(s.head.extra,o,n,h,y)),512&s.flags&&(s.check=iu(s.check,o,h,n)),a-=h,n+=h,s.length-=h),s.length))break e;s.length=0,s.mode=7;case 7:if(2048&s.flags){if(0===a)break e;h=0;do{y=o[n+h++],s.head&&y&&s.length<65536&&(s.head.name+=String.fromCharCode(y))}while(y&&h<a);if(512&s.flags&&(s.check=iu(s.check,o,h,n)),a-=h,n+=h,y)break e}else s.head&&(s.head.name=null);s.length=0,s.mode=8;case 8:if(4096&s.flags){if(0===a)break e;h=0;do{y=o[n+h++],s.head&&y&&s.length<65536&&(s.head.comment+=String.fromCharCode(y))}while(y&&h<a);if(512&s.flags&&(s.check=iu(s.check,o,h,n)),a-=h,n+=h,y)break e}else s.head&&(s.head.comment=null);s.mode=9;case 9:if(512&s.flags){for(;l<16;){if(0===a)break e;a--,c+=o[n++]<<l,l+=8}if(c!==(65535&s.check)){e.msg="header crc mismatch",s.mode=30;break}c=0,l=0}s.head&&(s.head.hcrc=s.flags>>9&1,s.head.done=!0),e.adler=s.check=0,s.mode=12;break;case 10:for(;l<32;){if(0===a)break e;a--,c+=o[n++]<<l,l+=8}e.adler=s.check=du(c),c=0,l=0,s.mode=11;case 11:if(0===s.havedict)return e.next_out=r,e.avail_out=u,e.next_in=n,e.avail_in=a,s.hold=c,s.bits=l,2;e.adler=s.check=1,s.mode=12;case 12:if(5===t||6===t)break e;case 13:if(s.last){c>>>=7&l,l-=7&l,s.mode=27;break}for(;l<3;){if(0===a)break e;a--,c+=o[n++]<<l,l+=8}switch(s.last=1&c,l-=1,3&(c>>>=1)){case 0:s.mode=14;break;case 1:if(Cu(s),s.mode=20,6===t){c>>>=2,l-=2;break e}break;case 2:s.mode=17;break;case 3:e.msg="invalid block type",s.mode=30}c>>>=2,l-=2;break;case 14:for(c>>>=7&l,l-=7&l;l<32;){if(0===a)break e;a--,c+=o[n++]<<l,l+=8}if((65535&c)!=(c>>>16^65535)){e.msg="invalid stored block lengths",s.mode=30;break}if(s.length=65535&c,c=0,l=0,s.mode=15,6===t)break e;case 15:s.mode=16;case 16:if(h=s.length){if(h>a&&(h=a),h>u&&(h=u),0===h)break e;tu.arraySet(i,o,n,h,r),a-=h,n+=h,u-=h,r+=h,s.length-=h;break}s.mode=12;break;case 17:for(;l<14;){if(0===a)break e;a--,c+=o[n++]<<l,l+=8}if(s.nlen=257+(31&c),c>>>=5,l-=5,s.ndist=1+(31&c),c>>>=5,l-=5,s.ncode=4+(15&c),c>>>=4,l-=4,s.nlen>286||s.ndist>30){e.msg="too many length or distance symbols",s.mode=30;break}s.have=0,s.mode=18;case 18:for(;s.have<s.ncode;){for(;l<3;){if(0===a)break e;a--,c+=o[n++]<<l,l+=8}s.lens[v[s.have++]]=7&c,c>>>=3,l-=3}for(;s.have<19;)s.lens[v[s.have++]]=0;if(s.lencode=s.lendyn,s.lenbits=7,E={bits:s.lenbits},D=lu(0,s.lens,0,19,s.lencode,0,s.work,E),s.lenbits=E.bits,D){e.msg="invalid code lengths set",s.mode=30;break}s.have=0,s.mode=19;case 19:for(;s.have<s.nlen+s.ndist;){for(;M=(L=s.lencode[c&(1<<s.lenbits)-1])>>>16&255,f=65535&L,!((m=L>>>24)<=l);){if(0===a)break e;a--,c+=o[n++]<<l,l+=8}if(f<16)c>>>=m,l-=m,s.lens[s.have++]=f;else{if(16===f){for(S=m+2;l<S;){if(0===a)break e;a--,c+=o[n++]<<l,l+=8}if(c>>>=m,l-=m,0===s.have){e.msg="invalid bit length repeat",s.mode=30;break}y=s.lens[s.have-1],h=3+(3&c),c>>>=2,l-=2}else if(17===f){for(S=m+3;l<S;){if(0===a)break e;a--,c+=o[n++]<<l,l+=8}l-=m,y=0,h=3+(7&(c>>>=m)),c>>>=3,l-=3}else{for(S=m+7;l<S;){if(0===a)break e;a--,c+=o[n++]<<l,l+=8}l-=m,y=0,h=11+(127&(c>>>=m)),c>>>=7,l-=7}if(s.have+h>s.nlen+s.ndist){e.msg="invalid bit length repeat",s.mode=30;break}for(;h--;)s.lens[s.have++]=y}}if(30===s.mode)break;if(0===s.lens[256]){e.msg="invalid code -- missing end-of-block",s.mode=30;break}if(s.lenbits=9,E={bits:s.lenbits},D=lu(1,s.lens,0,s.nlen,s.lencode,0,s.work,E),s.lenbits=E.bits,D){e.msg="invalid literal/lengths set",s.mode=30;break}if(s.distbits=6,s.distcode=s.distdyn,E={bits:s.distbits},D=lu(2,s.lens,s.nlen,s.ndist,s.distcode,0,s.work,E),s.distbits=E.bits,D){e.msg="invalid distances set",s.mode=30;break}if(s.mode=20,6===t)break e;case 20:s.mode=21;case 21:if(a>=6&&u>=258){e.next_out=r,e.avail_out=u,e.next_in=n,e.avail_in=a,s.hold=c,s.bits=l,nu(e,p),r=e.next_out,i=e.output,u=e.avail_out,n=e.next_in,o=e.input,a=e.avail_in,c=s.hold,l=s.bits,12===s.mode&&(s.back=-1);break}for(s.back=0;M=(L=s.lencode[c&(1<<s.lenbits)-1])>>>16&255,f=65535&L,!((m=L>>>24)<=l);){if(0===a)break e;a--,c+=o[n++]<<l,l+=8}if(M&&0==(240&M)){for(I=m,C=M,T=f;M=(L=s.lencode[T+((c&(1<<I+C)-1)>>I)])>>>16&255,f=65535&L,!(I+(m=L>>>24)<=l);){if(0===a)break e;a--,c+=o[n++]<<l,l+=8}c>>>=I,l-=I,s.back+=I}if(c>>>=m,l-=m,s.back+=m,s.length=f,0===M){s.mode=26;break}if(32&M){s.back=-1,s.mode=12;break}if(64&M){e.msg="invalid literal/length code",s.mode=30;break}s.extra=15&M,s.mode=22;case 22:if(s.extra){for(S=s.extra;l<S;){if(0===a)break e;a--,c+=o[n++]<<l,l+=8}s.length+=c&(1<<s.extra)-1,c>>>=s.extra,l-=s.extra,s.back+=s.extra}s.was=s.length,s.mode=23;case 23:for(;M=(L=s.distcode[c&(1<<s.distbits)-1])>>>16&255,f=65535&L,!((m=L>>>24)<=l);){if(0===a)break e;a--,c+=o[n++]<<l,l+=8}if(0==(240&M)){for(I=m,C=M,T=f;M=(L=s.distcode[T+((c&(1<<I+C)-1)>>I)])>>>16&255,f=65535&L,!(I+(m=L>>>24)<=l);){if(0===a)break e;a--,c+=o[n++]<<l,l+=8}c>>>=I,l-=I,s.back+=I}if(c>>>=m,l-=m,s.back+=m,64&M){e.msg="invalid distance code",s.mode=30;break}s.offset=f,s.extra=15&M,s.mode=24;case 24:if(s.extra){for(S=s.extra;l<S;){if(0===a)break e;a--,c+=o[n++]<<l,l+=8}s.offset+=c&(1<<s.extra)-1,c>>>=s.extra,l-=s.extra,s.back+=s.extra}if(s.offset>s.dmax){e.msg="invalid distance too far back",s.mode=30;break}s.mode=25;case 25:if(0===u)break e;if(h=p-u,s.offset>h){if((h=s.offset-h)>s.whave&&s.sane){e.msg="invalid distance too far back",s.mode=30;break}h>s.wnext?(h-=s.wnext,g=s.wsize-h):g=s.wnext-h,h>s.length&&(h=s.length),_=s.window}else _=i,g=r-s.offset,h=s.length;h>u&&(h=u),u-=h,s.length-=h;do{i[r++]=_[g++]}while(--h);0===s.length&&(s.mode=21);break;case 26:if(0===u)break e;i[r++]=s.length,u--,s.mode=21;break;case 27:if(s.wrap){for(;l<32;){if(0===a)break e;a--,c|=o[n++]<<l,l+=8}if(p-=u,e.total_out+=p,s.total+=p,p&&(e.adler=s.check=s.flags?iu(s.check,i,p,r-p):su(s.check,i,p,r-p)),p=u,(s.flags?c:du(c))!==s.check){e.msg="incorrect data check",s.mode=30;break}c=0,l=0}s.mode=28;case 28:if(s.wrap&&s.flags){for(;l<32;){if(0===a)break e;a--,c+=o[n++]<<l,l+=8}if(c!==(4294967295&s.total)){e.msg="incorrect length check",s.mode=30;break}c=0,l=0}s.mode=29;case 29:D=1;break e;case 30:D=-3;break e;case 31:return-4;case 32:default:return-2}return e.next_out=r,e.avail_out=u,e.next_in=n,e.avail_in=a,s.hold=c,s.bits=l,(s.wsize||p!==e.avail_out&&s.mode<30&&(s.mode<27||4!==t))&&Tu(e,e.output,e.next_out,p-e.avail_out),d-=e.avail_in,p-=e.avail_out,e.total_in+=d,e.total_out+=p,s.total+=p,s.wrap&&p&&(e.adler=s.check=s.flags?iu(s.check,i,p,e.next_out-p):su(s.check,i,p,e.next_out-p)),e.data_type=s.bits+(s.last?64:0)+(12===s.mode?128:0)+(20===s.mode||15===s.mode?256:0),(0===d&&0===p||4===t)&&0===D&&(D=-5),D},inflateEnd:function(e){if(!e||!e.state)return-2;var t=e.state;return t.window&&(t.window=null),e.state=null,0},inflateGetHeader:function(e,t){var s;return e&&e.state?0==(2&(s=e.state).wrap)?-2:(s.head=t,t.done=!1,0):-2},inflateSetDictionary:function(e,t){var s,o=t.length;return e&&e.state?0!==(s=e.state).wrap&&11!==s.mode?-2:11===s.mode&&su(1,t,o,0)!==s.check?-3:Tu(e,t,o,o)?(s.mode=31,-4):(s.havedict=1,0):-2},inflateInfo:"pako inflate (from Nodeca project)"},Du=!0,Eu=!0;try{String.fromCharCode.apply(null,[0])}catch(Ju){Du=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(Ju){Eu=!1}for(var Su=new tu.Buf8(256),Lu=0;Lu<256;Lu++)Su[Lu]=Lu>=252?6:Lu>=248?5:Lu>=240?4:Lu>=224?3:Lu>=192?2:1;Su[254]=Su[254]=1;function Au(e,t){if(t<65534&&(e.subarray&&Eu||!e.subarray&&Du))return String.fromCharCode.apply(null,tu.shrinkBuf(e,t));for(var s="",o=0;o<t;o++)s+=String.fromCharCode(e[o]);return s}var vu=function(e){var t,s,o,i,n,r=e.length,a=0;for(i=0;i<r;i++)55296==(64512&(s=e.charCodeAt(i)))&&i+1<r&&56320==(64512&(o=e.charCodeAt(i+1)))&&(s=65536+(s-55296<<10)+(o-56320),i++),a+=s<128?1:s<2048?2:s<65536?3:4;for(t=new tu.Buf8(a),n=0,i=0;n<a;i++)55296==(64512&(s=e.charCodeAt(i)))&&i+1<r&&56320==(64512&(o=e.charCodeAt(i+1)))&&(s=65536+(s-55296<<10)+(o-56320),i++),s<128?t[n++]=s:s<2048?(t[n++]=192|s>>>6,t[n++]=128|63&s):s<65536?(t[n++]=224|s>>>12,t[n++]=128|s>>>6&63,t[n++]=128|63&s):(t[n++]=240|s>>>18,t[n++]=128|s>>>12&63,t[n++]=128|s>>>6&63,t[n++]=128|63&s);return t},Nu=function(e){for(var t=new tu.Buf8(e.length),s=0,o=t.length;s<o;s++)t[s]=e.charCodeAt(s);return t},Ru=function(e,t){var s,o,i,n,r=t||e.length,a=new Array(2*r);for(o=0,s=0;s<r;)if((i=e[s++])<128)a[o++]=i;else if((n=Su[i])>4)a[o++]=65533,s+=n-1;else{for(i&=2===n?31:3===n?15:7;n>1&&s<r;)i=i<<6|63&e[s++],n--;n>1?a[o++]=65533:i<65536?a[o++]=i:(i-=65536,a[o++]=55296|i>>10&1023,a[o++]=56320|1023&i)}return Au(a,o)},Ou=function(e,t){var s;for((t=t||e.length)>e.length&&(t=e.length),s=t-1;s>=0&&128==(192&e[s]);)s--;return s<0||0===s?t:s+Su[e[s]]>t?s:t},Gu={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8},Uu={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"};var ku=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0};var Pu=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1},bu=Object.prototype.toString;function wu(e){if(!(this instanceof wu))return new wu(e);this.options=tu.assign({chunkSize:16384,windowBits:0,to:""},e||{});var t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&0==(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new ku,this.strm.avail_out=0;var s=yu.inflateInit2(this.strm,t.windowBits);if(s!==Gu.Z_OK)throw new Error(Uu[s]);if(this.header=new Pu,yu.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=vu(t.dictionary):"[object ArrayBuffer]"===bu.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(s=yu.inflateSetDictionary(this.strm,t.dictionary))!==Gu.Z_OK))throw new Error(Uu[s])}function Fu(e,t){var s=new wu(t);if(s.push(e,!0),s.err)throw s.msg||Uu[s.err];return s.result}wu.prototype.push=function(e,t){var s,o,i,n,r,a=this.strm,u=this.options.chunkSize,c=this.options.dictionary,l=!1;if(this.ended)return!1;o=t===~~t?t:!0===t?Gu.Z_FINISH:Gu.Z_NO_FLUSH,"string"==typeof e?a.input=Nu(e):"[object ArrayBuffer]"===bu.call(e)?a.input=new Uint8Array(e):a.input=e,a.next_in=0,a.avail_in=a.input.length;do{if(0===a.avail_out&&(a.output=new tu.Buf8(u),a.next_out=0,a.avail_out=u),(s=yu.inflate(a,Gu.Z_NO_FLUSH))===Gu.Z_NEED_DICT&&c&&(s=yu.inflateSetDictionary(this.strm,c)),s===Gu.Z_BUF_ERROR&&!0===l&&(s=Gu.Z_OK,l=!1),s!==Gu.Z_STREAM_END&&s!==Gu.Z_OK)return this.onEnd(s),this.ended=!0,!1;a.next_out&&(0!==a.avail_out&&s!==Gu.Z_STREAM_END&&(0!==a.avail_in||o!==Gu.Z_FINISH&&o!==Gu.Z_SYNC_FLUSH)||("string"===this.options.to?(i=Ou(a.output,a.next_out),n=a.next_out-i,r=Ru(a.output,i),a.next_out=n,a.avail_out=u-n,n&&tu.arraySet(a.output,a.output,i,n,0),this.onData(r)):this.onData(tu.shrinkBuf(a.output,a.next_out)))),0===a.avail_in&&0===a.avail_out&&(l=!0)}while((a.avail_in>0||0===a.avail_out)&&s!==Gu.Z_STREAM_END);return s===Gu.Z_STREAM_END&&(o=Gu.Z_FINISH),o===Gu.Z_FINISH?(s=yu.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,s===Gu.Z_OK):o!==Gu.Z_SYNC_FLUSH||(this.onEnd(Gu.Z_OK),a.avail_out=0,!0)},wu.prototype.onData=function(e){this.chunks.push(e)},wu.prototype.onEnd=function(e){e===Gu.Z_OK&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=tu.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var $u={Inflate:wu,inflate:Fu,inflateRaw:function(e,t){return(t=t||{}).raw=!0,Fu(e,t)},ungzip:Fu},qu={};(0,tu.assign)(qu,$u,Gu);var xu=qu;class Vu{constructor(e){this._m=e,this._n="InflateModule",this._bLogForInflateOK=!1,this._bLogForInflateError=!1}inflate(e){const t=new Uint8Array(e).slice(4),s=Date.now();let o;try{o=xu.inflate(t,{to:"string"}),this._bLogForInflateOK||(this._bLogForInflateOK=!0,new Cn("inflateOK").end())}catch(r){if(this._bLogForInflateError)return;return this._bLogForInflateError=!0,void new Cn("inflateError").setMessage(r).end()}const i=t.length+4,n=o.length;return _e.d(`inflate ok. zipped:${i} unzipped:${n} compression ratio:${Math.round(100*(n-i)/n)}% cost:${Date.now()-s}`),o}reset(){_e.l(this._n+".reset"),this._bLogForInflateOK=!1,this._bLogForInflateError=!1}}class Bu{constructor(e){const t=new Cn("sdkConstruct");this._n="ModuleManager",this._isReady=!1,this._reason=nn.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(ms,new Vr(this,e)),this._moduleMap.set(ws,new Vu(this)),this._moduleMap.set(Os,new Ja(this)),this._moduleMap.set(As,new ka(this)),this._moduleMap.set(vs,new ja(this)),this._moduleMap.set(Rs,new qa(this)),this._moduleMap.set(Ss,new Aa(this)),this._moduleMap.set(Es,new Ga(this)),this._moduleMap.set(rs,new Br(this)),this._moduleMap.set(as,new aa(this)),this._moduleMap.set(us,new ua(this)),this._moduleMap.set(Ps,new ca(this)),this._moduleMap.set(cs,new xr(this)),this._moduleMap.set(ls,new Bn(this)),this._moduleMap.set(_s,new lr(this)),this._moduleMap.set(ds,new Nr(this)),this._moduleMap.set(hs,new Or(this)),this._moduleMap.set(gs,new Pr(this)),this._moduleMap.set(Ms,new Kr(this)),this._moduleMap.set(bs,new eu(this)),this._moduleMap.set(fs,new jr(this)),this._moduleMap.set(Is,new Zr(this)),this._moduleMap.set(Cs,new ta(this)),this._moduleMap.set(Ts,new sa(this)),this._moduleMap.set(ys,new la(this)),this._moduleMap.set(Ds,new da(this)),this._moduleMap.set(Ls,new Ua(this)),this._moduleMap.set(Ns,new Pa(this)),this._moduleMap.set(ps,new Ya(this)),this._moduleMap.set(Gs,new Xa(this)),this._moduleMap.set(Us,new Za(this)),this._moduleMap.set(ks,new Qa(this)),this._eventThrottleMap=new Map;const{instanceID:s,oversea:o,SDKAppID:i}=e,n=`instanceID:${s} SDKAppID:${i} host:${lt()} oversea:${o} inBrowser:${b} inMiniApp:${P} canIUseInflate:`+this.canIUseInflate()+` workerAvailable:${Q} UserAgent:${F}`;Cn.bindEventStatModule(this._moduleMap.get(fs)),t.setMessage(`${n} ${function(){let e="";if(P)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(),_e.i("SDK "+n),Fn.prototype._getErrorMessage=this.getErrorMessage.bind(this),this._readyList=void 0,this._ssoLogForReady=null,this._initReadyList()}_startTimer(){const e=this._moduleMap.get(vs),t=e.isWorkerEnabled();_e.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)),_e.l(`${this._n}._startMainThreadTimer seed:${this._checkTimer}`)}stopTimer(){const e=this._moduleMap.get(vs),t=e.isWorkerEnabled();_e.l(`${this._n}.stopTimer isWorkerEnabled:${t} seed:${this._checkTimer}`),t?e.stopWorkerTimer():this._stopMainThreadTimer()}_stopMainThreadTimer(){_e.l(this._n+"._stopMainThreadTimer"),this._checkTimer>0&&(clearInterval(this._checkTimer),this._checkTimer=-1,this._checkCount=0)}_stopMainThreadSocket(){_e.l(this._n+"._stopMainThreadSocket");const e=this._moduleMap.get(Ss);e.setIsWorkerEnabled(!0),e.reConnect()}_startMainThreadSocket(){_e.l(this._n+"._startMainThreadSocket");const e=this._moduleMap.get(Ss);e.setIsWorkerEnabled(!1),e.reConnect()}onWorkerTimerEnabled(){_e.l(this._n+".onWorkerTimerEnabled, disable main thread timer and socket"),this._stopMainThreadTimer(),this._stopMainThreadSocket()}onWorkerTimerDisabled(){_e.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._moduleMap.get(_s)],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;_e.w(`SDK is ready. cost ${t} ms`),this._startLoginTs=Date.now();const s=this._moduleMap.get(Is).getNetworkType(),o=this._ssoLogForReady.getStartTs()+ue;this._ssoLogForReady.setNetworkType(s).setMessage(t).start(o).end()}}login(){0===this._startLoginTs&&(le(),this._startLoginTs=Date.now(),this._startTimer(),this._moduleMap.get(Is).start(),this._ssoLogForReady=new Cn("sdkReady"),this._reason=nn.LOGGING_IN)}onLoginFailed(){this._startLoginTs=0}getOuterEmitterInstance(){return null===this._outerEmitter&&(this._outerEmitter=new ea,qn(this._outerEmitter),this._outerEmitter._emit=this._outerEmitter.emit,this._outerEmitter.emit=function(t,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}_getEventData(t){return t===e.CONVERSATION_LIST_UPDATED?this._moduleMap.get(_s).getLocalConversationList():t===e.FRIEND_LIST_UPDATED?this._moduleMap.get(ps).getLocalFriendList(!1):t===e.GROUP_LIST_UPDATED?this._moduleMap.get(ds).getLocalGroupList():t===e.TOTAL_UNREAD_MESSAGE_COUNT_UPDATED?this._moduleMap.get(_s).getTotalUnreadMessageCount():void 0}getInnerEmitterInstance(){return null===this._innerEmitter&&(this._innerEmitter=new ea,this._innerEmitter._emit=this._innerEmitter.emit,this._innerEmitter.emit=function(e,t){let s;s=Pe(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)}canIUseInflate(){return!!this._moduleMap.get(ws)}isReady(){return this._isReady}isIntl(){return this.getModule(ms).isIntl()}getNotReadyReason(){return this._reason}setNotReadyReason(e){this._reason=e}getErrorMessage(e,t,s){return this._moduleMap.get(bs).get({key:e,replacement1:t,replacement2:s,isIntl:this.isIntl()})}outputWarning(e,t,s){const o=this.getErrorMessage(e,t,s);o&&_e.w(o)}onError(t){const s=`code:${t.code} message:${t.message}`;_e.w("Oops! "+s);new Cn("error").setMessage(s).setNetworkType(this.getModule(Is).getNetworkType()).setLevel("error").end(),this.getOuterEmitterInstance().emit(e.ERROR,t)}restartTimer(){_e.l(this._n+".restartTimer"),this.stopTimer(),this._startTimer(),this.getModule(ds).restartPolling()}getTimerID(){const e=this._moduleMap.get(vs);return e.isWorkerEnabled()?e.getTimerID():this._checkTimer}getPollingTimerID(e){return this._moduleMap.get(ds).getPollingTimerID(e)}reset(){_e.l(this._n+".reset"),le();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 Hu{constructor(e){this._funcMap=new Map,this._m=e}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)}new Cn(o).setMessage("eventName:"+t).setMoreMessage(n.message).end()}}}}class Ku{constructor(e){const t={SDKAppID:e.SDKAppID,unlimitedAVChatRoom:e.unlimitedAVChatRoom||!1,scene:e.scene||"",oversea:e.oversea||!1,instanceID:ct(),devMode:e.devMode||!1,proxyServer:e.proxyServer||void 0,fileUploadProxy:e.fileUploadProxy||void 0,fileDownloadProxy:e.fileDownloadProxy||e.fileUploadProxy||void 0};this._m=new Bu(t),this._safetyCallbackFactory=new Hu(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._m.reset(),e))}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._m.stopTimer();this._getModule(vs).terminate();this._getModule(Ss).dealloc();const t=this._m.getOuterEmitterInstance(),s=this._getModule(ms);t.emit(e.SDK_DESTROY,{SDKAppID:s.getSDKAppID()})})}on(e,t,s){_e.d("on","eventName:"+e);this._m.getOuterEmitterInstance().on(e,this._safetyCallbackFactory.defense(e,t,s),s)}once(e,t,s){_e.d("once","eventName:"+e);this._m.getOuterEmitterInstance().once(e,this._safetyCallbackFactory.defenseOnce(e,t,s),s||this)}off(e,t,s,o){_e.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(we(e["tim-offline-push-plugin"])){this._getModule(ys).registerPlugin(e)}else{this._getModule(Gs).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 ->";yt()?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)}_e.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 Vn({code:nn.MESSAGE_MERGER_TYPE_INVALID});if(Lt(e.payload.downloadKey))return Vn({code:nn.MESSAGE_MERGER_KEY_INVALID});return this._getModule(as).downloadMergerMessage(e).catch(e=>Vn({code:nn.MESSAGE_MERGER_DOWNLOAD_FAIL}))}createForwardMessage(e){return this._getModule(as).createForwardMessage(e)}sendMessage(e,t){if(!(e instanceof bn))return Vn({code:nn.MESSAGE_SEND_NEED_MESSAGE_INSTANCE});return this._getModule(as).sendMessageInstance(e,t)}callExperimentalAPI(e,t){if("sendComboMessage"===e){return this._getModule(Ps).sendMessage(t)}if("handleGroupInvitation"===e){return this._getModule(ds).handleGroupInvitation(t)}if("isCommercialAbilityEnabled"===e){return this._getModule(Os).isFeatureEnabled(t)}if("isIntl"===e)return this.isIntl();if("sendTRTCCustomData"===e){return this._getModule(ks).sendTRTCCustomData(t)}return"getTimerID"===e?this._m.getTimerID():"getPollingTimerID"===e?this._m.getPollingTimerID(t):Vn({code:nn.INVALID_OPERATION})}revokeMessage(e){return this._getModule(as).revokeMessage(e)}resendMessage(e){return this._getModule(as).resendMessage(e)}deleteMessage(e){return this._getModule(as).deleteMessage(e)}translateText(e){return this._getModule(as).translateText(e)}setMessageExtensions(e,t){return this._getModule(us).setMessageExtensions(e,t)}getMessageExtensions(e){return this._getModule(us).getMessageExtensions(e)}deleteMessageExtensions(e,t){return this._getModule(us).deleteMessageExtensions(e,t)}modifyMessage(e){return this._getModule(as).modifyRemoteMessage(e)}getMessageList(e){return this._getModule(_s).getMessageList(e)}getMessageListHopping(e){return this._getModule(_s).getMessageListHopping(e)}sendMessageReadReceipt(e){return this._getModule(_s).sendReadReceipt(e)}getMessageReadReceiptList(e){return this._getModule(_s).getReadReceiptList(e)}getGroupMessageReadMemberList(e){return this._getModule(ds).getReadReceiptDetail(e)}findMessage(e){return this._getModule(_s).findMessage(e)}setMessageRead(e){return this._getModule(_s).setMessageRead(e)}getConversationList(e){return this._getModule(_s).getConversationList(e)}getConversationProfile(e){return this._getModule(_s).getConversationProfile(e)}deleteConversation(e){return this._getModule(_s).deleteConversation(e)}clearHistoryMessage(e){return this._getModule(_s).clearHistoryMessage(e)}pinConversation(e){return this._getModule(_s).pinConversation(e)}setAllMessageRead(e){return this._getModule(_s).setAllMessageRead(e)}setMessageRemindType(e){return this._getModule(_s).setMessageRemindType(e)}getTotalUnreadMessageCount(){return this._getModule(_s).getTotalUnreadMessageCount()}setConversationCustomData(e){return this._getModule(_s).setConversationCustomData(e)}markConversation(e){return this._getModule(_s).markConversation(e)}getConversationGroupList(){return this._getModule(_s).getConversationGroupList()}createConversationGroup(e){return this._getModule(_s).createConversationGroup(e)}deleteConversationGroup(e){return this._getModule(_s).deleteConversationGroup(e)}renameConversationGroup(e){return this._getModule(_s).renameConversationGroup(e)}addConversationsToGroup(e){return this._getModule(_s).addConversationsToGroup(e)}deleteConversationsFromGroup(e){return this._getModule(_s).deleteConversationsFromGroup(e)}getMyProfile(){return this._getModule(cs).getMyProfile()}getUserProfile(e){return this._getModule(cs).getUserProfile(e)}updateMyProfile(e){return this._getModule(cs).updateMyProfile(e)}getBlacklist(){return this._getModule(cs).getLocalBlacklist()}addToBlacklist(e){return this._getModule(cs).addBlacklist(e)}removeFromBlacklist(e){return this._getModule(cs).deleteBlacklist(e)}setSelfStatus(e){return this._getModule(cs).setSelfStatus(e)}getUserStatus(e){return this._getModule(cs).getUserStatus(e)}subscribeUserStatus(e){return this._getModule(cs).subscribeUserStatus(e)}unsubscribeUserStatus(e){return this._getModule(cs).unsubscribeUserStatus(e)}getFriendList(){const e=this._getModule(ps);return e?e.getLocalFriendList():Vn({code:nn.CANNOT_FIND_MODULE})}addFriend(e){const t=this._getModule(ps);return t?t.addFriend(e):Vn({code:nn.CANNOT_FIND_MODULE})}deleteFriend(e){const t=this._getModule(ps);return t?t.deleteFriend(e):Vn({code:nn.CANNOT_FIND_MODULE})}checkFriend(e){const t=this._getModule(ps);return t?t.checkFriend(e):Vn({code:nn.CANNOT_FIND_MODULE})}getFriendProfile(e){const t=this._getModule(ps);return t?t.getFriendProfile(e):Vn({code:nn.CANNOT_FIND_MODULE})}updateFriend(e){const t=this._getModule(ps);return t?t.updateFriend(e):Vn({code:nn.CANNOT_FIND_MODULE})}getFriendApplicationList(){const e=this._getModule(ps);return e?e.getLocalFriendApplicationList():Vn({code:nn.CANNOT_FIND_MODULE})}acceptFriendApplication(e){const t=this._getModule(ps);return t?t.acceptFriendApplication(e):Vn({code:nn.CANNOT_FIND_MODULE})}refuseFriendApplication(e){const t=this._getModule(ps);return t?t.refuseFriendApplication(e):Vn({code:nn.CANNOT_FIND_MODULE})}deleteFriendApplication(e){const t=this._getModule(ps);return t?t.deleteFriendApplication(e):Vn({code:nn.CANNOT_FIND_MODULE})}setFriendApplicationRead(){const e=this._getModule(ps);return e?e.setFriendApplicationRead():Vn({code:nn.CANNOT_FIND_MODULE})}getFriendGroupList(){const e=this._getModule(ps);return e?e.getLocalFriendGroupList():Vn({code:nn.CANNOT_FIND_MODULE})}createFriendGroup(e){const t=this._getModule(ps);return t?t.createFriendGroup(e):Vn({code:nn.CANNOT_FIND_MODULE})}deleteFriendGroup(e){const t=this._getModule(ps);return t?t.deleteFriendGroup(e):Vn({code:nn.CANNOT_FIND_MODULE})}addToFriendGroup(e){const t=this._getModule(ps);return t?t.addToFriendGroup(e):Vn({code:nn.CANNOT_FIND_MODULE})}removeFromFriendGroup(e){const t=this._getModule(ps);return t?t.removeFromFriendGroup(e):Vn({code:nn.CANNOT_FIND_MODULE})}renameFriendGroup(e){const t=this._getModule(ps);return t?t.renameFriendGroup(e):Vn({code:nn.CANNOT_FIND_MODULE})}getGroupList(e){return this._getModule(ds).getGroupList(e)}getGroupProfile(e){return this._getModule(ds).getGroupProfile(e)}createGroup(e){return this._getModule(ds).createGroup(e)}dismissGroup(e){return this._getModule(ds).dismissGroup(e)}updateGroupProfile(e){return this._getModule(ds).updateGroupProfile(e)}joinGroup(e){return this._getModule(ds).joinGroup(e)}quitGroup(e){return this._getModule(ds).quitGroup(e)}searchGroupByID(e){return this._getModule(ds).searchGroupByID(e)}getGroupOnlineMemberCount(e){return this._getModule(ds).getGroupOnlineMemberCount(e)}changeGroupOwner(e){return this._getModule(ds).changeGroupOwner(e)}getGroupApplicationList(){return this._getModule(ds).getGroupApplicationList()}handleGroupApplication(e){return this._getModule(ds).handleGroupApplication(e)}initGroupAttributes(e){return this._getModule(ds).initGroupAttributes(e)}setGroupAttributes(e){return this._getModule(ds).setGroupAttributes(e)}deleteGroupAttributes(e){return this._getModule(ds).deleteGroupAttributes(e)}getGroupAttributes(e){return this._getModule(ds).getGroupAttributes(e)}setGroupCounters(e){return this._getModule(ds).setGroupCounters(e)}increaseGroupCounter(e){return this._getModule(ds).increaseGroupCounter(e)}decreaseGroupCounter(e){return this._getModule(ds).decreaseGroupCounter(e)}getGroupCounters(e){return this._getModule(ds).getGroupCounters(e)}getGroupMemberList(e){return this._getModule(hs).getGroupMemberList(e)}getGroupMemberProfile(e){return this._getModule(hs).getGroupMemberProfile(e)}addGroupMember(e){return this._getModule(hs).addGroupMember(e)}deleteGroupMember(e){return this._getModule(hs).deleteGroupMember(e)}setGroupMemberMuteTime(e){return this._getModule(hs).setGroupMemberMuteTime(e)}setGroupMemberRole(e){return this._getModule(hs).setGroupMemberRole(e)}setGroupMemberNameCard(e){return this._getModule(hs).setGroupMemberNameCard(e)}setGroupMemberCustomField(e){return this._getModule(hs).setGroupMemberCustomField(e)}markGroupMemberList(e){return this._getModule(hs).markGroupMemberList(e)}getJoinedCommunityList(){return this._getModule(gs).getJoinedCommunityList()}createTopicInCommunity(e){return this._getModule(gs).createTopicInCommunity(e)}deleteTopicFromCommunity(e){return this._getModule(gs).deleteTopicFromCommunity(e)}updateTopicProfile(e){return this._getModule(gs).updateTopicProfile(e)}getTopicList(e){return this._getModule(gs).getTopicList(e)}}const Wu={login:1,logout:1,destroy:1,on:1,off:1,ready:1,setLogLevel:1,joinGroup:1,quitGroup:1,registerPlugin:1,getGroupOnlineMemberCount:1};function Yu(e,t){if(e.isReady()||1===Wu[t])return!0;const s=e.getNotReadyReason(),o={code:s,message:`${e.getErrorMessage(s)} | ${t} | ${e.getErrorMessage(nn.SDK_IS_NOT_READY)}`};return e.onError(o),o}const ju={},zu={};zu.create=function(t){let o=0;const{SDKAppID:i}=t;if(Ge(i))o=i;else if(o=parseInt(i),isNaN(i))return _e.e("TIM.create failed. Failed to parse the SDKAppID, please check the arguments"),null;if(o&&ju[o])return ju[o];_e.l("TIM.create");const n=new Ku({...t,SDKAppID:o});n.on(e.SDK_DESTROY,e=>{ju[e.data.SDKAppID]=null,delete ju[e.data.SDKAppID]});const r=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=Yu(e,o);return!0===i?s():Vn(i)})).use((function(e,t){if(!0===At(e,is[o],o))return t()})).use((function(t,s){return e[o].apply(e,t)})),i.run(t)}}),t}(n);return ju[o]=r,is.hookGetAPITips(n.getErrorMessage.bind(n)),_e.l("TIM.create ok"),r},zu.TYPES=t,zu.EVENT=e,zu.VERSION="2.27.6",_e.l("TIM.VERSION:"+zu.VERSION);export{zu as default};