@tencentcloud/lite-chat 1.6.2-beta.0 → 1.6.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/basic.es.js CHANGED
@@ -1 +1 @@
1
- class e{constructor(){this.listeners={}}on(e,t,s){this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].push({fn:t,context:s})}off(e,s,n){s&&(this.listeners[e]=null==(e=this.listeners[e])?void 0:e.filter(e=>{var t=e.fn===s,e=!n||e.context===n;return!(t&&e)}))}emit(e,...s){e=this.listeners[e];e&&e.forEach(e=>{var{fn:e,context:t}=e;e.apply(t,s)})}once(t,s,n){let i=(...e)=>{s.apply(n,e),this.off(t,i)};this.on(t,i)}}let t={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,DONUT_NATIVE_APP:19,NS_NATIVE_APP:20,RN_NATIVE_APP:21},s=["heartbeat.alive","im_open_status.wslogin","im_open_status.wslogout","group_open_long_polling_http_svc.get_msg","group_open_long_polling_http_noauth_svc.get_msg"];var n,d;!function(e){e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e[e.NONE=4]="NONE"}(n=n||{});let i="LiteChat",o={[n.DEBUG]:console.debug,[n.INFO]:console.info,[n.WARN]:console.warn,[n.ERROR]:console.error},r={[n.INFO]:4,[n.WARN]:5,[n.ERROR]:6},a=1e3,c=2,l=5e3,u=50;!function(e){e[e.CONV_DELETED=1]="CONV_DELETED",e[e.CONV_PINED=2]="CONV_PINED",e[e.CONV_UNPINED=3]="CONV_UNPINED",e[e.CONV_MARK_UPDATED=4]="CONV_MARK_UPDATED",e[e.CONV_GROUP_ADDED=5]="CONV_GROUP_ADDED",e[e.CONV_GROUP_DELETED=6]="CONV_GROUP_DELETED",e[e.CONV_GROUP_UPDATED=7]="CONV_GROUP_UPDATED"}(d=d||{});var _,f,h=Object.freeze({__proto__:null,CONSOLE_METHOD:o,CloudConfigReportLevelMap:r,get ConvModifyPushType(){return d},DEFAULT_GLOBAL_MAX_TOTAL_COUNT:u,DEFAULT_GLOBAL_THROTTLE_TIME:l,DEFAULT_SINGLE_MAX_TOTAL_COUNT:c,DEFAULT_SINGLE_THROTTLE_TIME:a,ENUM_PLATFORM:t,IS_TOPIC_MESSAGE:2,get LogLevel(){return n},NOT_NEED_CRC_SERVCMD:s,SDK_NAME:i});!function(e){e.BUSINESS_COMMAND="business_command",e.C2C_REALTIME_MESSAGE="c2c_realtime_message",e.C2C_MESSAGE_MODIFIED="c2c_message_modified",e.C2C_REVOKED_MESSAGE="c2c_message_revoked",e.GROUP_REALTIME_MESSAGE="group_realtime_message",e.GROUP_MESSAGE_MODIFIED="group_message_modified",e.GROUP_MESSAGE_REVOKED="group_message_revoked",e.C2C_MESSAGE_READ_RECEIPT="c2c_message_read_receipt",e.MESSAGE_REACTION_UPDATED="message_reaction_updated",e.MESSAGE_REACTION_UPDATED_SYNC="message_reaction_updated_sync",e.GROUP_AT_TIPS="group_at_tips",e.USER_STATUS_UPDATE="user_status_update",e.FRIEND_LIST_MODIFIED="friend_list_modified",e.PROFILE_MODIFIED="profile_modified",e.CONV_MODIFIED="conversation_modified",e.GROUP_TIPS_NOTIFICATION="group_tips_notification",e.GROUP_MESSAGE_READ_RECEIPT="group_message_read_receipt",e.GROUP_MESSAGE_READ_SYNC="group_message_read_sync",e.GROUP_SYSTEM_NOTIFICATION="group_system_notification",e.C2C_MESSAGE_PEER_READ="c2c_message_peer_read",e.C2C_MESSAGE_READ_SYNC="c2c_message_read_sync",e.C2C_REMIND_TYPE_SYNC="c2c_remind_type_sync",e.FOLLOW_LIST_UPDATED="follow_list_updated",e.MESSAGE_EXTENSIONS_UPDATED="message_extensions_updated",e.ALL_MESSAGE_READ="all_message_read",e.CONVERSATION_MARK_UPDATED="conversation_mark_updated",e.CONVERSATION_GROUP_ADD="conversation_group_add",e.CONVERSATION_GROUP_DELETED="conversation_group_deleted",e.CONVERSATION_GROUP_UPDATED="conversation_group_updated",e.ALL_RECEIVE_MESSAGE_OPTION="all_receive_message_option",e.TOPIC_AT_TIPS="topic_at_tips",e.TOPIC_TIPS_NOTIFICATION="topic_tips_notification",e.TOPIC_SYSTEM_NOTIFICATION="topic_system_notification",e.TOPIC_MESSAGE_READ_SYNC="topic_message_read_sync",e.TOPIC_LATEST_MESSAGE="topic_latest_message",e.GROUP_MESSAGE_PINNED="group_message_pinned"}(_=_||{});let g=[16,17];function p(e){let t,s=[];return null!=(t=null==e?void 0:e.GroupTips)&&t.forEach(e=>{2===e.GroupInfo.MillionGroupFlag?s.push(_.TOPIC_TIPS_NOTIFICATION):g.includes(null==(e=null==e?void 0:e.MsgBody)?void 0:e.OpType)?s.push(_.GROUP_MESSAGE_PINNED):s.push(_.GROUP_TIPS_NOTIFICATION)}),s}let E=[{conditions:[{type:"event",value:100}],subType:_.BUSINESS_COMMAND},{conditions:[{type:"event",value:24}],subType:_.ALL_RECEIVE_MESSAGE_OPTION},{conditions:[{type:"event",value:26}],subType:_.TOPIC_LATEST_MESSAGE},{conditions:[{type:"hasKey",value:"C2cMsgArray"}],subType:_.C2C_REALTIME_MESSAGE},{conditions:[{type:"hasKey",value:"C2cMsgModNotifys"}],subType:_.C2C_MESSAGE_MODIFIED},{conditions:[{type:"hasKey",value:"ProfileDataMod"}],subType:_.PROFILE_MODIFIED},{conditions:[{type:"hasKey",value:"UserStatusList"}],subType:_.USER_STATUS_UPDATE},{conditions:[{type:"hasKey",value:"FriendListMod"}],subType:_.FRIEND_LIST_MODIFIED},{conditions:[{type:"hasKey",value:"GroupMsgArray"}],subType:_.GROUP_REALTIME_MESSAGE},{conditions:[{type:"hasKey",value:"GroupMsgModNotifys"}],subType:_.GROUP_MESSAGE_MODIFIED},{conditions:[{type:"hasKey",value:"C2cNotifyMsgArray"}],subTypeParser:function(e){let t,s=[];return null!=(t=null==e?void 0:e.C2cNotifyMsgArray)&&t.forEach(e=>{e.WithdrawC2cMsgNotify&&s.push(_.C2C_REVOKED_MESSAGE),e.C2cReadedReceipt&&s.push(_.C2C_MESSAGE_PEER_READ),e.ReadC2cMsgNotify&&s.push(_.C2C_MESSAGE_READ_SYNC),e.MuteNotificationsSync&&s.push(_.C2C_REMIND_TYPE_SYNC)}),s}},{conditions:[{type:"hasKey",value:"GroupTips"},{type:"event",value:4}],subTypeParser:p},{conditions:[{type:"hasKey",value:"GroupTips"},{type:"event",value:5}],subTypeParser:function(e){let t,s=[];return null!=(t=null==e?void 0:e.GroupTips)&&t.forEach(e=>{Array.isArray(e.MsgBody.GroupWithdrawInfoArray)?s.push(_.GROUP_MESSAGE_REVOKED):Array.isArray(e.MsgBody.GroupMsgReceiptList)?s.push(_.GROUP_MESSAGE_READ_RECEIPT):Array.isArray(e.MsgBody.GroupReadInfoArray)?e.MsgBody.GroupReadInfoArray[0].TopicId?s.push(_.TOPIC_MESSAGE_READ_SYNC):s.push(_.GROUP_MESSAGE_READ_SYNC):2===e.GroupInfo.MillionGroupFlag?s.push(_.TOPIC_SYSTEM_NOTIFICATION):s.push(_.GROUP_SYSTEM_NOTIFICATION)}),s}},{conditions:[{type:"hasKey",value:"GroupTips"},{type:"event",value:6}],subTypeParser:p},{conditions:[{type:"hasKey",value:"GroupTips"},{type:"event",value:12}],subTypeParser:function(e){let t,s=[];return null!=(t=null==e?void 0:e.GroupTips)&&t.forEach(e=>{var e=e["GroupAtTips"]["TopicId"];e?s.push(_.TOPIC_AT_TIPS):s.push(_.GROUP_AT_TIPS)}),s}},{conditions:[{type:"hasKey",value:"RecentContactMod"}],subTypeParser:function(e){let t,s=[];return null!=(t=null==e?void 0:e.RecentContactMod)&&t.forEach(e=>{switch(e.PushType){case d.CONV_MARK_UPDATED:s.push(_.CONVERSATION_MARK_UPDATED);break;case d.CONV_GROUP_ADDED:s.push(_.CONVERSATION_GROUP_ADD);break;case d.CONV_GROUP_DELETED:s.push(_.CONVERSATION_GROUP_DELETED);break;case d.CONV_GROUP_UPDATED:s.push(_.CONVERSATION_GROUP_UPDATED);break;default:s.push(_.CONV_MODIFIED)}}),s}},{conditions:[{type:"hasKey",value:"MsgReactionNotifyList"}],subType:_.MESSAGE_REACTION_UPDATED},{conditions:[{type:"hasKey",value:"MsgReactionNotify"}],subType:_.MESSAGE_REACTION_UPDATED_SYNC},{conditions:[{type:"hasKey",value:"C2cMsgInfo"}],subType:_.C2C_MESSAGE_READ_RECEIPT},{conditions:[{type:"hasKey",value:"FollowChangeList"}],subType:_.FOLLOW_LIST_UPDATED},{conditions:[{type:"hasKey",value:"MsgExtensionNotify"}],subType:_.MESSAGE_EXTENSIONS_UPDATED},{conditions:[{type:"hasKey",value:"C2CReadAllMsg"}],subType:_.ALL_MESSAGE_READ}];function m(n){let e,t=Array.isArray(null==(e=null==n?void 0:n.body)?void 0:e.EventArray)?n.body.EventArray:[],i=[];return t.forEach(t=>{t.Flag=n.body.Flag;var e=E.find(e=>e.conditions.every(e=>{switch(e.type){case"event":return t.Event===e.value;case"hasKey":return Object.prototype.hasOwnProperty.call(t,e.value);default:return!1}}));if(!e)return null;let s=[];"function"==typeof e.subTypeParser?s=e.subTypeParser(t):e.subType&&(s=e.subType),Array.isArray(s)?s.forEach(e=>{i.push({type:f.SERVER_PUSH_MESSAGE+":"+e,data:t})}):i.push({type:f.SERVER_PUSH_MESSAGE+":"+s,data:t})}),i}!function(e){e.SERVER_PUSH_MESSAGE="im_open_push.msg_push",e.SERVER_PUSH_MESSAGE_MULTIPLE="im_open_push.multi_msg_push_ws",e.ERROR="error"}(f=f||{});let S={[f.SERVER_PUSH_MESSAGE]:m,[f.SERVER_PUSH_MESSAGE_MULTIPLE]:m,[f.ERROR]:function(e){var t=e["errorCode"];return[{type:"error:"+t,data:e}]}},v=new class{constructor(){this._outerEventEmitter=null,this._innerEventEmitter=null,this._outerEventEmitter=new e,this._innerEventEmitter=new e,this.InnerEventSubType=_}subscribeInnerEvent(s,n,i,r){var o,t;if(["string","number"].includes(typeof n)){let e=n,t=i;null!=(o=this._innerEventEmitter)&&o.on(s+":"+e,t,r)}else{let e=n;null!=(t=this._innerEventEmitter)&&t.on(s,e,i)}}emitInnerEvent(t,s){var e;if(null!=(e=this._innerEventEmitter)&&e.emit(t,s),Object.keys(S).includes(t)){let e=null==(t=S[t])?void 0:t.call(S,s);null!=e&&e.forEach(e=>{var t;e&&null!=(t=this._innerEventEmitter)&&t.emit(e.type,e.data)})}}unSubscribeInnerEvent(s,n,i,r){var o,t;if(["string","number"].includes(typeof n)){let e=n,t=i;null!=(o=this._innerEventEmitter)&&o.off(s+":"+e,t,r)}else{let e=n;null!=(t=this._innerEventEmitter)&&t.off(s,e,i)}}subscribeOuterEvent(e,t,s){var n;null!=(n=this._outerEventEmitter)&&n.on(e,t,s)}unSubscribeOuterEvent(e,t,s){var n;null!=(n=this._outerEventEmitter)&&n.off(e,t,s)}emitOuterEvent(e,t){var s;null!=(s=this._outerEventEmitter)&&s.emit(e,t)}getOuterEventEmitter(){return this._outerEventEmitter}rest(){this._outerEventEmitter=null,this._innerEventEmitter=null}};function I(e,t){var s={};for(i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(s[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var n=0,i=Object.getOwnPropertySymbols(e);n<i.length;n++)t.indexOf(i[n])<0&&Object.prototype.propertyIsEnumerable.call(e,i[n])&&(s[i[n]]=e[i[n]]);return s}function C(e,o,a,l){return new(a=a||Promise)(function(s,t){function n(e){try{r(l.next(e))}catch(e){t(e)}}function i(e){try{r(l.throw(e))}catch(e){t(e)}}function r(e){var t;e.done?s(e.value):((t=e.value)instanceof a?t:new a(function(e){e(t)})).then(n,i)}r((l=l.apply(e,o||[])).next())})}let T=e=>void 0===e,M=e=>"string"==typeof e,O=e=>{return null==(e=Object.prototype.toString.call(e).match(/^\[object (.*)\]$/))?void 0:e[1].toLowerCase()},y=e=>"function"==typeof Array.isArray?Array.isArray(e):"array"===O(e),A=e=>null!==e&&"object"==typeof e,N=e=>y(e)||A(e),R=e=>{return"string"==typeof e&&(e=e[0],!/[^a-zA-Z0-9]/.test(e))},D=e=>{if("object"!=typeof e||null===e)return!1;e=Object.getPrototypeOf(e);if(null===e)return!0;let t=e;for(;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return e===t};function P(e=99999999){return Math.round(Math.random()*e)}let b=(s,n,i,r)=>{if(!N(s)||!N(n))return 0;let o=0;var a,l=Object.keys(n);for(let e=0,t=l.length;e<t;e++)if(a=l[e],!(T(n[a])||i&&i.includes(a)))if(N(s[a])&&N(n[a]))o+=b(s[a],n[a],i,r);else{if(r&&r.includes(n[a]))continue;s[a]!==n[a]&&(s[a]=n[a],o+=1)}return o};function w(s){let n,i,r=s,o="";for(let e=0,t=(r=s.length%8!=0?"0".repeat(8-s.length%8)+s:r)["length"];e<t;e+=8)n=parseInt(r.slice(e,e+4),2),i=parseInt(r.slice(e+4,e+8),2),o+=base16Map.get(n)+base16Map.get(i);return o}let L="undefined"!=typeof wx&&"function"==typeof wx.getSystemInfoSync&&("mac"===wx.getSystemInfoSync().platform||"windows"===wx.getSystemInfoSync().platform),k="undefined"!=typeof wx&&"function"==typeof wx.getSystemInfoSync&&Boolean(wx.getSystemInfoSync().fontSizeSetting)||L,U=k&&"function"==typeof wx.createGamePortal,G="undefined"!=typeof qq&&"function"==typeof qq.getSystemInfoSync&&Boolean(qq.getSystemInfoSync().fontSizeSetting),F="undefined"!=typeof tt&&"function"==typeof tt.getSystemInfoSync&&Boolean(tt.getSystemInfoSync().fontSizeSetting),B="undefined"!=typeof swan&&"function"==typeof swan.getSystemInfoSync&&Boolean(swan.getSystemInfoSync().fontSizeSetting),x="undefined"!=typeof my&&"function"==typeof my.getSystemInfoSync&&Boolean(my.getSystemInfoSync().fontSizeSetting),V="undefined"!=typeof jd&&"function"==typeof jd.getSystemInfoSync,$="undefined"!=typeof uni&&"undefined"==typeof window&&"function"==typeof uni.requireNativePlugin,q=k&&"object"==typeof wx.miniapp,W="undefined"!=typeof uni,Y=k||G||F||B||x||$||V,K="undefined"==typeof window&&!Y&&"undefined"!=typeof global&&void 0!==global.NativeScriptGlobals,H="undefined"!=typeof global&&(void 0!==global.nativeModuleProxy||void 0!==global.ReactNative),j="undefined"!=typeof wx&&"function"==typeof wx.getAccountInfoSync&&Boolean(wx.getAccountInfoSync().plugin),z="undefined"!=typeof uni?!Y:"undefined"!=typeof window&&!Y&&!H,Z=G?qq:F?tt:B?swan:x?my:k?wx:$?uni:V?jd:{},X=z&&window&&window.navigator&&window.navigator.userAgent||"",J=/(micromessenger|webbrowser)/i.test(X),Q=function(){let e="WEB";return J?e="WEB":G?e="QQ_MP":F?e="TT_MP":B?e="BAIDU_MP":x?e="ALI_MP":k?e=q?"DONUT_NATIVE_APP":"WX_MP":$?e="UNI_NATIVE_APP":K?e="NS_NATIVE_APP":H&&(e="RN_NATIVE_APP"),t[e]}(),ee=/iPad/i.test(X),te=/iPhone/i.test(X)&&!ee,se=/iPod/i.test(X),ne=te||ee||se,ie=function(){var e=X.match(/OS (\d+)_/i);return e&&e[1]?e[1]:null}(),oe=/Android/i.test(X),re=function(){var e,t,s=X.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);return s?(e=s[1]&&parseFloat(s[1]),t=s[2]&&parseFloat(s[2]),e&&t?parseFloat(s[1]+"."+s[2]):e||null):null}(),ae=/Firefox/i.test(X),ce=/Edge/i.test(X),le=!ce&&/Chrome/i.test(X),ue=/MSIE/.test(X)||-1<X.indexOf("Trident")&&-1<X.indexOf("rv:11.0"),de=function(){var e=/MSIE\s(\d+)\.\d/.exec(X);let t=e&&parseFloat(e[1]);return t=!t&&/Trident\/7.0/i.test(X)&&/rv:11.0/.test(X)?11:t}(),_e=/Safari/i.test(X)&&!le&&!oe&&!ce,he=/Windows/i.test(X),ge=/MAC OS X/i.test(X),pe=z&&"undefined"!=typeof Worker&&!ue,Ee=oe||ne,fe=z&&void 0!==window.tencent_cloud_im_csig_flutter_for_web_25F_cy,me=function(){var e;return"undefined"!=typeof window&&void 0!==window.navigator&&(e=window.navigator["standalone"],!(!ne||e||_e))}();function Se(){let e="unknown";if(ge&&(e="mac"),he&&(e="windows"),ne&&(e="ios"),oe&&(e="android"),Y)try{var t=Z.getSystemInfoSync()["platform"];void 0!==t&&(e=t)}catch(e){console.error(e)}return e}let ve=2800,Ie=2801,Ce=3e3,Te="application/x-www-form-urlencoded;charset=UTF-8";function Me(e){return C(this,arguments,void 0,function*({method:i,url:r,data:o,timeout:a=Ce}){return new Promise(Y?(t,e)=>{Z.request({url:r,data:o,method:i,timeout:a,header:{"content-type":Te},success:e=>t(e.data),fail:()=>e(new Error(`{"message":"Network error","code":${ve}}`))})}:(t,e)=>{let s=new XMLHttpRequest,n=setTimeout(()=>{s.abort(),e(new Error(`{"message":"Request timeout","code":${Ie}}`))},a);s.onreadystatechange=function(){if(4===s.readyState)if(clearTimeout(n),200===s.status||304===s.status)try{t(s.responseText?JSON.parse(s.responseText):null)}catch(e){t(s.responseText)}else e(new Error(`{"message":"Network error","code":${ve}}`))},s.open(i,r,!0),s.setRequestHeader("Content-type",Te),s.send(o||null)})})}function Oe(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(D(e)){for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0}return("[object Map]"===Object.prototype.toString.call(e)||"[object Set]"===Object.prototype.toString.call(e)||"[object File]"===Object.prototype.toString.call(e))&&0===e.size}function ye(n){if(null===n||"object"!=typeof n)return n;if(n instanceof Date)return new Date(n.getTime());if(n instanceof RegExp)return new RegExp(n.source,n.flags);if(n instanceof Map){let s=new Map;return n.forEach((e,t)=>{s.set(ye(t),ye(e))}),s}if(n instanceof Set){let t=new Set;return n.forEach(e=>{t.add(ye(e))}),t}if(Array.isArray(n))return n.map(e=>ye(e));let e=Object.getPrototypeOf(n),s=Object.create(e);return[...Object.getOwnPropertyNames(n),...Object.getOwnPropertySymbols(n)].forEach(e=>{var t=Object.getOwnPropertyDescriptor(n,e);t&&(t.get||t.set?Object.defineProperty(s,e,t):s[e]=ye(n[e]))}),s}function Ae(e,s,t){let n=new WeakSet;try{return JSON.stringify(e,(e,t)=>{if(void 0===(t=s?s(e,t):t))return"undefined";if(null===t)return null;if(Number.isNaN(t))return"NaN";if(t===1/0)return"Infinity";if(t===-1/0)return"-Infinity";if("function"==typeof t)return`[Function: ${t.name||"anonymous"}]`;if("symbol"==typeof t)return t.toString();if("bigint"==typeof t)return t.toString()+"n";if("object"==typeof t&&null!==t){if(n.has(t))return"[Circular]";n.add(t)}return t instanceof Date?t.toISOString():t instanceof Error?{name:t.name,message:t.message,stack:t.stack}:t instanceof Map?{dataType:"Map",value:Array.from(t.entries())}:t instanceof Set?{dataType:"Set",value:Array.from(t.values())}:t},t)}catch(e){return console.error("Failed to stringify:",e),""}}function Ne(){let s,n;return{promise:new Promise((e,t)=>{s=e,n=t}),resolve:s,reject:n}}var Re=Object.freeze({__proto__:null,ANDROID_VERSION:re,IE_VERSION:de,IN_ALIPAY_MINI_APP:x,IN_BAIDU_MINI_APP:B,IN_BROWSER:z,IN_DONUT_NATIVE_APP:q,IN_JD_MINI_APP:V,IN_MINI_APP:Y,IN_NS_NATIVE_APP:K,IN_QQ_MINI_APP:G,IN_RN_APP:H,IN_TT_MINI_APP:F,IN_UNI_APP:W,IN_UNI_NATIVE_APP:$,IN_WX_MINI_APP:k,IN_WX_MINI_APP_DESK:L,IN_WX_MINI_GAME:U,IN_WX_MINI_PLUGIN:j,IOS_VERSION:ie,IS_ANDROID:oe,IS_CHROME:le,IS_EDGE:ce,IS_FIREFOX:ae,IS_IE:ue,IS_IOS:ne,IS_IPAD:ee,IS_IPHONE:te,IS_IPOD:se,IS_MAC:ge,IS_SAFARI:_e,IS_WECHAT:J,IS_WIN:he,IS_WORKER_AVAILABLE:pe,MINI_APP_NAMESPACE:Z,USER_AGENT:X,base16EncodeBinaryString:w,deepCopyWithMethods:ye,deepMerge:b,generatePromise:Ne,getPlatformType:Se,getType:O,httpRequest:Me,isArray:y,isArrayOrObject:N,isEmpty:Oe,isFlutterWeb:fe,isH5:Ee,isIOSWebView:me,isNumber:e=>null!==e&&("number"==typeof e&&!Number.isNaN(+e)||"object"==typeof e&&e.constructor===Number),isObject:A,isPlainObject:D,isString:M,isUndefined:T,isValidRequestKey:R,platform:Q,randomInt:P,randomString:function(){let t="";for(let e=32;0<e;--e)t+="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[Math.floor(62*Math.random())];return t},safeStringify:Ae});class De{constructor(){this._socket=null}connectSocket(e){return this._socket=new WebSocket(e),this._socket}send(e){var t;try{null!=(t=this._socket)&&t.send(e)}catch(e){null!=(t=this._onSendFail)&&t.call(this,e)}}bindSocketHandlers(e){var{onOpen:e,onMessage:t,onClose:s,onError:n,onSendFail:i}=e;this._socket&&(this._socket.binaryType="arraybuffer",this._socket.onopen=e,this._socket.onmessage=t,this._socket.onclose=s,this._socket.onerror=n,this._onSendFail=i)}unbindSocketHandlers(){this._socket&&(this._socket.onopen=null,this._socket.onmessage=null,this._socket.onclose=null,this._socket.onerror=null)}disconnect(){this._socket&&(this._socket.close(),this._socket=null)}}class Pe{connectSocket(e){return this._socket=Z.connectSocket({url:e,header:{"content-type":"application/json"},complete:()=>{}}),this._socket}send(e){var t;null!=(t=this._socket)&&t.send({data:e,fail:this._onSendFail})}bindSocketHandlers(e){var{onOpen:e,onMessage:t,onClose:s,onError:n,onSendFail:i}=e;this._socket.onClose(s),this._socket.onOpen(e),this._socket.onMessage(t),this._socket.onError(n),this._onSendFail=i}unbindSocketHandlers(){this._socket&&(this._socket.onClose(()=>{}),this._socket.onOpen(()=>{}),this._socket.onMessage(()=>{}),this._socket.onError(()=>{}))}disconnect(){this._socket&&(this._socket.close(),this._socket=null)}}let be="CONNECT",we="SEND",Le="DISCONNECT",ke="OPEN",Ue="MESSAGE",Ge="CLOSE",Fe="ERROR",Be="SEND_FAIL";class xe{constructor(){this._worker=null,this._blobUrl=null}connectSocket(e){var t=new Blob(["\n let _socket = null;\n\n self.onmessage = (event) => {\n const { type, url, data } = event.data;\n\n switch (type) {\n case 'CONNECT':\n connectSocket(url);\n break;\n case 'SEND':\n send(data);\n break;\n case 'DISCONNECT':\n disconnect();\n break;\n }\n };\n\n function connectSocket(url) {\n _socket = new WebSocket(url);\n _socket.binaryType = 'arraybuffer';\n bindSocketHandlers();\n return _socket;\n }\n\n function send(packet) {\n try {\n _socket?.send(packet);\n } catch (error) {\n self.postMessage({\n type: 'SEND_FAIL', \n error: {\n message: error.message,\n name: error.name,\n },\n });\n }\n }\n\n function bindSocketHandlers() {\n if (_socket) {\n _socket.onopen = (event) => {\n self.postMessage({\n type: 'OPEN',\n data: {\n type: event.type,\n timeStamp: event.timeStamp,\n },\n });\n };\n\n _socket.onmessage = (event) => {\n self.postMessage({ \n type: 'MESSAGE',\n data: event.data,\n });\n };\n\n _socket.onclose = (event) => {\n self.postMessage({ \n type: 'CLOSE', \n data: { \n code: event.code,\n reason: event.reason,\n timeStamp: event.timeStamp,\n },\n });\n };\n\n _socket.onerror = (error) => {\n self.postMessage({\n type: 'ERROR',\n data: {\n message: error.message,\n name: error.name\n },\n });\n };\n }\n }\n\n function unbindSocketHandlers() {\n if (_socket) {\n _socket.onopen = null;\n _socket.onmessage = null;\n _socket.onclose = null;\n _socket.onerror = null;\n }\n }\n\n function disconnect() {\n if (_socket) {\n _socket.close();\n _socket = null;\n }\n }\n"],{type:"application/javascript"});this._worker=new Worker(URL.createObjectURL(t)),this._worker.postMessage({type:be,url:e})}send(e){var t;try{null!=(t=this._worker)&&t.postMessage({type:we,data:e})}catch(e){null!=(t=this._onSendFail)&&t.call(this,e)}}bindSocketHandlers(e){var{onOpen:t,onMessage:n,onClose:i,onError:r,onSendFail:o}=e;if(this._worker){let s={[ke]:t,[Ue]:n,[Ge]:i,[Fe]:r,[Be]:o};this._onSendFail=o,this._worker.onmessage=e=>{var t=((null==e?void 0:e.data)||{})["type"];"function"==typeof s[t]&&null!=(t=s[t])&&t.call(s,null==e?void 0:e.data)}}}unbindSocketHandlers(){this._worker&&(this._worker.onmessage=null)}disconnect(){this._worker&&(this._worker.postMessage({type:Le}),this._worker.terminate(),this._worker=null),this._blobUrl&&(URL.revokeObjectURL(this._blobUrl),this._blobUrl=null)}}var Ve,$e=new class{constructor(){this._store=new Map}get(e){return this._store.get(e)}getStorage(e){return Y?x?my.getStorageSync({key:e}).data:Z.getStorageSync(e):this._canUseLocalStorage()?localStorage.getItem(e):{}}set(e,t){var s=this._store.get(e)||{};t instanceof Map?this._store.set(e,t):this._store.set(e,Object.assign(Object.assign({},s),t))}setStorage(e,t){Y?x?my.setStorageSync({key:e,data:JSON.stringify(t)}):Z.setStorageSync(e,JSON.stringify(t)):this._canUseLocalStorage()&&localStorage.setItem(e,JSON.stringify(t))}clear(e){"string"==typeof e?this._store.set(e,{}):this._store.clear()}clearLocalStorage(e){this._canUseLocalStorage()&&("string"==typeof e?localStorage.setItem(e,""):localStorage.clear())}reset(){this.clear()}_canUseLocalStorage(){return"undefined"!=typeof window&&navigator&&navigator.cookieEnabled&&localStorage}};!function(e){e[e.CONNECTED=0]="CONNECTED",e[e.CONNECTING=1]="CONNECTING",e[e.DISCONNECTED=2]="DISCONNECTED"}(Ve=Ve||{});class qe{constructor(t){this._url="",this._readyState=Ve.DISCONNECTED,this._url=t,this._id=P(),this._emitter=new e,k||$?this._socket=new Pe:this._canUseWebWorker()?this._socket=new xe:this._socket=new De,this.connect()}connect(){this.doOpen(),this._bindSocketHandlers()}doOpen(){[Ve.CONNECTED,Ve.CONNECTING].includes(this._readyState)||(this._readyState=Ve.CONNECTING,this._ws=this._socket.connectSocket(this._url))}send(e){this._readyState!==Ve.CONNECTED?this.reconnect():this._socket.send(e)}reconnect(){[Ve.CONNECTED,Ve.CONNECTING].includes(this._readyState)||(this.disconnect(),this.doOpen())}getId(){return this._id}on(e,t,s){this._emitter.on(e,t,s)}off(e,t,s){this._emitter.off(e,t,s)}isConnected(){return this._readyState===Ve.CONNECTED}disconnect(){this._readyState=Ve.DISCONNECTED,this._unbindSocketHandlers(),this._socket.disconnect()}_onOpen(e){this._readyState===Ve.CONNECTING&&(this._readyState=Ve.CONNECTED,this._emitter.emit("connect",{socketId:this._id,event:e}))}_onMessage(e){this._emitter.emit("message",e)}_onClose(e){this._readyState=Ve.DISCONNECTED,this._emitter.emit("close",{socketId:this._id,event:e})}_onError(e){this._readyState=Ve.DISCONNECTED,this._emitter.emit("error",{socketId:this._id,error:e})}_onSendFail(e){this._readyState=Ve.DISCONNECTED,this._emitter.emit("sendFail",{socketId:this._id,error:e})}_bindSocketHandlers(){this._socket.bindSocketHandlers({onOpen:this._onOpen.bind(this),onMessage:this._onMessage.bind(this),onClose:this._onClose.bind(this),onError:this._onError.bind(this),onSendFail:this._onSendFail.bind(this)})}_unbindSocketHandlers(){this._socket.unbindSocketHandlers()}_canUseWebWorker(){var e=$e.get("cloudConfig")||{};return(T(e.isWorkerEnabled)||"1"===e.isWorkerEnabled)&&pe}}let We="CHINA",Ye="OVERSEA",Ke="SINGAPORE",He="KOREA",je="GERMANY",ze="IND",Ze="JPN",Xe="USA",Je="INDONESIA",Qe={TEST:{CHINA:{DEFAULT:"wss://wss-dev.tim.qq.com"},OVERSEA:{DEFAULT:"wss://wss-dev.tim.qq.com"},SINGAPORE:{DEFAULT:"wss://wsssgp-dev.im.qcloud.com"},KOREA:{DEFAULT:"wss://wsskr-dev.im.qcloud.com"},GERMANY:{DEFAULT:"wss://wssger-dev.im.qcloud.com"},IND:{DEFAULT:"wss://wssind-dev.im.qcloud.com"},JPN:{DEFAULT:"wss://wssjpn-dev.im.qcloud.com"},USA:{DEFAULT:"wss://wssusa-dev.im.qcloud.com"},INDONESIA:{DEFAULT:"wss://wssidn-dev.im.qcloud.com"}},PRODUCTION:{CHINA:{INITIAL:"wss://*w4c.my-imcloud.com",DEFAULT:"wss://wss.im.qcloud.com",IPV6:"wss://wssv6.im.qcloud.com",BACKUP:"wss://wss.tim.qq.com",BACKUP_WEB_ONLY:"wss://*w4c.my-cpaas.com",BACKUP_CN:"wss://wss.im.tencent.cn",STAT:"https://events.im.qcloud.com",ANYCAST:"wss://162.14.13.203"},OVERSEA:{INITIAL:"wss://*w4c.my-imcloud.com",DEFAULT:"wss://wss.im.qcloud.com",IPV6:"wss://wssv6.im.qcloud.com",BACKUP:"wss://wss.my-imcloud.com",BACKUP_WEB_ONLY:"wss://*w4c.my-cpaas.com",BACKUP_CN:"wss://wss.im.tencent.cn",STAT:"https://api.my-imcloud.com"},SINGAPORE:{INITIAL:"wss://*w4s.my-imcloud.com",DEFAULT:"wss://wsssgp.im.qcloud.com",IPV6:"wss://wsssgpv6.im.qcloud.com",BACKUP:"wss://wsssgp.my-imcloud.com",BACKUP_WEB_ONLY:"wss://*w4s.my-cpaas.com",STAT:"https://apisgp.my-imcloud.com",ANYCAST:"wss://162.14.19.159"},KOREA:{INITIAL:"wss://*w4k.my-imcloud.com",DEFAULT:"wss://wsskr.im.qcloud.com",IPV6:"wss://wsskrv6.im.qcloud.com",BACKUP:"wss://wsskr.my-imcloud.com",BACKUP_WEB_ONLY:"wss://*w4k.my-cpaas.com",STAT:"https://apikr.my-imcloud.com",ANYCAST:"wss://162.14.13.104"},GERMANY:{INITIAL:"wss://*w4g.my-imcloud.com",DEFAULT:"wss://wssger.im.qcloud.com",IPV6:"wss://wssgerv6.im.qcloud.com",BACKUP:"wss://wssger.my-imcloud.com",BACKUP_WEB_ONLY:"wss://*w4g.my-cpaas.com",STAT:"https://apiger.my-imcloud.com",ANYCAST:"wss://162.14.3.17"},IND:{INITIAL:"wss://*w4i.my-imcloud.com",DEFAULT:"wss://wssind.my-imcloud.com",IPV6:"wss://wssindv6.im.qcloud.com",BACKUP:"wss://wssind.im.qcloud.com",BACKUP_WEB_ONLY:"wss://*w4i.my-cpaas.com",STAT:"https://apiind.my-imcloud.com",ANYCAST:"wss://162.14.19.46"},JPN:{INITIAL:"wss://*w4j.my-imcloud.com",DEFAULT:"wss://wssjpn.im.qcloud.com",IPV6:"wss://wssjpnv6.im.qcloud.com",BACKUP:"wss://wssjpn.my-imcloud.com",BACKUP_WEB_ONLY:"wss://*w4j.my-cpaas.com",STAT:"https://apijpn.my-imcloud.com",ANYCAST:"wss://162.14.13.254"},USA:{INITIAL:"wss://*w4u.my-imcloud.com",DEFAULT:"wss://wssusa.im.qcloud.com",IPV6:"wss://wssusav6.im.qcloud.com",BACKUP:"wss://wssusa.my-imcloud.com",BACKUP_WEB_ONLY:"wss://*w4u.my-cpaas.com",STAT:"https://apiusa.my-imcloud.com",ANYCAST:"wss://162.14.10.42"},INDONESIA:{INITIAL:"wss://*w4y.my-imcloud.com",DEFAULT:"wss://wssidn.im.qcloud.com",IPV6:"wss://wssidnv6.im.qcloud.com",BACKUP:"wss://wssidn.my-imcloud.com",BACKUP_WEB_ONLY:"wss://*w4y.my-cpaas.com",STAT:"https://apiidn.my-imcloud.com",ANYCAST:"wss://43.129.34.169"}}},et={[Ke]:[[2e7,3e7],[172e7,173e7]],[He]:[[3e7,4e7],[173e7,174e7]],[je]:[[4e7,5e7],[174e7,175e7]],[ze]:[[5e7,6e7],[175e7,176e7]],[Ze]:[[6e7,7e7],[176e7,177e7]],[Xe]:[[7e7,8e7],[177e7,178e7]],[Je]:[[8e7,9e7],[178e7,179e7]]};function st(t){var e;if(null!=(e=$e.get("instance"))&&e.oversea)return Ye;for(let e of Object.keys(et))for(var[s,n]of et[e])if(t>=s&&t<n)return e;return We}var nt,it="1.6.2-beta.0";!function(e){e.INITIAL="INITIAL",e.DEFAULT="DEFAULT",e.BACKUP="BACKUP",e.BACKUP_WEB_ONLY="BACKUP_WEB_ONLY",e.BACKUP_CN="BACKUP_CN",e.ANYCAST="ANYCAST",e.IPV6="IPV6"}(nt=nt||{});let ot=nt.INITIAL;function rt(){var e=Math.random();return 0===e?rt():e}function at(e,t){var s,{isBinary:t=!1}=t||{},{sdkAppId:n,instanceId:i}=$e.get("instance"),r=rt(),o=Se(),a=function(){var e=Se();let t=-1;return"ios"===e?t=ie||-1:"android"===e&&(t=re||-1),t}(),n=(s={sdkappid:n,instanceid:i,random:r,platform:Q,host:o,version:a,sdkversion:it},Object.keys(s).map(e=>e+"="+s[e]).join("&"));return t?e+`/binfo?${n}&compress=gzip`:e+"/info?"+n}function ct(e){var{sdkAppId:t,testEnv:s}=$e.get("instance"),t=st(t);if(s)return at(Qe.TEST[t].DEFAULT,{isBinary:e});let n=Qe.PRODUCTION[t],i=z&&n.ANYCAST,r=z,o=!!n.BACKUP_CN;return at({[nt.INITIAL]:()=>(ot=nt.DEFAULT,n.DEFAULT),[nt.DEFAULT]:()=>(ot=nt.IPV6,n.IPV6),[nt.IPV6]:()=>(ot=nt.BACKUP,n.BACKUP),[nt.BACKUP]:()=>{return r?(ot=nt.BACKUP_WEB_ONLY,e=n.BACKUP_WEB_ONLY,t=Math.floor(10001*Math.random())+1e4,e.replace("*",String(t))):o?(ot=nt.BACKUP_CN,n.BACKUP_CN):i?(ot=nt.ANYCAST,n.ANYCAST):n.DEFAULT;var e,t},[nt.BACKUP_WEB_ONLY]:()=>o?(ot=nt.BACKUP_CN,n.BACKUP_CN):i?(ot=nt.ANYCAST,n.ANYCAST):n.DEFAULT,[nt.BACKUP_CN]:()=>(ot=i?nt.ANYCAST:nt.DEFAULT,n[ot]),[nt.ANYCAST]:()=>(ot=nt.DEFAULT,n.ANYCAST="",n.DEFAULT)}[ot](),{isBinary:e})}var lt=new class{constructor(){this._timeOffsetWithServer=0}getServerTimeMs(){return Date.now()+this._timeOffsetWithServer}getServerTimeSeconds(){return Math.floor(this.getServerTimeMs()/1e3)}getTimeOffsetWithServer(){return this._timeOffsetWithServer}calculateTimeOffsetWithServer(e,t){var s=Date.now();this._timeOffsetWithServer=t+(s-e)-s}};let ut=16;var dt=new class{constructor(){this._tasks=[],this._timer=null,this._taskMap=new Map}_addTaskToScheduler(e){var t=e["id"];this.removeTask(t),this._tasks.push(e),this._taskMap.set(t,e),this._sort(),this._scheduleNextTask()}_createTask(e){var{id:e,callback:t,context:s,isOnce:n=!1,intervalMs:i=ut}=e,r=Math.max(i,ut);return{id:e,nextExecuteTime:Date.now()+r,intervalMs:i,callback:t,context:s,isOnce:n}}addTask(e){e=this._createTask(e);this._addTaskToScheduler(e)}addOnceTask(e){e=this._createTask(Object.assign(Object.assign({},e),{isOnce:!0}));this._addTaskToScheduler(e)}removeTask(t){var e=this._tasks.findIndex(e=>e.id===t);-1<e&&(this._tasks.splice(e,1),this._taskMap.delete(t),this._scheduleNextTask())}updateTaskInterval(e,t){e=this._taskMap.get(e);e&&(e.intervalMs=t,e.nextExecuteTime=Date.now()+t,this._sort(),this._scheduleNextTask())}clearAllTasks(){this._tasks=[],this._taskMap.clear(),this._timer&&(clearTimeout(this._timer),this._timer=null)}dispose(){this.clearAllTasks()}_sort(){this._tasks.sort((e,t)=>e.nextExecuteTime-t.nextExecuteTime)}_scheduleNextTask(){this._timer&&(clearTimeout(this._timer),this._timer=null);var e=this._tasks[0];e&&(e=Math.max(0,e.nextExecuteTime-Date.now()),this._timer=setTimeout(()=>this._execute(),e))}_execute(){for(var e=Date.now();this._tasks.length&&this._tasks[0].nextExecuteTime<=e;){var t=this._tasks[0];try{t.context?t.callback.call(t.context):t.callback(),t.isOnce?this.removeTask(t.id):(t.nextExecuteTime=e+t.intervalMs,this._sort())}catch(e){console.warn(`Task ${t.id} execution failed:`,e),t.isOnce&&this.removeTask(t.id)}}this._scheduleNextTask()}};function _t(t){var s=[];for(let e=0;e<t.length;e+=1){var n,i=t.charCodeAt(e);55296<=i&&i<=56319?(n=t.charCodeAt(++e)-56320+(i-55296<<10)+65536,s.push(240|n>>18,128|n>>12&63,128|n>>6&63,128|63&n)):i<=127?s.push(i):i<=2047?s.push(192|i>>6,128|63&i):s.push(224|i>>12,128|i>>6&63,128|63&i)}return new Uint8Array(s)}function ht(e){var t,s=Array.isArray(e)?[]:Object.create(null);for(t in e)Object.prototype.hasOwnProperty.call(e,t)&&R(t)&&null!=e[t]&&(null===e[t]||"object"!=typeof e[t]?s[t]=e[t]:s[t]=ht(e[t]));return s}function gt(e,t){if(s.includes(e))return 0;var n=_t(JSON.stringify(t));let i=4294967295;var r=n["length"];for(let e=0;e<r;e++){i^=n[e];for(let e=0;e<8;e++)1&~i?i>>>=1:i=i>>>1^3988292384}return(4294967295^i)>>>0}function pt(e){var t,{servcmd:e,data:s}=e,n=(n=e,i=$e.get("login")||{},t=$e.get("instance")||{},{servcmd:n,ver:"v4",platform:Q,websdkappid:537048168,websdkversion:"1.7.3",a2:i.a2Key||void 0,tinyid:i.tinyID||void 0,status_instid:i.statusInstanceId||0,sdkappid:t.sdkAppId,contenttype:"json",reqtime:Math.floor(Date.now()/1e3),identifier:i.a2Key?void 0:i.userId,usersig:i.a2Key?void 0:i.userSig,sdkability:75689843,sdkability_ext:w(""),cappid:t.applicationID||0,tjgID:"",seq:mt(),cs:0}),i=ht(s);return n.cs=gt(e,i),{head:n,body:i}}function Et(e){var t,{servcmd:e,data:s}=e,n=(n=e,i=$e.get("login")||{},t=$e.get("instance")||{},{servcmd:n,ver:"v4",platform:Q,websdkappid:537048168,websdkversion:"1.7.3",sdkappid:t.sdkAppId,contenttype:"",reqtime:Math.floor(Date.now()/1e3),identifier:"",usersig:"",status_instid:i.statusInstanceId||0,sdkability:75689843,sdkability_ext:w(""),cappid:t.applicationID||0,seq:mt(),cs:0}),i=ht(s);return n.cs=gt(e,i),{head:n,body:i}}let ft=P();function mt(){return ft=ft<2415919103?ft+1:P()}function St(){var e=$e.get("login")||{},t=$e.get("instance")||{};return{sdk_type:30,sdk_app_id:t.sdkAppId,sdk_version:"1.6.2-beta.0",tiny_id:Number(e.tinyID),user_id:e.userId,platform:Q,instance_id:t.instanceId,trace_id:(new Date).getTime()}}var vt,Mt,It=Object.freeze({__proto__:null,generateCosSpecifiedData:function(e){var t,{servcmd:e,data:s}=e,n=(n=e,i=$e.get("login")||{},t=$e.get("instance")||{},{servcmd:n,ver:"v4",platform:Q,websdkappid:537048168,websdkversion:"1.7.3",sdkappid:t.sdkAppId,contenttype:"json",reqtime:Math.floor(Date.now()/1e3),identifier:i.userId,usersig:i.userSig,status_instid:i.statusInstanceId||0,sdkability:75689843,sdkability_ext:w(""),cappid:t.applicationID||0,seq:mt(),cs:0}),i=ht(s);return n.cs=gt(e,i),{head:n,body:i}},generateProtocolData:pt,generateSSOLogProtocolData:Et,generateSequence:mt,getCommonHead:St,taskScheduler:dt,timeManager:lt});!function(e){e[e.info=4]="info",e[e.warning=5]="warning",e[e.error=6]="error"}(vt=vt||{});let Ct={method:"extension",networkType:"network_type",eventType:"event_type",code:"error_code",message:"error_message",moreMessage:"more_message",duplicate:"duplicate",costTime:"cost_time",level:"level",uiPlatform:"ui_platform",timestamp:"timestamp"};class Tt{constructor(e){this.level=vt.info,this._canSendLog=!0,this._logCreatedAt=lt.getServerTimeMs(),this.timestamp=0,this.networkType=8,this.code=0,this.moreMessage="",this.method="",this.message="",this.costTime=0,this.duplicate=!1,this.eventType=0,this.uiPlatform=this._getUiPlatform(),this._sdkEdition=this._getSDKEdition();var{method:e,eventType:t=0,message:s="",costTime:n=0,error:i,moreMessage:r=""}=e||{};this.eventType=t,this.method=e,this.message=s,this.costTime=n,this.moreMessage=r,i&&this.setError(i)}setMoreMessage(e){this.moreMessage=this.moreMessage+" "+e}updateLogCreatedAtByTimeOffset(){this._logCreatedAt+=lt.getTimeOffsetWithServer()}end(){this._canSendLog&&(this._canSendLog=!1,this.timestamp=lt.getServerTimeMs(),this._ssoLogModule.pushToLogQueue(this._convertSSOLogDataKeyToServe()))}setError(e){var t;return e instanceof Error?this._canSendLog&&(null!=(t=$e.get("netWorkMonitor"))&&t.isNetworkOnline&&(e.errorCode&&(this.code=e.errorCode),e.errorMessage)&&this.setMoreMessage(e.errorMessage),this.level=vt.error):console.warn("SSOLogData.setError value not instanceof Error, please check!"),this}setLogInfo(t){return Object.keys(t).forEach(e=>{Object.keys(Ct).includes(e)&&(this[e]=t[e])}),this}setSSOLogModule(e){this._ssoLogModule=e}_convertSSOLogDataKeyToServe(){let t={};return Object.keys(this).forEach(e=>{Ct[e]&&(t[Ct[e]]=this[e])}),t}_getUiPlatform(){var e,t=null==(e=$e.get("instance"))?void 0:e.scene;if("string"==typeof t){let e=Number(t);return isNaN(e)?void 0:e}}_getSDKEdition(){var e;return null==(e=$e.get("instance"))?void 0:e.sdkEdition}}!function(e){e.RECONNECTED="reconnected",e.CLOUD_CONFIG_UPDATE="cloud_config_update",e.SOCKET_DISCONNECTED="socket_disconnected"}(Mt=Mt||{});var Ot=Mt;let yt=20,At=6e4,Nt=[4,5,6],Rt=[],Dt=[],Pt="report-logger";var bt=new class{constructor(){this._sdkAppIdBlackList=[],this._tinyIdWhiteList=[],this._reportLevel=[4,5,6],this._minThreshold=yt,this._maxThreshold=100,this._waitingTime=At,this._lastReportAt=Date.now(),this._ssoLogMap=new Map,this._logLevel=n.DEBUG,this._throttleConfig={global:{throttleTime:l,maxCount:u},single:{throttleTime:a,maxCount:c}},this._globalThrottle={count:0,startTime:Date.now()},this._singleThrottleMap=new Map,v.subscribeInnerEvent(Ot.CLOUD_CONFIG_UPDATE,this._handleCloudConfigUpdate,this),dt.addTask({id:Pt,intervalMs:1e3,callback:this._checkAndReportIfDue,context:this}),this._logQueue=[],this._savePlatFormInfo()}_handleCloudConfigUpdate(e){var{evt_rpt_threshold:e=yt,evt_rpt_waiting:t=At,evt_rpt_level:s=Nt,evt_rpt_sdkappid_bl:n=Rt,evt_rpt_tinyid_wl:i=Dt,evt_rpt_global_throttle_time:r=l,evt_rpt_global_throttle_count:o=u,evt_rpt_single_throttle_time:_=a,evt_rpt_single_throttle_count:d=c}=e||{};this._sdkAppIdBlackList=n,this._waitingTime=t,this._minThreshold=e,this._reportLevel=s,this._tinyIdWhiteList=i,this._throttleConfig={global:{throttleTime:r,maxCount:o},single:{throttleTime:_,maxCount:d}}}createSSOLogData(e){var t=new Tt(e);return t.setSSOLogModule(this),this._ssoLogMap.set(e.method,t),t}getSSOLogData(e){return this._ssoLogMap.get(e)||{}}pushToLogQueue(e){e&&(this._logQueue.push(e),this._shouldUploadImmediately())&&this.uploadSSOLogData()}setLogLevel(e){[n.DEBUG,n.ERROR,n.INFO,n.NONE,n.WARN].includes(e)&&(this._logLevel=e)}debug(e,t="",s){this._log(n.DEBUG,e,t,s)}info(e,t="",s){this._log(n.INFO,e,t,s)}warn(e,t="",s){this._log(n.WARN,e,t,s)}error(e,t="",s){this._log(n.ERROR,e,t,s)}_shouldUploadImmediately(){return this._logQueue.length>=this._minThreshold}_isReportDue(){return Date.now()>=this._lastReportAt+this._waitingTime}_checkAndReportIfDue(){this._isReportDue()&&0<this._logQueue.length&&this.uploadSSOLogData()}uploadSSOLogData(){return C(this,void 0,void 0,function*(){var e,t;0!==this._logQueue.length&&(t=this._logQueue.slice(),t=this._filterLogs(t),this._logQueue=[],0===t.length||Oe((t={Header:St(),Event:t}).Header.user_id)||(e=(t=Et({servcmd:e="imopenstat.tim_web_report_v2",data:t})).head.seq+e,yield void Jt.sendPacket(t,{requestId:e})),this._lastReportAt=Date.now())})}_savePlatFormInfo(){var e,t;if(k){var s=null==(t=null==(e=wx.getAccountInfoSync)?void 0:e.call(wx))?void 0:t.miniProgram;if(s){let{appId:e,envVersion:t}=s;$e.set("instance",{appId:e,envVersion:t})}}else z&&$e.set("instance",{href:window.location.href})}_filterLogs(e){var t=($e.get("login")||{})["tinyID"],s=($e.get("instance")||{})["sdkAppId"];return this._sdkAppIdBlackList.includes(s)&&!this._tinyIdWhiteList.includes(t)?[]:e.filter(e=>this._reportLevel.includes(e.level))}_checkThrottle(e){return!!this._checkGlobalThrottle()||this._checkSingleThrottle(e)}_checkGlobalThrottle(){var e=Date.now();if(e-this._globalThrottle.startTime>=this._throttleConfig.global.throttleTime)this._globalThrottle.count=1,this._globalThrottle.startTime=e;else if(this._globalThrottle.count++,this._globalThrottle.count>this._throttleConfig.global.maxCount)return!0;return!1}_checkSingleThrottle(e){var t=Date.now(),s=this._singleThrottleMap.get(e);return s?t-s.startTime>=this._throttleConfig.single.throttleTime?(s.count=1,s.startTime=t,!1):s.count>=this._throttleConfig.single.maxCount||(s.count++,!1):(this._singleThrottleMap.set(e,{count:1,startTime:t}),!1)}_shouldLog(e){return e>=this._logLevel&&this._logLevel!==n.NONE}_shouldReport(e){return this._reportLevel.includes(r[e])}_formatLog(e,t,s){var r=new Date,r=`${r.getHours()}:${r.getMinutes()}:${r.getSeconds()}:`+r.getMilliseconds(),e=`<${n[e]}>`;return ue||Y?[i+` [${r}] ${e} [${t}] `+s]:["%c%s%c%s","background:#0abf5b; padding:1px; border-radius:3px; color: #fff",i,"",`[${r}] ${e} [${t}] `+s]}_log(e,t,s,n){if(this._shouldLog(e)){var i=this._formatLog(e,t,s);if(o[e].apply(console,i),this._shouldReport(e)){let e=this._getThrottleKey(t,s,n);this._checkThrottle(e)||this.createSSOLogData(Object.assign(Object.assign({message:s},n),{method:t})).end()}}}_getThrottleKey(e,t,s){var e=""+e+t+Ae(Object.assign(Object.assign({},s),{costTime:""})),n=_t(JSON.stringify(e));let i=4294967295;var r=n["length"];for(let e=0;e<r;e++){i^=n[e];for(let e=0;e<8;e++)1&~i?i>>>=1:i=i>>>1^3988292384}return""+((4294967295^i)>>>0)}reset(){console.log("SSO_LOG_MODULE.reset"),dt.removeTask(Pt),v.unSubscribeInnerEvent(Ot.CLOUD_CONFIG_UPDATE,this._handleCloudConfigUpdate,this),this._lastReportAt=0,this.uploadSSOLogData(),this._sdkAppIdBlackList=[],this._tinyIdWhiteList=[],this._minThreshold=yt,this._maxThreshold=100,this._waitingTime=At,this._logQueue=[],this._logLevel=n.DEBUG,this._globalThrottle={count:0,startTime:Date.now()},this._singleThrottleMap.clear()}};let wt=15e3,Lt="Channel",kt="channel_schedule_task",Ut="channel_reconnect_task",Gt="connected",Ft="connecting",Bt="disconnected",xt=1e3,Vt="network_status_change",$t="activity_status_change",qt="send_fail",Wt="reconnect_failed",Yt="socket_error",Kt="socket_close";function Ht(e){return(Ht="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function jt(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var zt,ss,Zt={exports:{}},Xt=(zt||(Zt.exports=function s(n,i,r){function o(t,e){if(!i[t]){if(!n[t]){if(!e&&jt)return jt(t);if(a)return a(t,!0);e=new Error("Cannot find module '"+t+"'");throw e.code="MODULE_NOT_FOUND",e}e=i[t]={exports:{}};n[t][0].call(e.exports,function(e){return o(n[t][1][e]||e)},e,e.exports,s,n,i,r)}return i[t].exports}for(var a=jt,e=0;e<r.length;e++)o(r[e]);return o}({1:[function(e,t,s){var n="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array,i=(s.assign=function(e){for(var t,s,n=Array.prototype.slice.call(arguments,1);n.length;){var i=n.shift();if(i){if("object"!=Ht(i))throw new TypeError(i+"must be non-object");for(var r in i)t=i,s=r,Object.prototype.hasOwnProperty.call(t,s)&&(e[r]=i[r])}}return e},s.shrinkBuf=function(e,t){return e.length===t?e:e.subarray?e.subarray(0,t):(e.length=t,e)},{arraySet:function(e,t,s,n,i){if(t.subarray&&e.subarray)e.set(t.subarray(s,s+n),i);else for(var r=0;r<n;r++)e[i+r]=t[s+r]},flattenChunks:function(e){for(var t,s,n,i,r=t=0,o=e.length;r<o;r++)t+=e[r].length;for(i=new Uint8Array(t),r=s=0,o=e.length;r<o;r++)n=e[r],i.set(n,s),s+=n.length;return i}}),r={arraySet:function(e,t,s,n,i){for(var r=0;r<n;r++)e[i+r]=t[s+r]},flattenChunks:function(e){return[].concat.apply([],e)}};s.setTyped=function(e){e?(s.Buf8=Uint8Array,s.Buf16=Uint16Array,s.Buf32=Int32Array,s.assign(s,i)):(s.Buf8=Array,s.Buf16=Array,s.Buf32=Array,s.assign(s,r))},s.setTyped(n)},{}],2:[function(e,t,s){var l=e("./common"),i=!0,r=!0;try{String.fromCharCode.apply(null,[0])}catch(e){i=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(e){r=!1}for(var c=new l.Buf8(256),n=0;n<256;n++)c[n]=252<=n?6:248<=n?5:240<=n?4:224<=n?3:192<=n?2:1;function u(e,t){if(t<65534&&(e.subarray&&r||!e.subarray&&i))return String.fromCharCode.apply(null,l.shrinkBuf(e,t));for(var s="",n=0;n<t;n++)s+=String.fromCharCode(e[n]);return s}c[254]=c[254]=1,s.string2buf=function(e){for(var t,s,n,i,r=e.length,o=0,a=0;a<r;a++)55296==(64512&(s=e.charCodeAt(a)))&&a+1<r&&56320==(64512&(n=e.charCodeAt(a+1)))&&(s=65536+(s-55296<<10)+(n-56320),a++),o+=s<128?1:s<2048?2:s<65536?3:4;for(t=new l.Buf8(o),a=i=0;i<o;a++)55296==(64512&(s=e.charCodeAt(a)))&&a+1<r&&56320==(64512&(n=e.charCodeAt(a+1)))&&(s=65536+(s-55296<<10)+(n-56320),a++),s<128?t[i++]=s:(s<2048?t[i++]=192|s>>>6:(s<65536?t[i++]=224|s>>>12:(t[i++]=240|s>>>18,t[i++]=128|s>>>12&63),t[i++]=128|s>>>6&63),t[i++]=128|63&s);return t},s.buf2binstring=function(e){return u(e,e.length)},s.binstring2buf=function(e){for(var t=new l.Buf8(e.length),s=0,n=t.length;s<n;s++)t[s]=e.charCodeAt(s);return t},s.buf2string=function(e,t){for(var s,n,i,r=t||e.length,o=new Array(2*r),a=s=0;a<r;)if((n=e[a++])<128)o[s++]=n;else if(4<(i=c[n]))o[s++]=65533,a+=i-1;else{for(n&=2===i?31:3===i?15:7;1<i&&a<r;)n=n<<6|63&e[a++],i--;1<i?o[s++]=65533:n<65536?o[s++]=n:(n-=65536,o[s++]=55296|n>>10&1023,o[s++]=56320|1023&n)}return u(o,s)},s.utf8border=function(e,t){for(var s=(t=(t=t||e.length)>e.length?e.length:t)-1;0<=s&&128==(192&e[s]);)s--;return!(s<0||0===s)&&s+c[e[s]]>t?s:t}},{"./common":zt=1}],3:[function(e,t,s){t.exports=function(e,t,s,n){for(var i=65535&e,r=e>>>16&65535,o=0;0!==s;){for(s-=o=2e3<s?2e3:s;r=r+(i=i+t[n++]|0)|0,--o;);i%=65521,r%=65521}return i|r<<16}},{}],4:[function(e,t,s){t.exports={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}},{}],5:[function(e,t,s){var a=function(){for(var e=[],t=0;t<256;t++){for(var s=t,n=0;n<8;n++)s=1&s?3988292384^s>>>1:s>>>1;e[t]=s}return e}();t.exports=function(e,t,s,n){var i=a,r=n+s;e^=-1;for(var o=n;o<r;o++)e=e>>>8^i[255&(e^t[o])];return~e}},{}],6:[function(e,t,s){t.exports=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}},{}],7:[function(e,t,s){t.exports=function(e,t){var s,n,i,r,o,a,l=e.state,c=e.next_in,u=e.input,_=c+(e.avail_in-5),d=e.next_out,h=e.output,g=d-(t-e.avail_out),p=d+(e.avail_out-257),E=l.dmax,m=l.wsize,f=l.whave,S=l.wnext,v=l.window,I=l.hold,C=l.bits,M=l.lencode,T=l.distcode,O=(1<<l.lenbits)-1,y=(1<<l.distbits)-1;e:do{for(C<15&&(I+=u[c++]<<C,C+=8,I+=u[c++]<<C,C+=8),s=M[I&O];;){if(I>>>=n=s>>>24,C-=n,0==(n=s>>>16&255))h[d++]=65535&s;else{if(!(16&n)){if(!(64&n)){s=M[(65535&s)+(I&(1<<n)-1)];continue}if(32&n){l.mode=12;break e}e.msg="invalid literal/length code",l.mode=30;break e}for(i=65535&s,(n&=15)&&(C<n&&(I+=u[c++]<<C,C+=8),i+=I&(1<<n)-1,I>>>=n,C-=n),C<15&&(I+=u[c++]<<C,C+=8,I+=u[c++]<<C,C+=8),s=T[I&y];;){if(I>>>=n=s>>>24,C-=n,!(16&(n=s>>>16&255))){if(!(64&n)){s=T[(65535&s)+(I&(1<<n)-1)];continue}e.msg="invalid distance code",l.mode=30;break e}if(r=65535&s,C<(n&=15)&&(I+=u[c++]<<C,(C+=8)<n)&&(I+=u[c++]<<C,C+=8),E<(r+=I&(1<<n)-1)){e.msg="invalid distance too far back",l.mode=30;break e}if(I>>>=n,C-=n,(n=d-g)<r){if(f<(n=r-n)&&l.sane){e.msg="invalid distance too far back",l.mode=30;break e}if(a=v,(o=0)===S){if(o+=m-n,n<i){for(i-=n;h[d++]=v[o++],--n;);o=d-r,a=h}}else if(S<n){if(o+=m+S-n,(n-=S)<i){for(i-=n;h[d++]=v[o++],--n;);if(o=0,S<i){for(i-=n=S;h[d++]=v[o++],--n;);o=d-r,a=h}}}else if(o+=S-n,n<i){for(i-=n;h[d++]=v[o++],--n;);o=d-r,a=h}for(;2<i;)h[d++]=a[o++],h[d++]=a[o++],h[d++]=a[o++],i-=3;i&&(h[d++]=a[o++],1<i)&&(h[d++]=a[o++])}else{for(o=d-r;h[d++]=h[o++],h[d++]=h[o++],h[d++]=h[o++],2<(i-=3););i&&(h[d++]=h[o++],1<i)&&(h[d++]=h[o++])}break}}break}}while(c<_&&d<p);c-=i=C>>3,I&=(1<<(C-=i<<3))-1,e.next_in=c,e.next_out=d,e.avail_in=c<_?_-c+5:5-(c-_),e.avail_out=d<p?p-d+257:257-(d-p),l.hold=I,l.bits=C}},{}],8:[function(e,t,s){var P=e("../utils/common"),b=e("./adler32"),w=e("./crc32"),L=e("./inffast"),k=e("./inftrees"),U=0,G=-2,F=1,n=852,i=592;function B(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function r(){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 P.Buf16(320),this.work=new P.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function o(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=F,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new P.Buf32(n),t.distcode=t.distdyn=new P.Buf32(i),t.sane=1,t.back=-1,U):G}function a(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,o(e)):G}function l(e,t){var s,n;return!e||!e.state||(n=e.state,t<0?(s=0,t=-t):(s=1+(t>>4),t<48&&(t&=15)),t&&(t<8||15<t))?G:(null!==n.window&&n.wbits!==t&&(n.window=null),n.wrap=s,n.wbits=t,a(e))}function c(e,t){var s;return e?(s=new r,(e.state=s).window=null,(s=l(e,t))!==U&&(e.state=null),s):G}var x,V,q=!0;function Y(e,t,s,n){var i,e=e.state;return null===e.window&&(e.wsize=1<<e.wbits,e.wnext=0,e.whave=0,e.window=new P.Buf8(e.wsize)),n>=e.wsize?(P.arraySet(e.window,t,s-e.wsize,e.wsize,0),e.wnext=0,e.whave=e.wsize):(n<(i=e.wsize-e.wnext)&&(i=n),P.arraySet(e.window,t,s-n,i,e.wnext),(n-=i)?(P.arraySet(e.window,t,s-n,n,0),e.wnext=n,e.whave=e.wsize):(e.wnext+=i,e.wnext===e.wsize&&(e.wnext=0),e.whave<e.wsize&&(e.whave+=i))),0}s.inflateReset=a,s.inflateReset2=l,s.inflateResetKeep=o,s.inflateInit=function(e){return c(e,15)},s.inflateInit2=c,s.inflate=function(e,t){var s,n,i,r,o,a,l,c,u,_,d,h,g,p,E,m,f,S,v,I,C,M,T,O,y=0,A=new P.Buf8(4),N=[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 G;12===(s=e.state).mode&&(s.mode=13),o=e.next_out,i=e.output,l=e.avail_out,r=e.next_in,n=e.input,a=e.avail_in,c=s.hold,u=s.bits,_=a,d=l,M=U;e:for(;;)switch(s.mode){case F:if(0===s.wrap)s.mode=13;else{for(;u<16;){if(0===a)break e;a--,c+=n[r++]<<u,u+=8}if(2&s.wrap&&35615===c)A[s.check=0]=255&c,A[1]=c>>>8&255,s.check=w(s.check,A,2,0),u=c=0,s.mode=2;else 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;else if(8!=(15&c))e.msg="unknown compression method",s.mode=30;else{if(u-=4,C=8+(15&(c>>>=4)),0===s.wbits)s.wbits=C;else if(C>s.wbits){e.msg="invalid window size",s.mode=30;break}s.dmax=1<<C,e.adler=s.check=1,s.mode=512&c?10:12,u=c=0}}break;case 2:for(;u<16;){if(0===a)break e;a--,c+=n[r++]<<u,u+=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=w(s.check,A,2,0)),u=c=0,s.mode=3;case 3:for(;u<32;){if(0===a)break e;a--,c+=n[r++]<<u,u+=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=w(s.check,A,4,0)),u=c=0,s.mode=4;case 4:for(;u<16;){if(0===a)break e;a--,c+=n[r++]<<u,u+=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=w(s.check,A,2,0)),u=c=0,s.mode=5;case 5:if(1024&s.flags){for(;u<16;){if(0===a)break e;a--,c+=n[r++]<<u,u+=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=w(s.check,A,2,0)),u=c=0}else s.head&&(s.head.extra=null);s.mode=6;case 6:if(1024&s.flags&&((h=a<(h=s.length)?a:h)&&(s.head&&(C=s.head.extra_len-s.length,s.head.extra||(s.head.extra=new Array(s.head.extra_len)),P.arraySet(s.head.extra,n,r,h,C)),512&s.flags&&(s.check=w(s.check,n,h,r)),a-=h,r+=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;for(h=0;C=n[r+h++],s.head&&C&&s.length<65536&&(s.head.name+=String.fromCharCode(C)),C&&h<a;);if(512&s.flags&&(s.check=w(s.check,n,h,r)),a-=h,r+=h,C)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;for(h=0;C=n[r+h++],s.head&&C&&s.length<65536&&(s.head.comment+=String.fromCharCode(C)),C&&h<a;);if(512&s.flags&&(s.check=w(s.check,n,h,r)),a-=h,r+=h,C)break e}else s.head&&(s.head.comment=null);s.mode=9;case 9:if(512&s.flags){for(;u<16;){if(0===a)break e;a--,c+=n[r++]<<u,u+=8}if(c!==(65535&s.check)){e.msg="header crc mismatch",s.mode=30;break}u=c=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(;u<32;){if(0===a)break e;a--,c+=n[r++]<<u,u+=8}e.adler=s.check=B(c),u=c=0,s.mode=11;case 11:if(0===s.havedict)return e.next_out=o,e.avail_out=l,e.next_in=r,e.avail_in=a,s.hold=c,s.bits=u,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&u,u-=7&u,s.mode=27;else{for(;u<3;){if(0===a)break e;a--,c+=n[r++]<<u,u+=8}switch(s.last=1&c,--u,3&(c>>>=1)){case 0:s.mode=14;break;case 1:R=D=void 0;var R,D=s;if(q){for(x=new P.Buf32(512),V=new P.Buf32(32),R=0;R<144;)D.lens[R++]=8;for(;R<256;)D.lens[R++]=9;for(;R<280;)D.lens[R++]=7;for(;R<288;)D.lens[R++]=8;for(k(1,D.lens,0,288,x,0,D.work,{bits:9}),R=0;R<32;)D.lens[R++]=5;k(2,D.lens,0,32,V,0,D.work,{bits:5}),q=!1}if(D.lencode=x,D.lenbits=9,D.distcode=V,D.distbits=5,s.mode=20,6!==t)break;c>>>=2,u-=2;break e;case 2:s.mode=17;break;case 3:e.msg="invalid block type",s.mode=30}c>>>=2,u-=2}break;case 14:for(c>>>=7&u,u-=7&u;u<32;){if(0===a)break e;a--,c+=n[r++]<<u,u+=8}if((65535&c)!=(c>>>16^65535)){e.msg="invalid stored block lengths",s.mode=30;break}if(s.length=65535&c,u=c=0,s.mode=15,6===t)break e;case 15:s.mode=16;case 16:if(h=s.length){if(0===(h=l<(h=a<h?a:h)?l:h))break e;P.arraySet(i,n,r,h,o),a-=h,r+=h,l-=h,o+=h,s.length-=h}else s.mode=12;break;case 17:for(;u<14;){if(0===a)break e;a--,c+=n[r++]<<u,u+=8}if(s.nlen=257+(31&c),c>>>=5,u-=5,s.ndist=1+(31&c),c>>>=5,u-=5,s.ncode=4+(15&c),c>>>=4,u-=4,286<s.nlen||30<s.ndist){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(;u<3;){if(0===a)break e;a--,c+=n[r++]<<u,u+=8}s.lens[N[s.have++]]=7&c,c>>>=3,u-=3}for(;s.have<19;)s.lens[N[s.have++]]=0;if(s.lencode=s.lendyn,s.lenbits=7,T={bits:s.lenbits},M=k(0,s.lens,0,19,s.lencode,0,s.work,T),s.lenbits=T.bits,M){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=(y=s.lencode[c&(1<<s.lenbits)-1])>>>16&255,f=65535&y,!((E=y>>>24)<=u);){if(0===a)break e;a--,c+=n[r++]<<u,u+=8}if(f<16)c>>>=E,u-=E,s.lens[s.have++]=f;else{if(16===f){for(O=E+2;u<O;){if(0===a)break e;a--,c+=n[r++]<<u,u+=8}if(c>>>=E,u-=E,0===s.have){e.msg="invalid bit length repeat",s.mode=30;break}C=s.lens[s.have-1],h=3+(3&c),c>>>=2,u-=2}else if(17===f){for(O=E+3;u<O;){if(0===a)break e;a--,c+=n[r++]<<u,u+=8}C=0,h=3+(7&(c>>>=E)),c>>>=3,u=u-E-3}else{for(O=E+7;u<O;){if(0===a)break e;a--,c+=n[r++]<<u,u+=8}C=0,h=11+(127&(c>>>=E)),c>>>=7,u=u-E-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++]=C}}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,T={bits:s.lenbits},M=k(1,s.lens,0,s.nlen,s.lencode,0,s.work,T),s.lenbits=T.bits,M){e.msg="invalid literal/lengths set",s.mode=30;break}if(s.distbits=6,s.distcode=s.distdyn,T={bits:s.distbits},M=k(2,s.lens,s.nlen,s.ndist,s.distcode,0,s.work,T),s.distbits=T.bits,M){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(6<=a&&258<=l){e.next_out=o,e.avail_out=l,e.next_in=r,e.avail_in=a,s.hold=c,s.bits=u,L(e,d),o=e.next_out,i=e.output,l=e.avail_out,r=e.next_in,n=e.input,a=e.avail_in,c=s.hold,u=s.bits,12===s.mode&&(s.back=-1);break}for(s.back=0;m=(y=s.lencode[c&(1<<s.lenbits)-1])>>>16&255,f=65535&y,!((E=y>>>24)<=u);){if(0===a)break e;a--,c+=n[r++]<<u,u+=8}if(m&&!(240&m)){for(S=E,v=m,I=f;m=(y=s.lencode[I+((c&(1<<S+v)-1)>>S)])>>>16&255,f=65535&y,!(S+(E=y>>>24)<=u);){if(0===a)break e;a--,c+=n[r++]<<u,u+=8}c>>>=S,u-=S,s.back+=S}if(c>>>=E,u-=E,s.back+=E,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(O=s.extra;u<O;){if(0===a)break e;a--,c+=n[r++]<<u,u+=8}s.length+=c&(1<<s.extra)-1,c>>>=s.extra,u-=s.extra,s.back+=s.extra}s.was=s.length,s.mode=23;case 23:for(;m=(y=s.distcode[c&(1<<s.distbits)-1])>>>16&255,f=65535&y,!((E=y>>>24)<=u);){if(0===a)break e;a--,c+=n[r++]<<u,u+=8}if(!(240&m)){for(S=E,v=m,I=f;m=(y=s.distcode[I+((c&(1<<S+v)-1)>>S)])>>>16&255,f=65535&y,!(S+(E=y>>>24)<=u);){if(0===a)break e;a--,c+=n[r++]<<u,u+=8}c>>>=S,u-=S,s.back+=S}if(c>>>=E,u-=E,s.back+=E,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(O=s.extra;u<O;){if(0===a)break e;a--,c+=n[r++]<<u,u+=8}s.offset+=c&(1<<s.extra)-1,c>>>=s.extra,u-=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===l)break e;if(s.offset>(h=d-l)){if((h=s.offset-h)>s.whave&&s.sane){e.msg="invalid distance too far back",s.mode=30;break}g=h>s.wnext?(h-=s.wnext,s.wsize-h):s.wnext-h,h>s.length&&(h=s.length),p=s.window}else p=i,g=o-s.offset,h=s.length;for(l-=h=l<h?l:h,s.length-=h;i[o++]=p[g++],--h;);0===s.length&&(s.mode=21);break;case 26:if(0===l)break e;i[o++]=s.length,l--,s.mode=21;break;case 27:if(s.wrap){for(;u<32;){if(0===a)break e;a--,c|=n[r++]<<u,u+=8}if(d-=l,e.total_out+=d,s.total+=d,d&&(e.adler=s.check=(s.flags?w:b)(s.check,i,d,o-d)),d=l,(s.flags?c:B(c))!==s.check){e.msg="incorrect data check",s.mode=30;break}u=c=0}s.mode=28;case 28:if(s.wrap&&s.flags){for(;u<32;){if(0===a)break e;a--,c+=n[r++]<<u,u+=8}if(c!==(4294967295&s.total)){e.msg="incorrect length check",s.mode=30;break}u=c=0}s.mode=29;case 29:M=1;break e;case 30:M=-3;break e;case 31:return-4;default:return G}return e.next_out=o,e.avail_out=l,e.next_in=r,e.avail_in=a,s.hold=c,s.bits=u,(s.wsize||d!==e.avail_out&&s.mode<30&&(s.mode<27||4!==t))&&Y(e,e.output,e.next_out,d-e.avail_out)?(s.mode=31,-4):(_-=e.avail_in,d-=e.avail_out,e.total_in+=_,e.total_out+=d,s.total+=d,s.wrap&&d&&(e.adler=s.check=(s.flags?w:b)(s.check,i,d,e.next_out-d)),e.data_type=s.bits+(s.last?64:0)+(12===s.mode?128:0)+(20===s.mode||15===s.mode?256:0),M=(0==_&&0===d||4===t)&&M===U?-5:M)},s.inflateEnd=function(e){var t;return e&&e.state?((t=e.state).window&&(t.window=null),e.state=null,U):G},s.inflateGetHeader=function(e,t){return e&&e.state&&2&(e=e.state).wrap?((e.head=t).done=!1,U):G},s.inflateSetDictionary=function(e,t){var s,n=t.length;return!e||!e.state||0!==(s=e.state).wrap&&11!==s.mode?G:11===s.mode&&b(1,t,n,0)!==s.check?-3:Y(e,t,n,n)?(s.mode=31,-4):(s.havedict=1,U)},s.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":1,"./adler32":3,"./crc32":5,"./inffast":7,"./inftrees":9}],9:[function(e,t,s){var L=e("../utils/common"),k=[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],U=[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],G=[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],F=[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];t.exports=function(e,t,s,n,i,r,o,a){for(var l,c,u,_,d,h,g,p,E,m=a.bits,f=0,S=0,v=0,I=0,C=0,M=0,T=0,O=0,y=0,A=0,N=null,R=0,D=new L.Buf16(16),P=new L.Buf16(16),b=null,w=0,f=0;f<=15;f++)D[f]=0;for(S=0;S<n;S++)D[t[s+S]]++;for(C=m,I=15;1<=I&&0===D[I];I--);if(I<C&&(C=I),0===I)i[r++]=20971520,i[r++]=20971520,a.bits=1;else{for(v=1;v<I&&0===D[v];v++);for(C<v&&(C=v),f=O=1;f<=15;f++)if((O=(O<<1)-D[f])<0)return-1;if(0<O&&(0===e||1!==I))return-1;for(P[1]=0,f=1;f<15;f++)P[f+1]=P[f]+D[f];for(S=0;S<n;S++)0!==t[s+S]&&(o[P[t[s+S]]++]=S);if(h=0===e?(N=b=o,19):1===e?(N=k,R-=257,b=U,w-=257,256):(N=G,b=F,-1),f=v,d=r,T=S=A=0,u=-1,_=(y=1<<(M=C))-1,1===e&&852<y||2===e&&592<y)return 1;for(;;){for(E=o[S]<h?(p=0,o[S]):o[S]>h?(p=b[w+o[S]],N[R+o[S]]):(p=96,0),l=1<<(g=f-T),v=c=1<<M;i[d+(A>>T)+(c-=l)]=g<<24|p<<16|E,0!==c;);for(l=1<<f-1;A&l;)l>>=1;if(0!==l?A=(A&l-1)+l:A=0,S++,0==--D[f]){if(f===I)break;f=t[s+o[S]]}if(C<f&&(A&_)!==u){for(d+=v,O=1<<(M=f-(T=0===T?C:T));M+T<I&&!((O-=D[M+T])<=0);)M++,O<<=1;if(y+=1<<M,1===e&&852<y||2===e&&592<y)return 1;i[u=A&_]=C<<24|M<<16|d-r}}0!==A&&(i[d+A]=f-T<<24|64<<16),a.bits=C}return 0}},{"../utils/common":1}],10:[function(e,t,s){t.exports={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"}},{}],11:[function(e,t,s){t.exports=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}},{}],"/lib/inflate.js":[function(e,t,s){var _=e("./zlib/inflate"),d=e("./utils/common"),h=e("./utils/strings"),g=e("./zlib/constants"),n=e("./zlib/messages"),i=e("./zlib/zstream"),r=e("./zlib/gzheader"),p=Object.prototype.toString;function o(e){if(!(this instanceof o))return new o(e);this.options=d.assign({chunkSize:16384,windowBits:0,to:""},e||{});var t=this.options,e=(t.raw&&0<=t.windowBits&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits)&&(t.windowBits=-15),!(0<=t.windowBits&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),15<t.windowBits&&t.windowBits<48&&!(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new i,this.strm.avail_out=0,_.inflateInit2(this.strm,t.windowBits));if(e!==g.Z_OK)throw new Error(n[e]);if(this.header=new r,_.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=h.string2buf(t.dictionary):"[object ArrayBuffer]"===p.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw)&&(e=_.inflateSetDictionary(this.strm,t.dictionary))!==g.Z_OK)throw new Error(n[e])}function a(e,t){t=new o(t);if(t.push(e,!0),t.err)throw t.msg||n[t.err];return t.result}o.prototype.push=function(e,t){var s,n,i,r,o,a=this.strm,l=this.options.chunkSize,c=this.options.dictionary,u=!1;if(this.ended)return!1;n=t===~~t?t:!0===t?g.Z_FINISH:g.Z_NO_FLUSH,"string"==typeof e?a.input=h.binstring2buf(e):"[object ArrayBuffer]"===p.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 d.Buf8(l),a.next_out=0,a.avail_out=l),(s=(s=_.inflate(a,g.Z_NO_FLUSH))===g.Z_NEED_DICT&&c?_.inflateSetDictionary(this.strm,c):s)===g.Z_BUF_ERROR&&!0===u&&(s=g.Z_OK,u=!1),s!==g.Z_STREAM_END&&s!==g.Z_OK)return this.onEnd(s),!(this.ended=!0)}while(!a.next_out||0!==a.avail_out&&s!==g.Z_STREAM_END&&(0!==a.avail_in||n!==g.Z_FINISH&&n!==g.Z_SYNC_FLUSH)||("string"===this.options.to?(i=h.utf8border(a.output,a.next_out),r=a.next_out-i,o=h.buf2string(a.output,i),a.next_out=r,a.avail_out=l-r,r&&d.arraySet(a.output,a.output,i,r,0),this.onData(o)):this.onData(d.shrinkBuf(a.output,a.next_out))),0===a.avail_in&&0===a.avail_out&&(u=!0),(0<a.avail_in||0===a.avail_out)&&s!==g.Z_STREAM_END);return(n=s===g.Z_STREAM_END?g.Z_FINISH:n)===g.Z_FINISH?(s=_.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,s===g.Z_OK):n!==g.Z_SYNC_FLUSH||(this.onEnd(g.Z_OK),!(a.avail_out=0))},o.prototype.onData=function(e){this.chunks.push(e)},o.prototype.onEnd=function(e){e===g.Z_OK&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=d.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},s.Inflate=o,s.inflate=a,s.inflateRaw=function(e,t){return(t=t||{}).raw=!0,a(e,t)},s.ungzip=a},{"./utils/common":1,"./utils/strings":2,"./zlib/constants":4,"./zlib/gzheader":6,"./zlib/inflate":8,"./zlib/messages":10,"./zlib/zstream":11}]},{},[])("/lib/inflate.js")),Zt.exports),Jt=new class{constructor(){this._socketAdapter=null,this._url="",this._isReconnecting=!1,this._pendingRequests=new Map,this._nextHeartbeatAt=0,this._lastDiagnoseAt=0,this._isHeartbeatInProgress=!1,this._connectionEstablishedTime=0,this._connectionStartTime=0,this._connectionId=-1,this._isBinarySupported=!0,this._intendedDelay=xt,this._currentConnectState=Gt,this._beforeSendInterceptors=[]}init(){dt.addTask({id:kt,intervalMs:1e3,callback:this._executeScheduledTaskIfReady,context:this}),this._updateIsBinarySupported(),this._url=function(e){var{sdkAppId:t,testEnv:s,disableIndependentDomain:n}=$e.get("instance"),i=st(t);let r="";return s?r=Qe.TEST[i].DEFAULT:n?(r=Qe.PRODUCTION[i].DEFAULT,ot=nt.DEFAULT):r=Qe.PRODUCTION[i].INITIAL.replace("*",""+t),at(r,{isBinary:e})}(this._isBinarySupported),v.subscribeInnerEvent("networkStatusChange",this._handleNetworkStatusChange,this),v.subscribeInnerEvent("activityStatusChange",this._handleActivityStatusChange,this),this.connect()}sendPacket(e,t){var s,{requestId:n,timeout:i=wt,canResend:r=!0}=t||{};if(Oe(e))return bt.warn("sendPacket",Lt+".sendPacket: packet is empty "),null;this._executeBeforeSendInterceptors(e),this._currentConnectState===Bt&&this._handleConnectStateChange({state:Bt,shouldEmitEvent:!0,shouldAttemptReconnect:!0,reason:qt});var o=JSON.stringify(e);let a=null;if(n){let{resolve:e,reject:t,promise:s}=Ne();a=s,this._pendingRequests.set(n,{resolve:e,reject:t,timestamp:Date.now(),uplinkData:o,timeout:i,canResend:r})}t=this._isBinarySupported?_t(o).buffer:o;return null!=(s=this._socketAdapter)&&s.send(t),a}connect(){this._socketAdapter=new qe(this._url),this._connectionEstablishedTime=0,this._addEventListeners(),this._connectionStartTime=Date.now();var e=null==(e=this._socketAdapter)?void 0:e.getId(),t=Lt+`.connect isWorkerEnabled: false socketID:${e} url:`+this._url;this._connectionId=e,this._ssoLog({method:"connect",message:t})}disconnect(){var e=null==(e=this._socketAdapter)?void 0:e.getId(),e=Lt+".disconnect socketID:"+e;this._ssoLog({method:"disconnect",message:e}),this._removeEventListeners(),null!=(e=this._socketAdapter)&&e.disconnect()}getSocketAdapter(){return this._socketAdapter}dispose(){console.log(Lt+".dispose"),dt.removeTask(kt),dt.removeTask(Ut),v.unSubscribeInnerEvent("networkStatusChange",this._handleNetworkStatusChange,this),v.unSubscribeInnerEvent("activityStatusChange",this._handleActivityStatusChange,this),this.disconnect(),this._socketAdapter=null,this._isReconnecting=!1,this._isHeartbeatInProgress=!1,this._pendingRequests.clear(),this._nextHeartbeatAt=0,this._lastDiagnoseAt=0,this._intendedDelay=xt,this._url=""}registerBeforeSendInterceptor(e,t){this._beforeSendInterceptors.push(e.bind(t))}_executeBeforeSendInterceptors(e){for(var t of this._beforeSendInterceptors){var{servcmd:s=""}=null==e?void 0:e.head;t(s.includes(".")?s.split(".").pop():"")}}_shouldSkipReconnect(){var e=this._currentConnectState===Ft&&this._isReconnecting;return!this._socketAdapter||e}reconnect(){return C(this,void 0,void 0,function*(){var e=`${Lt}.reconnect isReconnecting: ${this._isReconnecting} currentConnectState: `+this._currentConnectState;if(this._ssoLog({method:"reconnect",message:e}),!this._shouldSkipReconnect()){this._url=ct(this._isBinarySupported);try{this._isReconnecting=!0,this.disconnect(),this.connect()}catch(e){this._isReconnecting=!1,this._handleConnectStateChange({state:Bt,shouldEmitEvent:!0,shouldAttemptReconnect:!0,reason:Wt}),console.warn(Lt+".reconnect failed: ",e)}}})}_addEventListeners(){var e;null!=(e=this._socketAdapter)&&e.on("connect",this._onConnect,this),null!=(e=this._socketAdapter)&&e.on("message",this._onMessage,this),null!=(e=this._socketAdapter)&&e.on("close",this._onClose,this),null!=(e=this._socketAdapter)&&e.on("error",this._onError,this),null!=(e=this._socketAdapter)&&e.on("sendFail",this._onSendFail,this)}_removeEventListeners(){var e;null!=(e=this._socketAdapter)&&e.off("connect",this._onConnect,this),null!=(e=this._socketAdapter)&&e.off("message",this._onMessage,this),null!=(e=this._socketAdapter)&&e.off("close",this._onClose,this),null!=(e=this._socketAdapter)&&e.off("error",this._onError,this),null!=(e=this._socketAdapter)&&e.off("sendFail",this._onSendFail,this)}_onClose(e){var{socketId:e,event:t}=e||{},s=0!==this._connectionEstablishedTime?Date.now()-this._connectionEstablishedTime:0,s=`${Lt}.onClose closeSocketID: ${e} currentSocketID: ${this._connectionId} connectionDuration: ${s} code: ${null==t?void 0:t.code} reason: `+(null==t?void 0:t.reason);this._ssoLog({method:"onClose",message:s}),e===this._connectionId&&this._handleConnectStateChange({state:Bt,shouldEmitEvent:!0,shouldAttemptReconnect:!0,reason:Kt}),this._isReconnecting&&(this._isReconnecting=!1)}_onError(e){var{socketId:e,error:t}=e||{},t=`${Lt}.onError sourceSocketID: ${e} currentSocketID: ${this._connectionId} isReconnecting: ${this._isReconnecting} error: `+JSON.stringify(t);this._ssoLog({method:"onError",message:t}),e===this._connectionId&&this._handleConnectStateChange({state:Bt,shouldEmitEvent:!0,shouldAttemptReconnect:!0,reason:Yt}),this._isReconnecting&&(this._isReconnecting=!1)}_onSendFail(e){var{socketId:e,error:t}=e||{},e=`${Lt}.onSendFail sendFailSocketId: ${e} currentSocketID: ${this._connectionId} isReconnecting: ${this._isReconnecting} error: `+t;this._ssoLog({method:"onSendFail",message:e}),this._isReconnecting&&(this._isReconnecting=!1)}_onMessage(t){let s,e;this._updateHeartbeatTime();try{s=this._isBinarySupported?(this._isCompressedData(t.data)?e=>{var t=new Uint8Array(e).slice(4);let s;try{s=Xt.inflate(t,{to:"string"})}catch(e){console.error("inflate error",e)}return s}:function(e){var i=new Uint8Array(e);let r="",o=0;for(var a=i["length"];o<a;){let t=i[o],s=0,n=0;if(t<=127?(s=0,n=255&t):t<=223?(s=1,n=31&t):t<=239?(s=2,n=15&t):t<=244&&(s=3,n=7&t),0<a-o-s)for(let e=0;e<s;e+=1)t=i[o+e+1],n=n<<6|63&t;else n=65533,s=a-o;r+=String.fromCodePoint(n),o+=s+1}return r})(t.data):t.data,e=JSON.parse(s)}catch(s){let e=t.data;return void this._ssoLog({method:"jsonParseError",message:e})}var n;e&&e.head&&({seq:t,servcmd:n}=e.head,this._pendingRequests.has(""+t+n)?this._handleRequestResponse(e):this._handlePushMessage(e))}_handleRequestResponse(e){var{seq:t,servcmd:s}=e.head,{int32_error_code:n,str_error_message:i}=(null==e?void 0:e.body)||{},r=(null==(r=null==e?void 0:e.body)?void 0:r.ErrorCode)||n,n=(null==(n=null==e?void 0:e.body)?void 0:n.ErrorInfo)||i,i=""+t+s,{resolve:t,reject:s}=this._pendingRequests.get(i);this._pendingRequests.delete(i),r&&0!==r?(v.emitInnerEvent("error",{errorCode:r,errorInfo:n}),s({errorCode:r,errorInfo:n})):t(e.body)}_handlePushMessage(e){var t=e.head["servcmd"],{NeedAck:s,SessionData:n}=e.body;1===s&&this._sendAck(n),v.emitInnerEvent(t,e)}_checkPendingRequestsAndResend(){var e;bt.debug("_checkPendingRequestsAndResend",` reConnectFlag:${this._isReconnecting} promiseMap.size:`+this._pendingRequests.size),null!=(e=this._pendingRequests)&&e.forEach((e,t)=>{var{uplinkData:s,canResend:n,resolve:i,reject:r,timeout:o}=e;if(n){this._pendingRequests.set(t,{resolve:i,reject:r,timestamp:Date.now(),uplinkData:s,timeout:o,canResend:n});let e=this._isBinarySupported?_t(s).buffer:s;null!=(i=this._socketAdapter)&&i.send(e)}else this._pendingRequests.delete(t)})}_onConnect(e){var{socketId:e,event:t={}}=e||{},s=(this._connectionId=e,this._connectionEstablishedTime=Date.now(),Date.now()-this._connectionStartTime),s=Lt+`.onConnect cost:${s} ms. socketID:${e} res:`+JSON.stringify(t);if(this._ssoLog({method:"onConnect",message:s}),this._checkPendingRequestsAndResend(),this._sendHeartbeatIfReady(),this._isReconnecting){let e=Lt+".reconnect success";this._ssoLog({method:"reconnectSuccess",message:e}),v.emitInnerEvent(Ot.RECONNECTED),this._isReconnecting=!1}this._resetReconnectDelay(),this._handleConnectStateChange({state:Gt,shouldEmitEvent:!0,shouldAttemptReconnect:!1})}_sendAck(e){e=pt({servcmd:"openim.ws_msg_push_ack",data:{SessionData:e}});this.sendPacket(e)}_executeScheduledTaskIfReady(){return C(this,void 0,void 0,function*(){this._clearTimeoutRequest(),this._sendHeartbeatIfReady()})}_canSendHeartbeat(){var e;return(null==(e=this._socketAdapter)?void 0:e.isConnected())&&Date.now()>=this._nextHeartbeatAt&&!this._isHeartbeatInProgress}_sendHeartbeat(){return C(this,void 0,void 0,function*(){var e,t=pt({servcmd:"heartbeat.alive",data:{}});try{let e=""+t.head.seq+t.head.servcmd;yield this.sendPacket(t,{requestId:e,timeout:3e3})}catch(t){var s=null==(e=$e.get("netWorkMonitor"))?void 0:e.isNetWorkOnline,s=Lt+`.sendHeartbeat failed. isNetWorkOnline:${s} error: `+t;this._ssoLog({method:"sendHeartbeatError",message:s}),this._handleConnectStateChange({state:Bt,shouldEmitEvent:!0,shouldAttemptReconnect:!0})}})}_sendHeartbeatIfReady(){return C(this,void 0,void 0,function*(){this._canSendHeartbeat()&&(this._isHeartbeatInProgress=!0,yield this._sendHeartbeat(),this._isHeartbeatInProgress=!1)})}_updateHeartbeatTime(){this._nextHeartbeatAt=$?Date.now()+5e3:Date.now()+1e4}_handleNetworkStatusChange(e){var t=Lt+".networkStatusChange "+JSON.stringify(e),{isNetworkOnline:t,networkType:e}=(this._ssoLog({method:"networkStatusChange",message:t}),e);t&&"none"!==e?this._handleConnectStateChange({state:Gt,shouldEmitEvent:!1,shouldAttemptReconnect:!0,reason:Vt}):this._handleConnectStateChange({state:Bt,shouldEmitEvent:!1,shouldAttemptReconnect:!0,reason:Vt})}isPrivateNetWork(){var e=$e.get("instance")||{};return e.proxyServer&&!e.fileDownloadProxy}_handleConnectStateChange(e){var{state:e,shouldAttemptReconnect:t,shouldEmitEvent:s,reason:n}=e,n=`${Lt}._handleConnectStateChange currentConnectState: ${this._currentConnectState} shouldAttemptReconnect: ${t} shouldEmitEvent: ${s} reason: `+n;this._currentConnectState!==e&&(this._ssoLog({method:"handleConnectStateChange",message:n}),s&&(bt.info("_handleConnectStateChange",` from ${this._currentConnectState} to `+e),v.emitOuterEvent("netStateChange",{name:"netStateChange",data:{state:e}}),(this._currentConnectState=e)===Bt)&&v.emitInnerEvent(Ot.SOCKET_DISCONNECTED),t)&&(this._resetReconnectDelay(),dt.addTask({id:Ut,intervalMs:this._intendedDelay,callback:this._scheduleReconnectWithBackoff,context:this}))}_handleActivityStatusChange(e){var t=null==(t=null==(t=this._socketAdapter)?void 0:t._ws)?void 0:t.readyState,e=`${Lt}.activityStatusChange ${JSON.stringify(e)} readyState: `+t;this._ssoLog({method:"activityStatusChange",message:e}),3===t&&this._handleConnectStateChange({state:Bt,shouldEmitEvent:!0,shouldAttemptReconnect:!0,reason:$t})}_resetReconnectDelay(){bt.debug(Lt+"._resetReconnectDelay"),dt.removeTask(Ut);var e=null==(e=$e.get("activityMonitor"))?void 0:e.isActive;this._intendedDelay=e?xt:1e3}_scheduleReconnectWithBackoff(){var e=null==(e=$e.get("activityMonitor"))?void 0:e.isActive,e=(this._intendedDelay=e?Math.min(5e3,Math.max(xt,1.5*this._intendedDelay)):Math.min(3e5,Math.max(1e3,1.5*this._intendedDelay)),(new Date).toTimeString().slice(0,8)),e=Lt+`.scheduleReconnectWithBackoff timeStr: ${e} intendedDelay: `+this._intendedDelay;bt.debug(e),this.reconnect(),dt.updateTaskInterval(Ut,this._intendedDelay)}_ssoLog(e){var{method:e,message:t}=e;bt.info(e,t)}_diagnose(){this.isPrivateNetWork()||(this._lastDiagnoseAt=Date.now(),function(t){C(this,void 0,void 0,function*(){var e=t.split("/")[2];if(e.startsWith("ws")){e=`https://${e}/v3/netcheck/getconninfo?${t.slice(t.indexOf("info?")+5)}&reqtime=`+Date.now();try{yield Me({method:"GET",url:e,data:{}})}catch(e){bt.warn("diagnoseBySSO","diagnoseBySSO failed. error:"+e.message)}}})}(this._url),function(t){C(this,void 0,void 0,function*(){var e=`https://boce-cdn.my-imcloud.com/v3/netcheck/getconninfo?${t.slice(t.indexOf("info?")+5)}&reqtime=`+Date.now();try{yield Me({method:"GET",url:e,data:{}})}catch(e){bt.warn("diagnoseByCDN', 'diagnoseByCDN failed. error:"+e.message)}})}(this._url),this._beforeSendInterceptors=[])}_clearTimeoutRequest(){for(var[e,t]of this._pendingRequests.entries()){var{reject:t,timestamp:s,timeout:n}=t;Date.now()-s>=n&&(this._pendingRequests.delete(e),3e4<=Date.now()-this._lastDiagnoseAt&&this._diagnose(),t({errorCode:Ie,errorInfo:"NETWORK_TIMEOUT",data:{requestId:e}}))}}_updateIsBinarySupported(){var e;(null!=(e=$e.get("instance"))&&e.devMode||(e=Se(),x)||k&&"windows"===e||$)&&(this._isBinarySupported=!1)}_isCompressedData(e){e=new Uint8Array(e);return 67===e[0]&&79===e[1]&&77===e[2]&&80===e[3]}};let Qt={init:function(e){$e.set("instance",e),Jt.init()},destroy:function(){Jt.dispose(),$e.clear(),dt.dispose()},notificationCenter:v,channel:Jt,store:$e,ssoLog:bt,utils:Re,common:It,constants:h},es=e=>"function"==typeof e;function ts(t,s,n){let i=n||[];var e,r;return!(!t||!s)&&(e=Object.keys(t).filter(e=>!i.includes(e)),r=Object.keys(s).filter(e=>!i.includes(e)),e.length===r.length)&&e.every(e=>!!s.hasOwnProperty(e)&&("object"==typeof t[e]&&null!==t[e]?ts(t[e],s[e],n):t[e]===s[e]))}!function(e){e.SDK_READY="sdkStateReady",e.SDK_NOT_READY="sdkStateNotReady",e.SDK_DESTROY="sdkDestroy",e.MESSAGE_RECEIVED="onMessageReceived",e.ROOM_CUSTOM_DATA_RECEIVED="onRoomCustomDataReceived",e.MESSAGE_MODIFIED="onMessageModified",e.MESSAGE_REVOKED="onMessageRevoked",e.MESSAGE_READ_BY_PEER="onMessageReadByPeer",e.MESSAGE_READ_RECEIPT_RECEIVED="onMessageReadReceiptReceived",e.MESSAGE_EXTENSIONS_UPDATED="onMessageExtensionsUpdated",e.MESSAGE_EXTENSIONS_DELETED="onMessageExtensionsDeleted",e.MESSAGE_REACTIONS_UPDATED="onMessageReactionsUpdated",e.CONVERSATION_LIST_UPDATED="onConversationListUpdated",e.TOTAL_UNREAD_MESSAGE_COUNT_UPDATED="onTotalUnreadMessageCountUpdated",e.CONVERSATION_GROUP_LIST_UPDATED="onConversationGroupListUpdated",e.CONVERSATION_IN_GROUP_UPDATED="onConversationInGroupUpdated",e.GROUP_LIST_UPDATED="onGroupListUpdated",e.GROUP_ATTRIBUTES_UPDATED="groupAttributesUpdated",e.GROUP_COUNTER_UPDATED="onGroupCounterUpdated",e.TOPIC_CREATED="onTopicCreated",e.TOPIC_DELETED="onTopicDeleted",e.TOPIC_UPDATED="onTopicUpdated",e.PROFILE_UPDATED="onProfileUpdated",e.USER_STATUS_UPDATED="onUserStatusUpdated",e.BLACKLIST_UPDATED="blacklistUpdated",e.FRIEND_LIST_UPDATED="onFriendListUpdated",e.FRIEND_GROUP_LIST_UPDATED="onFriendGroupListUpdated",e.FRIEND_APPLICATION_LIST_UPDATED="onFriendApplicationListUpdated",e.MY_FOLLOWERS_LIST_UPDATED="onMyFollowersListUpdated",e.MY_FOLLOWING_LIST_UPDATED="onMyFollowingListUpdated",e.MUTUAL_FOLLOWERS_LIST_UPDATED="onMutualFollowersListUpdated",e.KICKED_OUT="kickedOut",e.ERROR="error",e.NET_STATE_CHANGE="netStateChange",e.ALL_RECEIVE_MESSAGE_OPT_UPDATED="onAllReceiveMessageOptUpdated",e.SERVER_CONFIG_UPDATED="onServerConfigUpdated",e.PINNED_GROUP_MESSAGE_UPDATED="onPinnedGroupMessageUpdated"}(ss=ss||{});var ns,is=ss;!function(e){e.LOGOUT="logout",e.DESTROY="destroy",e.CLOUD_CONFIG_UPDATE="cloud_config_update",e.PROFILE_UPDATE="profile_updated",e.ERROR="error",e.RECONNECTED="reconnected",e.FORCE_OFFLINE="im_open_status.stat_forceoffline",e.COMMERCIAL_CONFIG_PUSH="im_sdk_config_mgr.push_imsdk_purchase_bitsv2",e.OVERLOAD_PUSH="OverLoadPush.notify2",e.NEW_MESSAGE="new_message",e.MESSAGE_PUSH="im_open_push.msg_push",e.MESSAGE_DELETED="message_deleted",e.MESSAGE_REVOKED="message_revoked",e.MESSAGE_MODIFIED="message_modified",e.SOCKET_DISCONNECTED="socket_disconnected",e.CONVERSATION_UPDATED="conversation_updated",e.TOPIC_MESSAGE_DELETED="topic_message_deleted",e.TOPIC_MESSAGE_REVOKED="topic_message_revoked",e.TOPIC_MESSAGE_MODIFIED="topic_message_modified",e.TOPIC_NEW_MESSAGE="topic_new_message",e.QUALITY_STAT="quality_stat",e.SYNC_CONVERSATION_LIST="sync_conversation_list"}(ns=ns||{});var os,us,_s,rs=ns,as=(!function(e){e.NEW_INVITATION_RECEIVED="newInvitationReceived",e.INVITEE_ACCEPTED="ts_invitee_accepted",e.INVITEE_REJECTED="ts_invitee_rejected",e.INVITATION_CANCELLED="ts_invitation_cancelled",e.INVITATION_TIMEOUT="ts_invitation_timeout",e.INVITATION_MODIFIED="ts_invitation_modified"}(os=os||{}),os);let cs=Object.assign({},{KICKED_OUT_MULT_ACCOUNT:"multipleAccount",KICKED_OUT_MULT_DEVICE:"multipleDevice",KICKED_OUT_USERSIG_EXPIRED:"userSigExpired",KICKED_OUT_REST_API:"REST_API_Kick"}),ls={MSG_TEXT:"TIMTextElem",MSG_IMAGE:"TIMImageElem",MSG_AUDIO:"TIMSoundElem",MSG_FILE:"TIMFileElem",MSG_FACE:"TIMFaceElem",MSG_VIDEO:"TIMVideoFileElem",MSG_LOCATION:"TIMLocationElem",MSG_GRP_TIP:"TIMGroupTipElem",MSG_GRP_SYS_NOTICE:"TIMGroupSystemNoticeElem",MSG_CUSTOM:"TIMCustomElem",MSG_MERGER:"TIMRelayElem"},ds=(!function(e){e.UNSENT="unSend",e.SUCCESS="success",e.FAIL="fail"}(us=us||{}),{modify:rs.MESSAGE_MODIFIED,delete:rs.MESSAGE_DELETED,revoke:rs.MESSAGE_REVOKED}),hs=(!function(e){e[e.FORWARD=0]="FORWARD",e[e.BACKWARD=1]="BACKWARD"}(_s=_s||{}),Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},ls),{MSG_PRIORITY_HIGH:"High",MSG_PRIORITY_NORMAL:"Normal",MSG_PRIORITY_LOW:"Low",MSG_PRIORITY_LOWEST:"Lowest"}),{RECEIVE_WITH_OFFLINE_PUSH_EXCEPT_AT:"AcceptNotNotifyExceptAt",NOT_RECEIVE_OFFLINE_PUSH_EXCEPT_AT:"AcceptNotNotifyExceptAt",NOT_RECEIVE_MSG_EXCEPT_AT:"NotReceiveMsgExceptAt",MSG_AT_ALL:"__kImSDK_MesssageAtALL__"}),{MSG_REMIND_ACPT_AND_NOTE:"AcceptAndNotify",MSG_REMIND_ACPT_NOT_NOTE:"AcceptNotNotify",MSG_REMIND_DISCARD:"Discard"}),{MessageStatus:us,Direction:_s})),gs={[ds.modify]:rs.TOPIC_MESSAGE_MODIFIED,[ds.delete]:rs.TOPIC_MESSAGE_DELETED,[ds.revoke]:rs.TOPIC_MESSAGE_REVOKED},ps={GENDER_UNKNOWN:"Gender_Type_Unknown",GENDER_FEMALE:"Gender_Type_Female",GENDER_MALE:"Gender_Type_Male",USER_STATUS_UNKNOWN:0,USER_STATUS_ONLINE:1,USER_STATUS_OFFLINE:2,USER_STATUS_UNLOGINED:3,USER_NOT_FOUND:"@TLS#NOT_FOUND"},Es=Object.assign({},ps),fs={CONV_C2C:"C2C",CONV_GROUP:"GROUP",CONV_TOPIC:"TOPIC",CONV_SYSTEM:"@TIM#SYSTEM"},ms=Object.assign(Object.assign(Object.assign(Object.assign({},fs),{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}),{READ_ALL_C2C_MSG:"readAllC2CMessage",READ_ALL_GROUP_MSG:"readAllGroupMessage",READ_ALL_MSG:"readAllMessage"}),Ss=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},{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"}),{ALLOW_TYPE_ALLOW_ANY:"AllowType_Type_AllowAny",ALLOW_TYPE_NEED_CONFIRM:"AllowType_Type_NeedConfirm",ALLOW_TYPE_DENY_ANY:"AllowType_Type_DenyAny"}),{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"}),{FORBID_TYPE_NONE:"AdminForbid_Type_None",FORBID_TYPE_SEND_OUT:"AdminForbid_Type_SendOut"}),vs={GRP_WORK:"Private",GRP_PUBLIC:"Public",GRP_MEETING:"ChatRoom",GRP_AVCHATROOM:"AVChatRoom",GRP_COMMUNITY:"Community",GRP_ROOM:"Room",GRP_LIVE:"Live"},Is={COMMUNITY:"@TGS#_",TOPIC:"@TOPIC#_"},Cs={JOINED:1,QUITTED:2,KICKED:3,ADMIN_SET:4,ADMIN_CANCELED:5,GROUP_PROFILE_UPDATED:6,GROUP_MEMBER_PROFILE_UPDATED:7,TOPIC_PROFILE_UPDATED:8},Ts=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},vs),{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}),{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"}),{GROUP_ID_PREFIX:Is,GROUP_TIPS_OPERATION_TYPE:Cs}),Ms=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},cs),hs),Es),ms),Ss),Ts),{IOS_OFFLINE_PUSH_NO_SOUND:"push.no_sound",IOS_OFFLINE_PUSH_DEFAULT_SOUND:"default"}),{NET_STATE_CONNECTING:"connecting",NET_STATE_DISCONNECTED:"disconnected"}),Os={NO_SDKAPPID:2e3,NO_TINYID:2022,NO_A2KEY:2023,USER_NOT_LOGGED_IN:2024,REPEAT_LOGIN:2025,MSG_SEND_FAIL:2100,MSG_SEND_FAIL_NOT_IN_AV:2101,MSG_SEND_GRP_WITH_TOPIC_FAIL:2115,MSG_INSTANCE_REQUIRED:2105,MSG_INVALID_CONV_TYPE:2106,MSG_REVOKE_FAIL:2110,MSG_DELETE_FAIL:2111,MSG_UNREAD_ALL_FAIL:2112,READ_RECEIPT_MSG_LIST_EMPTY:2114,CANNOT_DELETE_GRP_SYSTEM_NOTICE:2116,NOT_MY_FRIEND:2700,NETWORK_ERROR:2800,NETWORK_TIMEOUT:2801,NO_NETWORK:2805,UNCAUGHT_ERROR:2903,INVALID_OPERATION:2905,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,NO_USE:3122,OPTIONS_IS_EMPTY:3153,MSG_A2KEY_EXPIRED:20002,ACCOUNT_A2KEY_EXPIRED:70001,HELLO_ANSWER_KICKED_OUT:1002,OPEN_SERVICE_OVERLOAD_ERROR:60022},ys={BASIC:"1",STANDARD:"2",PROFESSIONAL:"3"},As={SYNC_SERVER_INFO_AFTER_RE_ONLINE:"sync-server-info-after-re-online",SYNC_SERVER_INFO_AFTER_LOGIN:"sync-server-info-after-login",RECEIVE_C2C_NEW_MESSAGE:"receive-c2c-new-message",RECEIVE_GROUP_NEW_MESSAGE:"receive-group-new-message",RECEIVE_GROUP_TIPS_NOTIFICATION:"receive-group-tips-notification"},Ns={USER_STATUS_UPDATE:"user-status-update",CONVERSATION_RECOVER:"conversation-recover",HISTORY_MESSAGE_RECOVER:"history-message-recover",BLACKLIST_RECOVER:"blacklist-recover",FRIEND_RECOVER:"friend-recover",GROUP_ATTRIBUTE_CACHE_CLEAR:"group-attribute-cache-clear",UNREAD_MESSAGE_RECOVER:"unread-message-recover",HANDLE_NEW_MESSAGE:"handle-new-message",HANDLE_CONVERSATION_PROFILE_UPDATED:"handle-conversation-profile-updated",COMMERCIAL_CONFIG_UPDATE:"commercial-config-update",UNREAD_MESSAGE_SYNC:"unread-message-sync",FRIEND_AND_BLACKLIST_SYNC:"friend-and-blacklist-sync",SIGNALING_MESSAGE_RECOVER:"signaling-message-recover",GROUP_LIST_SYNC:"group-list-sync",CONVERSATION_LIST_SYNC:"conversation-list-sync",USER_PROFILE_SYNC:"user-profile-sync",CONVERSATION_UPDATE_AFTER_UNREAD_SYNC_FINISHED:"conversation-update-after-unread-sync-finished",CONVERSATION_UPDATE_AFTER_GROUP_LIST_SYNC_FINISHED:"conversation-update-after-group-list-sync-finished",HANDLE_C2C_NEW_MESSAGE:"handle-c2c-new-message",HANDLE_GROUP_NEW_MESSAGE:"handle-group-new-message",CREATE_OR_UPDATE_CONVERSATION_BY_RECEIVE_NEW_MESSAGE:"create-or-update-conversation-by-receive-new-message",HANDLE_GROUP_TIPS_FROM_SYNC_UNREAD:"handle-group-tips-from-sync-unread",HANDLE_C2C_REVOKED_MESSAGE_FROM_SYNC_UNREAD:"handle-c2c-revoked-message-from-sync-unread",GROUP_REVOKED_NOTICE_RECOVER:"group-revoked-notice-recover",CLOUD_CONFIG_SYNC:"cloud-config-sync",UPDATE_GROUP_NEXT_SEQUENCE:"update-group-next-sequence",EMIT_C2C_MESSAGE_EVENT:"emit-c2c-message-event",EMIT_GROUP_MESSAGE_EVENT:"emit-group-message-event",CONVERSATION_GROUP_LIST_SYNC:"conversation-group-list-sync",CONVERSATION_GROUP_UPDATE:"conversation-group-update",UPDATE_TOPIC_AFTER_UNREAD_SYNC_FINISHED:"update-topic-after-unread-sync-finished",UPDATE_TOPIC_BY_RECEIVE_NEW_MESSAGE:"update-topic-by-received-new-message",TOPIC_REQUEST_INFO_RESET:"topic-request-info-reset",QUALITY_REPORT:"quality-report",GROUP_TIPS_RECOVER:"group-tips-recover",HANDLE_GROUP_TIPS_NOTIFICATION:"handle-group-tips-notification"},Rs={[As.SYNC_SERVER_INFO_AFTER_RE_ONLINE]:[{stepId:Ns.USER_STATUS_UPDATE},{stepId:Ns.GROUP_ATTRIBUTE_CACHE_CLEAR},{stepId:Ns.UNREAD_MESSAGE_SYNC},{stepId:Ns.CONVERSATION_RECOVER},{stepId:Ns.HISTORY_MESSAGE_RECOVER,dependency:Ns.CONVERSATION_RECOVER},{stepId:Ns.BLACKLIST_RECOVER},{stepId:Ns.FRIEND_RECOVER},{stepId:Ns.GROUP_REVOKED_NOTICE_RECOVER,dependency:Ns.HISTORY_MESSAGE_RECOVER},{stepId:Ns.GROUP_TIPS_RECOVER,dependency:Ns.HISTORY_MESSAGE_RECOVER},{stepId:Ns.TOPIC_REQUEST_INFO_RESET},{stepId:Ns.HANDLE_C2C_REVOKED_MESSAGE_FROM_SYNC_UNREAD,dependency:Ns.UNREAD_MESSAGE_SYNC},{stepId:Ns.HANDLE_GROUP_TIPS_FROM_SYNC_UNREAD,dependency:Ns.UNREAD_MESSAGE_SYNC},{stepId:Ns.CONVERSATION_UPDATE_AFTER_UNREAD_SYNC_FINISHED,dependency:[Ns.UNREAD_MESSAGE_SYNC,Ns.CONVERSATION_RECOVER]},{stepId:Ns.EMIT_C2C_MESSAGE_EVENT,dependency:[Ns.UNREAD_MESSAGE_SYNC,Ns.CONVERSATION_UPDATE_AFTER_UNREAD_SYNC_FINISHED],skipIfDependencyMissing:!1}],[As.SYNC_SERVER_INFO_AFTER_LOGIN]:[{stepId:Ns.COMMERCIAL_CONFIG_UPDATE},{stepId:Ns.CLOUD_CONFIG_SYNC},{stepId:Ns.USER_PROFILE_SYNC},{stepId:Ns.UNREAD_MESSAGE_SYNC},{stepId:Ns.FRIEND_AND_BLACKLIST_SYNC},{stepId:Ns.GROUP_LIST_SYNC},{stepId:Ns.CONVERSATION_LIST_SYNC},{stepId:Ns.SIGNALING_MESSAGE_RECOVER,dependency:Ns.UNREAD_MESSAGE_SYNC},{stepId:Ns.UPDATE_TOPIC_AFTER_UNREAD_SYNC_FINISHED,dependency:[Ns.UNREAD_MESSAGE_SYNC]},{stepId:Ns.CONVERSATION_UPDATE_AFTER_UNREAD_SYNC_FINISHED,dependency:[Ns.UNREAD_MESSAGE_SYNC,Ns.CONVERSATION_LIST_SYNC]},{stepId:Ns.CONVERSATION_UPDATE_AFTER_GROUP_LIST_SYNC_FINISHED,dependency:[Ns.GROUP_LIST_SYNC,Ns.CONVERSATION_LIST_SYNC]},{stepId:Ns.CONVERSATION_GROUP_LIST_SYNC},{stepId:Ns.CONVERSATION_GROUP_UPDATE,dependency:[Ns.CONVERSATION_LIST_SYNC,Ns.CONVERSATION_GROUP_LIST_SYNC]},{stepId:Ns.QUALITY_REPORT}],[As.RECEIVE_C2C_NEW_MESSAGE]:[{stepId:Ns.HANDLE_C2C_NEW_MESSAGE},{stepId:Ns.UNREAD_MESSAGE_SYNC},{stepId:Ns.CREATE_OR_UPDATE_CONVERSATION_BY_RECEIVE_NEW_MESSAGE,dependency:Ns.HANDLE_C2C_NEW_MESSAGE},{stepId:Ns.EMIT_C2C_MESSAGE_EVENT,dependency:[Ns.HANDLE_C2C_NEW_MESSAGE,Ns.CREATE_OR_UPDATE_CONVERSATION_BY_RECEIVE_NEW_MESSAGE],skipIfDependencyMissing:!1},{stepId:Ns.CONVERSATION_UPDATE_AFTER_UNREAD_SYNC_FINISHED,dependency:[Ns.UNREAD_MESSAGE_SYNC]}],[As.RECEIVE_GROUP_NEW_MESSAGE]:[{stepId:Ns.HANDLE_GROUP_NEW_MESSAGE},{stepId:Ns.CREATE_OR_UPDATE_CONVERSATION_BY_RECEIVE_NEW_MESSAGE,dependency:Ns.HANDLE_GROUP_NEW_MESSAGE},{stepId:Ns.UPDATE_GROUP_NEXT_SEQUENCE,dependency:Ns.HANDLE_GROUP_NEW_MESSAGE},{stepId:Ns.UPDATE_TOPIC_BY_RECEIVE_NEW_MESSAGE,dependency:Ns.HANDLE_GROUP_NEW_MESSAGE},{stepId:Ns.EMIT_GROUP_MESSAGE_EVENT,dependency:[Ns.HANDLE_GROUP_NEW_MESSAGE,Ns.CREATE_OR_UPDATE_CONVERSATION_BY_RECEIVE_NEW_MESSAGE],skipIfDependencyMissing:!1}],[As.RECEIVE_GROUP_TIPS_NOTIFICATION]:[{stepId:Ns.HANDLE_GROUP_TIPS_NOTIFICATION},{stepId:Ns.CREATE_OR_UPDATE_CONVERSATION_BY_RECEIVE_NEW_MESSAGE,dependency:Ns.HANDLE_GROUP_TIPS_NOTIFICATION}]},Ds={MESSAGE_SEND_SUCCESS_RATE:"messageSendSuccessRate"},Ps={TOTAL_COUNT:"sendMessageTotalCount",SUCCESS_COUNT:"sendMessageSuccessCount",FAILED_COUNT:"sendMessageFailedCount",SEND_COST:"sendMessageCost"},bs=["login","getMyProfile","getUserProfile","updateMyProfile","setSelfStatus","getUserStatus","subscribeUserStatus","unsubscribeUserStatus","modifyMessage","deleteGroupMember","dismissGroup","getGroupMemberList","getGroupOnlineMemberCount","joinGroup","markGroupMemberList","quitGroup","searchCloudMessages","searchCloudGroups","searchCloudGroupMembers","searchCloudUsers","getMyFollowingList","getMyFollowersList","getMutualFollowersList","followUser","unfollowUser","getUserFollowInfo","checkFollowType","getFriendProfile","addFriend","deleteFriend","updateFriend","checkFriend","setFriendApplicationRead","createFriendGroup","deleteFriendGroup","addToFriendGroup","removeFromFriendGroup","renameFriendGroup","changeGroupOwner","createGroup","dismissGroup","getGroupList","getGroupOnlineMemberCount","getGroupProfile","searchGroupByID","updateGroupProfile","handleGroupApplication","deleteGroupAttributes","getGroupAttributes","initGroupAttributes","setGroupAttributes","addGroupMember","deleteGroupMember","getGroupMemberList","getGroupMemberProfile","setGroupMemberMuteTime","setGroupMemberNameCard","setGroupMemberRole","deleteMessage","revokeMessage","setMessageExtensions","getMessageExtensions","deleteMessageExtensions","getMessageList","addMessageReaction","removeMessageReaction","clearHistoryMessage","invite","accept","cancel","reject","modifyInvitation","deleteConversation","pinConversation","setMessageRead","setAllMessageRead","getConversationList","getTotalUnreadMessageCount","renameConversationGroup","deleteConversationGroup","markConversation","setConversationCustomData","deleteConversationsFromGroup","addConversationsToGroup","createConversationGroup"];var Ls,ks,Us,ws=Object.freeze({__proto__:null,ERROR_CODE:Os,InnerEvent:rs,NEED_LOG_API:bs,OuterConstant:Ms,OuterEvent:is,QUALITY_METRICS:Ds,SDK_EDITION:ys,SDK_INFO:{VERSION:"1.7.3",APPID:537048168},SEND_MESSAGE_STAT:Ps,SignalingEvent:as,WORKFLOW_DEFINITIONS:Rs,WORKFLOW_NAME:As,WORKFLOW_STEP:Ns});!function(e){e[e.USER_INITIATED=0]="USER_INITIATED",e[e.KICKED_OUT=1]="KICKED_OUT"}(Ls=Ls||{}),function(e){e[e.multipleAccount=1]="multipleAccount",e[e.multipleDevice=2]="multipleDevice",e[e.restApi=3]="restApi"}(ks=ks||{}),function(e){e[e.multipleDevice=3002]="multipleDevice",e[e.multipleAccount=3003]="multipleAccount",e[e.usersigExpired=70001]="usersigExpired",e[e.restApi=20002]="restApi"}(Us=Us||{});let Gs={[ks.multipleAccount]:"multipleAccount",[ks.multipleDevice]:"multipleDevice",[ks.restApi]:"REST_API_Kick",[Us.multipleAccount]:"multipleAccount",[Us.multipleDevice]:"multipleDevice",[Us.restApi]:"REST_API_Kick",[Us.usersigExpired]:"userSigExpired"},Fs="login_online_presence_task",{ERROR:Bs,DESTROY:xs,FORCE_OFFLINE:Vs}=rs,{KICKED_OUT_MULT_ACCOUNT:$s,KICKED_OUT_MULT_DEVICE:qs,KICKED_OUT_REST_API:Ws,ACCOUNT_A2KEY_EXPIRED:Ys,MSG_A2KEY_EXPIRED:Ks}=Os;class Hs{init(){var e=Qt["notificationCenter"];e.subscribeInnerEvent(Vs,this._handleForceOfflineFromServerPush,this),e.subscribeInnerEvent(Bs,Ks,this._handleForceOfflineFromResponse,this),e.subscribeInnerEvent(Bs,Ys,this._handleForceOfflineFromResponse,this),e.subscribeInnerEvent(Bs,$s,this._handleForceOfflineFromResponse,this),e.subscribeInnerEvent(Bs,qs,this._handleForceOfflineFromResponse,this),e.subscribeInnerEvent(Bs,Ws,this._handleForceOfflineFromResponse,this),e.subscribeInnerEvent(xs,this._dispose,this)}_handleForceOfflineFromServerPush(e){var{EventArray:e=[]}=(null==e?void 0:e.body)||{};this._extractKickedOutMessages(e).forEach(e=>{var{KickType:e,NewInstInfo:t}=e["KickoutMsgNotify"];this._processKickedOutReasonInfo({kickedOutReasonCode:e,newInstanceInfo:t})})}_extractKickedOutMessages(e){return e.reduce((e,t)=>[...e,...t.C2cNotifyMsgArray||[]],[]).filter(e=>{return this._isKickedOut(null==(e=null==e?void 0:e.KickoutMsgNotify)?void 0:e.KickType)})}_handleForceOfflineFromResponse(e){e=e.errorCode;this._processKickedOutReasonInfo({kickedOutReasonCode:e})}_processKickedOutReasonInfo(n){return C(this,void 0,void 0,function*(){var e=n["kickedOutReasonCode"],{ssoLog:t,utils:{safeStringify:s}}=Qt;try{this._logKickedOutEvent(n),yield Qt.login.loginAction.logout(Ls.KICKED_OUT)}catch(e){t.debug("_processKickedOutReasonInfo"," fail "+s(e))}finally{Qt.notificationCenter.emitOuterEvent(is.KICKED_OUT,{data:{type:Gs[e]},name:is.KICKED_OUT}),[ks.restApi,Ys,Ks].includes(e)&&Qt.channel.reconnect()}})}_logKickedOutEvent(e){var{kickedOutReasonCode:e,newInstanceInfo:t={}}=e,e=`type:${Gs[e]} newInstanceInfo: `+JSON.stringify(t);Qt.ssoLog.warn("kickedOut",e)}_isKickedOut(e){return[ks.multipleAccount,ks.multipleDevice,ks.restApi].includes(e)}_dispose(){var e=Qt["notificationCenter"];e.unSubscribeInnerEvent(Vs,this._handleForceOfflineFromServerPush,this),e.unSubscribeInnerEvent(Bs,Ys,this._handleForceOfflineFromResponse,this),e.unSubscribeInnerEvent(Bs,Ks,this._handleForceOfflineFromResponse,this),e.unSubscribeInnerEvent(Bs,$s,this._handleForceOfflineFromResponse,this),e.unSubscribeInnerEvent(Bs,qs,this._handleForceOfflineFromResponse,this),e.unSubscribeInnerEvent(Bs,Ws,this._handleForceOfflineFromResponse,this),e.unSubscribeInnerEvent(xs,this._dispose,this)}}function js(n){return C(this,void 0,void 0,function*(){let e="im_open_status.wslogin",t=Qt.common.generateProtocolData({servcmd:e,data:{State:"Online",is_web_uniapp:0,InstType:0,CustomInfo:n}}),s=""+t.head.seq+e,_=yield Qt.channel.sendPacket(t,{timeout:9e4,requestId:s});if(_){let{HelloInterval:e,InstId:t,TinyId:s,TimeStamp:n,CustomStatus:i,PurchaseBits:r,A2Key:o,RichMsgAuthKey:a,ErrorCode:l,ErrorInfo:c,ActionStatus:u}=_;return{helloInterval:e,instanceID:t,tinyID:s,timeStamp:n,customStatus:i,purchaseBits:r,a2Key:o,authKey:a,errorCode:l,errorInfo:c,actionStatus:u}}})}function zs(t){var s;try{var n=$e.getStorage("errorMessage");if(!t||!n)return"";var i=(null==(s=JSON.parse(n))?void 0:s.errorMessage)||{},{isIntl:r=!1,code:o,replacement1:a="",replacement2:l=""}=t;if(!o)return"";var c=r?o+"_en":o+"_cn";let e=i[i[c]?c:o]||"";return e=e&&(a&&(e=e.replace("$replacement1",a)),l)?e.replace("$replacement2",l):e}catch(t){return console.warn("Error parsing stored error messages:",t),""}}class Zs extends Error{constructor(e){var{functionName:t="Unknown",code:s,message:n="",data:i="",moreMessage:r=""}=e;let o=n;s&&!n&&(o=zs(e));n=(s?`${t} failed. error: {"message": ${o}, "code": ${s}}`:`${t} failed. error: {"message": ${o}}`)+" "+r;super(),this.code=s,this.errorCode=s,this.errorMessage=n,this.message=n,this.data=i}}function Xs(e,t){if(e&&!0!==(null==(e=Qt.store.get("login"))?void 0:e.isLoggedIn))throw new Zs({code:Os.USER_NOT_LOGGED_IN,functionName:t})}function Js(t,s,n){if(Array.isArray(t))for(let e=0;e<t.length;e++)Qs.call(this,Object.assign(Object.assign({},t[e]),{value:s[e],name:n}));else for(var e in t)Qs.call(this,Object.assign(Object.assign({},t[e]),{value:s[0][e],name:n,key:e}))}function Qs({required:e,rules:n,value:t,allowEmpty:i,name:r,key:o,customValidator:a}){if(void 0===t){if(e)throw new Zs({functionName:r,message:`[${r}] Missing required params: "${o}"`})}else{let s="";if(!n.some(e=>{return e===Object.prototype.toString.call(t).match(/^\[object (.*)\]$/)[1].toLowerCase()})){for(let t=0;t<n.length;t++){let e=n[t];e=e.replace(e[0],e[0].toUpperCase()),s+=e+"/"}let e=`[${o}] must be type of ${s=s.substring(0,s.length-1)}, received type: ${Reflect.apply(Object.prototype.toString,t,[]).replace(/^\[object\s(\w+)\]$/,"$1").toLowerCase()}.`;throw new Zs({functionName:r,message:e})}if(!1===i){if(Array.isArray(t)&&(0===t.length||"string"==typeof t[0]&&""===t[0].trim()))throw new Zs({functionName:r,message:o+" can not be empty."});if("string"==typeof t&&""===t.trim())throw new Zs({functionName:r,message:o+" can not be empty."})}if(a&&"function"==typeof a){let e=a(t);if(!0!==e)throw new Zs({functionName:r,message:`[${o}] custom validation failed: `+(e||"Invalid value")})}}}let en=[],tn={},sn={};function nn(e,t){var s;Xs(tn[e],e),Js(sn[e],t,e),s=e,en.forEach(e=>{var{interceptor:e,context:t}=e;e.apply(t,[s])})}function on(e,t){en.push({interceptor:e,context:t})}function rn(e){var{params:e,auth:t}=e;e&&"object"==typeof e&&Object.assign(sn,e),t&&"object"==typeof t&&Object.assign(tn,t)}function an(e){return Qt.store.get("commercialConfig").get(e)}class cn{constructor(){this._handlers=new Map,this._activeWorkflows=new Map,this._stepStartTimes=new Map,this._logHandlers={start:(e,t)=>{var s=Date.now();t?(this._stepStartTimes.set(e+"-"+t,s),Qt.ssoLog.debug("_executeWorkflowStep",`[Workflow ${e}] Step ${t} started at `+new Date(s).toISOString())):(this._workflowStartTimes.set(e,s),Qt.ssoLog.debug("_executeWorkflowStep",`[Workflow ${e}] started at `+new Date(s).toISOString()))},success:(s,e)=>{var n=Date.now();if(e){var t=this._stepStartTimes.get(s+"-"+e),t=t?n-t:0;this._stepStartTimes.delete(s+"-"+e),Qt.ssoLog.debug("_executeWorkflowStep",`[Workflow ${s}] Step ${e} completed successfully at ${new Date(n).toISOString()} (${t}ms)`)}else{let e=this._workflowStartTimes.get(s),t=e?n-e:0;this._workflowStartTimes.delete(s),Qt.ssoLog.debug("_executeWorkflowStep",`[Workflow ${s}] completed successfully at ${new Date(n).toISOString()} (${t}ms)`)}},error:(s,e,n)=>{var{ssoLog:i,utils:{safeStringify:r}}=Qt,o=Date.now();if(e){var t=this._stepStartTimes.get(s+"-"+e),t=t?o-t:0;this._stepStartTimes.delete(s+"-"+e),i.error("_executeWorkflowStep",`[Workflow ${s}] Step ${e} failed at ${new Date(o).toISOString()} (${t}ms) `+r(n),{error:n})}else{let e=this._workflowStartTimes.get(s),t=e?o-e:0;this._workflowStartTimes.delete(s),i.error("_executeWorkflowStep",`[Workflow ${s}] failed at ${new Date(o).toISOString()} (${t}ms) `+r(n),{error:n})}}}}static getInstance(){return cn._instance||(cn._instance=new cn),cn._instance}static setInstance(e){cn._instance=e}init(){this._initializeWorkflows()}registerWorkflowStep(e,t,s,n){var i;this._handlers.has(e)?Rs[e].find(e=>e.stepId===t)?(i=this._handlers.get(e)).has(t)||i.set(t,n?s.bind(n):s):Qt.ssoLog.debug("registerWorkflowStep",`Step '${t}' not defined in workflow '${e}'`):Qt.ssoLog.debug("registerWorkflowStep",`Workflow '${e}' not defined in core`)}executeWorkflow(o,s){return C(this,void 0,void 0,function*(){if(this._validateWorkflow(o)){Qt.ssoLog.debug("executeWorkflow",`[Workflow ${o}] Started execution at `+(new Date).toISOString());let e=Rs[o],r={cancelled:!1};this._activeWorkflows.set(o,{cancelToken:r});try{let t=new Map,i=(e.forEach(e=>{t.set(e.stepId,e)}),{workflowName:o,pendingSteps:new Set(e.map(e=>e.stepId)),completedSteps:new Set,runningSteps:new Set,stepMap:t,stepResults:{},data:s,cancelToken:r});yield new Promise((t,s)=>{let n=()=>{r.cancelled?t():this._getExecutableSteps({pendingSteps:i.pendingSteps,completedSteps:i.completedSteps,stepMap:i.stepMap,workflowName:o}).filter(e=>!i.runningSteps.has(e)).forEach(e=>{i.completedSteps.has(e)||i.runningSteps.has(e)||this._executeWorkflowStep(e,i,{onComplete:()=>{0===i.pendingSteps.size?t():0===this._getExecutableSteps({pendingSteps:i.pendingSteps,completedSteps:i.completedSteps,stepMap:i.stepMap,workflowName:o}).filter(e=>!i.runningSteps.has(e)).length&&0===i.runningSteps.size&&(Qt.ssoLog.debug("executeWorkflow",`Workflow ${o} completed with some steps skipped due to dependency failures`),t())},onError:s,onStepComplete:n})})};n()}),Qt.ssoLog.debug("executeWorkflow",`[Workflow ${o}] Completed execution at `+(new Date).toISOString())}catch(e){Qt.ssoLog.error("executeWorkflow",`[Workflow ${o}] Failed execution at `+(new Date).toISOString(),{error:e})}finally{this._activeWorkflows.delete(o)}}})}_executeWorkflowStep(a,l,c){return C(this,void 0,void 0,function*(){let{workflowName:r,runningSteps:e,stepMap:s,stepResults:n,data:i}=l;e.add(a),this._logWorkflowExecution(r,a,"start");try{let e=s.get(a),t=null;null!=e&&e.dependency&&(M(e.dependency)?t=n[e.dependency]:Array.isArray(e.dependency)&&(t={},e.dependency.forEach(e=>{t[e]=n[e]})));var o=this._handlers.get(r).get(a);if(o){let e=yield Promise.resolve(o({data:i,result:t}));n[a]=e,this._logWorkflowExecution(r,a,"success")}l.completedSteps.add(a)}catch(e){let t=`[Workflow].${r}.`+a,{errorCode:s,errorInfo:n=t+" failed"}=e||{},i=new Zs({functionName:t,code:s,message:n});Qt.ssoLog.error(t,n,{error:i}),this._logWorkflowExecution(r,a,"error",e),c.onError(e)}finally{e.delete(a),l.pendingSteps.delete(a),c.onStepComplete(),c.onComplete()}})}reset(){this._cancelAllWorkflows()}destroy(){this.reset(),this._handlers.clear()}_initializeWorkflows(){Object.keys(Rs).forEach(e=>{this._handlers.has(e)||this._handlers.set(e,new Map)})}_cancelWorkFlow(e){var t=this._activeWorkflows.get(e);t&&(t=t["cancelToken"],t.cancelled=!0,this._activeWorkflows.delete(e))}_cancelAllWorkflows(){Object.keys(Rs).forEach(e=>{this._cancelWorkFlow(e)})}_validateWorkflow(e){return!!Rs[e]&&!!this._handlers.get(e)}_getExecutableSteps(e){let{pendingSteps:t,completedSteps:s,stepMap:n,workflowName:i}=e;return Array.from(t).filter(e=>{var{dependency:t,skipIfDependencyMissing:e=!0}=n.get(e)||{};if(!t)return!0;if(M(t))return this._isStepRegistered({workflowName:i,stepId:t})?s.has(t):!e;if(y(t)){if(0<t.filter(e=>!this._isStepRegistered({workflowName:i,stepId:e})).length&&e)return!1;for(let e of t)if(!s.has(e))return!1;return!0}return!1})}_isStepRegistered(e){var{workflowName:e,stepId:t}=e;return null==(e=this._handlers.get(e))?void 0:e.has(t)}_logWorkflowExecution(e,t,s,n){this._logHandlers[s](e,t)}}let ln=new Map,un=({type:e,groupID:t})=>e===Ms.GRP_COMMUNITY||(""+t).startsWith(Is.COMMUNITY)&&!(""+t).includes(Is.TOPIC),dn=(e="")=>{e=e.startsWith("GROUP")?e.replace("GROUP",""):e;return e.startsWith(Is.COMMUNITY)&&(""+e).includes(Is.TOPIC)},_n="openim",hn="million_group_open_http_svc";function gn(s){return C(this,void 0,void 0,function*(){var{servcmd:e,data:t}=pn(e=s.data)||En(e)?function(e){let{servcmd:t,data:s}=e;var n,i,r;return En(s)?({servcmd:e,data:n}=e,{GroupId:i=""}=n,[i]=(r=i).split(Is.TOPIC),{servcmd:fn(e),data:Object.assign(Object.assign({},n),{GroupId:i,TopicId:r})}):{servcmd:t=pn(s)?fn(t):t,data:s}}(s):s,t=Qt.common.generateProtocolData({servcmd:e,data:t}),e=""+t.head.seq+e;return Qt.channel.sendPacket(t,{requestId:e})})}function pn(e){var{Type:e,GroupId:t,GroupIdList:s=[]}=e,t=t||s[0]||"";return un({type:e,groupID:t})}function En(e){var{GroupId:e=""}=e;return dn(e)}function fn(e){return e.includes(_n)?e:(e=e.split(".")[1],hn+"."+e)}function mn(){var e;return null==(e=Qt.store.get("login"))?void 0:e.userId}let Sn=e=>y(e)||A(e),vn=(s,n,i,r)=>{if(!Sn(s)||!Sn(n))return 0;let o=0;var a,l=Object.keys(n);for(let e=0,t=l.length;e<t;e++)if(a=l[e],!(T(n[a])||i&&i.includes(a)))if(Sn(s[a])&&Sn(n[a]))o+=vn(s[a],n[a],i,r);else{if(r&&r.includes(n[a]))continue;s[a]!==n[a]&&(s[a]=n[a],o+=1)}return o},In=(e,t)=>{if(T(t))return"";switch(e){case Ms.MSG_TEXT:return t.text||"";case Ms.MSG_IMAGE:return"[Image]";case Ms.MSG_LOCATION:return"[Location]";case Ms.MSG_AUDIO:return"[Voice]";case Ms.MSG_VIDEO:return"[Video]";case Ms.MSG_FILE:return"[File]";case Ms.MSG_CUSTOM:return"[Custom Messages]";case Ms.MSG_GRP_TIP:return"[Group Notification]";case Ms.MSG_GRP_SYS_NOTICE:return"[Group System Message]";case Ms.MSG_FACE:return"[Animated Sticker]";case Ms.MSG_MERGER:return"[Chat Record]";default:return""}},Cn=[{cmd:"ws_get_user_status",interval:5,count:20},{cmd:"ws_status_subscribe",interval:5,count:20},{cmd:"ws_status_unsubscribe",interval:5,count:20},{cmd:"get_group_self_member_info",interval:5,count:20},{cmd:"modify_group_base_info",interval:1,count:8},{cmd:"get_pendency",interval:1,count:15},{cmd:"set_group_attr",interval:5,count:10},{cmd:"modify_group_attr",interval:5,count:10},{cmd:"delete_group_attr",interval:5,count:10},{cmd:"clear_group_attr",interval:5,count:10},{cmd:"get_group_attr",interval:5,count:20},{cmd:"update_group_counter",interval:5,count:20},{cmd:"get_group_counter",interval:5,count:20},{cmd:"get_topic",interval:1,count:10},{cmd:"read_all_unread_msg",interval:1,count:1},{cmd:"query",interval:5,count:20}],Tn="im_sdk_config_mgr.fetch_config",Mn="im_sdk_config_mgr.push_configv2",On="cloud-config",yn=2996,An=new class{init(e){this.core=e}};function Nn(s){return C(this,void 0,void 0,function*(){var e=(An.core.store.get("instance")||{})["sdkAppId"],e=An.core.helper.generateProtocolData({servcmd:Tn,data:{uint32_sdkappid:e,uint64_version:s}}),t=""+e.head.seq+Tn;return An.core.channel.sendPacket(e,{requestId:t})})}var Rn=new class{constructor(){this._core=null,this._expirationTime=0,this._version=0,this._isFetching=!1,this._cmdFrequencyLimitMap=new Map,this._methodCallFrequencyMap=new Map}install(e){var{notificationCenter:e,InnerEvent:t,helper:s,constants:{WORKFLOW_NAME:n,WORKFLOW_STEP:i},channel:r}=this._core=e;e.subscribeInnerEvent(Mn,this._handlePushedConfig,this),s.registerWorkflowStep(n.SYNC_SERVER_INFO_AFTER_LOGIN,i.CLOUD_CONFIG_SYNC,this._handleLoginSuccess,this),e.subscribeInnerEvent(t.LOGOUT,this._reset,this),e.subscribeInnerEvent(t.DESTROY,this._dispose,this),s.registerExperimentalAPI("getServerConfig",this),this._updateCmdFreqLimitMap(Cn),r.registerBeforeSendInterceptor(this.checkMethodCallOverLimit,this)}getServerConfig(s){return C(this,void 0,void 0,function*(){var e,t={code:0,data:""};return s&&(t.data=(null==(e=this._core.store.get("cloudConfig"))?void 0:e[s])||""),t})}checkMethodCallOverLimit(e){if(this._cmdFrequencyLimitMap.has(e))if(this._methodCallFrequencyMap.has(e)){var{count:t,interval:s}=this._cmdFrequencyLimitMap.get(e),{startTime:n,methodCallCounter:i}=this._methodCallFrequencyMap.get(e);if(Date.now()-n>1e3*s)this._methodCallFrequencyMap.set(e,{startTime:Date.now(),methodCallCounter:1});else if(this._methodCallFrequencyMap.set(e,{startTime:n,methodCallCounter:i+=1}),t<i)throw new this._core.helper.ChatError({code:yn,replacement1:e})}else this._methodCallFrequencyMap.set(e,{startTime:Date.now(),methodCallCounter:1})}_handlePushedConfig(s){return C(this,void 0,void 0,function*(){var{ssoLog:e,utils:{safeStringify:t}}=this._core;e.info("_handlePushedConfig",t(s)),yield this._updateCloudConfig(s)})}_handleLoginSuccess(){return C(this,void 0,void 0,function*(){var e,{ssoLog:t,utils:{safeStringify:s}}=this._core;try{this._canFetch()&&(e=yield Nn(this._version),t.info("_fetchCloudConfigIfLogin",s(e)),yield this._updateCloudConfig(e)),this._core.helper.taskScheduler.addTask({id:On,intervalMs:1e3,callback:this._fetchCloudConfigIfReady,context:this})}catch(e){t.error("_fetchCloudConfigIfLogin",s(e))}})}_fetchCloudConfigIfReady(){return C(this,void 0,void 0,function*(){var{ssoLog:t,utils:{safeStringify:s}}=this._core;if(this._canFetch())try{var e=yield Nn(this._version);t.info("_fetchCloudConfigIfReady",s(e)),yield this._updateCloudConfig(e)}catch(e){t.error("_fetchCloudConfigIfReady",s(e))}})}_updateCloudConfig(t){return C(this,void 0,void 0,function*(){var e=this._parseCloudConfig(t);e&&(this._core.store.set("cloudConfig",e),yield this._parseCmdFreqLimit(),this._core.notificationCenter.emitInnerEvent(this._core.InnerEvent.CLOUD_CONFIG_UPDATE,e),this._core.notificationCenter.emitOuterEvent(this._core.OuterEvent.SERVER_CONFIG_UPDATED,{name:this._core.OuterEvent.SERVER_CONFIG_UPDATED,data:{config:e}}))})}_canFetch(){var e=(this._core.store.get("login")||{})["isLoggedIn"];return e&&!this._isFetching&&Date.now()>=this._expirationTime}_parseCloudConfig(e){var{int32_error_code:t,str_json_config:s,uint32_expired_time:n,uint64_version:i}=e;let r=null;if(0===t){if(this._version!==i)try{r=JSON.parse(s),this._version=i}catch(e){}this._expirationTime=Date.now()+1e3*n}else this._expirationTime=void 0===t?Date.now()+36e5:Date.now()+12e4;return r}_parseCmdFreqLimit(){return C(this,void 0,void 0,function*(){var e,t=null==(e=yield this.getServerConfig("cmd_frequency_limit"))?void 0:e.data,s=this._core.utils["isEmpty"];if(!s(t))try{t=JSON.parse(t),this._updateCmdFreqLimitMap(t)}catch(e){console.warn(e)}})}_updateCmdFreqLimitMap(e){e.forEach(e=>{this._cmdFrequencyLimitMap.set(e.cmd,{interval:e.interval,count:e.count})})}_reset(){this._core.helper.taskScheduler.removeTask(On),this._core.store.clear("cloudConfig"),this._updateCmdFreqLimitMap(Cn),this._methodCallFrequencyMap.clear(),this._expirationTime=0,this._version=0,this._isFetching=!1}_dispose(){var{notificationCenter:e,InnerEvent:t}=this._core;e.unSubscribeInnerEvent(Mn,this._handlePushedConfig,this),e.unSubscribeInnerEvent(t.LOGOUT,this._reset,this),e.unSubscribeInnerEvent(t.DESTROY,this._dispose,this),this._reset()}};class Dn{constructor(e=0,t=0){this.high=e,this.low=t}equal(e){return null!==e&&this.low===e.low&&this.high===e.high}toString(){var e=Number(this.high).toString(16);let t=Number(this.low).toString(16);if(t.length<8){let e=8-t.length;for(;e;)t="0"+t,e--}return e+t}}let Pn={SEARCH_GRP_SNS:new Dn(0,Math.pow(2,1)).toString(),AV_HISTORY_MSG:new Dn(0,Math.pow(2,2)).toString(),GRP_COMMUNITY:new Dn(0,Math.pow(2,3)).toString(),MSG_TO_SPECIFIED_GRP_MBR:new Dn(0,Math.pow(2,4)).toString(),AV_MBR_LIST:new Dn(0,Math.pow(2,6)).toString(),USER_STATUS:new Dn(0,Math.pow(2,7)).toString(),CONV_MARK:new Dn(0,Math.pow(2,9)).toString(),CONV_GROUP:new Dn(0,Math.pow(2,10)).toString(),AV_BAN_MBR:new Dn(0,Math.pow(2,11)).toString(),MSG_EXT:new Dn(0,Math.pow(2,13)).toString(),GRP_COUNTER:new Dn(0,Math.pow(2,15)).toString(),PLUGIN_TRANSLATE:new Dn(Math.pow(2,6)).toString(),PLUGIN_VOICE_TO_TEXT:new Dn(Math.pow(2,7)).toString(),PLUGIN_CS:new Dn(Math.pow(2,8)).toString(),PLUGIN_PUSH:new Dn(Math.pow(2,9)).toString(),PLUGIN_BOT:new Dn(Math.pow(2,10)).toString(),MSG_REACTION:new Dn(Math.pow(2,16)).toString(),FOLLOW:new Dn(Math.pow(2,20)).toString()},bn="CommercialConfig",wn="commercial-config";var Bn,xn,Ln=new class{constructor(){this._core=null,this._expirationTime=0,this._isFetching=!1,this._featureMap=new Map,this._methodKeyMap=new Map,this._purchaseBits="0"}install(e){var{helper:t,notificationCenter:s,constants:{WORKFLOW_NAME:n,WORKFLOW_STEP:i,InnerEvent:r}}=this._core=e;s.subscribeInnerEvent(r.COMMERCIAL_CONFIG_PUSH,this._handlePushedConfig,this),s.subscribeInnerEvent(r.LOGOUT,this._handleLogout,this),s.subscribeInnerEvent(r.DESTROY,this._dispose,this),t.registerWorkflowStep(n.SYNC_SERVER_INFO_AFTER_LOGIN,i.COMMERCIAL_CONFIG_UPDATE,this._syncCommercialConfig,this),e.helper.registerExperimentalAPI("isCommercialAbilityEnabled",this),e.helper.registerExperimentalAPI("queryCommercialAbility",this)}isCommercialAbilityEnabled(e){return C(this,void 0,void 0,function*(){var s=parseInt(e,10).toString(2),n=s["length"];let i,r=!0;for(let e=n-1,t=0;0<=e;e--,t++)if("1"===s.charAt(e)&&(i=(t<32?new Dn(0,2**t):new Dn(2**(t-32),0)).toString(),!this._featureMap.get(i))){r=!1;break}return this._core.ssoLog.debug("isFeatureEnabled",`${bn}.isFeatureEnabled decimalNumber:${e} key:${i} ret:`+r),{code:0,data:{enabled:r}}})}queryCommercialAbility(){return this._purchaseBits}_fetchAndParseCommercialConfig(){return C(this,void 0,void 0,function*(){let s,{ssoLog:e,helper:n,utils:{safeStringify:t}}=this._core;try{this._isFetching=!0;let e=n.generateProtocolData({servcmd:"im_sdk_config_mgr.fetch_imsdk_purchase_bitsv2",data:{uint32_sdkappid:null==(s=this._core.store.get("instance"))?void 0:s.sdkAppId}}),t=yield this._core.channel.sendPacket(e);null!=t&&t.body&&(this._parseCommercialConfig(t.body),this._core.store.set("commercialConfig",this._methodKeyMap))}catch(s){e.error("_fetchAndParseCommercialConfig",t(s))}finally{this._isFetching=!1}})}_syncCommercialConfig(t){return C(this,void 0,void 0,function*(){var e=((null==t?void 0:t.data)||{})["purchaseBits"];e&&(this._parsePurchaseBits(e),this._core.store.set("commercialConfig",this._methodKeyMap)),this._canFetch()&&(yield this._fetchAndParseCommercialConfig()),this._core.helper.taskScheduler.addTask({id:wn,intervalMs:1e3,callback:this._fetchCommercialConfigIfReady,context:this})})}_canFetch(){var e=null==(e=this._core.store.get("login"))?void 0:e.isLoggedIn,t=Date.now()>=this._expirationTime;return e&&!this._isFetching&&t}_handlePushedConfig(e){null!=e&&e.body&&(this._parseCommercialConfig(e.body),this._core.store.set("commercialConfig",this._methodKeyMap))}_fetchCommercialConfigIfReady(){return C(this,void 0,void 0,function*(){this._canFetch()&&(yield this._fetchAndParseCommercialConfig())})}_parseCommercialConfig(e){var t,s,n,i,r=this._core["ssoLog"];"object"==typeof e&&({int32_error_code:t,str_error_message:s,str_purchase_bits:n,uint32_expired_time:i}=e,0===t?(this._parsePurchaseBits(n),this._expirationTime=Date.now()+1e3*i):void 0===t?(r.warn("_parseCommercialConfig",bn+"._parseCommercialConfig failed. Invalid message format:",e),this._expirationTime=Date.now()+36e5):(r.warn("_parseCommercialConfig",bn+`._parseCommercialConfig errorCode:${t} errorMessage:`+s),this._expirationTime=Date.now()+12e4))}_isValidPurchaseBits(e){return e&&"string"==typeof e&&1<=e.length&&e.length<=64&&/[01]{1,64}/.test(e)}_parsePurchaseBits(s){var{ssoLog:e,utils:{safeStringify:t}}=this._core;if(this._isValidPurchaseBits(s)){this._purchaseBits=s,this._featureMap.clear(),this._methodKeyMap.clear();var n;for(let e=s.length-1,t=0;0<=e;e--,t++)if(n=(t<32?new Dn(0,2**t):new Dn(2**(t-32),0)).toString(),"1"===s[e]){this._featureMap.set(n,!0);let e=this._getKeyByValue(Pn,n);e&&this._methodKeyMap.set(e,!0)}else{this._featureMap.set(n,!1);let e=this._getKeyByValue(Pn,n);e&&this._methodKeyMap.set(e,!1)}}else e.warn("_parsePurchaseBits",bn+".parsePurchaseBits invalid purchases:"+t(s))}_getKeyByValue(e,t){e=Object.entries(e).find(([,e])=>e===t);return e?e[0]:void 0}_handleLogout(){this._reset()}_dispose(){this._reset(),this._core.notificationCenter.unSubscribeInnerEvent(this._core.InnerEvent.COMMERCIAL_CONFIG_PUSH,this._handlePushedConfig,this),this._core.notificationCenter.unSubscribeInnerEvent(this._core.InnerEvent.LOGOUT,this._reset,this),this._core.notificationCenter.unSubscribeInnerEvent(this._core.InnerEvent.DESTROY,this._dispose,this)}_reset(){this._core.helper.taskScheduler.removeTask(wn),this._core.store.set("commercialConfig",{}),this._expirationTime=0,this._isFetching=!1,this._featureMap.clear(),this._purchaseBits="0"}},kn=new class{constructor(){this._core=null,this._serverOverloadInfoMap=new Map}install(e){this._core=e;var{notificationCenter:e,InnerEvent:t,channel:s}=this._core;e.subscribeInnerEvent(t.OVERLOAD_PUSH,this._handleOverLoadPush,this),e.subscribeInnerEvent(t.LOGOUT,this._reset,this),e.subscribeInnerEvent(t.DESTROY,this._dispose,this),s.registerBeforeSendInterceptor(this.checkServerOverload,this)}checkServerOverload(e){if(this._serverOverloadInfoMap.has(e)){var{overloadStartTimestamp:t,delaySeconds:s}=this._serverOverloadInfoMap.get(e);if(Date.now()-t<=1e3*s)throw new this._core.helper.ChatError({functionName:e,message:"service is busy, please try again later"});this._serverOverloadInfoMap.delete(e)}}_handleOverLoadPush(e){var{OverLoadServCmd:e,DelaySecs:t}=e;this._serverOverloadInfoMap.set(e,{overloadStartTimestamp:Date.now(),delaySeconds:t})}_reset(){this._serverOverloadInfoMap.clear()}_dispose(){this._reset();var{notificationCenter:e,InnerEvent:t}=this._core;e.unSubscribeInnerEvent(t.OVERLOAD_PUSH,this._handleOverLoadPush,this),e.unSubscribeInnerEvent(t.LOGOUT,this._reset,this),e.unSubscribeInnerEvent(t.DESTROY,this._dispose,this)}},Un=new class{constructor(){this.name="ConfigCenter"}install(e){An.init(e),Rn.install(e),Ln.install(e),kn.install(e)}},Gn=new class{constructor(){this.name="ErrorMessage",this._core=null}install(e){return C(this,void 0,void 0,function*(){if(this._core=e,this._canFetch()){let e=yield this._fetchErrorMessage();var t;e&&(t=this._parseResponse(e),this._saveErrorMessage(t))}})}_canFetch(){var e=this._core.store.getStorage("errorMessage");return!e||this._isExpired(e)}_saveErrorMessage(e){this._core.store.setStorage("errorMessage",{errorMessage:e,errorMessageSavedTime:(new Date).getTime()})}_fetchErrorMessage(){return C(this,void 0,void 0,function*(){try{return yield this._core.helper.httpRequest({method:"GET",url:"https://web.sdk.qcloud.com/im/download/error-message/v3/0.0.6/tim-error-message.txt"})}catch(e){console.error(e)}})}_isExpired(e){return!e||(e=e["errorMessageSavedTime"],e&&6048e5<=(new Date).getTime()-e)}_parseResponse(e){if("string"==typeof e){var s=e.split(";\n"),n={},i=new RegExp(/'/g);for(let t=0;t<s.length;t++){var r=s[t].indexOf(":"),o=s[t].slice(0,r);let e=s[t].slice(r+1);o.startsWith("//")||""!==e&&(e=e.replace(i,""),n[o]=e)}return n}}};function Fn(i,l){return C(this,void 0,void 0,function*(){let{cookie:e,syncFlag:t,syncTriggerEvent:s}=i,n="openim.getmsg",o=l.helper.generateProtocolData({servcmd:n,data:{Cookie:e,SyncFlag:t,IsOnlineSync:s,NeedAbstract:1,NeedSignaling:1,NeedCachedMsg:1}}),a=""+o.head.seq+n;try{let e=yield l.channel.sendPacket(o,{requestId:a});if(!e)return null;let{C2CPairUnreadCount:t,C2CRemainingUnreadCount:s,EventArray:n}=e,{unreadMessageList:i,revokedMessageList:r}=function(e,v){let n=[],i=[];return null!=e&&e.forEach(S=>{var e,t,s=function(){var{From_Account:e,From_AccountHeadurl:t,From_AccountNick:s,IsNeedReadReceipt:n,MsgBody:i,MsgClientTime:r,MsgRandom:o,MsgSeq:a,MsgTimeStamp:l,SendMsgControl:c,SupportMessageExtension:u,To_Account:_,TinyId:d,MsgCheckResult:h,CloudCustomData:g,IsPeerRead:p,MsgFlagBits:E,MsgVersion:m,EventArray:f}=S;return{from:e,avatar:t,nick:s,needReadReceipt:1===n,readReceiptSentByPeer:p,clientTime:r,messageFlagBits:E,random:o,sequence:a,time:l,messageControlInfo:c,isSupportExtension:u,to:_,tinyID:d,checkResult:h,cloudCustomData:g,messageVersion:m,eventArray:f,elements:v.message.messageHelper.parseServerPushMessageElement(i)}}();if(null!=(t=null==(e=null==(e=null==S?void 0:S.EventArray)?void 0:e[0])?void 0:e.hasOwnProperty)&&t.call(e,"C2cNotifyMsgArray"))i.push(...function(){let e,t=[];return null!=(e=S.EventArray)&&e.forEach(e=>{var e=e["C2cNotifyMsgArray"],e=null==(e=null==(e=null==e?void 0:e[0])?void 0:e.WithdrawC2cMsgNotify)?void 0:e.C2cWithdrawInfoArray;Array.isArray(e)&&t.push(...e)}),t}());else{let e=v.message.messageFactory.createMessage(Object.assign(Object.assign({},s),{conversationType:"C2C",flow:"in"})),t=s["elements"];e.setElement(t),n.push(e)}}),{unreadMessageList:n,revokedMessageList:i}}(e.MsgList,l);return{syncFlag:null==e?void 0:e.SyncFlag,unreadMessageList:i,revokedMessageList:r,unreadCountList:t,overflowUnreadCountList:s,cookie:null==e?void 0:e.Cookie,groupTipList:n}}catch(e){console.warn(e)}})}!function(e){e[e.START_SYNC=0]="START_SYNC",e[e.SYNCING=1]="SYNCING",e[e.SYNC_COMPLETE=2]="SYNC_COMPLETE"}(Bn=Bn||{}),function(e){e[e.LOGIN_SUCCESS=0]="LOGIN_SUCCESS",e[e.NEW_MESSAGE_RECEIVED=1]="NEW_MESSAGE_RECEIVED"}(xn=xn||{});var Vn=new class{constructor(){this.name="UnreadMessageSynchronizer",this._unreadDBMessageMap=new Map,this._cookie=""}install(e){var t=(this._core=e)["constants"];e.helper.registerWorkflowStep(t.WORKFLOW_NAME.SYNC_SERVER_INFO_AFTER_RE_ONLINE,t.WORKFLOW_STEP.UNREAD_MESSAGE_SYNC,this._syncUnreadDBMessageAfterReOnline,this),e.helper.registerWorkflowStep(t.WORKFLOW_NAME.RECEIVE_C2C_NEW_MESSAGE,t.WORKFLOW_STEP.UNREAD_MESSAGE_SYNC,this._syncUnreadDBMessageAfterNewMessageReceived,this),e.helper.registerWorkflowStep(t.WORKFLOW_NAME.SYNC_SERVER_INFO_AFTER_LOGIN,t.WORKFLOW_STEP.UNREAD_MESSAGE_SYNC,this._syncUnreadDBMessageAfterLogin,this),e.notificationCenter.subscribeInnerEvent(e.InnerEvent.LOGOUT,this._reset,this),e.notificationCenter.subscribeInnerEvent(e.InnerEvent.DESTROY,this._dispose,this)}_syncUnreadMessage(t){return C(this,void 0,void 0,function*(){let{isAfterReOnline:o=!1,isAfterNewMessageReceived:a=!1,isAfterLogin:e=!1}=t||{},l=Bn.START_SYNC;for(var c=[],u=[],_=[],d=[];this._canContinueSync({cookie:this._cookie,syncFlag:l});){let e=yield this._fetchUnreadDBMessage({cookie:this._cookie,syncFlag:l,syncTriggerEvent:a?xn.NEW_MESSAGE_RECEIVED:xn.LOGIN_SUCCESS});if(!e)break;let{unreadMessageList:t=[],revokedMessageList:s=[],overflowUnreadCountList:n,unreadCountList:i,groupTipList:r}=e;if(this._cookie=(null==e?void 0:e.cookie)||"",l=null==e?void 0:e.syncFlag,this._parseAndSaveUnreadMessageList(t),_.push(...s),this._updateConversationUnreadOptions({unreadCountList:i,overflowUnreadCountList:n,conversationUpdateFieldList:c}),Array.isArray(r)&&u.push(...r),o){let e=this._handleNewMessageList(t)["messages"];d.push(...e)}}return o?{conversationUpdateFieldList:c,revokedMessageList:_,unreadMessageMap:this._unreadDBMessageMap,groupTipList:u,messages:d}:{conversationUpdateFieldList:c,isInstantMessage:!e,isUnreadC2CMessage:!0,revokedMessageList:_,unreadMessageMap:this._unreadDBMessageMap,groupTipList:u}})}_syncUnreadDBMessageAfterLogin(){return C(this,void 0,void 0,function*(){return this._cookie="",this._syncUnreadMessage({isAfterLogin:!0})})}_syncUnreadDBMessageAfterNewMessageReceived(e){return C(this,void 0,void 0,function*(){if(1===e.data.Flag)return this._syncUnreadMessage({isAfterNewMessageReceived:!0})})}_updateConversationUnreadOptions(e){let{unreadCountList:t,overflowUnreadCountList:s,conversationUpdateFieldList:n}=e,{OuterConstant:{CONV_C2C:i,CONV_SYSTEM:r}}=this._core["constants"];null!=t&&t.forEach(e=>{let{From_Account:t,UnreadCount:s}=e;if(t!==r){let e=n.find(({conversationID:e})=>e===""+i+t);e?e.unreadCount=s:n.push({conversationID:""+i+t,unreadCount:s,type:i})}}),null!=s&&s.forEach(e=>{let{From_Account:t,LastMsgTime:s}=e;t===r||n.find(({conversationID:e})=>e===""+i+t)||n.push({conversationID:""+i+t,type:i,lastMsgTime:s})})}_syncUnreadDBMessageAfterReOnline(){return C(this,void 0,void 0,function*(){return this._syncUnreadMessage({isAfterReOnline:!0})})}_updateMessageProfile(n){var e;let i=(this._core.message||{})["messageDataHandler"],t=null==(e=this._core.store.get("login"))?void 0:e.userId,{from:s,nick:r,avatar:o,conversationID:a=""}=n;if(s!==t){let s=i.getLatestMsgSentByPeer(a);if(s){let{nick:e,avatar:t}=s;r&&o?r===e&&o===t||i.updateNickAndAvatarOfSentMessage({conversationID:a,latestNick:r,latestAvatar:o,isSentByMe:!1}):(n.nick=e,n.avatar=t)}}else{let e=i.getLatestMsgSentByMe(a);!e||r===e.nick&&o===e.avatar||i.updateNickAndAvatarOfSentMessage({conversationID:a,latestNick:r,latestAvatar:o,isSentByMe:!0})}}_handleNewMessageList(e){let t=(this._core.message||{})["messageDataHandler"],l=new Map,s=[];return e.forEach(a=>{this._updateMessageProfile(a);let e=1===a.isModified;if(t.isMessageSentByCurrentInstance(a)?a.isModified=e:e=!1,a.isOnlineMessage())a._onlineOnlyFlag=!0,t.isMessageSentByCurrentInstance(a)||s.push(a);else if(!t.isInMessageList(a)){if(t.storeConversationMessage(a)){let{conversationID:e,conversationType:t,conversationSubType:s,flow:n,_isExcludedFromUnreadCount:i,_isExcludedFromLastMessage:r}=a,o=r?"":a;l.has(e)?(l.get(e).lastMessage=o,"in"!==n||i||l.get(e).unreadCount++):l.set(e,{conversationID:e,type:t,subType:s,unreadCount:i||"in"!==n?0:1,lastMessage:o})}t.isMessageSentByCurrentInstance(a)&&!e||s.push(a)}}),{messages:s,conversationOptions:l}}_fetchUnreadDBMessage(u){return C(this,void 0,void 0,function*(){var{ssoLog:e,utils:{safeStringify:t}}=this._core;try{e.debug("_fetchUnreadDBMessage","unread-message-synchronizer._fetchUnreadDBMessage options:"+t(u));var s,n,i,r,o,a,l,c=yield Fn(u,this._core);return c?({syncFlag:s,unreadMessageList:n,revokedMessageList:i,cookie:r,unreadCountList:o,overflowUnreadCountList:a,groupTipList:l}=c,this._parseAndSaveUnreadMessageList(n),{syncFlag:s,cookie:r,unreadMessageList:n,revokedMessageList:i,unreadCountList:o,overflowUnreadCountList:a,groupTipList:l}):null}catch(e){console.log(e)}})}_canContinueSync({cookie:e,syncFlag:t}){return t===Bn.START_SYNC||t===Bn.SYNCING&&!(null!=(t=this._core)&&t.helper.isEmpty(e))}_parseAndSaveUnreadMessageList(e){e.forEach(e=>{var t=e["ID"];this._unreadDBMessageMap.set(t,e)})}_reset(){this._cookie="",this._unreadDBMessageMap.clear()}_dispose(){var e;null!=(e=this._core)&&e.notificationCenter.unSubscribeInnerEvent(this._core.InnerEvent.LOGOUT,this._reset,this),null!=(e=this._core)&&e.notificationCenter.unSubscribeInnerEvent(this._core.InnerEvent.DESTROY,this._dispose,this),this._reset()}},$n=new class{init(e){this._core=e,this._visibilityChangeHandler=this._handleVisibilityChange.bind(this),e.notificationCenter.subscribeInnerEvent(e.InnerEvent.DESTROY,this._dispose,this),null!==document&&void 0!==document&&document.addEventListener("visibilitychange",this._visibilityChangeHandler),null!=(e=this._core)&&e.store.set("activityMonitor",{isActive:!0})}_handleVisibilityChange(){var e,t="visible"===document.visibilityState;null!=(e=this._core)&&e.store.set("activityMonitor",{isActive:t}),null!=(e=this._core)&&e.notificationCenter.emitInnerEvent("activityStatusChange",{isActive:t})}_reset(){var e;null!=(e=this._core)&&e.store.clear("activityMonitor")}_dispose(){document.removeEventListener("visibilitychange",this._visibilityChangeHandler);var{notificationCenter:e,InnerEvent:t}=this._core;e.unSubscribeInnerEvent(t.DESTROY,this._dispose,this),this._reset()}},qn=new class{init(e){this._core=e,this._bindAppActivityEvent(),e.notificationCenter.subscribeInnerEvent(e.InnerEvent.DESTROY,this._dispose,this),null!=(e=this._core)&&e.store.set("activityMonitor",{isActive:!0})}_bindAppActivityEvent(){var e=((null==(e=this._core)?void 0:e.utils)||{})["MINI_APP_NAMESPACE"];e.onAppShow(()=>{var e;null!=(e=this._core)&&e.store.set("activityMonitor",{isActive:!0}),null!=(e=this._core)&&e.notificationCenter.emitInnerEvent("activityStatusChange",{isActive:!0})}),e.onAppHide(()=>{var e;null!=(e=this._core)&&e.store.set("activityMonitor",{isActive:!1}),null!=(e=this._core)&&e.notificationCenter.emitInnerEvent("activityStatusChange",{isActive:!1})})}_reset(){var e;null!=(e=this._core)&&e.store.clear("activityMonitor")}_dispose(){var{notificationCenter:e,InnerEvent:t}=this._core;e.unSubscribeInnerEvent(t.DESTROY,this._dispose,this),this._reset()}},Wn=new class{init(e){var{IN_WX_MINI_APP:t,IN_WX_MINI_PLUGIN:s}=e.helper;s||(t?qn:$n).init(e)}};let Yn="none",Kn="online";var Hn=new class{init(e){this._core=e,this._activateNetworkMonitoring(),e.notificationCenter.subscribeInnerEvent(e.InnerEvent.DESTROY,this._dispose,this)}_activateNetworkMonitoring(){return C(this,void 0,void 0,function*(){navigator.onLine?this._onOnline():this._onOffline(),this._onOnlineCallback=this._onOnline.bind(this),this._onOfflineCallback=this._onOffline.bind(this),window.addEventListener("online",this._onOnlineCallback),window.addEventListener("offline",this._onOfflineCallback)})}_deactivateNetworkMonitoring(){null!==this._onOnlineCallback&&(window.removeEventListener("online",this._onOnlineCallback),this._onOnlineCallback=null),null!==this._onOfflineCallback&&(window.removeEventListener("offline",this._onOfflineCallback),this._onOfflineCallback=null)}_onNetworkStatusChange(e){var t,{isConnected:e,networkType:s}=e;null!=(t=this._core)&&t.store.set("netWorkMonitor",{isNetworkOnline:e,networkType:s}),null!=(t=this._core)&&t.notificationCenter.emitInnerEvent("networkStatusChange",{isNetworkOnline:e,networkType:s})}_onOnline(){this._onNetworkStatusChange({isConnected:!0,networkType:Kn})}_onOffline(){this._onNetworkStatusChange({isConnected:!1,networkType:Yn})}_reset(){var e;this._deactivateNetworkMonitoring(),null!=(e=this._core)&&e.store.clear("netWorkMonitor")}_dispose(){var e;null!=(e=this._core)&&e.notificationCenter.unSubscribeInnerEvent(null==(e=this._core)?void 0:e.InnerEvent.DESTROY,this._dispose,this),this._reset()}},jn=new class{init(e){this._core=e,this._activateNetworkMonitoring(),e.notificationCenter.subscribeInnerEvent(e.InnerEvent.DESTROY,this._dispose,this)}_activateNetworkMonitoring(){return C(this,void 0,void 0,function*(){try{var{MINI_APP_NAMESPACE:e}=this._core["utils"];this._mpNetworkStatusCallback=this._onNetworkStatusChange.bind(this),e.onNetworkStatusChange(this._onNetworkStatusChange.bind(this))}catch(e){console.error(e)}})}_deactivateNetworkMonitoring(){var e;null!==this._mpNetworkStatusCallback&&({MINI_APP_NAMESPACE:e}=this._core["utils"],e.offNetworkStatusChange&&e.offNetworkStatusChange(this._mpNetworkStatusCallback),this._mpNetworkStatusCallback=null)}_onNetworkStatusChange(e){var t,{isConnected:e,networkType:s}=e;null!=(t=this._core)&&t.store.set("netWorkMonitor",{isNetworkOnline:e,networkType:s}),null!=(t=this._core)&&t.notificationCenter.emitInnerEvent("networkStatusChange",{isNetworkOnline:e,networkType:s})}_reset(){var e;this._deactivateNetworkMonitoring(),null!=(e=this._core)&&e.store.clear("netWorkMonitor")}_dispose(){var e;null!=(e=this._core)&&e.notificationCenter.unSubscribeInnerEvent(null==(e=this._core)?void 0:e.InnerEvent.DESTROY,this._dispose,this),this._reset()}},zn=new class{init(e){var t=e.utils["IN_MINI_APP"];(t?jn:Hn).init(e)}},Zn=new class{constructor(){this.name="SystemStateMonitor"}install(e){Wn.init(e),zn.init(e)}};let Xn=new Set(["tui_room_svr.*","callkit_records_svr.*","room_engine_srv.*","room_engine_http_srv.*","room_engine_mic.*","live_engine_srv.*","live_engine_http_srv.*","live_engine_pk.*","trtc_ai_service.*","call_engine_srv.*"]),Jn="tui_room_svr.*";var Qn=new class{constructor(){this.name="BusinessCommandTransfer",this._transferredCommands=Xn}install(e){var{notificationCenter:e,InnerEvent:t,helper:s}=this._core=e;e.subscribeInnerEvent(t.CLOUD_CONFIG_UPDATE,this._onCloudConfigUpdate,this),e.subscribeInnerEvent(t.LOGOUT,this._reset,this),e.subscribeInnerEvent(t.DESTROY,this._dispose,this),e.subscribeInnerEvent("im_open_push.msg_push",e.InnerEventSubType.BUSINESS_COMMAND,this._onServerPushBusinessCommand,this),s.registerExperimentalAPI("sendTRTCCustomData",this,"transferBusinessCommand"),s.registerExperimentalAPI("sendRoomCustomData",this,"transferBusinessCommand")}transferBusinessCommand(s){return C(this,void 0,void 0,function*(){var t="transferBusinessCommand";try{var{serviceCommand:e=Jn}=s||{};if(this._isValidTransferredCommand(e))return{code:0,data:(yield function(r,o){return C(this,void 0,void 0,function*(){var{helper:e,channel:t}=o,{serviceCommand:s=Jn,data:n}=r||{};let i={};try{i="string"==typeof n?JSON.parse(n):n}catch(e){console.warn(e)}n=e.generateProtocolData({servcmd:s,data:i}),e=""+n.head.seq+s;return t.sendPacket(n,{requestId:e})})}(s,this._core))||{}};throw new this._core.helper.ChatError({code:2995,functionName:t})}catch(e){throw console.warn(e),new this._core.helper.ChatError({code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo,data:{},functionName:t})}})}_onCloudConfigUpdate(e={}){try{var t;"string"==typeof e.rtc_cmd&&(t=JSON.parse(e.rtc_cmd),Array.isArray(t))&&(this._transferredCommands=new Set([...this._transferredCommands,...t]))}catch(e){console.log(e)}}_isValidTransferredCommand(e=""){e=`${null==e?void 0:e.split(".")[0]}.*`;return this._transferredCommands.has(e)}_onServerPushBusinessCommand(e){var{OuterEvent:t,notificationCenter:s}=this._core,e=(e||{})["MsgContent"],t=t["ROOM_CUSTOM_DATA_RECEIVED"];s.emitOuterEvent(t,{name:t,data:e})}_reset(){this._transferredCommands=Xn}_dispose(){var{notificationCenter:e,InnerEvent:t}=this._core;this._reset(),e.unSubscribeInnerEvent(t.CLOUD_CONFIG_UPDATE,this._onCloudConfigUpdate,this),e.unSubscribeInnerEvent(t.LOGOUT,this._reset,this),e.unSubscribeInnerEvent(t.DESTROY,this._dispose,this),e.unSubscribeInnerEvent("im_open_push.msg_push",e.InnerEventSubType.BUSINESS_COMMAND,this._onServerPushBusinessCommand,this)}};let ei=1,ti=300;var si=new class{constructor(){this.name="OfflineMessageSynchronizer",this._lastMessageSequenceMapOnDisconnect=new Map}install(e){var{common:{workflowManager:t},constants:{WORKFLOW_NAME:s,WORKFLOW_STEP:n,InnerEvent:i}}=this._core=e;t.registerWorkflowStep(s.SYNC_SERVER_INFO_AFTER_RE_ONLINE,n.HISTORY_MESSAGE_RECOVER,this._syncOfflineMessage,this),e.notificationCenter.subscribeInnerEvent(i.SOCKET_DISCONNECTED,this._updateLastMessageSequenceMapOnDisconnect,this)}_syncOfflineMessage(e){let t=((null==e?void 0:e.result)||{})["conversationList"],{OuterConstant:s,utils:{isArray:n}}=this._core;if(n(t)){let e=t.filter(e=>e.type===s.CONV_GROUP&&e.groupProfile.type!==s.GRP_AVCHATROOM);return this._recoverGroupHistoryMessage(e)}}_recoverGroupHistoryMessage(e){return C(this,void 0,void 0,function*(){let i=this._core["OuterConstant"],r=[],o=[];return yield Promise.all(null==e?void 0:e.map(n=>C(this,void 0,void 0,function*(){var{groupProfile:{groupID:e}={},lastMessage:{lastSequence:t}={}}=n,e=""+i.CONV_GROUP+e,s=this._getLocalLastMessageSequence(e);this._shouldRecoverHistory({localLastMessageSequence:s,serverLastMessageSequence:t})&&(yield this._recoverHistoryForConversation({conversationID:e,localLastMessageSequence:s,serverLastMessageSequence:t,groupTipList:o})),r.push(e.replace(i.CONV_GROUP,""))}))),{recoverRevokeNoticeGroupIDList:r,groupTipList:o}})}_recoverHistoryForConversation(e){return C(this,arguments,void 0,function*({conversationID:S,localLastMessageSequence:v,serverLastMessageSequence:I,groupTipList:C}){try{let{utils:{isArray:e,isObject:t,isEmpty:s},OuterEvent:n,OuterConstant:i,notificationCenter:r,message:o,appStore:a,common:{getMessagePreviewText:l}}=this._core,c=I-v,u=Math.min(20,c),_={},d=yield o.messageHistory.getGroupRoamingMessagesByAnchor({conversationID:S,sequence:v+u,direction:i.Direction.FORWARD,count:u}),{nextReqMessageIDFromServer:h,hasNoMoreHistoryMessage:g,messageList:p,serverGroupTipList:E}=d,m=(e(E)&&C.push(...E),g&&h<0),f=[];if(e(p)&&(p.forEach(e=>{o.messageReceiver.groupMessageReceiver.updateMessageProfile(e),e.from===i.CONV_SYSTEM&&(e.isSystemMessage=!1),o.messageDataHandler.storeConversationMessage(e)&&!s(e.payload)&&(f.push(e),e._isExcludedFromLastMessage||(_.lastMessage=Object.assign({},e)))}),0<f.length)&&r.emitOuterEvent(n.MESSAGE_RECEIVED,{name:n.MESSAGE_RECEIVED,data:f}),!m&&0<p.length){let e=p[p.length-1].sequence;yield this._recoverHistoryForConversation({conversationID:S,localLastMessageSequence:e,serverLastMessageSequence:I,groupTipList:C})}t(_.lastMessage)&&(_.lastMessage.messageForShow=l(_.lastMessage.type,_.lastMessage.payload),a.conversationStore.updateConversation(S,_))}catch(v){this._core.ssoLog.error("_recoverHistoryForConversation","Recovery failed for conversation:"+S,{error:v})}})}_updateLastMessageSequenceMapOnDisconnect(){let e=this._core["message"],n=e.messageDataHandler.getContinuousMessagesByConversation();for(let[t,s]of n)if(!t.startsWith("C2C")){let e=Array.from(s.values());var i;0<(null==e?void 0:e.length)&&(i=e[e.length-1].sequence,this._lastMessageSequenceMapOnDisconnect.set(t,i))}}_getLocalLastMessageSequence(e){var t=this._core["message"];return this._lastMessageSequenceMapOnDisconnect.has(e)?this._lastMessageSequenceMapOnDisconnect.get(e):null==(e=(t=t.messageDataHandler.getLocalMessageList(e))[t.length-1])?void 0:e.sequence}_shouldRecoverHistory(e){var t,{localLastMessageSequence:e,serverLastMessageSequence:s}=e;return"number"==typeof e&&"number"==typeof s&&(t=s-e,0!==s)&&0<e&&t>=ei&&t<ti}};let ni=ys.STANDARD,ii=[];ni=ys.BASIC,ii=[Gn,Un,Vn,Zn,Qn,si];var oi=Object.freeze({__proto__:null,ChatError:Zs,WorkflowManager:cn,buildAndSendPacket:gn,get builtInPlugins(){return ii},checkBusinessCapabilityBits:an,deepMerge:vn,getCurrentUserID:mn,getErrorMessage:zs,getMessagePreviewText:In,isC2CConv:e=>M(e)&&e.slice(0,3)===fs.CONV_C2C,isCommunity:un,isGroupConv:e=>M(e)&&e.slice(0,5)===fs.CONV_GROUP,isTopic:dn,isUnlimitedAVChatRoom:function(){var e;return!(null==(e=Qt.store.get("instance"))||!e.unlimitedAVChatRoom)},liteChatInstanceMap:ln,registerInterceptor:on,registerValidateConfig:rn,requireAuth:Xs,get sdkEdition(){return ni},updateGroupAtInfo:(t,s)=>{var{CONV_AT_ME:n,CONV_AT_ALL:i,CONV_AT_ALL_AT_ME:r}=Ms;if(!function(t,e){let{CONV_AT_ME:s,CONV_AT_ALL:n,CONV_AT_ALL_AT_ME:i}=Ms,{groupID:r,sequence:o}=t,a=!1;return un({groupID:r})&&e.forEach(e=>{e.messageSequence===o&&(e.atTypeArray.includes(s)&&t.groupAtType.includes(n)&&(e.atTypeArray=[i]),e.atTypeArray.includes(n)&&t.groupAtType.includes(s)&&(e.atTypeArray=[i],e.__random=t.__random,e.__sequence=t.__sequence),a=!0)}),a}(t,s)){let e=[...t.groupAtType];e.includes(n)&&e.includes(i)&&(e=[r]);n={from:t.from,groupID:t.groupID,topicID:t.topicID,messageSequence:t.sequence,atTypeArray:e,__random:t.__random,__sequence:t.__sequence};s.push(n)}},validateAndExecute:nn,validateParameters:Js});class ri{constructor(){this._builtInPlugins=new Set,this._externalPlugins=new Set}static getInstance(){return ri._instance||(ri._instance=new ri),ri._instance}static setInstance(e){ri._instance=e}installBuiltInPlugin(e){e&&this._installPlugin(e,this._builtInPlugins)}installExternalPlugin(e){e&&this._installPlugin(e,this._externalPlugins)}clear(){this._builtInPlugins=new Set,this._externalPlugins=new Set}_installPlugin(e,t){var s=[];let n=(s=y(e)?e:[e]).findIndex(e=>"AVChatRoom"===(null==e?void 0:e.name)),i=-1<n?s.splice(n,1):[];s.forEach(e=>{this._isPluginInstalled(e.name)||(e&&es(e.install)?(t.add(e.name),es(e.getInstalledSubPlugins)?e.install(_i.getInstance().exposeApiForPlugin(),i):e.install(_i.getInstance().exposeApiForPlugin()),es(e.handleLoginSuccess)&&this._isLoggedIn()&&e.handleLoginSuccess()):es(e)?(t.add(e.name),e(_i.getInstance().exposeApiForPlugin()),es(e.handleLoginSuccess)&&this._isLoggedIn()&&e.handleLoginSuccess()):console.warn('A plugin must either be a function or an object with an "install" function.'))})}_isPluginInstalled(e){return this._builtInPlugins.has(e)||this._externalPlugins.has(e)}_isLoggedIn(){var e;return!0===(null==(e=Qt.store.get("login"))?void 0:e.isLoggedIn)}}var fi,mi,Si,Ti,ai=new class{constructor(){this._conversationMap=new Map}getConversationMap(){return this._conversationMap}getConversation(e){return this._conversationMap.get(e)}updateConversation(e,t,s={emit:!0,needSort:!1}){let{emit:n,needSort:i}=s,r=this._conversationMap.get(e);r&&!Oe(t)&&(Object.keys(t).forEach(e=>{r[e]=t[e]}),n)&&Qt.notificationCenter.emitInnerEvent(rs.CONVERSATION_UPDATED,{needSort:i})}deleteConversation(e){this._conversationMap.has(e)&&(this._conversationMap.delete(e),Qt.notificationCenter.emitInnerEvent(rs.CONVERSATION_UPDATED))}},ci=new class{constructor(){this._groupMap=new Map}getGroupMap(){return this._groupMap}getGroup(e){return this._groupMap.get(e)}updateGroup(e,t){let s=this._groupMap.get(e);s&&!Oe(t)&&Object.keys(t).forEach(e=>{s[e]=t[e]})}},li=new class{constructor(){this._messagesByConversation=new Map}updateMessage(s,t,e){let n,{operation:i,updateUnreadCount:r=!0}=e,o=I(e,["operation","updateUnreadCount"]),a=[];for(let e of t){let t=null==(n=this._messagesByConversation.get(s))?void 0:n.get(e);if(!t)return!1;Object.keys(o).forEach(e=>{t[e]=o[e]}),a.push(t)}return this._emitMessageStoreOperationEvent(i,{conversationID:s,messageList:a,updateUnreadCount:r}),a}getMessagesByConversation(e){return[...(null==(e=this._messagesByConversation.get(e))?void 0:e.values())||[]]}getMessages(){return this._messagesByConversation}_emitMessageStoreOperationEvent(e,t){var s=t["conversationID"];dn(s)?Qt.notificationCenter.emitInnerEvent(gs[e],t):Qt.notificationCenter.emitInnerEvent(e,t)}},ui=new class{constructor(){this.userProfileMap=new Map,this.friendMap=new Map}getUserProfileMap(){return this.userProfileMap}getFriendMap(){return this.friendMap}getUserProfile(e){return this.userProfileMap.get(e)}getFriend(e){return this.friendMap.get(e)}},di=Object.freeze({__proto__:null,conversationStore:ai,groupStore:ci,messageStore:li,userStore:ui});class _i{static getInstance(){return _i._instance||(_i._instance=new _i),_i._instance}static setInstance(e){_i._instance=e}constructor(){this._experimentalApiMap={statTUIKeyFeatures:this.statKeyFeatureUsage.bind(this),setApplicationID:this.setApplicationID.bind(this)},this._apiHandlersMap={},this._apiMap={on:Qt.notificationCenter.subscribeOuterEvent.bind(Qt.notificationCenter),off:Qt.notificationCenter.unSubscribeOuterEvent.bind(Qt.notificationCenter),destroy:this.destroy.bind(this),callExperimentalAPI:this.callExperimentalAPI.bind(this),use:ri.getInstance().installExternalPlugin.bind(ri.getInstance()),registerPlugin:this.registerPlugin.bind(this),setLogLevel:this.setLogLevel.bind(this)}}registerPlugin(e){Qt.ssoLog.debug("registerPlugin",e)}statKeyFeatureUsage(e){Qt.ssoLog.debug("statTUIKeyFeatures",e)}setLogLevel(e){Qt.ssoLog.debug("setLogLevel",e),Qt.ssoLog.setLogLevel(e)}setApplicationID(e){Qt.store.set("instance",{applicationID:e})}getApiMap(){return this._apiMap}setApiMap(e){this._apiMap=e}registerApi(e){let{common:{timeManager:r},utils:{safeStringify:t}}=Qt,{apiName:o,context:s,methodName:a=o,matcher:n}=e;this._apiHandlersMap[o]||(this._apiHandlersMap[o]=[]),this._apiHandlersMap[o].push({context:s,methodName:a,matcher:n}),this._apiMap[o]&&1!==this._apiHandlersMap[o].length||(this._apiMap[o]=(...s)=>{let n=r.getServerTimeMs(),i=0;"login"===o&&(i=4),bs.includes(o)&&Qt.ssoLog.debug(o,o+" start params: "+t(s)),nn(a,s);for(let t of this._apiHandlersMap[o])if(!t.matcher||t.matcher(s))try{let e=t.context[t.methodName].bind(t.context)(...s);return this._isPromiseLike(e)?this._handleAsyncResult(e,o,i,n):(this._reportApiSuccessLog({result:e,apiName:o,eventType:i,startTime:n}),e)}catch(s){throw Qt.ssoLog.error(o,`${o} fail ${null==s?void 0:s.message})`,{error:s,costTime:r.getServerTimeMs()-n,eventType:i,method:o}),s}})}registerExperimentalAPI(e,t,s){this._experimentalApiMap[e]=t[s||e].bind(t)}destroy(){return C(this,void 0,void 0,function*(){var e,t;try{null!=(e=Qt.store.get("login"))&&e.isLogin&&(yield this._apiMap.logout()),Qt.notificationCenter.emitInnerEvent(rs.DESTROY)}catch(e){console.debug("destroy error: ",e)}finally{Qt.notificationCenter.emitOuterEvent(is.SDK_DESTROY,{SDKAppID:null==(t=Qt.store.get("instance"))?void 0:t.sdkAppId}),ln.clear(),ri.getInstance().clear(),cn.getInstance().destroy(),Qt.destroy()}})}exposeApiForClient(){return this._apiMap}exposeApiForPlugin(){return Object.assign(Object.assign({InnerEvent:rs,InnerEventSubType:Qt.notificationCenter.InnerEventSubType,OuterEvent:is,OuterConstant:Ms,SignalingEvent:as,helper:Object.assign(Object.assign(Object.assign({},Qt.utils),Qt.common),{registerApi:this.registerApi.bind(this),registerExperimentalAPI:this.registerExperimentalAPI.bind(this),registerInterceptor:on,registerValidateConfig:rn,checkBusinessCapabilityBits:an,registerWorkflowStep:cn.getInstance().registerWorkflowStep.bind(cn.getInstance()),ChatError:Zs}),apiMap:this._apiMap},Qt),{constants:Object.assign(Object.assign({},ws),Qt.constants),common:Object.assign(Object.assign(Object.assign({},oi),Qt.common),{workflowManager:cn.getInstance()}),utils:Qt.utils,appStore:di})}callExperimentalAPI(e,t){return this._experimentalApiMap[e]?this._experimentalApiMap[e](t):Promise.reject(new Zs({code:Os.INVALID_OPERATION}))}_isPromiseLike(e){return null!==e&&"object"==typeof e&&"function"==typeof e.then}_handleAsyncResult(e,t,s,n){return e.then(e=>(this._reportApiSuccessLog({result:e,apiName:t,eventType:s,startTime:n}),e)).catch(e=>{throw Qt.ssoLog.error(t,`${t} fail ${null==e?void 0:e.message})`,{error:e,costTime:Qt.common.timeManager.getServerTimeMs()-n,eventType:s,method:t}),e})}_reportApiSuccessLog(e){let{result:t,apiName:s,startTime:n,eventType:i}=e;var e=Qt.common["timeManager"],{successLog:{message:r,moreMessage:o}={message:"",moreMessage:""}}=t||{},a=e.getServerTimeMs();"login"===s&&(n+=e.getTimeOffsetWithServer()),bs.includes(s)&&Qt.ssoLog.info(s,s+` success ${r} `+o,{costTime:a-n,eventType:i,message:r,moreMessage:o}),null!=t&&t.successLog&&delete t.successLog}}class hi{constructor(){this._latestLoginAt=0,this._latestSendOnlinePresenceRequestTime=0,this._helloInterval=120,this._customLoginInfo=""}init(){var{notificationCenter:e,store:t}=Qt;t.set("login",{isReady:!1}),_i.getInstance().registerApi({apiName:"login",context:this}),_i.getInstance().registerApi({apiName:"logout",context:this}),_i.getInstance().registerApi({apiName:"getLoginUser",context:this}),_i.getInstance().registerApi({apiName:"isReady",context:this}),_i.getInstance().registerExperimentalAPI("setCustomLoginInfo",this),e.subscribeInnerEvent(rs.RECONNECTED,this._reLogin,this),Qt.notificationCenter.subscribeInnerEvent(rs.DESTROY,this._dispose,this)}login(l){return C(this,void 0,void 0,function*(){var e;let t=(Qt.store.get("instance")||{})["sdkEdition"];try{if(this._isLoginIn())return this._createRepeatLoginResponse();if(this._isLoginFrequencyExceeded())throw new Zs({functionName:"login",code:Os.REPEAT_LOGIN});var s=yield this._performLogin(l),n=(this._validateAfterLogin(s),this._handleLoginSuccess(s),yield this._ensureAsyncComplete(),this._updateAndEmitSDKReady(),this._latestLoginAt=0,null==(e=Qt.channel.getSocketAdapter())?void 0:e.getId()),{appId:i,href:r}=Qt.store.get("instance")||{},{instanceID:o,customStatus:a}=s||{};return{code:0,data:s,successLog:{message:t,moreMessage:`socketID:${n} instanceID:${o} customStatus:${a} href: ${r} appId: `+i}}}catch(e){let t=e["errorCode"],s=(t!==Os.REPEAT_LOGIN&&(this._latestLoginAt=0),new Zs({functionName:"login",code:t}));throw console.error(s),s}})}_reLogin(){return C(this,void 0,void 0,function*(){var e,t,s,n,i;try{this._isLoginIn()&&(t=yield js(this._customLoginInfo))&&({instanceID:s,customStatus:n}=t,Qt.store.set("login",{statusInstanceId:s}),cn.getInstance().executeWorkflow(As.SYNC_SERVER_INFO_AFTER_RE_ONLINE,{customStatus:n,statusType:ps.USER_STATUS_ONLINE}),i=null==(e=Qt.channel.getSocketAdapter())?void 0:e.getId(),Qt.ssoLog.info("reLogin",`socketId:${i} instanceId:`+s))}catch(e){console.warn(e)}})}logout(){return C(this,arguments,void 0,function*(t=Ls.USER_INITIATED){let e=Qt["ssoLog"];e.debug("logout","logout start logoutReason: "+t);try{yield this._performLogout(t),e.info("logout","logout success"),Qt.ssoLog.uploadSSOLogData()}catch(t){let e=t["errorCode"];throw new Zs({functionName:"logout",code:e})}finally{this._handleLogoutCompleted()}return{code:0,data:{}}})}getLoginUser(){return this._isLoginIn()?mn():""}isReady(){var e;return null==(e=Qt.store.get("login"))?void 0:e.isReady}setCustomLoginInfo(e=""){this._customLoginInfo=e}_updateAndEmitSDKReady(){Qt.store.set("login",{isReady:!0}),setTimeout(()=>{Qt.notificationCenter.emitOuterEvent(is.SDK_READY,{name:is.SDK_READY})},1)}_updateAndEmitSDKNotReady(){Qt.store.set("login",{isReady:!1}),Qt.notificationCenter.emitOuterEvent(is.SDK_NOT_READY,{name:is.SDK_NOT_READY})}_validateAfterLogin(e){var t="login";if(!e)throw new Zs({functionName:t,message:"login response is empty"});var{tinyID:e,a2Key:s}=e||{};if(!e)throw new Zs({functionName:t,code:Os.NO_TINYID});if(!s)throw new Zs({functionName:t,code:Os.NO_A2KEY})}_createRepeatLoginResponse(){var e;return{code:0,data:{actionStatus:"OK",errorCode:0,errorInfo:zs({code:"RepeatLogin",replacement1:null==(e=Qt.store.get("login"))?void 0:e.userId}),repeatLogin:!0}}}_performLogin(s){return C(this,void 0,void 0,function*(){var{userID:e,userSig:t}=s;return Qt.store.set("login",{userId:e,userSig:t}),this._latestLoginAt=Date.now(),js(this._customLoginInfo)})}_ensureAsyncComplete(){return C(this,void 0,void 0,function*(){yield new Promise(e=>{setTimeout(()=>e(null),1)})})}_handleLoginSuccess(e){var t=Qt.common["timeManager"],{helloInterval:s,timeStamp:n,customStatus:i,purchaseBits:r}=e;t.calculateTimeOffsetWithServer(this._latestLoginAt,1e3*n),this._helloInterval=s||120,this._updateLoginStore(e),Qt.user.userStatus.setCustomStatus(i),cn.getInstance().executeWorkflow(As.SYNC_SERVER_INFO_AFTER_LOGIN,{purchaseBits:r}),Qt.common.taskScheduler.addTask({id:Fs,intervalMs:1e3*this._helloInterval,callback:this._sendOnlinePresenceRequest,context:this})}_performLogout(e){return function(s){return C(this,void 0,void 0,function*(){var e=s["logoutReason"],t="im_open_status.wslogout",e=Qt.common.generateProtocolData({servcmd:t,data:{wslogout_type:e,isWebUniapp:0}}),t=e.head.seq+t;return yield Qt.channel.sendPacket(e,{requestId:t})})}({logoutReason:e})}_handleLogoutCompleted(){this._updateAndEmitSDKNotReady(),this._reset(),cn.getInstance().reset(),Qt.notificationCenter.emitInnerEvent("logout")}_updateLoginStore(e){var{a2Key:e,tinyID:t,instanceID:s,authKey:n}=e;Qt.store.set("login",{a2Key:e,tinyID:t,statusInstanceId:s,authKey:n,isLoggedIn:!0})}_sendOnlinePresenceRequest(){return C(this,void 0,void 0,function*(){this._latestSendOnlinePresenceRequestTime=Date.now();try{e="im_open_status.wshello",t=Qt.common.generateProtocolData({servcmd:e,data:{isWebUniapp:0}}),e=t.head.seq+e,yield Qt.channel.sendPacket(t,{requestId:e})}catch(e){Qt.ssoLog.warn("_sendOnlinePresenceRequest"," error:"+e.message)}var e,t})}_isLoginIn(){var e;return!0===(null==(e=Qt.store.get("login"))?void 0:e.isLoggedIn)}_isLoginFrequencyExceeded(){return Date.now()-this._latestLoginAt<=15e3}_reset(){Qt.common.taskScheduler.removeTask(Fs),this._helloInterval=120,this._latestSendOnlinePresenceRequestTime=0,this._latestLoginAt=0,this._customLoginInfo="",Qt.store.clear("login"),Qt.store.set("login",{isReady:!1}),Qt.store.set("instance",{applicationID:0})}_dispose(){this._reset();var e=Qt["notificationCenter"];e.unSubscribeInnerEvent(rs.RECONNECTED,this._reLogin,this),e.unSubscribeInnerEvent(rs.DESTROY,this._dispose,this)}}let gi={login:{userID:{required:!0,rules:["string"],allowEmpty:!1},userSig:{required:!0,rules:["string"],allowEmpty:!1}}},pi={logout:!0};class Ei{constructor(){this.loginAction=new hi,this.kickedOutHandler=new Hs,this.loginAction.init(),this.kickedOutHandler.init(),rn({auth:pi,params:gi})}}!function(e){e.CONV_C2C="C2C",e.CONV_GROUP="GROUP",e.CONV_TOPIC="TOPIC",e.CONV_SYSTEM="@TIM#SYSTEM"}(fi=fi||{}),function(e){e.MSG_PRIORITY_HIGH="High",e.MSG_PRIORITY_NORMAL="Normal",e.MSG_PRIORITY_LOW="Low",e.MSG_PRIORITY_LOWEST="Lowest"}(mi=mi||{}),function(e){e.MSG_TEXT="TIMTextElem",e.MSG_CUSTOM="TIMCustomElem",e.MSG_LOCATION="TIMLocationElem",e.MSG_FACE="TIMFaceElem",e.MSG_IMAGE="TIMImageElem",e.MSG_AUDIO="TIMSoundElem",e.MSG_FILE="TIMFileElem",e.MSG_VIDEO="TIMVideoFileElem",e.MSG_GRP_TIP="TIMGroupTipElem",e.MSG_GRP_SYS_NOTICE="TIMGroupSystemNoticeElem",e.MSG_MERGER="TIMRelayElem"}(Si=Si||{});let vi={1:mi.MSG_PRIORITY_HIGH,2:mi.MSG_PRIORITY_NORMAL,3:mi.MSG_PRIORITY_LOW,4:mi.MSG_PRIORITY_LOWEST},Ii=0,Ci=1,Mi=(!function(e){e.IN="in",e.OUT="out"}(Ti=Ti||{}),2),Oi={};function yi(e){var t,s,n;return e?(void 0===Oi[e]?(t=("3"+(n=new Date).getHours()).slice(-2),s=("0"+n.getMinutes()).slice(-2),n=("0"+n.getSeconds()).slice(-2),Oi[e]=parseInt([t,s,n,"0001"].join(""),10),console.log("autoIncrementIndex start index:"+Oi[e])):Oi[e]+=1,Oi[e]):0}class Ai{constructor(e){this.ID="",this.random=0,this.sequence=0,this.nameCard="",this.isRead=!1,this.isPeerRead=!1,this.isDeleted=!1,this.isResend=!1,this.hasRiskContent=!1,this._onlineOnlyFlag=!1,this.atUserList=[],this._groupAtInfoList=[],this.isBroadcastMessage=!1,this.priority=mi.MSG_PRIORITY_NORMAL,this._relayFlag=!1;var t,{clientTime:s=Qt.common.timeManager.getServerTimeSeconds()||0,senderTinyID:n,currentUser:i,needReadReceipt:r,isSupportExtension:o,customModerationConfigurationId:a,to:l,from:c,nick:u="",avatar:_="",time:d,messageControlInfo:h,tinyID:g,cloudCustomData:p="",messageLifeTime:E,messageVersion:m=0,conversationType:f,sequence:S,checkResult:v=0,isPlaceMessage:I=0,messageFlagBits:C,receiverList:M,isSystemMessage:T=!1,status:O=us.SUCCESS,revokeReason:y="",conversationSubType:A,clientSequence:N,protocol:R="JSON",revokerInfo:D={userID:"",nick:"",avatar:""},readReceiptInfo:P={readCount:void 0,unreadCount:void 0,isPeerRead:void 0,timestamp:0},random:b,groupProfile:w,atUserList:L,flow:k,isRead:U=!1}=e;this.clientTime=s,this.senderTinyID=n||g,this.needReadReceipt=!0===r||1===r,this.isSupportExtension=!0===o||1===o,this._cmConfigID=a,this.to=l,this.nick=u,this.avatar=_,this.protocol=R,this.random=void 0===b?(t=t||99999999,Math.round(Math.random()*t)):b,this.time=d||Math.ceil(Date.now()/1e3),this._isExcludedFromLastMessage=!(null==h||!h.excludedFromLastMessage),this._isExcludedFromUnreadCount=!(null==h||!h.excludedFromUnreadCount),this.isModified=!!m,this.cloudCustomData=p,this.messageLifeTime=E,this.from=c||null,this.sequence=S||0,this.conversationType=f||fi.CONV_C2C,this.hasRiskContent=1<v,this.version=m,this.isPlaceMessage=I,this.isRevoked=2===I||8===C,this.isSystemMessage=T,this.readReceiptInfo=P,this.revokeReason=y,this.revokerInfo=D,this._receiverList=M,this.conversationSubType=A,this.revoker=(null==D?void 0:D.revoker)||"",this.clientSequence=N||S||0,this.status=O,this.atUserList=L||[],this.flow=k,this.isRead=U,this.reInitialize(i),this._initC2CReadReceiptInfo(e),this._extractGroupInfo(w)}getElements(){return this._elements}isOnlineMessage(){return 0===this.messageLifeTime}setElement(e){Array.isArray(e)?this._elements=e:this._elements=[e],this._updatePayloadAndType()}transformElementsToServerFormat(){return this._elements?Array.isArray(this._elements)?this._elements.map(e=>e.transformToServerFormat()):this._elements.transformToServerFormat():null}setRelayFlag(e){this._relayFlag=e}validateBeforeSend(){var e,t;return this._relayFlag?{isValid:!0}:0<(null==(e=this._elements)?void 0:e.length)?null==(t=null==(e=this._elements[0])?void 0:e.validateBeforeSend)?void 0:t.call(e):{isValid:!1}}_updatePayloadAndType(){this._elements[0]&&(this.payload=this._elements[0].content,this.type=this._elements[0].type)}_initC2CReadReceiptInfo(e){var{readReceiptSentByPeer:e,timestamp:t=0}=e;this.conversationType===fi.CONV_C2C&&!0===this.needReadReceipt&&(this.readReceiptInfo.isPeerRead=1===e,this.readReceiptInfo.timestamp=t)}_extractGroupInfo(e){var t,s;e&&({From_AccountNick:e,From_AccountHeadurl:t,MsgFrom_AccountExtraInfo:s}=e,s=(s||{})["NameCard"],"string"==typeof e&&(this.nick=e),"string"==typeof t&&(this.avatar=t),"string"==typeof s)&&(this.nameCard=s)}reInitialize(e){e===this.from&&(this.isRead=!0),this._initSequence(e),this._concatConversationID(e),this.generateMessageID()}_concatConversationID(e){var t=this.conversationType;t!==fi.CONV_SYSTEM?(e=t!==fi.CONV_C2C||e===this.from?this.to:this.from,this.conversationID=e?""+t+e:null):this.conversationID=fi.CONV_SYSTEM}_initSequence(e){0===this.clientSequence&&e&&(this.clientSequence=yi(e)),0===this.sequence&&this.conversationType===fi.CONV_C2C&&(this.sequence=this.clientSequence)}generateMessageID(){this.from===fi.CONV_SYSTEM&&(this.senderTinyID="144115198244471703"),this.ID=`${this.senderTinyID}-${this.clientTime}-`+this.random}setIsRead(e){this.isRead=e}}class Ni{static parseServerPushElement(e){var{MsgContent:e={}}=e,{Data:e,Ext:t,Desc:s}=e;return new Ni({data:e,description:s,extension:t})}constructor(e){this.type=Si.MSG_CUSTOM;var{data:e="",description:t="",extension:s=""}=e;this.content={data:e,description:t,extension:s}}transformToServerFormat(e){var{isMergerMessage:e=!1}=e||{},{data:e,description:t,extension:s}=e?this.payload:this.content;return{MsgType:this.type,MsgContent:{Data:e,Ext:s,Desc:t}}}validateBeforeSend(){let t=Qt.utils["isEmpty"],e=[this.content.data,this.content.description,this.content.extension].some(e=>!t(e));return{isValid:e,error:e?null:{message:"content can not be empty"}}}}class Ri{static parseServerPushElement(e){var{MsgContent:e={Text:""}}=e,e=e["Text"];return new Ri({text:e})}constructor(e){this.type=ls.MSG_TEXT,this.content={text:e.text||""}}validateBeforeSend(){var e;return 0<(null==(e=null==(e=this.content)?void 0:e.text)?void 0:e.length)?{isValid:!0}:{isValid:!1,error:{message:"content can not be empty"}}}transformToServerFormat(e){var{isMergerMessage:e=!1}=e||{},e=(e?this.payload:this.content)["text"];return{MsgType:this.type,MsgContent:{Text:e}}}}var Di=new class{constructor(){this._elementClassMap={[Si.MSG_CUSTOM]:Ni,[Si.MSG_TEXT]:Ri}}init(){_i.getInstance().registerApi({apiName:"createCustomMessage",context:this}),_i.getInstance().registerApi({apiName:"createTextMessage",context:this})}registerElementClass(e,t){void 0!==t.prototype&&"constructor"in t.prototype&&(this._elementClassMap[e]=t)}getElementClass(e){return this._elementClassMap[e]}createMessage(e){var{from:t,flow:s=Ti.OUT}=e,n=(Qt.store.get("login")||{})["userId"],t=(this._isSendByCurrentInstance({from:t,flow:s,currentUser:n})?this._updateWithSenderInfo(e):this._isMultiEndpointSyncMessage({from:t,flow:s,currentUser:n})&&(e.flow=Ti.OUT),Object.assign(Object.assign({},e),{currentUser:n}));return new Ai(t)}createCustomMessage(t){let e=mn(),s=this.createMessage(Object.assign(Object.assign({},t),{from:e})),n=this._elementClassMap[Si.MSG_CUSTOM];if(!s)return null;if(n){let e=new n(t.payload);s.setElement(e)}return s}createTextMessage(e){var t,s;return e?(t="string"==typeof e.payload?e.payload:(null==(t=null==e?void 0:e.payload)?void 0:t.text)||"",t=new Ri({text:t}),s=mn(),(e=Qt.message.messageFactory.createMessage(Object.assign(Object.assign({},e),{from:s}))).setElement(t),e):null}_updateWithSenderInfo(e){var{nick:t,avatar:s}=e,{userId:n,tinyID:i}=Qt.store.get("login")||{},r=ui.getUserProfile(n);return e.nick=t||(null==r?void 0:r.nick)||"",e.avatar=s||(null==r?void 0:r.avatar)||"",e.tinyID=e.tinyID||i||"",e.from=n,e.status=us.UNSENT,e.flow=Ti.OUT,e}_isMultiEndpointSyncMessage(e){var{from:e,flow:t,currentUser:s}=e;return e===s&&t===Ti.IN}_isSendByCurrentInstance(e){var{from:e,flow:t,currentUser:s}=e;return e===s&&t===Ti.OUT}};let Pi={PushFlag:0,Title:"",Desc:"",Ext:"",ApnsInfo:{Sound:"",BadgeMode:0,IsVoipPush:void 0,Image:"",InterruptionLevel:"active",ContentAvailable:0},AndroidInfo:{Sound:"",XiaoMiChannelID:"",OPPOChannelID:"",GoogleChannelID:"",VIVOClassification:1,VIVOCategory:"",HuaWeiCategory:"",OPPOCategory:"",HuaWeiImage:"",HonorImage:"",GoogleImage:"",HonorImportance:"",MeizuNotifyType:void 0}},bi={HonorImportance:{range:["LOW","NORMAL"],defaultValue:void 0},MeizuNotifyType:{range:[0,1],defaultValue:void 0}},wi={enableIOSBackgroundNotification:{range:[!0,!1],defaultValue:!1},interruptionLevel:{range:["passive","active","time-sensitive","critical"],defaultValue:"active"}};function Li(n,i){return Object.keys(i).forEach(e=>{var{range:t,defaultValue:s}=i[e];n[e]=t.includes(n[e])?n[e]:s}),n}function ki(e){var t=e.lastIndexOf(".");return-1===t?e:e.slice(0,t)}function Ui(e){var{androidInfo:e={},androidOPPOChannelID:t=""}=e,t=e.OPPOChannelID||t,e=Li(e,bi),{sound:s="",FCMChannelID:n=""}=e,e=I(e,["sound","FCMChannelID"]);return Object.assign(Object.assign({},e),{Sound:ki(s),OPPOChannelID:t,GoogleChannelID:n})}function Gi(e){var{apnsInfo:e={},ignoreIOSBadge:t=!1,disableVoipPush:s}=e,e=Li(e,wi),{ignoreIOSBadge:n,disableVoipPush:i,enableIOSBackgroundNotification:r}=e,e=I(e,["ignoreIOSBadge","disableVoipPush","enableIOSBackgroundNotification"]),n=!0===n||!0===t?1:0;let o;return T(s)||(o=!1===s?1:0),T(i)||(o=!1===i?1:0),Object.assign(Object.assign({},e),{BadgeMode:n,IsVoipPush:o,ContentAvailable:r?1:0})}function Fi(e){return Qt.utils.isPlainObject(e)?{PushFlag:!0===e.disablePush?1:0,Title:e.title||"",Desc:e.description||"",Ext:e.extension||"",ApnsInfo:Gi(e),AndroidInfo:Ui(e)}:Pi}function Bi(e){let{From_AccountHeadurl:t,From_AccountNick:s,IsNeedReadReceipt:n,IsPeerRead:i,IsSyncMsg:r,MsgBody:o,MsgClientTime:a,MsgLifeTime:l,MsgRandom:c,MsgSeq:u,MsgTimeStamp:_,SendMsgControl:d,SupportMessageExtension:h,TinyId:g,MsgCheckResult:p,CloudCustomData:E,MsgVersion:m,MsgFlagBits:f,RevokerInfo:S}=e,v,{From_Account:I,To_Account:C}=e;if(1===r){let e=C;C=I,I=e}if(S){let{Reason:e,Revoker_Account:t,Revoker_FromUin:s}=S;v={reason:e,revoker:t,revokerFromUin:s,userID:t}}return{from:I,avatar:t,nick:s,needReadReceipt:1===n,isSyncMessage:r,clientTime:a,messageLifeTime:l,random:c,sequence:u,time:_,messageControlInfo:{excludedFromLastMessage:1===(null==d?void 0:d.NoLastMsg),excludedFromUnreadCount:1===(null==d?void 0:d.NoUnread)},isSupportExtension:h,to:C,tinyID:g,checkResult:p,cloudCustomData:E,revokerInfo:v,messageVersion:m,messageFlagBits:f,readReceiptSentByPeer:i,elements:qi(o)}}function xi(e){var{From_Account:e,MsgBody:t,MsgClientTime:s,MsgRandom:n,MsgSeq:i,MsgTimeStamp:r,To_Account:o,MsgVersion:a,CloudCustomData:l}=e;return{from:e,clientTime:s,random:n,sequence:i,time:r,to:o,elements:qi(t),messageVersion:a,cloudCustomData:l}}function Vi(e){let{ClientSeq:t,From_Account:s,GroupInfo:n,MsgBody:i,MsgClientTime:r,MsgRandom:o,MsgSeq:a,MsgTimeStamp:l,SendMsgControl:c,SupportMessageExtension:u,TinyId:_,CloudCustomData:d,MsgVersion:h,MsgCheckResult:g,NeedReadReceipt:p,IsPlaceMsg:E,RevokerInfo:m,GroupAtInfo:f}=e,S,v=mi.MSG_PRIORITY_NORMAL;if(Object.keys(vi).includes(String(e.MsgPriority))&&(v=vi[e.MsgPriority]),m){let{Reason:e,Revoker_Account:t,Revoker_FromUin:s}=m;S={reason:e,revoker:t,revokerFromUin:s,userID:t}}var I=function(e){let t=[];return Array.isArray(e)&&e.forEach(e=>{e.GroupAtAllFlag===Ii?t.push(e.GroupAt_Account):e.GroupAtAllFlag===Ci&&t.push(Ms.MSG_AT_ALL)}),t}(f);return{clientSequence:t,from:s,groupProfile:n,clientTime:r,priority:v,random:o,sequence:a,time:l,messageControlInfo:{excludedFromLastMessage:1===(null==c?void 0:c.NoLastMsg),excludedFromUnreadCount:1===(null==c?void 0:c.NoUnread)},isSupportExtension:u,tinyID:_,cloudCustomData:d,messageVersion:h,messageCheckResult:g,needReadReceipt:p,isPlaceMessage:E,revokerInfo:S,atUserList:I,elements:qi(i),to:$i(e)}}function $i(e){var{utils:{isEmpty:t},constants:{IS_TOPIC_MESSAGE:s}}=Qt,{ToGroupId:e,GroupInfo:{MillionGroupFlag:n=0,TopicId:i}={}}=e;return n!==s||t(i)?e:i}function qi(e){var t;return e?Array.isArray(e)?e.map(e=>{var t=Qt.message.messageFactory.getElementClass(e.MsgType);return null==t?void 0:t.parseServerPushElement(e)}):null==(t=Qt.message.messageFactory.getElementClass(e.MsgType))?void 0:t.parseServerPushElement(e):null}function Wi(e){var{From_Account:e,MsgBody:t,MsgClientTime:s,MsgRandom:n,MsgSeq:i,MsgTimeStamp:r,GroupId:o,TopicId:a,MsgVersion:l,CloudCustomData:c}=e;return{from:e,clientTime:s,random:n,sequence:i,time:r,groupID:o,topicID:a,elements:qi(t),messageVersion:l,cloudCustomData:c}}function Yi({conversationUpdateFields:e,message:t}){var{conversationID:s,conversationType:n,conversationSubType:i,flow:r,_isExcludedFromUnreadCount:o,_isExcludedFromLastMessage:a}=t,a=a?"":t,t=!o&&r===Ti.IN;e.has(s)?(e.get(s).lastMessage=a,t&&e.get(s).unreadCount++):e.set(s,{conversationID:s,type:n,subType:i,unreadCount:t?1:0,lastMessage:a})}function Ki(e){return e.filter(e=>{var t=!Oe(null==e?void 0:e.getElements()),s=1===(null==e?void 0:e.isPlaceMessage);return t||Qt.ssoLog.error("emptyMessageBody",`from:${e.from} to:${e.to} sequence:`+e.sequence),t&&!s})}function Hi(e){var t=Qt.message["messageDataHandler"];return!t.isInMessageList(e)&&!t.isMessageSentByCurrentInstance(e)}var ji=Object.freeze({__proto__:null,autoIncrementIndex:yi,filterValidMessages:Ki,parseServerGroupMessage:Vi,parseServerPushC2CModifyMessage:xi,parseServerPushGroupModifyMessage:Wi,parseServerPushMessage:Bi,parseServerPushMessageElement:qi,shouldStoreMessage:Hi,updateConversationFields:Yi});let zi=Qt.utils["isPlainObject"];function Zi(e,t={}){let{onlineUserOnly:s,messageControlInfo:n}=t,i=t["offlinePushInfo"],r=(e.conversationType===fi.CONV_C2C&&!0===s&&(i?i.disablePush=!0:i={disablePush:!0}),"");"string"==typeof e.cloudCustomData&&0<e.cloudCustomData.length&&(r=e.cloudCustomData);var o=[];if(n&&zi(n)){let{excludedFromUnreadCount:e,excludedFromLastMessage:t,excludedFromContentModeration:s}=n;!0===e&&o.push("NoUnread"),!0===t&&o.push("NoLastMsg"),!0===s&&o.push("NoMsgCheck")}return{onlineUserOnly:s,cloudCustomData:r,messageControlInfo:o,offlinePushInfo:i}}function Xi(e){var t,{webhookInfo:{disableCloudMessagePreHook:e=!1,disableCloudMessagePostHook:s=!1}={}}=e||{};if(e||s)return t=[],e&&t.push("ForbidBeforeSendMsgCallback"),s&&t.push("ForbidAfterSendMsgCallback"),t}function Ji(t,s){return C(this,void 0,void 0,function*(){var e=yield gn((t.conversationType===fi.CONV_GROUP?function(e,t){var s,{onlineUserOnly:n,cloudCustomData:i,messageControlInfo:r,offlinePushInfo:o}=Zi(e,t),a=JSON.parse(JSON.stringify(e.transformElementsToServerFormat()));let l;return y(e._receiverList)&&0<e._receiverList.length&&(l=e._receiverList,50<e._receiverList.length)&&(l=e._receiverList.slice(0,50),console.warn("ReceiverListLimit")),{servcmd:"group_open_http_svc.send_group_msg",data:{From_Account:null==(s=Qt.store.get("login"))?void 0:s.userId,GroupId:e.to,MsgBody:a,CloudCustomData:i,Random:e.random,MsgPriority:e.priority,ClientSeq:e.clientSequence,GroupAtInfo:e._groupAtInfoList,OnlineOnlyFlag:n?1:0,MsgClientTime:e.clientTime,OfflinePushInfo:Fi(o),SendMsgControl:n?void 0:r,NeedReadReceipt:!0===e.needReadReceipt?1:0,To_Account:l,SupportMessageExtension:!0===e.isSupportExtension?1:0,IsRelayMsg:!0===e._relayFlag?1:0,CustomModerationConfigID:e._cmConfigID,ForbidCallbackControl:Xi(t)}}}:function(e,t){var s,{onlineUserOnly:n,cloudCustomData:i,messageControlInfo:r,offlinePushInfo:o}=Zi(e,t),n=!0===n?0:void 0,a=JSON.parse(JSON.stringify(e.transformElementsToServerFormat()));return{servcmd:"openim.sendmsg",data:{From_Account:null==(s=Qt.store.get("login"))?void 0:s.userId,To_Account:e.to,MsgBody:a,CloudCustomData:i,MsgSeq:e.sequence,MsgRandom:e.random,MsgLifeTime:n,From_AccountNick:e.nick,From_AccountHeadurl:e.avatar,SendMsgControl:0!==n?r:void 0,MsgClientTime:e.clientTime,IsNeedReadReceipt:!0===e.needReadReceipt?1:0,SupportMessageExtension:!0===e.isSupportExtension?1:0,IsRelayMsg:!0===e._relayFlag?1:0,CustomModerationConfigID:e._cmConfigID,OfflinePushInfo:Fi(o),forbidCallbackControl:Xi(t)}}})(t,s));return e?{time:e.MsgTime,messageDropReason:e.MsgDropReason,sequence:e.MsgSeq}:null})}let Qi=Qt.utils["isPlainObject"],{MSG_AUDIO:eo,MSG_FILE:to,MSG_IMAGE:so,MSG_VIDEO:no,MSG_MERGER:io}=Ms;class oo{init(){_i.getInstance().registerApi({apiName:"sendMessage",context:this,matcher:e=>![eo,to,so,no,io].includes(e[0].type)})}sendMessage(u,_){return C(this,void 0,void 0,function*(){let{TOTAL_COUNT:e,SEND_COST:o,SUCCESS_COUNT:a,FAILED_COUNT:t}=Ps;if(!(u instanceof Ai))throw new Zs({code:Os.MSG_INSTANCE_REQUIRED});let s=u.validateBeforeSend();if(!s.isValid){let{code:e,message:t=""}=s.error||{};throw new Zs({code:e,message:t})}this._reportMessageSendQuality({name:e,message:u});let l=!1;var c=(Qt.message||{})["messageDataHandler"];try{let n=(_||{})["messageControlInfo"],i=null,r=(c.addRandomOfSentMessage(u.random),Date.now());if(u.conversationType===fi.CONV_C2C?(l=!0===(null==_?void 0:_.onlineUserOnly),i=yield Ji(u,_)):u.conversationType===fi.CONV_GROUP&&(yield this._validateBeforeSendGroupMessage(u),i=yield Ji(u,_)),i){let{messageDropReason:e,sequence:t,time:s}=i;if(this._updateNickAndAvatarOfSentMessageByMe(u),e&&this._logRateLimitInfo(u,t,e),this._reportMessageSendQuality({name:a,message:u}),this._reportMessageSendQuality({name:o,message:u,startTs:r}),!0===u.isResend){let e=c.findMessage(u.ID);e&&(Qt.ssoLog.debug("sendMessage","sendMessage resend ok. ID:"+e.ID),c.deleteConversationMessage(e))}return u.status=us.SUCCESS,u.time=s,u.conversationType===fi.CONV_GROUP&&(u.sequence=t),l?u._onlineOnlyFlag=!0:(c.storeConversationMessage(u),this._applySentMessageControlInfo(u,n),this._emitOnlineMessageSent(u)),{code:0,data:{message:u}}}}catch(e){u.status=us.FAIL,c.removeRandomOfSentMessage(u.random);var n=(e||{})["errorCode"],i=(null==e?void 0:e.errorMessage)||(null==e?void 0:e.message)||"";throw this._hasRiskContent(n)&&(u.hasRiskContent=!0),l||this._isRejectedByRestApi(n)||c.storeConversationMessage(u),this._reportMessageSendQuality({name:t,message:u,error:e}),i=`type:${u.type} from:${u.from} to:${u.to} `+i,new Zs({code:n,message:i,data:{message:u}})}})}_hasRiskContent(e){return 80001===e||80004===e}_isRejectedByRestApi(e){return 10100<=e&&e<=10200||120001<=e&&e<=13e4}_emitOnlineMessageSent(e){var t=e._isExcludedFromLastMessage?"":e,{conversationID:s,conversationType:n}=e,i=dn(s)?rs.TOPIC_NEW_MESSAGE:rs.NEW_MESSAGE;Qt.notificationCenter.emitInnerEvent(i,{result:{conversationUpdateFieldList:[{conversationID:s,type:n,message:e,lastMessage:t,unreadCount:0}]}})}_applySentMessageControlInfo(e,t){t&&Qi(t)&&(!0===t.excludedFromLastMessage&&(e._isExcludedFromLastMessage=!0),!0===t.excludedFromUnreadCount)&&(e._isExcludedFromUnreadCount=!0)}_logRateLimitInfo(e,t,s){e=`from:${e.from} to:${e.to} sequence:${t} messageDropReason:`+s;Qt.ssoLog.warn("messageDropReason",e)}_updateNickAndAvatarOfSentMessageByMe(e){var t=(Qt.message||{})["messageDataHandler"];let s=!1;var n,i=e["conversationID"],r=t.getLatestMsgSentByMe(i);r&&({nick:r,avatar:n}=r,s=r!==e.nick||n!==e.avatar||s)&&t.updateNickAndAvatarOfSentMessage({conversationID:i,latestNick:e.nick,latestAvatar:e.avatar,isSentByMe:!0})}_validateBeforeSendGroupMessage(i){return C(this,void 0,void 0,function*(){var{to:t,from:s}=i;let n=t,e=ci.getGroup(n);if(un({groupID:n})&&null!=e&&e.isSupportTopic)throw new Zs({code:Os.MSG_SEND_GRP_WITH_TOPIC_FAIL});if(dn(t)&&([n]=t.split(Is.TOPIC),e=ci.getGroup(n)),!e&&"function"==typeof(null==(t=_i.getInstance().getApiMap())?void 0:t.getGroupProfile)){let e=yield _i.getInstance().getApiMap().getGroupProfile({groupID:n});if((null==(t=null==(t=null==e?void 0:e.data)?void 0:t.group)?void 0:t.type)===Ms.GRP_AVCHATROOM){let e=zs({code:Os.MSG_SEND_FAIL_NOT_IN_AV,replacement1:s,replacement2:n});throw new Zs({code:Os.MSG_SEND_FAIL_NOT_IN_AV,message:e})}}return!0})}_reportMessageSendQuality(e){Qt.notificationCenter.emitInnerEvent(rs.QUALITY_STAT,{label:Ds.MESSAGE_SEND_SUCCESS_RATE,data:e})}}class ro{constructor(e){this.value=e,this.next=null}}class ao{constructor(e){this.head=null,this.tail=null,this.size=0,this.capacity=e}append(e){this.size>=this.capacity&&this.removeHead();e=new ro(e);this.head?this.tail.next=e:this.head=e,this.tail=e,this.size+=1}delete(t){if(this.head)if(this.head.value===t)this.head=this.head.next;else{let e=this.head;for(;e.next;){if(e.next.value===t)return void(e.next=e.next.next);e=e.next}}}has(e){if(!this.head)return!1;let t=this.head,s=!1;for(;t;)t.value===e&&(s=!0),t=t.next;return s}removeHead(){this.head&&(this.head===this.tail?(this.head=null,this.tail=null):this.head=this.head.next,--this.size)}peek(){var e;return null==(e=this.head)?void 0:e.value}length(){return this.size}isEmpty(){return 0===this.size}isFull(){return this.size===this.capacity}clear(){this.head=null,this.tail=null,this.size=0}}var co=new class{constructor(){this._sparseMessagesByConversation=new Map,this._latestMessageSentByPeerMap=new Map,this._latestMessageSentByMeMap=new Map,this._randomOfSentMessageList=new ao(100)}init(){Qt.notificationCenter.subscribeInnerEvent(rs.LOGOUT,this._reset,this),Qt.notificationCenter.subscribeInnerEvent(rs.DESTROY,this._dispose,this)}get _messagesByConversation(){return li.getMessages()}storeConversationMessage(e,t=!1){var s=e["conversationID"];return!!s&&(this._messagesByConversation.has(s)||this._messagesByConversation.set(s,new Map),!this._shouldSkipStoreMessage(e,t))&&(t=this._getUniqueIdOfMessage(e),this._messagesByConversation.get(s).set(t,e),this._updateLatestMessageMap(e),!0)}_updateLatestMessageMap(e){var t=e["conversationID"];"out"===e.flow?this._setLatestMsgSentByMe(t,e):t.startsWith("C2C")&&this._setLatestMsgSentByPeer(t,e)}_shouldSkipStoreMessage(e,t){var s=this._getUniqueIdOfMessage(e),n=this._messagesByConversation.get(e.conversationID);if(null!=n&&n.has(s)){let e=null==n?void 0:n.get(s);if(!t||!0===(null==e?void 0:e.isModified))return!0}return!1}deleteConversationMessage(e){var{conversationID:t=""}=e,e=this._getUniqueIdOfMessage(e);this._messagesByConversation.has(t)&&null!=(t=this._messagesByConversation.get(t))&&t.delete(e)}modifyConversationMessage(a,t){var l;if(this._messagesByConversation.has(a)||this._sparseMessagesByConversation.has(a)){let e=this._getUniqueIdOfMessage(t),o=this._getMessageFromLocalMessage(a,e);if(o){let{messageVersion:s,elements:n,cloudCustomData:i,checkResult:e=0}=t,r=1<e;if(console.log(`conversationToMessageMap modifyConversationMessage localVersion:${o.version} remoteVersion:`+s),o.version<s){let e=this._getUniqueIdOfMessage(o),t=ye(n);return null!=(l=this._messagesByConversation.get(a))&&l.has(e)?li.updateMessage(a,[e],{isModified:!0,version:s,_elements:t,payload:t[0].content,type:t[0].type,cloudCustomData:i,hasRiskContent:r,operation:ds.modify}):(o.version=s,o._elements=t,o.payload=o._elements[0].content,o.type=o._elements[0].type,o.cloudCustomData=i,o.isModified=!0,o.hasRiskContent=r),{isUpdated:!0,message:o}}return{isUpdated:!1,message:o}}}return{isUpdated:!1,message:null}}_getMessageFromLocalMessage(e,s){var t;if(this._messagesByConversation.has(e))return null==(t=this._messagesByConversation.get(e))?void 0:t.get(s);if(this._sparseMessagesByConversation.has(e)){let t=[...this._sparseMessagesByConversation.get(e).values()];for(let e=0;e<t.length;e++)if(this._getUniqueIdOfMessage(t[e])===s)return t[e]}return null}findMessage(t){let s=null,e=Array.from(this._messagesByConversation.values());for(var n of e)if(s=Array.from(n.values()).find(e=>e.ID===t)||null)break;if(!s){let e=Array.from(this._sparseMessagesByConversation.values());for(var i of e)if(s=i.get(t)||null,s)break}return s}deleteConversationMessageList(e){this._messagesByConversation.has(e)&&(this._messagesByConversation.delete(e),this._latestMessageSentByMeMap.delete(e),this._latestMessageSentByPeerMap.delete(e)),this._sparseMessagesByConversation.has(e)&&this._sparseMessagesByConversation.delete(e)}revokeMessage({conversationID:t,sequence:s,random:n,revoker:i}){let e=this._messagesByConversation.get(t),r=null;if(e){var o=Array.from(e.values());if(r=this._findMessageBySequenceAndRandom({messageList:o,random:n,sequence:s})){let e=this._getUniqueIdOfMessage(r);return li.updateMessage(t,[e],{isRevoked:!0,revoker:i,operation:ds.revoke}),r}}if(this._sparseMessagesByConversation.has(t)){let e=Array.from(this._sparseMessagesByConversation.get(t).values());if(r=this._findMessageBySequenceAndRandom({messageList:e,random:n,sequence:s}))return r.isRevoked=!0,r.revoker=i,r}}_findMessageBySequenceAndRandom({messageList:t,sequence:s,random:n}){for(let e=0;e<t.length;e+=1){var i=t[e];if(i.sequence===s&&(T(n)||i.random===n))return i}return null}prependLocalMessageList(e){let{messageList:s,conversationID:t}=e;if(0===s.length)return[];var n=[],i=[],r=this._messagesByConversation.get(t)||new Map;for(let t of s){let e=this._getUniqueIdOfMessage(t);r.has(e)||(n.push(t),i.push([e,t]))}if(0<i.length){let e=new Map([...i,...r.entries()]);this._messagesByConversation.set(t,e),this._updateLatestMessageSentByMe(t),this._updateLatestMessageSentByPeer(t)}return n}storeSparseMessageList(n){if(0!==n.length){let e=n[0]["conversationID"],s=n.length;this._sparseMessagesByConversation.has(e)||this._sparseMessagesByConversation.set(e,new Map);var i=this._sparseMessagesByConversation.get(e);for(let t=0;t<s;t++){let e=n[t];i.has(e.ID)||i.set(e.ID,e)}}}_updateLatestMessageSentByMe(t){var e,s=Array.from((null==(e=this._messagesByConversation.get(t))?void 0:e.values())||[]);if(0!==s.length)for(let e=s.length-1;0<=e;e--)if("out"===s[e].flow){this._setLatestMsgSentByMe(t,s[e]);break}}_updateLatestMessageSentByPeer(t){var e,s=Array.from((null==(e=this._messagesByConversation.get(t))?void 0:e.values())||[]);if(0!==s.length&&t.startsWith("C2C"))for(let e=s.length-1;0<=e;e--)if("in"===s[e].flow){this._setLatestMsgSentByPeer(t,s[e]);break}}_getUniqueIdOfMessage(e){var{from:e,to:t,random:s,sequence:n,time:i}=e;return e+`-${t}-${s}-${n}-`+i}_setLatestMsgSentByPeer(e,t){this._latestMessageSentByPeerMap.set(e,t)}_setLatestMsgSentByMe(e,t){this._latestMessageSentByMeMap.set(e,t)}getLatestMsgSentByPeer(e){return this._latestMessageSentByPeerMap.get(e)}getLatestMsgSentByMe(e){return this._latestMessageSentByMeMap.get(e)}addRandomOfSentMessage(e){this._randomOfSentMessageList.append(e)}removeRandomOfSentMessage(e){this._randomOfSentMessageList.delete(e)}updateNickAndAvatarOfSentMessage(e){let{conversationID:t="",latestAvatar:r,latestNick:o,isSentByMe:s=!0}=e,n=this._messagesByConversation.get(t);if(n){let e=Array.from(n.values()),i=s?"out":"in";e.forEach(e=>{var{nick:t,avatar:s,flow:n}=e;n===i&&(t!==o&&(e.nick=o),s!==r)&&(e.avatar=r)})}}isInMessageList(e){var t=e["conversationID"];return!!t&&!!this._messagesByConversation.has(t)&&(e=this._getUniqueIdOfMessage(e),null==(t=this._messagesByConversation.get(t))?void 0:t.has(e))}isMessageSentByCurrentInstance(e){e=e.random;return this._randomOfSentMessageList.has(e)}getContinuousMessagesByConversation(){return this._messagesByConversation}getLocalMessageList(e){e=this._messagesByConversation.get(e);return e?[...e.values()]:[]}getSparseMessageList(e){e=this._sparseMessagesByConversation.get(e);return e?[...e.values()]:[]}_reset(){this._messagesByConversation.clear(),this._latestMessageSentByPeerMap.clear(),this._latestMessageSentByMeMap.clear(),this._randomOfSentMessageList.clear()}_dispose(){this._reset(),Qt.notificationCenter.unSubscribeInnerEvent(rs.LOGOUT,this._reset,this),Qt.notificationCenter.unSubscribeInnerEvent(rs.DESTROY,this._dispose,this)}};function lo(e,t){var s,n,i,r,o,a,l,c=ai.getConversation(e);null!=c&&c.lastMessage&&(c=c["lastMessage"],{lastTime:s,lastSequence:n,version:i}=c,{time:t,sequence:r,messageVersion:o,elements:a,cloudCustomData:l}=t,s===t)&&n===r&&i!==o&&(c.type=a[0].type,c.payload=a[0].content,c.messageForShow=In(c.type,c.payload),c.cloudCustomData=l,c.version=o,ai.updateConversation(e,{lastMessage:c}))}class uo{init(){_i.getInstance().registerApi({apiName:"modifyMessage",context:this})}modifyMessage(c){return C(this,void 0,void 0,function*(){let{to:n,payload:t,sequence:i,conversationType:r,random:o,time:a,from:l,type:s}=c;if(this._canModifyMessageElement(s)){let e=c.getElements();1<e.length&&(e[0].type=s,e[0].content=t)}try{let t=null,s;if(r===fi.CONV_C2C?t=yield function(u){return C(this,void 0,void 0,function*(){let{from:e,to:t,version:s=0,sequence:n,random:i,time:r,type:o,cloudCustomData:a}=u,l={From_Account:e,To_Account:t,MsgVersion:s,MsgSeq:n,MsgRandom:i,MsgTime:r,MsgType:o,MsgBody:u.transformElementsToServerFormat(),CloudCustomData:a},c=yield gn({servcmd:"openim.modify_c2c_msg",data:l});if(c){let{MsgBody:e,MsgVersion:t,CloudCustomData:s}=c;return{elements:qi(e),messageVersion:t,cloudCustomData:s}}})}(c):r===fi.CONV_GROUP&&(t=yield function(o){return C(this,void 0,void 0,function*(){let{to:e,version:t=0,sequence:s,cloudCustomData:n}=o,i={GroupId:e,MsgVersion:t,MsgSeq:s,MsgBody:o.transformElementsToServerFormat(),CloudCustomData:n},r=yield gn({servcmd:"openim.modify_group_msg",data:i});if(r){let{MsgBody:e,MsgVersion:t,CloudCustomData:s}=r;return{elements:qi(e),messageVersion:t,cloudCustomData:s}}})}(c)),t){let e=""+r+n;return n===mn()&&r===fi.CONV_C2C&&(e=""+r+l),s={conversationType:r,from:l,to:n,time:a,random:o,sequence:i,elements:null==t?void 0:t.elements,cloudCustomData:null==t?void 0:t.cloudCustomData,messageVersion:null==t?void 0:t.messageVersion,conversationID:e},this._handleModifyMessageSuccess(s),{code:0,data:{message:c},successLog:{message:"to:"+n}}}}catch(e){let t=(e||{})["errorCode"];throw new Zs({functionName:"modifyMessage",code:t})}})}_handleModifyMessageSuccess(e){var t=e["conversationID"],{isUpdated:s,message:n}=Qt.message.messageDataHandler.modifyConversationMessage(t,e);!0===s&&Qt.notificationCenter.emitOuterEvent(is.MESSAGE_MODIFIED,{name:is.MESSAGE_MODIFIED,data:[n]}),Qt.notificationCenter.emitInnerEvent(rs.MESSAGE_MODIFIED,{conversationID:t,message:n}),lo(t,e)}_canModifyMessageElement(e){return[Si.MSG_TEXT,Si.MSG_CUSTOM,Si.MSG_LOCATION,Si.MSG_FACE].includes(e)}}class _o{init(){var e=Qt["notificationCenter"],t=e["InnerEventSubType"];cn.getInstance().registerWorkflowStep(As.RECEIVE_C2C_NEW_MESSAGE,Ns.HANDLE_C2C_NEW_MESSAGE,this._handleC2CMessagePush,this),cn.getInstance().registerWorkflowStep(As.RECEIVE_C2C_NEW_MESSAGE,Ns.EMIT_C2C_MESSAGE_EVENT,this._emitMessageEventsAfterReceiveNewMessage,this),cn.getInstance().registerWorkflowStep(As.SYNC_SERVER_INFO_AFTER_RE_ONLINE,Ns.EMIT_C2C_MESSAGE_EVENT,this._emitMessageEventsAfterSyncUnreadMessage,this),e.subscribeInnerEvent(rs.MESSAGE_PUSH,t.C2C_REALTIME_MESSAGE,this._executeReceiverNewMessageWorkFlow,this),e.subscribeInnerEvent(rs.MESSAGE_PUSH,t.C2C_MESSAGE_MODIFIED,this._handleC2CMessageModify,this),e.subscribeInnerEvent(rs.DESTROY,this._dispose,this)}_executeReceiverNewMessageWorkFlow(e){cn.getInstance().executeWorkflow(As.RECEIVE_C2C_NEW_MESSAGE,e)}_handleC2CMessagePush(e){let t=e.data||{},s=(Qt.message||{})["messageDataHandler"],n=[],i=new Map;return t.C2cMsgArray.forEach(e=>{e=this._generateC2CMessage(e);this._updateMessageProfile(e);let t=1===e.isModified;s.isMessageSentByCurrentInstance(e)?e.isModified=t:t=!1,e.isOnlineMessage()?(e._onlineOnlyFlag=!0,s.isMessageSentByCurrentInstance(e)||n.push(e)):Hi(e)&&(s.storeConversationMessage(e)&&Yi({conversationUpdateFields:i,message:e}),s.isMessageSentByCurrentInstance(e)&&!t||n.push(e))}),{conversationUpdateFieldList:[...i.values()],messages:n}}_emitMessageEventsAfterReceiveNewMessage(e){var{messages:e=[]}=(null==(e=e.result)?void 0:e[Ns.HANDLE_C2C_NEW_MESSAGE])||{};this._emitMessageEvents(e)}_emitMessageEventsAfterSyncUnreadMessage(e){var{messages:e=[]}=(null==(e=e.result)?void 0:e[Ns.UNREAD_MESSAGE_SYNC])||{};this._emitMessageEvents(e)}_emitMessageEvents(e){var t=(null==e?void 0:e.filter(e=>!0===(null==e?void 0:e.isModified)))||[],t=(0<t.length&&Qt.notificationCenter.emitOuterEvent("onMessageModified",{name:"onMessageModified",data:t}),null==e?void 0:e.filter(e=>!(null!=e&&e.isModified)));0<t.length&&Qt.notificationCenter.emitOuterEvent("onMessageReceived",{name:"onMessageReceived",data:t})}_generateC2CMessage(e){var t=fi.CONV_C2C,e=Bi(e),t=Qt.message.messageFactory.createMessage(Object.assign(Object.assign({},e),{conversationType:t,flow:Ti.IN})),e=e["elements"];return t.setElement(e),t}_updateMessageProfile(n){var e;let i=(Qt.message||{})["messageDataHandler"],t=null==(e=Qt.store.get("login"))?void 0:e.userId,{from:s,nick:r,avatar:o,conversationID:a=""}=n;if(s!==t){let s=i.getLatestMsgSentByPeer(a);if(s){let{nick:e,avatar:t}=s;T(r)||T(o)?(n.nick=M(e)?e:n.nick,n.avatar=M(t)?t:n.avatar):r===e&&o===t||(i.updateNickAndAvatarOfSentMessage({conversationID:a,latestNick:r,latestAvatar:o,isSentByMe:!1}),this._updateConversationUserProfile({conversationID:a,nick:r,avatar:o}))}}else{let e=i.getLatestMsgSentByMe(a);!e||r===e.nick&&o===e.avatar||i.updateNickAndAvatarOfSentMessage({conversationID:a,latestNick:r,latestAvatar:o,isSentByMe:!0})}}_updateConversationUserProfile(e){var{conversationID:e,nick:t,avatar:s}=e,{userProfile:n={}}=ai.getConversation(e)||{};n.avatar===s&&n.nick===t||ai.updateConversation(e,{userProfile:Object.assign(Object.assign({},n),{nick:t,avatar:s})})}_updateMessageListDueToModify(e){var t=e["conversationID"],{isUpdated:s,message:n}=Qt.message.messageDataHandler.modifyConversationMessage(t,e);!0===s&&Qt.notificationCenter.emitOuterEvent("onMessageModified",{name:"onMessageModified",data:[n]}),Qt.notificationCenter.emitInnerEvent("ModifyMessageSuccess",e),lo(t,e)}_handleC2CMessageModify(e){e.C2cMsgModNotifys.forEach(e=>{var t=fi.CONV_C2C,e=xi(e),{to:s,from:n}=e;let i=""+t+s;s===(null==(s=Qt.store.get("login"))?void 0:s.userId)&&(i=""+t+n),e=Object.assign({conversationType:t,conversationID:i},e),this._updateMessageListDueToModify(e)})}_dispose(){var e=Qt["notificationCenter"],e=e["InnerEventSubType"];Qt.notificationCenter.unSubscribeInnerEvent(rs.MESSAGE_PUSH,e.C2C_REALTIME_MESSAGE,this._handleC2CMessagePush,this),Qt.notificationCenter.unSubscribeInnerEvent(rs.MESSAGE_PUSH,e.C2C_MESSAGE_MODIFIED,this._handleC2CMessageModify,this),Qt.notificationCenter.unSubscribeInnerEvent(rs.DESTROY,this._dispose,this)}}class ho{init(){var e=Qt["notificationCenter"],t=e["InnerEventSubType"];cn.getInstance().registerWorkflowStep(As.RECEIVE_GROUP_NEW_MESSAGE,Ns.HANDLE_GROUP_NEW_MESSAGE,this._handleGroupMessagePush,this),cn.getInstance().registerWorkflowStep(As.RECEIVE_GROUP_NEW_MESSAGE,Ns.EMIT_GROUP_MESSAGE_EVENT,this._emitMessageEvents,this),e.subscribeInnerEvent(rs.MESSAGE_PUSH,t.GROUP_REALTIME_MESSAGE,this._executeReceiverNewMessageWorkFlow,this),e.subscribeInnerEvent(rs.MESSAGE_PUSH,t.GROUP_MESSAGE_MODIFIED,this._handleGroupMessageModify,this),e.subscribeInnerEvent(rs.DESTROY,this._dispose,this)}_executeReceiverNewMessageWorkFlow(e){this._canExecuteReceiverNewMessageWorkFlow(e)&&cn.getInstance().executeWorkflow(As.RECEIVE_GROUP_NEW_MESSAGE,e)}_handleGroupMessagePush(e){let t=e.data||{},s=Qt.message["messageDataHandler"],n=[],i=new Map,r=null==t?void 0:t.GroupMsgArray;return null!=r&&r.forEach(e=>{var t;1!==e.GroupInfo.NotVisible&&(e=this._generateGroupMessage(e),this.updateMessageProfile(e),t=1===e.isModified,s.isMessageSentByCurrentInstance(e)&&(e.isModified=t),e.isOnlineMessage()?(e._onlineOnlyFlag=!0,s.isMessageSentByCurrentInstance(e)||n.push(e)):Hi(e)&&s.storeConversationMessage(e)&&(n.push(e),Yi({conversationUpdateFields:i,message:e})))}),{conversationUpdateFieldList:[...i.values()],messages:n}}_emitMessageEvents(e){var e=((null==(e=e.result)?void 0:e[Ns.HANDLE_GROUP_NEW_MESSAGE])||{})["messages"],t=(null==e?void 0:e.filter(e=>!0===(null==e?void 0:e.isModified)))||[],t=(0<t.length&&Qt.notificationCenter.emitOuterEvent("onMessageModified",{name:"onMessageModified",data:t}),(null==e?void 0:e.filter(e=>!(null!=e&&e.isModified)))||[]);0<t.length&&Qt.notificationCenter.emitOuterEvent("onMessageReceived",{name:"onMessageReceived",data:t})}_generateGroupMessage(e){var t=fi.CONV_GROUP,e=Vi(e),t=Qt.message.messageFactory.createMessage(Object.assign(Object.assign({},e),{conversationType:t,flow:Ti.IN})),e=e["elements"];return t.setElement(e),t}updateMessageProfile(i){var e;let t=(Qt.message||{})["messageDataHandler"],s=null==(e=Qt.store.get("login"))?void 0:e.userId,{from:n,nick:r,avatar:o,conversationID:a="",_elements:l}=i;if(n===s){let e=t.getLatestMsgSentByMe(a);!e||r===e.nick&&o===e.avatar||t.updateNickAndAvatarOfSentMessage({conversationID:a,latestNick:r,latestAvatar:o,isSentByMe:!0})}else if(n===Ms.CONV_SYSTEM){let{operationType:e,memberInfoList:t,operatorInfo:s}=l,n={};if(Oe(t)?Oe(s)||(n=s):[Cs.JOINED,Cs.KICKED,Cs.ADMIN_SET,Cs.ADMIN_CANCELED].includes(e)&&(n=Object.assign({},t[0])),!Oe(n)){let{nick:e="",avatar:t=""}=n;i.nick=e,i.avatar=t}}}_updateMessageListDueToModify(e){var t=e["conversationID"],{isUpdated:s,message:n}=Qt.message.messageDataHandler.modifyConversationMessage(t,e);!0===s&&Qt.notificationCenter.emitOuterEvent("onMessageModified",{name:"onMessageModified",data:[n]}),lo(t,e)}_handleGroupMessageModify(e){e.GroupMsgModNotifys.forEach(e=>{var t=fi.CONV_GROUP,{topicID:s,groupID:n}=e=Wi(e),s=s||n,e=Object.assign({conversationType:t,conversationID:""+t+s,to:s},e);this._updateMessageListDueToModify(e)})}_dispose(){var e=Qt["notificationCenter"],{GROUP_REALTIME_MESSAGE:t,GROUP_MESSAGE_MODIFIED:s}=e["InnerEventSubType"];e.unSubscribeInnerEvent(rs.MESSAGE_PUSH,t,this._handleGroupMessagePush,this),e.unSubscribeInnerEvent(rs.MESSAGE_PUSH,s,this._handleGroupMessageModify,this),e.unSubscribeInnerEvent(rs.DESTROY,this._dispose,this)}_canExecuteReceiverNewMessageWorkFlow(e){var{GroupId:e,GroupType:t}=(null==(e=null==(e=null==e?void 0:e.GroupMsgArray)?void 0:e[0])?void 0:e.GroupInfo)||{},t=t===vs.GRP_AVCHATROOM;return!(!ci.getGroup(e)&&t)}}var go=new class{constructor(){this.c2cMessageReceiver=new _o,this.groupMessageReceiver=new ho}init(){this.c2cMessageReceiver.init(),this.groupMessageReceiver.init()}};let po={createCustomMessage:{to:{required:!0,rules:["string"],allowEmpty:!1},conversationType:{required:!0,rules:["string"],allowEmpty:!1},payload:{required:!0,rules:["object"],allowEmpty:!1},cloudCustomData:{required:!1,rules:["string"],allowEmpty:!1},priority:{required:!1,rules:["string"],allowEmpty:!1},customModerationConfigurationID:{required:!1,rules:["string"],allowEmpty:!1}},sendMessage:[{key:"message",required:!0,rules:["object"],allowEmpty:!1},{key:"options",required:!1,rules:["object"],allowEmpty:!1}],createTextMessage:{to:{required:!0,rules:["string"],allowEmpty:!1},conversationType:{required:!0,rules:["string"],allowEmpty:!1,customValidator:e=>!(!e.startsWith("C2C")&&!e.startsWith("GROUP"))||"conversationType is invalid."},payload:{required:!0,rules:["object"],allowEmpty:!1,customValidator:e=>{return"string"==typeof(null==e?void 0:e.text)&&("string"!=typeof e.text||0!==(null==(e=null==e?void 0:e.text)?void 0:e.length))||"payload.text must be a string"}}}},Eo={createCustomMessage:!0,sendMessage:!0,modifyMessage:!0};var fo=new class{getGroupRoamingMessagesByAnchor(i){return C(this,void 0,void 0,function*(){try{var{conversationID:t,count:s,direction:l,sequence:c,messageSequenceList:e,getType:n}=i,u=t.replace(fs.CONV_GROUP,""),_=[];let a=c;if(l===_s.BACKWARD){if("number"!=typeof c)return{messageList:[],hasNoMoreHistoryMessage:!1,nextReqMessageIDFromServer:""};a=c+s-1}var d=yield function(r){return C(this,void 0,void 0,function*(){var{groupID:e,count:t,messageSequence:s,messageSequenceList:n,getType:i}=r,e={GroupId:e,ReqMsgNumber:t,WithRecalledMsg:1,Version:1,GetType:i};return s&&(e.ReqMsgSeq=s),y(n)&&0<n.length&&(e.ReqMsgSeqList=n),yield gn({servcmd:"group_open_http_svc.group_msg_get",data:e})})}({groupID:u,count:s,messageSequence:a,messageSequenceList:e,getType:n});if(d){let{RspMsgList:t=[],NextReqMsgSeq:e=0,IsFinished:s,InvisibleMsgSeq:n}=d,i=`groupID:${u} sequence:${c} reqSeq:${a} direction:${l} complete:${s} nextSequence:${e} remoteMsgCount:${t.length} invisibleSequenceList:`+n,r=[];for(let e=0;e<t.length;e++){var h=t[e],g=(h.From_Account===Ms.CONV_SYSTEM&&_.push(h),this._parseMessage(h));r.push(g)}r.reverse();let o=s===Mi;l===_s.BACKWARD&&(o=r[r.length-1].sequence>=c);var p=Ki(r);return Qt.ssoLog.info("getGroupRoamingMessagesByAnchor",i),{messageList:p,invisibleSequenceList:n,nextReqMessageIDFromServer:e,hasNoMoreHistoryMessage:o,serverGroupTipList:_}}}catch(e){var{errorCode:t,errorInfo:s}=e||{};throw new Zs({code:t,message:s})}})}_parseMessage(e){var t=fs.CONV_GROUP,e=(4===e.Event&&(e.MsgBody.MsgType=Ms.MSG_GRP_TIP),Vi(e)),t=Di.createMessage(Object.assign(Object.assign({},e),{conversationType:t,flow:"in"}));return t.setElement(e.elements),t}};class mo{constructor(){this.messageHelper=ji,this.messageFactory=Di,this.messageSender=new oo,this.messageAction=new uo,this.messageReceiver=go,this.messageDataHandler=co,this.messageHistory=fo,this.messageSender.init(),this.messageFactory.init(),this.messageAction.init(),this.messageReceiver.init(),this.messageDataHandler.init(),rn({auth:Eo,params:po})}}let So="Tag_Profile_IM_",vo={NICK:So+"Nick",GENDER:So+"Gender",BIRTHDAY:So+"BirthDay",LOCATION:So+"Location",SELFSIGNATURE:So+"SelfSignature",ALLOWTYPE:So+"AllowType",LANGUAGE:So+"Language",AVATAR:So+"Image",MESSAGESETTINGS:So+"MsgSettings",ADMINFORBIDTYPE:So+"AdminForbidType",LEVEL:So+"Level",ROLE:So+"Role"},Io="Tag_Profile_Custom",Co="profileCustomField",To="USER_STATUS",Mo=1,Oo=1e3,yo={userID:"",nick:"",gender:"Gender_Type_Unknown",birthday:0,location:"",selfSignature:"",allowType:"AllowType_Type_AllowAny",language:0,avatar:"",messageSettings:0,adminForbidType:"AdminForbid_Type_None",level:0,role:0,lastUpdatedTime:0,profileCustomField:[]},Ao=new Map([[vo.NICK,"nick"],[vo.GENDER,"gender"],[vo.BIRTHDAY,"birthday"],[vo.LOCATION,"location"],[vo.SELFSIGNATURE,"selfSignature"],[vo.ALLOWTYPE,"allowType"],[vo.LANGUAGE,"language"],[vo.AVATAR,"avatar"],[vo.MESSAGESETTINGS,"messageSettings"],[vo.ADMINFORBIDTYPE,"adminForbidType"],[vo.LEVEL,"level"],[vo.ROLE,"role"]]);var Yo,Ko,Ho,No=new class{createProfile(e,t){let s={userID:e,profileCustomField:[]};return t.forEach(e=>{var{tag:e,value:t}=e;e&&-1<e.indexOf(Io)?s.profileCustomField.push({key:e,value:t}):Ao.has(e)&&(s[Ao.get(e)]=t)}),Object.assign(Object.assign({},yo),s)}parseProfileItem(e=[]){let t=[];return e.forEach(e=>{t.push({tag:e.Tag,value:e.Value})}),t}parseProfileList(e=[]){let t=[];return e.forEach(e=>{t.push({tag:e.Tag,value:e.ValueBytes})}),t}convertParamsToProfile(t){let s=[];return Object.keys(t).forEach(e=>{e!==Co&&s.push({tag:vo[e.toUpperCase()],value:t[e]})}),t.profileCustomField&&y(t.profileCustomField)&&t.profileCustomField.forEach(e=>{s.push({tag:e.key,value:e.value})}),s}normalizeProfileFields(e){let n={},i=[];return e.forEach(e=>{var{tag:t,value:s}=e;if(t&&-1<t.indexOf(Io)&&i.push({key:t,value:s}),Ao.has(t)&&void 0!==s){let e=Ao.get(t);n[e]=s}}),0<i.length&&(n.profileCustomField=i),n}};let Ro=Qt.common["generateProtocolData"];function Do(n){return C(this,void 0,void 0,function*(){let e="profile.portrait_get_all",t={From_Account:mn(),UserItem:[]};n.forEach(e=>{t.UserItem.push({CustomSequence:0,StandardSequence:0,To_Account:e})});var r=Ro({servcmd:e,data:t}),s=r.head.seq+e,r=yield Qt.channel.sendPacket(r,{requestId:s});if(r){let{ActionStatus:e,ErrorCode:t,ErrorDisplay:s,ErrorInfo:n,UserProfileItem:i}=r,o=[];return i.map(e=>{var{To_Account:e,CustomSequence:t,ResultCode:s,ResultInfo:n,StandardSequence:i,ProfileItem:r}=e,r=No.parseProfileItem(r);o.push({userId:e,customSequence:t,resultCode:s,resultInfo:n,standardSequence:i,profileItem:r})}),{actionStatus:e,errorCode:t,errorDisplay:s,errorInfo:n,userProfile:o}}})}function Po(e){return ui.getFriendMap().has(e)}let bo=Qt.utils["isEmpty"];class wo{constructor(){this._strangerProfileMap=new Map}init(){_i.getInstance().registerApi({apiName:"getMyProfile",context:this}),_i.getInstance().registerApi({apiName:"getUserProfile",context:this}),_i.getInstance().registerApi({apiName:"updateMyProfile",context:this}),this.createProfile=No.createProfile.bind(No);var e=Qt["notificationCenter"];cn.getInstance().registerWorkflowStep(As.SYNC_SERVER_INFO_AFTER_LOGIN,Ns.USER_PROFILE_SYNC,this.getMyProfileCacheThenServer,this),e.subscribeInnerEvent(rs.MESSAGE_PUSH,e.InnerEventSubType.PROFILE_MODIFIED,this._onProfileDataModify,this),e.subscribeInnerEvent(rs.LOGOUT,this._reset,this),e.subscribeInnerEvent(rs.DESTROY,this._dispose,this)}getMyProfile(){return C(this,void 0,void 0,function*(){try{var e,t=mn(),s=yield Do([t]);if(s)return e=this._handleProfileFormResponse(s)[0],ui.getUserProfileMap().set(t,e),{code:0,data:e}}catch(e){var{errorCode:s,errorInfo:t}=e;throw new Zs({functionName:"getMyProfile",code:s,message:t})}})}getUserProfile(l){return C(this,void 0,void 0,function*(){try{var t=l["userIDList"],{userIdListToRequest:e,profileFromCache:s}=this._filterRequestAndCacheUsers(t);if(0===e.length)return{code:0,data:s,successLog:{message:"userIDList.length:"+t.length}};e.length>Oo&&(Qt.ssoLog.warn("getUserProfile","userIdListToRequest.length > 1000"),e.length=Oo);var{data:n,error:i}=yield this._batchFetchUserProfiles(e),r=e.length,o=n.length,a=r-o;if(0===s.length&&r===a&&!bo(i))throw i;if(y(n)){n.forEach(e=>{(Po(e.userID)?ui.getUserProfileMap():this._strangerProfileMap).set(e.userID,e)});let e=n.concat(s);return{code:0,data:e,successLog:{message:`getUserProfile query:${r} success:${o} fail:${a} from cache:`+s.length}}}}catch(e){t=e["errorCode"];throw new Zs({functionName:"getUserProfile",code:t})}})}getMyProfileCacheThenServer(){return C(this,void 0,void 0,function*(){var e=mn(),e=ui.getUserProfileMap().has(e);return e?{code:0,data:e}:this.getMyProfile()})}updateMyProfile(a){return C(this,void 0,void 0,function*(){let t=mn(),s={};for(let e in a)void 0!==a[e]&&(s[e]=a[e]);var n=No.convertParamsToProfile(s);try{let e={From_Account:t,ProfileItem:n};yield function(n){return C(this,void 0,void 0,function*(){let e="profile.portrait_set",t=Ro({servcmd:e,data:n}),s=""+t.head.seq+e,i=yield Qt.channel.sendPacket(t,{requestId:s});if(i){let{ActionStatus:e,ErrorCode:t,ErrorDisplay:s,ErrorInfo:n}=i;return{actionStatus:e,errorCode:t,errorDisplay:s,errorInfo:n}}})}(e);var i=ui.getUserProfile(t),r=i?Object.assign(Object.assign({},i),s):No.createProfile(t,n),o=!ts(i,r,["lastUpdatedTime"]);return r.lastUpdatedTime=Date.now(),ui.getUserProfileMap().set(t,r),o&&this._emitProfileUpdated(r),{code:0,data:r,successLog:{message:"profileArray: "+Qt.utils.safeStringify(n)}}}catch(e){let{errorCode:t,errorInfo:s}=e;throw new Zs({functionName:"updateMyProfile",code:t,message:s})}})}updateMyNickAndAvatar(i){return C(this,void 0,void 0,function*(){var e=mn(),t=Date.now(),s=ui.getUserProfile(e),n={};(n=s?Object.assign(s,i):No.createProfile(e,i)).lastUpdatedTime=t,ui.getUserProfileMap().set(e,n)})}_onProfileDataModify(n){var e,t=function(){var{Profile_Account:e,PushType:t,ProfileList:s}=n.ProfileDataMod[0];return{userId:e,pushType:t,profileList:No.parseProfileList(s)}}();bo(t)||({isProfileUpdated:t,profile:e}=this._handleProfileModified(t),t&&this._emitProfileUpdated(e))}_emitProfileUpdated(e){Qt.notificationCenter.emitInnerEvent(rs.PROFILE_UPDATE,{name:rs.PROFILE_UPDATE,data:[e]}),Qt.notificationCenter.emitOuterEvent(is.PROFILE_UPDATED,{name:is.PROFILE_UPDATED,data:[e]}),ai.updateConversation("C2C"+(null==e?void 0:e.userID),{userProfile:e})}_dispose(){var e=Qt["notificationCenter"];e.unSubscribeInnerEvent(rs.LOGOUT,this._reset,this),e.unSubscribeInnerEvent(rs.MESSAGE_PUSH,e.InnerEventSubType.PROFILE_MODIFIED,this._onProfileDataModify,this),e.unSubscribeInnerEvent(rs.DESTROY,this._dispose,this),this._reset()}_handleProfileModified(e){let{userId:t,profileList:s}=e,n=ui.getUserProfile(t);if(!(mn()===t||Po(t)&&n))return{isProfileUpdated:!1,profile:null};let i=No.normalizeProfileFields(s),r=Object.keys(i).some(e=>e===Co?!ts(n.profileCustomField,i.profileCustomField):n[e]!==i[e]);return r?(e=Date.now(),e=Object.assign(Object.assign(Object.assign({},n),i),{lastUpdatedTime:e}),ui.getUserProfileMap().set(t,e),{isProfileUpdated:r,profile:e}):{isProfileUpdated:!1,profile:n}}_filterRequestAndCacheUsers(e){let s=[],n=[];return e.forEach(e=>{var t=ui.getUserProfileMap().has(e);Po(e)&&t?n.push(ui.getUserProfile(e)):this._isStrangerAndProfileValid(e)?n.push(this._strangerProfileMap.get(e)):s.push(e)}),{userIdListToRequest:s,profileFromCache:n}}_handleProfileFormResponse(e){e=e.userProfile;if(!Array.isArray(e))return[];let t=e.filter(e=>"@TLS#NOT_FOUND"!==e.userId&&""!==e.userId&&!bo(e.profileItem)),s=Date.now();return t.map(e=>{e=No.createProfile(e.userId,e.profileItem);return e.lastUpdatedTime=s,e})}_isStrangerAndProfileValid(e){var t;return!Po(e)&&({lastUpdatedTime:e=0}=this._strangerProfileMap.get(e)||{},t=(null==(t=Qt.store.get("cloudConfig"))?void 0:t.stranger_profile_expiration_time)||6e5,Date.now()-e<=t)}_chunkUserIDList(s,n){return Array.from({length:Math.ceil(s.length/n)},(e,t)=>s.slice(t*n,(t+1)*n))}_batchFetchUserProfiles(e){return C(this,void 0,void 0,function*(){let t=[],n=[],i={};return this._chunkUserIDList(e,100).forEach(e=>{t.push(Do(e))}),(yield Promise.allSettled(t)).forEach(s=>{if("fulfilled"===s.status){let e=s.value,t=this._handleProfileFormResponse(e);y(t)&&n.push(...t)}else if("rejected"===s.status){let{code:e,message:t}=s.reason||{};i={errorCode:e,message:t}}}),{data:n,error:i}})}_reset(){ui.getUserProfileMap().clear(),this._strangerProfileMap.clear()}}let Lo=new Map,ko=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F"];for(let e=0,t=ko.length;e<t;e++)Lo.set(e,ko[e]);function Uo(e){if(!e)return"";var i=String(e).replace(/[=]+$/,"");let r="";if(i.length%4==1)return"";for(let e,t,s=0,n=0;t=i.charAt(n++);~t&&(e=s%4?64*e+t:t,s++%4)&&(r+=String.fromCharCode(255&e>>(-2*s&6))))t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(t);try{return decodeURIComponent(escape(r))}catch(e){return console.warn(e),""}}let Go=Qt.utils["isEmpty"],Fo=Qt.common["generateProtocolData"];function Bo(i){return C(this,void 0,void 0,function*(){var e,t,s="im_open_status.ws_get_user_status",n=Fo({servcmd:s,data:{To_Account:i}}),s=n.head.seq+s,n=yield Qt.channel.sendPacket(n,{requestId:s});if(n)return{ErrorCode:s,ErrorInfo:n,ErrorList:e=[],UserStatusList:t=[]}=n,{errorCode:s,errorInfo:n,successUserList:t.map(e=>{var{To_Account:e,Status:t,CustomStatus:s}=e;return{userID:e,statusType:t,customStatus:Uo(s)}}),failureUserList:e.map(e=>{var{To_Account:e,Invalid_Account:t,ErrorCode:s,ErrorInfo:n}=e;return{userID:Go(t)?e:t,code:s,message:n}})}})}class xo{constructor(){this._customStatus=""}init(){var e=Qt["notificationCenter"];_i.getInstance().registerApi({apiName:"getUserStatus",context:this}),_i.getInstance().registerApi({apiName:"setSelfStatus",context:this}),_i.getInstance().registerApi({apiName:"subscribeUserStatus",context:this}),_i.getInstance().registerApi({apiName:"unsubscribeUserStatus",context:this}),cn.getInstance().registerWorkflowStep(As.SYNC_SERVER_INFO_AFTER_RE_ONLINE,Ns.USER_STATUS_UPDATE,this._onReOnline,this),e.subscribeInnerEvent(rs.MESSAGE_PUSH,e.InnerEventSubType.USER_STATUS_UPDATE,this._onUserStatusUpdate,this),e.subscribeInnerEvent(rs.LOGOUT,this._reset,this),e.subscribeInnerEvent(rs.DESTROY,this._dispose,this)}setSelfStatus(s){return C(this,void 0,void 0,function*(){let e=mn(),t=s["customStatus"];try{return yield function(i){return C(this,void 0,void 0,function*(){let e="im_open_status.ws_set_custom_status",t=Fo({servcmd:e,data:{CustomStatus:i}}),s=""+t.head.seq+e,n=yield Qt.channel.sendPacket(t,{requestId:s});if(n){let{ErrorCode:e,ErrorInfo:t}=n;return{errorCode:e,errorInfo:t}}})}(t),this._customStatus=t,{code:0,data:{userID:e,statusType:Mo,customStatus:t},successLog:{message:"customStatus: "+t}}}catch(e){let{errorCode:t,errorInfo:s}=e;throw new Zs({functionName:"setSelfStatus",code:t,message:s})}})}getUserStatus(s){return C(this,void 0,void 0,function*(){var{userIDList:e=[]}=s;let t={};return this._isOnlyMeInArray(e)&&(t=this._getMyStatus()),t=yield this._getUserStatus(e),Object.assign(Object.assign({},t),{successLog:{message:"userIDList length: "+e.length}})})}setCustomStatus(e){e=Uo(e);this._customStatus=e}subscribeUserStatus(i){return C(this,void 0,void 0,function*(){try{var{userIDList:e=[]}=i,t=(this._checkBusinessCapabilityBits("subscribeUserStatus"),this._getMaxUserCount("subscribe")),s=yield function(n){return C(this,void 0,void 0,function*(){var e=Qt["channel"],t="im_open_status.ws_status_subscribe",s=Fo({servcmd:t,data:{To_Account:n}}),t=s.head.seq+t;return yield e.sendPacket(s,{requestId:t})})}(this._sliceUserIDList(e,t)),n=this._parseResponse(s);return{code:0,data:{failureUserList:n},successLog:{message:`userID length:${e.length} failCount: `+n.length}}}catch(e){t=e["errorCode"];throw new Zs({functionName:"subscribeUserStatus",code:t})}})}unsubscribeUserStatus(i){return C(this,void 0,void 0,function*(){try{this._checkBusinessCapabilityBits("unsubscribeUserStatus");var{userIDList:e=[]}=i,t=this._getMaxUserCount("unsubscribe"),s=yield function(n){return C(this,void 0,void 0,function*(){var e=Qt["channel"],t="im_open_status.ws_status_unsubscribe",s=0===n.length?{UnsubscribeAll:1}:{To_Account:n},s=Fo({servcmd:t,data:s}),t=s.head.seq+t;return yield e.sendPacket(s,{requestId:t})})}(this._sliceUserIDList(e,t)),n=this._parseResponse(s);return{code:0,data:{failureUserList:n},successLog:{message:`userID length:${e.length} failCount: `+n.length}}}catch(e){t=e["errorCode"];throw new Zs({functionName:"unsubscribeUserStatus",code:t})}})}_onUserStatusUpdate(e){var{UserStatusList:e=[]}=e||{},e=e.map(e=>{var{To_Account:e,Status:t,CustomStatus:s}=e;return{userID:e,statusType:t,customStatus:Uo(s)}});this._emitUserStatusUpdatedEvent(e)}_onReOnline(e){var e=Uo(e.data.customStatus);this._customStatus!==e&&(this._customStatus=e,e={userID:mn(),statusType:Mo,customStatus:e},this._emitUserStatusUpdatedEvent(e))}_emitUserStatusUpdatedEvent(e){Qt.notificationCenter.emitOuterEvent(is.USER_STATUS_UPDATED,{name:is.USER_STATUS_UPDATED,data:e})}_sliceUserIDList(e,t){return e.slice(0,t)}_parseResponse(e){var{ErrorList:e=[]}=e;return e.map(e=>{var{To_Account:e,Invalid_Account:t,ErrorCode:s,ErrorInfo:n}=e;return{userID:Qt.utils.isEmpty(t)?e:t,code:s,message:n}})}_checkBusinessCapabilityBits(e){if(!Qt.store.get("commercialConfig").get(To))throw new Zs({functionName:e,code:Os.NO_USE,replacement1:e})}_getMaxUserCount(e){var t=Qt.store.get("cloudConfig")||{},{key:e,default:s}={query:{key:"status_query_count",default:500},subscribe:{key:"status_sub_count",default:100},unsubscribe:{key:"status_unsub_count",default:100}}[e],t=t[e]||s;return parseInt(t,10)}_getMyStatus(){return{code:0,data:{successUserList:[{userID:mn(),statusType:Mo,customStatus:this._customStatus}],failureUserList:[]}}}_getUserStatus(n){return C(this,void 0,void 0,function*(){try{this._checkBusinessCapabilityBits("getUserStatus");var t=this._getMaxUserCount("query"),{successUserList:e,failureUserList:s}=(yield Bo(this._sliceUserIDList(n,t)))||{};return{code:0,data:{successUserList:e,failureUserList:s}}}catch(e){t=e["errorCode"];throw new Zs({functionName:"getUserStatus",code:t})}})}_isOnlyMeInArray(e){var t=mn();return 1===e.length&&-1<e.indexOf(t)}_dispose(){var e=Qt["notificationCenter"];e.unSubscribeInnerEvent(rs.MESSAGE_PUSH,e.InnerEventSubType.USER_STATUS_UPDATE,this._onUserStatusUpdate,this),e.unSubscribeInnerEvent(rs.DESTROY,this._dispose,this),e.unSubscribeInnerEvent(rs.LOGOUT,this._reset,this),this._reset()}_reset(){this._customStatus=""}}let Vo={getUserProfile:{userIDList:{required:!0,rules:["array"],allowEmpty:!1}},updateMyProfile:{nick:{required:!1,rules:["string"],allowEmpty:!0},avatar:{required:!1,rules:["string"],allowEmpty:!0},gender:{required:!1,rules:["string"],allowEmpty:!0},selfSignature:{required:!1,rules:["string"],allowEmpty:!0},allowType:{required:!1,rules:["string"],allowEmpty:!0},birthday:{required:!1,rules:["number"],allowEmpty:!1},language:{required:!1,rules:["string"],allowEmpty:!0},messageSettings:{required:!1,rules:["string"],allowEmpty:!0},adminForbidType:{required:!1,rules:["string"],allowEmpty:!0},level:{required:!1,rules:["number"],allowEmpty:!1},role:{required:!1,rules:["number"],allowEmpty:!0},profileCustomField:{required:!1,rules:["array"],allowEmpty:!0,customValidator:function(e){for(var t of e){if("object"!=typeof t)return"Each item in profileCustomField must be an object";if("string"!=typeof(null==t?void 0:t.key))return"Each item.key in profileCustomField must be a string";if(null==t||!t.key.startsWith(Io))return'Each item.key in profileCustomField must start with "Tag_Profile_Custom"'}return!0}}},setSelfStatus:{customStatus:{required:!0,rules:["string"],allowEmpty:!0}},getUserStatus:{userIDList:{required:!0,rules:["array"],allowEmpty:!1}},subscribeUserStatus:{userIDList:{required:!0,rules:["array"],allowEmpty:!1}},unsubscribeUserStatus:{userIDList:{required:!1,rules:["array"],allowEmpty:!0}}},$o={getMyProfile:!0,getUserProfile:!0,updateMyProfile:!0,setSelfStatus:!0,getUserStatus:!0,subscribeUserStatus:!0,unsubscribeUserStatus:!0};class qo{constructor(){this.userProfile=new wo,this.userStatus=new xo,this.userProfile.init(),this.userStatus.init(),rn({auth:$o,params:Vo})}}function Wo(t){var s=[];if(M(t)){var n=t.length;if(0!==n)for(let e=n-1;0<=e;e--)"1"===t[e]&&s.push(2**(n-e-1))}return s}!function(e){e.NOT_START="notStart",e.PENDING="pending",e.RESOLVED="resolved",e.REJECTED="rejected"}(Yo=Yo||{}),function(e){e[e.C2C=1]="C2C",e[e.GROUP=2]="GROUP"}(Ko=Ko||{}),function(e){e[e.C2C=8]="C2C",e[e.GROUP=2]="GROUP"}(Ho=Ho||{});class jo{constructor(){this._name="SyncConversationHandler",this._pagingStatus=Yo.NOT_START,this._pagingTimeStamp=0,this._pagingStartIndex=0,this._pagingPinnedTimeStamp=0,this._pagingPinnedStartIndex=0}init(){var e=Qt["notificationCenter"];cn.getInstance().registerWorkflowStep(As.SYNC_SERVER_INFO_AFTER_RE_ONLINE,Ns.CONVERSATION_RECOVER,this._syncConversationList,this),cn.getInstance().registerWorkflowStep(As.SYNC_SERVER_INFO_AFTER_LOGIN,Ns.CONVERSATION_LIST_SYNC,this._syncConversationListAfterLogin,this),e.subscribeInnerEvent(rs.LOGOUT,this._reset,this),e.subscribeInnerEvent(rs.DESTROY,this._dispose,this),Qt.ssoLog.debug(this._name+".init")}isSyncCompleted(){return this._pagingStatus===Yo.RESOLVED}_syncConversationListAfterLogin(){return C(this,void 0,void 0,function*(){return this._pagingStatus=Yo.NOT_START,this._pagingTimeStamp=0,this._pagingStartIndex=0,this._pagingPinnedTimeStamp=0,this._pagingPinnedStartIndex=0,this._syncConversationList()})}_syncConversationList(){return C(this,void 0,void 0,function*(){let{ssoLog:t,utils:{safeStringify:s}}=Qt;t.debug("_syncConversationList","start");try{let e=yield this._pagingGetConversationList(!0);this._pagingStatus=Yo.RESOLVED;var{conversationList:n=[]}=e||{};return t.info("_syncConversationList","success count:"+n.length),e}catch(e){var{errorCode:n,errorInfo:i}=e,n=new Zs({code:n,message:i});t.error("_syncConversationList","fail "+s(e),{error:n})}})}_pagingGetConversationList(u){return C(this,void 0,void 0,function*(){try{var e,t=[],s=(this._pagingStatus=Yo.PENDING,yield function(r){return C(this,void 0,void 0,function*(){var{fromAccount:e,pagingTimeStamp:t,pagingStartIndex:s,pagingPinnedTimeStamp:n,pagingPinnedStartIndex:i}=r;return gn({servcmd:"recentcontact.page_get",data:{AssistFlags:31,MsgAssistFlags:15,OrderType:1,From_Account:e,StartIndex:s,TimeStamp:t,TopStartIndex:i,TopTimeStamp:n}})})}({fromAccount:mn(),pagingTimeStamp:u?this._pagingTimeStamp:0,pagingStartIndex:u?this._pagingStartIndex:0,pagingPinnedTimeStamp:u?this._pagingPinnedTimeStamp:0,pagingPinnedStartIndex:u?this._pagingPinnedStartIndex:0})),{CompleteFlag:n,SessionItem:i=[],TimeStamp:r,StartIndex:o,TopTimeStamp:a,TopStartIndex:l}=s||{};if(0<i.length){let e=this._getConversationOptions(i);t.push(...e);var c=Qt["notificationCenter"];c.emitInnerEvent(rs.SYNC_CONVERSATION_LIST,{conversationUpdateFieldList:e})}return this._pagingTimeStamp=r,this._pagingStartIndex=o,this._pagingPinnedTimeStamp=a,this._pagingPinnedStartIndex=l,1!==n&&(e=(yield this._pagingGetConversationList(u))["conversationList"],t.push(...e)),{conversationList:t}}catch(e){throw e}})}_getConversationOptions(e){let{isUndefined:t}=Qt["utils"],s=this._convertConversationKey(e);return this._filterValidConversations(s).map(e=>(t(e.lastMsg)&&(e.lastMsg={elements:[]}),e.type===Ko.C2C?this._assembleC2COption(e):this._assembleGroupOption(e)))}_filterValidConversations(e){return e.filter(({type:e,userID:t})=>e===Ko.C2C&&!function(e){let t;return"@TLS#ERROR"===(t=e.startsWith(Ms.CONV_C2C)?e.replace(Ms.CONV_C2C,""):t)||"@TLS#NOT_FOUND"===t}(t)||2===e)}_assembleC2COption(e){var t,s=this._createUserprofile(e);return{conversationID:""+Ms.CONV_C2C+e.userID,type:Ms.CONV_C2C,lastMessage:{lastTime:e.time,lastSequence:e.sequence,fromAccount:e.lastC2CMsgFromAccount,type:null!=(t=e.lastMsg)&&t.elements[0]?null==(t=e.lastMsg)?void 0:t.elements[0].type:null,payload:null!=(t=e.lastMsg)&&t.elements[0]?this._amendLayersOverLimitProp(e.lastMsg.elements[0].content):null,cloudCustomData:(null==(t=e.lastMsg)?void 0:t.cloudCustomData)||"",isRevoked:e.lastMessageFlag===Ho.C2C,onlineOnlyFlag:!1,nick:"",nameCard:"",version:0,isPeerRead:this._computeIsPeerRead(e),revoker:(null==(t=null==(t=e.lastMsg)?void 0:t.revokerInfo)?void 0:t.revoker)||null},unreadCount:0,userProfile:s,peerReadTime:e.peerReadTime,isPinned:1===e.isPinned,customData:e.customMark||"",markList:Wo(e.standardMark),conversationGroupList:[],remark:e.friendRemark||"",messageRemindType:this._transMsgRemindType(e.messageRemindType)}}_createUserprofile(e){var{userID:e,nick:t,peerAvatar:s}=e,t=[{tag:"Tag_Profile_IM_Nick",value:t},{tag:"Tag_Profile_IM_Image",value:s}];return null==(s=Qt.user.userProfile)?void 0:s.createProfile(e,t)}_computeIsPeerRead(e){var{lastC2CMsgFromAccount:e,time:t,c2cPeerReadTime:s}=e;return e===mn()&&t<=s}_assembleGroupOption(e){var t;return{conversationID:""+Ms.CONV_GROUP+e.groupID,type:Ms.CONV_GROUP,lastMessage:Object.assign(Object.assign({lastTime:e.time,lastSequence:e.sequence,fromAccount:e.msgGroupFromAccount},this._patchTypeAndPayload(e)),{cloudCustomData:(null==(t=e.lastMsg)?void 0:t.cloudCustomData)||"",isRevoked:e.lastMessageFlag===Ho.GROUP,onlineOnlyFlag:!1,nick:e.msgGroupFromNickName||"",nameCard:e.msgGroupFromCardName||"",revoker:(null==(t=null==(t=e.lastMsg)?void 0:t.revokerInfo)?void 0:t.revoker)||null}),groupProfile:{groupID:e.groupID,name:e.groupNick,avatar:e.groupImage,type:e.groupType,nextMessageSeq:e.nextMessageSeq},unreadCount:this._computeGroupUnreadCount(e),peerReadTime:0,isPinned:1===e.isPinned,version:0,customData:e.customMark||"",markList:Wo(e.standardMark),conversationGroupList:[],messageRemindType:this._transMsgRemindType(e.messageRemindType),subType:e.groupType}}_convertConversationKey(e){return e.map(e=>({type:e.Type,userID:e.To_Account,nick:e.C2cNick,peerAvatar:e.C2cImage,time:e.MsgTimeStamp,sequence:e.MsgSeq,lastC2CMsgFromAccount:e.LastC2cMsgFrom_Account,lastMsg:this._convertLastMsgKey(e.LastMsg),lastMessageFlag:e.LastMsgFlags,c2cPeerReadTime:e.LastC2cMsgPeerReadTime,peerReadTime:e.C2cPeerReadTime,friendRemark:e.C2cRemark,isPinned:e.TopFlags,standardMark:e.StandardMark,customMark:e.CustomMark,messageRemindType:e.MsgRecvOption,groupID:e.ToAccount,groupNick:e.GroupNick,groupImage:e.GroupImage,groupType:e.GroupType,nextMessageSeq:e.GroupNextMsgSeq,msgGroupFromAccount:e.MsgGroupFrom_Account,msgGroupFromNickName:e.MsgGroupFromNickName,MsgGroupFromCardName:e.MsgGroupFromCardName,unreadCount:e.UnreadMsgCount,noUnreadCount:e.GroupIgnoredUnreadSeqCount}))}_convertLastMsgKey(s){var e,t,n=Qt["utils"]["isEmpty"];if(n(s))return null;let i="",r=null;if(!n(s.GroupTips)){let{From_Account:e,GroupName:t}=(null==(n=s.GroupTips)?void 0:n.GroupInfo)||{};i=Ms.MSG_GRP_TIP,r=Object.assign(Object.assign({},this._parseContent(i,s.GroupTips.MsgBody)),{groupProfile:{from:e,groupName:t}})}return s.MsgBody&&(i=null==(e=s.MsgBody[0])?void 0:e.MsgType,r=this._parseContent(i,s.MsgBody[0])),{event:s.Event,elements:[{type:i,content:r,cloudCustomData:s.CloudCustomData}],revokerInfo:{revoker:null==(t=s.RevokerInfo)?void 0:t.revoker}}}_parseContent(e,t){return t&&((e=Qt.message.messageFactory.getElementClass(e))?null==(e=e.parseServerPushElement(t))?void 0:e.content:t)}_amendLayersOverLimitProp(e){var t=e["LayersOverLimit"];return I(e,["LayersOverLimit"]).layersOverLimit=1===t,e}_transMsgRemindType(e){let t="";return 0===e?t=Ms.MSG_REMIND_ACPT_AND_NOTE:1===e?t=Ms.MSG_REMIND_DISCARD:2===e?t=Ms.MSG_REMIND_ACPT_NOT_NOTE:3===e&&(t=Ms.NOT_RECEIVE_OFFLINE_PUSH_EXCEPT_AT),t}_patchTypeAndPayload(e){var t=Qt["utils"]["isUndefined"],{event:e,elements:s=[]}=e.lastMsg||{};return t(e)?{type:s[0]?s[0].type:null,payload:s[0]?this._amendLayersOverLimitProp(s[0].content):null}:{type:Ms.MSG_GRP_TIP,payload:(null==(t=null==s?void 0:s[0])?void 0:t.content)||{}}}_computeGroupUnreadCount(e){var{unreadCount:e=0,noUnreadCount:t=0}=e,e=e-t;return 0<e?e:0}_reset(){this._pagingStatus=Yo.NOT_START,this._pagingTimeStamp=0,this._pagingStartIndex=0,this._pagingPinnedTimeStamp=0,this._pagingPinnedStartIndex=0}_dispose(){this._reset();var e=Qt["notificationCenter"];e.unSubscribeInnerEvent(rs.LOGOUT,this._reset,this),e.unSubscribeInnerEvent(rs.DESTROY,this._dispose,this)}}class zo{constructor(){this.syncConversationHandler=new jo,this.syncConversationHandler.init()}}Qt.ssoLog.debug("TencentCloudLiteChat.VERSION:"+it);var Zo={create:function(e){var{SDKAppID:e,testEnv:t=!1,devMode:s=!1,unlimitedAVChatRoom:n=!1,scene:i="",oversea:r=!1,instance:o,disableIndependentDomain:a=!1}=e,l=e;if("number"!=typeof l&&(e=Number(l),Number.isNaN(e)))return console.error("Create SDK instance failed. Failed to parse the SDKAppID, please check the arguments"),null;if(l=Number(l),ln.has(l))return ln.get(l);let c=null;if(o)(c=o)._workflowManager&&cn.setInstance(c._workflowManager),c._pluginManager&&c._pluginManager.installBuiltInPlugin(ii),!o.isReady()||null!=(o=(e=cn.getInstance()).executeWorkflow)&&o.call(e,As.SYNC_SERVER_INFO_AFTER_LOGIN);else{let e=""+(u()+u())+u()+u()+u()+u()+u()+u();Qt.init({sdkAppId:l,instanceId:e,testEnv:t,devMode:s,unlimitedAVChatRoom:n,disableIndependentDomain:a,scene:i,oversea:r,sdkEdition:ni}),cn.getInstance().init(),Qt.message=new mo,Qt.user=new qo,Qt.login=new Ei,Qt.conversation=new zo,ri.getInstance().installBuiltInPlugin(ii),(c=_i.getInstance().exposeApiForClient())._workflowManager=cn.getInstance(),c._pluginManager=ri.getInstance()}function u(){return(65536*(1+Math.random())|0).toString(16).substring(1)}return ln.set(l,c),c},TSignaling:as,EVENT:is,VERSION:it,TYPES:Ms};export{Zo as default};
1
+ let e=e=>void 0===e,t=e=>"string"==typeof e,s=e=>{return null==(e=Object.prototype.toString.call(e).match(/^\[object (.*)\]$/))?void 0:e[1].toLowerCase()},n=e=>"function"==typeof Array.isArray?Array.isArray(e):"array"===s(e),i=e=>null!==e&&"object"==typeof e,o=e=>n(e)||i(e),r=e=>{return"string"==typeof e&&(e=e[0],!/[^a-zA-Z0-9]/.test(e))},a=e=>{if("object"!=typeof e||null===e)return!1;e=Object.getPrototypeOf(e);if(null===e)return!0;let t=e;for(;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return e===t};function c(e=99999999){return Math.round(Math.random()*e)}let l=(n,i,r,a)=>{if(!o(n)||!o(i))return 0;let c=0;var u,d=Object.keys(i);for(let t=0,s=d.length;t<s;t++)if(u=d[t],!(e(i[u])||r&&r.includes(u)))if(o(n[u])&&o(i[u]))c+=l(n[u],i[u],r,a);else{if(a&&a.includes(i[u]))continue;n[u]!==i[u]&&(n[u]=i[u],c+=1)}return c};function u(s){let n,i,r=s,o="";for(let e=0,t=(r=s.length%8!=0?"0".repeat(8-s.length%8)+s:r)["length"];e<t;e+=8)n=parseInt(r.slice(e,e+4),2),i=parseInt(r.slice(e+4,e+8),2),o+=base16Map.get(n)+base16Map.get(i);return o}let d={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,DONUT_NATIVE_APP:19,NS_NATIVE_APP:20,RN_NATIVE_APP:21},_=["heartbeat.alive","im_open_status.wslogin","im_open_status.wslogout","group_open_long_polling_http_svc.get_msg","group_open_long_polling_http_noauth_svc.get_msg"];var h,I;!function(e){e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e[e.NONE=4]="NONE"}(h=h||{});let g="LiteChat",p={[h.DEBUG]:console.debug,[h.INFO]:console.info,[h.WARN]:console.warn,[h.ERROR]:console.error},E={[h.INFO]:4,[h.WARN]:5,[h.ERROR]:6},f=1e3,m=2,S=5e3,v=50;!function(e){e[e.CONV_DELETED=1]="CONV_DELETED",e[e.CONV_PINED=2]="CONV_PINED",e[e.CONV_UNPINED=3]="CONV_UNPINED",e[e.CONV_MARK_UPDATED=4]="CONV_MARK_UPDATED",e[e.CONV_GROUP_ADDED=5]="CONV_GROUP_ADDED",e[e.CONV_GROUP_DELETED=6]="CONV_GROUP_DELETED",e[e.CONV_GROUP_UPDATED=7]="CONV_GROUP_UPDATED"}(I=I||{});var C=Object.freeze({__proto__:null,CONSOLE_METHOD:p,CloudConfigReportLevelMap:E,get ConvModifyPushType(){return I},DEFAULT_GLOBAL_MAX_TOTAL_COUNT:v,DEFAULT_GLOBAL_THROTTLE_TIME:S,DEFAULT_SINGLE_MAX_TOTAL_COUNT:m,DEFAULT_SINGLE_THROTTLE_TIME:f,ENUM_PLATFORM:d,IS_TOPIC_MESSAGE:2,get LogLevel(){return h},NOT_NEED_CRC_SERVCMD:_,SDK_NAME:g});let M="undefined"!=typeof wx&&"function"==typeof wx.getSystemInfoSync&&("mac"===wx.getSystemInfoSync().platform||"windows"===wx.getSystemInfoSync().platform),T="undefined"!=typeof wx&&"function"==typeof wx.getSystemInfoSync&&Boolean(wx.getSystemInfoSync().fontSizeSetting)||M,y=T&&"function"==typeof wx.createGamePortal,O="undefined"!=typeof qq&&"function"==typeof qq.getSystemInfoSync&&Boolean(qq.getSystemInfoSync().fontSizeSetting),A="undefined"!=typeof tt&&"function"==typeof tt.getSystemInfoSync&&Boolean(tt.getSystemInfoSync().fontSizeSetting),N=A&&"function"==typeof tt.onShow,R="undefined"!=typeof swan&&"function"==typeof swan.getSystemInfoSync&&Boolean(swan.getSystemInfoSync().fontSizeSetting),D="undefined"!=typeof my&&"function"==typeof my.getSystemInfoSync&&Boolean(my.getSystemInfoSync().fontSizeSetting),P="undefined"!=typeof jd&&"function"==typeof jd.getSystemInfoSync,b="undefined"!=typeof uni&&"undefined"==typeof window&&"function"==typeof uni.requireNativePlugin,w=T&&"object"==typeof wx.miniapp,L="undefined"!=typeof uni,k=T||O||A||R||D||b||P,U="undefined"==typeof window&&!k&&"undefined"!=typeof global&&void 0!==global.NativeScriptGlobals,G="undefined"!=typeof global&&(void 0!==global.nativeModuleProxy||void 0!==global.ReactNative),F="undefined"!=typeof wx&&"function"==typeof wx.getAccountInfoSync&&Boolean(wx.getAccountInfoSync().plugin),B="undefined"!=typeof uni?!k:"undefined"!=typeof window&&!k&&!G,x=O?qq:A?tt:R?swan:D?my:T?wx:b?uni:P?jd:{},V=B&&window&&window.navigator&&window.navigator.userAgent||"",$=/(micromessenger|webbrowser)/i.test(V),q=function(){let e="WEB";return $?e="WEB":O?e="QQ_MP":A?e="TT_MP":R?e="BAIDU_MP":D?e="ALI_MP":T?e=w?"DONUT_NATIVE_APP":"WX_MP":b?e="UNI_NATIVE_APP":U?e="NS_NATIVE_APP":G&&(e="RN_NATIVE_APP"),d[e]}(),W=/iPad/i.test(V),Y=/iPhone/i.test(V)&&!W,K=/iPod/i.test(V),H=Y||W||K,j=function(){var e=V.match(/OS (\d+)_/i);return e&&e[1]?e[1]:null}(),z=/Android/i.test(V),Z=function(){var e,t,s=V.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);return s?(e=s[1]&&parseFloat(s[1]),t=s[2]&&parseFloat(s[2]),e&&t?parseFloat(s[1]+"."+s[2]):e||null):null}(),X=/Firefox/i.test(V),J=/Edge/i.test(V),Q=!J&&/Chrome/i.test(V),ee=/MSIE/.test(V)||-1<V.indexOf("Trident")&&-1<V.indexOf("rv:11.0"),te=function(){var e=/MSIE\s(\d+)\.\d/.exec(V);let t=e&&parseFloat(e[1]);return t=!t&&/Trident\/7.0/i.test(V)&&/rv:11.0/.test(V)?11:t}(),se=/Safari/i.test(V)&&!Q&&!z&&!J,ne=/Windows/i.test(V),ie=/MAC OS X/i.test(V),oe=B&&"undefined"!=typeof Worker&&!ee,re=z||H,ae=B&&void 0!==window.tencent_cloud_im_csig_flutter_for_web_25F_cy,ce=function(){var e;return"undefined"!=typeof window&&void 0!==window.navigator&&(e=window.navigator["standalone"],!(!H||e||se))}();function le(){let e="unknown";if(ie&&(e="mac"),ne&&(e="windows"),H&&(e="ios"),z&&(e="android"),k)try{var t=x.getSystemInfoSync()["platform"];void 0!==t&&(e=t)}catch(e){console.error(e)}return e}function ue(e,t){var s={};for(i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(s[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var n=0,i=Object.getOwnPropertySymbols(e);n<i.length;n++)t.indexOf(i[n])<0&&Object.prototype.propertyIsEnumerable.call(e,i[n])&&(s[i[n]]=e[i[n]]);return s}function de(e,o,a,l){return new(a=a||Promise)(function(s,t){function n(e){try{r(l.next(e))}catch(e){t(e)}}function i(e){try{r(l.throw(e))}catch(e){t(e)}}function r(e){var t;e.done?s(e.value):((t=e.value)instanceof a?t:new a(function(e){e(t)})).then(n,i)}r((l=l.apply(e,o||[])).next())})}let _e=2800,he=2801,ge=3e3,pe="application/x-www-form-urlencoded;charset=UTF-8";function Ee(e){return de(this,arguments,void 0,function*({method:i,url:r,data:o,timeout:a=ge}){return new Promise(k?(t,e)=>{x.request({url:r,data:o,method:i,timeout:a,header:{"content-type":pe},success:e=>t(e.data),fail:()=>e(new Error(`{"message":"Network error","code":${_e}}`))})}:(t,e)=>{let s=new XMLHttpRequest,n=setTimeout(()=>{s.abort(),e(new Error(`{"message":"Request timeout","code":${he}}`))},a);s.onreadystatechange=function(){if(4===s.readyState)if(clearTimeout(n),200===s.status||304===s.status)try{t(s.responseText?JSON.parse(s.responseText):null)}catch(e){t(s.responseText)}else e(new Error(`{"message":"Network error","code":${_e}}`))},s.open(i,r,!0),s.setRequestHeader("Content-type",pe),s.send(o||null)})})}function fe(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(a(e)){for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0}return("[object Map]"===Object.prototype.toString.call(e)||"[object Set]"===Object.prototype.toString.call(e)||"[object File]"===Object.prototype.toString.call(e))&&0===e.size}function me(n){if(null===n||"object"!=typeof n)return n;if(n instanceof Date)return new Date(n.getTime());if(n instanceof RegExp)return new RegExp(n.source,n.flags);if(n instanceof Map){let s=new Map;return n.forEach((e,t)=>{s.set(me(t),me(e))}),s}if(n instanceof Set){let t=new Set;return n.forEach(e=>{t.add(me(e))}),t}if(Array.isArray(n))return n.map(e=>me(e));let e=Object.getPrototypeOf(n),s=Object.create(e);return[...Object.getOwnPropertyNames(n),...Object.getOwnPropertySymbols(n)].forEach(e=>{var t=Object.getOwnPropertyDescriptor(n,e);t&&(t.get||t.set?Object.defineProperty(s,e,t):s[e]=me(n[e]))}),s}function Se(e,s,t){let n=new WeakSet;try{return JSON.stringify(e,(e,t)=>{if(void 0===(t=s?s(e,t):t))return"undefined";if(null===t)return null;if(Number.isNaN(t))return"NaN";if(t===1/0)return"Infinity";if(t===-1/0)return"-Infinity";if("function"==typeof t)return`[Function: ${t.name||"anonymous"}]`;if("symbol"==typeof t)return t.toString();if("bigint"==typeof t)return t.toString()+"n";if("object"==typeof t&&null!==t){if(n.has(t))return"[Circular]";n.add(t)}return t instanceof Date?t.toISOString():t instanceof Error?{name:t.name,message:t.message,stack:t.stack}:t instanceof Map?{dataType:"Map",value:Array.from(t.entries())}:t instanceof Set?{dataType:"Set",value:Array.from(t.values())}:t},t)}catch(e){return console.error("Failed to stringify:",e),""}}function ve(){let s,n;return{promise:new Promise((e,t)=>{s=e,n=t}),resolve:s,reject:n}}var Ie,Ae,Ce=Object.freeze({__proto__:null,ANDROID_VERSION:Z,IE_VERSION:te,IN_ALIPAY_MINI_APP:D,IN_BAIDU_MINI_APP:R,IN_BROWSER:B,IN_DONUT_NATIVE_APP:w,IN_JD_MINI_APP:P,IN_MINI_APP:k,IN_NS_NATIVE_APP:U,IN_QQ_MINI_APP:O,IN_RN_APP:G,IN_TT_MINI_APP:A,IN_TT_MINI_GAME:N,IN_UNI_APP:L,IN_UNI_NATIVE_APP:b,IN_WX_MINI_APP:T,IN_WX_MINI_APP_DESK:M,IN_WX_MINI_GAME:y,IN_WX_MINI_PLUGIN:F,IOS_VERSION:j,IS_ANDROID:z,IS_CHROME:Q,IS_EDGE:J,IS_FIREFOX:X,IS_IE:ee,IS_IOS:H,IS_IPAD:W,IS_IPHONE:Y,IS_IPOD:K,IS_MAC:ie,IS_SAFARI:se,IS_WECHAT:$,IS_WIN:ne,IS_WORKER_AVAILABLE:oe,MINI_APP_NAMESPACE:x,USER_AGENT:V,base16EncodeBinaryString:u,deepCopyWithMethods:me,deepMerge:l,generatePromise:ve,getPlatformType:le,getType:s,httpRequest:Ee,isArray:n,isArrayOrObject:o,isEmpty:fe,isFlutterWeb:ae,isH5:re,isIOSWebView:ce,isNumber:e=>null!==e&&("number"==typeof e&&!Number.isNaN(+e)||"object"==typeof e&&e.constructor===Number),isObject:i,isPlainObject:a,isString:t,isUndefined:e,isUniIOSApp:function(){return b&&"ios"===uni.getDeviceInfo().platform.toLocaleLowerCase()},isValidRequestKey:r,platform:q,randomInt:c,randomString:function(){let t="";for(let e=32;0<e;--e)t+="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[Math.floor(62*Math.random())];return t},safeStringify:Se});class Me{constructor(){this.listeners={}}on(e,t,s){this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].push({fn:t,context:s})}off(e,s,n){s&&(this.listeners[e]=null==(e=this.listeners[e])?void 0:e.filter(e=>{var t=e.fn===s,e=!n||e.context===n;return!(t&&e)}))}emit(s,...n){var e=this.listeners[s];e&&e.forEach(e=>{var{fn:e,context:t}=e;try{e.apply(t,n)}catch(e){console.warn(`Error in event handler for ${s} error: `+Se(e))}})}once(t,s,n){let i=(...e)=>{s.apply(n,e),this.off(t,i)};this.on(t,i)}}!function(e){e.BUSINESS_COMMAND="business_command",e.C2C_REALTIME_MESSAGE="c2c_realtime_message",e.C2C_MESSAGE_MODIFIED="c2c_message_modified",e.C2C_REVOKED_MESSAGE="c2c_message_revoked",e.GROUP_REALTIME_MESSAGE="group_realtime_message",e.GROUP_MESSAGE_MODIFIED="group_message_modified",e.GROUP_MESSAGE_REVOKED="group_message_revoked",e.C2C_MESSAGE_READ_RECEIPT="c2c_message_read_receipt",e.MESSAGE_REACTION_UPDATED="message_reaction_updated",e.MESSAGE_REACTION_UPDATED_SYNC="message_reaction_updated_sync",e.GROUP_AT_TIPS="group_at_tips",e.USER_STATUS_UPDATE="user_status_update",e.FRIEND_LIST_MODIFIED="friend_list_modified",e.PROFILE_MODIFIED="profile_modified",e.CONV_MODIFIED="conversation_modified",e.GROUP_TIPS_NOTIFICATION="group_tips_notification",e.GROUP_MESSAGE_READ_RECEIPT="group_message_read_receipt",e.GROUP_MESSAGE_READ_SYNC="group_message_read_sync",e.GROUP_SYSTEM_NOTIFICATION="group_system_notification",e.C2C_MESSAGE_PEER_READ="c2c_message_peer_read",e.C2C_MESSAGE_READ_SYNC="c2c_message_read_sync",e.C2C_REMIND_TYPE_SYNC="c2c_remind_type_sync",e.FOLLOW_LIST_UPDATED="follow_list_updated",e.MESSAGE_EXTENSIONS_UPDATED="message_extensions_updated",e.ALL_MESSAGE_READ="all_message_read",e.CONVERSATION_MARK_UPDATED="conversation_mark_updated",e.CONVERSATION_GROUP_ADD="conversation_group_add",e.CONVERSATION_GROUP_DELETED="conversation_group_deleted",e.CONVERSATION_GROUP_UPDATED="conversation_group_updated",e.ALL_RECEIVE_MESSAGE_OPTION="all_receive_message_option",e.TOPIC_AT_TIPS="topic_at_tips",e.TOPIC_TIPS_NOTIFICATION="topic_tips_notification",e.TOPIC_SYSTEM_NOTIFICATION="topic_system_notification",e.TOPIC_MESSAGE_READ_SYNC="topic_message_read_sync",e.TOPIC_LATEST_MESSAGE="topic_latest_message",e.GROUP_MESSAGE_PINNED="group_message_pinned"}(Ie=Ie||{});let Te=[16,17];function ye(e){let t,s=[];return null!=(t=null==e?void 0:e.GroupTips)&&t.forEach(e=>{2===e.GroupInfo.MillionGroupFlag?s.push(Ie.TOPIC_TIPS_NOTIFICATION):Te.includes(null==(e=null==e?void 0:e.MsgBody)?void 0:e.OpType)?s.push(Ie.GROUP_MESSAGE_PINNED):s.push(Ie.GROUP_TIPS_NOTIFICATION)}),s}let Oe=[{conditions:[{type:"event",value:100}],subType:Ie.BUSINESS_COMMAND},{conditions:[{type:"event",value:24}],subType:Ie.ALL_RECEIVE_MESSAGE_OPTION},{conditions:[{type:"event",value:26}],subType:Ie.TOPIC_LATEST_MESSAGE},{conditions:[{type:"hasKey",value:"C2cMsgArray"}],subType:Ie.C2C_REALTIME_MESSAGE},{conditions:[{type:"hasKey",value:"C2cMsgModNotifys"}],subType:Ie.C2C_MESSAGE_MODIFIED},{conditions:[{type:"hasKey",value:"ProfileDataMod"}],subType:Ie.PROFILE_MODIFIED},{conditions:[{type:"hasKey",value:"UserStatusList"}],subType:Ie.USER_STATUS_UPDATE},{conditions:[{type:"hasKey",value:"FriendListMod"}],subType:Ie.FRIEND_LIST_MODIFIED},{conditions:[{type:"hasKey",value:"GroupMsgArray"}],subType:Ie.GROUP_REALTIME_MESSAGE},{conditions:[{type:"hasKey",value:"GroupMsgModNotifys"}],subType:Ie.GROUP_MESSAGE_MODIFIED},{conditions:[{type:"hasKey",value:"C2cNotifyMsgArray"}],subTypeParser:function(e){let t,s=[];return null!=(t=null==e?void 0:e.C2cNotifyMsgArray)&&t.forEach(e=>{e.WithdrawC2cMsgNotify&&s.push(Ie.C2C_REVOKED_MESSAGE),e.C2cReadedReceipt&&s.push(Ie.C2C_MESSAGE_PEER_READ),e.ReadC2cMsgNotify&&s.push(Ie.C2C_MESSAGE_READ_SYNC),e.MuteNotificationsSync&&s.push(Ie.C2C_REMIND_TYPE_SYNC)}),s}},{conditions:[{type:"hasKey",value:"GroupTips"},{type:"event",value:4}],subTypeParser:ye},{conditions:[{type:"hasKey",value:"GroupTips"},{type:"event",value:5}],subTypeParser:function(e){let t,s=[];return null!=(t=null==e?void 0:e.GroupTips)&&t.forEach(e=>{Array.isArray(e.MsgBody.GroupWithdrawInfoArray)?s.push(Ie.GROUP_MESSAGE_REVOKED):Array.isArray(e.MsgBody.GroupMsgReceiptList)?s.push(Ie.GROUP_MESSAGE_READ_RECEIPT):Array.isArray(e.MsgBody.GroupReadInfoArray)?e.MsgBody.GroupReadInfoArray[0].TopicId?s.push(Ie.TOPIC_MESSAGE_READ_SYNC):s.push(Ie.GROUP_MESSAGE_READ_SYNC):2===e.GroupInfo.MillionGroupFlag?s.push(Ie.TOPIC_SYSTEM_NOTIFICATION):s.push(Ie.GROUP_SYSTEM_NOTIFICATION)}),s}},{conditions:[{type:"hasKey",value:"GroupTips"},{type:"event",value:6}],subTypeParser:ye},{conditions:[{type:"hasKey",value:"GroupTips"},{type:"event",value:12}],subTypeParser:function(e){let t,s=[];return null!=(t=null==e?void 0:e.GroupTips)&&t.forEach(e=>{var e=e["GroupAtTips"]["TopicId"];e?s.push(Ie.TOPIC_AT_TIPS):s.push(Ie.GROUP_AT_TIPS)}),s}},{conditions:[{type:"hasKey",value:"RecentContactMod"}],subTypeParser:function(e){let t,s=[];return null!=(t=null==e?void 0:e.RecentContactMod)&&t.forEach(e=>{switch(e.PushType){case I.CONV_MARK_UPDATED:s.push(Ie.CONVERSATION_MARK_UPDATED);break;case I.CONV_GROUP_ADDED:s.push(Ie.CONVERSATION_GROUP_ADD);break;case I.CONV_GROUP_DELETED:s.push(Ie.CONVERSATION_GROUP_DELETED);break;case I.CONV_GROUP_UPDATED:s.push(Ie.CONVERSATION_GROUP_UPDATED);break;default:s.push(Ie.CONV_MODIFIED)}}),s}},{conditions:[{type:"hasKey",value:"MsgReactionNotifyList"}],subType:Ie.MESSAGE_REACTION_UPDATED},{conditions:[{type:"hasKey",value:"MsgReactionNotify"}],subType:Ie.MESSAGE_REACTION_UPDATED_SYNC},{conditions:[{type:"hasKey",value:"C2cMsgInfo"}],subType:Ie.C2C_MESSAGE_READ_RECEIPT},{conditions:[{type:"hasKey",value:"FollowChangeList"}],subType:Ie.FOLLOW_LIST_UPDATED},{conditions:[{type:"hasKey",value:"MsgExtensionNotify"}],subType:Ie.MESSAGE_EXTENSIONS_UPDATED},{conditions:[{type:"hasKey",value:"C2CReadAllMsg"}],subType:Ie.ALL_MESSAGE_READ}];function Ne(n){let e,t=Array.isArray(null==(e=null==n?void 0:n.body)?void 0:e.EventArray)?n.body.EventArray:[],i=[];return t.forEach(t=>{t.Flag=n.body.Flag;var e=Oe.find(e=>e.conditions.every(e=>{switch(e.type){case"event":return t.Event===e.value;case"hasKey":return Object.prototype.hasOwnProperty.call(t,e.value);default:return!1}}));if(!e)return null;let s=[];"function"==typeof e.subTypeParser?s=e.subTypeParser(t):e.subType&&(s=e.subType),Array.isArray(s)?s.forEach(e=>{i.push({type:Ae.SERVER_PUSH_MESSAGE+":"+e,data:t})}):i.push({type:Ae.SERVER_PUSH_MESSAGE+":"+s,data:t})}),i}!function(e){e.SERVER_PUSH_MESSAGE="im_open_push.msg_push",e.SERVER_PUSH_MESSAGE_MULTIPLE="im_open_push.multi_msg_push_ws",e.ERROR="error"}(Ae=Ae||{});let Re={[Ae.SERVER_PUSH_MESSAGE]:Ne,[Ae.SERVER_PUSH_MESSAGE_MULTIPLE]:Ne,[Ae.ERROR]:function(e){var t=e["errorCode"];return[{type:"error:"+t,data:e}]}},De=new class{constructor(){this._outerEventEmitter=null,this._innerEventEmitter=null,this._outerEventEmitter=new Me,this._innerEventEmitter=new Me,this.InnerEventSubType=Ie}subscribeInnerEvent(s,n,i,r){var o,t;if(["string","number"].includes(typeof n)){let e=n,t=i;null!=(o=this._innerEventEmitter)&&o.on(s+":"+e,t,r)}else{let e=n;null!=(t=this._innerEventEmitter)&&t.on(s,e,i)}}emitInnerEvent(t,s){var e;if(null!=(e=this._innerEventEmitter)&&e.emit(t,s),Object.keys(Re).includes(t)){let e=null==(t=Re[t])?void 0:t.call(Re,s);null!=e&&e.forEach(e=>{var t;e&&null!=(t=this._innerEventEmitter)&&t.emit(e.type,e.data)})}}unSubscribeInnerEvent(s,n,i,r){var o,t;if(["string","number"].includes(typeof n)){let e=n,t=i;null!=(o=this._innerEventEmitter)&&o.off(s+":"+e,t,r)}else{let e=n;null!=(t=this._innerEventEmitter)&&t.off(s,e,i)}}subscribeOuterEvent(e,t,s){var n;null!=(n=this._outerEventEmitter)&&n.on(e,t,s)}unSubscribeOuterEvent(e,t,s){var n;null!=(n=this._outerEventEmitter)&&n.off(e,t,s)}emitOuterEvent(e,t){var s;null!=(s=this._outerEventEmitter)&&s.emit(e,t)}getOuterEventEmitter(){return this._outerEventEmitter}rest(){this._outerEventEmitter=null,this._innerEventEmitter=null}};class Pe{constructor(){this._socket=null}connectSocket(e){return this._socket=new WebSocket(e),this._socket}send(e){var t;try{null!=(t=this._socket)&&t.send(e)}catch(e){null!=(t=this._onSendFail)&&t.call(this,e)}}bindSocketHandlers(e){var{onOpen:e,onMessage:t,onClose:s,onError:n,onSendFail:i}=e;this._socket&&(this._socket.binaryType="arraybuffer",this._socket.onopen=e,this._socket.onmessage=t,this._socket.onclose=s,this._socket.onerror=n,this._onSendFail=i)}unbindSocketHandlers(){this._socket&&(this._socket.onopen=null,this._socket.onmessage=null,this._socket.onclose=null,this._socket.onerror=null)}disconnect(){this._socket&&(this._socket.close(),this._socket=null)}}class be{connectSocket(e){return this._socket=x.connectSocket({url:e,header:{"content-type":"application/json"},complete:()=>{}}),this._socket}send(e){var t;null!=(t=this._socket)&&t.send({data:e,fail:this._onSendFail})}bindSocketHandlers(e){var{onOpen:e,onMessage:t,onClose:s,onError:n,onSendFail:i}=e;this._socket.onClose(s),this._socket.onOpen(e),this._socket.onMessage(t),this._socket.onError(n),this._onSendFail=i}unbindSocketHandlers(){this._socket&&(this._socket.onClose(()=>{}),this._socket.onOpen(()=>{}),this._socket.onMessage(()=>{}),this._socket.onError(()=>{}))}disconnect(){this._socket&&(this._socket.close(),this._socket=null)}}let we="CONNECT",Le="SEND",ke="DISCONNECT",Ue="OPEN",Ge="MESSAGE",Fe="CLOSE",Be="ERROR",xe="SEND_FAIL";class Ve{constructor(){this._worker=null,this._blobUrl=null}connectSocket(e){var t=new Blob(["\n let _socket = null;\n\n self.onmessage = (event) => {\n const { type, url, data } = event.data;\n\n switch (type) {\n case 'CONNECT':\n connectSocket(url);\n break;\n case 'SEND':\n send(data);\n break;\n case 'DISCONNECT':\n disconnect();\n break;\n }\n };\n\n function connectSocket(url) {\n _socket = new WebSocket(url);\n _socket.binaryType = 'arraybuffer';\n bindSocketHandlers();\n return _socket;\n }\n\n function send(packet) {\n try {\n _socket?.send(packet);\n } catch (error) {\n self.postMessage({\n type: 'SEND_FAIL', \n error: {\n message: error.message,\n name: error.name,\n },\n });\n }\n }\n\n function bindSocketHandlers() {\n if (_socket) {\n _socket.onopen = (event) => {\n self.postMessage({\n type: 'OPEN',\n data: {\n type: event.type,\n timeStamp: event.timeStamp,\n },\n });\n };\n\n _socket.onmessage = (event) => {\n self.postMessage({ \n type: 'MESSAGE',\n data: event.data,\n });\n };\n\n _socket.onclose = (event) => {\n self.postMessage({ \n type: 'CLOSE', \n data: { \n code: event.code,\n reason: event.reason,\n timeStamp: event.timeStamp,\n },\n });\n };\n\n _socket.onerror = (error) => {\n self.postMessage({\n type: 'ERROR',\n data: {\n message: error.message,\n name: error.name\n },\n });\n };\n }\n }\n\n function unbindSocketHandlers() {\n if (_socket) {\n _socket.onopen = null;\n _socket.onmessage = null;\n _socket.onclose = null;\n _socket.onerror = null;\n }\n }\n\n function disconnect() {\n if (_socket) {\n _socket.close();\n _socket = null;\n }\n }\n"],{type:"application/javascript"});this._worker=new Worker(URL.createObjectURL(t)),this._worker.postMessage({type:we,url:e})}send(e){var t;try{null!=(t=this._worker)&&t.postMessage({type:Le,data:e})}catch(e){null!=(t=this._onSendFail)&&t.call(this,e)}}bindSocketHandlers(e){var{onOpen:t,onMessage:n,onClose:i,onError:r,onSendFail:o}=e;if(this._worker){let s={[Ue]:t,[Ge]:n,[Fe]:i,[Be]:r,[xe]:o};this._onSendFail=o,this._worker.onmessage=e=>{var t=((null==e?void 0:e.data)||{})["type"];"function"==typeof s[t]&&null!=(t=s[t])&&t.call(s,null==e?void 0:e.data)}}}unbindSocketHandlers(){this._worker&&(this._worker.onmessage=null)}disconnect(){this._worker&&(this._worker.postMessage({type:ke}),this._worker.terminate(),this._worker=null),this._blobUrl&&(URL.revokeObjectURL(this._blobUrl),this._blobUrl=null)}}var $e,qe=new class{constructor(){this._store=new Map}get(e){return this._store.get(e)}getStorage(e){return k?D?my.getStorageSync({key:e}).data:x.getStorageSync(e):this._canUseLocalStorage()?localStorage.getItem(e):{}}set(e,t){var s=this._store.get(e)||{};t instanceof Map?this._store.set(e,t):this._store.set(e,Object.assign(Object.assign({},s),t))}setStorage(e,t){k?D?my.setStorageSync({key:e,data:JSON.stringify(t)}):x.setStorageSync(e,JSON.stringify(t)):this._canUseLocalStorage()&&localStorage.setItem(e,JSON.stringify(t))}clear(e){"string"==typeof e?this._store.set(e,{}):this._store.clear()}clearLocalStorage(e){this._canUseLocalStorage()&&("string"==typeof e?localStorage.setItem(e,""):localStorage.clear())}reset(){this.clear()}_canUseLocalStorage(){return"undefined"!=typeof window&&navigator&&navigator.cookieEnabled&&localStorage}};!function(e){e[e.CONNECTED=0]="CONNECTED",e[e.CONNECTING=1]="CONNECTING",e[e.DISCONNECTED=2]="DISCONNECTED"}($e=$e||{});class We{constructor(e){this._url="",this._readyState=$e.DISCONNECTED,this._url=e,this._id=c(),this._emitter=new Me,T||b||N?this._socket=new be:this._canUseWebWorker()?this._socket=new Ve:this._socket=new Pe,this.connect()}connect(){this.doOpen(),this._bindSocketHandlers()}doOpen(){[$e.CONNECTED,$e.CONNECTING].includes(this._readyState)||(this._readyState=$e.CONNECTING,this._ws=this._socket.connectSocket(this._url))}send(e){this._readyState!==$e.CONNECTED?this.reconnect():this._socket.send(e)}reconnect(){[$e.CONNECTED,$e.CONNECTING].includes(this._readyState)||(this.disconnect(),this.doOpen())}getId(){return this._id}on(e,t,s){this._emitter.on(e,t,s)}off(e,t,s){this._emitter.off(e,t,s)}isConnected(){return this._readyState===$e.CONNECTED}disconnect(){this._readyState=$e.DISCONNECTED,this._unbindSocketHandlers(),this._socket.disconnect()}_onOpen(e){this._readyState===$e.CONNECTING&&(this._readyState=$e.CONNECTED,this._emitter.emit("connect",{socketId:this._id,event:e}))}_onMessage(e){this._emitter.emit("message",e)}_onClose(e){this._readyState=$e.DISCONNECTED,this._emitter.emit("close",{socketId:this._id,event:e})}_onError(e){this._readyState=$e.DISCONNECTED,this._emitter.emit("error",{socketId:this._id,error:e})}_onSendFail(e){this._readyState=$e.DISCONNECTED,this._emitter.emit("sendFail",{socketId:this._id,error:e})}_bindSocketHandlers(){this._socket.bindSocketHandlers({onOpen:this._onOpen.bind(this),onMessage:this._onMessage.bind(this),onClose:this._onClose.bind(this),onError:this._onError.bind(this),onSendFail:this._onSendFail.bind(this)})}_unbindSocketHandlers(){this._socket.unbindSocketHandlers()}_canUseWebWorker(){var t=qe.get("cloudConfig")||{};return(e(t.isWorkerEnabled)||"1"===t.isWorkerEnabled)&&oe}}let Ye="CHINA",Ke="OVERSEA",He="SINGAPORE",je="KOREA",ze="GERMANY",Ze="IND",Xe="JPN",Je="USA",Qe="INDONESIA",et={TEST:{CHINA:{DEFAULT:"wss://wss-dev.tim.qq.com"},OVERSEA:{DEFAULT:"wss://wss-dev.tim.qq.com"},SINGAPORE:{DEFAULT:"wss://wsssgp-dev.im.qcloud.com"},KOREA:{DEFAULT:"wss://wsskr-dev.im.qcloud.com"},GERMANY:{DEFAULT:"wss://wssger-dev.im.qcloud.com"},IND:{DEFAULT:"wss://wssind-dev.im.qcloud.com"},JPN:{DEFAULT:"wss://wssjpn-dev.im.qcloud.com"},USA:{DEFAULT:"wss://wssusa-dev.im.qcloud.com"},INDONESIA:{DEFAULT:"wss://wssidn-dev.im.qcloud.com"}},PRODUCTION:{CHINA:{INITIAL:"wss://*w4c.my-imcloud.com",DEFAULT:"wss://wss.im.qcloud.com",IPV6:"wss://wssv6.im.qcloud.com",BACKUP:"wss://wss.tim.qq.com",BACKUP_WEB_ONLY:"wss://*w4c.my-cpaas.com",BACKUP_CN:"wss://wss.im.tencent.cn",STAT:"https://events.im.qcloud.com",ANYCAST:"wss://162.14.13.203"},OVERSEA:{INITIAL:"wss://*w4c.my-imcloud.com",DEFAULT:"wss://wss.im.qcloud.com",IPV6:"wss://wssv6.im.qcloud.com",BACKUP:"wss://wss.my-imcloud.com",BACKUP_WEB_ONLY:"wss://*w4c.my-cpaas.com",BACKUP_CN:"wss://wss.im.tencent.cn",STAT:"https://api.my-imcloud.com"},SINGAPORE:{INITIAL:"wss://*w4s.my-imcloud.com",DEFAULT:"wss://wsssgp.im.qcloud.com",IPV6:"wss://wsssgpv6.im.qcloud.com",BACKUP:"wss://wsssgp.my-imcloud.com",BACKUP_WEB_ONLY:"wss://*w4s.my-cpaas.com",STAT:"https://apisgp.my-imcloud.com",ANYCAST:"wss://162.14.19.159"},KOREA:{INITIAL:"wss://*w4k.my-imcloud.com",DEFAULT:"wss://wsskr.im.qcloud.com",IPV6:"wss://wsskrv6.im.qcloud.com",BACKUP:"wss://wsskr.my-imcloud.com",BACKUP_WEB_ONLY:"wss://*w4k.my-cpaas.com",STAT:"https://apikr.my-imcloud.com",ANYCAST:"wss://162.14.13.104"},GERMANY:{INITIAL:"wss://*w4g.my-imcloud.com",DEFAULT:"wss://wssger.im.qcloud.com",IPV6:"wss://wssgerv6.im.qcloud.com",BACKUP:"wss://wssger.my-imcloud.com",BACKUP_WEB_ONLY:"wss://*w4g.my-cpaas.com",STAT:"https://apiger.my-imcloud.com",ANYCAST:"wss://162.14.3.17"},IND:{INITIAL:"wss://*w4i.my-imcloud.com",DEFAULT:"wss://wssind.my-imcloud.com",IPV6:"wss://wssindv6.im.qcloud.com",BACKUP:"wss://wssind.im.qcloud.com",BACKUP_WEB_ONLY:"wss://*w4i.my-cpaas.com",STAT:"https://apiind.my-imcloud.com",ANYCAST:"wss://162.14.19.46"},JPN:{INITIAL:"wss://*w4j.my-imcloud.com",DEFAULT:"wss://wssjpn.im.qcloud.com",IPV6:"wss://wssjpnv6.im.qcloud.com",BACKUP:"wss://wssjpn.my-imcloud.com",BACKUP_WEB_ONLY:"wss://*w4j.my-cpaas.com",STAT:"https://apijpn.my-imcloud.com",ANYCAST:"wss://162.14.13.254"},USA:{INITIAL:"wss://*w4u.my-imcloud.com",DEFAULT:"wss://wssusa.im.qcloud.com",IPV6:"wss://wssusav6.im.qcloud.com",BACKUP:"wss://wssusa.my-imcloud.com",BACKUP_WEB_ONLY:"wss://*w4u.my-cpaas.com",STAT:"https://apiusa.my-imcloud.com",ANYCAST:"wss://162.14.10.42"},INDONESIA:{INITIAL:"wss://*w4y.my-imcloud.com",DEFAULT:"wss://wssidn.im.qcloud.com",IPV6:"wss://wssidnv6.im.qcloud.com",BACKUP:"wss://wssidn.my-imcloud.com",BACKUP_WEB_ONLY:"wss://*w4y.my-cpaas.com",STAT:"https://apiidn.my-imcloud.com",ANYCAST:"wss://43.129.34.169"}}},st={[He]:[[2e7,3e7],[172e7,173e7]],[je]:[[3e7,4e7],[173e7,174e7]],[ze]:[[4e7,5e7],[174e7,175e7]],[Ze]:[[5e7,6e7],[175e7,176e7]],[Xe]:[[6e7,7e7],[176e7,177e7]],[Je]:[[7e7,8e7],[177e7,178e7]],[Qe]:[[8e7,9e7],[178e7,179e7]]};function nt(t){var e;if(null!=(e=qe.get("instance"))&&e.oversea)return Ke;for(let e of Object.keys(st))for(var[s,n]of st[e])if(t>=s&&t<n)return e;return Ye}var it,ot="1.6.4";!function(e){e.INITIAL="INITIAL",e.DEFAULT="DEFAULT",e.BACKUP="BACKUP",e.BACKUP_WEB_ONLY="BACKUP_WEB_ONLY",e.BACKUP_CN="BACKUP_CN",e.ANYCAST="ANYCAST",e.IPV6="IPV6"}(it=it||{});let rt=it.INITIAL;function at(){var e=Math.random();return 0===e?at():e}function ct(e,t){var s,{isBinary:t=!1}=t||{},{sdkAppId:n,instanceId:i}=qe.get("instance"),r=at(),o=le(),a=function(){var e=le();let t=-1;return"ios"===e?t=j||-1:"android"===e&&(t=Z||-1),t}(),n=(s={sdkappid:n,instanceid:i,random:r,platform:q,host:o,version:a,sdkversion:ot},Object.keys(s).map(e=>e+"="+s[e]).join("&"));return t?e+`/binfo?${n}&compress=gzip`:e+"/info?"+n}function lt(e){var{sdkAppId:t,testEnv:s}=qe.get("instance"),t=nt(t);if(s)return ct(et.TEST[t].DEFAULT,{isBinary:e});let n=et.PRODUCTION[t],i=B&&n.ANYCAST,r=B,o=!!n.BACKUP_CN;return ct({[it.INITIAL]:()=>(rt=it.DEFAULT,n.DEFAULT),[it.DEFAULT]:()=>(rt=it.IPV6,n.IPV6),[it.IPV6]:()=>(rt=it.BACKUP,n.BACKUP),[it.BACKUP]:()=>{return r?(rt=it.BACKUP_WEB_ONLY,e=n.BACKUP_WEB_ONLY,t=Math.floor(10001*Math.random())+1e4,e.replace("*",String(t))):o?(rt=it.BACKUP_CN,n.BACKUP_CN):i?(rt=it.ANYCAST,n.ANYCAST):n.DEFAULT;var e,t},[it.BACKUP_WEB_ONLY]:()=>o?(rt=it.BACKUP_CN,n.BACKUP_CN):i?(rt=it.ANYCAST,n.ANYCAST):n.DEFAULT,[it.BACKUP_CN]:()=>(rt=i?it.ANYCAST:it.DEFAULT,n[rt]),[it.ANYCAST]:()=>(rt=it.DEFAULT,n.ANYCAST="",n.DEFAULT)}[rt](),{isBinary:e})}var ut=new class{constructor(){this._timeOffsetWithServer=0}getServerTimeMs(){return Date.now()+this._timeOffsetWithServer}getServerTimeSeconds(){return Math.floor(this.getServerTimeMs()/1e3)}getTimeOffsetWithServer(){return this._timeOffsetWithServer}calculateTimeOffsetWithServer(e,t){var s=Date.now();this._timeOffsetWithServer=t+(s-e)-s}};let dt=16;var _t=new class{constructor(){this._tasks=[],this._timer=null,this._taskMap=new Map}_addTaskToScheduler(e){var t=e["id"];this.removeTask(t),this._tasks.push(e),this._taskMap.set(t,e),this._sort(),this._scheduleNextTask()}_createTask(e){var{id:e,callback:t,context:s,isOnce:n=!1,intervalMs:i=dt}=e,r=Math.max(i,dt);return{id:e,nextExecuteTime:Date.now()+r,intervalMs:i,callback:t,context:s,isOnce:n}}addTask(e){e=this._createTask(e);this._addTaskToScheduler(e)}addOnceTask(e){e=this._createTask(Object.assign(Object.assign({},e),{isOnce:!0}));this._addTaskToScheduler(e)}removeTask(t){var e=this._tasks.findIndex(e=>e.id===t);-1<e&&(this._tasks.splice(e,1),this._taskMap.delete(t),this._scheduleNextTask())}updateTaskInterval(e,t){e=this._taskMap.get(e);e&&(e.intervalMs=t,e.nextExecuteTime=Date.now()+t,this._sort(),this._scheduleNextTask())}clearAllTasks(){this._tasks=[],this._taskMap.clear(),this._timer&&(clearTimeout(this._timer),this._timer=null)}dispose(){this.clearAllTasks()}_sort(){this._tasks.sort((e,t)=>e.nextExecuteTime-t.nextExecuteTime)}_scheduleNextTask(){this._timer&&(clearTimeout(this._timer),this._timer=null);var e=this._tasks[0];e&&(e=Math.max(0,e.nextExecuteTime-Date.now()),this._timer=setTimeout(()=>this._execute(),e))}_execute(){for(var e=Date.now();this._tasks.length&&this._tasks[0].nextExecuteTime<=e;){var t=this._tasks[0];try{t.context?t.callback.call(t.context):t.callback(),t.isOnce?this.removeTask(t.id):(t.nextExecuteTime=e+t.intervalMs,this._sort())}catch(e){console.warn(`Task ${t.id} execution failed:`,e),t.isOnce&&this.removeTask(t.id)}}this._scheduleNextTask()}};function ht(t){var s=[];for(let e=0;e<t.length;e+=1){var n,i=t.charCodeAt(e);55296<=i&&i<=56319?(n=t.charCodeAt(++e)-56320+(i-55296<<10)+65536,s.push(240|n>>18,128|n>>12&63,128|n>>6&63,128|63&n)):i<=127?s.push(i):i<=2047?s.push(192|i>>6,128|63&i):s.push(224|i>>12,128|i>>6&63,128|63&i)}return new Uint8Array(s)}function gt(e){var t,s=Array.isArray(e)?[]:Object.create(null);for(t in e)Object.prototype.hasOwnProperty.call(e,t)&&r(t)&&null!=e[t]&&(null===e[t]||"object"!=typeof e[t]?s[t]=e[t]:s[t]=gt(e[t]));return s}function pt(e,t){if(_.includes(e))return 0;var s=ht(JSON.stringify(t));let n=4294967295;var i=s["length"];for(let e=0;e<i;e++){n^=s[e];for(let e=0;e<8;e++)1&~n?n>>>=1:n=n>>>1^3988292384}return(4294967295^n)>>>0}function Et(e){var t,{servcmd:e,data:s}=e,n=(n=e,i=qe.get("login")||{},t=qe.get("instance")||{},{servcmd:n,ver:"v4",platform:q,websdkappid:537048168,websdkversion:"1.7.3",a2:i.a2Key||void 0,tinyid:i.tinyID||void 0,status_instid:i.statusInstanceId||0,sdkappid:t.sdkAppId,contenttype:"json",reqtime:Math.floor(Date.now()/1e3),identifier:i.a2Key?void 0:i.userId,usersig:i.a2Key?void 0:i.userSig,sdkability:75689843,sdkability_ext:u(""),cappid:t.applicationID||0,tjgID:"",seq:St(),cs:0}),i=gt(s);return n.cs=pt(e,i),{head:n,body:i}}function ft(e){var t,{servcmd:e,data:s}=e,n=(n=e,i=qe.get("login")||{},t=qe.get("instance")||{},{servcmd:n,ver:"v4",platform:q,websdkappid:537048168,websdkversion:"1.7.3",sdkappid:t.sdkAppId,contenttype:"",reqtime:Math.floor(Date.now()/1e3),identifier:"",usersig:"",status_instid:i.statusInstanceId||0,sdkability:75689843,sdkability_ext:u(""),cappid:t.applicationID||0,seq:St(),cs:0}),i=gt(s);return n.cs=pt(e,i),{head:n,body:i}}let mt=c();function St(){return mt=mt<2415919103?mt+1:c()}function vt(){var e=qe.get("login")||{},t=qe.get("instance")||{};return{sdk_type:30,sdk_app_id:t.sdkAppId,sdk_version:"1.6.4",tiny_id:Number(e.tinyID),user_id:e.userId,platform:q,instance_id:t.instanceId,trace_id:(new Date).getTime()}}var It,yt,Ct=Object.freeze({__proto__:null,generateCosSpecifiedData:function(e){var t,{servcmd:e,data:s}=e,n=(n=e,i=qe.get("login")||{},t=qe.get("instance")||{},{servcmd:n,ver:"v4",platform:q,websdkappid:537048168,websdkversion:"1.7.3",sdkappid:t.sdkAppId,contenttype:"json",reqtime:Math.floor(Date.now()/1e3),identifier:i.userId,usersig:i.userSig,status_instid:i.statusInstanceId||0,sdkability:75689843,sdkability_ext:u(""),cappid:t.applicationID||0,seq:St(),cs:0}),i=gt(s);return n.cs=pt(e,i),{head:n,body:i}},generateProtocolData:Et,generateSSOLogProtocolData:ft,generateSequence:St,getCommonHead:vt,taskScheduler:_t,timeManager:ut});!function(e){e[e.info=4]="info",e[e.warning=5]="warning",e[e.error=6]="error"}(It=It||{});let Mt={method:"extension",networkType:"network_type",eventType:"event_type",code:"error_code",message:"error_message",moreMessage:"more_message",duplicate:"duplicate",costTime:"cost_time",level:"level",uiPlatform:"ui_platform",timestamp:"timestamp"};class Tt{constructor(e){this.level=It.info,this._canSendLog=!0,this._logCreatedAt=ut.getServerTimeMs(),this.timestamp=0,this.networkType=8,this.code=0,this.moreMessage="",this.method="",this.message="",this.costTime=0,this.duplicate=!1,this.eventType=0,this.uiPlatform=this._getUiPlatform(),this._sdkEdition=this._getSDKEdition();var{method:e,eventType:t=0,message:s="",costTime:n=0,error:i,moreMessage:r=""}=e||{};this.eventType=t,this.method=e,this.message=s,this.costTime=n,this.moreMessage=r,i&&this.setError(i)}setMoreMessage(e){this.moreMessage=this.moreMessage+" "+e}updateLogCreatedAtByTimeOffset(){this._logCreatedAt+=ut.getTimeOffsetWithServer()}end(e=!1){this._canSendLog&&(this._canSendLog=!1,this.timestamp=ut.getServerTimeMs(),this._ssoLogModule.pushToLogQueue(this._convertSSOLogDataKeyToServe()),e)&&this._ssoLogModule.uploadSSOLogData()}setError(e){var t;return e instanceof Error?this._canSendLog&&(null!=(t=qe.get("netWorkMonitor"))&&t.isNetworkOnline&&(e.errorCode&&(this.code=e.errorCode),e.errorMessage)&&this.setMoreMessage(e.errorMessage),this.level=It.error):console.warn("SSOLogData.setError value not instanceof Error, please check!"),this}setLogInfo(t){return Object.keys(t).forEach(e=>{Object.keys(Mt).includes(e)&&(this[e]=t[e])}),this}setSSOLogModule(e){this._ssoLogModule=e}_convertSSOLogDataKeyToServe(){let t={};return Object.keys(this).forEach(e=>{Mt[e]&&(t[Mt[e]]=this[e])}),t}_getUiPlatform(){var e,t=null==(e=qe.get("instance"))?void 0:e.scene;if("string"==typeof t){let e=Number(t);return isNaN(e)?void 0:e}}_getSDKEdition(){var e;return null==(e=qe.get("instance"))?void 0:e.sdkEdition}}!function(e){e.RECONNECTED="reconnected",e.CLOUD_CONFIG_UPDATE="cloud_config_update",e.SOCKET_DISCONNECTED="socket_disconnected"}(yt=yt||{});var Ot=yt;let At=20,Nt=6e4,Rt=[4,5,6],Dt=[],Pt=[],bt="report-logger";var wt=new class{constructor(){this._sdkAppIdBlackList=[],this._tinyIdWhiteList=[],this._reportLevel=[4,5,6],this._minThreshold=At,this._maxThreshold=100,this._waitingTime=Nt,this._lastReportAt=Date.now(),this._ssoLogMap=new Map,this._logLevel=h.DEBUG,this._throttleConfig={global:{throttleTime:S,maxCount:v},single:{throttleTime:f,maxCount:m}},this._globalThrottle={count:0,startTime:Date.now()},this._singleThrottleMap=new Map,De.subscribeInnerEvent(Ot.CLOUD_CONFIG_UPDATE,this._handleCloudConfigUpdate,this),_t.addTask({id:bt,intervalMs:1e3,callback:this._checkAndReportIfDue,context:this}),this._logQueue=[],this._savePlatFormInfo()}_handleCloudConfigUpdate(e){var{evt_rpt_threshold:e=At,evt_rpt_waiting:t=Nt,evt_rpt_level:s=Rt,evt_rpt_sdkappid_bl:n=Dt,evt_rpt_tinyid_wl:i=Pt,evt_rpt_global_throttle_time:r=S,evt_rpt_global_throttle_count:o=v,evt_rpt_single_throttle_time:a=f,evt_rpt_single_throttle_count:l=m}=e||{};this._sdkAppIdBlackList=n,this._waitingTime=t,this._minThreshold=e,this._reportLevel=s,this._tinyIdWhiteList=i,this._throttleConfig={global:{throttleTime:r,maxCount:o},single:{throttleTime:a,maxCount:l}}}createSSOLogData(e){var t=new Tt(e);return t.setSSOLogModule(this),this._ssoLogMap.set(e.method,t),t}getSSOLogData(e){return this._ssoLogMap.get(e)||{}}pushToLogQueue(e){e&&(this._logQueue.push(e),this._shouldUploadImmediately())&&this.uploadSSOLogData()}setLogLevel(e){[h.DEBUG,h.ERROR,h.INFO,h.NONE,h.WARN].includes(e)&&(this._logLevel=e)}debug(e,t="",s){this._log(h.DEBUG,e,t,s)}info(e,t="",s){this._log(h.INFO,e,t,s)}warn(e,t="",s){this._log(h.WARN,e,t,s)}error(e,t="",s){this._log(h.ERROR,e,t,s)}_shouldUploadImmediately(){return this._logQueue.length>=this._minThreshold}_isReportDue(){return Date.now()>=this._lastReportAt+this._waitingTime}_checkAndReportIfDue(){this._isReportDue()&&0<this._logQueue.length&&this.uploadSSOLogData()}uploadSSOLogData(){return de(this,void 0,void 0,function*(){var e,t;0!==this._logQueue.length&&(t=this._logQueue.slice(),t=this._filterLogs(t),this._logQueue=[],0===t.length||fe((t={Header:vt(),Event:t}).Header.user_id)||(e=(t=ft({servcmd:e="imopenstat.tim_web_report_v2",data:t})).head.seq+e,yield void Qt.sendPacket(t,{requestId:e})),this._lastReportAt=Date.now())})}_savePlatFormInfo(){var e,t;if(T){var s=null==(t=null==(e=wx.getAccountInfoSync)?void 0:e.call(wx))?void 0:t.miniProgram;if(s){let{appId:e,envVersion:t}=s;qe.set("instance",{appId:e,envVersion:t})}}else B&&qe.set("instance",{href:window.location.href})}_filterLogs(e){var t=(qe.get("login")||{})["tinyID"],s=(qe.get("instance")||{})["sdkAppId"];return this._sdkAppIdBlackList.includes(s)&&!this._tinyIdWhiteList.includes(t)?[]:e.filter(e=>this._reportLevel.includes(e.level))}_checkThrottle(e){return!!this._checkGlobalThrottle()||this._checkSingleThrottle(e)}_checkGlobalThrottle(){var e=Date.now();if(e-this._globalThrottle.startTime>=this._throttleConfig.global.throttleTime)this._globalThrottle.count=1,this._globalThrottle.startTime=e;else if(this._globalThrottle.count++,this._globalThrottle.count>this._throttleConfig.global.maxCount)return!0;return!1}_checkSingleThrottle(e){var t=Date.now(),s=this._singleThrottleMap.get(e);return s?t-s.startTime>=this._throttleConfig.single.throttleTime?(s.count=1,s.startTime=t,!1):s.count>=this._throttleConfig.single.maxCount||(s.count++,!1):(this._singleThrottleMap.set(e,{count:1,startTime:t}),!1)}_shouldLog(e){return e>=this._logLevel&&this._logLevel!==h.NONE}_shouldReport(e){return this._reportLevel.includes(E[e])}_formatLog(e,t,s){var n=new Date,n=`${n.getHours()}:${n.getMinutes()}:${n.getSeconds()}:`+n.getMilliseconds(),e=`<${h[e]}>`;return ee||k?[g+` [${n}] ${e} [${t}] `+s]:["%c%s%c%s","background:#0abf5b; padding:1px; border-radius:3px; color: #fff",g,"",`[${n}] ${e} [${t}] `+s]}_log(e,t,s,n){if(this._shouldLog(e)){var i=this._formatLog(e,t,s);if(p[e].apply(console,i),this._shouldReport(e)){let e=this._getThrottleKey(t,s,n);this._checkThrottle(e)||this.createSSOLogData(Object.assign(Object.assign({message:s},n),{method:t})).end()}}}_getThrottleKey(e,t,s){var e=""+e+t+Se(Object.assign(Object.assign({},s),{costTime:""})),n=ht(JSON.stringify(e));let i=4294967295;var r=n["length"];for(let e=0;e<r;e++){i^=n[e];for(let e=0;e<8;e++)1&~i?i>>>=1:i=i>>>1^3988292384}return""+((4294967295^i)>>>0)}reset(){console.log("SSO_LOG_MODULE.reset"),_t.removeTask(bt),De.unSubscribeInnerEvent(Ot.CLOUD_CONFIG_UPDATE,this._handleCloudConfigUpdate,this),this._lastReportAt=0,this.uploadSSOLogData(),this._sdkAppIdBlackList=[],this._tinyIdWhiteList=[],this._minThreshold=At,this._maxThreshold=100,this._waitingTime=Nt,this._logQueue=[],this._logLevel=h.DEBUG,this._globalThrottle={count:0,startTime:Date.now()},this._singleThrottleMap.clear()}};let Lt=15e3,kt="Channel",Ut="channel_schedule_task",Gt="channel_reconnect_task",Ft="connected",Bt="connecting",xt="disconnected",Vt=1e3,$t="network_status_change",qt="activity_status_change",Wt="send_fail",Yt="reconnect_failed",Kt="socket_error",Ht="socket_close";function jt(e){return(jt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function zt(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Zt,ns,Xt={exports:{}},Jt=(Zt||(Xt.exports=function s(n,i,r){function o(t,e){if(!i[t]){if(!n[t]){if(!e&&zt)return zt(t);if(a)return a(t,!0);e=new Error("Cannot find module '"+t+"'");throw e.code="MODULE_NOT_FOUND",e}e=i[t]={exports:{}};n[t][0].call(e.exports,function(e){return o(n[t][1][e]||e)},e,e.exports,s,n,i,r)}return i[t].exports}for(var a=zt,e=0;e<r.length;e++)o(r[e]);return o}({1:[function(e,t,s){var n="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array,i=(s.assign=function(e){for(var t,s,n=Array.prototype.slice.call(arguments,1);n.length;){var i=n.shift();if(i){if("object"!=jt(i))throw new TypeError(i+"must be non-object");for(var r in i)t=i,s=r,Object.prototype.hasOwnProperty.call(t,s)&&(e[r]=i[r])}}return e},s.shrinkBuf=function(e,t){return e.length===t?e:e.subarray?e.subarray(0,t):(e.length=t,e)},{arraySet:function(e,t,s,n,i){if(t.subarray&&e.subarray)e.set(t.subarray(s,s+n),i);else for(var r=0;r<n;r++)e[i+r]=t[s+r]},flattenChunks:function(e){for(var t,s,n,i,r=t=0,o=e.length;r<o;r++)t+=e[r].length;for(i=new Uint8Array(t),r=s=0,o=e.length;r<o;r++)n=e[r],i.set(n,s),s+=n.length;return i}}),r={arraySet:function(e,t,s,n,i){for(var r=0;r<n;r++)e[i+r]=t[s+r]},flattenChunks:function(e){return[].concat.apply([],e)}};s.setTyped=function(e){e?(s.Buf8=Uint8Array,s.Buf16=Uint16Array,s.Buf32=Int32Array,s.assign(s,i)):(s.Buf8=Array,s.Buf16=Array,s.Buf32=Array,s.assign(s,r))},s.setTyped(n)},{}],2:[function(e,t,s){var l=e("./common"),i=!0,r=!0;try{String.fromCharCode.apply(null,[0])}catch(e){i=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(e){r=!1}for(var c=new l.Buf8(256),n=0;n<256;n++)c[n]=252<=n?6:248<=n?5:240<=n?4:224<=n?3:192<=n?2:1;function u(e,t){if(t<65534&&(e.subarray&&r||!e.subarray&&i))return String.fromCharCode.apply(null,l.shrinkBuf(e,t));for(var s="",n=0;n<t;n++)s+=String.fromCharCode(e[n]);return s}c[254]=c[254]=1,s.string2buf=function(e){for(var t,s,n,i,r=e.length,o=0,a=0;a<r;a++)55296==(64512&(s=e.charCodeAt(a)))&&a+1<r&&56320==(64512&(n=e.charCodeAt(a+1)))&&(s=65536+(s-55296<<10)+(n-56320),a++),o+=s<128?1:s<2048?2:s<65536?3:4;for(t=new l.Buf8(o),a=i=0;i<o;a++)55296==(64512&(s=e.charCodeAt(a)))&&a+1<r&&56320==(64512&(n=e.charCodeAt(a+1)))&&(s=65536+(s-55296<<10)+(n-56320),a++),s<128?t[i++]=s:(s<2048?t[i++]=192|s>>>6:(s<65536?t[i++]=224|s>>>12:(t[i++]=240|s>>>18,t[i++]=128|s>>>12&63),t[i++]=128|s>>>6&63),t[i++]=128|63&s);return t},s.buf2binstring=function(e){return u(e,e.length)},s.binstring2buf=function(e){for(var t=new l.Buf8(e.length),s=0,n=t.length;s<n;s++)t[s]=e.charCodeAt(s);return t},s.buf2string=function(e,t){for(var s,n,i,r=t||e.length,o=new Array(2*r),a=s=0;a<r;)if((n=e[a++])<128)o[s++]=n;else if(4<(i=c[n]))o[s++]=65533,a+=i-1;else{for(n&=2===i?31:3===i?15:7;1<i&&a<r;)n=n<<6|63&e[a++],i--;1<i?o[s++]=65533:n<65536?o[s++]=n:(n-=65536,o[s++]=55296|n>>10&1023,o[s++]=56320|1023&n)}return u(o,s)},s.utf8border=function(e,t){for(var s=(t=(t=t||e.length)>e.length?e.length:t)-1;0<=s&&128==(192&e[s]);)s--;return!(s<0||0===s)&&s+c[e[s]]>t?s:t}},{"./common":Zt=1}],3:[function(e,t,s){t.exports=function(e,t,s,n){for(var i=65535&e,r=e>>>16&65535,o=0;0!==s;){for(s-=o=2e3<s?2e3:s;r=r+(i=i+t[n++]|0)|0,--o;);i%=65521,r%=65521}return i|r<<16}},{}],4:[function(e,t,s){t.exports={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}},{}],5:[function(e,t,s){var a=function(){for(var e=[],t=0;t<256;t++){for(var s=t,n=0;n<8;n++)s=1&s?3988292384^s>>>1:s>>>1;e[t]=s}return e}();t.exports=function(e,t,s,n){var i=a,r=n+s;e^=-1;for(var o=n;o<r;o++)e=e>>>8^i[255&(e^t[o])];return-1^e}},{}],6:[function(e,t,s){t.exports=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}},{}],7:[function(e,t,s){t.exports=function(e,t){var s,n,i,r,o,a,l=e.state,c=e.next_in,u=e.input,d=c+(e.avail_in-5),_=e.next_out,h=e.output,g=_-(t-e.avail_out),p=_+(e.avail_out-257),E=l.dmax,m=l.wsize,f=l.whave,S=l.wnext,v=l.window,I=l.hold,C=l.bits,T=l.lencode,M=l.distcode,y=(1<<l.lenbits)-1,O=(1<<l.distbits)-1;e:do{for(C<15&&(I+=u[c++]<<C,C+=8,I+=u[c++]<<C,C+=8),s=T[I&y];;){if(I>>>=n=s>>>24,C-=n,0==(n=s>>>16&255))h[_++]=65535&s;else{if(!(16&n)){if(!(64&n)){s=T[(65535&s)+(I&(1<<n)-1)];continue}if(32&n){l.mode=12;break e}e.msg="invalid literal/length code",l.mode=30;break e}for(i=65535&s,(n&=15)&&(C<n&&(I+=u[c++]<<C,C+=8),i+=I&(1<<n)-1,I>>>=n,C-=n),C<15&&(I+=u[c++]<<C,C+=8,I+=u[c++]<<C,C+=8),s=M[I&O];;){if(I>>>=n=s>>>24,C-=n,!(16&(n=s>>>16&255))){if(!(64&n)){s=M[(65535&s)+(I&(1<<n)-1)];continue}e.msg="invalid distance code",l.mode=30;break e}if(r=65535&s,C<(n&=15)&&(I+=u[c++]<<C,(C+=8)<n)&&(I+=u[c++]<<C,C+=8),E<(r+=I&(1<<n)-1)){e.msg="invalid distance too far back",l.mode=30;break e}if(I>>>=n,C-=n,(n=_-g)<r){if(f<(n=r-n)&&l.sane){e.msg="invalid distance too far back",l.mode=30;break e}if(a=v,(o=0)===S){if(o+=m-n,n<i){for(i-=n;h[_++]=v[o++],--n;);o=_-r,a=h}}else if(S<n){if(o+=m+S-n,(n-=S)<i){for(i-=n;h[_++]=v[o++],--n;);if(o=0,S<i){for(i-=n=S;h[_++]=v[o++],--n;);o=_-r,a=h}}}else if(o+=S-n,n<i){for(i-=n;h[_++]=v[o++],--n;);o=_-r,a=h}for(;2<i;)h[_++]=a[o++],h[_++]=a[o++],h[_++]=a[o++],i-=3;i&&(h[_++]=a[o++],1<i)&&(h[_++]=a[o++])}else{for(o=_-r;h[_++]=h[o++],h[_++]=h[o++],h[_++]=h[o++],2<(i-=3););i&&(h[_++]=h[o++],1<i)&&(h[_++]=h[o++])}break}}break}}while(c<d&&_<p);c-=i=C>>3,I&=(1<<(C-=i<<3))-1,e.next_in=c,e.next_out=_,e.avail_in=c<d?d-c+5:5-(c-d),e.avail_out=_<p?p-_+257:257-(_-p),l.hold=I,l.bits=C}},{}],8:[function(e,t,s){var P=e("../utils/common"),w=e("./adler32"),b=e("./crc32"),L=e("./inffast"),k=e("./inftrees"),U=0,G=-2,F=1,n=852,i=592;function x(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function r(){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 P.Buf16(320),this.work=new P.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function o(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=F,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new P.Buf32(n),t.distcode=t.distdyn=new P.Buf32(i),t.sane=1,t.back=-1,U):G}function a(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,o(e)):G}function l(e,t){var s,n;return!e||!e.state||(n=e.state,t<0?(s=0,t=-t):(s=1+(t>>4),t<48&&(t&=15)),t&&(t<8||15<t))?G:(null!==n.window&&n.wbits!==t&&(n.window=null),n.wrap=s,n.wbits=t,a(e))}function c(e,t){var s;return e?(s=new r,(e.state=s).window=null,(s=l(e,t))!==U&&(e.state=null),s):G}var B,V,q=!0;function W(e,t,s,n){var i,e=e.state;return null===e.window&&(e.wsize=1<<e.wbits,e.wnext=0,e.whave=0,e.window=new P.Buf8(e.wsize)),n>=e.wsize?(P.arraySet(e.window,t,s-e.wsize,e.wsize,0),e.wnext=0,e.whave=e.wsize):(n<(i=e.wsize-e.wnext)&&(i=n),P.arraySet(e.window,t,s-n,i,e.wnext),(n-=i)?(P.arraySet(e.window,t,s-n,n,0),e.wnext=n,e.whave=e.wsize):(e.wnext+=i,e.wnext===e.wsize&&(e.wnext=0),e.whave<e.wsize&&(e.whave+=i))),0}s.inflateReset=a,s.inflateReset2=l,s.inflateResetKeep=o,s.inflateInit=function(e){return c(e,15)},s.inflateInit2=c,s.inflate=function(e,t){var s,n,i,r,o,a,l,c,u,d,_,h,g,p,E,m,f,S,v,I,C,T,M,y,O=0,A=new P.Buf8(4),R=[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 G;12===(s=e.state).mode&&(s.mode=13),o=e.next_out,i=e.output,l=e.avail_out,r=e.next_in,n=e.input,a=e.avail_in,c=s.hold,u=s.bits,d=a,_=l,T=U;e:for(;;)switch(s.mode){case F:if(0===s.wrap)s.mode=13;else{for(;u<16;){if(0===a)break e;a--,c+=n[r++]<<u,u+=8}if(2&s.wrap&&35615===c)A[s.check=0]=255&c,A[1]=c>>>8&255,s.check=b(s.check,A,2,0),u=c=0,s.mode=2;else 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;else if(8!=(15&c))e.msg="unknown compression method",s.mode=30;else{if(u-=4,C=8+(15&(c>>>=4)),0===s.wbits)s.wbits=C;else if(C>s.wbits){e.msg="invalid window size",s.mode=30;break}s.dmax=1<<C,e.adler=s.check=1,s.mode=512&c?10:12,u=c=0}}break;case 2:for(;u<16;){if(0===a)break e;a--,c+=n[r++]<<u,u+=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=b(s.check,A,2,0)),u=c=0,s.mode=3;case 3:for(;u<32;){if(0===a)break e;a--,c+=n[r++]<<u,u+=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=b(s.check,A,4,0)),u=c=0,s.mode=4;case 4:for(;u<16;){if(0===a)break e;a--,c+=n[r++]<<u,u+=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=b(s.check,A,2,0)),u=c=0,s.mode=5;case 5:if(1024&s.flags){for(;u<16;){if(0===a)break e;a--,c+=n[r++]<<u,u+=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=b(s.check,A,2,0)),u=c=0}else s.head&&(s.head.extra=null);s.mode=6;case 6:if(1024&s.flags&&((h=a<(h=s.length)?a:h)&&(s.head&&(C=s.head.extra_len-s.length,s.head.extra||(s.head.extra=new Array(s.head.extra_len)),P.arraySet(s.head.extra,n,r,h,C)),512&s.flags&&(s.check=b(s.check,n,h,r)),a-=h,r+=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;for(h=0;C=n[r+h++],s.head&&C&&s.length<65536&&(s.head.name+=String.fromCharCode(C)),C&&h<a;);if(512&s.flags&&(s.check=b(s.check,n,h,r)),a-=h,r+=h,C)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;for(h=0;C=n[r+h++],s.head&&C&&s.length<65536&&(s.head.comment+=String.fromCharCode(C)),C&&h<a;);if(512&s.flags&&(s.check=b(s.check,n,h,r)),a-=h,r+=h,C)break e}else s.head&&(s.head.comment=null);s.mode=9;case 9:if(512&s.flags){for(;u<16;){if(0===a)break e;a--,c+=n[r++]<<u,u+=8}if(c!==(65535&s.check)){e.msg="header crc mismatch",s.mode=30;break}u=c=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(;u<32;){if(0===a)break e;a--,c+=n[r++]<<u,u+=8}e.adler=s.check=x(c),u=c=0,s.mode=11;case 11:if(0===s.havedict)return e.next_out=o,e.avail_out=l,e.next_in=r,e.avail_in=a,s.hold=c,s.bits=u,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&u,u-=7&u,s.mode=27;else{for(;u<3;){if(0===a)break e;a--,c+=n[r++]<<u,u+=8}switch(s.last=1&c,--u,3&(c>>>=1)){case 0:s.mode=14;break;case 1:N=D=void 0;var N,D=s;if(q){for(B=new P.Buf32(512),V=new P.Buf32(32),N=0;N<144;)D.lens[N++]=8;for(;N<256;)D.lens[N++]=9;for(;N<280;)D.lens[N++]=7;for(;N<288;)D.lens[N++]=8;for(k(1,D.lens,0,288,B,0,D.work,{bits:9}),N=0;N<32;)D.lens[N++]=5;k(2,D.lens,0,32,V,0,D.work,{bits:5}),q=!1}if(D.lencode=B,D.lenbits=9,D.distcode=V,D.distbits=5,s.mode=20,6!==t)break;c>>>=2,u-=2;break e;case 2:s.mode=17;break;case 3:e.msg="invalid block type",s.mode=30}c>>>=2,u-=2}break;case 14:for(c>>>=7&u,u-=7&u;u<32;){if(0===a)break e;a--,c+=n[r++]<<u,u+=8}if((65535&c)!=(c>>>16^65535)){e.msg="invalid stored block lengths",s.mode=30;break}if(s.length=65535&c,u=c=0,s.mode=15,6===t)break e;case 15:s.mode=16;case 16:if(h=s.length){if(0===(h=l<(h=a<h?a:h)?l:h))break e;P.arraySet(i,n,r,h,o),a-=h,r+=h,l-=h,o+=h,s.length-=h}else s.mode=12;break;case 17:for(;u<14;){if(0===a)break e;a--,c+=n[r++]<<u,u+=8}if(s.nlen=257+(31&c),c>>>=5,u-=5,s.ndist=1+(31&c),c>>>=5,u-=5,s.ncode=4+(15&c),c>>>=4,u-=4,286<s.nlen||30<s.ndist){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(;u<3;){if(0===a)break e;a--,c+=n[r++]<<u,u+=8}s.lens[R[s.have++]]=7&c,c>>>=3,u-=3}for(;s.have<19;)s.lens[R[s.have++]]=0;if(s.lencode=s.lendyn,s.lenbits=7,M={bits:s.lenbits},T=k(0,s.lens,0,19,s.lencode,0,s.work,M),s.lenbits=M.bits,T){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=(O=s.lencode[c&(1<<s.lenbits)-1])>>>16&255,f=65535&O,!((E=O>>>24)<=u);){if(0===a)break e;a--,c+=n[r++]<<u,u+=8}if(f<16)c>>>=E,u-=E,s.lens[s.have++]=f;else{if(16===f){for(y=E+2;u<y;){if(0===a)break e;a--,c+=n[r++]<<u,u+=8}if(c>>>=E,u-=E,0===s.have){e.msg="invalid bit length repeat",s.mode=30;break}C=s.lens[s.have-1],h=3+(3&c),c>>>=2,u-=2}else if(17===f){for(y=E+3;u<y;){if(0===a)break e;a--,c+=n[r++]<<u,u+=8}C=0,h=3+(7&(c>>>=E)),c>>>=3,u=u-E-3}else{for(y=E+7;u<y;){if(0===a)break e;a--,c+=n[r++]<<u,u+=8}C=0,h=11+(127&(c>>>=E)),c>>>=7,u=u-E-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++]=C}}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,M={bits:s.lenbits},T=k(1,s.lens,0,s.nlen,s.lencode,0,s.work,M),s.lenbits=M.bits,T){e.msg="invalid literal/lengths set",s.mode=30;break}if(s.distbits=6,s.distcode=s.distdyn,M={bits:s.distbits},T=k(2,s.lens,s.nlen,s.ndist,s.distcode,0,s.work,M),s.distbits=M.bits,T){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(6<=a&&258<=l){e.next_out=o,e.avail_out=l,e.next_in=r,e.avail_in=a,s.hold=c,s.bits=u,L(e,_),o=e.next_out,i=e.output,l=e.avail_out,r=e.next_in,n=e.input,a=e.avail_in,c=s.hold,u=s.bits,12===s.mode&&(s.back=-1);break}for(s.back=0;m=(O=s.lencode[c&(1<<s.lenbits)-1])>>>16&255,f=65535&O,!((E=O>>>24)<=u);){if(0===a)break e;a--,c+=n[r++]<<u,u+=8}if(m&&!(240&m)){for(S=E,v=m,I=f;m=(O=s.lencode[I+((c&(1<<S+v)-1)>>S)])>>>16&255,f=65535&O,!(S+(E=O>>>24)<=u);){if(0===a)break e;a--,c+=n[r++]<<u,u+=8}c>>>=S,u-=S,s.back+=S}if(c>>>=E,u-=E,s.back+=E,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(y=s.extra;u<y;){if(0===a)break e;a--,c+=n[r++]<<u,u+=8}s.length+=c&(1<<s.extra)-1,c>>>=s.extra,u-=s.extra,s.back+=s.extra}s.was=s.length,s.mode=23;case 23:for(;m=(O=s.distcode[c&(1<<s.distbits)-1])>>>16&255,f=65535&O,!((E=O>>>24)<=u);){if(0===a)break e;a--,c+=n[r++]<<u,u+=8}if(!(240&m)){for(S=E,v=m,I=f;m=(O=s.distcode[I+((c&(1<<S+v)-1)>>S)])>>>16&255,f=65535&O,!(S+(E=O>>>24)<=u);){if(0===a)break e;a--,c+=n[r++]<<u,u+=8}c>>>=S,u-=S,s.back+=S}if(c>>>=E,u-=E,s.back+=E,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(y=s.extra;u<y;){if(0===a)break e;a--,c+=n[r++]<<u,u+=8}s.offset+=c&(1<<s.extra)-1,c>>>=s.extra,u-=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===l)break e;if(s.offset>(h=_-l)){if((h=s.offset-h)>s.whave&&s.sane){e.msg="invalid distance too far back",s.mode=30;break}g=h>s.wnext?(h-=s.wnext,s.wsize-h):s.wnext-h,h>s.length&&(h=s.length),p=s.window}else p=i,g=o-s.offset,h=s.length;for(l-=h=l<h?l:h,s.length-=h;i[o++]=p[g++],--h;);0===s.length&&(s.mode=21);break;case 26:if(0===l)break e;i[o++]=s.length,l--,s.mode=21;break;case 27:if(s.wrap){for(;u<32;){if(0===a)break e;a--,c|=n[r++]<<u,u+=8}if(_-=l,e.total_out+=_,s.total+=_,_&&(e.adler=s.check=(s.flags?b:w)(s.check,i,_,o-_)),_=l,(s.flags?c:x(c))!==s.check){e.msg="incorrect data check",s.mode=30;break}u=c=0}s.mode=28;case 28:if(s.wrap&&s.flags){for(;u<32;){if(0===a)break e;a--,c+=n[r++]<<u,u+=8}if(c!==(4294967295&s.total)){e.msg="incorrect length check",s.mode=30;break}u=c=0}s.mode=29;case 29:T=1;break e;case 30:T=-3;break e;case 31:return-4;default:return G}return e.next_out=o,e.avail_out=l,e.next_in=r,e.avail_in=a,s.hold=c,s.bits=u,(s.wsize||_!==e.avail_out&&s.mode<30&&(s.mode<27||4!==t))&&W(e,e.output,e.next_out,_-e.avail_out)?(s.mode=31,-4):(d-=e.avail_in,_-=e.avail_out,e.total_in+=d,e.total_out+=_,s.total+=_,s.wrap&&_&&(e.adler=s.check=(s.flags?b:w)(s.check,i,_,e.next_out-_)),e.data_type=s.bits+(s.last?64:0)+(12===s.mode?128:0)+(20===s.mode||15===s.mode?256:0),T=(0==d&&0===_||4===t)&&T===U?-5:T)},s.inflateEnd=function(e){var t;return e&&e.state?((t=e.state).window&&(t.window=null),e.state=null,U):G},s.inflateGetHeader=function(e,t){return e&&e.state&&2&(e=e.state).wrap?((e.head=t).done=!1,U):G},s.inflateSetDictionary=function(e,t){var s,n=t.length;return!e||!e.state||0!==(s=e.state).wrap&&11!==s.mode?G:11===s.mode&&w(1,t,n,0)!==s.check?-3:W(e,t,n,n)?(s.mode=31,-4):(s.havedict=1,U)},s.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":1,"./adler32":3,"./crc32":5,"./inffast":7,"./inftrees":9}],9:[function(e,t,s){var L=e("../utils/common"),k=[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],U=[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],G=[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],F=[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];t.exports=function(e,t,s,n,i,r,o,a){for(var l,c,u,d,_,h,g,p,E,m=a.bits,f=0,S=0,v=0,I=0,C=0,T=0,M=0,y=0,O=0,A=0,R=null,N=0,D=new L.Buf16(16),P=new L.Buf16(16),w=null,b=0,f=0;f<=15;f++)D[f]=0;for(S=0;S<n;S++)D[t[s+S]]++;for(C=m,I=15;1<=I&&0===D[I];I--);if(I<C&&(C=I),0===I)i[r++]=20971520,i[r++]=20971520,a.bits=1;else{for(v=1;v<I&&0===D[v];v++);for(C<v&&(C=v),f=y=1;f<=15;f++)if((y=(y<<1)-D[f])<0)return-1;if(0<y&&(0===e||1!==I))return-1;for(P[1]=0,f=1;f<15;f++)P[f+1]=P[f]+D[f];for(S=0;S<n;S++)0!==t[s+S]&&(o[P[t[s+S]]++]=S);if(h=0===e?(R=w=o,19):1===e?(R=k,N-=257,w=U,b-=257,256):(R=G,w=F,-1),f=v,_=r,M=S=A=0,u=-1,d=(O=1<<(T=C))-1,1===e&&852<O||2===e&&592<O)return 1;for(;;){for(E=o[S]<h?(p=0,o[S]):o[S]>h?(p=w[b+o[S]],R[N+o[S]]):(p=96,0),l=1<<(g=f-M),v=c=1<<T;i[_+(A>>M)+(c-=l)]=g<<24|p<<16|E,0!==c;);for(l=1<<f-1;A&l;)l>>=1;if(0!==l?A=(A&l-1)+l:A=0,S++,0==--D[f]){if(f===I)break;f=t[s+o[S]]}if(C<f&&(A&d)!==u){for(_+=v,y=1<<(T=f-(M=0===M?C:M));T+M<I&&!((y-=D[T+M])<=0);)T++,y<<=1;if(O+=1<<T,1===e&&852<O||2===e&&592<O)return 1;i[u=A&d]=C<<24|T<<16|_-r}}0!==A&&(i[_+A]=f-M<<24|64<<16),a.bits=C}return 0}},{"../utils/common":1}],10:[function(e,t,s){t.exports={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"}},{}],11:[function(e,t,s){t.exports=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}},{}],"/lib/inflate.js":[function(e,t,s){var d=e("./zlib/inflate"),_=e("./utils/common"),h=e("./utils/strings"),g=e("./zlib/constants"),n=e("./zlib/messages"),i=e("./zlib/zstream"),r=e("./zlib/gzheader"),p=Object.prototype.toString;function o(e){if(!(this instanceof o))return new o(e);this.options=_.assign({chunkSize:16384,windowBits:0,to:""},e||{});var t=this.options,e=(t.raw&&0<=t.windowBits&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits)&&(t.windowBits=-15),!(0<=t.windowBits&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),15<t.windowBits&&t.windowBits<48&&!(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new i,this.strm.avail_out=0,d.inflateInit2(this.strm,t.windowBits));if(e!==g.Z_OK)throw new Error(n[e]);if(this.header=new r,d.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=h.string2buf(t.dictionary):"[object ArrayBuffer]"===p.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw)&&(e=d.inflateSetDictionary(this.strm,t.dictionary))!==g.Z_OK)throw new Error(n[e])}function a(e,t){t=new o(t);if(t.push(e,!0),t.err)throw t.msg||n[t.err];return t.result}o.prototype.push=function(e,t){var s,n,i,r,o,a=this.strm,l=this.options.chunkSize,c=this.options.dictionary,u=!1;if(this.ended)return!1;n=t===~~t?t:!0===t?g.Z_FINISH:g.Z_NO_FLUSH,"string"==typeof e?a.input=h.binstring2buf(e):"[object ArrayBuffer]"===p.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 _.Buf8(l),a.next_out=0,a.avail_out=l),(s=(s=d.inflate(a,g.Z_NO_FLUSH))===g.Z_NEED_DICT&&c?d.inflateSetDictionary(this.strm,c):s)===g.Z_BUF_ERROR&&!0===u&&(s=g.Z_OK,u=!1),s!==g.Z_STREAM_END&&s!==g.Z_OK)return this.onEnd(s),!(this.ended=!0)}while(!a.next_out||0!==a.avail_out&&s!==g.Z_STREAM_END&&(0!==a.avail_in||n!==g.Z_FINISH&&n!==g.Z_SYNC_FLUSH)||("string"===this.options.to?(i=h.utf8border(a.output,a.next_out),r=a.next_out-i,o=h.buf2string(a.output,i),a.next_out=r,a.avail_out=l-r,r&&_.arraySet(a.output,a.output,i,r,0),this.onData(o)):this.onData(_.shrinkBuf(a.output,a.next_out))),0===a.avail_in&&0===a.avail_out&&(u=!0),(0<a.avail_in||0===a.avail_out)&&s!==g.Z_STREAM_END);return(n=s===g.Z_STREAM_END?g.Z_FINISH:n)===g.Z_FINISH?(s=d.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,s===g.Z_OK):n!==g.Z_SYNC_FLUSH||(this.onEnd(g.Z_OK),!(a.avail_out=0))},o.prototype.onData=function(e){this.chunks.push(e)},o.prototype.onEnd=function(e){e===g.Z_OK&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=_.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},s.Inflate=o,s.inflate=a,s.inflateRaw=function(e,t){return(t=t||{}).raw=!0,a(e,t)},s.ungzip=a},{"./utils/common":1,"./utils/strings":2,"./zlib/constants":4,"./zlib/gzheader":6,"./zlib/inflate":8,"./zlib/messages":10,"./zlib/zstream":11}]},{},[])("/lib/inflate.js")),Xt.exports),Qt=new class{constructor(){this._socketAdapter=null,this._url="",this._isReconnecting=!1,this._pendingRequests=new Map,this._nextHeartbeatAt=0,this._lastDiagnoseAt=0,this._isHeartbeatInProgress=!1,this._connectionEstablishedTime=0,this._connectionStartTime=0,this._connectionId=-1,this._isBinarySupported=!0,this._intendedDelay=Vt,this._currentConnectState=Ft,this._beforeSendInterceptors=[]}init(){_t.addTask({id:Ut,intervalMs:1e3,callback:this._executeScheduledTaskIfReady,context:this}),this._updateIsBinarySupported(),this._url=function(e){var{sdkAppId:t,testEnv:s,disableIndependentDomain:n}=qe.get("instance"),i=nt(t);let r="";return s?r=et.TEST[i].DEFAULT:n?(r=et.PRODUCTION[i].DEFAULT,rt=it.DEFAULT):r=et.PRODUCTION[i].INITIAL.replace("*",""+t),ct(r,{isBinary:e})}(this._isBinarySupported),De.subscribeInnerEvent("networkStatusChange",this._handleNetworkStatusChange,this),De.subscribeInnerEvent("activityStatusChange",this._handleActivityStatusChange,this),this.connect()}sendPacket(e,t){var s,{requestId:n,timeout:i=Lt,canResend:r=!0}=t||{};if(fe(e))return wt.warn("sendPacket",kt+".sendPacket: packet is empty "),null;this._executeBeforeSendInterceptors(e),this._currentConnectState===xt&&this._handleConnectStateChange({state:xt,shouldEmitEvent:!0,shouldAttemptReconnect:!0,reason:Wt});var o=JSON.stringify(e);let a=null;if(n){let{resolve:e,reject:t,promise:s}=ve();a=s,this._pendingRequests.set(n,{resolve:e,reject:t,timestamp:Date.now(),uplinkData:o,timeout:i,canResend:r})}t=this._isBinarySupported?ht(o).buffer:o;return null!=(s=this._socketAdapter)&&s.send(t),a}connect(){this._socketAdapter=new We(this._url),this._connectionEstablishedTime=0,this._addEventListeners(),this._connectionStartTime=Date.now();var e=null==(e=this._socketAdapter)?void 0:e.getId(),t=kt+`.connect isWorkerEnabled: false socketID:${e} url:`+this._url;this._connectionId=e,this._ssoLog({method:"connect",message:t})}disconnect(){var e=null==(e=this._socketAdapter)?void 0:e.getId(),e=kt+".disconnect socketID:"+e;this._ssoLog({method:"disconnect",message:e}),this._removeEventListeners(),null!=(e=this._socketAdapter)&&e.disconnect()}getSocketAdapter(){return this._socketAdapter}dispose(){console.log(kt+".dispose"),_t.removeTask(Ut),_t.removeTask(Gt),De.unSubscribeInnerEvent("networkStatusChange",this._handleNetworkStatusChange,this),De.unSubscribeInnerEvent("activityStatusChange",this._handleActivityStatusChange,this),this.disconnect(),this._socketAdapter=null,this._isReconnecting=!1,this._isHeartbeatInProgress=!1,this._pendingRequests.clear(),this._nextHeartbeatAt=0,this._lastDiagnoseAt=0,this._intendedDelay=Vt,this._url=""}registerBeforeSendInterceptor(e,t){this._beforeSendInterceptors.push(e.bind(t))}_executeBeforeSendInterceptors(e){for(var t of this._beforeSendInterceptors){var{servcmd:s=""}=null==e?void 0:e.head;t(s.includes(".")?s.split(".").pop():"")}}_shouldSkipReconnect(){var e=this._currentConnectState===Bt&&this._isReconnecting;return!this._socketAdapter||e}reconnect(){return de(this,void 0,void 0,function*(){var e=`${kt}.reconnect isReconnecting: ${this._isReconnecting} currentConnectState: `+this._currentConnectState;if(this._ssoLog({method:"reconnect",message:e}),!this._shouldSkipReconnect()){this._url=lt(this._isBinarySupported);try{this._isReconnecting=!0,this.disconnect(),this.connect()}catch(e){this._isReconnecting=!1,this._handleConnectStateChange({state:xt,shouldEmitEvent:!0,shouldAttemptReconnect:!0,reason:Yt}),console.warn(kt+".reconnect failed: ",e)}}})}_addEventListeners(){var e;null!=(e=this._socketAdapter)&&e.on("connect",this._onConnect,this),null!=(e=this._socketAdapter)&&e.on("message",this._onMessage,this),null!=(e=this._socketAdapter)&&e.on("close",this._onClose,this),null!=(e=this._socketAdapter)&&e.on("error",this._onError,this),null!=(e=this._socketAdapter)&&e.on("sendFail",this._onSendFail,this)}_removeEventListeners(){var e;null!=(e=this._socketAdapter)&&e.off("connect",this._onConnect,this),null!=(e=this._socketAdapter)&&e.off("message",this._onMessage,this),null!=(e=this._socketAdapter)&&e.off("close",this._onClose,this),null!=(e=this._socketAdapter)&&e.off("error",this._onError,this),null!=(e=this._socketAdapter)&&e.off("sendFail",this._onSendFail,this)}_onClose(e){var{socketId:e,event:t}=e||{},s=0!==this._connectionEstablishedTime?Date.now()-this._connectionEstablishedTime:0,s=`${kt}.onClose closeSocketID: ${e} currentSocketID: ${this._connectionId} connectionDuration: ${s} code: ${null==t?void 0:t.code} reason: `+(null==t?void 0:t.reason);this._ssoLog({method:"onClose",message:s}),e===this._connectionId&&this._handleConnectStateChange({state:xt,shouldEmitEvent:!0,shouldAttemptReconnect:!0,reason:Ht}),this._isReconnecting&&(this._isReconnecting=!1)}_onError(e){var{socketId:e,error:t}=e||{},t=`${kt}.onError sourceSocketID: ${e} currentSocketID: ${this._connectionId} isReconnecting: ${this._isReconnecting} error: `+JSON.stringify(t);this._ssoLog({method:"onError",message:t}),e===this._connectionId&&this._handleConnectStateChange({state:xt,shouldEmitEvent:!0,shouldAttemptReconnect:!0,reason:Kt}),this._isReconnecting&&(this._isReconnecting=!1)}_onSendFail(e){var{socketId:e,error:t}=e||{},e=`${kt}.onSendFail sendFailSocketId: ${e} currentSocketID: ${this._connectionId} isReconnecting: ${this._isReconnecting} error: `+t;this._ssoLog({method:"onSendFail",message:e}),this._isReconnecting&&(this._isReconnecting=!1)}_onMessage(t){let s,e;this._updateHeartbeatTime();try{s=this._isBinarySupported?(this._isCompressedData(t.data)?e=>{var t=new Uint8Array(e).slice(4);let s;try{s=Jt.inflate(t,{to:"string"})}catch(e){console.error("inflate error",e)}return s}:function(e){var i=new Uint8Array(e);let r="",o=0;for(var a=i["length"];o<a;){let t=i[o],s=0,n=0;if(t<=127?(s=0,n=255&t):t<=223?(s=1,n=31&t):t<=239?(s=2,n=15&t):t<=244&&(s=3,n=7&t),0<a-o-s)for(let e=0;e<s;e+=1)t=i[o+e+1],n=n<<6|63&t;else n=65533,s=a-o;r+=String.fromCodePoint(n),o+=s+1}return r})(t.data):t.data,e=JSON.parse(s)}catch(s){let e=t.data;return void this._ssoLog({method:"jsonParseError",message:e})}var n;e&&e.head&&({seq:t,servcmd:n}=e.head,this._pendingRequests.has(""+t+n)?this._handleRequestResponse(e):this._handlePushMessage(e))}_handleRequestResponse(e){var{seq:t,servcmd:s}=e.head,{int32_error_code:n,str_error_message:i}=(null==e?void 0:e.body)||{},r=(null==(r=null==e?void 0:e.body)?void 0:r.ErrorCode)||n,n=(null==(n=null==e?void 0:e.body)?void 0:n.ErrorInfo)||i,i=""+t+s,{resolve:t,reject:s}=this._pendingRequests.get(i);this._pendingRequests.delete(i),r&&0!==r?(De.emitInnerEvent("error",{errorCode:r,errorInfo:n}),s({errorCode:r,errorInfo:n})):t(e.body)}_handlePushMessage(e){var t=e.head["servcmd"],{NeedAck:s,SessionData:n}=e.body;1===s&&this._sendAck(n),De.emitInnerEvent(t,e)}_checkPendingRequestsAndResend(){var e;wt.debug("_checkPendingRequestsAndResend",` reConnectFlag:${this._isReconnecting} promiseMap.size:`+this._pendingRequests.size),null!=(e=this._pendingRequests)&&e.forEach((e,t)=>{var{uplinkData:s,canResend:n,resolve:i,reject:r,timeout:o}=e;if(n){this._pendingRequests.set(t,{resolve:i,reject:r,timestamp:Date.now(),uplinkData:s,timeout:o,canResend:n});let e=this._isBinarySupported?ht(s).buffer:s;null!=(i=this._socketAdapter)&&i.send(e)}else this._pendingRequests.delete(t)})}_onConnect(e){var{socketId:e,event:t={}}=e||{},s=(this._connectionId=e,this._connectionEstablishedTime=Date.now(),Date.now()-this._connectionStartTime),s=kt+`.onConnect cost:${s} ms. socketID:${e} res:`+JSON.stringify(t);if(this._ssoLog({method:"onConnect",message:s}),this._checkPendingRequestsAndResend(),this._sendHeartbeatIfReady(),this._isReconnecting){let e=kt+".reconnect success";this._ssoLog({method:"reconnectSuccess",message:e}),De.emitInnerEvent(Ot.RECONNECTED),this._isReconnecting=!1}this._resetReconnectDelay(),this._handleConnectStateChange({state:Ft,shouldEmitEvent:!0,shouldAttemptReconnect:!1})}_sendAck(e){e=Et({servcmd:"openim.ws_msg_push_ack",data:{SessionData:e}});this.sendPacket(e)}_executeScheduledTaskIfReady(){return de(this,void 0,void 0,function*(){this._clearTimeoutRequest(),this._sendHeartbeatIfReady()})}_canSendHeartbeat(){var e;return(null==(e=this._socketAdapter)?void 0:e.isConnected())&&Date.now()>=this._nextHeartbeatAt&&!this._isHeartbeatInProgress}_sendHeartbeat(){return de(this,void 0,void 0,function*(){var e,t=Et({servcmd:"heartbeat.alive",data:{}});try{let e=""+t.head.seq+t.head.servcmd;yield this.sendPacket(t,{requestId:e,timeout:3e3})}catch(t){var s=null==(e=qe.get("netWorkMonitor"))?void 0:e.isNetWorkOnline,s=kt+`.sendHeartbeat failed. isNetWorkOnline:${s} error: `+t;this._ssoLog({method:"sendHeartbeatError",message:s}),this._handleConnectStateChange({state:xt,shouldEmitEvent:!0,shouldAttemptReconnect:!0})}})}_sendHeartbeatIfReady(){return de(this,void 0,void 0,function*(){this._canSendHeartbeat()&&(this._isHeartbeatInProgress=!0,yield this._sendHeartbeat(),this._isHeartbeatInProgress=!1)})}_updateHeartbeatTime(){this._nextHeartbeatAt=b?Date.now()+5e3:Date.now()+1e4}_handleNetworkStatusChange(e){var t=kt+".networkStatusChange "+JSON.stringify(e),{isNetworkOnline:t,networkType:e}=(this._ssoLog({method:"networkStatusChange",message:t}),e);t&&"none"!==e?this._handleConnectStateChange({state:Ft,shouldEmitEvent:!1,shouldAttemptReconnect:!0,reason:$t}):this._handleConnectStateChange({state:xt,shouldEmitEvent:!1,shouldAttemptReconnect:!0,reason:$t})}isPrivateNetWork(){var e=qe.get("instance")||{};return e.proxyServer&&!e.fileDownloadProxy}_handleConnectStateChange(e){var{state:e,shouldAttemptReconnect:t,shouldEmitEvent:s,reason:n}=e,n=`${kt}._handleConnectStateChange currentConnectState: ${this._currentConnectState} shouldAttemptReconnect: ${t} shouldEmitEvent: ${s} reason: `+n;this._currentConnectState!==e&&(this._ssoLog({method:"handleConnectStateChange",message:n}),s&&(wt.info("_handleConnectStateChange",` from ${this._currentConnectState} to `+e),De.emitOuterEvent("netStateChange",{name:"netStateChange",data:{state:e}}),(this._currentConnectState=e)===xt)&&De.emitInnerEvent(Ot.SOCKET_DISCONNECTED),t)&&(this._resetReconnectDelay(),_t.addTask({id:Gt,intervalMs:this._intendedDelay,callback:this._scheduleReconnectWithBackoff,context:this}))}_handleActivityStatusChange(e){var t=null==(t=null==(t=this._socketAdapter)?void 0:t._ws)?void 0:t.readyState,e=`${kt}.activityStatusChange ${JSON.stringify(e)} readyState: `+t;this._ssoLog({method:"activityStatusChange",message:e}),3===t&&this._handleConnectStateChange({state:xt,shouldEmitEvent:!0,shouldAttemptReconnect:!0,reason:qt})}_resetReconnectDelay(){wt.debug(kt+"._resetReconnectDelay"),_t.removeTask(Gt);var e=null==(e=qe.get("activityMonitor"))?void 0:e.isActive;this._intendedDelay=e?Vt:1e3}_scheduleReconnectWithBackoff(){var e=null==(e=qe.get("activityMonitor"))?void 0:e.isActive,e=(this._intendedDelay=e?Math.min(5e3,Math.max(Vt,1.5*this._intendedDelay)):Math.min(3e5,Math.max(1e3,1.5*this._intendedDelay)),(new Date).toTimeString().slice(0,8)),e=kt+`.scheduleReconnectWithBackoff timeStr: ${e} intendedDelay: `+this._intendedDelay;wt.debug(e),this.reconnect(),_t.updateTaskInterval(Gt,this._intendedDelay)}_ssoLog(e){var{method:e,message:t}=e;wt.info(e,t)}_diagnose(){this.isPrivateNetWork()||(this._lastDiagnoseAt=Date.now(),function(t){de(this,void 0,void 0,function*(){var e=t.split("/")[2];if(e.startsWith("ws")){e=`https://${e}/v3/netcheck/getconninfo?${t.slice(t.indexOf("info?")+5)}&reqtime=`+Date.now();try{yield Ee({method:"GET",url:e,data:{}})}catch(e){wt.warn("diagnoseBySSO","diagnoseBySSO failed. error:"+e.message)}}})}(this._url),function(t){de(this,void 0,void 0,function*(){var e=`https://boce-cdn.my-imcloud.com/v3/netcheck/getconninfo?${t.slice(t.indexOf("info?")+5)}&reqtime=`+Date.now();try{yield Ee({method:"GET",url:e,data:{}})}catch(e){wt.warn("diagnoseByCDN', 'diagnoseByCDN failed. error:"+e.message)}})}(this._url),this._beforeSendInterceptors=[])}_clearTimeoutRequest(){for(var[e,t]of this._pendingRequests.entries()){var{reject:t,timestamp:s,timeout:n}=t;Date.now()-s>=n&&(this._pendingRequests.delete(e),3e4<=Date.now()-this._lastDiagnoseAt&&this._diagnose(),t({errorCode:he,errorInfo:"NETWORK_TIMEOUT",data:{requestId:e}}))}}_updateIsBinarySupported(){var e;(null!=(e=qe.get("instance"))&&e.devMode||(e=le(),D)||T&&"windows"===e||b)&&(this._isBinarySupported=!1)}_isCompressedData(e){e=new Uint8Array(e);return 67===e[0]&&79===e[1]&&77===e[2]&&80===e[3]}};let es={init:function(e){qe.set("instance",e),Qt.init()},destroy:function(){Qt.dispose(),qe.clear(),_t.dispose()},notificationCenter:De,channel:Qt,store:qe,ssoLog:wt,utils:Ce,common:Ct,constants:C},ts=e=>"function"==typeof e;function ss(t,s,n){let i=n||[];var e,r;return!(!t||!s)&&(e=Object.keys(t).filter(e=>!i.includes(e)),r=Object.keys(s).filter(e=>!i.includes(e)),e.length===r.length)&&e.every(e=>!!s.hasOwnProperty(e)&&("object"==typeof t[e]&&null!==t[e]?ss(t[e],s[e],n):t[e]===s[e]))}!function(e){e.SDK_READY="sdkStateReady",e.SDK_NOT_READY="sdkStateNotReady",e.SDK_DESTROY="sdkDestroy",e.MESSAGE_RECEIVED="onMessageReceived",e.ROOM_CUSTOM_DATA_RECEIVED="onRoomCustomDataReceived",e.MESSAGE_MODIFIED="onMessageModified",e.MESSAGE_REVOKED="onMessageRevoked",e.MESSAGE_READ_BY_PEER="onMessageReadByPeer",e.MESSAGE_READ_RECEIPT_RECEIVED="onMessageReadReceiptReceived",e.MESSAGE_EXTENSIONS_UPDATED="onMessageExtensionsUpdated",e.MESSAGE_EXTENSIONS_DELETED="onMessageExtensionsDeleted",e.MESSAGE_REACTIONS_UPDATED="onMessageReactionsUpdated",e.CONVERSATION_LIST_UPDATED="onConversationListUpdated",e.TOTAL_UNREAD_MESSAGE_COUNT_UPDATED="onTotalUnreadMessageCountUpdated",e.CONVERSATION_GROUP_LIST_UPDATED="onConversationGroupListUpdated",e.CONVERSATION_IN_GROUP_UPDATED="onConversationInGroupUpdated",e.GROUP_LIST_UPDATED="onGroupListUpdated",e.GROUP_ATTRIBUTES_UPDATED="groupAttributesUpdated",e.GROUP_COUNTER_UPDATED="onGroupCounterUpdated",e.TOPIC_CREATED="onTopicCreated",e.TOPIC_DELETED="onTopicDeleted",e.TOPIC_UPDATED="onTopicUpdated",e.PROFILE_UPDATED="onProfileUpdated",e.USER_STATUS_UPDATED="onUserStatusUpdated",e.BLACKLIST_UPDATED="blacklistUpdated",e.FRIEND_LIST_UPDATED="onFriendListUpdated",e.FRIEND_GROUP_LIST_UPDATED="onFriendGroupListUpdated",e.FRIEND_APPLICATION_LIST_UPDATED="onFriendApplicationListUpdated",e.MY_FOLLOWERS_LIST_UPDATED="onMyFollowersListUpdated",e.MY_FOLLOWING_LIST_UPDATED="onMyFollowingListUpdated",e.MUTUAL_FOLLOWERS_LIST_UPDATED="onMutualFollowersListUpdated",e.KICKED_OUT="kickedOut",e.ERROR="error",e.NET_STATE_CHANGE="netStateChange",e.ALL_RECEIVE_MESSAGE_OPT_UPDATED="onAllReceiveMessageOptUpdated",e.SERVER_CONFIG_UPDATED="onServerConfigUpdated",e.PINNED_GROUP_MESSAGE_UPDATED="onPinnedGroupMessageUpdated"}(ns=ns||{});var is,os=ns;!function(e){e.LOGOUT="logout",e.DESTROY="destroy",e.CLOUD_CONFIG_UPDATE="cloud_config_update",e.PROFILE_UPDATE="profile_updated",e.ERROR="error",e.RECONNECTED="reconnected",e.FORCE_OFFLINE="im_open_status.stat_forceoffline",e.COMMERCIAL_CONFIG_PUSH="im_sdk_config_mgr.push_imsdk_purchase_bitsv2",e.OVERLOAD_PUSH="OverLoadPush.notify2",e.NEW_MESSAGE="new_message",e.MESSAGE_PUSH="im_open_push.msg_push",e.MESSAGE_DELETED="message_deleted",e.MESSAGE_REVOKED="message_revoked",e.MESSAGE_MODIFIED="message_modified",e.SOCKET_DISCONNECTED="socket_disconnected",e.CONVERSATION_UPDATED="conversation_updated",e.TOPIC_MESSAGE_DELETED="topic_message_deleted",e.TOPIC_MESSAGE_REVOKED="topic_message_revoked",e.TOPIC_MESSAGE_MODIFIED="topic_message_modified",e.TOPIC_NEW_MESSAGE="topic_new_message",e.QUALITY_STAT="quality_stat",e.SYNC_CONVERSATION_LIST="sync_conversation_list"}(is=is||{});var rs,ds,hs,as=is,cs=(!function(e){e.NEW_INVITATION_RECEIVED="newInvitationReceived",e.INVITEE_ACCEPTED="ts_invitee_accepted",e.INVITEE_REJECTED="ts_invitee_rejected",e.INVITATION_CANCELLED="ts_invitation_cancelled",e.INVITATION_TIMEOUT="ts_invitation_timeout",e.INVITATION_MODIFIED="ts_invitation_modified"}(rs=rs||{}),rs);let ls=Object.assign({},{KICKED_OUT_MULT_ACCOUNT:"multipleAccount",KICKED_OUT_MULT_DEVICE:"multipleDevice",KICKED_OUT_USERSIG_EXPIRED:"userSigExpired",KICKED_OUT_REST_API:"REST_API_Kick"}),us={MSG_TEXT:"TIMTextElem",MSG_IMAGE:"TIMImageElem",MSG_AUDIO:"TIMSoundElem",MSG_FILE:"TIMFileElem",MSG_FACE:"TIMFaceElem",MSG_VIDEO:"TIMVideoFileElem",MSG_LOCATION:"TIMLocationElem",MSG_GRP_TIP:"TIMGroupTipElem",MSG_GRP_SYS_NOTICE:"TIMGroupSystemNoticeElem",MSG_CUSTOM:"TIMCustomElem",MSG_MERGER:"TIMRelayElem"},_s=(!function(e){e.UNSENT="unSend",e.SUCCESS="success",e.FAIL="fail"}(ds=ds||{}),{modify:as.MESSAGE_MODIFIED,delete:as.MESSAGE_DELETED,revoke:as.MESSAGE_REVOKED}),gs=(!function(e){e[e.FORWARD=0]="FORWARD",e[e.BACKWARD=1]="BACKWARD"}(hs=hs||{}),Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},us),{MSG_PRIORITY_HIGH:"High",MSG_PRIORITY_NORMAL:"Normal",MSG_PRIORITY_LOW:"Low",MSG_PRIORITY_LOWEST:"Lowest"}),{RECEIVE_WITH_OFFLINE_PUSH_EXCEPT_AT:"AcceptNotNotifyExceptAt",NOT_RECEIVE_OFFLINE_PUSH_EXCEPT_AT:"AcceptNotNotifyExceptAt",NOT_RECEIVE_MSG_EXCEPT_AT:"NotReceiveMsgExceptAt",MSG_AT_ALL:"__kImSDK_MesssageAtALL__"}),{MSG_REMIND_ACPT_AND_NOTE:"AcceptAndNotify",MSG_REMIND_ACPT_NOT_NOTE:"AcceptNotNotify",MSG_REMIND_DISCARD:"Discard"}),{MessageStatus:ds,Direction:hs})),ps={[_s.modify]:as.TOPIC_MESSAGE_MODIFIED,[_s.delete]:as.TOPIC_MESSAGE_DELETED,[_s.revoke]:as.TOPIC_MESSAGE_REVOKED},Es={GENDER_UNKNOWN:"Gender_Type_Unknown",GENDER_FEMALE:"Gender_Type_Female",GENDER_MALE:"Gender_Type_Male",USER_STATUS_UNKNOWN:0,USER_STATUS_ONLINE:1,USER_STATUS_OFFLINE:2,USER_STATUS_UNLOGINED:3,USER_NOT_FOUND:"@TLS#NOT_FOUND"},fs=Object.assign({},Es),ms={CONV_C2C:"C2C",CONV_GROUP:"GROUP",CONV_TOPIC:"TOPIC",CONV_SYSTEM:"@TIM#SYSTEM"},Ss=Object.assign(Object.assign(Object.assign(Object.assign({},ms),{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}),{READ_ALL_C2C_MSG:"readAllC2CMessage",READ_ALL_GROUP_MSG:"readAllGroupMessage",READ_ALL_MSG:"readAllMessage"}),vs=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},{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"}),{ALLOW_TYPE_ALLOW_ANY:"AllowType_Type_AllowAny",ALLOW_TYPE_NEED_CONFIRM:"AllowType_Type_NeedConfirm",ALLOW_TYPE_DENY_ANY:"AllowType_Type_DenyAny"}),{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"}),{FORBID_TYPE_NONE:"AdminForbid_Type_None",FORBID_TYPE_SEND_OUT:"AdminForbid_Type_SendOut"}),Is={GRP_WORK:"Private",GRP_PUBLIC:"Public",GRP_MEETING:"ChatRoom",GRP_AVCHATROOM:"AVChatRoom",GRP_COMMUNITY:"Community",GRP_ROOM:"Room",GRP_LIVE:"Live"},Cs={COMMUNITY:"@TGS#_",TOPIC:"@TOPIC#_"},Ms={JOINED:1,QUITTED:2,KICKED:3,ADMIN_SET:4,ADMIN_CANCELED:5,GROUP_PROFILE_UPDATED:6,GROUP_MEMBER_PROFILE_UPDATED:7,TOPIC_PROFILE_UPDATED:8},Ts=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},Is),{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}),{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"}),{GROUP_ID_PREFIX:Cs,GROUP_TIPS_OPERATION_TYPE:Ms}),ys=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},ls),gs),fs),Ss),vs),Ts),{IOS_OFFLINE_PUSH_NO_SOUND:"push.no_sound",IOS_OFFLINE_PUSH_DEFAULT_SOUND:"default"}),{NET_STATE_CONNECTING:"connecting",NET_STATE_DISCONNECTED:"disconnected"}),Os={NO_SDKAPPID:2e3,NO_TINYID:2022,NO_A2KEY:2023,USER_NOT_LOGGED_IN:2024,REPEAT_LOGIN:2025,MSG_SEND_FAIL:2100,MSG_SEND_FAIL_NOT_IN_AV:2101,MSG_SEND_GRP_WITH_TOPIC_FAIL:2115,MSG_INSTANCE_REQUIRED:2105,MSG_INVALID_CONV_TYPE:2106,MSG_REVOKE_FAIL:2110,MSG_DELETE_FAIL:2111,MSG_UNREAD_ALL_FAIL:2112,READ_RECEIPT_MSG_LIST_EMPTY:2114,CANNOT_DELETE_GRP_SYSTEM_NOTICE:2116,NOT_MY_FRIEND:2700,NETWORK_ERROR:2800,NETWORK_TIMEOUT:2801,NO_NETWORK:2805,UNCAUGHT_ERROR:2903,INVALID_OPERATION:2905,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,NO_USE:3122,OPTIONS_IS_EMPTY:3153,MSG_A2KEY_EXPIRED:20002,ACCOUNT_A2KEY_EXPIRED:70001,HELLO_ANSWER_KICKED_OUT:1002,OPEN_SERVICE_OVERLOAD_ERROR:60022},As={BASIC:"1",STANDARD:"2",PROFESSIONAL:"3"},Ns={SYNC_SERVER_INFO_AFTER_RE_ONLINE:"sync-server-info-after-re-online",SYNC_SERVER_INFO_AFTER_LOGIN:"sync-server-info-after-login",RECEIVE_C2C_NEW_MESSAGE:"receive-c2c-new-message",RECEIVE_GROUP_NEW_MESSAGE:"receive-group-new-message",RECEIVE_GROUP_TIPS_NOTIFICATION:"receive-group-tips-notification"},Rs={USER_STATUS_UPDATE:"user-status-update",CONVERSATION_RECOVER:"conversation-recover",HISTORY_MESSAGE_RECOVER:"history-message-recover",BLACKLIST_RECOVER:"blacklist-recover",FRIEND_RECOVER:"friend-recover",GROUP_ATTRIBUTE_CACHE_CLEAR:"group-attribute-cache-clear",UNREAD_MESSAGE_RECOVER:"unread-message-recover",HANDLE_NEW_MESSAGE:"handle-new-message",HANDLE_CONVERSATION_PROFILE_UPDATED:"handle-conversation-profile-updated",COMMERCIAL_CONFIG_UPDATE:"commercial-config-update",UNREAD_MESSAGE_SYNC:"unread-message-sync",FRIEND_AND_BLACKLIST_SYNC:"friend-and-blacklist-sync",SIGNALING_MESSAGE_RECOVER:"signaling-message-recover",GROUP_LIST_SYNC:"group-list-sync",CONVERSATION_LIST_SYNC:"conversation-list-sync",USER_PROFILE_SYNC:"user-profile-sync",CONVERSATION_UPDATE_AFTER_UNREAD_SYNC_FINISHED:"conversation-update-after-unread-sync-finished",CONVERSATION_UPDATE_AFTER_GROUP_LIST_SYNC_FINISHED:"conversation-update-after-group-list-sync-finished",HANDLE_C2C_NEW_MESSAGE:"handle-c2c-new-message",HANDLE_GROUP_NEW_MESSAGE:"handle-group-new-message",CREATE_OR_UPDATE_CONVERSATION_BY_RECEIVE_NEW_MESSAGE:"create-or-update-conversation-by-receive-new-message",HANDLE_GROUP_TIPS_FROM_SYNC_UNREAD:"handle-group-tips-from-sync-unread",HANDLE_C2C_REVOKED_MESSAGE_FROM_SYNC_UNREAD:"handle-c2c-revoked-message-from-sync-unread",GROUP_REVOKED_NOTICE_RECOVER:"group-revoked-notice-recover",CLOUD_CONFIG_SYNC:"cloud-config-sync",UPDATE_GROUP_NEXT_SEQUENCE:"update-group-next-sequence",EMIT_C2C_MESSAGE_EVENT:"emit-c2c-message-event",EMIT_GROUP_MESSAGE_EVENT:"emit-group-message-event",CONVERSATION_GROUP_LIST_SYNC:"conversation-group-list-sync",CONVERSATION_GROUP_UPDATE:"conversation-group-update",UPDATE_TOPIC_AFTER_UNREAD_SYNC_FINISHED:"update-topic-after-unread-sync-finished",UPDATE_TOPIC_BY_RECEIVE_NEW_MESSAGE:"update-topic-by-received-new-message",TOPIC_REQUEST_INFO_RESET:"topic-request-info-reset",QUALITY_REPORT:"quality-report",GROUP_TIPS_RECOVER:"group-tips-recover",HANDLE_GROUP_TIPS_NOTIFICATION:"handle-group-tips-notification"},Ds={[Ns.SYNC_SERVER_INFO_AFTER_RE_ONLINE]:[{stepId:Rs.USER_STATUS_UPDATE},{stepId:Rs.GROUP_ATTRIBUTE_CACHE_CLEAR},{stepId:Rs.UNREAD_MESSAGE_SYNC},{stepId:Rs.CONVERSATION_RECOVER},{stepId:Rs.HISTORY_MESSAGE_RECOVER,dependency:Rs.CONVERSATION_RECOVER},{stepId:Rs.BLACKLIST_RECOVER},{stepId:Rs.FRIEND_RECOVER},{stepId:Rs.GROUP_REVOKED_NOTICE_RECOVER,dependency:Rs.HISTORY_MESSAGE_RECOVER},{stepId:Rs.GROUP_TIPS_RECOVER,dependency:Rs.HISTORY_MESSAGE_RECOVER},{stepId:Rs.TOPIC_REQUEST_INFO_RESET},{stepId:Rs.HANDLE_C2C_REVOKED_MESSAGE_FROM_SYNC_UNREAD,dependency:Rs.UNREAD_MESSAGE_SYNC},{stepId:Rs.HANDLE_GROUP_TIPS_FROM_SYNC_UNREAD,dependency:Rs.UNREAD_MESSAGE_SYNC},{stepId:Rs.CONVERSATION_UPDATE_AFTER_UNREAD_SYNC_FINISHED,dependency:[Rs.UNREAD_MESSAGE_SYNC,Rs.CONVERSATION_RECOVER]},{stepId:Rs.EMIT_C2C_MESSAGE_EVENT,dependency:[Rs.UNREAD_MESSAGE_SYNC,Rs.CONVERSATION_UPDATE_AFTER_UNREAD_SYNC_FINISHED],skipIfDependencyMissing:!1}],[Ns.SYNC_SERVER_INFO_AFTER_LOGIN]:[{stepId:Rs.COMMERCIAL_CONFIG_UPDATE},{stepId:Rs.CLOUD_CONFIG_SYNC},{stepId:Rs.USER_PROFILE_SYNC},{stepId:Rs.UNREAD_MESSAGE_SYNC},{stepId:Rs.FRIEND_AND_BLACKLIST_SYNC},{stepId:Rs.GROUP_LIST_SYNC},{stepId:Rs.CONVERSATION_LIST_SYNC},{stepId:Rs.SIGNALING_MESSAGE_RECOVER,dependency:Rs.UNREAD_MESSAGE_SYNC},{stepId:Rs.UPDATE_TOPIC_AFTER_UNREAD_SYNC_FINISHED,dependency:[Rs.UNREAD_MESSAGE_SYNC]},{stepId:Rs.CONVERSATION_UPDATE_AFTER_UNREAD_SYNC_FINISHED,dependency:[Rs.UNREAD_MESSAGE_SYNC,Rs.CONVERSATION_LIST_SYNC]},{stepId:Rs.CONVERSATION_UPDATE_AFTER_GROUP_LIST_SYNC_FINISHED,dependency:[Rs.GROUP_LIST_SYNC,Rs.CONVERSATION_LIST_SYNC]},{stepId:Rs.CONVERSATION_GROUP_LIST_SYNC},{stepId:Rs.CONVERSATION_GROUP_UPDATE,dependency:[Rs.CONVERSATION_LIST_SYNC,Rs.CONVERSATION_GROUP_LIST_SYNC]},{stepId:Rs.QUALITY_REPORT}],[Ns.RECEIVE_C2C_NEW_MESSAGE]:[{stepId:Rs.HANDLE_C2C_NEW_MESSAGE},{stepId:Rs.UNREAD_MESSAGE_SYNC},{stepId:Rs.CREATE_OR_UPDATE_CONVERSATION_BY_RECEIVE_NEW_MESSAGE,dependency:Rs.HANDLE_C2C_NEW_MESSAGE},{stepId:Rs.EMIT_C2C_MESSAGE_EVENT,dependency:[Rs.HANDLE_C2C_NEW_MESSAGE,Rs.CREATE_OR_UPDATE_CONVERSATION_BY_RECEIVE_NEW_MESSAGE],skipIfDependencyMissing:!1},{stepId:Rs.CONVERSATION_UPDATE_AFTER_UNREAD_SYNC_FINISHED,dependency:[Rs.UNREAD_MESSAGE_SYNC]}],[Ns.RECEIVE_GROUP_NEW_MESSAGE]:[{stepId:Rs.HANDLE_GROUP_NEW_MESSAGE},{stepId:Rs.CREATE_OR_UPDATE_CONVERSATION_BY_RECEIVE_NEW_MESSAGE,dependency:Rs.HANDLE_GROUP_NEW_MESSAGE},{stepId:Rs.UPDATE_GROUP_NEXT_SEQUENCE,dependency:Rs.HANDLE_GROUP_NEW_MESSAGE},{stepId:Rs.UPDATE_TOPIC_BY_RECEIVE_NEW_MESSAGE,dependency:Rs.HANDLE_GROUP_NEW_MESSAGE},{stepId:Rs.EMIT_GROUP_MESSAGE_EVENT,dependency:[Rs.HANDLE_GROUP_NEW_MESSAGE,Rs.CREATE_OR_UPDATE_CONVERSATION_BY_RECEIVE_NEW_MESSAGE],skipIfDependencyMissing:!1}],[Ns.RECEIVE_GROUP_TIPS_NOTIFICATION]:[{stepId:Rs.HANDLE_GROUP_TIPS_NOTIFICATION},{stepId:Rs.CREATE_OR_UPDATE_CONVERSATION_BY_RECEIVE_NEW_MESSAGE,dependency:Rs.HANDLE_GROUP_TIPS_NOTIFICATION}]},Ps={MESSAGE_SEND_SUCCESS_RATE:"messageSendSuccessRate"},bs={TOTAL_COUNT:"sendMessageTotalCount",SUCCESS_COUNT:"sendMessageSuccessCount",FAILED_COUNT:"sendMessageFailedCount",SEND_COST:"sendMessageCost"},ws=["login","getMyProfile","getUserProfile","updateMyProfile","setSelfStatus","getUserStatus","subscribeUserStatus","unsubscribeUserStatus","modifyMessage","deleteGroupMember","dismissGroup","getGroupMemberList","getGroupOnlineMemberCount","joinGroup","markGroupMemberList","quitGroup","searchCloudMessages","searchCloudGroups","searchCloudGroupMembers","searchCloudUsers","getMyFollowingList","getMyFollowersList","getMutualFollowersList","followUser","unfollowUser","getUserFollowInfo","checkFollowType","getFriendProfile","addFriend","deleteFriend","updateFriend","checkFriend","setFriendApplicationRead","createFriendGroup","deleteFriendGroup","addToFriendGroup","removeFromFriendGroup","renameFriendGroup","changeGroupOwner","createGroup","dismissGroup","getGroupList","getGroupOnlineMemberCount","getGroupProfile","searchGroupByID","updateGroupProfile","handleGroupApplication","deleteGroupAttributes","getGroupAttributes","initGroupAttributes","setGroupAttributes","addGroupMember","deleteGroupMember","getGroupMemberList","getGroupMemberProfile","setGroupMemberMuteTime","setGroupMemberNameCard","setGroupMemberRole","deleteMessage","revokeMessage","setMessageExtensions","getMessageExtensions","deleteMessageExtensions","getMessageList","addMessageReaction","removeMessageReaction","clearHistoryMessage","invite","accept","cancel","reject","modifyInvitation","deleteConversation","pinConversation","setMessageRead","setAllMessageRead","getConversationList","getTotalUnreadMessageCount","renameConversationGroup","deleteConversationGroup","markConversation","setConversationCustomData","deleteConversationsFromGroup","addConversationsToGroup","createConversationGroup"];var ks,Us,Gs,Ls=Object.freeze({__proto__:null,ERROR_CODE:Os,InnerEvent:as,NEED_LOG_API:ws,OuterConstant:ys,OuterEvent:os,QUALITY_METRICS:Ps,SDK_EDITION:As,SDK_INFO:{VERSION:"1.7.3",APPID:537048168},SEND_MESSAGE_STAT:bs,SignalingEvent:cs,WORKFLOW_DEFINITIONS:Ds,WORKFLOW_NAME:Ns,WORKFLOW_STEP:Rs});!function(e){e[e.USER_INITIATED=0]="USER_INITIATED",e[e.KICKED_OUT=1]="KICKED_OUT"}(ks=ks||{}),function(e){e[e.multipleAccount=1]="multipleAccount",e[e.multipleDevice=2]="multipleDevice",e[e.restApi=3]="restApi"}(Us=Us||{}),function(e){e[e.multipleDevice=3002]="multipleDevice",e[e.multipleAccount=3003]="multipleAccount",e[e.usersigExpired=70001]="usersigExpired",e[e.restApi=20002]="restApi"}(Gs=Gs||{});let Fs={[Us.multipleAccount]:"multipleAccount",[Us.multipleDevice]:"multipleDevice",[Us.restApi]:"REST_API_Kick",[Gs.multipleAccount]:"multipleAccount",[Gs.multipleDevice]:"multipleDevice",[Gs.restApi]:"REST_API_Kick",[Gs.usersigExpired]:"userSigExpired"},Bs="login_online_presence_task",{ERROR:xs,DESTROY:Vs,FORCE_OFFLINE:$s}=as,{KICKED_OUT_MULT_ACCOUNT:qs,KICKED_OUT_MULT_DEVICE:Ws,KICKED_OUT_REST_API:Ys,ACCOUNT_A2KEY_EXPIRED:Ks,MSG_A2KEY_EXPIRED:Hs}=Os;class js{init(){var e=es["notificationCenter"];e.subscribeInnerEvent($s,this._handleForceOfflineFromServerPush,this),e.subscribeInnerEvent(xs,Hs,this._handleForceOfflineFromResponse,this),e.subscribeInnerEvent(xs,Ks,this._handleForceOfflineFromResponse,this),e.subscribeInnerEvent(xs,qs,this._handleForceOfflineFromResponse,this),e.subscribeInnerEvent(xs,Ws,this._handleForceOfflineFromResponse,this),e.subscribeInnerEvent(xs,Ys,this._handleForceOfflineFromResponse,this),e.subscribeInnerEvent(Vs,this._dispose,this)}_handleForceOfflineFromServerPush(e){var{EventArray:e=[]}=(null==e?void 0:e.body)||{};this._extractKickedOutMessages(e).forEach(e=>{var{KickType:e,NewInstInfo:t}=e["KickoutMsgNotify"];this._processKickedOutReasonInfo({kickedOutReasonCode:e,newInstanceInfo:t})})}_extractKickedOutMessages(e){return e.reduce((e,t)=>[...e,...t.C2cNotifyMsgArray||[]],[]).filter(e=>{return this._isKickedOut(null==(e=null==e?void 0:e.KickoutMsgNotify)?void 0:e.KickType)})}_handleForceOfflineFromResponse(e){e=e.errorCode;this._processKickedOutReasonInfo({kickedOutReasonCode:e})}_processKickedOutReasonInfo(n){return de(this,void 0,void 0,function*(){var e=n["kickedOutReasonCode"],{ssoLog:t,utils:{safeStringify:s}}=es;try{this._logKickedOutEvent(n),yield es.login.loginAction.logout(ks.KICKED_OUT)}catch(e){t.debug("_processKickedOutReasonInfo"," fail "+s(e))}finally{es.notificationCenter.emitOuterEvent(os.KICKED_OUT,{data:{type:Fs[e]},name:os.KICKED_OUT}),[Us.restApi,Ks,Hs].includes(e)&&es.channel.reconnect()}})}_logKickedOutEvent(e){var{kickedOutReasonCode:e,newInstanceInfo:t={}}=e,e=`type:${Fs[e]} newInstanceInfo: `+JSON.stringify(t);es.ssoLog.warn("kickedOut",e)}_isKickedOut(e){return[Us.multipleAccount,Us.multipleDevice,Us.restApi].includes(e)}_dispose(){var e=es["notificationCenter"];e.unSubscribeInnerEvent($s,this._handleForceOfflineFromServerPush,this),e.unSubscribeInnerEvent(xs,Ks,this._handleForceOfflineFromResponse,this),e.unSubscribeInnerEvent(xs,Hs,this._handleForceOfflineFromResponse,this),e.unSubscribeInnerEvent(xs,qs,this._handleForceOfflineFromResponse,this),e.unSubscribeInnerEvent(xs,Ws,this._handleForceOfflineFromResponse,this),e.unSubscribeInnerEvent(xs,Ys,this._handleForceOfflineFromResponse,this),e.unSubscribeInnerEvent(Vs,this._dispose,this)}}function zs(n){return de(this,void 0,void 0,function*(){let e="im_open_status.wslogin",t=es.common.generateProtocolData({servcmd:e,data:{State:"Online",is_web_uniapp:0,InstType:0,CustomInfo:n}}),s=""+t.head.seq+e,d=yield es.channel.sendPacket(t,{timeout:9e4,requestId:s});if(d){let{HelloInterval:e,InstId:t,TinyId:s,TimeStamp:n,CustomStatus:i,PurchaseBits:r,A2Key:o,RichMsgAuthKey:a,ErrorCode:l,ErrorInfo:c,ActionStatus:u}=d;return{helloInterval:e,instanceID:t,tinyID:s,timeStamp:n,customStatus:i,purchaseBits:r,a2Key:o,authKey:a,errorCode:l,errorInfo:c,actionStatus:u}}})}function Zs(t){var s;try{var n=qe.getStorage("errorMessage");if(!t||!n)return"";var i=(null==(s=JSON.parse(n))?void 0:s.errorMessage)||{},{isIntl:r=!1,code:o,replacement1:a="",replacement2:l=""}=t;if(!o)return"";var c=r?o+"_en":o+"_cn";let e=i[i[c]?c:o]||"";return e=e&&(a&&(e=e.replace("$replacement1",a)),l)?e.replace("$replacement2",l):e}catch(t){return console.warn("Error parsing stored error messages:",t),""}}class Xs extends Error{constructor(e){var{functionName:t="Unknown",code:s,message:n="",data:i="",moreMessage:r=""}=e;let o=n;s&&!n&&(o=Zs(e));n=(s?`${t} failed. error: {"message": ${o}, "code": ${s}}`:`${t} failed. error: {"message": ${o}}`)+" "+r;super(),this.code=s,this.errorCode=s,this.errorMessage=n,this.message=n,this.data=i}}function Js(e,t){if(e&&!0!==(null==(e=es.store.get("login"))?void 0:e.isLoggedIn))throw new Xs({code:Os.USER_NOT_LOGGED_IN,functionName:t})}function Qs(t,s,n){if(Array.isArray(t))for(let e=0;e<t.length;e++)en.call(this,Object.assign(Object.assign({},t[e]),{value:s[e],name:n}));else for(var e in t)en.call(this,Object.assign(Object.assign({},t[e]),{value:s[0][e],name:n,key:e}))}function en({required:e,rules:n,value:t,allowEmpty:i,name:r,key:o,customValidator:a}){if(void 0===t){if(e)throw new Xs({functionName:r,message:`[${r}] Missing required params: "${o}"`})}else{let s="";if(!n.some(e=>{return e===Object.prototype.toString.call(t).match(/^\[object (.*)\]$/)[1].toLowerCase()})){for(let t=0;t<n.length;t++){let e=n[t];e=e.replace(e[0],e[0].toUpperCase()),s+=e+"/"}let e=`[${o}] must be type of ${s=s.substring(0,s.length-1)}, received type: ${Reflect.apply(Object.prototype.toString,t,[]).replace(/^\[object\s(\w+)\]$/,"$1").toLowerCase()}.`;throw new Xs({functionName:r,message:e})}if(!1===i){if(Array.isArray(t)&&(0===t.length||"string"==typeof t[0]&&""===t[0].trim()))throw new Xs({functionName:r,message:o+" can not be empty."});if("string"==typeof t&&""===t.trim())throw new Xs({functionName:r,message:o+" can not be empty."})}if(a&&"function"==typeof a){let e=a(t);if(!0!==e)throw new Xs({functionName:r,message:`[${o}] custom validation failed: `+(e||"Invalid value")})}}}let tn=[],sn={},nn={};function on(e,t){var s;Js(sn[e],e),Qs(nn[e],t,e),s=e,tn.forEach(e=>{var{interceptor:e,context:t}=e;e.apply(t,[s])})}function rn(e,t){tn.push({interceptor:e,context:t})}function an(e){var{params:e,auth:t}=e;e&&"object"==typeof e&&Object.assign(nn,e),t&&"object"==typeof t&&Object.assign(sn,t)}function cn(e){return es.store.get("commercialConfig").get(e)}class ln{constructor(){this._handlers=new Map,this._activeWorkflows=new Map,this._stepStartTimes=new Map,this._logHandlers={start:(e,t)=>{var s=Date.now();t?(this._stepStartTimes.set(e+"-"+t,s),es.ssoLog.debug("_executeWorkflowStep",`[Workflow ${e}] Step ${t} started at `+new Date(s).toISOString())):(this._workflowStartTimes.set(e,s),es.ssoLog.debug("_executeWorkflowStep",`[Workflow ${e}] started at `+new Date(s).toISOString()))},success:(s,e)=>{var n=Date.now();if(e){var t=this._stepStartTimes.get(s+"-"+e),t=t?n-t:0;this._stepStartTimes.delete(s+"-"+e),es.ssoLog.debug("_executeWorkflowStep",`[Workflow ${s}] Step ${e} completed successfully at ${new Date(n).toISOString()} (${t}ms)`)}else{let e=this._workflowStartTimes.get(s),t=e?n-e:0;this._workflowStartTimes.delete(s),es.ssoLog.debug("_executeWorkflowStep",`[Workflow ${s}] completed successfully at ${new Date(n).toISOString()} (${t}ms)`)}},error:(s,e,n)=>{var{ssoLog:i,utils:{safeStringify:r}}=es,o=Date.now();if(e){var t=this._stepStartTimes.get(s+"-"+e),t=t?o-t:0;this._stepStartTimes.delete(s+"-"+e),i.error("_executeWorkflowStep",`[Workflow ${s}] Step ${e} failed at ${new Date(o).toISOString()} (${t}ms) `+r(n),{error:n})}else{let e=this._workflowStartTimes.get(s),t=e?o-e:0;this._workflowStartTimes.delete(s),i.error("_executeWorkflowStep",`[Workflow ${s}] failed at ${new Date(o).toISOString()} (${t}ms) `+r(n),{error:n})}}}}static getInstance(){return ln._instance||(ln._instance=new ln),ln._instance}static setInstance(e){ln._instance=e}init(){this._initializeWorkflows()}registerWorkflowStep(e,t,s,n){var i;this._handlers.has(e)?Ds[e].find(e=>e.stepId===t)?(i=this._handlers.get(e)).has(t)||i.set(t,n?s.bind(n):s):es.ssoLog.debug("registerWorkflowStep",`Step '${t}' not defined in workflow '${e}'`):es.ssoLog.debug("registerWorkflowStep",`Workflow '${e}' not defined in core`)}executeWorkflow(o,s){return de(this,void 0,void 0,function*(){if(this._validateWorkflow(o)){es.ssoLog.debug("executeWorkflow",`[Workflow ${o}] Started execution at `+(new Date).toISOString());let e=Ds[o],r={cancelled:!1};this._activeWorkflows.set(o,{cancelToken:r});try{let t=new Map,i=(e.forEach(e=>{t.set(e.stepId,e)}),{workflowName:o,pendingSteps:new Set(e.map(e=>e.stepId)),completedSteps:new Set,runningSteps:new Set,stepMap:t,stepResults:{},data:s,cancelToken:r});yield new Promise((t,s)=>{let n=()=>{r.cancelled?t():this._getExecutableSteps({pendingSteps:i.pendingSteps,completedSteps:i.completedSteps,stepMap:i.stepMap,workflowName:o}).filter(e=>!i.runningSteps.has(e)).forEach(e=>{i.completedSteps.has(e)||i.runningSteps.has(e)||this._executeWorkflowStep(e,i,{onComplete:()=>{0===i.pendingSteps.size?t():0===this._getExecutableSteps({pendingSteps:i.pendingSteps,completedSteps:i.completedSteps,stepMap:i.stepMap,workflowName:o}).filter(e=>!i.runningSteps.has(e)).length&&0===i.runningSteps.size&&(es.ssoLog.debug("executeWorkflow",`Workflow ${o} completed with some steps skipped due to dependency failures`),t())},onError:s,onStepComplete:n})})};n()}),es.ssoLog.debug("executeWorkflow",`[Workflow ${o}] Completed execution at `+(new Date).toISOString())}catch(e){es.ssoLog.error("executeWorkflow",`[Workflow ${o}] Failed execution at `+(new Date).toISOString(),{error:e})}finally{this._activeWorkflows.delete(o)}}})}_executeWorkflowStep(l,c,u){return de(this,void 0,void 0,function*(){let{workflowName:r,runningSteps:e,stepMap:n,stepResults:i,data:o}=c;e.add(l),this._logWorkflowExecution(r,l,"start");try{let e=n.get(l),s=null;null!=e&&e.dependency&&(t(e.dependency)?s=i[e.dependency]:Array.isArray(e.dependency)&&(s={},e.dependency.forEach(e=>{s[e]=i[e]})));var a=this._handlers.get(r).get(l);if(a){let e=yield Promise.resolve(a({data:o,result:s}));i[l]=e,this._logWorkflowExecution(r,l,"success")}c.completedSteps.add(l)}catch(e){let t=`[Workflow].${r}.`+l,{errorCode:s,errorInfo:n=t+" failed"}=e||{},i=new Xs({functionName:t,code:s,message:n});es.ssoLog.error(t,n,{error:i}),this._logWorkflowExecution(r,l,"error",e),u.onError(e)}finally{e.delete(l),c.pendingSteps.delete(l),u.onStepComplete(),u.onComplete()}})}reset(){this._cancelAllWorkflows()}destroy(){this.reset(),this._handlers.clear()}_initializeWorkflows(){Object.keys(Ds).forEach(e=>{this._handlers.has(e)||this._handlers.set(e,new Map)})}_cancelWorkFlow(e){var t=this._activeWorkflows.get(e);t&&(t=t["cancelToken"],t.cancelled=!0,this._activeWorkflows.delete(e))}_cancelAllWorkflows(){Object.keys(Ds).forEach(e=>{this._cancelWorkFlow(e)})}_validateWorkflow(e){return!!Ds[e]&&!!this._handlers.get(e)}_getExecutableSteps(e){let{pendingSteps:s,completedSteps:i,stepMap:r,workflowName:o}=e;return Array.from(s).filter(e=>{var{dependency:s,skipIfDependencyMissing:e=!0}=r.get(e)||{};if(!s)return!0;if(t(s))return this._isStepRegistered({workflowName:o,stepId:s})?i.has(s):!e;if(n(s)){if(0<s.filter(e=>!this._isStepRegistered({workflowName:o,stepId:e})).length&&e)return!1;for(let e of s)if(!i.has(e))return!1;return!0}return!1})}_isStepRegistered(e){var{workflowName:e,stepId:t}=e;return null==(e=this._handlers.get(e))?void 0:e.has(t)}_logWorkflowExecution(e,t,s,n){this._logHandlers[s](e,t)}}let un=new Map,dn=({type:e,groupID:t})=>e===ys.GRP_COMMUNITY||(""+t).startsWith(Cs.COMMUNITY)&&!(""+t).includes(Cs.TOPIC),_n=(e="")=>{e=e.startsWith("GROUP")?e.replace("GROUP",""):e;return e.startsWith(Cs.COMMUNITY)&&(""+e).includes(Cs.TOPIC)},hn="openim",gn="million_group_open_http_svc";function pn(s){return de(this,void 0,void 0,function*(){var{servcmd:e,data:t}=En(e=s.data)||fn(e)?function(e){let{servcmd:t,data:s}=e;var n,i,r;return fn(s)?({servcmd:e,data:n}=e,{GroupId:i=""}=n,[i]=(r=i).split(Cs.TOPIC),{servcmd:mn(e),data:Object.assign(Object.assign({},n),{GroupId:i,TopicId:r})}):{servcmd:t=En(s)?mn(t):t,data:s}}(s):s,t=es.common.generateProtocolData({servcmd:e,data:t}),e=""+t.head.seq+e;return es.channel.sendPacket(t,{requestId:e})})}function En(e){var{Type:e,GroupId:t,GroupIdList:s=[]}=e,t=t||s[0]||"";return dn({type:e,groupID:t})}function fn(e){var{GroupId:e=""}=e;return _n(e)}function mn(e){return e.includes(hn)?e:(e=e.split(".")[1],gn+"."+e)}function Sn(){var e;return null==(e=es.store.get("login"))?void 0:e.userId}let vn=e=>n(e)||i(e),In=(n,i,r,o)=>{if(!vn(n)||!vn(i))return 0;let a=0;var l,c=Object.keys(i);for(let t=0,s=c.length;t<s;t++)if(l=c[t],!(e(i[l])||r&&r.includes(l)))if(vn(n[l])&&vn(i[l]))a+=In(n[l],i[l],r,o);else{if(o&&o.includes(i[l]))continue;n[l]!==i[l]&&(n[l]=i[l],a+=1)}return a},Cn=(t,s)=>{if(e(s))return"";switch(t){case ys.MSG_TEXT:return s.text||"";case ys.MSG_IMAGE:return"[Image]";case ys.MSG_LOCATION:return"[Location]";case ys.MSG_AUDIO:return"[Voice]";case ys.MSG_VIDEO:return"[Video]";case ys.MSG_FILE:return"[File]";case ys.MSG_CUSTOM:return"[Custom Messages]";case ys.MSG_GRP_TIP:return"[Group Notification]";case ys.MSG_GRP_SYS_NOTICE:return"[Group System Message]";case ys.MSG_FACE:return"[Animated Sticker]";case ys.MSG_MERGER:return"[Chat Record]";default:return""}},Mn=[{cmd:"ws_get_user_status",interval:5,count:20},{cmd:"ws_status_subscribe",interval:5,count:20},{cmd:"ws_status_unsubscribe",interval:5,count:20},{cmd:"get_group_self_member_info",interval:5,count:20},{cmd:"modify_group_base_info",interval:1,count:8},{cmd:"get_pendency",interval:1,count:15},{cmd:"set_group_attr",interval:5,count:10},{cmd:"modify_group_attr",interval:5,count:10},{cmd:"delete_group_attr",interval:5,count:10},{cmd:"clear_group_attr",interval:5,count:10},{cmd:"get_group_attr",interval:5,count:20},{cmd:"update_group_counter",interval:5,count:20},{cmd:"get_group_counter",interval:5,count:20},{cmd:"get_topic",interval:1,count:10},{cmd:"read_all_unread_msg",interval:1,count:1},{cmd:"query",interval:5,count:20}],Tn="im_sdk_config_mgr.fetch_config",yn="im_sdk_config_mgr.push_configv2",On="cloud-config",An=2996,Nn=new class{init(e){this.core=e}};function Rn(s){return de(this,void 0,void 0,function*(){var e=(Nn.core.store.get("instance")||{})["sdkAppId"],e=Nn.core.helper.generateProtocolData({servcmd:Tn,data:{uint32_sdkappid:e,uint64_version:s}}),t=""+e.head.seq+Tn;return Nn.core.channel.sendPacket(e,{requestId:t})})}var Dn=new class{constructor(){this._core=null,this._expirationTime=0,this._version=0,this._isFetching=!1,this._cmdFrequencyLimitMap=new Map,this._methodCallFrequencyMap=new Map}install(e){var{notificationCenter:e,InnerEvent:t,helper:s,constants:{WORKFLOW_NAME:n,WORKFLOW_STEP:i},channel:r}=this._core=e;e.subscribeInnerEvent(yn,this._handlePushedConfig,this),s.registerWorkflowStep(n.SYNC_SERVER_INFO_AFTER_LOGIN,i.CLOUD_CONFIG_SYNC,this._handleLoginSuccess,this),e.subscribeInnerEvent(t.LOGOUT,this._reset,this),e.subscribeInnerEvent(t.DESTROY,this._dispose,this),s.registerExperimentalAPI("getServerConfig",this),this._updateCmdFreqLimitMap(Mn),r.registerBeforeSendInterceptor(this.checkMethodCallOverLimit,this)}getServerConfig(s){return de(this,void 0,void 0,function*(){var e,t={code:0,data:""};return s&&(t.data=(null==(e=this._core.store.get("cloudConfig"))?void 0:e[s])||""),t})}checkMethodCallOverLimit(e){if(this._cmdFrequencyLimitMap.has(e))if(this._methodCallFrequencyMap.has(e)){var{count:t,interval:s}=this._cmdFrequencyLimitMap.get(e),{startTime:n,methodCallCounter:i}=this._methodCallFrequencyMap.get(e);if(Date.now()-n>1e3*s)this._methodCallFrequencyMap.set(e,{startTime:Date.now(),methodCallCounter:1});else if(this._methodCallFrequencyMap.set(e,{startTime:n,methodCallCounter:i+=1}),t<i)throw new this._core.helper.ChatError({code:An,replacement1:e})}else this._methodCallFrequencyMap.set(e,{startTime:Date.now(),methodCallCounter:1})}_handlePushedConfig(s){return de(this,void 0,void 0,function*(){var{ssoLog:e,utils:{safeStringify:t}}=this._core;e.info("_handlePushedConfig",t(s)),yield this._updateCloudConfig(s)})}_handleLoginSuccess(){return de(this,void 0,void 0,function*(){var e,{ssoLog:t,utils:{safeStringify:s}}=this._core;try{this._canFetch()&&(e=yield Rn(this._version),t.info("_fetchCloudConfigIfLogin",s(e)),yield this._updateCloudConfig(e)),this._core.helper.taskScheduler.addTask({id:On,intervalMs:1e3,callback:this._fetchCloudConfigIfReady,context:this})}catch(e){t.error("_fetchCloudConfigIfLogin",s(e))}})}_fetchCloudConfigIfReady(){return de(this,void 0,void 0,function*(){var{ssoLog:t,utils:{safeStringify:s}}=this._core;if(this._canFetch())try{var e=yield Rn(this._version);t.info("_fetchCloudConfigIfReady",s(e)),yield this._updateCloudConfig(e)}catch(e){t.error("_fetchCloudConfigIfReady",s(e))}})}_updateCloudConfig(t){return de(this,void 0,void 0,function*(){var e=this._parseCloudConfig(t);e&&(this._core.store.set("cloudConfig",e),yield this._parseCmdFreqLimit(),this._core.notificationCenter.emitInnerEvent(this._core.InnerEvent.CLOUD_CONFIG_UPDATE,e),this._core.notificationCenter.emitOuterEvent(this._core.OuterEvent.SERVER_CONFIG_UPDATED,{name:this._core.OuterEvent.SERVER_CONFIG_UPDATED,data:{config:e}}))})}_canFetch(){var e=(this._core.store.get("login")||{})["isLoggedIn"];return e&&!this._isFetching&&Date.now()>=this._expirationTime}_parseCloudConfig(e){var{int32_error_code:t,str_json_config:s,uint32_expired_time:n,uint64_version:i}=e;let r=null;if(0===t){if(this._version!==i)try{r=JSON.parse(s),this._version=i}catch(e){}this._expirationTime=Date.now()+1e3*n}else this._expirationTime=void 0===t?Date.now()+36e5:Date.now()+12e4;return r}_parseCmdFreqLimit(){return de(this,void 0,void 0,function*(){var e,t=null==(e=yield this.getServerConfig("cmd_frequency_limit"))?void 0:e.data,s=this._core.utils["isEmpty"];if(!s(t))try{t=JSON.parse(t),this._updateCmdFreqLimitMap(t)}catch(e){console.warn(e)}})}_updateCmdFreqLimitMap(e){e.forEach(e=>{this._cmdFrequencyLimitMap.set(e.cmd,{interval:e.interval,count:e.count})})}_reset(){this._core.helper.taskScheduler.removeTask(On),this._core.store.clear("cloudConfig"),this._updateCmdFreqLimitMap(Mn),this._methodCallFrequencyMap.clear(),this._expirationTime=0,this._version=0,this._isFetching=!1}_dispose(){var{notificationCenter:e,InnerEvent:t}=this._core;e.unSubscribeInnerEvent(yn,this._handlePushedConfig,this),e.unSubscribeInnerEvent(t.LOGOUT,this._reset,this),e.unSubscribeInnerEvent(t.DESTROY,this._dispose,this),this._reset()}};class Pn{constructor(e=0,t=0){this.high=e,this.low=t}equal(e){return null!==e&&this.low===e.low&&this.high===e.high}toString(){var e=Number(this.high).toString(16);let t=Number(this.low).toString(16);if(t.length<8){let e=8-t.length;for(;e;)t="0"+t,e--}return e+t}}let bn={SEARCH_GRP_SNS:new Pn(0,Math.pow(2,1)).toString(),AV_HISTORY_MSG:new Pn(0,Math.pow(2,2)).toString(),GRP_COMMUNITY:new Pn(0,Math.pow(2,3)).toString(),MSG_TO_SPECIFIED_GRP_MBR:new Pn(0,Math.pow(2,4)).toString(),AV_MBR_LIST:new Pn(0,Math.pow(2,6)).toString(),USER_STATUS:new Pn(0,Math.pow(2,7)).toString(),CONV_MARK:new Pn(0,Math.pow(2,9)).toString(),CONV_GROUP:new Pn(0,Math.pow(2,10)).toString(),AV_BAN_MBR:new Pn(0,Math.pow(2,11)).toString(),MSG_EXT:new Pn(0,Math.pow(2,13)).toString(),GRP_COUNTER:new Pn(0,Math.pow(2,15)).toString(),PLUGIN_TRANSLATE:new Pn(Math.pow(2,6)).toString(),PLUGIN_VOICE_TO_TEXT:new Pn(Math.pow(2,7)).toString(),PLUGIN_CS:new Pn(Math.pow(2,8)).toString(),PLUGIN_PUSH:new Pn(Math.pow(2,9)).toString(),PLUGIN_BOT:new Pn(Math.pow(2,10)).toString(),MSG_REACTION:new Pn(Math.pow(2,16)).toString(),FOLLOW:new Pn(Math.pow(2,20)).toString()},wn="CommercialConfig",Ln="commercial-config";var xn,Vn,kn=new class{constructor(){this._core=null,this._expirationTime=0,this._isFetching=!1,this._featureMap=new Map,this._methodKeyMap=new Map,this._purchaseBits="0"}install(e){var{helper:t,notificationCenter:s,constants:{WORKFLOW_NAME:n,WORKFLOW_STEP:i,InnerEvent:r}}=this._core=e;s.subscribeInnerEvent(r.COMMERCIAL_CONFIG_PUSH,this._handlePushedConfig,this),s.subscribeInnerEvent(r.LOGOUT,this._handleLogout,this),s.subscribeInnerEvent(r.DESTROY,this._dispose,this),t.registerWorkflowStep(n.SYNC_SERVER_INFO_AFTER_LOGIN,i.COMMERCIAL_CONFIG_UPDATE,this._syncCommercialConfig,this),e.helper.registerExperimentalAPI("isCommercialAbilityEnabled",this),e.helper.registerExperimentalAPI("queryCommercialAbility",this)}isCommercialAbilityEnabled(e){return de(this,void 0,void 0,function*(){var s=parseInt(e,10).toString(2),n=s["length"];let i,r=!0;for(let e=n-1,t=0;0<=e;e--,t++)if("1"===s.charAt(e)&&(i=(t<32?new Pn(0,2**t):new Pn(2**(t-32),0)).toString(),!this._featureMap.get(i))){r=!1;break}return this._core.ssoLog.debug("isFeatureEnabled",`${wn}.isFeatureEnabled decimalNumber:${e} key:${i} ret:`+r),{code:0,data:{enabled:r}}})}queryCommercialAbility(){return this._purchaseBits}_fetchAndParseCommercialConfig(){return de(this,void 0,void 0,function*(){let s,{ssoLog:e,helper:n,utils:{safeStringify:t}}=this._core;try{this._isFetching=!0;let e=n.generateProtocolData({servcmd:"im_sdk_config_mgr.fetch_imsdk_purchase_bitsv2",data:{uint32_sdkappid:null==(s=this._core.store.get("instance"))?void 0:s.sdkAppId}}),t=yield this._core.channel.sendPacket(e);null!=t&&t.body&&(this._parseCommercialConfig(t.body),this._core.store.set("commercialConfig",this._methodKeyMap))}catch(s){e.error("_fetchAndParseCommercialConfig",t(s))}finally{this._isFetching=!1}})}_syncCommercialConfig(t){return de(this,void 0,void 0,function*(){var e=((null==t?void 0:t.data)||{})["purchaseBits"];e&&(this._parsePurchaseBits(e),this._core.store.set("commercialConfig",this._methodKeyMap)),this._canFetch()&&(yield this._fetchAndParseCommercialConfig()),this._core.helper.taskScheduler.addTask({id:Ln,intervalMs:1e3,callback:this._fetchCommercialConfigIfReady,context:this})})}_canFetch(){var e=null==(e=this._core.store.get("login"))?void 0:e.isLoggedIn,t=Date.now()>=this._expirationTime;return e&&!this._isFetching&&t}_handlePushedConfig(e){null!=e&&e.body&&(this._parseCommercialConfig(e.body),this._core.store.set("commercialConfig",this._methodKeyMap))}_fetchCommercialConfigIfReady(){return de(this,void 0,void 0,function*(){this._canFetch()&&(yield this._fetchAndParseCommercialConfig())})}_parseCommercialConfig(e){var t,s,n,i,r=this._core["ssoLog"];"object"==typeof e&&({int32_error_code:t,str_error_message:s,str_purchase_bits:n,uint32_expired_time:i}=e,0===t?(this._parsePurchaseBits(n),this._expirationTime=Date.now()+1e3*i):void 0===t?(r.warn("_parseCommercialConfig",wn+"._parseCommercialConfig failed. Invalid message format:",e),this._expirationTime=Date.now()+36e5):(r.warn("_parseCommercialConfig",wn+`._parseCommercialConfig errorCode:${t} errorMessage:`+s),this._expirationTime=Date.now()+12e4))}_isValidPurchaseBits(e){return e&&"string"==typeof e&&1<=e.length&&e.length<=64&&/[01]{1,64}/.test(e)}_parsePurchaseBits(s){var{ssoLog:e,utils:{safeStringify:t}}=this._core;if(this._isValidPurchaseBits(s)){this._purchaseBits=s,this._featureMap.clear(),this._methodKeyMap.clear();var n;for(let e=s.length-1,t=0;0<=e;e--,t++)if(n=(t<32?new Pn(0,2**t):new Pn(2**(t-32),0)).toString(),"1"===s[e]){this._featureMap.set(n,!0);let e=this._getKeyByValue(bn,n);e&&this._methodKeyMap.set(e,!0)}else{this._featureMap.set(n,!1);let e=this._getKeyByValue(bn,n);e&&this._methodKeyMap.set(e,!1)}}else e.warn("_parsePurchaseBits",wn+".parsePurchaseBits invalid purchases:"+t(s))}_getKeyByValue(e,t){e=Object.entries(e).find(([,e])=>e===t);return e?e[0]:void 0}_handleLogout(){this._reset()}_dispose(){this._reset(),this._core.notificationCenter.unSubscribeInnerEvent(this._core.InnerEvent.COMMERCIAL_CONFIG_PUSH,this._handlePushedConfig,this),this._core.notificationCenter.unSubscribeInnerEvent(this._core.InnerEvent.LOGOUT,this._reset,this),this._core.notificationCenter.unSubscribeInnerEvent(this._core.InnerEvent.DESTROY,this._dispose,this)}_reset(){this._core.helper.taskScheduler.removeTask(Ln),this._core.store.set("commercialConfig",{}),this._expirationTime=0,this._isFetching=!1,this._featureMap.clear(),this._purchaseBits="0"}},Un=new class{constructor(){this._core=null,this._serverOverloadInfoMap=new Map}install(e){this._core=e;var{notificationCenter:e,InnerEvent:t,channel:s}=this._core;e.subscribeInnerEvent(t.OVERLOAD_PUSH,this._handleOverLoadPush,this),e.subscribeInnerEvent(t.LOGOUT,this._reset,this),e.subscribeInnerEvent(t.DESTROY,this._dispose,this),s.registerBeforeSendInterceptor(this.checkServerOverload,this)}checkServerOverload(e){if(this._serverOverloadInfoMap.has(e)){var{overloadStartTimestamp:t,delaySeconds:s}=this._serverOverloadInfoMap.get(e);if(Date.now()-t<=1e3*s)throw new this._core.helper.ChatError({functionName:e,message:"service is busy, please try again later"});this._serverOverloadInfoMap.delete(e)}}_handleOverLoadPush(e){var{OverLoadServCmd:e,DelaySecs:t}=e;this._serverOverloadInfoMap.set(e,{overloadStartTimestamp:Date.now(),delaySeconds:t})}_reset(){this._serverOverloadInfoMap.clear()}_dispose(){this._reset();var{notificationCenter:e,InnerEvent:t}=this._core;e.unSubscribeInnerEvent(t.OVERLOAD_PUSH,this._handleOverLoadPush,this),e.unSubscribeInnerEvent(t.LOGOUT,this._reset,this),e.unSubscribeInnerEvent(t.DESTROY,this._dispose,this)}},Gn=new class{constructor(){this.name="ConfigCenter"}install(e){Nn.init(e),Dn.install(e),kn.install(e),Un.install(e)}},Fn=new class{constructor(){this.name="ErrorMessage",this._core=null}install(e){return de(this,void 0,void 0,function*(){if(this._core=e,this._canFetch()){let e=yield this._fetchErrorMessage();var t;e&&(t=this._parseResponse(e),this._saveErrorMessage(t))}})}_canFetch(){var e=this._core.store.getStorage("errorMessage");return!e||this._isExpired(e)}_saveErrorMessage(e){this._core.store.setStorage("errorMessage",{errorMessage:e,errorMessageSavedTime:(new Date).getTime()})}_fetchErrorMessage(){return de(this,void 0,void 0,function*(){try{return yield this._core.helper.httpRequest({method:"GET",url:"https://web.sdk.qcloud.com/im/download/error-message/v3/0.0.6/tim-error-message.txt"})}catch(e){console.error(e)}})}_isExpired(e){return!e||(e=e["errorMessageSavedTime"],e&&6048e5<=(new Date).getTime()-e)}_parseResponse(e){if("string"==typeof e){var s=e.split(";\n"),n={},i=new RegExp(/'/g);for(let t=0;t<s.length;t++){var r=s[t].indexOf(":"),o=s[t].slice(0,r);let e=s[t].slice(r+1);o.startsWith("//")||""!==e&&(e=e.replace(i,""),n[o]=e)}return n}}};function Bn(i,l){return de(this,void 0,void 0,function*(){let{cookie:e,syncFlag:t,syncTriggerEvent:s}=i,n="openim.getmsg",o=l.helper.generateProtocolData({servcmd:n,data:{Cookie:e,SyncFlag:t,IsOnlineSync:s,NeedAbstract:1,NeedSignaling:1,NeedCachedMsg:1}}),a=""+o.head.seq+n;try{let e=yield l.channel.sendPacket(o,{requestId:a});if(!e)return null;let{C2CPairUnreadCount:t,C2CRemainingUnreadCount:s,EventArray:n}=e,{unreadMessageList:i,revokedMessageList:r}=function(e,v){let n=[],i=[];return null!=e&&e.forEach(S=>{var e,t,s=function(){var{From_Account:e,From_AccountHeadurl:t,From_AccountNick:s,IsNeedReadReceipt:n,MsgBody:i,MsgClientTime:r,MsgRandom:o,MsgSeq:a,MsgTimeStamp:l,SendMsgControl:c,SupportMessageExtension:u,To_Account:d,TinyId:_,MsgCheckResult:h,CloudCustomData:g,IsPeerRead:p,MsgFlagBits:E,MsgVersion:m,EventArray:f}=S;return{from:e,avatar:t,nick:s,needReadReceipt:1===n,readReceiptSentByPeer:p,clientTime:r,messageFlagBits:E,random:o,sequence:a,time:l,messageControlInfo:c,isSupportExtension:u,to:d,tinyID:_,checkResult:h,cloudCustomData:g,messageVersion:m,eventArray:f,elements:v.message.messageHelper.parseServerPushMessageElement(i)}}();if(null!=(t=null==(e=null==(e=null==S?void 0:S.EventArray)?void 0:e[0])?void 0:e.hasOwnProperty)&&t.call(e,"C2cNotifyMsgArray"))i.push(...function(){let e,t=[];return null!=(e=S.EventArray)&&e.forEach(e=>{var e=e["C2cNotifyMsgArray"],e=null==(e=null==(e=null==e?void 0:e[0])?void 0:e.WithdrawC2cMsgNotify)?void 0:e.C2cWithdrawInfoArray;Array.isArray(e)&&t.push(...e)}),t}());else{let e=v.message.messageFactory.createMessage(Object.assign(Object.assign({},s),{conversationType:"C2C",flow:"in"})),t=s["elements"];e.setElement(t),n.push(e)}}),{unreadMessageList:n,revokedMessageList:i}}(e.MsgList,l);return{syncFlag:null==e?void 0:e.SyncFlag,unreadMessageList:i,revokedMessageList:r,unreadCountList:t,overflowUnreadCountList:s,cookie:null==e?void 0:e.Cookie,groupTipList:n}}catch(e){console.warn(e)}})}!function(e){e[e.START_SYNC=0]="START_SYNC",e[e.SYNCING=1]="SYNCING",e[e.SYNC_COMPLETE=2]="SYNC_COMPLETE"}(xn=xn||{}),function(e){e[e.LOGIN_SUCCESS=0]="LOGIN_SUCCESS",e[e.NEW_MESSAGE_RECEIVED=1]="NEW_MESSAGE_RECEIVED"}(Vn=Vn||{});var $n=new class{constructor(){this.name="UnreadMessageSynchronizer",this._unreadDBMessageMap=new Map,this._cookie=""}install(e){var t=(this._core=e)["constants"];e.helper.registerWorkflowStep(t.WORKFLOW_NAME.SYNC_SERVER_INFO_AFTER_RE_ONLINE,t.WORKFLOW_STEP.UNREAD_MESSAGE_SYNC,this._syncUnreadDBMessageAfterReOnline,this),e.helper.registerWorkflowStep(t.WORKFLOW_NAME.RECEIVE_C2C_NEW_MESSAGE,t.WORKFLOW_STEP.UNREAD_MESSAGE_SYNC,this._syncUnreadDBMessageAfterNewMessageReceived,this),e.helper.registerWorkflowStep(t.WORKFLOW_NAME.SYNC_SERVER_INFO_AFTER_LOGIN,t.WORKFLOW_STEP.UNREAD_MESSAGE_SYNC,this._syncUnreadDBMessageAfterLogin,this),e.notificationCenter.subscribeInnerEvent(e.InnerEvent.LOGOUT,this._reset,this),e.notificationCenter.subscribeInnerEvent(e.InnerEvent.DESTROY,this._dispose,this)}_syncUnreadMessage(t){return de(this,void 0,void 0,function*(){let{isAfterReOnline:o=!1,isAfterNewMessageReceived:a=!1,isAfterLogin:e=!1}=t||{},l=xn.START_SYNC;for(var c=[],u=[],d=[],_=[];this._canContinueSync({cookie:this._cookie,syncFlag:l});){let e=yield this._fetchUnreadDBMessage({cookie:this._cookie,syncFlag:l,syncTriggerEvent:a?Vn.NEW_MESSAGE_RECEIVED:Vn.LOGIN_SUCCESS});if(!e)break;let{unreadMessageList:t=[],revokedMessageList:s=[],overflowUnreadCountList:n,unreadCountList:i,groupTipList:r}=e;if(this._cookie=(null==e?void 0:e.cookie)||"",l=null==e?void 0:e.syncFlag,this._parseAndSaveUnreadMessageList(t),d.push(...s),this._updateConversationUnreadOptions({unreadCountList:i,overflowUnreadCountList:n,conversationUpdateFieldList:c}),Array.isArray(r)&&u.push(...r),o){let e=this._handleNewMessageList(t)["messages"];_.push(...e)}}return o?{conversationUpdateFieldList:c,revokedMessageList:d,unreadMessageMap:this._unreadDBMessageMap,groupTipList:u,messages:_}:{conversationUpdateFieldList:c,isInstantMessage:!e,isUnreadC2CMessage:!0,revokedMessageList:d,unreadMessageMap:this._unreadDBMessageMap,groupTipList:u}})}_syncUnreadDBMessageAfterLogin(){return de(this,void 0,void 0,function*(){return this._cookie="",this._syncUnreadMessage({isAfterLogin:!0})})}_syncUnreadDBMessageAfterNewMessageReceived(e){return de(this,void 0,void 0,function*(){if(1===e.data.Flag)return this._syncUnreadMessage({isAfterNewMessageReceived:!0})})}_updateConversationUnreadOptions(e){let{unreadCountList:t,overflowUnreadCountList:s,conversationUpdateFieldList:n}=e,{OuterConstant:{CONV_C2C:i,CONV_SYSTEM:r}}=this._core["constants"];null!=t&&t.forEach(e=>{let{From_Account:t,UnreadCount:s}=e;if(t!==r){let e=n.find(({conversationID:e})=>e===""+i+t);e?e.unreadCount=s:n.push({conversationID:""+i+t,unreadCount:s,type:i})}}),null!=s&&s.forEach(e=>{let{From_Account:t,LastMsgTime:s}=e;t===r||n.find(({conversationID:e})=>e===""+i+t)||n.push({conversationID:""+i+t,type:i,lastMsgTime:s})})}_syncUnreadDBMessageAfterReOnline(){return de(this,void 0,void 0,function*(){return this._syncUnreadMessage({isAfterReOnline:!0})})}_updateMessageProfile(n){var e;let i=(this._core.message||{})["messageDataHandler"],t=null==(e=this._core.store.get("login"))?void 0:e.userId,{from:s,nick:r,avatar:o,conversationID:a=""}=n;if(s!==t){let s=i.getLatestMsgSentByPeer(a);if(s){let{nick:e,avatar:t}=s;r&&o?r===e&&o===t||i.updateNickAndAvatarOfSentMessage({conversationID:a,latestNick:r,latestAvatar:o,isSentByMe:!1}):(n.nick=e,n.avatar=t)}}else{let e=i.getLatestMsgSentByMe(a);!e||r===e.nick&&o===e.avatar||i.updateNickAndAvatarOfSentMessage({conversationID:a,latestNick:r,latestAvatar:o,isSentByMe:!0})}}_handleNewMessageList(e){let t=(this._core.message||{})["messageDataHandler"],l=new Map,s=[];return e.forEach(a=>{this._updateMessageProfile(a);let e=1===a.isModified;if(t.isMessageSentByCurrentInstance(a)?a.isModified=e:e=!1,a.isOnlineMessage())a._onlineOnlyFlag=!0,t.isMessageSentByCurrentInstance(a)||s.push(a);else if(!t.isInMessageList(a)){if(t.storeConversationMessage(a)){let{conversationID:e,conversationType:t,conversationSubType:s,flow:n,_isExcludedFromUnreadCount:i,_isExcludedFromLastMessage:r}=a,o=r?"":a;l.has(e)?(l.get(e).lastMessage=o,"in"!==n||i||l.get(e).unreadCount++):l.set(e,{conversationID:e,type:t,subType:s,unreadCount:i||"in"!==n?0:1,lastMessage:o})}t.isMessageSentByCurrentInstance(a)&&!e||s.push(a)}}),{messages:s,conversationOptions:l}}_fetchUnreadDBMessage(u){return de(this,void 0,void 0,function*(){var{ssoLog:e,utils:{safeStringify:t}}=this._core;try{e.debug("_fetchUnreadDBMessage","unread-message-synchronizer._fetchUnreadDBMessage options:"+t(u));var s,n,i,r,o,a,l,c=yield Bn(u,this._core);return c?({syncFlag:s,unreadMessageList:n,revokedMessageList:i,cookie:r,unreadCountList:o,overflowUnreadCountList:a,groupTipList:l}=c,this._parseAndSaveUnreadMessageList(n),{syncFlag:s,cookie:r,unreadMessageList:n,revokedMessageList:i,unreadCountList:o,overflowUnreadCountList:a,groupTipList:l}):null}catch(e){console.log(e)}})}_canContinueSync({cookie:e,syncFlag:t}){return t===xn.START_SYNC||t===xn.SYNCING&&!(null!=(t=this._core)&&t.helper.isEmpty(e))}_parseAndSaveUnreadMessageList(e){e.forEach(e=>{var t=e["ID"];this._unreadDBMessageMap.set(t,e)})}_reset(){this._cookie="",this._unreadDBMessageMap.clear()}_dispose(){var e;null!=(e=this._core)&&e.notificationCenter.unSubscribeInnerEvent(this._core.InnerEvent.LOGOUT,this._reset,this),null!=(e=this._core)&&e.notificationCenter.unSubscribeInnerEvent(this._core.InnerEvent.DESTROY,this._dispose,this),this._reset()}},qn=new class{init(e){this._core=e,this._visibilityChangeHandler=this._handleVisibilityChange.bind(this),e.notificationCenter.subscribeInnerEvent(e.InnerEvent.DESTROY,this._dispose,this),null!==document&&void 0!==document&&document.addEventListener("visibilitychange",this._visibilityChangeHandler),null!=(e=this._core)&&e.store.set("activityMonitor",{isActive:!0})}_handleVisibilityChange(){var e,t="visible"===document.visibilityState;null!=(e=this._core)&&e.store.set("activityMonitor",{isActive:t}),null!=(e=this._core)&&e.notificationCenter.emitInnerEvent("activityStatusChange",{isActive:t})}_reset(){var e;null!=(e=this._core)&&e.store.clear("activityMonitor")}_dispose(){document.removeEventListener("visibilitychange",this._visibilityChangeHandler);var{notificationCenter:e,InnerEvent:t}=this._core;e.unSubscribeInnerEvent(t.DESTROY,this._dispose,this),this._reset()}},Wn=new class{init(e){this._core=e,this._bindAppActivityEvent(),e.notificationCenter.subscribeInnerEvent(e.InnerEvent.DESTROY,this._dispose,this),null!=(e=this._core)&&e.store.set("activityMonitor",{isActive:!0})}_bindAppActivityEvent(){var{MINI_APP_NAMESPACE:e,IN_TT_MINI_GAME:t,IN_WX_MINI_GAME:s}=(null==(e=this._core)?void 0:e.utils)||{};t||s?(null!=(t=null==e?void 0:e.onShow)&&t.call(e,()=>{var e;null!=(e=this._core)&&e.store.set("activityMonitor",{isActive:!0}),null!=(e=this._core)&&e.notificationCenter.emitInnerEvent("activityStatusChange",{isActive:!0})}),null!=(s=null==e?void 0:e.onHide)&&s.call(e,()=>{var e;null!=(e=this._core)&&e.store.set("activityMonitor",{isActive:!1}),null!=(e=this._core)&&e.notificationCenter.emitInnerEvent("activityStatusChange",{isActive:!1})})):(null!=(t=null==e?void 0:e.onAppShow)&&t.call(e,()=>{var e;null!=(e=this._core)&&e.store.set("activityMonitor",{isActive:!0}),null!=(e=this._core)&&e.notificationCenter.emitInnerEvent("activityStatusChange",{isActive:!0})}),null!=(s=null==e?void 0:e.onAppHide)&&s.call(e,()=>{var e;null!=(e=this._core)&&e.store.set("activityMonitor",{isActive:!1}),null!=(e=this._core)&&e.notificationCenter.emitInnerEvent("activityStatusChange",{isActive:!1})}))}_reset(){var e;null!=(e=this._core)&&e.store.clear("activityMonitor")}_dispose(){var{notificationCenter:e,InnerEvent:t}=this._core;e.unSubscribeInnerEvent(t.DESTROY,this._dispose,this),this._reset()}},Yn=new class{init(e){var{IN_MINI_APP:t,IN_WX_MINI_PLUGIN:s}=e.helper;s||(t?Wn:qn).init(e)}};let Kn="none",Hn="online";var jn=new class{init(e){this._core=e,this._activateNetworkMonitoring(),e.notificationCenter.subscribeInnerEvent(e.InnerEvent.DESTROY,this._dispose,this)}_activateNetworkMonitoring(){return de(this,void 0,void 0,function*(){navigator.onLine?this._onOnline():this._onOffline(),this._onOnlineCallback=this._onOnline.bind(this),this._onOfflineCallback=this._onOffline.bind(this),window.addEventListener("online",this._onOnlineCallback),window.addEventListener("offline",this._onOfflineCallback)})}_deactivateNetworkMonitoring(){null!==this._onOnlineCallback&&(window.removeEventListener("online",this._onOnlineCallback),this._onOnlineCallback=null),null!==this._onOfflineCallback&&(window.removeEventListener("offline",this._onOfflineCallback),this._onOfflineCallback=null)}_onNetworkStatusChange(e){var t,{isConnected:e,networkType:s}=e;null!=(t=this._core)&&t.store.set("netWorkMonitor",{isNetworkOnline:e,networkType:s}),null!=(t=this._core)&&t.notificationCenter.emitInnerEvent("networkStatusChange",{isNetworkOnline:e,networkType:s})}_onOnline(){this._onNetworkStatusChange({isConnected:!0,networkType:Hn})}_onOffline(){this._onNetworkStatusChange({isConnected:!1,networkType:Kn})}_reset(){var e;this._deactivateNetworkMonitoring(),null!=(e=this._core)&&e.store.clear("netWorkMonitor")}_dispose(){var e;null!=(e=this._core)&&e.notificationCenter.unSubscribeInnerEvent(null==(e=this._core)?void 0:e.InnerEvent.DESTROY,this._dispose,this),this._reset()}},zn=new class{init(e){this._core=e,this._activateNetworkMonitoring(),e.notificationCenter.subscribeInnerEvent(e.InnerEvent.DESTROY,this._dispose,this)}_activateNetworkMonitoring(){return de(this,void 0,void 0,function*(){try{var{MINI_APP_NAMESPACE:e}=this._core["utils"];this._mpNetworkStatusCallback=this._onNetworkStatusChange.bind(this),e.onNetworkStatusChange(this._onNetworkStatusChange.bind(this))}catch(e){console.error(e)}})}_deactivateNetworkMonitoring(){var e;null!==this._mpNetworkStatusCallback&&({MINI_APP_NAMESPACE:e}=this._core["utils"],e.offNetworkStatusChange&&e.offNetworkStatusChange(this._mpNetworkStatusCallback),this._mpNetworkStatusCallback=null)}_onNetworkStatusChange(e){var t,{isConnected:e,networkType:s}=e;null!=(t=this._core)&&t.store.set("netWorkMonitor",{isNetworkOnline:e,networkType:s}),null!=(t=this._core)&&t.notificationCenter.emitInnerEvent("networkStatusChange",{isNetworkOnline:e,networkType:s})}_reset(){var e;this._deactivateNetworkMonitoring(),null!=(e=this._core)&&e.store.clear("netWorkMonitor")}_dispose(){var e;null!=(e=this._core)&&e.notificationCenter.unSubscribeInnerEvent(null==(e=this._core)?void 0:e.InnerEvent.DESTROY,this._dispose,this),this._reset()}},Zn=new class{init(e){var t=e.utils["IN_MINI_APP"];(t?zn:jn).init(e)}},Xn=new class{constructor(){this.name="SystemStateMonitor"}install(e){Yn.init(e),Zn.init(e)}};let Jn=new Set(["tui_room_svr.*","callkit_records_svr.*","room_engine_srv.*","room_engine_http_srv.*","room_engine_mic.*","live_engine_srv.*","live_engine_http_srv.*","live_engine_pk.*","trtc_ai_service.*","call_engine_srv.*"]),Qn="tui_room_svr.*";var ei=new class{constructor(){this.name="BusinessCommandTransfer",this._transferredCommands=Jn}install(e){var{notificationCenter:e,InnerEvent:t,helper:s}=this._core=e;e.subscribeInnerEvent(t.CLOUD_CONFIG_UPDATE,this._onCloudConfigUpdate,this),e.subscribeInnerEvent(t.LOGOUT,this._reset,this),e.subscribeInnerEvent(t.DESTROY,this._dispose,this),e.subscribeInnerEvent("im_open_push.msg_push",e.InnerEventSubType.BUSINESS_COMMAND,this._onServerPushBusinessCommand,this),s.registerExperimentalAPI("sendTRTCCustomData",this,"transferBusinessCommand"),s.registerExperimentalAPI("sendRoomCustomData",this,"transferBusinessCommand")}transferBusinessCommand(s){return de(this,void 0,void 0,function*(){var t="transferBusinessCommand";try{var{serviceCommand:e=Qn}=s||{};if(this._isValidTransferredCommand(e))return{code:0,data:(yield function(r,o){return de(this,void 0,void 0,function*(){var{helper:e,channel:t}=o,{serviceCommand:s=Qn,data:n}=r||{};let i={};try{i="string"==typeof n?JSON.parse(n):n}catch(e){console.warn(e)}n=e.generateProtocolData({servcmd:s,data:i}),e=""+n.head.seq+s;return t.sendPacket(n,{requestId:e})})}(s,this._core))||{}};throw new this._core.helper.ChatError({code:2995,functionName:t})}catch(e){throw console.warn(e),new this._core.helper.ChatError({code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo,data:{},functionName:t})}})}_onCloudConfigUpdate(e={}){try{var t;"string"==typeof e.rtc_cmd&&(t=JSON.parse(e.rtc_cmd),Array.isArray(t))&&(this._transferredCommands=new Set([...this._transferredCommands,...t]))}catch(e){console.log(e)}}_isValidTransferredCommand(e=""){e=`${null==e?void 0:e.split(".")[0]}.*`;return this._transferredCommands.has(e)}_onServerPushBusinessCommand(e){var{OuterEvent:t,notificationCenter:s}=this._core,e=(e||{})["MsgContent"],t=t["ROOM_CUSTOM_DATA_RECEIVED"];s.emitOuterEvent(t,{name:t,data:e})}_reset(){this._transferredCommands=Jn}_dispose(){var{notificationCenter:e,InnerEvent:t}=this._core;this._reset(),e.unSubscribeInnerEvent(t.CLOUD_CONFIG_UPDATE,this._onCloudConfigUpdate,this),e.unSubscribeInnerEvent(t.LOGOUT,this._reset,this),e.unSubscribeInnerEvent(t.DESTROY,this._dispose,this),e.unSubscribeInnerEvent("im_open_push.msg_push",e.InnerEventSubType.BUSINESS_COMMAND,this._onServerPushBusinessCommand,this)}};let ti=1,si=300;var ni=new class{constructor(){this.name="OfflineMessageSynchronizer",this._lastMessageSequenceMapOnDisconnect=new Map}install(e){var{common:{workflowManager:t},constants:{WORKFLOW_NAME:s,WORKFLOW_STEP:n,InnerEvent:i}}=this._core=e;t.registerWorkflowStep(s.SYNC_SERVER_INFO_AFTER_RE_ONLINE,n.HISTORY_MESSAGE_RECOVER,this._syncOfflineMessage,this),e.notificationCenter.subscribeInnerEvent(i.SOCKET_DISCONNECTED,this._updateLastMessageSequenceMapOnDisconnect,this)}_syncOfflineMessage(e){let t=((null==e?void 0:e.result)||{})["conversationList"],{OuterConstant:s,utils:{isArray:n}}=this._core;if(n(t)){let e=t.filter(e=>e.type===s.CONV_GROUP&&e.groupProfile.type!==s.GRP_AVCHATROOM);return this._recoverGroupHistoryMessage(e)}}_recoverGroupHistoryMessage(e){return de(this,void 0,void 0,function*(){let i=this._core["OuterConstant"],r=[],o=[];return yield Promise.all(null==e?void 0:e.map(n=>de(this,void 0,void 0,function*(){var{groupProfile:{groupID:e}={},lastMessage:{lastSequence:t}={}}=n,e=""+i.CONV_GROUP+e,s=this._getLocalLastMessageSequence(e);this._shouldRecoverHistory({localLastMessageSequence:s,serverLastMessageSequence:t})&&(yield this._recoverHistoryForConversation({conversationID:e,localLastMessageSequence:s,serverLastMessageSequence:t,groupTipList:o})),r.push(e.replace(i.CONV_GROUP,""))}))),{recoverRevokeNoticeGroupIDList:r,groupTipList:o}})}_recoverHistoryForConversation(e){return de(this,arguments,void 0,function*({conversationID:S,localLastMessageSequence:v,serverLastMessageSequence:I,groupTipList:C}){try{let{utils:{isArray:e,isObject:t,isEmpty:s},OuterEvent:n,OuterConstant:i,notificationCenter:r,message:o,appStore:a,common:{getMessagePreviewText:l}}=this._core,c=I-v,u=Math.min(20,c),d={},_=yield o.messageHistory.getGroupRoamingMessagesByAnchor({conversationID:S,sequence:v+u,direction:i.Direction.FORWARD,count:u}),{nextReqMessageIDFromServer:h,hasNoMoreHistoryMessage:g,messageList:p,serverGroupTipList:E}=_,m=(e(E)&&C.push(...E),g&&h<0),f=[];if(e(p)&&(p.forEach(e=>{o.messageReceiver.groupMessageReceiver.updateMessageProfile(e),e.from===i.CONV_SYSTEM&&(e.isSystemMessage=!1),o.messageDataHandler.storeConversationMessage(e)&&!s(e.payload)&&(f.push(e),e._isExcludedFromLastMessage||(d.lastMessage=Object.assign({},e)))}),0<f.length)&&r.emitOuterEvent(n.MESSAGE_RECEIVED,{name:n.MESSAGE_RECEIVED,data:f}),!m&&0<p.length){let e=p[p.length-1].sequence;yield this._recoverHistoryForConversation({conversationID:S,localLastMessageSequence:e,serverLastMessageSequence:I,groupTipList:C})}t(d.lastMessage)&&(d.lastMessage.messageForShow=l(d.lastMessage.type,d.lastMessage.payload),a.conversationStore.updateConversation(S,d))}catch(v){this._core.ssoLog.error("_recoverHistoryForConversation","Recovery failed for conversation:"+S,{error:v})}})}_updateLastMessageSequenceMapOnDisconnect(){let e=this._core["message"],n=e.messageDataHandler.getContinuousMessagesByConversation();for(let[t,s]of n)if(!t.startsWith("C2C")){let e=Array.from(s.values());var i;0<(null==e?void 0:e.length)&&(i=e[e.length-1].sequence,this._lastMessageSequenceMapOnDisconnect.set(t,i))}}_getLocalLastMessageSequence(e){var t=this._core["message"];return this._lastMessageSequenceMapOnDisconnect.has(e)?this._lastMessageSequenceMapOnDisconnect.get(e):null==(e=(t=t.messageDataHandler.getLocalMessageList(e))[t.length-1])?void 0:e.sequence}_shouldRecoverHistory(e){var t,{localLastMessageSequence:e,serverLastMessageSequence:s}=e;return"number"==typeof e&&"number"==typeof s&&(t=s-e,0!==s)&&0<e&&t>=ti&&t<si}};let ii=As.STANDARD,oi=[];ii=As.BASIC,oi=[Fn,Gn,$n,Xn,ei,ni];var ri=Object.freeze({__proto__:null,ChatError:Xs,WorkflowManager:ln,buildAndSendPacket:pn,get builtInPlugins(){return oi},checkBusinessCapabilityBits:cn,deepMerge:In,getCurrentUserID:Sn,getErrorMessage:Zs,getMessagePreviewText:Cn,isC2CConv:e=>t(e)&&e.slice(0,3)===ms.CONV_C2C,isCommunity:dn,isGroupConv:e=>t(e)&&e.slice(0,5)===ms.CONV_GROUP,isTopic:_n,isUnlimitedAVChatRoom:function(){var e;return!(null==(e=es.store.get("instance"))||!e.unlimitedAVChatRoom)},liteChatInstanceMap:un,registerInterceptor:rn,registerValidateConfig:an,requireAuth:Js,get sdkEdition(){return ii},updateGroupAtInfo:(t,s)=>{var{CONV_AT_ME:n,CONV_AT_ALL:i,CONV_AT_ALL_AT_ME:r}=ys;if(!function(t,e){let{CONV_AT_ME:s,CONV_AT_ALL:n,CONV_AT_ALL_AT_ME:i}=ys,{groupID:r,sequence:o}=t,a=!1;return dn({groupID:r})&&e.forEach(e=>{e.messageSequence===o&&(e.atTypeArray.includes(s)&&t.groupAtType.includes(n)&&(e.atTypeArray=[i]),e.atTypeArray.includes(n)&&t.groupAtType.includes(s)&&(e.atTypeArray=[i],e.__random=t.__random,e.__sequence=t.__sequence),a=!0)}),a}(t,s)){let e=[...t.groupAtType];e.includes(n)&&e.includes(i)&&(e=[r]);n={from:t.from,groupID:t.groupID,topicID:t.topicID,messageSequence:t.sequence,atTypeArray:e,__random:t.__random,__sequence:t.__sequence};s.push(n)}},validateAndExecute:on,validateParameters:Qs});class ai{constructor(){this._builtInPlugins=new Set,this._externalPlugins=new Set}static getInstance(){return ai._instance||(ai._instance=new ai),ai._instance}static setInstance(e){ai._instance=e}installBuiltInPlugin(e){e&&this._installPlugin(e,this._builtInPlugins)}installExternalPlugin(e){e&&this._installPlugin(e,this._externalPlugins)}clear(){this._builtInPlugins=new Set,this._externalPlugins=new Set}_installPlugin(e,t){var s=[];let i=(s=n(e)?e:[e]).findIndex(e=>"AVChatRoom"===(null==e?void 0:e.name)),r=-1<i?s.splice(i,1):[];s.forEach(e=>{this._isPluginInstalled(e.name)||(e&&ts(e.install)?(t.add(e.name),ts(e.getInstalledSubPlugins)?e.install(hi.getInstance().exposeApiForPlugin(),r):e.install(hi.getInstance().exposeApiForPlugin()),ts(e.handleLoginSuccess)&&this._isLoggedIn()&&e.handleLoginSuccess()):ts(e)?(t.add(e.name),e(hi.getInstance().exposeApiForPlugin()),ts(e.handleLoginSuccess)&&this._isLoggedIn()&&e.handleLoginSuccess()):console.warn('A plugin must either be a function or an object with an "install" function.'))})}_isPluginInstalled(e){return this._builtInPlugins.has(e)||this._externalPlugins.has(e)}_isLoggedIn(){var e;return!0===(null==(e=es.store.get("login"))?void 0:e.isLoggedIn)}}var mi,Si,vi,Ti,ci=new class{constructor(){this._conversationMap=new Map}getConversationMap(){return this._conversationMap}getConversation(e){return this._conversationMap.get(e)}updateConversation(e,t,s={emit:!0,needSort:!1}){let{emit:n,needSort:i}=s,r=this._conversationMap.get(e);r&&!fe(t)&&(Object.keys(t).forEach(e=>{r[e]=t[e]}),n)&&es.notificationCenter.emitInnerEvent(as.CONVERSATION_UPDATED,{needSort:i})}deleteConversation(e){this._conversationMap.has(e)&&(this._conversationMap.delete(e),es.notificationCenter.emitInnerEvent(as.CONVERSATION_UPDATED))}},li=new class{constructor(){this._groupMap=new Map}getGroupMap(){return this._groupMap}getGroup(e){return this._groupMap.get(e)}updateGroup(e,t){let s=this._groupMap.get(e);s&&!fe(t)&&Object.keys(t).forEach(e=>{s[e]=t[e]})}},ui=new class{constructor(){this._messagesByConversation=new Map}updateMessage(s,t,e){let n,{operation:i,updateUnreadCount:r=!0}=e,o=ue(e,["operation","updateUnreadCount"]),a=[];for(let e of t){let t=null==(n=this._messagesByConversation.get(s))?void 0:n.get(e);if(!t)return!1;Object.keys(o).forEach(e=>{t[e]=o[e]}),a.push(t)}return this._emitMessageStoreOperationEvent(i,{conversationID:s,messageList:a,updateUnreadCount:r}),a}getMessagesByConversation(e){return[...(null==(e=this._messagesByConversation.get(e))?void 0:e.values())||[]]}getMessages(){return this._messagesByConversation}_emitMessageStoreOperationEvent(e,t){var s=t["conversationID"];_n(s)?es.notificationCenter.emitInnerEvent(ps[e],t):es.notificationCenter.emitInnerEvent(e,t)}},di=new class{constructor(){this.userProfileMap=new Map,this.friendMap=new Map}getUserProfileMap(){return this.userProfileMap}getFriendMap(){return this.friendMap}getUserProfile(e){return this.userProfileMap.get(e)}getFriend(e){return this.friendMap.get(e)}},_i=Object.freeze({__proto__:null,conversationStore:ci,groupStore:li,messageStore:ui,userStore:di});class hi{static getInstance(){return hi._instance||(hi._instance=new hi),hi._instance}static setInstance(e){hi._instance=e}constructor(){this._experimentalApiMap={statTUIKeyFeatures:this.statKeyFeatureUsage.bind(this),setApplicationID:this.setApplicationID.bind(this),reportModalView:this.reportModalView.bind(this)},this._apiHandlersMap={},this._apiMap={on:es.notificationCenter.subscribeOuterEvent.bind(es.notificationCenter),off:es.notificationCenter.unSubscribeOuterEvent.bind(es.notificationCenter),destroy:this.destroy.bind(this),callExperimentalAPI:this.callExperimentalAPI.bind(this),use:ai.getInstance().installExternalPlugin.bind(ai.getInstance()),registerPlugin:this.registerPlugin.bind(this),setLogLevel:this.setLogLevel.bind(this)}}registerPlugin(e){es.ssoLog.debug("registerPlugin",e)}statKeyFeatureUsage(e){es.ssoLog.debug("statTUIKeyFeatures",e)}setLogLevel(e){es.ssoLog.debug("setLogLevel",e),es.ssoLog.setLogLevel(e)}setApplicationID(e){es.store.set("instance",{applicationID:e})}getApiMap(){return this._apiMap}setApiMap(e){this._apiMap=e}registerApi(e){let{common:{timeManager:r},utils:{safeStringify:t}}=es,{apiName:o,context:s,methodName:a=o,matcher:n}=e;this._apiHandlersMap[o]||(this._apiHandlersMap[o]=[]),this._apiHandlersMap[o].push({context:s,methodName:a,matcher:n}),this._apiMap[o]&&1!==this._apiHandlersMap[o].length||(this._apiMap[o]=(...s)=>{let n=r.getServerTimeMs(),i=0;"login"===o&&(i=4),ws.includes(o)&&es.ssoLog.debug(o,o+" start params: "+t(s)),on(a,s);for(let t of this._apiHandlersMap[o])if(!t.matcher||t.matcher(s))try{let e=t.context[t.methodName].bind(t.context)(...s);return this._isPromiseLike(e)?this._handleAsyncResult(e,o,i,n):(this._reportApiSuccessLog({result:e,apiName:o,eventType:i,startTime:n}),e)}catch(s){throw es.ssoLog.error(o,`${o} fail ${null==s?void 0:s.message})`,{error:s,costTime:r.getServerTimeMs()-n,eventType:i,method:o}),s}})}registerExperimentalAPI(e,t,s){this._experimentalApiMap[e]=t[s||e].bind(t)}destroy(){return de(this,void 0,void 0,function*(){var e,t;try{null!=(e=es.store.get("login"))&&e.isLogin&&(yield this._apiMap.logout()),es.notificationCenter.emitInnerEvent(as.DESTROY)}catch(e){console.debug("destroy error: ",e)}finally{es.notificationCenter.emitOuterEvent(os.SDK_DESTROY,{SDKAppID:null==(t=es.store.get("instance"))?void 0:t.sdkAppId}),un.clear(),ai.getInstance().clear(),ln.getInstance().destroy(),es.destroy()}})}exposeApiForClient(){return this._apiMap}exposeApiForPlugin(){return Object.assign(Object.assign({InnerEvent:as,InnerEventSubType:es.notificationCenter.InnerEventSubType,OuterEvent:os,OuterConstant:ys,SignalingEvent:cs,helper:Object.assign(Object.assign(Object.assign({},es.utils),es.common),{registerApi:this.registerApi.bind(this),registerExperimentalAPI:this.registerExperimentalAPI.bind(this),registerInterceptor:rn,registerValidateConfig:an,checkBusinessCapabilityBits:cn,registerWorkflowStep:ln.getInstance().registerWorkflowStep.bind(ln.getInstance()),ChatError:Xs}),apiMap:this._apiMap},es),{constants:Object.assign(Object.assign({},Ls),es.constants),common:Object.assign(Object.assign(Object.assign({},ri),es.common),{workflowManager:ln.getInstance()}),utils:es.utils,appStore:_i})}callExperimentalAPI(e,t){return es.ssoLog.debug(`callExperimentalAPI.${e} start params: `+es.utils.safeStringify(t)),this._experimentalApiMap[e]?this._experimentalApiMap[e](t):Promise.reject(new Xs({code:Os.INVALID_OPERATION}))}reportModalView(e){var{ssoLog:t,utils:{safeStringify:s}}=es;try{t.createSSOLogData({method:"reportModalView",message:e,eventType:30}).end(!0)}catch(e){t.debug("reportModalView Report failed: "+s(e))}}_isPromiseLike(e){return null!==e&&"object"==typeof e&&"function"==typeof e.then}_handleAsyncResult(e,t,s,n){return e.then(e=>(this._reportApiSuccessLog({result:e,apiName:t,eventType:s,startTime:n}),e)).catch(e=>{throw es.ssoLog.error(t,`${t} fail ${null==e?void 0:e.message})`,{error:e,costTime:es.common.timeManager.getServerTimeMs()-n,eventType:s,method:t}),e})}_reportApiSuccessLog(e){let{result:t,apiName:s,startTime:n,eventType:i}=e;var e=es.common["timeManager"],{successLog:{message:r,moreMessage:o}={message:"",moreMessage:""}}=t||{},a=e.getServerTimeMs();"login"===s&&(n+=e.getTimeOffsetWithServer()),ws.includes(s)&&es.ssoLog.info(s,s+` success ${r} `+o,{costTime:a-n,eventType:i,message:r,moreMessage:o}),null!=t&&t.successLog&&delete t.successLog}}class gi{constructor(){this._latestLoginAt=0,this._latestSendOnlinePresenceRequestTime=0,this._helloInterval=120,this._customLoginInfo=""}init(){var{notificationCenter:e,store:t}=es;t.set("login",{isReady:!1}),hi.getInstance().registerApi({apiName:"login",context:this}),hi.getInstance().registerApi({apiName:"logout",context:this}),hi.getInstance().registerApi({apiName:"getLoginUser",context:this}),hi.getInstance().registerApi({apiName:"isReady",context:this}),hi.getInstance().registerExperimentalAPI("setCustomLoginInfo",this),e.subscribeInnerEvent(as.RECONNECTED,this._reLogin,this),es.notificationCenter.subscribeInnerEvent(as.DESTROY,this._dispose,this)}login(l){return de(this,void 0,void 0,function*(){var e;let t=(es.store.get("instance")||{})["sdkEdition"];try{if(this._isLoginIn())return this._createRepeatLoginResponse();if(this._isLoginFrequencyExceeded())throw new Xs({functionName:"login",code:Os.REPEAT_LOGIN});var s=yield this._performLogin(l),n=(this._validateAfterLogin(s),this._handleLoginSuccess(s),yield this._ensureAsyncComplete(),this._updateAndEmitSDKReady(),this._latestLoginAt=0,null==(e=es.channel.getSocketAdapter())?void 0:e.getId()),{appId:i,href:r}=es.store.get("instance")||{},{instanceID:o,customStatus:a}=s||{};return{code:0,data:s,successLog:{message:t,moreMessage:`socketID:${n} instanceID:${o} customStatus:${a} href: ${r} appId: `+i}}}catch(e){let t=e["errorCode"],s=(t!==Os.REPEAT_LOGIN&&(this._latestLoginAt=0),new Xs({functionName:"login",code:t}));throw console.error(s),s}})}_reLogin(){return de(this,void 0,void 0,function*(){var e,t,s,n,i;try{this._isLoginIn()&&(t=yield zs(this._customLoginInfo))&&({instanceID:s,customStatus:n}=t,es.store.set("login",{statusInstanceId:s}),ln.getInstance().executeWorkflow(Ns.SYNC_SERVER_INFO_AFTER_RE_ONLINE,{customStatus:n,statusType:Es.USER_STATUS_ONLINE}),i=null==(e=es.channel.getSocketAdapter())?void 0:e.getId(),es.ssoLog.info("reLogin",`socketId:${i} instanceId:`+s))}catch(e){console.warn(e)}})}logout(){return de(this,arguments,void 0,function*(t=ks.USER_INITIATED){let e=es["ssoLog"];e.debug("logout","logout start logoutReason: "+t);try{yield this._performLogout(t),e.info("logout","logout success"),es.ssoLog.uploadSSOLogData()}catch(t){let e=t["errorCode"];throw new Xs({functionName:"logout",code:e})}finally{this._handleLogoutCompleted()}return{code:0,data:{}}})}getLoginUser(){return this._isLoginIn()?Sn():""}isReady(){var e;return null==(e=es.store.get("login"))?void 0:e.isReady}setCustomLoginInfo(e=""){this._customLoginInfo=e}_updateAndEmitSDKReady(){es.store.set("login",{isReady:!0}),setTimeout(()=>{es.notificationCenter.emitOuterEvent(os.SDK_READY,{name:os.SDK_READY})},1)}_updateAndEmitSDKNotReady(){es.store.set("login",{isReady:!1}),es.notificationCenter.emitOuterEvent(os.SDK_NOT_READY,{name:os.SDK_NOT_READY})}_validateAfterLogin(e){var t="login";if(!e)throw new Xs({functionName:t,message:"login response is empty"});var{tinyID:e,a2Key:s}=e||{};if(!e)throw new Xs({functionName:t,code:Os.NO_TINYID});if(!s)throw new Xs({functionName:t,code:Os.NO_A2KEY})}_createRepeatLoginResponse(){var e;return{code:0,data:{actionStatus:"OK",errorCode:0,errorInfo:Zs({code:"RepeatLogin",replacement1:null==(e=es.store.get("login"))?void 0:e.userId}),repeatLogin:!0}}}_performLogin(s){return de(this,void 0,void 0,function*(){var{userID:e,userSig:t}=s;return es.store.set("login",{userId:e,userSig:t}),this._latestLoginAt=Date.now(),zs(this._customLoginInfo)})}_ensureAsyncComplete(){return de(this,void 0,void 0,function*(){yield new Promise(e=>{setTimeout(()=>e(null),1)})})}_handleLoginSuccess(e){var t=es.common["timeManager"],{helloInterval:s,timeStamp:n,customStatus:i,purchaseBits:r}=e;t.calculateTimeOffsetWithServer(this._latestLoginAt,1e3*n),this._helloInterval=s||120,this._updateLoginStore(e),es.user.userStatus.setCustomStatus(i),ln.getInstance().executeWorkflow(Ns.SYNC_SERVER_INFO_AFTER_LOGIN,{purchaseBits:r}),es.common.taskScheduler.addTask({id:Bs,intervalMs:1e3*this._helloInterval,callback:this._sendOnlinePresenceRequest,context:this})}_performLogout(e){return function(s){return de(this,void 0,void 0,function*(){var e=s["logoutReason"],t="im_open_status.wslogout",e=es.common.generateProtocolData({servcmd:t,data:{wslogout_type:e,isWebUniapp:0}}),t=e.head.seq+t;return yield es.channel.sendPacket(e,{requestId:t})})}({logoutReason:e})}_handleLogoutCompleted(){this._updateAndEmitSDKNotReady(),this._reset(),ln.getInstance().reset(),es.notificationCenter.emitInnerEvent("logout")}_updateLoginStore(e){var{a2Key:e,tinyID:t,instanceID:s,authKey:n}=e;es.store.set("login",{a2Key:e,tinyID:t,statusInstanceId:s,authKey:n,isLoggedIn:!0})}_sendOnlinePresenceRequest(){return de(this,void 0,void 0,function*(){this._latestSendOnlinePresenceRequestTime=Date.now();try{e="im_open_status.wshello",t=es.common.generateProtocolData({servcmd:e,data:{isWebUniapp:0}}),e=t.head.seq+e,yield es.channel.sendPacket(t,{requestId:e})}catch(e){es.ssoLog.warn("_sendOnlinePresenceRequest"," error:"+e.message)}var e,t})}_isLoginIn(){var e;return!0===(null==(e=es.store.get("login"))?void 0:e.isLoggedIn)}_isLoginFrequencyExceeded(){return Date.now()-this._latestLoginAt<=15e3}_reset(){es.common.taskScheduler.removeTask(Bs),this._helloInterval=120,this._latestSendOnlinePresenceRequestTime=0,this._latestLoginAt=0,this._customLoginInfo="",es.store.clear("login"),es.store.set("login",{isReady:!1}),es.store.set("instance",{applicationID:0})}_dispose(){this._reset();var e=es["notificationCenter"];e.unSubscribeInnerEvent(as.RECONNECTED,this._reLogin,this),e.unSubscribeInnerEvent(as.DESTROY,this._dispose,this)}}let pi={login:{userID:{required:!0,rules:["string"],allowEmpty:!1},userSig:{required:!0,rules:["string"],allowEmpty:!1}}},Ei={logout:!0};class fi{constructor(){this.loginAction=new gi,this.kickedOutHandler=new js,this.loginAction.init(),this.kickedOutHandler.init(),an({auth:Ei,params:pi})}}!function(e){e.CONV_C2C="C2C",e.CONV_GROUP="GROUP",e.CONV_TOPIC="TOPIC",e.CONV_SYSTEM="@TIM#SYSTEM"}(mi=mi||{}),function(e){e.MSG_PRIORITY_HIGH="High",e.MSG_PRIORITY_NORMAL="Normal",e.MSG_PRIORITY_LOW="Low",e.MSG_PRIORITY_LOWEST="Lowest"}(Si=Si||{}),function(e){e.MSG_TEXT="TIMTextElem",e.MSG_CUSTOM="TIMCustomElem",e.MSG_LOCATION="TIMLocationElem",e.MSG_FACE="TIMFaceElem",e.MSG_IMAGE="TIMImageElem",e.MSG_AUDIO="TIMSoundElem",e.MSG_FILE="TIMFileElem",e.MSG_VIDEO="TIMVideoFileElem",e.MSG_GRP_TIP="TIMGroupTipElem",e.MSG_GRP_SYS_NOTICE="TIMGroupSystemNoticeElem",e.MSG_MERGER="TIMRelayElem"}(vi=vi||{});let Ii={1:Si.MSG_PRIORITY_HIGH,2:Si.MSG_PRIORITY_NORMAL,3:Si.MSG_PRIORITY_LOW,4:Si.MSG_PRIORITY_LOWEST},Ci=0,Mi=1,yi=(!function(e){e.IN="in",e.OUT="out"}(Ti=Ti||{}),2),Oi={};function Ai(e){var t,s,n;return e?(void 0===Oi[e]?(t=("3"+(n=new Date).getHours()).slice(-2),s=("0"+n.getMinutes()).slice(-2),n=("0"+n.getSeconds()).slice(-2),Oi[e]=parseInt([t,s,n,"0001"].join(""),10),console.log("autoIncrementIndex start index:"+Oi[e])):Oi[e]+=1,Oi[e]):0}class Ni{constructor(e){this.ID="",this.random=0,this.sequence=0,this.nameCard="",this.isRead=!1,this.isPeerRead=!1,this.isDeleted=!1,this.isResend=!1,this.hasRiskContent=!1,this._onlineOnlyFlag=!1,this.atUserList=[],this._groupAtInfoList=[],this.isBroadcastMessage=!1,this.priority=Si.MSG_PRIORITY_NORMAL,this._relayFlag=!1;var t,{clientTime:s=es.common.timeManager.getServerTimeSeconds()||0,senderTinyID:n,currentUser:i,needReadReceipt:r,isSupportExtension:o,customModerationConfigurationId:a,to:l,from:c,nick:u="",avatar:d="",time:_,messageControlInfo:h,tinyID:g,cloudCustomData:p="",messageLifeTime:E,messageVersion:m=0,conversationType:f,sequence:S,checkResult:v=0,isPlaceMessage:I=0,messageFlagBits:C,receiverList:T,isSystemMessage:M=!1,status:y=ds.SUCCESS,revokeReason:O="",conversationSubType:A,clientSequence:R,protocol:N="JSON",revokerInfo:D={userID:"",nick:"",avatar:""},readReceiptInfo:P={readCount:void 0,unreadCount:void 0,isPeerRead:void 0,timestamp:0},random:w,groupProfile:b,atUserList:L,flow:k,isRead:U=!1}=e;this.clientTime=s,this.senderTinyID=n||g,this.needReadReceipt=!0===r||1===r,this.isSupportExtension=!0===o||1===o,this._cmConfigID=a,this.to=l,this.nick=u,this.avatar=d,this.protocol=N,this.random=void 0===w?(t=t||99999999,Math.round(Math.random()*t)):w,this.time=_||Math.ceil(Date.now()/1e3),this._isExcludedFromLastMessage=!(null==h||!h.excludedFromLastMessage),this._isExcludedFromUnreadCount=!(null==h||!h.excludedFromUnreadCount),this.isModified=!!m,this.cloudCustomData=p,this.messageLifeTime=E,this.from=c||null,this.sequence=S||0,this.conversationType=f||mi.CONV_C2C,this.hasRiskContent=1<v,this.version=m,this.isPlaceMessage=I,this.isRevoked=2===I||8===C,this.isSystemMessage=M,this.readReceiptInfo=P,this.revokeReason=O,this.revokerInfo=D,this._receiverList=T,this.conversationSubType=A,this.revoker=(null==D?void 0:D.revoker)||"",this.clientSequence=R||S||0,this.status=y,this.atUserList=L||[],this.flow=k,this.isRead=U,this.reInitialize(i),this._initC2CReadReceiptInfo(e),this._extractGroupInfo(b)}getElements(){return this._elements}isOnlineMessage(){return 0===this.messageLifeTime}setElement(e){Array.isArray(e)?this._elements=e:this._elements=[e],this._updatePayloadAndType()}transformElementsToServerFormat(){return this._elements?Array.isArray(this._elements)?this._elements.map(e=>e.transformToServerFormat()):this._elements.transformToServerFormat():null}setRelayFlag(e){this._relayFlag=e}validateBeforeSend(){var e,t;return this._relayFlag?{isValid:!0}:0<(null==(e=this._elements)?void 0:e.length)?null==(t=null==(e=this._elements[0])?void 0:e.validateBeforeSend)?void 0:t.call(e):{isValid:!1}}_updatePayloadAndType(){this._elements[0]&&(this.payload=this._elements[0].content,this.type=this._elements[0].type)}_initC2CReadReceiptInfo(e){var{readReceiptSentByPeer:e,timestamp:t=0}=e;this.conversationType===mi.CONV_C2C&&!0===this.needReadReceipt&&(this.readReceiptInfo.isPeerRead=1===e,this.readReceiptInfo.timestamp=t)}_extractGroupInfo(e){var t,s;e&&({From_AccountNick:e,From_AccountHeadurl:t,MsgFrom_AccountExtraInfo:s}=e,s=(s||{})["NameCard"],"string"==typeof e&&(this.nick=e),"string"==typeof t&&(this.avatar=t),"string"==typeof s)&&(this.nameCard=s)}reInitialize(e){e===this.from&&(this.isRead=!0),this._initSequence(e),this._concatConversationID(e),this.generateMessageID()}_concatConversationID(e){var t=this.conversationType;t!==mi.CONV_SYSTEM?(e=t!==mi.CONV_C2C||e===this.from?this.to:this.from,this.conversationID=e?""+t+e:null):this.conversationID=mi.CONV_SYSTEM}_initSequence(e){0===this.clientSequence&&e&&(this.clientSequence=Ai(e)),0===this.sequence&&this.conversationType===mi.CONV_C2C&&(this.sequence=this.clientSequence)}generateMessageID(){this.from===mi.CONV_SYSTEM&&(this.senderTinyID="144115198244471703"),this.ID=`${this.senderTinyID}-${this.clientTime}-`+this.random}setIsRead(e){this.isRead=e}}class Ri{static parseServerPushElement(e){var{MsgContent:e={}}=e,{Data:e,Ext:t,Desc:s}=e;return new Ri({data:e,description:s,extension:t})}constructor(e){this.type=vi.MSG_CUSTOM;var{data:e="",description:t="",extension:s=""}=e;this.content={data:e,description:t,extension:s}}transformToServerFormat(e){var{isMergerMessage:e=!1}=e||{},{data:e,description:t,extension:s}=e?this.payload:this.content;return{MsgType:this.type,MsgContent:{Data:e,Ext:s,Desc:t}}}validateBeforeSend(){let t=es.utils["isEmpty"],e=[this.content.data,this.content.description,this.content.extension].some(e=>!t(e));return{isValid:e,error:e?null:{message:"content can not be empty"}}}}class Di{static parseServerPushElement(e){var{MsgContent:e={Text:""}}=e,e=e["Text"];return new Di({text:e})}constructor(e){this.type=us.MSG_TEXT,this.content={text:e.text||""}}validateBeforeSend(){var e;return 0<(null==(e=null==(e=this.content)?void 0:e.text)?void 0:e.length)?{isValid:!0}:{isValid:!1,error:{message:"content can not be empty"}}}transformToServerFormat(e){var{isMergerMessage:e=!1}=e||{},e=(e?this.payload:this.content)["text"];return{MsgType:this.type,MsgContent:{Text:e}}}}var Pi=new class{constructor(){this._elementClassMap={[vi.MSG_CUSTOM]:Ri,[vi.MSG_TEXT]:Di}}init(){hi.getInstance().registerApi({apiName:"createCustomMessage",context:this}),hi.getInstance().registerApi({apiName:"createTextMessage",context:this})}registerElementClass(e,t){void 0!==t.prototype&&"constructor"in t.prototype&&(this._elementClassMap[e]=t)}getElementClass(e){return this._elementClassMap[e]}createMessage(e){var{from:t,flow:s=Ti.OUT}=e,n=(es.store.get("login")||{})["userId"],t=(this._isSendByCurrentInstance({from:t,flow:s,currentUser:n})?this._updateWithSenderInfo(e):this._isMultiEndpointSyncMessage({from:t,flow:s,currentUser:n})&&(e.flow=Ti.OUT),Object.assign(Object.assign({},e),{currentUser:n}));return new Ni(t)}createCustomMessage(t){let e=Sn(),s=this.createMessage(Object.assign(Object.assign({},t),{from:e})),n=this._elementClassMap[vi.MSG_CUSTOM];if(!s)return null;if(n){let e=new n(t.payload);s.setElement(e)}return s}createTextMessage(e){var t,s;return e?(t="string"==typeof e.payload?e.payload:(null==(t=null==e?void 0:e.payload)?void 0:t.text)||"",t=new Di({text:t}),s=Sn(),(e=es.message.messageFactory.createMessage(Object.assign(Object.assign({},e),{from:s}))).setElement(t),e):null}_updateWithSenderInfo(e){var{nick:t,avatar:s}=e,{userId:n,tinyID:i}=es.store.get("login")||{},r=di.getUserProfile(n);return e.nick=t||(null==r?void 0:r.nick)||"",e.avatar=s||(null==r?void 0:r.avatar)||"",e.tinyID=e.tinyID||i||"",e.from=n,e.status=ds.UNSENT,e.flow=Ti.OUT,e}_isMultiEndpointSyncMessage(e){var{from:e,flow:t,currentUser:s}=e;return e===s&&t===Ti.IN}_isSendByCurrentInstance(e){var{from:e,flow:t,currentUser:s}=e;return e===s&&t===Ti.OUT}};let bi={PushFlag:0,Title:"",Desc:"",Ext:"",ApnsInfo:{Sound:"",BadgeMode:0,IsVoipPush:void 0,Image:"",InterruptionLevel:"active",ContentAvailable:0},AndroidInfo:{Sound:"",XiaoMiChannelID:"",OPPOChannelID:"",GoogleChannelID:"",VIVOClassification:1,VIVOCategory:"",HuaWeiCategory:"",OPPOCategory:"",HuaWeiImage:"",HonorImage:"",GoogleImage:"",HonorImportance:"",MeizuNotifyType:void 0}},wi={HonorImportance:{range:["LOW","NORMAL"],defaultValue:void 0},MeizuNotifyType:{range:[0,1],defaultValue:void 0}},Li={enableIOSBackgroundNotification:{range:[!0,!1],defaultValue:!1},interruptionLevel:{range:["passive","active","time-sensitive","critical"],defaultValue:"active"}};function ki(n,i){return Object.keys(i).forEach(e=>{var{range:t,defaultValue:s}=i[e];n[e]=t.includes(n[e])?n[e]:s}),n}function Ui(e){var t=e.lastIndexOf(".");return-1===t?e:e.slice(0,t)}function Gi(e){var{androidInfo:e={},androidOPPOChannelID:t=""}=e,t=e.OPPOChannelID||t,e=ki(e,wi),{sound:s="",FCMChannelID:n=""}=e,e=ue(e,["sound","FCMChannelID"]);return Object.assign(Object.assign({},e),{Sound:Ui(s),OPPOChannelID:t,GoogleChannelID:n})}function Fi(t){var{apnsInfo:t={},ignoreIOSBadge:s=!1,disableVoipPush:n}=t,t=ki(t,Li),{ignoreIOSBadge:i,disableVoipPush:r,enableIOSBackgroundNotification:o}=t,t=ue(t,["ignoreIOSBadge","disableVoipPush","enableIOSBackgroundNotification"]),i=!0===i||!0===s?1:0;let a;return e(n)||(a=!1===n?1:0),e(r)||(a=!1===r?1:0),Object.assign(Object.assign({},t),{BadgeMode:i,IsVoipPush:a,ContentAvailable:o?1:0})}function Bi(e){return es.utils.isPlainObject(e)?{PushFlag:!0===e.disablePush?1:0,Title:e.title||"",Desc:e.description||"",Ext:e.extension||"",ApnsInfo:Fi(e),AndroidInfo:Gi(e)}:bi}function xi(e){let{From_AccountHeadurl:t,From_AccountNick:s,IsNeedReadReceipt:n,IsPeerRead:i,IsSyncMsg:r,MsgBody:o,MsgClientTime:a,MsgLifeTime:l,MsgRandom:c,MsgSeq:u,MsgTimeStamp:d,SendMsgControl:_,SupportMessageExtension:h,TinyId:g,MsgCheckResult:p,CloudCustomData:E,MsgVersion:m,MsgFlagBits:f,RevokerInfo:S}=e,v,{From_Account:I,To_Account:C}=e;if(1===r){let e=C;C=I,I=e}if(S){let{Reason:e,Revoker_Account:t,Revoker_FromUin:s}=S;v={reason:e,revoker:t,revokerFromUin:s,userID:t}}return{from:I,avatar:t,nick:s,needReadReceipt:1===n,isSyncMessage:r,clientTime:a,messageLifeTime:l,random:c,sequence:u,time:d,messageControlInfo:{excludedFromLastMessage:1===(null==_?void 0:_.NoLastMsg),excludedFromUnreadCount:1===(null==_?void 0:_.NoUnread)},isSupportExtension:h,to:C,tinyID:g,checkResult:p,cloudCustomData:E,revokerInfo:v,messageVersion:m,messageFlagBits:f,readReceiptSentByPeer:i,elements:Wi(o)}}function Vi(e){var{From_Account:e,MsgBody:t,MsgClientTime:s,MsgRandom:n,MsgSeq:i,MsgTimeStamp:r,To_Account:o,MsgVersion:a,CloudCustomData:l}=e;return{from:e,clientTime:s,random:n,sequence:i,time:r,to:o,elements:Wi(t),messageVersion:a,cloudCustomData:l}}function $i(e){let{ClientSeq:t,From_Account:s,GroupInfo:n,MsgBody:i,MsgClientTime:r,MsgRandom:o,MsgSeq:a,MsgTimeStamp:l,SendMsgControl:c,SupportMessageExtension:u,TinyId:d,CloudCustomData:_,MsgVersion:h,MsgCheckResult:g,NeedReadReceipt:p,IsPlaceMsg:E,RevokerInfo:m,GroupAtInfo:f}=e,S,v=Si.MSG_PRIORITY_NORMAL;if(Object.keys(Ii).includes(String(e.MsgPriority))&&(v=Ii[e.MsgPriority]),m){let{Reason:e,Revoker_Account:t,Revoker_FromUin:s}=m;S={reason:e,revoker:t,revokerFromUin:s,userID:t}}var I=function(e){let t=[];return Array.isArray(e)&&e.forEach(e=>{e.GroupAtAllFlag===Ci?t.push(e.GroupAt_Account):e.GroupAtAllFlag===Mi&&t.push(ys.MSG_AT_ALL)}),t}(f);return{clientSequence:t,from:s,groupProfile:n,clientTime:r,priority:v,random:o,sequence:a,time:l,messageControlInfo:{excludedFromLastMessage:1===(null==c?void 0:c.NoLastMsg),excludedFromUnreadCount:1===(null==c?void 0:c.NoUnread)},isSupportExtension:u,tinyID:d,cloudCustomData:_,messageVersion:h,messageCheckResult:g,needReadReceipt:p,isPlaceMessage:E,revokerInfo:S,atUserList:I,elements:Wi(i),to:qi(e)}}function qi(e){var{utils:{isEmpty:t},constants:{IS_TOPIC_MESSAGE:s}}=es,{ToGroupId:e,GroupInfo:{MillionGroupFlag:n=0,TopicId:i}={}}=e;return n!==s||t(i)?e:i}function Wi(e){var t;return e?Array.isArray(e)?e.map(e=>{var t=es.message.messageFactory.getElementClass(e.MsgType);return null==t?void 0:t.parseServerPushElement(e)}):null==(t=es.message.messageFactory.getElementClass(e.MsgType))?void 0:t.parseServerPushElement(e):null}function Yi(e){var{From_Account:e,MsgBody:t,MsgClientTime:s,MsgRandom:n,MsgSeq:i,MsgTimeStamp:r,GroupId:o,TopicId:a,MsgVersion:l,CloudCustomData:c}=e;return{from:e,clientTime:s,random:n,sequence:i,time:r,groupID:o,topicID:a,elements:Wi(t),messageVersion:l,cloudCustomData:c}}function Ki({conversationUpdateFields:e,message:t}){var{conversationID:s,conversationType:n,conversationSubType:i,flow:r,_isExcludedFromUnreadCount:o,_isExcludedFromLastMessage:a}=t,a=a?"":t,t=!o&&r===Ti.IN;e.has(s)?(e.get(s).lastMessage=a,t&&e.get(s).unreadCount++):e.set(s,{conversationID:s,type:n,subType:i,unreadCount:t?1:0,lastMessage:a})}function Hi(e){return e.filter(e=>{var t=!fe(null==e?void 0:e.getElements()),s=1===(null==e?void 0:e.isPlaceMessage);return t||es.ssoLog.error("emptyMessageBody",`from:${e.from} to:${e.to} sequence:`+e.sequence),t&&!s})}function ji(e){var t=es.message["messageDataHandler"];return!t.isInMessageList(e)&&!t.isMessageSentByCurrentInstance(e)}var zi=Object.freeze({__proto__:null,autoIncrementIndex:Ai,filterValidMessages:Hi,parseServerGroupMessage:$i,parseServerPushC2CModifyMessage:Vi,parseServerPushGroupModifyMessage:Yi,parseServerPushMessage:xi,parseServerPushMessageElement:Wi,shouldStoreMessage:ji,updateConversationFields:Ki});let Zi=es.utils["isPlainObject"];function Xi(e,t={}){let{onlineUserOnly:s,messageControlInfo:n}=t,i=t["offlinePushInfo"],r=(e.conversationType===mi.CONV_C2C&&!0===s&&(i?i.disablePush=!0:i={disablePush:!0}),"");"string"==typeof e.cloudCustomData&&0<e.cloudCustomData.length&&(r=e.cloudCustomData);var o=[];if(n&&Zi(n)){let{excludedFromUnreadCount:e,excludedFromLastMessage:t,excludedFromContentModeration:s}=n;!0===e&&o.push("NoUnread"),!0===t&&o.push("NoLastMsg"),!0===s&&o.push("NoMsgCheck")}return{onlineUserOnly:s,cloudCustomData:r,messageControlInfo:o,offlinePushInfo:i}}function Ji(e){var t,{webhookInfo:{disableCloudMessagePreHook:e=!1,disableCloudMessagePostHook:s=!1}={}}=e||{};if(e||s)return t=[],e&&t.push("ForbidBeforeSendMsgCallback"),s&&t.push("ForbidAfterSendMsgCallback"),t}function Qi(t,s){return de(this,void 0,void 0,function*(){var e=yield pn((t.conversationType===mi.CONV_GROUP?function(e,t){var s,{onlineUserOnly:i,cloudCustomData:r,messageControlInfo:o,offlinePushInfo:a}=Xi(e,t),l=JSON.parse(JSON.stringify(e.transformElementsToServerFormat()));let c;return n(e._receiverList)&&0<e._receiverList.length&&(c=e._receiverList,50<e._receiverList.length)&&(c=e._receiverList.slice(0,50),console.warn("ReceiverListLimit")),{servcmd:"group_open_http_svc.send_group_msg",data:{From_Account:null==(s=es.store.get("login"))?void 0:s.userId,GroupId:e.to,MsgBody:l,CloudCustomData:r,Random:e.random,MsgPriority:e.priority,ClientSeq:e.clientSequence,GroupAtInfo:e._groupAtInfoList,OnlineOnlyFlag:i?1:0,MsgClientTime:e.clientTime,OfflinePushInfo:Bi(a),SendMsgControl:i?void 0:o,NeedReadReceipt:!0===e.needReadReceipt?1:0,To_Account:c,SupportMessageExtension:!0===e.isSupportExtension?1:0,IsRelayMsg:!0===e._relayFlag?1:0,CustomModerationConfigID:e._cmConfigID,ForbidCallbackControl:Ji(t)}}}:function(e,t){var s,{onlineUserOnly:n,cloudCustomData:i,messageControlInfo:r,offlinePushInfo:o}=Xi(e,t),n=!0===n?0:void 0,a=JSON.parse(JSON.stringify(e.transformElementsToServerFormat()));return{servcmd:"openim.sendmsg",data:{From_Account:null==(s=es.store.get("login"))?void 0:s.userId,To_Account:e.to,MsgBody:a,CloudCustomData:i,MsgSeq:e.sequence,MsgRandom:e.random,MsgLifeTime:n,From_AccountNick:e.nick,From_AccountHeadurl:e.avatar,SendMsgControl:0!==n?r:void 0,MsgClientTime:e.clientTime,IsNeedReadReceipt:!0===e.needReadReceipt?1:0,SupportMessageExtension:!0===e.isSupportExtension?1:0,IsRelayMsg:!0===e._relayFlag?1:0,CustomModerationConfigID:e._cmConfigID,OfflinePushInfo:Bi(o),forbidCallbackControl:Ji(t)}}})(t,s));return e?{time:e.MsgTime,messageDropReason:e.MsgDropReason,sequence:e.MsgSeq}:null})}let eo=es.utils["isPlainObject"],{MSG_AUDIO:to,MSG_FILE:so,MSG_IMAGE:no,MSG_VIDEO:io,MSG_MERGER:oo}=ys;class ro{init(){hi.getInstance().registerApi({apiName:"sendMessage",context:this,matcher:e=>![to,so,no,io,oo].includes(e[0].type)})}sendMessage(u,d){return de(this,void 0,void 0,function*(){let{TOTAL_COUNT:e,SEND_COST:o,SUCCESS_COUNT:a,FAILED_COUNT:t}=bs;if(!(u instanceof Ni))throw new Xs({code:Os.MSG_INSTANCE_REQUIRED});let s=u.validateBeforeSend();if(!s.isValid){let{code:e,message:t=""}=s.error||{};throw new Xs({code:e,message:t})}this._reportMessageSendQuality({name:e,message:u});let l=!1;var c=(es.message||{})["messageDataHandler"];try{let n=(d||{})["messageControlInfo"],i=null,r=(c.addRandomOfSentMessage(u.random),Date.now());if(u.conversationType===mi.CONV_C2C?(l=!0===(null==d?void 0:d.onlineUserOnly),i=yield Qi(u,d)):u.conversationType===mi.CONV_GROUP&&(yield this._validateBeforeSendGroupMessage(u),i=yield Qi(u,d)),i){let{messageDropReason:e,sequence:t,time:s}=i;if(this._updateNickAndAvatarOfSentMessageByMe(u),e&&this._logRateLimitInfo(u,t,e),this._reportMessageSendQuality({name:a,message:u}),this._reportMessageSendQuality({name:o,message:u,startTs:r}),!0===u.isResend){let e=c.findMessage(u.ID);e&&(es.ssoLog.debug("sendMessage","sendMessage resend ok. ID:"+e.ID),c.deleteConversationMessage(e))}return u.status=ds.SUCCESS,u.time=s,u.conversationType===mi.CONV_GROUP&&(u.sequence=t),l?u._onlineOnlyFlag=!0:(c.storeConversationMessage(u),this._applySentMessageControlInfo(u,n),this._emitOnlineMessageSent(u)),{code:0,data:{message:u}}}}catch(e){u.status=ds.FAIL,c.removeRandomOfSentMessage(u.random);var n=(e||{})["errorCode"],i=(null==e?void 0:e.errorInfo)||(null==e?void 0:e.message)||"";throw this._hasRiskContent(n)&&(u.hasRiskContent=!0),l||this._isRejectedByRestApi(n)||c.storeConversationMessage(u),this._reportMessageSendQuality({name:t,message:u,error:e}),i=`type:${u.type} from:${u.from} to:${u.to} `+i,new Xs({code:n,message:i,data:{message:u}})}})}_hasRiskContent(e){return 80001===e||80004===e}_isRejectedByRestApi(e){return 10100<=e&&e<=10200||120001<=e&&e<=13e4}_emitOnlineMessageSent(e){var t=e._isExcludedFromLastMessage?"":e,{conversationID:s,conversationType:n}=e,i=_n(s)?as.TOPIC_NEW_MESSAGE:as.NEW_MESSAGE;es.notificationCenter.emitInnerEvent(i,{result:{conversationUpdateFieldList:[{conversationID:s,type:n,message:e,lastMessage:t,unreadCount:0}]}})}_applySentMessageControlInfo(e,t){t&&eo(t)&&(!0===t.excludedFromLastMessage&&(e._isExcludedFromLastMessage=!0),!0===t.excludedFromUnreadCount)&&(e._isExcludedFromUnreadCount=!0)}_logRateLimitInfo(e,t,s){e=`from:${e.from} to:${e.to} sequence:${t} messageDropReason:`+s;es.ssoLog.warn("messageDropReason",e)}_updateNickAndAvatarOfSentMessageByMe(e){var t=(es.message||{})["messageDataHandler"];let s=!1;var n,i=e["conversationID"],r=t.getLatestMsgSentByMe(i);r&&({nick:r,avatar:n}=r,s=r!==e.nick||n!==e.avatar||s)&&t.updateNickAndAvatarOfSentMessage({conversationID:i,latestNick:e.nick,latestAvatar:e.avatar,isSentByMe:!0})}_validateBeforeSendGroupMessage(i){return de(this,void 0,void 0,function*(){var{to:t,from:s}=i;let n=t,e=li.getGroup(n);if(dn({groupID:n})&&null!=e&&e.isSupportTopic)throw new Xs({code:Os.MSG_SEND_GRP_WITH_TOPIC_FAIL});if(_n(t)&&([n]=t.split(Cs.TOPIC),e=li.getGroup(n)),!e&&"function"==typeof(null==(t=hi.getInstance().getApiMap())?void 0:t.getGroupProfile)){let e=yield hi.getInstance().getApiMap().getGroupProfile({groupID:n});if((null==(t=null==(t=null==e?void 0:e.data)?void 0:t.group)?void 0:t.type)===ys.GRP_AVCHATROOM){let e=Zs({code:Os.MSG_SEND_FAIL_NOT_IN_AV,replacement1:s,replacement2:n});throw new Xs({code:Os.MSG_SEND_FAIL_NOT_IN_AV,message:e})}}return!0})}_reportMessageSendQuality(e){es.notificationCenter.emitInnerEvent(as.QUALITY_STAT,{label:Ps.MESSAGE_SEND_SUCCESS_RATE,data:e})}}class ao{constructor(e){this.value=e,this.next=null}}class co{constructor(e){this.head=null,this.tail=null,this.size=0,this.capacity=e}append(e){this.size>=this.capacity&&this.removeHead();e=new ao(e);this.head?this.tail.next=e:this.head=e,this.tail=e,this.size+=1}delete(t){if(this.head)if(this.head.value===t)this.head=this.head.next;else{let e=this.head;for(;e.next;){if(e.next.value===t)return void(e.next=e.next.next);e=e.next}}}has(e){if(!this.head)return!1;let t=this.head,s=!1;for(;t;)t.value===e&&(s=!0),t=t.next;return s}removeHead(){this.head&&(this.head===this.tail?(this.head=null,this.tail=null):this.head=this.head.next,--this.size)}peek(){var e;return null==(e=this.head)?void 0:e.value}length(){return this.size}isEmpty(){return 0===this.size}isFull(){return this.size===this.capacity}clear(){this.head=null,this.tail=null,this.size=0}}var lo=new class{constructor(){this._sparseMessagesByConversation=new Map,this._latestMessageSentByPeerMap=new Map,this._latestMessageSentByMeMap=new Map,this._randomOfSentMessageList=new co(100)}init(){es.notificationCenter.subscribeInnerEvent(as.LOGOUT,this._reset,this),es.notificationCenter.subscribeInnerEvent(as.DESTROY,this._dispose,this)}get _messagesByConversation(){return ui.getMessages()}storeConversationMessage(e,t=!1){var s=e["conversationID"];return!!s&&(this._messagesByConversation.has(s)||this._messagesByConversation.set(s,new Map),!this._shouldSkipStoreMessage(e,t))&&(t=this._getUniqueIdOfMessage(e),this._messagesByConversation.get(s).set(t,e),this._updateLatestMessageMap(e),!0)}_updateLatestMessageMap(e){var t=e["conversationID"];"out"===e.flow?this._setLatestMsgSentByMe(t,e):t.startsWith("C2C")&&this._setLatestMsgSentByPeer(t,e)}_shouldSkipStoreMessage(e,t){var s=this._getUniqueIdOfMessage(e),n=this._messagesByConversation.get(e.conversationID);if(null!=n&&n.has(s)){let e=null==n?void 0:n.get(s);if(!t||!0===(null==e?void 0:e.isModified))return!0}return!1}deleteConversationMessage(e){var{conversationID:t=""}=e,e=this._getUniqueIdOfMessage(e);this._messagesByConversation.has(t)&&null!=(t=this._messagesByConversation.get(t))&&t.delete(e)}modifyConversationMessage(a,t){var l;if(this._messagesByConversation.has(a)||this._sparseMessagesByConversation.has(a)){let e=this._getUniqueIdOfMessage(t),o=this._getMessageFromLocalMessage(a,e);if(o){let{messageVersion:s,elements:n,cloudCustomData:i,checkResult:e=0}=t,r=1<e;if(console.log(`conversationToMessageMap modifyConversationMessage localVersion:${o.version} remoteVersion:`+s),o.version<s){let e=this._getUniqueIdOfMessage(o),t=me(n);return null!=(l=this._messagesByConversation.get(a))&&l.has(e)?ui.updateMessage(a,[e],{isModified:!0,version:s,_elements:t,payload:t[0].content,type:t[0].type,cloudCustomData:i,hasRiskContent:r,operation:_s.modify}):(o.version=s,o._elements=t,o.payload=o._elements[0].content,o.type=o._elements[0].type,o.cloudCustomData=i,o.isModified=!0,o.hasRiskContent=r),{isUpdated:!0,message:o}}return{isUpdated:!1,message:o}}}return{isUpdated:!1,message:null}}_getMessageFromLocalMessage(e,s){var t;if(this._messagesByConversation.has(e))return null==(t=this._messagesByConversation.get(e))?void 0:t.get(s);if(this._sparseMessagesByConversation.has(e)){let t=[...this._sparseMessagesByConversation.get(e).values()];for(let e=0;e<t.length;e++)if(this._getUniqueIdOfMessage(t[e])===s)return t[e]}return null}findMessage(t){let s=null,e=Array.from(this._messagesByConversation.values());for(var n of e)if(s=Array.from(n.values()).find(e=>e.ID===t)||null)break;if(!s){let e=Array.from(this._sparseMessagesByConversation.values());for(var i of e)if(s=i.get(t)||null,s)break}return s}deleteConversationMessageList(e){this._messagesByConversation.has(e)&&(this._messagesByConversation.delete(e),this._latestMessageSentByMeMap.delete(e),this._latestMessageSentByPeerMap.delete(e)),this._sparseMessagesByConversation.has(e)&&this._sparseMessagesByConversation.delete(e)}revokeMessage({conversationID:t,sequence:s,random:n,revoker:i}){let e=this._messagesByConversation.get(t),r=null;if(e){var o=Array.from(e.values());if(r=this._findMessageBySequenceAndRandom({messageList:o,random:n,sequence:s})){let e=this._getUniqueIdOfMessage(r);return ui.updateMessage(t,[e],{isRevoked:!0,revoker:i,operation:_s.revoke}),r}}if(this._sparseMessagesByConversation.has(t)){let e=Array.from(this._sparseMessagesByConversation.get(t).values());if(r=this._findMessageBySequenceAndRandom({messageList:e,random:n,sequence:s}))return r.isRevoked=!0,r.revoker=i,r}}_findMessageBySequenceAndRandom({messageList:s,sequence:n,random:i}){for(let t=0;t<s.length;t+=1){var r=s[t];if(r.sequence===n&&(e(i)||r.random===i))return r}return null}prependLocalMessageList(e){let{messageList:s,conversationID:t}=e;if(0===s.length)return[];var n=[],i=[],r=this._messagesByConversation.get(t)||new Map;for(let t of s){let e=this._getUniqueIdOfMessage(t);r.has(e)||(n.push(t),i.push([e,t]))}if(0<i.length){let e=new Map([...i,...r.entries()]);this._messagesByConversation.set(t,e),this._updateLatestMessageSentByMe(t),this._updateLatestMessageSentByPeer(t)}return n}storeSparseMessageList(n){if(0!==n.length){let e=n[0]["conversationID"],s=n.length;this._sparseMessagesByConversation.has(e)||this._sparseMessagesByConversation.set(e,new Map);var i=this._sparseMessagesByConversation.get(e);for(let t=0;t<s;t++){let e=n[t];i.has(e.ID)||i.set(e.ID,e)}}}_updateLatestMessageSentByMe(t){var e,s=Array.from((null==(e=this._messagesByConversation.get(t))?void 0:e.values())||[]);if(0!==s.length)for(let e=s.length-1;0<=e;e--)if("out"===s[e].flow){this._setLatestMsgSentByMe(t,s[e]);break}}_updateLatestMessageSentByPeer(t){var e,s=Array.from((null==(e=this._messagesByConversation.get(t))?void 0:e.values())||[]);if(0!==s.length&&t.startsWith("C2C"))for(let e=s.length-1;0<=e;e--)if("in"===s[e].flow){this._setLatestMsgSentByPeer(t,s[e]);break}}_getUniqueIdOfMessage(e){var{from:e,to:t,random:s,sequence:n,time:i}=e;return e+`-${t}-${s}-${n}-`+i}_setLatestMsgSentByPeer(e,t){this._latestMessageSentByPeerMap.set(e,t)}_setLatestMsgSentByMe(e,t){this._latestMessageSentByMeMap.set(e,t)}getLatestMsgSentByPeer(e){return this._latestMessageSentByPeerMap.get(e)}getLatestMsgSentByMe(e){return this._latestMessageSentByMeMap.get(e)}addRandomOfSentMessage(e){this._randomOfSentMessageList.append(e)}removeRandomOfSentMessage(e){this._randomOfSentMessageList.delete(e)}updateNickAndAvatarOfSentMessage(e){let{conversationID:t="",latestAvatar:r,latestNick:o,isSentByMe:s=!0}=e,n=this._messagesByConversation.get(t);if(n){let e=Array.from(n.values()),i=s?"out":"in";e.forEach(e=>{var{nick:t,avatar:s,flow:n}=e;n===i&&(t!==o&&(e.nick=o),s!==r)&&(e.avatar=r)})}}isInMessageList(e){var t=e["conversationID"];return!!t&&!!this._messagesByConversation.has(t)&&(e=this._getUniqueIdOfMessage(e),null==(t=this._messagesByConversation.get(t))?void 0:t.has(e))}isMessageSentByCurrentInstance(e){e=e.random;return this._randomOfSentMessageList.has(e)}getContinuousMessagesByConversation(){return this._messagesByConversation}getLocalMessageList(e){e=this._messagesByConversation.get(e);return e?[...e.values()]:[]}getSparseMessageList(e){e=this._sparseMessagesByConversation.get(e);return e?[...e.values()]:[]}_reset(){this._messagesByConversation.clear(),this._latestMessageSentByPeerMap.clear(),this._latestMessageSentByMeMap.clear(),this._randomOfSentMessageList.clear()}_dispose(){this._reset(),es.notificationCenter.unSubscribeInnerEvent(as.LOGOUT,this._reset,this),es.notificationCenter.unSubscribeInnerEvent(as.DESTROY,this._dispose,this)}};function uo(e,t){var s,n,i,r,o,a,l,c=ci.getConversation(e);null!=c&&c.lastMessage&&(c=c["lastMessage"],{lastTime:s,lastSequence:n,version:i}=c,{time:t,sequence:r,messageVersion:o,elements:a,cloudCustomData:l}=t,s===t)&&n===r&&i!==o&&(c.type=a[0].type,c.payload=a[0].content,c.messageForShow=Cn(c.type,c.payload),c.cloudCustomData=l,c.version=o,ci.updateConversation(e,{lastMessage:c}))}class _o{init(){hi.getInstance().registerApi({apiName:"modifyMessage",context:this})}modifyMessage(c){return de(this,void 0,void 0,function*(){let{to:n,payload:t,sequence:i,conversationType:r,random:o,time:a,from:l,type:s}=c;if(this._canModifyMessageElement(s)){let e=c.getElements();1<e.length&&(e[0].type=s,e[0].content=t)}try{let t=null,s;if(r===mi.CONV_C2C?t=yield function(u){return de(this,void 0,void 0,function*(){let{from:e,to:t,version:s=0,sequence:n,random:i,time:r,type:o,cloudCustomData:a}=u,l={From_Account:e,To_Account:t,MsgVersion:s,MsgSeq:n,MsgRandom:i,MsgTime:r,MsgType:o,MsgBody:u.transformElementsToServerFormat(),CloudCustomData:a},c=yield pn({servcmd:"openim.modify_c2c_msg",data:l});if(c){let{MsgBody:e,MsgVersion:t,CloudCustomData:s}=c;return{elements:Wi(e),messageVersion:t,cloudCustomData:s}}})}(c):r===mi.CONV_GROUP&&(t=yield function(o){return de(this,void 0,void 0,function*(){let{to:e,version:t=0,sequence:s,cloudCustomData:n}=o,i={GroupId:e,MsgVersion:t,MsgSeq:s,MsgBody:o.transformElementsToServerFormat(),CloudCustomData:n},r=yield pn({servcmd:"openim.modify_group_msg",data:i});if(r){let{MsgBody:e,MsgVersion:t,CloudCustomData:s}=r;return{elements:Wi(e),messageVersion:t,cloudCustomData:s}}})}(c)),t){let e=""+r+n;return n===Sn()&&r===mi.CONV_C2C&&(e=""+r+l),s={conversationType:r,from:l,to:n,time:a,random:o,sequence:i,elements:null==t?void 0:t.elements,cloudCustomData:null==t?void 0:t.cloudCustomData,messageVersion:null==t?void 0:t.messageVersion,conversationID:e},this._handleModifyMessageSuccess(s),{code:0,data:{message:c},successLog:{message:"to:"+n}}}}catch(e){let t=(e||{})["errorCode"];throw new Xs({functionName:"modifyMessage",code:t})}})}_handleModifyMessageSuccess(e){var t=e["conversationID"],{isUpdated:s,message:n}=es.message.messageDataHandler.modifyConversationMessage(t,e);!0===s&&es.notificationCenter.emitOuterEvent(os.MESSAGE_MODIFIED,{name:os.MESSAGE_MODIFIED,data:[n]}),es.notificationCenter.emitInnerEvent(as.MESSAGE_MODIFIED,{conversationID:t,message:n}),uo(t,e)}_canModifyMessageElement(e){return[vi.MSG_TEXT,vi.MSG_CUSTOM,vi.MSG_LOCATION,vi.MSG_FACE].includes(e)}}class ho{init(){var e=es["notificationCenter"],t=e["InnerEventSubType"];ln.getInstance().registerWorkflowStep(Ns.RECEIVE_C2C_NEW_MESSAGE,Rs.HANDLE_C2C_NEW_MESSAGE,this._handleC2CMessagePush,this),ln.getInstance().registerWorkflowStep(Ns.RECEIVE_C2C_NEW_MESSAGE,Rs.EMIT_C2C_MESSAGE_EVENT,this._emitMessageEventsAfterReceiveNewMessage,this),ln.getInstance().registerWorkflowStep(Ns.SYNC_SERVER_INFO_AFTER_RE_ONLINE,Rs.EMIT_C2C_MESSAGE_EVENT,this._emitMessageEventsAfterSyncUnreadMessage,this),e.subscribeInnerEvent(as.MESSAGE_PUSH,t.C2C_REALTIME_MESSAGE,this._executeReceiverNewMessageWorkFlow,this),e.subscribeInnerEvent(as.MESSAGE_PUSH,t.C2C_MESSAGE_MODIFIED,this._handleC2CMessageModify,this),e.subscribeInnerEvent(as.DESTROY,this._dispose,this)}_executeReceiverNewMessageWorkFlow(e){ln.getInstance().executeWorkflow(Ns.RECEIVE_C2C_NEW_MESSAGE,e)}_handleC2CMessagePush(e){let t=e.data||{},s=(es.message||{})["messageDataHandler"],n=[],i=new Map;return t.C2cMsgArray.forEach(e=>{e=this._generateC2CMessage(e);this._updateMessageProfile(e);let t=1===e.isModified;s.isMessageSentByCurrentInstance(e)?e.isModified=t:t=!1,e.isOnlineMessage()?(e._onlineOnlyFlag=!0,s.isMessageSentByCurrentInstance(e)||n.push(e)):ji(e)&&(s.storeConversationMessage(e)&&Ki({conversationUpdateFields:i,message:e}),s.isMessageSentByCurrentInstance(e)&&!t||n.push(e))}),{conversationUpdateFieldList:[...i.values()],messages:n}}_emitMessageEventsAfterReceiveNewMessage(e){var{messages:e=[]}=(null==(e=e.result)?void 0:e[Rs.HANDLE_C2C_NEW_MESSAGE])||{};this._emitMessageEvents(e)}_emitMessageEventsAfterSyncUnreadMessage(e){var{messages:e=[]}=(null==(e=e.result)?void 0:e[Rs.UNREAD_MESSAGE_SYNC])||{};this._emitMessageEvents(e)}_emitMessageEvents(e){var t=(null==e?void 0:e.filter(e=>!0===(null==e?void 0:e.isModified)))||[],t=(0<t.length&&es.notificationCenter.emitOuterEvent("onMessageModified",{name:"onMessageModified",data:t}),null==e?void 0:e.filter(e=>!(null!=e&&e.isModified)));0<t.length&&es.notificationCenter.emitOuterEvent("onMessageReceived",{name:"onMessageReceived",data:t})}_generateC2CMessage(e){var t=mi.CONV_C2C,e=xi(e),t=es.message.messageFactory.createMessage(Object.assign(Object.assign({},e),{conversationType:t,flow:Ti.IN})),e=e["elements"];return t.setElement(e),t}_updateMessageProfile(r){var s;let o=(es.message||{})["messageDataHandler"],n=null==(s=es.store.get("login"))?void 0:s.userId,{from:i,nick:a,avatar:l,conversationID:c=""}=r;if(i!==n){let i=o.getLatestMsgSentByPeer(c);if(i){let{nick:s,avatar:n}=i;e(a)||e(l)?(r.nick=t(s)?s:r.nick,r.avatar=t(n)?n:r.avatar):a===s&&l===n||(o.updateNickAndAvatarOfSentMessage({conversationID:c,latestNick:a,latestAvatar:l,isSentByMe:!1}),this._updateConversationUserProfile({conversationID:c,nick:a,avatar:l}))}}else{let e=o.getLatestMsgSentByMe(c);!e||a===e.nick&&l===e.avatar||o.updateNickAndAvatarOfSentMessage({conversationID:c,latestNick:a,latestAvatar:l,isSentByMe:!0})}}_updateConversationUserProfile(e){var{conversationID:e,nick:t,avatar:s}=e,{userProfile:n={}}=ci.getConversation(e)||{};n.avatar===s&&n.nick===t||ci.updateConversation(e,{userProfile:Object.assign(Object.assign({},n),{nick:t,avatar:s})})}_updateMessageListDueToModify(e){var t=e["conversationID"],{isUpdated:s,message:n}=es.message.messageDataHandler.modifyConversationMessage(t,e);!0===s&&es.notificationCenter.emitOuterEvent("onMessageModified",{name:"onMessageModified",data:[n]}),es.notificationCenter.emitInnerEvent("ModifyMessageSuccess",e),uo(t,e)}_handleC2CMessageModify(e){e.C2cMsgModNotifys.forEach(e=>{var t=mi.CONV_C2C,e=Vi(e),{to:s,from:n}=e;let i=""+t+s;s===(null==(s=es.store.get("login"))?void 0:s.userId)&&(i=""+t+n),e=Object.assign({conversationType:t,conversationID:i},e),this._updateMessageListDueToModify(e)})}_dispose(){var e=es["notificationCenter"],e=e["InnerEventSubType"];es.notificationCenter.unSubscribeInnerEvent(as.MESSAGE_PUSH,e.C2C_REALTIME_MESSAGE,this._handleC2CMessagePush,this),es.notificationCenter.unSubscribeInnerEvent(as.MESSAGE_PUSH,e.C2C_MESSAGE_MODIFIED,this._handleC2CMessageModify,this),es.notificationCenter.unSubscribeInnerEvent(as.DESTROY,this._dispose,this)}}class go{init(){var e=es["notificationCenter"],t=e["InnerEventSubType"];ln.getInstance().registerWorkflowStep(Ns.RECEIVE_GROUP_NEW_MESSAGE,Rs.HANDLE_GROUP_NEW_MESSAGE,this._handleGroupMessagePush,this),ln.getInstance().registerWorkflowStep(Ns.RECEIVE_GROUP_NEW_MESSAGE,Rs.EMIT_GROUP_MESSAGE_EVENT,this._emitMessageEvents,this),e.subscribeInnerEvent(as.MESSAGE_PUSH,t.GROUP_REALTIME_MESSAGE,this._executeReceiverNewMessageWorkFlow,this),e.subscribeInnerEvent(as.MESSAGE_PUSH,t.GROUP_MESSAGE_MODIFIED,this._handleGroupMessageModify,this),e.subscribeInnerEvent(as.DESTROY,this._dispose,this)}_executeReceiverNewMessageWorkFlow(e){this._canExecuteReceiverNewMessageWorkFlow(e)&&ln.getInstance().executeWorkflow(Ns.RECEIVE_GROUP_NEW_MESSAGE,e)}_handleGroupMessagePush(e){let t=e.data||{},s=es.message["messageDataHandler"],n=[],i=new Map,r=null==t?void 0:t.GroupMsgArray;return null!=r&&r.forEach(e=>{var t;1!==e.GroupInfo.NotVisible&&(e=this._generateGroupMessage(e),this.updateMessageProfile(e),t=1===e.isModified,s.isMessageSentByCurrentInstance(e)&&(e.isModified=t),e.isOnlineMessage()?(e._onlineOnlyFlag=!0,s.isMessageSentByCurrentInstance(e)||n.push(e)):ji(e)&&s.storeConversationMessage(e)&&(n.push(e),Ki({conversationUpdateFields:i,message:e})))}),{conversationUpdateFieldList:[...i.values()],messages:n}}_emitMessageEvents(e){var e=((null==(e=e.result)?void 0:e[Rs.HANDLE_GROUP_NEW_MESSAGE])||{})["messages"],t=(null==e?void 0:e.filter(e=>!0===(null==e?void 0:e.isModified)))||[],t=(0<t.length&&es.notificationCenter.emitOuterEvent("onMessageModified",{name:"onMessageModified",data:t}),(null==e?void 0:e.filter(e=>!(null!=e&&e.isModified)))||[]);0<t.length&&es.notificationCenter.emitOuterEvent("onMessageReceived",{name:"onMessageReceived",data:t})}_generateGroupMessage(e){var t=mi.CONV_GROUP,e=$i(e),t=es.message.messageFactory.createMessage(Object.assign(Object.assign({},e),{conversationType:t,flow:Ti.IN})),e=e["elements"];return t.setElement(e),t}updateMessageProfile(i){var e;let t=(es.message||{})["messageDataHandler"],s=null==(e=es.store.get("login"))?void 0:e.userId,{from:n,nick:r,avatar:o,conversationID:a="",_elements:l}=i;if(n===s){let e=t.getLatestMsgSentByMe(a);!e||r===e.nick&&o===e.avatar||t.updateNickAndAvatarOfSentMessage({conversationID:a,latestNick:r,latestAvatar:o,isSentByMe:!0})}else if(n===ys.CONV_SYSTEM){let{operationType:e,memberInfoList:t,operatorInfo:s}=l,n={};if(fe(t)?fe(s)||(n=s):[Ms.JOINED,Ms.KICKED,Ms.ADMIN_SET,Ms.ADMIN_CANCELED].includes(e)&&(n=Object.assign({},t[0])),!fe(n)){let{nick:e="",avatar:t=""}=n;i.nick=e,i.avatar=t}}}_updateMessageListDueToModify(e){var t=e["conversationID"],{isUpdated:s,message:n}=es.message.messageDataHandler.modifyConversationMessage(t,e);!0===s&&es.notificationCenter.emitOuterEvent("onMessageModified",{name:"onMessageModified",data:[n]}),uo(t,e)}_handleGroupMessageModify(e){e.GroupMsgModNotifys.forEach(e=>{var t=mi.CONV_GROUP,{topicID:s,groupID:n}=e=Yi(e),s=s||n,e=Object.assign({conversationType:t,conversationID:""+t+s,to:s},e);this._updateMessageListDueToModify(e)})}_dispose(){var e=es["notificationCenter"],{GROUP_REALTIME_MESSAGE:t,GROUP_MESSAGE_MODIFIED:s}=e["InnerEventSubType"];e.unSubscribeInnerEvent(as.MESSAGE_PUSH,t,this._handleGroupMessagePush,this),e.unSubscribeInnerEvent(as.MESSAGE_PUSH,s,this._handleGroupMessageModify,this),e.unSubscribeInnerEvent(as.DESTROY,this._dispose,this)}_canExecuteReceiverNewMessageWorkFlow(e){var{GroupId:e,GroupType:t}=(null==(e=null==(e=null==e?void 0:e.GroupMsgArray)?void 0:e[0])?void 0:e.GroupInfo)||{},t=t===Is.GRP_AVCHATROOM;return!(!li.getGroup(e)&&t)}}var po=new class{constructor(){this.c2cMessageReceiver=new ho,this.groupMessageReceiver=new go}init(){this.c2cMessageReceiver.init(),this.groupMessageReceiver.init()}};let Eo={createCustomMessage:{to:{required:!0,rules:["string"],allowEmpty:!1},conversationType:{required:!0,rules:["string"],allowEmpty:!1},payload:{required:!0,rules:["object"],allowEmpty:!1},cloudCustomData:{required:!1,rules:["string"],allowEmpty:!1},priority:{required:!1,rules:["string"],allowEmpty:!1},customModerationConfigurationID:{required:!1,rules:["string"],allowEmpty:!1}},sendMessage:[{key:"message",required:!0,rules:["object"],allowEmpty:!1},{key:"options",required:!1,rules:["object"],allowEmpty:!1}],createTextMessage:{to:{required:!0,rules:["string"],allowEmpty:!1},conversationType:{required:!0,rules:["string"],allowEmpty:!1,customValidator:e=>!(!e.startsWith("C2C")&&!e.startsWith("GROUP"))||"conversationType is invalid."},payload:{required:!0,rules:["object"],allowEmpty:!1,customValidator:e=>{return"string"==typeof(null==e?void 0:e.text)&&("string"!=typeof e.text||0!==(null==(e=null==e?void 0:e.text)?void 0:e.length))||"payload.text must be a string"}}}},fo={createCustomMessage:!0,sendMessage:!0,modifyMessage:!0};var mo=new class{getGroupRoamingMessagesByAnchor(r){return de(this,void 0,void 0,function*(){try{var{conversationID:t,count:s,direction:l,sequence:c,messageSequenceList:e,getType:i}=r,u=t.replace(ms.CONV_GROUP,""),d=[];let a=c;if(l===hs.BACKWARD){if("number"!=typeof c)return{messageList:[],hasNoMoreHistoryMessage:!1,nextReqMessageIDFromServer:""};a=c+s-1}var _=yield function(o){return de(this,void 0,void 0,function*(){var{groupID:e,count:t,messageSequence:s,messageSequenceList:i,getType:r}=o,e={GroupId:e,ReqMsgNumber:t,WithRecalledMsg:1,Version:1,GetType:r};return s&&(e.ReqMsgSeq=s),n(i)&&0<i.length&&(e.ReqMsgSeqList=i),yield pn({servcmd:"group_open_http_svc.group_msg_get",data:e})})}({groupID:u,count:s,messageSequence:a,messageSequenceList:e,getType:i});if(_){let{RspMsgList:s=[],NextReqMsgSeq:e=0,IsFinished:t,InvisibleMsgSeq:n}=_,i=`groupID:${u} sequence:${c} reqSeq:${a} direction:${l} complete:${t} nextSequence:${e} remoteMsgCount:${s.length} invisibleSequenceList:`+n,r=[];for(let t=0;t<s.length;t++){var h=s[t];h.From_Account===ys.CONV_SYSTEM&&d.push(h);let e=this._parseMessage(h);r.push(e)}r.reverse();let o=t===yi;l===hs.BACKWARD&&(o=r[r.length-1].sequence>=c);var g=Hi(r);return es.ssoLog.info("getGroupRoamingMessagesByAnchor",i),{messageList:g,invisibleSequenceList:n,nextReqMessageIDFromServer:e,hasNoMoreHistoryMessage:o,serverGroupTipList:d}}}catch(e){var{errorCode:t,errorInfo:s}=e||{};throw new Xs({code:t,message:s})}})}_parseMessage(e){var t=ms.CONV_GROUP,e=(4===e.Event&&(e.MsgBody.MsgType=ys.MSG_GRP_TIP),$i(e)),t=Pi.createMessage(Object.assign(Object.assign({},e),{conversationType:t,flow:"in"}));return t.setElement(e.elements),t}};class So{constructor(){this.messageHelper=zi,this.messageFactory=Pi,this.messageSender=new ro,this.messageAction=new _o,this.messageReceiver=po,this.messageDataHandler=lo,this.messageHistory=mo,this.messageSender.init(),this.messageFactory.init(),this.messageAction.init(),this.messageReceiver.init(),this.messageDataHandler.init(),an({auth:fo,params:Eo})}}let vo="Tag_Profile_IM_",Io={NICK:vo+"Nick",GENDER:vo+"Gender",BIRTHDAY:vo+"BirthDay",LOCATION:vo+"Location",SELFSIGNATURE:vo+"SelfSignature",ALLOWTYPE:vo+"AllowType",LANGUAGE:vo+"Language",AVATAR:vo+"Image",MESSAGESETTINGS:vo+"MsgSettings",ADMINFORBIDTYPE:vo+"AdminForbidType",LEVEL:vo+"Level",ROLE:vo+"Role"},Co="Tag_Profile_Custom",Mo="profileCustomField",To="USER_STATUS",yo=1,Oo=1e3,Ao={userID:"",nick:"",gender:"Gender_Type_Unknown",birthday:0,location:"",selfSignature:"",allowType:"AllowType_Type_AllowAny",language:0,avatar:"",messageSettings:0,adminForbidType:"AdminForbid_Type_None",level:0,role:0,lastUpdatedTime:0,profileCustomField:[]},No=new Map([[Io.NICK,"nick"],[Io.GENDER,"gender"],[Io.BIRTHDAY,"birthday"],[Io.LOCATION,"location"],[Io.SELFSIGNATURE,"selfSignature"],[Io.ALLOWTYPE,"allowType"],[Io.LANGUAGE,"language"],[Io.AVATAR,"avatar"],[Io.MESSAGESETTINGS,"messageSettings"],[Io.ADMINFORBIDTYPE,"adminForbidType"],[Io.LEVEL,"level"],[Io.ROLE,"role"]]);var Ko,Ho,jo,Ro=new class{createProfile(e,t){let s={userID:e,profileCustomField:[]};return t.forEach(e=>{var{tag:e,value:t}=e;e&&-1<e.indexOf(Co)?s.profileCustomField.push({key:e,value:t}):No.has(e)&&(s[No.get(e)]=t)}),Object.assign(Object.assign({},Ao),s)}parseProfileItem(e=[]){let t=[];return e.forEach(e=>{t.push({tag:e.Tag,value:e.Value})}),t}parseProfileList(e=[]){let t=[];return e.forEach(e=>{t.push({tag:e.Tag,value:e.ValueBytes})}),t}convertParamsToProfile(t){let s=[];return Object.keys(t).forEach(e=>{e!==Mo&&s.push({tag:Io[e.toUpperCase()],value:t[e]})}),t.profileCustomField&&n(t.profileCustomField)&&t.profileCustomField.forEach(e=>{s.push({tag:e.key,value:e.value})}),s}normalizeProfileFields(e){let n={},i=[];return e.forEach(e=>{var{tag:t,value:s}=e;if(t&&-1<t.indexOf(Co)&&i.push({key:t,value:s}),No.has(t)&&void 0!==s){let e=No.get(t);n[e]=s}}),0<i.length&&(n.profileCustomField=i),n}};let Do=es.common["generateProtocolData"];function Po(n){return de(this,void 0,void 0,function*(){let e="profile.portrait_get_all",t={From_Account:Sn(),UserItem:[]};n.forEach(e=>{t.UserItem.push({CustomSequence:0,StandardSequence:0,To_Account:e})});var r=Do({servcmd:e,data:t}),s=r.head.seq+e,r=yield es.channel.sendPacket(r,{requestId:s});if(r){let{ActionStatus:e,ErrorCode:t,ErrorDisplay:s,ErrorInfo:n,UserProfileItem:i}=r,o=[];return i.map(e=>{var{To_Account:e,CustomSequence:t,ResultCode:s,ResultInfo:n,StandardSequence:i,ProfileItem:r}=e,r=Ro.parseProfileItem(r);o.push({userId:e,customSequence:t,resultCode:s,resultInfo:n,standardSequence:i,profileItem:r})}),{actionStatus:e,errorCode:t,errorDisplay:s,errorInfo:n,userProfile:o}}})}function bo(e){return di.getFriendMap().has(e)}let wo=es.utils["isEmpty"];class Lo{constructor(){this._strangerProfileMap=new Map}init(){hi.getInstance().registerApi({apiName:"getMyProfile",context:this}),hi.getInstance().registerApi({apiName:"getUserProfile",context:this}),hi.getInstance().registerApi({apiName:"updateMyProfile",context:this}),this.createProfile=Ro.createProfile.bind(Ro);var e=es["notificationCenter"];ln.getInstance().registerWorkflowStep(Ns.SYNC_SERVER_INFO_AFTER_LOGIN,Rs.USER_PROFILE_SYNC,this.getMyProfileCacheThenServer,this),e.subscribeInnerEvent(as.MESSAGE_PUSH,e.InnerEventSubType.PROFILE_MODIFIED,this._onProfileDataModify,this),e.subscribeInnerEvent(as.LOGOUT,this._reset,this),e.subscribeInnerEvent(as.DESTROY,this._dispose,this)}getMyProfile(){return de(this,void 0,void 0,function*(){try{var e,t=Sn(),s=yield Po([t]);if(s)return e=this._handleProfileFormResponse(s)[0],di.getUserProfileMap().set(t,e),{code:0,data:e}}catch(e){var{errorCode:s,errorInfo:t}=e;throw new Xs({functionName:"getMyProfile",code:s,message:t})}})}getUserProfile(c){return de(this,void 0,void 0,function*(){try{var t=c["userIDList"],{userIdListToRequest:e,profileFromCache:s}=this._filterRequestAndCacheUsers(t);if(0===e.length)return{code:0,data:s,successLog:{message:"userIDList.length:"+t.length}};e.length>Oo&&(es.ssoLog.warn("getUserProfile","userIdListToRequest.length > 1000"),e.length=Oo);var{data:i,error:r}=yield this._batchFetchUserProfiles(e),o=e.length,a=i.length,l=o-a;if(0===s.length&&o===l&&!wo(r))throw r;if(n(i)){i.forEach(e=>{(bo(e.userID)?di.getUserProfileMap():this._strangerProfileMap).set(e.userID,e)});let e=i.concat(s);return{code:0,data:e,successLog:{message:`getUserProfile query:${o} success:${a} fail:${l} from cache:`+s.length}}}}catch(e){t=e["errorCode"];throw new Xs({functionName:"getUserProfile",code:t})}})}getMyProfileCacheThenServer(){return de(this,void 0,void 0,function*(){var e=Sn(),e=di.getUserProfileMap().has(e);return e?{code:0,data:e}:this.getMyProfile()})}updateMyProfile(a){return de(this,void 0,void 0,function*(){let t=Sn(),s={};for(let e in a)void 0!==a[e]&&(s[e]=a[e]);var n=Ro.convertParamsToProfile(s);try{let e={From_Account:t,ProfileItem:n};yield function(n){return de(this,void 0,void 0,function*(){let e="profile.portrait_set",t=Do({servcmd:e,data:n}),s=""+t.head.seq+e,i=yield es.channel.sendPacket(t,{requestId:s});if(i){let{ActionStatus:e,ErrorCode:t,ErrorDisplay:s,ErrorInfo:n}=i;return{actionStatus:e,errorCode:t,errorDisplay:s,errorInfo:n}}})}(e);var i=di.getUserProfile(t),r=i?Object.assign(Object.assign({},i),s):Ro.createProfile(t,n),o=!ss(i,r,["lastUpdatedTime"]);return r.lastUpdatedTime=Date.now(),di.getUserProfileMap().set(t,r),o&&this._emitProfileUpdated(r),{code:0,data:r,successLog:{message:"profileArray: "+es.utils.safeStringify(n)}}}catch(e){let{errorCode:t,errorInfo:s}=e;throw new Xs({functionName:"updateMyProfile",code:t,message:s})}})}updateMyNickAndAvatar(i){return de(this,void 0,void 0,function*(){var e=Sn(),t=Date.now(),s=di.getUserProfile(e),n={};(n=s?Object.assign(s,i):Ro.createProfile(e,i)).lastUpdatedTime=t,di.getUserProfileMap().set(e,n)})}_onProfileDataModify(n){var e,t=function(){var{Profile_Account:e,PushType:t,ProfileList:s}=n.ProfileDataMod[0];return{userId:e,pushType:t,profileList:Ro.parseProfileList(s)}}();wo(t)||({isProfileUpdated:t,profile:e}=this._handleProfileModified(t),t&&this._emitProfileUpdated(e))}_emitProfileUpdated(e){es.notificationCenter.emitInnerEvent(as.PROFILE_UPDATE,{name:as.PROFILE_UPDATE,data:[e]}),es.notificationCenter.emitOuterEvent(os.PROFILE_UPDATED,{name:os.PROFILE_UPDATED,data:[e]}),ci.updateConversation("C2C"+(null==e?void 0:e.userID),{userProfile:e})}_dispose(){var e=es["notificationCenter"];e.unSubscribeInnerEvent(as.LOGOUT,this._reset,this),e.unSubscribeInnerEvent(as.MESSAGE_PUSH,e.InnerEventSubType.PROFILE_MODIFIED,this._onProfileDataModify,this),e.unSubscribeInnerEvent(as.DESTROY,this._dispose,this),this._reset()}_handleProfileModified(e){let{userId:t,profileList:s}=e,n=di.getUserProfile(t);if(!(Sn()===t||bo(t)&&n))return{isProfileUpdated:!1,profile:null};let i=Ro.normalizeProfileFields(s),r=Object.keys(i).some(e=>e===Mo?!ss(n.profileCustomField,i.profileCustomField):n[e]!==i[e]);return r?(e=Date.now(),e=Object.assign(Object.assign(Object.assign({},n),i),{lastUpdatedTime:e}),di.getUserProfileMap().set(t,e),{isProfileUpdated:r,profile:e}):{isProfileUpdated:!1,profile:n}}_filterRequestAndCacheUsers(e){let s=[],n=[];return e.forEach(e=>{var t=di.getUserProfileMap().has(e);bo(e)&&t?n.push(di.getUserProfile(e)):this._isStrangerAndProfileValid(e)?n.push(this._strangerProfileMap.get(e)):s.push(e)}),{userIdListToRequest:s,profileFromCache:n}}_handleProfileFormResponse(e){e=e.userProfile;if(!Array.isArray(e))return[];let t=e.filter(e=>"@TLS#NOT_FOUND"!==e.userId&&""!==e.userId&&!wo(e.profileItem)),s=Date.now();return t.map(e=>{e=Ro.createProfile(e.userId,e.profileItem);return e.lastUpdatedTime=s,e})}_isStrangerAndProfileValid(e){var t;return!bo(e)&&({lastUpdatedTime:e=0}=this._strangerProfileMap.get(e)||{},t=(null==(t=es.store.get("cloudConfig"))?void 0:t.stranger_profile_expiration_time)||6e5,Date.now()-e<=t)}_chunkUserIDList(s,n){return Array.from({length:Math.ceil(s.length/n)},(e,t)=>s.slice(t*n,(t+1)*n))}_batchFetchUserProfiles(e){return de(this,void 0,void 0,function*(){let t=[],i=[],r={};return this._chunkUserIDList(e,100).forEach(e=>{t.push(Po(e))}),(yield Promise.allSettled(t)).forEach(s=>{if("fulfilled"===s.status){let e=s.value,t=this._handleProfileFormResponse(e);n(t)&&i.push(...t)}else if("rejected"===s.status){let{code:e,message:t}=s.reason||{};r={errorCode:e,message:t}}}),{data:i,error:r}})}_reset(){di.getUserProfileMap().clear(),this._strangerProfileMap.clear()}}let ko=new Map,Uo=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F"];for(let e=0,t=Uo.length;e<t;e++)ko.set(e,Uo[e]);function Go(e){if(!e)return"";var i=String(e).replace(/[=]+$/,"");let r="";if(i.length%4==1)return"";for(let e,t,s=0,n=0;t=i.charAt(n++);~t&&(e=s%4?64*e+t:t,s++%4)&&(r+=String.fromCharCode(255&e>>(-2*s&6))))t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(t);try{return decodeURIComponent(escape(r))}catch(e){return console.warn(e),""}}let Fo=es.utils["isEmpty"],Bo=es.common["generateProtocolData"];function xo(i){return de(this,void 0,void 0,function*(){var e,t,s="im_open_status.ws_get_user_status",n=Bo({servcmd:s,data:{To_Account:i}}),s=n.head.seq+s,n=yield es.channel.sendPacket(n,{requestId:s});if(n)return{ErrorCode:s,ErrorInfo:n,ErrorList:e=[],UserStatusList:t=[]}=n,{errorCode:s,errorInfo:n,successUserList:t.map(e=>{var{To_Account:e,Status:t,CustomStatus:s}=e;return{userID:e,statusType:t,customStatus:Go(s)}}),failureUserList:e.map(e=>{var{To_Account:e,Invalid_Account:t,ErrorCode:s,ErrorInfo:n}=e;return{userID:Fo(t)?e:t,code:s,message:n}})}})}class Vo{constructor(){this._customStatus=""}init(){var e=es["notificationCenter"];hi.getInstance().registerApi({apiName:"getUserStatus",context:this}),hi.getInstance().registerApi({apiName:"setSelfStatus",context:this}),hi.getInstance().registerApi({apiName:"subscribeUserStatus",context:this}),hi.getInstance().registerApi({apiName:"unsubscribeUserStatus",context:this}),ln.getInstance().registerWorkflowStep(Ns.SYNC_SERVER_INFO_AFTER_RE_ONLINE,Rs.USER_STATUS_UPDATE,this._onReOnline,this),e.subscribeInnerEvent(as.MESSAGE_PUSH,e.InnerEventSubType.USER_STATUS_UPDATE,this._onUserStatusUpdate,this),e.subscribeInnerEvent(as.LOGOUT,this._reset,this),e.subscribeInnerEvent(as.DESTROY,this._dispose,this)}setSelfStatus(s){return de(this,void 0,void 0,function*(){let e=Sn(),t=s["customStatus"];try{return yield function(i){return de(this,void 0,void 0,function*(){let e="im_open_status.ws_set_custom_status",t=Bo({servcmd:e,data:{CustomStatus:i}}),s=""+t.head.seq+e,n=yield es.channel.sendPacket(t,{requestId:s});if(n){let{ErrorCode:e,ErrorInfo:t}=n;return{errorCode:e,errorInfo:t}}})}(t),this._customStatus=t,{code:0,data:{userID:e,statusType:yo,customStatus:t},successLog:{message:"customStatus: "+t}}}catch(e){let{errorCode:t,errorInfo:s}=e;throw new Xs({functionName:"setSelfStatus",code:t,message:s})}})}getUserStatus(s){return de(this,void 0,void 0,function*(){var{userIDList:e=[]}=s;let t={};return this._isOnlyMeInArray(e)&&(t=this._getMyStatus()),t=yield this._getUserStatus(e),Object.assign(Object.assign({},t),{successLog:{message:"userIDList length: "+e.length}})})}setCustomStatus(e){e=Go(e);this._customStatus=e}subscribeUserStatus(i){return de(this,void 0,void 0,function*(){try{var{userIDList:e=[]}=i,t=(this._checkBusinessCapabilityBits("subscribeUserStatus"),this._getMaxUserCount("subscribe")),s=yield function(n){return de(this,void 0,void 0,function*(){var e=es["channel"],t="im_open_status.ws_status_subscribe",s=Bo({servcmd:t,data:{To_Account:n}}),t=s.head.seq+t;return yield e.sendPacket(s,{requestId:t})})}(this._sliceUserIDList(e,t)),n=this._parseResponse(s);return{code:0,data:{failureUserList:n},successLog:{message:`userID length:${e.length} failCount: `+n.length}}}catch(e){t=e["errorCode"];throw new Xs({functionName:"subscribeUserStatus",code:t})}})}unsubscribeUserStatus(i){return de(this,void 0,void 0,function*(){try{this._checkBusinessCapabilityBits("unsubscribeUserStatus");var{userIDList:e=[]}=i,t=this._getMaxUserCount("unsubscribe"),s=yield function(n){return de(this,void 0,void 0,function*(){var e=es["channel"],t="im_open_status.ws_status_unsubscribe",s=0===n.length?{UnsubscribeAll:1}:{To_Account:n},s=Bo({servcmd:t,data:s}),t=s.head.seq+t;return yield e.sendPacket(s,{requestId:t})})}(this._sliceUserIDList(e,t)),n=this._parseResponse(s);return{code:0,data:{failureUserList:n},successLog:{message:`userID length:${e.length} failCount: `+n.length}}}catch(e){t=e["errorCode"];throw new Xs({functionName:"unsubscribeUserStatus",code:t})}})}_onUserStatusUpdate(e){var{UserStatusList:e=[]}=e||{},e=e.map(e=>{var{To_Account:e,Status:t,CustomStatus:s}=e;return{userID:e,statusType:t,customStatus:Go(s)}});this._emitUserStatusUpdatedEvent(e)}_onReOnline(e){var e=Go(e.data.customStatus);this._customStatus!==e&&(this._customStatus=e,e={userID:Sn(),statusType:yo,customStatus:e},this._emitUserStatusUpdatedEvent(e))}_emitUserStatusUpdatedEvent(e){es.notificationCenter.emitOuterEvent(os.USER_STATUS_UPDATED,{name:os.USER_STATUS_UPDATED,data:e})}_sliceUserIDList(e,t){return e.slice(0,t)}_parseResponse(e){var{ErrorList:e=[]}=e;return e.map(e=>{var{To_Account:e,Invalid_Account:t,ErrorCode:s,ErrorInfo:n}=e;return{userID:es.utils.isEmpty(t)?e:t,code:s,message:n}})}_checkBusinessCapabilityBits(e){if(!es.store.get("commercialConfig").get(To))throw new Xs({functionName:e,code:Os.NO_USE,replacement1:e})}_getMaxUserCount(e){var t=es.store.get("cloudConfig")||{},{key:e,default:s}={query:{key:"status_query_count",default:500},subscribe:{key:"status_sub_count",default:100},unsubscribe:{key:"status_unsub_count",default:100}}[e],t=t[e]||s;return parseInt(t,10)}_getMyStatus(){return{code:0,data:{successUserList:[{userID:Sn(),statusType:yo,customStatus:this._customStatus}],failureUserList:[]}}}_getUserStatus(n){return de(this,void 0,void 0,function*(){try{this._checkBusinessCapabilityBits("getUserStatus");var t=this._getMaxUserCount("query"),{successUserList:e,failureUserList:s}=(yield xo(this._sliceUserIDList(n,t)))||{};return{code:0,data:{successUserList:e,failureUserList:s}}}catch(e){t=e["errorCode"];throw new Xs({functionName:"getUserStatus",code:t})}})}_isOnlyMeInArray(e){var t=Sn();return 1===e.length&&-1<e.indexOf(t)}_dispose(){var e=es["notificationCenter"];e.unSubscribeInnerEvent(as.MESSAGE_PUSH,e.InnerEventSubType.USER_STATUS_UPDATE,this._onUserStatusUpdate,this),e.unSubscribeInnerEvent(as.DESTROY,this._dispose,this),e.unSubscribeInnerEvent(as.LOGOUT,this._reset,this),this._reset()}_reset(){this._customStatus=""}}let $o={getUserProfile:{userIDList:{required:!0,rules:["array"],allowEmpty:!1}},updateMyProfile:{nick:{required:!1,rules:["string"],allowEmpty:!0},avatar:{required:!1,rules:["string"],allowEmpty:!0},gender:{required:!1,rules:["string"],allowEmpty:!0},selfSignature:{required:!1,rules:["string"],allowEmpty:!0},allowType:{required:!1,rules:["string"],allowEmpty:!0},birthday:{required:!1,rules:["number"],allowEmpty:!1},language:{required:!1,rules:["string"],allowEmpty:!0},messageSettings:{required:!1,rules:["string"],allowEmpty:!0},adminForbidType:{required:!1,rules:["string"],allowEmpty:!0},level:{required:!1,rules:["number"],allowEmpty:!1},role:{required:!1,rules:["number"],allowEmpty:!0},profileCustomField:{required:!1,rules:["array"],allowEmpty:!0,customValidator:function(e){for(var t of e){if("object"!=typeof t)return"Each item in profileCustomField must be an object";if("string"!=typeof(null==t?void 0:t.key))return"Each item.key in profileCustomField must be a string";if(null==t||!t.key.startsWith(Co))return'Each item.key in profileCustomField must start with "Tag_Profile_Custom"'}return!0}}},setSelfStatus:{customStatus:{required:!0,rules:["string"],allowEmpty:!0}},getUserStatus:{userIDList:{required:!0,rules:["array"],allowEmpty:!1}},subscribeUserStatus:{userIDList:{required:!0,rules:["array"],allowEmpty:!1}},unsubscribeUserStatus:{userIDList:{required:!1,rules:["array"],allowEmpty:!0}}},qo={getMyProfile:!0,getUserProfile:!0,updateMyProfile:!0,setSelfStatus:!0,getUserStatus:!0,subscribeUserStatus:!0,unsubscribeUserStatus:!0};class Wo{constructor(){this.userProfile=new Lo,this.userStatus=new Vo,this.userProfile.init(),this.userStatus.init(),an({auth:qo,params:$o})}}function Yo(s){var n=[];if(t(s)){var i=s.length;if(0!==i)for(let e=i-1;0<=e;e--)"1"===s[e]&&n.push(2**(i-e-1))}return n}!function(e){e.NOT_START="notStart",e.PENDING="pending",e.RESOLVED="resolved",e.REJECTED="rejected"}(Ko=Ko||{}),function(e){e[e.C2C=1]="C2C",e[e.GROUP=2]="GROUP"}(Ho=Ho||{}),function(e){e[e.C2C=8]="C2C",e[e.GROUP=2]="GROUP"}(jo=jo||{});class zo{constructor(){this._name="SyncConversationHandler",this._pagingStatus=Ko.NOT_START,this._pagingTimeStamp=0,this._pagingStartIndex=0,this._pagingPinnedTimeStamp=0,this._pagingPinnedStartIndex=0}init(){var e=es["notificationCenter"];ln.getInstance().registerWorkflowStep(Ns.SYNC_SERVER_INFO_AFTER_RE_ONLINE,Rs.CONVERSATION_RECOVER,this._syncConversationList,this),ln.getInstance().registerWorkflowStep(Ns.SYNC_SERVER_INFO_AFTER_LOGIN,Rs.CONVERSATION_LIST_SYNC,this._syncConversationListAfterLogin,this),e.subscribeInnerEvent(as.LOGOUT,this._reset,this),e.subscribeInnerEvent(as.DESTROY,this._dispose,this),es.ssoLog.debug(this._name+".init")}isSyncCompleted(){return this._pagingStatus===Ko.RESOLVED}_syncConversationListAfterLogin(){return de(this,void 0,void 0,function*(){return this._pagingStatus=Ko.NOT_START,this._pagingTimeStamp=0,this._pagingStartIndex=0,this._pagingPinnedTimeStamp=0,this._pagingPinnedStartIndex=0,this._syncConversationList()})}_syncConversationList(){return de(this,void 0,void 0,function*(){let{ssoLog:t,utils:{safeStringify:s}}=es;t.debug("_syncConversationList","start");try{let e=yield this._pagingGetConversationList(!0);this._pagingStatus=Ko.RESOLVED;var{conversationList:n=[]}=e||{};return t.info("_syncConversationList","success count:"+n.length),e}catch(e){var{errorCode:n,errorInfo:i}=e,n=new Xs({code:n,message:i});t.error("_syncConversationList","fail "+s(e),{error:n})}})}_pagingGetConversationList(u){return de(this,void 0,void 0,function*(){try{var e,t=[],s=(this._pagingStatus=Ko.PENDING,yield function(r){return de(this,void 0,void 0,function*(){var{fromAccount:e,pagingTimeStamp:t,pagingStartIndex:s,pagingPinnedTimeStamp:n,pagingPinnedStartIndex:i}=r;return pn({servcmd:"recentcontact.page_get",data:{AssistFlags:31,MsgAssistFlags:15,OrderType:1,From_Account:e,StartIndex:s,TimeStamp:t,TopStartIndex:i,TopTimeStamp:n}})})}({fromAccount:Sn(),pagingTimeStamp:u?this._pagingTimeStamp:0,pagingStartIndex:u?this._pagingStartIndex:0,pagingPinnedTimeStamp:u?this._pagingPinnedTimeStamp:0,pagingPinnedStartIndex:u?this._pagingPinnedStartIndex:0})),{CompleteFlag:n,SessionItem:i=[],TimeStamp:r,StartIndex:o,TopTimeStamp:a,TopStartIndex:l}=s||{};if(0<i.length){let e=this._getConversationOptions(i);t.push(...e);var c=es["notificationCenter"];c.emitInnerEvent(as.SYNC_CONVERSATION_LIST,{conversationUpdateFieldList:e})}return this._pagingTimeStamp=r,this._pagingStartIndex=o,this._pagingPinnedTimeStamp=a,this._pagingPinnedStartIndex=l,1!==n&&(e=(yield this._pagingGetConversationList(u))["conversationList"],t.push(...e)),{conversationList:t}}catch(e){throw e}})}_getConversationOptions(e){let{isUndefined:t}=es["utils"],s=this._convertConversationKey(e);return this._filterValidConversations(s).map(e=>(t(e.lastMsg)&&(e.lastMsg={elements:[]}),e.type===Ho.C2C?this._assembleC2COption(e):this._assembleGroupOption(e)))}_filterValidConversations(e){return e.filter(({type:e,userID:t})=>e===Ho.C2C&&!function(e){let t;return"@TLS#ERROR"===(t=e.startsWith(ys.CONV_C2C)?e.replace(ys.CONV_C2C,""):t)||"@TLS#NOT_FOUND"===t}(t)||2===e)}_assembleC2COption(e){var t,s=this._createUserprofile(e);return{conversationID:""+ys.CONV_C2C+e.userID,type:ys.CONV_C2C,lastMessage:{lastTime:e.time,lastSequence:e.sequence,fromAccount:e.lastC2CMsgFromAccount,type:null!=(t=e.lastMsg)&&t.elements[0]?null==(t=e.lastMsg)?void 0:t.elements[0].type:null,payload:null!=(t=e.lastMsg)&&t.elements[0]?this._amendLayersOverLimitProp(e.lastMsg.elements[0].content):null,cloudCustomData:(null==(t=e.lastMsg)?void 0:t.cloudCustomData)||"",isRevoked:e.lastMessageFlag===jo.C2C,onlineOnlyFlag:!1,nick:"",nameCard:"",version:0,isPeerRead:this._computeIsPeerRead(e),revoker:(null==(t=null==(t=e.lastMsg)?void 0:t.revokerInfo)?void 0:t.revoker)||null},unreadCount:0,userProfile:s,peerReadTime:e.peerReadTime,isPinned:1===e.isPinned,customData:e.customMark||"",markList:Yo(e.standardMark),conversationGroupList:[],remark:e.friendRemark||"",messageRemindType:this._transMsgRemindType(e.messageRemindType)}}_createUserprofile(e){var{userID:e,nick:t,peerAvatar:s}=e,t=[{tag:"Tag_Profile_IM_Nick",value:t},{tag:"Tag_Profile_IM_Image",value:s}];return null==(s=es.user.userProfile)?void 0:s.createProfile(e,t)}_computeIsPeerRead(e){var{lastC2CMsgFromAccount:e,time:t,c2cPeerReadTime:s}=e;return e===Sn()&&t<=s}_assembleGroupOption(e){var t;return{conversationID:""+ys.CONV_GROUP+e.groupID,type:ys.CONV_GROUP,lastMessage:Object.assign(Object.assign({lastTime:e.time,lastSequence:e.sequence,fromAccount:e.msgGroupFromAccount},this._patchTypeAndPayload(e)),{cloudCustomData:(null==(t=e.lastMsg)?void 0:t.cloudCustomData)||"",isRevoked:e.lastMessageFlag===jo.GROUP,onlineOnlyFlag:!1,nick:e.msgGroupFromNickName||"",nameCard:e.msgGroupFromCardName||"",revoker:(null==(t=null==(t=e.lastMsg)?void 0:t.revokerInfo)?void 0:t.revoker)||null}),groupProfile:{groupID:e.groupID,name:e.groupNick,avatar:e.groupImage,type:e.groupType,nextMessageSeq:e.nextMessageSeq},unreadCount:this._computeGroupUnreadCount(e),peerReadTime:0,isPinned:1===e.isPinned,version:0,customData:e.customMark||"",markList:Yo(e.standardMark),conversationGroupList:[],messageRemindType:this._transMsgRemindType(e.messageRemindType),subType:e.groupType}}_convertConversationKey(e){return e.map(e=>({type:e.Type,userID:e.To_Account,nick:e.C2cNick,peerAvatar:e.C2cImage,time:e.MsgTimeStamp,sequence:e.MsgSeq,lastC2CMsgFromAccount:e.LastC2cMsgFrom_Account,lastMsg:this._convertLastMsgKey(e.LastMsg),lastMessageFlag:e.LastMsgFlags,c2cPeerReadTime:e.C2cPeerReadTime,peerReadTime:e.C2cPeerReadTime,friendRemark:e.C2cRemark,isPinned:e.TopFlags,standardMark:e.StandardMark,customMark:e.CustomMark,messageRemindType:e.MsgRecvOption,groupID:e.ToAccount,groupNick:e.GroupNick,groupImage:e.GroupImage,groupType:e.GroupType,nextMessageSeq:e.GroupNextMsgSeq,msgGroupFromAccount:e.MsgGroupFrom_Account,msgGroupFromNickName:e.MsgGroupFromNickName,MsgGroupFromCardName:e.MsgGroupFromCardName,unreadCount:e.UnreadMsgCount,noUnreadCount:e.GroupIgnoredUnreadSeqCount}))}_convertLastMsgKey(s){var e,t,n=es["utils"]["isEmpty"];if(n(s))return null;let i="",r=null;if(!n(s.GroupTips)){let{From_Account:e,GroupName:t}=(null==(n=s.GroupTips)?void 0:n.GroupInfo)||{};i=ys.MSG_GRP_TIP,r=Object.assign(Object.assign({},this._parseContent(i,s.GroupTips.MsgBody)),{groupProfile:{from:e,groupName:t}})}return s.MsgBody&&(i=null==(e=s.MsgBody[0])?void 0:e.MsgType,r=this._parseContent(i,s.MsgBody[0])),{event:s.Event,elements:[{type:i,content:r,cloudCustomData:s.CloudCustomData}],revokerInfo:{revoker:null==(t=s.RevokerInfo)?void 0:t.Revoker_Account}}}_parseContent(e,t){return t&&((e=es.message.messageFactory.getElementClass(e))?null==(e=e.parseServerPushElement(t))?void 0:e.content:t)}_amendLayersOverLimitProp(e){var t=e["LayersOverLimit"];return ue(e,["LayersOverLimit"]).layersOverLimit=1===t,e}_transMsgRemindType(e){let t="";return 0===e?t=ys.MSG_REMIND_ACPT_AND_NOTE:1===e?t=ys.MSG_REMIND_DISCARD:2===e?t=ys.MSG_REMIND_ACPT_NOT_NOTE:3===e&&(t=ys.NOT_RECEIVE_OFFLINE_PUSH_EXCEPT_AT),t}_patchTypeAndPayload(e){var t=es["utils"]["isUndefined"],{event:e,elements:s=[]}=e.lastMsg||{};return t(e)?{type:s[0]?s[0].type:null,payload:s[0]?this._amendLayersOverLimitProp(s[0].content):null}:{type:ys.MSG_GRP_TIP,payload:(null==(t=null==s?void 0:s[0])?void 0:t.content)||{}}}_computeGroupUnreadCount(e){var{unreadCount:e=0,noUnreadCount:t=0}=e,e=e-t;return 0<e?e:0}_reset(){this._pagingStatus=Ko.NOT_START,this._pagingTimeStamp=0,this._pagingStartIndex=0,this._pagingPinnedTimeStamp=0,this._pagingPinnedStartIndex=0}_dispose(){this._reset();var e=es["notificationCenter"];e.unSubscribeInnerEvent(as.LOGOUT,this._reset,this),e.unSubscribeInnerEvent(as.DESTROY,this._dispose,this)}}class Zo{constructor(){this.syncConversationHandler=new zo,this.syncConversationHandler.init()}}es.ssoLog.debug("TencentCloudLiteChat.VERSION:"+ot);var Xo={create:function(e){var{SDKAppID:e,testEnv:t=!1,devMode:s=!1,unlimitedAVChatRoom:n=!1,scene:i="",oversea:r=!1,instance:o,disableIndependentDomain:a=!1}=e,l=e;if("number"!=typeof l&&(e=Number(l),Number.isNaN(e)))return console.error("Create SDK instance failed. Failed to parse the SDKAppID, please check the arguments"),null;if(l=Number(l),un.has(l))return un.get(l);let c=null;if(o)(c=o)._workflowManager&&ln.setInstance(c._workflowManager),c._pluginManager&&c._pluginManager.installBuiltInPlugin(oi),!o.isReady()||null!=(o=(e=ln.getInstance()).executeWorkflow)&&o.call(e,Ns.SYNC_SERVER_INFO_AFTER_LOGIN);else{let e=""+(u()+u())+u()+u()+u()+u()+u()+u();es.init({sdkAppId:l,instanceId:e,testEnv:t,devMode:s,unlimitedAVChatRoom:n,disableIndependentDomain:a,scene:i,oversea:r,sdkEdition:ii}),ln.getInstance().init(),es.message=new So,es.user=new Wo,es.login=new fi,es.conversation=new Zo,ai.getInstance().installBuiltInPlugin(oi),(c=hi.getInstance().exposeApiForClient())._workflowManager=ln.getInstance(),c._pluginManager=ai.getInstance()}function u(){return(65536*(1+Math.random())|0).toString(16).substring(1)}return un.set(l,c),c},TSignaling:cs,EVENT:os,VERSION:ot,TYPES:ys};export{Xo as default};